WinXP-Examples: SysMgmt/MMC/Simple/registry.Cpp Source File

  • Main Page
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members
  • SysMgmt
  • MMC
  • Simple

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "globals.h"
00026
00027 ////////////////////////////////////////////////////////
00028 //
00029 // Internal helper functions prototypes
00030 //
00031
00032 // Set the given key and its value.
00033 BOOL setKeyAndValue(const _TCHAR* pszPath,
00034                     const _TCHAR* szSubkey,
00035                     const _TCHAR* szValue) ;
00036
00037 // Set the given key and its value in the MMC Snapin location
00038 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00039                           const _TCHAR* szSubkey,
00040                           const _TCHAR* szName,
00041                           const _TCHAR* szValue);
00042
00043 // Set the given valuename under the key to value
00044 BOOL setValue(const _TCHAR* szKey,
00045               const _TCHAR* szValueName,
00046               const _TCHAR* szValue);
00047
00048 // Delete szKeyChild and all of its descendents.
00049 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // Constants
00054 //
00055
00056 // Size of a CLSID as a string
00057 //const int CLSID_STRING_SIZE = 39 ;
00058
00059 /////////////////////////////////////////////////////////
00060 //
00061 // Public function implementation
00062 //
00063
00064 //
00065 // Register the component in the registry.
00066 //
00067 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00068                        const CLSID& clsid,         // Class ID
00069                        const _TCHAR* szFriendlyName)       //   IDs
00070 {
00071     // Get server location.
00072     _TCHAR szModule[512] ;
00073     DWORD dwResult =
00074         ::GetModuleFileName(hModule,
00075         szModule,
00076         sizeof(szModule)/sizeof(_TCHAR)) ;
00077
00078     assert(dwResult != 0) ;
00079
00080     // Get CLSID
00081     LPOLESTR wszCLSID = NULL ;
00082     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00083
00084     assert(SUCCEEDED(hr)) ;
00085
00086   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00087
00088     // Build the key CLSID\\{...}
00089     _TCHAR szKey[64] ;
00090     _tcscpy(szKey, _T("CLSID\\")) ;
00091   _tcscat(szKey, pszCLSID) ;
00092
00093     // Add the CLSID to the registry.
00094     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00095
00096     // Add the server filename subkey under the CLSID key.
00097     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00098
00099     // set the threading model
00100     _tcscat(szKey, _T("\\InprocServer32"));
00101     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00102
00103     // Free memory.
00104     CoTaskMemFree(wszCLSID) ;
00105
00106     return S_OK ;
00107 }
00108
00109 //
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00113 {
00114     // Get CLSID
00115     LPOLESTR wszCLSID = NULL ;
00116     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00117
00118
00119     // Build the key CLSID\\{...}
00120     _TCHAR szKey[64] ;
00121     _tcscpy(szKey, _T("CLSID\\")) ;
00122
00123   MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00124   _tcscat(szKey, pszT) ;
00125
00126     // Delete the CLSID Key - CLSID\{...}
00127     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00128     assert((lResult == ERROR_SUCCESS) ||
00129          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00130
00131     // Free memory.
00132     CoTaskMemFree(wszCLSID) ;
00133
00134     return S_OK ;
00135 }
00136
00137 //
00138 // Register the snap-in in the registry.
00139 //
00140 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00141                        const _TCHAR* szNameString,   // NameString
00142                        const CLSID& clsidAbout,   // Class Id for About Class
00143                        const BOOL fSupportExtensions)
00144 {
00145     // Get CLSID
00146     LPOLESTR wszCLSID = NULL ;
00147     LPOLESTR wszAboutCLSID = NULL;
00148     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00149
00150   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00151
00152
00153     // Add the CLSID to the registry.
00154     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00155     setSnapInKeyAndValue(pszCLSID, _T("StandAlone"), NULL, NULL);
00156
00157     if (IID_NULL != clsidAbout) {
00158         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00159     MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00160         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00161   }
00162
00163     if (fSupportExtensions) {
00164         // Build the key NodeType
00165         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00166
00167         _TCHAR szKey[64] ;
00168         _tcscpy(szKey, pszCLSID) ;
00169         _tcscat(szKey, _T("\\NodeTypes")) ;
00170         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00171     }
00172
00173     // Free memory.
00174     CoTaskMemFree(wszCLSID) ;
00175     if (IID_NULL != clsidAbout)
00176         CoTaskMemFree(wszAboutCLSID);
00177
00178     return S_OK ;
00179 }
00180
00181 //
00182 // Unregister the snap-in in the registry.
00183 //
00184 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00185 {
00186     _TCHAR szKeyBuf[1024];
00187     LPOLESTR wszCLSID = NULL;
00188
00189     // Get CLSID
00190     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00191   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00192
00193     // Load the buffer with the Snap-In Location
00194     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00195
00196     // Copy keyname into buffer.
00197     _tcscat(szKeyBuf, _T("\\"));
00198     _tcscat(szKeyBuf, pszCLSID);
00199
00200     // Delete the CLSID Key - CLSID\{...}
00201     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00202     assert((lResult == ERROR_SUCCESS) ||
00203          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00204
00205     // free the memory
00206     CoTaskMemFree(wszCLSID);
00207
00208     return S_OK;
00209 }
00210
00211 //
00212 // Delete a key and all of its descendents.
00213 //
00214 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00215                         const _TCHAR* lpszKeyChild)  // Key to delete
00216 {
00217     // Open the child.
00218     HKEY hKeyChild ;
00219     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00220         KEY_ALL_ACCESS, &hKeyChild) ;
00221     if (lRes != ERROR_SUCCESS)
00222     {
00223         return lRes ;
00224     }
00225
00226     // Enumerate all of the decendents of this child.
00227     FILETIME time ;
00228     _TCHAR szBuffer[256] ;
00229     DWORD dwSize = 256 ;
00230     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00231         NULL, NULL, &time) == S_OK)
00232     {
00233         // Delete the decendents of this child.
00234         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00235         if (lRes != ERROR_SUCCESS)
00236         {
00237             // Cleanup before exiting.
00238             RegCloseKey(hKeyChild) ;
00239             return lRes;
00240         }
00241         dwSize = 256 ;
00242     }
00243
00244     // Close the child.
00245     RegCloseKey(hKeyChild) ;
00246
00247     // Delete this child.
00248     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00249 }
00250
00251 //
00252 // Create a key and set its value.
00253 //   - This helper function was borrowed and modifed from
00254 //     Kraig Brockschmidt's book Inside OLE.
00255 //
00256 BOOL setKeyAndValue(const _TCHAR* szKey,
00257                     const _TCHAR* szSubkey,
00258                     const _TCHAR* szValue)
00259 {
00260     HKEY hKey;
00261     _TCHAR szKeyBuf[1024] ;
00262
00263     // Copy keyname into buffer.
00264     _tcscpy(szKeyBuf, szKey) ;
00265
00266     // Add subkey name to buffer.
00267     if (szSubkey != NULL)
00268     {
00269         _tcscat(szKeyBuf, _T("\\")) ;
00270         _tcscat(szKeyBuf, szSubkey ) ;
00271     }
00272
00273     // Create and open key and subkey.
00274     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00275         szKeyBuf,
00276         0, NULL, REG_OPTION_NON_VOLATILE,
00277         KEY_ALL_ACCESS, NULL,
00278         &hKey, NULL) ;
00279     if (lResult != ERROR_SUCCESS)
00280     {
00281         return FALSE ;
00282     }
00283
00284     // Set the Value.
00285     if (szValue != NULL)
00286     {
00287         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00288             (BYTE *)szValue,
00289             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00290     }
00291
00292     RegCloseKey(hKey) ;
00293     return TRUE ;
00294 }
00295
00296 //
00297 // Open a key value and set it
00298 //
00299 BOOL setValue(const _TCHAR* szKey,
00300               const _TCHAR* szValueName,
00301               const _TCHAR* szValue)
00302 {
00303     HKEY hKey;
00304     _TCHAR szKeyBuf[1024] ;
00305
00306     // Copy keyname into buffer.
00307     _tcscpy(szKeyBuf, szKey) ;
00308
00309     // Create and open key and subkey.
00310     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00311         szKeyBuf,
00312         0, NULL, REG_OPTION_NON_VOLATILE,
00313         KEY_ALL_ACCESS, NULL,
00314         &hKey, NULL) ;
00315     if (lResult != ERROR_SUCCESS)
00316     {
00317         return FALSE ;
00318     }
00319
00320     // Set the Value.
00321     if (szValue != NULL)
00322     {
00323         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00324             (BYTE *)szValue,
00325             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00326     }
00327
00328     RegCloseKey(hKey) ;
00329     return TRUE ;
00330 }
00331
00332 //
00333 // Create a key and set its value.
00334 //   - This helper function was borrowed and modifed from
00335 //     Kraig Brockschmidt's book Inside OLE.
00336 //
00337 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00338                           const _TCHAR* szSubkey,
00339                           const _TCHAR* szName,
00340                           const _TCHAR* szValue)
00341 {
00342     HKEY hKey;
00343     _TCHAR szKeyBuf[1024] ;
00344
00345     // Load the buffer with the Snap-In Location
00346     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00347
00348     // Copy keyname into buffer.
00349     _tcscat(szKeyBuf, _T("\\")) ;
00350     _tcscat(szKeyBuf, szKey) ;
00351
00352     // Add subkey name to buffer.
00353     if (szSubkey != NULL)
00354     {
00355         _tcscat(szKeyBuf, _T("\\")) ;
00356         _tcscat(szKeyBuf, szSubkey ) ;
00357     }
00358
00359     // Create and open key and subkey.
00360     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00361         szKeyBuf,
00362         0, NULL, REG_OPTION_NON_VOLATILE,
00363         KEY_ALL_ACCESS, NULL,
00364         &hKey, NULL) ;
00365     if (lResult != ERROR_SUCCESS)
00366     {
00367         return FALSE ;
00368     }
00369
00370     // Set the Value.
00371     if (szValue != NULL)
00372     {
00373         RegSetValueEx(hKey, szName, 0, REG_SZ,
00374             (BYTE *)szValue,
00375             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00376     }
00377
00378     RegCloseKey(hKey) ;
00379     return TRUE ;
00380 }
00381
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/RegExt.h Source File

  • Files
  • Directories
  • File List
  • File Members
  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

RegExt.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      RegExt.h
00007 //
00008 //  Implementation File:
00009 //      RegExt.cpp
00010 //
00011 //  Description:
00012 //      Definitions of routines for extension registration.
00013 //
00014 //  Author:
00015 //      <name> (<e-mail name>) Mmmm DD, 2003
00016 //
00017 //  Revision History:
00018 //
00019 //  Notes:
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 #pragma once
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Global Function Declarations
00027 /////////////////////////////////////////////////////////////////////////////
00028
00029 //
00030 //  Registration routines.
00031 //
00032
00033 DWORD
00034 RegisterCluAdminClusterExtension(
00035       HCLUSTER      hClusterIn
00036     , const CLSID * pClsidIn
00037     );
00038
00039 DWORD
00040 RegisterCluAdminAllNodesExtension(
00041       HCLUSTER      hClusterIn
00042     , const CLSID * pClsidIn
00043     );
00044
00045 DWORD
00046 RegisterCluAdminAllGroupsExtension(
00047       HCLUSTER      hClusterIn
00048     , const CLSID * pClsidIn
00049     );
00050
00051 DWORD
00052 RegisterCluAdminAllResourcesExtension(
00053       HCLUSTER      hClusterIn
00054     , const CLSID * pClsidIn
00055     );
00056
00057 DWORD
00058 RegisterCluAdminAllResourceTypesExtension(
00059       HCLUSTER      hClusterIn
00060     , const CLSID * pClsidIn
00061     );
00062
00063 DWORD
00064 RegisterCluAdminAllNetworksExtension(
00065       HCLUSTER      hClusterIn
00066     , const CLSID * pClsidIn
00067     );
00068
00069 DWORD
00070 RegisterCluAdminAllNetInterfacesExtension(
00071       HCLUSTER      hClusterIn
00072     , const CLSID * pClsidIn
00073     );
00074
00075 DWORD
00076 RegisterCluAdminResourceTypeExtension(
00077       HCLUSTER      hClusterIn
00078     , LPCWSTR       pwszResourceTypeIn
00079     , const CLSID * pClsidIn
00080     );
00081
00082 //
00083 //  Unregistration routines.
00084 //
00085
00086 DWORD
00087 UnregisterCluAdminClusterExtension(
00088       HCLUSTER      hClusterIn
00089     , const CLSID * pClsidIn
00090     );
00091
00092 DWORD
00093 UnregisterCluAdminAllNodesExtension(
00094       HCLUSTER      hClusterIn
00095     , const CLSID * pClsidIn
00096     );
00097
00098 DWORD
00099 UnregisterCluAdminAllGroupsExtension(
00100       HCLUSTER      hClusterIn
00101     , const CLSID * pClsidIn
00102     );
00103
00104 DWORD
00105 UnregisterCluAdminAllResourcesExtension(
00106       HCLUSTER      hClusterIn
00107     , const CLSID * pClsidIn
00108     );
00109
00110 DWORD
00111 UnregisterCluAdminAllResourceTypesExtension(
00112       HCLUSTER      hClusterIn
00113     , const CLSID * pClsidIn
00114     );
00115
00116 DWORD
00117 UnregisterCluAdminAllNetworksExtension(
00118       HCLUSTER      hClusterIn
00119     , const CLSID * pClsidIn
00120     );
00121
00122 DWORD
00123 UnregisterCluAdminAllNetInterfacesExtension(
00124       HCLUSTER      hClusterIn
00125     , const CLSID * pClsidIn
00126     );
00127
00128 DWORD
00129 UnregisterCluAdminResourceTypeExtension(
00130        HCLUSTER      hClusterIn
00131      , LPCWSTR       pwszResourceTypeIn
00132      , const CLSID * pClsid
00133     );
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_COPY_CHUNK Member List

This is the complete list of members for _COPY_CHUNK, including all inherited members.
Buffer | _COPY_CHUNK
Overlapped | _COPY_CHUNK
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/stream.h Source File

  • File Members
  • Dataaccess
  • oledb
  • sampprov

stream.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module STREAM.H | CStream base object and contained interfaces
00008 // definitions
00009 //
00010 //
00011
00012 #ifndef _STREAM_H_
00013 #define _STREAM_H_
00014
00015
00016 #include "baseobj.h"
00017
00018 // Forward declarations ------------------------------------------------------
00019
00020 class CImpIGetSourceRow;
00021 class CImpIStream;
00022
00023 // Classes -------------------------------------------------------------------
00024
00025 //----------------------------------------------------------------------------
00026 // @class CStream | Stream object. Containing class for all interfaces on the
00027 // Stream Object
00028 //
00029 class CStream : public CBaseObj       //@base public | CBaseObj
00030 {
00031   //  Contained interfaces are friends
00032   friend class CImpIStream;
00033   friend class CImpIGetSourceRow;
00034
00035   protected: //@access protected
00036     //@cmember Object that created this stream
00037     CRow *          m_pParentObj;
00038     //@cmember data buffer
00039     void *          m_pBuffer;
00040     //@cmember data buffer size
00041     DBLENGTH        m_cMaxSize;
00042     //@cmember  current index position in the buffer
00043     ULONG         m_iPos;
00044
00045     // Interface and OLE Variables
00046
00047     //@cmember Reference count
00048     ULONG         m_cRef;
00049     //@cmember Contained IGetSourceRow
00050     CImpIGetSourceRow *   m_pIGetSourceRow;
00051     //@cmember Contained IStream
00052     CImpIStream *     m_pIStream;
00053
00054   public: //@access public
00055     //@cmember Constructor
00056      CStream(LPUNKNOWN);
00057     //@cmember Destructor
00058     ~CStream(void);
00059
00060     //@cmember Intitialization Routine
00061     BOOL FInit(CRow*, ROWBUFF*);
00062
00063     //  Object's base IUnknown
00064     //@cmember Request an Interface
00065     STDMETHODIMP      QueryInterface(REFIID, LPVOID *);
00066     //@cmember Increments the Reference count
00067     STDMETHODIMP_(ULONG)  AddRef(void);
00068     //@cmember Decrements the Reference count
00069     STDMETHODIMP_(ULONG)  Release(void);
00070 };
00071
00072
00073 //----------------------------------------------------------------------------
00074 // @class CImpIGetSourceRow | Contained IGetSourceRow class
00075 //
00076 class CImpIGetSourceRow : public IGetSourceRow  //@base public | IGetSourceRow
00077 {
00078   private: //@access private
00079     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CStream)
00080
00081   public: //@access public
00082     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CStream, CImpIGetSourceRow);
00083     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00084
00085     //  IGetSourceRow members
00086     //@cmember GetSourceRow member
00087         STDMETHODIMP  GetSourceRow(REFIID riid, IUnknown** ppRow);
00088 };
00089
00090
00091 //----------------------------------------------------------------------------
00092 // @class CImpIStream | Contained IStream class
00093 //
00094 class CImpIStream : public IStream        //@base public | IStream
00095 {
00096   private: //@access private
00097     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CStream)
00098
00099   public: //@access public
00100     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CStream, CImpIStream);
00101     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00102
00103     //  ISequentialStream interfaces
00104     //@cmember Read member
00105     STDMETHODIMP Read(
00106         /* [out] */   void* pv,
00107         /* [in] */    ULONG cb,
00108         /* [out] */   ULONG* pcbRead);
00109         //@cmember Write member
00110     STDMETHODIMP Write(
00111         /* [in] */    const void* pv,
00112         /* [in] */    ULONG cb,
00113         /* [out] */   ULONG* pcbWritten);
00114
00115     //IStream interfaces
00116     STDMETHODIMP Seek(
00117                 LARGE_INTEGER dlibMove,     //Offset relative to dwOrigin
00118                 DWORD dwOrigin,         //Specifies the origin for the offset
00119                 ULARGE_INTEGER * plibNewPosition);
00120
00121     STDMETHODIMP SetSize( ULARGE_INTEGER libNewSize);   //Specifies the new size of the stream object
00122
00123     STDMETHODIMP CopyTo(  IStream * pstm,         //Points to the destination stream
00124                 ULARGE_INTEGER cb,        //Specifies the number of bytes to copy
00125                 ULARGE_INTEGER * pcbRead,   //Pointer to the actual number of bytes read from the source
00126                 ULARGE_INTEGER * pcbWritten); //Pointer to the actual number of bytes written to the destination
00127
00128     STDMETHODIMP Commit(  DWORD grfCommitFlags);      //Specifies how changes are committed
00129
00130     STDMETHODIMP Revert(  );
00131
00132     STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset,   //Specifies the byte offset for the beginning of the range
00133                 ULARGE_INTEGER cb,        //Specifies the length of the range in bytes
00134                 DWORD dwLockType);        //Specifies the restriction on accessing the specified range
00135
00136     STDMETHODIMP UnlockRegion(  ULARGE_INTEGER libOffset, //Specifies the byte offset for the beginning of the range
00137                   ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
00138                   DWORD dwLockType);      //Specifies the access restriction previously placed on the range);
00139     STDMETHODIMP Stat(
00140                 STATSTG * pstatstg,       //Location for STATSTG structure
00141                 DWORD grfStatFlag);       //Values taken from the STATFLAG enumeration
00142
00143     STDMETHODIMP Clone(   IStream ** ppstm );       //Points to location for pointer to the new stream object
00144 };
00145
00146
00147 #endif //_STREAM_H_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/StatList.c Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

StatList.c

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1996 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // PROGRAM: STATLIST.c
00009 //
00010 // PURPOSE: Illustrates the use of the PDH counter browsing dialog
00011 //          and the statistical functions of the PDH
00012 //
00013 // PLATFORMS:  Windows NT (only)
00014 //
00015 // FUNCTIONS:
00016 //    WinMain() - calls initialization function, processes message loop
00017 //    InitApplication() - Initializes window data nd registers window
00018 //    InitInstance() -saves instance handle and creates main window
00019 //    WindProc() Processes messages
00020 //    About() - Process menssages for "About" dialog box
00021 //    MyRegisterClass() - Registers the application's window class
00022 //    CenterWindow() -  Centers one window over another
00023 //
00024 // SPECIAL INSTRUCTIONS: N/A
00025 //
00026
00027 // Windows Header Files:
00028 #define WIN32_LEAN_AND_MEAN 1
00029 #include <windows.h>
00030
00031 // C RunTime Header Files
00032 #include <stdlib.h>
00033 #include <memory.h>
00034
00035 // Local Header Files
00036 #include "statlist.h"
00037
00038 // Global Variables:
00039
00040 HINSTANCE hInst;      // current instance
00041 char szAppName[100];  // Name of the app
00042 char szTitle[100];    // The title bar text
00043 char APPNAME[] = "Statlist"; // title of the app
00044
00045 // Foward declarations of functions included in this code module:
00046
00047 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
00048 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
00049 BOOL CenterWindow (HWND, HWND);
00050 LPTSTR   GetStringRes (int id);
00051
00052
00053 //
00054 //  FUNCTION: MyRegisterClass(CONST WNDCLASS*)
00055 //
00056 //  PURPOSE: Registers the window class.
00057 //
00058 //  COMMENTS:
00059 //
00060 //    This function and its usage is only necessary if you want this code
00061 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
00062 // function that was added to Windows 95. It is important to call this function
00063 //    so that the application will get 'well formed' small icons associated
00064 //    with it.
00065 //
00066 ATOM MyRegisterClass(CONST WNDCLASS *lpwc)
00067 {
00068    HANDLE  hMod;
00069    FARPROC proc;
00070    WNDCLASSEX wcex;
00071
00072    hMod = GetModuleHandle ("USER32");
00073    if (hMod != NULL) {
00074
00075 #if defined (UNICODE)
00076       proc = GetProcAddress (hMod, "RegisterClassExW");
00077 #else
00078       proc = GetProcAddress (hMod, "RegisterClassExA");
00079 #endif
00080
00081       if (proc != NULL) {
00082
00083          wcex.style         = lpwc->style;
00084          wcex.lpfnWndProc   = lpwc->lpfnWndProc;
00085          wcex.cbClsExtra    = lpwc->cbClsExtra;
00086          wcex.cbWndExtra    = lpwc->cbWndExtra;
00087          wcex.hInstance     = lpwc->hInstance;
00088          wcex.hIcon         = lpwc->hIcon;
00089          wcex.hCursor       = lpwc->hCursor;
00090          wcex.hbrBackground = lpwc->hbrBackground;
00091          wcex.lpszMenuName  = lpwc->lpszMenuName;
00092          wcex.lpszClassName = lpwc->lpszClassName;
00093
00094          // Added elements for Windows 95:
00095          wcex.cbSize = sizeof(WNDCLASSEX);
00096          wcex.hIconSm = LoadIcon(wcex.hInstance, "SMALL");
00097
00098          return (*proc)(&wcex);//return RegisterClassEx(&wcex) with type ATOM;
00099       }
00100    }
00101    return (RegisterClass(lpwc));
00102 }
00103
00104 //
00105 //  FUNCTION: InitApplication(HANDLE)
00106 //
00107 //  PURPOSE: Initializes window data and registers window class
00108 //
00109 //  COMMENTS:
00110 //
00111 //       In this function, we initialize a window class by filling out a data
00112 //       structure of type WNDCLASS and calling either RegisterClass or
00113 //       the internal MyRegisterClass.
00114 //
00115 BOOL InitApplication(HINSTANCE hInstance)
00116 {
00117     WNDCLASS  wc;
00118     HWND      hwnd;
00119
00120     // Win32 will always set hPrevInstance to NULL, so lets check
00121     // things a little closer. This is because we only want a single
00122     // version of this app to run at a time
00123     hwnd = FindWindow (szAppName, NULL);
00124     if (hwnd) {
00125         // We found another version of ourself. Lets defer to it:
00126         if (IsIconic(hwnd)) {
00127             ShowWindow(hwnd, SW_RESTORE);
00128         }
00129         SetForegroundWindow (hwnd);
00130
00131         // If this app actually had any functionality, we would
00132         // also want to communicate any action that our 'twin'
00133         // should now perform based on how the user tried to
00134         // execute us.
00135         return FALSE;
00136         }
00137
00138         // Fill in window class structure with parameters that describe
00139         // the main window.
00140         wc.style         = CS_HREDRAW | CS_VREDRAW;
00141         wc.lpfnWndProc   = (WNDPROC)WndProc;
00142         wc.cbClsExtra    = 0;
00143         wc.cbWndExtra    = 0;
00144         wc.hInstance     = hInstance;
00145         wc.hIcon         = LoadIcon (hInstance, szAppName);
00146         wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00147         wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00148
00149         wc.lpszMenuName  = szAppName;
00150         wc.lpszClassName = szAppName;
00151
00152         // Register the window class and return success/failure code.
00153         return RegisterClass(&wc);
00154 }
00155
00156 //
00157 //   FUNCTION: InitInstance(HANDLE, int)
00158 //
00159 //   PURPOSE: Saves instance handle and creates main window
00160 //
00161 //   COMMENTS:
00162 //
00163 //        In this function, we save the instance handle in a global variable and
00164 //        create and display the main program window.
00165 //
00166 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00167 {
00168    HWND hWnd;
00169    DWORD dwStatus;
00170
00171    hInst = hInstance; // Store instance handle in our global variable
00172
00173    hWnd = CreateWindow(szAppName, szTitle, WS_OVERLAPPEDWINDOW,
00174       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
00175       NULL, NULL, hInstance, NULL);
00176
00177    if (!hWnd) {
00178       dwStatus = GetLastError();
00179       return (FALSE);
00180    }
00181
00182    ShowWindow(hWnd, nCmdShow);
00183    UpdateWindow(hWnd);
00184
00185    return (TRUE);
00186 }
00187
00188 //
00189 //  FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
00190 //
00191 //  PURPOSE: Entry point for the application.
00192 //
00193 //  COMMENTS:
00194 //
00195 // This function initializes the application and processes the
00196 // message loop.
00197 //
00198 int APIENTRY WinMain(HINSTANCE hInstance,
00199                      HINSTANCE hPrevInstance,
00200                      LPSTR     lpCmdLine,
00201                      int       nCmdShow)
00202 {
00203    MSG msg;
00204    HANDLE hAccelTable;
00205
00206    // Initialize global strings
00207    lstrcpyn(szAppName, APPNAME, 99);
00208    szAppName[99] = '\0'; // ensure that szAppName is NULL terminated
00209    LoadString (hInstance, IDS_APP_TITLE, szTitle, 100);
00210
00211
00212    if (!hPrevInstance) {
00213       // Perform instance initialization:
00214       if (!InitApplication(hInstance)) {
00215          return (FALSE);
00216       }
00217    }
00218
00219    // Perform application initialization:
00220    if (!InitInstance(hInstance, nCmdShow)) {
00221       return (FALSE);
00222    }
00223
00224    hAccelTable = LoadAccelerators (hInstance, szAppName);
00225
00226    // Main message loop:
00227    while (GetMessage(&msg, NULL, 0, 0)) {
00228       if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg)) {
00229          TranslateMessage(&msg);
00230          DispatchMessage(&msg);
00231       }
00232    }
00233
00234    return (int) (msg.wParam);
00235
00236    lpCmdLine; // This will prevent 'unused formal parameter' warnings
00237 }
00238
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMainFrame Member List

This is the complete list of members for CMainFrame, including all inherited members.
Add2OpenedQueuePathNameArray(ARRAYQ *NewPath) | CMainFrame | [inline]
Add2PathNameArray(ARRAYQ *NewPath) | CMainFrame | [inline]
ClassToString(unsigned short MsgClass, LPTSTR pszStatus) | CMainFrame |
CleanPathNameArray() | CMainFrame |
CMainFrame() | CMainFrame |
CMainFrame() | CMainFrame | [protected]
CMainFrame() | CMainFrame | [protected]
CMainFrame() | CMainFrame | [protected]
DisplayOpenedQueuePathNameArray() | CMainFrame |
DisplayPathNameArray() | CMainFrame |
GetQueueHandle(TCHAR *pszPathName, QUEUEHANDLE *phClosedQueueHandle) | CMainFrame |
IsFormatName(TCHAR *pszName) | CMainFrame |
IsOpenedQueueArrayEmpty() | CMainFrame |
m_OpenedQueuePathNameArray | CMainFrame | [protected]
m_PathNameArray | CMainFrame | [protected]
m_wndDlgBar | CMainFrame | [protected]
m_wndStatusBar | CMainFrame | [protected]
m_wndToolBar | CMainFrame | [protected]
m_wndView | CMainFrame | [protected]
MoveToOpenedQueuePathNameArray(TCHAR *pszPathName, TCHAR *pszFormatName, QUEUEHANDLE hQueue, DWORD dwAccess) | CMainFrame |
MoveToPathNameArray(TCHAR *pszPathName) | CMainFrame |
OnApiCloseQueue() | CMainFrame | [protected]
OnApiCreateQueue() | CMainFrame | [protected]
OnApiDeleteQueue() | CMainFrame | [protected]
OnApiLocate() | CMainFrame | [protected]
OnApiOpenQueue() | CMainFrame | [protected]
OnApiReceiveMessage() | CMainFrame | [protected]
OnApiSendMessage() | CMainFrame | [protected]
OnCmdMsg(UINT nID, int nCode, void *pExtra, AFX_CMDHANDLERINFO *pHandlerInfo) | CMainFrame | [virtual]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CMainFrame | [protected]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CMainFrame | [protected]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CMainFrame | [protected]
OnMixerPlay() | CMainFrame | [protected]
OnSetFocus(CWnd *pOldWnd) | CMainFrame | [protected]
OnUpdateFrameTitle(BOOL bAddToTitle) | CMainFrame | [protected]
OnUpdateMixerPlay(CCmdUI *pCmdUI) | CMainFrame | [protected]
PreCreateWindow(CREATESTRUCT &cs) | CMainFrame | [virtual]
PreCreateWindow(CREATESTRUCT &cs) | CMainFrame | [virtual]
PreCreateWindow(CREATESTRUCT &cs) | CMainFrame | [virtual]
PreCreateWindow(CREATESTRUCT &cs) | CMainFrame | [virtual]
RemoveFromOpenedQueuePathNameArray(TCHAR *pszPathName) | CMainFrame |
RemoveFromPathNameArray(TCHAR *pszPathFormatName) | CMainFrame |
TranslatePathNameToFormatName(TCHAR *pszPathName, TCHAR *pszFormatName) | CMainFrame |
UpdatePathNameArrays() | CMainFrame |
~CMainFrame() | CMainFrame | [virtual]
~CMainFrame() | CMainFrame | [virtual]
~CMainFrame() | CMainFrame | [virtual]
~CMainFrame() | CMainFrame | [virtual]
Generated on Wed Nov 13 2024 16:56:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/space.Cpp Source File

  • SysMgmt
  • MMC
  • Extens

space.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include <stdio.h>
00021 #include "Space.h"
00022 #include "Comp.h"
00023 #define STRSAFE_NO_DEPRECATE
00024 #include <strsafe.h>
00025
00026 const GUID CSpaceVehicle::thisGuid = { 0x29743810, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00027 const GUID CRocket::thisGuid = { 0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00028
00029 //==============================================================
00030 //
00031 // CSpaceVehicle implementation
00032 //
00033 //
00034 CSpaceVehicle::CSpaceVehicle()
00035 {
00036     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00037         children[n] = new CRocket(_T("Rocket"), n+1, 500000, 265, 75000);
00038     }
00039 }
00040
00041 CSpaceVehicle::~CSpaceVehicle()
00042 {
00043     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00044         if (children[n]) {
00045             delete children[n];
00046         }
00047 }
00048
00049 HRESULT CSpaceVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00050 {
00051     HRESULT      hr = S_OK;
00052
00053     IHeaderCtrl *pHeaderCtrl = NULL;
00054     IResultData *pResultData = NULL;
00055
00056     if (bShow) {
00057         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00058         _ASSERT( SUCCEEDED(hr) );
00059
00060         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00061         _ASSERT( SUCCEEDED(hr) );
00062
00063         // Set the column headers in the results pane
00064         hr = pHeaderCtrl->InsertColumn( 0, L"Rocket Class", 0, MMCLV_AUTO );
00065         _ASSERT( S_OK == hr );
00066         hr = pHeaderCtrl->InsertColumn( 1, L"Rocket Weight", 0, MMCLV_AUTO );
00067         _ASSERT( S_OK == hr );
00068         hr = pHeaderCtrl->InsertColumn( 2, L"Rocket Height", 0, MMCLV_AUTO );
00069         _ASSERT( S_OK == hr );
00070         hr = pHeaderCtrl->InsertColumn( 3, L"Rocket Payload", 0, MMCLV_AUTO );
00071         _ASSERT( S_OK == hr );
00072         hr = pHeaderCtrl->InsertColumn( 4, L"Status", 0, MMCLV_AUTO );
00073         _ASSERT( S_OK == hr );
00074
00075         // insert items here
00076         RESULTDATAITEM rdi;
00077
00078         hr = pResultData->DeleteAllRsltItems();
00079         _ASSERT( SUCCEEDED(hr) );
00080
00081         if (!bExpanded) {
00082             // create the child nodes, then expand them
00083             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00084                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00085                 rdi.mask       = RDI_STR       |   // Displayname is valid
00086                     RDI_IMAGE     |
00087                     RDI_PARAM;        // nImage is valid
00088
00089                 rdi.nImage      = children[n]->GetBitmapIndex();
00090                 rdi.str         = MMC_CALLBACK;
00091                 rdi.nCol        = 0;
00092                 rdi.lParam      = (LPARAM)children[n];
00093
00094                 hr = pResultData->InsertItem( &rdi );
00095
00096                 _ASSERT( SUCCEEDED(hr) );
00097             }
00098         }
00099
00100         pHeaderCtrl->Release();
00101         pResultData->Release();
00102     }
00103
00104     return hr;
00105 }
00106
00107 //==============================================================
00108 //
00109 // CRocket implementation
00110 //
00111 //
00112 CRocket::CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload)
00113 : szName(NULL), lWeight(0), lHeight(0), lPayload(0), iStatus(STOPPED)
00114 {
00115     if (szName) {
00116         this->szName = new _TCHAR[(_tcslen(szName) + 1) * sizeof(_TCHAR)];
00117         _tcscpy(this->szName, szName);
00118     }
00119
00120     this->nId = id;
00121     this->lWeight = lWeight;
00122     this->lHeight = lHeight;
00123     this->lPayload = lPayload;
00124 }
00125
00126 CRocket::~CRocket()
00127 {
00128     if (szName)
00129         delete [] szName;
00130 }
00131
00132 const _TCHAR *CRocket::GetDisplayName(int nCol)
00133 {
00134     const size_t cchBuffer = 128;
00135     static _TCHAR buf[cchBuffer];
00136
00137     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00138     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00139
00140     switch (nCol) {
00141     case 0:
00142         StringCchPrintf(buf, cchBuffer, _T("%s (#%d)"), szName ? szName : _T(""), nId);
00143         break;
00144
00145     case 1:
00146         StringCchPrintf(buf, cchBuffer, _T("%ld metric tons"), lWeight);
00147         break;
00148
00149     case 2:
00150         StringCchPrintf(buf, cchBuffer, _T("%ld meters"), lHeight);
00151         break;
00152
00153     case 3:
00154         StringCchPrintf(buf, cchBuffer, _T("%ld kilos"), lPayload);
00155         break;
00156
00157     case 4:
00158         StringCchPrintf(buf, cchBuffer, _T("%s"),
00159             iStatus == RUNNING ? _T("running") :
00160         iStatus == PAUSED ? _T("paused") :
00161         iStatus == STOPPED ? _T("stopped") : _T("unknown"));
00162         break;
00163
00164     }
00165
00166     return buf;
00167 }
00168
00169 HRESULT CRocket::OnRename(LPOLESTR pszNewName)
00170 {
00171     if (szName) {
00172         delete [] szName;
00173         szName = NULL;
00174     }
00175
00176
00177     MAKE_TSTRPTR_FROMWIDE(ptrname, pszNewName);
00178     szName = new _TCHAR[(_tcslen(ptrname) + 1) * sizeof(_TCHAR)];
00179     _tcscpy(szName, ptrname);
00180
00181     return S_OK;
00182 }
00183
00184 HRESULT CRocket::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
00185 {
00186     IConsoleVerb *pConsoleVerb;
00187
00188     HRESULT hr = pConsole->QueryConsoleVerb(&pConsoleVerb);
00189     _ASSERT(SUCCEEDED(hr));
00190
00191     hr = pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, FALSE);
00192     hr = pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, TRUE);
00193
00194     hr = pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, FALSE);
00195     hr = pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
00196
00197     pConsoleVerb->Release();
00198
00199     return S_OK;
00200 }
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/compdata.h Source File

  • SysMgmt
  • MMC
  • Toolbar

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData,
00028 ISnapinHelp
00029 {
00030     friend class CComponent;
00031
00032 private:
00033     ULONG       m_cref;
00034     LPCONSOLE     m_ipConsole;
00035     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00036
00037     CStaticNode     *m_pStaticNode;
00038
00039     WCHAR            m_HelpFile[MAX_PATH];
00040
00041 public:
00042     CComponentData();
00043     ~CComponentData();
00044
00045     ///////////////////////////////
00046     // Interface IUnknown
00047     ///////////////////////////////
00048     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00049     STDMETHODIMP_(ULONG) AddRef();
00050     STDMETHODIMP_(ULONG) Release();
00051
00052     ///////////////////////////////
00053     // Interface IComponentData
00054     ///////////////////////////////
00055     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00056         /* [in] */ LPUNKNOWN pUnknown);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00059         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00060
00061         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00062         /* [in] */ LPDATAOBJECT lpDataObject,
00063         /* [in] */ MMC_NOTIFY_TYPE event,
00064         /* [in] */ LPARAM arg,
00065         /* [in] */ LPARAM param);
00066
00067         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00068
00069     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00070         /* [in] */ MMC_COOKIE cookie,
00071         /* [in] */ DATA_OBJECT_TYPES type,
00072         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00075         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00076
00077         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00078         /* [in] */ LPDATAOBJECT lpDataObjectA,
00079         /* [in] */ LPDATAOBJECT lpDataObjectB);
00080
00081         ///////////////////////////////
00082         // Interface ISnapinHelp
00083         ///////////////////////////////
00084         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetHelpTopic(
00085         /* [out] */ LPOLESTR __RPC_FAR *lpCompiledHelpFile);
00086
00087 public:
00088     // CComponent *getComponent() { return m_pComponent; }
00089 };
00090
00091 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/BasePage.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

BasePage.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      BasePage.h
00007 //
00008 //  Implementation File:
00009 //      BasePage.cpp
00010 //
00011 //  Description:
00012 //      Definition of the CBasePropertyPage class.  This class provides base
00013 //      functionality for extension DLL property pages.
00014 //
00015 //  Author:
00016 //      <name> (<e-mail name>) Mmmm DD, 2003
00017 //
00018 //  Revision History:
00019 //
00020 //  Notes:
00021 //
00022 /////////////////////////////////////////////////////////////////////////////
00023
00024 #pragma once
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // Include Files
00028 /////////////////////////////////////////////////////////////////////////////
00029
00030 #pragma warning( push )
00031 #include <CluAdmEx.h>
00032 #pragma warning( pop )
00033
00034 #include "ExtObj.h"     // for CExtObject
00035 #include "PropList.h"   // for CClusPropList, CObjectProperty
00036
00037 /////////////////////////////////////////////////////////////////////////////
00038 // CBasePropertyPage dialog
00039 /////////////////////////////////////////////////////////////////////////////
00040
00041 class CBasePropertyPage
00042     : public CPropertyPage
00043 {
00044     DECLARE_DYNCREATE( CBasePropertyPage )
00045
00046 //
00047 //  Construction
00048 //
00049
00050 public:
00051     CBasePropertyPage( void );
00052     CBasePropertyPage( UINT nIDTemplateIn, UINT nIDCaptionIn = 0 );
00053
00054     virtual ~CBasePropertyPage( void )
00055     {
00056     } //*** ~CBasePropertyPage
00057
00058     //
00059     //  Second phase construction.
00060     //
00061
00062     virtual HRESULT         HrInit( CExtObject * peoInout );
00063     HRESULT                 HrCreatePage( void );
00064
00065 protected:
00066     void                    CommonConstruct( void );
00067
00068     //
00069     //  Attributes
00070     //
00071     CExtObject *            m_peo;
00072     HPROPSHEETPAGE          m_hpage;
00073
00074     IDD                     m_iddPropertyPage;
00075     IDD                     m_iddWizardPage;
00076     IDS                     m_idsCaption;
00077
00078     CExtObject *            Peo( void ) const               { return m_peo; }
00079
00080     IDD                     IddPropertyPage( void ) const   { return m_iddPropertyPage; }
00081     IDD                     IddWizardPage( void ) const     { return m_iddWizardPage; }
00082     IDS                     IdsCaption( void ) const        { return m_idsCaption; }
00083
00084 public:
00085     HPROPSHEETPAGE          Hpage( void ) const             { return m_hpage; }
00086
00087     CLUADMEX_OBJECT_TYPE    Cot( void ) const
00088     {
00089         ASSERT( Peo() != NULL );
00090         return Peo()->Cot();
00091     }; //*** Cot
00092
00093 //
00094 //  Dialog Data
00095 //
00096
00097     //{{AFX_DATA(CBasePropertyPage)
00098     enum { IDD = 0 };
00099     //}}AFX_DATA
00100     CStatic m_staticIcon;
00101     CStatic m_staticTitle;
00102     CString m_strTitle;
00103
00104 //
00105 //  Overrides
00106 //
00107
00108     // ClassWizard generate virtual function overrides
00109     //{{AFX_VIRTUAL(CBasePropertyPage)
00110     public:
00111     virtual BOOL OnSetActive();
00112     virtual BOOL OnApply();
00113     virtual LRESULT OnWizardBack();
00114     virtual LRESULT OnWizardNext();
00115     virtual BOOL OnWizardFinish();
00116 protected:
00117     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00118     //}}AFX_VIRTUAL
00119
00120     virtual DWORD           ScParseUnknownProperty(
00121                                   LPCWSTR                           pwszNameIn
00122                                 , const CLUSPROP_BUFFER_HELPER &    rvalueIn
00123                                 , DWORD                             cbBufIn
00124                                 )
00125     {
00126         UNREFERENCED_PARAMETER( pwszNameIn );
00127         UNREFERENCED_PARAMETER( rvalueIn );
00128         UNREFERENCED_PARAMETER( cbBufIn );
00129         return ERROR_SUCCESS;
00130
00131     } //*** ScParseUnknownProperty
00132
00133     virtual BOOL            BApplyChanges( void );
00134     virtual BOOL            BBuildPropList( CClusPropList & rcplInout, BOOL fNoNewPropsIn = FALSE );
00135     virtual void            DisplaySetPropsError( DWORD scIn, UINT idsOperIn ) const;
00136
00137     virtual const CObjectProperty * Pprops( void ) const    { return NULL; }
00138     virtual DWORD                   Cprops( void ) const    { return 0; }
00139
00140 //
00141 //  Implementation
00142 //
00143
00144 protected:
00145     BOOL                    m_bBackPressed;
00146     BOOL                    m_bSaved;
00147     BOOL                    m_bDoDetach;
00148
00149     BOOL                    BBackPressed( void ) const      { return m_bBackPressed; }
00150     BOOL                    BSaved( void ) const            { return m_bSaved; }
00151     void                    EnableNext( BOOL fEnableIn = TRUE );
00152     IWCWizardCallback *     PiWizardCallback( void ) const
00153     {
00154         ASSERT( Peo() != NULL );
00155         return Peo()->PiWizardCallback();
00156     }; //*** PiWizardCallback
00157
00158     BOOL                    BWizard( void ) const
00159     {
00160         ASSERT( Peo() != NULL );
00161         return Peo()->BWizard();
00162     }; //*** BWizard
00163
00164     HCLUSTER                Hcluster( void ) const
00165     {
00166         ASSERT( Peo() != NULL );
00167         return Peo()->Hcluster();
00168     }; //*** Hcluster
00169
00170     DWORD                   ScParseProperties( CClusPropList & rcplIn );
00171     BOOL                    BSetPrivateProps(
00172                                   BOOL fValidateOnlyIn = FALSE
00173                                 , BOOL fNoNewPropsIn = FALSE
00174                                 );
00175
00176     //
00177     //  Generated message map functions
00178     //
00179
00180     //{{AFX_MSG(CBasePropertyPage)
00181     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00182     afx_msg void OnDestroy();
00183     virtual BOOL OnInitDialog();
00184     //}}AFX_MSG
00185     afx_msg void OnChangeCtrl();
00186     DECLARE_MESSAGE_MAP()
00187
00188 };  //*** class CBasePropertyPage
00189
00190 /////////////////////////////////////////////////////////////////////////////
00191 // CPageList
00192 /////////////////////////////////////////////////////////////////////////////
00193
00194 typedef CList< CBasePropertyPage *, CBasePropertyPage * > CPageList;
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Settings.h Source File

  • NetDS
  • SyncMgr
  • SyncDir

Settings.h

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012
00013 #ifndef _SAMPLESETTINGS
00014 #define _SAMPLESETTINGS
00015
00016 class CSettings;
00017 class CSyncMgrHandler;
00018
00019 // setting information that is given out publicly
00020 typedef struct _tagHANDLERITEMSETTINGS
00021 {
00022     // all the info we need to perform a sync.
00023     GUID ItemID;
00024     TCHAR szItemName[MAX_SYNCMGRITEMNAME];
00025     TCHAR dir1[MAX_PATH];
00026     TCHAR dir2[MAX_PATH];
00027     BOOL fRecursive;
00028     FILETIME ft;
00029 } HANDLERITEMSETTINGS;
00030 typedef HANDLERITEMSETTINGS *LPHANDLERITEMSETTINGS;
00031
00032
00033 // private settings information.
00034
00035 // structure for enumerator items. first item is the GENERICITEM so
00036 // can use the gerneric enumerator class.
00037 // structure passed as lParam to configuration dialog
00038
00039 typedef struct _tagSAMPLEITEMSETTINGS
00040 {
00041     GENERICITEM  genericItem;
00042     SYNCMGRITEM syncmgrItem; // item as passed in enumerator.
00043
00044     // handler specific data
00045     TCHAR dir1[MAX_PATH];
00046     TCHAR dir2[MAX_PATH];
00047     BOOL fRecursive;
00048
00049     BOOL fSyncLock; // handler has put a lock on this item.
00050     CSyncMgrHandler *pLockHandler; // ptr to handler who has lock on item.
00051
00052 } SAMPLEITEMSETTINGS;
00053
00054 typedef SAMPLEITEMSETTINGS *LPSAMPLEITEMSETTINGS;
00055
00056
00057 // definitions for global settings class
00058
00059 typedef struct _tagCONFIGSETTINGSLPARAM
00060 {
00061     CSettings *pSettings;
00062     HRESULT hr;
00063 } CONFIGSETTINGSLPARAM;
00064
00065
00066 typedef struct _tagITEMCONFIGSETTINGSLPARAM
00067 {
00068     CSettings *pSettings;
00069     BOOL fNewItem;
00070     SYNCMGRITEMID ItemID;
00071     LPSAMPLEITEMSETTINGS pItemSettings;
00072     HRESULT hr;
00073
00074     // vars used internally by dialog
00075     BOOL fDirty;
00076 } ITEMCONFIGSETTINGSLPARAM;
00077
00078
00079 typedef struct _tagCONFIGITEMLISTVIEWLPARAM
00080 {
00081   SYNCMGRITEMID ItemID;
00082 } CONFIGITEMLISTVIEWLPARAM;
00083
00084
00085 BOOL CALLBACK ConfigureDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
00086 BOOL CALLBACK ItemConfigDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
00087
00088 class CSettings : CLockHandler {
00089
00090 public:
00091     CSettings();
00092     ~CSettings();
00093
00094     STDMETHODIMP_(ULONG)    AddRef();
00095     STDMETHODIMP_(ULONG)    Release();
00096
00097     STDMETHODIMP    EnumSyncMgrItems(ISyncMgrEnumItems **ppenumOffineItems);
00098     STDMETHODIMP    ShowProperties(HWND hWndParent,REFSYNCMGRITEMID ItemID);
00099     BOOL RequestItemLock(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID);
00100     BOOL ReleaseItemLock(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID);
00101     BOOL ReleaseItemLock(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID,FILETIME *pfUpdateTime);
00102     BOOL CopyHandlerSyncInfo(REFSYNCMGRITEMID ItemID,
00103                         /* [in,out] */ LPHANDLERITEMSETTINGS pHandlerSyncItem);
00104 private:
00105     LPSAMPLEITEMSETTINGS FindItemSettings(REFSYNCMGRITEMID ItemID);
00106     STDMETHODIMP ReadSettings(BOOL fForce);
00107     BOOL WriteItemSettings(LPSAMPLEITEMSETTINGS pSampleItemSettings);
00108     BOOL DeleteItemSettings(LPSAMPLEITEMSETTINGS pSampleItemSettings);
00109     BOOL ReleaseItemLockX(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID,
00110                             BOOL fUpdateft,FILETIME *pfUpdateTime);
00111
00112
00113     STDMETHODIMP ShowItemProperties(HWND hWndParent,BOOL fNew,
00114             LPSAMPLEITEMSETTINGS pItemSettings,SYNCMGRITEMID ItemID);
00115     int Alert(HWND hWnd,LPCTSTR lpText);
00116
00117     // methods used by configuration properties dialog
00118     void OnConfigDlgInit(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00119                                         UINT uMessage, WPARAM wParam, LPARAM lParam);
00120     void OnConfigDlgDestroy(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00121                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00122     void OnConfigDlgNotify(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00123                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00124     void OnConfigDlgCommand(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00125                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00126     void OnConfigDlgAdd(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam);
00127     void OnConfigDlgRemove(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00128                                 SYNCMGRITEMID ItemID,int iSelection);
00129     void OnConfigDlgEdit(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00130                                 SYNCMGRITEMID ItemID,int iSelection);
00131
00132     int ConfigDlgAddListViewItem(HWND hWndList,SYNCMGRITEM syncMgrItem,int iItem,int iIconIndex);
00133     BOOL ConfigDlgDeleteListViewItem(HWND hWndList,int iItem);
00134
00135     // methods used by Item properties dialog
00136     void OnItemConfigDlgInit(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
00137                                         UINT uMessage, WPARAM wParam, LPARAM lParam);
00138     void OnItemConfigDlgDestroy(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
00139                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00140     void OnItemConfigDlgNotify(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
00141                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00142     void OnItemConfigDlgCommand(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
00143                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00144     BOOL OnItemConfigDlgApply(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
00145                                         UINT uMessage, WPARAM wParam,LPARAM lParam);
00146
00147     LPSAMPLEITEMSETTINGS ItemConfigDlgGetItemSettings(ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam);
00148
00149 private:
00150     LPGENERICITEMLIST m_pHandlerItems;
00151     LONG m_cRefs;
00152
00153     friend BOOL CALLBACK ConfigureDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
00154     friend BOOL CALLBACK ItemConfigDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
00155
00156 };
00157
00158
00159 // Enumerator for ISyncMgrEnumItems
00160 class CEnumSyncMgrItems : public CGenericEnum , public ISyncMgrEnumItems
00161 {
00162 public:
00163     CEnumSyncMgrItems(LPGENERICITEMLIST  pContactItemList,DWORD cOffset);
00164     virtual void DeleteThisObject();
00165
00166     //IUnknown members
00167     STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
00168     STDMETHODIMP_(ULONG)    AddRef();
00169     STDMETHODIMP_(ULONG)    Release();
00170
00171     //IEnumSyncMgrItems members
00172     STDMETHODIMP Next(ULONG celt, LPSYNCMGRITEM rgelt,ULONG *pceltFetched);
00173     STDMETHODIMP Clone(ISyncMgrEnumItems **ppenum);
00174     STDMETHODIMP Skip(ULONG celt);
00175     STDMETHODIMP Reset();
00176 };
00177
00178
00179 #endif // _SAMPLESETTINGS
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagSLOT Member List

This is the complete list of members for tagSLOT, including all inherited members.
cslot | tagSLOT
islotNext | tagSLOT
islotPrev | tagSLOT
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/globals.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

globals.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _MMC_GLOBALS_H
00015 #define _MMC_GLOBALS_H
00016
00017 #include <TChar.h>
00018 #include <Mmc.h>
00019 #include <CrtDbg.h>
00020 #include <CommCtrl.h>                  // Needed for button styles...
00021 #include "Guids.h"
00022
00023
00024 class CBaseNode;                       // References
00025 class CDataObject;
00026
00027
00028 //---------------------------------------------------------------------------
00029 extern HINSTANCE g_hInst;              // Global instance handle
00030 extern ULONG     g_uObjectCount;       // Instance count for this object
00031 extern ULONG     g_uServerLocks;       // Server lock count for this object
00032
00033 //---------------------------------------------------------------------------
00034 // Clipformats requiered by MMC
00035
00036 extern UINT g_cfDisplayName;      // DisplayName for our SnapIn node
00037 extern UINT g_cfNodeType;         // GUID of the selected node
00038 extern UINT g_cfSnapinClsid;      // Class ID of this SnapIn
00039 extern UINT g_cfszNodeType;       // String version of namespace GUID
00040
00041 extern UINT g_cfBaseNodePtr;      // Retrieves BaseNode pointer
00042 extern UINT g_cfDataObjPtr;       // Retrieves pointer to CDataObject
00043
00044 extern UINT g_cfMS_Snapins;       // MULTISELECT: New clipformats MMC is
00045 extern UINT g_cfMS_Objects;       // go to ask us for.
00046 extern UINT g_cfMS_IsMsObj;
00047
00048 extern UINT g_cfMS_Cookies;
00049
00050 //---------------------------------------------------------------------------
00051 //  Global function prototypes
00052
00053 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide );
00054 void _fastcall CopyT2W( LPWSTR strDest, LPCTSTR strSource, size_t count);
00055
00056 void InitClipboardFormats();
00057
00058 DWORD  IsCompositeDataObject( LPDATAOBJECT ipDataObject );
00059
00060 HRESULT ExtractFromDataObject( LPDATAOBJECT ipDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal );
00061
00062 CBaseNode* ExtractBaseNodePtr( LPDATAOBJECT ipDataObject );
00063 CDataObject* ExtractDataObjPtr( LPDATAOBJECT ipDataObject );
00064
00065 //---------------------------------------------------------------------------
00066 //  Global Strings
00067
00068
00069 static TCHAR*  gtszSNAPIN_NAME       = _T("Sample M (MMC 2.0) - MultiSelect");
00070 static TCHAR*  gtszABOUT_NAME        = _T("Sample M (MMC 2.0) - ISnapinAbout");
00071
00072
00073 static WCHAR*  gwszROOT_NODE_NAME    = L"MultiSelect Sample";
00074 static WCHAR*  gwszABOUT_DESCRIPTION = L"MMC SDK MultiSelect Sample";
00075 static WCHAR*  gwszABOUT_PROVIDER    = L"Copyright © 1999 - 2001 Microsoft Corporation";
00076 static WCHAR*  gwszABOUT_VERSION     = L"2.0";
00077
00078 // We need to do this to get around MMC.IDL - it explicitly defines
00079 // the clipboard formats as WCHAR types...
00080 #define T_CCF_DISPLAY_NAME    _T("CCF_DISPLAY_NAME")
00081 #define T_CCF_NODETYPE        _T("CCF_NODETYPE")
00082 #define T_CCF_SZNODETYPE      _T("CCF_SZNODETYPE")
00083 #define T_CCF_SNAPIN_CLASSID  _T("CCF_SNAPIN_CLASSID")
00084
00085 #define T_CCF_BASENODE_PTR    _T("CCF_BASENODE_PTR")
00086 #define T_CCF_DATAOBJ_PTR     _T("CCF_DATAOBJ_PTR")
00087
00088
00089 // MULTISELECT: Define required clipboard formats
00090 #define T_CCF_MULTI_SELECT_SNAPINS          _T("CCF_MULTI_SELECT_SNAPINS")
00091 #define T_CCF_OBJECT_TYPES_IN_MULTI_SELECT  _T("CCF_OBJECT_TYPES_IN_MULTI_SELECT")
00092 #define T_CCF_MMC_MULTISELECT_DATAOBJECT    _T("CCF_MMC_MULTISELECT_DATAOBJECT")
00093
00094 #define T_CCF_MULTISELECT_COOKIES           _T("CCF_MULTISELECT_COOKIES")
00095
00096 //---------------------------------------------------------------------------
00097 // Constants
00098
00099 #define NODETYPE_STATIC                100   // Node Types
00100 #define NODETYPE_DEVICE                200
00101 #define NODETYPE_FOLDER                300
00102 #define NODETYPE_RESULT                400
00103 #define NODETYPE_VFILE                 500
00104
00105
00106 #define ATTRIBUTE_DATA_ARCHIVE         2     // Node Attributes
00107 #define ATTRIBUTE_DATA_HIDDEN          4
00108 #define ATTRIBUTE_DATA_LOCKED          8
00109 #define ATTRIBUTE_DATA_READONLY        16
00110 #define ATTRIBUTE_BACKUP_DEVICE        2048
00111
00112
00113 #define IMG_DEVICE_DEFAULT             0     // Image Indexes
00114 #define IMG_DEVICE_OFFLINE             1
00115 #define IMG_DATA_FILE                  2
00116 #define IMG_DRIVE_DEFAULT              3
00117 #define IMG_DRIVE_OFFLINE              4
00118 #define IMG_FOLDER_DEFAULT             5
00119 #define IMG_CDROM_DEFAULT              6
00120 #define IMG_REMOVABLE_MEDIA            7
00121
00122 #define IDM_NEW_DEVICE                 100   // Menu defines
00123 #define IDM_NEW_FOLDER                 200
00124 #define IDM_TOGGLE_STATUS              300
00125 #define IDM_NEW_VIRTFILE               400
00126 #define IDM_CLEAR_ATTRIBS              500
00127
00128 #define STATUS_ONLINE                  1
00129 #define STATUS_OFFLINE                 0
00130
00131 // Define some custom window messages so that objects running in
00132 // different threads can send us commands.
00133 //
00134 #define WM_DELETE_NODE                 (WM_USER + 100)
00135 #define WM_ADDNEW_NODE                 (WM_USER + 101)
00136 #define WM_DIALOG_CLOSED               (WM_USER + 102)
00137 #define WM_ADD_VIRTUALFILE             (WM_USER + 103)
00138 #define WM_VIRTUALFILE_CLOSED          (WM_USER + 104)
00139
00140 // Defines interfaces which can be requested from IComponentData
00141 // or CComponent's ::GetInterface method
00142 //
00143 #define REQUEST_ICONSOLENAMESPACE      1000
00144 #define REQUEST_ICONSOLE               1001
00145 #define REQUEST_ICONSOLEVERB           1002
00146 #define REQUEST_IRESULTDATA            1003
00147 #define REQUEST_IHEADERCTRL            1004
00148 #define REQUEST_ICONTROLBAR            1005
00149 #define REQUEST_ISTATICTOOLBAR         1006
00150 #define REQUEST_IDEVICETOOLBAR         1007
00151 #define REQUEST_IVFILETOOLBAR          1008
00152
00153
00154 /////////////////////////////////////////////////////////////////////////////
00155 //  IExtendControlbar:  Create button structs which map the menu commands.
00156
00157 static MMCBUTTON StaticToolButtons[] =
00158 {
00159  { 0, IDM_NEW_DEVICE, TBSTATE_ENABLED, TBSTYLE_BUTTON, L"Device", L"New Device" }
00160 };
00161
00162
00163 static MMCBUTTON DeviceToolButtons[] =
00164 {
00165  { 0, IDM_NEW_FOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, L"Folder", L"Create New Folder" },
00166  { 1, IDM_TOGGLE_STATUS, TBSTATE_ENABLED, TBSTYLE_BUTTON, L"Toggle", L"Toggle Device Status" }
00167 };
00168
00169
00170 static MMCBUTTON VFileToolButtons[] =
00171 {
00172  { 0, IDM_CLEAR_ATTRIBS, TBSTATE_ENABLED, TBSTYLE_BUTTON, L"Clear", L"Clear Attributes" }
00173 };
00174
00175
00176 /////////////////////////////////////////////////////////////////////////////
00177 // Helper classes and macros
00178
00179 #define BYTE_SIZE(string)          ((_tcslen(string)+1) * sizeof(TCHAR))
00180
00181 #define BREAK_ON_ERROR( hResult )  if( S_OK != hResult ) continue
00182
00183 // Useful only for debugging.  Never use modal dialogs in release builds!!
00184 #define MsgBox(wszMsg, wszTitle) ::MessageBox(NULL, wszMsg, wszTitle, MB_OK)
00185
00186
00187 //---------------------------------------------------------------------------
00188 template<class TYPE>
00189 inline void SAFE_RELEASE( TYPE*& pObj )
00190 {
00191   if( NULL != pObj )
00192   {
00193     pObj->Release();
00194     pObj = NULL;
00195   }
00196   else
00197   {
00198     OutputDebugString(_T("Attempted to release NULL Com pointer.\n"));
00199   }
00200 }
00201
00202 //---------------------------------------------------------------------------
00203 template<class TYPE>
00204 inline void SAFE_FREE_BITMAP( TYPE*& pObj )
00205 {
00206   if( NULL != pObj )
00207   {
00208     BOOL bStatus = DeleteObject( pObj );
00209     pObj = NULL;
00210   }
00211   else
00212   {
00213     OutputDebugString(_T("Attempted to delete NULL Bitmap handle.\n"));
00214   }
00215 }
00216
00217 //---------------------------------------------------------------------------
00218 template<class TYPE>
00219 inline void SAFE_FREE_ICON( TYPE*& pObj )
00220 {
00221   if( NULL != pObj )
00222   {
00223     BOOL bStatus = DestroyIcon( pObj );
00224     pObj = NULL;
00225   }
00226   else
00227   {
00228     OutputDebugString(_T("Attempted to delete NULL Icon handle.\n"));
00229   }
00230 }
00231
00232
00233
00234 //---------------------------------------------------------------------------
00235 //  W2T converts a wide character string to unicode if _UNICODE is not
00236 //  defined.  If it is defined then the sting is copied to another buffer.
00237 //
00238 #ifndef _UNICODE
00239 #define W2T( szAnsiPtr, szWide )   Unicode2Ansi( szAnsiPtr, szWide )
00240 #else
00241 #define W2T( szAnsiPtr, szWide )                                 \
00242         *szAnsiPtr = (WCHAR*)CoTaskMemAlloc(BYTE_SIZE(szWide) ); \
00243         CopyMemory( *szAnsiPtr, szWide, BYTE_SIZE(szWide) )
00244
00245 #endif //_UNICODE
00246
00247
00248 #endif //_MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Microsoft::Uddi::Demo::Publish Member List

This is the complete list of members for Microsoft::Uddi::Demo::Publish, including all inherited members.
_connection | Microsoft::Uddi::Demo::Publish | [private, static]
AddService(BusinessEntity entity, string name, string desc) | Microsoft::Uddi::Demo::Publish | [inline, private, static]
DisplayOwnedEntities() | Microsoft::Uddi::Demo::Publish | [inline, private, static]
DisplayTaxonomy(string key) | Microsoft::Uddi::Demo::Publish | [inline, private, static]
DisplayTaxonomyItems(string key, string value, int tabs) | Microsoft::Uddi::Demo::Publish | [inline, private, static]
GetFirstLocation(AuthenticationMode mode) | Microsoft::Uddi::Demo::Publish | [inline, private, static]
Main() | Microsoft::Uddi::Demo::Publish | [inline, static]
SaveNewProvider(string name, string desc) | Microsoft::Uddi::Demo::Publish | [inline, private, static]
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/resource.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

resource.h

Go to the documentation of this file.
00001 //
00002 // Used by MyStorageResource.rc
00003 //
00004
00005 #define IDR_CEnumStorageResource                            101
00006 #define IDR_CStorageResource                                102
00007 #define IDR_CStorageResType                                 103
00008 #define IDR_CPartitionInfo                                  104
00009
00010 #define IDS_PROJNAME                                        200
00011 #define IDS_ENUMSTORAGERESOURCE_DESC                        201
00012 #define IDS_STORAGERESOURCE_DESC                            202
00013 #define IDS_STORAGERESTYPE_DESC                             203
00014 #define IDS_PARTITIONINFO_DESC                              204
00015
00016 #define IDS_RESTYPE_DISPLAYNAME                             300
00017 #define IDS_DISK                                            301
00018 #define IDS_GPT                                             302
00019 #define IDS_LDM                                             303
00020
00021 #define IDS_ERROR_OUTOFMEMORY                               4000
00022 #define IDS_ERROR_OUTOFMEMORY_REF                           4001
00023 #define IDS_ERROR_NULL_POINTER                              4002
00024 #define IDS_ERROR_NULL_POINTER_REF                          4003
00025 #define IDS_ERROR_NO_INTERFACE                              4004
00026 #define IDS_ERROR_GETCOMPUTERNAME_FAILED                    4005
00027 #define IDS_RESOURCE_DESCRIPTION                            4006
00028 #define IDS_CONFIGURING_RESTYPE                             4007
00029 #define IDS_CONFIGURING_RESTYPE_FAILED                      4008
00030 #define IDS_CONFIGURED_RESTYPE                              4010
00031 #define IDS_CONFIGURED_EXTENSION                            4011
00032 #define IDS_ERROR_INVALIDARG                                5001
00033 #define IDS_ERROR_INVALIDARG_REF                            5002
00034 #define IDS_WARN_BOOT_PARTITION_NOT_NTFS                    5003
00035 #define IDS_WARN_BOOT_PARTITION_NOT_NTFS_REF                5004
00036 #define IDS_INFO_PRUNING_BOOTDISK_BUS                       5005
00037 #define IDS_INFO_BOOTDISK_PRUNED                            5006
00038 #define IDS_INFO_BOOTDISK_PRUNED_REF                        5007
00039 #define IDS_INFO_PRUNING_SYSTEMDISK_BUS                     5008
00040 #define IDS_INFO_SYSTEMDISK_PRUNED                          5009
00041 #define IDS_INFO_SYSTEMDISK_PRUNED_REF                      5010
00042 #define IDS_ERROR_WMI_GET_LOGICALDISK_FAILED                5011
00043 #define IDS_INFO_NON_SCSI_DISKS                             5012
00044 #define IDS_INFO_NON_SCSI_DISKS_REF                         5013
00045 #define IDS_ERROR_FOUND_NON_SCSI_DISK                       5014
00046 #define IDS_ERROR_FOUND_NON_SCSI_DISK_REF                   5015
00047 #define IDS_INFO_PRUNING_PAGEFILEDISK_BUS                   5016
00048 #define IDS_INFO_PAGEFILEDISK_PRUNED                        5017
00049 #define IDS_INFO_PAGEFILEDISK_PRUNED_REF                    5018
00050 #define IDS_INFO_PRUNING_CRASHDUMP_BUS                      5019
00051 #define IDS_INFO_CRASHDUMPDISK_PRUNED                       5020
00052 #define IDS_INFO_CRASHDUMPDISK_PRUNED_REF                   5021
00053 #define IDS_ERROR_LDM_DISK                                  5022
00054 #define IDS_ERROR_LDM_DISK_REF                              5023
00055 #define IDS_INFO_GPT_DISK                                   5024
00056 #define IDS_INFO_GPT_DISK_REF                               5025
00057 #define IDS_ERROR_WMI_GET_LOGICALDISK_FAILED_REF            5026
00058 #define IDS_INFO_DISK_CREATE                                5100
00059 #define IDS_INFO_DISK_PRECREATE                             5101
00060 #define IDS_ERROR_DISK_SIGNATURE                            5102
00061 #define IDS_ERROR_DISK_SIGNATURE_REF                        5103
00062 #define IDS_INFO_DISK_CLUSTER_CAPABLE                       5104
00063 #define IDS_INFO_DISK_NOT_CLUSTER_CAPABLE                   5105
00064 #define IDS_INFO_DISK_NOT_CLUSTER_CAPABLE_REF               5106
00065 #define IDS_ERROR_WMI_DISKDRIVEPARTITIONS_QRY_FAILED        5107
00066 #define IDS_ERROR_WMI_DISKDRIVEPARTITIONS_QRY_FAILED_REF    5108
00067 #define IDS_ERROR_WQL_QRY_NEXT_FAILED                       5109
00068 #define IDS_ERROR_WQL_QRY_NEXT_FAILED_REF                   5110
00069 #define IDS_ERROR_DISK_CLUSTER_CAPABLE                      5111
00070 #define IDS_ERROR_DISK_CLUSTER_CAPABLE_REF                  5112
00071 #define IDS_ERROR_DISK_NO_FILE_SYSTEM                       5200
00072 #define IDS_ERROR_DISK_NO_FILE_SYSTEM_REF                   5201
00073 #define IDS_WARN_DISK_NOT_NTFS                              5202
00074 #define IDS_WARN_DISK_NOT_NTFS_REF                          5203
00075 #define IDS_ERROR_WMI_DISKS_QRY_FAILED                      5204
00076 #define IDS_ERROR_WMI_DISKS_QRY_FAILED_REF                  5205
00077 #define IDS_ERROR_WBEM_CONNECTION_FAILURE                   5206
00078 #define IDS_ERROR_WBEM_CONNECTION_FAILURE_REF               5207
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpwizard/SCPPageUI.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpwizard

SCPPageUI.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCPPageUI.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef _SCPPAGEUI_H
00012 #define _SCPPAGEUI_H
00013
00014 #include "resource.h"
00015 #include "util.h"
00016
00017 class CSCPWiz;
00018
00019 class CSCPPageGeneral : public CPropertyPage
00020 {
00021 public:
00022   CSCPPageGeneral(CSCPWiz* pWizExt)
00023     : CPropertyPage(IDD_SCP_PAGE_GENERAL)
00024   {
00025     m_pWizExt = pWizExt;
00026     m_szName  = _T("");
00027     m_szServiceClassName  = _T("");
00028     m_szServiceDNSName    = _T("");
00029     m_bNeedCreate = TRUE;
00030   }
00031
00032   virtual ~CSCPPageGeneral()
00033   {
00034   }
00035
00036   enum { IDD = IDD_SCP_PAGE_GENERAL};
00037
00038   virtual BOOL OnInitDialog();
00039   virtual BOOL OnKillActive();
00040   virtual BOOL OnSetActive();
00041
00042   afx_msg void OnNameChange();
00043   afx_msg void OnServiceClassChange();
00044   afx_msg void OnDNSNameChange();
00045   afx_msg void OnDNSNameTypeChange();
00046
00047   void SetWizardButtons();
00048
00049   void GetSummaryInfo(CString& szSummary);
00050
00051   DECLARE_MESSAGE_MAP()
00052
00053 private:
00054   CString   m_szName;
00055   CString   m_szServiceClassName;
00056   CString   m_szServiceDNSName;
00057   CString   m_szServiceDNSNameType;
00058
00059   BOOL      m_bNeedCreate;
00060
00061   CSCPWiz*  m_pWizExt;
00062 };
00063
00064 class CSCPPageBindingInfo : public CPropertyPage
00065 {
00066 public:
00067   CSCPPageBindingInfo(CSCPWiz* pWizExt);
00068
00069   virtual ~CSCPPageBindingInfo()
00070   {
00071     if (m_pAttributeEditor != NULL)
00072       delete m_pAttributeEditor;
00073   }
00074
00075   enum { IDD = IDD_SCP_PAGE_BINDING_INFO};
00076
00077   virtual BOOL OnInitDialog();
00078   virtual BOOL OnKillActive();
00079   virtual BOOL OnSetActive();
00080
00081   afx_msg void OnButtonClick();
00082
00083   void SetWizardButtons();
00084
00085   void GetSummaryInfo(CString& szSummary);
00086
00087   DECLARE_MESSAGE_MAP()
00088
00089 private:
00090   CSCPWiz* m_pWizExt;
00091
00092   CStringList m_szValueList;
00093
00094   CMultiValuedAttributeEditor*  m_pAttributeEditor;
00095 };
00096
00097
00098 class CSCPPageKeywords : public CPropertyPage
00099 {
00100 public:
00101   CSCPPageKeywords(CSCPWiz* pWizExt);
00102
00103   virtual ~CSCPPageKeywords()
00104   {
00105     if (m_pAttributeEditor != NULL)
00106       delete m_pAttributeEditor;
00107   }
00108
00109   enum { IDD = IDD_SCP_PAGE_KEYWORDS};
00110
00111   virtual BOOL OnInitDialog();
00112   virtual BOOL OnKillActive();
00113   virtual BOOL OnSetActive();
00114
00115   void SetWizardButtons();
00116
00117   void GetSummaryInfo(CString& szSummary);
00118
00119   DECLARE_MESSAGE_MAP()
00120
00121 private:
00122   CSCPWiz* m_pWizExt;
00123
00124   CStringList m_szValueList;
00125   CMultiValuedAttributeEditor*  m_pAttributeEditor;
00126 };
00127
00128 #endif //_SCPPAGEUI_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/globals.h Source File

  • SysMgmt
  • MMC
  • Complete

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <mmc.h>
00023 #include <tchar.h>
00024
00025 #ifndef STRINGS_ONLY
00026
00027     enum UPDATE_VIEWS_HINT {UPDATE_SCOPEITEM = 1000, DELETE_SCOPEITEM, UPDATE_RESULTITEM, DELETE_RESULTITEM};
00028     enum ITEM_TYPE {SCOPE = 10, RESULT};
00029
00030
00031         #define IDM_BUTTON1    0x100
00032         #define IDM_BUTTON2    0x101
00033
00034         extern HINSTANCE g_hinst;
00035         extern ULONG g_uObjects;
00036
00037         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00038         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00039
00040         // uncomment the following #define to enable message cracking
00041         // #define MMC_CRACK_MESSAGES
00042         void MMCN_Crack(BOOL bComponentData,
00043                                         IDataObject *pDataObject,
00044                                         IComponentData *pCompData,
00045                                         IComponent *pComp,
00046                                         MMC_NOTIFY_TYPE event,
00047                                         LPARAM arg,
00048                                         LPARAM param);
00049
00050
00051 #endif
00052
00053 //=--------------------------------------------------------------------------=
00054 // allocates a temporary buffer that will disappear when it goes out of scope
00055 // NOTE: be careful of that -- make sure you use the string in the same or
00056 // nested scope in which you created this buffer. people should not use this
00057 // class directly.  use the macro(s) below.
00058 //
00059 class TempBuffer {
00060   public:
00061     TempBuffer(ULONG cBytes) {
00062         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00063         m_fHeapAlloc = (cBytes > 120);
00064     }
00065     ~TempBuffer() {
00066         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00067     }
00068     void *GetBuffer() {
00069         return m_pBuf;
00070     }
00071
00072   private:
00073     void *m_pBuf;
00074     // we'll use this temp buffer for small cases.
00075     //
00076     char  m_szTmpBuf[120];
00077     unsigned m_fHeapAlloc:1;
00078 };
00079
00080 //=--------------------------------------------------------------------------=
00081 // string helpers.
00082 //
00083 // given a _TCHAR, copy it into a wide buffer.
00084 // be careful about scoping when using this macro!
00085 //
00086 // how to use the below two macros:
00087 //
00088 //  ...
00089 //  LPTSTR pszT;
00090 //  pszT = MyGetTStringRoutine();
00091 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00092 //  MyUseWideStringRoutine(pwsz);
00093 //  ...
00094 #ifdef UNICODE
00095 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00096     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00097     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00098     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00099     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00100 #else // ANSI
00101 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00102     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00103     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00104     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00105     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00106     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00107 #endif
00108
00109 #ifdef UNICODE
00110 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00111     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00112     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00113     lstrcpyW((LPWSTR)ptrname, tstr)
00114 #else // ANSI
00115 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00116     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00117     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00118     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00119     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00120 #endif
00121
00122 //
00123 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00124 // have to be declared, and no clean up must be done.
00125 //
00126 // * 2 for DBCS handling in below length computation
00127 //
00128 #ifdef UNICODE
00129 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00130     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00131     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00132     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00133     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00134 #else // ANSI
00135 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00136     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00137     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00138     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00139     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00140 #endif
00141
00142 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Deers Member List

This is the complete list of members for Deers, including all inherited members.
m_deleted | Deers
m_name | Deers
m_redNose | Deers
m_weight | Deers
NDeers enum value | Deers
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/coptions.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

coptions.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module COPTIONS.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////
00016 #include "Headers.h"
00017 #include "COptions.h"
00018
00019
00020 /////////////////////////////////////////////////////////////////////////////
00021 // COptionsSheet
00022 //
00023 /////////////////////////////////////////////////////////////////////////////
00024 COptionsSheet::COptionsSheet()
00025   : CPropSheetLite("Options")
00026 {
00027   AddPage(&m_CDataSource);
00028   AddPage(&m_CCommand);
00029   AddPage(&m_CAccessor);
00030   AddPage(&m_CRowset);
00031   AddPage(&m_CNotify);
00032   AddPage(&m_CError);
00033
00034   //DataSource
00035   m_dwCLSCTX        = CLSCTX_INPROC_SERVER;
00036   m_wszRemoteServer[0]  = EOL;
00037   m_dwCreateOpts      = CREATE_INITIALIZE | CREATE_SETPROPERTIES;
00038
00039   //Command
00040   m_dwCommandOpts     = COMMAND_ROWSAFFECTED | COMMAND_RELEASE_OPENOBJECTS;
00041
00042   //Accessor
00043   m_wBindingType      = DBTYPE_WSTR;
00044   m_dwMaxLength     = MAX_COL_SIZE;
00045   m_dwAccessorOpts    = ACCESSOR_BIND_VALUE | ACCESSOR_BIND_LENGTH | ACCESSOR_BIND_STATUS;
00046
00047   //Rowset
00048   m_dwConvFlags     = CONV_ALPHABOOL;
00049   m_dwRowsetOpts      = ROWSET_SETDEFAULTPROPS;
00050   m_cRowsToFetch      = 0;
00051
00052   //Notify
00053   m_dwNotifyOpts      = NOTIFY_OLEDB | NOTIFY_IDBASYNCHNOTIFY | NOTIFY_IROWSETNOTIFY | NOTIFY_IROWPOSITIONCHANGE | NOTIFY_IPOOLNOTIFY;
00054
00055   //Errors
00056
00057   //Load Options from the Registry
00058   LoadOptions();
00059 }
00060
00061
00062 /////////////////////////////////////////////////////////////////////////////
00063 // COptionsSheet::LoadOptions
00064 //
00065 /////////////////////////////////////////////////////////////////////////////
00066 BOOL COptionsSheet::LoadOptions()
00067 {
00068   //DataSource
00069   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"CLSCTX",       &m_dwCLSCTX);
00070   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"RemoteServer",     m_wszRemoteServer, MAX_NAME_LEN);
00071   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"ConnectOpts",      &m_dwCreateOpts);
00072
00073   //NOTE: Since these bits we added later, the default is 0.  Instead of having negative logic
00074   //all over the place (NO_QI_OPTIONAL), we just store and obtain the bits in reverse
00075   ENABLE_BIT(m_dwCreateOpts, CREATE_QI_MANDATORY, !(m_dwCreateOpts & CREATE_QI_MANDATORY));
00076   ENABLE_BIT(m_dwCreateOpts, CREATE_QI_OPTIONAL,  !(m_dwCreateOpts & CREATE_QI_OPTIONAL));
00077
00078   //Command
00079   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"CommandOpts",      &m_dwCommandOpts);
00080
00081   //Accessor
00082   DWORD dwType = m_wBindingType;
00083   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"BindingType",      &dwType);
00084   m_wBindingType = (DBTYPE)dwType;
00085
00086   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"MaxLength",      &m_dwMaxLength);
00087   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"AccessorOpts",     &m_dwAccessorOpts);
00088
00089   //Rowset
00090   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"ConvFlags",      &m_dwConvFlags);
00091   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"RowsetOpts",     &m_dwRowsetOpts);
00092   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"RowsToFetch",      &m_cRowsToFetch);
00093
00094   //Notifications
00095   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"NotifyOpts",     &m_dwNotifyOpts);
00096
00097   //Errors
00098   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"ErrorPostingFlags",  &g_dwErrorPost);
00099   GetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"BreakID",        &g_dwBreakID);
00100   return TRUE;
00101 }
00102
00103
00104 /////////////////////////////////////////////////////////////////////////////
00105 // COptionsSheet::SaveOptions
00106 //
00107 /////////////////////////////////////////////////////////////////////////////
00108 BOOL COptionsSheet::SaveOptions()
00109 {
00110   //DataSource
00111   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"CLSCTX",       m_dwCLSCTX);
00112   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"RemoteServer",     m_wszRemoteServer);
00113
00114   //NOTE: Since these bits we added later, the default is 0.  Instead of having negative logic
00115   //all over the place (NO_QI_OPTIONAL), we just store and obtain the bits in reverse
00116   DWORD dwCreateOpts = m_dwCreateOpts;
00117   ENABLE_BIT(dwCreateOpts, CREATE_QI_MANDATORY, !(dwCreateOpts & CREATE_QI_MANDATORY));
00118   ENABLE_BIT(dwCreateOpts, CREATE_QI_OPTIONAL,  !(dwCreateOpts & CREATE_QI_OPTIONAL));
00119   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"ConnectOpts",      dwCreateOpts);
00120
00121   //Command
00122   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"CommandOpts",      m_dwCommandOpts);
00123
00124   //Accessor
00125   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"BindingType",      m_wBindingType);
00126   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"MaxLength",      m_dwMaxLength);
00127   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"AccessorOpts",     m_dwAccessorOpts);
00128
00129   //Rowset
00130   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"ConvFlags",      m_dwConvFlags);
00131   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"RowsetOpts",     m_dwRowsetOpts);
00132   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"RowsToFetch",      m_cRowsToFetch);
00133
00134   //Notifications
00135   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"NotifyOpts",     m_dwNotifyOpts);
00136
00137   //Errors
00138   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"ErrorPostingFlags",  g_dwErrorPost);
00139   SetRegEntry(HKEY_ROWSETVIEWER, wszOPTIONS_KEY, L"BreakID",        g_dwBreakID);
00140   return TRUE;
00141 }
00142
00143
00144 /////////////////////////////////////////////////////////////////////////////
00145 // COptionsSheet::GetBindingType
00146 //
00147 /////////////////////////////////////////////////////////////////////////////
00148 DBTYPE COptionsSheet::GetBindingType(DBTYPE wNativeType)
00149 {
00150   //Native Binding
00151   if((m_wBindingType & ~(DBTYPE_BYREF | DBTYPE_ARRAY | DBTYPE_VECTOR)) == DBTYPE_UDT)
00152     return wNativeType | (m_wBindingType - DBTYPE_UDT);
00153
00154   //Otherwise use the type selected
00155   return m_wBindingType;
00156 }
00157
00158
00159 /////////////////////////////////////////////////////////////////////////////
00160 // COptionsDataSource
00161 //
00162 /////////////////////////////////////////////////////////////////////////////
00163 COptionsDataSource::COptionsDataSource()
00164   : CPropPageLite(IDD_FULLCONNECT_OPTIONS, "DataSource")
00165 {
00166 }
00167
00168
00169 /////////////////////////////////////////////////////////////////////////////
00170 // COptionsDataSource::OnInitDialog
00171 //
00172 /////////////////////////////////////////////////////////////////////////////
00173 BOOL COptionsDataSource::OnInitDialog()
00174 {
00175   CWaitCursor waitCursor;
00176
00177   //PropertySheet (BackPointer)
00178   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00179
00180   //Set CLSCTX to previous saved values
00181   CheckDlgButton(IDB_INPROC_SERVER,   BST2STATE(pCOptionsSheet->m_dwCLSCTX & CLSCTX_INPROC_SERVER));
00182   CheckDlgButton(IDB_LOCAL_SERVER,    BST2STATE(pCOptionsSheet->m_dwCLSCTX & CLSCTX_LOCAL_SERVER));
00183   CheckDlgButton(IDB_REMOTE_SERVER,   BST2STATE(pCOptionsSheet->m_dwCLSCTX & CLSCTX_REMOTE_SERVER));
00184   CheckDlgButton(IDB_INPROC_HANDLER,    BST2STATE(pCOptionsSheet->m_dwCLSCTX & CLSCTX_INPROC_HANDLER));
00185
00186   //Currently there is no way to pass RemoteServer in GetDataSource methods...
00187   wSendMessage(GetDlgItem(IDE_REMOTESERVER), WM_SETTEXT, 0, pCOptionsSheet->m_wszRemoteServer);
00188 	::EnableWindow(GetDlgItem(IDE_REMOTESERVER), pCOptionsSheet->m_dwCLSCTX & CLSCTX_REMOTE_SERVER);
00189
00190   //Set Connection Options to previous saved values
00191   CheckDlgButton(IDB_INIT_INITIALIZE,   BST2STATE(pCOptionsSheet->m_dwCreateOpts & CREATE_INITIALIZE));
00192   CheckDlgButton(IDB_INIT_SETPROPERTIES,  BST2STATE(pCOptionsSheet->m_dwCreateOpts & CREATE_SETPROPERTIES));
00193
00194   //AutoQI
00195   CheckDlgButton(IDB_QI_MANDATORY,    BST2STATE(pCOptionsSheet->m_dwCreateOpts & CREATE_QI_MANDATORY));
00196   CheckDlgButton(IDB_QI_OPTIONAL,     BST2STATE(pCOptionsSheet->m_dwCreateOpts & CREATE_QI_OPTIONAL));
00197
00198   //Set Other Options
00199   CheckDlgButton(IDB_USESERVICECOMP,    BST2STATE(pCOptionsSheet->m_dwCreateOpts & CREATE_USESERVICECOMP));
00200
00201   //Delegate
00202   return CPropPageLite::OnInitDialog();
00203 }
00204
00205
00206 /////////////////////////////////////////////////////////////////////////////
00207 // COptionsDataSource::OnApply
00208 //
00209 /////////////////////////////////////////////////////////////////////////////
00210 BOOL COptionsDataSource::OnApply()
00211 {
00212   //PropertySheet (BackPointer)
00213   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00214
00215   //Obtain CLSCTX
00216   pCOptionsSheet->m_dwCLSCTX = 0;
00217   if(IsDlgButtonChecked(IDB_INPROC_SERVER))
00218     pCOptionsSheet->m_dwCLSCTX |= CLSCTX_INPROC_SERVER;
00219   if(IsDlgButtonChecked(IDB_LOCAL_SERVER))
00220     pCOptionsSheet->m_dwCLSCTX |= CLSCTX_LOCAL_SERVER;
00221   if(IsDlgButtonChecked(IDB_REMOTE_SERVER))
00222     pCOptionsSheet->m_dwCLSCTX |= CLSCTX_REMOTE_SERVER;
00223   if(IsDlgButtonChecked(IDB_INPROC_HANDLER))
00224     pCOptionsSheet->m_dwCLSCTX |= CLSCTX_INPROC_HANDLER;
00225
00226   //Obtain RemoteServer
00227   wSendMessage(GetDlgItem(IDE_REMOTESERVER), WM_GETTEXT, MAX_NAME_LEN, pCOptionsSheet->m_wszRemoteServer);
00228
00229   //Obtain Connection Options
00230   pCOptionsSheet->m_dwCreateOpts = 0;
00231   if(IsDlgButtonChecked(IDB_INIT_INITIALIZE))
00232     pCOptionsSheet->m_dwCreateOpts |= CREATE_INITIALIZE;
00233   if(IsDlgButtonChecked(IDB_INIT_SETPROPERTIES))
00234     pCOptionsSheet->m_dwCreateOpts |= CREATE_SETPROPERTIES;
00235
00236   //AutoQI
00237   ENABLE_BIT(pCOptionsSheet->m_dwCreateOpts,  CREATE_QI_MANDATORY,  IsDlgButtonChecked(IDB_QI_MANDATORY));
00238   ENABLE_BIT(pCOptionsSheet->m_dwCreateOpts,  CREATE_QI_OPTIONAL,   IsDlgButtonChecked(IDB_QI_OPTIONAL));
00239
00240   //Obtain Other Options
00241   if(IsDlgButtonChecked(IDB_USESERVICECOMP))
00242     pCOptionsSheet->m_dwCreateOpts |= CREATE_USESERVICECOMP;
00243
00244   //delegate
00245   return CPropPageLite::OnApply();
00246 }
00247
00248
00249
00250 /////////////////////////////////////////////////////////////////////////////
00251 // COptionsDataSource::OnCommand
00252 //
00253 /////////////////////////////////////////////////////////////////////////////
00254 BOOL COptionsDataSource::OnCommand(UINT iID, HWND hWndCtrl)
00255 {
00256   switch(iID)
00257   {
00258     ON_COMMAND(IDB_REMOTE_SERVER, ::EnableWindow(GetDlgItem(IDE_REMOTESERVER), IsDlgButtonChecked(IDB_REMOTE_SERVER)))
00259   };
00260
00261   return FALSE;
00262 }
00263
00264
00265 /////////////////////////////////////////////////////////////////////////////
00266 // COptionsCommand
00267 //
00268 /////////////////////////////////////////////////////////////////////////////
00269 COptionsCommand::COptionsCommand()
00270   : CPropPageLite(IDD_OPTIONS_COMMAND, "Command")
00271 {
00272 }
00273
00274
00275 /////////////////////////////////////////////////////////////////////////////
00276 // COptionsCommand::OnInitDialog
00277 //
00278 /////////////////////////////////////////////////////////////////////////////
00279 BOOL COptionsCommand::OnInitDialog()
00280 {
00281   CWaitCursor waitCursor;
00282
00283   //PropertySheet (BackPointer)
00284   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00285
00286   //Display RowAffected
00287   CheckDlgButton(IDB_DISPLAY_ROWSAFFECTED,  BST2STATE(pCOptionsSheet->m_dwCommandOpts & COMMAND_ROWSAFFECTED));
00288
00289   //Display ReleaseRowset
00290   CheckDlgButton(IDB_RELEASE_OPENOBJECTS,   BST2STATE(pCOptionsSheet->m_dwCommandOpts & COMMAND_RELEASE_OPENOBJECTS));
00291
00292   //Delegate
00293   return CPropPageLite::OnInitDialog();
00294 }
00295
00296
00297 /////////////////////////////////////////////////////////////////////////////
00298 // COptionsCommand::OnApply
00299 //
00300 /////////////////////////////////////////////////////////////////////////////
00301 BOOL COptionsCommand::OnApply()
00302 {
00303   //PropertySheet (BackPointer)
00304   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00305
00306   //Display RowsAffected
00307   ENABLE_BIT(pCOptionsSheet->m_dwCommandOpts, COMMAND_ROWSAFFECTED, IsDlgButtonChecked(IDB_DISPLAY_ROWSAFFECTED));
00308
00309   //Display ReleaseRowset
00310   ENABLE_BIT(pCOptionsSheet->m_dwCommandOpts, COMMAND_RELEASE_OPENOBJECTS, IsDlgButtonChecked(IDB_RELEASE_OPENOBJECTS));
00311
00312   //delegate
00313   return CPropPageLite::OnApply();
00314 }
00315
00316
00317
00318 /////////////////////////////////////////////////////////////////////////////
00319 // COptionsAccessor
00320 //
00321 /////////////////////////////////////////////////////////////////////////////
00322 COptionsAccessor::COptionsAccessor()
00323   : CPropPageLite(IDD_OPTIONS_ACCESSOR, "Accessor")
00324 {
00325 }
00326
00327
00328 /////////////////////////////////////////////////////////////////////////////
00329 // COptionsAccessor::OnInitDialog
00330 //
00331 /////////////////////////////////////////////////////////////////////////////
00332 BOOL COptionsAccessor::OnInitDialog()
00333 {
00334   CWaitCursor waitCursor;
00335
00336   //PropertySheet (BackPointer)
00337   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00338
00339   //Populate Binding Type Combo
00340   m_comboBindingTypes.CreateIndirect(m_hWnd, IDC_BINDINGTYPE);
00341
00342   //Add the Native Binding Type
00343   m_comboBindingTypes.AddString(L"Native Type", DBTYPE_UDT);
00344
00345   //Add all the others
00346   for(ULONG i=0; i<g_cDBTypes; i++)
00347     m_comboBindingTypes.AddString(g_rgDBTypes[i].pwszName, g_rgDBTypes[i].lItem);
00348
00349   //Select the Default Type...
00350   DBTYPE wBindingType = pCOptionsSheet->GetBindingType();
00351   DBTYPE wBaseType = wBindingType & ~(DBTYPE_BYREF | DBTYPE_ARRAY | DBTYPE_VECTOR | DBTYPE_RESERVED);
00352   m_comboBindingTypes.SetSelValue(wBaseType);
00353
00354   //MODIFIERS (BYREF, ARRAY, VECTOR)
00355   CheckDlgButton(IDB_TO_BYREF,  BST2STATE(wBindingType & DBTYPE_BYREF));
00356   CheckDlgButton(IDB_TO_ARRAY,  BST2STATE(wBindingType & DBTYPE_ARRAY));
00357   CheckDlgButton(IDB_TO_VECTOR, BST2STATE(wBindingType & DBTYPE_VECTOR));
00358
00359   //DBPART
00360   CheckDlgButton(IDB_BIND_VALUE,  BST2STATE(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BIND_VALUE));
00361   CheckDlgButton(IDB_BIND_LENGTH, BST2STATE(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BIND_LENGTH));
00362   CheckDlgButton(IDB_BIND_STATUS, BST2STATE(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BIND_STATUS));
00363
00364   //DBMEMOWNER
00365   CheckDlgButton(IDB_OWNED_PROVIDER,  BST2STATE(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_OWNED_PROVIDER));
00366
00367   //MaxLength
00368   wSendMessageFmt(GetDlgItem(IDE_MAXLENGTH), WM_SETTEXT, 0, L"%lu", pCOptionsSheet->m_dwMaxLength);
00369
00370   //BLOB Binding Type
00371   if(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BLOB_ISEQSTREAM)
00372     CheckDlgButton(IDB_BLOB_ISEQSTREAM, BST_CHECKED);
00373   else if(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BLOB_ILOCKBYTES)
00374     CheckDlgButton(IDB_BLOB_ILOCKBYTES, BST_CHECKED);
00375   else if(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BLOB_ISTORAGE)
00376     CheckDlgButton(IDB_BLOB_ISTORAGE, BST_CHECKED);
00377   else if(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BLOB_ISTREAM)
00378     CheckDlgButton(IDB_BLOB_ISTREAM, BST_CHECKED);
00379   else
00380     CheckDlgButton(IDB_BLOB_INLINE, BST_CHECKED);
00381
00382   //Bookmark Column
00383   CheckDlgButton(IDB_BIND_BOOKMARK, BST2STATE(pCOptionsSheet->m_dwAccessorOpts & ACCESSOR_BIND_BOOKMARK));
00384
00385   //Delegate
00386   return CPropPageLite::OnInitDialog();
00387 }
00388
00389
00390 /////////////////////////////////////////////////////////////////////////////
00391 // COptionsAccessor::OnApply
00392 //
00393 /////////////////////////////////////////////////////////////////////////////
00394 BOOL COptionsAccessor::OnApply()
00395 {
00396   //PropertySheet (BackPointer)
00397   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00398
00399   //BindingType
00400   DBTYPE wBindingType = (DBTYPE)m_comboBindingTypes.GetItemParam(m_comboBindingTypes.GetCurSel());
00401   if(wBindingType == CB_ERR)
00402     wBindingType = DBTYPE_WSTR;
00403
00404   //MODIFIERS (BYREF, ARRAY, VECTOR)
00405   if(IsDlgButtonChecked(IDB_TO_BYREF))
00406     wBindingType |= DBTYPE_BYREF;
00407   if(IsDlgButtonChecked(IDB_TO_ARRAY))
00408     wBindingType |= DBTYPE_ARRAY;
00409   if(IsDlgButtonChecked(IDB_TO_VECTOR))
00410     wBindingType |= DBTYPE_VECTOR;
00411   pCOptionsSheet->SetBindingType(wBindingType);
00412
00413   //DBPART
00414   pCOptionsSheet->m_dwAccessorOpts &= ~(ACCESSOR_BIND_VALUE | ACCESSOR_BIND_LENGTH | ACCESSOR_BIND_STATUS);
00415   if(IsDlgButtonChecked(IDB_BIND_VALUE))
00416     pCOptionsSheet->m_dwAccessorOpts |= ACCESSOR_BIND_VALUE;
00417   if(IsDlgButtonChecked(IDB_BIND_LENGTH))
00418     pCOptionsSheet->m_dwAccessorOpts |= ACCESSOR_BIND_LENGTH;
00419   if(IsDlgButtonChecked(IDB_BIND_STATUS))
00420     pCOptionsSheet->m_dwAccessorOpts |= ACCESSOR_BIND_STATUS;
00421
00422   //DBMEMOWNER
00423   ENABLE_BIT(pCOptionsSheet->m_dwAccessorOpts, ACCESSOR_OWNED_PROVIDER, IsDlgButtonChecked(IDB_OWNED_PROVIDER));
00424
00425   //MaxLength
00426   if(!GetEditBoxValue(GetDlgItem(IDE_MAXLENGTH), (LONG*)&pCOptionsSheet->m_dwMaxLength, 0/*Min*/))
00427   {
00428     pCOptionsSheet->m_dwMaxLength = MAX_COL_SIZE;
00429     return FALSE;
00430   }
00431
00432   //BLOB Binding Type
00433   ENABLE_BIT(pCOptionsSheet->m_dwAccessorOpts, ACCESSOR_BLOB_ISEQSTREAM,  IsDlgButtonChecked(IDB_BLOB_ISEQSTREAM));
00434   ENABLE_BIT(pCOptionsSheet->m_dwAccessorOpts, ACCESSOR_BLOB_ILOCKBYTES,  IsDlgButtonChecked(IDB_BLOB_ILOCKBYTES));
00435   ENABLE_BIT(pCOptionsSheet->m_dwAccessorOpts, ACCESSOR_BLOB_ISTORAGE,  IsDlgButtonChecked(IDB_BLOB_ISTORAGE));
00436   ENABLE_BIT(pCOptionsSheet->m_dwAccessorOpts, ACCESSOR_BLOB_ISTREAM,   IsDlgButtonChecked(IDB_BLOB_ISTREAM));
00437
00438   //Bookmark Column
00439   ENABLE_BIT(pCOptionsSheet->m_dwAccessorOpts, ACCESSOR_BIND_BOOKMARK,  IsDlgButtonChecked(IDB_BIND_BOOKMARK));
00440
00441   //delegate
00442   return CPropPageLite::OnApply();
00443 }
00444
00445 /////////////////////////////////////////////////////////////////////////////
00446 // COptionsRowset
00447 //
00448 /////////////////////////////////////////////////////////////////////////////
00449 COptionsRowset::COptionsRowset()
00450   : CPropPageLite(IDD_OPTIONS_ROWSET, "Rowset")
00451 {
00452 }
00453
00454
00455 /////////////////////////////////////////////////////////////////////////////
00456 // COptionsRowset::OnInitDialog
00457 //
00458 /////////////////////////////////////////////////////////////////////////////
00459 BOOL COptionsRowset::OnInitDialog()
00460 {
00461   CWaitCursor waitCursor;
00462
00463   //PropertySheet (BackPointer)
00464   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00465
00466   //Hexidecimal
00467   CheckDlgButton(IDB_DISPLAY_HEXADECIMAL,   BST2STATE(pCOptionsSheet->m_dwConvFlags & CONV_HEX));
00468   //Use MSDADC Only
00469   CheckDlgButton(IDB_MSDADC_ONLY,       BST2STATE(pCOptionsSheet->m_dwConvFlags & CONV_MSDADC_ONLY));
00470
00471   //DefaultProps
00472   CheckDlgButton(IDB_SETDEFAULTPROPS,     BST2STATE(pCOptionsSheet->m_dwRowsetOpts & ROWSET_SETDEFAULTPROPS));
00473
00474   //RowsToFetch
00475   CheckDlgButton(IDB_ROWSTOFETCH,       BST2STATE(pCOptionsSheet->m_dwRowsetOpts & ROWSET_ROWSTOFETCH));
00476   CheckDlgButton(IDB_DEFAULTFETCH,      BST2STATE(!(pCOptionsSheet->m_dwRowsetOpts & ROWSET_ROWSTOFETCH)));
00477   wSendMessageFmt(GetDlgItem(IDE_ROWSTOFETCH), WM_SETTEXT, 0, L"%lu", pCOptionsSheet->m_cRowsToFetch);
00478 	::EnableWindow(GetDlgItem(IDE_ROWSTOFETCH), pCOptionsSheet->m_dwRowsetOpts & ROWSET_ROWSTOFETCH);
00479
00480   //FetchData
00481   CheckDlgButton(IDB_FETCHDATA,       BST2STATE(!(pCOptionsSheet->m_dwRowsetOpts & ROWSET_NODATA)));
00482
00483   //Hidden Columns
00484   CheckDlgButton(IDB_HIDDENCOLUMNS,     BST2STATE(pCOptionsSheet->m_dwRowsetOpts & ROWSET_HIDDENCOLUMNS));
00485
00486   //Always ReleaseRows
00487   CheckDlgButton(IDB_ALWAYSRELEASEROWS,   BST2STATE(pCOptionsSheet->m_dwRowsetOpts & ROWSET_ALWAYSRELEASEROWS));
00488
00489   //Delegate
00490   return CPropPageLite::OnInitDialog();
00491 }
00492
00493
00494 /////////////////////////////////////////////////////////////////////////////
00495 // COptionsRowset::OnApply
00496 //
00497 /////////////////////////////////////////////////////////////////////////////
00498 BOOL COptionsRowset::OnApply()
00499 {
00500   //PropertySheet (BackPointer)
00501   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00502
00503   //Hexidecimal
00504   ENABLE_BIT(pCOptionsSheet->m_dwConvFlags, CONV_HEX,       IsDlgButtonChecked(IDB_DISPLAY_HEXADECIMAL));
00505   //Use MSDADC Only
00506   ENABLE_BIT(pCOptionsSheet->m_dwConvFlags, CONV_MSDADC_ONLY,   IsDlgButtonChecked(IDB_MSDADC_ONLY));
00507
00508   //DefaultProps
00509   ENABLE_BIT(pCOptionsSheet->m_dwRowsetOpts,  ROWSET_SETDEFAULTPROPS, IsDlgButtonChecked(IDB_SETDEFAULTPROPS));
00510
00511   //RowsToFetch
00512   ENABLE_BIT(pCOptionsSheet->m_dwRowsetOpts,  ROWSET_ROWSTOFETCH,   IsDlgButtonChecked(IDB_ROWSTOFETCH));
00513   if(pCOptionsSheet->m_dwRowsetOpts & ROWSET_ROWSTOFETCH)
00514   {
00515     if(!GetEditBoxValue(GetDlgItem(IDE_ROWSTOFETCH), (LONG*)&pCOptionsSheet->m_cRowsToFetch, 0/*Min*/))
00516     {
00517       pCOptionsSheet->m_cRowsToFetch = 0;
00518       return FALSE;
00519     }
00520   }
00521
00522   //FetchData
00523   ENABLE_BIT(pCOptionsSheet->m_dwRowsetOpts,  ROWSET_NODATA,      !IsDlgButtonChecked(IDB_FETCHDATA));
00524
00525   //HiddenColumns
00526   ENABLE_BIT(pCOptionsSheet->m_dwRowsetOpts,  ROWSET_HIDDENCOLUMNS, IsDlgButtonChecked(IDB_HIDDENCOLUMNS));
00527
00528   //Always ReleaseRows
00529   ENABLE_BIT(pCOptionsSheet->m_dwRowsetOpts,  ROWSET_ALWAYSRELEASEROWS, IsDlgButtonChecked(IDB_ALWAYSRELEASEROWS));
00530
00531   //delegate
00532   return CPropPageLite::OnApply();
00533 }
00534
00535
00536 /////////////////////////////////////////////////////////////////////////////
00537 // COptionsDataRowset::OnCommand
00538 //
00539 /////////////////////////////////////////////////////////////////////////////
00540 BOOL COptionsRowset::OnCommand(UINT iID, HWND hWndCtrl)
00541 {
00542   switch(iID)
00543   {
00544     ON_COMMAND(IDB_ROWSTOFETCH,   ::EnableWindow(GetDlgItem(IDE_ROWSTOFETCH), IsDlgButtonChecked(IDB_ROWSTOFETCH)))
00545     ON_COMMAND(IDB_DEFAULTFETCH,  ::EnableWindow(GetDlgItem(IDE_ROWSTOFETCH), IsDlgButtonChecked(IDB_ROWSTOFETCH)))
00546   };
00547
00548   return FALSE;
00549 }
00550
00551
00552 /////////////////////////////////////////////////////////////////////////////
00553 // COptionsNotify
00554 //
00555 /////////////////////////////////////////////////////////////////////////////
00556 COptionsNotify::COptionsNotify()
00557   : CPropPageLite(IDD_OPTIONS_NOTIFICATIONS, "Notify")
00558 {
00559 }
00560
00561
00562 /////////////////////////////////////////////////////////////////////////////
00563 // COptionsNotify::OnInitDialog
00564 //
00565 /////////////////////////////////////////////////////////////////////////////
00566 BOOL COptionsNotify::OnInitDialog()
00567 {
00568   CWaitCursor waitCursor;
00569
00570   //PropertySheet (BackPointer)
00571   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00572
00573   //Display
00574   CheckDlgButton(IDB_DISPLAY_OLEDB,       BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_OLEDB));
00575   CheckDlgButton(IDB_DISPLAY_PROMPTVETO,      BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_PROMPTVETO));
00576
00577   //IUnknown
00578   CheckDlgButton(IDB_DISPLAY_ADDREF,        BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_ADDREF));
00579   CheckDlgButton(IDB_DISPLAY_RELEASE,       BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_RELEASE));
00580   CheckDlgButton(IDB_DISPLAY_QI,          BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_QI));
00581
00582   //Trace Provider
00583   CheckDlgButton(IDB_USE_TRACEPROVIDER,     BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_TRACEPROVIDER));
00584
00585   //Notifications
00586   CheckDlgButton(IDB_DISPLAY_IDBASYNCHNOTIFY,   BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_IDBASYNCHNOTIFY));
00587   CheckDlgButton(IDB_DISPLAY_IROWSETNOTIFY,   BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_IROWSETNOTIFY));
00588   CheckDlgButton(IDB_DISPLAY_IROWPOSITIONCHANGE,  BST2STATE(pCOptionsSheet->m_dwNotifyOpts & NOTIFY_IROWPOSITIONCHANGE));
00589
00590   //Delegate
00591   return CPropPageLite::OnInitDialog();
00592 }
00593
00594
00595 /////////////////////////////////////////////////////////////////////////////
00596 // COptionsNotify::OnApply
00597 //
00598 /////////////////////////////////////////////////////////////////////////////
00599 BOOL COptionsNotify::OnApply()
00600 {
00601   //PropertySheet (BackPointer)
00602   COptionsSheet* pCOptionsSheet = (COptionsSheet*)GetParent();
00603
00604   //Display
00605   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_OLEDB,        IsDlgButtonChecked(IDB_DISPLAY_OLEDB));
00606   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_PROMPTVETO,     IsDlgButtonChecked(IDB_DISPLAY_PROMPTVETO));
00607
00608   //IUnknown
00609   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_ADDREF,       IsDlgButtonChecked(IDB_DISPLAY_ADDREF));
00610   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_RELEASE,        IsDlgButtonChecked(IDB_DISPLAY_RELEASE));
00611   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_QI,         IsDlgButtonChecked(IDB_DISPLAY_QI));
00612
00613   //Trace Provider
00614   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_TRACEPROVIDER,    IsDlgButtonChecked(IDB_USE_TRACEPROVIDER));
00615
00616   //Notiifcations
00617   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_IDBASYNCHNOTIFY,    IsDlgButtonChecked(IDB_DISPLAY_IDBASYNCHNOTIFY));
00618   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_IROWSETNOTIFY,    IsDlgButtonChecked(IDB_DISPLAY_IROWSETNOTIFY));
00619   ENABLE_BIT(pCOptionsSheet->m_dwNotifyOpts, NOTIFY_IROWPOSITIONCHANGE, IsDlgButtonChecked(IDB_DISPLAY_IROWPOSITIONCHANGE));
00620
00621   //delegate
00622   return CPropPageLite::OnApply();
00623 }
00624
00625
00626 /////////////////////////////////////////////////////////////////////////////
00627 // COptionsError
00628 //
00629 /////////////////////////////////////////////////////////////////////////////
00630 COptionsError::COptionsError()
00631   : CPropPageLite(IDD_OPTIONS_ERRORS, "Errors")
00632 {
00633 }
00634
00635
00636 /////////////////////////////////////////////////////////////////////////////
00637 // COptionsError::OnInitDialog
00638 //
00639 /////////////////////////////////////////////////////////////////////////////
00640 BOOL COptionsError::OnInitDialog()
00641 {
00642   CWaitCursor waitCursor;
00643
00644   //ErrorInfo
00645   if(GetErrorPosting(EP_ERRORINFO_ALWAYS))
00646     CheckDlgButton(IDB_ERRORINFO_ALWAYS,    BST_CHECKED);
00647   if(GetErrorPosting(EP_ERRORINFO_FAILURE))
00648     CheckDlgButton(IDB_ERRORINFO_FAILURE,   BST_CHECKED);
00649   if(GetErrorPosting(EP_ERRORINFO_NEVER))
00650     CheckDlgButton(IDB_ERRORINFO_NEVER,     BST_CHECKED);
00651
00652   //HRESULTs
00653   if(GetErrorPosting(EP_HRESULT_ALWAYS))
00654     CheckDlgButton(IDB_HRESULT_ALWAYS,      BST_CHECKED);
00655   if(GetErrorPosting(EP_HRESULT_NOERRORINFO))
00656     CheckDlgButton(IDB_HRESULT_NOERRORINFO,   BST_CHECKED);
00657   if(GetErrorPosting(EP_HRESULT_FAILURE))
00658     CheckDlgButton(IDB_HRESULT_FAILURE,     BST_CHECKED);
00659   if(GetErrorPosting(EP_HRESULT_NEVER))
00660     CheckDlgButton(IDB_HRESULT_NEVER,     BST_CHECKED);
00661
00662   //IMallocSpy
00663   CheckDlgButton(IDB_IMALLOC_SPY,         BST2STATE(GetErrorPosting(EP_IMALLOC_SPY)));
00664   CheckDlgButton(IDB_IMALLOC_ALLOCS,        BST2STATE(GetErrorPosting(EP_IMALLOC_ALLOCS)));
00665 	::EnableWindow(GetDlgItem(IDB_IMALLOC_ALLOCS), GetErrorPosting(EP_IMALLOC_SPY));
00666 	::EnableWindow(GetDlgItem(IDB_BREAKID),      GetErrorPosting(EP_IMALLOC_SPY));
00667
00668   //BreakID
00669   CheckDlgButton(IDB_BREAKID,           BST2STATE(g_dwBreakID));
00670   wSendMessageFmt(GetDlgItem(IDE_BREAKID), WM_SETTEXT, 0, L"%d", g_dwBreakID);
00671 	::EnableWindow(GetDlgItem(IDE_BREAKID), GetErrorPosting(EP_IMALLOC_SPY) && g_dwBreakID);
00672
00673   //RefCounts
00674   CheckDlgButton(IDB_REFCOUNT_FAILURE,      BST2STATE(GetErrorPosting(EP_REFCOUNT_FAILURE)));
00675
00676   //Delegate
00677   return CPropPageLite::OnInitDialog();
00678 }
00679
00680
00681 /////////////////////////////////////////////////////////////////////////////
00682 // COptionsError::OnApply
00683 //
00684 /////////////////////////////////////////////////////////////////////////////
00685 BOOL COptionsError::OnApply()
00686 {
00687   //ErrorInfo
00688   SetErrorPosting(EP_ERRORINFO_ALWAYS,  IsDlgButtonChecked(IDB_ERRORINFO_ALWAYS));
00689   SetErrorPosting(EP_ERRORINFO_FAILURE, IsDlgButtonChecked(IDB_ERRORINFO_FAILURE));
00690   SetErrorPosting(EP_ERRORINFO_NEVER,   IsDlgButtonChecked(IDB_ERRORINFO_NEVER));
00691
00692   //HRESULTs
00693   SetErrorPosting(EP_HRESULT_ALWAYS,    IsDlgButtonChecked(IDB_HRESULT_ALWAYS));
00694   SetErrorPosting(EP_HRESULT_NOERRORINFO, IsDlgButtonChecked(IDB_HRESULT_NOERRORINFO));
00695   SetErrorPosting(EP_HRESULT_FAILURE,   IsDlgButtonChecked(IDB_HRESULT_FAILURE));
00696   SetErrorPosting(EP_HRESULT_NEVER,   IsDlgButtonChecked(IDB_HRESULT_NEVER));
00697
00698   //IMallocSpy
00699   SetErrorPosting(EP_IMALLOC_SPY,     IsDlgButtonChecked(IDB_IMALLOC_SPY));
00700   SetErrorPosting(EP_IMALLOC_ALLOCS,    IsDlgButtonChecked(IDB_IMALLOC_ALLOCS));
00701
00702   //Do we need to turn on spying. (if not done already)
00703   if(GetErrorPosting(EP_IMALLOC_SPY))
00704   {
00705     CWinApp* pCWinApp = (CWinApp*)GetAppLite();
00706     if(pCWinApp && !pCWinApp->m_pCMallocSpy)
00707     {
00708       pCWinApp->m_pCMallocSpy = new CMallocSpy;
00709       if(pCWinApp->m_pCMallocSpy)
00710         pCWinApp->m_pCMallocSpy->Register();
00711     }
00712   }
00713
00714   //BreakID
00715   g_dwBreakID = 0;
00716   if(IsDlgButtonChecked(IDB_BREAKID))
00717   {
00718     //Obtain the BreakID value from the EditBox
00719     if(!GetEditBoxValue(GetDlgItem(IDE_BREAKID), (LONG*)&g_dwBreakID, 0/*Min*/))
00720       return FALSE;
00721   }
00722
00723   //RefCounts
00724   SetErrorPosting(EP_REFCOUNT_FAILURE,  IsDlgButtonChecked(IDB_REFCOUNT_FAILURE));
00725
00726   //delegate
00727   return CPropPageLite::OnApply();
00728 }
00729
00730
00731
00732 /////////////////////////////////////////////////////////////////////////////
00733 // COptionsError::OnCommand
00734 //
00735 /////////////////////////////////////////////////////////////////////////////
00736 BOOL COptionsError::OnCommand(UINT iID, HWND hWndCtrl)
00737 {
00738   switch(iID)
00739   {
00740     case IDB_IMALLOC_SPY:
00741     {
00742       BOOL bChecked = IsDlgButtonChecked(IDB_IMALLOC_SPY);
00743 			::EnableWindow(GetDlgItem(IDB_IMALLOC_ALLOCS), bChecked);
00744 			::EnableWindow(GetDlgItem(IDB_BREAKID),      bChecked);
00745 			::EnableWindow(GetDlgItem(IDE_BREAKID),      bChecked);
00746       return TRUE;
00747     }
00748
00749     ON_COMMAND(IDB_BREAKID,     ::EnableWindow(GetDlgItem(IDE_BREAKID),     IsDlgButtonChecked(IDB_BREAKID)))
00750   };
00751
00752   return FALSE;
00753 }
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/CConf.Cpp Source File

  • Web
  • NetMeeting
  • NMChat

CConf.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       CCONF.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 // Global Varaiables
00018 INmManager    * g_pMgr        = NULL;  // The Conference Manager
00019 CMgrNotify    * g_pMgrNotify    = NULL;  // Notifications for the Manager
00020 INmConference * g_pConference   = NULL;  // The Current Conference
00021 CConfNotify   * g_pConferenceNotify = NULL;  // Notifications for the Conference
00022 BOOL      g_fActiveConference = FALSE; // TRUE when the conference is active
00023
00024 // Local Application Guid : {D29A8C50-774F-11d0-8B1D-00A0C91BC90E}
00025 const GUID g_guidApp =
00026 { 0xd29a8c51, 0x774f, 0x11d0, { 0x8b, 0x1d, 0x0, 0xa0, 0xc9, 0x1b, 0xc9, 0xe} };
00027
00028 // NetMeeting 2.0 chat guid: {340F3A60-7067-11D0-A041-444553540000}
00029 const GUID g_guidNM2Chat =
00030 { 0x340f3a60, 0x7067, 0x11d0, { 0xa0, 0x41, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
00031
00032
00033 //****************************************************************************
00034 //
00035 // CLASS CMgrNotify
00036 //
00037 //****************************************************************************
00038
00039 //****************************************************************************
00040 //
00041 // Constructor
00042 //
00043 //****************************************************************************
00044
00045 CMgrNotify::CMgrNotify() : RefCount(), CNotify()
00046 {
00047 }
00048
00049 //****************************************************************************
00050 //
00051 // Destructor
00052 //
00053 //****************************************************************************
00054
00055 CMgrNotify::~CMgrNotify()
00056 {
00057 }
00058
00059
00060 //****************************************************************************
00061 //
00062 // Methods from IUnknown
00063 //
00064 //****************************************************************************
00065
00066 ULONG STDMETHODCALLTYPE CMgrNotify::AddRef(void)
00067 {
00068   return RefCount::AddRef();
00069 }
00070
00071
00072 ULONG STDMETHODCALLTYPE CMgrNotify::Release(void)
00073 {
00074   return RefCount::Release();
00075 }
00076
00077 HRESULT STDMETHODCALLTYPE CMgrNotify::QueryInterface(REFIID riid, PVOID *ppvObject)
00078 {
00079   if(NULL == ppvObject)
00080   {
00081     return E_POINTER;
00082   }
00083
00084   HRESULT hr = NO_ERROR;
00085
00086   if (riid == IID_IUnknown)
00087   {
00088     *ppvObject = (IUnknown *)this;
00089   }
00090   else if (riid == IID_INmManagerNotify)
00091   {
00092     *ppvObject = (INmManagerNotify *)this;
00093   }
00094   else
00095   {
00096     hr = E_NOINTERFACE;
00097     *ppvObject = NULL;
00098   }
00099
00100   if (SUCCEEDED(hr))
00101   {
00102     AddRef();
00103   }
00104
00105   return hr;
00106 }
00107
00108
00109 //****************************************************************************
00110 //
00111 // HRESULT InitConfMgr(void)
00112 //
00113 //****************************************************************************
00114
00115 HRESULT InitConfMgr(void)
00116 {
00117   HRESULT hr      = NO_ERROR;
00118   LPCLASSFACTORY pcf  = NULL;
00119
00120     // Notify the system we want to use the conferencing services
00121     // by creating a conference manager object
00122     hr = CoGetClassObject(CLSID_NmManager,
00123                           CLSCTX_INPROC,
00124                           NULL,
00125                           IID_IClassFactory,
00126                           (void**)&pcf);
00127     if (SUCCEEDED(hr))
00128     {
00129         // Get the conference manager object
00130         hr = pcf->CreateInstance(NULL, IID_INmManager, (void**)&g_pMgr);
00131       if (SUCCEEDED(hr))
00132         {
00133             // Connect to the conference manager object
00134             g_pMgrNotify = new CMgrNotify();
00135             if (NULL != g_pMgrNotify)
00136             {
00137                 hr = g_pMgrNotify->Connect(g_pMgr);
00138           if (SUCCEEDED(hr))
00139                 {
00140                   ULONG uchCaps = NMCH_ALL;
00141                   ULONG uOptions = 0;
00142           hr = g_pMgr->Initialize(&uOptions, &uchCaps);
00143           if(FAILED(hr))
00144           {
00145             return hr;
00146           }
00147         }
00148             }
00149         }
00150
00151         pcf->Release();
00152     }
00153
00154   return hr;
00155 }
00156
00157
00158 //****************************************************************************
00159 //
00160 // VOID FreeConfMgr(void)
00161 //
00162 //****************************************************************************
00163
00164 VOID FreeConfMgr(void)
00165 {
00166   // Release conference manager notify
00167   if (NULL != g_pMgrNotify)
00168   {
00169     g_pMgrNotify->Disconnect();
00170     g_pMgrNotify->Release();
00171     g_pMgrNotify = NULL;
00172   }
00173
00174   // Release conference manager
00175   if (NULL != g_pMgr)
00176   {
00177     g_pMgr->Release();
00178     g_pMgr = NULL;
00179   }
00180 }
00181
00182
00183 //****************************************************************************
00184 //
00185 // VOID FreeConference(void)
00186 //
00187 //****************************************************************************
00188
00189 VOID FreeConference(void)
00190 {
00191   if (NULL != g_pConferenceNotify)
00192   {
00193     g_pConferenceNotify->Disconnect();
00194     g_pConferenceNotify->Release();
00195     g_pConferenceNotify = NULL;
00196   }
00197
00198   if (NULL != g_pConference)
00199   {
00200     g_pConference->Release();
00201     g_pConference = NULL;
00202   }
00203 }
00204
00205
00206 //****************************************************************************
00207 //
00208 // Methods from ICNotify
00209 //
00210 //****************************************************************************
00211
00212 HRESULT STDMETHODCALLTYPE CMgrNotify::Connect(IUnknown *pUnk)
00213 {
00214   return CNotify::Connect(pUnk, IID_INmManagerNotify, (IUnknown *)this);
00215 }
00216
00217 HRESULT STDMETHODCALLTYPE CMgrNotify::Disconnect(void)
00218 {
00219   return CNotify::Disconnect();
00220 }
00221
00222
00223 //****************************************************************************
00224 //
00225 // Methods from INmManagerNotify
00226 //
00227 //****************************************************************************
00228
00229 HRESULT STDMETHODCALLTYPE CMgrNotify::NmUI(CONFN confn)
00230 {
00231   return S_OK;
00232 }
00233
00234 HRESULT STDMETHODCALLTYPE CMgrNotify::CallCreated(INmCall *pCall)
00235 {
00236   return S_OK;
00237 }
00238
00239 // As soon as a conference is available, create the data channel
00240 HRESULT STDMETHODCALLTYPE CMgrNotify::ConferenceCreated(INmConference *pConference)
00241 {
00242   if(NULL == pConference)
00243   {
00244     return E_POINTER;
00245   }
00246
00247   HookConference(pConference);
00248
00249   return S_OK;
00250 }
00251
00252
00253 //****************************************************************************
00254 //
00255 // HRESULT HookConference(INmConference * pConference)
00256 //
00257 //****************************************************************************
00258
00259 HRESULT HookConference(INmConference * pConference)
00260 {
00261   HRESULT hr = NO_ERROR;
00262
00263   ASSERT(NULL != pConference);
00264   ASSERT(NULL == g_pConference);
00265
00266   if(NULL == pConference)
00267   {
00268     return E_POINTER;
00269   }
00270
00271   if(NULL != g_pConference)
00272   {
00273     return E_POINTER;
00274   }
00275
00276   g_pConference = pConference;
00277
00278   pConference->AddRef();
00279
00280     // Connect to the conference object
00281     ASSERT(NULL == g_pConferenceNotify)
00282     g_pConferenceNotify = new CConfNotify();
00283     if (NULL == g_pConferenceNotify)
00284     {
00285         hr = E_OUTOFMEMORY;
00286     }
00287     else
00288     {
00289     hr = g_pConferenceNotify->Connect(pConference);
00290     if (FAILED(hr))
00291     {
00292       g_pConferenceNotify->Release();
00293       g_pConferenceNotify = NULL;
00294     }
00295   }
00296
00297   return hr;
00298 }
00299
00300
00301 //****************************************************************************
00302 //
00303 // CLASS CConfNotify
00304 //
00305 //****************************************************************************
00306
00307 //****************************************************************************
00308 //
00309 // Constructor
00310 //
00311 //****************************************************************************
00312
00313 CConfNotify::CConfNotify() : RefCount(), CNotify()
00314 {
00315 }
00316
00317
00318 //****************************************************************************
00319 //
00320 // Destructor
00321 //
00322 //****************************************************************************
00323
00324 CConfNotify::~CConfNotify()
00325 {
00326 }
00327
00328
00329 //****************************************************************************
00330 //
00331 // Methods from IUnknown
00332 //
00333 //****************************************************************************
00334
00335 ULONG STDMETHODCALLTYPE CConfNotify::AddRef(void)
00336 {
00337   return RefCount::AddRef();
00338 }
00339
00340
00341 ULONG STDMETHODCALLTYPE CConfNotify::Release(void)
00342 {
00343   return RefCount::Release();
00344 }
00345
00346 HRESULT STDMETHODCALLTYPE CConfNotify::QueryInterface(REFIID riid, PVOID *ppvObject)
00347 {
00348   if(NULL == ppvObject)
00349   {
00350     return E_POINTER;
00351   }
00352
00353   HRESULT hr = NO_ERROR;
00354
00355   if (riid == IID_IUnknown)
00356   {
00357     *ppvObject = (IUnknown *)this;
00358   }
00359   else if (riid == IID_INmConferenceNotify)
00360   {
00361     *ppvObject = (INmConferenceNotify *)this;
00362   }
00363   else
00364   {
00365     hr = E_NOINTERFACE;
00366     *ppvObject = NULL;
00367   }
00368
00369   if(SUCCEEDED(hr))
00370   {
00371     AddRef();
00372   }
00373
00374   return hr;
00375 }
00376
00377
00378 //****************************************************************************
00379 //
00380 // Methods from ICNotify
00381 //
00382 //****************************************************************************
00383
00384 HRESULT STDMETHODCALLTYPE CConfNotify::Connect(IUnknown *pUnk)
00385 {
00386   return CNotify::Connect(pUnk, IID_INmConferenceNotify, (IUnknown *)this);
00387 }
00388
00389 HRESULT STDMETHODCALLTYPE CConfNotify::Disconnect(void)
00390 {
00391   return CNotify::Disconnect();
00392 }
00393
00394
00395 //****************************************************************************
00396 //
00397 // Methods from IConfNotify
00398 //
00399 //****************************************************************************
00400
00401 HRESULT STDMETHODCALLTYPE CConfNotify::NmUI(CONFN uNotify)
00402 {
00403   return S_OK;
00404 }
00405
00406 HRESULT STDMETHODCALLTYPE CConfNotify::StateChanged(NM_CONFERENCE_STATE uState)
00407 {
00408   if (NULL == g_pConference)
00409     return S_OK;
00410
00411   switch (uState)
00412   {
00413     case NM_CONFERENCE_ACTIVE:
00414     {
00415       g_fActiveConference = TRUE;
00416       CheckDataChannel();
00417       break;
00418     }
00419     case NM_CONFERENCE_INITIALIZING:
00420     {
00421       break; // can't do anything just yet
00422     }
00423     case NM_CONFERENCE_WAITING:
00424     {
00425       DisplaySysMsg(TEXT("Waiting in Host Mode"), NULL);
00426       g_fActiveConference = FALSE;
00427       FreeDataChannel();
00428       break;
00429     }
00430     case NM_CONFERENCE_IDLE:
00431     {
00432       DisplaySysMsg(TEXT("No conference"), NULL);
00433       g_fActiveConference = FALSE;
00434       FreeDataChannel();
00435       FreeConference();
00436       break;
00437     }
00438   }
00439   return S_OK;
00440 }
00441
00442 HRESULT STDMETHODCALLTYPE CConfNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
00443 {
00444   switch (uNotify)
00445   {
00446     case NM_MEMBER_ADDED:
00447     {
00448       if (S_OK == pMember->IsSelf())
00449       {
00450         ASSERT(NULL == g_pMemberLocal);
00451         g_pMemberLocal = pMember;
00452         g_pMemberLocal->AddRef();
00453       }
00454       break;
00455     }
00456
00457     case NM_MEMBER_REMOVED:
00458     {
00459       if (g_pMemberLocal == pMember)
00460       {
00461         g_pMemberLocal->Release();
00462         g_pMemberLocal = NULL;
00463       }
00464       break;
00465     }
00466
00467     default:
00468     case NM_MEMBER_UPDATED:
00469     {
00470       // Check if the data channel should be added
00471       if (g_fActiveConference && (g_pMemberLocal == pMember) )
00472       {
00473         CheckDataChannel();
00474       }
00475       break;
00476     }
00477   }
00478
00479   return S_OK;
00480 }
00481
00482 HRESULT STDMETHODCALLTYPE CConfNotify::ChannelChanged(NM_CHANNEL_NOTIFY uNotify, INmChannel *pChannel)
00483 {
00484   return S_OK;
00485 }
00486
00487
00488
00489
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DragImg/DragImg.h Source File

  • WinUI
  • Shell
  • DragImg

DragImg.h

Go to the documentation of this file.
00001
00002 BOOL InitApplication(HINSTANCE);
00003 BOOL InitInstance(HINSTANCE, int);
00004 extern "C" {
00005 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
00006 LRESULT CALLBACK About  (HWND, UINT, WPARAM, LPARAM);
00007 }
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MSDI Member List

This is the complete list of members for _MSDI, including all inherited members.
cmsd | _MSDI
edwp | _MSDI
rgmsd | _MSDI
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

DEB_DLL_NODE_INFO_STRUCT Member List

This is the complete list of members for DEB_DLL_NODE_INFO_STRUCT, including all inherited members.
DllDebugInfo | DEB_DLL_NODE_INFO_STRUCT
lpstrFileName | DEB_DLL_NODE_INFO_STRUCT
lpstrPathName | DEB_DLL_NODE_INFO_STRUCT
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/StatList.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

StatList.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 STATLIST.H
00010 ---------------------------------------------------------------------------*/
00011
00012 // Makes it easier to determine appropriate code paths:
00013 #define IS_WIN32 TRUE
00014 #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
00015 #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
00016 #define IS_WIN95 (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
00017
00018 #define IDM_NEW            101
00019 #define IDM_OPEN           102
00020 #define IDM_SAVE           103
00021 #define IDM_SAVEAS         104
00022 #define IDM_EXIT           105
00023
00024 #define IDM_ADD_COUNTERS   201
00025 #define IDM_DELETE_COUNTER 202
00026 #define IDM_CLEAR_ALL      203
00027 #define IDM_SETTINGS       204
00028
00029 #define IDM_GET_DATA       300
00030
00031 #define IDM_HELPTOPICS     401
00032 #define IDM_ABOUT          402
00033
00034 #define IDC_STATIC -1
00035
00036 #define DLG_VERFIRST        1000
00037 #define IDC_COMPANY         DLG_VERFIRST
00038 #define IDC_FILEDESC        DLG_VERFIRST+1
00039 #define IDC_PRODVER         DLG_VERFIRST+2
00040 #define IDC_COPYRIGHT       DLG_VERFIRST+3
00041 #define IDC_OSVERSION       DLG_VERFIRST+4
00042 #define IDC_TRADEMARK       DLG_VERFIRST+5
00043 #define DLG_VERLAST         DLG_VERFIRST+5
00044
00045 #define IDC_LABEL           DLG_VERLAST+1
00046
00047
00048 #define IDS_APP_TITLE       500
00049 #define IDS_DISPLAYCHANGED  501
00050 #define IDS_VER_INFO_LANG   502
00051 #define IDS_VERSION_ERROR   503
00052 #define IDS_NO_HELP         504
00053
00054 extern char APPNAME[];
00055
00056 
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

THREADARGS Member List

This is the complete list of members for THREADARGS, including all inherited members.
compopts | THREADARGS
fDeep | THREADARGS
fDescribeFiles | THREADARGS
fExit | THREADARGS
fInputFile | THREADARGS
fInputFileSingle | THREADARGS
first | THREADARGS
fOpenedFiles | THREADARGS
listopts | THREADARGS
notify | THREADARGS
savecomp | THREADARGS
savelist | THREADARGS
second | THREADARGS
view | THREADARGS
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/extend.h Source File

  • SysMgmt
  • MMC
  • Extens

extend.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _EXTEND_H
00021 #define _EXTEND_H
00022
00023 #include <tchar.h>
00024
00025 struct NODESTRUCT
00026 {
00027     GUID  GUID;
00028     _TCHAR  szDescription[256];
00029 };
00030
00031 #endif // _EXTEND_H
00032
00033
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/MultiReco/MultiReco.cpp Source File

  • TabletPC
  • MultiReco

MultiReco.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      MultiReco.cpp
00013 //
00014 // Description:
00015 //      This sample demonstrates such advanced features of the
00016 //      Microsoft Tablet PC Automation API used for handwriting
00017 //      recognition, as
00018 //          - serializing recognition results with a stroke collection
00019 //          - organizing stroke collections into a custom collection
00020 //            within the ink object
00021 //          - serializing ink object into/from an ISF file
00022 //          - enumerating the installed recognizers
00023 //          - creating a recognition context with a specific language
00024 //            recognizer
00025 //          - setting recognizer input guides
00026 //          - synchronous and asynchronous recognition
00027 //
00028 //      This application is discussed in the Getting Started guide.
00029 //
00030 //      (NOTE: For code simplicity, returned HRESULT is not checked
00031 //             for failure in the places where failures are not critical
00032 //             for the application)
00033 //
00034 //      The interfaces used are:
00035 //      IInkRecognizers, IInkRecognizer, IInkRecognizerContext,
00036 //      IInkRecognitionResult, IInkRecognizerGuide,
00037 //      IInkCollector, IInkDisp, IInkRenderer, IInkDrawingAttributes,
00038 //      IInkCustomStrokes, IInkStrokes, IInkStroke
00039 //
00040 // Requirements:
00041 //      One or more handwriting recognizer must be installed on the system.
00042 //      Also, appropriate Asian fonts need to be installed to output the
00043 //      results of the Asian recognizers.
00044 //
00045 //--------------------------------------------------------------------------
00046
00047 #ifndef _WIN32_WINNT
00048 #define _WIN32_WINNT 0x0500
00049 #endif
00050
00051 // Windows header files
00052 #include <windows.h>
00053 #include <commctrl.h>       // need it to call CreateStatusWindow
00054 #include <commdlg.h>
00055
00056 // A useful macro to determine the number of elements in the array
00057 #define countof(array)  (sizeof(array)/sizeof(array[0]))
00058
00059 // ATL header files
00060 #include <atlbase.h>        // defines CComModule, CComPtr, CComVariant
00061 CComModule _Module;
00062 #include <atlwin.h>         // defines CWindowImpl
00063 #include <atlcom.h>         // defines IDispEventSimpleImpl
00064
00065 // Headers for Tablet PC Automation interfaces
00066 #include <msinkaut.h>
00067 #include <msinkaut_i.c>
00068
00069 // The application header files
00070 #include "resource.h"       // main symbols, including command ID's
00071 #include "EventSinks.h"     // defines the IInkEventsImpl and IInkRecognitionEventsImpl
00072 #include "ChildWnds.h"      // definitions of the CInkInputWnd and CRecoOutputWnd
00073 #include "MultiReco.h"      // contains the definition of CAddRecoApp
00074
00075 // The static members of the event sink templates are initialized here
00076 // (defined in EventSinks.h). These _ATL_FUNC_INFO structures contain type information
00077 // used to describe a method or property on a dispinterface.
00078
00079 // Type information of the Recognition event of IInkRecognitionEvents
00080 const _ATL_FUNC_INFO IInkRecognitionEventsImpl<CMultiRecoApp>::mc_AtlFuncInfo =
00081         {CC_STDCALL, VT_EMPTY, 3, {VT_BSTR, VT_VARIANT, VT_I4}};
00082
00083 // Type information of the Stroke event of IInkCollectorEvents
00084 const _ATL_FUNC_INFO IInkCollectorEventsImpl<CMultiRecoApp>::mc_AtlFuncInfo =
00085         {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_UNKNOWN, VT_BOOL|VT_BYREF}};
00086
00087
00088 // The sample uses different colors for different collections of strokes. Below is the palette.
00089 const COLORREF CMultiRecoApp::mc_crColors[] = {
00090      RGB( 0, 0, 0)/*black*/, RGB(0xA0,0,0)/*red*/, RGB(0,0xA0,0)/*green*/, RGB(0,0,0xA0)/*blue*/,
00091      RGB(0xA0,0xA0,0)/**/, RGB(0xA0,0,0xA0)/**/, RGB(0,0xA0,0xA0)/**/, RGB(0xA0,0xA0,0xA0)/*gray*/
00092 };
00093
00094 const WCHAR gc_szAppName[] = L"Multiple Language Recognition with Serialization";
00095
00096 /////////////////////////////////////////////////////////
00097 //
00098 // WinMain
00099 //
00100 // The WinMain function is called by the system as the
00101 // initial entry point for a Win32-based application.
00102 //
00103 // Parameters:
00104 //        HINSTANCE hInstance,      : [in] handle to current instance
00105 //        HINSTANCE hPrevInstance,  : [in] handle to previous instance
00106 //        LPSTR lpCmdLine,          : [in] command line
00107 //        int nCmdShow              : [in] show state
00108 //
00109 // Return Values (int):
00110 //        0 : The function terminated before entering the message loop.
00111 //        non zero: Value of the wParam when receiving the WM_QUIT message
00112 //
00113 /////////////////////////////////////////////////////////
00114 int APIENTRY WinMain(
00115         HINSTANCE hInstance,
00116         HINSTANCE /*hPrevInstance*/,   // not used here
00117         LPSTR     /*lpCmdLine*/,       // not used here
00118         int       nCmdShow
00119         )
00120 {
00121     int iRet = 0;
00122
00123     // Initialize the COM library and the application module
00124     if (S_OK == ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))
00125     {
00126         _Module.Init(NULL, hInstance);
00127
00128         // Register the common control classes used by the application
00129         INITCOMMONCONTROLSEX icc;
00130         icc.dwSize = sizeof(icc);
00131         icc.dwICC = ICC_BAR_CLASSES;
00132         if (TRUE == ::InitCommonControlsEx(&icc))
00133         {
00134             // Call the boilerplate function of the application
00135             iRet = CMultiRecoApp::Run(nCmdShow);
00136         }
00137         else
00138         {
00139             ::MessageBoxW(NULL, L"Error initializing the common controls.",
00140                          gc_szAppName, MB_ICONERROR | MB_OK);
00141         }
00142
00143         // Release the module and the COM library
00144         _Module.Term();
00145         ::CoUninitialize();
00146     }
00147
00148     return iRet;
00149 }
00150
00151 /////////////////////////////////////////////////////////
00152 //
00153 // CMultiRecoApp::Run
00154 //
00155 // The static CMultiRecoApp::Run is the boilerplate of the application.
00156 // It instantiates and initializes an CMultiRecoApp object and runs the
00157 // application's message loop.
00158 //
00159 // Parameters:
00160 //      int nCmdShow              : [in] show state
00161 //
00162 // Return Values (int):
00163 //      0 : The function terminated before entering the message loop.
00164 //      non zero: Value of the wParam when receiving the WM_QUIT message
00165 //
00166 /////////////////////////////////////////////////////////
00167 int CMultiRecoApp::Run(
00168         int nCmdShow
00169         )
00170 {
00171
00172     CMultiRecoApp theApp;
00173
00174     // Load and update the menu before creating the main window.
00175     // Create menu items for the installed recognizers and for the
00176     // supported factoids.
00177     HMENU hMenu = theApp.LoadMenu();
00178     if (NULL == hMenu)
00179         return 0;
00180
00181     int iRet;
00182
00183     // Load the icon from the resource and associate it with the window class
00184     WNDCLASSEX& wc = CMultiRecoApp::GetWndClassInfo().m_wc;
00185     wc.hIcon = wc.hIconSm = ::LoadIcon(_Module.GetResourceInstance(),
00186                                        MAKEINTRESOURCE(IDR_APPICON));
00187
00188     // Create the application's main window
00189     if (theApp.Create(NULL, CWindow::rcDefault, gc_szAppName,
00190                       WS_OVERLAPPEDWINDOW, 0, (UINT)hMenu) != NULL)
00191     {
00192         // Initialize the application object:
00193         // Create an ink object
00194         theApp.SendMessage(WM_COMMAND, ID_FILE_NEW);
00195         // Create a recognition context using the first recognizer in the list
00196         // and start new stroke collection
00197         theApp.SendMessage(WM_COMMAND, ID_RECOGNIZER_FIRST);
00198
00199         // Show and update the main window
00200         theApp.ShowWindow(nCmdShow);
00201         theApp.UpdateWindow();
00202
00203         // Run the boilerplate message loop
00204         MSG msg;
00205         while (::GetMessage(&msg, NULL, 0, 0) > 0)
00206         {
00207             ::TranslateMessage(&msg);
00208             ::DispatchMessage(&msg);
00209         }
00210         iRet = msg.wParam;
00211     }
00212     else
00213     {
00214         ::MessageBoxW(NULL, L"Error creating the window",
00215                      gc_szAppName, MB_ICONERROR | MB_OK);
00216         ::DestroyMenu(hMenu);
00217         iRet = 0;
00218     }
00219
00220     return iRet;
00221 }
00222
00223 // Window message handlers //////////////////////////////
00224
00225 /////////////////////////////////////////////////////////
00226 //
00227 // CMultiRecoApp::OnCreate
00228 //
00229 // This WM_CREATE message handler creates the child windows,
00230 // creates the required objects, sets their attributes,
00231 // and enables pen input.
00232 //
00233 // Parameters:
00234 //      defined in the ATL's macro MESSAGE_HANDLER,
00235 //      none of them is used here
00236 //
00237 // Return Values (LRESULT):
00238 //      0 if succeeded, or -1 otherwise
00239 //
00240 /////////////////////////////////////////////////////////
00241 LRESULT CMultiRecoApp::OnCreate(
00242         UINT /*uMsg*/,
00243         WPARAM /*wParam*/,
00244         LPARAM /*lParam*/,
00245         BOOL& /*bHandled*/
00246         )
00247 {
00248     // Create child windows for ink input and recognition output,
00249     // listview controls for the lists of gestures, and a status bar
00250     if (false == CreateChildWindows())
00251         return -1;
00252
00253     HRESULT hr;
00254
00255     // Create an ink collector object.
00256     hr = m_spIInkCollector.CoCreateInstance(CLSID_InkCollector);
00257     if (FAILED(hr))
00258         return -1;
00259
00260     // Establish a connection to the collector's event source.
00261     hr = IInkCollectorEventsImpl<CMultiRecoApp>::DispEventAdvise(m_spIInkCollector);
00262     // There is nothing interesting the application can do without events
00263     // from the ink collector
00264     if (FAILED(hr))
00265         return -1;
00266
00267     // Enable ink input in the m_wndInput window
00268     hr = m_spIInkCollector->put_hWnd((long)m_wndInput.m_hWnd);
00269     if (FAILED(hr))
00270         return -1;
00271     hr = m_spIInkCollector->put_Enabled(VARIANT_TRUE);
00272     if (FAILED(hr))
00273         return -1;
00274
00275     // Create recognition guide objects
00276     CreateRecoGuides();
00277
00278     return 0;
00279 }
00280
00281 /////////////////////////////////////////////////////////
00282 //
00283 // CMultiRecoApp::OnDestroy
00284 //
00285 // The WM_DESTROY message handler.
00286 // Used for clean up and also to post a quit message to
00287 // the application itself.
00288 //
00289 // Parameters:
00290 //      defined in the ATL's macro MESSAGE_HANDLER,
00291 //      none is used here
00292 //
00293 // Return Values (LRESULT):
00294 //      always 0
00295 //
00296 /////////////////////////////////////////////////////////
00297 LRESULT CMultiRecoApp::OnDestroy(
00298         UINT /*uMsg*/,
00299         WPARAM /*wParam*/,
00300         LPARAM /*lParam*/,
00301         BOOL& /*bHandled*/
00302         )
00303 {
00304     // Disable ink input and release the InkCollector object
00305     if (m_spIInkCollector != NULL)
00306     {
00307         IInkCollectorEventsImpl<CMultiRecoApp>::DispEventUnadvise(m_spIInkCollector);
00308         m_spIInkCollector->put_Enabled(VARIANT_FALSE);
00309         m_spIInkCollector.Release();
00310     }
00311
00312     // Detach the strokes collection from the recognition context
00313     // and stop listening to the recognition events
00314     if (m_spIInkRecoContext != NULL)
00315     {
00316         m_spIInkRecoContext->EndInkInput();
00317         IInkRecognitionEventsImpl<CMultiRecoApp>::DispEventUnadvise(m_spIInkRecoContext);
00318         m_spIInkRecoContext.Release();
00319     }
00320
00321     // Release the other objects and collections
00322     m_spIInkRecoGuideLined.Release();
00323     m_spIInkRecoGuideBoxed.Release();
00324     m_spIInkStrokes.Release();
00325     m_spIInkRecognizers.Release();
00326
00327     // Post a WM_QUIT message to the application's message queue
00328     ::PostQuitMessage(0);
00329
00330     return 0;
00331 }
00332
00333 /////////////////////////////////////////////////////////
00334 //
00335 // CMultiRecoApp::OnSize
00336 //
00337 // The WM_SIZE message handler is needed to update
00338 // the layout of the child windows
00339 //
00340 // Parameters:
00341 //      defined in the ATL's macro MESSAGE_HANDLER,
00342 //      wParam of the WN_SIZE message is the only used here.
00343 //
00344 // Return Values (LRESULT):
00345 //      always 0
00346 //
00347 /////////////////////////////////////////////////////////
00348 LRESULT CMultiRecoApp::OnSize(
00349         UINT /*uMsg*/,
00350         WPARAM wParam,
00351         LPARAM /*lParam*/,
00352         BOOL& /*bHandled*/
00353         )
00354 {
00355     if (wParam != SIZE_MINIMIZED)
00356     {
00357         UpdateLayout();
00358     }
00359     return 0;
00360 }
00361
00362
00363 // InkCollector event handlers ///////////////////////////
00364
00365 /////////////////////////////////////////////////////////
00366 //
00367 // CMultiRecoApp::OnStroke
00368 //
00369 // The _IInkCollectorEvents's Stroke event handler.
00370 // See the Tablet PC Automation API Reference for the
00371 // detailed description of the event and its parameters.
00372 //
00373 // Parameters:
00374 //      IInkCursor* pIInkCursor     : [in] not used here
00375 //      IInkStrokeDisp* pInkStroke  : [in] the new stroke's interface pointer
00376 //      VARIANT_BOOL* pbCancel      : [in,out] option to cancel the gesture,
00377 //                                    default value is FALSE, not modified here
00378 //
00379 // Return Values (HRESULT):
00380 //      S_OK if succeeded, E_FAIL or E_INVALIDARG otherwise
00381 //
00382 /////////////////////////////////////////////////////////
00383 HRESULT CMultiRecoApp::OnStroke(
00384         IInkCursor* /*pIInkCursor*/,
00385         IInkStrokeDisp* pIInkStroke,
00386         VARIANT_BOOL* pbCancel
00387         )
00388 {
00389     if (m_spIInkStrokes == NULL)    // shouldn't happen
00390         return E_FAIL;
00391
00392     if (NULL == pIInkStroke)
00393         return E_INVALIDARG;
00394
00395     HRESULT hr;
00396
00397     // Add the new stroke to the current collection
00398     hr = m_spIInkStrokes->Add(pIInkStroke);
00399
00400     if (SUCCEEDED(hr))
00401     {
00402         // Cancel the previous background recognition requests
00403         // which have not been processed yet
00404         m_spIInkRecoContext->StopBackgroundRecognition();
00405
00406         // Ask the context to update the recognition results with newly added strokes
00407         // When the results are ready, the recognition context will return them
00408         // via the corresponding event RecognitionWithAlternates
00409         CComVariant vCustomData;
00410         m_spIInkRecoContext->BackgroundRecognize(vCustomData);
00411     }
00412     return hr;
00413 }
00414
00415 // Recognition event handler ////////////////////////////
00416
00417 /////////////////////////////////////////////////////////
00418 //
00419 // CMultiRecoApp::OnRecognition
00420 //
00421 // The _IInkRecognitionEvents's Recognition event handler
00422 //
00423 // Parameters:
00424 //      BSTR bstrRecognizedString : the top result of the recognition
00425 //      VARIANT vCustomParam      : not used here
00426 //      InkRecognitionStatus RecognitionStatus : not used here
00427 //
00428 // Return Values (HRESULT):
00429 //      always S_OK
00430 //
00431 /////////////////////////////////////////////////////////
00432 HRESULT CMultiRecoApp::OnRecognition(
00433         BSTR bstrRecognizedString,
00434         VARIANT /*vCustomParam*/,
00435         InkRecognitionStatus /*RecognitionStatus*/
00436         )
00437 {
00438     if (m_wndResults.IsWindow())
00439     {
00440         // Update the output window with the new results
00441         m_wndResults.UpdateString(bstrRecognizedString);
00442     }
00443
00444     if (NULL != bstrRecognizedString)
00445         ::SysFreeString(bstrRecognizedString);
00446
00447     return S_OK;
00448 }
00449
00450 // Command handlers /////////////////////////////////////
00451
00452 /////////////////////////////////////////////////////////
00453 //
00454 // CMultiRecoApp::OnClear
00455 //
00456 // Deletes all strokes and recognition results from the
00457 // ink object and clears the windows.
00458 //
00459 // Parameters:
00460 //      defined in the ATL's macro COMMAND_RANGE_HANDLER
00461 //      Here only wID - the id of the command associated
00462 //      with the recognizer menu item -  is used.
00463 //
00464 // Return Values (LRESULT):
00465 //      always 0
00466 //
00467 /////////////////////////////////////////////////////////
00468 LRESULT CMultiRecoApp::OnClear(
00469         WORD /*wNotifyCode*/,
00470         WORD /*wID*/,
00471         HWND /*hWndCtl*/,
00472         BOOL& /*bHandled*/
00473         )
00474 {
00475     if (m_spIInkDisp == NULL)   // there is nothing to clear
00476         return 0;
00477
00478     // Detach the current stroke collection from the recognition context and release it
00479     if (m_spIInkRecoContext != NULL)
00480         m_spIInkRecoContext->putref_Strokes(NULL);
00481     m_spIInkStrokes.Release();
00482
00483     // Clear the custom strokes collection
00484     if (m_spIInkCustomStrokes != NULL)
00485         m_spIInkCustomStrokes->Clear();
00486
00487     // Delete all strokes from the Ink object
00488     m_spIInkDisp->DeleteStrokes(NULL);  // Passing NULL as a stroke collection pointer
00489                                         // means asking to delete all strokes
00490
00491     // Get a new stroke collection from the ink object
00492
00493     CComVariant v;  // This varaint is used to pass an array of ID's of the strokes
00494                     // which to be included into the new collection.
00495     // Ask for an empty collection by passing an empty variant
00496     if (SUCCEEDED(m_spIInkDisp->CreateStrokes(v, &m_spIInkStrokes)))
00497     {
00498         // Attach it to the recognition context
00499         if (FAILED(m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes)))
00500         {
00501             MessageBoxW(L"Unable to attach the stroke collection to "
00502                         L"the recognition context",
00503                         gc_szAppName, MB_ICONERROR | MB_OK);
00504         }
00505     }
00506     else
00507     {
00508         MessageBoxW(L"Error creating new stroke collection.",
00509                     gc_szAppName, MB_ICONERROR | MB_OK);
00510     }
00511
00512     // Update the child windows
00513     m_wndInput.Invalidate();
00514     m_wndResults.ResetResults();    // resets the text and updates the window
00515
00516     // Tell the results window that a new stroke collection
00517     // is started, and set the color for it.
00518     m_wndResults.AddString(
00519             mc_crColors[m_iColor],  // new current color
00520             NULL                    // recognition result string, none yet
00521             );
00522
00523     return 0;
00524 }
00525
00526 /////////////////////////////////////////////////////////
00527 //
00528 // CMultiRecoApp::OnNewStrokes
00529 //
00530 // This command handler is called when user selects a recognizer
00531 // in the "New Strokes" submenu. It saves the current stroke collection,
00532 // creates a new recognition context if user selected a different language
00533 // recognizer, and then starts a new collection of strokes attached to
00534 // the new recognition context.
00535 //
00536 // Parameters:
00537 //      defined in the ATL's macro COMMAND_RANGE_HANDLER
00538 //      Here only wID - the id of the command associated
00539 //      with the recognizer menu item -  is used.
00540 //
00541 // Return Values (LRESULT):
00542 //      always 0
00543 //
00544 /////////////////////////////////////////////////////////
00545 LRESULT CMultiRecoApp::OnNewStrokes(
00546         WORD /*wNotifyCode*/,
00547         WORD wID,
00548         HWND /*hWndCtl*/,
00549         BOOL& /*bHandled*/
00550         )
00551 {
00552     // Change cursor to the system's Hourglass
00553     HCURSOR hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));
00554
00555     // Save the current stroke collection if there is any
00556     if (m_spIInkRecoContext != NULL)
00557     {
00558         // Cancel the previous background recognition requests
00559         // which have not been processed yet
00560         m_spIInkRecoContext->StopBackgroundRecognition();
00561
00562         // Let the context know that there'll be no more input
00563         // for the attached stroke collection
00564         m_spIInkRecoContext->EndInkInput();
00565
00566         // Add the stroke collection to the Ink object's CustomStrokes collection
00567         SaveStrokeCollection();
00568     }
00569
00570     // If a different recognizer was selected, create a new recognition context
00571     // Else, reuse the same recognition context
00572     if (wID != m_nCmdRecognizer)
00573     {
00574         // Get a pointer to the recognizer object from the recognizer collection
00575         CComPtr<IInkRecognizer> spIInkRecognizer;
00576         if ((m_spIInkRecognizers == NULL)
00577             || FAILED(m_spIInkRecognizers->Item(wID - ID_RECOGNIZER_FIRST,
00578                                                 &spIInkRecognizer))
00579             || (false == CreateRecoContext(spIInkRecognizer)))
00580         {
00581             // restore the cursor
00582             ::SetCursor(hCursor);
00583             return 0;
00584         }
00585
00586         // Update the status bar
00587         m_bstrCurRecoName.Empty();
00588         spIInkRecognizer->get_Name(&m_bstrCurRecoName);
00589         UpdateStatusBar();
00590
00591         // Store the selected recognizer's command id
00592         m_nCmdRecognizer = wID;
00593     }
00594
00595     // Create a new stroke collection
00596     StartNewStrokeCollection();
00597
00598     // restore the cursor
00599     ::SetCursor(hCursor);
00600
00601     return 0;
00602 }
00603
00604 // Helper methods //////////////////////////////
00605
00606 /////////////////////////////////////////////////////////
00607 //
00608 // CMultiRecoApp::StartNewStrokeCollection
00609 //
00610 // Creates an empty stroke collection and attaches it
00611 // to the recognition context.
00612 //
00613 // Parameters: none
00614 //
00615 // Return Values (void):
00616 //      ignore failures
00617 //
00618 /////////////////////////////////////////////////////////
00619 void CMultiRecoApp::StartNewStrokeCollection()
00620 {
00621     if ((m_spIInkDisp == NULL) || (m_spIInkRecoContext == NULL))
00622         return;
00623
00624     // Create a new empty stroke collection and attach it to the recognition context
00625     CComVariant vt(0);
00626     if (SUCCEEDED(m_spIInkDisp->CreateStrokes(vt, &m_spIInkStrokes)))
00627     {
00628         if (FAILED(m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes)))
00629         {
00630             MessageBoxW(L"Failed to attach the stroke collection to "
00631                         L"the recognition context",
00632                         gc_szAppName, MB_ICONERROR | MB_OK);
00633         }
00634
00635         // Change the color of the pen and text output
00636         CComPtr<IInkDrawingAttributes> spIInkDrawAttrs;
00637         if (SUCCEEDED(m_spIInkCollector->get_DefaultDrawingAttributes(&spIInkDrawAttrs)))
00638         {
00639             spIInkDrawAttrs->put_Color(mc_crColors[m_iColor]);
00640         }
00641         // Tell the output window that the new stroke collection is current now and
00642         // it's future recognition results should be shown in the RichEdit control
00643         // with a different color
00644         m_wndResults.AddString(
00645                 mc_crColors[m_iColor],  // new current color
00646                 NULL                    // recognition result string, none yet
00647                 );
00648     }
00649     else
00650     {
00651         MessageBoxW(L"Error creating new stroke collection.",
00652                     gc_szAppName, MB_ICONERROR | MB_OK);
00653     }
00654 }
00655
00656 /////////////////////////////////////////////////////////
00657 //
00658 // CMultiRecoApp::LoadMenu
00659 //
00660 // This method instantiates an enumerator object for the installed
00661 // recognizers, loads the main menu resource and creates a menu item
00662 // for the recognizers from the collection.
00663 //
00664 // Parameters:
00665 //      none
00666 //
00667 // Return Values (HMENU):
00668 //      The return value is a handle of the menu
00669 //      that'll be used for the main window
00670 //
00671 /////////////////////////////////////////////////////////
00672 HMENU CMultiRecoApp::LoadMenu()
00673 {
00674     HRESULT hr = S_OK;
00675
00676     // Create the enumerator for the installed recognizers
00677     hr = m_spIInkRecognizers.CoCreateInstance(CLSID_InkRecognizers);
00678     if (FAILED(hr))
00679         return NULL;
00680
00681     // Get the number of the recognizers known to the system
00682     LONG lCount = 0;
00683     hr = m_spIInkRecognizers->get_Count(&lCount);
00684     if (0 == lCount)
00685     {
00686         ::MessageBoxW(NULL, L"There are no handwriting recognizers installed.\n"
00687              L"You need to have at least one in order to run this sample.\nExiting.",
00688              gc_szAppName, MB_ICONERROR | MB_OK);
00689         return NULL;
00690     }
00691
00692     // Load the menu of the main window
00693     HMENU hMenu = ::LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MENU));
00694     if (NULL == hMenu)
00695         return NULL; // Not normal
00696
00697     MENUITEMINFOW miinfo;
00698     miinfo.cbSize = sizeof(miinfo);
00699     miinfo.fMask = MIIM_ID | MIIM_STATE | MIIM_TYPE;
00700     miinfo.fType = MFT_STRING;
00701
00702     // Get the submenu id for the recognizers menu.
00703     // This submenu will contain the list of installed recognizers
00704     HMENU hSubMenu = ::GetSubMenu(hMenu, mc_iSubmenuRecognizers);
00705     if (NULL == hSubMenu)
00706     {
00707         ::DestroyMenu(hMenu);
00708         return NULL; // Not normal
00709     }
00710
00711     // Remove the placeholding separator
00712     ::DeleteMenu(hSubMenu, 0, MF_BYPOSITION);
00713
00714     CComPtr<IInkRecognizer> spIInkRecognizer;
00715
00716     // Make sure that the number of menu items won't exceed
00717     // the predefined range of the corresponding command ID's
00718     if (lCount > (ID_RECOGNIZER_LAST - ID_RECOGNIZER_FIRST + 1))
00719         lCount = ID_RECOGNIZER_LAST - ID_RECOGNIZER_FIRST + 1;
00720
00721     miinfo.fState = 0;
00722     bool bAllFailed = true;
00723     for (LONG i = 0; i < lCount; i++)
00724     {
00725         if (FAILED(m_spIInkRecognizers->Item(i, &spIInkRecognizer)))
00726             continue;
00727
00728         // Filter out non-language recognizers by checking for
00729         // the languages supported by the recognizer - there'll be
00730         // none if it's a gesture or object recognizer.
00731         CComVariant vLanguages;
00732         if (SUCCEEDED(spIInkRecognizer->get_Languages(&vLanguages)))
00733         {
00734             if ((VT_ARRAY == (VT_ARRAY & vLanguages.vt))            // it should be an array
00735                 && (NULL != vLanguages.parray)
00736                 && (0 < vLanguages.parray->rgsabound[0].cElements)) // with at least one element
00737             {
00738                 // This is a language recognizer. Add its name to the menu.
00739                 CComBSTR bstrName;
00740                 if (SUCCEEDED(spIInkRecognizer->get_Name(&bstrName)))
00741                 {
00742                     // The ID_RECOGNIZER_FIRST is defined in the resource.h file.
00743                     // It's the base id for the commands that fill this submenu
00744                     miinfo.wID = ID_RECOGNIZER_FIRST + i;
00745                     miinfo.dwTypeData = bstrName;
00746                     if ((::InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &miinfo) != 0)
00747                         && (true == bAllFailed))
00748                     {
00749                         bAllFailed = false;
00750                     }
00751                 }
00752             }
00753         }
00754         spIInkRecognizer.Release();
00755     }
00756
00757     if (bAllFailed)
00758     {
00759         ::MessageBoxW(
00760             NULL,
00761             L"Unable to find or load handwriting text recognizers.\n"
00762             L"You need to have at least one in order to run this sample.\nExiting.",
00763             gc_szAppName,
00764             MB_ICONERROR | MB_OK);
00765
00766         ::DestroyMenu(hMenu);
00767
00768         return NULL;
00769     }
00770
00771     return hMenu;
00772 }
00773
00774 /////////////////////////////////////////////////////////
00775 //
00776 // CMultiRecoApp::DoOpen
00777 //
00778 // This helper function creates new ink object or takes
00779 // one loaded from a file and attaches it to the ink collector,
00780 // obtains a pointer to the custom strokes of the ink
00781 // and populates the stored recognition results from the stroke
00782 // collections.
00783 //
00784 // Parameters:
00785 //      bool bNew : true - create new ink object
00786 //                  false - let the user pick an .isf file
00787 //                  and load ink object from it.
00788 //
00789 // Return Values (bool):
00790 //      true - new ink object created or loaded from a file
00791 //      false - if failed to create ink object, or the user
00792 //              canceled the "Open" dialog box
00793 //
00794 /////////////////////////////////////////////////////////
00795 bool CMultiRecoApp::DoOpen(
00796         bool bNew
00797         )
00798 {
00799     // Disable inking
00800     m_spIInkCollector->put_Enabled(VARIANT_FALSE);
00801
00802     // Create a new ink object
00803     CComPtr<IInkDisp> spIInkDisp;
00804     if (FAILED(spIInkDisp.CoCreateInstance(CLSID_InkDisp)))
00805     {
00806         MessageBoxW(L"Unable to create an ink object.",
00807                     gc_szAppName, MB_ICONERROR | MB_OK);
00808         // Enable inking
00809         m_spIInkCollector->put_Enabled(VARIANT_TRUE);
00810         return false;
00811     }
00812
00813     // Let user select an .isf file to open
00814     if (false == bNew)
00815     {
00816         if (false == LoadFile(spIInkDisp))
00817         {
00818             // Don't proceed if opening a file or reading from it failed
00819             // or if the user canceled the operation
00820             // Enable inking
00821             m_spIInkCollector->put_Enabled(VARIANT_TRUE);
00822             return false;
00823         }
00824     }
00825     else
00826     {
00827         // Reset the file name and update the window's title
00828         UpdateFilename();
00829     }
00830
00831     // Replace the old Ink object with the new one
00832     m_spIInkDisp.Attach(spIInkDisp.Detach());   // Attach/Detach don't call AddRef/Release
00833     m_spIInkCollector->putref_Ink(m_spIInkDisp);
00834
00835     // Release the current stroke collections
00836     m_spIInkStrokes.Release();
00837     m_spIInkCustomStrokes.Release();
00838     m_wndResults.ResetResults();
00839
00840     // Obtain a pointer to the custom strokes collection of the new ink object
00841     long lCount = 0;
00842     if (SUCCEEDED(m_spIInkDisp->get_CustomStrokes(&m_spIInkCustomStrokes)))
00843     {
00844         m_spIInkCustomStrokes->get_Count(&lCount);
00845         for (CComVariant vItem(0); vItem.lVal < lCount; vItem.lVal++)
00846         {
00847             IInkStrokes* pIInkStrokes;
00848             if (SUCCEEDED(m_spIInkCustomStrokes->Item(vItem, &pIInkStrokes)))
00849             {
00850                 // Get the color of the strokes or use GRAY if fail
00851                 COLORREF clr = RGB(0x80,0x80,0x80);
00852                 CComPtr<IInkStrokeDisp> spIInkStroke;
00853                 CComPtr<IInkDrawingAttributes> spIDrawAttrs;
00854                 if (SUCCEEDED(pIInkStrokes->Item(0, &spIInkStroke))
00855                     && SUCCEEDED(spIInkStroke->get_DrawingAttributes(&spIDrawAttrs)))
00856                 {
00857                     spIDrawAttrs->get_Color((long*)&clr);
00858                 }
00859                 // Get the best result string
00860                 CComBSTR bstrToString;
00861                 if (SUCCEEDED(pIInkStrokes->ToString(&bstrToString)))
00862                 {
00863                     // Add the string to the RichEdit control
00864                     m_wndResults.AddString(
00865                             clr,                // the strokes color
00866                             bstrToString        // the recognition result string
00867                             );
00868                 }
00869                 pIInkStrokes->Release();
00870             }
00871         }
00872
00873     }
00874
00875     // Create an empty new stroke collection and attach it to the recognition context
00876     m_iColor = WORD(lCount) % countof(mc_crColors);   // next color to use
00877     StartNewStrokeCollection();
00878
00879     // Reset the Dirty flag
00880     m_spIInkDisp->put_Dirty(VARIANT_FALSE);
00881
00882     // Update the input window
00883     m_wndInput.Invalidate();
00884
00885     // Enable inking
00886     m_spIInkCollector->put_Enabled(VARIANT_TRUE);
00887     return true;
00888 }
00889
00890 /////////////////////////////////////////////////////////
00891 //
00892 // CMultiRecoApp::DoSave
00893 //
00894 // This function saves the current ink object into file.
00895 //
00896 //
00897 // Parameters:
00898 //      bool bSaveAs:  true - open "Save As..." common dialog box
00899 //                            for the user to specify the filename
00900 //                     false - save changes into the current file
00901 //      bool bAskUser: true - ask user whether she'd like to save
00902 //                            the changes; it's used when DoSave
00903 //                            is called from ID_FILE_NEW or ID_FILE_OPEN
00904 //                            command handlers
00905 //                     false - don't ask, just save
00906 //
00907 // Return Values (bool):
00908 //      true    - succeeded or there's nothing to save or the user was
00909 //                was asked and said "No" to saving
00910 //      false   - failed to save or canceled by the user
00911 //
00912 /////////////////////////////////////////////////////////
00913 bool CMultiRecoApp::DoSave(
00914         bool bSaveAs,
00915         bool bAskUser
00916         )
00917 {
00918     if (m_spIInkDisp == NULL)
00919         return true;
00920
00921     // If there's been no changes since the last save,
00922     // and it's not a SaveAs command, do nothing and return true
00923     VARIANT_BOOL bDirty = VARIANT_TRUE;
00924     if ((false == bSaveAs)
00925         && SUCCEEDED(m_spIInkDisp->get_Dirty(&bDirty))
00926         && VARIANT_FALSE == bDirty)
00927     {
00928         return true;
00929     }
00930
00931     if (true == bAskUser)
00932     {
00933         int iRet = MessageBoxW(L"The ink object has been changed.\n"
00934                                L"Do you want to save the changes?",
00935                                gc_szAppName, MB_ICONQUESTION | MB_YESNOCANCEL);
00936         if (IDCANCEL == iRet)
00937             return false;
00938         if (IDNO == iRet)
00939             return true;
00940     }
00941
00942     WCHAR wchFile[MAX_PATH];
00943     WCHAR wchFileTitle[MAX_PATH];
00944     wchFile[0] = wchFileTitle[0] = 0;
00945
00946     if (false == bSaveAs && 0 == m_wchFile[0])
00947         bSaveAs = true;
00948
00949     // If the function is called from the ID_FILE_SAVEAS command handler,
00950     // or the file is new, display the "SaveAs" common dialog box
00951     // for the user to specify the file name
00952     if (true == bSaveAs)
00953     {
00954         // Initialize the OPENFILENAME members.
00955         OPENFILENAMEW ofn;
00956         memset(&ofn, 0, sizeof(ofn));
00957         ofn.lStructSize = sizeof(ofn);
00958         ofn.hwndOwner = m_hWnd;
00959         ofn.lpstrDefExt = L"isf";
00960         ofn.lpstrFilter = L"*.isf\0";
00961         ofn.lpstrFileTitle= wchFileTitle;
00962         ofn.nMaxFileTitle = countof(wchFileTitle);
00963         ofn.lpstrFile= wchFile;
00964         ofn.nMaxFile = countof(wchFile);
00965         ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
00966
00967         // Display the dialog box
00968         if (::GetSaveFileNameW(&ofn) == 0)
00969             return false;   // canceled by the user
00970     }
00971
00972     // Add the current stroke collection to the Ink's CustomStrokes and release it
00973     SaveStrokeCollection();
00974
00975     // Save the ink object into a variant using the ISF format
00976     bool bOk = false;
00977     CComVariant vData;
00978     if (SUCCEEDED(m_spIInkDisp->Save(
00979                          IPF_InkSerializedFormat, // save as ISF
00980                          IPCM_Default,            // use default compression
00981                          &vData)                  // the output
00982                          ))
00983     {
00984         BYTE* pbData;
00985         if (SUCCEEDED(::SafeArrayAccessData(vData.parray, (void**)&pbData)))
00986         {
00987             // Create new or overwrite the existing file
00988             HANDLE hFile = ::CreateFileW(
00989                                 bSaveAs ? wchFile : m_wchFile,
00990                                 GENERIC_WRITE,
00991                                 0,
00992                                 NULL,
00993                                 CREATE_ALWAYS,
00994                                 0,
00995                                 NULL);
00996             if (INVALID_HANDLE_VALUE != hFile)
00997             {
00998                 // Write the data into the file
00999                 ULONG ulWritten, ulSize = vData.parray->rgsabound[0].cElements;
01000                 if (TRUE == ::WriteFile(hFile, pbData, ulSize, &ulWritten, NULL))
01001                 {
01002                     bOk = true;
01003                     m_spIInkDisp->put_Dirty(VARIANT_FALSE);
01004                 }
01005                 else
01006                 {
01007                     MessageBoxW(L"Error writing file!",
01008                                 gc_szAppName, MB_ICONERROR | MB_OK);
01009                 }
01010                 ::CloseHandle(hFile);
01011
01012                 // Update the filename string
01013                 if (true == bSaveAs)
01014                 {
01015                     UpdateFilename(wchFile, wchFileTitle);
01016                 }
01017             }
01018             else
01019             {
01020                 MessageBoxW(L"Unable to create the file.",
01021                             gc_szAppName, MB_ICONERROR | MB_OK);
01022             }
01023             ::SafeArrayUnaccessData(vData.parray);
01024         }
01025     }
01026
01027     return bOk;
01028 }
01029
01030 /////////////////////////////////////////////////////////
01031 //
01032 // CMultiRecoApp::LoadFile
01033 //
01034 // Loads the ink object from the specified file.
01035 //
01036 // Parameters:
01037 //      IInkDisp* pIInkDisp : pointer to the ink object
01038 //
01039 // Return Values (bool):
01040 //      true    - succeeded
01041 //      false   - failed
01042 //
01043 /////////////////////////////////////////////////////////
01044 bool CMultiRecoApp::LoadFile(
01045         IInkDisp* pIInkDisp
01046         )
01047 {
01048     WCHAR wchFile[MAX_PATH];
01049     WCHAR wchFileTitle[MAX_PATH];
01050     wchFile[0] = wchFileTitle[0] = 0;
01051
01052     // Initialize the OPENFILENAME members.
01053     OPENFILENAMEW ofn;
01054     memset(&ofn, 0, sizeof(ofn));
01055     ofn.lStructSize = sizeof(ofn);
01056     ofn.hwndOwner = m_hWnd;
01057     ofn.lpstrFilter = L"*.isf\0";
01058     ofn.lpstrFileTitle= wchFileTitle;
01059     ofn.nMaxFileTitle = countof(wchFileTitle);
01060     ofn.lpstrFile= wchFile;
01061     ofn.nMaxFile = countof(wchFile);
01062     ofn.Flags = OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
01063
01064     // Display the "Open File..." common dialog box
01065     if (::GetOpenFileNameW(&ofn) == 0)
01066     {
01067         return false;
01068     }
01069
01070     // Open the file and populate the Ink object from it
01071     HANDLE hFile = ::CreateFileW(wchFile, GENERIC_READ, 0, NULL,
01072                                  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
01073     if (INVALID_HANDLE_VALUE == hFile)
01074     {
01075         MessageBoxW(L"Error opening the file!", gc_szAppName, MB_ICONERROR | MB_OK);
01076         return false;
01077     }
01078
01079     // Load the file into a safearrray of bytes, then load the ink object from the array
01080     bool bOk = false;
01081     DWORD dwRead, dwSize;
01082     dwSize = ::GetFileSize(hFile, NULL);
01083     if (dwSize != DWORD(-1))
01084     {
01085         VARIANT vtData;
01086         VariantInit(&vtData);
01087         vtData.vt = VT_ARRAY | VT_UI1;
01088         vtData.parray = ::SafeArrayCreateVector(VT_UI1, 0, dwSize);
01089         if (vtData.parray)
01090         {
01091             BYTE *pbData;
01092             if (SUCCEEDED(::SafeArrayAccessData(vtData.parray, (void**)&pbData)))
01093             {
01094                 if (TRUE == ::ReadFile(hFile, pbData, dwSize, &dwRead, NULL)
01095                     && SUCCEEDED(pIInkDisp->Load(vtData)))
01096                 {
01097                     bOk = true;
01098                 }
01099                 ::SafeArrayUnaccessData(vtData.parray);
01100             }
01101             ::SafeArrayDestroy(vtData.parray);
01102         }
01103
01104         if (false == bOk)
01105         {
01106             MessageBoxW(L"Error loading ink object from the file.",
01107                         gc_szAppName, MB_ICONERROR | MB_OK);
01108         }
01109     }
01110     else
01111     {
01112         MessageBoxW(L"Error reading data from the file.\nUnknown file format.",
01113                     gc_szAppName, MB_ICONERROR | MB_OK);
01114     }
01115
01116     // Close the file
01117     ::CloseHandle(hFile);
01118
01119     // Store the filenames and update the title
01120     if (true == bOk)
01121     {
01122         UpdateFilename(wchFile, wchFileTitle);
01123     }
01124
01125     return bOk;
01126 }
01127
01128
01129 /////////////////////////////////////////////////////////
01130 //
01131 // CMultiRecoApp::CreateRecoGuides
01132 //
01133 // Create recognizer guides for boxed and lined input.
01134 // They are not required but recommended for getting
01135 // better recognition results.
01136 //
01137 // Parameters: none
01138 //
01139 // Return Values (void):
01140 //      the result is not important - the application just
01141 //      won't use the guides if failed to create or initialize them
01142 //
01143 /////////////////////////////////////////////////////////
01144 void CMultiRecoApp::CreateRecoGuides()
01145 {
01146     CComPtr<IInkRenderer> spIInkRenderer;
01147     if ((m_spIInkCollector == NULL)
01148         || FAILED(m_spIInkCollector->get_Renderer(&spIInkRenderer)))
01149         return;
01150
01151     HDC hdc = m_wndInput.GetDC();
01152     if (NULL == hdc)
01153         return;
01154
01155     // Initialize the recognizer guide data structure
01156     _InkRecoGuide irg;
01157     irg.midline = -1;                   // not use midline
01158     irg.cRows = mc_iNumRowsCols;
01159     irg.cColumns = mc_iNumRowsCols;
01160     ::SetRect(&irg.rectWritingBox, 0, 0, mc_iGuideColWidth, mc_iGuideRowHeight);
01161     // Make the guide's DrawnBox a little smaller than the the actual area
01162     // in which a user is expected to draw the ink (WritingBox)
01163     irg.rectDrawnBox = irg.rectWritingBox;
01164     ::InflateRect(&irg.rectDrawnBox, -mc_cxBoxMargin, -mc_cyBoxMargin);
01165
01166     // Set the m_wndInput's guide data with screen coordinates
01167     m_wndInput.SetGuide(irg);
01168
01169     // Use IInkRenderer to transform the guide boxes
01170     // rectangles into ink space coordinates
01171     // - the guide's writing box
01172     if (   SUCCEEDED(spIInkRenderer->PixelToInkSpace((long)hdc,
01173                                                      &irg.rectWritingBox.left,
01174                                                      &irg.rectWritingBox.top))
01175         && SUCCEEDED(spIInkRenderer->PixelToInkSpace((long)hdc,
01176                                                      &irg.rectWritingBox.right,
01177                                                      &irg.rectWritingBox.bottom))
01178         // and the drawn box
01179         && SUCCEEDED(spIInkRenderer->PixelToInkSpace((long)hdc,
01180                                                      &irg.rectDrawnBox.left,
01181                                                      &irg.rectDrawnBox.top))
01182         && SUCCEEDED(spIInkRenderer->PixelToInkSpace((long)hdc,
01183                                                      &irg.rectDrawnBox.right,
01184                                                      &irg.rectDrawnBox.bottom))
01185         )
01186     {
01187         // Create the boxed guide
01188         if (SUCCEEDED(m_spIInkRecoGuideBoxed.CoCreateInstance(CLSID_InkRecognizerGuide)))
01189         {
01190             // Initialize it
01191             if (FAILED(m_spIInkRecoGuideBoxed->put_GuideData(irg)))
01192             {
01193                 m_spIInkRecoGuideBoxed.Release();
01194             }
01195         }
01196
01197         // Create the lined guide
01198         if (SUCCEEDED(m_spIInkRecoGuideLined.CoCreateInstance(CLSID_InkRecognizerGuide)))
01199         {
01200             // Initialize it
01201             irg.cColumns = 0;  // no columns, just rows
01202             if (FAILED(m_spIInkRecoGuideLined->put_GuideData(irg)))
01203             {
01204                 m_spIInkRecoGuideLined.Release();
01205             }
01206         }
01207     }
01208
01209     // Clean up
01210     ReleaseDC(hdc);
01211 }
01212
01213 /////////////////////////////////////////////////////////
01214 //
01215 // CMultiRecoApp::SaveStrokeCollection
01216 //
01217 // The method finalize the recognition of the current
01218 // stroke collection and saves the best result with it.
01219 // Then this stroke collection is added to the custom strokes
01220 // collection of the ink object.
01221 //
01222 // Parameters:
01223 //      none
01224 //
01225 // Return Values (void):
01226 //      none - ignore any failures
01227 //
01228 /////////////////////////////////////////////////////////
01229 void CMultiRecoApp::SaveStrokeCollection()
01230 {
01231     if (m_spIInkStrokes == NULL)
01232         return;
01233
01234     long lCount = 0;
01235     if (m_spIInkRecoContext != NULL)
01236     {
01237         if (SUCCEEDED(m_spIInkStrokes->get_Count(&lCount)) && 0 != lCount)
01238         {
01239             CComPtr<IInkRecognitionResult> spIInkRecoResult;
01240             InkRecognitionStatus RecognitionStatus;
01241             if (SUCCEEDED(m_spIInkRecoContext->Recognize(&RecognitionStatus, &spIInkRecoResult)) && (spIInkRecoResult != NULL))
01242             {
01243                 if (SUCCEEDED(spIInkRecoResult->SetResultOnStrokes()))
01244                 {
01245                     CComBSTR bstr;
01246                     spIInkRecoResult->get_TopString(&bstr);
01247                     m_wndResults.UpdateString(bstr);
01248                 }
01249                 else
01250                 {
01251                     MessageBoxW(L"Unable to save recognition result "
01252                                 L"in the stroke collection.",
01253                                 gc_szAppName, MB_ICONERROR | MB_OK);
01254                 }
01255             }
01256             else
01257             {
01258                 MessageBoxW(L"Recognition has failed. No results will be "
01259                             L"stored in the stroke collection.",
01260                             gc_szAppName, MB_ICONERROR | MB_OK);
01261             }
01262         }
01263         // Detach the stroke collection from the old recognition context
01264         m_spIInkRecoContext->putref_Strokes(NULL);
01265     }
01266
01267     // Now add it to the ink's custom strokes collection
01268     // Each item (stroke collection) of the custom strokes must be identified
01269     // by a unique string. Here we generate a GUID for this.
01270     if ((0 != lCount) && (m_spIInkCustomStrokes != NULL))
01271     {
01272         GUID guid;
01273         WCHAR szGuid[40]; // format: "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"
01274         if (SUCCEEDED(::CoCreateGuid(&guid))
01275             && (::StringFromGUID2(guid, szGuid, countof(szGuid)) != 0))
01276         {
01277             CComBSTR bstrGuid(szGuid);
01278             if (FAILED(m_spIInkCustomStrokes->Add(bstrGuid, m_spIInkStrokes)))
01279             {
01280                 MessageBoxW(L"Failed to add the strokes to the Ink object's "
01281                             L"custom stroke collection",
01282                             gc_szAppName, MB_ICONERROR | MB_OK);
01283             }
01284         }
01285         else
01286         {
01287             MessageBoxW(L"Failed to create a unique string id for the stroke collection",
01288                         gc_szAppName, MB_ICONERROR | MB_OK);
01289         }
01290
01291         // Use another color for the next collection
01292         m_iColor++;
01293         if (m_iColor >= countof(mc_crColors))
01294         {
01295             m_iColor= 0;
01296         }
01297     }
01298
01299     m_spIInkStrokes.Release();
01300 }
01301
01302 /////////////////////////////////////////////////////////
01303 //
01304 // CMultiRecoApp::CreateRecoContext
01305 //
01306 // As it follows from the name, this helper method, given
01307 // a pointer to the recognizer, creates and initializes
01308 // new recognition context.
01309 //
01310 // Parameters:
01311 //      IInkRecognizer* pIInkRecognizer
01312 //              : [in] the recognizer to create a context with
01313 //
01314 // Return Values (bool):
01315 //      true if succeeded creating new recognition context, false otherwise
01316 //
01317 /////////////////////////////////////////////////////////
01318 bool CMultiRecoApp::CreateRecoContext(
01319         IInkRecognizer* pIInkRecognizer
01320         )
01321 {
01322     // Create a new recognition context
01323     CComPtr<IInkRecognizerContext> spNewContext;
01324     if (FAILED(pIInkRecognizer->CreateRecognizerContext(&spNewContext)))
01325         return false;
01326
01327     // Replace the current context with the new one
01328     if (m_spIInkRecoContext != NULL)
01329     {
01330         // Close the connection to the recognition events source
01331         IInkRecognitionEventsImpl<CMultiRecoApp>::DispEventUnadvise(m_spIInkRecoContext);
01332     }
01333     m_spIInkRecoContext.Attach(spNewContext.Detach());
01334
01335     // Establish a connection with the recognition context's event source
01336     if (FAILED(IInkRecognitionEventsImpl<CMultiRecoApp>::DispEventAdvise(m_spIInkRecoContext)))
01337     {
01338         MessageBoxW(L"Failed connect to the recognition context's event source.\n"
01339                     L"The input won't be recognized dynamically.",
01340                     gc_szAppName, MB_ICONERROR | MB_OK);
01341     }
01342
01343     // Set the guide if it's supported by the recognizer and has been created
01344     int cRows = 0, cColumns = 0;
01345   InkRecognizerCapabilities dwCapabilities = IRC_DontCare;
01346   if (SUCCEEDED(pIInkRecognizer->get_Capabilities(&dwCapabilities)))
01347     {
01348         // Try the boxed guide
01349         if (((IRC_BoxedInput & dwCapabilities) == IRC_BoxedInput)
01350             && (m_spIInkRecoGuideBoxed != NULL))
01351         {
01352             HRESULT hr = m_spIInkRecoContext->putref_Guide(m_spIInkRecoGuideBoxed);
01353             if (SUCCEEDED(hr))
01354             {
01355                 cRows = cColumns = mc_iNumRowsCols;
01356             }
01357         }
01358         // or the lined one
01359         else if (((IRC_LinedInput & dwCapabilities) == IRC_LinedInput)
01360             && (m_spIInkRecoGuideLined != NULL))
01361         {
01362             if (SUCCEEDED(m_spIInkRecoContext->putref_Guide(m_spIInkRecoGuideLined)))
01363             {
01364                 cRows = mc_iNumRowsCols;
01365             }
01366         }
01367     }
01368     // Update the input window
01369     m_wndInput.SetRowsCols(cRows, cColumns);
01370
01371     return true;
01372 }
01373
01374 /////////////////////////////////////////////////////////
01375 //
01376 // CMultiRecoApp::CreateChildWindows
01377 //
01378 // This helper method is called from WM_CREATE message handler.
01379 // The child windows and controls are created and initialized here.
01380 //
01381 // Parameters:
01382 //      none
01383 //
01384 // Return Values (bool):
01385 //      true if the windows have been created successfully,
01386 //      false otherwise
01387 //
01388 /////////////////////////////////////////////////////////
01389 bool CMultiRecoApp::CreateChildWindows()
01390 {
01391     // Create windows for input and output
01392     if ((m_wndResults.Create(m_hWnd, mc_iOutputWndId) == NULL)
01393         || (m_wndInput.Create(m_hWnd, CWindow::rcDefault, NULL,
01394                              WS_CHILD, WS_EX_CLIENTEDGE, (UINT)mc_iInputWndId) == NULL))
01395     {
01396         return false;
01397     }
01398
01399     // Create a status bar (Ignore if it fails, the application can live without it).
01400     m_hwndStatusBar = ::CreateStatusWindow(
01401                         WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SBARS_SIZEGRIP,
01402                         NULL, m_hWnd, (UINT)mc_iStatusWndId);
01403
01404     if (NULL != m_hwndStatusBar)
01405     {
01406         // Set the status bar font
01407         ::SendMessage(m_hwndStatusBar,
01408                       WM_SETFONT,
01409                       (LPARAM)::GetStockObject(DEFAULT_GUI_FONT),
01410                       FALSE);
01411     }
01412
01413     // Update the child windows' positions and sizes so that they cover
01414     // entire client area of the main window.
01415     UpdateLayout();
01416
01417     return true;
01418 }
01419
01420 /////////////////////////////////////////////////////////
01421 //
01422 // CMultiRecoApp::UpdateLayout
01423 //
01424 // This helper method is called when the size of the main
01425 // window has been changed and the child windows' positions
01426 // need to be updated so that they cover entire client area
01427 // of the main window.
01428 //
01429 // Parameters:
01430 //      none
01431 //
01432 // Return Values (void):
01433 //      none
01434 //
01435 /////////////////////////////////////////////////////////
01436 void CMultiRecoApp::UpdateLayout()
01437 {
01438     RECT rect;
01439     GetClientRect(&rect);
01440
01441     // update the size and position of the status bar
01442     if (::IsWindow(m_hwndStatusBar)
01443         && ((DWORD)::GetWindowLong(m_hwndStatusBar, GWL_STYLE) & WS_VISIBLE))
01444     {
01445         ::SendMessage(m_hwndStatusBar, WM_SIZE, 0, 0);
01446         RECT rectStatusBar;
01447         ::GetWindowRect(m_hwndStatusBar, &rectStatusBar);
01448         if (rect.bottom > rectStatusBar.bottom - rectStatusBar.top)
01449         {
01450             rect.bottom -= rectStatusBar.bottom - rectStatusBar.top;
01451         }
01452         else
01453         {
01454             rect.bottom = 0;
01455         }
01456     }
01457
01458     // update the size and position of the output window
01459     if (m_wndResults.IsWindow())
01460     {
01461         int cyResultsWnd = 100;
01462         if (cyResultsWnd > rect.bottom)
01463         {
01464             cyResultsWnd = rect.bottom;
01465         }
01466         ::SetWindowPos(m_wndResults.m_hWnd, NULL,
01467                        rect.left, rect.bottom - cyResultsWnd,
01468                        rect.right - rect.left, cyResultsWnd - rect.top,
01469                        SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
01470         rect.bottom -= cyResultsWnd;
01471     }
01472
01473     // update the size and position of the ink input window
01474     if (::IsWindow(m_wndInput.m_hWnd))
01475     {
01476         ::SetWindowPos(m_wndInput.m_hWnd, NULL,
01477                        rect.left, rect.top,
01478                        rect.right - rect.left, rect.bottom - rect.top,
01479                        SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
01480     }
01481 }
01482
01483 /////////////////////////////////////////////////////////
01484 //
01485 // CMultiRecoApp::UpdateStatusBar
01486 //
01487 // This helper function sets the name of the currently selected
01488 // recognizer to appear on the application's status bar.
01489 //
01490 // Parameters:
01491 //      none
01492 //
01493 // Return Values (void):
01494 //      none
01495 //
01496 /////////////////////////////////////////////////////////
01497 void CMultiRecoApp::UpdateStatusBar()
01498 {
01499     if (::IsWindow(m_hwndStatusBar))
01500     {
01501         ::SendMessage(m_hwndStatusBar, SB_SETTEXTW, NULL, (LPARAM)m_bstrCurRecoName.m_str);
01502     }
01503 }
01504
01505 /////////////////////////////////////////////////////////
01506 //
01507 // CMultiRecoApp::UpdateFilename
01508 //
01509 // This helper function stores the new file name
01510 // and update the window's caption
01511 //
01512 // Parameters:
01513 //      WCHAR   pwsFile      : the fule name of the opened file
01514 //      WCHAR   pwsFileTitle : the name and extension of the file, without path
01515 //
01516 // Return Values (void):
01517 //      none
01518 //
01519 /////////////////////////////////////////////////////////
01520 void CMultiRecoApp::UpdateFilename(
01521         WCHAR* pwsFile,
01522         WCHAR* pwsFileTitle
01523         )
01524 {
01525     // The title that appears in the window's caption bar
01526     CComBSTR bstrTitle;
01527
01528     if ((NULL != pwsFile) && (NULL != pwsFileTitle))
01529     {
01530         // Copy the strings
01531         int cbSize = countof(m_wchFile) - 1;
01532         wcsncpy(m_wchFile, pwsFile, cbSize);
01533         m_wchFile[cbSize] = 0;
01534         cbSize = countof(m_wchFileTitle) - 1;
01535         wcsncpy(m_wchFileTitle, pwsFileTitle, cbSize);
01536         m_wchFileTitle[cbSize] = 0;
01537         bstrTitle = m_wchFileTitle;
01538     }
01539     else
01540     {
01541         m_wchFile[0] = m_wchFileTitle[0] = 0;
01542         bstrTitle = L"New File";
01543     }
01544
01545     // The application's title is combined from the application name and
01546     // the name of the currently open file
01547     bstrTitle += L" - ";
01548     bstrTitle += gc_szAppName;
01549
01550     // Update the window's caption
01551     ::SetWindowTextW(m_hWnd, bstrTitle);
01552 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/clsfact.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

clsfact.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /******************************************************************************
00019
00020   File:          ClsFact.h
00021
00022   Description:   Defintions for CClassFactory.
00023
00024 ******************************************************************************/
00025
00026 #ifndef CCLASSFACTORY_H
00027 #define CCLASSFACTORY_H
00028
00029 /**************************************************************************
00030 #include statements
00031 **************************************************************************/
00032
00033 #include "DOServer.h"
00034
00035 /**************************************************************************
00036
00037   CClassFactory class definition
00038
00039 **************************************************************************/
00040
00041 class CClassFactory : public IClassFactory
00042 {
00043 protected:
00044   DWORD m_ObjRefCount;
00045
00046 public:
00047   CClassFactory();
00048   ~CClassFactory();
00049
00050   //IUnknown methods
00051   STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00052   STDMETHODIMP_(DWORD) AddRef();
00053   STDMETHODIMP_(DWORD) Release();
00054
00055   //IClassFactory methods
00056   STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
00057   STDMETHODIMP LockServer(BOOL);
00058 };
00059
00060 #endif   //CCLASSFACTORY_H
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/tracemacro.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

tracemacro.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  TraceMacro.h : Defines custom tracing helpers.
00014 //
00015
00016
00017 #ifndef _TRACE_MACRO_HEADER_
00018 #define _TRACE_MACRO_HEADER_
00019
00020 //---------------------------------------------------------------------------
00021 //  Function prototypes
00022 //
00023 VOID Trace_Start( LPCTSTR pszClass, LPCTSTR pszFunction );
00024 VOID Trace_HR( LPCTSTR pszClass, LPCTSTR pszFunction, HRESULT hr );
00025 VOID Trace_Value( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszValueName, LONG Value );
00026 VOID Trace_Event( LPCTSTR pszClass, LPCTSTR pszFunction, LONG nEvent );
00027 VOID MapEvent( LONG Event, LPTSTR szEventStr );
00028
00029
00030 // Alternate version provides complete path to the file
00031 // #define TRACE_HRESULT(str,hr)  Trace_HR( _T(__FILE__), (str), (hr) )
00032
00033 #ifdef _DEBUG
00034
00035 #undef  TRACE_HRESULT
00036 #define TRACE_HRESULT(s1,hr) Trace_HR( (MODULESTRING),(s1),(hr) )
00037
00038 #undef  TRACE_VAL
00039 #define TRACE_VAL(s1,s2,val) Trace_Value( (MODULESTRING),(s1),(s2),(val) )
00040
00041 #undef  TRACE_EVENT
00042 #define TRACE_EVENT(s1,val)  Trace_Event( (MODULESTRING),(s1),(val) )
00043
00044 #undef  TRACE_START
00045 #define TRACE_START( s1 )    Trace_Start( (MODULESTRING),(s1) )
00046
00047
00048 #else
00049
00050 #undef  TRACE_HRESULT
00051 #define TRACE_HRESULT
00052
00053 #undef  TRACE_VAL
00054 #define TRACE_VAL
00055
00056 #undef  TRACE_EVENT
00057 #define TRACE_EVENT
00058
00059 #undef  TRACE_START
00060 #define TRACE_START
00061
00062 #endif //_DEBUG
00063
00064
00065 #endif //_TRACE_MACRO_HEADER_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/langbar.cpp Source File

  • WinUI
  • TSFcase

langbar.cpp

Go to the documentation of this file.
00001 //
00002 // langbar.cpp
00003 //
00004 // Language bar ui code.
00005 //
00006
00007 #include "globals.h"
00008 #include "case.h"
00009 #include "resource.h"
00010
00011 #define CASE_LANGBARITEMSINK_COOKIE 0x0fab0fab
00012
00013 const struct
00014 {
00015     const WCHAR *pchDesc;
00016     void (*pfnHandler)(CCaseTextService *_this);
00017 }
00018 c_rgMenuItems[] =
00019 {
00020     { L"Show Snoop Wnd", CCaseTextService::_Menu_ShowSnoopWnd }, // must match MENU_SHOWSNOOP_INDEX
00021     { L"Hello World", CCaseTextService::_Menu_HelloWord },
00022     { L"Flip Selection", CCaseTextService::_Menu_FlipSel },
00023     { L"Flip Doc", CCaseTextService::_Menu_FlipDoc },
00024     { L"Flip Keystrokes", CCaseTextService::_Menu_FlipKeys }, // must match MENU_FLIPKEYS_INDEX
00025 };
00026
00027 #define MENU_SHOWSNOOP_INDEX    0
00028 #define MENU_FLIPKEYS_INDEX     4
00029
00030 class CLangBarItemButton : public ITfLangBarItemButton,
00031                            public ITfSource
00032 {
00033 public:
00034     CLangBarItemButton(CCaseTextService *pCase);
00035     ~CLangBarItemButton();
00036
00037     // IUnknown
00038     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00039     STDMETHODIMP_(ULONG) AddRef(void);
00040     STDMETHODIMP_(ULONG) Release(void);
00041
00042     // ITfLangBarItem
00043     STDMETHODIMP GetInfo(TF_LANGBARITEMINFO *pInfo);
00044     STDMETHODIMP GetStatus(DWORD *pdwStatus);
00045     STDMETHODIMP Show(BOOL fShow);
00046     STDMETHODIMP GetTooltipString(BSTR *pbstrToolTip);
00047
00048     // ITfLangBarItemButton
00049     STDMETHODIMP OnClick(TfLBIClick click, POINT pt, const RECT *prcArea);
00050     STDMETHODIMP InitMenu(ITfMenu *pMenu);
00051     STDMETHODIMP OnMenuSelect(UINT wID);
00052     STDMETHODIMP GetIcon(HICON *phIcon);
00053     STDMETHODIMP GetText(BSTR *pbstrText);
00054
00055     // ITfSource
00056     STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
00057     STDMETHODIMP UnadviseSink(DWORD dwCookie);
00058
00059 private:
00060     CCaseTextService *_pCase;
00061     ITfLangBarItemSink *_pLangBarItemSink;
00062     TF_LANGBARITEMINFO _tfLangBarItemInfo;
00063     LONG _cRef;
00064 };
00065
00066 //+---------------------------------------------------------------------------
00067 //
00068 // ctor
00069 //
00070 //----------------------------------------------------------------------------
00071
00072 CLangBarItemButton::CLangBarItemButton(CCaseTextService *pCase)
00073 {
00074     DllAddRef();
00075
00076     _tfLangBarItemInfo.clsidService = c_clsidCaseTextService;
00077     _tfLangBarItemInfo.guidItem = c_guidLangBarItemButton;
00078     _tfLangBarItemInfo.dwStyle = TF_LBI_STYLE_BTN_MENU;
00079     _tfLangBarItemInfo.ulSort = 0;
00080     SafeStringCopy(_tfLangBarItemInfo.szDescription, ARRAYSIZE(_tfLangBarItemInfo.szDescription), LANGBAR_ITEM_DESC);
00081
00082     _pCase = pCase;
00083     _pCase->AddRef();
00084     _pLangBarItemSink = NULL;
00085
00086     _cRef = 1;
00087 }
00088
00089 //+---------------------------------------------------------------------------
00090 //
00091 // dtor
00092 //
00093 //----------------------------------------------------------------------------
00094
00095 CLangBarItemButton::~CLangBarItemButton()
00096 {
00097     DllRelease();
00098     _pCase->Release();
00099 }
00100
00101 //+---------------------------------------------------------------------------
00102 //
00103 // QueryInterface
00104 //
00105 //----------------------------------------------------------------------------
00106
00107 STDAPI CLangBarItemButton::QueryInterface(REFIID riid, void **ppvObj)
00108 {
00109     if (ppvObj == NULL)
00110         return E_INVALIDARG;
00111
00112     *ppvObj = NULL;
00113
00114     if (IsEqualIID(riid, IID_IUnknown) ||
00115         IsEqualIID(riid, IID_ITfLangBarItem) ||
00116         IsEqualIID(riid, IID_ITfLangBarItemButton))
00117     {
00118         *ppvObj = (ITfLangBarItemButton *)this;
00119     }
00120     else if (IsEqualIID(riid, IID_ITfSource))
00121     {
00122         *ppvObj = (ITfSource *)this;
00123     }
00124
00125     if (*ppvObj)
00126     {
00127         AddRef();
00128         return S_OK;
00129     }
00130
00131     return E_NOINTERFACE;
00132 }
00133
00134
00135 //+---------------------------------------------------------------------------
00136 //
00137 // AddRef
00138 //
00139 //----------------------------------------------------------------------------
00140
00141 STDAPI_(ULONG) CLangBarItemButton::AddRef()
00142 {
00143     return ++_cRef;
00144 }
00145
00146 //+---------------------------------------------------------------------------
00147 //
00148 // Release
00149 //
00150 //----------------------------------------------------------------------------
00151
00152 STDAPI_(ULONG) CLangBarItemButton::Release()
00153 {
00154     LONG cr = --_cRef;
00155
00156     assert(_cRef >= 0);
00157
00158     if (_cRef == 0)
00159     {
00160         delete this;
00161     }
00162
00163     return cr;
00164 }
00165
00166 //+---------------------------------------------------------------------------
00167 //
00168 // GetInfo
00169 //
00170 //----------------------------------------------------------------------------
00171
00172 STDAPI CLangBarItemButton::GetInfo(TF_LANGBARITEMINFO *pInfo)
00173 {
00174     *pInfo = _tfLangBarItemInfo;
00175     return S_OK;
00176 }
00177
00178 //+---------------------------------------------------------------------------
00179 //
00180 // GetStatus
00181 //
00182 //----------------------------------------------------------------------------
00183
00184 STDAPI CLangBarItemButton::GetStatus(DWORD *pdwStatus)
00185 {
00186     *pdwStatus = 0;
00187     return S_OK;
00188 }
00189
00190 //+---------------------------------------------------------------------------
00191 //
00192 // Show
00193 //
00194 //----------------------------------------------------------------------------
00195
00196 STDAPI CLangBarItemButton::Show(BOOL fShow)
00197 {
00198     return E_NOTIMPL;
00199 }
00200
00201 //+---------------------------------------------------------------------------
00202 //
00203 // GetTooltipString
00204 //
00205 //----------------------------------------------------------------------------
00206
00207 STDAPI CLangBarItemButton::GetTooltipString(BSTR *pbstrToolTip)
00208 {
00209     *pbstrToolTip = SysAllocString(LANGBAR_ITEM_DESC);
00210
00211     return (*pbstrToolTip == NULL) ? E_OUTOFMEMORY : S_OK;
00212 }
00213
00214 //+---------------------------------------------------------------------------
00215 //
00216 // OnClick
00217 //
00218 //----------------------------------------------------------------------------
00219
00220 STDAPI CLangBarItemButton::OnClick(TfLBIClick click, POINT pt, const RECT *prcArea)
00221 {
00222     return S_OK;
00223 }
00224
00225 //+---------------------------------------------------------------------------
00226 //
00227 // InitMenu
00228 //
00229 //----------------------------------------------------------------------------
00230
00231 STDAPI CLangBarItemButton::InitMenu(ITfMenu *pMenu)
00232 {
00233     int i;
00234     DWORD dwFlags;
00235
00236     for (i=0; i<ARRAYSIZE(c_rgMenuItems); i++)
00237     {
00238         switch (i)
00239         {
00240             case MENU_SHOWSNOOP_INDEX:
00241                 dwFlags = _pCase->_IsSnoopWndVisible() ? TF_LBMENUF_CHECKED : 0;
00242                 break;
00243
00244             case MENU_FLIPKEYS_INDEX:
00245                 dwFlags = _pCase->_IsKeyFlipping() ? TF_LBMENUF_CHECKED : 0;
00246                 break;
00247
00248             default:
00249                 // all other items are plain
00250                 dwFlags = 0;
00251                 break;
00252         }
00253
00254         pMenu->AddMenuItem(i, dwFlags, NULL, NULL, c_rgMenuItems[i].pchDesc, (ULONG)wcslen(c_rgMenuItems[i].pchDesc), NULL);
00255     }
00256
00257     return S_OK;
00258 }
00259
00260 //+---------------------------------------------------------------------------
00261 //
00262 // OnMenuSelect
00263 //
00264 //----------------------------------------------------------------------------
00265
00266 STDAPI CLangBarItemButton::OnMenuSelect(UINT wID)
00267 {
00268     c_rgMenuItems[wID].pfnHandler(_pCase);
00269     return S_OK;
00270 }
00271
00272 //+---------------------------------------------------------------------------
00273 //
00274 // GetIcon
00275 //
00276 //----------------------------------------------------------------------------
00277
00278 STDAPI CLangBarItemButton::GetIcon(HICON *phIcon)
00279 {
00280     *phIcon = (HICON)LoadImage(g_hInst, TEXT("IDI_CASE"), IMAGE_ICON, 16, 16, 0);
00281
00282     return (*phIcon != NULL) ? S_OK : E_FAIL;
00283 }
00284
00285 //+---------------------------------------------------------------------------
00286 //
00287 // GetText
00288 //
00289 //----------------------------------------------------------------------------
00290
00291 STDAPI CLangBarItemButton::GetText(BSTR *pbstrText)
00292 {
00293     *pbstrText = SysAllocString(LANGBAR_ITEM_DESC);
00294
00295     return (*pbstrText == NULL) ? E_OUTOFMEMORY : S_OK;
00296 }
00297
00298 //+---------------------------------------------------------------------------
00299 //
00300 // AdviseSink
00301 //
00302 //----------------------------------------------------------------------------
00303
00304 STDAPI CLangBarItemButton::AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie)
00305 {
00306     if (!IsEqualIID(IID_ITfLangBarItemSink, riid))
00307         return CONNECT_E_CANNOTCONNECT;
00308
00309     if (_pLangBarItemSink != NULL)
00310         return CONNECT_E_ADVISELIMIT;
00311
00312     if (punk->QueryInterface(IID_ITfLangBarItemSink, (void **)&_pLangBarItemSink) != S_OK)
00313     {
00314         _pLangBarItemSink = NULL;
00315         return E_NOINTERFACE;
00316     }
00317
00318     *pdwCookie = CASE_LANGBARITEMSINK_COOKIE;
00319     return S_OK;
00320 }
00321
00322 //+---------------------------------------------------------------------------
00323 //
00324 // UnadviseSink
00325 //
00326 //----------------------------------------------------------------------------
00327
00328 STDAPI CLangBarItemButton::UnadviseSink(DWORD dwCookie)
00329 {
00330     if (dwCookie != CASE_LANGBARITEMSINK_COOKIE)
00331         return CONNECT_E_NOCONNECTION;
00332
00333     if (_pLangBarItemSink == NULL)
00334         return CONNECT_E_NOCONNECTION;
00335
00336     _pLangBarItemSink->Release();
00337     _pLangBarItemSink = NULL;
00338
00339     return S_OK;
00340 }
00341
00342 //+---------------------------------------------------------------------------
00343 //
00344 // _InitLanguageBar
00345 //
00346 //----------------------------------------------------------------------------
00347
00348 BOOL CCaseTextService::_InitLanguageBar()
00349 {
00350     ITfLangBarItemMgr *pLangBarItemMgr;
00351     BOOL fRet;
00352
00353     if (_pThreadMgr->QueryInterface(IID_ITfLangBarItemMgr, (void **)&pLangBarItemMgr) != S_OK)
00354         return FALSE;
00355
00356     fRet = FALSE;
00357
00358     if ((_pLangBarItem = new CLangBarItemButton(this)) == NULL)
00359         goto Exit;
00360
00361     if (pLangBarItemMgr->AddItem(_pLangBarItem) != S_OK)
00362     {
00363         _pLangBarItem->Release();
00364         _pLangBarItem = NULL;
00365         goto Exit;
00366     }
00367
00368     fRet = TRUE;
00369
00370 Exit:
00371     pLangBarItemMgr->Release();
00372     return fRet;
00373 }
00374
00375 //+---------------------------------------------------------------------------
00376 //
00377 // _UninitLanguageBar
00378 //
00379 //----------------------------------------------------------------------------
00380
00381 void CCaseTextService::_UninitLanguageBar()
00382 {
00383     ITfLangBarItemMgr *pLangBarItemMgr;
00384
00385     if (_pLangBarItem == NULL)
00386         return;
00387
00388     if (_pThreadMgr->QueryInterface(IID_ITfLangBarItemMgr, (void **)&pLangBarItemMgr) == S_OK)
00389     {
00390         pLangBarItemMgr->RemoveItem(_pLangBarItem);
00391         pLangBarItemMgr->Release();
00392     }
00393
00394     _pLangBarItem->Release();
00395     _pLangBarItem = NULL;
00396 }
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/findgoto.h Source File

  • Begin
  • sdkdiff

findgoto.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  *
00013  * FINDGOTO
00014  *
00015  */
00016
00017
00018 #ifndef __FINDGOTO_H__
00019 #define __FINDGOTO_H__
00020
00021
00022 /*
00023  * defines
00024  *
00025  */
00026 #define CCH_MAXDIGITS     10
00027 #define CCH_FINDSTRING    MAX_PATH
00028 #define NUM_FINDSTRINGS   16      /* indexed from 0 to 15 */
00029
00030 /*
00031  * functions
00032  *
00033  */
00034 int FAR PASCAL FindDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
00035 int FAR PASCAL GoToLineDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
00036 BOOL FindString(HWND hwndParent, LONG iCol, const char *pszFind, int nSearchDirection, int nWholeWord);
00037
00038
00039 #endif //__FINDGOTO_H__
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCNotify/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCNotify

StdAfx.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      stdafx.cpp
00003
00004   Summary:   source file that includes just the standard includes
00005              stdafx.pch will be the pre-compiled header
00006              stdafx.obj will contain the pre-compiled type information
00007
00008   Classes:   None
00009 -----------------------------------------------------------------------------
00010
00011 This file is part of the Microsoft COM+ Samples.
00012
00013 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00014
00015 This source code is intended only as a supplement to Microsoft
00016 Development Tools and/or on-line documentation. See these other
00017 materials for detailed information regarding Microsoft code samples.
00018
00019 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00020 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00022 PARTICULAR PURPOSE.
00023
00024 ==========================================================================+*/
00025
00026 #include "stdafx.h"
00027
00028 #ifdef _ATL_STATIC_REGISTRY
00029 #include <statreg.h>
00030 #include <statreg.cpp>
00031 #endif
00032
00033 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsecure/common.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsecure

common.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Server System Service
00006
00007     FILE: common.cpp
00008
00009     PURPOSE: Provides common file replication service routine definitions.
00010
00011 */
00012
00013 #include <windows.h>
00014 #include <tchar.h>
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <crtdbg.h>
00018
00019 #include "common.h"
00020
00021 HANDLE hProcessHeap = NULL;
00022
00023 VOID * AutoHeapAlloc(size_t dwBytes) {
00024     if (hProcessHeap == NULL) {
00025         hProcessHeap = GetProcessHeap();
00026     }
00027     return HeapAlloc(hProcessHeap, 0, dwBytes);
00028 }
00029
00030 VOID AutoHeapFree(VOID * lpMem) {
00031     DWORD status;
00032     ASSERTE(hProcessheap != NULL);
00033     status = HeapFree(hProcessHeap, 0, lpMem);
00034     ASSERTE(status);
00035 }
00036
00037 // end common.cpp
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Cstack_c Member List

This is the complete list of members for Cstack_c, including all inherited members.
CGetCounter() | Cstack_c | [inline]
counter | Cstack_c | [private]
CPop(int &Data) | Cstack_c | [inline]
CPush() | Cstack_c | [inline]
Cstack_c() | Cstack_c | [inline]
IsEmpty() | Cstack_c | [inline]
Pop(int &Data) | Stack_c< int > | [inline, private]
Push(intData) | Stack_c< int > | [inline, private]
Stack_c() | Stack_c< int > | [inline, private]
~Cstack_c() | Cstack_c | [inline]
~Stack_c() | Stack_c< int > | [inline, private]
Generated on Wed Nov 13 2024 16:57:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/ContextPlugin.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification

ContextPlugin.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       ContextPlugin.cpp
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011 #include "StdAfx.h"
00012 #include "ContextDll.h"
00013 #include "ContextPlugin.h"
00014 #include "ContextAdmin.h"
00015 #include "WMSContextNames.h"
00016 #include <comdef.h>
00017 #include "nserror.h"
00018
00019 const NUM_HANDLED_EVENTS = 27;
00020
00021 const LPWSTR CONTEXT_SAMPLE_USER_CONTEXT_HEADER = L"-------------------------\r\nUser Context\r\n-------------------------\r\n";
00022 const LPWSTR CONTEXT_SAMPLE_PRESENTATION_CONTEXT_HEADER = L"-------------------------\r\nPresentation Context\r\n-------------------------\r\n";
00023 const LPWSTR CONTEXT_SAMPLE_COMMAND_REQUEST_CONTEXT_HEADER = L"-------------------------\r\nCommand Request Context\r\n-------------------------\r\n";
00024 const LPWSTR CONTEXT_SAMPLE_COMMAND_RESPONSE_CONTEXT_HEADER = L"-------------------------\r\nCommand Response Context\r\n-------------------------\r\n";
00025
00026
00027 const LPWSTR CONTEXT_SAMPLE_BSTR_TYPE_STRING = L"%s(%d) = %s(VT_BSTR)\r\n";
00028 const LPWSTR CONTEXT_SAMPLE_I4_TYPE_STRING = L"%s(%d) = 0x%8.8x(%d)(VT_I4)\r\n";
00029 const LPWSTR CONTEXT_SAMPLE_UI8_TYPE_STRING = L"%s(%d) = 0x%16.16I64x(VT_UI8)\r\n";
00030 const LPWSTR CONTEXT_SAMPLE_CY_TYPE_STRING = L"%s(%d) = 0x%16.16I64x(VT_CY)\r\n";
00031 const LPWSTR CONTEXT_SAMPLE_DATE_TYPE_STRING = L"%s(%d) = 0x%8.8x(VT_DATE)\r\n";
00032 const LPWSTR CONTEXT_SAMPLE_DECIMAL_TYPE_STRING = L"%s(%d) = 0x%8.8x(VT_DECIMAL)\r\n";
00033 const LPWSTR CONTEXT_SAMPLE_UNKNOWN_TYPE_STRING = L"%s(%d) = 0x%8.8x(VT_UNKNOWN)\r\n";
00034 const LPWSTR CONTEXT_SAMPLE_DISPATCH_TYPE_STRING = L"%s(%d) = 0x%8.8x(VT_DISPATCH)\r\n";
00035 const LPWSTR CONTEXT_SAMPLE_ARRAY_TYPE_STRING = L"%s(%d) = Type(%d) (VT_ARRAY?)\r\n";
00036
00037
00038 const LPWSTR CONTEXT_SAMPLE_NEW_EVENT_HEADER = L"************************************************************\r\n%s Event at %4d.%02d.%02d %02d.%02d.%02d\r\n************************************************************\r\n";
00039
00040
00041 WCHAR * CContextPlugin::s_wstrNamedValueOutputPath = L"OutputPath";
00042 WCHAR * CContextPlugin::s_wstrNamedValueContextTypes = L"ContextTypes";
00043
00044 const ContextNameHint CContextPlugin::s_UserContextHintValues[] =
00045 {
00046     WMS_USER_AGENT, WMS_USER_AGENT_ID,
00047     WMS_USER_GUID, WMS_USER_GUID_ID,
00048     WMS_USER_NAME, WMS_USER_NAME_ID,
00049     WMS_USER_IP_ADDRESS, WMS_USER_IP_ADDRESS_ID,
00050     WMS_USER_IP_ADDRESS_STRING, WMS_USER_IP_ADDRESS_STRING_ID,
00051     WMS_USER_CONTROL_PROTOCOL, WMS_USER_CONTROL_PROTOCOL_ID,
00052     WMS_USER_AUTHENTICATOR, WMS_USER_AUTHENTICATOR_ID,
00053     WMS_USER_ID, WMS_USER_ID_ID,
00054     WMS_USER_PORT, WMS_USER_PORT_ID,
00055     WMS_USER_PRESENTATION_CONTEXT, WMS_USER_PRESENTATION_CONTEXT_ID,
00056     WMS_USER_LINK_BANDWIDTH, WMS_USER_LINK_BANDWIDTH_ID,
00057     WMS_USER_REFERER, WMS_USER_REFERER_ID,
00058     WMS_USER_VIA_UPSTREAM_PROXIES, WMS_USER_VIA_UPSTREAM_PROXIES_ID,
00059     WMS_USER_VIA_DOWNSTREAM_PROXIES, WMS_USER_VIA_DOWNSTREAM_PROXIES_ID,
00060     WMS_USER_CACHE_CLIENT_COOKIE, WMS_USER_CACHE_CLIENT_COOKIE_ID,
00061     WMS_USER_CACHE_SERVER_COOKIE, WMS_USER_CACHE_SERVER_COOKIE_ID,
00062     WMS_USER_PROXY_CLIENT_AGENT, WMS_USER_PROXY_CLIENT_AGENT_ID,
00063     NULL, -1          // signals end of array
00064 };
00065
00066 const ContextNameHint CContextPlugin::s_PresentationContextHintValues[] =
00067 {
00068     WMS_PRESENT_STREAM_HEADERS, WMS_PRESENT_STREAM_HEADERS_ID,
00069     WMS_PRESENT_CONTENT_DESCRIPTION, WMS_PRESENT_CONTENT_DESCRIPTION_ID,
00070     WMS_PRESENT_PHYSICAL_NAME, WMS_PRESENT_PHYSICAL_NAME_ID,
00071     WMS_PRESENT_REQUEST_NAME, WMS_PRESENT_REQUEST_NAME_ID,
00072     WMS_PRESENT_BROADCAST, WMS_PRESENT_BROADCAST_ID,
00073     WMS_PRESENT_SEEKABLE, WMS_PRESENT_SEEKABLE_ID,
00074     WMS_PRESENT_RELIABLE, WMS_PRESENT_RELIABLE_ID,
00075     WMS_PRESENT_BITRATE, WMS_PRESENT_BITRATE_ID,
00076     WMS_PRESENT_DURATION_HI, WMS_PRESENT_DURATION_HI_ID,
00077     WMS_PRESENT_DURATION_LO, WMS_PRESENT_DURATION_LO_ID,
00078     WMS_PRESENT_PLAY_RATE, WMS_PRESENT_PLAY_RATE_ID,
00079     WMS_PRESENT_START_TIME, WMS_PRESENT_START_TIME_ID,
00080     WMS_PRESENT_ORIGINAL_PHYSICAL_NAME, WMS_PRESENT_ORIGINAL_PHYSICAL_NAME_ID,
00081     WMS_PRESENT_ORIGINAL_REQUEST_NAME, WMS_PRESENT_ORIGINAL_REQUEST_NAME_ID,
00082     WMS_PRESENT_TOTAL_BYTES_SENT_HI, WMS_PRESENT_TOTAL_BYTES_SENT_HI_ID,
00083     WMS_PRESENT_TOTAL_BYTES_SENT_LO, WMS_PRESENT_TOTAL_BYTES_SENT_LO_ID,
00084     WMS_PRESENT_TOTAL_PLAY_TIME_HI, WMS_PRESENT_TOTAL_PLAY_TIME_HI_ID,
00085     WMS_PRESENT_TOTAL_PLAY_TIME_LO, WMS_PRESENT_TOTAL_PLAY_TIME_LO_ID,
00086     WMS_PRESENT_PLAYLIST_ENTRY_ROLE, WMS_PRESENT_PLAYLIST_ENTRY_ROLE_ID,
00087     WMS_PRESENT_WMSSINK_SELECTED_BITRATE, WMS_PRESENT_WMSSINK_SELECTED_BITRATE_ID,
00088     WMS_PRESENT_REDIRECT_LOCATION, WMS_PRESENT_REDIRECT_LOCATION_ID,
00089     WMS_PRESENT_PREROLL_TIME, WMS_PRESENT_PREROLL_TIME_ID,
00090     NULL, -1          // signals end of array
00091 };
00092
00093 const ContextNameHint CContextPlugin::s_CommandContextHintValues[] =
00094 {
00095     WMS_COMMAND_CONTEXT_URL, WMS_COMMAND_CONTEXT_URL_ID,
00096     WMS_COMMAND_CONTEXT_URL_SCHEME, WMS_COMMAND_CONTEXT_URL_SCHEME_ID,
00097     WMS_COMMAND_CONTEXT_URL_HOSTNAME, WMS_COMMAND_CONTEXT_URL_HOSTNAME_ID,
00098     WMS_COMMAND_CONTEXT_URL_PORT, WMS_COMMAND_CONTEXT_URL_PORT_ID,
00099     WMS_COMMAND_CONTEXT_URL_PATH, WMS_COMMAND_CONTEXT_URL_PATH_ID,
00100     WMS_COMMAND_CONTEXT_URL_EXTRAINFO, WMS_COMMAND_CONTEXT_URL_EXTRAINFO_ID,
00101     WMS_COMMAND_CONTEXT_BODY, WMS_COMMAND_CONTEXT_BODY_ID,
00102     WMS_COMMAND_CONTEXT_BODY_TYPE, WMS_COMMAND_CONTEXT_BODY_TYPE_ID,
00103     WMS_COMMAND_CONTEXT_START_OFFSET, WMS_COMMAND_CONTEXT_START_OFFSET_ID,
00104     WMS_COMMAND_CONTEXT_START_OFFSET_TYPE, WMS_COMMAND_CONTEXT_START_OFFSET_TYPE_ID,
00105     WMS_COMMAND_CONTEXT_RATE, WMS_COMMAND_CONTEXT_RATE_ID,
00106     WMS_COMMAND_CONTEXT_PUBPOINT_IDENTIFIER, WMS_COMMAND_CONTEXT_PUBPOINT_IDENTIFIER_ID,
00107     WMS_COMMAND_CONTEXT_EVENT, WMS_COMMAND_CONTEXT_EVENT_ID,
00108     WMS_COMMAND_CONTEXT_EVENT_ADMINNAME, WMS_COMMAND_CONTEXT_EVENT_ADMINNAME_ID,
00109     WMS_COMMAND_CONTEXT_LIMIT_CLIENTID, WMS_COMMAND_CONTEXT_LIMIT_CLIENTID_ID,
00110     WMS_COMMAND_CONTEXT_LIMIT_CLIENTIP, WMS_COMMAND_CONTEXT_LIMIT_CLIENTIP_ID,
00111     WMS_COMMAND_CONTEXT_LIMIT_OLD_VALUE, WMS_COMMAND_CONTEXT_LIMIT_OLD_VALUE_ID,
00112     WMS_COMMAND_CONTEXT_PLAYLIST_OBJECT, WMS_COMMAND_CONTEXT_PLAYLIST_OBJECT_ID,
00113     WMS_COMMAND_CONTEXT_PUBPOINT_NAME, WMS_COMMAND_CONTEXT_PUBPOINT_NAME_ID,
00114     WMS_COMMAND_CONTEXT_PUBPOINT_MONIKER, WMS_COMMAND_CONTEXT_PUBPOINT_MONIKER_ID,
00115     WMS_COMMAND_CONTEXT_EVENT_OLD_VALUE, WMS_COMMAND_CONTEXT_EVENT_OLD_VALUE_ID,
00116     WMS_COMMAND_CONTEXT_EVENT_NEW_VALUE, WMS_COMMAND_CONTEXT_EVENT_NEW_VALUE_ID,
00117     WMS_COMMAND_CONTEXT_EVENT_PROPERTY_NAME, WMS_COMMAND_CONTEXT_EVENT_PROPERTY_NAME_ID,
00118     WMS_COMMAND_CONTEXT_PLUGIN_NAME, WMS_COMMAND_CONTEXT_PLUGIN_NAME_ID,
00119     WMS_COMMAND_CONTEXT_PLUGIN_MONIKER, WMS_COMMAND_CONTEXT_PLUGIN_MONIKER_ID,
00120     WMS_COMMAND_CONTEXT_LIMIT_NEW_VALUE, WMS_COMMAND_CONTEXT_LIMIT_NEW_VALUE_ID,
00121     WMS_COMMAND_CONTEXT_CACHE_MONIKER, WMS_COMMAND_CONTEXT_CACHE_MONIKER_ID,
00122     WMS_COMMAND_CONTEXT_DOWNLOAD_URL, WMS_COMMAND_CONTEXT_DOWNLOAD_URL_ID,
00123     WMS_COMMAND_CONTEXT_REDIRECT_URL, WMS_COMMAND_CONTEXT_REDIRECT_URL_ID,
00124     WMS_COMMAND_CONTEXT_PUSH_DISTRIBUTION_TEMPLATE, WMS_COMMAND_CONTEXT_PUSH_DISTRIBUTION_TEMPLATE_ID,
00125     WMS_COMMAND_CONTEXT_PUSH_CREATING_NEW_PUBLISHING_POINT, WMS_COMMAND_CONTEXT_PUSH_CREATING_NEW_PUBLISHING_POINT_ID,
00126     WMS_COMMAND_CONTEXT_PLAYLIST_ENTRY_UNIQUE_RUNTIME_ID, WMS_COMMAND_CONTEXT_PLAYLIST_ENTRY_UNIQUE_RUNTIME_ID_ID,
00127     WMS_COMMAND_CONTEXT_REQUEST_URL, WMS_COMMAND_CONTEXT_REQUEST_URL_ID,
00128     NULL, -1          // signals end of array
00129 };
00130
00131
00132
00133 /////////////////////////////////////////////////////////////////////////////
00134 /////////////////////////////////////////////////////////////////////////////
00135 CContextPlugin::CContextPlugin()
00136 {
00137     m_pServer = NULL;
00138     m_pNamedValues = NULL;
00139     m_bstrOutputPath = NULL;
00140     m_wmsContexts = WMS_CONTEXT_PLUGIN_NO_CONTEXT;
00141 }
00142
00143
00144 /////////////////////////////////////////////////////////////////////////////
00145 /////////////////////////////////////////////////////////////////////////////
00146 CContextPlugin::~CContextPlugin()
00147 {
00148     if( NULL != m_bstrOutputPath )
00149     {
00150         ::SysFreeString( m_bstrOutputPath );
00151         m_bstrOutputPath = NULL;
00152     }
00153 }
00154
00155 /////////////////////////////////////////////////////////////////////////////
00156 /////////////////////////////////////////////////////////////////////////////
00157 STDMETHODIMP CContextPlugin::InitializePlugin
00158 (
00159     IWMSContext *pServerContext,
00160     IWMSNamedValues *pNamedValues,
00161     IWMSClassObject *pClassFactory
00162 )
00163 {
00164     HRESULT hr = S_OK;
00165
00166     if ( ( NULL == pServerContext )
00167         || ( NULL == pNamedValues )
00168         || ( NULL == pClassFactory ) )
00169     {
00170         return( E_INVALIDARG );
00171     }
00172
00173     hr = pServerContext->GetAndQueryIUnknownValue( const_cast<LPWSTR>( WMS_SERVER ), WMS_SERVER_ID,
00174                                                    IID_IWMSServer, (IUnknown**) &m_pServer, 0 );
00175
00176     if( SUCCEEDED( hr ) )
00177     {
00178         m_pNamedValues = pNamedValues;
00179         m_pNamedValues->AddRef();
00180
00181         hr = LoadConfigValues();
00182     }
00183
00184     return( hr );
00185 }
00186
00187
00188 /////////////////////////////////////////////////////////////////////////////
00189 /////////////////////////////////////////////////////////////////////////////
00190 STDMETHODIMP CContextPlugin::EnablePlugin( long *pdwFlags, long *pdwHeartbeatPeriod )
00191 {
00192     if ( ( NULL == pdwFlags ) || ( NULL == pdwHeartbeatPeriod ) )
00193     {
00194         return ( E_POINTER );
00195     }
00196
00197     // Set the heartbeat period in milliseconds
00198     *pdwHeartbeatPeriod = 0;
00199
00200     return ( S_OK );
00201 }
00202
00203
00204 /////////////////////////////////////////////////////////////////////////////
00205 /////////////////////////////////////////////////////////////////////////////
00206 STDMETHODIMP CContextPlugin::DisablePlugin()
00207 {
00208     return ( S_OK );
00209 }
00210
00211
00212 /////////////////////////////////////////////////////////////////////////////
00213 /////////////////////////////////////////////////////////////////////////////
00214 STDMETHODIMP CContextPlugin::ShutdownPlugin()
00215 {
00216     HRESULT hr = S_OK;
00217
00218     hr = SaveConfigValues();
00219
00220     if( NULL != m_pServer )
00221     {
00222         m_pServer->Release();
00223         m_pServer = NULL;
00224     }
00225
00226     if( NULL != m_pNamedValues )
00227     {
00228         m_pNamedValues->Release();
00229         m_pNamedValues = NULL;
00230     }
00231
00232     return( hr );
00233 }
00234
00235
00236 /////////////////////////////////////////////////////////////////////////////
00237 /////////////////////////////////////////////////////////////////////////////
00238 STDMETHODIMP CContextPlugin::OnHeartbeat()
00239 {
00240     HRESULT hr = S_OK;
00241
00242     // TODO: Add code that should execute on every Heartbeat Period
00243     return( hr );
00244 }
00245
00246
00247 /////////////////////////////////////////////////////////////////////////////
00248 /////////////////////////////////////////////////////////////////////////////
00249 STDMETHODIMP CContextPlugin::GetCustomAdminInterface( IDispatch **ppValue )
00250 {
00251     HRESULT hr = S_OK;
00252
00253     if ( ( NULL == ppValue ) )
00254     {
00255         return( E_POINTER );
00256     }
00257
00258     *ppValue = NULL;
00259
00260     CComObject< CContextAdmin > *spContextAdmin;
00261
00262     hr = CComObject< CContextAdmin >::CreateInstance( &spContextAdmin );
00263     if( SUCCEEDED( hr ) )
00264     {
00265         CComPtr< IDispatch > spAdmin( spContextAdmin );
00266         hr = spContextAdmin->Initialize( this );
00267         if ( SUCCEEDED( hr ) )
00268         {
00269             hr = spContextAdmin->QueryInterface( IID_IDispatch, (void **) ppValue );
00270         }
00271     }
00272
00273     return( hr );
00274 }
00275
00276 /////////////////////////////////////////////////////////////////////////////
00277 /////////////////////////////////////////////////////////////////////////////
00278 STDMETHODIMP CContextPlugin::GetHandledEvents( VARIANT *pvarHandledEvents )
00279 {
00280     HRESULT hr = S_OK;
00281     if( NULL == pvarHandledEvents )
00282     {
00283         return( E_POINTER );
00284     }
00285
00286     int nIndex = 0;
00287     WMS_EVENT_TYPE wmsHandledEvents[ NUM_HANDLED_EVENTS ];
00288     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_CONNECT;
00289     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_DISCONNECT;
00290     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_BEGIN_USER_SESSION;
00291     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_END_USER_SESSION;
00292     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_DESCRIBE;
00293     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_OPEN;
00294     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_SELECT_STREAMS;
00295     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_PLAY;
00296     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_PAUSE;
00297     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_STOP;
00298     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_CLOSE;
00299     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_SET_PARAMETER;
00300     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_GET_PARAMETER;
00301     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_VALIDATE_PUSH_DISTRIBUTION;
00302     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_CREATE_DISTRIBUTION_DATA_PATH;
00303     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_DESTROY_DISTRIBUTION_DATA_PATH;
00304     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_LOG;
00305     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_SERVER;
00306     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_PUBLISHING_POINT;
00307     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_LIMIT_CHANGE;
00308     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_LIMIT_HIT;
00309     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_PLUGIN;
00310     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_PLAYLIST;
00311     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_CACHE;
00312     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_REMOTE_CACHE_OPEN;
00313     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_REMOTE_CACHE_CLOSE;
00314     wmsHandledEvents[ nIndex++ ] = WMS_EVENT_REMOTE_CACHE_LOG;
00315
00316     hr = CreateArrayOfEvents( pvarHandledEvents, wmsHandledEvents, NUM_HANDLED_EVENTS );
00317
00318     return( hr );
00319 }
00320
00321 /////////////////////////////////////////////////////////////////////////////
00322 /////////////////////////////////////////////////////////////////////////////
00323 STDMETHODIMP CContextPlugin::OnEvent
00324 (
00325     WMS_EVENT *pEvent,
00326     IWMSContext *pUserCtx,
00327     IWMSContext *pPresentationCtx,
00328     IWMSCommandContext *pCommandCtx
00329 )
00330 {
00331     HRESULT hr = S_OK;
00332
00333     //
00334     // The event information must be valid in order to determine what
00335     // type of event has happened.
00336     //
00337     if(  NULL == pEvent )
00338     {
00339         return( E_INVALIDARG );
00340     }
00341
00342     //
00343     // The input contexts may be NULL if they are not defined for the
00344     // specified event.  Verify that any context you intend to use is
00345     // not NULL before using it.  If you need to use context that is
00346     // NULL, return E_INVALIDARG to notify the server of the problem.
00347     //
00348     switch( pEvent->Type )
00349     {
00350     case WMS_EVENT_CONNECT:
00351         hr = OnNotifyConnect( pUserCtx, pPresentationCtx, pCommandCtx );
00352         break;
00353     case WMS_EVENT_DISCONNECT:
00354         hr = OnNotifyDisconnect( pUserCtx, pPresentationCtx, pCommandCtx );
00355         break;
00356     case WMS_EVENT_BEGIN_USER_SESSION:
00357         hr = OnNotifyBeginUserSession( pUserCtx, pPresentationCtx, pCommandCtx );
00358         break;
00359     case WMS_EVENT_END_USER_SESSION:
00360         hr = OnNotifyEndUserSession( pUserCtx, pPresentationCtx, pCommandCtx );
00361         break;
00362     case WMS_EVENT_DESCRIBE:
00363         hr = OnNotifyDescribe( pUserCtx, pPresentationCtx, pCommandCtx );
00364         break;
00365     case WMS_EVENT_OPEN:
00366         hr = OnNotifyOpen( pUserCtx, pPresentationCtx, pCommandCtx );
00367         break;
00368     case WMS_EVENT_SELECT_STREAMS:
00369         hr = OnNotifySelectStreams( pUserCtx, pPresentationCtx, pCommandCtx );
00370         break;
00371     case WMS_EVENT_PLAY:
00372         hr = OnNotifyPlay( pUserCtx, pPresentationCtx, pCommandCtx );
00373         break;
00374     case WMS_EVENT_PAUSE:
00375         hr = OnNotifyPause( pUserCtx, pPresentationCtx, pCommandCtx );
00376         break;
00377     case WMS_EVENT_STOP:
00378         hr = OnNotifyStop( pUserCtx, pPresentationCtx, pCommandCtx );
00379         break;
00380     case WMS_EVENT_CLOSE:
00381         hr = OnNotifyClose( pUserCtx, pPresentationCtx, pCommandCtx );
00382         break;
00383     case WMS_EVENT_SET_PARAMETER:
00384         hr = OnNotifySetParameter( pUserCtx, pPresentationCtx, pCommandCtx );
00385         break;
00386     case WMS_EVENT_GET_PARAMETER:
00387         hr = OnNotifyGetParameter( pUserCtx, pPresentationCtx, pCommandCtx );
00388         break;
00389     case WMS_EVENT_VALIDATE_PUSH_DISTRIBUTION:
00390         hr = OnNotifyValidatePushDistribution( pUserCtx, pPresentationCtx, pCommandCtx );
00391         break;
00392     case WMS_EVENT_CREATE_DISTRIBUTION_DATA_PATH:
00393         hr = OnNotifyCreateDistributionDataPath( pUserCtx, pPresentationCtx, pCommandCtx );
00394         break;
00395     case WMS_EVENT_DESTROY_DISTRIBUTION_DATA_PATH:
00396         hr = OnNotifyDestroyDistributionDataPath( pUserCtx, pPresentationCtx, pCommandCtx );
00397         break;
00398     case WMS_EVENT_LOG:
00399         hr = OnNotifyLog( pUserCtx, pPresentationCtx, pCommandCtx );
00400         break;
00401     case WMS_EVENT_SERVER:
00402         hr = OnNotifyServer( pUserCtx, pPresentationCtx, pCommandCtx );
00403         break;
00404     case WMS_EVENT_PUBLISHING_POINT:
00405         hr = OnNotifyPublishingPoint( pUserCtx, pPresentationCtx, pCommandCtx );
00406         break;
00407     case WMS_EVENT_LIMIT_CHANGE:
00408         hr = OnNotifyLimitChange( pUserCtx, pPresentationCtx, pCommandCtx );
00409         break;
00410     case WMS_EVENT_LIMIT_HIT:
00411         hr = OnNotifyLimitHit( pUserCtx, pPresentationCtx, pCommandCtx );
00412         break;
00413     case WMS_EVENT_PLUGIN:
00414         hr = OnNotifyPlugin( pUserCtx, pPresentationCtx, pCommandCtx );
00415         break;
00416     case WMS_EVENT_PLAYLIST:
00417         hr = OnNotifyPlaylist( pUserCtx, pPresentationCtx, pCommandCtx );
00418         break;
00419     case WMS_EVENT_CACHE:
00420         hr = OnNotifyCache( pUserCtx, pPresentationCtx, pCommandCtx );
00421         break;
00422     case WMS_EVENT_REMOTE_CACHE_OPEN:
00423         hr = OnNotifyRemoteCacheOpen( pUserCtx, pPresentationCtx, pCommandCtx );
00424         break;
00425     case WMS_EVENT_REMOTE_CACHE_CLOSE:
00426         hr = OnNotifyRemoteCacheClose( pUserCtx, pPresentationCtx, pCommandCtx );
00427         break;
00428     case WMS_EVENT_REMOTE_CACHE_LOG:
00429         hr = OnNotifyRemoteCacheLog( pUserCtx, pPresentationCtx, pCommandCtx );
00430         break;
00431     }
00432
00433     return( hr );
00434 }
00435
00436
00437 HRESULT CContextPlugin::LoadConfigValues()
00438 {
00439     HRESULT hr = S_OK;
00440     IWMSNamedValue *pValue = NULL;
00441     VARIANT var;
00442
00443     if( NULL == m_pNamedValues )
00444     {
00445         return( E_UNEXPECTED );
00446     }
00447
00448     VariantInit( &var );
00449
00450     //
00451     // Get our properties from the server
00452     //
00453     hr = m_pNamedValues->get_Item( CComVariant(CContextPlugin::s_wstrNamedValueOutputPath), &pValue );
00454
00455     //
00456     // Get the Output Path Name
00457     //
00458
00459     if ( SUCCEEDED(hr) )
00460     {
00461         hr = pValue->get_Value(&var);
00462
00463         if ( SUCCEEDED(hr) )
00464         {
00465             hr = ::VariantChangeType( &var, &var, 0, VT_BSTR );
00466         }
00467
00468         if ( SUCCEEDED(hr) )
00469         {
00470             m_bstrOutputPath = ::SysAllocString( V_BSTR( &var ) );
00471             if( NULL == m_bstrOutputPath )
00472             {
00473                 hr = E_OUTOFMEMORY;
00474                 goto abort;
00475             }
00476         }
00477     }
00478
00479     hr = S_OK; // Default is OK
00480
00481     VariantClear( &var );
00482     if( NULL != pValue )
00483     {
00484         pValue->Release();
00485         pValue = NULL;
00486     }
00487
00488     //
00489     // Get the flags for ContextTypes
00490     //
00491
00492     hr = m_pNamedValues->get_Item( CComVariant(CContextPlugin::s_wstrNamedValueContextTypes), &pValue );
00493
00494     if ( SUCCEEDED(hr) )
00495     {
00496         hr = pValue->get_Value( &var );
00497
00498         if ( SUCCEEDED(hr) )
00499         {
00500             m_wmsContexts = (WMS_CONTEXT_PLUGIN_CONTEXT_TYPE) V_I4( &var );
00501         }
00502     }
00503
00504     hr = S_OK; // Default is OK
00505 abort:
00506     VariantClear( &var );
00507     if( NULL != pValue )
00508     {
00509         pValue->Release();
00510         pValue = NULL;
00511     }
00512
00513     return( hr );
00514 }
00515
00516
00517 HRESULT CContextPlugin::SaveConfigValues()
00518 {
00519     HRESULT hr = S_OK;
00520     IWMSNamedValue *pValue = NULL;
00521     VARIANT var;
00522
00523     if( NULL == m_pNamedValues )
00524     {
00525         return( E_UNEXPECTED );
00526     }
00527
00528     VariantInit( &var );
00529
00530     //
00531     // Save our Output Path property
00532     //
00533     V_VT( &var ) = VT_BSTR;
00534     if( NULL == ( V_BSTR( &var ) = ::SysAllocString( m_bstrOutputPath ) ) )
00535     {
00536         return( E_OUTOFMEMORY );
00537     }
00538     hr = m_pNamedValues->Add( CComBSTR( CContextPlugin::s_wstrNamedValueOutputPath ), var, &pValue );
00539     VariantClear( &var );
00540     if( NULL != pValue )
00541     {
00542         pValue->Release();
00543         pValue = NULL;
00544     }
00545
00546
00547
00548     VariantInit( &var );
00549
00550     //
00551     // Save our Context Types property
00552     //
00553     V_VT( &var ) = VT_I4;
00554     V_I4( &var ) = m_wmsContexts;
00555     hr = m_pNamedValues->Add( CComBSTR( CContextPlugin::s_wstrNamedValueContextTypes ), var, &pValue );
00556     VariantClear( &var );
00557
00558     if( NULL != pValue )
00559     {
00560         pValue->Release();
00561         pValue = NULL;
00562     }
00563
00564     return( hr );
00565 }
00566
00567
00568 HRESULT CContextPlugin::SetOutputPath( BSTR bstrOutputPath )
00569 {
00570     HRESULT hr = S_OK;
00571
00572     if( NULL != m_bstrOutputPath )
00573     {
00574         ::SysFreeString( m_bstrOutputPath );
00575         m_bstrOutputPath = NULL;
00576     }
00577
00578     if( NULL == bstrOutputPath )
00579     {
00580         // They just wanted to reset the OutputPath to nothing,
00581         // meaning no information is sent.
00582         return( hr );
00583     }
00584
00585     m_bstrOutputPath = ::SysAllocString( bstrOutputPath );
00586     if( NULL == m_bstrOutputPath )
00587     {
00588         hr = E_OUTOFMEMORY;
00589         return( hr );
00590     }
00591
00592     return( hr );
00593 }
00594
00595
00596 HRESULT CContextPlugin::GetOutputPath( BSTR *pbstrOutputPath )
00597 {
00598     if( NULL == pbstrOutputPath )
00599     {
00600         return( E_POINTER );
00601     }
00602     *pbstrOutputPath = NULL;
00603
00604     HRESULT hr = S_OK;
00605
00606     if( NULL != m_bstrOutputPath )
00607     {
00608         *pbstrOutputPath = ::SysAllocString( m_bstrOutputPath );
00609     }
00610     else
00611     {
00612         // Our string wasn't set, so we should return the empty string.
00613         *pbstrOutputPath = ::SysAllocString( L"" );
00614     }
00615
00616     if( NULL == *pbstrOutputPath )
00617     {
00618         hr = E_OUTOFMEMORY;
00619     }
00620
00621     return( hr );
00622 }
00623
00624
00625
00626 HRESULT CContextPlugin::CreateArrayOfEvents( VARIANT *pvarEvents, WMS_EVENT_TYPE *pWMSEvents, long nNumEvents)
00627 {
00628     HRESULT hr = S_OK;
00629     long iEvents = 0;
00630     SAFEARRAY *psa = NULL;
00631     SAFEARRAYBOUND rgsabound[1];
00632
00633     if( NULL == pvarEvents )
00634     {
00635         return( E_POINTER );
00636     }
00637
00638     if( NULL == pWMSEvents || 0 >= nNumEvents )
00639     {
00640         return( E_INVALIDARG );
00641     }
00642
00643     rgsabound[0].lLbound = 0;
00644     rgsabound[0].cElements = nNumEvents;
00645
00646     psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
00647
00648     if( NULL == psa )
00649     {
00650         return ( E_OUTOFMEMORY );
00651     }
00652
00653     for( iEvents = 0; iEvents < nNumEvents && SUCCEEDED( hr ); iEvents++ )
00654     {
00655         VARIANT varElement;
00656
00657         VariantInit( &varElement );
00658
00659         V_VT( &varElement ) = VT_I4;
00660         V_I4( &varElement ) = pWMSEvents[ iEvents ];
00661
00662         hr = SafeArrayPutElement( psa, &iEvents, &varElement );
00663         VariantClear( &varElement );
00664     }
00665
00666     if( FAILED( hr ) )
00667     {
00668         SafeArrayDestroy( psa );
00669         psa = NULL;
00670     }
00671     else
00672     {
00673         V_VT( pvarEvents ) = VT_ARRAY | VT_VARIANT;
00674         V_ARRAY( pvarEvents ) = psa;
00675     }
00676
00677     return ( hr );
00678 }
00679
00680
00681 HRESULT CContextPlugin::WriteContextInformation( HANDLE hFile, IWMSContext *pContext )
00682 {
00683     HRESULT hr = S_OK;
00684     ContextNameHint *pContextHintValues = NULL;
00685     DWORD nValue = 0;
00686     WMS_CONTEXT_TYPE wmsContextType = WMS_UNKNOWN_CONTEXT_TYPE;
00687     WCHAR wstrBuffer[MAX_PATH];
00688     DWORD cbWritten = 0;
00689     DWORD dwRet = 0;
00690
00691
00692     if( NULL == pContext )
00693     {
00694         // There is no Context, nothing to write
00695         return( hr );
00696     }
00697
00698     hr = pContext->GetContextType( &wmsContextType );
00699
00700     if( FAILED( hr ) )
00701     {
00702         return( hr );
00703     }
00704
00705     ZeroMemory( wstrBuffer, MAX_PATH * sizeof( WCHAR ) );
00706
00707     switch( wmsContextType )
00708     {
00709         case WMS_USER_CONTEXT_TYPE:
00710             // Create a header for this context type
00711             wcsncpy( wstrBuffer, CONTEXT_SAMPLE_USER_CONTEXT_HEADER, MAX_PATH );
00712             pContextHintValues = const_cast<ContextNameHint *>(CContextPlugin::s_UserContextHintValues);
00713             break;
00714         case WMS_PRESENTATION_CONTEXT_TYPE:
00715             // Create a header for this context type
00716             wcsncpy( wstrBuffer, CONTEXT_SAMPLE_PRESENTATION_CONTEXT_HEADER, MAX_PATH );
00717             pContextHintValues = const_cast<ContextNameHint *>(CContextPlugin::s_PresentationContextHintValues);
00718             break;
00719         case WMS_COMMAND_REQUEST_CONTEXT_TYPE:
00720             // Create a header for this context type
00721             wcsncpy( wstrBuffer, CONTEXT_SAMPLE_COMMAND_REQUEST_CONTEXT_HEADER, MAX_PATH );
00722             pContextHintValues = const_cast<ContextNameHint *>(CContextPlugin::s_CommandContextHintValues);
00723             break;
00724         case WMS_COMMAND_RESPONSE_CONTEXT_TYPE:
00725             // Create a header for this context type
00726             wcsncpy( wstrBuffer, CONTEXT_SAMPLE_COMMAND_RESPONSE_CONTEXT_HEADER, MAX_PATH );
00727             pContextHintValues = const_cast<ContextNameHint *>(CContextPlugin::s_CommandContextHintValues);
00728             break;
00729     }
00730
00731     if( !::WriteFile( hFile, (LPVOID) wstrBuffer, wcslen( wstrBuffer ) * sizeof( WCHAR ), &cbWritten, NULL ) )
00732     {
00733         dwRet = GetLastError();
00734         hr = HRESULT_FROM_WIN32( dwRet );
00735         // Failed to write the header should we still continue
00736         // No!
00737         return( hr );
00738     }
00739
00740     if( NULL == pContextHintValues )
00741     {
00742         return( E_UNEXPECTED );
00743     }
00744
00745     // Now we loop until -1 and Write the data
00746     while( ( NULL != pContextHintValues[nValue].wstrContextName ) && ( -1 != pContextHintValues[nValue].lContextHint ) )
00747     {
00748         VARIANT varValue;
00749         VariantInit( &varValue );
00750         ZeroMemory( wstrBuffer, MAX_PATH * sizeof( WCHAR ) );
00751
00752         hr = pContext->GetValue( pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, &varValue, 0 );
00753
00754         if( SUCCEEDED( hr ) )
00755         {
00756             // Write string with data information
00757             switch( V_VT( &varValue ) )
00758             {
00759                 case VT_BSTR:
00760                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_BSTR_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_BSTR( &varValue ) );
00761                     break;
00762                 case VT_I4:
00763                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_I4_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_I4( &varValue ), V_I4( &varValue ) );
00764                     break;
00765                 case VT_UI8:
00766                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_UI8_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_UI8( &varValue ) );
00767                     break;
00768                 case VT_CY:
00769                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_CY_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_CY( &varValue ) );
00770                     break;
00771                 case VT_DATE:
00772                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_DATE_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_DATE( &varValue ) );
00773                     break;
00774                 case VT_DECIMAL:
00775                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_DECIMAL_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_DECIMAL( &varValue ) );
00776                     break;
00777                 case VT_UNKNOWN:
00778                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_UNKNOWN_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_UNKNOWN( &varValue ) );
00779                     break;
00780                 case VT_DISPATCH:
00781                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_DISPATCH_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_DISPATCH( &varValue ) );
00782                     break;
00783                 default:
00784                     _snwprintf( wstrBuffer, MAX_PATH, CONTEXT_SAMPLE_ARRAY_TYPE_STRING, pContextHintValues[nValue].wstrContextName, pContextHintValues[nValue].lContextHint, V_ARRAY( &varValue ) );
00785                     break;
00786             }
00787
00788             if( !::WriteFile( hFile, (LPVOID) wstrBuffer, wcslen( wstrBuffer ) * sizeof( WCHAR ), &cbWritten, NULL ) )
00789             {
00790                 dwRet = GetLastError();
00791                 hr = HRESULT_FROM_WIN32( dwRet );
00792             }
00793         }
00794         else
00795         {
00796             // Value probably didn't exist for this event, don't worry about it
00797             // good place to put breakpoint
00798             hr = S_OK;
00799         }
00800
00801         // It doesn't hurt to do a VariantClear on an Empty Variant, this way we won't leak anything.
00802         VariantClear( &varValue );
00803
00804         nValue ++;
00805     }
00806
00807     return( hr );
00808 }
00809
00810
00811 HRESULT CContextPlugin::DumpContextInformation( LPCWSTR wstrEventType, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
00812 {
00813     HRESULT hr = S_OK;
00814     UINT uiPrevErrorMode = 0;
00815     DWORD dwRet = 0;
00816     DWORD cbWritten = 0;
00817     SYSTEMTIME sTime;
00818     WCHAR wstrHeader[MAX_PATH];
00819
00820     ZeroMemory( wstrHeader, MAX_PATH * sizeof( WCHAR ) );
00821
00822     if( ( WMS_CONTEXT_PLUGIN_NO_CONTEXT == m_wmsContexts )
00823         || ( NULL == m_bstrOutputPath )
00824         || ( '\0' == m_bstrOutputPath[0] ) )
00825     {
00826         // We aren't interested in dumping any context information, so just exit with Success
00827         return( hr );
00828     }
00829
00830     // Only keep the file open while dumping this event.
00831     HANDLE hFile = INVALID_HANDLE_VALUE;
00832
00833     // This stops the system from popping up an error dialog box if a floppy or CD is missing.
00834     uiPrevErrorMode = ::SetErrorMode( SEM_FAILCRITICALERRORS );
00835
00836     hFile = ::CreateFile( m_bstrOutputPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
00837
00838     if( INVALID_HANDLE_VALUE == hFile )
00839     {
00840         dwRet = GetLastError();
00841         hr = HRESULT_FROM_WIN32( dwRet );
00842         goto abort;
00843     }
00844     else
00845     {
00846         dwRet = GetLastError();
00847
00848         DWORD dwFileType = ::GetFileType( hFile );
00849         if( FILE_TYPE_DISK != dwFileType )
00850         {
00851             // Invalid File Type, for security reasons
00852             // we should only open disk files.
00853             hr = HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
00854             goto abort;
00855
00856         }
00857
00858         if( ERROR_ALREADY_EXISTS != dwRet )
00859         {
00860             // We just opened a new file, we must write the Unicode File bits
00861             BYTE pWriteBuffer[2];
00862             pWriteBuffer[0] = 0xFF;
00863             pWriteBuffer[1] = 0xFE;
00864             if( !::WriteFile( hFile, (LPVOID) pWriteBuffer, 2, &cbWritten, NULL ) )
00865             {
00866                 dwRet = GetLastError();
00867                 hr = HRESULT_FROM_WIN32( dwRet );
00868                 goto abort;
00869             }
00870         }
00871         else
00872         {
00873             // We need to check to see if the file is Unicode.
00874             BYTE pReadBuffer[2];
00875             pReadBuffer[0] = 0;
00876             pReadBuffer[1] = 0;
00877
00878             DWORD cbRead = 0;
00879             if( !::ReadFile( hFile, (LPVOID) pReadBuffer, 2, &cbRead, NULL ) )
00880             {
00881                 dwRet = GetLastError();
00882                 hr = HRESULT_FROM_WIN32( dwRet );
00883                 goto abort;
00884             }
00885             if( cbRead != 0 )
00886             {
00887                 if( ( 1 == cbRead ) || ( 0xFF != pReadBuffer[0] ) || ( 0xFE != pReadBuffer[1] ) )
00888                 {
00889                     // This file is not unicode, so error out.
00890                     hr = HRESULT_FROM_WIN32( ERROR_INVALID_DATA );
00891                     goto abort;
00892                 }
00893             }
00894             else
00895             {
00896                 // We just opened an empty file, we must write the Unicode File bits
00897                 BYTE pWriteBuffer[2];
00898                 pWriteBuffer[0] = 0xFF;
00899                 pWriteBuffer[1] = 0xFE;
00900                 if( !::WriteFile( hFile, (LPVOID) pWriteBuffer, 2, &cbWritten, NULL ) )
00901                 {
00902                     dwRet = GetLastError();
00903                     hr = HRESULT_FROM_WIN32( dwRet );
00904                     goto abort;
00905                 }
00906             }
00907         }
00908     }
00909
00910     if( SUCCEEDED( hr ) )
00911     {
00912         if( !::SetFilePointer( hFile, 0, 0, FILE_END ) )
00913         {
00914             dwRet = GetLastError();
00915             hr = HRESULT_FROM_WIN32( dwRet );
00916         }
00917
00918         if( SUCCEEDED( hr ) )
00919         {
00920             // Create a buffer of text to pass to WriteFile
00921             GetLocalTime( &sTime);
00922             _snwprintf( wstrHeader, MAX_PATH, CONTEXT_SAMPLE_NEW_EVENT_HEADER,
00923                             wstrEventType, sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond );
00924
00925             if( !::WriteFile( hFile, (LPVOID) wstrHeader, wcslen( wstrHeader ) * sizeof( WCHAR ), &cbWritten, NULL ) )
00926             {
00927                 dwRet = GetLastError();
00928                 hr = HRESULT_FROM_WIN32( dwRet );
00929             }
00930         }
00931     }
00932
00933     // Now do the writing of the information
00934     if( SUCCEEDED( hr ) && ( WMS_CONTEXT_PLUGIN_USER_CONTEXT & m_wmsContexts ) )
00935     {
00936         hr = WriteContextInformation( hFile, pUserCtx );
00937     }
00938
00939     if( SUCCEEDED( hr ) && ( WMS_CONTEXT_PLUGIN_PRESENTATION_CONTEXT & m_wmsContexts ) )
00940     {
00941         hr = WriteContextInformation( hFile, pPresentationCtx );
00942     }
00943
00944     if( SUCCEEDED( hr ) && ( WMS_CONTEXT_PLUGIN_COMMAND_REQUEST_CONTEXT & m_wmsContexts ) )
00945     {
00946         IWMSContext *pContext = NULL;
00947         hr = pCommandCtx->GetCommandRequest( &pContext );
00948         if( SUCCEEDED( hr ) )
00949         {
00950             hr = WriteContextInformation( hFile, pContext );
00951         }
00952
00953         if( NULL != pContext )
00954         {
00955             pContext->Release();
00956             pContext = NULL;
00957         }
00958     }
00959
00960     if( SUCCEEDED( hr ) && ( WMS_CONTEXT_PLUGIN_COMMAND_RESPONSE_CONTEXT & m_wmsContexts ) )
00961     {
00962         IWMSContext *pContext = NULL;
00963         hr = pCommandCtx->GetCommandResponse( &pContext );
00964         if( SUCCEEDED( hr ) )
00965         {
00966             hr = WriteContextInformation( hFile, pContext );
00967         }
00968
00969         if( NULL != pContext )
00970         {
00971             pContext->Release();
00972             pContext = NULL;
00973         }
00974     }
00975
00976 abort:
00977     if( INVALID_HANDLE_VALUE != hFile )
00978     {
00979         CloseHandle( hFile );
00980         hFile = INVALID_HANDLE_VALUE;
00981     }
00982
00983     // revert to previous error mode
00984     ::SetErrorMode( uiPrevErrorMode );
00985
00986     return( hr );
00987 }
00988
00989
00990 // Event Notification Helper Functions
00991 HRESULT CContextPlugin::OnNotifyConnect( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
00992 {
00993     HRESULT hr = S_OK;
00994     hr = DumpContextInformation( L"Connect", pUserCtx, pPresentationCtx, pCommandCtx );
00995     return( hr );
00996 }
00997
00998
00999 HRESULT CContextPlugin::OnNotifyDisconnect( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01000 {
01001     HRESULT hr = S_OK;
01002     hr = DumpContextInformation( L"Disconnect", pUserCtx, pPresentationCtx, pCommandCtx );
01003     return( hr );
01004 }
01005
01006
01007 HRESULT CContextPlugin::OnNotifyBeginUserSession( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01008 {
01009     HRESULT hr = S_OK;
01010     hr = DumpContextInformation( L"Begin User Session", pUserCtx, pPresentationCtx, pCommandCtx );
01011     return( hr );
01012 }
01013
01014
01015 HRESULT CContextPlugin::OnNotifyEndUserSession( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01016 {
01017     HRESULT hr = S_OK;
01018     hr = DumpContextInformation( L"End User Session", pUserCtx, pPresentationCtx, pCommandCtx );
01019     return( hr );
01020 }
01021
01022
01023 HRESULT CContextPlugin::OnNotifyDescribe( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01024 {
01025     HRESULT hr = S_OK;
01026     hr = DumpContextInformation( L"Describe", pUserCtx, pPresentationCtx, pCommandCtx );
01027     return( hr );
01028 }
01029
01030
01031 HRESULT CContextPlugin::OnNotifyOpen( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01032 {
01033     HRESULT hr = S_OK;
01034     hr = DumpContextInformation( L"Open", pUserCtx, pPresentationCtx, pCommandCtx );
01035     return( hr );
01036 }
01037
01038
01039 HRESULT CContextPlugin::OnNotifySelectStreams( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01040 {
01041     HRESULT hr = S_OK;
01042     hr = DumpContextInformation( L"Select Streams", pUserCtx, pPresentationCtx, pCommandCtx );
01043     return( hr );
01044 }
01045
01046
01047 HRESULT CContextPlugin::OnNotifyPlay( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01048 {
01049     HRESULT hr = S_OK;
01050     hr = DumpContextInformation( L"Play", pUserCtx, pPresentationCtx, pCommandCtx );
01051     return( hr );
01052 }
01053
01054
01055 HRESULT CContextPlugin::OnNotifyPause( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01056 {
01057     HRESULT hr = S_OK;
01058     hr = DumpContextInformation( L"Pause", pUserCtx, pPresentationCtx, pCommandCtx );
01059     return( hr );
01060 }
01061
01062
01063 HRESULT CContextPlugin::OnNotifyStop( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01064 {
01065     HRESULT hr = S_OK;
01066     hr = DumpContextInformation( L"Stop", pUserCtx, pPresentationCtx, pCommandCtx );
01067     return( hr );
01068 }
01069
01070
01071 HRESULT CContextPlugin::OnNotifyClose( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01072 {
01073     HRESULT hr = S_OK;
01074     hr = DumpContextInformation( L"Close", pUserCtx, pPresentationCtx, pCommandCtx );
01075     return( hr );
01076 }
01077
01078
01079 HRESULT CContextPlugin::OnNotifySetParameter( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01080 {
01081     HRESULT hr = S_OK;
01082     hr = DumpContextInformation( L"Set Parameter", pUserCtx, pPresentationCtx, pCommandCtx );
01083     return( hr );
01084 }
01085
01086
01087 HRESULT CContextPlugin::OnNotifyGetParameter( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01088 {
01089     HRESULT hr = S_OK;
01090     hr = DumpContextInformation( L"Get Parameter", pUserCtx, pPresentationCtx, pCommandCtx );
01091     return( hr );
01092 }
01093
01094
01095 HRESULT CContextPlugin::OnNotifyValidatePushDistribution( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01096 {
01097     HRESULT hr = S_OK;
01098     hr = DumpContextInformation( L"Validate Push Distribution", pUserCtx, pPresentationCtx, pCommandCtx );
01099     return( hr );
01100 }
01101
01102
01103 HRESULT CContextPlugin::OnNotifyCreateDistributionDataPath( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01104 {
01105     HRESULT hr = S_OK;
01106     hr = DumpContextInformation( L"Create Distribution Data Path", pUserCtx, pPresentationCtx, pCommandCtx );
01107     return( hr );
01108 }
01109
01110
01111 HRESULT CContextPlugin::OnNotifyDestroyDistributionDataPath( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01112 {
01113     HRESULT hr = S_OK;
01114     hr = DumpContextInformation( L"Destroy Distribution Data Path", pUserCtx, pPresentationCtx, pCommandCtx );
01115     return( hr );
01116 }
01117
01118
01119 HRESULT CContextPlugin::OnNotifyLog( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01120 {
01121     HRESULT hr = S_OK;
01122     hr = DumpContextInformation( L"Log", pUserCtx, pPresentationCtx, pCommandCtx );
01123     return( hr );
01124 }
01125
01126
01127 HRESULT CContextPlugin::OnNotifyServer( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01128 {
01129     HRESULT hr = S_OK;
01130     hr = DumpContextInformation( L"Server", pUserCtx, pPresentationCtx, pCommandCtx );
01131     return( hr );
01132 }
01133
01134
01135 HRESULT CContextPlugin::OnNotifyPublishingPoint( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01136 {
01137     HRESULT hr = S_OK;
01138     hr = DumpContextInformation( L"Publishing Point", pUserCtx, pPresentationCtx, pCommandCtx );
01139     return( hr );
01140 }
01141
01142
01143 HRESULT CContextPlugin::OnNotifyLimitChange( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01144 {
01145     HRESULT hr = S_OK;
01146     hr = DumpContextInformation( L"Limit Change", pUserCtx, pPresentationCtx, pCommandCtx );
01147     return( hr );
01148 }
01149
01150
01151 HRESULT CContextPlugin::OnNotifyLimitHit( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01152 {
01153     HRESULT hr = S_OK;
01154     hr = DumpContextInformation( L"Limit Hit", pUserCtx, pPresentationCtx, pCommandCtx );
01155     return( hr );
01156 }
01157
01158
01159 HRESULT CContextPlugin::OnNotifyPlugin( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01160 {
01161     HRESULT hr = S_OK;
01162     hr = DumpContextInformation( L"Plugin", pUserCtx, pPresentationCtx, pCommandCtx );
01163     return( hr );
01164 }
01165
01166
01167 HRESULT CContextPlugin::OnNotifyPlaylist( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01168 {
01169     HRESULT hr = S_OK;
01170     hr = DumpContextInformation( L"Playlist", pUserCtx, pPresentationCtx, pCommandCtx );
01171     return( hr );
01172 }
01173
01174
01175 HRESULT CContextPlugin::OnNotifyCache( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01176 {
01177     HRESULT hr = S_OK;
01178     hr = DumpContextInformation( L"Cache", pUserCtx, pPresentationCtx, pCommandCtx );
01179     return( hr );
01180 }
01181
01182
01183 HRESULT CContextPlugin::OnNotifyRemoteCacheOpen( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01184 {
01185     HRESULT hr = S_OK;
01186     hr = DumpContextInformation( L"Remote Cache Open", pUserCtx, pPresentationCtx, pCommandCtx );
01187     return( hr );
01188 }
01189
01190
01191 HRESULT CContextPlugin::OnNotifyRemoteCacheClose( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01192 {
01193     HRESULT hr = S_OK;
01194     hr = DumpContextInformation( L"Remote Cache Close", pUserCtx, pPresentationCtx, pCommandCtx );
01195     return( hr );
01196 }
01197
01198
01199 HRESULT CContextPlugin::OnNotifyRemoteCacheLog( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
01200 {
01201     HRESULT hr = S_OK;
01202     hr = DumpContextInformation( L"Remote Cache Log", pUserCtx, pPresentationCtx, pCommandCtx );
01203     return( hr );
01204 }
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIConvertType Member List

This is the complete list of members for CImpIConvertType, including all inherited members.
CanConvert(DBTYPE wFromType, DBTYPE wToType, DBCONVERTFLAGS dwConvertFlags) | CImpIConvertType
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIConvertType) | CImpIConvertType
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConServe/Server.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConServe

Server.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.CPP
00003
00004   Summary:   Implementation file for the CServer server-related utility
00005              C++ object.  This object encapsulates the server's internal
00006              control of global server object and lock counts. The
00007              CThreaded OwnThis mechanism is used to ensure mutually
00008              exclusive access to this CServer object by multiple threads.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial CONSERVE.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   CServer.
00017
00018   Functions:
00019
00020   Origin:    5-30-96: atrent - Editor-inheritance from SERVER.CPP in
00021                the FRESERVE Tutorial Code Sample.
00022
00023 ----------------------------------------------------------------------------
00024   This file is part of the Microsoft COM Tutorial Code Samples.
00025
00026   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00027
00028   This source code is intended only as a supplement to Microsoft
00029   Development Tools and/or on-line documentation.  See these other
00030   materials for detailed information regarding Microsoft code samples.
00031
00032   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00033   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00034   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00035   PARTICULAR PURPOSE.
00036 ==========================================================================+*/
00037
00038 /*---------------------------------------------------------------------------
00039   We include WINDOWS.H for all Win32 applications.
00040   We include OLE2.H because we will be calling the COM/OLE Libraries.
00041   We include APPUTIL.H because we will be building this DLL using
00042     the convenient Virtual Window and Dialog classes and other
00043     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00044   We include SERVER.H for the object class declarations for the
00045     C++ CServer server control object.
00046 ---------------------------------------------------------------------------*/
00047 #include <windows.h>
00048 #include <ole2.h>
00049 #include <apputil.h>
00050 #include "server.h"
00051
00052
00053 /*---------------------------------------------------------------------------
00054   Implementation the internal CServer C++ object.  Used to encapsulate
00055   some server data and the methods for Lock and Object count incrementing
00056   and decrementing.
00057 ---------------------------------------------------------------------------*/
00058
00059 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00060   Method:   CServer::CServer
00061
00062   Summary:  CServer Constructor.
00063
00064   Args:     void
00065
00066   Modifies: .
00067
00068   Returns:  void
00069 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00070 CServer::CServer(void)
00071 {
00072   // Zero the Object and Lock counts for this attached process.
00073   m_cObjects = 0;
00074   m_cLocks = 0;
00075
00076   return;
00077 }
00078
00079
00080 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00081   Method:   CServer::~CServer
00082
00083   Summary:  CServer Destructor.
00084
00085   Args:     void
00086
00087   Modifies: .
00088
00089   Returns:  void
00090 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00091 CServer::~CServer(void)
00092 {
00093   return;
00094 }
00095
00096
00097 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00098   Method:   CServer::Lock
00099
00100   Summary:  Increment the Server's Lock count.
00101
00102   Args:     void
00103
00104   Modifies: .
00105
00106   Returns:  void
00107 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00108 void CServer::Lock(void)
00109 {
00110   LONG cLocks;
00111
00112   if (OwnThis())
00113   {
00114     cLocks = ++m_cLocks;
00115
00116     UnOwnThis();
00117   }
00118
00119   return;
00120 }
00121
00122
00123 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00124   Method:   CServer::Unlock
00125
00126   Summary:  Decrement the Server's Lock count.
00127
00128   Args:     void
00129
00130   Modifies: .
00131
00132   Returns:  void
00133 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00134 void CServer::Unlock(void)
00135 {
00136   LONG cLocks;
00137
00138   if (OwnThis())
00139   {
00140     cLocks = --m_cLocks;
00141
00142     UnOwnThis();
00143   }
00144
00145   return;
00146 }
00147
00148
00149 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00150   Method:   CServer::ObjectsUp
00151
00152   Summary:  Increment the Server's living Object count.
00153
00154   Args:     void
00155
00156   Modifies: .
00157
00158   Returns:  void
00159 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00160 void CServer::ObjectsUp(void)
00161 {
00162   LONG cObjects;
00163
00164   if (OwnThis())
00165   {
00166     cObjects = ++m_cObjects;
00167
00168     UnOwnThis();
00169   }
00170
00171   return;
00172 }
00173
00174
00175 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00176   Method:   CServer::ObjectsDown
00177
00178   Summary:  Decrement the Server's living object count.
00179
00180   Args:     void
00181
00182   Modifies: .
00183
00184   Returns:  void
00185 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00186 void CServer::ObjectsDown(void)
00187 {
00188   LONG cObjects;
00189
00190   if (OwnThis())
00191   {
00192     cObjects = --m_cObjects;
00193
00194     UnOwnThis();
00195   }
00196
00197   return;
00198 }
00199
00200
00201 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00202   Method:   CServer::CanUnloadNow
00203
00204   Summary:  Checke if we can unload the server (ie, if there are no longer
00205             any living COM objects and no locks.
00206
00207   Args:     void
00208
00209   Modifies: .
00210
00211   Returns:  HRESULT
00212               S_OK if this server can be unloaded.
00213               S_FALSE if this server can not be unloaded.
00214 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00215 HRESULT CServer::CanUnloadNow(void)
00216 {
00217   HRESULT hr = S_FALSE;
00218   LONG cObjects, cLocks;
00219
00220   if (OwnThis())
00221   {
00222     cObjects = m_cObjects;
00223     cLocks = m_cLocks;
00224
00225     hr = (0L==cObjects && 0L==cLocks) ? S_OK : S_FALSE;
00226
00227     UnOwnThis();
00228   }
00229
00230   return hr;
00231 }
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

fullsvr::AsyncFullServ Member List

This is the complete list of members for fullsvr::AsyncFullServ, including all inherited members.
Begin_Sum(int i, int j) | fullsvr::AsyncFullServ |
fullsvr::AsyncIFullServ::Begin_Sum(int i, int j) | fullsvr::AsyncIFullServ |
Cancel(int ulSeconds) | fullsvr::AsyncFullServ |
clsid | fullsvr::AsyncFullServ | [static]
Finish_Sum() | fullsvr::AsyncFullServ |
fullsvr::AsyncIFullServ::Finish_Sum() | fullsvr::AsyncIFullServ |
iid | fullsvr::AsyncFullServ | [static]
fullsvr::AsyncIFullServ::iid | fullsvr::AsyncIFullServ | [static]
fullsvr::ISynchronize::iid | fullsvr::ISynchronize | [static]
Reset() | fullsvr::AsyncFullServ |
fullsvr::ISynchronize::Reset() | fullsvr::ISynchronize |
Signal() | fullsvr::AsyncFullServ |
fullsvr::ISynchronize::Signal() | fullsvr::ISynchronize |
TestCancel() | fullsvr::AsyncFullServ |
Wait(int dwFlags, int dwMilliseconds) | fullsvr::AsyncFullServ |
fullsvr::ISynchronize::Wait(int dwFlags, int dwMilliseconds) | fullsvr::ISynchronize |
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/oipaObj.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

oipaObj.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          OIPAObj.h
00021
00022   Description:   COleInPlaceActiveObect definitions.
00023
00024 **************************************************************************/
00025
00026 #ifndef INPLACEACTIVEOBJECT_H
00027 #define INPLACEACTIVEOBJECT_H
00028
00029 /**************************************************************************
00030 #include statements
00031 **************************************************************************/
00032
00033 #include "DOServer.h"
00034
00035 /**************************************************************************
00036
00037   COleInPlaceActiveObject class definition
00038
00039 **************************************************************************/
00040
00041 class COleDocument;
00042
00043 class COleInPlaceActiveObject : public IOleInPlaceActiveObject
00044 {
00045 private:
00046   COleDocument   *m_pOleDoc;
00047   BOOL           m_fEnableModeless;
00048
00049 public:
00050   COleInPlaceActiveObject::COleInPlaceActiveObject(COleDocument*);
00051   COleInPlaceActiveObject::~COleInPlaceActiveObject();
00052
00053   // IUnknown methods
00054   STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00055   STDMETHODIMP_(ULONG) AddRef();
00056   STDMETHODIMP_(ULONG) Release();
00057
00058   //IOleInPlaceActiveObject methods
00059   STDMETHODIMP OnDocWindowActivate(BOOL);
00060   STDMETHODIMP OnFrameWindowActivate(BOOL);
00061   STDMETHODIMP GetWindow(HWND*);
00062   STDMETHODIMP ContextSensitiveHelp(BOOL);
00063   STDMETHODIMP TranslateAccelerator(LPMSG);
00064   STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL);
00065   STDMETHODIMP EnableModeless(BOOL);
00066
00067 };
00068
00069 #endif   //INPLACEACTIVEOBJECT_H
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/GraphObj/DllDatax.h Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • GraphObj

DllDatax.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 #if !defined(AFX_DLLDATAX_H__BEEDC087_EBD2_11D0_A78F_00805F0D2083__INCLUDED_)
00013 #define AFX_DLLDATAX_H__BEEDC087_EBD2_11D0_A78F_00805F0D2083__INCLUDED_
00014
00015 #if _MSC_VER >= 1000
00016 #pragma once
00017 #endif // _MSC_VER >= 1000
00018
00019 #ifdef _MERGE_PROXYSTUB
00020
00021 extern "C"
00022 {
00023 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
00024   LPVOID lpReserved);
00025 STDAPI PrxDllCanUnloadNow(void);
00026 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
00027 STDAPI PrxDllRegisterServer(void);
00028 STDAPI PrxDllUnregisterServer(void);
00029 }
00030
00031 #endif
00032
00033 //{{AFX_INSERT_LOCATION}}
00034 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00035
00036 #endif // !defined(AFX_DLLDATAX_H__BEEDC087_EBD2_11D0_A78F_00805F0D2083__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

FileRepServer Member List

This is the complete list of members for FileRepServer, including all inherited members.
CHAR_PIPE_TYPE typedef | FileRepServer
CHAR_TYPE typedef | FileRepServer
OPEN_BUFSIZE | FileRepServer
PCONTEXT_HANDLE_TYPE | FileRepServer
PULL_BUFSIZE | FileRepServer
PUSH_BUFSIZE | FileRepServer
READ_BUFSIZE | FileRepServer
RemoteOpen([in] handle_t hFileRepServer,[out] PCONTEXT_HANDLE_TYPE *pphContext,[in, ref, string] STR pszFile,[out, ref, size_is(OPEN_BUFSIZE+1), length_is(*cbRead)] byte *Buf,[in, out, ref] unsigned long *cbRead) | FileRepServer
RemoteOpen([in] handle_t hFileRepServer,[out] PCONTEXT_HANDLE_TYPE *pphContext,[in, ref, string] STR pszFile,[out, ref, size_is(OPEN_BUFSIZE+1), length_is(*cbRead)] byte *Buf,[in, out, ref] unsigned long *cbRead) | FileRepServer
RemoteOpen([in] handle_t hFileRepServer,[out] PCONTEXT_HANDLE_TYPE *pphContext,[in, ref, string] STR pszFile,[out, ref, size_is(OPEN_BUFSIZE+1), length_is(*cbRead)] byte *Buf,[in, out, ref] unsigned long *cbRead) | FileRepServer
RemoteRead([in] handle_t hFileRepServer,[in, out] PCONTEXT_HANDLE_TYPE *pphContext,[out, ref, size_is(READ_BUFSIZE+1), length_is(*cbRead)] byte *Buf,[in, out, ref] unsigned long *cbRead) | FileRepServer
RemoteRead([in] handle_t hFileRepServer,[in, out] PCONTEXT_HANDLE_TYPE *pphContext,[out, ref, size_is(READ_BUFSIZE+1), length_is(*cbRead)] byte *Buf,[in, out, ref] unsigned long *cbRead) | FileRepServer
RemoteRead([in] handle_t hFileRepServer,[in, out] PCONTEXT_HANDLE_TYPE *pphContext,[out, ref, size_is(READ_BUFSIZE+1), length_is(*cbRead)] byte *Buf,[in, out, ref] unsigned long *cbRead) | FileRepServer
RemoteReadAsyncPipe([in] handle_t hFileRepServer,[in, ref, string] STR RemoteFileName,[out] CHAR_PIPE_TYPE *PipeData) | FileRepServer
STR typedef | FileRepServer
STR typedef | FileRepServer
STR typedef | FileRepServer
STR typedef | FileRepServer
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmMonitor/CrmMonComp.Cpp Source File

  • Com
  • Services
  • Crm
  • CrmMonitor

CrmMonComp.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmMonComp.cpp
00004
00005 ----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009
00010
00011 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00012
00013
00014
00015 This source code is intended only as a supplement to Microsoft
00016
00017 Development Tools and/or on-line documentation. See these other
00018
00019 materials for detailed information regarding Microsoft code samples.
00020
00021
00022
00023 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00024
00025 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00026
00027 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00028
00029 PARTICULAR PURPOSE.
00030
00031 ==========================================================================+*/
00032 // CrmMonComp.cpp : Implementation of DLL Exports.
00033
00034
00035 // Note: Proxy/Stub Information
00036 //    To merge the proxy/stub code into the object DLL, add the file
00037 //    dlldatax.c to the project.  Make sure precompiled headers
00038 //    are turned off for this file, and add _MERGE_PROXYSTUB to the
00039 //    defines for the project.
00040 //
00041 //    If you are not running WinNT4.0 or Win95 with DCOM, then you
00042 //    need to remove the following define from dlldatax.c
00043 //    #define _WIN32_WINNT 0x0500
00044 //
00045 //    Further, if you are running MIDL without /Oicf switch, you also
00046 //    need to remove the following define from dlldatax.c.
00047 //    #define USE_STUBLESS_PROXY
00048 //
00049 //    Modify the custom build rule for CrmMonComp.idl by adding the following
00050 //    files to the Outputs.
00051 //      CrmMonComp_p.c
00052 //      dlldata.c
00053 //    To build a separate proxy/stub DLL,
00054 //    run nmake -f CrmMonCompps.mk in the project directory.
00055
00056 #include "stdafx.h"
00057 #include "resource.h"
00058 #include "initguid.h"
00059 #include "CrmMonComp.h"
00060 #include "dlldatax.h"
00061
00062 #include "CrmMonComp_i.c"
00063 #include "CrmMonCompObj.h"
00064
00065 #ifdef _MERGE_PROXYSTUB
00066 extern "C" HINSTANCE hProxyDll;
00067 #endif
00068
00069 CComModule _Module;
00070
00071 BEGIN_OBJECT_MAP(ObjectMap)
00072   OBJECT_ENTRY(CLSID_CrmMonComp, CCrmMonComp)
00073 END_OBJECT_MAP()
00074
00075 /////////////////////////////////////////////////////////////////////////////
00076 // DLL Entry Point
00077
00078 extern "C"
00079 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00080 {
00081   lpReserved;
00082 #ifdef _MERGE_PROXYSTUB
00083   if (!PrxDllMain(hInstance, dwReason, lpReserved))
00084     return FALSE;
00085 #endif
00086   if (dwReason == DLL_PROCESS_ATTACH)
00087   {
00088     _Module.Init(ObjectMap, hInstance);
00089     DisableThreadLibraryCalls(hInstance);
00090   }
00091   else if (dwReason == DLL_PROCESS_DETACH)
00092     _Module.Term();
00093   return TRUE;    // ok
00094 }
00095
00096 /////////////////////////////////////////////////////////////////////////////
00097 // Used to determine whether the DLL can be unloaded by OLE
00098
00099 STDAPI DllCanUnloadNow(void)
00100 {
00101 #ifdef _MERGE_PROXYSTUB
00102   if (PrxDllCanUnloadNow() != S_OK)
00103     return S_FALSE;
00104 #endif
00105   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00106 }
00107
00108 /////////////////////////////////////////////////////////////////////////////
00109 // Returns a class factory to create an object of the requested type
00110
00111 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00112 {
00113 #ifdef _MERGE_PROXYSTUB
00114   if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00115     return S_OK;
00116 #endif
00117   return _Module.GetClassObject(rclsid, riid, ppv);
00118 }
00119
00120 /////////////////////////////////////////////////////////////////////////////
00121 // DllRegisterServer - Adds entries to the system registry
00122
00123 STDAPI DllRegisterServer(void)
00124 {
00125 #ifdef _MERGE_PROXYSTUB
00126   HRESULT hRes = PrxDllRegisterServer();
00127   if (FAILED(hRes))
00128     return hRes;
00129 #endif
00130   // registers object, typelib and all interfaces in typelib
00131   return _Module.RegisterServer(TRUE);
00132 }
00133
00134 /////////////////////////////////////////////////////////////////////////////
00135 // DllUnregisterServer - Removes entries from the system registry
00136
00137 STDAPI DllUnregisterServer(void)
00138 {
00139 #ifdef _MERGE_PROXYSTUB
00140   PrxDllUnregisterServer();
00141 #endif
00142   _Module.UnregisterServer();
00143   return S_OK;
00144 }
00145
00146
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/Atl.Cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

Atl.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        atl.cpp
00007 //
00008 // Contents:    ActiveX Template Library COM support
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include <pch.cpp>
00013
00014 #pragma hdrstop
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/msptrmvc.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

msptrmvc.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1998-1999 Microsoft Corporation
00004
00005 Module Name:
00006
00007     msptrmvc.cpp
00008
00009 Abstract:
00010
00011     MSP base classes: implementation of video capture terminal.
00012
00013 --*/
00014
00015
00016 #include "precomp.h"
00017 #pragma hdrstop
00018
00019 #include <amvideo.h>
00020
00021 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00023
00024 CVideoCaptureTerminal::~CVideoCaptureTerminal()
00025 {
00026     LOG((MSP_TRACE, "CVideoCaptureTerminal::~CVideoCaptureTerminal() finished"));
00027 }
00028
00029 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00030 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00031
00032 HRESULT CVideoCaptureTerminal::CreateTerminal(
00033     IN    CComPtr<IMoniker>    pMoniker,
00034     IN    MSP_HANDLE           htAddress,
00035     OUT   ITTerminal         **ppTerm
00036     )
00037 {
00038     USES_CONVERSION;
00039
00040     LOG((MSP_TRACE, "CVideoCaptureTerminal::CreateTerminal - enter"));
00041
00042     //
00043     // Validate the parameters
00044     //
00045
00046     if ( MSPB_IsBadWritePtr(ppTerm, sizeof(ITTerminal *) ) )
00047     {
00048         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateTerminal : "
00049             "bad terminal pointer; returning E_POINTER"));
00050         return E_POINTER;
00051     }
00052
00053     if ( IsBadReadPtr(pMoniker, sizeof(IMoniker) ) )
00054     {
00055         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateTerminal : "
00056             "bad moniker pointer; returning E_POINTER"));
00057         return E_POINTER;
00058     }
00059
00060     *ppTerm = NULL;
00061     HRESULT hr;
00062
00063     //
00064     // Get the name for this filter out of the property bag.
00065     //
00066     CComPtr<IPropertyBag> pBag;
00067     hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
00068     if (FAILED(hr))
00069     {
00070         LOG((MSP_ERROR,
00071             "CVideoCaptureTerminal::CreateTerminal (BindToStorage) - returning  %8x", hr));
00072         return hr;
00073     }
00074
00075     VARIANT var;
00076     var.vt = VT_BSTR;
00077     hr = pBag->Read(L"FriendlyName", &var, 0);
00078     if (FAILED(hr))
00079     {
00080         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateTerminal (IPropertyBag::Read) - returning  %8x", hr));
00081         return hr;
00082     }
00083
00084     //
00085     // Create the actual terminal object
00086     //
00087     CMSPComObject<CVideoCaptureTerminal> *pLclTerm = new CMSPComObject<CVideoCaptureTerminal>;
00088     if (pLclTerm == NULL)
00089     {
00090         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateTerminal returning E_OUTOFMEMORY"));
00091         return E_OUTOFMEMORY;
00092     }
00093
00094     //
00095     // Save some stuff we'll need later
00096     //
00097     pLclTerm->m_pMoniker = pMoniker;
00098     lstrcpyn(pLclTerm->m_szName, OLE2T(var.bstrVal), MAX_PATH);
00099
00100     SysFreeString(var.bstrVal);
00101
00102     //
00103     // Finally get the ITTerminal interface that we were asked for.
00104     //
00105     hr = pLclTerm->_InternalQueryInterface(IID_ITTerminal, (void**)ppTerm);
00106
00107     if ( FAILED(hr) )
00108     {
00109         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateTerminal - "
00110             "Internal QI failed; returning 0x%08x", hr));
00111
00112         delete pLclTerm;
00113         return hr;
00114     }
00115
00116     //
00117     // Finish initializing the terminal.
00118     //
00119
00120     hr = pLclTerm->Initialize(CLSID_VideoInputTerminal,
00121                               TAPIMEDIATYPE_VIDEO,
00122                               TD_CAPTURE,
00123                               htAddress
00124                              );
00125     if ( FAILED(hr) )
00126     {
00127         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateTerminal - "
00128             "Initialize failed; returning 0x%08x", hr));
00129
00130         (*ppTerm)->Release();
00131         return hr;
00132     }
00133
00134     LOG((MSP_TRACE, "CVideoCaptureTerminal::CreateTerminal - exit S_OK"));
00135     return S_OK;
00136 }
00137
00138
00139
00140 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00141 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00142 // Create the filters used by this terminal
00143
00144 HRESULT CVideoCaptureTerminal::CreateFilters()
00145 {
00146     LOG((MSP_TRACE, "CVideoCaptureTerminal::CreateFilters() - enter"));
00147
00148     //
00149     // If we already have the filter, just return S_OK.
00150     //
00151
00152     if ( m_pIFilter != NULL )
00153     {
00154         LOG((MSP_TRACE, "CVideoCaptureTerminal::CreateFilters() - "
00155             "already have a filter - exit S_OK"));
00156
00157         return S_OK;
00158     }
00159
00160     //
00161     // Now make the filter.
00162     //
00163
00164     HRESULT hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pIFilter);
00165
00166     if ( FAILED(hr) )
00167     {
00168         // reset the filer interface - it's a CComPointer so this releases it
00169
00170         m_pIFilter = NULL;
00171
00172         LOG((MSP_ERROR, "CVideoCaptureTerminal::CreateFilters() - "
00173             "BindToObject failed - exit 0x%08x", hr));
00174
00175         return hr;
00176     }
00177
00178     LOG((MSP_TRACE, "CVideoCaptureTerminal::CreateFilters() - exit S_OK"));
00179
00180     return S_OK;
00181 }
00182
00183 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00184 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00185
00186 HRESULT
00187 CVideoCaptureTerminal::FindCapturePin(
00188     )
00189 {
00190     LOG((MSP_TRACE, "CVideoCaptureTerminal::FindCapturePin() - enter"));
00191
00192     if ( m_pIPin != NULL )
00193     {
00194         LOG((MSP_INFO, "CVideoCaptureTerminal::FindCapturePin() - "
00195             "already called, so we already have a pin - exit S_OK"));
00196
00197         return S_OK;
00198     }
00199
00200     HRESULT hr;
00201     CComPtr<IEnumPins> pIEnumPins;
00202     ULONG cFetched;
00203
00204     //
00205     // Find the capture pin for the filter.
00206     //
00207
00208     if (FAILED(hr = m_pIFilter->EnumPins(&pIEnumPins)))
00209     {
00210         LOG((MSP_ERROR,
00211             "CVideoCaptureTerminal::FindCapturePin - can't enum pins %8x",
00212             hr));
00213         return hr;
00214     }
00215
00216     IPin * pIPin;
00217
00218     // Enumerate all the pins and break on the
00219     // first pin that meets requirement.
00220     for (;;)
00221     {
00222         if (pIEnumPins->Next(1, &pIPin, &cFetched) != S_OK)
00223         {
00224             LOG((MSP_ERROR,
00225                 "CVideoCaptureTerminal::FindCapturePin - can't get a pin %8x",
00226                 hr));
00227             return (hr == S_FALSE) ? E_FAIL : hr;
00228         }
00229
00230         if (0 == cFetched)
00231         {
00232             LOG((MSP_ERROR, "CVideoCaptureTerminal::FindCapturePin - got zero pins"));
00233             return E_FAIL;
00234         }
00235
00236         PIN_DIRECTION dir;
00237
00238         if (FAILED(hr = pIPin->QueryDirection(&dir)))
00239         {
00240             LOG((MSP_ERROR,
00241                 "CVideoCaptureTerminal::FindCapturePin - can't query pin direction %8x",
00242                 hr));
00243             pIPin->Release();
00244             return hr;
00245         }
00246
00247         if (PINDIR_OUTPUT == dir)
00248         {
00249             break;
00250         }
00251
00252         pIPin->Release();
00253     }
00254
00255     m_pIPin = pIPin;
00256
00257     LOG((MSP_TRACE, "CVideoCaptureTerminal::FindCapturePin - exit S_OK"));
00258
00259     return S_OK;
00260 }
00261
00262
00263 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00264 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00265
00266 HRESULT
00267 CVideoCaptureTerminal::AddFiltersToGraph(
00268     )
00269 {
00270     LOG((MSP_TRACE, "CVideoCaptureTerminal::AddFiltersToGraph called"));
00271
00272     if (m_pGraph == NULL)
00273     {
00274         LOG((MSP_ERROR, "CVideoCaptureTerminal::AddFiltersToGraph - "
00275             "no graph - exit E_UNEXPECTED"));
00276
00277         return E_UNEXPECTED;
00278     }
00279
00280     HRESULT hr;
00281
00282     hr = CreateFilters();
00283
00284     if ( FAILED(hr) )
00285     {
00286         LOG((MSP_ERROR, "CVideoCaptureTerminal::AddFiltersToGraph - "
00287             "CreateFilters failed - exit 0x%08x", hr));
00288
00289         return hr;
00290     }
00291
00292     //
00293     // Add the filter to the graph.
00294     //
00295     // A word about names:
00296     // If a filter has already been added with the same name (which will
00297     // happen if we have more than one video capture terminal in the same
00298     // graph) then that will return VFW_S_DUPLICATE_NAME, which is not
00299     // a failure.
00300     //
00301
00302     try
00303     {
00304         USES_CONVERSION;
00305         hr = m_pGraph->AddFilter(m_pIFilter, T2CW(m_szName));
00306     }
00307     catch (...)
00308     {
00309         LOG((MSP_ERROR, "CVideoCaptureTerminal::AddFiltersToGraph - T2CW threw an exception - "
00310             "return E_OUTOFMEMORY"));
00311
00312         return E_OUTOFMEMORY;
00313     }
00314
00315     if ( FAILED(hr) )
00316     {
00317         LOG((MSP_ERROR, "CVideoCaptureTerminal::AddFiltersToGraph - "
00318             "AddFilter failed - exit 0x%08x", hr));
00319
00320         return hr;
00321     }
00322
00323     //
00324     // set the terminal's capture pin (output pin)
00325     //
00326
00327     hr = FindCapturePin();
00328
00329     if ( FAILED(hr) )
00330     {
00331         LOG((MSP_ERROR, "CVideoCaptureTerminal::AddFiltersToGraph - "
00332             "FindCapturePin failed - exit 0x%08x", hr));
00333
00334         return hr;
00335     }
00336
00337     LOG((MSP_TRACE, "CVideoCaptureTerminal::AddFiltersToGraph succeeded"));
00338     return S_OK;
00339 }
00340
00341 // eof
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/comp.h Source File

  • SysMgmt
  • MMC
  • Nodes

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent, IResultOwnerData
00025 {
00026 private:
00027     ULONG       m_cref;
00028
00029     IConsole*   m_ipConsole;
00030
00031     class CComponentData *m_pComponentData;
00032     class CDelegationBase *m_pLastNode;
00033
00034     public:
00035         CComponent(CComponentData *parent);
00036         ~CComponent();
00037
00038         ///////////////////////////////
00039         // Interface IUnknown
00040         ///////////////////////////////
00041         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042         STDMETHODIMP_(ULONG) AddRef();
00043         STDMETHODIMP_(ULONG) Release();
00044
00045         ///////////////////////////////
00046         // Interface IComponent
00047         ///////////////////////////////
00048         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00049             /* [in] */ LPCONSOLE lpConsole);
00050
00051             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00052             /* [in] */ LPDATAOBJECT lpDataObject,
00053             /* [in] */ MMC_NOTIFY_TYPE event,
00054             /* [in] */ LPARAM arg,
00055             /* [in] */ LPARAM param);
00056
00057             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00058             /* [in] */ MMC_COOKIE cookie);
00059
00060             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00061             /* [in] */ MMC_COOKIE cookie,
00062             /* [in] */ DATA_OBJECT_TYPES type,
00063             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00064
00065             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00066             /* [in] */ MMC_COOKIE cookie,
00067             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00068             /* [out] */ long __RPC_FAR *pViewOptions);
00069
00070             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00071             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00072
00073             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00074             /* [in] */ LPDATAOBJECT lpDataObjectA,
00075             /* [in] */ LPDATAOBJECT lpDataObjectB);
00076
00077         ///////////////////////////////
00078         // Interface IComponent
00079         ///////////////////////////////
00080             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE FindItem(
00081             /* [in] */ LPRESULTFINDINFO pFindInfo,
00082             /* [out] */ int __RPC_FAR *pnFoundIndex);
00083
00084             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CacheHint(
00085             /* [in] */ int nStartIndex,
00086             /* [in] */ int nEndIndex);
00087
00088             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SortItems(
00089             /* [in] */ int nColumn,
00090             /* [in] */ DWORD dwSortOptions,
00091             /* [in] */ LPARAM lUserParam);
00092 };
00093
00094 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

blockTag Member List

This is the complete list of members for blockTag, including all inherited members.
chData | blockTag
hMem | blockTag
iInUse | blockTag
iNext | blockTag
NextBlock | blockTag
PrevBlock | blockTag
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMSMQEventHandler Member List

This is the complete list of members for CMSMQEventHandler, including all inherited members.
AdviseSource(IDispatch *pDispatch) | CMSMQEventHandler |
Arrived(IDispatch *pdispQueue, long lCursor) | CMSMQEventHandler | [virtual]
ArrivedError(IDispatch *pdispQueue, long lErrorCode, long lCursor) | CMSMQEventHandler | [virtual]
CMSMQEventHandler() | CMSMQEventHandler |
GetInterfaceHook(const void *piid) | CMSMQEventHandler |
m_dwMyCookie | CMSMQEventHandler | [private]
m_pMyCP | CMSMQEventHandler | [private]
~CMSMQEventHandler() | CMSMQEventHandler |
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/FullSvr/fullsvr.Idl Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • FullSvr

fullsvr.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: FullSvr.cpp
00004
00005 Summary:  Produced by VS6 ATL Wizard. Defines IFullServ and ISample
00006
00007 ----------------------------------------------------------------------------
00008
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021
00022 ==========================================================================+*/
00023 // FullSvr.idl : IDL source for FullSvr.dll
00024 //
00025
00026 // This file will be processed by the MIDL tool to
00027 // produce the type library (FullSvr.tlb) and marshalling code.
00028
00029 import "oaidl.idl";
00030 import "ocidl.idl";
00031
00032 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00033   Interface: IFullServ
00034 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00035
00036   [
00037     object,
00038     uuid(D3140112-D43F-4718-9119-EF62D631F2AB),
00039     async_uuid(D3140113-D43F-4718-9119-EF62D631F2AB),//Generate AsyncIFullServ
00040     helpstring("IFullServ Interface"),
00041     pointer_default(unique)
00042   ]
00043   interface IFullServ : IUnknown
00044   {
00045     [helpstring("method Sum")] HRESULT Sum([in] int i, [in] int j, [out,retval] int * sum);
00046   };
00047
00048 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00049   Interface: ISample
00050   Summary:   used by scaledemo. Work method does slightly less work than Sum
00051        but calls to Sum are handeled synchronously
00052 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00053
00054   [
00055     object,
00056     uuid(D3140114-D43F-4718-9119-EF62D631F2AB),
00057     async_uuid(D3140115-D43F-4718-9119-EF62D631F2AB),//Generate AsyncISample
00058     helpstring("ISample Interface"),
00059     pointer_default(unique)
00060   ]
00061   interface ISample : IUnknown
00062   {
00063     [helpstring("method Work")] HRESULT Work([in] int i, [in] int j, [out,retval] int * sum);
00064   };
00065
00066
00067 [
00068   uuid(F8AFC809-B006-4011-BBDF-F10C617811B9),
00069   version(1.0),
00070   helpstring("FullSvr 1.0 Type Library")
00071 ]
00072 library FULLSVRLib
00073 {
00074   importlib("stdole32.tlb");
00075   importlib("stdole2.tlb");
00076
00077   [
00078     uuid(F03BE175-A8DE-40D1-9161-A36BCBE1FEA6),
00079     helpstring("FullServ Class")
00080   ]
00081   coclass FullServ
00082   {
00083     [default] interface IFullServ;
00084     interface ICallFactory;//Added for VB and Java support
00085   };
00086   // AsyncFullServ coclass added to allow VB and Java to use
00087   // the AsyncIFullServ interface
00088   [
00089     uuid(F03BE176-A8DE-40D1-9161-A36BCBE1FEA6),
00090     helpstring("AsyncFullServ Class")
00091   ]
00092   coclass AsyncFullServ
00093   {
00094     [default] interface AsyncIFullServ;
00095     interface ISynchronize;
00096     interface ICancelMethodCalls;
00097   };
00098 };
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Clipboard/ClipText.h Source File

  • WinUI
  • Clipboard

ClipText.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \******************************************************************************/
00010
00011
00012 #include <windows.h>
00013
00014 #define IDM_ABOUT 100
00015
00016 /* file menu items */
00017
00018 #define     IDM_NEW      101
00019 #define     IDM_OPEN     102
00020 #define     IDM_SAVE     103
00021 #define     IDM_SAVEAS   104
00022 #define     IDM_PRINT    105
00023 #define     IDM_EXIT     106
00024
00025 /* edit menu items */
00026
00027 #define     IDM_UNDO     200
00028 #define     IDM_CUT      201
00029 #define     IDM_COPY     202
00030 #define     IDM_PASTE    203
00031 #define     IDM_CLEAR    204
00032
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Recordset20 Member List

This is the complete list of members for msado15::Recordset20, including all inherited members.
_xClone() | msado15::Recordset20 |
_xResync(int AffectRecords) | msado15::Recordset20 |
_xSave(String FileName, int PersistFormat) | msado15::Recordset20 |
AddNew(Variant FieldList, Variant Values) | msado15::Recordset20 |
Cancel() | msado15::Recordset20 |
CancelBatch(int AffectRecords) | msado15::Recordset20 |
CancelUpdate() | msado15::Recordset20 |
Clone(int LockType) | msado15::Recordset20 |
Close() | msado15::Recordset20 |
CompareBookmarks(Variant Bookmark1, Variant Bookmark2) | msado15::Recordset20 |
Delete(int AffectRecords) | msado15::Recordset20 |
Find(String Criteria, int SkipRecords, int SearchDirection, Variant Start) | msado15::Recordset20 |
getAbsolutePage() | msado15::Recordset20 |
getAbsolutePosition() | msado15::Recordset20 |
getActiveCommand() | msado15::Recordset20 |
getActiveConnection() | msado15::Recordset20 |
getBOF() | msado15::Recordset20 |
getBookmark() | msado15::Recordset20 |
getCacheSize() | msado15::Recordset20 |
getCollect(Variant Index) | msado15::Recordset20 |
getCursorLocation() | msado15::Recordset20 |
getCursorType() | msado15::Recordset20 |
getDataMember() | msado15::Recordset20 |
getDataSource() | msado15::Recordset20 |
getEditMode() | msado15::Recordset20 |
getEOF() | msado15::Recordset20 |
getFields() | msado15::Recordset20 |
getFilter() | msado15::Recordset20 |
getLockType() | msado15::Recordset20 |
getMarshalOptions() | msado15::Recordset20 |
getMaxRecords() | msado15::Recordset20 |
getPageCount() | msado15::Recordset20 |
getPageSize() | msado15::Recordset20 |
getProperties() | msado15::Recordset20 |
getRecordCount() | msado15::Recordset20 |
GetRows(int Rows, Variant Start, Variant Fields) | msado15::Recordset20 |
getSort() | msado15::Recordset20 |
getSource() | msado15::Recordset20 |
getState() | msado15::Recordset20 |
getStatus() | msado15::Recordset20 |
getStayInSync() | msado15::Recordset20 |
GetString(int StringFormat, int NumRows, String ColumnDelimeter, String RowDelimeter, String NullExpr) | msado15::Recordset20 |
iid | msado15::Recordset20 | [static]
Move(int NumRecords, Variant Start) | msado15::Recordset20 |
MoveFirst() | msado15::Recordset20 |
MoveLast() | msado15::Recordset20 |
MoveNext() | msado15::Recordset20 |
MovePrevious() | msado15::Recordset20 |
NextRecordset(Variant RecordsAffected) | msado15::Recordset20 |
Open(Variant Source, Variant ActiveConnection, int CursorType, int LockType, int Options) | msado15::Recordset20 |
Requery(int Options) | msado15::Recordset20 |
Resync(int AffectRecords, int ResyncValues) | msado15::Recordset20 |
setAbsolutePage(int pl) | msado15::Recordset20 |
setAbsolutePosition(int pl) | msado15::Recordset20 |
setActiveConnection(Object pvar) | msado15::Recordset20 |
setActiveConnection(Variant pvar) | msado15::Recordset20 |
setBookmark(Variant pvBookmark) | msado15::Recordset20 |
setCacheSize(int pl) | msado15::Recordset20 |
setCollect(Variant Index, Variant pvar) | msado15::Recordset20 |
setCursorLocation(int plCursorLoc) | msado15::Recordset20 |
setCursorType(int plCursorType) | msado15::Recordset20 |
setDataMember(String pbstrDataMember) | msado15::Recordset20 |
setDataSource(IUnknown ppunkDataSource) | msado15::Recordset20 |
setFilter(Variant Criteria) | msado15::Recordset20 |
setLockType(int plLockType) | msado15::Recordset20 |
setMarshalOptions(int peMarshal) | msado15::Recordset20 |
setMaxRecords(int plMaxRecords) | msado15::Recordset20 |
setPageSize(int pl) | msado15::Recordset20 |
setSort(String Criteria) | msado15::Recordset20 |
setSource(Object pvSource) | msado15::Recordset20 |
setSource(String pvSource) | msado15::Recordset20 |
setStayInSync(boolean pbStayInSync) | msado15::Recordset20 |
Supports(int CursorOptions) | msado15::Recordset20 |
Update(Variant Fields, Variant Values) | msado15::Recordset20 |
UpdateBatch(int AffectRecords) | msado15::Recordset20 |
Generated on Wed Nov 13 2024 16:58:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/Include/news.Idl Source File

  • Com
  • Services
  • Events
  • EventNews
  • Include

news.Idl

Go to the documentation of this file.
00001 // NewsFlash.idl
00002 #include "mtxattr.h"
00003 import "oaidl.idl";
00004 import "ocidl.idl";
00005 import "eventsys.idl";
00006
00007 // INewsEvent interface
00008 [
00009   object,
00010   uuid(4BF5E480-A5D3-11D2-AD4D-0080C7BFF6DB),
00011   dual,
00012   helpstring("INewsEvent Interface"),
00013   pointer_default(unique),
00014   QUEUEABLE
00015 ]
00016 interface INewsEvent : IDispatch
00017 {
00018
00019   [id(1), helpstring("method NewsFlash")] HRESULT NewsFlash([in] DATE dtTimeStamp, [in] BSTR Symbol, [in] BSTR Headline,[in] BSTR URL );
00020   [id(2), helpstring("method ShortQuote")] HRESULT ShortQuote( [in] BSTR Symbol, [in] double BidPrice, [in] double AskPrice, [in] DATE LastTradeTime, [in] double LastTradePrice, [in] double NetChange, [in] double DailyHigh, [in] double DailyLow );
00021   [id(3), helpstring("method LongQuote")] HRESULT LongQuote( [in] BSTR Symbol, [in] double BidPrice, [in] double AskPrice,[in] BSTR LastTradeTime, [in] double LastTradePrice, [in] double NetChange, [in] double DailyHigh, [in] double DailyLow,[in] long AskSize, [in] long BidSize, [in] double OpenPrice, [in] double ClosePrice, [in] BSTR CloseDate );
00022 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/multichan/multichan.h Source File

  • Multimedia
  • Audio
  • multichan

multichan.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) Microsoft Corportation. All rights reserved.
00003 */
00004
00005 // multichan.h : main header file for the MULTICHAN application
00006 //
00007
00008 #if !defined(AFX_MULTICHAN_H__C382F3EC_96AC_11D2_9012_00C04FC2D3B8__INCLUDED_)
00009 #define AFX_MULTICHAN_H__C382F3EC_96AC_11D2_9012_00C04FC2D3B8__INCLUDED_
00010
00011 #if _MSC_VER > 1000
00012 #pragma once
00013 #endif // _MSC_VER > 1000
00014
00015 #ifndef __AFXWIN_H__
00016   #error include 'stdafx.h' before including this file for PCH
00017 #endif
00018
00019 #include "resource.h"       // main symbols
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // CMultichanApp:
00023 // See multichan.cpp for the implementation of this class
00024 //
00025
00026 class CMultichanApp : public CWinApp
00027 {
00028 public:
00029   CMultichanApp();    //  ctor
00030     ~CMultichanApp();   //  dtor
00031
00032 // Overrides
00033   // ClassWizard generated virtual function overrides
00034   //{{AFX_VIRTUAL(CMultichanApp)
00035   public:
00036   virtual BOOL InitInstance();
00037   //}}AFX_VIRTUAL
00038
00039 // Implementation
00040
00041 public:
00042   //{{AFX_MSG(CMultichanApp)
00043   afx_msg void OnAppAbout();
00044   //}}AFX_MSG
00045   DECLARE_MESSAGE_MAP()
00046 };
00047
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050
00051 //{{AFX_INSERT_LOCATION}}
00052 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00053
00054 #endif // !defined(AFX_MULTICHAN_H__C382F3EC_96AC_11D2_9012_00C04FC2D3B8__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventProvider/OaHelp.Inl Source File

  • SysMgmt
  • WMI
  • VC
  • EventProvider

OaHelp.Inl

Go to the documentation of this file.
00001 // **************************************************************************
00002 //
00003 // Copyright (c)  Microsoft Corporation.
00004 //
00005 // File:  OAHELP.INL
00006 //
00007 // Description:
00008 //        OLE Automation Helpers for client code
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #ifndef _OAHELP_INL_
00015 #define _OAHELP_INL_
00016
00017 class CBSTR
00018 {
00019     BSTR m_pStr;
00020 public:
00021     CBSTR() { m_pStr = 0; }
00022     CBSTR(LPWSTR pSrc) { m_pStr = SysAllocString(pSrc); }
00023    ~CBSTR() { if (m_pStr) SysFreeString(m_pStr); }
00024     operator BSTR() { return m_pStr; }
00025
00026     void Unbind() { m_pStr = 0; }
00027 };
00028
00029 class CVARIANT
00030 {
00031     VARIANT v;
00032 public:
00033     CVARIANT() { VariantInit(&v); }
00034    ~CVARIANT() { VariantClear(&v); }
00035     void Clear()  { VariantClear(&v); }
00036
00037     operator VARIANT *() { return &v; }
00038     VARIANT *operator &() { return &v; }
00039
00040     CVARIANT(LPWSTR pSrc)   { VariantInit(&v); SetStr(pSrc); }
00041     CVARIANT(LONG lSrc)     { VariantInit(&v); SetLONG(lSrc); }
00042     CVARIANT(BOOL b)        { VariantInit(&v); SetBool(b); }
00043     CVARIANT(short i)       { VariantInit(&v); SetShort(i); }
00044     CVARIANT(double d)      { VariantInit(&v); SetDouble(d); }
00045     CVARIANT(BYTE b)        { VariantInit(&v); SetByte(b); }
00046     CVARIANT(IDispatch * pDisp) { VariantInit(&v); pDisp->AddRef(); SetDispatch(pDisp); }
00047
00048     void   SetStr(LPWSTR pSrc)
00049     { Clear(); V_VT(&v) = pSrc ? VT_BSTR : VT_NULL;
00050       V_BSTR(&v) = pSrc ? SysAllocString(pSrc) : 0;
00051     }
00052
00053     LPWSTR GetStr() { return V_VT(&v) == VT_BSTR ? V_BSTR(&v) : 0; }
00054     operator LPWSTR() { return V_VT(&v) == VT_BSTR ? V_BSTR(&v) : 0; }
00055
00056     void SetLONG(LONG lSrc) { Clear(); V_VT(&v) = VT_I4; V_I4(&v) = lSrc; }
00057     LONG GetLONG() { return V_I4(&v); }
00058     operator LONG() { return V_I4(&v);  }
00059
00060     void SetDouble(double dSrc) { Clear(); V_VT(&v) = VT_R8; V_R8(&v) = dSrc; }
00061     double GetDouble() { return V_R8(&v); }
00062     operator double() { return V_R8(&v);  }
00063
00064     void SetByte(BYTE bySrc) { Clear(); V_VT(&v) = VT_UI1; V_UI1(&v) = bySrc; }
00065     BYTE GetByte() { return V_UI1(&v); }
00066     operator BYTE() { return V_UI1(&v);  }
00067
00068     void SetBool(BOOL b) { V_VT(&v) = VT_BOOL; V_BOOL(&v) = b ? VARIANT_TRUE : VARIANT_FALSE; }
00069     BOOL GetBool() { return V_BOOL(&v) == VARIANT_TRUE; }
00070     operator BOOL() { return V_BOOL(&v); }
00071
00072     void SetDispatch(IDispatch* pDisp) { V_VT(&v) = VT_DISPATCH; V_DISPATCH(&v) = pDisp; }
00073     IDispatch * GetDispatch() { return V_DISPATCH(&v); }
00074
00075     void SetUnknown(IUnknown* pUnk) { V_VT(&v) = VT_UNKNOWN; V_UNKNOWN(&v) = pUnk; }
00076     IUnknown * GetUnknown() { return V_UNKNOWN(&v); }
00077
00078     void SetShort(short i) { V_VT(&v) = VT_I2; V_I2(&v) = i; }
00079     short GetShort() { return V_I2(&v); }
00080     operator short() { return V_I2(&v); }
00081
00082     VARTYPE GetType() { return V_VT(&v); }
00083
00084     void SetArray(SAFEARRAY *p, VARTYPE vt) { Clear(); V_VT(&v) = vt; V_ARRAY(&v) = p; }
00085         // This function acquires the SAFEARRAY pointer and it is no longer owned
00086         // by the caller.
00087
00088     operator SAFEARRAY *() { return (V_VT(&v) & VT_ARRAY ? V_ARRAY(&v) : 0); }
00089
00090     void Unbind() { VariantInit(&v); }
00091 };
00092
00093 class CSAFEARRAY
00094 {
00095     SAFEARRAY *p;
00096 public:
00097     CSAFEARRAY(VARTYPE v, int nSize)
00098     {
00099         SAFEARRAYBOUND rgsabound[1];
00100       rgsabound[0].lLbound = 0;
00101       rgsabound[0].cElements = nSize;
00102         p = SafeArrayCreate(v, 1, rgsabound);
00103     }
00104
00105     ~CSAFEARRAY() { if (p) SafeArrayDestroy(p); }
00106     CSAFEARRAY(SAFEARRAY *pSrc) { p = pSrc; }
00107
00108     HRESULT Put(long nLocation, LPVOID pData) {
00109         return SafeArrayPutElement(p, &nLocation, pData);
00110     }
00111
00112     HRESULT Get(long nLocation, LPVOID pData) {
00113         return SafeArrayGetElement(p, &nLocation, pData);
00114     }
00115
00116     HRESULT Access(void **pData) { return SafeArrayAccessData(p, pData); }
00117     HRESULT Unaccess() { return SafeArrayUnaccessData(p); }
00118
00119     operator SAFEARRAY *() { return p; }
00120     long GetNumElements() { long upper; SafeArrayGetUBound(p, 1, &upper); return upper + 1; }
00121
00122     void Unbind() { p = 0; }
00123 };
00124
00125
00126 #endif
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTestView Member List

This is the complete list of members for CTestView, including all inherited members.
CTestView() | CTestView | [protected]
GetDocument() | CTestView | [inline]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CTestView | [protected]
OnDraw(CDC *pDC) | CTestView | [virtual]
PreCreateWindow(CREATESTRUCT &cs) | CTestView | [virtual]
~CTestView() | CTestView | [virtual]
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/StdAfx.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #pragma once
00007
00008 #define VC_EXTRALEAN        // Exclude rarely-used stuff from Windows headers
00009
00010 #ifndef _UNICODE
00011 #define _UNICODE            // Microsoft Windows NT Cluster Administrator
00012                             //   Extension DLLs need to be Unicode
00013                             //   applications.
00014 #endif
00015
00016 // Choose which threading model you want by commenting or uncommenting
00017 // the proper constant definition.  If you want multi-threading
00018 // (i.e. "both"), comment both definitions out.  Also change the
00019 // THREADFLAGS_xxx set in the DECLARE_REGISTRY macro invokation in ExtObj.h
00020 //#define _ATL_SINGLE_THREADED
00021 #define _ATL_APARTMENT_THREADED
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // Macros
00025 /////////////////////////////////////////////////////////////////////////////
00026
00027 #if(_WIN32_WINNT <= 0x0500)
00028 #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
00029 #endif /* _WIN32_WINNT <= 0x0500 */
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Include Files
00033 /////////////////////////////////////////////////////////////////////////////
00034
00035 //
00036 // Project-wide pragmas
00037 //
00038 #pragma warning( disable : 4127 )   // conditional expression is constant (for BEGIN_COM_MAP & ASSERT)
00039 #pragma warning( disable : 4505 )   // <x>: unreferenced local function has been removed
00040 #pragma warning( disable : 4511 )   // <x>: copy constructor could not be generated
00041 #pragma warning( disable : 4512 )   // <x>: assignment operator could not be generated
00042 #pragma warning( disable : 4514 )   // <x>: unreferenced inline function has been removed
00043 #pragma warning( disable : 4710 )   // function '<x>' not inlined
00044
00045 /////////////////////////////////////////////////////////////////////////////
00046 // External Include Files
00047 /////////////////////////////////////////////////////////////////////////////
00048
00049 #pragma warning( push, 3 )
00050 #pragma warning( disable : 4601 )   // #pragma push_macro : 'new' is not currently defined as a macro
00051
00052 #include <afxwin.h>         // MFC core and standard components
00053 #include <afxext.h>         // MFC extensions
00054 #include <afxdisp.h>
00055 #include <afxtempl.h>
00056 #ifndef _AFX_NO_AFXCMN_SUPPORT
00057 #include <afxcmn.h>         // MFC support for Windows 95 Common Controls
00058 #endif // _AFX_NO_AFXCMN_SUPPORT
00059
00060 // Need to include this for WM_COMMANDHELP.  Unfortunately, both afxpriv.h and
00061 // atlconv.h define some of the same macros.  Since we are using ATL, we'll use
00062 // the ATL versions.
00063 #include <afxpriv.h>
00064
00065 #include <atlbase.h>
00066
00067 //You may derive a class from CComModule and use it if you want to override
00068 //something, but do not change the name of _Module
00069 extern CComModule _Module;
00070
00071 #include <atlcom.h>
00072
00073 #include <clusapi.h>
00074 #include <resapi.h>
00075
00076 #define STRSAFE_LIB
00077 #include <strsafe.h>
00078
00079 #include "proplist.h"
00080
00081 #pragma warning( pop )
00082
00083 /////////////////////////////////////////////////////////////////////////////
00084 // Common Types
00085 /////////////////////////////////////////////////////////////////////////////
00086
00087 typedef UINT    IDS;
00088 typedef UINT    IDD;
00089
00090 /////////////////////////////////////////////////////////////////////////////
00091 // Custom Resource Control Codes
00092 /////////////////////////////////////////////////////////////////////////////
00093
00094 #define CLUSCTL_RESOURCE_FILESHARESAMPLE_CALL_ISALIVE   CLUSCTL_USER_CODE( 1, CLUS_OBJECT_RESOURCE )
00095
00096 /////////////////////////////////////////////////////////////////////////////
00097 // Globals
00098 /////////////////////////////////////////////////////////////////////////////
00099
00100 extern const WCHAR g_wszResourceTypeNames[];
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

vcacct::IGetReceipt Member List

This is the complete list of members for vcacct::IGetReceipt, including all inherited members.
GetNextReceipt() | vcacct::IGetReceipt |
iid | vcacct::IGetReceipt | [static]
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/ADsLargeInteger.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

ADsLargeInteger.cpp

Go to the documentation of this file.
00001 // ADsLargeInteger.cpp : implementation file
00002 //
00003
00004 #include "stdafx.h"
00005 #include "ADQI.h"
00006 #include "ADsLargeInteger.h"
00007
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // CDlgIADsLargeInteger dialog
00016
00017
00018 CDlgIADsLargeInteger::CDlgIADsLargeInteger( LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
00019   : CDialog(CDlgIADsLargeInteger::IDD, pParent)
00020 {
00021   //{{AFX_DATA_INIT(CDlgIADsLargeInteger)
00022   m_lHiPart = 0;
00023   m_lLowPart = 0;
00024   //}}AFX_DATA_INIT
00025
00026
00027   HRESULT hr;
00028   m_pLargeInt = NULL;
00029
00030
00031   hr = pUnk->QueryInterface( IID_IADsLargeInteger, (void **) &m_pLargeInt );
00032   pUnk->Release();
00033
00034   if ( !SUCCEEDED(hr) )
00035   {
00036     AfxMessageBox(_T("Fatal Error! QI for IADsLargeInteger failed"));
00037     return;
00038   }
00039
00040
00041
00042
00043 }
00044
00045 CDlgIADsLargeInteger::~CDlgIADsLargeInteger()
00046 {
00047   if ( m_pLargeInt )
00048   {
00049     m_pLargeInt->Release();
00050   }
00051 }
00052
00053
00054 void CDlgIADsLargeInteger::DoDataExchange(CDataExchange* pDX)
00055 {
00056   CDialog::DoDataExchange(pDX);
00057   //{{AFX_DATA_MAP(CDlgIADsLargeInteger)
00058   DDX_Text(pDX, IDC_HIPART, m_lHiPart);
00059   DDX_Text(pDX, IDC_LOWPART, m_lLowPart);
00060   //}}AFX_DATA_MAP
00061 }
00062
00063
00064 BEGIN_MESSAGE_MAP(CDlgIADsLargeInteger, CDialog)
00065   //{{AFX_MSG_MAP(CDlgIADsLargeInteger)
00066   //}}AFX_MSG_MAP
00067 END_MESSAGE_MAP()
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 // CDlgIADsLargeInteger message handlers
00071
00072 void CDlgIADsLargeInteger::OnOK()
00073 {
00074
00075   CDialog::OnOK();
00076 }
00077
00078 BOOL CDlgIADsLargeInteger::OnInitDialog()
00079 {
00080   CDialog::OnInitDialog();
00081
00082   if ( m_pLargeInt )
00083   {
00084     m_pLargeInt->get_HighPart( &m_lHiPart );
00085     m_pLargeInt->get_LowPart( &m_lLowPart );
00086     UpdateData(FALSE);
00087   }
00088
00089   return TRUE;  // return TRUE unless you set the focus to a control
00090                 // EXCEPTION: OCX Property Pages should return FALSE
00091 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_Connection Member List

This is the complete list of members for msado15::_Connection, including all inherited members.
BeginTrans() | msado15::_Connection |
Cancel() | msado15::_Connection |
Close() | msado15::_Connection |
CommitTrans() | msado15::_Connection |
Execute(String CommandText, Variant RecordsAffected, int Options) | msado15::_Connection |
getAttributes() | msado15::_Connection |
getCommandTimeout() | msado15::_Connection |
getConnectionString() | msado15::_Connection |
getConnectionTimeout() | msado15::_Connection |
getCursorLocation() | msado15::_Connection |
getDefaultDatabase() | msado15::_Connection |
getErrors() | msado15::_Connection |
getIsolationLevel() | msado15::_Connection |
getMode() | msado15::_Connection |
getProperties() | msado15::_Connection |
getProvider() | msado15::_Connection |
getState() | msado15::_Connection |
getVersion() | msado15::_Connection |
iid | msado15::_Connection | [static]
Open(String ConnectionString, String UserID, String Password, int Options) | msado15::_Connection |
OpenSchema(int Schema, Variant Restrictions, Variant SchemaID) | msado15::_Connection |
RollbackTrans() | msado15::_Connection |
setAttributes(int plAttr) | msado15::_Connection |
setCommandTimeout(int plTimeout) | msado15::_Connection |
setConnectionString(String pbstr) | msado15::_Connection |
setConnectionTimeout(int plTimeout) | msado15::_Connection |
setCursorLocation(int plCursorLoc) | msado15::_Connection |
setDefaultDatabase(String pbstr) | msado15::_Connection |
setIsolationLevel(int Level) | msado15::_Connection |
setMode(int plMode) | msado15::_Connection |
setProvider(String pbstr) | msado15::_Connection |
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

LessThan< Item > Member List

This is the complete list of members for LessThan< Item >, including all inherited members.
operator()(const Item &rLeftIn, const Item &rRightIn) const LessThan< Item > [inline]
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/ClassProv/MainDll.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • ClassProv

MainDll.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  MAINDLL.CPP
00006
00007 //
00008
00009 //  Module: WINMGMT class provider sample code
00010
00011 //
00012
00013 //  Purpose: Contains DLL entry points.  Also has code that controls
00014
00015 //           when the DLL can be unloaded by tracking the number of
00016
00017 //           objects and locks as well as routines that support
00018
00019 //           self registration.
00020
00021 //
00022
00023 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00024 //
00025 //***************************************************************************
00026
00027 #include <objbase.h>
00028 #include <initguid.h>
00029 #include "sample.h"
00030 #include <tchar.h>
00031 #include <strsafe.h>
00032
00033 HMODULE ghModule;
00034
00035 // TODO, GuidGen should be used to generate a unique number for any
00036 // providers that are going to be used for anything more extensive
00037 // than just testing.
00038
00039 DEFINE_GUID(CLSID_classprovider,0x22cb8799, 0x914a, 0x11cf, 0xb7, 0x5, 0x0, 0xaa, 0x0, 0x62, 0xcb, 0xb7);
00040 // {22CB8799-914A-11cf-B705-00AA0062CBB7}
00041
00042 //Count number of objects and number of locks.
00043
00044 long       g_cObj=0;
00045 long       g_cLock=0;
00046
00047
00048 //***************************************************************************
00049 //
00050 // LibMain32
00051 //
00052 // Purpose: Entry point for DLL.
00053 //
00054 // Return: TRUE if OK.
00055 //
00056 //***************************************************************************
00057
00058
00059 BOOL WINAPI LibMain32(HINSTANCE hInstance, ULONG ulReason
00060     , LPVOID pvReserved)
00061 {
00062     if (DLL_PROCESS_ATTACH==ulReason)
00063         ghModule = hInstance;
00064     return TRUE;
00065 }
00066
00067 //***************************************************************************
00068 //
00069 //  DllGetClassObject
00070 //
00071 //  Purpose: Called by Ole when some client wants a class factory.  Return
00072 //           one only if it is the sort of class this DLL supports.
00073 //
00074 //***************************************************************************
00075
00076
00077 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, PPVOID ppv)
00078 {
00079     HRESULT hr;
00080     CProvFactory *pObj;
00081
00082     if (CLSID_classprovider!=rclsid)
00083         return E_FAIL;
00084
00085     pObj=new CProvFactory();
00086
00087     if (NULL==pObj)
00088         return E_OUTOFMEMORY;
00089
00090     hr=pObj->QueryInterface(riid, ppv);
00091
00092     if (FAILED(hr))
00093         delete pObj;
00094
00095     return hr;
00096 }
00097
00098 //***************************************************************************
00099 //
00100 // DllCanUnloadNow
00101 //
00102 // Purpose: Called periodically by Ole in order to determine if the
00103 //          DLL can be freed.
00104 //
00105 // Return:  S_OK if there are no objects in use and the class factory
00106 //          isn't locked.
00107 //
00108 //***************************************************************************
00109
00110 STDAPI DllCanUnloadNow(void)
00111 {
00112     SCODE   sc;
00113
00114     //It is OK to unload if there are no objects or locks on the
00115     // class factory.
00116
00117     sc=(0L==g_cObj && 0L==g_cLock) ? S_OK : S_FALSE;
00118     return sc;
00119 }
00120
00121 //***************************************************************************
00122 //
00123 // DllRegisterServer
00124 //
00125 // Purpose: Called during setup or by regsvr32.
00126 //
00127 // Return:  NOERROR if registration successful, error otherwise.
00128 //***************************************************************************
00129
00130 STDAPI DllRegisterServer(void)
00131 {
00132     char       szID[128];
00133   WCHAR   wcID[128];
00134     char       szCLSID[128];
00135     TCHAR       szModule[MAX_PATH + 1];
00136     const char * pName = "WINMGMT Sample Class Provider";
00137     const char * pModel = "Both";
00138     HKEY hKey1, hKey2;
00139
00140     // Create the path.
00141
00142   memset(wcID, NULL, sizeof(wcID));
00143   memset(szID, NULL, sizeof(szID));
00144     StringFromGUID2(CLSID_classprovider, wcID, sizeof(wcID)/sizeof(WCHAR));
00145   wcstombs(szID, wcID, sizeof(szID));
00146   StringCbCopy(szCLSID, sizeof(szCLSID), "Software\\classes\\CLSID\\");
00147   StringCbCat(szCLSID, sizeof(szCLSID), (LPCTSTR)szID);
00148
00149     // Create entries under CLSID
00150
00151   LONG lRet = RegCreateKeyEx( HKEY_LOCAL_MACHINE, szCLSID, 0, NULL,
00152                     REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
00153                     &hKey1, NULL );
00154   if (lRet != ERROR_SUCCESS)
00155   {
00156     return E_FAIL;
00157   }
00158
00159
00160     lRet = RegSetValueEx(hKey1, NULL, 0, REG_SZ, (BYTE *)pName, strlen(pName)+1);
00161   if (lRet != ERROR_SUCCESS)
00162   {
00163     RegCloseKey(hKey1);
00164     return E_FAIL;
00165   }
00166
00167   lRet = RegCreateKeyEx( hKey1, "InprocServer32", 0, NULL,
00168                     REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
00169                     &hKey2, NULL );
00170   if (lRet != ERROR_SUCCESS)
00171   {
00172     RegCloseKey(hKey1);
00173     return E_FAIL;
00174   }
00175
00176   memset(&szModule, NULL, sizeof(szModule));
00177   GetModuleFileName(ghModule, szModule, sizeof(szModule)/sizeof(TCHAR) - 1);
00178
00179     lRet = RegSetValueEx(hKey2, NULL, 0, REG_SZ, (BYTE *)szModule,
00180                                         strlen(szModule)+1);
00181   if (lRet != ERROR_SUCCESS)
00182   {
00183       RegCloseKey(hKey2);
00184     RegCloseKey(hKey1);
00185     return E_FAIL;
00186   }
00187
00188   lRet = RegSetValueEx(hKey2, "ThreadingModel", 0, REG_SZ,
00189                                         (BYTE *)pModel, strlen(pModel)+1);
00190   if (lRet != ERROR_SUCCESS)
00191   {
00192       RegCloseKey(hKey2);
00193     RegCloseKey(hKey1);
00194     return E_FAIL;
00195   }
00196     RegCloseKey(hKey1);
00197     RegCloseKey(hKey2);
00198     return NOERROR;
00199 }
00200
00201 //***************************************************************************
00202 //
00203 // DllUnregisterServer
00204 //
00205 // Purpose: Called when it is time to remove the registry entries.
00206 //
00207 // Return:  NOERROR if registration successful, error otherwise.
00208 //***************************************************************************
00209
00210 STDAPI DllUnregisterServer(void)
00211 {
00212     TCHAR szID[128];
00213   WCHAR wcID[128];
00214     TCHAR szCLSID[128];
00215     HKEY  hKey;
00216
00217     // Create the path using the CLSID
00218
00219   memset(wcID, NULL, sizeof(wcID));
00220   memset(szID, NULL, sizeof(szID));
00221     StringFromGUID2(CLSID_classprovider, wcID, sizeof(wcID)/sizeof(WCHAR));
00222   wcstombs(szID, wcID, sizeof(szID));
00223   StringCbCopy(szCLSID, sizeof(szCLSID), "Software\\classes\\CLSID\\");
00224   StringCbCat(szCLSID, sizeof(szCLSID), (LPCTSTR)szID);
00225
00226
00227
00228     // First delete the InProcServer subkey.
00229
00230     DWORD dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szCLSID, 0, KEY_WRITE, &hKey);
00231     if(dwRet == NO_ERROR)
00232     {
00233         RegDeleteKey(hKey, "InProcServer32");
00234         RegCloseKey(hKey);
00235     }
00236
00237     dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\classes\\CLSID", 0, KEY_WRITE, &hKey);
00238     if(dwRet == NO_ERROR)
00239     {
00240         RegDeleteKey(hKey,szID);
00241         RegCloseKey(hKey);
00242     }
00243
00244     return NOERROR;
00245 }
00246
00247
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/MTXSample/CreateTable.h Source File

  • Web
  • iis
  • Components
  • Cpp
  • MTXSample

CreateTable.h

Go to the documentation of this file.
00001 // CreateTable.h : Declaration of the CCreateTable
00002
00003 #ifndef __CREATETABLE_H_
00004 #define __CREATETABLE_H_
00005
00006 #include "resource.h"       // main symbols
00007
00008 /////////////////////////////////////////////////////////////////////////////
00009 // CCreateTable
00010 class ATL_NO_VTABLE CCreateTable :
00011   public CComObjectRootEx<CComSingleThreadModel>,
00012   public CComCoClass<CCreateTable, &CLSID_CreateTable>,
00013   public ISupportErrorInfo,
00014   public IDispatchImpl<ICreateTable, &IID_ICreateTable, &LIBID_BANKVCLib>
00015 {
00016 public:
00017   CCreateTable()
00018   {
00019   }
00020
00021 DECLARE_REGISTRY_RESOURCEID(IDR_CREATETABLE)
00022
00023 DECLARE_PROTECT_FINAL_CONSTRUCT()
00024
00025 BEGIN_COM_MAP(CCreateTable)
00026   COM_INTERFACE_ENTRY(ICreateTable)
00027   COM_INTERFACE_ENTRY(IDispatch)
00028   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00029 END_COM_MAP()
00030
00031 // ISupportsErrorInfo
00032   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00033
00034 // ICreateTable
00035 public:
00036   STDMETHOD(CreateAccount)();
00037 };
00038
00039 #endif //__CREATETABLE_H_
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat2/iapplet.c Source File

  • Web
  • NetMeeting
  • NMChat2

iapplet.c

Go to the documentation of this file.
00001 /* this file contains the actual definitions of */
00002 /* the IIDs and CLSIDs */
00003
00004 /* link this file in with the server and any clients */
00005
00006
00007 /* File created by MIDL compiler version 5.01.0164 */
00008 /* at Thu Apr 18 16:14:45 2002
00009  */
00010 /* Compiler settings for ..\..\include\iapplet.idl:
00011     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00012     error checks: allocation ref bounds_check enum stub_data
00013 */
00014 //@@MIDL_FILE_HEADING(  )
00015 #ifdef __cplusplus
00016 extern "C"{
00017 #endif
00018
00019
00020 #ifndef __IID_DEFINED__
00021 #define __IID_DEFINED__
00022
00023 typedef struct _IID
00024 {
00025     unsigned long x;
00026     unsigned short s1;
00027     unsigned short s2;
00028     unsigned char  c[8];
00029 } IID;
00030
00031 #endif // __IID_DEFINED__
00032
00033 #ifndef CLSID_DEFINED
00034 #define CLSID_DEFINED
00035 typedef IID CLSID;
00036 #endif // CLSID_DEFINED
00037
00038 const IID IID_IAppletSessionNotify = {0xf7c10ec0,0xa4d9,0x11d2,{0xb7,0x24,0x00,0x10,0x4b,0xc5,0x13,0x39}};
00039
00040
00041 const IID IID_IAppletSession = {0xe65dc590,0xa4d9,0x11d2,{0xb7,0x24,0x00,0x10,0x4b,0xc5,0x13,0x39}};
00042
00043
00044 const IID IID_IAppletNotify = {0x16153670,0xa4da,0x11d2,{0xb7,0x24,0x00,0x10,0x4b,0xc5,0x13,0x39}};
00045
00046
00047 const IID IID_IApplet = {0x07970b30,0xa4da,0x11d2,{0xb7,0x24,0x00,0x10,0x4b,0xc5,0x13,0x39}};
00048
00049
00050 const IID LIBID_NmApplet = {0x8C3ADF96,0xCCFE,0x11d2,{0xAD,0x10,0x00,0xC0,0x4F,0x72,0xDD,0x47}};
00051
00052
00053 const CLSID CLSID_NmApplet = {0x8C3ADF99,0xCCFE,0x11d2,{0xAD,0x10,0x00,0xC0,0x4F,0x72,0xDD,0x47}};
00054
00055
00056 #ifdef __cplusplus
00057 }
00058 #endif
00059
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IWMSCacheAdmin Member List

This is the complete list of members for IWMSCacheAdmin, including all inherited members.
ArchiveQuotaPerStream | IWMSCacheAdmin
BackendServer | IWMSCacheAdmin
CacheDirectoryPath | IWMSCacheAdmin
CacheOnDemandCacheMiss | IWMSCacheAdmin
get | IWMSCacheAdmin
PreferredProtocol | IWMSCacheAdmin
ProxyOnDemandCacheMiss | IWMSCacheAdmin
ProxyRedirectURL | IWMSCacheAdmin
set | IWMSCacheAdmin
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagOleStdEnumFmtEtc Member List

This is the complete list of members for tagOleStdEnumFmtEtc, including all inherited members.
lpVtbl | tagOleStdEnumFmtEtc
m_dwRefs | tagOleStdEnumFmtEtc
m_lpEtc | tagOleStdEnumFmtEtc
m_nCount | tagOleStdEnumFmtEtc
m_nIndex | tagOleStdEnumFmtEtc
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagQtStruct Member List

This is the complete list of members for tagQtStruct, including all inherited members.
buf | tagQtStruct
sz | tagQtStruct
szColName | tagQtStruct
szColNames | tagQtStruct
szDataItem | tagQtStruct
szParam | tagQtStruct
szParamQuery | tagQtStruct
szTableName | tagQtStruct
szValues | tagQtStruct
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/binder.h Source File

  • Dataaccess
  • oledb
  • sampprov

binder.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module BINDER.H | BINDER base object and contained interface
00008 // definitions
00009 //
00010 //
00011
00012 #ifndef _BINDER_H_
00013 #define _BINDER_H_
00014
00015
00016 #include "baseobj.h"
00017
00018 // Forward declarations ------------------------------------------------------
00019
00020 class CImpIBindResource;
00021 class CImpIDBBinderProperties;
00022 class CImpICreateRow;
00023
00024 typedef CImpIBindResource *     PIMPIBINDRESOURCE;
00025 typedef CImpIDBBinderProperties * PIMPIDBBINDERPROPERTIES;
00026 typedef CImpICreateRow *      PIMPICREATEROW;
00027
00028
00029 // Classes -------------------------------------------------------------------
00030
00031 //----------------------------------------------------------------------------
00032 // @class CBinder | Binder object. Containing class for all Binder interfaces
00033 // Object
00034 //
00035 class CBinder : public CBaseObj //@base public | IUnknown
00036 {
00037   //  Contained interfaces are friends
00038   friend class CImpIBindResource;
00039   friend class CImpIDBBinderProperties;
00040   friend class CImpICreateRow;
00041
00042   protected: //@access protected
00043
00044     //@member Utility object to manage properties
00045     PCUTILPROP          m_pUtilProp;
00046
00047     // Interface and OLE Variables
00048
00049     //@cmember Reference count
00050     DBREFCOUNT          m_cRef;
00051
00052     //@cmember Contained IBindResource
00053     PIMPIBINDRESOURCE     m_pIBindResource;
00054     //@cmember Contained IBinderProperties
00055     PIMPIDBBINDERPROPERTIES   m_pIDBBinderProperties;
00056     //@cmember Contained ICreateRow
00057     PIMPICREATEROW        m_pICreateRow;
00058
00059   public: //@access public
00060     //@cmember Constructor
00061     CBinder(LPUNKNOWN);
00062     //@cmember Destructor
00063     virtual ~CBinder(void);
00064
00065
00066     //@cmember Intitialization Routine
00067     BOOL FInit();
00068
00069     //@cmember Request an Interface
00070     STDMETHODIMP        QueryInterface(REFIID, LPVOID *);
00071     //@cmember Increments the Reference count
00072     STDMETHODIMP_(DBREFCOUNT) AddRef(void);
00073     //@cmember Decrements the Reference count
00074     STDMETHODIMP_(DBREFCOUNT) Release(void);
00075 };
00076
00077 typedef CBinder* PCBINDER;
00078
00079
00080 //----------------------------------------------------------------------------
00081 // @class CImpIBindResource | Contained IBindResource class
00082 //
00083 class CImpIBindResource : public IBindResource      //@base public | IBindResource
00084 {
00085   private: //@access private
00086     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CBaseObj)
00087
00088   public: //@access public
00089     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIBindResource);
00090     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00091
00092     //  IBindResource members
00093     STDMETHODIMP Bind
00094           (
00095             IUnknown *      pUnkOuter,
00096             LPCOLESTR     pwszURL,
00097             DWORD       dwBindFlags,
00098             REFGUID       rguid,
00099             REFIID        riid,
00100             IAuthenticate *   pAuthenticate,
00101             DBIMPLICITSESSION * pImplSession,
00102             DWORD *       pdwBindStatus,
00103             IUnknown **     ppUnk
00104           );
00105
00106     // non members
00107     HRESULT   BindDSO
00108           (
00109             IUnknown *      pUnkOuter,
00110             REFIID        riid,
00111             BOOL        fWaitForInit,
00112             WCHAR *       pwszDataSource,
00113             IUnknown **     ppUnk
00114           );
00115
00116     HRESULT   BindSession
00117           (
00118             IUnknown *      pUnkOuter,
00119             REFIID        riid,
00120             WCHAR *       pwszDataSource,
00121             IUnknown **     ppUnk
00122           );
00123
00124     HRESULT   BindSession
00125           (
00126             DBIMPLICITSESSION * pImplSession,
00127             WCHAR *       pwszDataSource
00128           );
00129
00130     HRESULT   BindRowset
00131           (
00132             IUnknown *      pUnkOuter,
00133             REFIID        riid,
00134             DBIMPLICITSESSION * pImplSession,
00135             WCHAR *       pwszDataSource,
00136             WCHAR *       pwszFile,
00137             IUnknown **     ppUnk
00138           );
00139
00140     HRESULT   BindRow
00141           (
00142             IUnknown *      pUnkOuter,
00143             REFIID        riid,
00144             DBIMPLICITSESSION * pImplSession,
00145             WCHAR *       pwszDataSource,
00146             WCHAR *       pwszFile,
00147             ULONG       ulRowNum,
00148             IUnknown **     ppUnk
00149           );
00150
00151     HRESULT   BindStream
00152           (
00153             IUnknown *      pUnkOuter,
00154             REFIID        riid,
00155             DBIMPLICITSESSION * pImplSession,
00156             WCHAR *       pwszDataSource,
00157             WCHAR *       pwszFile,
00158             ULONG       ulRowNum,
00159             IUnknown **     ppUnk
00160           );
00161
00162     HRESULT   ValidateBindArgs
00163           (
00164             IUnknown *      pUnkOuter,
00165             LPCOLESTR     pwszURL,
00166             DBBINDURLFLAG   dwBindFlags,
00167             REFGUID       rguid,
00168             REFIID        riid,
00169             DBIMPLICITSESSION * pImplSession,
00170             IAuthenticate *   pAuthenticate,
00171             DWORD *       pdwBindStatus,
00172             IUnknown **     ppUnk
00173           );
00174
00175     HRESULT   ParseURL
00176           (
00177             LPCOLESTR     pwszURL,
00178             WCHAR **      ppwszDataSource,
00179             WCHAR **      ppwszTableName,
00180             ULONG *       pulRowNum
00181           );
00182
00183     BOOL    FindKeyword
00184           (
00185             LPCOLESTR     pwszURL,
00186             LPCOLESTR     pwszKeyword,
00187             WCHAR **      ppwszToken
00188           );
00189 };
00190
00191
00192 //----------------------------------------------------------------------------
00193 // @class CImpICreateRow | Contained ICreateRow class
00194 //
00195 class CImpICreateRow : public ICreateRow          //@base public | ICreateRow
00196 {
00197   private: //@access private
00198     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CBinder)
00199
00200   public: //@access public
00201     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBinder, CImpICreateRow);
00202     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00203
00204     //  ICreateRow members
00205     //@cmember CreateRow method
00206     STDMETHODIMP CreateRow
00207           (
00208             IUnknown *      pUnkOuter,
00209             LPCOLESTR     pwszURL,
00210             DWORD       dwBindFlags,
00211             REFGUID       rguid,
00212             REFIID        riid,
00213             IAuthenticate *   pAuthenticate,
00214             DBIMPLICITSESSION * pImplSession,
00215             DWORD *       pdwBindStatus,
00216             LPOLESTR *      ppwszNewURL,
00217             IUnknown **     ppUnk
00218           );
00219 };
00220
00221
00222 //----------------------------------------------------------------------------
00223 // @class CImpIBinderProperties | Contained IBinderProperties class
00224 //
00225 class CImpIDBBinderProperties : public IDBBinderProperties  //@base public | IDBBinderProperties
00226 {
00227   private: //@access private
00228     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CBinder)
00229
00230   public: //@access public
00231     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBinder, CImpIDBBinderProperties);
00232     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00233
00234     //  IDBProperties member functions
00235     //@cmember GetProperties method
00236     STDMETHODIMP GetProperties
00237               (
00238             ULONG       cPropertySets,
00239             const DBPROPIDSET rgPropertySets[],
00240                 ULONG*              pcPropertySets,
00241             DBPROPSET**     prgPropertySets
00242               );
00243
00244     //@cmember GetPropertyInfo method
00245         STDMETHODIMP  GetPropertyInfo
00246           (
00247             ULONG       cPropertySets,
00248             const DBPROPIDSET rgPropertySets[],
00249             ULONG*        pcPropertyInfoSets,
00250             DBPROPINFOSET**   prgPropertyInfoSets,
00251             WCHAR**       ppDescBuffer
00252           );
00253
00254         //@cmember SetProperties method
00255         STDMETHODIMP  SetProperties
00256           (
00257             ULONG       cPropertySets,
00258             DBPROPSET     rgPropertySets[]
00259           );
00260
00261     //@cmember Reset method
00262         STDMETHODIMP  Reset();
00263 };
00264
00265
00266
00267 #endif //_BINDER_H_
00268
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/rtmapi.h Source File

  • NetDS
  • RRas
  • ip

rtmapi.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\rtmapi.h
00008
00009 Abstract:
00010
00011     The file contains the header for rtmapi.c...
00012
00013 --*/
00014
00015 #ifndef _RTMAPI_H_
00016 #define _RTMAPI_H_
00017
00018 //
00019 // this indirection would be useful if i ever write a protocol emulator
00020 //
00021
00022 #define RTM_RegisterEntity(preiEntity,                              \
00023                            preemMethods,                            \
00024                            recCallback,                             \
00025                            bReserve,                                \
00026                            rrpProfile,                              \
00027                            phHandle)                                \
00028 RtmRegisterEntity(preiEntity,                                       \
00029                   preemMethods,                                     \
00030                   recCallback,                                      \
00031                   bReserve,                                         \
00032                   rrpProfile,                                       \
00033                   phHandle)
00034
00035
00036 #define RTM_DeregisterEntity(hHandle)                               \
00037 RtmDeregisterEntity(hHandle)
00038
00039
00040
00041 #define RTM_RegisterForChangeNotification(hHandle,                  \
00042                                           rvsViews,                 \
00043                                           rnfFlags,                 \
00044                                           pvContext,                \
00045                                           phNotificationHandle)     \
00046 RtmRegisterForChangeNotification(hHandle,                           \
00047                                  rvsViews,                          \
00048                                  rnfFlags,                          \
00049                                  pvContext,                         \
00050                                  phNotificationHandle)
00051
00052
00053 #define RTM_DeregisterFromChangeNotification(hHandle,               \
00054                                              hNotificationHandle)   \
00055 RtmDeregisterFromChangeNotification(hHandle,                        \
00056                                     hNotificationHandle)
00057
00058
00059
00060 #define RTM_GetChangedDests(hRtmHandle,                             \
00061                             hNotificationHandle,                    \
00062                             puiNumDests,                            \
00063                             pRtmDestInfo)                           \
00064 RtmGetChangedDests(hRtmHandle,                                      \
00065                    hNotificationHandle,                             \
00066                    puiNumDests,                                     \
00067                    pRtmDestInfo)
00068
00069
00070 #define RTM_ReleaseChangedDests(hRtmHandle,                         \
00071                                 hNotificationHandle,                \
00072                                 uiNumDests,                         \
00073                                 pRtmDestInfo)                       \
00074 RtmReleaseChangedDests(hRtmHandle,                                  \
00075                       hNotificationHandle,                          \
00076                       uiNumDests,                                   \
00077                       pRtmDestInfo)
00078
00079
00080 #define RTM_SetAddress(prnaAddress,                                 \
00081                        ipAddress)                                   \
00082 RTM_IPV4_SET_ADDR_AND_LEN(prnaAddress,                              \
00083                           ipAddress,                                \
00084                           sizeof(IPADDRESS))
00085
00086 #define RTM_GetAddress(pipAddress,                                  \
00087                        prnaAddress)                                 \
00088 (                                                                   \
00089     IP_ASSIGN((pipAddress), (* (ULONG *)  (prnaAddress)->AddrBits)) \
00090 )
00091
00092 #define RTM_GetMostSpecificDestination (RtmRegHandle,               \
00093                                         DestAddress,                \
00094                                         ProtocolId,                 \
00095                                         TargetView,                 \
00096                                         DestInfo)                   \
00097 RtmGetMostSpecificDestination (RtmRegHandle,                        \
00098                                DestAddress,                         \
00099                                ProtocolId,                          \
00100                                TargetView,                          \
00101                                DestInfo)
00102
00103 #define RTM_ReleaseDestInfo (RtmRegHandle,                          \
00104                              DestInfo)                              \
00105 RtmReleaseDestInfo (RtmRegHandle,                                   \
00106                     DestInfo)
00107
00108 #define RTM_MarkDestForChangeNotification (RtmRegHandle,            \
00109                                            NotifyHandle,            \
00110                                            DestHandle,              \
00111                                            MarkDest)                \
00112 RtmMarkDestForChangeNotification (RtmRegHandle,                     \
00113                                   NotifyHandle,                     \
00114                                   DestHandle,                       \
00115                                   MarkDest)
00116
00117 #define RTM_IsMarkedForChangeNotification (RtmRegHandle,            \
00118                                            NotifyHandle,            \
00119                                            DestHandle,              \
00120                                            DestMarked)              \
00121 RtmIsMarkedForChangeNotification (RtmRegHandle,                     \
00122                                   NotifyHandle,                     \
00123                                   DestHandle,                       \
00124                                   DestMarked)
00125
00126 #define RTM_GetOpaqueInformationPointer (RtmRegHandle,              \
00127                                          DestHandle,                \
00128                                          OpaqueInfoPointer)         \
00129 RtmGetOpaqueInformationPointer (RtmRegHandle,                       \
00130                                 DestHandle,                         \
00131                                 OpaqueInfoPointer)
00132
00133
00134
00135 //
00136 // function declarations for rtmv2 interface
00137 //
00138
00139 #ifdef DEBUG
00140 DWORD
00141 RTM_DisplayDestInfo(
00142     IN  PRTM_DEST_INFO          prdi);
00143 #else
00144 #define RTM_DisplayDestInfo(prdi)
00145 #endif // DEBUG
00146
00147
00148
00149 DWORD
00150 RTM_NextHop (
00151     IN  PRTM_DEST_INFO              prdiDestination,
00152     OUT PDWORD                      pdwIfIndex,
00153     OUT PIPADDRESS                  pipNeighbor);
00154
00155
00156
00157 DWORD
00158 APIENTRY
00159 RTM_CallbackEvent (
00160     IN  RTM_ENTITY_HANDLE   hRtmHandle,
00161     IN  RTM_EVENT_TYPE      retEvent,
00162     IN  PVOID               pvContext1,
00163     IN  PVOID               pvContext2);
00164
00165 #endif // _RTMAPI_H_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/statnode.Cpp Source File

  • SysMgmt
  • MMC
  • Extens

statnode.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "StatNode.h"
00021
00022 #include "Space.h"
00023 #include "Sky.h"
00024 #include "People.h"
00025 #include "Land.h"
00026 #include "Extend.h"
00027
00028 const GUID CStaticNode::thisGuid = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00029
00030 //==============================================================
00031 //
00032 // CStaticNode implementation
00033 //
00034 //
00035 CStaticNode::CStaticNode()
00036 {
00037     children[0] = new CPeoplePoweredVehicle;
00038     children[1] = new CLandBasedVehicle;
00039     children[2] = new CSkyBasedVehicle;
00040     children[3] = new CSpaceVehicle;
00041 }
00042
00043 CStaticNode::~CStaticNode()
00044 {
00045     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00046         if (children[n]) {
00047             delete children[n];
00048         }
00049 }
00050
00051 HRESULT CStaticNode::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00052 {
00053     SCOPEDATAITEM sdi;
00054
00055     if (!bExpanded) {
00056         // create the child nodes, then expand them
00057         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00058             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00059             sdi.mask = SDI_STR       |   // Displayname is valid
00060                 SDI_PARAM     |   // lParam is valid
00061                 SDI_IMAGE     |   // nImage is valid
00062                 SDI_OPENIMAGE |   // nOpenImage is valid
00063                 SDI_PARENT    |
00064                 SDI_CHILDREN;
00065
00066             sdi.relativeID  = (HSCOPEITEM)parent;
00067             sdi.nImage      = children[n]->GetBitmapIndex();
00068             sdi.nOpenImage  = INDEX_OPENFOLDER;
00069             sdi.displayname = MMC_CALLBACK;
00070             sdi.lParam      = (LPARAM)children[n];  // The cookie
00071             sdi.cChildren   = (n == 0 || n == 2);   // Only first and third
00072                           // children have child nodes
00073
00074             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00075
00076             _ASSERT( SUCCEEDED(hr) );
00077         }
00078     }
00079
00080     return S_OK;
00081 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CONNECTEXARGS Member List

This is the complete list of members for _CONNECTEXARGS, including all inherited members.
dwBytesSent | _CONNECTEXARGS
dwSendDataLength | _CONNECTEXARGS
lpSendBuffer | _CONNECTEXARGS
name | _CONNECTEXARGS
namelen | _CONNECTEXARGS
s | _CONNECTEXARGS
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ActiveDirectory/PropSheetHost/stdafx.cpp Source File

  • NetDS
  • ActiveDirectory
  • PropSheetHost

stdafx.cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002 //    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003 //    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 //    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 //    PARTICULAR PURPOSE.
00006 //
00007 //    Copyright Microsoft Corporation. All Rights Reserved.
00008 //***************************************************************************
00009
00010 //***************************************************************************
00011 //
00012 //    File:          stdafx.cpp
00013 //
00014 //    Description: Source file that includes just the standard includes
00015 //    PropSheetHost.pch will be the pre-compiled header stdafx.obj will
00016 //    contain the pre-compiled type information
00017 //
00018 //***************************************************************************
00019
00020 //***************************************************************************
00021 //    #include statements
00022 //***************************************************************************
00023
00024 #include "stdafx.h"
00025
00026 // TODO: reference any additional headers you need in STDAFX.H
00027 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DcdServe/PAPER.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DcdServe

PAPER.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAPER.CPP
00003
00004   Summary:   Implementation file for the COPaper COM Object Class (for
00005              connectable COPaper COM Objects). This module provides a
00006              thread-safe virtual drawing Paper object. COPaper
00007              encapsulates into a COM object the behavior of an electronic
00008              sheet of white drawing paper. The client can use the native
00009              ISharePaper interface to draw free-form ink lines on the paper
00010              surface. No GUI behavior is provided within COPaper--it only
00011              provides the semantics of the virtual paper sheet and manages
00012              the ink data for the drawing done there.
00013
00014              APPUTIL's CThreaded OwnThis technology is used in COPaper to
00015              ensure mutually exclusive access by contending multiple
00016              client threads.
00017
00018              Connectable object technology is used in COPaper to notify
00019              connected clients of various events like when a load of new
00020              data is completed.
00021
00022              COPaper offers a main standard IUnknown interface (basic COM
00023              object features), the standard IConnectionPointContainer
00024              interface (connectable COM object features), and the custom
00025              ISharePaper interface (shared drawing Paper related
00026              features). This multiple interface COM Object Class is
00027              achieved via the technique of nested classes.  The
00028              implementations of the IConnectionPointContainer and
00029              ISharePaper interfaces are nested inside the COPaper Class.
00030
00031              For a comprehensive tutorial code tour of this module's
00032              contents and offerings see the tutorial DCDSERVE.HTM
00033              file. For more specific technical details on the internal
00034              workings see the comments dispersed throughout the module's
00035              source code.
00036
00037   Classes:   COPaper.
00038
00039   Functions: none.
00040
00041   Origin:    8-23-97: atrent - Editor-inheritance from BALL.CPP in
00042              the CONSERVE Tutorial Code Sample. [Revised]
00043
00044 ----------------------------------------------------------------------------
00045   This file is part of the Microsoft COM Tutorial Code Samples.
00046
00047   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00048
00049   This source code is intended only as a supplement to Microsoft
00050   Development Tools and/or on-line documentation.  See these other
00051   materials for detailed information regarding Microsoft code samples.
00052
00053   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00054   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00055   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00056   PARTICULAR PURPOSE.
00057 ==========================================================================+*/
00058
00059
00060 /*---------------------------------------------------------------------------
00061   We include WINDOWS.H for all Win32 applications.
00062   We include OLE2.H because we will be calling the COM/OLE Libraries.
00063   We include OLECTL.H because it has definitions for connectable objects.
00064   We include APPUTIL.H because we will be building this application using
00065     the convenient Virtual Window and Dialog classes and other
00066     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00067   We include PAPINT.H and PAPGUIDS.H for the common Paper-related
00068     Interface class, GUID, and CLSID specifications.
00069   We include SERVER.H because it has internal class declarations for
00070     the server's control object.
00071   We include CONNECT.H for object class declarations for the various
00072     connection point and connection COM objects used in DCDSERVE.
00073   We include PAPER.H because it has the COPaper class declarations.
00074 ---------------------------------------------------------------------------*/
00075 #include <windows.h>
00076 #include <ole2.h>
00077 #include <olectl.h>
00078 #include <apputil.h>
00079 #include <papint.h>
00080 #include <papguids.h>
00081 #include "server.h"
00082 #include "connect.h"
00083 #include "paper.h"
00084
00085
00086 /*---------------------------------------------------------------------------
00087   COPaper's implementation of its main COM object class including
00088   Constructor, Destructor, and the QueryInterface, AddRef, and Release
00089   methods of the principal IUnknown interface.
00090 ---------------------------------------------------------------------------*/
00091
00092 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00093   Method:   COPaper::COPaper
00094
00095   Summary:  COPaper Constructor. Note the member initializer:
00096             "m_ImpISharePaper(this, pUnkOuter)" which is used to pass the
00097             'this' and pUnkOuter pointers of the constructor function to
00098             the constructor in the instantiation of the implementation of
00099             the CImpISharePaper interface (which is nested inside this
00100             present COPaper Object Class). Same technique is used for the
00101             m_ImpIConnectionPointContainer nested interface
00102             implementation.
00103
00104   Args:     IUnknown* pUnkOuter,
00105               Pointer to the the outer IUnknown.  NULL means this COM Object
00106               is not being Aggregated.  Non NULL means it is being created
00107               on behalf of an outside COM object that is reusing it via
00108               aggregation.
00109             CServer* pServer)
00110               Pointer to the server's control object.
00111
00112   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00113
00114   Returns:  void
00115 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00116 COPaper::COPaper(
00117   IUnknown* pUnkOuter,
00118   CServer* pServer) :
00119   m_ImpISharePaper(this, pUnkOuter),
00120   m_ImpIConnectionPointContainer(this, pUnkOuter)
00121 {
00122   UINT i;
00123
00124   // Zero the COM object's reference count.
00125   m_cRefs = 0;
00126
00127   // No AddRef necessary if non-NULL, as we're nested.
00128   m_pUnkOuter = pUnkOuter;
00129
00130   // Assign the pointer to the server control object.
00131   m_pServer = pServer;
00132
00133   // Null all entries in the connection point array.
00134   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00135     m_aConnectionPoints[i] = NULL;
00136
00137   // Init the storage file name to empty.
00138   m_szPapFile[0] = 0;
00139
00140   return;
00141 }
00142
00143
00144 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00145   Method:   COPaper::~COPaper
00146
00147   Summary:  COPaper Destructor.
00148
00149   Args:     void
00150
00151   Returns:  void
00152 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00153 COPaper::~COPaper(void)
00154 {
00155   UINT i;
00156   IConnectionPoint* pIConnectionPoint;
00157
00158   // Do final release of the connection point objects.
00159   // If this isn't the final release, then the client has an outstanding
00160   // unbalanced reference to a connection point and a memory leak may
00161   // likely result because the host COPaper object is now going away yet
00162   // a connection point for this host object will not end up deleting
00163   // itself (and its connections array).
00164   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00165   {
00166     pIConnectionPoint = m_aConnectionPoints[i];
00167     RELEASE_INTERFACE(pIConnectionPoint);
00168   }
00169
00170   return;
00171 }
00172
00173
00174 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00175   Method:   COPaper::Init
00176
00177   Summary:  COPaper initialization method.  Create any necessary arrays,
00178             structures, and subordinate objects.
00179
00180   Args:     void
00181
00182   Modifies: m_aConnectionPoints.
00183
00184   Returns:  HRESULT
00185               Standard result code. NOERROR for success.
00186 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00187 HRESULT COPaper::Init(void)
00188 {
00189   HRESULT hr = NOERROR;
00190   COConnectionPoint* pCOConnPt;
00191
00192   // Rig this COPaper COM object to be connectable. Assign the connection
00193   // point array. This object's connection points are determined at
00194   // compile time--it currently has only one connection point:
00195   // the CONNPOINT_PAPERSINK connection point. Create a connection
00196   // point object for this and assign it into the array. This array could
00197   // easily grow to support additional connection points in the future.
00198
00199   // First try creating a new connection point object. Pass 'this' as the
00200   // pHostObj pointer used by the connection point to pass its AddRef and
00201   // Release calls back to the host connectable object.
00202   pCOConnPt = new COConnectionPoint(this);
00203   if (NULL != pCOConnPt)
00204   {
00205     // If creation succeeded then initialize it (including creating
00206     // its initial dynamic connection array).
00207     hr = pCOConnPt->Init(IID_IPaperSink);
00208
00209     // If the init succeeded then use QueryInterface to obtain the
00210     // IConnectionPoint interface on the new connection point object.
00211     // The interface pointer is assigned directly into the
00212     // connection point array. The QI also does the needed AddRef.
00213     if (SUCCEEDED(hr))
00214       hr = pCOConnPt->QueryInterface(
00215                         IID_IConnectionPoint,
00216                         (PPVOID)&m_aConnectionPoints[CONNPOINT_PAPERSINK]);
00217   }
00218   else
00219     hr = E_OUTOFMEMORY;
00220
00221   // Build a path to where the default shared drawing .PAP file
00222   // should be. It is assumed to be in the same directory as the
00223   // EXE server. The file name is the exename with a .PAP extension.
00224   MakeFamilyPath(
00225     m_pServer->m_hInstServer,
00226     m_szPapFile,
00227     TEXT(PAP_FILE_EXT));
00228
00229   return hr;
00230 }
00231
00232
00233 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00234   Method:   COPaper::QueryInterface
00235
00236   Summary:  QueryInterface of the COPaper non-delegating IUnknown
00237             implementation.
00238
00239   Args:     REFIID riid,
00240               [in] GUID of the Interface being requested.
00241             PPVOID ppv)
00242               [out] Address of the caller's pointer variable that will
00243               receive the requested interface pointer.
00244
00245   Returns:  HRESULT
00246               Standard result code. NOERROR for success.
00247 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00248 STDMETHODIMP COPaper::QueryInterface(
00249                REFIID riid,
00250                PPVOID ppv)
00251 {
00252   HRESULT hr = E_NOINTERFACE;
00253
00254   *ppv = NULL;
00255
00256   if (IID_IUnknown == riid)
00257     *ppv = this;
00258   else if (IID_ISharePaper == riid)
00259     *ppv = &m_ImpISharePaper;
00260   else if (IID_IConnectionPointContainer == riid)
00261     *ppv = &m_ImpIConnectionPointContainer;
00262
00263   if (NULL != *ppv)
00264   {
00265     // We've handed out a pointer to the interface so obey the COM rules
00266     // and AddRef the reference count.
00267     ((LPUNKNOWN)*ppv)->AddRef();
00268     hr = NOERROR;
00269   }
00270
00271   return (hr);
00272 }
00273
00274
00275 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00276   Method:   COPaper::AddRef
00277
00278   Summary:  AddRef of the COPaper non-delegating IUnknown implementation.
00279
00280   Args:     void
00281
00282   Modifies: m_cRefs.
00283
00284   Returns:  ULONG
00285               New value of m_cRefs (COM object's reference count).
00286 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00287 STDMETHODIMP_(ULONG) COPaper::AddRef(void)
00288 {
00289   ULONG cRefs;
00290
00291   if (OwnThis())
00292   {
00293     cRefs = ++m_cRefs;
00294
00295     UnOwnThis();
00296   }
00297
00298   return cRefs;
00299 }
00300
00301
00302 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00303   Method:   COPaper::Release
00304
00305   Summary:  Release of the COPaper non-delegating IUnknown implementation.
00306
00307   Args:     void
00308
00309   Modifies: m_cRefs.
00310
00311   Returns:  ULONG
00312               New value of m_cRefs (COM object's reference count).
00313 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00314 STDMETHODIMP_(ULONG) COPaper::Release(void)
00315 {
00316   ULONG cRefs;
00317
00318   if (OwnThis())
00319   {
00320     cRefs = --m_cRefs;
00321
00322     if (0 == cRefs)
00323     {
00324       // We've reached a zero reference count for this COM object.
00325       // So we tell the server housing to decrement its global object
00326       // count so that the server will be unloaded if appropriate.
00327       if (NULL != m_pServer)
00328         m_pServer->ObjectsDown();
00329
00330       // We artificially bump the main ref count to prevent reentrancy
00331       // via the main object destructor.  Not really needed in this
00332       // COPaper but a good practice because we are aggregatable and
00333       // may at some point in the future add something entertaining like
00334       // some Releases to the COPaper destructor. We relinquish thread
00335       // ownership of this object prior to deleting it--a good practice.
00336       m_cRefs++;
00337       UnOwnThis();
00338       delete this;
00339     }
00340     else
00341       UnOwnThis();
00342   }
00343
00344   return cRefs;
00345 }
00346
00347
00348 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00349   Method:   COPaper::NotifySinks
00350
00351   Summary:  Internal utility method of this COM object used to fire event
00352             notification calls to all listening connection sinks in the
00353             client(s).
00354
00355   Args:     PAPER_EVENT PaperEvent
00356               Type of notification event.
00357             SHORT nX
00358               X cordinate. Value is 0 unless event needs it.
00359             SHORT nY
00360               Y cordinate. Value is 0 unless event needs it.
00361             SHORT nInkWidth
00362               Ink Width. Value is 0 unless event needs it.
00363             SHORT crInkColor
00364               COLORREF RGB color value. Value is 0 unless event needs it.
00365
00366   Returns:  HRESULT
00367               Standard result code. NOERROR for success.
00368 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00369 HRESULT COPaper::NotifySinks(
00370        PAPER_EVENT PaperEvent,
00371        SHORT nX,
00372        SHORT nY,
00373        SHORT nInkWidth,
00374        COLORREF crInkColor)
00375 {
00376   HRESULT hr = NOERROR;
00377   IConnectionPoint* pIConnectionPoint;
00378   IEnumConnections* pIEnum;
00379   CONNECTDATA ConnData;
00380
00381   // If there was a paper event, broadcast appropriate notifications to
00382   // all Sinks connected to each connection point.
00383   if (PAPER_EVENT_NONE != PaperEvent)
00384   {
00385     // Here is the section for the PaperSink connection point--currently
00386     // this is the only connection point offered by COPaper objects.
00387     pIConnectionPoint = m_aConnectionPoints[CONNPOINT_PAPERSINK];
00388     if (NULL != pIConnectionPoint)
00389     {
00390       pIConnectionPoint->AddRef();
00391       hr = pIConnectionPoint->EnumConnections(&pIEnum);
00392       if (SUCCEEDED(hr))
00393       {
00394         // Loop thru the connection point's connections and if the
00395         // listening connection supports IPaperSink (ie, PaperSink events)
00396         // then dispatch the PaperEvent event notification to that sink.
00397         while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
00398         {
00399           IPaperSink* pIPaperSink;
00400
00401           hr = ConnData.pUnk->QueryInterface(
00402                                 IID_IPaperSink,
00403                                 (PPVOID)&pIPaperSink);
00404           if (SUCCEEDED(hr))
00405           {
00406             switch (PaperEvent)
00407             {
00408               case PAPER_EVENT_LOCKED:
00409                 pIPaperSink->Locked();
00410                 break;
00411               case PAPER_EVENT_UNLOCKED:
00412                 pIPaperSink->Unlocked();
00413                 break;
00414               case PAPER_EVENT_LOADED:
00415                 pIPaperSink->Loaded();
00416                 break;
00417               case PAPER_EVENT_SAVED:
00418                 pIPaperSink->Saved();
00419                 break;
00420               case PAPER_EVENT_INKSTART:
00421                 pIPaperSink->InkStart(nX, nY, nInkWidth, crInkColor);
00422                 break;
00423               case PAPER_EVENT_INKDRAW:
00424                 pIPaperSink->InkDraw(nX, nY);
00425                 break;
00426               case PAPER_EVENT_INKSTOP:
00427                 pIPaperSink->InkStop(nX, nY);
00428                 break;
00429               case PAPER_EVENT_ERASED:
00430                 pIPaperSink->Erased();
00431                 break;
00432               case PAPER_EVENT_RESIZED:
00433                 pIPaperSink->Resized(nX, nY);
00434                 break;
00435               default:
00436                 break;
00437             }
00438             pIPaperSink->Release();
00439           }
00440           ConnData.pUnk->Release();
00441         }
00442         pIEnum->Release();
00443       }
00444       pIConnectionPoint->Release();
00445     }
00446   }
00447
00448   return hr;
00449 }
00450
00451
00452 /*---------------------------------------------------------------------------
00453   COPaper's nested implementation of the COM standard
00454   IConnectionPointContainer interface including Constructor, Destructor,
00455   QueryInterface, AddRef, Release, FindConnectionPoint, and
00456   EnumConnectionPoints.
00457 ---------------------------------------------------------------------------*/
00458
00459 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00460   Method:   COPaper::CImpIConnectionPointContainer
00461               ::CImpIConnectionPointContainer
00462
00463   Summary:  Constructor for the CImpIConnectionPointContainer interface
00464             instantiation.
00465
00466   Args:     COPaper* pCO,
00467               Back pointer to the parent outer COM object.
00468             IUnknown* pUnkOuter
00469               Pointer to the outer Unknown.  For delegation.
00470
00471   Modifies: m_pCO, m_pUnkOuter.
00472
00473   Returns:  void
00474 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00475 COPaper::CImpIConnectionPointContainer::CImpIConnectionPointContainer(
00476   COPaper* pCO,
00477   IUnknown* pUnkOuter)
00478 {
00479   // Init the Back Object Pointer to point to the parent object.
00480   m_pCO = pCO;
00481
00482   // Init the CImpIConnectionPointContainer interface's delegating Unknown
00483   // pointer.  We use the Back Object pointer for IUnknown delegation here
00484   // if we are not being aggregated.  If we are being aggregated we use
00485   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00486   // pointer assignment requires no AddRef because the
00487   // CImpIConnectionPointContainer lifetime is quaranteed by the lifetime
00488   // of the parent object in which CImpIConnectionPointContainer is
00489   // nested.
00490   if (NULL == pUnkOuter)
00491     m_pUnkOuter = pCO;
00492   else
00493     m_pUnkOuter = pUnkOuter;
00494
00495   return;
00496 }
00497
00498
00499 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00500   Method:   COPaper::CImpIConnectionPointContainer
00501               ::~CImpIConnectionPointContainer
00502
00503   Summary:  Destructor for the CImpIConnectionPointContainer interface
00504             instantiation.
00505
00506   Args:     void
00507
00508   Returns:  void
00509 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00510 COPaper::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
00511 {
00512   return;
00513 }
00514
00515
00516 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00517   Method:   COPaper::CImpIConnectionPointContainer::QueryInterface
00518
00519   Summary:  The QueryInterface IUnknown member of this interface
00520             implementation that delegates to m_pUnkOuter, whatever it is.
00521
00522   Args:     REFIID riid,
00523               [in] GUID of the Interface being requested.
00524             PPVOID ppv)
00525               [out] Address of the caller's pointer variable that will
00526               receive the requested interface pointer.
00527
00528   Returns:  HRESULT
00529               Standard result code. NOERROR for success.
00530               Returned by the delegated outer QueryInterface call.
00531 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00532 STDMETHODIMP COPaper::CImpIConnectionPointContainer::QueryInterface(
00533                REFIID riid,
00534                PPVOID ppv)
00535 {
00536   // Delegate this call to the outer object's QueryInterface.
00537   return m_pUnkOuter->QueryInterface(riid, ppv);
00538 }
00539
00540
00541 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00542   Method:   COPaper::CImpIConnectionPointContainer::AddRef
00543
00544   Summary:  The AddRef IUnknown member of this interface implementation
00545             that delegates to m_pUnkOuter, whatever it is.
00546
00547   Args:     void
00548
00549   Returns:  ULONG
00550               Returned by the delegated outer AddRef call.
00551 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00552 STDMETHODIMP_(ULONG) COPaper::CImpIConnectionPointContainer::AddRef(void)
00553 {
00554   // Delegate this call to the outer object's AddRef.
00555   return m_pUnkOuter->AddRef();
00556 }
00557
00558
00559 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00560   Method:   COPaper::CImpIConnectionPointContainer::Release
00561
00562   Summary:  The Release IUnknown member of this interface implementation
00563             that delegates to m_pUnkOuter, whatever it is.
00564
00565   Args:     void
00566
00567   Returns:  ULONG
00568               Returned by the delegated outer Release call.
00569 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00570 STDMETHODIMP_(ULONG) COPaper::CImpIConnectionPointContainer::Release(void)
00571 {
00572   // Delegate this call to the outer object's Release.
00573   return m_pUnkOuter->Release();
00574 }
00575
00576
00577 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00578   Method:   COPaper::CImpIConnectionPointContainer::FindConnectionPoint
00579
00580   Summary:  Given an IID for a connection point sink find and return the
00581             interface pointer for that connection point sink.
00582
00583   Args:     REFIID riid
00584               Reference to an IID
00585             IConnectionPoint** ppConnPt
00586               Address of the caller's IConnectionPoint interface pointer
00587               variable that will receive the requested interface pointer.
00588
00589   Returns:  HRESULT
00590               Standard result code. NOERROR for success.
00591 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00592 STDMETHODIMP COPaper::CImpIConnectionPointContainer::FindConnectionPoint(
00593                REFIID riid,
00594                IConnectionPoint** ppConnPt)
00595 {
00596   HRESULT hr = E_NOINTERFACE;
00597   IConnectionPoint* pIConnPt;
00598
00599   if (OwnThis())
00600   {
00601     // NULL the output variable.
00602     *ppConnPt = NULL;
00603
00604     pIConnPt = m_pCO->m_aConnectionPoints[CONNPOINT_PAPERSINK];
00605     if (NULL != pIConnPt)
00606     {
00607       // This connectable COPaper object currently has only the Paper Sink
00608       // connection point. If the associated interface is requested,
00609       // use QI to get the Connection Point interface and perform the
00610       // needed AddRef.
00611       if (IID_IPaperSink == riid)
00612         hr = pIConnPt->QueryInterface(
00613                          IID_IConnectionPoint,
00614                          (PPVOID)ppConnPt);
00615     }
00616
00617     UnOwnThis();
00618   }
00619
00620   return hr;
00621 }
00622
00623
00624 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00625   Method:   COPaper::CImpIConnectionPointContainer::EnumConnectionPoints
00626
00627   Summary:  Return Enumerator for the connectable object's contained
00628             connection points.
00629
00630   Args:     IEnumConnectionPoints** ppIEnum
00631               Address of the caller's Enumerator interface pointer
00632               variable. An output variable that will receive a pointer to
00633               the connection point enumerator COM object.
00634
00635   Returns:  HRESULT
00636               Standard result code. NOERROR for success.
00637 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00638 STDMETHODIMP COPaper::CImpIConnectionPointContainer::EnumConnectionPoints(
00639                        IEnumConnectionPoints** ppIEnum)
00640 {
00641   HRESULT hr = NOERROR;
00642   IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
00643   COEnumConnectionPoints* pCOEnum;
00644   UINT i;
00645
00646   if (OwnThis())
00647   {
00648     // Zero the output interface pointer.
00649     *ppIEnum = NULL;
00650
00651     // Make a copy on the stack of the array of connection point
00652     // interfaces. The copy is used below in the creation of the new
00653     // Enumerator object.
00654     for (i=0; i<MAX_CONNECTION_POINTS; i++)
00655       aConnPts[i] = (IConnectionPoint*)m_pCO->m_aConnectionPoints[i];
00656
00657     // Create a Connection Point enumerator COM object for the connection
00658     // points offered by this COPaper object. Pass 'this' to be used to
00659     // hook the lifetime of the host object to the life time of this
00660     // enumerator object.
00661     pCOEnum = new COEnumConnectionPoints(this);
00662     if (NULL != pCOEnum)
00663     {
00664       // Use the array copy to Init the new Enumerator COM object.
00665       // Set the initial Enumerator index to 0.
00666       hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
00667       if (SUCCEEDED(hr))
00668       {
00669         // QueryInterface to return the requested interface pointer.
00670         // An AddRef will be conveniently done by the QI.
00671         if (SUCCEEDED(hr))
00672           hr = pCOEnum->QueryInterface(
00673                           IID_IEnumConnectionPoints,
00674                           (PPVOID)ppIEnum);
00675       }
00676     }
00677     else
00678       hr = E_OUTOFMEMORY;
00679
00680     UnOwnThis();
00681   }
00682
00683   return hr;
00684 }
00685
00686
00687 /*---------------------------------------------------------------------------
00688   COPaper's nested implementation of the custom ISharePaper interface
00689   including Constructor, Destructor, QueryInterface, AddRef, Release,
00690   Init, Lock, InkStart, InkDraw, InkStop, GetInk, Erase, and Resize.
00691 ---------------------------------------------------------------------------*/
00692
00693 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00694   Method:   COPaper::CImpISharePaper::CImpISharePaper
00695
00696   Summary:  Constructor for the CImpISharePaper interface instantiation.
00697
00698   Args:     COPaper* pCO,
00699               Back pointer to the parent outer COM object.
00700             IUnknown* pUnkOuter
00701               Pointer to the outer Unknown.  For delegation.
00702
00703   Modifies: m_pCO, m_pUnkOuter.
00704
00705   Returns:  void
00706 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00707 COPaper::CImpISharePaper::CImpISharePaper(
00708   COPaper* pCO,
00709   IUnknown* pUnkOuter)
00710 {
00711   // Init the Back Object Pointer to point to the parent object.
00712   m_pCO = pCO;
00713
00714   // Init the CImpISharePaper interface's delegating Unknown pointer. We
00715   // use the main object pointer for IUnknown delegation here if we are not
00716   // being aggregated.  If we are being aggregated we use the supplied
00717   // pUnkOuter for IUnknown delegation.  In either case the pointer
00718   // assignment requires no AddRef because the CImpISharePaper lifetime is
00719   // quaranteed by the lifetime of the parent object in which
00720   // CImpISharePaper is nested.
00721   if (NULL == pUnkOuter)
00722     m_pUnkOuter = pCO;
00723   else
00724     m_pUnkOuter = pUnkOuter;
00725
00726   // Now initialize the living heart of this virtual Paper entity.
00727   m_ClipBdFmt    = 0;
00728   m_bLocked      = FALSE;
00729   m_crWinColor   = RGB(255,255,255); // White
00730   m_crInkColor   = RGB(0,0,0);       // Black
00731   m_nInkWidth    = 2;                // 2 pixels wide (thin).
00732   m_lInkDataEnd  = 0;                // Current drawing data end.
00733   m_lInkDataMax  = 0;                // Upper bound to m_lInkDataEnd.
00734   m_paInkData    = NULL;             // Points to Ink data array.
00735
00736   return;
00737 }
00738
00739
00740 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00741   Method:   COPaper::CImpISharePaper::~CImpISharePaper
00742
00743   Summary:  Destructor for the CImpISharePaper interface instantiation.
00744
00745   Args:     void
00746
00747   Returns:  void
00748 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00749 COPaper::CImpISharePaper::~CImpISharePaper(void)
00750 {
00751   INKDATA* paInkData;
00752
00753   // NULL the pointer first and then delete the entire ink data array.
00754   paInkData = m_paInkData;
00755   m_paInkData = NULL;
00756   if (NULL != paInkData)
00757     delete [] paInkData;
00758
00759   return;
00760 }
00761
00762
00763 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00764   Method:   COPaper::CImpISharePaper::QueryInterface
00765
00766   Summary:  The QueryInterface IUnknown member of this ISharePaper
00767             interface implementation that delegates to m_pUnkOuter,
00768             whatever it is.
00769
00770   Args:     REFIID riid,
00771               [in] GUID of the Interface being requested.
00772             PPVOID ppv)
00773               [out] Address of the caller's pointer variable that will
00774               receive the requested interface pointer.
00775
00776   Returns:  HRESULT
00777               Standard result code. NOERROR for success.
00778               Returned by the delegated outer QueryInterface call.
00779 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00780 STDMETHODIMP COPaper::CImpISharePaper::QueryInterface(
00781                REFIID riid,
00782                PPVOID ppv)
00783 {
00784   // Delegate this call to the outer object's QueryInterface.
00785   return m_pUnkOuter->QueryInterface(riid, ppv);
00786 }
00787
00788
00789 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00790   Method:   COPaper::CImpISharePaper::AddRef
00791
00792   Summary:  The AddRef IUnknown member of this ISharePaper interface
00793             implementation that delegates to m_pUnkOuter, whatever it is.
00794
00795   Args:     void
00796
00797   Returns:  ULONG
00798               Returned by the delegated outer AddRef call.
00799 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00800 STDMETHODIMP_(ULONG) COPaper::CImpISharePaper::AddRef(void)
00801 {
00802   // Delegate this call to the outer object's AddRef.
00803   return m_pUnkOuter->AddRef();
00804 }
00805
00806
00807 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00808   Method:   COPaper::CImpISharePaper::Release
00809
00810   Summary:  The Release IUnknown member of this ISharePaper interface
00811             implementation that delegates to m_pUnkOuter, whatever it is.
00812
00813   Args:     void
00814
00815   Returns:  ULONG
00816               Returned by the delegated outer Release call.
00817 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00818 STDMETHODIMP_(ULONG) COPaper::CImpISharePaper::Release(void)
00819 {
00820   // Delegate this call to the outer object's Release.
00821   return m_pUnkOuter->Release();
00822 }
00823
00824
00825 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00826   Method:   COPaper::CImpISharePaper::InitPaper
00827
00828   Summary:  The InitPaper member method of the ISharePaper interface
00829             implementation. Called by outside clients of a COPaper object
00830             to initialize this shared electronic paper object.
00831
00832   Args:     RECT* pWinRect
00833               The initial drawing window rectangle. An [in,out] argument.
00834             BOOL* pbFirst
00835               A return value indicating TRUE if this the first client;
00836               FALSE otherwise. If FALSE caller should set its window
00837               size to the value pointed to by the returned *pWinRect.
00838
00839   Returns:  HRESULT
00840               Standard result code. NOERROR for success.
00841 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00842 STDMETHODIMP COPaper::CImpISharePaper::InitPaper(
00843                RECT* pWinRect,
00844                BOOL* pbFirst)
00845 {
00846   HRESULT hr = E_FAIL;
00847   INKDATA* paInkData;
00848   BOOL bFirst = (NULL == m_paInkData);
00849
00850   // Tell caller if this is first ink data array instance to Init.
00851   if (NULL != pbFirst)
00852     *pbFirst = bFirst;
00853
00854   if (OwnThis())
00855   {
00856     if (bFirst)
00857     {
00858       // Build the initial dynamic array of InkData.
00859       paInkData = new INKDATA[(LONG) INKDATA_ALLOC_INIT];
00860       if (NULL != paInkData)
00861       {
00862         // Zero the array.
00863         memset(paInkData, 0, INKDATA_ALLOC_INIT * sizeof(INKDATA));
00864
00865         // Rig this Paper object so that it can use the Ink Data array.
00866         m_lInkDataMax = INKDATA_ALLOC_INIT;
00867         m_paInkData = paInkData;
00868
00869         // Zero the Paper Properties structure. Init the ink data version.
00870         memset(&m_PaperProperties, 0, sizeof(PAPER_PROPERTIES));
00871         m_PaperProperties.lInkDataVersion = INKDATA_VERSION10;
00872
00873         // Register a clipboard format for these COPaper things.
00874         m_ClipBdFmt = RegisterClipboardFormat(TEXT(CLIPBDFMT_STR));
00875
00876         // Assign window rect values from master client.
00877         m_WinRect.left = 0;
00878         m_WinRect.top = 0;
00879         m_WinRect.right = pWinRect->right;
00880         m_WinRect.bottom = pWinRect->bottom;
00881         m_PaperProperties.WinRect.right = m_WinRect.right;
00882         m_PaperProperties.WinRect.bottom = m_WinRect.bottom;
00883         hr = NOERROR;
00884       }
00885       else
00886         hr = E_OUTOFMEMORY;
00887     }
00888     else
00889     {
00890       // If not the first init, assign slave client's output rect values.
00891       pWinRect->left = m_WinRect.left = 0;
00892       pWinRect->top = m_WinRect.top = 0;
00893       pWinRect->right = m_WinRect.right = m_PaperProperties.WinRect.right;
00894       pWinRect->bottom = m_WinRect.bottom = m_PaperProperties.WinRect.bottom;
00895       hr = NOERROR;
00896     }
00897
00898     UnOwnThis();
00899   }
00900
00901   return hr;
00902 }
00903
00904
00905 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00906   Method:   COPaper::CImpISharePaper::Lock
00907
00908   Summary:  The Lock member method of the ISharePaper interface
00909             implementation. Called by outside clients of a COPaper object
00910             to lock their ownership of the Paper object. COPaper is coded
00911             for eventual use in a multi-threaded multi- client situation
00912             where the Lock and Unlock methods permit a client to lock its
00913             use of a single COPaper object.
00914
00915   Args:     SHORT* pnLockKey
00916               Address of a short variable to receive the LockKey.
00917
00918   Returns:  HRESULT
00919               Standard result code. NOERROR for success.
00920 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00921 STDMETHODIMP COPaper::CImpISharePaper::Lock(
00922                BOOL bLock)
00923 {
00924   HRESULT hr = E_FAIL;
00925
00926   if (OwnThis())
00927   {
00928     if (bLock)
00929     {
00930       if (!m_bLocked)
00931       {
00932         // If the paper is not currently locked then lock it.
00933         m_bLocked = TRUE;
00934         hr = NOERROR;
00935       }
00936     }
00937     else
00938     {
00939       if (m_bLocked)
00940       {
00941         // If the paper is currently locked then set to unlocked state.
00942         m_bLocked = FALSE;
00943         hr = NOERROR;
00944       }
00945     }
00946
00947     UnOwnThis();
00948   }
00949
00950   // Notify all other connected clients that Paper is now locked/unlocked.
00951   if (SUCCEEDED(hr))
00952   {
00953     if (bLock)
00954       m_pCO->NotifySinks(PAPER_EVENT_LOCKED, 0, 0, 0, 0);
00955     else
00956       m_pCO->NotifySinks(PAPER_EVENT_UNLOCKED, 0, 0, 0, 0);
00957   }
00958
00959   return hr;
00960 }
00961
00962
00963 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00964   Method:   COPaper::CImpISharePaper::Load
00965
00966   Summary:  The Load member method of the ISharePaper interface
00967             implementation. Called by outside clients of a COPaper object
00968             to Load a new set of ink drawing data onto the Paper surface
00969             from the current structured storage compound file. Notifies
00970             all other connected clients when the load is complete.
00971
00972   Args:     RECT* pWinRect)
00973               [out] Pointer to RECT that receives the loaded window rect.
00974
00975   Returns:  HRESULT
00976               Standard result code. NOERROR for success.
00977 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00978 STDMETHODIMP COPaper::CImpISharePaper::Load(
00979                RECT* pWinRect)
00980 {
00981   HRESULT hr = E_FAIL;
00982   IStorage* pIStorage;
00983   IStream* pIStream;
00984   INKDATA* paInkData;
00985   ULONG ulToRead, ulReadIn;
00986   LONG lNewArraySize;
00987   PAPER_PROPERTIES NewProps;
00988
00989   if (OwnThis())
00990   {
00991     if (m_bLocked)
00992     {
00993       // Use COM service to next check if the file is there and actually
00994       // a valid compound file.
00995       hr = StgIsStorageFile(m_pCO->m_szPapFile);
00996       if (SUCCEEDED(hr))
00997       {
00998         // We're go. Use COM service to open the compound file and
00999         // obtain a IStorage interface.
01000         hr = StgOpenStorage(
01001                m_pCO->m_szPapFile,
01002                NULL,
01003                STGM_DIRECT | STGM_READ | STGM_SHARE_EXCLUSIVE,
01004                NULL,
01005                0,
01006                &pIStorage);
01007         if (SUCCEEDED(hr))
01008         {
01009           // Open the "PAPERDATA" stream where the paper data is stored.
01010           hr = pIStorage->OpenStream(
01011                  STREAM_PAPERDATA_USTR,
01012                  0,
01013                  STGM_READ | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
01014                  0,
01015                  &pIStream);
01016           if (SUCCEEDED(hr))
01017           {
01018             // We have the paper data stream. First read the Paper
01019             // Properties.
01020             ulToRead = sizeof(PAPER_PROPERTIES);
01021             hr = pIStream->Read(
01022                              &NewProps,
01023                              ulToRead,
01024                              &ulReadIn);
01025             if (SUCCEEDED(hr) && ulToRead != ulReadIn)
01026               hr = E_FAIL;
01027             if (SUCCEEDED(hr))
01028             {
01029               // Deal with the different versions of ink data format.
01030               switch (NewProps.lInkDataVersion)
01031               {
01032                 case INKDATA_VERSION10:
01033                   // Allocate an ink data array big enough--add some
01034                   // extra for user drawing.
01035                   lNewArraySize = NewProps.lInkArraySize + INKDATA_ALLOC;
01036                   paInkData = new INKDATA[(LONG) lNewArraySize];
01037                   if (NULL != paInkData)
01038                   {
01039                     // Delete the entire old ink data array.
01040                     delete [] m_paInkData;
01041
01042                     // Assign the new array.
01043                     m_paInkData = paInkData;
01044                     m_lInkDataMax = lNewArraySize;
01045
01046                     // Now read the complete array of Ink Data.
01047                     ulToRead = NewProps.lInkArraySize * sizeof(INKDATA);
01048                     hr = pIStream->Read(m_paInkData, ulToRead, &ulReadIn);
01049                     if (SUCCEEDED(hr) && ulToRead != ulReadIn)
01050                       hr = E_FAIL;
01051                     if (SUCCEEDED(hr))
01052                     {
01053                       // Rig COPaper to use the PAPER_PROPERTIES info.
01054                       m_lInkDataEnd = NewProps.lInkArraySize-1;
01055                       m_crWinColor = NewProps.crWinColor;
01056                       m_WinRect.right = NewProps.WinRect.right;
01057                       m_WinRect.bottom = NewProps.WinRect.bottom;
01058
01059                       // Copy the newly loaded drawing's window rectangle
01060                       // size for use by the caller.
01061                       pWinRect->left = NewProps.WinRect.left;
01062                       pWinRect->top = NewProps.WinRect.top;
01063                       pWinRect->right = NewProps.WinRect.right;
01064                       pWinRect->bottom = NewProps.WinRect.bottom;
01065
01066                       // Copy the new properties into current properties.
01067                       memcpy(
01068                         &m_PaperProperties,
01069                         &NewProps,
01070                         sizeof(PAPER_PROPERTIES));
01071                     }
01072                   }
01073                   else
01074                     hr = E_OUTOFMEMORY;
01075                   break;
01076                 default:
01077                   hr = E_FAIL;  // Bad version.
01078                   break;
01079               }
01080             }
01081
01082             // We are done with the stream so release it.
01083             pIStream->Release();
01084           }
01085
01086           // We are done with the storage so release it.
01087           // We don't hold the file open. We reopen it as needed.
01088           pIStorage->Release();
01089         }
01090       }
01091       else
01092       {
01093         // Erase();
01094         hr = Save();
01095       }
01096     }
01097
01098     UnOwnThis();
01099   }
01100
01101   // Notify all other connected clients that Paper is now loaded.
01102   // If we didn't load then erase to a safe, empty ink data array.
01103   if (SUCCEEDED(hr))
01104     m_pCO->NotifySinks(PAPER_EVENT_LOADED, 0, 0, 0, 0);
01105   else
01106     Erase();
01107
01108   return hr;
01109 }
01110
01111
01112 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01113   Method:   COPaper::CImpISharePaper::Save
01114
01115   Summary:  The Save member method of the ISharePaper interface
01116             implementation. Called by outside clients of a COPaper object
01117             to Save the current set of ink drawing data from the Paper
01118             surface to the current compound file storage. Notifies all
01119             other connected clients when the save is complete.
01120
01121   Args:     void.
01122
01123   Returns:  HRESULT
01124               Standard result code. NOERROR for success.
01125 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01126 STDMETHODIMP COPaper::CImpISharePaper::Save(
01127                void)
01128 {
01129   HRESULT hr = E_FAIL;
01130   IStorage* pIStorage;
01131   IStream* pIStream;
01132   ULONG ulToWrite, ulWritten;
01133
01134   if (OwnThis())
01135   {
01136     if (m_bLocked)
01137     {
01138       // Use COM service to re-open (or newly create) the compound file.
01139       hr = StgCreateDocfile(
01140              m_pCO->m_szPapFile,
01141              STGM_CREATE | STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
01142              0,
01143              &pIStorage);
01144       if (SUCCEEDED(hr))
01145       {
01146         // First use COM service to mark this compound file as one that is
01147         // handled by our server component, SharePaper.
01148         WriteClassStg(pIStorage, CLSID_SharePaper);
01149
01150         // Use COM Service to write user-readable clipboard format into
01151         // the compound file.
01152         WriteFmtUserTypeStg(pIStorage, m_ClipBdFmt, TEXT(CLIPBDFMT_STR));
01153
01154         // Create the stream to be used for the actual paper data.
01155         // Call it "PAPERDATA".
01156         hr = pIStorage->CreateStream(
01157                STREAM_PAPERDATA_USTR,
01158                STGM_CREATE | STGM_WRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
01159                0,
01160                0,
01161                &pIStream);
01162         if (SUCCEEDED(hr))
01163         {
01164           // Got a stream. Now write data into it.
01165           // First write PAPER_PROPERTIES structure.
01166           m_PaperProperties.lInkArraySize = m_lInkDataEnd+1;
01167           m_PaperProperties.crWinColor = m_crWinColor;
01168           m_PaperProperties.WinRect.right = m_WinRect.right;
01169           m_PaperProperties.WinRect.bottom = m_WinRect.bottom;
01170           ulToWrite = sizeof(PAPER_PROPERTIES);
01171           hr = pIStream->Write(&m_PaperProperties, ulToWrite, &ulWritten);
01172           if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01173             hr = STG_E_CANTSAVE;
01174           if (SUCCEEDED(hr))
01175           {
01176             // Now write the complete array of Ink Data.
01177             ulToWrite = m_PaperProperties.lInkArraySize * sizeof(INKDATA);
01178             hr = pIStream->Write(m_paInkData, ulToWrite, &ulWritten);
01179             if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01180               hr = STG_E_CANTSAVE;
01181           }
01182
01183           // We are done with the stream so release it.
01184           pIStream->Release();
01185         }
01186
01187         // We are done with the storage so release it.
01188         // We don't hold the file open. We reopen it as needed.
01189         pIStorage->Release();
01190       }
01191     }
01192
01193     UnOwnThis();
01194   }
01195
01196   // Notify all other connected clients that Paper is now saved.
01197   if (SUCCEEDED(hr))
01198     m_pCO->NotifySinks(PAPER_EVENT_SAVED, 0, 0, 0, 0);
01199
01200   return hr;
01201 }
01202
01203
01204 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01205   Method:   COPaper::CImpISharePaper::NextSlot
01206
01207   Summary:  An internal private utility member method to increment to the
01208             next slot in the dynamic Ink Data array. NextSlot will expand
01209             the dynamic array for more entries if needed. To guarantee
01210             thread safety, this private method should always be called
01211             within the protection of a bracketed OwnThis, UnOwnThis pair.
01212
01213   Args:     void
01214
01215   Modifies: m_lInkDataEnd, m_lInkDataMax, m_paInkData.
01216
01217   Returns:  HRESULT
01218               Standard result code. NOERROR for success.
01219 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01220 HRESULT COPaper::CImpISharePaper::NextSlot(
01221                                void)
01222 {
01223   HRESULT hr = NOERROR;
01224   LONG lInkDataEnd = m_lInkDataEnd + 1;
01225   INKDATA* paInkData;
01226
01227   if (lInkDataEnd >= m_lInkDataMax)
01228   {
01229     // No more room in Ink Data array. Allocate new space.
01230     paInkData = new INKDATA[(LONG) (m_lInkDataMax + INKDATA_ALLOC)];
01231     if (NULL != paInkData)
01232     {
01233       // Copy the content of the old full array to the new larger array.
01234       memcpy(paInkData, m_paInkData, lInkDataEnd * sizeof(INKDATA));
01235
01236       // Zero (& mark as empty) the expanded portion of the new array.
01237       memset(&paInkData[lInkDataEnd], 0, INKDATA_ALLOC * sizeof(INKDATA));
01238
01239       // New larger array is ready--delete the old array.
01240       delete [] m_paInkData;
01241
01242       // Rig the to use the new larger array.
01243       m_paInkData = paInkData;
01244
01245       // Calculate the new max index.
01246       m_lInkDataMax += INKDATA_ALLOC;
01247     }
01248     else
01249       hr = E_OUTOFMEMORY;
01250   }
01251
01252   if (SUCCEEDED(hr))
01253     m_lInkDataEnd = lInkDataEnd;
01254
01255   return hr;
01256 }
01257
01258
01259 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01260   Method:   COPaper::CImpISharePaper::InkStart
01261
01262   Summary:  The InkStart member method of the ISharePaper interface
01263             implementation. Called by outside clients of a COPaper object
01264             to start an ink drawing sequence.
01265
01266   Args:     SHORT nX,
01267               The X coordinate of the ink point.
01268             SHORT nY,
01269               The Y coordinate of the ink point.
01270             SHORT nInkWidth,
01271               The width of the ink in pixels.
01272             COLORREF crInkColor);
01273               The new ink color--an RGB COLORREF color.
01274
01275   Returns:  HRESULT
01276               Standard result code. NOERROR for success.
01277 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01278 STDMETHODIMP COPaper::CImpISharePaper::InkStart(
01279                SHORT nX,
01280                SHORT nY,
01281                SHORT nInkWidth,
01282                COLORREF crInkColor)
01283 {
01284   HRESULT hr = E_FAIL;
01285
01286   if (OwnThis())
01287   {
01288     if (m_bLocked)
01289     {
01290       hr = NextSlot();
01291       if (SUCCEEDED(hr))
01292       {
01293         // Add the new item to the Ink Data Array.
01294         m_paInkData[m_lInkDataEnd].nType = INKTYPE_START;
01295         m_paInkData[m_lInkDataEnd].nX = nX;
01296         m_paInkData[m_lInkDataEnd].nY = nY;
01297         m_paInkData[m_lInkDataEnd].nWidth = nInkWidth;
01298         m_paInkData[m_lInkDataEnd].crColor = crInkColor;
01299         m_nInkWidth = nInkWidth;
01300         m_crInkColor = crInkColor;
01301         m_pCO->NotifySinks(
01302           PAPER_EVENT_INKSTART,
01303           nX,
01304           nY,
01305           nInkWidth,
01306           crInkColor);
01307       }
01308     }
01309
01310     UnOwnThis();
01311   }
01312
01313   return hr;
01314 }
01315
01316
01317 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01318   Method:   COPaper::CImpISharePaper::InkDraw
01319
01320   Summary:  The InkDraw member method of the ISharePaper interface
01321             implementation. Called by outside clients of a COPaper object
01322             to "draw" ink data into an inking sequence.
01323
01324   Args:     SHORT nX,
01325               The X coordinate of the ink point.
01326             SHORT nY,
01327               The Y coordinate of the ink point.
01328
01329   Returns:  HRESULT
01330               Standard result code. NOERROR for success.
01331 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01332 STDMETHODIMP COPaper::CImpISharePaper::InkDraw(
01333                SHORT nX,
01334                SHORT nY)
01335 {
01336   HRESULT hr = E_FAIL;
01337
01338   if (OwnThis())
01339   {
01340     if (m_bLocked)
01341     {
01342       hr = NextSlot();
01343       if (SUCCEEDED(hr))
01344       {
01345         // Add the new item to the Ink Data Array.
01346         m_paInkData[m_lInkDataEnd].nType = INKTYPE_DRAW;
01347         m_paInkData[m_lInkDataEnd].nX = nX;
01348         m_paInkData[m_lInkDataEnd].nY = nY;
01349         m_paInkData[m_lInkDataEnd].nWidth = m_nInkWidth;
01350         m_paInkData[m_lInkDataEnd].crColor = m_crInkColor;
01351         m_pCO->NotifySinks(PAPER_EVENT_INKDRAW, nX, nY, 0, 0);
01352       }
01353     }
01354
01355     UnOwnThis();
01356   }
01357
01358   return hr;
01359 }
01360
01361
01362 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01363   Method:   COPaper::CImpISharePaper::InkStop
01364
01365   Summary:  The InkStop member method of the ISharePaper interface
01366             implementation. Called by outside clients of a COPaper object
01367             to stop the current ink drawing sequence.
01368
01369   Args:     SHORT nX,
01370               The X coordinate of the ink point.
01371             SHORT nY,
01372               The Y coordinate of the ink point.
01373
01374   Returns:  HRESULT
01375               Standard result code. NOERROR for success.
01376 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01377 STDMETHODIMP COPaper::CImpISharePaper::InkStop(
01378                SHORT nX,
01379                SHORT nY)
01380 {
01381   HRESULT hr = E_FAIL;
01382
01383   if (OwnThis())
01384   {
01385     if (m_bLocked)
01386     {
01387       hr = NextSlot();
01388       if (SUCCEEDED(hr))
01389       {
01390         // Add the new item to the Ink Data Array.
01391         m_paInkData[m_lInkDataEnd].nType = INKTYPE_STOP;
01392         m_paInkData[m_lInkDataEnd].nX = nX;
01393         m_paInkData[m_lInkDataEnd].nY = nY;
01394         m_paInkData[m_lInkDataEnd].nWidth = m_nInkWidth;
01395         m_paInkData[m_lInkDataEnd].crColor = m_crInkColor;
01396         m_pCO->NotifySinks(PAPER_EVENT_INKSTOP, nX, nY, 0, 0);
01397       }
01398     }
01399
01400     UnOwnThis();
01401   }
01402
01403   return hr;
01404 }
01405
01406
01407 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01408   Method:   COPaper::CImpISharePaper::GetInk
01409
01410   Summary:  The GetInk member method of the ISharePaper interface
01411             implementation. Called by outside clients of a COPaper object
01412             to obtain all content of the ink data array for redisplay.
01413
01414   Args:     LONG iIndex
01415               Array index starting at 0.
01416             SHORT* pnInkType,
01417               Address of the type of the ink item.
01418             SHORT* pnX,
01419               Address of the The X coordinate of the ink point.
01420             SHORT* pnY,
01421               Address of the The Y coordinate of the ink point.
01422             SHORT* pnInkWidth,
01423               Address of the width of the ink in pixels.
01424             COLORREF* pcrInkColor)
01425               Address of the new ink color--an RGB COLORREF color.
01426
01427   Returns:  HRESULT
01428               Standard result code. NOERROR for success. E_FAIL when
01429               no ink data for the index.
01430 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01431 STDMETHODIMP COPaper::CImpISharePaper::GetInk(
01432                LONG iIndex,
01433                SHORT* pnInkType,
01434                SHORT* pnX,
01435                SHORT* pnY,
01436                SHORT* pnInkWidth,
01437                COLORREF* pcrInkColor)
01438 {
01439   HRESULT hr = NOERROR;
01440
01441   if (OwnThis())
01442   {
01443     if (iIndex < m_lInkDataEnd+1)
01444     {
01445       *pnInkType = m_paInkData[iIndex].nType;
01446       *pnX = m_paInkData[iIndex].nX;
01447       *pnY = m_paInkData[iIndex].nY;
01448       *pnInkWidth = m_paInkData[iIndex].nWidth;
01449       *pcrInkColor = m_paInkData[iIndex].crColor;
01450     }
01451     else
01452       hr = E_FAIL;
01453
01454     UnOwnThis();
01455   }
01456
01457   return hr;
01458 }
01459
01460
01461 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01462   Method:   COPaper::CImpISharePaper::Erase
01463
01464   Summary:  The Erase member method of the ISharePaper interface
01465             implementation. Called by outside clients of a COPaper object
01466             to erase the drawn ink content of the paper object. Notifies
01467             all connected clients of the event.
01468
01469   Args:     void.
01470
01471   Returns:  HRESULT
01472               Standard result code. NOERROR for success.
01473 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01474 STDMETHODIMP COPaper::CImpISharePaper::Erase(
01475                void)
01476 {
01477   HRESULT hr = E_FAIL;
01478   LONG i;
01479
01480   if (OwnThis())
01481   {
01482     if (m_bLocked)
01483     {
01484       if (m_lInkDataEnd > 0 && NULL != m_paInkData)
01485       {
01486         // Loop thru the current Ink Data array and mark each
01487         // item as erased.
01488         for (i=0; i<m_lInkDataMax; i++)
01489           m_paInkData[i].nType = INKTYPE_NONE;
01490
01491         // Reset the Ink Data End index to 0.
01492         m_lInkDataEnd = 0;
01493         hr = NOERROR;
01494       }
01495     }
01496
01497     UnOwnThis();
01498   }
01499
01500   // Notify all other connected clients of the erase.
01501   if (SUCCEEDED(hr))
01502     m_pCO->NotifySinks(PAPER_EVENT_ERASED, 0, 0, 0, 0);
01503
01504   return hr;
01505 }
01506
01507
01508 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01509   Method:   COPaper::CImpISharePaper::Resize
01510
01511   Summary:  The Resize member method of the ISharePaper interface
01512             implementation. Called by outside clients of a COPaper object
01513             to resize the drawing rectangle of the paper object. Notifies
01514             all connected clients of the event and passes them the new
01515             rectangle size.
01516
01517   Args:     LONG lWidth,
01518               The new rectangle width in pixels.
01519             LONG lHeight
01520               The new rectangle height in pixels.
01521
01522   Returns:  HRESULT
01523               Standard result code. NOERROR for success.
01524 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01525 STDMETHODIMP COPaper::CImpISharePaper::Resize(
01526                LONG lWidth,
01527                LONG lHeight)
01528 {
01529   HRESULT hr = E_FAIL;
01530
01531   if (OwnThis())
01532   {
01533     if (m_bLocked)
01534     {
01535       m_WinRect.top = 0;
01536       m_WinRect.left = 0;
01537       m_WinRect.right = lWidth;
01538       m_WinRect.bottom = lHeight;
01539       m_PaperProperties.WinRect.top = 0;
01540       m_PaperProperties.WinRect.left = 0;
01541       m_PaperProperties.WinRect.right = lWidth;
01542       m_PaperProperties.WinRect.bottom = lHeight;
01543       hr = NOERROR;
01544     }
01545
01546     UnOwnThis();
01547   }
01548
01549   // Notify all other connected clients of the resize.
01550   if (SUCCEEDED(hr))
01551     m_pCO->NotifySinks(
01552              PAPER_EVENT_RESIZED,
01553              (SHORT)lWidth,
01554              (SHORT)lHeight,
01555              0,
01556              0);
01557
01558   return hr;
01559 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/Serialization/AssemblyInfo.cs Source File

  • TabletPC
  • Serialization

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("Serialization Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2003 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 //[assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 // [assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletRoster Member List

This is the complete list of members for tagAppletRoster, including all inherited members.
apAppletRecords | tagAppletRoster
apCapabilities | tagAppletRoster
cCapabilities | tagAppletRoster
cRecords | tagAppletRoster
fCapabilitiesChanged | tagAppletRoster
fNodesAdded | tagAppletRoster
fNodesRemoved | tagAppletRoster
fRosterChanged | tagAppletRoster
nInstanceNumber | tagAppletRoster
SessionKey | tagAppletRoster
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/dataobj.h Source File

  • SysMgmt
  • MMC
  • Openserv

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ParameterAttributesEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ParameterAttributesEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ParameterAttributesEnum
00019
00020 public class ParameterAttributesEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adParamSigned = 16;
00023   public static final short adParamNullable = 64;
00024   public static final short adParamLong = 128;
00025 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSecuritySub Member List

This is the complete list of members for CSecuritySub, including all inherited members.
CSecuritySub() | CSecuritySub | [inline]
CSecuritySub(CComSpy *pSpy) | CSecuritySub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetDomainSlashUser(PSID Sid, WCHAR *DomainSlashUser) | CSecuritySub | [inline]
GetEventClass(LPGUID guid) | CSecuritySub | [inline, virtual]
GetEventType(EventEnum *e) | CSecuritySub | [inline, virtual]
GetInterface(IID *iid) | CSecuritySub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnAuthenticate(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, ULONG64 ObjectID, REFGUID guidIID, ULONG iMeth, ULONG cbByteOrig, BYTE *pSidOriginalUser, ULONG cbByteCur, BYTE *pSidCurrentUser, BOOL bCurrentUserInpersonatingInProc) | CSecuritySub | [inline]
OnAuthenticateFail(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, ULONG64 ObjectID, REFGUID guidIID, ULONG iMeth, ULONG cbByteOrig, BYTE *pSidOriginalUser, ULONG cbByteCur, BYTE *pSidCurrentUser, BOOL bCurrentUserInpersonatingInProc) | CSecuritySub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:57:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/land.Cpp Source File

  • SysMgmt
  • MMC
  • Proppage

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/SimpleClient/WbemClient.h Source File

  • SysMgmt
  • WMI
  • VC
  • SimpleClient

WbemClient.h

Go to the documentation of this file.
00001 // WbemClient.h : main header file for the WBEMCLIENT application
00002
00003 //
00004
00005 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00006
00007 #if !defined(AFX_WBEMCLIENT_H__4C1DEDF7_F003_11D1_BDD8_00C04F8F8B8D__INCLUDED_)
00008 #define AFX_WBEMCLIENT_H__4C1DEDF7_F003_11D1_BDD8_00C04F8F8B8D__INCLUDED_
00009
00010 #if _MSC_VER >= 1000
00011 #pragma once
00012 #endif // _MSC_VER >= 1000
00013
00014 #ifndef __AFXWIN_H__
00015   #error include 'stdafx.h' before including this file for PCH
00016 #endif
00017
00018 #include "resource.h"   // main symbols
00019
00020 /////////////////////////////////////////////////////////////////////////////
00021 // CWbemClientApp:
00022 // See WbemClient.cpp for the implementation of this class
00023 //
00024
00025 class CWbemClientApp : public CWinApp
00026 {
00027 public:
00028   CWbemClientApp();
00029
00030   bool InitSecurity();
00031
00032 // Overrides
00033   // ClassWizard generated virtual function overrides
00034   //{{AFX_VIRTUAL(CWbemClientApp)
00035   public:
00036   virtual BOOL InitInstance();
00037   //}}AFX_VIRTUAL
00038
00039 // Implementation
00040
00041   //{{AFX_MSG(CWbemClientApp)
00042     // NOTE - the ClassWizard will add and remove member functions here.
00043     //    DO NOT EDIT what you see in these blocks of generated code !
00044   //}}AFX_MSG
00045   DECLARE_MESSAGE_MAP()
00046 };
00047
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050
00051 //{{AFX_INSERT_LOCATION}}
00052 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00053
00054 #endif // !defined(AFX_WBEMCLIENT_H__4C1DEDF7_F003_11D1_BDD8_00C04F8F8B8D__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/DiskQuota/PrintMenu.h Source File

  • WinBase
  • IO
  • DiskQuota

PrintMenu.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 PrintMenu.h
00011
00012 Description:
00013 Prototypes for functions used to print out the menus
00014
00015 ----------------------------------------------------------------------------*/
00016
00017 #if !defined (_PRINT_MENU_H_)
00018 #define _PRINT_MENU_H_
00019
00020 WCHAR PrintMainMenu();
00021 WCHAR PrintDefaultQuotaMenu();
00022 WCHAR PrintQuotaLogFlagMenu();
00023 WCHAR PrintDefaultLimitsMenu();
00024 WCHAR PrintUserManagerMenu();
00025 WCHAR PrintQuotaManagerMenu();
00026
00027 #endif /* _PRINT_MENU_H_ */
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/rtcsample/StdAfx.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • rtcsample

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
00007 #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013 // Exclude rarely-used stuff from Windows headers
00014 #ifndef WIN32_LEAN_AND_MEAN
00015 #define WIN32_LEAN_AND_MEAN
00016 #endif
00017
00018 // Uses Unicode character set
00019 #ifndef UNICODE
00020 #define UNICODE
00021 #endif
00022
00023 #ifndef _UNICODE
00024 #define _UNICODE
00025 #endif
00026
00027 // Application window defaults
00028 #define APP_TITLE L"RTC Sample"
00029 #define APP_CLASS L"RTCAPP"
00030 #define APP_WIDTH  250
00031 #define APP_HEIGHT 400
00032
00033 // IM window defaults
00034 #define IM_TITLE  L"RTC Message"
00035 #define IM_CLASS  L"RTCIM"
00036 #define IM_WIDTH   400
00037 #define IM_HEIGHT  400
00038
00039 // Audio/Video window defaults
00040 #define AV_TITLE  L"RTC Audio/Video Call"
00041 #define AV_CLASS  L"RTCAV"
00042 #define AV_WIDTH   250
00043 #define AV_HEIGHT  355
00044
00045 // String constants
00046 #define MAX_STRING 256
00047 #define MAX_XML_STRING 4096
00048
00049 // Video size constants
00050 #define QCIF_CX_SIZE  176
00051 #define QCIF_CY_SIZE  144
00052 #define QQCIF_CX_SIZE (QCIF_CX_SIZE/2)
00053 #define QQCIF_CY_SIZE (QCIF_CY_SIZE/2)
00054
00055 // Helper macros
00056 #define SAFE_RELEASE(x) {if(x){(x)->Release();(x)=NULL;}}
00057 #define SAFE_FREE_STRING(x) {if(x){SysFreeString(x);(x)=NULL;}}
00058
00059 // Includes
00060 #include <windows.h>
00061 #include <stdio.h>
00062 #include <commctrl.h>
00063 #include <richedit.h>
00064 #include <tchar.h>
00065 #include <rtccore.h>
00066 #include <rtcerr.h>
00067 #include <string.h>
00068 #include <vector>
00069
00070 #include "rtcwin.h"
00071 #include "rtcevents.h"
00072 #include "rtcdialogs.h"
00073 #include "rtcsession.h"
00074 #include "rtcim.h"
00075 #include "rtcav.h"
00076 #include "resource.h"
00077
00078 //{{AFX_INSERT_LOCATION}}
00079 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00080
00081 #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • Help

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030   static TCHAR error[64];
00031
00032   switch (verb) {
00033     case MMC_VERB_NONE:
00034     return _T("NONE");
00035     case MMC_VERB_OPEN:
00036     return _T("OPEN");
00037     case MMC_VERB_COPY:
00038     return _T("COPY");
00039     case MMC_VERB_PASTE:
00040     return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042     return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044     return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046     return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048     return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050     return _T("PRINT");
00051     case MMC_VERB_CUT:
00052     return _T("CUT");
00053   default:
00054     wsprintf(error, _T("Unknown verb id %d"), verb);
00055     return error;
00056   }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061         IComponentData *pCompData,
00062         IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064         LPARAM arg,
00065         LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069   TCHAR message[cchMessage] = {0};
00070
00071   if (bComponentData == TRUE)
00072     OutputDebugString(_T("IComponentData::Notify( "));
00073   else
00074     OutputDebugString(_T("IComponent::Notify( "));
00075
00076   wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077   OutputDebugString(message);
00078
00079     switch (event)  {
00080     case MMCN_ACTIVATE:
00081       wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082       break;
00083
00084     case MMCN_ADD_IMAGES:
00085       wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086       break;
00087
00088     case MMCN_BTN_CLICK:
00089       wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090       break;
00091
00092     case MMCN_COLUMN_CLICK:
00093       wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,   param);
00094       break;
00095
00096     case MMCN_COLUMNS_CHANGED:
00097       wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098       break;
00099
00100     case MMCN_CONTEXTHELP:
00101       wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102       break;
00103
00104     case MMCN_CONTEXTMENU:
00105       wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106       break;
00107
00108     case MMCN_CUTORMOVE:
00109       wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110       break;
00111
00112     case MMCN_DBLCLICK:
00113       wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114       break;
00115
00116     case MMCN_DELETE:
00117       wsprintf(message, _T("MMCN_DELETE\n"));
00118       break;
00119
00120     case MMCN_DESELECT_ALL:
00121       wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122       break;
00123
00124     case MMCN_EXPAND:
00125       wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126       break;
00127
00128     case MMCN_EXPANDSYNC:
00129       wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130       break;
00131
00132     case MMCN_FILTERBTN_CLICK:
00133       wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134       break;
00135
00136     case MMCN_FILTER_CHANGE:
00137       wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138       break;
00139
00140     case MMCN_HELP:
00141       wsprintf(message, _T("MMCN_HELP\n"));
00142       break;
00143
00144     case MMCN_INITOCX:
00145       wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146       break;
00147
00148     case MMCN_LISTPAD:
00149       wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150       break;
00151
00152     case MMCN_MENU_BTNCLICK:
00153       wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154       break;
00155
00156     case MMCN_MINIMIZED:
00157       wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158       break;
00159
00160     case MMCN_PASTE:
00161       wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162       break;
00163
00164     case MMCN_PRELOAD:
00165       wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166       break;
00167
00168     case MMCN_PRINT:
00169       wsprintf(message, _T("MMCN_PRINT\n"));
00170       break;
00171
00172     case MMCN_PROPERTY_CHANGE:
00173       wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174       break;
00175
00176     case MMCN_QUERY_PASTE:
00177       wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178       break;
00179
00180     case MMCN_REFRESH:
00181       wsprintf(message, _T("MMCN_REFRESH\n"));
00182       break;
00183
00184     case MMCN_REMOVE_CHILDREN:
00185       wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186       break;
00187
00188     case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192       StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193       break;
00194
00195     case MMCN_RESTORE_VIEW:
00196       wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197       break;
00198
00199     case MMCN_SELECT:
00200       wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201       break;
00202
00203     case MMCN_SHOW:
00204       wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205       break;
00206
00207     case MMCN_SNAPINHELP:
00208       wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209       break;
00210
00211     case MMCN_VIEW_CHANGE:
00212       wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213       break;
00214   }
00215
00216   if (message[0] != 0)
00217     OutputDebugString(message);
00218   else
00219     OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222   return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/data.Cpp Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

data.Cpp

Go to the documentation of this file.
00001 // Data.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f Dataps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "Data.h"
00012
00013 #include "Data_i.c"
00014 #include "Entity.h"
00015 #include "Dynamic.h"
00016 #include "odbcdata.h"
00017 #include "Proxy.h"
00018 #include "Resultset.h"
00019
00020 CComModule _Module;
00021
00022 BEGIN_OBJECT_MAP(ObjectMap)
00023 OBJECT_ENTRY(CLSID_Proxy, CProxy)
00024 OBJECT_ENTRY(CLSID_Entity, CEntity)
00025 OBJECT_ENTRY(CLSID_Dynamic, CDynamic)
00026 OBJECT_ENTRY(CLSID_Resultset, CResultset)
00027 END_OBJECT_MAP()
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // DLL Entry Point
00031
00032 extern "C"
00033 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00034 {
00035     if (dwReason == DLL_PROCESS_ATTACH)
00036     {
00037         _Module.Init(ObjectMap, hInstance, &LIBID_DataServices);
00038         DisableThreadLibraryCalls(hInstance);
00039     LoadLibraryW(L"dbnmpntw.dll");
00040     LoadLibraryW(L"odbc32.dll");
00041     LoadLibraryW(L"sqlsrv32.dll");
00042     LoadLibraryW(L"nddeapi.dll");
00043     LoadLibraryW(L"winspool.drv");
00044     }
00045     else if (dwReason == DLL_PROCESS_DETACH)
00046   {
00047         _Module.Term();
00048   }
00049   _Module.Lock();
00050     return TRUE;    // ok
00051 }
00052
00053 /////////////////////////////////////////////////////////////////////////////
00054 // Used to determine whether the DLL can be unloaded by OLE
00055
00056 STDAPI DllCanUnloadNow(void)
00057 {
00058 //    return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00059   return S_FALSE;
00060 }
00061
00062 /////////////////////////////////////////////////////////////////////////////
00063 // Returns a class factory to create an object of the requested type
00064
00065 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00066 {
00067     return _Module.GetClassObject(rclsid, riid, ppv);
00068 }
00069
00070 /////////////////////////////////////////////////////////////////////////////
00071 // DllRegisterServer - Adds entries to the system registry
00072
00073 STDAPI DllRegisterServer(void)
00074 {
00075     // registers object, typelib and all interfaces in typelib
00076     return _Module.RegisterServer(TRUE);
00077 }
00078
00079 /////////////////////////////////////////////////////////////////////////////
00080 // DllUnregisterServer - Removes entries from the system registry
00081
00082 STDAPI DllUnregisterServer(void)
00083 {
00084     return _Module.UnregisterServer(TRUE);
00085 }
00086
00087
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CacheProxySamplePlugin::PlaylistItem Member List

This is the complete list of members for CacheProxySamplePlugin::PlaylistItem, including all inherited members.
CacheID | CacheProxySamplePlugin::PlaylistItem
CacheUrl | CacheProxySamplePlugin::PlaylistItem
CDLData | CacheProxySamplePlugin::PlaylistItem
Generated on Wed Nov 13 2024 16:58:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CADVCGENDlg Member List

This is the complete list of members for CADVCGENDlg, including all inherited members.
CADVCGENDlg(CWnd *pParent=NULL) | CADVCGENDlg |
conn | CADVCGENDlg |
connStr | CADVCGENDlg |
DataRefresh(BOOL bflag) | CADVCGENDlg |
dataRs | CADVCGENDlg |
DoDataExchange(CDataExchange *pDX) | CADVCGENDlg | [protected, virtual]
hr | CADVCGENDlg |
IDD enum value | CADVCGENDlg |
m_DataGridDisplay | CADVCGENDlg |
m_hIcon | CADVCGENDlg | [protected]
m_SchemaInfo | CADVCGENDlg |
m_SQLEditBox | CADVCGENDlg |
m_TableListBox | CADVCGENDlg |
OnBuild() | CADVCGENDlg | [protected]
OnChangeTableList() | CADVCGENDlg | [protected]
OnExit() | CADVCGENDlg | [protected]
OnInitDialog() | CADVCGENDlg | [protected, virtual]
OnPaint() | CADVCGENDlg | [protected]
OnQueryDragIcon() | CADVCGENDlg | [protected]
OnSysCommand(UINT nID, LPARAM lParam) | CADVCGENDlg | [protected]
OnXecute() | CADVCGENDlg | [protected]
OutputIntoDataGrid(char *buffer) | CADVCGENDlg |
RestrictionsOnOpenSchema(_variant_t &restrictions, int lenCtr, _variant_t *criteriaValues) | CADVCGENDlg |
schemaRs | CADVCGENDlg |
VarToBstr(_variant_t varT) | CADVCGENDlg |
~CADVCGENDlg() | CADVCGENDlg |
Generated on Wed Nov 13 2024 16:55:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cstream.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cstream.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CSTREAM.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 //////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 ///////////////////////////////////////////////////////////////////////////////
00019 // Class CStream
00020 //
00021 ///////////////////////////////////////////////////////////////////////////////
00022 CStream::CStream(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CAsynchBase(eCStream, pCMainWindow, pCMDIChild)
00024 {
00025   //Storage Interfaces
00026   m_pISequentialStream  = NULL;
00027   m_pIStream        = NULL;
00028   m_pIStorage       = NULL;
00029   m_pILockBytes     = NULL;
00030
00031   //Data
00032   m_wType         = DBTYPE_STR;
00033 }
00034
00035
00036 ///////////////////////////////////////////////////////////////////////////////
00037 // ~CStream
00038 //
00039 ///////////////////////////////////////////////////////////////////////////////
00040 CStream::~CStream()
00041 {
00042   ReleaseObject(0);
00043 }
00044
00045
00046 /////////////////////////////////////////////////////////////////
00047 // IUnknown** CStream::GetInterfaceAddress
00048 //
00049 /////////////////////////////////////////////////////////////////
00050 IUnknown** CStream::GetInterfaceAddress(REFIID riid)
00051 {
00052   HANDLE_GETINTERFACE(ISequentialStream);
00053   HANDLE_GETINTERFACE(IStream);
00054   HANDLE_GETINTERFACE(IStorage);
00055   HANDLE_GETINTERFACE(ILockBytes);
00056
00057   //Otherwise delegate
00058   return CAsynchBase::GetInterfaceAddress(riid);
00059 }
00060
00061
00062 /////////////////////////////////////////////////////////////////
00063 // CStream::AutoRelease
00064 //
00065 /////////////////////////////////////////////////////////////////
00066 HRESULT CStream::AutoRelease()
00067 {
00068   //Stream
00069   RELEASE_INTERFACE(ISequentialStream);
00070   RELEASE_INTERFACE(IStream);
00071   RELEASE_INTERFACE(IStorage);
00072   RELEASE_INTERFACE(ILockBytes);
00073
00074   //Delegate
00075   return CAsynchBase::AutoRelease();
00076 }
00077
00078
00079 ////////////////////////////////////////////////////////////////
00080 // CStream::AutoQI
00081 //
00082 /////////////////////////////////////////////////////////////////
00083 HRESULT CStream::AutoQI(DWORD dwCreateOpts)
00084 {
00085   //Delegate First so we have base interfaces
00086   CAsynchBase::AutoQI(dwCreateOpts);
00087
00088   //[MANDATORY]
00089   if(dwCreateOpts & CREATE_QI_MANDATORY)
00090   {
00091     OBTAIN_INTERFACE(ISequentialStream);
00092   }
00093
00094   //AutoQI
00095   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00096   {
00097     //[OPTIONAL]
00098     OBTAIN_INTERFACE(IStream);
00099     OBTAIN_INTERFACE(IStorage);
00100     OBTAIN_INTERFACE(ILockBytes);
00101   }
00102
00103   return S_OK;
00104 }
00105
00106
00107
00108 ////////////////////////////////////////////////////////////////
00109 // CStream::OnDefOperation
00110 //
00111 /////////////////////////////////////////////////////////////////
00112 void CStream::OnDefOperation()
00113 {
00114   //Need to bring up the StreamViewer
00115   if(m_pCMainWindow)
00116   {
00117     UINT uID = IDM_ISEQSTREAM_READ;
00118
00119     //Determine which interface to use for reading.
00120     //Since the user just clicked on the object we have to guess which interface to use from those
00121     //that are available, and most functional...
00122     if(m_pIStream)
00123       uID = IDM_ISTREAM_READ;
00124
00125     //Display the Stream Viewer...
00126     //NOTE: This dialog could be displayed from numerous sources, either the execute dialog,
00127     //or directly from clicking on the stream - (ie: use GetFocus to determine the parent window)
00128     m_pCMainWindow->DisplayDialog(IDD_STREAM_VIEWER, GetFocus(), CMainWindow::StreamViewerProc, this, uID);
00129   }
00130 }
00131
00132
00133 /////////////////////////////////////////////////////////////////
00134 // CStream::DisplayObject
00135 //
00136 /////////////////////////////////////////////////////////////////
00137 HRESULT CStream::DisplayObject()
00138 {
00139   HRESULT hr = S_OK;
00140
00141   //Display the object...
00142   OnDefOperation();
00143
00144   //Delegate
00145   TESTC(hr = CAsynchBase::DisplayObject());
00146
00147 CLEANUP:
00148   return hr;
00149 }
00150
00151
00152 ////////////////////////////////////////////////////////////////
00153 // CStream::ReadBytes
00154 //
00155 /////////////////////////////////////////////////////////////////
00156 HRESULT CStream::ReadBytes(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, DBLENGTH cbMaxSize, void* pBuffer, DBLENGTH* pcbRead)
00157 {
00158   HRESULT hr = S_OK;
00159   BOOL  bUseDefault = FALSE;
00160
00161   ULONG cbRead = 0;
00162   cBytes = min(cBytes, cbMaxSize);
00163
00164   //Determine object type
00165   if(riid != IID_ISequentialStream && riid != IID_ILockBytes && riid != IID_IStream)
00166     bUseDefault = TRUE;
00167
00168   //IID_ISequentialStream
00169   if((riid == IID_ISequentialStream && m_pISequentialStream) || (bUseDefault && m_pISequentialStream))
00170   {
00171     //ISequentialStream::Read
00172     //TODO64:  I*::Read only takes a ULONG
00173     //NOTE: ::Read can post errorinfo objects in the case of warnings.  SQLOLEDB's XML Stream
00174     //object will post execution errors on the last read...
00175     XTEST_(hr = m_pISequentialStream->Read(pBuffer, (ULONG)cBytes, &cbRead),S_FALSE);
00176     TESTC(TRACE_METHOD(hr, L"ISequentialStream::Read(0x%p, %d, &%d)", pBuffer, cBytes, cbRead));
00177   }
00178   //IID_ILockBytes
00179   else if((riid == IID_ILockBytes && m_pILockBytes) || (bUseDefault && m_pILockBytes))
00180   {
00181     ULARGE_INTEGER ulgOffset;
00182     ulgOffset.QuadPart = ulOffset;
00183
00184     //ILockBytes::ReadAt
00185     //TODO64:  I*::Read only takes a ULONG
00186     XTEST_(hr = m_pILockBytes->ReadAt(ulgOffset, pBuffer, (ULONG)cBytes, &cbRead),S_FALSE);
00187     TESTC(TRACE_METHOD(hr, L"ILockBytes::ReadAt(%d, 0x%p, %d, &%d)", ulOffset, pBuffer, cBytes, cbRead));
00188   }
00189   //IID_IStream
00190   else if((riid == IID_IStream && m_pIStream) || (bUseDefault && m_pIStream))
00191   {
00192     //IStream::Read
00193     //TODO64:  I*::Read only takes a ULONG
00194     XTEST_(hr = m_pIStream->Read(pBuffer, (ULONG)cBytes, &cbRead),S_FALSE);
00195     TESTC(TRACE_METHOD(hr, L"IStream::Read(0x%p, %d, &%d)", pBuffer, cBytes, cbRead));
00196   }
00197 //  else if(m_pIStorage)
00198 //  {
00199     //TODO
00200 //  }
00201   else
00202   {
00203     TESTC(hr = E_FAIL);
00204   }
00205
00206 CLEANUP:
00207   if(pcbRead)
00208     *pcbRead = cbRead;
00209   return hr;
00210 }
00211
00212
00213 ////////////////////////////////////////////////////////////////
00214 // CStream::ReadString
00215 //
00216 /////////////////////////////////////////////////////////////////
00217 HRESULT CStream::ReadString(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, DBLENGTH ulMaxSize, WCHAR* pwszBuffer, DBLENGTH* pcbRead)
00218 {
00219   ASSERT(pwszBuffer);
00220   HRESULT hr = S_OK;
00221   pwszBuffer[0] = wEOL;
00222
00223   WCHAR pBuffer[MAX_COL_SIZE+1] = {0};
00224   DWORD dwConvFlags = GetOptions()->m_dwConvFlags;
00225
00226   DBLENGTH cbRead = 0;
00227   cBytes = min(min(sizeof(pBuffer), cBytes), ulMaxSize*sizeof(WCHAR));
00228
00229   //Delegate
00230   TESTC(hr = ReadBytes(riid, ulOffset, cBytes, ulMaxSize*sizeof(WCHAR), pBuffer, &cbRead));
00231
00232   //What type of data are we reading
00233   switch(m_wType)
00234   {
00235     case DBTYPE_WSTR:
00236     case DBTYPE_STR:
00237       //Add a NULL terminator on the end of the data before conversion
00238       //since the spec indicates the stream is not NULL terminated...
00239       //NOTE: We made sure we had a full extra WCHAR in the buffer ahead of time
00240       memset((BYTE*)pBuffer + min(cBytes, cbRead), 0, sizeof(WCHAR));
00241       cbRead += (m_wType == DBTYPE_WSTR) ? sizeof(WCHAR) : sizeof(CHAR);
00242       break;
00243   };
00244
00245   //Now that we have read the data, coerce it into a string for display purposes...
00246   XTESTC_(hr = DataConvert
00247     (
00248       DBSTATUS_S_OK,
00249       cbRead,
00250       sizeof(pBuffer),
00251       (m_wType == DBTYPE_WSTR || m_wType == DBTYPE_STR) ? m_wType : DBTYPE_BYTES,
00252       pBuffer,
00253       0,
00254       0,
00255
00256       DBTYPE_WSTR,
00257       NULL,
00258       NULL,
00259       pwszBuffer,
00260       ulMaxSize*sizeof(WCHAR),
00261       dwConvFlags
00262     ),S_OK);
00263
00264 CLEANUP:
00265   if(pcbRead)
00266     *pcbRead = cbRead;
00267   return hr;
00268 }
00269
00270
00271 ////////////////////////////////////////////////////////////////
00272 // CStream::WriteBytes
00273 //
00274 /////////////////////////////////////////////////////////////////
00275 HRESULT CStream::WriteBytes(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, void* pBuffer, DBLENGTH* pcbWritten)
00276 {
00277   HRESULT hr = S_OK;
00278   BOOL  bUseDefault = FALSE;
00279   ULONG cbWritten = 0;
00280
00281   //Determine object type
00282   if(riid != IID_ISequentialStream && riid != IID_ILockBytes && riid != IID_IStream)
00283     bUseDefault = TRUE;
00284
00285   //IID_ISequentialStream
00286   if((riid == IID_ISequentialStream && m_pISequentialStream) || (bUseDefault && m_pISequentialStream))
00287   {
00288     //ISequentialStream::Write
00289     //TODO64:  I*::Write only takes a ULONG
00290     XTEST(hr = m_pISequentialStream->Write(pBuffer, (ULONG)cBytes, &cbWritten));
00291     TESTC(TRACE_METHOD(hr, L"ISequentialStream::Write(0x%p, %d, &%d)", pBuffer, cBytes, cbWritten));
00292   }
00293   //IID_ILockBytes
00294   else if((riid == IID_ILockBytes && m_pILockBytes) || (bUseDefault && m_pILockBytes))
00295   {
00296     ULARGE_INTEGER ulgOffset;
00297     ulgOffset.QuadPart = ulOffset;
00298
00299     //ILockBytes::WriteAt
00300     //TODO64:  I*::Write only takes a ULONG
00301     XTEST(hr = m_pILockBytes->WriteAt(ulgOffset, pBuffer, (ULONG)cBytes, &cbWritten));
00302     TESTC(TRACE_METHOD(hr, L"ILockBytes::WriteAt(%d, 0x%p, %d, &%d)", ulOffset, pBuffer, cBytes, cbWritten));
00303   }
00304   //IID_IStream
00305   else if((riid == IID_IStream && m_pIStream) || (bUseDefault && m_pIStream))
00306   {
00307     //IStream::Write
00308     //TODO64:  I*::Write only takes a ULONG
00309     XTEST(hr = m_pIStream->Write(pBuffer, (ULONG)cBytes, &cbWritten));
00310     TESTC(TRACE_METHOD(hr, L"IStream::Write(0x%p, %d, &%d)", pBuffer, cBytes, cbWritten));
00311   }
00312 //  else if(m_pIStorage)
00313 //  {
00314     //TODO
00315 //  }
00316   else
00317   {
00318     TESTC(hr = E_FAIL);
00319   }
00320
00321 CLEANUP:
00322   if(pcbWritten)
00323     *pcbWritten = cbWritten;
00324   return hr;
00325 }
00326
00327
00328 ////////////////////////////////////////////////////////////////
00329 // CStream::WriteString
00330 //
00331 /////////////////////////////////////////////////////////////////
00332 HRESULT CStream::WriteString(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, WCHAR* pwszBuffer, DBLENGTH* pcbWritten)
00333 {
00334   HRESULT hr = S_OK;
00335   WCHAR pBuffer[MAX_COL_SIZE] = {0};
00336   DWORD dwConvFlags = GetOptions()->m_dwConvFlags;
00337
00338   DBLENGTH cbWritten = 0;
00339   cBytes = min(sizeof(pBuffer), cBytes);
00340
00341   //First Convert the user entered data into the backend format...
00342   //So the stream is a native stream of bytes to set into the backend...
00343   XTESTC_(hr = DataConvert
00344     (
00345       DBSTATUS_S_OK,
00346       cBytes,
00347       cBytes + sizeof(WCHAR),
00348       DBTYPE_WSTR,
00349       pwszBuffer,
00350       0,  //Precision
00351       0,  //Scale
00352
00353       (m_wType == DBTYPE_IUNKNOWN || m_wType == (DBTYPE_BYREF|DBTYPE_IUNKNOWN))
00354         ? DBTYPE_BYTES : m_wType,
00355
00356       NULL,   //&dbDstStatus
00357       &cBytes,  //&cbDstLength
00358       pBuffer,
00359       sizeof(pBuffer),
00360       dwConvFlags
00361     ),S_OK);
00362
00363
00364   //Delegate
00365   TESTC(hr = WriteBytes(riid, ulOffset, cBytes, pBuffer, &cbWritten));
00366
00367 CLEANUP:
00368   if(pcbWritten)
00369     *pcbWritten = cbWritten;
00370   return hr;
00371 }
00372
00373
00374 ////////////////////////////////////////////////////////////////
00375 // CStream::Clone
00376 //
00377 /////////////////////////////////////////////////////////////////
00378 HRESULT CStream::Clone(IStream** ppStream)
00379 {
00380   HRESULT hr = S_OK;
00381
00382   if(m_pIStream)
00383   {
00384     //IStream::Clone
00385     XTEST(hr = m_pIStream->Clone(ppStream));
00386     TESTC(TRACE_METHOD(hr, L"IStream::Clone(&0x%p)", ppStream ? *ppStream : NULL));
00387   }
00388
00389 CLEANUP:
00390   return hr;
00391 }
00392
00393
00394 ////////////////////////////////////////////////////////////////
00395 // CStream::Seek
00396 //
00397 /////////////////////////////////////////////////////////////////
00398 HRESULT CStream::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
00399 {
00400   HRESULT hr = E_INVALIDARG;
00401
00402   if(m_pIStream)
00403   {
00404     //IStream::Seek
00405     TEST(hr = m_pIStream->Seek(dlibMove, dwOrigin, plibNewPosition));
00406     TESTC(TRACE_METHOD(hr, L"IStream::Seek(%d, %d, &%d)", dlibMove.QuadPart, dwOrigin, plibNewPosition ? plibNewPosition->QuadPart : 0));
00407   }
00408
00409 CLEANUP:
00410   return hr;
00411 }
00412
00413
00414 ////////////////////////////////////////////////////////////////
00415 // CStream::Stat
00416 //
00417 /////////////////////////////////////////////////////////////////
00418 HRESULT CStream::Stat(STATSTG* pstatstg)
00419 {
00420   ASSERT(pstatstg);
00421   HRESULT hr = S_OK;
00422   WCHAR* pwszProgID = NULL;
00423
00424   if(m_pIStream)
00425   {
00426     memset(pstatstg, 0, sizeof(STATSTG));
00427
00428     //IStream::Stat
00429     XTEST(hr = m_pIStream->Stat(pstatstg, STATFLAG_DEFAULT));
00430
00431     pwszProgID = GetProgID(pstatstg->clsid);
00432     TESTC(TRACE_METHOD(hr, L"IStream::Stat(&{\"%s\", %d, %d, 0x%08x, 0x%08x, 0x%08x, %d, %d, \"%s\", 0x%08x, %d}, \"%s\")", pstatstg->pwcsName, pstatstg->type, (ULONG)pstatstg->cbSize.QuadPart, &pstatstg->mtime, &pstatstg->ctime, &pstatstg->atime, pstatstg->grfMode, pstatstg->grfLocksSupported, pwszProgID, pstatstg->grfStateBits, pstatstg->reserved, L"STATFLAG_DEFAULT"));
00433   }
00434
00435 CLEANUP:
00436   SAFE_FREE(pwszProgID);
00437   return hr;
00438 }
00439
00440
00441
00442 ///////////////////////////////////////////////////////////////////////////////
00443 // Class CStorageBuffer
00444 //
00445 // My implementation of storage interfaces
00446 ///////////////////////////////////////////////////////////////////////////////
00447 CStorageBuffer::CStorageBuffer()
00448 {
00449   m_iPos    = 0;
00450   m_cRef    = 1;
00451
00452   m_pBuffer   = NULL;
00453   m_cMaxSize  = 0;
00454 }
00455
00456
00457 CStorageBuffer::~CStorageBuffer()
00458 {
00459   SAFE_FREE(m_pBuffer);
00460 }
00461
00462 ULONG CStorageBuffer::AddRef()
00463 {
00464   m_cRef++;
00465   return m_cRef;
00466 }
00467
00468 ULONG CStorageBuffer::Release()
00469 {
00470   ASSERT(m_cRef);
00471   m_cRef--;
00472
00473   if(m_cRef)
00474     return m_cRef;
00475   delete this;
00476   return 0;
00477 }
00478
00479 HRESULT CStorageBuffer::QueryInterface(REFIID riid, void** ppv)
00480 {
00481   if(!ppv)
00482     return E_INVALIDARG;
00483   *ppv = NULL;
00484   HRESULT hr = E_NOINTERFACE;
00485
00486   if (riid == IID_IUnknown)
00487     *ppv = (IUnknown*)(ISequentialStream*)this;
00488   else if (riid == IID_ISequentialStream)
00489     *ppv = (ISequentialStream*)this;
00490   else if (riid == IID_IStream)
00491     *ppv = (IStream*)this;
00492   else if (riid == IID_ILockBytes)
00493     *ppv = (ILockBytes*)this;
00494 //  else if (riid == IID_IStorage)
00495 //    *ppv = (IStorage*)this;
00496
00497   if(*ppv)
00498   {
00499     //Avoid internal notiifcations
00500     m_cRef++;
00501     hr = S_OK;
00502   }
00503
00504   return hr;
00505 }
00506
00507
00508 HRESULT CStorageBuffer::ReadBuffer(ULONG ulOffset, void *pv, ULONG cb, ULONG* pcbRead)
00509 {
00510   //Parameter checking
00511   if(pcbRead)
00512     *pcbRead = 0;
00513
00514   if(!pv)
00515     return STG_E_INVALIDPOINTER;
00516
00517   if(cb == 0)
00518     return S_OK;
00519
00520   //Actual code
00521   ULONG cBytesLeft = m_cMaxSize > ulOffset ? m_cMaxSize - ulOffset : 0;
00522   ULONG cBytesRead = cb > cBytesLeft ? cBytesLeft : cb;
00523
00524   //if no more bytes to retrive return
00525   if(cBytesLeft == 0)
00526     return S_FALSE;
00527
00528   //Copy to users buffer the number of bytes requested or remaining
00529   memcpy(pv, (void*)((BYTE*)m_pBuffer + ulOffset), cBytesRead);
00530
00531   if(pcbRead)
00532     *pcbRead = cBytesRead;
00533
00534   if(cb != cBytesRead)
00535     return S_FALSE;
00536
00537   return S_OK;
00538 }
00539
00540
00541 HRESULT CStorageBuffer::WriteBuffer(ULONG ulOffset, const void *pv, ULONG cb, ULONG* pcbWritten)
00542 {
00543   //Parameter checking
00544   if(!pv)
00545     return STG_E_INVALIDPOINTER;
00546
00547   if(pcbWritten)
00548     *pcbWritten = 0;
00549
00550   if(cb == 0)
00551     return S_OK;
00552
00553   //May need to Enlarge the current buffer
00554   if(ulOffset + cb >= m_cMaxSize)
00555   {
00556     //Need to append to the end of the stream
00557     ULARGE_INTEGER largeSize = { ulOffset + cb };
00558     if(FAILED(SetSize(largeSize)))
00559       return E_OUTOFMEMORY;
00560   }
00561
00562   //Copy to the buffer
00563   memcpy((void*)((BYTE*)m_pBuffer + ulOffset), pv, cb);
00564
00565   if(pcbWritten)
00566     *pcbWritten = cb;
00567
00568   return S_OK;
00569 }
00570
00571
00572 HRESULT CStorageBuffer::Read(void *pv, ULONG cb, ULONG* pcbRead)
00573 {
00574   ULONG cbRead = 0;
00575   HRESULT hr = S_OK;
00576
00577   //Delegate, reading from the current position
00578   XTEST(hr = ReadBuffer(m_iPos, pv, cb, &cbRead));
00579   TRACE_METHOD(hr, L"\tISequentialStream::Read(0x%p, %d, &%d)", pv, cb, cbRead);
00580
00581   if(SUCCEEDED(hr))
00582     m_iPos += cbRead;
00583
00584   if(pcbRead)
00585     *pcbRead = cbRead;
00586
00587   return hr;
00588 }
00589
00590
00591 HRESULT CStorageBuffer::Write(const void *pv, ULONG cb, ULONG* pcbWritten)
00592 {
00593   ULONG cbWritten = 0;
00594   HRESULT hr = S_OK;
00595
00596   //Delegate, writting to the current position
00597   XTEST(hr = WriteBuffer(m_iPos, pv, cb, &cbWritten));
00598   TRACE_METHOD(hr, L"\tISequentialStream::Write(0x%p, %d, &%d)", pv, cb, cbWritten);
00599
00600   if(SUCCEEDED(hr))
00601     m_iPos += cbWritten;
00602
00603   if(pcbWritten)
00604     *pcbWritten = cbWritten;
00605
00606   return hr;
00607 }
00608
00609
00610 HRESULT CStorageBuffer::Seek(LONG lOffset, DWORD dwOrigin, ULONG* pulNewPosition)
00611 {
00612   HRESULT hr = S_OK;
00613   LONG lNewPos = 0;
00614
00615   //Determine with respect to what the origin is...
00616   switch(dwOrigin)
00617   {
00618     case STREAM_SEEK_SET:
00619       lNewPos = lOffset;
00620       break;
00621
00622     case STREAM_SEEK_CUR:
00623       lNewPos = m_iPos + lOffset;
00624       break;
00625
00626     case STREAM_SEEK_END:
00627       lNewPos = m_cMaxSize + lOffset;
00628       break;
00629
00630     default:
00631       //The value of the dwOrigin parameter is not valid
00632       hr = STG_E_INVALIDFUNCTION;
00633       goto CLEANUP;
00634       break;
00635   };
00636
00637   if(lNewPos<0 || (ULONG)lNewPos>m_cMaxSize)
00638     return STG_E_INVALIDFUNCTION; //No good return code for this situaiton?
00639
00640   //Reset the current buffer position
00641   m_iPos = lNewPos;
00642
00643 CLEANUP:
00644   if(pulNewPosition)
00645      *pulNewPosition = m_iPos;
00646   TRACE_METHOD(hr, L"\tIStream::Seek(%d, %d, &%d)", lOffset, dwOrigin, m_iPos);
00647   return S_OK;
00648 }
00649
00650 //IStream interfaces
00651 HRESULT CStorageBuffer::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER * plibNewPosition)
00652 {
00653   HRESULT hr = S_OK;
00654   ULONG ulNewPosition = 0;
00655
00656   //Delegate to the simplier version
00657   TESTC(hr = Seek((LONG)dlibMove.QuadPart, dwOrigin, &ulNewPosition));
00658
00659 CLEANUP:
00660   if(plibNewPosition)
00661      plibNewPosition->QuadPart = ulNewPosition;
00662   return hr;
00663 }
00664
00665
00666 HRESULT CStorageBuffer::SetSize(  ULARGE_INTEGER libNewSize)    //Specifies the new size of the stream object
00667 {
00668   HRESULT hr = STG_E_MEDIUMFULL;
00669   void* pBuffer = m_pBuffer;
00670
00671   //The value of the libNewSize parameter is not valid.
00672   //Since streams cannot be greater than 2^32 bytes in the COM-provided
00673   //implementation, the high DWORD of libNewSize must be 0.
00674   //If it is nonzero, this parameter is not valid.
00675   if(libNewSize.QuadPart > ULONG_MAX)
00676   {
00677     hr = STG_E_INVALIDFUNCTION;
00678     goto CLEANUP;
00679   }
00680
00681   //Use a copy variable, incase allocations fail...
00682   SAFE_REALLOC(pBuffer, BYTE, libNewSize.QuadPart);
00683
00684   m_pBuffer = pBuffer;
00685   m_cMaxSize = (ULONG)libNewSize.QuadPart;
00686   hr = S_OK;
00687
00688 CLEANUP:
00689   TRACE_METHOD(hr, L"\tIStream::SetSize(%d)", (ULONG)libNewSize.QuadPart);
00690   return hr;
00691 }
00692
00693 HRESULT CStorageBuffer::CopyTo( IStream * pIStream,       //Points to the destination stream
00694               ULARGE_INTEGER cb,        //Specifies the number of bytes to copy
00695               ULARGE_INTEGER * pcbRead,   //Pointer to the actual number of bytes read from the source
00696               ULARGE_INTEGER * pcbWritten)  //Pointer to the actual number of bytes written to the destination
00697 {
00698   HRESULT hr = S_OK;
00699
00700   //This is equivlent of doing Read from our stream then Write into the destination.
00701   //It also moves the seek position.  Bug this would require allocating a temp buffer...
00702   //Just access our stream directly...
00703
00704   //Parameter checking
00705   if(pcbRead)
00706     pcbRead->QuadPart = 0;
00707   if(pcbWritten)
00708     pcbWritten->QuadPart = 0;
00709
00710   //Actual code
00711   ULONG cBytesLeft = m_cMaxSize - m_iPos;
00712   ULONG cBytesRead = (ULONG)cb.QuadPart > cBytesLeft ? cBytesLeft : (ULONG)cb.QuadPart;
00713   ULONG cBytesWritten = 0;
00714
00715   if(!pIStream)
00716   {
00717     hr = STG_E_INVALIDPOINTER;
00718     goto CLEANUP;
00719   }
00720
00721   if(cb.QuadPart == 0)
00722   {
00723     hr = S_OK;
00724     goto CLEANUP;
00725   }
00726
00727   //if no more bytes to retrive return
00728   if(cBytesLeft == 0)
00729   {
00730     hr = S_FALSE;
00731     goto CLEANUP;
00732   }
00733
00734   //Copy to users buffer the number of bytes requested or remaining
00735   pIStream->Write((BYTE*)m_pBuffer + m_iPos, cBytesRead, &cBytesWritten);
00736   m_iPos += cBytesRead;
00737
00738   if(pcbRead)
00739     pcbRead->QuadPart = cBytesRead;
00740   if(pcbWritten)
00741     pcbWritten->QuadPart = cBytesWritten;
00742
00743   if(cb.QuadPart != cBytesRead)
00744     hr = S_FALSE;
00745
00746 CLEANUP:
00747   TRACE_METHOD(hr, L"\tIStream::CopyTo(0x%p, %d, &%d, &%d)", pIStream, cb, cBytesRead, cBytesWritten);
00748   return hr;
00749 }
00750
00751 HRESULT CStorageBuffer::Commit( DWORD grfCommitFlags)     //Specifies how changes are committed
00752 {
00753   HRESULT hr = S_OK;
00754   TRACE_METHOD(hr, L"\tIStream::Commit()");
00755   return hr;
00756 }
00757
00758 HRESULT CStorageBuffer::Revert( )
00759 {
00760   HRESULT hr = S_OK;
00761   TRACE_METHOD(hr, L"\tIStream::Revert()");
00762   return hr;
00763 }
00764
00765 HRESULT CStorageBuffer::LockRegion(ULARGE_INTEGER libOffset,    //Specifies the byte offset for the beginning of the range
00766               ULARGE_INTEGER cb,        //Specifies the length of the range in bytes
00767               DWORD dwLockType)       //Specifies the restriction on accessing the specified range
00768 {
00769   //Locking is optional
00770   HRESULT hr = STG_E_INVALIDFUNCTION;
00771   TRACE_METHOD(hr, L"\tIStream::LockRegion()");
00772   return hr;
00773 }
00774
00775 HRESULT CStorageBuffer::UnlockRegion(  ULARGE_INTEGER libOffset,  //Specifies the byte offset for the beginning of the range
00776                 ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
00777                 DWORD dwLockType)     //Specifies the access restriction previously placed on the range);
00778 {
00779   //Locking is optional
00780   HRESULT hr = STG_E_INVALIDFUNCTION;
00781   TRACE_METHOD(hr, L"\tIStream::UnlockRegion()");
00782   return hr;
00783 }
00784
00785 HRESULT CStorageBuffer::Stat(   STATSTG * pstatstg,       //Location for STATSTG structure
00786               DWORD grfStatFlag)        //Values taken from the STATFLAG enumeration
00787 {
00788   HRESULT hr = S_OK;
00789   ULARGE_INTEGER largeInteger = { m_cMaxSize };
00790
00791   if(!pstatstg)
00792   {
00793     hr = STG_E_INVALIDPOINTER;
00794     goto CLEANUP;
00795   }
00796
00797   //Initialize the struct
00798   memset(pstatstg, 0, sizeof(STATSTG));
00799
00800   //Set the string...
00801   switch(grfStatFlag)
00802   {
00803     case STATFLAG_NONAME:
00804       pstatstg->pwcsName = NULL;
00805       break;
00806
00807     case STATFLAG_DEFAULT:
00808       pstatstg->pwcsName = wcsDuplicate(L"OLE DB Test Storage Object...");
00809       break;
00810
00811     default:
00812       hr = STG_E_INVALIDFLAG;
00813       goto CLEANUP;
00814   };
00815
00816   //type
00817   pstatstg->type = STGTY_STREAM;
00818   pstatstg->grfMode = STGM_READ;
00819   pstatstg->grfLocksSupported = 0;
00820   pstatstg->cbSize = largeInteger;
00821
00822 CLEANUP:
00823   TRACE_METHOD(hr, L"\tIStream::Stat(0x%p, 0x%08x)", pstatstg, grfStatFlag);
00824   return hr;
00825 }
00826
00827 HRESULT CStorageBuffer::Clone(IStream** ppIStream)        //Points to location for pointer to the new stream object
00828 {
00829   HRESULT hr = E_NOTIMPL;
00830   TRACE_METHOD(hr, L"\tILockBytes::Clone()");
00831   return hr;
00832 }
00833
00834
00835 HRESULT CStorageBuffer::ReadAt(
00836               ULARGE_INTEGER ulOffset,
00837             /* [out] */   void* pv,
00838             /* [in] */    ULONG cb,
00839             /* [out] */   ULONG* pcbRead)
00840 {
00841   HRESULT hr = S_OK;
00842   ULONG cbRead = 0;
00843
00844   //Delegate, reading from the current position
00845   XTEST(hr = ReadBuffer((ULONG)ulOffset.QuadPart, pv, cb, &cbRead));
00846   TRACE_METHOD(hr, L"\tILockBytes::ReadAt(%d, 0x%p, %d, &%d)", (ULONG)ulOffset.QuadPart, pv, cb, cbRead);
00847
00848   if(pcbRead)
00849     *pcbRead = cbRead;
00850   return hr;
00851 }
00852
00853 HRESULT CStorageBuffer::WriteAt(
00854               ULARGE_INTEGER ulOffset,
00855             /* [in] */    const void* pv,
00856             /* [in] */    ULONG cb,
00857             /* [out] */   ULONG* pcbWritten)
00858 {
00859   HRESULT hr = S_OK;
00860   ULONG cbWritten = 0;
00861
00862   //Delegate, reading from the current position
00863   XTEST(hr = WriteBuffer((ULONG)ulOffset.QuadPart, pv, cb, &cbWritten));
00864   TRACE_METHOD(hr, L"\tILockBytes::WriteAt(%d, 0x%p, %d, &%d)", (ULONG)ulOffset.QuadPart, pv, cb, cbWritten);
00865
00866   if(pcbWritten)
00867     *pcbWritten = cbWritten;
00868   return hr;
00869 }
00870
00871 HRESULT CStorageBuffer::Flush()
00872 {
00873   HRESULT hr = S_OK;
00874   TRACE_METHOD(hr, L"\tILockBytes::Flush()");
00875   return hr;
00876 }
00877
00878
00879 ///////////////////////////////////////////////////////////////////////////////
00880 // Class CFileStream
00881 //
00882 // My implementation of stream interface on top of a file
00883 ///////////////////////////////////////////////////////////////////////////////
00884 CFileStream::CFileStream()
00885 {
00886   m_pFile = NULL;
00887   m_cRef  = 1;
00888 }
00889
00890 CFileStream::~CFileStream()
00891 {
00892   CloseFile();
00893 }
00894
00895 HRESULT CFileStream::OpenFile(WCHAR* pwszFile, WCHAR* pwszMode)
00896 {
00897   if(IsUnicodeOS())
00898   {
00899     m_pFile = _wfopen(pwszFile, pwszMode);
00900   }
00901   else
00902   {
00903     CHAR szFileName[MAX_NAME_LEN];
00904     ConvertToMBCS(pwszFile, szFileName, MAX_NAME_LEN);
00905     CHAR szMode[MAX_NAME_LEN];
00906     ConvertToMBCS(pwszMode, szMode, MAX_NAME_LEN);
00907
00908     m_pFile = fopen(szFileName, szMode);
00909   }
00910
00911   return m_pFile ? S_OK : STG_E_ACCESSDENIED;
00912 }
00913
00914
00915 HRESULT CFileStream::CloseFile()
00916 {
00917   if(m_pFile)
00918     fclose(m_pFile);
00919
00920   return S_OK;
00921 }
00922
00923
00924 ULONG CFileStream::AddRef()
00925 {
00926   m_cRef++;
00927   return m_cRef;
00928 }
00929
00930 ULONG CFileStream::Release()
00931 {
00932   ASSERT(m_cRef);
00933   m_cRef--;
00934
00935   if(m_cRef)
00936     return m_cRef;
00937   delete this;
00938   return 0;
00939 }
00940
00941 HRESULT CFileStream::QueryInterface(REFIID riid, void** ppv)
00942 {
00943   ASSERT(ppv);
00944   HRESULT hr = E_NOINTERFACE;
00945
00946   *ppv = NULL;
00947
00948   if (riid == IID_IUnknown)
00949     *ppv = (IUnknown*)this;
00950   else if (riid == IID_ISequentialStream)
00951     *ppv = (ISequentialStream*)this;
00952   else if (riid == IID_IStream)
00953     *ppv = (IStream*)this;
00954
00955   if(*ppv)
00956   {
00957     m_cRef++;
00958     hr = S_OK;
00959   }
00960
00961   return hr;
00962 }
00963
00964
00965 STDMETHODIMP CFileStream::Read(void *pv, ULONG cb, ULONG *pcbRead)
00966 {
00967   ULONG cbRead = 0;
00968
00969   //Parameter checking
00970   if(!m_pFile)
00971     return STG_E_INVALIDHANDLE;
00972   if(!pv)
00973     return STG_E_INVALIDPOINTER;
00974   if(cb == 0)
00975     return S_OK;
00976
00977   //Read from the file...
00978   cbRead = fread(pv, sizeof(BYTE), cb, m_pFile);
00979
00980   //Results..
00981   if(pcbRead)
00982     *pcbRead = cbRead;
00983   return cbRead==cb ? S_OK : S_FALSE;
00984 }
00985
00986
00987 STDMETHODIMP CFileStream::Write(const void *pv, ULONG cb, ULONG *pcbWritten)
00988 {
00989   ULONG cbWritten = 0;
00990
00991   //Parameter checking
00992   if(!m_pFile)
00993     return STG_E_INVALIDHANDLE;
00994   if(!pv)
00995     return STG_E_INVALIDPOINTER;
00996   if(cb == 0)
00997     return S_OK;
00998
00999   //Read from the file...
01000   cbWritten = fwrite(pv, sizeof(BYTE), cb, m_pFile);
01001
01002   //Results..
01003   if(pcbWritten)
01004     *pcbWritten = cbWritten;
01005   return cbWritten==cb ? S_OK : S_FALSE;
01006 }
01007
01008 //IStream interfaces
01009 HRESULT CFileStream::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER * plibNewPosition)
01010 {
01011   //Parameter checking
01012   if(!m_pFile)
01013     return STG_E_INVALIDHANDLE;
01014
01015   //Seek
01016   LONG lNewPosition = fseek(m_pFile, dlibMove.LowPart, dwOrigin);
01017   if (lNewPosition >= 0 && plibNewPosition)
01018     plibNewPosition->LowPart = lNewPosition;
01019
01020   return (lNewPosition >= 0) ? S_OK : E_FAIL;
01021 }
01022
01023
01024 HRESULT CFileStream::SetSize( ULARGE_INTEGER libNewSize)    //Specifies the new size of the stream object
01025 {
01026   return E_NOTIMPL;
01027 }
01028
01029 HRESULT CFileStream::CopyTo(  IStream * pIStream,       //Points to the destination stream
01030               ULARGE_INTEGER cb,        //Specifies the number of bytes to copy
01031               ULARGE_INTEGER * pcbRead,   //Pointer to the actual number of bytes read from the source
01032               ULARGE_INTEGER * pcbWritten)  //Pointer to the actual number of bytes written to the destination
01033 {
01034   return E_NOTIMPL;
01035 }
01036
01037 HRESULT CFileStream::Commit(  DWORD grfCommitFlags)     //Specifies how changes are committed
01038 {
01039   return E_NOTIMPL;
01040 }
01041
01042 HRESULT CFileStream::Revert(  )
01043 {
01044   return E_NOTIMPL;
01045 }
01046
01047 HRESULT CFileStream::LockRegion(ULARGE_INTEGER libOffset,   //Specifies the byte offset for the beginning of the range
01048               ULARGE_INTEGER cb,        //Specifies the length of the range in bytes
01049               DWORD dwLockType)       //Specifies the restriction on accessing the specified range
01050 {
01051   return E_NOTIMPL;
01052 }
01053
01054 HRESULT CFileStream::UnlockRegion(  ULARGE_INTEGER libOffset, //Specifies the byte offset for the beginning of the range
01055                 ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
01056                 DWORD dwLockType)     //Specifies the access restriction previously placed on the range);
01057 {
01058   return E_NOTIMPL;
01059 }
01060
01061 HRESULT CFileStream::Stat(    STATSTG * pstatstg,       //Location for STATSTG structure
01062               DWORD grfStatFlag)        //Values taken from the STATFLAG enumeration
01063 {
01064   return E_NOTIMPL;
01065 }
01066
01067 HRESULT CFileStream::Clone(IStream** ppIStream)       //Points to location for pointer to the new stream object
01068 {
01069   return E_NOTIMPL;
01070 }
01071
01072
01073
01074
01075
01076
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RUREGVALUE Member List

This is the complete list of members for _RUREGVALUE, including all inherited members.
dwSize | _RUREGVALUE
dwType | _RUREGVALUE
hr | _RUREGVALUE
pbData | _RUREGVALUE
pszName | _RUREGVALUE
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/dataobj.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

dataobj.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _CLASS_CDATAOBJECT_
00015 #define _CLASS_CDATAOBJECT_
00016
00017 #include "Globals.h"
00018 #include "StaticNode.h"
00019
00020 //---------------------------------------------------------------------------
00021 class CDataObject : public IDataObject
00022 {
00023   private:
00024     ULONG     m_cRef;
00025     ULONG     m_uCookie;
00026     ULONG     m_uContext;
00027
00028   public:
00029     CDataObject();
00030     ~CDataObject();
00031
00032   public:  // Interface IUnknown
00033     STDMETHODIMP QueryInterface( REFIID riid, LPVOID* ppv );
00034     STDMETHODIMP_(ULONG) AddRef();
00035     STDMETHODIMP_(ULONG) Release();
00036
00037   public:  // IDataObject methods
00038     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00039
00040     // The rest are not implemented
00041     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00042     { return E_NOTIMPL; };
00043
00044     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00045     { return E_NOTIMPL; };
00046
00047     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00048     { return E_NOTIMPL; };
00049
00050     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00051     { return E_NOTIMPL; };
00052
00053     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00054     { return E_NOTIMPL; };
00055
00056     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00057     { return E_NOTIMPL; };
00058
00059     STDMETHODIMP DUnadvise (DWORD dwConnection)
00060     { return E_NOTIMPL; };
00061
00062     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00063     { return E_NOTIMPL; };
00064
00065   ///////////////////////////////////////////////////////////////////////////
00066   // Custom Methods
00067   public:
00068     VOID   SetPrivateData( ULONG uCookie, ULONG uContext );
00069
00070     // For future use, not used in this sample
00071     ULONG  GetContext() { return m_uContext; }
00072     ULONG  GetCookie()  { return m_uCookie;  }
00073
00074   ///////////////////////////////////////////////////////////////////////////
00075   // Handlers for required clipboard formats
00076   private:
00077     HRESULT  RetrieveDisplayString( IStream* ipStream );
00078     HRESULT  RetrieveSnapInClassID( IStream* ipStream );
00079     HRESULT  RetrieveNodeTypeGuid( IStream* ipStream );
00080     HRESULT  RetrieveGuidString( IStream* ipStream );
00081     HRESULT  RetrieveBaseNodePtr( IStream* ipStream );
00082     HRESULT  RetrieveDataObjPtr( IStream* ipStream );
00083
00084 };
00085
00086 #endif //_CLASS_CDATAOBJECT_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIGetRow Member List

This is the complete list of members for CImpIGetRow, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIGetRow) | CImpIGetRow
GetRowFromHROW(IUnknown *pIUnkOuter, HROW hRow, REFIID riid, IUnknown **ppUnk) | CImpIGetRow
GetURLFromHROW(HROW hRow, LPOLESTR *ppwszURL) | CImpIGetRow
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellExt/ShellExt.h Source File

  • WinUI
  • Shell
  • ShellExt

ShellExt.h

Go to the documentation of this file.
00001 //
00002 // The class ID of this Shell extension class.
00003 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00004 //
00005 // class id:  87b9bd00-c65c-11cd-a259-00dd010e8c28
00006 //
00007 //
00008 // NOTE!!!  If you use this shell extension as a starting point,
00009 //          you MUST change the GUID below.  Simply run UUIDGEN.EXE
00010 //          to generate a new GUID.
00011 //
00012
00013 #define ODS(sz) OutputDebugString(sz)
00014
00015 #ifndef _SHELLEXT_H
00016 #define _SHELLEXT_H
00017
00018 DEFINE_GUID(CLSID_ShellExtension, 0x87b9bd00L, 0xc65c, 0x11cd, 0xa2, 0x59, 0x00, 0xdd, 0x01, 0x0e, 0x8c, 0x28 );
00019
00020 // this class factory object creates context menu handlers for Windows 95 shell
00021 class CShellExtClassFactory : public IClassFactory
00022 {
00023 protected:
00024     ULONG   m_cRef;
00025
00026 public:
00027     CShellExtClassFactory();
00028     ~CShellExtClassFactory();
00029
00030     //IUnknown members
00031     STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
00032     STDMETHODIMP_(ULONG)    AddRef();
00033     STDMETHODIMP_(ULONG)    Release();
00034
00035     //IClassFactory members
00036     STDMETHODIMP        CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
00037     STDMETHODIMP        LockServer(BOOL);
00038
00039 };
00040 typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
00041
00042 // this is the actual OLE Shell context menu handler
00043 class CShellExt : public IContextMenu,
00044                          IShellExtInit,
00045                          IExtractIcon,
00046                          IPersistFile,
00047                          IShellPropSheetExt,
00048                          ICopyHook
00049 {
00050 public:
00051     char         m_szPropSheetFileUserClickedOn[MAX_PATH];  //This will be the same as
00052                                                             //m_szFileUserClickedOn but I include
00053                                                             //here for demonstration.  That is,
00054                                                             //m_szFileUserClickedOn gets filled in
00055                                                             //as a result of this sample supporting
00056                                                             //the IExtractIcon and IPersistFile
00057                                                             //interface.  If this sample *only* showed
00058                                                             //a Property Sheet extesion, you would
00059                                                             //need to use the method I do here to find
00060                                                             //the filename the user clicked on.
00061
00062
00063 protected:
00064     ULONG        m_cRef;
00065     LPDATAOBJECT m_pDataObj;
00066     char         m_szFileUserClickedOn[MAX_PATH];
00067
00068     STDMETHODIMP DoGAKMenu1(HWND hParent,
00069                             LPCSTR pszWorkingDir,
00070                             LPCSTR pszCmd,
00071                             LPCSTR pszParam,
00072                             int iShowCmd);
00073
00074     STDMETHODIMP DoGAKMenu2(HWND hParent,
00075                             LPCSTR pszWorkingDir,
00076                             LPCSTR pszCmd,
00077                             LPCSTR pszParam,
00078                             int iShowCmd);
00079
00080     STDMETHODIMP DoGAKMenu3(HWND hParent,
00081                             LPCSTR pszWorkingDir,
00082                             LPCSTR pszCmd,
00083                             LPCSTR pszParam,
00084                             int iShowCmd);
00085
00086     STDMETHODIMP DoGAKMenu4(HWND hParent,
00087                             LPCSTR pszWorkingDir,
00088                             LPCSTR pszCmd,
00089                             LPCSTR pszParam,
00090                             int iShowCmd);
00091 public:
00092     CShellExt();
00093     ~CShellExt();
00094
00095     //IUnknown members
00096     STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
00097     STDMETHODIMP_(ULONG)    AddRef();
00098     STDMETHODIMP_(ULONG)    Release();
00099
00100     //IShell members
00101     STDMETHODIMP            QueryContextMenu(HMENU hMenu,
00102                                              UINT indexMenu,
00103                                              UINT idCmdFirst,
00104                                              UINT idCmdLast,
00105                                              UINT uFlags);
00106
00107     STDMETHODIMP            InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
00108
00109     STDMETHODIMP            GetCommandString(UINT_PTR idCmd,
00110                                              UINT uFlags,
00111                                              UINT FAR *reserved,
00112                                              LPSTR pszName,
00113                                              UINT cchMax);
00114
00115     //IShellExtInit methods
00116     STDMETHODIMP            Initialize(LPCITEMIDLIST pIDFolder,
00117                                        LPDATAOBJECT pDataObj,
00118                                        HKEY hKeyID);
00119
00120     //IExtractIcon methods
00121     STDMETHODIMP GetIconLocation(UINT   uFlags,
00122                                  LPSTR  szIconFile,
00123                                  UINT   cchMax,
00124                                  int   *piIndex,
00125                                  UINT  *pwFlags);
00126
00127     STDMETHODIMP Extract(LPCSTR pszFile,
00128                          UINT   nIconIndex,
00129                          HICON  *phiconLarge,
00130                          HICON  *phiconSmall,
00131                          UINT   nIconSize);
00132
00133     //IPersistFile methods
00134     STDMETHODIMP GetClassID(LPCLSID lpClassID);
00135
00136     STDMETHODIMP IsDirty();
00137
00138     STDMETHODIMP Load(LPCOLESTR lpszFileName, DWORD grfMode);
00139
00140     STDMETHODIMP Save(LPCOLESTR lpszFileName, BOOL fRemember);
00141
00142     STDMETHODIMP SaveCompleted(LPCOLESTR lpszFileName);
00143
00144     STDMETHODIMP GetCurFile(LPOLESTR FAR* lplpszFileName);
00145
00146     //IShellPropSheetExt methods
00147     STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
00148
00149     STDMETHODIMP ReplacePage(UINT uPageID,
00150                              LPFNADDPROPSHEETPAGE lpfnReplaceWith,
00151                              LPARAM lParam);
00152
00153     //ICopyHook method
00154     STDMETHODIMP_(UINT) CopyCallback(HWND hwnd,
00155                                      UINT wFunc,
00156                                      UINT wFlags,
00157                                      LPCSTR pszSrcFile,
00158                                      DWORD dwSrcAttribs,
00159                                      LPCSTR pszDestFile,
00160                                      DWORD dwDestAttribs);
00161
00162 };
00163 typedef CShellExt *LPCSHELLEXT;
00164
00165 #endif // _SHELLEXT_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/util.cpp Source File

  • Dataaccess
  • rds
  • handler
  • vc

util.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:    util.cpp
00004 //
00005 // Copyright: Copyright (c) 1991-1999 Microsoft Corporation
00006 //
00007 // Contents:  Implementation of class CUtil
00008 //
00009 // Comments:
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 #include "stdafx.h"
00014 #include <assert.h>
00015 #include <stdio.h>
00016 #include <time.h>
00017 #include "util.h"
00018
00019 static WCHAR const s_wszDatasource[] = L"Data Source";
00020 static int const s_cDatasource = sizeof(s_wszDatasource) / sizeof(WCHAR) - 1;
00021
00022
00023 //
00024 // The user of this class must use try/catch
00025 // on the constructor and member functions.
00026 //
00027 static void ThrowHR(HRESULT hr)
00028 {
00029   throw hr;
00030 }
00031
00032
00033 //
00034 // Constructor
00035 //
00036 CUtil::CUtil()
00037 {
00038   m_bstrIniFile = L"msdfmap.ini";
00039   m_lAccess = UTIL_NOACCESS;
00040
00041   m_cLastIniString = 4096;
00042   m_pszLastIniString = new CHAR [m_cLastIniString];
00043
00044   ULONG namelen = 0;
00045   GetUserNameA("", &namelen);
00046   if (namelen == 0)
00047     namelen = 256;
00048   m_pszUsername = new CHAR [namelen + 1];
00049   if (!m_pszUsername)
00050     ThrowHR(E_OUTOFMEMORY);
00051     if (!GetUserNameA(m_pszUsername, &namelen))
00052     m_pszUsername[0] = '\0';
00053
00054   if (!m_pszLastIniString)
00055     ThrowHR(E_OUTOFMEMORY);
00056 }
00057
00058
00059 //
00060 // Destructor
00061 //
00062 CUtil::~CUtil()
00063 {
00064   delete [] m_pszLastIniString;
00065   delete [] m_pszUsername;
00066 }
00067
00068
00069 //
00070 // Raise a Win32 error
00071 //
00072 void CUtil::RaiseError(HRESULT hr)
00073 {
00074   CHAR * ErrFileName = GetIniString("logs", "err");
00075
00076   if (ErrFileName[0])
00077   {
00078     FILE * fp = fopen(ErrFileName, "at");
00079     if (fp)
00080     {
00081       time_t t;
00082       struct tm *ptm;
00083
00084       time(&t);
00085       ptm = localtime(&t);
00086       fprintf(fp, "user=%s, hr=%lX, datetime=%s", GetUsername(), hr, asctime(ptm));
00087       fclose(fp);
00088     }
00089   }
00090   ThrowHR(hr);
00091 }
00092
00093
00094 //
00095 // Set the name of the INI file to open.
00096 // (the default name is set in the constructor)
00097 //
00098 void CUtil::SetIniFile(BSTR args)
00099 {
00100   if (!args || !wcslen(args))
00101     return;
00102
00103   if (wcschr(args, L':') || wcschr(args, L'\\'))
00104   {
00105     RaiseError(HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED));  //Handler argument can't specify a path.
00106     return;
00107   }
00108
00109   m_bstrIniFile = args;
00110 }
00111
00112
00113 //
00114 // Search for a character, but ignore those inside quoted strings.
00115 //
00116 static WCHAR * FindChr(WCHAR * str, WCHAR chr)
00117 {
00118   WCHAR *pChr;
00119   WCHAR *pQuote;
00120
00121   if (!str)
00122     return NULL;
00123   while(1)
00124   {
00125     // Outside of quotes
00126     pChr = wcschr(str, chr);
00127     if (!pChr)
00128       return NULL;
00129     pQuote = wcschr(str, L'\'');
00130     if (!pQuote)
00131       return pChr;
00132     if (pChr < pQuote)
00133       return pChr;
00134
00135     // We are now inside a quoted string.
00136     str = pQuote + 1;
00137     while(1)
00138     {
00139       // Find the end of the quoted string.
00140       pQuote = wcschr(str, L'\'');
00141       if (!pQuote)
00142         return NULL;
00143       if (pQuote[1] != L'\'')
00144         break;
00145
00146       // Skip double quotes
00147       str = pQuote + 2;
00148     }
00149     str = pQuote + 1;
00150   }
00151 }
00152
00153
00154 //
00155 // SubstituteParameters(RetVal,pszStr,params) replaces each "?" in "pszStr"
00156 // with the corresponding parameter in the comma separated list in "params".
00157 // (NOTE: this function is destructive to the "params" buffer!)
00158 //
00159 void CUtil::SubstituteParameters(CUtilString &RetVal, CHAR * pszStr, WCHAR * params)
00160 {
00161   assert(pszStr);
00162   assert(params);
00163   WCHAR *pStrNext;
00164   WCHAR *pArgNext;
00165   CUtilString bstrStr(pszStr, true);
00166   WCHAR *str;
00167
00168   // Initialize return value.
00169   RetVal = L"";
00170
00171   // Check and initialize input arguments
00172   str = bstrStr;
00173   if (!str)
00174     return;
00175
00176   while(1)
00177   {
00178     // Search for a parameter in the input string.
00179     pStrNext = FindChr(str, L'?');
00180     if (!pStrNext)
00181       break;
00182
00183     // Append the stuff before the parameter to the output string.
00184     *pStrNext++ = L'\0';
00185     RetVal += str;
00186
00187     // Search for a parameter in the parameter list.
00188     pArgNext = FindChr(params, L',');
00189     if (pArgNext)
00190       *pArgNext++ = L'\0';
00191     else
00192       pArgNext = params;
00193
00194     // Append the parameter to the output string.
00195     RetVal += params;
00196
00197     // Next interation.
00198     str = pStrNext;
00199     params = pArgNext;
00200   }
00201
00202   // Append the last stuff to the output string.
00203   RetVal += str;
00204 }
00205
00206
00207 //
00208 // GetIniString(section,key)
00209 // returns the value of the "key" in the "section" of the INI file.
00210 //
00211 CHAR * CUtil::GetIniString(CHAR * section, CHAR * key)
00212 {
00213   assert(section);
00214   assert(key);
00215   ULONG rc;
00216
00217   while(1)
00218   {
00219     if (!m_pszLastIniString)
00220       ThrowHR(E_OUTOFMEMORY);
00221
00222     // Get the value for the key in the section.
00223     rc = GetPrivateProfileStringA(section, key, "",
00224       m_pszLastIniString, m_cLastIniString, m_bstrIniFile);
00225     if (rc == 0)
00226       m_pszLastIniString[0] = '\0';
00227     if (rc < (m_cLastIniString-1))
00228       break;
00229
00230     // Make the buffer twice as big and try again.
00231     m_cLastIniString *= 2;
00232     delete [] m_pszLastIniString;
00233     m_pszLastIniString = new CHAR [m_cLastIniString];
00234   }
00235   return m_pszLastIniString;
00236 }
00237
00238
00239 //
00240 // SetSql(bstrStr) will set the sql string.  It will parse "bstrStr" for
00241 // "func(args)" then it look for "func" in the INI file.  If "bstrStr" does
00242 // not contain a function, then it searches for the whole string in the INI
00243 // file.  If it does not find it in the INI file then it will retrieve the
00244 // default sql string from the INI file.  If the "func" is found in the INI
00245 // file and there are "args" then the SubstituteParameters function is called.
00246 //
00247 void CUtil::SetSql(BSTR bstrStr)
00248 {
00249   WCHAR *pLP, *pRP, *pFunc, *pArgs;
00250   CHAR *pTemp;
00251   WCHAR *str = bstrStr ? bstrStr : L"";
00252   CUtilString temp(str, true);  // Make a copy of the string, so we are not destructive.
00253
00254   // Parse "func(args)" into "func" and "args".
00255   pFunc = temp;
00256   pLP = wcschr(pFunc, L'(');
00257   if (pLP)
00258   {
00259     *pLP++ = L'\0';
00260     pArgs = pLP;
00261     pRP = wcsrchr(pLP, L')');
00262     if (pRP)
00263       *pRP = L'\0';
00264   }
00265   else
00266     pArgs = L"";
00267
00268   // Figure out the section name and get the override for the sql string, if any.
00269   m_bstrSqlSection = L"sql ";
00270   m_bstrSqlSection += pFunc;
00271   pTemp = GetIniString(m_bstrSqlSection, "Sql");
00272   if (*pTemp)
00273   {
00274     SubstituteParameters(m_bstrSql, pTemp, pArgs);
00275   }
00276   else
00277   {
00278     m_bstrSqlSection = L"sql default";
00279     pTemp = GetIniString(m_bstrSqlSection, "Sql");
00280     if (*pTemp)
00281       m_bstrSql = pTemp;
00282     else
00283       m_bstrSql = str;
00284   }
00285 }
00286
00287
00288 //
00289 // SetSection is an internal function used to set the INI file section names.
00290 //
00291 void CUtil::SetSection(void)
00292 {
00293   CHAR *pTemp;
00294
00295   m_bstrSectionName = m_bstrDatasource;
00296   m_bstrSectionConn = L"connect ";
00297   m_bstrSectionConn += m_bstrSectionName;
00298   pTemp = GetIniString(m_bstrSectionConn, "Access");
00299   if (!*pTemp)
00300   {
00301     m_bstrSectionName = L"default";
00302     m_bstrSectionConn = L"connect default";
00303   }
00304   m_bstrSectionUserlist = L"userlist ";
00305   m_bstrSectionUserlist += m_bstrSectionName;
00306 }
00307
00308
00309 //
00310 // DecodeAccess will decode an "Access" string from the INI file.
00311 //
00312 static long DecodeAccess(CHAR *pszAccess)
00313 {
00314   long lAccess = UTIL_NOACCESS;
00315
00316   if (pszAccess && *pszAccess)
00317   {
00318     if (!_stricmp(pszAccess, "ReadOnly"))
00319       lAccess = UTIL_READONLY;
00320     if (!_stricmp(pszAccess, "ReadWrite"))
00321       lAccess = UTIL_READWRITE;
00322   }
00323
00324   return lAccess;
00325 }
00326
00327
00328 void CUtil::SetConn(BSTR conn)
00329 {
00330   CHAR *pTemp;
00331   WCHAR *pConn = conn ? conn : L"";
00332
00333   // Parse the connection string for the value of "Data Source".
00334   ParseConn(pConn);
00335
00336   // Figure out the section names.
00337   SetSection();
00338
00339   // Get the override for the connection string, if any.
00340   pTemp = GetIniString(m_bstrSectionConn, "Connect");
00341   if (*pTemp)
00342     m_bstrConn = pTemp;
00343   else
00344     m_bstrConn = pConn;
00345
00346   // Get the connect access.
00347   pTemp = GetIniString(m_bstrSectionConn, "Access");
00348   m_lAccess = DecodeAccess(pTemp);
00349
00350   if (m_pszUsername[0])
00351   {
00352     pTemp = GetIniString(m_bstrSectionUserlist, m_pszUsername);
00353     if (*pTemp)
00354       m_lAccess = DecodeAccess(pTemp);
00355   }
00356 }
00357
00358
00359 //
00360 // FindDatasource will search for the "Data Source" name/value pair
00361 // in a connection string.  It will either return a pointer to the value
00362 // or return NULL if not found.
00363 //
00364 static WCHAR * FindDatasource(WCHAR *pwszConn)
00365 {
00366   WCHAR *pwszCurr;
00367   WCHAR *pwszEq;
00368
00369   if (!pwszConn)
00370     return NULL;
00371
00372   pwszCurr = pwszConn;
00373   while(1)
00374   {
00375     // Search for next name/value pair.
00376     pwszEq = wcschr(pwszCurr, L'=');
00377     if (!pwszEq)
00378       break;
00379
00380     // Check the length of the name first.
00381     if ((pwszEq-pwszCurr) == s_cDatasource)
00382     {
00383       // Now check the name.
00384       // NOTE: _wcsnicmp does not work in general, but works for ASCII constants.
00385       if (!_wcsnicmp(pwszCurr, s_wszDatasource, s_cDatasource))
00386         return pwszEq+1;
00387     }
00388
00389     // Move on to the next name/value pair.
00390     pwszCurr = wcschr(pwszEq, L';');
00391     if (!pwszCurr)
00392       break;
00393     pwszCurr++;
00394   }
00395   return NULL;
00396 }
00397
00398
00399 //
00400 // ParseConn will parse a connection string for the value of the
00401 // "Data Source" name/value pair.  If it is not found, it will be "default".
00402 //
00403 void CUtil::ParseConn(WCHAR *conn)
00404 {
00405   assert(conn);
00406   WCHAR *pwszValue;
00407   WCHAR *pwszSemi;
00408   CUtilString bstrTemp(conn, true);
00409
00410   m_bstrDatasource = L"default";
00411
00412   // Search for the "Data Source" name/value pair.
00413   pwszValue = FindDatasource(bstrTemp);
00414   if (!pwszValue)
00415     return;
00416
00417   // See if there is more connection string after the value.
00418   pwszSemi = wcschr(pwszValue, L';');
00419   if (pwszSemi)
00420     *pwszSemi = L'\0';
00421
00422   // Save off the value of "Data Source".
00423   m_bstrDatasource = pwszValue;
00424 }
00425
00426
00427 #ifdef UTILTEST
00428 // This lets you test your parsing changes.
00429 #include "utiltest.cpp"
00430 #endif
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

params Member List

This is the complete list of members for params, including all inherited members.
bInProcess | params
dwObjectType | params
dwThreadType | params
szMachine | params
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpcmenu/dsmenu.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpcmenu

dsmenu.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       dsmenu.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef __DSMENU_H
00012 #define __DSMENU_H
00013
00014 class CContextMenu:
00015   IShellExtInit,
00016   IContextMenu,
00017   public CComObjectRoot,
00018   public CComCoClass<CContextMenu, &CLSID_SCPContextMenu>
00019 {
00020   BEGIN_COM_MAP(CContextMenu)
00021     COM_INTERFACE_ENTRY(IShellExtInit)
00022     COM_INTERFACE_ENTRY(IContextMenu)
00023   END_COM_MAP()
00024
00025 public:
00026   DECLARE_REGISTRY_CLSID()
00027
00028   CContextMenu();
00029   ~CContextMenu();
00030
00031   //
00032   // IShellExtInit
00033   //
00034   STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder,
00035                           LPDATAOBJECT pDataObj,
00036                           HKEY hKeyID );
00037
00038   //
00039   // IContextMenu
00040   //
00041   STDMETHODIMP QueryContextMenu(HMENU hShellMenu,
00042                                 UINT indexMenu,
00043                                 UINT idCmdFirst,
00044                                 UINT idCmdLast,
00045                                 UINT uFlags );
00046   STDMETHODIMP InvokeCommand( LPCMINVOKECOMMANDINFO lpcmi );
00047   STDMETHODIMP GetCommandString( UINT_PTR idCmd,
00048                                  UINT uFlags,
00049                                  UINT FAR* reserved,
00050                                  LPSTR pszName,
00051                                  UINT ccMax );
00052
00053   void ShowClipformatInfo();
00054
00055 private:
00056   CComPtr<IDataObject>  m_spDataObj;
00057 };
00058
00059 #endif // __DSMENU_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/RSM/mll/stl_mll.cpp Source File

  • WinBase
  • IO
  • RSM
  • mll

stl_mll.cpp

Go to the documentation of this file.
00001 /*
00002  *  This is a part of the Microsoft Source Code Samples.
00003  *  Copyright 1996 - 1998 Microsoft Corporation.
00004  *  All rights reserved.
00005  *
00006  *  This sample code shows the usage of some portions
00007  *  of the NTMS API.
00008  *
00009  *  Return codes are, for the most part, not checked in
00010  *  this code. See the Programmer's reference for error
00011  *  return information.
00012  *
00013  *  DLL must be built with standard calling convention (/Gz)
00014  *
00015  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00016  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00017  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018  * PARTICULAR PURPOSE.
00019  *
00020  * Copyright 1997 - 1998 Microsoft Corporation.  All Rights Reserved. *
00021  */
00022 #include <windows.h>
00023 #include "..\inc\stl.h"
00024 #include "STL_mll.h"
00025
00026 static DWORD GetMediaGuid(wchar_t *pDescription, WORD size, GUID &gMediaGuid);
00027
00028
00029 RSM_APPSAMPLE_LABEL_EXPORT DWORD WINAPI ClaimMediaLabel(const BYTE * const pBuffer, const DWORD nBufferSize,
00030           MediaLabelInfo * const pLabelInfo)
00031 {
00032   DWORD nError = NO_ERROR;
00033   STL_LABEL *pLabel;
00034   GUID gMediaGuid;
00035
00036
00037   // Go through the label and look at each field.  If something is seen that isn't STL, then bail
00038   // If this MLL is to recognize all instances of STL, then perhaps it should only check the first
00039   // two fields, since multiple applications and vendors could write STL.  If the intent is to
00040   // only recognize STL written by a particular app then the vendor and app fields are checked. That's
00041   // the way this sample is done.
00042   pLabel = (STL_LABEL *) pBuffer;
00043   if (wcsncmp ((wchar_t *)pLabel->LabelType, STL_LABEL_LabelType, STL_LABEL_LabelTypeSize/sizeof(WCHAR)))
00044     return ERROR_BAD_FORMAT;
00045
00046   if(wcsncmp((wchar_t *)pLabel->LabelVersion, STL_LABEL_Version, STL_LABEL_VersionSize/sizeof(WCHAR)))
00047     return ERROR_BAD_FORMAT;
00048
00049   if(wcsncmp((wchar_t *)pLabel->Vendor, STL_LABEL_Vendor, STL_LABEL_VendorSize/sizeof(WCHAR)))
00050     return ERROR_BAD_FORMAT;
00051
00052   if(wcsncmp((wchar_t *)pLabel->Application, STL_LABEL_Application, STL_LABEL_ApplicationSize/sizeof(WCHAR)))
00053     return ERROR_BAD_FORMAT;
00054
00055
00056   // OK, found an instance of STL, now populate the MediaLabelInfo structure to pass back to RSM
00057   memset(pLabelInfo, 0, sizeof(MediaLabelInfo));
00058   wcsncpy(pLabelInfo->LabelType, (wchar_t *) pLabel->LabelType, (STL_LABEL_LabelTypeSize/sizeof(WCHAR))-1);
00059
00060   if(GetMediaGuid((wchar_t *)pLabel->MediaID, STL_LABEL_MediaIDSize, gMediaGuid) == NO_ERROR)
00061   {
00062     pLabelInfo->LabelIDSize = sizeof(gMediaGuid);
00063     memcpy(pLabelInfo->LabelID, &gMediaGuid, sizeof(gMediaGuid));
00064   }
00065   else
00066     // Whoops, we got a valid STL instance, but the app screwed up the GUID
00067     // A real MLL could try to recover, or just bail.  Here we bail.
00068     return ERROR_BAD_FORMAT;
00069
00070   wcsncpy(pLabelInfo->LabelAppDescr, (wchar_t *) pLabel->TapeName, (STL_LABEL_TapeNameSize/sizeof(WCHAR))-1);
00071
00072   return NO_ERROR;
00073 }
00074
00075
00076 RSM_APPSAMPLE_LABEL_EXPORT DWORD WINAPI MaxMediaLabel (DWORD * const pMaxSize)
00077 {
00078   // local variables
00079   DWORD nError = NO_ERROR ;
00080
00081   // set the max size for the sample label in terms of 512 blocks
00082   *pMaxSize = 512 * ((sizeof(STL_LABEL) / 512)+1);
00083
00084   return nError ;
00085 }
00086
00087 #define HEX_0 L'0'
00088 #define HEX_9 L'9'
00089 #define HEX_A L'A'
00090 #define HEX_F L'F'
00091 #define OUR_STRING wchar_t*
00092 #define OUR_BAR L'|'
00093 #define OUR_BRACE L'{'
00094
00095 static DWORD ConvertHex(const wchar_t * str, const int length)
00096 {
00097   DWORD value = 0;
00098   for(int i=0;i<length;i++){
00099     value = value << 4;
00100     if(str[i] >= HEX_A && str[i] <= HEX_F){
00101       value += str[i]-'A'+10;
00102     } else if(str[i] >= HEX_0 && str[i] <= HEX_9){
00103       value += str[i]-HEX_0;
00104     }
00105   }
00106   return value;
00107 }
00108
00109 static DWORD GetMediaGuid(wchar_t * pDescription, WORD size, GUID &gMediaGuid)
00110 {
00111
00112     int numChars = size / sizeof(wchar_t);
00113
00114   wchar_t * pId = pDescription;
00115
00116   // check all the "syntactic sugar" characters as a check to insure this
00117   // is a valid GUID
00118   if((pId[0] != '{') ||
00119     (pId[9] != '-') ||
00120     (pId[14] != '-') ||
00121     (pId[19] != '-') ||
00122     (pId[24] != '-') ||
00123     (pId[37] != '}'))
00124     return ERROR_BAD_FORMAT;
00125
00126   // now pick the GUID fields out of the string
00127   gMediaGuid.Data1 = ConvertHex(pId,8);
00128   pId += 9;
00129   gMediaGuid.Data2 = (WORD)ConvertHex(pId,4);
00130   pId += 5;
00131   gMediaGuid.Data3 = (WORD)ConvertHex(pId,4);
00132   pId += 5;
00133   int i;
00134   for(i=0;i<2;i++){
00135     gMediaGuid.Data4[i] = (BYTE)ConvertHex(pId,2);
00136     pId += 2;
00137   }
00138   pId++;
00139   for(i=2;i<8;i++){
00140     gMediaGuid.Data4[i] = (BYTE)ConvertHex(pId,2);
00141     pId += 2;
00142   }
00143   pId++;
00144
00145     return NO_ERROR;
00146 }
00147
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/cleanup.cpp Source File

  • WinUI
  • TSFmark

cleanup.cpp

Go to the documentation of this file.
00001 //
00002 // cleanup.cpp
00003 //
00004 // ITfCleanupContextDurationSink, ITfCleanupContextSink implementation.
00005 //
00006
00007 #include "globals.h"
00008 #include "mark.h"
00009
00010 //+---------------------------------------------------------------------------
00011 //
00012 // ITfCleanupContextDurationSink::OnStartCleanupContext
00013 //
00014 // TSF calls this method before it starts making OnCleanupContext callbacks.
00015 // When this happens, we know we're just about to be shut down, and this will
00016 // be our last chance to modify text in the document.  So we'll set a flag so
00017 // we know not to initialize any contexts that might get created during the
00018 // shutdown.
00019 //----------------------------------------------------------------------------
00020
00021 STDAPI CMarkTextService::OnStartCleanupContext()
00022 {
00023     _fCleaningUp = TRUE;
00024     return S_OK;
00025 }
00026
00027 //+---------------------------------------------------------------------------
00028 //
00029 // ITfCleanupContextDurationSink::OnEndCleanupContext
00030 //
00031 // Clear the cleanup flag.
00032 //----------------------------------------------------------------------------
00033
00034 STDAPI CMarkTextService::OnEndCleanupContext()
00035 {
00036     _fCleaningUp = FALSE;
00037     return S_OK;
00038 }
00039
00040 //+---------------------------------------------------------------------------
00041 //
00042 // ITfCleanupContextSink::OnCleanupContext
00043 //
00044 // The system calls this method if we're about to be deactivated.  It's our
00045 // last chance to modify text in the context.  This is the time to abort any
00046 // ongoing compositions.
00047 //
00048 // You won't see this callback shutting down the app if the app destroys all
00049 // contexts before deactivating TSF.  Another way to get here is by installing
00050 // a non-english keyboard layout or text service.  If you switch languages
00051 // from english, the mark text service will be shut down before the context,
00052 // and this method will be called.
00053 //
00054 // There's intentionally no way to get an edit cookie when a context is popped.
00055 // In this case, it is assumed the context state is going to be thrown away.
00056 // It's the owner's responsibility to terminate any compositions/text services
00057 // before a Pop if they care about the contents afterwards.
00058 //----------------------------------------------------------------------------
00059
00060 STDAPI CMarkTextService::OnCleanupContext(TfEditCookie ecWrite, ITfContext *pContext)
00061 {
00062     // this sample has nothing to do here...a real text service wouldn't bother
00063     // to advise the sink in the first place if it took no action
00064     return S_OK;
00065 }
00066
00067 //+---------------------------------------------------------------------------
00068 //
00069 // _InitCleanupContextSink
00070 //
00071 //----------------------------------------------------------------------------
00072
00073 BOOL CMarkTextService::_InitCleanupContextDurationSink()
00074 {
00075     return AdviseSingleSink(_tfClientId, _pThreadMgr, (ITfCleanupContextDurationSink *)this,
00076                             IID_ITfCleanupContextDurationSink);
00077 }
00078
00079 //+---------------------------------------------------------------------------
00080 //
00081 // _UninitCleanupContextSink
00082 //
00083 //----------------------------------------------------------------------------
00084
00085 void CMarkTextService::_UninitCleanupContextDurationSink()
00086 {
00087     UnadviseSingleSink(_tfClientId, _pThreadMgr, IID_ITfCleanupContextDurationSink);
00088 }
00089
00090 //+---------------------------------------------------------------------------
00091 //
00092 // _InitCleanupContextSink
00093 //
00094 //----------------------------------------------------------------------------
00095
00096 BOOL CMarkTextService::_InitCleanupContextSink(ITfContext *pContext)
00097 {
00098     return AdviseSingleSink(_tfClientId, pContext, (ITfCleanupContextSink *)this,
00099                             IID_ITfCleanupContextSink);
00100 }
00101
00102 //+---------------------------------------------------------------------------
00103 //
00104 // _UninitCleanupContextSink
00105 //
00106 //----------------------------------------------------------------------------
00107
00108 void CMarkTextService::_UninitCleanupContextSink(ITfContext *pContext)
00109 {
00110     UnadviseSingleSink(_tfClientId, pContext, IID_ITfCleanupContextSink);
00111 }
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_Recordset Member List

This is the complete list of members for msado15::_Recordset, including all inherited members.
_xClone() | msado15::_Recordset |
_xResync(int AffectRecords) | msado15::_Recordset |
_xSave(String FileName, int PersistFormat) | msado15::_Recordset |
AddNew(Variant FieldList, Variant Values) | msado15::_Recordset |
Cancel() | msado15::_Recordset |
CancelBatch(int AffectRecords) | msado15::_Recordset |
CancelUpdate() | msado15::_Recordset |
Clone(int LockType) | msado15::_Recordset |
Close() | msado15::_Recordset |
CompareBookmarks(Variant Bookmark1, Variant Bookmark2) | msado15::_Recordset |
Delete(int AffectRecords) | msado15::_Recordset |
Find(String Criteria, int SkipRecords, int SearchDirection, Variant Start) | msado15::_Recordset |
getAbsolutePage() | msado15::_Recordset |
getAbsolutePosition() | msado15::_Recordset |
getActiveCommand() | msado15::_Recordset |
getActiveConnection() | msado15::_Recordset |
getBOF() | msado15::_Recordset |
getBookmark() | msado15::_Recordset |
getCacheSize() | msado15::_Recordset |
getCollect(Variant Index) | msado15::_Recordset |
getCursorLocation() | msado15::_Recordset |
getCursorType() | msado15::_Recordset |
getDataMember() | msado15::_Recordset |
getDataSource() | msado15::_Recordset |
getEditMode() | msado15::_Recordset |
getEOF() | msado15::_Recordset |
getFields() | msado15::_Recordset |
getFilter() | msado15::_Recordset |
getIndex() | msado15::_Recordset |
getLockType() | msado15::_Recordset |
getMarshalOptions() | msado15::_Recordset |
getMaxRecords() | msado15::_Recordset |
getPageCount() | msado15::_Recordset |
getPageSize() | msado15::_Recordset |
getProperties() | msado15::_Recordset |
getRecordCount() | msado15::_Recordset |
GetRows(int Rows, Variant Start, Variant Fields) | msado15::_Recordset |
getSort() | msado15::_Recordset |
getSource() | msado15::_Recordset |
getState() | msado15::_Recordset |
getStatus() | msado15::_Recordset |
getStayInSync() | msado15::_Recordset |
GetString(int StringFormat, int NumRows, String ColumnDelimeter, String RowDelimeter, String NullExpr) | msado15::_Recordset |
iid | msado15::_Recordset | [static]
Move(int NumRecords, Variant Start) | msado15::_Recordset |
MoveFirst() | msado15::_Recordset |
MoveLast() | msado15::_Recordset |
MoveNext() | msado15::_Recordset |
MovePrevious() | msado15::_Recordset |
NextRecordset(Variant RecordsAffected) | msado15::_Recordset |
Open(Variant Source, Variant ActiveConnection, int CursorType, int LockType, int Options) | msado15::_Recordset |
Requery(int Options) | msado15::_Recordset |
Resync(int AffectRecords, int ResyncValues) | msado15::_Recordset |
Save(Variant Destination, int PersistFormat) | msado15::_Recordset |
Seek(Variant KeyValues, int SeekOption) | msado15::_Recordset |
setAbsolutePage(int pl) | msado15::_Recordset |
setAbsolutePosition(int pl) | msado15::_Recordset |
setActiveConnection(Object pvar) | msado15::_Recordset |
setActiveConnection(Variant pvar) | msado15::_Recordset |
setBookmark(Variant pvBookmark) | msado15::_Recordset |
setCacheSize(int pl) | msado15::_Recordset |
setCollect(Variant Index, Variant pvar) | msado15::_Recordset |
setCursorLocation(int plCursorLoc) | msado15::_Recordset |
setCursorType(int plCursorType) | msado15::_Recordset |
setDataMember(String pbstrDataMember) | msado15::_Recordset |
setDataSource(IUnknown ppunkDataSource) | msado15::_Recordset |
setFilter(Variant Criteria) | msado15::_Recordset |
setIndex(String pbstrIndex) | msado15::_Recordset |
setLockType(int plLockType) | msado15::_Recordset |
setMarshalOptions(int peMarshal) | msado15::_Recordset |
setMaxRecords(int plMaxRecords) | msado15::_Recordset |
setPageSize(int pl) | msado15::_Recordset |
setSort(String Criteria) | msado15::_Recordset |
setSource(Object pvSource) | msado15::_Recordset |
setSource(String pvSource) | msado15::_Recordset |
setStayInSync(boolean pbStayInSync) | msado15::_Recordset |
Supports(int CursorOptions) | msado15::_Recordset |
Update(Variant Fields, Variant Values) | msado15::_Recordset |
UpdateBatch(int AffectRecords) | msado15::_Recordset |
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRowPosition Member List

This is the complete list of members for CRowPosition, including all inherited members.
AdviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
AutoQI(DWORD dwCreateOpts) | CRowPosition | [virtual]
AutoRelease() | CRowPosition | [virtual]
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CContainerBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CContainerBase |
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
CRowPosition(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRowPosition |
DisplayObject() | CBase | [virtual]
FindConnectionPoint(REFIID riid, IConnectionPoint **ppIConnectionPoint) | CContainerBase | [virtual]
GetBaseType() | CBase | [inline]
GetDefaultInterface() | CRowPosition | [inline, virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CRowPosition | [virtual]
GetObjectDesc() | CBase | [inline, virtual]
GetObjectImage() | CRowPosition | [inline, virtual]
GetObjectMenu() | CRowPosition | [inline, virtual]
GetObjectName() | CRowPosition | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetParent(SOURCE eSource) | CBase | [virtual]
GetRowset(REFIID riid, IUnknown **ppIUnknown) | CRowPosition | [virtual]
Initialize(IUnknown *pIUnkRowset) | CRowPosition | [virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_cRef | CBase | [protected]
m_dwCLSCTX | CBase |
m_dwCookieRowPos | CRowPosition |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_guidSource | CBase |
m_hTreeItem | CBase |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pIConnectionPointContainer | CContainerBase |
m_pIRowPosition | CRowPosition |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_strObjectDesc | CBase | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
UnadviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
~CBase() | CBase | [virtual]
~CContainerBase() | CContainerBase | [virtual]
~CRowPosition() | CRowPosition | [virtual]
Generated on Wed Nov 13 2024 16:57:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditGlyphs/StdAfx.h Source File

  • Web
  • Browser
  • EditGlyphs

StdAfx.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.h : include file for standard system include files,
00006 //      or project specific include files that are used frequently,
00007 //      but are changed infrequently
00008
00009 #if !defined(AFX_STDAFX_H__BC7206F5_CB70_47F2_9618_23FA71903CFA__INCLUDED_)
00010 #define AFX_STDAFX_H__BC7206F5_CB70_47F2_9618_23FA71903CFA__INCLUDED_
00011
00012 #if _MSC_VER > 1000
00013 #pragma once
00014 #endif // _MSC_VER > 1000
00015
00016 #define STRICT
00017 #ifndef _WIN32_WINNT
00018 #define _WIN32_WINNT 0x0400
00019 #endif
00020 #define _ATL_APARTMENT_THREADED
00021
00022 #include <atlbase.h>
00023
00024 //You may derive a class from CComModule and use it if you want to override
00025 //something, but do not change the name of _Module
00026 class CExeModule : public CComModule
00027 {
00028 public:
00029   LONG Unlock();
00030   DWORD dwThreadID;
00031   HANDLE hEventShutdown;
00032   void MonitorShutdown();
00033   bool StartMonitor();
00034   bool bActivity;
00035 };
00036 extern CExeModule _Module;
00037 #include <atlcom.h>
00038
00039 //{{AFX_INSERT_LOCATION}}
00040 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00041
00042 #endif // !defined(AFX_STDAFX_H__BC7206F5_CB70_47F2_9618_23FA71903CFA__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MYXFORM Member List

This is the complete list of members for _MYXFORM, including all inherited members.
xForm _MYXFORM
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPoint Member List

This is the complete list of members for CPoint, including all inherited members.
CPoint() | CPoint | [inline]
CPoint(COORD X, COORD Y) | CPoint | [inline]
CPoint(POINT pt) | CPoint | [inline]
CPoint() | CPoint | [inline]
get_x(long *pVal) | CPoint |
get_y(long *pVal) | CPoint |
GetClassID(CLSID *pClassID) | IMyPersistStreamImpl< CPoint > | [inline]
GetSizeMax(ULARGE_INTEGER FAR *pcbSize) | IMyPersistStreamImpl< CPoint > | [inline]
IMyPersistStreamImpl_GetSizeMax(ULARGE_INTEGER FAR *pcbSize) | CPoint |
IMyPersistStreamImpl_Load(LPSTREAM pStm) | CPoint |
IMyPersistStreamImpl_Save(LPSTREAM pStm, BOOL fClearDirty) | CPoint |
IsDirty() | IMyPersistStreamImpl< CPoint > | [inline]
Load(LPSTREAM pStm) | IMyPersistStreamImpl< CPoint > | [inline]
m_bRequiresSave | CPoint |
m_Point | CPoint | [private]
operator*(int c) | CPoint | [inline]
operator+(CPoint &pt) | CPoint | [inline]
operator-(CPoint &pt) | CPoint | [inline]
operator/(int c) | CPoint | [inline]
put_x(long newVal) | CPoint |
put_y(long newVal) | CPoint |
QueryInterface(REFIID riid, void **ppvObject)=0 | IMyPersistStreamImpl< CPoint > | [pure virtual]
Save(LPSTREAM pStm, BOOL fClearDirty) | IMyPersistStreamImpl< CPoint > | [inline]
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsimple/common.h Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsimple

common.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Server System Service
00006
00007     FILE: Service.h
00008
00009     PURPOSE: Provides file replication service function declarations.
00010
00011     FUNCTIONS:
00012
00013     COMMENTS: These funtions may be used by the main service routines
00014         as well as by the client and server file replication RPC routines.
00015
00016 */
00017
00018 #pragma once
00019
00020 #include <windows.h>
00021 #include <crtdbg.h>
00022
00023 // Macro for printing out error message and exiting the program if an
00024 // error occured during an RPC library call.
00025 #define EXIT_IF_FAIL(x, string){ \
00026         ((x) != RPC_S_OK) ? _tprintf(TEXT("%s failed with error %d\n"), \
00027         TEXT(string), (x)), exit(EXIT_FAILURE) : 0;}
00028
00029 // Make sure the ASSERTE macro is defined.
00030 #ifndef ASSERTE
00031 #define ASSERTE _ASSERTE
00032 #endif
00033
00034 // Size for short message strings.
00035 #define MSG_SIZE (256)
00036
00037 VOID * AutoHeapAlloc(size_t dwBytes);
00038
00039 VOID AutoHeapFree(VOID * lpMem);
00040
00041 // end common.h
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/rowset.h Source File

  • Dataaccess
  • oledb
  • sampprov

rowset.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module ROWSET.H | CRowset base object and contained interface
00008 // definitions
00009 //
00010 //
00011 #ifndef _ROWSET_H_
00012 #define _ROWSET_H_
00013
00014
00015 #include "fileio.h"
00016 #include "bitarray.h"
00017 #include "extbuff.h"
00018 #include "hashtbl.h"
00019 #include "command.h"
00020 #include "baseobj.h"
00021
00022 #include "dbsess.h"
00023
00024 // Forward declarations ------------------------------------------------------
00025
00026 class CImpIRowset;
00027 class CImpIRowsetChange;
00028 class CImpIColumnsInfo;
00029 class CImpIAccessor;
00030 class CImpIRowsetInfo;
00031 class CImpIRowsetIdentity;
00032 class CImpIConvertType;
00033 class CImpIGetRow;
00034
00035 typedef CImpIRowset*    PIMPIROWSET;
00036 typedef CImpIRowsetChange*  PIMPIROWSETCHANGE;
00037 typedef CImpIColumnsInfo* PIMPICOLUMNSINFO;
00038 typedef CImpIAccessor *   PIMPIACCESSOR;
00039 typedef CImpIRowsetIdentity*PIMPIROWSETIDENTITY;
00040 typedef CImpIRowsetInfo*  PIMPIROWSETINFO;
00041 typedef CImpIConvertType* PIMPICONVERTTYPE;
00042 typedef CImpIGetRow*    PIMPIGETROW;
00043
00044 // General Helper Function
00045 HRESULT GetInternalTypeFromCSVType(SWORD swDataType, BOOL fIsSigned, DWORD* pdwdbType);
00046
00047
00048 // Classes -------------------------------------------------------------------
00049
00050 //----------------------------------------------------------------------------
00051 // @class CRowset | Rowset object. Containing class for all interfaces on the Rowset
00052 // Object
00053 //
00054 class CRowset : public CBaseObj         //@base public | CBaseObj
00055 {
00056   //  Contained interfaces are friends
00057   friend class CImpIColumnsInfo;
00058   friend class CImpIRowset;
00059   friend class CImpIRowsetChange;
00060   friend class CImpIAccessor;
00061   friend class CImpIRowsetIdentity;
00062   friend class CImpIRowsetInfo;
00063   friend class CImpIConvertType;
00064   friend class CImpIGetRow;
00065
00066   // Row object interfaces are friends
00067   // since row object can have implicit rowset context
00068   friend class CRow;
00069   friend class CImpIRow;
00070   friend class CImpIGetSession;
00071   friend class CImpIRowChange;
00072
00073   private: //@access private
00074     //@cmember Creates Helper Classes
00075     HRESULT CreateHelperFunctions(void);
00076     //@cmember Returns the Buffer Pointer for the specified row
00077     ROWBUFF* GetRowBuff(DBCOUNTITEM iRow, BOOL fDataLocation = FALSE);
00078     //@cmember Establishes the data area bindings
00079     HRESULT Rebind(BYTE* pBase);
00080     //@cmember Establishes the data area bindings
00081     BOOL SupportIRowsetChange();
00082
00083   protected: //@access protected
00084     //@cmember File Manipulation Class
00085     CFileIO*            m_pFileio;
00086     //@cmember Count of Columns in Result Set
00087     DBORDINAL           m_cCols;
00088     //@cmember array of accessor ptrs
00089     LPEXTBUFFER             m_pextbufferAccessor;
00090     //@cmember internal buffer structure
00091     PLSTSLOT                m_pIBuffer;
00092     //@cmember bit array to mark active rows
00093     LPBITARRAY            m_prowbitsIBuffer;
00094     //@cmember size of row data in the buffer
00095     DBLENGTH                  m_cbRowSize;
00096     //@cmember size of row in the buffer
00097     ULONG                   m_cbTotalRowSize;
00098     //@cmember points to the first buffered row
00099     BYTE*             m_rgbRowData;
00100     //@cmember index of the first available rowbuffer
00101     ULONG             m_irowMin;
00102     //@cmember current # of rows in the buffer
00103     DBCOUNTITEM               m_cRows;
00104     //@cmember position in the resultset
00105     DBCOUNTITEM               m_irowFilePos;
00106     //@cmember Start of the rowset
00107     DBCOUNTITEM           m_irowLastFilePos;
00108     //@cmember status word for the entire cursor
00109     UDWORD                  m_dwStatus;
00110     //@cmember remember last binding location
00111     BYTE*             m_pLastBindBase;
00112     //@cmember RefCount of all outstanding row handles
00113     DBREFCOUNT                m_ulRowRefCount;
00114         //@cmember Object that created this rowset
00115     CBaseObj*           m_pParentObj;
00116     //@member Utility object to manage properties
00117     PCUTILPROP            m_pUtilProp;
00118     //@cmember File Path Name
00119     WCHAR             m_wszFilePath[MAX_PATH];
00120     //@cmember Data Source Path Name
00121     WCHAR             m_wszDataSourcePath[MAX_PATH];
00122
00123     // Interface and OLE Variables
00124
00125     //@cmember Reference count
00126     DBREFCOUNT            m_cRef;
00127     //@cmember Contained IColumnsInfo
00128     PIMPICOLUMNSINFO        m_pIColumnsInfo;
00129     //@cmember Contained IRowset
00130     PIMPIROWSET           m_pIRowset;
00131     //@cmember Contained IRowsetChange
00132     PIMPIROWSETCHANGE       m_pIRowsetChange;
00133     //@cmember Contained IAccessor
00134     PIMPIACCESSOR         m_pIAccessor;
00135     //@cmember Contained IRowsetIdentity
00136     PIMPIROWSETIDENTITY       m_pIRowsetIdentity;
00137     //@cmember Contained IRowsetInfo
00138     PIMPIROWSETINFO         m_pIRowsetInfo;
00139     //@cmember Contained IConvertType
00140     PIMPICONVERTTYPE        m_pIConvertType;
00141     //@cmember Contained IGetRow
00142     PIMPIGETROW           m_pIGetRow;
00143
00144   public: //@access public
00145     //@cmember Constructor
00146      CRowset(LPUNKNOWN);
00147     //@cmember Destructor
00148     ~CRowset(void);
00149
00150     //@cmember Intitialization Routine
00151     BOOL FInit(CFileIO*, CBaseObj*, WCHAR* pwszFileName, WCHAR* pwszDataSource);
00152     //@cmember Return the CUtilProp object
00153     inline PCUTILPROP GetCUtilProp() { return m_pUtilProp; };
00154     //@cmember Return m_pFileio
00155     inline CFileIO* GetFileObj() { return m_pFileio; };
00156
00157     //  Object's base IUnknown
00158     //@cmember Request an Interface
00159     STDMETHODIMP        QueryInterface(REFIID, LPVOID *);
00160     //@cmember Increments the Reference count
00161     STDMETHODIMP_(DBREFCOUNT) AddRef(void);
00162     //@cmember Decrements the Reference count
00163     STDMETHODIMP_(DBREFCOUNT) Release(void);
00164
00165     //Back pointer to a parent cmd object.
00166     PCCOMMAND       m_pCreator;
00167 };
00168
00169 typedef CRowset *PCROWSET;
00170
00171
00172 //----------------------------------------------------------------------------
00173 // @class CImpIRowset | Contained IRowset class
00174 //
00175 class CImpIRowset : public IRowset    //@base public | IRowset
00176 {
00177   private: //@access private
00178     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
00179
00180   public: //@access public
00181     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowset);
00182     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00183
00184     //  IRowset members
00185     //@cmember GetData Method
00186     STDMETHODIMP  GetData(HROW, HACCESSOR, void*);
00187     //@cmember GetNextRows Method
00188     STDMETHODIMP  GetNextRows(HCHAPTER, DBROWOFFSET, DBROWCOUNT, DBCOUNTITEM*, HROW**);
00189         //cmember ReleaseRows method
00190     STDMETHODIMP  ReleaseRows(DBCOUNTITEM, const HROW rghRows[], DBROWOPTIONS rgRowOptions[], DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[]);
00191         //@cmember RestartPosition method
00192     STDMETHODIMP  RestartPosition(HCHAPTER);
00193         //@cmember AddRefRows method
00194         STDMETHODIMP  AddRefRows(DBCOUNTITEM, const HROW rghRows[], DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[]);
00195 };
00196
00197
00198 //----------------------------------------------------------------------------
00199 // @class CImpIRowsetChange | Contained IRowsetChange class
00200 //
00201 class CImpIRowsetChange : public IRowsetChange  //@base public | IRowsetChange
00202 {
00203   private: //@access private
00204     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
00205
00206   public: //@access public
00207
00208     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetChange);
00209     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00210
00211     //  IRowsetChange members
00212     //@cmember SetData Method
00213       STDMETHODIMP  SetData(HROW, HACCESSOR, void*);
00214       STDMETHODIMP  DeleteRows(HCHAPTER, DBCOUNTITEM, const HROW rghRows[], DBROWSTATUS rgRowStatus[]);
00215     STDMETHODIMP    InsertRow(HCHAPTER hChapter,HACCESSOR hAccessor, void* pData, HROW* phRow);
00216 };
00217
00218
00219 //----------------------------------------------------------------------------
00220 // @class CImpIColumnsInfo | Contained IColumnsInfo class
00221 //
00222 class CImpIColumnsInfo : public IColumnsInfo    //@base public | IColumnsInfo
00223 {
00224   private: //@access private
00225     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CBaseObj)
00226
00227   public: //@access public
00228     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIColumnsInfo);
00229     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00230
00231     //  IColumnsInfo members
00232     //@cmember GetColumnInfo method
00233       STDMETHODIMP  GetColumnInfo(DBORDINAL*, DBCOLUMNINFO**, WCHAR**);
00234     //@cmember MapColumnIDs
00235     STDMETHODIMP  MapColumnIDs(DBORDINAL, const DBID rgColumnIDs[], DBORDINAL rgColumns[]);
00236 };
00237
00238
00239
00240 //----------------------------------------------------------------------------
00241 // @class CImpIRowsetInfo | Contained IRowsetInfo class
00242 //
00243 class CImpIRowsetInfo : public IRowsetInfo    //@base public | IRowsetInfo
00244 {
00245   private: //@access private
00246     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
00247
00248   public: //@access public
00249     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetInfo);
00250     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00251
00252     //@cmember GetReferencedRowset
00253     STDMETHODIMP      GetReferencedRowset
00254       (
00255         DBORDINAL iOrdinal,
00256         REFIID    rrid,
00257         IUnknown**  ppReferencedRowset
00258       );
00259
00260     //@cmember GetProperties
00261     STDMETHODIMP      GetProperties
00262         (
00263           const ULONG     cPropertySets,
00264           const DBPROPIDSET rgPropertySets[],
00265           ULONG*              pcProperties,
00266           DBPROPSET**     prgProperties
00267         );
00268
00269     //@cmember GetSpecification Method
00270     STDMETHODIMP      GetSpecification(REFIID, IUnknown**);
00271 };
00272
00273
00274
00275 //----------------------------------------------------------------------------
00276 // @class CImpIRowsetIdentity | Contained IRowsetIdentity class
00277 //
00278 class CImpIRowsetIdentity : public IRowsetIdentity    //@base public | IRowsetIdentity
00279 {
00280   private: //@access private
00281     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
00282
00283   public: //@access public
00284     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetIdentity);
00285     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00286
00287     //@cmember IsSameRow
00288     STDMETHODIMP  IsSameRow
00289       (
00290         HROW hThisRow,
00291         HROW hThatRow
00292       );
00293 };
00294
00295
00296
00297 //----------------------------------------------------------------------------
00298 // @class CImpIConvertType | Contained IConvertType class
00299 //
00300 class CImpIConvertType : public IConvertType    //@base public | IConvertType
00301 {
00302   private: //@access private
00303     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CBaseObj)
00304
00305   public: //@access public
00306     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIConvertType);
00307     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00308
00309     //@cmember CanConvert
00310     STDMETHODIMP CImpIConvertType::CanConvert
00311       (
00312         DBTYPE      wFromType,    //@parm IN | src type
00313         DBTYPE      wToType,    //@parm IN | dst type
00314         DBCONVERTFLAGS  dwConvertFlags  //@parm IN | conversion flags
00315       );
00316 };
00317
00318
00319
00320 //----------------------------------------------------------------------------
00321 // @class CImpIGetRow | Contained IGetRow class
00322 //
00323 class CImpIGetRow : public IGetRow    //@base public | IGetRow
00324 {
00325   private: //@access private
00326     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
00327
00328   public: //@access public
00329     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIGetRow);
00330     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00331
00332     //  IGetRow members
00333     //@cmember GetRowFromHROW Method
00334     STDMETHODIMP GetRowFromHROW
00335       (
00336         IUnknown *  pIUnkOuter,
00337         HROW    hRow,
00338         REFIID    riid,
00339         IUnknown ** ppUnk
00340       );
00341
00342     //@cmember GetURLFromHROW Method
00343     STDMETHODIMP GetURLFromHROW
00344       (
00345         HROW    hRow,
00346         LPOLESTR *  ppwszURL
00347       );
00348 };
00349
00350
00351 #endif
00352
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

helper::DatabaseSettings Member List

This is the complete list of members for helper::DatabaseSettings, including all inherited members.
DSN | helper::DatabaseSettings | [static]
Pass | helper::DatabaseSettings | [static]
User | helper::DatabaseSettings | [static]
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/StdAfx.cpp Source File

  • Web
  • Browser
  • EditHost

StdAfx.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.cpp : source file that includes just the standard includes
00006 //  stdafx.pch will be the pre-compiled header
00007 //  stdafx.obj will contain the pre-compiled type information
00008
00009 #include "stdafx.h"
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/File.c Source File

  • Multimedia
  • Gdi
  • WinCap32

File.c

Go to the documentation of this file.
00001 //*******************************************************************
00002 //
00003 //  file.c
00004 //
00005 //  Source file for Device-Independent Bitmap (DIB) API.  Provides
00006 //  the following functions:
00007 //
00008 //  SaveDIB()           - Saves the specified dib in a file
00009 //  LoadDIB()           - Loads a DIB from a file
00010 //  DestroyDIB()        - Deletes DIB when finished using it
00011 //
00012 // Written by Microsoft Product Support Services, Developer Support.
00013 // Copyright 1991 - 2000 Microsoft Corporation. All rights reserved.
00014 //*******************************************************************
00015
00016 #define     STRICT      // enable strict type checking
00017
00018 #include <windows.h>
00019 #include <string.h>
00020 #include <stdio.h>
00021 #include <math.h>
00022 #include <io.h>
00023 #include <direct.h>
00024 #include <stdlib.h>
00025 #include "dibutil.h"
00026 #include "dibapi.h"
00027
00028
00029 // Dib Header Marker - used in writing DIBs to files
00030
00031 #define DIB_HEADER_MARKER   ((WORD) ('M' << 8) | 'B')
00032
00033
00034 /*********************************************************************
00035  *
00036  * Local Function Prototypes
00037  *
00038  *********************************************************************/
00039
00040
00041 HANDLE ReadDIBFile(HANDLE);
00042 BOOL SaveDIBFile(void);
00043 BOOL WriteDIB(LPSTR, HANDLE);
00044
00045 /*************************************************************************
00046  *
00047  * LoadDIB()
00048  *
00049  * Loads the specified DIB from a file, allocates memory for it,
00050  * and reads the disk file into the memory.
00051  *
00052  *
00053  * Parameters:
00054  *
00055  * LPSTR lpFileName - specifies the file to load a DIB from
00056  *
00057  * Returns: A handle to a DIB, or NULL if unsuccessful.
00058  *
00059  * NOTE: The DIB API were not written to handle OS/2 DIBs; This
00060  * function will reject any file that is not a Windows DIB.
00061  *
00062  *************************************************************************/
00063
00064 HDIB LoadDIB(LPSTR lpFileName)
00065 {
00066     HDIB        hDIB;
00067     HANDLE      hFile;
00068
00069   if (!lpFileName)
00070     return NULL;
00071
00072     // Set the cursor to a hourglass, in case the loading operation
00073     // takes more than a sec, the user will know what's going on.
00074
00075     SetCursor(LoadCursor(NULL, IDC_WAIT));
00076
00077   // Create File with security related attributes
00078     hFile = CreateFile(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
00079             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | SECURITY_ANONYMOUS | SECURITY_SQOS_PRESENT, /* security level checks */
00080             NULL);
00081
00082   if (INVALID_HANDLE_VALUE == hFile)    //Unable to open File, quit load
00083     return NULL;
00084
00085   if ( GetFileType(hFile) != FILE_TYPE_DISK )
00086   {
00087     CloseHandle(hFile);
00088         DIBError(ERR_FILENOTFOUND);
00089         SetCursor(LoadCursor(NULL, IDC_ARROW));
00090         return NULL;
00091     }
00092     else
00093   {
00094         hDIB = ReadDIBFile(hFile);
00095         CloseHandle(hFile);
00096         SetCursor(LoadCursor(NULL, IDC_ARROW));
00097         return hDIB;
00098     }
00099
00100 }
00101
00102
00103 /*************************************************************************
00104  *
00105  * SaveDIB()
00106  *
00107  * Saves the specified DIB into the specified file name on disk.  No
00108  * error checking is done, so if the file already exists, it will be
00109  * written over.
00110  *
00111  * Parameters:
00112  *
00113  * HDIB hDib - Handle to the dib to save
00114  *
00115  * LPSTR lpFileName - pointer to full pathname to save DIB under
00116  *
00117  * Return value: 0 if successful, or one of:
00118  *        ERR_INVALIDHANDLE
00119  *        ERR_OPEN
00120  *        ERR_LOCK
00121  *
00122  *************************************************************************/
00123
00124 WORD SaveDIB(HDIB hDib, LPSTR lpFileName)
00125 {
00126     BITMAPFILEHEADER    bmfHdr;     // Header for Bitmap file
00127     LPBITMAPINFOHEADER  lpBI;       // Pointer to DIB info structure
00128     HANDLE              fh;         // file handle for opened file
00129     DWORD               dwDIBSize;
00130     DWORD               dwWritten;
00131
00132     if (!hDib)
00133         return ERR_INVALIDHANDLE;
00134
00135   if (!lpFileName)
00136     return ERR_FILENOTFOUND;
00137
00138     fh = CreateFile(lpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
00139             FILE_FLAG_SEQUENTIAL_SCAN | SECURITY_ANONYMOUS | SECURITY_SQOS_PRESENT, NULL);
00140
00141     if (fh == INVALID_HANDLE_VALUE)
00142         return ERR_OPEN;
00143
00144   if ( GetFileType(fh) != FILE_TYPE_DISK )
00145   {
00146       CloseHandle(fh);
00147       return ERR_OPEN;
00148   }
00149
00150     // Get a pointer to the DIB memory, the first of which contains
00151     // a BITMAPINFO structure
00152
00153     lpBI = (LPBITMAPINFOHEADER)GlobalLock(hDib);
00154     if (!lpBI)
00155     {
00156         CloseHandle(fh);
00157         return ERR_LOCK;
00158     }
00159
00160     // Check to see if we're dealing with an OS/2 DIB.  If so, don't
00161     // save it because our functions aren't written to deal with these
00162     // DIBs.
00163
00164     if (lpBI->biSize != sizeof(BITMAPINFOHEADER))
00165     {
00166         GlobalUnlock(hDib);
00167         CloseHandle(fh);
00168         return ERR_NOT_DIB;
00169     }
00170
00171     // Fill in the fields of the file header
00172
00173     // Fill in file type (first 2 bytes must be "BM" for a bitmap)
00174
00175     bmfHdr.bfType = DIB_HEADER_MARKER;  // "BM"
00176
00177     // Calculating the size of the DIB is a bit tricky (if we want to
00178     // do it right).  The easiest way to do this is to call GlobalSize()
00179     // on our global handle, but since the size of our global memory may have
00180     // been padded a few bytes, we may end up writing out a few too
00181     // many bytes to the file (which may cause problems with some apps,
00182     // like HC 3.0).
00183     //
00184     // So, instead let's calculate the size manually.
00185     //
00186     // To do this, find size of header plus size of color table.  Since the
00187     // first DWORD in both BITMAPINFOHEADER and BITMAPCOREHEADER conains
00188     // the size of the structure, let's use this.
00189
00190     // Partial Calculation
00191
00192     dwDIBSize = *(LPDWORD)lpBI + PaletteSize((LPSTR)lpBI);
00193
00194     // Now calculate the size of the image
00195
00196     // It's an RLE bitmap, we can't calculate size, so trust the biSizeImage
00197     // field
00198
00199     if ((lpBI->biCompression == BI_RLE8) || (lpBI->biCompression == BI_RLE4))
00200         dwDIBSize += lpBI->biSizeImage;
00201     else
00202     {
00203         DWORD dwBmBitsSize;  // Size of Bitmap Bits only
00204
00205         // It's not RLE, so size is Width (DWORD aligned) * Height
00206
00207         dwBmBitsSize = WIDTHBYTES((lpBI->biWidth)*((DWORD)lpBI->biBitCount)) *
00208                 lpBI->biHeight;
00209
00210         dwDIBSize += dwBmBitsSize;
00211
00212         // Now, since we have calculated the correct size, why don't we
00213         // fill in the biSizeImage field (this will fix any .BMP files which
00214         // have this field incorrect).
00215
00216         lpBI->biSizeImage = dwBmBitsSize;
00217     }
00218
00219
00220     // Calculate the file size by adding the DIB size to sizeof(BITMAPFILEHEADER)
00221
00222     bmfHdr.bfSize = dwDIBSize + sizeof(BITMAPFILEHEADER);
00223     bmfHdr.bfReserved1 = 0;
00224     bmfHdr.bfReserved2 = 0;
00225
00226     // Now, calculate the offset the actual bitmap bits will be in
00227     // the file -- It's the Bitmap file header plus the DIB header,
00228     // plus the size of the color table.
00229
00230     bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + lpBI->biSize +
00231             PaletteSize((LPSTR)lpBI);
00232
00233     // Write the file header
00234
00235     WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
00236
00237     // Write the DIB header and the bits -- use local version of
00238     // MyWrite, so we can write more than 32767 bytes of data
00239
00240     WriteFile(fh, (LPSTR)lpBI, dwDIBSize, &dwWritten, NULL);
00241
00242     GlobalUnlock(hDib);
00243     CloseHandle(fh);
00244
00245     if (dwWritten == 0)
00246         return ERR_OPEN; // oops, something happened in the write
00247     else
00248         return 0; // Success code
00249 }
00250
00251
00252 /*************************************************************************
00253  *
00254  * DestroyDIB ()
00255  *
00256  * Purpose:  Frees memory associated with a DIB
00257  *
00258  * Returns:  Nothing
00259  *
00260  *************************************************************************/
00261
00262 WORD DestroyDIB(HDIB hDib)
00263 {
00264     GlobalFree(hDib);
00265     return 0;
00266 }
00267
00268
00269 //************************************************************************
00270 //
00271 // Auxiliary Functions which the above procedures use
00272 //
00273 //************************************************************************
00274
00275
00276 /*************************************************************************
00277  *
00278  * Function:  ReadDIBFile (int)
00279  *
00280  *  Purpose:  Reads in the specified DIB file into a global chunk of
00281  *            memory.
00282  *
00283  *  Returns:  A handle to a dib (hDIB) if successful.
00284  *            NULL if an error occurs.
00285  *
00286  * Comments:  BITMAPFILEHEADER is stripped off of the DIB.  Everything
00287  *            from the end of the BITMAPFILEHEADER structure on is
00288  *            returned in the global memory handle.
00289  *
00290  *
00291  * NOTE: The DIB API were not written to handle OS/2 DIBs, so this
00292  * function will reject any file that is not a Windows DIB.
00293  *
00294  *************************************************************************/
00295
00296 HANDLE ReadDIBFile(HANDLE hFile)
00297 {
00298     BITMAPFILEHEADER    bmfHeader;
00299     DWORD               dwBitsSize;
00300     UINT                nNumColors;   // Number of colors in table
00301     HANDLE              hDIB;
00302     HANDLE              hDIBtmp;      // Used for GlobalRealloc() //MPB
00303     LPBITMAPINFOHEADER  lpbi;
00304     DWORD               offBits;
00305     DWORD               dwRead;
00306
00307   if (!hFile)
00308     return NULL;
00309
00310     // get length of DIB in bytes for use when reading
00311
00312     dwBitsSize = GetFileSize(hFile, NULL);
00313
00314     // Allocate memory for header & color table. We'll enlarge this
00315     // memory as needed.
00316
00317     hDIB = GlobalAlloc(GMEM_MOVEABLE, (DWORD)(sizeof(BITMAPINFOHEADER) +
00318             256 * sizeof(RGBQUAD)));
00319
00320     if (!hDIB)
00321         return NULL;
00322
00323     lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
00324
00325     if (!lpbi)
00326     {
00327         GlobalFree(hDIB);
00328         return NULL;
00329     }
00330
00331     // read the BITMAPFILEHEADER from our file
00332
00333     if (!ReadFile(hFile, (LPSTR)&bmfHeader, sizeof (BITMAPFILEHEADER),
00334             &dwRead, NULL))
00335         goto ErrExit;
00336
00337     if (sizeof (BITMAPFILEHEADER) != dwRead)
00338         goto ErrExit;
00339
00340     if (bmfHeader.bfType != 0x4d42)  // 'BM'
00341         goto ErrExit;
00342
00343     // read the BITMAPINFOHEADER
00344
00345     if (!ReadFile(hFile, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER), &dwRead,
00346             NULL))
00347         goto ErrExit;
00348
00349     if (sizeof(BITMAPINFOHEADER) != dwRead)
00350         goto ErrExit;
00351
00352     // Check to see that it's a Windows DIB -- an OS/2 DIB would cause
00353     // strange problems with the rest of the DIB API since the fields
00354     // in the header are different and the color table entries are
00355     // smaller.
00356     //
00357     // If it's not a Windows DIB (e.g. if biSize is wrong), return NULL.
00358
00359     if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
00360         goto ErrExit;
00361
00362     // Now determine the size of the color table and read it.  Since the
00363     // bitmap bits are offset in the file by bfOffBits, we need to do some
00364     // special processing here to make sure the bits directly follow
00365     // the color table (because that's the format we are susposed to pass
00366     // back)
00367
00368     if (!(nNumColors = (UINT)lpbi->biClrUsed))
00369     {
00370         // no color table for 24-bit, default size otherwise
00371
00372         if (lpbi->biBitCount != 24)
00373             nNumColors = 1 << lpbi->biBitCount; // standard size table
00374     }
00375
00376     // fill in some default values if they are zero
00377
00378     if (lpbi->biClrUsed == 0)
00379         lpbi->biClrUsed = nNumColors;
00380
00381     if (lpbi->biSizeImage == 0)
00382     {
00383         lpbi->biSizeImage = ((((lpbi->biWidth * (DWORD)lpbi->biBitCount) +
00384                 31) & ~31) >> 3) * lpbi->biHeight;
00385     }
00386
00387     // get a proper-sized buffer for header, color table and bits
00388
00389     GlobalUnlock(hDIB);
00390     hDIBtmp = GlobalReAlloc(hDIB, lpbi->biSize + nNumColors *
00391             sizeof(RGBQUAD) + lpbi->biSizeImage, 0);
00392
00393     if (!hDIBtmp) // can't resize buffer for loading
00394         goto ErrExitNoUnlock; //MPB
00395     else
00396         hDIB = hDIBtmp;
00397
00398     lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
00399
00400     // read the color table
00401
00402     ReadFile (hFile, (LPSTR)(lpbi) + lpbi->biSize,
00403             nNumColors * sizeof(RGBQUAD), &dwRead, NULL);
00404
00405     // offset to the bits from start of DIB header
00406
00407     offBits = lpbi->biSize + nNumColors * sizeof(RGBQUAD);
00408
00409     // If the bfOffBits field is non-zero, then the bits might *not* be
00410     // directly following the color table in the file.  Use the value in
00411     // bfOffBits to seek the bits.
00412
00413     if (bmfHeader.bfOffBits != 0L)
00414         SetFilePointer(hFile, bmfHeader.bfOffBits, NULL, FILE_BEGIN);
00415
00416     if (ReadFile(hFile, (LPSTR)lpbi + offBits, lpbi->biSizeImage, &dwRead,
00417             NULL))
00418         goto OKExit;
00419
00420
00421 ErrExit:
00422     GlobalUnlock(hDIB);
00423
00424 ErrExitNoUnlock:
00425     GlobalFree(hDIB);
00426     return NULL;
00427
00428 OKExit:
00429     GlobalUnlock(hDIB);
00430     return hDIB;
00431 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/TempConsumer/OaHelp.Inl Source File

  • SysMgmt
  • WMI
  • VC
  • TempConsumer

OaHelp.Inl

Go to the documentation of this file.
00001 // **************************************************************************
00002 // Copyright (c)  Microsoft Corporation
00003 //
00004 // File:  OAHELP.INL
00005 //
00006 // Description:  OLE Automation Helpers for client code
00007 //
00008 // History:
00009 //
00010 // **************************************************************************
00011
00012 #ifndef _OAHELP_INL_
00013 #define _OAHELP_INL_
00014
00015 class CBSTR
00016 {
00017     BSTR m_pStr;
00018 public:
00019     CBSTR() { m_pStr = 0; }
00020     CBSTR(LPWSTR pSrc) { m_pStr = SysAllocString(pSrc); }
00021    ~CBSTR() { if (m_pStr) SysFreeString(m_pStr); }
00022     operator BSTR() { return m_pStr; }
00023
00024     void Unbind() { m_pStr = 0; }
00025 };
00026
00027 class CVARIANT
00028 {
00029     VARIANT v;
00030 public:
00031     CVARIANT() { VariantInit(&v); }
00032    ~CVARIANT() { VariantClear(&v); }
00033     void Clear()  { VariantClear(&v); }
00034
00035     operator VARIANT *() { return &v; }
00036     VARIANT *operator &() { return &v; }
00037
00038     CVARIANT(LPWSTR pSrc)   { VariantInit(&v); SetStr(pSrc); }
00039     CVARIANT(LONG lSrc)     { VariantInit(&v); SetLONG(lSrc); }
00040     CVARIANT(BOOL b)        { VariantInit(&v); SetBool(b); }
00041     CVARIANT(short i)       { VariantInit(&v); SetShort(i); }
00042     CVARIANT(double d)      { VariantInit(&v); SetDouble(d); }
00043     CVARIANT(BYTE b)        { VariantInit(&v); SetByte(b); }
00044     CVARIANT(IDispatch * pDisp) { VariantInit(&v); pDisp->AddRef(); SetDispatch(pDisp); }
00045
00046     void   SetStr(LPWSTR pSrc)
00047     { Clear(); V_VT(&v) = pSrc ? VT_BSTR : VT_NULL;
00048       V_BSTR(&v) = pSrc ? SysAllocString(pSrc) : 0;
00049     }
00050
00051     LPWSTR GetStr() { return V_VT(&v) == VT_BSTR ? V_BSTR(&v) : 0; }
00052     operator LPWSTR() { return V_VT(&v) == VT_BSTR ? V_BSTR(&v) : 0; }
00053
00054     void SetLONG(LONG lSrc) { Clear(); V_VT(&v) = VT_I4; V_I4(&v) = lSrc; }
00055     LONG GetLONG() { return V_I4(&v); }
00056     operator LONG() { return V_I4(&v);  }
00057
00058     void SetDouble(double dSrc) { Clear(); V_VT(&v) = VT_R8; V_R8(&v) = dSrc; }
00059     double GetDouble() { return V_R8(&v); }
00060     operator double() { return V_R8(&v);  }
00061
00062     void SetByte(BYTE bySrc) { Clear(); V_VT(&v) = VT_UI1; V_UI1(&v) = bySrc; }
00063     BYTE GetByte() { return V_UI1(&v); }
00064     operator BYTE() { return V_UI1(&v);  }
00065
00066     void SetBool(BOOL b) { V_VT(&v) = VT_BOOL; V_BOOL(&v) = b ? VARIANT_TRUE : VARIANT_FALSE; }
00067     BOOL GetBool() { return V_BOOL(&v) == VARIANT_TRUE; }
00068     operator BOOL() { return V_BOOL(&v); }
00069
00070     void SetDispatch(IDispatch* pDisp) { V_VT(&v) = VT_DISPATCH; V_DISPATCH(&v) = pDisp; }
00071     IDispatch * GetDispatch() { return V_DISPATCH(&v); }
00072
00073     void SetUnknown(IUnknown* pUnk) { V_VT(&v) = VT_UNKNOWN; V_UNKNOWN(&v) = pUnk; }
00074     IUnknown * GetUnknown() { return V_UNKNOWN(&v); }
00075
00076     void SetShort(short i) { V_VT(&v) = VT_I2; V_I2(&v) = i; }
00077     short GetShort() { return V_I2(&v); }
00078     operator short() { return V_I2(&v); }
00079
00080     VARTYPE GetType() { return V_VT(&v); }
00081
00082     void SetArray(SAFEARRAY *p, VARTYPE vt) { Clear(); V_VT(&v) = vt; V_ARRAY(&v) = p; }
00083         // This function acquires the SAFEARRAY pointer and it is no longer owned
00084         // by the caller.
00085
00086     operator SAFEARRAY *() { return (V_VT(&v) & VT_ARRAY ? V_ARRAY(&v) : 0); }
00087
00088     void Unbind() { VariantInit(&v); }
00089 };
00090
00091 class CSAFEARRAY
00092 {
00093     SAFEARRAY *p;
00094 public:
00095     CSAFEARRAY(VARTYPE v, int nSize)
00096     {
00097         SAFEARRAYBOUND rgsabound[1];
00098       rgsabound[0].lLbound = 0;
00099       rgsabound[0].cElements = nSize;
00100         p = SafeArrayCreate(v, 1, rgsabound);
00101     }
00102
00103     ~CSAFEARRAY() { if (p) SafeArrayDestroy(p); }
00104     CSAFEARRAY(SAFEARRAY *pSrc) { p = pSrc; }
00105
00106     HRESULT Put(long nLocation, LPVOID pData) {
00107         return SafeArrayPutElement(p, &nLocation, pData);
00108     }
00109
00110     HRESULT Get(long nLocation, LPVOID pData) {
00111         return SafeArrayGetElement(p, &nLocation, pData);
00112     }
00113
00114     HRESULT Access(void **pData) { return SafeArrayAccessData(p, pData); }
00115     HRESULT Unaccess() { return SafeArrayUnaccessData(p); }
00116
00117     operator SAFEARRAY *() { return p; }
00118     long GetNumElements() { long upper; SafeArrayGetUBound(p, 1, &upper); return upper + 1; }
00119
00120     void Unbind() { p = 0; }
00121 };
00122
00123
00124 #endif
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/HtmlFilt.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

HtmlFilt.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       htmlfilt.hxx
00006 //
00007 //  Contents:   Html filter
00008 //
00009 //  Classes:    HtmlIFilter
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #ifndef __HTMLFILT_HXX__
00014 #define __HTMLFILT_HXX__
00015
00016 #include <htmliflt.hxx>
00017 #include <bag.hxx>
00018
00019 class CHtmlElement;
00020 class CFullPropSpec;
00021
00022
00023 //+---------------------------------------------------------------------------
00024 //
00025 //  Class:      CHtmlIFilter
00026 //
00027 //  Purpose:    Html Filter
00028 //
00029 //----------------------------------------------------------------------------
00030
00031 class CHtmlIFilter: public CHtmlIFilterBase
00032 {
00033
00034 public:
00035     CHtmlIFilter();
00036     ~CHtmlIFilter();
00037
00038     //
00039     // Functions inherited from IFilter and IPersistFile
00040     //
00041     SCODE STDMETHODCALLTYPE Init( ULONG grfFlags,
00042                                   ULONG cAttributes,
00043                                   FULLPROPSPEC const * aAttributes,
00044                                   ULONG * pFlags );
00045
00046     SCODE STDMETHODCALLTYPE GetChunk( STAT_CHUNK * pStat );
00047
00048     SCODE STDMETHODCALLTYPE GetText( ULONG * pcwcOutput,
00049                                      WCHAR * awcBuffer );
00050
00051     SCODE STDMETHODCALLTYPE GetValue( PROPVARIANT ** ppPropValue );
00052
00053     SCODE STDMETHODCALLTYPE BindRegion( FILTERREGION origPos,
00054                                         REFIID riid,
00055                                         void ** ppunk );
00056
00057     SCODE STDMETHODCALLTYPE GetClassID(CLSID * pClassID);
00058
00059     SCODE STDMETHODCALLTYPE IsDirty();
00060
00061     SCODE STDMETHODCALLTYPE Load(LPCWSTR pszFileName, DWORD dwMode);
00062
00063     SCODE STDMETHODCALLTYPE Save(LPCWSTR pszFileName, BOOL fRemember);
00064
00065     SCODE STDMETHODCALLTYPE SaveCompleted(LPCWSTR pszFileName);
00066
00067     SCODE STDMETHODCALLTYPE GetCurFile(LPWSTR * ppszFileName);
00068
00069     //
00070     // Html specific functions
00071     //
00072     void            ChangeState( CHtmlElement *pHtmlElemNewState );
00073     CHtmlElement *  QueryHtmlElement( HtmlTokenType eTokType );
00074     CHtmlElement *  GetCurHtmlElement()           { return _pHtmlElement; }
00075     BOOL            IsStopToken( CToken& token );
00076     ULONG           GetNextChunkId();
00077
00078     BOOL            FFilterContent()               { return _fFilterContent; }
00079
00080     LCID            GetLocale()                    { return _locale; }
00081     void            SetLocale( LCID locale )       { _locale = locale; }
00082
00083 private:
00084     BOOL            IsNonHtmlFile();
00085
00086     CHtmlElement *            _pHtmlElement;       // Current processing element
00087     BOOL                      _fNonHtmlFile;       // IE workaround: Set to true
00088                                                    //   if a non-html file
00089                                                    //   such as .gif file has been
00090                                                    //   asked to be filtered by html
00091                                                    //   filter
00092
00093     BOOL                      _fFilterContent;     // Filter contents ?
00094     BOOL                      _fFilterMetaTag;     // Filter meta tag ?
00095     BOOL                      _fFilterScriptTag;   // Filter script tag ?
00096
00097     ULONG                     _cAttributes;        // Count of attributes
00098     CFullPropSpec *           _pAttributes;        // Attributes to filter
00099
00100     WCHAR *                   _pwszFileName;       // File that has been loaded
00101     ULONG                     _ulChunkID;          // Current chunk id
00102     LCID                      _locale;             // Locale
00103
00104     CHtmlElementBag           _htmlElementBag;     // Bag of various Html elements
00105     CSerialStream             _serialStream;       // Input Stream
00106 };
00107
00108 #endif  //  __HTMLFILT_HXX__
00109
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpwizard/SCPWiz.cpp Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpwizard

SCPWiz.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCPWiz.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // SCPWiz.cpp : Implementation of CSCPWiz
00012 #include "stdafx.h"
00013 #include "SCPWiz.h"
00014 #include "util.h"
00015
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CWizExtBase
00019
00020 HRESULT CSCPWiz::Initialize(IADsContainer*        pADsContainerObj,
00021                                 IADs*                 pADsCopySource,
00022                                 LPCWSTR               lpszClassName,
00023                                 IDsAdminNewObj*       pDsAdminNewObj,
00024                                 LPDSA_NEWOBJ_DISPINFO pDispInfo)
00025 {
00026   HRESULT hr = S_OK;
00027   //
00028   // Debug Traces
00029   //
00030   TRACE(_T("IDsAdminNewObjExt::Initialize()\n"));
00031   TRACE(_T("\tpADsContainerObj = %p\n"), pADsContainerObj);
00032   TRACE(_T("\tlpszClassName = <%s>\n"), lpszClassName);
00033   TRACE(_T("\tpDsAdminNewObj = %p\n"), pDsAdminNewObj);
00034   TRACE(_T("\tpDispInfo = %p\n"), pDispInfo);
00035
00036   //
00037   // make sure we have valid parameters
00038   //
00039   if ( (pADsContainerObj == NULL) || (pDsAdminNewObj == NULL) || (lpszClassName == NULL) )
00040   {
00041     hr = E_INVALIDARG;
00042   }
00043
00044   if ( (pDispInfo == NULL) || (pDispInfo->dwSize != sizeof(DSA_NEWOBJ_DISPINFO)) )
00045   {
00046     hr = E_INVALIDARG;
00047   }
00048
00049   //
00050   // save the parameters passed
00051   //
00052   m_spDsAdminNewObj     = pDsAdminNewObj;
00053   m_spADsCopySourceObj  = pADsCopySource;
00054   m_spADsContainerObj   = pADsContainerObj;
00055   m_szClassName         = lpszClassName;
00056
00057   hr = m_spDsAdminNewObj->QueryInterface(IID_IDsAdminNewObjPrimarySite,
00058                                                  (PVOID*)&m_spDsAdminNewObjPrimarySite);
00059   if (FAILED(hr))
00060   {
00061     m_spDsAdminNewObjPrimarySite = NULL;
00062   }
00063
00064   //
00065   // save data from the DSA_NEWOBJ_DISPINFO struct
00066   //
00067   TRACE(_T("\tpDispInfo->dwSize = %d\n"), pDispInfo->dwSize);
00068   TRACE(_T("\tpDispInfo->hObjClassIcon  = 0x%x\n"), pDispInfo->hObjClassIcon);
00069   TRACE(_T("\tpDispInfo->lpszWizTitle = <%s>\n"), pDispInfo->lpszWizTitle);
00070   TRACE(_T("\tpDispInfo->lpszContDisplayName = <%s>\n"), pDispInfo->lpszContDisplayName);
00071
00072   m_hObjClassIcon = pDispInfo->hObjClassIcon;
00073   m_szTitle = pDispInfo->lpszWizTitle;
00074   m_szContCanonicalName = pDispInfo->lpszContDisplayName;
00075
00076   return hr;
00077 }
00078
00079
00080 HRESULT CSCPWiz::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
00081 {
00082   //
00083   // Add the pages for the wizard extension in the order they are to appear.
00084   //
00085   AFX_MANAGE_STATE(AfxGetStaticModuleState());
00086   m_pWizPage1 = new CSCPPageGeneral(this);
00087   (*lpfnAddPage)(CreatePropertySheetPage((PROPSHEETPAGE*)(&m_pWizPage1->m_psp)), lParam);
00088
00089   m_pWizPage2 = new CSCPPageBindingInfo(this);
00090   (*lpfnAddPage)(CreatePropertySheetPage((PROPSHEETPAGE*)(&m_pWizPage2->m_psp)), lParam);
00091
00092   m_pWizPage3 = new CSCPPageKeywords(this);
00093   (*lpfnAddPage)(CreatePropertySheetPage((PROPSHEETPAGE*)(&m_pWizPage3->m_psp)), lParam);
00094
00095   return S_OK;
00096 }
00097
00098 HRESULT CSCPWiz::SetObject(IADs* pADsObj)
00099 {
00100   //
00101   // Hang on to the object passed in
00102   // the smart pointer will handle the ref count
00103   //
00104   m_spADsObj = pADsObj;
00105   return S_OK;
00106 }
00107
00108 HRESULT CSCPWiz::WriteData(HWND hWnd, ULONG uContext)
00109 {
00110   HRESULT hr = E_INVALIDARG;
00111   //
00112   // NOTICE: when the property page has received the kill focus
00113   // notification, it has already written the data, so we do not
00114   // need to do anything on a precommit notification.
00115   //
00116   if (uContext == DSA_NEWOBJ_CTX_PRECOMMIT)
00117   {
00118     hr = S_OK;
00119   }
00120
00121   //
00122   // This extension does not write anything during the post commit phase
00123   // so we can just return.
00124   //
00125   if (uContext == DSA_NEWOBJ_CTX_POSTCOMMIT)
00126   {
00127     hr = S_OK;
00128   }
00129
00130   //
00131   // We have to handle the case when the creation failed, the object
00132   // got destroyed, a new temporary object was created, and it has to
00133   // be initialized again.
00134   //
00135   if (uContext == DSA_NEWOBJ_CTX_CLEANUP)
00136   {
00137     //
00138     // Call the helper function to do a precommit write.
00139     //
00140     hr = WriteDataHelper();
00141   }
00142
00143   return hr;
00144 }
00145
00146 HRESULT CSCPWiz::WriteDataHelper()
00147 {
00148   //
00149   // Write the data from the page to the temporary object given to the extension
00150   // by SetObject()
00151   //
00152
00153
00154   return S_OK;
00155 }
00156
00157 HRESULT CSCPWiz::GetSummaryInfo(BSTR* pBstrText)
00158 {
00159   //
00160   // Verify valid arguments
00161   //
00162   if (pBstrText == NULL)
00163   {
00164     return E_INVALIDARG;
00165   }
00166
00167   //
00168   // Format the summary string which will be displayed on the finish page of the wizard.
00169   //
00170   CString strSummary, szPage1, szPage2, szPage3;
00171   m_pWizPage1->GetSummaryInfo(szPage1);
00172   m_pWizPage2->GetSummaryInfo(szPage2);
00173   m_pWizPage3->GetSummaryInfo(szPage3);
00174
00175   strSummary = szPage1 + szPage2 + szPage3;
00176
00177   //
00178   // Copy to BSTR
00179   //
00180   *pBstrText = ::SysAllocString(strSummary);
00181   return S_OK;
00182 }
00183
00184 HRESULT CSCPWiz::OnError(HWND hWnd, HRESULT hr, ULONG uContext)
00185 {
00186   AFX_MANAGE_STATE(AfxGetStaticModuleState());
00187
00188   CString szMessage;
00189
00190   if (uContext == DSA_NEWOBJ_CTX_COMMIT)
00191   {
00192     //
00193     // The extension gets notified if the SetInfo() or an attempt to cleanup
00194     // a temporary object failed.
00195     //
00196     szMessage.Format(_T("SetInfo() failed: hr = 0x%x"), hr);
00197     AfxMessageBox(szMessage);
00198   }
00199   else if (uContext == DSA_NEWOBJ_CTX_PRECOMMIT)
00200   {
00201     //
00202     // Pre-commit failure is rare.  If it does occur handle the error here.
00203     //
00204   }
00205   else if (uContext == DSA_NEWOBJ_CTX_POSTCOMMIT)
00206   {
00207     //
00208     // Post-commit failure is rare.  If it does occur handle the error here.
00209     //
00210   }
00211   else if (uContext == DSA_NEWOBJ_CTX_CLEANUP)
00212   {
00213     //
00214     // For some reason (e.g. network failure or not enough privileges) DS Admin
00215     // could not remove the ill constructed (but committed) object after a
00216     // failure to write on post commit.  If appropriate, the extension can
00217     // handle the error message.
00218     //
00219
00220     //
00221     // NOTE : this is not a primary extension so we will leave it up to DS Admin
00222     //        to handle this error message.
00223     //
00224     return E_FAIL;
00225   }
00226
00227   //
00228   // Returning success means that DS Admin will not put up its own generic
00229   // error message.
00230   //
00231   return S_OK;
00232 }
00233
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RqsEngineCbInfo Member List

This is the complete list of members for _RqsEngineCbInfo, including all inherited members.
pClient | _RqsEngineCbInfo
pEngine | _RqsEngineCbInfo
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/dll/Select.h Source File

  • Begin
  • dll

Select.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /* These defines determine the meaning of the fFlags variable.  The low byte
00013  * is used for the various types of "boxes" to draw.  The high byte is
00014  * available for special commands.
00015  */
00016
00017 #define SL_BOX    1             /* Draw a solid border around the rectangle  */
00018 #define SL_BLOCK  2             /* Draw a solid rectangle                    */
00019
00020 #define SL_EXTEND 256           /* Extend the current pattern                */
00021
00022 #define SL_TYPE    0x00FF       /* Mask out everything but the type flags    */
00023 #define SL_SPECIAL 0xFF00       /* Mask out everything but the special flags */
00024
00025 // Temporary porting macros
00026
00027 #define INT2DWORD               DWORD
00028 typedef POINTS MPOINT;
00029 #define MAKEMPOINT(l)           (*((MPOINT *)&(l)))
00030 #define MPOINT2POINT(mpt, pt)   ((pt).x = (mpt).x, (pt).y = (mpt).y)
00031 #define POINT2MPOINT(pt, mpt)   ((mpt).x = (SHORT)(pt).x, (mpt).y = (SHORT)(pt).y)
00032
00033
00034 int APIENTRY StartSelection(HWND, MPOINT, LPRECT, int);
00035 int APIENTRY UpdateSelection(HWND, MPOINT, LPRECT, int);
00036 int APIENTRY EndSelection(MPOINT, LPRECT);
00037 int APIENTRY ClearSelection(HWND, LPRECT, int);
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/crow.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

crow.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CROW.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CROW_H_
00012 #define _CROW_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019 #include "CRowset.h"  //CDataAccess
00020
00021
00022 /////////////////////////////////////////////////////////////////
00023 // CRow
00024 //
00025 /////////////////////////////////////////////////////////////////
00026 class CRow : public CDataAccess
00027 {
00028 public:
00029   //Constructors
00030   CRow(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00031   virtual ~CRow();
00032
00033   //IUnknown Helpers
00034   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00035   virtual HRESULT     AutoRelease();
00036   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00037
00038   //Pure Virtual
00039   virtual WCHAR*      GetObjectName()     { return L"Row";      }
00040   virtual UINT      GetObjectMenu()     { return IDM_ROWMENU;   }
00041   virtual LONG      GetObjectImage()    { return IMAGE_FORM;    }
00042   virtual REFIID      GetDefaultInterface() { return IID_IRow;      }
00043
00044   virtual HRESULT     DisplayObject();
00045   virtual WCHAR*      GetObjectDesc();
00046
00047   //Members
00048   virtual HRESULT     SetupColAccess(BINDCOLS eBindCols = BIND_ALLCOLS);
00049
00050   virtual HRESULT     CreateCommand(CAggregate* pCAggregate, REFIID riid, IUnknown** ppIUnknown);
00051   virtual HRESULT     GetColumns(ULONG cColAccess, DBCOLUMNACCESS* rgColAccess);
00052   virtual HRESULT     Open(CAggregate* pCAggregate, DBID* pColumnID, REFGUID rguidObjectType, REFIID riid, IUnknown** ppIUnknown);
00053   virtual HRESULT     Bind(CAggregate* pCAggregate, WCHAR* pwszURL, DBBINDURLFLAG dwBindFlags, REFGUID rguidObjectType, REFIID riid, IUnknown** ppIUnknown);
00054   virtual HRESULT     OpenRowset(CAggregate* pCAggregate, DBID* pTableID, DBID* pIndexID, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown);
00055
00056   //Row
00057   //[MANADATORY]
00058   IRow*           m_pIRow;
00059   IGetSession*        m_pIGetSession;
00060
00061   //[OPTIONAL]
00062   IColumnsInfo2*        m_pIColumnsInfo2;
00063   ICreateRow*         m_pICreateRow;
00064   IDBCreateCommand*     m_pIDBCreateCommand;
00065   IRowChange*         m_pIRowChange;
00066   IRowSchemaChange*     m_pIRowSchemaChange;
00067   IBindResource*        m_pIBindResource;
00068   IScopedOperations*      m_pIScopedOperations;
00069
00070   //ColAccess
00071   ULONG           m_cColAccess;
00072   DBCOLUMNACCESS*       m_rgColAccess;
00073
00074   //Data
00075   HROW            m_hSourceRow;
00076 };
00077
00078
00079
00080
00081 #endif //_CROW_H_
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PREF Member List

This is the complete list of members for _PREF, including all inherited members.
dwNmch | _PREF
fAutoCall | _PREF
fAutoChat | _PREF
fAutoHost | _PREF
fAutoMonitor | _PREF
fChat | _PREF
fConfirm | _PREF
fMsg | _PREF
fMsgNotify | _PREF
fMsgObjects | _PREF
fMsgState | _PREF
fMsgTrace | _PREF
fMsgWindow | _PREF
fSbar | _PREF
fTbar | _PREF
fUserList | _PREF
iInit | _PREF
lf | _PREF
nmAddrType | _PREF
nmCallType | _PREF
pszAddr | _PREF
pszConferenceName | _PREF
pszFileName | _PREF
pszPassword | _PREF
wpMain | _PREF
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COleInPlaceActiveObject Member List

This is the complete list of members for COleInPlaceActiveObject, including all inherited members.
COleInPlaceActiveObject(COleDocument *) | COleInPlaceActiveObject |
ContextSensitiveHelp(BOOL) | COleInPlaceActiveObject |
EnableModeless(BOOL) | COleInPlaceActiveObject |
GetWindow(HWND *) | COleInPlaceActiveObject |
m_fEnableModeless | COleInPlaceActiveObject | [private]
m_pOleDoc | COleInPlaceActiveObject | [private]
OnDocWindowActivate(BOOL) | COleInPlaceActiveObject |
OnFrameWindowActivate(BOOL) | COleInPlaceActiveObject |
QueryInterface(REFIID, LPVOID *) | COleInPlaceActiveObject |
ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL) | COleInPlaceActiveObject |
STDMETHODIMP_(ULONG) AddRef() | COleInPlaceActiveObject |
STDMETHODIMP_(ULONG) Release() | COleInPlaceActiveObject |
TranslateAccelerator(LPMSG) | COleInPlaceActiveObject |
~COleInPlaceActiveObject() | COleInPlaceActiveObject |
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDeviceProp Member List

This is the complete list of members for CDeviceProp, including all inherited members.
CDeviceProp(CWnd *pParent=NULL) | CDeviceProp |
CDeviceProp(IUPnPDevice *pDevice, CWnd *pParent=NULL) | CDeviceProp |
DoDataExchange(CDataExchange *pDX) | CDeviceProp | [protected, virtual]
IDD enum value | CDeviceProp |
m_DeviceType | CDeviceProp |
m_FriendlyName | CDeviceProp |
m_Manufacturer | CDeviceProp |
m_ManufacturerUrl | CDeviceProp |
m_ModelDescription | CDeviceProp |
m_ModelName | CDeviceProp |
m_ModelNumber | CDeviceProp |
m_ModelUrl | CDeviceProp |
m_OkButton | CDeviceProp |
m_PresentationUrl | CDeviceProp |
m_SerialNumber | CDeviceProp |
m_UDN | CDeviceProp |
m_UPC | CDeviceProp |
OnInitDialog() | CDeviceProp | [protected, virtual]
OnOk() | CDeviceProp | [protected]
pCurrentDevice | CDeviceProp | [private]
PrintTextToEditBox(CEdit *pEditBox, BSTR bstrPrintText, HRESULT hrCheck) | CDeviceProp | [private]
~CDeviceProp() | CDeviceProp |
Generated on Wed Nov 13 2024 16:56:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/winhttp/setoptions/SetOptions.cpp Source File

  • Web
  • winhttp
  • setoptions

SetOptions.cpp

Go to the documentation of this file.
00001 /************************************************************
00002 *                                                           *
00003 * SetOptions.cpp                                            *
00004 *                                                           *
00005 * Copyright (c) Microsoft Corporation. All Rights Reserved. *
00006 *                                                           *
00007 ************************************************************/
00008
00009 #include <windows.h>
00010 #include <winhttp.h>
00011 #include <stdio.h>
00012
00013 int main(int argc, char *argv []){
00014
00015     HINTERNET hSession;
00016     BOOL httpResult;
00017     DWORD dwSize    = sizeof(DWORD);
00018     DWORD dwData = 0;
00019     DWORD dwNewData = 50000;
00020
00021     // Print a description for the user.
00022     printf("This sample demonstrates the process for setting WinHTTP options\n");
00023     printf("programmatically from a C/C++ application. WinHTTP application\n");
00024     printf("programming interface (API) functions are used to change the connect\n");
00025     printf("time-out value.\n\n");
00026
00027     // Use WinHttpOpen to obtain a session handle.
00028     hSession = WinHttpOpen(  L"A WinHTTP Example Program/1.0",
00029                              WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
00030                              WINHTTP_NO_PROXY_NAME,
00031                              WINHTTP_NO_PROXY_BYPASS, 0);
00032
00033
00034     // Use WinHttpQueryOption to retrieve the connect time-out.
00035     httpResult = WinHttpQueryOption( hSession, WINHTTP_OPTION_CONNECT_TIMEOUT,
00036                                      &dwData, &dwSize);
00037     printf("Old Connect Time-Out: %u\n", dwData);
00038
00039     // Use WinHttpSetOption to set a new connect time-out.
00040     httpResult = WinHttpSetOption( hSession, WINHTTP_OPTION_CONNECT_TIMEOUT,
00041                                    &dwNewData, dwSize);
00042
00043     // Use WinHttpQueryOption to verify the new connect time-out.
00044     httpResult = WinHttpQueryOption( hSession, WINHTTP_OPTION_CONNECT_TIMEOUT,
00045                                      &dwData, &dwSize);
00046     printf("New Connect Time-Out: %u\n", dwData);
00047
00048     // When finished, release the HINTERNET handle.
00049     httpResult = WinHttpCloseHandle(hSession);
00050     if (!httpResult)
00051         printf("Could not close the HINTERNET handle.\n");
00052
00053     return 0;
00054 }
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/delebase.h Source File

  • SysMgmt
  • MMC
  • Menubtn

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CDelegationBase {
00030 public:
00031     CDelegationBase();
00032     virtual ~CDelegationBase();
00033
00034     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00035     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00036
00037     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00038     virtual const int GetBitmapIndex() = 0;
00039
00040     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00041
00042 public:
00043     // virtual functions go here (for MMCN_*)
00044     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00045     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00046     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00047     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00048     virtual HRESULT OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile);
00049
00050     virtual HRESULT OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) { return S_FALSE; }
00051     virtual HRESULT SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton,
00052         BOOL bScope, BOOL bSelect) { return S_FALSE; }
00053     virtual HRESULT OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) { return S_FALSE; }
00054
00055 public:
00056     static HBITMAP m_pBMapSm;
00057     static HBITMAP m_pBMapLg;
00058
00059 protected:
00060     static void LoadBitmaps() {
00061         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00062         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00063     }
00064
00065     BOOL bExpanded;
00066
00067 private:
00068     // {2974380B-4C4B-11d2-89D8-000021473128}
00069     static const GUID thisGuid;
00070 };
00071
00072 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/ceerror.cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

ceerror.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2002
00005 //
00006 // File:        ceerror.cpp
00007 //
00008 // Contents:    Cert Server error wrapper routines
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include <pch.cpp>
00013
00014 #pragma hdrstop
00015
00016 #include "celib.h"
00017 #include <assert.h>
00018 #include <ntdsbmsg.h>
00019 #include <delayimp.h>
00020 #include <wininet.h>
00021
00022 #define CERTLIB_12BITERRORMASK  0x00000fff
00023 #define CERTLIB_WIN32ERRORMASK  0x0000ffff
00024
00025
00026 //+--------------------------------------------------------------------------
00027 // Jet errors:
00028
00029 #define HRESULT_FROM_JETWARNING(jerr) \
00030         (ERROR_SEVERITY_WARNING | (FACILITY_NTDSB << 16) | jerr)
00031
00032 #define HRESULT_FROM_JETERROR(jerr) \
00033         (ERROR_SEVERITY_ERROR | (FACILITY_NTDSB << 16) | -jerr)
00034
00035 #define JETERROR_FROM_HRESULT(hr) \
00036         (-(LONG) (CERTLIB_WIN32ERRORMASK & (hr)))
00037
00038 #define ISJETERROR(hr) \
00039         ((~CERTLIB_WIN32ERRORMASK & (hr)) == (HRESULT) ~CERTLIB_WIN32ERRORMASK)
00040
00041 #define ISJETHRESULT(hr) \
00042     ((~CERTLIB_WIN32ERRORMASK & (hr)) == (HRESULT) (ERROR_SEVERITY_ERROR | \
00043                 (FACILITY_NTDSB << 16)))
00044
00045 #define wszJETERRORPREFIX       L"ESE"
00046
00047
00048 //+--------------------------------------------------------------------------
00049 // Setup API errors:
00050
00051 #define ISSETUPHRESULT(hr) \
00052     ((~CERTLIB_WIN32ERRORMASK & (hr)) == (HRESULT) (ERROR_SEVERITY_ERROR | \
00053                                               APPLICATION_ERROR_MASK | \
00054                                               (FACILITY_NULL << 16)))
00055
00056 #define wszSETUPERRORPREFIX       L"INF"
00057
00058
00059 //+--------------------------------------------------------------------------
00060 // Win32 errors:
00061
00062 #define ISWIN32ERROR(hr) \
00063         ((~CERTLIB_WIN32ERRORMASK & (hr)) == 0)
00064
00065 #define ISWIN32HRESULT(hr) \
00066     ((~CERTLIB_WIN32ERRORMASK & (hr)) == (HRESULT) (ERROR_SEVERITY_WARNING | \
00067                 (FACILITY_WIN32 << 16)))
00068
00069 #define WIN32ERROR_FROM_HRESULT(hr) \
00070         (CERTLIB_WIN32ERRORMASK & (hr))
00071
00072 #define wszWIN32ERRORPREFIX     L"WIN32"
00073
00074
00075 //+--------------------------------------------------------------------------
00076 // Http errors:
00077
00078 #define ISHTTPERROR(hr) \
00079     ((HRESULT) HTTP_STATUS_FIRST <= (hr) && (HRESULT) HTTP_STATUS_LAST >= (hr))
00080
00081 #define ISHTTPHRESULT(hr) \
00082     (ISWIN32HRESULT(hr) && ISHTTPERROR(WIN32ERROR_FROM_HRESULT(hr)))
00083
00084 #define wszHTTPERRORPREFIX     L"HTTP"
00085
00086
00087 //+--------------------------------------------------------------------------
00088 // Delayload errors:
00089
00090 #define DELAYLOAD_FROM_WIN32(hr)  VcppException(ERROR_SEVERITY_ERROR, (hr))
00091
00092 #define WIN32ERROR_FROM_DELAYLOAD(hr)  (CERTLIB_WIN32ERRORMASK & (hr))
00093
00094 #define ISDELAYLOADHRESULTFACILITY(hr) \
00095     ((~CERTLIB_WIN32ERRORMASK & (hr)) == (HRESULT) (ERROR_SEVERITY_ERROR | \
00096                                               (FACILITY_VISUALCPP << 16)))
00097
00098 // E_DELAYLOAD_MOD_NOT_FOUND    0xc06d007e
00099 #define E_DELAYLOAD_MOD_NOT_FOUND   DELAYLOAD_FROM_WIN32(ERROR_MOD_NOT_FOUND)
00100
00101 // E_DELAYLOAD_PROC_NOT_FOUND   0xc06d007f
00102 #define E_DELAYLOAD_PROC_NOT_FOUND  DELAYLOAD_FROM_WIN32(ERROR_PROC_NOT_FOUND)
00103
00104 #define ISDELAYLOADHRESULT(hr) \
00105         ((HRESULT) E_DELAYLOAD_MOD_NOT_FOUND == (hr) || \
00106          (HRESULT) E_DELAYLOAD_PROC_NOT_FOUND == (hr) || \
00107          HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND) == (hr) || \
00108          HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND) == (hr))
00109
00110
00111 //+--------------------------------------------------------------------------
00112 // ASN encoding errors:
00113
00114 #define ISOSSERROR(hr) \
00115         ((~CERTLIB_12BITERRORMASK & (hr)) == CRYPT_E_OSS_ERROR)
00116
00117 #define OSSERROR_FROM_HRESULT(hr) \
00118         (CERTLIB_12BITERRORMASK & (hr))
00119
00120 #define wszOSSERRORPREFIX       L"ASN"
00121
00122
00123 HRESULT
00124 ceJetHResult(
00125     IN HRESULT hr)
00126 {
00127     if (S_OK != hr)
00128     {
00129         if (SUCCEEDED(hr))
00130         {
00131 #if 0
00132             hr = HRESULT_FROM_JETWARNING(hr);
00133 #else
00134             if (S_FALSE != hr)
00135             {
00136                 _PrintError(hr, "JetHResult: mapping to S_FALSE");
00137             }
00138             assert(S_FALSE == hr);
00139             hr = S_FALSE;
00140 #endif
00141         }
00142         else if (ISJETERROR(hr))
00143         {
00144             hr = HRESULT_FROM_JETERROR(hr);
00145         }
00146     }
00147     assert(S_OK == hr || S_FALSE == hr || FAILED(hr));
00148     return(hr);
00149 }
00150
00151
00152 HRESULT
00153 ceHExceptionCode(
00154     IN EXCEPTION_POINTERS const *pep)
00155 {
00156     HRESULT hr = pep->ExceptionRecord->ExceptionCode;
00157
00158 #if (0 == i386)
00159     if ((HRESULT) STATUS_DATATYPE_MISALIGNMENT == hr)
00160     {
00161   hr = CERTSRV_E_ALIGNMENT_FAULT;
00162     }
00163 #endif
00164     return(ceHError(hr));
00165 }
00166
00167
00168 BOOL
00169 ceIsDelayLoadHResult(
00170     IN HRESULT hr)
00171 {
00172     return(ISDELAYLOADHRESULT(hr));
00173 }
00174
00175
00176 #define wszCOLONSPACE   L": "
00177
00178 WCHAR const *
00179 ceHResultToStringEx(
00180     IN OUT WCHAR *awchr,
00181     IN HRESULT hr,
00182     IN BOOL fRaw)
00183 {
00184     HRESULT hrd;
00185     WCHAR const *pwszType;
00186
00187     hrd = hr;
00188     pwszType = L"";
00189     if (ISJETERROR(hr))
00190     {
00191         pwszType = wszJETERRORPREFIX wszCOLONSPACE;
00192     }
00193     else if (ISJETHRESULT(hr))
00194     {
00195         hrd = JETERROR_FROM_HRESULT(hr);
00196         pwszType = wszJETERRORPREFIX wszCOLONSPACE;
00197     }
00198     else if (ISOSSERROR(hr))
00199     {
00200         hrd = OSSERROR_FROM_HRESULT(hr);
00201         pwszType = wszOSSERRORPREFIX wszCOLONSPACE;
00202     }
00203     else if (ISHTTPHRESULT(hr) || ISHTTPERROR(hr))
00204     {
00205         hrd = WIN32ERROR_FROM_HRESULT(hr);
00206         pwszType = wszWIN32ERRORPREFIX L"/" wszHTTPERRORPREFIX wszCOLONSPACE;
00207     }
00208     else if (ISWIN32HRESULT(hr) || ISWIN32ERROR(hr))
00209     {
00210         hrd = WIN32ERROR_FROM_HRESULT(hr);
00211         pwszType = wszWIN32ERRORPREFIX wszCOLONSPACE;
00212     }
00213     else if (ISDELAYLOADHRESULTFACILITY(hr))
00214     {
00215         hrd = WIN32ERROR_FROM_DELAYLOAD(hr);
00216         pwszType = wszWIN32ERRORPREFIX wszCOLONSPACE;
00217     }
00218     else if (ISSETUPHRESULT(hr))
00219     {
00220         pwszType = wszSETUPERRORPREFIX wszCOLONSPACE;
00221     }
00222     if (fRaw)
00223     {
00224         pwszType = L"";
00225     }
00226
00227     _snwprintf(
00228         awchr,
00229         cwcHRESULTSTRING,
00230         L"0x%x (%ws%d)",
00231         hr,
00232         pwszType,
00233         hrd);
00234     return(awchr);
00235 }
00236
00237
00238 WCHAR const *
00239 ceHResultToString(
00240     IN OUT WCHAR *awchr,
00241     IN HRESULT hr)
00242 {
00243     return(ceHResultToStringEx(awchr, hr, FALSE));
00244 }
00245
00246
00247 WCHAR const *
00248 ceHResultToStringRaw(
00249     IN OUT WCHAR *awchr,
00250     IN HRESULT hr)
00251 {
00252     return(ceHResultToStringEx(awchr, hr, TRUE));
00253 }
00254
00255
00256 static HMODULE s_hMod = NULL;
00257 static DWORD s_idsUnexpected = 0;
00258 static DWORD s_idsUnknownErrorCode = 0; // L"Error %ws %ws"
00259
00260 VOID
00261 ceInitErrorMessageText(
00262     IN HMODULE hMod,
00263     IN DWORD idsUnexpected,
00264     IN DWORD idsUnknownErrorCode) // L"Error %ws %ws"
00265 {
00266     s_hMod = hMod;
00267     s_idsUnexpected = idsUnexpected;
00268     s_idsUnknownErrorCode = idsUnknownErrorCode;
00269 }
00270
00271
00272 DWORD
00273 errFormatMessage(
00274     IN HMODULE hMod,
00275     IN HRESULT hr,
00276     OUT WCHAR const **ppwszOut,
00277     OPTIONAL IN WCHAR const * const *ppwszArgs)
00278 {
00279     DWORD dwFlags;
00280
00281     dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER;
00282     if (NULL == hMod)
00283     {
00284   dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM;
00285     }
00286     else
00287     {
00288   dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
00289     }
00290     if (NULL == ppwszArgs || NULL == ppwszArgs[0])
00291     {
00292   dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS;
00293     }
00294     else
00295     {
00296   dwFlags |= FORMAT_MESSAGE_ARGUMENT_ARRAY;
00297     }
00298     return(FormatMessage(
00299     dwFlags,
00300                 hMod,
00301                 hr,
00302                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00303                 (WCHAR *) ppwszOut,
00304                 1,
00305     (va_list *) ppwszArgs));
00306 }
00307
00308
00309 // Alloc and return error message string
00310
00311 WCHAR const *
00312 ceGetErrorMessageText(
00313     IN HRESULT hr,
00314     IN BOOL fHResultString)
00315 {
00316     return(ceGetErrorMessageTextEx(hr, fHResultString, NULL));
00317 }
00318
00319
00320 WCHAR const *
00321 ceGetErrorMessageText1(
00322     IN HRESULT hr,
00323     IN BOOL fHResultString,
00324     IN OPTIONAL WCHAR const *pwszInsertionText)
00325 {
00326     WCHAR const *apwszInsertionText[2];
00327     WCHAR const * const *papwsz = NULL;
00328
00329     if (NULL != pwszInsertionText)
00330     {
00331   apwszInsertionText[0] = pwszInsertionText;
00332   apwszInsertionText[1] = NULL;
00333   papwsz = apwszInsertionText;
00334     }
00335     return(ceGetErrorMessageTextEx(hr, fHResultString, papwsz));
00336 }
00337
00338
00339 WCHAR const *
00340 ceGetErrorMessageTextEx(
00341     IN HRESULT hr,
00342     IN BOOL fHResultString,
00343     IN OPTIONAL WCHAR const * const *papwszInsertionText)
00344 {
00345     WCHAR const *pwszRet = NULL;
00346     WCHAR const *pwszRetStatic = NULL;
00347     WCHAR *pwszMsgT;
00348     WCHAR awchr[cwcHRESULTSTRING];
00349     DWORD cwc;
00350     DWORD cwcCopy;
00351     DWORD cwcUnexpected;
00352     WCHAR const *pwszUnexpected = NULL;
00353     WCHAR wszEmpty[] = L"";
00354     HMODULE hMod1 = NULL;
00355     HMODULE hMod2 = NULL;
00356
00357     if (E_UNEXPECTED == hr)
00358     {
00359   pwszUnexpected = L"Unexpected method call sequence.";
00360     }
00361 #if (0 == i386)
00362     else if (STATUS_DATATYPE_MISALIGNMENT == hr)
00363     {
00364   pwszUnexpected = L"Possible data alignment fault.";
00365     }
00366 #endif
00367     if (NULL == pwszUnexpected)
00368     {
00369   pwszUnexpected = wszEmpty;
00370     }
00371     cwcUnexpected = wcslen(pwszUnexpected);
00372
00373     cwc = errFormatMessage(NULL, hr, &pwszRet, papwszInsertionText);
00374     if (0 == cwc && ISDELAYLOADHRESULTFACILITY(hr))
00375     {
00376   cwc = errFormatMessage(
00377       NULL,
00378       WIN32ERROR_FROM_DELAYLOAD(hr),
00379       &pwszRet,
00380       papwszInsertionText);
00381     }
00382     if (0 == cwc)
00383     {
00384         hMod1 = LoadLibrary(L"ntdsbmsg.dll");
00385         if (NULL != hMod1)
00386         {
00387             HRESULT hrEDB = hr;
00388             HRESULT hrFormat;
00389             BOOL fFirst = TRUE;
00390
00391             while (TRUE)
00392             {
00393                 cwc = errFormatMessage(hMod1, hrEDB, &pwszRet, papwszInsertionText);
00394                 if (0 == cwc && FAILED(hrEDB) && fFirst)
00395                 {
00396                     hrFormat = ceHLastError();
00397                     if (HRESULT_FROM_WIN32(ERROR_MR_MID_NOT_FOUND) == hrFormat)
00398                     {
00399                         hrEDB = ceJetHResult(hrEDB);
00400                         if (hrEDB != hr)
00401                         {
00402                             fFirst = FALSE;
00403                             continue;
00404                         }
00405                     }
00406                 }
00407                 break;
00408             }
00409         }
00410     }
00411     if (0 == cwc)
00412     {
00413   HMODULE hModT = GetModuleHandle(L"wininet.dll");
00414         if (NULL != hModT)
00415         {
00416             HRESULT hrHttp = hr;
00417             HRESULT hrFormat;
00418             BOOL fFirst = TRUE;
00419
00420             while (TRUE)
00421             {
00422     cwc = errFormatMessage(hModT, hrHttp, &pwszRet, papwszInsertionText);
00423                 if (0 == cwc && ISWIN32HRESULT(hrHttp) && fFirst)
00424                 {
00425                     hrFormat = ceHLastError();
00426                     if (HRESULT_FROM_WIN32(ERROR_MR_MID_NOT_FOUND) == hrFormat)
00427                     {
00428       hrHttp = WIN32ERROR_FROM_HRESULT(hrHttp);
00429                         if (hrHttp != hr)
00430                         {
00431                             fFirst = FALSE;
00432                             continue;
00433                         }
00434                     }
00435                 }
00436                 break;
00437             }
00438         }
00439     }
00440     if (0 == cwc)
00441     {
00442         hMod2 = LoadLibrary(L"cdosys.dll");
00443         if (NULL != hMod2)
00444         {
00445       cwc = errFormatMessage(hMod2, hr, &pwszRet, papwszInsertionText);
00446         }
00447     }
00448
00449     if (0 == cwc) // couldn't find error, use default & error code
00450     {
00451   fHResultString = TRUE;
00452     }
00453     awchr[0] = L'\0';
00454     if (fHResultString)
00455     {
00456   ceHResultToString(awchr, hr);
00457     }
00458
00459     if (0 == cwc)
00460     {
00461   pwszRetStatic = L"Error";
00462   pwszRet = pwszRetStatic;
00463     }
00464
00465     // strip trailing \r\n
00466
00467     cwcCopy = wcslen(pwszRet);
00468     if (2 <= cwcCopy &&
00469   L'\r' == pwszRet[cwcCopy - 2] &&
00470   L'\n' == pwszRet[cwcCopy - 1])
00471     {
00472   cwcCopy -= 2;
00473     }
00474     cwc = cwcCopy + 1 + cwcUnexpected + 1 + wcslen(awchr) + 1;
00475     pwszMsgT = (WCHAR *) LocalAlloc(LMEM_FIXED, cwc * sizeof(WCHAR));
00476     if (NULL == pwszMsgT)
00477     {
00478   _JumpError(E_OUTOFMEMORY, error, "LocalAlloc");
00479     }
00480     CopyMemory(pwszMsgT, pwszRet, cwcCopy * sizeof(WCHAR));
00481     pwszMsgT[cwcCopy] = L'\0';
00482
00483     if (0 != cwcUnexpected)
00484     {
00485   wcscat(pwszMsgT, L" ");
00486   wcscat(pwszMsgT, pwszUnexpected);
00487     }
00488     if (fHResultString)
00489     {
00490   wcscat(pwszMsgT, L" ");
00491   wcscat(pwszMsgT, awchr);
00492     }
00493     assert(wcslen(pwszMsgT) < cwc);
00494     if (NULL != pwszRet && pwszRetStatic != pwszRet)
00495     {
00496   LocalFree(const_cast<WCHAR *>(pwszRet));
00497     }
00498     pwszRet = pwszMsgT;
00499
00500 error:
00501     if (NULL != hMod1)
00502     {
00503         FreeLibrary(hMod1);
00504     }
00505     if (NULL != hMod2)
00506     {
00507         FreeLibrary(hMod2);
00508     }
00509     return(pwszRet);
00510 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/MouseInfo/MousInfo.h Source File

  • WinUI
  • Input
  • MouseInfo

MousInfo.h

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////
00002 //
00003 // MODULE:      MOUSINFO.H
00004 //
00005 // DESCRIPTION: Include file for the MousInfo.Exe Tool
00006 //
00007 //
00008 //              Copyright 1995 - 2000 Microsoft Corporation.
00009 //                       All rights reserved
00010 //
00011 //
00012 ///////////////////////////////////////////////////////////////////////////
00013
00014 TCHAR szAppName[] = TEXT("MousInfo");
00015 TCHAR szClassName[] = TEXT("MousInfoClass");
00016
00017 // Maximum # of chars in title bar
00018 #define MAX_TITLE_LEN 44
00019
00020 // Index into Button Message Array
00021 #define NO_MESSAGE  0
00022 #define LBU         1   // Left Button Up
00023 #define RBU         2   // Right Button Up
00024 #define MBU         3   // Middle Button Up
00025 #define LBD         4   // Left Button Down
00026 #define RBD         5   // Right Button Down
00027 #define MBD         6   // Middle Button Down
00028 #define LB2         7   // Left Button Double Click
00029 #define MB2         8   // Right Button Double Click
00030 #define RB2         9   // Middle Button Double Click
00031 #define MW          10  // Mouse Wheel
00032 #define MH          11  // Mouse Hover
00033 #define ML          12  // Mouse Leave
00034
00035 // Resource defines
00036 #define MOUSINFO_ICON 102
00037
00038 #define IDM_MENU    0x0900
00039
00040 #define IDM_TRACK   0x1000
00041 #define IDM_HOVER   0x1001
00042 #define IDM_LEAVE   0x1002
00043
00044 #define IDM_ABOUT   0x2000
00045
00046
00047
00048 // Function Prototypes
00049 int     WINAPI   WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
00050 LRESULT CALLBACK MainWindowProc (HWND, UINT, WPARAM, LPARAM);
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/Resource.h Source File

  • WinBase
  • WtsApi
  • WtsApi

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by API.rc
00004 //
00005 #define IDD_ABOUTBOX                    100
00006 #define IDR_MAINFRAME                   128
00007 #define IDR_APITYPE                     129
00008 #define IDD_SERVERDLG                   130
00009 #define IDD_SERVER_PROCESS              131
00010 #define IDD_PROCESS                     131
00011 #define IDD_SESSION                     132
00012 #define IDD_QUERY_SESSION               134
00013 #define IDD_SEND_MESSAGE                135
00014 #define IDD_WAIT_SYSTEM_EVENT           136
00015 #define IDD_DIALOG1                     137
00016 #define IDD_SHUTDOWN                    138
00017 #define IDD_SETSESSION                  140
00018 #define IDC_DOMAIN_NAME                 1000
00019 #define IDC_SERVER_LIST                 1001
00020 #define IDC_BUTTON1                     1002
00021 #define IDC_LIST_SERVERS                1002
00022 #define IDC_SETSESSION                  1002
00023 #define IDC_LIST1                       1003
00024 #define IDC_PROCESS                     1003
00025 #define IDC_SESSION_LIST                1003
00026 #define IDC_EVENT_FLAGS                 1003
00027 #define IDC_SHUTDOWN_PARAMETERS         1003
00028 #define IDC_LIST2                       1004
00029 #define ID_TERMINATE_PROCESS            1005
00030 #define IDC_DISCONNECT_SESSION          1006
00031 #define IDC_LOGOFF_SESSION              1007
00032 #define IDC_QUERY_SESSION               1008
00033 #define IDQUERY                         1009
00034 #define IDC_SESSION_INFO                1010
00035 #define ID_SEND_MESSAGE                 1012
00036 #define IDC_VIRTUAL_CHANNEL             1013
00037 #define IDC_SERVER_NAME                 1015
00038 #define IDC_SERVERNAME                  1017
00039 #define IDC_REFRESH                     1019
00040 #define IDSHUTDOWN                      1022
00041 #define IDC_LIST_SESSION                1026
00042 #define IDC_USERNAME                    1030
00043 #define IDC_DOMAIN                      1031
00044 #define IDC_PASSWORD                    1032
00045 #define IDC_SERVER_LIST2                1036
00046 #define IDC_MANUAL_SERVER_NAME          1037
00047 #define IDC_CANCEL                      1038
00048 #define IDC_SEND_MESSAGE                1041
00049 #define ID_RUN_TEST                     32771
00050 #define ID_SERVER                       32771
00051 #define ID_PROCESS                      32772
00052 #define ID_SESSION                      32773
00053 #define ID_SHUTDOWN_SYSTEM              32774
00054 #define ID_WAIT_EVENT                   32777
00055 #define ID_VIRTUAL_CHANNEL              32778
00056
00057 // Next default values for new objects
00058 //
00059 #ifdef APSTUDIO_INVOKED
00060 #ifndef APSTUDIO_READONLY_SYMBOLS
00061 #define _APS_3D_CONTROLS                     1
00062 #define _APS_NEXT_RESOURCE_VALUE        143
00063 #define _APS_NEXT_COMMAND_VALUE         32780
00064 #define _APS_NEXT_CONTROL_VALUE         1043
00065 #define _APS_NEXT_SYMED_VALUE           101
00066 #endif
00067 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/osp/vc/common.cpp Source File

  • Dataaccess
  • osp
  • vc

common.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample OLE DB Simple Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation.  All Rights Reserved.
00004 //
00005 // module COMMON.CPP | Common Routines
00006 //
00007 //--------------------------------------------------------------------
00008
00009 ////////////////////////////////////////////////////////
00010 // Defines
00011 //
00012 ////////////////////////////////////////////////////////
00013 #define INITGUID
00014 #define DBINITCONSTANTS
00015
00016 //Common Header
00017 #include "Common.h"
00018
00019 ////////////////////////////////////////////////////////
00020 // CompareVariant
00021 //
00022 ////////////////////////////////////////////////////////
00023 BOOL CompareVariant
00024 (
00025   VARIANT *pVar1, //@parm [in]: Pointer to the variant in the consumer's buffer.
00026   VARIANT *pVar2, //@parm [in]: Pointer to the variant at the backend.
00027   BOOL fCaseSensitive
00028 )
00029 {
00030   //Handle NULL cases...
00031   if(pVar1==NULL || pVar2==NULL)
00032   {
00033     if(pVar1 == pVar2)
00034       return TRUE;
00035     return FALSE;
00036   }
00037
00038   // The variant has to be the same type
00039   if (V_VT(pVar1) != V_VT(pVar2))
00040     return FALSE;
00041
00042   // Return FALSE if vt is ORed with VT_RESERVED
00043   if (V_VT(pVar1) & VT_RESERVED)
00044     return FALSE;
00045
00046   // Return TRUE is the vt is VT_EMPTY or VT_NULL
00047   if (V_VT(pVar1)==VT_EMPTY || V_VT(pVar1)==VT_NULL)
00048     return TRUE;
00049
00050   switch(V_VT(pVar1))
00051   {
00052     case VT_UI1:
00053       return V_UI1(pVar1) == V_UI1(pVar2);
00054
00055     case VT_I2:
00056       return V_I2(pVar1) == V_I2(pVar2);
00057
00058     case VT_I4:
00059       return V_I4(pVar1) == V_I4(pVar2);
00060
00061     case VT_R4:
00062       return V_R4(pVar1) == V_R4(pVar2);
00063
00064     case VT_R8:
00065       return V_R8(pVar1) == V_R8(pVar2);
00066
00067     case VT_BOOL:
00068       return V_BOOL(pVar1) == V_BOOL(pVar2);
00069
00070     case VT_ERROR:
00071       return V_ERROR(pVar1) == V_ERROR(pVar2);
00072
00073     case VT_CY:
00074       return memcmp(&V_CY(pVar1), &V_CY(pVar2),8)==0;
00075
00076     case VT_DATE:
00077       return V_DATE(pVar1) == V_DATE(pVar2);
00078
00079     case VT_BSTR:
00080       if(fCaseSensitive)
00081         return wcscmp(V_BSTR(pVar1), V_BSTR(pVar2));
00082       else
00083         return _wcsicmp(V_BSTR(pVar1), V_BSTR(pVar2));
00084
00085     // As we are not testing OLE object, return FALSE for VT_UNKNOWN
00086     case VT_UNKNOWN:
00087       return FALSE;
00088
00089     // As we are not testing OLE object, return FALSE for VT_DISPATCH
00090     case VT_DISPATCH:
00091       return FALSE;
00092
00093     case VT_I2 | VT_BYREF:
00094       return *V_I2REF(pVar1) == *V_I2REF(pVar2);
00095
00096     case VT_I4 | VT_BYREF:
00097       return *V_I4REF(pVar1) == *V_I4REF(pVar2);
00098
00099     case VT_R4 | VT_BYREF:
00100       return *V_R4REF(pVar1) == *V_R4REF(pVar2);
00101
00102     case VT_R8 | VT_BYREF:
00103       return *V_R8REF(pVar1) == *V_R8REF(pVar2);
00104
00105     case VT_BOOL | VT_BYREF:
00106       return *V_BOOLREF(pVar1) == *V_BOOLREF(pVar2);
00107
00108     case VT_ERROR | VT_BYREF:
00109       return *V_ERRORREF(pVar1) == *V_ERRORREF(pVar2);
00110
00111     case VT_CY | VT_BYREF:
00112       return memcmp(V_CYREF(pVar1), V_CYREF(pVar2),8)==0;
00113
00114     case VT_DATE | VT_BYREF:
00115       return *V_DATEREF(pVar1) == *V_DATEREF(pVar2);
00116
00117     case VT_BSTR | VT_BYREF:
00118       if(fCaseSensitive)
00119         return wcscmp(*V_BSTRREF(pVar1), *V_BSTRREF(pVar2));
00120       else
00121         return _wcsicmp(*V_BSTRREF(pVar1), *V_BSTRREF(pVar2));
00122
00123     // As we are not testing OLE object, return FALSE for VT_UNKNOWN
00124     case VT_UNKNOWN | VT_BYREF:
00125       return FALSE;
00126
00127     // As we are not testing OLE object, return FALSE for VT_DISPATCH
00128     case VT_DISPATCH | VT_BYREF:
00129       return FALSE;
00130   }
00131
00132   return FALSE;
00133 }
00134
00135 ////////////////////////////////////////////////////////
00136 // HRESULT GetRegEntry
00137 //
00138 ////////////////////////////////////////////////////////
00139 HRESULT GetRegEntry(REGENTRY* pRegEntry, CHAR* pszValue, ULONG cBytes)
00140 {
00141   return GetRegEntry(pRegEntry->hRootKey, pRegEntry->szKeyName, pRegEntry->szValueName, pszValue, cBytes);
00142 }
00143
00144
00145 ////////////////////////////////////////////////////////
00146 // HRESULT GetRegEntry
00147 //
00148 ////////////////////////////////////////////////////////
00149 HRESULT GetRegEntry(HKEY hRootKey, CHAR* pszKeyName, CHAR* pszValueName, CHAR* pszValue, ULONG cBytes)
00150 {
00151   HRESULT hr = E_FAIL;
00152   HKEY hKey = NULL;
00153
00154   //no-op, pszValueName is not required
00155   if(!pszKeyName || !pszValue)
00156     return E_FAIL;
00157
00158   //Obtain the Key for HKEY_CLASSES_ROOT\"SubKey"
00159   if(ERROR_SUCCESS != RegOpenKeyEx(hRootKey, pszKeyName, 0, KEY_READ, &hKey))
00160     goto CLEANUP;
00161
00162   //Obtain the Data for the above key
00163   if(ERROR_SUCCESS == RegQueryValueEx(hKey, pszValueName, NULL, NULL, (LPBYTE)pszValue, &cBytes))
00164     hr = S_OK;
00165
00166 CLEANUP:
00167   if(hKey)
00168     RegCloseKey(hKey);
00169
00170   return hr;
00171 }
00172
00173
00174 ////////////////////////////////////////////////////////
00175 // HRESULT SetRegEntry
00176 //
00177 ////////////////////////////////////////////////////////
00178 HRESULT SetRegEntry(REGENTRY* pRegEntry)
00179 {
00180   return SetRegEntry(pRegEntry->hRootKey, pRegEntry->szKeyName, pRegEntry->szValueName, pRegEntry->szValue);
00181 }
00182
00183
00184 ////////////////////////////////////////////////////////
00185 // HRESULT SetRegEntry
00186 //
00187 ////////////////////////////////////////////////////////
00188 HRESULT SetRegEntry(HKEY hRootKey, CHAR* pszKeyName, CHAR* pszValueName, CHAR* pszValue)
00189 {
00190   HRESULT hr = E_FAIL;
00191   HKEY hKey = NULL;
00192   ULONG dwDisposition;
00193
00194   //no-op, pszValueName is not required
00195   if(!pszKeyName || !pszValue)
00196     return E_FAIL;
00197
00198   //Create the Key for HKEY_CLASSES_ROOT\"SubKey"
00199     if(ERROR_SUCCESS != RegCreateKeyEx(hRootKey, pszKeyName, 0, NULL,
00200       REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition))
00201       goto CLEANUP;
00202
00203   //Set the data for the above key
00204     if(ERROR_SUCCESS == RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
00205             (BYTE*)pszValue, strlen(pszValue) + sizeof(CHAR)))
00206     hr = S_OK;
00207
00208 CLEANUP:
00209   if(hKey)
00210     RegCloseKey(hKey);
00211
00212   return hr;
00213 }
00214
00215
00216 ////////////////////////////////////////////////////////
00217 // HRESULT DelRegEntry
00218 //
00219 ////////////////////////////////////////////////////////
00220 HRESULT DelRegEntry(REGENTRY* pRegEntry)
00221 {
00222   return DelRegEntry(pRegEntry->hRootKey, pRegEntry->szKeyName);
00223 }
00224
00225 ////////////////////////////////////////////////////////
00226 // HRESULT DelRegEntry
00227 //
00228 ////////////////////////////////////////////////////////
00229 HRESULT DelRegEntry(HKEY hRootKey, CHAR* pszKeyName)
00230 {
00231   HKEY hKey = NULL;
00232   HRESULT hr;
00233
00234   //no-op
00235   if(!pszKeyName)
00236     return E_FAIL;
00237
00238   //Delete the Key for HKEY_CLASSES_ROOT\"SubKey"
00239   hr = RegDeleteKey(hRootKey, pszKeyName);
00240
00241   //Entry successfully deleted - return S_OK
00242   if(hr==ERROR_SUCCESS)
00243     return S_OK;
00244
00245   //Entry not found - return S_FALSE
00246   if(hr==ERROR_FILE_NOT_FOUND)
00247     return S_FALSE;
00248
00249   return E_FAIL;
00250 }
00251
00252
00253 /////////////////////////////////////////////////////////////////////////////
00254 // HRESULT ConvertToMBCS
00255 //
00256 /////////////////////////////////////////////////////////////////////////////
00257 HRESULT ConvertToMBCS(WCHAR* pwsz, CHAR* psz, ULONG cbStrLen)
00258 {
00259   //Convert the string to MBCS
00260   INT iResult = WideCharToMultiByte(CP_ACP, 0, pwsz, -1, psz, cbStrLen, NULL, NULL);
00261   return iResult ? S_OK : E_FAIL;
00262 }
00263
00264 /////////////////////////////////////////////////////////////////////////////
00265 // HRESULT ConvertToWCHAR
00266 //
00267 /////////////////////////////////////////////////////////////////////////////
00268 HRESULT ConvertToWCHAR(CHAR* psz, WCHAR* pwsz, ULONG cbStrLen)
00269 {
00270   //Convert the string to MBCS
00271   INT iResult = MultiByteToWideChar(CP_ACP, 0, psz, -1, pwsz, cbStrLen);
00272   return iResult ? S_OK : E_FAIL;
00273 }
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userwizard/extpageuser.cpp Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userwizard

extpageuser.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       ExtPageUser.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #include "stdafx.h"
00012 #include "ExtPageUser.h"
00013 #include "WizExt.h"
00014 #include "util.h"
00015
00016 BEGIN_MESSAGE_MAP(CExtPageUser, CPropertyPage)
00017   ON_BN_CLICKED(IDC_BUTTON_CHANGE_PICTURE, OnChangePicture)
00018   ON_BN_CLICKED(IDC_BUTTON_CLEAR_PICTURE, OnClearPicture)
00019 END_MESSAGE_MAP()
00020
00021 BOOL CExtPageUser::OnInitDialog()
00022 {
00023   BOOL bResult = CPropertyPage::OnInitDialog();
00024
00025   //
00026   // Set the name of the container
00027   //
00028   SetDlgItemText(IDC_EDIT_CONTAINER, m_pWizExt->GetContainerCanonicalName());
00029
00030   //
00031   // Set the class icon
00032   //
00033   ((CStatic*)GetDlgItem(IDC_STATIC_ICON))->SetIcon(m_pWizExt->GetClassIcon());
00034
00035   //
00036   // Initialize the object that manipulates the thumbnail photo
00037   //
00038   m_thumbNailPhotoHolder.Initialize(GetPathEdit()->m_hWnd, GetPicture()->m_hWnd);
00039
00040   return bResult;
00041 }
00042
00043 BOOL CExtPageUser::OnKillActive()
00044 {
00045   //
00046   // Write changes to temporary object
00047   //
00048   ASSERT(m_pWizExt != NULL);
00049   return (SUCCEEDED(WriteDataHelper()));
00050 }
00051
00052 BOOL CExtPageUser::OnSetActive()
00053 {
00054   //
00055   // Make sure we reset the next/back buttons state, just in case
00056   // some other extension changes it
00057   //
00058   SetWizardButtons();
00059
00060   return TRUE;
00061 }
00062
00063 void CExtPageUser::SetWizardButtons()
00064 {
00065   ASSERT(m_pWizExt != NULL);
00066
00067   //
00068   // Always enable the next button, we allow to have
00069   // the fields not filled in.
00070   //
00071
00072   HRESULT hr = m_pWizExt->GetIDsAdminNewObj()->SetButtons(0, TRUE /*bValid*/);
00073 }
00074
00075 void CExtPageUser::OnChangePicture()
00076 {
00077   //
00078   // just call the thumbnail photo holder to do the job
00079   //
00080   m_thumbNailPhotoHolder.Change(m_hWnd);
00081 }
00082
00083
00084
00085 void CExtPageUser::OnClearPicture()
00086 {
00087   //
00088   // just call the thumbnail photo holder to do the job
00089   //
00090   m_thumbNailPhotoHolder.Clear();
00091 }
00092
00093
00094
00095 HRESULT CExtPageUser::WriteDataHelper()
00096 {
00097   ASSERT(m_pWizExt->GetObj() != NULL);
00098   //
00099   // Write the data from the page to the temporary object given to the extension
00100   // by SetObject()
00101   //
00102
00103   HRESULT hr = S_OK;
00104
00105   CString szEmployeeID;
00106   GetIDEdit()->GetWindowText(szEmployeeID);
00107   hr = SetStringAttribute(m_pWizExt->GetObj(), _T("employeeID"), szEmployeeID);
00108   if (FAILED(hr))
00109   {
00110     // Format and display error message
00111     CString szErrorMessage;
00112     szErrorMessage.Format(_T("Failed to set employeeID to %s, hr = 0x%x"), (LPCWSTR)szEmployeeID, hr);
00113     AfxMessageBox(szErrorMessage);
00114     return hr;
00115   }
00116
00117   //
00118   // Set the thumbnail photo in the temporary object
00119   //
00120   hr = m_thumbNailPhotoHolder.Write(m_pWizExt->GetObj());
00121
00122   return hr;
00123 }
00124
00125
00126 void CExtPageUser::GetSummaryInfo(BSTR* pBstrText)
00127 {
00128   //
00129   // Format the summary string which will be displayed on the finish page of the wizard.
00130   //
00131   CString szEmployeeID;
00132   GetIDEdit()->GetWindowText(szEmployeeID);
00133
00134   CString strSummary;
00135   strSummary.Format(_T("Extension summary:\n\tEmployee ID: %s\n"), (LPCWSTR)szEmployeeID);
00136
00137   //
00138   // Copy to BSTR
00139   //
00140   *pBstrText = ::SysAllocString(strSummary);
00141
00142 }
00143
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/DbgMsg.h Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

DbgMsg.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Debugging Routines
00005
00006     FILE: DbgMsg.h
00007
00008     PURPOSE: Routines for debugging system services
00009
00010     FUNCTIONS:
00011         DbgMsgOpenLog - Opens the profile log.
00012         DbgMsgRecord - Records and event.
00013         DbgMsgCloseLog - Closes the profile log.
00014
00015 */
00016 #pragma once
00017
00018 // Maximum size for the debug log.
00019 // After the log reaches this size new entries "fall off" (threy
00020 // do not get reorded).
00021 #define DEBUG_LOG_MAX_SIZE (10*1024*1024)
00022
00023 // Used for mutial exclusion when generating and
00024 // writing the debug information.
00025 extern CRITICAL_SECTION DbgMsgCriticalSection;
00026
00027 /*
00028     FUNCTION: DbgMsgOpenLog
00029
00030     COMMENTS:
00031
00032 */
00033 VOID DbgMsgOpenLog(LPTSTR LogFileName);
00034
00035 /*
00036     FUNCTION: DbgMsgRecordTime
00037
00038     COMMENTS:  If the maximum log size has been exceeded, no action is taken.
00039
00040 */
00041 VOID DbgMsgRecord(LPTSTR msg);
00042
00043 /*
00044     FUNCTION: DbgMsgCloseLog
00045
00046     COMMENTS:
00047
00048 */
00049 VOID DbgMsgCloseLog(VOID);
00050
00051 // end DbgMsg.h
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/ToolBand.h Source File

  • WinUI
  • Shell
  • BandObjs

ToolBand.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ToolBand.h
00013
00014    Description:   CToolBand definitions.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023 #include <shlobj.h>
00024 #include "Globals.h"
00025
00026 /**************************************************************************
00027    global variables and definitions
00028 **************************************************************************/
00029
00030 #ifndef TOOLBAND_H
00031 #define TOOLBAND_H
00032
00033 #define TB_CLASS_NAME (TEXT("ToolBandSampleClass"))
00034
00035 #define TB_MIN_SIZE_X   10
00036 #define TB_MIN_SIZE_Y   10
00037
00038 #define TB_MAX_SIZE_Y   25
00039
00040 /**************************************************************************
00041
00042    CToolBand class definition
00043
00044 **************************************************************************/
00045
00046 class CToolBand : public IDeskBand,
00047                   public IInputObject,
00048                   public IObjectWithSite,
00049                   public IPersistStream
00050 {
00051 protected:
00052    DWORD m_ObjRefCount;
00053
00054 public:
00055    CToolBand();
00056    ~CToolBand();
00057
00058    //IUnknown methods
00059    STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00060    STDMETHODIMP_(DWORD) AddRef();
00061    STDMETHODIMP_(DWORD) Release();
00062
00063    //IOleWindow methods
00064    STDMETHOD (GetWindow) (HWND*);
00065    STDMETHOD (ContextSensitiveHelp) (BOOL);
00066
00067    //IDockingWindow methods
00068    STDMETHOD (ShowDW) (BOOL fShow);
00069    STDMETHOD (CloseDW) (DWORD dwReserved);
00070    STDMETHOD (ResizeBorderDW) (LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
00071
00072    //IDeskBand methods
00073    STDMETHOD (GetBandInfo) (DWORD, DWORD, DESKBANDINFO*);
00074
00075    //IInputObject methods
00076    STDMETHOD (UIActivateIO) (BOOL, LPMSG);
00077    STDMETHOD (HasFocusIO) (void);
00078    STDMETHOD (TranslateAcceleratorIO) (LPMSG);
00079
00080    //IObjectWithSite methods
00081    STDMETHOD (SetSite) (IUnknown*);
00082    STDMETHOD (GetSite) (REFIID, LPVOID*);
00083
00084    //IPersistStream methods
00085    STDMETHOD (GetClassID) (LPCLSID);
00086    STDMETHOD (IsDirty) (void);
00087    STDMETHOD (Load) (LPSTREAM);
00088    STDMETHOD (Save) (LPSTREAM, BOOL);
00089    STDMETHOD (GetSizeMax) (ULARGE_INTEGER*);
00090
00091 private:
00092   BOOL m_bFocus;
00093   HWND m_hwndParent;
00094   HWND m_hWnd;
00095   DWORD m_dwViewMode;
00096    DWORD m_dwBandID;
00097    IInputObjectSite *m_pSite;
00098
00099 private:
00100   void FocusChange(BOOL);
00101    LRESULT OnKillFocus(void);
00102   LRESULT OnSetFocus(void);
00103   static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00104   LRESULT OnPaint(void);
00105   LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
00106   LRESULT OnSize(LPARAM);
00107    BOOL RegisterAndCreateWindow(void);
00108 };
00109
00110 #endif   //TOOLBAND_H
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Dt_Dll2/ApiHook.Hpp Source File

  • NetDS
  • WinSock
  • Dt_Dll2

ApiHook.Hpp

Go to the documentation of this file.
00001 // Filename  : APIHook.hpp
00002 // Abstract  : This template class encapsulates API function return
00003 //             information, invoking library information, and whether
00004 //             a DT hook is a 'pre' or 'post' notification.  This class
00005 //             really exists to make DTHandler.cpp less cluttered code.
00006 // Author    : Jeffrey C. Venable, Sr.
00007 // Copyright : THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00008 //             WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00009 //             INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
00010 //             MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00011 //             Copyright (C) 1998 - 2001,  Microsoft Corporation.
00012 //             All rights reserved.
00013
00014 #ifndef _APIHOOK_HPP
00015 #define _APIHOOK_HPP
00016
00017 template<class T>
00018 class APIHook {
00019
00020     APIHook();
00021
00022     const T *_rValue;
00023     const char *const _libName;
00024     const bool _preAPI;
00025
00026 public :
00027
00028     APIHook(const T *returnValue, const char *const libraryName, const bool preAPI) :
00029             _rValue(returnValue), _libName(libraryName), _preAPI(preAPI) {}
00030
00031     inline const T *
00032     rValue() { return (_rValue); }
00033
00034     inline const char *const
00035     libName() { return (_libName); }
00036
00037     inline const bool
00038     preAPI() { return (_preAPI); }
00039
00040 }; // class APIHook
00041
00042 #endif
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicClien/LicClien.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicClien

LicClien.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      LICCLIEN.H
00003
00004   Summary:   Include file for the LICCLIEN code sample application.
00005              In addition to class definitions, this LICCLIEN.H file
00006              contains definitions of the application's menu, string,
00007              and other resource IDs.
00008
00009              Based largely on the DLLCLIEN.EXE source code, this include
00010              file has resource IDs for the set of new menus for exercising
00011              the several COM components manipulated in this COM Client.
00012              Of special interest are the new menus for exercising the
00013              licensed COM components housed in the partner LICSERVE server.
00014
00015              For a comprehensive tutorial code tour of LICCLIEN's
00016              contents and offerings see the tutorial LICCLIEN.HTM file.
00017              For more specific technical details on the internal workings
00018              see the comments dispersed throughout the LICCLIEN source code.
00019
00020   Classes:   CMainWindow
00021
00022   Functions: WinMain
00023
00024   Origin:    10-5-95: atrent - Editor-inheritance from the DLLCLIEN source.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(LICCLIEN_H)
00042 #define LICCLIEN_H
00043
00044 #ifdef __cplusplus
00045
00046 extern CMsgLog* g_pMsgLog;
00047
00048 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00049   Class:    CMainWindow
00050
00051   Summary:  Class to encapsulate the application's main window, menu, and
00052             message dispatching behavior.
00053
00054   Methods:  CMainWindow
00055               Constructor.
00056             InitInstance
00057               Creates a new instance of the main window.
00058 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00059 class CMainWindow: public CVirWindow
00060 {
00061 public:
00062   CMainWindow();
00063   ~CMainWindow();
00064   BOOL InitInstance(HINSTANCE, int);
00065
00066   // A method for getting an interface on a COM object.
00067   BOOL GetInterface(IUnknown* pObj, REFIID riid, PPVOID ppv);
00068
00069   TCHAR m_szFileName[MAX_PATH];
00070   CMsgBox*  m_pMsgBox;
00071   CMsgLog*  m_pMsgLog;
00072   BSTR      m_bstrLicKey;
00073
00074   // Some member variables to store pointers to Car-like COM Objects.
00075   // We save pointers to each COM objects controlling IUnknown.
00076   IUnknown* m_pCar;
00077   IUnknown* m_pUtilityCar;
00078   IUnknown* m_pLicCruiseCar;
00079   IUnknown* m_pUtilityCruiseCar;
00080
00081   // Some cached pointers to the the Car Sample utility objects.
00082   ISample*  m_pLicCarSample;
00083   ISample*  m_pDllCarSample;
00084
00085 protected:
00086   LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00087
00088 private:
00089   LRESULT DoMenu(WPARAM wParam, LPARAM lParam);
00090
00091   WORD m_wWidth;
00092   WORD m_wHeight;
00093   TCHAR m_szHelpFile[MAX_PATH];
00094   TCHAR m_szFileTitle[MAX_PATH];
00095   TEXTMETRIC m_tm;
00096   OPENFILENAME m_ofnFile;
00097 };
00098
00099 #endif // __cplusplus
00100
00101 // Window Class String Macros.
00102 #define MAIN_WINDOW_TITLE_STR       "LICCLIEN: Tutorial Code Sample"
00103 #define MAIN_WINDOW_CLASS_NAME_STR  "LICCLIENWindow"
00104 #define MAIN_WINDOW_CLASS_MENU_STR  "LICCLIENMenu"
00105
00106 // File Name String Macros.
00107 #define LICSERVE_TUTFILE_STR        "licserve.htm"
00108 #define DLLSERVE_TUTFILE_STR        "dllserve.htm"
00109
00110 // OpenFile-related String Macros.
00111 #define OFN_DEFAULTFILES_STR "All Files (*.*)\0*.*\0"
00112 #define OFN_DEFAULTTITLE_STR "Open File"
00113
00114 // File Menu Command Identifiers.
00115 #define IDM_FILE_EXIT               1000
00116
00117 // Car Menu Command Identifiers.
00118 #define IDM_CAR_CREATE              1100
00119 #define IDM_CAR_RELEASE             1101
00120 #define IDM_CAR_SHIFT               1102
00121 #define IDM_CAR_CLUTCH              1103
00122 #define IDM_CAR_SPEED               1104
00123 #define IDM_CAR_STEER               1105
00124
00125 // UtilityCar Menu Command Identifiers.
00126 #define IDM_UCAR_CREATE             1200
00127 #define IDM_UCAR_RELEASE            1201
00128 #define IDM_UCAR_SHIFT              1202
00129 #define IDM_UCAR_CLUTCH             1203
00130 #define IDM_UCAR_SPEED              1204
00131 #define IDM_UCAR_STEER              1205
00132 #define IDM_UCAR_OFFROAD            1206
00133 #define IDM_UCAR_WINCH              1207
00134
00135 // LicCruiseCar Menu Command Identifiers.
00136 #define IDM_CCAR_CREATE             1300
00137 #define IDM_CCAR_RELEASE            1301
00138 #define IDM_CCAR_SHIFT              1302
00139 #define IDM_CCAR_CLUTCH             1303
00140 #define IDM_CCAR_SPEED              1304
00141 #define IDM_CCAR_STEER              1305
00142 #define IDM_CCAR_ENGAGE             1306
00143 #define IDM_CCAR_ADJUST             1307
00144
00145 // UtilityCruiseCar Menu Command Identifiers.
00146 #define IDM_UCRU_GETLICKEY          1400
00147 #define IDM_UCRU_CLEARLICKEY        1401
00148 #define IDM_UCRU_CREATE             1402
00149 #define IDM_UCRU_RELEASE            1403
00150 #define IDM_UCRU_SHIFT              1404
00151 #define IDM_UCRU_CLUTCH             1405
00152 #define IDM_UCRU_SPEED              1406
00153 #define IDM_UCRU_STEER              1407
00154 #define IDM_UCRU_ENGAGE             1408
00155 #define IDM_UCRU_ADJUST             1409
00156 #define IDM_UCRU_OFFROAD            1410
00157 #define IDM_UCRU_WINCH              1411
00158
00159 // Log Menu Command Identifiers.
00160 #define IDM_LOG_LOGCLEAR            1890
00161 #define IDM_LOG_LICSERVER           1891
00162 #define IDM_LOG_DLLSERVER           1892
00163 #define IDM_LOG_LOGGING             1893
00164 #define IDM_LOG_COPYCLIP            1894
00165
00166 // Help Menu Command Identifiers.
00167 #define IDM_HELP_CONTENTS           1900
00168 #define IDM_HELP_TUTORIAL           1901
00169 #define IDM_HELP_TUTLICSERVER       1902
00170 #define IDM_HELP_TUTDLLSERVER       1903
00171 #define IDM_HELP_READSOURCE         1904
00172 #define IDM_HELP_ABOUT              1905
00173 #define IDM_HELP_ABOUTLICSERVER     1906
00174 #define IDM_HELP_ABOUTDLLSERVER     1907
00175
00176 // Error-related String Identifiers.
00177 #define IDS_COMINITFAILED           2000
00178 #define IDS_APPINITFAILED           2001
00179 #define IDS_OUTOFMEMORY             2002
00180 #define IDS_NOUNICODE               2003
00181 #define IDS_NODLLSERVER             2004
00182 #define IDS_NOLICSERVER             2005
00183 #define IDS_NOLICENSE               2006
00184 #define IDS_NORUNLICENSE            2007
00185
00186 #define IDS_ASSERT_FAIL             2200
00187
00188 // Notice-related String Identifiers.
00189 #define IDS_NOTIMPLEMENTED          2301
00190
00191 // Log Message String Identifiers.
00192 #define IDS_START_MESSAGE_LOG       2400
00193
00194 #endif
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Bag.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

Bag.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       bag.hxx
00006 //
00007 //  Contents:   Bag for Html parsing elements
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #if !defined( __BAG_HXX__ )
00012 #define __BAG_HXX__
00013
00014 class CHtmlElement;
00015
00016 const COUNT_OF_HTML_ELEMENTS = 14;
00017
00018 //+-------------------------------------------------------------------------
00019 //
00020 //  Class:      CHtmlElemBagEntry
00021 //
00022 //  Purpose:    Maps a Html token type to the corresponding parsing element
00023 //
00024 //--------------------------------------------------------------------------
00025
00026 class CHtmlElemBagEntry
00027 {
00028
00029 public:
00030     CHtmlElemBagEntry();
00031     ~CHtmlElemBagEntry();
00032
00033     void    SetHtmlElement( CHtmlElement *pHtmlElement )    { _pHtmlElement = pHtmlElement; }
00034     CHtmlElement *GetHtmlElement()                          { return _pHtmlElement; }
00035
00036     void    SetTokenType( HtmlTokenType eTokType )          { _eTokType = eTokType; }
00037     HtmlTokenType GetTokenType()                            { return _eTokType; }
00038
00039 private:
00040     CHtmlElement *      _pHtmlElement;
00041     HtmlTokenType       _eTokType;
00042 };
00043
00044
00045 //+-------------------------------------------------------------------------
00046 //
00047 //  Class:      CHtmlElementBag
00048 //
00049 //  Purpose:    To add and retrieve elements for parsing Html in an extensible manner
00050 //
00051 //--------------------------------------------------------------------------
00052
00053 class CHtmlElementBag
00054 {
00055
00056 public:
00057     CHtmlElementBag( unsigned cElems );
00058     ~CHtmlElementBag();
00059
00060     void             AddElement( HtmlTokenType eTokType, CHtmlElement *pHtmlElement );
00061     CHtmlElement *   QueryElement( HtmlTokenType eTokType );
00062
00063 private:
00064     CHtmlElemBagEntry *         _aBagEntry;
00065     unsigned                    _uMaxSize;
00066     unsigned                    _uCurSize;
00067 };
00068
00069
00070 #endif // __BAG_HXX__
00071
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/io/ASyncTrans/openf.h Source File

  • Web
  • iis
  • extensions
  • io
  • ASyncTrans

openf.h

Go to the documentation of this file.
00001 /* Copyright(c) 1995-2002 Microsoft Corporation
00002
00003   Module Name:
00004
00005     openf.h
00006
00007   Abstract:
00008
00009     This module defines functions for opening and closing files
00010     and provides transparent caching for file handles
00011 */
00012
00013 # ifndef _OPENF_HXX_
00014 # define _OPENF_HXX_
00015
00016 # include <windows.h>
00017 # include <httpext.h>
00018
00019 #define InitializeListHead(ListHead) (\
00020     (ListHead)->Flink = (ListHead)->Blink = (ListHead))
00021
00022 #define IsListEmpty(ListHead) \
00023     ((ListHead)->Flink == (ListHead))
00024
00025 #define RemoveHeadList(ListHead) \
00026     (ListHead)->Flink;\
00027     {RemoveEntryList((ListHead)->Flink)}
00028
00029 #define RemoveTailList(ListHead) \
00030     (ListHead)->Blink;\
00031     {RemoveEntryList((ListHead)->Blink)}
00032
00033 #define RemoveEntryList(Entry) {\
00034     PLIST_ENTRY _EX_Blink;\
00035     PLIST_ENTRY _EX_Flink;\
00036     _EX_Flink = (Entry)->Flink;\
00037     _EX_Blink = (Entry)->Blink;\
00038     _EX_Blink->Flink = _EX_Flink;\
00039     _EX_Flink->Blink = _EX_Blink;\
00040                             }
00041
00042 #define InsertTailList(ListHead,Entry) {\
00043     PLIST_ENTRY _EX_Blink;\
00044     PLIST_ENTRY _EX_ListHead;\
00045     _EX_ListHead = (ListHead);\
00046     _EX_Blink = _EX_ListHead->Blink;\
00047     (Entry)->Flink = _EX_ListHead;\
00048     (Entry)->Blink = _EX_Blink;\
00049     _EX_Blink->Flink = (Entry);\
00050     _EX_ListHead->Blink = (Entry);\
00051                                     }
00052 #define InsertHeadList(ListHead,Entry) {\
00053     PLIST_ENTRY _EX_Flink;\
00054     PLIST_ENTRY _EX_ListHead;\
00055     _EX_ListHead = (ListHead);\
00056     _EX_Flink = _EX_ListHead->Flink;\
00057     (Entry)->Flink = _EX_Flink;\
00058     (Entry)->Blink = _EX_ListHead;\
00059     _EX_Flink->Blink = (Entry);\
00060     _EX_ListHead->Flink = (Entry);\
00061                                     }
00062 /* Initialization and cleanup functions */
00063
00064 DWORD CleanupFileHandleCache(VOID);
00065 HANDLE FcOpenFile(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile);
00066 DWORD FcCloseFile(IN HANDLE hFile);
00067 BOOL FcReadFromFile(IN HANDLE hFile, OUT CHAR *pchBuffer, IN  DWORD dwBufferSize, OUT LPDWORD pcbRead, IN OUT LPOVERLAPPED pov);
00068 VOID InitFileHandleCache(VOID);
00069
00070 # endif
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/Imp_Draw/DrawArea.h Source File

  • NetDS
  • MessageQueuing
  • Imp_Draw

DrawArea.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // drawarea.h : header file
00014 //
00015
00016
00017 #include <afxtempl.h>
00018
00019 #define MAX_MSG_BODY_LEN 32
00020
00021 typedef struct tagLINE
00022 {
00023   CPoint ptStart;
00024   CPoint ptEnd;
00025 } LINE;
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // CDrawArea window
00029
00030 class CDrawArea : public CEdit
00031 {
00032 // Construction
00033 public:
00034   CDrawArea();
00035
00036 // Attributes
00037 public:
00038
00039 protected:
00040   CPoint m_ptLast;
00041   CList<LINE, LINE &> m_listLines;
00042
00043 // Operations
00044 public:
00045   void AddLine(LINE line);
00046   void AddKeystroke(char *mbsKey);
00047
00048 // Overrides
00049   // ClassWizard generated virtual function overrides
00050   //{{AFX_VIRTUAL(CDrawArea)
00051   //}}AFX_VIRTUAL
00052
00053 // Implementation
00054 public:
00055   virtual ~CDrawArea();
00056
00057   // Generated message map functions
00058 protected:
00059   //{{AFX_MSG(CDrawArea)
00060   afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00061   afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00062   afx_msg void OnPaint();
00063   afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
00064   afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
00065   afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00066   afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00067   afx_msg void OnSetFocus(CWnd* pOldWnd);
00068   afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
00069   afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00070   //}}AFX_MSG
00071
00072   DECLARE_MESSAGE_MAP()
00073 };
00074
00075 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/Xmit/Xmitu.c Source File

  • NetDS
  • RPC
  • Data
  • Xmit

Xmitu.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         xmit Example
00005
00006     FILE:       xmitu.c
00007
00008     PURPOSE:    Utility functions used by both client and server
00009                 sides of the RPC distributed application.
00010                 This sample demonstrates the transmit_as example.
00011                 A doubly-linked list is transmitted over the network
00012                 as a sized array.
00013
00014     RELATED:    xmits.c - server main
00015                 xmitp.c - remote procedures
00016                 xmitc.c - client main
00017
00018     FUNCTIONS:  DOUBLE_LINK_TYPE_to_xmit - convert list to array
00019                 DOUBLE_LINK_TYPE_from_xmit - convert array to list
00020                 DOUBLE_LINK_TYPE_free_inst - free linked list memory
00021                 DOUBLE_LINK_TYPE_free_xmit - free array memory
00022                 midl_user_allocate - user-supplied memory allocator
00023                 midl_user_free - user-supplied routine to free memory
00024
00025                 ArrayWalkProc - utility to display the array
00026                 ListWalkProc - utility to display the linked list
00027                 InsertNewNode - utility to add a node to the list
00028
00029     COMMENTS:   This sample program generates a linked list to
00030                 demonstrate how a list with aliasing can be transmitted
00031                 using the transmit_as attribute as a sized array.
00032                 The pointers are rebuilt on the server side.
00033
00034 ****************************************************************************/
00035
00036 #include <stdlib.h>
00037 #include <stdio.h>
00038 #include "xmit.h"    // header file generated by MIDL compiler
00039 #include "xmitu.h"
00040
00041
00042 /***************************************************************************/
00043
00044 void ArrayWalkProc(DOUBLE_XMIT_TYPE * pArray)
00045 {
00046     int i;
00047
00048     printf("Display contents of transmitted array:\n");
00049     for (i = 0; i < pArray->sSize; i++)
00050         printf("pArray->asNumber[%d] = %d\n", i, pArray->asNumber[i]);
00051 }
00052
00053 void ListWalkProc(DOUBLE_LINK_TYPE * pList)
00054 {
00055     printf("Display contents of doubly linked list:\n");
00056     while (pList != NULL) {
00057         printf("pList %p = %d, Next = %p\n",
00058                pList, pList->sNumber, pList->pNext);
00059         pList = pList->pNext;
00060     }
00061 }
00062
00063 DOUBLE_LINK_TYPE * InsertNewNode(short sValue, DOUBLE_LINK_TYPE * pPrevious)
00064 {
00065     DOUBLE_LINK_TYPE * pNew;
00066
00067     do {
00068         pNew = (DOUBLE_LINK_TYPE *)midl_user_allocate(sizeof(DOUBLE_LINK_TYPE));
00069     } while (pNew == pPrevious);
00070
00071     pNew->pNext = NULL;      // initialize
00072     pNew->pPrevious = NULL;  // initialize
00073     pNew->sNumber = sValue;  // insert b between a and c
00074
00075     pNew->pPrevious = pPrevious;             // prev(b) = a
00076     if (pPrevious == NULL)
00077         pNew->pNext = NULL;
00078     else {
00079         pNew->pNext = pPrevious->pNext;      // next(b) = c
00080         pPrevious->pNext = pNew;             // next(a) = b
00081         if (pNew->pNext != NULL)
00082             (pNew->pNext)->pPrevious = pNew; // prev(c) = b
00083     }
00084
00085     return(pNew);
00086 }
00087
00088
00089 /***************************************************************************/
00090
00091 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00092 {
00093     return(malloc(len));
00094 }
00095
00096 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00097 {
00098     free(ptr);
00099 }
00100
00101
00102 /***************************************************************************/
00103
00104 /* convert from linked list to array */
00105 void __RPC_USER
00106 DOUBLE_LINK_TYPE_to_xmit(
00107     DOUBLE_LINK_TYPE __RPC_FAR * pList,
00108     DOUBLE_XMIT_TYPE __RPC_FAR * __RPC_FAR * ppArray)
00109 {
00110     short cCount = 0;
00111     DOUBLE_LINK_TYPE * pHead = pList;  // save pointer to start
00112     DOUBLE_XMIT_TYPE * pArray;
00113
00114     /* count the number of elements to allocate memory */
00115     for (; pList != NULL; pList = pList->pNext)
00116         cCount++;
00117
00118     /* allocate the memory for the array */
00119     pArray = (DOUBLE_XMIT_TYPE *) midl_user_allocate
00120              (sizeof(DOUBLE_XMIT_TYPE) + (cCount * sizeof(short)));
00121     pArray->sSize = cCount;
00122
00123     /* copy the linked list contents into the array */
00124     for (cCount = 0, pList = pHead; pList != NULL; pList = pList->pNext)
00125         pArray->asNumber[cCount++] = pList->sNumber;
00126
00127     /* return the address of the pointer to the array */
00128     *ppArray = pArray;
00129 }
00130
00131 /* convert from array to linked list */
00132 void __RPC_USER
00133 DOUBLE_LINK_TYPE_from_xmit(
00134     DOUBLE_XMIT_TYPE __RPC_FAR * pArray,
00135     DOUBLE_LINK_TYPE __RPC_FAR * pList)
00136 {
00137     DOUBLE_LINK_TYPE *pCurrent;
00138     int i;
00139
00140     if (pArray->sSize <= 0) {  // error checking
00141         pList = NULL;
00142         return;
00143     }
00144
00145     if (pList == NULL)
00146         pList = InsertNewNode(pArray->asNumber[0], NULL);
00147     else {
00148         DOUBLE_LINK_TYPE_free_inst(pList);  // free all other nodes
00149         pList->sNumber = pArray->asNumber[0];
00150         pList->pNext = NULL;
00151     }
00152
00153     pCurrent = pList;
00154     for (i = 1; i < pArray->sSize; i++)  // write new values
00155         pCurrent = InsertNewNode(pArray->asNumber[i], pCurrent);
00156 }
00157
00158
00159 /* free the doubly linked list */
00160 /* move forward through list, freeing the previous entry */
00161 void __RPC_USER
00162 DOUBLE_LINK_TYPE_free_inst(
00163     DOUBLE_LINK_TYPE __RPC_FAR * pList)
00164 {
00165     while (pList->pNext != NULL)  // go to end of list
00166         pList = pList->pNext;
00167
00168     pList = pList->pPrevious;
00169     while (pList != NULL) {  // back through list
00170         midl_user_free(pList->pNext);
00171         pList = pList->pPrevious;
00172     }
00173 }
00174
00175 /* free the array structure */
00176 void __RPC_USER
00177 DOUBLE_LINK_TYPE_free_xmit(
00178     DOUBLE_XMIT_TYPE __RPC_FAR * pArray)
00179 {
00180     midl_user_free(pArray);
00181 }
00182
00183 /* end file xmitu.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/capicom/c_sharp/chainsh/AssemblyInfo.cs Source File

  • Security
  • capicom
  • c_sharp
  • chainsh

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("")]
00010 [assembly: AssemblyDescription("")]
00011 [assembly: AssemblyConfiguration("")]
00012 [assembly: AssemblyCompany("")]
00013 [assembly: AssemblyProduct("")]
00014 [assembly: AssemblyCopyright("")]
00015 [assembly: AssemblyTrademark("")]
00016 [assembly: AssemblyCulture("")]
00017
00018 //
00019 // Version information for an assembly consists of the following four values:
00020 //
00021 //      Major Version
00022 //      Minor Version
00023 //      Build Number
00024 //      Revision
00025 //
00026 // You can specify all the values or you can default the Revision and Build Numbers
00027 // by using the '*' as shown below:
00028
00029 [assembly: AssemblyVersion("1.0.*")]
00030
00031 //
00032 // In order to sign your assembly you must specify a key to use. Refer to the
00033 // Microsoft .NET Framework documentation for more information on assembly signing.
00034 //
00035 // Use the attributes below to control which key is used for signing.
00036 //
00037 // Notes:
00038 //   (*) If no key is specified, the assembly is not signed.
00039 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00040 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00041 //       a key.
00042 //   (*) If the KeyFile and the KeyName values are both specified, the
00043 //       following processing occurs:
00044 //       (1) If the KeyName can be found in the CSP, that key is used.
00045 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00046 //           in the KeyFile is installed into the CSP and used.
00047 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00048 //       When specifying the KeyFile, the location of the KeyFile should be
00049 //       relative to the project output directory which is
00050 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00051 //       located in the project directory, you would specify the AssemblyKeyFile
00052 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00053 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00054 //       documentation for more information on this.
00055 //
00056 [assembly: AssemblyDelaySign(false)]
00057 [assembly: AssemblyKeyFile("")]
00058 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/MTXSample/MoveMoney.h Source File

  • Web
  • iis
  • Components
  • Cpp
  • MTXSample

MoveMoney.h

Go to the documentation of this file.
00001 // MoveMoney.h : Declaration of the CMoveMoney
00002
00003 #ifndef __MOVEMONEY_H_
00004 #define __MOVEMONEY_H_
00005
00006 #include "resource.h"       // main symbols
00007
00008 /////////////////////////////////////////////////////////////////////////////
00009 // CMoveMoney
00010 class ATL_NO_VTABLE CMoveMoney :
00011   public CComObjectRootEx<CComSingleThreadModel>,
00012   public CComCoClass<CMoveMoney, &CLSID_MoveMoney>,
00013   public ISupportErrorInfo,
00014   public IDispatchImpl<IMoveMoney, &IID_IMoveMoney, &LIBID_BANKVCLib>
00015 {
00016 public:
00017   CMoveMoney()
00018   {
00019   }
00020
00021 DECLARE_REGISTRY_RESOURCEID(IDR_MOVEMONEY)
00022
00023 DECLARE_PROTECT_FINAL_CONSTRUCT()
00024
00025 BEGIN_COM_MAP(CMoveMoney)
00026   COM_INTERFACE_ENTRY(IMoveMoney)
00027   COM_INTERFACE_ENTRY(IDispatch)
00028   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00029 END_COM_MAP()
00030
00031 // ISupportsErrorInfo
00032   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00033
00034 // IMoveMoney
00035 public:
00036   STDMETHOD(Perform)(/*[in]*/long lngAcnt1, /*[in]*/ long lngAcnt2, /*[in]*/long lngAmount, /*[in]*/long lngType, /*[out, retval]*/BSTR* pVal);
00037 };
00038
00039 #endif //__MOVEMONEY_H_
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook ServerEx/StdAfx.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook ServerEx

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  ClipBook ServerEx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 const WCHAR g_wszResourceTypeNames[] =
00008         L"ClipBook Server\0"
00009         ;
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__81709773_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00007 #define AFX_STDAFX_H__81709773_0672_11D2_B218_0000F87A6B50__INCLUDED_
00008
00009 #if _MSC_VER >= 1000
00010 #pragma once
00011 #endif // _MSC_VER >= 1000
00012
00013 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00014
00015 #include <afxwin.h>         // MFC core and standard components
00016 #include <afxext.h>         // MFC extensions
00017 #ifndef _AFX_NO_AFXCMN_SUPPORT
00018 #include <afxcmn.h>     // MFC support for Windows Common Controls
00019 #endif // _AFX_NO_AFXCMN_SUPPORT
00020 #include <afxole.h>
00021 #include <atlbase.h>
00022 #include <atlconv.h>
00023 #include <activeds.h>
00024
00025
00026 typedef void (* ADSDLGPROC)(LPUNKNOWN, LPUNKNOWN*);
00027
00028 typedef struct tagADSIIF
00029 {
00030   const GUID    *pIID;
00031   LPTSTR       szIf;
00032   ADSDLGPROC     pFn;
00033 } ADSIIF;
00034
00035 typedef struct tagADSERRMSG
00036 {
00037   HRESULT    hr;
00038   LPCTSTR    pszError;
00039 }ADSERRMSG;
00040
00041 #define MAKEADSENTRY(x)  &IID_##x, _T(#x)
00042 #define ADDADSERROR(x)   x, _T(#x)
00043 #define DECLAREADSPROC(x) void DlgProc##x(LPUNKNOWN, LPUNKNOWN *ppNew=NULL); \
00044 void DlgProc##x(LPUNKNOWN pUnk, LPUNKNOWN *ppNew) { CDlg##x dlg( pUnk); dlg.DoModal(); }
00045
00046 #define ARROW_SYMBOL _T("--> ")
00047
00048 #include "helper.h"
00049
00050 //{{AFX_INSERT_LOCATION}}
00051 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00052
00053 #endif // !defined(AFX_STDAFX_H__81709773_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00054
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWebBrowser Member List

This is the complete list of members for CWebBrowser, including all inherited members.
CanInPlaceActivate(void) | COleClient | [inline]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
COleClient(HWND hWndParent=NULL, UINT nID=0) | COleClient | [inline]
ContextSensitiveHelp(BOOL fEnterMode) | COleClient | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWebBrowser(HWND hWndParent=NULL, UINT nID=0) | CWebBrowser | [inline]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeactivateAndUndo(void) | COleClient | [inline]
DestroyWindow() | CWndLite | [virtual]
DiscardUndoState(void) | COleClient | [inline]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetContainer(IOleContainer **ppContainer) | COleClient | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid) | COleClient | [inline]
GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) | COleClient | [inline]
GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo) | COleClient | [inline]
GetTypeInfoCount(UINT *pctinfo) | COleClient | [inline]
GetWindow(HWND *phwnd) | COleClient | [inline]
GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) | COleClient | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pvarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) | CWebBrowser | [inline]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
Load(IStream *pIStream) | CWebBrowser | [inline, virtual]
m_bUnicodeMsg | CWndLite |
m_cRef | COleClient | [protected]
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_spLoadStream | CWebBrowser |
m_spOleObject | CWebBrowser |
m_spWebBrowser2 | CWebBrowser |
m_wndPlacement | CWndLite |
Navigate(LPWSTR pwszURL) | CWebBrowser | [inline, virtual]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDocumentComplete() | CWebBrowser | [inline, virtual]
OnDownloadBegin() | CWebBrowser | [inline, virtual]
OnDownloadComplete() | CWebBrowser | [inline, virtual]
OnDownloadControl() | CWebBrowser | [inline, virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWebBrowser | [inline, virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnInPlaceActivate(void) | COleClient | [inline]
OnInPlaceDeactivate(void) | COleClient | [inline]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNavigateComplete() | CWebBrowser | [inline, virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnPosRectChange(LPCRECT lprcPosRect) | COleClient | [inline]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnShowWindow(BOOL fShow) | COleClient | [inline]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUIActivate(void) | COleClient | [inline]
OnUIDeactivate(BOOL fUndoable) | COleClient | [inline]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | COleClient | [inline]
RequestNewObjectLayout(void) | COleClient | [inline]
SaveObject(void) | COleClient | [inline]
Scroll(SIZE scrollExtant) | COleClient | [inline]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
Show(LONG iVerb=OLEIVERB_INPLACEACTIVATE) | CWebBrowser | [inline, virtual]
ShowObject(void) | COleClient | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
STDMETHOD_(ULONG, AddRef)() | COleClient | [inline]
STDMETHOD_(ULONG, Release)() | COleClient | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~COleClient() | COleClient | [inline, virtual]
~CWebBrowser() | CWebBrowser | [inline, virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::SaveOptionsEnum Member List

This is the complete list of members for msado15::SaveOptionsEnum, including all inherited members.
adSaveCreateNotExist | msado15::SaveOptionsEnum | [static]
adSaveCreateOverWrite | msado15::SaveOptionsEnum | [static]
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptServe/AptServe.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptServe

AptServe.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      APTSERVE.CPP
00003
00004   Summary:   Based largely on the LOCSERVE.EXE source code, this module
00005              implements the main framework for a Win32 .EXE application.
00006              This application is meant to run hidden as a local multiple
00007              Apartment COM server that offers the Car, UtilityCar, and
00008              CruiseCar components.  Though this local server offers a
00009              simple main window and menu system these are not seen during
00010              normal operation.  This server can be run stand-alone for
00011              debugging purposes by explicitly using the -embedding command
00012              line switch and invoking APTSERVE prior to the client.
00013
00014              This local server supports self-registration and this program
00015              recognizes the -RegServer and -UnregServer command line
00016              switches and has the appropriate functions (RegisterServer
00017              and UnregisterServer) to register this local server in the
00018              system Registry.
00019
00020              For a comprehensive tutorial code tour of APTSERVE's
00021              contents and offerings see the tutorial APTSERVE.HTM file.
00022              For more specific technical details on the internal workings
00023              see the comments dispersed throughout the APTSERVE source code.
00024              For more details on the APTCLIEN.EXE that APTSERVE works with
00025              see the APTCLIEN.HTM file in the main tutorial directory.
00026
00027   Classes:   CMainWindow
00028
00029   Functions: InitApplication, WinMain
00030
00031   Origin:    2-17-98: atrent - Based on LOCSERVE source. [Revised]
00032
00033 ----------------------------------------------------------------------------
00034   This file is part of the Microsoft COM Tutorial Code Samples.
00035
00036   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00037
00038   This source code is intended only as a supplement to Microsoft
00039   Development Tools and/or on-line documentation.  See these other
00040   materials for detailed information regarding Microsoft code samples.
00041
00042   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00043   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00044   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00045   PARTICULAR PURPOSE.
00046 ==========================================================================+*/
00047
00048 /*--------------------------------------------------------------------------
00049   We include WINDOWS.H for all Win32 applications.
00050   We include OLE2.H because we will make calls to the COM/OLE libraries.
00051   We include INITGUID.H only once (here) in the entire app because we
00052     will be defining GUIDs and want them as constants in the data segment.
00053   We include APPUTIL.H because we will be building this application using
00054     the convenient Virtual Window and Dialog classes and other
00055     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00056   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00057     class, GUID, and CLSID specifications.
00058   We include APTSERVE.H because it has class and resource definitions
00059     specific to this APTSERVE application.
00060   We include SERVER.H because it has internal class declarations for
00061     the server's control object.
00062   We include FACTORY.H because it has the necessary internal class factory
00063     declarations for this component server.
00064 ---------------------------------------------------------------------------*/
00065 #include <windows.h>
00066 #include <ole2.h>
00067 #include <initguid.h>
00068 #include <apputil.h>
00069 #include <micars.h>
00070 #include <carguids.h>
00071 #include "aptserve.h"
00072 #include "server.h"
00073 #include "factory.h"
00074
00075
00076 // We encapsulate the control of this COM server (eg, lock and object
00077 // counting) in a server control C++ object.  Here is it's pointer.
00078 CServer*  g_pServer = NULL;
00079
00080 // Here is a pointer for use by the global Trace Message logging macros.
00081 CSendLog* g_pMsgLog = NULL;
00082
00083
00084 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00085   Method:   CMainWindow::CMainWindow
00086
00087   Summary:  CMainWindow Constructor.
00088
00089   Args:     .
00090
00091   Modifies: m_pMsgBox.
00092
00093   Returns:  .
00094 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00095 CMainWindow::CMainWindow()
00096 {
00097   // Null the Message object pointers.
00098   m_pMsgBox = NULL;
00099   m_pMsgLog = NULL;
00100 }
00101
00102
00103 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00104   Method:   CMainWindow::~CMainWindow
00105
00106   Summary:  CMainWindow Destructor.  Destruction of the main window
00107             indicates that the application should quit and thus the
00108             PostQuitMessage API is called.
00109
00110   Args:     .
00111
00112   Modifies: .
00113
00114   Returns:  .
00115 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00116 CMainWindow::~CMainWindow()
00117 {
00118   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00119   // message and causes a delete of CMainWindow which in turn causes this
00120   // destructor to run. The WM_DESTROY results when the window is destoyed
00121   // after a close of the window. Prior to exiting the main message loop:
00122
00123   // Close down the factories (ie, Revoke and release the Class Factories).
00124   if (NULL != g_pServer)
00125     g_pServer->CloseFactories();
00126
00127   LOGF1("L<%X>: Exiting APTSERVE local server application.",TID);
00128
00129   // We delete the CMsgBox and CMsgLog objects that were made in
00130   // Initinstance and the server control object, CServer.
00131   DELETE_POINTER(g_pServer);
00132   DELETE_POINTER(m_pMsgBox);
00133   DELETE_POINTER(m_pMsgLog);
00134
00135   // We then post a WM_QUIT message to cause an exit of the main thread's
00136   // message loop and an exit of this instance of the application.
00137   PostQuitMessage(0);
00138 }
00139
00140
00141 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00142   Method:   CMainWindow::RegisterServer
00143
00144   Summary:  Member function used by this server to register itself in the
00145             system registry.
00146
00147   Args:     void.
00148
00149   Returns:  BOOL
00150               TRUE
00151 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00152 BOOL CMainWindow::RegisterServer(void)
00153 {
00154   BOOL  bOk = TRUE;
00155   TCHAR szID[GUID_SIZE+1];
00156   TCHAR szAID[GUID_SIZE+1];
00157   TCHAR szCLSID[GUID_SIZE+32];
00158   TCHAR szAPPID[GUID_SIZE+32];
00159   TCHAR szModulePath[MAX_PATH];
00160   TCHAR szExeName[MAX_PATH];
00161
00162   // Be safe with null strings in these stack-allocated strings.
00163   szID[0] = 0;
00164   szAID[0] = 0;
00165   szCLSID[0] = 0;
00166   szAPPID[0] = 0;
00167   szModulePath[0] = 0;
00168   szExeName[0] = 0;
00169
00170   // Obtain the path to this module's executable file for later use.
00171   // GetModuleFileName is an APPUTIL convenience function.
00172   GetModuleFileName(
00173     g_pServer->m_hInstServer,
00174     szModulePath,
00175     sizeof(szModulePath)/sizeof(TCHAR));
00176
00177   // Obtain the file name of this module's executable for later use.
00178   // GetExeName is an APPUTIL convenience function.
00179   GetExeName(
00180     g_pServer->m_hInstServer,
00181     szExeName);
00182
00183   /*-------------------------------------------------------------------------
00184     Create registry entries for the AptCar Component.
00185   -------------------------------------------------------------------------*/
00186   // Create some base key strings.
00187   StringFromGUID2(CLSID_AptCar, szID, GUID_SIZE);
00188   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00189   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00190   // Use the ClassID of this first component as the AppID for all
00191   // of the server's components.
00192   lstrcpyn(szAPPID, TEXT("AppID\\"), sizeof(szAPPID)/sizeof(TCHAR));
00193   lstrncat(szAPPID, szID, sizeof(szAPPID)/sizeof(TCHAR) - lstrlen(szAPPID));
00194   lstrcpyn(szAID, szID, sizeof(szAID)/sizeof(TCHAR));
00195
00196   // Create ProgID keys.
00197   SetRegKeyValue(
00198     TEXT("CTS.AptCar.1"),
00199     NULL,
00200     TEXT("AptCar Component - APTSERVE Code Sample"));
00201   SetRegKeyValue(
00202     TEXT("CTS.AptCar.1"),
00203     TEXT("CLSID"),
00204     szID);
00205
00206   // Create VersionIndependentProgID keys.
00207   SetRegKeyValue(
00208     TEXT("CTS.AptCar"),
00209     NULL,
00210     TEXT("AptCar Component - APTSERVE Code Sample"));
00211   SetRegKeyValue(
00212     TEXT("CTS.AptCar"),
00213     TEXT("CurVer"),
00214     TEXT("CTS.AptCar.1"));
00215   SetRegKeyValue(
00216     TEXT("CTS.AptCar"),
00217     TEXT("CLSID"),
00218     szID);
00219
00220   // Create entries under CLSID.
00221   SetRegKeyValue(
00222     szCLSID,
00223     NULL,
00224     TEXT("AptCar Component - APTSERVE Code Sample"));
00225   SetRegKeyValue(
00226     szCLSID,
00227     TEXT("ProgID"),
00228     TEXT("CTS.AptCar.1"));
00229   SetRegKeyValue(
00230     szCLSID,
00231     TEXT("VersionIndependentProgID"),
00232     TEXT("CTS.AptCar"));
00233   SetRegKeyValue(
00234     szCLSID,
00235     TEXT("NotInsertable"),
00236     NULL);
00237   SetRegKeyValue(
00238     szCLSID,
00239     TEXT("LocalServer32"),
00240     szModulePath);
00241   AddRegNamedValue(
00242     szCLSID,
00243     NULL,
00244     TEXT("AppID"),
00245     szAID);
00246
00247   /*-------------------------------------------------------------------------
00248     Create registry entries for the AptUtilityCar Component.
00249   -------------------------------------------------------------------------*/
00250   // Create some base key strings.
00251   StringFromGUID2(CLSID_AptUtilityCar, szID, GUID_SIZE);
00252   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00253   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00254
00255   // Create ProgID keys.
00256   SetRegKeyValue(
00257     TEXT("CTS.AptUtilityCar.1"),
00258     NULL,
00259     TEXT("AptUtilityCar Component - APTSERVE Code Sample"));
00260   SetRegKeyValue(
00261     TEXT("CTS.AptUtilityCar.1"),
00262     TEXT("CLSID"),
00263     szID);
00264
00265   // Create VersionIndependentProgID keys.
00266   SetRegKeyValue(
00267     TEXT("CTS.AptUtilityCar"),
00268     NULL,
00269     TEXT("AptUtilityCar Component - APTSERVE Code Sample"));
00270   SetRegKeyValue(
00271     TEXT("CTS.AptUtilityCar"),
00272     TEXT("CurVer"),
00273     TEXT("CTS.AptUtilityCar.1"));
00274   SetRegKeyValue(
00275     TEXT("CTS.AptUtilityCar"),
00276     TEXT("CLSID"),
00277     szID);
00278
00279   // Create entries under CLSID.
00280   SetRegKeyValue(
00281     szCLSID,
00282     NULL,
00283     TEXT("AptUtilityCar Component - APTSERVE Code Sample"));
00284   SetRegKeyValue(
00285     szCLSID,
00286     TEXT("ProgID"),
00287     TEXT("CTS.AptUtilityCar.1"));
00288   SetRegKeyValue(
00289     szCLSID,
00290     TEXT("VersionIndependentProgID"),
00291     TEXT("CTS.AptUtilityCar"));
00292   SetRegKeyValue(
00293     szCLSID,
00294     TEXT("NotInsertable"),
00295     NULL);
00296   SetRegKeyValue(
00297     szCLSID,
00298     TEXT("LocalServer32"),
00299     szModulePath);
00300   AddRegNamedValue(
00301     szCLSID,
00302     NULL,
00303     TEXT("AppID"),
00304     szAID);
00305
00306   /*-------------------------------------------------------------------------
00307     Create registry entries for the AptCruiseCar Component.
00308   -------------------------------------------------------------------------*/
00309   // Create some base key strings.
00310   StringFromGUID2(CLSID_AptCruiseCar, szID, GUID_SIZE);
00311   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00312   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00313
00314   // Create ProgID keys.
00315   SetRegKeyValue(
00316     TEXT("CTS.AptCruiseCar.1"),
00317     NULL,
00318     TEXT("AptCruiseCar Component - APTSERVE Code Sample"));
00319   SetRegKeyValue(
00320     TEXT("CTS.AptCruiseCar.1"),
00321     TEXT("CLSID"),
00322     szID);
00323
00324   // Create VersionIndependentProgID keys.
00325   SetRegKeyValue(
00326     TEXT("CTS.AptCruiseCar"),
00327     NULL,
00328     TEXT("AptCruiseCar Component - APTSERVE Code Sample"));
00329   SetRegKeyValue(
00330     TEXT("CTS.AptCruiseCar"),
00331     TEXT("CurVer"),
00332     TEXT("CTS.AptCruiseCar.1"));
00333   SetRegKeyValue(
00334     TEXT("CTS.AptCruiseCar"),
00335     TEXT("CLSID"),
00336     szID);
00337
00338   // Create entries under CLSID.
00339   SetRegKeyValue(
00340     szCLSID,
00341     NULL,
00342     TEXT("AptCruiseCar Component - APTSERVE Code Sample"));
00343   SetRegKeyValue(
00344     szCLSID,
00345     TEXT("ProgID"),
00346     TEXT("CTS.AptCruiseCar.1"));
00347   SetRegKeyValue(
00348     szCLSID,
00349     TEXT("VersionIndependentProgID"),
00350     TEXT("CTS.AptCruiseCar"));
00351   SetRegKeyValue(
00352     szCLSID,
00353     TEXT("NotInsertable"),
00354     NULL);
00355   SetRegKeyValue(
00356     szCLSID,
00357     TEXT("LocalServer32"),
00358     szModulePath);
00359   AddRegNamedValue(
00360     szCLSID,
00361     NULL,
00362     TEXT("AppID"),
00363     szAID);
00364
00365   /*-------------------------------------------------------------------------
00366     Create Server AppID entries.
00367   -------------------------------------------------------------------------*/
00368   SetRegKeyValue(
00369     szAPPID,
00370     NULL,
00371     TEXT("CTS.APTSERVE(Cars).1"));
00372   SetRegKeyValue(
00373     TEXT("AppID"),
00374     szExeName,
00375     NULL);
00376   AddRegNamedValue(
00377     TEXT("AppID"),
00378     szExeName,
00379     TEXT("AppID"),
00380     szAID);
00381
00382   return bOk;
00383 }
00384
00385
00386 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00387   Method:   CMainWindow::UnregisterServer
00388
00389   Summary:  Member function used by this server to unregister itself from
00390             the system Registry.
00391
00392   Args:     void.
00393
00394   Returns:  BOOL
00395               TRUE
00396 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00397 BOOL CMainWindow::UnregisterServer(void)
00398 {
00399   BOOL  bOk = TRUE;
00400   TCHAR szID[GUID_SIZE+1];
00401   TCHAR szCLSID[GUID_SIZE+32];
00402   TCHAR szAPPID[GUID_SIZE+32];
00403   TCHAR szExeName[MAX_PATH];
00404   TCHAR szTemp[MAX_PATH+GUID_SIZE];
00405
00406   // Obtain the file name of this module's executable for later use.
00407   GetExeName(
00408     g_pServer->m_hInstServer,
00409     szExeName);
00410
00411   /*-------------------------------------------------------------------------
00412     Delete registry entries for the AptCar Component.
00413   -------------------------------------------------------------------------*/
00414   //Create some base key strings.
00415   StringFromGUID2(CLSID_AptCar, szID, GUID_SIZE);
00416   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00417   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00418   lstrcpyn(szAPPID, TEXT("AppID\\"), sizeof(szAPPID)/sizeof(TCHAR));
00419   lstrncat(szAPPID, szID, sizeof(szAPPID)/sizeof(TCHAR) - lstrlen(szID));
00420
00421   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCar\\CurVer"));
00422   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCar\\CLSID"));
00423   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCar"));
00424
00425   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCar.1\\CLSID"));
00426   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCar.1"));
00427
00428   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00429   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00430
00431   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00432   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00433
00434   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00435   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00436
00437   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("LocalServer32"));
00438   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00439
00440   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00441
00442   /*-------------------------------------------------------------------------
00443     Delete registry entries for the AptUtilityCar Component.
00444   -------------------------------------------------------------------------*/
00445   //Create some base key strings.
00446   StringFromGUID2(CLSID_AptUtilityCar, szID, GUID_SIZE);
00447   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00448   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00449
00450   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptUtilityCar\\CurVer"));
00451   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptUtilityCar\\CLSID"));
00452   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptUtilityCar"));
00453
00454   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptUtilityCar.1\\CLSID"));
00455   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptUtilityCar.1"));
00456
00457   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00458   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00459
00460   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00461   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00462
00463   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00464   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00465
00466   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("LocalServer32"));
00467   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00468
00469   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00470
00471   /*-------------------------------------------------------------------------
00472     Delete registry entries for the AptCruiseCar Component.
00473   -------------------------------------------------------------------------*/
00474   //Create some base key strings.
00475   StringFromGUID2(CLSID_AptCruiseCar, szID, GUID_SIZE);
00476   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00477   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00478
00479   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCruiseCar\\CurVer"));
00480   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCruiseCar\\CLSID"));
00481   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCruiseCar"));
00482
00483   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCruiseCar.1\\CLSID"));
00484   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.AptCruiseCar.1"));
00485
00486   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00487   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00488
00489   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00490   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00491
00492   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00493   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00494
00495   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("LocalServer32"));
00496   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00497
00498   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00499
00500   /*-------------------------------------------------------------------------
00501     Delete registry entries for the AppID of this server.
00502   -------------------------------------------------------------------------*/
00503   wsprintf(szTemp, TEXT("%s\\%s"), TEXT("AppID"), szExeName);
00504   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00505
00506   RegDeleteKey(HKEY_CLASSES_ROOT, szAPPID);
00507
00508   return bOk;
00509 }
00510
00511
00512 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00513   Method:   CMainWindow::DoMenu
00514
00515   Summary:  Dispatch and handle the main menu commands.
00516
00517   Args:     WPARAM wParam,
00518               First message parameter (word sized).
00519             LPARAM lParam)
00520               Second message parameter (long sized).
00521
00522   Modifies: ...
00523
00524   Returns:  LRESULT
00525               Standard Windows WindowProc return value.
00526 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00527 LRESULT CMainWindow::DoMenu(
00528           WPARAM wParam,
00529           LPARAM lParam)
00530 {
00531   LRESULT lResult = FALSE;
00532   HMENU hMenu  = ::GetMenu(m_hWnd);
00533
00534   switch (LOWORD(wParam))
00535   {
00536     //----------------------------------------------------------------------
00537     // Handle File Menu Commands.
00538     //----------------------------------------------------------------------
00539     case IDM_FILE_EXIT:
00540       // The user commands us to exit this application so we tell the
00541       // Main window to close itself.
00542       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00543       break;
00544
00545     //----------------------------------------------------------------------
00546     // Handle Log Menu Commands.
00547     //----------------------------------------------------------------------
00548     case IDM_LOG_LOGCLEAR:
00549       // Clear the message log.
00550       g_pMsgLog->Clear();
00551       // Use macro to log messages.
00552       LOGID(IDS_LOGTO_SERVER);
00553       break;
00554     case IDM_LOG_COPYCLIP:
00555       // Copy trace message log to clipboard.
00556       g_pMsgLog->Copy();
00557       break;
00558
00559     //----------------------------------------------------------------------
00560     // Handle Help Menu Commands.
00561     //----------------------------------------------------------------------
00562     case IDM_HELP_ABOUT:
00563       {
00564         CAboutBox dlgAboutBox;
00565         HWND hWnd = FindWindow(NULL, TEXT(CLIENT_WINDOW_TITLE));
00566         if (NULL == hWnd)
00567           hWnd = m_hWnd;
00568
00569         LOGF1("L<%X>: === Help Menu: About APTSERVE.",TID);
00570         // Show the standard About Box dialog for this EXE by telling the
00571         // dialog C++ object to show itself by invoking its ShowDialog
00572         // method.  Pass it this EXE instance and the parent window handle.
00573         // Use a dialog resource ID for the dialog template stored in
00574         // this EXE module's resources.
00575         dlgAboutBox.ShowDialog(
00576           m_hInst,
00577           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00578           hWnd);
00579       }
00580       break;
00581
00582     default:
00583       // Defer all messages NOT handled here to the Default Window Proc.
00584       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00585       break;
00586   }
00587
00588   return(lResult);
00589 }
00590
00591
00592 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00593   Method:   CMainWindow::InitInstance
00594
00595   Summary:  Instantiates an instance of the main application window.
00596             This method must be called only once, immediately after
00597             window class construction.  We take care to delete 'this'
00598             CMainWindow if we must return the error condition FALSE.
00599
00600   Args:     HINSTANCE hInstance,
00601               Handle of the application instance.
00602             int nShow)
00603               Command to pass to ShowWindow.
00604
00605   Modifies: m_pMsgBox, m_pMsgLog.
00606
00607   Returns:  BOOL.
00608               TRUE if succeeded.
00609               FALSE if failed.
00610 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00611 BOOL CMainWindow::InitInstance(
00612        HINSTANCE hInstance,
00613        int nShow)
00614 {
00615   BOOL bOk = FALSE;
00616   HWND hWnd;
00617
00618   // Create the Message Box object.
00619   m_pMsgBox = new CMsgBox;
00620   m_pMsgLog = new CSendLog;
00621
00622   if (NULL != m_pMsgBox && NULL != m_pMsgLog)
00623   {
00624     // Note, the Create method sets the m_hWnd member so we don't
00625     // need to set it explicitly here first.
00626
00627     // Here is the create of this window.  Size the window reasonably.
00628     // Create sets both m_hInst and m_hWnd.
00629     hWnd = Create(
00630              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00631              TEXT(MAIN_WINDOW_TITLE_STR),
00632              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00633                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00634              CW_USEDEFAULT,
00635              CW_USEDEFAULT,
00636              ::GetSystemMetrics(SM_CXSCREEN)*3/5,
00637              ::GetSystemMetrics(SM_CYSCREEN)*3/5,
00638              NULL,
00639              NULL,
00640              hInstance);
00641     if (hWnd)
00642     {
00643       // Assign the server's copy of the main window handle.
00644       g_pServer->m_hWndServer = m_hWnd;
00645
00646       // Init the Message Box object.
00647       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00648       {
00649         bOk = TRUE;
00650         // If the Client's Main window is found then set up logging to it.
00651         hWnd = FindWindow(NULL, TEXT(CLIENT_WINDOW_TITLE));
00652         if (NULL != hWnd)
00653         {
00654           // Tell the CSendLog object that we are logging to client.
00655           m_pMsgLog->LogToServer(FALSE);
00656           // Assign the global MsgLog pointer.
00657           g_pMsgLog = m_pMsgLog;
00658           m_pMsgLog->SetClient(m_hInst, m_hWnd, hWnd);
00659           LOGID(IDS_LOGTO_CLIENT);
00660         }
00661         else
00662         {
00663           // If the client window can't be found then create and show the
00664           // log display in this local server.
00665
00666           // Indicate we are logging to our own server log facility.
00667           m_pMsgLog->LogToServer(TRUE);
00668
00669           // Ensure the new window is shown on screen and its content
00670           // is painted.
00671           ::ShowWindow(m_hWnd, nShow);
00672           ::UpdateWindow(m_hWnd);
00673
00674           // Create the Trace Message Log ListBox as a child window that
00675           // fits the client area of the Main Window (the TRUE 3rd argument
00676           // specifies such an inside child). If you want the Trace Message
00677           // Log in a separate (but owned) window, then pass a FALSE
00678           // instead for the 3rd argument.
00679           if (m_pMsgLog->CreateServerLog(m_hInst, m_hWnd, TRUE))
00680           {
00681             // Assign the global MsgLog pointer.
00682             g_pMsgLog = m_pMsgLog;
00683             // Use macro to log an initial start messsage.
00684             LOGID(IDS_LOGTO_SERVER);
00685           }
00686           else
00687             bOk = FALSE;
00688         }
00689       }
00690     }
00691   }
00692
00693   if (!bOk)
00694   {
00695     DELETE_POINTER(m_pMsgBox);
00696     DELETE_POINTER(m_pMsgLog);
00697   }
00698
00699   return (bOk);
00700 }
00701
00702
00703 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00704   Method:   CMainWindow::WindowProc
00705
00706   Summary:  Main window procedure for this window object.  See CVirWindow
00707             in the APPUTIL library (APPUTIL.CPP) for details on how this
00708             method gets called by the global WindowProc.
00709
00710   Args:     UINT uMsg,
00711               Windows message that is "sent" to this window.
00712             WPARAM wParam,
00713               First message parameter (word sized).
00714             LPARAM lParam)
00715               Second message parameter (long sized).
00716
00717   Modifies: ...
00718
00719   Returns:  LRESULT
00720               Standard Windows WindowProc return value.
00721 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00722 LRESULT CMainWindow::WindowProc(
00723           UINT uMsg,
00724           WPARAM wParam,
00725           LPARAM lParam)
00726 {
00727   LRESULT lResult = FALSE;
00728
00729   switch (uMsg)
00730   {
00731     case WM_CREATE:
00732       break;
00733
00734     case WM_COMMAND:
00735       // Dispatch and handle any Menu command messages received.
00736       lResult = DoMenu(wParam, lParam);
00737       break;
00738
00739     case WM_CLOSE:
00740       // The user selected Close on the main window's System menu
00741       // or Exit on the File menu.
00742     case WM_QUIT:
00743       // If the app is being quit then close any associated help windows.
00744     default:
00745       // Defer all messages NOT handled here to the Default Window Proc.
00746       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00747       break;
00748   }
00749
00750   return(lResult);
00751 }
00752
00753
00754 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00755   Function: UnicodeOk
00756
00757   Summary:  Checks if the platform will handle unicode versions of
00758             Win32 API calls.
00759
00760   Args:     void
00761
00762   Modifies: .
00763
00764   Returns:  BOOL
00765               TRUE if unicode support; FALSE if not.
00766 ------------------------------------------------------------------------F-F*/
00767 BOOL UnicodeOk(void)
00768 {
00769   BOOL bOk = TRUE;
00770   TCHAR szUserName[MAX_STRING_LENGTH];
00771   DWORD dwSize = MAX_STRING_LENGTH;
00772
00773   if (!GetUserName(szUserName, &dwSize))
00774     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00775
00776   return bOk;
00777 }
00778
00779
00780 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00781   Function: InitApplication
00782
00783   Summary:  Initializes the application and registers its main window class.
00784
00785   Args:     HINSTANCE hInstance)
00786               Handle to the first instance of the application.
00787
00788   Modifies: .
00789
00790   Returns:  BOOL.
00791               TRUE if success.
00792               FALSE if fail.
00793 ------------------------------------------------------------------------F-F*/
00794 BOOL InitApplication(
00795        HINSTANCE hInstance)
00796 {
00797   BOOL bOk;
00798   // The window class for all instances of the main frame window.
00799   WNDCLASSEX wcf;
00800
00801   // Assign the appropriate values for this main frame window class.
00802   wcf.cbSize        = sizeof(WNDCLASSEX);
00803   wcf.cbClsExtra    = 0;            // No per-class extra data.
00804   wcf.cbWndExtra    = 0;            // No per-window extra data.
00805   wcf.hInstance     = hInstance;    // Application module instance.
00806   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00807                                     // APPUTIL for all CVirWindows).
00808   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
00809   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00810                                 hInstance,
00811                                 TEXT("AppIcon"));
00812   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00813                                 hInstance,
00814                                 TEXT("AppIcon"),
00815                                 IMAGE_ICON,
00816                                 16, 16,
00817                                 0);
00818   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
00819   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
00820   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
00821   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
00822
00823   // Register the window class and return FALSE if unsuccesful.
00824   bOk = RegisterClassEx(&wcf);
00825
00826   return (bOk);
00827 }
00828
00829
00830 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00831   Function: WinMain
00832
00833   Summary:  The Windows main entry point function for this application.
00834             Initializes the application, the COM Libraries, and starts
00835             the main application message loop.
00836
00837   Args:     HINSTANCE hInstance,
00838               Instance handle; a new one for each invocation of this app.
00839             HINSTANCE hPrevInstance,
00840               Instance handle of the previous instance. NULL in Win32.
00841             LPSTR lpCmdLine,
00842               Windows passes a pointer to the application's
00843               invocation command line.
00844             int nCmdShow)
00845               Bits telling the show state of the application.
00846
00847   Returns:  int
00848               msg.wParam (upon exit of message loop).
00849               FALSE if this instance couldn't initialize and run.
00850 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00851 extern "C" int WINAPI WinMain(
00852                         HINSTANCE hInstance,
00853                         HINSTANCE hPrevInstance,
00854                         LPSTR lpCmdLine,
00855                         int nCmdShow)
00856 {
00857   CMainWindow* pWin = NULL;
00858   int iRun = TRUE;
00859   MSG msg;
00860
00861   // If we were compiled for UNICODE and the platform seems OK with this
00862   // then proceed.  Else we error and exit the app.
00863   if (UnicodeOk())
00864   {
00865     // Call to initialize the COM Library.  Use the SUCCEEDED macro
00866     // to detect success.  If fail then exit app with error message.
00867     // The default apartment model is assumed and used.
00868     if (SUCCEEDED(CoInitialize(NULL)))
00869     {
00870       // If we succeeded in initializing the COM Library we proceed to
00871       // initialize the application.  If we can't init the application
00872       // then we signal shut down with an error message exit.
00873       iRun = InitApplication(hInstance);
00874       if (iRun)
00875       {
00876         // Assume we'll set iRun to TRUE when initialization is done.
00877         iRun = FALSE;
00878
00879         // We are still go for running so we try to create a nifty new
00880         // CMainWindow object for this app instance.
00881         pWin = new CMainWindow;
00882         if (NULL != pWin)
00883         {
00884           // Setup the server control object.
00885           g_pServer = new CServer;
00886           if (NULL != g_pServer)
00887           {
00888             // Assign the server's instance handle.
00889             g_pServer->m_hInstServer = hInstance;
00890
00891             // Check command line for switches to register or unregister
00892             // this server's managed components.   iRun will be set to 2
00893             // to signal an immediate and quiet exit of this application
00894             // if such registration or unregistration is requested.
00895             if (0 == lstrcmpiA(lpCmdLine, "-RegServer")
00896                 || 0 == lstrcmpiA(lpCmdLine, "/RegServer"))
00897             {
00898               if (pWin->RegisterServer())
00899                 iRun = 2;
00900             }
00901             else if (0 == lstrcmpiA(lpCmdLine, "-UnregServer")
00902                      || 0 == lstrcmpiA(lpCmdLine, "/UnregServer"))
00903             {
00904               if (pWin->UnregisterServer())
00905                 iRun = 2;
00906             }
00907
00908             if (FALSE == iRun)
00909             {
00910               // If we did not process a command line switch that
00911               // requires immediate exit, then initialize an instance of
00912               // the new CMainWindow. This entails creating the main window.
00913               if (pWin->InitInstance(hInstance, nCmdShow))
00914               {
00915                 LOGF2("L<%X>: CmdLine Switches= %s",TID,lpCmdLine);
00916                 // Create and register the Class Factories.  But only do so
00917                 // if this application has been launched by COM as indicated
00918                 // by the -Embedding command line switch.
00919                 if (0 == lstrcmpiA(lpCmdLine, "-Embedding")
00920                     || 0 == lstrcmpiA(lpCmdLine, "/Embedding"))
00921                   iRun = g_pServer->OpenFactories();
00922               }
00923             }
00924           }
00925         }
00926       }
00927
00928       switch (iRun)
00929       {
00930         case TRUE:
00931           {
00932             // If we initialized the app instance properly then we are still
00933             // go for running.  We then start up the main message pump for
00934             // the application.  The application will normally live hidden
00935             // as a local server.
00936             while (GetMessage(&msg, NULL, 0, 0))
00937             {
00938               TranslateMessage(&msg);
00939               DispatchMessage(&msg);
00940             }
00941
00942             // We'll pass to the OS the reason why we exited the message
00943             // loop.
00944             iRun = (int) msg.wParam;
00945           }
00946           break;
00947
00948         case FALSE:
00949           // We failed to initialize the application--issue an error
00950           // messagebox.  Can't initialize or can't run stand-alone.
00951           ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
00952
00953           // Delete the CMainWindow object.
00954           DELETE_POINTER(pWin);
00955
00956           // Pass the OS an error code of 1.
00957           iRun = 1;
00958           break;
00959
00960         default:
00961           // Pass the OS an error code of 0.
00962           iRun = 0;
00963           break;
00964       }
00965
00966       // We're exiting this app (either normally or by init failure) so
00967       // shut down the COM Library.
00968       CoUninitialize();
00969     }
00970     else
00971     {
00972       // We failed to Initialize the COM Library. Put up error message box
00973       // saying that COM Library couldn't be initialized.  Parent window
00974       // is desktop (ie, NULL). Exit the failed application (ie, by
00975       // returning FALSE to WinMain).
00976       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
00977     }
00978   }
00979   else
00980   {
00981     // If we were compiled for UNICODE but the platform has problems with
00982     // this then indicate an error and exit the app immediately.
00983     CHAR szMsg[MAX_STRING_LENGTH];
00984
00985     if (LoadStringA(
00986           hInstance,
00987           IDS_NOUNICODE,
00988           szMsg,
00989           MAX_STRING_LENGTH))
00990     {
00991       MessageBoxA(
00992         NULL,
00993         szMsg,
00994         ERROR_TITLE_STR,
00995         MB_OK | MB_ICONEXCLAMATION);
00996     }
00997   }
00998
00999   return iRun;
01000 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/OPBank/bankdlg.h Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • OPBank

bankdlg.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      BankDlg.h
00003   Summary:   Header for bank client
00004   Classes:   CBankDlg
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #ifndef __BANKDLG_H_
00023 #define __BANKDLG_H_
00024
00025 #include "resource.h"       // main symbols
00026 #include "linkable.h"
00027
00028 #define WM_SHOWRESULTS  WM_USER+1 // Devstudio deletes this if I put it in REsOURCE.H
00029 #define WM_SHOWERROR  WM_USER+2 // Devstudio deletes this if I put it in REsOURCE.H
00030
00031 typedef enum
00032 {
00033   CoInitMTA = 0,
00034   CoInitSTA,
00035   CoInitRandom
00036 } EnumCoInit;
00037
00038 // (04.26.00 mdl) Include support for Delphi.
00039 typedef enum
00040 {
00041   VC = 0,
00042   VB,
00043   Java,
00044   Delphi,
00045 } BankLang;
00046
00047 struct THREADDATA
00048 {
00049
00050   int nTestType;
00051   EnumCoInit  eCoInit;
00052   int nIters;
00053   BOOL bRandom;
00054   BOOL bChatty;
00055   int nFrom;
00056   int nTo;
00057   int nTranType;
00058   int nAmount;
00059   int nThreads;
00060   BOOL bCreatePerIteration;
00061   BankLang eLang;
00062
00063 };
00064
00065 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00066 Class: CThreadData
00067 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00068
00069 class CThreadData : public CLinkable
00070 {
00071
00072   THREADDATA m_td;
00073
00074 public:
00075     CThreadData()
00076     {
00077       ZeroMemory(&m_td, sizeof(m_td));
00078     }
00079     CThreadData(THREADDATA * pData)
00080     {
00081       memcpy(&m_td, pData, sizeof(m_td));
00082     }
00083
00084
00085     THREADDATA * GetThreadData(){return &m_td;}
00086
00087 };
00088
00089 struct CREATEDATA
00090 {
00091
00092   int nRows;
00093   HWND hWndResults;
00094   HWND hWndStopButton;
00095   BOOL bStop;
00096   BOOL bDone;
00097   int nTotalRows;
00098   BOOL bChatty;
00099
00100 };
00101
00102
00103
00104 struct RESULTDATA
00105 {
00106   LPOLESTR sString;
00107   DWORD dwThreadId;
00108 };
00109
00110
00111 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00112 Class: CBankDlg
00113 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00114
00115 class CBankDlg :
00116   public CDialogImpl<CBankDlg>
00117 {
00118
00119 private:
00120     CThreadData * m_pCurrentThreadData;
00121     CREATEDATA m_cd;
00122     HANDLE m_hCreateThread;
00123     void ConsumeAllMessages();
00124     void DoWork(CThreadData * pData, int nTestType);
00125     int m_nSuiteIndex;
00126     int m_nTotalTests;
00127     CListHeader m_list;
00128     void UpdateStatus(CThreadData * pData, int nCurItem);
00129     HMENU m_hMenu;
00130     void SetDescription(THREADDATA *pData);
00131     int m_nMaxRowLength;
00132     HANDLE  m_hFile;
00133     int m_nMsgs;
00134
00135
00136 public:
00137
00138   BOOL LoadAll();
00139   BOOL SaveAll();
00140   void SetThreadData(THREADDATA * pTd);
00141   void GetThreadData(THREADDATA * pTd);
00142   CBankDlg();
00143   ~CBankDlg();
00144
00145   enum { IDD = IDD_BANKDLG };
00146
00147 // (04.26.00 mdl) Include support for Delphi.
00148 BEGIN_MSG_MAP(CBankDlg)
00149   MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
00150   MESSAGE_HANDLER(WM_CLOSE, OnClose)
00151   COMMAND_ID_HANDLER(IDOK, OnOK)
00152   COMMAND_ID_HANDLER(IDCANCEL, OnOK)
00153   COMMAND_ID_HANDLER(IDC_SUBMIT, OnGo)
00154   COMMAND_ID_HANDLER(IDC_CREATE_ROWS, OnCreateRows)
00155   COMMAND_ID_HANDLER(IDC_CREATE_TABLES, OnCreateTables)
00156   COMMAND_ID_HANDLER(IDC_VIEW_PREV, OnViewPrev)
00157   COMMAND_ID_HANDLER(IDC_VIEW_NEXT, OnViewNext)
00158   COMMAND_ID_HANDLER(IDC_ADD, OnAdd)
00159   COMMAND_ID_HANDLER(IDC_REMOVE, OnRemove)
00160   COMMAND_ID_HANDLER(IDM_KILL_THREADS, OnKillThreads)
00161
00162   COMMAND_ID_HANDLER(ID_ASSERT_ON_ERRORS, OnAssertOnErrors)
00163   COMMAND_ID_HANDLER(IDM_OPTION_ODBC_STOP, OnStopOnODBCErrors)
00164   COMMAND_ID_HANDLER(IDM_RANDOM, OnRandom)
00165   COMMAND_ID_HANDLER(IDM_OPTION_CREATE_ITERATION, OnSelectCreatePerIteration)
00166   COMMAND_ID_HANDLER(IDM_OPTION_CHATTY, OnSelectChattyDisplay)
00167   COMMAND_RANGE_HANDLER(ID_MM_TRANSFER, ID_MM_CREDIT, OnSelectMoveMoney)
00168   COMMAND_RANGE_HANDLER(ID_AC_DEBIT, ID_AC_CREDIT, OnSelectAccount)
00169   COMMAND_RANGE_HANDLER(ID_LANG_C, ID_LANG_DELPHI, OnSelectLanguage)
00170   COMMAND_RANGE_HANDLER(ID_COINIT_MTA, ID_COINIT_RANDOM, OnSelectCoInit)
00171
00172
00173   COMMAND_ID_HANDLER(IDM_RETRY, OnRetryOnErrors)
00174   COMMAND_ID_HANDLER(IDM_COPY, OnCopy)
00175   COMMAND_ID_HANDLER(IDM_COPYALL, OnCopyAll)
00176   COMMAND_ID_HANDLER(IDM_COPYERRORS, OnCopyErrors)
00177
00178   COMMAND_ID_HANDLER(IDC_STOP, OnStop)
00179   COMMAND_ID_HANDLER(IDC_RUN_SUITE, OnRunSuite)
00180   MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
00181   MESSAGE_HANDLER(WM_SHOWRESULTS, OnShowResults)
00182   MESSAGE_HANDLER(WM_SHOWERROR, OnShowError)
00183   MESSAGE_HANDLER(WM_SIZE, OnSize)
00184   MESSAGE_HANDLER(WM_INITMENU, OnInitMenu)
00185 END_MSG_MAP()
00186
00187   LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00188   LRESULT OnShowResults(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00189   LRESULT OnShowError(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00190
00191   LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00192   LRESULT OnInitMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00193   LRESULT OnViewNext(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00194   LRESULT OnViewPrev(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00195   LRESULT OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00196   LRESULT OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00197   LRESULT OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00198   LRESULT OnKillThreads(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00199   LRESULT OnAssertOnErrors(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00200   LRESULT OnStopOnODBCErrors(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00201   LRESULT OnSelectCreatePerIteration(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00202   LRESULT OnSelectChattyDisplay(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00203   LRESULT OnSelectMoveMoney(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00204   LRESULT OnSelectAccount(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00205   LRESULT OnSelectLanguage(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00206   LRESULT OnSelectCoInit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00207   LRESULT OnRetryOnErrors(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00208
00209   LRESULT OnRandom(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00210   LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00211   LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00212   LRESULT OnGo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00213   LRESULT OnStop(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00214
00215   LRESULT OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00216   LRESULT OnCopyAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00217   LRESULT OnCopyErrors(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00218   LRESULT OnCreateRows(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00219   LRESULT OnCreateTables(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00220   LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00221   LRESULT OnRunSuite(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00222
00223
00224 };
00225
00226 #endif //__BANKDLG_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/CmdLineConsumer/CmdLineConsumerDlg.h Source File

  • SysMgmt
  • WMI
  • VC
  • CmdLineConsumer

CmdLineConsumerDlg.h

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  CmdLineConsumerDlg.h
00006 //
00007 // Description:
00008 //      Defines the class for the consumer's dialog
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #if !defined(AFX_CMDLINECONSUMERDLG_H__EF85AEB9_6B6C_11D1_ADAD_00AA00B8E05A__INCLUDED_)
00015 #define AFX_CMDLINECONSUMERDLG_H__EF85AEB9_6B6C_11D1_ADAD_00AA00B8E05A__INCLUDED_
00016
00017 #if _MSC_VER >= 1000
00018 #pragma once
00019 #endif // _MSC_VER >= 1000
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // CCmdLineConsumerDlg dialog
00023
00024 class CCmdLineConsumerDlg : public CDialog
00025 {
00026 // Construction
00027 public:
00028   CCmdLineConsumerDlg(CWnd* pParent = NULL);  // standard constructor
00029
00030 // Dialog Data
00031   //{{AFX_DATA(CCmdLineConsumerDlg)
00032   enum { IDD = IDD_CMDLINECONSUMER_DIALOG };
00033   CListBox  m_output;
00034   //}}AFX_DATA
00035
00036   // ClassWizard generated virtual function overrides
00037   //{{AFX_VIRTUAL(CCmdLineConsumerDlg)
00038   protected:
00039   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00040   //}}AFX_VIRTUAL
00041
00042 // Implementation
00043 protected:
00044   HICON m_hIcon;
00045
00046   // Generated message map functions
00047   //{{AFX_MSG(CCmdLineConsumerDlg)
00048   virtual BOOL OnInitDialog();
00049   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00050   afx_msg void OnPaint();
00051   afx_msg HCURSOR OnQueryDragIcon();
00052   //}}AFX_MSG
00053   DECLARE_MESSAGE_MAP()
00054 };
00055
00056 //{{AFX_INSERT_LOCATION}}
00057 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00058
00059 #endif // !defined(AFX_CMDLINECONSUMERDLG_H__EF85AEB9_6B6C_11D1_ADAD_00AA00B8E05A__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/RegAcc32.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

RegAcc32.Cxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright (C) Microsoft Corporation, 1992 - 1996
00005 //
00006 //  File:       RegAcc.hxx
00007 //
00008 //  Contents:   'Simple' registry access
00009 //
00010 //
00011 //--------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <osv.hxx>
00017 #include <regacc32.hxx>
00018
00019 //+-------------------------------------------------------------------------
00020 //
00021 //  Member:     CRegAccess::CRegAccess, public
00022 //
00023 //  Synopsis:   Initialize registry access object
00024 //
00025 //  Arguments:  [ulRelative] -- Position in registry from which [pwcsRegPath]
00026 //                              begins.
00027 //              [pwcsRegPath] -- Path to node.
00028 //
00029 //--------------------------------------------------------------------------
00030
00031 CRegAccess::CRegAccess( HKEY keyRelative, WCHAR const * pwcsRegPath )
00032         : _hKey( (HKEY) (SIZE_T) -1 ),
00033           _wcsPath( 0 )
00034 {
00035     if ( GetOSVersion() == VER_PLATFORM_WIN32_NT )
00036     {
00037         RegOpenKeyW( keyRelative, pwcsRegPath, &_hKey );
00038     }
00039     else // win95
00040     {
00041         int nPathLen = (int) ( wcslen( pwcsRegPath ) * 2 );  // some multibyte chars are 2 bytes long
00042
00043         char * pszPath = new char [nPathLen];
00044
00045         if ( NULL != pszPath )
00046         {
00047             wcstombs( pszPath, pwcsRegPath, nPathLen );
00048
00049             RegOpenKeyA( keyRelative, pszPath, &_hKey );
00050         }
00051
00052         delete [] pszPath;
00053     }
00054 }
00055
00056 //+-------------------------------------------------------------------------
00057 //
00058 //  Member:     CRegAccess::~CRegAccess, public
00059 //
00060 //  Synopsis:   Destructor
00061 //
00062 //--------------------------------------------------------------------------
00063
00064 CRegAccess::~CRegAccess()
00065 {
00066     RegCloseKey( _hKey );
00067     delete [] _wcsPath;
00068 }
00069
00070 //+-------------------------------------------------------------------------
00071 //
00072 //  Member:     CRegAccess::Get, public
00073 //
00074 //  Synopsis:   Retrive value of specified key from registry.
00075 //
00076 //  Arguments:  [pwcsKey] -- Key to retrieve value of.
00077 //              [wcsVal]  -- String stored here.
00078 //              [cc]      -- Size (in characters) of [wcsVal]
00079 //
00080 //  Notes:      Key must be string for successful retrieval.
00081 //
00082 //--------------------------------------------------------------------------
00083
00084 BOOL CRegAccess::Get( WCHAR const * pwcsKey, WCHAR * wcsVal, unsigned cc )
00085 {
00086     if ( _hKey == (HKEY) (SIZE_T) -1 )
00087         return FALSE;
00088
00089     DWORD dwType;
00090     DWORD cb = cc * sizeof(WCHAR);
00091     wcsVal[0] = 0;
00092
00093     BOOL fOk;
00094
00095     if ( GetOSVersion() == VER_PLATFORM_WIN32_NT )
00096     {
00097         fOk = ( ERROR_SUCCESS == RegQueryValueExW( _hKey,
00098                                                   pwcsKey,
00099                                                   0,
00100                                                   &dwType,
00101                                                   (BYTE *)wcsVal,
00102                                                   &cb ) ) &&
00103               ( wcsVal[0] != 0 );
00104     }
00105     else // win95
00106     {
00107         // Worst case - size of multibyte == size of Unicode
00108         int nKeyLen = (int) ( wcslen( pwcsKey ) * 2 );
00109
00110         char * pszKey = new char [nKeyLen];
00111
00112         if ( NULL != pszKey )
00113         {
00114             char * pszVal = new char [cc*2];
00115
00116             if ( NULL != pszVal )
00117             {
00118                 wcstombs( pszKey, pwcsKey, nKeyLen );
00119
00120                 fOk = (ERROR_SUCCESS == RegQueryValueExA( _hKey,
00121                                                           pszKey,
00122                                                           0,
00123                                                           &dwType,
00124                                                          (BYTE *)pszVal,
00125                                                          &cb ) );
00126
00127                 mbstowcs( wcsVal, pszVal, cb );     // cb since it will convert fewer when it hits terminator
00128
00129                 delete [] pszVal;
00130             }
00131             else
00132             {
00133                 fOk = FALSE;
00134             }
00135
00136             delete [] pszKey;
00137         }
00138         else
00139         {
00140             fOk = FALSE;
00141         }
00142     }
00143
00144     return fOk;
00145 }
00146
00147
00148
00149 //+-------------------------------------------------------------------------
00150 //
00151 //  Method:     StringToClsid
00152 //
00153 //  Synopsis:   Convert string containing CLSID to CLSID
00154 //
00155 //  Arguments:  [wszClass] -- string containg CLSID
00156 //              [guidClass] -- output guid
00157 //
00158 //--------------------------------------------------------------------------
00159
00160 void StringToClsid( WCHAR *wszClass, GUID& guidClass )
00161 {
00162     wszClass[9] = 0;
00163     guidClass.Data1 = wcstoul( &wszClass[1], 0, 16 );
00164     wszClass[14] = 0;
00165     guidClass.Data2 = (USHORT)wcstoul( &wszClass[10], 0, 16 );
00166     wszClass[19] = 0;
00167     guidClass.Data3 = (USHORT)wcstoul( &wszClass[15], 0, 16 );
00168
00169     WCHAR wc = wszClass[22];
00170     wszClass[22] = 0;
00171     guidClass.Data4[0] = (unsigned char)wcstoul( &wszClass[20], 0, 16 );
00172     wszClass[22] = wc;
00173     wszClass[24] = 0;
00174     guidClass.Data4[1] = (unsigned char)wcstoul( &wszClass[22], 0, 16 );
00175
00176     for ( int i = 0; i < 6; i++ )
00177     {
00178        wc = wszClass[27+i*2];
00179        wszClass[27+i*2] = 0;
00180        guidClass.Data4[2+i] = (unsigned char)wcstoul( &wszClass[25+i*2], 0, 16 );
00181        wszClass[27+i*2] = wc;
00182     }
00183 }
00184
00185
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ip_hdr Member List

This is the complete list of members for ip_hdr, including all inherited members.
ip_checksum | ip_hdr
ip_destaddr | ip_hdr
ip_id | ip_hdr
ip_offset | ip_hdr
ip_protocol | ip_hdr
ip_srcaddr | ip_hdr
ip_tos | ip_hdr
ip_totallength | ip_hdr
ip_ttl | ip_hdr
ip_verlen | ip_hdr
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/io/SyncWrite/fwrite.c Source File

  • Web
  • iis
  • extensions
  • io
  • SyncWrite

fwrite.c

Go to the documentation of this file.
00001 /* Copyright (c) 1995-2002 Microsoft Corporation
00002
00003   Module Name:
00004
00005     fwrite.c
00006
00007   Abstract:
00008
00009     This module demonstrates a simple file transfer using ISAPI application
00010     using the WriteClient() callback.
00011 */
00012
00013 #define WIN32_LEAN_AND_MEAN
00014 #include <windows.h>
00015 #include <stdio.h>
00016 #include "httpext.h"
00017 #include "openf.h"
00018
00019 #define MAX_BUFFER_SIZE 4096
00020
00021 DWORD SendHeaderToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszErrorMsg);
00022 DWORD SendFileToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile);
00023 DWORD SendFileOver(IN EXTENSION_CONTROL_BLOCK *pecb, IN HANDLE hFile);
00024
00025 /*
00026   Description:
00027
00028     This function DllLibMain() is the main initialization function for
00029     this DLL. It initializes local variables and prepares it to be invoked
00030     subsequently.
00031
00032   Arguments:
00033
00034     hinstDll          Instance Handle of the DLL
00035     fdwReason         Reason why NT called this DLL
00036     lpvReserved       Reserved parameter for future use.
00037
00038   Returns:
00039
00040     Returns TRUE is successful; otherwise FALSE is returned.
00041 */
00042
00043 BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD fdwReason, IN LPVOID lpvContext OPTIONAL)
00044 {
00045   BOOL fReturn = TRUE;
00046
00047   switch (fdwReason) {
00048
00049     case DLL_PROCESS_ATTACH :
00050
00051       OutputDebugString("Initializing the global data in fwrite.dll\n");
00052
00053       /* Initialize various data and modules. */
00054
00055       fReturn = (InitFileHandleCache() == NO_ERROR);
00056
00057       break;
00058
00059     case DLL_PROCESS_DETACH :
00060
00061       /*
00062         Only cleanup when we are called because of a FreeLibrary() (i.e., when lpvContext == NULL)
00063         If we are called because of a process termination, dont free anything. System will free resources and memory for us.
00064       */
00065
00066       CleanupFileHandleCache();
00067
00068       break;
00069
00070     default :
00071
00072       break;
00073   }
00074
00075   return fReturn;
00076 }
00077
00078 DWORD WINAPI HttpExtensionProc(IN EXTENSION_CONTROL_BLOCK *pecb)
00079 {
00080   DWORD hseStatus;
00081
00082   if (pecb->lpszQueryString == NULL)
00083     hseStatus = SendHeaderToClient(pecb, "File Not Found");
00084   else
00085     hseStatus = SendFileToClient(pecb, pecb->lpszQueryString);
00086
00087   return hseStatus;
00088 }
00089
00090 /*
00091   Description:
00092
00093     Sets the ISAPI extension version information.
00094
00095   Arguments:
00096
00097     Version     pointer to HSE_VERSION_INFO structure
00098
00099   Return Value:
00100
00101     TRUE
00102 */
00103
00104 BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
00105 {
00106   pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
00107
00108   lstrcpyn((LPSTR) pVer->lpszExtensionDesc, "File Transfer Using WriteClient", HSE_MAX_EXT_DLL_NAME_LEN);
00109
00110   return TRUE;
00111 }
00112
00113 BOOL WINAPI TerminateExtension(DWORD dwFlags)
00114 {
00115   /* Nothing specific do here for cleanup. Cleanup is done in the dll process detach in DllLibMain() */
00116
00117   return TRUE;
00118 }
00119
00120 DWORD SendHeaderToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszErrorMsg)
00121 {
00122   HSE_SEND_HEADER_EX_INFO SendHeaderExInfo;
00123   char szStatus[] = "200 OK";
00124   char szHeader[1024];
00125
00126   /* Note the HTTP header block is terminated by a blank '\r\n' pair, followed by the document body */
00127
00128   wsprintf(szHeader, "Content-Type: text/html\r\n\r\n<head><title>Simple File Transfer (Synchronous Write)</title></head>\n<body><h1>%s</h1>\n", pszErrorMsg);
00129
00130   /*  Populate SendHeaderExInfo struct */
00131
00132   SendHeaderExInfo.pszStatus = szStatus;
00133   SendHeaderExInfo.pszHeader = szHeader;
00134   SendHeaderExInfo.cchStatus = lstrlen(szStatus);
00135   SendHeaderExInfo.cchHeader = lstrlen(szHeader);
00136   SendHeaderExInfo.fKeepConn = FALSE;
00137
00138   /* Send header - use the EX Version to send the header blob */
00139
00140   if (!pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &SendHeaderExInfo, NULL, NULL))
00141     return HSE_STATUS_ERROR;
00142
00143   return HSE_STATUS_SUCCESS;
00144 }
00145
00146 DWORD SendFileToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile)
00147 {
00148   CHAR    pchBuffer[1024];
00149   HANDLE  hFile;
00150   DWORD   hseStatus = HSE_STATUS_SUCCESS;
00151
00152   hFile = FcOpenFile(pecb, pszFile);
00153
00154   if (hFile == INVALID_HANDLE_VALUE) {
00155
00156     wsprintfA(pchBuffer, "OpenFailed: Error (%d) while opening the file %s.\n", GetLastError(), pszFile);
00157
00158     hseStatus = SendHeaderToClient(pecb, pchBuffer);
00159
00160   } else {
00161
00162     wsprintfA(pchBuffer, "Transferred file contains...");
00163
00164     hseStatus = SendHeaderToClient(pecb, pchBuffer);
00165
00166     if (hseStatus == HSE_STATUS_SUCCESS) {
00167
00168       hseStatus = SendFileOver(pecb, hFile);
00169
00170       if (hseStatus != HSE_STATUS_PENDING) {
00171
00172         if (hseStatus != HSE_STATUS_SUCCESS) {
00173
00174           /* Error in transmitting the file. Send error message. */
00175
00176           wsprintfA(pchBuffer, "Send Failed: Error (%d) for file %s.\n", GetLastError(), pszFile);
00177
00178           SendHeaderToClient(pecb, pchBuffer);
00179         }
00180       }
00181
00182       if (hseStatus != HSE_STATUS_PENDING) {
00183
00184         /* Assume that the data is transmitted and close the file handle */
00185
00186         FcCloseFile(hFile);
00187       }
00188     }
00189   }
00190
00191   return hseStatus;
00192 }
00193
00194 DWORD SendFileOver(IN EXTENSION_CONTROL_BLOCK *pecb, IN HANDLE hFile)
00195 {
00196   CHAR pchBuffer[MAX_BUFFER_SIZE];
00197   DWORD dwBytesInFile = GetFileSize(hFile, NULL);
00198   DWORD nRead = 0;
00199   DWORD hseStatus = HSE_STATUS_SUCCESS;
00200   OVERLAPPED  ov;
00201   DWORD err;
00202
00203   /* Send the whole file. Loop thru reading the file and transmitting it to client */
00204
00205   memset(&ov, 0, sizeof(OVERLAPPED));
00206
00207   ov.OffsetHigh = 0;
00208   ov.Offset = 0;
00209   ov.hEvent = CreateEvent(NULL, TRUE, FALSE, "OVERLAPPED::hEvent");
00210
00211   if (NULL == ov.hEvent)
00212     return HSE_STATUS_ERROR;
00213
00214   for (;;) {
00215
00216     nRead = 0;
00217
00218     /* read data from the file */
00219
00220     if (!FcReadFromFile(hFile, pchBuffer, MAX_BUFFER_SIZE, &nRead, &ov)) {
00221
00222       hseStatus = HSE_STATUS_ERROR;
00223
00224       break;
00225     }
00226
00227     /* write data to client */
00228
00229     if (!pecb->WriteClient(pecb->ConnID, pchBuffer, &nRead, 0)) {
00230
00231       hseStatus = HSE_STATUS_ERROR;
00232
00233       break;
00234     }
00235   }
00236
00237   if (NULL != ov.hEvent) {
00238
00239     err = GetLastError();
00240
00241     CloseHandle(ov.hEvent);
00242
00243     ov.hEvent = NULL;
00244
00245     SetLastError(err);
00246   }
00247
00248   return hseStatus;
00249 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/TextWnd.Cpp Source File

  • WinUI
  • GlobalDev
  • CSSamp

TextWnd.Cpp

Go to the documentation of this file.
00001 ////    TEXTWND.CPP
00002 //
00003 //              Maintains the text display panel
00004 #include "precomp.hxx"
00005 #include "global.h"
00006
00007 ////    InvalidateText - Force redisplay
00008 //
00009 //
00010 void InvalidateText()
00011 {
00012     RECT rc = {0};
00013
00014     rc.left   = g_fPresentation ? 0 : g_iSettingsWidth;
00015     rc.top    = 0;
00016     rc.right  = 10000;
00017     rc.bottom = 10000;
00018     InvalidateRect(g_hTextWnd, &rc, TRUE);
00019 }
00020
00021 ////    Header - Draw a simple header for each text section
00022 //
00023 //      Used to distinguish logical, plaintext and formatted text sections of
00024 //      text window.
00025 //
00026 //      Advances SEPARATORHEIGHT drawing a horizontal line 2/5ths of the way
00027 //      down, and displays a title below the line.
00028 //
00029 //      At the top of the page displays only the title.
00030 const int SEPARATORHEIGHT = 35;
00031
00032 void Header(HDC hdc, char* str, RECT *prc, int *piY) {
00033
00034     HFONT hf      = NULL;
00035     HFONT hfold   = NULL;
00036     RECT  rcClear = {0};
00037
00038     int iLinePos      = 0;
00039     int iTextPos      = 0;
00040     int iFontEmHeight = 0;
00041     int iHeight       = 0;
00042
00043     iFontEmHeight = SEPARATORHEIGHT*40/100;
00044     if (*piY <= prc->top)
00045     {
00046         // Prepare settings for title only, at top of window
00047         iLinePos = -1;
00048         iTextPos = 0;
00049         iHeight  = SEPARATORHEIGHT*60/100;
00050     }
00051     else
00052     {
00053         // Prepare settings for 40% white space, a line, 10% whitespace, text and 3% whitespace
00054         iLinePos = SEPARATORHEIGHT*30/100;
00055         iTextPos = SEPARATORHEIGHT*40/100;
00056         iHeight  = SEPARATORHEIGHT;
00057     }
00058
00059     rcClear = *prc;
00060     rcClear.top = *piY;
00061     rcClear.bottom = *piY + iHeight;
00062     FillRect(hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00063
00064     if (*piY > prc->top)
00065     {
00066         // Separate from previous output with double pixel line
00067         MoveToEx(hdc, prc->left,  *piY+iLinePos, NULL);
00068         LineTo  (hdc, prc->right, *piY+iLinePos);
00069         MoveToEx(hdc, prc->left,  *piY+iLinePos+1, NULL);
00070         LineTo  (hdc, prc->right, *piY+iLinePos+1);
00071     }
00072
00073     hf = CreateFont(-iFontEmHeight, 0, 0, 0, 0, 0, 0, 0, 1, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE|DEFAULT_PITCH,TEXT("Arial"));
00074     hfold = (HFONT) SelectObject(hdc, hf);
00075     __try
00076     {
00077          // If str is not null terminated, this call can cause access violation.
00078         ExtTextOutA(hdc, prc->left, *piY + iTextPos, 0, prc, str, (int)strlen(str), NULL);
00079     }
00080     __except(EXCEPTION_EXECUTE_HANDLER)
00081     {
00082         DeleteObject(hf);
00083         return;
00084      }
00085
00086     *piY += iHeight;
00087
00088     SelectObject(hdc, hfold);
00089     DeleteObject(hf);
00090 }
00091
00092 ////    ResetCaret - Used during paint by each DSP*.CPP
00093 //
00094 //
00095 void ResetCaret(int iX, int iY, int iHeight)
00096 {
00097     g_iCaretX = iX;
00098     g_iCaretY = iY;
00099
00100     if (g_iCaretHeight != iHeight)
00101     {
00102         g_iCaretHeight = iHeight;
00103         HideCaret(g_hTextWnd);
00104         DestroyCaret();
00105         CreateCaret(g_hTextWnd, NULL, 0, g_iCaretHeight);
00106         SetCaretPos(g_iCaretX, g_iCaretY);
00107         ShowCaret(g_hTextWnd);
00108     }
00109     else
00110     {
00111         SetCaretPos(g_iCaretX, g_iCaretY);
00112     }
00113 }
00114
00115 ////    Paint - Redraw part or all of client area
00116 //
00117 //
00118 void Paint(
00119     HWND         hWnd)
00120 {
00121
00122     PAINTSTRUCT  ps          = {0};
00123     HDC          hdc         = NULL;
00124     int          iPos        = 0;
00125     int          iY          = 0;
00126     int          iLineHeight = 0;
00127     RECT         rcText      = {0};
00128     RECT         rcClear     = {0};
00129
00130     hdc = BeginPaint(hWnd, &ps);
00131
00132     // Remove the settings dialog from the repaint rectangle
00133     if (ps.fErase)
00134     {
00135         // Clear below the settings dialog
00136         if (!g_fPresentation)
00137         {
00138             rcClear = ps.rcPaint;
00139             if (rcClear.right > g_iSettingsWidth)
00140             {
00141                 rcClear.right = g_iSettingsWidth;
00142             }
00143             if (rcClear.top < g_iSettingsHeight)
00144             {
00145                 rcClear.top = g_iSettingsHeight;
00146             }
00147
00148             FillRect(ps.hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00149         }
00150     }
00151
00152     // Clear top and left margin
00153     GetClientRect(hWnd, &rcText);
00154
00155     // Left margin
00156     rcClear = rcText;
00157     rcClear.left  = g_fPresentation ? 0 : g_iSettingsWidth;
00158     rcClear.right = rcClear.left + 10;
00159     FillRect(ps.hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00160
00161     // Top margin
00162     rcClear = rcText;
00163     rcClear.left  = g_fPresentation ? 0 : g_iSettingsWidth;
00164     rcClear.top = 0;
00165     rcClear.bottom = 8;
00166     FillRect(ps.hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00167
00168     rcText.left = g_fPresentation ? 10 : g_iSettingsWidth + 10;
00169     rcText.top  = 8;
00170
00171     iPos = 0;
00172     iY = rcText.top;
00173
00174     if (g_fPresentation)
00175     {
00176         iLineHeight = rcText.bottom*9/20;
00177     }
00178     else
00179     {
00180         iLineHeight = 40;
00181     }
00182
00183     if (g_fShowLogical)
00184     {
00185         if (!g_fPresentation)
00186         {
00187             Header(hdc, "Logical characters (ScriptGetCmap, ExtTextOut(ETO_GLYPHINDEX))", &rcText, &iY);
00188         }
00189         PaintLogical(hdc, &iY, &rcText, iLineHeight);
00190     }
00191
00192     if (g_fShowPlainText)
00193     {
00194         if (!g_fPresentation)
00195         {
00196             Header(hdc, "Plain text (ScriptStringAnalyse, ScriptStringOut, ScriptStringFree)", &rcText, &iY);
00197         }
00198         PaintPlainText(hdc, &iY, &rcText, iLineHeight);
00199     }
00200
00201     if (g_fShowFancyText  &&  !g_fPresentation)
00202     {
00203         Header(hdc, "Formatted text (ScriptItemize, ScriptLayout, ScriptShape, ScriptPlace, ScriptTextOut)", &rcText, &iY);
00204         PaintFormattedText(hdc, &iY, &rcText, iLineHeight);
00205     }
00206
00207     // Clear any remaining space below the text
00208     if (    ps.fErase
00209         &&  iY < rcText.bottom)
00210     {
00211         rcClear = rcText;
00212         rcClear.top = iY;
00213         FillRect(ps.hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00214     }
00215
00216     EndPaint(hWnd, &ps);
00217 }
00218
00219 ////    TextWndProc - Main window message handler and dispatcher
00220 //
00221 //
00222 LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00223 {
00224     HDC hdc = NULL;
00225     LRESULT lProcessed = 0;
00226     switch (message)
00227     {
00228         case WM_CREATE:
00229             hdc = GetDC(hWnd);
00230             g_iLogPixelsY = GetDeviceCaps(hdc, LOGPIXELSY);
00231             ReleaseDC(hWnd, hdc);
00232             break;
00233
00234         case WM_ERASEBKGND:
00235             lProcessed = 0;       // Leave Paint to erase the background
00236             break;
00237
00238         case WM_CHAR:
00239
00240             if (!g_bUnicodeWnd)
00241             {
00242                 // Convert ANSI keyboard data to Unicode
00243                 int   iCP = 0;
00244                 switch (PRIMARYLANGID(LOWORD(GetKeyboardLayout(NULL))))
00245                 {
00246                     case LANG_ARABIC:   iCP = 1256;   break;
00247                     case LANG_HEBREW:   iCP = 1255;   break;
00248                     case LANG_THAI:     iCP =  874;   break;
00249                     default:            iCP = 1252;   break;
00250                 }
00251                 DWORD tmpChr = wParam;
00252
00253                 MultiByteToWideChar(iCP, 0, (char*)&tmpChr, 1, (WCHAR*)&wParam, 1);
00254             }
00255
00256             if (LOWORD(wParam) == 0x1B)
00257             {
00258                 // Exit presentation mode
00259                 g_fPresentation = FALSE;
00260                 ShowWindow(g_hSettingsDlg, SW_SHOW);
00261                 UpdateWindow(g_hSettingsDlg);
00262                 InvalidateText();
00263
00264             }
00265             else
00266             {
00267                 EditChar(LOWORD(wParam));
00268             }
00269             break;
00270
00271         case WM_KEYDOWN:
00272             EditKeyDown(LOWORD(wParam));
00273             break;
00274
00275         case WM_KEYUP:
00276
00277             if (wParam != VK_ESCAPE)
00278             {
00279                 goto DefaultWindowProcedure;
00280             }
00281             // Eat all escape key processing
00282             break;
00283
00284         case WM_LBUTTONDOWN:
00285             g_iMouseDownX = LOWORD(lParam);  // horizontal position of cursor
00286             g_iMouseDownY = HIWORD(lParam);  // vertical position of cursor
00287             g_fMouseDown  = TRUE;
00288             SetFocus(hWnd);
00289             break;
00290
00291         case WM_MOUSEMOVE:
00292             // Treat movement like lbuttonup while lbutton is down,
00293             // so the selection tracks the cursor movement.
00294             if (wParam & MK_LBUTTON)
00295             {
00296                 g_iMouseUpX = LOWORD(lParam);  // horizontal position of cursor
00297                 g_iMouseUpY = HIWORD(lParam);  // vertical position of cursor
00298                 g_fMouseUp = TRUE;
00299                 InvalidateText();
00300                 SetActiveWindow(hWnd);
00301             }
00302             break;
00303
00304         case WM_LBUTTONUP:
00305             g_iMouseUpX = LOWORD(lParam);  // horizontal position of cursor
00306             g_iMouseUpY = HIWORD(lParam);  // vertical position of cursor
00307             g_fMouseUp = TRUE;
00308             InvalidateText();
00309             SetActiveWindow(hWnd);
00310             break;
00311
00312         case WM_SETFOCUS:
00313             CreateCaret(hWnd, NULL, 0, g_iCaretHeight);
00314             SetCaretPos(g_iCaretX, g_iCaretY);
00315             ShowCaret(hWnd);
00316             break;
00317
00318         case WM_KILLFOCUS:
00319             DestroyCaret();
00320             break;
00321
00322         case WM_GETMINMAXINFO:
00323
00324             // Don't let text window size drop too low
00325
00326             ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = g_fPresentation ? 10 : g_iMinWidth;
00327             ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = g_fPresentation ? 10 : g_iMinHeight;
00328             lProcessed = 0;
00329             break;
00330
00331         case WM_PAINT:
00332             Paint(hWnd);
00333             break;
00334
00335         case WM_DESTROY:
00336             DestroyWindow(g_hSettingsDlg);
00337             PostQuitMessage(0);
00338             lProcessed = 0;
00339             break;
00340
00341         default:
00342         DefaultWindowProcedure:
00343             if (g_bUnicodeWnd)
00344             {
00345                 lProcessed = DefWindowProcW(hWnd, message, wParam, lParam);
00346             }
00347             else
00348             {
00349                 lProcessed = DefWindowProcA(hWnd, message, wParam, lParam);
00350             }
00351     }
00352
00353     return lProcessed;
00354 }
00355
00356 ////    CreateTextWindow - create window class and window
00357 //
00358 //      Attempts to use a Unicode window, if this fails uses an ANSI
00359 //      window.
00360 //
00361 //      For example the Unicode window will succeed on Windows NT and
00362 //      Windows CE, but fail on Windows 9x.
00363 HWND CreateTextWindow()
00364 {
00365     WNDCLASSA  wcA  = {0};
00366     WNDCLASSW  wcW  = {0};
00367     HWND       hWnd = NULL;
00368
00369     // Try registering as a Unicode window
00370     wcW.style         = CS_HREDRAW | CS_VREDRAW;
00371     wcW.lpfnWndProc   = TextWndProc;
00372     wcW.cbClsExtra    = 0;
00373     wcW.cbWndExtra    = 0;
00374     wcW.hInstance     = g_hInstance;
00375     wcW.hIcon         = LoadIconW(g_hInstance, APPNAMEW);
00376     wcW.hCursor       = LoadCursorW(NULL, (WCHAR*)IDC_ARROW);
00377     wcW.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00378     wcW.lpszMenuName  = APPNAMEW;
00379     wcW.lpszClassName = APPNAMEW;
00380
00381     if (RegisterClassW(&wcW))
00382     {
00383         // Use a Unicode window
00384         g_bUnicodeWnd = TRUE;
00385         hWnd  = CreateWindowW(
00386             APPNAMEW, APPTITLEW,
00387             WS_OVERLAPPEDWINDOW,
00388             CW_USEDEFAULT, 0,
00389             CW_USEDEFAULT, 0,
00390             NULL, NULL,
00391             g_hInstance,
00392             NULL);
00393
00394     }
00395     else
00396     {
00397         // Must use an ANSI window.
00398         wcA.style         = CS_HREDRAW | CS_VREDRAW;
00399         wcA.lpfnWndProc   = TextWndProc;
00400         wcA.cbClsExtra    = 0;
00401         wcA.cbWndExtra    = 0;
00402         wcA.hInstance     = g_hInstance;
00403         wcA.hIcon         = LoadIconA(g_hInstance, APPNAMEA);
00404         wcA.hCursor       = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
00405         wcA.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00406         wcA.lpszMenuName  = APPNAMEA;
00407         wcA.lpszClassName = APPNAMEA;
00408
00409         if (!RegisterClassA(&wcA))
00410         {
00411             hWnd = NULL;
00412         }
00413         else
00414         {
00415             g_bUnicodeWnd = FALSE;
00416
00417             hWnd  = CreateWindowA(
00418                 APPNAMEA, APPTITLEA,
00419                 WS_OVERLAPPEDWINDOW,
00420                 CW_USEDEFAULT, 0,
00421                 CW_USEDEFAULT, 0,
00422                 NULL, NULL,
00423                 g_hInstance,
00424                 NULL);
00425         }
00426     }
00427
00428     return hWnd;
00429 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CClusterUtils Member List

This is the complete list of members for CClusterUtils, including all inherited members.
CClusterUtils(const CClusterUtils &nodeSrc) | CClusterUtils | [private]
CClusterUtils(void) | CClusterUtils | [inline, protected]
HrEnumNodeResources(BSTR bstrNodeNameIn) | CClusterUtils |
HrGetQuorumResourceName(BSTR *pbstrQuorumResourceNameOut) | CClusterUtils |
HrIsClusterServiceRunning(void) | CClusterUtils |
HrIsCoreResource(HRESOURCE hResourceIn) | CClusterUtils |
HrIsGroupOwnedByThisNode(HGROUP hGroupIn, BSTR bstrNodeNameIn) | CClusterUtils |
HrIsNodeClustered(void) | CClusterUtils |
HrLoadGroupResources(HCLUSTER hClusterIn, HGROUP hGroupIn) | CClusterUtils |
HrNodeResourceCallback(HRESOURCE hResourceIn)=0 | CClusterUtils | [pure virtual]
operator=(const CClusterUtils &nodeSrc) | CClusterUtils | [private]
~CClusterUtils(void) | CClusterUtils | [inline, protected, virtual]
Generated on Wed Nov 13 2024 16:55:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEnumFormatEtc Member List

This is the complete list of members for CEnumFormatEtc, including all inherited members.
CEnumFormatEtc(void) | CEnumFormatEtc |
CEnumFormatEtc(ULONG, LPFORMATETC) | CEnumFormatEtc |
CEnumFormatEtc(LPFORMATETC pFE, int numberItems) | CEnumFormatEtc |
Clone(LPENUMFORMATETC *) | CEnumFormatEtc |
Clone(IEnumFORMATETC **) | CEnumFormatEtc |
Clone(IEnumFORMATETC **) | CEnumFormatEtc |
m_cfe | CEnumFormatEtc | [private]
m_cfEmbedSource | CEnumFormatEtc | [private]
m_cItems | CEnumFormatEtc | [private]
m_cRef | CEnumFormatEtc | [private]
m_cRefCount | CEnumFormatEtc | [private]
m_iCur | CEnumFormatEtc | [private]
m_ObjRefCount | CEnumFormatEtc | [private]
m_prgfe | CEnumFormatEtc | [private]
m_pStrFE | CEnumFormatEtc | [private]
Next(ULONG, LPFORMATETC, ULONG *) | CEnumFormatEtc |
Next(ULONG, LPFORMATETC, ULONG *) | CEnumFormatEtc |
Next(ULONG, LPFORMATETC, ULONG *) | CEnumFormatEtc |
QueryInterface(REFIID, LPVOID *) | CEnumFormatEtc |
QueryInterface(REFIID, VOID **) | CEnumFormatEtc |
QueryInterface(REFIID, LPVOID *) | CEnumFormatEtc |
Reset(void) | CEnumFormatEtc |
Reset(void) | CEnumFormatEtc |
Reset(void) | CEnumFormatEtc |
Skip(ULONG) | CEnumFormatEtc |
Skip(ULONG) | CEnumFormatEtc |
Skip(ULONG) | CEnumFormatEtc |
STDMETHOD_(ULONG, AddRef)(void) | CEnumFormatEtc |
STDMETHOD_(ULONG, Release)(void) | CEnumFormatEtc |
STDMETHODIMP_(ULONG) AddRef(void) | CEnumFormatEtc |
STDMETHODIMP_(ULONG) Release(void) | CEnumFormatEtc |
STDMETHODIMP_(ULONG) AddRef(void) | CEnumFormatEtc |
STDMETHODIMP_(ULONG) Release(void) | CEnumFormatEtc |
~CEnumFormatEtc(void) | CEnumFormatEtc |
~CEnumFormatEtc(void) | CEnumFormatEtc |
~CEnumFormatEtc(void) | CEnumFormatEtc |
Generated on Wed Nov 13 2024 16:56:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProvider_IWbemUnboundObjectSink Member List

This is the complete list of members for CProvider_IWbemUnboundObjectSink, including all inherited members.
CProvider_IWbemUnboundObjectSink() | CProvider_IWbemUnboundObjectSink |
IndicateToConsumer(IWbemClassObject *a_LogicalConsumer, long a_ObjectCount, IWbemClassObject **a_Objects) | CProvider_IWbemUnboundObjectSink |
m_ReferenceCount | CProvider_IWbemUnboundObjectSink | [private]
QueryInterface(REFIID, LPVOID FAR *) | CProvider_IWbemUnboundObjectSink |
STDMETHODIMP_(ULONG) AddRef() | CProvider_IWbemUnboundObjectSink |
STDMETHODIMP_(ULONG) Release() | CProvider_IWbemUnboundObjectSink |
~CProvider_IWbemUnboundObjectSink() | CProvider_IWbemUnboundObjectSink |
Generated on Wed Nov 13 2024 16:57:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CADOComponent Member List

This is the complete list of members for CADOComponent, including all inherited members.
Activate() | CADOComponent |
CADOComponent() | CADOComponent | [inline]
m_spObjectContext | CADOComponent |
SimpleQuery(VARIANT *returnval) | CADOComponent |
STDMETHOD_(BOOL, CanBePooled)() | CADOComponent |
STDMETHOD_(void, Deactivate)() | CADOComponent |
Generated on Wed Nov 13 2024 16:55:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoServe/Factory.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoServe

Factory.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.H
00003
00004   Summary:   Include file for the class factory COM object: CFPaper. This
00005              constitutes the STOSERVE server's class factory for the
00006              DllPaper COM component.
00007
00008              The multiple interface COM Object Class is achieved via the
00009              technique of nested classes: the implementation of the
00010              standard IClassFactory interface is nested inside of the
00011              class factory COM object class. APPUTIL's CThreaded OwnThis
00012              mechanism is used to ensure mutually exclusive access to the
00013              class factory by contending multiple threads.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial STOSERVE.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   CFPaper.
00022
00023   Functions: .
00024
00025   Origin:    6-10-96: atrent - Editor-inheritance from FACTORY.H in
00026                the CONSERVE Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 #if !defined(FACTORY_H)
00044 #define FACTORY_H
00045
00046 #ifdef __cplusplus
00047
00048 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00049   ObjectClass: CFPaper
00050
00051   Summary:     Class Factory COM Object Class for DllPaper COM components.
00052                Used to manufacture COPaper COM objects.  The mulitple
00053                interfaces on this COM object class are constructed via the
00054                nested interface classes technique.
00055
00056   Interfaces:  IUnknown
00057                  Standard interface providing COM object features.
00058                IClassFactory
00059                  Standard interface providing COM Class Factory features.
00060
00061   Aggregation: Yes, CFPaper COM objects are aggregatable by
00062                passing a non-NULL pUnkOuter IUnknown pointer into the
00063                constructor.
00064 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00065 class CFPaper : public IUnknown, public CThreaded
00066 {
00067   public:
00068     // Main Object Constructor & Destructor.
00069     CFPaper(IUnknown* pUnkOuter, CServer* pServer);
00070     ~CFPaper(void);
00071
00072     // IUnknown methods. Main object, non-delegating.
00073     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00074     STDMETHODIMP_(ULONG) AddRef(void);
00075     STDMETHODIMP_(ULONG) Release(void);
00076
00077     // We declare nested class interface implementations here.
00078
00079     // We implement the IClassFactory interface in this class
00080     // factory COM object class. Derive also from abstract CThreaded
00081     // to provide the OwnThis/UnownThis thread-safety mechanism.
00082     class CImpIClassFactory : public IClassFactory, public CThreaded
00083     {
00084       public:
00085         // Interface Implementation Constructor & Destructor.
00086         CImpIClassFactory(
00087           CFPaper* pBackObj,
00088           IUnknown* pUnkOuter,
00089           CServer* pServer);
00090         ~CImpIClassFactory(void);
00091
00092         // IUnknown methods.
00093         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00094         STDMETHODIMP_(ULONG) AddRef(void);
00095         STDMETHODIMP_(ULONG) Release(void);
00096
00097         // IClassFactory methods.
00098         STDMETHODIMP         CreateInstance(IUnknown*, REFIID, PPVOID);
00099         STDMETHODIMP         LockServer(BOOL);
00100
00101       private:
00102         // Data private to this interface implementation of IClassFactory.
00103         CFPaper*      m_pBackObj;    // Parent Object back pointer.
00104         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00105         CServer*      m_pServer;     // Server's control object.
00106     };
00107
00108     // Make the otherwise private and nested IClassFactory interface
00109     // implementation a friend to COM object instantiations of this
00110     // CFPaper COM object class.
00111     friend CImpIClassFactory;
00112
00113   private:
00114     // Private data of CFPaper COM objects.
00115
00116     // Nested IClassFactory implementation instantiation.
00117     CImpIClassFactory m_ImpIClassFactory;
00118
00119     // Main Object reference count.
00120     ULONG             m_cRefs;
00121
00122     // Outer unknown (aggregation & delegation). Used when this
00123     // CFPaper object is being aggregated.  Otherwise it is used
00124     // for delegation if this object is reused via containment.
00125     IUnknown*         m_pUnkOuter;
00126
00127     // Pointer to this component server's control object.
00128     CServer*          m_pServer;
00129 };
00130
00131 typedef CFPaper* PCFPaper;
00132
00133
00134 #endif // __cplusplus
00135
00136
00137 #endif // FACTORY_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/PhoneEntry/PhoneEntry.c Source File

  • NetDS
  • Ras
  • PhoneEntry

PhoneEntry.c

Go to the documentation of this file.
00001 //
00002 //      This is a part of the Microsoft Source Code Samples.
00003 //      Copyright 1993 - 2002 Microsoft Corporation.
00004 //      All rights reserved.
00005 //      This source code is only intended as a supplement to
00006 //      Microsoft Development Tools and/or WinHelp documentation.
00007 //      See these sources for detailed information regarding the
00008 //      Microsoft samples programs.
00009 //
00010 //      APIs used in this sample:
00011 //        RasEnumDevices()
00012 //        RasGetCountryInfo()
00013 //        RasValidateEntryName()
00014 //        RasSetEntryProperties()
00015 //        RasEnumEntries()
00016 //        RasGetEntryProperties()
00017 //
00018
00019 #define STRICT
00020 #include <windows.h>
00021 #include <windowsx.h>
00022 #include <ras.h>
00023 #include <raserror.h>
00024 #include <commctrl.h>
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include "resource.h"
00029
00030
00031 #define MAX_BUF_SIZE 256
00032 #define NUMBER_OF_PROPERTY_SHEETS   3
00033
00034 HINSTANCE g_hInstance = NULL;
00035 char g_szEntryName[256] = {0};
00036 LPRASENTRY g_lpRasEntry = NULL;
00037 LPRASDEVINFO g_RasDevInfo = NULL;
00038 BOOL g_fFlag = FALSE;
00039 BOOL g_fValidEntry = FALSE;
00040 DWORD g_dwEntries = 0;
00041 int g_iTemp = 0;
00042
00043 // Macro for counting maximum characters that will fit into a buffer
00044 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00045
00046 // Property sheet function prototypes
00047 BOOL CALLBACK PropSheet(HWND hWnd);
00048 INT_PTR CALLBACK Page0Proc(HWND, UINT, WPARAM, LPARAM);
00049 INT_PTR CALLBACK Page1Proc(HWND, UINT, WPARAM, LPARAM);
00050 INT_PTR CALLBACK Page2Proc(HWND, UINT, WPARAM, LPARAM);
00051
00052 // Dialog box function prototype
00053 INT_PTR CALLBACK Dlg_Proc1(HWND, UINT, WPARAM, LPARAM);
00054 INT_PTR CALLBACK Dlg_Proc2(HWND, UINT, WPARAM, LPARAM);
00055
00056
00057 //
00058 //  FUNCTION: Dlg_Proc1(HWND, UINT, WPARAM, LPARAM)
00059 //
00060 //  PURPOSE:  Dialog Procedure for manipulating the TCP/IP settings for a
00061 //        phonebook entry.
00062 //
00063 //  PARAMETERS:
00064 //    hwnd     - window handle
00065 //    uMessage - message number
00066 //    wparam   - additional information (dependant on message number)
00067 //    lparam   - additional information (dependant on message number)
00068 //
00069 //  RETURN VALUE:
00070 //      Returns 0.
00071 //
00072 //  COMMENTS:
00073 //    This function handles the dialog box for the TCP/IP settings.
00074 //    The dialog box allows the user to assign an IP address or use a server
00075 //    assigned one. It also allows the user to specify the various name server
00076 //    addresses. Finally, the user can also specify to use IP header compression
00077 //    and to use a default gateway on a remote network.
00078 //
00079 //    The following fields of the RASENTRY structure are modified
00080 //
00081 //    g_lpRasEntry->ipaddr
00082 //    g_lpRasEntry->ipaddrDns
00083 //    g_lpRasEntry->ipaddrDnsAlt
00084 //    g_lpRasEntry->ipaddrWins
00085 //    g_lpRasEntry->ipaddrWinsAlt
00086 //
00087 //    The following flags in the g_lpRasEntry->dwfOptions are modified
00088 //
00089 //    RASEO_SpecificIpAddr
00090 //    RASEO_SpecificNameServers
00091 //    RASEO_IpHeaderCompression
00092 //    RASEO_RemoteDefaultGateway
00093 //
00094
00095 INT_PTR CALLBACK Dlg_Proc1(HWND hWnd, UINT uMsgID, WPARAM wParam, LPARAM lParam)
00096 {
00097     static HWND hRadio1 = NULL;
00098     static HWND hRadio2 = NULL;
00099     static HWND hRadio3 = NULL;
00100     static HWND hRadio4 = NULL;
00101     static HWND hEdit1 = NULL;
00102     static HWND hEdit2 = NULL;
00103     static HWND hEdit3 = NULL;
00104     static HWND hEdit4 = NULL;
00105     static HWND hEdit5 = NULL;
00106     char buff[256];
00107     BYTE a, b, c, d;
00108
00109     // Initialize handles for various controls
00110     hRadio1 = GetDlgItem(hWnd, IDC_RADIO1);
00111     hRadio2 = GetDlgItem(hWnd, IDC_RADIO2);
00112     hRadio3 = GetDlgItem(hWnd, IDC_RADIO3);
00113     hRadio4 = GetDlgItem(hWnd, IDC_RADIO4);
00114     hEdit1 = GetDlgItem(hWnd, IDC_EDIT8);
00115     hEdit2 = GetDlgItem(hWnd, IDC_EDIT2);
00116     hEdit3 = GetDlgItem(hWnd, IDC_EDIT3);
00117     hEdit4 = GetDlgItem(hWnd, IDC_EDIT6);
00118     hEdit5 = GetDlgItem(hWnd, IDC_EDIT7);
00119
00120     if (!hRadio1 || !hRadio2 || !hRadio3 || !hRadio4 || !hEdit1 || !hEdit2 || !hEdit3 || !hEdit4 || !hEdit5)
00121     {
00122         return 0;
00123     }
00124
00125     switch (uMsgID)
00126     {
00127         case WM_INITDIALOG:
00128             if (g_fFlag)        // Check if any phonebook entry exists
00129             {                   // Display parametres of the existing entry
00130                 if (g_lpRasEntry->dwfOptions & RASEO_SpecificIpAddr)
00131                 {
00132                     CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO2, IDC_RADIO2);
00133                     EnableWindow(hEdit1, TRUE);
00134
00135                     _snprintf(buff, CELEMS(buff), "%d.%d.%d.%d", g_lpRasEntry->ipaddr.a, g_lpRasEntry->ipaddr.b,
00136                         g_lpRasEntry->ipaddr.c, g_lpRasEntry->ipaddr.d);
00137                     SendMessage(hEdit1, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) buff);
00138                 }
00139                 else
00140                 {
00141                     CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
00142                     EnableWindow(hEdit1, FALSE);
00143                 }
00144
00145                 if (g_lpRasEntry->dwfOptions & RASEO_SpecificNameServers)
00146                 {
00147                     CheckRadioButton(hWnd, IDC_RADIO3, IDC_RADIO4, IDC_RADIO4);
00148                     EnableWindow(hEdit2, TRUE);
00149                     EnableWindow(hEdit3, TRUE);
00150                     EnableWindow(hEdit4, TRUE);
00151                     EnableWindow(hEdit5, TRUE);
00152
00153                     _snprintf(buff, CELEMS(buff), "%d.%d.%d.%d", g_lpRasEntry->ipaddrDns.a, g_lpRasEntry->ipaddrDns.b,
00154                         g_lpRasEntry->ipaddrDns.c, g_lpRasEntry->ipaddrDns.d);
00155                     SendMessage(hEdit2, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) buff);
00156
00157                     _snprintf(buff, CELEMS(buff), "%d.%d.%d.%d", g_lpRasEntry->ipaddrDnsAlt.a, g_lpRasEntry->ipaddrDnsAlt.b,
00158                         g_lpRasEntry->ipaddrDnsAlt.c, g_lpRasEntry->ipaddrDnsAlt.d);
00159                     SendMessage(hEdit3, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) buff);
00160
00161                     _snprintf(buff, CELEMS(buff), "%d.%d.%d.%d", g_lpRasEntry->ipaddrWins.a, g_lpRasEntry->ipaddrWins.b,
00162                         g_lpRasEntry->ipaddrWins.c, g_lpRasEntry->ipaddrWins.d);
00163                     SendMessage(hEdit4, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) buff);
00164
00165                     _snprintf(buff, CELEMS(buff), "%d.%d.%d.%d", g_lpRasEntry->ipaddrWinsAlt.a, g_lpRasEntry->ipaddrWinsAlt.b,
00166                         g_lpRasEntry->ipaddrWinsAlt.c, g_lpRasEntry->ipaddrWinsAlt.d);
00167                     SendMessage(hEdit5, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) buff);
00168                 }
00169                 else
00170                 {
00171                     CheckRadioButton(hWnd, IDC_RADIO3, IDC_RADIO4, IDC_RADIO3);
00172                     EnableWindow(hEdit2, FALSE);
00173                     EnableWindow(hEdit3, FALSE);
00174                     EnableWindow(hEdit4, FALSE);
00175                     EnableWindow(hEdit5, FALSE);
00176                 }
00177
00178                 if (g_lpRasEntry->dwfOptions & RASEO_IpHeaderCompression)
00179                 {
00180                     CheckDlgButton(hWnd, IDC_CHECK7, BST_CHECKED);
00181                 }
00182
00183                 if (g_lpRasEntry->dwfOptions & RASEO_RemoteDefaultGateway)
00184                 {
00185                     CheckDlgButton(hWnd, IDC_CHECK8, BST_CHECKED);
00186                 }
00187             }
00188             else
00189             {                   // No entry exists, display default paramters
00190                 CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
00191                 CheckRadioButton(hWnd, IDC_RADIO3, IDC_RADIO4, IDC_RADIO3);
00192                 EnableWindow(hEdit1, FALSE);
00193                 EnableWindow(hEdit2, FALSE);
00194                 EnableWindow(hEdit3, FALSE);
00195                 EnableWindow(hEdit4, FALSE);
00196                 EnableWindow(hEdit5, FALSE);
00197                 CheckDlgButton(hWnd, IDC_CHECK7, BST_CHECKED);
00198                 CheckDlgButton(hWnd, IDC_CHECK8, BST_CHECKED);
00199             }
00200             break;
00201         case WM_CLOSE:
00202             EndDialog(hWnd, 0);
00203             break;
00204         case WM_COMMAND:
00205             switch (LOWORD(wParam))
00206             {
00207                 case IDOK:
00208                     if (IsDlgButtonChecked(hWnd, IDC_RADIO2) == BST_CHECKED)
00209                     {
00210                         // Enable the SpecificIpAddr flag and store the
00211                         // IP address in RASENTRY
00212                         g_lpRasEntry->dwfOptions |= RASEO_SpecificIpAddr;
00213
00214                         GetWindowText(GetDlgItem(hWnd, IDC_EDIT8), buff, CELEMS(buff));
00215                         sscanf(buff, "%d.%d.%d.%d", &a, &b, &c, &d);
00216                         g_lpRasEntry->ipaddr.a = a;
00217                         g_lpRasEntry->ipaddr.b = b;
00218                         g_lpRasEntry->ipaddr.c = c;
00219                         g_lpRasEntry->ipaddr.d = d;
00220                     }
00221                     else        // Disable the SpecificIpAddr flag
00222                     {
00223                         g_lpRasEntry->dwfOptions &= ~RASEO_SpecificIpAddr;
00224                     }
00225
00226                     if (IsDlgButtonChecked(hWnd, IDC_RADIO4) == BST_CHECKED)
00227                     {
00228                         // Enable the SpecificNameServers flag and store
00229                         // the DNS, DNS Alt., WINS and WINS Alt. addresses in RASENTRY
00230                         g_lpRasEntry->dwfOptions |= RASEO_SpecificNameServers;
00231
00232                         GetWindowText(GetDlgItem(hWnd, IDC_EDIT2), buff, CELEMS(buff));
00233                         sscanf(buff, "%d.%d.%d.%d", &a, &b, &c, &d);
00234                         g_lpRasEntry->ipaddrDns.a = a;
00235                         g_lpRasEntry->ipaddrDns.b = b;
00236                         g_lpRasEntry->ipaddrDns.c = c;
00237                         g_lpRasEntry->ipaddrDns.d = d;
00238
00239                         GetWindowText(GetDlgItem(hWnd, IDC_EDIT3), buff, CELEMS(buff));
00240                         sscanf(buff, "%d.%d.%d.%d", &a, &b, &c, &d);
00241                         g_lpRasEntry->ipaddrDnsAlt.a = a;
00242                         g_lpRasEntry->ipaddrDnsAlt.b = b;
00243                         g_lpRasEntry->ipaddrDnsAlt.c = c;
00244                         g_lpRasEntry->ipaddrDnsAlt.d = d;
00245
00246                         GetWindowText(GetDlgItem(hWnd, IDC_EDIT6), buff, CELEMS(buff));
00247                         sscanf(buff, "%d.%d.%d.%d", &a, &b, &c, &d);
00248                         g_lpRasEntry->ipaddrWins.a = a;
00249                         g_lpRasEntry->ipaddrWins.b = b;
00250                         g_lpRasEntry->ipaddrWins.c = c;
00251                         g_lpRasEntry->ipaddrWins.d = d;
00252
00253                         GetWindowText(GetDlgItem(hWnd, IDC_EDIT7), buff, CELEMS(buff));
00254                         sscanf(buff, "%d.%d.%d.%d", &a, &b, &c, &d);
00255                         g_lpRasEntry->ipaddrWinsAlt.a = a;
00256                         g_lpRasEntry->ipaddrWinsAlt.b = b;
00257                         g_lpRasEntry->ipaddrWinsAlt.c = c;
00258                         g_lpRasEntry->ipaddrWinsAlt.d = d;
00259                     }
00260                     else
00261                     {
00262                         // Disable the SpecificNameServers
00263                         g_lpRasEntry->dwfOptions &= ~RASEO_SpecificNameServers;
00264                     }
00265
00266                     if (IsDlgButtonChecked(hWnd, IDC_CHECK7) == BST_CHECKED)
00267                     {
00268                         // Enable the IpHeaderCompression flag
00269                         g_lpRasEntry->dwfOptions |= RASEO_IpHeaderCompression;
00270                     }
00271                     else
00272                     {
00273                         // Disable the IpHeaderCompression flag
00274                         g_lpRasEntry->dwfOptions &= ~RASEO_IpHeaderCompression;
00275                     }
00276
00277                     if (IsDlgButtonChecked(hWnd, IDC_CHECK8) == BST_CHECKED)
00278                     {
00279                         // Enable the RemoteDefaultGateway flag
00280                         g_lpRasEntry->dwfOptions |= RASEO_RemoteDefaultGateway;
00281                     }
00282                     else
00283                     {
00284                         // Disable the RemoteDefaultGateway flag
00285                         g_lpRasEntry->dwfOptions &= ~RASEO_RemoteDefaultGateway;
00286                     }
00287
00288                     EndDialog(hWnd, TRUE);
00289                     break;
00290                 case IDCANCEL:
00291                     EndDialog(hWnd, 0);
00292                     break;
00293                 case IDC_RADIO2:
00294                     EnableWindow(hEdit1, TRUE);
00295                     break;
00296                 case IDC_RADIO4:
00297                     EnableWindow(hEdit2, TRUE);
00298                     EnableWindow(hEdit3, TRUE);
00299                     EnableWindow(hEdit4, TRUE);
00300                     EnableWindow(hEdit5, TRUE);
00301                     break;
00302                 case IDC_RADIO1:
00303                     EnableWindow(hEdit1, FALSE);
00304                     break;
00305                 case IDC_RADIO3:
00306                     EnableWindow(hEdit2, FALSE);
00307                     EnableWindow(hEdit3, FALSE);
00308                     EnableWindow(hEdit4, FALSE);
00309                     EnableWindow(hEdit5, FALSE);
00310                     break;
00311                 default:
00312                     break;
00313             }
00314             break;
00315         default:
00316             break;
00317     }
00318     return 0;
00319 }
00320
00321
00322 //
00323 //  FUNCTION: Page0_Proc(HWND, UINT, WPARAM, LPARAM)
00324 //
00325 //  PURPOSE:  Intialized Page 0 of the property sheet.
00326 //
00327 //  PARAMETERS:
00328 //    hwnd     - window handle
00329 //    uMessage - message number
00330 //    wparam   - additional information (dependant on message number)
00331 //    lparam   - additional information (dependant on message number)
00332 //
00333 //  RETURN VALUE:
00334 //      Returns 0.
00335 //
00336 //  COMMENTS:
00337 //    This function handles the dialog box on the zeroth page (Basic) of the
00338 //    property sheet.
00339 //    The dialog box allows the user to enter the name of the phone book
00340 //    entry. It further allows the user to enter the telephone number
00341 //    and the device that is to be associated with that phone book entry
00342 //
00343 //    It uses the following RAS APIs
00344 //    RasEnumDevices(): To enumerate the various RAS capable devices
00345 //    RasGetCountryInfo(): To obtain the country code and country ID
00346 //    RasValidateEntryName(): To verify the entry name is of the correct form
00347 //    RasSetEntryProperties(): To set the modified values of an existing
00348 //    phone book entry or to set the values of a new entry
00349 //
00350 //    The following fields of the RASENTRY structure are modified
00351 //
00352 //    g_lpRasEntry->dwCountryID
00353 //    g_lpRasEntry->dwCountryCode
00354 //    g_lpRasEntry->szAreaCode
00355 //    g_lpRasEntry->szLocalPhoneNumber
00356 //    g_lpRasEntry->szDeviceType
00357 //    g_lpRasEntry->szDeviceName
00358 //
00359 //    The following flag in the g_lpRasEntry->dwfOptions is modified
00360 //
00361 //    RASEO_UseCountryAndAreaCodes
00362 //
00363
00364 INT_PTR CALLBACK Page0Proc(HWND hWnd, UINT uMsgID, WPARAM wParam, LPARAM lParam)
00365 {
00366     int i = 0, j = 0, k = 0, iItem =0;
00367     char szCCode[256] = {0};
00368     char szCName[256] = {0};
00369     char szTemp[256] = {0};
00370     char temp[256] = {0};
00371     DWORD nRet = 0;
00372     DWORD cb = 0;
00373     DWORD cDevices = 0;
00374     DWORD dwSize = 0;
00375   WPARAM wp = 0;
00376     LPRASCTRYINFO lpRasCtryInfo = (LPRASCTRYINFO) temp;
00377     LONG l = 0;
00378
00379     static HWND hComboBox = NULL;
00380     static HWND hComboBox2 = NULL;
00381     static HWND hEditBox1 = NULL;
00382     static HWND hEditBox3 = NULL;
00383     static HWND hEditBox4 = NULL;
00384
00385
00386     // Initialize the various controls
00387     hComboBox = GetDlgItem(hWnd, IDC_COMBO3);
00388     hComboBox2 = GetDlgItem(hWnd, IDC_COMBO1);
00389     hEditBox1 = GetDlgItem(hWnd, IDC_ENTRYNAME);
00390     hEditBox3 = GetDlgItem(hWnd, IDC_ACODE);
00391     hEditBox4 = GetDlgItem(hWnd, IDC_PHONE);
00392
00393     if (!hComboBox || !hComboBox2 || !hEditBox1 || !hEditBox3 || !hEditBox4)
00394     {
00395         return 0;
00396     }
00397
00398     lpRasCtryInfo->dwCountryID = 1;
00399     switch (uMsgID)
00400     {
00401         case WM_INITDIALOG:
00402
00403             cb = sizeof(RASDEVINFO);
00404
00405             // Allocate memory in RASDEVINFO for RasEnumDevices
00406             g_RasDevInfo = (RASDEVINFO*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00407             if (NULL == g_RasDevInfo)
00408             {
00409                 _snprintf(szTemp, CELEMS(szTemp), "HeapAlloc failed.");
00410                 return 0;
00411             }
00412
00413             g_RasDevInfo->dwSize = sizeof(RASDEVINFO);
00414
00415             nRet = RasEnumDevices(g_RasDevInfo, &cb, &cDevices);
00416             switch (nRet)
00417             {
00418             case ERROR_BUFFER_TOO_SMALL:
00419                 // If the buffer is too small, free the allocated memory and allocate a bigger buffer.
00420                 if (HeapFree(GetProcessHeap(), 0, (LPVOID)g_RasDevInfo))
00421                 {
00422                     g_RasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00423                     if (NULL == g_RasDevInfo)
00424                     {
00425                         printf("HeapAlloc failed.\n");
00426                         return 0;
00427                     }
00428
00429                     g_RasDevInfo->dwSize = sizeof(RASDEVINFO);
00430                     nRet = RasEnumDevices(g_RasDevInfo, &cb, &cDevices);
00431                 }
00432                 else
00433                 {
00434                     printf("HeapFree failed.\n");
00435                     return 0;
00436                 }
00437                 break;
00438
00439             case ERROR_SUCCESS:
00440                 break;
00441
00442             default:
00443                 _snprintf(szTemp, CELEMS(szTemp), "RasEnumDevices failed: %d ", nRet);
00444                 MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00445                 return 0;
00446                 break;
00447
00448             }
00449
00450             // Check for RAS capable devices using RasEnumDevices
00451             if (ERROR_SUCCESS != nRet)
00452             {
00453                 _snprintf(szTemp, CELEMS(szTemp), "RasEnumDevices failed: %d ", nRet);
00454                 MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00455                 return 0;
00456             }
00457             else
00458             {
00459                 g_iTemp = cDevices;
00460                 if (!cDevices)
00461                 {
00462                     _snprintf(szTemp, CELEMS(szTemp), "No RAS capable devices found.");
00463                     MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00464                     return 0;
00465                 }
00466                 else
00467                 {               // Display the devices in the combo box
00468                     for (i = 0; i < (int) cDevices; i++)
00469                     {
00470                         SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) g_RasDevInfo[i].szDeviceName);
00471                     }
00472
00473                     if (g_fFlag)
00474                     {
00475                         wp = SendMessage(hComboBox, CB_FINDSTRINGEXACT, 0, (LPARAM) (LPCTSTR) g_lpRasEntry->szDeviceName);
00476                         SendMessage(hComboBox, CB_SETCURSEL, wp, 0);
00477                     }
00478                     else
00479                     {
00480                         SendMessage(hComboBox, CB_SETCURSEL, 0, 0);
00481                     }
00482                 }
00483             }
00484
00485             while (lpRasCtryInfo->dwCountryID)
00486             {
00487                 // Initialize RASCTRYINFO structure to be used in RasGetCountryInfo().
00488                 lpRasCtryInfo->dwSize = sizeof(RASCTRYINFO);
00489                 dwSize = MAX_BUF_SIZE;     // Minimum size of 256 required.
00490
00491                 nRet = RasGetCountryInfo(lpRasCtryInfo, &dwSize);
00492                 if (nRet)
00493                 {
00494                     _snprintf(szTemp, CELEMS(szTemp), "RasGetCountryInfo failed: %d", nRet);
00495                     MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00496                     return FALSE;
00497                 }
00498
00499                 _snprintf(szCCode, CELEMS(szCCode), "%s (%d)", (LPSTR) lpRasCtryInfo + lpRasCtryInfo->dwCountryNameOffset, lpRasCtryInfo->dwCountryCode);
00500
00501                 // Display the country information in the combo box
00502                 SendMessage(hComboBox2, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) szCCode);
00503
00504                 // Store the current phonebook entry's country name and code
00505                 if (g_lpRasEntry->dwCountryID == lpRasCtryInfo->dwCountryID)
00506                 {
00507                     lstrcpyn(szTemp, szCCode, CELEMS(szTemp));
00508                 }
00509
00510                 lpRasCtryInfo->dwCountryID = lpRasCtryInfo->dwNextCountryID;
00511             }
00512
00513             if (g_fFlag == TRUE)   // Flag to indicate phonebook entry exists
00514             {
00515                 // Display the properties retrieved for the first page
00516                 SendMessage(hEditBox1, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) g_szEntryName);
00517                 if (g_lpRasEntry->dwfOptions & RASEO_UseCountryAndAreaCodes)
00518                 {
00519                     CheckDlgButton(hWnd, IDC_CHECK6, BST_CHECKED);
00520                     wp = SendMessage(hComboBox2, CB_FINDSTRINGEXACT, 0, (LPARAM) (LPCTSTR) szTemp);
00521                     SendMessage(hComboBox2, CB_SETCURSEL, wp, 0);
00522                     SendMessage(hEditBox3, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) g_lpRasEntry->szAreaCode);
00523                     EnableWindow(hEditBox3, TRUE);
00524                     EnableWindow(hComboBox2, TRUE);
00525
00526                 }
00527                 else
00528                 {
00529                     EnableWindow(hEditBox3, FALSE);
00530                     EnableWindow(hComboBox2, FALSE);
00531                 }
00532
00533                 SendMessage(hEditBox4, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) g_lpRasEntry->szLocalPhoneNumber);
00534
00535             }
00536             else
00537             {
00538                 // Set Default Values
00539                 EnableWindow(hComboBox2, FALSE);
00540                 EnableWindow(hEditBox3, FALSE);
00541                 g_lpRasEntry->dwfNetProtocols |= RASNP_Ip;
00542                 g_lpRasEntry->dwFramingProtocol = RASFP_Ppp;
00543             }
00544
00545             return TRUE;
00546         case WM_COMMAND:
00547             switch (LOWORD(wParam))
00548             {
00549                 // If user selects to use the Country Code and Area Code
00550                 case IDC_ECAC:
00551                     if (IsDlgButtonChecked(hWnd, IDC_ECAC) == BST_CHECKED)
00552                     {
00553                         EnableWindow(hEditBox3, TRUE);
00554                         EnableWindow(hComboBox2, TRUE);
00555                         SendMessage(hComboBox2, CB_SETCURSEL, 0, 0);
00556                     }
00557                     else
00558                     {
00559                         EnableWindow(hEditBox3, FALSE);
00560                         EnableWindow(hComboBox2, FALSE);
00561                     }
00562                     return TRUE;
00563                 default:
00564                     break;
00565
00566             }
00567             break;
00568         case WM_NOTIFY:
00569             switch (((LPNMHDR) lParam)->code)
00570             {
00571                 case PSN_APPLY: // OK button has been clicked
00572                     {
00573                         HWND hwndControl = NULL;
00574
00575                         // Get the values in the edit fields of the first page
00576                         hwndControl = GetDlgItem(hWnd, IDC_ENTRYNAME);
00577                         if (hwndControl)
00578                         {
00579                             GetWindowText(hwndControl, g_szEntryName, CELEMS(g_szEntryName));
00580                         }
00581
00582                         hwndControl = GetDlgItem(hWnd, IDC_ACODE);
00583                         if (hwndControl)
00584                         {
00585                             GetWindowText(hwndControl, g_lpRasEntry->szAreaCode, CELEMS(g_lpRasEntry->szAreaCode));
00586                         }
00587
00588                         hwndControl = GetDlgItem(hWnd, IDC_PHONE);
00589                         if (hwndControl)
00590                         {
00591                             GetWindowText(hwndControl, g_lpRasEntry->szLocalPhoneNumber, CELEMS(g_lpRasEntry->szLocalPhoneNumber));
00592                         }
00593
00594                         // Validate the phonebook entry name using RasValidateEntryName
00595                         if (nRet = RasValidateEntryName(NULL, (LPSTR)g_szEntryName))
00596                         {
00597                             switch (nRet)
00598                             {
00599                                 case ERROR_ALREADY_EXISTS:
00600                                     // If entry already exists, warn user that original values
00601                                     // will be overwritten
00602                                     g_fValidEntry = TRUE;
00603                                     _snprintf(szTemp, CELEMS(szTemp), "Entry name %s already exists, will overwrite!", g_szEntryName);
00604                                     iItem = MessageBox(hWnd, szTemp, "Warning!!!", MB_YESNO | MB_ICONWARNING);
00605                                     if (iItem == IDNO)
00606                                         return 0;
00607                                     break;
00608                                 case ERROR_INVALID_NAME:
00609                                     g_fValidEntry = FALSE;
00610                                     _snprintf(szTemp, CELEMS(szTemp), "Entry name %s is invalid", g_szEntryName);
00611                                     MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00612                                     return 0;
00613                                     break;
00614                             }
00615                         }
00616                         else
00617                         {
00618                             g_fValidEntry = TRUE;
00619                         }
00620
00621                         if (IsDlgButtonChecked(hWnd, IDC_ECAC) == BST_CHECKED)
00622                             // Enable the UseCountryAndAreaCodes flag
00623                         {
00624                             g_lpRasEntry->dwfOptions |= RASEO_UseCountryAndAreaCodes;
00625                             // Get the country name and code
00626                 wp = SendMessage(hComboBox2, CB_GETCURSEL, 0, 0);
00627                             l = SendMessage(hComboBox2, CB_GETLBTEXTLEN, wp, (LPARAM)0);
00628                             if (CELEMS(szTemp) > l)
00629                             {
00630                                 SendMessage(hComboBox2, CB_GETLBTEXT, wp, (LPARAM) (LPCSTR) szTemp);
00631                                 lstrcpyn(szCCode, szTemp, CELEMS(szCCode));
00632                             }
00633                             else
00634                             {
00635                                 return FALSE;
00636                             }
00637
00638                             k = 0;
00639                             // Store the country name in a buffer
00640                             while (szCCode[k] != '(')
00641                             {
00642                                 k++;
00643                             }
00644
00645                             szCCode[k - 1] = '\0';
00646                             k++;
00647                             i = 0;
00648
00649                             // Store the country code in another buffer
00650                             while (szTemp[k] != ')')
00651                             {
00652                                 szCName[i] = szTemp[k];
00653                                 i++;
00654                                 k++;
00655                             }
00656
00657                             szCName[i] = '\0';
00658
00659                             // Convert the country code string to an integer
00660                             j = atoi(szCName);
00661                             lpRasCtryInfo->dwSize = sizeof(RASCTRYINFO);
00662                             lpRasCtryInfo->dwCountryID = 1;
00663
00664                             // Obtain the country ID by using RasGetCountryInfo
00665                             while (lpRasCtryInfo->dwCountryID)
00666                             {
00667                                 lpRasCtryInfo->dwSize = sizeof(RASCTRYINFO);
00668                                 dwSize = MAX_BUF_SIZE;
00669                                 if (nRet = RasGetCountryInfo(lpRasCtryInfo, &dwSize))
00670                                 {
00671                                     _snprintf(szTemp, CELEMS(szTemp), "RasGetCountryInfo failed: %d", nRet);
00672                                     MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00673                                     return -1;
00674                                 }
00675                                 if ((lstrcmp(szCCode, (LPSTR) lpRasCtryInfo + lpRasCtryInfo->dwCountryNameOffset)) == 0)
00676                                 {
00677                                     g_lpRasEntry->dwCountryCode = lpRasCtryInfo->dwCountryCode;
00678                                     g_lpRasEntry->dwCountryID = lpRasCtryInfo->dwCountryID;
00679                                     break;
00680                                 }
00681
00682                                 lpRasCtryInfo->dwCountryID = lpRasCtryInfo->dwNextCountryID;
00683                             }
00684                         }
00685                         else
00686                         {
00687                             g_lpRasEntry->dwfOptions &= ~RASEO_UseCountryAndAreaCodes;
00688                         }
00689
00690                         // Get the device chosen from the combo box
00691               wp = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
00692                         l = SendMessage(hComboBox, CB_GETLBTEXTLEN, wp, (LPARAM) 0);
00693                         if (CELEMS(g_lpRasEntry->szDeviceName) > l)
00694                         {
00695                             SendMessage(hComboBox, CB_GETLBTEXT, wp, (LPARAM) (LPCSTR) g_lpRasEntry->szDeviceName);
00696                             for (i = 0; i < g_iTemp; i++)
00697                             {
00698                                 if (!(lstrcmp(g_RasDevInfo[i].szDeviceName, g_lpRasEntry->szDeviceName)))
00699                                 {
00700                                     lstrcpyn(g_lpRasEntry->szDeviceType, g_RasDevInfo[i].szDeviceType, CELEMS(g_lpRasEntry->szDeviceType));
00701                                 }
00702                             }
00703
00704                             // Set the properties of the phonebook entry using
00705                             // RasSetEntryProperties
00706
00707                             if (nRet = RasSetEntryProperties(NULL, (LPSTR) g_szEntryName, g_lpRasEntry, g_lpRasEntry->dwSize, NULL, 0))
00708                             {
00709                                 _snprintf(szTemp, CELEMS(szTemp), "RasSetEntryProperties  failed: %d", nRet);
00710                                 MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
00711                             }
00712                         }
00713                         else
00714                         {
00715                             return FALSE;
00716                         }
00717
00718                         return TRUE;
00719                     }
00720                 default:
00721                     break;
00722             }
00723             break;
00724
00725         default:
00726             break;
00727     }
00728
00729     return FALSE;
00730 }
00731
00732 //
00733 //  FUNCTION: Page1_Proc(HWND, UINT, WPARAM, LPARAM)
00734 //
00735 //  PURPOSE:  Intialized Page 1 of the property sheet.
00736 //
00737 //  PARAMETERS:
00738 //    hwnd     - window handle
00739 //    uMessage - message number
00740 //    wparam   - additional information (dependant on message number)
00741 //    lparam   - additional information (dependant on message number)
00742 //
00743 //  RETURN VALUE:
00744 //      Returns 0.
00745 //
00746 //  COMMENTS:
00747 //    This function handles the dialog box on the first page (Server) of the
00748 //    property sheet.
00749 //    The dialog box allows the user to enter the dial up server type.
00750 //    There are two options to choose from. It further allows the user to
00751 //    choose the Network Protocols, namely, TCP/IP or IPX/SPX.
00752 //    Finally it allows the user to enable Software Compression and PPP LCP
00753 //    extensions.
00754 //
00755 //    The following fields of the RASENTRY structure are modified
00756 //
00757 //    g_lpRasEntry->dwfNetProtocols
00758 //    g_lpRasEntry->dwFramingProtocol
00759 //
00760 //    The following flags in the g_lpRasEntry->dwfOptions are modified
00761 //
00762 //    RASEO_SwCompression
00763 //    RASEO_DisableLcpExtensions
00764 //
00765
00766 INT_PTR CALLBACK Page1Proc(HWND hWnd, UINT uMsgID, WPARAM wParam, LPARAM lParam)
00767 {
00768     static HWND hComboBox = NULL;
00769     static HWND hCheckBox1 = NULL;
00770     static HWND hCheckBox4 = NULL;
00771     static HWND hCheckBox5 = NULL;
00772     static HWND hButton = NULL;
00773     int i = 0;
00774
00775     // Initialize the various controls
00776     hComboBox = GetDlgItem(hWnd, IDC_COMBO2);
00777     hCheckBox1 = GetDlgItem(hWnd, IDC_CHECK1);
00778     hCheckBox4 = GetDlgItem(hWnd, IDC_CHECK4);
00779     hCheckBox5 = GetDlgItem(hWnd, IDC_CHECK5);
00780     hButton = GetDlgItem(hWnd, IDC_BUTTON1);
00781
00782     if (!hComboBox || !hCheckBox1 || !hCheckBox4 || !hCheckBox5 || !hButton)
00783     {
00784         return FALSE;
00785     }
00786
00787     switch (uMsgID)
00788     {
00789         case WM_INITDIALOG:
00790             SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM) "PPP: Windows NT, Windows 95 Plus, Internet");
00791             SendMessage(hComboBox, CB_ADDSTRING, 1, (LPARAM) "SLIP: Internet");
00792
00793             if (g_fFlag)           // Phonebook entry exists
00794             {                   // Display the entry's parameters
00795
00796                 switch (g_lpRasEntry->dwFramingProtocol)
00797                 {
00798                     case RASFP_Ppp:
00799                         SendMessage(hComboBox, CB_SETCURSEL, 0, 0);
00800                         break;
00801                     case RASFP_Slip:
00802                         SendMessage(hComboBox, CB_SETCURSEL, 1, 0);
00803                         break;
00804
00805                     default:
00806                         break;
00807                 }
00808
00809                 if (g_lpRasEntry->dwfOptions & RASEO_SwCompression)
00810                 {
00811                     CheckDlgButton(hWnd, IDC_CHECK4, BST_CHECKED);
00812                 }
00813                 else
00814                 {
00815                     CheckDlgButton(hWnd, IDC_CHECK4, BST_UNCHECKED);
00816                 }
00817
00818                 if (g_lpRasEntry->dwfOptions & RASEO_DisableLcpExtensions)
00819                 {
00820                     CheckDlgButton(hWnd, IDC_CHECK5, BST_UNCHECKED);
00821                 }
00822                 else
00823                 {
00824                     CheckDlgButton(hWnd, IDC_CHECK5, BST_CHECKED);
00825                 }
00826
00827
00828                 if (g_lpRasEntry->dwfNetProtocols & RASNP_Ip)
00829                 {
00830                     CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);
00831                 }
00832                 else
00833                 {
00834                     CheckDlgButton(hWnd, IDC_CHECK1, BST_UNCHECKED);
00835                 }
00836             }
00837             else
00838             {
00839                 // Display default parameters
00840                 SendMessage(hComboBox, CB_SETCURSEL, 0, 0);
00841                 CheckDlgButton(hWnd, IDC_CHECK5, BST_CHECKED);
00842                 CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);
00843             }
00844             return TRUE;
00845
00846         case WM_COMMAND:
00847             switch (LOWORD(wParam))
00848             {
00849                 case IDC_BUTTON1:   // TCP/IP Settings Button pressed
00850                     DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG7), hWnd, Dlg_Proc1);
00851                     return TRUE;
00852
00853                 case IDC_COMBO2:// Framing Protocol settings
00854                     if (CBN_SELCHANGE == HIWORD(wParam))
00855                     {
00856                         i = (int)SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
00857                         switch (i)
00858                         {
00859                             case 0: // PPP
00860
00861                                 CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);
00862                                 CheckDlgButton(hWnd, IDC_CHECK5, BST_CHECKED);
00863                                 EnableWindow(hCheckBox1, TRUE);
00864                                 EnableWindow(hCheckBox4, TRUE);
00865                                 EnableWindow(hCheckBox5, TRUE);
00866                                 EnableWindow(hButton, TRUE);
00867                                 break;
00868                             case 1: // Slip
00869                                 EnableWindow(hCheckBox1, TRUE);
00870                                 CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);
00871                                 if (IsDlgButtonChecked(hWnd, IDC_CHECK4))
00872                                     CheckDlgButton(hWnd, IDC_CHECK4, BST_UNCHECKED);
00873                                 if (IsDlgButtonChecked(hWnd, IDC_CHECK5))
00874                                     CheckDlgButton(hWnd, IDC_CHECK5, BST_UNCHECKED);
00875                                 EnableWindow(hCheckBox4, FALSE);
00876                                 EnableWindow(hCheckBox5, FALSE);
00877                                 EnableWindow(hButton, TRUE);
00878                                 break;
00879                             default:
00880                                 break;
00881                         }
00882                     }
00883                     break;
00884                 default:
00885                     break;
00886             }
00887             return TRUE;
00888
00889         case WM_NOTIFY:
00890             switch (((LPNMHDR) lParam)->code)
00891             {
00892                 case PSN_KILLACTIVE:
00893                     i = (int)SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
00894                     switch (i)  // Set framing protocol based on the
00895                     {           // value returned from the combo box
00896                         case 0:
00897                             g_lpRasEntry->dwFramingProtocol = RASFP_Ppp;
00898                             break;
00899                         case 1:
00900                             g_lpRasEntry->dwFramingProtocol = RASFP_Slip;
00901                             break;
00902                         default:
00903                             g_lpRasEntry->dwFramingProtocol = RASFP_Ppp;
00904                             break;
00905                     }
00906
00907                     if (IsDlgButtonChecked(hWnd, IDC_CHECK4) == BST_CHECKED)
00908                     {
00909                         // Enable the SwCompression flag
00910                         g_lpRasEntry->dwfOptions |= RASEO_SwCompression;
00911                     }
00912                     else
00913                     {
00914                         // Disable the SwCompression flag
00915                         g_lpRasEntry->dwfOptions &= ~RASEO_SwCompression;
00916                     }
00917
00918                     if (IsDlgButtonChecked(hWnd, IDC_CHECK5) == BST_UNCHECKED)
00919                     {
00920                         // Enable the DisableLcpExtensions flag
00921                         g_lpRasEntry->dwfOptions |= RASEO_DisableLcpExtensions;
00922                     }
00923                     else
00924                     {
00925                         // Disable the DisableLcpExtensions flag
00926                         g_lpRasEntry->dwfOptions &= ~RASEO_DisableLcpExtensions;
00927                     }
00928
00929                     if (IsDlgButtonChecked(hWnd, IDC_CHECK1) == BST_CHECKED)
00930                     {
00931                         // Enable Ip Net Protocol
00932                         g_lpRasEntry->dwfNetProtocols |= RASNP_Ip;
00933                     }
00934                     else
00935                     {
00936                         // Disable Ip Net Protocol
00937                         g_lpRasEntry->dwfNetProtocols &= ~RASNP_Ip;
00938                     }
00939
00940                     return TRUE;
00941                 default:
00942                     break;
00943             }
00944             break;
00945         default:
00946             break;
00947     }
00948     return FALSE;
00949 }
00950
00951 //
00952 //  FUNCTION: Page2_Proc(HWND, UINT, WPARAM, LPARAM)
00953 //
00954 //  PURPOSE:  Intialized Page 2 of the property sheet.
00955 //
00956 //  PARAMETERS:
00957 //    hwnd     - window handle
00958 //    uMessage - message number
00959 //    wparam   - additional information (dependant on message number)
00960 //    lparam   - additional information (dependant on message number)
00961 //
00962 //  RETURN VALUE:
00963 //      Returns 0.
00964 //
00965 //  COMMENTS:
00966 //    This function handles the dialog box on the second page (Script) of the
00967 //    property sheet.
00968 //    The dialog box allows the user to enter the name of script that they
00969 //    want to run after dialing. The user can also enable a Terminal Window
00970 //    to show up after dialing.
00971 //
00972 //    The following field of the RASENTRY structure is modified
00973 //
00974 //    g_lpRasEntry->szScript
00975 //
00976 //    The following flag in the g_lpRasEntry->dwfOptions is modified
00977 //
00978 //    RASEO_TerminalAfterDial
00979 //
00980
00981 INT_PTR CALLBACK Page2Proc(HWND hWnd, UINT uMsgID, WPARAM wParam, LPARAM lParam)
00982 {
00983     static HWND hEdit1 = NULL;
00984
00985     // Initialize the various controls
00986     hEdit1 = GetDlgItem(hWnd, IDC_EDIT1);
00987
00988     if (!hEdit1)
00989     {
00990         return 0;
00991     }
00992
00993     switch (uMsgID)
00994     {
00995         case WM_INITDIALOG:
00996             if (g_fFlag)        // Phonebook entry exists
00997             {                   // Display the parameters of the entry
00998                 if (g_lpRasEntry->dwfOptions & RASEO_TerminalAfterDial)
00999                 {
01000                     CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO3, IDC_RADIO3);
01001                     EnableWindow(hEdit1, FALSE);
01002                 }
01003                 else
01004                 {
01005                     if ((strcmp(g_lpRasEntry->szScript, "")) != 0)
01006                     {
01007                         CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO3, IDC_RADIO2);
01008                         EnableWindow(hEdit1, TRUE);
01009                         SendMessage(hEdit1, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) g_lpRasEntry->szScript);
01010                     }
01011                     else
01012                     {
01013                         CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO3, IDC_RADIO1);
01014                         EnableWindow(hEdit1, FALSE);
01015                     }
01016                 }
01017             }
01018             else
01019             {                   // Display default parametrs
01020                 CheckRadioButton(hWnd, IDC_RADIO1, IDC_RADIO3, IDC_RADIO1);
01021                 EnableWindow(hEdit1, FALSE);
01022             }
01023
01024             break;
01025         case WM_COMMAND:
01026             switch (LOWORD(wParam))
01027             {
01028                 case IDC_RADIO1:// Disable the edit box for holding the script name
01029                 case IDC_RADIO3:
01030                     EnableWindow(hEdit1, FALSE);
01031                     break;
01032                 case IDC_RADIO2:// Enable the edit box for holding the script name
01033                     EnableWindow(hEdit1, TRUE);
01034                     break;
01035                 default:
01036                     break;
01037             }
01038             break;
01039         case WM_NOTIFY:
01040             switch (((LPNMHDR) lParam)->code)
01041             {
01042                 case PSN_KILLACTIVE:
01043                     if (IsDlgButtonChecked(hWnd, IDC_RADIO3))
01044                     {
01045                         // Enable the TerminalAfterDial flag
01046                         g_lpRasEntry->dwfOptions |= RASEO_TerminalAfterDial;
01047                     }
01048                     else
01049                     {
01050                         // Disable the TerminalAfterDial flag
01051                         g_lpRasEntry->dwfOptions &= ~RASEO_TerminalAfterDial;
01052                     }
01053
01054                     if (IsDlgButtonChecked(hWnd, IDC_RADIO2))
01055                     {
01056                         // Get the script name from the edit box
01057                         GetWindowText(GetDlgItem(hWnd, IDC_EDIT1), g_lpRasEntry->szScript, 256);
01058                     }
01059                     else
01060                     {
01061                         // Corresponds to "None"
01062                         g_lpRasEntry->szScript[0] = TEXT('\0');
01063                     }
01064
01065                     return TRUE;
01066                     break;
01067                 default:
01068                     break;
01069             }
01070             break;
01071         default:
01072             break;
01073     }
01074     return 0;
01075 }
01076
01077
01078 //
01079 //  FUNCTION: PropSheet()
01080 //
01081 //  PURPOSE:  Intialized Property Sheet.
01082 //
01083 //  PARAMETERS:
01084 //    none
01085 //
01086 //  RETURN VALUE:
01087 //    Returns 0.
01088 //
01089 //  COMMENTS:
01090 //    This function defines and initializes the property sheet.
01091 //
01092
01093 BOOL CALLBACK PropSheet(HWND hWnd)
01094 {
01095     // Build property sheet
01096     PROPSHEETHEADER pshSheet;
01097     PROPSHEETPAGE pspPage[NUMBER_OF_PROPERTY_SHEETS];
01098     int iRC = 0;
01099
01100     ZeroMemory(&pshSheet, sizeof(PROPSHEETHEADER));
01101
01102     // Sheet
01103     pshSheet.dwSize = sizeof(PROPSHEETHEADER);
01104     pshSheet.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
01105     pshSheet.hwndParent = hWnd;
01106     pshSheet.hInstance = g_hInstance;
01107     pshSheet.pszCaption = "EditPhonebookEntries";
01108     pshSheet.nPages = NUMBER_OF_PROPERTY_SHEETS;
01109     pshSheet.ppsp = pspPage;
01110
01111     ZeroMemory(&pspPage, sizeof(PROPSHEETPAGE) * NUMBER_OF_PROPERTY_SHEETS);
01112
01113     // Page 0
01114     pspPage[0].dwSize = sizeof(PROPSHEETPAGE);
01115     pspPage[0].hInstance = g_hInstance;
01116     pspPage[0].pszTemplate = MAKEINTRESOURCE(IDD_DIALOG2);
01117     pspPage[0].pfnDlgProc = Page0Proc;
01118
01119     // Page 1
01120     pspPage[1].dwSize = sizeof(PROPSHEETPAGE);
01121     pspPage[1].hInstance = g_hInstance;
01122     pspPage[1].pszTemplate = MAKEINTRESOURCE(IDD_DIALOG3);
01123     pspPage[1].pfnDlgProc = Page1Proc;
01124
01125     // Page 2
01126     pspPage[2].dwSize = sizeof(PROPSHEETPAGE);
01127     pspPage[2].hInstance = g_hInstance;
01128     pspPage[2].pszTemplate = MAKEINTRESOURCE(IDD_DIALOG4);
01129     pspPage[2].pfnDlgProc = Page2Proc;
01130
01131     iRC = PropertySheet(&pshSheet);
01132
01133     return 0;
01134 }
01135
01136
01137 //
01138 //  FUNCTION: WinMain(HWND, UINT, WPARAM, LPARAM)
01139 //
01140 //
01141 //  PARAMETERS:
01142 //    hwnd     - window handle
01143 //    uMessage - message number
01144 //    wparam   - additional information (dependant on message number)
01145 //    lparam   - additional information (dependant on message number)
01146 //
01147 //  RETURN VALUE:
01148 //    Returns the main dialog box which lists all the available phone
01149 //    book entries.
01150 //
01151
01152 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
01153 {
01154     int iRet = 0;
01155     iRet = (int)DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, Dlg_Proc2);
01156
01157     if (g_RasDevInfo)
01158     {
01159         HeapFree(GetProcessHeap(), 0, (LPVOID)g_RasDevInfo);
01160         g_RasDevInfo = NULL;
01161     }
01162
01163     return iRet;
01164 }
01165
01166 //
01167 //  FUNCTION: Dlg_Proc2(HWND, UINT, WPARAM, LPARAM)
01168 //
01169 //  PURPOSE:  Display a list of available phone book entries and
01170 //        allow user to modify it or enter a new entry to the phone book
01171 //
01172 //  PARAMETERS:
01173 //    hwnd     - window handle
01174 //    uMessage - message number
01175 //    wparam   - additional information (dependant on message number)
01176 //    lparam   - additional information (dependant on message number)
01177 //
01178 //  RETURN VALUE:
01179 //      Returns 0.
01180 //
01181 //  COMMENTS:
01182 //    This function displays the dialog box that contains a list of existing
01183 //    phonebook entries. The user can either modify these entries or enter
01184 //    values for a new entry.
01185 //
01186 //    RAS API's used
01187 //
01188 //    RasEnumEntries(): To enumerate the list of the phone book entries
01189 //    RasGetEntryProperties(): To get the properties of an existing entry
01190 //
01191
01192 INT_PTR CALLBACK Dlg_Proc2(HWND hWnd, UINT uMsgID, WPARAM wParam, LPARAM lParam)
01193 {
01194     int i = 0;
01195     char szTemp[256] = {0};
01196     DWORD nRet = 0;
01197     LPRASENTRYNAME lpRasEntryName = NULL;
01198     LPRASENTRYNAME lpTempRasEntryName = NULL;
01199
01200     DWORD cbEntry = sizeof(RASENTRYNAME);
01201     DWORD cEntries = 0;
01202     static HWND hComboBox = NULL;
01203     DWORD dwRasEntryInfoSize = 0;
01204   WPARAM wp = 0;
01205     LONG l = 0;
01206
01207     hComboBox = GetDlgItem(hWnd, IDC_COMBO1);
01208     if (!hComboBox)
01209     {
01210         return FALSE;
01211     }
01212
01213     switch (uMsgID)
01214     {
01215         case WM_INITDIALOG:
01216             // Enumerate all the phonebook entries using RasEnumEntries
01217
01218             lpRasEntryName = (LPRASENTRYNAME)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RASENTRYNAME));
01219             if (NULL == lpRasEntryName)
01220             {
01221                 return FALSE;
01222             }
01223
01224             lpRasEntryName->dwSize = sizeof(RASENTRYNAME);
01225             nRet = RasEnumEntries(NULL, NULL, lpRasEntryName, &cbEntry, &cEntries);
01226             if (ERROR_BUFFER_TOO_SMALL == nRet)
01227             {
01228                 // Need to make sure that we actually free the memory before allocating it again.
01229                 if (HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasEntryName))
01230                 {
01231                     lpRasEntryName = (LPRASENTRYNAME)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbEntry);
01232                     if (NULL == lpRasEntryName)
01233                     {
01234                         _snprintf(szTemp, CELEMS(szTemp), "Couldn't allocate memory.");
01235                         MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
01236                         return FALSE;
01237                     }
01238
01239                     lpRasEntryName->dwSize = sizeof(RASENTRYNAME);
01240                     if (nRet = RasEnumEntries(NULL, NULL, lpRasEntryName, &cbEntry, &cEntries))
01241                     {
01242                         _snprintf(szTemp, CELEMS(szTemp), "RasEnumEntries  failed: %d", nRet);
01243                         MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
01244
01245                         if (lpRasEntryName)
01246                         {
01247                             HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasEntryName);
01248                             lpRasEntryName = NULL;
01249                         }
01250
01251                         return FALSE;
01252                     }
01253                 }
01254                 else
01255                 {
01256                     return FALSE;
01257                 }
01258             }
01259
01260             lpTempRasEntryName = lpRasEntryName;
01261             if (cEntries)
01262             {
01263                 g_dwEntries = cEntries;
01264                 for (i = 0; i < (int) cEntries; i++)
01265                 {
01266                     SendMessage(hComboBox, CB_ADDSTRING, i,
01267                         (LPARAM) (LPCTSTR) lpRasEntryName->szEntryName);
01268                     lpRasEntryName++;
01269                 }
01270
01271                 SendMessage(hComboBox, CB_SETCURSEL, 0, 0);
01272                 GetWindowText(hComboBox, g_szEntryName, CELEMS(g_szEntryName));
01273             }
01274             else
01275             {
01276                 SendMessage(hComboBox, CB_SETCURSEL, 0, 0);
01277             }
01278
01279             if (lpTempRasEntryName)
01280             {
01281                 HeapFree(GetProcessHeap(), 0, (LPVOID)lpTempRasEntryName);
01282                 lpRasEntryName = NULL;
01283             }
01284             return TRUE;
01285
01286         case WM_CLOSE:
01287             EndDialog(hWnd, 0);
01288             return TRUE;
01289
01290         case WM_COMMAND:
01291             switch (LOWORD(wParam))
01292             {
01293                 case IDOK:
01294                     EndDialog(hWnd, 0);
01295                     return TRUE;
01296
01297                 case IDNEW:
01298                     g_fFlag = FALSE;
01299                     g_lpRasEntry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RASENTRY));
01300                     if (NULL == g_lpRasEntry)
01301                     {
01302                         return FALSE;
01303                     }
01304
01305                     g_lpRasEntry->dwSize = sizeof(RASENTRY);
01306                     PropSheet(hWnd);
01307                     if (g_fValidEntry)
01308                     {
01309                         SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) g_szEntryName);
01310             wp = SendMessage(hComboBox, CB_FINDSTRINGEXACT, 0, (LPARAM) (LPCTSTR) g_szEntryName);
01311                         SendMessage(hComboBox, CB_SETCURSEL, wp, 0);
01312                         g_dwEntries++;
01313                     }
01314
01315                     HeapFree(GetProcessHeap(), 0, (LPVOID)g_lpRasEntry);
01316                     g_lpRasEntry = NULL;
01317
01318                     return TRUE;
01319                 case IDCHANGE:
01320                     if (g_dwEntries)
01321                     {
01322                         wp = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
01323                         l = SendMessage(hComboBox, CB_GETLBTEXTLEN, wp, (LPARAM) 0);
01324                         if (CELEMS(g_szEntryName) > l)
01325                         {
01326                             SendMessage(hComboBox, CB_GETLBTEXT, wp, (LPARAM) (LPCSTR) g_szEntryName);
01327                         }
01328
01329                         // Initialize the dwRasEntryInfoSize parameter
01330                         if ((nRet = RasGetEntryProperties(NULL,
01331                                     g_szEntryName,
01332                                     NULL,
01333                                     &dwRasEntryInfoSize,
01334                                     NULL,
01335                                     0)) != ERROR_BUFFER_TOO_SMALL)
01336                         {
01337                             _snprintf(szTemp, CELEMS(szTemp), "RasGetEntryProperty failed: %d", nRet);
01338                             MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
01339                         }
01340
01341                         if (dwRasEntryInfoSize > 0)
01342                         {
01343                             g_lpRasEntry = (LPRASENTRY) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRasEntryInfoSize);
01344                             if (NULL == g_lpRasEntry)
01345                             {
01346                                 return FALSE;
01347                             }
01348                             g_lpRasEntry->dwSize = dwRasEntryInfoSize;
01349                         }
01350                         else
01351                         {
01352                             g_lpRasEntry = NULL;
01353                         }
01354
01355                         // Retrieve the properties of the phonebook entry using
01356                         // RasGetEntryProperties
01357                         if (nRet = RasGetEntryProperties(NULL,
01358                                 g_szEntryName,
01359                                 g_lpRasEntry,
01360                                 &dwRasEntryInfoSize,
01361                                 NULL,
01362                                 0))
01363                         {
01364                             _snprintf(szTemp, CELEMS(szTemp), "RasGetEntryProperty failed: %d", nRet);
01365                             MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONERROR);
01366                         }
01367                         else
01368                         {
01369                             g_fFlag = TRUE;    // Flag to indicate phonebook entry exists
01370                             PropSheet(hWnd);
01371                         }
01372
01373                         HeapFree(GetProcessHeap(), 0, (LPVOID)g_lpRasEntry);
01374                         g_lpRasEntry = NULL;
01375
01376                     }
01377                     return TRUE;
01378
01379                 case IDC_COMBO1:
01380           wp = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
01381                     l = SendMessage(hComboBox, CB_GETLBTEXTLEN, wp, (LPARAM) 0);
01382                     if (CELEMS(g_szEntryName) > l)
01383                     {
01384                         SendMessage(hComboBox, CB_GETLBTEXT, wp, (LPARAM) (LPCSTR) g_szEntryName);
01385                     }
01386                     else
01387                     {
01388                         return FALSE;
01389                     }
01390
01391                     return TRUE;
01392             }
01393             break;
01394     }
01395
01396     return FALSE;
01397 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_threadparameters Member List

This is the complete list of members for _threadparameters, including all inherited members.
hPrevThread | _threadparameters
hPrinter | _threadparameters
hWnd | _threadparameters
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CExecuteParamDlg Member List

This is the complete list of members for CExecuteParamDlg, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CExecuteParamDlg(CMDIChild *pCMDIChild) | CExecuteParamDlg |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CRowsetViewerDlg(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRowsetViewerDlg |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetActiveParam() | CExecuteParamDlg |
GetActiveValue() | CExecuteParamDlg |
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetOptions() | CRowsetViewerDlg | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCMainWindow | CRowsetViewerDlg |
m_pCMDIChild | CRowsetViewerDlg |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_tabParamSets | CExecuteParamDlg | [protected]
m_uIDD | CDialogLite |
m_vecParams | CExecuteParamDlg | [protected]
m_vecValues | CExecuteParamDlg | [protected]
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnAddParameter() | CExecuteParamDlg | [virtual]
OnAddSet(INDEX iParamSet, BOOL fUseDefaults=TRUE) | CExecuteParamDlg | [virtual]
OnCancel() | CExecuteParamDlg | [virtual]
CDialogLite::OnCancel() | CDialogLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CExecuteParamDlg | [virtual]
CDialogLite::OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CExecuteParamDlg | [virtual]
CDialogLite::OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDelParameter() | CExecuteParamDlg | [virtual]
OnDelSet(INDEX iParamSet) | CExecuteParamDlg | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CExecuteParamDlg | [virtual]
CDialogLite::OnInitDialog() | CDialogLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CExecuteParamDlg | [virtual]
CDialogLite::OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CExecuteParamDlg | [virtual]
CDialogLite::OnOK() | CDialogLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnStatusChange(DBSTATUS dbStatus) | CExecuteParamDlg | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/about.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

about.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Implementation of ISnapinAbout
00014 //
00015
00016
00017 #include "Globals.h"
00018 #include "About.h"
00019 #include "Resource.h"
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 //  Construction/Destruction
00023
00024 //---------------------------------------------------------------------------
00025 CSnapinAbout::CSnapinAbout()
00026 {
00027   m_cRef = 0;
00028   InterlockedIncrement((long*)&g_uObjectCount);
00029
00030   m_hSmallImage = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_16), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00031   m_hLargeImage = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_32), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00032
00033   // This image is displayed when the static node is selected
00034   m_hOpenImage  = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_16), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00035
00036   m_hAppIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_APP_ICON));
00037 }
00038
00039 CSnapinAbout::~CSnapinAbout()
00040 {
00041   SAFE_FREE_BITMAP( m_hSmallImage );
00042   SAFE_FREE_BITMAP( m_hLargeImage );
00043   SAFE_FREE_BITMAP( m_hOpenImage  );
00044   SAFE_FREE_ICON( m_hAppIcon );
00045
00046   InterlockedDecrement((long*)&g_uObjectCount);
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // IUnknown implementation
00051
00052 //---------------------------------------------------------------------------
00053 STDMETHODIMP CSnapinAbout::QueryInterface
00054 (
00055   REFIID   riid,       //[in] Identifier of the requested interface
00056   LPVOID   *ppv        //[out] Address of requested interface
00057 )
00058 {
00059   if( !ppv )
00060     return E_FAIL;
00061
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065     *ppv = static_cast<ISnapinAbout*>(this);
00066   else if( IsEqualIID(riid, IID_ISnapinAbout) )
00067     *ppv = static_cast<ISnapinAbout*>(this);
00068
00069   if( *ppv )
00070   {
00071     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00072     return S_OK;
00073   }
00074
00075   return E_NOINTERFACE;
00076 }
00077
00078 //---------------------------------------------------------------------------
00079 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00080 {
00081   return InterlockedIncrement((long*)&m_cRef);
00082 }
00083
00084 //---------------------------------------------------------------------------
00085 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00086 {
00087   if( 0 == InterlockedDecrement((long*)&m_cRef) )
00088   {
00089     // we need to decrement our object count in the DLL
00090     delete this;
00091     return 0;
00092   }
00093   return m_cRef;
00094 }
00095
00096
00097 /////////////////////////////////////////////////////////////////////////////
00098 // Interface ISnapinAbout
00099
00100 //---------------------------------------------------------------------------
00101 STDMETHODIMP CSnapinAbout::GetSnapinDescription
00102 (
00103   LPOLESTR* pszDescription   //[out] Pointer to the description text
00104 )
00105 {
00106   LONG nLen = wcslen( gwszABOUT_DESCRIPTION ) + 1;
00107   *pszDescription = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00108   if( NULL == *pszDescription )
00109     return E_OUTOFMEMORY;
00110
00111   wcscpy( *pszDescription, gwszABOUT_DESCRIPTION );
00112   return S_OK;
00113 }
00114
00115 //---------------------------------------------------------------------------
00116 STDMETHODIMP CSnapinAbout::GetProvider
00117 (
00118   LPOLESTR* pszProvider      //[out] Pointer to provider text
00119 )
00120 {
00121   LONG nLen = wcslen( gwszABOUT_PROVIDER ) + 1;
00122   *pszProvider = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00123   if( NULL == *pszProvider )
00124     return E_OUTOFMEMORY;
00125
00126   wcscpy( *pszProvider, gwszABOUT_PROVIDER );
00127   return S_OK;
00128 }
00129
00130 //---------------------------------------------------------------------------
00131 STDMETHODIMP CSnapinAbout::GetSnapinVersion
00132 (
00133   LPOLESTR*  pszVersion      //[out] Pointer to version text
00134 )
00135 {
00136   LONG nLen = wcslen( gwszABOUT_VERSION ) + 1;
00137   *pszVersion = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00138   if( NULL == *pszVersion )
00139     return E_OUTOFMEMORY;
00140
00141   wcscpy( *pszVersion, gwszABOUT_VERSION );
00142   return S_OK;
00143 }
00144
00145 //---------------------------------------------------------------------------
00146 STDMETHODIMP CSnapinAbout::GetSnapinImage
00147 (
00148   HICON *hAppIcon            //[out] Pointer to the Snap-in's main icon
00149 )
00150 {
00151   *hAppIcon = m_hAppIcon;
00152   HRESULT hResult = S_FALSE;
00153   (NULL == *hAppIcon ) ? hResult = E_FAIL : hResult = S_OK;
00154
00155   return hResult;
00156 }
00157
00158 //---------------------------------------------------------------------------
00159 STDMETHODIMP CSnapinAbout::GetStaticFolderImage
00160 (
00161   HBITMAP*   hSmallImage,      //[out] Pointer to small image
00162   HBITMAP*   hOpenImage,       //[out] Pointer to open folder image
00163   HBITMAP*   hLargeImage,      //[out] Pointer to large image
00164   COLORREF*  cMask             //[out] Pointer to image color mask
00165 )
00166 {
00167   *hSmallImage = m_hSmallImage;
00168   *hLargeImage = m_hLargeImage;
00169   *hOpenImage  = m_hOpenImage;
00170   *cMask       = RGB(0, 255, 0);
00171
00172   if( NULL == *hSmallImage || NULL == *hLargeImage || NULL == *hOpenImage )
00173     return E_FAIL;
00174
00175   return S_OK;
00176 }
00177
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/NewsEvent/newsEventClass/INewsEventDefault.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • NewsEvent
  • newsEventClass

INewsEventDefault.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc147.tmp" /nologo /d "D:\ComPlusSamples\Source\LCE\NewsEvent" "D:\ComPlusSamples\Source\LCE\NewsEvent\NewsEventClass.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package newseventclass;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface INewsEventDefault
00019 /** @com.interface(iid=00020400-0000-0000-C000-000000000046, thread=AUTO, type=DUAL) */
00020 public interface INewsEventDefault extends newseventclass.INewsEvent
00021 {
00022   /** @com.method(vtoffset=4, dispid=1, type=METHOD, name="NewsFlash", addFlagsVtable=4)
00023       @com.parameters([in,type=DATE] dtTimeStamp, [in,type=STRING] Symbol, [in,type=STRING] Headline, [in,type=STRING] URL) */
00024   public void NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL);
00025
00026   /** @com.method(vtoffset=5, dispid=2, type=METHOD, name="ShortQuote", addFlagsVtable=4)
00027       @com.parameters([in,type=STRING] Symbol, [in,type=R8] BidPrice, [in,type=R8] AskPrice, [in,type=DATE] LastTradeTime, [in,type=R8] LastTradePrice, [in,type=R8] NetChange, [in,type=R8] DailyHigh, [in,type=R8] DailyLow) */
00028   public void ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow);
00029
00030   /** @com.method(vtoffset=6, dispid=3, type=METHOD, name="LongQuote", addFlagsVtable=4)
00031       @com.parameters([in,type=STRING] Symbol, [in,type=R8] BidPrice, [in,type=R8] AskPrice, [in,type=STRING] LastTradeTime, [in,type=R8] LastTradePrice, [in,type=R8] NetChange, [in,type=R8] DailyHigh, [in,type=R8] DailyLow, [in,type=I4] AskSize, [in,type=I4] BidSize, [in,type=R8] OpenPrice, [in,type=R8] ClosePrice, [in,type=STRING] CloseDate) */
00032   public void LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate);
00033
00034
00035   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x20400, (short)0x0, (short)0x0, (byte)0xc0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x46);
00036 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDlgIADsSecurityDescriptor Member List

This is the complete list of members for CDlgIADsSecurityDescriptor, including all inherited members.
CDlgIADsSecurityDescriptor(LPUNKNOWN, CWnd *pParent=NULL) | CDlgIADsSecurityDescriptor |
DisplayACE(IADsAccessControlEntry *pACE) | CDlgIADsSecurityDescriptor | [protected]
DisplayAceObjectType(UINT nID, CString &sObjectType) | CDlgIADsSecurityDescriptor | [protected]
DoDataExchange(CDataExchange *pDX) | CDlgIADsSecurityDescriptor | [protected, virtual]
IDD enum value | CDlgIADsSecurityDescriptor |
m_acePtrList | CDlgIADsSecurityDescriptor | [protected]
m_cACEList | CDlgIADsSecurityDescriptor |
m_pSecurityDesc | CDlgIADsSecurityDescriptor | [protected]
m_search | CDlgIADsSecurityDescriptor | [protected]
OnInitDialog() | CDlgIADsSecurityDescriptor | [protected, virtual]
OnSelChangeAceList() | CDlgIADsSecurityDescriptor | [protected]
PopulateACL(IADsAccessControlList *pACL) | CDlgIADsSecurityDescriptor | [protected]
ResetAceMaskControls() | CDlgIADsSecurityDescriptor | [protected]
ResetAcePtr() | CDlgIADsSecurityDescriptor | [protected]
~CDlgIADsSecurityDescriptor() | CDlgIADsSecurityDescriptor |
Generated on Wed Nov 13 2024 16:56:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/StdAfx.Cpp Source File

  • Com
  • Services
  • Crm
  • CrmFiles

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ISnap Member List

This is the complete list of members for ISnap, including all inherited members.
GetSnapOn(LONG *lIsOn) | ISnap
GetSnapOn(LONG *lIsOn) | ISnap
SetSnapOn(LONG lIsOn) | ISnap
SetSnapOn(LONG lIsOn) | ISnap
SnapIncrement([out, retval] long *pVal) | ISnap
SnapIncrement([in] long newVal) | ISnap
SnapOn([out, retval] BOOL *pVal) | ISnap
SnapOn([in] BOOL newVal) | ISnap
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/selectEventsDlg.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

selectEventsDlg.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include <comsvcs.h>
00019 #include <comadmin.h>
00020
00021 #include "ComSpyCtl.h"
00022 #include "ComSpyAudit.h"
00023
00024 #include "CComSpy.h"
00025 #include "AppInfo.h"
00026 #include "SelectEventsDlg.h"
00027 #include <algorithm>
00028 #include <comdef.h>   // For _bstr_t and _variant_t
00029
00030
00031 // A simple macro used to set the checked state of a ListView item.
00032 #ifndef ListView_SetCheckState
00033    #define ListView_SetCheckState(hwndLV, i, fCheck) \
00034       ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck)+1),\
00035                     LVIS_STATEIMAGEMASK)
00036 #endif
00037
00038
00039 // #DEFINES
00040 #define MAX_APPNAME_SIZE 256
00041
00042
00043 // CONSTANTS
00044 const _bstr_t g_bstrAllApps(_T("All Applications"));
00045 const _bstr_t g_bstrAppType_Application(_T("Application:"));
00046 const _bstr_t g_bstrAppType_Process(_T("Process:"));
00047
00048
00049 // TYPEDEFS
00050 typedef struct _EVENT_SINK_INFO
00051 {
00052   TCHAR * sDisplayName;
00053   EventEnum eEvent;
00054 } EVENT_SINK_INFO;
00055
00056
00057 // Module level EventInfo array containing all possible Publishing
00058 // interfaces from COM+.
00059 EVENT_SINK_INFO EventInfo[] =
00060 {
00061   _T("Activity"),   Activity,
00062   _T("Object Pool"),  ObjectPool,
00063   _T("Pool Mgmt"),  ObjectPool2,
00064   _T("Application"),  Application,
00065   _T("Construction"), ObjectConstruction,
00066   _T("Thread"),   Thread,
00067   _T("Instance"),   Instance,
00068   _T("Transaction"),  Transaction,
00069   _T("Method"),   Method,
00070   _T("Object"),   Object,
00071   _T("Resource"),   Resource,
00072   _T("UserDefined"),  User,
00073   _T("Security"),   Security,
00074   _T("Identity"),   Identity,
00075   _T("Queued"),   QC,
00076   _T("Exception"),  Exception,
00077   _T("CRM"),      CRM,
00078 };
00079
00080 //System events
00081 EVENT_SINK_INFO SystemEventInfo[] =
00082 {
00083   _T("Event Store"),  EventStore,
00084   _T("Load Balancing"), LoadBalancing,
00085 };
00086
00087
00088 // -----------------------------------------------------------------------------
00089 // Method:  CSelectEventsDlg::CSelectEventsDlg(...)
00090 // Params:  spMap:      Pointer to a MapStringToAppInfo that contains a STL
00091 //              map of all CAppInfo structures and their names.
00092 //              Each CAppInfo manages the events it subscribes to.
00093 //      pSysAppInfo:  Pointer to AppInfo that manages the system events it
00094 //              subscribe to. Should have only one instance per COM+ system.
00095 //      pSpyObj:    Polymorphic pointer to the CComSpy-derived subscription
00096 //              object for various COM+ Events.
00097 // Returns: (None)
00098 // Purpose: Parameterized Constructor for the CSelectEventsDlg class.
00099 // -----------------------------------------------------------------------------
00100 CSelectEventsDlg::CSelectEventsDlg(MapStringToAppInfo* spMap, CAppInfo * pSysAppInfo, CComSpy* pSpyObj)
00101 {
00102   m_map = spMap;
00103   m_pSysAppInfo = pSysAppInfo;
00104   m_pSpyObj = pSpyObj;
00105 }
00106
00107
00108
00109 // -----------------------------------------------------------------------------
00110 // Method:  CSelectEventsDlg::OnInitDialog(...)
00111 // Params:  All params are standard for ATL's MESSAGE_HANDLER mapping.
00112 // Returns: Always 1 to ensure that the system sets focus
00113 // Purpose: Called when Dialog sends WM_INITDIALOG message.  Does following:
00114 //        1. Modifies the ListView to add CheckBox support.
00115 //        2. Sets the Delete flag on all current Applications.
00116 //        3. Gets a list of all Apps from the Catalog.
00117 //        4. Gets a list of all running apps from COM+.
00118 //        5. Fill the Event ListView with the available events.
00119 //        6. Create the special AllApps object if necessary.
00120 //        7. Parse the list of apps and delete those with Delete flag True
00121 //        8. Select the first row in the Apps List Box.
00122 //        9. Update the Event checkboxes for the current App or AllApps
00123 // -----------------------------------------------------------------------------
00124 LRESULT CSelectEventsDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam,
00125                           BOOL& bHandled)
00126 {
00127   // Set the window to have Check Box support.
00128   ListView_SetExtendedListViewStyle(GetDlgItem(IDC_LISTVIEWEVENTS), LVS_EX_CHECKBOXES);
00129
00130
00131   ListView_SetExtendedListViewStyle(GetDlgItem(IDC_LISTVIEWSYSEVENTS), LVS_EX_CHECKBOXES);
00132
00133   // Mark all Apps as ready for deletion until proven otherwise.
00134   MarkAllAppsForDelete(false);
00135
00136   // Now populate the current Catalog applications.
00137   GetCatalogApps();
00138
00139   // Now populate the current Running applications.
00140   GetRunningApps();
00141
00142   // Populate the list of possible App events.
00143   PopulateEventList();
00144
00145   //Populate the list of possible system events.
00146   PopulateSysEventList();
00147
00148   // Now create the AllApps CAppInfo.
00149   CAppInfo* pInfo = (*m_map)[(char*)g_bstrAllApps];
00150   if (!pInfo)
00151   {
00152     pInfo = new CAppInfo((TCHAR*)g_bstrAllApps, m_pSpyObj);
00153     (*m_map)[(char*)g_bstrAllApps] = pInfo;
00154   }
00155   else
00156     pInfo->SetDeleteFlag(false);
00157
00158   // Do garbage collection on the apps that are no longer valid.
00159   MarkAllAppsForDelete(true);
00160
00161   // Select the first Application in the listbox.
00162   SendDlgItemMessage(IDC_LIST_APPS, LB_SETCURSEL, 0);
00163
00164   // If they are using any event in the special AllApps object, then display
00165   // the check box and disable the ListBox.
00166   if (pInfo->IsSubscribedToAny())
00167   {
00168     CheckDlgButton(IDC_CHECK_ALLAPPS, 1);
00169     SelectAllApps(true);
00170   }
00171   else
00172     SelectApplication(0);
00173
00174   ShowSelectedSystemEvents();
00175
00176   return 1;
00177 }
00178
00179
00180
00181 // -----------------------------------------------------------------------------
00182 // Method:  CSelectEventsDlg::OnOK(...)
00183 // Params:  All params for the standard ATL COMMAND_ID_HANDLER map.
00184 // Returns: Returns 0 always.
00185 // Purpose: Handler for the OK button.  Simply ends the Dialog.
00186 // -----------------------------------------------------------------------------
00187 LRESULT CSelectEventsDlg::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl,
00188                  BOOL& bHandled)
00189 {
00190   EndDialog(wID);
00191   return 0;
00192 }
00193
00194
00195
00196 // -----------------------------------------------------------------------------
00197 // Method:  CSelectEventsDlg::OnDestroyDlg(...)
00198 // Params:  All params for the standard ATL COMMAND_ID_HANDLER map.
00199 // Returns: Returns 0 always.
00200 // Purpose: Handler for the Destory Window message.  Ends the Dialog.
00201 // -----------------------------------------------------------------------------
00202 LRESULT CSelectEventsDlg::OnDestroyDlg(UINT uMsg, WPARAM wParam,
00203                           LPARAM lParam, BOOL& bHandled)
00204 {
00205   bHandled = FALSE;
00206   return 0;
00207 }
00208
00209
00210
00211 // -----------------------------------------------------------------------------
00212 // Method:  CSelectEventsDlg::MarkAllAppsForDelete()
00213 // Params:  bDeleteUnused: If true, this will actually delete the CAppInfo
00214 //                  instances with the delete flag set.
00215 // Returns: (None)
00216 // Purpose: To iterate through the STL map of applications and to set the delete
00217 //        flag for each one. Every app that is later found again will be
00218 //        cleared. Finally, the ones remaining will be garbaged.
00219 // -----------------------------------------------------------------------------
00220 void CSelectEventsDlg::MarkAllAppsForDelete(bool bDeleteUnused)
00221 {
00222   MapStringToAppInfo::iterator item;
00223   CAppInfo * pInfo = NULL;
00224
00225   item = m_map->begin();
00226   while (item != m_map->end())
00227   {
00228     pInfo = (*item).second;
00229     _ASSERTE(pInfo);
00230
00231     // If Delete Unsued flag is set, we purge.
00232     if (bDeleteUnused)
00233     {
00234       if (pInfo->IsReadyForDelete())
00235       {
00236         delete pInfo;
00237         item = m_map->erase(item);
00238       }
00239       else
00240       {
00241         item++;
00242       }
00243     }
00244     else // We just set everything to delete.
00245     {
00246       pInfo->SetDeleteFlag(true);
00247       item++;
00248     };
00249   };
00250 //for (item = m_map->begin(); item != m_map->end(); ++item)
00251 }
00252
00253
00254
00255 // -----------------------------------------------------------------------------
00256 // Method:  CSelectEventsDlg::GetCatalogApps()
00257 // Params:  (None)
00258 // Returns: True if successfully added the apps, otherwise False.
00259 //  Purpose:  To list all COM+ apps in the Catalog, create a CAppInfo for each
00260 //        one that does not yet exist, add the AppName to the list box, and
00261 //        add the new app to the Application MAP.
00262 // Steps: 1. Get a reference to the COMAdminCatalog object.
00263 //        2. Get it to get "Applications" Collection as ICatalogCollection.
00264 //        3. Populate() the collection to actually retrieve the data.
00265 //        4. Iterate through the collection for every Item (ICatalogObject)
00266 //        5. Use the interface to pull AppName, AppID (guid), etc.
00267 //        6. If necessary, create a new CAppInfo object for this instance.
00268 //          and add it to the global m_map STL MAP.
00269 //        7. Set the Delete flag for the app to False (it still exists).
00270 //        8. Add the App name to the App ListBox control.
00271 //        9. Clean up references and get out.
00272 // -----------------------------------------------------------------------------
00273 bool CSelectEventsDlg::GetCatalogApps()
00274 {
00275   USES_CONVERSION;
00276
00277   HRESULT hr = E_FAIL;
00278   ICOMAdminCatalog* pCOMAdminCatalog = NULL;
00279   IDispatch* pDisp;
00280   ICatalogCollection* pCatalogCollection = NULL;
00281   ICatalogObject* pCatalog = NULL;
00282   CComBSTR bstrApplications("Applications");
00283
00284   hr = CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_ALL,
00285                          IID_ICOMAdminCatalog, (void **)&pCOMAdminCatalog);
00286   if (hr || (!pCOMAdminCatalog))
00287   {
00288     _ASSERTE(0);
00289     return false;
00290   }
00291
00292   hr = pCOMAdminCatalog->GetCollection(bstrApplications, &pDisp);
00293   if (hr || (!pDisp))
00294   {
00295     _ASSERTE(0);
00296     return false;
00297   }
00298   SafeRelease(pCOMAdminCatalog);
00299
00300   hr = pDisp->QueryInterface(IID_ICatalogCollection,
00301                  (void **)&pCatalogCollection);
00302   if (hr || (!pCatalogCollection))
00303   {
00304     _ASSERTE(0);
00305     return false;
00306   }
00307   SafeRelease(pDisp);
00308
00309   // Populate the Catalog collection.  The collection is empty
00310   //  until this is called.
00311   hr = pCatalogCollection->Populate();
00312   if (hr)
00313   {
00314     _ASSERTE(0);
00315     return false;
00316   }
00317
00318   // Now we can iterate through the Catalog apps.
00319   long lApplications;
00320   int dIndex;
00321   pCatalogCollection->get_Count(&lApplications);
00322   for (int i = 0; i < lApplications; i++)
00323   {
00324     pDisp = NULL;
00325     pCatalog = NULL;
00326
00327     // Get the next Catalog in the collection.
00328     pCatalogCollection->get_Item(i, &pDisp);
00329     if (pDisp) pDisp->QueryInterface(IID_ICatalogObject,
00330                      (void **)&pCatalog);
00331
00332     // Get the Application name into a _bstr_t from the Catalog
00333     // object for easier conversion.
00334     _variant_t vName;
00335     if (pCatalog) pCatalog->get_Name(&vName);
00336     _bstr_t sName = vName;
00337     LPSTR p = (char*)sName;
00338     _variant_t vKey;
00339     if (pCatalog) pCatalog->get_Key(&vKey);
00340     _bstr_t sKey = vKey;
00341
00342     // Now get the pointer to the CAppInfo for this one.
00343     CAppInfo * pInfo = NULL;
00344     pInfo = (*m_map)[p];
00345     if (!pInfo)
00346     {
00347       pInfo = new CAppInfo((TCHAR*)sName, m_pSpyObj, (TCHAR*)sKey);
00348       _ASSERTE(pInfo);
00349       (*m_map)[p] = pInfo;
00350     };
00351
00352     // Ensure we don't delete this app during Garbage Collection.
00353     pInfo->SetDeleteFlag(false);
00354
00355     // Add the item to the List Box.
00356     dIndex = SendDlgItemMessage(IDC_LIST_APPS, LB_ADDSTRING,
00357                   0, (LPARAM)(TCHAR*)sName);
00358     SafeRelease(pDisp);
00359     SafeRelease(pCatalog);
00360   };
00361   SafeRelease(pCatalogCollection);
00362
00363   return true;
00364 };
00365
00366
00367
00368 // -----------------------------------------------------------------------------
00369 // Method:  CSelectEventsDlg::GetRunningApps()
00370 // Params:  (None)
00371 // Returns: True if successfully added the apps, False otherwise.
00372 // Purpose: To iterate through the currently running COM+ processes.  This can
00373 //        be either standard Applications or other processes via Libraries.
00374 //        For each new Process, create a CAppInfo object for it and add it
00375 //        to the Application MAP.  Also, add the name to App ListBox.
00376 // Steps: 1. Get a reference to the MtsGrp object.
00377 //        2. Get count of active applications.
00378 //        3. For every app, get a IUnknown pointer to it.
00379 //        4. QI for IMtsEvents to pull AppName, AppID (guid), etc.
00380 //        5. If necessary, create a new CAppInfo object for this instance.
00381 //          and add it to the global m_map STL MAP.
00382 //        6. Set the Delete flag for the app to False (it still exists).
00383 //        7. Add the App name to the App ListBox control.
00384 //        8. Clean up references and get out.
00385 // -----------------------------------------------------------------------------
00386 bool CSelectEventsDlg::GetRunningApps()
00387 {
00388   USES_CONVERSION;
00389
00390   long lApplications;
00391   int dIndex;
00392   HRESULT hr = E_FAIL;
00393   IMtsGrp * pMtsGrp = NULL;
00394   IUnknown * pUnk = NULL;
00395   IMtsEvents * pEvents = NULL;
00396
00397   hr = CoCreateInstance (CLSID_MtsGrp, NULL, CLSCTX_ALL, IID_IMtsGrp, (void **)&pMtsGrp);
00398   if (!pMtsGrp)
00399   {
00400     return false;
00401   }
00402
00403   pMtsGrp->get_Count(&lApplications);
00404
00405   // For each running Application, get the name and stuff it in LB.
00406   for (int i=0; i < lApplications; i++)
00407   {
00408     pMtsGrp->Item(i, &pUnk);
00409     pEvents = NULL;
00410
00411     if (pUnk) pUnk->QueryInterface(IID_IMtsEvents, (void **)&pEvents);
00412     _ASSERTE(pEvents);
00413
00414     // Get the Application name into a _bstr_t for easier conversion.
00415     CComBSTR sName;
00416     CAppInfo * pInfo = NULL;
00417     long lPID;
00418     if (pEvents) pEvents->get_PackageName(&sName);
00419     if (pEvents) pEvents->GetProcessID(&lPID);
00420     _bstr_t bstrApplicationName((BSTR)sName);
00421
00422     // Now get the pointer to the CAppInfo for this one.
00423     TCHAR szExtendedName[255];
00424     wsprintf( szExtendedName, _T(" [PID=%d (0x%08X)]"), lPID, lPID);
00425     bstrApplicationName += szExtendedName;
00426     LPSTR p = (char*)bstrApplicationName;
00427     pInfo = (*m_map)[p];
00428     if (!pInfo)
00429     {
00430       pInfo = new CAppInfo((TCHAR*)bstrApplicationName, m_pSpyObj, lPID);
00431       _ASSERTE(pInfo);
00432       (*m_map)[p] = pInfo;
00433     };
00434
00435     // Ensure we don't delete this app during Garbage Collection.
00436     pInfo->SetDeleteFlag(false);
00437
00438     // Add the AppName (with PID info) to the Apps ListBox.
00439     dIndex = SendDlgItemMessage(IDC_LIST_APPS, LB_ADDSTRING, 0,
00440                        (LPARAM)((TCHAR*)bstrApplicationName));
00441
00442     SafeRelease(pEvents);
00443     SafeRelease(pUnk);
00444   }
00445
00446   SafeRelease(pMtsGrp);
00447
00448   return true;
00449 };
00450
00451
00452
00453 // -----------------------------------------------------------------------------
00454 // Method:  CSelectEventsDlg::PopulateEventList()
00455 // Params:  (None)
00456 // Returns: (None)
00457 // Purpose: Empties and then fills the Event ListView with possible events.
00458 //        All events are set to non-checked initially.  This basically uses
00459 //        some macros to insert into the ListView.
00460 // -----------------------------------------------------------------------------
00461 void CSelectEventsDlg::PopulateEventList()
00462 {
00463   LVITEM lvItem;
00464   int nIndex;
00465   int i;
00466   HWND  hEvents = GetDlgItem(IDC_LISTVIEWEVENTS);
00467
00468   lvItem.state = 0;
00469   lvItem.iItem = 0;
00470   lvItem.stateMask = 0;
00471   lvItem.mask = LVIF_TEXT | LVIF_PARAM;
00472   lvItem.iSubItem = 0;
00473
00474   // fill the Possible Events list
00475   for (i = 0; i < sizeof(EventInfo)/sizeof(EventInfo[0]); i++)
00476   {
00477     lvItem.pszText = EventInfo[i].sDisplayName;
00478     lvItem.lParam = (long)EventInfo[i].eEvent;
00479     lvItem.mask = LVIF_TEXT | LVIF_PARAM;
00480     nIndex = ListView_InsertItem(hEvents, &lvItem);
00481   }
00482 }
00483
00484
00485
00486 // -----------------------------------------------------------------------------
00487 // Method:  CSelectEventsDlg::PopulateSysEventList()
00488 // Params:  (None)
00489 // Returns: (None)
00490 // Purpose: Empties and then fills the System Event ListView with possible system events.
00491 //      All events are set to non-checked initially.  This basically uses
00492 //      some macros to insert into the ListView.
00493 // -----------------------------------------------------------------------------
00494 void CSelectEventsDlg::PopulateSysEventList()
00495 {
00496
00497   LVITEM lvItem;
00498   int nIndex;
00499   int i;
00500
00501   HWND  hSysEvents = GetDlgItem(IDC_LISTVIEWSYSEVENTS);
00502
00503   lvItem.state = 0;
00504   lvItem.iItem = 0;
00505   lvItem.stateMask = 0;
00506   lvItem.mask = LVIF_TEXT | LVIF_PARAM;
00507   lvItem.iSubItem = 0;
00508
00509   //fill the possilbe System Events list
00510   for (i = 0; i < sizeof(SystemEventInfo)/sizeof(SystemEventInfo[0]); i++)
00511   {
00512     lvItem.pszText = SystemEventInfo[i].sDisplayName;
00513     lvItem.lParam = (long)SystemEventInfo[i].eEvent;
00514     lvItem.mask = LVIF_TEXT | LVIF_PARAM;
00515     nIndex = ListView_InsertItem(hSysEvents, &lvItem);
00516   }
00517
00518 }
00519
00520
00521 // -----------------------------------------------------------------------------
00522 // Method:  CSelectEventsDlg::AppsListHandler(...)
00523 // Params:  All params for the standard ATL COMMAND_ID_HANDLER map.
00524 // Returns: Always returns 0
00525 // Purpose: If the Selection was changed, then update the GUI to display events
00526 //        for the new Application.  Also, this may take some time so we need
00527 //        to throw up the HourGlass.
00528 // -----------------------------------------------------------------------------
00529 LRESULT CSelectEventsDlg::AppsListHandler(WORD wNotifyCode, WORD wID,
00530                             HWND hWndCtl, BOOL& bHandled)
00531 {
00532   bool bResult;
00533   int nIndex;
00534   HCURSOR hOldCursor;
00535   switch(wNotifyCode)
00536   {
00537   case LBN_SELCHANGE:
00538     hOldCursor = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
00539     nIndex = SendDlgItemMessage(IDC_LIST_APPS, LB_GETCURSEL, 0, (LPARAM)0);
00540     bResult = SelectApplication(nIndex); // See below...
00541     ::SetCursor(hOldCursor);
00542     break;
00543   default:
00544     break;
00545   };
00546   bHandled = TRUE;
00547   return 0;
00548 }
00549
00550
00551
00552 // -----------------------------------------------------------------------------
00553 // Method:  CSelectEventsDlg::OnSelectAllApps(...)
00554 // Params:  Standard COMMAND_HANDLER() params.
00555 // Returns: 0 always.
00556 // Purpose: Handle the toggling of the checkbox for Selecting All Apps.
00557 // -----------------------------------------------------------------------------
00558 LRESULT CSelectEventsDlg::OnSelectAllApps(WORD wNotifyCode, WORD wID,
00559                             HWND hWndCtl, BOOL& bHandled)
00560 {
00561   UINT nChecked = IsDlgButtonChecked(IDC_CHECK_ALLAPPS);
00562   bool bResult = SelectAllApps(nChecked ? true : false);
00563   return 0;
00564 };
00565
00566
00567
00568 // -----------------------------------------------------------------------------
00569 // Method:  CSelectEventsDlg::SelectAllApps()
00570 // Params:  bSelectAll: True says to SelectAll, False says Un-Select All.
00571 // Returns: True always.
00572 // Purpose: Handle the toggling of the checkbox for Selecting All Apps.
00573 //        If the checkbox is set, then we do the following:
00574 //        1. Remove all Subscriptions for every App (expect AllApps object).
00575 //        2. Disable Apps ListBox and update the static text caption.
00576 //        3. Show current event mapping for the AllApps object.
00577 //        In the Un-Select case, we simply reverse this. We also use
00578 //        Hourglass because this can take some time.
00579 // -----------------------------------------------------------------------------
00580 bool CSelectEventsDlg::SelectAllApps(bool bSelectAll)
00581 {
00582   CAppInfo* pAllAppsInfo = (*m_map)[(char*)g_bstrAllApps];
00583
00584   // Modify the cursor.
00585   HCURSOR hOldCursor = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
00586
00587   // Now remove all events for every app.
00588   MapStringToAppInfo::iterator item;
00589   CAppInfo* pAppInfo;
00590   for (item = m_map->begin(); item != m_map->end(); ++item)
00591   {
00592     pAppInfo = (*item).second;
00593     if ((pAppInfo) && (pAppInfo != pAllAppsInfo))
00594       pAppInfo->RemoveAllSubscriptions();
00595   };
00596
00597   if (!bSelectAll)
00598   {
00599     ::EnableWindow(GetDlgItem(IDC_LIST_APPS), TRUE);
00600     int nItem = SendDlgItemMessage(IDC_LIST_APPS, LB_GETCURSEL, 0, 0);
00601     // Since we are unselecting AllApps, we need to remove its subscriptions
00602     pAllAppsInfo->RemoveAllSubscriptions();
00603     bool bResult = SelectApplication(nItem);
00604   }
00605   else
00606   {
00607     ::EnableWindow(GetDlgItem(IDC_LIST_APPS), FALSE);
00608     SetDlgItemText(IDC_STATIC_CURRENTAPP, (TCHAR*)g_bstrAllApps);
00609   };
00610
00611   // Re-fresh the event list for this CAppInfo
00612   ShowSelectedEvents((*m_map)[(char*)g_bstrAllApps]);
00613
00614   // Update the static text for the application type.
00615   SetDlgItemText(IDC_STATIC_TYPE, (TCHAR*)g_bstrAppType_Application);
00616
00617   ::SetCursor(hOldCursor);
00618   return true;
00619 };
00620
00621
00622
00623 // -----------------------------------------------------------------------------
00624 // Method:  CSelectEventsDlg::LVEventItemChanged(...)
00625 // Params:  All params for the standard ATL COMMAND_ID_HANDLER map.
00626 // Returns: Always returns 0
00627 // Purpose:
00628 // -----------------------------------------------------------------------------
00629 LRESULT CSelectEventsDlg::LVEventItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
00630 {
00631   NM_LISTVIEW* pnmList = (NM_LISTVIEW*)pnmh;
00632   LVITEM lvItem;
00633   BOOL bResult;
00634   TCHAR sz[MAX_APPNAME_SIZE];
00635
00636   UINT nItemNumber = pnmList->iItem;
00637   UINT nCurrentState = pnmList->uNewState;
00638   UINT nOldState = pnmList->uOldState;
00639
00640   lvItem.iItem = nItemNumber;
00641   lvItem.iSubItem = 0;
00642   lvItem.mask = LVIF_PARAM;
00643   memset(&sz[0], NULL, MAX_APPNAME_SIZE * sizeof(TCHAR));
00644
00645   // If we toggled check box state, do this.
00646   if (((nCurrentState & 8192) && (nOldState & 4096)) ||
00647      ((nOldState & 8192) && (nCurrentState & 4096)))
00648   {
00649     EventEnum nEvent;
00650     bResult = ListView_GetItem(GetDlgItem(IDC_LISTVIEWEVENTS), &lvItem);
00651     _ASSERTE(bResult);
00652     nEvent = (EventEnum)lvItem.lParam;
00653
00654     // Get App Name.  If Checkbox enabled, then use the AllApps string.
00655     if (IsDlgButtonChecked(IDC_CHECK_ALLAPPS) == 0)
00656     {
00657       int nAppIndex = SendDlgItemMessage(IDC_LIST_APPS, LB_GETCURSEL, 0, (LPARAM)0);
00658       SendDlgItemMessage(IDC_LIST_APPS, LB_GETTEXT, nAppIndex, (LPARAM)sz);
00659     }
00660     else
00661       _tcsncpy(sz, (TCHAR*)g_bstrAllApps, _tcslen(g_bstrAllApps));
00662
00663     CAppInfo * pInfo = NULL;
00664     _bstr_t bstrApplicationName(sz);
00665     LPSTR p = (char*)bstrApplicationName;
00666     pInfo = (*m_map)[p];
00667     _ASSERTE(pInfo);
00668
00669     // If we have checked a previously unchecked box, do this:
00670     if ((nCurrentState & 8192) && (nOldState & 4096))
00671     {
00672       // Install this event handler.
00673       if (!pInfo->IsSubscribed(nEvent))
00674       {
00675         HCURSOR hOldCursor = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
00676         bResult = pInfo->AddSubscription(nEvent);
00677         ::SetCursor(hOldCursor);
00678       };
00679     }
00680     else if ((nOldState & 8192) && (nCurrentState & 4096))
00681     {
00682       // Remove this event handler.
00683       if (pInfo->IsSubscribed(nEvent))
00684       {
00685         HCURSOR hOldCursor = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
00686         bResult = pInfo->RemoveSubscription(nEvent);
00687         ::SetCursor(hOldCursor);
00688       };
00689     }
00690   };
00691
00692   return 0;
00693 };
00694
00695
00696 // -----------------------------------------------------------------------------
00697 // Method:  CSelectEventsDlg::LVSystemEventItemChanged(...)
00698 // Params:  All params for the standard ATL COMMAND_ID_HANDLER map.
00699 // Returns: Always returns 0
00700 // Purpose:
00701 // -----------------------------------------------------------------------------
00702 LRESULT CSelectEventsDlg::LVSystemEventItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
00703 {
00704   NM_LISTVIEW* pnmList = (NM_LISTVIEW*)pnmh;
00705   LVITEM lvItem;
00706   BOOL bResult;
00707   TCHAR sz[MAX_APPNAME_SIZE];
00708
00709   UINT nItemNumber = pnmList->iItem;
00710   UINT nCurrentState = pnmList->uNewState;
00711   UINT nOldState = pnmList->uOldState;
00712
00713   lvItem.iItem = nItemNumber;
00714   lvItem.iSubItem = 0;
00715   lvItem.mask = LVIF_PARAM;
00716   memset(&sz[0], NULL, MAX_APPNAME_SIZE * sizeof(TCHAR));
00717
00718   // If we toggled check box state, do this.
00719   if (((nCurrentState & 8192) && (nOldState & 4096)) ||
00720      ((nOldState & 8192) && (nCurrentState & 4096)))
00721   {
00722     EventEnum nEvent;
00723     bResult = ListView_GetItem(GetDlgItem(IDC_LISTVIEWSYSEVENTS), &lvItem);
00724     _ASSERTE(bResult);
00725     nEvent = (EventEnum)lvItem.lParam;
00726
00727     // If we have checked a previously unchecked box, do this:
00728     if ((nCurrentState & 8192) && (nOldState & 4096))
00729     {
00730       // Install this event handler.
00731       if (!m_pSysAppInfo->IsSubscribed(nEvent))
00732       {
00733         HCURSOR hOldCursor = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
00734         bResult = m_pSysAppInfo->AddSubscription(nEvent);
00735         ::SetCursor(hOldCursor);
00736       };
00737     }
00738     else if ((nOldState & 8192) && (nCurrentState & 4096))
00739     {
00740       // Remove this event handler.
00741       if (m_pSysAppInfo->IsSubscribed(nEvent))
00742       {
00743         HCURSOR hOldCursor = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
00744         bResult = m_pSysAppInfo->RemoveSubscription(nEvent);
00745         ::SetCursor(hOldCursor);
00746       };
00747     }
00748   };
00749
00750   return 0;
00751 };
00752
00753
00754 // -----------------------------------------------------------------------------
00755 // Method:  CSelectEventsDlg::ShowSelectedEvents(...)
00756 // Params:  pInfo: Pointer to the CAppInfo object to display.
00757 // Returns: (None)
00758 // Purpose: This will update the Event ListView for the specified CAppInfo
00759 //        object, based on the subscriptions the object contains.
00760 // -----------------------------------------------------------------------------
00761 void CSelectEventsDlg::ShowSelectedEvents(CAppInfo* pInfo)
00762 {
00763   _ASSERTE(pInfo);
00764   LVITEM lvItem;
00765   BOOL bResult;
00766   bool bIsChecked;
00767   EventEnum nEvent;
00768
00769   lvItem.iSubItem = 0;
00770   lvItem.mask = LVIF_PARAM; // Get the the EventEnum value from lParam.
00771
00772   for (int i = 0; i < sizeof(EventInfo)/sizeof(EventInfo[0]); i++)
00773   {
00774     // First, get the EventEnum for this item.
00775     lvItem.iItem = i;
00776     bResult = ListView_GetItem(GetDlgItem(IDC_LISTVIEWEVENTS), &lvItem);
00777     _ASSERTE(bResult);
00778     nEvent = (EventEnum)lvItem.lParam;
00779
00780     // Now determine whether or not it should be checked.
00781     bIsChecked = pInfo->IsSubscribed(nEvent);
00782
00783     // Next, update the ListView accordingly.
00784     ListView_SetCheckState(GetDlgItem(IDC_LISTVIEWEVENTS), i, bIsChecked);
00785   };
00786 };
00787
00788
00789 // -----------------------------------------------------------------------------
00790 // Method:  CSelectEventsDlg::ShowSelectedSystemEvents(...)
00791 // Returns: (None)
00792 // Purpose: This will update the System Event ListView based on the
00793 //      subscriptions of the object that m_pSysAppInfo points to contains.
00794 // -----------------------------------------------------------------------------
00795 void CSelectEventsDlg::ShowSelectedSystemEvents()
00796 {
00797   _ASSERTE(m_pSysAppInfo);
00798   LVITEM lvItem;
00799   BOOL bResult;
00800   bool bIsChecked;
00801   EventEnum nEvent;
00802
00803   lvItem.iSubItem = 0;
00804   lvItem.mask = LVIF_PARAM; // Get the the EventEnum value from lParam.
00805
00806   for (int i = 0; i < sizeof(SystemEventInfo)/sizeof(SystemEventInfo[0]); i++)
00807   {
00808     // First, get the EventEnum for this item.
00809     lvItem.iItem = i;
00810     bResult = ListView_GetItem(GetDlgItem(IDC_LISTVIEWSYSEVENTS), &lvItem);
00811     _ASSERTE(bResult);
00812     nEvent = (EventEnum)lvItem.lParam;
00813
00814     // Now determine whether or not it should be checked.
00815     bIsChecked = m_pSysAppInfo->IsSubscribed(nEvent);
00816
00817     // Next, update the ListView accordingly.
00818     ListView_SetCheckState(GetDlgItem(IDC_LISTVIEWSYSEVENTS), i, bIsChecked);
00819   };
00820 };
00821
00822
00823 // -----------------------------------------------------------------------------
00824 // Method:  CSelectEventsDlg::SelectApplication(...)
00825 // Params:  nItem: Application index in listbox.
00826 // Returns: Always returns true
00827 // Purpose: Select the Application with index nItem. This will update the
00828 //        ListBox control with the proper highlight. It also gets the
00829 //        CAppInfo pointer for the given item. It updates some label text
00830 //        on the Dialog to respect Process or Application.  Finally, this
00831 //        method will update the list of events registered for this CAppInfo.
00832 // -----------------------------------------------------------------------------
00833 bool CSelectEventsDlg::SelectApplication(int nItem)
00834 {
00835   USES_CONVERSION;
00836   TCHAR sz[MAX_APPNAME_SIZE];
00837   memset(&sz[0], NULL, MAX_APPNAME_SIZE * sizeof(TCHAR));
00838   SendDlgItemMessage(IDC_LIST_APPS, LB_GETTEXT, nItem, (LPARAM)sz);
00839   SetDlgItemText(IDC_STATIC_CURRENTAPP, sz);
00840
00841   // If this is a Process, use the special name.
00842   int nAppIndex = SendDlgItemMessage(IDC_LIST_APPS, LB_GETCURSEL, 0, (LPARAM)0);
00843   SendDlgItemMessage(IDC_LIST_APPS, LB_GETTEXT, nAppIndex, (LPARAM)sz);
00844
00845   // Now get the pointer to the CAppInfo for this one.
00846   CAppInfo* pInfo = (*m_map)[T2A(sz)];
00847   _ASSERTE(pInfo);
00848   if (pInfo->GetFilterType() == ProcessID)
00849     SetDlgItemText(IDC_STATIC_TYPE, (TCHAR*)g_bstrAppType_Process);
00850   else
00851     SetDlgItemText(IDC_STATIC_TYPE, (TCHAR*)g_bstrAppType_Application);
00852
00853   // Re-fresh the event list for this CAppInfo
00854   ShowSelectedEvents(pInfo);
00855
00856   return true;
00857 };
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/about.h Source File

  • SysMgmt
  • MMC
  • CMenu

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpproppage/SCP.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpproppage

SCP.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCP.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef _SCP_H
00012 #define _SCP_H
00013
00014 #include "stdafx.h"
00015 #include "SCPProppage.h"
00016 #include "SCPUI.h"
00017
00018 class /*ATL_NO_VTABLE*/ CSCP :
00019   public CComObjectRootEx<CComSingleThreadModel>,
00020   public IShellExtInit,
00021   public IShellPropSheetExt,
00022   public CComCoClass<CSCP, &CLSID_ProppageSCP>
00023 {
00024 public:
00025   CSCP()
00026   {
00027     m_pProppageUIGeneral      = NULL;
00028     m_pProppageUIBindingInfo  = NULL;
00029     m_pProppageUIKeywords     = NULL;
00030   }
00031
00032   ~CSCP()
00033   {
00034   }
00035
00036
00037 BEGIN_COM_MAP(CSCP)
00038   COM_INTERFACE_ENTRY(IShellExtInit)
00039   COM_INTERFACE_ENTRY(IShellPropSheetExt)
00040 END_COM_MAP()
00041
00042 DECLARE_REGISTRY_CLSID();
00043
00044 public:
00045
00046   //
00047   // IShellExtInit interface
00048   //
00049   STDMETHOD(Initialize)(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObject, HKEY hKeyID);
00050
00051   //
00052   // IShellPropSheetExt interface
00053   //
00054   STDMETHOD(AddPages)(LPFNADDPROPSHEETPAGE pAddPageProc, LPARAM lParam);
00055   STDMETHOD(ReplacePage)(UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam);
00056
00057 private:
00058   CSCPUIGeneral*      m_pProppageUIGeneral;
00059   CSCPUIBindingInfo*  m_pProppageUIBindingInfo;
00060   CSCPUIKeywords*     m_pProppageUIKeywords;
00061
00062   CComPtr<IDataObject> m_spDataObj;
00063 };
00064
00065
00066 #endif // _SCP_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/GQos/QosEvent/Sender.Cpp Source File

  • NetDS
  • GQos
  • QosEvent

Sender.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      sender.cpp
00010 //
00011 // Abstract:
00012 //      Implement send-side functionality.  The sender uses a combination of
00013 //      WSASend and WSAEventSelect to support sending of either TCP or UDP data
00014 //      and receive notification of QOS activity on the socket.  Additionally,
00015 //      data may be sent to a multicast group with or without QOS.  Note that
00016 //      when a Class D address (multicast group address) is used (by -n:Group-IP),
00017 //      the program will automatically treat that as a multicast socket (as if
00018 //      the -m option was used). For a complete list of valid multicast
00019 //      addresses consult RFC1112 and RFC1700.
00020 //
00021 //      The template used when enabling QOS is specified with the commandline
00022 //      option -q:template.  A value of default for template will result in default
00023 //      values being entered for sending and receiving flowspec (see FillQos).
00024 //      Otherwise the specified template is used (again see FillQos).
00025 //
00026 //      QOS can be enabled in the sender in the following manner
00027 //      -i:b    before WSAConnect/WSAJoinLeaf on the sending socket using WSAIoctl
00028 //      -i:d    during WSAConnect/WSAJoinLeaf using the lpSQos parameter of WSAConnect
00029 //      -i:a    after WSAConnect/WSAJoinLeaf on the sending socket using WSAIoctl
00030 //      For non-multicast UDP QOS tranfers there is no API that gets called
00031 //      prior to initiating the data transfers, therefore QOS is
00032 //      set prior to the data transfers (i.e. -i:b).
00033 //
00034 //      A QOS-enabled application should always check whether it is ok to start
00035 //      data transfers before receipt of a RESV from the receiver.
00036 //
00037 // Entry Points:
00038 //      Sender - send contents of data buffer to receiver program.
00039 //
00040 // Author:
00041 //      Barry R. Butterklee
00042
00043 #include "qosevent.h"
00044
00045
00046 #define WSAEVENTSELECT_EVENT 0
00047 #define WSASEND_EVENT 1
00048 #define TOTAL_EVENTS 2
00049
00050
00051 // encapsulate socket, events, buffers, and various flags and counters that
00052 // control how/when data is sent into a structure
00053 typedef struct _SEND_INFO
00054 {
00055     SOCKET          sd;
00056     WSAEVENT        hEvents[TOTAL_EVENTS];     // WSASend and WSAEventSelect
00057                                                // events
00058     WSAOVERLAPPED   ovr;
00059     BOOL            bSendEnabled;
00060     BOOL            bSendComplete;
00061     int             nTotalSends;
00062     WSABUF          sndbuf;
00063 } SEND_INFO;
00064
00065
00066
00067 static BOOL CreateSendingSocket(SEND_INFO *, OPTIONS *, WSAPROTOCOL_INFO *);
00068 static BOOL fd_connect_func(DWORD, WSANETWORKEVENTS *, SEND_INFO *, OPTIONS *);
00069 static BOOL fd_qos_func(DWORD, WSANETWORKEVENTS *, SEND_INFO *, OPTIONS *);
00070 static BOOL fd_close_func(DWORD, WSANETWORKEVENTS *, SEND_INFO *);
00071 static BOOL PostSend(SEND_INFO *, OPTIONS *);
00072 static BOOL CompleteSend(SEND_INFO *, OPTIONS *);
00073
00074
00075
00076
00077 // Abstract:
00078 //      Main function to establish connection (if using TCP) to server and then
00079 //      send data to server.  WSASend and WSAEventSelect are used to send data
00080 //      and monitor socket activity, respectively.
00081 //
00082 //      Due to the nature of this application - just sending data in a loop -
00083 //      FD_WRITE is not suitable whereas using WSASend with overlapped I/O is.
00084 //      The reason is because FD_WRITE will only be delivered after the inital
00085 //      connection has been established and only after sends block would
00086 //      WSAEWOULDBLOCK and buffer space becomes available once again.  Thus
00087 //      WSAWaitForMultipleEvents waits on the event associated with overlapped
00088 //      structure passed to WSASend AND the event associated with
00089 //      WSAEventSelect.
00090 //
00091 VOID Sender(
00092     OPTIONS             *pOptions,
00093     WSAPROTOCOL_INFO    *pProtocolInfo
00094     )
00095 {
00096     WSANETWORKEVENTS    NetworkEvents;
00097     BOOL                bProcessEventsDone;
00098     SEND_INFO           SendInfo;
00099     int                 i;
00100     BOOL                bDisableQos = TRUE;
00101     BOOL                bErr;
00102
00103     printf("Sender\n");
00104
00105     //Initialize SEND_INFO
00106     ZeroMemory((char *)&SendInfo,sizeof(SendInfo));
00107     for (i=0; i<TOTAL_EVENTS; i++)
00108     {
00109         SendInfo.hEvents[i] = WSACreateEvent();
00110         if (WSA_INVALID_EVENT == SendInfo.hEvents[i])
00111         {
00112             printf("WSACreateEvent(%d): %d\n", i, WSAGetLastError());
00113             goto CLEANUP;
00114         }
00115     }
00116
00117     SendInfo.sd           = INVALID_SOCKET;
00118     SendInfo.ovr.hEvent   = SendInfo.hEvents[WSASEND_EVENT];
00119     SendInfo.sndbuf.buf   = pOptions->buf;
00120     SendInfo.sndbuf.len   = pOptions->nBufSize;
00121     SendInfo.nTotalSends  = 0;
00122
00123     // Should we be able to send yet?
00124     if (!pOptions->spOptions.bQos)
00125         SendInfo.bSendEnabled = TRUE;
00126     else
00127         SendInfo.bSendEnabled = !pOptions->qosOptions.bWaitToSend;
00128
00129     bErr = CreateSendingSocket(&SendInfo, pOptions, pProtocolInfo);
00130
00131     if (!bErr)
00132         goto CLEANUP;
00133
00134     // If we are using UDP.
00135     if (IPPROTO_UDP == pOptions->spOptions.iProtocol)
00136         //
00137         // Post the first send.
00138         if (PostSend(&SendInfo, pOptions))
00139             goto CLEANUP;
00140
00141     bProcessEventsDone = FALSE;
00142     do
00143     {
00144         DWORD dwEvent = WSAWaitForMultipleEvents(TOTAL_EVENTS, SendInfo.hEvents,
00145                                                     FALSE, WSA_INFINITE, FALSE);
00146         switch (dwEvent)
00147         {
00148         case WSA_WAIT_FAILED:
00149             printf("WSAEventSelect: %d\n", WSAGetLastError());
00150             goto CLEANUP;
00151
00152         case WAIT_IO_COMPLETION:
00153         case WSA_WAIT_TIMEOUT:
00154             _assume(0);
00155             break;
00156
00157         default:
00158             dwEvent -= WSA_WAIT_EVENT_0;
00159
00160             if (WSAEVENTSELECT_EVENT != dwEvent) {
00161                 bProcessEventsDone = CompleteSend(&SendInfo, pOptions);
00162                 break;
00163             }
00164
00165             // lets see what network activity trigged this event
00166             if (SOCKET_ERROR == WSAEnumNetworkEvents(
00167                                     SendInfo.sd,
00168                                     SendInfo.hEvents[WSAEVENTSELECT_EVENT],
00169                                     &NetworkEvents))
00170             {
00171                 printf("WSAEnumNetworkEvent: %d lNetworkEvent %X\n",
00172                     WSAGetLastError(), NetworkEvents.lNetworkEvents);
00173                 NetworkEvents.lNetworkEvents = 0;
00174                 break;
00175             }
00176
00177             if (FD_CONNECT & NetworkEvents.lNetworkEvents)
00178                 bProcessEventsDone |= fd_connect_func(dwEvent,
00179                                                       &NetworkEvents,
00180                                                       &SendInfo,
00181                                                       pOptions);
00182
00183             if (FD_QOS     & NetworkEvents.lNetworkEvents)
00184                 bProcessEventsDone |= fd_qos_func(dwEvent,
00185                                                   &NetworkEvents,
00186                                                   &SendInfo,
00187                                                   pOptions);
00188
00189             if (FD_CLOSE   & NetworkEvents.lNetworkEvents)
00190                 bProcessEventsDone |= fd_close_func(dwEvent,
00191                                                     &NetworkEvents,
00192                                                     &SendInfo);
00193         }
00194
00195         // allow pauses between notifications
00196         if (pOptions->dwSleep)
00197             Sleep(pOptions->dwSleep);
00198
00199         // alternate every N sends enabling or disabling QOS on a socket
00200         if (    pOptions->spOptions.bQos
00201             &&  pOptions->qosOptions.bAlternateQos
00202             &&  ((SendInfo.nTotalSends % 5) == 0) )
00203         {
00204             QOS     qos;
00205             DWORD   dwBytes, cbQosLen;
00206             int     nRet;
00207
00208             if (bDisableQos)
00209             {
00210                 bDisableQos = FALSE;
00211
00212                 qos.ReceivingFlowspec    = default_notraffic;
00213                 qos.SendingFlowspec      = default_notraffic;
00214                 qos.ProviderSpecific.buf = NULL;
00215                 qos.ProviderSpecific.len = 0;
00216
00217                 cbQosLen = sizeof(QOS) + qos.ProviderSpecific.len;
00218
00219                 nRet = WSAIoctl(SendInfo.sd, SIO_SET_QOS, (LPVOID)&qos,
00220                                     cbQosLen, NULL, 0, &dwBytes, NULL, NULL);
00221
00222                 if (SOCKET_ERROR == nRet)
00223                     printf("WSAIoctl:SIO_SET_QOS %d\n", WSAGetLastError());
00224
00225                 SendInfo.bSendEnabled = TRUE;
00226             }
00227             else
00228             {
00229                 bDisableQos = TRUE;
00230
00231                 SetQos(SendInfo.sd, &pOptions->qosOptions, TRUE,
00232                         &qos, &cbQosLen);
00233
00234                 // sender should not send data until RESV arrives for this new
00235                 // PATH msg if -rsvp-wait flag is specified.
00236                 SendInfo.bSendEnabled = !pOptions->qosOptions.bWaitToSend;
00237             }
00238
00239             printf("  bSendEnabled = %s\n", (
00240                         SendInfo.bSendEnabled?"TRUE":"FALSE"));
00241
00242         }
00243     } while (!bProcessEventsDone);
00244
00245
00246 CLEANUP:
00247     if (    (INVALID_SOCKET != SendInfo.sd)
00248         &&  (NULL != SendInfo.sd))
00249         closesocket(SendInfo.sd);
00250
00251     for (i=0; i<TOTAL_EVENTS; i++)
00252         if (    (WSA_INVALID_EVENT != SendInfo.hEvents[i])
00253             &&  (NULL != SendInfo.hEvents[i]))
00254             WSACloseEvent(SendInfo.hEvents[i]);
00255
00256 }
00257
00258
00259 // Abstract:
00260 //      Create a socket on which to send data.  Also, please
00261 //      note that WSA_FLAG_OVERLAPPED *MUST* be specified.  Also, note that
00262 //      the parameters for WSASocket and the data to fill in the SOCKADDR_IN
00263 //      structure come from the supplied protocol info structure instead of
00264 //      being hardcoded.
00265 //
00266 //      The socket can be made into a QOS socket either before, during, or
00267 //      after WSAConnect has been called.
00268 //
00269 static BOOL CreateSendingSocket(
00270     SEND_INFO           *pSendInfo,
00271     OPTIONS             *pOptions,
00272     WSAPROTOCOL_INFO    *pProtocolInfo
00273     )
00274 {
00275     DWORD       dwSocketFlags;
00276     QOS         qos;
00277     QOS         *pQos;
00278     long        lNetworkEvents;
00279     int         nRet;
00280     DWORD       cbQosLen;
00281
00282     // set up the address structure of the destination which is needed on
00283     // connect and/or sendto operations.
00284     ZeroMemory((PVOID)&g_destaddr, sizeof(g_destaddr));
00285     g_destaddr.sin_family = (USHORT) pProtocolInfo->iAddressFamily;
00286     g_destaddr.sin_port = htons(pOptions->port);
00287     g_destaddr.sin_addr.s_addr = inet_addr(pOptions->szHostname);
00288
00289     if (INADDR_NONE == g_destaddr.sin_addr.s_addr)
00290     {
00291         struct addrinfo hints, *ai;
00292         LPSOCKADDR_IN   in_ai;
00293
00294         memset(&hints, 0, sizeof(hints));
00295         hints.ai_family   = PF_INET;
00296         hints.ai_socktype = (IPPROTO_UDP == pOptions->spOptions.iProtocol) ?
00297                                 SOCK_DGRAM : SOCK_STREAM;
00298
00299         // the host name for the server is not in dot format,
00300         // try it as a string
00301         nRet = getaddrinfo(pOptions->szHostname, NULL, &hints, &ai);
00302         if (nRet != 0)
00303         {
00304             printf("getaddrinfo %d for %s", WSAGetLastError(),
00305                     pOptions->szHostname);
00306             return(FALSE);
00307         }
00308
00309         in_ai = (LPSOCKADDR_IN) ai->ai_addr;
00310         g_destaddr.sin_addr = in_ai->sin_addr;
00311         freeaddrinfo(ai);
00312     }
00313
00314     // Test if the destination address is multi-cast by looking at the
00315     // first byte of the ip address to start with 1110 for Class D.
00316     if ((g_destaddr.sin_addr.S_un.S_addr & 0xF0) == 0xE0)
00317     {
00318         // Treat this as though -m option has been given
00319         pOptions->spOptions.bMulticast = TRUE;
00320         pOptions->qosOptions.bSetDestaddr = FALSE;
00321     }
00322
00323     dwSocketFlags = WSA_FLAG_OVERLAPPED;
00324
00325     // For a socket to join a multicast group you must specify whether you are
00326     // acting as a root or leaf in the control and data planes. IP multicasting
00327     // only supports leaves in both control and data planes.
00328     if (pOptions->spOptions.bMulticast)
00329         dwSocketFlags |= (WSA_FLAG_MULTIPOINT_C_LEAF | WSA_FLAG_MULTIPOINT_D_LEAF);
00330
00331     pSendInfo->sd = WSASocket(FROM_PROTOCOL_INFO,
00332                               FROM_PROTOCOL_INFO,
00333                               FROM_PROTOCOL_INFO,
00334                               pProtocolInfo,
00335                               0,
00336                               dwSocketFlags);
00337
00338     if (INVALID_SOCKET == pSendInfo->sd)
00339     {
00340         printf("socket %d", WSAGetLastError());
00341         return(FALSE);
00342     }
00343
00344     // When using UDP (not multicast) and QOS, the sending socket must be bound
00345     // for QOS to work.
00346     if (    (IPPROTO_UDP == pOptions->spOptions.iProtocol)
00347          && (pOptions->spOptions.bQos)
00348          && (!pOptions->spOptions.bMulticast))
00349     {
00350         SOCKADDR_IN srcaddr;
00351
00352         ZeroMemory((PVOID)&srcaddr, sizeof(srcaddr));
00353         srcaddr.sin_family      = (USHORT) pProtocolInfo->iAddressFamily;
00354         srcaddr.sin_addr.s_addr = htonl(INADDR_ANY);
00355         srcaddr.sin_port        = 0;
00356
00357         nRet = bind(pSendInfo->sd, (LPSOCKADDR)&srcaddr, sizeof(srcaddr));
00358
00359         if (SOCKET_ERROR == nRet)
00360         {
00361             printf("bind %d", WSAGetLastError());
00362             return(FALSE);
00363         }
00364     }
00365
00366     // If needed do a SetQos, or flll out the pQos structure for the connect
00367     if (pOptions->spOptions.bQos)
00368     {
00369         switch (pOptions->qosOptions.qosIoctlSet)
00370         {
00371         case QOS_IOCTL_SET_BEFORE:
00372             if (SetQos(pSendInfo->sd, &pOptions->qosOptions, TRUE, &qos, &cbQosLen))
00373                 printf("  QOS set before connect\n");
00374
00375             pQos = NULL;
00376             break;
00377
00378         case QOS_IOCTL_SET_DURING:
00379             if (SetQos(pSendInfo->sd, &pOptions->qosOptions, FALSE, &qos, &cbQosLen))
00380                 pQos = &qos;
00381             else
00382                 pQos = NULL;
00383
00384             break;
00385
00386         case QOS_IOCTL_SET_AFTER:
00387             pQos = NULL;
00388
00389             break;
00390         }
00391     }
00392
00393     // Set up events to recieve
00394     if (IPPROTO_TCP == pOptions->spOptions.iProtocol)
00395         lNetworkEvents = FD_CONNECT;
00396     else
00397         lNetworkEvents = (FD_QOS|FD_CLOSE);
00398
00399     if (SOCKET_ERROR == WSAEventSelect(
00400                                 pSendInfo->sd,
00401                                 pSendInfo->hEvents[WSAEVENTSELECT_EVENT],
00402                                 lNetworkEvents))
00403     {
00404         printf("WSAEventSelect: %d\n", WSAGetLastError());
00405         return(FALSE);
00406     }
00407
00408
00409     // Do Connects
00410     if (IPPROTO_TCP == pOptions->spOptions.iProtocol)
00411     {
00412         // Tcp Connect
00413         nRet = WSAConnect(pSendInfo->sd, (LPSOCKADDR)&g_destaddr,
00414                             sizeof(g_destaddr), NULL, NULL, pQos, NULL);
00415
00416         if (SOCKET_ERROR == nRet)
00417         {
00418             DWORD dwErr = WSAGetLastError();
00419             if (WSAEWOULDBLOCK != dwErr)
00420             {
00421                 printf("WSAConnect: %d\n", dwErr);
00422                 return(FALSE);
00423             }
00424         }
00425
00426         // Is it time to do a setqos?
00427         if (    (pOptions->spOptions.bQos)
00428             &&  (QOS_IOCTL_SET_AFTER == pOptions->qosOptions.qosIoctlSet))
00429         {
00430             if (SetQos(pSendInfo->sd, &pOptions->qosOptions,
00431                         TRUE, &qos, &cbQosLen))
00432                 printf("    QOS set after connect\n");
00433         }
00434     }
00435     else
00436     {
00437         // UDP
00438
00439         if (pOptions->spOptions.bMulticast)
00440         {
00441             nRet = (int) WSAJoinLeaf(pSendInfo->sd, (LPSOCKADDR)&g_destaddr,
00442                                      sizeof(g_destaddr), NULL, NULL, pQos,
00443                                      NULL, JL_SENDER_ONLY);
00444
00445             if (INVALID_SOCKET == nRet)
00446             {
00447                 printf("WSAJoinLeaf: %d\n", WSAGetLastError());
00448                 return(FALSE);
00449             }
00450
00451             if (    (pOptions->spOptions.bQos)
00452                 &&  (QOS_IOCTL_SET_AFTER == pOptions->qosOptions.qosIoctlSet))
00453             {
00454                 if (SetQos(pSendInfo->sd, &pOptions->qosOptions,
00455                             TRUE, &qos, &cbQosLen))
00456                     printf("    QOS set after connect\n");
00457             }
00458         }
00459         else
00460         {
00461             // for TCP the following happens in the connect handler
00462             if (!pOptions->spOptions.bQos)
00463                 pSendInfo->bSendEnabled = TRUE;
00464             else
00465             {
00466                 if (pOptions->qosOptions.bWaitToSend)
00467                     pSendInfo->bSendEnabled = FALSE;
00468                 else
00469                     pSendInfo->bSendEnabled = ChkQosSend(pSendInfo->sd);
00470             }
00471             printf("  CreateSendingSocket QOS bSendEnabled = %s\n",
00472                     (pSendInfo->bSendEnabled?"TRUE":"FALSE"));
00473         }
00474     }
00475
00476     return(TRUE);
00477 }
00478
00479
00480 // Abstract:
00481 //      FD_CONNECT handler.  This handler is invoked when an asynchronous
00482 //      connect completes, successfully or otherwise.  After the socket
00483 //      connects additional notifications will be enabled using WSAEventSelect.
00484 //
00485 //      The connected socket will be made into a QOS socket after connect if
00486 //      the -i:a option is used.
00487 //
00488 static BOOL fd_connect_func(
00489     DWORD               dwEvent,
00490     WSANETWORKEVENTS    *NetworkEvents,
00491     SEND_INFO           *pSendInfo,
00492     OPTIONS             *pOptions
00493     )
00494 {
00495     int     nRet;
00496     QOS     qos;
00497     DWORD   cbQosLen;
00498
00499
00500     printf("  FD_CONNECT: dwEvent=%d error code =%d\n",
00501     dwEvent, NetworkEvents->iErrorCode[FD_CONNECT_BIT]);
00502
00503     if (NetworkEvents->iErrorCode[FD_CONNECT_BIT] != 0)
00504         return(TRUE);
00505
00506     // SetQos if it's time
00507     if (    (pOptions->spOptions.bQos)
00508         &&  (QOS_IOCTL_SET_AFTER == pOptions->qosOptions.qosIoctlSet)
00509         &&  SetQos(pSendInfo->sd, &pOptions->qosOptions, TRUE, &qos, &cbQosLen))
00510             printf("    QOS set after connect\n");
00511
00512     nRet = WSAEventSelect(pSendInfo->sd,
00513                           pSendInfo->hEvents[WSAEVENTSELECT_EVENT],
00514                           (FD_QOS|FD_CLOSE));
00515
00516     if (SOCKET_ERROR == nRet)
00517     {
00518         printf("WSAEventSelect: %d\n", WSAGetLastError());
00519         return(FALSE);
00520     }
00521
00522     // determine when to start sending data.  If not using QOS then start
00523     // sending right away.  Also note that the socket must be a QOS socket
00524     // before we can call use this ioctl, otherwise we would get WSAEINVAL.
00525
00526     if (!pOptions->spOptions.bQos)
00527         pSendInfo->bSendEnabled = TRUE;
00528     else
00529     {
00530         if (pOptions->qosOptions.bWaitToSend)
00531             pSendInfo->bSendEnabled = FALSE;
00532         else
00533             pSendInfo->bSendEnabled = ChkQosSend(pSendInfo->sd);
00534     }
00535
00536     printf("    bSendEnabled = %s\n",
00537                 (pSendInfo->bSendEnabled?"TRUE":"FALSE"));
00538
00539     // potentially post initial send (if we are here we are using TCP)
00540     if (    !pOptions->spOptions.bQos
00541         ||  !pOptions->qosOptions.bWaitToSend)
00542         return(PostSend(pSendInfo, pOptions));
00543
00544     return(FALSE);
00545 }
00546
00547
00548
00549
00550 // Abstract:
00551 //      FD_QOS handler.  This notification indicates that the GQOSSP wants to
00552 //      indicate a change in QOS status (i.e. delivery of an RSVP message).
00553 //      Only a change in QOS will cause FD_QOS notifications to be delivered,
00554 //      periodic RSVP refresh messages will not cause an FD_QOS notification.
00555 //
00556 //      Note that the iErrorCode is not really an errorcode but a status code.
00557 //
00558 //      Also notice that multiple QOS structures may be queued up per FD_QOS
00559 //      notification and should be examined.
00560 //
00561 static BOOL fd_qos_func(
00562     DWORD               dwEvent,
00563     WSANETWORKEVENTS    *NetworkEvents,
00564     SEND_INFO           *pSendInfo,
00565     OPTIONS             *pOptions
00566     )
00567 {
00568     printf("  FD_QOS: dwEvent=%d status code =%d\n",
00569     dwEvent, NetworkEvents->iErrorCode[FD_QOS_BIT]);
00570
00571     do
00572     {
00573         QOS                 *pQos;
00574         QOS_OBJECT_HDR      *pObjectHdr;
00575         RSVP_STATUS_INFO    *pRsvpStatus;
00576
00577         if (!GetQos(pSendInfo->sd, pOptions->qosOptions.bQueryBufferSize, &pQos))
00578             break;
00579
00580         PrintQos(pQos, "    ");
00581
00582         pObjectHdr  = (QOS_OBJECT_HDR *) pQos->ProviderSpecific.buf;
00583
00584         if (RSVP_OBJECT_STATUS_INFO != pObjectHdr->ObjectType)
00585         {
00586             printf("FD_QOS: not rsvp_object_status_info\n");
00587             free(pQos);
00588             break;
00589         }
00590
00591         pRsvpStatus = (RSVP_STATUS_INFO *) pObjectHdr;
00592
00593         switch (pRsvpStatus->StatusCode)
00594         {
00595             case WSA_QOS_RECEIVERS:
00596                 if (pOptions->qosOptions.bWaitToSend)
00597                 {
00598                     printf("FD_QOS: start sending data\n");
00599                     pSendInfo->bSendEnabled = TRUE;
00600                     PostSend(pSendInfo, pOptions);
00601                 }
00602                 break;
00603
00604             case WSA_QOS_NO_RECEIVERS:
00605                 if (pOptions->qosOptions.bWaitToSend)
00606                 {
00607                     printf("FD_QOS: Stop sending data\n");
00608                     pSendInfo->bSendEnabled = FALSE;
00609                 }
00610                 break;
00611
00612             default:
00613                 printf("FD_QOS: Status code %d - no action taken\n",
00614                             pRsvpStatus->StatusCode);
00615         }
00616
00617         free(pQos);
00618     }while (TRUE);
00619
00620     // check for local traffic control
00621     if (pOptions->qosOptions.bQosabilityIoctls)
00622     {
00623         int   nRet;
00624         DWORD dwBytes, outbuf;
00625         DWORD inbuf = LOCAL_TRAFFIC_CONTROL;
00626
00627         nRet = WSAIoctl(pSendInfo->sd, SIO_CHK_QOS, (LPVOID)&inbuf,
00628                         sizeof(inbuf), (LPVOID)&outbuf,
00629                         sizeof(outbuf), &dwBytes, NULL, NULL);
00630
00631         if (SOCKET_ERROR == nRet)
00632             printf("  SIO_CHK_QOS(LOCAL_TRAFFIC_CONTROL) %d\n", WSAGetLastError());
00633         else
00634         {
00635             printf("  Local Traffic = ");
00636
00637             switch( outbuf )
00638             {
00639                 case INFO_NOT_AVAILABLE:
00640                     printf("INFO_NOT_AVAILABLE\n");
00641                     break;
00642                 case 1:
00643                     printf("Available\n");
00644                     break;
00645                 case 0:
00646                     printf("Not available\n");
00647                     break;
00648                 default:
00649                      _assume(0);
00650             }
00651         }
00652     }
00653
00654     return(FALSE);
00655 }
00656
00657
00658
00659
00660 // Abstract:
00661 //      FD_CLOSE handler.   If server closes before we have sent all the data,
00662 //      then we are done.  Winsock2 events are manual reset events and FD_CLOSE
00663 //      has no re-enabling function, therefore must reset the event here,
00664 //      otherwise we would get additional FD_CLOSE notifications.
00665 //
00666 static BOOL fd_close_func(
00667     DWORD               dwEvent,
00668     WSANETWORKEVENTS    *NetworkEvents,
00669     SEND_INFO           *pSendInfo
00670     )
00671 {
00672     printf("  FD_CLOSE: dwEvent=%d error code =%d\n",
00673             dwEvent, NetworkEvents->iErrorCode[FD_CLOSE_BIT]);
00674
00675     WSAResetEvent(pSendInfo->hEvents[WSAEVENTSELECT_EVENT]);
00676     closesocket(pSendInfo->sd);
00677
00678     return(TRUE);
00679 }
00680
00681
00682
00683
00684 // Abstract:
00685 //      Post an overlapped send and indicate a send is in progress if it doesn
00686 //      not complete immediately.  If the WSASend completes immediately bump
00687 //      the counters and indicate the send completed.  The send flag is needed
00688 //      to what needs to be done in CompleteSend() - wait for overlapped
00689 //      results or post another send.
00690 //
00691 static BOOL PostSend(
00692     SEND_INFO   *pSendInfo,
00693     OPTIONS     *pOptions
00694     )
00695 {
00696     int     nRet;
00697     DWORD   cbBytesXfer = 0;
00698
00699     if (pSendInfo->bSendEnabled)
00700         return(FALSE);
00701
00702     printf("  PostSend\n");
00703
00704     pSendInfo->bSendComplete = FALSE;
00705
00706     if (IPPROTO_TCP == pOptions->spOptions.iProtocol)
00707         nRet = WSASend(pSendInfo->sd, &pSendInfo->sndbuf, 1, &cbBytesXfer,
00708                         0, &pSendInfo->ovr, NULL);
00709     else
00710         nRet = WSASendTo(pSendInfo->sd, &pSendInfo->sndbuf, 1, &cbBytesXfer, 0,
00711                             (LPSOCKADDR)&g_destaddr, sizeof(g_destaddr),
00712                             &pSendInfo->ovr, NULL);
00713
00714     if (SOCKET_ERROR == nRet) {
00715         DWORD dwErr = WSAGetLastError();
00716
00717         if (WSA_IO_PENDING != dwErr)
00718         {
00719             // Real Error
00720             printf("WSASend %d\n", dwErr);
00721             return(TRUE);
00722         }
00723
00724         return(FALSE);
00725     }
00726
00727     // the send completed immediately
00728     pSendInfo->sndbuf.len -= cbBytesXfer;
00729     pSendInfo->sndbuf.buf += cbBytesXfer;
00730     return(TRUE);
00731 }
00732
00733
00734
00735
00736 // Abstract:
00737 //      Handle the completion of a WSASend.  This may involve posting another
00738 //      overlapped send or closing the socket.  Actually to be more precise,
00739 //      if a TCP socket is being used, shutdown is called and closesocket
00740 //      is handled explicitedly in the FD_CLOSE handler function whereas a
00741 //      UDP socket is closed immediately since it will not receive an FD_CLOSE
00742 //      notification.
00743 //
00744 static BOOL CompleteSend(
00745     SEND_INFO   *pSendInfo,
00746     OPTIONS     *pOptions
00747     )
00748 {
00749     BOOL    bProcessEventsDone  = FALSE;
00750     BOOL    bNormalShutdown     = FALSE;
00751     int     i;
00752
00753     printf("  CompleteSend\n");
00754
00755     if (!pSendInfo->bSendComplete)
00756     {
00757         DWORD   dwFlags = 0;
00758         DWORD   cbBytesXfer;
00759
00760         // handle getting overlapped results
00761         if (!WSAGetOverlappedResult(pSendInfo->sd, &pSendInfo->ovr,
00762                                     &cbBytesXfer, TRUE, &dwFlags))
00763         {
00764             printf("WSAGetOverlappedResults = %d\n", WSAGetLastError());
00765             bProcessEventsDone = TRUE;
00766         }
00767         else
00768         {
00769             pSendInfo->bSendComplete = TRUE;
00770             pSendInfo->sndbuf.len -= cbBytesXfer;
00771             pSendInfo->sndbuf.buf += cbBytesXfer;
00772         }
00773     }
00774
00775     // We need to send more
00776     if (pSendInfo->sndbuf.len > 0)
00777     {
00778         PostSend(pSendInfo, pOptions);
00779         return FALSE;
00780     }
00781
00782     // now we have sent the entire buffer, check repeat count to
00783     // see if buffer needs to be sent again.
00784     if (pOptions->nRepeat || pOptions->qosOptions.bAlternateQos)
00785         pSendInfo->nTotalSends++;
00786     else
00787         pSendInfo->nTotalSends = -1;
00788
00789     pSendInfo->sndbuf.buf = pOptions->buf;
00790     pSendInfo->sndbuf.len = pOptions->nBufSize;
00791
00792     if (    pSendInfo->nTotalSends <= pOptions->nRepeat - 1
00793         ||  pOptions->qosOptions.bAlternateQos)
00794     {
00795         PostSend(pSendInfo, pOptions);
00796         return FALSE;
00797     }
00798
00799     // We are done sending, go into cleanup
00800     printf("    repeat count complete - closing\n");
00801
00802     if (IPPROTO_UDP == pOptions->spOptions.iProtocol)
00803     {
00804         // UDP will not recieve FD_CLOSE, nor is shutdown applicable
00805         closesocket(pSendInfo->sd);
00806         WSAResetEvent(pSendInfo->hEvents[WSASEND_EVENT]);
00807         return(TRUE);
00808     }
00809
00810     //TCP case
00811     // On NT it is possible that shutdown returns WSAENOTCONN even
00812     // after receipt of an FD_CONNECT notification (see KB).  To
00813     // get around this, just add a little delay.
00814
00815     for (i=0; i<20; i++)
00816     {
00817         int nRet = shutdown(pSendInfo->sd, SD_SEND);
00818
00819         if (0 == nRet)
00820         {
00821             bNormalShutdown = TRUE;
00822             break;
00823         }
00824         else
00825         {
00826             DWORD dwErr = WSAGetLastError();
00827
00828             if (dwErr == WSAENOTCONN)
00829                 Sleep(100);
00830             else
00831             {
00832                 printf("    shutdown: %d\n", dwErr);
00833                 break;
00834             }
00835         }
00836     }
00837
00838     if (! bNormalShutdown)
00839     {
00840         //
00841         // Normal shutdown failed... too bad.
00842         closesocket(pSendInfo->sd);
00843         bProcessEventsDone = TRUE;
00844     }
00845
00846     WSAResetEvent(pSendInfo->hEvents[WSASEND_EVENT]);
00847     return(bProcessEventsDone);
00848 }
00849
00850
00851
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/basenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

basenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Generic base node class.  All nodes are derived from this.
00014
00015
00016 #ifndef _CLASS_CBASENODE_
00017 #define _CLASS_CBASENODE_
00018
00019 #include "Globals.h"
00020 #include "Resource.h"
00021
00022
00023 #define DEFAULT_SDI_MASK  (SDI_STR | SDI_PARAM | SDI_IMAGE | SDI_OPENIMAGE | SDI_PARENT | SDI_CHILDREN)
00024 #define DEFAULT_RDI_MASK  (RDI_STR | RDI_PARAM | RDI_IMAGE)
00025
00026 #define MAX_NAME_LEN     64
00027
00028
00029 class  CBaseNode;            // References
00030
00031 //---------------------------------------------------------------------------
00032 //  DRAGDROP:  Two new data members have been added to facilitate cut/paste
00033 //             operations between two different console processes.
00034 //             See CDataObject
00035 //
00036 //    pChildProps  - An array of CHILD_PROPERTIES structs.  Each struct
00037 //                   represents one child object.
00038 //
00039 //    dwChildCount - The number of CHILD_PROPERTIES structs in the array.
00040 //
00041 //
00042
00043 struct CHILD_PROPERTIES
00044 {
00045   WCHAR            szNodeName[MAX_NAME_LEN];
00046   DWORD            dwAttributes;
00047 };
00048
00049 struct NODE_PROPERTIES
00050 {
00051   WCHAR              szNodeName[MAX_NAME_LEN];
00052   LONG_PTR           pComponentData;
00053   LONG_PTR           pParentObject;
00054   DWORD              dwAttributes;
00055   LONG               nChildCount;
00056   LONG               nBlockSize;
00057   CHILD_PROPERTIES   pChildProps;
00058 };
00059
00060 typedef NODE_PROPERTIES    NODEPROPS;
00061 typedef NODE_PROPERTIES*   LPNODEPROPS;
00062 typedef CHILD_PROPERTIES   CHILDPROPS;
00063 typedef CHILD_PROPERTIES*  LPCHILDPROPS;
00064 typedef CBaseNode*         LPBASENODE;
00065
00066
00067 //---------------------------------------------------------------------------
00068 class CBaseNode
00069 {
00070   public:
00071     CBaseNode()
00072     {
00073       m_pwszNodeName      = NULL;
00074
00075       ZeroMemory( &m_SDI, sizeof(SCOPEDATAITEM) );
00076       ZeroMemory( &m_RDI, sizeof(RESULTDATAITEM) );
00077     };
00078
00079     virtual ~CBaseNode()
00080     {
00081       if( NULL != m_pwszNodeName )
00082         CoTaskMemFree( m_pwszNodeName );
00083     };
00084
00085   public:
00086     LPWSTR   GetNodeName()     { return m_pwszNodeName;  };
00087
00088     virtual  HRESULT Initialize( LPNODEPROPS pNodeProps ) = 0;
00089     virtual  HRESULT GetProperties( LPNODEPROPS* ppNodeProps ) = 0;
00090     virtual  ULONG   GetNodeType() = 0;
00091     virtual  GUID&   GetNodeGUID() = 0;
00092
00093   ///////////////////////////////////////////////////////////////////////////
00094   // These virtual methods handle calls from the console
00095   //
00096   public:
00097     virtual  HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI ) = 0;
00098     virtual  HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI ) = 0;
00099     virtual  HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo ) = 0;
00100
00101   ///////////////////////////////////////////////////////////////////////////
00102   // Context Menu methods
00103   //
00104   public:
00105     virtual  HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed ) = 0;
00106     virtual  HRESULT Command( long lCommandID ) = 0;
00107
00108   ///////////////////////////////////////////////////////////////////////////
00109   // These virtual methods handle notifications
00110   //
00111   public:
00112     virtual  HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00113     virtual  HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00114     virtual  HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00115     virtual  HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData ) = 0;
00116     virtual  HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData ) = 0;
00117
00118
00119     virtual  HRESULT OnViewChange( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00120                      { return E_NOTIMPL; };
00121
00122     // DRAGDROP:  Support for additional notifications
00123     virtual  HRESULT OnQueryPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00124     virtual  HRESULT OnPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00125     virtual  HRESULT OnCutOrMove( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00126
00127   public:
00128     SCOPEDATAITEM    m_SDI;
00129     RESULTDATAITEM   m_RDI;
00130
00131   protected:
00132     LPWSTR     m_pwszNodeName;
00133
00134 }; //end class CBaseNode
00135
00136 #endif //_CLASS_CBASENODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEnumXXX< T, ELT_T, IFACE > Member List

This is the complete list of members for CEnumXXX< T, ELT_T, IFACE >, including all inherited members.
AddRef() | CEnumXXX< T, ELT_T, IFACE > | [virtual]
CEnumXXX(LPUNKNOWN lpUnk, REFIID iid, DWORD nCount) | CEnumXXX< T, ELT_T, IFACE > | [protected]
CEnumXXX() | CEnumXXX< T, ELT_T, IFACE > | [inline, private]
Clone(IFACE **ppenum) | CEnumXXX< T, ELT_T, IFACE > | [virtual]
Create(LPUNKNOWN lpUnk, DWORD nCount, ELT_T *elemlist) | CEnumXXX< T, ELT_T, IFACE > | [static]
FinalRelease() | CEnumXXX< T, ELT_T, IFACE > | [virtual]
Init(ELT_T *elemlist) | CEnumXXX< T, ELT_T, IFACE > | [protected, virtual]
m_cELT | CEnumXXX< T, ELT_T, IFACE > |
m_cRef | CEnumXXX< T, ELT_T, IFACE > |
m_iCur | CEnumXXX< T, ELT_T, IFACE > |
m_iid | CEnumXXX< T, ELT_T, IFACE > |
m_lpunk | CEnumXXX< T, ELT_T, IFACE > |
m_prgELT | CEnumXXX< T, ELT_T, IFACE > |
Next(ULONG celt, ELT_T *rgelt, PULONG pceltFetched) | CEnumXXX< T, ELT_T, IFACE > | [virtual]
QueryInterface(REFIID iid, PVOID *ppv) | CEnumXXX< T, ELT_T, IFACE > | [virtual]
Release() | CEnumXXX< T, ELT_T, IFACE > | [virtual]
Reset(void) | CEnumXXX< T, ELT_T, IFACE > | [virtual]
Skip(ULONG celt) | CEnumXXX< T, ELT_T, IFACE > | [virtual]
~CEnumXXX() | CEnumXXX< T, ELT_T, IFACE > | [virtual]
Generated on Wed Nov 13 2024 16:56:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinNT/HalfTone/resource.h Source File

  • Multimedia
  • Gdi
  • WinNT
  • HalfTone

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by HalfTone.RC
00004 //
00005 #define IDM_ERRORMESSAGE                2
00006 #define IDM_EXIT                        102
00007 #define IDM_PROPERTIES                  103
00008 #define IDM_ABOUT                       105
00009 #define IDM_LOADDIB                     106
00010 #define IDC_FLAGS                       222
00011 #define IDC_ILLUMINATE                  226
00012 #define IDC_REDGAMMA                    229
00013 #define IDC_GREENGAMMA                  230
00014 #define IDC_BLUEGAMMA                   231
00015 #define IDC_REFBLACK                    232
00016 #define IDC_REFWHITE                    233
00017 #define IDC_CONTRAST                    234
00018 #define IDC_BRIGHTNESS                  236
00019 #define IDC_COLORFULNESS                238
00020 #define IDC_TINT                        239
00021 #define DLG_VERFIRST                    400
00022 #define IDC_REDGAMMASLIDER              1000
00023 #define IDC_GREENGAMMASLIDER            1001
00024 #define IDC_BLUEGAMMASLIDER             1002
00025 #define IDC_UPDATE                      1003
00026 #define IDC_REFBLACKSLIDER              1004
00027 #define IDC_REFWHITESLIDER              1005
00028 #define IDC_CONTRASTSLIDER              1006
00029 #define IDC_BRIGHTNESSSLIDER            1007
00030 #define IDC_COLORFULNESSSLIDER          1008
00031 #define IDC_TINTSLIDER                  1009
00032 #define IDC_STATIC                      -1
00033
00034 // Next default values for new objects
00035 //
00036 #ifdef APSTUDIO_INVOKED
00037 #ifndef APSTUDIO_READONLY_SYMBOLS
00038 #define _APS_NEXT_RESOURCE_VALUE        103
00039 #define _APS_NEXT_COMMAND_VALUE         109
00040 #define _APS_NEXT_CONTROL_VALUE         1004
00041 #define _APS_NEXT_SYMED_VALUE           101
00042 #endif
00043 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Parent/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Parent
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Parent.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProvider_IWbemServices Member List

This is the complete list of members for CProvider_IWbemServices, including all inherited members.
CancelAsyncCall(IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
CProvider_IWbemServices() | CProvider_IWbemServices |
CreateClassEnum(const BSTR a_Superclass, long a_Flags, IWbemContext *a_Context, IEnumWbemClassObject **a_Enum) | CProvider_IWbemServices | [inline]
CreateClassEnumAsync(const BSTR a_Superclass, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
CreateInstanceEnum(const BSTR a_Class, long a_Flags, IWbemContext *a_Context, IEnumWbemClassObject **a_Enum) | CProvider_IWbemServices | [inline]
CreateInstanceEnumAsync(const BSTR a_Class, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
CreateInstanceEnumAsync_Contacts(IWbemClassObject *a_ClassObject, long a_Flags, IWbemContext __RPC_FAR *a_Context, IWbemObjectSink FAR *a_Sink) | CProvider_IWbemServices | [private]
CreateInstanceEnumAsync_Process(IWbemClassObject *a_ClassObject, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices | [private]
DeleteClass(const BSTR a_Class, long a_Flags, IWbemContext *a_Context, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
DeleteClassAsync(const BSTR a_Class, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
DeleteInstance(const BSTR a_ObjectPath, long a_Flags, IWbemContext *a_Context, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
DeleteInstanceAsync(const BSTR a_ObjectPath, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
ExecMethod(const BSTR a_ObjectPath, const BSTR a_MethodName, long a_Flags, IWbemContext *a_Context, IWbemClassObject *a_InParams, IWbemClassObject **a_OutParams, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
ExecMethodAsync(const BSTR a_ObjectPath, const BSTR a_MethodName, long a_Flags, IWbemContext *a_Context, IWbemClassObject *a_InParams, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
ExecNotificationQuery(const BSTR a_QueryLanguage, const BSTR a_Query, long a_Flags, IWbemContext *a_Context, IEnumWbemClassObject **a_Enum) | CProvider_IWbemServices | [inline]
ExecNotificationQueryAsync(const BSTR a_QueryLanguage, const BSTR a_Query, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices | [inline]
ExecQuery(const BSTR a_QueryLanguage, const BSTR a_Query, long a_Flags, IWbemContext *a_Context, IEnumWbemClassObject **a_Enum) | CProvider_IWbemServices | [inline]
ExecQueryAsync(const BSTR a_QueryLanguage, const BSTR a_Query, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
GetObject(const BSTR a_ObjectPath, long a_Flags, IWbemContext *a_Context, IWbemClassObject **ppObject, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
GetObjectAsync(const BSTR a_ObjectPath, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
GetProperty(long a_Flags, const BSTR a_Locale, const BSTR a_ClassMapping, const BSTR a_InstanceMapping, const BSTR a_PropertyMapping, VARIANT *a_Value) | CProvider_IWbemServices |
Initialize(LPWSTR a_User, LONG a_Flags, LPWSTR a_Namespace, LPWSTR a_Locale, IWbemServices *a_Core, IWbemContext *a_Context, IWbemProviderInitSink *a_Sink) | CProvider_IWbemServices |
m_ComputerName | CProvider_IWbemServices | [private]
m_ContactInfo_Object | CProvider_IWbemServices | [private]
m_CoreService | CProvider_IWbemServices | [private]
m_CriticalSection | CProvider_IWbemServices | [private]
m_Locale | CProvider_IWbemServices | [private]
m_Namespace | CProvider_IWbemServices | [private]
m_OperatingSystemVersion | CProvider_IWbemServices | [private]
m_ReferenceCount | CProvider_IWbemServices | [private]
m_User | CProvider_IWbemServices | [private]
m_Win32_ProcessEx_Object | CProvider_IWbemServices | [private]
OpenNamespace(const BSTR a_Namespace, long a_Flags, IWbemContext *a_Context, IWbemServices **a_Service, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
PutClass(IWbemClassObject *a_Object, long a_Flags, IWbemContext *a_Context, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
PutClassAsync(IWbemClassObject *a_Object, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
PutInstance(IWbemClassObject *a_Instance, long a_Flags, IWbemContext *a_Context, IWbemCallResult **a_CallResult) | CProvider_IWbemServices | [inline]
PutInstanceAsync(IWbemClassObject *a_Instance, long a_Flags, IWbemContext *a_Context, IWbemObjectSink *a_Sink) | CProvider_IWbemServices |
PutProperty(long a_Flags, const BSTR a_Locale, const BSTR a_ClassMapping, const BSTR a_InstanceMapping, const BSTR a_PropertyMapping, const VARIANT *a_Value) | CProvider_IWbemServices |
QueryInterface(REFIID, LPVOID FAR *) | CProvider_IWbemServices |
QueryObjectSink(long a_Flags, IWbemObjectSink **a_Sink) | CProvider_IWbemServices | [inline]
Shutdown(LONG a_Flags, ULONG a_MaxMilliSeconds, IWbemContext *a_Context) | CProvider_IWbemServices |
STDMETHODIMP_(ULONG) AddRef() | CProvider_IWbemServices |
STDMETHODIMP_(ULONG) Release() | CProvider_IWbemServices |
~CProvider_IWbemServices() | CProvider_IWbemServices |
Generated on Wed Nov 13 2024 16:57:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/Extension.cpp Source File

  • Web
  • iis
  • ISAPI_6.0

Extension.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: ***
00006
00007 Abstract:
00008
00009     ISAPI extension ***
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee), ***
00014
00015 --*/
00016
00017 #ifndef _WIN32_WINNT
00018 #define _WIN32_WINNT 0x0500
00019 #endif
00020
00021 #include <windows.h>
00022 #include <httpext.h>
00023
00024 BOOL
00025 WINAPI
00026 GetExtensionVersion(
00027     HSE_VERSION_INFO *  pVer
00028     )
00029 /*++
00030
00031 Purpose:
00032
00033     Entry point for ISAPI extension initialization.  Required.
00034
00035     This function will be called exactly once in the lifetime
00036     of the extension, at initialization time.  This function is
00037     a useful point to do complex initialization tasks.  This
00038     function is called outside of the system loader lock, so
00039     it does not have the same restrictions as DllMain.
00040
00041 Arguments:
00042
00043     pVer - points to extension version info structure
00044
00045 Returns:
00046
00047     TRUE on success, FALSE on failure.
00048
00049     Note that in the case of FALSE, IIS will call GetLastError()
00050     and return an error page to the client.  The entity body of
00051     the page may be textual if the FormatMessage API can resolve
00052     it, or it may just be an error number if FormatMessage can't
00053     resolve it.
00054
00055 --*/
00056 {
00057     //
00058     // Tell IIS which version of ISAPI this extension was built from.
00059     //
00060
00061     pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
00062                                          HSE_VERSION_MAJOR);
00063
00064     //
00065     // Report the description string for this extension.  Ensure
00066     // that it does not exceed the maximum length and is NULL
00067     // terminated.
00068     //
00069
00070     strncpy( pVer->lpszExtensionDesc,
00071              "***",
00072              HSE_MAX_EXT_DLL_NAME_LEN );
00073
00074     pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
00075
00076     //
00077     // Return TRUE if we successfully initialized.
00078     //
00079
00080     return TRUE;
00081 }
00082
00083 DWORD
00084 WINAPI
00085 HttpExtensionProc(
00086     EXTENSION_CONTROL_BLOCK *   pecb
00087     )
00088 /*++
00089
00090 Purpose:
00091
00092     Entry point for ISAPI requests.  Required.
00093
00094     This function is called once per request.  The EXTENSION_CONTROL_BLOCK
00095     passed in contains information and function pointers sufficient to
00096     interact with the server during this processing.
00097
00098     Note that, once HttpExtensionProc is called, it is the responsibility
00099     of the extension to send back any data that the client should receive.
00100     IIS will not automatically generate any response, even in the case of
00101     HSE_STATUS_ERROR once the request has progressed to the point where
00102     this function is called.
00103
00104     Also note that you should not make any blocking calls or do long-running
00105     operations within this function.  To allow efficient scaling of your
00106     server, you should consider creating a pool of private threads to handle
00107     the requests.  In that case, the implementation of this function would
00108     be just to add the pecb to a queue and return HSE_STATUS_PENDING.  The
00109     threads in the pool would be responsible for dequeing a pecb and calling
00110     HSE_REQ_DONE_WITH_SESSION when they are finished processing it.
00111
00112 Arguments:
00113
00114     pecb - pointer to the extenstion control block
00115
00116 Returns:
00117
00118     HSE_STATUS_SUCCESS - Indicates successful request.
00119     HSE_STATUS_ERROR   - Indicates failed request.
00120     HSE_STATUS_PENDING - Indicates that processing of the request
00121                          should continue after this function returns.
00122                          It HSE_STATUS_PENDING is used, it is necessary
00123                          that HSE_REQ_DONE_WITH_SESSION is called
00124                          exactly once when processing is completed for
00125                          the request.
00126
00127 --*/
00128 {
00129     return HSE_STATUS_SUCCESS;
00130 }
00131
00132 BOOL
00133 WINAPI
00134 TerminateExtension(
00135     DWORD   dwFlags
00136     )
00137 /*++
00138
00139 Purpose:
00140
00141     Entry point for ISAPI extension termination.  Optional.
00142
00143     If present, IIS will call this function just before it
00144     unloads the extension.  In general, this function will
00145     be called after all of the running requests for this
00146     extension have completed.
00147
00148     Any complex or long-running uninitialization tasks should
00149     be performed here.  This function is called outside of the
00150     system loader lock, so it does not have the same
00151     restrictions as DllMain.
00152
00153 Arguments:
00154
00155     dwFlags - specifies whether the DLL can refuse to unload or not
00156
00157 Returns:
00158
00159     TRUE, if the DLL can be unloaded
00160
00161     Note that the HSE_TERM_ADVISORY_UNLOAD flag is not used by
00162     IIS, so it's not necessary to consider any cases where the
00163     extension can refuse to unload.
00164
00165 --*/
00166 {
00167     BOOL    fReturn = TRUE;
00168
00169     switch ( dwFlags )
00170     {
00171     case HSE_TERM_ADVISORY_UNLOAD:
00172
00173         //
00174         // Return TRUE if ok to unload or FALSE if not
00175         //
00176
00177         fReturn = TRUE;
00178
00179     case HSE_TERM_MUST_UNLOAD:
00180
00181         //
00182         // Cannot refuse to unload
00183         //
00184
00185         fReturn = TRUE;
00186     }
00187
00188     return fReturn;
00189 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/createuser/vc/UserProps.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • createuser
  • vc

UserProps.cpp

Go to the documentation of this file.
00001
00002 #define INC_OLE2
00003 #define UNICODE 1
00004 #define _WIN32_DCOM
00005
00006 #include <windows.h>
00007 #include <winuser.h>
00008
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 #include <string.h>
00012
00013 #include <activeds.h>
00014
00015 #include "UserProps.h"
00016
00017
00018 ////////////////////////////////////////////////////
00019 //        Mandatory
00020 ////////////////////////////////////////////////////
00021
00022 WCHAR * parwszUserMandatoryProps []=
00023 {
00024     // Attrib Name              Type                                Multi or Single Valued
00025     L"cn",                      L"DirectoryString",                 L"SV",
00026     L"instanceType",            L"INTEGER",                         L"SV",
00027     L"nTSecurityDescriptor",    L"ObjectSecurityDescriptor",        L"SV",
00028     L"objectCategory",          L"DN",                              L"SV",
00029     L"objectClass",             L"OID",                             L"MV",
00030     L"objectSid",               L"OctetString",                     L"SV",
00031     L"sAMAccountName",          L"DirectoryString",                 L"SV"
00032 };
00033
00034
00035 ////////////////////////////////////////////////////
00036 //        OptionalProperties
00037 ////////////////////////////////////////////////////
00038
00039 WCHAR * parwszUserOptionalProps []=
00040 {
00041     // Attrib Name                      Type                        Multi or Single Valued
00042     L"accountExpires",                  L"INTEGER8",              L"SV",
00043     L"aCSPolicyName",               L"DirectoryString",         L"SV",
00044     L"adminCount",                    L"INTEGER",                 L"SV",
00045     L"adminDescription",            L"DirectoryString",         L"SV",
00046     L"adminDisplayName",            L"DirectoryString",         L"SV",
00047     L"allowedAttributes",           L"OID",                     L"MV",
00048     L"allowedAttributesEffective",    L"OID",                     L"MV",
00049     L"allowedChildClasses",           L"OID",                     L"MV",
00050     L"allowedChildClassesEffective",  L"OID",                     L"MV",
00051     L"alternateSecurityIdentities",   L"IA5String",             L"MV",
00052     L"altRecipient",                L"DN",                      L"SV",
00053     L"altRecipientBL",                L"DN",                      L"MV",
00054     L"altSecurityIdentities",       L"DirectoryString",         L"MV",
00055     L"ancestorID",                    L"OctetString",             L"SV",
00056     L"assistant",                   L"DN",                      L"SV",
00057     L"assocRemoteDXA",                L"DN",                      L"MV",
00058     L"attributeCertificate",        L"OctetString",             L"MV",
00059     L"AuthOrig",                    L"ORName",                  L"MV",
00060     L"AuthOrigBL",                    L"DN",                      L"MV",
00061     L"autoReply",                   L"Boolean",                 L"SV",
00062     L"autoReplyMessage",            L"DirectoryString",         L"SV",
00063     L"autoReplySubject",            L"DirectoryString",         L"SV",
00064     L"badPasswordTime",               L"INTEGER8",              L"SV",
00065     L"badPwdCount",                   L"INTEGER",                 L"SV",
00066     L"bridgeheadServerListBL",        L"DN",                      L"MV",
00067     L"c",                           L"DirectoryString",         L"SV",
00068     L"CanCreatePFBL",               L"DN",                      L"MV",
00069     L"CanCreatePFDLBL",               L"DN",                      L"MV",
00070     L"CanNotCreatePFBL",            L"DN",                      L"MV",
00071     L"CanNotCreatePFDLBL",            L"DN",                      L"MV",
00072     L"canonicalName",               L"DirectoryString",         L"MV",
00073     L"co",                            L"DirectoryString",         L"SV",
00074     L"codePage",                    L"INTEGER",                 L"SV",
00075     L"comment",                       L"DirectoryString",         L"SV",
00076     L"controlAccessRights",           L"OctetString",             L"MV",
00077     L"countryCode",                   L"INTEGER",                 L"SV",
00078     L"createTimeStamp",               L"GeneralizedTime",         L"SV",
00079     L"dBCSPwd",                       L"OctetString",             L"SV",
00080     L"defaultClassStore",           L"DN",                      L"MV",
00081     L"deletedItemFlags",            L"INTEGER",                 L"SV",
00082     L"delivContLength",               L"INTEGER",                 L"SV",
00083     L"delivEITs",                   L"OctetString",             L"MV",
00084     L"deliverAndRedirect",            L"Boolean",                 L"SV",
00085     L"delivExtContTypes",           L"OctetString",             L"MV",
00086     L"department",                    L"DirectoryString",         L"SV",
00087     L"description",                   L"DirectoryString",         L"MV",
00088     L"desktopProfile",                L"DirectoryString",         L"SV",
00089     L"destinationIndicator",        L"PrintableString",         L"MV",
00090     L"directReports",               L"DN",                      L"MV",
00091     L"displayName",                   L"DirectoryString",         L"SV",
00092     L"displayNamePrintable",        L"PrintableString",         L"SV",
00093     L"distinguishedName",           L"DN",                      L"SV",
00094     L"division",                    L"DirectoryString",         L"SV",
00095     L"DLMemRejectPerms",            L"ORName",                  L"MV",
00096     L"DLMemRejectPermsBL",            L"DN",                      L"MV",
00097     L"DLMemSubmitPerms",            L"ORName",                  L"MV",
00098     L"DLMemSubmitPermsBL",            L"DN",                      L"MV",
00099     L"dnQualifier",                   L"DirectoryString",         L"SV",
00100     L"dSASignature",                L"OctetString",             L"SV",
00101     L"dynamicLDAPServer",           L"DN",                      L"SV",
00102     L"employeeID",                    L"DirectoryString",         L"SV",
00103     L"expirationTime",                L"UTCTime",                 L"SV",
00104     L"extensionAttribute1",           L"DirectoryString",         L"SV",
00105     L"extensionAttribute10",        L"DirectoryString",         L"SV",
00106     L"extensionAttribute11",        L"DirectoryString",         L"SV",
00107     L"extensionAttribute12",        L"DirectoryString",         L"SV",
00108     L"extensionAttribute13",        L"DirectoryString",         L"SV",
00109     L"extensionAttribute14",        L"DirectoryString",         L"SV",
00110     L"extensionAttribute15",        L"DirectoryString",         L"SV",
00111     L"extensionAttribute2",           L"DirectoryString",         L"SV",
00112     L"extensionAttribute3",           L"DirectoryString",         L"SV",
00113     L"extensionAttribute4",           L"DirectoryString",         L"SV",
00114     L"extensionAttribute5",           L"DirectoryString",         L"SV",
00115     L"extensionAttribute6",           L"DirectoryString",         L"SV",
00116     L"extensionAttribute7",           L"DirectoryString",         L"SV",
00117     L"extensionAttribute8",           L"DirectoryString",         L"SV",
00118     L"extensionAttribute9",           L"DirectoryString",         L"SV",
00119     L"extensionData",               L"OctetString",             L"MV",
00120     L"extensionName",               L"DirectoryString",         L"MV",
00121     L"extensionNameInherited",        L"DirectoryString",         L"MV",
00122     L"facsimileTelephoneNumber",    L"DirectoryString",         L"SV",
00123     L"flags",                       L"INTEGER",                 L"SV",
00124     L"forwardingAddress",           L"DirectoryString",         L"SV",
00125     L"fromEntry",                   L"Boolean",                 L"MV",
00126     L"frsComputerReferenceBL",        L"DN",                      L"MV",
00127     L"fRSMemberReferenceBL",        L"DN",                      L"MV",
00128     L"fSMORoleOwner",               L"DN",                      L"SV",
00129     L"garbageCollPeriod",           L"INTEGER",                 L"SV",
00130     L"gatewayProxy",                L"DirectoryString",         L"MV",
00131     L"generationQualifier",           L"DirectoryString",         L"SV",
00132     L"givenName",                   L"DirectoryString",         L"SV",
00133     L"gPLink",                        L"DirectoryString",         L"SV",
00134     L"gPOptions",                   L"INTEGER",                 L"SV",
00135     L"groupMembershipSAM",            L"OctetString",             L"SV",
00136     L"groupPriority",               L"DirectoryString",         L"MV",
00137     L"groupsToIgnore",                L"DirectoryString",         L"MV",
00138     L"heuristics",                    L"INTEGER",                 L"SV",
00139     L"homeDirectory",               L"DirectoryString",         L"SV",
00140     L"homeDrive",                   L"DirectoryString",         L"SV",
00141     L"homeMDB",                       L"DN",                      L"SV",
00142     L"homeMDBBL",                   L"DN",                      L"MV",
00143     L"homeMTA",                       L"DN",                      L"SV",
00144     L"homePhone",                   L"DirectoryString",         L"SV",
00145     L"homePostalAddress",           L"DirectoryString",         L"SV",
00146     L"iMOBuiltinAccountOpsGroup",   L"DN",                      L"MV",
00147     L"iMOBuiltinAdminGroup",        L"DN",                      L"MV",
00148     L"iMOBuiltinBackupGroup",       L"DN",                      L"MV",
00149     L"iMOBuiltinGuestGroup",        L"DN",                      L"MV",
00150     L"iMOBuiltinPrintOpsGroup",       L"DN",                      L"MV",
00151     L"iMOBuiltinReplicatorGroup",   L"DN",                      L"MV",
00152     L"iMOBuiltinServerOpsGroup",    L"DN",                      L"MV",
00153     L"iMOBuiltinUsersGroup",        L"DN",                      L"MV",
00154     L"importedFrom",                L"DirectoryString",         L"SV",
00155     L"incomingMsgSizeLimit",        L"INTEGER",                 L"SV",
00156     L"initials",                    L"DirectoryString",         L"SV",
00157     L"internationalISDNNumber",       L"NumericString",         L"MV",
00158     L"internetEncoding",            L"INTEGER",                 L"SV",
00159     L"ipPhone",                       L"DirectoryString",         L"SV",
00160     L"isCriticalSystemObject",        L"Boolean",                 L"SV",
00161     L"isDeleted",                   L"Boolean",                 L"SV",
00162     L"isPrivilegeHolder",           L"DN",                      L"MV",
00163     L"l",                           L"DirectoryString",         L"SV",
00164     L"LabeledURI",                    L"DirectoryString",         L"MV",
00165     L"language",                    L"DirectoryString",         L"SV",
00166     L"languageCode",                L"INTEGER",                 L"SV",
00167     L"lastKnownParent",               L"DN",                      L"SV",
00168     L"lastLogoff",                    L"INTEGER8",              L"SV",
00169     L"lastLogon",                   L"INTEGER8",              L"SV",
00170     L"legacyExchangeDN",            L"CaseIgnoreString",      L"SV",
00171     L"lmPwdHistory",                L"OctetString",             L"MV",
00172     L"localeID",                    L"INTEGER",                 L"MV",
00173     L"lockoutTime",                   L"INTEGER8",              L"SV",
00174     L"logonCount",                    L"INTEGER",                 L"SV",
00175     L"logonHours",                    L"OctetString",             L"SV",
00176     L"logonWorkstation",            L"OctetString",             L"SV",
00177     L"mail",                        L"DirectoryString",         L"SV",
00178     L"mailDrop",                    L"DirectoryString",         L"SV",
00179     L"mailNickname",                L"DirectoryString",         L"SV",
00180     L"maintainAutoReplyHistory",    L"Boolean",                 L"SV",
00181     L"managedObjects",                L"DN",                      L"MV",
00182     L"manager",                       L"DN",                      L"SV",
00183     L"mAPIRecipient",               L"Boolean",                 L"SV",
00184     L"maxStorage",                    L"INTEGER8",              L"SV",
00185     L"memberOf",                    L"DN",                      L"MV",
00186     L"mhsORAddress",                L"DirectoryString",         L"MV",
00187     L"middleName",                    L"DirectoryString",         L"SV",
00188     L"mobile",                        L"DirectoryString",         L"SV",
00189     L"modifyTimeStamp",               L"GeneralizedTime",         L"SV",
00190     L"mSMQDigests",                   L"OctetString",             L"MV",
00191     L"mSMQDigestsMig",                L"OctetString",             L"MV",
00192     L"mSMQSignCertificates",        L"OctetString",             L"SV",
00193     L"mSMQSignCertificatesMig",       L"OctetString",             L"SV",
00194     L"msNPAllowDialin",               L"Boolean",                 L"SV",
00195     L"msNPCallingStationID",        L"IA5String",             L"MV",
00196     L"msNPSavedCallingStationID",   L"IA5String",             L"MV",
00197     L"msRADIUSCallbackNumber",        L"IA5String",             L"SV",
00198     L"msRADIUSFramedIPAddress",       L"INTEGER",                 L"SV",
00199     L"msRADIUSFramedRoute",           L"IA5String",             L"MV",
00200     L"msRADIUSServiceType",           L"INTEGER",                 L"SV",
00201     L"msRASSavedCallbackNumber",    L"IA5String",             L"SV",
00202     L"msRASSavedFramedIPAddress",   L"INTEGER",                 L"SV",
00203     L"msRASSavedFramedRoute",       L"IA5String",             L"MV",
00204     L"name",                        L"DirectoryString",         L"SV",
00205     L"netbootSCPBL",                L"DN",                      L"SV",
00206     L"networkAddress",                L"CaseIgnoreString",      L"MV",
00207     L"nNTPCharacterSet",            L"DirectoryString",         L"SV",
00208     L"nNTPContentFormat",           L"DirectoryString",         L"SV",
00209     L"nNTPNewsfeeds",               L"DN",                      L"MV",
00210     L"nonSecurityMemberBL",           L"DN",                      L"MV",
00211     L"notes",                       L"DirectoryString",         L"SV",
00212     L"ntPwdHistory",                L"OctetString",             L"MV",
00213     L"o",                           L"DirectoryString",         L"MV",
00214     L"objectGUID",                    L"OctetString",             L"SV",
00215     L"objectVersion",               L"INTEGER",                 L"SV",
00216     L"objViewContainers",           L"DN",                      L"MV",
00217     L"operatorCount",               L"INTEGER",                 L"SV",
00218     L"otherFacsimileTelephoneNumber", L"DirectoryString",         L"MV",
00219     L"otherHomePhone",                L"DirectoryString",         L"MV",
00220     L"otherIpPhone",                L"DirectoryString",         L"MV",
00221     L"otherLoginWorkstations",        L"DirectoryString",         L"MV",
00222     L"otherMailbox",                L"DirectoryString",         L"MV",
00223     L"otherMobile",                   L"DirectoryString",         L"MV",
00224     L"otherPager",                    L"DirectoryString",         L"MV",
00225     L"otherTelephone",                L"DirectoryString",         L"MV",
00226     L"ou",                            L"DirectoryString",         L"MV",
00227     L"overrideNNTPContentFormat",   L"Boolean",                 L"SV",
00228     L"ownerBL",                       L"DN",                      L"SV",
00229     L"pager",                       L"DirectoryString",         L"SV",
00230     L"partialAttributeDeletionList",  L"OctetString",             L"SV",
00231     L"partialAttributeSet",           L"OctetString",             L"SV",
00232     L"periodReplStagger",           L"INTEGER",                 L"SV",
00233     L"periodRepSyncTimes",            L"OctetString",             L"SV",
00234     L"personalTitle",               L"DirectoryString",         L"SV",
00235     L"physicalDeliveryOfficeName",    L"DirectoryString",         L"SV",
00236     L"pOPCharacterSet",               L"DirectoryString",         L"SV",
00237     L"pOPContentFormat",            L"DirectoryString",         L"SV",
00238     L"possibleInferiors",           L"OID",                     L"MV",
00239     L"postalAddress",               L"DirectoryString",         L"MV",
00240     L"postalCode",                    L"DirectoryString",         L"SV",
00241     L"postOfficeBox",               L"DirectoryString",         L"MV",
00242     L"preferredDeliveryMethod",       L"INTEGER",                 L"MV",
00243     L"preferredOU",                   L"DN",                      L"SV",
00244     L"primaryGroupID",                L"INTEGER",                 L"SV",
00245     L"primaryInternationalISDNNumber",  L"DirectoryString",         L"SV",
00246     L"primaryTelexNumber",            L"DirectoryString",         L"SV",
00247     L"profilePath",                   L"DirectoryString",         L"SV",
00248     L"protocolSettings",            L"DirectoryString",         L"MV",
00249     L"proxiedObjectName",           L"DN",                      L"SV",
00250     L"proxyAddresses",                L"DirectoryString",         L"MV",
00251     L"publicDelegatesBL",           L"DN",                      L"MV",
00252     L"pwdLastSet",                    L"INTEGER8",              L"SV",
00253     L"queryPolicyBL",               L"DN",                      L"MV",
00254     L"registeredAddress",           L"OctetString",             L"MV",
00255     L"replicatedObjectVersion",       L"INTEGER",                 L"SV",
00256     L"replicationSensitivity",        L"INTEGER",                 L"SV",
00257     L"replPropertyMetaData",        L"OctetString",             L"SV",
00258     L"replUpToDateVector",            L"OctetString",             L"SV",
00259     L"repsFrom",                    L"OctetString",             L"MV",
00260     L"repsTo",                        L"OctetString",             L"MV",
00261     L"repsToExt",                   L"OctetString",             L"MV",
00262     L"reverseMembership",           L"OctetString",             L"MV",
00263     L"revision",                    L"INTEGER",                 L"SV",
00264     L"rid",                           L"INTEGER",                 L"SV",
00265     L"sAMAccountType",                L"INTEGER",                 L"SV",
00266     L"scriptPath",                    L"DirectoryString",         L"SV",
00267     L"securityIdentifier",            L"OctetString",             L"SV",
00268     L"securityProtocol",            L"OctetString",             L"MV",
00269     L"seeAlso",                       L"DN",                      L"MV",
00270     L"serverReferenceBL",           L"DN",                      L"SV",
00271     L"servicePrincipalName",        L"DirectoryString",         L"MV",
00272     L"showInAddressBook",           L"DN",                      L"MV",
00273     L"showInAdvancedViewOnly",        L"Boolean",                 L"SV",
00274     L"sIDHistory",                    L"OctetString",             L"MV",
00275     L"siteObjectBL",                L"DN",                      L"MV",
00276     L"sn",                            L"DirectoryString",         L"SV",
00277     L"st",                            L"DirectoryString",         L"SV",
00278     L"street",                        L"DirectoryString",         L"SV",
00279     L"streetAddress",               L"DirectoryString",         L"SV",
00280     L"submissionContLength",        L"INTEGER",                 L"SV",
00281     L"subRefs",                       L"DN",                      L"MV",
00282     L"subSchemaSubEntry",           L"DN",                      L"MV",
00283     L"supplementalCredentials",       L"OctetString",             L"MV",
00284     L"supportedAlgorithms",           L"OctetString",             L"SV",
00285     L"supportingStackBL",           L"DN",                      L"MV",
00286     L"systemFlags",                   L"INTEGER",                 L"SV",
00287     L"taggedCertificate",           L"OctetString",             L"MV",
00288     L"telephoneNumber",               L"DirectoryString",         L"SV",
00289     L"teletexTerminalIdentifier",   L"OctetString",             L"MV",
00290     L"telexNumber",                   L"OctetString",             L"MV",
00291     L"terminalServer",                L"OctetString",             L"SV",
00292     L"textEncodedORAddress",        L"DirectoryString",         L"SV",
00293     L"thumbnailLogo",               L"OctetString",             L"SV",
00294     L"thumbnailPhoto",                L"OctetString",             L"SV",
00295     L"title",                       L"DirectoryString",         L"SV",
00296     L"UnauthOrig",                    L"ORName",                  L"MV",
00297     L"UnauthOrigBL",                L"DN",                      L"MV",
00298     L"unicodePwd",                    L"OctetString",             L"SV",
00299     L"url",                           L"DirectoryString",         L"MV",
00300     L"userAccountControl",            L"INTEGER",                 L"SV",
00301     L"userCert",                    L"OctetString",             L"SV",
00302     L"userCertificate",               L"OctetString",             L"MV",
00303     L"userParameters",                L"DirectoryString",         L"SV",
00304     L"userPassword",                L"OctetString",             L"MV",
00305     L"userPrincipalName",           L"DirectoryString",         L"SV",
00306     L"userSharedFolder",            L"DirectoryString",         L"SV",
00307     L"userSharedFolderOther",       L"DirectoryString",         L"MV",
00308     L"userSMIMECertificate",        L"OctetString",             L"MV",
00309     L"userWorkstations",            L"DirectoryString",         L"SV",
00310     L"useServerValues",               L"Boolean",                 L"SV",
00311     L"uSNChanged",                    L"INTEGER8",              L"SV",
00312     L"uSNCreated",                    L"INTEGER8",              L"SV",
00313     L"uSNDSALastObjRemoved",        L"INTEGER8",              L"SV",
00314     L"USNIntersite",                L"INTEGER",                 L"SV",
00315     L"uSNLastObjRem",               L"INTEGER8",              L"SV",
00316     L"uSNSource",                   L"INTEGER8",              L"SV",
00317     L"viewContainer1",                L"DirectoryString",         L"SV",
00318     L"viewContainer2",                L"DirectoryString",         L"SV",
00319     L"viewContainer3",                L"DirectoryString",         L"SV",
00320     L"viewSite",                    L"DirectoryString",         L"SV",
00321     L"voiceMailFlags",                L"OctetString",             L"MV",
00322     L"voiceMailGreetings",            L"DirectoryString",         L"MV",
00323     L"voiceMailPassword",           L"DirectoryString",         L"SV",
00324     L"voiceMailRecordedName",       L"OctetString",             L"SV",
00325     L"voiceMailRecordingLength",    L"INTEGER",                 L"MV",
00326     L"voiceMailSpeed",                L"INTEGER",                 L"SV",
00327     L"voiceMailSystemGUID",           L"OctetString",             L"SV",
00328     L"voiceMailUserID",               L"DirectoryString",         L"SV",
00329     L"voiceMailVolume",               L"INTEGER",                 L"SV",
00330     L"wbemPath",                    L"DirectoryString",         L"MV",
00331     L"wellKnownObjects",            L"1.2.840.113556.1.4.903",  L"MV",
00332     L"whenChanged",                   L"GeneralizedTime",         L"SV",
00333     L"whenCreated",                   L"GeneralizedTime",         L"SV",
00334     L"wWWHomePage",                   L"DirectoryString",         L"SV",
00335     L"x121Address",                   L"NumericString",         L"MV",
00336     L"x500AccessControlList",       L"OctetString",             L"SV"
00337 };
00338
00339 BOOL FindAttribFromName(LPWSTR pwszName,WCHAR * pwsArray[],int iSize,LPWSTR * ppwszRetAttType, LPWSTR * ppwszRetAttribMultiOrSingle)
00340 {
00341     *ppwszRetAttType                  = NULL;
00342     *ppwszRetAttribMultiOrSingle      = NULL;
00343
00344     for (int x =0; x< iSize; x+=3)
00345         if (_wcsicmp(pwsArray[x],pwszName)==0)
00346         {
00347             *ppwszRetAttType              = pwsArray[x+1];
00348             *ppwszRetAttribMultiOrSingle  = pwsArray[x+2];
00349             return TRUE;
00350         }
00351     return FALSE;
00352 }
00353
00354 BOOL MapMandatoryUserAttribToType(LPWSTR pwszAttrib,LPWSTR *ppwszRetAttType, LPWSTR *ppwszRetAttribMultiOrSingle)
00355 {
00356     return FindAttribFromName(pwszAttrib,parwszUserMandatoryProps,sizeof(parwszUserMandatoryProps),ppwszRetAttType, ppwszRetAttribMultiOrSingle);
00357 }
00358
00359 BOOL MapOptionalUserAttribToType(LPWSTR pwszAttrib,LPWSTR *ppwszRetAttType, LPWSTR *ppwszRetAttribMultiOrSingle)
00360 {
00361     return FindAttribFromName(pwszAttrib,parwszUserOptionalProps,sizeof(parwszUserOptionalProps),ppwszRetAttType, ppwszRetAttribMultiOrSingle );
00362 }
00363
00364 BOOL MapUserAttribToType(LPWSTR pwszAttrib,LPWSTR *ppwszRetAttType, LPWSTR *ppwszRetAttribMultiOrSingle)
00365 {
00366     BOOL bret;
00367
00368     bret = MapMandatoryUserAttribToType(pwszAttrib,ppwszRetAttType, ppwszRetAttribMultiOrSingle);
00369
00370     if (!bret)
00371         bret = MapOptionalUserAttribToType(pwszAttrib,ppwszRetAttType, ppwszRetAttribMultiOrSingle);
00372
00373     return bret;
00374 }
00375
00376 struct ADSTYPEsyntaxmapping
00377 {
00378     LPWSTR pwszSyntax;
00379     ADSTYPE adsType;
00380 };
00381
00382 ADSTYPEsyntaxmapping aSyntaxMap[] =
00383 {
00384     { L"Boolean",                    ADSTYPE_BOOLEAN             },
00385     { L"Integer",              ADSTYPE_INTEGER             },
00386     { L"OctetString",          ADSTYPE_OCTET_STRING        },
00387
00388     // The following are
00389     // in ADS only
00390     { L"Counter",              ADSTYPE_INTEGER             },
00391     { L"ADsPath",              ADSTYPE_CASE_IGNORE_STRING  },
00392     { L"EmailAddress",         ADSTYPE_CASE_IGNORE_STRING  },
00393     { L"FaxNumber",            ADSTYPE_CASE_IGNORE_STRING  },
00394     { L"Interval",             ADSTYPE_INTEGER             },
00395     { L"List",                 ADSTYPE_OCTET_STRING        },
00396     { L"NetAddress",           ADSTYPE_CASE_IGNORE_STRING  },
00397     { L"Path",                 ADSTYPE_CASE_IGNORE_STRING  },
00398     { L"PhoneNumber",          ADSTYPE_CASE_IGNORE_STRING  },
00399     { L"PostalAddress",        ADSTYPE_CASE_IGNORE_STRING  },
00400     { L"SmallInterval",        ADSTYPE_INTEGER             },
00401     { L"String",               ADSTYPE_CASE_IGNORE_STRING  },
00402     { L"Time",                 ADSTYPE_UTC_TIME            },
00403
00404     // The following are in         NTDS only
00405     { L"INTEGER8",             ADSTYPE_LARGE_INTEGER       },
00406     { L"UTCTime",              ADSTYPE_UTC_TIME            },
00407     { L"DN",                   ADSTYPE_DN_STRING           },
00408     { L"OID",                  ADSTYPE_CASE_IGNORE_STRING  },
00409     { L"DirectoryString",      ADSTYPE_CASE_IGNORE_STRING  },
00410     { L"PrintableString",      ADSTYPE_PRINTABLE_STRING    },
00411     { L"CaseIgnoreString",     ADSTYPE_CASE_IGNORE_STRING  },
00412     { L"NumericString",        ADSTYPE_NUMERIC_STRING      },
00413     { L"IA5String",            ADSTYPE_PRINTABLE_STRING    },
00414     { L"PresentationAddresses",ADSTYPE_CASE_IGNORE_STRING  },
00415     { L"ORName",               ADSTYPE_INVALID             },
00416     { L"AccessPointDN",        ADSTYPE_INVALID             },
00417     { L"NTSecurityDescriptor", ADSTYPE_OCTET_STRING        },
00418     { L"GeneralizedTime",      ADSTYPE_UTC_TIME            }
00419
00420 };
00421
00422 // TAkes a String for the Adstype and returns the appropriate ADSTYPE enum
00423 ADSTYPE MapTypeToADSTYPE(LPWSTR pwszName)
00424 {
00425     int iSize = sizeof(aSyntaxMap);
00426
00427     for (int x =0; x< iSize; x++)
00428         if (_wcsicmp(aSyntaxMap[x].pwszSyntax,pwszName)==0)
00429             return aSyntaxMap[x].adsType;
00430     return ADSTYPE_UNKNOWN ;
00431 }
00432
00433
00434 struct ADSTYPE_TO_STRING_ENTRY
00435 {
00436     LPWSTR      pwszTypeName;
00437     ADSTYPE     AdsType;
00438 };
00439
00440 ADSTYPE_TO_STRING_ENTRY pAdsTypeToStringList []=
00441 {
00442     L"CaseExactString",  ADSTYPE_CASE_EXACT_STRING ,
00443     L"CaseIgnoreString", ADSTYPE_CASE_IGNORE_STRING ,
00444     L"",                 ADSTYPE_PRINTABLE_STRING ,
00445     L"",                 ADSTYPE_NUMERIC_STRING ,
00446     L"Boolean",          ADSTYPE_BOOLEAN ,
00447     L"",                 ADSTYPE_INTEGER ,
00448     L"", ADSTYPE_OCTET_STRING ,
00449     L"", ADSTYPE_UTC_TIME ,
00450     L"", ADSTYPE_LARGE_INTEGER ,
00451     L"", ADSTYPE_PROV_SPECIFIC ,
00452     L"", ADSTYPE_OBJECT_CLASS ,
00453     L"", ADSTYPE_CASEIGNORE_LIST ,
00454     L"", ADSTYPE_OCTET_LIST ,
00455     L"", ADSTYPE_PATH ,
00456     L"", ADSTYPE_POSTALADDRESS ,
00457     L"", ADSTYPE_TIMESTAMP ,
00458     L"", ADSTYPE_BACKLINK ,
00459     L"", ADSTYPE_TYPEDNAME ,
00460     L"", ADSTYPE_HOLD ,
00461     L"", ADSTYPE_NETADDRESS ,
00462     L"", ADSTYPE_REPLICAPOINTER ,
00463     L"", ADSTYPE_FAXNUMBER ,
00464     L"", ADSTYPE_EMAIL ,
00465     L"", ADSTYPE_NT_SECURITY_DESCRIPTOR ,
00466     L"", ADSTYPE_UNKNOWN
00467 } ;
00468
00469
00470 ADSTYPE MapAdsTypeFromString(LPWSTR pwszAdsType)
00471 {
00472 /*    //"1.2.840.113556.1.4.903",
00473   Boolean,
00474   CaseIgnoreString,
00475   DirectoryString,
00476   DN,
00477   GeneralizedTime,
00478   IA5String,
00479   INTEGER,
00480   INTEGER8,
00481   NumericString,
00482   ObjectSecurityDescriptor,
00483   OctetString,
00484   OID,
00485   ORName,
00486   PrintableString,
00487   UTCTime
00488 */
00489     if (_wcsicmp(pwszAdsType,L"Boolean")==0)
00490     {
00491         return ADSTYPE_BOOLEAN;
00492     }
00493     else if (_wcsicmp(pwszAdsType,L"CaseIgnoreString")==0)
00494     {
00495         return ADSTYPE_CASE_IGNORE_STRING;
00496     }
00497     else if (_wcsicmp(pwszAdsType,L"DirectoryString")==0)
00498     {
00499         return ADSTYPE_CASE_IGNORE_STRING;
00500     }
00501     else if (_wcsicmp(pwszAdsType,L"DN")==0)
00502     {
00503         return ADSTYPE_CASE_IGNORE_STRING;
00504     }
00505     else if (_wcsicmp(pwszAdsType,L"GeneralizedTime")==0)
00506     {
00507         return ADSTYPE_UTC_TIME;
00508     }
00509     else if (_wcsicmp(pwszAdsType,L"IA5String")==0)
00510     {
00511         return ADSTYPE_CASE_IGNORE_STRING;
00512     }
00513     else if (_wcsicmp(pwszAdsType,L"INTEGER")==0)
00514     {
00515         return ADSTYPE_INTEGER;
00516     }
00517     else if (_wcsicmp(pwszAdsType,L"INTEGER8")==0)
00518     {
00519         return ADSTYPE_LARGE_INTEGER;
00520     }
00521     else if (_wcsicmp(pwszAdsType,L"NumericString")==0)
00522     {
00523         return ADSTYPE_NUMERIC_STRING;
00524     }
00525     else if (_wcsicmp(pwszAdsType,L"ObjectSecurityDescriptor")==0)
00526     {
00527         return ADSTYPE_OCTET_STRING;
00528     }
00529     else if (_wcsicmp(pwszAdsType,L"OctetString")==0)
00530     {
00531         return ADSTYPE_OCTET_STRING ;
00532     }
00533     else if (_wcsicmp(pwszAdsType,L"OID")==0)
00534     {
00535         return ADSTYPE_OCTET_STRING;
00536     }
00537     else if (_wcsicmp(pwszAdsType,L"ORName")==0)
00538     {
00539         return ADSTYPE_CASE_IGNORE_STRING;
00540     }
00541     else if (_wcsicmp(pwszAdsType,L"PrintableString")==0)
00542     {
00543         return ADSTYPE_PRINTABLE_STRING;
00544     }
00545     else if (_wcsicmp(pwszAdsType,L"UTCTime")==0)
00546     {
00547         return ADSTYPE_UTC_TIME;
00548     }
00549     return ADSTYPE_UNKNOWN;
00550 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSkateboardFolder Member List

This is the complete list of members for CSkateboardFolder, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
children | CSkateboardFolder | [private]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
CSkateboardFolder() | CSkateboardFolder |
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetBitmapIndex() | CSkateboardFolder | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboardFolder | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CSkateboardFolder | [virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
getNodeType() | CSkateboardFolder | [inline, virtual]
GetParentScopeItem() | CSkateboardFolder | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CSkateboardFolder | [virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CSkateboardFolder | [virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CSkateboardFolder | [virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CSkateboardFolder | [virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CSkateboardFolder | [virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_hParentHScopeItem | CSkateboardFolder | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
NUMBER_OF_CHILDREN enum value | CSkateboardFolder | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSkateboardFolder | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CSkateboardFolder | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CSkateboardFolder | [virtual]
thisGuid | CSkateboardFolder | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
~CSkateboardFolder() | CSkateboardFolder | [virtual]
Generated on Wed Nov 13 2024 16:57:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Title.h Source File

  • WinUI
  • CommDlg
  • CDTest

Title.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 void DoTitleDialog(HWND) ;
00007
00008 INT_PTR APIENTRY TitleProc(HWND, UINT, WPARAM, LPARAM) ;
00009
00010 #define ID_PATHTI                   105
00011 #define ID_TITLETI                  106
00012 #define ID_BUFFSIZETI               107
00013 #define ID_RETURNTI                 108
00014
00015 #define ID_TITLEDIALOG              601
00016 #define ID_RESETTITLE               603
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/tracemacro.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

tracemacro.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "TraceMacro.h"
00017 #include <StdIo.h>             // Needed for sprintf on Win98
00018
00019
00020 //---------------------------------------------------------------------------
00021 //  Function implementations
00022 //
00023
00024 //---------------------------------------------------------------------------
00025 //  Provides trace output for HRESULTs in hex.
00026 //
00027 VOID Trace_HR
00028 (
00029   LPCTSTR pszClass,        //[in] Class name for message
00030   LPCTSTR pszFunction,     //[in] Function name for message
00031   HRESULT hr               //[in] HRESULT to display as a value
00032 )
00033 {
00034 #ifdef _DEBUG
00035
00036   TCHAR  szBuffer[512];
00037   TCHAR  szFormat[] = _T("%s::%s-> Returned 0x%X\n");
00038   INT    nChars     = 0;
00039
00040   nChars = _stprintf( szBuffer, szFormat, pszClass, pszFunction, hr );
00041   _ASSERTE( nChars < sizeof(szBuffer) );
00042
00043   OutputDebugString( szBuffer );
00044
00045 #endif
00046 } //end Trace_HR()
00047
00048
00049 //---------------------------------------------------------------------------
00050 //  Provides trace output for user defined numeric values in the form:
00051 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00052 //
00053 VOID Trace_Value
00054 (
00055   LPCTSTR pszClass,        //[in] Class name for message
00056   LPCTSTR pszFunction,     //[in] Function name for message
00057   LPCTSTR pszValueName,    //[in] Value name for message
00058   LONG    nValue           //[in] Numeric value for message
00059 )
00060 {
00061 #ifdef _DEBUG
00062
00063   TCHAR  szBuffer[512];
00064   TCHAR  szFormat[] = _T("%s::%s-> %s = %u\n");
00065   INT    nChars     = 0;
00066
00067   nChars = _stprintf( szBuffer,
00068                       szFormat,
00069                       pszClass,
00070                       pszFunction,
00071                       pszValueName,
00072                       nValue
00073                     );
00074   _ASSERTE( nChars < sizeof(szBuffer) );
00075
00076   OutputDebugString( szBuffer );
00077
00078 #endif
00079 } //end Trace_Value()
00080
00081 //---------------------------------------------------------------------------
00082 //  Provides trace output for user defined numeric values in the form:
00083 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00084 //
00085 VOID Trace_Pointer
00086 (
00087   LPCTSTR pszClass,        //[in] Class name for message
00088   LPCTSTR pszFunction,     //[in] Function name for message
00089   LPCTSTR pszAction,       //[in] Action which was taken
00090   ULONG   ulValue          //[in] Numeric value for message
00091 )
00092 {
00093 #ifdef _DEBUG
00094
00095   TCHAR  szBuffer[512];
00096   TCHAR  szFormat[] = _T("%s::%s-> %s = 0x%X\n");
00097   INT    nChars     = 0;
00098
00099   nChars = _stprintf( szBuffer,
00100                       szFormat,
00101                       pszClass,
00102                       pszFunction,
00103                       pszAction,
00104                       ulValue
00105                     );
00106   _ASSERTE( nChars < sizeof(szBuffer) );
00107
00108   OutputDebugString( szBuffer );
00109
00110 #endif
00111 } //end Trace_Pointer()
00112
00113
00114 //---------------------------------------------------------------------------
00115 //  Provides trace output which shows the class name, function name, and
00116 //  a string which maps to an MMC notification.
00117 //
00118 VOID Trace_Event
00119 (
00120   LPCTSTR pszClass,        //[in] Class name for message
00121   LPCTSTR pszFunction,     //[in] Event name for message
00122   LONG    nEvent           //[in] Event code to map to string
00123 )
00124 {
00125 #ifdef _DEBUG
00126
00127   TCHAR  szEventStr[64];
00128   TCHAR  szBuffer[512];
00129   TCHAR  szFormat[] = _T("%s::%s-> Event = %s\n");
00130   INT    nChars     = 0;
00131
00132   MapEvent( nEvent, szEventStr );
00133
00134   nChars = _stprintf( szBuffer,
00135                       szFormat,
00136                       pszClass,
00137                       pszFunction,
00138                       szEventStr
00139                     );
00140   _ASSERTE( nChars < sizeof(szBuffer) );
00141
00142   OutputDebugString( szBuffer );
00143
00144 #endif
00145 } //end Trace_Event()
00146
00147 //---------------------------------------------------------------------------
00148 //  Provides trace output which shows the class name and function name
00149 //
00150 VOID Trace_Start
00151 (
00152   LPCTSTR pszClass,        //[in] Class name for message
00153   LPCTSTR pszFunction      //[in] Event name for message
00154 )
00155 {
00156 #ifdef _DEBUG
00157
00158   TCHAR  szBuffer[512];
00159   TCHAR  szFormat[] = _T("%s::%s-> Started \n");
00160   INT    nChars     = 0;
00161
00162   nChars = _stprintf( szBuffer,
00163                       szFormat,
00164                       pszClass,
00165                       pszFunction
00166                     );
00167   _ASSERTE( nChars < sizeof(szBuffer) );
00168
00169   OutputDebugString( szBuffer );
00170
00171 #endif
00172 } //end Trace_Start()
00173
00174
00175
00176 //---------------------------------------------------------------------------
00177 // Provides human readable output for notifications
00178 //
00179 VOID MapEvent( LONG Event, LPTSTR szEventStr )
00180 {
00181 #ifdef _DEBUG
00182
00183   switch( Event )
00184   {
00185     case 0x8001:
00186       _tcscpy( szEventStr, _T("MMCN_ACTIVATE          ") );
00187       break;
00188
00189     case 0x8002:
00190       _tcscpy( szEventStr, _T("MMCN_ADD_IMAGES        ") );
00191       break;
00192
00193     case 0x8003:
00194       _tcscpy( szEventStr, _T("MMCN_BTN_CLICK         ") );
00195       break;
00196
00197     case 0x8004:
00198       _tcscpy( szEventStr, _T("MMCN_CLICK             ") );
00199       break;
00200
00201     case 0x8005:
00202       _tcscpy( szEventStr, _T("MMCN_COLUMN_CLICK       ") );
00203       break;
00204
00205     case 0x8006:
00206       _tcscpy( szEventStr, _T("MMCN_CONTEXTMENU        ") );
00207       break;
00208
00209     case 0x8007:
00210       _tcscpy( szEventStr, _T("MMCN_CUTORMOVE          ") );
00211       break;
00212
00213     case 0x8008:
00214       _tcscpy( szEventStr, _T("MMCN_DBLCLICK           ") );
00215       break;
00216
00217     case 0x8009:
00218       _tcscpy( szEventStr, _T("MMCN_DELETE             ") );
00219       break;
00220
00221     case 0x800A:
00222       _tcscpy( szEventStr, _T("MMCN_DESELECT_ALL       ") );
00223       break;
00224
00225     case 0x800B:
00226       _tcscpy( szEventStr, _T("MMCN_EXPAND             ") );
00227       break;
00228
00229     case 0x800C:
00230       _tcscpy( szEventStr, _T("MMCN_HELP               ") );
00231       break;
00232
00233     case 0x800D:
00234       _tcscpy( szEventStr, _T("MMCN_MENU_BTNCLICK      ") );
00235       break;
00236
00237     case 0x800E:
00238       _tcscpy( szEventStr, _T("MMCN_MINIMIZED          ") );
00239       break;
00240
00241     case 0x800F:
00242       _tcscpy( szEventStr, _T("MMCN_PASTE              ") );
00243       break;
00244
00245     case 0x8010:
00246       _tcscpy( szEventStr, _T("MMCN_PROPERTY_CHANGE    ") );
00247       break;
00248
00249     case 0x8011:
00250       _tcscpy( szEventStr, _T("MMCN_QUERY_PASTE        ") );
00251       break;
00252
00253     case 0x8012:
00254       _tcscpy( szEventStr, _T("MMCN_REFRESH            ") );
00255       break;
00256
00257     case 0x8013:
00258       _tcscpy( szEventStr, _T("MMCN_REMOVE_CHILDREN    ") );
00259       break;
00260
00261     case 0x8014:
00262       _tcscpy( szEventStr, _T("MMCN_RENAME             ") );
00263       break;
00264
00265     case 0x8015:
00266       _tcscpy( szEventStr, _T("MMCN_SELECT             ") );
00267       break;
00268
00269     case 0x8016:
00270       _tcscpy( szEventStr, _T("MMCN_SHOW               ") );
00271       break;
00272
00273     case 0x8017:
00274       _tcscpy( szEventStr, _T("MMCN_VIEW_CHANGE        ") );
00275       break;
00276
00277     case 0x8018:
00278       _tcscpy( szEventStr, _T("MMCN_SNAPINHELP         ") );
00279       break;
00280
00281     case 0x8019:
00282       _tcscpy( szEventStr, _T("MMCN_CONTEXTHELP        ") );
00283       break;
00284
00285     case 0x801A:
00286       _tcscpy( szEventStr, _T("MMCN_INITOCX            ") );
00287       break;
00288
00289     // MMC Version 1.1 notifications
00290     case 0x801B:
00291       _tcscpy( szEventStr, _T("MMCN_FILTER_CHANGE      ") );
00292       break;
00293
00294     case 0x801C:
00295       _tcscpy( szEventStr, _T("MMCN_FILTERBTN_CLICK    ") );
00296       break;
00297
00298     case 0x801D:
00299       _tcscpy( szEventStr, _T("MMCN_RESTORE_VIEW       ") );
00300       break;
00301
00302     case 0x801E:
00303       _tcscpy( szEventStr, _T("MMCN_PRINT              ") );
00304       break;
00305
00306     case 0x801F:
00307       _tcscpy( szEventStr, _T("MMCN_PRELOAD            ") );
00308       break;
00309
00310     case 0x8020:
00311       _tcscpy( szEventStr, _T("MMCN_LISTPAD            ") );
00312       break;
00313
00314     case 0x8021:
00315       _tcscpy( szEventStr, _T("MMCN_EXPANDSYNC         ") );
00316       break;
00317
00318     // MMC Version 1.2 notifications
00319     case 0x8022:
00320       _tcscpy( szEventStr, _T("MMCN_COLUMNS_CHANGED    ") );
00321       break;
00322
00323     // MMC Version 2.0 notifications
00324     case 0x8023:
00325       _tcscpy( szEventStr, _T("MMCN_CANPASTE_OUTOFPROC ") );
00326       break;
00327
00328     default:
00329       _stprintf( szEventStr, _T("0x%X"), Event );
00330       break;
00331   }
00332
00333 #endif
00334 } //end MapEvent()
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/registry.h Source File

  • SysMgmt
  • MMC
  • Proppage

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/PingResp/DllDatax.h Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • PingResp

DllDatax.h

Go to the documentation of this file.
00001 #if !defined(AFX_DLLDATAX_H__8C0B3D3C_DB1F_11D2_8C2B_00A0C9F422B8__INCLUDED_)
00002 #define AFX_DLLDATAX_H__8C0B3D3C_DB1F_11D2_8C2B_00A0C9F422B8__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007
00008 #ifdef _MERGE_PROXYSTUB
00009
00010 extern "C"
00011 {
00012 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
00013   LPVOID lpReserved);
00014 STDAPI PrxDllCanUnloadNow(void);
00015 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
00016 STDAPI PrxDllRegisterServer(void);
00017 STDAPI PrxDllUnregisterServer(void);
00018 }
00019
00020 #endif
00021
00022 //{{AFX_INSERT_LOCATION}}
00023 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00024
00025 #endif // !defined(AFX_DLLDATAX_H__8C0B3D3C_DB1F_11D2_8C2B_00A0C9F422B8__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpICommandText Member List

This is the complete list of members for CImpICommandText, including all inherited members.
Cancel() | CImpICommandText
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CCommand, CImpICommandText) | CImpICommandText
Execute(IUnknown *pUnkOuter, REFIID riid, DBPARAMS *pParams, DBROWCOUNT *pcRowsAffected, IUnknown **ppRowset) | CImpICommandText
GetCommandText(GUID *pguidDialect, LPOLESTR *ppwszCommand) | CImpICommandText
GetDBSession(REFIID riid, IUnknown **ppSession) | CImpICommandText
SetCommandText(REFGUID rguidDialect, LPCOLESTR pwszCommand) | CImpICommandText
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProppageUserUI Member List

This is the complete list of members for CProppageUserUI, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
CProppageUserUI(HWND hNotifyObj) | CProppageUserUI | [inline]
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
GetChangePictureButton() | CProppageUserUI | [inline, private]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetClearPictureButton() | CProppageUserUI | [inline, private]
GetIDEdit() | CProppageUserUI | [inline, private]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
GetPathEdit() | CProppageUserUI | [inline, private]
GetPicture() | CProppageUserUI | [inline, private]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [virtual]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
Init(PWSTR pszPath, PWSTR pszClass) | CProppageUserUI |
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hNotifyObj | CProppageUserUI | [private]
m_hWnd | CPropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_pIPropertyPageSite | CPropertyPage | [protected]
m_pWritableAttrs | CProppageUserUI | [private]
m_spDsObj | CProppageUserUI | [private]
m_szClass | CProppageUserUI | [private]
m_szPath | CProppageUserUI | [private]
m_thumbNailPhotoHolder | CProppageUserUI | [private]
Move(LPCRECT pRect) | CPropertyPage |
OnApply() | CProppageUserUI | [virtual]
OnChangePicture() | CProppageUserUI |
OnClearPicture() | CProppageUserUI |
OnDestroy() | CProppageUserUI | [virtual]
OnEmployeeIDChange() | CProppageUserUI |
OnInitDialog() | CProppageUserUI | [virtual]
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
SetUIData() | CProppageUserUI | [private]
SetUIEmployeeID() | CProppageUserUI | [private]
SetUIPhoto() | CProppageUserUI | [private]
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
WriteEmployeeID() | CProppageUserUI | [private]
~CPropertyPage() | CPropertyPage | [virtual]
~CProppageUserUI() | CProppageUserUI | [inline]
Generated on Wed Nov 13 2024 16:57:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIPersistFile Member List

This is the complete list of members for CImpIPersistFile, including all inherited members.
CImpIPersistFile(PCFileViewer, LPUNKNOWN) | CImpIPersistFile |
GetClassID(LPCLSID) | CImpIPersistFile |
GetCurFile(LPOLESTR *) | CImpIPersistFile |
IsDirty(void) | CImpIPersistFile |
Load(LPCOLESTR, DWORD) | CImpIPersistFile |
m_pObj | CImpIPersistFile | [private]
m_pUnkOuter | CImpIPersistFile | [private]
QueryInterface(REFIID, PPVOID) | CImpIPersistFile |
Save(LPCOLESTR, BOOL) | CImpIPersistFile |
SaveCompleted(LPCOLESTR) | CImpIPersistFile |
STDMETHODIMP_(ULONG) AddRef(void) | CImpIPersistFile |
STDMETHODIMP_(ULONG) Release(void) | CImpIPersistFile |
~CImpIPersistFile(void) | CImpIPersistFile |
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/Common.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

Common.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      Common.h
00005 //
00006 //  Description:
00007 //      Macros that wrap calling IClusCfgCallback::SendStatusReport.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #pragma once
00012
00013
00014 //////////////////////////////////////////////////////////////////////////////
00015 //  SendStatusReport Logging Macros
00016 //
00017 //  The following macros are used to simplify the usage of the
00018 //  SendStatusReport function and tidy up the code by removing these often
00019 //  used code patterns.
00020 //
00021 //////////////////////////////////////////////////////////////////////////////
00022 #define LOG_STATUS_REPORT( _pwsz_, _hr_ ) \
00023     HrSendStatusReport( \
00024                           TASKID_Major_Update_Progress \
00025                         , TASKID_Major_Server_Log \
00026                         , 1 \
00027                         , 1 \
00028                         , 1 \
00029                         , _hr_\
00030                         , _pwsz_ \
00031                         , (UINT)NULL \
00032                         )
00033
00034 #define LOG_STATUS_REPORT_MINOR( _minor_, _pwsz_, _hr_ ) \
00035     HrSendStatusReport( \
00036                           TASKID_Major_Server_Log \
00037                         , _minor_ \
00038                         , 1 \
00039                         , 1 \
00040                         , 1 \
00041                         , _hr_ \
00042                         , _pwsz_ \
00043                         , (UINT)NULL \
00044                         )
00045
00046 #define LOG_STATUS_REPORT_MINOR_STRING( _minor_, _pwszFormat_, _arg0_, _hr_ ) \
00047     { \
00048         BSTR    _bstrMsg_ = NULL; \
00049         HRESULT _hrTemp_; \
00050         \
00051         _hrTemp_ = HrFormatStringIntoBSTR( _pwszFormat_, &_bstrMsg_, _arg0_ ); \
00052         _hrTemp_ = HrSendStatusReport( \
00053                               TASKID_Major_Server_Log \
00054                             , _minor_ \
00055                             , 1 \
00056                             , 1 \
00057                             , 1 \
00058                             , _hr_ \
00059                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00060                             , (UINT) 0 \
00061                             ); \
00062         if ( FAILED( _hrTemp_ ) && SUCCEEDED( _hr_ ) ) \
00063         { \
00064             _hr_ = _hrTemp_; \
00065         } \
00066         \
00067         SysFreeString( _bstrMsg_ ); \
00068     }
00069
00070 #define LOG_STATUS_REPORT_STRING( _pwszFormat_, _arg0_, _hr_ ) \
00071     { \
00072         BSTR    _bstrMsg_ = NULL; \
00073         HRESULT _hrTemp_; \
00074         \
00075         _hrTemp_ = HrFormatStringIntoBSTR( _pwszFormat_, &_bstrMsg_, _arg0_ ); \
00076         _hrTemp_ = HrSendStatusReport( \
00077                               TASKID_Major_Update_Progress \
00078                             , TASKID_Major_Server_Log \
00079                             , 1 \
00080                             , 1 \
00081                             , 1 \
00082                             , _hr_ \
00083                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00084                             , (UINT) 0 \
00085                             ); \
00086         if ( FAILED( _hrTemp_ ) && SUCCEEDED( _hr_ ) ) \
00087         { \
00088             _hr_ = _hrTemp_; \
00089         } \
00090         \
00091         SysFreeString( _bstrMsg_ ); \
00092     }
00093
00094 #define LOG_STATUS_REPORT_STRING2( _pwszFormat_, _arg0_, _arg1_, _hr_ ) \
00095     { \
00096         BSTR    _bstrMsg_ = NULL; \
00097         HRESULT _hrTemp_; \
00098         \
00099         _hrTemp_ = HrFormatStringIntoBSTR( _pwszFormat_, &_bstrMsg_, _arg0_, _arg1_ ); \
00100         _hrTemp_ = HrSendStatusReport( \
00101                               TASKID_Major_Update_Progress \
00102                             , TASKID_Major_Server_Log \
00103                             , 1 \
00104                             , 1 \
00105                             , 1 \
00106                             , _hr_\
00107                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00108                             , (UINT) 0 \
00109                             ); \
00110         if ( FAILED( _hrTemp_ ) ) \
00111         { \
00112             _hr_ = _hrTemp_; \
00113         } \
00114         \
00115         SysFreeString( _bstrMsg_ ); \
00116     }
00117
00118 #define LOG_STATUS_REPORT_STRING3( _pwszFormat_, _arg0_, _arg1_, _arg2_, _hr_ ) \
00119     { \
00120         BSTR    _bstrMsg_ = NULL; \
00121         HRESULT _hrTemp_; \
00122         \
00123         _hrTemp_ = HrFormatStringIntoBSTR( _pwszFormat_, &_bstrMsg_, _arg0_, _arg1_, _arg2_ ); \
00124         _hrTemp_ = HrSendStatusReport( \
00125                               TASKID_Major_Update_Progress \
00126                             , TASKID_Major_Server_Log \
00127                             , 1 \
00128                             , 1 \
00129                             , 1 \
00130                             , _hr_\
00131                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00132                             , (UINT) 0 \
00133                             ); \
00134         if ( FAILED( _hrTemp_ ) ) \
00135         { \
00136             _hr_ = _hrTemp_; \
00137         } \
00138         \
00139         SysFreeString( _bstrMsg_ ); \
00140     }
00141
00142 #define LOG_STATUS_REPORT_STRING4( _pwszFormat_, _arg0_, _arg1_, _arg2_, _arg3_, _hr_ ) \
00143     { \
00144         BSTR    _bstrMsg_ = NULL; \
00145         HRESULT _hrTemp_; \
00146         \
00147         _hrTemp_ = HrFormatStringIntoBSTR( _pwszFormat_, &_bstrMsg_, _arg0_, _arg1_, _arg2_, _arg3_ ); \
00148         _hrTemp_ = HrSendStatusReport( \
00149                               TASKID_Major_Update_Progress \
00150                             , TASKID_Major_Server_Log \
00151                             , 1 \
00152                             , 1 \
00153                             , 1 \
00154                             , _hr_\
00155                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00156                             , (UINT) 0 \
00157                             ); \
00158         if ( FAILED( _hrTemp_ ) ) \
00159         { \
00160             _hr_ = _hrTemp_; \
00161         } \
00162         \
00163         SysFreeString( _bstrMsg_ ); \
00164     }
00165
00166 #define STATUS_REPORT_REF( _major_, _minor_, _idsMsg_, _idsRef_, _hr_ ) \
00167     HrSendStatusReport( \
00168                       _major_ \
00169                     , _minor_ \
00170                     , 1 \
00171                     , 1 \
00172                     , 1 \
00173                     , _hr_ \
00174                     , (DWORD) _idsMsg_ \
00175                     , (DWORD) _idsRef_ \
00176                     )
00177
00178 #define STATUS_REPORT_STRING( _major_, _minor_, _idsFormat_, _arg0_, _hr_ ) \
00179     { \
00180         BSTR    _bstrMsg_ = NULL; \
00181         HRESULT _hrTemp_; \
00182         \
00183         _hrTemp_ = HrFormatStringIntoBSTR( NULL, _idsFormat_, &_bstrMsg_, _arg0_ ); \
00184         _hrTemp_ = HrSendStatusReport( \
00185                               _major_ \
00186                             , _minor_ \
00187                             , 1 \
00188                             , 1 \
00189                             , 1 \
00190                             , _hr_ \
00191                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00192                             , (UINT)0 \
00193                             , (UINT)0 \
00194                             ); \
00195         if ( FAILED( _hrTemp_ ) ) \
00196         { \
00197             _hr_ = _hrTemp_; \
00198         } \
00199         \
00200         SysFreeString( _bstrMsg_ ); \
00201     }
00202
00203 #define STATUS_REPORT_STRING2( _major_, _minor_, _idsFormat_, _arg0_, _arg1_, _hr_ ) \
00204     { \
00205         BSTR    _bstrMsg_ = NULL; \
00206         HRESULT _hrTemp_; \
00207         \
00208         _hrTemp_ = HrFormatStringIntoBSTR( NULL, _idsFormat_, &_bstrMsg_, _arg0_, _arg1_ ); \
00209         _hrTemp_ = HrSendStatusReport( \
00210                               _major_ \
00211                             , _minor_ \
00212                             , 1 \
00213                             , 1 \
00214                             , 1 \
00215                             , _hr_ \
00216                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00217                             , (UINT)0 \
00218                             , (UINT)0 \
00219                             ); \
00220         if ( FAILED( _hrTemp_ ) ) \
00221         { \
00222             _hr_ = _hrTemp_; \
00223         } \
00224         \
00225         SysFreeString( _bstrMsg_ ); \
00226     }
00227
00228 #define STATUS_REPORT_STRING_REF( _major_, _minor_, _idsFormat_, _arg0_, _idsRef_, _hr_ ) \
00229     { \
00230         BSTR    _bstrMsg_ = NULL; \
00231         HRESULT _hrTemp_; \
00232         \
00233         _hrTemp_ = HrFormatStringIntoBSTR( NULL, _idsFormat_, &_bstrMsg_, _arg0_ ); \
00234         _hrTemp_ = HrSendStatusReport( \
00235                               _major_ \
00236                             , _minor_ \
00237                             , 1 \
00238                             , 1 \
00239                             , 1 \
00240                             , _hr_ \
00241                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00242                             , _idsRef_ \
00243                             , NULL \
00244                             ); \
00245         if ( FAILED( _hrTemp_ ) ) \
00246         { \
00247             _hr_ = _hrTemp_; \
00248         } \
00249         \
00250         SysFreeString( _bstrMsg_ ); \
00251     }
00252
00253 #define STATUS_REPORT_STRING2_REF( _major_, _minor_, _idsFormat_, _arg0_, _arg1_, _idsRef_, _hr_ ) \
00254     { \
00255         BSTR    _bstrMsg_ = NULL; \
00256         HRESULT _hrTemp_; \
00257         \
00258         _hrTemp_ = HrFormatStringIntoBSTR( NULL, _idsFormat_, &_bstrMsg_, _arg0_, _arg1_ ); \
00259         _hrTemp_ = HrSendStatusReport( \
00260                               _major_ \
00261                             , _minor_ \
00262                             , 1 \
00263                             , 1 \
00264                             , 1 \
00265                             , _hr_ \
00266                             , _hrTemp_ == S_OK ? _bstrMsg_ : L"The description for this entry could not be located." \
00267                             , _idsRef_ \
00268                             , NULL \
00269                             ); \
00270         if ( FAILED( _hrTemp_ ) ) \
00271         { \
00272             _hr_ = _hrTemp_; \
00273         } \
00274         \
00275         SysFreeString( _bstrMsg_ ); \
00276     }
00277
00278 #define STATUS_REPORT( _major_, _minor_, _uid_, _hr_ ) \
00279     HrSendStatusReport( \
00280                           _major_ \
00281                         , _minor_ \
00282                         , 1 \
00283                         , 1 \
00284                         , 1 \
00285                         , _hr_\
00286                         , _uid_ \
00287                         , NULL \
00288                         )
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/Debug.Cpp Source File

  • Web
  • NetMeeting
  • NMUI

Debug.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       DEBUG.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016 #include <atlbase.h>
00017 #include <atlconv.h>
00018
00019
00020 #define STRING_CASE(val)               case val: pcsz = TEXT(#val); break
00021
00022 //****************************************************************************
00023 //
00024 // LPCTSTR GetHrSz(HRESULT hr)
00025 //
00026 //****************************************************************************
00027
00028 LPCTSTR GetHrSz(HRESULT hr)
00029 {
00030   LPCTSTR pcsz  = NULL;
00031   static TCHAR _szHRESULT[128];
00032
00033   switch (hr)
00034     {
00035   STRING_CASE(S_OK);
00036   STRING_CASE(S_FALSE);
00037
00038   STRING_CASE(NM_E_NOT_INITIALIZED);
00039   STRING_CASE(NM_E_CHANNEL_ALREADY_EXISTS);
00040   STRING_CASE(NM_E_NO_T120_CONFERENCE);
00041   STRING_CASE(NM_E_NOT_ACTIVE);
00042
00043   STRING_CASE(DRAGDROP_S_CANCEL);
00044   STRING_CASE(DRAGDROP_S_DROP);
00045   STRING_CASE(DRAGDROP_S_USEDEFAULTCURSORS);
00046
00047   STRING_CASE(E_UNEXPECTED);
00048   STRING_CASE(E_NOTIMPL);
00049   STRING_CASE(E_OUTOFMEMORY);
00050   STRING_CASE(E_INVALIDARG);
00051   STRING_CASE(E_NOINTERFACE);
00052   STRING_CASE(E_POINTER);
00053   STRING_CASE(E_HANDLE);
00054   STRING_CASE(E_ABORT);
00055   STRING_CASE(E_FAIL);
00056   STRING_CASE(E_ACCESSDENIED);
00057
00058   STRING_CASE(CLASS_E_NOAGGREGATION);
00059
00060   STRING_CASE(CO_E_NOTINITIALIZED);
00061   STRING_CASE(CO_E_ALREADYINITIALIZED);
00062   STRING_CASE(CO_E_INIT_ONLY_SINGLE_THREADED);
00063
00064   STRING_CASE(REGDB_E_INVALIDVALUE);
00065   STRING_CASE(REGDB_E_CLASSNOTREG);
00066   STRING_CASE(REGDB_E_IIDNOTREG);
00067
00068   STRING_CASE(DV_E_DVASPECT);
00069   STRING_CASE(DV_E_LINDEX);
00070   STRING_CASE(DV_E_TYMED);
00071   STRING_CASE(DV_E_FORMATETC);
00072
00073   default:
00074     ZeroMemory(_szHRESULT, 128 * sizeof(TCHAR));
00075     _sntprintf(_szHRESULT, 127, TEXT("%#lx\0"), hr);
00076     pcsz = _szHRESULT;
00077     break;
00078     }
00079
00080   return pcsz;
00081 }
00082
00083
00084 //****************************************************************************
00085 //
00086 // LPCTSTR GetConfnSz(CONFN confn)
00087 //
00088 //****************************************************************************
00089
00090 LPCTSTR GetConfnSz(CONFN confn)
00091 {
00092   LPCTSTR pcsz  = NULL;
00093   static TCHAR _szMsg[256];
00094
00095   switch (confn)
00096     {
00097   STRING_CASE(CONFN_FT_UI);
00098   STRING_CASE(CONFN_FT_OFFERED);
00099   STRING_CASE(CONFN_FT_STARTED);
00100   STRING_CASE(CONFN_FT_PROGRESS);
00101   STRING_CASE(CONFN_FT_COMPLETE);
00102   STRING_CASE(CONFN_FT_CANCELED);
00103
00104   STRING_CASE(CONFN_CALL_INCOMPATIBLE);
00105   STRING_CASE(CONFN_CALL_OLDER);
00106   STRING_CASE(CONFN_CALL_NEWER);
00107   STRING_CASE(CONFN_CALL_IGNORED);
00108   STRING_CASE(CONFN_CALL_FAILED);
00109   STRING_CASE(CONFN_CALL_IN_CONFERENCE);
00110
00111   STRING_CASE(CONFN_NM_STARTED);
00112   STRING_CASE(CONFN_NM_STOPPED);
00113
00114   default:
00115     ZeroMemory(_szMsg, 256 * sizeof(TCHAR));
00116     _sntprintf(_szMsg, 255, TEXT("CONFN_%08X\0"), confn);
00117     pcsz = _szMsg;
00118     break;
00119     }
00120   return pcsz;
00121 }
00122
00123
00124 //****************************************************************************
00125 //
00126 // LPCTSTR GetNmchSz(ULONG uch)
00127 //
00128 //****************************************************************************
00129
00130 LPCTSTR GetNmchSz(ULONG uch)
00131 {
00132   LPCTSTR pcsz  = NULL;
00133   static TCHAR _szMsg[256];
00134
00135   switch (uch)
00136     {
00137   case NMCH_DATA:  pcsz = TEXT("Data");  break;
00138   case NMCH_AUDIO: pcsz = TEXT("Audio"); break;
00139   case NMCH_VIDEO: pcsz = TEXT("Video"); break;
00140   case NMCH_SHARE: pcsz = TEXT("Share"); break;
00141   case NMCH_FT:    pcsz = TEXT("Ft");    break;
00142
00143   case NMCH_ALL:
00144   case NMCH_NONE:
00145   default:
00146     ZeroMemory(_szMsg, 256 * sizeof(TCHAR));
00147     _sntprintf(_szMsg, 255, TEXT("%04X\0"), uch);
00148     pcsz = _szMsg;
00149     break;
00150     }
00151   return pcsz;
00152 }
00153
00154
00155 //****************************************************************************
00156 //
00157 // LPCTSTR GetCallStateSz(NM_CALL_STATE uState)
00158 //
00159 //****************************************************************************
00160
00161 LPCTSTR GetCallStateSz(NM_CALL_STATE uState)
00162 {
00163   LPCTSTR pcsz  = NULL;
00164   static TCHAR _szMsg[256];
00165
00166   switch (uState)
00167     {
00168   STRING_CASE(NM_CALL_INVALID);
00169   STRING_CASE(NM_CALL_INIT);
00170   STRING_CASE(NM_CALL_RING);
00171   STRING_CASE(NM_CALL_SEARCH);
00172   STRING_CASE(NM_CALL_WAIT);
00173   STRING_CASE(NM_CALL_ACCEPTED);
00174   STRING_CASE(NM_CALL_REJECTED);
00175   STRING_CASE(NM_CALL_CANCELED);
00176
00177   default:
00178     ZeroMemory(_szMsg, 256 * sizeof(TCHAR));
00179     _sntprintf(_szMsg, 255, TEXT("NM_CALL_%04X\0"), uState);
00180     pcsz = _szMsg;
00181     break;
00182     }
00183   return pcsz;
00184 }
00185
00186
00187 //****************************************************************************
00188 //
00189 // LPCTSTR GetConferenceStateSz(NM_CONFERENCE_STATE uState)
00190 //
00191 //****************************************************************************
00192
00193 LPCTSTR GetConferenceStateSz(NM_CONFERENCE_STATE uState)
00194 {
00195   LPCTSTR pcsz  = NULL;
00196   static TCHAR _szMsg[256];
00197
00198   switch (uState)
00199     {
00200   STRING_CASE(NM_CONFERENCE_IDLE);
00201   STRING_CASE(NM_CONFERENCE_WAITING);
00202   STRING_CASE(NM_CONFERENCE_INITIALIZING);
00203   STRING_CASE(NM_CONFERENCE_ACTIVE);
00204
00205   default:
00206     ZeroMemory(_szMsg, 256 * sizeof(TCHAR));
00207     _sntprintf(_szMsg, 255, TEXT("NM_CONFERENCE_%04X\0"), uState);
00208     pcsz = _szMsg;
00209     break;
00210     }
00211   return pcsz;
00212 }
00213
00214 //****************************************************************************
00215 //
00216 // LPCTSTR GetCollaborationStateSz(NM_SHARE_STATE uState)
00217 //
00218 //****************************************************************************
00219
00220 LPCTSTR GetCollaborationStateSz(NM_SHARE_STATE uState)
00221 {
00222   LPCTSTR pcsz  = NULL;
00223   static TCHAR _szMsg[256];
00224
00225   switch (uState)
00226     {
00227   STRING_CASE(NM_SHARE_COLLABORATING);
00228   STRING_CASE(NM_SHARE_UNKNOWN);
00229   STRING_CASE(NM_SHARE_IN_CONTROL);
00230   STRING_CASE(NM_SHARE_WORKING_ALONE);
00231
00232   default:
00233     ZeroMemory(_szMsg, 256 * sizeof(TCHAR));
00234     _sntprintf(_szMsg, 255, TEXT("NM_SHARE_%04X\0"), uState);
00235     pcsz = _szMsg;
00236     break;
00237     }
00238   return pcsz;
00239 }
00240 //****************************************************************************
00241 //
00242 // VOID FAR PASCAL AssertProc(LPTSTR lpszMsg, LPTSTR lpszAssert, LPTSTR lpszFile, UINT line)
00243 //
00244 //****************************************************************************
00245
00246 VOID FAR PASCAL AssertProc(LPTSTR lpszMsg, LPTSTR lpszAssert, LPTSTR lpszFile, UINT line)
00247 {
00248   int  id = 0;
00249   TCHAR szBuffer[1024]; // a big buffer
00250   ZeroMemory(szBuffer, 1024 * sizeof(TCHAR));
00251
00252   _sntprintf(szBuffer, 1023, TEXT("Assert: %s\nFile %s, Line %d"),
00253     (lpszMsg && *lpszMsg) ? lpszMsg : lpszAssert,
00254     lpszFile ? lpszFile : TEXT(""), line);
00255
00256 #ifdef DEBUG
00257   OutputDebugString(szBuffer);
00258 #endif
00259
00260   do {
00261     id = MessageBox(NULL, szBuffer, TEXT("NmUi Assert"),
00262           MB_ICONHAND | MB_ABORTRETRYIGNORE | MB_SYSTEMMODAL);
00263
00264     switch (id)
00265     {
00266     case IDRETRY:
00267       DebugBreak();
00268       break;
00269     case IDABORT:
00270       FatalAppExit(0, szBuffer);
00271       break;
00272     case IDIGNORE:
00273     default:
00274       break;
00275     }
00276   } while (id == IDRETRY);
00277 }
00278
00279
00280 //****************************************************************************
00281 //
00282 // VOID Log(COLORREF cv, LPTSTR pszMsg)
00283 //
00284 //****************************************************************************
00285
00286 VOID Log(COLORREF cv, LPTSTR pszMsg)
00287 {
00288   int iItem = SendMessage(ghwndMsg, LB_ADDSTRING, 0, (LPARAM) pszMsg);
00289
00290   SendMessage(ghwndMsg, LB_SETITEMDATA, (WPARAM)iItem, (LPARAM) cv);
00291
00292   PostMessage(ghwndMsg, WM_VSCROLL, SB_BOTTOM, 0);
00293 }
00294
00295 //****************************************************************************
00296 //
00297 // VOID ClearLog(void)
00298 //
00299 //****************************************************************************
00300
00301 VOID ClearLog(void)
00302 {
00303   SendMessage(ghwndMsg, LB_RESETCONTENT, 0, 0);
00304 }
00305
00306
00307 //****************************************************************************
00308 //
00309 // VOID TraceMsg(PSTR pszFormat,...)
00310 //
00311 //****************************************************************************
00312
00313 VOID TraceMsg(LPTSTR ptszFormat,...)
00314 {
00315
00316   TCHAR szMsg[1024];
00317   va_list v1;
00318
00319   ZeroMemory(szMsg, 1024 * sizeof(TCHAR));
00320
00321   va_start(v1, ptszFormat);
00322   _vsntprintf(szMsg, 1023, ptszFormat, v1);
00323   va_end(v1);
00324
00325   Log(RGB(0, 0, 0), szMsg);
00326
00327 #ifdef DEBUG
00328   OutputDebugString(szMsg);
00329   OutputDebugString(TEXT("\r\n"));
00330 #endif
00331 }
00332
00333
00334 //****************************************************************************
00335 //
00336 // VOID WarnMsg(PSTR pszFormat,...)
00337 //
00338 //****************************************************************************
00339
00340 VOID WarnMsg(LPTSTR ptszFormat,...)
00341 {
00342   TCHAR szMsg[1024];
00343   va_list v1;
00344
00345   ZeroMemory(szMsg, 1024 * sizeof(TCHAR));
00346
00347   va_start(v1, ptszFormat);
00348   _vsntprintf(szMsg, 1023, ptszFormat, v1);
00349   va_end(v1);
00350
00351   Log(RGB(0, 0, 255), szMsg);
00352
00353 #ifdef DEBUG
00354   OutputDebugString(szMsg);
00355   OutputDebugString(TEXT("\r\n"));
00356 #endif
00357 }
00358
00359
00360 //****************************************************************************
00361 //
00362 // VOID ErrorMsg(PSTR pszFormat,...)
00363 //
00364 //****************************************************************************
00365
00366 VOID ErrorMsg(LPTSTR ptszFormat,...)
00367 {
00368   TCHAR szMsg[1024];
00369   va_list v1;
00370
00371   ZeroMemory(szMsg, 1024 * sizeof(TCHAR));
00372
00373   va_start(v1, ptszFormat);
00374   _vsntprintf(szMsg, 1023, ptszFormat, v1);
00375   va_end(v1);
00376
00377   Log(RGB(255, 0, 0), szMsg);
00378
00379 #ifdef DEBUG
00380   OutputDebugString(szMsg);
00381   OutputDebugString(TEXT("\r\n"));
00382 #endif
00383 }
00384
00385
00386 //****************************************************************************
00387 //
00388 // VOID LogMsg(COLORREF cv, PSTR pszFormat,...)
00389 //
00390 //****************************************************************************
00391
00392 VOID LogMsg(COLORREF cv, LPTSTR tszFormat,...)
00393 {
00394   TCHAR tszMsg[1024];
00395   va_list v1;
00396
00397   ZeroMemory(tszMsg, 1024 * sizeof(TCHAR));
00398
00399   va_start(v1, tszFormat);
00400   _vsntprintf(tszMsg, 1023, tszFormat, v1);
00401   va_end(v1);
00402
00403   Log(cv, tszMsg);
00404
00405 #ifdef DEBUG
00406   OutputDebugString(tszMsg);
00407   OutputDebugString(TEXT("\r\n"));
00408 #endif
00409 }
00410
00411
00412 //****************************************************************************
00413 //
00414 // VOID DumpCallInfo(INmCall * pCall)
00415 //
00416 //****************************************************************************
00417
00418 VOID DumpCallInfo(INmCall * pCall)
00419 {
00420   HRESULT       hr      = NO_ERROR  ;
00421   BSTR        bstrName    = NULL    ;
00422   BSTR        bstrAddr    = NULL    ;
00423   NM_ADDR_TYPE    uType           ;
00424   NM_CALL_STATE   uState          ;
00425   INmConference * pConference = NULL    ;
00426
00427   OBJECT_MSG(TEXT("[%08X] - dump call info"), pCall);
00428   if (NULL == pCall)
00429   {
00430     ERROR_MSG(TEXT("DumpCallInfo: Invalid Call"));
00431     return;
00432   }
00433
00434   hr = pCall->GetName(&bstrName);
00435   if (FAILED(hr))
00436   {
00437     bstrName = NULL;
00438       ERROR_MSG(TEXT("DumpCallInfo: GetName failed"));
00439   }
00440
00441   hr = pCall->GetAddr(&bstrAddr, &uType);
00442   if (FAILED(hr))
00443   {
00444     bstrAddr = NULL;
00445     uType = NM_ADDR_UNKNOWN;
00446       ERROR_MSG(TEXT("DumpCallInfo: GetAddr failed"));
00447   }
00448
00449     if (FAILED(pCall->GetState(&uState)))
00450     {
00451     uState = NM_CALL_INVALID;
00452       ERROR_MSG(TEXT("DumpCallInfo: GetState failed"));
00453     }
00454
00455   hr = pCall->GetConference(&pConference);
00456   if (FAILED(hr))
00457   {
00458       WARN_MSG(TEXT("DumpCallInfo: GetConference failed %s"), GetHrSz(hr));
00459   }
00460   else if (NULL == pConference)
00461   {
00462     WARN_MSG(TEXT("DumpCallInfo: GetConference returned a null ptr"));
00463   }
00464
00465   TRACE_MSG(TEXT("Call=[%s] Addr=[%s], Type=%d, State=%s %s conf=%08X"),
00466     (LPTSTR) BTSTR(bstrName), (LPTSTR) BTSTR(bstrAddr),
00467     uType, GetCallStateSz(uState),
00468     (S_OK == pCall->IsIncoming()) ? TEXT("(Incoming)") : TEXT(""), pConference);
00469
00470   if (NULL != pConference)
00471   {
00472     pConference->Release();
00473     pConference = NULL;
00474   }
00475
00476   SysFreeString(bstrName);
00477   SysFreeString(bstrAddr);
00478 }
00479
00480
00481 //****************************************************************************
00482 //
00483 // VOID DumpAllCalls(void)
00484 //
00485 //****************************************************************************
00486
00487 VOID DumpAllCalls(void)
00488 {
00489   if (NULL == g_pListCall)
00490     return;
00491
00492   for (POSITION pos = g_pListCall->GetHeadPosition(); NULL != pos; )
00493   {
00494     INmCall * pCall = (INmCall *) g_pListCall->GetNext(pos);
00495     DumpCallInfo(pCall);
00496   }
00497 }
00498
00499
00500 //****************************************************************************
00501 //
00502 // VOID DumpConferenceInfo(INmConference * pConference)
00503 //
00504 //****************************************************************************
00505
00506 VOID DumpConferenceInfo(INmConference * pConference)
00507 {
00508   HRESULT       hr      = NO_ERROR  ;
00509   BSTR        bstr    = NULL    ;
00510   ULONG       cMember   = 0     ;
00511   ULONG       cChannel  = 0     ;
00512   NM_CONFERENCE_STATE uState          ;
00513
00514   if (NULL == pConference)
00515   {
00516     ERROR_MSG(TEXT("DumpConferenceInfo: Invalid conference"));
00517     return;
00518   }
00519
00520   hr = pConference->GetName(&bstr);
00521   if (FAILED(hr))
00522   {
00523     ERROR_MSG(TEXT("GetName failed"));
00524     bstr = NULL;
00525   }
00526
00527   hr = pConference->GetState(&uState);
00528   if (FAILED(hr))
00529   {
00530     ERROR_MSG(TEXT("GetState failed?"));
00531   }
00532
00533   hr = pConference->GetMemberCount(&cMember);
00534   if (FAILED(hr))
00535   {
00536     ERROR_MSG(TEXT("GetMemberCount failed"));
00537     cMember = 0;
00538   }
00539
00540   hr = pConference->GetChannelCount(&cChannel);
00541   if (FAILED(hr))
00542   {
00543     ERROR_MSG(TEXT("GetChannelCount failed"));
00544     cChannel = 0;
00545   }
00546
00547   TRACE_MSG(TEXT("[%08X] - Conference=[%s] state=%s"), pConference,
00548     (LPTSTR) BTSTR(bstr), GetConferenceStateSz(uState));
00549   TRACE_MSG(TEXT("  MemberCount=%d, ChannelCount=%d"), cMember, cChannel);
00550
00551   SysFreeString(bstr);
00552 }
00553
00554
00555 //****************************************************************************
00556 //
00557 // VOID DumpMemberInfo(INmMember * pMember)
00558 //
00559 //****************************************************************************
00560
00561 VOID DumpMemberInfo(INmMember * pMember)
00562 {
00563   HRESULT     hr      = NO_ERROR  ;
00564   BSTR      bstr    = NULL    ;
00565   BOOL      fLocal    = FALSE   ;
00566   BOOL      fMcu    = FALSE   ;
00567   BOOL      fTop    = FALSE   ;
00568   ULONG     uchCaps   = 0     ;
00569   ULONG     uVer    = 0     ;
00570   INmConference * pConference = NULL    ;
00571
00572   if  (NULL == pMember)
00573   {
00574     ERROR_MSG(TEXT("DumpMemberInfo: NULL == pMember"));
00575     return;
00576   }
00577
00578   hr = pMember->GetName(&bstr);
00579   if (FAILED(hr))
00580   {
00581     ERROR_MSG(TEXT("Problem with GetName"));
00582   }
00583
00584   hr = pMember->GetNmchCaps(&uchCaps);
00585   if (FAILED(hr))
00586   {
00587     ERROR_MSG(TEXT("Problem with GetNmchCaps"));
00588     uchCaps = 0;
00589   }
00590
00591   hr = pMember->GetNmVersion(&uVer);
00592   if (FAILED(hr))
00593   {
00594     ERROR_MSG(TEXT("Problem with GetNmVersion"));
00595     uVer = 0;
00596   }
00597
00598   fLocal = S_OK == pMember->IsSelf();
00599   fMcu = S_OK == pMember->IsMCU();
00600
00601   fTop = FALSE;
00602   hr = pMember->GetConference(&pConference);
00603   if (FAILED(hr) || (NULL == pConference))
00604   {
00605     TRACE_MSG(TEXT("Problem with GetConference"));
00606   }
00607   else
00608   {
00609     INmMember * pMemberTop  = NULL;
00610     if (SUCCEEDED(pConference->GetTopProvider(&pMemberTop)) && (NULL != pMemberTop))
00611     {
00612       fTop = (pMember == pMemberTop);
00613
00614       pMemberTop->Release();
00615       pMemberTop = NULL;
00616     }
00617
00618     pConference->Release();
00619     pConference = NULL;
00620   }
00621
00622   TRACE_MSG(TEXT("[%08X] Member=[%s] "), pMember, (LPTSTR) BTSTR(bstr));
00623   TRACE_MSG(TEXT("Local=%d, MCU=%d, Top=%d, uch=%08X, version=%d"), fLocal, fMcu, fTop, uchCaps, uVer);
00624
00625   SysFreeString(bstr);
00626 }
00627
00628
00629 //****************************************************************************
00630 //
00631 // VOID DumpChannelInfo(INmChannel * pChannel)
00632 //
00633 //****************************************************************************
00634
00635 VOID DumpChannelInfo(INmChannel * pChannel)
00636 {
00637   HRESULT hr    = NO_ERROR;
00638   ULONG uch   = 0;
00639   ULONG cMember = 0;
00640
00641   if  (NULL == pChannel)
00642   {
00643     ERROR_MSG(TEXT("DumpChannelInfo: NULL == pChannel"));
00644     return;
00645   }
00646
00647   hr = pChannel->GetNmch(&uch);
00648   if (FAILED(hr))
00649   {
00650     ERROR_MSG(TEXT("GetNmch failed"));
00651     uch = 0;
00652   }
00653
00654   hr = pChannel->GetMemberCount(&cMember);
00655   if (FAILED(hr))
00656   {
00657     ERROR_MSG(TEXT("GetMemberCount failed"));
00658     cMember = 0;
00659   }
00660
00661   TRACE_MSG(TEXT("[%08X] - Channel=[%s] MemberCount=%d"), pChannel, GetNmchSz(uch), cMember);
00662   switch (uch)
00663     {
00664   case NMCH_AUDIO:
00665   {
00666     INmChannelAudio * pChannelAudio = NULL;
00667     hr = pChannel->QueryInterface(IID_INmChannelAudio, (void **)&pChannelAudio);
00668     if (FAILED(hr))
00669     {
00670       ERROR_MSG(TEXT("Not an audio channel?"));
00671     }
00672     else if (NULL == pChannelAudio)
00673     {
00674       ERROR_MSG(TEXT("DumpChannelInfo: NULL == pChannelAudio"));
00675     }
00676     else
00677     {
00678       NM_AUDIO_STATE uState ;
00679       pChannelAudio->GetState(&uState);
00680       TRACE_MSG(TEXT("Audio State: %d"), uState);
00681       pChannelAudio->Release();
00682       pChannelAudio = NULL;
00683     }
00684     break;
00685   }
00686
00687   case NMCH_VIDEO:
00688     break;
00689
00690   case NMCH_DATA:
00691   {
00692     INmChannelData * pChannelData = NULL;
00693     hr = pChannel->QueryInterface(IID_INmChannelData, (void **)&pChannelData);
00694     if (FAILED(hr) || (NULL == pChannelData))
00695     {
00696       ERROR_MSG(TEXT("Not a data channel?"));
00697     }
00698     else
00699     {
00700       TRACE_MSG(TEXT("Data channel is %s"),
00701         (S_OK == pChannelData->IsActive()) ? TEXT("Active") : TEXT("Inactive"));
00702       pChannelData->Release();
00703       pChannelData = NULL;
00704     }
00705     break;
00706   }
00707   default:
00708     break;
00709     }
00710 }
00711
00712 //****************************************************************************
00713 //
00714 // VOID DoEnumChannelMember(INmChannel * pChannel)
00715 //
00716 //****************************************************************************
00717
00718 VOID DoEnumChannelMember(INmChannel * pChannel)
00719 {
00720   HRESULT       hr    = NO_ERROR;
00721   IEnumNmMember * pEnum   = NULL;
00722   ULONG       cFetched  = 0;
00723   ULONG       cMember = 0;
00724
00725   ASSERT(NULL != pChannel);
00726   if  (NULL == pChannel)
00727   {
00728     ERROR_MSG(TEXT("DoEnumChannelMember: NULL == pChannel"));
00729     return;
00730   }
00731
00732   hr = pChannel->GetMemberCount(&cMember);
00733   if (FAILED(hr))
00734   {
00735       ERROR_MSG(TEXT("GetMemberCount Failed (%s)"), GetHrSz(hr));
00736       return;
00737   }
00738   TRACE_MSG(TEXT("%d members in channel (%08X)"), cMember, pChannel);
00739
00740   if (0 == cMember)
00741     return;
00742
00743   if (cMember > 10)
00744     cMember = 10;
00745
00746   hr = pChannel->EnumMember(&pEnum);
00747   if (FAILED(hr))
00748   {
00749       ERROR_MSG(TEXT("EnumMember Failed (%s)"), GetHrSz(hr));
00750       return;
00751   }
00752   else if (NULL == pEnum)
00753   {
00754     ERROR_MSG(TEXT("EnumMember returned a Null ptr"));
00755     return;
00756   }
00757
00758   INmMember * rgpMember[10];
00759   for (int i = 0; i < 10; i++)
00760     rgpMember[i] = NULL;
00761
00762
00763   hr = pEnum->Next(cMember, rgpMember, &cFetched);
00764   if (FAILED(hr))
00765   {
00766       ERROR_MSG(TEXT("EnumMember Failed (%s)"), GetHrSz(hr));
00767   }
00768   else
00769   {
00770     for (UINT iMember = 0; iMember < cFetched; iMember++)
00771     {
00772       DumpMemberInfo(rgpMember[iMember]);
00773
00774       if  (NULL != rgpMember[iMember])
00775       {
00776         rgpMember[iMember]->Release();
00777         rgpMember[iMember] = NULL;
00778       }
00779     }
00780   }
00781
00782   pEnum->Release();
00783   pEnum = NULL;
00784 }
00785
00786
00787 //****************************************************************************
00788 //
00789 // VOID DoEnumConferenceMember(INmConference * pConference)
00790 //
00791 //****************************************************************************
00792
00793 VOID DoEnumConferenceMember(INmConference * pConference)
00794 {
00795   HRESULT       hr    = NO_ERROR;
00796   IEnumNmMember * pEnum   = NULL;
00797   ULONG       cFetched  = 0;
00798   ULONG       cMember = 0;
00799
00800   ASSERT(NULL != pConference);
00801   if  (NULL == pConference)
00802   {
00803     ERROR_MSG(TEXT("DoEnumConferenceMember: NULL == pConference"));
00804     return;
00805   }
00806
00807   hr = pConference->GetMemberCount(&cMember);
00808   if (FAILED(hr))
00809   {
00810       ERROR_MSG(TEXT("GetMemberCount Failed (%s)"), GetHrSz(hr));
00811       return;
00812   }
00813   TRACE_MSG(TEXT("%d members in conference (%08X)"), cMember, pConference);
00814
00815   if (cMember > 10)
00816     cMember = 10;
00817
00818   hr = pConference->EnumMember(&pEnum);
00819   if (FAILED(hr))
00820   {
00821       ERROR_MSG(TEXT("EnumMember Failed (%s)"), GetHrSz(hr));
00822       return;
00823   }
00824
00825   if  (NULL == pEnum)
00826   {
00827     ERROR_MSG(TEXT("EnumMember returned Null ptr"));
00828     return;
00829   }
00830
00831   INmMember * rgpMember[10];
00832   BSTR      bstrAddr  = NULL;
00833   NM_ADDR_TYPE  uType;
00834
00835   for (int i = 0; i < 10; i++)
00836     rgpMember[i] = NULL;
00837
00838   hr = pEnum->Next(cMember, rgpMember, &cFetched);
00839   if (FAILED(hr))
00840   {
00841       ERROR_MSG(TEXT("EnumMember Failed (%s)"), GetHrSz(hr));
00842   }
00843   else
00844   {
00845     for (UINT iMember = 0; iMember < cFetched; iMember++)
00846     {
00847       if  (NULL != rgpMember[iMember])
00848       {
00849         hr = rgpMember[iMember] ->GetAddr(&bstrAddr, &uType);
00850         DumpMemberInfo(rgpMember[iMember]);
00851         rgpMember[iMember]->Release();
00852         rgpMember[iMember] = NULL;
00853       }
00854       else
00855         ERROR_MSG(TEXT("rgpMember[iMember] == NULL"));
00856     }
00857   }
00858
00859   pEnum->Release();
00860   pEnum = NULL;
00861 }
00862
00863
00864 //****************************************************************************
00865 //
00866 // VOID DoEnumAll(void)
00867 //
00868 //****************************************************************************
00869
00870 VOID DoEnumAll(void)
00871 {
00872   HRESULT       hr    = NO_ERROR;
00873   IEnumNmChannel  * pEnum   = NULL;
00874   ULONG       cFetched  = 0;
00875   ULONG       cChannel  = 0;
00876   INmConference * pConference = GetCurrentConference();
00877
00878   if (NULL == pConference)
00879   {
00880     TRACE_MSG(TEXT("No current conference"));
00881     return;
00882   }
00883
00884   DumpConferenceInfo(pConference);
00885
00886   DoEnumConferenceMember(pConference);
00887
00888   hr = pConference->GetChannelCount(&cChannel);
00889   if (FAILED(hr))
00890   {
00891       ERROR_MSG(TEXT("GetChannelCount Failed (%s)"), GetHrSz(hr));
00892       return;
00893   }
00894   TRACE_MSG(TEXT("%d channels in conference"), cChannel);
00895
00896   if (cChannel > 10)
00897     cChannel = 10;
00898
00899   hr = pConference->EnumChannel(&pEnum);
00900   if (FAILED(hr))
00901   {
00902       ERROR_MSG(TEXT("EnumChannel Failed (%s)"), GetHrSz(hr));
00903       return;
00904   }
00905
00906   if  (NULL == pEnum)
00907   {
00908     ERROR_MSG(TEXT("EnumChannel returned NULL ptr"));
00909     return;
00910   }
00911
00912   INmChannel * rgpChannel[10];
00913   for (int i = 0; i < 10; i++)
00914     rgpChannel[i] = NULL;
00915
00916   hr = pEnum->Next(cChannel, rgpChannel, &cFetched);
00917   if (FAILED(hr))
00918   {
00919       ERROR_MSG(TEXT("EnumMember Failed (%s)"), GetHrSz(hr));
00920   }
00921   else
00922   {
00923     for (UINT iChannel = 0; iChannel < cFetched; iChannel++)
00924     {
00925       if  (NULL != rgpChannel[iChannel])
00926       {
00927         DumpChannelInfo(rgpChannel[iChannel]);
00928         DoEnumChannelMember(rgpChannel[iChannel]);
00929         rgpChannel[iChannel]->Release();
00930         rgpChannel[iChannel] = NULL;
00931       }
00932       else
00933       {
00934         ERROR_MSG(TEXT("DoEnumAll: rgpChannel[iChannel] == NULL"));
00935       }
00936     }
00937   }
00938
00939   pEnum->Release();
00940 }
00941
00942 //****************************************************************************
00943 //
00944 // VOID DoEnumMemberLeak(void)
00945 //
00946 //****************************************************************************
00947
00948 VOID DoEnumMemberLeak(void)
00949 {
00950
00951   HRESULT       hr    = NO_ERROR;
00952   IEnumNmMember * pEnum   = NULL;
00953   INmMember   * pm    = NULL;
00954   INmConference * pConference = GetCurrentConference();
00955   UINT i;
00956
00957   if (NULL == pConference)
00958   {
00959     TRACE_MSG(TEXT("No current conference"));
00960     return;
00961   }
00962
00963   for(i=0; i < 10; i++)
00964   {
00965     hr = pConference->EnumMember(&pEnum);
00966     if  (SUCCEEDED(hr) && (NULL != pEnum))
00967     {
00968       while(pEnum->Next(1, &pm, NULL) == NO_ERROR)
00969       {
00970         if  (NULL != pm)
00971         {
00972           pm->Release();
00973           pm = NULL;
00974         }
00975       }
00976
00977       pEnum->Release();
00978       pEnum = NULL;
00979     }
00980     else
00981     {
00982       ERROR_MSG(TEXT("DoEnumMemberLeak: Error INmMember::EnumMember"));
00983     }
00984   }
00985
00986 }
00987 //****************************************************************************
00988 //
00989 // VOID DoSharableAppLeak(void)
00990 //
00991 //****************************************************************************
00992
00993 VOID DoSharableAppLeak(void)
00994 {
00995
00996   HRESULT         hr  = NO_ERROR  ;
00997   IEnumNmSharableApp  * pEnum = NULL    ;
00998   INmSharableApp    * pa  = NULL    ;
00999
01000   if  (NULL == g_pChannelAppShare)
01001   {
01002     ERROR_MSG(TEXT("DoSharableAppLeak: NULL == g_pChannelAppShare"));
01003     return;
01004   }
01005
01006   for(UINT i=0; i < 1000; i++)
01007   {
01008     hr = g_pChannelAppShare->EnumSharableApp(&pEnum);
01009     if  (SUCCEEDED(hr) && (NULL != pEnum))
01010     {
01011       while(pEnum->Next(1, &pa, NULL) == NO_ERROR)
01012       {
01013         if  (NULL != pa)
01014         {
01015           pa->Release();
01016           pa = NULL;
01017         }
01018       }
01019
01020       pEnum->Release();
01021       pEnum = NULL;
01022     }
01023     else
01024     {
01025       ERROR_MSG(TEXT("DoSharableAppLeak: NULL == pEnum"));
01026     }
01027   }
01028
01029 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Anchor.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

Anchor.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       anchor.cxx
00006 //
00007 //  Contents:   Parsing algorithm for anchor tag in Html
00008 //
00009 //  Classes:    CAnchorTag
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <anchor.hxx>
00017 #include <htmlguid.hxx>
00018
00019 //+-------------------------------------------------------------------------
00020 //
00021 //  Method:     CAnchorTag::CAnchorTag
00022 //
00023 //  Synopsis:   Constructor
00024 //
00025 //  Arguments:  [htmlIFilter]    -- Html IFilter
00026 //              [serialStream]   -- Input stream
00027 //
00028 //--------------------------------------------------------------------------
00029
00030 CAnchorTag::CAnchorTag( CHtmlIFilter& htmlIFilter,
00031                         CSerialStream& serialStream )
00032     : CHtmlElement(htmlIFilter, serialStream),
00033       _eState(StartAnchor),
00034       _pwcHrefBuf(0),
00035       _uLenHrefBuf(0),
00036       _cHrefChars(0),
00037       _cHrefCharsFiltered(0)
00038 {
00039 }
00040
00041
00042
00043 //+-------------------------------------------------------------------------
00044 //
00045 //  Method:     CAnchorTag::~CAnchorTag
00046 //
00047 //  Synopsis:   Destructor
00048 //
00049 //  Arguments:  [htmlIFilter]    -- Html IFilter
00050 //              [serialStream]   -- Input stream
00051 //
00052 //--------------------------------------------------------------------------
00053
00054 CAnchorTag::~CAnchorTag()
00055 {
00056     delete[] _pwcHrefBuf;
00057 }
00058
00059
00060 //+-------------------------------------------------------------------------
00061 //
00062 //  Method:     CAnchorTag::GetChunk
00063 //
00064 //  Synopsis:   Gets the next chunk and returns chunk information in pStat
00065 //
00066 //  Arguments:  [pStat] -- chunk information returned here
00067 //
00068 //--------------------------------------------------------------------------
00069
00070 SCODE CAnchorTag::GetChunk( STAT_CHUNK * pStat )
00071 {
00072     //
00073     // Toggle state
00074     //
00075     if ( _eState == StartAnchor )
00076         _eState = EndAnchor;
00077     else
00078         _eState = StartAnchor;
00079
00080     SCODE sc = SwitchToNextHtmlElement( pStat );
00081
00082     return sc;
00083 }
00084
00085
00086
00087 //+-------------------------------------------------------------------------
00088 //
00089 //  Method:     CAnchorTag::GetText
00090 //
00091 //  Synopsis:   Retrieves text from current chunk
00092 //
00093 //  Arguments:  [pcwcOutput] -- count of UniCode characters in buffer
00094 //              [awcBuffer]  -- buffer for text
00095 //
00096 //--------------------------------------------------------------------------
00097
00098 SCODE CAnchorTag::GetText( ULONG *pcwcOutput, WCHAR *awcBuffer )
00099 {
00100     if ( _eState == StartAnchor )
00101     {
00102         *pcwcOutput = 0;
00103         return FILTER_E_NO_MORE_TEXT;
00104     }
00105
00106     ULONG cCharsRemaining = _cHrefChars - _cHrefCharsFiltered;
00107
00108     if ( cCharsRemaining == 0 )
00109     {
00110         *pcwcOutput = 0;
00111         return FILTER_E_NO_MORE_TEXT;
00112     }
00113
00114     if ( *pcwcOutput < cCharsRemaining )
00115     {
00116         RtlCopyMemory( awcBuffer,
00117                        _pwcHrefBuf + _cHrefCharsFiltered,
00118                        *pcwcOutput * sizeof(WCHAR) );
00119         _cHrefCharsFiltered += *pcwcOutput;
00120
00121         return S_OK;
00122     }
00123     else
00124     {
00125         RtlCopyMemory( awcBuffer,
00126                        _pwcHrefBuf + _cHrefCharsFiltered,
00127                        cCharsRemaining * sizeof(WCHAR) );
00128         _cHrefCharsFiltered += cCharsRemaining;
00129         *pcwcOutput = cCharsRemaining;
00130
00131         return FILTER_S_LAST_TEXT;
00132     }
00133 }
00134
00135
00136
00137 //+-------------------------------------------------------------------------
00138 //
00139 //  Method:     CAnchorTag::InitStatChunk
00140 //
00141 //  Synopsis:   Initializes the STAT_CHUNK
00142 //
00143 //  Arguments:  [pStat] -- STAT_CHUNK to initialize
00144 //
00145 //--------------------------------------------------------------------------
00146
00147 void CAnchorTag::InitStatChunk( STAT_CHUNK *pStat )
00148 {
00149     pStat->idChunk = _htmlIFilter.GetNextChunkId();
00150     pStat->flags = CHUNK_TEXT;
00151     pStat->locale = _htmlIFilter.GetLocale();
00152     pStat->attribute.guidPropSet = CLSID_HtmlInformation;
00153     pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00154     pStat->attribute.psProperty.propid = PID_HREF;
00155     pStat->breakType = CHUNK_EOS;
00156
00157     if ( _eState == StartAnchor)
00158     {
00159         //
00160         // Start tag, hence read href field into local buffer
00161         //
00162         _scanner.ReadTagIntoBuffer();
00163
00164         WCHAR *pwcHrefBuf;
00165         unsigned cHrefChars;
00166         _scanner.ScanTagBuffer( L"href=\"", pwcHrefBuf, cHrefChars );
00167
00168         //
00169         // Need to grow internal buffer ?
00170         //
00171         if ( cHrefChars > _uLenHrefBuf )
00172         {
00173             delete[] _pwcHrefBuf;
00174             _pwcHrefBuf = 0;
00175             _uLenHrefBuf = 0;
00176
00177             _pwcHrefBuf = newk(mtNewX, NULL) WCHAR[cHrefChars];
00178             _uLenHrefBuf = cHrefChars;
00179         }
00180
00181         RtlCopyMemory( _pwcHrefBuf, pwcHrefBuf, cHrefChars*sizeof(WCHAR) );
00182         _cHrefChars = cHrefChars;
00183         _cHrefCharsFiltered = 0;
00184
00185         pStat->idChunkSource = 0;
00186         pStat->cwcStartSource = 0;
00187         pStat->cwcLenSource = 0;
00188     }
00189     else
00190     {
00191         Win4Assert( _eState == EndAnchor );
00192
00193         _scanner.EatTag();
00194
00195         //
00196         // Set up the filter region to be the one between the start and end
00197         // anchor tags, i.e. the region belonging to the current Html element,
00198         // because we haven't changed state yet.
00199         //
00200         _htmlIFilter.GetCurHtmlElement()->InitFilterRegion( pStat->idChunkSource,
00201                                                             pStat->cwcStartSource,
00202                                                             pStat->cwcLenSource );
00203     }
00204 }
00205
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/editsess.h Source File

  • WinUI
  • TSFmark

editsess.h

Go to the documentation of this file.
00001 //
00002 // editsess.h
00003 //
00004 // CEditSessionBase declaration.
00005 //
00006
00007 #ifndef EDITSESS_H
00008 #define EDITSESS_H
00009
00010 class CEditSessionBase : public ITfEditSession
00011 {
00012 public:
00013     CEditSessionBase(ITfContext *pContext)
00014     {
00015         _cRef = 1;
00016         _pContext = pContext;
00017         _pContext->AddRef();
00018     }
00019     virtual ~CEditSessionBase()
00020     {
00021         _pContext->Release();
00022     }
00023
00024     // IUnknown
00025     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj)
00026     {
00027         if (ppvObj == NULL)
00028             return E_INVALIDARG;
00029
00030         *ppvObj = NULL;
00031
00032         if (IsEqualIID(riid, IID_IUnknown) ||
00033             IsEqualIID(riid, IID_ITfEditSession))
00034         {
00035             *ppvObj = (ITfLangBarItemButton *)this;
00036         }
00037
00038         if (*ppvObj)
00039         {
00040             AddRef();
00041             return S_OK;
00042         }
00043
00044         return E_NOINTERFACE;
00045     }
00046     STDMETHODIMP_(ULONG) AddRef(void)
00047     {
00048         return ++_cRef;
00049     }
00050     STDMETHODIMP_(ULONG) Release(void)
00051     {
00052         LONG cr = --_cRef;
00053
00054         assert(_cRef >= 0);
00055
00056         if (_cRef == 0)
00057         {
00058             delete this;
00059         }
00060
00061         return cr;
00062     }
00063
00064     // ITfEditSession
00065     virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0;
00066
00067 protected:
00068     ITfContext *_pContext;
00069
00070 private:
00071     LONG _cRef;     // COM ref count
00072 };
00073
00074 #endif // EDITSESS_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Enum/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Enum
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__D01D6930_AF25_11D2_9A73_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__D01D6930_AF25_11D2_9A73_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__D01D6930_AF25_11D2_9A73_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/globals.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

globals.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015
00016 // Global variables
00017
00018 HINSTANCE g_hInst = NULL;      // Our global instance handle
00019 ULONG g_uObjectCount = 0;      // Global object count
00020 ULONG g_uServerLocks = 0;      // Global lock count
00021
00022
00023 //---------------------------------------------------------------------------
00024 //  XPROPPAGE: Varible for our extension clipformat
00025
00026 UINT g_cfNodeAttrPtr = 0;
00027
00028
00029 //---------------------------------------------------------------------------
00030 //  This is the fast, simple way to convert unicode to ansi.  It does NOT
00031 //  handle multibyte ansi strings and is not localized.  But it should be
00032 //  fine for registry entries
00033 //  NOTE:  The caller is responsible for freeing the memory.
00034 //
00035 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide )
00036 {
00037   LONG nLen = wcslen( szWide ) +1;
00038   *pszAnsi = (char*)CoTaskMemAlloc( nLen );
00039   char* pCounter = *pszAnsi;
00040
00041   while( *szWide )
00042   {
00043     *pCounter = LOBYTE(*szWide);
00044     pCounter++;
00045     szWide++;
00046   }
00047   *pCounter = NULL;
00048 }
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_DYNAMIC_LOCKS_STORE Member List

This is the complete list of members for _DYNAMIC_LOCKS_STORE, including all inherited members.
hHeap | _DYNAMIC_LOCKS_STORE
llFreeLocksList | _DYNAMIC_LOCKS_STORE
ulCountAllocated | _DYNAMIC_LOCKS_STORE
ulCountFree | _DYNAMIC_LOCKS_STORE
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/CascadeEC/cascade.Cpp Source File

  • Com
  • Services
  • Events
  • EventNews
  • CascadeEC

cascade.Cpp

Go to the documentation of this file.
00001 // Cascade.cpp : Implementation of CCascade
00002 #include "stdafx.h"
00003 #include "CascadeEC.h"
00004 #include "Cascade.h"
00005
00006 /////////////////////////////////////////////////////////////////////////////
00007 // CCascade
00008
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletRegistryItem Member List

This is the complete list of members for tagAppletRegistryItem, including all inherited members.
ItemType | tagAppletRegistryItem
nChannelID | tagAppletRegistryItem
nTokenID | tagAppletRegistryItem
ostrParamValue | tagAppletRegistryItem
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/CPPClient/stdafx.h Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • CPPClient

stdafx.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 // stdafx.h : include file for standard system include files,
00019 //  or project specific include files that are used frequently, but
00020 //      are changed infrequently
00021 //
00022
00023 #if !defined(AFX_STDAFX_H__629B8F26_E496_400F_A7DE_85F3BD592EE7__INCLUDED_)
00024 #define AFX_STDAFX_H__629B8F26_E496_400F_A7DE_85F3BD592EE7__INCLUDED_
00025
00026 #if _MSC_VER > 1000
00027 #pragma once
00028 #endif // _MSC_VER > 1000
00029
00030 #define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers
00031
00032 #include <stdio.h>
00033 #define STRICT
00034 #ifndef _WIN32_WINNT
00035 #define _WIN32_WINNT 0x0400
00036 #endif
00037 #define _ATL_APARTMENT_THREADED
00038
00039 #include <atlbase.h>
00040 //You may derive a class from CComModule and use it if you want to override
00041 //something, but do not change the name of _Module
00042 extern CComModule _Module;
00043 #include <atlcom.h>
00044
00045
00046 //{{AFX_INSERT_LOCATION}}
00047 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00048
00049 #endif // !defined(AFX_STDAFX_H__1589FC99_1DF0_11D3_9496_00C04F6877AA__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_COLUMNDATA Member List

This is the complete list of members for _COLUMNDATA, including all inherited members.
bData | _COLUMNDATA
dwLength | _COLUMNDATA
dwStatus | _COLUMNDATA
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepmultiuser/common.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepmultiuser

common.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Server System Service
00006
00007     FILE: common.cpp
00008
00009     PURPOSE: Provides common file replication service routine definitions.
00010
00011 */
00012
00013 #include <windows.h>
00014 #include <tchar.h>
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <crtdbg.h>
00018
00019 #include "common.h"
00020
00021 HANDLE hProcessHeap = NULL;
00022
00023 VOID GetEEInfoText(TCHAR *Msg, UINT BuffSize, UINT *MsgSize) {
00024     RPC_STATUS status;
00025     RPC_ERROR_ENUM_HANDLE EnumHandle;
00026
00027   *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("EEInfo:\n"));
00028
00029     status = RpcErrorStartEnumeration(&EnumHandle);
00030
00031     if (status == RPC_S_ENTRY_NOT_FOUND) {
00032         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("no EEInfo found\n"));
00033     }
00034     else if (status != RPC_S_OK) {
00035         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("could not get EEInfo\n"));
00036     }
00037     else {
00038         RPC_EXTENDED_ERROR_INFO ErrorInfo;
00039
00040         while (status == RPC_S_OK) {
00041             ErrorInfo.Version = RPC_EEINFO_VERSION;
00042             ErrorInfo.Flags = 0;
00043             ErrorInfo.NumberOfParameters = 4;
00044
00045             status = RpcErrorGetNextRecord(&EnumHandle, FALSE, &ErrorInfo);
00046             if (status == RPC_S_ENTRY_NOT_FOUND) {
00047                 break;
00048             }
00049             else if (status != RPC_S_OK) {
00050                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("enumeration broke with status %d\n"), status);
00051                 break;
00052             }
00053             else {
00054                 INT i;
00055
00056                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("GeneratingComponent: %d\n"), ErrorInfo.GeneratingComponent);
00057                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Status: %d\n"), ErrorInfo.Status);
00058                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Detection Location: %d\n"), ErrorInfo.DetectionLocation);
00059                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Flags: %d\n"), ErrorInfo.Flags);
00060                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("NumberOfParameters: %d\n"), ErrorInfo.NumberOfParameters);
00061
00062                 for (i = 0; i < ErrorInfo.NumberOfParameters; i++) {
00063                     switch (ErrorInfo.Parameters[i].ParameterType) {
00064                     case eeptAnsiString:
00065                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("AnsiString: %s\n"), ErrorInfo.Parameters[i].u.AnsiString);
00066                         break;
00067
00068                     case eeptUnicodeString:
00069                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("UnicodeString: %S\n"), ErrorInfo.Parameters[i].u.UnicodeString);
00070                         break;
00071
00072                     case eeptLongVal:
00073                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("LongVal: %d\n"), ErrorInfo.Parameters[i].u.LVal);
00074                         break;
00075
00076                     case eeptShortVal:
00077                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("ShortVal: %d\n"), ErrorInfo.Parameters[i].u.SVal);
00078                         break;
00079
00080                     case eeptPointerVal:
00081                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("PointerVal: %d\n"), ErrorInfo.Parameters[i].u.PVal);
00082                         break;
00083
00084                     case eeptNone:
00085                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Invalid type of parameter %d\n"), ErrorInfo.Parameters[i].ParameterType);
00086                         break;
00087
00088                     default:
00089                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Invalid type of parameter %d\n"), ErrorInfo.Parameters[i].ParameterType);
00090                     }
00091                 }
00092             }
00093         }
00094     }
00095 }
00096
00097 VOID PrintProcFailureEEInfo(LPTSTR ProcName, DWORD ErrCode) {
00098     TCHAR Msg[MSG_SIZE];
00099     UINT MsgSize = 0;
00100
00101     MsgSize += _stprintf(&Msg[MsgSize], TEXT("%s failed with code %d\n"), ProcName, ErrCode);
00102   GetEEInfoText(Msg, MSG_SIZE, &MsgSize);
00103
00104   Msg[MsgSize] = 0;
00105
00106     _tprintf(TEXT("%s"), Msg);
00107 }
00108
00109 // Memory management functions.
00110 VOID * AutoHeapAlloc(size_t dwBytes) {
00111     if (hProcessHeap == NULL) {
00112         hProcessHeap = GetProcessHeap();
00113     }
00114     return HeapAlloc(hProcessHeap, 0, dwBytes);
00115 }
00116
00117 VOID AutoHeapFree(VOID * lpMem) {
00118     DWORD status;
00119     ASSERTE(hProcessheap != NULL);
00120     status = HeapFree(hProcessHeap, 0, lpMem);
00121     ASSERTE(status);
00122 }
00123
00124 // end common.cpp
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/DISPATCH.c Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

DISPATCH.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   dispatch.c
00009 //
00010 //  PURPOSE:  Implement the generic message and command dispatchers.
00011 //
00012 //
00013 //  FUNCTIONS:
00014 //    DispMessage - Call the function associated with a message.
00015 //    DispCommand - Call the function associated with a command.
00016 //    DispDefault - Call the appropriate default window procedure.
00017 //
00018 //  COMMENTS:
00019 //
00020
00021 #include <windows.h>            // required for all Windows applications
00022 #include <windowsx.h>
00023 #include "globals.h"            // prototypes specific to this application
00024
00025 LRESULT DispDefault(EDWP, HWND, UINT, WPARAM, LPARAM);
00026
00027 //
00028 //  FUNCTION: DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM)
00029 //
00030 //  PURPOSE: Call the function associated with a message.
00031 //
00032 //  PARAMETERS:
00033 //    lpmsdi - Structure containing the message dispatch information.
00034 //    hwnd - The window handle
00035 //    uMessage - The message number
00036 //    wparam - Message specific data
00037 //    lparam - Message specific data
00038 //
00039 //  RETURN VALUE:
00040 //    The value returned by the message function that was called.
00041 //
00042 //  COMMENTS:
00043 //    Runs the table of messages stored in lpmsdi->rgmsd searching
00044 //    for a message number that matches uMessage.  If a match is found,
00045 //    call the associated function.  Otherwise, call DispDefault to
00046 //    call the default function, if any, associated with the message
00047 //    structure.  In either case, return the value recieved from the
00048 //    message or default function.
00049 //
00050
00051 LRESULT DispMessage(LPMSDI lpmsdi,
00052                     HWND   hwnd,
00053                     UINT   uMessage,
00054                     WPARAM wparam,
00055                     LPARAM lparam)
00056 {
00057     int  imsd = 0;
00058
00059     MSD *rgmsd = lpmsdi->rgmsd;
00060     int  cmsd  = lpmsdi->cmsd;
00061
00062     for (imsd = 0; imsd < cmsd; imsd++)
00063     {
00064         if (rgmsd[imsd].uMessage == uMessage)
00065             return rgmsd[imsd].pfnmsg(hwnd, uMessage, wparam, lparam);
00066     }
00067
00068     return DispDefault(lpmsdi->edwp, hwnd, uMessage, wparam, lparam);
00069 }
00070
00071 //
00072 //  FUNCTION: DispCommand(LPCMDI, HWND, WPARAM, LPARAM)
00073 //
00074 //  PURPOSE: Call the function associated with a command.
00075 //
00076 //  PARAMETERS:
00077 //    lpcmdi - Structure containing the command dispatch information.
00078 //    hwnd - The window handle
00079 //    GET_WM_COMMAND_ID(wparam, lparam) - Identifier of the menu item,
00080 //      control, or accelerator.
00081 //    GET_WM_COMMAND_CMD(wparam, lparam) - Notification code.
00082 //    GET_WM_COMMAND_HWND(wparam, lparam) - The control handle or NULL.
00083 //
00084 //  RETURN VALUE:
00085 //    The value returned by the command function that was called.
00086 //
00087 //  COMMENTS:
00088 //    Runs the table of commands stored in lpcmdi->rgcmd searching
00089 //    for a command number that matches wCommand.  If a match is found,
00090 //    call the associated function.  Otherwise, call DispDefault to
00091 //    call the default function, if any, associated with the command
00092 //    structure.  In either case, return the value recieved from the
00093 //    command or default function.
00094 //
00095
00096
00097 LRESULT DispCommand(LPCMDI lpcmdi,
00098                     HWND   hwnd,
00099                     WPARAM wparam,
00100                     LPARAM lparam)
00101 {
00102     LRESULT lRet = 0;
00103     WORD    wCommand = GET_WM_COMMAND_ID(wparam, lparam);
00104     int     icmd;
00105
00106     CMD    *rgcmd = lpcmdi->rgcmd;
00107     int     ccmd  = lpcmdi->ccmd;
00108
00109     // Message packing of wparam and lparam have changed for Win32,
00110     // so use the GET_WM_COMMAND macro to unpack the commnad
00111
00112     for (icmd = 0; icmd < ccmd; icmd++)
00113     {
00114         if (rgcmd[icmd].wCommand == wCommand)
00115         {
00116             return rgcmd[icmd].pfncmd(hwnd,
00117                                       wCommand,
00118                                       GET_WM_COMMAND_CMD(wparam, lparam),
00119                                       GET_WM_COMMAND_HWND(wparam, lparam));
00120         }
00121     }
00122
00123     return DispDefault(lpcmdi->edwp, hwnd, WM_COMMAND, wparam, lparam);
00124 }
00125
00126
00127 //
00128 //  FUNCTION: DispDefault(EDWP, HWND, UINT, WPARAM, LPARAM)
00129 //
00130 //  PURPOSE: Call the appropriate default window procedure.
00131 //
00132 //  PARAMETERS:
00133 //    edwp - Enumerate specifying the appropriate default winow procedure.
00134 //    hwnd - The window handle
00135 //    uMessage - The message number
00136 //    wparam - Message specific data
00137 //    lparam - Message specific data
00138 //
00139 //  RETURN VALUE:
00140 //    If there is a default proc, return the value returned by the
00141 //    default proc.  Otherwise, return 0.
00142 //
00143 //  COMMENTS:
00144 //    Calls the default procedure associated with edwp using the specified
00145 //    parameters.
00146 //
00147
00148 LRESULT DispDefault(EDWP   edwp,
00149                     HWND   hwnd,
00150                     UINT   uMessage,
00151                     WPARAM wparam,
00152                     LPARAM lparam)
00153 {
00154     switch (edwp)
00155     {
00156         case edwpNone:
00157             return 0;
00158         case edwpWindow:
00159             return DefWindowProc(hwnd, uMessage, wparam, lparam);
00160         case edwpDialog:
00161             return DefDlgProc(hwnd, uMessage, wparam, lparam);
00162         case edwpMDIFrame:
00163             return DefFrameProc(hwnd, hwndMDIClient, uMessage, wparam, lparam);
00164         case edwpMDIChild:
00165             return DefMDIChildProc(hwnd, uMessage, wparam, lparam);
00166     }
00167     return 0;
00168 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/about.h Source File

  • SysMgmt
  • MMC
  • CutCopy

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::StreamReadEnum Member List

This is the complete list of members for msado15::StreamReadEnum, including all inherited members.
adReadAll | msado15::StreamReadEnum | [static]
adReadLine | msado15::StreamReadEnum | [static]
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cmutipleresults.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cmutipleresults.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CMUTIPLERESULTS.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 //////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 /////////////////////////////////////////////////////////////////
00019 // CMultipleResults::CMultipleResults
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CMultipleResults::CMultipleResults(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CBase(eCMultipleResults, pCMainWindow, pCMDIChild)
00024 {
00025   //MultipleResults
00026   m_pIMultipleResults       = NULL;//MultipleResults Interface
00027 }
00028
00029
00030 /////////////////////////////////////////////////////////////////
00031 // CMultipleResults::~CMultipleResults
00032 //
00033 /////////////////////////////////////////////////////////////////
00034 CMultipleResults::~CMultipleResults()
00035 {
00036   ReleaseObject(0);
00037 }
00038
00039
00040 /////////////////////////////////////////////////////////////////
00041 // IUnknown** CMultipleResults::GetInterfaceAddress
00042 //
00043 /////////////////////////////////////////////////////////////////
00044 IUnknown** CMultipleResults::GetInterfaceAddress(REFIID riid)
00045 {
00046   HANDLE_GETINTERFACE(IMultipleResults);
00047
00048   //Otherwise delegate
00049   return CBase::GetInterfaceAddress(riid);
00050 }
00051
00052
00053 /////////////////////////////////////////////////////////////////
00054 // CMultipleResults::AutoRelease
00055 //
00056 /////////////////////////////////////////////////////////////////
00057 HRESULT CMultipleResults::AutoRelease()
00058 {
00059   //MultipleResults
00060   RELEASE_INTERFACE(IMultipleResults);
00061
00062   //Delegate
00063   return CBase::AutoRelease();
00064 }
00065
00066
00067 ////////////////////////////////////////////////////////////////
00068 // CMultipleResults::AutoQI
00069 //
00070 /////////////////////////////////////////////////////////////////
00071 HRESULT CMultipleResults::AutoQI(DWORD dwCreateOpts)
00072 {
00073   //Delegate First so we have base interfaces
00074   CBase::AutoQI(dwCreateOpts);
00075
00076   //[MANDATORY]
00077   if(dwCreateOpts & CREATE_QI_MANDATORY)
00078   {
00079     OBTAIN_INTERFACE(IMultipleResults);
00080   }
00081
00082   //Auto QI
00083   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00084   {
00085   }
00086
00087   return S_OK;
00088 }
00089
00090
00091 ////////////////////////////////////////////////////////////////
00092 // CMultipleResults::GetResult
00093 //
00094 /////////////////////////////////////////////////////////////////
00095 HRESULT CMultipleResults::GetResult(CAggregate* pCAggregate, DB_LRESERVE lResultFlag, REFIID riid, DBROWCOUNT* pcRowsAffected, IUnknown** ppIUnknown)
00096 {
00097   HRESULT hr = E_FAIL;
00098
00099   //No-op
00100   if(m_pIMultipleResults == NULL)
00101     return E_FAIL;
00102
00103   //IMultipleResults::GetResult...
00104   XTEST(hr = m_pIMultipleResults->GetResult(pCAggregate, lResultFlag, riid, pcRowsAffected, ppIUnknown));
00105   TESTC(TRACE_METHOD(hr, L"IMultipleResults::GetResult(0x%p, %d, %s, &%ld, &0x%p)", pCAggregate, lResultFlag, GetInterfaceName(riid), pcRowsAffected ? *pcRowsAffected : NULL, ppIUnknown ? *ppIUnknown : NULL));
00106
00107   //Handle Aggregation
00108   if(pCAggregate)
00109     TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00110
00111 CLEANUP:
00112   return hr;
00113 }
00114
00115
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cstream.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cstream.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CSTREAM.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CSTREAM_H_
00012 #define _CSTREAM_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019
00020
00021 ///////////////////////////////////////////////////////////////////////////////
00022 // Class CStream
00023 //
00024 ///////////////////////////////////////////////////////////////////////////////
00025 class CStream : public CAsynchBase
00026 {
00027 public:
00028   //Constructors
00029   CStream(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00030   virtual ~CStream();
00031
00032   //IUnknown Helpers
00033   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00034   virtual HRESULT     AutoRelease();
00035   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00036
00037
00038   //Pure Virtual
00039   virtual WCHAR*      GetObjectName()     { return L"Stream";       }
00040   virtual UINT      GetObjectMenu()     { return IDM_STREAMMENU;    }
00041   virtual LONG      GetObjectImage()    { return IMAGE_STREAM;      }
00042   virtual REFIID      GetDefaultInterface() { return IID_ISequentialStream; }
00043
00044   virtual void      OnDefOperation();
00045   virtual HRESULT     DisplayObject();
00046
00047   //Helpers
00048   virtual HRESULT     ReadBytes(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, DBLENGTH cbMaxSize, void* pBuffer, DBLENGTH* pcbRead = NULL);
00049   virtual HRESULT     WriteBytes(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, void* pBuffer, DBLENGTH* pcbWritten = NULL);
00050
00051   //Helpers
00052   virtual HRESULT     ReadString(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, DBLENGTH ulMaxSize, WCHAR* pwszBuffer, DBLENGTH* pcbRead = NULL);
00053   virtual HRESULT     WriteString(REFIID riid, DBLENGTH ulOffset, DBLENGTH cBytes, WCHAR* pwszBuffer, DBLENGTH* pcbWritten = NULL);
00054
00055   virtual HRESULT     Stat(STATSTG* pSTATSTG);
00056   virtual HRESULT     Clone(IStream** ppStream);
00057   virtual HRESULT     Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
00058
00059   //[MANDATORY]
00060   ISequentialStream*    m_pISequentialStream;
00061
00062   //[OPTIONAL]
00063   IStream*        m_pIStream;
00064   IStorage*       m_pIStorage;
00065   ILockBytes*       m_pILockBytes;
00066
00067   //Data
00068   DBTYPE          m_wType;
00069 };
00070
00071
00072
00073
00074 ///////////////////////////////////////////////////////////////////////////////
00075 // Class CStorageBuffer
00076 //
00077 ///////////////////////////////////////////////////////////////////////////////
00078 class CStorageBuffer : public IStream, /*ISequentialStream*/ public ILockBytes
00079 {
00080 public:
00081   //Constructors
00082   CStorageBuffer();
00083   virtual ~CStorageBuffer();
00084
00085   //Helpers
00086   STDMETHODIMP      Seek(LONG lOffset, DWORD dwOrigin = STREAM_SEEK_SET, ULONG* pulNewPosition = NULL);
00087   STDMETHODIMP      ReadBuffer(ULONG ulOffset, void* pv, ULONG cb, ULONG* pcbRead);
00088   STDMETHODIMP      WriteBuffer(ULONG ulOffset, const void* pv, ULONG cb, ULONG* pcbRead);
00089
00090   //IUnknown
00091   STDMETHODIMP_(ULONG)  AddRef();
00092   STDMETHODIMP_(ULONG)  Release();
00093   STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00094
00095   //ISequentialStream interfaces
00096   STDMETHODIMP Read(
00097             /* [out] */   void* pv,
00098             /* [in] */    ULONG cb,
00099             /* [out] */   ULONG* pcbRead);
00100
00101     STDMETHODIMP Write(
00102             /* [in] */    const void* pv,
00103             /* [in] */    ULONG cb,
00104             /* [out] */   ULONG* pcbWritten);
00105
00106   //IStream interfaces
00107   STDMETHODIMP Seek(
00108               LARGE_INTEGER dlibMove,     //Offset relative to dwOrigin
00109               DWORD dwOrigin,         //Specifies the origin for the offset
00110               ULARGE_INTEGER * plibNewPosition);
00111
00112   STDMETHODIMP SetSize( ULARGE_INTEGER libNewSize);   //Specifies the new size of the stream object
00113
00114   STDMETHODIMP CopyTo(  IStream * pstm,         //Points to the destination stream
00115               ULARGE_INTEGER cb,        //Specifies the number of bytes to copy
00116               ULARGE_INTEGER * pcbRead,   //Pointer to the actual number of bytes read from the source
00117               ULARGE_INTEGER * pcbWritten); //Pointer to the actual number of bytes written to the destination
00118
00119   STDMETHODIMP Commit(  DWORD grfCommitFlags);      //Specifies how changes are committed
00120
00121   STDMETHODIMP Revert(  );
00122
00123   STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset,   //Specifies the byte offset for the beginning of the range
00124               ULARGE_INTEGER cb,        //Specifies the length of the range in bytes
00125               DWORD dwLockType);        //Specifies the restriction on accessing the specified range
00126
00127   STDMETHODIMP UnlockRegion(  ULARGE_INTEGER libOffset, //Specifies the byte offset for the beginning of the range
00128                 ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
00129                 DWORD dwLockType);      //Specifies the access restriction previously placed on the range);
00130   STDMETHODIMP Stat(
00131               STATSTG * pstatstg,       //Location for STATSTG structure
00132               DWORD grfStatFlag);       //Values taken from the STATFLAG enumeration
00133
00134   STDMETHODIMP Clone(   IStream ** ppstm );       //Points to location for pointer to the new stream object
00135
00136
00137   //ILockBytes interfaces
00138   STDMETHODIMP ReadAt(
00139               ULARGE_INTEGER ulOffset,
00140             /* [out] */   void* pv,
00141             /* [in] */    ULONG cb,
00142             /* [out] */   ULONG* pcbRead);
00143
00144     STDMETHODIMP WriteAt(
00145               ULARGE_INTEGER ulOffset,
00146             /* [in] */    const void* pv,
00147             /* [in] */    ULONG cb,
00148             /* [out] */   ULONG* pcbWritten);
00149
00150   STDMETHODIMP Flush();
00151
00152 protected:
00153   //Data
00154
00155 private:
00156   ULONG     m_cRef;     // reference count
00157
00158   void*     m_pBuffer;    // buffer
00159   ULONG     m_cMaxSize;     // Maximum allocated buffer size
00160   ULONG     m_iPos;     // current index position in the buffer
00161 };
00162
00163
00164 ///////////////////////////////////////////////////////////////////////////////
00165 // Class CFileStream
00166 //
00167 // Implementation of stream interface on top of a file
00168 ///////////////////////////////////////////////////////////////////////////////
00169 class CFileStream : public IStream
00170 {
00171 public:
00172   //constructors
00173   CFileStream();
00174   virtual ~CFileStream();
00175
00176   //Helpers
00177   HRESULT OpenFile(WCHAR* pwszFile, WCHAR* pwszMode);
00178   HRESULT CloseFile();
00179
00180   //IUnknown
00181   STDMETHODIMP_(ULONG)  AddRef();
00182   STDMETHODIMP_(ULONG)  Release();
00183   STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00184
00185   //IStream
00186   STDMETHODIMP Read(
00187             /* [out] */   void* pv,
00188             /* [in] */    ULONG cb,
00189             /* [out] */   ULONG* pcbRead);
00190
00191     STDMETHODIMP Write(
00192             /* [in] */    const void* pv,
00193             /* [in] */    ULONG cb,
00194             /* [out] */   ULONG* pcbWritten);
00195
00196   STDMETHODIMP Seek(
00197               LARGE_INTEGER dlibMove,     //Offset relative to dwOrigin
00198               DWORD dwOrigin,         //Specifies the origin for the offset
00199               ULARGE_INTEGER * plibNewPosition);
00200
00201   STDMETHODIMP SetSize( ULARGE_INTEGER libNewSize);   //Specifies the new size of the stream object
00202
00203   STDMETHODIMP CopyTo(  IStream * pstm,         //Points to the destination stream
00204               ULARGE_INTEGER cb,        //Specifies the number of bytes to copy
00205               ULARGE_INTEGER * pcbRead,   //Pointer to the actual number of bytes read from the source
00206               ULARGE_INTEGER * pcbWritten); //Pointer to the actual number of bytes written to the destination
00207
00208   STDMETHODIMP Commit(  DWORD grfCommitFlags);      //Specifies how changes are committed
00209
00210   STDMETHODIMP Revert(  );
00211
00212   STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset,   //Specifies the byte offset for the beginning of the range
00213               ULARGE_INTEGER cb,        //Specifies the length of the range in bytes
00214               DWORD dwLockType);        //Specifies the restriction on accessing the specified range
00215
00216   STDMETHODIMP UnlockRegion(  ULARGE_INTEGER libOffset, //Specifies the byte offset for the beginning of the range
00217                 ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
00218                 DWORD dwLockType);      //Specifies the access restriction previously placed on the range);
00219   STDMETHODIMP Stat(
00220               STATSTG * pstatstg,       //Location for STATSTG structure
00221               DWORD grfStatFlag);       //Values taken from the STATFLAG enumeration
00222
00223   STDMETHODIMP Clone(   IStream ** ppstm );       //Points to location for pointer to the new stream object
00224
00225
00226 protected:
00227   FILE*     m_pFile;
00228
00229 private:
00230   ULONG     m_cRef;
00231 };
00232
00233
00234 #endif //_CSTREAM_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/StringUtils.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

StringUtils.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      StringUtils.h
00005 //
00006 //  Description:
00007 //      Declaration of string manipulation routines.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #pragma once
00012
00013 #include "stdafx.h"
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // Custom string compare function declarations. Used to replace lstrcmp*
00017 /////////////////////////////////////////////////////////////////////////////
00018
00019 //
00020 // Full string compares.
00021 //
00022
00023 int
00024 IBSTRCompareW(
00025       BSTR  bstrString1In
00026     , BSTR  bstrString2In
00027     );
00028
00029 int
00030 BSTRCompareW(
00031       BSTR  bstrString1In
00032     , BSTR  bstrString2In
00033     );
00034
00035 int
00036 IStringCompareW(
00037       LPCWSTR pcwszString1In
00038     , LPCWSTR pcwszString2In
00039     );
00040
00041 int
00042 StringCompareW(
00043       LPCWSTR pcwszString1In
00044     , LPCWSTR pcwszString2In
00045     );
00046
00047 int
00048 IStringCompareW(
00049       LPCWSTR   pcwszString1In
00050     , size_t    cch1In
00051     , LPCWSTR   pcwszString2In
00052     , size_t    cch2In
00053     );
00054
00055 int
00056 StringCompareW(
00057       LPCWSTR   pcwszString1In
00058     , size_t    cch1In
00059     , LPCWSTR   pcwszString2In
00060     , size_t    cch2In
00061     );
00062
00063 //
00064 // Partial string compares.  They use whichever one's length is shortest
00065 // if both are specified or the NBSTR routines are used.
00066 //
00067
00068 int
00069 NIBSTRCompareW(
00070       BSTR  bstrString1In
00071     , BSTR  bstrString2In
00072     );
00073
00074 int
00075 NBSTRCompareW(
00076       BSTR  bstrString1In
00077     , BSTR  bstrString2In
00078     );
00079
00080 int
00081 NIStringCompareW(
00082       LPCWSTR   pcwszString1In
00083     , LPCWSTR   pcwszString2In
00084     , size_t    cchIn
00085     );
00086
00087 int
00088 NStringCompareW(
00089       LPCWSTR   pcwszString1In
00090     , LPCWSTR   pcwszString2In
00091     , size_t    cchIn
00092     );
00093
00094 int
00095 NIStringCompareW(
00096       LPCWSTR   pcwszString1In
00097     , size_t    cch1In
00098     , LPCWSTR   pcwszString2In
00099     , size_t    cch2In
00100     );
00101
00102 int
00103 NStringCompareW(
00104       LPCWSTR   pcwszString1In
00105     , size_t    cch1In
00106     , LPCWSTR   pcwszString2In
00107     , size_t    cch2In
00108     );
00109
00110
00111 //////////////////////////////////////////////////////////////////////////////
00112 // Load string routines
00113 //////////////////////////////////////////////////////////////////////////////
00114
00115 HRESULT
00116 HrLoadStringIntoBSTR(
00117       HINSTANCE hInstanceIn
00118     , LANGID    langidIn
00119     , UINT      idsIn
00120     , BSTR *    pbstrInout
00121     );
00122
00123 inline
00124 HRESULT
00125 HrLoadStringIntoBSTR(
00126       UINT      idsIn
00127     , BSTR *    pbstrInout
00128     )
00129 {
00130     return HrLoadStringIntoBSTR(
00131                           NULL
00132                         , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00133                         , idsIn
00134                         , pbstrInout
00135                         );
00136 } //*** HrLoadStringIntoBSTR
00137
00138 inline
00139 HRESULT
00140 HrLoadStringIntoBSTR(
00141       HINSTANCE hInstanceIn
00142     , UINT      idsIn
00143     , BSTR *    pbstrInout
00144     )
00145
00146 {
00147     return HrLoadStringIntoBSTR(
00148                           hInstanceIn
00149                         , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00150                         , idsIn
00151                         , pbstrInout
00152                         );
00153
00154 } //*** HrLoadStringIntoBSTR
00155
00156 //////////////////////////////////////////////////////////////////////////////
00157 // Format string ID routines
00158 //////////////////////////////////////////////////////////////////////////////
00159
00160 HRESULT
00161 HrFormatStringIntoBSTR(
00162       HINSTANCE hInstanceIn
00163     , LANGID    langidIn
00164     , UINT      idsIn
00165     , BSTR *    pbstrInout
00166     , ...
00167     );
00168
00169 HRESULT
00170 HrFormatStringWithVAListIntoBSTR(
00171       HINSTANCE hInstanceIn
00172     , LANGID    langidIn
00173     , UINT      idsIn
00174     , BSTR *    pbstrInout
00175     , va_list   valistIn
00176     );
00177
00178 inline
00179 HRESULT
00180 HrFormatStringIntoBSTR(
00181       HINSTANCE hInstanceIn
00182     , UINT      idsIn
00183     , BSTR *    pbstrInout
00184     , ...
00185     )
00186 {
00187     HRESULT hr;
00188     va_list valist;
00189
00190     va_start( valist, pbstrInout );
00191
00192     hr = HrFormatStringWithVAListIntoBSTR(
00193                   hInstanceIn
00194                 , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00195                 , idsIn
00196                 , pbstrInout
00197                 , valist
00198                 );
00199
00200     va_end( valist );
00201
00202     return hr;
00203
00204 } //*** HrFormatStringIntoBSTR
00205
00206 inline
00207 HRESULT
00208 HrFormatStringIntoBSTR(
00209       UINT      idsIn
00210     , BSTR *    pbstrInout
00211     , ...
00212     )
00213 {
00214     HRESULT hr;
00215     va_list valist;
00216
00217     va_start( valist, pbstrInout );
00218
00219     hr = HrFormatStringWithVAListIntoBSTR(
00220                   NULL
00221                 , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00222                 , idsIn
00223                 , pbstrInout
00224                 , valist
00225                 );
00226
00227     va_end( valist );
00228
00229     return hr;
00230
00231 } //*** HrFormatStringIntoBSTR
00232
00233 inline
00234 HRESULT
00235 HrFormatStringWithVAListIntoBSTR(
00236       HINSTANCE hInstanceIn
00237     , UINT      idsIn
00238     , BSTR *    pbstrInout
00239     , va_list   valistIn
00240     )
00241 {
00242     return HrFormatStringWithVAListIntoBSTR(
00243                   hInstanceIn
00244                 , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00245                 , idsIn
00246                 , pbstrInout
00247                 , valistIn
00248                 );
00249
00250 } //*** HrFormatStringWithVAListIntoBSTR
00251
00252 //////////////////////////////////////////////////////////////////////////////
00253 // Format string routines
00254 //////////////////////////////////////////////////////////////////////////////
00255
00256 HRESULT
00257 HrFormatStringIntoBSTR(
00258       LPCWSTR   pcwszFmtIn
00259     , BSTR *    pbstrInout
00260     , ...
00261     );
00262
00263 HRESULT
00264 HrFormatStringWithVAListIntoBSTR(
00265       LPCWSTR   pcwszFmtIn
00266     , BSTR *    pbstrInout
00267     , va_list   valistIn
00268     );
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAttributeValueEditButton Member List

This is the complete list of members for CAttributeValueEditButton, including all inherited members.
CAttributeValueEditButton(CMultiValuedAttributeEditor *pEditor) | CAttributeValueEditButton | [inline]
m_pEditor | CAttributeValueEditButton | [protected]
OnEdit() | CAttributeValueEditButton |
~CAttributeValueEditButton() | CAttributeValueEditButton | [inline]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/ListWIN.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

ListWIN.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      LISTWIN.CPP
00003
00004   Summary:   Implementation of the C++ object that encapsulates the
00005              list box control window that displays the page list.
00006
00007   Classes:   CListWin.
00008
00009   Functions: none.
00010
00011   Origin:    5-24-97: atrent - Editor Inheritance from CMsgLog in
00012              APPUTIL.CPP.
00013
00014 ----------------------------------------------------------------------------
00015   This file is part of the Microsoft COM Tutorial Code Samples.
00016
00017   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00018
00019   This source code is intended only as a supplement to Microsoft
00020   Development Tools and/or on-line documentation.  See these other
00021   materials for detailed information regarding Microsoft code samples.
00022
00023   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00024   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00025   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00026   PARTICULAR PURPOSE.
00027 ==========================================================================+*/
00028
00029 /*---------------------------------------------------------------------------
00030   We include WINDOWS.H for all Win32 applications.
00031   We include TCHAR.H for general Unicode/Ansi prototype of utility
00032     functions like wvsprintf.
00033   We include APPUTIL.H because we will be building this application using
00034     the convenient Virtual Window and Dialog classes and other
00035     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00036   We include LISTWIN.H for the defines and the CListWin class declaration
00037     needed in LISTWIN.
00038 ---------------------------------------------------------------------------*/
00039 #include <windows.h>
00040 #include <tchar.h>
00041 #include <apputil.h>
00042 #include "listwin.h"
00043
00044
00045 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00046   Method:   CListWin::Create
00047
00048   Summary:  Creates the ListBox as a child window to fill the client area
00049             of the specified parent window or to exist as a separate
00050             window owned by the parent window.
00051
00052   Args:     HINSTANCE hInst,
00053               Instance handle of the application.
00054             HWND hWndparent,
00055               Window handle for the parent window of the listbox.
00056             BOOL bSeparate)
00057               Flag to create the listbox as a separate window.  FALSE
00058               means fit the child window to fill the client area of the
00059               parent window. TRUE means the window is a separate (but
00060               owned) window.
00061
00062   Returns:  BOOL
00063               TRUE if successful; FALSE if not.
00064 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00065 BOOL CListWin::Create(
00066        HINSTANCE hInst,
00067        HWND hWndParent,
00068        BOOL bSeparate)
00069 {
00070   BOOL bResult = FALSE;
00071   HWND hWnd;
00072   RECT rect;
00073   DWORD dwStyle = WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LBS_NOTIFY |
00074                     LBS_NOINTEGRALHEIGHT;
00075   TCHAR* pszTitle = bSeparate ? TEXT("Page List") : NULL;
00076
00077   dwStyle |= bSeparate ? WS_OVERLAPPEDWINDOW : WS_CHILD;
00078
00079   if (IsWindow(hWndParent))
00080   {
00081     GetClientRect(hWndParent, &rect);
00082
00083     // Create the ListBox window.
00084     hWnd = ::CreateWindowEx(
00085                0,                // Extended Window Style
00086                TEXT("LISTBOX"),  // Class Name
00087                pszTitle,         // Window Title
00088                dwStyle,          // The window style
00089                0,                // (x,y)=Upper left of Parent window
00090                0,
00091                rect.right,       // Width; Fill Client Window
00092                rect.bottom,      // Height
00093                hWndParent,       // Parent Window Handle
00094                (HMENU) IDC_LISTWIN, // No menu but rig ID for notifications.
00095                hInst,            // App Instance Handle
00096                NULL);            // Window Creation Data
00097
00098     if (NULL != hWnd)
00099     {
00100       // Remember the window handle of this listbox window.
00101       m_hWnd = hWnd;
00102       // Remember the instance of this application.
00103       m_hInst = hInst;
00104       // Remember if this is a separate window (bSeparate==TRUE).
00105       m_bSeparate = bSeparate;
00106       // Return success.
00107       bResult = TRUE;
00108     }
00109   }
00110
00111   return (bResult);
00112 }
00113
00114
00115 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00116   Method:   CListWin::SetCurSel
00117
00118   Summary:  Sets the current selection to the specified list item. Also
00119             sets keyboard focus to the ListWin listbox.
00120
00121   Args:     INT iIndex
00122               Zero-based Listbox Index of the selection to set.
00123
00124   Returns:  BOOL
00125               TRUE.
00126 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00127 BOOL CListWin::SetCurSel(
00128        INT iIndex)
00129 {
00130   BOOL bOk = FALSE;
00131
00132   if (IsWindow(m_hWnd))
00133   {
00134     iIndex = (int)::SendMessage(
00135                  m_hWnd,
00136                  LB_SETCURSEL,
00137                  iIndex,
00138                  0);
00139     if (LB_ERR != iIndex && iIndex >= 0)
00140     {
00141       ::SetFocus(m_hWnd);
00142       bOk = TRUE;
00143     }
00144   }
00145
00146   return bOk;
00147 }
00148
00149
00150 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00151   Method:   CListWin::GetCurSel
00152
00153   Summary:  Gets the index (page number) of the current listbox selection.
00154
00155   Args:     INT* piPage
00156               Address of output INT Page number variable.
00157
00158   Returns:  BOOL
00159               TRUE.
00160 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00161 BOOL CListWin::GetCurSel(
00162        INT* piPage)
00163 {
00164   BOOL bOk = FALSE;
00165   INT iIndex;
00166
00167   if (IsWindow(m_hWnd))
00168   {
00169     iIndex = (int)::SendMessage(
00170                  m_hWnd,
00171                  LB_GETCURSEL,
00172                  0,
00173                  0);
00174     if (LB_ERR != iIndex && iIndex >= 0)
00175     {
00176       *piPage = iIndex;
00177       bOk = TRUE;
00178     }
00179   }
00180
00181   return bOk;
00182 }
00183
00184
00185 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00186   Method:   CListWin::AddFmt
00187
00188   Summary:  Add a printf-style formatted message as a separate line in the
00189             ListWin listbox.
00190
00191   Args:     LPTSTR szFmt
00192               The format/message string to control the display line.
00193             [...]
00194               Arguments to match those specified in the format string.
00195
00196   Returns:  BOOL
00197               TRUE if successful; FALSE if not.
00198 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00199 BOOL CListWin::AddFmt(
00200        LPTSTR szFmt,
00201        ...)
00202 {
00203   BOOL bResult = FALSE;
00204   va_list arglist;
00205   va_start(arglist, szFmt);
00206   TCHAR szLine[MAX_STRING_LENGTH];
00207   INT iIndex;
00208
00209   // Use the format string and arguments to format the line text.
00210   wvsprintf(szLine, szFmt, arglist);
00211
00212   // Send the newly formated message string to the ListWin listbox.
00213   if (IsWindow(m_hWnd))
00214   {
00215     ::SendMessage(
00216         m_hWnd,
00217         LB_ADDSTRING,
00218         0,
00219         (LPARAM)szLine);
00220     iIndex = (int)::SendMessage(
00221                  m_hWnd,
00222                  LB_GETCOUNT,
00223                  0,
00224                  0);
00225     if (LB_ERR != iIndex && iIndex > 0)
00226     {
00227       --iIndex;
00228       ::SendMessage(
00229           m_hWnd,
00230           LB_SETCURSEL,
00231           (WPARAM)iIndex,
00232           0);
00233     }
00234     bResult = TRUE;
00235   }
00236
00237   return (bResult);
00238 }
00239
00240
00241 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00242   Method:   CListWin::InsertFmt
00243
00244   Summary:  Insert a printf-style formatted entry as a separate line in
00245             the ListWin listbox at the given index.
00246
00247   Args:     SHORT nIndex,
00248               Index in the Listbox at which to perform the insert.
00249             LPTSTR szFmt
00250               The format/message string to control the display line.
00251             [...]
00252               Arguments to match those specified in the format string.
00253
00254   Returns:  BOOL
00255               TRUE if successful; FALSE if not.
00256 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00257 BOOL CListWin::InsertFmt(
00258        INT iIndex,
00259        LPTSTR szFmt,
00260        ...)
00261 {
00262   BOOL bResult = FALSE;
00263   va_list arglist;
00264   va_start(arglist, szFmt);
00265   TCHAR szLine[MAX_STRING_LENGTH];
00266   INT iNewItem;
00267
00268   // Use the format string and arguments to format the line text.
00269   wvsprintf(szLine, szFmt, arglist);
00270
00271   // Send the newly formated message string to the ListWin Listbox.
00272   if (IsWindow(m_hWnd))
00273   {
00274     iNewItem = (int)::SendMessage(
00275                    m_hWnd,
00276                    LB_INSERTSTRING,
00277                    iIndex,
00278                    (LPARAM)szLine);
00279     if (LB_ERR != iNewItem && iNewItem > 0)
00280     {
00281       ::SendMessage(
00282           m_hWnd,
00283           LB_SETCURSEL,
00284           (WPARAM)iNewItem,
00285           0);
00286     }
00287     bResult = TRUE;
00288   }
00289
00290   return (bResult);
00291 }
00292
00293
00294 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00295   Method:   CListWin::Resize
00296
00297   Summary:  Resizes the listbox to a new width and height.  Called during
00298             the parent window's WM_SIZE to fit the listbox to the client
00299             area of the parent window.  It only honors this request if it
00300             is an integral child window.
00301
00302   Args:     INT nWidth
00303               New width in pixels of the listbox.
00304             INT nHeight
00305               New height in pixels of the listbox.
00306
00307   Returns:  BOOL
00308               TRUE if successful; FALSE if not.
00309 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00310 BOOL CListWin::Resize(
00311        INT nWidth,
00312        INT nHeight)
00313 {
00314   BOOL bResult = FALSE;
00315
00316   if (!m_bSeparate)
00317     bResult = ::MoveWindow(m_hWnd, 0, 0, nWidth, nHeight, TRUE);
00318
00319   return (bResult);
00320 }
00321
00322
00323 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00324   Method:   CListWin::Clear
00325
00326   Summary:  Clears all displayh lines from the ListWin listbox.
00327
00328   Args:     void
00329
00330   Returns:  BOOL
00331               TRUE.
00332 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00333 BOOL CListWin::Clear(
00334        void)
00335 {
00336   if (IsWindow(m_hWnd))
00337     ::SendMessage(
00338         m_hWnd,
00339         LB_RESETCONTENT,
00340         0,
00341         0);
00342
00343   return (TRUE);
00344 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/devicenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

devicenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CDeviceNode class.  This node is a child of
00014 //                CStaticNode.  It represents a Virtual Storage device
00015 //
00016 //
00017
00018
00019 #ifndef _CLASS_CDEVICENODE_
00020 #define _CLASS_CDEVICENODE_
00021
00022 #include "Globals.h"
00023 #include "FolderNode.h"      // Folders are children of this node
00024 #include "LListImpl.h"
00025
00026
00027 class CComponentData;        // References
00028
00029 //---------------------------------------------------------------------------
00030 class CDeviceNode : public CBaseNode
00031 {
00032   public:
00033     CDeviceNode();
00034     virtual ~CDeviceNode();
00035
00036     HRESULT Initialize( NODE_PROPERTIES* pNodeProps );
00037     VOID    ToggleStatus();
00038
00039   // Virtual methods
00040   public:
00041     ULONG   GetNodeType() { return NODETYPE_DEVICE; }
00042     GUID&   GetNodeGUID() { return thisGUID; }
00043
00044     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00045     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00046     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00047
00048   ///////////////////////////////////////////////////////////////////////////
00049   // Notification handlers
00050   //
00051   public:
00052     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00053     HRESULT OnShow( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00054     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData );
00055     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData );
00056
00057   ///////////////////////////////////////////////////////////////////////////
00058   //  Context Menu methods
00059   //
00060   public:
00061     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00062     HRESULT Command( long lCommandID );
00063
00064   ///////////////////////////////////////////////////////////////////////////
00065   // Private helpers
00066   //
00067   private:
00068     HRESULT  DeleteChildItems( LPCONSOLENAMESPACE2 ipCNS2 );
00069     HRESULT  InsertChildItems( LPCONSOLENAMESPACE2 ipCNS2 );
00070     HRESULT  RefreshNodeList();
00071     VOID     RemoveNodes();
00072
00073   private:
00074     static GUID  thisGUID;
00075     DWORD        m_dwAttributes;
00076     HSCOPEITEM   m_hParentNode;
00077     LPWSTR       m_wzStatus;
00078     BOOL         m_bOnlineStatus;
00079
00080     CLListImpl<CBaseNode*,CBaseNode*>  m_NodeList;
00081     CComponentData*                    m_pCompData;
00082
00083 };
00084
00085 #endif //_CLASS_CDEVICENODE_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SMmStream Member List

This is the complete list of members for SMmStream, including all inherited members.
_pStream | SMmStream | [private]
Acquire() | SMmStream | [inline]
operator!() | SMmStream | [inline]
operator*() | SMmStream | [inline]
operator->() | SMmStream | [inline]
Set(PMmStream *pStream) | SMmStream | [inline]
SMmStream(PMmStream *pStream) | SMmStream | [inline]
~SMmStream() | SMmStream |
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/spy.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

spy.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module SPY.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016 #include "Spy.h"
00017
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // Defines
00021 //
00022 /////////////////////////////////////////////////////////////////////////////
00023
00024 // Format:
00025 // HEADSIGNITURE + BUFFERSIZE + BUFFERID + PFILENAME + LINENUMBER + BUFFER + TAILSIGNITURE
00026
00027 //All the header info must be ULONGs,
00028 //so that the user buffer falls on a word boundary
00029 //The tail must be a byte, since if it was a ULONG it would
00030 //also require a word boundary, but the users buffer could
00031 //be an odd number of bytes, so instead of rounding up, just use BYTE
00032
00033 const ULONG   HEADSIZE    = sizeof(ULONG);  //HEADSIGNITURE
00034 const SIZE_T  LENGTHSIZE    = sizeof(SIZE_T); //BUFFERSIZE
00035 const ULONG   IDSIZE      = sizeof(ULONG);  //BUFFERID
00036 const ULONG   FILENAMESIZE  = sizeof(WCHAR*); //PFILENAME
00037 const ULONG   LINENUMBERSIZE  = sizeof(ULONG);  //LINENUMBER
00038 const ULONG   TAILSIZE    = sizeof(BYTE);   //TAILSIGNITURE
00039
00040 const ULONG HEADERSIZE = ROUNDUP(HEADSIZE + LENGTHSIZE + IDSIZE + FILENAMESIZE + LINENUMBERSIZE);
00041 const ULONG FOOTERSIZE = TAILSIZE;
00042
00043 const BYTE  HEADSIGN = '{';
00044 const BYTE  TAILSIGN = '}';
00045
00046 const BYTE  ALLOCSIGN = '$';
00047 const BYTE  FREESIGN  = 'Z';
00048
00049 #define HEAD_OFFSET(pActual)    ((BYTE*)pActual)
00050 #define TAIL_OFFSET(pActual)    (USERS_OFFSET(pActual)+BUFFER_LENGTH(pActual))
00051
00052 #define USERS_OFFSET(pActual)   (HEAD_OFFSET(pActual) + HEADERSIZE)
00053 #define HEADER_OFFSET(pRequest)   ((BYTE*)(pRequest) - HEADERSIZE)
00054
00055 #define LENGTH_OFFSET(pActual)    (HEAD_OFFSET(pActual) + HEADSIZE)
00056 #define BUFFER_LENGTH(pActual)    (*(SIZE_T*)LENGTH_OFFSET(pActual))
00057
00058 #define ID_OFFSET(pActual)      (LENGTH_OFFSET(pActual) + LENGTHSIZE)
00059 #define BUFFER_ID(pActual)      (*(ULONG*)ID_OFFSET(pActual))
00060
00061 #define FILENAME_OFFSET(pActual)  (ID_OFFSET(pActual) + IDSIZE)
00062 #define BUFFER_FILENAME(pActual)  (*(WCHAR**)FILENAME_OFFSET(pActual))
00063
00064 #define LINENUMBER_OFFSET(pActual)  (FILENAME_OFFSET(pActual) + FILENAMESIZE)
00065 #define BUFFER_LINENUMBER(pActual)  (*(ULONG*)LINENUMBER_OFFSET(pActual))
00066
00067 #define HEAD_SIGNITURE(pActual)   (*(ULONG*)HEAD_OFFSET(pActual))
00068 #define TAIL_SIGNITURE(pActual)   (*(BYTE*)TAIL_OFFSET(pActual))
00069
00070
00071 /////////////////////////////////////////////////////////////////////////////
00072 // CMallocSpy::CMallocSpy()
00073 //
00074 /////////////////////////////////////////////////////////////////////////////
00075 CMallocSpy::CMallocSpy()
00076 {
00077     m_cRef      = 1;
00078   m_cbRequest   = 0;
00079   m_cAllocations  = 0;
00080 }
00081
00082 /////////////////////////////////////////////////////////////////////////////
00083 // CMallocSpy::~CMallocSpy()
00084 //
00085 /////////////////////////////////////////////////////////////////////////////
00086 CMallocSpy::~CMallocSpy()
00087 {
00088   //Remove all the elements of the list
00089   ASSERT(m_cRef == 0);
00090   CAllocList.RemoveAll();
00091 }
00092
00093
00094 /////////////////////////////////////////////////////////////////////////////
00095 // CMallocSpy::Reset()
00096 //
00097 /////////////////////////////////////////////////////////////////////////////
00098 void CMallocSpy::Reset()
00099 {
00100   //Reset the number of allocations
00101   m_cAllocations = 0;;
00102 }
00103
00104
00105 /////////////////////////////////////////////////////////////////////////////
00106 // HRESULT CMallocSpy::AddToList
00107 //
00108 /////////////////////////////////////////////////////////////////////////////
00109 HRESULT CMallocSpy::AddToList(void* pv)
00110 {
00111   ASSERT(pv);
00112
00113   //NOTE:  We don't have to worry about access into our list in Multi-Threads as COM states:
00114   //"The call to the pre-method through the return from the corresponding post-method
00115   //is guaranteed to be thread-safe in multi-threaded operations."
00116
00117   //Add this element to the list
00118   CAllocList.AddTail(pv);
00119   return S_OK;
00120 }
00121
00122
00123 /////////////////////////////////////////////////////////////////////////////
00124 // HRESULT CMallocSpy::RemoveFromList
00125 //
00126 /////////////////////////////////////////////////////////////////////////////
00127 HRESULT CMallocSpy::RemoveFromList(void* pv)
00128 {
00129   ASSERT(pv);
00130
00131   //NOTE:  We don't have to worry about access into our list in Multi-Threads as COM states:
00132   //"The call to the pre-method through the return from the corresponding post-method
00133   //is guaranteed to be thread-safe in multi-threaded operations."
00134
00135   //Remove this element from the list
00136   POSITION pos = CAllocList.Find(pv);
00137   if(pos)
00138   {
00139     CAllocList.RemoveAt(pos);
00140     return S_OK;
00141   }
00142
00143   return E_FAIL;
00144 }
00145
00146 /////////////////////////////////////////////////////////////////////////////
00147 // HRESULT CMallocSpy::Register
00148 //
00149 /////////////////////////////////////////////////////////////////////////////
00150 HRESULT CMallocSpy::Register()
00151 {
00152   //NOTE:  This may fail, if unreigster failed to unload the previous one.
00153   //CO_E_OBJISREG There is already a registered spy.
00154   return CoRegisterMallocSpy(this); // Does an AddRef on Object
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // HRESULT CMallocSpy::Unregister
00159 //
00160 /////////////////////////////////////////////////////////////////////////////
00161 HRESULT CMallocSpy::Unregister()
00162 {
00163   //NOTE:  Unregister will fail if their are outstanding leaks as the docs indicate:
00164
00165   //If the return code is E_ACCESSDENIED, there are still outstanding allocations that were
00166   //made while the spy was active. In this case, the registered spy cannot be revoked at this
00167   //time because it may have attached arbitrary headers and/or trailers to these allocations
00168   //that only the spy knows about. Only the spy's PreFree (or PreRealloc) method knows how to
00169   //account for these headers and trailers. Before returning E_ACCESSDENIED, CoRevokeMallocSpy
00170   //notes internally that a revoke is pending. When the outstanding allocations have been freed,
00171   //the revoke proceeds automatically, releasing the IMallocSpy object. Thus, it is necessary to
00172   //call CoRevokeMallocSpy only once for each call to CoRegisterMallocSpy, even if E_ACCESSDENIED
00173   //is returned.
00174   return CoRevokeMallocSpy(); //Does a Release on Object
00175 }
00176
00177
00178
00179 /////////////////////////////////////////////////////////////////////////////
00180 // HRESULT CMallocSpy::DumpLeaks
00181 //
00182 /////////////////////////////////////////////////////////////////////////////
00183 HRESULT CMallocSpy::DumpLeaks()
00184 {
00185   ULONG cTotalLeaks = 0;
00186   SIZE_T  cTotalBytes = 0;
00187   DWORD dwSelection = IDOK;
00188
00189   //Display Leaks to the Output Window
00190   while(!CAllocList.IsEmpty())
00191   {
00192     //Obtain the pointer to the leaked memory
00193     void* pRequest = CAllocList.RemoveHead();
00194     ASSERT(pRequest);
00195
00196     void* pActual = HEADER_OFFSET(pRequest);
00197     ASSERT(pActual);
00198
00199     //Make sure that the head/tail signitures are intact
00200     if(HEAD_SIGNITURE(pActual) != HEADSIGN)
00201       InternalTraceFmt(L"TRACE - IMallocSpy HeadSigniture Corrupted! - 0x%p, ID=%08lu, %lu byte(s)\n", pRequest, BUFFER_ID(pActual), BUFFER_LENGTH(pActual));
00202
00203     if(TAIL_SIGNITURE(pActual) != TAILSIGN)
00204       InternalTraceFmt(L"TRACE - IMallocSpy TailSigniture Corrupted! - 0x%p, ID=%08lu, %lu byte(s)\n", pRequest, BUFFER_ID(pActual), BUFFER_LENGTH(pActual));
00205
00206     SIZE_T  ulSize    = BUFFER_LENGTH(pActual);
00207     ULONG ulID    = BUFFER_ID(pActual);
00208     WCHAR*  pwszFileName= BUFFER_FILENAME(pActual);
00209     ULONG ulLine    = BUFFER_LINENUMBER(pActual);
00210
00211     //Display a message box for all leaks (until the user is tired of it...)
00212     if(dwSelection == IDOK)
00213     {
00214       dwSelection = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1,
00215         L"IMallocSpy Leak",
00216           L"IMallocSpy Leak:\n"
00217           L"0x%p, ID=%08lu, %lu byte(s), File: %s, Line %d\n\n",
00218           pRequest, ulID, ulSize, pwszFileName, ulLine);
00219     }
00220
00221     //Include FileName and Line Number of the leak...
00222     InternalTraceFmt(L"-- IMallocSpy Leak! - 0x%p,\tID=%08lu,\t%lu byte(s),\tFile: %s,\tLine %d" wWndEOL, pRequest, ulID, ulSize, pwszFileName, ulLine);
00223
00224     cTotalLeaks++;
00225     cTotalBytes += ulSize;
00226
00227     //Free the Leak
00228     //You really cant free the leak since the app could be potentially still
00229     //using it.  Or the DLL may still be in use or have attached threads...
00230     //SAFE_FREE(pActual);
00231   }
00232
00233   if(cTotalLeaks)
00234     InternalTraceFmt(L"-- IMallocSpy Total Leaks: %lu = %lu byte(s)" wWndEOL, cTotalLeaks, cTotalBytes);
00235   return S_OK;
00236 }
00237
00238 /////////////////////////////////////////////////////////////////////////////
00239 // HRESULT CMallocSpy::QueryInterface
00240 //
00241 /////////////////////////////////////////////////////////////////////////////
00242 HRESULT CMallocSpy::QueryInterface(REFIID riid, void** ppIUnknown)
00243 {
00244   if(!ppIUnknown)
00245     return E_INVALIDARG;
00246   *ppIUnknown = NULL;
00247
00248   //IID_IUnknown
00249     if(riid == IID_IUnknown)
00250     *ppIUnknown = this;
00251     //IDD_IMallocSpy
00252   else if(riid == IID_IMallocSpy)
00253          *ppIUnknown =  this;
00254
00255   if(*ppIUnknown)
00256     {
00257         ((IUnknown*)*ppIUnknown)->AddRef();
00258         return S_OK;
00259   }
00260
00261   return E_NOINTERFACE;
00262 }
00263
00264 /////////////////////////////////////////////////////////////////////////////
00265 // ULONG CMallocSpy::AddRef
00266 //
00267 /////////////////////////////////////////////////////////////////////////////
00268 ULONG CMallocSpy::AddRef()
00269 {
00270     return ++m_cRef;
00271 }
00272
00273 /////////////////////////////////////////////////////////////////////////////
00274 // ULONG CMallocSpy::Release
00275 //
00276 /////////////////////////////////////////////////////////////////////////////
00277 ULONG CMallocSpy::Release()
00278 {
00279     if(--m_cRef)
00280       return m_cRef;
00281
00282   TRACE(L"TRACE - Releasing IMallocSpy\n");
00283
00284     delete this;
00285     return 0;
00286 }
00287
00288
00289 /////////////////////////////////////////////////////////////////////////////
00290 // CMallocSpy::PreAlloc
00291 //
00292 /////////////////////////////////////////////////////////////////////////////
00293 SIZE_T CMallocSpy::PreAlloc(SIZE_T cbRequest)
00294 {
00295   //cbRequest is the orginal number of bytes requested by the user
00296   //Store the users requested size
00297     m_cbRequest = cbRequest;
00298
00299   //Return the total size requested, plus extra for header/footer
00300   return (m_cbRequest + HEADERSIZE + FOOTERSIZE);
00301 }
00302
00303 /////////////////////////////////////////////////////////////////////////////
00304 // void* CMallocSpy::PostAlloc
00305 //
00306 /////////////////////////////////////////////////////////////////////////////
00307 void* CMallocSpy::PostAlloc(void* pActual)
00308 {
00309   //E_OUTOFMEMORY condition
00310   if(!pActual)
00311     return NULL;
00312
00313   //pActual is the pointer to the head of the buffer, including the header
00314   //Add the users pointer to the list
00315   AddToList(USERS_OFFSET(pActual));
00316
00317   //Place the HeadSigniture in the HEADER
00318   HEAD_SIGNITURE(pActual) = HEADSIGN;
00319
00320   //Place the Size in the HEADER
00321   BUFFER_LENGTH(pActual) = m_cbRequest;
00322
00323   //Place the ID in the HEADER
00324   ULONG ulID = ++m_cAllocations;
00325   BUFFER_ID(pActual) = ulID;
00326
00327   //Place the FILENAME in the HEADER
00328   BUFFER_FILENAME(pActual) = NULL;
00329
00330   //Place the LINE NUMBER in the HEADER
00331   BUFFER_LINENUMBER(pActual) = 0;
00332
00333   //Set the UsersBuffer to a known char
00334     memset(USERS_OFFSET(pActual), ALLOCSIGN, m_cbRequest);
00335
00336   //Place the TailSigniture in the HEADER
00337   TAIL_SIGNITURE(pActual) = TAILSIGN;
00338
00339   //Show Allocation
00340   if(GetErrorPosting(EP_IMALLOC_ALLOCS))
00341     InternalTraceFmt(L"TRACE - IMallocSpy Alloc - 0x%p,\tID=%08lu,\t%lu byte(s)\n", USERS_OFFSET(pActual), ulID, m_cbRequest);
00342
00343   //Break at indicated Allocation
00344   if(g_dwBreakID == ulID)
00345     BREAKINTO();
00346
00347   // Return the actual users buffer
00348     return USERS_OFFSET(pActual);
00349 }
00350
00351 /////////////////////////////////////////////////////////////////////////////
00352 // void* CMallocSpy::PreFree
00353 //
00354 /////////////////////////////////////////////////////////////////////////////
00355 void* CMallocSpy::PreFree(void* pRequest, BOOL fSpyed)
00356 {
00357   //pRequest is the users pointer to thier buffer, not the header
00358
00359   //E_OUTOFMEMORY condition
00360   if(!pRequest)
00361     return NULL;
00362
00363     //If this memory was alloced under IMallocSpy, need to remove it
00364     if(fSpyed)
00365   {
00366     //Remove this pointer from the list
00367     RemoveFromList(pRequest);
00368
00369     void* pActual = HEADER_OFFSET(pRequest);
00370     ULONG ulID    = BUFFER_ID(pActual);
00371
00372     //Make sure that the head/tail signitures are intact
00373     if(HEAD_SIGNITURE(pActual) != HEADSIGN)
00374       InternalTraceFmt(L"TRACE - IMallocSpy HeadSigniture Corrupted! - 0x%p, ID=%08lu, %lu byte(s)\n", pRequest, ulID, BUFFER_LENGTH(pActual));
00375
00376     if(TAIL_SIGNITURE(pActual) != TAILSIGN)
00377       InternalTraceFmt(L"TRACE - IMallocSpy TailSigniture Corrupted! - 0x%p, ID=%08lu, %lu byte(s)\n", pRequest, ulID, BUFFER_LENGTH(pActual));
00378
00379     //Break at indicated Allocation
00380     if(g_dwBreakID == ulID)
00381       BREAKINTO();
00382
00383     //Set the UsersBuffer to a known char
00384     memset(pRequest, FREESIGN, BUFFER_LENGTH(pActual));
00385
00386     //Need to return the actual header pointer to
00387     //free the entire buffer including the heading
00388     return pActual;
00389   }
00390
00391   //else
00392   return pRequest;
00393 }
00394
00395
00396 /////////////////////////////////////////////////////////////////////////////
00397 // void CMallocSpy::PostFree
00398 //
00399 /////////////////////////////////////////////////////////////////////////////
00400 void CMallocSpy::PostFree(BOOL fSpyed)
00401 {
00402     // Note the free or whatever
00403     return;
00404 }
00405
00406
00407 /////////////////////////////////////////////////////////////////////////////
00408 // CMallocSpy::PreRealloc
00409 //
00410 /////////////////////////////////////////////////////////////////////////////
00411 SIZE_T CMallocSpy::PreRealloc(void* pRequest, SIZE_T cbRequest,
00412                              void** ppNewRequest, BOOL fSpyed)
00413 {
00414   ASSERT(pRequest && ppNewRequest);
00415
00416   //If this was alloced under IMallocSpy we need to adjust
00417   //the size stored in the header
00418     if(fSpyed)
00419     {
00420     //Remove the original pRequest pointer from the list
00421     //Since Realloc could change the original pointer
00422     RemoveFromList(pRequest);
00423
00424         //Find the start
00425     *ppNewRequest = HEADER_OFFSET(pRequest);
00426
00427     //Store the new desired size
00428     m_cbRequest = cbRequest;
00429
00430     //Return the total size, including extra
00431     return (m_cbRequest + HEADERSIZE + FOOTERSIZE);
00432     }
00433
00434   //else
00435   *ppNewRequest = pRequest;
00436     return cbRequest;
00437 }
00438
00439
00440 /////////////////////////////////////////////////////////////////////////////
00441 // void* CMallocSpy::PostRealloc
00442 //
00443 /////////////////////////////////////////////////////////////////////////////
00444 void* CMallocSpy::PostRealloc(void* pActual, BOOL fSpyed)
00445 {
00446   //E_OUTOFMEMORY condition
00447   if(!pActual)
00448     return NULL;
00449
00450     //If this buffer was alloced under IMallocSpy
00451     if(fSpyed)
00452     {
00453     //pActual is the pointer to header
00454     //Add the new pointer to the list
00455     AddToList(USERS_OFFSET(pActual));
00456
00457     //HeadSigniture should still be intact
00458     if(HEAD_SIGNITURE(pActual) != HEADSIGN)
00459       InternalTraceFmt(L"TRACE - IMallocSpy HeadSigniture Corrupted! - 0x%p, ID=%08lu, %lu byte(s)\n", USERS_OFFSET(pActual), BUFFER_ID(pActual), BUFFER_LENGTH(pActual));
00460
00461     //ID should still be intact
00462
00463     //Place the new Size in the HEADER
00464     BUFFER_LENGTH(pActual) = m_cbRequest;
00465
00466     //Place the new FileName in the HEADER
00467     BUFFER_FILENAME(pActual) = NULL;
00468
00469     //Place the new Line Number in the HEADER
00470     BUFFER_LINENUMBER(pActual) = 0;
00471
00472         //Need to place the tail signiture again,
00473     //since it will be over written by the realloc
00474     TAIL_SIGNITURE(pActual) = TAILSIGN;
00475
00476     //Show ReAllocations
00477     if(GetErrorPosting(EP_IMALLOC_ALLOCS))
00478       InternalTraceFmt(L"TRACE - IMallocSpy Realloc - 0x%p,\tID=%08lu,\t%lu byte(s)\n", USERS_OFFSET(pActual), BUFFER_ID(pActual), m_cbRequest);
00479
00480     //Return the actual "user" buffer
00481     return USERS_OFFSET(pActual);
00482     }
00483
00484   //else
00485     return pActual;
00486 }
00487
00488
00489 /////////////////////////////////////////////////////////////////////////////
00490 // void* CMallocSpy::PreGetSize
00491 //
00492 /////////////////////////////////////////////////////////////////////////////
00493 void* CMallocSpy::PreGetSize(void* pRequest, BOOL fSpyed)
00494 {
00495     if (fSpyed)
00496         return HEADER_OFFSET(pRequest);
00497
00498     return pRequest;
00499 }
00500
00501
00502
00503 /////////////////////////////////////////////////////////////////////////////
00504 // CMallocSpy::PostGetSize
00505 //
00506 /////////////////////////////////////////////////////////////////////////////
00507 SIZE_T CMallocSpy::PostGetSize(SIZE_T cbActual, BOOL fSpyed)
00508 {
00509     if (fSpyed)
00510         return cbActual - HEADERSIZE - FOOTERSIZE;
00511
00512     return cbActual;
00513 }
00514
00515
00516
00517
00518 /////////////////////////////////////////////////////////////////////////////
00519 // void* CMallocSpy::PreDidAlloc
00520 //
00521 /////////////////////////////////////////////////////////////////////////////
00522 void* CMallocSpy::PreDidAlloc(void* pRequest, BOOL fSpyed)
00523 {
00524     if (fSpyed)
00525         return HEADER_OFFSET(pRequest);
00526
00527   return pRequest;
00528 }
00529
00530
00531 /////////////////////////////////////////////////////////////////////////////
00532 // BOOL CMallocSpy::PostDidAlloc
00533 //
00534 /////////////////////////////////////////////////////////////////////////////
00535 BOOL CMallocSpy::PostDidAlloc(void* pRequest, BOOL fSpyed, BOOL fActual)
00536 {
00537     return fActual;
00538 }
00539
00540
00541
00542 /////////////////////////////////////////////////////////////////////////////
00543 // void CMallocSpy::PreHeapMinimize
00544 //
00545 /////////////////////////////////////////////////////////////////////////////
00546 void CMallocSpy::PreHeapMinimize()
00547 {
00548     // We don't do anything here
00549     return;
00550 }
00551
00552
00553 /////////////////////////////////////////////////////////////////////////////
00554 // void CMallocSpy::PostHeapMinimize
00555 //
00556 /////////////////////////////////////////////////////////////////////////////
00557 void CMallocSpy::PostHeapMinimize()
00558 {
00559     // We don't do anything here
00560     return;
00561 }
00562
00563
00564
00565 /////////////////////////////////////////////////////////////////////////////
00566 // CRTReportHook
00567 //
00568 /////////////////////////////////////////////////////////////////////////////
00569 #ifdef _DEBUG
00570 _CRT_REPORT_HOOK g_fpPrevCRTReportHook = NULL;
00571 int __cdecl CRTReportHook(INT nReportType, CHAR* pszMsg, INT* pReturnVal)
00572 {
00573   //Output
00574   if(pReturnVal)
00575     *pReturnVal = 0;
00576
00577   //If the user wants us to handle the ASSERTs...
00578   if(TRUE)
00579   {
00580     //Determine what type of report this is...
00581     switch(nReportType)
00582     {
00583       case _CRT_ASSERT: // - only defined for DEBUG
00584         //Display the Assert
00585         InternalTraceFmt(L"---------- C-Runtime Assert ----------" wWndEOL);
00586         InternalTraceFmt(L"%S", pszMsg);
00587         return TRUE;
00588
00589       case _CRT_ERROR:  // - only defined for DEBUG
00590         //Display the Error
00591         InternalTraceFmt(L"---------- C-Runtime Error ----------" wWndEOL);
00592         InternalTraceFmt(L"%S", pszMsg);
00593         return TRUE;
00594
00595       default:
00596         //There may be other reports or messages going to the C-runtime
00597         //such as _CRT_WARN and _CRT_ERRCNT which we don't need to filter...
00598         //CRT_WARN is used frequently by apps instead of OutputDebugString
00599         break;
00600     };
00601   }
00602
00603   //If we have made it this far the ASSERT was not handled, so we should either call the previous
00604   //installed CallBack (that we replaced if there was one) or return FALSE to the CRuntime to
00605   //indicate we didn't handle this error, so do the normal processing for the error...
00606   if(g_fpPrevCRTReportHook)
00607     return g_fpPrevCRTReportHook(nReportType, pszMsg, pReturnVal);
00608   return FALSE;
00609 }
00610
00611 #endif //_DEBUG
00612
00613 void EnableCRTReportHook(BOOL fEnable)
00614 {
00615 #ifdef _DEBUG
00616   if(fEnable)
00617   {
00618     if(!g_fpPrevCRTReportHook)
00619       g_fpPrevCRTReportHook = _CrtSetReportHook(&CRTReportHook);
00620   }
00621   else
00622   {
00623     if(g_fpPrevCRTReportHook)
00624       _CrtSetReportHook(g_fpPrevCRTReportHook);
00625     g_fpPrevCRTReportHook = NULL;
00626   }
00627 #endif //_DEBUG
00628 }
00629
00630
00631
00632 /////////////////////////////////////////////////////////////////////////////
00633 // CRTAllocHook
00634 //
00635 /////////////////////////////////////////////////////////////////////////////
00636
00637 #ifdef _DEBUG
00638 //NOTE:  The reason we have our own function pointer type is that in MSVC5.0
00639 //the definition was "const char* filename", and in 6.0 they changed the debug definition to
00640 //"const unsigned char* filename".  So to compile with earlier versions we stick with the
00641 //older definition and just cast away the "unsigned" ness...
00642 typedef int (__cdecl * _CRT_ALLOC_HOOK_SIGNED)(int, void *, size_t, int, long, const char *, int);
00643
00644 _CRT_ALLOC_HOOK_SIGNED g_fpPrevCRTAllocHook = NULL;
00645 int __cdecl CRTAllocHook(int allocType, void *userData, size_t size, int blockType,
00646    long requestNumber, const /*unsigned*/ char *filename, int lineNumber)
00647 {
00648   //If the user wants us to handle the ASSERTs...
00649   if(TRUE)
00650   {
00651     //Determine what type of Alloc this is...
00652     switch(allocType)
00653     {
00654       case _HOOK_ALLOC: // - only defined for DEBUG
00655         //Display the Alloc
00656         InternalTraceFmt(L"TRACE - CRT Alloc - 0x%p, ID=%08lu, %lu byte(s), File: %S, Line: %d\n", userData, requestNumber, size, filename, lineNumber);
00657         return TRUE;
00658
00659       case _HOOK_REALLOC: // - only defined for DEBUG
00660         //Display the ReAlloc
00661         InternalTraceFmt(L"TRACE - CRT Realloc - 0x%p, ID=%08lu, %lu byte(s), File: %S, Line: %d\n", userData, requestNumber, size, filename, lineNumber);
00662         return TRUE;
00663
00664       case _HOOK_FREE:  // - only defined for DEBUG
00665         //Display the Free
00666         InternalTraceFmt(L"TRACE - CRT Free - 0x%p, ID=%08lu, %lu byte(s), File: %S, Line: %d\n", userData, requestNumber, size, filename, lineNumber);
00667         return TRUE;
00668
00669       default:
00670         //There may be other reports or messages going to the C-runtime
00671         break;
00672     };
00673   }
00674
00675   //After the hook function has finished processing, it must return a Boolean value,
00676   //which tells the main C run-time allocation process how to continue. When the hook function
00677   //wants the main allocation process to continue as if the hook function had never been called,
00678   //then the hook function should return TRUE.
00679   if(g_fpPrevCRTAllocHook)
00680     return g_fpPrevCRTAllocHook(allocType, userData, size, blockType, requestNumber, filename, lineNumber);
00681   return TRUE;
00682 }
00683 #endif //_DEBUG
00684
00685 void EnableCRTAllocHook(BOOL fEnable)
00686 {
00687 #ifdef _DEBUG
00688   if(fEnable)
00689   {
00690     if(!g_fpPrevCRTAllocHook)
00691       g_fpPrevCRTAllocHook  = (_CRT_ALLOC_HOOK_SIGNED)_CrtSetAllocHook((_CRT_ALLOC_HOOK)&CRTAllocHook);
00692   }
00693   else
00694   {
00695     if(g_fpPrevCRTAllocHook)
00696       _CrtSetAllocHook((_CRT_ALLOC_HOOK)g_fpPrevCRTAllocHook);
00697     g_fpPrevCRTAllocHook = NULL;
00698   }
00699 #endif //_DEBUG
00700 }
00701
00702
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/compdata.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

compdata.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENTDATA_
00016 #define _CLASS_CCOMPONENTDATA_
00017
00018
00019 #include <ObjIdl.h>
00020 #include "Globals.h"
00021 #include "StaticNode.h"
00022 #include "Comp.h"
00023
00024 //---------------------------------------------------------------------------
00025 class CComponentData : public IComponentData2
00026 {
00027   private:
00028     ULONG                m_cRef;
00029     LPCONSOLE            m_ipConsole2;           // Not used in this sample
00030     LPCONSOLENAMESPACE   m_ipConsoleNameSpace2;  // Not used in this sample
00031     CStaticNode*         m_pStaticNode;
00032
00033   public:
00034     CComponentData();
00035     ~CComponentData();
00036
00037     /////////////////////////////////////////////////////////////////////////
00038     // Interface IUnknown
00039     //
00040     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00041     STDMETHODIMP_(ULONG) AddRef();
00042     STDMETHODIMP_(ULONG) Release();
00043
00044     /////////////////////////////////////////////////////////////////////////
00045     // Interface IComponentData
00046     //
00047     HRESULT STDMETHODCALLTYPE Initialize
00048             ( /*[in] */ LPUNKNOWN pUnknown );
00049
00050     HRESULT STDMETHODCALLTYPE CreateComponent
00051             ( /*[out]*/ LPCOMPONENT __RPC_FAR* ppComponent);
00052
00053     HRESULT STDMETHODCALLTYPE Notify
00054             ( /*[in] */ LPDATAOBJECT ipDataObject,
00055               /*[in] */ MMC_NOTIFY_TYPE MmcEvent,
00056               /*[in] */ LPARAM nArg,
00057               /*[in] */ LPARAM nParam
00058             );
00059
00060     HRESULT STDMETHODCALLTYPE Destroy( void);
00061
00062     HRESULT STDMETHODCALLTYPE QueryDataObject
00063             ( /*[in] */  MMC_COOKIE uCookie,
00064               /*[in] */  DATA_OBJECT_TYPES nEnumType,
00065               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00066             );
00067
00068     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00069             ( /* [out][in] */ SCOPEDATAITEM __RPC_FAR* pScopeDataItem );
00070
00071     HRESULT STDMETHODCALLTYPE CompareObjects
00072             ( /*[in] */ LPDATAOBJECT lpDataObjectA,
00073               /*[in] */ LPDATAOBJECT lpDataObjectB
00074             );
00075
00076     HRESULT STDMETHODCALLTYPE QueryDispatch
00077             ( /*[in] */  MMC_COOKIE  nCookie,
00078               /*[in] */  DATA_OBJECT_TYPES eType,
00079               /*[out]*/  LPDISPATCH* pipDispatch
00080             );
00081
00082
00083   // Pulic helper methods
00084   public:
00085     CStaticNode* GetStaticNode() { return m_pStaticNode; }
00086
00087 };
00088
00089 #endif //_CLASS_CCOMPONENTDATA_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/_Recordset.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

_Recordset.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface _Recordset
00019 /** @com.interface(iid=00000556-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface _Recordset extends msado15.Recordset21
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=1000, type=PROPGET, name="AbsolutePosition", name2="getAbsolutePosition", addFlagsVtable=4)
00027       @com.parameters([type=I4] return) */
00028   public int getAbsolutePosition();
00029
00030   /** @com.method(vtoffset=6, dispid=1000, type=PROPPUT, name="AbsolutePosition", name2="putAbsolutePosition", addFlagsVtable=4)
00031       @com.parameters([in,type=I4] pl) */
00032   public void setAbsolutePosition(int pl);
00033
00034   /** @com.method(vtoffset=7, dispid=1001, type=PROPPUTREF, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00035       @com.parameters([in,iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] pvar) */
00036   public void setActiveConnection(Object pvar);
00037
00038   /** @com.method(vtoffset=8, dispid=1001, type=PROPPUT, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00039       @com.parameters([in,type=VARIANT] pvar) */
00040   public void setActiveConnection(Variant pvar);
00041
00042   /** @com.method(vtoffset=9, dispid=1001, type=PROPGET, name="ActiveConnection", name2="getActiveConnection", addFlagsVtable=4)
00043       @com.parameters([type=VARIANT] return) */
00044   public Variant getActiveConnection();
00045
00046   /** @com.method(vtoffset=10, dispid=1002, type=PROPGET, name="BOF", name2="getBOF", addFlagsVtable=4)
00047       @com.parameters([type=BOOLEAN] return) */
00048   public boolean getBOF();
00049
00050   /** @com.method(vtoffset=11, dispid=1003, type=PROPGET, name="Bookmark", name2="getBookmark", addFlagsVtable=4)
00051       @com.parameters([type=VARIANT] return) */
00052   public Variant getBookmark();
00053
00054   /** @com.method(vtoffset=12, dispid=1003, type=PROPPUT, name="Bookmark", name2="putBookmark", addFlagsVtable=4)
00055       @com.parameters([in,type=VARIANT] pvBookmark) */
00056   public void setBookmark(Variant pvBookmark);
00057
00058   /** @com.method(vtoffset=13, dispid=1004, type=PROPGET, name="CacheSize", name2="getCacheSize", addFlagsVtable=4)
00059       @com.parameters([type=I4] return) */
00060   public int getCacheSize();
00061
00062   /** @com.method(vtoffset=14, dispid=1004, type=PROPPUT, name="CacheSize", name2="putCacheSize", addFlagsVtable=4)
00063       @com.parameters([in,type=I4] pl) */
00064   public void setCacheSize(int pl);
00065
00066   /** @com.method(vtoffset=15, dispid=1005, type=PROPGET, name="CursorType", name2="getCursorType", addFlagsVtable=4)
00067       @com.parameters([type=I4] return) */
00068   public int getCursorType();
00069
00070   /** @com.method(vtoffset=16, dispid=1005, type=PROPPUT, name="CursorType", name2="putCursorType", addFlagsVtable=4)
00071       @com.parameters([in,type=I4] plCursorType) */
00072   public void setCursorType(int plCursorType);
00073
00074   /** @com.method(vtoffset=17, dispid=1006, type=PROPGET, name="EOF", name2="getEOF", addFlagsVtable=4)
00075       @com.parameters([type=BOOLEAN] return) */
00076   public boolean getEOF();
00077
00078   /** @com.method(vtoffset=18, dispid=0, type=PROPGET, name="Fields", name2="getFields", addFlagsVtable=4)
00079       @com.parameters([iid=00000564-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00080   public msado15.Fields getFields();
00081
00082   /** @com.method(vtoffset=19, dispid=1008, type=PROPGET, name="LockType", name2="getLockType", addFlagsVtable=4)
00083       @com.parameters([type=I4] return) */
00084   public int getLockType();
00085
00086   /** @com.method(vtoffset=20, dispid=1008, type=PROPPUT, name="LockType", name2="putLockType", addFlagsVtable=4)
00087       @com.parameters([in,type=I4] plLockType) */
00088   public void setLockType(int plLockType);
00089
00090   /** @com.method(vtoffset=21, dispid=1009, type=PROPGET, name="MaxRecords", name2="getMaxRecords", addFlagsVtable=4)
00091       @com.parameters([type=I4] return) */
00092   public int getMaxRecords();
00093
00094   /** @com.method(vtoffset=22, dispid=1009, type=PROPPUT, name="MaxRecords", name2="putMaxRecords", addFlagsVtable=4)
00095       @com.parameters([in,type=I4] plMaxRecords) */
00096   public void setMaxRecords(int plMaxRecords);
00097
00098   /** @com.method(vtoffset=23, dispid=1010, type=PROPGET, name="RecordCount", name2="getRecordCount", addFlagsVtable=4)
00099       @com.parameters([type=I4] return) */
00100   public int getRecordCount();
00101
00102   /** @com.method(vtoffset=24, dispid=1011, type=PROPPUTREF, name="Source", name2="putSource", addFlagsVtable=4)
00103       @com.parameters([in,iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] pvSource) */
00104   public void setSource(Object pvSource);
00105
00106   /** @com.method(vtoffset=25, dispid=1011, type=PROPPUT, name="Source", name2="putSource", addFlagsVtable=4)
00107       @com.parameters([in,type=STRING] pvSource) */
00108   public void setSource(String pvSource);
00109
00110   /** @com.method(vtoffset=26, dispid=1011, type=PROPGET, name="Source", name2="getSource", addFlagsVtable=4)
00111       @com.parameters([type=VARIANT] return) */
00112   public Variant getSource();
00113
00114   /** @com.method(vtoffset=27, dispid=1012, type=METHOD, name="AddNew", addFlagsVtable=4)
00115       @com.parameters([in,type=VARIANT] FieldList, [in,type=VARIANT] Values) */
00116   public void AddNew(Variant FieldList, Variant Values);
00117
00118   /** @com.method(vtoffset=28, dispid=1013, type=METHOD, name="CancelUpdate", addFlagsVtable=4)
00119       @com.parameters() */
00120   public void CancelUpdate();
00121
00122   /** @com.method(vtoffset=29, dispid=1014, type=METHOD, name="Close", addFlagsVtable=4)
00123       @com.parameters() */
00124   public void Close();
00125
00126   /** @com.method(vtoffset=30, dispid=1015, type=METHOD, name="Delete", addFlagsVtable=4)
00127       @com.parameters([in,type=I4] AffectRecords) */
00128   public void Delete(int AffectRecords);
00129
00130   /** @com.method(vtoffset=31, dispid=1016, type=METHOD, name="GetRows", addFlagsVtable=4)
00131       @com.parameters([in,type=I4] Rows, [in,type=VARIANT] Start, [in,type=VARIANT] Fields, [type=VARIANT] return) */
00132   public Variant GetRows(int Rows, Variant Start, Variant Fields);
00133
00134   /** @com.method(vtoffset=32, dispid=1017, type=METHOD, name="Move", addFlagsVtable=4)
00135       @com.parameters([in,type=I4] NumRecords, [in,type=VARIANT] Start) */
00136   public void Move(int NumRecords, Variant Start);
00137
00138   /** @com.method(vtoffset=33, dispid=1018, type=METHOD, name="MoveNext", addFlagsVtable=4)
00139       @com.parameters() */
00140   public void MoveNext();
00141
00142   /** @com.method(vtoffset=34, dispid=1019, type=METHOD, name="MovePrevious", addFlagsVtable=4)
00143       @com.parameters() */
00144   public void MovePrevious();
00145
00146   /** @com.method(vtoffset=35, dispid=1020, type=METHOD, name="MoveFirst", addFlagsVtable=4)
00147       @com.parameters() */
00148   public void MoveFirst();
00149
00150   /** @com.method(vtoffset=36, dispid=1021, type=METHOD, name="MoveLast", addFlagsVtable=4)
00151       @com.parameters() */
00152   public void MoveLast();
00153
00154   /** @com.method(vtoffset=37, dispid=1022, type=METHOD, name="Open", addFlagsVtable=4)
00155       @com.parameters([in,type=VARIANT] Source, [in,type=VARIANT] ActiveConnection, [in,type=I4] CursorType, [in,type=I4] LockType, [in,type=I4] Options) */
00156   public void Open(Variant Source, Variant ActiveConnection, int CursorType, int LockType, int Options);
00157
00158   /** @com.method(vtoffset=38, dispid=1023, type=METHOD, name="Requery", addFlagsVtable=4)
00159       @com.parameters([in,type=I4] Options) */
00160   public void Requery(int Options);
00161
00162   /** @com.method(vtoffset=39, dispid=1610809378, type=METHOD, name="_xResync", addFlagsVtable=4)
00163       @com.parameters([in,type=I4] AffectRecords)
00164       @hidden */
00165   public void _xResync(int AffectRecords);
00166
00167   /** @com.method(vtoffset=40, dispid=1025, type=METHOD, name="Update", addFlagsVtable=4)
00168       @com.parameters([in,type=VARIANT] Fields, [in,type=VARIANT] Values) */
00169   public void Update(Variant Fields, Variant Values);
00170
00171   /** @com.method(vtoffset=41, dispid=1047, type=PROPGET, name="AbsolutePage", name2="getAbsolutePage", addFlagsVtable=4)
00172       @com.parameters([type=I4] return) */
00173   public int getAbsolutePage();
00174
00175   /** @com.method(vtoffset=42, dispid=1047, type=PROPPUT, name="AbsolutePage", name2="putAbsolutePage", addFlagsVtable=4)
00176       @com.parameters([in,type=I4] pl) */
00177   public void setAbsolutePage(int pl);
00178
00179   /** @com.method(vtoffset=43, dispid=1026, type=PROPGET, name="EditMode", name2="getEditMode", addFlagsVtable=4)
00180       @com.parameters([type=I4] return) */
00181   public int getEditMode();
00182
00183   /** @com.method(vtoffset=44, dispid=1030, type=PROPGET, name="Filter", name2="getFilter", addFlagsVtable=4)
00184       @com.parameters([type=VARIANT] return) */
00185   public Variant getFilter();
00186
00187   /** @com.method(vtoffset=45, dispid=1030, type=PROPPUT, name="Filter", name2="putFilter", addFlagsVtable=4)
00188       @com.parameters([in,type=VARIANT] Criteria) */
00189   public void setFilter(Variant Criteria);
00190
00191   /** @com.method(vtoffset=46, dispid=1050, type=PROPGET, name="PageCount", name2="getPageCount", addFlagsVtable=4)
00192       @com.parameters([type=I4] return) */
00193   public int getPageCount();
00194
00195   /** @com.method(vtoffset=47, dispid=1048, type=PROPGET, name="PageSize", name2="getPageSize", addFlagsVtable=4)
00196       @com.parameters([type=I4] return) */
00197   public int getPageSize();
00198
00199   /** @com.method(vtoffset=48, dispid=1048, type=PROPPUT, name="PageSize", name2="putPageSize", addFlagsVtable=4)
00200       @com.parameters([in,type=I4] pl) */
00201   public void setPageSize(int pl);
00202
00203   /** @com.method(vtoffset=49, dispid=1031, type=PROPGET, name="Sort", name2="getSort", addFlagsVtable=4)
00204       @com.parameters([type=STRING] return) */
00205   public String getSort();
00206
00207   /** @com.method(vtoffset=50, dispid=1031, type=PROPPUT, name="Sort", name2="putSort", addFlagsVtable=4)
00208       @com.parameters([in,type=STRING] Criteria) */
00209   public void setSort(String Criteria);
00210
00211   /** @com.method(vtoffset=51, dispid=1029, type=PROPGET, name="Status", name2="getStatus", addFlagsVtable=4)
00212       @com.parameters([type=I4] return) */
00213   public int getStatus();
00214
00215   /** @com.method(vtoffset=52, dispid=1054, type=PROPGET, name="State", name2="getState", addFlagsVtable=4)
00216       @com.parameters([type=I4] return) */
00217   public int getState();
00218
00219   /** @com.method(vtoffset=53, dispid=1610809392, type=METHOD, name="_xClone", addFlagsVtable=4)
00220       @com.parameters([iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return)
00221       @hidden */
00222   public msado15._Recordset _xClone();
00223
00224   /** @com.method(vtoffset=54, dispid=1035, type=METHOD, name="UpdateBatch", addFlagsVtable=4)
00225       @com.parameters([in,type=I4] AffectRecords) */
00226   public void UpdateBatch(int AffectRecords);
00227
00228   /** @com.method(vtoffset=55, dispid=1049, type=METHOD, name="CancelBatch", addFlagsVtable=4)
00229       @com.parameters([in,type=I4] AffectRecords) */
00230   public void CancelBatch(int AffectRecords);
00231
00232   /** @com.method(vtoffset=56, dispid=1051, type=PROPGET, name="CursorLocation", name2="getCursorLocation", addFlagsVtable=4)
00233       @com.parameters([type=I4] return) */
00234   public int getCursorLocation();
00235
00236   /** @com.method(vtoffset=57, dispid=1051, type=PROPPUT, name="CursorLocation", name2="putCursorLocation", addFlagsVtable=4)
00237       @com.parameters([in,type=I4] plCursorLoc) */
00238   public void setCursorLocation(int plCursorLoc);
00239
00240   /** @com.method(vtoffset=58, dispid=1052, type=METHOD, name="NextRecordset", addFlagsVtable=4)
00241       @com.parameters([out,elementType=VARIANT,type=PTR] RecordsAffected, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00242   public msado15._Recordset NextRecordset(Variant RecordsAffected);
00243
00244   /** @com.method(vtoffset=59, dispid=1036, type=METHOD, name="Supports", addFlagsVtable=4)
00245       @com.parameters([in,type=I4] CursorOptions, [type=BOOLEAN] return) */
00246   public boolean Supports(int CursorOptions);
00247
00248   /** @com.method(vtoffset=60, dispid=4294967288, type=PROPGET, name="Collect", name2="getCollect", addFlagsVtable=4)
00249       @com.parameters([in,type=VARIANT] Index, [type=VARIANT] return)
00250       @hidden */
00251   public Variant getCollect(Variant Index);
00252
00253   /** @com.method(vtoffset=61, dispid=4294967288, type=PROPPUT, name="Collect", name2="putCollect", addFlagsVtable=4)
00254       @com.parameters([in,type=VARIANT] Index, [in,type=VARIANT] pvar)
00255       @hidden */
00256   public void setCollect(Variant Index, Variant pvar);
00257
00258   /** @com.method(vtoffset=62, dispid=1053, type=PROPGET, name="MarshalOptions", name2="getMarshalOptions", addFlagsVtable=4)
00259       @com.parameters([type=I4] return) */
00260   public int getMarshalOptions();
00261
00262   /** @com.method(vtoffset=63, dispid=1053, type=PROPPUT, name="MarshalOptions", name2="putMarshalOptions", addFlagsVtable=4)
00263       @com.parameters([in,type=I4] peMarshal) */
00264   public void setMarshalOptions(int peMarshal);
00265
00266   /** @com.method(vtoffset=64, dispid=1058, type=METHOD, name="Find", addFlagsVtable=4)
00267       @com.parameters([in,type=STRING] Criteria, [in,type=I4] SkipRecords, [in,type=I4] SearchDirection, [in,type=VARIANT] Start) */
00268   public void Find(String Criteria, int SkipRecords, int SearchDirection, Variant Start);
00269
00270   /** @com.method(vtoffset=65, dispid=1055, type=METHOD, name="Cancel", addFlagsVtable=4)
00271       @com.parameters() */
00272   public void Cancel();
00273
00274   /** @com.method(vtoffset=66, dispid=1056, type=PROPGET, name="DataSource", name2="getDataSource", addFlagsVtable=4)
00275       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00276   public IUnknown getDataSource();
00277
00278   /** @com.method(vtoffset=67, dispid=1056, type=PROPPUTREF, name="DataSource", name2="putDataSource", addFlagsVtable=4)
00279       @com.parameters([in,iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] ppunkDataSource) */
00280   public void setDataSource(IUnknown ppunkDataSource);
00281
00282   /** @com.method(vtoffset=68, dispid=1610874883, type=METHOD, name="_xSave", addFlagsVtable=4)
00283       @com.parameters([in,type=STRING] FileName, [in,type=I4] PersistFormat)
00284       @hidden */
00285   public void _xSave(String FileName, int PersistFormat);
00286
00287   /** @com.method(vtoffset=69, dispid=1061, type=PROPGET, name="ActiveCommand", name2="getActiveCommand", addFlagsVtable=4)
00288       @com.parameters([iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] return) */
00289   public Object getActiveCommand();
00290
00291   /** @com.method(vtoffset=70, dispid=1063, type=PROPPUT, name="StayInSync", name2="putStayInSync", addFlagsVtable=4)
00292       @com.parameters([in,type=BOOLEAN] pbStayInSync) */
00293   public void setStayInSync(boolean pbStayInSync);
00294
00295   /** @com.method(vtoffset=71, dispid=1063, type=PROPGET, name="StayInSync", name2="getStayInSync", addFlagsVtable=4)
00296       @com.parameters([type=BOOLEAN] return) */
00297   public boolean getStayInSync();
00298
00299   /** @com.method(vtoffset=72, dispid=1062, type=METHOD, name="GetString", addFlagsVtable=4)
00300       @com.parameters([in,type=I4] StringFormat, [in,type=I4] NumRows, [in,type=STRING] ColumnDelimeter, [in,type=STRING] RowDelimeter, [in,type=STRING] NullExpr, [type=STRING] return) */
00301   public String GetString(int StringFormat, int NumRows, String ColumnDelimeter, String RowDelimeter, String NullExpr);
00302
00303   /** @com.method(vtoffset=73, dispid=1064, type=PROPGET, name="DataMember", name2="getDataMember", addFlagsVtable=4)
00304       @com.parameters([type=STRING] return) */
00305   public String getDataMember();
00306
00307   /** @com.method(vtoffset=74, dispid=1064, type=PROPPUT, name="DataMember", name2="putDataMember", addFlagsVtable=4)
00308       @com.parameters([in,type=STRING] pbstrDataMember) */
00309   public void setDataMember(String pbstrDataMember);
00310
00311   /** @com.method(vtoffset=75, dispid=1065, type=METHOD, name="CompareBookmarks", addFlagsVtable=4)
00312       @com.parameters([in,type=VARIANT] Bookmark1, [in,type=VARIANT] Bookmark2, [type=I4] return) */
00313   public int CompareBookmarks(Variant Bookmark1, Variant Bookmark2);
00314
00315   /** @com.method(vtoffset=76, dispid=1034, type=METHOD, name="Clone", addFlagsVtable=4)
00316       @com.parameters([in,type=I4] LockType, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00317   public msado15._Recordset Clone(int LockType);
00318
00319   /** @com.method(vtoffset=77, dispid=1024, type=METHOD, name="Resync", addFlagsVtable=4)
00320       @com.parameters([in,type=I4] AffectRecords, [in,type=I4] ResyncValues) */
00321   public void Resync(int AffectRecords, int ResyncValues);
00322
00323   /** @com.method(vtoffset=78, dispid=1066, type=METHOD, name="Seek", addFlagsVtable=4)
00324       @com.parameters([in,type=VARIANT] KeyValues, [in,type=I4] SeekOption) */
00325   public void Seek(Variant KeyValues, int SeekOption);
00326
00327   /** @com.method(vtoffset=79, dispid=1067, type=PROPPUT, name="Index", name2="putIndex", addFlagsVtable=4)
00328       @com.parameters([in,type=STRING] pbstrIndex) */
00329   public void setIndex(String pbstrIndex);
00330
00331   /** @com.method(vtoffset=80, dispid=1067, type=PROPGET, name="Index", name2="getIndex", addFlagsVtable=4)
00332       @com.parameters([type=STRING] return) */
00333   public String getIndex();
00334
00335   /** @com.method(vtoffset=81, dispid=1057, type=METHOD, name="Save", addFlagsVtable=4)
00336       @com.parameters([in,type=VARIANT] Destination, [in,type=I4] PersistFormat) */
00337   public void Save(Variant Destination, int PersistFormat);
00338
00339
00340   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x556, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00341 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/AutoClaims/C#/AssemblyInfo.cs Source File

  • TabletPC
  • AutoClaims
  • C#

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("Auto Claims Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2003 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 //[assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 //[assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/land.Cpp Source File

  • SysMgmt
  • MMC
  • Extens

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

compitem Member List

This is the complete list of members for compitem, including all inherited members.
bDiscard | compitem
bMarked | compitem
delims | compitem
left | compitem
result | compitem
right | compitem
secs_composite | compitem
secs_left | compitem
secs_right | compitem
state | compitem
tag | compitem
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COMPlus Member List

This is the complete list of members for COMPlus, including all inherited members.
Activate() | COMPlus | [inline]
CanBePooled() | COMPlus | [inline]
Deactivate() | COMPlus | [inline]
Method1() | COMPlus | [inline]
Method1() | COMPlus | [inline]
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProvFactory Member List

This is the complete list of members for CProvFactory, including all inherited members.
CProvFactory(void) | CProvFactory |
CProvFactory(void) | CProvFactory |
CProvFactory(void) | CProvFactory |
CProvFactory(void) | CProvFactory |
CreateInstance(LPUNKNOWN, REFIID, PPVOID) | CProvFactory |
CreateInstance(LPUNKNOWN, REFIID, PPVOID) | CProvFactory |
CreateInstance(LPUNKNOWN, REFIID, PPVOID) | CProvFactory |
CreateInstance(LPUNKNOWN, REFIID, PPVOID) | CProvFactory |
LockServer(BOOL) | CProvFactory |
LockServer(BOOL) | CProvFactory |
LockServer(BOOL) | CProvFactory |
LockServer(BOOL) | CProvFactory |
m_cRef | CProvFactory | [protected]
QueryInterface(REFIID, PPVOID) | CProvFactory |
QueryInterface(REFIID, PPVOID) | CProvFactory |
QueryInterface(REFIID, PPVOID) | CProvFactory |
QueryInterface(REFIID, PPVOID) | CProvFactory |
STDMETHODIMP_(ULONG) AddRef(void) | CProvFactory |
STDMETHODIMP_(ULONG) Release(void) | CProvFactory |
STDMETHODIMP_(ULONG) AddRef(void) | CProvFactory |
STDMETHODIMP_(ULONG) Release(void) | CProvFactory |
STDMETHODIMP_(ULONG) AddRef(void) | CProvFactory |
STDMETHODIMP_(ULONG) Release(void) | CProvFactory |
STDMETHODIMP_(ULONG) AddRef(void) | CProvFactory |
STDMETHODIMP_(ULONG) Release(void) | CProvFactory |
~CProvFactory(void) | CProvFactory |
~CProvFactory(void) | CProvFactory |
~CProvFactory(void) | CProvFactory |
~CProvFactory(void) | CProvFactory |
Generated on Wed Nov 13 2024 16:57:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/ToolBar.h Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

ToolBar.h

Go to the documentation of this file.
00001
00002 // Global variable for Toolbar window
00003 extern HWND hWndToolbar;
00004
00005 // Function protoptype for Creating Toolbar
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/ProcessDlg.h Source File

  • WinBase
  • WtsApi
  • WtsApi

ProcessDlg.h

Go to the documentation of this file.
00001 //  Copyright 1995-1999, Citrix Systems Inc.
00002 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00003 #if !defined(AFX_PROCESSDLG_H__1A55D422_30F9_11D1_8310_00C04FBEFCDA__INCLUDED_)
00004 #define AFX_PROCESSDLG_H__1A55D422_30F9_11D1_8310_00C04FBEFCDA__INCLUDED_
00005
00006 #if _MSC_VER >= 1000
00007 #pragma once
00008 #endif // _MSC_VER >= 1000
00009
00010 #include <wtsapi32.h>
00011
00012 // ProcessDlg.h : header file
00013 //
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CProcessDlg dialog
00017
00018 class CProcessDlg : public CDialog
00019 {
00020 // Construction
00021 public:
00022   PWTS_PROCESS_INFO pProcessInfo;
00023   CProcessDlg(CWnd* pParent = NULL);   // standard constructor
00024
00025 // Dialog Data
00026   //{{AFX_DATA(CProcessDlg)
00027   enum { IDD = IDD_PROCESS };
00028   CEdit m_serverName;
00029   CListBox  m_processList;
00030   //}}AFX_DATA
00031
00032
00033 // Overrides
00034   // ClassWizard generated virtual function overrides
00035   //{{AFX_VIRTUAL(CProcessDlg)
00036   protected:
00037   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00038   //}}AFX_VIRTUAL
00039
00040 // Implementation
00041 protected:
00042
00043   // Generated message map functions
00044   //{{AFX_MSG(CProcessDlg)
00045   afx_msg void OnTerminateProcess();
00046   afx_msg void Refresh();
00047   virtual BOOL OnInitDialog();
00048   virtual void OnCancel();
00049   afx_msg void OnRefresh();
00050   //}}AFX_MSG
00051   DECLARE_MESSAGE_MAP()
00052 private:
00053   DWORD count;
00054   HANDLE serverHandle;
00055   LPSTR serverName;
00056 };
00057
00058 //{{AFX_INSERT_LOCATION}}
00059 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00060
00061 #endif // !defined(AFX_PROCESSDLG_H__1A55D422_30F9_11D1_8310_00C04FBEFCDA__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/StdAfx.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  File Share SampleEx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 const WCHAR g_wszResourceTypeNames[] =
00008         L"File Share Sample\0"
00009         ;
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsimple/prof.h Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsimple

prof.h

Go to the documentation of this file.
00001 #pragma once
00002 /*
00003     Copyright Microsoft Corp. 1992 - 2001
00004
00005     Server Profiling Routines
00006
00007     FILE: Prof.h
00008
00009     PURPOSE: Routines for profiling server system services.
00010
00011     FUNCTIONS:
00012         ProfOpenLog - Opens the profile log file and prepares to
00013     take timings.
00014   ProfRecordTime - Records the time of an event.
00015   ProfCloseLog - Writes the profiling data to the file
00016     and closes it.
00017
00018     COMMENTS: These routines depend on the existence of a high-resolution
00019         performance counter.
00020 */
00021
00022 // Maximum size for the profile log.
00023 // After the log reaches this size new entries "fall off" (threy
00024 // do not get reorded).
00025 #define PROF_LOG_MAX_SIZE (10*1024*1024)
00026
00027 // This mutex is used for mutial exclusion when generating and
00028 // writing the profiling information.  It is also accessible to
00029 // the server routines that may want to use it for syncronising
00030 // their internal operation and creation of profiling info.
00031 // The mutex can only be used between the calls to ProfOpenLog and
00032 // ProfCloseLog.
00033 extern HANDLE hProfMutex;
00034
00035 /*
00036     FUNCTION: ProfOpenLog
00037
00038     PURPOSE: Opens the profile log file and prepares to
00039     take timings.  Also inits the mutex.
00040
00041     PARAMETERS:
00042         LogFileName - Name of the profile log file.
00043
00044     RETURN VALUE:
00045         none
00046
00047     COMMENTS:
00048
00049 */
00050 VOID ProfOpenLog(LPTSTR LogFileName);
00051
00052 /*
00053     FUNCTION: ProfRecordTime
00054
00055     PURPOSE: Creates an entry for the even with identifier id, and
00056         with message msg with a timestamp corresponding to the number of
00057   secods since the start of the program.
00058
00059     PARAMETERS:
00060         id - Id of the event.
00061   msg - Message for the event.
00062
00063     RETURN VALUE:
00064         none
00065
00066     COMMENTS:  If the maximum log size has been exceeded, no action is taken.
00067
00068 */
00069 VOID ProfRecordTime(UINT id, LPTSTR msg);
00070
00071 /*
00072     FUNCTION: ProfCloseLog
00073
00074     PURPOSE: Writes out the acumulated profile data and closes the log file.
00075         Closes the mutex.
00076
00077     PARAMETERS:
00078         none
00079
00080     RETURN VALUE:
00081         none
00082
00083     COMMENTS:
00084
00085 */
00086 VOID ProfCloseLog(VOID);
00087
00088 // end Prof.h
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/SockAuth/Comm.cpp Source File

  • Security
  • SSPI
  • SockAuth

Comm.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 Module Name:
00006
00007     comm.cpp
00008
00009 Abstract:
00010
00011     Implements a set of common operations for socket communication
00012
00013 Revision History:
00014
00015 --*/
00016
00017 #include <windows.h>
00018 #include <winsock.h>
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include "comm.h"
00022
00023 BOOL InitWinsock ()
00024 {
00025   int nRes;
00026   WSADATA wsaData;
00027   WORD wVerRequested = 0x0101; // ver 1.1
00028
00029   // Init the sockets interface
00030   nRes = WSAStartup (wVerRequested, &wsaData);
00031   if (nRes)  {
00032     fprintf (stderr, "Couldn't init winsock: %d\n", nRes);
00033     return(FALSE);
00034   }
00035
00036   return(TRUE);
00037 }
00038
00039 BOOL TermWinsock ()
00040 {
00041   if (SOCKET_ERROR == WSACleanup ())
00042     return(FALSE);
00043   else
00044     return(TRUE);
00045 }
00046
00047 BOOL SendMsg (SOCKET s, PBYTE pBuf, DWORD cbBuf)
00048 /*++
00049
00050  Routine Description:
00051
00052     Sends a message over the socket by first sending a DWORD that
00053   represents the size of the message followed by the message itself.
00054
00055  Return Value:
00056
00057     Returns TRUE is successful; otherwise FALSE is returned.
00058
00059 --*/
00060 {
00061   if (0 == cbBuf)
00062     return(TRUE);
00063
00064   // send the size of the message
00065   //
00066   if (!SendBytes (s, (PBYTE)&cbBuf, sizeof (cbBuf)))
00067     return(FALSE);
00068
00069   // send the body of the message
00070   //
00071   if (!SendBytes (s, pBuf, cbBuf))
00072     return(FALSE);
00073
00074   return(TRUE);
00075 }
00076
00077 BOOL ReceiveMsg (SOCKET s, PBYTE pBuf, DWORD cbBuf, DWORD *pcbRead)
00078 /*++
00079
00080  Routine Description:
00081
00082     Receives a message over the socket.  The first DWORD in the message
00083   will be the message size.  The remainder of the bytes will be the
00084   actual message.
00085
00086  Return Value:
00087
00088     Returns TRUE is successful; otherwise FALSE is returned.
00089
00090 --*/
00091 {
00092   DWORD cbRead;
00093   DWORD cbData;
00094
00095   // find out how much data is in the message
00096   //
00097   if (!ReceiveBytes (s, (PBYTE)&cbData, sizeof (cbData), &cbRead))
00098     return(FALSE);
00099
00100   if (sizeof (cbData) != cbRead)
00101     return(FALSE);
00102
00103   // Read the full message
00104   //
00105   if (!ReceiveBytes (s, pBuf, cbData, &cbRead))
00106     return(FALSE);
00107
00108   if (cbRead != cbData)
00109     return(FALSE);
00110
00111   *pcbRead = cbRead;
00112
00113   return(TRUE);
00114 }
00115
00116 BOOL SendBytes (SOCKET s, PBYTE pBuf, DWORD cbBuf)
00117 {
00118   PBYTE pTemp = pBuf;
00119   int cbSent, cbRemaining = cbBuf;
00120
00121   if (0 == cbBuf)
00122     return(TRUE);
00123
00124   while (cbRemaining) {
00125     cbSent = send (s, (const char *)pTemp, cbRemaining, 0);
00126     if (SOCKET_ERROR == cbSent) {
00127       fprintf (stderr, "send failed: %u\n", GetLastError ());
00128       return FALSE;
00129     }
00130
00131     pTemp += cbSent;
00132     cbRemaining -= cbSent;
00133   }
00134
00135   return TRUE;
00136 }
00137
00138 BOOL ReceiveBytes (SOCKET s, PBYTE pBuf, DWORD cbBuf, DWORD *pcbRead)
00139 {
00140   PBYTE pTemp = pBuf;
00141   int cbRead, cbRemaining = cbBuf;
00142
00143   while (cbRemaining) {
00144     cbRead = recv (s, (char *)pTemp, cbRemaining, 0);
00145     if (0 == cbRead)
00146       break;
00147
00148     if (SOCKET_ERROR == cbRead) {
00149       fprintf (stderr, "recv failed: %u\n", GetLastError ());
00150       return FALSE;
00151     }
00152
00153     cbRemaining -= cbRead;
00154     pTemp += cbRead;
00155   }
00156
00157   *pcbRead = cbBuf - cbRemaining;
00158
00159   return TRUE;
00160 }
00161
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBackgroundCopyCallback Member List

This is the complete list of members for CBackgroundCopyCallback, including all inherited members.
AddRef(void) | CBackgroundCopyCallback | [inline, virtual]
CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject) | CBackgroundCopyCallback | [inline, virtual]
JobError(IBackgroundCopyJob *pJob, IBackgroundCopyError *pError) | CBackgroundCopyCallback | [inline, virtual]
JobModification(IBackgroundCopyJob *pJob, DWORD dwReserved) | CBackgroundCopyCallback | [inline, virtual]
JobTransferred(IBackgroundCopyJob *pJob) | CBackgroundCopyCallback | [inline, virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBackgroundCopyCallback | [inline, virtual]
Release(void) | CBackgroundCopyCallback | [inline, virtual]
Generated on Wed Nov 13 2024 16:55:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/tapirecv/workerthread.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • tapirecv

workerthread.h

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1999 - 2000  Microsoft Corporation
00004
00005
00006 Module Name:
00007
00008     WorkerThread.h
00009
00010 Abstract:
00011
00012     interface for the CWorkerThread class.
00013
00014 */
00015
00016
00017 #if !defined(AFX_WORKERTHREAD_H__45467AAB_C5AB_43D6_B518_B81B971A859C__INCLUDED_)
00018 #define AFX_WORKERTHREAD_H__45467AAB_C5AB_43D6_B518_B81B971A859C__INCLUDED_
00019
00020
00021 //
00022 // worker whose purpose is to asynchronously process messages received
00023 // from TAPI
00024 //
00025
00026 class CWorkerThread
00027 {
00028
00029 public:
00030
00031     //
00032     // post an message to be processed asyncronously
00033     //
00034
00035     BOOL PostMessage(UINT Msg,       // message to post
00036                      WPARAM wParam,  // first message parameter
00037                      LPARAM lParam   // second message parameter
00038                      );
00039
00040 public:
00041
00042     //
00043     // create thread
00044     //
00045
00046     HRESULT Initialize();
00047
00048     //
00049     // shutdown thread
00050     //
00051
00052     HRESULT Shutdown();
00053
00054
00055
00056     CWorkerThread()
00057         :m_hThreadHandle(NULL),
00058         m_nThreadID(0)
00059     {}
00060
00061
00062     virtual ~CWorkerThread();
00063
00064 protected:
00065
00066     //
00067     // the actual thread function
00068     //
00069
00070     static unsigned long _stdcall ThreadFunction(void *);
00071
00072
00073 private:
00074
00075     //
00076     // thread handle and thread id
00077     //
00078
00079     HANDLE m_hThreadHandle;
00080
00081     unsigned long m_nThreadID;
00082
00083 };
00084
00085 #endif // !defined(AFX_WORKERTHREAD_H__45467AAB_C5AB_43D6_B518_B81B971A859C__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/CreateCert/CreateCert.c Source File

  • Security
  • CryptoApi
  • CreateCert

CreateCert.c

Go to the documentation of this file.
00001 //===================================================================
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00003 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00004 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00005 // PURPOSE.
00006 //
00007 // Copyright 1998 - 2000. Microsoft Corporation. All Right Reserved.
00008 // File: CreateCert.c
00009 //
00010 // This sample demonstrates how to create Certificates using CryptoAPI.
00011 // The sample lets the user create Self-Signed Certificates or
00012 // create Certificates signed by another Certificate.
00013 //
00014 // When a Self-Signed Certificate is created a file called
00015 // SelfSigned.cer is created.  The file can be ran to trust
00016 // the certificate as a Certificate Authority.
00017 //
00018 // When a non Self-Signed Certificate is created a file called
00019 // Certificate.cer is created.  This can be used on Windows 2000
00020 // to install the certificate under the "AddressBook" store for
00021 // example.  Only the public key information is stored in the
00022 // certificate.
00023 //
00024 //===================================================================
00025 #include <windows.h>
00026 #include <wincrypt.h>
00027 #include <rpc.h>
00028 #include <stdio.h>
00029 #include "CreateCert.h"
00030
00031 #define KEY_USAGE_SIZE 5
00032
00033 #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
00034
00035 // This structure will be used to calculate
00036 // the Enhanced Key Usage Extension from an
00037 // integer
00038 typedef struct tagEnhKeyUsage
00039 {
00040    DWORD dwCount;
00041    LPSTR szUsage[KEY_USAGE_SIZE];
00042    DWORD dwValue[KEY_USAGE_SIZE];
00043 } ENHKEYUSAGE;
00044
00045 // Every Enhanced Usage Extension has a
00046 // corresponding number to it.  Just add
00047 // the number to set the appropriate
00048 // extension:
00049 // Server Authentication   1
00050 // Client Authentication   2
00051 // Code Signing            4
00052 // Email Protection        8
00053 // Time Stamping           16
00054 ENHKEYUSAGE g_EnhKeyUsage =
00055 {
00056    KEY_USAGE_SIZE,
00057    {
00058       szOID_PKIX_KP_SERVER_AUTH,
00059       szOID_PKIX_KP_CLIENT_AUTH,
00060       szOID_PKIX_KP_CODE_SIGNING,
00061       szOID_PKIX_KP_EMAIL_PROTECTION,
00062       szOID_PKIX_KP_TIMESTAMP_SIGNING
00063    },
00064    { 1, 2, 4, 8, 16}
00065 };
00066
00067 LPSTR g_szSigAlg[] = {
00068    szOID_RSA_MD5RSA,
00069    szOID_RSA_SHA1RSA
00070 };
00071
00072 // Default store and empty string
00073 LPSTR g_szMyStore = "MY";
00074 LPSTR g_szEmpty = "";
00075
00076 int main(int argc, char *argv[])
00077 {
00078    BOOL bResult;
00079    DWORD dwUsage = 0;
00080    DWORD dwKeyType = AT_KEYEXCHANGE;
00081    DWORD dwProvNum = 0;
00082    LPSTR szSigAlg = g_szSigAlg[1];
00083    BOOL bExport = FALSE;
00084    BOOL bSelfSigned = TRUE;
00085    BOOL bIssuerUser = TRUE;
00086    BOOL bSubjectUser = TRUE;
00087    BOOL bUseProv = FALSE;
00088    LPSTR szX509 = NULL;
00089    LPSTR szSubjectStore = g_szMyStore;
00090    LPSTR szIssuerStore = g_szMyStore;
00091    LPSTR szIssuerName = g_szEmpty;
00092    LPSTR szCertFile = g_szEmpty;
00093    LPSTR szKeyFile = g_szEmpty;
00094    LPSTR szPassword = g_szEmpty;
00095    WORD wMonths = 0;
00096    BOOL bCA = FALSE;
00097    int n;
00098
00099    // Print Usage
00100    if (argc < 2)
00101    {
00102      PrintUsage();
00103      return 0;
00104    }
00105
00106
00107    // User wants to import a certificate
00108    if (strcmpi(argv[1], "-i") == 0)
00109    {
00110       BOOL bUser;
00111       DWORD num;
00112
00113       if (argc != 8)
00114       {
00115          PrintUsage();
00116          return 0;
00117       }
00118
00119       if (strcmpi(argv[6], "m") == 0)
00120          bUser = FALSE;
00121       else
00122          bUser = TRUE;
00123
00124       num = (DWORD)atoi(argv[7]);
00125
00126       bResult = ImportCertificate(argv[2],
00127                                 argv[3],
00128                                 argv[4],
00129                                 argv[5],
00130                                 bUser,
00131                                 num);
00132       if (!bResult)
00133       {
00134          printf("Unable to Import Certificate\n");
00135          return 0;
00136       }
00137       else
00138       {
00139          printf("Certificate Imported successfully\n");
00140          return 1;
00141       }
00142    }
00143
00144    // Set X509 Name
00145    szX509 = argv[1];
00146
00147    // Parse rest of the options
00148    n = 2;
00149    while (n < argc)
00150    {
00151     // User selected Key Type
00152     if (strcmpi(argv[n], "-k") == 0)
00153     {
00154       if ((n+1) < argc)
00155       {
00156          if (strcmpi(argv[++n], "s") == 0)
00157            dwKeyType = AT_SIGNATURE;
00158          else
00159            dwKeyType = AT_KEYEXCHANGE;
00160       }
00161       else
00162       {
00163          PrintUsage();
00164          return 0;
00165       }
00166     }
00167
00168     // User set number of months
00169     if (strcmpi(argv[n], "-m") == 0)
00170     {
00171        if ((n+1) < argc)
00172        {
00173           wMonths = (WORD)atoi(argv[++n]);
00174        }
00175        else
00176        {
00177           PrintUsage();
00178           return 0;
00179        }
00180     }
00181
00182     // User wants this to be a CA.  Indicated in
00183     // Basic contraints
00184     if (strcmpi(argv[n], "-ca") == 0)
00185     {
00186        bCA = TRUE;
00187     }
00188
00189     // User wants to set Enhanced Key usage extension
00190     if (strcmpi(argv[n], "-u") == 0)
00191     {
00192       if ((n+1) < argc)
00193       {
00194          dwUsage = (DWORD)atoi(argv[++n]);
00195       }
00196       else
00197       {
00198          PrintUsage();
00199          return 0;
00200       }
00201     }
00202
00203     // User wants to set the Crypto Provider
00204     if (strcmpi(argv[n], "-p") == 0)
00205     {
00206        if ((n+1) < argc)
00207        {
00208           bUseProv = TRUE;
00209           dwProvNum = (DWORD)atoi(argv[++n]);
00210        }
00211        else
00212        {
00213           PrintUsage();
00214           return 0;
00215        }
00216     }
00217
00218     // User selected signature algorithm
00219     if (strcmpi(argv[n], "-s") == 0)
00220     {
00221        if ((n+1) < argc)
00222        {
00223           if (strcmpi(argv[++n], "md5") == 0)
00224              szSigAlg = g_szSigAlg[0];
00225           else
00226              szSigAlg = g_szSigAlg[1];
00227        }
00228        else
00229        {
00230           PrintUsage();
00231           return 0;
00232        }
00233     }
00234
00235     // User selected the Subject Location
00236     if (strcmpi(argv[n], "-sl") == 0)
00237     {
00238        if ((n+2) < argc)
00239        {
00240           bExport = FALSE;
00241           szSubjectStore = argv[++n];
00242           if (strcmpi(argv[++n], "m") == 0)
00243              bSubjectUser = FALSE;
00244           else
00245              bSubjectUser = TRUE;
00246        }
00247        else
00248        {
00249           PrintUsage();
00250           return 0;
00251        }
00252     }
00253
00254     // User wants to export the Certificate
00255     if (strcmpi(argv[n], "-ex") == 0)
00256     {
00257        if ((n+3) < argc)
00258        {
00259           bExport = TRUE;
00260           szCertFile = argv[++n];
00261           szKeyFile = argv[++n];
00262           szPassword = argv[++n];
00263        }
00264        else
00265        {
00266           PrintUsage();
00267           return 0;
00268        }
00269     }
00270
00271     // User has selected an issuer
00272     if (strcmpi(argv[n], "-is") == 0)
00273     {
00274        if ((n+3) < argc)
00275        {
00276           bSelfSigned = FALSE;
00277           szIssuerName = argv[++n];
00278           szIssuerStore = argv[++n];
00279           if (strcmpi(argv[++n], "m") == 0)
00280              bIssuerUser = FALSE;
00281           else
00282              bIssuerUser = TRUE;
00283        }
00284        else
00285        {
00286           PrintUsage();
00287           return 0;
00288        }
00289     }
00290
00291     n++;
00292    }
00293
00294    // Create Certificate
00295    bResult = CreateCertificate(
00296                      szX509,        // Certificate Name
00297                      dwKeyType,     // Key Type
00298                      szSigAlg,      // Signature Algorithm
00299                      wMonths,       // Number of Months
00300                      dwUsage,       // Enhanced Key Usage
00301                      bCA,           // CA or not
00302                      bUseProv,      // Use dwProvNum
00303                      dwProvNum,     // Provider Number
00304                      szSubjectStore,// Certificate Store
00305                      bSubjectUser,  // User or Machine flag
00306                      bSelfSigned,   // Self Signed flag
00307                      szIssuerName,  // Issuer of Certificate
00308                      szIssuerStore, // Store of Issuer
00309                      bIssuerUser,   // User or Machine flag
00310                      bExport,       // Export flag
00311                      szCertFile,    // Certificate File
00312                      szKeyFile,     // Key File
00313                      szPassword);   // Password for Key File
00314    if (!bResult)
00315    {
00316      printf("Unable to create certificate\n");
00317    }
00318
00319    return 1;
00320 }
00321
00322 //
00323 // ImportCertificate installs the crpto provider and certificate
00324 // on the machine.
00325 //
00326 BOOL ImportCertificate(LPSTR szCertFile, LPSTR szKeyFile, LPSTR szPassword,
00327                   LPSTR szStore, BOOL bUser, DWORD dwProviderNum)
00328 {
00329    LPSTR szContainer = NULL;
00330    HCRYPTPROV hProv = 0;
00331    HCRYPTHASH hHash = 0;
00332    HCERTSTORE hStore = NULL;
00333    HCRYPTKEY hKey = 0;
00334    HCRYPTKEY hPubKey = 0;
00335    HANDLE hFile = INVALID_HANDLE_VALUE;
00336    LPBYTE pbEncodedCert = NULL;
00337    LPBYTE pbEncodedKey = NULL;
00338    PCCERT_CONTEXT pCertContext = NULL;
00339    CRYPT_KEY_PROV_INFO CertKeyInfo;
00340    BOOL fReturn = FALSE;
00341    RPC_STATUS Status;
00342    HANDLE hHeap;
00343    UUID Uuid;
00344    BOOL bResult;
00345    DWORD dwSize, dwRead;
00346    WCHAR szwStore[20];
00347    DWORD dwAcquireFlags = 0;
00348    DWORD dwCertOpenFlags = CERT_SYSTEM_STORE_CURRENT_USER;
00349    CHAR szProvider[260] = { MS_DEF_PROV };
00350    DWORD dwProviderType = PROV_RSA_FULL;
00351    int i;
00352
00353    __try
00354    {
00355      if (!bUser)
00356      {
00357         dwAcquireFlags = CRYPT_MACHINE_KEYSET;
00358         dwCertOpenFlags = CERT_SYSTEM_STORE_LOCAL_MACHINE;
00359      }
00360
00361      dwSize = 260;
00362      bResult = MyCryptEnumProviders(dwProviderNum,
00363                                     NULL,
00364                                     0,
00365                                     &dwProviderType,
00366                                     szProvider,
00367                                     &dwSize);
00368      if (!bResult)
00369      {
00370         printf("Unable to get provider\n");
00371         __leave;
00372      }
00373
00374      // Get process heap
00375      hHeap = GetProcessHeap();
00376
00377      // Open Key File
00378      hFile = CreateFile(szKeyFile,
00379                       GENERIC_READ,
00380                       0,
00381                       NULL,
00382                       OPEN_EXISTING,
00383                       FILE_ATTRIBUTE_NORMAL,
00384                       NULL);
00385      if (hFile == INVALID_HANDLE_VALUE)
00386      {
00387          printf("Unable to open key file\n");
00388          __leave;
00389      }
00390
00391      // Get file length
00392      dwSize = GetFileSize(hFile, NULL);
00393      if (dwSize == 0xFFFFFFFF)
00394      {
00395        printf("Unable to get size of certificate file\n");
00396        __leave;
00397      }
00398
00399      // Allocate memory for encoded key
00400      pbEncodedKey = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
00401      if (!pbEncodedKey)
00402      {
00403        printf("Unable to allocate memory for encoded key\n");
00404        __leave;
00405      }
00406
00407      // Read encoded key data
00408      bResult = ReadFile(hFile,
00409                     (LPVOID)pbEncodedKey,
00410                     dwSize,
00411                     &dwRead,
00412                     NULL);
00413      if (!bResult)
00414      {
00415        printf("Unable to read encoded key\n");
00416        __leave;
00417      }
00418
00419      // Close file handle
00420      CloseHandle(hFile);
00421      hFile = INVALID_HANDLE_VALUE;
00422
00423      {
00424         HCRYPTPROV hTemp;
00425
00426         // Create Temporary Provider
00427         bResult = CryptAcquireContext(&hTemp,
00428                                       "Temp000",
00429                                       MS_DEF_PROV,
00430                                       PROV_RSA_FULL,
00431                                       CRYPT_NEWKEYSET);
00432         if (!bResult)
00433         {
00434            // If Temporary Provider exists already,
00435            // open it
00436            if (GetLastError() == NTE_EXISTS)
00437            {
00438               bResult = CryptAcquireContext(&hTemp,
00439                                           "Temp000",
00440                                           MS_DEF_PROV,
00441                                           PROV_RSA_FULL,
00442                                           0);
00443               if (!bResult)
00444               {
00445                  printf("Unable to get temporary provider handle\n");
00446                  __leave;
00447               }
00448            }
00449            else
00450            {
00451               printf("Unable to create temporary provider handle\n");
00452               __leave;
00453            }
00454         }
00455
00456         // Place random data in Uuid
00457         // Could have used UuidCreate but it is not supported
00458         // under Win9x.
00459         bResult = CryptGenRandom(hTemp, sizeof(Uuid), (LPBYTE)&Uuid);
00460         if (!bResult)
00461         {
00462            printf("CryptGenRandom failed with %x\n", GetLastError());
00463            __leave;
00464         }
00465
00466         // Close Provider handle
00467         CryptReleaseContext(hTemp, 0);
00468
00469         // Delete Container
00470         CryptAcquireContext(&hTemp,
00471                            "Temp000",
00472                            MS_DEF_PROV,
00473                            PROV_RSA_FULL,
00474                            CRYPT_DELETEKEYSET);
00475
00476         // Create a random uuid
00477         /*Status = UuidCreate(&Uuid);
00478         if (Status != RPC_S_OK)
00479         {
00480           printf("Unable to create random container\n");
00481           __leave;
00482         }*/
00483
00484         // convert random uuid to a string, we will use it as a container
00485         Status = UuidToString(&Uuid, &szContainer);
00486         if (Status != RPC_S_OK)
00487         {
00488           printf("Unable to convert uuid to string\n");
00489           __leave;
00490         }
00491      }
00492
00493      // Create new crypto context
00494      bResult = CryptAcquireContext(&hProv,
00495                             szContainer,
00496                             szProvider,
00497                             dwProviderType,
00498                             CRYPT_NEWKEYSET | dwAcquireFlags);
00499      if (!bResult)
00500      {
00501        printf("CryptAcquireContext failed with %x\n", GetLastError());
00502        __leave;
00503      }
00504
00505      // Create Hash to hash password
00506      bResult = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash);
00507      if (!bResult)
00508      {
00509        printf("CryptCreateHash failed with %x\n", GetLastError());
00510        __leave;
00511      }
00512
00513      // Hash Password
00514      bResult = CryptHashData(hHash, (LPBYTE)szPassword, (DWORD)strlen(szPassword), 0);
00515      if (!bResult)
00516      {
00517        printf("CryptHashData failed with %x\n", GetLastError());
00518        __leave;
00519      }
00520
00521      // Derive Session Key from password hash
00522      bResult = CryptDeriveKey(hProv, CALG_RC4, hHash, CRYPT_EXPORTABLE, &hKey);
00523      if (!bResult)
00524      {
00525        printf("CryptDeriveKey failed with %x\n", GetLastError());
00526        __leave;
00527      }
00528
00529      // Import Private/Public Key into Provider
00530      bResult = CryptImportKey(hProv, pbEncodedKey, dwSize, hKey,
00531                         CRYPT_EXPORTABLE, &hPubKey);
00532      if (!bResult)
00533      {
00534        printf("CryptImportKey failed with %x\n", GetLastError());
00535        __leave;
00536      }
00537
00538      // Open Certificate file
00539      hFile = CreateFile(szCertFile,
00540                    GENERIC_READ,
00541                    0,
00542                    NULL,
00543                    OPEN_EXISTING,
00544                    FILE_ATTRIBUTE_NORMAL,
00545                    NULL);
00546      if (hFile == INVALID_HANDLE_VALUE)
00547      {
00548        printf("Unable to open certificate file\n");
00549        __leave;
00550      }
00551
00552      // Get file length
00553      dwSize = GetFileSize(hFile, NULL);
00554      if (dwSize == 0xFFFFFFFF)
00555      {
00556        printf("Unable to get size of certificate file\n");
00557        __leave;
00558      }
00559
00560      // Allocate memory for encoded certificate
00561      pbEncodedCert = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
00562      if (!pbEncodedCert)
00563      {
00564        printf("Unable to allocate memory for encoded certificate\n");
00565        __leave;
00566      }
00567
00568      // Read encoded certificate data
00569      bResult = ReadFile(hFile,
00570                     (LPVOID)pbEncodedCert,
00571                     dwSize,
00572                     &dwRead,
00573                     NULL);
00574      if (!bResult)
00575      {
00576        printf("Unable to read encoded certificate\n");
00577        __leave;
00578      }
00579
00580      // Close file handle
00581      CloseHandle(hFile);
00582      hFile = INVALID_HANDLE_VALUE;
00583
00584      // Convert multibyte store name to wide char string
00585      if (mbstowcs(szwStore, szStore, strlen(szStore)+1) == (size_t)-1)
00586      {
00587        printf("Unable to convert store to Unicode string\n");
00588        __leave;
00589      }
00590
00591      // Open Certificate Store
00592      hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
00593                       ENCODING,
00594                       0,
00595                       dwCertOpenFlags,
00596                       (LPVOID)szwStore);
00597      if (!hStore)
00598      {
00599        printf("CertOpenStore failed with %x\n", GetLastError());
00600        __leave;
00601      }
00602
00603      // Add Certificate to store
00604      bResult = CertAddEncodedCertificateToStore(hStore,
00605                                      X509_ASN_ENCODING,
00606                                      pbEncodedCert,
00607                                      dwSize,
00608                                      CERT_STORE_ADD_REPLACE_EXISTING,
00609                                      &pCertContext);
00610      if (!bResult)
00611      {
00612        printf("CertAddEncodedCertificateToStore failed with %x\n", GetLastError());
00613        __leave;
00614      }
00615
00616      {
00617         WCHAR szwContainer[160];
00618         WCHAR szwProvider[260];
00619
00620         i = (int)mbstowcs(szwContainer, szContainer, (size_t)(sizeof(szContainer)+1));
00621         if (i == 0)
00622         {
00623             printf("MultiByteToWideChar failed with %d\n", GetLastError());
00624             __leave;
00625         }
00626
00627         i = MultiByteToWideChar(0, 0, szProvider, -1, szwProvider, 260);
00628         if (i == 0)
00629         {
00630             printf("MultiByteToWideChar failed with %d\n", GetLastError());
00631             __leave;
00632         }
00633
00634         ZeroMemory(&CertKeyInfo, sizeof(CertKeyInfo));
00635         CertKeyInfo.pwszContainerName = szwContainer;
00636         CertKeyInfo.pwszProvName = szwProvider;
00637         CertKeyInfo.dwProvType = dwProviderType;
00638
00639         bResult = CryptGetKeyParam(hPubKey, KP_ALGID, (LPBYTE)&CertKeyInfo.dwKeySpec,
00640                             &dwSize, 0);
00641         if (!bResult)
00642         {
00643           printf("CryptGetKeyParam failed with %x\n", GetLastError());
00644           __leave;
00645         }
00646
00647         // Set Key property for Certificate
00648         bResult = CertSetCertificateContextProperty(pCertContext,
00649                                          CERT_KEY_PROV_INFO_PROP_ID,
00650                                          0,
00651                                          (LPVOID)&CertKeyInfo);
00652         if (!bResult)
00653         {
00654           printf("CertSetCertificateContextProperty failed with %x\n", GetLastError());
00655           __leave;
00656         }
00657      }
00658
00659      fReturn = TRUE;
00660    }
00661    _finally
00662    {
00663      // Clean up
00664      if (szContainer) RpcStringFree(&szContainer);
00665      if (hHash) CryptDestroyHash(hHash);
00666      if (hKey) CryptDestroyKey(hKey);
00667      if (hPubKey) CryptDestroyKey(hPubKey);
00668      if (hProv) CryptReleaseContext(hProv, 0);
00669      if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile);
00670      if (pbEncodedCert) HeapFree(hHeap, 0, pbEncodedCert);
00671      if (pbEncodedKey) HeapFree(hHeap, 0, pbEncodedKey);
00672      if (pCertContext) CertFreeCertificateContext(pCertContext);
00673      if (hStore) CertCloseStore(hStore, 0);
00674    }
00675
00676    return fReturn;
00677 }
00678
00679 BOOL CreateCertificate(LPSTR szX509, DWORD dwKeyType,
00680                        LPSTR szSigAlg, WORD wMonths,
00681                        DWORD dwUsage, BOOL bCA, BOOL bUseProv,
00682                        DWORD dwProviderNum, LPSTR szSubjectStore,
00683                        BOOL bSubjectUser, BOOL bSelfSigned,
00684                        LPSTR szIssuerName, LPSTR szIssuerStore,
00685                        BOOL bIssuerUser, BOOL bExport,
00686                        LPSTR szCertFile, LPSTR szKeyFile,
00687                        LPSTR szPassword)
00688 {
00689    BOOL bReturn = FALSE;
00690    BOOL bResult;
00691    LPBYTE pbNameBlob = NULL;
00692    LPSTR szContainer = NULL;
00693    RPC_STATUS Status;
00694    HCRYPTPROV hProv = 0;
00695    HCRYPTPROV hIssuerProv = 0;
00696    HCRYPTKEY hPubKey = 0;
00697    HCRYPTKEY hSessionKey = 0;
00698    HCRYPTHASH hHash = 0;
00699    HCERTSTORE hStore = 0;
00700    HANDLE hCertFile = INVALID_HANDLE_VALUE;
00701    HANDLE hKeyFile = INVALID_HANDLE_VALUE;
00702    PCRYPT_DATA_BLOB KeyId = NULL;
00703    PCERT_PUBLIC_KEY_INFO PublicKeyInfo = NULL;
00704    PCCERT_CONTEXT pIssuerCert = NULL;
00705    PCCERT_CONTEXT pCertContext = NULL;
00706    LPBYTE pbKeyIdentifier = NULL;
00707    LPBYTE SubjectKeyIdentifier = NULL;
00708    LPBYTE pbKeyUsage = NULL;
00709    LPBYTE pbEnhKeyUsage = NULL;
00710    LPBYTE pbBasicConstraints = NULL;
00711    LPBYTE pbAuthorityKeyId = NULL;
00712    LPBYTE bpEncodedCert = NULL;
00713    LPBYTE pbExportedKey = NULL;
00714    CERT_ENHKEY_USAGE CertEnhKeyUsage = { 0, NULL };
00715    BYTE SerialNumber[8];
00716    CERT_BASIC_CONSTRAINTS2_INFO BasicConstraints;
00717    CERT_AUTHORITY_KEY_ID_INFO AuthorityKeyId;
00718    BYTE ByteData;
00719    CRYPT_BIT_BLOB KeyUsage;
00720    CERT_EXTENSION CertExtension[5];
00721    CRYPT_DATA_BLOB CertKeyIdentifier;
00722    CERT_NAME_BLOB IssuerName;
00723    HANDLE hHeap = GetProcessHeap();
00724    CERT_INFO CertInfo;
00725    DWORD dwSize, m, q;
00726    DWORD dwAcquireFlags, dwIssuerKeyType;
00727    DWORD dwIssuerFlags, dwSubjectFlags;
00728    FILETIME ftTime;
00729    SYSTEMTIME stTime;
00730    CHAR szProvider[260] = { MS_DEF_PROV };
00731    DWORD dwProviderType = PROV_RSA_FULL;
00732    BOOL bAddAuthorityExtension = FALSE;
00733
00734    __try
00735    {
00736       // Enumerate Provider
00737       if (bUseProv)
00738       {
00739          dwSize = 260;
00740          bResult = MyCryptEnumProviders(
00741                            dwProviderNum,
00742                            NULL,
00743                            0,
00744                            &dwProviderType,
00745                            szProvider,
00746                            &dwSize);
00747          if (!bResult)
00748          {
00749             printf("Unable to get provider\n");
00750             __leave;
00751          }
00752
00753       }
00754
00755       if (bSubjectUser)
00756       {
00757          // Certificate will be in the User store and
00758          // key container will be a User container
00759          dwAcquireFlags = 0;
00760          dwSubjectFlags = CERT_SYSTEM_STORE_CURRENT_USER;
00761       }
00762       else
00763       {
00764          // Certificate will be in the Machine store and
00765          // key container will be a Mahince container
00766          dwAcquireFlags = CRYPT_MACHINE_KEYSET;
00767          dwSubjectFlags = CERT_SYSTEM_STORE_LOCAL_MACHINE;
00768       }
00769
00770       if (bIssuerUser)
00771       {
00772          // Get Issuer Certificate from User store
00773          dwIssuerFlags = CERT_SYSTEM_STORE_CURRENT_USER;
00774       }
00775       else
00776       {
00777          // Get Issuer Certificate from Machine store
00778          dwIssuerFlags = CERT_SYSTEM_STORE_LOCAL_MACHINE;
00779       }
00780
00781       // Get X509 Name and convert it to a Name Blob
00782       bResult = CertStrToName(X509_ASN_ENCODING,
00783                           szX509,
00784                           CERT_X500_NAME_STR,
00785                           NULL,
00786                           NULL,
00787                           &dwSize,
00788                           NULL);
00789       if (!bResult)
00790       {
00791          printf("CertStrToName failed with %x\n", GetLastError());
00792          __leave;
00793       }
00794
00795       // Allocate memory for Name Blob
00796       pbNameBlob = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
00797       if (!pbNameBlob)
00798       {
00799          printf("Unable to allocate memory for name blob\n");
00800          __leave;
00801       }
00802
00803       // Convert X509 Name to Name Blob
00804       bResult = CertStrToName(X509_ASN_ENCODING,
00805                           szX509,
00806                           CERT_X500_NAME_STR,
00807                           NULL,
00808                           (LPBYTE)pbNameBlob,
00809                           &dwSize,
00810                           NULL);
00811       if (!bResult)
00812       {
00813          printf("CertStrToName failed with %x\n", GetLastError());
00814          __leave;
00815       }
00816
00817       IssuerName.cbData = dwSize;
00818       IssuerName.pbData = pbNameBlob;
00819
00820       // Convert Enhanced Key usage number to
00821       // Enhanced Key Usage extension
00822
00823       // Find Enhanced Key Usage extensions count
00824       for (m = 0; m < g_EnhKeyUsage.dwCount; m++)
00825       {
00826         if ((g_EnhKeyUsage.dwValue[m] & dwUsage) == g_EnhKeyUsage.dwValue[m])
00827         {
00828           CertEnhKeyUsage.cUsageIdentifier++;
00829         }
00830       }
00831
00832       // If extensions exist continue
00833       if (CertEnhKeyUsage.cUsageIdentifier != 0)
00834       {
00835          // Allocate memory for Enhanced Key Usage array
00836          CertEnhKeyUsage.rgpszUsageIdentifier =
00837              (LPSTR *)HeapAlloc(hHeap, 0, CertEnhKeyUsage.cUsageIdentifier * sizeof(LPSTR));
00838          if (!CertEnhKeyUsage.rgpszUsageIdentifier)
00839          {
00840            printf("Unable to allocate memory for Enhanced Usage array\n");
00841            __leave;
00842          }
00843
00844          // Initialize Enhanced Key Usage array to NULL
00845          for (m = 0; m < CertEnhKeyUsage.cUsageIdentifier; m++)
00846          {
00847            CertEnhKeyUsage.rgpszUsageIdentifier[m] = NULL;
00848          }
00849
00850          // Add proper extension OID to array
00851          q = 0;
00852          for (m = 0; m < g_EnhKeyUsage.dwCount; m++)
00853          {
00854            if ((g_EnhKeyUsage.dwValue[m] & dwUsage) == g_EnhKeyUsage.dwValue[m])
00855            {
00856              CertEnhKeyUsage.rgpszUsageIdentifier[q++] = g_EnhKeyUsage.szUsage[m];
00857            }
00858          }
00859       }
00860
00861       // Create Crypto Context
00862
00863       {
00864          UUID Uuid;
00865          HCRYPTPROV hTemp;
00866
00867          // Create Temporary Provider
00868          bResult = CryptAcquireContext(&hTemp,
00869                                        "Temp000",
00870                                        MS_DEF_PROV,
00871                                        PROV_RSA_FULL,
00872                                        CRYPT_NEWKEYSET);
00873          if (!bResult)
00874          {
00875             // If Temporary Provider exists already,
00876             // open it
00877             if (GetLastError() == NTE_EXISTS)
00878             {
00879                bResult = CryptAcquireContext(&hTemp,
00880                                           "Temp000",
00881                                           MS_DEF_PROV,
00882                                           PROV_RSA_FULL,
00883                                           0);
00884                if (!bResult)
00885                {
00886                   printf("Unable to get temporary provider handle\n");
00887                   __leave;
00888                }
00889             }
00890             else
00891             {
00892                printf("Unable to create temporary provider handle\n");
00893                __leave;
00894             }
00895          }
00896
00897          // Place random data in Uuid
00898          // Could have used UuidCreate but it is not supported
00899          // under Win9x.
00900          bResult = CryptGenRandom(hTemp, sizeof(Uuid), (LPBYTE)&Uuid);
00901          if (!bResult)
00902          {
00903             printf("CryptGenRandom failed with %x\n", GetLastError());
00904             __leave;
00905          }
00906
00907          // Close Provider handle
00908          CryptReleaseContext(hTemp, 0);
00909
00910          // Delete Container
00911          CryptAcquireContext(&hTemp,
00912                            "Temp000",
00913                            MS_DEF_PROV,
00914                            PROV_RSA_FULL,
00915                            CRYPT_DELETEKEYSET);
00916
00917          // Create a random uuid
00918          /*Status = UuidCreate(&Uuid);
00919          if (Status != RPC_S_OK)
00920          {
00921             printf("Unable to create random container\n");
00922             __leave;
00923          }*/
00924
00925          // convert random uuid to a string, we will use it as a container
00926          Status = UuidToString(&Uuid, &szContainer);
00927          if (Status != RPC_S_OK)
00928          {
00929             printf("Unable to convert uuid to string\n");
00930             __leave;
00931          }
00932
00933          // Create new crypto context
00934          bResult = CryptAcquireContext(&hProv,
00935                             szContainer,
00936                             szProvider,
00937                             dwProviderType,
00938                             CRYPT_NEWKEYSET | dwAcquireFlags);
00939          if (!bResult)
00940          {
00941             printf("CryptAcquireContext failed with %x\n", GetLastError());
00942             __leave;
00943          }
00944       }
00945
00946       // Generate Private/Public key pair
00947       bResult = CryptGenKey(hProv, dwKeyType, CRYPT_EXPORTABLE, &hPubKey);
00948       if (!bResult)
00949       {
00950          printf("CryptGenKey failed with %x\n", GetLastError());
00951          __leave;
00952       }
00953
00954       // Zero CERT_INFO structure
00955       ZeroMemory(&CertInfo, sizeof(CertInfo));
00956
00957       // Set Version of Certificate
00958       CertInfo.dwVersion = CERT_V3;
00959
00960       // Create Random Serial Number
00961       bResult = CryptGenRandom(hProv, 8, SerialNumber);
00962       if (!bResult)
00963       {
00964          printf("CryptGenRandom failed with %x\n", GetLastError());
00965          __leave;
00966       }
00967
00968       // Set Serial Number of Certificate
00969       CertInfo.SerialNumber.cbData = 8;
00970       CertInfo.SerialNumber.pbData = SerialNumber;
00971
00972       // Set Signature Algorithm of Certificate
00973       CertInfo.SignatureAlgorithm.pszObjId = szSigAlg;
00974
00975       // set NotBefore date
00976       GetSystemTime(&stTime);
00977       SystemTimeToFileTime(&stTime, &ftTime);
00978       CertInfo.NotBefore = ftTime;
00979
00980       if (wMonths == 0)
00981       {
00982          if (bSelfSigned)
00983             wMonths = 24;
00984          else
00985             wMonths = 6;
00986       }
00987
00988       //
00989       // Set After Date
00990       //
00991       stTime.wMonth += wMonths;
00992       if ((stTime.wMonth / 12) > 0)
00993       {
00994          stTime.wYear += (stTime.wMonth / 12);
00995          stTime.wMonth = (stTime.wMonth % 12);
00996       }
00997
00998       SystemTimeToFileTime(&stTime, &ftTime);
00999       CertInfo.NotAfter = ftTime;
01000
01001       // Get Public Key Info size
01002       bResult = CryptExportPublicKeyInfo(hProv, dwKeyType,
01003                                        X509_ASN_ENCODING, NULL, &dwSize);
01004       if (!bResult)
01005       {
01006          printf("CryptExportPublicKeyInfo failed with %x\n", GetLastError());
01007          __leave;
01008       }
01009
01010       // Allocate memory for Public Key Info
01011       PublicKeyInfo = (PCERT_PUBLIC_KEY_INFO)HeapAlloc(hHeap, 0, dwSize);
01012       if (!PublicKeyInfo)
01013       {
01014          printf("Unable to allocate memory for public key info\n");
01015          __leave;
01016       }
01017
01018       // Get Public Key Info
01019       bResult = CryptExportPublicKeyInfo(hProv, dwKeyType,
01020                                        X509_ASN_ENCODING,
01021                                        PublicKeyInfo, &dwSize);
01022       if (!bResult)
01023       {
01024          printf("CryptExportPublicKeyInfo failed with %x\n", GetLastError());
01025          __leave;
01026       }
01027
01028       // Set Public Key info of Certificate
01029       CertInfo.SubjectPublicKeyInfo = *PublicKeyInfo;
01030
01031       // Create Hash
01032       bResult = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash);
01033       if (!bResult)
01034       {
01035          printf("CryptCreateHash failed with %x\n", GetLastError());
01036          __leave;
01037       }
01038
01039       // Hash Public Key Info
01040       bResult = CryptHashData(hHash, (LPBYTE)PublicKeyInfo, dwSize, 0);
01041       if (!bResult)
01042       {
01043          printf("CryptHashData failed with %x\n", GetLastError());
01044          __leave;
01045       }
01046
01047       // Get Size of Hash
01048       bResult = CryptGetHashParam(hHash, HP_HASHVAL, NULL, &dwSize, 0);
01049       if (!bResult)
01050       {
01051          printf("CryptGetHashParam failed with %x\n", GetLastError());
01052          __leave;
01053       }
01054
01055       // Allocate Memory for Key Identifier (hash of Public Key info)
01056       pbKeyIdentifier = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01057       if (!pbKeyIdentifier)
01058       {
01059          printf("Unable to allocate memory for Hashed Public key Info\n");
01060          __leave;
01061       }
01062
01063       // Get Hash of Public Key Info
01064       bResult = CryptGetHashParam(hHash, HP_HASHVAL, pbKeyIdentifier, &dwSize, 0);
01065       if (!bResult)
01066       {
01067          printf("CryptGetHashParam failed with %x\n", GetLastError());
01068          __leave;
01069       }
01070
01071       // We will use this to set the Key Identifier extension
01072       CertKeyIdentifier.cbData = dwSize;
01073       CertKeyIdentifier.pbData = pbKeyIdentifier;
01074
01075       // Set Subject of Certificate
01076       CertInfo.Subject = IssuerName;
01077
01078       // Set Issuer of Certificate
01079       if (bSelfSigned)
01080       {
01081          CertInfo.Issuer = IssuerName;
01082       }
01083       else
01084       {
01085          pIssuerCert = FindCertificate(szIssuerName, szIssuerStore,
01086                                        dwIssuerFlags, &KeyId,
01087                                        &hIssuerProv, &dwIssuerKeyType);
01088          if (!pIssuerCert)
01089          {
01090             printf("Unable to find Issuer Certificate\n");
01091             __leave;
01092          }
01093
01094          CertInfo.Issuer = pIssuerCert->pCertInfo->Subject;
01095       }
01096
01097       // Get Subject Key Identifier Extension size
01098       bResult = CryptEncodeObject(ENCODING,
01099                                   szOID_SUBJECT_KEY_IDENTIFIER,
01100                                   (LPVOID)&CertKeyIdentifier,
01101                                   NULL, &dwSize);
01102       if (!bResult)
01103       {
01104          printf("CryptEncodeObject failed with %x\n", GetLastError());
01105          __leave;
01106       }
01107
01108       // Allocate Memory for Subject Key Identifier Blob
01109       SubjectKeyIdentifier = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01110       if (!SubjectKeyIdentifier)
01111       {
01112          printf("Unable to allocate memory for Subject Key Identifier\n");
01113          __leave;
01114       }
01115
01116       // Get Subject Key Identifier Extension
01117       bResult = CryptEncodeObject(ENCODING,
01118                                   szOID_SUBJECT_KEY_IDENTIFIER,
01119                                   (LPVOID)&CertKeyIdentifier,
01120                                   SubjectKeyIdentifier, &dwSize);
01121       if (!bResult)
01122       {
01123          printf("CryptEncodeObject failed with %x\n", GetLastError());
01124          __leave;
01125       }
01126
01127       // Set Subject Key Identifier
01128       CertExtension[CertInfo.cExtension].pszObjId = szOID_SUBJECT_KEY_IDENTIFIER;
01129       CertExtension[CertInfo.cExtension].fCritical = FALSE;
01130       CertExtension[CertInfo.cExtension].Value.cbData = dwSize;
01131       CertExtension[CertInfo.cExtension].Value.pbData = SubjectKeyIdentifier;
01132
01133       // Increase extension count
01134       CertInfo.cExtension++;
01135
01136       // Set Key Usage according to Public Key Type
01137       ZeroMemory(&KeyUsage, sizeof(KeyUsage));
01138       KeyUsage.cbData = 1;
01139       KeyUsage.pbData = &ByteData;
01140
01141       if (dwKeyType == AT_SIGNATURE)
01142       {
01143          ByteData = CERT_DIGITAL_SIGNATURE_KEY_USAGE|
01144                     CERT_NON_REPUDIATION_KEY_USAGE|
01145                     CERT_KEY_CERT_SIGN_KEY_USAGE |
01146                     CERT_CRL_SIGN_KEY_USAGE;
01147       }
01148
01149       if (dwKeyType == AT_KEYEXCHANGE)
01150       {
01151          ByteData = CERT_DIGITAL_SIGNATURE_KEY_USAGE |
01152                     CERT_DATA_ENCIPHERMENT_KEY_USAGE|
01153                     CERT_KEY_ENCIPHERMENT_KEY_USAGE |
01154                     CERT_KEY_AGREEMENT_KEY_USAGE;
01155       }
01156
01157       // Get Key Usage blob size
01158       bResult = CryptEncodeObject(ENCODING,
01159                                   X509_KEY_USAGE,
01160                                   (LPVOID)&KeyUsage,
01161                                   NULL, &dwSize);
01162       if (!bResult)
01163       {
01164          printf("CryptEncodeObject failed with %x\n", GetLastError());
01165          __leave;
01166       }
01167
01168       // Allocate Memory for Key Usage Blob
01169       pbKeyUsage = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01170       if (!pbKeyUsage)
01171       {
01172          printf("Unable to allocate memory for Subject Key Identifier\n");
01173          __leave;
01174       }
01175
01176       // Get Key Usage Extension blob
01177       bResult = CryptEncodeObject(ENCODING,
01178                                   X509_KEY_USAGE,
01179                                   (LPVOID)&KeyUsage,
01180                                   pbKeyUsage, &dwSize);
01181       if (!bResult)
01182       {
01183          printf("CryptEncodeObject failed with %x\n", GetLastError());
01184          __leave;
01185       }
01186
01187       // Set Key Usage extension
01188       CertExtension[CertInfo.cExtension].pszObjId = szOID_KEY_USAGE;
01189       CertExtension[CertInfo.cExtension].fCritical = FALSE;
01190       CertExtension[CertInfo.cExtension].Value.cbData = dwSize;
01191       CertExtension[CertInfo.cExtension].Value.pbData = pbKeyUsage;
01192
01193       // Increase extension count
01194       CertInfo.cExtension++;
01195
01196       if (CertEnhKeyUsage.cUsageIdentifier != 0)
01197       {
01198          // Get Enhanced Key Usage size
01199          bResult = CryptEncodeObject(ENCODING,
01200                                      X509_ENHANCED_KEY_USAGE,
01201                                      (LPVOID)&CertEnhKeyUsage,
01202                                      NULL, &dwSize);
01203          if (!bResult)
01204          {
01205             printf("CryptEncodeObject failed with %x\n", GetLastError());
01206             __leave;
01207          }
01208
01209          // Allocate Memory for Enhanced Key usage Blob
01210          pbEnhKeyUsage = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01211          if (!pbEnhKeyUsage)
01212          {
01213             printf("Unable to allocate memory for Subject Key Identifier\n");
01214             __leave;
01215          }
01216
01217          // Get Enhanced Key Usage Extension blob
01218          bResult = CryptEncodeObject(ENCODING,
01219                                      X509_ENHANCED_KEY_USAGE,
01220                                      (LPVOID)&CertEnhKeyUsage,
01221                                      pbEnhKeyUsage, &dwSize);
01222          if (!bResult)
01223          {
01224             printf("CryptEncodeObject failed with %x\n", GetLastError());
01225             __leave;
01226          }
01227
01228          // Set Enhanced Key Usage extension
01229          CertExtension[CertInfo.cExtension].pszObjId = szOID_ENHANCED_KEY_USAGE;
01230          CertExtension[CertInfo.cExtension].fCritical = FALSE;
01231          CertExtension[CertInfo.cExtension].Value.cbData = dwSize;
01232          CertExtension[CertInfo.cExtension].Value.pbData = pbEnhKeyUsage;
01233
01234          // Increase extension count
01235          CertInfo.cExtension++;
01236       }
01237
01238       // Zero Basic Constraints structure
01239       ZeroMemory(&BasicConstraints, sizeof(BasicConstraints));
01240
01241       // Self-signed is always a CA
01242       if (bSelfSigned)
01243       {
01244          BasicConstraints.fCA = TRUE;
01245          BasicConstraints.fPathLenConstraint = TRUE;
01246          BasicConstraints.dwPathLenConstraint = 1;
01247       }
01248       else
01249       {
01250          BasicConstraints.fCA = bCA;
01251       }
01252
01253       // Get Basic Constraints blob size
01254       bResult = CryptEncodeObject(ENCODING,
01255                                   X509_BASIC_CONSTRAINTS2,
01256                                   (LPVOID)&BasicConstraints,
01257                                   NULL, &dwSize);
01258       if (!bResult)
01259       {
01260          printf("CryptEncodeObject failed with %x\n", GetLastError());
01261          __leave;
01262       }
01263
01264       // Allocate Memory for Basic Constraints Blob
01265       pbBasicConstraints = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01266       if (!pbBasicConstraints)
01267       {
01268          printf("Unable to allocate memory for Subject Key Identifier\n");
01269          __leave;
01270       }
01271
01272       // Get Basic Constraints Extension blob
01273       bResult = CryptEncodeObject(ENCODING,
01274                                   X509_BASIC_CONSTRAINTS2,
01275                                   (LPVOID)&BasicConstraints,
01276                                   pbBasicConstraints, &dwSize);
01277       if (!bResult)
01278       {
01279          printf("CryptEncodeObject failed with %x\n", GetLastError());
01280          __leave;
01281       }
01282
01283       // Set Basic Constraints extension
01284       CertExtension[CertInfo.cExtension].pszObjId = szOID_BASIC_CONSTRAINTS2;
01285       CertExtension[CertInfo.cExtension].fCritical = FALSE;
01286       CertExtension[CertInfo.cExtension].Value.cbData = dwSize;
01287       CertExtension[CertInfo.cExtension].Value.pbData = pbBasicConstraints;
01288
01289       // Increase extension count
01290       CertInfo.cExtension++;
01291
01292       if (bSelfSigned)
01293       {
01294          AuthorityKeyId.KeyId = CertKeyIdentifier;
01295          AuthorityKeyId.CertIssuer = CertInfo.Issuer;
01296          AuthorityKeyId.CertSerialNumber = CertInfo.SerialNumber;
01297          bAddAuthorityExtension = TRUE;
01298       }
01299       else
01300       {
01301          if (KeyId)
01302          {
01303             AuthorityKeyId.KeyId = *KeyId;
01304             AuthorityKeyId.CertIssuer = pIssuerCert->pCertInfo->Issuer;
01305             AuthorityKeyId.CertSerialNumber = pIssuerCert->pCertInfo->SerialNumber;
01306             bAddAuthorityExtension = TRUE;
01307          }
01308       }
01309
01310       if (bAddAuthorityExtension)
01311       {
01312          // Get Authority Key Id blob size
01313          bResult = CryptEncodeObject(ENCODING,
01314                                      X509_AUTHORITY_KEY_ID,
01315                                      (LPVOID)&AuthorityKeyId,
01316                                      NULL, &dwSize);
01317          if (!bResult)
01318          {
01319             printf("CryptEncodeObject failed with %x\n", GetLastError());
01320             __leave;
01321          }
01322
01323          // Allocate Authority Key Id Blob
01324          pbAuthorityKeyId = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01325          if (!pbAuthorityKeyId)
01326          {
01327             printf("Unable to allocate memory for Subject Key Identifier\n");
01328             __leave;
01329          }
01330
01331          // Get Authority Key Id blob
01332          bResult = CryptEncodeObject(ENCODING,
01333                                      X509_AUTHORITY_KEY_ID,
01334                                      (LPVOID)&AuthorityKeyId,
01335                                      pbAuthorityKeyId, &dwSize);
01336          if (!bResult)
01337          {
01338             printf("CryptEncodeObject failed with %x\n", GetLastError());
01339             __leave;
01340          }
01341
01342          // Set Authority Key Id extension
01343          CertExtension[CertInfo.cExtension].pszObjId = szOID_AUTHORITY_KEY_IDENTIFIER;
01344          CertExtension[CertInfo.cExtension].fCritical = FALSE;
01345          CertExtension[CertInfo.cExtension].Value.cbData = dwSize;
01346          CertExtension[CertInfo.cExtension].Value.pbData = pbAuthorityKeyId;
01347
01348          // Increase extension count
01349          CertInfo.cExtension++;
01350       }
01351
01352       CertInfo.rgExtension = CertExtension;
01353
01354       if (bSelfSigned)
01355       {
01356          // Get Encoded Certificate Size
01357          bResult = CryptSignAndEncodeCertificate(hProv, dwKeyType,
01358                                                  X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED,
01359                                                  (LPVOID)&CertInfo,
01360                                                  &(CertInfo.SignatureAlgorithm),
01361                                                  NULL, NULL, &dwSize);
01362          if (!bResult)
01363          {
01364             printf("CryptSignAndEncodeCertificate failed with %x\n", GetLastError());
01365             __leave;
01366          }
01367
01368          // Allocate memory for encoded certificate
01369          bpEncodedCert = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01370          if (!bpEncodedCert)
01371          {
01372             printf("Unable to allocate memory for encoded certficate\n");
01373             __leave;
01374          }
01375
01376          // Sign and Encode certificate
01377          bResult = CryptSignAndEncodeCertificate(hProv, dwKeyType,
01378                                                  X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED,
01379                                                  (LPVOID)&CertInfo,
01380                                                  &(CertInfo.SignatureAlgorithm),
01381                                                  NULL, bpEncodedCert, &dwSize);
01382          if (!bResult)
01383          {
01384             printf("CryptSignAndEncodeCertificate failed with %x\n", GetLastError());
01385             __leave;
01386          }
01387       }
01388       else
01389       {
01390          // Get Encoded Certificate Size
01391          bResult = CryptSignAndEncodeCertificate(hIssuerProv, dwIssuerKeyType,
01392                                                  X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED,
01393                                                  (LPVOID)&CertInfo,
01394                                                  &(pIssuerCert->pCertInfo->SignatureAlgorithm),
01395                                                  NULL, NULL, &dwSize);
01396          if (!bResult)
01397          {
01398             printf("CryptSignAndEncodeCertificate failed with %x\n", GetLastError());
01399             __leave;
01400          }
01401
01402          // Allocate memory for encoded certificate
01403          bpEncodedCert = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01404          if (!bpEncodedCert)
01405          {
01406             printf("Unable to allocate memory for encoded certficate\n");
01407             __leave;
01408          }
01409
01410          // Sign and Encode certificate
01411          bResult = CryptSignAndEncodeCertificate(hIssuerProv, dwIssuerKeyType,
01412                                                  X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED,
01413                                                  (LPVOID)&CertInfo,
01414                                                  &(pIssuerCert->pCertInfo->SignatureAlgorithm),
01415                                                  NULL, bpEncodedCert, &dwSize);
01416          if (!bResult)
01417          {
01418             printf("CryptSignAndEncodeCertificate failed with %x\n", GetLastError());
01419             __leave;
01420          }
01421       }
01422
01423       if (bExport)
01424       {
01425           DWORD dwWritten;
01426
01427           // Create Certificate file
01428           hCertFile = CreateFile(szCertFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
01429                                  FILE_ATTRIBUTE_NORMAL, NULL);
01430           if (hCertFile == INVALID_HANDLE_VALUE)
01431           {
01432               printf("CreateFile failed with %d\n", GetLastError());
01433               __leave;
01434           }
01435
01436           // Write encoded Certificate to file
01437           bResult = WriteFile(hCertFile, (LPVOID)bpEncodedCert, dwSize, &dwWritten, NULL);
01438           if (!bResult)
01439           {
01440               printf("WriteFile failed with %d\n", GetLastError());
01441               __leave;
01442           }
01443
01444           // Destroy previous hash
01445           if (hHash) CryptDestroyHash(hHash);
01446           hHash = 0;
01447
01448           // Create hash
01449           bResult = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash);
01450           if (!bResult)
01451           {
01452               printf("CryptCreateHash failed with %x\n", GetLastError());
01453               __leave;
01454           }
01455
01456           // Hash password
01457           bResult = CryptHashData(hHash, (LPBYTE)szPassword, (DWORD)strlen(szPassword), 0);
01458           if (!bResult)
01459           {
01460               printf("CryptHashData failed with %x\n", GetLastError());
01461               __leave;
01462           }
01463
01464           // Derive Session Key from hash
01465           bResult = CryptDeriveKey(hProv, CALG_RC4, hHash, CRYPT_EXPORTABLE, &hSessionKey);
01466           if (!bResult)
01467           {
01468               printf("CryptDeriveKey failed with %x\n", GetLastError());
01469               __leave;
01470           }
01471
01472           // Get size of exported key blob
01473           bResult = CryptExportKey(hPubKey, hSessionKey, PRIVATEKEYBLOB, 0, NULL, &dwSize);
01474           if (!bResult)
01475           {
01476               printf("CryptExportKey failed with %x\n", GetLastError());
01477               __leave;
01478           }
01479
01480           // Allocate memory for exported key blob
01481           pbExportedKey = (LPBYTE)HeapAlloc(hHeap, 0, dwSize);
01482           if (!pbExportedKey)
01483           {
01484               printf("Unable to allocate memory for exported key\n");
01485               __leave;
01486           }
01487
01488           // Get exported key blob
01489           bResult = CryptExportKey(hPubKey, hSessionKey, PRIVATEKEYBLOB,
01490                                    0, pbExportedKey, &dwSize);
01491           if (!bResult)
01492           {
01493               printf("CryptExportKey failed with %x\n", GetLastError());
01494               __leave;
01495           }
01496
01497           // Create Exported Key File
01498           hKeyFile = CreateFile(szKeyFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
01499                                 FILE_ATTRIBUTE_NORMAL, NULL);
01500           if (hKeyFile == INVALID_HANDLE_VALUE)
01501           {
01502               printf("CreateFile failed with %d\n", GetLastError());
01503               __leave;
01504           }
01505
01506           // Write exported key to file
01507           bResult = WriteFile(hKeyFile, (LPVOID)pbExportedKey, dwSize, &dwWritten, NULL);
01508           if (!bResult)
01509           {
01510               printf("WriteFile failed with %d\n", GetLastError());
01511               __leave;
01512           }
01513
01514           // Create new crypto context
01515           bResult = CryptAcquireContext(&hProv,
01516                             szContainer,
01517                             szProvider,
01518                             dwProviderType,
01519                             CRYPT_DELETEKEYSET | dwAcquireFlags);
01520           if (!bResult)
01521
01522           {
01523               printf("CryptAcquireContext failed with %x\n", GetLastError());
01524               __leave;
01525           }
01526
01527                   bReturn = TRUE;
01528
01529           printf("Certificate and Key information stored to files\n");
01530       }
01531       else
01532       {
01533           WCHAR szwStore[20];
01534           WCHAR szwContainer[160];
01535           WCHAR szwProvider[260];
01536           CRYPT_KEY_PROV_INFO CryptKeyProvInfo;
01537           LPSTR szFile;
01538           int i;
01539           DWORD dwWritten;
01540
01541           if (bSelfSigned)
01542           {
01543               szFile = "SelfSigned.cer";
01544           }
01545           else
01546           {
01547               szFile = "Certificate.cer";
01548           }
01549
01550           // Create Certificate file
01551           hCertFile = CreateFile(szFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
01552                                  FILE_ATTRIBUTE_NORMAL, NULL);
01553           if (hCertFile == INVALID_HANDLE_VALUE)
01554           {
01555               printf("CreateFile failed with %d\n", GetLastError());
01556               __leave;
01557           }
01558
01559           // Write encoded Certificate to file
01560           bResult = WriteFile(hCertFile, (LPVOID)bpEncodedCert, dwSize, &dwWritten, NULL);
01561           if (!bResult)
01562           {
01563               printf("WriteFile failed with %d\n", GetLastError());
01564               __leave;
01565           }
01566
01567                   printf("File called %s has been saved.\n", szFile);
01568
01569           // Convert Store string to unicode
01570           i = MultiByteToWideChar(0, 0, szSubjectStore, -1, szwStore, 20);
01571           if (i == 0)
01572           {
01573               printf("MultiByteToWideChar failed with %d\n", GetLastError());
01574               __leave;
01575           }
01576
01577           i = MultiByteToWideChar(0, 0, szProvider, -1, szwProvider, 260);
01578           if (i == 0)
01579           {
01580              printf("MultiByteToWideChar failed with %d\n", GetLastError());
01581               __leave;
01582           }
01583
01584           // Open Certificate store
01585           hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
01586                                  ENCODING,
01587                                  0, dwSubjectFlags, (LPVOID)szwStore);
01588           if (!hStore)
01589           {
01590               printf("CertOpenStore failed with %x\n", GetLastError());
01591               __leave;
01592           }
01593
01594           // Place Certificate in store
01595           bResult = CertAddEncodedCertificateToStore(hStore, X509_ASN_ENCODING,
01596                                     bpEncodedCert, dwSize,
01597                                     CERT_STORE_ADD_REPLACE_EXISTING,
01598                                     &pCertContext);
01599           if (!bResult)
01600           {
01601               printf("CertAddEncodedCertificateToStore failed with %x\n", GetLastError());
01602               __leave;
01603           }
01604
01605           // Convert container to unicode
01606           i = MultiByteToWideChar(0, 0, szContainer, -1, szwContainer, 160);
01607           if (i == 0)
01608           {
01609               printf("MultiByteToWideChar failed with %d\n", GetLastError());
01610               __leave;
01611           }
01612
01613           // Initialize CRYPT_KEY_PROV_INFO structure
01614           ZeroMemory(&CryptKeyProvInfo, sizeof(CryptKeyProvInfo));
01615           CryptKeyProvInfo.pwszContainerName = szwContainer;
01616           CryptKeyProvInfo.pwszProvName = szwProvider;
01617           CryptKeyProvInfo.dwProvType = dwProviderType;
01618           CryptKeyProvInfo.dwKeySpec = dwKeyType;
01619
01620           // Set Certificate's Key Provider info
01621           bResult = CertSetCertificateContextProperty(pCertContext,
01622                                         CERT_KEY_PROV_INFO_PROP_ID,
01623                                         0, (LPVOID)&CryptKeyProvInfo);
01624           if (!bResult)
01625           {
01626               printf("CertSetCertificateContextProperty failed with %x\n", GetLastError());
01627               __leave;
01628           }
01629
01630                   bReturn = TRUE;
01631
01632           printf("Certificate created successfully and installed\n");
01633       }
01634    }
01635    _finally
01636    {
01637       // Clean up
01638       if (pbNameBlob) HeapFree(hHeap, 0, pbNameBlob);
01639       if (CertEnhKeyUsage.rgpszUsageIdentifier)
01640          HeapFree(hHeap, 0, CertEnhKeyUsage.rgpszUsageIdentifier);
01641       if (PublicKeyInfo) HeapFree(hHeap, 0, PublicKeyInfo);
01642       if (pbKeyIdentifier) HeapFree(hHeap, 0, pbKeyIdentifier);
01643       if (SubjectKeyIdentifier) HeapFree(hHeap, 0, SubjectKeyIdentifier);
01644       if (pbKeyUsage) HeapFree(hHeap, 0, pbKeyUsage);
01645       if (pbEnhKeyUsage) HeapFree(hHeap, 0, pbEnhKeyUsage);
01646       if (pbBasicConstraints) HeapFree(hHeap, 0, pbBasicConstraints);
01647       if (KeyId) HeapFree(hHeap, 0, KeyId);
01648       if (pbAuthorityKeyId) HeapFree(hHeap, 0, pbAuthorityKeyId);
01649       if (bpEncodedCert) HeapFree(hHeap, 0, bpEncodedCert);
01650       if (pbExportedKey) HeapFree(hHeap, 0, pbExportedKey);
01651       if (szContainer) RpcStringFree(&szContainer);
01652       if (hCertFile) CloseHandle(hCertFile);
01653       if (hKeyFile) CloseHandle(hKeyFile);
01654       if (hPubKey) CryptDestroyKey(hPubKey);
01655       if (hSessionKey) CryptDestroyKey(hSessionKey);
01656       if (hHash) CryptDestroyHash(hHash);
01657       if (hProv) CryptReleaseContext(hProv, 0);
01658       if (hIssuerProv) CryptReleaseContext(hIssuerProv, 0);
01659       if (pIssuerCert) CertFreeCertificateContext(pIssuerCert);
01660       if (pCertContext) CertFreeCertificateContext(pCertContext);
01661       if (hStore) CertCloseStore(hStore, 0);
01662    }
01663
01664    return bReturn;
01665 }
01666
01667 //
01668 // Find Certificate with szCertName in the Subject name
01669 //
01670 PCCERT_CONTEXT FindCertificate(LPSTR szCertName, LPSTR szStore,
01671                                DWORD dwFlags, PCRYPT_DATA_BLOB *KeyId,
01672                                HCRYPTPROV *hProv, LPDWORD dwKeyType)
01673 {
01674    HANDLE hHeap = GetProcessHeap();
01675    PCRYPT_KEY_PROV_INFO KeyProvInfo;
01676    PCCERT_CONTEXT pCertContext = NULL;
01677    PCERT_EXTENSION pExtension = NULL;
01678    HCERTSTORE hStore = 0;
01679    WCHAR szwStore[20];
01680    CHAR szContainer[160];
01681    CHAR szProvider[160];
01682    BOOL bResult, bSuccess = FALSE;
01683    DWORD dwSize, dwAcquireFlags = 0;
01684    int i;
01685
01686    __try
01687    {
01688       *KeyId = NULL;
01689       *hProv = 0;
01690
01691       if (dwFlags == CERT_SYSTEM_STORE_LOCAL_MACHINE)
01692          dwAcquireFlags = CRYPT_MACHINE_KEYSET;
01693
01694       // Convert Store string to Unicode
01695       i = MultiByteToWideChar(0, 0, szStore, -1, szwStore, 20);
01696       if (i == 0)
01697       {
01698          __leave;
01699       }
01700
01701       // Open Certificate store
01702       hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
01703                            ENCODING,
01704                            0, dwFlags, (LPVOID)szwStore);
01705       if (!hStore)
01706       {
01707          __leave;
01708       }
01709
01710       // Find Certificate with Subject name
01711       pCertContext = CertFindCertificateInStore(hStore,
01712                               ENCODING,
01713                               0, CERT_FIND_SUBJECT_STR_A,
01714                               (LPVOID)szCertName, NULL);
01715       if (pCertContext)
01716       {
01717          // Get Key Provider Info size
01718          bResult = CertGetCertificateContextProperty(pCertContext,
01719                                              CERT_KEY_PROV_INFO_PROP_ID,
01720                                              NULL,
01721                                              &dwSize);
01722          if (!bResult)
01723          {
01724             __leave;
01725          }
01726
01727          // Allocate Key Provider Info
01728          KeyProvInfo = (PCRYPT_KEY_PROV_INFO)HeapAlloc(hHeap, 0, dwSize);
01729          if (!KeyProvInfo)
01730          {
01731             __leave;
01732          }
01733
01734          // Get Key Provider Info
01735          bResult = CertGetCertificateContextProperty(pCertContext,
01736                                              CERT_KEY_PROV_INFO_PROP_ID,
01737                                              (LPVOID)KeyProvInfo,
01738                                              &dwSize);
01739          if (!bResult)
01740          {
01741             __leave;
01742          }
01743
01744          // Convert Container Name to ANSI
01745          i = WideCharToMultiByte(0, 0, KeyProvInfo->pwszContainerName,
01746                                  -1, szContainer, 160, NULL, NULL);
01747          if (i == 0)
01748          {
01749             __leave;
01750          }
01751
01752          // Convert Provider Name to ANSI
01753          i = WideCharToMultiByte(0, 0, KeyProvInfo->pwszProvName, -1,
01754                                  szProvider, 160, NULL, NULL);
01755          if (i == 0)
01756          {
01757             __leave;
01758          }
01759
01760          // Get Crypto Context of Certificate
01761          bResult = CryptAcquireContext(hProv, szContainer, szProvider,
01762                                        KeyProvInfo->dwProvType, dwAcquireFlags);
01763          if (!bResult)
01764          {
01765             __leave;
01766          }
01767
01768          // Return Key Spec
01769          *dwKeyType = KeyProvInfo->dwKeySpec;
01770
01771          bSuccess = TRUE;
01772
01773          // Find Subject Key Identifier Extension
01774          pExtension = CertFindExtension(szOID_SUBJECT_KEY_IDENTIFIER,
01775                                         pCertContext->pCertInfo->cExtension,
01776                                         pCertContext->pCertInfo->rgExtension);
01777
01778          // If Subject Key Identifier Extension Exists
01779          if (pExtension)
01780          {
01781
01782             // Get Size of Data Blob
01783             bResult = CryptDecodeObject(ENCODING,
01784                                         szOID_SUBJECT_KEY_IDENTIFIER,
01785                                         pExtension->Value.pbData,
01786                                         pExtension->Value.cbData,
01787                                         0, NULL, &dwSize);
01788             if (!bResult)
01789             {
01790                __leave;
01791             }
01792
01793             // Allocate Data Blob
01794             *KeyId = (PCRYPT_DATA_BLOB)HeapAlloc(hHeap, 0, dwSize);
01795             if (!(*KeyId))
01796             {
01797                __leave;
01798             }
01799
01800             // Get Key Identifier Data Blob
01801             bResult = CryptDecodeObject(ENCODING,
01802                                         szOID_SUBJECT_KEY_IDENTIFIER,
01803                                         pExtension->Value.pbData,
01804                                         pExtension->Value.cbData,
01805                                         0, (LPVOID)*KeyId, &dwSize);
01806             if (!bResult)
01807             {
01808                __leave;
01809             }
01810          }
01811       }
01812       else
01813       {
01814          __leave;
01815       }
01816
01817       bSuccess = TRUE;
01818    }
01819    __finally
01820    {
01821       // Clean up
01822       if (hStore) CertCloseStore(hStore, 0);
01823       if (KeyProvInfo) HeapFree(hHeap, 0, KeyProvInfo);
01824       if (!bSuccess)
01825       {
01826          if (pCertContext) CertFreeCertificateContext(pCertContext);
01827          pCertContext = NULL;
01828          if (*KeyId) HeapFree(hHeap, 0, *KeyId);
01829          *KeyId = NULL;
01830       }
01831    }
01832
01833    return pCertContext;
01834 }
01835
01836 //
01837 // Implement this is CryptEnumProviders is unavailble
01838 //
01839 BOOL WINAPI MyCryptEnumProviders(DWORD dwIndex, LPDWORD Res, DWORD dwFlags, LPDWORD pdwProvType,
01840                                  LPTSTR szProvName, LPDWORD pcbProvName)
01841 {
01842     static LPTSTR szKeyPath = TEXT("SOFTWARE\\Microsoft\\Cryptography\\Defaults\\Provider");
01843     BOOL bResult = TRUE;
01844     DWORD dwNumKeys;
01845     HKEY hKey = NULL;
01846     HKEY hSubKey = NULL;
01847     LONG lResult;
01848     FILETIME ft;
01849
01850     __try
01851     {
01852        // Open registry provider registry key
01853         lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKeyPath, 0, KEY_READ, &hKey);
01854         if (lResult != ERROR_SUCCESS)
01855         {
01856             bResult = FALSE;
01857             __leave;
01858         }
01859
01860
01861         if (szProvName == NULL)
01862         {
01863            // Query for Number of Keys and Size maximum size of
01864            // provider
01865            lResult = RegQueryInfoKey(hKey, NULL, NULL, NULL, &dwNumKeys, pcbProvName,
01866                                      NULL, NULL, NULL, NULL, NULL, NULL);
01867            if (lResult != ERROR_SUCCESS)
01868            {
01869               bResult = FALSE;
01870               __leave;
01871            }
01872
01873            // return Size of Provider Name
01874            *pcbProvName = (*pcbProvName + 1) * sizeof(TCHAR);
01875
01876            if (dwIndex >= dwNumKeys) return FALSE;
01877         }
01878         else
01879         {
01880            DWORD dwSize;
01881            DWORD dwType;
01882
01883            // Get Provider by Index
01884            dwSize = *pcbProvName/sizeof(TCHAR);
01885            lResult = RegEnumKeyEx(hKey, dwIndex, szProvName, &dwSize, NULL, NULL, NULL, &ft);
01886            if (lResult != ERROR_SUCCESS)
01887            {
01888               bResult = FALSE;
01889               __leave;
01890            }
01891
01892            *pcbProvName = (dwSize + 1) * sizeof(TCHAR);
01893
01894            // Open the Provider Registry Key
01895            lResult = RegOpenKeyEx(hKey, szProvName, 0, KEY_READ, &hSubKey);
01896            if (lResult != ERROR_SUCCESS)
01897            {
01898               bResult = FALSE;
01899               __leave;
01900            }
01901
01902            // Get Provider Type
01903            dwSize = sizeof(DWORD);
01904            lResult = RegQueryValueEx(hSubKey, TEXT("Type"), NULL, &dwType, (LPBYTE)pdwProvType, &dwSize);
01905            if (lResult != ERROR_SUCCESS)
01906            {
01907               bResult = FALSE;
01908               __leave;
01909            }
01910         }
01911     }
01912     __finally
01913     {
01914        // Clean up
01915        if (hKey != NULL) RegCloseKey(hKey);
01916        if (hSubKey != NULL) RegCloseKey(hSubKey);
01917     }
01918
01919     return bResult;
01920 }
01921
01922 //
01923 // Print Usage
01924 //
01925 void PrintUsage(void)
01926 {
01927    DWORD nIndex = 0;
01928    DWORD dwProvType, dwSize;
01929    CHAR szProvider[160];
01930
01931    printf("\nUsage: CreateCert [Import option] <X509 Name> [Options]\n");
01932    printf("\n[Import option] : If this option is present, everything else is ignored\n");
01933    printf("\t-i <cert file> <public key file> <password> <store> <u>ser|<m>achine <provider num>\n");
01934    printf("\n<X509 Name> (eg. CN=Certificate)\n");
01935    printf("\n[Options]\n");
01936    printf("Type of Certificate:\n");
01937    printf("\t-p <provider number> - default: MS_DEF_PROV\n");
01938    printf("\t-k <e>xchange key | <s>ignature key - default:exchange\n");
01939    printf("\t-s <sha>|<md5> - default:sha\n");
01940    printf("\t-m <number of months of validity>\n");
01941    printf("\t-ca - indicates that the certificate is to be a CA. True for selfsigned\n");
01942    printf("\t-u <enhanced key usage number> - add following numbers\n");
01943    printf("\t\tServer Authentication : 1\n");
01944    printf("\t\tClient Authentication : 2\n");
01945    printf("\t\tCode Signing          : 4\n");
01946    printf("\t\tEmail Protection      : 8\n");
01947    printf("\t\tTime Stamping         : 16\n");
01948    printf("\nLocation of Certificate:\n");
01949    printf("\t-sl <store> <u>ser|<m>achine - default:my u\n");
01950    printf("\t\tor\n");
01951    printf("\t-ex <cert file> <public key file> <password>\n");
01952    printf("\nSigner of the certificate - defaults to self-signed if -is is not present\n");
01953    printf("\t-is <CommonName or substring> <store> <u>ser|<m>achine\n");
01954
01955    printf("\nProviders:\n");
01956    dwSize = 160;
01957    while (MyCryptEnumProviders(nIndex, NULL, 0, &dwProvType, szProvider, &dwSize))
01958    {
01959       printf("\t%d : %s\n", nIndex, szProvider);
01960       dwSize = 160;
01961       nIndex++;
01962    }
01963
01964    printf("\nSelf-Signed Certificates create a file called SelfSigned.cer\n");
01965    printf("Non Self-Signed Certificates create a file called Certificate.cer\n");
01966 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/Util.Cpp Source File

  • Web
  • NetMeeting
  • NMUI

Util.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       UTIL.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016 #include "shlobj.h"
00017
00018
00019 //****************************************************************************
00020 //
00021 // BOOL GetIniBool(LPTSTR pszEntry, BOOL fDefault)
00022 //
00023 // Get the boolean data for an entry
00024 //
00025 //****************************************************************************
00026
00027 BOOL GetIniBool(LPTSTR pszEntry, BOOL fDefault)
00028 {
00029   return GetPrivateProfileInt(gszAppName, pszEntry, fDefault, gszIniName) != 0;
00030 }
00031
00032 //****************************************************************************
00033 //
00034 // DWORD GetIniInt(LPTSTR pszEntry, DWORD dwDefault)
00035 //
00036 // Get the numeric data for an entry
00037 //
00038 //****************************************************************************
00039
00040 DWORD GetIniInt(LPTSTR pszEntry, DWORD dwDefault)
00041 {
00042   return GetPrivateProfileInt(gszAppName, pszEntry, dwDefault, gszIniName);
00043 }
00044
00045 //****************************************************************************
00046 //
00047 // LPTSTR GetIniStr(LPTSTR pszEntry, LPTSTR pszDefault)
00048 //
00049 // Get the string data for an entry
00050 //
00051 //****************************************************************************
00052
00053 LPTSTR GetIniStr(LPTSTR pszEntry, LPTSTR pszDefault)
00054 {
00055   int     cch   = 0;
00056   LPTSTR    pszRet  = 0;
00057
00058   TCHAR   sz[MAX_PATH + 1];
00059   ZeroMemory(sz, (MAX_PATH + 1) * sizeof(TCHAR));
00060
00061   cch = GetPrivateProfileString(gszAppName, pszEntry, pszDefault, sz, MAX_PATH, gszIniName);
00062   if (cch == 0)
00063   {
00064     if (NULL == pszDefault)
00065       return NULL;
00066
00067     cch = lstrlen(pszDefault);
00068     lstrcpyn(sz, pszDefault, MAX_PATH+1);
00069     sz[MAX_PATH] = 0;
00070   }
00071
00072   pszRet = PszAlloc(cch);
00073   if (pszRet == NULL)
00074     return NULL;
00075
00076   ZeroMemory(pszRet, (cch+1)* sizeof(TCHAR)); // PszAlloc allocated cch + 1 characters
00077   lstrcpyn(pszRet, sz, cch+1);
00078   pszRet[cch] = 0;
00079
00080   return pszRet;
00081 }
00082
00083
00084 //****************************************************************************
00085 //
00086 // VOID GetIniHex(LPTSTR pszEntry, LPVOID lpv, int cb)
00087 //
00088 // Convert the hex data into binary.
00089 // If no entry is found, lpv isn't modified
00090 //
00091 //****************************************************************************
00092
00093 VOID GetIniHex(LPTSTR pszEntry, LPVOID lpv, int cb)
00094 {
00095   TCHAR sz[MAX_PATH + 1];
00096   ZeroMemory(sz, (MAX_PATH + 1) * sizeof(TCHAR));
00097
00098   if (GetPrivateProfileString(gszAppName, pszEntry, TEXT(""), sz, MAX_PATH, gszIniName) != 0)
00099   {
00100     HexToData(sz, lpv, (MAX_PATH < cb) ? MAX_PATH : cb);
00101   }
00102 }
00103
00104
00105 //****************************************************************************
00106 //
00107 // VOID WriteIniStr(LPTSTR pszEntry, LPTSTR pszData)
00108 //
00109 // Write the data to an entry in the ini file
00110 //
00111 //****************************************************************************
00112
00113 VOID WriteIniStr(LPTSTR pszEntry, LPTSTR pszData)
00114 {
00115   WritePrivateProfileString(gszAppName, pszEntry, pszData, gszIniName);
00116 }
00117
00118
00119 //****************************************************************************
00120 //
00121 // VOID WriteIniInt(LPTSTR pszEntry, DWORD dw)
00122 //
00123 // Write the numeric data to an entry in the ini file
00124 //
00125 //****************************************************************************
00126
00127 VOID WriteIniInt(LPTSTR pszEntry, DWORD dw)
00128 {
00129   TCHAR szData[MAX_PATH + 1];
00130   ZeroMemory(szData, (MAX_PATH + 1) * sizeof(TCHAR));
00131
00132   _sntprintf(szData, MAX_PATH, TEXT("%d\0"), dw);
00133   WritePrivateProfileString(gszAppName, pszEntry, szData, gszIniName);
00134 }
00135
00136
00137 //****************************************************************************
00138 //
00139 // VOID WriteIniBool(LPTSTR pszEntry, BOOL f)
00140 //
00141 // Write the boolean value to an entry in the registery
00142 //
00143 //****************************************************************************
00144
00145 VOID WriteIniBool(LPTSTR pszEntry, BOOL f)
00146 {
00147   WritePrivateProfileString(gszAppName, pszEntry, f ? TEXT("1") : TEXT("0"), gszIniName);
00148 }
00149
00150
00151 //****************************************************************************
00152 //
00153 // VOID WriteIniHex(LPTSTR pszEntry, LPVOID lpv, int cb)
00154 //
00155 //****************************************************************************
00156 VOID WriteIniHex(LPTSTR pszEntry, LPVOID lpv, int cb)
00157 {
00158   if  ((NULL == pszEntry) || (NULL == lpv))
00159   {
00160     ERROR_MSG(TEXT("WriteIniHex: NULL == in parameter"));
00161     return;
00162   }
00163
00164   TCHAR sz[MAX_PATH + 1];
00165   ZeroMemory(sz, sizeof(TCHAR) * (MAX_PATH+1));
00166
00167   DataToHex((LPTSTR) lpv, sz, 2*cb > MAX_PATH ? MAX_PATH : 2*cb);
00168
00169   WriteIniStr(pszEntry, sz);
00170
00171 }
00172
00173
00174 //****************************************************************************
00175 //
00176 // VOID CenterWindow(HWND hwndChild, HWND hwndParent)
00177 //
00178 // Center a window over another window.
00179 //
00180 //****************************************************************************
00181
00182 VOID CenterWindow(HWND hwndChild, HWND hwndParent)
00183 {
00184   int xNew    = 0;
00185   int yNew    = 0;
00186   int cxChild   = 0;
00187   int cyChild   = 0;
00188   int cxParent  = 0;
00189   int cyParent  = 0;
00190   int cxScreen  = 0;
00191   int cyScreen  = 0;
00192
00193   RECT  rcChild = {0,0,0,0};
00194   RECT  rcParent= {0,0,0,0};
00195   HDC   hdc;
00196
00197   // Get the Height and Width of the child window
00198   GetWindowRect(hwndChild, &rcChild);
00199   cxChild = rcChild.right - rcChild.left;
00200   cyChild = rcChild.bottom - rcChild.top;
00201
00202   // Get the Height and Width of the parent window
00203   GetWindowRect(hwndParent, &rcParent);
00204   cxParent = rcParent.right - rcParent.left;
00205   cyParent = rcParent.bottom - rcParent.top;
00206
00207   // Get the display limits
00208   hdc = GetDC(hwndChild);
00209   if (hdc == NULL) {
00210     // major problems - move window to 0,0
00211     xNew = yNew = 0;
00212   } else {
00213     cxScreen = GetDeviceCaps(hdc, HORZRES);
00214     cyScreen = GetDeviceCaps(hdc, VERTRES);
00215     ReleaseDC(hwndChild, hdc);
00216
00217     if (NULL == hwndParent) {
00218       cxParent = cxScreen;
00219       cyParent = cyScreen;
00220       SetRect(&rcParent, 0, 0, cxScreen, cyScreen);
00221     }
00222
00223     // Calculate new X position, then adjust for screen
00224     xNew = rcParent.left + ((cxParent - cxChild) / 2);
00225     if (xNew < 0) {
00226       xNew = 0;
00227     } else if ((xNew + cxChild) > cxScreen) {
00228       xNew = cxScreen - cxChild;
00229     }
00230
00231     // Calculate new Y position, then adjust for screen
00232     yNew = rcParent.top  + ((cyParent - cyChild) / 2);
00233     if (yNew < 0) {
00234       yNew = 0;
00235     } else if ((yNew + cyChild) > cyScreen) {
00236       yNew = cyScreen - cyChild;
00237     }
00238
00239   }
00240
00241   SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
00242     SWP_NOSIZE | SWP_NOZORDER);
00243 }
00244
00245
00246 //****************************************************************************
00247 //
00248 // LPVOID LpvAlloc(int cb)
00249 //
00250 // Return a pointer to an allocated array of bytes
00251 //
00252 //****************************************************************************
00253
00254 LPVOID LpvAlloc(int cb)
00255 {
00256   return LocalAlloc(LMEM_FIXED, cb);
00257 }
00258
00259
00260 //****************************************************************************
00261 //
00262 // LPTSTR PszAlloc(int cch)
00263 //
00264 //****************************************************************************
00265
00266 LPTSTR PszAlloc(int cch)
00267 {
00268   return (LPTSTR) LocalAlloc(LMEM_FIXED, sizeof(TCHAR) * (cch+1));
00269 }
00270
00271
00272 //****************************************************************************
00273 //
00274 // VOID FreePlpv(LPVOID plpv)
00275 //
00276 // Free the data pointed to by plpv and set *plpv to NULL
00277 //
00278 //****************************************************************************
00279
00280 VOID FreePlpv(LPVOID plpv)
00281 {
00282   if ((plpv == NULL) || (*(VOID FAR * FAR *)plpv == NULL)) {
00283     return;
00284   }
00285
00286   LocalFree(*(VOID FAR * FAR *)plpv);
00287   *(VOID FAR * FAR *)plpv = NULL;
00288 }
00289
00290
00291 //****************************************************************************
00292 //
00293 // TCHAR ChFromHex(LPTSTR lpch)
00294 //
00295 // Convert from Hex data to ascii character
00296 //
00297 //****************************************************************************
00298
00299 TCHAR ChFromHex(LPTSTR lpch)
00300 {
00301   if  (NULL == lpch)
00302     return NULL;
00303
00304   int   i = 0;
00305   int   cch = 2;
00306   char  ch  = 0;
00307
00308   while (cch-- > 0)
00309   {
00310     ch = *lpch++;
00311     if (ch >= 'A')
00312     {
00313       i = (i*16) + (ch - ('A'-10));
00314     }
00315     else
00316     {
00317       i = (i*16) + (ch - '0');
00318     }
00319   }
00320
00321   return (TCHAR) i;
00322 }
00323
00324
00325 //****************************************************************************
00326 //
00327 // VOID HexToData(LPTSTR lpchSrc, LPVOID lpvDest, int cb)
00328 //
00329 // Convert from Hex data to ascii character
00330 //
00331 //****************************************************************************
00332
00333 VOID HexToData(LPTSTR lpchSrc, LPVOID lpvDest, int cb)
00334 {
00335   if  ((NULL == lpvDest) || (NULL == lpchSrc))
00336     return;
00337
00338   PTCHAR lpchDest = (PTCHAR) lpvDest;
00339
00340   CharUpperBuff(lpchSrc, cb);
00341
00342   while (cb-- > 0)
00343   {
00344     *lpchDest++ = ChFromHex(lpchSrc);
00345     lpchSrc += 2;
00346   }
00347 }
00348
00349
00350 //****************************************************************************
00351 //
00352 // LPTSTR HexToBin(LPTSTR lpchSrc, LPVOID lpvDest, int cb)
00353 //
00354 // Convert from Hex data to ascii character
00355 //
00356 //****************************************************************************
00357
00358 LPTSTR HexToBin(LPTSTR lpchSrc, LPVOID lpvDest, int cb)
00359 {
00360   if  ((NULL == lpvDest) || (NULL == lpchSrc))
00361     return NULL;
00362
00363   TCHAR * lpchDest = ((TCHAR *) lpvDest) + cb;
00364
00365   CharUpperBuff(lpchSrc, cb);
00366
00367   while (cb-- > 0)
00368   {
00369     lpchDest--;
00370     *lpchDest = ChFromHex(lpchSrc);
00371     lpchSrc += 2;
00372   }
00373   return lpchSrc;
00374 }
00375
00376 //****************************************************************************
00377 //
00378 // VOID DataToHex(LPTSTR lpchSrc, LPTSTR lpchDest, int cb)
00379 //
00380 //****************************************************************************
00381
00382 VOID DataToHex(LPTSTR lpchSrc, LPTSTR lpchDest, int cbDest)
00383 {
00384   int cb  = cbDest / 2;
00385   UINT ch = 0;
00386
00387   if  (NULL == lpchDest)
00388   {
00389     ERROR_MSG(TEXT("DataToHex: Destination string is NULL"));
00390     return;
00391   }
00392
00393   if (lpchSrc == NULL)
00394   {
00395     lpchDest[0] = 0;  // return empty string
00396     return;
00397   }
00398
00399   while (cb-- > 0)
00400   {
00401     ch = 0x00FF & (unsigned char) (*lpchSrc++);
00402     _sntprintf(lpchDest, 2, TEXT("%02X"), ch);
00403     lpchDest += 2;
00404   }
00405 }
00406
00407
00408 //****************************************************************************
00409 //
00410 // VOID SetMenuCheck(UINT idm, BOOL fCheck)
00411 //
00412 // Set the menu item's check mark.
00413 //
00414 //****************************************************************************
00415
00416 VOID SetMenuCheck(UINT idm, BOOL fCheck)
00417 {
00418   CheckMenuItem(ghMenu, idm,
00419     fCheck ? (MF_CHECKED  | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND));
00420 }
00421
00422
00423 //****************************************************************************
00424 //
00425 // VOID MaybeDeleteObject(HGDIOBJ * phgdi)
00426 //
00427 // Check usage count, delete if we can
00428 //
00429 //****************************************************************************
00430
00431 VOID MaybeDeleteObject(HGDIOBJ * phgdi)
00432 {
00433   if ((NULL == phgdi) || (NULL == *phgdi))
00434     return;
00435
00436   DeleteObject(*phgdi);
00437   *phgdi = NULL;
00438 }
00439
00440 //****************************************************************************
00441 //
00442 // BOOL FGetFileName(LPTSTR szFileName)
00443 //
00444 //****************************************************************************
00445
00446 BOOL FGetFileName(LPTSTR szFileName)
00447 {
00448   if  (NULL == szFileName)
00449   {
00450     ERROR_MSG(TEXT("FGetFileName: NULL == szFileName"));
00451     return FALSE;
00452   }
00453
00454   OPENFILENAME ofn;
00455   ZeroMemory(&ofn, sizeof(OPENFILENAME));
00456
00457   szFileName[0] = TEXT('\0');
00458
00459   ofn.lStructSize   = sizeof(OPENFILENAME);
00460   ofn.hwndOwner     = ghwndMain;
00461   ofn.hInstance     = (HINSTANCE) ghInst;
00462   ofn.lpstrFilter   = TEXT("All Files\0*.*\0Text Files (*.txt)\0*.TXT\0");
00463   ofn.nFilterIndex  = 1L;
00464   ofn.lpstrFile     = szFileName;
00465   ofn.nMaxFile      = MAX_PATH;
00466   ofn.lpstrTitle    = TEXT("Pick a file to send\0");
00467   ofn.lpstrInitialDir = NULL;
00468   ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
00469
00470   if (!GetOpenFileName(&ofn))
00471     return FALSE;
00472
00473   return TRUE;
00474 }
00475
00476
00477 //****************************************************************************
00478 //
00479 // BOOL FGetDirectory(LPTSTR szDir)
00480 //
00481 //****************************************************************************
00482
00483 BOOL FGetDirectory(LPTSTR szDir)
00484 {
00485   BOOL      fRet    = FALSE;
00486   LPITEMIDLIST  pidl    = NULL;
00487   LPITEMIDLIST  pidlRoot  = NULL;
00488   LPMALLOC    lpMalloc  = NULL;
00489
00490   TCHAR     szPath[MAX_PATH + 1];
00491   ZeroMemory(szPath, sizeof(TCHAR) * (MAX_PATH + 1));
00492
00493   BROWSEINFO bi = {
00494     ghwndMain,
00495     NULL,
00496     szPath,
00497     TEXT("Select a Directory\0"),
00498     BIF_RETURNONLYFSDIRS,
00499     NULL, 0L, 0 };
00500
00501   if  (0 != SHGetSpecialFolderLocation(HWND_DESKTOP, CSIDL_DRIVES, &pidlRoot))
00502     return FALSE;
00503
00504   if  (NULL == pidlRoot)
00505     return FALSE;
00506
00507   bi.pidlRoot = pidlRoot;
00508   pidl = SHBrowseForFolder(&bi);
00509
00510   if  (NULL != pidl)
00511     fRet = SHGetPathFromIDList(pidl, szDir);
00512   else
00513     fRet = FALSE;
00514
00515   // Get the shell's allocator to free PIDLs
00516   if (!SHGetMalloc(&lpMalloc) && (NULL != lpMalloc))
00517   {
00518     if (NULL != pidlRoot)
00519     {
00520       lpMalloc->Free(pidlRoot);
00521       pidlRoot = NULL;
00522     }
00523
00524     if (NULL != pidl)
00525     {
00526       lpMalloc->Free(pidl);
00527       pidl = NULL;
00528     }
00529
00530     lpMalloc->Release();
00531     lpMalloc = NULL;
00532   }
00533
00534   return fRet;
00535 }
00536
00537
00538 //****************************************************************************
00539 //
00540 // VOID GetDlgItemPsz(HWND hdlg, UINT id, LPTSTR *ppsz)
00541 //
00542 // Get the text in the dialog item and retun a pointer to it in *ppsz.
00543 // Note: Any previous data in ppsz is released.
00544 //
00545 //****************************************************************************
00546
00547 VOID GetDlgItemPsz(HWND hdlg, UINT id, LPTSTR *ppsz)
00548 {
00549   if  (NULL == ppsz)
00550   {
00551     ERROR_MSG(TEXT("GetDlgItemPsz: NULL = ppsz"));
00552     return;
00553   }
00554
00555   UINT  cch   = 0;
00556
00557   TCHAR sz[MAX_PATH+1];
00558   ZeroMemory(sz, sizeof(TCHAR) * (MAX_PATH + 1));
00559
00560   FreePlpv(ppsz);
00561
00562   cch = GetDlgItemText(hdlg, id, sz, MAX_PATH);
00563   if (0 == cch)
00564     return;
00565
00566   *ppsz = (LPTSTR) PszAlloc(cch);
00567   if (NULL == *ppsz)
00568     return;
00569
00570   ZeroMemory(*ppsz, (cch+1)* sizeof(TCHAR));  //PszAlloc allocates number of bytes passed + 1
00571   lstrcpyn(*ppsz, sz, cch+1);
00572   (*ppsz)[cch] = 0;
00573 }
00574
00575
00576 //****************************************************************************
00577 //
00578 // int GetRadioButton(HWND hdlg, int idrFirst, int idrLast)
00579 //
00580 //****************************************************************************
00581
00582 int GetRadioButton(HWND hdlg, int idrFirst, int idrLast)
00583 {
00584   for (int id = idrFirst; id <= idrLast; id++)
00585   {
00586     if (BST_UNCHECKED != IsDlgButtonChecked(hdlg, id))
00587       return id;
00588   }
00589   return idrFirst;
00590 }
00591
00592 //****************************************************************************
00593 //
00594 // VOID GuidToSz(GUID * pguid, LPTSTR lpchDest)
00595 //
00596 // Convert the guid to a special hex string.
00597 // Assumes lpchDest has space for at least sizeof(GUID)*2 +6 chars.
00598 // LENGTH_SZGUID_FORMATTED is 30 and includes space for the null terminator.
00599 //
00600 // Note the difference between this and UuidToString (or StringFromGUID2)
00601 //
00602 // GUID Format: {12345678-1234-1234-1234-567890123456}
00603 //
00604 //****************************************************************************
00605
00606 VOID GuidToSz(GUID * pguid, LPTSTR lpchDest)
00607 {
00608   ASSERT(NULL != pguid);
00609   ASSERT(NULL != lpchDest);
00610
00611   if  ((NULL == pguid) || (NULL == lpchDest))
00612   {
00613     ERROR_MSG(TEXT("GuidToSz: Null pointer passed in as parameter"));
00614     return;
00615   }
00616
00617   _sntprintf(lpchDest, 25, TEXT("{%08X-%04X-%04X-%02X%02X-"),
00618     pguid->Data1, pguid->Data2, pguid->Data3, pguid->Data4[0], pguid->Data4[1]);
00619   lpchDest += 1+8+1+4+1+4+1+2+2+1;
00620
00621   for (int i = 2; i < 8; i++)
00622   {
00623     _sntprintf(lpchDest, 2, TEXT("%02X"), pguid->Data4[i]);
00624     lpchDest += 2;
00625   }
00626
00627   lpchDest[0] = TEXT('}');
00628 }
00629
00630
00631 //****************************************************************************
00632 //
00633 // VOID SzToGuid(LPTSTR lpchSrc, GUID * pguid)
00634 //
00635 //****************************************************************************
00636
00637 VOID SzToGuid(LPTSTR lpchSrc, GUID * pguid)
00638 {
00639   if  (NULL == pguid)
00640     return;
00641
00642   ZeroMemory(pguid, sizeof(GUID));
00643
00644   if ((NULL == lpchSrc) || (NULL == lpchSrc[0]) || (lstrlen(lpchSrc) < sizeof(GUID)*2 + 6))
00645   {
00646     return;
00647   }
00648
00649   if (_T('{') != *lpchSrc++)
00650     return;
00651   lpchSrc = HexToBin(lpchSrc, &pguid->Data1, sizeof(pguid->Data1));
00652   if (_T('-') != *lpchSrc++)
00653     return;
00654   lpchSrc = HexToBin(lpchSrc, &pguid->Data2, sizeof(pguid->Data2));
00655   if (_T('-') != *lpchSrc++)
00656     return;
00657   lpchSrc = HexToBin(lpchSrc, &pguid->Data3, sizeof(pguid->Data3));
00658   if (_T('-') != *lpchSrc++)
00659     return;
00660   lpchSrc = HexToBin(lpchSrc, &pguid->Data4[0], sizeof(BYTE));
00661   lpchSrc = HexToBin(lpchSrc, &pguid->Data4[1], sizeof(BYTE));
00662   if (_T('-') != *lpchSrc++)
00663     return;
00664   HexToData(lpchSrc, &pguid->Data4[2], sizeof(pguid->Data4) - 2*sizeof(BYTE));
00665 }
00666
00667
00668 //****************************************************************************
00669 //
00670 // LPTSTR SzFindLastCh(LPTSTR lpsz, TCHAR ch)
00671 //
00672 // Returns a pointer to the ch within the lpsz or NULL if not found
00673 //
00674 //****************************************************************************
00675
00676 LPTSTR SzFindLastCh(LPTSTR lpsz, TCHAR ch)
00677 {
00678   if  (NULL == lpsz)
00679     return NULL;
00680
00681   LPTSTR  lpchRet = NULL;
00682
00683   for (lpchRet = NULL; *lpsz; lpsz = CharNext(lpsz))
00684   {
00685     if (ch == *lpsz)
00686       lpchRet = lpsz;
00687   }
00688
00689   return lpchRet;
00690 }
00691
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/Grid.h Source File

  • Web
  • Browser
  • EditHost

Grid.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // Grid.h : Declaration of the CGrid
00006
00007 #ifndef __GRID_H_
00008 #define __GRID_H_
00009
00010 #include "resource.h"       // main symbols
00011 #include "mshtml.h"
00012 //#include "objsafe.h"
00013 #include "atlctl.h" // For IObjectSafety
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CGrid
00017 class ATL_NO_VTABLE CGrid :
00018   public CComObjectRootEx<CComSingleThreadModel>,
00019   public CComCoClass<CGrid, &CLSID_Grid>,
00020   public IGrid,
00021   public IElementBehavior,
00022   public IElementBehaviorFactory,
00023   // CODE REVIEW: Add following security comment.
00024   /* The following untrusted use of IObjectSafetyImpl is for simplicity
00025   in this sample code.  This usage in production code can expose a
00026   security risk in some situations. */
00027   public IObjectSafetyImpl<CGrid, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
00028   public IHTMLPainter
00029 {
00030 public:
00031   CGrid() : m_lGridSize(50)
00032   {
00033   }
00034
00035 DECLARE_REGISTRY_RESOURCEID(IDR_GRID)
00036
00037 DECLARE_PROTECT_FINAL_CONSTRUCT()
00038
00039 BEGIN_COM_MAP(CGrid)
00040   COM_INTERFACE_ENTRY(IGrid)
00041   COM_INTERFACE_ENTRY(IElementBehavior)
00042   COM_INTERFACE_ENTRY(IElementBehaviorFactory)
00043   COM_INTERFACE_ENTRY(IObjectSafety)
00044   COM_INTERFACE_ENTRY(IHTMLPainter)
00045 END_COM_MAP()
00046
00047 // IGrid
00048   CComPtr<IElementBehaviorSite> m_spSite;
00049   CComPtr<IHTMLPaintSite>     m_spPaintSite;
00050   long              m_lGridSize;
00051   long              m_lClientTop;
00052   long              m_lClientLeft;
00053
00054 public:
00055   STDMETHOD(get_GridSize)(/*[out, retval]*/ long *pVal);
00056   STDMETHOD(put_GridSize)(/*[in]*/ long newVal);
00057
00058 public:
00059 // IElementBehavior
00060   STDMETHOD(Init)(IElementBehaviorSite * pBehaviorSite);
00061   STDMETHOD(Notify)(LONG lEvent, VARIANT * pVar);
00062   STDMETHOD(Detach)();
00063
00064 // IFactory
00065   STDMETHOD(FindBehavior)(BSTR bstrBehavior, BSTR bstrBehaviorUrl, IElementBehaviorSite* pSite, IElementBehavior** ppBehavior);
00066
00067 // IObjectSafety override
00068   STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions);
00069
00070 // IHTMLPainter
00071   STDMETHOD(Draw)(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject);
00072   STDMETHOD(OnResize)(SIZE size);
00073   STDMETHOD(GetPainterInfo)(HTML_PAINTER_INFO * pInfo);
00074   STDMETHOD(HitTestPoint)(POINT pt, BOOL* pbHit, LONG * plPartID);
00075
00076 // Debug
00077   void Trace(WCHAR* message)
00078   {
00079     MessageBoxW(NULL, message, L"Trace", NULL);
00080   }
00081 };
00082
00083 #endif //__GRID_H_
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/TestDoc.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

TestDoc.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // testDoc.h : interface of the CTestDoc class
00013 //
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016
00017 class CTestDoc : public CDocument
00018 {
00019 protected: // create from serialization only
00020   CTestDoc();
00021   DECLARE_DYNCREATE(CTestDoc)
00022
00023 // Attributes
00024 public:
00025
00026 // Operations
00027 public:
00028
00029 // Overrides
00030   // ClassWizard generated virtual function overrides
00031   //{{AFX_VIRTUAL(CTestDoc)
00032   public:
00033   virtual BOOL OnNewDocument();
00034   virtual void Serialize(CArchive& ar);
00035   //}}AFX_VIRTUAL
00036
00037 // Implementation
00038 public:
00039   virtual ~CTestDoc();
00040 #ifdef _DEBUG
00041   virtual void AssertValid() const;
00042   virtual void Dump(CDumpContext& dc) const;
00043 #endif
00044
00045 protected:
00046
00047 // Generated message map functions
00048 protected:
00049   //{{AFX_MSG(CTestDoc)
00050     // NOTE - the ClassWizard will add and remove member functions here.
00051     //    DO NOT EDIT what you see in these blocks of generated code !
00052   //}}AFX_MSG
00053   DECLARE_MESSAGE_MAP()
00054 };
00055
00056 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/MyToken/MyToken.cpp Source File

  • Security
  • Authorization
  • MyToken

MyToken.cpp

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2002.  Microsoft Corporation.  All rights reserved.
00008 */
00009
00010 /*
00011     Module: MYTOKEN.CPP
00012
00013     When you log on to a Microsoft Windows NT based platform, NT generates
00014     an Access Token that describes who you are, what groups you belong to,
00015     and what privileges you have on that computer.
00016
00017     The following sample code demonstrates how to extract this interesting
00018     information from the current thread/process access token. When I look
00019     at this information I tend to separate it into three categories
00020
00021         1. User identification and miscellaneous info
00022         2. Group information
00023         3. Privileges
00024
00025     Notes about the group information:
00026
00027         1) You will see a group sid with the form NONE_MAPPED. This is
00028         the login SID generated for this particular logon session. It is
00029         unique until the server is rebooted.
00030
00031         2) Many of the group SIDS are well-known SIDs and RIDs. Consult the
00032         documentation for information about these well-known Identifiers.
00033
00034     Notes about the privileges information:
00035
00036         The attributes number is simply a bit flag. 1 indicates that the
00037         privilege is enabled and 2 indicates that the privilege is enabled
00038         by default. 3, of course, indicates that it is enabled by default
00039         and currently enabled.
00040
00041
00042     This code sample requires the following import libraries:
00043
00044         advapi32.lib
00045         user32.lib
00046 */
00047
00048 #define UNICODE
00049 #define _UNICODE
00050 #include <windows.h>
00051 #include <tchar.h>
00052 #include <stdio.h>
00053 #include <strsafe.h> // for proper buffer handling
00054
00055 LPVOID RetrieveTokenInformationClass(
00056             HANDLE hToken,
00057             TOKEN_INFORMATION_CLASS InfoClass,
00058             LPDWORD dwSize);
00059 LPTSTR ConvertBinarySidToName(PSID pSid);
00060 BOOL DisplayUserInfo(HANDLE hToken);
00061 BOOL DisplayOwnerInfo(HANDLE hToken);
00062 BOOL DisplayPrimaryGroupInfo(HANDLE hToken);
00063 BOOL DisplayStatistics(HANDLE hToken);
00064 BOOL DisplaySource(HANDLE hToken);
00065 BOOL DisplayGroupsInfo(HANDLE hToken);
00066 BOOL DisplayPrivileges(HANDLE hToken);
00067 BOOL DisplayTokenInformation(HANDLE hToken);
00068 BOOL DisplayCallerAccessTokenInformation();
00069 void __cdecl MyPrintf(LPCTSTR lpszFormat, ...);
00070
00071 #define CheckAndLocalFree(ptr) \
00072             if (ptr != NULL) \
00073             { \
00074                LocalFree(ptr); \
00075                ptr = NULL; \
00076             }
00077
00078 void __cdecl MyPrintf(LPCTSTR lpszFormat, ...)
00079 {
00080    TCHAR szOutput[2048];
00081    va_list v1 = NULL;
00082    HRESULT hr = S_OK;
00083
00084    va_start(v1, lpszFormat);
00085    hr = StringCbVPrintf(szOutput, sizeof(szOutput), lpszFormat, v1);
00086    if (SUCCEEDED(hr))
00087    {
00088       OutputDebugString(szOutput);
00089       _tprintf(szOutput);
00090    }
00091    else
00092    {
00093       _tprintf(_T("StringCbVPrintf failed with %X\n"), hr);
00094    }
00095 }
00096
00097 LPVOID RetrieveTokenInformationClass(
00098       HANDLE hToken,
00099       TOKEN_INFORMATION_CLASS InfoClass,
00100       LPDWORD lpdwSize)
00101 {
00102    LPVOID pInfo = NULL;
00103    BOOL fSuccess = FALSE;
00104
00105    __try
00106    {
00107       *lpdwSize = 0;
00108
00109       //
00110       // Determine size of buffer needed
00111       //
00112
00113       GetTokenInformation(
00114             hToken,
00115             InfoClass,
00116             NULL,
00117             *lpdwSize, lpdwSize);
00118       if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
00119       {
00120          MyPrintf(_T("GetTokenInformation failed with %d\n"), GetLastError());
00121          __leave;
00122       }
00123
00124       //
00125       // Allocate a buffer for getting token information
00126       //
00127       pInfo = LocalAlloc(LPTR, *lpdwSize);
00128       if (pInfo == NULL)
00129       {
00130          MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00131          __leave;
00132       }
00133
00134       if (!GetTokenInformation(
00135             hToken,
00136             InfoClass,
00137             pInfo,
00138             *lpdwSize, lpdwSize))
00139       {
00140          MyPrintf(_T("GetTokenInformation failed with %d\n"), GetLastError());
00141          __leave;
00142       }
00143
00144       fSuccess = TRUE;
00145    }
00146    __finally
00147    {
00148       // Free pDomainAndUserName only if failed.
00149       // Otherwise, the caller has to free after use
00150       if (fSuccess == FALSE)
00151       {
00152          CheckAndLocalFree(pInfo);
00153       }
00154    }
00155
00156    return pInfo;
00157 }
00158
00159 LPTSTR ConvertBinarySidToName(PSID pSid)
00160 {
00161    LPTSTR pAccountName = NULL;
00162    LPTSTR pDomainName = NULL;
00163    LPTSTR pDomainAndUserName = NULL;
00164    DWORD dwAccountNameSize = 0;
00165    DWORD dwDomainNameSize = 0;
00166    DWORD dwSize = 0;
00167    SID_NAME_USE sidType;
00168    BOOL fSuccess = FALSE;
00169    HRESULT hr = S_OK;
00170
00171    __try
00172    {
00173       LookupAccountSid(
00174             NULL,                      // lookup on local system
00175             pSid,
00176             pAccountName,              // buffer to recieve name
00177             &dwAccountNameSize,
00178             pDomainName,
00179             &dwDomainNameSize,
00180             &sidType);
00181       // If the SID cannot be resolved, LookupAccountSid will fail with
00182       // ERROR_NONE_MAPPED
00183       if (GetLastError() == ERROR_NONE_MAPPED)
00184       {
00185          LPTSTR pNoneMappedString = _T("NONE_MAPPED");
00186
00187          dwAccountNameSize = sizeof(_T("NONE_MAPPED"))/sizeof(TCHAR);
00188          pAccountName = (LPTSTR)LocalAlloc(LPTR, dwAccountNameSize * sizeof(TCHAR));
00189          if (pAccountName == NULL)
00190          {
00191             MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00192             __leave;
00193          }
00194          hr = StringCchCopy(pAccountName, dwAccountNameSize, pNoneMappedString);
00195          if (FAILED(hr))
00196          {
00197             _tprintf(_T("StringCchCopy failed with %X\n"), hr);
00198             __leave;
00199          }
00200
00201          dwDomainNameSize = 0;
00202          pDomainName = NULL;
00203       }
00204       else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
00205       {
00206          pAccountName = (LPTSTR)LocalAlloc(LPTR, dwAccountNameSize * sizeof(TCHAR));
00207          if (pAccountName == NULL)
00208          {
00209             MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00210             __leave;
00211          }
00212
00213          pDomainName = (LPTSTR)LocalAlloc(LPTR, dwDomainNameSize * sizeof(TCHAR));
00214          if (pDomainName == NULL)
00215          {
00216             MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00217             __leave;
00218          }
00219
00220          if (!LookupAccountSid(
00221                NULL,                      // lookup on local system
00222                pSid,
00223                pAccountName,              // buffer to recieve name
00224                &dwAccountNameSize,
00225                pDomainName,
00226                &dwDomainNameSize,
00227                &sidType))
00228          {
00229             MyPrintf(_T("LookupAccountSid failed with %d\n"), GetLastError());
00230             __leave;
00231          }
00232       }
00233       // Any other error code
00234       else
00235       {
00236          MyPrintf(_T("LookupAccountSid failed with %d\n"), GetLastError());
00237          __leave;
00238       }
00239
00240       dwSize = dwDomainNameSize +
00241                   1 /* For \\ character */ +
00242                   dwAccountNameSize +
00243                   1 /* For NULL character */;
00244
00245       pDomainAndUserName = (LPTSTR)LocalAlloc(LPTR, dwSize * sizeof(TCHAR));
00246       if (pDomainAndUserName == NULL)
00247       {
00248          MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00249          __leave;
00250       }
00251
00252       pDomainAndUserName[0] = 0;
00253       if (dwDomainNameSize != 0)
00254       {
00255          hr = StringCchCopy(pDomainAndUserName, dwSize, pDomainName);
00256          if (FAILED(hr))
00257          {
00258             _tprintf(_T("StringCchCopy failed with %X\n"), hr);
00259             __leave;
00260          }
00261          hr = StringCchCat(pDomainAndUserName, dwSize, _T("\\"));
00262          if (FAILED(hr))
00263          {
00264             _tprintf(_T("StringCchCat failed with %X\n"), hr);
00265             __leave;
00266          }
00267       }
00268       if (dwAccountNameSize != 0)
00269       {
00270          hr = StringCchCat(pDomainAndUserName, dwSize, pAccountName);
00271          if (FAILED(hr))
00272          {
00273             _tprintf(_T("StringCchCat failed with %X\n"), hr);
00274             __leave;
00275          }
00276       }
00277
00278       fSuccess = TRUE;
00279    }
00280    __finally
00281    {
00282       CheckAndLocalFree(pAccountName);
00283       CheckAndLocalFree(pDomainName);
00284       // Free pDomainAndUserName only if failed.
00285       // Otherwise, the caller has to free after use
00286       if (fSuccess == FALSE)
00287       {
00288          CheckAndLocalFree(pDomainAndUserName);
00289       }
00290    }
00291
00292    return pDomainAndUserName;
00293 }
00294
00295 LPTSTR ConvertLUIDToName(PLUID pLuid)
00296 {
00297    LPTSTR pPrivilegeName = NULL;
00298    DWORD dwSize = 0;
00299    BOOL fSuccess = FALSE;
00300
00301    __try
00302    {
00303       LookupPrivilegeName(
00304             NULL,                      // lookup on local system
00305             pLuid,
00306             pPrivilegeName,            // buffer to recieve name
00307             &dwSize);
00308       // Check for ERROR_INSUFFICIENT_BUFFER error code
00309       if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
00310       {
00311          MyPrintf(_T("LookupPrivilegeName failed with %d\n"), GetLastError());
00312          __leave;
00313       }
00314
00315       pPrivilegeName = (LPTSTR)LocalAlloc(LPTR, dwSize * sizeof(TCHAR));
00316       if (pPrivilegeName == NULL)
00317       {
00318          MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00319          __leave;
00320       }
00321
00322       if (!LookupPrivilegeName(
00323             NULL,                      // lookup on local system
00324             pLuid,
00325             pPrivilegeName,            // buffer to recieve name
00326             &dwSize))
00327       {
00328          MyPrintf(_T("LookupPrivilegeName failed with %d\n"), GetLastError());
00329          __leave;
00330       }
00331
00332       fSuccess = TRUE;
00333    }
00334    __finally
00335    {
00336       // Free pPrivilegeName only if failed.
00337       // Otherwise, the caller has to free after use
00338       if (fSuccess == FALSE)
00339       {
00340          CheckAndLocalFree(pPrivilegeName);
00341       }
00342    }
00343
00344    return pPrivilegeName;
00345 }
00346
00347 BOOL DisplayUserInfo(HANDLE hToken)
00348 {
00349    TOKEN_USER *pUserInfo = NULL;
00350    DWORD dwSize = 0;
00351    LPTSTR pName = NULL;
00352
00353    //
00354    // Get User Information
00355    //
00356
00357    pUserInfo = (TOKEN_USER *)RetrieveTokenInformationClass(hToken, TokenUser, &dwSize);
00358    if (pUserInfo == NULL)
00359    {
00360       return FALSE;
00361    }
00362
00363    pName = ConvertBinarySidToName(pUserInfo->User.Sid);
00364    if (pName == NULL)
00365    {
00366       return FALSE;
00367    }
00368
00369    MyPrintf(_T("User : %s\n"), pName);
00370
00371    CheckAndLocalFree(pUserInfo);
00372    CheckAndLocalFree(pName);
00373    return TRUE;
00374 }
00375
00376 BOOL DisplayOwnerInfo(HANDLE hToken)
00377 {
00378    TOKEN_OWNER *pOwnerInfo = NULL;
00379    DWORD dwSize = 0;
00380    LPTSTR pName = NULL;
00381
00382    //
00383    // Get Owner Information
00384    //
00385
00386    pOwnerInfo = (TOKEN_OWNER *)RetrieveTokenInformationClass(hToken, TokenOwner, &dwSize);
00387    if (pOwnerInfo == NULL)
00388    {
00389       return FALSE;
00390    }
00391
00392    pName = ConvertBinarySidToName(pOwnerInfo->Owner);
00393    if (pName == NULL)
00394    {
00395       return FALSE;
00396    }
00397
00398    MyPrintf(_T("Owner : %s\n"), pName);
00399
00400    CheckAndLocalFree(pOwnerInfo);
00401    CheckAndLocalFree(pName);
00402    return TRUE;
00403 }
00404
00405 BOOL DisplayPrimaryGroupInfo(HANDLE hToken)
00406 {
00407    TOKEN_PRIMARY_GROUP *pPrimaryGroupInfo = NULL;
00408    DWORD dwSize = 0;
00409    LPTSTR pName = NULL;
00410
00411    //
00412    // Get Primary Group Information
00413    //
00414
00415    pPrimaryGroupInfo = (TOKEN_PRIMARY_GROUP *)RetrieveTokenInformationClass(hToken, TokenPrimaryGroup, &dwSize);
00416    if (pPrimaryGroupInfo == NULL)
00417    {
00418       return FALSE;
00419    }
00420
00421    pName = ConvertBinarySidToName(pPrimaryGroupInfo->PrimaryGroup);
00422    if (pName == NULL)
00423    {
00424       return FALSE;
00425    }
00426
00427    MyPrintf(_T("Primary Group : %s\n"), pName);
00428
00429    CheckAndLocalFree(pPrimaryGroupInfo);
00430    CheckAndLocalFree(pName);
00431    return TRUE;
00432 }
00433
00434 BOOL DisplayStatistics(HANDLE hToken)
00435 {
00436    TOKEN_STATISTICS *pStatistics = NULL;
00437    DWORD dwSize = 0;
00438
00439    //
00440    // Get Token Statistics Information
00441    //
00442
00443    pStatistics = (TOKEN_STATISTICS *)RetrieveTokenInformationClass(hToken, TokenStatistics, &dwSize);
00444    if (pStatistics == NULL)
00445    {
00446       return FALSE;
00447    }
00448
00449    //
00450    // Display some of the token statistics information
00451    //
00452
00453    MyPrintf(_T("LUID for this instance of token %i64\n"), pStatistics->TokenId);
00454    MyPrintf(_T("LUID for this logon session     %i64\n"), pStatistics->AuthenticationId);
00455
00456    if (pStatistics->TokenType == TokenPrimary)
00457       MyPrintf(_T("Token type is PRIMARY\n"));
00458    else
00459       MyPrintf(_T("Token type is IMPERSONATION\n"));
00460
00461    CheckAndLocalFree(pStatistics);
00462    return TRUE;
00463 }
00464
00465 BOOL DisplaySource(HANDLE hToken)
00466 {
00467    TOKEN_SOURCE *pSource = NULL;
00468    DWORD dwSize = 0;
00469    DWORD i = 0;
00470
00471    //
00472    // Display source of access token
00473    //
00474
00475    pSource = (TOKEN_SOURCE *)RetrieveTokenInformationClass(hToken, TokenSource, &dwSize);
00476    if (pSource == NULL)
00477    {
00478       return FALSE;
00479    }
00480
00481    MyPrintf(_T("Token source is <"));
00482    for (i = 0; i < TOKEN_SOURCE_LENGTH; i++)
00483    {
00484       MyPrintf(_T("%c"), pSource->SourceName[i]);
00485    }
00486    MyPrintf(_T(">\n"));
00487
00488    CheckAndLocalFree(pSource);
00489    return TRUE;
00490 }
00491
00492 BOOL DisplayGroupsInfo(HANDLE hToken)
00493 {
00494    TOKEN_GROUPS *pGroupInfo = NULL;
00495    DWORD dwSize = 0;
00496    DWORD i;
00497
00498    //
00499    //  List all groups in the access token
00500    //
00501
00502    pGroupInfo = (PTOKEN_GROUPS)RetrieveTokenInformationClass(hToken, TokenGroups, &dwSize);
00503    if (pGroupInfo == NULL)
00504    {
00505       return FALSE;
00506    }
00507
00508    MyPrintf(_T("\nRetrieving Group information from the access token\n"));
00509    for (i = 0; i < pGroupInfo->GroupCount; i++)
00510    {
00511       LPTSTR pName = NULL;
00512
00513       pName = ConvertBinarySidToName(pGroupInfo->Groups[i].Sid);
00514       if (pName != NULL)
00515       {
00516          MyPrintf(_T("SID %d Group: %s\n"), i, pName);
00517          CheckAndLocalFree(pName);
00518       }
00519    }
00520
00521    CheckAndLocalFree(pGroupInfo);
00522    return TRUE;
00523 }
00524
00525 BOOL DisplayPrivileges(HANDLE hToken)
00526 {
00527    TOKEN_PRIVILEGES *pPrivileges = NULL;
00528    DWORD dwSize = 0;
00529    DWORD i;
00530
00531    //
00532    // Display privileges associated with this access token
00533    //
00534
00535    pPrivileges = (TOKEN_PRIVILEGES *)RetrieveTokenInformationClass(hToken, TokenPrivileges, &dwSize);
00536    if (pPrivileges == NULL)
00537    {
00538       return FALSE;
00539    }
00540
00541    MyPrintf(_T("\nPrivileges associated with this token (%lu)\n"), pPrivileges->PrivilegeCount);
00542    for (i = 0; i < pPrivileges->PrivilegeCount; i++)
00543    {
00544       LPTSTR pPrivilegeName = NULL;
00545
00546       pPrivilegeName = ConvertLUIDToName(&(pPrivileges->Privileges[i].Luid));
00547       if (pPrivilegeName != NULL)
00548       {
00549          MyPrintf(_T("%s - (attributes) %lu\n"), pPrivilegeName, pPrivileges->Privileges[i].Attributes);
00550          CheckAndLocalFree(pPrivilegeName);
00551       }
00552    }
00553
00554    CheckAndLocalFree(pPrivileges);
00555    return TRUE;
00556 }
00557
00558 BOOL DisplayTokenInformation(HANDLE hToken)
00559 {
00560    //
00561    // Display access token information
00562    //
00563
00564    if (!DisplayUserInfo(hToken))
00565    {
00566       return FALSE;
00567    }
00568    if (!DisplayOwnerInfo(hToken))
00569    {
00570       return FALSE;
00571    }
00572    if (!DisplayPrimaryGroupInfo(hToken))
00573    {
00574       return FALSE;
00575    }
00576    if (!DisplayStatistics(hToken))
00577    {
00578       return FALSE;
00579    }
00580    if (!DisplaySource(hToken))
00581    {
00582       return FALSE;
00583    }
00584    if (!DisplayGroupsInfo(hToken))
00585    {
00586       return FALSE;
00587    }
00588    if (!DisplayPrivileges(hToken))
00589    {
00590       return FALSE;
00591    }
00592
00593    return TRUE;
00594 }
00595
00596 BOOL DisplayCallerAccessTokenInformation()
00597 {
00598    HANDLE hToken = NULL;
00599    BOOL bResult = FALSE;
00600
00601    // Use OpenThreadToken() API first, to determine
00602    // if the calling thread is running under impersonation
00603    bResult = OpenThreadToken(GetCurrentThread(),
00604       TOKEN_QUERY | TOKEN_QUERY_SOURCE, TRUE, &hToken);
00605    if (bResult == FALSE && GetLastError() == ERROR_NO_TOKEN)
00606    {
00607       // Otherwise, use process access token
00608       bResult = OpenProcessToken(GetCurrentProcess(),
00609          TOKEN_QUERY | TOKEN_QUERY_SOURCE, &hToken);
00610    }
00611    if (bResult)
00612    {
00613       bResult = DisplayTokenInformation(hToken);
00614       CloseHandle(hToken);
00615    }
00616    else
00617       MyPrintf(_T("OpenThread/ProcessToken failed with %d\n"), GetLastError());
00618
00619    return bResult;
00620 }
00621
00622 void _tmain(int argc, TCHAR **argv)
00623 {
00624    DisplayCallerAccessTokenInformation();
00625 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHtmlIFilterBase Member List

This is the complete list of members for CHtmlIFilterBase, including all inherited members.
_uRefs | CHtmlIFilterBase | [protected]
AddRef() | CHtmlIFilterBase | [virtual]
BindRegion(FILTERREGION origPos, REFIID riid, void **ppunk)=0 | CHtmlIFilterBase | [pure virtual]
CHtmlIFilterBase() | CHtmlIFilterBase | [protected]
GetChunk(STAT_CHUNK *pStat)=0 | CHtmlIFilterBase | [pure virtual]
GetClassID(CLSID *pClassID)=0 | CHtmlIFilterBase | [pure virtual]
GetCurFile(LPWSTR *ppszFileName)=0 | CHtmlIFilterBase | [pure virtual]
GetText(ULONG *pcwcBuffer, WCHAR *awcBuffer)=0 | CHtmlIFilterBase | [pure virtual]
GetValue(PROPVARIANT **ppPropValue)=0 | CHtmlIFilterBase | [pure virtual]
Init(ULONG grfFlags, ULONG cAttributes, FULLPROPSPEC const *aAttributes, ULONG *pFlags)=0 | CHtmlIFilterBase | [pure virtual]
IsDirty()=0 | CHtmlIFilterBase | [pure virtual]
Load(LPCWSTR pszFileName, DWORD dwMode)=0 | CHtmlIFilterBase | [pure virtual]
QueryInterface(REFIID riid, void **ppvObject) | CHtmlIFilterBase | [virtual]
Release() | CHtmlIFilterBase | [virtual]
Save(LPCWSTR pszFileName, BOOL fRemember)=0 | CHtmlIFilterBase | [pure virtual]
SaveCompleted(LPCWSTR pszFileName)=0 | CHtmlIFilterBase | [pure virtual]
~CHtmlIFilterBase() | CHtmlIFilterBase | [protected, virtual]
Generated on Wed Nov 13 2024 16:56:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/BookmarkEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

BookmarkEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: BookmarkEnum
00019
00020 public class BookmarkEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adBookmarkCurrent = 0;
00023   public static final short adBookmarkFirst = 1;
00024   public static final short adBookmarkLast = 2;
00025 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/Cset.Cxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

Cset.Cxx

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <windowsx.h>
00003 #include <string.h>
00004 #include "app.h"
00005
00006 #include "cset.hxx"
00007
00008 //+--------------------------------------------------------
00009 // Class:       CSet
00010 //
00011 // Purpose:     Set of characters
00012 //
00013 // History:     03-Aug-1994     asmusf  created
00014 //----------------------------------------------------------
00015
00016 // pure inline
00017
00018 //+--------------------------------------------------------
00019 // Class:       CCTypesSet
00020 //
00021 // Purpose:     Set of chars defined by common CType
00022 //
00023 // History:     03-Aug-1994     asmusf  created
00024 //----------------------------------------------------------
00025
00026 CCTypeSet :: CCTypeSet(WORD fC1Mask, WORD fC2Test, WORD fC3Mask)
00027 {
00028   _fC1Mask = fC1Mask;
00029   _fC2Test = fC2Test;
00030   _fC3Mask = fC3Mask;
00031   GetPageData( 0 );  // Page 0 is ALWAYS the default
00032 }
00033
00034 CCTypeSet :: In(WORD iChar)
00035 {
00036   WORD iPage = iChar & 0xFF00;
00037   if( iPage != _iPage )
00038   {
00039     GetPageData(iPage);
00040   }
00041   return _pCharInSet[iChar &0xFF];
00042 }
00043
00044
00045 void CCTypeSet :: GetPageData(WORD iPage)
00046 {
00047   WORD i;
00048   TCHAR vchTemp[256];
00049   WORD vCtype[256];
00050
00051   for ( i=0; i < 256; i++ )
00052   {
00053     vchTemp[i] = iPage+i;
00054     _pCharInSet[i] = FALSE;
00055   }
00056   if( _fC1Mask )
00057   {
00058     GetStringTypeEx(0,CT_CTYPE1,vchTemp,256, vCtype);
00059     for( i=0; i<256;i++ ){
00060       _pCharInSet[i] = _pCharInSet[i] || (vCtype[i] & _fC1Mask);
00061     }
00062   }
00063   if( _fC2Test )
00064   {
00065     GetStringTypeEx(0,CT_CTYPE2,vchTemp,256, vCtype);
00066     for( i=0; i<256;i++ ){
00067       _pCharInSet[i] = _pCharInSet[i] || (vCtype[i] == _fC2Test);  //enumerated value
00068     }
00069   }
00070   if( _fC3Mask )
00071   {
00072     GetStringTypeEx(0,CT_CTYPE3,vchTemp,256, vCtype);
00073     for( i=0; i<256;i++ ){
00074       _pCharInSet[i] = _pCharInSet[i] || (vCtype[i] & _fC3Mask);
00075     }
00076   }
00077   _iPage = iPage;
00078 }
00079
00080
00081
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/networking/ftpjr/FTPJr.cpp Source File

  • Web
  • networking
  • ftpjr

FTPJr.cpp

Go to the documentation of this file.
00001
00002 //=--------------------------------------------------------------------------=
00003 //  (C) Copyright 1996-2000 Microsoft Corporation. All Rights Reserved.
00004 //=--------------------------------------------------------------------------=
00005 //////////////////////////////////////////////////////////
00006 //
00007 //         FTP Jr  -- A Poor Man's FTP Client
00008 //         Sample WinInet Application to demonstrate
00009 //         The FTP APIs
00010 //         Microsoft Corporation (C)
00011 //
00012 //////////////////////////////////////////////////////////
00013
00014 #define STRSAFE_WITH_GETS
00015 #include <iostream.h>
00016 #include <windows.h>
00017 #include <direct.h>
00018 #include <wininet.h>
00019 #include <strsafe.h>
00020
00021 #define PROMPT  "FTP Jr>"
00022
00023 BOOL ParseCommand(char *, char *, char *);
00024 BOOL Open (CHAR *);
00025 BOOL Close ();
00026 BOOL ErrorOut ( DWORD, CHAR *);
00027 void FtpEnumDirectory ();
00028 void lcd (char *);
00029 void rcd (char *);
00030 void type (char *);
00031 void DisplayHelp();
00032 void ShowUsage();
00033
00034 char arg1[256], arg2[256], arg3[256];
00035 char szProxy[256] = "";
00036 char szServer[256] = "";
00037 char szCmdLine[256] = "";
00038 HINTERNET hOpen, hConnect;
00039 BOOL bActiveSession = FALSE;
00040 DWORD dwType = FTP_TRANSFER_TYPE_BINARY;
00041
00042 void main(int argc, char *argv[])
00043 {
00044
00045   // Display our banner
00046   cout << "FTP Jr. WinInet FTP Sample Application" << endl;
00047   cout << "Microsoft Corporation" << endl << endl;
00048
00049   // Do they want the display syntax?
00050   if ((lstrcmp(argv[1], "/?") == 0) ||
00051         (lstrcmp(argv[1], "?") == 0) ||
00052     (lstrcmp(argv[1], "-?") == 0) ||
00053     (lstrcmp(argv[1], "help") == 0) ||
00054         (lstrcmp(argv[1], "/help") == 0) ||
00055     (lstrcmp(argv[1], "/HELP") == 0) ||
00056     (lstrcmp(argv[1], "HELP") == 0))
00057   {
00058     ShowUsage();
00059     return;
00060   }
00061
00062   switch (argc)
00063   {
00064   case 2:
00065     // Specified proxy, Open WININET.DLL w/ Proxy
00066     StringCchCopy(szProxy, 256, argv[1]);
00067         if ( !(hOpen = InternetOpen ( "FTP Jr (C)",  CERN_PROXY_INTERNET_ACCESS, szProxy, NULL, 0) ) )
00068         {
00069             ErrorOut ( GetLastError(), "InternetOpen");
00070            return ;
00071         }
00072         break;
00073     case 1:
00074     // No proxy specified.  Open WININET.DLL w/ local access
00075         if ( !(hOpen = InternetOpen ( "FTP Jr (C)",  LOCAL_INTERNET_ACCESS , NULL, 0, 0) ) )
00076         {
00077             ErrorOut ( GetLastError(), "InternetOpen");
00078             return ;
00079         }
00080         break;
00081     default:
00082     ShowUsage();
00083     return;
00084   }
00085
00086   printf("%10s", PROMPT);
00087 //  cout << "FTPJr"<<endl;
00088
00089   // Parse commands 1 line at a time
00090   while(TRUE)
00091   {
00092     char *pszArg1, *pszArg2, *pszArg3, *pszTemp;
00093
00094     // Read line
00095     HRESULT hr = StringCchGets(szCmdLine, 256);
00096     pszArg1 = szCmdLine;
00097
00098     //Remove white space before 1st arg
00099     while((*pszArg1 != 0) &&
00100         (*pszArg1 == ' ')) pszArg1++;
00101
00102     pszArg2 = pszArg1;
00103
00104     //Find end of 1st arg and zero terminate
00105     while ((*pszArg2 != 0) &&
00106          (*pszArg2 != ' ')) pszArg2++;
00107
00108     if (*pszArg2 != 0) *pszArg2++ = 0;
00109
00110     //Remove white space before 2nd arg
00111     while ((*pszArg2 !=0) &&
00112          (*pszArg2 == ' ')) pszArg2++;
00113
00114     pszArg3 = pszArg2;
00115
00116     //Find end of 2nd arg and zero terminate
00117     while ((*pszArg3 != 0) &&
00118          (*pszArg3 != ' ')) pszArg3++;
00119
00120     if (*pszArg3 != 0) *pszArg3++ = 0;
00121
00122     //Remove white space before 3rd Arg
00123     while ((*pszArg3 !=0) &&
00124          (*pszArg3 == ' ')) pszArg3++;
00125
00126     pszTemp = pszArg3;
00127
00128     //Find end of 3rd arg and zero terminate
00129     while((*pszTemp != 0) &&
00130         (*pszTemp != ' ')) pszTemp++;
00131
00132     if (*pszTemp != 0) *pszTemp = 0;
00133
00134     //Loop indefintely until ParseCommand returns false
00135     if (ParseCommand(pszArg1, pszArg2, pszArg3) == FALSE)
00136       return;
00137
00138   }
00139 }
00140
00141 ///////////////////////////////////////////////////////////
00142 //
00143 //      ParseCommand Function
00144 //
00145 //      Input:   FTP command arguments
00146 //      Returns: TRUE if any command called but quit
00147 //               FALSE if command is quit
00148 //
00149 //////////////////////////////////////////////////////////
00150 BOOL ParseCommand(char *pszArg1, char *pszArg2, char *pszArg3)
00151 {
00152   _strupr(pszArg1);
00153     CHAR szFile1[256] ="", szFile2[256] ="";
00154
00155   // Quit Command
00156   if (lstrcmp(pszArg1, "QUIT") == 0)
00157     return FALSE;
00158
00159   // Get Command
00160   else if (lstrcmp(pszArg1, "GET") == 0)
00161   {
00162       if (bActiveSession)
00163         {
00164       cout << "Enter Remote Filename: ";
00165       StringCchGetsA(szFile1, 256);
00166       cout << "Enter Local Filename: ";
00167       StringCchGetsA(szFile2, 256);
00168             if (!FtpGetFile (hConnect, szFile1, szFile2, FALSE, 0, INTERNET_FLAG_RELOAD | dwType, 0 ) )
00169                 ErrorOut (GetLastError(), "FtpGetFile");
00170         }
00171         else
00172             cout << "No active session" ;
00173         cout << endl << PROMPT;
00174   }
00175
00176   // Put Command
00177   else if (lstrcmp(pszArg1, "PUT") == 0)
00178   {
00179       if (bActiveSession)
00180         {
00181       cout << "Enter Remote Filename: ";
00182       StringCchGetsA(szFile1, 256);
00183       cout << "Enter Local Filename: ";
00184       StringCchGetsA(szFile2, 256);
00185             if (!FtpPutFile (hConnect,szFile1, szFile2, dwType, 0 ) )
00186                 ErrorOut (GetLastError(), "FtpPutFile");
00187         }
00188         else
00189             cout << "No active session" ;
00190         cout << endl << PROMPT;
00191   }
00192
00193   // Del Command
00194   else if (lstrcmp(pszArg1, "DEL") == 0)
00195   {
00196       if (bActiveSession)
00197         {
00198       cout << "Enter Remote Filename: ";
00199       StringCchGetsA(szFile1, 256);
00200             if (!FtpDeleteFile (hConnect,szFile1 ) )
00201                 ErrorOut (GetLastError(), "FtpDelFile");
00202         }
00203         else
00204             cout << "No active session" ;
00205         cout << endl << PROMPT;
00206   }
00207
00208   // Ren Command
00209   else if (lstrcmp(pszArg1, "REN") == 0)
00210   {
00211       if (bActiveSession)
00212         {
00213       cout << "Enter Existing Filename: ";
00214       StringCchGetsA(szFile1, 256);
00215       cout << "Enter New Filename: ";
00216       StringCchGetsA(szFile2, 256);
00217             if (!FtpRenameFile (hConnect,szFile1, szFile2 ) )
00218                 ErrorOut (GetLastError(), "FtpRenameFile");
00219         }
00220         else
00221             cout << "No active session" ;
00222         cout << endl << PROMPT;
00223
00224   }
00225
00226   // ls command
00227   else if (lstrcmp(pszArg1, "LS") == 0)
00228   {
00229       if (bActiveSession)
00230             FtpEnumDirectory();
00231         else
00232             cout << "No active session" ;
00233         cout << endl << PROMPT;
00234   }
00235
00236   // md command
00237   else if (lstrcmp(pszArg1, "MD") == 0)
00238   {
00239       if (bActiveSession)
00240         {
00241       cout << "Enter Directory: ";
00242       StringCchGetsA(szFile1, 256);
00243             if (!FtpCreateDirectory (hConnect,szFile1 ) )
00244                 ErrorOut (GetLastError(), "FtpCreateDirectory");
00245         }
00246         else
00247             cout << "No active session" ;
00248         cout << endl << PROMPT;
00249   }
00250
00251   // rd command
00252   else if (lstrcmp(pszArg1, "RD") == 0)
00253   {
00254       if (bActiveSession)
00255         {
00256       cout << "Enter Directory: ";
00257       StringCchGetsA(szFile1, 256);
00258             if (!FtpRemoveDirectory (hConnect,szFile1 ) )
00259                 ErrorOut (GetLastError(), "FtpRemoveDirectory");
00260         }
00261         else
00262             cout << "No active session" ;
00263         cout << endl << PROMPT;
00264   }
00265
00266   // type command
00267   else if (lstrcmp(pszArg1, "TYPE") == 0)
00268   {
00269         if (bActiveSession)
00270             type (pszArg2);
00271         else
00272             cout << "No active session" << endl << PROMPT;
00273   }
00274
00275   // cd command
00276   else if (lstrcmp(pszArg1, "CD") == 0)
00277   {
00278         if (bActiveSession)
00279             rcd (pszArg2);
00280         else
00281             cout << "No active session" << endl << PROMPT;
00282   }
00283
00284   // lcd command
00285   else if (lstrcmp(pszArg1, "LCD") == 0)
00286   {
00287     lcd(pszArg2);
00288   }
00289
00290   // open command
00291   else if (lstrcmp(pszArg1, "OPEN") == 0)
00292   {
00293         if (!bActiveSession)
00294         {
00295           if (Open (pszArg2))
00296                 cout << "Connected to " << pszArg2 << endl << PROMPT;
00297             else
00298                 cout << "Session closed" << endl << PROMPT;
00299         }
00300         else
00301             cout << "Already connected to " << szServer << endl << PROMPT;
00302
00303   }
00304
00305   // close command
00306   else if (lstrcmp(pszArg1, "CLOSE") == 0)
00307   {
00308         if (bActiveSession)
00309         {
00310           Close();
00311             cout << "Session closed" << endl << PROMPT;
00312         }
00313         else
00314             cout << "No active session" << endl << PROMPT;
00315   }
00316
00317   // help command
00318   else if (lstrcmp(pszArg1, "HELP") == 0)
00319   {
00320     DisplayHelp();
00321   }
00322
00323   // error Unknown command
00324   else
00325   {
00326     cout << "?Unknown Command" << endl << PROMPT;
00327   }
00328   return TRUE;
00329 }
00330
00331 void DisplayHelp()
00332 {
00333   cout << "Commands are:" << endl;
00334   cout << "   cd" << endl;
00335   cout << "   close" << endl;
00336   cout << "   del" << endl;
00337   cout << "   get" << endl;
00338   cout << "   help" << endl;
00339   cout << "   lcd" << endl;
00340   cout << "   ls" << endl;
00341   cout << "   md" << endl;
00342   cout << "   open" << endl;
00343   cout << "   put" << endl;
00344   cout << "   quit" << endl;
00345   cout << "   rd" << endl;
00346   cout << "   ren" << endl;
00347   cout << "   type" << endl;
00348     ShowUsage ();
00349   cout << endl << PROMPT;
00350 }
00351
00352 void lcd(char *pszDir)
00353 {
00354   if ((*pszDir != 0) && (_chdir(pszDir) == -1))
00355     cout << "?Invalid Local Directory" << endl << PROMPT;
00356   else
00357   {
00358     char dir[256];
00359     GetCurrentDirectory(256, dir);
00360     cout << "Local Directory is " << dir << endl << PROMPT;
00361   }
00362 }
00363
00364 void rcd(char *pszDir)
00365 {
00366     char dir[256];
00367   if (*pszDir != 0)
00368     {
00369     if (!FtpSetCurrentDirectory (hConnect, pszDir))
00370         {
00371             ErrorOut (GetLastError(), "FtpSetCurrentDirectory");
00372             cout <<  PROMPT;
00373         }
00374         else
00375         cout << "Remote Directory is " << pszDir << endl << PROMPT;
00376     }
00377   else
00378   {
00379         DWORD dwSize = sizeof(dir);
00380     if (!FtpGetCurrentDirectory (hConnect, dir, &dwSize))
00381             cout << "Can not determine current remote directory " << endl << PROMPT;
00382         else
00383         cout << "Remote Directory is " << dir << endl << PROMPT;
00384   }
00385 }
00386
00387 void type (char *szType)
00388 {
00389
00390   _strupr(szType);
00391   if (*szType != 0)
00392     {
00393       if (lstrcmp(szType, "BIN") == 0)
00394         {
00395         dwType = FTP_TRANSFER_TYPE_BINARY;
00396             cout << "BIN mode selected";
00397         }
00398       else if (lstrcmp(szType, "ASCII") == 0)
00399         {
00400         dwType = FTP_TRANSFER_TYPE_ASCII;
00401             cout << "ASCII mode selected";
00402         }
00403         else
00404             cout << "Invalid mode";
00405         cout << endl << PROMPT;
00406     }
00407   else
00408   {
00409     if ( dwType == FTP_TRANSFER_TYPE_BINARY)
00410             cout << "BIN ";
00411         else
00412         cout << "ASCII ";
00413         cout << "mode selected " << endl << PROMPT;
00414   }
00415 }
00416
00417
00418 void ShowUsage()
00419 {
00420   cout << "Syntax:" << endl << "  FTPJR <proxy>" << endl ;
00421     cout << "Note: a CERN style proxy will not work. You will need to "<< endl;
00422     cout << "specify a TIS style FTP proxy in the form:" << endl << endl;
00423   cout << "     FTPJR ftp-gw" << endl << endl;
00424   cout << "where ftp-gw is the name of the host that is running the gateway" << endl;
00425 }
00426
00427 BOOL Open (CHAR * szHost)
00428 {
00429     CHAR szUser[256], szPass[256];
00430     if ( *szHost == 0)
00431     {
00432     cout << "Enter Host: ";
00433     StringCchGetsA(szHost, 256);
00434     cout << "Enter Username: ";
00435     StringCchGetsA(szUser, 256);
00436     cout << "Enter Password: ";
00437     StringCchGetsA(szPass, 256);
00438     }
00439     else
00440     {
00441     cout << "Enter Username: ";
00442     StringCchGetsA(szUser, 256);
00443     cout << "Enter Password: ";
00444     StringCchGetsA(szPass, 256);
00445     }
00446     if ( !(hConnect = InternetConnect ( hOpen, szHost , INTERNET_INVALID_PORT_NUMBER, szUser,  szPass, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE , 0) ) )
00447     {
00448       ErrorOut (GetLastError(), "InternetConnect");
00449         return FALSE;
00450     }
00451     bActiveSession = TRUE;
00452   HRESULT hr = StringCchCopyA(szServer, 256, szHost);
00453     return TRUE;
00454 }
00455
00456 BOOL Close ()
00457 {
00458     if (!InternetCloseHandle (hConnect) )
00459     {
00460         ErrorOut (GetLastError(), "InternetCloseHandle");
00461         return FALSE;
00462     }
00463     bActiveSession = FALSE;
00464     return TRUE;
00465 }
00466
00467 void FtpEnumDirectory ()
00468 {
00469   WIN32_FIND_DATA pData;
00470   HINTERNET hFind;
00471   DWORD dError;
00472
00473   // Start enumeration and get file handle
00474   if ( !(hFind = FtpFindFirstFile (hConnect, TEXT ("*.*"), &pData, 0, 0) ))
00475     if (GetLastError()  == ERROR_NO_MORE_FILES)
00476     {
00477       cout << "This directory is empty" << endl;
00478       return ;
00479     }
00480     else
00481     {
00482       ErrorOut (GetLastError (), "FindFirst error: ");
00483       return ;
00484     }
00485
00486   cout << pData.cFileName;
00487   if (pData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
00488     // Entry is a directory, mark it as such
00489     cout << " <DIR> " << endl;
00490   else
00491     cout << endl;
00492
00493   dError = NO_ERROR;
00494   do
00495   {
00496      if (!InternetFindNextFile (hFind, &pData))
00497      {
00498        dError = GetLastError();
00499        if ( dError == ERROR_NO_MORE_FILES )
00500         break;
00501        else
00502        {
00503          ErrorOut (dError, "InternetFindNextFile");
00504          return ;
00505        }
00506      }
00507      else
00508      {
00509         cout << pData.cFileName;
00510         if (pData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
00511           cout << " <DIR> " << endl;
00512         else
00513           cout << endl;
00514        }
00515   }
00516   while ( TRUE);
00517   if (!InternetCloseHandle (hFind) )
00518   {
00519     ErrorOut (GetLastError(), "InternetCloseHandle error");
00520     return ;
00521   }
00522   return ;
00523 }
00524
00525
00526 /****************************************************************************
00527 *
00528 *    FUNCTION: ErrorOut
00529 *
00530 *    PURPOSE: This function is used to get extended Internet error.
00531 *
00532 *    COMMENTS:  Function returns TRUE on success and FALSE on failure.
00533 *
00534 ****************************************************************************/
00535
00536 BOOL ErrorOut ( DWORD dError, TCHAR * szCallFunc)
00537 {
00538     TCHAR szTemp[100] = "", *szBuffer=NULL, *szBufferFinal = NULL;
00539     DWORD  dwIntError , dwLength = 0;
00540   HRESULT hr = StringCchPrintf(szTemp, 100, "%s error %d\n", szCallFunc, dError );
00541   if (dError == ERROR_INTERNET_EXTENDED_ERROR)
00542   {
00543     InternetGetLastResponseInfo (&dwIntError, NULL, &dwLength);
00544     if (dwLength)
00545     {
00546       if ( !(szBuffer = (TCHAR *) LocalAlloc ( LPTR,  dwLength) ) )
00547       {
00548         HRESULT hr = StringCchCat( szTemp, 100, "Unable to allocate memory to display Internet error code. Error code: " );
00549         hr = StringCchCat( szTemp, 100, TEXT (_itoa (GetLastError(), szBuffer, 10)  ) );
00550         hr = StringCchCat( szTemp, 100, TEXT ("\n") );
00551         cerr << szTemp << endl;
00552         return FALSE;
00553       }
00554       if (!InternetGetLastResponseInfo (&dwIntError, (LPTSTR) szBuffer, &dwLength))
00555       {
00556         hr = StringCchCat( szTemp, 100, "Unable to get Internet error. Error code: " );
00557         hr = StringCchCat( szTemp, 100, TEXT (_itoa (GetLastError(), szBuffer, 10)  ) );
00558         hr = StringCchCat( szTemp, 100, TEXT ("\n") );
00559         cerr << szTemp << endl;
00560         return FALSE;
00561       }
00562       if ( !(szBufferFinal = (TCHAR *) LocalAlloc ( LPTR,  (strlen (szBuffer) +strlen (szTemp) + 1)  ) )  )
00563       {
00564         hr = StringCchCat( szTemp, 100, "Unable to allocate memory. Error code: " );
00565         hr = StringCchCat( szTemp, 100, TEXT (_itoa (GetLastError(), szBuffer, 10)  ) );
00566         hr = StringCchCat( szTemp, 100, TEXT ("\n") );
00567         cerr << szTemp << endl;
00568         return FALSE;
00569       }
00570       hr = StringCchCopy(szBufferFinal, 110, szTemp);
00571       hr = StringCchCat( szBufferFinal, 110, szBuffer );
00572       LocalFree (szBuffer);
00573       cerr <<  szBufferFinal  << endl;
00574       LocalFree (szBufferFinal);
00575     }
00576   }
00577   else
00578         cerr << szTemp << endl;
00579     return TRUE;
00580 }
00581
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMethodSub Member List

This is the complete list of members for CMethodSub, including all inherited members.
CMethodSub(CComSpy *pSpy) | CMethodSub | [inline]
CMethodSub() | CMethodSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetClsidOfTypeLib2(IID *piid, UUID *puuidClsid) | CMethodSub |
GetEventClass(LPGUID guid) | CMethodSub | [inline, virtual]
GetEventType(EventEnum *e) | CMethodSub | [inline, virtual]
GetInterface(IID *iid) | CMethodSub | [inline, virtual]
GetMethodName(REFIID riid, int iMeth, _TCHAR **ppszMethodName) | CMethodSub |
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_map | CMethodSub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnMethodCall(COMSVCSEVENTINFO *pInfo, ULONG64 oid, REFCLSID cid, REFIID rid, ULONG iMeth) | CMethodSub |
OnMethodException(COMSVCSEVENTINFO *pInfo, ULONG64 oid, REFCLSID cid, REFIID rid, ULONG iMeth) | CMethodSub |
OnMethodReturn(COMSVCSEVENTINFO *pInfo, ULONG64 oid, REFCLSID cid, REFIID rid, ULONG iMeth, HRESULT hr) | CMethodSub |
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:56:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CX224 Member List

This is the complete list of members for CX224, including all inherited members.
CloseListenSocket() | CX224 |
CloseSocket() | CX224 |
CreateAcceptSocket(HWND hWnd) | CX224 |
CreateConnectSocket(HWND hwnd, LPSTR pszHostName) | CX224 |
CreateListenSocket(HWND hwnd) | CX224 |
CX224(void) | CX224 |
GetSocket() | CX224 |
m_hListenSocket | CX224 | [private]
m_hSocket | CX224 | [private]
m_szHostName | CX224 | [private]
SetAndGetHostName() | CX224 |
~CX224(void) | CX224 |
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcRDO/Resource.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcRDO

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by RDOKB.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_RDOCOMPONENT                101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/resource.h Source File

  • SysMgmt
  • MMC
  • Simple

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Resources.rc
00004 //
00005 #define IDS_HELPFILE                    1
00006 #define IDS_SNAPINDESC                  2
00007 #define IDS_NAME                        3
00008 #define IDS_SNAPINNAME                  6
00009 #define IDS_ABOUTNAME                   9
00010 #define IDI_ICON1                       108
00011 #define IDR_SMICONS                     120
00012 #define IDR_LGICONS                     121
00013 #define IDB_ROCKET                      40004
00014 #define IDB_CAR                         40005
00015 #define IDB_PLANE                       40006
00016 #define IDB_BIKE                        40007
00017 #define IDB_ROCKET2                     40008
00018 #define IDB_CAR2                        40009
00019 #define IDB_PLANE2                      40010
00020 #define IDB_BIKE2                       40011
00021 #define IDB_CLOSED2                     40012
00022 #define IDB_OPEN2                       40013
00023 #define IDB_CLOSED                      40014
00024 #define IDB_OPEN                        40015
00025
00026 // Next default values for new objects
00027 //
00028 #ifdef APSTUDIO_INVOKED
00029 #ifndef APSTUDIO_READONLY_SYMBOLS
00030 #define _APS_NEXT_RESOURCE_VALUE        108
00031 #define _APS_NEXT_COMMAND_VALUE         40016
00032 #define _APS_NEXT_CONTROL_VALUE         1000
00033 #define _APS_NEXT_SYMED_VALUE           101
00034 #endif
00035 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CToolBand Member List

This is the complete list of members for CToolBand, including all inherited members.
CloseDW(DWORD dwReserved) | CToolBand |
ContextSensitiveHelp(BOOL) | CToolBand |
CToolBand() | CToolBand |
FocusChange(BOOL) | CToolBand | [private]
GetBandInfo(DWORD, DWORD, DESKBANDINFO *) | CToolBand |
GetClassID(LPCLSID) | CToolBand |
GetSite(REFIID, LPVOID *) | CToolBand |
GetSizeMax(ULARGE_INTEGER *) | CToolBand |
GetWindow(HWND *) | CToolBand |
HasFocusIO(void) | CToolBand |
IsDirty(void) | CToolBand |
Load(LPSTREAM) | CToolBand |
m_bFocus | CToolBand | [private]
m_dwBandID | CToolBand | [private]
m_dwViewMode | CToolBand | [private]
m_hWnd | CToolBand | [private]
m_hwndParent | CToolBand | [private]
m_ObjRefCount | CToolBand | [protected]
m_pSite | CToolBand | [private]
OnCommand(WPARAM wParam, LPARAM lParam) | CToolBand | [private]
OnKillFocus(void) | CToolBand | [private]
OnPaint(void) | CToolBand | [private]
OnSetFocus(void) | CToolBand | [private]
OnSize(LPARAM) | CToolBand | [private]
QueryInterface(REFIID, LPVOID *) | CToolBand |
RegisterAndCreateWindow(void) | CToolBand | [private]
ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) | CToolBand |
Save(LPSTREAM, BOOL) | CToolBand |
SetSite(IUnknown *) | CToolBand |
ShowDW(BOOL fShow) | CToolBand |
STDMETHODIMP_(DWORD) AddRef() | CToolBand |
STDMETHODIMP_(DWORD) Release() | CToolBand |
TranslateAcceleratorIO(LPMSG) | CToolBand |
UIActivateIO(BOOL, LPMSG) | CToolBand |
WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) | CToolBand | [private, static]
~CToolBand() | CToolBand |
Generated on Wed Nov 13 2024 16:57:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/ansiapi.h Source File

  • Com
  • Fundamentals
  • OleStd

ansiapi.h

Go to the documentation of this file.
00001 /*
00002  * ansiapi.h
00003  * This file contains prototypes of ANSI version of OLE apis
00004  * and mapping fooA to foo
00005  */
00006
00007 #ifndef _ANSIAPI_INCL
00008 #define _ANSIAPI_INCL
00009
00010 #define UNICODEOLE32
00011
00012 #ifdef WIN32S
00013 #if !defined(UNICODEOLE32)
00014 #pragma message("Compiling for 32bit ANSI Ole!\n");
00015 #endif
00016 #endif
00017
00018 #define WASANSI() {                                                           \
00019                    OutputDebugString("\n\r\t\tUnicode string was ANSI!\r\n"); \
00020                    Assert(0);                                                 \
00021                    _asm { int 3 }                                             \
00022                   }
00023
00024
00025
00026 #ifndef UNICODEOLE32
00027
00028 #define W2A(w, a, cb)     lstrcpy (a, w)
00029 #define A2W(a, w, cb)     lstrcpy (w, a)
00030
00031 #define FREELOCALSTRING(p)
00032 #define MAKE_STR_LOCAL_COPYW2A(s, l)  l = s
00033 #define MAKE_STR_LOCAL_COPYA2W(s, l)  l = s
00034
00035 #define OLESTRCPY                lstrcpy
00036 #define OLESTRCAT                lstrcat
00037 #define OLESTRLEN                lstrlen
00038 #define OLESTRCMP                lstrcmp
00039 #define OLESTRCMPI               lstrcmpi
00040
00041 #define DeleteFile_AW            DeleteFile
00042 #define _lopen_AW                _lopen
00043 #define _lcreat_AW               _lcreat
00044 #define GlobalAddAtom_AW         GlobalAddAtom
00045 #define GlobalGetAtomName_AW     GlobalGetAtomName
00046 #define RegOpenKey_AW            RegOpenKey
00047
00048 #define CoLoadLibraryA   CoLoadLibrary
00049
00050 #define StringFromCLSID2A    StringFromCLSID2
00051 #define StringFromIID2A      StringFromIID2
00052 #define StringFromGUID2A     StringFromGUID2
00053 #define CLSIDFromProgIDA     CLSIDFromProgID
00054 #define CLSIDFromStringA     CLSIDFromString
00055 #define ProgIDFromCLSIDA     ProgIDFromCLSID
00056 #define StringFromCLSIDA     StringFromCLSID
00057
00058 #define UtDupStringA2W       UtDupString
00059
00060 // Storage APIs
00061 #define StgOpenStorageA      StgOpenStorage
00062
00063 // IPersistFile ansi translation
00064
00065 #define IPersistFile_LoadA(pf, file, mode) (pf)->Load(file, mode)
00066
00067 // IMoniker ansi translation
00068
00069 #define IMoniker_GetDisplayNameA(pm, p1, p2, p3) (pm)->GetDisplayName(p1,p2,p3)
00070
00071 #define CreateFileMonikerA   CreateFileMoniker
00072
00073 #else  // UNICODEOLE32
00074
00075
00076 #define W2A(w, a, cb)     WideCharToMultiByte(                              \
00077                                                CP_ACP,                      \
00078                                                0,                           \
00079                                                w,                           \
00080                                                -1,                          \
00081                                                a,                           \
00082                                                cb,                          \
00083                                                NULL,                        \
00084                                                NULL)
00085
00086 #define A2W(a, w, cb)     MultiByteToWideChar(                              \
00087                                                CP_ACP,                      \
00088                                                0,                           \
00089                                                a,                           \
00090                                                -1,                          \
00091                                                w,                           \
00092                                                cb)
00093
00094
00095 #define FREELOCALSTRING(p)      delete (p)
00096 #define MAKE_STR_LOCAL_COPYW2A(s, l)  {                                   \
00097                                       l = UtDupStringW2A(s);              \
00098                                       if (!l) {                           \
00099                                          return ResultFromScode(S_OOM);   \
00100                                       }                                   \
00101                                    }
00102
00103 #define MAKE_STR_LOCAL_COPYA2W(s, l)  {                                   \
00104                                       l = UtDupStringA2W(s);              \
00105                                       if (!l) {                           \
00106                                          return ResultFromScode(S_OOM);   \
00107                                       }                                   \
00108                                    }
00109
00110 #define OLESTRCPY                lstrcpyW
00111 #define OLESTRCAT                lstrcatW
00112 #define OLESTRLEN                lstrlenW
00113 #define OLESTRCMP                lstrcmpW
00114 #define OLESTRCMPI               lstrcmpiW
00115
00116 #define DeleteFile_AW            DeleteFileW
00117 #define _lopen_AW                _lopenW
00118 #define _lcreat_AW               _lcreatW
00119 #define GlobalAddAtom_AW         GlobalAddAtomW
00120 #define GlobalGetAtomName_AW     GlobalGetAtomNameW
00121 #define RegOpenKey_AW            RegOpenKeyW
00122
00123 STDAPI_(HINSTANCE) CoLoadLibraryA(LPSTR lpszLibName, BOOL bAutoFree);
00124
00125 #define StringFromCLSID2A(rclsid, lpsz, cbMax) \
00126     StringFromGUID2A(rclsid, lpsz, cbMax)
00127
00128 #define StringFromIID2A(riid, lpsz, cbMax) \
00129     StringFromGUID2A(riid, lpsz, cbMax)
00130
00131
00132 STDAPI_(int)  StringFromGUID2A(REFGUID rguid, LPSTR lpsz, int cbMax);
00133 STDAPI        CLSIDFromProgIDA(LPCSTR szProgID, LPCLSID pclsid);
00134 STDAPI        CLSIDFromStringA(LPSTR lpsz, LPCLSID lpclsid);
00135 STDAPI        StringFromCLSIDA(REFCLSID rclsid, LPSTR FAR* lplpsz);
00136 STDAPI        ProgIDFromCLSIDA (REFCLSID clsid, LPSTR FAR* lplpszProgID);
00137
00138 LPWSTR UtDupStringA2W(LPCSTR pSrc);
00139 LPSTR  UtDupStringW2A(LPCWSTR pSrc);
00140
00141 // Storage APIs
00142 STDAPI StgOpenStorageA(LPCSTR pwcsName,IStorage FAR *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage FAR * FAR *ppstgOpen);
00143
00144 // IPersistFile ansi translation
00145
00146 HRESULT IPersistFile_LoadA(LPPERSISTFILE pIPF, LPSTR szFile, DWORD dwMode);
00147
00148 // IMoniker ansi translation
00149
00150 HRESULT IMoniker_GetDisplayNameA(LPMONIKER pm, LPBC p1, LPMONIKER p2, LPSTR FAR *p3);
00151
00152 //OLEAPI CreateFileMonikerA ( LPSTR lpszPathName, LPMONIKER FAR * ppmk );
00153
00154 #endif // !UNICODEOLE32
00155
00156 #endif //  _ANSIAPI_INCL
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/staticnode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

staticnode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CStaticNode class.  This is the Snap-in's
00014 //                top level node
00015 //
00016
00017
00018 #ifndef _CLASS_CSTATICNODE_
00019 #define _CLASS_CSTATICNODE_
00020
00021 #include "Globals.h"
00022 #include "BaseNode.h"          // For NODE_PROPERTIES
00023 #include "LListImpl.h"
00024
00025 class CDeviceNode;             // References
00026 class CComponentData;
00027
00028
00029 //---------------------------------------------------------------------------
00030 class CStaticNode : public CBaseNode
00031 {
00032   public:
00033     CStaticNode();
00034     virtual ~CStaticNode();
00035
00036     HRESULT Initialize( LPNODEPROPS pNodeProps );
00037
00038
00039   // Virtual methods
00040   public:
00041     HRESULT GetProperties( LPNODEPROPS* ppNodeProps );
00042     ULONG   GetNodeType() { return NODETYPE_STATIC; }
00043     GUID&   GetNodeGUID() { return thisGUID; }
00044
00045     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00046     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00047     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00048
00049   ///////////////////////////////////////////////////////////////////////////
00050   // Notification handlers
00051   public:
00052     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00053     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00054     HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00055             { return E_NOTIMPL; }
00056
00057     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00058     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00059
00060     // DRAGDROP:  Support for additional notifications
00061     HRESULT OnQueryPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00062             { return S_FALSE; }
00063
00064     HRESULT OnPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00065             { return E_NOTIMPL; }
00066
00067     HRESULT OnCutOrMove( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00068             { return E_NOTIMPL; }
00069
00070   /////////////////////////////////////////////////////////////////////////
00071   //  Context Menu methods
00072   //
00073   public:
00074     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00075     HRESULT Command( long lCommandID );
00076
00077   ///////////////////////////////////////////////////////////////////////////
00078   // Private helpers
00079   private:
00080     HRESULT  DeleteScopeItems( LPCONSOLENAMESPACE2 ipCNS );
00081     HRESULT  InsertScopeItems( LPCONSOLENAMESPACE2 ipCNS );
00082     HRESULT  InitDefaultDevices();
00083     VOID     RemoveNodes();
00084
00085   ///////////////////////////////////////////////////////////////////////////
00086   // Public helpers
00087   public:
00088     HRESULT  AddDeviceNode( NODE_PROPERTIES* pProperties );
00089     VOID     ToggleStatus( LPDATAOBJECT ipDataObject );
00090     HWND     GetMessageWnd() { return m_hMessageWnd; }
00091
00092     static LRESULT CALLBACK StaticNodeWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
00093
00094   private:
00095     static GUID      thisGUID;
00096     HSCOPEITEM       m_hStaticNode;
00097     CComponentData*  m_pCompData;
00098     HWND             m_hMessageWnd;        // Our message handler
00099
00100     CLListImpl<CDeviceNode*,CDeviceNode*>  m_NodeList;
00101
00102   public:
00103     HWND             m_hAddDeviceDlg;      // Instance of AddDeviceDlg
00104
00105 };
00106
00107 #endif //_CLASS_CSTATICNODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_playinfo Member List

This is the complete list of members for _playinfo, including all inherited members.
bPlayContinuous | _playinfo
iRecord | _playinfo
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/resource.h Source File

  • WinUI
  • tsfapp

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by TSFApp.rc
00004 //
00005 #define IDI_MAIN_ICON                   101
00006 #define IDR_MAIN_MENU                   102
00007 #define IDD_ABOUT_DIALOG                103
00008 #define IDM_EXIT                        40001
00009 #define IDM_ABOUT                       40002
00010 #define IDM_GETPRESERVEDKEY             40003
00011 #define IDM_TEST                        40004
00012 #define IDM_GETDISPATTR                 40005
00013 #define IDM_TERMINATE_COMPOSITION       40006
00014 #define IDM_GET_TEXTOWNER               40007
00015 #define IDM_GET_READING                 40008
00016 #define IDM_GET_COMPOSING               40009
00017 #define IDM_RECONVERT                   40010
00018 #define IDM_PLAYBACK                    40011
00019 #define IDM_SAVE                        40012
00020 #define IDM_LOAD                        40013
00021
00022 // Next default values for new objects
00023 //
00024 #ifdef APSTUDIO_INVOKED
00025 #ifndef APSTUDIO_READONLY_SYMBOLS
00026 #define _APS_NEXT_RESOURCE_VALUE        104
00027 #define _APS_NEXT_COMMAND_VALUE         40014
00028 #define _APS_NEXT_CONTROL_VALUE         1000
00029 #define _APS_NEXT_SYMED_VALUE           101
00030 #endif
00031 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step2/HelloWorld.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step2

HelloWorld.h

Go to the documentation of this file.
00001 // HelloWorld.h: Definition of the HelloWorld class
00002 //
00003 //////////////////////////////////////////////////////////////////////
00004
00005 #if !defined(AFX_HELLOWORLD_H__E1E3EDF9_48D1_11D2_B22B_0000F87A6B50__INCLUDED_)
00006 #define AFX_HELLOWORLD_H__E1E3EDF9_48D1_11D2_B22B_0000F87A6B50__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #include "resource.h"       // main symbols
00013 //#import "c:\winnt\system32\activeds.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // HelloWorld
00017
00018 class HelloWorld :
00019   //public IDispatchImpl<IHelloWorld, &IID_IHelloWorld, &LIBID_ADSFIRSTEXTLib>,
00020     public IHelloWorld,
00021   public ISupportErrorInfo,
00022   public CComObjectRoot,
00023   public CComCoClass<HelloWorld,&CLSID_HelloWorld>,
00024   public IADsExtension
00025 {
00026 protected:
00027   ITypeInfo   *m_pTypeInfo;
00028
00029 public:
00030   HelloWorld();
00031   ~HelloWorld();
00032
00033 BEGIN_COM_MAP(HelloWorld)
00034   COM_INTERFACE_ENTRY(IDispatch)
00035   COM_INTERFACE_ENTRY(IHelloWorld)
00036   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00037   COM_INTERFACE_ENTRY(IADsExtension)
00038 END_COM_MAP()
00039 //DECLARE_NOT_AGGREGATABLE(HelloWorld)
00040 // Remove the comment from the line above if you don't want your object to
00041 // support aggregation.
00042
00043 DECLARE_REGISTRY_RESOURCEID(IDR_HelloWorld)
00044 // ISupportsErrorInfo
00045   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00046
00047   // IDispatch
00048   STDMETHOD(GetTypeInfoCount)(UINT* pctinfo);
00049   STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
00050   STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
00051     LCID lcid, DISPID* rgdispid);
00052   STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
00053     LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
00054     EXCEPINFO* pexcepinfo, UINT* puArgErr);
00055
00056 // IHelloWorld
00057 public:
00058
00059   STDMETHOD(Say)();
00060 // IADsExtension
00061   STDMETHOD(Operate)(ULONG dwCode, VARIANT varData1, VARIANT varData2, VARIANT varData3)
00062   {
00063     HRESULT hr = S_OK;
00064
00065     switch (dwCode)
00066     {
00067
00068       case ADS_EXT_INITCREDENTIALS:
00069           // For debugging purpose you can prompt a dialog box
00070           // MessageBox(NULL, "INITCRED", "ADsExt", MB_OK);
00071           break;
00072
00073       default:
00074           hr = E_FAIL;
00075           break;
00076
00077     }
00078
00079         return hr;
00080
00081   }
00082
00083
00084   STDMETHOD(PrivateGetIDsOfNames)(REFIID riid, OLECHAR ** rgszNames, unsigned int cNames, LCID lcid, DISPID  * rgdispid)
00085   {
00086
00087     if (rgdispid == NULL)
00088     {
00089       return E_POINTER;
00090     }
00091
00092     return  DispGetIDsOfNames(m_pTypeInfo, rgszNames, cNames, rgdispid);
00093   }
00094
00095
00096
00097   STDMETHOD(PrivateInvoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
00098   {
00099        return DispInvoke( (IHelloWorld*)this,
00100         m_pTypeInfo,
00101         dispidMember,
00102         wFlags,
00103         pdispparams,
00104         pvarResult,
00105         pexcepinfo,
00106         puArgErr );
00107   }
00108 };
00109
00110 #endif // !defined(AFX_HELLOWORLD_H__E1E3EDF9_48D1_11D2_B22B_0000F87A6B50__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

VJQuery Member List

This is the complete list of members for VJQuery, including all inherited members.
main(String[] args) | VJQuery | [inline, static]
StripEndQuotes(String S) | VJQuery | [inline, package, static]
Usage() | VJQuery | [inline, package, static]
Generated on Wed Nov 13 2024 16:58:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ADCPROP_UPDATECRITERIA_ENUM Member List

This is the complete list of members for msado15::ADCPROP_UPDATECRITERIA_ENUM, including all inherited members.
adCriteriaAllCols | msado15::ADCPROP_UPDATECRITERIA_ENUM | [static]
adCriteriaKey | msado15::ADCPROP_UPDATECRITERIA_ENUM | [static]
adCriteriaTimeStamp | msado15::ADCPROP_UPDATECRITERIA_ENUM | [static]
adCriteriaUpdCols | msado15::ADCPROP_UPDATECRITERIA_ENUM | [static]
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/DataSourceNames.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1

DataSourceNames.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DataSourceNames.h
00003   Summary:   Constant Data Source Names and passwords
00004   Origin:    Implementation of case study in Queued Components specification
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #ifndef __DATASOURCENAMES_H_
00023 #define __DATASOURCENAMES_H_
00024
00025 LPCWSTR const pszOrderDSN = L"DSN=QCSampleOrder";
00026 LPCWSTR const pszShipDSN  = L"DSN=QCSampleShip";
00027 LPCWSTR const pszUserId   = L"sa";
00028 LPCWSTR const pszPassword = L"";
00029
00030 #endif // __DATASOURCENAMES_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/Comp.Cpp Source File

  • SysMgmt
  • MMC
  • Help

Comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "DataObj.h"
00021 #include <commctrl.h>        // Needed for button styles...
00022 #include <crtdbg.h>
00023 #include "globals.h"
00024 #include "resource.h"
00025 #include "DeleBase.h"
00026 #include "CompData.h"
00027
00028 CComponent::CComponent(CComponentData *parent)
00029 : m_pComponentData(parent), m_cref(0), m_ipConsole(NULL), m_ipDisplayHelp(NULL)
00030 {
00031     OBJECT_CREATED
00032 }
00033
00034 CComponent::~CComponent()
00035 {
00036     OBJECT_DESTROYED
00037 }
00038
00039 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00040 {
00041     if (!ppv)
00042         return E_FAIL;
00043
00044     *ppv = NULL;
00045
00046     if (IsEqualIID(riid, IID_IUnknown))
00047         *ppv = static_cast<IComponent *>(this);
00048     else if (IsEqualIID(riid, IID_IComponent))
00049         *ppv = static_cast<IComponent *>(this);
00050
00051     if (*ppv)
00052     {
00053         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00054         return S_OK;
00055     }
00056
00057     return E_NOINTERFACE;
00058 }
00059
00060 STDMETHODIMP_(ULONG) CComponent::AddRef()
00061 {
00062     return InterlockedIncrement((LONG *)&m_cref);
00063 }
00064
00065 STDMETHODIMP_(ULONG) CComponent::Release()
00066 {
00067     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00068     {
00069         delete this;
00070         return 0;
00071     }
00072     return m_cref;
00073
00074 }
00075
00076 ///////////////////////////////
00077 // Interface IComponent
00078 ///////////////////////////////
00079 STDMETHODIMP CComponent::Initialize(
00080                                     /* [in] */ LPCONSOLE lpConsole)
00081 {
00082     HRESULT hr = S_OK;
00083
00084     // Save away all the interfaces we'll need.
00085     // Fail if we can't QI the required interfaces.
00086
00087     m_ipConsole = lpConsole;
00088     m_ipConsole->AddRef();
00089
00090     hr = m_ipConsole->QueryInterface(IID_IDisplayHelp, (void **)&m_ipDisplayHelp);
00091
00092     return hr;
00093 }
00094
00095 STDMETHODIMP CComponent::Notify(
00096                                 /* [in] */ LPDATAOBJECT lpDataObject,
00097                                 /* [in] */ MMC_NOTIFY_TYPE event,
00098                                 /* [in] */ LPARAM arg,
00099                                 /* [in] */ LPARAM param)
00100 {
00101     MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00102
00103     HRESULT hr = S_FALSE;
00104
00105   //Get our data object. If it is NULL, we return with S_FALSE.
00106   //See implementation of GetOurDataObject() to see how to
00107   //handle special data objects.
00108   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00109   if (NULL == pDataObject)
00110     return S_FALSE;
00111
00112   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00113
00114     switch (event)  {
00115     case MMCN_CONTEXTHELP:
00116         hr = base->OnShowContextHelp(m_ipDisplayHelp, m_pComponentData->m_HelpFile);
00117         break;
00118     }
00119
00120     return hr;
00121 }
00122
00123 STDMETHODIMP CComponent::Destroy(
00124                                  /* [in] */ MMC_COOKIE cookie)
00125 {
00126     if (m_ipConsole) {
00127         m_ipConsole->Release();
00128         m_ipConsole = NULL;
00129     }
00130
00131     if (m_ipDisplayHelp) {
00132         m_ipDisplayHelp->Release();
00133         m_ipDisplayHelp = NULL;
00134     }
00135
00136     return S_OK;
00137 }
00138
00139
00140 STDMETHODIMP CComponent::QueryDataObject(
00141                                          /* [in] */ MMC_COOKIE cookie,
00142                                          /* [in] */ DATA_OBJECT_TYPES type,
00143                                          /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00144 {
00145     CDataObject *pObj = NULL;
00146
00147     if (cookie == 0)
00148         pObj = new CDataObject((MMC_COOKIE)m_pComponentData->m_pStaticNode, type);
00149     else
00150         pObj = new CDataObject(cookie, type);
00151
00152     if (!pObj)
00153         return E_OUTOFMEMORY;
00154
00155     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00156
00157     return S_OK;
00158 }
00159
00160 STDMETHODIMP CComponent::GetResultViewType(
00161                                            /* [in] */ MMC_COOKIE cookie,
00162                                            /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00163                                            /* [out] */ long __RPC_FAR *pViewOptions)
00164 {
00165     CDelegationBase *base = (CDelegationBase *)cookie;
00166
00167     //
00168     // Ask for default listview.
00169     //
00170     if (base == NULL)
00171     {
00172         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00173         *ppViewType = NULL;
00174     }
00175     else
00176         return base->GetResultViewType(ppViewType, pViewOptions);
00177
00178     return S_OK;
00179 }
00180
00181 STDMETHODIMP CComponent::GetDisplayInfo(
00182                                         /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00183 {
00184     HRESULT hr = S_OK;
00185     CDelegationBase *base = NULL;
00186
00187     // if they are asking for the RDI_STR we have one of those to give
00188
00189     if (pResultDataItem->lParam) {
00190         base = (CDelegationBase *)pResultDataItem->lParam;
00191         if (pResultDataItem->mask & RDI_STR) {
00192       LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00193       MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00194             pResultDataItem->str = pszW;
00195         }
00196
00197         if (pResultDataItem->mask & RDI_IMAGE) {
00198             pResultDataItem->nImage = base->GetBitmapIndex();
00199         }
00200     }
00201
00202     return hr;
00203 }
00204
00205
00206 STDMETHODIMP CComponent::CompareObjects(
00207                                         /* [in] */ LPDATAOBJECT lpDataObjectA,
00208                                         /* [in] */ LPDATAOBJECT lpDataObjectB)
00209 {
00210     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00211     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00212
00213     // compare the object pointers
00214     if (baseA->GetCookie() == baseB->GetCookie())
00215         return S_OK;
00216
00217     return S_FALSE;
00218 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFileTransferNotify Member List

This is the complete list of members for CFileTransferNotify, including all inherited members.
AddRef(void) | CFileTransferNotify |
RefCount::AddRef(void) | RefCount |
CFileTransferNotify() | CFileTransferNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
Connect(IUnknown *pUnk) | CFileTransferNotify |
CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Disconnect(void) | CFileTransferNotify |
FtUpdate(CONFN uNotify, INmFt *pFt) | CFileTransferNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CFileTransferNotify |
NmUI(CONFN uNotify) | CFileTransferNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CFileTransferNotify |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
Release(void) | CFileTransferNotify |
RefCount::Release(void) | RefCount |
~CFileTransferNotify() | CFileTransferNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
Generated on Wed Nov 13 2024 16:56:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CReindeer Member List

This is the complete list of members for CReindeer, including all inherited members.
CReindeer(LPCWSTR chsClassName, LPCWSTR lpszNameSpace) | CReindeer |
DeleteInstance(const CInstance &Instance, long lFlags=0L) | CReindeer | [protected, virtual]
EnumerateInstances(MethodContext *pMethodContext, long lFlags=0L) | CReindeer | [protected, virtual]
EnumerationCallback(CInstance *pReindeer, MethodContext *pMethodContext, VOID *pTotWeight) | CReindeer | [private]
ExecMethod(const CInstance &Instance, const BSTR bstrMethodName, CInstance *pInParams, CInstance *pOutParams, long lFlags=0L) | CReindeer | [protected, virtual]
ExecQuery(MethodContext *pMethodContext, CFrameworkQuery &Query, long lFlags=0L) | CReindeer | [protected, virtual]
GetObject(CInstance *pInstance, long lFlags=0L) | CReindeer | [protected, virtual]
IsInList(const CHStringArray &asArray, LPCWSTR pszString) | CReindeer | [private]
LoadPropertyValues(CInstance *pInstance, DWORD dwIndex, DWORD dwRequiredProperties) | CReindeer | [protected]
PutInstance(const CInstance &Instance, long lFlags=0L) | CReindeer | [protected, virtual]
StaticEnumerationCallback(Provider *pThat, CInstance *pInstance, MethodContext *pContext, void *pUserData) | CReindeer | [private, static]
~CReindeer() | CReindeer | [virtual]
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Cfact.Cpp Source File

  • NetDS
  • SyncMgr
  • SyncDir

Cfact.Cpp

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #include "precomp.h"
00013
00014 //
00015 // Global variables
00016 //
00017
00018 EXTERN_C const GUID CLSID_SyncMgrHandler;
00019
00020 extern UINT      g_cRefThisDll;    // Reference count of this DLL.
00021 extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
00022
00023
00024 //+---------------------------------------------------------------------------
00025 //
00026 //  Member:     CClassFactory::CClassFactory, public
00027 //
00028 //  Synopsis:   Constructor
00029 //
00030 //  Arguments:
00031 //
00032 //  Returns:
00033 //
00034 //  Modifies:
00035 //
00036 //----------------------------------------------------------------------------
00037
00038 CClassFactory::CClassFactory()
00039 {
00040     m_cRef = 0L;
00041
00042     g_cRefThisDll++;
00043 }
00044
00045 //+---------------------------------------------------------------------------
00046 //
00047 //  Member:     CClassFactory::~CClassFactory, public
00048 //
00049 //  Synopsis:   Destructor
00050 //
00051 //  Arguments:
00052 //
00053 //  Returns:
00054 //
00055 //  Modifies:
00056 //
00057 //----------------------------------------------------------------------------
00058
00059 CClassFactory::~CClassFactory()
00060 {
00061     g_cRefThisDll--;
00062 }
00063
00064 //+---------------------------------------------------------------------------
00065 //
00066 //  Member:     CClassFactory::QueryInterface public
00067 //
00068 //  Synopsis:
00069 //
00070 //  Arguments:
00071 //
00072 //  Returns:
00073 //
00074 //  Modifies:
00075 //
00076 //----------------------------------------------------------------------------
00077
00078 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid,
00079                                                    LPVOID FAR *ppv)
00080 {
00081     *ppv = NULL;
00082
00083     // Any interface on this object is the object pointer
00084     if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
00085     {
00086         *ppv = (LPCLASSFACTORY)this;
00087
00088         AddRef();
00089
00090         return NOERROR;
00091     }
00092
00093     return E_NOINTERFACE;
00094 }
00095
00096 //+---------------------------------------------------------------------------
00097 //
00098 //  Member:     CClassFactory::AddRef, public
00099 //
00100 //  Synopsis:
00101 //
00102 //  Arguments:
00103 //
00104 //  Returns:
00105 //
00106 //  Modifies:
00107 //
00108 //----------------------------------------------------------------------------
00109
00110 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00111 {
00112     return ++m_cRef;
00113 }
00114
00115
00116 //+---------------------------------------------------------------------------
00117 //
00118 //  Member:     CClassFactory::Release, public
00119 //
00120 //  Synopsis:
00121 //
00122 //  Arguments:
00123 //
00124 //  Returns:
00125 //
00126 //  Modifies:
00127 //
00128 //----------------------------------------------------------------------------
00129
00130 STDMETHODIMP_(ULONG) CClassFactory::Release()
00131 {
00132     if (--m_cRef)
00133         return m_cRef;
00134
00135     delete this;
00136
00137     return 0L;
00138 }
00139
00140
00141 //+---------------------------------------------------------------------------
00142 //
00143 //  Member:     CClassFactory::CreateInstance, public
00144 //
00145 //  Synopsis:
00146 //
00147 //  Arguments:
00148 //
00149 //  Returns:
00150 //
00151 //  Modifies:
00152 //
00153 //----------------------------------------------------------------------------
00154
00155 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
00156                                                       REFIID riid,
00157                                                       LPVOID *ppvObj)
00158 {
00159 HRESULT hr = NOERROR;
00160
00161     *ppvObj = NULL;
00162
00163     if (pUnkOuter)
00164         return CLASS_E_NOAGGREGATION;
00165
00166     LPSYNCMGRSYNCHRONIZE pSyncMgrHandler = new CSyncMgrHandler();
00167
00168     if (NULL == pSyncMgrHandler)
00169         return E_OUTOFMEMORY;
00170
00171     hr =  pSyncMgrHandler->QueryInterface(riid, ppvObj);
00172     pSyncMgrHandler->Release(); // remove our reference.
00173
00174     return hr;
00175
00176 }
00177
00178
00179 //+---------------------------------------------------------------------------
00180 //
00181 //  Member:     CClassFactory::LockServer, public
00182 //
00183 //  Synopsis:
00184 //
00185 //  Arguments:
00186 //
00187 //  Returns:
00188 //
00189 //  Modifies:
00190 //
00191 //----------------------------------------------------------------------------
00192
00193 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00194 {
00195     if (fLock)
00196     {
00197        ++g_cRefThisDll;
00198     }
00199     else
00200     {
00201        --g_cRefThisDll;
00202     }
00203
00204     return NOERROR;
00205
00206 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/proppagex.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

proppagex.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CPROPERTYSHEETX_
00016 #define _CLASS_CPROPERTYSHEETX_
00017
00018
00019 #include "Globals.h"
00020
00021 //---------------------------------------------------------------------------
00022 class CExtendPropertySheet : public IExtendPropertySheet
00023 {
00024   private:
00025     ULONG          m_cRef;
00026     ULONG          m_nPageCount;
00027     NODE_ATTRIBS   m_pNodeAttribs;     // Path to object
00028     DWORD          m_dwXAttribs;       // Our extended attributes
00029
00030   public:
00031
00032   public:
00033     CExtendPropertySheet();
00034     ~CExtendPropertySheet();
00035
00036   ///////////////////////////////////////////////////////////////////////////
00037   // Interface IUnknown
00038   public:
00039     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043
00044   /////////////////////////////////////////////////////////////////////////
00045   // Interface IExtendPropertySheet
00046   public:
00047     HRESULT STDMETHODCALLTYPE CreatePropertyPages
00048             ( /*[in]*/ LPPROPERTYSHEETCALLBACK lpProvider,
00049               /*[in]*/ LONG_PTR Handle,
00050               /*[in]*/ LPDATAOBJECT ipIDataObject
00051             );
00052
00053     HRESULT STDMETHODCALLTYPE QueryPagesFor
00054             ( /*[in]*/ LPDATAOBJECT ipDataObject
00055             );
00056
00057
00058   private:
00059     static BOOL CALLBACK PPageWndProcX( HWND hPage, UINT uMsg, WPARAM wParam, LPARAM lParam );
00060
00061     BOOL OnInitPropPage( HWND hPage, WPARAM wParam, LPARAM lParam );
00062     BOOL OnApplyChanges( HWND hPage, WPARAM wParam, LPARAM lParam );
00063
00064     BOOL IsAttributeSet( DWORD dwAttribute );
00065
00066 };
00067
00068 #endif //_CLASS_CPROPERTYSHEETX_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

FONTENUM Member List

This is the complete list of members for FONTENUM, including all inherited members.
ft | FONTENUM
lf | FONTENUM
tm | FONTENUM
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/Cancel/InProc/SServer.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • Cancel
  • InProc

SServer.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #define _WIN32_WINNT 0x0400
00018 #include <stdio.h>
00019 #include <tchar.h>
00020 #include <windows.h>
00021 #include <WindowsX.h>
00022
00023 #include <initguid.h>
00024
00025 // {37824810-ADBA-11d1-B6FB-00A024A85A1F}
00026 DEFINE_GUID(CLSID_NoneCancelObject, 0x37824810, 0xadba, 0x11d1, 0xb6, 0xfb, 0x0, 0xa0, 0x24, 0xa8, 0x5a, 0x1f);
00027
00028 // {37824811-ADBA-11d1-B6FB-00A024A85A1F}
00029 DEFINE_GUID(CLSID_STACancelObject, 0x37824811, 0xadba, 0x11d1, 0xb6, 0xfb, 0x0, 0xa0, 0x24, 0xa8, 0x5a, 0x1f);
00030
00031 // {37824812-ADBA-11d1-B6FB-00A024A85A1F}
00032 DEFINE_GUID(CLSID_MTACancelObject, 0x37824812, 0xadba, 0x11d1, 0xb6, 0xfb, 0x0, 0xa0, 0x24, 0xa8, 0x5a, 0x1f);
00033
00034 long  g_Count;
00035 typedef struct tagCONSOLEDATA
00036 {
00037   int x;
00038   int y;
00039 } CONSOLEDATA;
00040
00041 CRITICAL_SECTION g_cs;
00042 CONSOLEDATA g_ConsoleData;
00043
00044 // %%Classes: ----------------------------------------------------------------
00045
00046 // simple class-factory: only knows how to create CSimpleObject instances
00047 class CClassFactory : public IClassFactory
00048 {
00049   public:
00050     // IUnknown
00051     STDMETHODIMP    QueryInterface (REFIID riid, void** ppv);
00052     STDMETHODIMP_(ULONG) AddRef(void)  { return 2; };
00053     STDMETHODIMP_(ULONG) Release(void) { return 1; }
00054
00055     // IClassFactory
00056     STDMETHODIMP    CreateInstance (LPUNKNOWN punkOuter, REFIID iid, void **ppv);
00057     STDMETHODIMP    LockServer (BOOL fLock) { fLock ? InterlockedIncrement(&g_Count): InterlockedDecrement(&g_Count); return S_OK;}
00058
00059     CClassFactory()  { }
00060
00061   private:
00062     };
00063
00064 class CSimpleObject : public IPersist
00065 {
00066   public:
00067     // IUnknown
00068     STDMETHODIMP    QueryInterface (REFIID iid, void **ppv);
00069     STDMETHODIMP_(ULONG) AddRef(void)  {InterlockedIncrement(&m_cRef);return m_cRef;}
00070     STDMETHODIMP_(ULONG) Release(void) {
00071     if (InterlockedDecrement(&m_cRef) == 0)
00072     { delete this; return 0;}
00073     else
00074       return m_cRef;
00075   }
00076
00077     // IPersist
00078     STDMETHODIMP    GetClassID(CLSID *pClsID);
00079
00080     // constructors/destructors
00081     CSimpleObject()     {
00082     m_cRef = 1;
00083     xy.X = 0;
00084     xy.Y = (short)g_ConsoleData.y;
00085     InterlockedIncrement(&g_Count);
00086     hConsole = CreateFile(TEXT("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
00087       FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
00088     if (INVALID_HANDLE_VALUE == hConsole)
00089       hConsole = 0;
00090   }
00091     ~CSimpleObject()    { InterlockedDecrement(&g_Count); if (hConsole) CloseHandle(hConsole);}
00092     STDMETHODIMP    WasteTime(TCHAR *szMessage);
00093
00094   private:
00095     LONG        m_cRef;
00096   COORD       xy;
00097   HANDLE hConsole;
00098
00099     };
00100
00101 // %%Globals: ----------------------------------------------------------------
00102
00103 CClassFactory   g_ClassFactory;
00104 HINSTANCE   g_hInstance;
00105
00106 BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
00107 {
00108   UNREFERENCED_PARAMETER(lpvReserved);
00109   switch (fdwReason)
00110     {
00111         case DLL_PROCESS_ATTACH:
00112        g_hInstance = hDLLInst;
00113        InitializeCriticalSection(&g_cs);
00114        break;
00115         case DLL_THREAD_ATTACH:
00116       break;
00117         case DLL_THREAD_DETACH:
00118       break;
00119         case DLL_PROCESS_DETACH:
00120        DeleteCriticalSection(&g_cs);
00121        _tprintf(TEXT("\n going..going..gone\n"));
00122        break;
00123     default:
00124       break;
00125   }
00126     return TRUE;
00127 }
00128
00129 // ---------------------------------------------------------------------------
00130 // %%Function: Message
00131 //
00132 //  Formats and displays a message to the console.
00133 // ---------------------------------------------------------------------------
00134 void
00135 Message(LPTSTR szPrefix, HRESULT hr)
00136 {
00137     LPTSTR   szMessage;
00138   TCHAR szDisplay[1000];
00139
00140     if (hr == S_OK)
00141         {
00142     _stprintf(szDisplay, TEXT("%s"), szPrefix);
00143     MessageBox(0, szDisplay, TEXT("Msg"),MB_SERVICE_NOTIFICATION);
00144         return;
00145         }
00146
00147     if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
00148         hr = HRESULT_CODE(hr);
00149
00150     FormatMessage(
00151         FORMAT_MESSAGE_ALLOCATE_BUFFER |
00152         FORMAT_MESSAGE_FROM_SYSTEM,
00153         NULL,
00154         hr,
00155         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00156         (LPTSTR)&szMessage,
00157         0,
00158         NULL );
00159
00160     _stprintf(szDisplay, TEXT("%s: %s(%lx)"), szPrefix, szMessage, hr);
00161   MessageBox(0, szDisplay, TEXT("Service:Msg"),MB_SERVICE_NOTIFICATION);
00162     LocalFree(szMessage);
00163 }  // Message
00164
00165
00166 // ---------------------------------------------------------------------------
00167 // %%Function: CSimpleObject::QueryInterface
00168 // ---------------------------------------------------------------------------
00169  STDMETHODIMP
00170 CSimpleObject::QueryInterface(REFIID riid, void** ppv)
00171 {
00172     if (ppv == NULL)
00173         return E_INVALIDARG;
00174     *ppv = NULL;
00175     if (riid == IID_IUnknown || riid == IID_IPersist)
00176     {
00177         *ppv =  this;
00178         ((IUnknown*)*ppv)->AddRef();
00179         return S_OK;
00180   }
00181
00182     return E_NOINTERFACE;
00183 }  // CSimpleObject::QueryInterface
00184
00185 STDMETHODIMP Busy(HANDLE hConsole, COORD& xy, int nIter)
00186 {
00187   HRESULT hr = S_OK;
00188   SetConsoleCursorPosition(hConsole, xy);
00189   TCHAR *szMessage = TEXT("!!!Call cancelled!!!");
00190   TCHAR *szBuf[4]={TEXT("|"), TEXT("/"), TEXT("-"), TEXT("\\")};
00191   for (int i = 0; i < nIter; i++)
00192   {
00193     WriteConsole(hConsole, szBuf[0], 1, NULL, NULL);
00194     SetConsoleCursorPosition(hConsole, xy);
00195     WriteConsole(hConsole, szBuf[1], 1, NULL, NULL);
00196     SetConsoleCursorPosition(hConsole, xy);
00197     WriteConsole(hConsole, szBuf[2], 1, NULL, NULL);
00198     SetConsoleCursorPosition(hConsole, xy);
00199     WriteConsole(hConsole, szBuf[3], 1, NULL, NULL);
00200     SetConsoleCursorPosition(hConsole, xy);
00201     if (RPC_E_CALL_CANCELED == CoTestCancel())
00202     {
00203       hr = RPC_E_CALL_CANCELED;
00204       WriteConsole(hConsole, szMessage, lstrlen(szMessage), NULL, NULL);
00205       break;
00206     }
00207   }
00208   return hr;
00209 }
00210
00211 STDMETHODIMP
00212 CSimpleObject::WasteTime(TCHAR *szMessage)
00213 {
00214   if (hConsole)
00215   {
00216     SetConsoleCursorPosition(hConsole, xy);
00217     WriteConsole(hConsole, szMessage, lstrlen(szMessage), NULL, NULL);
00218     xy.X += 50;
00219     return Busy(hConsole, xy, 5000);
00220   }
00221   return S_OK;
00222 }
00223
00224
00225 STDMETHODIMP
00226 CSimpleObject::GetClassID(CLSID *pClsID)
00227 {
00228   UNREFERENCED_PARAMETER(pClsID);
00229   MessageBeep(0);
00230   xy.X = 0;
00231   return WasteTime(TEXT("In Call                               "));
00232 }
00233
00234 // ---------------------------------------------------------------------------
00235 // %%Function: CClassFactory::QueryInterface
00236 // ---------------------------------------------------------------------------
00237  STDMETHODIMP
00238 CClassFactory::QueryInterface(REFIID riid, void** ppv)
00239 {
00240     if (ppv == NULL)
00241         return E_INVALIDARG;
00242     if (riid == IID_IClassFactory || riid == IID_IUnknown)
00243         {
00244         *ppv = (IClassFactory *) this;
00245         AddRef();
00246         return S_OK;
00247         }
00248     *ppv = NULL;
00249     return E_NOINTERFACE;
00250 }  // CClassFactory::QueryInterface
00251
00252 // ---------------------------------------------------------------------------
00253 // %%Function: CClassFactory::CreateInstance
00254 // ---------------------------------------------------------------------------
00255
00256  STDMETHODIMP
00257 CClassFactory::CreateInstance(LPUNKNOWN punkOuter, REFIID riid, void** ppv)
00258 {
00259   HRESULT hr = S_OK;
00260     *ppv = NULL;
00261   CSimpleObject *p;
00262
00263     if (punkOuter != NULL)
00264         return CLASS_E_NOAGGREGATION;
00265   EnterCriticalSection(&g_cs);
00266   g_ConsoleData.y++;
00267   p = new CSimpleObject;
00268   LeaveCriticalSection(&g_cs);
00269     if (p == NULL)
00270         return E_OUTOFMEMORY;
00271   if (RPC_E_CALL_CANCELED == p->WasteTime(TEXT("Creating Object")))
00272   {
00273     p->Release();
00274     return hr;
00275   }
00276     hr = p->QueryInterface(riid, ppv);
00277   p->Release();
00278   return hr;
00279 }  // CClassFactory::CreateInstance
00280
00281
00282 STDAPI DllCanUnloadNow()
00283 {
00284   if (g_Count == 0)
00285   {
00286     return S_OK ;
00287   }
00288   else
00289   {
00290     return S_FALSE ;
00291   }
00292 }
00293
00294 STDAPI DllGetClassObject(const CLSID& clsid,
00295                          const IID& iid,
00296                          void** ppv)
00297 {
00298
00299   // Can we create this component?
00300   if ( (clsid != CLSID_NoneCancelObject) && (clsid != CLSID_STACancelObject) &&
00301      (clsid != CLSID_MTACancelObject))
00302   {
00303     return CLASS_E_CLASSNOTAVAILABLE ;
00304   }
00305   HRESULT hr =  g_ClassFactory.QueryInterface(iid, ppv) ;
00306   return hr ;
00307 }
00308
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Simple/StdAfx.Cpp Source File

  • Web
  • iis
  • Components
  • Cpp
  • Simple

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/Simple/sclient/sclient.cpp Source File

  • Com
  • Fundamentals
  • DCom
  • Simple
  • sclient

sclient.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 // ===========================================================================
00019 // Description:
00020 //
00021 //  This is the client-portion of the SIMPLE Distributed COM sample. This
00022 // application uses the CLSID_SimpleObject class implemented by the SSERVER.CPP
00023 // module. Pass the machine-name to instantiate the object on, or pass no
00024 // arguments to instantiate the object on the same machine. See the comments
00025 // in SSERVER.CPP for further details.
00026 //
00027 //  The purpose of this sample is to demonstrate what is minimally required
00028 // to use a COM object, whether it runs on the same machine or on a different
00029 // machine.
00030 //
00031 // Instructions:
00032 //
00033 //  To use this sample:
00034 //   * build it using the NMAKE command. NMAKE will create SSERVER.EXE and
00035 //     SCLIENT.EXE.
00036 //   * install the SSERVER.EXE on the current machine or on a remote machine
00037 //     according to the installation instructions found in SSERVER.CPP.
00038 //   * run SCLIENT.EXE. use no command-line arguments to instantiate the object
00039 //     on the current machine. use a single command-line argument of the remote
00040 //     machine-name (UNC or DNS) to instantiate the object on a remote machine.
00041 //   * SCLIENT.EXE displays some simple information about the calls it is
00042 //     making on the object.
00043 //
00044 // Copyright 1996 Microsoft Corporation.  All Rights Reserved.
00045 // ===========================================================================
00046
00047 // %%Includes: ---------------------------------------------------------------
00048 #define INC_OLE2
00049 #include <stdio.h>
00050 #include <windows.h>
00051 #include <initguid.h>
00052 #include <tchar.h>
00053 #include <conio.h>
00054
00055 // %%GUIDs: ------------------------------------------------------------------
00056 DEFINE_GUID(CLSID_SimpleObject, 0x5e9ddec7, 0x5767, 0x11cf, 0xbe, 0xab, 0x0, 0xaa, 0x0, 0x6c, 0x36, 0x6);
00057
00058 // %%Constants: --------------------------------------------------------------
00059 const ULONG cbDefault = 4096;    // default # of bytes to Read/Write
00060
00061 // ---------------------------------------------------------------------------
00062 // %%Function: Message
00063 //
00064 //  Formats and displays a message to the console.
00065 // ---------------------------------------------------------------------------
00066  void
00067 Message(LPTSTR szPrefix, HRESULT hr)
00068 {
00069     LPTSTR   szMessage;
00070
00071     if (hr == S_OK)
00072         {
00073         wprintf(szPrefix);
00074         return;
00075         }
00076
00077     if (HRESULT_FACILITY(hr) == FACILITY_WINDOWS)
00078         hr = HRESULT_CODE(hr);
00079
00080     FormatMessage(
00081         FORMAT_MESSAGE_ALLOCATE_BUFFER |
00082         FORMAT_MESSAGE_FROM_SYSTEM,
00083         NULL,
00084         hr,
00085         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00086         (LPTSTR)&szMessage,
00087         0,
00088         NULL);
00089
00090     wprintf(TEXT("%s: %s(%lx)\n"), szPrefix, szMessage, hr);
00091
00092     LocalFree(szMessage);
00093 }  // Message
00094
00095 // ---------------------------------------------------------------------------
00096 // %%Function: OutputTime
00097 // ---------------------------------------------------------------------------
00098  void
00099 OutputTime(LARGE_INTEGER* pliStart, LARGE_INTEGER* pliFinish)
00100 {
00101     LARGE_INTEGER liFreq;
00102
00103     QueryPerformanceFrequency(&liFreq);
00104     wprintf(TEXT("%0.4f seconds\n"),
00105         (float)(pliFinish->LowPart - pliStart->LowPart)/(float)liFreq.LowPart);
00106 }  // OutputTime
00107
00108 // ---------------------------------------------------------------------------
00109 // %%Function: main
00110 // ---------------------------------------------------------------------------
00111  void __cdecl
00112 main(int argc, CHAR **argv)
00113 {
00114     HRESULT hr;
00115     MULTI_QI    mq;
00116     COSERVERINFO csi, *pcsi=NULL;
00117     WCHAR wsz [MAX_PATH];
00118     ULONG cb = cbDefault;
00119     LARGE_INTEGER liStart, liFinish;
00120
00121     // allow a machine-name as the command-line argument
00122     if (argc > 1)
00123         {
00124         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, argv[1], -1,
00125             wsz, MAX_PATH);
00126         memset(&csi, 0, sizeof(COSERVERINFO));
00127         csi.pwszName = wsz;
00128         pcsi = &csi;
00129         }
00130
00131     // allow a byte-size to be passed on the command-line
00132     if (argc > 2)
00133         cb = atol(argv[2]);
00134
00135     // initialize COM for free-threaded use
00136     hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00137     if (FAILED(hr))
00138         {
00139         Message(TEXT("Client: CoInitializeEx"), hr);
00140         exit(hr);
00141         }
00142
00143     // create a remote instance of the object on the argv[1] machine
00144     Message(TEXT("Client: Creating Instance..."), S_OK);
00145     mq.pIID = &IID_IStream;
00146     mq.pItf = NULL;
00147     mq.hr = S_OK;
00148     QueryPerformanceCounter(&liStart);
00149     hr = CoCreateInstanceEx(CLSID_SimpleObject, NULL, CLSCTX_SERVER, pcsi, 1, &mq);
00150     QueryPerformanceCounter(&liFinish);
00151     OutputTime(&liStart, &liFinish);
00152
00153     if (FAILED(hr))
00154         Message(TEXT("Client: CoCreateInstanceEx"), hr);
00155     else
00156         {
00157         LPSTREAM    pstm = (IStream*)mq.pItf;
00158         LPVOID      pv;
00159
00160         // "read" some data from the object
00161         Message(TEXT("Client: Reading data..."), S_OK);
00162         pv = CoTaskMemAlloc(cb);
00163         QueryPerformanceCounter(&liStart);
00164         hr = pstm->Read(pv, cb, NULL);
00165         QueryPerformanceCounter(&liFinish);
00166         OutputTime(&liStart, &liFinish);
00167         if (FAILED(hr))
00168             Message(TEXT("Client: IStream::Read"), hr);
00169
00170         // "write" some data to the object
00171         Message(TEXT("Client: Writing data..."), S_OK);
00172         QueryPerformanceCounter(&liStart);
00173         hr = pstm->Write(pv, cb, NULL);
00174         QueryPerformanceCounter(&liFinish);
00175         OutputTime(&liStart, &liFinish);
00176         if (FAILED(hr))
00177             Message(TEXT("Client: IStream::Write"), hr);
00178
00179         // let go of the object
00180         pstm->Release();
00181         }
00182
00183     CoUninitialize();
00184     Message(TEXT("Client: Done"), S_OK);
00185 }  // main
00186
00187 // EOF =======================================================================
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagSHOWPROPERTIESMSG Member List

This is the complete list of members for _tagSHOWPROPERTIESMSG, including all inherited members.
hWndParent | _tagSHOWPROPERTIESMSG
ItemID | _tagSHOWPROPERTIESMSG
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Object_Property Member List

This is the complete list of members for Object_Property, including all inherited members.
m_Name | Object_Property
m_State | Object_Property
m_Type | Object_Property
m_Value | Object_Property
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CStorageBuffer Member List

This is the complete list of members for CStorageBuffer, including all inherited members.
Clone(IStream **ppstm) | CStorageBuffer |
Commit(DWORD grfCommitFlags) | CStorageBuffer |
CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) | CStorageBuffer |
CStorageBuffer() | CStorageBuffer |
Flush() | CStorageBuffer |
LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) | CStorageBuffer |
m_cMaxSize | CStorageBuffer | [private]
m_cRef | CStorageBuffer | [private]
m_iPos | CStorageBuffer | [private]
m_pBuffer | CStorageBuffer | [private]
QueryInterface(REFIID riid, LPVOID *ppv) | CStorageBuffer |
Read(void *pv, ULONG cb, ULONG *pcbRead) | CStorageBuffer |
ReadAt(ULARGE_INTEGER ulOffset, void *pv, ULONG cb, ULONG *pcbRead) | CStorageBuffer |
ReadBuffer(ULONG ulOffset, void *pv, ULONG cb, ULONG *pcbRead) | CStorageBuffer |
Revert() | CStorageBuffer |
Seek(LONG lOffset, DWORD dwOrigin=STREAM_SEEK_SET, ULONG *pulNewPosition=NULL) | CStorageBuffer |
Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) | CStorageBuffer |
SetSize(ULARGE_INTEGER libNewSize) | CStorageBuffer |
Stat(STATSTG *pstatstg, DWORD grfStatFlag) | CStorageBuffer |
STDMETHODIMP_(ULONG) AddRef() | CStorageBuffer |
STDMETHODIMP_(ULONG) Release() | CStorageBuffer |
UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) | CStorageBuffer |
Write(const void *pv, ULONG cb, ULONG *pcbWritten) | CStorageBuffer |
WriteAt(ULARGE_INTEGER ulOffset, const void *pv, ULONG cb, ULONG *pcbWritten) | CStorageBuffer |
WriteBuffer(ULONG ulOffset, const void *pv, ULONG cb, ULONG *pcbRead) | CStorageBuffer |
~CStorageBuffer() | CStorageBuffer | [virtual]
Generated on Wed Nov 13 2024 16:57:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/FrameworkProv/FrameworkProv.h Source File

  • SysMgmt
  • WMI
  • VC
  • FrameworkProv

FrameworkProv.h

Go to the documentation of this file.
00001 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00002 /******************************************************************
00003
00004    FrameworkProv.H -- WMI provider class definition
00005
00006    Generated by Microsoft WMI Code Generation Engine
00007
00008    Description:
00009    Sample provider using the Provider Framework
00010
00011 *******************************************************************/
00012
00013 // Property set identification
00014 //============================
00015
00016 #define PROVIDER_NAME_REINDEERPROV L"Reindeer"
00017
00018 // Property name externs -- defined in FrameworkProv.cpp
00019 //=================================================
00020
00021 extern const WCHAR* pName ;
00022 extern const WCHAR* pRedNose ;
00023 extern const WCHAR* pWeight ;
00024
00025 class CReindeer : public Provider
00026 {
00027   public:
00028     // Constructor/destructor
00029     //=======================
00030
00031     CReindeer(LPCWSTR chsClassName, LPCWSTR lpszNameSpace);
00032     virtual ~CReindeer();
00033
00034   protected:
00035     // Reading Functions
00036     //============================
00037     virtual HRESULT EnumerateInstances(MethodContext*  pMethodContext, long lFlags = 0L);
00038     virtual HRESULT GetObject(CInstance* pInstance, long lFlags = 0L);
00039     virtual HRESULT ExecQuery(MethodContext *pMethodContext, CFrameworkQuery& Query, long lFlags = 0L);
00040
00041     // Writing Functions
00042     //============================
00043     virtual HRESULT PutInstance(const CInstance& Instance, long lFlags = 0L);
00044     virtual HRESULT DeleteInstance(const CInstance& Instance, long lFlags = 0L);
00045
00046     // Other Functions
00047     virtual HRESULT ExecMethod( const CInstance& Instance,
00048             const BSTR bstrMethodName,
00049             CInstance *pInParams,
00050             CInstance *pOutParams,
00051             long lFlags = 0L );
00052
00053     // TO DO: Declare any additional functions and accessor
00054     // functions for private data used by this class
00055     //===========================================================
00056         HRESULT LoadPropertyValues( CInstance *pInstance, DWORD dwIndex, DWORD dwRequiredProperties);
00057
00058   private:
00059     // All data members for CReindeer should be included here.
00060         BOOL IsInList(const CHStringArray &asArray, LPCWSTR pszString);
00061         static HRESULT WINAPI StaticEnumerationCallback(Provider* pThat, CInstance* pInstance, MethodContext* pContext, void* pUserData);
00062         HRESULT EnumerationCallback(CInstance *pReindeer, MethodContext *pMethodContext, VOID *pTotWeight);
00063
00064 } ;
00065
00066 // struct to hold instance information
00067 struct Deers
00068 {
00069   WCHAR*    m_name; // name of Reindeer
00070   DWORD    m_weight;  // weight of reindeer
00071   bool     m_redNose; // does he have a red nose?
00072   bool     m_deleted; // has he been deleted?
00073
00074   enum {NDeers = 9};
00075 };
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

direct Member List

This is the complete list of members for direct, including all inherited members.
bScanned | direct
curdir | direct
directs | direct
diritems | direct
head | direct
parent | direct
pos | direct
relname | direct
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminCatalogObject Member List

This is the complete list of members for comadmin::COMAdminCatalogObject, including all inherited members.
clsid | comadmin::COMAdminCatalogObject | [static]
getKey() | comadmin::COMAdminCatalogObject |
getName() | comadmin::COMAdminCatalogObject |
getValid() | comadmin::COMAdminCatalogObject |
getValue(String bstrPropName) | comadmin::COMAdminCatalogObject |
iid | comadmin::COMAdminCatalogObject | [static]
IsPropertyReadOnly(String bstrPropName) | comadmin::COMAdminCatalogObject |
IsPropertyWriteOnly(String bstrPropName) | comadmin::COMAdminCatalogObject |
setValue(String bstrPropName, Variant retval) | comadmin::COMAdminCatalogObject |
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMShare/chWnd.Cpp Source File

  • Web
  • NetMeeting
  • NMShare

chWnd.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMSHARE.EXE
00003 //  File:       CHWND.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #include "precomp.h"
00017
00018 COBLIST * g_pListApp = (COBLIST *) NULL;
00019
00020
00021 //****************************************************************************
00022 //
00023 // int AddApp(INmSharableApp * pApp)
00024 //
00025 //****************************************************************************
00026
00027 int AddApp(INmSharableApp * pApp)
00028 {
00029   TCHAR sz[MAX_PATH + 1];
00030   ZeroMemory(sz,(MAX_PATH + 1) * sizeof(TCHAR));
00031   _sntprintf(sz,MAX_PATH,TEXT("%08X"), pApp);
00032
00033   //wsprintf(sz, TEXT("%08X"), pApp);
00034
00035   pApp->AddRef();
00036   AddNode(pApp, &g_pListApp);
00037
00038   LV_ITEM  lvItem;
00039   ClearStruct(&lvItem);
00040   lvItem.iItem = g_pListApp->GetItemCount();
00041   lvItem.mask = LVIF_PARAM | LVIF_TEXT;
00042   lvItem.pszText = sz;
00043   lvItem.cchTextMax = lstrlen(sz);
00044   lvItem.lParam = (LPARAM) pApp;
00045   return ListView_InsertItem(ghwndApp, &lvItem);
00046 }
00047
00048
00049 //****************************************************************************
00050 //
00051 // int ItemFromPApp(INmSharableApp * pApp)
00052 //
00053 //****************************************************************************
00054
00055 int ItemFromPApp(INmSharableApp * pApp)
00056 {
00057   if (NULL == ghwndApp)
00058     return -1;
00059
00060   LV_FINDINFO findInfo;
00061   ClearStruct(&findInfo);
00062   findInfo.flags = LVFI_PARAM;
00063     findInfo.lParam = (LPARAM) pApp;
00064     return ListView_FindItem(ghwndApp, -1, &findInfo);
00065 }
00066
00067
00068 //****************************************************************************
00069 //
00070 // VOID FreeAllApps(void)
00071 //
00072 //****************************************************************************
00073
00074 VOID FreeAllApps(void)
00075 {
00076   if (NULL != g_pListApp)
00077   {
00078     while (!g_pListApp->IsEmpty())
00079     {
00080       INmSharableApp * pApp = (INmSharableApp *) g_pListApp->RemoveHead();
00081       ASSERT(NULL != pApp);
00082       pApp->Release();
00083     }
00084   }
00085 }
00086
00087
00088 //****************************************************************************
00089 //
00090 // VOID UpdateApp(INmSharableApp * pApp)
00091 //
00092 //****************************************************************************
00093
00094 VOID UpdateApp(INmSharableApp * pApp)
00095 {
00096   HRESULT hr = S_OK;
00097   LPTSTR  psz = NULL;
00098   BSTR    bstr;
00099
00100   HWND    hwnd = 0;
00101   int     iItem = 0;
00102   NM_SHAPP_STATE uState;
00103
00104   iItem = ItemFromPApp(pApp);
00105   if (-1 == iItem)
00106   {
00107     iItem = AddApp(pApp);
00108     if (-1 == iItem)
00109       return;
00110   }
00111
00112   hr = pApp->GetHwnd(&hwnd);
00113   if (SUCCEEDED(hr))
00114   {
00115     TCHAR sz[MAX_PATH + 1];
00116     ZeroMemory(sz,(MAX_PATH + 1) * sizeof(TCHAR));
00117     _sntprintf(sz,MAX_PATH,TEXT("%08X"), hwnd);
00118
00119     //TCHAR sz[MAX_PATH];
00120     //wsprintf(sz, TEXT("%08X"), hwnd);
00121     ListView_SetItemText(ghwndApp, iItem, ILV_HWND, sz);
00122   }
00123
00124   hr = pApp->GetState(&uState);
00125   if (SUCCEEDED(hr))
00126   {
00127     ListView_SetItemText(ghwndApp, iItem, ILV_STATUS,
00128       (NM_SHAPP_SHARED == uState) ? TEXT("Shared") : TEXT("Not Shared"));
00129   }
00130
00131   hr = pApp->GetName(&bstr);
00132   if (SUCCEEDED(hr))
00133   {
00134     psz = PszFromBstr(bstr);
00135     SysFreeString(bstr);
00136
00137     ListView_SetItemText(ghwndApp, iItem, ILV_NAME, psz);
00138     FreePlpv(&psz);
00139   }
00140 }
00141
00142
00143 //****************************************************************************
00144 //
00145 // VOID UpdateAppList(void)
00146 //
00147 //****************************************************************************
00148
00149 VOID UpdateAppList(void)
00150 {
00151   // Update all apps
00152   // - enumerate all
00153   // - ensure all are in list
00154   // - check data for each
00155 }
00156
00157
00158 //****************************************************************************
00159 //
00160 // LRESULT MsgNotifyAppList(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00161 //
00162 //****************************************************************************
00163
00164 LRESULT MsgNotifyAppList(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00165 {
00166   LV_DISPINFO *pLvdi = (LV_DISPINFO *)lParam;
00167
00168   switch(pLvdi->hdr.code)
00169   {
00170     case NM_DBLCLK:
00171     case NM_RETURN:
00172     {
00173       HRESULT hr = S_OK;
00174       NM_SHAPP_STATE uState;
00175
00176       int iItem = ListView_GetNextItem(ghwndApp, -1, LVNI_ALL | LVNI_SELECTED);
00177       if (-1 == iItem)
00178         break;
00179
00180       LV_ITEM lvi;
00181       ClearStruct(&lvi);
00182       lvi.iItem = iItem;
00183       lvi.mask = LVIF_PARAM;
00184       if (!ListView_GetItem(ghwndApp, &lvi))
00185         break;
00186
00187       INmSharableApp * pApp = (INmSharableApp *) lvi.lParam;
00188       ASSERT(NULL != pApp);
00189       hr = pApp->GetState(&uState);
00190       if (FAILED(hr))
00191         break;
00192
00193       if (NM_SHAPP_NOT_SHARED == uState)
00194         uState = NM_SHAPP_SHARED;
00195       else
00196         uState = NM_SHAPP_NOT_SHARED;
00197
00198       hr = pApp->SetState(uState);
00199       break;
00200     }
00201     default:
00202       break;
00203   }
00204
00205   return 0;
00206 }
00207
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Fields15.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Fields15.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Fields15
00019 /** @com.interface(iid=00000506-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Fields15 extends msado15._Collection
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=PROPGET, name="Count", name2="getCount", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int getCount();
00025
00026   /** @com.method(vtoffset=5, dispid=4294967292, type=METHOD, name="_NewEnum", addFlagsVtable=4)
00027       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00028   public IUnknown _NewEnum();
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=METHOD, name="Refresh", addFlagsVtable=4)
00031       @com.parameters() */
00032   public void Refresh();
00033
00034   /** @com.method(vtoffset=7, dispid=0, type=PROPGET, name="Item", name2="getItem", addFlagsVtable=4)
00035       @com.parameters([in,type=VARIANT] Index, [iid=0000054C-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00036   public msado15.Field getItem(Variant Index);
00037
00038
00039   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x506, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00040 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAppShareNotify Member List

This is the complete list of members for CAppShareNotify, including all inherited members.
AddRef(void) | CAppShareNotify |
AddRef(void) | CAppShareNotify |
RefCount::AddRef(void) | RefCount |
CAppShareNotify() | CAppShareNotify |
CAppShareNotify() | CAppShareNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
Connect(IUnknown *pUnk) | CAppShareNotify |
Connect(IUnknown *pUnk) | CAppShareNotify |
CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Disconnect(void) | CAppShareNotify |
Disconnect(void) | CAppShareNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CAppShareNotify |
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CAppShareNotify |
NmUI(CONFN uNotify) | CAppShareNotify |
NmUI(CONFN uNotify) | CAppShareNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CAppShareNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CAppShareNotify |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
Release(void) | CAppShareNotify |
Release(void) | CAppShareNotify |
RefCount::Release(void) | RefCount |
StateChanged(NM_SHAPP_STATE uNotify, INmSharableApp *pApp) | CAppShareNotify |
StateChanged(NM_SHAPP_STATE uState, INmSharableApp *pApp) | CAppShareNotify |
~CAppShareNotify() | CAppShareNotify |
~CAppShareNotify() | CAppShareNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
Generated on Wed Nov 13 2024 16:55:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPidlMgr Member List

This is the complete list of members for CPidlMgr, including all inherited members.
Concatenate(LPCITEMIDLIST, LPCITEMIDLIST) | CPidlMgr |
Copy(LPCITEMIDLIST) | CPidlMgr |
CopySingleItem(LPCITEMIDLIST) | CPidlMgr |
CPidlMgr() | CPidlMgr |
Create(VOID) | CPidlMgr | [private]
CreateFolderPidl(LPCTSTR) | CPidlMgr |
CreateItemPidl(LPCTSTR, LPCTSTR) | CPidlMgr |
Delete(LPITEMIDLIST) | CPidlMgr |
GetData(LPCITEMIDLIST, LPTSTR, DWORD) | CPidlMgr |
GetDataPointer(LPCITEMIDLIST) | CPidlMgr | [inline, private]
GetLastItem(LPCITEMIDLIST) | CPidlMgr |
GetName(LPCITEMIDLIST, LPTSTR, DWORD) | CPidlMgr |
GetNextItem(LPCITEMIDLIST) | CPidlMgr |
GetRelativeName(LPCITEMIDLIST, LPTSTR, DWORD) | CPidlMgr |
GetSize(LPCITEMIDLIST) | CPidlMgr |
IsFolder(LPCITEMIDLIST) | CPidlMgr |
m_pMalloc | CPidlMgr | [private]
SetData(LPCITEMIDLIST, LPCTSTR) | CPidlMgr |
~CPidlMgr() | CPidlMgr |
Generated on Wed Nov 13 2024 16:57:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/PoolTest.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest

PoolTest.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: PoolTest.cpp
00004
00005 Summary: Implementation of WinMain
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021
00022 // Note: Proxy/Stub Information
00023 //      To build a separate proxy/stub DLL,
00024 //      run nmake -f PoolTestps.mk in the project directory.
00025
00026 #include "stdafx.h"
00027 #include "resource.h"
00028 #include "PoolTest.h"
00029 #include "testdlg.h"
00030
00031 CComModule _Module;
00032
00033 // dummy object map for ATL
00034 BEGIN_OBJECT_MAP(ObjectMap)
00035 END_OBJECT_MAP()
00036
00037 /////////////////////////////////////////////////////////////////////////////
00038 //
00039 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00040     HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
00041 {
00042
00043     HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00044     _ASSERTE(SUCCEEDED(hRes));
00045
00046     _Module.Init(NULL, hInstance);
00047
00048   // show our dialog
00049   CTestDlg *dlg = new CTestDlg;
00050   dlg->DoModal();
00051   delete dlg;
00052
00053   CoUninitialize();
00054
00055     _Module.Term();
00056     return 0;
00057 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Field15.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Field15.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Field15
00019 /** @com.interface(iid=00000505-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Field15 extends msado15._ADO
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=1109, type=PROPGET, name="ActualSize", name2="getActualSize", addFlagsVtable=4)
00027       @com.parameters([type=I4] return) */
00028   public int getActualSize();
00029
00030   /** @com.method(vtoffset=6, dispid=1036, type=PROPGET, name="Attributes", name2="getAttributes", addFlagsVtable=4)
00031       @com.parameters([type=I4] return) */
00032   public int getAttributes();
00033
00034   /** @com.method(vtoffset=7, dispid=1103, type=PROPGET, name="DefinedSize", name2="getDefinedSize", addFlagsVtable=4)
00035       @com.parameters([type=I4] return) */
00036   public int getDefinedSize();
00037
00038   /** @com.method(vtoffset=8, dispid=1100, type=PROPGET, name="Name", name2="getName", addFlagsVtable=4)
00039       @com.parameters([type=STRING] return) */
00040   public String getName();
00041
00042   /** @com.method(vtoffset=9, dispid=1102, type=PROPGET, name="Type", name2="getType", addFlagsVtable=4)
00043       @com.parameters([type=I4] return) */
00044   public int getType();
00045
00046   /** @com.method(vtoffset=10, dispid=0, type=PROPGET, name="Value", name2="getValue", addFlagsVtable=4)
00047       @com.parameters([type=VARIANT] return) */
00048   public Variant getValue();
00049
00050   /** @com.method(vtoffset=11, dispid=0, type=PROPPUT, name="Value", name2="putValue", addFlagsVtable=4)
00051       @com.parameters([in,type=VARIANT] pvar) */
00052   public void setValue(Variant pvar);
00053
00054   /** @com.method(vtoffset=12, dispid=1610809351, type=PROPGET, name="Precision", name2="getPrecision", addFlagsVtable=4)
00055       @com.parameters([type=U1] return) */
00056   public byte getPrecision();
00057
00058   /** @com.method(vtoffset=13, dispid=1610809352, type=PROPGET, name="NumericScale", name2="getNumericScale", addFlagsVtable=4)
00059       @com.parameters([type=U1] return) */
00060   public byte getNumericScale();
00061
00062   /** @com.method(vtoffset=14, dispid=1107, type=METHOD, name="AppendChunk", addFlagsVtable=4)
00063       @com.parameters([in,type=VARIANT] Data) */
00064   public void AppendChunk(Variant Data);
00065
00066   /** @com.method(vtoffset=15, dispid=1108, type=METHOD, name="GetChunk", addFlagsVtable=4)
00067       @com.parameters([in,type=I4] Length, [type=VARIANT] return) */
00068   public Variant GetChunk(int Length);
00069
00070   /** @com.method(vtoffset=16, dispid=1104, type=PROPGET, name="OriginalValue", name2="getOriginalValue", addFlagsVtable=4)
00071       @com.parameters([type=VARIANT] return) */
00072   public Variant getOriginalValue();
00073
00074   /** @com.method(vtoffset=17, dispid=1105, type=PROPGET, name="UnderlyingValue", name2="getUnderlyingValue", addFlagsVtable=4)
00075       @com.parameters([type=VARIANT] return) */
00076   public Variant getUnderlyingValue();
00077
00078
00079   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x505, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00080 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook ServerEx/ResProp.h Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook ServerEx

ResProp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ResProp.h
00007 //
00008 //  Implementation File:
00009 //      ResProp.cpp
00010 //
00011 //  Description:
00012 //      Definition of the resource extension property page classes.
00013 //
00014 //  Author:
00015 //      <name> (<e-mail name>) Mmmm DD, 2003
00016 //
00017 //  Revision History:
00018 //
00019 //  Notes:
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 #pragma once
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Include Files
00027 /////////////////////////////////////////////////////////////////////////////
00028
00029 #ifndef _BASEPAGE_H_
00030 #include "BasePage.h"   // for CBasePropertyPage
00031 #endif
00032
00033 #ifndef _PROPLIST_H_
00034 #include "PropList.h"   // for CObjectPropert
00035 #endif
00036
00037 /////////////////////////////////////////////////////////////////////////////
00038 // Forward Class Declarations
00039 /////////////////////////////////////////////////////////////////////////////
00040
00041 class CClipBookServerParamsPage;
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // External Class Declarations
00045 /////////////////////////////////////////////////////////////////////////////
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 //
00049 //  CClipBookServerParamsPage
00050 //
00051 //  Purpose:
00052 //      Parameters page for resources.
00053 //
00054 /////////////////////////////////////////////////////////////////////////////
00055
00056 class CClipBookServerParamsPage
00057     : public CBasePropertyPage
00058 {
00059     DECLARE_DYNCREATE( CClipBookServerParamsPage )
00060
00061 //
00062 //  Construction
00063 //
00064
00065 public:
00066     CClipBookServerParamsPage( void );
00067
00068 //
00069 //  Dialog Data
00070 //
00071
00072     //{{AFX_DATA(CClipBookServerParamsPage)
00073     enum { IDD = IDD_PP_CLIPBOOKSERVER_PARAMETERS };
00074     //}}AFX_DATA
00075
00076 protected:
00077
00078 // Overrides
00079     // ClassWizard generate virtual function overrides
00080     //{{AFX_VIRTUAL(CClipBookServerParamsPage)
00081     public:
00082     virtual BOOL OnSetActive();
00083     protected:
00084     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00085     //}}AFX_VIRTUAL
00086
00087 protected:
00088     virtual const CObjectProperty * Pprops( void ) const    { return NULL; }
00089     virtual DWORD                   Cprops( void ) const    { return 0; }
00090
00091 //
00092 //  Implementation
00093 //
00094
00095 protected:
00096     BOOL    BAllRequiredFieldsPresent( void ) const;
00097
00098     // Generated message map functions
00099     //{{AFX_MSG(CClipBookServerParamsPage)
00100     virtual BOOL OnInitDialog();
00101     afx_msg void OnChangeRequiredField();
00102     //}}AFX_MSG
00103     DECLARE_MESSAGE_MAP()
00104
00105 };  //*** class CClipBookServerParamsPage
00106
00107 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CApplet Member List

This is the complete list of members for CApplet, including all inherited members.
AddRef(void) | CApplet |
Advise(void) | CApplet | [inline]
AutoJoinSessionIndication(IAppletSession *pSession, HRESULT hrResult, AppletUserID uidMyself, AppletNodeID nidMyself, AppletSessionID sidMyself, AppletEntityID eidMyself, ULONG cDynamicChannels, AppletChannelID aDynamicChannels[]) | CApplet |
CApplet(IApplet *pIApplet) | CApplet |
CRefCount() | CRefCount |
m_dwCookie | CApplet | [private]
m_pIApplet | CApplet | [private]
PermitToJoinSessionIndication(AppletConfID nConfID, BOOL fPermissionGranted) | CApplet |
QueryInterface(REFIID riid, void **ppvObj) | CApplet |
Release(void) | CApplet |
UnAdvise(void) | CApplet | [inline]
~CApplet(void) | CApplet |
~CRefCount() | CRefCount | [virtual]
Generated on Wed Nov 13 2024 16:55:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/table.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

table.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1995-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module TABLE.H
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////////
00015 #include "winmain.h"
00016 #include "common.h"
00017 #include "tablecopy.h"
00018 #include "table.h"
00019 #include "wizard.h"
00020 #include "progress.h"
00021
00022
00023 //////////////////////////////////////////////////////////////////////////////
00024 // Defines / Macros
00025 //
00026 //////////////////////////////////////////////////////////////////////////////
00027 #define NO_MATCH          0x0000
00028 #define MATCH_EXACT         0x0001
00029 #define MATCH_TYPE          0x0002
00030 #define MATCH_SIZE          0x0004
00031 #define MATCH_DEFAULT       0x0008
00032
00033
00034
00035 /////////////////////////////////////////////////////////////////
00036 // CTable::CTable
00037 //
00038 /////////////////////////////////////////////////////////////////
00039 CTable::CTable(CWizard* pCWizard)
00040 {
00041   ASSERT(pCWizard);
00042
00043   m_wszIDQuote[0]     = EOL;
00044   m_wszIDSeperator[0]   = EOL;
00045
00046   //TableInfo
00047   memset(&m_TableInfo, 0, sizeof(TABLEINFO));
00048   m_wszQualTableName[0] = EOL;
00049
00050   //IndexInfo
00051   m_cIndexes    = 0;    // Count of indexes
00052   m_rgIndexInfo = NULL;   // Index information
00053
00054   //ColumnInfo
00055   m_cColumns    = 0;    // Count of columns
00056   m_rgColDesc   = NULL;   // Column information
00057
00058   //DataSource
00059   m_pCDataSource  = new CDataSource;
00060   m_pCWizard    = pCWizard;     // Back pointer to Windowing class
00061
00062   //Rowset
00063   m_pIAccessor  = NULL;
00064   m_pIRowset    = NULL;
00065 }
00066
00067
00068 /////////////////////////////////////////////////////////////////
00069 // CTable::~CTable
00070 //
00071 /////////////////////////////////////////////////////////////////
00072 CTable::~CTable()
00073 {
00074   delete m_pCDataSource;
00075
00076   SAFE_FREE(m_rgIndexInfo);
00077   SAFE_FREE(m_rgColDesc);
00078
00079   //Rowset
00080   SAFE_RELEASE(m_pIAccessor);
00081   SAFE_RELEASE(m_pIRowset);
00082 }
00083
00084
00085 /////////////////////////////////////////////////////////////////
00086 // BOOL CTable::Connect
00087 //
00088 /////////////////////////////////////////////////////////////////
00089 BOOL CTable::Connect(HWND hWnd, CDataSource* pCDataSource)
00090 {
00091   ASSERT(m_pCDataSource);
00092
00093   HRESULT hr = m_pCDataSource->Connect(hWnd, m_pCDataSource);
00094   if (SUCCEEDED(hr) && (REGDB_E_CLASSNOTREG != hr))
00095   {
00096     //Get LiteralInfo for this table
00097     GetLiteralInfo();
00098     return TRUE;
00099   }
00100
00101   return FALSE;
00102 }
00103
00104
00105 /////////////////////////////////////////////////////////////////
00106 // BOOL CTable::IsConnected
00107 //
00108 /////////////////////////////////////////////////////////////////
00109 BOOL CTable::IsConnected()
00110 {
00111   ASSERT(m_pCDataSource);
00112   return m_pCDataSource->IsConnected();
00113 }
00114
00115
00116 /////////////////////////////////////////////////////////////////
00117 // HRESULT CTable::GetLiteralInfo
00118 //
00119 /////////////////////////////////////////////////////////////////
00120 HRESULT CTable::GetLiteralInfo()
00121 {
00122   ASSERT(m_pCDataSource);
00123   ASSERT(m_pCDataSource->m_pIDBInitialize);
00124
00125   HRESULT hr;
00126
00127   const static ULONG cLiterals = 2;
00128   const static DBLITERAL rgLiterals[cLiterals] = {DBLITERAL_QUOTE, DBLITERAL_CATALOG_SEPARATOR};
00129
00130   IDBInfo* pIDBInfo = NULL;
00131
00132   ULONG cLiteralInfo = 0;
00133   DBLITERALINFO* rgLiteralInfo = NULL;
00134   WCHAR* pwszCharBuffer = NULL;
00135
00136   //Reset Info
00137   m_wszIDQuote[0] = EOL;
00138   m_wszIDSeperator[0] = EOL;
00139
00140   //Obtain IDBInfo interface
00141   //Some providers may not support IDBInfo so don't display dialog
00142   QTESTC(hr = m_pCDataSource->m_pIDBInitialize->QueryInterface(IID_IDBInfo, (void **)&pIDBInfo));
00143
00144   //GetLiteralInfo
00145   //Can return an error for unsupported literals
00146   hr = pIDBInfo->GetLiteralInfo(cLiterals, rgLiterals, &cLiteralInfo, &rgLiteralInfo, &pwszCharBuffer);
00147
00148   //DBLITERAL_QUOTE
00149   if(rgLiteralInfo && rgLiteralInfo[0].fSupported)
00150     wcscpy(m_wszIDQuote, rgLiteralInfo[0].pwszLiteralValue);
00151
00152   //DBLITERAL_CATALOG_SEPARATOR
00153   if(rgLiteralInfo && rgLiteralInfo[1].fSupported)
00154     wcscpy(m_wszIDSeperator, rgLiteralInfo[1].pwszLiteralValue);
00155
00156
00157 CLEANUP:
00158   SAFE_RELEASE(pIDBInfo);
00159   SAFE_FREE(rgLiteralInfo);
00160   SAFE_FREE(pwszCharBuffer);
00161   return hr;
00162 }
00163
00164
00165
00166 /////////////////////////////////////////////////////////////////
00167 // BOOL CTable::GetQuotedID
00168 //
00169 /////////////////////////////////////////////////////////////////
00170 BOOL CTable::GetQuotedID(WCHAR* pwszOutBuff, WCHAR* pwszInBuff)
00171 {
00172   WCHAR pwsz[MAX_NAME_LEN*2];
00173   WCHAR* pwszItr = pwsz;
00174
00175   ULONG cQuoteLen = wcslen(m_wszIDQuote);
00176   ULONG cSepLen = wcslen(m_wszIDSeperator);
00177   ULONG cPeriodLen= wcslen(wsz_PERIOD);
00178
00179   //No-op case
00180   //If the provider doesn't have a delimiter, then just use input name.
00181   if(cQuoteLen == 0)
00182   {
00183     wcscpy(pwszOutBuff, pwszInBuff);
00184     return (TRUE);
00185   }
00186
00187   //Put on front delimeter
00188   wcscpy(pwszItr, m_wszIDQuote);
00189   pwszItr += cQuoteLen;
00190
00191   //Copy from Source to Temp
00192   while(*pwszInBuff!=EOL)
00193   {
00194     //If we have a seperator char, we need to quote both pieces
00195     if(wcsncmp(pwszInBuff, m_wszIDSeperator, cSepLen)==0)
00196     {
00197       // "nstl@odbc.authors -> "nstl"@"odbc.authors"
00198       wcscat(pwszItr, m_wszIDQuote);    //Ending Quote
00199       wcscat(pwszItr, m_wszIDSeperator);  //Seperator
00200       wcscat(pwszItr, m_wszIDQuote);    //Beginning Quote
00201       pwszItr += cQuoteLen + cSepLen + cQuoteLen;
00202     }
00203     else if(*pwszInBuff == L'.')
00204     {
00205       // "nstl@odbc.authors -> "nstl@odbc"."authors"
00206       wcscat(pwszItr, m_wszIDQuote);    //Ending Quote
00207       wcscat(pwszItr, wsz_PERIOD);    //Period
00208       wcscat(pwszItr, m_wszIDQuote);    //Beginning Quote
00209       pwszItr += cQuoteLen + cPeriodLen + cQuoteLen;
00210     }
00211     else
00212     {
00213       *pwszItr = *pwszInBuff;     //Actual Character
00214       pwszItr++;
00215     }
00216
00217     pwszInBuff++;
00218     *pwszItr = EOL;
00219   }
00220
00221   //Put on the Tail delimeter
00222   wcscat(pwszItr, m_wszIDQuote);
00223
00224   //Give back to the user
00225   wcscpy(pwszOutBuff, pwsz);
00226   return TRUE;
00227 }
00228
00229
00230
00231 /////////////////////////////////////////////////////////////////
00232 // HRESULT CTable::GetTypeNameAndParams
00233 //
00234 /////////////////////////////////////////////////////////////////
00235 HRESULT CTable::GetTypeNameAndParams(ULONG iCol, WCHAR* pwszName)
00236 {
00237   ASSERT(iCol < m_cColumns);
00238   ASSERT(pwszName);
00239
00240   WCHAR  wszBuffer[MAX_NAME_LEN];  // Buffer
00241
00242   // Add CreateParams precision and scale information
00243   wszBuffer[0] = EOL;
00244   if(m_rgColDesc[iCol].ulCreateParams & CP_PRECISION && m_rgColDesc[iCol].ulCreateParams & CP_SCALE)
00245   {
00246     swprintf(wszBuffer, L"(%lu,%lu)", COLINFO_SIZE(m_rgColDesc[iCol]), m_rgColDesc[iCol].bScale);
00247   }
00248   else if(m_rgColDesc[iCol].ulCreateParams & CP_PRECISION || m_rgColDesc[iCol].ulCreateParams & CP_LENGTH || m_rgColDesc[iCol].ulCreateParams & CP_MAXLENGTH)
00249   {
00250     swprintf(wszBuffer, L"(%lu)", COLINFO_SIZE(m_rgColDesc[iCol]));
00251   }
00252
00253   //Add the ColumnType
00254   //Check for "()" in the typename, indicating creation params
00255   //are required at some other position besides the end, ie: "numeric() identity"
00256   pwszName[0] = EOL;
00257   if(wcsstr(m_rgColDesc[iCol].wszTypeName, L"()"))
00258   {
00259     // Add the ColumnType, upto the '()'
00260     wcsncat(pwszName, m_rgColDesc[iCol].wszTypeName, wcsstr(m_rgColDesc[iCol].wszTypeName, L"()") - m_rgColDesc[iCol].wszTypeName);
00261
00262     // Add the precision and scale information
00263     wcscat(pwszName, wszBuffer);
00264
00265     // Add the ColumnType, after the '()'
00266     wcscat(pwszName, wcsstr(m_rgColDesc[iCol].wszTypeName, L"()") + 2);
00267   }
00268   else
00269   {
00270     // Add the ColumnType
00271     wcscpy(pwszName, m_rgColDesc[iCol].wszTypeName);
00272
00273     // If required, add the precision and scale information
00274     wcscat(pwszName, wszBuffer);
00275   }
00276
00277   return S_OK;
00278 }
00279
00280
00281
00282 /////////////////////////////////////////////////////////////////
00283 // HRESULT CTable::GetColInfo
00284 //
00285 /////////////////////////////////////////////////////////////////
00286 HRESULT CTable::GetColInfo(DWORD dwInsertOpt)
00287 {
00288   HRESULT hr;
00289
00290   ULONG i,cColumns = 0;
00291   DBCOLUMNINFO* rgColInfo = NULL;
00292   WCHAR*  rgStringBuffer = NULL;
00293   IColumnsInfo* pIColumnsInfo = NULL;
00294
00295   //Obtain the rowset (m_pIRowset);
00296   QTESTC(hr = GetRowset(dwInsertOpt));
00297   CHECKC(m_pIRowset);
00298
00299   //Now finally GetColInfo
00300   XTESTC(hr = m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&pIColumnsInfo));
00301   XTESTC(hr = pIColumnsInfo->GetColumnInfo(&cColumns, &rgColInfo, &rgStringBuffer));
00302
00303   //Alloc room for the COLDESC
00304   SAFE_FREE(m_rgColDesc);
00305   SAFE_ALLOC(m_rgColDesc, COLDESC, cColumns);
00306   memset(m_rgColDesc, 0, cColumns*sizeof(COLDESC));
00307
00308   //Loop through the ColInfo and Copy to our ColDesc
00309   m_cColumns = 0;
00310   for(i=0; i<cColumns; i++)
00311   {
00312     //ignore Bookmark columns
00313     if(rgColInfo[i].iOrdinal == 0)
00314       continue;
00315
00316     //DBCOLUMNINFO pwszName
00317     if(rgColInfo[i].pwszName==NULL)
00318     {
00319         //Although ColInfo is allowed to return NULL for unknown column names
00320       //TableCopy needs column names for many operations,
00321       //(CREATE TABLE, INSERT, INDEXES), so just "generate" one
00322       swprintf(m_rgColDesc[m_cColumns].wszColName, L"Unknown%d", i);
00323     }
00324     else
00325     {
00326       wcscpy(m_rgColDesc[m_cColumns].wszColName, rgColInfo[i].pwszName);
00327     }
00328
00329     //Now copy the rest of the info
00330     m_rgColDesc[m_cColumns].iOrdinal    = rgColInfo[i].iOrdinal;
00331     m_rgColDesc[m_cColumns].ulColumnSize  = rgColInfo[i].ulColumnSize;
00332     m_rgColDesc[m_cColumns].wType     = rgColInfo[i].wType;
00333     m_rgColDesc[m_cColumns].dwFlags     = rgColInfo[i].dwFlags;
00334     m_rgColDesc[m_cColumns].bPrecision    = rgColInfo[i].bPrecision;
00335     m_rgColDesc[m_cColumns].bScale      = rgColInfo[i].bScale;
00336     m_cColumns++;
00337   }
00338
00339
00340 CLEANUP:
00341   SAFE_RELEASE(pIColumnsInfo);
00342   SAFE_FREE(rgColInfo);
00343   SAFE_FREE(rgStringBuffer);
00344   return hr;
00345 }
00346
00347
00348
00349 /////////////////////////////////////////////////////////////////
00350 // HRESULT CTable::GetTypeInfo
00351 //
00352 /////////////////////////////////////////////////////////////////
00353 HRESULT CTable::GetTypeInfo()
00354 {
00355   ASSERT(m_pCDataSource);
00356   HRESULT hr;
00357
00358   IRowset*  pIRowset = NULL;
00359   IAccessor*  pIAccessor = NULL;
00360   HACCESSOR hAccessor = DB_NULL_HACCESSOR;
00361
00362   ULONG   i;
00363   ULONG   cRowsObtained = 0;
00364   HROW*   rghRows = NULL;
00365
00366   //Current SchemaInfo for each type, until we find the correct match
00367   TYPEINFO TypeInfo;
00368   TYPEINFO* rgTypeInfo = NULL;
00369   ULONG* rgMatch = NULL;
00370
00371   //Arrays to store best TypeInfo
00372   SAFE_ALLOC(rgTypeInfo, TYPEINFO, m_cColumns);
00373   SAFE_ALLOC(rgMatch, ULONG, m_cColumns);
00374   memset(rgMatch, NO_MATCH, m_cColumns*sizeof(ULONG));
00375
00376   //Get ProviderTypes rowset IDBSchemaRowset
00377   QTESTC(hr = GetTypeInfoRowset(&pIAccessor, &hAccessor, &pIRowset));
00378
00379   //Loop over all the Schema TypeInfo rowset
00380   //And match up with ColInfo
00381   while(TRUE)
00382   {
00383     XTESTC(hr = pIRowset->GetNextRows(NULL,0,MAX_BLOCK_SIZE,&cRowsObtained, &rghRows));
00384
00385     //ENDOFROWSET
00386     if(cRowsObtained==0)
00387       break;
00388
00389     //Loop over the BLOCK of rows obtained
00390     for(i=0; i<cRowsObtained; i++)
00391     {
00392       //Reset all the TypeInfo fields
00393       memset(&TypeInfo, 0, sizeof(TYPEINFO));
00394
00395       //Put the data for one type into the TypeInfo Struct
00396       XTESTC(hr = pIRowset->GetData(rghRows[i],hAccessor, (void*)&TypeInfo));
00397
00398       //Loop over all the columns and see if they match this type
00399       for(ULONG iCol=0; iCol<m_cColumns; iCol++)
00400       {
00401         ASSERT(m_rgColDesc);
00402
00403         //Only try matching if this is the correct type and
00404         //the column doesn't already have a perfect match
00405         if(TypeInfo.wType != m_rgColDesc[iCol].wType || (rgMatch[iCol] & MATCH_EXACT))
00406           continue;
00407
00408         //A Nullable type cannot be mapped to a non-Nullable type
00409         if(m_rgColDesc[iCol].fIsNullable && !TypeInfo.fIsNullable)
00410           continue;
00411
00412         //If never matched before, we at least know they match by type
00413         if(!rgMatch[iCol])
00414         {
00415           rgMatch[iCol] |= MATCH_TYPE;
00416           rgTypeInfo[iCol] = TypeInfo;
00417         }
00418
00419         // Exact type/size matches take precedence
00420         if(COLINFO_SIZE(m_rgColDesc[iCol]) == TypeInfo.ulColumnSize)
00421         {
00422           rgMatch[iCol] |= MATCH_EXACT;
00423           rgTypeInfo[iCol] = TypeInfo;
00424         }
00425
00426         // Otherwise try best fit size
00427         if(COLINFO_SIZE(m_rgColDesc[iCol]) < TypeInfo.ulColumnSize &&
00428           TypeInfo.ulColumnSize <= rgTypeInfo[iCol].ulColumnSize)
00429         {
00430           rgMatch[iCol] |= MATCH_SIZE;
00431           rgTypeInfo[iCol] = TypeInfo;
00432         }
00433       }
00434     }
00435
00436     //Release this group of rows
00437     XTESTC(hr = pIRowset->ReleaseRows(cRowsObtained,rghRows,NULL,NULL,NULL));
00438     SAFE_FREE(rghRows);
00439   }
00440
00441   //Now that we have the TypeInfo matched, fill in our ColDesc struct
00442   for(i=0; i<m_cColumns; i++)
00443   {
00444     ASSERT(m_rgColDesc);
00445     if(rgMatch[i])
00446     {
00447       //TYPEINFO
00448       wcscpy(m_rgColDesc[i].wszTypeName, rgTypeInfo[i].wszTypeName);
00449       m_rgColDesc[i].ulCreateParams = GetCreateParams(rgTypeInfo[i].wszCreateParams);
00450       m_rgColDesc[i].fIsNullable    = rgTypeInfo[i].fIsNullable == VARIANT_TRUE;
00451       m_rgColDesc[i].fIsAutoInc   = rgTypeInfo[i].fIsAutoInc == VARIANT_TRUE;
00452     }
00453     else
00454     {
00455       wMessageBox(NULL, MB_TASKMODAL | MB_ICONEXCLAMATION | MB_OK, wsz_ERROR,
00456         wsz_NO_TYPE_FOUND_, GetDBTypeName(m_rgColDesc[i].wType));
00457     }
00458   }
00459
00460
00461 CLEANUP:
00462   if(hAccessor && pIAccessor)
00463     XTEST(pIAccessor->ReleaseAccessor(hAccessor,NULL));
00464
00465   SAFE_RELEASE(pIAccessor);
00466   SAFE_RELEASE(pIRowset);
00467
00468   SAFE_FREE(rgMatch);
00469   SAFE_FREE(rgTypeInfo);
00470
00471   SAFE_FREE(rghRows);
00472   return hr;
00473 }
00474
00475
00476 /////////////////////////////////////////////////////////////////
00477 // HRESULT CTable::MapTableInfo
00478 //
00479 /////////////////////////////////////////////////////////////////
00480 HRESULT CTable::MapTableInfo(CTable* pCSourceTable)
00481 {
00482   ASSERT(pCSourceTable);
00483   ASSERT(m_pCDataSource);
00484   HRESULT hr;
00485
00486   IAccessor* pIAccessor = NULL;
00487   HACCESSOR  hAccessor = DB_NULL_HACCESSOR;
00488
00489   IRowset* pIRowset = NULL;
00490
00491   ULONG cRowsObtained = 0;
00492   HROW* rghRows = NULL;
00493
00494   //Match bitmask, indicating what type of match was found
00495   BOOL fMatchedAll = FALSE;
00496
00497   TYPEINFO TypeInfo;
00498   TYPEINFO* rgTypeInfo = NULL;
00499   ULONG* rgMatch = NULL;
00500
00501   //ColumnInfo
00502   m_cColumns  = pCSourceTable->m_cColumns;
00503   SAFE_FREE(m_rgColDesc);
00504   SAFE_ALLOC(m_rgColDesc, COLDESC, m_cColumns);
00505   memcpy(m_rgColDesc, pCSourceTable->m_rgColDesc, m_cColumns * sizeof(COLDESC));
00506
00507   //IndexInfo
00508   m_cIndexes  = pCSourceTable->m_cIndexes;
00509   SAFE_FREE(m_rgIndexInfo);
00510   SAFE_ALLOC(m_rgIndexInfo, INDEXINFO, m_cIndexes);
00511   memcpy(m_rgIndexInfo, pCSourceTable->m_rgIndexInfo, m_cIndexes * sizeof(INDEXINFO));
00512
00513   //Arrays to store best TypeInfo
00514   SAFE_ALLOC(rgTypeInfo, TYPEINFO, m_cColumns);
00515   SAFE_ALLOC(rgMatch, ULONG, m_cColumns);
00516   memset(rgMatch, NO_MATCH, m_cColumns*sizeof(ULONG));
00517
00518   //Get ProviderTypes rowset IDBSchemaRowset
00519   QTESTC(hr = GetTypeInfoRowset(&pIAccessor, &hAccessor, &pIRowset));
00520
00521   //Loop until all types are matched.
00522   //We may not find a match, which promotes the type to the next higher
00523   //type, which will require another cycle to match that type...
00524   while(!fMatchedAll)
00525   {
00526     //Get data for each row in rowset
00527     XTESTC(hr = pIRowset->RestartPosition(NULL));
00528
00529     //Loops over the entire SchemaRowset
00530     while(TRUE)
00531     {
00532       XTESTC(hr = pIRowset->GetNextRows(NULL, 0, MAX_BLOCK_SIZE, &cRowsObtained, &rghRows));
00533
00534       //ENDOFROWSET
00535       if(cRowsObtained == 0)
00536         break;
00537
00538       //Loop over the BLOCK of rows obtained
00539       for(ULONG i=0; i<cRowsObtained; i++)
00540       {
00541         ASSERT(m_rgColDesc);
00542
00543         //Reset all the TypeInfo fields
00544         memset(&TypeInfo, 0, sizeof(TYPEINFO));
00545
00546         //Put the data for one type into the TypeInfo Struct
00547         XTESTC(hr = pIRowset->GetData(rghRows[i], hAccessor, (void *)&TypeInfo));
00548
00549         //Loop over the columns and get TypeInfo
00550         for(ULONG iCol=0; iCol<m_cColumns; iCol++)
00551         {
00552           //Only try matching if this is the correct type and
00553           //the column doesn't already have a perfect match
00554           if(TypeInfo.wType != m_rgColDesc[iCol].wType || (rgMatch[iCol] & MATCH_EXACT))
00555             continue;
00556
00557           //An NonAutoInc Column cannot be placed into an AutoInc type
00558           if(TypeInfo.fIsAutoInc && !m_rgColDesc[iCol].fIsNullable)
00559             continue;
00560
00561           //A Nullable type cannot be mapped to a non-Nullable type
00562           if(m_rgColDesc[iCol].fIsNullable && !TypeInfo.fIsNullable)
00563             continue;
00564
00565           //If never matched before, we at least know they match by type
00566           if(!rgMatch[iCol])
00567           {
00568             rgMatch[iCol] |= MATCH_TYPE;
00569             rgTypeInfo[iCol] = TypeInfo;
00570           }
00571
00572           // Exact type/size matches take precedence
00573           if(COLINFO_SIZE(m_rgColDesc[iCol]) == TypeInfo.ulColumnSize)
00574           {
00575             rgMatch[iCol] |= MATCH_EXACT;
00576             rgTypeInfo[iCol] = TypeInfo;
00577           }
00578
00579           // Otherwise try best fit size
00580           if(COLINFO_SIZE(m_rgColDesc[iCol]) < TypeInfo.ulColumnSize &&
00581             TypeInfo.ulColumnSize <= rgTypeInfo[iCol].ulColumnSize)
00582           {
00583               rgMatch[iCol] |= MATCH_SIZE;
00584               rgTypeInfo[iCol] = TypeInfo;
00585           }
00586         }
00587       }
00588
00589       //Release this group of rows
00590       XTESTC(hr = pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL));
00591       SAFE_FREE(rghRows);
00592     }
00593
00594     // See if every type has a match
00595     fMatchedAll = TRUE;
00596     for(ULONG i=0; i<m_cColumns; i++)
00597     {
00598       ASSERT(m_rgColDesc);
00599
00600       // If not we will have to promote a type and try again
00601       if(rgMatch[i])
00602       {
00603         //If found a match fill in the TypeInfo fileds of our ColDesc
00604         wcscpy(m_rgColDesc[i].wszTypeName, rgTypeInfo[i].wszTypeName);
00605         m_rgColDesc[i].ulCreateParams = GetCreateParams(rgTypeInfo[i].wszCreateParams);
00606         m_rgColDesc[i].fIsNullable    = rgTypeInfo[i].fIsNullable == VARIANT_TRUE;
00607         m_rgColDesc[i].fIsAutoInc   = rgTypeInfo[i].fIsAutoInc == VARIANT_TRUE;
00608
00609         //TODO: why is this here?
00610         if (m_rgColDesc[i].ulColumnSize > rgTypeInfo[i].ulColumnSize)
00611           m_rgColDesc[i].ulColumnSize = rgTypeInfo[i].ulColumnSize;
00612       }
00613       else
00614       {
00615         fMatchedAll = FALSE;
00616
00617         //Try to promote it to the next largest type
00618         if(!GetPromotedType(&m_rgColDesc[i].wType))
00619         {
00620           //If unable to promote, we are out of luck
00621           wMessageBox(NULL, MB_TASKMODAL | MB_ICONEXCLAMATION | MB_OK, wsz_ERROR,
00622             wsz_NO_TYPE_MATCH_, GetDBTypeName(m_rgColDesc[i].wType));
00623           goto CLEANUP;
00624         }
00625       }
00626     }
00627   }
00628
00629
00630 CLEANUP:
00631   if(hAccessor && pIAccessor)
00632     XTEST(pIAccessor->ReleaseAccessor(hAccessor, NULL));
00633
00634   SAFE_RELEASE(pIAccessor);
00635   SAFE_RELEASE(pIRowset);
00636
00637   SAFE_FREE(rgMatch);
00638   SAFE_FREE(rgTypeInfo);
00639
00640   SAFE_FREE(rghRows);
00641   return hr;
00642 }
00643
00644
00645
00646
00647 /////////////////////////////////////////////////////////////////
00648 // HRESULT CTable::CreateTable
00649 //
00650 /////////////////////////////////////////////////////////////////
00651 HRESULT CTable::CreateTable()
00652 {
00653   ASSERT(m_pCDataSource);
00654   ASSERT(m_pCDataSource->m_pICommandText || m_pCDataSource->m_pIOpenRowset);
00655   HRESULT hr;
00656
00657   BSTR      bstrSqlState = NULL;
00658   WCHAR     wszSqlStmt[MAX_QUERY_LEN];  // Create table statement
00659
00660   ULONG cRecords = 0;
00661   IErrorRecords* pIErrorRecords = NULL;
00662   ICommandText* pICommandText = NULL;
00663   DBCOLUMNDESC* rgColumnDesc = NULL;
00664
00665   //Release any existing rowsets
00666   SAFE_RELEASE(m_pIRowset);
00667   SAFE_RELEASE(m_pIAccessor);
00668
00669   //If ITableDefinition is supported by the provider, use it by default.
00670   if(m_pCDataSource->m_pITableDefinition)
00671   {
00672     DBID      TableID;
00673
00674     //Get DBCOLUMNDESC info
00675     QTESTC(hr = GetColumnDesc(&rgColumnDesc));
00676
00677     //Create TableID
00678     TableID.eKind = DBKIND_NAME;
00679     TableID.uName.pwszName = wszSqlStmt;
00680     GetQuotedID(wszSqlStmt, m_wszQualTableName);
00681
00682     //ITableDefinition::CreateTable
00683     hr = m_pCDataSource->m_pITableDefinition->CreateTable(NULL, &TableID, m_cColumns, rgColumnDesc, IID_NULL, NULL, NULL, NULL, NULL);
00684
00685     //If table already exists, offer to drop it
00686     if(hr == DB_E_DUPLICATETABLEID)
00687     {
00688       //If the user doesn't wants to drop it, exit
00689       if(IDNO == wMessageBox(NULL, MB_TASKMODAL | MB_ICONQUESTION | MB_YESNO, wsz_ERROR,
00690         wsz_ASK_DROP_TABLE_, m_pCDataSource->m_pwszTableTerm, m_wszQualTableName))
00691         goto CLEANUP;
00692
00693       //Otherwise drop that table and continue
00694       XTESTC(hr = m_pCDataSource->m_pITableDefinition->DropTable(&TableID));
00695       XTESTC(hr = m_pCDataSource->m_pITableDefinition->CreateTable(NULL, &TableID, m_cColumns, rgColumnDesc, IID_NULL, NULL, NULL, NULL, NULL));
00696     }
00697     //If succeeded offer warning and continue
00698     if(hr == DB_S_ERRORSOCCURRED)
00699     {
00700             //TODO:display dialog
00701         }
00702     else
00703     {
00704       //Some other failure
00705       //Display Extended ErrorInfo
00706       XTESTC(hr);
00707     }
00708   }
00709   // Otherwise use SQL to create the table.
00710   else if(m_pCDataSource->m_pICommandText)
00711   {
00712     // Setup the initialize CREATE TABLE '<CTableName>'
00713     CreateSQLStmt(ESQL_CREATE_TABLE, wszSqlStmt);
00714
00715     // Set the Command Text
00716     pICommandText = m_pCDataSource->m_pICommandText;
00717     XTESTC(hr = pICommandText->SetCommandText(DBGUID_DBSQL, wszSqlStmt));
00718
00719     // Execute the command
00720     hr = pICommandText->Execute(NULL, IID_NULL, NULL, NULL, NULL);
00721
00722     // If this didn't work, then we need to display messages, and if the
00723     // error was a duplicate table, offer to drop.
00724     if(FAILED(hr))
00725     {
00726       //Get the Error Records, need to save them, since every call
00727       //cleans the previous error objects
00728       QTESTC(GetErrorRecords(&cRecords, &pIErrorRecords));
00729
00730       //If Error was due to an existing table, just ask to drop it
00731       if(GetSqlErrorInfo(0, pIErrorRecords, &bstrSqlState)==S_OK &&
00732         bstrSqlState && wcscmp(bstrSqlState, L"S0001")==0)
00733       {
00734         WCHAR   wszBuffer[MAX_QUERY_LEN];
00735
00736         //If the user doesn't wants to drop it, exit
00737         if(IDNO == wMessageBox(NULL, MB_TASKMODAL | MB_ICONQUESTION | MB_YESNO, wsz_ERROR,
00738                   wsz_ASK_DROP_TABLE_, m_pCDataSource->m_pwszTableTerm, m_wszQualTableName))
00739           goto CLEANUP;
00740
00741         //Otherwise drop that table and continue
00742         CreateSQLStmt(ESQL_DROP_TABLE, wszBuffer);
00743
00744         //Drop the existing Table
00745         XTESTC(hr = pICommandText->SetCommandText(DBGUID_DBSQL, wszBuffer));
00746         XTESTC(hr = pICommandText->Execute(NULL, IID_NULL, NULL, NULL, NULL));
00747
00748         //Now reset the CreateTable text to the SqlStmt and Execute
00749         XTESTC(hr = pICommandText->SetCommandText(DBGUID_DBSQL, wszSqlStmt));
00750         XTESTC(hr = pICommandText->Execute(NULL, IID_NULL, NULL, NULL, NULL));
00751       }
00752       else
00753       {
00754         //Otherwsie unknown error, just display it to the user
00755         DisplayErrorRecords(NULL, cRecords, pIErrorRecords);
00756       }
00757     }
00758   }
00759
00760 CLEANUP:
00761   SAFE_SYSFREE(bstrSqlState);
00762   SAFE_RELEASE(pIErrorRecords);
00763
00764   //Free DBCOLUMNDESC
00765   if(rgColumnDesc)
00766   {
00767     for(ULONG i=0; i<m_cColumns && rgColumnDesc; i++)
00768       FreeProperties(rgColumnDesc[i].cPropertySets, rgColumnDesc[i].rgPropertySets);
00769     SAFE_FREE(rgColumnDesc);
00770   }
00771   return hr;
00772 }
00773
00774
00775
00776
00777 /////////////////////////////////////////////////////////////////
00778 // HRESULT CTable::CopyIndexes
00779 //
00780 /////////////////////////////////////////////////////////////////
00781 HRESULT CTable::CopyIndexes(CTable* pCTable)
00782 {
00783   ASSERT(pCTable);
00784   HRESULT hr;
00785
00786   WCHAR     wszBuffer[MAX_NAME_LEN];
00787   WCHAR     wszSqlStmt[MAX_QUERY_LEN];
00788   ULONG i;
00789
00790   // Don't waste time if there aren't any indexes.
00791   if (m_cIndexes == 0)
00792     return (S_OK);
00793
00794   //Copy Index Info from Source table
00795   m_cIndexes  = pCTable->m_cIndexes;
00796   ULONG cIndexColumnDescs = 0;
00797   DBINDEXCOLUMNDESC* rgIndexColumnDescs = NULL;
00798   DBID* rgDBIDs = NULL;
00799
00800   //Array to indicate which index/columns we have used
00801   ULONG* rgIndexUsed = NULL;
00802   SAFE_ALLOC(rgIndexUsed, ULONG, m_cIndexes);
00803   memset(rgIndexUsed, 0, m_cIndexes * sizeof(ULONG));
00804
00805   SAFE_FREE(m_rgIndexInfo);
00806   SAFE_ALLOC(m_rgIndexInfo, INDEXINFO, m_cIndexes);
00807   memcpy(m_rgIndexInfo, pCTable->m_rgIndexInfo, m_cIndexes * sizeof(INDEXINFO));
00808
00809   //Alloc DBINDEXCOLUMNDESC
00810   SAFE_ALLOC(rgIndexColumnDescs, DBINDEXCOLUMNDESC, m_cColumns);
00811   SAFE_ALLOC(rgDBIDs, DBID, m_cColumns);
00812
00813   //Use IIndexDefinition::CreateIndex if supported
00814   if(m_pCDataSource->m_pIIndexDefinition)
00815   {
00816     //Create TableID
00817     DBID TableID;
00818     TableID.eKind = DBKIND_NAME;
00819     GetQuotedID(wszSqlStmt, m_wszQualTableName);
00820     TableID.uName.pwszName = wszSqlStmt;
00821
00822     // Loop around each index that is valid.  See if any are to be created
00823     for(i=0; i<m_cIndexes; i++)
00824     {
00825       //If this index has already been created, skip
00826       //might have been used in another index creation
00827       if(rgIndexUsed[i])
00828         continue;
00829
00830       //If this index is used as a primary key, skip
00831       //PrimaryKeys are taken care of differently
00832       if(m_rgIndexInfo[i].fIsPrimaryKey)
00833         continue;
00834
00835       //Create IndexID
00836       DBID IndexID;
00837       IndexID.eKind = DBKIND_NAME;
00838       GetQuotedID(wszBuffer, m_rgIndexInfo[i].wszIndexName);
00839       IndexID.uName.pwszName = wszBuffer;
00840
00841       // Now loop through all columns that belong to this index
00842       cIndexColumnDescs = 0;
00843       for(ULONG iCol=i; iCol<m_cIndexes; iCol++)
00844       {
00845         //If not the same index skip
00846         if(wcscmp(m_rgIndexInfo[i].wszIndexName, m_rgIndexInfo[iCol].wszIndexName)!=0)
00847           continue;
00848
00849         //mark this Index as used
00850         rgIndexUsed[iCol] = TRUE;
00851
00852         //DBINDEXCOLUMNDESC info
00853         rgIndexColumnDescs[cIndexColumnDescs].pColumnID = &rgDBIDs[cIndexColumnDescs];
00854         rgIndexColumnDescs[cIndexColumnDescs].pColumnID->eKind = DBKIND_NAME;
00855         rgIndexColumnDescs[cIndexColumnDescs].pColumnID->uName.pwszName = m_rgIndexInfo[iCol].wszColName;
00856
00857         //Indicate column order
00858         rgIndexColumnDescs[cIndexColumnDescs].eIndexColOrder = (m_rgIndexInfo[iCol].dwCollation == DB_COLLATION_DESC) ? DBINDEX_COL_ORDER_DESC : DBINDEX_COL_ORDER_ASC;
00859         cIndexColumnDescs++;
00860       }
00861
00862       //Now Setup Index Properties
00863       ULONG cPropSets = 0;
00864       DBPROPSET* rgPropSets = NULL;
00865
00866       //DBPROP_INDEX_AUTOUPDATE
00867       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_AUTOUPDATE, DBPROPSET_INDEX))
00868         SetProperty(DBPROP_INDEX_AUTOUPDATE, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_BOOL, m_rgIndexInfo[i].fAutoUpdate);
00869
00870       //DBPROP_INDEX_CLUSTERED
00871       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_CLUSTERED, DBPROPSET_INDEX))
00872         SetProperty(DBPROP_INDEX_CLUSTERED, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_BOOL, m_rgIndexInfo[i].fClustered);
00873
00874       //DBPROP_INDEX_FILLFACTOR
00875       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_FILLFACTOR, DBPROPSET_INDEX))
00876         SetProperty(DBPROP_INDEX_FILLFACTOR, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_I4, m_rgIndexInfo[i].dwFillFactor);
00877
00878       //DBPROP_INDEX_INITIALSIZE
00879       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_INITIALSIZE, DBPROPSET_INDEX))
00880         SetProperty(DBPROP_INDEX_INITIALSIZE, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_I4, m_rgIndexInfo[i].dwInitialSize);
00881
00882       //DBPROP_INDEX_NULLCOLLATION
00883       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_NULLCOLLATION, DBPROPSET_INDEX))
00884         SetProperty(DBPROP_INDEX_NULLCOLLATION, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_I4, m_rgIndexInfo[i].dwNullCollation);
00885
00886       //DBPROP_INDEX_NULLS
00887       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_NULLS, DBPROPSET_INDEX))
00888         SetProperty(DBPROP_INDEX_NULLS, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_I4, m_rgIndexInfo[i].dwNulls);
00889
00890       //DBPROP_INDEX_PRIMARYKEY
00891       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_PRIMARYKEY, DBPROPSET_INDEX))
00892         SetProperty(DBPROP_INDEX_PRIMARYKEY, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_BOOL, m_rgIndexInfo[i].fIsPrimaryKey);
00893
00894       //DBPROP_INDEX_SORTBOOKMARKS
00895       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_SORTBOOKMARKS, DBPROPSET_INDEX))
00896         SetProperty(DBPROP_INDEX_SORTBOOKMARKS, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_BOOL, m_rgIndexInfo[i].fSortBookmarks);
00897
00898       //DBPROP_INDEX_TEMPINDEX
00899 //      if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_TEMPINDEX, DBPROPSET_INDEX))
00900 //        SetProperty(DBPROP_INDEX_TEMPINDEX, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_BOOL, m_rgIndexInfo[i].fTempIndex);
00901
00902       //DBPROP_INDEX_TYPE
00903       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_TYPE, DBPROPSET_INDEX))
00904         SetProperty(DBPROP_INDEX_TYPE, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_I4, m_rgIndexInfo[i].wType);
00905
00906       //DBPROP_INDEX_UNIQUE
00907       if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_INDEX_UNIQUE, DBPROPSET_INDEX))
00908         SetProperty(DBPROP_INDEX_UNIQUE, DBPROPSET_INDEX, &cPropSets, &rgPropSets, DBTYPE_BOOL, m_rgIndexInfo[i].fUnique);
00909
00910       //IIndexDefinition::CreateIndex
00911       //Don't exit yet, the user might want to continue even though this index failed
00912       XTEST(hr = m_pCDataSource->m_pIIndexDefinition->CreateIndex(&TableID, &IndexID, cIndexColumnDescs, rgIndexColumnDescs, cPropSets, rgPropSets, NULL));
00913
00914       //Free Properties
00915       FreeProperties(cPropSets, rgPropSets);
00916
00917       //If INDEX Failed
00918       if(FAILED(hr))
00919       {
00920         //Index Failed, Do you want to Continue?
00921         if(IDNO == wMessageBox(NULL, MB_TASKMODAL | MB_ICONINFORMATION | MB_YESNO, wsz_ERROR,
00922             wsz_INDEX_FAILED_, m_rgIndexInfo[i].wszIndexName))
00923           goto CLEANUP;
00924       }
00925
00926       //Since the User didn't exit, continue as normal
00927       hr = S_OK;
00928     }
00929   }
00930   //Using SQL Commands to insert the index
00931   else if(m_pCDataSource->m_pICommandText)
00932   {
00933
00934     // Loop around each index that is valid.  See if any are to be created
00935     for(i=0; i<m_cIndexes; i++)
00936     {
00937       //If this index has already been created, skip
00938       //might have been used in another index creation
00939       if(rgIndexUsed[i])
00940         continue;
00941
00942       //If this index is used as a primary key, skip
00943       //PrimaryKeys are taken care of differently
00944       if(m_rgIndexInfo[i].fIsPrimaryKey)
00945         continue;
00946
00947       //"CREATE <UNIQUE> INDEX "
00948       swprintf(wszSqlStmt, wsz_CREATE_INDEX_, (m_rgIndexInfo[i].fUnique == VARIANT_TRUE) ? wsz_UNIQUE_INDEX : wsz_SPACE);
00949
00950       //Add IndexName to the list (quoted)
00951       GetQuotedID(wszBuffer, m_rgIndexInfo[i].wszIndexName);
00952       wcscat(wszSqlStmt, wszBuffer);
00953
00954       //Add TableName
00955       wcscat(wszSqlStmt, L" ON ");
00956       GetQuotedID(wszBuffer, m_wszQualTableName);
00957       wcscat(wszSqlStmt, wszBuffer);
00958       wcscat(wszSqlStmt, wsz_LPAREN);
00959
00960       // Now loop through find all columns that belong to this index
00961       for(ULONG iCol=i; iCol<m_cIndexes; iCol++)
00962       {
00963         //If not the same index skip
00964         if(wcscmp(m_rgIndexInfo[i].wszIndexName, m_rgIndexInfo[iCol].wszIndexName)!=0)
00965           continue;
00966
00967         //mark this Index as used
00968         rgIndexUsed[iCol] = TRUE;
00969
00970         //Add Column Name to the list (quoted)
00971         GetQuotedID(wszBuffer, m_rgIndexInfo[iCol].wszColName);
00972         wcscat(wszSqlStmt, wszBuffer);
00973
00974         // Indicate Asending or Decending
00975         if(m_rgIndexInfo[iCol].dwCollation == DB_COLLATION_DESC)
00976           wcscat(wszSqlStmt, wsz_INDEX_DESC);
00977
00978         //Add trailing "," between col names
00979         wcscat(wszSqlStmt, wsz_COMMA);
00980       }
00981
00982       //Replace last trailing "," with a ")"
00983       wcscpy(&wszSqlStmt[wcslen(wszSqlStmt)-wcslen(wsz_COMMA)], wsz_RPAREN);
00984
00985       // If user wants to see the statement, show it to them
00986       if(m_pCWizard->m_pCTableCopy->m_fShowQuery)
00987         wMessageBox(NULL, MB_TASKMODAL | MB_OK | MB_ICONINFORMATION, wsz_OLEDB,
00988           wsz_SHOW_SQL_, m_pCDataSource->m_pwszDataSource, wszSqlStmt);
00989
00990       //Set the command text
00991       XTESTC(hr = m_pCDataSource->m_pICommandText->SetCommandText(DBGUID_DBSQL, wszSqlStmt));
00992
00993       //Execute the command
00994       //Don't exit yet, the user might want to continue even though this index failed
00995       XTEST(hr = m_pCDataSource->m_pICommandText->Execute(NULL, IID_NULL, NULL, NULL, NULL));
00996
00997       //If INDEX Failed
00998       if(FAILED(hr))
00999       {
01000         //Index Failed, Do you want to Continue?
01001         if(IDNO == wMessageBox(NULL, MB_TASKMODAL | MB_ICONINFORMATION | MB_YESNO, wsz_ERROR,
01002             wsz_INDEX_FAILED_, m_rgIndexInfo[i].wszIndexName))
01003           goto CLEANUP;
01004       }
01005
01006       //Since the User didn't exit, continue as normal
01007       hr = S_OK;
01008     }
01009   }
01010
01011 CLEANUP:
01012   SAFE_FREE(rgIndexUsed);
01013   SAFE_FREE(rgIndexColumnDescs);
01014   SAFE_FREE(rgDBIDs);
01015   return hr;
01016 }
01017
01018
01019 /////////////////////////////////////////////////////////////////
01020 // HRESULT CTable::CreateSQLStmt
01021 //
01022 /////////////////////////////////////////////////////////////////
01023 HRESULT CTable::CreateSQLStmt(ESQL_STMT eSqlStmt, WCHAR* pwszSqlStmt, BOOL fShowSql)
01024 {
01025   ASSERT(pwszSqlStmt);
01026   HRESULT hr = S_OK;
01027   WCHAR     wszBuffer[MAX_NAME_LEN*2];   // Buffer
01028
01029   switch(eSqlStmt)
01030   {
01031     //SELECT <ColumnList> FROM <QualifiedTableName>
01032     case ESQL_SELECT:
01033     {
01034       //Create the SELECT statment
01035       wcscpy(pwszSqlStmt, wsz_SELECT);
01036
01037       // Loop through each column
01038       for(ULONG i=0; i<m_cColumns; i++)
01039       {
01040         // Add the column to the list (quoted)
01041         GetQuotedID(wszBuffer, m_rgColDesc[i].wszColName);
01042         wcscat(pwszSqlStmt, wszBuffer);
01043
01044         if(i<m_cColumns-1)
01045           wcscat(pwszSqlStmt, wsz_COMMA);
01046       }
01047
01048       // Add the Table Name
01049       wcscat(pwszSqlStmt, wsz_FROM);
01050       GetQuotedID(wszBuffer, m_wszQualTableName);
01051       wcscat(pwszSqlStmt, wszBuffer);
01052     }
01053     break;
01054
01055     case ESQL_INSERT:
01056     {
01057       wcscpy(pwszSqlStmt, wsz_INSERT_INTO);
01058
01059       //Add the Table Name
01060       GetQuotedID(wszBuffer, m_wszQualTableName);
01061       wcscat(pwszSqlStmt, wszBuffer);
01062       wcscat(pwszSqlStmt, wsz_LPAREN);
01063       ULONG cColumns = 0;
01064
01065       // Add the column list
01066       for(ULONG i=0; i<m_cColumns; i++)
01067       {
01068         //Only Bind updatable columns
01069         if(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_WRITE || m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_WRITEUNKNOWN)
01070         {
01071           //Only add a leading comma if there are preceding columns
01072           if(cColumns++)
01073             wcscat(pwszSqlStmt, wsz_COMMA);
01074
01075           // Add the column to the list (quoted)
01076           GetQuotedID(wszBuffer, m_rgColDesc[i].wszColName);
01077           wcscat(pwszSqlStmt, wszBuffer);
01078         }
01079       }
01080
01081       //Add VALUES clause
01082       wcscat(pwszSqlStmt, wsz_VALUES_CLAUSE);
01083
01084       // Loop through each column
01085       cColumns = 0;
01086       for(i=0; i<m_cColumns; i++)
01087       {
01088         //Only Bind those columns that are updatable
01089         if(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_WRITE || m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_WRITEUNKNOWN)
01090         {
01091           //Only add a leading comma if there are preceding columns
01092           if(cColumns++)
01093             wcscat(pwszSqlStmt, wsz_COMMA);
01094           wcscat(pwszSqlStmt, wsz_PARAM);
01095         }
01096       }
01097
01098       // Finish off the string
01099       wcscat(pwszSqlStmt, wsz_RPAREN);
01100     }
01101     break;
01102
01103     case ESQL_CREATE_TABLE:
01104     {
01105
01106       // Setup the initialize CREATE TABLE '<CTableName>'
01107       wcscpy(pwszSqlStmt, wsz_CREATE_TABLE);
01108       GetQuotedID(wszBuffer, m_wszQualTableName);
01109       wcscat(pwszSqlStmt, wszBuffer);
01110
01111       // Setup (<ColList>)
01112       wcscat(pwszSqlStmt, wsz_LPAREN);
01113
01114       // Loop through each column and format the column name, type, and precision
01115       for(ULONG i=0; i<m_cColumns; i++)
01116       {
01117         // Add the column to the list (quoted)
01118         GetQuotedID(wszBuffer, m_rgColDesc[i].wszColName);
01119         wcscat(pwszSqlStmt, wszBuffer);
01120         wcscat(pwszSqlStmt, wsz_SPACE);
01121
01122         // Add ColumnType (formatted with CreateParams)
01123         GetTypeNameAndParams(i, wszBuffer);
01124         wcscat(pwszSqlStmt, wszBuffer);
01125
01126         //Add PRIMARY KEY if Supported and a PrimaryKey Column
01127         if(m_rgColDesc[i].fIsPrimaryKey && m_pCDataSource->m_fPrimaryKeysSupported && m_pCWizard->m_pCTableCopy->m_fCopyPrimaryKeys)
01128           wcscat(pwszSqlStmt, wsz_PRIMARY_KEY);
01129
01130         //Add Comma
01131         if(i<m_cColumns-1)
01132           wcscat(pwszSqlStmt, wsz_COMMA);
01133       }
01134
01135       //Add trailing ")"
01136       wcscat(pwszSqlStmt, wsz_RPAREN);
01137     }
01138     break;
01139
01140     case ESQL_DROP_TABLE:
01141     {
01142       GetQuotedID(wszBuffer, m_wszQualTableName);
01143       swprintf(pwszSqlStmt, wsz_DROP_TABLE_, wszBuffer);
01144     }
01145     break;
01146
01147     default:
01148       ASSERT(!"Unhandled Case!");
01149       break;
01150   };
01151
01152   // If user wants to see the statement, show it to them
01153   if(m_pCWizard->m_pCTableCopy->m_fShowQuery && fShowSql)
01154     wMessageBox(NULL, MB_TASKMODAL | MB_OK | MB_ICONINFORMATION, wsz_OLEDB,
01155       wsz_SHOW_SQL_, m_pCDataSource->m_pwszDataSource, pwszSqlStmt);
01156
01157   return hr;
01158 }
01159
01160
01161 /////////////////////////////////////////////////////////////////
01162 // HRESULT CTable::AdjustBindings
01163 //
01164 /////////////////////////////////////////////////////////////////
01165 HRESULT CTable::AdjustBindings(ULONG cBindings, DBBINDING* rgBindings, void* pData)
01166 {
01167   ASSERT(pData);
01168   HRESULT hr = S_OK;
01169
01170   //Adjust all Storage Objects
01171   //We have 2 problems.  First some providers (MSDASQL) may require the LENGTH
01172   //of the storage object bound.  We have no clue what the LENGTH is unless
01173   //we read the entire stream.  Second some providers may only allow 1 storage
01174   //object open at any one time.  The simplest soltuion would be just to buffer
01175   //the provider storage objects into our own and release the providers...
01176
01177   for(ULONG i=0; i<cBindings; i++)
01178   {
01179     //DBSTATUS_S_ISNULL - nothing to adjust
01180     if(BINDING_STATUS(rgBindings[i],pData) == DBSTATUS_S_ISNULL)
01181       continue;
01182
01183     //DB_S_TRUNCATED
01184     //Need to Adjust the LENGTH binding to be cbMaxLen
01185     if(BINDING_STATUS(rgBindings[i],pData) == DBSTATUS_S_TRUNCATED)
01186       BINDING_LENGTH(rgBindings[i], pData) = rgBindings[i].cbMaxLen;
01187
01188     //DBTYPE_IUNKNOWN
01189     if(rgBindings[i].wType == DBTYPE_IUNKNOWN)
01190     {
01191        //Obtain the providers ISeqStream object
01192       ISequentialStream* pISequentialStream = (ISequentialStream*)BINDING_VALUE(rgBindings[i], pData);
01193
01194       //Copy the providers stream into our own CISeqStream object
01195       CISeqStream* pCISeqStream = new CISeqStream();
01196       pCISeqStream->Write(pISequentialStream, NULL);
01197       BINDING_VALUE(rgBindings[i], pData) = (ULONG)pCISeqStream;
01198       SAFE_RELEASE(pISequentialStream);
01199
01200       //Indicate the LENGTH Binding
01201       BINDING_LENGTH(rgBindings[i], pData) = pCISeqStream->Length();
01202     }
01203
01204     //DBSTATUS_S_OK
01205     BINDING_STATUS(rgBindings[i],pData) = DBSTATUS_S_OK;
01206   }
01207
01208   return hr;
01209 }
01210
01211
01212 /////////////////////////////////////////////////////////////////
01213 // HRESULT CTable::CreateAccessors
01214 //
01215 /////////////////////////////////////////////////////////////////
01216 HRESULT CTable::CreateAccessors(ULONG* pcBindingInfo, BINDINGINFO** prgBindingInfo, ULONG* pcRowSize, ULONG ulBlobSize, BOOL* pbOutofLine)
01217 {
01218   ASSERT(m_pIRowset);
01219   ASSERT(m_pIAccessor);
01220   ASSERT(pcBindingInfo);
01221   ASSERT(prgBindingInfo);
01222   ASSERT(pbOutofLine);
01223
01224   HRESULT hr = S_OK;
01225
01226   ULONG ulOffset = 0;
01227   ULONG i,cBindings = 0;
01228   DBBINDING* rgBindings = NULL;
01229   ULONG cStorageObjects = 0;
01230
01231   //Alloc the space for BindingInfo
01232   ULONG cBindingInfo = 0;
01233   BINDINGINFO* rgBindingInfo = NULL;
01234   SAFE_ALLOC(rgBindingInfo, BINDINGINFO, m_cColumns);
01235
01236   //Alloc the space to hold the Bindings and Accessors
01237   SAFE_ALLOC(rgBindings, DBBINDING, m_cColumns);
01238
01239   cBindings = 0;
01240   for(i=0; i<m_cColumns; i++)
01241   {
01242     //SetUp the Bindings
01243     rgBindings[cBindings].iOrdinal  = m_rgColDesc[i].iOrdinal;
01244     rgBindings[cBindings].obStatus  = ulOffset;
01245     rgBindings[cBindings].obLength  = ulOffset + sizeof(DBSTATUS);
01246     rgBindings[cBindings].obValue = ulOffset + sizeof(DBSTATUS) + sizeof(ULONG);
01247
01248     rgBindings[cBindings].pTypeInfo = NULL;
01249     rgBindings[cBindings].pBindExt  = NULL;
01250
01251     rgBindings[cBindings].dwPart  = DBPART_VALUE|DBPART_LENGTH|DBPART_STATUS;
01252     rgBindings[cBindings].dwMemOwner= DBMEMOWNER_CLIENTOWNED;
01253     rgBindings[cBindings].eParamIO  = DBPARAMIO_NOTPARAM;
01254
01255     rgBindings[cBindings].dwFlags = 0;
01256     rgBindings[cBindings].bPrecision= m_rgColDesc[i].bPrecision;
01257     rgBindings[cBindings].bScale  = m_rgColDesc[i].bScale;
01258
01259     rgBindings[cBindings].pObject = NULL;
01260     rgBindings[cBindings].wType   = m_rgColDesc[i].wType;
01261     rgBindings[cBindings].cbMaxLen  = m_rgColDesc[i].ulColumnSize;
01262
01263     //Account for the NULL terminator
01264     if(rgBindings[cBindings].wType == DBTYPE_STR)
01265       rgBindings[cBindings].cbMaxLen  += sizeof(CHAR);
01266     if(rgBindings[cBindings].wType == DBTYPE_WSTR)
01267       rgBindings[cBindings].cbMaxLen  += sizeof(WCHAR);
01268
01269     //Adjust ISLONG Columns if not bound as ISeqStream
01270     if(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_ISLONG)
01271       ADJUST_SIZE(rgBindings[cBindings].cbMaxLen, ulBlobSize);
01272
01273     //ISeqStream
01274     //Since some providers may only allow 1 storage object bound at a time
01275     //we will create a seperate accessor for each storage object bound.
01276     if(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_ISLONG && ulBlobSize == ULONG_MAX)
01277     {
01278       cStorageObjects++;
01279       //Setup wType
01280       rgBindings[cBindings].wType   = DBTYPE_IUNKNOWN;
01281       rgBindings[cBindings].cbMaxLen  = sizeof(IUnknown*);
01282
01283       //Setup pObject structure
01284       SAFE_ALLOC(rgBindings[cBindings].pObject, DBOBJECT, 1);
01285       rgBindings[cBindings].pObject->iid = IID_ISequentialStream;
01286       rgBindings[cBindings].pObject->dwFlags = STGM_READ;
01287
01288       //Only need a seperate Accessor if there is more than 1 Storage column
01289       if(cStorageObjects > 1)
01290       {
01291         //Setup BindingInfo
01292         rgBindingInfo[cBindingInfo].cBindings = 1;
01293         SAFE_ALLOC(rgBindingInfo[cBindingInfo].rgBindings, DBBINDING, 1);
01294         memcpy(rgBindingInfo[cBindingInfo].rgBindings, &rgBindings[cBindings], sizeof(DBBINDING));
01295
01296         //Create the accessor for the Storage column
01297         XTESTC(hr = m_pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 1, &rgBindings[cBindings], 0, &rgBindingInfo[cBindingInfo].hAccessor, NULL));
01298         cBindingInfo++;
01299       }
01300     }
01301
01302     //Determine if there is out of line data...
01303     switch(rgBindings[cBindings].wType)
01304     {
01305       case DBTYPE_VARIANT:
01306         *pbOutofLine = TRUE;
01307         break;
01308     }
01309
01310     ulOffset = ROUNDUP(rgBindings[cBindings].obValue + rgBindings[cBindings].cbMaxLen);
01311
01312     //Already handled ISeqStream columns
01313     if(!(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_ISLONG && ulBlobSize == ULONG_MAX && cStorageObjects>1))
01314       cBindings++;
01315   }
01316
01317   //Create the accessor for the entire row, (excluding Storage columns)
01318   if(cBindings)
01319   {
01320     //Setup BindingInfo
01321     rgBindingInfo[cBindingInfo].cBindings = cBindings;
01322     rgBindingInfo[cBindingInfo].rgBindings = rgBindings;
01323
01324     XTESTC(hr = m_pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, 0, &rgBindingInfo[cBindingInfo].hAccessor, NULL));
01325     cBindingInfo++;
01326   }
01327
01328   //Size for pData
01329   if(pcRowSize)
01330     *pcRowSize = ulOffset;
01331
01332   //Accessors
01333   *pcBindingInfo = cBindingInfo;
01334   *prgBindingInfo = rgBindingInfo;
01335
01336 CLEANUP:
01337   return hr;
01338 }
01339
01340
01341 /////////////////////////////////////////////////////////////////
01342 // HRESULT CTable::GetRowset
01343 //
01344 /////////////////////////////////////////////////////////////////
01345 HRESULT CTable::GetRowset(DWORD dwInsertOpt)
01346 {
01347   ASSERT(m_pCDataSource);
01348   WCHAR   wszBuffer[MAX_NAME_LEN];
01349   HRESULT hr;
01350
01351   ULONG cPropSets = 0;
01352   DBPROPSET* rgPropSets = NULL;
01353
01354   //Release the current rowset
01355   SAFE_RELEASE(m_pIRowset);
01356   SAFE_RELEASE(m_pIAccessor);
01357
01358   //Kagera's Implementation requires IID_RowsetLocate for BLOB Support
01359   if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_IRowsetLocate, DBPROPSET_ROWSET))
01360     SetProperty(DBPROP_IRowsetLocate, DBPROPSET_ROWSET, &cPropSets, &rgPropSets, DBTYPE_BOOL, TRUE);
01361
01362   //DBPROP_UPDATABILITY
01363   if(dwInsertOpt != IDR_PARAM_SETS && IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_UPDATABILITY, DBPROPSET_ROWSET))
01364     SetProperty(DBPROP_UPDATABILITY, DBPROPSET_ROWSET, &cPropSets, &rgPropSets, DBTYPE_I4, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE | DBPROPVAL_UP_INSERT);
01365
01366   //DBPROP_IRowsetChange
01367   if(dwInsertOpt == IDR_INSERTROW_IMMEDIATE && IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_IRowsetChange, DBPROPSET_ROWSET))
01368     SetProperty(DBPROP_IRowsetChange, DBPROPSET_ROWSET, &cPropSets, &rgPropSets, DBTYPE_BOOL, TRUE);
01369
01370   //DBPROP_IRowsetUpdate
01371   if(dwInsertOpt == IDR_INSERTROW_BUFFERED && IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_IRowsetUpdate, DBPROPSET_ROWSET))
01372   {
01373     //DBPROP_CANHOLDROWS
01374     //In order to insert more rows while there are pending changes
01375     SetProperty(DBPROP_CANHOLDROWS, DBPROPSET_ROWSET, &cPropSets, &rgPropSets, DBTYPE_BOOL, TRUE);
01376     SetProperty(DBPROP_IRowsetUpdate, DBPROPSET_ROWSET, &cPropSets, &rgPropSets, DBTYPE_BOOL, TRUE);
01377   }
01378
01379   //Setup TableID
01380   DBID TableID;
01381   TableID.eKind = DBKIND_NAME;
01382
01383   //Quote the TableName
01384   TableID.uName.pwszName = wszBuffer;
01385   GetQuotedID(wszBuffer, m_wszQualTableName);
01386
01387   //IOpenRowset
01388   XTESTC(hr = m_pCDataSource->m_pIOpenRowset->OpenRowset(NULL, &TableID, NULL, IID_IRowset, cPropSets, rgPropSets, (IUnknown**)&m_pIRowset));
01389   CHECKC(m_pIRowset);
01390
01391   //Obtain the Accessor
01392   XTESTC(hr = m_pIRowset->QueryInterface(IID_IAccessor, (void**)&m_pIAccessor));
01393
01394 CLEANUP:
01395   FreeProperties(cPropSets, rgPropSets);
01396   return hr;
01397 }
01398
01399
01400
01401 /////////////////////////////////////////////////////////////////
01402 // HRESULT CTable::CopyData
01403 //
01404 /////////////////////////////////////////////////////////////////
01405 HRESULT CTable::CopyData(CTable* pCSourceTable, ULONG* pcRowsCopied)
01406 {
01407   ASSERT(pCSourceTable && pcRowsCopied);
01408   HRESULT hr;
01409
01410   WCHAR   wszSqlStmt[MAX_QUERY_LEN];  // Format the select statement
01411   WCHAR   wszBuffer[MAX_NAME_LEN];
01412
01413     ULONG   i,j,ulOffset = 0;
01414   ULONG   cBindings = 0;
01415   DBBINDING*  rgBindings = NULL;
01416   HACCESSOR  hAccessor = DB_NULL_HACCESSOR;
01417   IAccessor* pIAccessor = NULL;
01418
01419   ULONG cRowSize = 0;
01420   IRowset*    pISourceRowset = pCSourceTable->m_pIRowset;
01421   IRowsetChange*  pIRowsetChange = NULL;
01422   IRowsetUpdate*  pIRowsetUpdate = NULL;
01423
01424   ULONG cRowsObtained = 0;
01425   HROW* rghRows = NULL;
01426   DBPARAMS DBParams;
01427
01428   void* pData = NULL;
01429   void* pRowData = NULL;
01430   ULONG cRows = 0;
01431
01432   CTableCopy* pCTableCopy = m_pCWizard->m_pCTableCopy;
01433     ULONG ulParamSets = pCTableCopy->m_dwInsertOpt == IDR_PARAM_SETS ? pCTableCopy->m_ulParamSets : 0;
01434   ULONG ulBlobSize  = pCTableCopy->m_dwBlobOpt == IDR_BLOB_SIZE ? pCTableCopy->m_ulBlobSize : ULONG_MAX;
01435   ULONG ulMaxRows   = pCTableCopy->m_dwRowOpt == IDR_ROW_COUNT ? pCTableCopy->m_ulMaxRows : ULONG_MAX;
01436
01437   BOOL bOutofLine = FALSE;
01438   ULONG cBindingInfo = 0;
01439   BINDINGINFO* rgBindingInfo = NULL;
01440   CProgress* pCProgress = m_pCWizard->m_pCProgress;
01441
01442   //Get the Rowset from the SourceTable
01443   QTESTC(hr = pCSourceTable->CreateAccessors(&cBindingInfo, &rgBindingInfo, &cRowSize, ulBlobSize, &bOutofLine));
01444
01445   //Obtain the Accessor
01446   SAFE_ALLOC(rgBindings, DBBINDING, m_cColumns);
01447
01448   cBindings = 0;
01449   for(i=0; i<m_cColumns; i++)
01450   {
01451     rgBindings[cBindings].iOrdinal  = ulParamSets ? cBindings+1 : m_rgColDesc[i].iOrdinal;
01452     rgBindings[cBindings].obStatus  = ulOffset;
01453     rgBindings[cBindings].obLength  = ulOffset + sizeof(DBSTATUS);
01454     rgBindings[cBindings].obValue   = ulOffset + sizeof(ULONG) + sizeof(DBSTATUS);
01455
01456     rgBindings[cBindings].pTypeInfo = NULL;
01457     rgBindings[cBindings].pBindExt  = NULL;
01458
01459     rgBindings[cBindings].dwPart  = DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS;
01460     rgBindings[cBindings].dwMemOwner= DBMEMOWNER_CLIENTOWNED;
01461     rgBindings[cBindings].eParamIO  = ulParamSets ? DBPARAMIO_INPUT : DBPARAMIO_NOTPARAM;
01462     rgBindings[cBindings].dwFlags = 0;
01463
01464     rgBindings[cBindings].bPrecision= pCSourceTable->m_rgColDesc[i].bPrecision;
01465     rgBindings[cBindings].bScale  = pCSourceTable->m_rgColDesc[i].bScale;
01466
01467     rgBindings[cBindings].pObject = NULL;
01468     rgBindings[cBindings].wType   = pCSourceTable->m_rgColDesc[i].wType;
01469     rgBindings[cBindings].cbMaxLen  = pCSourceTable->m_rgColDesc[i].ulColumnSize;
01470
01471     //Account for the NULL terminator
01472     if(rgBindings[cBindings].wType == DBTYPE_STR)
01473       rgBindings[cBindings].cbMaxLen  += sizeof(CHAR);
01474     if(rgBindings[cBindings].wType == DBTYPE_WSTR)
01475       rgBindings[cBindings].cbMaxLen  += sizeof(WCHAR);
01476
01477     //Adjust ISLONG Columns if not bound as ISeqStream
01478     if(pCSourceTable->m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_ISLONG)
01479       ADJUST_SIZE(rgBindings[cBindings].cbMaxLen, ulBlobSize);
01480
01481     //ISeqStream
01482     if(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_ISLONG &&
01483       pCTableCopy->m_dwBlobOpt == IDR_ISEQ_STREAM)
01484     {
01485       //Setup wType
01486       rgBindings[cBindings].wType   = DBTYPE_IUNKNOWN;
01487       rgBindings[cBindings].cbMaxLen  = sizeof(IUnknown*);
01488
01489       //Setup pObject structure
01490       SAFE_ALLOC(rgBindings[cBindings].pObject, DBOBJECT, 1);
01491       rgBindings[cBindings].pObject->iid = IID_ISequentialStream;
01492       rgBindings[cBindings].pObject->dwFlags = STGM_READ;
01493     }
01494
01495     ulOffset = ROUNDUP(rgBindings[cBindings].obValue + rgBindings[cBindings].cbMaxLen);
01496
01497     //Only Bind Updatable columns
01498     //Note, we are not using the Source info here, since in the process
01499     //of adjusting columns to a different DSN, the columns may have become writeable
01500     if(m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_WRITE || m_rgColDesc[i].dwFlags & DBCOLUMNFLAGS_WRITEUNKNOWN)
01501       cBindings++;
01502   }
01503
01504   //If using Parameters to INSERT the Data
01505   if(pCTableCopy->m_dwInsertOpt == IDR_PARAM_SETS)
01506   {
01507     // Now create the INSERT INTO statment
01508     CreateSQLStmt(ESQL_INSERT, wszSqlStmt, ulParamSets);
01509
01510     //Set the command text
01511     XTESTC(hr = m_pCDataSource->m_pICommandText->SetCommandText(DBGUID_DBSQL, wszSqlStmt));
01512
01513     //Create the Target Accessor
01514     XTESTC(hr = m_pCDataSource->m_pICommandText->QueryInterface(IID_IAccessor, (void**)&pIAccessor));
01515     XTESTC(hr = pIAccessor->CreateAccessor(DBACCESSOR_PARAMETERDATA, cBindings, rgBindings, ulOffset, &hAccessor, NULL));
01516   }
01517   //were using InsertRow
01518   else
01519   {
01520     //Obtain IRowsetChange interface from the TargetRowset
01521     XTESTC(hr = m_pIRowset->QueryInterface(IID_IRowsetChange, (void**)&pIRowsetChange));
01522
01523     //Create the Target Accessor
01524     XTESTC(hr = m_pIRowset->QueryInterface(IID_IAccessor, (void**)&pIAccessor));
01525     XTESTC(hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, ulOffset, &hAccessor, NULL));
01526
01527     if(pCTableCopy->m_dwInsertOpt == IDR_INSERTROW_BUFFERED)
01528       XTESTC(hr = m_pIRowset->QueryInterface(IID_IRowsetUpdate, (void**)&pIRowsetUpdate));
01529   }
01530
01531   // Display the progress dialog
01532   pCProgress->Display();
01533   pCProgress->SetHeading(wsz_COPYING);
01534
01535   //Alloc room for pData
01536   SAFE_ALLOC(pData, BYTE, max(ulParamSets, 1) * cRowSize);
01537   memset(pData, 0, max(ulParamSets, 1) * cRowSize);
01538
01539   //Setup DBPARAMS Struct
01540   DBParams.cParamSets = 1;      //Numer of Parameter sets
01541   DBParams.hAccessor  = hAccessor;  //Target Param Accessor
01542   DBParams.pData    = pData;    //Source Data
01543
01544   while(cRows < ulMaxRows)
01545   {
01546     XTESTC(hr = pISourceRowset->GetNextRows(NULL, 0, (ulParamSets > 1) ? ulParamSets : MAX_BLOCK_SIZE, &cRowsObtained, &rghRows));
01547
01548     //ENDOFROWSET
01549     if(cRowsObtained==0)
01550       break;
01551
01552     //Determine the number of rows that are actually needed to retrieve
01553     //The user might have specfified the number of rows to retrieve which could
01554     //be smaller than the number in the block size
01555     ULONG cRowsNeeded = min(cRowsObtained, ulMaxRows-cRows);
01556
01557     //Use Parameters to INSERT the data, use MultipleParamSets
01558     if(ulParamSets > 1)
01559     {
01560       //GetData
01561       for(i=0; i<cRowsNeeded; i++)
01562       {
01563         pRowData = (BYTE*)pData + (i*cRowSize);
01564         for(j=0; j<cBindingInfo; j++)
01565         {
01566           XTESTC(hr = pISourceRowset->GetData(rghRows[i], rgBindingInfo[j].hAccessor, pRowData));
01567
01568           //AdjustBindings
01569           QTESTC(hr = AdjustBindings(rgBindingInfo[j].cBindings, rgBindingInfo[j].rgBindings, pRowData));
01570         }
01571       }
01572
01573       //Adjust the paramerer sets
01574       DBParams.cParamSets = cRowsNeeded;
01575
01576       //Execute the INSERT (multiple param sets)
01577       XTESTC(hr = m_pCDataSource->m_pICommandText->Execute(NULL, IID_NULL, &DBParams, NULL, NULL));
01578
01579       //FreeBindingData - outofline memory
01580       for(i=0; i<cRowsNeeded && bOutofLine; i++)
01581       {
01582         pRowData = (BYTE*)pData + (i*cRowSize);
01583         for(j=0; j<cBindingInfo; j++)
01584           QTESTC(FreeBindingData(rgBindingInfo[j].cBindings, rgBindingInfo[j].rgBindings, pData));
01585       }
01586
01587       // Update insert progress
01588       swprintf(wszBuffer, wsz_COPIED_RECORDS, (cRows += cRowsNeeded));
01589       if(!pCProgress->Update(wszBuffer))
01590         goto CLEANUP;
01591     }
01592     //Use Paramseters to INSERT the data, but only 1 ParamSet (not multiple)
01593     else if(ulParamSets == 1)
01594     {
01595       for(i=0; i<cRowsNeeded; i++)
01596       {
01597         for(j=0; j<cBindingInfo; j++)
01598         {
01599           //GetData
01600           XTESTC(hr = pISourceRowset->GetData(rghRows[i], rgBindingInfo[j].hAccessor, pData));
01601
01602           //AdjustBindings
01603           QTESTC(hr = AdjustBindings(rgBindingInfo[j].cBindings, rgBindingInfo[j].rgBindings, pData));
01604         }
01605
01606         //Execute the INSERT
01607         XTESTC(hr = m_pCDataSource->m_pICommandText->Execute(NULL, IID_NULL, &DBParams, NULL, NULL));
01608
01609         //FreeBindingData - outofline memory
01610         for(j=0; j<cBindingInfo && bOutofLine; j++)
01611           QTESTC(FreeBindingData(rgBindingInfo[j].cBindings, rgBindingInfo[j].rgBindings, pData));
01612
01613         // Update insert progress
01614         swprintf(wszBuffer, wsz_COPIED_RECORDS, cRows++);
01615         if(!pCProgress->Update(wszBuffer))
01616           goto CLEANUP;
01617       }
01618     }
01619     //Use InsertRow to INSERT the Data
01620     else
01621     {
01622       for(i=0; i<cRowsNeeded; i++)
01623       {
01624         for(j=0; j<cBindingInfo; j++)
01625         {
01626           //GetData from the Source
01627           XTESTC(hr = pISourceRowset->GetData(rghRows[i], rgBindingInfo[j].hAccessor, pData));
01628
01629           //AdjustBindings
01630           QTESTC(hr = AdjustBindings(rgBindingInfo[j].cBindings, rgBindingInfo[j].rgBindings, pData));
01631         }
01632
01633         //InsertRow to the Target
01634         XTESTC(hr = pIRowsetChange->InsertRow(NULL, hAccessor, pData, NULL));
01635
01636         // Update insert progress
01637         if(pCTableCopy->m_dwInsertOpt == IDR_INSERTROW_IMMEDIATE)
01638         {
01639           // Update insert progress
01640           swprintf(wszBuffer, wsz_COPIED_RECORDS, cRows++);
01641           if(!pCProgress->Update(wszBuffer))
01642             goto CLEANUP;
01643         }
01644
01645         //FreeBindingData - outofline memory
01646         for(j=0; j<cBindingInfo && bOutofLine; j++)
01647           QTESTC(FreeBindingData(rgBindingInfo[j].cBindings, rgBindingInfo[j].rgBindings, pData));
01648       }
01649
01650       //Use IRowsetUpdate::Update if in Bufferred mode
01651       //Update all, since we don't have the inserted row handles...
01652       if(pCTableCopy->m_dwInsertOpt == IDR_INSERTROW_BUFFERED)
01653       {
01654         XTESTC(hr = pIRowsetUpdate->Update(NULL, 0, NULL, NULL, NULL, NULL));
01655
01656         // Update insert progress
01657         swprintf(wszBuffer, wsz_COPIED_RECORDS, cRows += cRowsNeeded);
01658         if(!pCProgress->Update(wszBuffer))
01659           goto CLEANUP;
01660       }
01661     }
01662
01663     //Release the group of rows
01664     XTESTC(hr = pISourceRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL));
01665     SAFE_FREE(rghRows);
01666   }
01667
01668 CLEANUP:
01669   //Stop the propgress
01670   pCProgress->Destroy();
01671   *pcRowsCopied = cRows;
01672
01673   //Release Accessors
01674   if(hAccessor)
01675     XTEST(pIAccessor->ReleaseAccessor(hAccessor, NULL));
01676   SAFE_RELEASE(pIAccessor);
01677
01678   //Free any outofbound data, (error case)
01679   for(i=0; i<cBindingInfo; i++)
01680     FreeBindingData(rgBindingInfo[i].cBindings, rgBindingInfo[i].rgBindings, pData);
01681
01682   //Release Accessors
01683   for(i=0; i<cBindingInfo; i++)
01684   {
01685     XTEST(pCSourceTable->m_pIAccessor->ReleaseAccessor(rgBindingInfo[i].hAccessor, NULL));
01686     FreeBindings(rgBindingInfo[i].cBindings, rgBindingInfo[i].rgBindings);
01687   }
01688
01689   SAFE_FREE(rgBindingInfo);
01690   FreeBindings(cBindings, rgBindings);
01691   SAFE_FREE(pData);
01692
01693   SAFE_RELEASE(pIRowsetChange);
01694   SAFE_RELEASE(pIRowsetUpdate);
01695   SAFE_FREE(rghRows);
01696   return hr;
01697 }
01698
01699
01700
01701
01702 /////////////////////////////////////////////////////////////////////////////
01703 // HRESULT CTable::GetTypeInfoRowset
01704 //
01705 /////////////////////////////////////////////////////////////////////////////
01706 HRESULT CTable::GetTypeInfoRowset(IAccessor** ppIAccessor, HACCESSOR* phAccessor, IRowset** ppIRowset)
01707 {
01708   ASSERT(ppIAccessor && phAccessor && ppIRowset);
01709   ASSERT(m_pCDataSource && m_pCDataSource->m_pIOpenRowset);
01710   HRESULT hr;
01711
01712   IDBSchemaRowset* pIDBSchemaRowset = m_pCDataSource->m_pIDBSchemaRowset;
01713
01714   //Provider doesn't have to support IDBSchemaRowset
01715   if(pIDBSchemaRowset == NULL)
01716     return E_FAIL;
01717
01718   //Bind all the columns from types rowset:
01719   const static ULONG cBindings = 6;
01720   const static DBBINDING rgBindings[cBindings] =
01721   {
01722     //TYPE_NAME
01723     1,
01724     offsetof(TYPEINFO, wszTypeName),  // offset of value in consumers buffer
01725     0,                  // offset of length
01726     0,                  // offset of status
01727     NULL,               // reserved
01728     NULL,               // for ole object
01729     NULL,               // reserved
01730     DBPART_VALUE,           // specifies Value is bound only
01731     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
01732     DBPARAMIO_NOTPARAM,         //
01733     MAX_NAME_LEN,           // size in bytes of the value part in the consumers buffer
01734     0,                  // reserved
01735     DBTYPE_WSTR,            // data type indicator
01736     0,                  // precision
01737     0,                  // scale
01738
01739     //DATA_TYPE
01740     2,
01741     offsetof(TYPEINFO, wType),      // offset of value in consumers buffer
01742     0,                  // offset of length
01743     0,                  // offset of status
01744     NULL,               // reserved
01745     NULL,               // for ole object
01746     NULL,               // reserved
01747     DBPART_VALUE,           // specifies Value is bound only
01748     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
01749     DBPARAMIO_NOTPARAM,         //
01750     sizeof(USHORT),           // size in bytes of the value part in the consumers buffer
01751     0,                  // reserved
01752     DBTYPE_UI2,             // data type indicator
01753     0,                  // precision
01754     0,                  // scale
01755
01756     //COLUMN_SIZE
01757     3,
01758     offsetof(TYPEINFO, ulColumnSize), // offset of value in consumers buffer
01759     0,                  // offset of length
01760     0,                  // offset of status
01761     NULL,               // reserved
01762     NULL,               // for ole object
01763     NULL,               // reserved
01764     DBPART_VALUE,           // specifies Value is bound only
01765     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
01766     DBPARAMIO_NOTPARAM,         //
01767     sizeof(ULONG),            // size in bytes of the value part in the consumers buffer
01768     0,                  // reserved
01769     DBTYPE_UI4,             // data type indicator
01770     0,                  // precision
01771     0,                  // scale
01772
01773     //CREATE_PARAMS
01774     6,
01775     offsetof(TYPEINFO, wszCreateParams),// offset of value in consumers buffer
01776     0,                  // offset of length
01777     0,                  // offset of status
01778     NULL,               // reserved
01779     NULL,               // for ole object
01780     NULL,               // reserved
01781     DBPART_VALUE,           // specifies Value is bound only
01782     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
01783     DBPARAMIO_NOTPARAM,         //
01784     MAX_NAME_LEN,           // size in bytes of the value part in the consumers buffer
01785     0,                  // reserved
01786     DBTYPE_WSTR,            // data type indicator
01787     0,                  // precision
01788     0,                  // scale
01789
01790     //IS_NULLABLE
01791     7,
01792     offsetof(TYPEINFO, fIsNullable),  // offset of value in consumers buffer
01793     0,                  // offset of length
01794     0,                  // offset of status
01795     NULL,               // reserved
01796     NULL,               // for ole object
01797     NULL,               // reserved
01798     DBPART_VALUE,           // specifies Value is bound only
01799     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
01800     DBPARAMIO_NOTPARAM,         //
01801     sizeof(VARIANT_BOOL),       // size in bytes of the value part in the consumers buffer
01802     0,                  // reserved
01803     DBTYPE_BOOL,            // data type indicator
01804     0,                  // precision
01805     0,                  // scale
01806
01807     //AUTO_UNIQUE_VALUE
01808     12,
01809     offsetof(TYPEINFO, fIsAutoInc),   // offset of value in consumers buffer
01810     0,                  // offset of length
01811     0,                  // offset of status
01812     NULL,               // reserved
01813     NULL,               // for ole object
01814     NULL,               // reserved
01815     DBPART_VALUE,           // specifies Value is bound only
01816     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
01817     DBPARAMIO_NOTPARAM,         //
01818     sizeof(VARIANT_BOOL),       // size in bytes of the value part in the consumers buffer
01819     0,                  // reserved
01820     DBTYPE_BOOL,            // data type indicator
01821     0,                  // precision
01822     0,                  // scale
01823   };
01824
01825   //GetRowset
01826   //DBSCHEMA_PROVIDER_TYPES is required a SCHEMA
01827   XTESTC(hr = pIDBSchemaRowset->GetRowset(NULL, DBSCHEMA_PROVIDER_TYPES, 0, NULL, IID_IRowset,0, NULL, (IUnknown**)ppIRowset));
01828
01829   //Create the the Accessor
01830   XTESTC(hr = (*ppIRowset)->QueryInterface(IID_IAccessor, (void **)ppIAccessor));
01831   XTESTC(hr = (*ppIAccessor)->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, 0, phAccessor, NULL));
01832
01833
01834 CLEANUP:
01835   return hr;
01836 }
01837
01838
01839 /////////////////////////////////////////////////////////////////////////////
01840 // HRESULT CTable::GetColumnDesc
01841 //
01842 /////////////////////////////////////////////////////////////////////////////
01843 HRESULT CTable::GetColumnDesc(DBCOLUMNDESC** prgColumnDesc)
01844 {
01845   //Init buffer
01846   ULONG i=0;
01847   HRESULT hr = S_OK;
01848   DBCOLUMNDESC* rgColumnDesc = NULL;
01849   SAFE_ALLOC(rgColumnDesc, DBCOLUMNDESC, m_cColumns);
01850
01851   // For each column, fill out DBCOLUMNDESC info
01852   for(i=0; i<m_cColumns; i++)
01853   {
01854     //TypeName
01855     rgColumnDesc[i].pwszTypeName = m_rgColDesc[i].wszTypeName;
01856
01857     rgColumnDesc[i].pTypeInfo  = NULL;
01858     rgColumnDesc[i].pclsid     = NULL;
01859
01860     //ColumnID
01861     rgColumnDesc[i].dbcid.eKind = DBKIND_NAME;
01862     rgColumnDesc[i].dbcid.uName.pwszName = m_rgColDesc[i].wszColName;
01863
01864     //Typeinfo
01865     rgColumnDesc[i].wType     = m_rgColDesc[i].wType;
01866     rgColumnDesc[i].ulColumnSize  = m_rgColDesc[i].ulColumnSize;
01867     rgColumnDesc[i].bPrecision    = m_rgColDesc[i].bPrecision;
01868     rgColumnDesc[i].bScale      = m_rgColDesc[i].bScale;
01869
01870     //Properties
01871     rgColumnDesc[i].cPropertySets = 0;
01872     rgColumnDesc[i].rgPropertySets = NULL;
01873
01874     //DBPPROP_COL_AUTOINCREMENT
01875 //why make a column auto inc just cause it can be?
01876 //    if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_COL_AUTOINCREMENT, DBPROPSET_COLUMN))
01877 //      SetProperty(DBPROP_COL_AUTOINCREMENT, DBPROPSET_COLUMN, &rgColumnDesc[i].cPropertySets, &rgColumnDesc[i].rgPropertySets, DBTYPE_BOOL, m_rgColDesc[i].fIsAutoInc,DBPROPOPTIONS_OPTIONAL);
01878
01879     //TODO DBPROP_COL_DEFAULT
01880
01881     //TODO DBPROP_COL_DESCRIPTION
01882
01883     //DBPROP_COL_FIXEDLENGTH
01884     if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_COL_FIXEDLENGTH, DBPROPSET_COLUMN))
01885       SetProperty(DBPROP_COL_FIXEDLENGTH, DBPROPSET_COLUMN, &rgColumnDesc[i].cPropertySets, &rgColumnDesc[i].rgPropertySets, DBTYPE_BOOL, IsNumericType(m_rgColDesc[i].wType),DBPROPOPTIONS_OPTIONAL);
01886
01887     //DBPROP_COL_NULLABLE
01888     if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_COL_NULLABLE, DBPROPSET_COLUMN))
01889       SetProperty(DBPROP_COL_NULLABLE, DBPROPSET_COLUMN, &rgColumnDesc[i].cPropertySets, &rgColumnDesc[i].rgPropertySets, DBTYPE_BOOL, m_rgColDesc[i].fIsNullable,DBPROPOPTIONS_OPTIONAL);
01890
01891     //DBPROP_COL_PRIMARYKEY
01892     if(IsSettableProperty(m_pCDataSource->m_pIDBInitialize, DBPROP_COL_PRIMARYKEY, DBPROPSET_COLUMN))
01893       SetProperty(DBPROP_COL_PRIMARYKEY, DBPROPSET_COLUMN, &rgColumnDesc[i].cPropertySets, &rgColumnDesc[i].rgPropertySets, DBTYPE_BOOL, m_rgColDesc[i].fIsPrimaryKey && m_pCWizard->m_pCTableCopy->m_fCopyPrimaryKeys,DBPROPOPTIONS_OPTIONAL);
01894
01895     //TODO DBPROP_COL_UNIQUE
01896   }
01897
01898 CLEANUP:
01899   *prgColumnDesc = rgColumnDesc;
01900   return hr;
01901 }
01902
01903
01904 ///////////////////////////////////////////////////////////////////////////////
01905 // Class CISeqStream
01906 //
01907 // My implementation of ISeqStream interface
01908 ///////////////////////////////////////////////////////////////////////////////
01909
01910 CISeqStream::CISeqStream()
01911 {
01912   m_iPos         = 0;
01913   m_cRef       = 0;
01914   m_pBuffer      = NULL;
01915   m_cBufSize     = 0;
01916
01917   //The constructor AddRef's
01918   AddRef();
01919 }
01920
01921
01922 CISeqStream::~CISeqStream()
01923 {
01924   //Shouldn't have any references left
01925   ASSERT(m_cRef == 0);
01926   SAFE_FREE(m_pBuffer);
01927 }
01928
01929 ULONG CISeqStream::AddRef(void)
01930 {
01931   return ++m_cRef;
01932 }
01933
01934 ULONG CISeqStream::Release(void)
01935 {
01936   ASSERT(m_cRef);
01937
01938   if(--m_cRef)
01939     return m_cRef;
01940
01941   delete this;
01942   return 0;
01943 }
01944
01945 HRESULT CISeqStream::QueryInterface(REFIID riid, void** ppv)
01946 {
01947   ASSERT(ppv);
01948   *ppv = NULL;
01949
01950   if (riid == IID_IUnknown)
01951     *ppv = this;
01952   if (riid == IID_ISequentialStream)
01953     *ppv = this;
01954
01955   if(*ppv)
01956   {
01957     ((IUnknown*)*ppv)->AddRef();
01958     return S_OK;
01959   }
01960
01961   return E_NOINTERFACE;
01962 }
01963
01964 BOOL CISeqStream::Seek(ULONG iPos)
01965 {
01966   //Make sure the desired position is within the buffer
01967   ASSERT(iPos == 0 || iPos < m_cBufSize);
01968
01969   //Reset the current buffer position
01970   m_iPos = iPos;
01971   return TRUE;
01972 }
01973
01974 BOOL CISeqStream::Clear()
01975 {
01976   //Frees the buffer
01977   m_iPos       = 0;
01978   m_cBufSize     = 0;
01979
01980   SAFE_FREE(m_pBuffer);
01981   return TRUE;
01982 }
01983
01984 BOOL CISeqStream::CompareData(void* pBuffer)
01985 {
01986   ASSERT(pBuffer);
01987
01988   //Quick and easy way to compare user buffer with the stream
01989   return memcmp(pBuffer, m_pBuffer, m_cBufSize)==0;
01990 }
01991
01992
01993 HRESULT CISeqStream::Read(void *pv, ULONG cb, ULONG* pcbRead)
01994 {
01995   //Parameter checking
01996   if(pcbRead)
01997     *pcbRead = 0;
01998
01999   if(!pv)
02000     return STG_E_INVALIDPOINTER;
02001
02002   if(cb == 0)
02003     return S_OK;
02004
02005   //Actual code
02006   ULONG cBytesLeft = m_cBufSize - m_iPos;
02007   ULONG cBytesRead = cb > cBytesLeft ? cBytesLeft : cb;
02008
02009   //if no more bytes to retrive return
02010   if(cBytesLeft == 0)
02011     return S_FALSE;
02012
02013   //Copy to users buffer the number of bytes requested or remaining
02014   memcpy(pv, (void*)((BYTE*)m_pBuffer + m_iPos), cBytesRead);
02015   m_iPos += cBytesRead;
02016
02017   if(pcbRead)
02018     *pcbRead = cBytesRead;
02019
02020   if(cb != cBytesRead)
02021     return S_FALSE;
02022
02023   return S_OK;
02024 }
02025
02026 HRESULT CISeqStream::Write(const void *pv, ULONG cb, ULONG* pcbWritten)
02027 {
02028   //Parameter checking
02029   if(!pv)
02030     return STG_E_INVALIDPOINTER;
02031
02032   if(pcbWritten)
02033     *pcbWritten = 0;
02034
02035   if(cb == 0)
02036     return S_OK;
02037
02038   //Enlarge the current buffer
02039   m_cBufSize += cb;
02040
02041   //Need to append to the end of the stream
02042   SAFE_REALLOC(m_pBuffer, BYTE, m_cBufSize);
02043   memcpy((void*)((BYTE*)m_pBuffer + m_iPos), pv, cb);
02044
02045   if(pcbWritten)
02046     *pcbWritten = cb;
02047
02048 CLEANUP:
02049   return S_OK;
02050 }
02051
02052
02053 HRESULT CISeqStream::Write(ISequentialStream* pISeqStream, ULONG* pcbWritten)
02054 {
02055   //Parameter checking
02056   if(!pISeqStream)
02057     return STG_E_INVALIDPOINTER;
02058
02059   if(pcbWritten)
02060     *pcbWritten = 0;
02061
02062   HRESULT hr = S_OK;
02063   ULONG cbRead = MAX_STREAM_BLOCK_SIZE;
02064
02065   //Need to read (in chunks) from the Stream passed in and sotre in our CISeqStream object
02066   while(hr==S_OK && cbRead==MAX_STREAM_BLOCK_SIZE)
02067   {
02068     //Keep appending the data to the end of our buffer
02069     SAFE_REALLOC(m_pBuffer, BYTE, m_cBufSize + MAX_STREAM_BLOCK_SIZE);
02070     hr = pISeqStream->Read((BYTE*)m_pBuffer + m_cBufSize, MAX_STREAM_BLOCK_SIZE, &cbRead);
02071     m_cBufSize += cbRead;
02072
02073     if(pcbWritten)
02074       *pcbWritten += cbRead;
02075   }
02076
02077 CLEANUP:
02078   return S_OK;
02079 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletLongString Member List

This is the complete list of members for tagAppletLongString, including all inherited members.
nStrLen | tagAppletLongString
pnValue | tagAppletLongString
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

RealTimeStylusPluginApp::PluginListItem Member List

This is the complete list of members for RealTimeStylusPluginApp::PluginListItem, including all inherited members.
Description | RealTimeStylusPluginApp::PluginListItem |
Plugin | RealTimeStylusPluginApp::PluginListItem |
PluginListItem(IStylusSyncPlugin stylusPlugin, String pluginDescription) | RealTimeStylusPluginApp::PluginListItem | [inline]
ToString() | RealTimeStylusPluginApp::PluginListItem | [inline]
Generated on Wed Nov 13 2024 16:58:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ConnectPromptEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ConnectPromptEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ConnectPromptEnum
00019
00020 public class ConnectPromptEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adPromptAlways = 1;
00023   public static final short adPromptComplete = 2;
00024   public static final short adPromptCompleteRequired = 3;
00025   public static final short adPromptNever = 4;
00026 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/GetImage/BitmapWnd.cpp Source File

  • Multimedia
  • wia
  • GetImage

BitmapWnd.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 --*/
00006
00007 #include "stdafx.h"
00008 #include "resource.h"
00009
00010 #include "BitmapUtil.h"
00011 #include "BitmapWnd.h"
00012
00013 //////////////////////////////////////////////////////////////////////////
00014 //
00015 // CBitmapWnd::CBitmapWnd
00016 //
00017
00018 CBitmapWnd::CBitmapWnd(IStream *pStream) : m_Image(pStream)
00019 {
00020     m_cRef = 0;
00021 }
00022
00023 //////////////////////////////////////////////////////////////////////////
00024 //
00025 // CBitmapWnd::CBitmapWnd
00026 //
00027
00028 CBitmapWnd::CBitmapWnd(PCWSTR pszFileName) : m_Image(pszFileName)
00029 {
00030     m_cRef = 0;
00031 }
00032
00033 //////////////////////////////////////////////////////////////////////////
00034 //
00035 // CBitmapWnd::QueryInterface
00036 //
00037
00038 STDMETHODIMP CBitmapWnd::QueryInterface(REFIID iid, LPVOID *ppvObj)
00039 {
00040     if (ppvObj == NULL)
00041     {
00042       return E_POINTER;
00043     }
00044
00045     if (iid == IID_IUnknown)
00046     {
00047       *ppvObj = (IUnknown *) this;
00048     }
00049     else
00050     {
00051         *ppvObj = NULL;
00052         return E_NOINTERFACE;
00053     }
00054
00055   AddRef();
00056     return S_OK;
00057 }
00058
00059 //////////////////////////////////////////////////////////////////////////
00060 //
00061 // CBitmapWnd::AddRef
00062 //
00063
00064 STDMETHODIMP_(ULONG) CBitmapWnd::AddRef()
00065 {
00066     return InterlockedIncrement(&m_cRef);
00067 }
00068
00069 //////////////////////////////////////////////////////////////////////////
00070 //
00071 // CBitmapWnd::Release
00072 //
00073
00074 STDMETHODIMP_(ULONG) CBitmapWnd::Release()
00075 {
00076     LONG cRef = InterlockedDecrement(&m_cRef);
00077
00078     if (cRef == 0)
00079     {
00080         delete this;
00081     }
00082
00083     return cRef;
00084 }
00085
00086 ///////////////////////////////////////////////////////////////////////////////
00087 //
00088 // CBitmapWnd::Register
00089 //
00090
00091 ATOM CBitmapWnd::Register()
00092 {
00093     WNDCLASSEX wcex = { 0 };
00094
00095     wcex.cbSize         = sizeof(wcex);
00096     wcex.style          = CS_HREDRAW | CS_VREDRAW;
00097     wcex.lpfnWndProc    = WindowProc;
00098     wcex.hInstance      = g_hInstance;
00099     wcex.hIcon      = LoadIcon(NULL, IDI_APPLICATION);
00100     wcex.hCursor    = LoadCursor(NULL, IDC_ARROW);
00101     wcex.lpszClassName  = _T("BitmapWindow");
00102
00103     return RegisterClassEx(&wcex);
00104 }
00105
00106 //////////////////////////////////////////////////////////////////////////
00107 //
00108 // CBitmapWnd::WindowProc
00109 //
00110
00111 LRESULT
00112 CALLBACK
00113 CBitmapWnd::WindowProc(
00114     HWND   hWnd,
00115     UINT   uMsg,
00116     WPARAM wParam,
00117     LPARAM lParam
00118 )
00119 {
00120     switch (uMsg)
00121     {
00122         case WM_CREATE:
00123         {
00124             LPCREATESTRUCT pcs = (LPCREATESTRUCT) lParam;
00125
00126             LPMDICREATESTRUCT pmdics = (LPMDICREATESTRUCT) pcs->lpCreateParams;
00127
00128             CBitmapWnd *that = (CBitmapWnd *) pmdics->lParam;
00129
00130             that->AddRef();
00131
00132             SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) that);
00133
00134             break;
00135         }
00136
00137         case WM_DESTROY:
00138         {
00139             CBitmapWnd *that = (CBitmapWnd *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
00140
00141             SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL);
00142
00143             that->Release();
00144
00145             break;
00146         }
00147
00148         case WM_PAINT:
00149         {
00150             CBitmapWnd *that = (CBitmapWnd *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
00151
00152             that->OnPaint(hWnd);
00153
00154             break;
00155         }
00156     }
00157
00158     return DefMDIChildProc(
00159         hWnd,
00160         uMsg,
00161         wParam,
00162         lParam
00163     );
00164 }
00165
00166 //////////////////////////////////////////////////////////////////////////
00167 //
00168 // CBitmapWnd::OnPaint
00169 //
00170
00171 LRESULT CBitmapWnd::OnPaint(HWND hWnd)
00172 {
00173     // Get the destination DC
00174
00175     PAINTSTRUCT ps;
00176
00177     HDC hDC = BeginPaint(hWnd, &ps);
00178
00179     if (hDC != NULL)
00180     {
00181         Gdiplus::Graphics graphics(hDC);
00182
00183         // Get the size of the window
00184
00185         RECT r;
00186
00187         GetClientRect(hWnd, &r);
00188
00189         UINT nWindowWidth = r.right;
00190         UINT nWindowHeight = r.bottom;
00191
00192         // Get the size of the image
00193
00194         UINT nBitmapWidth = m_Image.GetWidth();
00195         UINT nBitmapHeight = m_Image.GetHeight();
00196
00197         if (nBitmapWidth != 0 && nBitmapHeight != 0)
00198         {
00199             // Calculate the coordinates and the size of the image
00200
00201             Gdiplus::Rect rDest;
00202
00203             if (nBitmapWidth <= nWindowWidth && nBitmapHeight <= nWindowHeight)
00204             {
00205                 // If the image is smaller than the window, center the image
00206
00207                 rDest.X      = (nWindowWidth - nBitmapWidth) / 2;
00208                 rDest.Y      = (nWindowHeight - nBitmapHeight) / 2;
00209                 rDest.Width  = nBitmapWidth;
00210                 rDest.Height = nBitmapHeight;
00211             }
00212             else
00213             {
00214                 // If the image is larger than the window, resize and center
00215                 // the image while keeping the aspect ratio
00216
00217                 UINT nStretchedWidth  = nWindowWidth;
00218                 UINT nStretchedHeight = MulDiv(nBitmapHeight, nWindowWidth, nBitmapWidth);
00219
00220           if (nStretchedHeight > nWindowHeight)
00221           {
00222             nStretchedWidth  = MulDiv(nBitmapWidth, nWindowHeight, nBitmapHeight);
00223             nStretchedHeight = nWindowHeight;
00224           }
00225
00226                 rDest.X      = (nWindowWidth - nStretchedWidth) / 2;
00227                 rDest.Y      = (nWindowHeight - nStretchedHeight) / 2;
00228                 rDest.Width  = nStretchedWidth;
00229                 rDest.Height = nStretchedHeight;
00230             }
00231
00232             // Paint the image with a white background
00233
00234             graphics.DrawImage(&m_Image, rDest);
00235
00236             graphics.ExcludeClip(rDest);
00237         }
00238
00239         graphics.Clear(Gdiplus::Color::White);
00240
00241         EndPaint(hWnd, &ps);
00242     }
00243
00244     return 0;
00245 }
00246
00247
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/c_draw/DrawArea.Cpp Source File

  • NetDS
  • MessageQueuing
  • c_draw

DrawArea.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 //
00013 // drawarea.cpp : implementation file
00014 //
00015 //
00016
00017
00018 #include "stdafx.h"
00019 #include "disdraw.h"
00020 #include "drawdlg.h"
00021
00022 #ifdef _DEBUG
00023 #define new DEBUG_NEW
00024 #undef THIS_FILE
00025 static char THIS_FILE[] = __FILE__;
00026 #endif
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CDrawArea
00030
00031 CDrawArea::CDrawArea()
00032 {
00033 }
00034
00035 CDrawArea::~CDrawArea()
00036 {
00037 }
00038
00039
00040 BEGIN_MESSAGE_MAP(CDrawArea, CEdit)
00041   //{{AFX_MSG_MAP(CDrawArea)
00042   ON_WM_LBUTTONDOWN()
00043   ON_WM_MOUSEMOVE()
00044   ON_WM_PAINT()
00045   ON_WM_RBUTTONUP()
00046   ON_WM_CTLCOLOR_REFLECT()
00047   ON_WM_KEYDOWN()
00048   ON_WM_CHAR()
00049   ON_WM_SETFOCUS()
00050   ON_WM_SETCURSOR()
00051   ON_WM_LBUTTONDBLCLK()
00052   //}}AFX_MSG_MAP
00053 END_MESSAGE_MAP()
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // CDrawArea message handlers
00057
00058 void CDrawArea::AddKeystroke(char *mbsKey)
00059 {
00060   //
00061   // The backspace keystroke should erase the preceding character.
00062   //
00063   if (mbsKey[0] == VK_BACK)
00064   {
00065     int nStart, nEnd;
00066     GetSel(nStart, nEnd);
00067     SetSel(nEnd-1, nEnd);
00068     mbsKey[0] = '\0';
00069
00070         //
00071         // Erasing a line feed should erase the preceding carriage return.
00072         //
00073         CString strText;
00074         GetWindowText(strText);
00075         int iLength = strText.GetLength();
00076         if (iLength > 0 && strText.GetAt(strText.GetLength() - 1) == '\n')
00077             SetSel(nEnd-2, nEnd);
00078   }
00079
00080   //
00081   // Append a line feed to a carriage return.
00082   //
00083   else if (mbsKey[0] == VK_RETURN)
00084   {
00085     mbsKey[1] = '\xa';
00086     mbsKey[2] = '\0';
00087   }
00088   //
00089   // Store the new keystroke.
00090   //
00091   ReplaceSel(mbsKey);
00092 }
00093
00094
00095 void CDrawArea::AddLine(LINE line)
00096 {
00097   //
00098   // Set the clipping region for the drawing.
00099   //
00100   CClientDC dc(this);
00101   RECT rect;
00102   GetClientRect(&rect);
00103   CRgn rgn;
00104   rgn.CreateRectRgnIndirect(&rect);
00105   dc.SelectClipRgn(&rgn);
00106
00107   //
00108   // Draw the line and save it for redrawing.
00109   //
00110   dc.MoveTo(line.ptStart);
00111   dc.LineTo(line.ptEnd);
00112     m_listLines.AddTail(line);
00113 }
00114
00115
00116 void CDrawArea::OnLButtonDown(UINT nFlags, CPoint point)
00117 {
00118   // TODO: Add your message handler code here and/or call default.
00119
00120   m_ptLast = point;
00121   SetFocus();
00122 }
00123
00124
00125 void CDrawArea::OnMouseMove(UINT nFlags, CPoint point)
00126 {
00127   // TODO: Add your message handler code here and/or call default.
00128
00129   if (nFlags & MK_LBUTTON)
00130   {
00131     //
00132     // Add the line drawn to the drawing.
00133     //
00134     LINE line;
00135     line.ptStart = m_ptLast;
00136     line.ptEnd = point;
00137         AddLine(line);
00138
00139     //
00140     // Send the line to the friend queue.
00141     //
00142     ((CDisdrawDlg *)GetParent())->SendMouseMovement(line);
00143
00144     //
00145     // Remember the end point of the line.
00146     //
00147     m_ptLast = point;
00148   }
00149 }
00150
00151
00152 void CDrawArea::OnPaint()
00153 {
00154   CPaintDC dc(this); // device context for painting
00155
00156   // TODO: Add your message handler code here.
00157
00158   //
00159   // Set the clipping region for the drawing.
00160   //
00161   RECT rect;
00162   GetClientRect(&rect);
00163   CRgn rgn;
00164   rgn.CreateRectRgnIndirect(&rect);
00165   dc.SelectClipRgn(&rgn);
00166
00167   //
00168   // Erase the drawing area.
00169   //
00170   dc.FillSolidRect(&rect, GetSysColor(COLOR_MENU));
00171
00172   //
00173   // Redisplay the text.
00174   //
00175     CString strText;
00176     GetWindowText(strText);
00177     dc.SelectStockObject(ANSI_VAR_FONT);
00178     rect.top++;
00179     rect.left++;
00180     dc.DrawText(strText, &rect, DT_TOP | DT_WORDBREAK);
00181
00182   //
00183   // Redraw each line.
00184   //
00185   LINE line;
00186   POSITION posLine = m_listLines.GetHeadPosition();
00187   while (posLine != NULL)
00188   {
00189     line = m_listLines.GetNext(posLine);
00190     dc.MoveTo(line.ptStart);
00191     dc.LineTo(line.ptEnd);
00192   }
00193
00194   // Do not call CEdit::OnPaint() for painting messages.
00195 }
00196
00197
00198 void CDrawArea::OnRButtonUp(UINT nFlags, CPoint point)
00199 {
00200   // TODO: Add your message handler code here and/or call default.
00201
00202   //
00203   // Clear the drawing area.
00204   //
00205   SetSel(0, -1);
00206   Clear();
00207   m_listLines.RemoveAll();
00208   RedrawWindow();
00209 }
00210
00211
00212 BOOL CDrawArea::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00213 {
00214   // TODO: Add your message handler code here and/or call default.
00215
00216   return 0;
00217 }
00218
00219
00220 void CDrawArea::OnSetFocus(CWnd* pOldWnd)
00221 {
00222   CEdit::OnSetFocus(pOldWnd);
00223
00224   // TODO: Add your message handler code here.
00225
00226   HideCaret();
00227 }
00228
00229
00230 HBRUSH CDrawArea::CtlColor(CDC* pDC, UINT nCtlColor)
00231 {
00232   // TODO: Change any attributes of the DC here.
00233   pDC->SetBkColor(GetSysColor(COLOR_MENU));
00234
00235   // TODO: Return a non-NULL brush if the parent's handler should not be called.
00236   return HBRUSH((CBrush *)pDC->SelectStockObject(LTGRAY_BRUSH));
00237 }
00238
00239
00240 void CDrawArea::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
00241 {
00242   // TODO: Add your message handler code here and/or call default.
00243
00244   switch (nChar)
00245   {
00246   case VK_LEFT:
00247   case VK_RIGHT:
00248   case VK_UP:
00249   case VK_DOWN:
00250   case VK_HOME: break;
00251   default:    CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
00252   }
00253 }
00254
00255
00256 void CDrawArea::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
00257 {
00258   // TODO: Add your message handler code here and/or call default.
00259   ((CDisdrawDlg *)GetParent())->SendKeystroke(nChar);
00260
00261   CEdit::OnChar(nChar, nRepCnt, nFlags);
00262
00263   RedrawWindow();
00264 }
00265
00266
00267 void CDrawArea::OnLButtonDblClk(UINT nFlags, CPoint point)
00268 {
00269   // TODO: Add your message handler code here and/or call default.
00270 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMemoryException Member List

This is the complete list of members for CMemoryException, including all inherited members.
Delete(void) | CMemoryException | [inline]
Delete(void) | CMemoryException | [inline]
Delete(void) | CMemoryException | [inline]
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/sky.h Source File

  • SysMgmt
  • MMC
  • Toolbar

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025 class CSkyBasedVehicle : public CDelegationBase {
00026 public:
00027     CSkyBasedVehicle(CComponentData *pComponentData = NULL)
00028     { m_pComponentData = pComponentData;  }
00029
00030     virtual ~CSkyBasedVehicle() {}
00031
00032     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00033     virtual const GUID & getNodeType() { return thisGuid; }
00034     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00035
00036 public:
00037     // virtual functions go here (for MMCN_*)
00038
00039 private:
00040     enum { IDM_NEW_SKY = 3 };
00041
00042     // {2974380F-4C4B-11d2-89D8-000021473128}
00043     static const GUID thisGuid;
00044 };
00045
00046 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/basesnap.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

basesnap.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  Abstract: This module provides the basic COM and DLL methods to create
00015 //            and load the Snap-in.  IClassFactory::CreateInstance creates
00016 //            an instance of a class whose type is passed in the constructor
00017 //
00018
00019
00020 #ifndef _BASESNAP_H_
00021 #define _BASESNAP_H_
00022
00023 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppvObj);
00024 STDAPI DllCanUnloadNow(void);
00025
00026 //---------------------------------------------------------------------------
00027 //  NEW:  Added the FACTORY_TYPE enumeration and changed the class
00028 //        constructor to support multiple types
00029 //
00030 class CClassFactory : public IClassFactory
00031 {
00032   public:
00033     enum FACTORY_TYPE {COMPONENTDATA = 0, ABOUT = 1};
00034
00035   public:
00036     CClassFactory(FACTORY_TYPE eFactoryType);
00037     ~CClassFactory();
00038
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
00044     STDMETHODIMP LockServer(BOOL);
00045
00046   private:
00047     ULONG         m_cRef;
00048     FACTORY_TYPE  m_FactoryType;
00049
00050 };
00051
00052 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/comp.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

comp.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Comp.h"
00016 #include "CompData.h"
00017 #include "DataObj.h"
00018 #include "Resource.h"
00019 #include "StaticNode.h"
00020
00021                              // Tracing stuff
00022 #include "TraceMacro.h"
00023 #undef  MODULESTRING
00024 #define MODULESTRING  _T("CComponent")
00025
00026
00027 //---------------------------------------------------------------------------
00028 //  Our default constuctor provides a pointer to the parent CComponentData
00029 //  class which we cache for use in later samples.
00030 //
00031 CComponent::CComponent
00032 (
00033   CComponentData*  pParent   //[in] Points to parent object
00034 )
00035 {
00036   _ASSERT( NULL != pParent );
00037
00038   m_cRef           = 0;
00039   m_pComponentData = pParent;
00040
00041 }
00042
00043 //---------------------------------------------------------------------------
00044 CComponent::~CComponent()
00045 {
00046 }
00047
00048 /////////////////////////////////////////////////////////////////////////////
00049 //  Implementation of IUnknown
00050
00051 //---------------------------------------------------------------------------
00052 STDMETHODIMP CComponent::QueryInterface
00053 (
00054   REFIID   riid,       //[in] Identifier of the requested interface
00055   LPVOID   *ppv        //[out] Address of requested interface
00056 )
00057 {
00058   if( !ppv )
00059     return E_FAIL;
00060
00061   *ppv = NULL;
00062
00063   if( IsEqualIID(riid, IID_IUnknown) )
00064     *ppv = static_cast<IComponent*>(this);
00065   else if( IsEqualIID(riid, IID_IComponent) )
00066     *ppv = static_cast<IComponent*>(this);
00067   else if( IsEqualIID(riid, IID_IComponent2) )
00068     *ppv = static_cast<IComponent2*>(this);
00069
00070
00071
00072   if( *ppv )
00073   {
00074     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00075     return S_OK;
00076   }
00077
00078   return E_NOINTERFACE;
00079 }
00080
00081 //---------------------------------------------------------------------------
00082 STDMETHODIMP_(ULONG) CComponent::AddRef()
00083 {
00084   return InterlockedIncrement((LONG*)&m_cRef);
00085 }
00086
00087 //---------------------------------------------------------------------------
00088 STDMETHODIMP_(ULONG) CComponent::Release()
00089 {
00090   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00091   {
00092     delete this;
00093     return 0;
00094   }
00095   return m_cRef;
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // Implementation of IComponent
00100
00101 //---------------------------------------------------------------------------
00102 STDMETHODIMP CComponent::Initialize
00103 (
00104   LPCONSOLE ipConsole    //[in] Points to the console's IUnknown
00105 )
00106 {
00107   HRESULT hResult = S_OK;
00108
00109   // Have to return S_OK here or we will get the dreaded message
00110   // "The selected snap-in did not initialize properly"
00111
00112   return hResult;
00113 }
00114
00115
00116 //---------------------------------------------------------------------------
00117 STDMETHODIMP CComponent::Notify
00118 (
00119   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00120   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00121   LPARAM           nArg,           //[in] Depends on the notification type
00122   LPARAM           nParam          //[in] Depends on the notification type
00123 )
00124 {
00125   TRACE_EVENT( _T("Notify"), MmcEvent );
00126   // Not doing anything here except providing trace output for
00127   // MMC's notifications
00128
00129   return E_NOTIMPL;
00130 }
00131
00132 //---------------------------------------------------------------------------
00133 STDMETHODIMP CComponent::Destroy
00134 (
00135   MMC_COOKIE nCookie   //[in] Not used
00136 )
00137 {
00138   return S_OK;
00139 }
00140
00141 //---------------------------------------------------------------------------
00142 STDMETHODIMP CComponent::QueryDataObject
00143 (
00144   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00145   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00146   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00147 )
00148 {
00149   return E_NOTIMPL;
00150 }
00151
00152 //---------------------------------------------------------------------------
00153 //  Delegate this to the static node
00154 //
00155 STDMETHODIMP CComponent::GetResultViewType
00156 (
00157   MMC_COOKIE          nCookie,     //[in]  Indentifier of selected node
00158   LPOLESTR __RPC_FAR* ppViewType,  //[out] Points to view type string
00159   long __RPC_FAR*     pViewOptions //[out] Points to MMC_VIEW_OPTIONS enumeration
00160 )
00161 {
00162   HRESULT hResult = E_NOTIMPL;   //S_FALSE;
00163
00164   _ASSERT( FALSE );    //BUGLIST:  Should never get called
00165
00166 /*
00167   if( NULL == nCookie )
00168   {
00169     CStaticNode* pNode = m_pComponentData->GetStaticNode();
00170     hResult = pNode->GetResultViewType( ppViewType, pViewOptions );
00171   }
00172   else
00173   {
00174     _ASSERT( FALSE );
00175   }
00176 */
00177
00178   return hResult;
00179 }
00180
00181
00182 //---------------------------------------------------------------------------
00183 STDMETHODIMP CComponent::GetDisplayInfo
00184 (
00185   RESULTDATAITEM __RPC_FAR* pResultDataItem  //[in][out] Result item struct
00186 )
00187 {
00188   HRESULT hResult = S_FALSE;
00189
00190   // This never gets called in this sample
00191   return hResult;
00192 }
00193
00194 //---------------------------------------------------------------------------
00195 STDMETHODIMP CComponent::CompareObjects
00196 (
00197   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00198   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00199 )
00200 {
00201   return E_NOTIMPL;
00202 }
00203
00204 //---------------------------------------------------------------------------
00205 HRESULT CComponent::QueryDispatch
00206 (
00207   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00208   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00209   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00210 )
00211 {
00212   return E_NOTIMPL;
00213 }
00214
00215 //---------------------------------------------------------------------------
00216 //  NOTE:  Failure to correctly implement this method will result in
00217 //         the error:  "Snap-in failed to initialize"
00218 //
00219 HRESULT CComponent::GetResultViewType2
00220 (
00221   MMC_COOKIE             nCookie,  //[in] Identifier of object
00222   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00223 )
00224 {
00225   HRESULT hResult = S_FALSE;
00226
00227   if( NULL == nCookie )
00228   {
00229     CStaticNode* pNode = m_pComponentData->GetStaticNode();
00230     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00231   }
00232   else
00233   {
00234     _ASSERT( FALSE );
00235   }
00236
00237   TRACE_HRESULT(_T("GetResultViewType2"), hResult );
00238   return hResult;
00239 }
00240
00241
00242
00243 //---------------------------------------------------------------------------
00244 HRESULT CComponent::RestoreResultView
00245 (
00246   MMC_COOKIE             nCookie,         //[in] Identifier of object
00247   PRESULT_VIEW_TYPE_INFO pResultViewType  //[in,out] View type info data
00248 )
00249 {
00250   return E_NOTIMPL;
00251 }
00252
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADSIDump/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADSIDump

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  AdsiDump.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepmultiuser/resources.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepmultiuser

resources.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     FILE: Resources.cpp
00005
00006     PURPOSE: Declarations for resource management routines and
00007         data structures.
00008
00009     COMMENTS:  See Resources.h for function and data-type info.
00010
00011 */
00012
00013 #include <Windows.h>
00014
00015 #include "Resources.h"
00016 #include "common.h"
00017 #include "Service.h"
00018
00019 #ifdef DEBUG
00020 #include "DbgMsg.h"
00021 #endif
00022
00023 Counter * CounterCreate(UINT Bound) {
00024     Counter * pCounter;
00025
00026 #ifdef DEBUG
00027     DbgMsgRecord(TEXT("-> CounterCreate\n"));
00028 #endif
00029
00030     pCounter = (Counter *)AutoHeapAlloc(sizeof(Counter));
00031
00032     if (pCounter == NULL) {
00033         return NULL;
00034     }
00035
00036     pCounter->Value = 0;
00037     pCounter->Bound = Bound;
00038
00039 #ifdef DEBUG
00040     DbgMsgRecord(TEXT("<- CounterCreate\n"));
00041 #endif
00042
00043     return pCounter;
00044 }
00045
00046 VOID CounterDelete(Counter * pCounter) {
00047
00048 #ifdef DEBUG
00049     DbgMsgRecord(TEXT("-> CounterDelete\n"));
00050 #endif
00051
00052     ASSERTE(pCounter != NULL);
00053
00054     AutoHeapFree(pCounter);
00055
00056 #ifdef DEBUG
00057     DbgMsgRecord(TEXT("<- QueueDelete\n"));
00058 #endif
00059 }
00060
00061 BOOL CounterIncrement(Counter *pCounter) {
00062     BOOL ret = FALSE;
00063
00064 #ifdef DEBUG
00065     DbgMsgRecord(TEXT("-> CounterIncrement\n"));
00066 #endif
00067
00068     ASSERTE(pCounter != NULL);
00069
00070     // Check for the bound.
00071     if (InterlockedIncrement(&pCounter->Value) > pCounter->Bound) {
00072         ret = FALSE;
00073         InterlockedDecrement(&pCounter->Value);
00074     }
00075     else {
00076         ret = TRUE;
00077     }
00078
00079 #ifdef DEBUG
00080     DbgMsgRecord(TEXT("<- CounterIncrement\n"));
00081 #endif
00082
00083     return ret;
00084 }
00085
00086 VOID CounterDecrement(Counter *pCounter) {
00087
00088 #ifdef DEBUG
00089     DbgMsgRecord(TEXT("-> CounterDecrement\n"));
00090 #endif
00091
00092     ASSERTE(pCounter != NULL);
00093
00094     InterlockedDecrement(&pCounter->Value);
00095
00096 #ifdef DEBUG
00097     DbgMsgRecord(TEXT("<- CounterDecrement\n"));
00098 #endif
00099
00100 }
00101
00102 BOOL CountersCreate(Counter *pCounters[], UINT n, UINT * Bounds) {
00103     BOOL ret = FALSE;
00104
00105 #ifdef DEBUG
00106     DbgMsgRecord(TEXT("-> CountersCreate\n"));
00107 #endif
00108
00109     for (UINT i=0; i<n; i++) {
00110         if ((pCounters[i] = CounterCreate(Bounds[i])) == NULL) {
00111             CountersDelete(pCounters, i-1);
00112             ret = FALSE;
00113             break;
00114         }
00115     }
00116     ret = TRUE;
00117
00118 #ifdef DEBUG
00119     DbgMsgRecord(TEXT("<- CountersCreate\n"));
00120 #endif
00121
00122     return ret;
00123 }
00124
00125 VOID CountersDelete(Counter *pCounters[], UINT n) {
00126
00127 #ifdef DEBUG
00128     DbgMsgRecord(TEXT("-> CountersDelete\n"));
00129 #endif
00130
00131     for (UINT i=0; i<n; i++) {
00132         ASSERTE(pCounters[i] != NULL);
00133         CounterDelete(pCounters[i]);
00134         pCounters[i] = NULL;
00135     }
00136
00137 #ifdef DEBUG
00138     DbgMsgRecord(TEXT("<- CountersDelete\n"));
00139 #endif
00140 }
00141
00142 BOOL CountersCheckForNonzero(Counter *pCounters[], UINT n) {
00143     for (UINT i=0; i<n; i++) {
00144         ASSERTE(pCounters[i] != NULL);
00145         if (pCounters[i]->Value != 0) {
00146             return TRUE;
00147         }
00148     }
00149     return FALSE;
00150 }
00151
00152 Queue * QueueCreate(BOOL NoCritSec) {
00153     Queue * pQueue;
00154
00155 #ifdef DEBUG
00156     DbgMsgRecord(TEXT("-> QueueCreate\n"));
00157 #endif
00158
00159     pQueue = (Queue *)AutoHeapAlloc(sizeof(Queue));
00160
00161     if (pQueue == NULL) {
00162         AddToMessageLog(TEXT("QueueCreate: AutoHeapAlloc failed"));
00163         return NULL;
00164     }
00165
00166     pQueue->pFirst = NULL;
00167     pQueue->pLast = NULL;
00168
00169     if (NoCritSec) {
00170         pQueue->lpCriticalSection = NULL;
00171     }
00172     else {
00173         pQueue->lpCriticalSection = (LPCRITICAL_SECTION) AutoHeapAlloc(sizeof(CRITICAL_SECTION));
00174         if (InitializeCriticalSectionAndSpinCount(pQueue->lpCriticalSection, 0) == 0) {
00175             AddToMessageLogProcFailure(TEXT("QueueCreate: InitializeCriticalSectionAndSpinCount"), GetLastError());
00176             QueueDelete(pQueue);
00177             return NULL;
00178         }
00179     }
00180
00181 #ifdef DEBUG
00182     DbgMsgRecord(TEXT("<- QueueCreate\n"));
00183 #endif
00184
00185     return pQueue;
00186 }
00187
00188 VOID QueueDelete(Queue * pQueue) {
00189     QueueNode *pNextNode;
00190
00191 #ifdef DEBUG
00192     DbgMsgRecord(TEXT("-> QueueDelete\n"));
00193 #endif
00194
00195     ASSERTE(pQueue != NULL);
00196
00197     if (pQueue->lpCriticalSection != NULL) {
00198         DeleteCriticalSection(pQueue->lpCriticalSection);
00199         AutoHeapFree(pQueue->lpCriticalSection);
00200     }
00201
00202     if (pQueue->pFirst != NULL) {
00203         for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNextNode) {
00204             pNextNode = pNode->pNext;
00205             AutoHeapFree(pNode->pData);
00206             AutoHeapFree(pNode);
00207         }
00208     }
00209
00210     AutoHeapFree(pQueue);
00211
00212 #ifdef DEBUG
00213     DbgMsgRecord(TEXT("<- QueueDelete\n"));
00214 #endif
00215 }
00216
00217 BOOL QueueIsEmpty(Queue * pQueue) {
00218     BOOL Ret = FALSE;
00219
00220     ASSERTE(pQueue != NULL);
00221
00222     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00223
00224     Ret = (pQueue->pFirst == NULL);
00225
00226     ASSERTE((!Ret) || (pQueue->pFirst == pQueue->pLast));
00227
00228     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00229
00230     return Ret;
00231 }
00232
00233 VOID QueueAdd(Queue *pQueue, VOID *pData, BOOL EnterCritSec) {
00234
00235     ASSERTE(pQueue != NULL);
00236
00237 #ifdef DEBUG
00238     DbgMsgRecord(TEXT("-> QueueAdd\n"));
00239 #endif
00240
00241     QueueNode * pNode = (QueueNode *) AutoHeapAlloc(sizeof(QueueNode));
00242     if (pNode == NULL) {
00243         AddToMessageLog(TEXT("QueueAdd: AutoHeapAlloc failed"));
00244         return;
00245     }
00246
00247     pNode->pNext = NULL;
00248     pNode->pData = pData;
00249
00250     if (pQueue->lpCriticalSection != NULL && EnterCritSec) EnterCriticalSection(pQueue->lpCriticalSection);
00251
00252     if (pQueue->pFirst == NULL) {
00253         ASSERTE(pQueue->pLast == NULL);
00254         pQueue->pFirst = pNode;
00255         pQueue->pLast = pNode;
00256     }
00257     else {
00258         ASSERTE(pQueue->pLast->pNext == NULL);
00259         pQueue->pLast->pNext = pNode;
00260         pQueue->pLast = pNode;
00261     }
00262
00263 #ifdef DEBUG
00264     DbgMsgRecord(TEXT("<- QueueAdd\n"));
00265 #endif
00266
00267     if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00268 }
00269
00270 VOID * QueueRemove(Queue *pQueue) {
00271     VOID * pData;
00272     QueueNode *pFuturepFirst;
00273     VOID * pToFree;
00274
00275     ASSERTE(pQueue != NULL);
00276
00277     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00278
00279 #ifdef DEBUG
00280     DbgMsgRecord(TEXT("-> QueueRemove\n"));
00281 #endif
00282
00283     if (pQueue->pFirst == NULL) {
00284         ASSERTE(pQueue->pFirst == pQueue->pLast);
00285
00286         if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00287         return NULL;
00288     }
00289
00290     pData = pQueue->pFirst->pData;
00291     pFuturepFirst = pQueue->pFirst->pNext;
00292
00293     if (pFuturepFirst == NULL) {
00294         pQueue->pLast = NULL;
00295     }
00296
00297     pToFree = pQueue->pFirst;
00298     pQueue->pFirst = pFuturepFirst;
00299
00300 #ifdef DEBUG
00301     DbgMsgRecord(TEXT("<- QueueRemove\n"));
00302 #endif
00303
00304     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00305
00306     AutoHeapFree(pToFree);
00307
00308     return pData;
00309 }
00310
00311 VOID QueueMoveToBack(Queue *pQueue, QueueNode *pNode, QueueNode *pPrevNode) {
00312
00313     ASSERTE(pQueue != NULL);
00314     ASSERTE(pNode != NULL);
00315
00316     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00317
00318     // If it is the first element.
00319     if (pPrevNode == NULL) {
00320         pQueue->pFirst = pNode->pNext;
00321     }
00322     // If it has a predecessor in the queue
00323     else {
00324         pPrevNode->pNext = pNode->pNext;
00325     }
00326
00327     // If it is the last element.
00328     if (pNode->pNext == NULL) {
00329         if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00330         return;
00331     }
00332
00333     // Put the subqueue onto the back of the queue.
00334     pNode->pNext = NULL;
00335     if (QueueIsEmpty(pQueue)) {
00336         pQueue->pFirst = pNode;
00337         pQueue->pLast = pNode;
00338     }
00339     else {
00340         pQueue->pLast->pNext = pNode;
00341         pQueue->pLast = pNode;
00342     }
00343
00344     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00345 }
00346
00347 BOOL QueuesCreate(Queue *Queues[], UINT n, BOOL NoCritSec) {
00348     BOOL ret = FALSE;
00349
00350 #ifdef DEBUG
00351     DbgMsgRecord(TEXT("-> QueuesCreate\n"));
00352 #endif
00353
00354     for (UINT i=0; i<n; i++) {
00355         if ((Queues[i] = QueueCreate(NoCritSec)) == NULL) {
00356             QueuesDelete(Queues, i-1);
00357             ret = FALSE;
00358             break;
00359         }
00360     }
00361
00362     ret = TRUE;
00363
00364 #ifdef DEBUG
00365     DbgMsgRecord(TEXT("<- QueuesCreate\n"));
00366 #endif
00367
00368     return ret;
00369 }
00370
00371 VOID QueuesDelete(Queue *Queues[], UINT n) {
00372
00373 #ifdef DEBUG
00374     DbgMsgRecord(TEXT("-> QueuesDelete\n"));
00375 #endif
00376
00377     for (UINT i=0; i<n; i++) {
00378         QueueDelete(Queues[i]);
00379         Queues[i] = NULL;
00380     }
00381
00382 #ifdef DEBUG
00383     DbgMsgRecord(TEXT("<- QueuesDelete\n"));
00384 #endif
00385
00386 }
00387
00388 VOID QueueHashAdd(Queue *pQueue, PSID Sid, VOID *pValue, BOOL EnterCritSec) {
00389     QueueHashNode *pQueueHashNode;
00390     DWORD SidLength;
00391
00392     ASSERTE(pQueue != NULL);
00393
00394     if (pQueue->lpCriticalSection != NULL && EnterCritSec) EnterCriticalSection(pQueue->lpCriticalSection);
00395
00396 #ifdef DEBUG
00397     DbgMsgRecord(TEXT("-> QueueHashAdd\n"));
00398 #endif
00399
00400     pQueueHashNode = (QueueHashNode *) AutoHeapAlloc(sizeof(QueueHashNode));
00401
00402     SidLength = GetLengthSid(Sid);
00403
00404     // We need to copy the key so that if the original
00405     // copy gets deallocated we still have one.
00406     if ((pQueueHashNode->pKey = AutoHeapAlloc(SidLength)) == NULL) {
00407         AddToMessageLog(TEXT("QueueHashAdd: AutoHeapAlloc failed"));
00408
00409         if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00410         return;
00411     }
00412
00413     if (CopySid(SidLength, pQueueHashNode->pKey, Sid) == 0) {
00414         AddToMessageLogProcFailure(TEXT("QueueHashAdd: CopySid"), GetLastError());
00415
00416         if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00417         return;
00418     }
00419
00420     pQueueHashNode->pValue = pValue;
00421
00422     QueueAdd(pQueue, (VOID *) pQueueHashNode, FALSE);
00423
00424 #ifdef DEBUG
00425     DbgMsgRecord(TEXT("<- QueueHashAdd\n"));
00426 #endif
00427
00428     if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00429 }
00430
00431 VOID * QueueHashLookup(Queue *pQueue, PSID Sid, BOOL EnterCritSec) {
00432     VOID * pValue;
00433     QueueNode *pNextNode;
00434
00435     ASSERTE(pQueue != NULL);
00436
00437     if (pQueue->lpCriticalSection != NULL && EnterCritSec) EnterCriticalSection(pQueue->lpCriticalSection);
00438
00439 #ifdef DEBUG
00440     DbgMsgRecord(TEXT("-> QueueHashLookup\n"));
00441 #endif
00442
00443     pValue = NULL;
00444
00445     for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNextNode) {
00446         pNextNode = pNode->pNext;
00447         if (EqualSid(((QueueHashNode *)(pNode->pData))->pKey, Sid) == TRUE) {
00448             pValue = ((QueueHashNode *)(pNode->pData))->pValue;
00449             break;
00450         }
00451     }
00452
00453 #ifdef DEBUG
00454     DbgMsgRecord(TEXT("<- QueueHashLookup\n"));
00455 #endif
00456
00457     if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00458
00459     return pValue;
00460 }
00461
00462 VOID QueueHashAddToSubqueue(Queue *pHashQueue, PSID pSID, VOID * pData) {
00463
00464     ASSERTE(pHashQueue != NULL);
00465
00466     if (pHashQueue->lpCriticalSection != NULL) EnterCriticalSection(pHashQueue->lpCriticalSection);
00467
00468 #ifdef DEBUG
00469     DbgMsgRecord(TEXT("-> QueueHashAddToSubqueue\n"));
00470 #endif
00471
00472     // Put the request onto the appropriate queue.
00473
00474     // Lookup the subqueue for the user's sid.
00475     Queue * pQueue = (Queue *) QueueHashLookup(pHashQueue, pSID, FALSE);
00476     // If the subqueue does not exist, create it.
00477     if (pQueue == NULL) {
00478         if ((pQueue = QueueCreate(TRUE)) == NULL) {
00479             AddToMessageLog(TEXT("QueueHashAddToSubqueue: QueueCreate failed"));
00480             if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00481             return;
00482   }
00483         QueueHashAdd(pHashQueue, pSID, pQueue, FALSE);
00484     }
00485     // Add the request to the subqueue
00486     QueueAdd(pQueue, pData, FALSE);
00487
00488 #ifdef DEBUG
00489     DbgMsgRecord(TEXT("<- QueueHashAddToSubqueue\n"));
00490 #endif
00491
00492     if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00493 }
00494
00495 VOID * QueueHashRemoveFromSubqueue(Queue *pQueue) {
00496     Queue * pSubQueue;
00497     QueueNode *pPrevNode;
00498     VOID * pData;
00499
00500     ASSERTE(pQueue != NULL);
00501
00502     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00503
00504     pSubQueue = NULL;
00505
00506 #ifdef DEBUG
00507     DbgMsgRecord(TEXT("-> QueueHashRemoveFromSubqueue\n"));
00508 #endif
00509
00510     // If the hash queue is not empty.
00511     if (pQueue->pFirst != NULL) {
00512         // Find the first nonempty subqueue.
00513         pPrevNode = NULL;
00514         for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNode->pNext) {
00515
00516             // Check if it has elements in it.
00517             if (!QueueIsEmpty((Queue*) ((QueueHashNode *)pNode->pData)->pValue)) {
00518                 // Select it.  We will extract an element off this subqueue
00519                 // and put the subqueue into the end of the hash queue.
00520                 pSubQueue = (Queue*) ((QueueHashNode *)pNode->pData)->pValue;
00521
00522                 // Take it off the hash queue and put it
00523                 // on the back.
00524                 QueueMoveToBack(pQueue, pNode, pPrevNode);
00525
00526                 break;
00527             }
00528
00529             pPrevNode = pNode;
00530         }
00531         if (pSubQueue == NULL) {
00532             // We did not find any nonemoty subqueues.
00533             pData = NULL;
00534         }
00535     }
00536     else {
00537         // There are no nonempty subqueues.
00538         pData = NULL;
00539     }
00540
00541     if (pSubQueue != NULL) {
00542         // Extract an element from the subqueue.
00543         pData = QueueRemove(pSubQueue);
00544     }
00545
00546 #ifdef DEBUG
00547     DbgMsgRecord(TEXT("<- QueueHashRemoveFromSubqueue\n"));
00548 #endif
00549
00550     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00551
00552     return pData;
00553 }
00554
00555 BOOL QueueHashIncrementCounter(Queue *pHashQueue, PSID pSID) {
00556     Counter *pCounter;
00557     BOOL ret;
00558
00559     ASSERTE(pHashQueue != NULL);
00560
00561     if (pHashQueue->lpCriticalSection != NULL) EnterCriticalSection(pHashQueue->lpCriticalSection);
00562
00563 #ifdef DEBUG
00564     DbgMsgRecord(TEXT("-> QueueHashIncrementCounter\n"));
00565 #endif
00566
00567     // Put the counter onto the appropriate queue.
00568     // Lookup the counter for the user's sid.
00569     pCounter = (Counter *) QueueHashLookup(pHashQueue, pSID, FALSE);
00570     // If the counter does not exist, create it.
00571     if (pCounter == NULL) {
00572         if ((pCounter = CounterCreate(MaxUserReqs)) == NULL) {
00573             AddToMessageLog(TEXT("QueueHashIncrementCounter: CounterCreate failed"));
00574             if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00575             return FALSE;
00576         }
00577         QueueHashAdd(pHashQueue, pSID, pCounter, FALSE);
00578     }
00579     // Attempt to increment the counter
00580     ret = CounterIncrement(pCounter);
00581
00582 #ifdef DEBUG
00583     DbgMsgRecord(TEXT("<- QueueHashIncrementCounter\n"));
00584 #endif
00585
00586     if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00587
00588     return ret;
00589 }
00590
00591 VOID QueueHashDecrementCounter(Queue *pHashQueue, PSID pSID) {
00592     Counter *pCounter;
00593
00594     ASSERTE(pHashQueue != NULL);
00595
00596     if (pHashQueue->lpCriticalSection != NULL) EnterCriticalSection(pHashQueue->lpCriticalSection);
00597
00598 #ifdef DEBUG
00599     DbgMsgRecord(TEXT("-> QueueHashDecrementCounter\n"));
00600 #endif
00601
00602     // Put the counter onto the appropriate queue.
00603     // Lookup the counter for the user's sid.
00604     pCounter = (Counter *) QueueHashLookup(pHashQueue, pSID, FALSE);
00605     // If the counter does not exist, create it.
00606     if (pCounter == NULL) {
00607         if ((pCounter = CounterCreate(MaxUserReqs)) == NULL) {
00608             AddToMessageLog(TEXT("QueueHashIncrementCounter: CounterCreate failed"));
00609             if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00610             return;
00611         }
00612         QueueHashAdd(pHashQueue, pSID, pCounter, FALSE);
00613     }
00614     // Decrement the counter.
00615     CounterDecrement(pCounter);
00616
00617 #ifdef DEBUG
00618     DbgMsgRecord(TEXT("<- QueueHashDecrementCounter\n"));
00619 #endif
00620
00621     if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00622 }
00623
00624 // end Resources.cpp
00625
00626
00627
00628
00629
00630
00631
00632
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Security/VC/StdAfx.Cpp Source File

  • Com
  • Services
  • Security
  • VC

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/stdafx.h Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

stdafx.h

Go to the documentation of this file.
00001 // Filename: stdafx.h
00002 //
00003 // Description: include file for standard system include files,
00004 //        or project specific include files that are used frequently,
00005 //        but are changed infrequently
00006 //
00007 // This file is provided as part of the Microsoft Transaction Server
00008 // Software Development Kit
00009 //
00010 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00011 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00012 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00013 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00014 // PURPOSE.
00015 //
00016 // Copyright (C) 1997 Microsoft Corporation, All rights reserved
00017
00018 #if 0
00019 #if defined(_ATL_NO_DEBUG_CRT)
00020 #include <svcerr.h>
00021 #define _ASSERTE(x) ASSERT(x)
00022 #endif // defined(_ATL_NO_DEBUG_CRT)
00023 #endif
00024
00025
00026 #include <atlbase.h>
00027 //You may derive a class from CComModule and use it if you want to override
00028 //something, but do not change the name of _Module
00029 extern CComModule _Module;
00030 #include <atlcom.h>
00031 #ifndef DBNTWIN32
00032 #define DBNTWIN32
00033 #include <SQL.h>
00034 #include <SQLEXT.h>
00035 #endif
00036 #define THROW_ERR(exp,str) {if (FAILED (hr = (exp))) {lErrFlag = 0; pErrMsg = _T(str); throw hr;}}
00037 #define THROW_STR(str) { hr = APP_ERROR; lErrFlag = 1; pErrMsg = str; throw hr;}
00038 #define RETHROW_ERR(exp) { if (FAILED(hr = (exp))) {lErrFlag = 2; throw hr;}}
00039
00040 #define APP_ERROR 0x80004100
00041
00042 extern void GetError(HENV henv, HDBC hdbc, HSTMT hstmt, BSTR * sErr);
00043
00044 #define SafeRelease(x) { if (x){x->Release();x=NULL;}}
00045
00046
00047 #define SQL_FAILED(rc)  ( (rc) != SQL_SUCCESS && (rc) != SQL_SUCCESS_WITH_INFO)
00048
00049
00050
00051 #define ASSERT_SQL_SUCCESS(rc) { _ASSERTE(rc==SQL_SUCCESS || rc==SQL_SUCCESS_WITH_INFO);}
00052
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/tracemacro.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

tracemacro.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "TraceMacro.h"
00017 #include <StdIo.h>             // Needed for sprintf on Win98
00018
00019
00020 //---------------------------------------------------------------------------
00021 //  Function implementations
00022 //
00023
00024 //---------------------------------------------------------------------------
00025 //  Provides trace output for HRESULTs in hex.
00026 //
00027 VOID Trace_HR
00028 (
00029   LPCTSTR pszClass,        //[in] Class name for message
00030   LPCTSTR pszFunction,     //[in] Function name for message
00031   HRESULT hr               //[in] HRESULT to display as a value
00032 )
00033 {
00034 #ifdef _DEBUG
00035
00036   TCHAR  szBuffer[512];
00037   TCHAR  szFormat[] = _T("%s::%s-> Returned 0x%X\n");
00038   INT    nChars     = 0;
00039
00040   nChars = _stprintf( szBuffer, szFormat, pszClass, pszFunction, hr );
00041   _ASSERTE( nChars < sizeof(szBuffer) );
00042
00043   OutputDebugString( szBuffer );
00044
00045 #endif
00046 } //end Trace_HR()
00047
00048
00049 //---------------------------------------------------------------------------
00050 //  Provides trace output for user defined numeric values in the form:
00051 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00052 //
00053 VOID Trace_Value
00054 (
00055   LPCTSTR pszClass,        //[in] Class name for message
00056   LPCTSTR pszFunction,     //[in] Function name for message
00057   LPCTSTR pszValueName,    //[in] Value name for message
00058   LONG    nValue           //[in] Numeric value for message
00059 )
00060 {
00061 #ifdef _DEBUG
00062
00063   TCHAR  szBuffer[512];
00064   TCHAR  szFormat[] = _T("%s::%s-> %s = %u\n");
00065   INT    nChars     = 0;
00066
00067   nChars = _stprintf( szBuffer,
00068                       szFormat,
00069                       pszClass,
00070                       pszFunction,
00071                       pszValueName,
00072                       nValue
00073                     );
00074   _ASSERTE( nChars < sizeof(szBuffer) );
00075
00076   OutputDebugString( szBuffer );
00077
00078 #endif
00079 } //end Trace_Value()
00080
00081 //---------------------------------------------------------------------------
00082 //  Provides trace output for user defined numeric values in the form:
00083 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00084 //
00085 VOID Trace_Pointer
00086 (
00087   LPCTSTR pszClass,        //[in] Class name for message
00088   LPCTSTR pszFunction,     //[in] Function name for message
00089   LPCTSTR pszAction,       //[in] Action which was taken
00090   ULONG   ulValue          //[in] Numeric value for message
00091 )
00092 {
00093 #ifdef _DEBUG
00094
00095   TCHAR  szBuffer[512];
00096   TCHAR  szFormat[] = _T("%s::%s-> %s = 0x%X\n");
00097   INT    nChars     = 0;
00098
00099   nChars = _stprintf( szBuffer,
00100                       szFormat,
00101                       pszClass,
00102                       pszFunction,
00103                       pszAction,
00104                       ulValue
00105                     );
00106   _ASSERTE( nChars < sizeof(szBuffer) );
00107
00108   OutputDebugString( szBuffer );
00109
00110 #endif
00111 } //end Trace_Pointer()
00112
00113
00114 //---------------------------------------------------------------------------
00115 //  Provides trace output which shows the class name, function name, and
00116 //  a string which maps to an MMC notification.
00117 //
00118 VOID Trace_Event
00119 (
00120   LPCTSTR pszClass,        //[in] Class name for message
00121   LPCTSTR pszFunction,     //[in] Event name for message
00122   LONG    nEvent           //[in] Event code to map to string
00123 )
00124 {
00125 #ifdef _DEBUG
00126
00127   TCHAR  szEventStr[64];
00128   TCHAR  szBuffer[512];
00129   TCHAR  szFormat[] = _T("%s::%s-> Event = %s\n");
00130   INT    nChars     = 0;
00131
00132   MapEvent( nEvent, szEventStr );
00133
00134   nChars = _stprintf( szBuffer,
00135                       szFormat,
00136                       pszClass,
00137                       pszFunction,
00138                       szEventStr
00139                     );
00140   _ASSERTE( nChars < sizeof(szBuffer) );
00141
00142   OutputDebugString( szBuffer );
00143
00144 #endif
00145 } //end Trace_Event()
00146
00147 //---------------------------------------------------------------------------
00148 //  Provides trace output which shows the class name and function name
00149 //
00150 VOID Trace_Start
00151 (
00152   LPCTSTR pszClass,        //[in] Class name for message
00153   LPCTSTR pszFunction      //[in] Event name for message
00154 )
00155 {
00156 #ifdef _DEBUG
00157
00158   TCHAR  szBuffer[512];
00159   TCHAR  szFormat[] = _T("%s::%s-> Started \n");
00160   INT    nChars     = 0;
00161
00162   nChars = _stprintf( szBuffer,
00163                       szFormat,
00164                       pszClass,
00165                       pszFunction
00166                     );
00167   _ASSERTE( nChars < sizeof(szBuffer) );
00168
00169   OutputDebugString( szBuffer );
00170
00171 #endif
00172 } //end Trace_Start()
00173
00174
00175
00176 //---------------------------------------------------------------------------
00177 // Provides human readable output for notifications
00178 //
00179 VOID MapEvent( LONG Event, LPTSTR szEventStr )
00180 {
00181 #ifdef _DEBUG
00182
00183   switch( Event )
00184   {
00185     case MMCN_ACTIVATE:
00186       _tcscpy( szEventStr, _T("MMCN_ACTIVATE          ") );
00187       break;
00188
00189     case MMCN_ADD_IMAGES:
00190       _tcscpy( szEventStr, _T("MMCN_ADD_IMAGES        ") );
00191       break;
00192
00193     case MMCN_BTN_CLICK:
00194       _tcscpy( szEventStr, _T("MMCN_BTN_CLICK         ") );
00195       break;
00196
00197     case MMCN_CLICK:
00198       _tcscpy( szEventStr, _T("MMCN_CLICK             ") );
00199       break;
00200
00201     case MMCN_COLUMN_CLICK:
00202       _tcscpy( szEventStr, _T("MMCN_COLUMN_CLICK       ") );
00203       break;
00204
00205     case MMCN_CONTEXTMENU:
00206       _tcscpy( szEventStr, _T("MMCN_CONTEXTMENU        ") );
00207       break;
00208
00209     case MMCN_CUTORMOVE:
00210       _tcscpy( szEventStr, _T("MMCN_CUTORMOVE          ") );
00211       break;
00212
00213     case MMCN_DBLCLICK:
00214       _tcscpy( szEventStr, _T("MMCN_DBLCLICK           ") );
00215       break;
00216
00217     case MMCN_DELETE:
00218       _tcscpy( szEventStr, _T("MMCN_DELETE             ") );
00219       break;
00220
00221     case MMCN_DESELECT_ALL:
00222       _tcscpy( szEventStr, _T("MMCN_DESELECT_ALL       ") );
00223       break;
00224
00225     case MMCN_EXPAND:
00226       _tcscpy( szEventStr, _T("MMCN_EXPAND             ") );
00227       break;
00228
00229     case MMCN_HELP:
00230       _tcscpy( szEventStr, _T("MMCN_HELP               ") );
00231       break;
00232
00233     case MMCN_MENU_BTNCLICK:
00234       _tcscpy( szEventStr, _T("MMCN_MENU_BTNCLICK      ") );
00235       break;
00236
00237     case MMCN_MINIMIZED:
00238       _tcscpy( szEventStr, _T("MMCN_MINIMIZED          ") );
00239       break;
00240
00241     case MMCN_PASTE:
00242       _tcscpy( szEventStr, _T("MMCN_PASTE              ") );
00243       break;
00244
00245     case MMCN_PROPERTY_CHANGE:
00246       _tcscpy( szEventStr, _T("MMCN_PROPERTY_CHANGE    ") );
00247       break;
00248
00249     case MMCN_QUERY_PASTE:
00250       _tcscpy( szEventStr, _T("MMCN_QUERY_PASTE        ") );
00251       break;
00252
00253     case MMCN_REFRESH:
00254       _tcscpy( szEventStr, _T("MMCN_REFRESH            ") );
00255       break;
00256
00257     case MMCN_REMOVE_CHILDREN:
00258       _tcscpy( szEventStr, _T("MMCN_REMOVE_CHILDREN    ") );
00259       break;
00260
00261     case MMCN_RENAME:
00262       _tcscpy( szEventStr, _T("MMCN_RENAME             ") );
00263       break;
00264
00265     case MMCN_SELECT:
00266       _tcscpy( szEventStr, _T("MMCN_SELECT             ") );
00267       break;
00268
00269     case MMCN_SHOW:
00270       _tcscpy( szEventStr, _T("MMCN_SHOW               ") );
00271       break;
00272
00273     case MMCN_VIEW_CHANGE:
00274       _tcscpy( szEventStr, _T("MMCN_VIEW_CHANGE        ") );
00275       break;
00276
00277     case MMCN_SNAPINHELP:
00278       _tcscpy( szEventStr, _T("MMCN_SNAPINHELP         ") );
00279       break;
00280
00281     case MMCN_CONTEXTHELP:
00282       _tcscpy( szEventStr, _T("MMCN_CONTEXTHELP        ") );
00283       break;
00284
00285     case MMCN_INITOCX:
00286       _tcscpy( szEventStr, _T("MMCN_INITOCX            ") );
00287       break;
00288
00289     // MMC Version 1.1 notifications
00290     case MMCN_FILTER_CHANGE:
00291       _tcscpy( szEventStr, _T("MMCN_FILTER_CHANGE      ") );
00292       break;
00293
00294     case MMCN_FILTERBTN_CLICK:
00295       _tcscpy( szEventStr, _T("MMCN_FILTERBTN_CLICK    ") );
00296       break;
00297
00298     case MMCN_RESTORE_VIEW:
00299       _tcscpy( szEventStr, _T("MMCN_RESTORE_VIEW       ") );
00300       break;
00301
00302     case MMCN_PRINT:
00303       _tcscpy( szEventStr, _T("MMCN_PRINT              ") );
00304       break;
00305
00306     case MMCN_PRELOAD:
00307       _tcscpy( szEventStr, _T("MMCN_PRELOAD            ") );
00308       break;
00309
00310     case MMCN_LISTPAD:
00311       _tcscpy( szEventStr, _T("MMCN_LISTPAD            ") );
00312       break;
00313
00314     case MMCN_EXPANDSYNC:
00315       _tcscpy( szEventStr, _T("MMCN_EXPANDSYNC         ") );
00316       break;
00317
00318     // MMC Version 1.2 notifications
00319     case MMCN_COLUMNS_CHANGED:
00320       _tcscpy( szEventStr, _T("MMCN_COLUMNS_CHANGED    ") );
00321       break;
00322
00323     // MMC Version 2.0 notifications
00324     case MMCN_CANPASTE_OUTOFPROC:
00325       _tcscpy( szEventStr, _T("MMCN_CANPASTE_OUTOFPROC ") );
00326       break;
00327
00328     default:
00329       _stprintf( szEventStr, _T("0x%X"), Event );
00330       break;
00331   }
00332
00333 #endif
00334 } //end MapEvent()
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConServe/BALL.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConServe

BALL.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      BALL.CPP
00003
00004   Summary:   Implementation file for the COBall COM Object Class (for
00005              connectable COBall COM Objects). This module provides a
00006              thread-safe virtual Ball object. The ball has internal
00007              algorithms that determine its position within a bounded two
00008              dimensional area. No display or other GUI behavior is done in
00009              this object.  It is a mathematical entity. Clients of this
00010              ball can command it to reset, move, and reveal its current
00011              position, size, and color. These last are used by a client
00012              that displays images of this ball. The color in particular is
00013              an internal property maintained by the ball that indicates
00014              the thread of execution that last moved this ball.
00015
00016              COBall offers a main standard IUnknown interface (basic COM
00017              object features), the standard IConnectionPointContainer
00018              interface (connectable COM object features), and the custom
00019              IBall interface (Moving Ball related features). This multiple
00020              interface COM Object Class is achieved via the technique of
00021              nested classes.  The implementations of the
00022              IConnectionPointContainer and IBall interfaces are nested
00023              inside the COBall Class.
00024
00025              This file also implements some internal C++ classes (CXForm
00026              and CBallThread) that provide internal support for the custom
00027              IBall interface.
00028
00029              For a comprehensive tutorial code tour of this module's
00030              contents and offerings see the tutorial CONSERVE.HTM
00031              file. For more specific technical details on the internal
00032              workings see the comments dispersed throughout the module's
00033              source code.
00034
00035   Classes:   CXForm, CBallThread, COBall.
00036
00037   Functions: none.
00038
00039   Origin:    12-28-96: atrent - Editor-inheritance from BALL.CPP in
00040              the FRESERVE Tutorial Code Sample.
00041
00042 ----------------------------------------------------------------------------
00043   This file is part of the Microsoft COM Tutorial Code Samples.
00044
00045   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00046
00047   This source code is intended only as a supplement to Microsoft
00048   Development Tools and/or on-line documentation.  See these other
00049   materials for detailed information regarding Microsoft code samples.
00050
00051   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00052   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00053   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00054   PARTICULAR PURPOSE.
00055 ==========================================================================+*/
00056
00057
00058 /*---------------------------------------------------------------------------
00059   We include WINDOWS.H for all Win32 applications.
00060   We include OLE2.H because we will be calling the COM/OLE Libraries.
00061   We include OLECTL.H because it has definitions for connectable objects.
00062   We include APPUTIL.H because we will be building this application using
00063     the convenient Virtual Window and Dialog classes and other
00064     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00065   We include IBALL.H and BALLGUID.H for the common Ball-related Interface
00066     class, GUID, and CLSID specifications.
00067   We include SERVER.H because it has internal class declarations and
00068     resource ID definitions specific for this DLL.
00069   We include CONNECT.H for object class declarations for the various
00070     connection point and connection COM objects used in CONSERVE.
00071   We include BALL.H because it has the class COBall declarations.
00072 ---------------------------------------------------------------------------*/
00073 #include <windows.h>
00074 #include <ole2.h>
00075 #include <olectl.h>
00076 #include <apputil.h>
00077 #include <iball.h>
00078 #include <ballguid.h>
00079 #include "server.h"
00080 #include "connect.h"
00081 #include "ball.h"
00082
00083
00084 /*---------------------------------------------------------------------------
00085   COBall's implementation of its internal utility class CXForm.
00086 ---------------------------------------------------------------------------*/
00087
00088 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00089   Method:   CXForm::Clear
00090
00091   Summary:  Clears and initializes the transformation matrix.
00092
00093   Args:     void
00094
00095   Modifies: ...
00096
00097   Returns:  void
00098 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00099 void CXForm::Clear(void)
00100 {
00101   int Row,Col;
00102
00103   for(Row=0; Row < 3; Row++)
00104     for(Col=0; Col < 3; Col++)
00105       if(Row == Col)
00106         XForm[Row][Col] = 1;
00107       else
00108         XForm[Row][Col] = 0;
00109
00110   return;
00111 }
00112
00113
00114 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00115   Method:   CXForm::Scale
00116
00117   Summary:  Method to allow setting the transformation to multiply
00118             by a scale factor.
00119
00120   Args:     int xScale
00121               x Scale factor.
00122             int yScale
00123               y Scale factor.
00124
00125   Modifies: ...
00126
00127   Returns:  void
00128 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00129 void CXForm::Scale(int xScale, int yScale)
00130 {
00131   int idx;
00132
00133   for(idx=0; idx < 3; idx++)
00134   {
00135     XForm[idx][0] = XForm[idx][0] * xScale;
00136     XForm[idx][1] = XForm[idx][1] * yScale;
00137   }
00138
00139   return;
00140 }
00141
00142
00143 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00144   Method:   CXForm::Trans
00145
00146   Summary:  Perform the transform uing the internal matrix.
00147
00148   Args:     int xTrans
00149               x coordinate.
00150             int yTrans
00151               y coordinate.
00152
00153   Modifies: ...
00154
00155   Returns:  void
00156 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00157 void CXForm::Trans(int xTrans, int yTrans)
00158 {
00159   XForm[2][0] = XForm[2][0] + xTrans;
00160   XForm[2][1] = XForm[2][1] + yTrans;
00161
00162   return;
00163 }
00164
00165
00166 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00167   Method:   CXForm::Point
00168
00169   Summary:  Transform a point.
00170
00171   Args:     POINT* pPoint
00172               Pointer to the point.
00173
00174   Modifies: ...
00175
00176   Returns:  void
00177 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00178 void CXForm::Point(POINT* pPoint)
00179 {
00180   int x,y;
00181
00182   x = (XForm[0][0] * pPoint->x) + (XForm[1][0] * pPoint->y) + XForm[2][0];
00183   y = (XForm[0][1] * pPoint->x) + (XForm[1][1] * pPoint->y) + XForm[2][1];
00184
00185   pPoint->x = x;
00186   pPoint->y = y;
00187
00188   return;
00189 }
00190
00191
00192 /*---------------------------------------------------------------------------
00193   COBall's implementation of its main COM object class including
00194   Constructor, Destructor, QueryInterface, AddRef, and Release.
00195 ---------------------------------------------------------------------------*/
00196
00197 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00198   Method:   COBall::COBall
00199
00200   Summary:  COBall Constructor. Note the member initializer:
00201             "m_ImpIBall(this, pUnkOuter)" which is used to pass the 'this'
00202             and pUnkOuter pointers of the constructor function to the
00203             constructor in the instantiation of the implementation of the
00204             CImpIBall interface (which is nested inside this present
00205             COBall Object Class). Same technique is used for the
00206             m_ImpIConnectionPointContainer nested interface
00207             implementation.
00208
00209   Args:     IUnknown* pUnkOuter,
00210               Pointer to the the outer Unknown.  NULL means this COM Object
00211               is not being Aggregated.  Non NULL means it is being created
00212               on behalf of an outside COM object that is reusing it via
00213               aggregation.
00214             CServer* pServer)
00215               Pointer to the server's control object.
00216
00217   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00218
00219   Returns:  void
00220 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00221 COBall::COBall(
00222   IUnknown* pUnkOuter,
00223   CServer* pServer) :
00224   m_ImpIBall(this, pUnkOuter),
00225   m_ImpIConnectionPointContainer(this, pUnkOuter)
00226 {
00227   UINT i;
00228
00229   // Zero the COM object's reference count.
00230   m_cRefs = 0;
00231
00232   // No AddRef necessary if non-NULL, as we're nested.
00233   m_pUnkOuter = pUnkOuter;
00234
00235   // Assign the pointer to the server control object.
00236   m_pServer = pServer;
00237
00238   // Null all entries in the connection point array.
00239   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00240     m_aConnectionPoints[i] = NULL;
00241
00242   return;
00243 }
00244
00245
00246 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00247   Method:   COBall::~COBall
00248
00249   Summary:  COBall Destructor.
00250
00251   Args:     void
00252
00253   Modifies: .
00254
00255   Returns:  void
00256 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00257 COBall::~COBall(void)
00258 {
00259   UINT i;
00260   IConnectionPoint* pIConnectionPoint;
00261
00262   // Do final release of the connection point objects.
00263   // If this isn't the final release, then the client has an outstanding
00264   // unbalanced reference to a connection point and a memory leak may
00265   // likely result because the host COBall object is now going away yet
00266   // a connection point for this host object will not end up deleting
00267   // itself (and its connections array).
00268   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00269   {
00270     pIConnectionPoint = m_aConnectionPoints[i];
00271     RELEASE_INTERFACE(pIConnectionPoint);
00272   }
00273
00274   return;
00275 }
00276
00277
00278 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00279   Method:   COBall::Init
00280
00281   Summary:  COBall initialization method.  Create any necessary arrays,
00282             structures, and subordinate objects.
00283
00284   Args:     void
00285
00286   Modifies: m_aConnectionPoints.
00287
00288   Returns:  HRESULT
00289               Standard result code. NOERROR for success.
00290 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00291 HRESULT COBall::Init(void)
00292 {
00293   HRESULT hr = NOERROR;
00294   COConnectionPoint* pCOConnPt;
00295
00296   // Rig this COBall COM object to be connectable. Assign the connection
00297   // point array. This object's connection points are determined at
00298   // compile time--it currently has only one connection point:
00299   // the CONNPOINT_BALLSINK connection point. Create a connection
00300   // point object for this and assign it into the array. This array could
00301   // easily grow to support additional connection points in the future.
00302
00303   // First try creating a new connection point object. Pass 'this' as the
00304   // pHostObj pointer used by the connection point to pass its AddRef and
00305   // Release calls back to the host connectable object.
00306   pCOConnPt = new COConnectionPoint(this);
00307   if (NULL != pCOConnPt)
00308   {
00309     // If creation succeeded then initialize it (including creating
00310     // its initial dynamic connection array).
00311     hr = pCOConnPt->Init(IID_IBallSink);
00312
00313     // If the init succeeded then use QueryInterface to obtain the
00314     // IConnectionPoint interface on the new connection point object.
00315     // The interface pointer is assigned directly into the
00316     // connection point array. The QI also does the needed AddRef.
00317     if (SUCCEEDED(hr))
00318       hr = pCOConnPt->QueryInterface(
00319                         IID_IConnectionPoint,
00320                         (PPVOID)&m_aConnectionPoints[CONNPOINT_BALLSINK]);
00321   }
00322   else
00323     hr = E_OUTOFMEMORY;
00324
00325   return hr;
00326 }
00327
00328
00329 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00330   Method:   COBall::QueryInterface
00331
00332   Summary:  QueryInterface of the COBall non-delegating IUnknown
00333             implementation.
00334
00335   Args:     REFIID riid,
00336               [in] GUID of the Interface being requested.
00337             PPVOID ppv)
00338               [out] Address of the caller's pointer variable that will
00339               receive the requested interface pointer.
00340
00341   Modifies: .
00342
00343   Returns:  HRESULT
00344               Standard result code. NOERROR for success.
00345 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00346 STDMETHODIMP COBall::QueryInterface(
00347                REFIID riid,
00348                PPVOID ppv)
00349 {
00350   HRESULT hr = E_NOINTERFACE;
00351
00352   *ppv = NULL;
00353
00354   if (IID_IUnknown == riid)
00355     *ppv = this;
00356   else if (IID_IBall == riid)
00357     *ppv = &m_ImpIBall;
00358   else if (IID_IConnectionPointContainer == riid)
00359     *ppv = &m_ImpIConnectionPointContainer;
00360
00361   if (NULL != *ppv)
00362   {
00363     // We've handed out a pointer to the interface so obey the COM rules
00364     // and AddRef the reference count.
00365     ((LPUNKNOWN)*ppv)->AddRef();
00366     hr = NOERROR;
00367   }
00368
00369   return (hr);
00370 }
00371
00372
00373 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00374   Method:   COBall::AddRef
00375
00376   Summary:  AddRef of the COBall non-delegating IUnknown implementation.
00377
00378   Args:     void
00379
00380   Modifies: m_cRefs.
00381
00382   Returns:  ULONG
00383               New value of m_cRefs (COM object's reference count).
00384 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00385 STDMETHODIMP_(ULONG) COBall::AddRef(void)
00386 {
00387   ULONG cRefs;
00388
00389   if (OwnThis())
00390   {
00391     cRefs = ++m_cRefs;
00392
00393     UnOwnThis();
00394   }
00395
00396   return cRefs;
00397 }
00398
00399
00400 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00401   Method:   COBall::Release
00402
00403   Summary:  Release of the COBall non-delegating IUnknown implementation.
00404
00405   Args:     void
00406
00407   Modifies: m_cRefs.
00408
00409   Returns:  ULONG
00410               New value of m_cRefs (COM object's reference count).
00411 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00412 STDMETHODIMP_(ULONG) COBall::Release(void)
00413 {
00414   ULONG cRefs;
00415
00416   if (OwnThis())
00417   {
00418     cRefs = --m_cRefs;
00419
00420     if (0 == cRefs)
00421     {
00422       // We've reached a zero reference count for this COM object.
00423       // So we tell the server housing to decrement its global object
00424       // count so that the server will be unloaded if appropriate.
00425       if (NULL != m_pServer)
00426         m_pServer->ObjectsDown();
00427
00428       // We artificially bump the main ref count to prevent reentrancy
00429       // via the main object destructor.  Not really needed in this
00430       // COBall but a good practice because we are aggregatable and
00431       // may at some point in the future add something entertaining like
00432       // some Releases to the COBall destructor. Relinquish thread
00433       // ownership of this object before deleting it--a good practice.
00434       m_cRefs++;
00435       UnOwnThis();
00436       delete this;
00437     }
00438     else
00439       UnOwnThis();
00440   }
00441
00442   return cRefs;
00443 }
00444
00445
00446 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00447   Method:   COBall::NotifySinks
00448
00449   Summary:  Internal utility method of this COM object used to fire event
00450             notification calls to all listening connection sinks in the
00451             client.
00452
00453   Args:     DWORD dwEvent
00454               Type of notification event.
00455
00456   Modifies: ...
00457
00458   Returns:  HRESULT
00459               Standard result code. NOERROR for success.
00460 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00461 HRESULT COBall::NotifySinks(
00462        DWORD dwEvent)
00463 {
00464   HRESULT hr = NOERROR;
00465   IConnectionPoint* pIConnectionPoint;
00466   IEnumConnections* pIEnum;
00467   CONNECTDATA ConnData;
00468
00469   // If there was a bounce event, broadcast appropriate notifications to
00470   // all Sinks connected to each connection point.
00471   if (BOUNCE_NONE != dwEvent)
00472   {
00473     // Here is the section for the BallSink connection point--currently
00474     // this is the only connection point offered by COBall objects.
00475     pIConnectionPoint = m_aConnectionPoints[CONNPOINT_BALLSINK];
00476     if (NULL != pIConnectionPoint)
00477     {
00478       pIConnectionPoint->AddRef();
00479       hr = pIConnectionPoint->EnumConnections(&pIEnum);
00480       if (SUCCEEDED(hr))
00481       {
00482         // Loop thru the connection point's connections and if the listening
00483         // connection supports IBallSink (ie, BallSink events) then dispatch
00484         // the dwEvent event notification to that sink.
00485         while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
00486         {
00487           IBallSink* pIBallSink;
00488
00489           hr = ConnData.pUnk->QueryInterface(
00490                                 IID_IBallSink,
00491                                 (PPVOID)&pIBallSink);
00492           if (SUCCEEDED(hr))
00493           {
00494             switch (dwEvent)
00495             {
00496               case BOUNCE_BOTTOM:
00497                 pIBallSink->BounceBottom();
00498                 break;
00499               case BOUNCE_LEFT:
00500                 pIBallSink->BounceLeft();
00501                 break;
00502               case BOUNCE_RIGHT:
00503                 pIBallSink->BounceRight();
00504                 break;
00505               case BOUNCE_TOP:
00506                 pIBallSink->BounceTop();
00507                 break;
00508               default:
00509                 break;
00510             }
00511             pIBallSink->Release();
00512           }
00513           ConnData.pUnk->Release();
00514         }
00515         pIEnum->Release();
00516       }
00517       pIConnectionPoint->Release();
00518     }
00519   }
00520
00521   return hr;
00522 }
00523
00524
00525 /*---------------------------------------------------------------------------
00526   COBall's nested implementation of the COM standard
00527   IConnectionPointContainer interface including Constructor, Destructor,
00528   QueryInterface, AddRef, Release, FindConnectionPoint, and
00529   EnumConnectionPoints.
00530 ---------------------------------------------------------------------------*/
00531
00532 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00533   Method:   COBall::CImpIConnectionPointContainer
00534               ::CImpIConnectionPointContainer
00535
00536   Summary:  Constructor for the CImpIConnectionPointContainer interface
00537             instantiation.
00538
00539   Args:     COBall* pBackObj,
00540               Back pointer to the parent outer object.
00541             IUnknown* pUnkOuter
00542               Pointer to the outer Unknown.  For delegation.
00543
00544   Modifies: m_pBackObj, m_pUnkOuter.
00545
00546   Returns:  void
00547 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00548 COBall::CImpIConnectionPointContainer::CImpIConnectionPointContainer(
00549   COBall* pBackObj,
00550   IUnknown* pUnkOuter)
00551 {
00552   // Init the Back Object Pointer to point to the parent object.
00553   m_pBackObj = pBackObj;
00554
00555   // Init the CImpIConnectionPointContainer interface's delegating Unknown
00556   // pointer.  We use the Back Object pointer for IUnknown delegation here if
00557   // we are not being aggregated.  If we are being aggregated we use the
00558   // supplied pUnkOuter for IUnknown delegation.  In either case the pointer
00559   // assignment requires no AddRef because the CImpIConnectionPointContainer
00560   // lifetime is quaranteed by the lifetime of the parent object in which
00561   // CImpIConnectionPointContainer is nested.
00562   if (NULL == pUnkOuter)
00563     m_pUnkOuter = pBackObj;
00564   else
00565     m_pUnkOuter = pUnkOuter;
00566
00567   return;
00568 }
00569
00570
00571 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00572   Method:   COBall::CImpIConnectionPointContainer
00573               ::~CImpIConnectionPointContainer
00574
00575   Summary:  Destructor for the CImpIConnectionPointContainer interface
00576             instantiation.
00577
00578   Args:     void
00579
00580   Modifies: .
00581
00582   Returns:  void
00583 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00584 COBall::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
00585 {
00586   return;
00587 }
00588
00589
00590 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00591   Method:   COBall::CImpIConnectionPointContainer::QueryInterface
00592
00593   Summary:  The QueryInterface IUnknown member of this IBall interface
00594             implementation that delegates to m_pUnkOuter, whatever it is.
00595
00596   Args:     REFIID riid,
00597               [in] GUID of the Interface being requested.
00598             PPVOID ppv)
00599               [out] Address of the caller's pointer variable that will
00600               receive the requested interface pointer.
00601
00602   Modifies: .
00603
00604   Returns:  HRESULT
00605               Standard result code. NOERROR for success.
00606               Returned by the delegated outer QueryInterface call.
00607 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00608 STDMETHODIMP COBall::CImpIConnectionPointContainer::QueryInterface(
00609                REFIID riid,
00610                PPVOID ppv)
00611 {
00612   // Delegate this call to the outer object's QueryInterface.
00613   return m_pUnkOuter->QueryInterface(riid, ppv);
00614 }
00615
00616
00617 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00618   Method:   COBall::CImpIConnectionPointContainer::AddRef
00619
00620   Summary:  The AddRef IUnknown member of this IBall interface
00621             implementation that delegates to m_pUnkOuter, whatever it is.
00622
00623   Args:     void
00624
00625   Modifies: .
00626
00627   Returns:  ULONG
00628               Returned by the delegated outer AddRef call.
00629 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00630 STDMETHODIMP_(ULONG) COBall::CImpIConnectionPointContainer::AddRef(void)
00631 {
00632   // Delegate this call to the outer object's AddRef.
00633   return m_pUnkOuter->AddRef();
00634 }
00635
00636
00637 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00638   Method:   COBall::CImpIConnectionPointContainer::Release
00639
00640   Summary:  The Release IUnknown member of this IBall interface
00641             implementation that delegates to m_pUnkOuter, whatever it is.
00642
00643   Args:     void
00644
00645   Modifies: .
00646
00647   Returns:  ULONG
00648               Returned by the delegated outer Release call.
00649 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00650 STDMETHODIMP_(ULONG) COBall::CImpIConnectionPointContainer::Release(void)
00651 {
00652   // Delegate this call to the outer object's Release.
00653   return m_pUnkOuter->Release();
00654 }
00655
00656
00657 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00658   Method:   COBall::CImpIConnectionPointContainer::FindConnectionPoint
00659
00660   Summary:  Given an IID for a connection point sink find and return the
00661             interface pointer for that connection point sink.
00662
00663   Args:     REFIID riid
00664               Reference to an IID
00665             IConnectionPoint** ppConnPt
00666               Pointer to the caller's Connection Point pointer variable.
00667
00668   Modifies: .
00669
00670   Returns:  HRESULT
00671               Standard result code. NOERROR for success.
00672 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00673 STDMETHODIMP COBall::CImpIConnectionPointContainer::FindConnectionPoint(
00674                REFIID riid,
00675                IConnectionPoint** ppConnPt)
00676 {
00677   HRESULT hr = E_NOINTERFACE;
00678   IConnectionPoint* pIConnPt;
00679
00680   if (OwnThis())
00681   {
00682     // NULL the output variable.
00683     *ppConnPt = NULL;
00684
00685     pIConnPt = m_pBackObj->m_aConnectionPoints[CONNPOINT_BALLSINK];
00686     if (NULL != pIConnPt)
00687     {
00688       // This connectable COBall object currently has only the Ball Sink
00689       // connection point. If the associated interface is requested,
00690       // use QI to get the Connection Point interface and perform the
00691       // needed AddRef.
00692       if (IID_IBallSink == riid)
00693         hr = pIConnPt->QueryInterface(
00694                          IID_IConnectionPoint,
00695                          (PPVOID)ppConnPt);
00696     }
00697
00698     UnOwnThis();
00699   }
00700
00701   return hr;
00702 }
00703
00704
00705 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00706   Method:   COBall::CImpIConnectionPointContainer::EnumConnectionPoints
00707
00708   Summary:  Return Enumerator for the connectable object's contained
00709             connection points.
00710
00711   Args:     IEnumConnectionPoints** ppIEnum
00712               Pointer to the caller's Enumerator pointer variable.
00713               An output variable that will receive a pointer to the
00714               connection point enumerator COM object.
00715
00716   Modifies: .
00717
00718   Returns:  HRESULT
00719               Standard result code. NOERROR for success.
00720 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00721 STDMETHODIMP COBall::CImpIConnectionPointContainer::EnumConnectionPoints(
00722                        IEnumConnectionPoints** ppIEnum)
00723 {
00724   HRESULT hr = NOERROR;
00725   IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
00726   COEnumConnectionPoints* pCOEnum;
00727   UINT i;
00728
00729   if (OwnThis())
00730   {
00731     // Zero the output interface pointer.
00732     *ppIEnum = NULL;
00733
00734     // Make a copy on the stack of the array of connection point interfaces.
00735     // The copy is used below in the creation of the new Enumerator object.
00736     for (i=0; i<MAX_CONNECTION_POINTS; i++)
00737       aConnPts[i] = (IConnectionPoint*)m_pBackObj->m_aConnectionPoints[i];
00738
00739     // Create a Connection Point enumerator COM object for the connection
00740     // points offered by this COBall object. Pass 'this' to be used to
00741     // hook the lifetime of the host object to the life time of this
00742     // enumerator object.
00743     pCOEnum = new COEnumConnectionPoints(this);
00744     if (NULL != pCOEnum)
00745     {
00746       // Use the array copy to Init the new Enumerator COM object.
00747       // Set the initial Enumerator index to 0.
00748       hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
00749       if (SUCCEEDED(hr))
00750       {
00751         // QueryInterface to return the requested interface pointer.
00752         // An AddRef will be conveniently done by the QI.
00753         if (SUCCEEDED(hr))
00754           hr = pCOEnum->QueryInterface(
00755                           IID_IEnumConnectionPoints,
00756                           (PPVOID)ppIEnum);
00757       }
00758     }
00759     else
00760       hr = E_OUTOFMEMORY;
00761
00762     UnOwnThis();
00763   }
00764
00765   return hr;
00766 }
00767
00768
00769 /*---------------------------------------------------------------------------
00770   COBall's nested implementation of the custom IBall interface including
00771   Constructor, Destructor, QueryInterface, AddRef, Release, Reset, Move,
00772   and GetBall. This interface implementation also has internal methods
00773   that are not particulary intended for outside clients: GetDimensions,
00774   SetDimensions, GetDirection, SetDirection, GetPosition, SetPostion,
00775   CheckBounce, and FindThread. The IBall interface only provides client
00776   access to the IUnknown methods and the Reset, Move, and GetBall methods.
00777 ---------------------------------------------------------------------------*/
00778
00779 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00780   Method:   COBall::CImpIBall::CImpIBall
00781
00782   Summary:  Constructor for the CImpIBall interface instantiation.
00783
00784   Args:     COBall* pBackObj,
00785               Back pointer to the parent outer object.
00786             IUnknown* pUnkOuter
00787               Pointer to the outer Unknown.  For delegation.
00788
00789   Modifies: m_pBackObj, m_pUnkOuter.
00790
00791   Returns:  void
00792 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00793 COBall::CImpIBall::CImpIBall(
00794   COBall* pBackObj,
00795   IUnknown* pUnkOuter)
00796 {
00797   size_t i;
00798   BYTE r=128, g=128, b=128;
00799
00800   // Init the Back Object Pointer to point to the parent object.
00801   m_pBackObj = pBackObj;
00802
00803   // Init the CImpIBall interface's delegating Unknown pointer.  We use
00804   // the Back Object pointer for IUnknown delegation here if we are not
00805   // being aggregated.  If we are being aggregated we use the supplied
00806   // pUnkOuter for IUnknown delegation.  In either case the pointer
00807   // assignment requires no AddRef because the CImpIBall lifetime is
00808   // quaranteed by the lifetime of the parent object in which
00809   // CImpIBall is nested.
00810   if (NULL == pUnkOuter)
00811     m_pUnkOuter = pBackObj;
00812   else
00813     m_pUnkOuter = pUnkOuter;
00814
00815   // Now initialize the living heart of the COBall object.
00816   m_bAlive       = TRUE;
00817   m_xDirection   = 0;
00818   m_yDirection   = 0;
00819   m_bNewPosition = FALSE;
00820   m_xPosition    = 0;
00821   m_yPosition    = 0;
00822   m_nWidth       = 30;
00823   m_nHeight      = 30;
00824   m_xSkew        = BALL_MOVE_SKEW;
00825   m_ySkew        = BALL_MOVE_SKEW;
00826   m_crColor      = RGB(0,0,0);
00827
00828   // Clear point transformation array.
00829   m_XForm.Clear();
00830
00831   // Init BallThread array--init colors and clear thread Ids.
00832   // The BallThreads are the threads that contend to move and/or
00833   // paint the Ball object.
00834   for (i = 0; i < MAX_BALLTHREADS; i++)
00835     m_aBallThreads[i].Id = 0;
00836   m_aBallThreads[0].Color = RGB(0  ,  0,255);  // Blue
00837   m_aBallThreads[1].Color = RGB(0  ,255,  0);  // Green
00838   m_aBallThreads[2].Color = RGB(255,  0,  0);  // Red
00839   m_aBallThreads[3].Color = RGB(255,  0,255);  // Purple
00840   m_aBallThreads[4].Color = RGB(0  ,255,255);  // Aqua
00841   m_aBallThreads[5].Color = RGB(255,255,  0);  // Brown
00842   m_aBallThreads[6].Color = RGB(0  ,  0,  0);  // Black
00843   if (MAX_BALLTHREADS > 8)
00844     for (i=7; i<MAX_BALLTHREADS; i++)
00845     {
00846       // Fill the remainder with some random colors.
00847       m_aBallThreads[i].Color = RGB(r,g,b);
00848       r = (BYTE) lRandom() % 255;
00849       g = (BYTE) lRandom() % 255;
00850       b = (BYTE) lRandom() % 255;
00851     }
00852
00853   return;
00854 }
00855
00856
00857 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00858   Method:   COBall::CImpIBall::~CImpIBall
00859
00860   Summary:  Destructor for the CImpIBall interface instantiation.
00861
00862   Args:     void
00863
00864   Modifies: .
00865
00866   Returns:  void
00867 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00868 COBall::CImpIBall::~CImpIBall(void)
00869 {
00870   return;
00871 }
00872
00873
00874 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00875   Method:   COBall::CImpIBall::GetDimensions
00876
00877   Summary:  Internal private utility method to get the Ball x,y dimensions.
00878
00879   Args:     POINT* pDimension
00880               Pointer to the point that will contain the dimensions.
00881
00882   Modifies: *pDimension.
00883
00884   Returns:  void
00885 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00886 void COBall::CImpIBall::GetDimensions(POINT* pDimension)
00887 {
00888   pDimension->x = m_nWidth;
00889   pDimension->y = m_nHeight;
00890
00891   return;
00892 }
00893
00894
00895 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00896   Method:   COBall::CImpIBall::SetDimensions
00897
00898   Summary:  Internal private utility method to set the Ball x,y dimensions.
00899
00900   Args:     int nWidth
00901               New Ball width.
00902             int nHeight
00903               New Ball Height.
00904
00905   Modifies: .
00906
00907   Returns:  void
00908 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00909 void COBall::CImpIBall::SetDimensions(int nWidth, int nHeight)
00910 {
00911   m_nWidth  = nWidth;
00912   m_nHeight = nHeight;
00913
00914   return;
00915 }
00916
00917
00918 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00919   Method:   COBall::CImpIBall::GetDirection
00920
00921   Summary:  Internal private utility method to get the Ball direction.
00922
00923   Args:     POINT* pDirection
00924               Pointer to the Point that will contain the x,y direction
00925               data.
00926
00927   Modifies: ...
00928
00929   Returns:  void
00930 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00931 void COBall::CImpIBall::GetDirection(POINT* pDirection)
00932 {
00933   pDirection->x = m_xDirection;
00934   pDirection->y = m_yDirection;
00935
00936   return;
00937 }
00938
00939
00940 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00941   Method:   COBall::CImpIBall::SetDirection
00942
00943   Summary:  Internal private utility method to set the Ball direction.
00944
00945   Args:     int xDirection
00946               x coordinate of the new direction.
00947             int yDirection
00948               y coordinate of the new direction.
00949
00950   Modifies: ...
00951
00952   Returns:  void
00953 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00954 void COBall::CImpIBall::SetDirection(int xDirection, int yDirection)
00955 {
00956   m_xDirection = xDirection;
00957   m_yDirection = yDirection;
00958
00959   return;
00960 }
00961
00962
00963 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00964   Method:   COBall::CImpIBall::GetPosition
00965
00966   Summary:  Internal private utility method to get current the Ball
00967             position.
00968
00969   Args:     POINT* pPosition
00970               Pointer to the Point that is the position.
00971
00972   Modifies: *pPostion.
00973
00974   Returns:  void
00975 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00976 void COBall::CImpIBall::GetPosition(POINT* pPosition)
00977 {
00978   POINT Org;
00979
00980   Org.x = 0;
00981   Org.y = 0;
00982   m_XForm.Point(&Org);
00983
00984   pPosition->x = Org.x;
00985   pPosition->y = Org.y;
00986
00987   return;
00988 }
00989
00990
00991 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00992   Method:   COBall::CImpIBall::SetPosition
00993
00994   Summary:  Internal private utility method to set current the Ball
00995             position.
00996
00997   Args:     int x
00998               x-coordinate of new position.
00999             int y
01000               y-coordinate of new position.
01001
01002   Modifies: ...
01003
01004   Returns:  void
01005 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01006 void COBall::CImpIBall::SetPosition(int x, int y)
01007 {
01008   m_bNewPosition = TRUE;
01009   m_xPosition    = x;
01010   m_yPosition    = y;
01011
01012   return;
01013 }
01014
01015
01016 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01017   Method:   COBall::CImpIBall::CheckBounce
01018
01019   Summary:  Internal private utility method to check the current Ball
01020             position, dimension, and direction data and determine if the
01021             Ball has hit the internal WinRect bounding rectangle. If it
01022             has then the Ball data is recalculated to achieve a "bounce"
01023             effect for the Ball as it moves. Returns a DWORD indicating
01024             the type of bounce event that happened.
01025
01026   Args:     void
01027
01028   Modifies: ...
01029
01030   Returns:  DWORD
01031               Type of bounce: BOUNCE_NONE, BOUNCE_BOTTOM, BOUNCE_LEFT,
01032               BOUNCE_RIGHT, or BOUNCE_TOP.
01033 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01034 DWORD COBall::CImpIBall::CheckBounce(void)
01035 {
01036   DWORD dwBounceType = BOUNCE_NONE;
01037   POINT Pos, Dir, Dim;
01038   int   xNewPos, yNewPos, xNewDir, yNewDir;
01039
01040   GetPosition(&Pos);
01041   GetDirection(&Dir);
01042   GetDimensions(&Dim);
01043
01044   // Check each edge of the client rectangle.  If the Ball goes past the
01045   // boundries, reset its position and direction to give it a "bounce"
01046   // effect the next time it is displayed.
01047   xNewDir = Dir.x;
01048   yNewDir = Dir.y;
01049   xNewPos = Pos.x + Dir.x;
01050   yNewPos = Pos.y + Dir.y;
01051
01052   if(xNewPos < m_WinRect.left)
01053   {
01054     xNewDir = ((lRandom() % m_xSkew) + m_xSkew);
01055     SetPosition(m_WinRect.left, Pos.y);
01056     dwBounceType = BOUNCE_LEFT;
01057   }
01058   if((xNewPos + Dim.x) > m_WinRect.right)
01059   {
01060     xNewDir = -(((int)lRandom() % m_xSkew) + m_xSkew);
01061     SetPosition(m_WinRect.right - Dim.x, Pos.y);
01062     dwBounceType = BOUNCE_RIGHT;
01063   }
01064   if(yNewPos < m_WinRect.top)
01065   {
01066     yNewDir = ((lRandom() % m_ySkew) + m_ySkew);
01067     SetPosition(Pos.x, m_WinRect.top);
01068     dwBounceType = BOUNCE_TOP;
01069   }
01070   if((yNewPos + Dim.y) > m_WinRect.bottom)
01071   {
01072     yNewDir = -(((int)lRandom() % m_ySkew) + m_ySkew);
01073     SetPosition(Pos.x, m_WinRect.bottom - Dim.y);
01074     dwBounceType = BOUNCE_BOTTOM;
01075   }
01076
01077   SetDirection(xNewDir, yNewDir);
01078
01079   return dwBounceType;
01080 }
01081
01082
01083 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01084   Method:   COBall::CImpIBall::FindThread
01085
01086   Summary:  Internal private utility method to Find the thread that is now
01087             executing this code. If the executing thread is not already in
01088             the Thread array, remember the new Thread's Id and add it to
01089             the array. This in effect assigns the thread a color that can
01090             be used for tutorial display of which thread is executing on
01091             the Ball object.
01092
01093   Args:     void
01094
01095   Modifies: ...
01096
01097   Returns:  void
01098 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01099 void COBall::CImpIBall::FindThread(void)
01100 {
01101   BOOL bFound = FALSE;
01102   DWORD dwTId = GetCurrentThreadId();
01103   size_t i = 0;
01104
01105   while(!bFound && i<MAX_BALLTHREADS)
01106   {
01107     if (m_aBallThreads[i].Id == 0)
01108     {
01109       // Found empty slot. This simple array logic allows no empty holes.
01110       m_aBallThreads[i].Id = dwTId;
01111       bFound = TRUE;
01112     }
01113     else
01114     {
01115       if (m_aBallThreads[i].Id == dwTId)
01116       {
01117         // Found previous visiting thread--use its assigned color.
01118         m_crColor = m_aBallThreads[i].Color;
01119         bFound = TRUE;
01120       }
01121       else
01122       {
01123         i++;
01124         if (i >= MAX_BALLTHREADS)
01125         {
01126           // Thread array is full--use a gray color for all other
01127           // excess visiting threads.
01128           m_crColor = RGB(127,127,127);
01129           bFound = TRUE;
01130         }
01131       }
01132     }
01133   }
01134
01135   return;
01136 }
01137
01138
01139 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01140   Method:   COBall::CImpIBall::QueryInterface
01141
01142   Summary:  The QueryInterface IUnknown member of this IBall interface
01143             implementation that delegates to m_pUnkOuter, whatever it is.
01144
01145   Args:     REFIID riid,
01146               [in] GUID of the Interface being requested.
01147             PPVOID ppv)
01148               [out] Address of the caller's pointer variable that will
01149               receive the requested interface pointer.
01150
01151   Modifies: .
01152
01153   Returns:  HRESULT
01154               Standard result code. NOERROR for success.
01155               Returned by the delegated outer QueryInterface call.
01156 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01157 STDMETHODIMP COBall::CImpIBall::QueryInterface(
01158                REFIID riid,
01159                PPVOID ppv)
01160 {
01161   // Delegate this call to the outer object's QueryInterface.
01162   return m_pUnkOuter->QueryInterface(riid, ppv);
01163 }
01164
01165
01166 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01167   Method:   COBall::CImpIBall::AddRef
01168
01169   Summary:  The AddRef IUnknown member of this IBall interface
01170             implementation that delegates to m_pUnkOuter, whatever it is.
01171
01172   Args:     void
01173
01174   Modifies: .
01175
01176   Returns:  ULONG
01177               Returned by the delegated outer AddRef call.
01178 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01179 STDMETHODIMP_(ULONG) COBall::CImpIBall::AddRef(void)
01180 {
01181   // Delegate this call to the outer object's AddRef.
01182   return m_pUnkOuter->AddRef();
01183 }
01184
01185
01186 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01187   Method:   COBall::CImpIBall::Release
01188
01189   Summary:  The Release IUnknown member of this IBall interface
01190             implementation that delegates to m_pUnkOuter, whatever it is.
01191
01192   Args:     void
01193
01194   Modifies: .
01195
01196   Returns:  ULONG
01197               Returned by the delegated outer Release call.
01198 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01199 STDMETHODIMP_(ULONG) COBall::CImpIBall::Release(void)
01200 {
01201   // Delegate this call to the outer object's Release.
01202   return m_pUnkOuter->Release();
01203 }
01204
01205
01206
01207
01208 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01209   Method:   COBall::CImpIBall::Reset
01210
01211   Summary:  The Reset member method of the IBall interface implementation.
01212             Called by outside clients of a COBall object to reset the
01213             virtual Ball. The ball is restored to the upper left corner.
01214
01215   Args:     RECT* pNewRect,
01216               Pointer to a RECT structure. Tells the COBall the bounding
01217               rectangle within which the Ball can move.
01218             short nBallSize,
01219               The size of the ball in pixels. nBallSize == Width == Height
01220               meaning that a circle is assumed.
01221
01222   Modifies: ...
01223
01224   Returns:  void
01225 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01226 STDMETHODIMP COBall::CImpIBall::Reset(
01227                RECT* pNewRect,
01228                short nBallSize)
01229 {
01230   HRESULT hr = E_FAIL;
01231   int nDim, xDirection, yDirection;
01232
01233   if (OwnThis())
01234   {
01235     // Find the thread who is executing this and remember its color.
01236     FindThread();
01237
01238     m_xSkew = m_ySkew = BALL_MOVE_SKEW;
01239     m_WinRect.left = pNewRect->left;
01240     m_WinRect.top = pNewRect->top;
01241     m_WinRect.right = pNewRect->right;
01242     m_WinRect.bottom = pNewRect->bottom;
01243     nDim = nBallSize ? nBallSize : max(5, m_WinRect.right / 13);
01244     SetDimensions(nDim, nDim);
01245     SetPosition(0, 0);
01246     xDirection = ((lRandom() % m_xSkew) + m_xSkew);
01247     yDirection = ((lRandom() % m_ySkew) + m_ySkew);
01248     SetDirection(xDirection, yDirection);
01249
01250     hr = NOERROR;
01251
01252     UnOwnThis();
01253   }
01254
01255   return hr;
01256 }
01257
01258
01259 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01260   Method:   COBall::CImpIBall::Move
01261
01262   Summary:  The Move member method of this IBall interface implementation.
01263             Called by outside clients of a COBall object to advance the
01264             "motion" of this COBall virtual Ball entity.
01265
01266   Args:     BOOL bAlive
01267               TRUE means stay alive; FALSE means don't move but die.
01268
01269   Modifies: m_bAlive.
01270
01271   Returns:  HRESULT
01272               Standard result code. NOERROR for success and means the move
01273               was done and the ball is still alive. E_FAIL means the move
01274               was not done and the ball has been killed.
01275 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01276 STDMETHODIMP COBall::CImpIBall::Move(
01277                BOOL bAlive)
01278 {
01279   HRESULT hr = E_FAIL;
01280   DWORD dwEvent;
01281
01282   if (OwnThis())
01283   {
01284     if (bAlive && m_bAlive)
01285     {
01286       // Find thread that is now executing this code. Remember its Id and
01287       // assign it a color. If this thread previously visited here then
01288       // use its remembered values. In any case, set a color value in
01289       // m_crColor of its existing or newly assigned color.
01290       FindThread();
01291
01292       // Ask the Ball if it has hit any of the edges of the current window
01293       // rectangle. If so, it will recalculate its position and direction
01294       // to achieve a "bounce" effect in its motion the next time it is
01295       // painted. CheckBounce also determines and returns any notification
01296       // events.
01297       dwEvent = CheckBounce();
01298
01299       // Send notification of each bounce event to any listening sinks.
01300       m_pBackObj->NotifySinks(dwEvent);
01301
01302       // Calculate and set new Ball position.
01303       if(m_bNewPosition)
01304       {
01305         m_bNewPosition = FALSE;
01306         m_XForm.Clear();
01307         m_XForm.Trans(m_xPosition, m_yPosition);
01308       }
01309       else
01310         m_XForm.Trans(m_xDirection, m_yDirection);
01311     }
01312     else
01313       m_bAlive = FALSE;
01314
01315     hr = m_bAlive ? NOERROR : E_FAIL;
01316
01317     UnOwnThis();
01318   }
01319
01320   return hr;
01321 }
01322
01323
01324 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01325   Method:   COBall::CImpIBall::GetBall
01326
01327   Summary:  The GetBall member method of this IBall interface
01328             implementation. Called by outside clients of a COBall object
01329             to get the necessary data on the moving Ball to enable GUI
01330             display of an actual image of this virtual Ball. This COBall
01331             is a data entity only that is kept alive by client threads
01332             that call Move. A GUI client can independently call GetBall
01333             to allow it to display some visual representation of the Ball.
01334
01335   Args:     POINT* pNewOrg,
01336               Pointer to a point that will contain the new origin
01337               position of the Ball.
01338             POINT* pNewExt,
01339               Pointer to a point that will contain the new extent
01340               size of the Ball.
01341             COLORREF* pcrColor)
01342               Pointer to a COLORREF that will contain the current color
01343               of the Ball. This color is determined by the last thread
01344               that was executing in the Ball before this call is made.
01345
01346   Modifies: ...
01347
01348   Returns:  void
01349 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01350 STDMETHODIMP COBall::CImpIBall::GetBall(
01351        POINT* pNewOrg,
01352        POINT* pNewExt,
01353        COLORREF* pcrColor)
01354 {
01355   HRESULT hr = E_FAIL;
01356
01357   if (OwnThis())
01358   {
01359     pNewOrg->x = 0;
01360     pNewOrg->y = 0;
01361     m_XForm.Point(pNewOrg);
01362     pNewExt->x = m_nWidth;
01363     pNewExt->y = m_nHeight;
01364     m_XForm.Point(pNewExt);
01365
01366     *pcrColor = m_crColor;
01367
01368     hr = NOERROR;
01369
01370     UnOwnThis();
01371   }
01372
01373   return hr;
01374 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/FaxDlg.h Source File

  • NetDS
  • fax
  • PrintSdi

FaxDlg.h

Go to the documentation of this file.
00001 #if !defined(AFX_FAXDLG_H__55689554_8B6C_11D1_B7AE_000000000000__INCLUDED_)
00002 #define AFX_FAXDLG_H__55689554_8B6C_11D1_B7AE_000000000000__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007 // FaxDlg.h : header file
00008 //
00009
00010 /////////////////////////////////////////////////////////////////////////////
00011 // FaxDlg dialog
00012
00013 class FaxDlg : public CDialog
00014 {
00015 // Construction
00016 public:
00017   FaxDlg(CWnd* pParent = NULL);   // standard constructor
00018
00019 // Dialog Data
00020   //{{AFX_DATA(FaxDlg)
00021   enum { IDD = IDD_FAX };
00022   CString m_FaxNumber;
00023   CString m_RecipientName;
00024   //}}AFX_DATA
00025
00026
00027 // Overrides
00028   // ClassWizard generated virtual function overrides
00029   //{{AFX_VIRTUAL(FaxDlg)
00030   protected:
00031   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00032   //}}AFX_VIRTUAL
00033
00034 // Implementation
00035 protected:
00036
00037   // Generated message map functions
00038   //{{AFX_MSG(FaxDlg)
00039     // NOTE: the ClassWizard will add member functions here
00040   //}}AFX_MSG
00041   DECLARE_MESSAGE_MAP()
00042 };
00043
00044 //{{AFX_INSERT_LOCATION}}
00045 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00046
00047 #endif // !defined(AFX_FAXDLG_H__55689554_8B6C_11D1_B7AE_000000000000__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CContextAdmin Member List

This is the complete list of members for CContextAdmin, including all inherited members.
CContextAdmin() | CContextAdmin | [inline]
get_ContextTypes(WMS_CONTEXT_PLUGIN_CONTEXT_TYPE *pwmsContextTypes) | CContextAdmin |
get_OutputPath(BSTR *pbstrOutputPath) | CContextAdmin |
Initialize(CContextPlugin *pPlugin) | CContextAdmin |
InterfaceSupportsErrorInfo(REFIID riid) | CContextAdmin |
m_pContextPlugin | CContextAdmin | [private]
put_ContextTypes(WMS_CONTEXT_PLUGIN_CONTEXT_TYPE wmsContextTypes) | CContextAdmin |
put_OutputPath(BSTR bstrOutputPath) | CContextAdmin |
Generated on Wed Nov 13 2024 16:55:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCompartmentMonitor Member List

This is the complete list of members for CCompartmentMonitor, including all inherited members.
CCompartmentMonitor(void) | CCompartmentMonitor |
GetStatus(BOOL *pfStatus) | CCompartmentMonitor |
Initialize(const GUID *pguidCompartment, PCOMPARTMENTMONITORPROC pCallback, LPARAM lParam) | CCompartmentMonitor |
m_dwCookie | CCompartmentMonitor | [private]
m_dwRef | CCompartmentMonitor | [private]
m_guidCompartment | CCompartmentMonitor | [private]
m_lParam | CCompartmentMonitor | [private]
m_pCallback | CCompartmentMonitor | [private]
m_pCompartment | CCompartmentMonitor | [private]
OnChange(REFGUID rguid) | CCompartmentMonitor |
QueryInterface(REFIID riid, void **ppvObj) | CCompartmentMonitor |
STDMETHODIMP_(ULONG) AddRef(void) | CCompartmentMonitor |
STDMETHODIMP_(ULONG) Release(void) | CCompartmentMonitor |
Uninitialize(void) | CCompartmentMonitor |
~CCompartmentMonitor() | CCompartmentMonitor | [virtual]
Generated on Wed Nov 13 2024 16:55:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConClien/ConClien.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConClien

ConClien.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONCLIEN.CPP
00003
00004   Summary:   Based largely on the FRECLIEN.EXE application code, this
00005              client loads and accesses the Connectable DllSndBall
00006              component provided in a separate in-process COM Server
00007              (CONSERVE built in the sibling CONSERVE directory).  Thus to
00008              run CONCLIEN you must build CONSERVE first. This client
00009              application is meant to exercise the CONSERVE in-process
00010              server and illustrate the use of event sinks in the client
00011              which connect to connection points in the server-housed
00012              connectable object, COBall.  This objec maintains logic and
00013              data to simulate a ball bouncing inside of an enclosed
00014              2-dimensional area. The client continuously moves and
00015              displays the virtual ball and listens for sink notifications
00016              when the ball bounces. Different Sounds are issued when the
00017              ball hits and bounces off the top, sides, and bottom of the
00018              bounding rectangle.
00019
00020              There is no GUI behavior in the server--it is all in this
00021              client.  This client instantiates one instance of the
00022              server's COBall COM object and then moves and displays it.
00023              There is a minimal menu in CONCLIEN. All the action is
00024              automatic. The main application window's client area is used
00025              for visual display of the moving ball.
00026
00027              For a comprehensive tutorial code tour of CONCLIEN's contents
00028              and offerings see the tutorial CONCLIEN.HTM file. For
00029              more specific technical details on the internal workings see
00030              the comments dispersed throughout the CONCLIEN source code.
00031              For more details on the CONSERVE.DLL that CONCLIEN works with
00032              see the CONSERVE.HTM file in the main tutorial directory.
00033
00034   Classes:   CMainWindow
00035
00036   Functions: InitApplication, WinMain
00037
00038   Origin:    5-30-96: atrent - Editor-inheritance from the FRECLIEN source.
00039
00040 ----------------------------------------------------------------------------
00041   This file is part of the Microsoft COM Tutorial Code Samples.
00042
00043   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00044
00045   This source code is intended only as a supplement to Microsoft
00046   Development Tools and/or on-line documentation.  See these other
00047   materials for detailed information regarding Microsoft code samples.
00048
00049   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00050   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00051   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00052   PARTICULAR PURPOSE.
00053 ==========================================================================+*/
00054
00055 /*--------------------------------------------------------------------------
00056   We include WINDOWS.H for all Win32 applications.
00057   We include OLE2.H because we will be calling the COM/OLE libraries.
00058   We include OLECTL.H because it has definitions for connectable objects.
00059   We include INITGUID.H only once (here) in the entire app because we
00060     will be defining GUIDs and want them as constants in the data segment.
00061   We include COMMDLG.H because we will be using the Open File and
00062     potentially other Common dialogs.
00063   We include APPUTIL.H because we will be building this application using
00064     the convenient Virtual Window and Dialog classes and other
00065     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00066   We include IBALL.H and BALLGUID.H for the common Ball-related Interface
00067     class, GUID, and CLSID specifications.
00068   We include GUIBALL.H because it has the C++ class used for GUI display
00069     of the moving ball.
00070   We include CONCLIEN.H because it has class and resource definitions
00071     specific to this CONCLIEN application.
00072 ---------------------------------------------------------------------------*/
00073 #include <windows.h>
00074 #include <ole2.h>
00075 #include <olectl.h>
00076 #include <initguid.h>
00077 #include <commdlg.h>
00078 #include <apputil.h>
00079 #include <iball.h>
00080 #include <ballguid.h>
00081 #include "guiball.h"
00082 #include "conclien.h"
00083
00084
00085 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00086   Method:   CMainWindow::CMainWindow
00087
00088   Summary:  CMainWindow Constructor.
00089
00090   Args:     .
00091
00092   Modifies: .
00093
00094   Returns:  .
00095 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00096 CMainWindow::CMainWindow()
00097 {
00098   // Ensure these member variable strings are null strings.
00099   m_szFileName[0] = 0;
00100   m_szFileTitle[0] = 0;
00101
00102   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00103   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00104   m_ofnFile.hwndOwner = m_hWnd;
00105   m_ofnFile.hInstance = m_hInst;
00106   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00107   m_ofnFile.lpstrCustomFilter = NULL;
00108   m_ofnFile.nMaxCustFilter = 0;
00109   m_ofnFile.nFilterIndex = 1;
00110   m_ofnFile.lpstrFile = m_szFileName;
00111   m_ofnFile.nMaxFile = MAX_PATH;
00112   m_ofnFile.lpstrInitialDir = TEXT(".");
00113   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00114   m_ofnFile.nMaxFileTitle = MAX_PATH;
00115   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00116   m_ofnFile.lpstrDefExt = NULL;
00117   m_ofnFile.Flags = OFN_HIDEREADONLY;
00118
00119   m_pMsgBox  = NULL;
00120   m_pGuiBall = NULL;
00121 }
00122
00123
00124 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00125   Method:   CMainWindow::~CMainWindow
00126
00127   Summary:  CMainWindow Destructor.  Destruction of the main window
00128             indicates that the application should quit and thus the
00129             PostQuitMessage API is called.
00130
00131   Args:     .
00132
00133   Modifies: .
00134
00135   Returns:  .
00136 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00137 CMainWindow::~CMainWindow()
00138 {
00139   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00140   // message and causes a delete of CMainWindow which in turn causes this
00141   // destructor to run. The WM_DESTROY results when the window is destoyed
00142   // after a close of the window. Prior to exiting the main message loop:
00143
00144   // We delete the CGuiBall and CMsgBox objects that were made in
00145   // Initinstance.
00146   DELETE_POINTER(m_pGuiBall);
00147   DELETE_POINTER(m_pMsgBox);
00148
00149   // We then post a WM_QUIT message to cause an exit of the main thread's
00150   // message loop and an exit of this instance of the application.
00151   PostQuitMessage(0);
00152 }
00153
00154
00155 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00156   Method:   CMainWindow::InitInstance
00157
00158   Summary:  Instantiates an instance of the main application window.
00159             This method must be called only once, immediately after
00160             window class construction.  We take care to delete 'this'
00161             CMainWindow if we must return the error condition FALSE.
00162
00163   Args:     HINSTANCE hInstance,
00164               Handle of the application instance.
00165             int nCmdShow)
00166               Command to pass to ShowWindow.
00167
00168   Modifies: m_szHelpFile, m_pMsgBox.
00169
00170   Returns:  BOOL.
00171               TRUE if succeeded.
00172               FALSE if failed.
00173 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00174 BOOL CMainWindow::InitInstance(
00175        HINSTANCE hInstance,
00176        int nCmdShow)
00177 {
00178   BOOL bOk = FALSE;
00179   HWND hWnd = NULL;
00180   HRESULT hr;
00181
00182   // Create the Message Box and Message Log objects.
00183   m_pMsgBox = new CMsgBox;
00184
00185   // Create the CGuiBall object.
00186   m_pGuiBall = new CGuiBall;
00187
00188   if (NULL != m_pMsgBox && NULL != m_pGuiBall)
00189   {
00190     // Note, the Create method sets the m_hWnd member so we don't
00191     // need to set it explicitly here first. Here is the create of this
00192     // window.  Size the window reasonably. Create sets both m_hInst and
00193     // m_hWnd. This creates the main client window.
00194     hWnd = Create(
00195              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00196              TEXT(MAIN_WINDOW_TITLE_STR),
00197              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00198                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00199              CW_USEDEFAULT,
00200              CW_USEDEFAULT,
00201              ::GetSystemMetrics(SM_CXSCREEN)*2/5,
00202              ::GetSystemMetrics(SM_CYSCREEN)*2/5,
00203              NULL,
00204              NULL,
00205              hInstance);
00206     if (NULL != hWnd)
00207     {
00208       // Init the new GuiBall.
00209       bOk = m_pGuiBall->Init(m_hWnd);
00210       if (bOk)
00211       {
00212         // Ensure the new window is shown on screen and content
00213         // is painted.
00214         ::ShowWindow(m_hWnd, nCmdShow);
00215         ::UpdateWindow(m_hWnd);
00216
00217         // Build a path to where the help file should be (it should be in
00218         // the same directory as the .EXE but with the .HTM extension.
00219         MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00220
00221         // Init the Message Box object.
00222         bOk = m_pMsgBox->Init(m_hInst, m_hWnd);
00223
00224         // Connect the new Ball Sink in this client to receive event
00225         // calls from a COBall source in the server.
00226         hr = m_pGuiBall->ConnectBallSink();
00227         if (SUCCEEDED(hr))
00228         {
00229           HMENU hMenu  = ::GetMenu(m_hWnd);
00230
00231           ::CheckMenuItem(
00232               hMenu,
00233               IDM_SOUND_BALL_ON,
00234               MF_BYCOMMAND | MF_CHECKED);
00235           ::CheckMenuItem(
00236               hMenu,
00237               IDM_SOUND_BALL_OFF,
00238               MF_BYCOMMAND | MF_UNCHECKED);
00239         }
00240       }
00241     }
00242   }
00243
00244   if (!bOk)
00245   {
00246     DELETE_POINTER(m_pMsgBox);
00247     DELETE_POINTER(m_pGuiBall);
00248   }
00249
00250   return (bOk);
00251 }
00252
00253
00254 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00255   Method:   CMainWindow::DoMenu
00256
00257   Summary:  Dispatch and handle the main menu commands.
00258
00259   Args:     WPARAM wParam,
00260               First message parameter (word sized).
00261             LPARAM lParam)
00262               Second message parameter (long sized).
00263
00264   Modifies: m_ofnFile, ...
00265
00266   Returns:  LRESULT
00267               Standard Windows WindowProc return value.
00268 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00269 LRESULT CMainWindow::DoMenu(
00270           WPARAM wParam,
00271           LPARAM lParam)
00272 {
00273   LRESULT lResult = FALSE;
00274   HMENU hMenu  = ::GetMenu(m_hWnd);
00275
00276   switch (LOWORD(wParam))
00277   {
00278     //----------------------------------------------------------------------
00279     // Handle File Menu Commands.
00280     //----------------------------------------------------------------------
00281     case IDM_FILE_EXIT:
00282       // The user commands us to exit this application so we tell the
00283       // Main window to close itself.
00284       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00285       break;
00286
00287     //----------------------------------------------------------------------
00288     // Handle Sound Menu Commands.
00289     //----------------------------------------------------------------------
00290     case IDM_SOUND_BALL_ON:
00291       // Connect the client's sound event Ball Sink to the COBall event
00292       // source in the server. Set the proper checkmark indicator on
00293       // the menu selections as well.
00294       {
00295         HRESULT hr;
00296         HMENU hMenu  = ::GetMenu(m_hWnd);
00297         BOOL bConnected = ::GetMenuState(
00298                               hMenu,
00299                               IDM_SOUND_BALL_ON,
00300                               MF_BYCOMMAND) & MF_CHECKED;
00301         if (!bConnected)
00302         {
00303           hr = m_pGuiBall->ConnectBallSink();
00304           if (SUCCEEDED(hr))
00305           {
00306             ::CheckMenuItem(
00307                 hMenu,
00308                 IDM_SOUND_BALL_ON,
00309                 MF_BYCOMMAND | MF_CHECKED);
00310             ::CheckMenuItem(
00311                 hMenu,
00312                 IDM_SOUND_BALL_OFF,
00313                 MF_BYCOMMAND | MF_UNCHECKED);
00314           }
00315         }
00316       }
00317       break;
00318     case IDM_SOUND_BALL_OFF:
00319       // Disconnect the client's sound event Ball Sink from the COBall
00320       // event source in the server. Set the proper checkmark indicator on
00321       // the menu selections as well.
00322       {
00323         HRESULT hr;
00324         HMENU hMenu  = ::GetMenu(m_hWnd);
00325         BOOL bDisConnected = ::GetMenuState(
00326                                 hMenu,
00327                                 IDM_SOUND_BALL_OFF,
00328                                 MF_BYCOMMAND) & MF_CHECKED;
00329         if (!bDisConnected)
00330         {
00331           hr = m_pGuiBall->DisconnectBallSink();
00332           if (SUCCEEDED(hr))
00333           {
00334             ::CheckMenuItem(
00335                 hMenu,
00336                 IDM_SOUND_BALL_ON,
00337                 MF_BYCOMMAND | MF_UNCHECKED);
00338             ::CheckMenuItem(
00339                 hMenu,
00340                 IDM_SOUND_BALL_OFF,
00341                 MF_BYCOMMAND | MF_CHECKED);
00342           }
00343         }
00344       }
00345       break;
00346
00347     //----------------------------------------------------------------------
00348     // Handle Help Menu Commands.
00349     //----------------------------------------------------------------------
00350     case IDM_HELP_CONTENTS:
00351       // We have some stubbed support here for bringing up the online
00352       // Help for this application.
00353       ReadHelp(m_hWnd, m_szHelpFile);
00354       break;
00355     case IDM_HELP_TUTORIAL:
00356       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00357       // tutorial narrative file associated with this tutorial code sample.
00358       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00359       break;
00360     case IDM_HELP_TUTSERVER:
00361       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00362       // tutorial narrative file associated with the COM server.
00363       ReadTutorial(m_hInst, m_hWnd, TEXT(SERVER_TUTFILE_STR));
00364       break;
00365     case IDM_HELP_READSOURCE:
00366       // Call the APPUTIL utility function ReadSource to allow the
00367       // user to open and read any of the source files of CONCLIEN.
00368       ReadSource(m_hWnd, &m_ofnFile);
00369       break;
00370     case IDM_HELP_ABOUT:
00371       {
00372         CAboutBox dlgAboutBox;
00373
00374         // Show the standard About Box dialog for this EXE by telling the
00375         // dialog C++ object to show itself by invoking its ShowDialog
00376         // method.  Pass it this EXE instance and the parent window handle.
00377         // Use a dialog resource ID for the dialog template stored in
00378         // this EXE module's resources.
00379         dlgAboutBox.ShowDialog(
00380           m_hInst,
00381           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00382           m_hWnd);
00383       }
00384       break;
00385
00386     default:
00387       // Defer all messages NOT handled here to the Default Window Proc.
00388       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00389       break;
00390   }
00391
00392   return(lResult);
00393 }
00394
00395
00396 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00397   Method:   CMainWindow::WindowProc
00398
00399   Summary:  Main window procedure for this window object.  See CVirWindow
00400             in the APPUTIL library (APPUTIL.CPP) for details on how this
00401             method gets called by the global WindowProc.
00402
00403   Args:     UINT uMsg,
00404               Windows message that is "sent" to this window.
00405             WPARAM wParam,
00406               First message parameter (word sized).
00407             LPARAM lParam)
00408               Second message parameter (long sized).
00409
00410   Modifies: ...
00411
00412   Returns:  LRESULT
00413               Standard Windows WindowProc return value.
00414 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00415 LRESULT CMainWindow::WindowProc(
00416           UINT uMsg,
00417           WPARAM wParam,
00418           LPARAM lParam)
00419 {
00420   LRESULT lResult = FALSE;
00421
00422   switch (uMsg)
00423   {
00424     case WM_CREATE:
00425       break;
00426
00427     case WM_MEASUREITEM:
00428       // Get setup for painting text in this window.
00429       {
00430         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00431         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00432         lpmis->itemWidth = m_wWidth;
00433         lResult = TRUE;
00434       }
00435
00436     case WM_SIZE:
00437       // Handle a resize of this window.
00438       // Clear window and Restart the ball from upper left.
00439       m_wWidth = LOWORD(lParam);
00440       m_wHeight = HIWORD(lParam);
00441       m_pGuiBall->Restart();
00442       // Turn off sounds if app is minimized.
00443       if (SIZE_MINIMIZED == wParam)
00444         DoMenu(IDM_SOUND_BALL_OFF, 0);
00445       break;
00446
00447     case WM_TIMER:
00448       // This is our timed attempt to continuously move & paint the ball.
00449       // In this app PaintBall both moves and paints the ball.
00450       m_pGuiBall->PaintBall();
00451       break;
00452
00453     case WM_COMMAND:
00454       // Dispatch and handle any Menu command messages received.
00455       lResult = DoMenu(wParam, lParam);
00456       break;
00457
00458     case WM_CHAR:
00459       if (wParam == 0x1b)
00460       {
00461         // Exit this app if user hits ESC key.
00462         PostMessage(m_hWnd,WM_CLOSE,0,0);
00463         break;
00464       }
00465     case WM_LBUTTONUP:
00466     case WM_PAINT:
00467       // If something major happened or user clicks or hits key then
00468       // repaint the whole window.
00469       m_pGuiBall->PaintWin();
00470       break;
00471
00472     case WM_CLOSE:
00473       // The user selected Close on the main window's System menu
00474       // or Exit on the File menu.
00475     case WM_QUIT:
00476       // If the app is being quit then close any associated help windows.
00477     default:
00478       // Defer all messages NOT handled here to the Default Window Proc.
00479       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00480       break;
00481   }
00482
00483   return(lResult);
00484 }
00485
00486
00487 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00488   Function: UnicodeOk
00489
00490   Summary:  Checks if the platform will handle unicode versions of
00491             Win32 string API calls.
00492
00493   Args:     void
00494
00495   Returns:  BOOL
00496               TRUE if unicode support; FALSE if not.
00497 ------------------------------------------------------------------------F-F*/
00498 BOOL UnicodeOk(void)
00499 {
00500   BOOL bOk = TRUE;
00501   TCHAR szUserName[MAX_STRING_LENGTH];
00502   DWORD dwSize = MAX_STRING_LENGTH;
00503
00504   if (!GetUserName(szUserName, &dwSize))
00505     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00506
00507   return bOk;
00508 }
00509
00510
00511 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00512   Function: InitApplication
00513
00514   Summary:  Initializes the application and registers its main window
00515             class. InitApplication is called only once (in WinMain).
00516
00517   Args:     HINSTANCE hInstance)
00518               Handle to the first instance of the application.
00519
00520   Returns:  BOOL.
00521               TRUE if success.
00522               FALSE if fail.
00523 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00524 BOOL InitApplication(
00525        HINSTANCE hInstance)
00526 {
00527   BOOL bOk;
00528   // The window class for all instances of the main frame window.
00529   WNDCLASSEX wcf;
00530
00531   // Assign the appropriate values for this main frame window class.
00532   wcf.cbSize        = sizeof(WNDCLASSEX);
00533   wcf.cbClsExtra    = 0;            // No per-class extra data.
00534   wcf.cbWndExtra    = 0;            // No per-window extra data.
00535   wcf.hInstance     = hInstance;    // Application module instance.
00536   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00537                                     // APPUTIL for all CVirWindows).
00538   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
00539   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00540                                 hInstance,
00541                                 TEXT("AppIcon"));
00542   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00543                                 hInstance,
00544                                 TEXT("AppIcon"),
00545                                 IMAGE_ICON,
00546                                 16, 16,
00547                                 0);
00548   wcf.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // Backgnd color.
00549   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
00550   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
00551   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
00552
00553   // Register the window class and return FALSE if unsuccesful.
00554   bOk = RegisterClassEx(&wcf);
00555
00556   return (bOk);
00557 }
00558
00559
00560 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00561   Function: WinMain
00562
00563   Summary:  The Windows main entry point function for this application.
00564             Initializes the application, the COM Libraries, and starts
00565             the main application message loop.
00566
00567   Args:     HINSTANCE hInstance,
00568               Instance handle; a new one for each invocation of this app.
00569             HINSTANCE hPrevInstance,
00570               Instance handle of the previous instance. NULL in Win32.
00571             LPSTR lpCmdLine,
00572               Windows passes a pointer to the application's
00573               invocation command line.
00574             int nCmdShow)
00575               Bits telling the show state of the application.
00576
00577   Returns:  int
00578               msg.wParam (upon exit of message loop).
00579               FALSE if this instance couldn't initialize and run.
00580 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00581 extern "C" int PASCAL WinMain(
00582                         HINSTANCE hInstance,
00583                         HINSTANCE hPrevInstance,
00584                         LPSTR lpCmdLine,
00585                         int nCmdShow)
00586 {
00587   CMainWindow* pWin = NULL;
00588   MSG msg;
00589   HACCEL hAccel;
00590   int iRun = FALSE;
00591
00592   // If we were compiled for UNICODE and the platform seems OK with this
00593   // then proceed.  Else we error and exit the app.
00594   if (UnicodeOk())
00595   {
00596     // Call to initialize the COM Library.  Use the SUCCEEDED macro
00597     // to detect success.  If fail then exit app with error message.
00598     // Tell COM that this client process and all subordinate threads
00599     // will live in a single-threaded apartment world.
00600     if (SUCCEEDED(CoInitialize(NULL)))
00601     {
00602       // If we succeeded in initializing the COM Library we proceed to
00603       // initialize the application.  If we can't init the application
00604       // then we signal shut down with an error message exit.
00605       iRun = InitApplication(hInstance);
00606       if (iRun)
00607       {
00608         // Assume we'll set iRun to TRUE when initialization is done.
00609         iRun = FALSE;
00610         // We are still go for running so we try to create a nifty new
00611         // CMainWindow object for this app instance.
00612         pWin = new CMainWindow;
00613         if (NULL != pWin)
00614         {
00615           // Now we initialize an instance of the new CMainWindow.
00616           // This includes creating the main window.
00617           if (pWin->InitInstance(hInstance, nCmdShow))
00618           {
00619             // Load the keyboard accelerators from the resources.
00620             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
00621             if (NULL != hAccel)
00622             {
00623               // Signal App Initialization is successfully done.
00624               iRun = TRUE;
00625             }
00626           }
00627         }
00628       }
00629
00630       if (iRun)
00631       {
00632         // If we initialized the app instance properly then we are still
00633         // go for running.  We then start up the main message pump for
00634         // the application.
00635         while (GetMessage(&msg, NULL, 0, 0))
00636         {
00637           if (!TranslateAccelerator(pWin->GetHwnd(), hAccel, &msg))
00638           {
00639             TranslateMessage(&msg);
00640             DispatchMessage(&msg);
00641           }
00642         }
00643
00644         // We also ask COM to unload any unused COM Servers, including our
00645         // friend, CONSERVE.
00646         CoFreeUnusedLibraries();
00647
00648         // We'll pass to Windows the reason why we exited the message loop.
00649         iRun = msg.wParam;
00650       }
00651       else
00652       {
00653         // We failed to initialize the application. Put up error message
00654         // box saying that application couldn't be initialized.  Parent
00655         // window is desktop (ie, NULL). Exit the failed application
00656         // (ie, by returning FALSE to WinMain).
00657         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
00658
00659         // Delete the CMainWindow object.
00660         DELETE_POINTER(pWin);
00661       }
00662
00663       // We're exiting this app (either normally or by init failure) so
00664       // shut down the COM Library.
00665       CoUninitialize();
00666     }
00667     else
00668     {
00669       // We failed to Initialize the COM Library. Put up error message box
00670       // saying that COM Library couldn't be initialized.  Parent window
00671       // is desktop (ie, NULL). Exit the failed application (ie, by
00672       // returning FALSE to WinMain).
00673       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
00674     }
00675   }
00676   else
00677   {
00678     // If we were compiled for UNICODE but the platform has problems with
00679     // this then indicate an error and exit the app immediately.
00680     CHAR szMsg[MAX_STRING_LENGTH];
00681
00682     if (LoadStringA(
00683           hInstance,
00684           IDS_NOUNICODE,
00685           szMsg,
00686           MAX_STRING_LENGTH))
00687     {
00688       MessageBoxA(
00689         NULL,
00690         szMsg,
00691         ERROR_TITLE_STR,
00692         MB_OK | MB_ICONEXCLAMATION);
00693     }
00694   }
00695
00696   return iRun;
00697 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/DELQDlg.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

DELQDlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // DelQDlg.h : header file
00013 //
00014
00015
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CDeleteQueueDialog dialog
00019
00020 class CDeleteQueueDialog : public CDialog
00021 {
00022 // Construction
00023 public:
00024   CDeleteQueueDialog(CArray <ARRAYQ*, ARRAYQ*>*, CWnd* pParent = NULL);   // standard constructor
00025
00026 // Dialog Data
00027   //{{AFX_DATA(CDeleteQueueDialog)
00028   enum { IDD = IDD_DELETE_QUEUE_DIALOG };
00029   CComboBox m_PathNameCB;
00030   CString m_szPathName;
00031   //}}AFX_DATA
00032
00033   /* pointer to the array with the strings for the combo box (Queues PathName). */
00034   CArray <ARRAYQ*, ARRAYQ*>* m_pStrArray ;
00035
00036 // Overrides
00037   // ClassWizard generated virtual function overrides
00038   //{{AFX_VIRTUAL(CDeleteQueueDialog)
00039   protected:
00040   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00041   //}}AFX_VIRTUAL
00042
00043 // Implementation
00044 protected:
00045
00046   // Generated message map functions
00047   //{{AFX_MSG(CDeleteQueueDialog)
00048   virtual BOOL OnInitDialog();
00049   //}}AFX_MSG
00050   DECLARE_MESSAGE_MAP()
00051
00052 public:
00053   void GetPathName(TCHAR szPathName[BUFFERSIZE])
00054   {
00055     ASSERT(szPathName != NULL);
00056
00057     _tcsncpy (szPathName, m_szPathName, BUFFERSIZE-1);
00058     szPathName[BUFFERSIZE-1] = '\0';
00059
00060   }
00061
00062 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminApplicationExportOptions Member List

This is the complete list of members for comadmin::COMAdminApplicationExportOptions, including all inherited members.
COMAdminExportApplicationProxy | comadmin::COMAdminApplicationExportOptions | [static]
COMAdminExportForceOverwriteOfFiles | comadmin::COMAdminApplicationExportOptions | [static]
COMAdminExportNoUsers | comadmin::COMAdminApplicationExportOptions | [static]
COMAdminExportUsers | comadmin::COMAdminApplicationExportOptions | [static]
Generated on Wed Nov 13 2024 16:58:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/registry.h Source File

  • SysMgmt
  • MMC
  • ActiveX

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/SimpSvr.Cpp Source File

  • Com
  • Fundamentals
  • SimpSvr

SimpSvr.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: simpsvr.cpp
00003 //
00004 //      Main source file for the simple OLE 2.0 server
00005 //
00006 // Functions:
00007 //
00008 //      WinMain         - Program entry point
00009 //      MainWndProc     - Processes messages for the frame window
00010 //      About           - Processes messages for the about dialog
00011 //      DocWndProc      - Processes messages for the doc window
00012 //
00013 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00014 //**********************************************************************
00015
00016 #include "pre.h"
00017 #include "obj.h"
00018 #include "app.h"
00019 #include "doc.h"
00020 #include "icf.h"
00021
00022 // This line is needed for the debug utilities in OLESTD
00023 extern "C" {
00024         OLEDBGDATA_MAIN("SIMPSVR")
00025 }
00026
00027 CSimpSvrApp FAR * lpCSimpSvrApp;
00028 CClassFactory FAR * lpClassFactory;
00029
00030 //**********************************************************************
00031 //
00032 // WinMain
00033 //
00034 // Purpose:
00035 //
00036 //      Program entry point
00037 //
00038 // Parameters:
00039 //
00040 //      HANDLE hInstance        - Instance handle for this instance
00041 //
00042 //      HANDLE hPrevInstance    - Instance handle for the last instance
00043 //
00044 //      LPSTR lpCmdLine         - Pointer to the command line
00045 //
00046 //      int nCmdShow            - Window State
00047 //
00048 // Return Value:
00049 //
00050 //      msg.wParam
00051 //
00052 // Function Calls:
00053 //      Function                        Location
00054 //
00055 //      CSimpSvrApp::CSimpSvrApp          APP.CPP
00056 //      CSimpSvrApp::fInitApplication    APP.CPP
00057 //      CSimpSvrApp::fInitInstance       APP.CPP
00058 //      CSimpSvrApp::HandleAccelerators  APP.CPP
00059 //      CSimpSvrApp::~CSimpSvrApp         APP.CPP
00060 //      GetMessage                      Windows API
00061 //      TranslateMessage                Windows API
00062 //      DispatchMessage                 Windows API
00063 //
00064 // Comments:
00065 //
00066 //********************************************************************
00067
00068 int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
00069
00070 {
00071         MSG msg;
00072
00073         // recommended size for OLE apps
00074         SetMessageQueue(96);
00075
00076         lpCSimpSvrApp = new CSimpSvrApp;
00077
00078         lpCSimpSvrApp->AddRef();      // need the app ref. count at 1 to hold the
00079                                                                   // app alive.
00080
00081         lpCSimpSvrApp->ParseCmdLine(lpCmdLine);
00082
00083         // app initialization
00084         if (!hPrevInstance)
00085                 if (!lpCSimpSvrApp->fInitApplication(hInstance))
00086                         return (FALSE);
00087
00088         // instance initialization
00089         if (!lpCSimpSvrApp->fInitInstance(hInstance, nCmdShow, lpClassFactory))
00090                 return (FALSE);
00091
00092         /* Initialization required for OLE 2 UI library.  This call is
00093         **    needed ONLY if we are using the static link version of the UI
00094         **    library. If we are using the DLL version, we should NOT call
00095         **    this function in our application.
00096         */
00097 #if 0
00098         if (!OleUIInitialize(hInstance, hPrevInstance))
00099                 {
00100                 OleDbgOut("Could not initialize OLEUI library\n");
00101                 return FALSE;
00102                 }
00103 #endif
00104         // message loop
00105         while (GetMessage(&msg, NULL, NULL, NULL))
00106                 {
00107                 if (lpCSimpSvrApp->IsInPlaceActive())
00108
00109                         // Only key messages need to be sent to OleTranslateAccelerator.  Any other message
00110                         // would result in an extra FAR call to occur for that message processing...
00111
00112                         if ( (msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST) )
00113
00114                                 // OleTranslateAccelerator MUST be called, even though this application does
00115                                 // not have an accelerator table.  This has to be done in order for the
00116                                 // mneumonics for the top level menu items to work properly.
00117
00118                                 if ( OleTranslateAccelerator ( lpCSimpSvrApp->GetDoc()->GetObj()->GetInPlaceFrame(),
00119                                                                                            lpCSimpSvrApp->GetDoc()->GetObj()->GetFrameInfo(),
00120                                                                                            &msg) == NOERROR)
00121                                         continue;
00122
00123                 TranslateMessage(&msg);    /* Translates virtual key codes           */
00124                 DispatchMessage(&msg);     /* Dispatches message to window           */
00125                 }
00126
00127         // De-initialization for UI libraries.  Just like OleUIInitialize, this
00128         // funciton is needed ONLY if we are using the static link version of the
00129         // OLE UI library.
00130 #if 0
00131         OleUIUninitialize();
00132 #endif
00133
00134         return (msg.wParam);           /* Returns the value from PostQuitMessage */
00135 }
00136
00137
00138 //**********************************************************************
00139 //
00140 // MainWndProc
00141 //
00142 // Purpose:
00143 //
00144 //      Processes messages for the frame window
00145 //
00146 // Parameters:
00147 //
00148 //      HWND hWnd       - Window handle for frame window
00149 //
00150 //      UINT message    - Message value
00151 //
00152 //      WPARAM wParam   - Message info
00153 //
00154 //      LPARAM lParam   - Message info
00155 //
00156 // Return Value:
00157 //
00158 //      long
00159 //
00160 // Function Calls:
00161 //      Function                        Location
00162 //
00163 //      CSimpSvrApp::lCommandHandler     APP.CPP
00164 //      CSimpSvrApp::DestroyDocs         APP.CPP
00165 //      CSimpSvrApp::lCreateDoc          APP.CPP
00166 //      CSimpSvrApp::lSizeHandler        APP.CPP
00167 //      CGameDoc::lAddVerbs           DOC.CPP
00168 //      PostQuitMessage                 Windows API
00169 //      DefWindowProc                   Windows API
00170 //
00171 // Comments:
00172 //
00173 //********************************************************************
00174
00175 //@@WTK WIN32, UNICODE
00176 //long FAR PASCAL _export MainWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
00177 long FAR PASCAL EXPORT MainWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
00178
00179 {
00180
00181         switch (message)
00182                 {
00183                 case WM_CLOSE:
00184                         OutputDebugString("*** In WM_CLOSE *** \r\n");
00185
00186                         // if there is still a document
00187                         if (lpCSimpSvrApp->GetDoc())
00188
00189                                 // if there is still an object within a document
00190                                 if (lpCSimpSvrApp->GetDoc()->GetObj())   // this case occurs if there is still
00191                                                                                                                  // an outstanding Ref count on the object
00192                                                                                                                  // when the app is trying to go away.
00193                                                                                                                  // typically this case will occur in
00194                                                                                                                  // the "open" editing mode.
00195                                         //  Close the document
00196                                         lpCSimpSvrApp->GetDoc()->Close();
00197
00198                         // hide the app window
00199                         lpCSimpSvrApp->HideAppWnd();
00200
00201                         // if we were started by ole, unregister the class factory, otherwise
00202                         // remove the ref count on our dummy OLE object
00203                         if (lpCSimpSvrApp->IsStartedByOle())
00204                                 CoRevokeClassObject(lpCSimpSvrApp->GetRegisterClass());
00205                         else
00206                                 lpCSimpSvrApp->GetOleObject()->Release();
00207
00208                         lpCSimpSvrApp->Release();  // This should close the app.
00209
00210                         break;
00211
00212                 case WM_COMMAND:           // message: command from application menu
00213                         return lpCSimpSvrApp->lCommandHandler(hWnd, message, wParam, lParam);
00214                         break;
00215
00216                 case WM_CREATE:
00217                         return lpCSimpSvrApp->lCreateDoc(hWnd, message, wParam, lParam);
00218                         break;
00219
00220                 case WM_DESTROY:                  // message: window being destroyed
00221                         PostQuitMessage(0);
00222                         break;
00223
00224                 case WM_SIZE:
00225                         return lpCSimpSvrApp->lSizeHandler(hWnd, message, wParam, lParam);
00226
00227                 default:                          // Passes it on if unproccessed
00228                         return (DefWindowProc(hWnd, message, wParam, lParam));
00229                 }
00230                 return (NULL);
00231 }
00232
00233
00234 //**********************************************************************
00235 //
00236 // About
00237 //
00238 // Purpose:
00239 //
00240 //      Processes dialog box messages
00241 //
00242 // Parameters:
00243 //
00244 //      HWND hWnd       - Window handle for dialog box
00245 //
00246 //      UINT message    - Message value
00247 //
00248 //      WPARAM wParam   - Message info
00249 //
00250 //      LPARAM lParam   - Message info
00251 //
00252 // Return Value:
00253 //
00254 // Function Calls:
00255 //      Function                    Location
00256 //
00257 //      EndDialog                   Windows API
00258 //
00259 // Comments:
00260 //
00261 //********************************************************************
00262
00263 //@@WTK WIN32, UNICODE
00264 //BOOL FAR PASCAL _export About(HWND hDlg,unsigned message,WORD wParam,LONG lParam)
00265 BOOL FAR PASCAL EXPORT About(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
00266
00267 {
00268         switch (message) {
00269         case WM_INITDIALOG:                /* message: initialize dialog box */
00270                 return (TRUE);
00271
00272         case WM_COMMAND:                      /* message: received a command */
00273                 //@@WTK WIN32, UNICODE
00274                 //if (wParam == IDOK                /* "OK" box selected?          */
00275                 if (LOWORD(wParam) == IDOK                /* "OK" box selected?          */
00276                 || LOWORD(wParam) == IDCANCEL) {      /* System menu close command? */
00277                         EndDialog(hDlg, TRUE);        /* Exits the dialog box        */
00278                         return (TRUE);
00279                 }
00280                 break;
00281         }
00282         return (FALSE);                           /* Didn't process a message    */
00283 }
00284
00285 //**********************************************************************
00286 //
00287 // DocWndProc
00288 //
00289 // Purpose:
00290 //
00291 //      Processes dialog box messages
00292 //
00293 // Parameters:
00294 //
00295 //      HWND hWnd       - Window handle for doc window
00296 //
00297 //      UINT message    - Message value
00298 //
00299 //      WPARAM wParam   - Message info
00300 //
00301 //      LPARAM lParam   - Message info
00302 //
00303 // Return Value:
00304 //
00305 // Function Calls:
00306 //      Function                            Location
00307 //
00308 //      CSimpSvrApp::PaintApp                APP.CPP
00309 //      BeginPaint                          Windows API
00310 //      EndPaint                            Windows API
00311 //      DefWindowProc                       Windows API
00312 //      IOleObject::QueryInterface          Object
00313 //      IOleInPlaceObject::UIDeactivate     Object
00314 //      IOleObject::DoVerb                  Object
00315 //      IOleInPlaceObject::Release          Object
00316 //
00317 // Comments:
00318 //
00319 //********************************************************************
00320
00321 //@@WTK WIN32, UNICODE
00322 //long FAR PASCAL _export DocWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
00323 long FAR PASCAL EXPORT DocWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
00324 {
00325         HDC hDC;
00326         PAINTSTRUCT ps;
00327
00328         switch (message) {
00329                 case WM_COMMAND:           // message: command from application menu
00330                         return lpCSimpSvrApp->lCommandHandler(hWnd, message, wParam, lParam);
00331                         break;
00332
00333                 case WM_PAINT:
00334                         hDC = BeginPaint(hWnd, &ps);
00335
00336                         // tell the app class to paint itself
00337                         if (lpCSimpSvrApp)
00338                                 lpCSimpSvrApp->PaintApp (hDC);
00339
00340                         EndPaint(hWnd, &ps);
00341                         break;
00342
00343                 case WM_MENUSELECT:
00344                         lpCSimpSvrApp->SetStatusText();
00345                         break;
00346
00347         default:                          /* Passes it on if unproccessed    */
00348                 return (DefWindowProc(hWnd, message, wParam, lParam));
00349         }
00350         return (NULL);
00351 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcADO/adocomponent.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcADO

adocomponent.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: ADOComponent.h
00003 //
00004 // Description: Declaration of the CADOComponent
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022
00023 #ifndef __ADOCOMPONENT_H_
00024 #define __ADOCOMPONENT_H_
00025
00026 #include "resource.h"       // main symbols
00027 #include <comsvcs.h>
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CADOComponent
00031 class ATL_NO_VTABLE CADOComponent :
00032   public CComObjectRootEx<CComSingleThreadModel>,
00033   public CComCoClass<CADOComponent, &CLSID_ADOComponent>,
00034   public IObjectControl,
00035   public IDispatchImpl<IADOComponent, &IID_IADOComponent, &LIBID_ADOKBLib>
00036 {
00037 public:
00038   CADOComponent()
00039   {
00040   }
00041
00042 DECLARE_REGISTRY_RESOURCEID(IDR_ADOCOMPONENT)
00043 DECLARE_NOT_AGGREGATABLE(CADOComponent)
00044
00045 BEGIN_COM_MAP(CADOComponent)
00046   COM_INTERFACE_ENTRY(IADOComponent)
00047   COM_INTERFACE_ENTRY(IObjectControl)
00048   COM_INTERFACE_ENTRY(IDispatch)
00049 END_COM_MAP()
00050
00051 // IObjectControl
00052 public:
00053   STDMETHOD(Activate)();
00054   STDMETHOD_(BOOL, CanBePooled)();
00055   STDMETHOD_(void, Deactivate)();
00056
00057   CComPtr<IObjectContext> m_spObjectContext;
00058
00059 // IADOComponent
00060 public:
00061   STDMETHOD(SimpleQuery)(/*[in, out]*/ VARIANT * returnval);
00062 };
00063
00064 #endif //__ADOCOMPONENT_H_
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/Msi/setup.exe/setupui.h Source File

  • SysMgmt
  • Msi
  • setup.exe

setupui.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved.
00004 //
00005 //  File:       setupui.h
00006 //
00007 //--------------------------------------------------------------------------
00008
00009 #ifndef _SETUPUI_H_3E24CC91_BC41_4182_BEBA_785BBB28B677_
00010 #define _SETUPUI_H_3E24CC91_BC41_4182_BEBA_785BBB28B677_
00011
00012 #include <windows.h>
00013 #include <urlmon.h>
00014
00015 /*---------------------------------------------------------------------------
00016  *
00017  * Constants
00018  *
00019  ---------------------------------------------------------------------------*/
00020 #define MAX_STR_CAPTION 256
00021
00022 /*---------------------------------------------------------------------------
00023  *
00024  * Enums
00025  *
00026  ---------------------------------------------------------------------------*/
00027 enum irmProgress // progress dialog return messages
00028 {
00029     irmNotInitialized = -1, // dialog was not initialized
00030     irmOK             =  0, // ok
00031     irmCancel         =  1, // user depressed cancel button
00032 };
00033
00034 /*---------------------------------------------------------------------------
00035  *
00036  * CDownloadUI class
00037  *
00038  ---------------------------------------------------------------------------*/
00039 class CDownloadUI
00040 {
00041 public:
00042      CDownloadUI();
00043      ~CDownloadUI();
00044
00045     bool Initialize(HINSTANCE hInst, HWND hwndParent, LPCSTR szCaption);
00046     bool Terminate();
00047     HWND GetCurrentWindow();
00048     bool HasUserCanceled();
00049     void SetUserCancel();
00050     void InitProgressBar(ULONG ulProgressMax);
00051     void IncrementProgressBar(ULONG ulProgress);
00052
00053     irmProgress SetBannerText(LPCSTR szBanner);
00054     irmProgress SetActionText(LPCSTR szAction);
00055
00056 private:
00057     HINSTANCE m_hInst;  // handle to instance containing resources
00058
00059     HWND  m_hwndProgress;    // handle to progress dialog
00060     HWND  m_hwndParent;      // handle to parent window
00061     char  m_szCaption[MAX_STR_CAPTION]; // caption
00062     bool  m_fInitialized;    // whether dialog has been initialized
00063     bool  m_fUserCancel;     // whether user has chosen to cancel
00064     ULONG m_ulProgressMax;   // maximum number of ticks on progress bar
00065     ULONG m_ulProgressSoFar; // current progress
00066 };
00067
00068 /*---------------------------------------------------------------------------
00069  *
00070  * CDownloadBindStatusCallback class
00071  *
00072  ---------------------------------------------------------------------------*/
00073
00074 class CDownloadBindStatusCallback : public IBindStatusCallback
00075 {
00076  public: // IUnknown implemented virtual functions
00077      HRESULT         __stdcall QueryInterface(const IID& riid, void** ppvObj);
00078      unsigned long   __stdcall AddRef();
00079      unsigned long   __stdcall Release();
00080  public: // IBindStatusCallback implemented virtual functions
00081      CDownloadBindStatusCallback(CDownloadUI* piDownloadUI);
00082     ~CDownloadBindStatusCallback();
00083
00084     HRESULT __stdcall OnStartBinding(DWORD, IBinding*) {return S_OK;}
00085     HRESULT __stdcall GetPriority(LONG*) {return S_OK;}
00086     HRESULT __stdcall OnLowResource(DWORD ) {return S_OK;}
00087     HRESULT __stdcall OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText);
00088     HRESULT __stdcall OnStopBinding(HRESULT, LPCWSTR ) {return S_OK;}
00089     HRESULT __stdcall GetBindInfo(DWORD*, BINDINFO*) {return S_OK;}
00090     HRESULT __stdcall OnDataAvailable(DWORD, DWORD, FORMATETC*, STGMEDIUM*) {return S_OK;}
00091     HRESULT __stdcall OnObjectAvailable(REFIID, IUnknown*) {return S_OK;}
00092  private:
00093     CDownloadUI* m_pDownloadUI; // pointer to actual UI
00094     int          m_iRefCnt;
00095     ULONG        m_ulProgressSoFar;
00096 };
00097
00098 #endif //_SETUPUI_H_3E24CC91_BC41_4182_BEBA_785BBB28B677_
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/unicode.h Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

unicode.h

Go to the documentation of this file.
00001 //
00002 // unicode.h
00003 //
00004 // Header file that forcibly turns on a unicode compile
00005 //
00006
00007 #ifndef UNICODE
00008 #define UNICODE
00009 #endif
00010
00011 #ifndef _UNICODE
00012 #define _UNICODE
00013 #endif
00014
00015 #undef MBCS
00016 #undef _MBCS
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/DiskQuota/DskQuota.Cpp Source File

  • WinBase
  • IO
  • DiskQuota

DskQuota.Cpp

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 DskQuota.cpp
00011
00012 Description:
00013 Main module. Makes sure the COM subsystem is initialized and the
00014 disk quota control COM object is initialized before printing out the main
00015 menu.
00016 ----------------------------------------------------------------------------*/
00017
00018 #define WIN32_LEAN_AND_MEAN
00019
00020 #include <windows.h>
00021 #include <stdio.h>
00022 #define INITGUIDS
00023 #include <dskquota.h>
00024 #include "ProcessMenu.h"
00025 #include "PrintMenu.h"
00026 #include "Commands.h"
00027
00028 /*-----------------------------------------------------------------------------
00029 wmain(int argc, WCHAR* argv[])
00030     Initilizes COM, initializes the IDiskQuotaControl
00031
00032 Parameters
00033     argc - The number of command line parameters
00034     argv[] - Array of command line parameters
00035
00036 Return Value
00037     0 - Program terminated with an error
00038     1 - Program terminated normally
00039 -----------------------------------------------------------------------------*/
00040 extern "C"
00041 int wmain(int argc, WCHAR* argv[])
00042 {
00043     HRESULT hr;
00044
00045     // Get command line parameters
00046     if (argc != 2)
00047     {
00048         wprintf(L"\nUsage: %s <Path of Root Directory>\n", argv[0]);
00049         return 0;
00050     }
00051
00052     // Initialize COM
00053     hr = CoInitialize(NULL);
00054
00055     if (SUCCEEDED(hr))
00056     {
00057         IDiskQuotaControl* lpDiskQuotaControl;
00058
00059         // Create an instance of the disk quota control
00060         hr = CoCreateInstance(CLSID_DiskQuotaControl,
00061                               NULL,
00062                               CLSCTX_INPROC_SERVER,
00063                               IID_IDiskQuotaControl,
00064                               (LPVOID*)&lpDiskQuotaControl);
00065         if (SUCCEEDED(hr))
00066         {
00067             // Initialize IDiskQuotaControl
00068             hr = lpDiskQuotaControl->Initialize(argv[1], TRUE);
00069
00070             if (SUCCEEDED(hr))
00071             {
00072                 // Print main menu stuff
00073                 while (ProcessMainMenu(PrintMainMenu(), lpDiskQuotaControl));
00074             }
00075
00076             // Release the IDiskQuotaControl COM object and Uninitialize COM
00077             lpDiskQuotaControl->Release();
00078         }
00079         CoUninitialize();
00080     }
00081
00082     if (FAILED(hr)) PrintError(hr);
00083
00084     return SUCCEEDED(hr) ? 1 : 0;
00085 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CClipBookServerParamsPage Member List

This is the complete list of members for CClipBookServerParamsPage, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
BAllRequiredFieldsPresent(void) const | CClipBookServerParamsPage | [protected]
BApplyChanges(void) | CBasePropertyPage | [protected, virtual]
BApplyChanges(void) | CBasePropertyPage | [protected, virtual]
BBackPressed(void) const | CBasePropertyPage | [inline, protected]
BBackPressed(void) const | CBasePropertyPage | [inline, protected]
BBuildPropList(CClusPropList &rcplInout, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected, virtual]
BBuildPropList(CClusPropList &rcplInout, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected, virtual]
BSaved(void) const | CBasePropertyPage | [inline, protected]
BSaved(void) const | CBasePropertyPage | [inline, protected]
BSetPrivateProps(BOOL fValidateOnlyIn=FALSE, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected]
BSetPrivateProps(BOOL fValidateOnlyIn=FALSE, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected]
BWizard(void) const | CBasePropertyPage | [inline, protected]
BWizard(void) const | CBasePropertyPage | [inline, protected]
CBasePropertyPage(void) | CBasePropertyPage |
CBasePropertyPage(UINT nIDTemplateIn, UINT nIDCaptionIn=0) | CBasePropertyPage |
CBasePropertyPage(void) | CBasePropertyPage |
CBasePropertyPage(UINT nIDTemplateIn, UINT nIDCaptionIn=0) | CBasePropertyPage |
CClipBookServerParamsPage(void) | CClipBookServerParamsPage |
CommonConstruct(void) | CBasePropertyPage | [protected]
CommonConstruct(void) | CBasePropertyPage | [protected]
Cot(void) const | CBasePropertyPage | [inline]
Cot(void) const | CBasePropertyPage | [inline]
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
Cprops(void) const | CClipBookServerParamsPage | [inline, protected, virtual]
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
DisplaySetPropsError(DWORD scIn, UINT idsOperIn) const | CBasePropertyPage | [protected, virtual]
DisplaySetPropsError(DWORD scIn, UINT idsOperIn) const | CBasePropertyPage | [protected, virtual]
DoDataExchange(CDataExchange *pDX) | CClipBookServerParamsPage | [protected, virtual]
EnableNext(BOOL fEnableIn=TRUE) | CBasePropertyPage | [protected]
EnableNext(BOOL fEnableIn=TRUE) | CBasePropertyPage | [protected]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [virtual]
Hcluster(void) const | CBasePropertyPage | [inline, protected]
Hcluster(void) const | CBasePropertyPage | [inline, protected]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
Hpage(void) const | CBasePropertyPage | [inline]
Hpage(void) const | CBasePropertyPage | [inline]
HrCreatePage(void) | CBasePropertyPage |
HrCreatePage(void) | CBasePropertyPage |
HrInit(CExtObject *peoInout) | CBasePropertyPage | [virtual]
HrInit(CExtObject *peoInout) | CBasePropertyPage | [virtual]
IDD enum value | CClipBookServerParamsPage |
IddPropertyPage(void) const | CBasePropertyPage | [inline, protected]
IddPropertyPage(void) const | CBasePropertyPage | [inline, protected]
IddWizardPage(void) const | CBasePropertyPage | [inline, protected]
IddWizardPage(void) const | CBasePropertyPage | [inline, protected]
IdsCaption(void) const | CBasePropertyPage | [inline, protected]
IdsCaption(void) const | CBasePropertyPage | [inline, protected]
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_bBackPressed | CBasePropertyPage | [protected]
m_bDoDetach | CBasePropertyPage | [protected]
m_bSaved | CBasePropertyPage | [protected]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hpage | CBasePropertyPage | [protected]
m_hWnd | CPropertyPage | [protected]
m_iddPropertyPage | CBasePropertyPage | [protected]
m_iddWizardPage | CBasePropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_idsCaption | CBasePropertyPage | [protected]
m_peo | CBasePropertyPage | [protected]
m_pIPropertyPageSite | CPropertyPage | [protected]
m_staticIcon | CBasePropertyPage |
m_staticTitle | CBasePropertyPage |
m_strTitle | CBasePropertyPage |
Move(LPCRECT pRect) | CPropertyPage |
OnApply() | CBasePropertyPage | [virtual]
OnApply() | CBasePropertyPage | [virtual]
OnChangeCtrl() | CBasePropertyPage | [protected]
OnChangeCtrl() | CBasePropertyPage | [protected]
OnChangeRequiredField() | CClipBookServerParamsPage | [protected]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CBasePropertyPage | [protected]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CBasePropertyPage | [protected]
OnDestroy() | CBasePropertyPage | [protected]
OnDestroy() | CBasePropertyPage | [protected]
OnInitDialog() | CClipBookServerParamsPage | [protected, virtual]
OnSetActive() | CClipBookServerParamsPage | [virtual]
OnWizardBack() | CBasePropertyPage | [virtual]
OnWizardBack() | CBasePropertyPage | [virtual]
OnWizardFinish() | CBasePropertyPage | [virtual]
OnWizardFinish() | CBasePropertyPage | [virtual]
OnWizardNext() | CBasePropertyPage | [virtual]
OnWizardNext() | CBasePropertyPage | [virtual]
Peo(void) const | CBasePropertyPage | [inline, protected]
Peo(void) const | CBasePropertyPage | [inline, protected]
PiWizardCallback(void) const | CBasePropertyPage | [inline, protected]
PiWizardCallback(void) const | CBasePropertyPage | [inline, protected]
Pprops(void) const | CClipBookServerParamsPage | [inline, protected, virtual]
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
ScParseProperties(CClusPropList &rcplIn) | CBasePropertyPage | [protected]
ScParseProperties(CClusPropList &rcplIn) | CBasePropertyPage | [protected]
ScParseUnknownProperty(LPCWSTR pwszNameIn, const CLUSPROP_BUFFER_HELPER &rvalueIn, DWORD cbBufIn) | CBasePropertyPage | [inline, protected, virtual]
ScParseUnknownProperty(LPCWSTR pwszNameIn, const CLUSPROP_BUFFER_HELPER &rvalueIn, DWORD cbBufIn) | CBasePropertyPage | [inline, protected, virtual]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
~CBasePropertyPage(void) | CBasePropertyPage | [inline, virtual]
~CBasePropertyPage(void) | CBasePropertyPage | [inline, virtual]
~CPropertyPage() | CPropertyPage | [virtual]
Generated on Wed Nov 13 2024 16:55:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

igmp_group_record_v3 Member List

This is the complete list of members for igmp_group_record_v3, including all inherited members.
aux_data_len | igmp_group_record_v3
group_addr | igmp_group_record_v3
num_sources | igmp_group_record_v3
source_addr | igmp_group_record_v3
type | igmp_group_record_v3
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/GINA/GinaStub/GinaStub.c Source File

  • Security
  • GINA
  • GinaStub

GinaStub.c

Go to the documentation of this file.
00001 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002
00003  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00004  EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00005  WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00006
00007  Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009  Module:   Ginastub.c
00010
00011  Abstract: See ReadMe.txt for more detail information about this sample.
00012
00013  Revision: August 2, 1999.
00014
00015 -------------------------------------------------------------------------------*/
00016
00017 #define _WIN32_WINNT 0x0400
00018
00019 #include <windows.h>
00020 #include <winwlx.h>
00021
00022 #include "Ginastub.h"
00023
00024 //
00025 // Location of the real MSGINA.
00026 //
00027
00028 #define REALGINA_PATH      TEXT("MSGINA.DLL")
00029 #define GINASTUB_VERSION   (WLX_VERSION_1_3) // Highest version supported at
00030                                              // this point. Remember to modify
00031                                              // this as support for newer version
00032                                              // is added to this program.
00033 //
00034 // Winlogon function dispatch table.
00035 //
00036 PVOID g_pWinlogon;
00037
00038 //
00039 // Pointers to the real MSGINA functions.
00040 //
00041
00042 PFWLXNEGOTIATE                pfWlxNegotiate;
00043 PFWLXINITIALIZE               pfWlxInitialize;
00044 PFWLXDISPLAYSASNOTICE         pfWlxDisplaySASNotice;
00045 PFWLXLOGGEDOUTSAS             pfWlxLoggedOutSAS;
00046 PFWLXACTIVATEUSERSHELL        pfWlxActivateUserShell;
00047 PFWLXLOGGEDONSAS              pfWlxLoggedOnSAS;
00048 PFWLXDISPLAYLOCKEDNOTICE      pfWlxDisplayLockedNotice;
00049 PFWLXWKSTALOCKEDSAS           pfWlxWkstaLockedSAS;
00050 PFWLXISLOCKOK                 pfWlxIsLockOk;
00051 PFWLXISLOGOFFOK               pfWlxIsLogoffOk;
00052 PFWLXLOGOFF                   pfWlxLogoff;
00053 PFWLXSHUTDOWN                 pfWlxShutdown;
00054
00055 //
00056 // New for version 1.1
00057 //
00058
00059 PFWLXSTARTAPPLICATION         pfWlxStartApplication  = NULL;
00060 PFWLXSCREENSAVERNOTIFY        pfWlxScreenSaverNotify = NULL;
00061
00062 //
00063 // New for version 1.2 - No new GINA interface was added, except
00064 //                       a new function in the dispatch table.
00065 //
00066
00067 //
00068 // New for version 1.3
00069 //
00070
00071 PFWLXNETWORKPROVIDERLOAD      pfWlxNetworkProviderLoad  = NULL;
00072 PFWLXDISPLAYSTATUSMESSAGE     pfWlxDisplayStatusMessage = NULL;
00073 PFWLXGETSTATUSMESSAGE         pfWlxGetStatusMessage     = NULL;
00074 PFWLXREMOVESTATUSMESSAGE      pfWlxRemoveStatusMessage  = NULL;
00075
00076
00077 //
00078 // Hook into the real MSGINA.
00079 //
00080
00081 BOOL MyInitialize (HINSTANCE hDll, DWORD dwWlxVersion)
00082 {
00083    //
00084    // Get pointers to all of the WLX functions in the real MSGINA.
00085    //
00086    pfWlxInitialize =
00087       (PFWLXINITIALIZE) GetProcAddress(hDll, "WlxInitialize");
00088    if (!pfWlxInitialize)
00089    {
00090       return FALSE;
00091    }
00092
00093    pfWlxDisplaySASNotice =
00094       (PFWLXDISPLAYSASNOTICE) GetProcAddress(hDll, "WlxDisplaySASNotice");
00095    if (!pfWlxDisplaySASNotice)
00096    {
00097       return FALSE;
00098    }
00099
00100    pfWlxLoggedOutSAS =
00101       (PFWLXLOGGEDOUTSAS) GetProcAddress(hDll, "WlxLoggedOutSAS");
00102    if (!pfWlxLoggedOutSAS)
00103    {
00104       return FALSE;
00105    }
00106
00107    pfWlxActivateUserShell =
00108       (PFWLXACTIVATEUSERSHELL) GetProcAddress(hDll, "WlxActivateUserShell");
00109    if (!pfWlxActivateUserShell)
00110    {
00111       return FALSE;
00112    }
00113
00114    pfWlxLoggedOnSAS =
00115       (PFWLXLOGGEDONSAS) GetProcAddress(hDll, "WlxLoggedOnSAS");
00116    if (!pfWlxLoggedOnSAS)
00117    {
00118       return FALSE;
00119    }
00120
00121    pfWlxDisplayLockedNotice =
00122       (PFWLXDISPLAYLOCKEDNOTICE) GetProcAddress(hDll, "WlxDisplayLockedNotice");
00123    if (!pfWlxDisplayLockedNotice)
00124    {
00125       return FALSE;
00126    }
00127
00128    pfWlxIsLockOk =
00129       (PFWLXISLOCKOK) GetProcAddress(hDll, "WlxIsLockOk");
00130    if (!pfWlxIsLockOk)
00131    {
00132       return FALSE;
00133    }
00134
00135    pfWlxWkstaLockedSAS =
00136        (PFWLXWKSTALOCKEDSAS) GetProcAddress(hDll, "WlxWkstaLockedSAS");
00137    if (!pfWlxWkstaLockedSAS)
00138    {
00139       return FALSE;
00140    }
00141
00142    pfWlxIsLogoffOk =
00143       (PFWLXISLOGOFFOK) GetProcAddress(hDll, "WlxIsLogoffOk");
00144    if (!pfWlxIsLogoffOk)
00145    {
00146       return FALSE;
00147    }
00148
00149    pfWlxLogoff =
00150       (PFWLXLOGOFF) GetProcAddress(hDll, "WlxLogoff");
00151    if (!pfWlxLogoff)
00152    {
00153       return FALSE;
00154    }
00155
00156    pfWlxShutdown =
00157       (PFWLXSHUTDOWN) GetProcAddress(hDll, "WlxShutdown");
00158    if (!pfWlxShutdown)
00159    {
00160       return FALSE;
00161    }
00162
00163    //
00164    // Load functions for version 1.1 as necessary.
00165    //
00166    if (dwWlxVersion > WLX_VERSION_1_0)
00167    {
00168       pfWlxStartApplication =
00169          (PFWLXSTARTAPPLICATION) GetProcAddress(hDll, "WlxStartApplication");
00170       if (!pfWlxStartApplication)
00171       {
00172          return FALSE;
00173       }
00174
00175       pfWlxScreenSaverNotify =
00176          (PFWLXSCREENSAVERNOTIFY) GetProcAddress(hDll, "WlxScreenSaverNotify");
00177       if (!pfWlxScreenSaverNotify)
00178       {
00179          return FALSE;
00180       }
00181    }
00182
00183    //
00184    // Load functions for version 1.3 as necessary.
00185    //
00186    if (dwWlxVersion > WLX_VERSION_1_2)
00187    {
00188       pfWlxNetworkProviderLoad =
00189          (PFWLXNETWORKPROVIDERLOAD)
00190             GetProcAddress(hDll, "WlxNetworkProviderLoad");
00191       if (!pfWlxNetworkProviderLoad)
00192       {
00193          return FALSE;
00194       }
00195
00196       pfWlxDisplayStatusMessage =
00197          (PFWLXDISPLAYSTATUSMESSAGE)
00198             GetProcAddress(hDll, "WlxDisplayStatusMessage");
00199       if (!pfWlxDisplayStatusMessage)
00200       {
00201          return FALSE;
00202       }
00203
00204       pfWlxGetStatusMessage =
00205          (PFWLXGETSTATUSMESSAGE)
00206             GetProcAddress(hDll, "WlxGetStatusMessage");
00207       if (!pfWlxGetStatusMessage)
00208       {
00209          return FALSE;
00210       }
00211
00212       pfWlxRemoveStatusMessage =
00213          (PFWLXREMOVESTATUSMESSAGE)
00214             GetProcAddress(hDll, "WlxRemoveStatusMessage");
00215       if (!pfWlxRemoveStatusMessage)
00216       {
00217          return FALSE;
00218       }
00219    }
00220
00221    //
00222    // Load functions for newer version here...
00223    //
00224
00225    //
00226    // Everything loaded OK.
00227    //
00228    return TRUE;
00229 }
00230
00231
00232 BOOL
00233 WINAPI
00234 WlxNegotiate (DWORD   dwWinlogonVersion,
00235               DWORD * pdwDllVersion)
00236 {
00237    HINSTANCE hDll;
00238    DWORD dwWlxVersion = GINASTUB_VERSION;
00239
00240    //
00241    // Load MSGINA.DLL.
00242    //
00243    if (!(hDll = LoadLibrary(REALGINA_PATH)))
00244    {
00245       return FALSE;
00246    }
00247
00248    //
00249    // Get pointers to WlxNegotiate function in the real MSGINA.
00250    //
00251    pfWlxNegotiate = (PFWLXNEGOTIATE) GetProcAddress(hDll, "WlxNegotiate");
00252    if (!pfWlxNegotiate)
00253    {
00254       return FALSE;
00255    }
00256
00257    //
00258    // Handle older version of Winlogon.
00259    //
00260    if (dwWinlogonVersion < dwWlxVersion)
00261    {
00262       dwWlxVersion = dwWinlogonVersion;
00263    }
00264
00265    //
00266    // Negotiate with MSGINA for version that we can support.
00267    //
00268    if (!pfWlxNegotiate(dwWlxVersion, &dwWlxVersion))
00269    {
00270       return FALSE;
00271    }
00272
00273    //
00274    // Load the rest of the WLX functions from the real MSGINA.
00275    //
00276    if (!MyInitialize(hDll, dwWlxVersion))
00277    {
00278       return FALSE;
00279    }
00280
00281    //
00282    // Inform Winlogon which version to use.
00283    //
00284    *pdwDllVersion = dwWlxVersion;
00285
00286    return TRUE;
00287 }
00288
00289
00290 BOOL
00291 WINAPI
00292 WlxInitialize (LPWSTR  lpWinsta,
00293                HANDLE  hWlx,
00294                PVOID   pvReserved,
00295                PVOID   pWinlogonFunctions,
00296                PVOID * pWlxContext)
00297 {
00298
00299    //
00300    // Save pointer to dispatch table.
00301    //
00302    // Note that g_pWinlogon will need to be properly casted to the
00303    // appropriate version when used to call function in the dispatch
00304    // table.
00305    //
00306    // For example, assuming we are at WLX_VERSION_1_3, we would call
00307    // WlxSasNotify() as follows:
00308    //
00309    // ((PWLX_DISPATCH_VERSION_1_3) g_pWinlogon)->WlxSasNotify(hWlx, MY_SAS);
00310    //
00311    g_pWinlogon = pWinlogonFunctions;
00312
00313    return pfWlxInitialize(lpWinsta,
00314                           hWlx,
00315                           pvReserved,
00316                           pWinlogonFunctions,
00317                           pWlxContext);
00318 }
00319
00320
00321 VOID
00322 WINAPI
00323 WlxDisplaySASNotice (PVOID pWlxContext)
00324 {
00325    pfWlxDisplaySASNotice(pWlxContext);
00326 }
00327
00328
00329 int
00330 WINAPI
00331 WlxLoggedOutSAS (PVOID                pWlxContext,
00332                  DWORD                dwSasType,
00333                  PLUID                pAuthenticationId,
00334                  PSID                 pLogonSid,
00335                  PDWORD               pdwOptions,
00336                  PHANDLE              phToken,
00337                  PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
00338                  PVOID *              pProfile)
00339 {
00340    int iRet;
00341
00342    iRet = pfWlxLoggedOutSAS(pWlxContext,
00343                             dwSasType,
00344                             pAuthenticationId,
00345                             pLogonSid,
00346                             pdwOptions,
00347                             phToken,
00348                             pMprNotifyInfo,
00349                             pProfile);
00350
00351    if(iRet == WLX_SAS_ACTION_LOGON)
00352    {
00353       //
00354       // Copy pMprNotifyInfo and pLogonSid for later use.
00355       //
00356
00357       // pMprNotifyInfo->pszUserName
00358       // pMprNotifyInfo->pszDomain
00359       // pMprNotifyInfo->pszPassword
00360       // pMprNotifyInfo->pszOldPassword
00361    }
00362
00363    return iRet;
00364 }
00365
00366
00367 BOOL
00368 WINAPI
00369 WlxActivateUserShell (PVOID pWlxContext,
00370                       PWSTR pszDesktopName,
00371                       PWSTR pszMprLogonScript,
00372                       PVOID pEnvironment)
00373 {
00374    return pfWlxActivateUserShell(pWlxContext,
00375                                  pszDesktopName,
00376                                  pszMprLogonScript,
00377                                  pEnvironment);
00378 }
00379
00380
00381 int
00382 WINAPI
00383 WlxLoggedOnSAS (PVOID pWlxContext,
00384                 DWORD dwSasType,
00385                 PVOID pReserved)
00386 {
00387    return pfWlxLoggedOnSAS(pWlxContext,
00388                            dwSasType,
00389                            pReserved);
00390 }
00391
00392
00393 VOID
00394 WINAPI
00395 WlxDisplayLockedNotice (PVOID pWlxContext)
00396 {
00397    pfWlxDisplayLockedNotice(pWlxContext);
00398 }
00399
00400
00401 BOOL
00402 WINAPI
00403 WlxIsLockOk (PVOID pWlxContext)
00404 {
00405    return pfWlxIsLockOk(pWlxContext);
00406 }
00407
00408
00409 int
00410 WINAPI
00411 WlxWkstaLockedSAS (PVOID pWlxContext,
00412                    DWORD dwSasType)
00413 {
00414    return pfWlxWkstaLockedSAS(pWlxContext, dwSasType);
00415 }
00416
00417
00418 BOOL
00419 WINAPI
00420 WlxIsLogoffOk (PVOID pWlxContext)
00421 {
00422    BOOL bSuccess;
00423
00424    bSuccess = pfWlxIsLogoffOk(pWlxContext);
00425
00426    if(bSuccess)
00427    {
00428       //
00429       // If it's OK to logoff, make sure stored credentials are cleaned up.
00430       //
00431    }
00432
00433    return bSuccess;
00434 }
00435
00436
00437 VOID
00438 WINAPI
00439 WlxLogoff (PVOID pWlxContext)
00440 {
00441    pfWlxLogoff(pWlxContext);
00442 }
00443
00444
00445 VOID
00446 WINAPI
00447 WlxShutdown(PVOID pWlxContext,
00448             DWORD ShutdownType)
00449 {
00450    pfWlxShutdown(pWlxContext, ShutdownType);
00451 }
00452
00453
00454 //
00455 // New for version 1.1
00456 //
00457
00458 BOOL
00459 WINAPI
00460 WlxScreenSaverNotify (PVOID  pWlxContext,
00461                       BOOL * pSecure)
00462 {
00463    return pfWlxScreenSaverNotify(pWlxContext, pSecure);
00464 }
00465
00466 BOOL
00467 WINAPI
00468 WlxStartApplication (PVOID pWlxContext,
00469                      PWSTR pszDesktopName,
00470                      PVOID pEnvironment,
00471                      PWSTR pszCmdLine)
00472 {
00473    return pfWlxStartApplication(pWlxContext,
00474                                 pszDesktopName,
00475                                 pEnvironment,
00476                                 pszCmdLine);
00477 }
00478
00479
00480 //
00481 // New for version 1.3
00482 //
00483
00484 BOOL
00485 WINAPI
00486 WlxNetworkProviderLoad (PVOID                pWlxContext,
00487                         PWLX_MPR_NOTIFY_INFO pNprNotifyInfo)
00488 {
00489    return pfWlxNetworkProviderLoad(pWlxContext, pNprNotifyInfo);
00490 }
00491
00492
00493 BOOL
00494 WINAPI
00495 WlxDisplayStatusMessage (PVOID pWlxContext,
00496                          HDESK hDesktop,
00497                          DWORD dwOptions,
00498                          PWSTR pTitle,
00499                          PWSTR pMessage)
00500 {
00501    return pfWlxDisplayStatusMessage(pWlxContext,
00502                                     hDesktop,
00503                                     dwOptions,
00504                                     pTitle,
00505                                     pMessage);
00506 }
00507
00508
00509 BOOL
00510 WINAPI
00511 WlxGetStatusMessage (PVOID   pWlxContext,
00512                      DWORD * pdwOptions,
00513                      PWSTR   pMessage,
00514                      DWORD   dwBufferSize)
00515 {
00516    return pfWlxGetStatusMessage(pWlxContext,
00517                                 pdwOptions,
00518                                 pMessage,
00519                                 dwBufferSize);
00520 }
00521
00522
00523 BOOL
00524 WINAPI
00525 WlxRemoveStatusMessage (PVOID pWlxContext)
00526 {
00527    return pfWlxRemoveStatusMessage(pWlxContext);
00528 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Parameter Member List

This is the complete list of members for msado15::Parameter, including all inherited members.
AppendChunk(Variant Val) | msado15::Parameter |
clsid | msado15::Parameter | [static]
getAttributes() | msado15::Parameter |
getDirection() | msado15::Parameter |
getName() | msado15::Parameter |
getNumericScale() | msado15::Parameter |
getPrecision() | msado15::Parameter |
getProperties() | msado15::Parameter |
getSize() | msado15::Parameter |
getType() | msado15::Parameter |
getValue() | msado15::Parameter |
iid | msado15::Parameter | [static]
setAttributes(int plParmAttribs) | msado15::Parameter |
setDirection(int plParmDirection) | msado15::Parameter |
setName(String pbstr) | msado15::Parameter |
setNumericScale(byte pbScale) | msado15::Parameter |
setPrecision(byte pbPrecision) | msado15::Parameter |
setSize(int pl) | msado15::Parameter |
setType(int psDataType) | msado15::Parameter |
setValue(Variant pvar) | msado15::Parameter |
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/ResProp.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

ResProp.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ResProp.cpp
00007 //
00008 //  Description:
00009 //      Implementation of the resource extension property page classes.
00010 //
00011 //  Author:
00012 //      <name> (<e-mail name>) Mmmm DD, 2003
00013 //
00014 //  Revision History:
00015 //
00016 //  Notes:
00017 //
00018 /////////////////////////////////////////////////////////////////////////////
00019
00020 #include "stdafx.h"
00021 #include "File Share SampleEx.h"
00022 #include "ResProp.h"
00023 #include "ExtObj.h"
00024 #include "DDxDDv.h"
00025
00026 #ifdef _DEBUG
00027 #define new DEBUG_NEW
00028 #undef THIS_FILE
00029 static char THIS_FILE[] = __FILE__;
00030 #endif
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 // CFileShareSampleParamsPage property page
00034 /////////////////////////////////////////////////////////////////////////////
00035
00036 IMPLEMENT_DYNCREATE( CFileShareSampleParamsPage, CBasePropertyPage )
00037
00038 /////////////////////////////////////////////////////////////////////////////
00039 // Message Maps
00040
00041 BEGIN_MESSAGE_MAP( CFileShareSampleParamsPage, CBasePropertyPage )
00042     //{{AFX_MSG_MAP(CFileShareSampleParamsPage)
00043     ON_EN_CHANGE( IDC_PP_FILESHARESAMPLE_SHARENAME, OnChangeRequiredField )
00044     ON_EN_CHANGE( IDC_PP_FILESHARESAMPLE_PATH, OnChangeRequiredField )
00045     //}}AFX_MSG_MAP
00046
00047     //
00048     //  TODO: Modify the following lines to represent the data displayed on this page.
00049     //
00050
00051     ON_EN_CHANGE( IDC_PP_FILESHARESAMPLE_REMARK, CBasePropertyPage::OnChangeCtrl )
00052     ON_EN_CHANGE( IDC_PP_FILESHARESAMPLE_MAXUSERS, CBasePropertyPage::OnChangeCtrl )
00053 END_MESSAGE_MAP()
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 //++
00057 //
00058 //  CFileShareSampleParamsPage::CFileShareSampleParamsPage
00059 //
00060 //  Description:
00061 //      Default constructor.
00062 //
00063 //  Arguments:
00064 //      None.
00065 //
00066 //  Return Value:
00067 //      None.
00068 //
00069 //--
00070 /////////////////////////////////////////////////////////////////////////////
00071 CFileShareSampleParamsPage::CFileShareSampleParamsPage( void )
00072     : CBasePropertyPage( CFileShareSampleParamsPage::IDD )
00073 {
00074     //
00075     //  TODO: Modify the following lines to represent the data displayed on this page.
00076     //
00077
00078     //{{AFX_DATA_INIT(CFileShareSampleParamsPage)
00079     m_strShareName = _T("");
00080     m_strPath = _T("");
00081     m_strRemark = _T("");
00082     m_nMaxUsers = static_cast< DWORD >( 4294967295 );
00083     //}}AFX_DATA_INIT
00084
00085     // Setup the property array.
00086     {
00087         m_rgProps[ epropShareName ].Set( REGPARAM_FILESHARESAMPLE_SHARENAME, m_strShareName, m_strPrevShareName );
00088         m_rgProps[ epropPath ].SetExpandSz( REGPARAM_FILESHARESAMPLE_PATH, m_strPath, m_strPrevPath );
00089         m_rgProps[ epropRemark ].Set( REGPARAM_FILESHARESAMPLE_REMARK, m_strRemark, m_strPrevRemark );
00090         m_rgProps[ epropMaxUsers ].Set( REGPARAM_FILESHARESAMPLE_MAXUSERS, m_nMaxUsers, m_nPrevMaxUsers );
00091     } // Setup the property array
00092
00093     m_iddPropertyPage = IDD_PP_FILESHARESAMPLE_PARAMETERS;
00094     m_iddWizardPage = IDD_WIZ_FILESHARESAMPLE_PARAMETERS;
00095
00096 } //*** CFileShareSampleParamsPage::CFileShareSampleParamsPage
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 //++
00100 //
00101 //  CFileShareSampleParamsPage::DoDataExchange
00102 //
00103 //  Description:
00104 //      Do data exchange between the dialog and the class.
00105 //
00106 //  Arguments:
00107 //      pDXIn
00108 //          Data exchange object.
00109 //
00110 //  Return Value:
00111 //      None.
00112 //
00113 //--
00114 /////////////////////////////////////////////////////////////////////////////
00115 void
00116 CFileShareSampleParamsPage::DoDataExchange(
00117     CDataExchange * pDXIn
00118     )
00119 {
00120     if ( ! pDXIn->m_bSaveAndValidate || ! BSaved() )
00121     {
00122         AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00123
00124         //
00125         //  TODO: Modify the following lines to represent the data displayed on this page.
00126         //
00127
00128         //  {{AFX_DATA_MAP(CFileShareSampleParamsPage)
00129         DDX_Control( pDXIn, IDC_PP_FILESHARESAMPLE_SHARENAME, m_editShareName );
00130         DDX_Control( pDXIn, IDC_PP_FILESHARESAMPLE_PATH, m_editPath );
00131         DDX_Text( pDXIn, IDC_PP_FILESHARESAMPLE_SHARENAME, m_strShareName );
00132         DDX_Text( pDXIn, IDC_PP_FILESHARESAMPLE_PATH, m_strPath );
00133         DDX_Text( pDXIn, IDC_PP_FILESHARESAMPLE_REMARK, m_strRemark );
00134         DDX_Text( pDXIn, IDC_PP_FILESHARESAMPLE_MAXUSERS, m_nMaxUsers );
00135         //}}AFX_DATA_MAP
00136
00137         //
00138         //  Handle numeric parameters.
00139         //
00140
00141         if ( ! BBackPressed() )
00142         {
00143             DDX_Number(
00144                   pDXIn
00145                 , IDC_PP_FILESHARESAMPLE_MAXUSERS
00146                 , m_nMaxUsers
00147                 , static_cast< DWORD >( 0 )
00148                 , static_cast< DWORD >( 4294967295 )
00149                 , FALSE /*bSigned*/
00150                 );
00151         } // if: back button not pressed
00152
00153         //
00154         //  TODO: Add any additional field validation here.
00155         //
00156
00157         if ( pDXIn->m_bSaveAndValidate )
00158         {
00159             //
00160             //  Make sure all required fields are present.
00161             //
00162
00163             if ( ! BBackPressed() )
00164             {
00165                 DDV_RequiredText( pDXIn, IDC_PP_FILESHARESAMPLE_SHARENAME, IDC_PP_FILESHARESAMPLE_SHARENAME_LABEL, m_strShareName );
00166                 DDV_RequiredText( pDXIn, IDC_PP_FILESHARESAMPLE_PATH, IDC_PP_FILESHARESAMPLE_PATH_LABEL, m_strPath );
00167             } // if: back button not pressed
00168         } // if: saving data from dialog
00169     } // if: not saving or haven't saved yet
00170
00171     CBasePropertyPage::DoDataExchange( pDXIn );
00172
00173 } //*** CFileShareSampleParamsPage::DoDataExchange
00174
00175 /////////////////////////////////////////////////////////////////////////////
00176 //++
00177 //
00178 //  CFileShareSampleParamsPage::OnInitDialog
00179 //
00180 //  Description:
00181 //      Handler for the WM_INITDIALOG message.
00182 //
00183 //  Arguments:
00184 //      None.
00185 //
00186 //  Return Value:
00187 //      TRUE
00188 //          We need the focus to be set for us.
00189 //
00190 //      FALSE
00191 //          We already set the focus to the proper control.
00192 //
00193 //--
00194 /////////////////////////////////////////////////////////////////////////////
00195 BOOL
00196 CFileShareSampleParamsPage::OnInitDialog( void )
00197 {
00198     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00199
00200     CBasePropertyPage::OnInitDialog();
00201
00202     //
00203     //  TODO: Limit the size of the text that can be entered in edit controls.
00204     //
00205
00206     //
00207     //  Return TRUE unless you set the focus to a control.
00208     //
00209     //  EXCEPTION: OCX Property Pages should return FALSE..
00210     //
00211
00212     return TRUE;
00213
00214 } //*** CFileShareSampleParamsPage::OnInitDialog
00215
00216 /////////////////////////////////////////////////////////////////////////////
00217 //++
00218 //
00219 //  CFileShareSampleParamsPage::OnSetActive
00220 //
00221 //  Description:
00222 //      Handler for the PSN_SETACTIVE message.
00223 //
00224 //  Arguments:
00225 //      None.
00226 //
00227 //  Return Value:
00228 //      TRUE
00229 //          Page successfully initialized.
00230 //
00231 //      FALSE
00232 //          Page not initialized.
00233 //
00234 //--
00235 /////////////////////////////////////////////////////////////////////////////
00236 BOOL
00237 CFileShareSampleParamsPage::OnSetActive( void )
00238 {
00239     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00240
00241     // Enable/disable the Next/Finish button.
00242     if ( BWizard() )
00243     {
00244         EnableNext( BAllRequiredFieldsPresent() );
00245     } // if: displaying a wizard
00246
00247     return CBasePropertyPage::OnSetActive();
00248
00249 } //*** CFileShareSampleParamsPage::OnSetActive
00250
00251 /////////////////////////////////////////////////////////////////////////////
00252 //++
00253 //
00254 //  CFileShareSampleParamsPage::OnChangeRequiredField
00255 //
00256 //  Description:
00257 //      Handler for the EN_CHANGE message on the Share name or Path edit
00258 //      controls.
00259 //
00260 //  Arguments:
00261 //      None.
00262 //
00263 //  Return Value:
00264 //      None.
00265 //
00266 //--
00267 /////////////////////////////////////////////////////////////////////////////
00268 void
00269 CFileShareSampleParamsPage::OnChangeRequiredField( void )
00270 {
00271     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00272
00273     OnChangeCtrl();
00274
00275     if ( BWizard() )
00276     {
00277         EnableNext( BAllRequiredFieldsPresent() );
00278     } // if: displaying a wizard
00279
00280 } //*** CFileShareSampleParamsPage::OnChangeRequiredField
00281
00282 /////////////////////////////////////////////////////////////////////////////
00283 //++
00284 //
00285 //  CFileShareSampleParamsPage::BAllRequiredFieldsPresent
00286 //
00287 //  Description:
00288 //      Handler for the EN_CHANGE message on the Share name or Path edit
00289 //      controls.
00290 //
00291 //  Arguments:
00292 //      None.
00293 //
00294 //  Return Value:
00295 //      None.
00296 //
00297 //--
00298 /////////////////////////////////////////////////////////////////////////////
00299 BOOL
00300 CFileShareSampleParamsPage::BAllRequiredFieldsPresent( void ) const
00301 {
00302     BOOL    fPresent;
00303
00304     if ( 0
00305         || (m_editShareName.GetWindowTextLength() == 0)
00306         || (m_editPath.GetWindowTextLength() == 0)
00307         )
00308     {
00309         fPresent = FALSE;
00310     } // if: required field not present
00311     else
00312     {
00313         fPresent = TRUE;
00314     } // else: all required fields are present
00315
00316     return fPresent;
00317
00318 } //*** CFileShareSampleParamsPage::BAllRequiredFieldsPresent
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

gss_OID_desc_struct Member List

This is the complete list of members for gss_OID_desc_struct, including all inherited members.
elements | gss_OID_desc_struct
length | gss_OID_desc_struct
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/NetMon/parsers/blrplate/blrplate.h Source File

  • NetDS
  • NetMon
  • parsers
  • blrplate

blrplate.h

Go to the documentation of this file.
00001 //============================================================================
00002 //  FILE: BLRPLATE.h
00003 //
00004 //  Description: BLRPLATE (BLRPLATE) Parser
00005 //
00006 //  Note: info for this parser was gleaned from:
00007 //  rfcXXXX (BLRPLATE)
00008 //
00009 //  Modification History
00010 //
00011 //  Your Name Here      01/01/70    Created
00012 //============================================================================
00013
00014 #ifndef _BLRPLATE_H_
00015 #define _BLRPLATE_H_
00016
00017 #include <windows.h>
00018 #include <netmon.h>
00019 #include <stdlib.h>
00020 #include <string.h>
00021
00022 // structure for decoding the header -----------------------------------------
00023 typedef struct _BLRPLATE
00024 {
00025     DWORD Signature;
00026     WORD  Opcode;
00027     BYTE  Flags;
00028
00029 } BLRPLATEHDR;
00030 typedef BLRPLATEHDR UNALIGNED *PBLRPLATEHDR;
00031
00032 // property ordinals ---------------------------------------------------------
00033 // (These must be kept in sync with the contents of BLRPLATEPropertyTable)
00034 typedef enum
00035 {
00036     BLRPLATE_SUMMARY = 0,
00037     BLRPLATE_SIGNATURE,
00038     BLRPLATE_OPCODE,
00039     BLRPLATE_FLAGS_SUMMARY,
00040     BLRPLATE_FLAGS_FLAGS
00041 };
00042
00043 #endif // _BLRPLATE_H_
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Ppgeext/globals.h Source File

  • SysMgmt
  • MMC
  • Ppgeext

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025         #define IDM_BUTTON1    0x100
00026         #define IDM_BUTTON2    0x101
00027
00028         extern HINSTANCE g_hinst;
00029         extern ULONG g_uObjects;
00030
00031         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034 #endif
00035
00036 //=--------------------------------------------------------------------------=
00037 // allocates a temporary buffer that will disappear when it goes out of scope
00038 // NOTE: be careful of that -- make sure you use the string in the same or
00039 // nested scope in which you created this buffer. people should not use this
00040 // class directly.  use the macro(s) below.
00041 //
00042 class TempBuffer {
00043   public:
00044     TempBuffer(ULONG cBytes) {
00045         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00046         m_fHeapAlloc = (cBytes > 120);
00047     }
00048     ~TempBuffer() {
00049         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00050     }
00051     void *GetBuffer() {
00052         return m_pBuf;
00053     }
00054
00055   private:
00056     void *m_pBuf;
00057     // we'll use this temp buffer for small cases.
00058     //
00059     char  m_szTmpBuf[120];
00060     unsigned m_fHeapAlloc:1;
00061 };
00062
00063 //=--------------------------------------------------------------------------=
00064 // string helpers.
00065 //
00066 // given a _TCHAR, copy it into a wide buffer.
00067 // be careful about scoping when using this macro!
00068 //
00069 // how to use the below two macros:
00070 //
00071 //  ...
00072 //  LPTSTR pszT;
00073 //  pszT = MyGetTStringRoutine();
00074 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00075 //  MyUseWideStringRoutine(pwsz);
00076 //  ...
00077 #ifdef UNICODE
00078 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00079     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00080     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00081     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00082     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00083 #else // ANSI
00084 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00085     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00086     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00087     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00088     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00089     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00090 #endif
00091
00092 #ifdef UNICODE
00093 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00094     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00095     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00096     lstrcpyW((LPWSTR)ptrname, tstr)
00097 #else // ANSI
00098 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00099     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00100     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00101     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00102     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00103 #endif
00104
00105 //
00106 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00107 // have to be declared, and no clean up must be done.
00108 //
00109 // * 2 for DBCS handling in below length computation
00110 //
00111 #ifdef UNICODE
00112 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00113     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00114     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00115     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00116     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00117 #else // ANSI
00118 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00119     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00120     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00121     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00122     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00123 #endif
00124
00125 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/registry.h Source File

  • SysMgmt
  • MMC
  • Simple

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/llistimpl.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

llistimpl.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.h:  Definition and implementation of CLListImpl.  This is a
00013 //                 generic linked list class which emulates CList from MFC.
00014 //
00015
00016
00017 #ifndef __CLASS_CLLISTIMPL__
00018 #define __CLASS_CLLISTIMPL__
00019
00020 #if _MSC_VER > 1000
00021 #pragma once
00022 #endif // _MSC_VER > 1000
00023
00024 #include <CrtDbg.h>
00025 #include <Windows.h>
00026 #include <new.h>
00027
00028
00029 // Abstract iteration position
00030 struct  __POSITION { };
00031 typedef __POSITION*  POSITION;
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 //  CPlex stuff for allocating nodes
00035 //
00036
00037 //---------------------------------------------------------------------------
00038 struct CPlex     // warning variable length structure
00039 {
00040   CPlex* pNext;
00041 //#if (_AFX_PACKING >= 8)
00042   DWORD dwReserved[1];    // align on 8 byte boundary
00043 //#endif
00044
00045   // BYTE data[maxNum*elementSize];
00046
00047   void* data() { return this+1; }
00048
00049   static CPlex* PASCAL Create(CPlex*& head, UINT nMax, UINT cbElement);
00050       // like 'calloc' but no zero fill
00051       // may throw memory exceptions
00052
00053   void FreeDataChain();       // free this one and links
00054 };
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 //  Helpers
00059 //
00060
00061 BOOL IsValidAddress( const void*  lp, UINT nBytes, BOOL bReadWrite = TRUE );
00062
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // CLListImpl<TYPE, ARG_TYPE>
00066
00067 template<class TYPE, class ARG_TYPE>
00068 class CLListImpl
00069 {
00070   public:
00071     CLListImpl( int nBlockSize = 10 );
00072     ~CLListImpl();
00073
00074   protected:
00075     struct CNode
00076     {
00077       CNode* pNext;
00078       CNode* pPrev;
00079       TYPE   data;
00080     };
00081
00082   public:
00083                                          // Attributes (head and tail)
00084    int       GetCount() const;
00085    BOOL      IsEmpty() const;
00086
00087    TYPE&     GetHead();                  // Peek at head and tail
00088    TYPE      GetHead() const;
00089    TYPE&     GetTail();
00090    TYPE      GetTail() const;
00091                                          // Operations
00092    TYPE      RemoveHead();
00093    TYPE      RemoveTail();
00094                                          // Add before head or after tail
00095    POSITION  AddHead( ARG_TYPE NewElement );
00096    POSITION  AddTail( ARG_TYPE NewElement );
00097
00098    void      AddHead(CLListImpl* pNewList);  // Add another list
00099    void      AddTail(CLListImpl* pNewList);
00100
00101    void      RemoveAll();                // Remove all elements
00102
00103    POSITION  GetHeadPosition() const;
00104    POSITION  GetTailPosition() const;
00105    TYPE&     GetNext(POSITION& rPosition);       // return *Position++
00106    TYPE      GetNext(POSITION& rPosition) const; // return *Position++
00107    TYPE&     GetPrev(POSITION& rPosition);       // return *Position--
00108    TYPE      GetPrev(POSITION& rPosition) const; // return *Position--
00109
00110    // Getting/modifying an element at a given position
00111    TYPE&     GetAt(POSITION Position);
00112    TYPE      GetAt(POSITION Position) const;
00113    void      SetAt(POSITION Pos, ARG_TYPE NewElement);
00114    void      RemoveAt(POSITION Position);
00115
00116    // inserting before or after a given position
00117    POSITION InsertBefore(POSITION position, ARG_TYPE newElement);
00118    POSITION InsertAfter(POSITION position, ARG_TYPE newElement);
00119
00120    // Helper functions (note: O(n) speed)
00121
00122    // Defaults to starting at the HEAD, return NULL if not found
00123    POSITION Find(ARG_TYPE SearchValue, POSITION StartAfter = NULL) const;
00124
00125    // Get the 'nIndex'th element (may return NULL)
00126    POSITION FindIndex(int nIndex) const;
00127
00128   // Implementation
00129   protected:
00130     CNode*   m_pNodeHead;
00131     CNode*   m_pNodeTail;
00132     int      m_nCount;
00133     CNode*   m_pNodeFree;
00134     struct   CPlex* m_pBlocks;
00135     int m_nBlockSize;
00136
00137     CNode*   NewNode(CNode*, CNode*);
00138     void     FreeNode(CNode*);
00139
00140 #ifdef _DEBUG
00141
00142   void AssertValid() const;
00143
00144 #endif //_DEBUG
00145
00146 }; //end class CLListImpl
00147
00148 /////////////////////////////////////////////////////////////////////////////
00149 // CLListImpl<TYPE, ARG_TYPE> inline functions
00150
00151 template<class TYPE, class ARG_TYPE>
00152 inline int CLListImpl<TYPE, ARG_TYPE>::GetCount() const
00153   { return m_nCount; }
00154
00155 template<class TYPE, class ARG_TYPE>
00156 inline BOOL CLListImpl<TYPE, ARG_TYPE>::IsEmpty() const
00157   { return m_nCount == 0; }
00158
00159 template<class TYPE, class ARG_TYPE>
00160 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetHead()
00161   {
00162     _ASSERT( NULL != m_pNodeHead );
00163     return m_pNodeHead->data;
00164   }
00165
00166 template<class TYPE, class ARG_TYPE>
00167 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetHead() const
00168   {
00169     _ASSERT( NULL != m_pNodeHead );
00170     return m_pNodeHead->data;
00171   }
00172
00173 template<class TYPE, class ARG_TYPE>
00174 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetTail()
00175   {
00176     _ASSERT( NULL != m_pNodeTail );
00177     return m_pNodeTail->data;
00178   }
00179
00180 template<class TYPE, class ARG_TYPE>
00181 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetTail() const
00182   {
00183     _ASSERT( NULL != m_pNodeTail );
00184     return m_pNodeTail->data;
00185   }
00186
00187 template<class TYPE, class ARG_TYPE>
00188 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetHeadPosition() const
00189   { return (POSITION)m_pNodeHead; }
00190
00191 template<class TYPE, class ARG_TYPE>
00192 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetTailPosition() const
00193   { return (POSITION)m_pNodeTail; }
00194
00195 template<class TYPE, class ARG_TYPE>
00196 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) // return *Position++
00197   {
00198     CNode* pNode = (CNode*) rPosition;
00199     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00200     rPosition = (POSITION) pNode->pNext;
00201     return pNode->data;
00202   }
00203
00204 template<class TYPE, class ARG_TYPE>
00205 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) const // return *Position++
00206   {
00207     CNode* pNode = (CNode*) rPosition;
00208     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00209     rPosition = (POSITION) pNode->pNext;
00210     return pNode->data;
00211   }
00212
00213 template<class TYPE, class ARG_TYPE>
00214 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) // return *Position--
00215   {
00216     CNode* pNode = (CNode*) rPosition;
00217     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00218     rPosition = (POSITION) pNode->pPrev;
00219     return pNode->data;
00220   }
00221
00222 template<class TYPE, class ARG_TYPE>
00223 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) const // return *Position--
00224   {
00225     CNode* pNode = (CNode*) rPosition;
00226     ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00227     rPosition = (POSITION) pNode->pPrev;
00228     return pNode->data;
00229   }
00230
00231 template<class TYPE, class ARG_TYPE>
00232 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position)
00233   {
00234     CNode* pNode = (CNode*)Position;
00235     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00236     return pNode->data;
00237   }
00238
00239 template<class TYPE, class ARG_TYPE>
00240 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position) const
00241   {
00242     CNode* pNode = (CNode*) Position;
00243     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00244     return pNode->data;
00245   }
00246
00247 template<class TYPE, class ARG_TYPE>
00248 inline void CLListImpl<TYPE, ARG_TYPE>::SetAt(POSITION Pos, ARG_TYPE NewElement)
00249   {
00250     CNode* pNode = (CNode*)Pos;
00251     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00252     pNode->data = newElement;
00253   }
00254
00255
00256 template<class TYPE, class ARG_TYPE>
00257 CLListImpl<TYPE, ARG_TYPE>::CLListImpl( int nBlockSize )
00258 {
00259   _ASSERT( nBlockSize > 0 );
00260
00261   m_nCount     = 0;
00262   m_pNodeHead  = m_pNodeTail = m_pNodeFree = NULL;
00263   m_pBlocks    = NULL;
00264   m_nBlockSize = nBlockSize;
00265 }
00266
00267 template<class TYPE, class ARG_TYPE>
00268 void CLListImpl<TYPE, ARG_TYPE>::RemoveAll()
00269 {
00270   // destroy elements
00271   CNode* pNode;
00272   for( pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext )
00273     (pNode->data).~TYPE();
00274
00275   m_nCount = 0;
00276   m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL;
00277   m_pBlocks->FreeDataChain();
00278   m_pBlocks = NULL;
00279 }
00280
00281 template<class TYPE, class ARG_TYPE>
00282 CLListImpl<TYPE, ARG_TYPE>::~CLListImpl()
00283 {
00284   RemoveAll();
00285   _ASSERT(m_nCount == 0);
00286 }
00287
00288
00289 /////////////////////////////////////////////////////////////////////////////
00290 // Node helpers
00291 //
00292 //  Implementation note: CNode's are stored in CPlex blocks and
00293 //  chained together. Free blocks are maintained in a singly linked list
00294 //  using the 'pNext' member of CNode with 'm_pNodeFree' as the head.
00295 //  Used blocks are maintained in a doubly linked list using both 'pNext'
00296 //  and 'pPrev' as links and 'm_pNodeHead' and 'm_pNodeTail'
00297 //  as the head/tail.
00298 //
00299 //  We never free a CPlex block unless the List is destroyed or RemoveAll()
00300 //  is used - so the total number of CPlex blocks may grow large depending
00301 //  on the maximum past size of the list.
00302 //
00303
00304
00305 template<class TYPE, class ARG_TYPE>
00306 CLListImpl<TYPE, ARG_TYPE>::CNode*
00307 CLListImpl<TYPE, ARG_TYPE>::NewNode(CLListImpl::CNode* pPrev, CLListImpl::CNode* pNext)
00308 {
00309   if( NULL == m_pNodeFree )
00310   {
00311     // add another block
00312     CPlex* pNewBlock = CPlex::Create( m_pBlocks, m_nBlockSize, sizeof(CNode) );
00313
00314     // chain them into free list
00315     CNode* pNode = (CNode*) pNewBlock->data();
00316     // free in reverse order to make it easier to debug
00317     pNode += m_nBlockSize - 1;
00318     for( int i = m_nBlockSize-1; i >= 0; i--, pNode-- )
00319     {
00320       pNode->pNext = m_pNodeFree;
00321       m_pNodeFree = pNode;
00322     }
00323   }
00324   _ASSERT( NULL != m_pNodeFree );  // we must have something
00325
00326   CLListImpl::CNode* pNode = m_pNodeFree;
00327   m_pNodeFree = m_pNodeFree->pNext;
00328   pNode->pPrev = pPrev;
00329   pNode->pNext = pNext;
00330   m_nCount++;
00331   _ASSERT(m_nCount > 0);  // make sure we don't overflow
00332
00333   new (&pNode->data) TYPE; // Placement new
00334
00335   return pNode;
00336 }
00337
00338
00339 template<class TYPE, class ARG_TYPE>
00340 void CLListImpl<TYPE, ARG_TYPE>::FreeNode(CLListImpl::CNode* pNode)
00341 {
00342   (pNode->data).~TYPE();
00343   pNode->pNext = m_pNodeFree;
00344   m_pNodeFree = pNode;
00345   m_nCount--;
00346   _ASSERT(m_nCount >= 0);  // make sure we don't underflow
00347
00348   // if no more elements, cleanup completely
00349   if( 0 == m_nCount )
00350     RemoveAll();
00351 }
00352
00353 template<class TYPE, class ARG_TYPE>
00354 POSITION CLListImpl<TYPE, ARG_TYPE>::AddHead( ARG_TYPE NewElement )
00355 {
00356   _ASSERT( NULL != NewElement );
00357
00358   CNode* pNewNode = NewNode( NULL, m_pNodeHead );
00359   pNewNode->data = NewElement;
00360   if( NULL != m_pNodeHead )
00361     m_pNodeHead->pPrev = pNewNode;
00362   else
00363     m_pNodeTail = pNewNode;
00364
00365   m_pNodeHead = pNewNode;
00366   return (POSITION)pNewNode;
00367 }
00368
00369
00370 template<class TYPE, class ARG_TYPE>
00371 POSITION CLListImpl<TYPE, ARG_TYPE>::AddTail(ARG_TYPE NewElement)
00372 {
00373   _ASSERT( NULL != NewElement );
00374
00375   CNode* pNewNode = NewNode( m_pNodeTail, NULL );
00376   pNewNode->data = NewElement;
00377   if( NULL != m_pNodeTail )
00378     m_pNodeTail->pNext = pNewNode;
00379   else
00380     m_pNodeHead = pNewNode;
00381
00382   m_pNodeTail = pNewNode;
00383   return (POSITION)pNewNode;
00384 }
00385
00386
00387 template<class TYPE, class ARG_TYPE>
00388 void CLListImpl<TYPE, ARG_TYPE>::AddHead( CLListImpl* pNewList )
00389 {
00390   _ASSERT( NULL != pNewList );
00391
00392   // Add a list of same elements to head (maintain order)
00393   POSITION Pos = pNewList->GetTailPosition();
00394   while( NULL != Pos )
00395     AddHead(pNewList->GetPrev( Pos ));
00396 }
00397
00398
00399 template<class TYPE, class ARG_TYPE>
00400 void CLListImpl<TYPE, ARG_TYPE>::AddTail(CLListImpl* pNewList)
00401 {
00402   _ASSERT( NULL != pNewList );
00403
00404   // Add a list of same elements
00405   POSITION Pos = pNewList->GetHeadPosition();
00406   while( NULL != Pos )
00407     AddTail(pNewList->GetNext( Pos ));
00408 }
00409
00410
00411 template<class TYPE, class ARG_TYPE>
00412 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveHead()
00413 {
00414   _ASSERT( NULL != m_pNodeHead );  // don't call on empty list !!!
00415   _ASSERT( IsValidAddress( m_pNodeHead, sizeof(CNode)) );
00416
00417   CNode* pOldNode = m_pNodeHead;
00418   TYPE returnValue = pOldNode->data;
00419
00420   m_pNodeHead = pOldNode->pNext;
00421   if( NULL != m_pNodeHead )
00422     m_pNodeHead->pPrev = NULL;
00423   else
00424     m_pNodeTail = NULL;
00425
00426   FreeNode(pOldNode);
00427   return returnValue;
00428 }
00429
00430
00431 template<class TYPE, class ARG_TYPE>
00432 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveTail()
00433 {
00434   _ASSERT( NULL != m_pNodeTail );  // don't call on empty list !!!
00435   _ASSERT( IsValidAddress( m_pNodeTail, sizeof(CNode)) );
00436
00437   CNode* pOldNode = m_pNodeTail;
00438   TYPE returnValue = pOldNode->data;
00439
00440   m_pNodeTail = pOldNode->pPrev;
00441   if( NULL != m_pNodeTail )
00442     m_pNodeTail->pNext = NULL;
00443   else
00444     m_pNodeHead = NULL;
00445
00446   FreeNode(pOldNode);
00447   return returnValue;
00448 }
00449
00450
00451 template<class TYPE, class ARG_TYPE>
00452 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertBefore(POSITION Position, ARG_TYPE NewElement)
00453 {
00454   _ASSERT( NULL != NewElement );
00455
00456   if( NULL == Position )
00457     return AddHead( NewElement ); // insert before nothing -> head of the list
00458
00459   // Insert it before position
00460   CNode* pOldNode = (CNode*)Position;
00461   CNode* pNewNode = NewNode( pOldNode->pPrev, pOldNode );
00462   pNewNode->data  = NewElement;
00463
00464   if( NULL != pOldNode->pPrev )
00465   {
00466     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00467     pOldNode->pPrev->pNext = pNewNode;
00468   }
00469   else
00470   {
00471     _ASSERT( pOldNode == m_pNodeHead );
00472     m_pNodeHead = pNewNode;
00473   }
00474   pOldNode->pPrev = pNewNode;
00475   return (POSITION)pNewNode;
00476 }
00477
00478
00479 template<class TYPE, class ARG_TYPE>
00480 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertAfter(POSITION Position, ARG_TYPE NewElement)
00481 {
00482   ASSERT( NULL != NewElement );
00483
00484   if( NULL == Position )
00485     return AddTail( NewElement ); // insert after nothing -> tail of the list
00486
00487   // Insert it before position
00488   CNode* pOldNode = (CNode*)Position;
00489   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode) ) );
00490   CNode* pNewNode = NewNode( pOldNode, pOldNode->pNext );
00491   pNewNode->data = NewElement;
00492
00493   if( NULL != pOldNode->pNext )
00494   {
00495     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00496     pOldNode->pNext->pPrev = pNewNode;
00497   }
00498   else
00499   {
00500     _ASSERT( pOldNode == m_pNodeTail );
00501     m_pNodeTail = pNewNode;
00502   }
00503   pOldNode->pNext = pNewNode;
00504   return (POSITION)pNewNode;
00505 }
00506
00507
00508 template<class TYPE, class ARG_TYPE>
00509 void CLListImpl<TYPE, ARG_TYPE>::RemoveAt( POSITION Position )
00510 {
00511   _ASSERT( NULL != Position );
00512
00513   CNode* pOldNode = (CNode*)Position;
00514   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode)) );
00515
00516   // Remove pOldNode from list
00517   if( pOldNode == m_pNodeHead )
00518   {
00519     m_pNodeHead = pOldNode->pNext;
00520   }
00521   else
00522   {
00523     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00524     pOldNode->pPrev->pNext = pOldNode->pNext;
00525   }
00526   if( pOldNode == m_pNodeTail )
00527   {
00528     m_pNodeTail = pOldNode->pPrev;
00529   }
00530   else
00531   {
00532     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00533     pOldNode->pNext->pPrev = pOldNode->pPrev;
00534   }
00535   FreeNode( pOldNode );
00536 }
00537
00538
00539 template<class TYPE, class ARG_TYPE>
00540 POSITION CLListImpl<TYPE, ARG_TYPE>::FindIndex(int nIndex) const
00541 {
00542   if( nIndex >= m_nCount || nIndex < 0 )
00543     return NULL;  // went too far
00544
00545   CNode* pNode = m_pNodeHead;
00546   while (nIndex--)
00547   {
00548     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00549     pNode = pNode->pNext;
00550   }
00551   return (POSITION)pNode;
00552 }
00553
00554
00555 template<class TYPE, class ARG_TYPE>
00556 POSITION CLListImpl<TYPE, ARG_TYPE>::Find(ARG_TYPE SearchValue, POSITION StartAfter) const
00557 {
00558   _ASSERT( NULL != SearchValue );
00559
00560   CNode* pNode = (CNode*)StartAfter;
00561   if( NULL == pNode )
00562   {
00563     pNode = m_pNodeHead;  // start at head
00564   }
00565   else
00566   {
00567     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00568     pNode = pNode->pNext;  // start after the one specified
00569   }
00570
00571   for (; pNode != NULL; pNode = pNode->pNext)
00572     if (CompareElements<TYPE>(&pNode->data, &searchValue))
00573       return (POSITION)pNode;
00574
00575   return NULL;
00576 }
00577
00578 #ifdef _DEBUG
00579
00580 template<class TYPE, class ARG_TYPE>
00581 void CLListImpl<TYPE, ARG_TYPE>::AssertValid() const
00582 {
00583   if( 0 == m_nCount )
00584   {
00585     // empty list
00586     _ASSERT( NULL == m_pNodeHead );
00587     _ASSERT( NULL == m_pNodeTail );
00588   }
00589   else
00590   {
00591     // non-empty list
00592     _ASSERT( IsValidAddress(m_pNodeHead, sizeof(CNode)) );
00593     _ASSERT( IsValidAddress(m_pNodeTail, sizeof(CNode)) );
00594   }
00595 }
00596 #endif //_DEBUG
00597
00598 #endif //__CLASS_CLLISTIMPL__
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellIconOverlay/IcnOvrly.h Source File

  • WinUI
  • Shell
  • ShellIconOverlay

IcnOvrly.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          IcnOvrly.h
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023 #include <initguid.h>
00024 #include <shlobj.h>
00025
00026 /**************************************************************************
00027    function prototypes
00028 **************************************************************************/
00029
00030 /**************************************************************************
00031    global variables and definitions
00032 **************************************************************************/
00033
00034 // {EA3775F2-28BE-11d3-9C8D-00105A24ED29}
00035 DEFINE_GUID(CLSID_SampleShellIconOverlay,
00036 0xea3775f2, 0x28be, 0x11d3, 0x9c, 0x8d, 0x0, 0x10, 0x5a, 0x24, 0xed, 0x29);
00037
00038 /**************************************************************************
00039
00040    CClassFactory class definition
00041
00042 **************************************************************************/
00043
00044 class CClassFactory : public IClassFactory
00045 {
00046 protected:
00047    DWORD m_ObjRefCount;
00048
00049 public:
00050    CClassFactory();
00051    ~CClassFactory();
00052
00053    //IUnknown methods
00054    STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
00055    STDMETHODIMP_(DWORD) AddRef();
00056    STDMETHODIMP_(DWORD) Release();
00057
00058    //IClassFactory methods
00059    STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
00060    STDMETHODIMP LockServer(BOOL);
00061 };
00062
00063 /**************************************************************************
00064
00065    CShellIconOverlayID class definition
00066
00067 **************************************************************************/
00068
00069 class CShellIconOverlayID : public IShellIconOverlayIdentifier
00070 {
00071 protected:
00072    DWORD          m_ObjRefCount;
00073
00074 public:
00075    CShellIconOverlayID();
00076    ~CShellIconOverlayID();
00077
00078    //IUnknown methods
00079    STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
00080    STDMETHODIMP_(DWORD) AddRef();
00081    STDMETHODIMP_(DWORD) Release();
00082
00083    //IShellIconOverlayIdentifier methods
00084    STDMETHODIMP IsMemberOf(LPCWSTR pwszPath, DWORD dwAttr);
00085    STDMETHODIMP GetOverlayInfo(LPWSTR pwszIconFile, int cchMax, LPINT pIndex, LPDWORD pdwFlags);
00086    STDMETHODIMP GetPriority(LPINT pPriority);
00087 };
00088
00089 #ifdef _cplusplus
00090 extern "C" {
00091 #endif   //_cplusplus
00092
00093 BOOL DeleteEntireKey(HKEY hKey, LPTSTR pszSubKey);
00094 int WideCharToLocal(LPTSTR pLocal, LPCWSTR pWide, DWORD dwChars);
00095 int LocalToWideChar(LPWSTR pWide, LPCTSTR pLocal, DWORD dwChars);
00096
00097 #ifdef _cplusplus
00098 }
00099 #endif   //_cplusplus
00100
00101 #define ARRAYSIZE(a)    (sizeof(a)/sizeof(a[0]))
00102
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/resource.h Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by tServer.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDS_COMPUTER_DESC               105
00007 #define IDR_Computer                    106
00008 #define IDS_HUMAN_DESC                  107
00009 #define IDR_Human                       108
00010
00011 // Next default values for new objects
00012 //
00013 #ifdef APSTUDIO_INVOKED
00014 #ifndef APSTUDIO_READONLY_SYMBOLS
00015 #define _APS_NEXT_RESOURCE_VALUE        201
00016 #define _APS_NEXT_COMMAND_VALUE         32768
00017 #define _APS_NEXT_CONTROL_VALUE         201
00018 #define _APS_NEXT_SYMED_VALUE           109
00019 #endif
00020 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cenum.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cenum.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CENUM.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 /////////////////////////////////////////////////////////////////
00019 // CEnumerator::CEnumerator
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CEnumerator::CEnumerator(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CPropertiesBase(eCEnumerator, pCMainWindow, pCMDIChild)
00024 {
00025   //[MANDATORY]
00026   m_pISourcesRowset     = NULL;   //Enumerator interface
00027   m_pIParseDisplayName    = NULL;   //Enumerator interface
00028
00029   //[OPTIONAL]
00030
00031   //Enumerator ProvierInfo
00032   m_cEnumInfo       = 0;
00033   m_rgEnumInfo      = NULL;
00034 }
00035
00036
00037 /////////////////////////////////////////////////////////////////
00038 // CEnumerator::~CEnumerator
00039 //
00040 /////////////////////////////////////////////////////////////////
00041 CEnumerator::~CEnumerator()
00042 {
00043   ReleaseObject(0);
00044
00045   m_cEnumInfo     = 0;
00046   SAFE_FREE(m_rgEnumInfo);
00047 }
00048
00049
00050 /////////////////////////////////////////////////////////////////
00051 // IUnknown** CEnumerator::GetInterfaceAddress
00052 //
00053 /////////////////////////////////////////////////////////////////
00054 IUnknown** CEnumerator::GetInterfaceAddress(REFIID riid)
00055 {
00056   HANDLE_GETINTERFACE(ISourcesRowset);
00057   HANDLE_GETINTERFACE(IParseDisplayName);
00058
00059   //Otherwise delegate
00060   return CPropertiesBase::GetInterfaceAddress(riid);
00061 }
00062
00063
00064 /////////////////////////////////////////////////////////////////
00065 // CEnumerator::AutoRelease
00066 //
00067 /////////////////////////////////////////////////////////////////
00068 HRESULT CEnumerator::AutoRelease()
00069 {
00070   //[MANDATORY]
00071   RELEASE_INTERFACE(ISourcesRowset);
00072   RELEASE_INTERFACE(IParseDisplayName);
00073
00074   //[OPTIONAL]
00075
00076   //Delegate
00077   return CPropertiesBase::AutoRelease();
00078 }
00079
00080
00081 /////////////////////////////////////////////////////////////////
00082 // HRESULT CEnumerator::AutoQI
00083 //
00084 /////////////////////////////////////////////////////////////////
00085 HRESULT CEnumerator::AutoQI(DWORD dwCreateOpts)
00086 {
00087   //Delegate First so we have base interfaces
00088   CPropertiesBase::AutoQI(dwCreateOpts);
00089
00090   //[MANDATORY]
00091   if(dwCreateOpts & CREATE_QI_MANDATORY)
00092   {
00093     OBTAIN_INTERFACE(IParseDisplayName);
00094     OBTAIN_INTERFACE(ISourcesRowset);
00095   }
00096
00097   //AutoQI
00098   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00099   {
00100     //[OPTIONAL]
00101   }
00102
00103   return S_OK;
00104 }
00105
00106
00107 /////////////////////////////////////////////////////////////////////////////
00108 // CEnumerator::GetObjectDesc
00109 //
00110 /////////////////////////////////////////////////////////////////////////////
00111 WCHAR* CEnumerator::GetObjectDesc()
00112 {
00113   if(!m_strObjectDesc && m_guidSource != GUID_NULL)
00114   {
00115     if(m_guidSource == CLSID_OLEDB_ENUMERATOR)
00116       m_strObjectDesc.CopyFrom(L"Root Enumerator");
00117     else
00118       m_strObjectDesc.CopyFrom(GetProgID(m_guidSource));
00119   }
00120
00121   return m_strObjectDesc;
00122 }
00123
00124
00125 ////////////////////////////////////////////////////////////////
00126 // CEnumerator::OnDefOperation
00127 //
00128 /////////////////////////////////////////////////////////////////
00129 void  CEnumerator::OnDefOperation()
00130 {
00131   if(m_pISourcesRowset)
00132     m_pCMainWindow->DisplayDialog(IDD_GETSOURCESROWSET, GetFocus(), CMainWindow::GetSourcesRowsetProc, this);
00133 }
00134
00135
00136 /////////////////////////////////////////////////////////////////////////////
00137 // HRESULT CEnumerator::ParseDisplayName
00138 //
00139 /////////////////////////////////////////////////////////////////////////////
00140 HRESULT CEnumerator::ParseDisplayName(WCHAR* pwszParseName, DWORD dwCLSCTX, REFIID riid, IUnknown** ppIUnknown, CBase** ppCSource, DWORD dwConnectOpts, WCHAR* pwszRemoteServer)
00141 {
00142   ASSERT(pwszParseName);
00143
00144   CComPtr<IMoniker> spMoniker;
00145   CComPtr<IBindCtx> spBindCtx;
00146   ULONG chEaten = 0;
00147   CLSID clsid;
00148   HRESULT hr = E_FAIL;
00149
00150   CBase* pCSource = NULL;
00151
00152   //Try and use ParseDisplayName
00153   //Otherwise we may be forced to just try CoCreateInstance if not installed...
00154   //Also cannot use ParseDisplayName if trying to aggregate ServiceComponents
00155   if(m_pIParseDisplayName && !(dwConnectOpts & CREATE_USESERVICECOMP))
00156   {
00157     if(dwCLSCTX)
00158     {
00159       //Setup BIND_OPTS
00160       BIND_OPTS2 BindOps2;
00161       BindOps2.cbStruct   = sizeof(BIND_OPTS2);
00162       BindOps2.grfFlags   = BIND_MAYBOTHERUSER;
00163       BindOps2.grfMode    = STGM_READWRITE;
00164       BindOps2.dwTickCountDeadline = 0;
00165       BindOps2.dwTrackFlags = 1;
00166       BindOps2.dwClassContext = dwCLSCTX;
00167       BindOps2.locale     = GetSystemDefaultLCID();
00168       BindOps2.pServerInfo  = NULL;
00169
00170       //Setup ServerInfo just incase we need it...
00171       COSERVERINFO  ServerInfo  = { 0, pwszRemoteServer, NULL, 0};
00172
00173       //Setup RemoteServer is specified
00174       if(dwCLSCTX & CLSCTX_REMOTE_SERVER)
00175         BindOps2.pServerInfo = &ServerInfo;
00176
00177       //If this fails for some reason, we can still continue...
00178       hr = CreateBindCtx(0, &spBindCtx);
00179       if(SUCCEEDED(hr) && spBindCtx)
00180         hr = spBindCtx->SetBindOptions(&BindOps2);
00181
00182       //If it does fail we will just release the Bind Context and pass
00183       //IParseDisplayName NULL and let it choose the CLXCTX...
00184       if(FAILED(hr))
00185         spBindCtx.Release();
00186     }
00187
00188     //ParseDisplayName
00189     //Don't display error, since we have our own retry logic...
00190     hr = m_pIParseDisplayName->ParseDisplayName(spBindCtx, pwszParseName, &chEaten, &spMoniker);
00191     TRACE_METHOD(hr, L"IParseDisplayName::ParseDisplayName(0x%p, \"%s\", &%d, &0x%p)", spBindCtx, pwszParseName, chEaten, spMoniker);
00192
00193     if(SUCCEEDED(hr))
00194     {
00195       XTEST(hr = BindMoniker(spMoniker, 0, riid, (void**)ppIUnknown));
00196       TESTC(TRACE_METHOD(hr, L"BindMoniker(0x%p, 0, %s, &0x%p)", spBindCtx, GetInterfaceName(riid), ppIUnknown ? *ppIUnknown : NULL));
00197       pCSource = this;
00198     }
00199   }
00200
00201   //If Not using RootEnum or for some reason the RootEnum failed,
00202   if(m_pIParseDisplayName == NULL || FAILED(hr))
00203   {
00204     //Find the CLSID from the ParseName
00205     //The user may have entered a ProgID or a CLSID
00206     //Since the ParseName is a CLSID, try the common case first...
00207     if(FAILED(hr = CLSIDFromString(pwszParseName, &clsid)))
00208       XTESTC(hr = CLSIDFromProgID(pwszParseName, &clsid));
00209
00210     //If using Service Components
00211     if(dwConnectOpts & CREATE_USESERVICECOMP)
00212     {
00213       if(dwCLSCTX == CLSCTX_INPROC_SERVER)
00214       {
00215         //Can just reuse our Main DataLink object...
00216         TESTC(hr = m_pCMainWindow->m_pCServiceComp->CreateDBInstance(clsid, NULL, CLSCTX_INPROC_SERVER, riid, ppIUnknown));
00217         pCSource = m_pCMainWindow->m_pCServiceComp;
00218       }
00219       else
00220       {
00221         //If not inproc we just create a stand alone Data Link object
00222         //We do this again here, incase you want Remoted Providers...
00223         CServiceComp* pCServiceComp = new CServiceComp(m_pCMainWindow);
00224         TESTC(pCServiceComp->Create(NULL, dwCLSCTX, pwszRemoteServer));
00225
00226         //The provider is always "inproc" to wherever the ServiceComponents are:
00227         TESTC(hr = pCServiceComp->CreateDBInstance(clsid, NULL, CLSCTX_INPROC_SERVER, riid, ppIUnknown));
00228         pCSource = pCServiceComp;
00229       }
00230     }
00231     else
00232     {
00233       //Delegate
00234       XTESTC(hr = CreateInstance(NULL, clsid, dwCLSCTX, riid, ppIUnknown, pwszRemoteServer));
00235       pCSource = NULL;
00236     }
00237   }
00238
00239 CLEANUP:
00240   if(ppCSource)
00241     *ppCSource = pCSource;
00242   return hr;
00243 }
00244
00245
00246 /////////////////////////////////////////////////////////////////
00247 // HRESULT CEnumerator::GetSourcesRowset
00248 //
00249 /////////////////////////////////////////////////////////////////
00250 HRESULT CEnumerator::GetSourcesRowset(CAggregate* pCAggregate, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown)
00251 {
00252   HRESULT hr = S_OK;
00253
00254   if(m_pISourcesRowset)
00255   {
00256     XTEST_(hr = m_pISourcesRowset->GetSourcesRowset(pCAggregate, riid, cPropSets, rgPropSets, ppIUnknown),S_OK);
00257     TRACE_METHOD(hr, L"ISourcesRowset::GetSourcesRowset(0x%p, %s, %d, 0x%p, &0x%p)", pCAggregate, GetInterfaceName(riid), cPropSets, rgPropSets, ppIUnknown ? *ppIUnknown : NULL);
00258   }
00259
00260   //Display Errors (if occurred)
00261   TESTC(hr = DisplayPropErrors(hr, cPropSets, rgPropSets));
00262
00263   //Handle Aggregation
00264   if(pCAggregate)
00265     TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00266
00267 CLEANUP:
00268   return hr;
00269 }
00270
00271
00272
00273
00274 WINOLEAPI CoCreateInstanceEx(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
00275 /////////////////////////////////////////////////////////////////////////////
00276 // HRESULT CEnumerator::CreateInstance
00277 //
00278 /////////////////////////////////////////////////////////////////////////////
00279 HRESULT CEnumerator::CreateInstance(CAggregate* pCAggregate, REFCLSID clsid, DWORD dwCLSCTX, REFIID riid, IUnknown** ppIUnknown, WCHAR* pwszRemoteServer)
00280 {
00281   HRESULT hr = S_OK;
00282
00283   //CLSID to String (just for display purposes...)
00284   WCHAR* pwszProgID = GetProgID(clsid);
00285
00286
00287   //Determine which method to use...
00288   if(dwCLSCTX & CLSCTX_REMOTE_SERVER)
00289   {
00290     //Setup ServerInfo...
00291     COSERVERINFO  ServerInfo  = { 0, pwszRemoteServer, NULL, 0};
00292     MULTI_QI    MultiQI   = { &riid, NULL, S_OK};
00293
00294     //CoCreateInstanceEx
00295     hr = CoCreateInstanceEx(clsid, pCAggregate, dwCLSCTX, &ServerInfo, 1, &MultiQI);
00296     TESTC(TRACE_METHOD(hr, L"CoCreateInstanceEx(%s, 0x%p, 0x%08x, 0x%p, 1, 0x%p)", pwszProgID, pCAggregate, dwCLSCTX, &ServerInfo, &MultiQI));
00297
00298     //Output pointer from the MultiQI
00299     if(ppIUnknown)
00300       *ppIUnknown = MultiQI.pItf;
00301   }
00302   else
00303   {
00304     //CoCreateInstance
00305     hr = CoCreateInstance(clsid, pCAggregate, dwCLSCTX, riid, (void**)ppIUnknown);
00306     TESTC(TRACE_METHOD(hr, L"CoCreateInstance(%s, 0x%p, 0x%08x, %s, &0x%p)", pwszProgID, pCAggregate, dwCLSCTX, GetInterfaceName(riid), ppIUnknown ? *ppIUnknown : NULL));
00307   }
00308
00309   //Handle Aggregation
00310   if(pCAggregate)
00311     TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00312
00313 CLEANUP:
00314   SAFE_FREE(pwszProgID);
00315   return hr;
00316 }
00317
00318
00319 /////////////////////////////////////////////////////////////////////////////
00320 // HRESULT CEnumerator::Create
00321 //
00322 /////////////////////////////////////////////////////////////////////////////
00323 HRESULT CEnumerator::Create(REFCLSID clsid)
00324 {
00325   HRESULT hr = S_OK;
00326   CComPtr<IParseDisplayName>  spParseDisplayName;
00327
00328   //Initialize the Enumerator and Obtain rowset
00329   m_guidSource = clsid;
00330   TESTC(hr = CreateInstance(NULL, clsid, CLSCTX_ALL, IID_IParseDisplayName, (IUnknown**)&spParseDisplayName));
00331
00332   //Now Delegate to our generic Enumerator method
00333   TESTC(hr = CreateObject(NULL, IID_IParseDisplayName, spParseDisplayName));
00334
00335 CLEANUP:
00336   return hr;
00337 }
00338
00339
00340 /////////////////////////////////////////////////////////////////////////////
00341 // HRESULT CEnumerator::CreateEnumInfo
00342 //
00343 /////////////////////////////////////////////////////////////////////////////
00344 HRESULT CEnumerator::CreateEnumInfo(REFCLSID clsid, BOOL fRefresh)
00345 {
00346   HRESULT hr = S_OK;
00347
00348   //Create the Enumerator, if we haven't already...
00349   if(clsid!=GUID_NULL && !m_pIParseDisplayName)
00350     TESTC(hr = Create(clsid));
00351
00352   //Free Previous Info
00353   if(fRefresh || !m_cEnumInfo)
00354   {
00355     m_cEnumInfo = 0;
00356     SAFE_FREE(m_rgEnumInfo)
00357
00358     //Obtain the Enumerator Info from the rowset...
00359     TESTC(hr = EnumerateInfo(&m_cEnumInfo, &m_rgEnumInfo));
00360   }
00361
00362 CLEANUP:
00363   return hr;
00364 }
00365
00366
00367 /////////////////////////////////////////////////////////////////////////////
00368 // HRESULT CEnumerator::EnumerateInfo
00369 //
00370 /////////////////////////////////////////////////////////////////////////////
00371 HRESULT CEnumerator::EnumerateInfo(ULONG* pcEnumInfo, ENUMINFO** prgEnumInfo)
00372 {
00373   HRESULT hr = E_FAIL;
00374   ASSERT(pcEnumInfo);
00375   ASSERT(prgEnumInfo);
00376
00377   HROW rghRows[MAX_BLOCK_SIZE];
00378   HROW* phRows = rghRows;
00379   DBCOUNTITEM cRowsObtained = 0;
00380   CComPtr<IRowset> spRowset = NULL;
00381   HACCESSOR hAccessor = DB_NULL_HACCESSOR;
00382   CRowset cRowset(m_pCMainWindow);
00383
00384   //Make our lives easier
00385   ULONG cEnumInfo = 0;
00386   ENUMINFO* rgEnumInfo = NULL;
00387
00388   // Bind the user and table name for the list
00389   const static DBCOUNTITEM cBindings = 5;
00390   const static DBBINDING rgBindings[cBindings] =
00391     {
00392       1,
00393       offsetof(ENUMINFO, wszName),
00394       0,
00395       0,
00396       NULL,
00397       NULL,
00398       NULL,
00399       DBPART_VALUE,
00400       DBMEMOWNER_CLIENTOWNED,
00401       DBPARAMIO_NOTPARAM,
00402       MAX_NAME_LEN,
00403       0,
00404       DBTYPE_WSTR,
00405       0,
00406       0,
00407
00408       2,
00409       offsetof(ENUMINFO, wszParseName),
00410       0,
00411       0,
00412       NULL,
00413       NULL,
00414       NULL,
00415       DBPART_VALUE,
00416       DBMEMOWNER_CLIENTOWNED,
00417       DBPARAMIO_NOTPARAM,
00418       MAX_NAME_LEN,
00419       0,
00420       DBTYPE_WSTR,
00421       0,
00422       0,
00423
00424       3,
00425       offsetof(ENUMINFO, wszDescription),
00426       0,
00427       0,
00428       NULL,
00429       NULL,
00430       NULL,
00431       DBPART_VALUE,
00432       DBMEMOWNER_CLIENTOWNED,
00433       DBPARAMIO_NOTPARAM,
00434       MAX_NAME_LEN,
00435       0,
00436       DBTYPE_WSTR,
00437       0,
00438       0,
00439
00440       4,
00441       offsetof(ENUMINFO, eType),
00442       0,
00443       0,
00444       NULL,
00445       NULL,
00446       NULL,
00447       DBPART_VALUE,
00448       DBMEMOWNER_CLIENTOWNED,
00449       DBPARAMIO_NOTPARAM,
00450       sizeof(USHORT),
00451       0,
00452       DBTYPE_UI2,
00453       0,
00454       0,
00455
00456       5,
00457       offsetof(ENUMINFO, fIsParent),
00458       0,
00459       0,
00460       NULL,
00461       NULL,
00462       NULL,
00463       DBPART_VALUE,
00464       DBMEMOWNER_CLIENTOWNED,
00465       DBPARAMIO_NOTPARAM,
00466       sizeof(VARIANT_BOOL),
00467       0,
00468       DBTYPE_BOOL,
00469       0,
00470       0,
00471   };
00472
00473   //ISourcesRowset::GetSourcesRowset
00474   TESTC(hr = GetSourcesRowset(NULL, IID_IRowset, 0, NULL, (IUnknown**)&spRowset));
00475   TESTC(hr = cRowset.CreateObject(this, IID_IRowset, spRowset));
00476
00477   //Create Accessor
00478   TESTC(hr = cRowset.CreateAccessor(DBACCESSOR_ROWDATA, cBindings, (DBBINDING*)rgBindings, 0, &hAccessor));
00479
00480   //Loop through the entire returned rowset
00481   while(TRUE)
00482   {
00483     TESTC(hr = cRowset.GetNextRows(0, MAX_BLOCK_SIZE, &cRowsObtained, &phRows));
00484
00485     //ENDOFROWSET
00486     if(cRowsObtained==0)
00487       break;
00488
00489     //Alloc room for ProviderInfo (in chunks)
00490     SAFE_REALLOC(rgEnumInfo, ENUMINFO, cEnumInfo + cRowsObtained);
00491     memset(&rgEnumInfo[cEnumInfo], 0, sizeof(ENUMINFO) * (size_t)cRowsObtained);
00492
00493     //Loop over rows obtained and get ProviderInfo
00494     for(ULONG i=0; i<cRowsObtained; i++)
00495     {
00496       //Get the Data
00497       TESTC(hr = cRowset.GetData(rghRows[i], hAccessor, (void*)&rgEnumInfo[cEnumInfo]));
00498       cEnumInfo++;
00499     }
00500
00501     //Release all the rows
00502     TESTC(hr = cRowset.ReleaseRows(cRowsObtained, rghRows));
00503   }
00504
00505   //Special handling for Root Enumerator
00506   if(m_guidSource == CLSID_OLEDB_ENUMERATOR)
00507   {
00508     //NOTE:  The Root Enumerator doesn't include itself in the List of Enumerators
00509     //This is good for the case of tree controls would be never ending, but bad
00510     //for apps like this one, where you might want to see the "rowset" of the Root
00511     //Enum.  So to get arround this I will just add it to the list manually
00512
00513     //Alloc room for extra MSDAENUM additon
00514     SAFE_REALLOC(rgEnumInfo, ENUMINFO, cEnumInfo + 2);
00515     StringCopy(rgEnumInfo[cEnumInfo].wszName,   L"MSDAENUM", MAX_NAME_LEN);
00516     StringCopy(rgEnumInfo[cEnumInfo].wszParseName,  L"{c8b522d0-5cf3-11ce-ade5-00aa0044773d}",  MAX_NAME_LEN);
00517     StringCopy(rgEnumInfo[cEnumInfo].wszDescription,L"Microsoft OLE DB Root Enumerator", MAX_NAME_LEN);
00518     rgEnumInfo[cEnumInfo].eType           = DBSOURCETYPE_ENUMERATOR;
00519     rgEnumInfo[cEnumInfo].fIsParent         = VARIANT_TRUE;
00520     cEnumInfo++;
00521
00522     //Also add the RootBinder to the list of valid progids.
00523     StringCopy(rgEnumInfo[cEnumInfo].wszName,   L"MSDAURL.Binder", MAX_NAME_LEN);
00524     StringCopy(rgEnumInfo[cEnumInfo].wszParseName,  L"{FF151822-B0BF-11D1-A80D-000000000000}", MAX_NAME_LEN);
00525     StringCopy(rgEnumInfo[cEnumInfo].wszDescription,L"Microsoft OLE DB Root Binder for Internet Publishing", MAX_NAME_LEN);
00526     rgEnumInfo[cEnumInfo].eType           = DBSOURCETYPE_ENUMERATOR;
00527     rgEnumInfo[cEnumInfo].fIsParent         = VARIANT_TRUE;
00528     cEnumInfo++;
00529   }
00530
00531 CLEANUP:
00532   //Now update the output params
00533   *pcEnumInfo = cEnumInfo;
00534   *prgEnumInfo = rgEnumInfo;
00535
00536   cRowset.ReleaseAccessor(&hAccessor);
00537   return hr;
00538 }
00539
00540
Generated on Wed Nov 13 2024 16:52:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Enum.Cpp Source File

  • NetDS
  • SyncMgr
  • SyncDir

Enum.Cpp

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012
00013 #include "precomp.h"
00014
00015 extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
00016
00017 //+---------------------------------------------------------------------------
00018 //
00019 //  Member:     CGenericEnum::CGenericEnum, public
00020 //
00021 //  Synopsis:   Constructor
00022 //
00023 //  Arguments:
00024 //
00025 //  Returns:
00026 //
00027 //  Modifies:
00028 //
00029 //----------------------------------------------------------------------------
00030
00031 CGenericEnum::CGenericEnum(LPGENERICITEMLIST pGenericItemList,DWORD cOffset)
00032 {
00033 DWORD dwItemIndex;
00034 m_cRef                   = 1;   // give the intial reference
00035 m_pGenericItemList   = pGenericItemList;
00036 m_cOffset                = cOffset;
00037
00038     AddRef_ItemList(m_pGenericItemList); // increment our hold on shared memory.
00039
00040     // set the current item to point to next record.
00041     m_pNextItem = m_pGenericItemList->pFirstGenericItem;
00042     dwItemIndex = cOffset;
00043
00044     // this is a bug if this happens so assert in final.
00045     if (dwItemIndex > m_pGenericItemList->dwNumItems)
00046         dwItemIndex = 0;
00047
00048     // move the nextItem pointer to the proper position
00049     while(dwItemIndex--)
00050     {
00051     m_pNextItem = m_pNextItem->pNextGenericItem;
00052     ++m_cOffset;
00053
00054     if (NULL == m_pNextItem)
00055         break; // Again, another error.
00056     }
00057 }
00058
00059
00060 //+---------------------------------------------------------------------------
00061 //
00062 //  Member:     CGenericEnum::~CGenericEnum, public
00063 //
00064 //  Synopsis:   Destructor.
00065 //
00066 //  Arguments:
00067 //
00068 //  Returns:
00069 //
00070 //  Modifies:
00071 //
00072 //----------------------------------------------------------------------------
00073
00074 CGenericEnum::~CGenericEnum()
00075 {
00076     Release_ItemList(m_pGenericItemList); // decrement our hold on shared memory.
00077 }
00078
00079
00080 //+---------------------------------------------------------------------------
00081 //
00082 //  Member:     CGenericEnum::QueryInterface, public
00083 //
00084 //  Synopsis:
00085 //
00086 //  Arguments:
00087 //
00088 //  Returns:
00089 //
00090 //  Modifies:
00091 //
00092 //----------------------------------------------------------------------------
00093
00094 STDMETHODIMP CGenericEnum::QueryInterface(REFIID riid, LPVOID FAR *ppv)
00095 {
00096     return E_NOINTERFACE;
00097 }
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 //  Member:     CGenericEnum::Addref, public
00102 //
00103 //  Synopsis:
00104 //
00105 //  Arguments:
00106 //
00107 //  Returns:
00108 //
00109 //  Modifies:
00110 //
00111 //----------------------------------------------------------------------------
00112
00113 STDMETHODIMP_(ULONG) CGenericEnum::AddRef()
00114 {
00115     return ++m_cRef;
00116 }
00117
00118
00119 //+---------------------------------------------------------------------------
00120 //
00121 //  Member:     CGenericEnum::Release, public
00122 //
00123 //  Synopsis:
00124 //
00125 //  Arguments:
00126 //
00127 //  Returns:
00128 //
00129 //  Modifies:
00130 //
00131 //----------------------------------------------------------------------------
00132
00133 STDMETHODIMP_(ULONG) CGenericEnum::Release()
00134 {
00135     if (--m_cRef)
00136         return m_cRef;
00137
00138     DeleteThisObject();
00139
00140     return 0L;
00141 }
00142
00143 //+---------------------------------------------------------------------------
00144 //
00145 //  Member:     CGenericEnum::Next, public
00146 //
00147 //  Synopsis:
00148 //
00149 //  Arguments:
00150 //
00151 //  Returns:
00152 //
00153 //  Modifies:
00154 //
00155 //----------------------------------------------------------------------------
00156
00157 STDMETHODIMP CGenericEnum::Next(ULONG celt, LPGENERICITEM rgelt,ULONG *pceltFetched)
00158 {
00159 HRESULT hr = NOERROR;
00160 ULONG ulFetchCount = celt;
00161 ULONG ulNumFetched = 0;
00162 LPGENERICITEM pGenericItem;
00163
00164     if ( (m_cOffset + celt) > m_pGenericItemList->dwNumItems)
00165     {
00166     ulFetchCount = m_pGenericItemList->dwNumItems - m_cOffset;
00167     hr = S_FALSE;
00168     }
00169
00170     pGenericItem = rgelt;
00171
00172     while (ulFetchCount--)
00173     {
00174     *pGenericItem = *(m_pNextItem->pNextGenericItem);
00175     m_pNextItem = m_pNextItem->pNextGenericItem; // add error checking
00176     ++m_cOffset;
00177         ++ulNumFetched;
00178     ++pGenericItem;
00179     }
00180
00181     if (pceltFetched)
00182     {
00183         *pceltFetched = ulNumFetched;
00184     }
00185
00186     return hr;
00187 }
00188
00189 //+---------------------------------------------------------------------------
00190 //
00191 //  Member:     CGenericEnum::Skip, public
00192 //
00193 //  Synopsis:
00194 //
00195 //  Arguments:
00196 //
00197 //  Returns:
00198 //
00199 //  Modifies:
00200 //
00201 //----------------------------------------------------------------------------
00202
00203 STDMETHODIMP CGenericEnum::Skip(ULONG celt)
00204 {
00205 HRESULT hr;
00206
00207     if ( (m_cOffset + celt) > m_pGenericItemList->dwNumItems)
00208     {
00209     m_cOffset = m_pGenericItemList->dwNumItems;
00210     m_pNextItem = NULL;
00211     hr = S_FALSE;
00212     }
00213     else
00214     {
00215     while (celt--)
00216     {
00217         ++m_cOffset;
00218         m_pNextItem = m_pNextItem->pNextGenericItem;
00219     }
00220
00221     hr = NOERROR;
00222     }
00223
00224     return hr;
00225 }
00226
00227
00228 //+---------------------------------------------------------------------------
00229 //
00230 //  Member:     CGenericEnum::Reset, public
00231 //
00232 //  Synopsis:
00233 //
00234 //  Arguments:
00235 //
00236 //  Returns:
00237 //
00238 //  Modifies:
00239 //
00240 //----------------------------------------------------------------------------
00241
00242 STDMETHODIMP CGenericEnum::Reset()
00243 {
00244     m_pNextItem = m_pGenericItemList->pFirstGenericItem;
00245     return NOERROR;
00246 }
00247
00248
00249 //+---------------------------------------------------------------------------
00250 //
00251 //  Member:     CGenericEnum::Clone, public
00252 //
00253 //  Synopsis:
00254 //
00255 //  Arguments:
00256 //
00257 //  Returns:
00258 //
00259 //  Modifies:
00260 //
00261 //----------------------------------------------------------------------------
00262
00263 STDMETHODIMP CGenericEnum::Clone(CGenericEnum **ppenum)
00264 {
00265     return E_NOTIMPL;
00266 }
00267
00268
00269 // help functions for managing enum list
00270 // helper functions for managing the Generics list.
00271 // properly increments and destroys shared Genericlist in memory.
00272
00273
00274 //+---------------------------------------------------------------------------
00275 //
00276 //  Function:     AddRef_ItemList, public
00277 //
00278 //  Synopsis:
00279 //
00280 //  Arguments:
00281 //
00282 //  Returns:
00283 //
00284 //  Modifies:
00285 //
00286 //----------------------------------------------------------------------------
00287
00288 DWORD AddRef_ItemList(LPGENERICITEMLIST pGenericItemList)
00289 {
00290     return ++pGenericItemList->_cRefs;
00291 }
00292
00293 //+---------------------------------------------------------------------------
00294 //
00295 //  Function:     Release_ItemList, public
00296 //
00297 //  Synopsis:
00298 //
00299 //  Arguments:
00300 //
00301 //  Returns:
00302 //
00303 //  Modifies:
00304 //
00305 //----------------------------------------------------------------------------
00306
00307 DWORD Release_ItemList(LPGENERICITEMLIST pGenericItemList)
00308 {
00309 DWORD cRefs;
00310
00311     // bug, not threadsafe
00312     cRefs = --pGenericItemList->_cRefs;
00313
00314     if (0 == pGenericItemList->_cRefs)
00315     {
00316     LPGENERICITEM pCurItem = pGenericItemList->pFirstGenericItem;
00317
00318         while(pCurItem)
00319         {
00320         LPGENERICITEM pFreeItem = pCurItem;
00321
00322             pCurItem = pCurItem->pNextGenericItem;
00323             FREE(pFreeItem);
00324         }
00325
00326     FREE(pGenericItemList);
00327     }
00328
00329     return cRefs;
00330 }
00331
00332 //+---------------------------------------------------------------------------
00333 //
00334 //  Function:     CreateItemList, public
00335 //
00336 //  Synopsis: create an new list and initialize it to nothing
00337 //            and set the refcount to 1.
00338 //
00339 //  Arguments:
00340 //
00341 //  Returns:
00342 //
00343 //  Modifies:
00344 //
00345 //----------------------------------------------------------------------------
00346
00347 LPGENERICITEMLIST CreateItemList()
00348 {
00349 LPGENERICITEMLIST lpGenericList = (LPGENERICITEMLIST) ALLOC(sizeof(GENERICITEMLIST));
00350
00351     if (lpGenericList)
00352     {
00353     memset(lpGenericList,0,sizeof(GENERICITEMLIST));
00354     AddRef_ItemList(lpGenericList);
00355     }
00356
00357     return lpGenericList;
00358 }
00359
00360 //+---------------------------------------------------------------------------
00361 //
00362 //  Function:     DuplicateList, public
00363 //
00364 //  Synopsis:   Duplicates the list
00365 //
00366 //  Arguments:
00367 //
00368 //  Returns:
00369 //
00370 //  Modifies:
00371 //
00372 //----------------------------------------------------------------------------
00373
00374 LPGENERICITEMLIST DuplicateItemList(LPGENERICITEMLIST pItemList)
00375 {
00376 LPGENERICITEMLIST lpNewItemList;
00377 LPGENERICITEM pCurItem;
00378
00379     lpNewItemList = CreateItemList();
00380     if (!lpNewItemList)
00381     {
00382         return NULL;
00383     }
00384
00385     pCurItem = pItemList->pFirstGenericItem;
00386
00387     while (pCurItem)
00388     {
00389     LPGENERICITEM pNewItemInList;
00390
00391         Assert(pCurItem->cbSize >= sizeof(GENERICITEM));
00392
00393         pNewItemInList = CreateNewListItem(pCurItem->cbSize);
00394
00395         if (pNewItemInList)
00396         {
00397             memcpy(pNewItemInList,pCurItem,pCurItem->cbSize);
00398             pNewItemInList->pNextGenericItem = NULL;
00399             AddItemToList(lpNewItemList,pNewItemInList);
00400         }
00401
00402         pCurItem = pCurItem->pNextGenericItem;
00403     }
00404
00405     return lpNewItemList;
00406 }
00407
00408
00409 //+---------------------------------------------------------------------------
00410 //
00411 //  Function:     AddNewItemToList, public
00412 //
00413 //  Synopsis: allocates space for a new item and adds it to the list,
00414 //      if successfull returns pointer to new item so caller can initialize it.
00415 //
00416 //  Arguments:
00417 //
00418 //  Returns:
00419 //
00420 //  Modifies:
00421 //
00422 //----------------------------------------------------------------------------
00423
00424 LPGENERICITEM AddNewItemToList(LPGENERICITEMLIST lpGenericList,ULONG cbSize)
00425 {
00426 LPGENERICITEM pNewGenericItem;
00427
00428     pNewGenericItem = CreateNewListItem(cbSize);
00429
00430     if (pNewGenericItem)
00431     {
00432         if (!AddItemToList(lpGenericList,pNewGenericItem))
00433         {
00434             FREE(pNewGenericItem);
00435             pNewGenericItem = NULL;
00436         }
00437     }
00438
00439     return pNewGenericItem;
00440 }
00441
00442
00443 //+---------------------------------------------------------------------------
00444 //
00445 //  Function:     AddItemToList, public
00446 //
00447 //  Synopsis:
00448 //
00449 //  Arguments:
00450 //
00451 //  Returns:
00452 //
00453 //  Modifies:
00454 //
00455 //----------------------------------------------------------------------------
00456
00457 BOOL AddItemToList(LPGENERICITEMLIST lpGenericList,LPGENERICITEM pNewGenericItem)
00458 {
00459 LPGENERICITEM pGenericItem;
00460
00461     if (!pNewGenericItem || !lpGenericList)
00462     {
00463         Assert(lpGenericList);
00464         Assert(pNewGenericItem);
00465         return FALSE;
00466     }
00467
00468     if (pNewGenericItem)
00469     {
00470         Assert(pNewGenericItem->cbSize >= sizeof(GENERICITEM));
00471
00472         pGenericItem = lpGenericList->pFirstGenericItem;
00473
00474         if (NULL == pGenericItem)
00475         {
00476             lpGenericList->pFirstGenericItem = pNewGenericItem;
00477         }
00478         else
00479         {
00480             while (pGenericItem->pNextGenericItem)
00481                 pGenericItem = pGenericItem->pNextGenericItem;
00482
00483             pGenericItem->pNextGenericItem = pNewGenericItem;
00484
00485         }
00486
00487     ++lpGenericList->dwNumItems;
00488     }
00489
00490     return TRUE;
00491 }
00492
00493 //+---------------------------------------------------------------------------
00494 //
00495 //  Function:     DeleteItemFromList, public
00496 //
00497 //  Synopsis:
00498 //
00499 //  Arguments:
00500 //
00501 //  Returns:
00502 //
00503 //  Modifies:
00504 //
00505 //----------------------------------------------------------------------------
00506
00507 BOOL DeleteItemFromList(LPGENERICITEMLIST lpGenericList,LPGENERICITEM pGenericItem)
00508 {
00509
00510     if (!pGenericItem || !lpGenericList)
00511     {
00512         Assert(lpGenericList);
00513         Assert(pGenericItem);
00514         return FALSE;
00515     }
00516
00517     if (pGenericItem)
00518     {
00519     LPGENERICITEM pCurItem;
00520     GENERICITEM  GenericItemTempHead;
00521
00522         Assert(pGenericItem->cbSize >= sizeof(GENERICITEM));
00523
00524         GenericItemTempHead.pNextGenericItem = lpGenericList->pFirstGenericItem;
00525         pCurItem = &GenericItemTempHead;
00526
00527
00528         while(pCurItem->pNextGenericItem)
00529         {
00530
00531             if (pCurItem->pNextGenericItem == pGenericItem)
00532             {
00533
00534                 pCurItem->pNextGenericItem = pGenericItem->pNextGenericItem;
00535                 FREE(pGenericItem);
00536
00537
00538                 // update the head
00539                 lpGenericList->pFirstGenericItem = GenericItemTempHead.pNextGenericItem;
00540
00541                 // update the number of items in the list
00542                 --lpGenericList->dwNumItems;
00543
00544                 return TRUE;
00545             }
00546
00547             pCurItem = pCurItem->pNextGenericItem;
00548         }
00549
00550     }
00551
00552     AssertSz(0,"Didn't find item in List");
00553     return FALSE; // didn't find anything.
00554 }
00555
00556 //+---------------------------------------------------------------------------
00557 //
00558 //  Function:     CreateNewListItem, public
00559 //
00560 //  Synopsis:
00561 //
00562 //  Arguments:
00563 //
00564 //  Returns:
00565 //
00566 //  Modifies:
00567 //
00568 //----------------------------------------------------------------------------
00569
00570 LPGENERICITEM CreateNewListItem(ULONG cbSize)
00571 {
00572 LPGENERICITEM pNewGenericItem;
00573
00574     // size must be at least size of the base generic item.
00575     if (cbSize < sizeof(GENERICITEM))
00576     return NULL;
00577
00578      pNewGenericItem = (LPGENERICITEM) ALLOC(cbSize);
00579
00580     // add item to the end of the list so if commit we do
00581     // it in the same order items were added.
00582
00583     if (pNewGenericItem)
00584     {
00585     // initialize to zero, and then add it to the list.
00586     memset(pNewGenericItem,0,cbSize);
00587         pNewGenericItem->cbSize = cbSize;
00588     }
00589
00590     return pNewGenericItem;
00591 }
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/pluggable/plgterm.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • pluggable

plgterm.cpp

Go to the documentation of this file.
00001 // PlgTerm.cpp: implementation of the CPlgTermSample class.
00002 //
00003 //////////////////////////////////////////////////////////////////////
00004
00005 #include "stdafx.h"
00006 #include "PlgTerm.h"
00007 #include <initguid.h>
00008 #include "GUIDs.h"
00009 #include "PlgTermFilter.h"
00010 #include "PlgTermSample_i.c"
00011
00012 //////////////////////////////////////////////////////////////////////
00013 // Construction/Destruction
00014 //////////////////////////////////////////////////////////////////////
00015
00016 CPlgTermSample::CPlgTermSample()
00017   :m_pEventSink(NULL),
00018   m_bKnownSafeContext(FALSE)
00019 {
00020
00021   LOG((MSP_TRACE, "CPlgTermSample::CPlgTermSample enter"));
00022
00023 }
00024
00025
00026 //////////////////////////////////////////////////////////////////////////////
00027
00028
00029 CPlgTermSample::~CPlgTermSample()
00030 {
00031   LOG((MSP_TRACE, "CPlgTermSample::~CPlgTermSample enter"));
00032
00033     //
00034     // if we have an event sink, release it
00035     //
00036     if( NULL != m_pEventSink )
00037     {
00038     LOG((MSP_TRACE, "CPlgTermSample::~CPlgTermSample release sink"));
00039         m_pEventSink->Release();
00040         m_pEventSink = NULL;
00041     }
00042
00043     //
00044   // Release free thread marshaler
00045   //
00046     if( m_pFTM )
00047     {
00048         m_pFTM->Release();
00049         m_pFTM = NULL;
00050     }
00051
00052   LOG((MSP_TRACE, "CPlgTermSample::~CPlgTermSample exit"));
00053 }
00054
00055
00056     //
00057     // ITPlgSampleEvent methods
00058     //
00059
00060 HRESULT CPlgTermSample::FireEvent( long lEventCode)
00061 {
00062   LOG((MSP_TRACE, "CPlgTermSample::FireEvent enter"));
00063   //
00064     // we need a sink before we can fire an event
00065     //
00066
00067     CLock lock(m_CritSec);
00068
00069
00070     if (NULL == m_pEventSink)
00071     {
00072         LOG((MSP_ERROR, "CPlgTermSample::FireEvent no Sink - exit E_FAIL"));
00073         return E_FAIL;
00074     }
00075
00076
00077     //
00078     // initilize the structure
00079     //
00080
00081     MSP_EVENT_INFO mspEventInfo;
00082
00083     mspEventInfo.dwSize = sizeof(MSP_EVENT_INFO);
00084     mspEventInfo.Event = ME_PRIVATE_EVENT;
00085     mspEventInfo.hCall = NULL;
00086
00087     mspEventInfo.MSP_PRIVATE_EVENT_INFO.lEventCode = lEventCode;
00088
00089
00090     //
00091     // put the pointer to our IDispatch interface in the structure
00092     //
00093
00094     HRESULT hr = _InternalQueryInterface(IID_IDispatch,
00095                                          reinterpret_cast<void**>(&(mspEventInfo.MSP_PRIVATE_EVENT_INFO.pEvent)));
00096
00097     if (FAILED(hr))
00098     {
00099         LOG((MSP_ERROR, "CPlgTermSample::FireEvent failed to get IDispatch interface - exit hr=0x%08", hr));
00100         return hr;
00101     }
00102
00103     //
00104     // pass event to the msp
00105     //
00106
00107     hr = m_pEventSink->FireEvent(&mspEventInfo);
00108
00109     if (FAILED(hr))
00110     {
00111
00112         //
00113         // release all interfaces that we are holding.
00114         // fire event failed so no one else will release them for us.
00115         //
00116         mspEventInfo.MSP_PRIVATE_EVENT_INFO.pEvent->Release();
00117         mspEventInfo.MSP_PRIVATE_EVENT_INFO.pEvent=NULL;
00118
00119         LOG((MSP_ERROR, "CPlgTermSample::FireEvent on sink failed - exit hr=0x%08", hr));
00120
00121         return hr;
00122     }
00123
00124     //
00125     // event fired
00126     //
00127
00128     LOG((MSP_TRACE, "CPlgTermSample::FireEvent exit S_OK"));
00129
00130     return hr;
00131 }
00132
00133 //////////////////////////////////////////////////////////////////////
00134 //
00135 // ITPluggableTerminalEventSinkRegistration - Methods implementation
00136 //
00137 //////////////////////////////////////////////////////////////////////
00138
00139 HRESULT CPlgTermSample::RegisterSink(
00140     IN  ITPluggableTerminalEventSink *pSink
00141     )
00142 {
00143   LOG((MSP_TRACE, "CPlgTermSample::RegisterSink enter"));
00144
00145     //
00146     // Critical section
00147     //
00148
00149     CLock lock(m_CritSec);
00150
00151     //
00152     // Validates argument
00153     //
00154
00155     if( IsBadReadPtr( pSink, sizeof(ITPluggableTerminalEventSink)) )
00156     {
00157         LOG((MSP_ERROR, "CPlgTermSample::RegisterSink - "
00158       "ITPluggableTerminalEventSink invalid pointer - exit 0x%08x", E_POINTER));
00159         return E_POINTER;
00160     }
00161
00162     //
00163     // Release the old event sink
00164     //
00165
00166     if( NULL != m_pEventSink )
00167     {
00168         LOG((MSP_TRACE, "CPlgTermSample::RegisterSink - releasing sink [%p]",m_pEventSink));
00169         m_pEventSink->Release();
00170         m_pEventSink = NULL;
00171     }
00172
00173
00174     //
00175     // Set the new event sink
00176     //
00177
00178   LOG((MSP_TRACE, "CPlgTermSample::RegisterSink - keeping new sink [%p]",pSink));
00179
00180     m_pEventSink = pSink;
00181     m_pEventSink->AddRef();
00182
00183
00184     LOG((MSP_TRACE, "CPlgTermSample::RegisterSink exit - S_OK"));
00185
00186     return S_OK;
00187 }
00188
00189
00190 HRESULT CPlgTermSample::UnregisterSink()
00191 {
00192     LOG((MSP_TRACE, "CPlgTermSample::UnregisterSink enter"));
00193     //
00194     // Critical section
00195     //
00196
00197     CLock lock(m_CritSec);
00198
00199
00200     //
00201     // Release the old event sink
00202     //
00203
00204     if( m_pEventSink )
00205     {
00206         LOG((MSP_TRACE, "CPlgTermSample::RegisterSink - releasing sink [%p]",m_pEventSink));
00207         m_pEventSink->Release();
00208         m_pEventSink = NULL;
00209     }
00210
00211     LOG((MSP_TRACE, "CPlgTermSample::UnregisterSink - exit S_OK"));
00212     return S_OK;
00213 }
00214
00215
00216
00217 //////////////////////////////////////////////////////////////////////////////
00218
00219
00220 HRESULT STDMETHODCALLTYPE CPlgTermSample::InitializeDynamic(
00221       IN  IID                   iidTerminalClass,
00222       IN  DWORD                 dwMediaType,
00223       IN  TERMINAL_DIRECTION    Direction,
00224         IN  MSP_HANDLE            htAddress
00225         )
00226
00227 {
00228
00229     LOG((MSP_TRACE, "CPlgTermSample::InitializeDynamic enter"));
00230
00231     //
00232     // make sure the direction is correct - we register it with this direction
00233     //
00234
00235     if (TD_RENDER != Direction)
00236     {
00237         LOG((MSP_ERROR, "CPlgTermSample::InitializeDynamic"
00238         " - bad direction [%d] requested. returning 0x%08x",
00239         Direction, E_INVALIDARG));
00240
00241         return E_INVALIDARG;
00242     }
00243
00244
00245     //
00246     // make sure the mediatype is correct - TAPIMEDIATYPE_AUDIO - is how we set it in registry
00247     //
00248
00249
00250     if ( TAPIMEDIATYPE_AUDIO != dwMediaType)
00251     {
00252
00253         LOG((MSP_ERROR, "CPlgTermSample::InitializeDynamic"
00254         " - bad media type [%d] requested. returning 0x%08x",
00255         dwMediaType, E_INVALIDARG));
00256
00257         return E_INVALIDARG;
00258     }
00259
00260
00261     CLock lock(m_CritSec);
00262
00263     //
00264     // Call the base class method
00265     //
00266     LOG((MSP_TRACE, "CPlgTermSample::InitializeDynamic - CBaseTerminal::Initialize with"
00267                 "dwMediaType = 0x%08x, Direction = 0x%08x", dwMediaType, Direction));
00268
00269     HRESULT hr;
00270     hr = CBaseTerminal::Initialize(iidTerminalClass,
00271                                    dwMediaType,
00272                                    Direction,
00273                                    htAddress);
00274
00275     if ( FAILED(hr) )
00276     {
00277         LOG((MSP_ERROR, "CPlgTermSample::InitializeDynamic - "
00278                 "base class method failed - 0x%08x", hr));
00279         return hr;
00280     }
00281
00282     //
00283     // Set the terminal info
00284     //
00285
00286     hr = SetTerminalInfo();
00287     if( FAILED(hr) )
00288     {
00289         LOG((MSP_ERROR, "CPlgTermSample::InitializeDynamic - "
00290                 "SetTerminalInfo failed - 0x%08x", hr));
00291
00292         return hr;
00293     }
00294
00295     //
00296     // Create the filter
00297     //
00298
00299     hr = CreateFilter();
00300
00301     if( FAILED(hr) )
00302     {
00303         LOG((MSP_ERROR, "CPlgTermSample::InitializeDynamic - "
00304         "CreateFilter failed - 0x%08x", hr));
00305         return hr;
00306     }
00307
00308     //
00309     // Get and sets the pin
00310     //
00311
00312     hr = FindPin();
00313
00314     if( FAILED(hr) )
00315     {
00316         LOG((MSP_ERROR, "CPlgTermSample::InitializeDynamic - "
00317             "FindPin failed - 0x%08x", hr));
00318     }
00319
00320     m_bKnownSafeContext = TRUE;
00321
00322   LOG((MSP_TRACE, "CPlgTermSample::InitializeDynamic exit - 0x%08x", hr));
00323     return hr;
00324
00325 }
00326
00327
00328 //////////////////////////////////////////////////////////////////////////////
00329
00330
00331 DWORD CPlgTermSample::GetSupportedMediaTypes()
00332 {
00333
00334     LOG((MSP_TRACE, "CPlgTermSample::GetSupportedMediaTypes enter "));
00335
00336     CLock lock(m_CritSec);
00337
00338
00339     DWORD dwMediaType = TAPIMEDIATYPE_AUDIO; //we set this in registry
00340
00341
00342     LOG((MSP_TRACE, "CPlgTermSample::GetSupportedMediaTypes exit - S_OK "));
00343
00344
00345     return dwMediaType;
00346 }
00347
00348
00349
00350 //////////////////////////////////////////////////////////////////////////////
00351
00352
00353 HRESULT CPlgTermSample::AddFiltersToGraph()
00354 {
00355     LOG((MSP_TRACE, "CPlgTermSample::AddFiltersToGraph enter "));
00356
00357     USES_CONVERSION;
00358
00359     //
00360     // Validates m_pGraph
00361     //
00362
00363     if ( m_pGraph == NULL)
00364     {
00365         LOG((MSP_ERROR, "CPlgTermSample::AddFiltersToGraph - "
00366         "we have no graph - returning 0x%08x", E_UNEXPECTED));
00367         return E_UNEXPECTED;
00368     }
00369
00370     //
00371     // Validates m_pIFilter
00372     //
00373
00374     if ( m_pIFilter == NULL)
00375     {
00376         LOG((MSP_ERROR, "CPlgTermSample::AddFiltersToGraph - "
00377         "we have no filter - returning 0x%08x", E_UNEXPECTED));
00378         return E_UNEXPECTED;
00379     }
00380
00381     CLock lock(m_CritSec);
00382
00383     //
00384     // AddFilter returns VFW_S_DUPLICATE_NAME if name is duplicate; still succeeds
00385     //
00386
00387     HRESULT hr = m_pGraph->AddFilter(m_pIFilter, T2CW(m_szName));
00388
00389     if ( FAILED(hr) )
00390     {
00391         LOG((MSP_ERROR, "CPlgTermSample::AddFiltersToGraph - "
00392         "can not add filter "));
00393
00394     }
00395
00396     LOG((MSP_TRACE, "CPlgTermSample::AddFiltersToGraph - exit %08x", hr));
00397     return hr;
00398 }
00399 /*++
00400 SetTerminalInfo
00401
00402 Sets the name of the terminal and the terminal type
00403 Is called by InitializeDynamic
00404 --*/
00405 HRESULT CPlgTermSample::SetTerminalInfo()
00406 {
00407     LOG((MSP_TRACE, "CPlgTermSample::SetTerminalInfo - enter"));
00408
00409   //
00410     // set terminals's name for ITTerminal::get_Name
00411     //
00412
00413     size_t nStringMaxSize = sizeof(m_szName)/sizeof(TCHAR);
00414
00415     _tcsncpy(m_szName, SZTERMNAME, min(_tcslen(SZTERMNAME), nStringMaxSize));
00416
00417
00418     //
00419     // in case string copy did not append with a zero, do it by hand
00420     //
00421
00422     m_szName[min(_tcslen(SZTERMNAME), nStringMaxSize - 1)] = 0;
00423
00424     //
00425     // set other properties
00426     //
00427
00428     m_TerminalType = TT_DYNAMIC;
00429
00430     m_TerminalState = TS_NOTINUSE;
00431
00432     LOG((MSP_TRACE, "CPlgTermSample::SetTerminalInfo - exit S_OK"));
00433
00434     return S_OK;
00435 }
00436
00437
00438 /*++
00439 CreateFilter
00440
00441 Create the internal filter
00442 Is called by InitializeDynamic
00443 --*/
00444 HRESULT CPlgTermSample::CreateFilter()
00445 {
00446     LOG((MSP_TRACE, "CPlgTermSample::CreateFilter - enter"));
00447
00448     // Create the filter
00449     CPlgFilter* pFilter = new CPlgFilter();
00450
00451     if( NULL == pFilter )
00452     {
00453         LOG((MSP_ERROR, "CPlgTermSample::CreateFilter - "
00454                 "create filter failed - returning 0x%08x", E_OUTOFMEMORY));
00455         return E_OUTOFMEMORY;
00456     }
00457
00458     // COM Rule
00459     pFilter->AddRef();
00460
00461   //
00462   // Get the pin
00463   //
00464
00465   HRESULT hr = pFilter->Initialize( );
00466     if( FAILED(hr) )
00467     {
00468         LOG((MSP_ERROR, "CPlgTermSample::CreateFilter - "
00469                 "Initialize private failed - returning 0x%08x", hr));
00470     pFilter->Release();
00471         return hr;
00472     }
00473
00474
00475     //
00476     // Get the IBaseFilter interface
00477     //
00478
00479     hr = pFilter->QueryInterface(
00480         IID_IBaseFilter,
00481         (void**)&m_pIFilter
00482         );
00483
00484     if( FAILED(hr) )
00485     {
00486         LOG((MSP_ERROR, "CPlgTermSample::CreateFilter - "
00487             "QI for IBaseFilter failed"));
00488     }
00489     else
00490     {
00491         pFilter->InitializePrivate(this);
00492     }
00493
00494     pFilter->Release();
00495
00496     LOG((MSP_TRACE, "CPlgTermSample::CreateFilter - exit 0x%08x", hr));
00497     return hr;
00498 }
00499
00500 /*++
00501 FindPin
00502
00503 Get the pin from the filter and set the m_pIPin member
00504 Is called by InitializeDynamic
00505 --*/
00506 HRESULT CPlgTermSample::FindPin()
00507 {
00508     LOG((MSP_TRACE, "CPlgTermSample::FindPin - enter"));
00509
00510     //
00511     // Validates the filter object (smart pointer)
00512     //
00513
00514     if (m_pIFilter == NULL)
00515     {
00516         LOG((MSP_ERROR, "CPlgTermSample::FindPin - "
00517         "filter object is NULL - returning 0x%08x", E_UNEXPECTED));
00518         return E_UNEXPECTED;
00519     }
00520
00521     //
00522     // Make sure the IPin object is not initialized
00523     //
00524
00525     if (m_pIPin != NULL)
00526     {
00527         LOG((MSP_ERROR, "CPlgTermSample::FindPin - "
00528         "already got a pin - returning 0x%08x", E_UNEXPECTED));
00529         return E_UNEXPECTED;
00530     }
00531
00532     HRESULT hr;
00533     IEnumPins* pIEnumPins;
00534     ULONG cFetched;
00535
00536     //
00537     // Get the pins collection
00538     //
00539
00540     if (FAILED(hr = m_pIFilter->EnumPins(&pIEnumPins)))
00541     {
00542         LOG((MSP_ERROR, "CPlgTermSample::FindPin - "
00543         "cannot enum pins - returning 0x%08x", hr));
00544         return hr;
00545     }
00546
00547     //
00548     // Get the out pin of the Pluggable Filter
00549     //
00550
00551     if (S_OK != (hr = pIEnumPins->Next(1, &m_pIPin, &cFetched)))
00552     {
00553         LOG((MSP_ERROR, "CPlgTermSample::FindPin - "
00554         "cannot get a pin - returning 0x%08x", hr));
00555
00556         hr = (hr == S_FALSE) ? E_FAIL : hr;
00557     }
00558
00559     LOG((MSP_TRACE, "CPlgTermSample::FindPin - exit 0x%08x", hr));
00560     return S_OK;
00561 }
00562
00563
00564
00565 //////////////////////////////////////////////////////////////////////////////
00566 //
00567 //  SetInterfaceSafetyOptions
00568 //
00569 //  this is a safeguard to prevent using this terminal in scripting outside
00570 //  terminal manager context.
00571 //
00572 //  if we detect that InitializeDynamic has not been called, this method will
00573 //  fail thus marking the object as unsafe for scripting
00574 //
00575 //////////////////////////////////////////////////////////////////////////////
00576
00577 HRESULT CPlgTermSample::SetInterfaceSafetyOptions(REFIID riid,
00578                                                     DWORD dwOptionSetMask,
00579                                                     DWORD dwEnabledOptions)
00580 {
00581
00582     CLock lock(m_CritSec);
00583
00584
00585     //
00586     // check if we are running in safe context
00587     //
00588
00589     if (!m_bKnownSafeContext)
00590     {
00591
00592         //
00593         // we have not been initialized properly... someone evil is trying to
00594         // use this terminal. NO!
00595         //
00596
00597         return E_FAIL;
00598     }
00599
00600
00601     //
00602     // we are known to safe, so simply delegate request to the base class
00603     //
00604
00605     return CMSPObjectSafetyImpl::SetInterfaceSafetyOptions(riid,
00606                                                            dwOptionSetMask,
00607                                                            dwEnabledOptions);
00608 }
00609
00610
00611 //////////////////////////////////////////////////////////////////////////////
00612 //
00613 //  GetInterfaceSafetyOptions
00614 //
00615 //  this is a safeguard to prevent using this terminal in scripting outside
00616 //  terminal manager context.
00617 //
00618 //  if we detect that InitializeDynamic has not been called, this method will
00619 //  fail thus marking the object as unsafe for scripting
00620 //
00621 //////////////////////////////////////////////////////////////////////////////
00622
00623 HRESULT CPlgTermSample::GetInterfaceSafetyOptions(REFIID riid,
00624                                                     DWORD *pdwSupportedOptions,
00625                                                     DWORD *pdwEnabledOptions)
00626 {
00627
00628     CLock lock(m_CritSec);
00629
00630
00631     //
00632     // check if we are running in safe context
00633     //
00634
00635     if (!m_bKnownSafeContext)
00636     {
00637
00638         //
00639         // we have not been initialized properly... someone evil is trying to
00640         // use this terminal. NO!
00641         //
00642
00643         return E_FAIL;
00644     }
00645
00646
00647     //
00648     // we are known to safe, so simply delegate request to the base class
00649     //
00650
00651     return CMSPObjectSafetyImpl::GetInterfaceSafetyOptions(riid,
00652                                                            pdwSupportedOptions,
00653                                                            pdwEnabledOptions);
00654 }
00655
00656
00657
00658 HRESULT CPlgTermSample::FinalConstruct(void)
00659 {
00660     LOG((MSP_TRACE, "CPlgTermSample::FinalConstruct - enter"));
00661
00662     HRESULT hr = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
00663                                                 & m_pFTM );
00664
00665     if ( FAILED(hr) )
00666     {
00667         LOG((MSP_ERROR, "CFPTerminal::FinalConstruct - "
00668             "create FTM returned 0x%08x; exit", hr));
00669
00670         return hr;
00671     }
00672
00673     LOG((MSP_TRACE, "CPlgTermSample::FinalConstruct - exit S_OK"));
00674
00675     return S_OK;
00676
00677 }
00678
00679 // eof
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/RequestCert/RequestCert.Cpp Source File

  • Security
  • CertServices
  • RequestCert

RequestCert.Cpp

Go to the documentation of this file.
00001 /*======================================================================
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00003 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00004 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00005 PURPOSE.
00006
00007 Copyright 1998 - 2000. Microsoft Corporation.  All Right Reserved.
00008
00009 Module Name:
00010     RequestCert.cpp
00011
00012 Abstract:
00013     Requests certificate from Microsoft Certificate Server
00014
00015 History
00016     Created     June 1998
00017 =======================================================================*/
00018
00019
00020 // Include Headers
00021 #include <windows.h>
00022 #include <stdio.h>
00023 #include <tchar.h>
00024 #include <wincrypt.h>
00025 #include <objbase.h>
00026 #include <certsrv.h>
00027 #include <xenroll.h>
00028
00029 #define BUFFERSIZE   512
00030 void PrintUsage(void);
00031
00032 // Global variables
00033 TCHAR szCertReq[BUFFERSIZE];
00034 WCHAR szwTempBuffer[BUFFERSIZE];
00035
00036 // ProgID for ICEnroll control
00037 OLECHAR *ICEnrollProgID = OLESTR("CEnroll.CEnroll.1");
00038
00039 extern "C"
00040 void _cdecl _tmain(int argc, TCHAR *argv[])
00041 {
00042    HRESULT hr;
00043    ICEnroll4 *CertEnroll = NULL;
00044    ICertRequest *CertRequest = NULL;
00045    ICertConfig *CertConfig = NULL;
00046    CLSID CLSID_CCertEnroll;
00047    BSTR pPKCS10 = NULL, pConfig = NULL, pPKCS7 = NULL;
00048    BSTR bstrTemp = NULL;
00049    BSTR bstrCertReq = NULL;
00050    LONG Disposition, RequestId;
00051    int n;
00052
00053    __try {
00054       if (argc == 1)
00055       {
00056          PrintUsage();
00057          return;
00058       }
00059
00060       // Append Common name to Certificate request string
00061       lstrcpy(szCertReq, TEXT("CN="));
00062       lstrcat(szCertReq, argv[1]);
00063
00064       // Parse command line and append to Certificate Request String
00065       for (n = 2; n < argc; n++)
00066       {
00067          // Append common string identifier
00068          if (lstrcmp(argv[n], TEXT("/ou")) == 0) lstrcat(szCertReq, TEXT(",OU="));
00069          else if (lstrcmp(argv[n], TEXT("/o")) == 0) lstrcat(szCertReq, TEXT(",O="));
00070          else if (lstrcmp(argv[n], TEXT("/l")) == 0) lstrcat(szCertReq, TEXT(",L="));
00071          else if (lstrcmp(argv[n], TEXT("/s")) == 0) lstrcat(szCertReq, TEXT(",S="));
00072          else if (lstrcmp(argv[n], TEXT("/c")) == 0) lstrcat(szCertReq, TEXT(",C="));
00073          else if (lstrcmp(argv[n], TEXT("/e")) == 0) lstrcat(szCertReq, TEXT(",E="));
00074          else
00075          {
00076             PrintUsage();
00077             return;
00078          }
00079
00080          // Append string
00081          if ((n + 1) < argc) lstrcat(szCertReq, argv[++n]);
00082          else
00083          {
00084             PrintUsage();
00085             return;
00086          }
00087       }
00088
00089       // Convert Certificate Request String to BSTR
00090 #ifdef UNICODE
00091       bstrCertReq = SysAllocString(szCertReq);
00092 #else
00093       n = MultiByteToWideChar(CP_ACP, 0, szCertReq, -1, szwTempBuffer, BUFFERSIZE);
00094       if (n == 0)
00095       {
00096             _tprintf(TEXT("MultiByteToWideChar failed with %d\n"), GetLastError());
00097             __leave;
00098       }
00099       bstrCertReq = SysAllocString(szwTempBuffer);
00100 #endif
00101
00102       // Initialize COM library
00103       hr = CoInitialize(NULL);
00104       if (FAILED(hr))
00105       {
00106             _tprintf(TEXT("CoInitialize failed\n"));
00107             __leave;
00108       }
00109
00110       // Get CLSID for ICEnroll
00111       hr = CLSIDFromProgID(ICEnrollProgID, &CLSID_CCertEnroll);
00112       if (FAILED(hr))
00113       {
00114          _tprintf(TEXT("CLSIDFromProgID failed\n"));
00115          __leave;
00116       }
00117
00118       // get pointer to ICEnroll interface
00119       hr = CoCreateInstance(
00120                CLSID_CCertEnroll,
00121                NULL,
00122                CLSCTX_INPROC_SERVER,
00123                IID_ICEnroll4,
00124                (void **)&CertEnroll);
00125       if (FAILED(hr))
00126       {
00127          _tprintf(TEXT("CoCreateInstance with IID_ICEnroll4 failed\n"));
00128          __leave;
00129       }
00130
00131       // get pointer to ICertRequest interface
00132       hr = CoCreateInstance(
00133                 CLSID_CCertRequest,
00134                 NULL,
00135                 CLSCTX_INPROC_SERVER,
00136                 IID_ICertRequest,
00137                 (void **)&CertRequest);
00138       if (FAILED(hr))
00139       {
00140             _tprintf(TEXT("CoCreateInstance with IID_ICertRequest failed\n"));
00141             __leave;
00142       }
00143
00144       // get pointer to ICertConfig interface
00145       hr = CoCreateInstance(
00146                 CLSID_CCertConfig,
00147                 NULL,
00148                 CLSCTX_INPROC_SERVER,
00149                 IID_ICertConfig,
00150                 (void **)&CertConfig);
00151       if (FAILED(hr))
00152       {
00153          _tprintf(TEXT("CoCreateInstance with IID_ICertConfig failed\n"));
00154          __leave;
00155       }
00156
00157       // Set KeySpec to be Exchange key
00158       // An exchange key makes this certificate a client certificate.
00159       // The server encrypts something with the certificate's
00160       // public key. The client can decrypt it with the private key
00161       // and verify itself
00162       hr = CertEnroll->put_KeySpec(AT_KEYEXCHANGE);
00163       if (FAILED(hr))
00164       {
00165          _tprintf(TEXT("CertEnroll->putKeySpec failed\n"));
00166          __leave;
00167       }
00168
00169       // Create Certificate Request (PKCS10)
00170       // Second paramter is the OID that describes the purpose of the certificate.
00171       // 1.3.6.1.5.5.7.3.2 is the OID for Client Authentication
00172       // 1.3.6.1.5.5.7.3.3 is the OID for Code Signing
00173       // 1.3.6.1.5.5.7.3.1 is the OID for Server Authentication
00174       // 1.3.6.1.5.5.7.3.4 is the OID for email protection
00175       bstrTemp = SysAllocString(OLESTR("1.3.6.1.5.5.7.3.2"));
00176       hr = CertEnroll->createPKCS10(
00177                 bstrCertReq,
00178                 bstrTemp,
00179                 &pPKCS10);
00180       if (FAILED(hr))
00181       {
00182          _tprintf(TEXT("CertEnroll->CreatePKCS10 failed\n"));
00183          __leave;
00184       }
00185       SysFreeString(bstrTemp);
00186       bstrTemp = NULL;
00187
00188       // Get Default configuration
00189       hr = CertConfig->GetConfig(0, &pConfig);
00190       if (FAILED(hr))
00191       {
00192          _tprintf(TEXT("CertConfig->GetConfig failed\n"));
00193          __leave;
00194       }
00195
00196       // Submit the Certificate Request
00197       // Second parameter specifies the attributes for the
00198       // certificate request. We don't set any attributes
00199       // in this sample.  Attributes may be a BSTR of type
00200       // "AttributeName1:AttributeValue1\nAttributeName2:AttributeValue2"
00201       // where each attribute is a name/value pair separated
00202       // by new line characters.
00203       bstrTemp = SysAllocString(OLESTR(""));
00204       hr = CertRequest->Submit(
00205                 CR_IN_BASE64|CR_IN_PKCS10,
00206                 pPKCS10,
00207                 bstrTemp,
00208                 pConfig,
00209                 &Disposition);
00210       if (FAILED(hr))
00211       {
00212          _tprintf(TEXT("CertRequest->Submit failed\n"));
00213          __leave;
00214       }
00215       SysFreeString(bstrTemp);
00216       bstrTemp = NULL;
00217
00218       _tprintf(TEXT("Certificate request submitted\n"));
00219
00220       // if Certificate Server issued certificate Get Certificate
00221       if (Disposition == CR_DISP_ISSUED)
00222       {
00223          // Get the issued Certificate in a BASE64 PKCS#7 message
00224          hr = CertRequest->GetCertificate(CR_OUT_BASE64 | CR_OUT_CHAIN, &pPKCS7);
00225          if (FAILED(hr))
00226          {
00227             _tprintf(TEXT("CertRequest->GetCertificate failed\n"));
00228             __leave;
00229          }
00230
00231          // save PKCS#7 message to file in binary format when accepting it
00232          // This is not necessary, but can be used later to look at the
00233          // certificate information.
00234          bstrTemp = SysAllocString(OLESTR("PKCS7BinaryFile"));
00235          hr = CertEnroll->put_SPCFileName(bstrTemp);
00236          if (FAILED(hr))
00237          {
00238             _tprintf(TEXT("CertEnroll->put_SPCFileName failed\n"));
00239             __leave;
00240          }
00241          SysFreeString(bstrTemp);
00242          bstrTemp = NULL;
00243
00244          // accept the encoded certificate and place it in the store
00245          // The store will automatically be the "MY" store.
00246          // This behavior can be change by setting the
00247          // CertEnroll::MyStoreName property.  Use
00248          // CertEnroll::put_MyStoreName when using C++
00249          hr = CertEnroll->acceptPKCS7(pPKCS7);
00250          if (FAILED(hr))
00251          {
00252             _tprintf(TEXT("CertEnroll->acceptPKCS7 failed\n"));
00253             __leave;
00254          }
00255
00256          _tprintf(TEXT("Certificate accepted and installed\n"));
00257       }
00258       else
00259       {
00260          // Certificate Server did not issue certificate
00261          _tprintf(TEXT("Certificate Server did not issue certificate\n"));
00262          _tprintf(TEXT("Dispostion returned:\n"));
00263
00264          // Get Disposition message
00265          hr = CertRequest->GetDispositionMessage(&bstrTemp);
00266          if (FAILED(hr))
00267          {
00268             _tprintf(TEXT("CertRequest->GetDispositionMessage failed\n"));
00269             __leave;
00270          }
00271
00272          wcscpy(szwTempBuffer, bstrTemp);
00273          wprintf(szwTempBuffer);
00274          wprintf(L"\n");
00275          SysFreeString(bstrTemp);
00276          bstrTemp = NULL;
00277       }
00278
00279       // Get Request Id
00280       hr = CertRequest->GetRequestId(&RequestId);
00281       if (FAILED(hr))
00282       {
00283          _tprintf(TEXT("CertRequest->GetRequestId failed\n"));
00284          __leave;
00285       }
00286
00287       // Display request Id
00288       _tprintf(TEXT("Request Id = %d\n"), RequestId);
00289
00290    }
00291    __finally {
00292       // Clean up
00293       if (CertEnroll != NULL) CertEnroll->Release();
00294       if (CertRequest != NULL) CertRequest->Release();
00295       if (CertConfig != NULL) CertConfig->Release();
00296       if (bstrCertReq != NULL) SysFreeString(bstrCertReq);
00297       if (pPKCS10 != NULL) SysFreeString(pPKCS10);
00298       if (pPKCS7 != NULL) SysFreeString(pPKCS7);
00299       if (pConfig != NULL) SysFreeString(pConfig);
00300       if (bstrTemp != NULL) SysFreeString(bstrTemp);
00301       CoUninitialize();
00302    }
00303 }
00304
00305 /*---------------------------------------------------------------
00306  Print Program's Usage
00307 ----------------------------------------------------------------*/
00308 void PrintUsage(void)
00309 {
00310    _tprintf(TEXT("Usage : RequestCert <common name> [options]\n"));
00311    _tprintf(TEXT("options:\n\t/ou <organizational unit>\n"));
00312    _tprintf(TEXT("\t/o <organization>\n"));
00313    _tprintf(TEXT("\t/l <locale>\n"));
00314    _tprintf(TEXT("\t/s <state>\n"));
00315    _tprintf(TEXT("\t/c <country>\n"));
00316    _tprintf(TEXT("\t/e <email address>\n"));
00317 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COL Member List

This is the complete list of members for COL, including all inherited members.
dwWidth | COL
lpsz | COL
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminAuthenticationCapabilitiesOptions.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminAuthenticationCapabilitiesOptions.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminAuthenticationCapabilitiesOptions
00019
00020 public interface COMAdminAuthenticationCapabilitiesOptions
00021 {
00022   public static final int COMAdminAuthenticationCapabilitiesNone = 0;
00023   public static final int COMAdminAuthenticationCapabilitiesStaticCloaking = 32;
00024   public static final int COMAdminAuthenticationCapabilitiesDynamicCloaking = 64;
00025   public static final int COMAdminAuthenticationCapabilitiesSecureReference = 2;
00026 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/RPCssm/RPCssm.Idl Source File

  • NetDS
  • RPC
  • RPCssm

RPCssm.Idl

Go to the documentation of this file.
00001 [ uuid (A4F1DB00-CA47-1067-B31F-00DD010662DA),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface rpcssm
00006 {
00007
00008 /* =======================================================================
00009                        data types
00010 ======================================================================= */
00011
00012 const short LIST_SIZE = 4;
00013
00014 typedef struct _lbox {
00015     long               data;
00016     struct _lbox *     next;
00017 } LBOX, * PBOX;
00018
00019 /* =======================================================================
00020                       remote procedures
00021 ======================================================================= */
00022
00023 void
00024 InOutList( [in,out] PBOX  *  ppBox );
00025
00026 void Shutdown(void);
00027
00028 }
00029 
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/llistimpl.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

llistimpl.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.cpp: implementation of CLListImpl helper functions
00013 //
00014
00015
00016 #include "LListImpl.h"
00017
00018
00019 //---------------------------------------------------------------------------
00020 CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
00021 {
00022   _ASSERT( nMax > 0 && cbElement > 0 );
00023   CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
00024       // may throw exception
00025   p->pNext = pHead;
00026   pHead = p;  // change head (adds in reverse order for simplicity)
00027   return p;
00028
00029 } //end Create()
00030
00031 //---------------------------------------------------------------------------
00032 // Free this one and links
00033 //
00034 void CPlex::FreeDataChain()
00035 {
00036   CPlex* p = this;
00037   while (p != NULL)
00038   {
00039     BYTE* bytes = (BYTE*) p;
00040     CPlex* pNext = p->pNext;
00041     delete[] bytes;
00042     p = pNext;
00043   }
00044 } //end FreeDataChain()
00045
00046 //---------------------------------------------------------------------------
00047 // IsValidAddress() returns TRUE if the passed parameter points
00048 // to at least nBytes of accessible memory. If bReadWrite is TRUE,
00049 // the memory must be writeable; if bReadWrite is FALSE, the memory
00050 // may be const.
00051 //
00052 BOOL IsValidAddress
00053 (
00054   const void*  lp,
00055   UINT         nBytes,
00056   BOOL         bReadWrite /* TRUE */
00057 )
00058 {
00059   // Simple version using Win-32 APIs for pointer validation.
00060   return (lp != NULL && !IsBadReadPtr(lp, nBytes) &&
00061          (!bReadWrite || !IsBadWritePtr((LPVOID)lp, nBytes)));
00062
00063 } //end IsValidAddress()
00064
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEntity Member List

This is the complete list of members for CEntity, including all inherited members.
_NewEnum(LPUNKNOWN *pVal) | CEntity |
Add(VARIANT *pItem, VARIANT *pKey=&vtMissing, VARIANT *pBefore=&vtMissing, VARIANT *pAfter=&vtMissing) | CEntity |
Append(VARIANT *pItem, VARIANT *pKey) | CEntity |
CEntity() | CEntity | [inline]
Clear() | CEntity |
ClearArrays() | CEntity | [private]
Count(long *pVal) | CEntity |
DECLARE_FIXED_ALLOC(CEntity) | CEntity | [private]
DisconnectObject(DWORD dwReserved) | CEntity | [inline]
ExtractParams(WCHAR *wszParams) | CEntity | [private]
get_DeleteCommand(BSTR *pVal) | CEntity |
get_DeleteStoredProcedure(BSTR *pVal) | CEntity |
get_EditMode(ColEditModeEnum *pVal) | CEntity |
get_Field(VARIANT *Index, VARIANT *pVal) | CEntity |
get_InsertCommand(BSTR *pVal) | CEntity |
get_InsertStoredProcedure(BSTR *pVal) | CEntity |
get_Key(long Index, BSTR *pVal) | CEntity |
get_KeyField(BSTR *pVal) | CEntity |
get_ReadCommand(BSTR *pVal) | CEntity |
get_ReadStoredProcedure(BSTR *pVal) | CEntity |
get_UpdateCommand(BSTR *pVal) | CEntity |
get_UpdateStoredProcedure(BSTR *pVal) | CEntity |
GetClassID(GUID *pClassID) | CEntity | [inline]
GetMarshalSizeMax(REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags, ULONG *pSize) | CEntity | [inline]
GetPersistSize(bool bWithMetaData=true) | CEntity | [inline]
GetPersistSizeMax(_ULARGE_INTEGER *pCbSize, bool bWithMetaData=true) | CEntity | [inline]
GetSizeMax(_ULARGE_INTEGER *pCbSize) | CEntity | [inline]
GetUnmarshalClass(REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags, CLSID *pCid) | CEntity | [inline]
Initialize(long Size) | CEntity |
InitNew() | CEntity | [inline]
Insert(long Index, BSTR Key, VARIANT *Value) | CEntity |
InterfaceSupportsErrorInfo(REFIID riid) | CEntity |
InternalInsert(long Index, LPCWSTR wszKey, VARIANT *pValue, VARTYPE vt) | CEntity |
InternalInsert(long Index, LPCWSTR wszKey, WCHAR *wszValue) | CEntity |
InternalInsert(long Index, LPCWSTR wszKey, long *pnValue) | CEntity |
IsDirty() | CEntity | [inline]
Item(VARIANT *pIndex, VARIANT *pVal) | CEntity |
Load(IStream *pStm) | CEntity | [inline]
LoadFromStream(IStream *pStm, bool bWithMetaData=true) | CEntity | [inline]
m_bRequiresSave | CEntity | [private]
m_EditMode | CEntity | [private]
m_keyMap | CEntity |
m_nCount | CEntity | [private]
m_nMaxCount | CEntity | [private]
m_pContents | CEntity |
m_Type | CEntity |
m_wszDeleteStoredProc | CEntity |
m_wszInsertStoredProc | CEntity |
m_wszKeyField | CEntity |
m_wszReadStoredProc | CEntity |
m_wszUpdateStoredProc | CEntity |
MarshalInterface(IStream *pStm, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags) | CEntity | [inline]
put_DeleteStoredProcedure(BSTR newVal) | CEntity |
put_EditMode(ColEditModeEnum newVal) | CEntity |
put_Field(VARIANT *Index, VARIANT *newVal) | CEntity |
put_InsertStoredProcedure(BSTR newVal) | CEntity |
put_Key(long Index, BSTR newVal) | CEntity |
put_KeyField(BSTR newVal) | CEntity |
put_ReadStoredProcedure(BSTR newVal) | CEntity |
put_Recordset(_Recordset *newVal) | CEntity |
put_UpdateStoredProcedure(BSTR newVal) | CEntity |
ReleaseMarshalData(IStream *pStm) | CEntity | [inline]
Remove(VARIANT *pIndex) | CEntity |
Save(IStream *pStm, int fClearDirty) | CEntity | [inline]
SaveToStream(IStream *pStm, int fClearDirty, bool bWithMetaData=true) | CEntity | [inline]
UnmarshalInterface(IStream *pStm, REFIID riid, void **ppv) | CEntity | [inline]
~CEntity() | CEntity | [inline]
Generated on Wed Nov 13 2024 16:56:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CLine::LINEDATA Member List

This is the complete list of members for CLine::LINEDATA, including all inherited members.
x1 | CLine::LINEDATA
x2 | CLine::LINEDATA
y1 | CLine::LINEDATA
y2 | CLine::LINEDATA
Generated on Wed Nov 13 2024 16:56:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcADO/ADOKB.Idl Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcADO

ADOKB.Idl

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename:  ADOKB.idl
00003 //
00004 // Description: IDL source for ADOKB.dll
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022 // This file will be processed by the MIDL tool to
00023 // produce the type library (ADOKB.tlb) and marshalling code.
00024
00025 import "oaidl.idl";
00026 import "ocidl.idl";
00027
00028   [
00029     object,
00030     uuid(FD6AF2D0-E380-11D0-823B-00AA00A3F13E),
00031     dual,
00032     helpstring("IADOComponent Interface"),
00033     pointer_default(unique)
00034   ]
00035   interface IADOComponent : IDispatch
00036   {
00037     [id(1), helpstring("method SimpleQuery")] HRESULT SimpleQuery([in, out] VARIANT * returnval);
00038   };
00039 [
00040   uuid(FD6AF2C3-E380-11D0-823B-00AA00A3F13E),
00041   version(1.0),
00042   helpstring("ADOKB 1.0 Type Library")
00043 ]
00044 library ADOKBLib
00045 {
00046   importlib("stdole32.tlb");
00047   importlib("stdole2.tlb");
00048
00049   [
00050     uuid(FD6AF2D1-E380-11D0-823B-00AA00A3F13E),
00051     helpstring("ADOComponent Class")
00052   ]
00053   coclass ADOComponent
00054   {
00055     [default] interface IADOComponent;
00056   };
00057 };
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/SampleMSP/Resource.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • SampleMSP

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by sampmsp.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_SampleMSP                   101
00007 #define IDS_CAPTURE_STREAM              105
00008 #define IDS_RENDER_STREAM               106
00009
00010 // Next default values for new objects
00011 //
00012 #ifdef APSTUDIO_INVOKED
00013 #ifndef APSTUDIO_READONLY_SYMBOLS
00014 #define _APS_NEXT_RESOURCE_VALUE        201
00015 #define _APS_NEXT_COMMAND_VALUE         32768
00016 #define _APS_NEXT_CONTROL_VALUE         201
00017 #define _APS_NEXT_SYMED_VALUE           1000
00018 #endif
00019 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authentication/StdAfx.h Source File

  • Multimedia
  • WindowsMediaServices9
  • Authentication

StdAfx.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       StdAfx.h
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011
00012
00013 // stdafx.h : include file for standard system include files,
00014 //      or project specific include files that are used frequently,
00015 //      but are changed infrequently
00016 #if !defined(AFX_STDAFX_H__7F011C0C_326F_4F70_B942_F259753FA61A__INCLUDED_)
00017 #define AFX_STDAFX_H__7F011C0C_326F_4F70_B942_F259753FA61A__INCLUDED_
00018
00019 #if _MSC_VER > 1000
00020 #pragma once
00021 #endif // _MSC_VER > 1000
00022
00023 #define STRICT
00024 #ifndef _WIN32_WINNT
00025 #define _WIN32_WINNT 0x0400
00026 #endif
00027 #define _ATL_APARTMENT_THREADED
00028
00029 #include <atlbase.h>
00030
00031 //You may derive a class from CComModule and use it if you want to override
00032 //something, but do not change the name of _Module
00033 extern CComModule _Module;
00034
00035 #include <atlcom.h>
00036 #include <msxml2.h>
00037 #include <WMSBasicPlugin.h>
00038 #include <authen.h>
00039
00040 //{{AFX_INSERT_LOCATION}}
00041 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00042
00043 #endif // !defined(AFX_STDAFX_H__7F011C0C_326F_4F70_B942_F259753FA61A__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/IPRoute/IPRoute.Cpp Source File

  • NetDS
  • IPHelp
  • IPRoute

IPRoute.Cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002     Copyright (c) 1998 - 2000  Microsoft Corporation
00003     Module Name: IpRoute.exe
00004     File       : IpRoute.cpp
00005     Description: This file demonstrates the use of IP Helper APIs to
00006                  manipulate routing table.
00007     Author:
00008     Frank Li            April 18, 1998
00009
00010     Revision History:
00011     Who         When        What
00012     --------    --------    ----------------------------------
00013     Frank Li    04-18-98    created
00014 ---------------------------------------------------------------------------*/
00015
00016 #include "IpRoute.h"
00017
00018 void Usage(char * pszProgramName)
00019 {
00020     printf("Manipulates network routing tables.\n\n");
00021
00022     printf("%s -p                                               ...Prints route table.\n", pszProgramName);
00023     printf("%s -a destination netmask gateway interface [metric]...Adds a route.\n", pszProgramName);
00024     printf("%s -d destination                                   ...Deletes routes to\n", pszProgramName);
00025     printf("                                                            destination.\n\n");
00026
00027     printf("destination  Specifies the destination host.\n\n");
00028
00029     printf("netmask      Specifies a subnet mask value to be associated\n");
00030     printf("             with this route entry.\n\n");
00031
00032     printf("gateway      Specifies gateway.\n\n");
00033
00034     printf("interface    Specifies the interface ip.\n\n");
00035
00036     printf("metric       The cost for this destination\n\n");
00037
00038     printf("Diagnostic Notes:\n\n");
00039     printf("Invalid MASK generates an error, that is when (DEST & MASK) != DEST.\n");
00040     printf("Example> IpRoute -a 157.0.0.0 155.0.0.0 157.55.80.1 157.55.80.9\n");
00041     printf("         IpRoute: Invalid Mask 155.0.0.0\n\n");
00042
00043     printf("Examples:\n\n");
00044
00045     printf("> IpRoute -p\n");
00046     printf("> IpRoute -a 157.0.0.0    255.0.0.0 157.55.80.1  157.55.80.9           1\n");
00047     printf("             ^destination ^mask     ^gateway     ^existing interface   ^metric\n");
00048     printf("> IpRoute -p\n");
00049     printf("> IpRoute -d 157.0.0.0\n");
00050     printf("> IpRoute -p\n");
00051
00052     WSACleanup();
00053     exit(1);
00054 }
00055
00056
00057 void _cdecl main(int argc, char **argv)
00058 {
00059     WORD wVersionRequested = MAKEWORD(1,1);
00060     WSADATA wsaData;
00061     int nRet;
00062
00063     nRet = WSAStartup(wVersionRequested, &wsaData);
00064     if (wsaData.wVersion != wVersionRequested)
00065     {
00066         fprintf(stderr,"\n Wrong version\n");
00067         return;
00068     }
00069
00070     if ((argc < 2) || (argv[1][0] != '-'))
00071         Usage("IpRoute");
00072     if (strlen(argv[1]) > 2)
00073         Usage("IpRoute");
00074
00075     switch(argv[1][1])
00076     {
00077     case 'p':
00078         // Print routing table
00079         DoGetIpForwardTable();
00080         break;
00081     case 'a':
00082         //Adds an entry into routing table
00083         if (argc == 6)
00084             DoSetIpForwardEntry(argv[2], argv[3], argv[4], argv[5]); // dest mask gateway if
00085         else if (argc == 7)
00086         {
00087             DWORD dwMetric;
00088             if (sscanf(argv[6], "%u", &dwMetric ) == 1)
00089                 DoSetIpForwardEntry(argv[2], argv[3], argv[4], argv[5], dwMetric);
00090             else
00091                 printf("IpRoute: Bad argument %s\n", argv[6]);
00092         }
00093         else
00094             Usage("IpRoute");
00095         break;
00096
00097     case 'd':
00098         //Delete an entry from the routing table
00099         if (argc == 3)
00100             DoDeleteIpForwardEntry(argv[2]);
00101         else
00102             Usage("IpRoute");
00103         break;
00104     default:
00105         // help
00106         Usage("IpRoute");
00107         break;
00108     }
00109     WSACleanup();
00110 }
00111
00112 void DoGetIpForwardTable()
00113 {
00114     DWORD dwStatus;
00115     PMIB_IPFORWARDTABLE pIpRouteTab = NULL; // Ip routing table
00116
00117
00118     if ( (dwStatus = MyGetIpForwardTable(pIpRouteTab, TRUE)) == NO_ERROR)
00119     {
00120         PrintIpForwardTable(pIpRouteTab);
00121         free(pIpRouteTab);
00122         return;
00123     }
00124     else if ( dwStatus == ERROR_NO_DATA)
00125     {
00126         printf("No entries in route table.\n");
00127         if (pIpRouteTab)
00128             free (pIpRouteTab);
00129         return;
00130     }
00131     else
00132     {
00133         if (pIpRouteTab)
00134             free (pIpRouteTab);
00135         printf("IpRoute returned 0x%x\n", dwStatus);
00136         return;
00137     }
00138 }
00139
00140 void DoSetIpForwardEntry(char* pszDest, char* pszNetMask, char* pszGateway, char* pszInterface, DWORD dwMetric)
00141 {
00142     DWORD dwStatus;
00143
00144     MIB_IPFORWARDROW routeEntry;            // Ip routing table row entry
00145     PMIB_IPADDRTABLE pIpAddrTable = NULL;   // Ip Addr Table
00146     DWORD dwIfIndex;                        // Interface index number
00147     DWORD dwIfMask;                         // Interface Subnet Mask
00148     DWORD dwIfIpAddr;                       // Interface Ip Address
00149
00150     memset(&routeEntry, 0, sizeof(MIB_IPFORWARDROW));
00151
00152
00153     // converting and checking input arguments...
00154     if (pszDest == NULL || pszNetMask == NULL || pszGateway == NULL)
00155     {
00156         printf("IpRoute: Bad Argument\n");
00157         return;
00158     }
00159
00160     routeEntry.dwForwardDest = inet_addr(pszDest); // convert dotted ip addr. to ip addr.
00161     if (routeEntry.dwForwardDest == INADDR_NONE)
00162     {
00163         printf("IpRoute: Bad Destination %s\n", pszDest);
00164         return;
00165     }
00166
00167     routeEntry.dwForwardMask = inet_addr(pszNetMask);
00168     if ( (routeEntry.dwForwardMask == INADDR_NONE) &&
00169          (strcmp("255.255.255.255", pszNetMask) != 0) )
00170     {
00171         printf("IpRoute: Bad Mask %s\n", pszNetMask);
00172         return;
00173     }
00174
00175     routeEntry.dwForwardNextHop = inet_addr(pszGateway);
00176     if (routeEntry.dwForwardNextHop == INADDR_NONE)
00177     {
00178         printf("IpRoute: Bad Gateway %s\n", pszGateway);
00179         return;
00180     }
00181
00182     if ( (routeEntry.dwForwardDest & routeEntry.dwForwardMask) != routeEntry.dwForwardDest)
00183     {
00184         printf("IpRoute: Invalid Mask %s\n", pszNetMask);
00185         return;
00186
00187     }
00188
00189     dwIfIpAddr = inet_addr(pszInterface);
00190     if (dwIfIpAddr == INADDR_NONE)
00191     {
00192         printf("IpRoute: Bad Interface %s\n", pszInterface);
00193         return;
00194     }
00195
00196
00197     // Check if we have the given interface
00198     if ( (dwStatus = MyGetIpAddrTable(pIpAddrTable)) != NO_ERROR)
00199     {
00200         printf("GetIpAddrTable returned 0x%x\n", dwStatus);
00201         if (pIpAddrTable)
00202             free(pIpAddrTable);
00203         return;
00204     }
00205     assert(pIpAddrTable);
00206     if ( InterfaceIpToIdxAndMask(pIpAddrTable, pszInterface, dwIfIndex, dwIfMask) == FALSE)
00207     {
00208         printf("IpRoute: Bad Argument %s\n", pszInterface);
00209         return;
00210     }
00211     free(pIpAddrTable);
00212
00213
00214     if ( (routeEntry.dwForwardNextHop & dwIfMask) != (dwIfIpAddr & dwIfMask) )
00215     {
00216         printf("IpRoute: Gateway %s and Interface %s are not in the same subnet.\n", pszGateway, pszInterface);
00217         return;
00218     }
00219
00220     routeEntry.dwForwardIfIndex = dwIfIndex;
00221
00222     routeEntry.dwForwardMetric1 = dwMetric;
00223
00224     // some default values
00225     routeEntry.dwForwardProto = MIB_IPPROTO_LOCAL;
00226     routeEntry.dwForwardMetric2 = (DWORD)-1;
00227     routeEntry.dwForwardMetric3 = (DWORD)-1;
00228     routeEntry.dwForwardMetric4 = (DWORD)-1;
00229
00230     dwStatus = SetIpForwardEntry(&routeEntry);
00231     if (dwStatus != NO_ERROR)
00232     {
00233         printf("IpRoute: couldn't add (%s), dwStatus = %lu.\n",
00234                     pszDest, dwStatus);
00235     }
00236
00237 }
00238
00239
00240 void DoDeleteIpForwardEntry(char* pszDest)
00241 {
00242     DWORD dwStatus, dwDelStatus, i;
00243     PMIB_IPFORWARDTABLE pIpRouteTab = NULL; // Ip routing table
00244     MIB_IPFORWARDROW routeEntry;            // Ip routing table row entry
00245     DWORD dwForwardDest = 0;
00246     bool fDeleted = FALSE;
00247
00248
00249     memset(&routeEntry, 0, sizeof(MIB_IPFORWARDROW));
00250     dwForwardDest = inet_addr(pszDest); // convert dotted ip addr. to ip addr.
00251     if (dwForwardDest == INADDR_NONE)
00252     {
00253         printf("IpRoute: Bad Destination %s\n", pszDest);
00254         return;
00255     }
00256
00257
00258     if ( (dwStatus = MyGetIpForwardTable(pIpRouteTab, TRUE)) == NO_ERROR)
00259     {
00260         for (i = 0; i < pIpRouteTab->dwNumEntries; i++)
00261         {
00262             if (dwForwardDest == pIpRouteTab->table[i].dwForwardDest)
00263             {
00264                 memcpy(&routeEntry, &(pIpRouteTab->table[i]), sizeof(MIB_IPFORWARDROW));
00265                 dwDelStatus = DeleteIpForwardEntry(&routeEntry);
00266                 if (dwDelStatus != NO_ERROR)
00267                 {
00268                     printf("IpRoute: couldn't delete (%s), dwStatus = %lu.\n",
00269                             pszDest, dwDelStatus);
00270                     return;
00271                 }
00272                 else
00273                     fDeleted = TRUE;
00274             }
00275         }
00276         free(pIpRouteTab);
00277         if (! fDeleted)
00278             printf("IpRoute: The route specified was not found.\n");
00279         return;
00280     }
00281     else if ( dwStatus == ERROR_NO_DATA)
00282     {
00283         printf("IpRoute: No entries in route table.\n");
00284         if (pIpRouteTab)
00285             free (pIpRouteTab);
00286         return;
00287     }
00288     else
00289     {
00290         if (pIpRouteTab)
00291             free (pIpRouteTab);
00292         printf("IpRoute returned 0x%x\n", dwStatus);
00293         return;
00294     }
00295
00296 }
00297
00298
00299
00300 //----------------------------------------------------------------------------
00301 // If returned status is NO_ERROR, then pIpRouteTab points to a routing
00302 // table.
00303 //----------------------------------------------------------------------------
00304 DWORD MyGetIpForwardTable(PMIB_IPFORWARDTABLE& pIpRouteTab, BOOL fOrder)
00305 {
00306     DWORD status = NO_ERROR;
00307     DWORD statusRetry = NO_ERROR;
00308     DWORD dwActualSize = 0;
00309
00310     // query for buffer size needed
00311     status = GetIpForwardTable(pIpRouteTab, &dwActualSize, fOrder);
00312
00313     if (status == NO_ERROR)
00314     {
00315         printf("No error\n");
00316         return status;
00317     }
00318     else if (status == ERROR_INSUFFICIENT_BUFFER)
00319     {
00320         // need more space
00321
00322         pIpRouteTab = (PMIB_IPFORWARDTABLE) malloc(dwActualSize);
00323         assert(pIpRouteTab);
00324
00325         statusRetry = GetIpForwardTable(pIpRouteTab, &dwActualSize, fOrder);
00326         return statusRetry;
00327     }
00328     else
00329     {
00330         return status;
00331     }
00332
00333 }
00334
00335 //----------------------------------------------------------------------------
00336 // Print out ip routing table in the following format:
00337 //Active Routes:
00338 //
00339 //  Network Address          Netmask  Gateway Address        Interface  Metric
00340 //          0.0.0.0          0.0.0.0     157.54.176.1   157.54.177.149       1
00341 //        127.0.0.0        255.0.0.0        127.0.0.1        127.0.0.1       1
00342 //     157.54.176.0    255.255.252.0   157.54.177.149   157.54.177.149       1
00343 //   157.54.177.149  255.255.255.255        127.0.0.1        127.0.0.1       1
00344 //   157.54.255.255  255.255.255.255   157.54.177.149   157.54.177.149       1
00345 //        224.0.0.0        224.0.0.0   157.54.177.149   157.54.177.149       1
00346 //  255.255.255.255  255.255.255.255   157.54.177.149   157.54.177.149       1
00347 //----------------------------------------------------------------------------
00348 void PrintIpForwardTable(PMIB_IPFORWARDTABLE pIpRouteTable)
00349 {
00350     DWORD i, dwStatus, dwCurrIndex;
00351     struct in_addr inadDest;
00352     struct in_addr inadMask;
00353     struct in_addr inadGateway;
00354     char szIpAddr[128];          // ip address of an interface index
00355     PMIB_IPADDRTABLE pIpAddrTable = NULL;
00356
00357     char szDestIp[128];
00358     char szMaskIp[128];
00359     char szGatewayIp[128];
00360
00361     if (pIpRouteTable == NULL)
00362     {
00363         printf( "pIpRouteTable == NULL in line %d\n", __LINE__);
00364         return;
00365     }
00366     // get IP Address Table for mapping interface index number to ip address
00367     if ( (dwStatus = MyGetIpAddrTable(pIpAddrTable)) != NO_ERROR)
00368     {
00369         printf("GetIpAddrTable returned 0x%x\n", dwStatus);
00370         if (pIpAddrTable)
00371             free(pIpAddrTable);
00372         return;
00373     }
00374     assert(pIpAddrTable);
00375
00376
00377     printf("Active Routes:\n\n");
00378
00379     printf("  Network Address          Netmask  Gateway Address        Interface  Metric\n");
00380     for (i = 0; i < pIpRouteTable->dwNumEntries; i++)
00381     {
00382         dwCurrIndex = pIpRouteTable->table[i].dwForwardIfIndex;
00383         if (InterfaceIdxToInterfaceIp(pIpAddrTable, dwCurrIndex, szIpAddr) == FALSE)
00384         {
00385             printf("Error: Could not convert Interface number 0x%X to IP address.\n",dwCurrIndex);
00386             if (pIpAddrTable)
00387                 free(pIpAddrTable);
00388             return;
00389         }
00390
00391         inadDest.s_addr = pIpRouteTable->table[i].dwForwardDest;
00392         inadMask.s_addr = pIpRouteTable->table[i].dwForwardMask;
00393         inadGateway.s_addr = pIpRouteTable->table[i].dwForwardNextHop;
00394
00395         strcpy(szDestIp, inet_ntoa(inadDest));
00396         strcpy(szMaskIp, inet_ntoa(inadMask));
00397         strcpy(szGatewayIp, inet_ntoa(inadGateway));
00398         printf("  %15s %16s %16s %16s %7d\n",
00399                 szDestIp,
00400                 szMaskIp,
00401                 szGatewayIp,
00402                 szIpAddr,
00403                 pIpRouteTable->table[i].dwForwardMetric1);
00404
00405     }
00406
00407     if (pIpAddrTable)
00408         free(pIpAddrTable);
00409
00410 }
00411
00412 //----------------------------------------------------------------------------
00413 // Inputs: pIpAddrTable is the IP address table
00414 //         dwIndex is the Interface Number
00415 // Output: If it returns TRUE, str contains the ip address of the interface
00416 //----------------------------------------------------------------------------
00417 bool InterfaceIdxToInterfaceIp(PMIB_IPADDRTABLE pIpAddrTable, DWORD dwIndex, char str[])
00418 {
00419     struct in_addr inadTmp;
00420     char* szIpAddr;
00421
00422     if (pIpAddrTable == NULL ||  str == NULL)
00423         return FALSE;
00424     str[0] = '\0';
00425     for (DWORD dwIdx = 0; dwIdx < pIpAddrTable->dwNumEntries; dwIdx++)
00426     {
00427         if (dwIndex == pIpAddrTable->table[dwIdx].dwIndex)
00428         {
00429             inadTmp.s_addr = pIpAddrTable->table[dwIdx].dwAddr;
00430             szIpAddr = inet_ntoa(inadTmp);
00431             if (szIpAddr)
00432             {
00433                 strcpy(str, szIpAddr);
00434                 return TRUE;
00435             }
00436             else
00437                 return FALSE;
00438         }
00439     }
00440     return FALSE;
00441
00442 }
00443
00444 //----------------------------------------------------------------------------
00445 // Inputs: pIpAddrTable is the IP address table
00446 //         str is the Interface Ip address in dotted decimal format
00447 // Output: If it returns TRUE, dwIndex contains the interface index number
00448 //         and dwMask contains the corresponding subnet mask.
00449 //----------------------------------------------------------------------------
00450 bool InterfaceIpToIdxAndMask(PMIB_IPADDRTABLE pIpAddrTable, char str[], DWORD& dwIndex, DWORD& dwMask)
00451 {
00452     DWORD dwIfIpAddr; // Interface Ip Address
00453
00454     if (pIpAddrTable == NULL)
00455         return FALSE;
00456
00457     dwIfIpAddr = inet_addr(str);
00458     if (dwIfIpAddr == INADDR_NONE)
00459         return FALSE;
00460
00461     for (DWORD dwIdx = 0; dwIdx < pIpAddrTable->dwNumEntries; dwIdx++)
00462     {
00463         if (dwIfIpAddr == pIpAddrTable->table[dwIdx].dwAddr)
00464         {
00465             dwIndex = pIpAddrTable->table[dwIdx].dwIndex;
00466             dwMask = pIpAddrTable->table[dwIdx].dwMask;
00467             return TRUE;
00468         }
00469     }
00470     return FALSE;
00471 }
00472
00473 //----------------------------------------------------------------------------
00474 // If returned status is NO_ERROR, then pIpAddrTable points to a Ip Address
00475 // table.
00476 //----------------------------------------------------------------------------
00477 DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE& pIpAddrTable, BOOL fOrder)
00478 {
00479     DWORD status = NO_ERROR;
00480     DWORD statusRetry = NO_ERROR;
00481     DWORD dwActualSize = 0;
00482
00483     // query for buffer size needed
00484     status = GetIpAddrTable(pIpAddrTable, &dwActualSize, fOrder);
00485
00486     if (status == NO_ERROR)
00487     {
00488         printf("No error\n");
00489         return status;
00490     }
00491     else if (status == ERROR_INSUFFICIENT_BUFFER)
00492     {
00493         // need more space
00494
00495         pIpAddrTable = (PMIB_IPADDRTABLE) malloc(dwActualSize);
00496         assert(pIpAddrTable);
00497
00498         statusRetry = GetIpAddrTable(pIpAddrTable, &dwActualSize, fOrder);
00499         return statusRetry;
00500     }
00501     else
00502     {
00503         return status;
00504     }
00505 }
00506
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CellDataList Member List

This is the complete list of members for CellDataList, including all inherited members.
id | CellDataList
ncells | CellDataList
plist | CellDataList
row | CellDataList
startcell | CellDataList
Generated on Wed Nov 13 2024 16:56:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/about.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

about.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     This class implements ISnapinAbout
00014
00015
00016
00017 #ifndef _CLASS_CSNAPINABOUT_
00018 #define _CLASS_CSNAPINABOUT_
00019
00020 #include <mmc.h>
00021
00022
00023 //---------------------------------------------------------------------------
00024 class CSnapinAbout : public ISnapinAbout
00025 {
00026   private:
00027     ULONG       m_cRef;
00028     HBITMAP     m_hSmallImage;
00029     HBITMAP     m_hLargeImage;
00030     HBITMAP     m_hOpenImage;
00031     HICON       m_hAppIcon;
00032
00033   public:
00034     CSnapinAbout();
00035     ~CSnapinAbout();
00036
00037     /////////////////////////////////////////////////////////////////////////
00038     // Interface IUnknown
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     /////////////////////////////////////////////////////////////////////////
00044     // Interface ISnapinAbout
00045     STDMETHODIMP GetSnapinDescription(/*[out]*/ LPOLESTR* pszDescription );
00046
00047     STDMETHODIMP GetProvider(/*[out]*/ LPOLESTR* pszProvider );
00048
00049     STDMETHODIMP GetSnapinVersion(/*[out]*/ LPOLESTR* pszVersion);
00050
00051     STDMETHODIMP GetSnapinImage(/*[out]*/ HICON* hAppIcon );
00052
00053     STDMETHODIMP GetStaticFolderImage
00054                  (/*[out]*/ HBITMAP*  hSmallImage,
00055                   /*[out]*/ HBITMAP*  hOpenImage,
00056                   /*[out]*/ HBITMAP*  hLargeImage,
00057                   /*[out]*/ COLORREF* cMask
00058                  );
00059 };
00060
00061 #endif _CLASS_CSNAPINABOUT_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows.Net/module.cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows.Net

module.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        module.cpp
00007 //
00008 // Contents:    Cert Server Exit Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013 #pragma hdrstop
00014
00015 #include "celib.h"
00016 #include "module.h"
00017 #include "exit.h"
00018
00019
00020 STDMETHODIMP
00021 CCertManageExitModuleSample::GetProperty(
00022             /* [in] */ const BSTR strConfig,
00023             /* [in] */ BSTR strStorageLocation,
00024             /* [in] */ BSTR strPropertyName,
00025             /* [in] */ LONG Flags,
00026             /* [retval][out] */ VARIANT __RPC_FAR *pvarProperty)
00027 {
00028     LPWSTR szStr = NULL;
00029
00030     if (pvarProperty == NULL)
00031         return E_POINTER;
00032
00033     VariantInit(pvarProperty);
00034
00035     if (strPropertyName == NULL)
00036         return S_FALSE;
00037
00038     if (0 == _wcsicmp(strPropertyName, wszCMM_PROP_NAME))
00039         szStr = wsz_SAMPLE_NAME;
00040     else if (0 == _wcsicmp(strPropertyName, wszCMM_PROP_DESCRIPTION))
00041         szStr = wsz_SAMPLE_DESCRIPTION;
00042     else if (0 == _wcsicmp(strPropertyName, wszCMM_PROP_COPYRIGHT))
00043         szStr = wsz_SAMPLE_COPYRIGHT;
00044     else if (0 == _wcsicmp(strPropertyName, wszCMM_PROP_FILEVER))
00045         szStr = wsz_SAMPLE_FILEVER;
00046     else if (0 == _wcsicmp(strPropertyName, wszCMM_PROP_PRODUCTVER))
00047         szStr = wsz_SAMPLE_PRODUCTVER;
00048     else
00049         return S_FALSE;
00050
00051     pvarProperty->bstrVal = SysAllocString(szStr);
00052     if (NULL == pvarProperty->bstrVal)
00053         return E_OUTOFMEMORY;
00054
00055     pvarProperty->vt = VT_BSTR;
00056
00057     return S_OK;
00058 }
00059
00060 STDMETHODIMP
00061 CCertManageExitModuleSample::SetProperty(
00062             /* [in] */ const BSTR strConfig,
00063             /* [in] */ BSTR strStorageLocation,
00064             /* [in] */ BSTR strPropertyName,
00065             /* [in] */ LONG Flags,
00066             /* [in] */ VARIANT const __RPC_FAR *pvarProperty)
00067 {
00068      // no settable properties supported
00069      return S_FALSE;
00070 }
00071
00072 STDMETHODIMP
00073 CCertManageExitModuleSample::Configure(
00074             /* [in] */ const BSTR strConfig,
00075             /* [in] */ BSTR strStorageLocation,
00076             /* [in] */ LONG Flags)
00077 {
00078     MessageBox(NULL, L"No Configurable Options", NULL, MB_OK|MB_ICONINFORMATION);
00079
00080     return S_OK;
00081 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Accept/common.h Source File

  • NetDS
  • WinSock
  • Accept

common.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: common.h
00009 //
00010 // Description:
00011 //             This file contains the common definitions for various
00012 // constants and functions used in the server modules.
00013
00014 #ifndef __ACCEPT_COMMON_H__
00015 #define __ACCEPT_COMMON_H__
00016
00017 #include <winsock2.h>   // for Winsock API
00018 #include <windows.h>    // for Win32 APIs and types
00019 #include <ws2tcpip.h>   // for IPv6 support
00020 #include <wspiapi.h>    // for IPv6 support
00021 #include <strsafe.h>    // for safe versions of string functions
00022 #include <stdio.h>      // for printing to stdout.
00023
00024 // This is the number of clients that can be accomodated in the FD_SETs that
00025 // are used in the select command. In spite of the name referring to the
00026 // max number of clients, the actual number of clients that will be
00027 // accomodated will be a little less because the select will also include the
00028 // server interfaces on which the app is listening.
00029 // If you want to increase this value, first undefine FD_SETSIZE and redefine
00030 // FD_SETSIZE to the required value before including winsock2.h
00031 #define MAX_CLIENTS             FD_SETSIZE
00032
00033 // This is the default size of the data buffer that'll be used in recv
00034 // each time. In real apps, this value will be much higher.
00035 #define RECV_DATA_SIZE          4096
00036
00037
00038 // Different types of accepts that are supported by the server.
00039
00040 // This flag indicates the server to use select() and do a
00041 // non-blocking accept with single thread.
00042 const BYTE NON_BLOCKING_ACCEPT = 1;
00043
00044 // This flag indicates the server to use WSAAsyncSelect() to get
00045 // Window messages and call accept on receiving FD_ACCEPT event.
00046 const BYTE ASYNC_SELECT_ACCEPT = 2;
00047
00048 // This is the message that'll be sent to the server by winsock if
00049 // any of the registered socket events happen in the AsyncSelect case.
00050 // Any value above the WM_USER can be used to avoid collision with the standard
00051 // Windows messages.
00052 #define WM_USER_ASYNCSELECT_MSG     WM_USER + 1
00053
00054
00055 // default values for various command-line options
00056
00057 // The default address family to bind to.
00058 #define DEFAULT_ADDRESS_FAMILY          AF_UNSPEC
00059
00060 // The default interface to listen to.
00061 #define DEFAULT_INTERFACE               NULL
00062
00063 // The default port to listen to.
00064 #define DEFAULT_PORT                    "7243"
00065
00066 // The default type of accept to be done.
00067 #define DEFAULT_TYPE_OF_ACCEPT          NON_BLOCKING_ACCEPT
00068
00069
00070 // This structure defines the contents of the data buffer that'll be used
00071 // to store the messages that are received from and sent to the client.
00072 typedef struct _DATA_BUFFER
00073 {
00074     char buf[RECV_DATA_SIZE];  // the data buffer
00075     int  dataSize;             // length of the actual data present
00076     int  sendOffset;           // position of the next byte in buf to be sent
00077     BOOL isNewData;            // TRUE if buf has not been fully sent
00078 } DATA_BUFFER;
00079
00080
00081 // This structure holds the information for each socket the server creates.
00082 // The server maintains a list of these structures and operates on them.
00083 typedef struct _SOCK_INFO
00084 {
00085     SOCKET sock;                // socket handle
00086     BOOL   isSocketListening;   // TRUE if the socket is listening
00087     struct _SOCK_INFO *prev,    // previous structure in the list
00088                       *next;    // next structure in the list
00089     DATA_BUFFER recdData;       // details of data buffer that's recd/sent
00090     int     nTotalRecd;         // total number of bytes recd so far
00091     int     nTotalSent;         // total number of bytes sent so far
00092     BOOL    isFdCloseRecd;      // TRUE if FD_CLOSE event was received
00093 } SOCK_INFO, *PSOCK_INFO;
00094
00095
00096 // This structure bundles all the global variables needed between
00097 // different functions into a global context.
00098 typedef struct _AcceptContext
00099 {
00100     BYTE    addressFamily;      // Address Family requested
00101     char    *szInterface;       // Interface to listen on
00102     char    *szPort;            // Port to listen on
00103     BYTE    typeOfAccept;       // Which type of accept should be done
00104     SOCK_INFO *pSockList;       // List of the listening/accepted sockets
00105     HWND    hAcceptWindow;      // Handle to the hidden accept window
00106 } AcceptContext;
00107
00108 // This is the only global variable that'll be used throughout the server
00109 // module.
00110 extern AcceptContext g_AcceptContext;
00111
00112 // functions defined in SockInfo.cpp
00113 PSOCK_INFO AllocAndInitSockInfo();
00114 void FreeSockInfo(PSOCK_INFO pSockInfo);
00115 void AddSockInfoToList(PSOCK_INFO *ppHead, PSOCK_INFO pNewSockInfo);
00116 void DeleteSockInfoFromList(PSOCK_INFO *ppHead, PSOCK_INFO pDelSockInfo);
00117
00118 // functions exported from Common.cpp
00119 void PrintAddressString(LPSOCKADDR pSockAddr, DWORD dwSockAddrLen);
00120 void CreateListeningSockets();
00121 void DestroyListeningSockets();
00122 PSOCK_INFO ProcessAcceptEvent(PSOCK_INFO pSockInfo);
00123 BOOL ProcessReadEvent(PSOCK_INFO pSockInfo);
00124 BOOL SendData(PSOCK_INFO pSockInfo);
00125
00126 // functions exported from NBAccept.cpp
00127 void NonBlockingAcceptMain();
00128
00129 // functions exported from ASAccept.cpp
00130 void AsyncSelectAcceptMain();
00131
00132 #endif // __ACCEPT_COMMON_H__
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/Viewlist.Cpp Source File

  • WinUI
  • Shell
  • SampView

Viewlist.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ViewList.cpp
00013
00014    Description:   Implements CViewList.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ViewList.h"
00023 #include <ShellApi.h>
00024
00025 /**************************************************************************
00026
00027    CViewList::CViewList
00028
00029 **************************************************************************/
00030
00031 CViewList::CViewList()
00032 {
00033 m_pFirst = m_pLast = NULL;
00034
00035 //get the shell's IMalloc pointer
00036 //we'll keep this until we get destroyed
00037 if(FAILED(SHGetMalloc(&m_pMalloc)))
00038    {
00039    delete this;
00040    return;
00041    }
00042 }
00043
00044 /**************************************************************************
00045
00046    CViewList::~CViewList
00047
00048 **************************************************************************/
00049
00050 CViewList::~CViewList()
00051 {
00052 DeleteList();
00053
00054 if(m_pMalloc)
00055    m_pMalloc->Release();
00056 }
00057
00058 /**************************************************************************
00059
00060    CViewList::GetNextView()
00061
00062 **************************************************************************/
00063
00064 CShellView* CViewList::GetNextView(CShellView *pViewIn)
00065 {
00066 LPVIEWLIST  pTemp;
00067 CShellView  *pViewOut = NULL;
00068
00069 if(!pViewIn)
00070    pTemp = m_pFirst;
00071 else
00072    {
00073    for(pTemp = m_pFirst; pTemp; pTemp = pTemp->pNext)
00074       {
00075       if(pTemp->pView == pViewIn)
00076          {
00077          pTemp = pTemp->pNext;
00078          break;
00079          }
00080       }
00081    }
00082
00083 if(pTemp)
00084    {
00085    pViewOut = pTemp->pView;
00086    }
00087
00088 return pViewOut;
00089 }
00090
00091 /**************************************************************************
00092
00093    CViewList::AddToList()
00094
00095 **************************************************************************/
00096
00097 BOOL CViewList::AddToList(CShellView *pView)
00098 {
00099 LPVIEWLIST  pNew;
00100
00101 pNew = (LPVIEWLIST)m_pMalloc->Alloc(sizeof(VIEWLIST));
00102
00103 if(pNew)
00104    {
00105    //set the next pointer
00106    pNew->pNext = NULL;
00107    pNew->pView = pView;
00108
00109    //is this the first item in the list?
00110    if(!m_pFirst)
00111       {
00112       m_pFirst = pNew;
00113       }
00114
00115    if(m_pLast)
00116       {
00117       //add the new item to the end of the list
00118       m_pLast->pNext = pNew;
00119       }
00120
00121    //update the last item pointer
00122    m_pLast = pNew;
00123
00124    return TRUE;
00125    }
00126
00127 return FALSE;
00128 }
00129
00130 /**************************************************************************
00131
00132    CViewList::RemoveFromList()
00133
00134 **************************************************************************/
00135
00136 VOID CViewList::RemoveFromList(CShellView *pView)
00137 {
00138 LPVIEWLIST  pDelete;
00139 LPVIEWLIST  pPrev;
00140
00141 //find the item to be removed
00142 for(pDelete = m_pFirst, pPrev = NULL; pDelete; pDelete = pDelete->pNext)
00143    {
00144    if(pDelete->pView == pView)
00145       break;
00146
00147    //save the previous item in the list
00148    pPrev = pDelete;
00149    }
00150
00151 if(pDelete)
00152    {
00153    if(pPrev)
00154       {
00155       pPrev->pNext = pDelete->pNext;
00156       }
00157    else
00158       {
00159       //the item being deleted is the first item in the list
00160       m_pFirst = pDelete->pNext;
00161       }
00162
00163    //was the last item deleted?
00164    if(!pDelete->pNext)
00165       m_pLast = pPrev;
00166
00167    //free the list item
00168    m_pMalloc->Free(pDelete);
00169    }
00170 }
00171
00172 /**************************************************************************
00173
00174    CViewList::DeleteList()
00175
00176 **************************************************************************/
00177
00178 BOOL CViewList::DeleteList(VOID)
00179 {
00180 LPVIEWLIST  pDelete;
00181
00182 while(m_pFirst)
00183    {
00184    pDelete = m_pFirst;
00185    m_pFirst = pDelete->pNext;
00186
00187    //free the list item
00188    m_pMalloc->Free(pDelete);
00189    }
00190
00191 m_pFirst = m_pLast = NULL;
00192
00193 return TRUE;
00194 }
00195
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ComUser/ComUser.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ComUser

ComUser.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      COMUSER.CPP
00003
00004   Summary:   Based largely on the DLLUSER.EXE application code, this
00005              module is meant to implicitly link to the COMOBJ.DLL
00006              and illustrate the use (by this COMUSER client app) of the
00007              exported COM Object creation calls from that DLL:
00008              CreateCar, CreateUtilityCar, CreateCruiseCar.
00009              To this end, COMUSER also provides a set of menus for these
00010              Car related objects with selections for the respective
00011              methods of the Interfaces exposed by those COM Objects.
00012
00013              For a comprehensive tutorial code tour of COMUSER's contents
00014              and offerings see the tutorial COMUSER.HTM file. For more
00015              specific technical details on the internal workings see the
00016              comments dispersed throughout the COMUSER source code. For
00017              more details on the COMOBJ.DLL that COMUSER works with see
00018              the COMOBJ.HTM tutorial file in the main tutorial directory.
00019
00020   Classes:   CMainWindow
00021
00022   Functions: InitApplication, WinMain
00023
00024   Origin:    8-20-95: atrent - Editor-inheritance from the DLLUSER source.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 /*--------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will make calls to the COM/OLE libraries.
00044   We include INITGUID.H only once (here) in the entire app because we
00045     will be defining GUIDs and want them as constants in the data segment.
00046   We include COMMDLG.H because we will be using the Open File and
00047     potentially other Common dialogs.
00048   We include APPUTIL.H because we will be building this application using
00049     the convenient Virtual Window and Dialog classes and other
00050     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00051   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00052     class, GUID, and CLSID specifications.
00053   We include COMOBJ.H for the interface declarations and the import
00054     prototypes for the service functions provided by COMOBJ.DLL.
00055   We include COMUSER.H because it has class and resource definitions
00056     specific to this COMUSER application.
00057 ---------------------------------------------------------------------------*/
00058 #include <windows.h>
00059 #include <ole2.h>
00060 #include <initguid.h>
00061 #include <commdlg.h>
00062 #include <apputil.h>
00063 #include <icars.h>
00064 #include <carguids.h>
00065 #include <comobj.h>
00066 #include "comuser.h"
00067 #include "utcrucar.h"
00068
00069
00070 // Here is a pointer for use by the global Trace Message logging macros.
00071 CMsgLog* g_pMsgLog = NULL;
00072
00073
00074 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00075   Method:   CMainWindow::CMainWindow
00076
00077   Summary:  CMainWindow Constructor.
00078
00079   Args:     .
00080
00081   Modifies: .
00082
00083   Returns:  .
00084 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00085 CMainWindow::CMainWindow()
00086 {
00087   // Ensure these member variable strings are null strings.
00088   m_szFileName[0] = 0;
00089   m_szFileTitle[0] = 0;
00090
00091   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00092   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00093   m_ofnFile.hwndOwner = m_hWnd;
00094   m_ofnFile.hInstance = m_hInst;
00095   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00096   m_ofnFile.lpstrCustomFilter = NULL;
00097   m_ofnFile.nMaxCustFilter = 0;
00098   m_ofnFile.nFilterIndex = 1;
00099   m_ofnFile.lpstrFile = m_szFileName;
00100   m_ofnFile.nMaxFile = MAX_PATH;
00101   m_ofnFile.lpstrInitialDir = TEXT(".");
00102   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00103   m_ofnFile.nMaxFileTitle = MAX_PATH;
00104   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00105   m_ofnFile.lpstrDefExt = NULL;
00106   m_ofnFile.Flags = OFN_HIDEREADONLY;
00107
00108   // Null the COM Object IUnknown pointers.
00109   m_pCar = NULL;
00110   m_pUtilityCar = NULL;
00111   m_pCruiseCar = NULL;
00112   m_pUtilityCruiseCar = NULL;
00113
00114   // Null the Message object pointers.
00115   m_pMsgBox = NULL;
00116   m_pMsgLog = NULL;
00117 }
00118
00119
00120 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00121   Method:   CMainWindow::~CMainWindow
00122
00123   Summary:  CMainWindow Destructor.  Destruction of the main window
00124             indicates that the application should quit and thus the
00125             PostQuitMessage API is called.
00126
00127   Args:     .
00128
00129   Modifies: .
00130
00131   Returns:  .
00132 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00133 CMainWindow::~CMainWindow()
00134 {
00135   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00136   // message and causes a delete of CMainWindow which in turn causes this
00137   // destructor to run. The WM_DESTROY results when the window is destoyed
00138   // after a close of the window. Prior to exiting the main message loop:
00139
00140   // We release any and all of the pointers to instantiated COM objects.
00141   RELEASE_INTERFACE(m_pCar);
00142   RELEASE_INTERFACE(m_pUtilityCar);
00143   RELEASE_INTERFACE(m_pCruiseCar);
00144   RELEASE_INTERFACE(m_pUtilityCruiseCar);
00145
00146   // We delete the CMsgBox and CMsgLog objects that were made in
00147   // Initinstance.
00148   DELETE_POINTER(m_pMsgBox);
00149   DELETE_POINTER(m_pMsgLog);
00150
00151   // We then post a WM_QUIT message to cause an exit of the main thread's
00152   // message loop and an exit of this instance of the application.
00153   PostQuitMessage(0);
00154 }
00155
00156
00157 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00158   Method:   CMainWindow::InitInstance
00159
00160   Summary:  Instantiates an instance of the main application window.
00161             This method must be called only once, immediately after
00162             window class construction.  We take care to delete 'this'
00163             CMainWindow if we must return the error condition FALSE.
00164
00165   Args:     HINSTANCE hInstance,
00166               Handle of the application instance.
00167             int nCmdShow)
00168               Command to pass to ShowWindow.
00169
00170   Modifies: m_szHelpFile, m_pMsgBox, m_pMsgLog.
00171
00172   Returns:  BOOL.
00173               TRUE if succeeded.
00174               FALSE if failed.
00175 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00176 BOOL CMainWindow::InitInstance(
00177        HINSTANCE hInstance,
00178        int nCmdShow)
00179 {
00180   BOOL bResult = FALSE;
00181   HWND hWnd;
00182
00183   // Create the Message Box and Message Log objects.
00184   m_pMsgBox = new CMsgBox;
00185   m_pMsgLog = new CMsgLog;
00186
00187   if (NULL != m_pMsgBox && NULL != m_pMsgLog)
00188   {
00189     // Note, the Create method sets the m_hWnd member so we don't
00190     //   need to set it explicitly here first.
00191
00192     // Here is the create of this window.  Size the window reasonably.
00193     //   Create sets both m_hInst and m_hWnd.
00194     hWnd = Create(
00195              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00196              TEXT(MAIN_WINDOW_TITLE_STR),
00197              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00198                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00199              CW_USEDEFAULT,
00200              CW_USEDEFAULT,
00201              ::GetSystemMetrics(SM_CXSCREEN)*3/5,
00202              ::GetSystemMetrics(SM_CYSCREEN)*3/5,
00203              NULL,
00204              NULL,
00205              hInstance);
00206     if (hWnd)
00207     {
00208       // Ensure the new window is shown on screen and its content is painted.
00209       ::ShowWindow(m_hWnd, nCmdShow);
00210       ::UpdateWindow(m_hWnd);
00211
00212       // Build a path to where the help file should be (it should be in
00213       // the same directory as the .EXE but with the .HTM extension.
00214       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00215
00216       // Init the Message Box object.
00217       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00218       {
00219         // Create the Trace Message Log ListBox as a child window that
00220         //   fits the client area of the Main Window (the TRUE 3rd argument
00221         //   specifies such an inside child).
00222         // If you want the Trace Message Log in a separate (but owned)
00223         //   window, then pass a FALSE instead for the 3rd argument.
00224         if (m_pMsgLog->Create(m_hInst, m_hWnd, TRUE))
00225         {
00226           // Assign the global MsgLog pointer.
00227           g_pMsgLog = m_pMsgLog;
00228           // Use macro to log an initial start messsage.
00229           LOGID(IDS_START_MESSAGE_LOG);
00230           // Since we're exploiting the COMOBJ DLL and we want it to use
00231           // this same Message Log facility, we pass it a pointer to our
00232           // particular instance's CMsgLog object.
00233           ComObjInitMsgLog(g_pMsgLog);
00234           // Signal that we succeeded in initializing the app.
00235           bResult = TRUE;
00236         }
00237       }
00238     }
00239   }
00240
00241   if (!bResult)
00242   {
00243     DELETE_POINTER(m_pMsgBox);
00244     DELETE_POINTER(m_pMsgLog);
00245   }
00246
00247   return (bResult);
00248 }
00249
00250
00251 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00252   Method:   CMainWindow::GetInterface
00253
00254   Summary:  Convenience method that wraps the QueryInterface call
00255             and accepts a main COM object IUnknown pointer as an argument.
00256
00257   Args:     IUnknown* pObj,
00258               Pointer to the COM Object we are getting an interface on.
00259             REFIID riid,
00260               The GUID for the interface that we are seeking.
00261             PPVOID ppv);
00262               Address of the caller's pointer variable that will
00263               receive the requested interface pointer.
00264
00265   Modifies: .
00266
00267   Returns:  BOOL.
00268               TRUE if succeeded.
00269               FALSE if failed.
00270 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00271 BOOL CMainWindow::GetInterface(
00272        IUnknown* pObj,
00273        REFIID riid,
00274        PPVOID ppv)
00275 {
00276   BOOL bResult = FALSE;
00277   HRESULT hr;
00278
00279   *ppv=NULL;
00280
00281   if (NULL != pObj)
00282   {
00283     LOG("E: --Obtaining Interface Pointer.");
00284     hr=pObj->QueryInterface(riid, ppv);
00285
00286     if (FAILED(hr))
00287     {
00288       LOGERROR("C: ???? QueryInterface", hr);
00289     }
00290     else
00291     {
00292       LOGF1("E: Interface obtained. *ppv=0x%X", *ppv);
00293       bResult = TRUE;
00294     }
00295   }
00296   else
00297   {
00298     LOG("E: ???? Create an object first.");
00299   }
00300
00301   return (bResult);
00302 }
00303
00304
00305 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00306   Method:   CMainWindow::DoMenu
00307
00308   Summary:  Dispatch and handle the main menu commands.
00309
00310   Args:     WPARAM wParam,
00311               First message parameter (word sized).
00312             LPARAM lParam)
00313               Second message parameter (long sized).
00314
00315   Modifies: m_ofnFile, ...
00316
00317   Returns:  LRESULT
00318               Standard Windows WindowProc return value.
00319 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00320 LRESULT CMainWindow::DoMenu(
00321           WPARAM wParam,
00322           LPARAM lParam)
00323 {
00324   LRESULT lResult = FALSE;
00325   HRESULT hr;
00326   HMENU hMenu  = ::GetMenu(m_hWnd);
00327   // Here are some interface pointers used to call methods on
00328   // our COUtilityCar, COCruiseCar, and COUtilityCruiseCar COM objects.
00329   ICar* pICar;
00330   IUtility* pIUtility;
00331   ICruise* pICruise;
00332
00333   switch (LOWORD(wParam))
00334   {
00335     //----------------------------------------------------------------------
00336     // Handle File Menu Commands.
00337     //----------------------------------------------------------------------
00338     case IDM_FILE_EXIT:
00339       // The user commands us to exit this application so we tell the
00340       // Main window to close itself.
00341       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00342       break;
00343
00344     //----------------------------------------------------------------------
00345     // Handle Car Menu Commands.
00346     //----------------------------------------------------------------------
00347     case IDM_CAR_CREATE:
00348       LOG("E: === Car Menu: Create.");
00349       if (NULL == m_pCar)
00350       {
00351         hr = CreateCar(NULL, IID_IUnknown, (PPVOID)&m_pCar);
00352         if (SUCCEEDED(hr))
00353         {
00354           ::CheckMenuItem(
00355               hMenu,
00356               IDM_CAR_CREATE,
00357               MF_BYCOMMAND | MF_CHECKED);
00358         }
00359         else
00360           LOG("C: ???? Car creation failed.");
00361       }
00362       else
00363         LOG("E: ???? Car already exists.");
00364       break;
00365     case IDM_CAR_RELEASE:
00366       LOG("E: === Car Menu: Release.");
00367       if (NULL != m_pCar)
00368       {
00369         RELEASE_INTERFACE(m_pCar);
00370         ::CheckMenuItem(
00371             hMenu,
00372             IDM_CAR_CREATE,
00373             MF_BYCOMMAND | MF_UNCHECKED);
00374       }
00375       else
00376         LOG("E: ???? No Car to Release.");
00377       break;
00378     case IDM_CAR_SHIFT:
00379       LOG("E: === Car Menu: ICar::Shift");
00380       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00381       {
00382         LOG("E: --Calling pICar->Shift");
00383         pICar->Shift(1);
00384         LOG("E: --Releasing pICar");
00385         pICar->Release();
00386       }
00387       break;
00388     case IDM_CAR_CLUTCH:
00389       LOG("E: === Car Menu: ICar::Clutch");
00390       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00391       {
00392         LOG("E: --Calling pICar->Clutch");
00393         pICar->Clutch(100);
00394         LOG("E: --Releasing pICar");
00395         pICar->Release();
00396       }
00397       break;
00398     case IDM_CAR_SPEED:
00399       LOG("E: === Car Menu: ICar::Speed");
00400       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00401       {
00402         LOG("E: --Calling pICar->Speed");
00403         pICar->Speed(20);
00404         LOG("E: --Releasing pICar");
00405         pICar->Release();
00406       }
00407       break;
00408     case IDM_CAR_STEER:
00409       LOG("E: === Car Menu: ICar::Steer");
00410       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00411       {
00412         LOG("E: --Calling pICar->Steer");
00413         pICar->Steer(0);
00414         LOG("E: --Releasing pICar");
00415         pICar->Release();
00416       }
00417       break;
00418
00419     //----------------------------------------------------------------------
00420     // Handle UtilityCar Menu Commands.
00421     //----------------------------------------------------------------------
00422     case IDM_UCAR_CREATE:
00423       LOG("E: === UtilityCar Menu: Create.");
00424       if (NULL == m_pUtilityCar)
00425       {
00426         hr = CreateUtilityCar(NULL, IID_IUnknown, (PPVOID)&m_pUtilityCar);
00427         if (SUCCEEDED(hr))
00428         {
00429           ::CheckMenuItem(
00430               hMenu,
00431               IDM_UCAR_CREATE,
00432               MF_BYCOMMAND | MF_CHECKED);
00433         }
00434         else
00435           LOG("C: ???? UtilityCar creation failed.");
00436       }
00437       else
00438         LOG("E: ???? UtilityCar already exists.");
00439       break;
00440     case IDM_UCAR_RELEASE:
00441       LOG("E: === UtilityCar Menu: Release.");
00442       if (NULL != m_pUtilityCar)
00443       {
00444         RELEASE_INTERFACE(m_pUtilityCar);
00445         ::CheckMenuItem(
00446             hMenu,
00447             IDM_UCAR_CREATE,
00448             MF_BYCOMMAND | MF_UNCHECKED);
00449       }
00450       else
00451         LOG("E: ???? No UtilityCar to Release.");
00452       break;
00453     case IDM_UCAR_SHIFT:
00454       LOG("E: === UtilityCar Menu: ICar::Shift");
00455       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00456       {
00457         LOG("E: --Calling pICar->Shift");
00458         pICar->Shift(2);
00459         LOG("E: --Releasing pICar");
00460         pICar->Release();
00461       }
00462       break;
00463     case IDM_UCAR_CLUTCH:
00464       LOG("E: === UtilityCar Menu: ICar::Clutch");
00465       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00466       {
00467         LOG("E: --Calling pICar->Clutch");
00468         pICar->Clutch(100);
00469         LOG("E: --Releasing pICar");
00470         pICar->Release();
00471       }
00472       break;
00473     case IDM_UCAR_SPEED:
00474       LOG("E: === UtilityCar Menu: ICar::Speed");
00475       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00476       {
00477         LOG("E: --Calling pICar->Speed");
00478         pICar->Speed(30);
00479         LOG("E: --Releasing pICar");
00480         pICar->Release();
00481       }
00482       break;
00483     case IDM_UCAR_STEER:
00484       LOG("E: === UtilityCar Menu: ICar::Steer");
00485       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00486       {
00487         LOG("E: --Calling pICar->Steer");
00488         pICar->Steer(10);
00489         LOG("E: --Releasing pICar");
00490         pICar->Release();
00491       }
00492       break;
00493     case IDM_UCAR_OFFROAD:
00494       LOG("E: === UtilityCar Menu: IUtility::Offroad");
00495       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00496       {
00497         LOG("E: --Calling pIUtility->Offroad");
00498         pIUtility->Offroad(1);
00499         LOG("E: --Releasing pIUtility");
00500         pIUtility->Release();
00501       }
00502       break;
00503     case IDM_UCAR_WINCH:
00504       LOG("E: === UtilityCar Menu: IUtility::Winch");
00505       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00506       {
00507         LOG("E: --Calling pIUtility->Winch");
00508         pIUtility->Winch(0);
00509         LOG("E: --Releasing pIUtility");
00510         pIUtility->Release();
00511       }
00512       break;
00513
00514     //----------------------------------------------------------------------
00515     // Handle CruiseCar Menu Commands.
00516     //----------------------------------------------------------------------
00517     case IDM_CCAR_CREATE:
00518       LOG("E: === CruiseCar Menu: Create.");
00519       if (NULL == m_pCruiseCar)
00520       {
00521         hr = CreateCruiseCar(NULL, IID_IUnknown, (PPVOID)&m_pCruiseCar);
00522         if (SUCCEEDED(hr))
00523         {
00524           ::CheckMenuItem(
00525               hMenu,
00526               IDM_CCAR_CREATE,
00527               MF_BYCOMMAND | MF_CHECKED);
00528         }
00529         else
00530           LOG("C: ???? CruiseCar creation failed.");
00531       }
00532       else
00533         LOG("E: ???? CruiseCar already exists.");
00534       break;
00535     case IDM_CCAR_RELEASE:
00536       LOG("E: === CruiseCar Menu: Release.");
00537       if (NULL != m_pCruiseCar)
00538       {
00539         RELEASE_INTERFACE(m_pCruiseCar);
00540         ::CheckMenuItem(
00541             hMenu,
00542             IDM_CCAR_CREATE,
00543             MF_BYCOMMAND | MF_UNCHECKED);
00544       }
00545       else
00546         LOG("E: ???? No CruiseCar to Release.");
00547       break;
00548     case IDM_CCAR_SHIFT:
00549       LOG("E: === CruiseCar Menu: ICar::Shift");
00550       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00551       {
00552         LOG("E: --Calling pICar->Shift");
00553         pICar->Shift(4);
00554         LOG("E: --Releasing pICar");
00555         pICar->Release();
00556       }
00557       break;
00558     case IDM_CCAR_CLUTCH:
00559       LOG("E: === CruiseCar Menu: ICar::Clutch");
00560       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00561       {
00562         LOG("E: --Calling pICar->Clutch");
00563         pICar->Clutch(100);
00564         LOG("E: --Releasing pICar");
00565         pICar->Release();
00566       }
00567       break;
00568     case IDM_CCAR_SPEED:
00569       LOG("E: === CruiseCar Menu: ICar::Speed");
00570       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00571       {
00572         LOG("E: --Calling pICar->Speed");
00573         pICar->Speed(60);
00574         LOG("E: --Releasing pICar");
00575         pICar->Release();
00576       }
00577       break;
00578     case IDM_CCAR_STEER:
00579       LOG("E: === CruiseCar Menu: ICar::Steer");
00580       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00581       {
00582         LOG("E: --Calling pICar->Steer");
00583         pICar->Steer(0);
00584         LOG("E: --Releasing pICar");
00585         pICar->Release();
00586       }
00587       break;
00588     case IDM_CCAR_ENGAGE:
00589       LOG("E: === CruiseCar Menu: ICruise::Engage");
00590       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00591       {
00592         LOG("E: --Calling pICruise->Engage");
00593         pICruise->Engage(TRUE);
00594         LOG("E: --Releasing pICruise");
00595         pICruise->Release();
00596       }
00597       break;
00598     case IDM_CCAR_ADJUST:
00599       LOG("E: === CruiseCar Menu: ICruise::Adjust");
00600       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00601       {
00602         LOG("E: --Calling pICruise->Adjust");
00603         pICruise->Adjust(FALSE);
00604         LOG("E: --Releasing pICruise");
00605         pICruise->Release();
00606       }
00607       break;
00608
00609     //----------------------------------------------------------------------
00610     // Handle UtilityCruiseCar Menu Commands.
00611     //----------------------------------------------------------------------
00612     case IDM_UCRU_CREATE:
00613       LOG("E: === UtilityCruiseCar Menu: Create.");
00614       if (NULL == m_pUtilityCruiseCar)
00615       {
00616         hr = CreateUtilityCruiseCar(
00617                NULL,
00618                IID_IUnknown,
00619                (PPVOID)&m_pUtilityCruiseCar);
00620         if (SUCCEEDED(hr))
00621         {
00622           ::CheckMenuItem(
00623               hMenu,
00624               IDM_UCRU_CREATE,
00625               MF_BYCOMMAND | MF_CHECKED);
00626         }
00627         else
00628           LOG("C: ???? UtilityCruiseCar creation failed.");
00629       }
00630       else
00631         LOG("E: ???? UtilityCruiseCar already exists.");
00632       break;
00633     case IDM_UCRU_RELEASE:
00634       LOG("E: === UtilityCruiseCar Menu: Release.");
00635       if (NULL != m_pUtilityCruiseCar)
00636       {
00637         RELEASE_INTERFACE(m_pUtilityCruiseCar);
00638         ::CheckMenuItem(
00639             hMenu,
00640             IDM_UCRU_CREATE,
00641             MF_BYCOMMAND | MF_UNCHECKED);
00642       }
00643       else
00644         LOG("E: ???? No UtilityCruiseCar to Release.");
00645       break;
00646     case IDM_UCRU_SHIFT:
00647       LOG("E: === UtilityCruiseCar Menu: ICar::Shift");
00648       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00649       {
00650         LOG("E: --Calling pICar->Shift");
00651         pICar->Shift(1);
00652         LOG("E: --Releasing pICar");
00653         pICar->Release();
00654       }
00655       break;
00656     case IDM_UCRU_CLUTCH:
00657       LOG("E: === UtilityCruiseCar Menu: ICar::Clutch");
00658       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00659       {
00660         LOG("E: --Calling pICar->Clutch");
00661         pICar->Clutch(80);
00662         LOG("E: --Releasing pICar");
00663         pICar->Release();
00664       }
00665       break;
00666     case IDM_UCRU_SPEED:
00667       LOG("E: === UtilityCruiseCar Menu: ICar::Speed");
00668       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00669       {
00670         LOG("E: --Calling pICar->Speed");
00671         pICar->Speed(10);
00672         LOG("E: --Releasing pICar");
00673         pICar->Release();
00674       }
00675       break;
00676     case IDM_UCRU_STEER:
00677       LOG("E: === UtilityCruiseCar Menu: ICar::Steer");
00678       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00679       {
00680         LOG("E: --Calling pICar->Steer");
00681         pICar->Steer(10);
00682         LOG("E: --Releasing pICar");
00683         pICar->Release();
00684       }
00685       break;
00686     case IDM_UCRU_ENGAGE:
00687       LOG("E: === UtilityCruiseCar Menu: ICruise::Engage");
00688       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00689       {
00690         LOG("E: --Calling pICruise->Engage");
00691         pICruise->Engage(FALSE);
00692         LOG("E: --Releasing pICruise");
00693         pICruise->Release();
00694       }
00695       break;
00696     case IDM_UCRU_ADJUST:
00697       LOG("E: === UtilityCruiseCar Menu: ICruise::Adjust");
00698       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00699       {
00700         LOG("E: --Calling pICruise->Adjust");
00701         pICruise->Adjust(FALSE);
00702         LOG("E: --Releasing pICruise");
00703         pICruise->Release();
00704       }
00705       break;
00706     case IDM_UCRU_OFFROAD:
00707       LOG("E: === UtilityCruiseCar Menu: IUtility::Offroad");
00708       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00709       {
00710         LOG("E: --Calling pIUtility->Offroad");
00711         pIUtility->Offroad(3);
00712         LOG("E: --Releasing pIUtility");
00713         pIUtility->Release();
00714       }
00715       break;
00716     case IDM_UCRU_WINCH:
00717       LOG("E: === UtilityCruiseCar Menu: IUtility::Winch");
00718       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00719       {
00720         LOG("E: --Calling pIUtility->Winch");
00721         pIUtility->Winch(0);
00722         LOG("E: --Releasing pIUtility");
00723         pIUtility->Release();
00724       }
00725       break;
00726
00727     //----------------------------------------------------------------------
00728     // Handle Log Menu Commands.
00729     //----------------------------------------------------------------------
00730     case IDM_LOG_LOGCLEAR:
00731       // Clear the message log.
00732       m_pMsgLog->Clear();
00733       // Use macro to log messages.
00734       LOGID(IDS_START_MESSAGE_LOG);
00735       break;
00736     case IDM_LOG_LOGGING:
00737       // Toggle the state of the Message Logging.
00738       // Toggle the checkmark indicator on the menu selection as well.
00739       {
00740         HMENU hMenu  = ::GetMenu(m_hWnd);
00741         BOOL bLogging = ::GetMenuState(
00742                             hMenu,
00743                             IDM_LOG_LOGGING,
00744                             MF_BYCOMMAND) & MF_CHECKED;
00745         if (bLogging)
00746         {
00747           m_pMsgLog->Logging(FALSE);
00748           ::CheckMenuItem(
00749               hMenu,
00750               IDM_LOG_LOGGING,
00751               MF_BYCOMMAND | MF_UNCHECKED);
00752         }
00753         else
00754         {
00755           m_pMsgLog->Logging(TRUE);
00756           ::CheckMenuItem(
00757               hMenu,
00758               IDM_LOG_LOGGING,
00759               MF_BYCOMMAND | MF_CHECKED);
00760         }
00761       }
00762       break;
00763     case IDM_LOG_COPYCLIP:
00764       // Copy trace message log to clipboard.
00765       m_pMsgLog->Copy();
00766       break;
00767
00768     //----------------------------------------------------------------------
00769     // Handle Help Menu Commands.
00770     //----------------------------------------------------------------------
00771     case IDM_HELP_CONTENTS:
00772       // We have some stubbed support here for bringing up the online
00773       // Help for this application.
00774       ReadHelp(m_hWnd, m_szHelpFile);
00775       break;
00776     case IDM_HELP_TUTORIAL:
00777       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00778       // tutorial narrative file associated with this tutorial code sample.
00779       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00780       break;
00781     case IDM_HELP_TUTDLL:
00782       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00783       // tutorial narrative file associated with the DLL server.
00784       ReadTutorial(m_hInst, m_hWnd, TEXT(DLL_TUTFILE_STR));
00785       break;
00786     case IDM_HELP_READSOURCE:
00787       // Call the APPUTIL utility function ReadSource to allow the
00788       // user to open and read any of the source files of COMUSER.
00789       ReadSource(m_hWnd, &m_ofnFile);
00790       break;
00791     case IDM_HELP_ABOUT:
00792       {
00793         CAboutBox dlgAboutBox;
00794
00795         // Show the standard About Box dialog for this EXE by telling the
00796         // dialog C++ object to show itself by invoking its ShowDialog
00797         // method.  Pass it this EXE instance and the parent window handle.
00798         // Use a dialog resource ID for the dialog template stored in
00799         // this EXE module's resources.
00800         dlgAboutBox.ShowDialog(
00801           m_hInst,
00802           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00803           m_hWnd);
00804       }
00805       break;
00806     case IDM_HELP_ABOUTDLL:
00807       // Call the COMOBJ DLL to show the DLL's About Box.
00808       ::ComObjAboutBox(m_hWnd);
00809       break;
00810
00811     default:
00812       // Defer all messages NOT handled here to the Default Window Proc.
00813       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00814       break;
00815   }
00816
00817   return(lResult);
00818 }
00819
00820
00821 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00822   Method:   CMainWindow::WindowProc
00823
00824   Summary:  Main window procedure for this window object.  See CVirWindow
00825             in the APPUTIL library (APPUTIL.CPP) for details on how this
00826             method gets called by the global WindowProc.
00827
00828   Args:     UINT uMsg,
00829               Windows message that is "sent" to this window.
00830             WPARAM wParam,
00831               First message parameter (word sized).
00832             LPARAM lParam)
00833               Second message parameter (long sized).
00834
00835   Modifies: ...
00836
00837   Returns:  LRESULT
00838               Standard Windows WindowProc return value.
00839 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00840 LRESULT CMainWindow::WindowProc(
00841           UINT uMsg,
00842           WPARAM wParam,
00843           LPARAM lParam)
00844 {
00845   LRESULT lResult = FALSE;
00846
00847   switch (uMsg)
00848   {
00849     case WM_CREATE:
00850       {
00851         // Setup for painting text in this window.
00852         HDC hdc = GetDC(m_hWnd);
00853         ::GetTextMetrics(hdc, &m_tm);
00854         ::ReleaseDC(m_hWnd, hdc);
00855       }
00856       break;
00857
00858     case WM_MEASUREITEM:
00859       // Get setup for painting text in this window.
00860       {
00861         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00862         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00863         lpmis->itemWidth = m_wWidth;
00864         lResult = TRUE;
00865       }
00866
00867     case WM_SIZE:
00868       // Handle a resize of this window.
00869       m_wWidth = LOWORD(lParam);
00870       m_wHeight = HIWORD(lParam);
00871       // Resize the Message Log ListBox
00872       m_pMsgLog->Resize(m_wWidth, m_wHeight);
00873       break;
00874
00875     case WM_COMMAND:
00876       // Dispatch and handle any Menu command messages received.
00877       lResult = DoMenu(wParam, lParam);
00878       break;
00879
00880     case WM_CLOSE:
00881       // The user selected Close on the main window's System menu
00882       // or Exit on the File menu.
00883     case WM_QUIT:
00884       // If the app is being quit then close any associated help windows.
00885     default:
00886       // Defer all messages NOT handled here to the Default Window Proc.
00887       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00888       break;
00889   }
00890
00891   return(lResult);
00892 }
00893
00894
00895 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00896   Function: UnicodeOk
00897
00898   Summary:  Checks if the platform will handle unicode versions of
00899             Win32 string API calls.
00900
00901   Args:     void
00902
00903   Returns:  BOOL
00904               TRUE if unicode support; FALSE if not.
00905 ------------------------------------------------------------------------F-F*/
00906 BOOL UnicodeOk(void)
00907 {
00908   BOOL bOk = TRUE;
00909   TCHAR szUserName[MAX_STRING_LENGTH];
00910   DWORD dwSize = MAX_STRING_LENGTH;
00911
00912   if (!GetUserName(szUserName, &dwSize))
00913     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00914
00915   return bOk;
00916 }
00917
00918
00919 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00920   Function: InitApplication
00921
00922   Summary:  Initializes the application and registers its main window
00923             class. InitApplication is called only once (in WinMain).
00924
00925   Args:     HINSTANCE hInstance)
00926               Handle to the first instance of the application.
00927
00928   Returns:  BOOL.
00929               TRUE if success.
00930               FALSE if fail.
00931 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00932 BOOL InitApplication(
00933        HINSTANCE hInstance)
00934 {
00935   BOOL bOk;
00936   // The window class for all instances of the main frame window.
00937   WNDCLASSEX wcf;
00938
00939   // Assign the appropriate values for this main frame window class.
00940   wcf.cbSize        = sizeof(WNDCLASSEX);
00941   wcf.cbClsExtra    = 0;            // No per-class extra data.
00942   wcf.cbWndExtra    = 0;            // No per-window extra data.
00943   wcf.hInstance     = hInstance;    // Application module instance.
00944   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00945                                     // APPUTIL for all CVirWindows).
00946   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
00947   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00948                                 hInstance,
00949                                 TEXT("AppIcon"));
00950   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00951                                 hInstance,
00952                                 TEXT("AppIcon"),
00953                                 IMAGE_ICON,
00954                                 16, 16,
00955                                 0);
00956   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
00957   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
00958   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
00959   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
00960
00961   // Register the window class and return FALSE if unsuccesful.
00962   bOk = RegisterClassEx(&wcf);
00963
00964   return (bOk);
00965 }
00966
00967
00968 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00969   Function: WinMain
00970
00971   Summary:  The Windows main entry point function for this application.
00972             Initializes the application, the COM Libraries, and starts
00973             the main application message loop.
00974
00975   Args:     HINSTANCE hInstance,
00976               Instance handle; a new one for each invocation of this app.
00977             HINSTANCE hPrevInstance,
00978               Instance handle of the previous instance. NULL in Win32.
00979             LPSTR lpCmdLine,
00980               Windows passes a pointer to the application's
00981               invocation command line.
00982             int nCmdShow)
00983               Bits telling the show state of the application.
00984
00985   Returns:  int
00986               msg.wParam (upon exit of message loop).
00987               FALSE if this instance couldn't initialize and run.
00988 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00989 extern "C" int PASCAL WinMain(
00990                         HINSTANCE hInstance,
00991                         HINSTANCE hPrevInstance,
00992                         LPSTR lpCmdLine,
00993                         int nCmdShow)
00994 {
00995   CMainWindow* pWin = NULL;
00996   MSG msg;
00997   HACCEL hAccel;
00998   int iRun = FALSE;
00999
01000   // If we were compiled for UNICODE and the platform seems OK with this
01001   // then proceed.  Else we error and exit the app.
01002   if (UnicodeOk())
01003   {
01004     // Call to initialize the COM Library.  Use the SUCCEEDED macro
01005     // to detect success.  If fail then exit app with error message.
01006     if (SUCCEEDED(CoInitialize(NULL)))
01007     {
01008       // If we succeeded in initializing the COM Library we proceed to
01009       // initialize the application.  If we can't init the application
01010       // then we signal shut down with an error message exit.
01011       iRun = InitApplication(hInstance);
01012
01013       if (iRun)
01014       {
01015         // Assume we'll set iRun to TRUE when initialization is done.
01016         iRun = FALSE;
01017         // We are still go for running so we try to create a nifty new
01018         // CMainWindow object for this app instance.
01019         pWin = new CMainWindow;
01020         if (NULL != pWin)
01021         {
01022           // Now we initialize an instance of the new CMainWindow.
01023           // This includes creating the main window.
01024           if (pWin->InitInstance(hInstance, nCmdShow))
01025           {
01026             // Load the keyboard accelerators from the resources.
01027             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
01028             if (NULL != hAccel)
01029             {
01030               // Signal App Initialization is successfully done.
01031               iRun = TRUE;
01032             }
01033           }
01034         }
01035       }
01036
01037       if (iRun)
01038       {
01039         // If we initialized the app instance properly then we are still
01040         // go for running.  We then start up the main message pump for
01041         // the application.
01042         while (GetMessage(&msg, NULL, 0, 0))
01043         {
01044           if (!TranslateAccelerator(
01045                  pWin->GetHwnd(),
01046                  hAccel,
01047                  &msg))
01048           {
01049             TranslateMessage(&msg);
01050             DispatchMessage(&msg);
01051           }
01052         }
01053
01054         // We'll pass to Windows the reason why we exited the message loop.
01055         iRun = (int) msg.wParam;
01056       }
01057       else
01058       {
01059         // We failed to initialize the application. Put up error message
01060         // box saying that application couldn't be initialized.  Parent
01061         // window is desktop (ie, NULL). Exit the failed application
01062         // (ie, by returning FALSE to WinMain).
01063         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
01064
01065         // Delete the CMainWindow object.
01066         DELETE_POINTER(pWin);
01067       }
01068
01069       // We're exiting this app (either normally or by init failure) so
01070       // shut down the COM Library.
01071       CoUninitialize();
01072     }
01073     else
01074     {
01075       // We failed to Initialize the COM Library. Put up error message box
01076       // saying that COM Library couldn't be initialized.  Parent window
01077       // is desktop (ie, NULL). Exit the failed application (ie, by
01078       // returning FALSE to WinMain).
01079       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
01080     }
01081   }
01082   else
01083   {
01084     // If we were compiled for UNICODE but the platform has problems with
01085     // this then indicate an error and exit the app immediately.
01086     CHAR szMsg[MAX_STRING_LENGTH];
01087
01088     if (LoadStringA(
01089           hInstance,
01090           IDS_UNICODEFAIL,
01091           szMsg,
01092           MAX_STRING_LENGTH))
01093     {
01094       MessageBoxA(
01095         NULL,
01096         szMsg,
01097         ERROR_TITLE_STR,
01098         MB_OK | MB_ICONEXCLAMATION);
01099     }
01100   }
01101
01102   return iRun;
01103 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/EncryptDecrypt/RSAKey/RSAKey.cpp Source File

  • Security
  • CryptoApi
  • EncryptDecrypt
  • RSAKey

RSAKey.cpp

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2002.  Microsoft Corporation.  All rights reserved.
00008 */
00009
00010 #define UNICODE
00011 #define _UNICODE
00012 #define _WIN32_WINNT 0x0400
00013
00014 #include <windows.h>
00015 #include <tchar.h>
00016 #include <stdio.h>
00017 #include <strsafe.h> // for proper buffer handling
00018
00019 const int IN_BUFFER_SIZE    = 64 * 1024;
00020 // OUT_BUFFER_SIZE is 8 bytes larger than IN_BUFFER_SIZE
00021 // When CALG_RC2 algorithm is used, encrypted data
00022 // will be 8 bytes larger than IN_BUFFER_SIZE
00023 const int OUT_BUFFER_SIZE   = IN_BUFFER_SIZE + 8; // extra padding
00024
00025 void PrintUsage();
00026 BOOL EncryptDecryptFile(LPTSTR lpszContainerName,
00027                         DWORD dwFlags,
00028                         LPTSTR lpszInputFileName,
00029                         LPTSTR lpszOutputFileName,
00030                         BOOL fEncrypt);
00031 void __cdecl MyPrintf(LPCTSTR lpszFormat, ...);
00032
00033 #define CheckAndLocalFree(ptr) \
00034             if (ptr != NULL) \
00035             { \
00036                LocalFree(ptr); \
00037                ptr = NULL; \
00038             }
00039
00040 void PrintUsage()
00041 {
00042    MyPrintf(_T("RSAKey [</e>|</d>] <KeyContainerName> [</u>|</m>] <InputFile> <OutputFile>\n"));
00043    MyPrintf(_T("/e for Encryption\n"));
00044    MyPrintf(_T("/d for Decryption\n"));
00045    MyPrintf(_T("/u for current user key container\n"));
00046    MyPrintf(_T("/m for local machine key container\n"));
00047 }
00048
00049 void __cdecl MyPrintf(LPCTSTR lpszFormat, ...)
00050 {
00051    TCHAR szOutput[2048];
00052    va_list v1 = NULL;
00053    HRESULT hr = S_OK;
00054
00055    va_start(v1, lpszFormat);
00056    hr = StringCbVPrintf(szOutput, sizeof(szOutput), lpszFormat, v1);
00057    if (SUCCEEDED(hr))
00058    {
00059       OutputDebugString(szOutput);
00060       _tprintf(szOutput);
00061    }
00062    else
00063    {
00064       _tprintf(_T("StringCbVPrintf failed with %X\n"), hr);
00065    }
00066 }
00067
00068 void _tmain(int argc, TCHAR **argv)
00069 {
00070    BOOL fEncrypt = FALSE;
00071    LPTSTR lpszContainerName = NULL;
00072    LPTSTR lpszInputFileName = NULL;
00073    LPTSTR lpszOutputFileName = NULL;
00074    DWORD dwFlags = 0;
00075
00076    if (argc != 6)
00077    {
00078       PrintUsage();
00079       return;
00080    }
00081
00082    /* Check whether the action to be performed is encrypt or decrypt */
00083    if (_tcsicmp(argv[1], _T("/e")) == 0)
00084    {
00085       fEncrypt = TRUE;
00086    }
00087    else if (_tcsicmp(argv[1], _T("/d")) == 0)
00088    {
00089       fEncrypt = FALSE;
00090    }
00091    else
00092    {
00093       PrintUsage();
00094       return;
00095    }
00096
00097    lpszContainerName = argv[2];
00098
00099    /* Check whether to use current user or local machine key container */
00100    if (_tcsicmp(argv[3], _T("/u")) == 0)
00101    {
00102       dwFlags = 0;
00103    }
00104    else if (_tcsicmp(argv[3], _T("/m")) == 0)
00105    {
00106       dwFlags = CRYPT_MACHINE_KEYSET;
00107    }
00108    else
00109    {
00110       PrintUsage();
00111       return;
00112    }
00113
00114    lpszInputFileName = argv[4];
00115    lpszOutputFileName = argv[5];
00116
00117    EncryptDecryptFile(lpszContainerName,
00118                         dwFlags,
00119                         lpszInputFileName,
00120                         lpszOutputFileName,
00121                         fEncrypt);
00122 }
00123
00124 BOOL EncryptDecryptFile(LPTSTR lpszContainerName,
00125                         DWORD dwFlags,
00126                         LPTSTR lpszInputFileName,
00127                         LPTSTR lpszOutputFileName,
00128                         BOOL fEncrypt)
00129 {
00130    BOOL fResult = FALSE;
00131    HCRYPTPROV hProv = NULL;
00132    HCRYPTKEY hRSAKey = NULL;
00133    HCRYPTKEY hSessionKey = NULL;
00134    HANDLE hInFile = INVALID_HANDLE_VALUE;
00135    HANDLE hOutFile = INVALID_HANDLE_VALUE;
00136    BOOL finished = FALSE;
00137    BYTE pbBuffer[OUT_BUFFER_SIZE];
00138    DWORD dwByteCount = 0;
00139    DWORD dwBytesRead = 0;
00140    DWORD dwBytesWritten = 0;
00141    LPBYTE pbSessionKeyBlob = NULL;
00142    DWORD dwSessionKeyBlob = 0;
00143    BOOL fSuccess = FALSE;
00144
00145    __try
00146    {
00147       // Open the input file to be encrypted or decrypted
00148       hInFile = CreateFile(lpszInputFileName,
00149                   GENERIC_READ,
00150                   0,
00151                   NULL,
00152                   OPEN_EXISTING,
00153                   FILE_ATTRIBUTE_NORMAL,
00154                   NULL);
00155       if (hInFile == INVALID_HANDLE_VALUE)
00156       {
00157          MyPrintf(_T("CreateFile failed with %d\n"), GetLastError());
00158          __leave;
00159       }
00160
00161       // Open the output file to write the encrypted or decrypted data
00162       hOutFile = CreateFile(lpszOutputFileName,
00163                   GENERIC_WRITE,
00164                   0,
00165                   NULL,
00166                   CREATE_ALWAYS,
00167                   FILE_ATTRIBUTE_NORMAL,
00168                   NULL);
00169       if (hOutFile == INVALID_HANDLE_VALUE)
00170       {
00171          MyPrintf(_T("CreateFile failed with %d\n"), GetLastError());
00172          __leave;
00173       }
00174
00175       // Acquire context for RSA key
00176       fResult = CryptAcquireContext(&hProv,
00177                      lpszContainerName,
00178                      MS_DEF_PROV,
00179                      PROV_RSA_FULL,
00180                      dwFlags);
00181       if (!fResult)
00182       {
00183          if (GetLastError() == NTE_BAD_KEYSET)
00184          {
00185             // Create a key container if one does not exist.
00186             fResult = CryptAcquireContext(&hProv,
00187                         lpszContainerName,
00188                         MS_DEF_PROV,
00189                         PROV_RSA_FULL,
00190                         CRYPT_NEWKEYSET | dwFlags);
00191             if (!fResult)
00192             {
00193                MyPrintf(_T("CryptAcquireContext (2) failed with %X\n"), GetLastError());
00194                __leave;
00195             }
00196         }
00197         else
00198         {
00199             MyPrintf(_T("CryptAcquireContext (1) failed with %X\n"), GetLastError());
00200             __leave;
00201         }
00202       }
00203
00204       // Get the RSA key handle
00205       fResult = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hRSAKey);
00206       if (!fResult)
00207       {
00208          if (GetLastError() == NTE_NO_KEY)
00209          {
00210             // Create a key if one does not exist.
00211             fResult = CryptGenKey(hProv,
00212                         AT_KEYEXCHANGE,
00213                         CRYPT_EXPORTABLE,
00214                         &hRSAKey);
00215             if (!fResult)
00216             {
00217                MyPrintf(_T("CryptGenKey failed with %X\n"), GetLastError());
00218                __leave;
00219             }
00220          }
00221          else
00222          {
00223             MyPrintf(_T("CryptGetUserKey failed with %X\n"), GetLastError());
00224             __leave;
00225          }
00226       }
00227
00228       if (fEncrypt)
00229       {
00230          fResult = CryptGenKey(hProv, CALG_RC4, CRYPT_EXPORTABLE, &hSessionKey);
00231          if (!fResult)
00232          {
00233             MyPrintf(_T("CryptGenKey failed with %X\n"), GetLastError());
00234             __leave;
00235          }
00236
00237          // The first call to ExportKey with NULL gets the key size.
00238          dwSessionKeyBlob = 0;
00239          fResult = CryptExportKey(hSessionKey, hRSAKey, SIMPLEBLOB, 0,
00240                      NULL, &dwSessionKeyBlob);
00241          if (!fResult)
00242          {
00243             MyPrintf(_T("CryptExportKey failed with %X\n"), GetLastError());
00244             __leave;
00245          }
00246
00247          // Allocate memory for Encrypted Session key blob
00248          pbSessionKeyBlob = (LPBYTE)LocalAlloc(LPTR, dwSessionKeyBlob);
00249          if (!pbSessionKeyBlob)
00250          {
00251             MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00252             __leave;
00253          }
00254
00255          fResult = CryptExportKey(hSessionKey, hRSAKey, SIMPLEBLOB, 0,
00256                      pbSessionKeyBlob, &dwSessionKeyBlob);
00257          if (!fResult)
00258          {
00259             MyPrintf(_T("CryptExportKey failed with %X\n"), GetLastError());
00260             __leave;
00261          }
00262
00263          // Write the size of key blob, then the key blob itself, to output file.
00264          fResult = WriteFile(hOutFile, &dwSessionKeyBlob,
00265                      sizeof(dwSessionKeyBlob),
00266                      &dwBytesWritten, NULL);
00267          if (!fResult)
00268          {
00269             MyPrintf(_T("WriteFile failed with %d\n"), GetLastError());
00270             __leave;
00271          }
00272          fResult = WriteFile(hOutFile, pbSessionKeyBlob,
00273                      dwSessionKeyBlob,
00274                      &dwBytesWritten, NULL);
00275          if (!fResult)
00276          {
00277             MyPrintf(_T("WriteFile failed with %d\n"), GetLastError());
00278             __leave;
00279          }
00280       }
00281       else
00282       {
00283          // Read in key block size, then key blob itself from input file.
00284          fResult = ReadFile(hInFile, &dwByteCount, sizeof(dwByteCount),
00285                &dwBytesRead, NULL);
00286          if (!fResult)
00287          {
00288             MyPrintf(_T("ReadFile failed with %d\n"), GetLastError());
00289             __leave;
00290          }
00291
00292          fResult = ReadFile(hInFile, pbBuffer, dwByteCount, &dwBytesRead, NULL);
00293          if (!fResult)
00294          {
00295             MyPrintf(_T("ReadFile failed with %d\n"), GetLastError());
00296             __leave;
00297          }
00298
00299          // import key blob into "CSP"
00300          fResult = CryptImportKey(hProv, pbBuffer, dwByteCount, hRSAKey, 0, &hSessionKey);
00301          if (!fResult)
00302          {
00303             MyPrintf(_T("CryptImportKey failed with %X\n"), GetLastError());
00304             __leave;
00305          }
00306       }
00307
00308       do
00309       {
00310          dwByteCount = 0;
00311
00312          // Now read data from the input file 64K bytes at a time.
00313          fResult = ReadFile(hInFile, pbBuffer, IN_BUFFER_SIZE, &dwByteCount, NULL);
00314
00315          // If the file size is exact multiple of 64K, dwByteCount will be zero after
00316          // all the data has been read from the input file. In this case, simply break
00317          // from the while loop. The check to do this is below
00318          if (dwByteCount == 0)
00319             break;
00320
00321          if (!fResult)
00322          {
00323             MyPrintf(_T("ReadFile failed with %d\n"), GetLastError());
00324             __leave;
00325          }
00326
00327          finished = (dwByteCount < IN_BUFFER_SIZE);
00328
00329          // Encrypt/Decrypt depending on the required action.
00330          if (fEncrypt)
00331          {
00332             fResult = CryptEncrypt(hSessionKey, 0, finished, 0, pbBuffer, &dwByteCount,
00333                            OUT_BUFFER_SIZE);
00334             if (!fResult)
00335             {
00336                MyPrintf(_T("CryptEncrypt failed with %X\n"), GetLastError());
00337                __leave;
00338             }
00339          }
00340          else
00341          {
00342             fResult = CryptDecrypt(hSessionKey, 0, finished, 0, pbBuffer, &dwByteCount);
00343             if (!fResult)
00344             {
00345                MyPrintf(_T("CryptDecrypt failed with %X\n"), GetLastError());
00346                __leave;
00347             }
00348          }
00349
00350          // Write the encrypted/decrypted data to the output file.
00351          fResult = WriteFile(hOutFile, pbBuffer, dwByteCount,
00352             &dwBytesWritten, NULL);
00353          if (!fResult)
00354          {
00355             MyPrintf(_T("WriteFile failed with %d\n"), GetLastError());
00356             __leave;
00357          }
00358
00359       } while (!finished);
00360
00361       if (fEncrypt)
00362          MyPrintf(_T("File %s is encrypted successfully!\n"), lpszInputFileName);
00363       else
00364          MyPrintf(_T("File %s is decrypted successfully!\n"), lpszInputFileName);
00365
00366       fSuccess = TRUE;
00367    }
00368    __finally
00369    {
00370       /* Cleanup */
00371       CheckAndLocalFree(pbSessionKeyBlob);
00372       if (hRSAKey != NULL) CryptDestroyKey(hRSAKey);
00373       if (hSessionKey != NULL) CryptDestroyKey(hSessionKey);
00374       if (hProv != NULL) CryptReleaseContext(hProv, 0);
00375       if (hInFile != INVALID_HANDLE_VALUE) CloseHandle(hInFile);
00376       if (hOutFile != INVALID_HANDLE_VALUE) CloseHandle(hOutFile);
00377    }
00378
00379    return fSuccess;
00380 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows.Net/certxsam.idl Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows.Net

certxsam.idl

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        certxsam.idl
00007 //
00008 // Contents:    IDL source for certsam
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 import "wtypes.idl";
00013 import "certexit.idl";
00014 import "certmod.idl";
00015
00016
00017 //+--------------------------------------------------------------------------
00018 // certexit Type library
00019 //+--------------------------------------------------------------------------
00020
00021 [
00022     uuid(d29571d0-c2c8-11d2-b313-00c04f79dc72),
00023     version(1.0),
00024     helpstring("CertExitSample 1.0 Type Library")
00025 ]
00026
00027 library CERTEXITSAMPLELib
00028 {
00029     importlib("stdole2.tlb");
00030
00031     [
00032   uuid(d2075560-c2c8-11d2-b313-00c04f79dc72),
00033   helpstring("CertExitSample Class")
00034     ]
00035     coclass CCertExitSample
00036     {
00037   [default] interface ICertExit;
00038     };
00039
00040     [
00041   uuid(d3099410-c2c8-11d2-b313-00c04f79dc72),
00042   helpstring("CertManageExitModuleSample Class")
00043     ]
00044     coclass CCertManageExitModuleSample
00045     {
00046   [default] interface ICertManageModule;
00047     };
00048 };
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/AdvClientdlg.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

AdvClientdlg.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  HMMSampDlg.cpp
00006 //
00007 // Description:
00008 //  This file implements the CAdvClientDlg dialog class which
00009 //    is the main dialog for the tutorial.
00010 //
00011 // History:
00012 //
00013 // **************************************************************************
00014
00015
00016 #include "stdafx.h"
00017 #include "AdvClient.h"
00018 #include "AdvClientDlg.h"
00019 #include "OnAsync.h"
00020 #include <strsafe.h>
00021
00022
00023 #ifdef _DEBUG
00024 #define new DEBUG_NEW
00025 #undef THIS_FILE
00026 static char THIS_FILE[] = __FILE__;
00027 #endif
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CAboutDlg dialog used for App About
00031
00032 class CAboutDlg : public CDialog
00033 {
00034 public:
00035   CAboutDlg();
00036
00037 // Dialog Data
00038   //{{AFX_DATA(CAboutDlg)
00039   enum { IDD = IDD_ABOUTBOX };
00040   //}}AFX_DATA
00041
00042   // ClassWizard generated virtual function overrides
00043   //{{AFX_VIRTUAL(CAboutDlg)
00044   protected:
00045   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00046   //}}AFX_VIRTUAL
00047
00048 // Implementation
00049 protected:
00050   //{{AFX_MSG(CAboutDlg)
00051   //}}AFX_MSG
00052   DECLARE_MESSAGE_MAP()
00053 };
00054
00055 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00056 {
00057   //{{AFX_DATA_INIT(CAboutDlg)
00058   //}}AFX_DATA_INIT
00059 }
00060
00061 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00062 {
00063   CDialog::DoDataExchange(pDX);
00064   //{{AFX_DATA_MAP(CAboutDlg)
00065   //}}AFX_DATA_MAP
00066 }
00067
00068 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00069   //{{AFX_MSG_MAP(CAboutDlg)
00070     // No message handlers
00071   //}}AFX_MSG_MAP
00072 END_MESSAGE_MAP()
00073
00074 // **************************************************************************
00075 //
00076 //  CAdvClientDlg::CAdvClientDlg()
00077 //
00078 // Description:
00079 //    Constructor for the main dialog. Puts the default namespace
00080 //    in the edit box and initializes variables.
00081 // Parameters:
00082 //    pParent (in) - parent window.
00083 //
00084 // Returns:
00085 //    nothing.
00086 //
00087 // Globals accessed:
00088 //    None.
00089 //
00090 // Globals modified:
00091 //    None.
00092 //
00093 //===========================================================================
00094 CAdvClientDlg::CAdvClientDlg(CWnd* pParent /*=NULL*/)
00095   : CDialog(CAdvClientDlg::IDD, pParent),
00096   m_threadId(0), m_thread(0), m_ptrReady(0), m_stopThread(0)
00097 {
00098   //{{AFX_DATA_INIT(CAdvClientDlg)
00099   m_namespace = _T("\\\\.\\root\\cimv2");
00100   //}}AFX_DATA_INIT
00101
00102   m_pIWbemServices = NULL;
00103   m_pOfficeService = NULL;
00104   m_pQueryCallback = NULL;
00105   m_regPerm = TRUE;
00106   m_regTemp = TRUE;
00107   m_pStream = NULL;
00108
00109     InitializeCriticalSection(&m_critSect);
00110   m_stopThread = CreateEvent(NULL, FALSE, FALSE, NULL);
00111   m_ptrReady = CreateEvent(NULL, FALSE, FALSE, NULL);
00112
00113
00114 }
00115
00116 // **************************************************************************
00117 //
00118 //  CAdvClientDlg::~CAdvClientDlg()
00119 //
00120 // Description:
00121 //    Destructor. Releases COM interfaces for the dialog class.
00122 // Parameters:
00123 //    None.
00124 //
00125 // Returns:
00126 //    nothing.
00127 //
00128 // Globals accessed:
00129 //    None.
00130 //
00131 // Globals modified:
00132 //    None.
00133 //
00134 //===========================================================================
00135 CAdvClientDlg::~CAdvClientDlg()
00136 {
00137
00138   if (m_thread != NULL)
00139   {
00140     OnTempUnregister();
00141   }
00142
00143   // done with m_pQueryCallback sink.
00144   if(m_pQueryCallback)
00145   {
00146     m_pQueryCallback->Release();
00147     delete m_pQueryCallback;
00148     m_pQueryCallback = NULL;
00149   }
00150
00151   // done with m_pIWbemServices.
00152   if (m_pIWbemServices)
00153   {
00154     m_pIWbemServices->Release();
00155     m_pIWbemServices = NULL;
00156   }
00157   // done with m_pIWbemServices.
00158   if (m_pOfficeService)
00159   {
00160     m_pOfficeService->Release();
00161     m_pOfficeService = NULL;
00162   }
00163
00164   StopThread();
00165
00166     DeleteCriticalSection(&m_critSect);
00167
00168
00169 }
00170 void CAdvClientDlg::DoDataExchange(CDataExchange* pDX)
00171 {
00172   CDialog::DoDataExchange(pDX);
00173   //{{AFX_DATA_MAP(CAdvClientDlg)
00174   DDX_Control(pDX, IDC_DISK_PROPS_DESCRIPTIONS, m_diskDescriptions);
00175   DDX_Control(pDX, IDC_EVENTLIST, m_eventList);
00176   DDX_Control(pDX, IDC_REGPERM, m_perm);
00177   DDX_Control(pDX, IDC_REGTEMP, m_temp);
00178   DDX_Control(pDX, IDC_ADDEQUIPMENT, m_addEquipment);
00179   DDX_Control(pDX, IDC_ENUMSERVICES, m_enumServices);
00180   DDX_Control(pDX, IDC_ENUMSERVICESASYNC, m_enumServicesAsync);
00181   DDX_Control(pDX, IDC_ENUMDISKS, m_enumDisks);
00182   DDX_Control(pDX, IDC_DISKDETAILS, m_diskDetails);
00183   DDX_Control(pDX, IDC_CONNECT, m_connect);
00184   DDX_Control(pDX, IDC_OUTPUTLIST, m_outputList);
00185   DDX_Text(pDX, IDC_NAMESPACE, m_namespace);
00186   //}}AFX_DATA_MAP
00187 }
00188
00189 BEGIN_MESSAGE_MAP(CAdvClientDlg, CDialog)
00190   //{{AFX_MSG_MAP(CAdvClientDlg)
00191   ON_WM_SYSCOMMAND()
00192   ON_BN_CLICKED(IDC_ADDEQUIPMENT, OnAddEquipment)
00193   ON_BN_CLICKED(IDC_CONNECT, OnConnect)
00194   ON_BN_CLICKED(IDC_ENUMDISKS, OnEnumdisks)
00195   ON_BN_CLICKED(IDC_ENUMSERVICES, OnEnumservices)
00196   ON_BN_CLICKED(IDC_ENUMSERVICESASYNC, OnEnumservicesasync)
00197   ON_BN_CLICKED(IDC_DISKDETAILS, OnDiskdetails)
00198   ON_BN_CLICKED(IDC_REGPERM, OnRegPerm)
00199   ON_BN_CLICKED(IDC_REGTEMP, OnRegTemp)
00200   ON_WM_QUERYDRAGICON()
00201   ON_BN_CLICKED(IDC_DISK_PROPS_DESCRIPTIONS, OnDiskPropsDescriptions)
00202   //}}AFX_MSG_MAP
00203 END_MESSAGE_MAP()
00204
00205 /////////////////////////////////////////////////////////////////////////////
00206 // CAdvClientDlg message handlers
00207
00208 BOOL CAdvClientDlg::OnInitDialog()
00209 {
00210   CDialog::OnInitDialog();
00211
00212   // Add "About..." menu item to system menu.
00213
00214   // IDM_ABOUTBOX must be in the system command range.
00215   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00216   ASSERT(IDM_ABOUTBOX < 0xF000);
00217
00218   CMenu* pSysMenu = GetSystemMenu(FALSE);
00219   if (pSysMenu != NULL)
00220   {
00221     CString strAboutMenu;
00222     strAboutMenu.LoadString(IDS_ABOUTBOX);
00223     if (!strAboutMenu.IsEmpty())
00224     {
00225       pSysMenu->AppendMenu(MF_SEPARATOR);
00226       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
00227     }
00228   }
00229
00230   //make scrollable horizontally by 5000 pixels
00231   m_outputList.SetHorizontalExtent(5000);
00232
00233
00234   return TRUE;  // return TRUE  unless you set the focus to a control
00235 }
00236
00237 void CAdvClientDlg::OnSysCommand(UINT nID, LPARAM lParam)
00238 {
00239   if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00240   {
00241     CAboutDlg dlgAbout;
00242     dlgAbout.DoModal();
00243   }
00244   else
00245   {
00246     CDialog::OnSysCommand(nID, lParam);
00247   }
00248 }
00249
00250
00251 // **************************************************************************
00252 //
00253 //  ErrorString()
00254 //
00255 // Description:
00256 //    Converts an HRESULT to a displayable string.
00257 //
00258 // Parameters:
00259 //    hRes (in) - HRESULT to be converted.
00260 //
00261 // Returns:
00262 //    ptr to displayable string.
00263 //
00264 // Globals accessed:
00265 //    None.
00266 //
00267 // Globals modified:
00268 //    None.
00269 //
00270 //===========================================================================
00271 LPCTSTR ErrorString(HRESULT hRes)
00272 {
00273     TCHAR szBuffer2[19];
00274   static TCHAR szBuffer[24];
00275   LPCTSTR psz;
00276
00277    switch(hRes)
00278    {
00279    case WBEM_NO_ERROR:
00280     psz = _T("WBEM_NO_ERROR");
00281     break;
00282    case WBEM_S_FALSE:
00283     psz = _T("WBEM_S_FALSE");
00284     break;
00285    case WBEM_S_NO_MORE_DATA:
00286     psz = _T("WBEM_S_NO_MORE_DATA");
00287     break;
00288   case WBEM_E_FAILED:
00289     psz = _T("WBEM_E_FAILED");
00290     break;
00291   case WBEM_E_NOT_FOUND:
00292     psz = _T("WBEM_E_NOT_FOUND");
00293     break;
00294   case WBEM_E_ACCESS_DENIED:
00295     psz = _T("WBEM_E_ACCESS_DENIED");
00296     break;
00297   case WBEM_E_PROVIDER_FAILURE:
00298     psz = _T("WBEM_E_PROVIDER_FAILURE");
00299     break;
00300   case WBEM_E_TYPE_MISMATCH:
00301     psz = _T("WBEM_E_TYPE_MISMATCH");
00302     break;
00303   case WBEM_E_OUT_OF_MEMORY:
00304     psz = _T("WBEM_E_OUT_OF_MEMORY");
00305     break;
00306   case WBEM_E_INVALID_CONTEXT:
00307     psz = _T("WBEM_E_INVALID_CONTEXT");
00308     break;
00309   case WBEM_E_INVALID_PARAMETER:
00310     psz = _T("WBEM_E_INVALID_PARAMETER");
00311     break;
00312   case WBEM_E_NOT_AVAILABLE:
00313     psz = _T("WBEM_E_NOT_AVAILABLE");
00314     break;
00315   case WBEM_E_CRITICAL_ERROR:
00316     psz = _T("WBEM_E_CRITICAL_ERROR");
00317     break;
00318   case WBEM_E_INVALID_STREAM:
00319     psz = _T("WBEM_E_INVALID_STREAM");
00320     break;
00321   case WBEM_E_NOT_SUPPORTED:
00322     psz = _T("WBEM_E_NOT_SUPPORTED");
00323     break;
00324   case WBEM_E_INVALID_SUPERCLASS:
00325     psz = _T("WBEM_E_INVALID_SUPERCLASS");
00326     break;
00327   case WBEM_E_INVALID_NAMESPACE:
00328     psz = _T("WBEM_E_INVALID_NAMESPACE");
00329     break;
00330   case WBEM_E_INVALID_OBJECT:
00331     psz = _T("WBEM_E_INVALID_OBJECT");
00332     break;
00333   case WBEM_E_INVALID_CLASS:
00334     psz = _T("WBEM_E_INVALID_CLASS");
00335     break;
00336   case WBEM_E_PROVIDER_NOT_FOUND:
00337     psz = _T("WBEM_E_PROVIDER_NOT_FOUND");
00338     break;
00339   case WBEM_E_INVALID_PROVIDER_REGISTRATION:
00340     psz = _T("WBEM_E_INVALID_PROVIDER_REGISTRATION");
00341     break;
00342   case WBEM_E_PROVIDER_LOAD_FAILURE:
00343     psz = _T("WBEM_E_PROVIDER_LOAD_FAILURE");
00344     break;
00345   case WBEM_E_INITIALIZATION_FAILURE:
00346     psz = _T("WBEM_E_INITIALIZATION_FAILURE");
00347     break;
00348   case WBEM_E_TRANSPORT_FAILURE:
00349     psz = _T("WBEM_E_TRANSPORT_FAILURE");
00350     break;
00351   case WBEM_E_INVALID_OPERATION:
00352     psz = _T("WBEM_E_INVALID_OPERATION");
00353     break;
00354   case WBEM_E_INVALID_QUERY:
00355     psz = _T("WBEM_E_INVALID_QUERY");
00356     break;
00357   case WBEM_E_INVALID_QUERY_TYPE:
00358     psz = _T("WBEM_E_INVALID_QUERY_TYPE");
00359     break;
00360   case WBEM_E_ALREADY_EXISTS:
00361     psz = _T("WBEM_E_ALREADY_EXISTS");
00362     break;
00363    case WBEM_S_ALREADY_EXISTS:
00364       psz = _T("WBEM_S_ALREADY_EXISTS");
00365       break;
00366    case WBEM_S_RESET_TO_DEFAULT:
00367       psz = _T("WBEM_S_RESET_TO_DEFAULT");
00368       break;
00369    case WBEM_S_DIFFERENT:
00370       psz = _T("WBEM_S_DIFFERENT");
00371       break;
00372    case WBEM_E_OVERRIDE_NOT_ALLOWED:
00373       psz = _T("WBEM_E_OVERRIDE_NOT_ALLOWED");
00374       break;
00375    case WBEM_E_PROPAGATED_QUALIFIER:
00376       psz = _T("WBEM_E_PROPAGATED_QUALIFIER");
00377       break;
00378    case WBEM_E_PROPAGATED_PROPERTY:
00379       psz = _T("WBEM_E_PROPAGATED_PROPERTY");
00380       break;
00381    case WBEM_E_UNEXPECTED:
00382       psz = _T("WBEM_E_UNEXPECTED");
00383       break;
00384    case WBEM_E_ILLEGAL_OPERATION:
00385       psz = _T("WBEM_E_ILLEGAL_OPERATION");
00386       break;
00387    case WBEM_E_CANNOT_BE_KEY:
00388       psz = _T("WBEM_E_CANNOT_BE_KEY");
00389       break;
00390    case WBEM_E_INCOMPLETE_CLASS:
00391       psz = _T("WBEM_E_INCOMPLETE_CLASS");
00392       break;
00393    case WBEM_E_INVALID_SYNTAX:
00394       psz = _T("WBEM_E_INVALID_SYNTAX");
00395       break;
00396    case WBEM_E_NONDECORATED_OBJECT:
00397       psz = _T("WBEM_E_NONDECORATED_OBJECT");
00398       break;
00399    case WBEM_E_READ_ONLY:
00400       psz = _T("WBEM_E_READ_ONLY");
00401       break;
00402    case WBEM_E_PROVIDER_NOT_CAPABLE:
00403       psz = _T("WBEM_E_PROVIDER_NOT_CAPABLE");
00404       break;
00405    case WBEM_E_CLASS_HAS_CHILDREN:
00406       psz = _T("WBEM_E_CLASS_HAS_CHILDREN");
00407       break;
00408    case WBEM_E_CLASS_HAS_INSTANCES:
00409       psz = _T("WBEM_E_CLASS_HAS_INSTANCES");
00410       break;
00411    case WBEM_E_QUERY_NOT_IMPLEMENTED:
00412       psz = _T("WBEM_E_QUERY_NOT_IMPLEMENTED");
00413       break;
00414    case WBEM_E_ILLEGAL_NULL:
00415       psz = _T("WBEM_E_ILLEGAL_NULL");
00416       break;
00417    case WBEM_E_INVALID_QUALIFIER_TYPE:
00418       psz = _T("WBEM_E_INVALID_QUALIFIER_TYPE");
00419       break;
00420    case WBEM_E_INVALID_PROPERTY_TYPE:
00421       psz = _T("WBEM_E_INVALID_PROPERTY_TYPE");
00422       break;
00423    case WBEM_E_VALUE_OUT_OF_RANGE:
00424       psz = _T("WBEM_E_VALUE_OUT_OF_RANGE");
00425       break;
00426    case WBEM_E_CANNOT_BE_SINGLETON:
00427       psz = _T("WBEM_E_CANNOT_BE_SINGLETON");
00428       break;
00429   default:
00430       _itot(hRes, szBuffer2, 16);
00431     StringCbCopy(szBuffer, sizeof(szBuffer),_T("0x"));
00432       StringCbCat(szBuffer, sizeof(szBuffer), szBuffer2);
00433     psz = szBuffer;
00434   }
00435   return psz;
00436 }
00437
00438 // **************************************************************************
00439 //
00440 //  ValueToString()
00441 //
00442 // Description:
00443 //    Converts a variant to a displayable string.
00444 //
00445 // Parameters:
00446 //    pValue (in) - variant to be converted.
00447 //    pbuf (out) - ptr to receive displayable string.
00448 //
00449 // Returns:
00450 //    Same as pbuf.
00451 //
00452 // Globals accessed:
00453 //    None.
00454 //
00455 // Globals modified:
00456 //    None.
00457 //
00458 //===========================================================================
00459 #define BLOCKSIZE (32 * sizeof(WCHAR))
00460 #define CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop  (this size stolen from cvt.h in c runtime library) */
00461
00462 LPWSTR ValueToString(VARIANT *pValue, WCHAR **pbuf)
00463 {
00464    DWORD iNeed = 0;
00465    DWORD iVSize = 0;
00466    DWORD iCurBufSize = 0;
00467
00468    WCHAR *vbuf = NULL;
00469    WCHAR *buf = NULL;
00470
00471    switch (pValue->vt)
00472    {
00473    case VT_NULL:
00474          buf = (WCHAR *)malloc(BLOCKSIZE);
00475      if (buf)
00476       StringCbCopyW(buf, BLOCKSIZE, L"<null>");
00477          break;
00478
00479    case VT_BOOL: {
00480          VARIANT_BOOL b = pValue->boolVal;
00481          buf = (WCHAR *)malloc(BLOCKSIZE);
00482      if (buf)
00483      {
00484       if (!b) {
00485         StringCbCopyW(buf, BLOCKSIZE, L"FALSE");
00486
00487       } else {
00488         StringCbCopyW(buf, BLOCKSIZE, L"TRUE");
00489       }
00490     }
00491          break;
00492       }
00493
00494    case VT_UI1: {
00495       unsigned char b = pValue->bVal;
00496         buf = (WCHAR *)malloc(BLOCKSIZE);
00497         if (buf)
00498         {
00499             if (b >= 32)
00500             {
00501                 StringCbPrintfW(buf, BLOCKSIZE, L"'%c' (%hu, 0x%hX)", b, (unsigned char)b, b);
00502             }
00503             else
00504             {
00505                 StringCbPrintfW(buf, BLOCKSIZE, L"%hu (0x%hX)", (unsigned char)b, b);
00506             }
00507         }
00508         break;
00509   }
00510    case VT_I2:  {
00511         USHORT i = pValue->uiVal;
00512         buf = (WCHAR *)malloc(BLOCKSIZE);
00513         if (buf)
00514         {
00515             StringCbPrintfW(buf, BLOCKSIZE, L"%hu (0x%hX)", i, i);
00516         }
00517         break;
00518     }
00519
00520    case VT_I4: {
00521          LONG l = pValue->lVal;
00522         buf = (WCHAR *)malloc(BLOCKSIZE);
00523         if (buf)
00524         {
00525             StringCbPrintfW(buf, BLOCKSIZE, L"%d (0x%X)", l, l);
00526         }
00527         break;
00528       }
00529
00530    case VT_R4: {
00531         float f = pValue->fltVal;
00532         buf = (WCHAR *)malloc(CVTBUFSIZE * sizeof(WCHAR));
00533         if (buf)
00534         {
00535             StringCbPrintfW(buf, BLOCKSIZE,  L"%10.4f", f);
00536         }
00537         break;
00538       }
00539
00540    case VT_R8: {
00541     double d = pValue->dblVal;
00542         buf = (WCHAR *)malloc(CVTBUFSIZE * sizeof(WCHAR));
00543         if (buf)
00544         {
00545             StringCbPrintfW(buf, BLOCKSIZE, L"%10.4f", d);
00546         }
00547         break;
00548     }
00549
00550    case VT_BSTR: {
00551      LPWSTR pWStr = pValue->bstrVal;
00552      int bufSize = (wcslen(pWStr) * sizeof(WCHAR)) + sizeof(WCHAR) + (2 * sizeof(WCHAR));
00553      buf = (WCHAR *)malloc(bufSize);
00554      if (buf)
00555       StringCbPrintfW(buf, bufSize, L"\"%wS\"", pWStr);
00556      break;
00557     }
00558
00559   // the sample GUI is too simple to make it necessary to display
00560   // these 'complicated' types--so ignore them.
00561    case VT_DISPATCH:  // Currently only used for embedded objects
00562    case VT_BOOL|VT_ARRAY:
00563    case VT_UI1|VT_ARRAY:
00564    case VT_I2|VT_ARRAY:
00565    case VT_I4|VT_ARRAY:
00566    case VT_R4|VT_ARRAY:
00567    case VT_R8|VT_ARRAY:
00568    case VT_BSTR|VT_ARRAY:
00569    case VT_DISPATCH | VT_ARRAY:
00570          break;
00571
00572    default:
00573          buf = (WCHAR *)malloc(BLOCKSIZE);
00574      if (buf)
00575       StringCbCopyW(buf, BLOCKSIZE, L"<conversion error>");
00576    }
00577
00578    *pbuf = buf;
00579    return buf;
00580 }
00581 // **************************************************************************
00582 //
00583 //  CAdvClientDlg::EnsureOfficeNamespace()
00584 //
00585 // Description:
00586 //    Returns a pointer to root\cimv2\office namespace; creating
00587 //    it if it doesn't already exist
00588 // Parameters:
00589 //    None.
00590 //
00591 // Returns:
00592 //    COM interface to the namespace.
00593 //
00594 // Globals accessed:
00595 //    None.
00596 //
00597 // Globals modified:
00598 //    None.
00599 //
00600 //===========================================================================
00601 BOOL CAdvClientDlg::EnsureOfficeNamespace(void)
00602 {
00603   IWbemClassObject *pNSClass = NULL;
00604   IWbemClassObject *pNSInst = NULL;
00605
00606   BSTR Prop = NULL;
00607   VARIANT v;
00608   HRESULT hRes;
00609
00610   BSTR Namespace = SysAllocString(L"SAMPLE_Office");
00611   if (Namespace == NULL)
00612   {
00613     return FALSE;
00614   }
00615
00616   // avoid getting another pointer if you already one. Potential
00617   // leak if you do.
00618   if(m_pOfficeService != NULL)
00619   {
00620     return TRUE;
00621   }
00622
00623   // if 'Office' namespace doesnt exists...
00624   if((hRes = m_pIWbemServices->OpenNamespace(Namespace, 0, NULL, &m_pOfficeService, NULL)) != S_OK)
00625   { // create it.
00626
00627     BSTR NamespaceClass = SysAllocString(L"__Namespace");
00628     if (NamespaceClass == NULL)
00629     {
00630       SysFreeString(Namespace);
00631       return FALSE;
00632     }
00633
00634     //-----------------------------------
00635     // get the namespace class
00636     hRes = m_pIWbemServices->GetObject(NamespaceClass,
00637                       0L, NULL,
00638                       &pNSClass,
00639                       NULL);
00640
00641     SysFreeString(NamespaceClass);
00642     if(hRes == S_OK)
00643     {
00644       //-----------------------------------
00645       // spawn a new instance
00646       if((hRes = pNSClass->SpawnInstance(0, &pNSInst)) == S_OK)
00647       {
00648         TRACE(_T("SpawnInstance() worked\n"));
00649
00650         // set the namespace's name.
00651         VariantInit(&v);
00652         V_VT(&v) = VT_BSTR;
00653         V_BSTR(&v) = Namespace;
00654         Prop = SysAllocString(L"Name");
00655         if (Prop == NULL)
00656         {
00657           pNSClass->Release();  // Don't need the class any more
00658           pNSClass = NULL;
00659           SysFreeString(Namespace);
00660           return FALSE;
00661         }
00662
00663         pNSInst->Put(Prop, 0, &v, 0);
00664
00665         SysFreeString(Prop);
00666         VariantClear(&v);
00667
00668         // create the instance.
00669         hRes = m_pIWbemServices->PutInstance(pNSInst, 0, NULL, NULL);
00670         pNSInst->Release();
00671         pNSInst = NULL;
00672
00673         //-----------------------------------
00674         // open the new namespace.
00675         if((hRes = m_pIWbemServices->OpenNamespace(Namespace, 0, NULL, &m_pOfficeService, NULL)) != S_OK)
00676         {
00677           TRACE(_T("OpenNamespace() still failed: %s\n"), ErrorString(hRes));
00678         } // endif OpenNamespace() again
00679       }
00680       else
00681       {
00682         TRACE(_T("SpawnInstance() failed: %s\n"), ErrorString(hRes));
00683
00684       } //endif SpawnInstance()
00685
00686       pNSClass->Release();  // Don't need the class any more
00687       pNSClass = NULL;
00688     }
00689
00690   } //endif OpenNamespace()
00691
00692   SysFreeString(Namespace);
00693
00694   // NOTE: The caller needs to Release() it.
00695   return (m_pOfficeService != NULL);
00696 }
00697 //--------------------------------------------------------
00698 BOOL CAdvClientDlg::CheckOfficeNamespace(void)
00699 {
00700   IWbemServices *pOfficeService = NULL;
00701   HRESULT hRes;
00702   BOOL itsThere = FALSE;
00703
00704   // lazy check first.
00705   if(m_pOfficeService != NULL) return TRUE;
00706
00707   // do some real work now.
00708   BSTR Namespace = SysAllocString(L"SAMPLE_Office");
00709   if (Namespace == NULL)
00710     return FALSE; //out of memory
00711
00712   // if 'Office' namespace doesnt exists...
00713   if((hRes = m_pIWbemServices->OpenNamespace(Namespace, 0, NULL,
00714                         &pOfficeService, NULL)) == S_OK)
00715   {
00716     itsThere = TRUE;
00717     pOfficeService->Release();
00718     pOfficeService = NULL;
00719
00720   } //endif OpenNamespace()
00721
00722   SysFreeString(Namespace);
00723
00724   return itsThere;
00725 }
00726
00727 //---------------------------------------------------------------
00728 void CAdvClientDlg::OnCancel()
00729 {
00730   // make sure you unregister that sink.
00731   if (m_thread != NULL)
00732   {
00733     OnTempUnregister();
00734   }
00735
00736   CDialog::OnCancel();
00737 }
00738
00739
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/people.Cpp Source File

  • SysMgmt
  • MMC
  • Menubtn

people.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include "People.h"
00021
00022 const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 const GUID CBicycleFolder::thisGuid = { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00025 const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00026 const GUID CIceSkateFolder::thisGuid = { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00027
00028 const GUID CBicycle::thisGuid = { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00029 const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00030 const GUID CIceSkate::thisGuid = { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00031
00032
00033 //==============================================================
00034 //
00035 // CPeoplePoweredVehicle implementation
00036 //
00037 //
00038 CPeoplePoweredVehicle::CPeoplePoweredVehicle()
00039 {
00040     children[0] = new CBicycleFolder;
00041     children[1] = new CSkateboardFolder;
00042     children[2] = new CIceSkateFolder;
00043 }
00044
00045 CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
00046 {
00047     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00048         delete children[n];
00049 }
00050
00051 HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00052 {
00053     SCOPEDATAITEM sdi;
00054
00055     if (!bExpanded) {
00056         // create the child nodes, then expand them
00057         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00058             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00059             sdi.mask = SDI_STR       |   // Displayname is valid
00060                 SDI_PARAM     |   // lParam is valid
00061                 SDI_IMAGE     |   // nImage is valid
00062                 SDI_OPENIMAGE |   // nOpenImage is valid
00063                 SDI_PARENT    |   // relativeID is valid
00064                 SDI_CHILDREN;     // cChildren is valid
00065
00066             sdi.relativeID  = (HSCOPEITEM)parent;
00067             sdi.nImage      = children[n]->GetBitmapIndex();
00068             sdi.nOpenImage  = INDEX_OPENFOLDER;
00069             sdi.displayname = MMC_CALLBACK;
00070             sdi.lParam      = (LPARAM)children[n];       // The cookie
00071             sdi.cChildren   = 0;
00072
00073             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00074
00075             _ASSERT( SUCCEEDED(hr) );
00076         }
00077     }
00078
00079     return S_OK;
00080 }
00081
00082 CBicycleFolder::CBicycleFolder()
00083 {
00084     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00085         children[n] = new CBicycle(n + 1);
00086     }
00087 }
00088
00089 CBicycleFolder::~CBicycleFolder()
00090 {
00091     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00092         if (children[n]) {
00093             delete children[n];
00094         }
00095 }
00096
00097 HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00098 {
00099     HRESULT      hr = S_OK;
00100
00101     IHeaderCtrl *pHeaderCtrl = NULL;
00102     IResultData *pResultData = NULL;
00103
00104     if (bShow) {
00105         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00106         _ASSERT( SUCCEEDED(hr) );
00107
00108         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00109         _ASSERT( SUCCEEDED(hr) );
00110
00111         // Set the column headers in the results pane
00112         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00113         _ASSERT( S_OK == hr );
00114
00115         // insert items here
00116         RESULTDATAITEM rdi;
00117
00118         hr = pResultData->DeleteAllRsltItems();
00119         _ASSERT( SUCCEEDED(hr) );
00120
00121         if (!bExpanded) {
00122             // create the child nodes, then expand them
00123             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00124                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00125                 rdi.mask       = RDI_STR       |   // Displayname is valid
00126                     RDI_IMAGE     |
00127                     RDI_PARAM;        // nImage is valid
00128
00129                 rdi.nImage      = children[n]->GetBitmapIndex();
00130                 rdi.str         = MMC_CALLBACK;
00131                 rdi.nCol        = 0;
00132                 rdi.lParam      = (LPARAM)children[n];
00133
00134                 hr = pResultData->InsertItem( &rdi );
00135
00136                 _ASSERT( SUCCEEDED(hr) );
00137             }
00138         }
00139
00140         pHeaderCtrl->Release();
00141         pResultData->Release();
00142     }
00143
00144     return hr;
00145 }
00146
00147 CIceSkateFolder::CIceSkateFolder()
00148 {
00149     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00150         children[n] = new CIceSkate(n + 1);
00151     }
00152 }
00153
00154 CIceSkateFolder::~CIceSkateFolder()
00155 {
00156     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00157         if (children[n]) {
00158             delete children[n];
00159         }
00160 }
00161
00162 HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00163 {
00164     HRESULT      hr = S_OK;
00165
00166     IHeaderCtrl *pHeaderCtrl = NULL;
00167     IResultData *pResultData = NULL;
00168
00169     if (bShow) {
00170         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00171         _ASSERT( SUCCEEDED(hr) );
00172
00173         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00174         _ASSERT( SUCCEEDED(hr) );
00175
00176         // Set the column headers in the results pane
00177         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00178         _ASSERT( S_OK == hr );
00179
00180         // insert items here
00181         RESULTDATAITEM rdi;
00182
00183         hr = pResultData->DeleteAllRsltItems();
00184         _ASSERT( SUCCEEDED(hr) );
00185
00186         if (!bExpanded) {
00187             // create the child nodes, then expand them
00188             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00189                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00190                 rdi.mask       = RDI_STR       |   // Displayname is valid
00191                     RDI_IMAGE     |
00192                     RDI_PARAM;        // nImage is valid
00193
00194                 rdi.nImage      = children[n]->GetBitmapIndex();
00195                 rdi.str         = MMC_CALLBACK;
00196                 rdi.nCol        = 0;
00197                 rdi.lParam      = (LPARAM)children[n];
00198
00199                 hr = pResultData->InsertItem( &rdi );
00200
00201                 _ASSERT( SUCCEEDED(hr) );
00202             }
00203         }
00204
00205         pHeaderCtrl->Release();
00206         pResultData->Release();
00207     }
00208
00209     return hr;
00210 }
00211
00212 CSkateboardFolder::CSkateboardFolder()
00213 {
00214     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00215         children[n] = new CSkateboard(n + 1);
00216     }
00217 }
00218
00219 CSkateboardFolder::~CSkateboardFolder()
00220 {
00221     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00222         if (children[n]) {
00223             delete children[n];
00224         }
00225 }
00226
00227 HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00228 {
00229     HRESULT      hr = S_OK;
00230
00231     IHeaderCtrl *pHeaderCtrl = NULL;
00232     IResultData *pResultData = NULL;
00233
00234     if (bShow) {
00235         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00236         _ASSERT( SUCCEEDED(hr) );
00237
00238         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00239         _ASSERT( SUCCEEDED(hr) );
00240
00241         // Set the column headers in the results pane
00242         hr = pHeaderCtrl->InsertColumn( 0, L"Name                      ", 0, MMCLV_AUTO );
00243         _ASSERT( S_OK == hr );
00244
00245         // insert items here
00246         RESULTDATAITEM rdi;
00247
00248         hr = pResultData->DeleteAllRsltItems();
00249         _ASSERT( SUCCEEDED(hr) );
00250
00251         if (!bExpanded) {
00252             // create the child nodes, then expand them
00253             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00254                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00255                 rdi.mask       = RDI_STR       |   // Displayname is valid
00256                     RDI_IMAGE     |
00257                     RDI_PARAM;        // nImage is valid
00258
00259                 rdi.nImage      = children[n]->GetBitmapIndex();
00260                 rdi.str         = MMC_CALLBACK;
00261                 rdi.nCol        = 0;
00262                 rdi.lParam      = (LPARAM)children[n];
00263
00264                 hr = pResultData->InsertItem( &rdi );
00265
00266                 _ASSERT( SUCCEEDED(hr) );
00267             }
00268         }
00269
00270         pHeaderCtrl->Release();
00271         pResultData->Release();
00272     }
00273
00274     return hr;
00275 }
00276
00277 const _TCHAR *CBicycle::GetDisplayName(int nCol)
00278 {
00279     static _TCHAR buf[128];
00280
00281     _stprintf(buf, _T("Bicycle #%d"), id);
00282
00283     return buf;
00284 }
00285
00286 const _TCHAR *CSkateboard::GetDisplayName(int nCol)
00287 {
00288     static _TCHAR buf[128];
00289
00290     _stprintf(buf, _T("Skateboard #%d"), id);
00291
00292     return buf;
00293 }
00294
00295 const _TCHAR *CIceSkate::GetDisplayName(int nCol)
00296 {
00297     static _TCHAR buf[128];
00298
00299     _stprintf(buf, _T("Ice Skate #%d"), id);
00300
00301     return buf;
00302 }
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/MyStorageResource.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

MyStorageResource.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      MyStorageResource.cpp
00005 //
00006 //  Description:
00007 //      Main DLL code. Contains ATL stub code
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Include Files
00013 //////////////////////////////////////////////////////////////////////////////
00014
00015 #include "stdafx.h"
00016 #include "CEnumStorageResource.h"
00017 #include "CStorageResource.h"
00018 #include "CStorageResType.h"
00019 #include "CPartitionInfo.h"
00020
00021 //
00022 // Main ATL COM module
00023 //
00024
00025 CComModule _Module;
00026
00027 //
00028 // List of all COM classes supported by this DLL
00029 //
00030
00031 BEGIN_OBJECT_MAP( ObjectMap )
00032     OBJECT_ENTRY( CLSID_CEnumStorageResource,   CEnumStorageResource )
00033     OBJECT_ENTRY( CLSID_CStorageResource,       CStorageResource )
00034     OBJECT_ENTRY( CLSID_CStorageResType,        CStorageResType )
00035     OBJECT_ENTRY( CLSID_CPartitionInfo,         CPartitionInfo )
00036 END_OBJECT_MAP()
00037
00038
00039 //////////////////////////////////////////////////////////////////////////////
00040 //++
00041 //
00042 //  DllMain
00043 //
00044 //  Description:
00045 //      Main DLL entry point function
00046 //
00047 //  Arguments:
00048 //      IN  HINSTANCE   hInstance
00049 //      IN  DWORD       dwReason
00050 //      IN  LPVOID
00051 //
00052 //  Return Value:
00053 //      TRUE    Success
00054 //
00055 //--
00056 //////////////////////////////////////////////////////////////////////////////
00057 extern "C"
00058 BOOL
00059 WINAPI
00060 DllMain(
00061       HINSTANCE   hInstance
00062     , DWORD       dwReason
00063     , LPVOID      pvReserved
00064     )
00065 {
00066     UNREFERENCED_PARAMETER( pvReserved );
00067
00068     if ( dwReason == DLL_PROCESS_ATTACH )
00069     {
00070         _Module.Init( ObjectMap, hInstance, &LIBID_MyStorageResourceLib );
00071         DisableThreadLibraryCalls( hInstance );
00072     } // if: we are being loaded
00073     else if ( dwReason == DLL_PROCESS_DETACH )
00074     {
00075         _Module.Term();
00076     } // else: we are being unloaded
00077
00078     return TRUE;    // ok
00079
00080 } //*** DllMain
00081
00082
00083 //////////////////////////////////////////////////////////////////////////////
00084 //++
00085 //
00086 //  DllCanUnloadNow
00087 //
00088 //  Description:
00089 //      Used to determine whether or not this DLL can be unloaded
00090 //
00091 //  Arguments:
00092 //      None.
00093 //
00094 //  Return Value:
00095 //      S_OK        Yes
00096 //      S_FALSE     No
00097 //
00098 //--
00099 //////////////////////////////////////////////////////////////////////////////
00100 STDAPI
00101 DllCanUnloadNow( void )
00102 {
00103     return ( _Module.GetLockCount() == 0 ) ? S_OK : S_FALSE;
00104
00105 } //*** DllCanUnloadNow
00106
00107
00108 //////////////////////////////////////////////////////////////////////////////
00109 //++
00110 //
00111 //  DllGetClassObject
00112 //
00113 //  Description:
00114 //      Returns a class factory to create an object of the requested type
00115 //
00116 //  Arguments:
00117 //      rclsidIn
00118 //      riidIn
00119 //      ppvOut
00120 //
00121 //  Return Value:
00122 //      S_OK    Success
00123 //
00124 //--
00125 //////////////////////////////////////////////////////////////////////////////
00126 STDAPI
00127 DllGetClassObject(
00128     REFCLSID    rclsidIn,
00129     REFIID      riidIn,
00130     LPVOID *    ppvOut
00131     )
00132 {
00133     return _Module.GetClassObject( rclsidIn, riidIn, ppvOut );
00134
00135 } //*** DllGetClassObject
00136
00137
00138 //////////////////////////////////////////////////////////////////////////////
00139 //++
00140 //
00141 //  DllRegisterServer
00142 //
00143 //  Description:
00144 //      Adds entries to the system registry
00145 //
00146 //  Arguments:
00147 //      None.
00148 //
00149 //  Return Value:
00150 //      S_OK    Success
00151 //
00152 //--
00153 //////////////////////////////////////////////////////////////////////////////
00154 STDAPI
00155 DllRegisterServer( void )
00156 {
00157     // registers object, typelib and all interfaces in typelib
00158     return _Module.RegisterServer( TRUE );
00159
00160 } //*** DllRegisterServer
00161
00162
00163 //////////////////////////////////////////////////////////////////////////////
00164 //++
00165 //
00166 //  DllUnRegisterServer
00167 //
00168 //  Description:
00169 //      Removes entries to the system registry
00170 //
00171 //  Arguments:
00172 //      None.
00173 //
00174 //  Return Value:
00175 //      S_OK    Success
00176 //
00177 //  Remarks:
00178 //      None.
00179 //
00180 //--
00181 //////////////////////////////////////////////////////////////////////////////
00182 STDAPI
00183 DllUnregisterServer( void )
00184 {
00185     return _Module.UnregisterServer( TRUE );
00186
00187 } //*** DllUnregisterServer
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/resource.h Source File

  • WinUI
  • TSFmark

resource.h

Go to the documentation of this file.
00001 //
00002 // resource.h
00003 //
00004 // Resource declarations.
00005 //
00006
00007 #ifndef RESOURCE_H
00008 #define RESOURCE_H
00009
00010 //#define IDI_MARK        0
00011
00012 #endif // RESOURCE_H
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/helper.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

helper.cpp

Go to the documentation of this file.
00001 #include "stdafx.h"
00002 #include "helper.h"
00003
00004
00005
00006 extern ADSIIF  adsiIfs[];
00007
00008 HRESULT  VariantToStringList(  VARIANT& refvar, CStringList& refstringlist)
00009 {
00010     HRESULT hr = S_OK;
00011     long start, end;
00012   USES_CONVERSION;
00013
00014   if ( !(V_VT(&refvar) &  VT_ARRAY)  ) // Single Value
00015     {
00016     if ( V_VT(&refvar) == VT_DISPATCH )
00017     {
00018       // Find out which interfaces it supports
00019       IUnknown *pQI;
00020       int xx=0;
00021       CString s;
00022       while( !IsEqualIID( *adsiIfs[xx].pIID, IID_NULL ) )
00023       {
00024                hr = V_DISPATCH(&refvar)->QueryInterface( *adsiIfs[xx].pIID, (void**) &pQI );
00025                if ( SUCCEEDED(hr) )
00026            {
00027               s = ARROW_SYMBOL;
00028             s += adsiIfs[xx].szIf;
00029                   refstringlist.AddHead( s );
00030                   pQI->Release();
00031            }
00032                xx++;
00033       }
00034       return S_OK;
00035
00036
00037     }
00038     else if ( V_VT(&refvar) != VT_BSTR )
00039     {
00040
00041       hr = VariantChangeType( &refvar, &refvar,0, VT_BSTR );
00042
00043       if( FAILED(hr) )
00044       {
00045         return hr;
00046       }
00047
00048     }
00049
00050
00051     refstringlist.AddHead( OLE2T(V_BSTR(&refvar)) );
00052         return hr;
00053     }
00054
00055
00056     SAFEARRAY *saAttributes = V_ARRAY( &refvar );
00057
00058     //
00059     // Figure out the dimensions of the array.
00060     //
00061
00062     hr = SafeArrayGetLBound( saAttributes, 1, &start );
00063         if( FAILED(hr) )
00064                 return hr;
00065
00066     hr = SafeArrayGetUBound( saAttributes, 1, &end );
00067         if( FAILED(hr) )
00068                 return hr;
00069
00070     VARIANT SingleResult;
00071     VariantInit( &SingleResult );
00072
00073     //
00074     // Process the array elements.
00075     //
00076
00077     for ( long idx = start; idx <= end; idx++   )
00078   {
00079
00080         hr = SafeArrayGetElement( saAttributes, &idx, &SingleResult );
00081         if( FAILED(hr) )
00082     {
00083             return hr;
00084     }
00085
00086     if ( V_VT(&SingleResult) != VT_BSTR )
00087     {
00088
00089
00090       if ( V_VT(&SingleResult) == VT_NULL )
00091       {
00092         V_VT(&SingleResult ) = VT_BSTR;
00093         V_BSTR(&SingleResult ) = SysAllocString(L"0");
00094       }
00095       else
00096       {
00097         hr = VariantChangeType( &SingleResult, &SingleResult,0, VT_BSTR );
00098
00099         if( FAILED(hr) )
00100         {
00101           return hr;
00102         }
00103       }
00104     }
00105
00106
00107
00108          refstringlist.AddHead( OLE2T(V_BSTR(&SingleResult)) );
00109         VariantClear( &SingleResult );
00110     }
00111
00112     return S_OK;
00113 } // VariantToStringList()
00114
00115
00116
00117 HRESULT OctetVariantToString(  VARIANT& refvar, CString &sResult)
00118 {
00119     HRESULT hr = S_OK;
00120   CString s;
00121     long start, end;
00122   USES_CONVERSION;
00123
00124   if ( !(V_VT(&refvar) &  VT_ARRAY)  ) // Single Value
00125     {
00126     return E_UNEXPECTED;
00127     }
00128
00129
00130     SAFEARRAY *saAttributes = V_ARRAY( &refvar );
00131
00132     //
00133     // Figure out the dimensions of the array.
00134     //
00135
00136     hr = SafeArrayGetLBound( saAttributes, 1, &start );
00137     if( FAILED(hr) )
00138            return hr;
00139
00140     hr = SafeArrayGetUBound( saAttributes, 1, &end );
00141     if( FAILED(hr) )
00142             return hr;
00143
00144     VARIANT SingleResult;
00145     VariantInit( &SingleResult );
00146
00147     //
00148     // Process the array elements.
00149     //
00150   sResult.Empty();
00151     for ( long idx = start; idx <= end; idx++   )
00152   {
00153
00154         hr = SafeArrayGetElement( saAttributes, &idx, &SingleResult );
00155         if( FAILED(hr) )
00156     {
00157             return hr;
00158     }
00159
00160     if ( V_VT(&SingleResult) == VT_I1 )
00161     {
00162       s.Format("%02X", V_I1(&SingleResult));
00163       sResult += s;
00164       VariantClear( &SingleResult );
00165     }
00166     }
00167
00168     return S_OK;
00169 } // VariantToStringList()
00170
00171
00172
00173
00174
00175 HRESULT StringListToVariant( VARIANT& refvar, const CStringList& refstringlist)
00176 {
00177     HRESULT hr = S_OK;
00178     int cCount = refstringlist.GetCount();
00179
00180     SAFEARRAYBOUND rgsabound[1];
00181     rgsabound[0].lLbound = 0;
00182     rgsabound[0].cElements = cCount;
00183
00184     SAFEARRAY* psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
00185     if (NULL == psa)
00186         return E_OUTOFMEMORY;
00187
00188     VariantClear( &refvar );
00189     V_VT(&refvar) = VT_VARIANT|VT_ARRAY;
00190     V_ARRAY(&refvar) = psa;
00191
00192     VARIANT SingleResult;
00193     VariantInit( &SingleResult );
00194     V_VT(&SingleResult) = VT_BSTR;
00195     POSITION pos = refstringlist.GetHeadPosition();
00196     long i;
00197     for (i = 0; i < cCount, pos != NULL; i++)
00198     {
00199         V_BSTR(&SingleResult) = T2BSTR((LPCTSTR)refstringlist.GetNext(pos));
00200         hr = SafeArrayPutElement(psa, &i, &SingleResult);
00201         if( FAILED(hr) )
00202             return hr;
00203     }
00204     if (i != cCount || pos != NULL)
00205         return E_UNEXPECTED;
00206
00207     return hr;
00208 } // StringListToVariant()
00209
00210
00211 void StringToStringList( CString s, CStringList &sList )
00212 {
00213   int idx;
00214   CString sAttr;
00215
00216   //////////////////////////////////////////
00217   // Parse and put them in the string list
00218   //////////////////////////////////////////
00219   idx = s.Find(_T(","));
00220   while( idx != -1 )
00221   {
00222        sAttr = s.Mid(0, idx );
00223        sAttr.TrimLeft(); sAttr.TrimRight();
00224        if ( !sAttr.IsEmpty() )
00225        {
00226        sList.AddTail( sAttr );
00227        }
00228        s = s.Mid( idx + 1 );
00229        idx = s.Find(_T(","));
00230   }
00231   s.TrimLeft(); s.TrimRight();
00232   if ( !s.IsEmpty() )
00233   {
00234     sList.AddTail( s );
00235   }
00236
00237
00238 }
00239
00240
00241 void StringListToString( CStringList &sList, CString &s )
00242 {
00243   POSITION pos;
00244   int idx=0;
00245   CString sTemp;
00246
00247
00248   pos = sList.GetHeadPosition();
00249   s.Empty();
00250   while( pos != NULL )
00251   {
00252     if ( idx )
00253     {
00254       s += _T(" #");
00255       s += sList.GetAt(pos);
00256     }
00257     else
00258     {
00259       s += sList.GetAt(pos);
00260     }
00261
00262     sList.GetNext(pos);
00263     idx++;
00264
00265   }
00266
00267 }
00268
00269
00270
00271 void ADsToStringList(ADSVALUE *pValues, DWORD dwNumber, CStringList &sList )
00272 {
00273   CString sTemp;
00274
00275   sList.RemoveAll();
00276
00277
00278   USES_CONVERSION;
00279
00280   for (DWORD x=0; x < dwNumber; x++)
00281   {
00282         if ( pValues->dwType == ADSTYPE_INVALID )
00283       {
00284         continue;
00285       }
00286
00287
00288       sTemp.Empty();
00289
00290       switch( pValues->dwType )
00291       {
00292       case ADSTYPE_DN_STRING         :
00293         sTemp.Format(
00294         "%s",
00295                 OLE2T(pValues->DNString)
00296                 );
00297         break;
00298
00299       case ADSTYPE_CASE_EXACT_STRING :
00300         sTemp.Format(
00301                 "%s",
00302                 OLE2T(pValues->CaseExactString)
00303                 );
00304         break;
00305
00306       case ADSTYPE_CASE_IGNORE_STRING:
00307
00308         sTemp.Format(
00309                 "%s",
00310                 OLE2T(pValues->CaseIgnoreString)
00311                 );
00312
00313             break;
00314
00315       case ADSTYPE_PRINTABLE_STRING  :
00316         sTemp.Format(
00317                 "%s",
00318                 pValues->PrintableString
00319                 );
00320         break;
00321
00322       case ADSTYPE_NUMERIC_STRING    :
00323         sTemp.Format(
00324                 "%s",
00325                 pValues->NumericString
00326                 );
00327         break;
00328
00329       case ADSTYPE_OBJECT_CLASS    :
00330         sTemp.Format(
00331                 "%s",
00332                 pValues->ClassName
00333                 );
00334         break;
00335
00336       case ADSTYPE_BOOLEAN           :
00337         sTemp.Format(
00338                 "%s",
00339                 (DWORD) pValues->Boolean ?
00340                 "TRUE" : "FALSE"
00341                 );
00342         break;
00343
00344       case ADSTYPE_INTEGER           :
00345         sTemp.Format(
00346                 "%d",
00347                 (DWORD) pValues->Integer
00348                 );
00349         break;
00350
00351       case ADSTYPE_OCTET_STRING      :
00352         {
00353           CString sOctet;
00354           CString sPrint;
00355           CString sChar;
00356
00357
00358
00359           BYTE  b;
00360           for ( DWORD idx=0; idx<pValues->OctetString.dwLength; idx++)
00361           {
00362             b = ((BYTE *)pValues->OctetString.lpValue)[idx];
00363             sOctet.Format(
00364              "%02X ",
00365               b
00366             );
00367             if ( idx != 0 && ((idx % 16)  == 0) )
00368             {
00369               sTemp += "\t";
00370               sTemp += sPrint;
00371               sList.AddTail( sTemp );
00372               sTemp.Empty();
00373               sPrint.Empty();
00374             }
00375
00376             if ( !isprint(b) )
00377             {
00378               sPrint += _T(".");
00379             }
00380             else
00381             {
00382               sChar.Format("%c", b );
00383               sPrint += sChar;
00384
00385             }
00386
00387
00388             sTemp += sOctet;
00389
00390           }
00391
00392           if ( !sPrint.IsEmpty() )
00393           {
00394             DWORD dwMod;
00395              // Figure out the remaining 16 bytes aligment
00396              // for display
00397              dwMod = 16 - (idx % 16);
00398              for( idx=0;idx < dwMod; idx++ )
00399              {
00400               sTemp += _T("Xx ");
00401              }
00402              sTemp += _T("\t");
00403              sTemp += sPrint;
00404           }
00405
00406         }
00407         break;
00408
00409       case ADSTYPE_LARGE_INTEGER     :
00410         if  ( pValues->LargeInteger.HighPart )
00411         {
00412           sTemp.Format("%ld%ld", pValues->LargeInteger.HighPart, pValues->LargeInteger.LowPart );
00413         }
00414         else
00415         {
00416           sTemp.Format("%ld", pValues->LargeInteger.LowPart );
00417         }
00418
00419         break;
00420
00421       case ADSTYPE_UTC_TIME          :
00422         sTemp.Format(
00423           "%02d/%02d/%04d %02d:%02d:%02d", pValues->UTCTime.wMonth, pValues->UTCTime.wDay, pValues->UTCTime.wYear,
00424            pValues->UTCTime.wHour, pValues->UTCTime.wMinute, pValues->UTCTime.wSecond
00425           );
00426         break;
00427
00428       case ADSTYPE_PROV_SPECIFIC     :
00429         sTemp.Format(
00430           "(provider specific value) "
00431           );
00432         break;
00433
00434
00435       case ADSTYPE_NT_SECURITY_DESCRIPTOR:
00436         {
00437           sTemp.Format(_T("%sIADsSecurityDescriptor"), ARROW_SYMBOL );
00438           }
00439         break;
00440
00441       }
00442
00443       pValues++;
00444
00445
00446       sList.AddTail( sTemp );
00447
00448   }
00449
00450
00451  }
00452
00453
00454
00455 void PopulateListBoxFromStringList( CListBox &list, CStringList &sList )
00456 {
00457   POSITION pos;
00458
00459
00460
00461   pos = sList.GetHeadPosition();
00462   while( pos != NULL )
00463   {
00464     list.AddString( sList.GetAt(pos));
00465     sList.GetNext(pos);
00466   }
00467
00468 }
00469
00470
00471 void PopulateComboBoxFromStringList( CComboBox &list, CStringList &sList )
00472 {
00473   POSITION pos;
00474
00475
00476
00477   pos = sList.GetHeadPosition();
00478   while( pos != NULL )
00479   {
00480     list.AddString( sList.GetAt(pos));
00481     sList.GetNext(pos);
00482   }
00483
00484 }
00485
00486
00487 HRESULT ReportError( HRESULT hr )
00488 {
00489   AfxMessageBox( GetErrorMessage(hr) );
00490   return hr;
00491 }
00492
00493
00494
00495 HRESULT  VariantToPtrList(  VARIANT& refvar, CPtrList & refptrlist)
00496 {
00497     HRESULT hr = S_OK;
00498     long start, end;
00499
00500   if ( !(V_VT(&refvar) &  VT_ARRAY)  )
00501     {
00502
00503     if ( V_VT(&refvar) != VT_DISPATCH )
00504     {
00505       return E_FAIL;
00506     }
00507     else
00508     {
00509        refptrlist.AddHead( V_DISPATCH(&refvar) );
00510
00511     }
00512
00513     }
00514
00515     SAFEARRAY *saAttributes = V_ARRAY( &refvar );
00516
00517     //
00518     // Figure out the dimensions of the array.
00519     //
00520
00521     hr = SafeArrayGetLBound( saAttributes, 1, &start );
00522         if( FAILED(hr) )
00523                 return hr;
00524
00525     hr = SafeArrayGetUBound( saAttributes, 1, &end );
00526         if( FAILED(hr) )
00527                 return hr;
00528
00529     VARIANT SingleResult;
00530     VariantInit( &SingleResult );
00531
00532     //
00533     // Process the array elements.
00534     //
00535
00536     for ( long idx = start; idx <= end; idx++   )
00537   {
00538
00539         hr = SafeArrayGetElement( saAttributes, &idx, &SingleResult );
00540         if( FAILED(hr) )
00541     {
00542             return hr;
00543     }
00544
00545     if ( V_VT(&SingleResult) != VT_DISPATCH )
00546     {
00547       return E_UNEXPECTED;
00548     }
00549
00550
00551         refptrlist.AddHead( V_DISPATCH(&SingleResult) );
00552     }
00553
00554     return S_OK;
00555 } // VariantToStringList()
00556
00557
00558
00559 HRESULT PropertyValueToString( LONG lADsType, IADsPropertyValue *pValue, CString &sValue )
00560 {
00561   BSTR bstr = NULL;
00562   LONG l;
00563   VARIANT var;
00564   HRESULT hr = S_OK;
00565   sValue.Empty();
00566
00567   VariantInit(&var);
00568   switch( lADsType )
00569   {
00570   case ADSTYPE_DN_STRING:
00571      hr = pValue->get_DNString( &bstr );
00572      sValue = bstr;
00573     break;
00574
00575   case ADSTYPE_CASE_EXACT_STRING:
00576     hr = pValue->get_CaseExactString( &bstr );
00577     sValue = bstr;
00578     break;
00579
00580   case ADSTYPE_CASE_IGNORE_STRING:
00581      hr = pValue->get_CaseIgnoreString( &bstr );
00582      sValue = bstr;
00583     break;
00584
00585   case ADSTYPE_PRINTABLE_STRING:
00586      hr = pValue->get_PrintableString( &bstr );
00587      sValue = bstr;
00588     break;
00589
00590   case ADSTYPE_NUMERIC_STRING:
00591     hr = pValue->get_NumericString( &bstr );
00592     sValue = bstr;
00593     break;
00594
00595   case ADSTYPE_BOOLEAN:
00596      hr = pValue->get_Boolean( &l );
00597      sValue = l ? _T("TRUE") : _T("FALSE");
00598     break;
00599
00600   case ADSTYPE_INTEGER:
00601      hr = pValue->get_Integer( &l );
00602      sValue.Format("%ld", l );
00603     break;
00604
00605
00606   case ADSTYPE_OCTET_STRING:
00607      hr = pValue->get_OctetString( &var );
00608      if ( SUCCEEDED(hr) )
00609      {
00610       CString s;
00611       hr =  OctetVariantToString( var, s);
00612       if ( SUCCEEDED(hr) )
00613       {
00614         sValue = s;
00615       }
00616      }
00617
00618     break;
00619
00620
00621   case ADSTYPE_UTC_TIME:
00622     {
00623       DATE date;
00624       hr = pValue->get_UTCTime(&date);
00625
00626
00627     }
00628     break;
00629
00630   case ADSTYPE_LARGE_INTEGER:
00631     sValue.Format(_T("%sIADsLargeInteger"), ARROW_SYMBOL );
00632     break;
00633
00634   case ADSTYPE_PROV_SPECIFIC:
00635     sValue = _T("Provider Specific");
00636     break;
00637
00638   case ADSTYPE_CASEIGNORE_LIST:
00639     hr = pValue->get_CaseIgnoreString(&bstr);
00640     sValue = bstr;
00641     break;
00642
00643   case ADSTYPE_OCTET_LIST:
00644     sValue.Format(_T("%sIADsOctetString"), ARROW_SYMBOL );
00645     break;
00646
00647   case ADSTYPE_PATH:
00648     sValue.Format(_T("%sIADsPath"), ARROW_SYMBOL );
00649     break;
00650
00651   case ADSTYPE_POSTALADDRESS:
00652     sValue.Format(_T("%sIADsPostalAddress"), ARROW_SYMBOL );
00653     break;
00654
00655   case ADSTYPE_TIMESTAMP:
00656     sValue.Format(_T("%sIADsTimestamp"), ARROW_SYMBOL );
00657     break;
00658
00659   case ADSTYPE_BACKLINK:
00660     sValue.Format(_T("%sIADsBackLink"), ARROW_SYMBOL );
00661     break;
00662
00663   case ADSTYPE_TYPEDNAME:
00664     sValue.Format(_T("%sIADsTypedName"), ARROW_SYMBOL );
00665     break;
00666
00667   case ADSTYPE_HOLD:
00668     sValue.Format(_T("%sIADsHold"), ARROW_SYMBOL );
00669     break;
00670
00671   case ADSTYPE_NETADDRESS:
00672     sValue.Format(_T("%sIADsNetAddress"), ARROW_SYMBOL );
00673     break;
00674
00675   case ADSTYPE_REPLICAPOINTER:
00676     sValue.Format(_T("%sIADsReplicaPointer"), ARROW_SYMBOL );
00677     break;
00678
00679   case ADSTYPE_FAXNUMBER:
00680     sValue.Format(_T("%sIADsFaxNumber"), ARROW_SYMBOL );
00681     break;
00682
00683   case ADSTYPE_EMAIL:
00684     sValue.Format(_T("%sIADsEmail"), ARROW_SYMBOL );
00685     break;
00686
00687   case ADSTYPE_NT_SECURITY_DESCRIPTOR:
00688     sValue.Format(_T("%sIADsSecurityDescriptor"), ARROW_SYMBOL );
00689     break;
00690
00691   case ADSTYPE_UNKNOWN:
00692      sValue = _T("Unknown");
00693      break;
00694
00695   }
00696
00697   if ( bstr )
00698   {
00699     SysFreeString( bstr );
00700   }
00701
00702   VariantClear(&var);
00703   pValue->Release();
00704   return hr;
00705 }
00706
00707
00708
00709
00710
00711 CString GetErrorMessage( HRESULT hr )
00712 {
00713   BOOL bRet;
00714   CString s;
00715   LPTSTR lpBuffer=NULL;
00716
00717   if ( SUCCEEDED(hr) )
00718   {
00719     return _T("Success");
00720   }
00721
00722
00723   if ( hr & 0x00005000) // standard ADSI Errors
00724   {
00725     s = GetADSIError(hr);
00726   }
00727   else if ( HRESULT_FACILITY(hr)==FACILITY_WIN32 )
00728   {
00729
00730
00731     /////////////////////////////////////////////
00732     //
00733     // Retrieve the Win32 Error message
00734     //
00735     /////////////////////////////////////////////////
00736
00737     bRet = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00738                NULL,  hr,
00739                MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
00740                (LPTSTR) &lpBuffer, 0, NULL);
00741
00742     if ( !bRet )
00743     {
00744       s.Format(_T("Error %X"), hr );
00745     }
00746
00747     if ( lpBuffer )
00748     {
00749       s = lpBuffer;
00750       LocalFree( lpBuffer );
00751     }
00752   }
00753   else // Non Win32 Error
00754   {
00755     s.Format("%X", hr );
00756   }
00757
00758   //////////////////////////////////////////////////////////////////
00759   //
00760   // Extended error message may be occured.
00761   //
00762   // IADs, IADsContainer, IDirectoryObject or IDirectorySearch may return
00763   // this extended error message
00764   //
00765   ////////////////////////////////////////////////////////////////////
00766
00767   if ( (hr & 0x00005000) ||  //adsi
00768      (hr & 0x00007000) )   // and win32
00769   {
00770     WCHAR szBuffer[MAX_PATH];
00771     WCHAR szName[MAX_PATH];
00772     DWORD dwError;
00773
00774
00775     hr = ADsGetLastError( &dwError, szBuffer, (sizeof(szBuffer)/sizeof(WCHAR))-1,
00776                         szName, (sizeof(szName)/sizeof(WCHAR))-1 );
00777
00778
00779     if ( SUCCEEDED(hr) && dwError != ERROR_INVALID_DATA  && wcslen(szBuffer))
00780     {
00781       USES_CONVERSION;
00782       s += _T("  -- Extended Error:");
00783       s += OLE2T(szName);
00784       s += _T(" : ");
00785       s += OLE2T( szBuffer );
00786     }
00787   }
00788
00789
00790   return s;
00791 }
00792
00793 ADSERRMSG adsErr[] =
00794 {
00795   ADDADSERROR(E_ADS_BAD_PATHNAME),
00796   ADDADSERROR(E_ADS_INVALID_DOMAIN_OBJECT),
00797   ADDADSERROR(E_ADS_INVALID_USER_OBJECT),
00798   ADDADSERROR(E_ADS_INVALID_COMPUTER_OBJECT),
00799   ADDADSERROR(E_ADS_UNKNOWN_OBJECT),
00800   ADDADSERROR(E_ADS_PROPERTY_NOT_SET),
00801   ADDADSERROR(E_ADS_PROPERTY_NOT_SUPPORTED),
00802   ADDADSERROR(E_ADS_PROPERTY_INVALID),
00803   ADDADSERROR(E_ADS_BAD_PARAMETER),
00804   ADDADSERROR(E_ADS_OBJECT_UNBOUND),
00805   ADDADSERROR(E_ADS_PROPERTY_NOT_MODIFIED),
00806   ADDADSERROR(E_ADS_PROPERTY_MODIFIED),
00807   ADDADSERROR(E_ADS_CANT_CONVERT_DATATYPE),
00808   ADDADSERROR(E_ADS_PROPERTY_NOT_FOUND),
00809   ADDADSERROR(E_ADS_OBJECT_EXISTS),
00810   ADDADSERROR(E_ADS_SCHEMA_VIOLATION),
00811   ADDADSERROR(E_ADS_COLUMN_NOT_SET),
00812   ADDADSERROR(E_ADS_INVALID_FILTER),
00813   ADDADSERROR(0),
00814 };
00815
00816
00817 /////////////////////////////////////////////
00818 //
00819 // Error message specific to ADSI
00820 //
00821 ////////////////////////////////////////////
00822 CString GetADSIError( HRESULT hr )
00823 {
00824   CString s;
00825
00826
00827   if ( hr & 0x00005000 )
00828   {
00829     int idx=0;
00830     while (adsErr[idx].hr != 0 )
00831     {
00832       if ( adsErr[idx].hr == hr )
00833       {
00834         return adsErr[idx].pszError;
00835       }
00836       idx++;
00837     }
00838   }
00839
00840   return _T("");
00841
00842
00843 }
00844
00845
00846
00847
00848
00849
00850 #if _ATL_VER <= 0x0200
00851
00852 LPWSTR WINAPI AtlA2WHelper(LPWSTR lpw, LPCSTR lpa, int nChars)
00853 {
00854   _ASSERTE(lpa != NULL);
00855   _ASSERTE(lpw != NULL);
00856   // verify that no illegal character present
00857   // since lpw was allocated based on the size of lpa
00858   // don't worry about the number of chars
00859   lpw[0] = '\0';
00860   MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars);
00861   return lpw;
00862 }
00863
00864 LPSTR WINAPI AtlW2AHelper(LPSTR lpa, LPCWSTR lpw, int nChars)
00865 {
00866   _ASSERTE(lpw != NULL);
00867   _ASSERTE(lpa != NULL);
00868   // verify that no illegal character present
00869   // since lpa was allocated based on the size of lpw
00870   // don't worry about the number of chars
00871   lpa[0] = '\0';
00872   WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpa, nChars, NULL, NULL);
00873   return lpa;
00874 }
00875
00876 #endif
00877
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step3/Dimmer.h Source File

  • NetDS
  • upnp
  • StepByStep
  • Step3

Dimmer.h

Go to the documentation of this file.
00001 // Dimmer.h : Declaration of the CDimmer
00002
00003 #ifndef __DIMMER_H_
00004 #define __DIMMER_H_
00005
00006 #include "resource.h"       // main symbols
00007 #import "C:\UPnPSample\SDKDimmer\DimmerDevice\StepByStep\Step2\Debug\upnphost.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
00008
00009 /////////////////////////////////////////////////////////////////////////////
00010 // CDimmer
00011 class ATL_NO_VTABLE CDimmer :
00012   public CComObjectRootEx<CComMultiThreadModel>,
00013   public CComCoClass<CDimmer, &CLSID_Dimmer>,
00014   //public IDispatchImpl<IDimmer, &IID_IDimmer, &LIBID_MYDEVICELib>,
00015   public IUPnPDeviceControl
00016 {
00017 public:
00018   CDimmer()
00019   {
00020   }
00021
00022 DECLARE_REGISTRY_RESOURCEID(IDR_DIMMER)
00023
00024 DECLARE_PROTECT_FINAL_CONSTRUCT()
00025
00026 BEGIN_COM_MAP(CDimmer)
00027   //COM_INTERFACE_ENTRY(IDimmer)
00028   //COM_INTERFACE_ENTRY(IDispatch)
00029   COM_INTERFACE_ENTRY(IUPnPDeviceControl)
00030 END_COM_MAP()
00031
00032 // IDimmer
00033 public:
00034 // IUPnPDeviceControl
00035   STDMETHOD(Initialize)(BSTR bstrXMLDesc, BSTR bstrDeviceIdentifier, BSTR bstrInitString)
00036   {
00037     return E_NOTIMPL;
00038   }
00039   STDMETHOD(GetServiceObject)(BSTR bstrUDN, BSTR bstrServiceId, IDispatch * * ppdispService)
00040   {
00041     if (ppdispService == NULL)
00042       return E_POINTER;
00043
00044     return E_NOTIMPL;
00045   }
00046 };
00047
00048 #endif //__DIMMER_H_
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step2/resource.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step2

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ADsFirstExt.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDS_HELLOWORLD_DESC             102
00007 #define IDR_HelloWorld                  103
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           104
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/security.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

security.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 //
00003 //  Microsoft Active Directory 2.5 Sample Code
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1996 - 2000
00006 //
00007 //  File:       security.cpp
00008 //
00009 //  Contents:   IADsSecurityDescriptor, IADsAccessControlList, IADsAccessControlEntry usage
00010 //
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #include "stdafx.h"
00015 #include "ADQI.h"
00016 #include "directorysearch.h"
00017 #include "security.h"
00018
00019 #ifdef _DEBUG
00020 #define new DEBUG_NEW
00021 #undef THIS_FILE
00022 static char THIS_FILE[] = __FILE__;
00023 #endif
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // CDlgIADsSecurityDescriptor dialog
00027
00028
00029 CDlgIADsSecurityDescriptor::CDlgIADsSecurityDescriptor(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
00030   : CDialog(CDlgIADsSecurityDescriptor::IDD, pParent)
00031 {
00032   //{{AFX_DATA_INIT(CDlgIADsSecurityDescriptor)
00033   //}}AFX_DATA_INIT
00034
00035
00036
00037   HRESULT hr;
00038   m_pSecurityDesc = NULL;
00039
00040
00041   hr = pUnk->QueryInterface( IID_IADsSecurityDescriptor, (void **) &m_pSecurityDesc );
00042   pUnk->Release();
00043
00044   if ( !SUCCEEDED(hr) )
00045   {
00046     AfxMessageBox(_T("Fatal Error! QI for IADsSecurityDescriptor failed"));
00047     return;
00048   }
00049
00050
00051
00052 }
00053
00054 CDlgIADsSecurityDescriptor::~CDlgIADsSecurityDescriptor()
00055 {
00056   ResetAcePtr();
00057   if ( m_pSecurityDesc )
00058   {
00059     m_pSecurityDesc->Release();
00060   }
00061
00062 }
00063
00064
00065 void CDlgIADsSecurityDescriptor::DoDataExchange(CDataExchange* pDX)
00066 {
00067   CDialog::DoDataExchange(pDX);
00068   //{{AFX_DATA_MAP(CDlgIADsSecurityDescriptor)
00069   DDX_Control(pDX, IDC_ACELIST, m_cACEList);
00070   //}}AFX_DATA_MAP
00071 }
00072
00073
00074 BEGIN_MESSAGE_MAP(CDlgIADsSecurityDescriptor, CDialog)
00075   //{{AFX_MSG_MAP(CDlgIADsSecurityDescriptor)
00076   ON_LBN_SELCHANGE(IDC_ACELIST, OnSelChangeAceList)
00077   //}}AFX_MSG_MAP
00078 END_MESSAGE_MAP()
00079
00080 /////////////////////////////////////////////////////////////////////////////
00081 // CDlgIADsSecurityDescriptor message handlers
00082
00083 void CDlgIADsSecurityDescriptor::PopulateACL(IADsAccessControlList * pACL)
00084 {
00085   ASSERT( pACL );
00086   HRESULT hr;
00087   ULONG   lFetch;
00088
00089   IEnumVARIANT *pEnum;
00090   LPUNKNOWN     pUnk;
00091   VARIANT       var;
00092   IDispatch  *pDisp;
00093   BSTR      bstr;
00094   CString     s;
00095
00096   IADsAccessControlEntry *pACE;
00097
00098
00099   m_cACEList.ResetContent();
00100   ResetAcePtr();
00101
00102
00103   hr = pACL->get__NewEnum( &pUnk );
00104   if ( !SUCCEEDED(hr) )
00105   {
00106     return;
00107   }
00108
00109   hr = pUnk->QueryInterface( IID_IEnumVARIANT, (void**) &pEnum );
00110   if ( !SUCCEEDED(hr) )
00111   {
00112     return;
00113   }
00114
00115   hr = pEnum->Next( 1, &var, &lFetch );
00116
00117   while( hr == S_OK )
00118   {
00119     if ( lFetch == 1 )
00120     {
00121       if ( VT_DISPATCH != V_VT(&var) )
00122       {
00123         break;
00124       }
00125
00126
00127         pDisp = V_DISPATCH(&var);
00128       ///////////////////////////
00129       // Get the ACE
00130       /////////////////////////////
00131       hr = pDisp->QueryInterface( IID_IADsAccessControlEntry, (void**)&pACE );
00132       if ( SUCCEEDED(hr) )
00133       {
00134         pACE->get_Trustee(&bstr);
00135         s = bstr;
00136         SysFreeString(bstr);
00137         m_cACEList.AddString( s );
00138         m_acePtrList.AddTail( pACE ); //save the pointer for future use,
00139                                    // we don't need to Release() it.
00140
00141       }
00142
00143       VariantClear(&var);
00144     }
00145     hr = pEnum->Next( 1, &var, &lFetch );
00146
00147     };
00148
00149
00150
00151   pACL->Release();
00152 }
00153
00154
00155 void CDlgIADsSecurityDescriptor::ResetAcePtr()
00156 {
00157   POSITION pos;
00158   IADsAccessControlList *pACE;
00159   pos = m_acePtrList.GetHeadPosition();
00160   while( pos != NULL )
00161   {
00162       pACE = (IADsAccessControlList*) m_acePtrList.GetAt( pos );
00163     pACE->Release();
00164     m_acePtrList.GetNext( pos );
00165   }
00166   m_acePtrList.RemoveAll();
00167 }
00168
00169
00170 BOOL CDlgIADsSecurityDescriptor::OnInitDialog()
00171 {
00172   CDialog::OnInitDialog();
00173
00174   if ( m_pSecurityDesc == NULL )
00175   {
00176     return TRUE;
00177   }
00178
00179
00180   /////////////////////////////////////////////
00181   // Populate the DACL
00182   ////////////////////////////////////////////
00183   HRESULT hr;
00184   IDispatch *pDisp;
00185
00186   IADsAccessControlList *pACL;
00187   hr = m_pSecurityDesc->get_DiscretionaryAcl( &pDisp );
00188   if (!SUCCEEDED(hr) )
00189   {
00190     AfxMessageBox(GetErrorMessage(hr));
00191     return TRUE;
00192   }
00193
00194
00195   hr = pDisp->QueryInterface( IID_IADsAccessControlList, (void**) &pACL );
00196   pDisp->Release();
00197
00198   if ( SUCCEEDED(hr) )
00199   {
00200     PopulateACL( pACL );
00201   }
00202
00203
00204   return TRUE;  // return TRUE unless you set the focus to a control
00205                 // EXCEPTION: OCX Property Pages should return FALSE
00206 }
00207
00208 void CDlgIADsSecurityDescriptor::OnSelChangeAceList()
00209 {
00210   int idx=0;
00211
00212   ///////////////////////////////////////////////////
00213   // Seach the ACEs
00214   ////////////////////////////////////////////////
00215   idx = m_cACEList.GetCurSel();
00216   if ( idx == LB_ERR )
00217   {
00218     return;
00219   }
00220
00221   POSITION pos = m_acePtrList.FindIndex( idx );
00222   IADsAccessControlEntry *pACE = NULL;
00223   if ( !pos )
00224   {
00225     return;
00226   }
00227
00228   ///////////////////////////////////////////////////
00229   // Now we can disply the ACE characteristics
00230   ////////////////////////////////////////////////////
00231     pACE = (IADsAccessControlEntry *) m_acePtrList.GetAt( pos );
00232   if ( pACE )
00233   {
00234     pACE->AddRef();
00235     DisplayACE( pACE );
00236   }
00237 }
00238
00239
00240
00241 void CDlgIADsSecurityDescriptor::DisplayACE( IADsAccessControlEntry *pACE )
00242 {
00243   LONG aceMask;
00244   LONG aceType;
00245   int idx;
00246   BSTR bstr;
00247   CString sObjectType;
00248
00249   ASSERT( pACE );
00250
00251   ///////////////////////////////////////////////////
00252   //  Get Access Mask, Ace Type and Object Type
00253   ////////////////////////////////////////////////////
00254   if( !SUCCEEDED(pACE->get_AccessMask(&aceMask)) )
00255   {
00256     return;
00257   }
00258   if ( !SUCCEEDED(pACE->get_AceType(&aceType)) )
00259   {
00260     return;
00261   }
00262
00263   if ( !SUCCEEDED(pACE->get_ObjectType(&bstr)) )
00264   {
00265     return;
00266   }
00267
00268   sObjectType = bstr;
00269   SysFreeString( bstr );
00270
00271
00272
00273   //////////////////////////////////////
00274   // Display the type
00275   //////////////////////////////////////
00276   int aceTypeList[] =
00277   {
00278     ADS_ACETYPE_ACCESS_ALLOWED,
00279       ADS_ACETYPE_ACCESS_DENIED,
00280     ADS_ACETYPE_ACCESS_ALLOWED_OBJECT,
00281     ADS_ACETYPE_ACCESS_DENIED_OBJECT,
00282     ADS_ACETYPE_SYSTEM_AUDIT,
00283     ADS_ACETYPE_SYSTEM_AUDIT_OBJECT,
00284   };
00285
00286
00287   int sel = -1;
00288   for( idx=0; idx < (sizeof(aceTypeList)/sizeof(int)); idx++ )
00289   {
00290     if ( aceType  == aceTypeList[idx] )
00291     {
00292       sel = idx;
00293       break;
00294     }
00295   }
00296   ((CComboBox*)GetDlgItem(IDC_ACETYPE))->SetCurSel( sel );
00297
00298   /////////////////////////////////////
00299   // Display the aces mask
00300   /////////////////////////////////////
00301   ResetAceMaskControls(); // Reset the UI
00302
00303   // Standard ACE Rights
00304   if ( aceMask &  ADS_RIGHT_DELETE )
00305   {
00306     CheckDlgButton( IDC_DELETEOBJECT, TRUE );
00307   }
00308
00309   if ( aceMask & ADS_RIGHT_READ_CONTROL )
00310   {
00311     CheckDlgButton( IDC_READPERMISSION, TRUE );
00312   }
00313
00314   if ( aceMask & ADS_RIGHT_WRITE_DAC )
00315   {
00316     CheckDlgButton( IDC_MODIFYPERMISSION, TRUE );
00317   }
00318
00319   if ( aceMask & ADS_RIGHT_WRITE_OWNER )
00320   {
00321     CheckDlgButton( IDC_MODIFYOWNER, TRUE );
00322   }
00323
00324
00325   // Directory ACE Rights
00326   if ( aceMask & ADS_RIGHT_DS_CREATE_CHILD )
00327   {
00328     CheckDlgButton( IDC_CREATECHILD, TRUE );
00329     DisplayAceObjectType( IDC_CREATECHILD_EDIT, sObjectType );
00330   }
00331
00332   if ( aceMask & ADS_RIGHT_DS_DELETE_CHILD )
00333   {
00334      CheckDlgButton( IDC_DELETECHILD, TRUE );
00335      DisplayAceObjectType( IDC_DELETECHILD_EDIT, sObjectType );
00336   }
00337
00338   if ( aceMask & ADS_RIGHT_ACTRL_DS_LIST )
00339   {
00340      CheckDlgButton( IDC_LISTCONTENT, TRUE );
00341   }
00342
00343   if ( aceMask & ADS_RIGHT_DS_SELF )
00344   {
00345     CheckDlgButton( IDC_LISTOBJECT, TRUE );
00346   }
00347
00348   if ( aceMask & ADS_RIGHT_DS_DELETE_TREE )
00349   {
00350     CheckDlgButton( IDC_DELETETREE, TRUE );
00351   }
00352
00353   if ( aceMask & ( ADS_RIGHT_DS_READ_PROP  |  ADS_RIGHT_DS_WRITE_PROP | 0x100) &&
00354      ( (aceType == ADS_ACETYPE_ACCESS_ALLOWED_OBJECT)  |
00355        (aceType == ADS_ACETYPE_ACCESS_DENIED_OBJECT)  )
00356      )
00357   {
00358     CheckDlgButton( IDC_EXTENDEDRIGHT, TRUE );
00359     DisplayAceObjectType( IDC_EXTENDEDRIGHT_EDIT, sObjectType );
00360
00361   }
00362   else
00363   {
00364     if ( aceMask & ADS_RIGHT_DS_READ_PROP )
00365     {
00366       CheckDlgButton( IDC_READPROP, TRUE );
00367       DisplayAceObjectType( IDC_READPROP_EDIT, sObjectType );
00368     }
00369
00370     if ( aceMask & ADS_RIGHT_DS_WRITE_PROP )
00371     {
00372       CheckDlgButton( IDC_WRITEPROP, TRUE );
00373       DisplayAceObjectType( IDC_WRITEPROP_EDIT, sObjectType );
00374     }
00375   }
00376
00377
00378
00379
00380
00381 }
00382
00383
00384 void CDlgIADsSecurityDescriptor::DisplayAceObjectType( UINT nID, CString &sObjectType )
00385 {
00386   if ( sObjectType.IsEmpty() )
00387   {
00388     SetDlgItemText( nID, _T("ALL") );
00389   }
00390   else
00391   {
00392     SetDlgItemText( nID, sObjectType );
00393   }
00394
00395
00396 }
00397 void CDlgIADsSecurityDescriptor::ResetAceMaskControls()
00398 {
00399    CheckDlgButton( IDC_DELETEOBJECT, FALSE );
00400    CheckDlgButton( IDC_READPERMISSION, FALSE );
00401    CheckDlgButton( IDC_CREATECHILD, FALSE );
00402    CheckDlgButton( IDC_DELETECHILD, FALSE );
00403    CheckDlgButton( IDC_LISTCONTENT, FALSE );
00404    CheckDlgButton( IDC_LISTOBJECT, FALSE );
00405    CheckDlgButton( IDC_DELETETREE, FALSE );
00406    CheckDlgButton( IDC_READPROP, FALSE );
00407    CheckDlgButton( IDC_WRITEPROP, FALSE );
00408
00409    SetDlgItemText( IDC_CREATECHILD_EDIT, _T("") );
00410    SetDlgItemText( IDC_DELETECHILD_EDIT, _T("") );
00411    SetDlgItemText( IDC_READPROP_EDIT, _T("") );
00412    SetDlgItemText( IDC_WRITEPROP_EDIT, _T("") );
00413    SetDlgItemText( IDC_EXTENDEDRIGHT_EDIT, _T("") );
00414
00415 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMetaTag Member List

This is the complete list of members for CMetaTag, including all inherited members.
_aTempBuffer | CHtmlElement | [protected]
_awszPropSpec | CMetaTag | [private]
_clsidMetaInfo | CMetaTag | [private]
_cValueChars | CMetaTag | [private]
_eState | CMetaTag | [private]
_htmlIFilter | CHtmlElement | [protected]
_pwcValueBuf | CMetaTag | [private]
_scanner | CHtmlElement | [protected]
_serialStream | CHtmlElement | [protected]
CHtmlElement(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CHtmlElement |
CMetaTag(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream, GUID ClsidMetaInfo) | CMetaTag |
GetChunk(STAT_CHUNK *pStat) | CMetaTag | [virtual]
GetText(ULONG *pcwcOutput, WCHAR *awcBuffer) | CMetaTag | [virtual]
GetValue(PROPVARIANT **ppPropValue) | CMetaTag | [virtual]
InitFilterRegion(ULONG &idChunkSource, ULONG &cwcStartSource, ULONG &cwcLenSource) | CHtmlElement | [virtual]
InitStatChunk(STAT_CHUNK *pStat) | CMetaTag | [virtual]
SkipRemainingTextAndGotoNextChunk(STAT_CHUNK *pStat) | CHtmlElement | [protected]
SwitchToNextHtmlElement(STAT_CHUNK *pStat) | CHtmlElement | [protected]
~CHtmlElement() | CHtmlElement | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Ppgeext/guids.h Source File

  • SysMgmt
  • MMC
  • Ppgeext

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {CFCDC9F3-C50E-11d2-952B-00C04FB92EC2}
00020 DEFINE_GUID(CLSID_CPropSheetExtension,
00021             0xcfcdc9f3, 0xc50e, 0x11d2, 0x95, 0x2b, 0x0, 0xc0, 0x4f, 0xb9, 0x2e, 0xc2);
00022 // {CFCDC9F7-C50E-11d2-952B-00C04FB92EC2}
00023 DEFINE_GUID(CLSID_CSnapinAbout,
00024             0xcfcdc9f7, 0xc50e, 0x11d2, 0x95, 0x2b, 0x0, 0xc0, 0x4f, 0xb9, 0x2e, 0xc2);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsimple/filerepclientproc.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsimple

filerepclientproc.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Client System Service
00006
00007     FILE: FileRepClientProc.cpp
00008
00009     PURPOSE: Remote procedures for client system service
00010
00011     FUNCTIONS:
00012         RequestFile() - receives file replication requests
00013   ThreadProcRequest() - processes file replication requests
00014     in an independent thread.
00015
00016     COMMENTS:
00017
00018 */
00019
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <tchar.h>
00023
00024 #include "common.h"
00025
00026 // header file generated by MIDL compiler
00027 #include "FileRepClient.h"
00028 #include "FileRepServer.h"
00029
00030 // Contains declarations for system service functions.
00031 #include "Service.h"
00032
00033 // This structure simply packages up the variables to be passed
00034 // to the processing thread.
00035 typedef struct {
00036     handle_t hFileRepServer;
00037     HANDLE hLocalFile;
00038     PCONTEXT_HANDLE_TYPE phContext;
00039     BYTE pbBuf[MAX_BUFSIZE];
00040 #ifdef PROF
00041     ULONG nReqId;
00042 #endif
00043 } ThreadArgs;
00044
00045 // Closes the file handle and frees all thread data if an error occured
00046 // in one of the following functions.
00047 VOID ShutdownThread(ThreadArgs *pArgs) {
00048     INT status;
00049     RPC_STATUS rpcstatus;
00050
00051     if(pArgs != NULL) {
00052   if(pArgs->hFileRepServer != NULL) {
00053       rpcstatus = RpcBindingFree(&(pArgs->hFileRepServer));
00054       ASSERTE(rpcstatus == RPC_S_OK);
00055   }
00056   // Check that hLocalFile has been initialized and that initialization
00057   // was successful.
00058   if(pArgs->hLocalFile != NULL && pArgs->hLocalFile != INVALID_HANDLE_VALUE) {
00059       status = CloseHandle(pArgs->hLocalFile);
00060       ASSERTE(status != 0);
00061   }
00062   if(pArgs->phContext != NULL) {
00063       RpcSsDestroyClientContext((VOID **)&pArgs->phContext);
00064   }
00065   AutoHeapFree(pArgs);
00066     }
00067 }
00068
00069 /*
00070     FUNCTIONS: ThreadProcRequest
00071
00072     PURPOSE:
00073         Called by FileRepRequestFile to have the Client System
00074         Service process the file replication request.
00075
00076     PARAMETERS:
00077         Self-explanatory.
00078
00079     RETURN VALUE: STATUS_SUCCESS or 1
00080
00081 */
00082 void ThreadProcRequest(ThreadArgs *pArgs) {
00083     UINT i = 0;
00084     ULONG cbRead, cbWritten;
00085
00086     TCHAR Msg[MSG_SIZE];
00087
00088     // Get the remainder of text from the remote file.  When the
00089     // server returns a NULL context handle, the read has completed and
00090     // the file has been closed.
00091     do {
00092
00093         // We did not read anything yet.
00094         cbRead = 0;
00095
00096 #ifdef RETRY_EXCEPTION
00097   // When making aggressive calls to the server, this flag is
00098   // set when the call succeeded.  This makes the client service attempt
00099   // to contact the server even after an exception occured.
00100   BOOL bRetryCall = TRUE;
00101   while (bRetryCall) {
00102 #endif
00103
00104         RpcTryExcept {
00105             c_RemoteRead(pArgs->hFileRepServer,
00106        &(pArgs->phContext),
00107        pArgs->pbBuf,
00108        &cbRead);
00109
00110 #ifdef RETRY_EXCEPTION
00111       bRetryCall = FALSE;
00112 #endif
00113
00114   }
00115         RpcExcept ( ( (RpcExceptionCode() != STATUS_ACCESS_VIOLATION) &&
00116           (RpcExceptionCode() != STATUS_DATATYPE_MISALIGNMENT) &&
00117           (RpcExceptionCode() != STATUS_PRIVILEGED_INSTRUCTION) &&
00118           (RpcExceptionCode() != STATUS_ILLEGAL_INSTRUCTION) &&
00119           (RpcExceptionCode() != STATUS_BREAKPOINT))
00120         ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) {
00121
00122       // Log the error code as well as the error.
00123       // Msg is sufficiently large and can't overflow.
00124       _stprintf(Msg, TEXT("ThreadProcRequest: Exception: c_RemoteRead failed with code %d"), RpcExceptionCode());
00125       AddToMessageLog(Msg);
00126
00127 #ifdef RETRY_EXCEPTION
00128       // This code attempts to make aggressive calls, retrying
00129       // if no endpoints were available.  It is used to put servers
00130       // under stress.
00131       if (RpcExceptionCode() != EPT_S_NOT_REGISTERED &&
00132     RpcExceptionCode() != RPC_S_SERVER_UNAVAILABLE) {
00133 #endif
00134       ShutdownThread(pArgs);
00135       return;
00136 #ifdef RETRY_EXCEPTION
00137       }
00138 #endif
00139   }
00140   RpcEndExcept;
00141
00142 #ifdef RETRY_EXCEPTION
00143   }
00144 #endif
00145
00146   if(!WriteFile(pArgs->hLocalFile,
00147           pArgs->pbBuf,
00148           cbRead,
00149           &cbWritten,
00150           NULL)) {
00151
00152       _stprintf(Msg, TEXT("ThreadProcRequest: WriteFile failed with code %d"), GetLastError());
00153       AddToMessageLog(Msg);
00154
00155       ShutdownThread(pArgs);
00156       return;
00157   }
00158     } while(pArgs->phContext != NULL);
00159
00160 #ifdef PROF
00161     ProfRecordTime(pArgs->nReqId, TEXT("handled"));
00162 #endif
00163
00164     ShutdownThread(pArgs);
00165
00166     // After this procedure returns the replication request will have
00167     // been handled.
00168     return;
00169 }
00170
00171 /*
00172     FUNCTIONS: RequestFile
00173
00174     PURPOSE:
00175         Called by FileRep to have the Client System
00176         Service request file replication from a Server System Service.
00177
00178     PARAMETERS:
00179         Self-explanatory.
00180
00181     RETURN VALUE: STATUS_SUCCESS or 1
00182
00183 */
00184 VOID RequestFile(handle_t hFileRepClient,
00185      LPTSTR ServerName,
00186      LPTSTR RemoteFileName,
00187      LPTSTR LocalFileName)
00188 {
00189     INT status;
00190     RPC_STATUS rpcstatus;
00191
00192     ULONG cbRead, cbWritten;
00193
00194     // Default connection to server system service is over TCP/IP.
00195     LPTSTR DefaultProtocolSequence = TEXT("ncacn_ip_tcp");
00196
00197     // An empty endpoint string is used, since we are going to
00198     // connect to the endpoint dynamically generated by the
00199     // RPC run-time library.    Server calls RpcServerUseProtseq to
00200     // obtain a binding hadnle and a dynamic endpoint.
00201     LPTSTR DefaultEndpoint = TEXT("");
00202
00203     LPTSTR pszUuid = NULL;
00204     LPTSTR pszOptions = NULL;
00205     LPTSTR pszStringBinding = NULL;
00206
00207     ULONG ThreadIdentifier;
00208     HANDLE hThread;
00209
00210     ThreadArgs *pArgs = NULL;
00211
00212     if((pArgs = (ThreadArgs *) AutoHeapAlloc(sizeof(ThreadArgs))) == NULL) {
00213         RpcRaiseException(ERROR_OUTOFMEMORY);
00214         return;
00215     }
00216
00217     // Set pArgs' fields to NULL so that we will know
00218     // in ShutdownThread which ones have been initialized.
00219     pArgs->hFileRepServer = NULL;
00220     pArgs->hLocalFile = NULL;
00221     pArgs->phContext = NULL;
00222
00223 #ifdef PROF
00224     static ULONG nTotalId;
00225
00226     if (WaitForSingleObject(hProfMutex, INFINITE) == WAIT_FAILED) {
00227   RaiseException(GetLastError(), 0, 0, NULL);
00228   return;
00229     }
00230
00231     // Record the number of the current request.
00232     pArgs->nReqId = nTotalId;
00233     // Increment the number of the request.
00234     nTotalId++;
00235
00236     if (ReleaseMutex(hProfMutex) == FALSE) {
00237   RaiseException(GetLastError(), 0, 0, NULL);
00238   return;
00239     }
00240
00241     TCHAR ProfMsg[MAX_PATH+16];
00242     _stprintf(ProfMsg, TEXT("name=\"%s\" arrived"), RemoteFileName);
00243
00244     // Record the time of arrival of this request.
00245     ProfRecordTime(pArgs->nReqId, ProfMsg);
00246 #endif
00247
00248     // Prepare the binding information.
00249     if ((rpcstatus = RpcStringBindingCompose(pszUuid,
00250                DefaultProtocolSequence,
00251                ServerName,
00252                DefaultEndpoint,
00253                pszOptions,
00254                &pszStringBinding)) != RPC_S_OK) {
00255
00256   ShutdownThread(pArgs);
00257         RpcRaiseException(rpcstatus);
00258   return;
00259     }
00260
00261     if ((rpcstatus = RpcBindingFromStringBinding(pszStringBinding, &(pArgs->hFileRepServer))) != RPC_S_OK) {
00262   // The binding handle is invalid
00263   pArgs->hFileRepServer = NULL;
00264
00265   ShutdownThread(pArgs);
00266         RpcRaiseException(rpcstatus);
00267   return;
00268     }
00269
00270     // We need to delete the string binding, since it is no longer
00271     // necessary.  All the binding information is now contained in the
00272     // binding handle.
00273     rpcstatus = RpcStringFree(&pszStringBinding);
00274     ASSERTE(rpcstatus == RPC_S_OK);
00275
00276     // We did not read anything yet.
00277     cbRead = 0;
00278
00279 #ifdef RETRY_EXCEPTION
00280     // When making aggressive calls to the server, this flag is
00281     // set when the call succeeded.  This makes the client service attempt
00282     // to contact the server even after an exception occured.
00283     BOOL bRetryCall = TRUE;
00284     while (bRetryCall) {
00285 #endif
00286
00287     // Attempt to open the remote file.
00288     RpcTryExcept {
00289         c_RemoteOpen(pArgs->hFileRepServer,
00290          &(pArgs->phContext),
00291          RemoteFileName,
00292          pArgs->pbBuf,
00293          &cbRead);
00294
00295 #ifdef RETRY_EXCEPTION
00296   bRetryCall = FALSE;
00297 #endif
00298
00299     }
00300     RpcExcept ( ( (RpcExceptionCode() != STATUS_ACCESS_VIOLATION) &&
00301       (RpcExceptionCode() != STATUS_DATATYPE_MISALIGNMENT) &&
00302       (RpcExceptionCode() != STATUS_PRIVILEGED_INSTRUCTION) &&
00303       (RpcExceptionCode() != STATUS_ILLEGAL_INSTRUCTION) &&
00304       (RpcExceptionCode() != STATUS_BREAKPOINT) )
00305       ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) {
00306
00307 #ifdef RETRY_EXCEPTION
00308   // This code attempts to make aggressive calls, retrying
00309   // if no endpoints are available.  It is used to put servers
00310   // under stress.
00311   if (RpcExceptionCode() != EPT_S_NOT_REGISTERED &&
00312       RpcExceptionCode() != RPC_S_SERVER_UNAVAILABLE) {
00313 #endif
00314   ShutdownThread(pArgs);
00315         RpcRaiseException(RPC_S_CALL_FAILED);
00316   return;
00317 #ifdef RETRY_EXCEPTION
00318         }
00319 #endif
00320     }
00321     RpcEndExcept;
00322
00323 #ifdef RETRY_EXCEPTION
00324     }
00325 #endif
00326
00327     // Attempt to open the local file.
00328     if ((pArgs->hLocalFile = CreateFile(LocalFileName,
00329           GENERIC_WRITE,
00330           0,
00331           NULL,
00332           CREATE_ALWAYS,
00333           FILE_ATTRIBUTE_NORMAL,
00334           NULL)) == INVALID_HANDLE_VALUE) {
00335   ShutdownThread(pArgs);
00336         RpcRaiseException(GetLastError());
00337   return;
00338     }
00339
00340     // Write the data received to local file.
00341     if(!WriteFile(pArgs->hLocalFile,
00342       pArgs->pbBuf,
00343       cbRead,
00344       &cbWritten,
00345       NULL)){
00346
00347   ShutdownThread(pArgs);
00348         RpcRaiseException(GetLastError());
00349         return;
00350     }
00351
00352     // If there are no errors and the call returned NULL, then
00353     // the file was read in a single call and has already been closed.
00354     // We just need to write the buffer and return.
00355     if(pArgs->phContext == NULL){
00356
00357 #ifdef PROF
00358   ProfRecordTime(pArgs->nReqId, TEXT("handled"));
00359 #endif
00360
00361   ShutdownThread(pArgs);
00362         return;
00363     }
00364
00365     // We need to read and close the file on a different
00366     // thread so that the client replication utility can return.
00367     // The data will be transfered in the background.
00368     if((hThread = CreateThread(NULL,
00369              0,
00370              (LPTHREAD_START_ROUTINE) ThreadProcRequest,
00371              pArgs,
00372              0,
00373              &ThreadIdentifier)) == NULL) {
00374
00375   ShutdownThread(pArgs);
00376         RpcRaiseException(GetLastError());
00377   return;
00378     }
00379
00380     // Unless we close a handle to the thread, it will remain in the
00381     // system even after its execution has terminated.
00382     status = CloseHandle(hThread);
00383     ASSERTE(status != 0);
00384
00385     // The memory will be freed and handles closed in ThreadProcRequest.
00386
00387     return;
00388 }
00389
00390 // end FileRepClientProc.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/error.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

error.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module ERROR.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 ////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 ////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 ////////////////////////////////////////////////////////////////////////
00019 // Globals
00020 //
00021 ////////////////////////////////////////////////////////////////////////
00022 DWORD g_dwErrorPost = EP_ERRORINFO_FAILURE | EP_HRESULT_NOERRORINFO;
00023 DWORD g_dwBreakID = 0;
00024
00025 BOOL SetErrorPosting(ERRORPOST eErrorPost, BOOL fSet)
00026 {
00027   if(fSet)
00028     g_dwErrorPost |= eErrorPost;
00029   else
00030     g_dwErrorPost &= ~eErrorPost;
00031
00032   return TRUE;
00033 };
00034
00035 BOOL GetErrorPosting(ERRORPOST eErrorPost)
00036 {
00037   return g_dwErrorPost & eErrorPost;
00038 };
00039
00040
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 //  Interface Map
00044 //
00045 /////////////////////////////////////////////////////////////////////////////
00046 const static WIDEGUIDMAP g_rgInterfaceMaps[] =
00047 {
00048   //TEnumerator
00049     VALUE_PWCHAR(IID_IParseDisplayName),
00050     VALUE_PWCHAR(IID_ISourcesRowset),
00051
00052   //TDataSource
00053     VALUE_PWCHAR(IID_IDBInitialize),
00054     VALUE_PWCHAR(IID_IDBProperties),
00055     VALUE_PWCHAR(IID_IDBCreateSession),
00056     VALUE_PWCHAR(IID_IDBInfo),
00057     VALUE_PWCHAR(IID_IPersist),
00058     VALUE_PWCHAR(IID_IDBAsynchStatus),
00059     VALUE_PWCHAR(IID_IDBDataSourceAdmin),
00060     VALUE_PWCHAR(IID_IPersistFile),
00061     VALUE_PWCHAR(IID_ISupportErrorInfo),
00062     VALUE_PWCHAR(IID_IServiceProvider),
00063     VALUE_PWCHAR(IID_ISpecifyPropertyPages),
00064
00065   //TSession
00066     VALUE_PWCHAR(IID_IGetDataSource),
00067     VALUE_PWCHAR(IID_IOpenRowset),
00068     VALUE_PWCHAR(IID_ISessionProperties),
00069     VALUE_PWCHAR(IID_IDBCreateCommand),
00070     VALUE_PWCHAR(IID_IDBSchemaRowset),
00071     VALUE_PWCHAR(IID_IIndexDefinition),
00072     VALUE_PWCHAR(IID_IAlterIndex),
00073     VALUE_PWCHAR(IID_IAlterTable),
00074     VALUE_PWCHAR(IID_ITableDefinition),
00075     VALUE_PWCHAR(IID_ITransactionJoin),
00076     VALUE_PWCHAR(IID_ITransactionLocal),
00077     VALUE_PWCHAR(IID_ITransactionObject),
00078
00079   //TCommand
00080     VALUE_PWCHAR(IID_IAccessor),
00081     VALUE_PWCHAR(IID_IColumnsInfo),
00082     VALUE_PWCHAR(IID_ICommand),
00083     VALUE_PWCHAR(IID_ICommandProperties),
00084     VALUE_PWCHAR(IID_ICommandText),
00085     VALUE_PWCHAR(IID_IConvertType),
00086     VALUE_PWCHAR(IID_IColumnsRowset),
00087     VALUE_PWCHAR(IID_ICommandPrepare),
00088     VALUE_PWCHAR(IID_ICommandPersist),
00089     VALUE_PWCHAR(IID_ICommandStream),
00090     VALUE_PWCHAR(IID_ICommandWithParameters),
00091
00092   //TRowset
00093     VALUE_PWCHAR(IID_IRowset),
00094     VALUE_PWCHAR(IID_IRowsetInfo),
00095     VALUE_PWCHAR(IID_IConnectionPointContainer),
00096     VALUE_PWCHAR(IID_IRowsetChange),
00097     VALUE_PWCHAR(IID_IRowsetIdentity),
00098     VALUE_PWCHAR(IID_IRowsetLocate),
00099     VALUE_PWCHAR(IID_IRowsetFind),
00100     VALUE_PWCHAR(IID_IRowsetView),
00101     VALUE_PWCHAR(IID_IChapteredRowset),
00102     VALUE_PWCHAR(IID_IRowsetResynch),
00103     VALUE_PWCHAR(IID_IRowsetRefresh),
00104     VALUE_PWCHAR(IID_IRowsetScroll),
00105     VALUE_PWCHAR(IID_IRowsetUpdate),
00106     VALUE_PWCHAR(IID_IRowsetBookmark),
00107     VALUE_PWCHAR(IID_IParentRowset),
00108     VALUE_PWCHAR(IID_IGetRow),
00109
00110   //TRow
00111     VALUE_PWCHAR(IID_IRow),
00112     VALUE_PWCHAR(IID_IGetSession),
00113     VALUE_PWCHAR(IID_IColumnsInfo2),
00114     VALUE_PWCHAR(IID_IRowChange),
00115     VALUE_PWCHAR(IID_IRowSchemaChange),
00116     VALUE_PWCHAR(IID_ICreateRow),
00117     VALUE_PWCHAR(IID_IScopedOperations),
00118
00119   //TTransaction
00120     VALUE_PWCHAR(IID_ITransaction),
00121     VALUE_PWCHAR(IID_ITransactionOptions),
00122
00123   //TMultipleResults
00124     VALUE_PWCHAR(IID_IMultipleResults),
00125
00126   //TView
00127     VALUE_PWCHAR(IID_IViewChapter),
00128     VALUE_PWCHAR(IID_IViewFilter),
00129     VALUE_PWCHAR(IID_IViewRowset),
00130     VALUE_PWCHAR(IID_IViewSort),
00131
00132   //TIndex
00133     VALUE_PWCHAR(IID_IRowsetIndex),
00134
00135   //TError
00136     VALUE_PWCHAR(IID_IErrorInfo),
00137     VALUE_PWCHAR(IID_IErrorRecords),
00138     VALUE_PWCHAR(IID_ISQLErrorInfo),
00139
00140   //Connection Points
00141     VALUE_PWCHAR(IID_IConnectionPoint),
00142     VALUE_PWCHAR(IID_IRowsetNotify),
00143     VALUE_PWCHAR(IID_IDBAsynchNotify),
00144     VALUE_PWCHAR(IID_IRowPositionChange),
00145
00146   //Misc
00147     VALUE_PWCHAR(IID_IRowPosition),
00148     VALUE_PWCHAR(IID_ISequentialStream),
00149     VALUE_PWCHAR(IID_IStream),
00150     VALUE_PWCHAR(IID_IStorage),
00151     VALUE_PWCHAR(IID_ILockBytes),
00152
00153   //MD
00154     VALUE_PWCHAR(IID_IMDDataset),
00155     VALUE_PWCHAR(IID_IMDFind),
00156     VALUE_PWCHAR(IID_IMDRangeRowset),
00157
00158   //Security
00159     VALUE_PWCHAR(IID_ITrusteeAdmin),
00160     VALUE_PWCHAR(IID_ITrusteeGroupAdmin),
00161     VALUE_PWCHAR(IID_IObjectAccessControl),
00162     VALUE_PWCHAR(IID_ISecurityInfo),
00163
00164   //Table Creation
00165     VALUE_PWCHAR(IID_ITableDefinitionWithConstraints),
00166     VALUE_PWCHAR(IID_ITableCreation),
00167
00168   //TBinder
00169     VALUE_PWCHAR(IID_IBindResource),
00170     VALUE_PWCHAR(IID_IDBBinderProperties),
00171     VALUE_PWCHAR(IID_IRegisterProvider),
00172
00173   //TStream
00174     VALUE_PWCHAR(IID_IGetSourceRow),
00175
00176   //Service Components
00177     VALUE_PWCHAR(IID_IDBPromptInitialize),
00178     VALUE_PWCHAR(IID_IDataInitialize),
00179
00180
00181   //Aggregation
00182     VALUE_PWCHAR(IID_IAggregate),
00183
00184   //IUnknown
00185     VALUE_PWCHAR(IID_IUnknown),
00186     VALUE_PWCHAR(IID_NULL),
00187 };
00188 const static ULONG g_cInterfaceMaps = NUMELE(g_rgInterfaceMaps);
00189
00190
00191 ////////////////////////////////////////////////////////////////////////
00192 // rgDBTypes
00193 //
00194 ////////////////////////////////////////////////////////////////////////
00195 const static WIDENAMEMAP g_rgDBTypes[] =
00196 {
00197     VALUE_WCHAR(DBTYPE_EMPTY  ),
00198   VALUE_WCHAR(DBTYPE_NULL ),
00199   VALUE_WCHAR(DBTYPE_I2 ),
00200   VALUE_WCHAR(DBTYPE_I4 ),
00201   VALUE_WCHAR(DBTYPE_R4 ),
00202   VALUE_WCHAR(DBTYPE_R8 ),
00203   VALUE_WCHAR(DBTYPE_CY ),
00204   VALUE_WCHAR(DBTYPE_DATE ),
00205   VALUE_WCHAR(DBTYPE_BSTR ),
00206   VALUE_WCHAR(DBTYPE_IDISPATCH  ),
00207   VALUE_WCHAR(DBTYPE_ERROR  ),
00208   VALUE_WCHAR(DBTYPE_BOOL ),
00209   VALUE_WCHAR(DBTYPE_VARIANT  ),
00210   VALUE_WCHAR(DBTYPE_IUNKNOWN ),
00211   VALUE_WCHAR(DBTYPE_DECIMAL  ),
00212   VALUE_WCHAR(DBTYPE_UI1  ),
00213   VALUE_WCHAR(DBTYPE_ARRAY  ),
00214   VALUE_WCHAR(DBTYPE_BYREF  ),
00215   VALUE_WCHAR(DBTYPE_I1 ),
00216   VALUE_WCHAR(DBTYPE_UI2  ),
00217   VALUE_WCHAR(DBTYPE_UI4  ),
00218   VALUE_WCHAR(DBTYPE_I8 ),
00219   VALUE_WCHAR(DBTYPE_UI8  ),
00220   VALUE_WCHAR(DBTYPE_GUID ),
00221   VALUE_WCHAR(DBTYPE_VECTOR ),
00222   VALUE_WCHAR(DBTYPE_RESERVED ),
00223   VALUE_WCHAR(DBTYPE_BYTES  ),
00224   VALUE_WCHAR(DBTYPE_STR  ),
00225   VALUE_WCHAR(DBTYPE_WSTR ),
00226   VALUE_WCHAR(DBTYPE_NUMERIC  ),
00227   VALUE_WCHAR(DBTYPE_UDT  ),
00228   VALUE_WCHAR(DBTYPE_DBDATE ),
00229   VALUE_WCHAR(DBTYPE_DBTIME ),
00230   VALUE_WCHAR(DBTYPE_DBTIMESTAMP  ),
00231   VALUE_WCHAR(DBTYPE_HCHAPTER ),
00232
00233   //2.0 Types
00234   VALUE_WCHAR(DBTYPE_FILETIME ),
00235   VALUE_WCHAR(DBTYPE_PROPVARIANT  ),
00236   VALUE_WCHAR(DBTYPE_VARNUMERIC ),
00237 };
00238 const static ULONG g_cDBTypes = NUMELE(g_rgDBTypes);
00239
00240
00241 ////////////////////////////////////////////////////////////////////////
00242 // rgVariantTypes
00243 //
00244 ////////////////////////////////////////////////////////////////////////
00245 const static WIDENAMEMAP g_rgVariantTypes[] =
00246 {
00247     VALUE_WCHAR(VT_EMPTY  ),
00248   VALUE_WCHAR(VT_NULL ),
00249   VALUE_WCHAR(VT_I2 ),
00250   VALUE_WCHAR(VT_I4 ),
00251   VALUE_WCHAR(VT_R4 ),
00252   VALUE_WCHAR(VT_R8 ),
00253   VALUE_WCHAR(VT_CY ),
00254   VALUE_WCHAR(VT_DATE ),
00255   VALUE_WCHAR(VT_BSTR ),
00256   VALUE_WCHAR(VT_DISPATCH ),
00257   VALUE_WCHAR(VT_ERROR  ),
00258   VALUE_WCHAR(VT_BOOL ),
00259   VALUE_WCHAR(VT_VARIANT  ),
00260   VALUE_WCHAR(VT_UNKNOWN  ),
00261   VALUE_WCHAR(VT_DECIMAL  ),
00262   VALUE_WCHAR(VT_I1 ),
00263   VALUE_WCHAR(VT_UI1  ),
00264   VALUE_WCHAR(VT_UI2  ),
00265   VALUE_WCHAR(VT_UI4  ),
00266   VALUE_WCHAR(VT_I8 ),
00267   VALUE_WCHAR(VT_UI8  ),
00268   VALUE_WCHAR(VT_INT  ),
00269   VALUE_WCHAR(VT_UINT ),
00270   VALUE_WCHAR(VT_VOID ),
00271   VALUE_WCHAR(VT_HRESULT  ),
00272   VALUE_WCHAR(VT_PTR  ),
00273   VALUE_WCHAR(VT_SAFEARRAY  ),
00274   VALUE_WCHAR(VT_CARRAY ),
00275   VALUE_WCHAR(VT_USERDEFINED  ),
00276   VALUE_WCHAR(VT_LPSTR  ),
00277   VALUE_WCHAR(VT_LPWSTR ),
00278   VALUE_WCHAR(VT_FILETIME ),
00279   VALUE_WCHAR(VT_BLOB ),
00280   VALUE_WCHAR(VT_STREAM ),
00281   VALUE_WCHAR(VT_STORAGE  ),
00282   VALUE_WCHAR(VT_STREAMED_OBJECT  ),
00283   VALUE_WCHAR(VT_STORED_OBJECT  ),
00284   VALUE_WCHAR(VT_BLOB_OBJECT  ),
00285   VALUE_WCHAR(VT_CF ),
00286   VALUE_WCHAR(VT_CLSID  ),
00287   VALUE_WCHAR(VT_VECTOR ),
00288   VALUE_WCHAR(VT_ARRAY  ),
00289   VALUE_WCHAR(VT_BYREF  ),
00290   VALUE_WCHAR(VT_RESERVED ),
00291   VALUE_WCHAR(VT_ILLEGAL  ),
00292   VALUE_WCHAR(VT_ILLEGALMASKED  ),
00293   VALUE_WCHAR(VT_TYPEMASK ),
00294 };
00295 const static ULONG g_cVariantTypes = NUMELE(g_rgVariantTypes);
00296
00297
00298 ////////////////////////////////////////////////////////////////////////
00299 // ERRORMAP
00300 //
00301 ////////////////////////////////////////////////////////////////////////
00302 const static NAMEMAP g_rgErrorMap[] =
00303 {
00304    //System Success
00305    VALUE_CHAR(S_OK),
00306    VALUE_CHAR(S_FALSE),
00307    VALUE_CHAR(CO_S_NOTALLINTERFACES),
00308
00309    //System Errors
00310    VALUE_CHAR(E_FAIL),
00311    VALUE_CHAR(E_INVALIDARG),
00312    VALUE_CHAR(E_OUTOFMEMORY),
00313    VALUE_CHAR(E_NOINTERFACE),
00314    VALUE_CHAR(REGDB_E_CLASSNOTREG),
00315    VALUE_CHAR(CLASS_E_NOAGGREGATION),
00316      VALUE_CHAR(E_UNEXPECTED),
00317      VALUE_CHAR(E_NOTIMPL),
00318      VALUE_CHAR(E_POINTER),
00319      VALUE_CHAR(E_HANDLE),
00320      VALUE_CHAR(E_ABORT),
00321      VALUE_CHAR(E_ACCESSDENIED),
00322      VALUE_CHAR(E_PENDING),
00323
00324    //OLE DB Warnings 1.1
00325      VALUE_CHAR(DB_S_ROWLIMITEXCEEDED),
00326      VALUE_CHAR(DB_S_COLUMNTYPEMISMATCH),
00327      VALUE_CHAR(DB_S_TYPEINFOOVERRIDDEN),
00328      VALUE_CHAR(DB_S_BOOKMARKSKIPPED),
00329      VALUE_CHAR(DB_S_ENDOFROWSET),
00330      VALUE_CHAR(DB_S_COMMANDREEXECUTED),
00331      VALUE_CHAR(DB_S_BUFFERFULL),
00332      VALUE_CHAR(DB_S_NORESULT),
00333      VALUE_CHAR(DB_S_CANTRELEASE),
00334      VALUE_CHAR(DB_S_DIALECTIGNORED),
00335      VALUE_CHAR(DB_S_UNWANTEDPHASE),
00336      VALUE_CHAR(DB_S_UNWANTEDREASON),
00337      VALUE_CHAR(DB_S_COLUMNSCHANGED),
00338      VALUE_CHAR(DB_S_ERRORSRETURNED),
00339      VALUE_CHAR(DB_S_BADROWHANDLE),
00340      VALUE_CHAR(DB_S_DELETEDROW),
00341      VALUE_CHAR(DB_S_STOPLIMITREACHED),
00342      VALUE_CHAR(DB_S_LOCKUPGRADED),
00343      VALUE_CHAR(DB_S_PROPERTIESCHANGED),
00344      VALUE_CHAR(DB_S_ERRORSOCCURRED),
00345      VALUE_CHAR(DB_S_PARAMUNAVAILABLE),
00346      VALUE_CHAR(DB_S_MULTIPLECHANGES),
00347
00348    //OLE DB Errors 1.1
00349      VALUE_CHAR(DB_E_BADACCESSORHANDLE),
00350      VALUE_CHAR(DB_E_ROWLIMITEXCEEDED),
00351      VALUE_CHAR(DB_E_READONLYACCESSOR),
00352      VALUE_CHAR(DB_E_SCHEMAVIOLATION),
00353      VALUE_CHAR(DB_E_BADROWHANDLE),
00354      VALUE_CHAR(DB_E_OBJECTOPEN),
00355      VALUE_CHAR(DB_E_CANTCONVERTVALUE),
00356      VALUE_CHAR(DB_E_BADBINDINFO),
00357      VALUE_CHAR(DB_SEC_E_PERMISSIONDENIED),
00358      VALUE_CHAR(DB_E_NOTAREFERENCECOLUMN),
00359      VALUE_CHAR(DB_E_NOCOMMAND),
00360      VALUE_CHAR(DB_E_BADBOOKMARK),
00361      VALUE_CHAR(DB_E_BADLOCKMODE),
00362      VALUE_CHAR(DB_E_PARAMNOTOPTIONAL),
00363      VALUE_CHAR(DB_E_BADCOLUMNID),
00364      VALUE_CHAR(DB_E_BADRATIO),
00365      VALUE_CHAR(DB_E_ERRORSINCOMMAND),
00366      VALUE_CHAR(DB_E_CANTCANCEL),
00367      VALUE_CHAR(DB_E_DIALECTNOTSUPPORTED),
00368      VALUE_CHAR(DB_E_DUPLICATEDATASOURCE),
00369      VALUE_CHAR(DB_E_CANNOTRESTART),
00370      VALUE_CHAR(DB_E_NOTFOUND),
00371      VALUE_CHAR(DB_E_NEWLYINSERTED),
00372      VALUE_CHAR(DB_E_UNSUPPORTEDCONVERSION),
00373      VALUE_CHAR(DB_E_BADSTARTPOSITION),
00374      VALUE_CHAR(DB_E_NOTREENTRANT),
00375      VALUE_CHAR(DB_E_ERRORSOCCURRED),
00376      VALUE_CHAR(DB_E_NOAGGREGATION),
00377      VALUE_CHAR(DB_E_DELETEDROW),
00378      VALUE_CHAR(DB_E_CANTFETCHBACKWARDS),
00379      VALUE_CHAR(DB_E_ROWSNOTRELEASED),
00380      VALUE_CHAR(DB_E_BADSTORAGEFLAG),
00381      VALUE_CHAR(DB_E_BADSTATUSVALUE),
00382      VALUE_CHAR(DB_E_CANTSCROLLBACKWARDS),
00383      VALUE_CHAR(DB_E_MULTIPLESTATEMENTS),
00384      VALUE_CHAR(DB_E_INTEGRITYVIOLATION),
00385      VALUE_CHAR(DB_E_BADTYPENAME),
00386      VALUE_CHAR(DB_E_ABORTLIMITREACHED),
00387      VALUE_CHAR(DB_E_DUPLICATEINDEXID),
00388      VALUE_CHAR(DB_E_NOINDEX),
00389      VALUE_CHAR(DB_E_INDEXINUSE),
00390      VALUE_CHAR(DB_E_NOTABLE),
00391      VALUE_CHAR(DB_E_CONCURRENCYVIOLATION),
00392      VALUE_CHAR(DB_E_BADCOPY),
00393      VALUE_CHAR(DB_E_BADPRECISION),
00394      VALUE_CHAR(DB_E_BADSCALE),
00395      VALUE_CHAR(DB_E_BADID),
00396      VALUE_CHAR(DB_E_BADTYPE),
00397      VALUE_CHAR(DB_E_DUPLICATECOLUMNID),
00398      VALUE_CHAR(DB_E_DUPLICATETABLEID),
00399      VALUE_CHAR(DB_E_TABLEINUSE),
00400      VALUE_CHAR(DB_E_NOLOCALE),
00401      VALUE_CHAR(DB_E_BADRECORDNUM),
00402      VALUE_CHAR(DB_E_BOOKMARKSKIPPED),
00403      VALUE_CHAR(DB_E_BADPROPERTYVALUE),
00404      VALUE_CHAR(DB_E_INVALID),
00405      VALUE_CHAR(DB_E_BADACCESSORFLAGS),
00406      VALUE_CHAR(DB_E_BADSTORAGEFLAGS),
00407      VALUE_CHAR(DB_E_BYREFACCESSORNOTSUPPORTED),
00408      VALUE_CHAR(DB_E_NULLACCESSORNOTSUPPORTED),
00409      VALUE_CHAR(DB_E_NOTPREPARED),
00410      VALUE_CHAR(DB_E_BADACCESSORTYPE),
00411      VALUE_CHAR(DB_E_WRITEONLYACCESSOR),
00412      VALUE_CHAR(DB_SEC_E_AUTH_FAILED),
00413      VALUE_CHAR(DB_E_CANCELED),
00414      VALUE_CHAR(DB_E_BADSOURCEHANDLE),
00415      VALUE_CHAR(DB_E_PARAMUNAVAILABLE),
00416      VALUE_CHAR(DB_E_ALREADYINITIALIZED),
00417      VALUE_CHAR(DB_E_NOTSUPPORTED),
00418      VALUE_CHAR(DB_E_MAXPENDCHANGESEXCEEDED),
00419      VALUE_CHAR(DB_E_BADORDINAL),
00420      VALUE_CHAR(DB_E_PENDINGCHANGES),
00421      VALUE_CHAR(DB_E_DATAOVERFLOW),
00422      VALUE_CHAR(DB_E_BADHRESULT),
00423      VALUE_CHAR(DB_E_BADLOOKUPID),
00424      VALUE_CHAR(DB_E_BADDYNAMICERRORID),
00425      VALUE_CHAR(DB_E_PENDINGINSERT),
00426      VALUE_CHAR(DB_E_BADCONVERTFLAG),
00427      VALUE_CHAR(DB_E_BADPARAMETERNAME),
00428      VALUE_CHAR(DB_E_MULTIPLESTORAGE),
00429      VALUE_CHAR(DB_E_CANTFILTER),
00430      VALUE_CHAR(DB_E_CANTORDER),
00431
00432    //OLE DB Warnings 1.5
00433      VALUE_CHAR(DB_S_ASYNCHRONOUS),
00434      VALUE_CHAR(DB_S_UNWANTEDOPERATION),
00435
00436    //OLE DB Warnings 2.0
00437    VALUE_CHAR(DB_S_NONEXTROWSET),
00438
00439    //OLE DB Warnings 2.1
00440    VALUE_CHAR(DB_S_NOTSINGLETON),
00441    VALUE_CHAR(DB_S_NOROWSPECIFICCOLUMNS),
00442
00443    //OLE DB Warnings 2.5
00444    VALUE_CHAR(DB_S_GOALCHANGED),
00445    VALUE_CHAR(DB_S_TOOMANYCHANGES),
00446
00447    //OLE DB Errors 1.5
00448      VALUE_CHAR(DB_E_BADCHAPTER),
00449    VALUE_CHAR(DB_E_BADCOMPAREOP),
00450
00451    //OLE DB Errors 2.0
00452    VALUE_CHAR(DB_E_BADVALUES),
00453    VALUE_CHAR(DB_E_NOQUERY),
00454    VALUE_CHAR(DB_E_ROWSETINCOMMAND),
00455    VALUE_CHAR(DB_E_CANTTRANSLATE),
00456    VALUE_CHAR(DB_E_CHAPTERNOTRELEASED),
00457
00458    VALUE_CHAR(MD_E_BADTUPLE),
00459    VALUE_CHAR(MD_E_BADCOORDINATE),
00460    VALUE_CHAR(MD_E_INVALIDAXIS),
00461    VALUE_CHAR(MD_E_INVALIDCELLRANGE),
00462    VALUE_CHAR(DB_E_NOCOLUMN),
00463    VALUE_CHAR(DB_E_COMMANDNOTPERSISTED),
00464    VALUE_CHAR(DB_E_DUPLICATEID),
00465    VALUE_CHAR(DB_E_OBJECTCREATIONLIMITREACHED),
00466    VALUE_CHAR(DB_E_BADINDEXID),
00467    VALUE_CHAR(DB_E_BADCOMMANDID),
00468
00469    //OLE DB Errors 2.1
00470      VALUE_CHAR(SEC_E_PERMISSIONDENIED),
00471      VALUE_CHAR(SEC_E_BADTRUSTEEID               ),
00472      VALUE_CHAR(SEC_E_NOTRUSTEEID                ),
00473      VALUE_CHAR(SEC_E_NOMEMBERSHIPSUPPORT        ),
00474      VALUE_CHAR(SEC_E_INVALIDOBJECT              ),
00475      VALUE_CHAR(SEC_E_NOOWNER                    ),
00476      VALUE_CHAR(SEC_E_INVALIDACCESSENTRYLIST     ),
00477      VALUE_CHAR(SEC_E_INVALIDOWNER               ),
00478      VALUE_CHAR(SEC_E_INVALIDACCESSENTRY         ),
00479      VALUE_CHAR(DB_E_BADCONSTRAINTTYPE           ),
00480      VALUE_CHAR(DB_E_BADCONSTRAINTFORM           ),
00481      VALUE_CHAR(DB_E_BADDEFERRABILITY            ),
00482      VALUE_CHAR(DB_E_BADMATCHTYPE                ),
00483      VALUE_CHAR(DB_E_BADUPDATEDELETERULE         ),
00484      VALUE_CHAR(DB_E_BADCONSTRAINTID             ),
00485      VALUE_CHAR(DB_E_BADCOMMANDFLAGS             ),
00486      VALUE_CHAR(DB_E_OBJECTMISMATCH              ),
00487      VALUE_CHAR(DB_E_NOSOURCEOBJECT              ),
00488      VALUE_CHAR(DB_E_RESOURCELOCKED              ),
00489      VALUE_CHAR(DB_E_NOTCOLLECTION               ),
00490      VALUE_CHAR(DB_E_READONLY                    ),
00491      VALUE_CHAR(DB_E_ASYNCNOTSUPPORTED           ),
00492      VALUE_CHAR(DB_E_CANNOTCONNECT               ),
00493      VALUE_CHAR(DB_E_TIMEOUT                     ),
00494      VALUE_CHAR(DB_E_RESOURCEEXISTS              ),
00495      VALUE_CHAR(DB_E_RESOURCEOUTOFSCOPE          ),
00496      VALUE_CHAR(DB_E_DROPRESTRICTED              ),
00497      VALUE_CHAR(DB_E_DUPLICATECONSTRAINTID       ),
00498
00499    //OLE DB Errors 2.5
00500      VALUE_CHAR(DB_SEC_E_SAFEMODE_DENIED       ),
00501    VALUE_CHAR(DB_E_LIMITREJECTED),
00502    VALUE_CHAR(DB_E_COSTLIMIT),
00503    VALUE_CHAR(DB_E_CANNOTFREE),
00504    VALUE_CHAR(DB_E_GOALREJECTED),
00505    VALUE_CHAR(DB_E_BADREGIONHANDLE),
00506    VALUE_CHAR(DB_E_NONCONTIGUOUSRANGE),
00507    VALUE_CHAR(DB_E_INVALIDTRANSITION),
00508    VALUE_CHAR(DB_E_NOTASUBREGION),
00509
00510    //OLE DB Errors 2.6
00511    VALUE_CHAR(DB_E_NOSTATISTIC                 ),
00512    VALUE_CHAR(DB_E_ALTERRESTRICTED             ),
00513    VALUE_CHAR(DB_E_RESOURCENOTSUPPORTED        ),
00514    VALUE_CHAR(DB_E_NOCONSTRAINT        ),
00515    VALUE_CHAR(DB_E_COLUMNUNAVAILABLE       ),
00516
00517    //Transactions
00518    VALUE_CHAR(XACT_E_ABORTED                  ),
00519    VALUE_CHAR(XACT_E_ALREADYOTHERSINGLEPHASE  ),
00520    VALUE_CHAR(XACT_E_ALREADYINPROGRESS        ),
00521    VALUE_CHAR(XACT_E_CANTRETAIN               ),
00522    VALUE_CHAR(XACT_E_COMMITFAILED             ),
00523    VALUE_CHAR(XACT_E_COMMITPREVENTED          ),
00524    VALUE_CHAR(XACT_E_CONNECTION_DENIED        ),
00525    VALUE_CHAR(XACT_E_CONNECTION_DOWN          ),
00526    VALUE_CHAR(XACT_E_HEURISTICABORT           ),
00527    VALUE_CHAR(XACT_E_HEURISTICCOMMIT          ),
00528    VALUE_CHAR(XACT_E_HEURISTICDAMAGE          ),
00529    VALUE_CHAR(XACT_E_HEURISTICDANGER          ),
00530    VALUE_CHAR(XACT_E_INDOUBT                  ),
00531    VALUE_CHAR(XACT_E_INVALIDCOOKIE            ),
00532    VALUE_CHAR(XACT_E_ISOLATIONLEVEL           ),
00533    VALUE_CHAR(XACT_E_LOGFULL                  ),
00534    VALUE_CHAR(XACT_E_NOASYNC                  ),
00535    VALUE_CHAR(XACT_E_NOENLIST                 ),
00536    VALUE_CHAR(XACT_E_NOIMPORTOBJECT           ),
00537    VALUE_CHAR(XACT_E_NOISORETAIN              ),
00538    VALUE_CHAR(XACT_E_NORESOURCE               ),
00539    VALUE_CHAR(XACT_E_NOTCURRENT               ),
00540    VALUE_CHAR(XACT_E_NOTIMEOUT                ),
00541    VALUE_CHAR(XACT_E_NOTRANSACTION            ),
00542    VALUE_CHAR(XACT_E_NOTSUPPORTED             ),
00543    VALUE_CHAR(XACT_E_REENLISTTIMEOUT          ),
00544    VALUE_CHAR(XACT_E_TMNOTAVAILABLE           ),
00545    VALUE_CHAR(XACT_E_UNKNOWNRMGRID            ),
00546    VALUE_CHAR(XACT_E_WRONGSTATE               ),
00547    VALUE_CHAR(XACT_E_WRONGUOW                 ),
00548    VALUE_CHAR(XACT_E_XTIONEXISTS              ),
00549
00550    VALUE_CHAR(XACT_S_ABORTING                 ),
00551    VALUE_CHAR(XACT_S_ALLNORETAIN              ),
00552    VALUE_CHAR(XACT_S_ASYNC                    ),
00553    VALUE_CHAR(XACT_S_DEFECT                   ),
00554    VALUE_CHAR(XACT_S_OKINFORM                 ),
00555    VALUE_CHAR(XACT_S_MADECHANGESCONTENT       ),
00556    VALUE_CHAR(XACT_S_MADECHANGESINFORM        ),
00557    VALUE_CHAR(XACT_S_READONLY                 ),
00558    VALUE_CHAR(XACT_S_SINGLEPHASE              ),
00559    VALUE_CHAR(XACT_S_SOMENORETAIN             ),
00560
00561    //Com Errors
00562    VALUE_CHAR(CO_E_NOTINITIALIZED              ),
00563    VALUE_CHAR(CO_E_ALREADYINITIALIZED          ),
00564    VALUE_CHAR(CO_E_CANTDETERMINECLASS          ),
00565    VALUE_CHAR(CO_E_CLASSSTRING                 ),
00566    VALUE_CHAR(CO_E_IIDSTRING                   ),
00567    VALUE_CHAR(CO_E_APPNOTFOUND                 ),
00568    VALUE_CHAR(CO_E_APPSINGLEUSE                ),
00569    VALUE_CHAR(CO_E_ERRORINAPP                  ),
00570    VALUE_CHAR(CO_E_DLLNOTFOUND                 ),
00571    VALUE_CHAR(CO_E_ERRORINDLL                  ),
00572    VALUE_CHAR(CO_E_WRONGOSFORAPP               ),
00573    VALUE_CHAR(CO_E_OBJNOTREG                   ),
00574    VALUE_CHAR(CO_E_OBJISREG                    ),
00575    VALUE_CHAR(CO_E_OBJNOTCONNECTED             ),
00576    VALUE_CHAR(CO_E_APPDIDNTREG                 ),
00577    VALUE_CHAR(CO_E_RELEASED                    ),
00578
00579    //Moniker Errors
00580    VALUE_CHAR(MK_E_CONNECTMANUALLY             ),
00581    VALUE_CHAR(MK_E_EXCEEDEDDEADLINE            ),
00582    VALUE_CHAR(MK_E_NEEDGENERIC                 ),
00583    VALUE_CHAR(MK_E_UNAVAILABLE                 ),
00584    VALUE_CHAR(MK_E_SYNTAX                      ),
00585    VALUE_CHAR(MK_E_NOOBJECT                    ),
00586    VALUE_CHAR(MK_E_INVALIDEXTENSION            ),
00587    VALUE_CHAR(MK_E_INTERMEDIATEINTERFACENOTSUPPORTED ),
00588    VALUE_CHAR(MK_E_NOTBINDABLE                 ),
00589    VALUE_CHAR(MK_E_NOTBOUND                    ),
00590    VALUE_CHAR(MK_E_CANTOPENFILE                ),
00591    VALUE_CHAR(MK_E_MUSTBOTHERUSER              ),
00592    VALUE_CHAR(MK_E_NOINVERSE                   ),
00593    VALUE_CHAR(MK_E_NOSTORAGE                   ),
00594    VALUE_CHAR(MK_E_NOPREFIX                    ),
00595    VALUE_CHAR(MK_E_ENUMERATION_FAILED          ),
00596
00597    //Connection Points
00598    VALUE_CHAR(CONNECT_E_NOCONNECTION),
00599    VALUE_CHAR(CONNECT_E_ADVISELIMIT),
00600    VALUE_CHAR(CONNECT_E_CANNOTCONNECT),
00601    VALUE_CHAR(CONNECT_E_OVERRIDDEN),
00602
00603    //Dispatch/Variant Errors
00604    VALUE_CHAR(DISP_E_UNKNOWNINTERFACE),
00605    VALUE_CHAR(DISP_E_MEMBERNOTFOUND),
00606    VALUE_CHAR(DISP_E_PARAMNOTFOUND),
00607    VALUE_CHAR(DISP_E_TYPEMISMATCH),
00608    VALUE_CHAR(DISP_E_UNKNOWNNAME),
00609    VALUE_CHAR(DISP_E_NONAMEDARGS),
00610    VALUE_CHAR(DISP_E_BADVARTYPE),
00611    VALUE_CHAR(DISP_E_EXCEPTION),
00612    VALUE_CHAR(DISP_E_OVERFLOW),
00613    VALUE_CHAR(DISP_E_BADINDEX),
00614    VALUE_CHAR(DISP_E_UNKNOWNLCID),
00615    VALUE_CHAR(DISP_E_ARRAYISLOCKED),
00616    VALUE_CHAR(DISP_E_BADPARAMCOUNT),
00617    VALUE_CHAR(DISP_E_PARAMNOTOPTIONAL),
00618    VALUE_CHAR(DISP_E_BADCALLEE),
00619    VALUE_CHAR(DISP_E_NOTACOLLECTION),
00620
00621    //DataSource Locator Errors
00622    VALUE_CHAR(DB_E_BADINITSTRING),
00623    VALUE_CHAR(DB_E_NOPROVIDERSREGISTERED),
00624    VALUE_CHAR(DB_E_MISMATCHEDPROVIDER),
00625
00626   //STG Errors
00627   VALUE_CHAR(STG_E_INVALIDFUNCTION            ),
00628   VALUE_CHAR(STG_E_FILENOTFOUND               ),
00629   VALUE_CHAR(STG_E_PATHNOTFOUND               ),
00630   VALUE_CHAR(STG_E_TOOMANYOPENFILES           ),
00631   VALUE_CHAR(STG_E_ACCESSDENIED               ),
00632   VALUE_CHAR(STG_E_INVALIDHANDLE              ),
00633   VALUE_CHAR(STG_E_INSUFFICIENTMEMORY         ),
00634   VALUE_CHAR(STG_E_INVALIDPOINTER             ),
00635   VALUE_CHAR(STG_E_NOMOREFILES                ),
00636   VALUE_CHAR(STG_E_DISKISWRITEPROTECTED       ),
00637   VALUE_CHAR(STG_E_SEEKERROR                  ),
00638   VALUE_CHAR(STG_E_WRITEFAULT                 ),
00639   VALUE_CHAR(STG_E_READFAULT                  ),
00640   VALUE_CHAR(STG_E_SHAREVIOLATION             ),
00641   VALUE_CHAR(STG_E_LOCKVIOLATION              ),
00642   VALUE_CHAR(STG_E_FILEALREADYEXISTS          ),
00643   VALUE_CHAR(STG_E_INVALIDPARAMETER           ),
00644   VALUE_CHAR(STG_E_MEDIUMFULL                 ),
00645   VALUE_CHAR(STG_E_PROPSETMISMATCHED          ),
00646   VALUE_CHAR(STG_E_ABNORMALAPIEXIT            ),
00647   VALUE_CHAR(STG_E_INVALIDHEADER              ),
00648   VALUE_CHAR(STG_E_INVALIDNAME                ),
00649   VALUE_CHAR(STG_E_UNKNOWN                    ),
00650   VALUE_CHAR(STG_E_UNIMPLEMENTEDFUNCTION      ),
00651   VALUE_CHAR(STG_E_INVALIDFLAG                ),
00652   VALUE_CHAR(STG_E_INUSE                      ),
00653   VALUE_CHAR(STG_E_NOTCURRENT                 ),
00654   VALUE_CHAR(STG_E_REVERTED                   ),
00655   VALUE_CHAR(STG_E_CANTSAVE                   ),
00656   VALUE_CHAR(STG_E_OLDFORMAT                  ),
00657   VALUE_CHAR(STG_E_OLDDLL                     ),
00658   VALUE_CHAR(STG_E_SHAREREQUIRED              ),
00659   VALUE_CHAR(STG_E_NOTFILEBASEDSTORAGE        ),
00660   VALUE_CHAR(STG_E_EXTANTMARSHALLINGS         ),
00661   VALUE_CHAR(STG_E_DOCFILECORRUPT             ),
00662   VALUE_CHAR(STG_E_BADBASEADDRESS             ),
00663   VALUE_CHAR(STG_E_INCOMPLETE                 ),
00664   VALUE_CHAR(STG_E_TERMINATED                 ),
00665   VALUE_CHAR(STG_S_CONVERTED                  ),
00666   VALUE_CHAR(STG_S_BLOCK                      ),
00667   VALUE_CHAR(STG_S_RETRYNOW                   ),
00668   VALUE_CHAR(STG_S_MONITORING                 ),
00669
00670    //RPC Errors
00671   VALUE_CHAR( CO_E_INIT_TLS                    ),
00672   VALUE_CHAR( CO_E_INIT_SHARED_ALLOCATOR       ),
00673   VALUE_CHAR( CO_E_INIT_MEMORY_ALLOCATOR       ),
00674   VALUE_CHAR( CO_E_INIT_CLASS_CACHE            ),
00675   VALUE_CHAR( CO_E_INIT_RPC_CHANNEL            ),
00676   VALUE_CHAR( CO_E_INIT_TLS_SET_CHANNEL_CONTROL ),
00677   VALUE_CHAR( CO_E_INIT_TLS_CHANNEL_CONTROL    ),
00678   VALUE_CHAR( CO_E_INIT_UNACCEPTED_USER_ALLOCATOR ),
00679   VALUE_CHAR( CO_E_INIT_SCM_MUTEX_EXISTS       ),
00680   VALUE_CHAR( CO_E_INIT_SCM_FILE_MAPPING_EXISTS ),
00681   VALUE_CHAR( CO_E_INIT_SCM_MAP_VIEW_OF_FILE   ),
00682   VALUE_CHAR( CO_E_INIT_SCM_EXEC_FAILURE       ),
00683   VALUE_CHAR( CO_E_INIT_ONLY_SINGLE_THREADED   ),
00684   VALUE_CHAR( CO_E_CANT_REMOTE                 ),
00685   VALUE_CHAR( CO_E_BAD_SERVER_NAME             ),
00686   VALUE_CHAR( CO_E_WRONG_SERVER_IDENTITY       ),
00687   VALUE_CHAR( CO_E_OLE1DDE_DISABLED            ),
00688   VALUE_CHAR( CO_E_RUNAS_SYNTAX                ),
00689   VALUE_CHAR( CO_E_CREATEPROCESS_FAILURE       ),
00690   VALUE_CHAR( CO_E_RUNAS_CREATEPROCESS_FAILURE ),
00691   VALUE_CHAR( CO_E_RUNAS_LOGON_FAILURE         ),
00692   VALUE_CHAR( CO_E_LAUNCH_PERMSSION_DENIED     ),
00693   VALUE_CHAR( CO_E_START_SERVICE_FAILURE       ),
00694   VALUE_CHAR( CO_E_REMOTE_COMMUNICATION_FAILURE ),
00695   VALUE_CHAR( CO_E_SERVER_START_TIMEOUT        ),
00696   VALUE_CHAR( CO_E_CLSREG_INCONSISTENT         ),
00697   VALUE_CHAR( CO_E_IIDREG_INCONSISTENT         ),
00698   VALUE_CHAR( CO_E_NOT_SUPPORTED               ),
00699
00700   //RPC Errors
00701      VALUE_CHAR_HR(ERROR_BAD_FORMAT                 ),
00702      VALUE_CHAR_HR(ERROR_INVALID_ACCESS             ),
00703      VALUE_CHAR_HR(ERROR_INVALID_DATA               ),
00704      VALUE_CHAR_HR(ERROR_OUTOFMEMORY                ),
00705      VALUE_CHAR_HR(ERROR_INVALID_DRIVE              ),
00706      VALUE_CHAR_HR(ERROR_CURRENT_DIRECTORY          ),
00707      VALUE_CHAR_HR(ERROR_NOT_SAME_DEVICE            ),
00708      VALUE_CHAR_HR(ERROR_NO_MORE_FILES              ),
00709      VALUE_CHAR_HR(ERROR_WRITE_PROTECT              ),
00710      VALUE_CHAR_HR(ERROR_BAD_UNIT                   ),
00711      VALUE_CHAR_HR(ERROR_NOT_READY                  ),
00712      VALUE_CHAR_HR(ERROR_BAD_COMMAND                ),
00713      VALUE_CHAR_HR(ERROR_CRC                        ),
00714      VALUE_CHAR_HR(ERROR_BAD_LENGTH                 ),
00715      VALUE_CHAR_HR(ERROR_SEEK                       ),
00716      VALUE_CHAR_HR(ERROR_NOT_DOS_DISK               ),
00717      VALUE_CHAR_HR(ERROR_SECTOR_NOT_FOUND           ),
00718      VALUE_CHAR_HR(ERROR_OUT_OF_PAPER               ),
00719      VALUE_CHAR_HR(ERROR_WRITE_FAULT                ),
00720      VALUE_CHAR_HR(ERROR_READ_FAULT                 ),
00721      VALUE_CHAR_HR(ERROR_GEN_FAILURE                ),
00722      VALUE_CHAR_HR(ERROR_SHARING_VIOLATION          ),
00723      VALUE_CHAR_HR(ERROR_LOCK_VIOLATION             ),
00724      VALUE_CHAR_HR(ERROR_WRONG_DISK                 ),
00725      VALUE_CHAR_HR(ERROR_SHARING_BUFFER_EXCEEDED    ),
00726      VALUE_CHAR_HR(ERROR_HANDLE_EOF                 ),
00727      VALUE_CHAR_HR(ERROR_HANDLE_DISK_FULL           ),
00728      VALUE_CHAR_HR(ERROR_NOT_SUPPORTED              ),
00729      VALUE_CHAR_HR(ERROR_REM_NOT_LIST               ),
00730      VALUE_CHAR_HR(ERROR_DUP_NAME                   ),
00731      VALUE_CHAR_HR(ERROR_BAD_NETPATH                ),
00732      VALUE_CHAR_HR(ERROR_NETWORK_BUSY               ),
00733      VALUE_CHAR_HR(ERROR_DEV_NOT_EXIST              ),
00734      VALUE_CHAR_HR(ERROR_TOO_MANY_CMDS              ),
00735      VALUE_CHAR_HR(ERROR_ADAP_HDW_ERR               ),
00736      VALUE_CHAR_HR(ERROR_BAD_NET_RESP               ),
00737      VALUE_CHAR_HR(ERROR_UNEXP_NET_ERR              ),
00738      VALUE_CHAR_HR(ERROR_BAD_REM_ADAP               ),
00739      VALUE_CHAR_HR(ERROR_PRINTQ_FULL                ),
00740      VALUE_CHAR_HR(ERROR_NO_SPOOL_SPACE             ),
00741      VALUE_CHAR_HR(ERROR_PRINT_CANCELLED            ),
00742      VALUE_CHAR_HR(ERROR_NETNAME_DELETED            ),
00743      VALUE_CHAR_HR(ERROR_NETWORK_ACCESS_DENIED      ),
00744      VALUE_CHAR_HR(ERROR_BAD_DEV_TYPE               ),
00745      VALUE_CHAR_HR(ERROR_BAD_NET_NAME               ),
00746      VALUE_CHAR_HR(ERROR_TOO_MANY_NAMES             ),
00747      VALUE_CHAR_HR(ERROR_TOO_MANY_SESS              ),
00748      VALUE_CHAR_HR(ERROR_SHARING_PAUSED             ),
00749      VALUE_CHAR_HR(ERROR_REQ_NOT_ACCEP              ),
00750      VALUE_CHAR_HR(ERROR_REDIR_PAUSED               ),
00751      VALUE_CHAR_HR(ERROR_FILE_EXISTS                ),
00752      VALUE_CHAR_HR(ERROR_CANNOT_MAKE                ),
00753      VALUE_CHAR_HR(ERROR_FAIL_I24                   ),
00754      VALUE_CHAR_HR(ERROR_OUT_OF_STRUCTURES          ),
00755      VALUE_CHAR_HR(ERROR_ALREADY_ASSIGNED           ),
00756      VALUE_CHAR_HR(ERROR_INVALID_PASSWORD           ),
00757      VALUE_CHAR_HR(ERROR_INVALID_PARAMETER          ),
00758      VALUE_CHAR_HR(ERROR_NET_WRITE_FAULT            ),
00759      VALUE_CHAR_HR(ERROR_NO_PROC_SLOTS              ),
00760      VALUE_CHAR_HR(ERROR_TOO_MANY_SEMAPHORES        ),
00761      VALUE_CHAR_HR(ERROR_EXCL_SEM_ALREADY_OWNED     ),
00762      VALUE_CHAR_HR(ERROR_SEM_IS_SET                 ),
00763      VALUE_CHAR_HR(ERROR_TOO_MANY_SEM_REQUESTS      ),
00764      VALUE_CHAR_HR(ERROR_INVALID_AT_INTERRUPT_TIME  ),
00765      VALUE_CHAR_HR(ERROR_SEM_OWNER_DIED             ),
00766      VALUE_CHAR_HR(ERROR_SEM_USER_LIMIT             ),
00767      VALUE_CHAR_HR(ERROR_DISK_CHANGE                ),
00768      VALUE_CHAR_HR(ERROR_DRIVE_LOCKED               ),
00769      VALUE_CHAR_HR(ERROR_BROKEN_PIPE                ),
00770      VALUE_CHAR_HR(ERROR_OPEN_FAILED                ),
00771      VALUE_CHAR_HR(ERROR_BUFFER_OVERFLOW            ),
00772      VALUE_CHAR_HR(ERROR_DISK_FULL                  ),
00773      VALUE_CHAR_HR(ERROR_NO_MORE_SEARCH_HANDLES     ),
00774      VALUE_CHAR_HR(ERROR_INVALID_TARGET_HANDLE      ),
00775      VALUE_CHAR_HR(ERROR_INVALID_CATEGORY           ),
00776      VALUE_CHAR_HR(ERROR_INVALID_VERIFY_SWITCH      ),
00777      VALUE_CHAR_HR(ERROR_BAD_DRIVER_LEVEL           ),
00778      VALUE_CHAR_HR(ERROR_CALL_NOT_IMPLEMENTED       ),
00779      VALUE_CHAR_HR(ERROR_SEM_TIMEOUT                ),
00780      VALUE_CHAR_HR(ERROR_INSUFFICIENT_BUFFER        ),
00781      VALUE_CHAR_HR(ERROR_INVALID_NAME               ),
00782      VALUE_CHAR_HR(ERROR_INVALID_LEVEL              ),
00783      VALUE_CHAR_HR(ERROR_NO_VOLUME_LABEL            ),
00784      VALUE_CHAR_HR(ERROR_MOD_NOT_FOUND              ),
00785      VALUE_CHAR_HR(ERROR_PROC_NOT_FOUND             ),
00786      VALUE_CHAR_HR(ERROR_WAIT_NO_CHILDREN           ),
00787      VALUE_CHAR_HR(ERROR_CHILD_NOT_COMPLETE         ),
00788      VALUE_CHAR_HR(ERROR_DIRECT_ACCESS_HANDLE       ),
00789      VALUE_CHAR_HR(ERROR_NEGATIVE_SEEK              ),
00790      VALUE_CHAR_HR(ERROR_SEEK_ON_DEVICE             ),
00791      VALUE_CHAR_HR(ERROR_IS_JOIN_TARGET             ),
00792      VALUE_CHAR_HR(ERROR_IS_JOINED                  ),
00793      VALUE_CHAR_HR(ERROR_IS_SUBSTED                 ),
00794      VALUE_CHAR_HR(ERROR_NOT_JOINED                 ),
00795      VALUE_CHAR_HR(ERROR_NOT_SUBSTED                ),
00796      VALUE_CHAR_HR(ERROR_JOIN_TO_JOIN               ),
00797      VALUE_CHAR_HR(ERROR_SUBST_TO_SUBST             ),
00798      VALUE_CHAR_HR(ERROR_JOIN_TO_SUBST              ),
00799      VALUE_CHAR_HR(ERROR_SUBST_TO_JOIN              ),
00800      VALUE_CHAR_HR(ERROR_BUSY_DRIVE                 ),
00801      VALUE_CHAR_HR(ERROR_SAME_DRIVE                 ),
00802      VALUE_CHAR_HR(ERROR_DIR_NOT_ROOT               ),
00803      VALUE_CHAR_HR(ERROR_DIR_NOT_EMPTY              ),
00804      VALUE_CHAR_HR(ERROR_IS_SUBST_PATH              ),
00805      VALUE_CHAR_HR(ERROR_IS_JOIN_PATH               ),
00806      VALUE_CHAR_HR(ERROR_PATH_BUSY                  ),
00807      VALUE_CHAR_HR(ERROR_IS_SUBST_TARGET            ),
00808      VALUE_CHAR_HR(ERROR_SYSTEM_TRACE               ),
00809      VALUE_CHAR_HR(ERROR_INVALID_EVENT_COUNT        ),
00810      VALUE_CHAR_HR(ERROR_TOO_MANY_MUXWAITERS        ),
00811      VALUE_CHAR_HR(ERROR_INVALID_LIST_FORMAT        ),
00812      VALUE_CHAR_HR(ERROR_LABEL_TOO_LONG             ),
00813      VALUE_CHAR_HR(ERROR_TOO_MANY_TCBS              ),
00814      VALUE_CHAR_HR(ERROR_SIGNAL_REFUSED             ),
00815      VALUE_CHAR_HR(ERROR_DISCARDED                  ),
00816      VALUE_CHAR_HR(ERROR_NOT_LOCKED                 ),
00817      VALUE_CHAR_HR(ERROR_BAD_THREADID_ADDR          ),
00818      VALUE_CHAR_HR(ERROR_BAD_ARGUMENTS              ),
00819      VALUE_CHAR_HR(ERROR_BAD_PATHNAME               ),
00820      VALUE_CHAR_HR(ERROR_SIGNAL_PENDING             ),
00821      VALUE_CHAR_HR(ERROR_MAX_THRDS_REACHED          ),
00822      VALUE_CHAR_HR(ERROR_LOCK_FAILED                ),
00823      VALUE_CHAR_HR(ERROR_BUSY                       ),
00824      VALUE_CHAR_HR(ERROR_CANCEL_VIOLATION           ),
00825      VALUE_CHAR_HR(ERROR_ATOMIC_LOCKS_NOT_SUPPORTED ),
00826      VALUE_CHAR_HR(ERROR_INVALID_SEGMENT_NUMBER     ),
00827      VALUE_CHAR_HR(ERROR_INVALID_ORDINAL            ),
00828      VALUE_CHAR_HR(ERROR_ALREADY_EXISTS             ),
00829      VALUE_CHAR_HR(ERROR_INVALID_FLAG_NUMBER        ),
00830      VALUE_CHAR_HR(ERROR_SEM_NOT_FOUND              ),
00831      VALUE_CHAR_HR(ERROR_INVALID_STARTING_CODESEG   ),
00832      VALUE_CHAR_HR(ERROR_INVALID_STACKSEG           ),
00833      VALUE_CHAR_HR(ERROR_INVALID_MODULETYPE         ),
00834      VALUE_CHAR_HR(ERROR_INVALID_EXE_SIGNATURE      ),
00835      VALUE_CHAR_HR(ERROR_EXE_MARKED_INVALID         ),
00836      VALUE_CHAR_HR(ERROR_BAD_EXE_FORMAT             ),
00837      VALUE_CHAR_HR(ERROR_ITERATED_DATA_EXCEEDS_64k  ),
00838      VALUE_CHAR_HR(ERROR_INVALID_MINALLOCSIZE       ),
00839      VALUE_CHAR_HR(ERROR_DYNLINK_FROM_INVALID_RING  ),
00840      VALUE_CHAR_HR(ERROR_IOPL_NOT_ENABLED           ),
00841      VALUE_CHAR_HR(ERROR_INVALID_SEGDPL             ),
00842      VALUE_CHAR_HR(ERROR_AUTODATASEG_EXCEEDS_64k    ),
00843      VALUE_CHAR_HR(ERROR_RING2SEG_MUST_BE_MOVABLE   ),
00844      VALUE_CHAR_HR(ERROR_RELOC_CHAIN_XEEDS_SEGLIM   ),
00845      VALUE_CHAR_HR(ERROR_INFLOOP_IN_RELOC_CHAIN     ),
00846      VALUE_CHAR_HR(ERROR_ENVVAR_NOT_FOUND           ),
00847      VALUE_CHAR_HR(ERROR_NO_SIGNAL_SENT             ),
00848      VALUE_CHAR_HR(ERROR_FILENAME_EXCED_RANGE       ),
00849      VALUE_CHAR_HR(ERROR_RING2_STACK_IN_USE         ),
00850      VALUE_CHAR_HR(ERROR_META_EXPANSION_TOO_LONG    ),
00851      VALUE_CHAR_HR(ERROR_INVALID_SIGNAL_NUMBER      ),
00852      VALUE_CHAR_HR(ERROR_THREAD_1_INACTIVE          ),
00853      VALUE_CHAR_HR(ERROR_LOCKED                     ),
00854      VALUE_CHAR_HR(ERROR_TOO_MANY_MODULES           ),
00855      VALUE_CHAR_HR(ERROR_NESTING_NOT_ALLOWED        ),
00856      VALUE_CHAR_HR(ERROR_EXE_MACHINE_TYPE_MISMATCH  ),
00857      VALUE_CHAR_HR(ERROR_BAD_PIPE                   ),
00858      VALUE_CHAR_HR(ERROR_PIPE_BUSY                  ),
00859      VALUE_CHAR_HR(ERROR_NO_DATA                    ),
00860      VALUE_CHAR_HR(ERROR_PIPE_NOT_CONNECTED         ),
00861      VALUE_CHAR_HR(ERROR_MORE_DATA                  ),
00862      VALUE_CHAR_HR(ERROR_VC_DISCONNECTED            ),
00863      VALUE_CHAR_HR(ERROR_INVALID_EA_NAME            ),
00864      VALUE_CHAR_HR(ERROR_EA_LIST_INCONSISTENT       ),
00865      VALUE_CHAR_HR(ERROR_NO_MORE_ITEMS              ),
00866      VALUE_CHAR_HR(ERROR_CANNOT_COPY                ),
00867      VALUE_CHAR_HR(ERROR_DIRECTORY                  ),
00868      VALUE_CHAR_HR(ERROR_EAS_DIDNT_FIT              ),
00869      VALUE_CHAR_HR(ERROR_EA_FILE_CORRUPT            ),
00870      VALUE_CHAR_HR(ERROR_EA_TABLE_FULL              ),
00871      VALUE_CHAR_HR(ERROR_INVALID_EA_HANDLE          ),
00872      VALUE_CHAR_HR(ERROR_EAS_NOT_SUPPORTED          ),
00873      VALUE_CHAR_HR(ERROR_NOT_OWNER                  ),
00874      VALUE_CHAR_HR(ERROR_TOO_MANY_POSTS             ),
00875      VALUE_CHAR_HR(ERROR_PARTIAL_COPY               ),
00876      VALUE_CHAR_HR(ERROR_MR_MID_NOT_FOUND           ),
00877      VALUE_CHAR_HR(ERROR_INVALID_ADDRESS            ),
00878      VALUE_CHAR_HR(ERROR_ARITHMETIC_OVERFLOW        ),
00879      VALUE_CHAR_HR(ERROR_PIPE_CONNECTED             ),
00880      VALUE_CHAR_HR(ERROR_PIPE_LISTENING             ),
00881      VALUE_CHAR_HR(ERROR_EA_ACCESS_DENIED           ),
00882      VALUE_CHAR_HR(ERROR_OPERATION_ABORTED          ),
00883      VALUE_CHAR_HR(ERROR_IO_INCOMPLETE              ),
00884      VALUE_CHAR_HR(ERROR_IO_PENDING                 ),
00885      VALUE_CHAR_HR(ERROR_NOACCESS                   ),
00886      VALUE_CHAR_HR(ERROR_SWAPERROR                  ),
00887      VALUE_CHAR_HR(ERROR_STACK_OVERFLOW             ),
00888      VALUE_CHAR_HR(ERROR_INVALID_MESSAGE            ),
00889      VALUE_CHAR_HR(ERROR_CAN_NOT_COMPLETE           ),
00890      VALUE_CHAR_HR(ERROR_INVALID_FLAGS              ),
00891      VALUE_CHAR_HR(ERROR_UNRECOGNIZED_VOLUME        ),
00892      VALUE_CHAR_HR(ERROR_FILE_INVALID               ),
00893      VALUE_CHAR_HR(ERROR_FULLSCREEN_MODE            ),
00894      VALUE_CHAR_HR(ERROR_NO_TOKEN                   ),
00895      VALUE_CHAR_HR(ERROR_BADDB                      ),
00896      VALUE_CHAR_HR(ERROR_BADKEY                     ),
00897      VALUE_CHAR_HR(ERROR_CANTOPEN                   ),
00898      VALUE_CHAR_HR(ERROR_CANTREAD                   ),
00899      VALUE_CHAR_HR(ERROR_CANTWRITE                  ),
00900      VALUE_CHAR_HR(ERROR_REGISTRY_RECOVERED         ),
00901      VALUE_CHAR_HR(ERROR_REGISTRY_CORRUPT           ),
00902      VALUE_CHAR_HR(ERROR_REGISTRY_IO_FAILED         ),
00903      VALUE_CHAR_HR(ERROR_NOT_REGISTRY_FILE          ),
00904      VALUE_CHAR_HR(ERROR_KEY_DELETED                ),
00905      VALUE_CHAR_HR(ERROR_NO_LOG_SPACE               ),
00906      VALUE_CHAR_HR(ERROR_KEY_HAS_CHILDREN           ),
00907      VALUE_CHAR_HR(ERROR_CHILD_MUST_BE_VOLATILE     ),
00908      VALUE_CHAR_HR(ERROR_NOTIFY_ENUM_DIR            ),
00909      VALUE_CHAR_HR(ERROR_DEPENDENT_SERVICES_RUNNING ),
00910      VALUE_CHAR_HR(ERROR_INVALID_SERVICE_CONTROL    ),
00911      VALUE_CHAR_HR(ERROR_SERVICE_REQUEST_TIMEOUT    ),
00912      VALUE_CHAR_HR(ERROR_SERVICE_NO_THREAD          ),
00913      VALUE_CHAR_HR(ERROR_SERVICE_DATABASE_LOCKED    ),
00914      VALUE_CHAR_HR(ERROR_SERVICE_ALREADY_RUNNING    ),
00915      VALUE_CHAR_HR(ERROR_INVALID_SERVICE_ACCOUNT    ),
00916      VALUE_CHAR_HR(ERROR_SERVICE_DISABLED           ),
00917      VALUE_CHAR_HR(ERROR_CIRCULAR_DEPENDENCY        ),
00918      VALUE_CHAR_HR(ERROR_SERVICE_DOES_NOT_EXIST     ),
00919      VALUE_CHAR_HR(ERROR_SERVICE_CANNOT_ACCEPT_CTRL ),
00920      VALUE_CHAR_HR(ERROR_SERVICE_NOT_ACTIVE         ),
00921      VALUE_CHAR_HR(ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ),
00922      VALUE_CHAR_HR(ERROR_EXCEPTION_IN_SERVICE       ),
00923      VALUE_CHAR_HR(ERROR_DATABASE_DOES_NOT_EXIST    ),
00924      VALUE_CHAR_HR(ERROR_SERVICE_SPECIFIC_ERROR     ),
00925      VALUE_CHAR_HR(ERROR_PROCESS_ABORTED            ),
00926      VALUE_CHAR_HR(ERROR_SERVICE_DEPENDENCY_FAIL    ),
00927      VALUE_CHAR_HR(ERROR_SERVICE_LOGON_FAILED       ),
00928      VALUE_CHAR_HR(ERROR_SERVICE_START_HANG         ),
00929      VALUE_CHAR_HR(ERROR_INVALID_SERVICE_LOCK       ),
00930      VALUE_CHAR_HR(ERROR_SERVICE_MARKED_FOR_DELETE  ),
00931      VALUE_CHAR_HR(ERROR_SERVICE_EXISTS             ),
00932      VALUE_CHAR_HR(ERROR_ALREADY_RUNNING_LKG        ),
00933      VALUE_CHAR_HR(ERROR_SERVICE_DEPENDENCY_DELETED ),
00934      VALUE_CHAR_HR(ERROR_BOOT_ALREADY_ACCEPTED      ),
00935      VALUE_CHAR_HR(ERROR_SERVICE_NEVER_STARTED      ),
00936      VALUE_CHAR_HR(ERROR_DUPLICATE_SERVICE_NAME     ),
00937      VALUE_CHAR_HR(ERROR_DIFFERENT_SERVICE_ACCOUNT  ),
00938      VALUE_CHAR_HR(ERROR_END_OF_MEDIA               ),
00939      VALUE_CHAR_HR(ERROR_FILEMARK_DETECTED          ),
00940      VALUE_CHAR_HR(ERROR_BEGINNING_OF_MEDIA         ),
00941      VALUE_CHAR_HR(ERROR_SETMARK_DETECTED           ),
00942      VALUE_CHAR_HR(ERROR_NO_DATA_DETECTED           ),
00943      VALUE_CHAR_HR(ERROR_PARTITION_FAILURE          ),
00944      VALUE_CHAR_HR(ERROR_INVALID_BLOCK_LENGTH       ),
00945      VALUE_CHAR_HR(ERROR_DEVICE_NOT_PARTITIONED     ),
00946      VALUE_CHAR_HR(ERROR_UNABLE_TO_LOCK_MEDIA       ),
00947      VALUE_CHAR_HR(ERROR_UNABLE_TO_UNLOAD_MEDIA     ),
00948      VALUE_CHAR_HR(ERROR_MEDIA_CHANGED              ),
00949      VALUE_CHAR_HR(ERROR_BUS_RESET                  ),
00950      VALUE_CHAR_HR(ERROR_NO_MEDIA_IN_DRIVE          ),
00951      VALUE_CHAR_HR(ERROR_NO_UNICODE_TRANSLATION     ),
00952      VALUE_CHAR_HR(ERROR_DLL_INIT_FAILED            ),
00953      VALUE_CHAR_HR(ERROR_SHUTDOWN_IN_PROGRESS       ),
00954      VALUE_CHAR_HR(ERROR_NO_SHUTDOWN_IN_PROGRESS    ),
00955      VALUE_CHAR_HR(ERROR_IO_DEVICE                  ),
00956      VALUE_CHAR_HR(ERROR_SERIAL_NO_DEVICE           ),
00957      VALUE_CHAR_HR(ERROR_IRQ_BUSY                   ),
00958      VALUE_CHAR_HR(ERROR_MORE_WRITES                ),
00959      VALUE_CHAR_HR(ERROR_COUNTER_TIMEOUT            ),
00960      VALUE_CHAR_HR(ERROR_FLOPPY_ID_MARK_NOT_FOUND   ),
00961      VALUE_CHAR_HR(ERROR_FLOPPY_WRONG_CYLINDER      ),
00962      VALUE_CHAR_HR(ERROR_FLOPPY_UNKNOWN_ERROR       ),
00963      VALUE_CHAR_HR(ERROR_FLOPPY_BAD_REGISTERS       ),
00964      VALUE_CHAR_HR(ERROR_DISK_RECALIBRATE_FAILED    ),
00965      VALUE_CHAR_HR(ERROR_DISK_OPERATION_FAILED      ),
00966      VALUE_CHAR_HR(ERROR_DISK_RESET_FAILED          ),
00967      VALUE_CHAR_HR(ERROR_EOM_OVERFLOW               ),
00968      VALUE_CHAR_HR(ERROR_NOT_ENOUGH_SERVER_MEMORY   ),
00969      VALUE_CHAR_HR(ERROR_POSSIBLE_DEADLOCK          ),
00970      VALUE_CHAR_HR(ERROR_MAPPED_ALIGNMENT           ),
00971      VALUE_CHAR_HR(ERROR_SET_POWER_STATE_VETOED     ),
00972      VALUE_CHAR_HR(ERROR_SET_POWER_STATE_FAILED     ),
00973      VALUE_CHAR_HR(ERROR_TOO_MANY_LINKS             ),
00974      VALUE_CHAR_HR(ERROR_OLD_WIN_VERSION            ),
00975      VALUE_CHAR_HR(ERROR_APP_WRONG_OS               ),
00976      VALUE_CHAR_HR(ERROR_SINGLE_INSTANCE_APP        ),
00977      VALUE_CHAR_HR(ERROR_RMODE_APP                  ),
00978      VALUE_CHAR_HR(ERROR_INVALID_DLL                ),
00979      VALUE_CHAR_HR(ERROR_NO_ASSOCIATION             ),
00980      VALUE_CHAR_HR(ERROR_DDE_FAIL                   ),
00981      VALUE_CHAR_HR(ERROR_DLL_NOT_FOUND              ),
00982      VALUE_CHAR_HR(ERROR_BAD_USERNAME               ),
00983      VALUE_CHAR_HR(ERROR_NOT_CONNECTED              ),
00984      VALUE_CHAR_HR(ERROR_OPEN_FILES                 ),
00985      VALUE_CHAR_HR(ERROR_ACTIVE_CONNECTIONS         ),
00986      VALUE_CHAR_HR(ERROR_DEVICE_IN_USE              ),
00987      VALUE_CHAR_HR(ERROR_BAD_DEVICE                 ),
00988      VALUE_CHAR_HR(ERROR_CONNECTION_UNAVAIL         ),
00989      VALUE_CHAR_HR(ERROR_DEVICE_ALREADY_REMEMBERED  ),
00990      VALUE_CHAR_HR(ERROR_NO_NET_OR_BAD_PATH         ),
00991      VALUE_CHAR_HR(ERROR_BAD_PROVIDER               ),
00992      VALUE_CHAR_HR(ERROR_CANNOT_OPEN_PROFILE        ),
00993      VALUE_CHAR_HR(ERROR_BAD_PROFILE                ),
00994      VALUE_CHAR_HR(ERROR_NOT_CONTAINER              ),
00995      VALUE_CHAR_HR(ERROR_EXTENDED_ERROR             ),
00996      VALUE_CHAR_HR(ERROR_INVALID_GROUPNAME          ),
00997      VALUE_CHAR_HR(ERROR_INVALID_COMPUTERNAME       ),
00998      VALUE_CHAR_HR(ERROR_INVALID_EVENTNAME          ),
00999      VALUE_CHAR_HR(ERROR_INVALID_DOMAINNAME         ),
01000      VALUE_CHAR_HR(ERROR_INVALID_SERVICENAME        ),
01001      VALUE_CHAR_HR(ERROR_INVALID_NETNAME            ),
01002      VALUE_CHAR_HR(ERROR_INVALID_SHARENAME          ),
01003      VALUE_CHAR_HR(ERROR_INVALID_PASSWORDNAME       ),
01004      VALUE_CHAR_HR(ERROR_INVALID_MESSAGENAME        ),
01005      VALUE_CHAR_HR(ERROR_INVALID_MESSAGEDEST        ),
01006      VALUE_CHAR_HR(ERROR_SESSION_CREDENTIAL_CONFLICT ),
01007      VALUE_CHAR_HR(ERROR_REMOTE_SESSION_LIMIT_EXCEEDED ),
01008      VALUE_CHAR_HR(ERROR_DUP_DOMAINNAME             ),
01009      VALUE_CHAR_HR(ERROR_NO_NETWORK                 ),
01010      VALUE_CHAR_HR(ERROR_CANCELLED                  ),
01011      VALUE_CHAR_HR(ERROR_USER_MAPPED_FILE           ),
01012      VALUE_CHAR_HR(ERROR_CONNECTION_REFUSED         ),
01013      VALUE_CHAR_HR(ERROR_GRACEFUL_DISCONNECT        ),
01014      VALUE_CHAR_HR(ERROR_ADDRESS_ALREADY_ASSOCIATED ),
01015      VALUE_CHAR_HR(ERROR_ADDRESS_NOT_ASSOCIATED     ),
01016      VALUE_CHAR_HR(ERROR_CONNECTION_INVALID         ),
01017      VALUE_CHAR_HR(ERROR_CONNECTION_ACTIVE          ),
01018      VALUE_CHAR_HR(ERROR_NETWORK_UNREACHABLE        ),
01019      VALUE_CHAR_HR(ERROR_HOST_UNREACHABLE           ),
01020      VALUE_CHAR_HR(ERROR_PROTOCOL_UNREACHABLE       ),
01021      VALUE_CHAR_HR(ERROR_PORT_UNREACHABLE           ),
01022      VALUE_CHAR_HR(ERROR_REQUEST_ABORTED            ),
01023      VALUE_CHAR_HR(ERROR_CONNECTION_ABORTED         ),
01024      VALUE_CHAR_HR(ERROR_RETRY                      ),
01025      VALUE_CHAR_HR(ERROR_CONNECTION_COUNT_LIMIT     ),
01026      VALUE_CHAR_HR(ERROR_LOGIN_TIME_RESTRICTION     ),
01027      VALUE_CHAR_HR(ERROR_LOGIN_WKSTA_RESTRICTION    ),
01028      VALUE_CHAR_HR(ERROR_INCORRECT_ADDRESS          ),
01029      VALUE_CHAR_HR(ERROR_ALREADY_REGISTERED         ),
01030      VALUE_CHAR_HR(ERROR_SERVICE_NOT_FOUND          ),
01031      VALUE_CHAR_HR(ERROR_NOT_AUTHENTICATED          ),
01032      VALUE_CHAR_HR(ERROR_NOT_LOGGED_ON              ),
01033      VALUE_CHAR_HR(ERROR_CONTINUE                   ),
01034      VALUE_CHAR_HR(ERROR_ALREADY_INITIALIZED        ),
01035      VALUE_CHAR_HR(ERROR_NO_MORE_DEVICES            ),
01036      VALUE_CHAR_HR(ERROR_NOT_ALL_ASSIGNED           ),
01037      VALUE_CHAR_HR(ERROR_SOME_NOT_MAPPED            ),
01038      VALUE_CHAR_HR(ERROR_NO_QUOTAS_FOR_ACCOUNT      ),
01039      VALUE_CHAR_HR(ERROR_LOCAL_USER_SESSION_KEY     ),
01040      VALUE_CHAR_HR(ERROR_NULL_LM_PASSWORD           ),
01041      VALUE_CHAR_HR(ERROR_UNKNOWN_REVISION           ),
01042      VALUE_CHAR_HR(ERROR_REVISION_MISMATCH          ),
01043      VALUE_CHAR_HR(ERROR_INVALID_OWNER              ),
01044      VALUE_CHAR_HR(ERROR_INVALID_PRIMARY_GROUP      ),
01045      VALUE_CHAR_HR(ERROR_NO_IMPERSONATION_TOKEN     ),
01046      VALUE_CHAR_HR(ERROR_CANT_DISABLE_MANDATORY     ),
01047      VALUE_CHAR_HR(ERROR_NO_LOGON_SERVERS           ),
01048
01049      VALUE_CHAR_HR(ERROR_NO_SUCH_LOGON_SESSION      ),
01050      VALUE_CHAR_HR(ERROR_NO_SUCH_PRIVILEGE          ),
01051      VALUE_CHAR_HR(ERROR_PRIVILEGE_NOT_HELD         ),
01052      VALUE_CHAR_HR(ERROR_INVALID_ACCOUNT_NAME       ),
01053      VALUE_CHAR_HR(ERROR_USER_EXISTS                ),
01054      VALUE_CHAR_HR(ERROR_NO_SUCH_USER               ),
01055      VALUE_CHAR_HR(ERROR_GROUP_EXISTS               ),
01056      VALUE_CHAR_HR(ERROR_NO_SUCH_GROUP              ),
01057      VALUE_CHAR_HR(ERROR_MEMBER_IN_GROUP            ),
01058      VALUE_CHAR_HR(ERROR_MEMBER_NOT_IN_GROUP        ),
01059      VALUE_CHAR_HR(ERROR_LAST_ADMIN                 ),
01060      VALUE_CHAR_HR(ERROR_WRONG_PASSWORD             ),
01061      VALUE_CHAR_HR(ERROR_ILL_FORMED_PASSWORD        ),
01062      VALUE_CHAR_HR(ERROR_PASSWORD_RESTRICTION       ),
01063      VALUE_CHAR_HR(ERROR_LOGON_FAILURE              ),
01064      VALUE_CHAR_HR(ERROR_ACCOUNT_RESTRICTION        ),
01065      VALUE_CHAR_HR(ERROR_INVALID_LOGON_HOURS        ),
01066      VALUE_CHAR_HR(ERROR_INVALID_WORKSTATION        ),
01067      VALUE_CHAR_HR(ERROR_PASSWORD_EXPIRED           ),
01068      VALUE_CHAR_HR(ERROR_ACCOUNT_DISABLED           ),
01069      VALUE_CHAR_HR(ERROR_NONE_MAPPED                ),
01070      VALUE_CHAR_HR(ERROR_TOO_MANY_LUIDS_REQUESTED   ),
01071      VALUE_CHAR_HR(ERROR_LUIDS_EXHAUSTED            ),
01072      VALUE_CHAR_HR(ERROR_INVALID_SUB_AUTHORITY      ),
01073      VALUE_CHAR_HR(ERROR_INVALID_ACL                ),
01074      VALUE_CHAR_HR(ERROR_INVALID_SID                ),
01075      VALUE_CHAR_HR(ERROR_INVALID_SECURITY_DESCR     ),
01076      VALUE_CHAR_HR(ERROR_BAD_INHERITANCE_ACL        ),
01077      VALUE_CHAR_HR(ERROR_SERVER_DISABLED            ),
01078      VALUE_CHAR_HR(ERROR_SERVER_NOT_DISABLED        ),
01079      VALUE_CHAR_HR(ERROR_INVALID_ID_AUTHORITY       ),
01080      VALUE_CHAR_HR(ERROR_ALLOTTED_SPACE_EXCEEDED    ),
01081      VALUE_CHAR_HR(ERROR_INVALID_GROUP_ATTRIBUTES   ),
01082      VALUE_CHAR_HR(ERROR_BAD_IMPERSONATION_LEVEL    ),
01083      VALUE_CHAR_HR(ERROR_CANT_OPEN_ANONYMOUS        ),
01084      VALUE_CHAR_HR(ERROR_BAD_VALIDATION_CLASS       ),
01085      VALUE_CHAR_HR(ERROR_BAD_TOKEN_TYPE             ),
01086      VALUE_CHAR_HR(ERROR_NO_SECURITY_ON_OBJECT      ),
01087      VALUE_CHAR_HR(ERROR_CANT_ACCESS_DOMAIN_INFO    ),
01088      VALUE_CHAR_HR(ERROR_INVALID_SERVER_STATE       ),
01089      VALUE_CHAR_HR(ERROR_INVALID_DOMAIN_STATE       ),
01090      VALUE_CHAR_HR(ERROR_INVALID_DOMAIN_ROLE        ),
01091      VALUE_CHAR_HR(ERROR_NO_SUCH_DOMAIN             ),
01092      VALUE_CHAR_HR(ERROR_DOMAIN_EXISTS              ),
01093      VALUE_CHAR_HR(ERROR_DOMAIN_LIMIT_EXCEEDED      ),
01094      VALUE_CHAR_HR(ERROR_INTERNAL_DB_CORRUPTION     ),
01095      VALUE_CHAR_HR(ERROR_INTERNAL_ERROR             ),
01096      VALUE_CHAR_HR(ERROR_GENERIC_NOT_MAPPED         ),
01097      VALUE_CHAR_HR(ERROR_BAD_DESCRIPTOR_FORMAT      ),
01098      VALUE_CHAR_HR(ERROR_NOT_LOGON_PROCESS          ),
01099      VALUE_CHAR_HR(ERROR_LOGON_SESSION_EXISTS       ),
01100      VALUE_CHAR_HR(ERROR_NO_SUCH_PACKAGE            ),
01101      VALUE_CHAR_HR(ERROR_BAD_LOGON_SESSION_STATE    ),
01102      VALUE_CHAR_HR(ERROR_LOGON_SESSION_COLLISION    ),
01103      VALUE_CHAR_HR(ERROR_INVALID_LOGON_TYPE         ),
01104      VALUE_CHAR_HR(ERROR_CANNOT_IMPERSONATE         ),
01105      VALUE_CHAR_HR(ERROR_RXACT_INVALID_STATE        ),
01106      VALUE_CHAR_HR(ERROR_RXACT_COMMIT_FAILURE       ),
01107      VALUE_CHAR_HR(ERROR_SPECIAL_ACCOUNT            ),
01108      VALUE_CHAR_HR(ERROR_SPECIAL_GROUP              ),
01109      VALUE_CHAR_HR(ERROR_SPECIAL_USER               ),
01110      VALUE_CHAR_HR(ERROR_MEMBERS_PRIMARY_GROUP      ),
01111      VALUE_CHAR_HR(ERROR_TOKEN_ALREADY_IN_USE       ),
01112      VALUE_CHAR_HR(ERROR_NO_SUCH_ALIAS              ),
01113      VALUE_CHAR_HR(ERROR_MEMBER_NOT_IN_ALIAS        ),
01114      VALUE_CHAR_HR(ERROR_MEMBER_IN_ALIAS            ),
01115      VALUE_CHAR_HR(ERROR_ALIAS_EXISTS               ),
01116      VALUE_CHAR_HR(ERROR_LOGON_NOT_GRANTED          ),
01117      VALUE_CHAR_HR(ERROR_TOO_MANY_SECRETS           ),
01118      VALUE_CHAR_HR(ERROR_SECRET_TOO_LONG            ),
01119      VALUE_CHAR_HR(ERROR_INTERNAL_DB_ERROR          ),
01120      VALUE_CHAR_HR(ERROR_TOO_MANY_CONTEXT_IDS       ),
01121      VALUE_CHAR_HR(ERROR_LOGON_TYPE_NOT_GRANTED     ),
01122      VALUE_CHAR_HR(ERROR_NT_CROSS_ENCRYPTION_REQUIRED ),
01123      VALUE_CHAR_HR(ERROR_NO_SUCH_MEMBER             ),
01124      VALUE_CHAR_HR(ERROR_INVALID_MEMBER             ),
01125      VALUE_CHAR_HR(ERROR_TOO_MANY_SIDS              ),
01126      VALUE_CHAR_HR(ERROR_LM_CROSS_ENCRYPTION_REQUIRED ),
01127      VALUE_CHAR_HR(ERROR_NO_INHERITANCE             ),
01128      VALUE_CHAR_HR(ERROR_FILE_CORRUPT               ),
01129      VALUE_CHAR_HR(ERROR_DISK_CORRUPT               ),
01130      VALUE_CHAR_HR(ERROR_NO_USER_SESSION_KEY        ),
01131      VALUE_CHAR_HR(ERROR_LICENSE_QUOTA_EXCEEDED     ),
01132      VALUE_CHAR_HR(ERROR_INVALID_WINDOW_HANDLE      ),
01133      VALUE_CHAR_HR(ERROR_INVALID_MENU_HANDLE        ),
01134      VALUE_CHAR_HR(ERROR_INVALID_CURSOR_HANDLE      ),
01135      VALUE_CHAR_HR(ERROR_INVALID_ACCEL_HANDLE       ),
01136      VALUE_CHAR_HR(ERROR_INVALID_HOOK_HANDLE        ),
01137      VALUE_CHAR_HR(ERROR_INVALID_DWP_HANDLE         ),
01138      VALUE_CHAR_HR(ERROR_TLW_WITH_WSCHILD           ),
01139      VALUE_CHAR_HR(ERROR_CANNOT_FIND_WND_CLASS      ),
01140      VALUE_CHAR_HR(ERROR_WINDOW_OF_OTHER_THREAD     ),
01141      VALUE_CHAR_HR(ERROR_HOTKEY_ALREADY_REGISTERED  ),
01142      VALUE_CHAR_HR(ERROR_CLASS_ALREADY_EXISTS       ),
01143      VALUE_CHAR_HR(ERROR_CLASS_DOES_NOT_EXIST       ),
01144      VALUE_CHAR_HR(ERROR_CLASS_HAS_WINDOWS          ),
01145      VALUE_CHAR_HR(ERROR_INVALID_INDEX              ),
01146      VALUE_CHAR_HR(ERROR_INVALID_ICON_HANDLE        ),
01147      VALUE_CHAR_HR(ERROR_PRIVATE_DIALOG_INDEX       ),
01148      VALUE_CHAR_HR(ERROR_LISTBOX_ID_NOT_FOUND       ),
01149      VALUE_CHAR_HR(ERROR_NO_WILDCARD_CHARACTERS     ),
01150      VALUE_CHAR_HR(ERROR_CLIPBOARD_NOT_OPEN         ),
01151      VALUE_CHAR_HR(ERROR_HOTKEY_NOT_REGISTERED      ),
01152      VALUE_CHAR_HR(ERROR_WINDOW_NOT_DIALOG          ),
01153      VALUE_CHAR_HR(ERROR_CONTROL_ID_NOT_FOUND       ),
01154      VALUE_CHAR_HR(ERROR_INVALID_COMBOBOX_MESSAGE   ),
01155      VALUE_CHAR_HR(ERROR_WINDOW_NOT_COMBOBOX        ),
01156      VALUE_CHAR_HR(ERROR_INVALID_EDIT_HEIGHT        ),
01157      VALUE_CHAR_HR(ERROR_DC_NOT_FOUND               ),
01158      VALUE_CHAR_HR(ERROR_INVALID_HOOK_FILTER        ),
01159      VALUE_CHAR_HR(ERROR_INVALID_FILTER_PROC        ),
01160      VALUE_CHAR_HR(ERROR_HOOK_NEEDS_HMOD            ),
01161      VALUE_CHAR_HR(ERROR_GLOBAL_ONLY_HOOK           ),
01162      VALUE_CHAR_HR(ERROR_JOURNAL_HOOK_SET           ),
01163      VALUE_CHAR_HR(ERROR_HOOK_NOT_INSTALLED         ),
01164      VALUE_CHAR_HR(ERROR_INVALID_LB_MESSAGE         ),
01165      VALUE_CHAR_HR(ERROR_SETCOUNT_ON_BAD_LB         ),
01166      VALUE_CHAR_HR(ERROR_LB_WITHOUT_TABSTOPS        ),
01167      VALUE_CHAR_HR(ERROR_DESTROY_OBJECT_OF_OTHER_THREAD ),
01168      VALUE_CHAR_HR(ERROR_CHILD_WINDOW_MENU          ),
01169      VALUE_CHAR_HR(ERROR_NO_SYSTEM_MENU             ),
01170      VALUE_CHAR_HR(ERROR_INVALID_MSGBOX_STYLE       ),
01171      VALUE_CHAR_HR(ERROR_INVALID_SPI_VALUE          ),
01172      VALUE_CHAR_HR(ERROR_SCREEN_ALREADY_LOCKED      ),
01173      VALUE_CHAR_HR(ERROR_HWNDS_HAVE_DIFF_PARENT     ),
01174      VALUE_CHAR_HR(ERROR_NOT_CHILD_WINDOW           ),
01175      VALUE_CHAR_HR(ERROR_INVALID_GW_COMMAND         ),
01176      VALUE_CHAR_HR(ERROR_INVALID_THREAD_ID          ),
01177      VALUE_CHAR_HR(ERROR_NON_MDICHILD_WINDOW        ),
01178      VALUE_CHAR_HR(ERROR_POPUP_ALREADY_ACTIVE       ),
01179      VALUE_CHAR_HR(ERROR_NO_SCROLLBARS              ),
01180      VALUE_CHAR_HR(ERROR_INVALID_SCROLLBAR_RANGE    ),
01181      VALUE_CHAR_HR(ERROR_INVALID_SHOWWIN_COMMAND    ),
01182      VALUE_CHAR_HR(ERROR_NO_SYSTEM_RESOURCES        ),
01183      VALUE_CHAR_HR(ERROR_NONPAGED_SYSTEM_RESOURCES  ),
01184      VALUE_CHAR_HR(ERROR_PAGED_SYSTEM_RESOURCES     ),
01185      VALUE_CHAR_HR(ERROR_WORKING_SET_QUOTA          ),
01186      VALUE_CHAR_HR(ERROR_PAGEFILE_QUOTA             ),
01187      VALUE_CHAR_HR(ERROR_COMMITMENT_LIMIT           ),
01188      VALUE_CHAR_HR(ERROR_MENU_ITEM_NOT_FOUND        ),
01189      VALUE_CHAR_HR(ERROR_INVALID_KEYBOARD_HANDLE    ),
01190      VALUE_CHAR_HR(ERROR_HOOK_TYPE_NOT_ALLOWED      ),
01191      VALUE_CHAR_HR(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION ),
01192      VALUE_CHAR_HR(ERROR_TIMEOUT                    ),
01193      VALUE_CHAR_HR(ERROR_EVENTLOG_FILE_CORRUPT      ),
01194      VALUE_CHAR_HR(ERROR_EVENTLOG_CANT_START        ),
01195      VALUE_CHAR_HR(ERROR_LOG_FILE_FULL              ),
01196      VALUE_CHAR_HR(ERROR_EVENTLOG_FILE_CHANGED      ),
01197
01198
01199      VALUE_CHAR_HR(RPC_S_INVALID_STRING_BINDING     ),
01200      VALUE_CHAR_HR(RPC_S_WRONG_KIND_OF_BINDING      ),
01201      VALUE_CHAR_HR(RPC_S_INVALID_BINDING            ),
01202      VALUE_CHAR_HR(RPC_S_PROTSEQ_NOT_SUPPORTED      ),
01203      VALUE_CHAR_HR(RPC_S_INVALID_RPC_PROTSEQ        ),
01204      VALUE_CHAR_HR(RPC_S_INVALID_STRING_UUID        ),
01205      VALUE_CHAR_HR(RPC_S_INVALID_ENDPOINT_FORMAT    ),
01206      VALUE_CHAR_HR(RPC_S_INVALID_NET_ADDR           ),
01207      VALUE_CHAR_HR(RPC_S_NO_ENDPOINT_FOUND          ),
01208      VALUE_CHAR_HR(RPC_S_INVALID_TIMEOUT            ),
01209      VALUE_CHAR_HR(RPC_S_OBJECT_NOT_FOUND           ),
01210      VALUE_CHAR_HR(RPC_S_ALREADY_REGISTERED         ),
01211      VALUE_CHAR_HR(RPC_S_TYPE_ALREADY_REGISTERED    ),
01212      VALUE_CHAR_HR(RPC_S_ALREADY_LISTENING          ),
01213      VALUE_CHAR_HR(RPC_S_NO_PROTSEQS_REGISTERED     ),
01214      VALUE_CHAR_HR(RPC_S_NOT_LISTENING              ),
01215      VALUE_CHAR_HR(RPC_S_UNKNOWN_MGR_TYPE           ),
01216      VALUE_CHAR_HR(RPC_S_UNKNOWN_IF                 ),
01217      VALUE_CHAR_HR(RPC_S_NO_BINDINGS                ),
01218      VALUE_CHAR_HR(RPC_S_NO_PROTSEQS                ),
01219      VALUE_CHAR_HR(RPC_S_CANT_CREATE_ENDPOINT       ),
01220      VALUE_CHAR_HR(RPC_S_OUT_OF_RESOURCES           ),
01221      VALUE_CHAR_HR(RPC_S_SERVER_UNAVAILABLE         ),
01222      VALUE_CHAR_HR(RPC_S_SERVER_TOO_BUSY            ),
01223      VALUE_CHAR_HR(RPC_S_INVALID_NETWORK_OPTIONS    ),
01224      VALUE_CHAR_HR(RPC_S_NO_CALL_ACTIVE             ),
01225      VALUE_CHAR_HR(RPC_S_CALL_FAILED                ),
01226      VALUE_CHAR_HR(RPC_S_CALL_FAILED_DNE            ),
01227      VALUE_CHAR_HR(RPC_S_PROTOCOL_ERROR             ),
01228      VALUE_CHAR_HR(RPC_S_UNSUPPORTED_TRANS_SYN      ),
01229      VALUE_CHAR_HR(RPC_S_UNSUPPORTED_TYPE           ),
01230      VALUE_CHAR_HR(RPC_S_INVALID_TAG                ),
01231      VALUE_CHAR_HR(RPC_S_INVALID_BOUND              ),
01232      VALUE_CHAR_HR(RPC_S_NO_ENTRY_NAME              ),
01233      VALUE_CHAR_HR(RPC_S_INVALID_NAME_SYNTAX        ),
01234      VALUE_CHAR_HR(RPC_S_UNSUPPORTED_NAME_SYNTAX    ),
01235      VALUE_CHAR_HR(RPC_S_UUID_NO_ADDRESS            ),
01236      VALUE_CHAR_HR(RPC_S_DUPLICATE_ENDPOINT         ),
01237      VALUE_CHAR_HR(RPC_S_UNKNOWN_AUTHN_TYPE         ),
01238      VALUE_CHAR_HR(RPC_S_MAX_CALLS_TOO_SMALL        ),
01239      VALUE_CHAR_HR(RPC_S_STRING_TOO_LONG            ),
01240      VALUE_CHAR_HR(RPC_S_PROTSEQ_NOT_FOUND          ),
01241      VALUE_CHAR_HR(RPC_S_PROCNUM_OUT_OF_RANGE       ),
01242      VALUE_CHAR_HR(RPC_S_BINDING_HAS_NO_AUTH        ),
01243      VALUE_CHAR_HR(RPC_S_UNKNOWN_AUTHN_SERVICE      ),
01244      VALUE_CHAR_HR(RPC_S_UNKNOWN_AUTHN_LEVEL        ),
01245      VALUE_CHAR_HR(RPC_S_INVALID_AUTH_IDENTITY      ),
01246      VALUE_CHAR_HR(RPC_S_UNKNOWN_AUTHZ_SERVICE      ),
01247      VALUE_CHAR_HR(EPT_S_INVALID_ENTRY              ),
01248      VALUE_CHAR_HR(EPT_S_CANT_PERFORM_OP            ),
01249      VALUE_CHAR_HR(EPT_S_NOT_REGISTERED             ),
01250      VALUE_CHAR_HR(RPC_S_NOTHING_TO_EXPORT          ),
01251      VALUE_CHAR_HR(RPC_S_INCOMPLETE_NAME            ),
01252      VALUE_CHAR_HR(RPC_S_INVALID_VERS_OPTION        ),
01253      VALUE_CHAR_HR(RPC_S_NO_MORE_MEMBERS            ),
01254      VALUE_CHAR_HR(RPC_S_NOT_ALL_OBJS_UNEXPORTED    ),
01255      VALUE_CHAR_HR(RPC_S_INTERFACE_NOT_FOUND        ),
01256      VALUE_CHAR_HR(RPC_S_ENTRY_ALREADY_EXISTS       ),
01257      VALUE_CHAR_HR(RPC_S_ENTRY_NOT_FOUND            ),
01258      VALUE_CHAR_HR(RPC_S_NAME_SERVICE_UNAVAILABLE   ),
01259      VALUE_CHAR_HR(RPC_S_INVALID_NAF_ID             ),
01260      VALUE_CHAR_HR(RPC_S_CANNOT_SUPPORT             ),
01261      VALUE_CHAR_HR(RPC_S_NO_CONTEXT_AVAILABLE       ),
01262      VALUE_CHAR_HR(RPC_S_INTERNAL_ERROR             ),
01263      VALUE_CHAR_HR(RPC_S_ZERO_DIVIDE                ),
01264      VALUE_CHAR_HR(RPC_S_ADDRESS_ERROR              ),
01265      VALUE_CHAR_HR(RPC_S_FP_DIV_ZERO                ),
01266      VALUE_CHAR_HR(RPC_S_FP_UNDERFLOW               ),
01267      VALUE_CHAR_HR(RPC_S_FP_OVERFLOW                ),
01268      VALUE_CHAR_HR(RPC_X_NO_MORE_ENTRIES            ),
01269      VALUE_CHAR_HR(RPC_X_SS_CHAR_TRANS_OPEN_FAIL    ),
01270      VALUE_CHAR_HR(RPC_X_SS_CHAR_TRANS_SHORT_FILE   ),
01271      VALUE_CHAR_HR(RPC_X_SS_IN_NULL_CONTEXT         ),
01272      VALUE_CHAR_HR(RPC_X_SS_CONTEXT_DAMAGED         ),
01273      VALUE_CHAR_HR(RPC_X_SS_HANDLES_MISMATCH        ),
01274      VALUE_CHAR_HR(RPC_X_SS_CANNOT_GET_CALL_HANDLE  ),
01275      VALUE_CHAR_HR(RPC_X_NULL_REF_POINTER           ),
01276      VALUE_CHAR_HR(RPC_X_ENUM_VALUE_OUT_OF_RANGE    ),
01277      VALUE_CHAR_HR(RPC_X_BYTE_COUNT_TOO_SMALL       ),
01278      VALUE_CHAR_HR(RPC_X_BAD_STUB_DATA              ),
01279
01280      VALUE_CHAR_HR(ERROR_INVALID_USER_BUFFER        ),
01281      VALUE_CHAR_HR(ERROR_UNRECOGNIZED_MEDIA         ),
01282      VALUE_CHAR_HR(ERROR_NO_TRUST_LSA_SECRET        ),
01283      VALUE_CHAR_HR(ERROR_NO_TRUST_SAM_ACCOUNT       ),
01284      VALUE_CHAR_HR(ERROR_TRUSTED_DOMAIN_FAILURE     ),
01285      VALUE_CHAR_HR(ERROR_TRUSTED_RELATIONSHIP_FAILURE ),
01286      VALUE_CHAR_HR(ERROR_TRUST_FAILURE              ),
01287      VALUE_CHAR_HR(RPC_S_CALL_IN_PROGRESS           ),
01288      VALUE_CHAR_HR(ERROR_NETLOGON_NOT_STARTED       ),
01289      VALUE_CHAR_HR(ERROR_ACCOUNT_EXPIRED            ),
01290      VALUE_CHAR_HR(ERROR_REDIRECTOR_HAS_OPEN_HANDLES ),
01291      VALUE_CHAR_HR(ERROR_PRINTER_DRIVER_ALREADY_INSTALLED ),
01292      VALUE_CHAR_HR(ERROR_UNKNOWN_PORT               ),
01293      VALUE_CHAR_HR(ERROR_UNKNOWN_PRINTER_DRIVER     ),
01294      VALUE_CHAR_HR(ERROR_UNKNOWN_PRINTPROCESSOR     ),
01295      VALUE_CHAR_HR(ERROR_INVALID_SEPARATOR_FILE     ),
01296      VALUE_CHAR_HR(ERROR_INVALID_PRIORITY           ),
01297      VALUE_CHAR_HR(ERROR_INVALID_PRINTER_NAME       ),
01298      VALUE_CHAR_HR(ERROR_PRINTER_ALREADY_EXISTS     ),
01299      VALUE_CHAR_HR(ERROR_INVALID_PRINTER_COMMAND    ),
01300      VALUE_CHAR_HR(ERROR_INVALID_DATATYPE           ),
01301      VALUE_CHAR_HR(ERROR_INVALID_ENVIRONMENT        ),
01302      VALUE_CHAR_HR(RPC_S_NO_MORE_BINDINGS           ),
01303      VALUE_CHAR_HR(ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT ),
01304      VALUE_CHAR_HR(ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT ),
01305      VALUE_CHAR_HR(ERROR_NOLOGON_SERVER_TRUST_ACCOUNT ),
01306      VALUE_CHAR_HR(ERROR_DOMAIN_TRUST_INCONSISTENT  ),
01307      VALUE_CHAR_HR(ERROR_SERVER_HAS_OPEN_HANDLES    ),
01308      VALUE_CHAR_HR(ERROR_RESOURCE_DATA_NOT_FOUND    ),
01309      VALUE_CHAR_HR(ERROR_RESOURCE_TYPE_NOT_FOUND    ),
01310      VALUE_CHAR_HR(ERROR_RESOURCE_NAME_NOT_FOUND    ),
01311      VALUE_CHAR_HR(ERROR_RESOURCE_LANG_NOT_FOUND    ),
01312      VALUE_CHAR_HR(ERROR_NOT_ENOUGH_QUOTA           ),
01313      VALUE_CHAR_HR(RPC_S_NO_INTERFACES              ),
01314      VALUE_CHAR_HR(RPC_S_CALL_CANCELLED             ),
01315      VALUE_CHAR_HR(RPC_S_BINDING_INCOMPLETE         ),
01316      VALUE_CHAR_HR(RPC_S_COMM_FAILURE               ),
01317      VALUE_CHAR_HR(RPC_S_UNSUPPORTED_AUTHN_LEVEL    ),
01318      VALUE_CHAR_HR(RPC_S_NO_PRINC_NAME              ),
01319      VALUE_CHAR_HR(RPC_S_NOT_RPC_ERROR              ),
01320      VALUE_CHAR_HR(RPC_S_UUID_LOCAL_ONLY            ),
01321      VALUE_CHAR_HR(RPC_S_SEC_PKG_ERROR              ),
01322      VALUE_CHAR_HR(RPC_S_NOT_CANCELLED              ),
01323      VALUE_CHAR_HR(RPC_X_INVALID_ES_ACTION          ),
01324      VALUE_CHAR_HR(RPC_X_WRONG_ES_VERSION           ),
01325      VALUE_CHAR_HR(RPC_X_WRONG_STUB_VERSION         ),
01326      VALUE_CHAR_HR(RPC_X_INVALID_PIPE_OBJECT        ),
01327      VALUE_CHAR_HR(RPC_X_INVALID_PIPE_OPERATION     ),
01328      VALUE_CHAR_HR(RPC_X_WRONG_PIPE_VERSION         ),
01329      VALUE_CHAR_HR(RPC_S_GROUP_MEMBER_NOT_FOUND     ),
01330      VALUE_CHAR_HR(EPT_S_CANT_CREATE                ),
01331      VALUE_CHAR_HR(RPC_S_INVALID_OBJECT             ),
01332      VALUE_CHAR_HR(ERROR_INVALID_TIME               ),
01333      VALUE_CHAR_HR(ERROR_INVALID_FORM_NAME          ),
01334      VALUE_CHAR_HR(ERROR_INVALID_FORM_SIZE          ),
01335      VALUE_CHAR_HR(ERROR_ALREADY_WAITING            ),
01336      VALUE_CHAR_HR(ERROR_PRINTER_DELETED            ),
01337      VALUE_CHAR_HR(ERROR_INVALID_PRINTER_STATE      ),
01338      VALUE_CHAR_HR(ERROR_PASSWORD_MUST_CHANGE       ),
01339      VALUE_CHAR_HR(ERROR_DOMAIN_CONTROLLER_NOT_FOUND ),
01340      VALUE_CHAR_HR(ERROR_ACCOUNT_LOCKED_OUT         ),
01341      VALUE_CHAR_HR(OR_INVALID_OXID                  ),
01342      VALUE_CHAR_HR(OR_INVALID_OID                   ),
01343      VALUE_CHAR_HR(OR_INVALID_SET                   ),
01344      VALUE_CHAR_HR(RPC_S_SEND_INCOMPLETE            ),
01345      VALUE_CHAR_HR(ERROR_NO_BROWSER_SERVERS_FOUND   ),
01346
01347      VALUE_CHAR_HR(ERROR_INVALID_PIXEL_FORMAT       ),
01348      VALUE_CHAR_HR(ERROR_BAD_DRIVER                 ),
01349      VALUE_CHAR_HR(ERROR_INVALID_WINDOW_STYLE       ),
01350      VALUE_CHAR_HR(ERROR_METAFILE_NOT_SUPPORTED     ),
01351      VALUE_CHAR_HR(ERROR_TRANSFORM_NOT_SUPPORTED    ),
01352      VALUE_CHAR_HR(ERROR_CLIPPING_NOT_SUPPORTED     ),
01353      VALUE_CHAR_HR(ERROR_UNKNOWN_PRINT_MONITOR      ),
01354      VALUE_CHAR_HR(ERROR_PRINTER_DRIVER_IN_USE      ),
01355      VALUE_CHAR_HR(ERROR_SPOOL_FILE_NOT_FOUND       ),
01356      VALUE_CHAR_HR(ERROR_SPL_NO_STARTDOC            ),
01357      VALUE_CHAR_HR(ERROR_SPL_NO_ADDJOB              ),
01358      VALUE_CHAR_HR(ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED ),
01359      VALUE_CHAR_HR(ERROR_PRINT_MONITOR_ALREADY_INSTALLED ),
01360      VALUE_CHAR_HR(ERROR_INVALID_PRINT_MONITOR      ),
01361      VALUE_CHAR_HR(ERROR_PRINT_MONITOR_IN_USE       ),
01362      VALUE_CHAR_HR(ERROR_PRINTER_HAS_JOBS_QUEUED    ),
01363      VALUE_CHAR_HR(ERROR_SUCCESS_REBOOT_REQUIRED    ),
01364      VALUE_CHAR_HR(ERROR_SUCCESS_RESTART_REQUIRED   ),
01365      VALUE_CHAR_HR(ERROR_WINS_INTERNAL              ),
01366      VALUE_CHAR_HR(ERROR_CAN_NOT_DEL_LOCAL_WINS     ),
01367      VALUE_CHAR_HR(ERROR_STATIC_INIT                ),
01368      VALUE_CHAR_HR(ERROR_INC_BACKUP                 ),
01369      VALUE_CHAR_HR(ERROR_FULL_BACKUP                ),
01370      VALUE_CHAR_HR(ERROR_REC_NON_EXISTENT           ),
01371      VALUE_CHAR_HR(ERROR_RPL_NOT_ALLOWED            ),
01372
01373      VALUE_CHAR(CO_E_INIT_SHARED_ALLOCATOR       ),
01374      VALUE_CHAR(CO_E_INIT_MEMORY_ALLOCATOR       ),
01375      VALUE_CHAR(CO_E_INIT_CLASS_CACHE            ),
01376      VALUE_CHAR(CO_E_INIT_RPC_CHANNEL            ),
01377      VALUE_CHAR(OLE_E_OLEVERB                    ),
01378      VALUE_CHAR(OLE_E_ADVF                       ),
01379      VALUE_CHAR(OLE_E_ENUM_NOMORE                ),
01380      VALUE_CHAR(OLE_E_ADVISENOTSUPPORTED         ),
01381      VALUE_CHAR(OLE_E_NOCONNECTION               ),
01382      VALUE_CHAR(OLE_E_NOTRUNNING                 ),
01383      VALUE_CHAR(OLE_E_NOCACHE                    ),
01384      VALUE_CHAR(OLE_E_BLANK                      ),
01385      VALUE_CHAR(OLE_E_CLASSDIFF                  ),
01386      VALUE_CHAR(OLE_E_CANT_GETMONIKER            ),
01387      VALUE_CHAR(OLE_E_CANT_BINDTOSOURCE          ),
01388      VALUE_CHAR(OLE_E_STATIC                     ),
01389      VALUE_CHAR(OLE_E_PROMPTSAVECANCELLED        ),
01390      VALUE_CHAR(OLE_E_INVALIDRECT                ),
01391      VALUE_CHAR(OLE_E_WRONGCOMPOBJ               ),
01392      VALUE_CHAR(OLE_E_INVALIDHWND                ),
01393      VALUE_CHAR(OLE_E_NOT_INPLACEACTIVE          ),
01394      VALUE_CHAR(OLE_E_CANTCONVERT                ),
01395      VALUE_CHAR(OLE_E_NOSTORAGE                  ),
01396      VALUE_CHAR(DRAGDROP_E_NOTREGISTERED         ),
01397      VALUE_CHAR(DRAGDROP_E_ALREADYREGISTERED     ),
01398      VALUE_CHAR(DRAGDROP_E_INVALIDHWND           ),
01399      VALUE_CHAR(CLASS_E_CLASSNOTAVAILABLE        ),
01400      VALUE_CHAR(REGDB_E_READREGDB                ),
01401      VALUE_CHAR(REGDB_E_WRITEREGDB               ),
01402      VALUE_CHAR(REGDB_E_KEYMISSING               ),
01403      VALUE_CHAR(REGDB_E_INVALIDVALUE             ),
01404      VALUE_CHAR(REGDB_E_IIDNOTREG                ),
01405      VALUE_CHAR(CACHE_E_NOCACHE_UPDATED          ),
01406      VALUE_CHAR(OLEOBJ_E_NOVERBS                 ),
01407      VALUE_CHAR(OLEOBJ_E_INVALIDVERB             ),
01408      VALUE_CHAR(CLIPBRD_E_CANT_OPEN              ),
01409      VALUE_CHAR(CLIPBRD_E_CANT_EMPTY             ),
01410      VALUE_CHAR(CLIPBRD_E_CANT_SET               ),
01411      VALUE_CHAR(CLIPBRD_E_BAD_DATA               ),
01412      VALUE_CHAR(CLIPBRD_E_CANT_CLOSE             ),
01413      VALUE_CHAR(OLE_S_USEREG                     ),
01414      VALUE_CHAR(OLE_S_STATIC                     ),
01415      VALUE_CHAR(DRAGDROP_S_DROP                  ),
01416      VALUE_CHAR(DRAGDROP_S_CANCEL                ),
01417      VALUE_CHAR(DRAGDROP_S_USEDEFAULTCURSORS     ),
01418      VALUE_CHAR(MK_S_REDUCED_TO_SELF             ),
01419      VALUE_CHAR(MK_S_ME                          ),
01420      VALUE_CHAR(MK_S_HIM                         ),
01421      VALUE_CHAR(MK_S_US                          ),
01422      VALUE_CHAR(MK_S_MONIKERALREADYREGISTERED    ),
01423      VALUE_CHAR(CO_E_CLASS_CREATE_FAILED         ),
01424      VALUE_CHAR(CO_E_SCM_ERROR                   ),
01425      VALUE_CHAR(CO_E_SCM_RPC_FAILURE             ),
01426      VALUE_CHAR(CO_E_BAD_PATH                    ),
01427      VALUE_CHAR(CO_E_SERVER_EXEC_FAILURE         ),
01428      VALUE_CHAR(CO_E_OBJSRV_RPC_FAILURE          ),
01429      VALUE_CHAR(MK_E_NO_NORMALIZED               ),
01430      VALUE_CHAR(CO_E_SERVER_STOPPING             ),
01431      VALUE_CHAR(MEM_E_INVALID_ROOT               ),
01432      VALUE_CHAR(MEM_E_INVALID_LINK               ),
01433      VALUE_CHAR(MEM_E_INVALID_SIZE               ),
01434
01435      VALUE_CHAR(TYPE_E_BUFFERTOOSMALL            ),
01436      VALUE_CHAR(TYPE_E_INVDATAREAD               ),
01437      VALUE_CHAR(TYPE_E_UNSUPFORMAT               ),
01438      VALUE_CHAR(TYPE_E_REGISTRYACCESS            ),
01439      VALUE_CHAR(TYPE_E_LIBNOTREGISTERED          ),
01440      VALUE_CHAR(TYPE_E_UNDEFINEDTYPE             ),
01441      VALUE_CHAR(TYPE_E_QUALIFIEDNAMEDISALLOWED   ),
01442      VALUE_CHAR(TYPE_E_INVALIDSTATE              ),
01443      VALUE_CHAR(TYPE_E_WRONGTYPEKIND             ),
01444      VALUE_CHAR(TYPE_E_ELEMENTNOTFOUND           ),
01445      VALUE_CHAR(TYPE_E_AMBIGUOUSNAME             ),
01446      VALUE_CHAR(TYPE_E_NAMECONFLICT              ),
01447      VALUE_CHAR(TYPE_E_UNKNOWNLCID               ),
01448      VALUE_CHAR(TYPE_E_DLLFUNCTIONNOTFOUND       ),
01449      VALUE_CHAR(TYPE_E_BADMODULEKIND             ),
01450      VALUE_CHAR(TYPE_E_SIZETOOBIG                ),
01451      VALUE_CHAR(TYPE_E_DUPLICATEID               ),
01452      VALUE_CHAR(TYPE_E_INVALIDID                 ),
01453      VALUE_CHAR(TYPE_E_TYPEMISMATCH              ),
01454      VALUE_CHAR(TYPE_E_OUTOFBOUNDS               ),
01455      VALUE_CHAR(TYPE_E_IOERROR                   ),
01456      VALUE_CHAR(TYPE_E_CANTCREATETMPFILE         ),
01457      VALUE_CHAR(TYPE_E_CANTLOADLIBRARY           ),
01458      VALUE_CHAR(TYPE_E_INCONSISTENTPROPFUNCS     ),
01459      VALUE_CHAR(TYPE_E_CIRCULARTYPE              ),
01460      VALUE_CHAR(RPC_E_CALL_REJECTED              ),
01461      VALUE_CHAR(RPC_E_CALL_CANCELED              ),
01462      VALUE_CHAR(RPC_E_CANTPOST_INSENDCALL        ),
01463      VALUE_CHAR(RPC_E_CANTCALLOUT_INASYNCCALL    ),
01464      VALUE_CHAR(RPC_E_CANTCALLOUT_INEXTERNALCALL ),
01465      VALUE_CHAR(RPC_E_CONNECTION_TERMINATED      ),
01466      VALUE_CHAR(RPC_E_SERVER_DIED                ),
01467      VALUE_CHAR(RPC_E_CLIENT_DIED                ),
01468      VALUE_CHAR(RPC_E_INVALID_DATAPACKET         ),
01469      VALUE_CHAR(RPC_E_CANTTRANSMIT_CALL          ),
01470      VALUE_CHAR(RPC_E_CLIENT_CANTMARSHAL_DATA    ),
01471      VALUE_CHAR(RPC_E_CLIENT_CANTUNMARSHAL_DATA  ),
01472      VALUE_CHAR(RPC_E_SERVER_CANTMARSHAL_DATA    ),
01473      VALUE_CHAR(RPC_E_SERVER_CANTUNMARSHAL_DATA  ),
01474      VALUE_CHAR(RPC_E_INVALID_DATA               ),
01475      VALUE_CHAR(RPC_E_INVALID_PARAMETER          ),
01476      VALUE_CHAR(RPC_E_CANTCALLOUT_AGAIN          ),
01477      VALUE_CHAR(RPC_E_SERVER_DIED_DNE            ),
01478      VALUE_CHAR(RPC_E_SYS_CALL_FAILED            ),
01479      VALUE_CHAR(RPC_E_OUT_OF_RESOURCES           ),
01480      VALUE_CHAR(RPC_E_ATTEMPTED_MULTITHREAD      ),
01481      VALUE_CHAR(RPC_E_NOT_REGISTERED             ),
01482      VALUE_CHAR(RPC_E_FAULT                      ),
01483      VALUE_CHAR(RPC_E_SERVERFAULT                ),
01484      VALUE_CHAR(RPC_E_CHANGED_MODE               ),
01485      VALUE_CHAR(RPC_E_INVALIDMETHOD              ),
01486      VALUE_CHAR(RPC_E_DISCONNECTED               ),
01487      VALUE_CHAR(RPC_E_RETRY                      ),
01488      VALUE_CHAR(RPC_E_SERVERCALL_RETRYLATER      ),
01489      VALUE_CHAR(RPC_E_SERVERCALL_REJECTED        ),
01490      VALUE_CHAR(RPC_E_INVALID_CALLDATA           ),
01491      VALUE_CHAR(RPC_E_CANTCALLOUT_ININPUTSYNCCALL ),
01492      VALUE_CHAR(RPC_E_WRONG_THREAD               ),
01493      VALUE_CHAR(RPC_E_THREAD_NOT_INIT            ),
01494      VALUE_CHAR(RPC_E_VERSION_MISMATCH           ),
01495      VALUE_CHAR(RPC_E_INVALID_HEADER             ),
01496      VALUE_CHAR(RPC_E_INVALID_EXTENSION          ),
01497      VALUE_CHAR(RPC_E_INVALID_IPID               ),
01498      VALUE_CHAR(RPC_E_INVALID_OBJECT             ),
01499      VALUE_CHAR(RPC_S_CALLPENDING                ),
01500      VALUE_CHAR(RPC_S_WAITONTIMER                ),
01501      VALUE_CHAR(RPC_E_CALL_COMPLETE              ),
01502      VALUE_CHAR(RPC_E_UNSECURE_CALL              ),
01503      VALUE_CHAR(RPC_E_TOO_LATE                   ),
01504      VALUE_CHAR(RPC_E_NO_GOOD_SECURITY_PACKAGES  ),
01505      VALUE_CHAR(RPC_E_ACCESS_DENIED              ),
01506      VALUE_CHAR(RPC_E_REMOTE_DISABLED            ),
01507      VALUE_CHAR(RPC_E_INVALID_OBJREF             ),
01508      VALUE_CHAR(RPC_E_UNEXPECTED                 ),
01509      VALUE_CHAR(TRUST_E_PROVIDER_UNKNOWN         ),
01510      VALUE_CHAR(TRUST_E_ACTION_UNKNOWN           ),
01511      VALUE_CHAR(TRUST_E_SUBJECT_FORM_UNKNOWN     ),
01512      VALUE_CHAR(TRUST_E_SUBJECT_NOT_TRUSTED      ),
01513      VALUE_CHAR(PERSIST_E_SIZEDEFINITE           ),
01514      VALUE_CHAR(PERSIST_E_SIZEINDEFINITE         ),
01515      VALUE_CHAR(PERSIST_E_NOTSELFSIZING          ),
01516      VALUE_CHAR(TRUST_E_NOSIGNATURE              ),
01517      VALUE_CHAR(CERT_E_EXPIRED                   ),
01518      VALUE_CHAR(CERT_E_ROLE                      ),
01519      VALUE_CHAR(CERT_E_PATHLENCONST              ),
01520      VALUE_CHAR(CERT_E_CRITICAL                  ),
01521      VALUE_CHAR(CERT_E_PURPOSE                   ),
01522      VALUE_CHAR(CERT_E_ISSUERCHAINING            ),
01523      VALUE_CHAR(CERT_E_MALFORMED                 ),
01524      VALUE_CHAR(CERT_E_UNTRUSTEDROOT             ),
01525      VALUE_CHAR(CERT_E_CHAINING                  ),
01526 };
01527
01528
01529 ////////////////////////////////////////////////////////////////////////
01530 // PROPSTATUSMAP
01531 //
01532 ////////////////////////////////////////////////////////////////////////
01533 const static WIDENAMEMAP g_rgPropStatusMap[] =
01534 {
01535     VALUE_WCHAR(DBPROPSTATUS_OK),
01536   VALUE_WCHAR(DBPROPSTATUS_NOTSUPPORTED),
01537   VALUE_WCHAR(DBPROPSTATUS_BADVALUE),
01538   VALUE_WCHAR(DBPROPSTATUS_BADOPTION),
01539   VALUE_WCHAR(DBPROPSTATUS_BADCOLUMN),
01540   VALUE_WCHAR(DBPROPSTATUS_NOTALLSETTABLE),
01541   VALUE_WCHAR(DBPROPSTATUS_NOTSETTABLE),
01542   VALUE_WCHAR(DBPROPSTATUS_NOTSET),
01543   VALUE_WCHAR(DBPROPSTATUS_CONFLICTING),
01544
01545   //2.1
01546   VALUE_WCHAR(DBPROPSTATUS_NOTAVAILABLE),
01547 };
01548
01549
01550 ////////////////////////////////////////////////////////////////////////
01551 // WCHAR* GetPropStatusName
01552 //
01553 ////////////////////////////////////////////////////////////////////////
01554 WCHAR* GetPropStatusName(DBPROPSTATUS dbPropStatus)
01555 {
01556   return GetMapName(dbPropStatus, NUMELE(g_rgPropStatusMap), g_rgPropStatusMap);
01557 }
01558
01559
01560 ////////////////////////////////////////////////////////////////////////
01561 // STATUSMAP
01562 //
01563 ////////////////////////////////////////////////////////////////////////
01564 const static WIDENAMEMAP g_rgStatusMap[] =
01565 {
01566     VALUE_WCHAR(DBSTATUS_S_OK ),
01567   VALUE_WCHAR(DBSTATUS_E_BADACCESSOR  ),
01568   VALUE_WCHAR(DBSTATUS_E_CANTCONVERTVALUE ),
01569   VALUE_WCHAR(DBSTATUS_S_ISNULL ),
01570   VALUE_WCHAR(DBSTATUS_S_TRUNCATED  ),
01571   VALUE_WCHAR(DBSTATUS_E_SIGNMISMATCH ),
01572   VALUE_WCHAR(DBSTATUS_E_DATAOVERFLOW ),
01573   VALUE_WCHAR(DBSTATUS_E_CANTCREATE ),
01574   VALUE_WCHAR(DBSTATUS_E_UNAVAILABLE  ),
01575   VALUE_WCHAR(DBSTATUS_E_PERMISSIONDENIED ),
01576   VALUE_WCHAR(DBSTATUS_E_INTEGRITYVIOLATION ),
01577   VALUE_WCHAR(DBSTATUS_E_SCHEMAVIOLATION  ),
01578   VALUE_WCHAR(DBSTATUS_E_BADSTATUS  ),
01579   VALUE_WCHAR(DBSTATUS_S_DEFAULT  ),
01580
01581   //2.0
01582   VALUE_WCHAR(MDSTATUS_S_CELLEMPTY  ),
01583   VALUE_WCHAR(DBSTATUS_S_IGNORE ),
01584
01585   //2.1
01586     VALUE_WCHAR(DBSTATUS_E_DOESNOTEXIST),
01587   VALUE_WCHAR(DBSTATUS_E_INVALIDURL),
01588   VALUE_WCHAR(DBSTATUS_E_RESOURCELOCKED),
01589   VALUE_WCHAR(DBSTATUS_E_RESOURCEEXISTS),
01590   VALUE_WCHAR(DBSTATUS_E_CANNOTCOMPLETE),
01591   VALUE_WCHAR(DBSTATUS_E_VOLUMENOTFOUND),
01592   VALUE_WCHAR(DBSTATUS_E_OUTOFSPACE),
01593   VALUE_WCHAR(DBSTATUS_S_CANNOTDELETESOURCE),
01594   VALUE_WCHAR(DBSTATUS_E_READONLY),
01595
01596   //2.5
01597   VALUE_WCHAR(DBSTATUS_E_CANCELED),
01598   VALUE_WCHAR(DBSTATUS_E_NOTCOLLECTION),
01599
01600   //2.6
01601   VALUE_WCHAR(DBSTATUS_S_ROWSETCOLUMN ),
01602 };
01603
01604
01605 ////////////////////////////////////////////////////////////////////////
01606 // WCHAR* GetStatusName
01607 //
01608 ////////////////////////////////////////////////////////////////////////
01609 WCHAR* GetStatusName(DBSTATUS dbStatus, DWORD dwConvFlags)
01610 {
01611   return GetMapName(dbStatus, NUMELE(g_rgStatusMap), g_rgStatusMap, dwConvFlags);
01612 }
01613
01614 ////////////////////////////////////////////////////////////////////////
01615 // DBSTATUS GetStatusValue
01616 //
01617 ////////////////////////////////////////////////////////////////////////
01618 DBSTATUS GetStatusValue(WCHAR* pwszName)
01619 {
01620   return GetMapName(pwszName, NUMELE(g_rgStatusMap), g_rgStatusMap);
01621 }
01622
01623 ////////////////////////////////////////////////////////////////////////
01624 // PROPSET
01625 //
01626 ////////////////////////////////////////////////////////////////////////
01627 const static WIDEGUIDMAP g_rgPropSetMaps[] =
01628 {
01629   //Property Sets
01630   VALUE_PWCHAR(DBPROPSET_COLUMN),
01631   VALUE_PWCHAR(DBPROPSET_DATASOURCE),
01632   VALUE_PWCHAR(DBPROPSET_DATASOURCEINFO),
01633   VALUE_PWCHAR(DBPROPSET_DBINIT),
01634   VALUE_PWCHAR(DBPROPSET_DBINITALL),
01635   VALUE_PWCHAR(DBPROPSET_INDEX),
01636   VALUE_PWCHAR(DBPROPSET_TABLE),
01637   VALUE_PWCHAR(DBPROPSET_VIEW),
01638   VALUE_PWCHAR(DBPROPSET_DATASOURCEALL),
01639   VALUE_PWCHAR(DBPROPSET_DATASOURCEINFOALL),
01640   VALUE_PWCHAR(DBPROPSET_ROWSET),
01641   VALUE_PWCHAR(DBPROPSET_ROWSETALL),
01642   VALUE_PWCHAR(DBPROPSET_SESSION),
01643   VALUE_PWCHAR(DBPROPSET_SESSIONALL),
01644   VALUE_PWCHAR(DBPROPSET_PROPERTIESINERROR),
01645
01646   //2.1
01647   VALUE_PWCHAR(DBPROPSET_TRUSTEE),
01648   VALUE_PWCHAR(DBPROPSET_COLUMNALL),
01649   VALUE_PWCHAR(DBPROPSET_INDEXALL),
01650   VALUE_PWCHAR(DBPROPSET_TABLEALL),
01651   VALUE_PWCHAR(DBPROPSET_TRUSTEEALL),
01652   VALUE_PWCHAR(DBPROPSET_CONSTRAINTALL),
01653
01654   //2.6
01655   VALUE_PWCHAR(DBPROPSET_STREAM),
01656   VALUE_PWCHAR(DBPROPSET_STREAMALL),
01657
01658   //Negative Testing
01659   VALUE_PWCHAR(GUID_NULL),
01660 };
01661 const static ULONG g_cPropSetMaps = NUMELE(g_rgPropSetMaps);
01662
01663
01664 ////////////////////////////////////////////////////////////////////////
01665 // IsSpecialPropSet
01666 //
01667 ////////////////////////////////////////////////////////////////////////
01668 BOOL IsSpecialPropSet(REFGUID guidSpecialPropertySet, GUID* pGuidPropertySet)
01669 {
01670   //Special Property Sets
01671   typedef struct _SPECIALGUIDMAP
01672   {
01673     const GUID* pSpecialPropertySet;
01674     const GUID* pGuidPropertySet;
01675   } SPECIALGUIDMAP;
01676
01677   const static SPECIALGUIDMAP rgSpecialPropSet[] =
01678   {
01679     & DBPROPSET_COLUMNALL,            & DBPROPSET_COLUMN,
01680     & DBPROPSET_DATASOURCEALL,          & DBPROPSET_DATASOURCE,
01681     & DBPROPSET_DATASOURCEINFOALL,        & DBPROPSET_DATASOURCEINFO,
01682     & DBPROPSET_INDEXALL,           & DBPROPSET_INDEX,
01683     & DBPROPSET_DBINITALL,            & DBPROPSET_DBINIT,
01684     & DBPROPSET_SESSIONALL,           & DBPROPSET_SESSION,
01685     & DBPROPSET_TABLEALL,           & DBPROPSET_TABLE,
01686     & DBPROPSET_TRUSTEEALL,           & DBPROPSET_TRUSTEE,
01687     & DBPROPSET_VIEWALL,            & DBPROPSET_VIEW,
01688     & DBPROPSET_ROWSETALL,            & DBPROPSET_ROWSET,
01689     & DBPROPSET_STREAMALL,            & DBPROPSET_STREAM,
01690   };
01691
01692   //Is this one of the special Property Sets
01693   for(ULONG iPropSet=0; iPropSet<NUMELE(rgSpecialPropSet); iPropSet++)
01694   {
01695     const SPECIALGUIDMAP* pSpecPropSet = &rgSpecialPropSet[iPropSet];
01696     if(guidSpecialPropertySet == *pSpecPropSet->pSpecialPropertySet)
01697     {
01698       if(pGuidPropertySet)
01699         *pGuidPropertySet = *pSpecPropSet->pGuidPropertySet;
01700       return TRUE;
01701     }
01702   }
01703
01704   //Not a special set...
01705   return FALSE;
01706 }
01707
01708
01709
01710 ////////////////////////////////////////////////////////////////////////
01711 // GetStaticPropValues
01712 //
01713 ////////////////////////////////////////////////////////////////////////
01714 HRESULT GetStaticPropValues(DBPROPID dwPropertyID, REFGUID guidPropertySet, ULONG* pcPropValMap, const WIDENAMEMAP** prgPropValMap)
01715 {
01716   ASSERT(pcPropValMap);
01717   ASSERT(prgPropValMap);
01718
01719   //DBPROPSET_ROWSET
01720   if(guidPropertySet == DBPROPSET_ROWSET)
01721   {
01722     switch(dwPropertyID)
01723     {
01724       case DBPROP_UPDATABILITY:
01725       {
01726         const static WIDENAMEMAP rgUPDATABILITY[] =
01727         {
01728           VALUE_WCHAR(DBPROPVAL_UP_CHANGE ),
01729           VALUE_WCHAR(DBPROPVAL_UP_DELETE ),
01730           VALUE_WCHAR(DBPROPVAL_UP_INSERT ),
01731         };
01732
01733         *pcPropValMap = NUMELE(rgUPDATABILITY);
01734         *prgPropValMap = rgUPDATABILITY;
01735         return S_OK;
01736       }
01737     };
01738   }
01739   else if(guidPropertySet == DBPROPSET_DBINIT)
01740   {
01741     switch(dwPropertyID)
01742     {
01743       case DBPROP_INIT_PROMPT:
01744       {
01745         const static WIDENAMEMAP rgPrompts[] =
01746         {
01747           VALUE_WCHAR(DBPROMPT_PROMPT),
01748           VALUE_WCHAR(DBPROMPT_COMPLETE),
01749           VALUE_WCHAR(DBPROMPT_COMPLETEREQUIRED),
01750           VALUE_WCHAR(DBPROMPT_NOPROMPT),
01751         };
01752
01753         *pcPropValMap = NUMELE(rgPrompts);
01754         *prgPropValMap = rgPrompts;
01755         return S_OK;
01756       }
01757     };
01758   }
01759
01760   return DB_E_NOTFOUND;
01761 }
01762
01763
01764 ////////////////////////////////////////////////////////////////////////
01765 // GetStaticPropInfo
01766 //
01767 ////////////////////////////////////////////////////////////////////////
01768 HRESULT GetStaticPropInfo(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets, ULONG* pcStaticInfoSets, const DBPROPINFOSET** prgStaticInfoSets)
01769 {
01770   HRESULT hr = S_OK;
01771   ASSERT(pcStaticInfoSets);
01772   ASSERT(prgStaticInfoSets);
01773
01774   //DBPROPSET_COLUMN
01775   const static DBPROPINFO rgColumnPropInfo[] =
01776   {
01777     VALUE_WCHAR(DBPROP_COL_AUTOINCREMENT),      DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01778     VALUE_WCHAR(DBPROP_COL_DEFAULT  ),        DBPROPFLAGS_COLUMN,     DBTYPE_EMPTY,   {0,0,0,0,0},
01779     VALUE_WCHAR(DBPROP_COL_DESCRIPTION  ),      DBPROPFLAGS_COLUMN,     DBTYPE_BSTR,    {0,0,0,0,0},
01780     VALUE_WCHAR(DBPROP_COL_FIXEDLENGTH  ),      DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01781     VALUE_WCHAR(DBPROP_COL_INCREMENT),        DBPROPFLAGS_COLUMN,     DBTYPE_EMPTY,   {0,0,0,0,0},
01782     VALUE_WCHAR(DBPROP_COL_ISLONG),         DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01783     VALUE_WCHAR(DBPROP_COL_NULLABLE ),        DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01784     VALUE_WCHAR(DBPROP_COL_PRIMARYKEY ),      DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01785     VALUE_WCHAR(DBPROP_COL_UNIQUE ),        DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01786     VALUE_WCHAR(DBPROP_COLUMNLCID),         DBPROPFLAGS_COLUMN,     DBTYPE_BOOL,    {0,0,0,0,0},
01787     VALUE_WCHAR(DBPROP_COL_SEED),         DBPROPFLAGS_COLUMN,     DBTYPE_EMPTY,   {0,0,0,0,0},
01788   };
01789
01790   //DBPROPSET_DATASOURCE
01791   const static DBPROPINFO rgDataSourcePropInfo[] =
01792   {
01793     VALUE_WCHAR(DBPROP_CURRENTCATALOG ),      DBPROPFLAGS_DATASOURCE,   DBTYPE_BSTR,    {0,0,0,0,0},
01794     VALUE_WCHAR(DBPROP_MULTIPLECONNECTIONS),    DBPROPFLAGS_DATASOURCE,   DBTYPE_BOOL,    {0,0,0,0,0},
01795     VALUE_WCHAR(DBPROP_RESETDATASOURCE),      DBPROPFLAGS_DATASOURCE,   DBTYPE_I4,      {0,0,0,0,0},
01796   };
01797
01798   //DBPROPSET_DATASOURCEINFO
01799   const static DBPROPINFO rgDataSourceInfoPropInfo[] =
01800   {
01801     VALUE_WCHAR(DBPROP_ACTIVESESSIONS ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01802     VALUE_WCHAR(DBPROP_ALTERCOLUMN),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01803     VALUE_WCHAR(DBPROP_ASYNCTXNABORT  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01804     VALUE_WCHAR(DBPROP_ASYNCTXNCOMMIT ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01805     VALUE_WCHAR(DBPROP_BYREFACCESSORS ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01806     VALUE_WCHAR(DBPROP_CATALOGLOCATION  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01807     VALUE_WCHAR(DBPROP_CATALOGTERM  ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01808     VALUE_WCHAR(DBPROP_CATALOGUSAGE ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01809     VALUE_WCHAR(DBPROP_COLUMNDEFINITION ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01810     VALUE_WCHAR(DBPROP_COMSERVICES  ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01811     VALUE_WCHAR(DBPROP_CONCATNULLBEHAVIOR ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01812     VALUE_WCHAR(DBPROP_CONNECTIONSTATUS),     DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01813     VALUE_WCHAR(DBPROP_DATASOURCENAME ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01814     VALUE_WCHAR(DBPROP_DATASOURCEREADONLY ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01815     VALUE_WCHAR(DBPROP_DATASOURCE_TYPE),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01816     VALUE_WCHAR(DBPROP_DBMSNAME ),          DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01817     VALUE_WCHAR(DBPROP_DBMSVER  ),          DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01818     VALUE_WCHAR(DBPROP_DSOTHREADMODEL ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01819     VALUE_WCHAR(DBPROP_GENERATEURL),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01820     VALUE_WCHAR(DBPROP_GROUPBY  ),          DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01821     VALUE_WCHAR(DBPROP_HETEROGENEOUSTABLES  ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01822     VALUE_WCHAR(DBPROP_IDENTIFIERCASE),       DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01823     VALUE_WCHAR(DBPROP_MAXINDEXSIZE ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01824     VALUE_WCHAR(DBPROP_MAXOPENCHAPTERS  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01825     VALUE_WCHAR(DBPROP_MAXROWSIZE ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01826     VALUE_WCHAR(DBPROP_MAXROWSIZEINCLUDESBLOB ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01827     VALUE_WCHAR(DBPROP_MAXTABLESINSELECT  ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01828     VALUE_WCHAR(DBPROP_MULTIPLEPARAMSETS  ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01829     VALUE_WCHAR(DBPROP_MULTIPLERESULTS  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01830     VALUE_WCHAR(DBPROP_MULTIPLESTORAGEOBJECTS ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01831     VALUE_WCHAR(DBPROP_MULTITABLEUPDATE ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01832     VALUE_WCHAR(DBPROP_NULLCOLLATION  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01833     VALUE_WCHAR(DBPROP_OLEOBJECTS ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01834     VALUE_WCHAR(DBPROP_OPENROWSETSUPPORT),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01835     VALUE_WCHAR(DBPROP_ORDERBYCOLUMNSINSELECT ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01836     VALUE_WCHAR(DBPROP_OUTPUTPARAMETERAVAILABILITY  ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,    {0,0,0,0,0},
01837     VALUE_WCHAR(DBPROP_PERSISTENTIDTYPE ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01838     VALUE_WCHAR(DBPROP_PREPAREABORTBEHAVIOR ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01839     VALUE_WCHAR(DBPROP_PREPARECOMMITBEHAVIOR  ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01840     VALUE_WCHAR(DBPROP_PROCEDURETERM  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01841     VALUE_WCHAR(DBPROP_PROVIDERFRIENDLYNAME),   DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01842     VALUE_WCHAR(DBPROP_PROVIDERMEMORY),       DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01843     VALUE_WCHAR(DBPROP_PROVIDERFILENAME ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01844     VALUE_WCHAR(DBPROP_PROVIDEROLEDBVER ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01845     VALUE_WCHAR(DBPROP_PROVIDERVER  ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01846     VALUE_WCHAR(DBPROP_QUOTEDIDENTIFIERCASE ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01847     VALUE_WCHAR(DBPROP_ROWSETCONVERSIONSONCOMMAND ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01848     VALUE_WCHAR(DBPROP_SCHEMATERM ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01849     VALUE_WCHAR(DBPROP_SCHEMAUSAGE  ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01850     VALUE_WCHAR(DBPROP_SERVERNAME),         DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01851     VALUE_WCHAR(DBPROP_SQLSUPPORT ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01852     VALUE_WCHAR(DBPROP_STRUCTUREDSTORAGE  ),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01853     VALUE_WCHAR(DBPROP_SUBQUERIES ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01854     VALUE_WCHAR(DBPROP_SUPPORTEDTXNDDL  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01855     VALUE_WCHAR(DBPROP_SUPPORTEDTXNISOLEVELS  ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01856     VALUE_WCHAR(DBPROP_SUPPORTEDTXNISORETAIN  ),  DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01857     VALUE_WCHAR(DBPROP_TABLETERM  ),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01858     VALUE_WCHAR(DBPROP_TABLESTATISTICS  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01859     VALUE_WCHAR(DBPROP_USERNAME ),          DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BSTR,    {0,0,0,0,0},
01860
01861     //OLAP Documention
01862     VALUE_WCHAR(MDPROP_AXES),           DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01863     VALUE_WCHAR(MDPROP_FLATTENING_SUPPORT),     DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01864     VALUE_WCHAR(MDPROP_MDX_JOINCUBES),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01865     VALUE_WCHAR(MDPROP_NAMED_LEVELS),       DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01866     VALUE_WCHAR(MDPROP_RANGEROWSET),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01867     VALUE_WCHAR(MDPROP_MDX_SLICER),         DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01868     VALUE_WCHAR(MDPROP_MDX_CUBEQUALIFICATION),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01869     VALUE_WCHAR(MDPROP_MDX_OUTERREFERENCE),     DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01870     VALUE_WCHAR(MDPROP_MDX_QUERYBYPROPERTY),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01871     VALUE_WCHAR(MDPROP_MDX_CASESUPPORT),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01872     VALUE_WCHAR(MDPROP_MDX_STRING_COMPOP),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01873     VALUE_WCHAR(MDPROP_MDX_DESCFLAGS),        DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01874     VALUE_WCHAR(MDPROP_MDX_SET_FUNCTIONS),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01875     VALUE_WCHAR(MDPROP_MDX_MEMBER_FUNCTIONS),   DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01876     VALUE_WCHAR(MDPROP_MDX_NUMERIC_FUNCTIONS),    DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01877     VALUE_WCHAR(MDPROP_MDX_FORMULAS),       DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01878     VALUE_WCHAR(MDPROP_MDX_AGGREGATECELL_UPDATE), DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01879
01880     //Not yet doc'd...
01881     VALUE_WCHAR(DBPROP_STORAGEFLAGS),       DBPROPFLAGS_DATASOURCEINFO, DBTYPE_BOOL,    {0,0,0,0,0},
01882
01883     //2.6
01884     VALUE_WCHAR(DBPROP_TABLESTATISTICS  ),      DBPROPFLAGS_DATASOURCEINFO, DBTYPE_I4,      {0,0,0,0,0},
01885   };
01886
01887   //DBPROPSET_INDEX
01888   const static DBPROPINFO rgIndexPropInfo[] =
01889   {
01890     VALUE_WCHAR(DBPROP_INDEX_AUTOUPDATE),     DBPROPFLAGS_INDEX,      DBTYPE_BOOL,    {0,0,0,0,0},
01891     VALUE_WCHAR(DBPROP_INDEX_CLUSTERED),      DBPROPFLAGS_INDEX,      DBTYPE_BOOL,    {0,0,0,0,0},
01892     VALUE_WCHAR(DBPROP_INDEX_FILLFACTOR),     DBPROPFLAGS_INDEX,      DBTYPE_I4,      {0,0,0,0,0},
01893     VALUE_WCHAR(DBPROP_INDEX_INITIALSIZE),      DBPROPFLAGS_INDEX,      DBTYPE_I4,      {0,0,0,0,0},
01894     VALUE_WCHAR(DBPROP_INDEX_NULLCOLLATION),    DBPROPFLAGS_INDEX,      DBTYPE_I4,      {0,0,0,0,0},
01895     VALUE_WCHAR(DBPROP_INDEX_NULLS),        DBPROPFLAGS_INDEX,      DBTYPE_I4,      {0,0,0,0,0},
01896     VALUE_WCHAR(DBPROP_INDEX_PRIMARYKEY),     DBPROPFLAGS_INDEX,      DBTYPE_BOOL,    {0,0,0,0,0},
01897     VALUE_WCHAR(DBPROP_INDEX_SORTBOOKMARKS),    DBPROPFLAGS_INDEX,      DBTYPE_BOOL,    {0,0,0,0,0},
01898     VALUE_WCHAR(DBPROP_INDEX_TEMPINDEX),      DBPROPFLAGS_INDEX,      DBTYPE_BOOL,    {0,0,0,0,0},
01899     VALUE_WCHAR(DBPROP_INDEX_TYPE),         DBPROPFLAGS_INDEX,      DBTYPE_I4,      {0,0,0,0,0},
01900     VALUE_WCHAR(DBPROP_INDEX_UNIQUE),       DBPROPFLAGS_INDEX,      DBTYPE_BOOL,    {0,0,0,0,0},
01901   };
01902
01903   //DBPROPSET_DBINIT
01904   const static DBPROPINFO rgInitPropInfo[] =
01905   {
01906     VALUE_WCHAR(DBPROP_AUTH_CACHE_AUTHINFO  ),    DBPROPFLAGS_DBINIT,     DBTYPE_BOOL,    {0,0,0,0,0},
01907     VALUE_WCHAR(DBPROP_AUTH_ENCRYPT_PASSWORD  ),  DBPROPFLAGS_DBINIT,     DBTYPE_BOOL,    {0,0,0,0,0},
01908     VALUE_WCHAR(DBPROP_AUTH_INTEGRATED  ),      DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01909     VALUE_WCHAR(DBPROP_AUTH_MASK_PASSWORD ),    DBPROPFLAGS_DBINIT,     DBTYPE_BOOL,    {0,0,0,0,0},
01910     VALUE_WCHAR(DBPROP_AUTH_PASSWORD  ),      DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01911     VALUE_WCHAR(DBPROP_AUTH_PERSIST_ENCRYPTED ),  DBPROPFLAGS_DBINIT,     DBTYPE_BOOL,    {0,0,0,0,0},
01912     VALUE_WCHAR(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO  ),    DBPROPFLAGS_DBINIT,     DBTYPE_BOOL,    {0,0,0,0,0},
01913     VALUE_WCHAR(DBPROP_AUTH_USERID  ),        DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01914     VALUE_WCHAR(DBPROP_INIT_ASYNCH),        DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01915     VALUE_WCHAR(DBPROP_INIT_BINDFLAGS),       DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01916     VALUE_WCHAR(DBPROP_INIT_CATALOG),       DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01917     VALUE_WCHAR(DBPROP_INIT_DATASOURCE),      DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01918     VALUE_WCHAR(DBPROP_INIT_GENERALTIMEOUT),    DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01919     VALUE_WCHAR(DBPROP_INIT_HWND  ),        DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01920     VALUE_WCHAR(DBPROP_INIT_IMPERSONATION_LEVEL ),  DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01921     VALUE_WCHAR(DBPROP_INIT_LCID  ),        DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01922     VALUE_WCHAR(DBPROP_INIT_LOCATION  ),      DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01923     VALUE_WCHAR(DBPROP_INIT_LOCKOWNER),       DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01924     VALUE_WCHAR(DBPROP_INIT_MODE  ),        DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01925     VALUE_WCHAR(DBPROP_INIT_OLEDBSERVICES),     DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01926     VALUE_WCHAR(DBPROP_INIT_PROMPT  ),        DBPROPFLAGS_DBINIT,     DBTYPE_I2,      {0,0,0,0,0},
01927     VALUE_WCHAR(DBPROP_INIT_PROTECTION_LEVEL  ),  DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01928     VALUE_WCHAR(DBPROP_INIT_PROVIDERSTRING  ),    DBPROPFLAGS_DBINIT,     DBTYPE_BSTR,    {0,0,0,0,0},
01929     VALUE_WCHAR(DBPROP_INIT_TIMEOUT ),        DBPROPFLAGS_DBINIT,     DBTYPE_I4,      {0,0,0,0,0},
01930   };
01931
01932   //DBPROPSET_SESSION
01933   const static DBPROPINFO rgSessionPropInfo[] =
01934   {
01935     VALUE_WCHAR(DBPROP_SESS_AUTOCOMMITISOLEVELS ),  DBPROPFLAGS_SESSION,    DBTYPE_I4,      {0,0,0,0,0},
01936   };
01937
01938   //DBPROPSET_TABLE
01939   const static DBPROPINFO rgTablePropInfo[] =
01940   {
01941     VALUE_WCHAR(DBPROP_TBL_TEMPTABLE  ),      DBPROPFLAGS_TABLE,      DBTYPE_BOOL,    {0,0,0,0,0},
01942   };
01943
01944   //DBPROPSET_TRUSTEE
01945   const static DBPROPINFO rgTrusteePropInfo[] =
01946   {
01947     //Documented in Security Whitepaper
01948     VALUE_WCHAR(DBPROP_TRUSTEE_USERNAME),     DBPROPFLAGS_TRUSTEE,    DBTYPE_BOOL,    {0,0,0,0,0},
01949     VALUE_WCHAR(DBPROP_TRUSTEE_AUTHENTICATION),   DBPROPFLAGS_TRUSTEE,    DBTYPE_BOOL,    {0,0,0,0,0},
01950     VALUE_WCHAR(DBPROP_TRUSTEE_NEWAUTHENTICATION),  DBPROPFLAGS_TRUSTEE,    DBTYPE_BOOL,    {0,0,0,0,0},
01951   };
01952
01953   //DBPROPSET_VIEW
01954   const static DBPROPINFO rgViewPropInfo[] =
01955   {
01956     VALUE_WCHAR(DBPROP_FILTERCOMPAREOPS ),      DBPROPFLAGS_VIEW,     DBTYPE_I4,      {0,0,0,0,0},
01957     VALUE_WCHAR(DBPROP_IAccessor  ),        DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01958     VALUE_WCHAR(DBPROP_IColumnsInfo ),        DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01959     VALUE_WCHAR(DBPROP_ISupportErrorInfo),      DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01960     VALUE_WCHAR(DBPROP_IViewChapter),       DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01961     VALUE_WCHAR(DBPROP_IViewFilter),        DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01962     VALUE_WCHAR(DBPROP_IViewRowset),        DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01963     VALUE_WCHAR(DBPROP_IViewSort),          DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01964     VALUE_WCHAR(DBPROP_MAXORSINFILTER ),      DBPROPFLAGS_VIEW,     DBTYPE_I4,      {0,0,0,0,0},
01965     VALUE_WCHAR(DBPROP_MAXSORTCOLUMNS ),      DBPROPFLAGS_VIEW,     DBTYPE_I4,      {0,0,0,0,0},
01966     VALUE_WCHAR(DBPROP_SORTONINDEX  ),        DBPROPFLAGS_VIEW,     DBTYPE_BOOL,    {0,0,0,0,0},
01967   };
01968
01969   //DBPROPSET_ROWSET
01970   const static DBPROPINFO rgRowsetPropInfo[] =
01971   {
01972     VALUE_WCHAR(DBPROP_ABORTPRESERVE  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01973     VALUE_WCHAR(DBPROP_ACCESSORDER),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
01974     VALUE_WCHAR(DBPROP_APPENDONLY ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01975     VALUE_WCHAR(DBPROP_BLOCKINGSTORAGEOBJECTS ),  DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01976     VALUE_WCHAR(DBPROP_BOOKMARKINFO),       DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
01977     VALUE_WCHAR(DBPROP_BOOKMARKS  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01978     VALUE_WCHAR(DBPROP_BOOKMARKSKIPPED  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01979     VALUE_WCHAR(DBPROP_BOOKMARKTYPE ),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
01980     VALUE_WCHAR(DBPROP_CACHEDEFERRED  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01981     VALUE_WCHAR(DBPROP_CANFETCHBACKWARDS  ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01982     VALUE_WCHAR(DBPROP_CANHOLDROWS  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01983     VALUE_WCHAR(DBPROP_CANSCROLLBACKWARDS ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01984     VALUE_WCHAR(DBPROP_CHANGEINSERTEDROWS ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01985     VALUE_WCHAR(DBPROP_CLIENTCURSOR),       DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01986     VALUE_WCHAR(DBPROP_COLUMNRESTRICT ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01987     VALUE_WCHAR(DBPROP_COMMANDTIMEOUT ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
01988     VALUE_WCHAR(DBPROP_COMMITPRESERVE ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01989     VALUE_WCHAR(DBPROP_DEFERRED ),          DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01990     VALUE_WCHAR(DBPROP_DELAYSTORAGEOBJECTS  ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01991     VALUE_WCHAR(DBPROP_FINDCOMPAREOPS ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
01992     VALUE_WCHAR(DBPROP_HIDDENCOLUMNS),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
01993     VALUE_WCHAR(DBPROP_IAccessor  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01994     VALUE_WCHAR(DBPROP_IChapteredRowset ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01995     VALUE_WCHAR(DBPROP_IColumnsInfo ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01996     VALUE_WCHAR(DBPROP_IColumnsInfo2),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01997     VALUE_WCHAR(DBPROP_IColumnsRowset ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01998     VALUE_WCHAR(DBPROP_IConnectionPointContainer),  DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
01999     VALUE_WCHAR(DBPROP_IConvertType ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02000     VALUE_WCHAR(DBPROP_ICreateRow),         DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02001     VALUE_WCHAR(DBPROP_IDBAsynchStatus  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02002     VALUE_WCHAR(DBPROP_IGetRow),          DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02003     VALUE_WCHAR(DBPROP_IGetSession),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02004     VALUE_WCHAR(DBPROP_IGetSourceRow),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02005     VALUE_WCHAR(DBPROP_ILockBytes),         DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02006     VALUE_WCHAR(DBPROP_IMMOBILEROWS),       DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02007     VALUE_WCHAR(DBPROP_IMultipleResults),     DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02008     VALUE_WCHAR(DBPROP_IParentRowset),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02009     VALUE_WCHAR(DBPROP_IRow),           DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02010     VALUE_WCHAR(DBPROP_IRowChange),         DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02011     VALUE_WCHAR(DBPROP_IRowSchemaChange),     DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02012     VALUE_WCHAR(DBPROP_IRowset  ),          DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02013     VALUE_WCHAR(DBPROP_IRowsetChange  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02014     VALUE_WCHAR(DBPROP_IRowsetCurrentIndex),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02015     VALUE_WCHAR(DBPROP_IRowsetFind  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02016     VALUE_WCHAR(DBPROP_IRowsetIdentity),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02017     VALUE_WCHAR(DBPROP_IRowsetIndex),       DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02018     VALUE_WCHAR(DBPROP_IRowsetInfo),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02019     VALUE_WCHAR(DBPROP_IRowsetLocate),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02020     VALUE_WCHAR(DBPROP_IRowsetRefresh),       DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02021     VALUE_WCHAR(DBPROP_IRowsetScroll),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02022     VALUE_WCHAR(DBPROP_IRowsetUpdate),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02023     VALUE_WCHAR(DBPROP_IRowsetView),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02024     VALUE_WCHAR(DBPROP_IScopedOperations),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02025     VALUE_WCHAR(DBPROP_ISequentialStream),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02026     VALUE_WCHAR(DBPROP_IStorage),         DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02027     VALUE_WCHAR(DBPROP_IStream),          DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02028     VALUE_WCHAR(DBPROP_ISupportErrorInfo),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02029     VALUE_WCHAR(DBPROP_LITERALBOOKMARKS ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02030     VALUE_WCHAR(DBPROP_LITERALIDENTITY  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02031     VALUE_WCHAR(DBPROP_LOCKMODE),         DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02032     VALUE_WCHAR(DBPROP_MAXOPENROWS  ),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02033     VALUE_WCHAR(DBPROP_MAXPENDINGROWS ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02034     VALUE_WCHAR(DBPROP_MAXROWS  ),          DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02035     VALUE_WCHAR(DBPROP_MAYWRITECOLUMN ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02036     VALUE_WCHAR(DBPROP_MEMORYUSAGE  ),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02037     VALUE_WCHAR(DBPROP_NOTIFICATIONGRANULARITY  ),  DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02038     VALUE_WCHAR(DBPROP_NOTIFICATIONPHASES ),    DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02039     VALUE_WCHAR(DBPROP_NOTIFYCOLUMNSET  ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02040     VALUE_WCHAR(DBPROP_NOTIFYROWDELETE  ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02041     VALUE_WCHAR(DBPROP_NOTIFYROWFIRSTCHANGE ),    DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02042     VALUE_WCHAR(DBPROP_NOTIFYROWINSERT  ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02043     VALUE_WCHAR(DBPROP_NOTIFYROWRESYNCH ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02044     VALUE_WCHAR(DBPROP_NOTIFYROWSETRELEASE  ),    DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02045     VALUE_WCHAR(DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE),  DBPROPFLAGS_ROWSET,     DBTYPE_I4,    {0,0,0,0,0},
02046     VALUE_WCHAR(DBPROP_NOTIFYROWUNDOCHANGE  ),    DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02047     VALUE_WCHAR(DBPROP_NOTIFYROWUNDODELETE  ),    DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02048     VALUE_WCHAR(DBPROP_NOTIFYROWUNDOINSERT  ),    DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02049     VALUE_WCHAR(DBPROP_NOTIFYROWUPDATE  ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02050     VALUE_WCHAR(DBPROP_ORDEREDBOOKMARKS ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02051     VALUE_WCHAR(DBPROP_OTHERINSERT  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02052     VALUE_WCHAR(DBPROP_OTHERUPDATEDELETE  ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02053     VALUE_WCHAR(DBPROP_OWNINSERT  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02054     VALUE_WCHAR(DBPROP_OWNUPDATEDELETE  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02055     VALUE_WCHAR(DBPROP_QUICKRESTART ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02056     VALUE_WCHAR(DBPROP_REENTRANTEVENTS  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02057     VALUE_WCHAR(DBPROP_REMOVEDELETED  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02058     VALUE_WCHAR(DBPROP_REPORTMULTIPLECHANGES  ),  DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02059     VALUE_WCHAR(DBPROP_RETURNPENDINGINSERTS ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02060     VALUE_WCHAR(DBPROP_ROW_BULKOPS),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02061     VALUE_WCHAR(DBPROP_ROWRESTRICT  ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02062     VALUE_WCHAR(DBPROP_ROWSET_ASYNCH  ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02063     VALUE_WCHAR(DBPROP_ROWTHREADMODEL ),      DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02064     VALUE_WCHAR(DBPROP_SERVERCURSOR ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02065     VALUE_WCHAR(DBPROP_SERVERDATAONINSERT),     DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02066     VALUE_WCHAR(DBPROP_STRONGIDENTITY ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02067     VALUE_WCHAR(DBPROP_TRANSACTEDOBJECT ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02068     VALUE_WCHAR(DBPROP_UNIQUEROWS),         DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02069     VALUE_WCHAR(DBPROP_UPDATABILITY ),        DBPROPFLAGS_ROWSET,     DBTYPE_I4,      {0,0,0,0,0},
02070
02071     //2.6
02072     //TODO: IRowsetBookmark and property are not doc'd - as of today?
02073     VALUE_WCHAR(DBPROP_IRowsetBookmark  ),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02074     VALUE_WCHAR(DBPROP_SKIPROWCOUNTRESULTS  ),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02075
02076     //Currently not doc'd due to unknown property set...
02077     VALUE_WCHAR(DBPROP_IBindResource),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02078     VALUE_WCHAR(DBPROP_IDBBinderProperties),    DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02079     VALUE_WCHAR(DBPROP_IRegisterProvider),      DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02080     VALUE_WCHAR(DBPROP_IRowsetResynch),       DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02081
02082     //Deprecated Properties
02083 //    VALUE_WCHAR(DBPROP_MARSHALLABLE ),        DBPROPFLAGS_ROWSET,     DBTYPE_BOOL,    {0,0,0,0,0},
02084   };
02085
02086   //DBPROPSET_STREAM
02087   const static DBPROPINFO rgStreamPropInfo[] =
02088   {
02089     VALUE_WCHAR(DBPROP_OUTPUTSTREAM ),        DBPROPFLAGS_STREAM,     DBTYPE_IUNKNOWN,  {0,0,0,0,0},
02090     VALUE_WCHAR(DBPROP_OUTPUTENCODING),       DBPROPFLAGS_STREAM,     DBTYPE_BSTR,    {0,0,0,0,0},
02091   };
02092
02093
02094   //Now build a static map of all the sets...
02095   const static DBPROPINFOSET rgAllPropInfoSet[] =
02096   {
02097     //DBPROPSET_COLUMN
02098     (DBPROPINFO*)rgColumnPropInfo,        NUMELE(rgColumnPropInfo),       {0xc8b522b9,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02099     //DBPROPSET_DATASOURCE
02100     (DBPROPINFO*)rgDataSourcePropInfo,      NUMELE(rgDataSourcePropInfo),   {0xc8b522ba,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02101     //DBPROPSET_DATASOURCEINFO
02102     (DBPROPINFO*)rgDataSourceInfoPropInfo,    NUMELE(rgDataSourceInfoPropInfo), {0xc8b522bb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02103     //DBPROPSET_INDEX
02104     (DBPROPINFO*)rgIndexPropInfo,       NUMELE(rgIndexPropInfo),      {0xc8b522bd,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02105     //DBPROPSET_DBINIT
02106     (DBPROPINFO*)rgInitPropInfo,        NUMELE(rgInitPropInfo),       {0xc8b522bc,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02107     //DBPROPSET_SESSION
02108     (DBPROPINFO*)rgSessionPropInfo,       NUMELE(rgSessionPropInfo),      {0xc8b522c6,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02109     //DBPROPSET_TABLE
02110     (DBPROPINFO*)rgTablePropInfo,       NUMELE(rgTablePropInfo),      {0xc8b522bf,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02111     //DBPROPSET_TRUSTEE
02112     (DBPROPINFO*)rgTrusteePropInfo,       NUMELE(rgTrusteePropInfo),      {0xc8b522e1,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02113     //DBPROPSET_VIEW
02114     (DBPROPINFO*)rgViewPropInfo,        NUMELE(rgViewPropInfo),       {0xc8b522df,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02115     //DBPROPSET_ROWSET
02116     (DBPROPINFO*)rgRowsetPropInfo,        NUMELE(rgRowsetPropInfo),     {0xc8b522be,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02117     //DBPROPSET_STREAM
02118     (DBPROPINFO*)rgStreamPropInfo,        NUMELE(rgStreamPropInfo),     {0xc8b522fd,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}},
02119   };
02120
02121   if(cPropertyIDSets == 0)
02122   {
02123     //Return all OLE DB Defined sets to the caller.
02124     *pcStaticInfoSets   = NUMELE(rgAllPropInfoSet);
02125     *prgStaticInfoSets    = rgAllPropInfoSet;
02126     return S_OK;
02127   }
02128   else
02129   {
02130     //Currently this routine only handles one level.
02131     //All that we currently need at this point for RowsetViewer...
02132     ASSERT(cPropertyIDSets==1);
02133     ASSERT(rgPropertyIDSets && rgPropertyIDSets[0].cPropertyIDs==0);
02134
02135     //First, is this a special property set, then map it to its defined property set...?
02136     GUID guidSpecialPropertySet = rgPropertyIDSets[0].guidPropertySet;
02137     IsSpecialPropSet(guidSpecialPropertySet, &guidSpecialPropertySet);
02138
02139     //Now loop through all the Property Sets and see which is desired...
02140     for(ULONG iPropSet=0; iPropSet<NUMELE(rgAllPropInfoSet); iPropSet++)
02141     {
02142       const DBPROPINFOSET* pPropInfoSet = &rgAllPropInfoSet[iPropSet];
02143       if(guidSpecialPropertySet == pPropInfoSet->guidPropertySet)
02144       {
02145         *pcStaticInfoSets   = 1;
02146         *prgStaticInfoSets    = pPropInfoSet;
02147         return S_OK;
02148       }
02149     }
02150   }
02151
02152 //CLEANUP:
02153   //Otherwise propety set was not found...
02154   *pcStaticInfoSets = 0;
02155   *prgStaticInfoSets = NULL;
02156   return DB_E_NOTFOUND;
02157 };
02158
02159
02160 ////////////////////////////////////////////////////////////////////////
02161 // GetAllocedPropInfo
02162 //
02163 ////////////////////////////////////////////////////////////////////////
02164 HRESULT GetAllocedPropInfo(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets, ULONG* pcPropInfoSets, DBPROPINFOSET** prgPropInfoSets)
02165 {
02166   HRESULT hr = S_OK;
02167   ASSERT(pcPropInfoSets);
02168   ASSERT(prgPropInfoSets);
02169
02170   ULONG iPropSet,cStaticInfoSets = 0;
02171   const DBPROPINFOSET* rgStaticInfoSets = NULL;
02172
02173   ULONG cPropInfoSets = 0;
02174   DBPROPINFOSET* rgPropInfoSets = NULL;
02175
02176   //Delegate
02177   TESTC(hr = GetStaticPropInfo(cPropertyIDSets, rgPropertyIDSets, &cStaticInfoSets, &rgStaticInfoSets));
02178
02179   //Now dump this static info into an allocated DBPROPINFOSET...
02180   SAFE_ALLOC(rgPropInfoSets, DBPROPINFOSET, cStaticInfoSets);
02181   cPropInfoSets = cStaticInfoSets;
02182   for(iPropSet=0; iPropSet<cStaticInfoSets; iPropSet++)
02183   {
02184     //Setup outer
02185     rgPropInfoSets[iPropSet].cPropertyInfos   = rgStaticInfoSets[iPropSet].cPropertyInfos;
02186     rgPropInfoSets[iPropSet].guidPropertySet  = rgStaticInfoSets[iPropSet].guidPropertySet;
02187     SAFE_ALLOC(rgPropInfoSets[iPropSet].rgPropertyInfos, DBPROPINFO, rgStaticInfoSets[iPropSet].cPropertyInfos);
02188     memcpy(rgPropInfoSets[iPropSet].rgPropertyInfos, rgStaticInfoSets[iPropSet].rgPropertyInfos, sizeof(DBPROPINFO)*rgStaticInfoSets[iPropSet].cPropertyInfos);
02189   }
02190
02191 CLEANUP:
02192   *pcPropInfoSets = cPropInfoSets;
02193   *prgPropInfoSets = rgPropInfoSets;
02194   return hr;
02195 };
02196
02197
02198 ////////////////////////////////////////////////////////////////////////
02199 // PROPFLAGS
02200 //
02201 ////////////////////////////////////////////////////////////////////////
02202 const static WIDENAMEMAP g_rgPropFlagsMap[] =
02203 {
02204     VALUE_WCHAR(DBPROPFLAGS_NOTSUPPORTED  ),
02205   VALUE_WCHAR(DBPROPFLAGS_COLUMN  ),
02206   VALUE_WCHAR(DBPROPFLAGS_DATASOURCE  ),
02207   VALUE_WCHAR(DBPROPFLAGS_DATASOURCECREATE  ),
02208   VALUE_WCHAR(DBPROPFLAGS_DATASOURCEINFO  ),
02209   VALUE_WCHAR(DBPROPFLAGS_DBINIT  ),
02210   VALUE_WCHAR(DBPROPFLAGS_INDEX ),
02211   VALUE_WCHAR(DBPROPFLAGS_ROWSET  ),
02212   VALUE_WCHAR(DBPROPFLAGS_TABLE ),
02213   VALUE_WCHAR(DBPROPFLAGS_COLUMNOK  ),
02214   VALUE_WCHAR(DBPROPFLAGS_READ  ),
02215   VALUE_WCHAR(DBPROPFLAGS_WRITE ),
02216   VALUE_WCHAR(DBPROPFLAGS_REQUIRED  ),
02217   VALUE_WCHAR(DBPROPFLAGS_SESSION ),
02218
02219   //2.1
02220     VALUE_WCHAR(DBPROPFLAGS_TRUSTEE),
02221 };
02222
02223
02224 const static WIDENAMEMAP g_rgIsoLevels[] =
02225 {
02226   VALUE_WCHAR(ISOLATIONLEVEL_UNSPECIFIED  ),
02227   VALUE_WCHAR(ISOLATIONLEVEL_CHAOS  ),
02228   VALUE_WCHAR(ISOLATIONLEVEL_READUNCOMMITTED  ),
02229   VALUE_WCHAR(ISOLATIONLEVEL_BROWSE ),
02230   VALUE_WCHAR(ISOLATIONLEVEL_CURSORSTABILITY  ),
02231   VALUE_WCHAR(ISOLATIONLEVEL_READCOMMITTED  ),
02232   VALUE_WCHAR(ISOLATIONLEVEL_REPEATABLEREAD ),
02233   VALUE_WCHAR(ISOLATIONLEVEL_SERIALIZABLE ),
02234   VALUE_WCHAR(ISOLATIONLEVEL_ISOLATED ),
02235 };
02236 const static ULONG g_cIsoLevels = NUMELE(g_rgIsoLevels);
02237
02238
02239 const static WIDENAMEMAP g_rgXACTTC[] =
02240 {
02241   VALUE_WCHAR(XACTTC_SYNC_PHASEONE  ),
02242   VALUE_WCHAR(XACTTC_SYNC_PHASETWO  ),
02243   VALUE_WCHAR(XACTTC_SYNC ),
02244   VALUE_WCHAR(XACTTC_ASYNC_PHASEONE ),
02245 };
02246 const static ULONG g_cXACTTC = NUMELE(g_rgXACTTC);
02247
02248
02249 ////////////////////////////////////////////////////////////////////////
02250 // OBJECTYTPEMAP
02251 //
02252 ////////////////////////////////////////////////////////////////////////
02253 const static WIDEGUIDMAP g_rgObjectTypeMaps[] =
02254 {
02255     VALUE_PWCHAR(DBGUID_DSO ),
02256   VALUE_PWCHAR(DBGUID_SESSION ),
02257   VALUE_PWCHAR(DBGUID_ROWSET  ),
02258   VALUE_PWCHAR(DBGUID_ROW ),
02259   VALUE_PWCHAR(DBGUID_COMMAND ),
02260   VALUE_PWCHAR(DBGUID_STREAM  ),
02261
02262   //Negative testing
02263   VALUE_PWCHAR(GUID_NULL  ),
02264 };
02265 const static ULONG g_cObjectTypeMaps = NUMELE(g_rgObjectTypeMaps);
02266
02267
02268 ////////////////////////////////////////////////////////////////////////
02269 // ROWCOLMAP
02270 //
02271 ////////////////////////////////////////////////////////////////////////
02272 const static WIDEDBIDMAP g_rgRowColMaps[] =
02273 {
02274   VALUE_PWCHAR(DBROWCOL_DEFAULTSTREAM),
02275   VALUE_PWCHAR(DBROWCOL_DEFAULTDOCUMENT),
02276   VALUE_PWCHAR(DBROWCOL_ROWURL),
02277   VALUE_PWCHAR(DBROWCOL_PARSENAME),
02278   VALUE_PWCHAR(DBROWCOL_PARENTNAME),
02279   VALUE_PWCHAR(DBROWCOL_ABSOLUTEPARSENAME),
02280   VALUE_PWCHAR(DBROWCOL_CONTENTTYPE),
02281   VALUE_PWCHAR(DBROWCOL_CONTENTCLASS),
02282   VALUE_PWCHAR(DBROWCOL_CONTENTLANGUAGE),
02283   VALUE_PWCHAR(DBROWCOL_CREATIONTIME),
02284   VALUE_PWCHAR(DBROWCOL_LASTACCESSTIME),
02285   VALUE_PWCHAR(DBROWCOL_LASTWRITETIME),
02286   VALUE_PWCHAR(DBROWCOL_STREAMSIZE),
02287   VALUE_PWCHAR(DBROWCOL_DISPLAYNAME),
02288   VALUE_PWCHAR(DBROWCOL_ISROOT),
02289   VALUE_PWCHAR(DBROWCOL_ISCOLLECTION),
02290   VALUE_PWCHAR(DBROWCOL_ISSTRUCTUREDDOCUMENT),
02291   VALUE_PWCHAR(DBROWCOL_ISHIDDEN),
02292   VALUE_PWCHAR(DBROWCOL_ISREADONLY),
02293
02294   //Negative testing
02295   VALUE_PWCHAR(DB_NULLID  ),
02296 };
02297 const static ULONG g_cRowColMaps = NUMELE(g_rgRowColMaps);
02298
02299
02300 ////////////////////////////////////////////////////////////////////////
02301 // WCHAR* GetRowColName
02302 //
02303 ////////////////////////////////////////////////////////////////////////
02304 WCHAR* GetRowColName(const DBID* pColumnid)
02305 {
02306   return GetMapName(pColumnid, g_cRowColMaps, g_rgRowColMaps);
02307 }
02308
02309
02310 ////////////////////////////////////////////////////////////////////////
02311 // DBPROMPTOPTIONS
02312 //
02313 ////////////////////////////////////////////////////////////////////////
02314 const static WIDENAMEMAP g_rgPromptOptions[] =
02315 {
02316   VALUE_WCHAR(DBPROMPTOPTIONS_WIZARDSHEET),
02317   VALUE_WCHAR(DBPROMPTOPTIONS_PROPERTYSHEET),
02318   VALUE_WCHAR(DBPROMPTOPTIONS_BROWSEONLY),
02319   VALUE_WCHAR(DBPROMPTOPTIONS_DISABLE_PROVIDER_SELECTION),
02320   VALUE_WCHAR(DBPROMPTOPTIONS_DISABLESAVEPASSWORD),
02321 };
02322 const static ULONG g_cPromptOptions = NUMELE(g_rgPromptOptions);
02323
02324
02325 ////////////////////////////////////////////////////////////////////////
02326 // DBSOURCETYPE
02327 //
02328 ////////////////////////////////////////////////////////////////////////
02329 const static WIDENAMEMAP g_rgSourceType[] =
02330 {
02331     VALUE_WCHAR(DBSOURCETYPE_DATASOURCE),
02332   VALUE_WCHAR(DBSOURCETYPE_ENUMERATOR),
02333   VALUE_WCHAR(DBSOURCETYPE_BINDER),
02334   VALUE_WCHAR(DBSOURCETYPE_DATASOURCE_MDP),
02335 };
02336 const static ULONG g_cSourceType = NUMELE(g_rgSourceType);
02337
02338
02339 ////////////////////////////////////////////////////////////////////////
02340 // DBBINDURLMAP
02341 //
02342 ////////////////////////////////////////////////////////////////////////
02343 const static WIDENAMEMAP g_rgBindURLMaps[] =
02344 {
02345     VALUE_WCHAR(DBBINDURLFLAG_READ),
02346   VALUE_WCHAR(DBBINDURLFLAG_WRITE),
02347   VALUE_WCHAR(DBBINDURLFLAG_READWRITE),
02348   VALUE_WCHAR(DBBINDURLFLAG_SHARE_DENY_READ),
02349   VALUE_WCHAR(DBBINDURLFLAG_SHARE_DENY_WRITE),
02350   VALUE_WCHAR(DBBINDURLFLAG_SHARE_EXCLUSIVE),
02351   VALUE_WCHAR(DBBINDURLFLAG_SHARE_DENY_NONE),
02352   VALUE_WCHAR(DBBINDURLFLAG_ASYNCHRONOUS),
02353   VALUE_WCHAR(DBBINDURLFLAG_COLLECTION),
02354   VALUE_WCHAR(DBBINDURLFLAG_DELAYFETCHSTREAM),
02355   VALUE_WCHAR(DBBINDURLFLAG_DELAYFETCHCOLUMNS),
02356   VALUE_WCHAR(DBBINDURLFLAG_RECURSIVE),
02357   VALUE_WCHAR(DBBINDURLFLAG_OUTPUT),
02358   VALUE_WCHAR(DBBINDURLFLAG_WAITFORINIT),
02359   VALUE_WCHAR(DBBINDURLFLAG_OPENIFEXISTS),
02360   VALUE_WCHAR(DBBINDURLFLAG_OVERWRITE),
02361   VALUE_WCHAR(DBBINDURLFLAG_ISSTRUCTUREDDOCUMENT),
02362 };
02363 const static ULONG g_cBindURLMaps = NUMELE(g_rgBindURLMaps);
02364
02365
02366 ////////////////////////////////////////////////////////////////////////
02367 // DBCONSTRAINTTYPE
02368 //
02369 ////////////////////////////////////////////////////////////////////////
02370 const static WIDENAMEMAP g_rgConsTypeMaps[] =
02371 {
02372   //Constraint Types
02373   VALUE_WCHAR(DBCONSTRAINTTYPE_UNIQUE),
02374   VALUE_WCHAR(DBCONSTRAINTTYPE_FOREIGNKEY),
02375   VALUE_WCHAR(DBCONSTRAINTTYPE_PRIMARYKEY),
02376   VALUE_WCHAR(DBCONSTRAINTTYPE_CHECK),
02377 };
02378 const static ULONG  g_cConsTypeMaps = NUMELE(g_rgConsTypeMaps);
02379
02380
02381 ////////////////////////////////////////////////////////////////////////
02382 // DBDEFERRABILITY
02383 //
02384 ////////////////////////////////////////////////////////////////////////
02385 const static WIDENAMEMAP g_rgDeferrabilityMaps[] =
02386 {
02387   //Deferrability flags
02388   VALUE_WCHAR(DBDEFERRABILITY_DEFERRED),
02389   VALUE_WCHAR(DBDEFERRABILITY_DEFERRABLE),
02390 };
02391 const static ULONG  g_cDeferrabilityMaps = NUMELE(g_rgDeferrabilityMaps);
02392
02393
02394 ////////////////////////////////////////////////////////////////////////
02395 // DBMATCHTYPE
02396 //
02397 ////////////////////////////////////////////////////////////////////////
02398 const static WIDENAMEMAP g_rgMatchTypeMaps[] =
02399 {
02400   //Match type values
02401   VALUE_WCHAR(DBMATCHTYPE_NONE),
02402   VALUE_WCHAR(DBMATCHTYPE_FULL),
02403   VALUE_WCHAR(DBMATCHTYPE_PARTIAL),
02404 };
02405 const static ULONG  g_cMatchTypeMaps = NUMELE(g_rgMatchTypeMaps);
02406
02407
02408 ////////////////////////////////////////////////////////////////////////
02409 // DBUPDELRULE
02410 //
02411 ////////////////////////////////////////////////////////////////////////
02412 const static WIDENAMEMAP g_rgUpDelRuleMaps[] =
02413 {
02414   //Update/Delete rule values
02415   VALUE_WCHAR(DBUPDELRULE_NOACTION),
02416   VALUE_WCHAR(DBUPDELRULE_CASCADE),
02417   VALUE_WCHAR(DBUPDELRULE_SETNULL),
02418   VALUE_WCHAR(DBUPDELRULE_SETDEFAULT),
02419 };
02420 const static ULONG  g_cUpDelRuleMaps = NUMELE(g_rgUpDelRuleMaps);
02421
02422
02423 ////////////////////////////////////////////////////////////////////////
02424 // DBCOLUMNDESCFLAGS
02425 //
02426 ////////////////////////////////////////////////////////////////////////
02427 const static WIDENAMEMAP g_rgCDFlagsMaps[] =
02428 {
02429   //Deferrability flags
02430   VALUE_WCHAR(DBCOLUMNDESCFLAGS_TYPENAME),
02431   VALUE_WCHAR(DBCOLUMNDESCFLAGS_ITYPEINFO),
02432   VALUE_WCHAR(DBCOLUMNDESCFLAGS_PROPERTIES),
02433   VALUE_WCHAR(DBCOLUMNDESCFLAGS_CLSID),
02434   VALUE_WCHAR(DBCOLUMNDESCFLAGS_COLSIZE),
02435   VALUE_WCHAR(DBCOLUMNDESCFLAGS_DBCID),
02436   VALUE_WCHAR(DBCOLUMNDESCFLAGS_WTYPE),
02437   VALUE_WCHAR(DBCOLUMNDESCFLAGS_PRECISION),
02438   VALUE_WCHAR(DBCOLUMNDESCFLAGS_SCALE),
02439 };
02440 const static ULONG  g_cCDFlagsMaps = NUMELE(g_rgCDFlagsMaps);
02441
02442
02443 ////////////////////////////////////////////////////////////////////////
02444 // WCHAR* GetObjectTypeName
02445 //
02446 ////////////////////////////////////////////////////////////////////////
02447 WCHAR* GetObjectTypeName(REFGUID rguidObjectType)
02448 {
02449   return GetMapName(rguidObjectType, g_cObjectTypeMaps, g_rgObjectTypeMaps);
02450 }
02451
02452
02453 ////////////////////////////////////////////////////////////////////////
02454 // WCHAR* GetPropertyName
02455 //
02456 ////////////////////////////////////////////////////////////////////////
02457 WCHAR* GetPropertyName(DBPROPID dwPropertyID, REFGUID guidPropertySet)
02458 {
02459   //Thankfully all OLE DB Properties have different DBPROPIDs, (all unique)
02460   //The problem is that provider specific properties may not be.
02461   //So if we know the set we can find the property, otherwsie we don't know it...
02462   ULONG cPropInfoSets = 0;
02463   const DBPROPINFOSET* rgPropInfoSets = NULL;
02464   DBPROPINFO* pPropInfo = NULL;
02465
02466   //Setup the info we are looking for...
02467   const ULONG cPropertyIDSets = 1;
02468   DBPROPIDSET rgPropertyIDSets[cPropertyIDSets];
02469   rgPropertyIDSets[0].cPropertyIDs = 0;
02470   rgPropertyIDSets[0].rgPropertyIDs = NULL;
02471   rgPropertyIDSets[0].guidPropertySet = guidPropertySet;
02472
02473   //Obtain the properties for the specified set...
02474   TESTC(GetStaticPropInfo(cPropertyIDSets, rgPropertyIDSets, &cPropInfoSets, &rgPropInfoSets));
02475
02476   //Now that we have the correct set, just obtain the sub element (property name)
02477   pPropInfo = FindProperty(dwPropertyID, guidPropertySet, cPropInfoSets, (DBPROPINFOSET*)rgPropInfoSets);
02478   if(pPropInfo)
02479     return pPropInfo->pwszDescription;
02480
02481 CLEANUP:
02482   return NULL;
02483 }
02484
02485
02486 ////////////////////////////////////////////////////////////////////////
02487 // WCHAR* GetPropSetName
02488 //
02489 ////////////////////////////////////////////////////////////////////////
02490 WCHAR* GetPropSetName(REFGUID guidPropertySet)
02491 {
02492   return GetMapName(guidPropertySet, g_cPropSetMaps, g_rgPropSetMaps);
02493 }
02494
02495
02496 ////////////////////////////////////////////////////////////////////////
02497 // LCID
02498 //
02499 ////////////////////////////////////////////////////////////////////////
02500 const static WIDENAMEMAP g_rgLCID[] =
02501 {
02502   VALUE_WCHAR(LOCALE_SYSTEM_DEFAULT),
02503   VALUE_WCHAR(LOCALE_USER_DEFAULT),
02504   VALUE_WCHAR(LOCALE_NEUTRAL),
02505   VALUE_WCHAR(GetSystemDefaultLCID()),
02506   VALUE_WCHAR(GetUserDefaultLCID()),
02507 };
02508 const static ULONG g_cLCID = NUMELE(g_rgLCID);
02509
02510
02511
02512 ////////////////////////////////////////////////////////////////////////
02513 // CHAR* GetMapName
02514 //
02515 ////////////////////////////////////////////////////////////////////////
02516 CHAR* GetMapName(LONG lItem, ULONG cNameMap, const NAMEMAP* rgNameMap)
02517 {
02518   for(ULONG i=0; i<cNameMap; i++)
02519   {
02520     if(lItem == rgNameMap[i].lItem)
02521       return rgNameMap[i].pszName;
02522   }
02523
02524   //Otherwise indicate failure
02525   return NULL;
02526 }
02527
02528
02529 ////////////////////////////////////////////////////////////////////////
02530 // GetMapName
02531 //
02532 ////////////////////////////////////////////////////////////////////////
02533 LONG GetMapName(WCHAR* pwsz, ULONG cNameMap, const WIDENAMEMAP* rgNameMap)
02534 {
02535   for(ULONG i=0; i<cNameMap; i++)
02536   {
02537     if(StringCompare(pwsz, rgNameMap[i].pwszName))
02538       return rgNameMap[i].lItem;
02539   }
02540
02541   //Otherwise indicate failure
02542   return -1;
02543 }
02544
02545 ////////////////////////////////////////////////////////////////////////
02546 // GetMapName
02547 //
02548 ////////////////////////////////////////////////////////////////////////
02549 LONG GetMapName(CHAR* psz, ULONG cNameMap, const NAMEMAP* rgNameMap)
02550 {
02551   for(ULONG i=0; i<cNameMap; i++)
02552   {
02553     if(strcmp(psz, rgNameMap[i].pszName)==0)
02554       return rgNameMap[i].lItem;
02555   }
02556
02557   //Otherwise indicate failure
02558   return -1;
02559 }
02560
02561
02562 ////////////////////////////////////////////////////////////////////////
02563 // WCHAR* GetMapName
02564 //
02565 ////////////////////////////////////////////////////////////////////////
02566 WCHAR* GetMapName(LONG lItem, ULONG cNameMap, const WIDENAMEMAP* rgNameMap, DWORD dwConvFlags)
02567 {
02568   for(ULONG i=0; i<cNameMap; i++)
02569   {
02570     if(lItem == rgNameMap[i].lItem)
02571       return rgNameMap[i].pwszName;
02572   }
02573
02574   if(dwConvFlags)
02575   {
02576     //If we didn't find it, then just format the value in a string
02577     //and return it to the user (if requested)...
02578     static WCHAR wszBuffer[MAX_NAME_LEN];
02579     if(dwConvFlags & CONV_HEX)
02580       StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%x", lItem);
02581     else
02582       StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", lItem);
02583     return wszBuffer;
02584   }
02585
02586   //Otherwise indicate failure
02587   return NULL;
02588 }
02589
02590
02591 ////////////////////////////////////////////////////////////////////////
02592 // WCHAR* GetBitMapName
02593 //
02594 ////////////////////////////////////////////////////////////////////////
02595 WCHAR* GetBitMapName(DWORD dwItem, ULONG cNameMap, const WIDENAMEMAP* rgNameMap, DWORD dwBitStart)
02596 {
02597   static WCHAR wszBuffer[MAX_NAME_LEN] = {0};
02598   DWORD dwItemBase = dwItem;
02599   DWORD dwFound = 0;
02600
02601   //NOTE: Some bitmasks, are actually composed of some sequental values, and then some bits.
02602   //For Example, DBTYPE_* contains sequential types upto a point, and then the rest are bit masks.
02603   //This function is designed to handle this case as well, dwBitStart denotes all bits that
02604   //are allowed to be on, all other values (non-indicated-bits) will be compared literally ie: (==).
02605   if(dwBitStart)
02606     dwItemBase &= ~dwBitStart;  //Remove all high order bits
02607
02608   for(ULONG i=0; i<cNameMap; i++)
02609   {
02610     //Does our item contains this particular bit?
02611     if(BIT_SET(dwItem, (DWORD)rgNameMap[i].lItem))
02612     {
02613       if(dwBitStart)
02614       {
02615         //If we are using a bitstart, then we need to make sure either this is one
02616         //of the special orable bits, or the items match exactly, if not then skip...
02617         if(! ((dwBitStart & rgNameMap[i].lItem) || dwItemBase == (DWORD)rgNameMap[i].lItem) )
02618           continue;
02619       }
02620
02621       if(dwFound)
02622       {
02623         wcscat(wszBuffer, L" | ");
02624         wcscat(wszBuffer, rgNameMap[i].pwszName);
02625       }
02626       else
02627       {
02628         wcscpy(wszBuffer, rgNameMap[i].pwszName);
02629       }
02630
02631       //NOTE: We keep track of all the "bits" we have found.
02632       dwFound |= rgNameMap[i].lItem;
02633     }
02634   }
02635
02636   //We keep track of all the bits we saw, so if at the end we didn't see some of the bits
02637   //then we just return the bits, and not an incorrect sub-set string mapping...
02638   if(dwFound != dwItem)
02639   {
02640     //Unknown, just display bitmask as hex
02641     StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", dwItem);
02642   }
02643
02644   //return
02645   return wszBuffer;
02646 }
02647
02648
02649 ////////////////////////////////////////////////////////////////////////
02650 // WCHAR* GetMapName
02651 //
02652 ////////////////////////////////////////////////////////////////////////
02653 WCHAR* GetMapName(REFGUID guid, ULONG cGuidMap, const WIDEGUIDMAP* rgGuidMap)
02654 {
02655   for(ULONG i=0; i<cGuidMap; i++)
02656   {
02657     if(guid == *(rgGuidMap[i].pGuid))
02658       return rgGuidMap[i].pwszName;
02659   }
02660
02661   //Otherwise indicate failure
02662   return NULL;
02663 }
02664
02665
02666 ////////////////////////////////////////////////////////////////////////
02667 // WCHAR* GetMapName
02668 //
02669 ////////////////////////////////////////////////////////////////////////
02670 WCHAR* GetMapName(const DBID* pDBID, ULONG cMap, const WIDEDBIDMAP* rgMap)
02671 {
02672   for(ULONG i=0; i<cMap; i++)
02673   {
02674     if(memcmp(pDBID, rgMap[i].pDBID, sizeof(DBID))==0)
02675       return rgMap[i].pwszName;
02676   }
02677
02678   //Otherwise indicate failure
02679   return NULL;
02680 }
02681
02682 ////////////////////////////////////////////////////////////////////////
02683 // CHAR* GetErrorName
02684 //
02685 ////////////////////////////////////////////////////////////////////////
02686 CHAR* GetErrorName(HRESULT hr)
02687 {
02688   return GetMapName(hr, NUMELE(g_rgErrorMap), g_rgErrorMap);
02689 }
02690
02691
02692 ////////////////////////////////////////////////////////////////////////
02693 // WCHAR* GetInterfaceName
02694 //
02695 ////////////////////////////////////////////////////////////////////////
02696 WCHAR* GetInterfaceName(REFIID riid)
02697 {
02698   return GetMapName(riid, NUMELE(g_rgInterfaceMaps), g_rgInterfaceMaps);
02699 }
02700
02701
02702 ////////////////////////////////////////////////////////////////////////
02703 //TODO: Remove once these are in our SQLOLEDB.H
02704 extern const GUID  DBGUID_MSSQLXML          = {0x5d531cb2L,0xe6ed,0x11d2,{0xb2,0x52,0x00,0xc0,0x4f,0x68,0x1b,0x71}};
02705 extern const GUID  DBGUID_XPATH             = {0xec2a4293L,0xe898,0x11d2,{0xb1,0xb7,0x00,0xc0,0x4f,0x68,0x0c,0x56}};
02706
02707 ////////////////////////////////////////////////////////////////////////
02708 // DialectMaps
02709 //
02710 ////////////////////////////////////////////////////////////////////////
02711 const static WIDEGUIDMAP g_rgDialectMaps[] =
02712 {
02713   VALUE_PWCHAR(DBGUID_DEFAULT ),
02714   VALUE_PWCHAR(DBGUID_SQL ),
02715   VALUE_PWCHAR(MDGUID_MDX ),
02716   VALUE_PWCHAR(DBGUID_MSSQLXML  ),
02717   VALUE_PWCHAR(DBGUID_XPATH ),
02718
02719   //Negative testing
02720   VALUE_PWCHAR(GUID_NULL  ),
02721 };
02722 const static ULONG g_cDialectMaps = NUMELE(g_rgDialectMaps);
02723
02724 ////////////////////////////////////////////////////////////////////////
02725 // WCHAR* GetDialectName
02726 //
02727 ////////////////////////////////////////////////////////////////////////
02728 WCHAR* GetDialectName(REFGUID rguid)
02729 {
02730   return GetMapName(rguid, g_cDialectMaps, g_rgDialectMaps);
02731 }
02732
02733
02734
02735 ////////////////////////////////////////////////////////////////////////
02736 // HRESULT DisplayBindingErrors
02737 //
02738 /////////////////////////////////////////////////////////////////////////////
02739 HRESULT DisplayBindingErrors(HRESULT hrReturned, DBCOUNTITEM cBindings, const DBBINDING* rgBindings, void* pData)
02740 {
02741   //Display the badstatus for pData operations.
02742   //(ie:  GetData / SetData / InsertRow)
02743   INT iSelect = 0;
02744
02745   //Binding Errors only occur with the following returned codes...
02746   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
02747     return hrReturned;
02748
02749   for(ULONG i=0; i<cBindings; i++)
02750   {
02751     ASSERT(rgBindings);
02752
02753     //If STATUS is not bound, we don't know if this binding failed or not.
02754     //And we can't really access the data or length, since we are not sure what the status is...
02755     if(!STATUS_IS_BOUND(rgBindings[i]))
02756       continue;
02757
02758     DBSTATUS dbStatus = BINDING_STATUS(rgBindings[i], pData);
02759     DBLENGTH dbLength = LENGTH_IS_BOUND(rgBindings[i]) ? BINDING_LENGTH(rgBindings[i], pData) : 0;
02760
02761     switch(dbStatus)
02762     {
02763       case DBSTATUS_S_OK:
02764       case DBSTATUS_S_ISNULL:
02765       case DBSTATUS_S_DEFAULT:
02766       case DBSTATUS_S_IGNORE:
02767         break;
02768
02769       //Display Status Error to the user...
02770       default:
02771       {
02772         iSelect = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
02773           L"Binding Status Errors:\n"
02774           L"rgBindings[%lu]\n\n"
02775           L"iOrdinal = %ld\n"
02776           L"wType = %s\n"
02777           L"cbMaxLen = %lu\n"
02778           L"bPrecision = %d\n"
02779           L"bScale = %d\n\n"
02780           L"DBSTATUS = %s\n"
02781           L"DBLENGTH = %lu\n",
02782           i,
02783           rgBindings[i].iOrdinal,
02784           GetDBTypeName(rgBindings[i].wType),
02785           rgBindings[i].cbMaxLen,
02786           rgBindings[i].bPrecision,
02787           rgBindings[i].bScale,
02788           GetStatusName(dbStatus),
02789           dbLength
02790           );
02791
02792         if(iSelect == IDCANCEL)
02793         {
02794           hrReturned = DB_E_CANCELED;
02795           goto CLEANUP;
02796         }
02797         break;
02798       }
02799     }
02800   }
02801
02802 CLEANUP:
02803   return hrReturned;
02804 }
02805
02806
02807 ////////////////////////////////////////////////////////////////////////
02808 // HRESULT DisplayColAccessErrors
02809 //
02810 /////////////////////////////////////////////////////////////////////////////
02811 HRESULT DisplayColAccessErrors(HRESULT hrReturned, DBORDINAL cColAccess, DBCOLUMNACCESS* rgColAccess)
02812 {
02813   //Display the badstatus for pData operations.
02814   //(ie:  GetData / SetData / InsertRow)
02815   INT iSelect = 0;
02816
02817   //Binding Errors only occur with the following returned codes...
02818   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
02819     return hrReturned;
02820
02821   for(ULONG i=0; i<cColAccess; i++)
02822   {
02823     ASSERT(rgColAccess);
02824     DBCOLUMNACCESS* pColAccess = &rgColAccess[i];
02825
02826     switch(pColAccess->dwStatus)
02827     {
02828       case DBSTATUS_S_OK:
02829       case DBSTATUS_S_ISNULL:
02830       case DBSTATUS_S_DEFAULT:
02831       case DBSTATUS_S_IGNORE:
02832         break;
02833
02834       default:
02835       {
02836         //Convert the Column ID into a string
02837         WCHAR wszBuffer[MAX_NAME_LEN] = {0};
02838         DBIDToString(&pColAccess->columnid, wszBuffer, MAX_NAME_LEN);
02839
02840         //Display Status Error to the user...
02841         iSelect = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
02842           L"ColumnAccess Status Errors:\n"
02843           L"rgColAccess[%lu]\n\n"
02844           L"columnid = %s\n"
02845           L"wType = %s\n"
02846           L"cbMaxLen = %lu\n"
02847           L"bPrecision = %d\n"
02848           L"bScale = %d\n\n"
02849           L"dwStatus = %s\n"
02850           L"cbDataLen = %lu\n",
02851           i,
02852           wszBuffer,
02853           GetDBTypeName(pColAccess->wType),
02854           pColAccess->cbMaxLen,
02855           pColAccess->bPrecision,
02856           pColAccess->bScale,
02857           GetStatusName(pColAccess->dwStatus),
02858           pColAccess->cbDataLen
02859           );
02860
02861         if(iSelect == IDCANCEL)
02862         {
02863           hrReturned = DB_E_CANCELED;
02864           goto CLEANUP;
02865         }
02866         break;
02867       }
02868     }
02869   }
02870
02871 CLEANUP:
02872   return hrReturned;
02873 }
02874
02875
02876 ////////////////////////////////////////////////////////////////////////
02877 // HRESULT DisplayColumnErrors
02878 //
02879 /////////////////////////////////////////////////////////////////////////////
02880 HRESULT DisplayColumnErrors(HRESULT hrReturned, DBORDINAL cColumns, DBID* rgColumns, DBSTATUS* rgStatus)
02881 {
02882   //Display the badstatus for pData operations.
02883   //(ie:  GetData / SetData / InsertRow)
02884   INT iSelect = 0;
02885
02886   //Binding Errors only occur with the following returned codes...
02887   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
02888     return hrReturned;
02889
02890   for(ULONG i=0; i<cColumns; i++)
02891   {
02892     ASSERT(rgColumns);
02893     DBID* pDBID = &rgColumns[i];
02894
02895     switch(rgStatus[i])
02896     {
02897       case DBSTATUS_S_OK:
02898       case DBSTATUS_S_ISNULL:
02899       case DBSTATUS_S_DEFAULT:
02900       case DBSTATUS_S_IGNORE:
02901         break;
02902
02903       default:
02904       {
02905         //Convert the Column ID into a string
02906         WCHAR wszBuffer[MAX_NAME_LEN] = {0};
02907         DBIDToString(pDBID, wszBuffer, MAX_NAME_LEN);
02908
02909         //Display Status Error to the user...
02910         iSelect = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
02911           L"Column Status Errors:\n"
02912           L"rgColumnIDs[%lu]\n\n"
02913           L"columnid = %s\n"
02914           L"dwStatus = %s\n",
02915           i,
02916           wszBuffer,
02917           GetStatusName(rgStatus[i])
02918           );
02919
02920         if(iSelect == IDCANCEL)
02921         {
02922           hrReturned = DB_E_CANCELED;
02923           goto CLEANUP;
02924         }
02925         break;
02926       }
02927     }
02928   }
02929
02930 CLEANUP:
02931   return hrReturned;
02932 }
02933
02934
02935 ////////////////////////////////////////////////////////////////////////
02936 // STATUSMAP
02937 //
02938 ////////////////////////////////////////////////////////////////////////
02939 const static WIDENAMEMAP g_rgRowStatusMap[] =
02940 {
02941     VALUE_WCHAR(DBROWSTATUS_S_OK  ),
02942   VALUE_WCHAR(DBROWSTATUS_S_MULTIPLECHANGES ),
02943   VALUE_WCHAR(DBROWSTATUS_S_PENDINGCHANGES  ),
02944   VALUE_WCHAR(DBROWSTATUS_E_CANCELED  ),
02945   VALUE_WCHAR(DBROWSTATUS_E_CANTRELEASE ),
02946   VALUE_WCHAR(DBROWSTATUS_E_CONCURRENCYVIOLATION  ),
02947   VALUE_WCHAR(DBROWSTATUS_E_DELETED ),
02948   VALUE_WCHAR(DBROWSTATUS_E_PENDINGINSERT ),
02949   VALUE_WCHAR(DBROWSTATUS_E_NEWLYINSERTED ),
02950   VALUE_WCHAR(DBROWSTATUS_E_INTEGRITYVIOLATION  ),
02951   VALUE_WCHAR(DBROWSTATUS_E_INVALID ),
02952   VALUE_WCHAR(DBROWSTATUS_E_MAXPENDCHANGESEXCEEDED  ),
02953   VALUE_WCHAR(DBROWSTATUS_E_OBJECTOPEN  ),
02954   VALUE_WCHAR(DBROWSTATUS_E_OUTOFMEMORY ),
02955   VALUE_WCHAR(DBROWSTATUS_E_PERMISSIONDENIED  ),
02956   VALUE_WCHAR(DBROWSTATUS_E_LIMITREACHED  ),
02957   VALUE_WCHAR(DBROWSTATUS_E_SCHEMAVIOLATION ),
02958   VALUE_WCHAR(DBROWSTATUS_E_FAIL  ),
02959
02960   //2.0
02961   VALUE_WCHAR(DBROWSTATUS_S_NOCHANGE  ),
02962 };
02963
02964
02965
02966 ////////////////////////////////////////////////////////////////////////
02967 // COLUMNFLAGSMAP
02968 //
02969 ////////////////////////////////////////////////////////////////////////
02970 const static WIDENAMEMAP g_rgColFlagsMaps[] =
02971 {
02972     VALUE_WCHAR(DBCOLUMNFLAGS_ISBOOKMARK),
02973   VALUE_WCHAR(DBCOLUMNFLAGS_MAYDEFER),
02974   VALUE_WCHAR(DBCOLUMNFLAGS_WRITE),
02975   VALUE_WCHAR(DBCOLUMNFLAGS_WRITEUNKNOWN),
02976   VALUE_WCHAR(DBCOLUMNFLAGS_ISFIXEDLENGTH),
02977   VALUE_WCHAR(DBCOLUMNFLAGS_ISNULLABLE),
02978   VALUE_WCHAR(DBCOLUMNFLAGS_MAYBENULL),
02979   VALUE_WCHAR(DBCOLUMNFLAGS_ISLONG),
02980   VALUE_WCHAR(DBCOLUMNFLAGS_ISROWID),
02981   VALUE_WCHAR(DBCOLUMNFLAGS_ISROWVER),
02982   VALUE_WCHAR(DBCOLUMNFLAGS_CACHEDEFERRED),
02983
02984   //1.5
02985     VALUE_WCHAR(DBCOLUMNFLAGS_ISCHAPTER),
02986
02987   //2.0
02988     VALUE_WCHAR(DBCOLUMNFLAGS_SCALEISNEGATIVE),
02989
02990     //2.1
02991   VALUE_WCHAR(DBCOLUMNFLAGS_ISROWURL),
02992   VALUE_WCHAR(DBCOLUMNFLAGS_ISDEFAULTSTREAM),
02993   VALUE_WCHAR(DBCOLUMNFLAGS_ISCOLLECTION),
02994
02995   //2.6
02996   VALUE_WCHAR(DBCOLUMNFLAGS_ISSTREAM),
02997   VALUE_WCHAR(DBCOLUMNFLAGS_ISROWSET),
02998   VALUE_WCHAR(DBCOLUMNFLAGS_ISROW),
02999   VALUE_WCHAR(DBCOLUMNFLAGS_ROWSPECIFICCOLUMN),
03000 };
03001 const static ULONG g_cColFlagsMaps = NUMELE(g_rgColFlagsMaps);
03002
03003
03004
03005 //////////////////////////////////////////////////////////////////////////////
03006 // DBRESULTFLAG
03007 //
03008 //////////////////////////////////////////////////////////////////////////////
03009 const static WIDENAMEMAP g_rgResultFlagMaps[] =
03010 {
03011   VALUE_WCHAR(DBRESULTFLAG_DEFAULT),
03012   VALUE_WCHAR(DBRESULTFLAG_ROWSET),
03013   VALUE_WCHAR(DBRESULTFLAG_ROW),
03014 };
03015 const static ULONG g_cResultFlagMaps = NUMELE(g_rgResultFlagMaps);
03016
03017
03018
03019 //////////////////////////////////////////////////////////////////////////////
03020 // GetPhaseName
03021 //
03022 //////////////////////////////////////////////////////////////////////////////
03023 WCHAR* GetPhaseName(DBEVENTPHASE ePhase)
03024 {
03025   const static WIDENAMEMAP  rgPhase[] =
03026   {
03027     VALUE_WCHAR(DBEVENTPHASE_OKTODO),
03028     VALUE_WCHAR(DBEVENTPHASE_ABOUTTODO),
03029     VALUE_WCHAR(DBEVENTPHASE_SYNCHAFTER),
03030     VALUE_WCHAR(DBEVENTPHASE_DIDEVENT),
03031     VALUE_WCHAR(DBEVENTPHASE_FAILEDTODO)
03032   };
03033
03034   return GetMapName(ePhase, NUMELE(rgPhase), rgPhase);
03035 }
03036
03037 //////////////////////////////////////////////////////////////////////////////
03038 // GetReasonName
03039 //
03040 //////////////////////////////////////////////////////////////////////////////
03041 WCHAR* GetReasonName(DBREASON eReason)
03042 {
03043   const static WIDENAMEMAP  rgReason[] =
03044   {
03045     VALUE_WCHAR(  DBREASON_ROWSET_FETCHPOSITIONCHANGE ),
03046     VALUE_WCHAR(  DBREASON_ROWSET_RELEASE ),
03047     VALUE_WCHAR(  DBREASON_COLUMN_SET ),
03048     VALUE_WCHAR(  DBREASON_COLUMN_RECALCULATED  ),
03049     VALUE_WCHAR(  DBREASON_ROW_ACTIVATE ),
03050     VALUE_WCHAR(  DBREASON_ROW_RELEASE  ),
03051     VALUE_WCHAR(  DBREASON_ROW_DELETE ),
03052     VALUE_WCHAR(  DBREASON_ROW_FIRSTCHANGE  ),
03053     VALUE_WCHAR(  DBREASON_ROW_INSERT ),
03054     VALUE_WCHAR(  DBREASON_ROW_RESYNCH  ),
03055     VALUE_WCHAR(  DBREASON_ROW_UNDOCHANGE ),
03056     VALUE_WCHAR(  DBREASON_ROW_UNDOINSERT ),
03057     VALUE_WCHAR(  DBREASON_ROW_UNDODELETE ),
03058     VALUE_WCHAR(  DBREASON_ROW_UPDATE ),
03059     VALUE_WCHAR(  DBREASON_ROWSET_CHANGED ),
03060
03061     VALUE_WCHAR( DBREASON_ROWPOSITION_CHANGED ),
03062     VALUE_WCHAR(  DBREASON_ROWPOSITION_CHAPTERCHANGED ),
03063     VALUE_WCHAR(  DBREASON_ROWPOSITION_CLEARED  ),
03064     VALUE_WCHAR(  DBREASON_ROW_ASYNCHINSERT ),
03065
03066 //    VALUE_WCHAR(  DBREASON_ROWSET_ROWSADDED ),
03067 //    VALUE_WCHAR(  DBREASON_ROWSET_POPULATIONCOMPLETE  ),
03068 //    VALUE_WCHAR(  DBREASON_ROWSET_POPULATIONSTOPPED ),
03069   };
03070
03071   return GetMapName(eReason, NUMELE(rgReason), rgReason);
03072 }
03073
03074
03075 //////////////////////////////////////////////////////////////////////////////
03076 // GetAsynchReason
03077 //
03078 //////////////////////////////////////////////////////////////////////////////
03079 WCHAR* GetAsynchReason(ULONG ulOperation)
03080 {
03081   const static WIDENAMEMAP  rgAsynchReason[] =
03082   {
03083     VALUE_WCHAR(  DBASYNCHOP_OPEN ),
03084   };
03085
03086   return GetMapName(ulOperation, NUMELE(rgAsynchReason), rgAsynchReason);
03087 }
03088
03089 //////////////////////////////////////////////////////////////////////////////
03090 // GetAsynchPhase
03091 //
03092 //////////////////////////////////////////////////////////////////////////////
03093 WCHAR* GetAsynchPhase(ULONG ulAsynchPhase)
03094 {
03095   const static WIDENAMEMAP  rgAsynchPhase[] =
03096   {
03097     VALUE_WCHAR(DBASYNCHPHASE_INITIALIZATION),
03098     VALUE_WCHAR(DBASYNCHPHASE_POPULATION),
03099     VALUE_WCHAR(DBASYNCHPHASE_COMPLETE),
03100     VALUE_WCHAR(DBASYNCHPHASE_CANCELED),
03101   };
03102
03103   return GetMapName(ulAsynchPhase, NUMELE(rgAsynchPhase), rgAsynchPhase);
03104 }
03105
03106
03107
03108 ////////////////////////////////////////////////////////////////////////
03109 // HRESULT DisplayRowErrors
03110 //
03111 /////////////////////////////////////////////////////////////////////////////
03112 HRESULT DisplayRowErrors(HRESULT hrReturned, DBROWCOUNT cRows, HROW* rghRows, DBROWSTATUS* rgRowStatus)
03113 {
03114   //Display the badstatus for row operations.
03115   INT iSelect = 0;
03116
03117   //Binding Errors only occur with the following returned codes...
03118   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
03119     return hrReturned;
03120
03121   for(LONG i=0; i<cRows; i++)
03122   {
03123     ASSERT(rghRows);
03124     ASSERT(rgRowStatus);
03125
03126     switch(rgRowStatus[i])
03127     {
03128       case DBROWSTATUS_S_OK:
03129         break;
03130
03131       //Display RowStatus Error to the user...
03132       default:
03133       {
03134         iSelect = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
03135           L"Row Status Errors:\n\n"
03136           L"rghRow[%lu] = 0x%p\n"
03137           L"DBROWSTATUS = %d=%s",
03138           i,
03139           rghRows[i],
03140           rgRowStatus[i],
03141           GetMapName(rgRowStatus[i], NUMELE(g_rgRowStatusMap), g_rgRowStatusMap)
03142           );
03143
03144         if(iSelect == IDCANCEL)
03145         {
03146           //NOTE: Will return DB_E_CANCELED if the user doesn't wish to continue
03147           hrReturned = DB_E_CANCELED;
03148           goto CLEANUP;
03149         }
03150         break;
03151       }
03152     }
03153   }
03154
03155 CLEANUP:
03156   return hrReturned;
03157 }
03158
03159
03160 ////////////////////////////////////////////////////////////////////////
03161 // STATUSMAP
03162 //
03163 ////////////////////////////////////////////////////////////////////////
03164 const static WIDENAMEMAP g_rgBindStatusMap[] =
03165 {
03166     VALUE_WCHAR(DBBINDSTATUS_OK ),
03167   VALUE_WCHAR(DBBINDSTATUS_BADORDINAL ),
03168   VALUE_WCHAR(DBBINDSTATUS_UNSUPPORTEDCONVERSION  ),
03169   VALUE_WCHAR(DBBINDSTATUS_BADBINDINFO  ),
03170   VALUE_WCHAR(DBBINDSTATUS_BADSTORAGEFLAGS  ),
03171   VALUE_WCHAR(DBBINDSTATUS_NOINTERFACE  ),
03172   VALUE_WCHAR(DBBINDSTATUS_MULTIPLESTORAGE  ),
03173 };
03174
03175
03176 ////////////////////////////////////////////////////////////////////////
03177 // HRESULT DisplayAccessorErrors
03178 //
03179 /////////////////////////////////////////////////////////////////////////////
03180 HRESULT DisplayAccessorErrors(HRESULT hrReturned, DBCOUNTITEM cBindings, const DBBINDING* rgBindings, DBBINDSTATUS* rgStatus)
03181 {
03182   //Display the badstatus for row operations.
03183   INT iSelect = 0;
03184
03185   //Binding Errors only occur with the following returned codes...
03186   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
03187     return hrReturned;
03188
03189   //Display any binding errors
03190   for(ULONG i=0; i<cBindings; i++)
03191   {
03192     ASSERT(rgBindings);
03193     ASSERT(rgStatus);
03194
03195     switch(rgStatus[i])
03196     {
03197       case DBBINDSTATUS_OK:
03198         break;
03199
03200       //Display BindStatus Error to the user...
03201       default:
03202       {
03203         iSelect = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
03204           L"Accessor BindStatus Errors:\n"
03205           L"rgBindings[%lu]\n\n"
03206           L"iOrdinal = %ld\n"
03207           L"wType = %s\n"
03208           L"cbMaxLen = %lu\n"
03209           L"bPrecision = %d\n"
03210           L"bScale = %d\n\n"
03211           L"DBBINDSTATUS = %s",
03212           i,
03213           rgBindings[i].iOrdinal,
03214           GetDBTypeName(rgBindings[i].wType),
03215           rgBindings[i].cbMaxLen,
03216           rgBindings[i].bPrecision,
03217           rgBindings[i].bScale,
03218           GetMapName(rgStatus[i], NUMELE(g_rgBindStatusMap), g_rgBindStatusMap)
03219           );
03220
03221         if(iSelect == IDCANCEL)
03222         {
03223           //NOTE: Will return DB_E_CANCELED if the user doesn't wish to continue
03224           hrReturned = DB_E_CANCELED;
03225           goto CLEANUP;
03226         }
03227         break;
03228       }
03229     }
03230   }
03231
03232 CLEANUP:
03233   return hrReturned;
03234 }
03235
03236
03237 ////////////////////////////////////////////////////////////////////////
03238 // HRESULT DisplayPropErrors
03239 //
03240 /////////////////////////////////////////////////////////////////////////////
03241 HRESULT DisplayPropErrors(HRESULT hrReturned, ULONG cPropSets, DBPROPSET* rgPropSets)
03242 {
03243   //Property Errors only occur with the following returned codes...
03244   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
03245     return hrReturned;
03246
03247   //Display all property errors...
03248   for(ULONG iPropSet=0; iPropSet<cPropSets; iPropSet++)
03249   {
03250     DBPROPSET* pPropSet = &rgPropSets[iPropSet];
03251     for(ULONG iProp=0; iProp<pPropSet->cProperties; iProp++)
03252     {
03253       DBPROP* pProp = &pPropSet->rgProperties[iProp];
03254       if(pProp->dwStatus != DBPROPSTATUS_OK)
03255       {
03256         WCHAR wszBuffer[MAX_NAME_LEN+1];
03257         WCHAR wszPropSet[MAX_NAME_LEN+1];
03258
03259         WCHAR* pwszPropSet = GetPropSetName(pPropSet->guidPropertySet);
03260         if(pwszPropSet == NULL)
03261         {
03262           StringFromGUID2(pPropSet->guidPropertySet, wszPropSet, MAX_NAME_LEN);
03263           pwszPropSet = wszPropSet;
03264         }
03265
03266         //Find property Value
03267         wszBuffer[0] = wEOL;
03268         VariantToString(&pProp->vValue, wszBuffer, MAX_NAME_LEN, CONV_VARBOOL);
03269
03270         //Append the Error
03271         INT iSelect = wMessageBox
03272           (
03273             GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
03274             L"Properties in Error:\n"
03275             L"rgPropSets[%d].rgProperties[%d]\n\n"
03276             L"guidPropertySet\t= %s\n"
03277             L"dwPropertyID\t= %s (0x%x)\n"
03278             L"dwOptions\t\t= %s\n"
03279             L"vValue.vt\t\t= %s\n"
03280             L"vValue\t\t= %s\n\n"
03281             L"dbStatus\t\t= %s",
03282             iPropSet,iProp,
03283             pwszPropSet,
03284             GetPropertyName(pProp->dwPropertyID, pPropSet->guidPropertySet),
03285             pProp->dwPropertyID,
03286             pProp->dwOptions == DBPROPOPTIONS_REQUIRED ? L"DBPROPOPTIONS_REQUIRED" : L"DBPROPOPTIONS_OPTIONAL",
03287             GetVariantTypeName(V_VT(&pProp->vValue)),
03288             wszBuffer,
03289             GetPropStatusName(pProp->dwStatus)
03290           );
03291
03292         if(iSelect == IDCANCEL)
03293         {
03294           //NOTE: Will return DB_E_CANCELED if the user doesn't wish to continue
03295           hrReturned = DB_E_CANCELED;
03296           goto CLEANUP;
03297         }
03298       }
03299     }
03300   }
03301
03302 CLEANUP:
03303   return hrReturned;
03304 }
03305
03306
03307 ////////////////////////////////////////////////////////////////////////
03308 // HRESULT DisplayPropErrors
03309 //
03310 /////////////////////////////////////////////////////////////////////////////
03311 HRESULT DisplayPropErrors(HRESULT hrReturned, ULONG cPropInfoSets, DBPROPINFOSET* rgPropInfoSets)
03312 {
03313   //Property Errors only occur with the following returned codes...
03314   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
03315     return hrReturned;
03316
03317   //Display all property errors...
03318   for(ULONG iPropInfoSet=0; iPropInfoSet<cPropInfoSets; iPropInfoSet++)
03319   {
03320     DBPROPINFOSET* pPropInfoSet = &rgPropInfoSets[iPropInfoSet];
03321     for(ULONG iPropInfo=0; iPropInfo<pPropInfoSet->cPropertyInfos; iPropInfo++)
03322     {
03323       DBPROPINFO* pPropInfo = &pPropInfoSet->rgPropertyInfos[iPropInfo];
03324       if(pPropInfo->dwFlags == DBPROPFLAGS_NOTSUPPORTED)
03325       {
03326         WCHAR wszBuffer[MAX_NAME_LEN+1];
03327         WCHAR wszPropSet[MAX_NAME_LEN+1];
03328
03329         WCHAR* pwszPropSet = GetPropSetName(pPropInfoSet->guidPropertySet);
03330         if(pwszPropSet == NULL)
03331         {
03332           StringFromGUID2(pPropInfoSet->guidPropertySet, wszPropSet, MAX_NAME_LEN);
03333           pwszPropSet = wszPropSet;
03334         }
03335
03336         //Find property Value
03337         wszBuffer[0] = wEOL;
03338         VariantToString(&pPropInfo->vValues, wszBuffer, MAX_NAME_LEN, CONV_VARBOOL);
03339
03340         //Append the Error
03341         INT iSelect = wMessageBox
03342           (
03343             GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OKCANCEL, wsz_ERROR,
03344             L"Properties in Error:\n"
03345             L"rgPropInfoSets[%d].rgPropertyInfos[%d]\n\n"
03346             L"guidPropertySet\t= %s\n"
03347             L"pwszDescription\t= %s\n"
03348             L"dwPropertyID\t= %s (0x%x)\n"
03349             L"vtType\t\t= %s\n"
03350             L"vValues\t\t= %s\n\n"
03351             L"dwFlags\t\t= %s (0x%x)",
03352             iPropInfoSet,iPropInfo,
03353             pwszPropSet,
03354             pPropInfo->pwszDescription,
03355             GetPropertyName(pPropInfo->dwPropertyID, pPropInfoSet->guidPropertySet),
03356             pPropInfo->dwPropertyID,
03357             GetVariantTypeName(pPropInfo->vtType),
03358             wszBuffer,
03359             L"DBPROPFLAGS_NOTSUPPORTED",
03360             pPropInfo->dwFlags
03361           );
03362
03363         if(iSelect == IDCANCEL)
03364         {
03365           //NOTE: Will return DB_E_CANCELED if the user doesn't wish to continue
03366           hrReturned = DB_E_CANCELED;
03367           goto CLEANUP;
03368         }
03369       }
03370     }
03371   }
03372
03373 CLEANUP:
03374   return hrReturned;
03375 }
03376
03377
03378 ////////////////////////////////////////////////////////////////////////
03379 // HRESULT DisplayPropErrors
03380 //
03381 /////////////////////////////////////////////////////////////////////////////
03382 HRESULT DisplayPropErrors(HRESULT hrReturned, REFIID riid, IUnknown* pIUnknown)
03383 {
03384   ASSERT(pIUnknown);
03385
03386   //Property Errors only occur with the following returned codes...
03387   if(hrReturned!=DB_S_ERRORSOCCURRED && hrReturned!=DB_E_ERRORSOCCURRED)
03388     return hrReturned;
03389
03390   //GetProperties with DBPROPSET_PROPERTIESINERROR.
03391   ULONG cPropSets = 0;
03392   DBPROPSET* rgPropSets = NULL;
03393   IDBProperties* pIDBProperties = NULL;
03394   ICommandProperties* pICommandProperties = NULL;
03395
03396   //Setup input DBPROPSET_PROPERTIESINERROR
03397   const ULONG cPropertyIDSets = 1;
03398   DBPROPIDSET rgPropertyIDSets[cPropertyIDSets];
03399   rgPropertyIDSets[0].guidPropertySet = DBPROPSET_PROPERTIESINERROR;
03400   rgPropertyIDSets[0].cPropertyIDs = 0;
03401   rgPropertyIDSets[0].rgPropertyIDs = NULL;
03402
03403   //Which GetProperties
03404   if(riid == IID_IDBProperties)
03405   {
03406     XTESTC(pIUnknown->QueryInterface(IID_IDBProperties, (void**)&pIDBProperties));
03407     XTESTC(pIDBProperties->GetProperties(cPropertyIDSets, rgPropertyIDSets, &cPropSets, &rgPropSets));
03408   }
03409   else
03410   {
03411     XTESTC(pIUnknown->QueryInterface(IID_ICommandProperties, (void**)&pICommandProperties));
03412     XTESTC(pICommandProperties->GetProperties(cPropertyIDSets, rgPropertyIDSets, &cPropSets, &rgPropSets));
03413   }
03414
03415   //Now delegate to display all properties in error
03416   TESTC(hrReturned = DisplayPropErrors(hrReturned, cPropSets, rgPropSets));
03417
03418 CLEANUP:
03419   FreeProperties(&cPropSets, &rgPropSets);
03420   SAFE_RELEASE(pICommandProperties);
03421   SAFE_RELEASE(pIDBProperties);
03422   return hrReturned;
03423 }
03424
03425
03426 ////////////////////////////////////////////////////////////////////////
03427 // HRESULT DisplayRefCountErrors
03428 //
03429 /////////////////////////////////////////////////////////////////////////////
03430 HRESULT DisplayRefCountErrors(WCHAR* pwszName, ULONG ulActRefCount, ULONG ulExpRefCount)
03431 {
03432   ASSERT(pwszName);
03433
03434   //Display RefCount difference...
03435   if(ulActRefCount != ulExpRefCount && GetErrorPosting(EP_REFCOUNT_FAILURE))
03436   {
03437     wMessageBox
03438       (
03439       GetFocus(),
03440       MB_TASKMODAL | MB_ICONERROR | MB_OK,
03441       wsz_ERROR,
03442       L"%s\n"
03443       L"RefCount = %d, Expected = %d",
03444       pwszName,
03445       ulActRefCount,
03446       ulExpRefCount
03447       );
03448   }
03449
03450   return S_OK;
03451 }
03452
03453
03454 ////////////////////////////////////////////////////////////////////////
03455 // HRESULT DisplayAllErrors
03456 //
03457 /////////////////////////////////////////////////////////////////////////////
03458 HRESULT DisplayAllErrors(HRESULT hrActual, WCHAR* pwszFile, ULONG ulLine, INT* piResult)
03459 {
03460   //Delegate
03461   //This function just verifies that the hreuslt succeeded...
03462   return DisplayAllErrors(hrActual, SUCCEEDED(hrActual) ? hrActual : S_OK, pwszFile, ulLine, piResult);
03463 }
03464
03465 ////////////////////////////////////////////////////////////////////////
03466 // HRESULT DisplayAllErrors
03467 //
03468 /////////////////////////////////////////////////////////////////////////////
03469 HRESULT DisplayAllErrors(HRESULT hrActual, HRESULT hrExpected, WCHAR* pwszFile, ULONG ulLine, INT* piResult)
03470 {
03471   BOOL bEqual = (hrActual == hrExpected) || (hrActual == S_OK);
03472
03473   //First Display any ErrorInfo
03474   //NOTE: If ErrorInfo=Always, ErrorInfo is always displayed
03475   if((!bEqual || GetErrorPosting(EP_ERRORINFO_ALWAYS)) && !GetErrorPosting(EP_ERRORINFO_NEVER))
03476   {
03477     if(DisplayErrorInfo(hrActual, pwszFile, ulLine, piResult)==S_OK)
03478     {
03479       //We had ErrorInfo, no need to display error info
03480       //Unless the user has something other than NOERRORINFO selected
03481       if(GetErrorPosting(EP_HRESULT_NOERRORINFO))
03482         goto CLEANUP;
03483     }
03484   }
03485
03486   //Second, Display the HRESULT, (if requested)
03487   //NOTE: If HRESULT=Always, Hresult is always displayed, except if S_OK is returned, otherwise you would always get message boxes...
03488   if((!bEqual || (hrActual!=S_OK && GetErrorPosting(EP_HRESULT_ALWAYS))) && !GetErrorPosting(EP_HRESULT_NEVER))
03489   {
03490     //Display the HRESULT
03491     DisplayHRESULT(hrActual, pwszFile, ulLine, piResult);
03492   }
03493
03494 CLEANUP:
03495   //We need to return a failure code if not equal, so we don't continue...
03496   if(!bEqual && SUCCEEDED(hrActual))
03497     return E_FAIL;
03498
03499   return hrActual;
03500 }
03501
03502
03503 //////////////////////////////////////////////////////////////////
03504 // DisplayWinError
03505 //
03506 //////////////////////////////////////////////////////////////////
03507 HRESULT DisplayWinError(DWORD dwError, WCHAR* pwszFile, LONG lLine, WCHAR* pwszText)
03508 {
03509   if(dwError)
03510   {
03511     CHAR* pszError = NULL;
03512
03513     //Format the Message (obtain the textual string)
03514     FormatMessageA(
03515       FORMAT_MESSAGE_ALLOCATE_BUFFER |
03516       FORMAT_MESSAGE_FROM_SYSTEM |
03517       FORMAT_MESSAGE_IGNORE_INSERTS,
03518       NULL,
03519       dwError,
03520       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
03521       (CHAR*)&pszError,
03522       0,
03523       NULL
03524     );
03525
03526     if(pszError)
03527     {
03528       //Display the Error
03529       wMessageBox
03530         (
03531         GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OK, wsz_ERROR,
03532         L"%s: GetLastError() = %d = %S" wWndEOL
03533         L"<File:%s>" wWndEOL
03534         L"Line:%d" wWndEOL,
03535         pwszText,
03536         dwError,
03537         pszError,
03538         pwszFile,
03539         lLine
03540         );
03541
03542       // Free the buffer.
03543       LocalFree( pszError );
03544     }
03545   }
03546
03547   return dwError;
03548 }
03549
03550
03551 ////////////////////////////////////////////////////////////////////////
03552 // HRESULT DisplayHRESULT
03553 //
03554 /////////////////////////////////////////////////////////////////////////////
03555 HRESULT DisplayHRESULT(HRESULT hrActual, WCHAR* pwszFile, ULONG ulLine, INT* piResult)
03556 {
03557   //If we end up here, their must not be any extended error info supported by the provider
03558   //the best we can do is display the HRESULT, and see of the system has a defined string
03559   //for the last error?
03560   CHAR* pszError = NULL;
03561   INT iResult = 0;
03562
03563   //Format the Message (obtain the textual string)
03564   FormatMessageA(
03565     FORMAT_MESSAGE_ALLOCATE_BUFFER |
03566     FORMAT_MESSAGE_FROM_SYSTEM |
03567     FORMAT_MESSAGE_IGNORE_INSERTS,
03568     NULL,
03569     hrActual,
03570     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
03571     (CHAR*)&pszError,
03572     0,
03573     NULL );
03574
03575   if(pszError)
03576   {
03577     //Display the Error (including Windows Defined String)
03578     iResult = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OK, wsz_ERROR,
03579       L"Interface: %s\nResult: 0x%08x = %S\n\nFormatMessage: \"%S\"\n\nFile: %s\nLine: %d", L"Unknown", hrActual, GetErrorName(hrActual), pszError, pwszFile, ulLine);
03580
03581     // Free the buffer from Format Message
03582     LocalFree( pszError );
03583   }
03584   else
03585   {
03586     //Display the Error
03587     iResult = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OK, wsz_ERROR,
03588       L"Interface: %s\nResult: 0x%08x = %S\n\nFile: %s\nLine: %d", L"Unknown", hrActual, GetErrorName(hrActual), pwszFile, ulLine);
03589   }
03590
03591   if(piResult)
03592     *piResult = iResult;
03593
03594   return hrActual;
03595 }
03596
03597
03598
03599 ////////////////////////////////////////////////////////////////////////
03600 // HRESULT DisplayErrorInfo
03601 //
03602 /////////////////////////////////////////////////////////////////////////////
03603 HRESULT DisplayErrorInfo(HRESULT hrActual, WCHAR* pwszFile, ULONG ulLine, INT* piResult)
03604 {
03605   HRESULT hr = S_OK;
03606
03607   CSmartPtr<IErrorInfo>   spErrorInfo;
03608   CSmartPtr<IErrorRecords>  spErrorRecords;
03609   ULONG cErrorRecords = 0;
03610
03611   CComBSTR cstrDescription;
03612   CComBSTR cstrSource;
03613   CComBSTR cstrSQLInfo;
03614   INT iResult = 0;
03615   static LCID lcid = GetSystemDefaultLCID();
03616
03617   //NOTE: GetErrorInfo will return S_OK and a NULL pointer if there is not error object
03618   if((hr = GetErrorInfo(0, &spErrorInfo))==S_OK && spErrorInfo)
03619   {
03620     //The Error Object may support multiple Errors (IErrorRecords)
03621     if(SUCCEEDED(hr = spErrorInfo->QueryInterface(&spErrorRecords)))
03622     {
03623       //Multiple Errors
03624       XTESTC(hr = spErrorRecords->GetRecordCount(&cErrorRecords));
03625     }
03626     else
03627     {
03628       //Only a single Error Object
03629       cErrorRecords = 1;
03630     }
03631
03632     LONG lNativeError = 0;
03633     ERRORINFO ErrorInfo = { hrActual, 0 };
03634
03635     //Loop through the records
03636     for(ULONG i=0; i<cErrorRecords; i++)
03637     {
03638       //For multiple errors, we will allow the user to cancel out of the dialogs
03639       //since the user may not be interested in clicking through many errors...
03640       //NOTE: This logic puts on the CANCEL button if more than 1 and not the last error...
03641       UINT uMBType = MB_TASKMODAL | MB_ICONERROR | MB_OK;
03642       if(i < (cErrorRecords-1))
03643         uMBType |= MB_OKCANCEL;
03644
03645       //ErrorRecords
03646       if(spErrorRecords)
03647       {
03648         spErrorInfo.Release();
03649         XTESTC(hr = spErrorRecords->GetErrorInfo(i, lcid, &spErrorInfo));
03650
03651         //Get the Basic ErrorInfo
03652         XTEST(hr = spErrorRecords->GetBasicErrorInfo(i, &ErrorInfo));
03653
03654         //Get the SQL Info
03655         GetSqlErrorInfo(i, spErrorRecords, &cstrSQLInfo, &lNativeError);
03656       }
03657       else
03658       {
03659         //ErrorInfo is only available...
03660         XTEST(hr = spErrorInfo->GetGUID(&ErrorInfo.iid));
03661       }
03662
03663       //Get the Description
03664       XTEST(hr = spErrorInfo->GetDescription(&cstrDescription));
03665
03666       //Get the Source - this will be the window title...
03667       XTEST(hr = spErrorInfo->GetSource(&cstrSource));
03668
03669       //Display the Error
03670       if(cstrSQLInfo)
03671       {
03672         iResult = wMessageBox(GetFocus(), uMBType, cstrSource ? cstrSource : wsz_ERRORINFO,
03673                 L"Source: \"%s\"\n\n"
03674                 L"Interface: %s\n"
03675                 L"Result: 0x%08x = %S\n\n"
03676                 L"ISQLErrorInfo: [%s][0x%08x]\n"
03677                 L"IErrorInfo: [0x%08x] \"%s\"\n\n"
03678                 L"File: %s\n"
03679                 L"Line: %d",
03680                 cstrSource,
03681                 GetInterfaceName(ErrorInfo.iid),
03682                 ErrorInfo.hrError, GetErrorName(ErrorInfo.hrError),
03683                 cstrSQLInfo, lNativeError,
03684                 ErrorInfo.dwMinor, cstrDescription,
03685                 pwszFile,
03686                 ulLine);
03687       }
03688       else
03689       {
03690         iResult = wMessageBox(GetFocus(), uMBType, cstrSource ? cstrSource : wsz_ERRORINFO,
03691                 L"Source: \"%s\"\n\n"
03692                 L"Interface: %s\n"
03693                 L"Result: 0x%08x = %S\n\n"
03694 //                L"ISQLErrorInfo: [%s][0x%08x]\n"
03695                 L"IErrorInfo: [0x%08x] \"%s\"\n\n"
03696                 L"File: %s\n"
03697                 L"Line: %d",
03698                 cstrSource,
03699                 GetInterfaceName(ErrorInfo.iid),
03700                 ErrorInfo.hrError, GetErrorName(ErrorInfo.hrError),
03701 //                cstrSQLInfo, lNativeError,
03702                 ErrorInfo.dwMinor, cstrDescription,
03703                 pwszFile,
03704                 ulLine);
03705       }
03706
03707       spErrorInfo.Release();
03708       cstrDescription.Empty();
03709       cstrSource.Empty();
03710       cstrSQLInfo.Empty();
03711
03712       if(iResult == IDCANCEL)
03713         goto CLEANUP;
03714     }
03715   }
03716
03717
03718 CLEANUP:
03719   if(piResult)
03720     *piResult = iResult;
03721   return hr;
03722 }
03723
03724
03725
03726 ////////////////////////////////////////////////////////////////////////
03727 // HRESULT GetSqlErrorInfo
03728 //
03729 // Get the error message generated by an OLE DB object
03730 /////////////////////////////////////////////////////////////////////////////
03731 HRESULT GetSqlErrorInfo(ULONG iRecord, IErrorRecords* pIErrorRecords, BSTR* pBstr, LONG* plNativeError)
03732 {
03733   ASSERT(pBstr);
03734   HRESULT hr = S_OK;
03735
03736   CSmartPtr<ISQLErrorInfo>  spSQLErrorInfo;
03737   LONG lNativeError = 0;
03738
03739   //Get the Error Records
03740   if(pIErrorRecords)
03741   {
03742     //If there is ErrorInfo, GetSQLInfo for the desired record
03743     //ISQLErrorInfo is not mandatory
03744     TESTC(hr = pIErrorRecords->GetCustomErrorObject(iRecord, IID_ISQLErrorInfo, (IUnknown**)&spSQLErrorInfo));
03745
03746     //If there was a CustomErrorObject
03747     if(spSQLErrorInfo)
03748       hr = spSQLErrorInfo->GetSQLInfo(pBstr, &lNativeError);
03749   }
03750
03751 CLEANUP:
03752   if(plNativeError)
03753     *plNativeError = lNativeError;
03754   return hr;
03755 }
03756
03757
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Intermediate/StdAfx.h Source File

  • Web
  • iis
  • Components
  • Cpp
  • Intermediate

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005
00006 #include <atlbase.h>
00007 #include <mtx.h>
00008 //You may derive a class from CComModule and use it if you want to override
00009 //something, but do not change the name of _Module
00010 extern CComModule _Module;
00011 #include <atlcom.h>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMShare/PreComp.h Source File

  • Web
  • NetMeeting
  • NMShare

PreComp.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMSHARE.EXE
00003 //  File:       PRECOMP.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #ifndef _PRECOMP_H
00017 #define _PRECOMP_H
00018
00019 // System Include files
00020 #include <windows.h>
00021 #include <windowsx.h>
00022 #include <commctrl.h>
00023 #include <tchar.h>
00024 #include <ocidl.h>
00025 #include <stdio.h>
00026
00027 #include "imsconf2.h"
00028
00029 #include "global.h"
00030 #include "clUtil.h"
00031 #include "cConf.h"
00032 #include "cShare.h"
00033 #include "cMemb.h"
00034
00035 #include "resource.h"
00036
00037 #endif /* _PRECOMP_H */
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCertEncodeStringArray Member List

This is the complete list of members for CCertEncodeStringArray, including all inherited members.
_Cleanup(VOID) | CCertEncodeStringArray | [private]
_SetErrorInfo(IN HRESULT hrError, IN WCHAR const *pwszDescription) | CCertEncodeStringArray | [private]
CCertEncodeStringArray() | CCertEncodeStringArray | [inline]
Encode(BSTR *pstrBinary) | CCertEncodeStringArray |
GetCount(LONG __RPC_FAR *pCount) | CCertEncodeStringArray |
GetValue(LONG Index, BSTR __RPC_FAR *pstr) | CCertEncodeStringArray |
m_aValue | CCertEncodeStringArray | [private]
m_cValue | CCertEncodeStringArray | [private]
m_cValuesSet | CCertEncodeStringArray | [private]
m_fConstructing | CCertEncodeStringArray | [private]
m_StringType | CCertEncodeStringArray | [private]
Reset(LONG Count, LONG StringType) | CCertEncodeStringArray |
SetValue(LONG Index, BSTR const str) | CCertEncodeStringArray |
~CCertEncodeStringArray() | CCertEncodeStringArray |
Generated on Wed Nov 13 2024 16:55:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyEvictListener/MyEvictListener.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyEvictListener

MyEvictListener.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      MyEvictListener.h
00005 //
00006 //  Description:
00007 //      Declaration of the CMyEvictListener class.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #pragma once
00012
00013 //
00014 // Categories and ClusCfg GUIDS
00015 //
00016 #include <ClusCfgGuids.h>
00017
00018 #include "resource.h"
00019
00020 //
00021 // Store the warning state.
00022 //
00023 #pragma warning( push )
00024
00025 //
00026 // Disable warning 4995. The text of the warning is below:
00027 // 'wsprintf': name was marked as #pragma deprecated
00028 //
00029 #pragma warning( disable : 4995 )
00030
00031 // {8097F026-7E96-4afa-B317-B35D8F88CFF7}
00032 DEFINE_GUID(CLSID_MyEvictListener,
00033 0x8097f026, 0x7e96, 0x4afa, 0xb3, 0x17, 0xb3, 0x5d, 0x8f, 0x88, 0xcf, 0xf7);
00034
00035 /////////////////////////////////////////////////////////////////////////////
00036 //++
00037 //
00038 // CMyEvictListener class definition
00039 //
00040 //--
00041 /////////////////////////////////////////////////////////////////////////////
00042 class CMyEvictListener
00043     : public CComObjectRootEx<CComMultiThreadModel>
00044     , public CComCoClass<CMyEvictListener, &CLSID_MyEvictListener>
00045     , public IClusCfgEvictListener
00046     , public IClusCfgInitialize
00047 {
00048 private:
00049     //
00050     // Locale id.
00051     //
00052     LCID                m_lcid;
00053
00054     //
00055     // Pointer to the callback interface.
00056     //
00057     IClusCfgCallback * m_piccCallback;
00058
00059 protected:
00060     //
00061     // Constructor and destructor
00062     //
00063     CMyEvictListener( void );
00064     ~CMyEvictListener( void );
00065
00066 public:
00067
00068     DECLARE_REGISTRY_RESOURCEID( IDR_MYEVICTLISTENER )
00069     DECLARE_NOT_AGGREGATABLE( CMyEvictListener )
00070
00071     DECLARE_PROTECT_FINAL_CONSTRUCT()
00072
00073     BEGIN_COM_MAP( CMyEvictListener )
00074         COM_INTERFACE_ENTRY( IClusCfgEvictListener )
00075         COM_INTERFACE_ENTRY( IClusCfgInitialize )
00076     END_COM_MAP()
00077
00078     BEGIN_CATEGORY_MAP( CMyEvictListener )
00079         IMPLEMENTED_CATEGORY( CATID_ClusCfgEvictListeners )
00080     END_CATEGORY_MAP()
00081
00082     //
00083     // IClusCfgEvictListener methods
00084     //
00085     STDMETHOD( EvictNotify ) ( LPCWSTR pcszNodeNameIn );
00086
00087     //
00088     //  IClusCfgInitialize methods
00089     //
00090     STDMETHOD( Initialize )(
00091           IUnknown *   punkCallbackIn
00092         , LCID         lcidIn
00093         );
00094
00095 }; //*** class: CMyEvictListener
00096
00097 //
00098 // Restore the warning state.
00099 //
00100 #pragma warning( pop )
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

dirlist Member List

This is the complete list of members for dirlist, including all inherited members.
bFile | dirlist
bSum | dirlist
dot | dirlist
pDescription | dirlist
pOtherDirList | dirlist
pPattern | dirlist
rootname | dirlist
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagPENSTYLELOOKUP Member List

This is the complete list of members for tagPENSTYLELOOKUP, including all inherited members.
iPenStyle | tagPENSTYLELOOKUP
wMenuItem | tagPENSTYLELOOKUP
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CNotify Member List

This is the complete list of members for CNotify, including all inherited members.
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Disconnect(void) | CNotify |
Disconnect(void) | CNotify |
Disconnect(void) | CNotify |
Disconnect(void) | CNotify |
Disconnect(void) | CNotify |
Disconnect(void) | CNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
m_dwCookie | CNotify | [private]
m_pcnp | CNotify | [private]
m_pcnpcnt | CNotify | [private]
m_pUnk | CNotify | [private]
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
Generated on Wed Nov 13 2024 16:56:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/Msi/process.dll/Process.cpp Source File

  • SysMgmt
  • Msi
  • process.dll

Process.cpp

Go to the documentation of this file.
00001 #if 0  // makefile definitions
00002 DESCRIPTION = Process UserAccounts Database Table
00003 MODULENAME = process
00004 FILEVERSION = Msi
00005 ENTRY = ProcessUserAccounts,UninstallUserAccounts
00006 LINKLIBS = netapi32.lib
00007 UNICODE=1
00008 !include "..\TOOLS\MsiTool.mak"
00009 !if 0  #nmake skips the rest of this file
00010 #endif // end of makefile definitions
00011
00012 // Required headers
00013 #define WINDOWS_LEAN_AND_MEAN  // faster compile
00014 #include <windows.h>
00015 #ifndef RC_INVOKED    // start of source code
00016
00017 #include "msiquery.h"
00018 #include <windows.h>
00019 #include <basetsd.h>
00020 #include <lm.h>
00021 #include "strsafe.h"
00022
00023 #define UNICODE 1
00024
00025 //+-------------------------------------------------------------------------
00026 //
00027 //  Microsoft Windows
00028 //
00029 //  Copyright (C) Microsoft Corporation, all rights reserved.
00030 //
00031 //  File:       process.cpp
00032 //
00033 //  Notes: DLL custom actions, must be used in conjunction with the DLL
00034 //         custom actions included in create.cpp and remove.cpp
00035 //--------------------------------------------------------------------------
00036
00037 //-----------------------------------------------------------------------------------------
00038 //
00039 // BUILD Instructions
00040 //
00041 // notes:
00042 //  - SDK represents the full path to the install location of the
00043 //     Windows Installer SDK
00044 //
00045 // Using NMake:
00046 //    %vcbin%\nmake -f process.cpp include="%include;SDK\Include" lib="%lib%;SDK\Lib"
00047 //
00048 // Using MsDev:
00049 //    1. Create a new Win32 DLL project
00050 //      2. Add process.cpp to the project
00051 //      3. Add SDK\Include and SDK\Lib directories on the Tools\Options Directories tab
00052 //      4. Add msi.libto the library list in the Project Settings dialog
00053 //          (in addition to the standard libs included by MsDev)
00054 //      5. Add /DUNICODE to the project options in the Project Settings dialog
00055 //
00056 //------------------------------------------------------------------------------------------
00057
00058
00059 /////////////////////////////////////////////////////////////////////////////
00060 // ClearSecret
00061 //
00062 //     Zeroes the secret data in the wszSecret buffer.  This is to reduce
00063 //     the amount of time the secret data is kept in clear text in memory.
00064 //
00065 void ClearSecret(WCHAR* wszSecret, DWORD cbSecret)
00066 {
00067   if (!wszSecret)
00068     return; // nothing to do
00069
00070   volatile char* vpch = (volatile char*)wszSecret;
00071   while (cbSecret)
00072   {
00073     *vpch = 0;
00074     vpch++;
00075     cbSecret--;
00076   }
00077 }
00078
00079 //////////////////////////////////////////////////////////////////////////
00080 // ProcessUserAccounts (resides in process.dll)
00081 //
00082 //     Process the UserAccounts custom table generating deferred actions
00083 //       to handle account creation (requires elevated priviledges) and
00084 //       rollback
00085 //
00086 UINT __stdcall ProcessUserAccounts(MSIHANDLE hInstall)
00087 {
00088   PMSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);
00089   if ( !hDatabase )
00090     return ERROR_INSTALL_FAILURE;
00091
00092   PMSIHANDLE hView = 0;
00093
00094   //
00095   // constants -- custom action names, SQL query, separator
00096   //
00097   // wszCreateCA = name of deferred CA to create account
00098   // wszRollbackCA = name of rollback CA to rollback account creation
00099   //
00100   const WCHAR wszCreateCA[] = L"CreateAccount";
00101   const WCHAR wszRollbackCA[] = L"RollbackAccount";
00102   const WCHAR wszSQL[] = L"SELECT `UserName`, `Password`, `Attributes` FROM `CustomUserAccounts`";
00103   const WCHAR wchSep = '\001';
00104
00105   UINT uiStat = ERROR_SUCCESS;
00106   if (ERROR_SUCCESS != (uiStat = MsiDatabaseOpenViewW(hDatabase, wszSQL, &hView)))
00107   {
00108     if (ERROR_BAD_QUERY_SYNTAX == uiStat
00109       && MSICONDITION_NONE == MsiDatabaseIsTablePersistentW(hDatabase, L"CustomUserAccounts"))
00110       return ERROR_SUCCESS; // table not present
00111     else
00112       return ERROR_INSTALL_FAILURE; // error -- should never happen
00113   }
00114   if (ERROR_SUCCESS != (uiStat = MsiViewExecute(hView, 0)))
00115     return ERROR_INSTALL_FAILURE; // error -- should never happen
00116
00117   // Fetch all entries from the CustomUserAccounts table
00118   PMSIHANDLE hRecFetch = 0;
00119   while (ERROR_SUCCESS == (uiStat = MsiViewFetch(hView, &hRecFetch)))
00120   {
00121     // Obtain user name
00122     WCHAR* wszUser = 0;
00123     DWORD cchUser = 0;
00124     if (ERROR_MORE_DATA != MsiRecordGetStringW(hRecFetch, 1, L"", &cchUser))
00125       return ERROR_INSTALL_FAILURE;
00126
00127     wszUser = new WCHAR[++cchUser];
00128     if ( !wszUser )
00129       return ERROR_INSTALL_FAILURE; // out of memory
00130
00131     if (ERROR_SUCCESS != MsiRecordGetStringW(hRecFetch, 1, wszUser, &cchUser))
00132     {
00133       delete [] wszUser;
00134       return ERROR_INSTALL_FAILURE; // error -- should never happen
00135     }
00136
00137     // Obtain name of property containing password
00138     WCHAR* wszPassWdProp = 0;
00139     DWORD cchPassWdProp = 0;
00140     if (ERROR_MORE_DATA != MsiRecordGetStringW(hRecFetch, 2, L"", &cchPassWdProp))
00141     {
00142       delete [] wszUser;
00143       return ERROR_INSTALL_FAILURE;
00144     }
00145
00146     wszPassWdProp = new WCHAR[++cchPassWdProp];
00147     if ( !wszPassWdProp )
00148     {
00149       delete [] wszUser;
00150       return ERROR_INSTALL_FAILURE; // out of memory
00151     }
00152
00153     if (ERROR_SUCCESS != MsiRecordGetStringW(hRecFetch, 2, wszPassWdProp, &cchPassWdProp))
00154     {
00155       delete [] wszUser;
00156       delete [] wszPassWdProp;
00157       return ERROR_INSTALL_FAILURE; // error -- should never happen
00158     }
00159
00160     // Obtain property value containing password
00161     WCHAR* wszAccountPassWd = 0;
00162     DWORD cchAccountPassWd = 0;
00163     if (ERROR_MORE_DATA != MsiGetProperty(hInstall, wszPassWdProp, L"", &cchAccountPassWd))
00164     {
00165       delete [] wszUser;
00166       delete [] wszPassWdProp;
00167       return ERROR_INSTALL_FAILURE;
00168     }
00169
00170     wszAccountPassWd = new WCHAR[++cchAccountPassWd];
00171     if ( !wszAccountPassWd )
00172     {
00173       delete [] wszUser;
00174       delete [] wszPassWdProp;
00175       return ERROR_INSTALL_FAILURE;
00176     }
00177
00178     ZeroMemory(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00179
00180     if (ERROR_SUCCESS != MsiGetProperty(hInstall, wszPassWdProp, wszAccountPassWd, &cchAccountPassWd)
00181       || *wszAccountPassWd == 0) // do not allow blank password
00182     {
00183       delete [] wszUser;
00184       delete [] wszPassWdProp;
00185       delete [] wszAccountPassWd;
00186       return ERROR_INSTALL_FAILURE;
00187     }
00188
00189     // Obtain attributes of user account
00190     WCHAR* wszAttrib  = 0;
00191     DWORD cchAttrib = 0;
00192     if (ERROR_MORE_DATA != MsiRecordGetStringW(hRecFetch, 3, L"", &cchAttrib))
00193     {
00194       delete [] wszUser;
00195       delete [] wszPassWdProp;
00196       ClearSecret(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00197       delete [] wszAccountPassWd;
00198       return ERROR_INSTALL_FAILURE;
00199     }
00200
00201     wszAttrib = new WCHAR[++cchAttrib];
00202     if ( !wszAttrib )
00203     {
00204       delete [] wszUser;
00205       delete [] wszPassWdProp;
00206       ClearSecret(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00207       delete [] wszAccountPassWd;
00208       return ERROR_INSTALL_FAILURE; // out of memory
00209     }
00210
00211     if (ERROR_SUCCESS != MsiRecordGetStringW(hRecFetch, 3, wszAttrib, &cchAttrib))
00212     {
00213       delete [] wszUser;
00214       delete [] wszPassWdProp;
00215       ClearSecret(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00216       delete [] wszAccountPassWd;
00217       delete [] wszAttrib;
00218       return ERROR_INSTALL_FAILURE; // error -- should never happen
00219     }
00220
00221     // Generate the customized property that the deferred action will read
00222     DWORD cchBuf = cchUser + cchAccountPassWd + cchAttrib + 4;
00223     WCHAR* wszBuf = new WCHAR[cchBuf];
00224     if ( !wszBuf )
00225     {
00226       delete [] wszUser;
00227       delete [] wszPassWdProp;
00228       ClearSecret(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00229       delete [] wszAccountPassWd;
00230       delete [] wszAttrib;
00231       return ERROR_INSTALL_FAILURE; // out of memory
00232     }
00233
00234     wszBuf[0] = 0;
00235
00236     if (FAILED(StringCchPrintfW(wszBuf, cchBuf, L"%s%c%s%c%s", wszUser, wchSep, wszAccountPassWd, wchSep, wszAttrib)))
00237     {
00238       delete [] wszUser;
00239       delete [] wszPassWdProp;
00240       ClearSecret(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00241       delete [] wszAccountPassWd;
00242       delete [] wszAttrib;
00243       delete [] wszBuf;
00244       return ERROR_INSTALL_FAILURE;
00245     }
00246
00247     // clear wszAccountPassWd
00248     ClearSecret(wszAccountPassWd, cchAccountPassWd*sizeof(WCHAR));
00249
00250
00251     // Add action data (template is in ActionText table), but do not display temp passwd
00252     PMSIHANDLE hRecInfo = MsiCreateRecord(2);
00253     if ( !hRecInfo
00254             || ERROR_SUCCESS != MsiRecordSetStringW(hRecInfo, 1, wszUser)
00255       || ERROR_SUCCESS != MsiRecordSetStringW(hRecInfo, 2, wszAttrib))
00256     {
00257       delete [] wszUser;
00258       delete [] wszPassWdProp;
00259       delete [] wszAccountPassWd;
00260       delete [] wszAttrib;
00261       ClearSecret(wszBuf, cchBuf*sizeof(WCHAR));
00262       delete [] wszBuf;
00263       return ERROR_INSTALL_FAILURE;
00264     }
00265
00266     int iRet = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecInfo);
00267     if (IDCANCEL == iRet || IDABORT == iRet)
00268     {
00269       delete [] wszUser;
00270       delete [] wszPassWdProp;
00271       delete [] wszAccountPassWd;
00272       delete [] wszAttrib;
00273       ClearSecret(wszBuf, cchBuf*sizeof(WCHAR));
00274       delete [] wszBuf;
00275       return ERROR_INSTALL_USEREXIT;
00276     }
00277
00278     // Rollback custom action goes first
00279     // Create a rollback custom action (in case install is stopped and rolls back)
00280     // Rollback custom action can't read tables, so we have to set a property
00281     if (ERROR_SUCCESS != MsiSetPropertyW(hInstall, wszRollbackCA, wszUser)
00282       || ERROR_SUCCESS != MsiDoActionW(hInstall, wszRollbackCA)
00283       || ERROR_SUCCESS != MsiSetPropertyW(hInstall, wszRollbackCA, L""))
00284     {
00285       delete [] wszUser;
00286       delete [] wszPassWdProp;
00287       delete [] wszAccountPassWd;
00288       delete [] wszAttrib;
00289       ClearSecret(wszBuf, cchBuf*sizeof(WCHAR));
00290       delete [] wszBuf;
00291       return ERROR_INSTALL_FAILURE;
00292     }
00293
00294     // Create a deferred custom action (gives us the right priviledges to create the user account)
00295     // Deferred custom actions can't read tables, so we have to set a property
00296     if (ERROR_SUCCESS != MsiSetPropertyW(hInstall, wszCreateCA, wszBuf)
00297       || ERROR_SUCCESS != MsiDoActionW(hInstall, wszCreateCA)
00298       || ERROR_SUCCESS != MsiSetPropertyW(hInstall, wszCreateCA, L""))
00299     {
00300       delete [] wszUser;
00301       delete [] wszPassWdProp;
00302       delete [] wszAccountPassWd;
00303       delete [] wszAttrib;
00304       ClearSecret(wszBuf, cchBuf*sizeof(WCHAR));
00305       delete [] wszBuf;
00306       return ERROR_INSTALL_FAILURE;
00307     }
00308
00309
00310     ClearSecret(wszBuf, cchBuf*sizeof(WCHAR));
00311     delete [] wszBuf;
00312     delete [] wszUser;
00313     delete [] wszPassWdProp;
00314     delete [] wszAccountPassWd;
00315     delete [] wszAttrib;
00316   }
00317   return (ERROR_NO_MORE_ITEMS != uiStat) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS;
00318 }
00319
00320 //////////////////////////////////////////////////////////////////////////
00321 // UninstallUserAccounts (resides in process.dll)
00322 //
00323 //     Process the UserAccounts custom table generating deferred actions
00324 //       to handle removal of user accounts
00325 //
00326 UINT __stdcall UninstallUserAccounts(MSIHANDLE hInstall)
00327 {
00328   //
00329   // constants -- custom action name SQL query
00330   //
00331   // wszRemoveCA = name of deferred CA to remove user account
00332   //
00333   const WCHAR wszRemoveCA[] = L"RemoveAccount";
00334   const WCHAR wszSQL[] = L"SELECT `UserName` FROM `CustomUserAccounts`";
00335
00336   PMSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);
00337   if ( !hDatabase )
00338     return ERROR_INSTALL_FAILURE;
00339
00340   PMSIHANDLE hView = 0;
00341
00342   UINT uiStat = ERROR_SUCCESS;
00343   if (ERROR_SUCCESS != (uiStat = MsiDatabaseOpenViewW(hDatabase, wszSQL, &hView)))
00344   {
00345     if (ERROR_BAD_QUERY_SYNTAX == uiStat
00346       && MSICONDITION_NONE == MsiDatabaseIsTablePersistentW(hDatabase, L"CustomUserAccounts"))
00347       return ERROR_SUCCESS; // table not present
00348     else
00349       return ERROR_INSTALL_FAILURE;
00350   }
00351
00352   if (ERROR_SUCCESS != MsiViewExecute(hView, 0))
00353     return ERROR_INSTALL_FAILURE; // error -- should never happen
00354
00355   // Fetch all entries from the UserAccounts custom table
00356   PMSIHANDLE hRecFetch = 0;
00357   while (ERROR_SUCCESS == (uiStat = MsiViewFetch(hView, &hRecFetch)))
00358   {
00359     // Obtain user name
00360     DWORD cchUser = 0;
00361     if (ERROR_MORE_DATA == MsiRecordGetStringW(hRecFetch, 1, L"", &cchUser))
00362     {
00363       WCHAR* wszUser = new WCHAR[++cchUser]; // add 1 for null-terminator which is not included in return count
00364       if (wszUser)
00365       {
00366         if (ERROR_SUCCESS == MsiRecordGetStringW(hRecFetch, 1, wszUser, &cchUser))
00367         {
00368           // Send ActionData message (template is in ActionText table)
00369           PMSIHANDLE hRecInfo = MsiCreateRecord(1);
00370           if ( !hRecInfo
00371             || ERROR_SUCCESS != MsiRecordSetStringW(hRecInfo, 1, wszUser))
00372           {
00373             delete [] wszUser;
00374             return ERROR_INSTALL_FAILURE;
00375           }
00376
00377           int iRet = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecInfo);
00378           if (IDCANCEL == iRet || IDABORT == iRet)
00379           {
00380             delete [] wszUser;
00381             return ERROR_INSTALL_USEREXIT;
00382           }
00383
00384           // We can't do a rollback custom action here (well, we could, but it wouldn't be correct)
00385           // After a user account has been deleted, it cannot be recreated exactly as it was before
00386           // because it will have been assigned a new SID.  In the case of uninstall, we won't
00387           // rollback the deletion.
00388
00389           // Create a deferred custom action (gives us the right priviledges to create the user account)
00390           // Deferred custom actions can't read tables, so we have to set a property
00391           if (ERROR_SUCCESS != MsiSetPropertyW(hInstall, wszRemoveCA, wszUser)
00392             || ERROR_SUCCESS != MsiDoActionW(hInstall, wszRemoveCA)
00393             || ERROR_SUCCESS != MsiSetPropertyW(hInstall, wszRemoveCA, L""))
00394           {
00395             delete [] wszUser;
00396             return ERROR_INSTALL_FAILURE;
00397           }
00398         }
00399         delete [] wszUser;
00400       }
00401       else
00402         return ERROR_INSTALL_FAILURE;
00403     }
00404     else
00405       return ERROR_INSTALL_FAILURE;
00406   }
00407   if (ERROR_NO_MORE_ITEMS != uiStat)
00408     return ERROR_INSTALL_FAILURE; // error -- should never happen
00409
00410   return ERROR_SUCCESS;
00411 }
00412
00413 #else // RC_INVOKED, end of source code, start of resources
00414 // resource definition go here
00415
00416 #endif // RC_INVOKED
00417 #if 0
00418 !endif // makefile terminator
00419 #endif
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/VCAcct/StdAfx.Cpp Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • VCAcct

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #include <initguid.h>
00008 #include <adoid.h>
00009 #include <adoint.h>
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
00017
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/sampver.h Source File

  • Dataaccess
  • oledb
  • sampprov

sampver.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB Version File
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module version include file
00008 //
00009 //
00010
00011 // Constants -----------------------------------------------------------------
00012 #ifndef _AXVER_H_
00013 #define _AXVER_H_
00014
00015 #define VER_FILEVERSION 2,50,4809.0
00016 #define VER_FILEVERSION_STR "2.50.4809.0\0"
00017 #define VER_PRODUCTVERSION 2,50,4809.0
00018 #define VER_PRODUCTVERSION_STR "2.50.4809.0\0"
00019
00020 #define VER_FILEFLAGSMASK   (VS_FF_DEBUG | VS_FF_PRERELEASE)
00021 #ifdef _DEBUG
00022 #define VER_FILEFLAGS     (VS_FF_DEBUG)
00023 #else
00024 #define VER_FILEFLAGS     (0)
00025 #endif
00026
00027 #define VER_FILEOS        VOS_NT_WINDOWS32
00028
00029 #define VER_COMPANYNAME_STR   "Microsoft Corporation\0"
00030 #define VER_PRODUCTNAME_STR   "Microsoft OLE DB\0"
00031 #define VER_LEGALCOPYRIGHT_STR  "Copyright \251 Microsoft Corporation 1991-1999\0"
00032
00033 // Resource DLL Version Resource ID
00034 #define IDS_RESDLL_VER      1
00035
00036 #endif
00037 //--------------------
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/PerfDllS/AppMem/pub/MemCtrnm.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • PerfDllS
  • AppMem
  • pub

MemCtrnm.h

Go to the documentation of this file.
00001 //
00002 //  memctrnm.h
00003 //
00004 //  Offset definition file for exensible counter objects and counters
00005 //
00006 //  These "relative" offsets must start at 0 and be multiples of 2 (i.e.
00007 //  even numbers). In the Open Procedure, they will be added to the
00008 //  "First Counter" and "First Help" values fo the device they belong to,
00009 //  in order to determine the  absolute location of the counter and
00010 //  object names and corresponding help text in the registry.
00011 //
00012 //  this file is used by the extensible counter DLL code as well as the
00013 //  counter name and help text definition file (.INI) file that is used
00014 //  by LODCTR to load the names into the registry.
00015 //
00016 #define APPMEMOBJ       0
00017 #define APPMEMALLOC     2
00018 #define APPALLOCS       4
00019 #define APPALLOCSSEC    6
00020 #define APPREALLOCS     8
00021 #define APPREALLOCSSEC  10
00022 #define APPFREES        12
00023 #define APPFREESSEC     14
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/precomp.cpp Source File

  • WinUI
  • TSFcase

precomp.cpp

Go to the documentation of this file.
00001 //
00002 // precomp.cpp
00003 //
00004 // Stub for vc precompiled header.
00005 //
00006
00007 #include "globals.h"
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CView Member List

This is the complete list of members for CView, including all inherited members.
_iScale | CView | [protected]
_ptClient | CView | [protected]
_ptOrg | CView | [protected]
_ptScroll | CView | [protected]
_size | CView | [protected]
CView(int cx, int cy) | CView |
Hittest(CCanvas &canvas, POINT pt, CModel *_pModel) | CView |
Invalidate(HWND hwnd, LPRECT lpRect=NULL) | CView |
Paint(CCanvas &canvas, CModel *_pModel, RECT rc) | CView |
Scroll(CCanvas &canvas) | CView | [protected]
SetSize(int cx, int cy) | CView |
Generated on Wed Nov 13 2024 16:57:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/BasicRecognition/BasicRecognition.cpp Source File

  • TabletPC
  • BasicRecognition

BasicRecognition.cpp

Go to the documentation of this file.
00001 //
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      BasicRecognition.cpp
00013 //
00014 // Description:
00015 //      This program demonstrates how you can build a basic handwriting
00016 //      recognition application using Microsoft Tablet PC Automation API.
00017 //
00018 //      This program co-creates an InkCollector object to enable inking
00019 //      in the window and a default recognition context object.
00020 //      Upon receiving the "Recognize!" command, fired from the application's menu,
00021 //      the collected ink strokes are passed to the recognition context
00022 //      and the best result string is presented in a message box.
00023 //
00024 //      (NOTE: For code simplicity, returned HRESULT is not checked
00025 //             on failure in the places where failures are not critical
00026 //             for the application or very unexpected)
00027 //
00028 //      This application is discussed in the Getting Started guide.
00029 //
00030 //      The interfaces used are:
00031 //      IInkCollector, IInkDisp, IInkStrokes
00032 //      IInkRecognizerContext, IInkRecognitionResult,
00033 //
00034 //--------------------------------------------------------------------------
00035
00036 #include <windows.h>
00037 #include <comdef.h>
00038 #include <msinkaut.h>
00039 #include <msinkaut_i.c>
00040 #include "resource.h"
00041
00042 // Global constants and variables.
00043 const TCHAR*    gc_szAppName = TEXT("Basic Recognition");
00044
00045 // Declare all necessary global interface pointers here
00046 IInkCollector *     g_pIInkCollector    = NULL;
00047 IInkDisp *          g_pIInkDisp         = NULL;
00048 IInkRecognizerContext *   g_pIInkRecoContext  = NULL;
00049
00050 /////////////////////////////////////////////////////////
00051 //
00052 // Cleanup
00053 //
00054 //      This method releases all the COM pointers held by the
00055 //      program. The order of the release does not matter.
00056 //
00057 /////////////////////////////////////////////////////////
00058 void CleanUp()  // Release all objects
00059 {
00060     if (g_pIInkRecoContext != NULL)
00061     {
00062         g_pIInkRecoContext->Release();
00063         g_pIInkRecoContext = NULL;
00064     }
00065
00066     if (g_pIInkDisp != NULL)
00067     {
00068         g_pIInkDisp->Release();
00069         g_pIInkDisp = NULL;
00070     }
00071
00072     if (g_pIInkCollector != NULL)
00073     {
00074         g_pIInkCollector->Release();
00075         g_pIInkCollector = NULL;
00076     }
00077 }
00078
00079 /////////////////////////////////////////////////////////
00080 //
00081 // WndProc
00082 //
00083 // Description of function/method
00084 //        The WindowProc function is an application-defined
00085 //        function that processes messages sent to a window
00086 //
00087 // Parameters:
00088 //        HWND hwnd      : [in] handle to window
00089 //        UINT uMsg      : [in] message identifier
00090 //        WPARAM wParam  : [in] first message parameter
00091 //        LPARAM lParam  : [in] second message parameter
00092 //
00093 // Return Values:
00094 //        The return value is the result of the
00095 //        message processing and depends on the message sent
00096 //
00097 /////////////////////////////////////////////////////////
00098 LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00099 {
00100     switch (uMsg)
00101     {
00102         case WM_CREATE:
00103         {
00104             HRESULT hr;
00105
00106
00107             // Create a recognition context that uses the default recognizer.
00108             // The single context will be used for all the recognition.
00109             hr = CoCreateInstance(CLSID_InkRecognizerContext,
00110                                   NULL, CLSCTX_INPROC_SERVER,
00111                                   IID_IInkRecognizerContext,
00112                                   (void **) &g_pIInkRecoContext);
00113             if (FAILED(hr))
00114             {
00115                 ::MessageBox(NULL, TEXT("There are no handwriting recognizers installed.\n")
00116                                    TEXT("You need to have at least one in order to run this sample.\nExiting."),
00117                      gc_szAppName, MB_ICONERROR);
00118                 return -1;
00119             }
00120
00121             // Create the InkCollector object.
00122             hr = CoCreateInstance(CLSID_InkCollector,
00123                                   NULL, CLSCTX_INPROC_SERVER,
00124                                   IID_IInkCollector,
00125                                   (void **) &g_pIInkCollector);
00126             if (FAILED(hr))
00127                 return -1;
00128
00129             // Get a pointer to the Ink object
00130             hr = g_pIInkCollector->get_Ink(&g_pIInkDisp);
00131             if (FAILED(hr))
00132                 return -1;
00133
00134             // Tell InkCollector the window to collect ink in
00135             hr = g_pIInkCollector->put_hWnd((long)hwnd);
00136             if (FAILED(hr))
00137                 return -1;
00138
00139             // Enable ink input in the window
00140             hr = g_pIInkCollector->put_Enabled(VARIANT_TRUE);
00141             if (FAILED(hr))
00142                 return -1;
00143
00144             break;
00145         }
00146
00147         case WM_DESTROY:
00148
00149             PostQuitMessage(0);
00150             break;
00151
00152         case WM_COMMAND:
00153
00154             if (wParam == ID_CLEAR)
00155             {
00156                 // Delete all strokes from the Ink
00157                 g_pIInkDisp->DeleteStrokes(0);
00158
00159                 // Update the window
00160                 InvalidateRect(hwnd, NULL, TRUE);
00161             }
00162             else if (wParam == ID_RECOGNIZE)
00163             {
00164                 // change cursor to the system's Hourglass
00165                 HCURSOR hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));
00166                 // Get a pointer to the ink stroke collection
00167                 // This collection is a snapshot of the entire ink object
00168                 IInkStrokes* pIInkStrokes = NULL;
00169                 HRESULT hr = g_pIInkDisp->get_Strokes(&pIInkStrokes);
00170                 if (SUCCEEDED(hr))
00171                 {
00172                     // Pass the stroke collection to the recognition context
00173                     hr = g_pIInkRecoContext->putref_Strokes(pIInkStrokes);
00174                     if (SUCCEEDED(hr))
00175                     {
00176                         // Recognize
00177                         IInkRecognitionResult* pIInkRecoResult = NULL;
00178                         InkRecognitionStatus RecognitionStatus;
00179                         hr = g_pIInkRecoContext->Recognize(&RecognitionStatus, &pIInkRecoResult);
00180                         if (SUCCEEDED(hr) && (pIInkRecoResult!= NULL))
00181                         {
00182                             // Get the best result of the recognition
00183                             BSTR bstrBestResult = NULL;
00184                             hr = pIInkRecoResult->get_TopString(&bstrBestResult);
00185                             pIInkRecoResult->Release();
00186                             pIInkRecoResult = NULL;
00187
00188                             // Show the result string
00189                             if (SUCCEEDED(hr) && bstrBestResult)
00190                             {
00191                                 MessageBoxW(hwnd, bstrBestResult,
00192                                             L"Recognition Results", MB_OK);
00193                                 SysFreeString(bstrBestResult);
00194                             }
00195                         }
00196                         // Reset the recognition context
00197                         g_pIInkRecoContext->putref_Strokes(NULL);
00198                     }
00199                     pIInkStrokes->Release();
00200                 }
00201                 // restore the cursor
00202                 ::SetCursor(hCursor);
00203             }
00204             else
00205             {
00206                 return DefWindowProc(hwnd, uMsg, wParam, lParam);
00207             }
00208             break;
00209
00210         default:
00211             return DefWindowProc(hwnd, uMsg, wParam, lParam);
00212     }
00213
00214     return 0;
00215 }
00216
00217 /////////////////////////////////////////////////////////
00218 //
00219 // RegisterWindowClass
00220 //
00221 // The RegisterWindowClass function registers a window class for
00222 // subsequent use in calls to the CreateWindow or CreateWindowEx function.
00223 //
00224 // Parameters:
00225 //        HINSTANCE hInstance : [in] Handle to the instance that
00226 //                              contains the window procedure for the class.
00227 //
00228 // Return Values:
00229 //        TRUE : Success
00230 //        FALSE : Failure to register the class
00231 //
00232 /////////////////////////////////////////////////////////
00233 BOOL RegisterWindowClass(HINSTANCE hInstance)
00234 {
00235     WNDCLASSEX WndClassEx;
00236
00237     WndClassEx.cbSize        = sizeof(WndClassEx);
00238     WndClassEx.style         = CS_HREDRAW | CS_VREDRAW;
00239     WndClassEx.lpfnWndProc   = WndProc;
00240     WndClassEx.cbClsExtra    = 0;
00241     WndClassEx.cbWndExtra    = 0;
00242     WndClassEx.hInstance     = hInstance;
00243     WndClassEx.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
00244     WndClassEx.hIconSm       = WndClassEx.hIcon;
00245     WndClassEx.hCursor       = LoadCursor(NULL, IDC_ARROW);
00246     WndClassEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
00247     WndClassEx.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU);
00248     WndClassEx.lpszClassName = gc_szAppName;
00249
00250     if (!RegisterClassEx(&WndClassEx))
00251     {
00252         MessageBox(NULL, TEXT("Failed to register window class!"),
00253                    gc_szAppName, MB_ICONERROR);
00254         return false;
00255     }
00256
00257     return true;
00258 }
00259
00260 /////////////////////////////////////////////////////////
00261 //
00262 // WinMain
00263 //
00264 //      The WinMain function is called by the system as the
00265 //      initial entry point for a Win32-based application.
00266 //      It contains typical boilerplate code to create and
00267 //      show the main window, and pump messages.
00268 //
00269 // Parameters:
00270 //      HINSTANCE hInstance,      : [in] handle to current instance
00271 //      HINSTANCE hPrevInstance,  : [in] handle to previous instance
00272 //      LPSTR lpCmdLine,          : [in] command line
00273 //      int nCmdShow              : [in] show state
00274 //
00275 // Return Values:
00276 //      0 : The function terminated before entering the message loop.
00277 //      non zero: Value of the wParam when receiving the WM_QUIT message
00278 //
00279 /////////////////////////////////////////////////////////
00280 int APIENTRY WinMain(HINSTANCE hInstance,
00281                      HINSTANCE hPrevInstance,
00282                      LPSTR     lpCmdLine,
00283                      int       nCmdShow)
00284 {
00285     if (!RegisterWindowClass(hInstance))
00286         return 0;
00287
00288     CoInitialize(NULL);
00289
00290     // Create the application window
00291     HWND hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, gc_szAppName, gc_szAppName,
00292                                WS_OVERLAPPEDWINDOW,
00293                                CW_USEDEFAULT, CW_USEDEFAULT,
00294                                CW_USEDEFAULT, CW_USEDEFAULT,
00295                                NULL, NULL, hInstance, NULL);
00296     if (NULL == hWnd)
00297     {
00298         MessageBox(NULL, TEXT("Error creating the window"), TEXT("Error"),
00299                    MB_OK | MB_ICONINFORMATION);
00300         return 0;
00301     }
00302
00303     // Show the main window
00304     ShowWindow(hWnd, nCmdShow);
00305     UpdateWindow(hWnd);
00306
00307     // Start the boilerplate message loop
00308     MSG msg;
00309     while (GetMessage(&msg, NULL, 0, 0) > 0)
00310     {
00311         TranslateMessage(&msg);
00312         DispatchMessage(&msg);
00313     }
00314
00315     CleanUp();
00316     CoUninitialize();
00317
00318     return msg.wParam;
00319 }
00320
00321
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Registry/Monkey.c Source File

  • WinBase
  • Registry

Monkey.c

Go to the documentation of this file.
00001
00002 /******************************************************************************
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00009
00010 This source code is only intended as a supplement to Microsoft Development
00011 Tools and/or WinHelp documentation.  See these sources for detailed information
00012 regarding the Microsoft samples programs.
00013 ******************************************************************************/
00014
00015 /*************************************************************************\
00016 *
00017 *  PROGRAM: Monkey: the Registry Monkey Utility.
00018 *  PURPOSE: To demonstrate Registry API.
00019 *  COMMENTS:
00020 *
00021 \*************************************************************************/
00022
00023
00024 #define STRICT
00025 #include <windows.h>
00026 #include <string.h>
00027 #define _MBCS
00028 #include <mbstring.h>
00029 #include <stdlib.h>
00030 #include <stdio.h>
00031 #include "monkey.h"
00032
00033
00034 HANDLE hInst;
00035 HWND   hDlg;
00036
00037 HANDLE hHeap;
00038
00039
00040 /*************************************************************************\
00041 *
00042 *  FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
00043 *
00044 *  PURPOSE: Creates the dialogbox.
00045 *
00046 *  COMMENTS:
00047 *
00048 \*************************************************************************/
00049
00050 int APIENTRY WinMain (HINSTANCE hInstance,
00051                       HINSTANCE hPrevInstance,
00052                       LPSTR     lpCmdLine,
00053                       int       nCmdShow)
00054
00055
00056 {
00057     DWORD retCode;
00058
00059     UNREFERENCED_PARAMETER( nCmdShow );
00060     UNREFERENCED_PARAMETER( lpCmdLine );
00061     UNREFERENCED_PARAMETER( hPrevInstance );
00062
00063     hInst   = hInstance;
00064     hHeap   = HeapCreate (0, 0, 0);
00065
00066     retCode = (int)DialogBox ((HANDLE)hInst, (LPCSTR)"MonkeyDlg",
00067                               NULL, (DLGPROC)MonkeyDlgProc);
00068
00069     HeapDestroy (hHeap);
00070     return(retCode);
00071
00072 }
00073
00074 /************************************************************************\
00075 *
00076 *  FUNCTION: MonkeyDlgProc();
00077 *
00078 *  PURPOSE:  Handle the Monkey dialog box messages.
00079 *
00080 *  MESSAGES:
00081 *
00082 *    WM_INITDIALOG  - Posts WM_GETFIRSTKEY message.
00083 *
00084 *    WM_GETFIRSTKEY - Puts the first 4 pre-defined keys in the listbox.
00085 *
00086 *    IDL_LISTBOX    - Trapped when an item in the left hand listbox
00087 *                     has been double clicked.  It posts a IDB_NEXT message.
00088 *
00089 *    IDL_LISTBOX2   - Trapped when an item in the right hand listbox has
00090 *                     been double clicked.  It basically calls DisplayKeyData,
00091 *                     which fills the Value edit fields with the data from
00092 *                     the current key's specified value information.
00093 *
00094 *    IDB_PRINT      - Basically calls PrintTree() which does a recursive
00095 *                     print of the Registry from the current key to the
00096 *                     end of it's branches.
00097 *
00098 *    IDB_BACK       - Sets the dialog box with the information from the
00099 *                     previously selected key (one closer to the root of
00100 *                     the registry, the parent of the current key).
00101 *
00102 *    IDB_NEXT       - Sets the dialog box with the information on the
00103 *                     selected key child.
00104 *
00105 *    IDR_FULL       - Sets a global variable used to determine if the
00106 *                     user wants to print full Registry information
00107 *                     or only information from keys that have value
00108 *                     associated with it.  Variable is set to TRUE.
00109 *
00110 *    IDR_TRIMMED    - Same as above, only the variable is set to FALSE.
00111 *
00112 \************************************************************************/
00113
00114 int APIENTRY MonkeyDlgProc (HWND hDlg, WORD wMsg, LONG wParam, LONG lParam)
00115 {
00116     ULONG    KeyClassLength = 256;
00117     ULONG    KeyNameLength = 256;
00118     LRESULT  indexLB;
00119     CHAR     *putNullAt;
00120     CHAR     lpBuffer1[128];
00121     CHAR     lpBuffer2[128];
00122
00123     static   CHAR     RegPath[MAX_PATH]  = "";
00124     static   CHAR     NameLBSelect[256]  = "";
00125     static   HKEY     hKeyRoot;
00126     static   DWORD    RegLevel;
00127     static   BOOL     FullBranches = TRUE;
00128
00129     static   HANDLE   hFile = INVALID_HANDLE_VALUE;
00130     static   HANDLE   hBootIni;
00131
00132     UNREFERENCED_PARAMETER( lParam );
00133
00134     switch (wMsg)
00135     {
00136     case WM_INITDIALOG:
00137         // Post a message to get the first 4 pre-defined keys, and set
00138         // Full Branches to be the print default.
00139         PostMessage (hDlg, WM_GETFIRSTKEY, 0, 0);
00140         CheckDlgButton (hDlg, IDR_FULL, TRUE);
00141         return(0);
00142
00143     case WM_GETFIRSTKEY:
00144         // Initialize by putting the first 4 predefined keys of the
00145         // registry in the list box.
00146
00147         SendMessage (GetDlgItem(hDlg, IDL_LISTBOX),
00148                      LB_ADDSTRING, 0, (LPARAM)"HKEY_LOCAL_MACHINE");
00149
00150         SendMessage (GetDlgItem(hDlg, IDL_LISTBOX),
00151                      LB_ADDSTRING, 0, (LPARAM)"HKEY_CURRENT_USER");
00152
00153         SendMessage (GetDlgItem(hDlg, IDL_LISTBOX),
00154                      LB_ADDSTRING, 0, (LPARAM)"HKEY_USERS");
00155
00156         SendMessage (GetDlgItem(hDlg, IDL_LISTBOX),
00157                      LB_ADDSTRING, 0, (LPARAM)"HKEY_CLASSES_ROOT");
00158
00159         hKeyRoot = 0;                   // Initialize hKeyRoot.
00160         return(0);
00161
00162     case WM_SYSCOMMAND:
00163         if (wParam == SC_CLOSE)
00164         {
00165             EndDialog (hDlg, TRUE);
00166             if (hFile != INVALID_HANDLE_VALUE)
00167                 CloseHandle (hFile);
00168             return(TRUE);
00169         }
00170         break;
00171
00172     case WM_COMMAND:
00173
00174         switch (LOWORD(wParam))
00175         {
00176         case IDR_FULL:
00177             // If Full Branches pressed, set global var to TRUE.
00178             FullBranches = TRUE;
00179             return(0);
00180
00181         case IDR_TRIMMED:
00182             // If Trimmed Branches pressed, set global var to FALSE.
00183             FullBranches = FALSE;
00184             return(0);
00185
00186         case IDL_LISTBOX:
00187             // If double click in left hand listbox, clear Value
00188             // edit fields, and execute Next functionality.
00189             if ( HIWORD (wParam) == LBN_DBLCLK)
00190             {
00191                 SetDlgItemText (hDlg, IDE_VALUE1, "");
00192                 SetDlgItemText (hDlg, IDE_VALUE2, "");
00193                 PostMessage (hDlg, WM_COMMAND, IDB_NEXT, 0);
00194             }
00195             return(0);
00196
00197         case IDL_LISTBOX2:
00198             // If double click right hand listbox, clear Value edit
00199             // fields, then display the key's data.
00200             if ( HIWORD (wParam) == LBN_DBLCLK)
00201             {
00202                 SetDlgItemText (hDlg, IDE_VALUE1, "");
00203                 SetDlgItemText (hDlg, IDE_VALUE2, "");
00204                 DisplayKeyData (hDlg, RegPath, hKeyRoot);
00205             }
00206             return(0);
00207
00208
00209         case IDB_NEXT:
00210             // Get the index of the cursor selection
00211             // in the list box.
00212             indexLB = SendMessage (GetDlgItem (hDlg, IDL_LISTBOX),
00213                                    LB_GETCURSEL, 0, 0);
00214
00215             // If nothing is selected, flag user and return, otherwise
00216             // process the selected key.
00217             // LB_ERR indicates nothing selected.
00218             if (indexLB == LB_ERR)
00219             {
00220                 LoadString(hInst, IDS_SELECTMSG, lpBuffer1, sizeof(lpBuffer1));
00221                 LoadString(hInst, IDS_NAME, lpBuffer2, sizeof(lpBuffer2));
00222                 MessageBox (hDlg, lpBuffer1, lpBuffer2, MB_OK);
00223                 return(0);
00224             }
00225
00226             // If listbox item 0 is pressed, user wants to move
00227             // back up.  Execute the Back functionality.
00228             if (indexLB == 0 && hKeyRoot)
00229             {
00230                 PostMessage (hDlg, WM_COMMAND, IDB_BACK, 0);
00231                 return(0);
00232             }
00233
00234
00235             // Get text from selection in LB.
00236             SendMessage (GetDlgItem (hDlg, IDL_LISTBOX),
00237                          LB_GETTEXT, indexLB, (LPARAM)NameLBSelect);
00238
00239             // Put name of chosen item in Name field.
00240             SetDlgItemText (hDlg, IDE_NAME, NameLBSelect);
00241
00242             // Then clear ListBox entries.
00243             SendMessage (GetDlgItem (hDlg, IDL_LISTBOX),
00244                          LB_RESETCONTENT, 0, 0);
00245             SendMessage (GetDlgItem (hDlg, IDL_LISTBOX2),
00246                          LB_RESETCONTENT, 0, 0);
00247
00248             EnumerateLevel (hDlg, NameLBSelect, RegPath, &hKeyRoot);
00249
00250             return(0);
00251
00252
00253
00254         case IDB_BACK:
00255
00256             // For this case (hRootKey = 0)you're at the top level already.
00257             // Tell the user, then return
00258             if (!hKeyRoot)
00259             {
00260                 LoadString(hInst, IDS_TOPLEVEL, lpBuffer1, sizeof(lpBuffer1));
00261                 LoadString(hInst, IDS_NAME, lpBuffer2, sizeof(lpBuffer2));
00262                 MessageBox (hDlg, lpBuffer1, lpBuffer2, MB_OK);
00263                 return(0);
00264             }
00265
00266             //For all remaining cases, clear the listboxes.
00267             SendMessage (GetDlgItem (hDlg, IDL_LISTBOX),
00268                          LB_RESETCONTENT, 0, 0);
00269             SendMessage (GetDlgItem (hDlg, IDL_LISTBOX2),
00270                          LB_RESETCONTENT, 0, 0);
00271
00272
00273
00274             // If hRootKey has a value, but the pathname is blank,
00275             // then you must be 1 level deep, reset to level 0 by
00276             // posting WM_GETFIRSTKEY.
00277             if (strcmp (RegPath, "") == 0)
00278             {
00279                 SetDlgItemText (hDlg, IDE_NAME, "");
00280                 PostMessage (hDlg, WM_GETFIRSTKEY, 0, 0);
00281                 return(0);
00282             }
00283
00284
00285             // Two cases left.  One in which the path has only one
00286             // key name in it, and no back slash character (meaning
00287             // strrchr() will return NULL); and one the other case
00288             // where there are more than one key name in the path (
00289             // and at least one back slash for strrchr().  If this
00290             // is the first case, we want to fakeout EnumerateLevel
00291             // into thinking we just picked one of the pre-defined keys,
00292             // and then re-enumerate it's child keys.
00293             if ((putNullAt = _mbsrchr (RegPath, '\\')) == NULL)
00294             {
00295                 RegPath[0] = '\0';
00296
00297                 switch ((DWORD_PTR)hKeyRoot)
00298                 {
00299                 case (DWORD_PTR)HKEY_LOCAL_MACHINE:
00300                     strncpy (NameLBSelect, "HKEY_LOCAL_MACHINE",19);
00301                     break;
00302
00303                 case (DWORD_PTR)HKEY_USERS:
00304                     strncpy (NameLBSelect, "HKEY_USERS",11);
00305                     break;
00306
00307                 case (DWORD_PTR)HKEY_CURRENT_USER:
00308                     strncpy (NameLBSelect, "HKEY_CURRENT_USER",18);
00309                     break;
00310
00311                 case (DWORD_PTR)HKEY_CLASSES_ROOT:
00312                     strncpy (NameLBSelect, "HKEY_CLASSES_ROOT",18);
00313                     break;
00314                 }
00315                 SetDlgItemText (hDlg, IDE_NAME, NameLBSelect);
00316                 hKeyRoot = 0;
00317                 EnumerateLevel (hDlg, NameLBSelect, RegPath, &hKeyRoot);
00318             }
00319             else
00320             {
00321                 // In the final case, we can just trim the last key
00322                 // name off the path, and re-enumerate the level.
00323                 CHAR *pEndOfBuffer = putNullAt;
00324                 *putNullAt = '\0';
00325                 putNullAt = _mbsrchr (RegPath, '\\');
00326
00327                 if (putNullAt)
00328                 {
00329                     strncpy (NameLBSelect, putNullAt+1,pEndOfBuffer-putNullAt);
00330                     *putNullAt = '\0';
00331                 }
00332                 else
00333                 {
00334                     strncpy (NameLBSelect, RegPath,pEndOfBuffer-RegPath+1);
00335                     *RegPath = '\0';
00336                 }
00337                 SetDlgItemText (hDlg, IDE_NAME, NameLBSelect);
00338                 EnumerateLevel (hDlg, NameLBSelect, RegPath, &hKeyRoot);
00339             }
00340             return(0);
00341
00342         default:
00343             return(0);
00344
00345         }
00346
00347     }
00348     return(FALSE);
00349
00350 }
00351
00352
00353
00354
00355 /************************************************************************\
00356 *
00357 *  FUNCTION: EnumerateLevel();
00358 *
00359 *  PURPOSE: To get a valid key handle (either to determine if the one sent
00360 *           to the function was one of the pre-defined, or to open a key
00361 *           specified by the path), and to pass that key handle along
00362 *           to QueryKey().
00363 *
00364 *           To enumerate the children of a key, you must have
00365 *           an open handle to it.  The four top keys of the
00366 *           Registry are predefined and open for use:
00367 *           HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_USER,
00368 *           and HKEY_CLASSES_ROOT.  These 4 can be used for
00369 *           RegEnumKey as is; but to RegEnumKey on any of the
00370 *           children of these you must first have an open key
00371 *           handle to the child.
00372 *
00373 *           If hKeyRoot != 0, assume you are lower than the
00374 *           first level of the Registry and the user is trying
00375 *           to enumerate one of the children.  First calculate
00376 *           the name of the child, and then use RegOpenKey to
00377 *           get an open handle.
00378 *
00379 *           If hKeyRoot == 0, assume you are at the top level
00380 *           of the Registry, and set the hKey to be enumerated
00381 *           to be one of the 4 predefined values, the specific
00382 *           one indicated by the ListBox selection.
00383 *
00384 \************************************************************************/
00385 VOID EnumerateLevel (HWND hDlg, LPTSTR NameLBSelect,
00386                      LPTSTR RegPath, HKEY *hKeyRoot)
00387 {
00388
00389     HKEY hKey;
00390     DWORD  retCode;
00391     CHAR   Buf[MAX_PATH];
00392     CHAR   lpBuffer[128];
00393     size_t  ByteCount = MAX_PATH - 1;
00394
00395
00396     if (*hKeyRoot)
00397     {
00398         // If RegPath is not NULL, then
00399         // you have to add a backslash to the
00400         // path name before appending the next
00401         // level child name.
00402         if (strcmp (RegPath, "") != 0) {
00403             CHAR *pEndOfBuffer;
00404             strncat (RegPath, "\\",1);
00405             pEndOfBuffer = _mbsrchr (RegPath, '\\');
00406             ByteCount -= (pEndOfBuffer - RegPath);
00407         }
00408
00409         // Add the next level child name.
00410         strncat (RegPath, NameLBSelect,ByteCount);
00411
00412         // Use RegOpenKeyEx() with the new
00413         // Registry path to get an open handle
00414         // to the child key you want to
00415         // enumerate.
00416         retCode = RegOpenKeyEx (*hKeyRoot,
00417                                 RegPath,
00418                                 0,
00419                                 KEY_ENUMERATE_SUB_KEYS |
00420                                 KEY_EXECUTE |
00421                                 KEY_QUERY_VALUE,
00422                                 &hKey);
00423
00424         if (retCode != ERROR_SUCCESS)
00425         {
00426             if (retCode == ERROR_ACCESS_DENIED)
00427             {
00428                 LoadString(hInst, IDS_CANTOPENKEY, lpBuffer, sizeof(lpBuffer));
00429                 wsprintf (Buf, lpBuffer);
00430             }
00431             else
00432             {
00433                 LoadString(hInst, IDS_OPENKEYERR, lpBuffer, sizeof(lpBuffer));
00434                 wsprintf (Buf, lpBuffer, retCode, __LINE__);
00435             }
00436             MessageBox (hDlg, Buf, "", MB_OK);
00437             PostMessage (hDlg, WM_COMMAND, IDB_BACK, 0);
00438             return;
00439         }
00440
00441     }
00442     else
00443     {
00444         // Set the *hKeyRoot handle based
00445         // on the text taken from the ListBox.
00446
00447         if (strcmp (NameLBSelect, "HKEY_CLASSES_ROOT") == 0)
00448             *hKeyRoot = HKEY_CLASSES_ROOT;
00449
00450         if (strcmp (NameLBSelect, "HKEY_USERS") == 0)
00451             *hKeyRoot = HKEY_USERS;
00452
00453         if (strcmp (NameLBSelect, "HKEY_LOCAL_MACHINE") == 0)
00454             *hKeyRoot = HKEY_LOCAL_MACHINE;
00455
00456         if (strcmp (NameLBSelect, "HKEY_CURRENT_USER") == 0)
00457             *hKeyRoot = HKEY_CURRENT_USER;
00458
00459         hKey = *hKeyRoot;     // hKey is used in RegEnumKey().
00460
00461     }//end if/else *hKeyRoot
00462
00463     QueryKey (hDlg, hKey);
00464
00465
00466     RegCloseKey (hKey);   // Close the key handle.
00467
00468 //      rect.top = 0; rect.left = 5; rect.right = 1200; rect.bottom = 25;
00469 //      hDC = GetDC (hDlg);
00470 //      FillRect (hDC, &rect, GetStockObject(WHITE_BRUSH));
00471 //      TextOut (hDC, 5, 5, RegPath, strlen(RegPath));
00472 //      ReleaseDC (hDlg, hDC);
00473     SetDlgItemText (hDlg, IDE_TEXTOUT, RegPath);
00474
00475
00476 }
00477
00478
00479 /************************************************************************\
00480 *
00481 *  FUNCTION: QueryKey();
00482 *
00483 *  PURPOSE:  To display the key's children (subkeys) and the names of
00484 *            the Values associated with it.  This function uses RegEnumKey,
00485 *            RegEnumValue, and RegQueryInfoKey.
00486 *
00487 \************************************************************************/
00488 VOID QueryKey (HWND hDlg, HANDLE hKey)
00489 {
00490     CHAR     KeyName[MAX_PATH];
00491     CHAR     ClassName[MAX_PATH] = ""; // Buffer for class name.
00492     DWORD    dwcClassLen = MAX_PATH;   // Length of class string.
00493     DWORD    dwcSubKeys;               // Number of sub keys.
00494     DWORD    dwcMaxSubKey;             // Longest sub key size.
00495     DWORD    dwcMaxClass;              // Longest class string.
00496     DWORD    dwcValues;                // Number of values for this key.
00497     DWORD    dwcMaxValueName;          // Longest Value name.
00498     DWORD    dwcMaxValueData;          // Longest Value data.
00499     DWORD    dwcSecDesc;               // Security descriptor.
00500     FILETIME ftLastWriteTime;          // Last write time.
00501
00502     DWORD i;
00503     DWORD retCode;
00504
00505     DWORD j;
00506     DWORD retValue;
00507     CHAR  ValueName[MAX_VALUE_NAME];
00508     DWORD dwcValueName = MAX_VALUE_NAME;
00509     CHAR  Buf[80];
00510     CHAR  lpBuffer[80];
00511     DWORD dwMaxPath;
00512     FILETIME ftFileTime;
00513
00514
00515     // Get Class name, Value count.
00516
00517     RegQueryInfoKey (hKey,              // Key handle.
00518                      ClassName,         // Buffer for class name.
00519                      &dwcClassLen,      // Length of class string.
00520                      NULL,              // Reserved.
00521                      &dwcSubKeys,       // Number of sub keys.
00522                      &dwcMaxSubKey,     // Longest sub key size.
00523                      &dwcMaxClass,      // Longest class string.
00524                      &dwcValues,        // Number of values for this key.
00525                      &dwcMaxValueName,  // Longest Value name.
00526                      &dwcMaxValueData,  // Longest Value data.
00527                      &dwcSecDesc,       // Security descriptor.
00528                      &ftLastWriteTime); // Last write time.
00529
00530     SetDlgItemText (hDlg, IDE_CLASS, ClassName);
00531     SetDlgItemInt  (hDlg, IDE_CVALUES, dwcValues, FALSE);
00532
00533     SendMessage (GetDlgItem (hDlg, IDL_LISTBOX),
00534                  LB_ADDSTRING, 0, (LPARAM)"..");
00535
00536     // Loop until RegEnumKey fails, get
00537     // the name of each child and enter
00538     // it into the box.
00539
00540     // Enumerate the Child Keys.
00541
00542     SetCursor (LoadCursor (NULL, IDC_WAIT));
00543     for (i=0, retCode = ERROR_SUCCESS; retCode == ERROR_SUCCESS; i++)
00544     {
00545
00546         dwMaxPath = MAX_PATH;
00547         retCode = RegEnumKeyEx( hKey,i, KeyName,
00548                                 &dwMaxPath, NULL, NULL,
00549                                 NULL,  &ftFileTime);
00550
00551
00552         if (retCode == (DWORD)ERROR_SUCCESS)
00553             SendMessage (GetDlgItem(hDlg, IDL_LISTBOX),
00554                          LB_ADDSTRING, 0, (LPARAM)KeyName);
00555     }
00556     SetCursor (LoadCursor (NULL, IDC_ARROW));
00557
00558
00559     // Enumerate the Key Values
00560     SetCursor (LoadCursor (NULL, IDC_WAIT));
00561
00562     if (dwcValues)
00563         for (j = 0, retValue = ERROR_SUCCESS; j < dwcValues; j++)
00564         {
00565             dwcValueName = MAX_VALUE_NAME;
00566             ValueName[0] = '\0';
00567             retValue = RegEnumValue (hKey, j, ValueName,
00568                                      &dwcValueName,
00569                                      NULL,
00570                                      NULL,               //&dwType,
00571                                      NULL,               //&bData,
00572                                      NULL);              //&bcData);
00573             if (retValue != (DWORD)ERROR_SUCCESS &&
00574                 retValue != ERROR_INSUFFICIENT_BUFFER)
00575             {
00576                 LoadString(hInst, IDS_REGERR, lpBuffer, sizeof(lpBuffer));
00577                 wsprintf (Buf, lpBuffer, __LINE__, j, retValue, dwcValueName);
00578                 LoadString(hInst, IDS_DEBUG, lpBuffer, sizeof(lpBuffer));
00579                 MessageBox (hDlg, Buf, lpBuffer, MB_OK);
00580             }
00581
00582             Buf[0] = '\0';
00583             if (ValueName[0] == '\0')
00584             {
00585                 LoadString(hInst, IDS_NONAME, lpBuffer, sizeof(lpBuffer));
00586                 strncpy (ValueName, lpBuffer,80);
00587             }
00588             wsprintf (Buf, "%d) %s ", j, ValueName);
00589             SendMessage (GetDlgItem (hDlg, IDL_LISTBOX2),
00590                          LB_ADDSTRING, 0, (LONG_PTR)Buf);
00591
00592         }// end for(;;)
00593
00594     SetCursor (LoadCursor (NULL, IDC_ARROW));
00595
00596 }
00597
00598
00599
00600 /************************************************************************\
00601 *
00602 *  FUNCTION: DisplayKeyData();
00603 *
00604 *  PURPOSE:  To display the keys values and value types to the Value edit
00605 *            field.  This function is called when the right hand listbox
00606 *            is double clicked.  The functionality is much like that found
00607 *            in the function PrintTree, please see it for more details.
00608 *
00609 \************************************************************************/
00610
00611
00612 VOID DisplayKeyData (HWND hDlg, CHAR *RegPath, HANDLE hKeyRoot)
00613 {
00614     HKEY   hKey;
00615     DWORD  dwLBIndex;
00616     CHAR   Buf[LINE_LEN];
00617     CHAR   ValueName[MAX_VALUE_NAME];
00618     DWORD  cbValueName = MAX_VALUE_NAME;
00619     DWORD  dwType;
00620     DWORD  retCode;
00621     CHAR   lpBuffer[128];
00622     CHAR   lpBuffer2[128];
00623
00624     CHAR   ClassName[MAX_PATH];
00625     DWORD  dwcClassLen = MAX_PATH;
00626     DWORD  dwcSubKeys;
00627     DWORD  dwcMaxSubKey;
00628     DWORD  dwcMaxClass;
00629     DWORD  dwcValues;
00630     DWORD  dwcMaxValueName;
00631     DWORD  dwcMaxValueData;
00632     DWORD  dwcSecDesc;
00633     FILETIME  ftLastWriteTime;
00634
00635
00636     BYTE   *bData;
00637     DWORD  cbData;
00638
00639     CHAR   *outBuf;
00640     DWORD  i;
00641     DWORD  cStrLen;
00642
00643     CHAR   *BinaryStrBuf;
00644     CHAR   ByteBuf[4];
00645
00646     CHAR   *ptr;
00647
00648     // OPEN THE KEY.
00649
00650     // LBIndex should == value index.
00651     dwLBIndex = (DWORD)SendMessage (GetDlgItem (hDlg, IDL_LISTBOX2),
00652                                     LB_GETCURSEL, 0, 0);
00653
00654     retCode = RegOpenKeyEx (hKeyRoot,    // Key handle at root level.
00655                             RegPath,     // Path name of child key.
00656                             0,           // Reserved.
00657                             KEY_EXECUTE, // Requesting read access.
00658                             &hKey);      // Address of key to be returned.
00659
00660     if (retCode)
00661     {
00662         LoadString(hInst, IDS_REGOPENERR, lpBuffer, sizeof(lpBuffer));
00663         wsprintf (Buf, lpBuffer, retCode);
00664         MessageBox (hDlg, Buf, "DisplayKeyData()", MB_OK);
00665         return;
00666     }
00667
00668 // ADD A QUERY AND ALLOCATE A BUFFER FOR BDATA.
00669
00670     retCode =
00671     RegQueryInfoKey (hKey,              // Key handle.
00672                      ClassName,         // Buffer for class name.
00673                      &dwcClassLen,      // Length of class string.
00674                      NULL,              // Reserved.
00675                      &dwcSubKeys,       // Number of sub keys.
00676                      &dwcMaxSubKey,     // Longest sub key size.
00677                      &dwcMaxClass,      // Longest class string.
00678                      &dwcValues,        // Number of values for this key.
00679                      &dwcMaxValueName,  // Longest Value name.
00680                      &dwcMaxValueData,  // Longest Value data.
00681                      &dwcSecDesc,       // Security descriptor.
00682                      &ftLastWriteTime); // Last write time.
00683
00684     if (retCode)
00685     {
00686         LoadString(hInst, IDS_REGQUERYERR, lpBuffer, sizeof(lpBuffer));
00687         wsprintf (Buf, lpBuffer, retCode, __LINE__);
00688         MessageBox (hDlg, Buf, "", MB_OK);
00689     }
00690
00691     bData = HeapAlloc (hHeap, 0, dwcMaxValueData);
00692     cbData = dwcMaxValueData;
00693
00694
00695     // ENUMERATE THE KEY.
00696
00697     retCode = RegEnumValue (hKey,        // Key handle returned from RegOpenKeyEx.
00698                             dwLBIndex,   // Value index, taken from listbox.
00699                             ValueName,   // Name of value.
00700                             &cbValueName,// Size of value name.
00701                             NULL,        // Reserved, dword = NULL.
00702                             &dwType,     // Type of data.
00703                             bData,       // Data buffer.
00704                             &cbData);    // Size of data buffer.
00705
00706     if (retCode != ERROR_SUCCESS)
00707     {
00708
00709         if (dwType < REG_FULL_RESOURCE_DESCRIPTOR)
00710         {
00711             LoadString(hInst, IDS_REGENUMERR, lpBuffer, sizeof(lpBuffer));
00712             wsprintf (Buf, lpBuffer, retCode, cbData, __LINE__);
00713             MessageBox (hDlg, Buf, "", MB_OK);
00714         }
00715     }
00716
00717
00718     switch (dwType)
00719     {
00720 //    REG_NONE                    ( 0 )   // No value type
00721 //    REG_SZ                      ( 1 )   // Unicode nul terminated string
00722 //    REG_EXPAND_SZ               ( 2 )   // Unicode nul terminated string
00723     // (with environment variable references)
00724 //    REG_BINARY                  ( 3 )   // Free form binary
00725 //    REG_DWORD                   ( 4 )   // 32-bit number
00726 //    REG_DWORD_LITTLE_ENDIAN     ( 4 )   // 32-bit number (same as REG_DWORD)
00727 //    REG_DWORD_BIG_ENDIAN        ( 5 )   // 32-bit number
00728 //    REG_LINK                    ( 6 )   // Symbolic Link (unicode)
00729 //    REG_MULTI_SZ                ( 7 )   // Multiple Unicode strings
00730 //    REG_RESOURCE_LIST           ( 8 )   // Resource list in the resource map
00731 //    REG_FULL_RESOURCE_DESCRIPTOR ( 9 )  // Resource list in the hardware description
00732
00733     case REG_NONE:
00734         LoadString(hInst, IDS_REGNONE, lpBuffer, sizeof(lpBuffer));
00735         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00736         break;
00737
00738     case REG_SZ:
00739         LoadString(hInst, IDS_REGSZ, lpBuffer, sizeof(lpBuffer));
00740         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00741
00742         outBuf = HeapAlloc (hHeap, 0, cbData + 2);
00743         *outBuf = '\0';
00744
00745         strncat (outBuf, "\"", 1);
00746         strncat (outBuf, bData, cbData);
00747         strncat (outBuf, "\"", 1);
00748
00749         SetDlgItemText (hDlg, IDE_VALUE2, outBuf);
00750         HeapFree (hHeap, 0, outBuf);
00751         break;
00752
00753     case REG_EXPAND_SZ:
00754         LoadString(hInst, IDS_REGEXPSZ, lpBuffer, sizeof(lpBuffer));
00755         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00756         outBuf = HeapAlloc (hHeap, 0, cbData + 2);
00757         *outBuf = '\0';
00758
00759         strncat (outBuf, "\"", 1);
00760         strncat (outBuf, bData, cbData);
00761         strncat (outBuf, "\"", 1);
00762
00763         SetDlgItemText (hDlg, IDE_VALUE2, outBuf);
00764         HeapFree (hHeap, 0, outBuf);
00765         break;
00766
00767     case REG_BINARY:
00768         LoadString(hInst, IDS_REGBIN, lpBuffer, sizeof(lpBuffer));
00769         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00770         SetCursor (LoadCursor (NULL, IDC_WAIT));
00771
00772         BinaryStrBuf = HeapAlloc (hHeap, 0, (3 * cbData) + 1);
00773         if (BinaryStrBuf)
00774         {
00775             *BinaryStrBuf = '\0';
00776             *ByteBuf = '\0';
00777             for (i = 0; i < cbData; i++)
00778             {
00779                 sprintf (ByteBuf, "%02x ", (BYTE)bData[i]);
00780                 strncat (BinaryStrBuf, ByteBuf,4);
00781             }
00782             SetDlgItemText (hDlg, IDE_VALUE2, BinaryStrBuf);
00783         }
00784         else
00785         {
00786             LoadString(hInst, IDS_MALLOCERR, lpBuffer, sizeof(lpBuffer));
00787             LoadString(hInst, IDS_DBGTITLE, lpBuffer2, sizeof(lpBuffer2));
00788             MessageBox (hDlg, lpBuffer, lpBuffer2, MB_OK);
00789         }
00790         SetDlgItemText (hDlg, IDL_LISTBOX2, BinaryStrBuf);
00791         HeapFree (hHeap, 0, BinaryStrBuf);
00792         SetCursor (LoadCursor (NULL, IDC_ARROW));
00793
00794         break;
00795
00796     case REG_DWORD:
00797         LoadString(hInst, IDS_REGDWORD, lpBuffer, sizeof(lpBuffer));
00798         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00799         SetDlgItemInt (hDlg, IDE_VALUE2, *(UINT *)bData, FALSE);
00800         break;
00801
00802     case REG_DWORD_BIG_ENDIAN:
00803         LoadString(hInst, IDS_REGBIGEND, lpBuffer, sizeof(lpBuffer));
00804         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00805         SetDlgItemInt (hDlg, IDE_VALUE2, *(UINT *)bData, TRUE);
00806         break;
00807
00808     case REG_LINK:
00809         LoadString(hInst, IDS_REGLINK, lpBuffer, sizeof(lpBuffer));
00810         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00811         SetDlgItemText (hDlg, IDE_VALUE2, bData);
00812         break;
00813
00814     case REG_MULTI_SZ:
00815         LoadString(hInst, IDS_REGMULTI, lpBuffer, sizeof(lpBuffer));
00816         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00817         SetCursor (LoadCursor (NULL, IDC_WAIT));
00818         // Count the NULLs in the buffer to
00819         // find out how many strings there are.
00820
00821         for (i=0, cStrLen=4; i < cbData; i++)
00822             if (!bData[i])
00823                 cStrLen+=4;                  // Add room for two quotes and two
00824                                              // spaced per string.
00825
00826         outBuf = HeapAlloc (hHeap, 0, cbData + cStrLen);
00827
00828         ptr = bData;                     // Set ptr to beginning of buffer.
00829         *outBuf = '\0';                  // Initialize output string.
00830
00831         strncat (outBuf, "{ ", 2);           // Do first bracket.
00832         while (*ptr)                     // Loop til you hit 2 NULLs in a row.
00833         {
00834             strncat (outBuf, "\"", 1);        // Put quotes around each string.
00835             strncat (outBuf, ptr, cbData);
00836             strncat (outBuf, "\"  ", 3);
00837             while(*ptr) ptr++;
00838             ptr++;
00839         }
00840         strncat (outBuf, "}", 1);            // Add final bracket.
00841         SetDlgItemText (hDlg, IDE_VALUE2, outBuf);
00842
00843         SetCursor (LoadCursor (NULL, IDC_ARROW));
00844         HeapFree (hHeap, 0, outBuf);                 // free output string.
00845         break;
00846
00847
00848     case REG_RESOURCE_LIST:            // CM_RESOURCE_LIST is complex.  Print it
00849         // as a free formed binary data for now.
00850
00851         LoadString(hInst, IDS_REGRESLST, lpBuffer, sizeof(lpBuffer));
00852         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00853
00854         BinaryStrBuf = HeapAlloc (hHeap, 0, (3 * cbData) + 1);
00855         if (BinaryStrBuf)
00856         {
00857             *BinaryStrBuf = '\0';
00858             *ByteBuf = '\0';
00859             for (i = 0; i < cbData; i++)
00860             {
00861                 sprintf (ByteBuf, "%02x ", (BYTE)bData[i]);
00862                 strncat (BinaryStrBuf, ByteBuf, 4);
00863             }
00864             SetDlgItemText (hDlg, IDE_VALUE2, BinaryStrBuf);
00865         }
00866         else
00867         {
00868             LoadString(hInst, IDS_MALLOCERR, lpBuffer, sizeof(lpBuffer));
00869             LoadString(hInst, IDS_DBGTITLE, lpBuffer2, sizeof(lpBuffer2));
00870             MessageBox (hDlg, lpBuffer, lpBuffer2, MB_OK);
00871         }
00872         SetDlgItemText (hDlg, IDL_LISTBOX2, BinaryStrBuf);
00873         HeapFree (hHeap, 0, BinaryStrBuf);
00874
00875         break;
00876
00877     case REG_FULL_RESOURCE_DESCRIPTOR:
00878         LoadString(hInst, IDS_REGFULLDESC, lpBuffer, sizeof(lpBuffer));
00879         SetDlgItemText (hDlg, IDE_VALUE1, lpBuffer);
00880         break;
00881
00882
00883
00884     default:
00885         LoadString(hInst, IDS_REGUNDEFINE, lpBuffer, sizeof(lpBuffer));
00886         wsprintf (Buf, lpBuffer, dwType);
00887         SetDlgItemText (hDlg, IDE_VALUE1, Buf);
00888         break;
00889
00890     } // end switch
00891
00892
00893     HeapFree (hHeap, 0, bData);
00894 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/clUtil.Cpp Source File

  • Web
  • NetMeeting
  • NMChat

clUtil.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       CLUTIL.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017
00018 //****************************************************************************
00019 //
00020 // CLASS RefCount
00021 //
00022 //****************************************************************************
00023
00024
00025 //****************************************************************************
00026 //
00027 // Constructor
00028 //
00029 //****************************************************************************
00030
00031 RefCount::RefCount(void)
00032 {
00033   m_cRef = 1;
00034 }
00035
00036
00037 //****************************************************************************
00038 //
00039 // Destructor
00040 //
00041 //****************************************************************************
00042
00043 RefCount::~RefCount(void)
00044 {
00045 }
00046
00047
00048 //****************************************************************************
00049 //
00050 // Methods from IUnknown
00051 //
00052 //****************************************************************************
00053
00054 ULONG STDMETHODCALLTYPE RefCount::AddRef(void)
00055 {
00056    ASSERT(m_cRef >= 0);
00057
00058    InterlockedIncrement(&m_cRef);
00059
00060    return (ULONG) m_cRef;
00061 }
00062
00063
00064 ULONG STDMETHODCALLTYPE RefCount::Release(void)
00065 {
00066   if (0 == InterlockedDecrement(&m_cRef))
00067   {
00068     delete this;
00069     return 0;
00070   }
00071
00072   ASSERT(m_cRef > 0);
00073   return (ULONG) m_cRef;
00074 }
00075
00076
00077 //****************************************************************************
00078 //
00079 // CLASS CNotify
00080 //
00081 //****************************************************************************
00082
00083
00084 //****************************************************************************
00085 //
00086 // Constructor
00087 //
00088 //****************************************************************************
00089
00090 CNotify::CNotify() :
00091   m_pcnpcnt(NULL),
00092     m_pcnp(NULL),
00093     m_dwCookie(0),
00094     m_pUnk(NULL)
00095 {
00096 }
00097
00098
00099 //****************************************************************************
00100 //
00101 // Destructor
00102 //
00103 //****************************************************************************
00104
00105 CNotify::~CNotify()
00106 {
00107   Disconnect(); // Make sure we're disconnected
00108 }
00109
00110
00111 //****************************************************************************
00112 //
00113 // HRESULT CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN)
00114 //
00115 //****************************************************************************
00116
00117 HRESULT CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN)
00118 {
00119   HRESULT hr = NO_ERROR;
00120
00121   if(NULL == pUnk || NULL == pUnkN)
00122   {
00123     return E_POINTER;
00124   }
00125
00126   ASSERT(0 == m_dwCookie);
00127
00128   if(m_dwCookie != 0)
00129   {
00130     return HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED);
00131   }
00132
00133   // Get the connection container
00134   hr = pUnk->QueryInterface(IID_IConnectionPointContainer, (void **)&m_pcnpcnt);
00135   if (SUCCEEDED(hr))
00136   {
00137     // Find an appropriate connection point
00138     hr = m_pcnpcnt->FindConnectionPoint(riid, &m_pcnp);
00139     if (SUCCEEDED(hr))
00140     {
00141       ASSERT(NULL != m_pcnp);
00142       // Connect the sink object
00143       hr = m_pcnp->Advise((IUnknown *)pUnkN, &m_dwCookie);
00144     }
00145   }
00146
00147   if (FAILED(hr))
00148   {
00149     m_dwCookie = 0;
00150   }
00151   else
00152   {
00153       m_pUnk = pUnk; // keep around for caller
00154     }
00155
00156   return hr;
00157 }
00158
00159
00160 //****************************************************************************
00161 //
00162 // HRESULT CNotify::Disconnect (void)
00163 //
00164 //****************************************************************************
00165
00166 HRESULT CNotify::Disconnect (void)
00167 {
00168     if (0 != m_dwCookie)
00169     {
00170         // Disconnect the sink object
00171         m_pcnp->Unadvise(m_dwCookie);
00172         m_dwCookie = 0;
00173
00174         m_pcnp->Release();
00175         m_pcnp = NULL;
00176
00177         m_pcnpcnt->Release();
00178         m_pcnpcnt = NULL;
00179
00180         m_pUnk = NULL;
00181     }
00182
00183     return S_OK;
00184 }
00185
00186
00187 //****************************************************************************
00188 //
00189 // CLASS COBLIST
00190 //
00191 //****************************************************************************
00192
00193
00194 //****************************************************************************
00195 //
00196 // Destructor
00197 //
00198 //****************************************************************************
00199
00200 COBLIST::~COBLIST()
00201 {
00202     ASSERT(IsEmpty());
00203 }
00204
00205
00206 #ifdef DEBUG
00207 VOID* COBLIST::GetHead()
00208 {
00209   ASSERT(m_pHead);
00210
00211   if(NULL == m_pHead)
00212   {
00213     return NULL;
00214   }
00215
00216   return m_pHead->pItem;
00217 }
00218
00219 VOID* COBLIST::GetTail()
00220 {
00221   ASSERT(m_pTail);
00222
00223   if(NULL == m_pTail)
00224   {
00225     return NULL;
00226   }
00227
00228   return m_pTail->pItem;
00229 }
00230 #endif /* DEBUG */
00231
00232
00233 //****************************************************************************
00234 //
00235 // VOID* COBLIST::GetNext(POSITION& rPos)
00236 //
00237 //****************************************************************************
00238
00239 VOID* COBLIST::GetNext(POSITION& rPos)
00240 {
00241   ASSERT(rPos);
00242
00243   if(NULL == rPos)
00244   {
00245     return NULL;
00246   }
00247
00248   VOID* pReturn = rPos->pItem;
00249   rPos = rPos->pNext;
00250
00251   return pReturn;
00252 }
00253
00254
00255 //****************************************************************************
00256 //
00257 // VOID* COBLIST::RemoveAt(POSITION Pos)
00258 //
00259 //****************************************************************************
00260
00261 VOID* COBLIST::RemoveAt(POSITION Pos)
00262 {
00263   if(NULL == Pos)
00264   {
00265     return NULL;
00266   }
00267
00268   VOID* pReturn = NULL;
00269
00270   if (m_pHead)
00271   {
00272     if (m_pHead == Pos)
00273     {
00274       // Removing the first element in the list
00275
00276       m_pHead = Pos->pNext;
00277       pReturn = Pos->pItem;
00278       delete Pos;
00279       m_cItem--;
00280       ASSERT(0 <= m_cItem);
00281
00282       if (NULL == m_pHead)
00283       {
00284         // Removing the only element!
00285         m_pTail = NULL;
00286       }
00287     }
00288     else
00289     {
00290       POSITION pCur = m_pHead;
00291
00292       while (pCur && pCur->pNext)
00293       {
00294         if (pCur->pNext == Pos)
00295         {
00296           // Removing
00297
00298           pCur->pNext = Pos->pNext;
00299           if (m_pTail == Pos)
00300           {
00301             m_pTail = pCur;
00302           }
00303           pReturn = Pos->pItem;
00304           delete Pos;
00305
00306           m_cItem--;
00307           ASSERT(0 <= m_cItem);
00308         }
00309
00310         pCur = pCur->pNext;
00311       }
00312     }
00313   }
00314
00315   return pReturn;
00316 }
00317
00318
00319 //****************************************************************************
00320 //
00321 // POSITION COBLIST::AddTail(VOID* pItem)
00322 //
00323 //****************************************************************************
00324
00325 POSITION COBLIST::AddTail(VOID* pItem)
00326 {
00327   POSITION posRet = NULL;
00328
00329   if (m_pTail)
00330   {
00331     if (m_pTail->pNext = new COBNODE)
00332     {
00333       m_pTail = m_pTail->pNext;
00334       m_pTail->pItem = pItem;
00335       m_pTail->pNext = NULL;
00336       m_cItem++;
00337     }
00338   }
00339   else
00340   {
00341     ASSERT(!m_pHead);
00342     if (m_pHead = new COBNODE)
00343     {
00344       m_pTail = m_pHead;
00345       m_pTail->pItem = pItem;
00346       m_pTail->pNext = NULL;
00347       m_cItem++;
00348     }
00349   }
00350
00351   return m_pTail;
00352 }
00353
00354
00355 //****************************************************************************
00356 //
00357 // void COBLIST::EmptyList()
00358 //
00359 //****************************************************************************
00360
00361 void COBLIST::EmptyList()
00362 {
00363     while (!IsEmpty())
00364   {
00365         RemoveAt(GetHeadPosition());
00366     }
00367 }
00368
00369
00370 #ifdef DEBUG
00371 VOID* COBLIST::RemoveTail()
00372 {
00373   ASSERT(m_pHead);
00374   ASSERT(m_pTail);
00375
00376   if(NULL == m_pHead || NULL == m_pTail)
00377   {
00378     return NULL;
00379   }
00380
00381   return RemoveAt(m_pTail);
00382 }
00383
00384 VOID* COBLIST::RemoveHead()
00385 {
00386   ASSERT(m_pHead);
00387   ASSERT(m_pTail);
00388
00389   if(NULL == m_pHead || NULL == m_pTail)
00390   {
00391     return NULL;
00392   }
00393
00394   return RemoveAt(m_pHead);
00395 }
00396
00397 void * COBLIST::GetFromPosition(POSITION Pos)
00398 {
00399     void * Result = SafeGetFromPosition(Pos);
00400   ASSERT(Result);
00401   return Result;
00402 }
00403 #endif /* DEBUG */
00404
00405
00406 //****************************************************************************
00407 //
00408 // POSITION COBLIST::GetPosition(void* _pItem)
00409 //
00410 //****************************************************************************
00411
00412 POSITION COBLIST::GetPosition(void* _pItem)
00413 {
00414     POSITION    Position = m_pHead;
00415
00416     while (Position)
00417   {
00418         if (Position->pItem == _pItem)
00419     {
00420             break;
00421         }
00422     GetNext(Position);
00423     }
00424     return Position;
00425 }
00426
00427
00428 //****************************************************************************
00429 //
00430 // POSITION COBLIST::Lookup(void* pComparator)
00431 //
00432 //****************************************************************************
00433
00434 POSITION COBLIST::Lookup(void* pComparator)
00435 {
00436     POSITION    Position = m_pHead;
00437
00438     while (Position)
00439   {
00440         if (Compare(Position->pItem, pComparator))
00441     {
00442             break;
00443         }
00444     GetNext(Position);
00445     }
00446     return Position;
00447 }
00448
00449
00450 //****************************************************************************
00451 //
00452 // void * COBLIST::SafeGetFromPosition(POSITION Pos)
00453 //
00454 //****************************************************************************
00455
00456 void * COBLIST::SafeGetFromPosition(POSITION Pos)
00457 {
00458   // Safe way to validate that an entry is still in the list,
00459   // which ensures bugs that would reference deleted memory,
00460   // reference a NULL pointer instead
00461   // (e.g. an event handler fires late/twice).
00462   // Note that versioning on entries would provide an additional
00463   // safeguard against re-use of a position.
00464   // Walk list to find entry.
00465
00466   POSITION PosWork = m_pHead;
00467
00468   while (PosWork)
00469   {
00470     if (PosWork == Pos)
00471     {
00472       return Pos->pItem;
00473     }
00474     GetNext(PosWork);
00475   }
00476   return NULL;
00477 }
00478
00479
00480 //****************************************************************************
00481 //
00482 // COBLIST Utility routines
00483 //
00484 //****************************************************************************
00485
00486
00487 //****************************************************************************
00488 //
00489 // POSITION AddNode(PVOID pv, COBLIST ** ppList)
00490 //
00491 // Add a node to a list.
00492 // Initializes the ObList, if necessary.
00493 // Returns the position in the list or NULL if there was a problem.
00494 //
00495 //****************************************************************************
00496
00497 POSITION AddNode(PVOID pv, COBLIST ** ppList)
00498 {
00499   ASSERT(NULL != ppList);
00500   if(NULL == ppList)
00501   {
00502     return NULL;
00503   }
00504
00505   if (NULL == *ppList)
00506   {
00507     *ppList = new COBLIST();
00508     if (NULL == *ppList)
00509     {
00510       return NULL;
00511     }
00512   }
00513
00514   return (*ppList)->AddTail(pv);
00515 }
00516
00517
00518 //****************************************************************************
00519 //
00520 // PVOID RemoveNode(POSITION * pPos, COBLIST *pList)
00521 //
00522 // Remove a node from a list.
00523 // Sets pPos to NULL
00524 //
00525 //****************************************************************************
00526
00527 PVOID RemoveNode(POSITION * pPos, COBLIST *pList)
00528 {
00529   if ((NULL == pList) || (NULL == pPos))
00530   {
00531     return NULL;
00532   }
00533
00534   PVOID pv = pList->RemoveAt(*pPos);
00535   *pPos = NULL;
00536   return pv;
00537 }
00538
00539
00540 //****************************************************************************
00541 //
00542 // CLASS BSTRING
00543 //
00544 //****************************************************************************
00545
00546
00547 //****************************************************************************
00548 //
00549 // Constructor
00550 //
00551 // We don't support construction from an ANSI string in the Unicode build.
00552 //
00553 //****************************************************************************
00554
00555 #if !defined(UNICODE)
00556
00557 BSTRING::BSTRING(LPCSTR lpcString)
00558 {
00559   m_bstr = NULL;
00560
00561   // Compute the length of the required BSTR, including the null
00562   int cWC =  MultiByteToWideChar(CP_ACP, 0, lpcString, -1, NULL, 0);
00563   if (cWC <= 0)
00564   {
00565     return;
00566   }
00567
00568   // Allocate the BSTR, including the null
00569   m_bstr = SysAllocStringLen(NULL, cWC); // SysAllocStringLen adds another 1
00570
00571   ASSERT(NULL != m_bstr);
00572   if (NULL == m_bstr)
00573   {
00574     return;
00575   }
00576
00577   ZeroMemory(m_bstr, (cWC + 1) * sizeof(OLECHAR));
00578
00579   // Copy the string
00580   MultiByteToWideChar(CP_ACP, 0, lpcString, -1, (LPWSTR) m_bstr, cWC);
00581 }
00582
00583 #endif // !defined(UNICODE)
00584
00585
00586 //****************************************************************************
00587 //
00588 // CLASS BTSTR
00589 //
00590 //****************************************************************************
00591
00592 //****************************************************************************
00593 //
00594 // Constructor
00595 //
00596 //****************************************************************************
00597
00598 BTSTR::BTSTR(BSTR bstr)
00599 {
00600   m_psz = PszFromBstr(bstr);
00601 }
00602
00603
00604 //****************************************************************************
00605 //
00606 // Destructor
00607 //
00608 //****************************************************************************
00609
00610 BTSTR::~BTSTR()
00611 {
00612   if (NULL != m_psz)
00613   {
00614     LocalFree(m_psz);
00615   }
00616 }
00617
00618
00619 //****************************************************************************
00620 //
00621 // LPTSTR PszFromBstr(BSTR bstr)
00622 //
00623 // Converts a BSTR to a LPSTR
00624 //
00625 //****************************************************************************
00626
00627 LPTSTR PszFromBstr(BSTR bstr)
00628 {
00629   if (NULL == bstr)
00630   {
00631     return NULL;
00632   }
00633   int cch =  WideCharToMultiByte(CP_ACP, 0, (LPWSTR)bstr, -1, NULL, 0, NULL, NULL);
00634   if (cch <= 0)
00635   {
00636     return NULL;
00637   }
00638
00639   LPTSTR psz = PszAlloc(cch);
00640   if (NULL == psz)
00641   {
00642     return NULL;
00643   }
00644
00645   ZeroMemory(psz, sizeof(TCHAR) * (cch + 1));
00646
00647   WideCharToMultiByte(CP_ACP, 0, (LPWSTR)bstr, -1, psz, cch, NULL, NULL);
00648   return psz;
00649 }
00650
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/headers.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

headers.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module HEADERS.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////////////////
00012 // Include
00013 //
00014 /////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFileIdx Member List

This is the complete list of members for CFileIdx, including all inherited members.
CFileIdx(void) | CFileIdx |
DeleteRow(DBCOUNTITEM ulDex) | CFileIdx |
fInit(void) | CFileIdx |
GetRowOffset(DBCOUNTITEM ulDex) | CFileIdx |
IsDeleted(DBCOUNTITEM ulDex) | CFileIdx |
m_rgDex | CFileIdx | [private]
m_ulDexCnt | CFileIdx | [private]
ReAlloc(DBCOUNTITEM ulRows) | CFileIdx | [private]
SetIndex(DBCOUNTITEM ulDex, ULONG ulOffset) | CFileIdx |
~CFileIdx(void) | CFileIdx |
Generated on Wed Nov 13 2024 16:56:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/WinNT/RasHost/Resource.h Source File

  • NetDS
  • Ras
  • WinNT
  • RasHost

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by RASHOST.RC
00004 //
00005
00006 // Next default values for new objects
00007 //
00008 #ifdef APSTUDIO_INVOKED
00009 #ifndef APSTUDIO_READONLY_SYMBOLS
00010 #define _APS_NEXT_RESOURCE_VALUE        101
00011 #define _APS_NEXT_COMMAND_VALUE         40001
00012 #define _APS_NEXT_CONTROL_VALUE         1000
00013 #define _APS_NEXT_SYMED_VALUE           101
00014 #endif
00015 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/registry.Cpp Source File

  • SysMgmt
  • MMC
  • Menubtn

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "globals.h"
00026
00027 ////////////////////////////////////////////////////////
00028 //
00029 // Internal helper functions prototypes
00030 //
00031
00032 // Set the given key and its value.
00033 BOOL setKeyAndValue(const _TCHAR* pszPath,
00034                     const _TCHAR* szSubkey,
00035                     const _TCHAR* szValue) ;
00036
00037 // Set the given key and its value in the MMC Snapin location
00038 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00039                           const _TCHAR* szSubkey,
00040                           const _TCHAR* szName,
00041                           const _TCHAR* szValue);
00042
00043 // Set the given valuename under the key to value
00044 BOOL setValue(const _TCHAR* szKey,
00045               const _TCHAR* szValueName,
00046               const _TCHAR* szValue);
00047
00048 // Delete szKeyChild and all of its descendents.
00049 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // Constants
00054 //
00055
00056 // Size of a CLSID as a string
00057 //const int CLSID_STRING_SIZE = 39 ;
00058
00059 /////////////////////////////////////////////////////////
00060 //
00061 // Public function implementation
00062 //
00063
00064 //
00065 // Register the component in the registry.
00066 //
00067 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00068                        const CLSID& clsid,         // Class ID
00069                        const _TCHAR* szFriendlyName)       //   IDs
00070 {
00071     // Get server location.
00072     _TCHAR szModule[512] ;
00073     DWORD dwResult =
00074         ::GetModuleFileName(hModule,
00075         szModule,
00076         sizeof(szModule)/sizeof(_TCHAR)) ;
00077
00078     assert(dwResult != 0) ;
00079
00080     // Get CLSID
00081     LPOLESTR wszCLSID = NULL ;
00082     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00083
00084     assert(SUCCEEDED(hr)) ;
00085
00086         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00087
00088     // Build the key CLSID\\{...}
00089     _TCHAR szKey[64] ;
00090     _tcscpy(szKey, _T("CLSID\\")) ;
00091         _tcscat(szKey, pszCLSID) ;
00092
00093     // Add the CLSID to the registry.
00094     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00095
00096     // Add the server filename subkey under the CLSID key.
00097     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00098
00099     // set the threading model
00100     _tcscat(szKey, _T("\\InprocServer32"));
00101     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00102
00103     // Free memory.
00104     CoTaskMemFree(wszCLSID) ;
00105
00106     return S_OK ;
00107 }
00108
00109 //
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00113 {
00114     // Get CLSID
00115     LPOLESTR wszCLSID = NULL ;
00116     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00117
00118
00119     // Build the key CLSID\\{...}
00120     _TCHAR szKey[64] ;
00121     _tcscpy(szKey, _T("CLSID\\")) ;
00122
00123         MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00124         _tcscat(szKey, pszT) ;
00125
00126     // Delete the CLSID Key - CLSID\{...}
00127     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00128     assert((lResult == ERROR_SUCCESS) ||
00129                (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00130
00131     // Free memory.
00132     CoTaskMemFree(wszCLSID) ;
00133
00134     return S_OK ;
00135 }
00136
00137 //
00138 // Register the snap-in in the registry.
00139 //
00140 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00141                        const _TCHAR* szNameString,   // NameString
00142                        const CLSID& clsidAbout,         // Class Id for About Class
00143                        const BOOL fSupportExtensions)
00144 {
00145     // Get CLSID
00146     LPOLESTR wszCLSID = NULL ;
00147     LPOLESTR wszAboutCLSID = NULL;
00148     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00149
00150     if (IID_NULL != clsidAbout)
00151         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00152
00153         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00154         MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00155
00156
00157     // Add the CLSID to the registry.
00158     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00159     setSnapInKeyAndValue(pszCLSID, _T("StandAlone"), NULL, NULL);
00160     if (IID_NULL != clsidAbout)
00161         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00162
00163     if (fSupportExtensions) {
00164         // Build the key NodeType
00165         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00166
00167         _TCHAR szKey[64] ;
00168         _tcscpy(szKey, pszCLSID) ;
00169         _tcscat(szKey, _T("\\NodeTypes")) ;
00170         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00171     }
00172
00173     // Free memory.
00174     CoTaskMemFree(wszCLSID) ;
00175     if (IID_NULL != clsidAbout)
00176         CoTaskMemFree(wszAboutCLSID);
00177
00178     return S_OK ;
00179 }
00180
00181 //
00182 // Unregister the snap-in in the registry.
00183 //
00184 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00185 {
00186     _TCHAR szKeyBuf[1024];
00187     LPOLESTR wszCLSID = NULL;
00188
00189     // Get CLSID
00190     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00191         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00192
00193     // Load the buffer with the Snap-In Location
00194     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00195
00196     // Copy keyname into buffer.
00197     _tcscat(szKeyBuf, _T("\\"));
00198     _tcscat(szKeyBuf, pszCLSID);
00199
00200     // Delete the CLSID Key - CLSID\{...}
00201     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00202     assert((lResult == ERROR_SUCCESS) ||
00203                (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00204
00205     // free the memory
00206     CoTaskMemFree(wszCLSID);
00207
00208     return S_OK;
00209 }
00210
00211 //
00212 // Delete a key and all of its descendents.
00213 //
00214 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00215                         const _TCHAR* lpszKeyChild)  // Key to delete
00216 {
00217     // Open the child.
00218     HKEY hKeyChild ;
00219     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00220         KEY_ALL_ACCESS, &hKeyChild) ;
00221     if (lRes != ERROR_SUCCESS)
00222     {
00223         return lRes ;
00224     }
00225
00226     // Enumerate all of the decendents of this child.
00227     FILETIME time ;
00228     _TCHAR szBuffer[256] ;
00229     DWORD dwSize = 256 ;
00230     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00231         NULL, NULL, &time) == S_OK)
00232     {
00233         // Delete the decendents of this child.
00234         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00235         if (lRes != ERROR_SUCCESS)
00236         {
00237             // Cleanup before exiting.
00238             RegCloseKey(hKeyChild) ;
00239             return lRes;
00240         }
00241         dwSize = 256 ;
00242     }
00243
00244     // Close the child.
00245     RegCloseKey(hKeyChild) ;
00246
00247     // Delete this child.
00248     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00249 }
00250
00251 //
00252 // Create a key and set its value.
00253 //   - This helper function was borrowed and modifed from
00254 //     Kraig Brockschmidt's book Inside OLE.
00255 //
00256 BOOL setKeyAndValue(const _TCHAR* szKey,
00257                     const _TCHAR* szSubkey,
00258                     const _TCHAR* szValue)
00259 {
00260     HKEY hKey;
00261     _TCHAR szKeyBuf[1024] ;
00262
00263     // Copy keyname into buffer.
00264     _tcscpy(szKeyBuf, szKey) ;
00265
00266     // Add subkey name to buffer.
00267     if (szSubkey != NULL)
00268     {
00269         _tcscat(szKeyBuf, _T("\\")) ;
00270         _tcscat(szKeyBuf, szSubkey ) ;
00271     }
00272
00273     // Create and open key and subkey.
00274     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00275         szKeyBuf,
00276         0, NULL, REG_OPTION_NON_VOLATILE,
00277         KEY_ALL_ACCESS, NULL,
00278         &hKey, NULL) ;
00279     if (lResult != ERROR_SUCCESS)
00280     {
00281         return FALSE ;
00282     }
00283
00284     // Set the Value.
00285     if (szValue != NULL)
00286     {
00287         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00288             (BYTE *)szValue,
00289             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00290     }
00291
00292     RegCloseKey(hKey) ;
00293     return TRUE ;
00294 }
00295
00296 //
00297 // Open a key value and set it
00298 //
00299 BOOL setValue(const _TCHAR* szKey,
00300               const _TCHAR* szValueName,
00301               const _TCHAR* szValue)
00302 {
00303     HKEY hKey;
00304     _TCHAR szKeyBuf[1024] ;
00305
00306     // Copy keyname into buffer.
00307     _tcscpy(szKeyBuf, szKey) ;
00308
00309     // Create and open key and subkey.
00310     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00311         szKeyBuf,
00312         0, NULL, REG_OPTION_NON_VOLATILE,
00313         KEY_ALL_ACCESS, NULL,
00314         &hKey, NULL) ;
00315     if (lResult != ERROR_SUCCESS)
00316     {
00317         return FALSE ;
00318     }
00319
00320     // Set the Value.
00321     if (szValue != NULL)
00322     {
00323         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00324             (BYTE *)szValue,
00325             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00326     }
00327
00328     RegCloseKey(hKey) ;
00329     return TRUE ;
00330 }
00331
00332 //
00333 // Create a key and set its value.
00334 //   - This helper function was borrowed and modifed from
00335 //     Kraig Brockschmidt's book Inside OLE.
00336 //
00337 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00338                           const _TCHAR* szSubkey,
00339                           const _TCHAR* szName,
00340                           const _TCHAR* szValue)
00341 {
00342     HKEY hKey;
00343     _TCHAR szKeyBuf[1024] ;
00344
00345     // Load the buffer with the Snap-In Location
00346     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00347
00348     // Copy keyname into buffer.
00349     _tcscat(szKeyBuf, _T("\\")) ;
00350     _tcscat(szKeyBuf, szKey) ;
00351
00352     // Add subkey name to buffer.
00353     if (szSubkey != NULL)
00354     {
00355         _tcscat(szKeyBuf, _T("\\")) ;
00356         _tcscat(szKeyBuf, szSubkey ) ;
00357     }
00358
00359     // Create and open key and subkey.
00360     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00361         szKeyBuf,
00362         0, NULL, REG_OPTION_NON_VOLATILE,
00363         KEY_ALL_ACCESS, NULL,
00364         &hKey, NULL) ;
00365     if (lResult != ERROR_SUCCESS)
00366     {
00367         return FALSE ;
00368     }
00369
00370     // Set the Value.
00371     if (szValue != NULL)
00372     {
00373         RegSetValueEx(hKey, szName, 0, REG_SZ,
00374             (BYTE *)szValue,
00375             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00376     }
00377
00378     RegCloseKey(hKey) ;
00379     return TRUE ;
00380 }
00381
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/basesnap.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

basesnap.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  Abstract: This module provides the basic COM and DLL methods to create
00015 //            and load the Snap-in.  IClassFactory::CreateInstance creates
00016 //            an instance of a class whose type is passed in the constructor
00017 //
00018
00019
00020 #ifndef _BASESNAP_H_
00021 #define _BASESNAP_H_
00022
00023 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppvObj);
00024 STDAPI DllCanUnloadNow(void);
00025
00026 //---------------------------------------------------------------------------
00027 class CClassFactory : public IClassFactory
00028 {
00029   public:
00030     enum FACTORY_TYPE {COMPONENTDATA = 0, ABOUT = 1};
00031
00032   public:
00033     CClassFactory(FACTORY_TYPE eFactoryType);
00034     ~CClassFactory();
00035
00036     STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv);
00037     STDMETHODIMP_(ULONG) AddRef();
00038     STDMETHODIMP_(ULONG) Release();
00039
00040     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
00041     STDMETHODIMP LockServer(BOOL);
00042
00043   private:
00044     ULONG         m_cRef;
00045     FACTORY_TYPE  m_FactoryType;
00046
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/basenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

basenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Generic base node class.  All nodes are derived from this.
00014
00015
00016 #ifndef _CLASS_BASENODE_
00017 #define _CLASS_BASENODE_
00018
00019 #include "Globals.h"
00020 #include "Resource.h"
00021
00022
00023 #define DEFAULT_SDI_MASK  (SDI_STR | SDI_PARAM | SDI_IMAGE | SDI_OPENIMAGE | SDI_PARENT | SDI_CHILDREN)
00024 #define DEFAULT_RDI_MASK  (RDI_STR | RDI_PARAM | RDI_IMAGE)
00025
00026 #define MAX_NAME_LEN     64
00027
00028
00029 //---------------------------------------------------------------------------
00030 //  Data types specific to this object
00031 //
00032 typedef struct tag_BASENODE_PROPERTIES
00033 {
00034   WCHAR      szNodeName[MAX_NAME_LEN];
00035   LONG_PTR   pComponentData;
00036
00037 }NODE_PROPERTIES;
00038
00039 typedef NODE_PROPERTIES*  LPNODE_PROPERTIES;
00040
00041
00042 //---------------------------------------------------------------------------
00043 class CBaseNode
00044 {
00045   public:
00046     CBaseNode()
00047     {
00048       m_pwszNodeName      = NULL;
00049
00050       ZeroMemory( &m_SDI, sizeof(SCOPEDATAITEM) );
00051       ZeroMemory( &m_RDI, sizeof(RESULTDATAITEM) );
00052     };
00053
00054     virtual ~CBaseNode()
00055     {
00056       if( NULL != m_pwszNodeName )
00057         CoTaskMemFree( m_pwszNodeName );
00058     };
00059
00060   public:
00061     LPWSTR   GetNodeName()     { return m_pwszNodeName;  }
00062
00063     virtual  HRESULT Initialize( NODE_PROPERTIES* pProperties ) = 0;
00064     virtual  ULONG   GetNodeType() = 0;
00065     virtual  GUID*   GetNodeGUID() = 0;
00066
00067   ///////////////////////////////////////////////////////////////////////////
00068   // These virtual methods handle calls from the console
00069   //
00070   public:
00071     virtual  HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI ) = 0;
00072     virtual  HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI ) = 0;
00073     virtual  HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo ) = 0;
00074
00075   ///////////////////////////////////////////////////////////////////////////
00076   // These virtual methods handle notifications
00077   //
00078   public:
00079     virtual  HRESULT OnSelect( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent ) = 0;
00080     virtual  HRESULT OnShow( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent ) = 0;
00081
00082   public:
00083     SCOPEDATAITEM    m_SDI;
00084     RESULTDATAITEM   m_RDI;
00085
00086   protected:
00087     LPWSTR     m_pwszNodeName;
00088
00089 }; //end class CBaseNode
00090
00091 #endif //_CLASS_BASENODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/InpStrm.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

InpStrm.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       inpstrm.cxx
00006 //
00007 //  Contents:   Memory mapped input stream
00008 //
00009 //  Classes:    CMemoryMappedSerialStream
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <htmlfilt.hxx>
00017 #include <codepage.hxx>
00018
00019 //+-------------------------------------------------------------------------
00020 //
00021 //  Method:     CMemoryMappedInputStream::CMemoryMappedInputStream
00022 //
00023 //  Synopsis:   Constructor
00024 //
00025 //--------------------------------------------------------------------------
00026
00027 CMemoryMappedInputStream::CMemoryMappedInputStream()
00028     : _bytesReadFromMMBuffer(0),
00029       _charsReadFromTranslatedBuffer(0),
00030       _cwcTranslatedBuffer(0),
00031       _ulCodePage(LocaleToCodepage(GetSystemDefaultLCID())),
00032       _fUnGotChar(FALSE),
00033       _wch(0)
00034 {
00035 }
00036
00037
00038
00039 //+-------------------------------------------------------------------------
00040 //
00041 //  Method:     CMemoryMappedInputStream::~CMemoryMappedInputStream
00042 //
00043 //  Synopsis:   Destructor
00044 //
00045 //--------------------------------------------------------------------------
00046
00047 CMemoryMappedInputStream::~CMemoryMappedInputStream()
00048 {
00049     if ( _mmStream.Ok() && _mmStreamBuf.Get() != 0 )
00050         _mmStream.Unmap( _mmStreamBuf );
00051 }
00052
00053
00054
00055 //+-------------------------------------------------------------------------
00056 //
00057 //  Method:     CMemoryMappedInputStream::Init
00058 //
00059 //  Synopsis:   Initialize the memory mapped stream
00060 //
00061 //  Arguments:  [pwszFileName] -- File to be mapped
00062 //
00063 //--------------------------------------------------------------------------
00064
00065 void CMemoryMappedInputStream::Init( WCHAR *pwszFileName )
00066 {
00067     Win4Assert( pwszFileName );
00068
00069     _bytesReadFromMMBuffer = 0;
00070
00071     if ( _mmStream.Ok() )
00072     {
00073         _mmStreamBuf.Rewind();
00074         _mmStream.Close();
00075     }
00076
00077     _mmStream.Open( pwszFileName,
00078                     GENERIC_READ,
00079                     FILE_SHARE_READ,
00080                     OPEN_EXISTING );
00081
00082     if ( _mmStream.Ok() )
00083     {
00084         _mmStreamBuf.Init( &_mmStream );
00085         if ( !_mmStream.isEmpty() )
00086             _mmStreamBuf.Map( HTML_FILTER_CHUNK_SIZE );
00087     }
00088     else
00089     {
00090         htmlDebugOut(( DEB_ERROR, "Throwing FILTER_E_ACCESS in CMemoryMappedInputStream::Init\n" ));
00091         throw( CException( FILTER_E_ACCESS ) );
00092     }
00093 }
00094
00095
00096
00097 //+-------------------------------------------------------------------------
00098 //
00099 //  Method:     CMemoryMappedInputStream::GetChar
00100 //
00101 //  Synopsis:   Read the next consecutive character from the input file
00102 //
00103 //--------------------------------------------------------------------------
00104
00105 WCHAR CMemoryMappedInputStream::GetChar()
00106 {
00107     if ( !_mmStream.Ok() || !_mmStreamBuf.Get() )
00108         throw( CException( FILTER_E_ACCESS ) );
00109
00110     if ( _fUnGotChar )
00111     {
00112         _fUnGotChar = FALSE;
00113         return _wch;
00114     }
00115
00116     if ( _charsReadFromTranslatedBuffer == _cwcTranslatedBuffer )
00117     {
00118         if ( _bytesReadFromMMBuffer == _mmStreamBuf.Size() )
00119         {
00120             if ( _mmStreamBuf.Eof() )
00121                 return WEOF;
00122
00123             //
00124             // Try to map in next chunk of file
00125             //
00126             _mmStreamBuf.Map( HTML_FILTER_CHUNK_SIZE );
00127             _bytesReadFromMMBuffer = 0;
00128
00129             Win4Assert( _mmStreamBuf.Size() > _bytesReadFromMMBuffer );
00130         }
00131
00132         ULONG cChUnread = _mmStreamBuf.Size() - _bytesReadFromMMBuffer;
00133
00134         //
00135         // Since, the wide chars are precomposed, assume 1:1 translation mapping
00136         //
00137         ULONG cChIn = TRANSLATED_CHAR_BUFFER_LENGTH;
00138         if ( cChIn > cChUnread )
00139         {
00140             //
00141             // Not enough chars in input
00142             //
00143             cChIn = cChUnread;
00144         }
00145
00146         ULONG cwcActual = 0;
00147         do
00148         {
00149             cwcActual = MultiByteToWideChar( _ulCodePage,
00150                                              MB_PRECOMPOSED,
00151                                              (char *) _mmStreamBuf.Get() + _bytesReadFromMMBuffer,
00152                                              cChIn,
00153                                              _awcTranslatedBuffer,
00154                                              TRANSLATED_CHAR_BUFFER_LENGTH );
00155             if ( cwcActual == 0 )
00156             {
00157                 if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER && cChIn >= 2 )
00158                     cChIn /= 2;
00159                 else
00160                 {
00161                     Win4Assert( !"CMemoryMappedInputStream::GetChar, cannot translate single char" );
00162
00163                     throw( CException( GetLastError() ) );
00164                 }
00165             }
00166         } while( cwcActual == 0 );
00167
00168         Win4Assert( _bytesReadFromMMBuffer + cChIn <= _mmStreamBuf.Size() );
00169         Win4Assert( cwcActual <= TRANSLATED_CHAR_BUFFER_LENGTH );
00170
00171         _bytesReadFromMMBuffer += cChIn;
00172         _charsReadFromTranslatedBuffer = 0;
00173         _cwcTranslatedBuffer = cwcActual;
00174     }
00175
00176     return _awcTranslatedBuffer[_charsReadFromTranslatedBuffer++];
00177 }
00178
00179
00180
00181
00182 //+-------------------------------------------------------------------------
00183 //
00184 //  Method:     CMemoryMappedInputStream::UnGetChar
00185 //
00186 //  Synopsis:   Pushes(logically) a character back into the input stream
00187 //
00188 //  Arguments:  [wch] -- Char to be pushed back
00189 //
00190 //--------------------------------------------------------------------------
00191
00192 void CMemoryMappedInputStream::UnGetChar( WCHAR wch )
00193 {
00194     //
00195     // We can unget only one char at a time
00196     //
00197     Win4Assert( !_fUnGotChar );
00198
00199     _fUnGotChar = TRUE;
00200     _wch = wch;
00201 }
00202
00203
00204
00205 //+-------------------------------------------------------------------------
00206 //
00207 //  Method:     CMemoryMappedInputStream::Eof
00208 //
00209 //  Synopsis:   Is this the end of input file ?
00210 //
00211 //--------------------------------------------------------------------------
00212
00213 BOOL CMemoryMappedInputStream::Eof()
00214 {
00215     if ( !_mmStream.Ok() )
00216         throw( CException( FILTER_E_ACCESS ) );
00217
00218     if ( _fUnGotChar )
00219         return FALSE;
00220
00221     if ( _charsReadFromTranslatedBuffer < _cwcTranslatedBuffer )
00222         return FALSE;
00223
00224     if ( _bytesReadFromMMBuffer == _mmStreamBuf.Size() )
00225         return _mmStreamBuf.Eof();
00226     else
00227         return FALSE;
00228 }
00229
00230
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_Command Member List

This is the complete list of members for msado15::_Command, including all inherited members.
Cancel() | msado15::_Command |
CreateParameter(String Name, int Type, int Direction, int Size, Variant Value) | msado15::_Command |
Execute(Variant RecordsAffected, Variant Parameters, int Options) | msado15::_Command |
getActiveConnection() | msado15::_Command |
getCommandText() | msado15::_Command |
getCommandTimeout() | msado15::_Command |
getCommandType() | msado15::_Command |
getName() | msado15::_Command |
getParameters() | msado15::_Command |
getPrepared() | msado15::_Command |
getProperties() | msado15::_Command |
getState() | msado15::_Command |
iid | msado15::_Command | [static]
setActiveConnection(msado15._Connection ppvObject) | msado15::_Command |
setActiveConnection(Variant ppvObject) | msado15::_Command |
setCommandText(String pbstr) | msado15::_Command |
setCommandTimeout(int pl) | msado15::_Command |
setCommandType(int plCmdType) | msado15::_Command |
setName(String pbstrName) | msado15::_Command |
setPrepared(boolean pfPrepared) | msado15::_Command |
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpproppage/SCP.cpp Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpproppage

SCP.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCP.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #include "stdafx.h"
00012 #include "SCP.h"
00013 #include "util.h"
00014 #include "adsprop.h"
00015 #include "dsclient.h"   //CFSTR_DSOBJECTNAMES
00016
00017 //
00018 // IShellExtInit interface
00019 //
00020 STDMETHODIMP CSCP::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObject, HKEY hKeyID)
00021 {
00022   if (pDataObject != NULL)
00023   {
00024     //
00025     // Store the IDataObject in a smart pointer.
00026     //
00027     m_spDataObj = pDataObject;
00028   }
00029   else
00030   {
00031     return E_INVALIDARG;
00032   }
00033   return S_OK;
00034 }
00035
00036 //
00037 // IShellPropSheetExt interface
00038 //
00039 STDMETHODIMP CSCP::AddPages(LPFNADDPROPSHEETPAGE pAddPageProc, LPARAM lParam)
00040 {
00041   AFX_MANAGE_STATE(AfxGetStaticModuleState());
00042
00043   //
00044   // Unpack the data pointer and create the property page.
00045   // Register clipboard format
00046   //
00047   CLIPFORMAT cfDsObjectNames = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_DSOBJECTNAMES);
00048   ASSERT(cfDsObjectNames != 0);
00049
00050   FORMATETC fmte = { cfDsObjectNames, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
00051   STGMEDIUM objMedium;
00052
00053   HRESULT hr = m_spDataObj->GetData(&fmte, &objMedium);
00054   if (FAILED(hr))
00055   {
00056     AfxMessageBox(_T("Failed to retrieve data from medium."));
00057     return hr;
00058   }
00059
00060   LPDSOBJECTNAMES pDsObjectNames;
00061   pDsObjectNames = (LPDSOBJECTNAMES)objMedium.hGlobal;
00062   if (pDsObjectNames->cItems < 1)
00063   {
00064     return ERROR_INVALID_DATA;
00065   }
00066
00067   PWSTR pszObjADsPath = (PWSTR)BYTE_OFFSET(pDsObjectNames, pDsObjectNames->aObjects[0].offsetName);
00068   PWSTR pszClass = (PWSTR)BYTE_OFFSET(pDsObjectNames, pDsObjectNames->aObjects[0].offsetClass);
00069   TRACE(_T("Object path: %s, class: %s\n"), pszObjADsPath, pszClass);
00070
00071   //
00072   // Create/contact the notification object.
00073   //
00074   HWND hNotifyObj;
00075
00076   hr = ADsPropCreateNotifyObj(m_spDataObj, pszObjADsPath, &hNotifyObj);
00077
00078   if (FAILED(hr))
00079   {
00080     return hr;
00081   }
00082
00083   //
00084   // Create and initialize the general page
00085   //
00086   m_pProppageUIGeneral = new CSCPUIGeneral(hNotifyObj);
00087   m_pProppageUIGeneral->Init(pszObjADsPath, pszClass);
00088
00089   //
00090   // Add the general page to the sheet
00091   //
00092   ((PROPSHEETPAGE*)&m_pProppageUIGeneral->m_psp)->lParam = (LPARAM)m_pProppageUIGeneral;
00093   if (!(*pAddPageProc)(CreatePropertySheetPage((PROPSHEETPAGE*)&m_pProppageUIGeneral->m_psp), (LPARAM)lParam))
00094   {
00095     return E_FAIL;
00096   }
00097
00098   //
00099   // Create and initialize the binding information page
00100   //
00101   m_pProppageUIBindingInfo = new CSCPUIBindingInfo(hNotifyObj);
00102   m_pProppageUIBindingInfo->Init(pszObjADsPath, pszClass);
00103
00104   //
00105   // Add the binding information page to the sheet
00106   //
00107   ((PROPSHEETPAGE*)&m_pProppageUIBindingInfo->m_psp)->lParam = (LPARAM)m_pProppageUIBindingInfo;
00108   if (!(*pAddPageProc)(CreatePropertySheetPage((PROPSHEETPAGE*)&m_pProppageUIBindingInfo->m_psp), (LPARAM)lParam))
00109   {
00110     return E_FAIL;
00111   }
00112
00113   //
00114   // Create and initialize the keywords page
00115   //
00116   m_pProppageUIKeywords = new CSCPUIKeywords(hNotifyObj);
00117   m_pProppageUIKeywords->Init(pszObjADsPath, pszClass);
00118
00119   //
00120   // Add the keywords page to the sheet
00121   //
00122   ((PROPSHEETPAGE*)&m_pProppageUIKeywords->m_psp)->lParam = (LPARAM)m_pProppageUIKeywords;
00123   if (!(*pAddPageProc)(CreatePropertySheetPage((PROPSHEETPAGE*)&m_pProppageUIKeywords->m_psp), (LPARAM)lParam))
00124   {
00125     return E_FAIL;
00126   }
00127
00128   return S_OK;
00129 }
00130
00131 STDMETHODIMP CSCP::ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
00132 {
00133   //
00134   // This method is not used.  It should only be called if the pages are an extension for the Control Panel.
00135   //
00136   return E_FAIL;
00137 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSmpFilter Member List

This is the complete list of members for CSmpFilter, including all inherited members.
AddRef() | CSmpFilter | [virtual]
BindRegion(FILTERREGION origPos, REFIID riid, void **ppunk) | CSmpFilter | [virtual]
CSmpFilter() | CSmpFilter | [private]
CSmpFilterCF class | CSmpFilter | [friend]
GetChunk(STAT_CHUNK *pStat) | CSmpFilter | [virtual]
GetClassID(CLSID *pClassID) | CSmpFilter | [virtual]
GetCurFile(LPWSTR *ppszFileName) | CSmpFilter | [virtual]
GetText(ULONG *pcwcBuffer, WCHAR *awcBuffer) | CSmpFilter | [virtual]
GetValue(PROPVARIANT **ppPropValue) | CSmpFilter | [virtual]
Init(ULONG grfFlags, ULONG cAttributes, FULLPROPSPEC const *aAttributes, ULONG *pFlags) | CSmpFilter | [virtual]
IsDirty() | CSmpFilter | [virtual]
Load(LPCWSTR pszFileName, DWORD dwMode) | CSmpFilter | [virtual]
m_fContents | CSmpFilter | [private]
m_fEof | CSmpFilter | [private]
m_hFile | CSmpFilter | [private]
m_lRefs | CSmpFilter | [private]
m_pwszFileName | CSmpFilter | [private]
m_ulBufferLen | CSmpFilter | [private]
m_ulCharsRead | CSmpFilter | [private]
m_ulChunkID | CSmpFilter | [private]
m_ulCodePage | CSmpFilter | [private]
m_wcsBuffer | CSmpFilter | [private]
QueryInterface(REFIID riid, void **ppvObject) | CSmpFilter | [virtual]
Release() | CSmpFilter | [virtual]
Save(LPCWSTR pszFileName, BOOL fRemember) | CSmpFilter | [virtual]
SaveCompleted(LPCWSTR pszFileName) | CSmpFilter | [virtual]
~CSmpFilter() | CSmpFilter | [private]
Generated on Wed Nov 13 2024 16:57:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/ADQIDlg.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

ADQIDlg.h

Go to the documentation of this file.
00001 // ADQIDlg.h : header file
00002 //
00003
00004 #if !defined(AFX_ADQIDLG_H__81709771_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00005 #define AFX_ADQIDLG_H__81709771_0672_11D2_B218_0000F87A6B50__INCLUDED_
00006
00007 #if _MSC_VER >= 1000
00008 #pragma once
00009 #endif // _MSC_VER >= 1000
00010
00011 /////////////////////////////////////////////////////////////////////////////
00012 // CADQIDlg dialog
00013
00014 class CADQIDlg : public CDialog
00015 {
00016 // Construction
00017 public:
00018   void EnumerateInterface();
00019   CADQIDlg(CWnd* pParent = NULL); // standard constructor
00020
00021 // Dialog Data
00022   //{{AFX_DATA(CADQIDlg)
00023   enum { IDD = IDD_ADQI_DIALOG };
00024   CListBox  m_cListIf;
00025   CButton m_cOK;
00026   CEdit m_cADsPath;
00027   CString m_sADsPath;
00028   LPUNKNOWN m_pUnk;
00029   //}}AFX_DATA
00030
00031   // ClassWizard generated virtual function overrides
00032   //{{AFX_VIRTUAL(CADQIDlg)
00033   protected:
00034   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00035   //}}AFX_VIRTUAL
00036
00037 // Implementation
00038 protected:
00039   HICON m_hIcon;
00040
00041   // Generated message map functions
00042   //{{AFX_MSG(CADQIDlg)
00043   virtual BOOL OnInitDialog();
00044   afx_msg void OnPaint();
00045   afx_msg HCURSOR OnQueryDragIcon();
00046   virtual void OnOK();
00047   afx_msg void OnChangeADsPath();
00048   virtual void OnCancel();
00049   afx_msg void OnDblClkInterfaces();
00050   //}}AFX_MSG
00051   DECLARE_MESSAGE_MAP()
00052 };
00053
00054
00055 void DlgProcIADsOpenDSObject( LPUNKNOWN pUnk, LPUNKNOWN *ppNew);
00056
00057
00058
00059
00060 //{{AFX_INSERT_LOCATION}}
00061 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00062
00063 #endif // !defined(AFX_ADQIDLG_H__81709771_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00064
00065
00066
00067
00068
00069
00070
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/Rcmd/Server.c Source File

  • Security
  • Authorization
  • Rcmd

Server.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011     server.c
00012
00013 Abstract:
00014
00015     This sample illustrates the new DuplicateTokenEx() API for Windows NT 4.0.
00016     This portion of the sample illustrates how to implement a remote cmd
00017     server which launches cmd.exe in the security context of the client that
00018     connected to the server.
00019
00020     When a client connects to the named-pipe, the server process impersonates
00021     the client and then saves a copy of the impersonation token.  This token
00022     is then duplicated via DuplicateTokenEx() to a primary level access token.
00023     The primary level token is then supplied to CreateProcessAsUser(), which
00024     launches a process in the security context of the client.  All threads in
00025     the new process inherit the security context of the client.  All processes
00026     created by the new process inherit the security context of the client.  The
00027     input and output of the new process will be redirected to the client over
00028     the named-pipes, which provides a means of interactively executing commands
00029     remotely in a secure manner.
00030
00031     In order to allow processes to run in a different security context than
00032     the server process, it is necessary to adjust the security on the
00033     windowstation and desktop objects associated with the server process.
00034     This is required to allow for proper console initialization.
00035
00036     For simplicity, this sample applies a Null Dacl to the windowstation and
00037     desktop objects, which is generally not appropriate in a production
00038     environment.  The best approach to selectively secure the windowstation and
00039     desktop objects is to extract the Logon Sid from the access token returned
00040     by DuplicateTokenEx().  The Logon Sid can be extracted with
00041     GetTokenInformation() and then added to an access allowed ace which is
00042     supplied in a Dacl which contains the existing access allowed aces in
00043     addition to the new access allowed ace.
00044
00045     Some additional considerations with this sample follow:
00046
00047     * The account which the server process runs in needs the following two
00048       privileges granted, to allow for the call to CreateProcessAsUser() to
00049       succeed:
00050
00051       SeAssignPrimaryTokenPrivilege (Replace a process level token)
00052       SeIncreateQuotaPrivilege (Increase quotas)
00053
00054     * The security on the initial server side named-pipe allows for Everyone
00055       to connect.  This may present security problems in the event that the
00056       server's file system has not be secured appropriately.  In a production
00057       environment, it may be appropriate to apply a more restrictive Dacl on
00058       the initial named-pipe.
00059
00060     * This sample only allows one client to be connected at a time.
00061
00062     * Any child processes started by the launched process will not be terminated
00063       when the initial child process exits.
00064
00065 --*/
00066
00067 #include <windows.h>
00068 #include <stdio.h>
00069
00070 BOOL
00071 BuildNamedPipeAcl(
00072     PACL pAcl,
00073     PDWORD cbAclSize
00074     );
00075
00076 BOOL
00077 SetupNamedPipes(
00078     PSECURITY_ATTRIBUTES saInbound,
00079     PSECURITY_ATTRIBUTES saOutbound,
00080     PHANDLE hFileIn,
00081     PHANDLE hFileOut
00082     );
00083
00084 BOOL
00085 SetWinstaDesktopSecurity(
00086     void
00087     );
00088
00089 void
00090 DisplayLastError(
00091     LPSTR szAPI // pointer to Ansi function name
00092     );
00093
00094 //
00095 // this defines the commandline that the server will execute in the security
00096 // context of the client.  The /Q switch tells cmd.exe not to echo the
00097 // entered commands back to the client.
00098 //
00099 #define COMMANDLINE     TEXT("cmd.exe /Q")
00100
00101 #define INBOUND_PIPE    TEXT("\\\\.\\pipe\\rcmd_in")
00102 #define OUTBOUND_PIPE   TEXT("\\\\.\\pipe\\rcmd_out")
00103
00104 #define RTN_OK 0
00105 #define RTN_ERROR 13
00106
00107 int
00108 __cdecl
00109 main(
00110     void
00111     )
00112 {
00113     HANDLE hPipeInbound;
00114     HANDLE hPipeOutbound;
00115
00116     SECURITY_ATTRIBUTES saInbound;
00117     SECURITY_DESCRIPTOR sd;
00118
00119     BYTE AclBuf[ 64 ];
00120     DWORD cbAclSize = 64;
00121     PACL pAcl = (PACL)AclBuf;
00122
00123     SECURITY_ATTRIBUTES saOutbound;
00124
00125     HANDLE hImpersonationToken;
00126     HANDLE hPrimaryToken;
00127
00128     STARTUPINFO si;
00129     PROCESS_INFORMATION pi;
00130
00131     //
00132     // suppress errors regarding startup directory, etc
00133     //
00134     SetErrorMode(SEM_FAILCRITICALERRORS);
00135
00136     //
00137     // build security attributes for named-pipes
00138     //
00139     // the inbound pipe will grant Everyone the ability to connect,
00140     // and the server process full control over the pipe.  This way,
00141     // only the server process has the ability to update security
00142     // on the resource; clients can only connect.
00143     //
00144     // the outbound pipe will be built after the server impersonates
00145     // the client, and will inherit the default security of the client
00146     // as a result.  This allows only the same user that connected to
00147     // the inbound pipe to connect to the outbound pipe
00148     //
00149
00150     if(!BuildNamedPipeAcl(pAcl, &cbAclSize)) {
00151         DisplayLastError("BuildNamedPipeAcl");
00152         return RTN_ERROR;
00153     }
00154
00155     if(!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) {
00156         DisplayLastError("InitializeSecurityDescriptor");
00157         return RTN_ERROR;
00158     }
00159
00160     if(!SetSecurityDescriptorDacl(&sd, TRUE, pAcl, FALSE)) {
00161         DisplayLastError("SetSecurityDescriptorDacl");
00162         return RTN_ERROR;
00163     }
00164
00165     saInbound.nLength = sizeof(SECURITY_ATTRIBUTES);
00166     saInbound.lpSecurityDescriptor = &sd;
00167     saInbound.bInheritHandle = TRUE;
00168
00169     saOutbound.nLength = sizeof(SECURITY_ATTRIBUTES);
00170     saOutbound.lpSecurityDescriptor = NULL; // default Dacl of caller
00171     saOutbound.bInheritHandle = TRUE;
00172
00173     //
00174     // modify security on windowstation and desktop to allow for correct
00175     // process and console initialization by arbitrary clients
00176     //
00177     if(!SetWinstaDesktopSecurity()) {
00178         DisplayLastError("SetWinstaDesktopSecurity");
00179         return RTN_ERROR;
00180     }
00181
00182     while(1) {
00183
00184     hPipeInbound = INVALID_HANDLE_VALUE;
00185     hPipeOutbound = INVALID_HANDLE_VALUE;
00186     hImpersonationToken = INVALID_HANDLE_VALUE;
00187     hPrimaryToken = INVALID_HANDLE_VALUE;
00188     pi.hProcess = INVALID_HANDLE_VALUE;
00189     pi.hThread = INVALID_HANDLE_VALUE;
00190
00191     if(!SetupNamedPipes(
00192         &saInbound,
00193         &saOutbound,
00194         &hPipeInbound,
00195         &hPipeOutbound
00196         )) {
00197
00198         //
00199         // just bail out on failure for now
00200         //
00201         DisplayLastError("SetupNamedPipes");
00202         break;
00203     }
00204
00205     //
00206     // obtain the impersonation token from the current thread
00207     //
00208     if(!OpenThreadToken(
00209         GetCurrentThread(),
00210         TOKEN_DUPLICATE,
00211         TRUE,
00212         &hImpersonationToken
00213         )) {
00214         DisplayLastError("OpenThreadToken");
00215         goto cleanup;
00216     }
00217
00218     //
00219     // duplicate the impersonation token to primary
00220     // since we are impersonating the client, the token will get the
00221     // default Dacl of the client
00222     //
00223     if(!DuplicateTokenEx(
00224         hImpersonationToken,
00225         TOKEN_IMPERSONATE | TOKEN_READ |
00226         TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE,
00227         NULL,
00228         SecurityImpersonation,
00229         TokenPrimary,
00230         &hPrimaryToken
00231         )) {
00232         DisplayLastError("DuplicateTokenEx");
00233         goto cleanup;
00234     }
00235
00236     RevertToSelf();
00237     CloseHandle(hImpersonationToken);
00238     hImpersonationToken = INVALID_HANDLE_VALUE;
00239
00240     //
00241     // setup STARTUPINFO structure
00242     //
00243     si.cb = sizeof(STARTUPINFO);
00244     si.lpReserved = NULL;
00245     si.lpDesktop = NULL;
00246     si.lpTitle = NULL;
00247     si.cbReserved2 = 0;
00248     si.lpReserved2 = NULL;
00249     si.dwFlags = STARTF_USESTDHANDLES;
00250     si.hStdOutput = hPipeOutbound;
00251     si.hStdError = hPipeOutbound;
00252     si.hStdInput = hPipeInbound;
00253
00254     //
00255     // create a process running as the user
00256     //
00257
00258     if(!CreateProcessAsUser(
00259         hPrimaryToken,
00260         NULL,
00261         COMMANDLINE, // commandline to execute
00262         NULL,   // process sa
00263         NULL,   // thread sa
00264         TRUE,   // inherit handles?
00265         0,      // process creation flags (inherit existing console)
00266         NULL,   // environment
00267         NULL,   // current directory
00268         &si,    // startupinfo
00269         &pi     // processinfo
00270         )) {
00271         DisplayLastError("CreateProcessAsUser");
00272         goto cleanup;
00273     }
00274
00275 cleanup:
00276
00277     if(hImpersonationToken != INVALID_HANDLE_VALUE) {
00278         RevertToSelf();
00279         CloseHandle(hImpersonationToken);
00280     }
00281
00282     if(hPrimaryToken != INVALID_HANDLE_VALUE) {
00283         CloseHandle(hPrimaryToken);
00284     }
00285
00286     if(pi.hThread != INVALID_HANDLE_VALUE) {
00287         CloseHandle(pi.hThread);
00288     }
00289
00290     if(pi.hProcess != INVALID_HANDLE_VALUE) {
00291         WaitForSingleObject(pi.hProcess, INFINITE);
00292         CloseHandle(pi.hProcess);
00293
00294         //
00295         // TODO kill any child by enumerating process tokens in the system
00296         // by looking at the tokenID
00297         //
00298     }
00299
00300     if(hPipeInbound != INVALID_HANDLE_VALUE) {
00301         DisconnectNamedPipe(hPipeInbound);
00302         CloseHandle(hPipeInbound);
00303     }
00304
00305     if(hPipeOutbound != INVALID_HANDLE_VALUE) {
00306         DisconnectNamedPipe(hPipeOutbound);
00307         CloseHandle(hPipeOutbound);
00308     }
00309
00310     } // while
00311
00312     return RTN_OK;
00313 }
00314
00315 /***
00316  If the function succeeds, the return value is TRUE.  The parameters
00317  hFileIn and hFileOut will point to the Inbound and Outbound named-pipe
00318  handles.  The current thread will be impersonating the client.
00319
00320  If the function fails, the return value is FALSE.  The current thread will
00321  not be impersonating the client.
00322 ***/
00323 BOOL
00324 SetupNamedPipes(
00325     PSECURITY_ATTRIBUTES saInbound, // security attributes for Inbound pipe
00326     PSECURITY_ATTRIBUTES saOutbound,// security attributes for Outbound pipe
00327     PHANDLE hFileIn,                // resultant Inbound pipe handle on success
00328     PHANDLE hFileOut                // resultant Outbound pipe handle on success
00329     )
00330 {
00331     HANDLE hPipeInbound = INVALID_HANDLE_VALUE;
00332     HANDLE hPipeOutbound = INVALID_HANDLE_VALUE;
00333
00334     BOOL bSuccess = FALSE; // assume this function fails
00335
00336     //
00337     // create Inbound named-pipe
00338     //
00339     hPipeInbound = CreateNamedPipe(
00340         INBOUND_PIPE,
00341         PIPE_ACCESS_INBOUND,
00342         PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
00343         1, // number of instances
00344         4096,
00345         4096,
00346         NMPWAIT_USE_DEFAULT_WAIT,
00347         saInbound
00348         );
00349
00350     if(hPipeInbound == INVALID_HANDLE_VALUE) {
00351         DisplayLastError("CreateNamedPipe");
00352         return FALSE;
00353     }
00354
00355     printf("Waiting for connection... ");
00356
00357     //
00358     // wait for somebody to connect to the Inbound named pipe
00359     //
00360     ConnectNamedPipe(hPipeInbound, NULL);
00361
00362     //
00363     // impersonate the client
00364     //
00365     if(!ImpersonateNamedPipeClient(hPipeInbound)) {
00366         DisplayLastError("ImpersonateNamedPipeClient");
00367         goto cleanup;
00368     }
00369
00370     //
00371     // create Outbound named-pipe
00372     // the security on this named-pipe will be inherited from the default Dacl
00373     // of the client that just connected, because this pipe instance is
00374     // created in that users security context.  This prevents other users
00375     // from connecting to the Outbound pipe.
00376     //
00377     hPipeOutbound = CreateNamedPipe(
00378         OUTBOUND_PIPE,
00379         PIPE_ACCESS_OUTBOUND,
00380         PIPE_TYPE_MESSAGE | PIPE_WAIT,
00381         1, // number of instances
00382         4096,
00383         4096,
00384         NMPWAIT_USE_DEFAULT_WAIT,
00385         saOutbound
00386         );
00387
00388     if(hPipeOutbound == INVALID_HANDLE_VALUE) {
00389         DisplayLastError("CreateNamedPipe");
00390         goto cleanup;
00391     }
00392
00393     //
00394     // wait for the client to connect to the Outbound named pipe
00395     //
00396     ConnectNamedPipe(hPipeOutbound, NULL);
00397
00398     printf("Client connected!\n");
00399
00400     *hFileIn = hPipeInbound;
00401     *hFileOut = hPipeOutbound;
00402
00403     bSuccess = TRUE;
00404
00405 cleanup:
00406
00407     if(!bSuccess) {
00408         RevertToSelf();
00409
00410         if(hPipeInbound != INVALID_HANDLE_VALUE)
00411             CloseHandle(hPipeInbound);
00412         if(hPipeOutbound != INVALID_HANDLE_VALUE)
00413             CloseHandle(hPipeOutbound);
00414     }
00415
00416     return bSuccess;
00417 }
00418
00419 /**
00420 This function builds a Dacl which grants the creator of the objects
00421 FILE_ALL_ACCESS and Everyone FILE_GENERIC_READ and FILE_GENERIC_WRITE
00422 access to the object.
00423
00424 This Dacl allows for higher security than a NULL Dacl, which is common for
00425 named-pipes, as this only grants the creator/owner write access to the
00426 security descriptor, and grants Everyone the ability to "use" the named-pipe.
00427 This scenario prevents a malevolent user from disrupting service by preventing
00428 arbitrary access manipulation.
00429 **/
00430 BOOL
00431 BuildNamedPipeAcl(
00432     PACL pAcl,
00433     PDWORD cbAclSize
00434     )
00435 {
00436     DWORD dwAclSize;
00437
00438     SID_IDENTIFIER_AUTHORITY siaWorld = SECURITY_WORLD_SID_AUTHORITY;
00439     SID_IDENTIFIER_AUTHORITY siaCreator = SECURITY_CREATOR_SID_AUTHORITY;
00440
00441     BYTE BufEveryoneSid[32];
00442     BYTE BufOwnerSid[32];
00443
00444     PSID pEveryoneSid = (PSID)BufEveryoneSid;
00445     PSID pOwnerSid = (PSID)BufOwnerSid;
00446
00447     //
00448     // compute size of acl
00449     //
00450     dwAclSize = sizeof(ACL) +
00451         2 * ( sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) ) +
00452         GetSidLengthRequired( 1 ) + // well-known Everyone Sid
00453         GetSidLengthRequired( 1 ) ; // well-known Creator Owner Sid
00454
00455     if(*cbAclSize < dwAclSize) {
00456         *cbAclSize = dwAclSize;
00457         return FALSE;
00458     }
00459
00460     *cbAclSize = dwAclSize;
00461
00462     //
00463     // intialize well known sids
00464     //
00465
00466     if(!InitializeSid(pEveryoneSid, &siaWorld, 1)) return FALSE;
00467     *GetSidSubAuthority(pEveryoneSid, 0) = SECURITY_WORLD_RID;
00468
00469     if(!InitializeSid(pOwnerSid, &siaCreator, 1)) return FALSE;
00470     *GetSidSubAuthority(pOwnerSid, 0) = SECURITY_CREATOR_OWNER_RID;
00471
00472     if(!InitializeAcl(pAcl, dwAclSize, ACL_REVISION))
00473         return FALSE;
00474
00475     //
00476     //
00477     if(!AddAccessAllowedAce(
00478         pAcl,
00479         ACL_REVISION,
00480         FILE_GENERIC_READ | FILE_GENERIC_WRITE,
00481         pEveryoneSid
00482         ))
00483         return FALSE;
00484
00485     //
00486     //
00487     return AddAccessAllowedAce(
00488         pAcl,
00489         ACL_REVISION,
00490         FILE_ALL_ACCESS,
00491         pOwnerSid
00492         );
00493 }
00494
00495 /**
00496 This function adjusts the security on the current windowstation and desktop,
00497 to allow arbitrary client to have access to the windowstation and desktop.
00498 This is necessary to allow for correct process and console initialization.
00499
00500 Note that in a secure environment, it would be appropriate to create
00501 a specific desktop and launch the process spawned by the client on that
00502 desktop, rather than opening up the current desktop to the client.
00503
00504 This function simply applies a NULL Dacl to the current windowstation and
00505 desktop in order to reduce the size of this sample.  Applying NULL Dacls
00506 to objects is generally not a wise idea.
00507
00508 TODO revist this function later to better address security on the windowstation
00509 and desktop.
00510 **/
00511 BOOL
00512 SetWinstaDesktopSecurity(
00513     void
00514     )
00515 {
00516     HWINSTA hWinsta;
00517     HDESK hDesk;
00518
00519     SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;
00520     SECURITY_DESCRIPTOR sd;
00521
00522     hWinsta = GetProcessWindowStation();
00523     if(hWinsta == NULL) return FALSE;
00524
00525     hDesk = GetThreadDesktop(GetCurrentThreadId());
00526     if(hDesk == NULL) return FALSE;
00527
00528     InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
00529     SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE);
00530
00531     if(!SetUserObjectSecurity(hWinsta, &si, &sd)) return FALSE;
00532
00533     return SetUserObjectSecurity(hDesk, &si, &sd);
00534 }
00535
00536 void
00537 DisplayLastError(
00538     LPSTR szAPI // pointer to Ansi function name
00539     )
00540 {
00541     LPSTR MessageBuffer;
00542     DWORD dwBufferLength;
00543
00544     //
00545     // TODO get this fprintf out of here!
00546     //
00547     fprintf(stderr,"%s error!\n", szAPI);
00548
00549     if(dwBufferLength=FormatMessageA(
00550             FORMAT_MESSAGE_ALLOCATE_BUFFER |
00551             FORMAT_MESSAGE_FROM_SYSTEM,
00552             NULL,
00553             GetLastError(),
00554             MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00555             (LPSTR) &MessageBuffer,
00556             0,
00557             NULL
00558             ))
00559     {
00560         DWORD dwBytesWritten; // unused
00561
00562         //
00563         // Output message string on stderr
00564         //
00565         WriteFile(
00566                 GetStdHandle(STD_ERROR_HANDLE),
00567                 MessageBuffer,
00568                 dwBufferLength,
00569                 &dwBytesWritten,
00570                 NULL
00571                 );
00572
00573         //
00574         // free the buffer allocated by the system
00575         //
00576         LocalFree(MessageBuffer);
00577     }
00578 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/omniprov/source/cdbfile.cpp Source File

  • Dataaccess
  • oledb
  • omniprov
  • source

cdbfile.cpp

Go to the documentation of this file.
00001 #include "stdafx.h"
00002 #include "CDBFile.h"
00003
00004 // The Constructor
00005 CDBFile::~CDBFile()
00006 {
00007   int nSize = m_Rows.GetSize();
00008   for (int n = 0; n < nSize; n++)
00009     delete m_Rows[n];
00010   // Close the file
00011   if(!m_bClosed)
00012     Close();
00013   // Delete the m_prgColInfo
00014   if (NULL != m_prgColInfo)
00015     delete m_prgColInfo;
00016 }
00017
00018
00019 bool CDBFile::Open(LPCTSTR szFileName, bool bOpenMode)  // 0 = Open Exclusive mode
00020 {
00021   TCHAR pszFileName[_MAX_PATH];
00022     _tcscpy(pszFileName,szFileName);
00023   // Open schema .sxt file
00024   if (!GetFileSchemaInfo(pszFileName))
00025   {
00026     // An error occured opening schema file
00027     OUT_LINE_FILE();
00028     return false;
00029   }
00030
00031   // Get the Data file from the schema file
00032   pszFileName[_tcslen(szFileName) - 3] = 't';
00033
00034   if(true == bOpenMode)
00035   {
00036     m_hFile = CreateFile(pszFileName, GENERIC_READ | GENERIC_WRITE, 0 /* open file for exclusive use*/,
00037            NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
00038   }
00039   else
00040   {
00041     m_hFile = CreateFile(pszFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ /* open file for non-exclusive use*/,
00042            NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
00043   }
00044
00045   if (m_hFile == INVALID_HANDLE_VALUE)
00046   {
00047     // An error occured opening the file
00048     OUT_LINE_FILE();
00049     return false;
00050   }
00051
00052   m_hMapFile = CreateFileMapping(m_hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
00053   if (m_hMapFile == NULL)
00054   {
00055     OUT_LINE_FILE();
00056     return false;
00057   }
00058
00059   // Create just one view of the memory-mapped file
00060   m_pFileMap = MapViewOfFile(m_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
00061   if (m_pFileMap == NULL)
00062   {
00063     OUT_LINE_FILE();
00064     return false;
00065   }
00066
00067   m_pbEOF = (char *) m_pFileMap + GetFileSize(m_hFile, NULL) -1;
00068
00069   m_bClosed = false;
00070
00071   return true;
00072 }
00073
00074 // Close the File
00075
00076 bool CDBFile::Close()
00077 {
00078   int nFileSize = m_pbEOF - (char *)m_pFileMap + 1;
00079
00080   UnmapViewOfFile(m_pFileMap);
00081
00082   CloseHandle(m_hMapFile);
00083
00084   CloseHandle(m_hFile);
00085
00086   m_bClosed = true;
00087
00088   return m_bClosed;
00089 }
00090
00091 // Allocate and Fill CRow objects
00092
00093 bool CDBFile::FillRowArray()
00094 {
00095   CRow *pRow;
00096   m_pbCurrentPos = (char *)m_pFileMap;
00097   int iIndex = 0;
00098   int nRet;
00099
00100   while (nRet = FetchRow(&pRow) == FETCH_SUCCESS)
00101   {
00102     // Row fetched successfully. Add it to the array.
00103     pRow->m_bmk = ++iIndex;
00104     m_Rows.Add(pRow);
00105   }
00106
00107   if (ERROR_IN_ROW_DATA == nRet)
00108   {
00109     OUT_LINE_FILE();
00110     return false; // fatal error
00111   }
00112
00113   return true;
00114 }
00115
00116
00117 int CDBFile::FetchRow(CRow** ppRow)
00118 {
00119   if (m_pbCurrentPos > m_pbEOF)
00120     return LAST_ROW_FETCHED;    // we were already at the end of the line and therefore there is no row to fetch
00121
00122   CRow *pRow = new CRow;
00123
00124   pRow->m_pbStartLoc = m_pbCurrentPos;
00125
00126   int cbRowSize = 0;
00127   while (m_pbCurrentPos <= m_pbEOF && *m_pbCurrentPos != '\r')
00128   {
00129     m_pbCurrentPos++;
00130     cbRowSize++;
00131   }
00132
00133
00134   if (m_pbCurrentPos <= m_pbEOF)
00135   {
00136     // not EOF
00137     if (*m_pbCurrentPos == '\r' && *(m_pbCurrentPos+1) == '\n')
00138       m_pbCurrentPos+=2;  // skip the carriage return
00139     else
00140     {
00141       if (*m_pbCurrentPos == '\r')
00142       {
00143         delete pRow;
00144         return ERROR_IN_ROW_DATA;  // error because there was a \r without a \n
00145       }
00146     }
00147   }
00148
00149   pRow->m_cbRowSize = cbRowSize;  // cbRowSize does not include the carriage return - line feed
00150
00151   // defer filling the CColumn elements until the row is fetched and the data is fetched using IRowset::GetData
00152
00153   *ppRow = pRow;
00154   return FETCH_SUCCESS;
00155
00156 }
00157
00158
00159 ATLCOLUMNINFO * CDBFile::GetSchemaInfo(ULONG * pNumCols)
00160 {
00161   // Allocate the column information only once  as the functions we are returning the
00162   // data from don't free.
00163   *pNumCols = m_cCols;
00164
00165   return m_prgColInfo;
00166 }
00167
00168 bool CDBFile::GetFileSchemaInfo(LPCTSTR pszFileName)
00169 {
00170 //  Do a bunch of stuff to get the schema information from the file
00171
00172   USES_CONVERSION;
00173
00174   TCHAR szTmpFileName[_MAX_PATH];
00175   if(_MAX_PATH < _tcslen(pszFileName) )
00176   {
00177     ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: File path cannot be larger than 260 characters...\n");
00178     return false;
00179   }
00180   _tcscpy(szTmpFileName,pszFileName);
00181   szTmpFileName[_tcslen(szTmpFileName) - 3] = 's';
00182
00183   FILE *fptr;
00184   if( !(fptr=fopen(szTmpFileName,"r")) )
00185   {
00186     ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Schema file cannot be read...\n");
00187     return false;
00188   }
00189
00190   // Start reading the file...
00191   // Expected Format of the Schema file
00192     // <Table_Properties> <Column_Properties>[,...n]
00193     // Syntax :
00194   // <Table_Properties> ::= <Table_Name> <Number_of_Fields> <New_Line>
00195   // <Table_Name> ::= <Table_Alphabet>[1,....,20]
00196   // <Table_Alphabet> ::= [a,...,z] | [0,...9]
00197   // <Number_of_Fields> ::= [0,...,255]
00198   // <Table_Properties> ::= <Table_Name> <Number_of_Fields> <New_Line>
00199   // <Column_Properties> ::= <Column_Name> <Column_Type> <Column_Precision> <Column_Size><New_Line>
00200   // <Column_Name> ::= <Column_Alphabet>[1,....,20]
00201   // <Column_Alphabet> ::= [a,...,z] | [0,...9]
00202   // <Column_Type> ::= DBTYPE_I4 | DBTYPE_STR
00203   // <Column_Presicion> ::= [1...255]
00204   // <Column_Size> ::= [1...255]
00205   // <New_Line> ::= '\n'
00206
00207     // Get the <Table_Properties>
00208   char szTblNm[40],szColNm[40],szColType[20];
00209   ULONG ulNumFld, ulColPrec, ulColSize;
00210   ulNumFld=ulColPrec=ulColSize =0;
00211
00212   fscanf(fptr,"%s %d",szTblNm,&ulNumFld);
00213   if(_tcslen(szTblNm) > 20)
00214   {
00215     ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Table Name too long...\n");
00216     return false;
00217   }
00218   else if(ulNumFld > 255 || ulNumFld < 1)
00219   {
00220     ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Incorrect Number of fields specified...\n");
00221     return false;
00222   }
00223   // Set the number of columns
00224   m_cCols = ulNumFld;
00225   // Set Table_Name
00226   _tcscpy(m_szTblNm,szTblNm);
00227   // Build the ColumnInfo structure
00228   m_prgColInfo = new ATLCOLUMNINFO[(sizeof(ATLCOLUMNINFO) * ulNumFld)];
00229     // Get the <Column_Properties>
00230   for(ULONG ulColCnt = 0; ulColCnt < ulNumFld; ulColCnt++)
00231   {
00232     fscanf(fptr,"%s %s %d %d",szColNm,szColType,&ulColPrec,&ulColSize);
00233     if (_tcslen(szColNm) > 20)
00234     {
00235       ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Column Name too long...\n");
00236       return false;
00237     }
00238     else if (_tcscmp(szColType,"DBTYPE_I4") != 0 && _tcscmp(szColType,"DBTYPE_STR") != 0 )
00239     {
00240       ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Only DBTYPE_I4 or DBTYPE_STR types supported...\n");
00241       return false;
00242     }
00243     else if( (ulColPrec < 1 || ulColPrec > 255) && (_tcscmp(szColType,"DBTYPE_I4") == 0) )
00244     {
00245       ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Incorrect Column Precision specified...\n");
00246       return false;
00247     }
00248     else if ((ulColSize < 1 || ulColSize > 255) && (_tcscmp(szColType,"DBTYPE_STR") == 0) )
00249     {
00250       ATLTRACE2(atlTraceDBProvider, 0, "FILE ERROR: Incorrect Column Size specified...\n");
00251       return false;
00252     }
00253
00254     // Do the assignment into the ATLCOLUMNINFO structure
00255     DWORD dwFlags = DBCOLUMNFLAGS_WRITE;
00256     memset(&m_prgColInfo[ulColCnt], 0, sizeof(ATLCOLUMNINFO));
00257     m_prgColInfo[ulColCnt].iOrdinal = ulColCnt + 1;
00258     m_prgColInfo[ulColCnt].columnid.eKind = DBKIND_GUID_NAME; //DBKIND_NAME;
00259     m_prgColInfo[ulColCnt].pTypeInfo = (ITypeInfo*)NULL;
00260     m_prgColInfo[ulColCnt].columnid.uGuid.guid = GUID_NULL;
00261     m_prgColInfo[ulColCnt].dwFlags = dwFlags;
00262     m_prgColInfo[ulColCnt].bScale = -1;
00263     // User modifiable Attributes
00264     m_prgColInfo[ulColCnt].columnid.uName.pwszName = SysAllocString(T2OLE(szColNm));
00265     m_prgColInfo[ulColCnt].pwszName = SysAllocString(T2OLE(szColNm));
00266     if(_tcscmp(szColType,"DBTYPE_I4") == 0)
00267     {
00268       m_prgColInfo[ulColCnt].ulColumnSize = 4;
00269       m_prgColInfo[ulColCnt].bPrecision = (BYTE) ulColPrec;
00270       m_prgColInfo[ulColCnt].wType = DBTYPE_I4;
00271     }
00272     else  //DBTYPE_STR
00273     {
00274       m_prgColInfo[ulColCnt].ulColumnSize = ulColSize;
00275       m_prgColInfo[ulColCnt].bPrecision = -1;
00276       m_prgColInfo[ulColCnt].wType = DBTYPE_STR;
00277     }
00278     if(0 == ulColCnt)
00279       m_prgColInfo[ulColCnt].cbOffset = 0;
00280     else
00281       m_prgColInfo[ulColCnt].cbOffset = m_prgColInfo[ulColCnt-1].cbOffset + m_prgColInfo[ulColCnt-1].ulColumnSize;
00282
00283   }
00284   return true;
00285 }
00286
00287
00288 //TODO: remove this function - should be move to rowset because rowset will have
00289 //      final column information
00290 void CDBFile::AllocateProxyBuffers(bool bUseBookmarks)
00291 {
00292   int nSize = m_Rows.GetSize();
00293   for (int i = 0; i < nSize; i++)
00294   {
00295     m_Rows[i]->AllocProxyBuffer(m_prgColInfo, m_cCols);
00296   }
00297
00298 }
00299
00300
00301 // DeleteRowImmediate:
00302 //  This function deletes the row from the file immediately.
00303 //  The record is not marked for deletion but is immediately removed.
00304 //  With large files, this function may be expensive and it is
00305 //  recommended that the consumer use deferred updates (IRowestUpdate)
00306 //int CDBFile::DeleteRowImmediate(CRow * pRow, ULONG ulRow)
00307 int CDBFile::DeleteRowImmediate(CRow * pRow)
00308 {
00309   // TODO: could derive row number from the bookmark. Should we do this?
00310
00311   // CRow contains the starting location and the the row size
00312   // Special consideration: if this is the last row, there may not be
00313   // a "\r\n" pair so we need to check for this in the calculations
00314   // If it is not the last row being deleted then we need to subtract 2 bytes from
00315   // the file count.
00316   ULONG ulRow = pRow->m_bmk;
00317   ULONG ulActRow = ulRow -1;  // Actual Row is Bookmark - 1
00318
00319   int nRows = m_Rows.GetSize();
00320
00321   BYTE *  pbOldEOF = (BYTE *)m_pbEOF;
00322
00323   // check for last element of the array
00324   //if (ulRow == (ULONG)nRows -1)
00325   if (ulRow == (ULONG)nRows)
00326   {
00327 //    m_pbEOF = m_Rows[ulRow]->m_pbStartLoc - 1;
00328     m_pbEOF = m_Rows[ulActRow]->m_pbStartLoc - 1;
00329     // For the last element update the bookmark too
00330     m_Rows[ulActRow]->m_bmk --;
00331   }
00332   else
00333   {
00334     // Copy record over previous record
00335     // Row sizes will stay the same.
00336 //    BYTE * pbDest = (BYTE *)m_Rows[ulRow]->m_pbStartLoc;
00337     BYTE * pbDest = (BYTE *)m_Rows[ulActRow]->m_pbStartLoc;
00338     BYTE * pbSrc;
00339     for (int i = ulActRow+1; i < nRows; i++)
00340     {
00341       pbSrc = (BYTE *)m_Rows[i]->m_pbStartLoc;
00342       m_Rows[i]->m_pbStartLoc = (char *)pbDest;
00343       // m_Rows[i]->m_bmk = m_Rows[i-1]->m_bmk;
00344       m_Rows[i]->m_bmk --;
00345
00346
00347       for (int c = 0; c < m_Rows[i]->m_cbRowSize; c++)
00348       {
00349         *pbDest++ = *pbSrc++;
00350       }
00351
00352       // add carriage return - line feed
00353       *pbDest++ = '\r';
00354       *pbDest++ = '\n';
00355
00356     }
00357     m_pbEOF = (char *)pbDest-1;  // this will be used to set the end of file when we close the file
00358   }
00359
00360   // slide everything up  - this is OK because only ReleaseRows will ever reference the row again
00361 //    m_Rows[ulActRow]->m_bDeleted = true;
00362   if(1 == m_Rows.GetSize( ))
00363     m_Rows.RemoveAll();
00364   else
00365   {
00366     if (!(m_Rows.RemoveAt(ulActRow)))
00367       return S_FALSE;
00368   }
00369   // Close and re-open the file so that the transaction is completely done and the file is completely modified
00370   // This is an expensive operation but is done to ensure that the file is not currupted if the application is terminated
00371   // and the CDBFile is not closed properly
00372   SaveAndReOpenFile();
00373
00374   return S_OK;
00375 }
00376
00377 HRESULT CDBFile::UpdateRowImmediate(CRow * pRow, ATLCOLUMNINFO * prgColInfo, ULONG ulCols)
00378 {
00379   // TODO: currently we are updating the lazy way  - just take and move everything to make
00380   // space or shrink the row.
00381   //
00382   //  If the updated row is smaller than it was before, we will fill the rest of the row with white
00383   //  space as we will strip off any white space in the reading of the row.
00384   //
00385   //  If the updated row is larger than the existing row, we move everything to make
00386   //  space.  Other algorithms, could be used which wouldn't cause the shuffling of all of the
00387   //  data but this would probably mean some kind of mechanism of marking rows as deleted.
00388   //  TODO: need to revist this
00389   bool bAddEOLtoEOF= false;
00390   bool bModifyEOF = false;
00391   ULONG ulBytesNeeded;
00392   ULONG ulBytesToDelete = 0;
00393   HRESULT hr = S_OK;
00394
00395   if ((ulBytesNeeded = pRow->CalculateRowData(prgColInfo, ulCols) )> 0)
00396   {
00397     if ( !(pRow->HasEOL((BYTE*)m_pbEOF)) )
00398     {
00399       ulBytesNeeded += 2;  // add space needed to add a \r\n which may not be there
00400                 // if this is the last row
00401       bAddEOLtoEOF = true;
00402     }
00403     // Accomodate pre-existing EOL which is not part of the data
00404     ULONG ulBytesToMove  = 0;
00405     ulBytesToMove = (ULONG)m_pbEOF - (ULONG)(pRow->m_pbStartLoc + pRow->m_cbRowSize) + 1;
00406
00407     // need to make space for updated row
00408     ExpandFileAndAdjustRowObjects(ulBytesNeeded,EXPAND_FILE);
00409     if(true== bAddEOLtoEOF)
00410     {
00411       *(m_pbEOF-1) = '\r';
00412       *m_pbEOF = '\n';
00413     }
00414     // end of current row
00415     BYTE * pbEOR = NULL;
00416       pbEOR =  (BYTE *)pRow->m_pbStartLoc + pRow->m_cbRowSize;
00417     // Move rows to make room for new row
00418     //Move bytes from end of row to EOF - ulBytesNeeded
00419     memmove(pbEOR + ulBytesNeeded, pbEOR, ulBytesToMove);
00420   }
00421   // If the data updated is less-than previously - implode the data
00422   else if (0 == ulBytesNeeded )
00423   {
00424     // This ulBytesNeeded has to be positive
00425     ulBytesToDelete = pRow->CalculateRowDataToDelete(prgColInfo, ulCols);
00426     if(true == m_Rows[m_Rows.m_nSize-1]->HasEOL((BYTE*) m_pbEOF) )
00427       bModifyEOF = true;
00428
00429     // Accomodate pre-existing EOL which is not part of the data
00430     ULONG ulBytesToMove  = 0;
00431     ulBytesToMove = (ULONG)m_pbEOF - (ULONG)(pRow->m_pbStartLoc + pRow->m_cbRowSize) + 1;
00432
00433     char*pprevEOF = m_pbEOF;
00434     ExpandFileAndAdjustRowObjects(ulBytesToDelete, CONTRACT_FILE);
00435
00436     BYTE * pbEOR = NULL;
00437     pbEOR =  (BYTE *)pRow->m_pbStartLoc + pRow->m_cbRowSize;
00438     //Move bytes from end of row to EOF - ulBytesNeeded
00439     memmove(pbEOR - ulBytesToDelete, pbEOR, ulBytesToMove);
00440     if(   (ULONG)( pprevEOF - m_pbEOF) == ulBytesToDelete) // The file was not reallocated....
00441     {  // Since no new memory was allocated for the data
00442       // there could junk between the current (smaller) EOF and the prev EOF...
00443       // This could be picked up when writing the file
00444       memset(m_pbEOF+1, 0, ulBytesToDelete);
00445     }
00446   }
00447    // If the Number of Bytes required are in Error !!!
00448   else if(ulBytesNeeded < 0)
00449       return DB_E_DATAOVERFLOW;
00450
00451   // now that there is space allocated, simply dump the row's data
00452   pRow->Update(prgColInfo, ulCols); // write the data to the file
00453   // The Start Location of all the remaining Rows need to be updated...
00454   if(ulBytesNeeded > 0)
00455     for(long iRow = pRow->m_bmk; iRow< m_Rows.m_nSize; iRow++)
00456       m_Rows[iRow]->m_pbStartLoc += ulBytesNeeded;
00457    else if(0 == ulBytesNeeded)
00458      for(long iRow = pRow->m_bmk; iRow< m_Rows.m_nSize; iRow++)
00459       m_Rows[iRow]->m_pbStartLoc -= ulBytesToDelete;
00460
00461   // commit data to disk
00462   BOOL bSuccess = FlushViewOfFile(m_pFileMap, m_pbEOF - (char *)m_pFileMap + 1);
00463   if (!bSuccess)
00464     return E_OUTOFMEMORY;  // This is a generic error message for the present
00465 //    return DBFILE_FLUSH_ERROR;
00466   return 0;
00467 }
00468
00469
00470 int CDBFile::SaveAndReOpenFile()
00471 {
00472   void * pFileMapOld = m_pFileMap;
00473   int nFileSize = m_pbEOF - (char *)m_pFileMap + 1;
00474
00475   // commit data to disk
00476   BOOL bSuccess = FlushViewOfFile(m_pFileMap, nFileSize);
00477   if (!bSuccess)
00478     return DBFILE_FLUSH_ERROR;
00479
00480   pFileMapOld = m_pFileMap;
00481
00482   UnmapViewOfFile(m_pFileMap);
00483
00484   CloseHandle(m_hMapFile);
00485
00486   SetFilePointer(m_hFile, nFileSize, NULL, FILE_BEGIN);
00487
00488   SetEndOfFile(m_hFile);
00489   // CloseHandle(m_hFile);  don't actually close file
00490
00491   // re-open and adjust row objects based on a new adjust potentially
00492   m_hMapFile = CreateFileMapping(m_hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
00493   if (m_hMapFile == NULL)
00494   {
00495     OUT_LINE_FILE();
00496     return false;
00497   }
00498
00499   // Create just one view of the memory-mapped file
00500   m_pFileMap = MapViewOfFile(m_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
00501   if (m_pFileMap == NULL)
00502   {
00503     OUT_LINE_FILE();
00504     return false;
00505   }
00506
00507   // Check to see if the mapping address has changed.  If it has, must recalculate all
00508   // CRow objects.
00509   if (m_pFileMap != pFileMapOld)
00510   {
00511     // calculate adjustment
00512     long nAdjustment = (long)m_pFileMap - (long)pFileMapOld;
00513
00514     int nSize = m_Rows.GetSize();
00515     for (int iRow = 0; iRow < nSize; iRow++)
00516     {
00517       m_Rows[iRow]->m_pbStartLoc += nAdjustment;
00518     }
00519
00520     m_pbEOF += nAdjustment;
00521   }
00522
00523   return true;
00524 }
00525
00526
00527
00528 int CDBFile::ExpandFileAndAdjustRowObjects(ULONG ulBytesNeeded, bool bExpOrCon)
00529 {
00530   void * pFileMapOld = m_pFileMap;
00531   int nFileSize = m_pbEOF - (char *)m_pFileMap + 1;
00532
00533   // commit data to disk
00534 //  BOOL bSuccess = FlushViewOfFile(m_pFileMap, nFileSize);
00535 //  if (!bSuccess)
00536 //    return DBFILE_FLUSH_ERROR;
00537
00538   pFileMapOld = m_pFileMap;
00539
00540   UnmapViewOfFile(m_pFileMap);
00541
00542   CloseHandle(m_hMapFile);
00543
00544 //  SetFilePointer(m_hFile, nFileSize, NULL, FILE_BEGIN);
00545
00546 //  SetEndOfFile(m_hFile);
00547   // CloseHandle(m_hFile);  don't actually close file
00548
00549   // re-open and adjust row objects based on a new address potentially
00550   if(EXPAND_FILE == bExpOrCon)
00551     m_hMapFile = CreateFileMapping(m_hFile, NULL, PAGE_READWRITE, 0, nFileSize + ulBytesNeeded, NULL);
00552   else
00553     m_hMapFile = CreateFileMapping(m_hFile, NULL, PAGE_READWRITE, 0, nFileSize - ulBytesNeeded, NULL);
00554
00555   if (m_hMapFile == NULL)
00556   {
00557     OUT_LINE_FILE();
00558     return false;
00559   }
00560
00561   // Create just one view of the memory-mapped file
00562   m_pFileMap = MapViewOfFile(m_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
00563   if (m_pFileMap == NULL)
00564   {
00565     OUT_LINE_FILE();
00566     return false;
00567   }
00568
00569   // Check to see if the mapping address has changed.  If it has, must recalculate all
00570   // CRow objects.
00571   if (m_pFileMap != pFileMapOld)
00572   {
00573     // calculate adjustment
00574     long nAdjustment = (long)m_pFileMap - (long)pFileMapOld;
00575
00576     int nSize = m_Rows.GetSize();
00577     for (int iRow = 0; iRow < nSize; iRow++)
00578     {
00579       m_Rows[iRow]->m_pbStartLoc += nAdjustment;
00580     }
00581
00582     if(EXPAND_FILE == bExpOrCon)
00583       m_pbEOF += nAdjustment + ulBytesNeeded;
00584     else
00585       m_pbEOF += nAdjustment - ulBytesNeeded;
00586   }
00587   else
00588   {
00589     if(EXPAND_FILE == bExpOrCon)
00590       m_pbEOF += ulBytesNeeded;
00591     else
00592       m_pbEOF -= ulBytesNeeded;
00593   }
00594
00595   return 0;
00596 }
00597
00598 HRESULT CDBFile::InsertRowImmediate(CRow * pRow, ATLCOLUMNINFO * prgColInfo, ULONG ulCols, bool bData)
00599 {
00600   bool bAddEOL=false;
00601   ULONG ulBytesNeeded;
00602
00603   if(bData == true)  // Data is contained in the Row
00604     ulBytesNeeded = pRow->CalculateRowData(prgColInfo, ulCols); // m_cbRowsize == 0 when this called
00605   else
00606     ulBytesNeeded = pRow->CreateDefaultRow(prgColInfo, ulCols);
00607   // If the Number of Bytes required are in Error !!!
00608   if (ulBytesNeeded < 0)
00609     return DB_E_DATAOVERFLOW;
00610
00611   // To accomodate the \r \n at the end of the line
00612   ulBytesNeeded += 2;
00613
00614   // Check if the previous line if any had any EOL
00615   if(pRow->m_bmk > 1)
00616   {
00617     if (!(m_Rows[(pRow->m_bmk) - 2]->HasEOL((BYTE*)m_pbEOF)))
00618     {
00619       ulBytesNeeded += 2;  // add space needed to add a \r\n which may not be there
00620                 // if this is the last row
00621       bAddEOL = true;
00622     }
00623   }
00624   // need to make space for updated row
00625   ExpandFileAndAdjustRowObjects(ulBytesNeeded);
00626
00627   // add \r\n on end of row if necessary
00628   if (bAddEOL)
00629   {
00630     m_Rows[pRow->m_bmk - 1]->AddEOL();
00631     // adjust start location of pRow
00632     pRow->AdjustStartLocationForEOL();
00633   }
00634
00635   // now that there is space allocated, simply dump the row's data
00636   pRow->Update(prgColInfo, ulCols); // write the data to the file
00637
00638   pRow->AddEOL();
00639
00640   // commit data to disk
00641   BOOL bSuccess = FlushViewOfFile(m_pFileMap, m_pbEOF - (char *)m_pFileMap + 1);
00642   if (!bSuccess)
00643     return DBFILE_FLUSH_ERROR;
00644
00645   return 0;
00646
00647 }
00648
00649 BOOL CDBFile::AddRow(CRow * pRow, ATLCOLUMNINFO * prgColInfo, ULONG ulCols)
00650 {
00651   pRow->m_cbRowSize = 0;
00652   pRow->AllocProxyBuffer(prgColInfo, ulCols);
00653   pRow->m_pbStartLoc = m_pbEOF + 1;
00654   BOOL bTmp = m_Rows.Add(pRow);
00655   if (bTmp == TRUE)
00656     pRow->m_bmk = m_Rows.GetSize(); // Initialize it
00657    return bTmp;
00658 }
00659
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/NewDocDlg.Cpp Source File

  • NetDS
  • fax
  • PrintSdi

NewDocDlg.Cpp

Go to the documentation of this file.
00001 // NewDocDlg.cpp : implementation file
00002 //
00003
00004 #include "stdafx.h"
00005 #include "PrintSDI.h"
00006 #include "NewDocDlg.h"
00007
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // NewDocDlg dialog
00016
00017
00018 NewDocDlg::NewDocDlg(CWnd* pParent /*=NULL*/)
00019   : CDialog(NewDocDlg::IDD, pParent)
00020 {
00021   //{{AFX_DATA_INIT(NewDocDlg)
00022   m_szText = _T("");
00023   m_polytype = -1;
00024   //}}AFX_DATA_INIT
00025 }
00026
00027
00028 void NewDocDlg::DoDataExchange(CDataExchange* pDX)
00029 {
00030   CDialog::DoDataExchange(pDX);
00031   //{{AFX_DATA_MAP(NewDocDlg)
00032   DDX_Text(pDX, IDC_EDIT1, m_szText);
00033   DDX_Radio(pDX, IDC_CIRCLE, m_polytype);
00034   //}}AFX_DATA_MAP
00035 }
00036
00037
00038 BEGIN_MESSAGE_MAP(NewDocDlg, CDialog)
00039   //{{AFX_MSG_MAP(NewDocDlg)
00040     // NOTE: the ClassWizard will add message map macros here
00041   //}}AFX_MSG_MAP
00042 END_MESSAGE_MAP()
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // NewDocDlg message handlers
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/atl/mmccontrol.Cpp Source File

  • SysMgmt
  • MMC
  • ActiveX
  • atl

mmccontrol.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // MMCControl.cpp : Implementation of CMMCControl
00020
00021 #include "stdafx.h"
00022 #include "ATLControl.h"
00023 #include "MMCControl.h"
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // CMMCControl
00027
00028
00029 STDMETHODIMP CMMCControl::StartAnimation()
00030 {
00031     m_bAnimating = TRUE;
00032
00033     SetDlgItemText(IDC_ANIMATIONSTATE, _TEXT("Animation Running"));
00034     SetDlgItemText(IDC_ANIMATE, _TEXT("Stop"));
00035
00036     OutputDebugString(_TEXT("CMMCControl_StartAnimation\n"));
00037
00038   return S_OK;
00039 }
00040
00041 STDMETHODIMP CMMCControl::StopAnimation()
00042 {
00043     m_bAnimating = FALSE;
00044
00045     SetDlgItemText(IDC_ANIMATIONSTATE, _TEXT("Animation Stopped"));
00046     SetDlgItemText(IDC_ANIMATE, _TEXT("Start"));
00047
00048     OutputDebugString(_TEXT("CMMCControl_StopAnimation\n"));
00049
00050   return S_OK;
00051 }
00052
00053 STDMETHODIMP CMMCControl::DoHelp()
00054 {
00055     MessageBox(_TEXT("DoHelp called"), _TEXT("Sample Animation control"), MB_OK);
00056
00057   return S_OK;
00058 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/comp.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

comp.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "Comp.h"
00017 #include "CompData.h"
00018 #include "DataObj.h"
00019 #include "Resource.h"
00020 #include "StaticNode.h"
00021 #include "FolderNode.h"
00022 #include "VirtualFile.h"
00023
00024                              // Tracing stuff
00025 #include "TraceMacro.h"
00026 #undef  MODULESTRING
00027 #define MODULESTRING  _T("CComponent")
00028
00029
00030 //---------------------------------------------------------------------------
00031 //  Our default constuctor provides a pointer to the parent CComponentData
00032 //  class which we cache for use in later samples.
00033 //
00034 CComponent::CComponent
00035 (
00036   CComponentData*  pParent   //[in] Points to parent object
00037 )
00038 {
00039   _ASSERT( NULL != pParent );
00040
00041   m_cRef           = 0;
00042   m_ipConsole      = NULL;
00043   m_ipConsoleVerb  = NULL;
00044   m_ipResultData   = NULL;
00045   m_ipHeaderCtrl   = NULL;
00046   m_pScopeCookie   = NULL;
00047   m_pComponentData = pParent;
00048
00049   m_ipControlbar     = NULL;
00050   m_ipStaticToolbar  = NULL;
00051   m_ipDeviceToolbar  = NULL;
00052   m_ipVFileToolbar   = NULL;
00053 }
00054
00055 //---------------------------------------------------------------------------
00056 CComponent::~CComponent()
00057 {
00058 }
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 //  Implementation of IUnknown
00062
00063 //---------------------------------------------------------------------------
00064 //  Add support for IComponent2 & IExtendControlBar
00065 //
00066 STDMETHODIMP CComponent::QueryInterface
00067 (
00068   REFIID   riid,       //[in] Identifier of the requested interface
00069   LPVOID   *ppv        //[out] Address of requested interface
00070 )
00071 {
00072   if( !ppv )
00073     return E_FAIL;
00074
00075   *ppv = NULL;
00076
00077   if( IsEqualIID(riid, IID_IUnknown) )
00078     *ppv = static_cast<IComponent*>(this);
00079   else if( IsEqualIID(riid, IID_IComponent) )
00080     *ppv = static_cast<IComponent*>(this);
00081   else if( IsEqualIID(riid, IID_IComponent2) )
00082     *ppv = static_cast<IComponent2*>(this);
00083   else if( IsEqualIID(riid, IID_IExtendControlbar) )
00084     *ppv = static_cast<IExtendControlbar*>(this);
00085
00086
00087   if( *ppv )
00088   {
00089     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00090     return S_OK;
00091   }
00092
00093   return E_NOINTERFACE;
00094 }
00095
00096 //---------------------------------------------------------------------------
00097 STDMETHODIMP_(ULONG) CComponent::AddRef()
00098 {
00099   return InterlockedIncrement((LONG*)&m_cRef);
00100 }
00101
00102 //---------------------------------------------------------------------------
00103 STDMETHODIMP_(ULONG) CComponent::Release()
00104 {
00105   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00106   {
00107     delete this;
00108     return 0;
00109   }
00110   return m_cRef;
00111 }
00112
00113 /////////////////////////////////////////////////////////////////////////////
00114 // Implementation of IComponent
00115
00116 //---------------------------------------------------------------------------
00117 STDMETHODIMP CComponent::Initialize
00118 (
00119   LPCONSOLE ipConsole    //[in] Points to the console's IUnknown
00120 )
00121 {
00122   HRESULT hResult = S_FALSE;
00123
00124   do
00125   {
00126     hResult = ipConsole->QueryInterface( IID_IConsole,(VOID**)&m_ipConsole );
00127     BREAK_ON_ERROR( hResult );
00128
00129     hResult = m_ipConsole->QueryConsoleVerb( &m_ipConsoleVerb );
00130     BREAK_ON_ERROR( hResult );
00131
00132     hResult = m_ipConsole->QueryInterface( IID_IResultData,(VOID**)&m_ipResultData );
00133     BREAK_ON_ERROR( hResult );
00134
00135     hResult = m_ipConsole->QueryInterface( IID_IHeaderCtrl2,(VOID**)&m_ipHeaderCtrl );
00136     BREAK_ON_ERROR( hResult );
00137
00138   }while( 0 );
00139
00140   TRACE_HRESULT(_T("Initialize"), hResult );
00141   return hResult;
00142 }
00143
00144
00145 //---------------------------------------------------------------------------
00146 STDMETHODIMP CComponent::Notify
00147 (
00148   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00149   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00150   LONG             nArg,           //[in] Depends on the notification type
00151   LONG             nParam          //[in] Depends on the notification type
00152 )
00153 {
00154   HRESULT hResult = S_FALSE;       // Return this for unhandled notifications
00155   TRACE_EVENT( _T("Notify"), MmcEvent );
00156
00157   if( NULL == ipDataObject )       // Not handling notifications with
00158     return hResult;                // NULL data objects
00159
00160   // Make sure we have a valid node
00161   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00162   if( NULL == pNode )
00163     return hResult;
00164
00165   if( MMC_MULTI_SELECT_COOKIE == (INT_PTR)pNode )
00166     return S_OK;
00167
00168
00169   switch( MmcEvent )
00170   {
00171     case MMCN_ADD_IMAGES:
00172       hResult = OnAddImages( ipDataObject, nArg, nParam );
00173       break;
00174
00175     case MMCN_SELECT:
00176       hResult = pNode->OnSelect( ipDataObject, nArg, nParam, (LONG_PTR)this );
00177       break;
00178
00179     case MMCN_SHOW:
00180       hResult = pNode->OnShow( ipDataObject, nArg, nParam, (LONG_PTR)this );
00181       if( TRUE == nArg )
00182         m_pScopeCookie = (LONG_PTR)ExtractBaseNodePtr(ipDataObject);
00183       else
00184         m_pScopeCookie = NULL;
00185
00186       break;
00187
00188     case MMCN_VIEW_CHANGE:
00189       hResult = pNode->OnViewChange( ipDataObject, nArg, nParam, (LONG_PTR)this );
00190       break;
00191
00192     case MMCN_RENAME:
00193       hResult = pNode->OnRename( ipDataObject, nArg, nParam, (LONG_PTR)this );
00194       break;
00195
00196     default:
00197       break;
00198
00199   }
00200   return hResult;
00201 }
00202
00203 //---------------------------------------------------------------------------
00204 STDMETHODIMP CComponent::Destroy
00205 (
00206   MMC_COOKIE nCookie   //[in] Not used
00207 )
00208 {
00209   SAFE_RELEASE( m_ipConsole     );
00210   SAFE_RELEASE( m_ipHeaderCtrl  );
00211   SAFE_RELEASE( m_ipResultData  );
00212   SAFE_RELEASE( m_ipConsoleVerb );
00213
00214   // Cached Controlbar/Toolbar interfaces are released in SetControlbar()
00215
00216   return S_OK;
00217 }
00218
00219 //---------------------------------------------------------------------------
00220 STDMETHODIMP CComponent::QueryDataObject
00221 (
00222   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00223   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00224   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00225 )
00226 {
00227   _ASSERT( NULL != nCookie );
00228   HRESULT hResult = S_FALSE;
00229
00230   CDataObject* pNewObject = new CDataObject();
00231   if( NULL == pNewObject )
00232     return E_OUTOFMEMORY;
00233
00234   if( MMC_MULTI_SELECT_COOKIE == nCookie )
00235   {
00236     hResult = QueryMultiSelDataObject( nCookie, nEnumType, &pNewObject );
00237   }
00238   else
00239   {
00240     pNewObject->SetPrivateData( nCookie, (ULONG)nEnumType );
00241   }
00242
00243   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00244   return hResult;
00245 }
00246
00247 //---------------------------------------------------------------------------
00248 //  Builds a multiselect data object
00249 //
00250 HRESULT CComponent::QueryMultiSelDataObject
00251 (
00252   MMC_COOKIE         nCookie,     //[in]  Indentifier of the selected node
00253   DATA_OBJECT_TYPES  nEnumType,   //[in]  Context in which this object was created
00254   CDataObject**      ppDataObject //[out] Points to data object we create
00255 )
00256 {
00257   HRESULT        hResult  = S_OK;
00258   LPBASENODE     pTmpNode = NULL;
00259   CDataObject*   pMSelObj = *ppDataObject;
00260   RESULTDATAITEM rdi;
00261
00262   ZeroMemory( &rdi, sizeof(RESULTDATAITEM) );
00263   rdi.mask   = RDI_STATE;
00264   rdi.nIndex = -1;
00265   rdi.nState = TVIS_SELECTED;
00266
00267   // Store the basic info in the MS DataObject
00268   pMSelObj->SetPrivateData( nCookie, (ULONG)nEnumType );
00269
00270
00271   // Iterate through the selected items, create a new data object for each
00272   // and add it to the list
00273   while( S_OK == m_ipResultData->GetNextItem(&rdi) )
00274   {
00275     pTmpNode = reinterpret_cast<LPBASENODE>(rdi.lParam);   // Need to save this...
00276     pMSelObj->AddMultiSelectCookie( rdi.lParam );
00277   }
00278
00279   // All our result items are of one type so there is only one GUID
00280   // to support in CCF_OBJECT_TYPES_IN_MULTI_SELECT
00281   pMSelObj->AddMultiSelectGuid( &pTmpNode->GetNodeGUID() );
00282
00283   //TRACE_PTR(_T("QueryMultiSelDataObject"),_T("pDO"), (ULONG_PTR)*ppDataObject );
00284   return hResult;
00285 }
00286
00287 //---------------------------------------------------------------------------
00288 //  This method not used when the Console's QI for IComponent2 is successful
00289 //
00290 STDMETHODIMP CComponent::GetResultViewType
00291 (
00292   MMC_COOKIE          nCookie,     //[in]  Indentifier of selected node
00293   LPOLESTR __RPC_FAR* ppViewType,  //[out] Points to view type string
00294   long __RPC_FAR*     pViewOptions //[out] Points to MMC_VIEW_OPTIONS enumeration
00295 )
00296 {
00297   return E_NOTIMPL;
00298 }
00299
00300
00301 //---------------------------------------------------------------------------
00302 STDMETHODIMP CComponent::GetDisplayInfo
00303 (
00304   RESULTDATAITEM __RPC_FAR* pResultDataItem  //[in][out] Result item struct
00305 )
00306 {
00307   _ASSERT( NULL != pResultDataItem );
00308   _ASSERT( NULL != pResultDataItem->lParam );
00309
00310   HRESULT  hResult = S_FALSE;
00311
00312   LPBASENODE pNode = reinterpret_cast<LPBASENODE>(pResultDataItem->lParam);
00313   hResult = pNode->GetDisplayInfo( pResultDataItem );
00314
00315   //TRACE_HRESULT( _T("GetDisplayInfo"), hResult );
00316   return hResult;
00317 }
00318
00319 //---------------------------------------------------------------------------
00320 STDMETHODIMP CComponent::CompareObjects
00321 (
00322   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00323   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00324 )
00325 {
00326   return E_NOTIMPL;
00327 }
00328
00329 //---------------------------------------------------------------------------
00330 HRESULT CComponent::QueryDispatch
00331 (
00332   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00333   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00334   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00335 )
00336 {
00337   return E_NOTIMPL;
00338 }
00339
00340 //---------------------------------------------------------------------------
00341 //  If we support IComponent2 this method is called to set the view type
00342 //  parameters.
00343 //
00344 HRESULT CComponent::GetResultViewType2
00345 (
00346   MMC_COOKIE             nCookie,  //[in] Identifier of object
00347   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00348 )
00349 {
00350   HRESULT hResult = S_FALSE;
00351
00352   if( NULL == nCookie )
00353   {
00354     CStaticNode* pNode = m_pComponentData->GetStaticNode();
00355     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00356   }
00357   else
00358   {
00359     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(nCookie);
00360     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00361   }
00362
00363   TRACE_HRESULT(_T("GetResultViewType2"), hResult );
00364   return hResult;
00365 }
00366
00367
00368 //---------------------------------------------------------------------------
00369 HRESULT CComponent::RestoreResultView
00370 (
00371   MMC_COOKIE             nCookie,  //[in] Identifier of object
00372   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00373 )
00374 {
00375   return E_NOTIMPL;
00376 }
00377
00378
00379 /////////////////////////////////////////////////////////////////////////////
00380 //  Notification handlers
00381
00382
00383 //---------------------------------------------------------------------------
00384 HRESULT CComponent::OnAddImages
00385 (
00386   LPDATAOBJECT   ipDataObject, //[in] Points to the selected data object
00387   LONG           nArg,         //[in] Pointer to IImageList
00388   LONG           nParam        //[in] HSCOPEITEM of selected/deselected item
00389
00390 )
00391 {
00392   HRESULT hResult = S_FALSE;
00393
00394   HBITMAP hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16));
00395   HBITMAP hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32));
00396
00397   if( NULL != nArg )           // May get this when shutting down
00398   {
00399     IImageList* ipImageList = reinterpret_cast<IImageList*>(nArg);
00400     hResult = ipImageList->ImageListSetStrip( (LONG_PTR*)hImageStrip16,
00401                                               (LONG_PTR*)hImageStrip32,
00402                                               0,
00403                                               RGB(0,255,0)
00404                                             );
00405   }
00406
00407   SAFE_FREE_BITMAP( hImageStrip16 );
00408   SAFE_FREE_BITMAP( hImageStrip32 );
00409
00410   TRACE_HRESULT(_T("OnAddImages"), hResult );
00411   return hResult;
00412 }
00413
00414 /////////////////////////////////////////////////////////////////////////////
00415 //  Interface IExtendControlBar
00416
00417
00418 //---------------------------------------------------------------------------
00419 //  TOOLBAR:  This method is only called when the static node is selected
00420 //            after selecting the console root node.
00421 //            We just build the toolbars with this notification, we do not
00422 //            attach or display them.
00423 //
00424 HRESULT CComponent::SetControlbar
00425 (
00426   LPCONTROLBAR ipControlbar  //[in] Pointer to the IControlbar interface
00427 )
00428 {
00429   HRESULT hResult = S_FALSE;
00430
00431   if( NULL == ipControlbar )           // Snap-in is deactivating
00432   {
00433     if( NULL == m_ipControlbar )       // Needed to prevent AVs
00434       return hResult;
00435
00436     hResult = m_ipControlbar->Detach( (LPUNKNOWN)m_ipStaticToolbar );
00437
00438     SAFE_RELEASE( m_ipVFileToolbar  );
00439     SAFE_RELEASE( m_ipDeviceToolbar ); // We release these here instead of
00440     SAFE_RELEASE( m_ipStaticToolbar ); // Destroy() because this gets called
00441     SAFE_RELEASE( m_ipControlbar    ); // after Destroy()
00442
00443     return hResult;
00444   }
00445
00446   if( NULL == m_ipControlbar )         // Cache the control bar if we don't
00447   {                                    // have it already
00448     m_ipControlbar = ipControlbar;
00449     m_ipControlbar->AddRef();
00450   }
00451
00452   if( NULL == m_ipStaticToolbar )      // Static Node toolbar not created
00453   {
00454     hResult = m_ipControlbar->Create( TOOLBAR, this, (LPUNKNOWN*)&m_ipStaticToolbar );
00455
00456     HBITMAP hbmpStaticToolbar = LoadBitmap( g_hInst, MAKEINTRESOURCE(IDR_STATIC_TOOLBAR) );
00457     hResult = m_ipStaticToolbar->AddBitmap( 1, hbmpStaticToolbar, 16, 16, RGB(0,255,0) );
00458
00459     hResult = m_ipStaticToolbar->AddButtons(1, StaticToolButtons);
00460   }
00461
00462   if( NULL == m_ipDeviceToolbar )      // Device Node toolbar not created
00463   {
00464     hResult = m_ipControlbar->Create( TOOLBAR, this, (LPUNKNOWN*)&m_ipDeviceToolbar );
00465
00466     HBITMAP hbmpDeviceToolbar = LoadBitmap( g_hInst, MAKEINTRESOURCE(IDR_DEVICE_TOOLBAR) );
00467     hResult = m_ipDeviceToolbar->AddBitmap( 1, hbmpDeviceToolbar, 16, 16, RGB(0,255,0) );
00468
00469     hResult = m_ipDeviceToolbar->AddButtons(2, DeviceToolButtons);
00470   }
00471
00472   if( NULL == m_ipVFileToolbar )       // Virtual File toolbar not created
00473   {
00474     hResult = m_ipControlbar->Create( TOOLBAR, this, (LPUNKNOWN*)&m_ipVFileToolbar );
00475
00476     HBITMAP hbmpVFileToolbar = LoadBitmap( g_hInst, MAKEINTRESOURCE(IDR_VFILE_TOOLBAR) );
00477     hResult = m_ipVFileToolbar->AddBitmap( 1, hbmpVFileToolbar, 16, 16, RGB(0,255,0) );
00478
00479     hResult = m_ipVFileToolbar->AddButtons(1, VFileToolButtons);
00480   }
00481
00482   return hResult;
00483 }
00484
00485
00486 //---------------------------------------------------------------------------
00487 //  Handle notifications from our custom toolbars
00488 //
00489 HRESULT CComponent::ControlbarNotify
00490 (
00491   MMC_NOTIFY_TYPE MmcEvent,  //[in] User action event
00492   LPARAM          nArg,      //[in] Depends on the event parameter
00493   LPARAM          lParam     //[in] Depends on the event parameter
00494 )
00495 {
00496   HRESULT hResult = S_FALSE;
00497   TRACE_START(_T("ControlbarNotify") );
00498
00499   switch( MmcEvent )
00500   {
00501     case MMCN_SELECT:
00502     {
00503       _ASSERT( NULL != lParam );
00504       LPBASENODE pNode = ExtractBaseNodePtr( reinterpret_cast<IDataObject*>(lParam) );
00505       if( NULL == pNode )
00506       {
00507         // MULTISELECT:  If pNode is NULL, the data object doesn't belong to
00508         // us.  If a multiple selection was made, the data object will be a
00509         // composite data object from the console which supports the clipboard
00510         // format CCF_MMC_MULTISELECT_DATAOBJECT.  If the return value is 1,
00511         // then this is a multiselect data object.
00512         // There are two ways to handle this:
00513         // - Just return S_OK.  That will result in the toolbar buttons being
00514         //   greyed out.
00515         // - Enable toolbar buttons for all result item types.
00516         //
00517         // Note: IsCompositeDataObject is defined in Globals.cpp
00518
00519         if( IsCompositeDataObject( (IDataObject*)lParam ) )
00520         {
00521           BOOL bSelect = (BOOL)HIWORD(nArg);
00522           if( TRUE == bSelect )
00523           {
00524             hResult = m_ipControlbar->Attach(TOOLBAR, (LPUNKNOWN)m_ipVFileToolbar);
00525             hResult = m_ipVFileToolbar->SetButtonState( IDM_CLEAR_ATTRIBS, ENABLED, TRUE );
00526           }
00527           else
00528           {
00529             hResult = m_ipControlbar->Detach( (LPUNKNOWN)m_ipVFileToolbar );
00530           }
00531         }  // Not a composite data object, return S_FALSE
00532       }
00533       else // pNode is not null, must be single selection
00534       {
00535         hResult = pNode->ControlbarNotify( nArg, lParam, (LONG_PTR)this );
00536       }
00537       break;
00538     }
00539     case MMCN_BTN_CLICK:
00540     {
00541       _ASSERT( NULL != nArg );
00542
00543       // MULTISELECT:  First we have to determine if this is a single selection
00544       // or a multiselect.  We do a double test, first is the data object our
00545       // own.  If yes then definitely a single selection was made.
00546
00547       LPBASENODE pNode = ExtractBaseNodePtr( reinterpret_cast<IDataObject*>(nArg) );
00548       if( NULL == pNode )
00549       {
00550         // If the data object is not ours, is it a MMC Composite Data Object?
00551         if( IsCompositeDataObject( (IDataObject*)nArg ) )
00552         {
00553           // If it's a MMC Composite Data Object, extract the data which is
00554           // stored as a SMMCDataObject.  First we extract this object, then
00555           // from it we get the cookie array.  The cookie array is our own
00556           // custom clipboard format which stores an array of pointers to the
00557           // selected nodes.  Then for each node we delegate the command.
00558           // Don't forget to update all views to reflect any changes.
00559
00560           FORMATETC FormatEtc = { g_cfMS_Snapins, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
00561           STGMEDIUM StgMedium = { TYMED_HGLOBAL,  NULL };
00562
00563           IDataObject* ipDO = reinterpret_cast<IDataObject*>(nArg);
00564           hResult = ipDO->GetData( &FormatEtc, &StgMedium );
00565           if( S_OK == hResult )
00566           {
00567             SMMCDataObjects* pMSObjs = (SMMCDataObjects*)StgMedium.hGlobal;
00568             for( DWORD dwObjCount = 0; dwObjCount < pMSObjs->count; dwObjCount++ )
00569             {
00570               IDataObject* ipDO = pMSObjs->lpDataObject[dwObjCount];
00571               FORMATETC FormatEtc = { g_cfMS_Cookies, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
00572               STGMEDIUM StgMedium = { TYMED_HGLOBAL,  NULL };
00573
00574               hResult = ipDO->GetData( &FormatEtc, &StgMedium );
00575               _ASSERT( S_OK == hResult );
00576
00577               MULTISELECT_COOKIES* pCookieArray = (MULTISELECT_COOKIES*)GlobalLock(StgMedium.hGlobal);
00578               CVirtualFile* pNode = NULL;
00579
00580               for( DWORD dwIndex = 0; dwIndex < pCookieArray->count; dwIndex++ )
00581               {
00582                 pNode = (CVirtualFile*)pCookieArray->Cookies[dwIndex];
00583                 hResult = pNode->Command( lParam );
00584               }
00585               LPDATAOBJECT pTmpDO = NULL;
00586               QueryDataObject( (MMC_COOKIE)pNode->GetParent(), CCT_SCOPE, &pTmpDO );
00587               hResult = m_ipConsole->UpdateAllViews( pTmpDO, 0, 0 );
00588               pTmpDO->Release();                 // Free the temp data object
00589
00590               GlobalUnlock( StgMedium.hGlobal );
00591               GlobalFree( StgMedium.hGlobal );   // Free the cookie array
00592             }
00593             GlobalFree( StgMedium.hGlobal );     // Free SMMCDataObjects
00594           }
00595         }  // Return whatever we got from ipDO->GetData()
00596       }
00597       else // Single selection was made
00598       {
00599         hResult = pNode->Command( lParam );
00600         LPDATAOBJECT pTmpDO = NULL;
00601         QueryDataObject( (MMC_COOKIE)((CVirtualFile*)pNode)->GetParent(), CCT_SCOPE, &pTmpDO );
00602         hResult = m_ipConsole->UpdateAllViews( pTmpDO, 0, 0 );
00603         pTmpDO->Release();                 // Free the temp data object
00604       }
00605       break;
00606     }
00607     default:
00608       break;
00609   }
00610   return hResult;
00611 }
00612
00613
00614 /////////////////////////////////////////////////////////////////////////////
00615 //  Public helper methods
00616
00617 //---------------------------------------------------------------------------
00618 //  Supplies interfaces to node objects.
00619 //
00620 HRESULT CComponent::GetInterface
00621 (
00622   DWORD dwRequestedInterface,  //[in] Request flag
00623   LONG_PTR* ppInterface        //[in-out] Interface pointer to return
00624 )
00625 {
00626   _ASSERT( NULL != ppInterface );
00627   HRESULT hResult = S_OK;
00628
00629   switch( dwRequestedInterface )
00630   {
00631     case REQUEST_ICONSOLE:
00632       _ASSERT( NULL != m_ipConsole );
00633       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00634       break;
00635
00636     case REQUEST_ICONSOLEVERB:
00637       _ASSERT( NULL != m_ipConsoleVerb );
00638       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleVerb);
00639       break;
00640
00641     case REQUEST_IRESULTDATA:
00642       _ASSERT( NULL != m_ipResultData );
00643       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipResultData);
00644       break;
00645
00646     case REQUEST_IHEADERCTRL:
00647       _ASSERT( NULL != m_ipHeaderCtrl );
00648       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipHeaderCtrl);
00649       break;
00650
00651     case REQUEST_ICONTROLBAR:
00652       _ASSERT( NULL != m_ipControlbar );
00653       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipControlbar);
00654       break;
00655
00656     case REQUEST_ISTATICTOOLBAR:
00657       _ASSERT( NULL != m_ipStaticToolbar );
00658       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipStaticToolbar);
00659       break;
00660
00661     case REQUEST_IDEVICETOOLBAR:
00662       _ASSERT( NULL != m_ipDeviceToolbar );
00663       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipDeviceToolbar);
00664       break;
00665
00666     case REQUEST_IVFILETOOLBAR:
00667       _ASSERT( NULL != m_ipVFileToolbar );
00668       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipVFileToolbar);
00669       break;
00670
00671    default:
00672       hResult = S_FALSE;
00673       *ppInterface = NULL;
00674       break;
00675   }
00676   return hResult;
00677 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/compdata.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

compdata.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "Comp.h"
00016 #include "CompData.h"
00017 #include "DataObj.h"
00018 #include "Resource.h"
00019
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CComponentData")
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // Construction/Destruction
00028
00029
00030 //---------------------------------------------------------------------------
00031 //  This constructor is called when the Snap-in is selected from the
00032 //  Add/Remove dialog.  Build our static node and load the required
00033 //  clipformats before MMC calls us.
00034 //
00035 CComponentData::CComponentData()
00036 {
00037   // Do not assume only one instance of IComponentData implementation is created.
00038
00039
00040     m_cRef                = 0;
00041     m_ipConsoleNameSpace2 = NULL;
00042     m_ipConsole           = NULL;
00043     m_ipScopeImage        = NULL;
00044     m_hImageStrip16       = NULL;
00045     m_hImageStrip32       = NULL;
00046
00047     // Increment this so DllCanUnloadNow works correctly
00048     InterlockedIncrement((long*)&g_uObjectCount);
00049
00050     NODE_PROPERTIES NodeProps;
00051     ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00052     wcscpy( NodeProps.szNodeName, gwszROOT_NODE_NAME );
00053     NodeProps.pParentObject  = NULL;
00054     NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(this);
00055
00056     m_pStaticNode = new CStaticNode;
00057     m_pStaticNode->Initialize( &NodeProps );
00058
00059     InitClipboardFormats();
00060 }
00061
00062 //---------------------------------------------------------------------------
00063 CComponentData::~CComponentData()
00064 {
00065   if( NULL != m_pStaticNode )
00066   {
00067     delete m_pStaticNode;
00068     m_pStaticNode = NULL;
00069   }
00070
00071   // All done, decrement object count so the dll can be unloaded
00072   InterlockedDecrement((long*)&g_uObjectCount);
00073 }
00074
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // IUnknown implementation
00078
00079 //---------------------------------------------------------------------------
00080 STDMETHODIMP CComponentData::QueryInterface
00081 (
00082   REFIID   riid,       //[in] Identifier of the requested interface
00083   LPVOID   *ppv        //[out] Address of requested interface
00084 )
00085 {
00086   if( !ppv )
00087     return E_FAIL;
00088
00089   *ppv = NULL;
00090
00091   if( IsEqualIID(riid, IID_IUnknown) )
00092     *ppv = static_cast<IComponentData*>(this);
00093   else if( IsEqualIID(riid, IID_IComponentData) )
00094     *ppv = static_cast<IComponentData*>(this);
00095   else if( IsEqualIID(riid, IID_IComponentData2) )
00096     *ppv = static_cast<IComponentData2*>(this);
00097   else if( IsEqualIID(riid, IID_IExtendContextMenu) )
00098     *ppv = static_cast<IExtendContextMenu *>(this);
00099
00100
00101   if( *ppv )
00102   {
00103     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00104     return S_OK;
00105   }
00106
00107   return E_NOINTERFACE;
00108 }
00109
00110 //---------------------------------------------------------------------------
00111 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00112 {
00113   return InterlockedIncrement((LONG*)&m_cRef);
00114 }
00115
00116 //---------------------------------------------------------------------------
00117 STDMETHODIMP_(ULONG) CComponentData::Release()
00118 {
00119   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00120   {
00121     delete this;
00122     return 0;
00123   }
00124
00125   return m_cRef;
00126 }
00127
00128 /////////////////////////////////////////////////////////////////////////////
00129 // Interface IComponentData2
00130
00131 //---------------------------------------------------------------------------
00132 //  Called when the user selects the Snap-in from the scope pane.
00133 //  This is where we QI and cache interfaces we will use later.  These
00134 //  interfaces are for future use since they are not used in this sample
00135 //
00136 HRESULT CComponentData::Initialize
00137 (
00138   LPUNKNOWN pUnknown         //[in] Pointer to the console's IUnknown
00139 )
00140 {
00141   HRESULT hResult = S_FALSE;
00142                              // Fail to initialize if we can't get the
00143   do                         // interfaces we need to cache
00144   {
00145     hResult = pUnknown->QueryInterface(IID_IConsoleNameSpace2, (void**)&m_ipConsoleNameSpace2);
00146     BREAK_ON_ERROR( hResult );
00147
00148     hResult = pUnknown->QueryInterface(IID_IConsole3, (void**)&m_ipConsole);
00149     BREAK_ON_ERROR( hResult );
00150
00151     // Add the images for the scope tree
00152     hResult = m_ipConsole->QueryScopeImageList(&m_ipScopeImage);
00153     BREAK_ON_ERROR( hResult );
00154
00155     // Load the bitmaps from the dll
00156     m_hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16) );
00157     if( NULL == m_hImageStrip16 )
00158     {
00159       hResult = S_FALSE;
00160       continue;
00161     }
00162
00163     m_hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32) );
00164      if( NULL == m_hImageStrip32)
00165     {
00166       hResult = S_FALSE;
00167       continue;
00168     }
00169
00170     // Set the images
00171     hResult = m_ipScopeImage->ImageListSetStrip( (LONG*)m_hImageStrip16,
00172                                                  (LONG*)m_hImageStrip32,
00173                                                  0,
00174                                                  RGB(0,255,0)
00175                                                );
00176     BREAK_ON_ERROR( hResult );
00177   }
00178   while( 0 );
00179
00180   return hResult;
00181 }
00182
00183 //---------------------------------------------------------------------------
00184 //  Called by the console every time we need to create a new result view.
00185 //  There can be several different result views. Aside from the default one
00186 //  created when the Snap-in initializes, additional ones are created by
00187 //  selecting "New window from here" in MMC's user interface.
00188 //
00189 HRESULT CComponentData::CreateComponent
00190 (
00191   LPCOMPONENT __RPC_FAR* ppComponent   //[out] Points to new IComponent class
00192 )
00193 {
00194   *ppComponent = NULL;
00195
00196   // Pass the new CComponent a pointer to it's parent
00197   CComponent* pComponent = new CComponent( this );
00198
00199   if( NULL == pComponent )
00200     return E_OUTOFMEMORY;
00201
00202   return pComponent->QueryInterface( IID_IComponent, (void**)ppComponent );
00203 }
00204
00205 //---------------------------------------------------------------------------
00206 //  Handles notification events from MMC
00207 //
00208 HRESULT CComponentData::Notify
00209 (
00210   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00211   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00212   LONG             nArg,           //[in] Depends on the notification type
00213   LONG             nParam          //[in] Depends on the notification type
00214 )
00215 {
00216   TRACE_EVENT( _T("Notify"), MmcEvent );  // Provides trace output
00217
00218   HRESULT hResult = S_FALSE;
00219   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00220   if( NULL == pNode )
00221     return hResult;
00222
00223   switch( MmcEvent )
00224   {
00225     case MMCN_EXPAND:
00226       hResult = pNode->OnExpand( ipDataObject, nArg, nParam, (LONG_PTR)this );
00227       break;
00228
00229     case MMCN_REMOVE_CHILDREN:
00230       hResult = pNode->OnRemoveChildren( ipDataObject, nArg, nParam, (LONG_PTR)this );
00231       break;
00232
00233     case MMCN_PRELOAD:                 // Function not implemented
00234     case MMCN_PROPERTY_CHANGE:         // Function not implemented
00235     case MMCN_DELETE:                  // Function not implemented
00236     case MMCN_RENAME:                  // Function not implemented
00237     default:
00238       break;
00239   }
00240
00241   return hResult;
00242 }
00243
00244 //---------------------------------------------------------------------------
00245 //  This is where we release any cached interface pointers or any
00246 //  allocated resources.
00247 //
00248 HRESULT CComponentData::Destroy( void)
00249 {
00250   SAFE_RELEASE( m_ipScopeImage        );
00251   SAFE_RELEASE( m_ipConsoleNameSpace2 );
00252   SAFE_RELEASE( m_ipConsole           );
00253
00254   SAFE_FREE_BITMAP( m_hImageStrip16 );
00255   SAFE_FREE_BITMAP( m_hImageStrip32 );
00256
00257   return S_OK;
00258 }
00259
00260 //---------------------------------------------------------------------------
00261 //  MMC provides a NULL cookie for the static/root node.  In this sample
00262 //  we don't pass that on, instead we use the pointer to our static node
00263 //  object which handles notifications
00264 //
00265 HRESULT CComponentData::QueryDataObject
00266 (
00267   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00268   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00269   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00270 )
00271 {
00272   HRESULT hResult = S_FALSE;
00273   ULONG   uCookie = 0;
00274
00275   CDataObject* pNewObject = new CDataObject();
00276   if( NULL == pNewObject )
00277     hResult = E_OUTOFMEMORY;
00278
00279   (0 == nCookie) ? uCookie = (ULONG)m_pStaticNode : uCookie = nCookie;
00280   pNewObject->SetPrivateData( uCookie, (ULONG)nEnumType );
00281
00282   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00283
00284   return hResult;
00285 }
00286
00287 //---------------------------------------------------------------------------
00288 //  Delegate the call to the static node object
00289 //
00290 HRESULT CComponentData::GetDisplayInfo
00291 (
00292   SCOPEDATAITEM* pScopeDataItem    //[out][in] Points to a SCOPEDATAITEM struct
00293 )
00294 {
00295   _ASSERT( NULL != pScopeDataItem );
00296   HRESULT hResult = S_OK;
00297
00298   // The console will only ask for the name string
00299   if(  pScopeDataItem->mask & SDI_STR )
00300   {
00301     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(pScopeDataItem->lParam);
00302     hResult = pNode->GetDisplayInfo( pScopeDataItem );
00303   }
00304
00305   return hResult;
00306 }
00307
00308 //---------------------------------------------------------------------------
00309 HRESULT CComponentData::CompareObjects
00310 (
00311   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00312   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00313 )
00314 {
00315   return E_NOTIMPL;
00316 }
00317
00318 //---------------------------------------------------------------------------
00319 HRESULT CComponentData::QueryDispatch
00320 (
00321   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00322   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00323   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00324 )
00325 {
00326   return E_NOTIMPL;
00327 }
00328
00329 /////////////////////////////////////////////////////////////////////////////
00330 // Interface IExtendContextMenu
00331
00332 //---------------------------------------------------------------------------
00333 HRESULT CComponentData::AddMenuItems
00334 (
00335   LPDATAOBJECT ipDataObject,         //[in]
00336   LPCONTEXTMENUCALLBACK ipCallback,  //[in]
00337   long __RPC_FAR* pInsertionAllowed  //[out-in]
00338 )
00339 {
00340   _ASSERT( NULL != ipCallback );
00341   HRESULT hResult = S_FALSE;
00342
00343   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00344   if( NULL != pNode )
00345     hResult = pNode->AddMenuItems( ipCallback, pInsertionAllowed );
00346
00347   return hResult;
00348 }
00349
00350 //---------------------------------------------------------------------------
00351 //
00352 HRESULT CComponentData::Command
00353 (
00354   long         lCommandID,   //[in] Identifier of the menu item
00355   LPDATAOBJECT ipDataObject  //[in] DataObject for selected node
00356 )
00357 {
00358   HRESULT hResult = S_OK;
00359
00360   CBaseNode* pNode = ExtractBaseNodePtr( ipDataObject );
00361   if( NULL != pNode )
00362     hResult = pNode->Command( lCommandID );
00363
00364   return hResult;
00365 }
00366
00367 /////////////////////////////////////////////////////////////////////////////
00368 //  Helper methods
00369
00370 //---------------------------------------------------------------------------
00371 HRESULT CComponentData::GetInterface
00372 (
00373   DWORD     dwRequestedInterface,  //[in] Request flag
00374   LONG_PTR* ppInterface            //[in-out] Interface pointer to return
00375 )
00376 {
00377   _ASSERT( NULL != ppInterface );
00378   HRESULT hResult = S_OK;
00379
00380   switch( dwRequestedInterface )
00381   {
00382     case REQUEST_ICONSOLENAMESPACE2:
00383       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleNameSpace2);
00384       break;
00385
00386     case REQUEST_ICONSOLE:
00387       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00388       break;
00389
00390     default:
00391       hResult = S_FALSE;
00392       *ppInterface = NULL;
00393       break;
00394   }
00395
00396   return hResult;
00397 }
00398
00399
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/compitem.cpp Source File

  • Begin
  • sdkdiff

compitem.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * compitem.cpp
00013  *
00014  * comparison between two files. A compitem is a data type that knows
00015  * about two files, and can compare them. The result of the comparison
00016  * is a list of sections for each file, and a composite list of sections
00017  * representing the comparison of the two files.
00018  *
00019  * A compitem has a state (one of the integer values defined in state.h)
00020  * representing the result of the comparison. It can also be
00021  * queried for the text result (text equivalent of the state) as well
00022  * as the tag - or title for this compitem (usually a text string containing
00023  * the name(s) of the files being compared).
00024  *
00025  * a compitem will supply a composite section list even if the files are
00026  * the same, or if there is only one file. The composite section list will
00027  * only be built (and the files read in) when the compitem_getcomposite()
00028  * call is made (and not at compitem_new time).
00029  *
00030  */
00031
00032 #include "precomp.h"
00033
00034 #include "state.h"
00035 #include "sdkdiff.h"
00036 #include "wdiffrc.h"
00037
00038 #include "list.h"
00039 #include "line.h"
00040 #include "scandir.h"
00041 #include "file.h"
00042 #include "section.h"
00043 #include "complist.h"
00044 #include "view.h"
00045 #include "compitem.h"
00046
00047
00048 /* --- data structures ------------------------------------------------ */
00049
00050 /*
00051  * the user has a handle to a compitem, which is in fact a pointer to
00052  * one of these structs.
00053  */
00054 struct compitem {
00055
00056     FILEDATA left;          /* handle for left-hand file */
00057     FILEDATA right;         /* handle for right-hand file */
00058
00059     LIST secs_composite;    /* list of sections (composite file)*/
00060     LIST secs_left;         /* list of sections (left file) */
00061     LIST secs_right;        /* list of sections (right file) */
00062
00063     int state;              /* compitem state - result of compare */
00064     BOOL bDiscard;          /* true if not alloc-ed on list */
00065     LPSTR tag;              /* text for tag (title of compitem) */
00066     LPSTR result;           /* text equivalent of state */
00067
00068     BOOL bMarked;           /* mark-state: used only by get/set mark*/
00069     char delims[64];        /* null term string of delimiters for lines */
00070 };
00071
00072 /* --- forward declaration of internal functions -------------------- */
00073
00074 LPSTR ci_copytext(LPSTR in);
00075 void ci_makecomposite(COMPITEM ci);
00076 void ci_compare(COMPITEM ci);
00077 void FindDelimiters(DIRITEM leftname, DIRITEM rightname, LPSTR delims);
00078 LPSTR ci_AddTimeString(LPSTR in, COMPITEM ci, DIRITEM leftname, DIRITEM rightname);
00079 void SetStateAndTag( COMPITEM ci, DIRITEM leftname, DIRITEM rightname, BOOL fExact);
00080
00081
00082
00083 /* -- externally called functions ---------------------------------- */
00084
00085 /*
00086  * compitem_new
00087  *
00088  * return a handle to a new compitem - given the filenames for the
00089  * left and right files to be compared. Either left or right or neither
00090  * (but not both) may be null. In this case we set the state accordingly.
00091  *
00092  * The parameters are handles to DIRITEM objects: these allow us to get the
00093  * the name of the file relative to the compare roots (needed for the tag)
00094  * and the absolute name of the file (needed for opening the file).
00095  *
00096  * if the list parameter is not null, the List_New* functions are used to
00097  * allocate memory for the compitem. We remember this (in the bDiscard flag)
00098  * so we do not delete the compitem if it was allocated on the list.
00099  *
00100  * If the list parameter is null, the memory
00101  * for the compitem is allocated using HeapAlloc.
00102  *
00103  */
00104 COMPITEM
00105 compitem_new(DIRITEM leftname, DIRITEM rightname, LIST list, BOOL fExact)
00106 {
00107     COMPITEM ci;
00108
00109     /*
00110      * allocate the memory for the compitem, either at the end of the
00111      * list or using HeapAlloc.
00112      */
00113     if (list == NULL)
00114     {
00115         /* no list passed */
00116         ci = (COMPITEM) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct compitem));
00117         if (!ci)
00118             return NULL;
00119         ci->bDiscard = TRUE;
00120     }
00121     else
00122     {
00123         /* add to end of list */
00124         ci = (COMPITEM) List_NewLast(list, sizeof(struct compitem));
00125         if (!ci)
00126             return NULL;
00127         ci->bDiscard = FALSE;
00128     }
00129
00130     ci->secs_composite = NULL;
00131     ci->secs_left = NULL;
00132     ci->secs_right = NULL;
00133
00134     FindDelimiters(leftname, rightname, ci->delims);
00135
00136     /*
00137      * make a filedata for each of the files that are non-null.
00138      * filedata objects are responsible for reading the file and
00139      * accessing the lines in it. Don't read in the files until we need to.
00140      */
00141     if (leftname != NULL) {
00142         ci->left = file_new(leftname, FALSE);
00143         if (ci->left == NULL) {
00144             return(NULL);
00145         }
00146     } else {
00147         ci->left = NULL;
00148     }
00149     if ( rightname != NULL) {
00150         ci->right = file_new(rightname, FALSE);
00151         if (ci->right == NULL) {
00152             return(NULL);
00153         }
00154     } else {
00155         ci->right = NULL;
00156     }
00157
00158
00159     /*
00160      * see if we have one or two files, and set the state accordingly
00161      */
00162     if ( ! ci->left && !ci->right) {
00163         /* two NULL files - this is wrong */
00164         return(NULL);
00165     }
00166
00167     SetStateAndTag(ci, leftname, rightname, fExact);
00168
00169     if ( ((ci->state == STATE_DIFFER) && !TrackDifferent) ||
00170          ((ci->state == STATE_SAME)   && !TrackSame)      ) {
00171         if ( ci->right != NULL ) {
00172             file_delete( ci->right );
00173         }
00174         if ( ci->left != NULL ) {
00175             file_delete( ci->left );
00176         }
00177         if ( list == NULL ) {
00178            HeapFree(GetProcessHeap(), NULL, (LPSTR)ci);
00179         } else {
00180             List_Delete( ci );
00181         }
00182     }
00183
00184
00185     /*
00186      * building the section lists and composite lists can wait
00187      * until needed.
00188      */
00189     return(ci);
00190 } /* compitem_new */
00191
00192
00193
00194 /* re-do the checksum based comparison for this file - useful for UNREADABLEs
00195    We force fExact to be TRUE - This time we WILL get checksums.
00196 */
00197 void compitem_rescan(COMPITEM ci)
00198 {
00199     DIRITEM diLeft, diRight;
00200
00201     /*
00202        The way we get from a ci to the info we
00203        need is ci->filedata->diritem->direct->dirlist->hpipe.
00204        We let scandir do the work.
00205     */
00206
00207     diLeft = file_getdiritem(ci->left);
00208     diRight = file_getdiritem(ci->right);
00209
00210     dir_rescanfile(diLeft);
00211     dir_rescanfile(diRight);
00212
00213     if (ci->result != NULL) {
00214         HeapFree(GetProcessHeap(), NULL, ci->result);
00215         ci->result = NULL;
00216     }
00217
00218     SetStateAndTag( ci, diLeft, diRight, TRUE);
00219 } /* compitem_rescan */
00220
00221
00222
00223 /*
00224  * delete a compitem and free all associated data.
00225  *
00226  * If the ci->bDiscard flag is set, the compitem was alloc-ed on a list,
00227  * and should not be discarded (the list itself will be deleted).
00228  *
00229  * the data pointed to by the compitem will be discarded in either case.
00230  *
00231  * the DIRDATA we were passed are not deleted. the filedata, lines
00232  * and sections are.
00233  */
00234 void
00235 compitem_delete(COMPITEM ci)
00236 {
00237     if (ci == NULL) {
00238         return;
00239     }
00240
00241     compitem_discardsections(ci);
00242
00243     /* delete the two filedatas (and associated line lists) */
00244     file_delete(ci->left);
00245     file_delete(ci->right);
00246
00247     /* text we allocated. */
00248     if (ci->tag!=NULL)
00249         HeapFree(GetProcessHeap(), NULL, ci->tag);
00250     if (ci->result!=NULL)
00251         HeapFree(GetProcessHeap(), NULL, ci->result);
00252
00253     /* free the compitem struct itself if not alloced on a list */
00254     if (ci->bDiscard) {
00255         HeapFree(GetProcessHeap(), NULL, ci);
00256     }
00257 }
00258
00259
00260 /*
00261  * discard sections - throw away cached information relating to the
00262  * comparison (but not the files if they are read into memory). This
00263  * is used to force a re-compare if changes in the comparison options
00264  * are made
00265  */
00266 void
00267 compitem_discardsections(COMPITEM ci)
00268 {
00269     /* delete the lists of sections we built */
00270     if (ci == NULL) {
00271         return;
00272     }
00273     if (ci->secs_composite) {
00274         section_deletelist(ci->secs_composite);
00275         ci->secs_composite = NULL;
00276     }
00277     if (ci->secs_left) {
00278         section_deletelist(ci->secs_left);
00279         ci->secs_left = NULL;
00280     }
00281     if (ci->secs_right) {
00282         section_deletelist(ci->secs_right);
00283         ci->secs_right = NULL;
00284     }
00285
00286     /* reset the line lists to throw away cached hash codes and links */
00287     if (ci->left != NULL) {
00288         file_reset(ci->left);
00289     }
00290     if (ci->right != NULL) {
00291         file_reset(ci->right);
00292     }
00293 }
00294
00295 /* -- accessor functions ---------------*/
00296
00297 /* get the handle for the composite section list */
00298 LIST
00299 compitem_getcomposite(COMPITEM ci)
00300 {
00301     if (ci == NULL) {
00302         return NULL;
00303     }
00304     /*
00305      * do the comparison if we haven't already done it
00306      */
00307     if (ci->secs_composite == NULL) {
00308         ci_makecomposite(ci);
00309     }
00310
00311     return(ci->secs_composite);
00312 }
00313
00314 /* get the handle for the list of sections in the left file */
00315 LIST
00316 compitem_getleftsections(COMPITEM ci)
00317 {
00318     if (ci == NULL) {
00319         return NULL;
00320     }
00321     /*
00322      * do the comparison if we haven't already done it
00323      */
00324     if (ci->secs_composite == NULL) {
00325         ci_makecomposite(ci);
00326     }
00327
00328     return(ci->secs_left);
00329 }
00330
00331 /* get the handle for the list of sections in the right file */
00332 LIST
00333 compitem_getrightsections(COMPITEM ci)
00334 {
00335     if (ci == NULL) {
00336         return NULL;
00337     }
00338     /*
00339      * do the comparison if we haven't already done it
00340      */
00341     if (ci->secs_composite == NULL) {
00342         ci_makecomposite(ci);
00343     }
00344
00345     return(ci->secs_right);
00346 }
00347
00348 /* get the handle to the left file itself */
00349 FILEDATA
00350 compitem_getleftfile(COMPITEM ci)
00351 {
00352     if (ci == NULL) {
00353         return(NULL);
00354     }
00355     return(ci->left);
00356 }
00357
00358 /* get the handle to the right file itself */
00359 FILEDATA
00360 compitem_getrightfile(COMPITEM ci)
00361 {
00362     if (ci == NULL) {
00363         return(NULL);
00364     }
00365     return(ci->right);
00366 }
00367
00368 /* get the state (compare result) of this compitem */
00369 int
00370 compitem_getstate(COMPITEM ci)
00371 {
00372     if (ci == NULL) {
00373         return(0);
00374     }
00375     return(ci->state);
00376 }
00377
00378 /* get the tag (text for the compitem title) */
00379 LPSTR
00380 compitem_gettext_tag(COMPITEM ci)
00381 {
00382     if (ci == NULL) {
00383         return(NULL);
00384     }
00385     return(ci->tag);
00386 }
00387
00388 /* get the result text (text equiv of state) */
00389 LPSTR
00390 compitem_gettext_result(COMPITEM ci)
00391 {
00392     if (ci == NULL) {
00393         return(NULL);
00394     }
00395     return(ci->result);
00396 }
00397
00398 /*
00399  * return the name of the file associated with this compitem. The option
00400  * argument (one of CI_LEFT, CI_RIGHT, CI_COMP) indicates which file
00401  * is required.
00402  *
00403  * called must call compitem_freefilename once the file is finished with.
00404  *
00405  * CI_LEFT and CI_RIGHT just result in calls to dir_getopenname to get
00406  * an open-able filename.
00407  *
00408  * for CI_COMP, we create a temporary file, write out all the text in the
00409  * composite section list to this file, and then pass the name of the
00410  * temporary file to the caller. This file will be deleted on
00411  * the call to compitem_freefilename().
00412  */
00413 LPSTR
00414 compitem_getfilename(VIEW view, COMPITEM item, int option)
00415 {
00416     LPSTR fname;
00417
00418     if (item == NULL) {
00419         return(NULL);
00420     }
00421
00422     switch (option) {
00423         case CI_LEFT:
00424             if (item->left != NULL) {
00425                 return(dir_getopenname(file_getdiritem(item->left)));
00426             } else {
00427                 return(NULL);
00428             }
00429
00430         case CI_RIGHT:
00431             if (item->right != NULL) {
00432                 return(dir_getopenname(file_getdiritem(item->right)));
00433             } else {
00434                 return(NULL);
00435             }
00436
00437         case CI_COMP:
00438
00439             /* caller has asked for the filename of the composite file.
00440              * we need to create a temporary file and write the
00441              * lines in the composite section list out to it.
00442              */
00443             fname = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH);
00444             if (fname == NULL)
00445         return NULL;
00446       GetTempPath(MAX_PATH, fname);
00447             GetTempFileName(fname, "wdf", 0, fname);
00448
00449             /* write out the temp file and return the result */
00450             compitem_savecomp(view, item, fname, expand_include);
00451             return fname;
00452
00453         default:
00454             TRACE_ERROR(LoadRcString(IDS_BAD_ARGUMENT), FALSE);
00455             return(NULL);
00456     }
00457 }
00458
00459 /*
00460  * save the composite file
00461  *
00462  * if savename is not null, write the list out to savename using compopts.
00463  * otherwise, prompt by dialog for filename and options.
00464  */
00465 LPSTR
00466 compitem_savecomp(VIEW view, COMPITEM item, LPSTR savename, int compopts)
00467 {
00468   char    fname[2*MAX_PATH + 1];
00469   HCURSOR   hcurs;
00470
00471   if (item == NULL) {
00472     return NULL;
00473   }
00474
00475   if (savename == NULL) {
00476     /* Ask for the filename - using gfile standard dialogs */
00477     savename = fname;
00478     if (!gfile_open(hwndClient, LoadRcString(IDS_SAVE_COMPFILE), ".txt", "*.txt", NULL, 0, savename)) {
00479       return NULL;
00480     }
00481   }
00482   else {
00483     HRESULT hr = StringCchCopy(fname, (2*MAX_PATH+1), savename);
00484     if (FAILED(hr)) {
00485       OutputError(hr, IDS_SAFE_COPY);
00486       return NULL;
00487     }
00488     GetFullPathName(savename, 2*MAX_PATH + 1, fname, NULL);
00489     savename = fname;
00490   }
00491
00492   /* Write to file */
00493   hcurs = SetCursor(LoadCursor(NULL, IDC_WAIT));
00494   if (!compitem_writefile(view, item, savename, compopts)) {
00495     return NULL;
00496   }
00497
00498   /* Return filename */
00499   SetCursor(hcurs);
00500   return savename;
00501 }
00502
00503 /*
00504  * worker function to write the actual composite file
00505  *
00506  * if savename is not null, write the list out to savename using compopts.
00507  * otherwise, prompt by dialog for filename and options.
00508  */
00509 LPSTR
00510 compitem_writefile(VIEW view, COMPITEM item, LPSTR savename, int compopts)
00511 {
00512   HANDLE    fh;
00513   SECTION   sec;
00514   LINE    line;
00515   COMPLIST  list;
00516   LPSTR   lhead;
00517   LPSTR   tag, text;
00518   char    msg[2*MAX_PATH+100];
00519   UINT    linecount = 0;
00520     DWORD       cbWritten;
00521
00522   /* Return immediately if no file name or item */
00523   if (!savename || !*savename || !item) {
00524     return NULL;
00525   }
00526
00527   /* Try to open the file */
00528   fh = CreateFile(savename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
00529   if (fh == INVALID_HANDLE_VALUE) {
00530     HRESULT hr = StringCchPrintf(msg, (2*MAX_PATH+100),"Cannot open %s", savename);
00531     if (FAILED(hr)) {
00532       OutputError(hr, IDS_SAFE_PRINTF);
00533       return NULL;
00534     }
00535     sdkdiff_UI(TRUE);
00536     MessageBox(hwndClient, msg, "Sdkdiff", MB_ICONSTOP|MB_OK);
00537     sdkdiff_UI(FALSE);
00538     return NULL;
00539   }
00540
00541   /* Make sure the composite list has been built */
00542   if (item->secs_composite == NULL) {
00543     ci_makecomposite(item);
00544   }
00545
00546   /* write out the header line */
00547   list = view_getcomplist(view);
00548   lhead = complist_getdescription(list);
00549   HRESULT hr = StringCchPrintf(msg, (2*MAX_PATH+100), "-- %s -- %s -- includes %s%s%s%s%s lines\r\n",
00550        lhead,
00551        item->tag,
00552        (LPSTR) ((compopts & INCLUDE_SAME) ? "identical," : ""),
00553        (LPSTR) ((compopts & INCLUDE_LEFTONLY) ? "left-only," : ""),
00554        (LPSTR) ((compopts & INCLUDE_RIGHTONLY) ? "right-only," : ""),
00555        (LPSTR) ((compopts & INCLUDE_MOVEDLEFT) ? "moved-left," : ""),
00556        (LPSTR) ((compopts & INCLUDE_MOVEDRIGHT) ? "moved-right" : "") );
00557   if (FAILED(hr)) {
00558     OutputError(hr, IDS_SAFE_PRINTF);
00559     return NULL;
00560   }
00561   WriteFile(fh, msg, lstrlen(msg), &cbWritten, NULL);
00562   complist_freedescription(list, lhead);
00563
00564   /* Write out every line in every section on the composite
00565    * list to the temp file.
00566    */
00567     for( sec=(SECTION)List_First(item->secs_composite);  sec!=NULL;  sec = (SECTION)List_Next((LPVOID)sec)) {
00568     tag = "    ";  /* avoid strange diagnostic */
00569     /* get the tag field based on the section state*/
00570     switch(section_getstate(sec)) {
00571
00572     case STATE_SAME:
00573       if (!(compopts & INCLUDE_SAME))
00574         continue;
00575       tag = "    ";
00576       break;
00577
00578     case STATE_LEFTONLY:
00579     case STATE_SIMILARLEFT:
00580       if (!(compopts & INCLUDE_LEFTONLY))
00581         continue;
00582       tag = " <! ";
00583       break;
00584     case STATE_RIGHTONLY:
00585     case STATE_SIMILARRIGHT:
00586       if (!(compopts & INCLUDE_RIGHTONLY))
00587         continue;
00588       tag = " !> ";
00589       break;
00590
00591     case STATE_MOVEDLEFT:
00592       if (!(compopts & INCLUDE_MOVEDLEFT))
00593         continue;
00594       tag = " <- ";
00595       break;
00596
00597     case STATE_MOVEDRIGHT:
00598       if (!(compopts & INCLUDE_MOVEDRIGHT))
00599         continue;
00600       tag = " -> ";
00601       break;
00602     }
00603
00604     /* write out each line in this section.
00605      * non-standard traverse of list as we only
00606      * want to go from section first to section last
00607      * inclusive.
00608      */
00609     for (line = section_getfirstline(sec); line != NULL; line = (LINE)List_Next(line)) {
00610       /* write out to file */
00611       text = line_gettext(line);
00612       WriteFile(fh, tag, lstrlen(tag), &cbWritten, NULL);
00613       WriteFile(fh, text, lstrlen(text), &cbWritten, NULL);
00614       ++linecount;
00615
00616       if (line == section_getlastline(sec))
00617         break;
00618     }
00619   }
00620
00621   /* Write the footer */
00622   hr = StringCchPrintf(msg, (2*MAX_PATH+100),"-- %u lines listed\r\n", linecount);
00623   if (FAILED(hr)) {
00624     OutputError(hr, IDS_SAFE_PRINTF);
00625     return NULL;
00626   }
00627   WriteFile(fh, msg, lstrlen(msg), &cbWritten, NULL);
00628
00629   /* Close the file and return */
00630   CloseHandle(fh);
00631   return savename;
00632 }
00633
00634 /*
00635  * free memory created by a call to compitem_getfilename. if a temporary
00636  * file was created, this may cause it to be deleted. The option argument must
00637  * be the same as passed to the original compitem_getfilename call.
00638  *
00639  * if we created a temporary file for CI_COMP, then delete it. otherwise
00640  * just pass the name to dir_freeopenname.
00641  */
00642 void
00643 compitem_freefilename(COMPITEM item, int option, LPSTR filename)
00644 {
00645     if ((item == NULL) || (filename == NULL)) {
00646         return;
00647     }
00648
00649     switch (option) {
00650
00651         case CI_LEFT:
00652             dir_freeopenname(file_getdiritem(item->left), filename);
00653             break;
00654
00655         case CI_RIGHT:
00656             dir_freeopenname(file_getdiritem(item->right), filename);
00657             break;
00658
00659         case CI_COMP:
00660
00661             /* this is a temporary file we created. Delete it. */
00662             DeleteFile(filename);
00663
00664             HeapFree(GetProcessHeap(), NULL, filename);
00665             break;
00666     }
00667 }
00668
00669
00670 /*
00671  * set the mark state of a file. The only use for this is to retrieve it
00672  * later using compitem_getmark. The state is a bool.
00673  */
00674 void
00675 compitem_setmark(COMPITEM item, BOOL bMark)
00676 {
00677     if (item == NULL) {
00678         return;
00679     }
00680
00681     item->bMarked = bMark;
00682 }
00683
00684
00685 /* return the mark state set by compitem_setmark */
00686 BOOL
00687 compitem_getmark(COMPITEM item)
00688 {
00689     if (item == NULL) {
00690         return(FALSE);
00691     } else {
00692         return(item->bMarked);
00693     }
00694 }
00695
00696
00697 /* --- internally called functions ------------------------------*/
00698
00699 /* return TRUE if di looks like it is a text file as opposed to a program file */
00700 BOOL IsDocName(DIRITEM di)
00701 {
00702     BOOL bRet = FALSE;
00703     LPSTR name = dir_getrelname(di);
00704     LPSTR ext;                                   /* extension part of name */
00705     if (name!=NULL) {                            /* there is a name */
00706         ext = My_mbsrchr(name, '.');
00707         if (ext!=NULL) {                        /* there is a dot in name */
00708             ++ext;                              /* skip past the dot */
00709             if (   (0==lstrcmp(ext,"doc"))      /* N.B depends on name being lower case */
00710                    ||  (0==lstrcmp(ext,"txt"))
00711                    ||  (0==lstrcmp(ext,"rtf"))
00712                )
00713                 bRet = TRUE;                /* doc type */
00714         }
00715
00716     }
00717
00718     if (name!=NULL) dir_freerelname(di, name);
00719     return bRet;
00720 } /* IsDocName */
00721
00722 /* return TRUE if di looks like it is a "C" program file */
00723 BOOL IsCName(DIRITEM di)
00724 {
00725     BOOL bRet = FALSE;   /* default to not a "C" type */
00726     LPSTR name = dir_getrelname(di);
00727     LPSTR ext;                                   /* extension part of name */
00728
00729     if (name!=NULL) {                          /* there is a name */
00730
00731         ext = My_mbsrchr(name, '.');
00732         if (ext!=NULL) {                      /* there is a dot in the name */
00733
00734             ++ext;                            /* skip past the dot */
00735             if (  (0==lstrcmp(ext,"c"))
00736                   || (0==lstrcmp(ext,"h"))
00737                   || (0==lstrcmp(ext,"cxx"))
00738                   || (0==lstrcmp(ext,"hxx"))
00739                   || (0==lstrcmp(ext,"cpp"))
00740                   || (0==lstrcmp(ext,"hpp"))
00741                )
00742                 bRet = TRUE;                /*  "C" type */
00743         }
00744     }
00745
00746     if (name!=NULL) dir_freerelname(di, name);
00747     return bRet;
00748 } /* IsDocName */
00749
00750 /* This is a bit ugly.  These really belong in a Complist? */
00751 static char RightRoot[MAX_PATH];
00752 static char LeftRoot[MAX_PATH];
00753
00754 void compitem_SetCopyPaths(LPSTR RightPath, LPSTR LeftPath)
00755 {
00756     HRESULT hr = StringCchCopy(LeftRoot, MAX_PATH, LeftPath);
00757   if (FAILED(hr)) {
00758     OutputError(hr, IDS_SAFE_COPY);
00759   }
00760     hr = StringCchCopy(RightRoot, MAX_PATH, RightPath);
00761   if (FAILED(hr)) {
00762     OutputError(hr, IDS_SAFE_COPY);
00763   }
00764
00765 } /* compitem_SetCopyPaths */
00766
00767
00768 void FindDelimiters(DIRITEM leftname, DIRITEM rightname, LPSTR delims)
00769 {
00770     extern BOOL gbPerverseCompare; // in sdkdiff.c
00771   HRESULT hr;
00772
00773   if (gbPerverseCompare) {
00774     hr = StringCchCopy(delims, 64, ".!?;\n");
00775     if (FAILED(hr))
00776       OutputError(hr, IDS_SAFE_COPY);
00777   }
00778   else { /* default - guess */
00779         hr = StringCchCopy(delims, 64, "\n");
00780     if (FAILED(hr))
00781       OutputError(hr, IDS_SAFE_COPY);
00782   }
00783
00784 } /* FindDelimiters */
00785
00786
00787
00788 /*
00789  * alloc a buffer large enough for the text string and copy the text into
00790  * it. return a pointer to the string.
00791  */
00792 LPSTR
00793 ci_copytext(LPSTR in)
00794 {
00795     LPSTR out;
00796
00797     if (in == NULL) {
00798         out = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1);
00799     if (out == NULL)
00800       return NULL;
00801         out[0] = '\0';
00802     } else {
00803         out = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lstrlen(in) + 1);
00804     if (out == NULL)
00805       return NULL;
00806     HRESULT hr = StringCchCopy(out, (lstrlen(in)+1), in);
00807     if (FAILED(hr)) {
00808       OutputError(hr, IDS_SAFE_COPY);
00809       return NULL;
00810     }
00811     }
00812     return(out);
00813 } /* ci_copytext */
00814
00815 LPSTR ci_AddTimeString(LPSTR in, COMPITEM ci, DIRITEM leftname, DIRITEM rightname)
00816 {
00817     FILETIME ftLeft;
00818     FILETIME ftRight;
00819     long rc;
00820     char buff[400] = {0};
00821     LPTSTR lpStr;
00822
00823     HRESULT hr = StringCchCatN(buff, 400,in, sizeof(buff)-1);
00824   if (FAILED(hr)) {
00825     OutputError(hr, IDS_SAFE_CAT);
00826     return NULL;
00827   }
00828
00829     ftLeft = file_GetTime(ci->left);
00830     ftRight = file_GetTime(ci->right);
00831     if ((ftLeft.dwLowDateTime || ftLeft.dwHighDateTime) &&
00832         (ftRight.dwLowDateTime || ftRight.dwHighDateTime))
00833     {
00834         rc = CompareFileTime(&ftLeft, &ftRight);
00835
00836         if((lpStr = (LPSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlen(in)+1)*sizeof(TCHAR))) == NULL)
00837             return NULL;
00838         hr = StringCchCopy(lpStr, (lstrlen(in)+1*sizeof(TCHAR)), in);
00839     if (FAILED(hr)) {
00840       OutputError(hr, IDS_SAFE_COPY);
00841       return NULL;
00842     }
00843         if (rc<0) {
00844             LPSTR str = dir_getrootdescription(dir_getlist(rightname));
00845             hr = StringCchPrintf(buff, 400, LoadRcString(IDS_IS_MORE_RECENT), lpStr, str);
00846       if (FAILED(hr)) {
00847         OutputError(hr, IDS_SAFE_PRINTF);
00848         return NULL;
00849       }
00850             dir_freerootdescription(dir_getlist(rightname), str);
00851         } else if (rc>0) {
00852             LPSTR str = dir_getrootdescription(dir_getlist(leftname));
00853             hr = StringCchPrintf(buff, 400, LoadRcString(IDS_IS_MORE_RECENT), lpStr, str);
00854       if (FAILED(hr)) {
00855         OutputError(hr, IDS_SAFE_PRINTF);
00856         return NULL;
00857       }
00858             dir_freerootdescription(dir_getlist(leftname), str);
00859     } else {
00860             hr = StringCchCat(buff, 400, LoadRcString(IDS_IDENTICAL_TIMES));
00861       if (FAILED(hr)) {
00862         OutputError(hr, IDS_SAFE_CAT);
00863         return NULL;
00864       }
00865     }
00866         HeapFree(GetProcessHeap(), NULL, lpStr);
00867     }
00868
00869     return ci_copytext(buff);
00870
00871 } /* ci_AddTimeString */
00872
00873
00874
00875
00876 /* make a list containing a single section from the whole list of lines */
00877 LIST
00878 ci_onesection(FILEDATA file)
00879 {
00880     LIST lines;
00881     LIST sections;
00882     SECTION section;
00883
00884     lines = file_getlinelist(file);
00885
00886     /* create a null list */
00887     sections = List_Create();
00888
00889     /* tell the section to create itself on the end of this list. */
00890     section = section_new((LINE)List_First(lines), (LINE)List_Last(lines), sections);
00891     section_setstate(section, STATE_SAME);
00892
00893
00894     return(sections);
00895 }
00896
00897
00898
00899 /*
00900  * compare the two files and build the composite list. called whenever
00901  * we need one of the section lists. Only does the comparison if
00902  * the composite list does not already exist
00903  */
00904 void
00905 ci_makecomposite(COMPITEM ci)
00906 {
00907     if (ci->secs_composite != NULL) {
00908         return;
00909     }
00910
00911     readfile_setdelims((LPBYTE)ci->delims);
00912
00913     /* if there is only one file, make a single item list
00914      * of sections
00915      */
00916     if (ci->left == NULL) {
00917         ci->secs_left = NULL;
00918         ci->secs_right = ci_onesection(ci->right);
00919
00920         /* make a second list, not a pointer to the first
00921          * or we will get confused when deleting
00922          */
00923         ci->secs_composite = ci_onesection(ci->right);
00924         return;
00925     } else if (ci->right == NULL) {
00926         ci->secs_right = NULL;
00927         ci->secs_left = ci_onesection(ci->left);
00928
00929         /* make a second list, not a pointer to the first
00930          * or we will get confused when deleting
00931          */
00932         ci->secs_composite = ci_onesection(ci->left);
00933         return;
00934     }
00935
00936     /* we have two files - we need to compare them fully */
00937     ci_compare(ci);
00938
00939     /* check if the composite list consists of one single section -
00940      * - if it does, and the files have a 'differ' state, then they
00941      * must differ in blanks only. Warn the user with a popup, and change
00942      * the tag text for the outline view. NB we should not need to
00943      * refresh the outline view since any action that gets this function
00944      * called will refresh the outline view anyway.
00945      */
00946     if (ci->state == STATE_DIFFER) {
00947         if (  (List_Card(ci->secs_composite) == 1)
00948               && (STATE_SAME==section_getstate((SECTION)List_First(ci->secs_composite)))
00949            ) {
00950             sdkdiff_UI(TRUE);
00951             MessageBox(hwndClient, LoadRcString(IDS_DIFF_BLANK_ONLY),
00952                        "Sdkdiff", MB_ICONINFORMATION|MB_OK);
00953             sdkdiff_UI(FALSE);
00954
00955             if (ci->result != NULL) {
00956                 HeapFree(GetProcessHeap(), NULL, ci->result);
00957                 ci->result = NULL;
00958             }
00959             ci->result = ci_copytext(LoadRcString(IDS_DIFF_BLANK_ONLY));
00960         } else ci->state = STATE_DIFFER;  /* could be that blanks option has
00961                                              changed and it was blanks only
00962                                              differ which now counts as different
00963                                           */
00964     }
00965 } /* ci_makecomposite */
00966
00967 /*
00968  * we have two files - compare them and build a composite list.
00969  *
00970  * comparison method:
00971  *
00972  *    0   (and what makes it fast) break each file into lines and hash
00973  *        each line.  Lines which don't match can be rapidly eliminated
00974  *        by just comparing the hash code.  The hashing knows whether blanks
00975  *        are to be ignored or not.
00976  *
00977  *    1   (and what makes it really fast) Store the hash codes in a binary
00978  *        search tree that will give for each hash code the number of times
00979  *        that it occurred in each file and one of the lines where it occurred
00980  *        in each file.  The tree is used to rapidly find the partner
00981  *        of a line which occurs exactly once in each file.
00982  *
00983  *    2   make a section covering the whole file (for both)
00984  *        and link unique lines between these sections (i.e. link lines
00985  *        which occur exactly once in each file as they must match each other).
00986  *        These are referred to as anchor points.
00987  *
00988  *    3   build section lists for both files by traversing line lists and
00989  *        making a section for each set of adjacent lines that are unmatched
00990  *        and for each set of adjacent lines that match a set of adjacent
00991  *        lines in the other file.  In making a section we start from a
00992  *        known matching line and work both forwards and backwards through
00993  *        the file including lines which match, whether they are unique or not.
00994  *
00995  *    4   establish links between sections that match
00996  *        and also between sections that don't match but do
00997  *        correspond (by position in file between matching sections)
00998  *
00999  *    5   for each section pair that don't match but do correspond,
01000  *        link up matching lines unique within that section.  (i.e. do
01001  *        the whole algorithm again on just this section).
01002  *
01003  *    There may be some lines which occur many times over in each file.
01004  *    As these occurrences are matched up, so the number left to match
01005  *    reduces, and may reach one in each file.  At this point these two
01006  *    can be matched.  Therefore we...
01007  *
01008  *    repeat steps 1-5 until no more new links are added, but (especially
01009  *    in step 0) we only bother with lines which have not yet been matched.
01010  *    this means that a line which has only one unmatched instance in each
01011  *    file gets a count of one and so is a new anchor point.
01012  *
01013  *    ALGORITHM2
01014  *    After we have found all lines that match by the above, we see if there
01015  *    are any lines which occur MORE than once on each side which are still
01016  *    unmatched.  We then try matching the first occurrence on each side
01017  *    with each other.  However we only do this for lines longer than (arbitrarily)
01018  *    8 chars.  Matching lines that are just blank or } gives too many false hits.
01019  *    If this achieved anything, we go back to the previous
01020  *    uniqueness condition to see how much more progress we can make.  This is
01021  *    controlled by the TryDups logic at the end of the loop.
01022  *
01023  *    Finally build a composite list from the two lists of sections.
01024  */
01025 void
01026 ci_compare(COMPITEM ci)
01027 {
01028     LIST lines_left, lines_right;
01029     SECTION whole_left, whole_right;
01030     BOOL bChanges;  /* loop control - we're still making more matches */
01031     BOOL bTryDups;  /* first try exact matches - then try matching non-unique ones too */
01032     extern BOOL Algorithm2;   /* declared in sdkdiff.cpp */
01033 #ifdef trace
01034     DWORD Ticks;        /* time for profiling */
01035     DWORD StartTicks;   /* time for profiling */
01036 #endif
01037     /* get the list of lines for each file */
01038     lines_left = file_getlinelist(ci->left);
01039     lines_right = file_getlinelist(ci->right);
01040
01041     if ((lines_left == NULL) || (lines_right == NULL)) {
01042         ci->secs_left = NULL;
01043         ci->secs_right = NULL;
01044         ci->secs_composite = NULL;
01045         return;
01046     }
01047
01048     bTryDups = FALSE;
01049
01050 #ifdef trace
01051     StartTicks = GetTickCount();
01052     Ticks = StartTicks;
01053 #endif
01054     do {
01055
01056         /* we have made no changes so far this time round the
01057          * loop
01058          */
01059         bChanges = FALSE;
01060
01061         /* make a section covering the whole file */
01062         whole_left = section_new((LINE)List_First(lines_left),
01063                                  (LINE)List_Last(lines_left), NULL);
01064
01065         whole_right = section_new((LINE)List_First(lines_right),
01066                                   (LINE)List_Last(lines_right), NULL);
01067
01068         /* link up matching unique lines between these sections */
01069         if (section_match(whole_left, whole_right, bTryDups)) {
01070             bChanges = TRUE;
01071         }
01072
01073         /* delete the two temp sections */
01074         section_delete(whole_left);
01075         section_delete(whole_right);
01076
01077         /* discard previous section lists if made */
01078         if (ci->secs_left) {
01079             section_deletelist(ci->secs_left);
01080             ci->secs_left = NULL;
01081         }
01082         if (ci->secs_right) {
01083             section_deletelist(ci->secs_right);
01084             ci->secs_right = NULL;
01085         }
01086         /* build new section lists for both files */
01087         ci->secs_left = section_makelist(lines_left, TRUE);
01088         ci->secs_right = section_makelist(lines_right, FALSE);
01089
01090         /* match up sections - make links and corresponds between
01091          * sections. Attempts to section_match corresponding
01092          * sections that are not matched. returns true if any
01093          * further links were made
01094          */
01095         if (section_matchlists(ci->secs_left, ci->secs_right, bTryDups)) {
01096             bChanges = TRUE;
01097         }
01098
01099 #ifdef trace
01100         /* profiling */
01101         {   char Msg[80];
01102             DWORD tks = GetTickCount();
01103             HRESULT hr = StringCchPrintf( Msg, 80, "ci_compare loop %ld, total %d %s %s \n"
01104                       , tks-Ticks, tks-StartTicks
01105                       , (bChanges ? "Changes," : "No changes,")
01106                       , (bTryDups ? "Was trying dups." : "Was not trying dups.")
01107                     );
01108       if (FAILED(hr)) {
01109         OutputError(hr, IDS_SAFE_PRINTF);
01110       }
01111             Trace_File(Msg);
01112             Ticks = GetTickCount();
01113             /* correct for time spent profiling */
01114             StartTicks = StartTicks+Ticks-tks;
01115         }
01116 #endif
01117
01118         /* repeat as long as we keep adding new links */
01119         if (bChanges) bTryDups = FALSE;
01120         else if ((bTryDups==FALSE) & Algorithm2) {bTryDups = TRUE;
01121             bChanges = TRUE;  // at least one more go
01122         }
01123
01124
01125     } while (bChanges);
01126
01127     /* all possible lines linked, and section lists made .
01128      * combine the two section lists to get a view of the
01129      * whole comparison - the composite section list. This also
01130      * sets the state of each section in the composite list.
01131      */
01132 #ifdef trace
01133     StartTicks = GetTickCount();
01134 #endif
01135     ci->secs_composite = section_makecomposite(ci->secs_left, ci->secs_right);
01136 #ifdef trace
01137     Ticks = GetTickCount()-StartTicks;
01138     {   char Msg[80];
01139         HRESULT hr = StringCchPrintf( Msg, 80, "section_makecomposite time = %d\n", Ticks);
01140     if (FAILED(hr)) {
01141       OutputError(hr, IDS_SAFE_PRINTF);
01142     }
01143         Trace_File(Msg);
01144     }
01145 #endif
01146 }
01147
01148
01149 void SetStateAndTag( COMPITEM ci, DIRITEM leftname, DIRITEM rightname, BOOL fExact)
01150 {
01151     /* set the tag (title field) for this item. if the
01152      * two files have names that match, we use just that name -
01153      * otherwise we use both names separated by a colon 'left : right'.
01154      *
01155      * in both cases, use the names relative to compare root (the
01156      * names will certainly be different if we compare the abs paths)
01157      */
01158     LPSTR str1 = dir_getrelname(leftname);
01159     LPSTR str2 = dir_getrelname(rightname);
01160     char buf[2*MAX_PATH+20];
01161     TCHAR tmpbuf[MAX_PATH];
01162   HRESULT hr;
01163
01164     /* if only one file - set name to that */
01165     if (ci->left == NULL) {
01166         ci->tag = ci_copytext(str2);
01167     } else if (ci->right == NULL) {
01168         ci->tag = ci_copytext(str1);
01169     } else {
01170         if (lstrcmpi(str1, str2) == 0) {
01171             ci->tag = ci_copytext(str2);
01172         } else {
01173             hr = StringCchPrintf(buf, (2*MAX_PATH+20), "%s : %s", str1, str2);
01174       if (FAILED(hr))
01175         OutputError(hr, IDS_SAFE_PRINTF);
01176             ci->tag = ci_copytext(buf);
01177         }
01178     }
01179
01180     dir_freerelname(leftname, str1);
01181     dir_freerelname(rightname, str2);
01182
01183
01184     if (ci->left == NULL) {
01185
01186         BOOL Readable = TRUE;
01187         // At this point we COULD try to set Readable but we would need
01188         // to do a rescan to ensure that sumvalid and fileerror are set.
01189         // where the file is only found on one side or the other, in the
01190         // interests of speed we have NOT TRIED to read the file.
01191
01192         str1 = dir_getrootdescription(dir_getlist(rightname));
01193         hr = StringCchCopy(tmpbuf, MAX_PATH, (Readable ? TEXT("") : LoadRcString(IDS_UNREADABLE)));
01194     if (FAILED(hr))
01195       OutputError(hr, IDS_SAFE_COPY);
01196         hr = StringCchPrintf(buf, (2*MAX_PATH+20), LoadRcString(IDS_ONLY_IN), str1, tmpbuf);
01197     if (FAILED(hr))
01198       OutputError(hr, IDS_SAFE_PRINTF);
01199         dir_freerootdescription(dir_getlist(rightname), str1);
01200
01201         ci->result = ci_copytext(buf);
01202         ci->state = STATE_FILERIGHTONLY;
01203     } else if (ci->right == NULL) {
01204
01205         BOOL Readable = TRUE;        // See above
01206
01207         str1 = dir_getrootdescription(dir_getlist(leftname));
01208         hr = StringCchCopy(tmpbuf, MAX_PATH, (Readable ? TEXT("") : LoadRcString(IDS_UNREADABLE)));
01209         if (FAILED(hr))
01210       OutputError(hr, IDS_SAFE_COPY);
01211     hr = StringCchPrintf(buf, (2*MAX_PATH+20), LoadRcString(IDS_ONLY_IN), str1, tmpbuf);
01212         if (FAILED(hr))
01213       OutputError(hr, IDS_SAFE_PRINTF);
01214     dir_freerootdescription(dir_getlist(leftname), str1);
01215
01216         ci->result = ci_copytext(buf);
01217         ci->state = STATE_FILELEFTONLY;
01218     } else {
01219         /* two files - are they the same ? compare
01220          * the file sizes, and if necessary, checksums.
01221          * if the sizes differ, we don't need to checksum.
01222          */
01223
01224         // if there is some error in the file, we can mark them
01225         // as differs and set the text to indicate that one or
01226         // both is unreadable.
01227         if (dir_fileerror(leftname)) {
01228             ci->state = STATE_DIFFER;
01229             if (dir_fileerror(rightname)) {
01230                 ci->result = ci_copytext(LoadRcString(IDS_BOTH_UNREADABLE));
01231             } else {
01232                 ci->result = ci_copytext(LoadRcString(IDS_LEFT_UNREADABLE));
01233             }
01234         } else if (dir_fileerror(rightname)) {
01235             ci->state = STATE_DIFFER;
01236             ci->result = ci_copytext(LoadRcString(IDS_RIGHT_UNREADABLE));
01237         }
01238
01239         /* Subtle side-effects below us:
01240            dir_validchecksum merely tells us whether we have YET got a valid
01241            checksum for the file, NOT whether one is available if we tried.
01242            If !fExact then we don't WANT them, so we don't ask.
01243            If fExact then we must FIRST ask for the checksum and only after
01244            that enquire if one is valid.  (file read errors etc will mean that
01245            it is NOT valid).  dir_getchecksum has side effect of evaluating it
01246            if needed.  If it's by chance available, then we should use it, even
01247            if exact matching is not in operation.
01248
01249            Where files differ we report which is earliest in time.
01250
01251            The logic is as follows
01252                  sizes equal
01253                N     ?                  Y
01254                      |          both-sums-known
01255             differ   |          Y       ?      N
01256           (different |      sums-equal  |   exact
01257              sizes)  |     Y    ?  N    |  N  ?          Y
01258                      | identical|differ | same|   right-sum-valid
01259                      |          |       | size|  N   ?      Y
01260                      |          |       |     |right |  left-sum-valid
01261                      |          |       |     |un-   | N    ?      Y
01262                      |          |       |     |read- |left  |  sums-match
01263                      |          |       |     |able  |un-   |  N   ?   Y
01264                      |          |       |     |      |read- |differ|identical
01265                      |          |       |     |      |able  |      |
01266         */
01267
01268
01269         else if (dir_getfilesize(leftname) != dir_getfilesize(rightname)) {
01270             ci->state = STATE_DIFFER;
01271             ci->result = ci_AddTimeString(LoadRcString(IDS_DIFFERENT), ci, leftname, rightname);
01272         } else if (dir_validchecksum(leftname) && dir_validchecksum(rightname)) {
01273             if (dir_getchecksum(leftname) == dir_getchecksum(rightname)) {
01274                 ci->result =  ci_copytext(LoadRcString(IDS_IDENTICAL));
01275                 ci->state = STATE_SAME;
01276             } else {
01277                 ci->result = ci_AddTimeString(LoadRcString(IDS_DIFFERENT), ci, leftname, rightname);
01278                 ci->state = STATE_DIFFER;
01279             }
01280         } else if (!fExact) {
01281             ci->result = ci_AddTimeString(LoadRcString(IDS_SAME_SIZE), ci, leftname, rightname);
01282             ci->state = STATE_SAME;
01283         } else {
01284             DWORD LSum = dir_getchecksum(leftname);
01285             DWORD RSum = dir_getchecksum(rightname);
01286
01287             if (!dir_validchecksum(rightname) ) {
01288                 if (!dir_validchecksum(leftname) ) {
01289                     ci->result = ci_AddTimeString(LoadRcString(IDS_BOTH_UNREADABLE), ci, leftname, rightname);
01290                     ci->state = STATE_DIFFER;
01291                 } else {
01292                     ci->result = ci_AddTimeString(LoadRcString(IDS_RIGHT_UNREADABLE), ci, leftname, rightname);
01293                     ci->state = STATE_DIFFER;
01294                 }
01295             } else if (!dir_validchecksum(leftname) ) {
01296                 ci->result = ci_AddTimeString(LoadRcString(IDS_LEFT_UNREADABLE), ci, leftname, rightname);
01297                 ci->state = STATE_DIFFER;
01298             } else if (LSum!=RSum) {
01299                 ci->result = ci_AddTimeString(LoadRcString(IDS_DIFFERENT), ci, leftname, rightname);
01300                 ci->state = STATE_DIFFER;
01301             } else {
01302                 ci->result =  ci_copytext(LoadRcString(IDS_IDENTICAL));
01303                 ci->state = STATE_SAME;
01304             }
01305         }
01306     }
01307 } /* SetStateAndTag */
01308
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/RegisterDevice/RegDevice.cpp Source File

  • NetDS
  • upnp
  • RegisterDevice

RegDevice.cpp

Go to the documentation of this file.
00001 //
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 // PARTICULAR PURPOSE.
00006 //
00007 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00008 //
00009 //
00010 // RegDevice.cpp:  Provides a tool to register custom device with DeviceHost
00011 //
00012
00013 #include <stdio.h>
00014 #include <conio.h>
00015 #include <tchar.h>
00016 #include <objbase.h>
00017 #include <initguid.h>
00018 #include <atlbase.h>
00019 #include <upnphost.h>
00020 #include "dimmerdevice.h"
00021 #include "dimmerdevice_i.c"
00022
00023 #define DEFAULT_DEVICE_LIFETIME 3200
00024
00025 BOOL DescriptionDocToBSTR (WCHAR* szDDocFilename, BSTR *pdXMLDoc)
00026 {
00027    // This function reads in the description doc and converts it to a BSTR that
00028    // can be passed to the Device Host during Registration.
00029    // Memory is allocated for the BSTR here and freed when we are done with registration
00030
00031    HANDLE fHandle = NULL;
00032    BOOL retVal = TRUE;
00033    BOOL status = TRUE;
00034    DWORD lowerFileSize = 0;
00035    LPVOID pBuffer = NULL;
00036    WCHAR *pwBuffer = NULL;
00037    DWORD numBytesRead = 0;
00038
00039    if ((szDDocFilename==NULL) || (pdXMLDoc==NULL))
00040    {
00041       goto error;
00042    }
00043
00044    fHandle = CreateFile(
00045       szDDocFilename,         // file name
00046       GENERIC_READ,           // access mode
00047       FILE_SHARE_READ,        // share mode
00048       NULL,                   // SD
00049       OPEN_EXISTING,          // how to create
00050       FILE_ATTRIBUTE_NORMAL,  // file attributes
00051       NULL                    // handle to template file
00052       );
00053
00054    if (fHandle == INVALID_HANDLE_VALUE)
00055    {
00056       fHandle = NULL;
00057       goto error;
00058    }
00059
00060    // Otherwise we read the contents of the file and convert it to a BSTR
00061    lowerFileSize = GetFileSize (fHandle, NULL);
00062
00063    if (lowerFileSize == INVALID_FILE_SIZE)
00064    {
00065       // Do not support such large file sizes or GetFileSize returned an error
00066       goto error;
00067    }
00068
00069    pBuffer = CoTaskMemAlloc(lowerFileSize);
00070    if (pBuffer == NULL)
00071    {
00072       goto error;
00073    }
00074
00075    pwBuffer= (WCHAR *) CoTaskMemAlloc((lowerFileSize+1)*sizeof(WCHAR));
00076
00077    if (pwBuffer==NULL)
00078    {
00079       goto error;
00080    }
00081
00082    // Else read from the file into the buffer
00083    status = ReadFile(
00084       fHandle,
00085       pBuffer,
00086       lowerFileSize,
00087       &numBytesRead,
00088       NULL
00089       );
00090    if (!status || (numBytesRead == 0))
00091    {
00092       goto error;
00093    }
00094
00095    // Convert to a WCHAR string
00096    if (MultiByteToWideChar(CP_ACP, // code page
00097       MB_PRECOMPOSED,              // character-type options
00098       (LPCSTR) pBuffer,            // string to map
00099       lowerFileSize,               // number of bytes in string
00100       pwBuffer,                    // wide-character buffer
00101       lowerFileSize                // size of wide char buffer
00102       )==0)
00103    {
00104       goto error;
00105    }
00106
00107    //adding a "\0" to the end of the buffer
00108    pwBuffer[lowerFileSize]=_TEXT('\0');
00109    //now convert the file to a BSTR
00110    *pdXMLDoc = NULL;
00111    *pdXMLDoc = SysAllocString(pwBuffer);
00112
00113    if (*pdXMLDoc == NULL)
00114    {
00115       goto error;
00116    }
00117
00118    CloseHandle(fHandle);
00119    CoTaskMemFree(pBuffer);
00120    CoTaskMemFree(pwBuffer);
00121
00122    // Have copied the description doc to a BSTR and so return TRUE
00123    return retVal;
00124
00125 error:
00126
00127    retVal = FALSE;
00128    if (fHandle)
00129    {
00130       CloseHandle(fHandle);
00131    }
00132    CoTaskMemFree(pBuffer);
00133    CoTaskMemFree(pwBuffer);
00134    return retVal;
00135
00136 }
00137
00138
00139
00140 int _cdecl main()
00141 {
00142    // This executable makes the call to the Device Host to register a device
00143
00144    HRESULT hr = S_OK;
00145    IUnknown *punk = NULL;
00146    IDispatch *pIDisp = NULL;
00147    IUPnPRegistrar *pReg = NULL;
00148    IUPnPReregistrar *pRereg = NULL;
00149    LPWSTR resourcePath = NULL;
00150    DWORD dwSize = 0;
00151    WCHAR fileDescriptionDoc[] = L"DimmerDevice-Desc.xml";
00152    WCHAR initString[] = L"DimmerDevice SDK Sample";
00153    LONG lifeTime = DEFAULT_DEVICE_LIFETIME;
00154    BSTR DeviceID = NULL;
00155    BSTR desDoc = NULL;
00156    BSTR initBSTR = NULL;
00157    BSTR resourcePathBSTR = NULL;
00158    CHAR option;
00159    INT getMsgRet = 0;
00160
00161    BOOL retVal = TRUE;
00162
00163    printf("\nSetup:");
00164    printf("\nBefore running this program please make sure that the two XML files");
00165    printf("\nare in the same directory as the EXE.\n");
00166    printf("\nAlso make sure that the command 'regsvr32 UPNPSampleDimmerDevice.dll'");
00167    printf("\nhas been run to register device-specific COM object.\n");
00168
00169    hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);
00170    if (FAILED(hr))
00171    {
00172       printf("\nCould not initialize COM library");
00173       return 0;
00174    }
00175
00176    hr = CoInitializeSecurity(
00177       NULL,
00178       -1,
00179       NULL,
00180       NULL,
00181       RPC_C_AUTHN_LEVEL_DEFAULT,
00182       RPC_C_IMP_LEVEL_IMPERSONATE,
00183       NULL,
00184       EOAC_SECURE_REFS,
00185       NULL
00186       );
00187
00188    if (FAILED(hr))
00189    {
00190       printf("\nCould not initialize COM security");
00191       goto error;
00192    }
00193
00194    // Now try to instantiate the Device Control Object
00195    hr = CoCreateInstance(
00196       CLSID_UPNPSampleDimmerDevice,
00197       NULL,
00198       CLSCTX_INPROC_SERVER,
00199       IID_IUnknown,
00200       (LPVOID *) &punk
00201       );
00202
00203    if (FAILED(hr))
00204    {
00205       printf("\nCould not Instantiate the Device Control Object. - %x",hr);
00206       printf("\nCheck that the dll UPNPSampleDimmerDevice.dll has been registered");
00207       goto error;
00208    }
00209
00210    // Continue with the registration and register the running device with the Device Host
00211    // get the resource path or the current directory where the XML files are located
00212
00213    // Call GetCurrentDirectory() specifying nBufferLength = 0 to get the size of the
00214    // required buffer to hold path, then call this function again to fill in the buffer
00215    dwSize = GetCurrentDirectoryW(0, NULL);
00216    resourcePath = (WCHAR *) CoTaskMemAlloc((dwSize + 1) * sizeof (WCHAR)); // add for for trailing "\"
00217    if (resourcePath == NULL)
00218    {
00219       printf("\nMemory Allocation Failure.. exiting");
00220       goto error;
00221    }
00222
00223    if (GetCurrentDirectoryW(dwSize, resourcePath) == 0)
00224    {
00225       printf("\nCould not get the current directory Path where the XML files are located");
00226       goto error;
00227    }
00228
00229    wcscat(resourcePath,L"\\");
00230
00231    //now we try to read in the description doc for the DimmerDevice
00232    retVal = DescriptionDocToBSTR(fileDescriptionDoc, &desDoc);
00233
00234    if (retVal==FALSE)
00235    {
00236       printf("\nCould not load the description document for the device");
00237       goto error;
00238    }
00239
00240    initBSTR = SysAllocString(initString);
00241    if (initBSTR==NULL)
00242    {
00243       printf("\nMemory Allocation Failure.. exiting");
00244       goto error;
00245    }
00246
00247    resourcePathBSTR = SysAllocString(resourcePath);
00248    if (resourcePathBSTR == NULL)
00249    {
00250       printf("\nMemory Allocation Failure.. exiting");
00251       goto error;
00252    }
00253
00254    //now register the device with the Device Host service
00255    hr = CoCreateInstance(
00256       CLSID_UPnPRegistrar,
00257       NULL,
00258       CLSCTX_LOCAL_SERVER,
00259       IID_IUPnPRegistrar,
00260       (LPVOID *) &pReg
00261       );
00262    if (FAILED(hr))
00263    {
00264       printf("\nCould not get a pointer to the IUPnPRegistrar Interface failed - %x",hr);
00265       printf("\nCheck that the UPNP Device Host Component is installed on this machine");
00266       goto error;
00267    }
00268
00269    //now get a pointer to the IID_IUPnPReregistrar
00270    hr = CoCreateInstance(
00271       CLSID_UPnPRegistrar,
00272       NULL,
00273       CLSCTX_LOCAL_SERVER,
00274       IID_IUPnPReregistrar,
00275       (LPVOID *) &pRereg
00276       );
00277
00278    if (FAILED(hr))
00279    {
00280       printf("\nCould not get the pointer to the IUPnPReregistrar Interface - %x",hr);
00281       printf("\nCheck that the UPNP Device Host Component is installed on this machine");
00282       goto error;
00283    }
00284
00285    hr = pReg->RegisterRunningDevice(desDoc,punk,initBSTR,resourcePathBSTR,lifeTime,&DeviceID);
00286
00287    if (FAILED(hr))
00288    {
00289       printf("Could not register the device with the Device Host - %x",hr);
00290       goto error;
00291    }
00292
00293    printf("\nDevice Registered Successfully with the UPNP Device Host...");
00294    printf("\nHit d to unregister the device -  ");
00295    while (1)
00296    {
00297       option =  (CHAR)_getche();
00298       if((option=='d')||(option=='D'))
00299       {
00300          break;
00301       }
00302    }
00303
00304    printf("\nUnregistering the device with the UPNP Device Host and Quitting ..");
00305    //deregister the device
00306    hr = pReg->UnregisterDevice(DeviceID,TRUE);
00307
00308    if (SUCCEEDED(hr))
00309    {
00310       printf("\nDevice was unregistered successfully");
00311    }
00312    else
00313    {
00314       printf("\nDevice could not be unregistered - %x",hr);
00315    }
00316
00317    CoTaskMemFree(resourcePath);
00318    SysFreeString(desDoc);
00319    SysFreeString(initBSTR);
00320    SysFreeString(resourcePathBSTR);
00321    //release the references to the interfaces
00322    pRereg->Release();
00323    punk->Release();
00324    pReg->Release();
00325    CoUninitialize();
00326    return 1;
00327
00328 error:
00329
00330    CoTaskMemFree(resourcePath);
00331    SysFreeString(desDoc);
00332    SysFreeString(initBSTR);
00333    SysFreeString(resourcePathBSTR);
00334    if (punk)
00335    {
00336       punk->Release();
00337    }
00338    if (pRereg)
00339    {
00340       pRereg->Release();
00341    }
00342    if (pReg)
00343    {
00344       pReg->Release();
00345    }
00346    CoUninitialize();
00347    return 0;
00348 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/LSP/spi.cpp Source File

  • NetDS
  • WinSock
  • LSP

spi.cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: spi.cpp
00009 //
00010 // Description:
00011 //
00012 //    This sample illustrates how to develop a layered service provider that is
00013 //    capable of counting all bytes transmitted through an IP socket. The application
00014 //    reports when sockets are created and reports how many bytes were sent and
00015 //    received when a socket closes. The results are reported using the OutputDebugString
00016 //    API which will allow you to intercept the I/O by using a debugger such as cdb.exe
00017 //    or you can monitor the I/O using dbmon.exe.
00018 //
00019 //    This file contains the 30 SPI functions you are required to implement in a
00020 //    service provider. It also contains the two functions that must be exported
00021 //    from the DLL module DllMain and WSPStartup.
00022 //
00023
00024 #include "provider.h"
00025 #include "install.h"
00026
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029
00030 //
00031 // Globals used across files
00032 //
00033 CRITICAL_SECTION    gCriticalSection,
00034                     gOverlappedCS,
00035                     gDebugCritSec;
00036 WSPUPCALLTABLE      MainUpCallTable;
00037 HINSTANCE           hDllInstance = NULL;
00038
00039 LPPROVIDER          gBaseInfo = NULL;   // Provider information for each layer under us
00040 INT                 gLayerCount=0;      // Number of base providers we're layered over
00041
00042 HANDLE              hLspHeap=NULL;
00043 HANDLE              gAddContextEvent=NULL;
00044
00045 extern HANDLE       ghIocp;             // Handle to IO completion port
00046
00047
00048 void FreeSocketsAndMemory(int *lpErrno);
00049
00050 //
00051 // Need to keep track of which PROVIDERs that are currently executing
00052 //  a blocking Winsock call on a per thread basis.
00053 //
00054 #define SetBlockingProvider(Provider)       \
00055     (TlsIndex!=0xFFFFFFFF)                  \
00056         ? TlsSetValue (TlsIndex, Provider)  \
00057         : NULL
00058
00059 //
00060 // Globals local to this file
00061 //
00062 static DWORD               TlsIndex=0xFFFFFFFF;
00063 static DWORD               gEntryCount = 0;    // how many times WSPStartup has been called
00064 static DWORD               gLayerCatId = 0;    // Catalog ID of our dummy entry
00065 static WSPDATA             gWSPData;
00066 static WSPPROC_TABLE       gProcTable;
00067 static BOOL                bDetached=FALSE;
00068
00069 static TCHAR Msg[512];                         // For outputting debug messages
00070
00071
00072 //
00073 // Function: dbgprint
00074 //
00075 // Description:
00076 //    Format and print a message to the debugger.
00077 //
00078 void dbgprint(char *format,...)
00079 {
00080     static  DWORD pid=0;
00081     va_list vl;
00082     char    dbgbuf1[2048],
00083             dbgbuf2[2048];
00084
00085     // Prepend the process ID to the message
00086     if (pid == 0)
00087     {
00088         pid = GetCurrentProcessId();
00089     }
00090
00091     EnterCriticalSection(&gDebugCritSec);
00092     va_start(vl, format);
00093     wvsprintf(dbgbuf1, format, vl);
00094     wsprintf(dbgbuf2, "%lu: %s\r\n", pid, dbgbuf1);
00095     va_end(vl);
00096
00097     OutputDebugString(dbgbuf2);
00098     LeaveCriticalSection(&gDebugCritSec);
00099 }
00100
00101 //
00102 // Function: PrintProcTable
00103 //
00104 // Description
00105 //    Print the table of function pointers. This can be useful in tracking
00106 //    down bugs with other LSP being layered over.
00107 //
00108 void PrintProcTable(LPWSPPROC_TABLE lpProcTable)
00109 {
00110     #ifdef DBG_PRINTPROCTABLE
00111     dbgprint("WSPAccept              = 0x%X", lpProcTable->lpWSPAccept);
00112     dbgprint("WSPAddressToString     = 0x%X", lpProcTable->lpWSPAddressToString);
00113     dbgprint("WSPAsyncSelect         = 0x%X", lpProcTable->lpWSPAsyncSelect);
00114     dbgprint("WSPBind                = 0x%X", lpProcTable->lpWSPBind);
00115     dbgprint("WSPCancelBlockingCall  = 0x%X", lpProcTable->lpWSPCancelBlockingCall);
00116     dbgprint("WSPCleanup             = 0x%X", lpProcTable->lpWSPCleanup);
00117     dbgprint("WSPCloseSocket         = 0x%X", lpProcTable->lpWSPCloseSocket);
00118     dbgprint("WSPConnect             = 0x%X", lpProcTable->lpWSPConnect);
00119     dbgprint("WSPDuplicateSocket     = 0x%X", lpProcTable->lpWSPDuplicateSocket);
00120     dbgprint("WSPEnumNetworkEvents   = 0x%X", lpProcTable->lpWSPEnumNetworkEvents);
00121     dbgprint("WSPEventSelect         = 0x%X", lpProcTable->lpWSPEventSelect);
00122     dbgprint("WSPGetOverlappedResult = 0x%X", lpProcTable->lpWSPGetOverlappedResult);
00123     dbgprint("WSPGetPeerName         = 0x%X", lpProcTable->lpWSPGetPeerName);
00124     dbgprint("WSPGetSockOpt          = 0x%X", lpProcTable->lpWSPGetSockOpt);
00125     dbgprint("WSPGetSockName         = 0x%X", lpProcTable->lpWSPGetSockName);
00126     dbgprint("WSPGetQOSByName        = 0x%X", lpProcTable->lpWSPGetQOSByName);
00127     dbgprint("WSPIoctl               = 0x%X", lpProcTable->lpWSPIoctl);
00128     dbgprint("WSPJoinLeaf            = 0x%X", lpProcTable->lpWSPJoinLeaf);
00129     dbgprint("WSPListen              = 0x%X", lpProcTable->lpWSPListen);
00130     dbgprint("WSPRecv                = 0x%X", lpProcTable->lpWSPRecv);
00131     dbgprint("WSPRecvDisconnect      = 0x%X", lpProcTable->lpWSPRecvDisconnect);
00132     dbgprint("WSPRecvFrom            = 0x%X", lpProcTable->lpWSPRecvFrom);
00133     dbgprint("WSPSelect              = 0x%X", lpProcTable->lpWSPSelect);
00134     dbgprint("WSPSend                = 0x%X", lpProcTable->lpWSPSend);
00135     dbgprint("WSPSendDisconnect      = 0x%X", lpProcTable->lpWSPSendDisconnect);
00136     dbgprint("WSPSendTo              = 0x%X", lpProcTable->lpWSPSendTo);
00137     dbgprint("WSPSetSockOpt          = 0x%X", lpProcTable->lpWSPSetSockOpt);
00138     dbgprint("WSPShutdown            = 0x%X", lpProcTable->lpWSPShutdown);
00139     dbgprint("WSPSocket              = 0x%X", lpProcTable->lpWSPSocket);
00140     dbgprint("WSPStringToAddress     = 0x%X", lpProcTable->lpWSPStringToAddress);
00141     #endif
00142 }
00143
00144 //
00145 // Function: VerifyProctable
00146 //
00147 // Description:
00148 //    Checks to make sure all function pointers are non-NULL. Returns SOCKET_ERROR
00149 //    if successful, NO_ERROR otherwise.
00150 //
00151 int VerifyProcTable(LPWSPPROC_TABLE lpProcTable)
00152 {
00153    if ( lpProcTable->lpWSPAccept &&
00154         lpProcTable->lpWSPAddressToString &&
00155         lpProcTable->lpWSPAsyncSelect &&
00156         lpProcTable->lpWSPBind &&
00157         lpProcTable->lpWSPCancelBlockingCall &&
00158         lpProcTable->lpWSPCleanup &&
00159         lpProcTable->lpWSPCloseSocket &&
00160         lpProcTable->lpWSPConnect &&
00161         lpProcTable->lpWSPDuplicateSocket &&
00162         lpProcTable->lpWSPEnumNetworkEvents &&
00163         lpProcTable->lpWSPEventSelect &&
00164         lpProcTable->lpWSPGetOverlappedResult &&
00165         lpProcTable->lpWSPGetPeerName &&
00166         lpProcTable->lpWSPGetSockOpt &&
00167         lpProcTable->lpWSPGetSockName &&
00168         lpProcTable->lpWSPGetQOSByName &&
00169         lpProcTable->lpWSPIoctl &&
00170         lpProcTable->lpWSPJoinLeaf &&
00171         lpProcTable->lpWSPListen &&
00172         lpProcTable->lpWSPRecv &&
00173         lpProcTable->lpWSPRecvDisconnect &&
00174         lpProcTable->lpWSPRecvFrom &&
00175         lpProcTable->lpWSPSelect &&
00176         lpProcTable->lpWSPSend &&
00177         lpProcTable->lpWSPSendDisconnect &&
00178         lpProcTable->lpWSPSendTo &&
00179         lpProcTable->lpWSPSetSockOpt &&
00180         lpProcTable->lpWSPShutdown &&
00181         lpProcTable->lpWSPSocket &&
00182         lpProcTable->lpWSPStringToAddress)
00183     {
00184         return NO_ERROR;
00185     }
00186     return SOCKET_ERROR;
00187 }
00188
00189 //
00190 // Function: DllMain
00191 //
00192 // Description:
00193 //    Provides initialization when the LSP DLL is loaded. In our case we simply,
00194 //    initialize some critical sections used throughout the DLL.
00195 //
00196 BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD dwReason, LPVOID lpvReserved)
00197 {
00198     switch (dwReason)
00199     {
00200
00201         case DLL_PROCESS_ATTACH:
00202             hDllInstance = hinstDll;
00203             //
00204             // Initialize some critical section objects
00205             //
00206             InitializeCriticalSection(&gCriticalSection);
00207             InitializeCriticalSection(&gOverlappedCS);
00208             InitializeCriticalSection(&gDebugCritSec);
00209
00210             TlsIndex = TlsAlloc();
00211             break;
00212
00213         case DLL_THREAD_ATTACH:
00214             break;
00215
00216         case DLL_THREAD_DETACH:
00217             break;
00218
00219         case DLL_PROCESS_DETACH:
00220             bDetached = TRUE;
00221
00222             EnterCriticalSection(&gCriticalSection);
00223             if (gBaseInfo)
00224             {
00225                 int Error;
00226
00227                 FreeSocketsAndMemory(&Error);
00228             }
00229             LeaveCriticalSection(&gCriticalSection);
00230
00231             DeleteCriticalSection(&gCriticalSection);
00232             DeleteCriticalSection(&gOverlappedCS);
00233             DeleteCriticalSection(&gDebugCritSec);
00234
00235             if (lpvReserved == NULL)
00236             {
00237                 if (TlsIndex != 0xFFFFFFFF)
00238                 {
00239                     TlsFree(TlsIndex);
00240                     TlsIndex = 0xFFFFFFFF;
00241                 }
00242             }
00243             break;
00244     }
00245
00246     return TRUE;
00247 }
00248
00249 //
00250 // Function: WSPAccept
00251 //
00252 // Description:
00253 //    Handle the WSAAccept function. The only special consideration here is the
00254 //    conditional accept callback. You can choose to intercept this by substituting
00255 //    your own callback (you'll need to keep track of the user supplied callback so
00256 //    you can trigger that once your substituted function is triggered).
00257 //
00258 SOCKET WSPAPI WSPAccept (
00259     SOCKET          s,
00260     struct sockaddr FAR * addr,
00261     LPINT           addrlen,
00262     LPCONDITIONPROC lpfnCondition,
00263     DWORD_PTR       dwCallbackData,
00264     LPINT           lpErrno)
00265 {
00266     SOCKET     NewProviderSocket;
00267     SOCKET     NewSocket = INVALID_SOCKET;
00268     SOCK_INFO *NewSocketContext;
00269     SOCK_INFO *SocketContext;
00270
00271     // Query for our per socket info
00272     //
00273     SocketContext = FindAndLockSocketContext(s, lpErrno);
00274     if (SocketContext == NULL)
00275     {
00276         *lpErrno = WSAENOTSOCK;
00277         return INVALID_SOCKET;
00278     }
00279
00280     //
00281     // Note: You can subsitute your own conditional accept callback function
00282     //       in order to intercept this callback. You would have to keep track
00283     //       of the user's callback function so that you can call that when
00284     //       your intermediate function executes.
00285     //
00286     SetBlockingProvider(SocketContext->Provider);
00287     NewProviderSocket = SocketContext->Provider->NextProcTable.lpWSPAccept(
00288                             SocketContext->ProviderSocket,
00289                             addr,
00290                             addrlen,
00291                             lpfnCondition,
00292                             dwCallbackData,
00293                             lpErrno);
00294     SetBlockingProvider(NULL);
00295     if (NewProviderSocket != INVALID_SOCKET)
00296     {
00297         // The underlying provider received a new connection so lets create our own
00298         //  socket to pass back up to the application.
00299         //
00300         NewSocketContext = CreateSockInfo(
00301                 SocketContext->Provider,
00302                 NewProviderSocket,
00303                 SocketContext,
00304                 FALSE);
00305         if  (NewSocketContext == NULL)
00306         {
00307             *lpErrno = WSAENOBUFS;
00308         }
00309         else
00310         {
00311             NewSocket = NewSocketContext->LayeredSocket = MainUpCallTable.lpWPUCreateSocketHandle(
00312                     SocketContext->Provider->LayeredProvider.ProtocolChain.ChainEntries[0],
00313                     (DWORD_PTR) NewSocketContext,
00314                     lpErrno);
00315             if (NewSocket == INVALID_SOCKET)
00316             {
00317                 dbgprint("WSPAccept(): WPUCreateSocketHandle() failed: %d", *lpErrno);
00318
00319                 // Close the lower provider's socket
00320                 SocketContext->Provider->NextProcTable.lpWSPCloseSocket(
00321                     NewProviderSocket,
00322                     lpErrno
00323                     );
00324
00325                 // Context is not in the list yet so we can just free it
00326                 FreeSockInfo(NewSocketContext);
00327             }
00328             else
00329             {
00330                 InsertSocketInfo(SocketContext->Provider, NewSocketContext);
00331             }
00332         }
00333     }
00334     UnlockSocketContext(SocketContext, lpErrno);
00335
00336     return NewSocket;
00337 }
00338
00339 //
00340 // Function: WSPAdressToString
00341 //
00342 // Description:
00343 //    Convert an address to string. We simply pass this to the lower provider.
00344 //
00345 int WSPAPI WSPAddressToString(
00346     LPSOCKADDR          lpsaAddress,
00347     DWORD               dwAddressLength,
00348     LPWSAPROTOCOL_INFOW lpProtocolInfo,
00349     LPWSTR              lpszAddressString,
00350     LPDWORD             lpdwAddressStringLength,
00351     LPINT               lpErrno)
00352 {
00353     WSAPROTOCOL_INFOW *pInfo=NULL;
00354     PROVIDER          *Provider=NULL;
00355     INT                i, ret;
00356
00357     // First find the appropriate provider
00358     //
00359     for(i=0; i < gLayerCount ;i++)
00360     {
00361         if ((gBaseInfo[i].NextProvider.iAddressFamily == lpProtocolInfo->iAddressFamily) &&
00362             (gBaseInfo[i].NextProvider.iSocketType == lpProtocolInfo->iSocketType) &&
00363             (gBaseInfo[i].NextProvider.iProtocol   == lpProtocolInfo->iProtocol))
00364         {
00365             if (lpProtocolInfo)
00366             {
00367                 // In case of multiple providers check the provider flags
00368                 if ( (gBaseInfo[i].NextProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES) !=
00369                      (lpProtocolInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES) )
00370                 {
00371                     continue;
00372                 }
00373             }
00374             Provider = &gBaseInfo[i];
00375             pInfo = &gBaseInfo[i].NextProvider;
00376             break;
00377         }
00378     }
00379     if (Provider == NULL)
00380     {
00381         *lpErrno = WSAEINVAL;
00382         return SOCKET_ERROR;
00383     }
00384     // Of course if the next layer isn't a base just pass down lpProtocolInfo.
00385     //
00386     if (pInfo->ProtocolChain.ChainLen != BASE_PROTOCOL)
00387     {
00388         pInfo = lpProtocolInfo;
00389     }
00390
00391     SetBlockingProvider(Provider);
00392     ret = Provider->NextProcTable.lpWSPAddressToString(lpsaAddress,
00393                                                        dwAddressLength,
00394                                                        pInfo,
00395                                                        lpszAddressString,
00396                                                        lpdwAddressStringLength,
00397                                                        lpErrno);
00398     SetBlockingProvider(NULL);
00399
00400     return ret;
00401 }
00402
00403 //
00404 // Function: WSPAsyncSelect
00405 //
00406 // Description:
00407 //    Register specific Winsock events with a socket. We need to substitute
00408 //    the app socket with the provider socket and use our own hidden window.
00409 //
00410 int WSPAPI WSPAsyncSelect (
00411     SOCKET       s,
00412     HWND         hWnd,
00413     unsigned int wMsg,
00414     long         lEvent,
00415     LPINT        lpErrno)
00416 {
00417     SOCK_INFO *SocketContext;
00418     HWND       hWorkerWindow;
00419     INT        ret;
00420
00421     // Make sure the window handle is valid
00422     //
00423     ret = SOCKET_ERROR;
00424     if (IsWindow(hWnd))
00425     {
00426         // Verify only valid events have been set
00427         //
00428         if ( (lEvent & ~FD_ALL_EVENTS) == 0)
00429         {
00430             // Find our provider socket corresonding to this one
00431             //
00432             SocketContext = FindAndLockSocketContext(s, lpErrno);
00433             if (SocketContext != NULL)
00434             {
00435                 SocketContext->hWnd = hWnd;
00436                 SocketContext->uMsg = wMsg;
00437
00438                 // Get the handle to our hidden window
00439                 //
00440                 if ((hWorkerWindow = GetWorkerWindow()) != NULL)
00441                 {
00442                     SetBlockingProvider(SocketContext->Provider);
00443                     ret = SocketContext->Provider->NextProcTable.lpWSPAsyncSelect(
00444                                SocketContext->ProviderSocket,
00445                                hWorkerWindow,
00446                                WM_SOCKET,
00447                                lEvent,
00448                                lpErrno);
00449                     SetBlockingProvider(NULL);
00450                 }
00451                 else
00452                 {
00453                     *lpErrno = WSAEINVAL;
00454                 }
00455                 UnlockSocketContext(SocketContext, lpErrno);
00456             }
00457             else
00458             {
00459                 dbgprint("WSPAsyncSelect: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
00460                 *lpErrno = WSAENOTSOCK;
00461             }
00462         }
00463         else
00464         {
00465             *lpErrno = WSAEINVAL;
00466         }
00467     }
00468     else
00469     {
00470         *lpErrno = WSAEINVAL;
00471     }
00472
00473     return ret;
00474 }
00475
00476 //
00477 // Function: WSPBind
00478 //
00479 // Description:
00480 //    Bind the socket to a local address. We just map socket handles and
00481 //    call the lower provider.
00482 //
00483 int WSPAPI WSPBind(
00484     SOCKET                s,
00485     const struct sockaddr FAR * name,
00486     int                   namelen,
00487     LPINT                 lpErrno)
00488 {
00489     SOCK_INFO *SocketContext;
00490     INT        ret;
00491
00492     SocketContext = FindAndLockSocketContext(s, lpErrno);
00493     if (SocketContext == NULL)
00494     {
00495         dbgprint("WSPBind: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
00496         *lpErrno = WSAENOTSOCK;
00497         return SOCKET_ERROR;
00498     }
00499
00500     SetBlockingProvider(SocketContext->Provider);
00501     ret = SocketContext->Provider->NextProcTable.lpWSPBind(
00502         SocketContext->ProviderSocket,
00503         name,
00504         namelen,
00505         lpErrno);
00506     SetBlockingProvider(NULL);
00507
00508     UnlockSocketContext(SocketContext, lpErrno);
00509
00510     return ret;
00511 }
00512
00513 //
00514 // Function: WSPCancelBlockingCall
00515 //
00516 // Description:
00517 //    This call cancels any blocking Winsock call in the current thread only.
00518 //    For every Winsock call that blocks we use thread local storage (TLS) to
00519 //    store a pointer to the provider on which the blocking call was issued.
00520 //    This is necessary since WSACancelBlockingCall takes no arguments (i.e.
00521 //    the LSP needs to keep track of what calls are blocking).
00522 //
00523 int WSPAPI WSPCancelBlockingCall(
00524     LPINT lpErrno)
00525 {
00526     PROVIDER *Provider=NULL;
00527     INT       ret = NO_ERROR;
00528
00529     Provider = (PROVIDER *)TlsGetValue(TlsIndex);
00530     if (Provider != NULL)
00531     {
00532         ret = Provider->NextProcTable.lpWSPCancelBlockingCall(lpErrno);
00533     }
00534     return ret;
00535 }
00536
00537 //
00538 // Function: WSPCleanup
00539 //
00540 // Description:
00541 //    Decrement the entry count. If equal to zero then we can prepare to have us
00542 //    unloaded. Close any outstanding sockets and free up allocated memory.
00543 //
00544 int WSPAPI WSPCleanup(
00545     LPINT lpErrno
00546     )
00547 {
00548     int        ret=NO_ERROR;
00549
00550     if (bDetached)
00551         return NO_ERROR;
00552
00553     EnterCriticalSection(&gCriticalSection);
00554
00555     if (!gEntryCount)
00556     {
00557         *lpErrno = WSANOTINITIALISED;
00558
00559         dbgprint("WSPCleanup returning WSAENOTINITIALISED");
00560
00561         LeaveCriticalSection(&gCriticalSection);
00562         return SOCKET_ERROR;
00563     }
00564     // Decrement the entry count
00565     //
00566     gEntryCount--;
00567
00568     #ifdef DEBUG
00569     dbgprint("WSPCleanup: %d", gEntryCount);
00570     #endif
00571
00572     if (gEntryCount == 0)
00573     {
00574         dbgprint("WSPCleanup: gEntryCount == 0; cleaning up");
00575
00576         StopAsyncWindowManager();
00577         StopOverlappedManager();
00578
00579         Sleep(200);
00580
00581         FreeSocketsAndMemory(lpErrno);
00582     /*
00583         DecrementLspUsage(hDllInstance, 1);
00584     */
00585     }
00586     LeaveCriticalSection(&gCriticalSection);
00587
00588     return ret;
00589 }
00590
00591 //
00592 // Function: WSPCloseSocket
00593 //
00594 // Description:
00595 //    Close the socket handle of the app socket as well as the provider socket.
00596 //    However, if there are outstanding async IO requests on the app socket
00597 //    we only close the provider socket. Only when all the IO requests complete
00598 //    (with error) will we then close the app socket (this will occur in
00599 //    the overlapped manager - overlapp.cpp).
00600 //
00601 int WSPAPI WSPCloseSocket(
00602     SOCKET s,
00603     LPINT  lpErrno
00604 )
00605 {
00606     SOCK_INFO *SocketContext;
00607
00608     SocketContext = FindAndLockSocketContext(s, lpErrno);
00609     if (SocketContext == NULL)
00610     {
00611         dbgprint("WSPCloseSocket: WPUQuerySocketHandle() failed: %d", *lpErrno);
00612
00613         *lpErrno = WSAENOTSOCK;
00614         return SOCKET_ERROR;
00615     }
00616     AcquireSocketLock(SocketContext);
00617
00618     #ifdef DEBUG
00619     dbgprint("WSPCloseSocket: Closing layered socket 0x%p (provider 0x%p)",
00620         s, SocketContext->ProviderSocket);
00621     #endif
00622
00623     //
00624     // If we there are outstanding async calls on this handle don't close the app
00625     //  socket handle...only close the provider's handle.  Therefore any errors
00626     //  incurred can be propogated back to the app socket.
00627     //
00628     #ifdef DEBUG
00629     dbgprint("dwOutstanding = %d; RefCount = %d", SocketContext->dwOutstandingAsync,
00630         SocketContext->RefCount);
00631     #endif
00632
00633     if ((SocketContext->dwOutstandingAsync != 0) || (SocketContext->RefCount != 1))
00634     {
00635         SocketContext->bClosing = TRUE;
00636
00637         if (SocketContext->Provider->NextProcTable.lpWSPCloseSocket(
00638                 SocketContext->ProviderSocket,
00639                 lpErrno) == SOCKET_ERROR)
00640         {
00641             *lpErrno = WSAENOTSOCK;
00642             ReleaseSocketLock(SocketContext);
00643             UnlockSocketContext(SocketContext, lpErrno);
00644             dbgprint("WSPCloseSocket: Invalid socket handle");
00645             return SOCKET_ERROR;
00646         }
00647         #ifdef DEBUG
00648         else
00649         {
00650             dbgprint("Closed lower provider socket: 0x%p", SocketContext->ProviderSocket);
00651         }
00652         #endif
00653
00654         SocketContext->ProviderSocket = INVALID_SOCKET;
00655
00656         ReleaseSocketLock(SocketContext);
00657
00658         UnlockSocketContext(SocketContext, lpErrno);
00659         return NO_ERROR;
00660     }
00661     //
00662     // Close the provider socket
00663     //
00664     SetBlockingProvider(SocketContext->Provider);
00665     if (SocketContext->Provider->NextProcTable.lpWSPCloseSocket(
00666             SocketContext->ProviderSocket,
00667             lpErrno) == SOCKET_ERROR)
00668     {
00669         SetBlockingProvider(NULL);
00670
00671         ReleaseSocketLock(SocketContext);
00672         UnlockSocketContext(SocketContext, lpErrno);
00673
00674         dbgprint("WSPCloseSocket: Provider close failed");
00675         return SOCKET_ERROR;
00676     }
00677     SetBlockingProvider(NULL);
00678
00679     SocketContext->ProviderSocket = INVALID_SOCKET;
00680
00681     //
00682     // Remove the socket info
00683     //
00684     RemoveSocketInfo(SocketContext->Provider, SocketContext);
00685
00686     //
00687     // Close the app socket
00688     //
00689     if (MainUpCallTable.lpWPUCloseSocketHandle(s, lpErrno) == SOCKET_ERROR)
00690     {
00691         dbgprint("WPUCloseSocketHandle failed: %d", *lpErrno);
00692
00693         ReleaseSocketLock(SocketContext);
00694         UnlockSocketContext(SocketContext, lpErrno);
00695         return SOCKET_ERROR;
00696     }
00697
00698     #ifdef DEBUG
00699     dbgprint("Closing socket %d Bytes Sent [%lu] Bytes Recv [%lu]",
00700         s, SocketContext->BytesSent, SocketContext->BytesRecv);
00701     #endif
00702
00703     ReleaseSocketLock(SocketContext);
00704
00705     // Don't need to 'UnlockSocketContext' as we're deleting the object now
00706
00707     FreeSockInfo(SocketContext);
00708
00709     return NO_ERROR;
00710 }
00711
00712 //
00713 // Function: WSPConnect
00714 //
00715 // Description:
00716 //    Performs a connect call. The only thing we need to do is translate
00717 //    the socket handle.
00718 //
00719 int WSPAPI WSPConnect (
00720     SOCKET                s,
00721     const struct sockaddr FAR * name,
00722     int                   namelen,
00723     LPWSABUF              lpCallerData,
00724     LPWSABUF              lpCalleeData,
00725     LPQOS                 lpSQOS,
00726     LPQOS                 lpGQOS,
00727     LPINT                 lpErrno
00728 )
00729 {
00730     SOCK_INFO *SocketContext;
00731     INT        ret;
00732
00733     SocketContext = FindAndLockSocketContext(s, lpErrno);
00734     if (SocketContext == NULL)
00735     {
00736         dbgprint("WSPConnect: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
00737         *lpErrno = WSAENOTSOCK;
00738         return SOCKET_ERROR;
00739     }
00740
00741     SetBlockingProvider(SocketContext->Provider);
00742     ret = SocketContext->Provider->NextProcTable.lpWSPConnect(
00743                 SocketContext->ProviderSocket,
00744                 name,
00745                 namelen,
00746                 lpCallerData,
00747                 lpCalleeData,
00748                 lpSQOS,
00749                 lpGQOS,
00750                 lpErrno);
00751     SetBlockingProvider(NULL);
00752
00753     UnlockSocketContext(SocketContext, lpErrno);
00754
00755     return ret;
00756 }
00757
00758 //
00759 // Function: WSPDuplicateSocket
00760 //
00761 // Description:
00762 //    This function provides a WSAPROTOCOL_INFOW structure which can be passed
00763 //    to another process to open a handle to the same socket. First we need
00764 //    to translate the user socket into the provider socket and call the underlying
00765 //    WSPDuplicateSocket. Note that the lpProtocolInfo structure passed into us
00766 //    is an out parameter only!
00767 //
00768 int WSPAPI WSPDuplicateSocket(
00769     SOCKET              s,
00770     DWORD               dwProcessId,
00771     LPWSAPROTOCOL_INFOW lpProtocolInfo,
00772     LPINT               lpErrno)
00773 {
00774     PROVIDER          *Provider=NULL;
00775     SOCK_INFO         *SocketContext=NULL;
00776     DWORD              dwReserved;
00777     int                ret;
00778
00779     SocketContext = FindAndLockSocketContext(s, lpErrno);
00780     if (SocketContext == NULL)
00781     {
00782         dbgprint("WSPDuplicateSocket: WPUQuerySocketHandle() failed: %d", *lpErrno);
00783         *lpErrno = WSAENOTSOCK;
00784         return SOCKET_ERROR;
00785     }
00786     //
00787     // Find the underlying provider
00788     //
00789     Provider = SocketContext->Provider;
00790
00791     SetBlockingProvider(Provider);
00792     ret = Provider->NextProcTable.lpWSPDuplicateSocket(
00793                 SocketContext->ProviderSocket,
00794                 dwProcessId,
00795                 lpProtocolInfo,
00796                 lpErrno);
00797     SetBlockingProvider(NULL);
00798
00799     UnlockSocketContext(SocketContext, lpErrno);
00800
00801     if (ret == NO_ERROR)
00802     {
00803         // We want to return the WSAPROTOCOL_INFOW structure of the underlying
00804         // provider but we need to preserve the reserved info returned by the
00805         // WSPDuplicateSocket call.
00806         //
00807         dwReserved = lpProtocolInfo->dwProviderReserved;
00808         memcpy(lpProtocolInfo, &Provider->LayeredProvider, sizeof(WSAPROTOCOL_INFOW));
00809         lpProtocolInfo->dwProviderReserved = dwReserved;
00810     }
00811     return ret;
00812 }
00813
00814 //
00815 // Function: WSPEnumNetworkEvents
00816 //
00817 // Description:
00818 //    Enumerate the network events for a socket. We only need to translate the
00819 //    socket handle.
00820 //
00821 int WSPAPI WSPEnumNetworkEvents(
00822     SOCKET             s,
00823     WSAEVENT           hEventObject,
00824     LPWSANETWORKEVENTS lpNetworkEvents,
00825     LPINT              lpErrno)
00826 {
00827     SOCK_INFO *SocketContext;
00828     INT        ret;
00829
00830     SocketContext = FindAndLockSocketContext(s, lpErrno);
00831     if (SocketContext == NULL)
00832     {
00833         dbgprint("WSPEnumNetworkEvents: WPUQuerySocketHandleContext() failed: %d",
00834             *lpErrno);
00835         *lpErrno = WSAENOTSOCK;
00836         return SOCKET_ERROR;
00837     }
00838
00839     SetBlockingProvider(SocketContext->Provider);
00840     ret = SocketContext->Provider->NextProcTable.lpWSPEnumNetworkEvents(
00841                 SocketContext->ProviderSocket,
00842                 hEventObject,
00843                 lpNetworkEvents,
00844                 lpErrno);
00845     SetBlockingProvider(NULL);
00846
00847     UnlockSocketContext(SocketContext, lpErrno);
00848
00849     return ret;
00850 }
00851
00852 //
00853 // Function: WSPEventSelect
00854 //
00855 // Description:
00856 //    Register the specified events on the socket with the given event handle.
00857 //    All we need to do is translate the socket handle.
00858 //
00859 int WSPAPI WSPEventSelect(
00860     SOCKET   s,
00861     WSAEVENT hEventObject,
00862     long     lNetworkEvents,
00863     LPINT    lpErrno)
00864 {
00865     SOCK_INFO *SocketContext;
00866     INT        ret;
00867
00868     SocketContext = FindAndLockSocketContext(s, lpErrno);
00869     if (SocketContext == NULL)
00870     {
00871         dbgprint("WSPEventSelect: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
00872         *lpErrno = WSAENOTSOCK;
00873         return SOCKET_ERROR;
00874     }
00875
00876     SetBlockingProvider(SocketContext->Provider);
00877     ret = SocketContext->Provider->NextProcTable.lpWSPEventSelect(
00878                 SocketContext->ProviderSocket,
00879                 hEventObject,
00880                 lNetworkEvents,
00881                 lpErrno);
00882     SetBlockingProvider(NULL);
00883
00884     UnlockSocketContext(SocketContext, lpErrno);
00885
00886     return ret;
00887 }
00888
00889 //
00890 // Function: WSPGetOverlappedResult
00891 //
00892 // Description:
00893 //    This function reports whether the specified overlapped call has
00894 //    completed. If it has, return the requested information. If not,
00895 //    and fWait is true, wait until completion. Otherwise return an
00896 //    error immediately.
00897 //
00898 BOOL WSPAPI WSPGetOverlappedResult (
00899     SOCKET          s,
00900     LPWSAOVERLAPPED lpOverlapped,
00901     LPDWORD         lpcbTransfer,
00902     BOOL            fWait,
00903     LPDWORD         lpdwFlags,
00904     LPINT           lpErrno)
00905 {
00906     DWORD ret;
00907
00908     s;
00909     if (lpOverlapped->Internal != WSS_OPERATION_IN_PROGRESS)
00910     {
00911         // Operation has completed, update the parameters and return
00912         //
00913         *lpcbTransfer = (DWORD)lpOverlapped->InternalHigh;
00914         *lpdwFlags = (DWORD)lpOverlapped->OffsetHigh;
00915         *lpErrno = (INT)lpOverlapped->Offset;
00916
00917         return (lpOverlapped->Offset == 0 ? TRUE : FALSE);
00918     }
00919     else
00920     {
00921         // Operation is still in progress
00922         //
00923         if (fWait)
00924         {
00925             // Wait on the app supplied event handle. Once the operation
00926             //  is completed the IOCP or completion routine will fire.
00927             //  Once that is handled, WPUCompleteOverlappedRequest will
00928             //  be called which will signal the app event.
00929             //
00930             ret = WaitForSingleObject(lpOverlapped->hEvent, INFINITE);
00931             if ( (ret == WAIT_OBJECT_0) &&
00932                  (lpOverlapped->Internal != WSS_OPERATION_IN_PROGRESS) )
00933             {
00934                 *lpcbTransfer = (DWORD)lpOverlapped->InternalHigh;
00935                 *lpdwFlags = (DWORD)lpOverlapped->OffsetHigh;
00936                 *lpErrno = (INT)lpOverlapped->Offset;
00937
00938                 return(lpOverlapped->Offset == 0 ? TRUE : FALSE);
00939             }
00940             else if (lpOverlapped->Internal == WSS_OPERATION_IN_PROGRESS)
00941                 *lpErrno = WSA_IO_PENDING;
00942             else
00943                 *lpErrno = WSASYSCALLFAILURE;
00944         }
00945         else
00946             *lpErrno = WSA_IO_INCOMPLETE;
00947     }
00948     return FALSE;
00949 }
00950
00951 //
00952 // Function: WSPGetPeerName
00953 //
00954 // Description:
00955 //    Returns the address of the peer. The only thing we need to do is translate
00956 //    the socket handle.
00957 //
00958 int WSPAPI WSPGetPeerName(
00959     SOCKET          s,
00960     struct sockaddr FAR * name,
00961     LPINT           namelen,
00962     LPINT           lpErrno)
00963 {
00964     SOCK_INFO *SocketContext;
00965     INT        ret;
00966
00967     SocketContext = FindAndLockSocketContext(s, lpErrno);
00968     if (SocketContext == NULL)
00969     {
00970         dbgprint("WSPGetPeerName: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
00971         *lpErrno = WSAENOTSOCK;
00972         return SOCKET_ERROR;
00973     }
00974
00975     SetBlockingProvider(SocketContext->Provider);
00976     ret = SocketContext->Provider->NextProcTable.lpWSPGetPeerName(
00977                 SocketContext->ProviderSocket,
00978                 name,
00979                 namelen,
00980                 lpErrno);
00981     SetBlockingProvider(NULL);
00982
00983     UnlockSocketContext(SocketContext, lpErrno);
00984
00985     return ret;
00986 }
00987
00988 //
00989 // Function: WSPGetSockName
00990 //
00991 // Description:
00992 //    Returns the local address of a socket. All we need to do is translate
00993 //    the socket handle.
00994 //
00995 int WSPAPI WSPGetSockName(
00996     SOCKET          s,
00997     struct sockaddr FAR * name,
00998     LPINT           namelen,
00999     LPINT           lpErrno)
01000 {
01001     SOCK_INFO *SocketContext;
01002     INT        ret;
01003
01004     SocketContext = FindAndLockSocketContext(s, lpErrno);
01005     if (SocketContext == NULL)
01006     {
01007         dbgprint("WSPGetSockName: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01008         *lpErrno = WSAENOTSOCK;
01009         return SOCKET_ERROR;
01010     }
01011
01012     SetBlockingProvider(SocketContext->Provider);
01013     ret = SocketContext->Provider->NextProcTable.lpWSPGetSockName(
01014                 SocketContext->ProviderSocket,
01015                 name,
01016                 namelen,
01017                 lpErrno);
01018     SetBlockingProvider(NULL);
01019
01020     UnlockSocketContext(SocketContext, lpErrno);
01021
01022     return ret;
01023 }
01024
01025 //
01026 // Function: WSPGetSockOpt
01027 //
01028 // Description:
01029 //    Get the specified socket option. All we need to do is translate the
01030 //    socket handle.
01031 //
01032 int WSPAPI WSPGetSockOpt(
01033     SOCKET     s,
01034     int        level,
01035     int        optname,
01036     char FAR * optval,
01037     LPINT      optlen,
01038     LPINT      lpErrno)
01039 {
01040     SOCK_INFO *SocketContext;
01041     INT        ret=NO_ERROR;
01042
01043     SocketContext = FindAndLockSocketContext(s, lpErrno);
01044     if (SocketContext == NULL)
01045     {
01046         dbgprint("WSPGetSockOpt: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01047         *lpErrno = WSAENOTSOCK;
01048         return SOCKET_ERROR;
01049     }
01050     //
01051     // We need to capture this and return our own WSAPROTOCOL_INFO structure.
01052     // Otherwise, if we translate the handle and pass it to the lower provider
01053     // we'll return the lower provider's protocol info!
01054     //
01055     if ((level == SOL_SOCKET) && ((optname == SO_PROTOCOL_INFO) ||
01056                                   (optname == SO_PROTOCOL_INFOA) ||
01057                                   (optname == SO_PROTOCOL_INFOW) ))
01058     {
01059         if ((optname == SO_PROTOCOL_INFOW) && (*optlen >= sizeof(WSAPROTOCOL_INFOW)))
01060         {
01061             // No conversion necessary, just copy the data
01062             memcpy(optval,
01063                    &SocketContext->Provider->LayeredProvider,
01064                    sizeof(WSAPROTOCOL_INFOW));
01065         }
01066         else if ((optname == SO_PROTOCOL_INFOA) && (*optval >= sizeof(WSAPROTOCOL_INFOA)))
01067         {
01068             // Copy everything but the string
01069             memcpy(optval,
01070                    &SocketContext->Provider->LayeredProvider,
01071                    sizeof(WSAPROTOCOL_INFOW)-WSAPROTOCOL_LEN+1);
01072             // Convert our saved UNICODE string to ASCII
01073             WideCharToMultiByte(CP_ACP,
01074                                 0,
01075                                 SocketContext->Provider->LayeredProvider.szProtocol,
01076                                 -1,
01077                                 ((WSAPROTOCOL_INFOA *)optval)->szProtocol,
01078                                 WSAPROTOCOL_LEN+1,
01079                                 NULL,
01080                                 NULL);
01081         }
01082         else
01083         {
01084             *lpErrno = WSAEFAULT;
01085             ret = SOCKET_ERROR;
01086         }
01087     }
01088     else
01089     {
01090         SetBlockingProvider(SocketContext->Provider);
01091         ret = SocketContext->Provider->NextProcTable.lpWSPGetSockOpt(
01092                     SocketContext->ProviderSocket,
01093                     level,
01094                     optname,
01095                     optval,
01096                     optlen,
01097                     lpErrno);
01098         SetBlockingProvider(NULL);
01099     }
01100
01101     UnlockSocketContext(SocketContext, lpErrno);
01102
01103     return ret;
01104 }
01105
01106 //
01107 // Function: WSPGetQOSByName
01108 //
01109 // Description:
01110 //    Get a QOS template by name. All we need to do is translate the socket
01111 //    handle.
01112 //
01113 BOOL WSPAPI WSPGetQOSByName(
01114     SOCKET   s,
01115     LPWSABUF lpQOSName,
01116     LPQOS    lpQOS,
01117     LPINT    lpErrno)
01118 {
01119     SOCK_INFO *SocketContext;
01120     INT        ret;
01121
01122     SocketContext = FindAndLockSocketContext(s, lpErrno);
01123     if (SocketContext == NULL)
01124     {
01125         dbgprint("WSPGetQOSByName: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01126         *lpErrno = WSAENOTSOCK;
01127         return FALSE;
01128     }
01129
01130     SetBlockingProvider(SocketContext->Provider);
01131     ret = SocketContext->Provider->NextProcTable.lpWSPGetQOSByName(
01132                 SocketContext->ProviderSocket,
01133                 lpQOSName,
01134                 lpQOS,
01135                 lpErrno);
01136     SetBlockingProvider(NULL);
01137
01138     UnlockSocketContext(SocketContext, lpErrno);
01139
01140     return ret;
01141 }
01142
01143 //
01144 // Function: WSPIoctl
01145 //
01146 // Description:
01147 //    Invoke an ioctl. In most cases, we just need to translate the socket
01148 //    handle. However, if the dwIoControlCode is SIO_GET_EXTENSION_FUNCTION_POINTER,
01149 //    we'll need to intercept this and return our own function pointers when
01150 //    they're requesting either TransmitFile or AcceptEx. This is necessary so
01151 //    we can trap these calls. Also for PnP OS's (Win2k) we need to trap calls
01152 //    to SIO_QUERY_TARGET_PNP_HANDLE. For this ioctl we simply have to return
01153 //    the provider socket.
01154 //
01155 int WSPAPI WSPIoctl(
01156     SOCKET          s,
01157     DWORD           dwIoControlCode,
01158     LPVOID          lpvInBuffer,
01159     DWORD           cbInBuffer,
01160     LPVOID          lpvOutBuffer,
01161     DWORD           cbOutBuffer,
01162     LPDWORD         lpcbBytesReturned,
01163     LPWSAOVERLAPPED lpOverlapped,
01164     LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
01165     LPWSATHREADID   lpThreadId,
01166     LPINT           lpErrno)
01167 {
01168     LPWSAOVERLAPPEDPLUS ProviderOverlapped=NULL;
01169     SOCK_INFO          *SocketContext;
01170     GUID                AcceptExGuid = WSAID_ACCEPTEX;
01171     GUID                TransmitFileGuid = WSAID_TRANSMITFILE;
01172     GUID                GetAcceptExSockAddrsGuid = WSAID_GETACCEPTEXSOCKADDRS;
01173     GUID                ConnectExGuid = WSAID_CONNECTEX;
01174     GUID                DisconnectExGuid = WSAID_DISCONNECTEX;
01175     GUID                TransmitPacketsGuid = WSAID_TRANSMITPACKETS;
01176     GUID                WSARecvMsgGuid = WSAID_WSARECVMSG;
01177     int                 ret=NO_ERROR;
01178
01179     SocketContext = FindAndLockSocketContext(s, lpErrno);
01180     if (SocketContext == NULL)
01181     {
01182         dbgprint("WSPIoctl: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01183         *lpErrno = WSAENOTSOCK;
01184         return SOCKET_ERROR;
01185     }
01186
01187     if (dwIoControlCode == SIO_GET_EXTENSION_FUNCTION_POINTER)
01188     {
01189         // Check to see which extension function is being requested.
01190         //
01191         if (memcmp (lpvInBuffer, &TransmitFileGuid, sizeof (GUID)) == 0)
01192         {
01193             // Return a pointer to our intermediate extesion function
01194             //
01195             *((LPFN_TRANSMITFILE *)lpvOutBuffer) = ExtTransmitFile;
01196             //
01197             // Attempt to load the lower provider's extension function
01198             //
01199             if (!SocketContext->Provider->NextProcTableExt.lpfnTransmitFile)
01200             {
01201                 SetBlockingProvider(SocketContext->Provider);
01202                 ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01203                         SocketContext->ProviderSocket,
01204                         SIO_GET_EXTENSION_FUNCTION_POINTER,
01205                         &TransmitFileGuid,
01206                         sizeof(GUID),
01207                         (LPVOID) &SocketContext->Provider->NextProcTableExt.lpfnTransmitFile,
01208                         sizeof(LPFN_TRANSMITFILE),
01209                         lpcbBytesReturned,
01210                         NULL,
01211                         NULL,
01212                         NULL,
01213                         lpErrno);
01214                 SetBlockingProvider(NULL);
01215             }
01216
01217             UnlockSocketContext(SocketContext, lpErrno);
01218
01219             return ret;
01220         }
01221         else if (memcmp(lpvInBuffer, &AcceptExGuid, sizeof(GUID)) == 0)
01222         {
01223             // Return a pointer to our intermediate extension function
01224             //
01225             *((LPFN_ACCEPTEX *)lpvOutBuffer) = ExtAcceptEx;
01226             //
01227             // Attempt to load the lower provider's extension function
01228             //
01229             if (!SocketContext->Provider->NextProcTableExt.lpfnAcceptEx)
01230             {
01231                 SetBlockingProvider(SocketContext->Provider);
01232                 ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01233                         SocketContext->ProviderSocket,
01234                         SIO_GET_EXTENSION_FUNCTION_POINTER,
01235                         &AcceptExGuid,
01236                         sizeof(GUID),
01237                         (LPVOID) &SocketContext->Provider->NextProcTableExt.lpfnAcceptEx,
01238                         sizeof(LPFN_ACCEPTEX),
01239                         lpcbBytesReturned,
01240                         NULL,
01241                         NULL,
01242                         NULL,
01243                         lpErrno);
01244                 SetBlockingProvider(NULL);
01245             }
01246
01247             UnlockSocketContext(SocketContext, lpErrno);
01248
01249             return ret;
01250         }
01251         else if (memcmp (lpvInBuffer, &ConnectExGuid, sizeof(GUID)) == 0)
01252         {
01253             // Return a pointer to our intermediate extension function
01254             //
01255             *((LPFN_CONNECTEX *)lpvOutBuffer) = ExtConnectEx;
01256             //
01257             // Attempt to load the lower provider's extension function
01258             //
01259             if (!SocketContext->Provider->NextProcTableExt.lpfnConnectEx)
01260             {
01261                 SetBlockingProvider(SocketContext->Provider);
01262                 ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01263                         SocketContext->ProviderSocket,
01264                         SIO_GET_EXTENSION_FUNCTION_POINTER,
01265                         &ConnectExGuid,
01266                         sizeof(GUID),
01267                         (LPVOID) &SocketContext->Provider->NextProcTableExt.lpfnConnectEx,
01268                         sizeof(LPFN_CONNECTEX),
01269                         lpcbBytesReturned,
01270                         NULL,
01271                         NULL,
01272                         NULL,
01273                         lpErrno);
01274                 SetBlockingProvider(NULL);
01275             }
01276
01277             UnlockSocketContext(SocketContext, lpErrno);
01278
01279             return ret;
01280         }
01281         else if (memcmp (lpvInBuffer, &DisconnectExGuid, sizeof(GUID)) == 0)
01282         {
01283             // Return a pointer to our intermediate extension function
01284             //
01285             *((LPFN_DISCONNECTEX *)lpvOutBuffer) = ExtDisconnectEx;
01286             //
01287             // Attempt to load the lower provider's extension function
01288             //
01289             if (!SocketContext->Provider->NextProcTableExt.lpfnDisconnectEx)
01290             {
01291                 SetBlockingProvider(SocketContext->Provider);
01292                 ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01293                         SocketContext->ProviderSocket,
01294                         SIO_GET_EXTENSION_FUNCTION_POINTER,
01295                         &DisconnectExGuid,
01296                         sizeof(GUID),
01297                         (LPVOID) &SocketContext->Provider->NextProcTableExt.lpfnDisconnectEx,
01298                         sizeof(LPFN_DISCONNECTEX),
01299                         lpcbBytesReturned,
01300                         NULL,
01301                         NULL,
01302                         NULL,
01303                         lpErrno);
01304                 SetBlockingProvider(NULL);
01305             }
01306
01307             UnlockSocketContext(SocketContext, lpErrno);
01308
01309             return ret;
01310         }
01311         else if (memcmp (lpvInBuffer, &TransmitPacketsGuid, sizeof(GUID)) == 0)
01312         {
01313             // Return a pointer to our intermediate extension function
01314             //
01315             *((LPFN_TRANSMITPACKETS *)lpvOutBuffer) = ExtTransmitPackets;
01316             //
01317             // Attempt to load the lower provider's extension function
01318             //
01319             if (!SocketContext->Provider->NextProcTableExt.lpfnTransmitPackets)
01320             {
01321                 SetBlockingProvider(SocketContext->Provider);
01322                 ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01323                         SocketContext->ProviderSocket,
01324                         SIO_GET_EXTENSION_FUNCTION_POINTER,
01325                         &TransmitPacketsGuid,
01326                         sizeof(GUID),
01327                         (LPVOID) &SocketContext->Provider->NextProcTableExt.lpfnTransmitPackets,
01328                         sizeof(LPFN_TRANSMITPACKETS),
01329                         lpcbBytesReturned,
01330                         NULL,
01331                         NULL,
01332                         NULL,
01333                         lpErrno);
01334                 SetBlockingProvider(NULL);
01335             }
01336
01337             UnlockSocketContext(SocketContext, lpErrno);
01338
01339             return ret;
01340         }
01341         else if (memcmp (lpvInBuffer, &WSARecvMsgGuid, sizeof(GUID)) == 0)
01342         {
01343             // Return a pointer to our intermediate extension function
01344             //
01345             *((LPFN_WSARECVMSG *)lpvOutBuffer) = ExtWSARecvMsg;
01346             //
01347             // Attempt to load the lower provider's extension function
01348             //
01349             if (!SocketContext->Provider->NextProcTableExt.lpfnWSARecvMsg)
01350             {
01351                 SetBlockingProvider(SocketContext->Provider);
01352                 ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01353                         SocketContext->ProviderSocket,
01354                         SIO_GET_EXTENSION_FUNCTION_POINTER,
01355                         &WSARecvMsgGuid,
01356                         sizeof(GUID),
01357                         (LPVOID) &SocketContext->Provider->NextProcTableExt.lpfnWSARecvMsg,
01358                         sizeof(LPFN_WSARECVMSG),
01359                         lpcbBytesReturned,
01360                         NULL,
01361                         NULL,
01362                         NULL,
01363                         lpErrno);
01364                 SetBlockingProvider(NULL);
01365             }
01366
01367             UnlockSocketContext(SocketContext, lpErrno);
01368
01369             return ret;
01370         }
01371         else if (memcmp (lpvInBuffer, &GetAcceptExSockAddrsGuid, sizeof (GUID)) == 0)
01372         {
01373             // No socket handle translation needed, let the call pass through below
01374             // (i.e. we really don't have any need to intercept this call)
01375         }
01376         else
01377         {
01378             UnlockSocketContext(SocketContext, lpErrno);
01379
01380             *lpErrno = WSAEINVAL;
01381             return SOCKET_ERROR;
01382         }
01383     }
01384     else if (dwIoControlCode == SIO_QUERY_TARGET_PNP_HANDLE)
01385     {
01386         DWORD       BytesReturned = 0;
01387
01388         dbgprint("SIO_QUERY_PNP_HANDLE requested");
01389
01390         *((SOCKET *)lpvOutBuffer) = SocketContext->ProviderSocket;
01391         *lpcbBytesReturned = sizeof(SocketContext->ProviderSocket);
01392
01393         if (lpOverlapped)
01394         {
01395             ProviderOverlapped = GetOverlappedStructure(SocketContext);
01396             if (ProviderOverlapped == NULL)
01397             {
01398                 UnlockSocketContext(SocketContext, lpErrno);
01399
01400                 *lpErrno = WSAENOBUFS;
01401                 return SOCKET_ERROR;
01402             }
01403
01404             __try {
01405                 if  (( lpCompletionRoutine == NULL ) && (lpOverlapped->hEvent != NULL ))
01406                 {
01407                     ret = ResetEvent(lpOverlapped->hEvent);
01408                     if (ret == 0)
01409                     {
01410                         // Return to original state and indicate error
01411                         (SocketContext->dwOutstandingAsync)--;
01412                         UnlockSocketContext(SocketContext, lpErrno);
01413                         PutbackOverlappedStructure(ProviderOverlapped);
01414                         *lpErrno = ERROR_INVALID_HANDLE;
01415                         return SOCKET_ERROR;
01416                     }
01417                 }
01418                 CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
01419                 ProviderOverlapped->CallerThreadId = *lpThreadId;
01420                 lpOverlapped->InternalHigh         = BytesReturned = *lpcbBytesReturned;
01421                 lpOverlapped->Internal             = (DWORD_PTR)lpCompletionRoutine;
01422
01423             }
01424             __except(EXCEPTION_EXECUTE_HANDLER)
01425             {
01426                 // Return to original state and indicate error
01427                 (SocketContext->dwOutstandingAsync)--;
01428                 UnlockSocketContext(SocketContext, lpErrno);
01429                 PutbackOverlappedStructure(ProviderOverlapped);
01430                 *lpErrno = WSAEFAULT;
01431                 return SOCKET_ERROR;
01432             }
01433
01434             ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
01435             ProviderOverlapped->SockInfo           = SocketContext;
01436             ProviderOverlapped->CallerSocket       = s;
01437             ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
01438             ProviderOverlapped->Error              = NO_ERROR;
01439             ProviderOverlapped->Operation          = LSP_OP_IOCTL;
01440             ProviderOverlapped->lpCallerCompletionRoutine   = lpCompletionRoutine;
01441             ProviderOverlapped->Provider = SocketContext->Provider;
01442
01443             //
01444             // Call the completion routine immediately since there is nothing
01445             //  else to do. For this ioctl all we do is return the provider
01446             //  socket. If it was called overlapped just complete the operation.
01447             //
01448
01449             dbgprint("SIO_QUERY_PNP_HANDLE overlapped");
01450
01451             IntermediateCompletionRoutine(0,
01452                                           BytesReturned,
01453                                          (WSAOVERLAPPED *)ProviderOverlapped,
01454                                           0);
01455         }
01456         UnlockSocketContext(SocketContext, lpErrno);
01457
01458         return NO_ERROR;
01459     }
01460
01461     //
01462     // Check for overlapped I/O
01463     //
01464     if (lpOverlapped)
01465     {
01466         ProviderOverlapped = GetOverlappedStructure(SocketContext);
01467         if (!ProviderOverlapped)
01468         {
01469             UnlockSocketContext(SocketContext, lpErrno);
01470
01471             *lpErrno = WSAENOBUFS;
01472             return SOCKET_ERROR;
01473         }
01474
01475         __try {
01476             if (( lpCompletionRoutine == NULL ) && ( lpOverlapped->hEvent != NULL ))
01477             {
01478                 ret = ResetEvent(lpOverlapped->hEvent);
01479                 if (ret == 0)
01480                 {
01481                     // Return to original state and indicate error
01482                     (SocketContext->dwOutstandingAsync)--;
01483                     UnlockSocketContext(SocketContext, lpErrno);
01484                     PutbackOverlappedStructure(ProviderOverlapped);
01485                     *lpErrno = ERROR_INVALID_HANDLE;
01486                     return SOCKET_ERROR;
01487                 }
01488             }
01489             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
01490             ProviderOverlapped->CallerThreadId            = *lpThreadId;
01491             ProviderOverlapped->IoctlArgs.cbBytesReturned = (lpcbBytesReturned ? *lpcbBytesReturned : 0);
01492         }
01493         __except(EXCEPTION_EXECUTE_HANDLER)
01494         {
01495             // Return to original state and indicate error
01496             (SocketContext->dwOutstandingAsync)--;
01497             UnlockSocketContext(SocketContext, lpErrno);
01498             PutbackOverlappedStructure(ProviderOverlapped);
01499             *lpErrno = WSAEFAULT;
01500             return SOCKET_ERROR;
01501         }
01502
01503         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
01504         ProviderOverlapped->SockInfo           = SocketContext;
01505         ProviderOverlapped->CallerSocket       = s;
01506         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
01507         ProviderOverlapped->Error              = NO_ERROR;
01508         ProviderOverlapped->Operation          = LSP_OP_IOCTL;
01509         ProviderOverlapped->lpCallerCompletionRoutine   = lpCompletionRoutine;
01510         ProviderOverlapped->IoctlArgs.dwIoControlCode   = dwIoControlCode;
01511         ProviderOverlapped->IoctlArgs.lpvInBuffer       = lpvInBuffer;
01512         ProviderOverlapped->IoctlArgs.cbInBuffer        = cbInBuffer;
01513         ProviderOverlapped->IoctlArgs.lpvOutBuffer      = lpvOutBuffer;
01514         ProviderOverlapped->IoctlArgs.cbOutBuffer       = cbOutBuffer;
01515         ProviderOverlapped->Provider = SocketContext->Provider;
01516
01517         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
01518
01519         if (ret != NO_ERROR)
01520         {
01521             *lpErrno = ret;
01522             ret = SOCKET_ERROR;
01523         }
01524     }
01525     else
01526     {
01527         SetBlockingProvider(SocketContext->Provider);
01528         ret = SocketContext->Provider->NextProcTable.lpWSPIoctl(
01529                 SocketContext->ProviderSocket,
01530                 dwIoControlCode,
01531                 lpvInBuffer,
01532                 cbInBuffer,
01533                 lpvOutBuffer,
01534                 cbOutBuffer,
01535                 lpcbBytesReturned,
01536                 lpOverlapped,
01537                 lpCompletionRoutine,
01538                 lpThreadId,
01539                 lpErrno);
01540         SetBlockingProvider(NULL);
01541     }
01542
01543     UnlockSocketContext(SocketContext, lpErrno);
01544
01545     return ret;
01546 }
01547
01548 //
01549 // Function: WSPJoinLeaf
01550 //
01551 // Description:
01552 //    This function joins a socket to a multipoint session. For those providers
01553 //    that support multipoint semantics there are 2 possible behaviors. First,
01554 //    for IP, WSAJoinLeaf always returns the same socket handle which was passed
01555 //    into it. In this case there is no new socket so we don't want to create
01556 //    any socket context once the lower provider WSPJoinLeaf is called. In the
01557 //    second case, for ATM, a new socket IS created when we call the lower
01558 //    provider. In this case we do want to create a new user socket and create
01559 //    a socket context.
01560 //
01561 SOCKET WSPAPI WSPJoinLeaf(
01562     SOCKET       s,
01563     const struct sockaddr FAR * name,
01564     int          namelen,
01565     LPWSABUF     lpCallerData,
01566     LPWSABUF     lpCalleeData,
01567     LPQOS        lpSQOS,
01568     LPQOS        lpGQOS,
01569     DWORD        dwFlags,
01570     LPINT        lpErrno)
01571 {
01572     SOCK_INFO *SocketContext;
01573     SOCKET     NextProviderSocket = INVALID_SOCKET,
01574                NewSocket = INVALID_SOCKET;
01575
01576     SocketContext = FindAndLockSocketContext(s, lpErrno);
01577     if (SocketContext == NULL)
01578     {
01579         dbgprint("WSPJoinLeaf: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01580         *lpErrno = WSAENOTSOCK;
01581         return INVALID_SOCKET;
01582     }
01583
01584     SetBlockingProvider(SocketContext->Provider);
01585     NextProviderSocket = SocketContext->Provider->NextProcTable.lpWSPJoinLeaf(
01586             SocketContext->ProviderSocket,
01587             name,
01588             namelen,
01589             lpCallerData,
01590             lpCalleeData,
01591             lpSQOS,
01592             lpGQOS,
01593             dwFlags,
01594             lpErrno);
01595     SetBlockingProvider(NULL);
01596     //
01597     // If the socket returned from the lower provider is the same as the socket
01598     //  passed into it then there really isn't a new socket - just return.
01599     //  Otherwise, a new socket has been created and we need to create the socket
01600     //  context and create a user socket to pass back.
01601     //
01602     if (NextProviderSocket == INVALID_SOCKET)
01603     {
01604         NewSocket = INVALID_SOCKET;
01605     }
01606     else if (NextProviderSocket != SocketContext->ProviderSocket)
01607     {
01608         SOCK_INFO   *NewSocketContext;
01609
01610         //
01611         // Create socket context for new socket
01612         //
01613         NewSocketContext = CreateSockInfo(
01614                 SocketContext->Provider,
01615                 NextProviderSocket,
01616                 SocketContext,
01617                 FALSE
01618                 );
01619         if  (NewSocketContext == NULL)
01620         {
01621             *lpErrno = WSAENOBUFS;
01622         }
01623         else
01624         {
01625             //
01626             // Create a socket handle to pass to the app
01627             //
01628             NewSocket = NewSocketContext->LayeredSocket = MainUpCallTable.lpWPUCreateSocketHandle(
01629                     SocketContext->Provider->LayeredProvider.ProtocolChain.ChainEntries[0],
01630                     (DWORD_PTR) NewSocketContext,
01631                     lpErrno
01632                     );
01633             if (NewSocketContext->LayeredSocket == INVALID_SOCKET)
01634             {
01635                 // Close the lower provider's socket
01636                 SocketContext->Provider->NextProcTable.lpWSPCloseSocket(
01637                     NextProviderSocket,
01638                     lpErrno
01639                     );
01640
01641                 // Context is not in the list yet so we can just free it
01642                 FreeSockInfo(NewSocketContext);
01643             }
01644             else
01645             {
01646                 // Need to insert the context
01647                 InsertSocketInfo(SocketContext->Provider, NewSocketContext);
01648             }
01649         }
01650     }
01651     else
01652     {
01653         NewSocket = s;
01654     }
01655
01656     UnlockSocketContext(SocketContext, lpErrno);
01657
01658     return NewSocket;
01659 }
01660
01661 //
01662 // Function: WSPListen
01663 //
01664 // Description:
01665 //    This function sets the backlog value on a listening socket. All we need to
01666 //    do is translate the socket handle to the correct provider.
01667 //
01668 int WSPAPI WSPListen(
01669     SOCKET s,
01670     int    backlog,
01671     LPINT  lpErrno)
01672 {
01673     SOCK_INFO *SocketContext;
01674     INT        ret;
01675
01676     SocketContext = FindAndLockSocketContext(s, lpErrno);
01677     if (SocketContext == NULL)
01678     {
01679         dbgprint("WSPListen: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01680         *lpErrno = WSAENOTSOCK;
01681         return SOCKET_ERROR;
01682     }
01683
01684     SetBlockingProvider(SocketContext->Provider);
01685     ret = SocketContext->Provider->NextProcTable.lpWSPListen(
01686                 SocketContext->ProviderSocket,
01687                 backlog,
01688                 lpErrno);
01689     SetBlockingProvider(NULL);
01690
01691     UnlockSocketContext(SocketContext, lpErrno);
01692
01693     return ret;
01694 }
01695
01696 //
01697 // Function: WSPRecv
01698 //
01699 // Description:
01700 //    This function receives data on a given socket and also allows for asynchronous
01701 //    (overlapped) operation. First translate the socket handle to the lower provider
01702 //    handle and then make the receive call. If called with overlap, post the operation
01703 //    to our IOCP or completion routine.
01704 //
01705 int WSPAPI WSPRecv(
01706     SOCKET          s,
01707     LPWSABUF        lpBuffers,
01708     DWORD           dwBufferCount,
01709     LPDWORD         lpNumberOfBytesRecvd,
01710     LPDWORD         lpFlags,
01711     LPWSAOVERLAPPED lpOverlapped,
01712     LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
01713     LPWSATHREADID   lpThreadId,
01714     LPINT           lpErrno)
01715 {
01716     LPWSAOVERLAPPEDPLUS ProviderOverlapped;
01717     SOCK_INFO          *SocketContext;
01718     int                 ret;
01719
01720     SocketContext = FindAndLockSocketContext(s, lpErrno);
01721     if (SocketContext == NULL)
01722     {
01723         dbgprint("WSPRecv: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01724         *lpErrno = WSAENOTSOCK;
01725         return SOCKET_ERROR;
01726     }
01727     //
01728     // Check for overlapped I/O
01729     //
01730     if (lpOverlapped)
01731     {
01732         ProviderOverlapped = GetOverlappedStructure(SocketContext);
01733         if (!ProviderOverlapped)
01734         {
01735             UnlockSocketContext(SocketContext, lpErrno);
01736             dbgprint("WSPRecv: GetOverlappedStructure() returned NULL");
01737             *lpErrno = WSAENOBUFS;
01738             return SOCKET_ERROR;
01739         }
01740
01741         __try {
01742             if (( lpCompletionRoutine == NULL ) && ( lpOverlapped->hEvent != NULL ))
01743             {
01744                 ret = ResetEvent(lpOverlapped->hEvent);
01745                 if (ret == 0)
01746                 {
01747                     // Return to original state and indicate error
01748                     (SocketContext->dwOutstandingAsync)--;
01749                     UnlockSocketContext(SocketContext, lpErrno);
01750                     PutbackOverlappedStructure(ProviderOverlapped);
01751                     *lpErrno = ERROR_INVALID_HANDLE;
01752                     return SOCKET_ERROR;
01753                 }
01754             }
01755             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
01756             ProviderOverlapped->CallerThreadId                = *lpThreadId;
01757             ProviderOverlapped->RecvArgs.dwNumberOfBytesRecvd = (lpNumberOfBytesRecvd ? *lpNumberOfBytesRecvd : 0);
01758             ProviderOverlapped->RecvArgs.dwFlags              = (lpFlags ? *lpFlags : 0);
01759             ProviderOverlapped->RecvArgs.lpBuffers            = CopyBuffer(lpBuffers, dwBufferCount);
01760         }
01761         __except(EXCEPTION_EXECUTE_HANDLER)
01762         {
01763             // Return to original state and indicate error
01764             (SocketContext->dwOutstandingAsync)--;
01765             UnlockSocketContext(SocketContext, lpErrno);
01766             PutbackOverlappedStructure(ProviderOverlapped);
01767             *lpErrno = WSAEFAULT;
01768             return SOCKET_ERROR;
01769         }
01770
01771         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
01772         ProviderOverlapped->SockInfo           = SocketContext;
01773         ProviderOverlapped->CallerSocket       = s;
01774         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
01775         ProviderOverlapped->Error              = NO_ERROR;
01776         ProviderOverlapped->Operation          = LSP_OP_RECV;
01777         ProviderOverlapped->lpCallerCompletionRoutine = lpCompletionRoutine;
01778         ProviderOverlapped->RecvArgs.dwBufferCount    = dwBufferCount;
01779         ProviderOverlapped->Provider = SocketContext->Provider;
01780
01781         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
01782
01783         if (ret != NO_ERROR)
01784         {
01785             *lpErrno = ret;
01786             ret = SOCKET_ERROR;
01787         }
01788     }
01789     else
01790     {
01791         SetBlockingProvider(SocketContext->Provider);
01792         ret = SocketContext->Provider->NextProcTable.lpWSPRecv(
01793                 SocketContext->ProviderSocket,
01794                 lpBuffers,
01795                 dwBufferCount,
01796                 lpNumberOfBytesRecvd,
01797                 lpFlags,
01798                 lpOverlapped,
01799                 lpCompletionRoutine,
01800                 lpThreadId,
01801                 lpErrno);
01802         SetBlockingProvider(NULL);
01803         if (ret != SOCKET_ERROR)
01804         {
01805             SocketContext->BytesRecv += *lpNumberOfBytesRecvd;
01806         }
01807     }
01808
01809     UnlockSocketContext(SocketContext, lpErrno);
01810
01811     return ret;
01812 }
01813
01814 //
01815 // Function: WSPRecvDisconnect
01816 //
01817 // Description:
01818 //    Receive data and disconnect. All we need to do is translate the socket
01819 //    handle to the lower provider.
01820 //
01821 int WSPAPI WSPRecvDisconnect(
01822     SOCKET   s,
01823     LPWSABUF lpInboundDisconnectData,
01824     LPINT    lpErrno)
01825 {
01826     SOCK_INFO *SocketContext;
01827     INT        ret;
01828
01829     SocketContext = FindAndLockSocketContext(s, lpErrno);
01830     if (SocketContext == NULL)
01831     {
01832         dbgprint("WSPRecvDisconnect: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01833         *lpErrno = WSAENOTSOCK;
01834         return SOCKET_ERROR;
01835     }
01836
01837     SetBlockingProvider(SocketContext->Provider);
01838     ret = SocketContext->Provider->NextProcTable.lpWSPRecvDisconnect(
01839                 SocketContext->ProviderSocket,
01840                 lpInboundDisconnectData,
01841                 lpErrno);
01842     SetBlockingProvider(NULL);
01843
01844     UnlockSocketContext(SocketContext, lpErrno);
01845
01846     return ret;
01847 }
01848
01849 //
01850 // Function: WSPRecvFrom
01851 //
01852 // Description:
01853 //    This function receives data on a given socket and also allows for asynchronous
01854 //    (overlapped) operation. First translate the socket handle to the lower provider
01855 //    handle and then make the receive call. If called with overlap, post the operation
01856 //    to our IOCP or completion routine.
01857 //
01858 int WSPAPI WSPRecvFrom(
01859     SOCKET          s,
01860     LPWSABUF        lpBuffers,
01861     DWORD           dwBufferCount,
01862     LPDWORD         lpNumberOfBytesRecvd,
01863     LPDWORD         lpFlags,
01864     struct sockaddr FAR * lpFrom,
01865     LPINT           lpFromLen,
01866     LPWSAOVERLAPPED lpOverlapped,
01867     LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
01868     LPWSATHREADID   lpThreadId,
01869     LPINT           lpErrno)
01870 {
01871     LPWSAOVERLAPPEDPLUS ProviderOverlapped;
01872     SOCK_INFO          *SocketContext;
01873     int                 ret;
01874
01875     SocketContext = FindAndLockSocketContext(s, lpErrno);
01876     if (SocketContext == NULL)
01877     {
01878         dbgprint("WSPRecvFrom: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
01879         *lpErrno = WSAENOTSOCK;
01880         return SOCKET_ERROR;
01881     }
01882     //
01883     // Check for overlapped I/O
01884     //
01885     if (lpOverlapped)
01886     {
01887         ProviderOverlapped = GetOverlappedStructure(SocketContext);
01888         if (!ProviderOverlapped)
01889         {
01890             UnlockSocketContext(SocketContext, lpErrno);
01891             dbgprint("WSPRecvFrom: GetOverlappedStructure() returned NULL");
01892
01893             *lpErrno = WSAENOBUFS;
01894             return SOCKET_ERROR;
01895         }
01896
01897         __try {
01898             if (( lpCompletionRoutine == NULL ) && ( lpOverlapped->hEvent != NULL ))
01899             {
01900                 ret = ResetEvent(lpOverlapped->hEvent);
01901                 if (ret == 0)
01902                 {
01903                     // Return to original state and indicate error
01904                     (SocketContext->dwOutstandingAsync)--;
01905                     UnlockSocketContext(SocketContext, lpErrno);
01906                     PutbackOverlappedStructure(ProviderOverlapped);
01907                     *lpErrno = ERROR_INVALID_HANDLE;
01908                     return SOCKET_ERROR;
01909                 }
01910             }
01911             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
01912             ProviderOverlapped->CallerThreadId                    = *lpThreadId;
01913             ProviderOverlapped->RecvFromArgs.dwNumberOfBytesRecvd = (lpNumberOfBytesRecvd ? *lpNumberOfBytesRecvd : 0);
01914             ProviderOverlapped->RecvFromArgs.dwFlags              = (lpFlags ? *lpFlags : 0);
01915             ProviderOverlapped->RecvFromArgs.lpBuffers            = CopyBuffer(lpBuffers, dwBufferCount);
01916         }
01917         __except(EXCEPTION_EXECUTE_HANDLER)
01918         {
01919             // Return to original state and indicate error
01920             (SocketContext->dwOutstandingAsync)--;
01921             UnlockSocketContext(SocketContext, lpErrno);
01922             PutbackOverlappedStructure(ProviderOverlapped);
01923             *lpErrno = WSAEFAULT;
01924             return SOCKET_ERROR;
01925         }
01926
01927         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
01928         ProviderOverlapped->SockInfo           = SocketContext;
01929         ProviderOverlapped->CallerSocket       = s;
01930         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
01931         ProviderOverlapped->Error              = NO_ERROR;
01932         ProviderOverlapped->Operation          = LSP_OP_RECVFROM;
01933         ProviderOverlapped->lpCallerCompletionRoutine           = lpCompletionRoutine;
01934         ProviderOverlapped->RecvFromArgs.dwBufferCount          = dwBufferCount;
01935         ProviderOverlapped->RecvFromArgs.lpFrom                 = lpFrom;
01936         ProviderOverlapped->RecvFromArgs.lpFromLen              = lpFromLen;
01937         ProviderOverlapped->Provider = SocketContext->Provider;
01938
01939         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
01940
01941         if (ret != NO_ERROR)
01942         {
01943             *lpErrno = ret;
01944             ret = SOCKET_ERROR;
01945         }
01946     }
01947     else
01948     {
01949         // Make a blocking WSPRecvFrom call
01950         //
01951         SetBlockingProvider(SocketContext->Provider);
01952         ret = SocketContext->Provider->NextProcTable.lpWSPRecvFrom(
01953                 SocketContext->ProviderSocket,
01954                 lpBuffers,
01955                 dwBufferCount,
01956                 lpNumberOfBytesRecvd,
01957                 lpFlags,
01958                 lpFrom,
01959                 lpFromLen,
01960                 lpOverlapped,
01961                 lpCompletionRoutine,
01962                 lpThreadId,
01963                 lpErrno);
01964         SetBlockingProvider(NULL);
01965         if (ret != SOCKET_ERROR)
01966         {
01967             SocketContext->BytesRecv += *lpNumberOfBytesRecvd;
01968         }
01969     }
01970
01971     UnlockSocketContext(SocketContext, lpErrno);
01972
01973     return ret;
01974 }
01975
01976 //
01977 // Function: WSPSelect
01978 //
01979 // Description:
01980 //    This function tests a set of sockets for readability, writeability, and
01981 //    exceptions. We must translate each handle in the fd_set structures to
01982 //    their underlying provider handles before calling the next provider's
01983 //    WSPSelect. The select API is really bad for LSPs in the sense multiple
01984 //    provider's sockets can be passed into this provider's WSPSelect call.
01985 //    If these unknown sockets (unknown since this LSP won't have a socket
01986 //    context structure for it) are passed in the best we can do is pass
01987 //    it down unmodified to the lower layer in the hopes that it knows what it
01988 //    is. In the case where these unknown sockets belong to another LSP (which
01989 //    isn't in our immediate chain) then the lower provider won't know about
01990 //    that socket and will fail the call. Lastly we hold the context lock on
01991 //    all sockets passed in until we're done.
01992 //
01993 int WSPAPI WSPSelect(
01994     int          nfds,
01995     fd_set FAR * readfds,
01996     fd_set FAR * writefds,
01997     fd_set FAR * exceptfds,
01998     const struct timeval FAR * timeout,
01999     LPINT        lpErrno)
02000 {
02001     SOCK_INFO *SocketContext=NULL;
02002     u_int      count,
02003                i;
02004     int        HandleCount,
02005                ret;
02006
02007     struct
02008     {
02009         SOCKET     ClientSocket;
02010         SOCKET     ProvSocket;
02011         SOCK_INFO *Context;
02012     } Read[FD_SETSIZE], Write[FD_SETSIZE], Except[FD_SETSIZE];
02013
02014     fd_set ReadFds, WriteFds, ExceptFds;
02015
02016     if ( !readfds && !writefds && !exceptfds )
02017     {
02018         *lpErrno = WSAEINVAL;
02019         return SOCKET_ERROR;
02020     }
02021     //
02022     // Translate all handles contained in the fd_set structures.
02023     //  For each fd_set go through and build another fd_set which contains
02024     //  their lower provider socket handles.
02025     //
02026     if (readfds)
02027     {
02028         FD_ZERO(&ReadFds);
02029
02030         if (readfds->fd_count > FD_SETSIZE)
02031         {
02032             *lpErrno = WSAENOBUFS;
02033             return SOCKET_ERROR;
02034         }
02035         for (i = 0; i < readfds->fd_count; i++)
02036         {
02037             Read[i].Context = FindAndLockSocketContext(
02038                     (Read[i].ClientSocket = readfds->fd_array[i]),
02039                     lpErrno
02040                     );
02041             if (Read[i].Context == NULL)
02042             {
02043                 // This socket isn't ours -- just pass down in hopes the lower provider
02044                 // knows about it
02045                 Read[i].ProvSocket = readfds->fd_array[i];
02046                 FD_SET(Read[i].ProvSocket, &ReadFds);
02047             }
02048             else
02049             {
02050                 Read[i].ProvSocket = Read[i].Context->ProviderSocket;
02051                 FD_SET(Read[i].ProvSocket, &ReadFds);
02052
02053                 // Save the first valid socket context structure
02054                 if (SocketContext == NULL)
02055                     SocketContext = Read[i].Context;
02056             }
02057         }
02058     }
02059
02060     if (writefds)
02061     {
02062         FD_ZERO(&WriteFds);
02063
02064         if (writefds->fd_count > FD_SETSIZE)
02065         {
02066             *lpErrno = WSAENOBUFS;
02067             return SOCKET_ERROR;
02068         }
02069         for (i = 0; i < writefds->fd_count; i++)
02070         {
02071             Write[i].Context = FindAndLockSocketContext(
02072                     (Write[i].ClientSocket = writefds->fd_array[i]),
02073                     lpErrno
02074                     );
02075             if (Write[i].Context == NULL)
02076             {
02077                 // This socket isn't ours -- just pass down in hopes the lower provider
02078                 // knows about it
02079                 Write[i].ProvSocket = writefds->fd_array[i];
02080                 FD_SET(Write[i].ProvSocket, &WriteFds);
02081             }
02082             else
02083             {
02084                 Write[i].ProvSocket = Write[i].Context->ProviderSocket;
02085                 FD_SET(Write[i].ProvSocket, &WriteFds);
02086
02087                 // Save the first valid socket context structure
02088                 if (SocketContext == NULL)
02089                     SocketContext = Write[i].Context;
02090             }
02091         }
02092     }
02093
02094     if (exceptfds)
02095     {
02096         FD_ZERO(&ExceptFds);
02097
02098         if (exceptfds->fd_count > FD_SETSIZE)
02099         {
02100             *lpErrno = WSAENOBUFS;
02101             return SOCKET_ERROR;
02102         }
02103         for (i = 0; i < exceptfds->fd_count; i++)
02104         {
02105             Except[i].Context = FindAndLockSocketContext(
02106                     (Except[i].ClientSocket = exceptfds->fd_array[i]),
02107                     lpErrno
02108                     );
02109             if (Except[i].Context == NULL)
02110             {
02111                 // This socket isn't ours -- just pass down in hopes the lower provider
02112                 // knows about it
02113                 Except[i].ProvSocket = exceptfds->fd_array[i];
02114                 FD_SET(Except[i].ProvSocket, &ExceptFds);
02115             }
02116             else
02117             {
02118                 Except[i].ProvSocket = Except[i].Context->ProviderSocket;
02119                 FD_SET(Except[i].ProvSocket, &ExceptFds);
02120
02121                 // Save the first valid socket context structure
02122                 if (SocketContext == NULL)
02123                     SocketContext = Write[i].Context;
02124             }
02125         }
02126     }
02127
02128     //
02129     // Now call the lower provider's WSPSelect with the fd_set structures we built
02130     //  containing the lower provider's socket handles.
02131     //
02132     if (SocketContext == NULL)
02133     {
02134         *lpErrno = WSAEINVAL;
02135         return SOCKET_ERROR;
02136     }
02137     SetBlockingProvider(SocketContext->Provider);
02138     ret = SocketContext->Provider->NextProcTable.lpWSPSelect(
02139             nfds,
02140             (readfds ? &ReadFds : NULL),
02141             (writefds ? &WriteFds : NULL),
02142             (exceptfds ? &ExceptFds : NULL),
02143             timeout,
02144             lpErrno);
02145     SetBlockingProvider(NULL);
02146     if (ret != SOCKET_ERROR)
02147     {
02148         // Once we complete we now have to go through the fd_sets we passed and
02149         //  map them BACK to the application socket handles. Fun!
02150         //
02151         HandleCount = ret;
02152
02153         if (readfds)
02154         {
02155             count = readfds->fd_count;
02156             FD_ZERO(readfds);
02157
02158             for(i = 0; (i < count) && HandleCount; i++)
02159             {
02160                 if (MainUpCallTable.lpWPUFDIsSet(Read[i].ProvSocket, &ReadFds))
02161                 {
02162                     FD_SET(Read[i].ClientSocket, readfds);
02163                     HandleCount--;
02164                 }
02165             }
02166             // Release the socket context
02167             for(i=0; i < readfds->fd_count ;i++)
02168             {
02169                 if (Read[i].Context != NULL)
02170                     UnlockSocketContext(Read[i].Context, lpErrno);
02171             }
02172         }
02173
02174         if (writefds)
02175         {
02176             count = writefds->fd_count;
02177             FD_ZERO(writefds);
02178
02179             for(i = 0; (i < count) && HandleCount; i++)
02180             {
02181                 if (MainUpCallTable.lpWPUFDIsSet(Write[i].ProvSocket, &WriteFds))
02182                 {
02183                     FD_SET(Write[i].ClientSocket, writefds);
02184                     HandleCount--;
02185                 }
02186             }
02187             // Release the socket context
02188             for(i=0; i < writefds->fd_count ;i++)
02189             {
02190                 if (Write[i].Context != NULL)
02191                     UnlockSocketContext(Write[i].Context, lpErrno);
02192             }
02193         }
02194
02195         if (exceptfds)
02196         {
02197             count = exceptfds->fd_count;
02198             FD_ZERO(exceptfds);
02199
02200             for(i = 0; (i < count) && HandleCount; i++)
02201             {
02202                 if (MainUpCallTable.lpWPUFDIsSet(Except[i].ProvSocket, &ExceptFds))
02203                 {
02204                     FD_SET(Except[i].ClientSocket, exceptfds);
02205                     HandleCount--;
02206                 }
02207             }
02208             // Release the socket context
02209             for(i=0; i < exceptfds->fd_count ;i++)
02210             {
02211                 if (Except[i].Context != NULL)
02212                     UnlockSocketContext(Except[i].Context, lpErrno);
02213             }
02214         }
02215     }
02216     return ret;
02217 }
02218
02219 //
02220 // Function: WSPSend
02221 //
02222 // Description:
02223 //    This function sends data on a given socket and also allows for asynchronous
02224 //    (overlapped) operation. First translate the socket handle to the lower provider
02225 //    handle and then make the send call. If called with overlap, post the operation
02226 //    to our IOCP or completion routine.
02227 //
02228 int WSPAPI WSPSend(
02229     SOCKET          s,
02230     LPWSABUF        lpBuffers,
02231     DWORD           dwBufferCount,
02232     LPDWORD         lpNumberOfBytesSent,
02233     DWORD           dwFlags,
02234     LPWSAOVERLAPPED lpOverlapped,
02235     LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
02236     LPWSATHREADID   lpThreadId,
02237     LPINT           lpErrno
02238     )
02239 {
02240     INT                 ret;
02241     SOCK_INFO          *SocketContext;
02242     LPWSAOVERLAPPEDPLUS ProviderOverlapped;
02243
02244     SocketContext = FindAndLockSocketContext(s, lpErrno);
02245     if (SocketContext == NULL)
02246     {
02247         dbgprint("WSPSend: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
02248         *lpErrno = WSAENOTSOCK;
02249         return SOCKET_ERROR;
02250     }
02251     //
02252     // Check for overlapped I/O
02253     //
02254     if (lpOverlapped)
02255     {
02256         ProviderOverlapped = GetOverlappedStructure(SocketContext);
02257         if (!ProviderOverlapped)
02258         {
02259             UnlockSocketContext(SocketContext, lpErrno);
02260
02261             dbgprint("WSPSend: GetOverlappedStructure() returned NULL");
02262             *lpErrno = WSAENOBUFS;
02263             return SOCKET_ERROR;
02264         }
02265
02266         __try {
02267             if (( lpCompletionRoutine == NULL ) && ( lpOverlapped->hEvent != NULL ))
02268             {
02269                 ret = ResetEvent(lpOverlapped->hEvent);
02270                 if (ret == 0)
02271                 {
02272                     // Return to original state and indicate error
02273                     (SocketContext->dwOutstandingAsync)--;
02274                     UnlockSocketContext(SocketContext, lpErrno);
02275                     PutbackOverlappedStructure(ProviderOverlapped);
02276                     *lpErrno = ERROR_INVALID_HANDLE;
02277                     return SOCKET_ERROR;
02278                 }
02279             }
02280             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
02281             ProviderOverlapped->CallerThreadId               = *lpThreadId;
02282             ProviderOverlapped->SendArgs.lpBuffers           = CopyBuffer(lpBuffers, dwBufferCount);
02283             ProviderOverlapped->SendArgs.dwNumberOfBytesSent = (lpNumberOfBytesSent ? *lpNumberOfBytesSent : 0);
02284         }
02285         __except(EXCEPTION_EXECUTE_HANDLER)
02286         {
02287             // Return to original state and indicate error
02288             (SocketContext->dwOutstandingAsync)--;
02289             UnlockSocketContext(SocketContext, lpErrno);
02290             PutbackOverlappedStructure(ProviderOverlapped);
02291             *lpErrno = WSAEFAULT;
02292             return SOCKET_ERROR;
02293         }
02294
02295         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
02296         ProviderOverlapped->SockInfo           = SocketContext;
02297         ProviderOverlapped->CallerSocket       = s;
02298         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
02299         ProviderOverlapped->Error              = NO_ERROR;
02300         ProviderOverlapped->Operation          = LSP_OP_SEND;
02301         ProviderOverlapped->lpCallerCompletionRoutine = lpCompletionRoutine;
02302         ProviderOverlapped->SendArgs.dwBufferCount    = dwBufferCount;
02303         ProviderOverlapped->SendArgs.dwFlags          = dwFlags;
02304         ProviderOverlapped->Provider = SocketContext->Provider;
02305
02306         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
02307
02308         if (ret != NO_ERROR)
02309         {
02310             *lpErrno = ret;
02311             ret = SOCKET_ERROR;
02312         }
02313     }
02314     else
02315     {
02316         // Make a blocking send call
02317         //
02318         SetBlockingProvider(SocketContext->Provider);
02319         ret = SocketContext->Provider->NextProcTable.lpWSPSend(
02320                 SocketContext->ProviderSocket,
02321                 lpBuffers,
02322                 dwBufferCount,
02323                 lpNumberOfBytesSent,
02324                 dwFlags,
02325                 lpOverlapped,
02326                 lpCompletionRoutine,
02327                 lpThreadId,
02328                 lpErrno);
02329         SetBlockingProvider(NULL);
02330         if (ret != SOCKET_ERROR)
02331         {
02332             SocketContext->BytesSent += *lpNumberOfBytesSent;
02333         }
02334     }
02335
02336     UnlockSocketContext(SocketContext, lpErrno);
02337
02338     return ret;
02339 }
02340
02341 //
02342 // Function: WSPSendDisconnect
02343 //
02344 // Description:
02345 //    Send data and disconnect. All we need to do is translate the socket
02346 //    handle to the lower provider.
02347 //
02348 int WSPAPI WSPSendDisconnect(
02349     SOCKET   s,
02350     LPWSABUF lpOutboundDisconnectData,
02351     LPINT    lpErrno)
02352 {
02353     SOCK_INFO *SocketContext;
02354     INT        ret;
02355
02356     SocketContext = FindAndLockSocketContext(s, lpErrno);
02357     if (SocketContext == NULL)
02358     {
02359         dbgprint("WSPSendDisconnect: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
02360
02361         *lpErrno = WSAENOTSOCK;
02362         return SOCKET_ERROR;
02363     }
02364
02365     SetBlockingProvider(SocketContext->Provider);
02366     ret = SocketContext->Provider->NextProcTable.lpWSPSendDisconnect(
02367             SocketContext->ProviderSocket,
02368             lpOutboundDisconnectData,
02369             lpErrno);
02370     SetBlockingProvider(NULL);
02371
02372     UnlockSocketContext(SocketContext, lpErrno);
02373
02374     return ret;
02375 }
02376
02377 //
02378 // Function: WSPSendTo
02379 //
02380 // Description:
02381 //    This function sends data on a given socket and also allows for asynchronous
02382 //    (overlapped) operation. First translate the socket handle to the lower provider
02383 //    handle and then make the send call. If called with overlap, post the operation
02384 //    to our IOCP or completion routine.
02385 //
02386 int WSPAPI WSPSendTo(
02387     SOCKET          s,
02388     LPWSABUF        lpBuffers,
02389     DWORD           dwBufferCount,
02390     LPDWORD         lpNumberOfBytesSent,
02391     DWORD           dwFlags,
02392     const struct sockaddr FAR * lpTo,
02393     int             iToLen,
02394     LPWSAOVERLAPPED lpOverlapped,
02395     LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
02396     LPWSATHREADID   lpThreadId,
02397     LPINT           lpErrno)
02398 {
02399     int                 ret;
02400     SOCK_INFO          *SocketContext;
02401     LPWSAOVERLAPPEDPLUS ProviderOverlapped;
02402
02403     // Check for overlapped I/O
02404     //
02405     SocketContext = FindAndLockSocketContext(s, lpErrno);
02406     if (SocketContext == NULL)
02407     {
02408         dbgprint("WSPSendTo: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
02409
02410         *lpErrno = WSAENOTSOCK;
02411         return SOCKET_ERROR;
02412     }
02413     //
02414     // Check for overlapped
02415     //
02416     if (lpOverlapped)
02417     {
02418         ProviderOverlapped = GetOverlappedStructure(SocketContext);
02419         if (!ProviderOverlapped)
02420         {
02421             UnlockSocketContext(SocketContext, lpErrno);
02422             dbgprint("WSPSendto: GetOverlappedStructure() returned NULL");
02423
02424             *lpErrno = WSAENOBUFS;
02425             return SOCKET_ERROR;
02426         }
02427
02428         __try {
02429             if (( lpCompletionRoutine == NULL ) && ( lpOverlapped->hEvent != NULL ))
02430             {
02431                 ret = ResetEvent(lpOverlapped->hEvent);
02432                 if (ret == 0)
02433                 {
02434                     // Return to original state and indicate error
02435                     (SocketContext->dwOutstandingAsync)--;
02436                     UnlockSocketContext(SocketContext, lpErrno);
02437                     PutbackOverlappedStructure(ProviderOverlapped);
02438                     *lpErrno = ERROR_INVALID_HANDLE;
02439                     return SOCKET_ERROR;
02440                 }
02441             }
02442             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
02443             ProviderOverlapped->CallerThreadId                 = *lpThreadId;
02444             ProviderOverlapped->SendToArgs.lpBuffers           = CopyBuffer(lpBuffers, dwBufferCount);
02445             ProviderOverlapped->SendToArgs.dwNumberOfBytesSent = (lpNumberOfBytesSent ? *lpNumberOfBytesSent : 0);
02446             if (iToLen <= sizeof(ProviderOverlapped->SendToArgs.To))
02447                 CopyMemory(&ProviderOverlapped->SendToArgs.To, lpTo, iToLen);
02448         }
02449         __except(EXCEPTION_EXECUTE_HANDLER)
02450         {
02451             // Return to original state and indicate error
02452             (SocketContext->dwOutstandingAsync)--;
02453             UnlockSocketContext(SocketContext, lpErrno);
02454             PutbackOverlappedStructure(ProviderOverlapped);
02455             *lpErrno = WSAEFAULT;
02456             return SOCKET_ERROR;
02457         }
02458
02459         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
02460         ProviderOverlapped->SockInfo           = SocketContext;
02461         ProviderOverlapped->CallerSocket       = s;
02462         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
02463         ProviderOverlapped->Error              = NO_ERROR;
02464         ProviderOverlapped->Operation          = LSP_OP_SENDTO;
02465         ProviderOverlapped->lpCallerCompletionRoutine        = lpCompletionRoutine;
02466         ProviderOverlapped->SendToArgs.dwBufferCount         = dwBufferCount;
02467         ProviderOverlapped->SendToArgs.dwFlags               = dwFlags;
02468         ProviderOverlapped->SendToArgs.iToLen                = iToLen;
02469         ProviderOverlapped->Provider = SocketContext->Provider;
02470
02471         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
02472
02473         if (ret != NO_ERROR)
02474         {
02475             *lpErrno = ret;
02476             ret = SOCKET_ERROR;
02477         }
02478     }
02479     else
02480     {
02481         SetBlockingProvider(SocketContext->Provider);
02482         ret = SocketContext->Provider->NextProcTable.lpWSPSendTo(
02483                 SocketContext->ProviderSocket,
02484                 lpBuffers,
02485                 dwBufferCount,
02486                 lpNumberOfBytesSent,
02487                 dwFlags,
02488                 lpTo,
02489                 iToLen,
02490                 lpOverlapped,
02491                 lpCompletionRoutine,
02492                 lpThreadId,
02493                 lpErrno);
02494         SetBlockingProvider(NULL);
02495         if (ret != SOCKET_ERROR)
02496         {
02497             SocketContext->BytesSent += *lpNumberOfBytesSent;
02498         }
02499     }
02500
02501     UnlockSocketContext(SocketContext, lpErrno);
02502
02503     return ret;
02504 }
02505
02506 //
02507 // Function: WSPSetSockOpt
02508 //
02509 // Description:
02510 //    Set a socket option. For most all options we just have to translate the
02511 //    socket option and call the lower provider. The only special case is for
02512 //    SO_UPDATE_ACCEPT_CONTEXT in which case a socket handle is passed as the
02513 //    argument which we need to translate before calling the lower provider.
02514 //
02515 int WSPAPI WSPSetSockOpt(
02516     SOCKET     s,
02517     int        level,
02518     int        optname,
02519     const char FAR * optval,
02520     int        optlen,
02521     LPINT      lpErrno)
02522 {
02523     SOCK_INFO *SocketContext,
02524               *AcceptContext;
02525     INT        ret;
02526
02527     SocketContext = FindAndLockSocketContext(s, lpErrno);
02528     if (SocketContext == NULL)
02529     {
02530         *lpErrno = WSAENOTSOCK;
02531         return SOCKET_ERROR;
02532     }
02533
02534     if (optname == SO_UPDATE_ACCEPT_CONTEXT)
02535     {
02536         // We need to intercept this (and any other options) that pass
02537         //  a socket handle as an argument so we can replace it with the
02538         //  correct underlying provider's socket handle.
02539         //
02540         AcceptContext = FindAndLockSocketContext( *((SOCKET *)optval), lpErrno);
02541         if (AcceptContext == NULL)
02542         {
02543             dbgprint("WSPSetSockOpt: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
02544             *lpErrno = WSAENOTSOCK;
02545             UnlockSocketContext(SocketContext, lpErrno);
02546             return SOCKET_ERROR;
02547         }
02548
02549         SetBlockingProvider(SocketContext->Provider);
02550         ret = SocketContext->Provider->NextProcTable.lpWSPSetSockOpt(
02551                     SocketContext->ProviderSocket,
02552                     level,
02553                     optname,
02554                     (char *)&AcceptContext->ProviderSocket,
02555                     optlen,
02556                     lpErrno);
02557         SetBlockingProvider(NULL);
02558
02559         UnlockSocketContext(AcceptContext, lpErrno);
02560
02561     }
02562     else
02563     {
02564         SetBlockingProvider(SocketContext->Provider);
02565         ret = SocketContext->Provider->NextProcTable.lpWSPSetSockOpt(
02566                     SocketContext->ProviderSocket,
02567                     level,
02568                     optname,
02569                     optval,
02570                     optlen,
02571                     lpErrno);
02572         SetBlockingProvider(NULL);
02573     }
02574
02575     UnlockSocketContext(SocketContext, lpErrno);
02576
02577     return ret;
02578 }
02579
02580 //
02581 // Function: WSPShutdown
02582 //
02583 // Description:
02584 //    This function performs a shutdown on the socket. All we need to do is
02585 //    translate the socket handle to the lower provider.
02586 //
02587 int WSPAPI WSPShutdown (
02588     SOCKET s,
02589     int    how,
02590     LPINT  lpErrno)
02591 {
02592     SOCK_INFO *SocketContext;
02593     INT        ret;
02594
02595     SocketContext = FindAndLockSocketContext(s, lpErrno);
02596     if (SocketContext == NULL)
02597     {
02598         dbgprint("WSPShutdown: WPUQuerySocketHandleContext() failed: %d", *lpErrno);
02599         *lpErrno = WSAENOTSOCK;
02600         return SOCKET_ERROR;
02601     }
02602
02603     SetBlockingProvider(SocketContext->Provider);
02604     ret = SocketContext->Provider->NextProcTable.lpWSPShutdown(
02605                 SocketContext->ProviderSocket,
02606                 how,
02607                 lpErrno);
02608     SetBlockingProvider(NULL);
02609
02610     UnlockSocketContext(SocketContext, lpErrno);
02611
02612     return ret;
02613 }
02614
02615 //
02616 // Function: WSPStringToAddress
02617 //
02618 // Description:
02619 //    Convert a string to an address (SOCKADDR structure).  We need to translate
02620 //    the socket handle as well as possibly substitute the lpProtocolInfo structure
02621 //    passed to the next provider.
02622 //
02623 int WSPAPI WSPStringToAddress(
02624     LPWSTR              AddressString,
02625     INT                 AddressFamily,
02626     LPWSAPROTOCOL_INFOW lpProtocolInfo,
02627     LPSOCKADDR          lpAddress,
02628     LPINT               lpAddressLength,
02629     LPINT               lpErrno)
02630 {
02631     WSAPROTOCOL_INFOW   *pInfo=NULL;
02632     PROVIDER            *Provider=NULL;
02633     INT                  i, ret;
02634
02635     for(i=0; i < gLayerCount ;i++)
02636     {
02637         if ((gBaseInfo[i].NextProvider.iAddressFamily == lpProtocolInfo->iAddressFamily) &&
02638             (gBaseInfo[i].NextProvider.iSocketType == lpProtocolInfo->iSocketType) &&
02639             (gBaseInfo[i].NextProvider.iProtocol   == lpProtocolInfo->iProtocol))
02640         {
02641             if (lpProtocolInfo)
02642             {
02643                 // In case of multiple providers check the provider flags
02644                 if ( (gBaseInfo[i].NextProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES) !=
02645                      (lpProtocolInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES) )
02646                 {
02647                     continue;
02648                 }
02649             }
02650             Provider = &gBaseInfo[i];
02651             pInfo = &gBaseInfo[i].NextProvider;
02652             break;
02653         }
02654     }
02655     if (Provider == NULL)
02656     {
02657         *lpErrno = WSAEINVAL;
02658         return SOCKET_ERROR;
02659     }
02660     // If we're not immediately above the base then pass the lpProtocolInfo passed
02661     // into us.
02662     //
02663     if (pInfo->ProtocolChain.ChainLen != BASE_PROTOCOL)
02664     {
02665         pInfo = lpProtocolInfo;
02666     }
02667
02668     SetBlockingProvider(Provider);
02669     ret = Provider->NextProcTable.lpWSPStringToAddress(
02670                 AddressString,
02671                 AddressFamily,
02672                 pInfo,
02673                 lpAddress,
02674                 lpAddressLength,
02675                 lpErrno);
02676     SetBlockingProvider(NULL);
02677
02678     return ret;
02679 }
02680
02681 //
02682 // Function: WSPSocket
02683 //
02684 // Description:
02685 //    This function creates a socket. There are two sockets created. The first
02686 //    socket is created by calling the lower providers WSPSocket. This is the
02687 //    handle that we use internally within our LSP. We then create a second
02688 //    socket with WPUCreateSocketHandle which will be returned to the calling
02689 //    application. We will also create a socket context structure which will
02690 //    maintain information on each socket. This context is associated with the
02691 //    socket handle passed to the application.
02692 //
02693 SOCKET WSPAPI WSPSocket(
02694     int                 af,
02695     int                 type,
02696     int                 protocol,
02697     LPWSAPROTOCOL_INFOW lpProtocolInfo,
02698     GROUP               g,
02699     DWORD               dwFlags,
02700     LPINT               lpErrno)
02701 {
02702     SOCKET              NextProviderSocket = INVALID_SOCKET;
02703     SOCKET              NewSocket = INVALID_SOCKET;
02704     SOCK_INFO          *SocketContext;
02705     WSAPROTOCOL_INFOW  *pInfo=NULL, InfoCopy;
02706     PROVIDER           *Provider=NULL;
02707     BOOL                bAddressFamilyOkay=FALSE,
02708                         bSockTypeOkay=FALSE,
02709                         bProtocolOkay=FALSE;
02710     INT                 iAddressFamily,
02711                         iSockType,
02712                         iProtocol,
02713                         i;
02714     static int entrycount=0;
02715
02716     entrycount++;
02717
02718     *lpErrno = NO_ERROR;
02719     //
02720     // If a WSAPROTOCOL_INFO structure was passed in, use those socket/protocol
02721     //  values. Then find the underlying provider's WSAPROTOCOL_INFO structure.
02722     //
02723     iAddressFamily = (lpProtocolInfo ? lpProtocolInfo->iAddressFamily : af);
02724     iProtocol      = (lpProtocolInfo ? lpProtocolInfo->iProtocol   : protocol);
02725     iSockType      = (lpProtocolInfo ? lpProtocolInfo->iSocketType : type);
02726
02727     #ifdef DEBUG
02728     if (lpProtocolInfo)
02729         dbgprint("WSPSocket: [entry %d] Provider: '%S'", entrycount, lpProtocolInfo->szProtocol);
02730     else
02731         dbgprint("WSPSocket: [entry %d] Provider: NULL", entrycount);
02732     #endif
02733
02734     for(i=0; i < gLayerCount ;i++)
02735     {
02736         if ((iAddressFamily == AF_UNSPEC) ||
02737             (iAddressFamily == gBaseInfo[i].NextProvider.iAddressFamily))
02738         {
02739             bAddressFamilyOkay = TRUE;
02740         }
02741         if (iSockType == gBaseInfo[i].NextProvider.iSocketType)
02742         {
02743             bSockTypeOkay = TRUE;
02744         }
02745         if ((iProtocol == 0) || (iProtocol == gBaseInfo[i].NextProvider.iProtocol) ||
02746             (iProtocol == IPPROTO_RAW) || (iSockType == SOCK_RAW))
02747         {
02748             bProtocolOkay = TRUE;
02749         }
02750     }
02751     if (!bAddressFamilyOkay)
02752     {
02753         *lpErrno = WSAEAFNOSUPPORT;
02754         return INVALID_SOCKET;
02755     }
02756     if (!bSockTypeOkay)
02757     {
02758         *lpErrno = WSAESOCKTNOSUPPORT;
02759         return INVALID_SOCKET;
02760     }
02761     if (!bProtocolOkay)
02762     {
02763         *lpErrno = WSAEPROTONOSUPPORT;
02764         return INVALID_SOCKET;
02765     }
02766     // If AF_UNSPEC was passed in we need to go by the socket type and protocol
02767     //  if possible.
02768     //
02769     if ((iAddressFamily == AF_UNSPEC) && (iProtocol == 0))
02770     {
02771         for(i=0; i < gLayerCount ;i++)
02772         {
02773             if (gBaseInfo[i].NextProvider.iSocketType == iSockType)
02774             {
02775                 if (lpProtocolInfo)
02776                 {
02777                     // In case of multiple providers check the provider flags
02778                     if ( (gBaseInfo[i].NextProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES) !=
02779                          (lpProtocolInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES) )
02780                     {
02781                         continue;
02782                     }
02783                 }
02784                 Provider = &gBaseInfo[i];
02785                 pInfo = &gBaseInfo[i].NextProvider;
02786                 if (lpProtocolInfo)
02787                     pInfo->dwProviderReserved = lpProtocolInfo->dwProviderReserved;
02788                 break;
02789             }
02790         }
02791     }
02792     else if ((iAddressFamily == AF_UNSPEC) && (iProtocol != 0))
02793     {
02794         for(i=0; i < gLayerCount ;i++)
02795         {
02796             if ((gBaseInfo[i].NextProvider.iProtocol == iProtocol) &&
02797                 (gBaseInfo[i].NextProvider.iSocketType == iSockType) )
02798             {
02799                 if (lpProtocolInfo)
02800                 {
02801                     // In case of multiple providers check the provider flags
02802                     if ( (gBaseInfo[i].NextProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES) !=
02803                          (lpProtocolInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES) )
02804                     {
02805                         continue;
02806                     }
02807                 }
02808                 Provider = &gBaseInfo[i];
02809                 pInfo = &gBaseInfo[i].NextProvider;
02810                 if (lpProtocolInfo)
02811                     pInfo->dwProviderReserved = lpProtocolInfo->dwProviderReserved;
02812                 break;
02813             }
02814         }
02815         if (pInfo == NULL)
02816         {
02817             *lpErrno = WSAEPROTOTYPE;
02818             return INVALID_SOCKET;
02819         }
02820     }
02821     else if ((iProtocol != 0) && (iProtocol != IPPROTO_RAW) && (iSockType != SOCK_RAW))
02822     {
02823         for(i=0; i < gLayerCount ;i++)
02824         {
02825             if ((gBaseInfo[i].NextProvider.iAddressFamily == iAddressFamily) &&
02826                 (gBaseInfo[i].NextProvider.iSocketType == iSockType) &&
02827                 (gBaseInfo[i].NextProvider.iProtocol == iProtocol))
02828             {
02829                 if (lpProtocolInfo)
02830                 {
02831                     // In case of multiple providers check the provider flags
02832                     if ( (gBaseInfo[i].NextProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES) !=
02833                          (lpProtocolInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES) )
02834                     {
02835                         continue;
02836                     }
02837                 }
02838                 Provider = &gBaseInfo[i];
02839                 pInfo = &gBaseInfo[i].NextProvider;
02840                 if (lpProtocolInfo)
02841                     pInfo->dwProviderReserved = lpProtocolInfo->dwProviderReserved;
02842                 break;
02843             }
02844         }
02845     }
02846     else
02847     {
02848         for(i=0; i < gLayerCount ;i++)
02849         {
02850             if ((gBaseInfo[i].NextProvider.iAddressFamily == iAddressFamily) &&
02851                 (gBaseInfo[i].NextProvider.iSocketType == iSockType) )
02852             {
02853                 if (lpProtocolInfo)
02854                 {
02855                     // In case of multiple providers check the provider flags
02856                     if ( (gBaseInfo[i].NextProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES) !=
02857                          (lpProtocolInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES) )
02858                     {
02859                         continue;
02860                     }
02861                 }
02862                 Provider = &gBaseInfo[i];
02863                 pInfo = &gBaseInfo[i].NextProvider;
02864                 if (lpProtocolInfo)
02865                     pInfo->dwProviderReserved = lpProtocolInfo->dwProviderReserved;
02866                 break;
02867             }
02868         }
02869     }
02870     if (!Provider)
02871     {
02872         *lpErrno = WSAEAFNOSUPPORT;
02873         return INVALID_SOCKET;
02874     }
02875
02876     if (pInfo->ProtocolChain.ChainLen != BASE_PROTOCOL)
02877     {
02878         pInfo = lpProtocolInfo;
02879     }
02880
02881     memcpy(&InfoCopy, pInfo, sizeof(InfoCopy));
02882
02883     if (lpProtocolInfo)
02884         InfoCopy.dwProviderReserved = lpProtocolInfo->dwProviderReserved;
02885
02886     //
02887     // Create the underlying provider's socket.
02888     //
02889
02890     #ifdef DEBUGSPEW
02891     dbgprint("Calling the lower provider WSPSocket: '%S'", Provider->NextProvider.szProtocol);
02892     #endif
02893
02894     SetBlockingProvider(Provider);
02895     NextProviderSocket = Provider->NextProcTable.lpWSPSocket(
02896                             af,
02897                             type,
02898                             protocol,
02899                             &InfoCopy, //pInfo,
02900                             g,
02901                             dwFlags,
02902                             lpErrno);
02903     SetBlockingProvider(NULL);
02904
02905     if (NextProviderSocket != INVALID_SOCKET)
02906     {
02907         // Create the context information to be associated with this socket
02908         //
02909         if ((SocketContext = CreateSockInfo(Provider,
02910                                             NextProviderSocket,
02911                                             NULL)) == NULL)
02912         {
02913             *lpErrno = WSAENOBUFS;
02914         }
02915         else
02916         {
02917             // Create a socket handle to pass back to app
02918             //
02919             NewSocket = MainUpCallTable.lpWPUCreateSocketHandle(
02920                         Provider->LayeredProvider.ProtocolChain.ChainEntries[0],
02921                         (DWORD_PTR) SocketContext,
02922                         lpErrno);
02923             if (NewSocket == INVALID_SOCKET)
02924             {
02925                 dbgprint("WSPSocket: WPUCreateSocketHandle() failed: %d", *lpErrno);
02926
02927                 Provider->NextProcTable.lpWSPCloseSocket(NextProviderSocket, lpErrno);
02928
02929                 // Need to remove socket from list as it was already inserted above
02930                 RemoveSocketInfo(Provider, SocketContext);
02931                 FreeSockInfo(SocketContext);
02932
02933                 return INVALID_SOCKET;
02934             }
02935
02936             #ifdef DEBUG
02937             dbgprint("Lower provider socket = 0x%x  LSP Socket = 0x%x\n", NextProviderSocket, NewSocket);
02938             #endif
02939
02940             SocketContext->LayeredSocket = NewSocket;
02941
02942             pInfo->dwProviderReserved = 0;
02943         }
02944
02945         return NewSocket;
02946     }
02947     else
02948     {
02949         dbgprint("WSPSocket: NextProcTable.WSPSocket() failed: %d", *lpErrno);
02950     }
02951
02952     return INVALID_SOCKET;
02953 }
02954
02955 //
02956 // Function: WSPStartup
02957 //
02958 // Description:
02959 //    This function intializes our LSP. We maintain a ref count to keep track
02960 //    of how many times this function has been called. On the first call we'll
02961 //    look at the Winsock catalog to find our catalog ID and find which entries
02962 //    we are layered over. We'll create a number of structures to keep this
02963 //    information handy.
02964 //
02965 //    NOTE: There are two basic methods of finding an LSPs position in the chain.
02966 //          First, it may look at the protocol chain of the lpProtocolInfo passed
02967 //          in. If it does this an LSP SHOULD find its position by matching ANY
02968 //          of the provider IDs beloging to the LSP. This includes the ID of the
02969 //          dummy entry as well as the IDs of any of the layered providers belonging
02970 //          to the LSP!
02971 //
02972 //          The second option is to enumerate the Winsock catalog and find find
02973 //          all the entries belonging to this LSP. Then from the layered provider
02974 //          entries, take position 1 in the protocol chain to find out who is next
02975 //          in your layer and load them.
02976 //
02977 //          This LSP takes the second approach -- mainly because if another LSP
02978 //          layers on top of us and dorks up their protocol chain, if this LSP is
02979 //          called it can reliably load the lower provider (unless the bad LSP
02980 //          modified our LSPs entries and goofed up our chains as well).
02981 //
02982 int WSPAPI WSPStartup(
02983     WORD                wVersion,
02984     LPWSPDATA           lpWSPData,
02985     LPWSAPROTOCOL_INFOW lpProtocolInfo,
02986     WSPUPCALLTABLE      UpCallTable,
02987     LPWSPPROC_TABLE     lpProcTable)
02988 {
02989     LPWSAPROTOCOL_INFOW ProtocolInfo,
02990                         pInfo;
02991     UINT                iBaseId;
02992     INT                 ret = NO_ERROR,
02993                         TotalProtocols,
02994                         Error,
02995                         idx,
02996                         i, x, z;
02997
02998     EnterCriticalSection(&gCriticalSection);
02999
03000     MainUpCallTable = UpCallTable;
03001
03002     ret = NO_ERROR;
03003
03004     ProtocolInfo = pInfo = NULL;
03005
03006     //
03007     // Load Next Provider in chain if this is the first time called
03008     //
03009     if (gEntryCount == 0)
03010     {
03011
03012         // Create an event which is signaled when a socket context is added
03013         gAddContextEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
03014         if (gAddContextEvent == NULL)
03015         {
03016             dbgprint("WSPStartup: CreateEvent failed: %d", GetLastError());
03017             ret = WSAENOBUFS;
03018             goto cleanup;
03019         }
03020
03021         //
03022         // Remap service provider functions here
03023         //
03024         gProcTable.lpWSPAccept = WSPAccept;
03025         gProcTable.lpWSPAddressToString = WSPAddressToString;
03026         gProcTable.lpWSPAsyncSelect = WSPAsyncSelect;
03027         gProcTable.lpWSPBind = WSPBind;
03028         gProcTable.lpWSPCancelBlockingCall = WSPCancelBlockingCall;
03029         gProcTable.lpWSPCleanup = WSPCleanup;
03030         gProcTable.lpWSPCloseSocket = WSPCloseSocket;
03031         gProcTable.lpWSPConnect = WSPConnect;
03032         gProcTable.lpWSPDuplicateSocket = WSPDuplicateSocket;
03033         gProcTable.lpWSPEnumNetworkEvents = WSPEnumNetworkEvents;
03034         gProcTable.lpWSPEventSelect = WSPEventSelect;
03035         gProcTable.lpWSPGetOverlappedResult = WSPGetOverlappedResult;
03036         gProcTable.lpWSPGetPeerName = WSPGetPeerName;
03037         gProcTable.lpWSPGetSockOpt = WSPGetSockOpt;
03038         gProcTable.lpWSPGetSockName = WSPGetSockName;
03039         gProcTable.lpWSPGetQOSByName = WSPGetQOSByName;
03040         gProcTable.lpWSPIoctl = WSPIoctl;
03041         gProcTable.lpWSPJoinLeaf = WSPJoinLeaf;
03042         gProcTable.lpWSPListen = WSPListen;
03043         gProcTable.lpWSPRecv = WSPRecv;
03044         gProcTable.lpWSPRecvDisconnect = WSPRecvDisconnect;
03045         gProcTable.lpWSPRecvFrom = WSPRecvFrom;
03046         gProcTable.lpWSPSelect = WSPSelect;
03047         gProcTable.lpWSPSend = WSPSend;
03048         gProcTable.lpWSPSendDisconnect = WSPSendDisconnect;
03049         gProcTable.lpWSPSendTo = WSPSendTo;
03050         gProcTable.lpWSPSetSockOpt = WSPSetSockOpt;
03051         gProcTable.lpWSPShutdown = WSPShutdown;
03052         gProcTable.lpWSPSocket = WSPSocket;
03053         gProcTable.lpWSPStringToAddress = WSPStringToAddress;
03054         //
03055         // Save off the WSP data structures for use later
03056         //
03057         memset(&gWSPData, 0, sizeof(WSPDATA));
03058         gWSPData.wVersion = 0x202;
03059         gWSPData.wHighVersion = 0x202;
03060
03061         //
03062         // Create our private heap
03063         //
03064         hLspHeap = HeapCreate(0, 128000, 0);
03065         if (hLspHeap == NULL)
03066         {
03067             dbgprint("WSPStartup: HeapCreate() failed: %d", GetLastError());
03068             ret = WSAEPROVIDERFAILEDINIT;
03069             goto cleanup;
03070         }
03071
03072         //
03073         //  Get all protocol information in database
03074         //
03075         if ((ProtocolInfo = EnumerateProviders(LspCatalogBoth, &TotalProtocols)) == NULL)
03076         {
03077             dbgprint("GetProviders failed");
03078             ret = WSAEPROVIDERFAILEDINIT;
03079             goto cleanup;
03080         }
03081         // Find out what our layered protocol catalog ID entry is
03082         //
03083         for (i = 0; i < TotalProtocols; i++)
03084         {
03085             if (memcmp (&ProtocolInfo[i].ProviderId, &ProviderGuid, sizeof (GUID))==0)
03086             {
03087                 gLayerCatId = ProtocolInfo[i].dwCatalogEntryId;
03088                 break;
03089             }
03090         }
03091         //
03092         // Find out how many protocol entries we're layered over
03093         //
03094         gLayerCount=0;
03095         for(x=0; x < TotalProtocols ;x++)
03096         {
03097             if ((ProtocolInfo[x].ProtocolChain.ChainLen > 1) &&
03098                 (gLayerCatId == ProtocolInfo[x].ProtocolChain.ChainEntries[0]))
03099             {
03100                 gLayerCount++;
03101             }
03102         }
03103
03104         #ifdef DEBUG
03105         dbgprint("Layered over %d protocols", gLayerCount);
03106         #endif
03107
03108         //
03109         // Allocate some space to save off the WSAPROTOCOL_INFO structures of the
03110         //  underlying providers. We'll need these throughout execution.
03111         //
03112         gBaseInfo = (LPPROVIDER)HeapAlloc(hLspHeap,
03113                                           HEAP_ZERO_MEMORY,
03114                                           sizeof(PROVIDER)*gLayerCount);
03115         if (!gBaseInfo)
03116         {
03117             dbgprint("WSPStartup: HeapAlloc() failed on gBaseInfo: %d", GetLastError());
03118             ret = WSAENOBUFS;
03119             goto cleanup;
03120         }
03121         for(i=0; i < gLayerCount ;i++)
03122         {
03123             InitializeCriticalSection(&gBaseInfo[i].ProviderCritSec);
03124         }
03125         //
03126         // Now copy the WSAPROTOCOL_INFO structures into our storage space
03127         //
03128         idx=0;
03129         for(x=0; x < TotalProtocols ;x++)
03130         {
03131             if ( (ProtocolInfo[x].ProtocolChain.ChainLen > 1) &&
03132                  (gLayerCatId == ProtocolInfo[x].ProtocolChain.ChainEntries[0]))
03133             {
03134                 memcpy(&gBaseInfo[idx].LayeredProvider,
03135                        &ProtocolInfo[x],
03136                        sizeof(WSAPROTOCOL_INFOW));
03137
03138                 #ifdef DEBUG
03139                 dbgprint("Layer is %S", gBaseInfo[idx].LayeredProvider.szProtocol);
03140                 #endif
03141
03142                 //
03143                 // Our LSP exists in this entries chain so grab the entry
03144                 //  after ours (i.e. the next provider in the chain)
03145                 //
03146                 iBaseId = ProtocolInfo[x].ProtocolChain.ChainEntries[1];
03147                 for(z=0; z < TotalProtocols ;z++)
03148                 {
03149                     if (ProtocolInfo[z].dwCatalogEntryId == iBaseId)
03150                     {
03151
03152                         if (ProtocolInfo[z].ProtocolChain.ChainLen == LAYERED_PROTOCOL)
03153                         {
03154                             BOOL bFound = FALSE;
03155
03156                             // Slight problem, the chain indicates an LSP's dummy
03157                             // entry and not a layered entry belonging to that LSP.
03158                             // See if we can find an appropriate provider entry
03159                             for(i=0; i < TotalProtocols ;i++)
03160                             {
03161                                 if ((ProtocolInfo[i].ProtocolChain.ChainEntries[0] == iBaseId) &&
03162                                     (ProtocolInfo[i].iAddressFamily == ProtocolInfo[x].iAddressFamily) &&
03163                                     (ProtocolInfo[i].iSocketType == ProtocolInfo[x].iSocketType) &&
03164                                     (ProtocolInfo[i].iProtocol == ProtocolInfo[x].iProtocol)
03165                                     )
03166                                 {
03167                                     bFound = TRUE;
03168                                     memcpy(&gBaseInfo[idx++].NextProvider,
03169                                            &ProtocolInfo[i],
03170                                             sizeof(WSAPROTOCOL_INFOW));
03171                                 }
03172                             }
03173
03174                             if (bFound == FALSE)
03175                             {
03176                                 // Didn't find it so just use the dummy and hope for
03177                                 // the best...
03178                                 memcpy(&gBaseInfo[idx++].NextProvider,
03179                                        &ProtocolInfo[z],
03180                                         sizeof(WSAPROTOCOL_INFOW));
03181                             }
03182                         }
03183                         else
03184                         {
03185                             memcpy(&gBaseInfo[idx++].NextProvider,
03186                                    &ProtocolInfo[z],
03187                                     sizeof(WSAPROTOCOL_INFOW));
03188                         }
03189                         break;
03190                     }
03191                 }
03192             }
03193         }
03194         for(x=0; x < gLayerCount ;x++)
03195         {
03196             gBaseInfo[x].ProviderPathLen = MAX_PATH-1;
03197             if (WSCGetProviderPath(&gBaseInfo[x].NextProvider.ProviderId,
03198                                     gBaseInfo[x].ProviderPathW,
03199                                    &gBaseInfo[x].ProviderPathLen,
03200                                    &Error) == SOCKET_ERROR)
03201             {
03202                 dbgprint("WSPStartup: WSCGetProviderPath failed: %d", Error);
03203                 ret = WSAEPROVIDERFAILEDINIT;
03204                 goto cleanup;
03205             }
03206
03207             if (ExpandEnvironmentStringsW(gBaseInfo[x].ProviderPathW,
03208                                           gBaseInfo[x].LibraryPathW,
03209                                           MAX_PATH-1))
03210             {
03211                 if ((gBaseInfo[x].hProvider = LoadLibraryW(gBaseInfo[x].LibraryPathW)) == NULL)
03212                 {
03213                     dbgprint("WSPStartup: LoadLibraryW failed: %d", GetLastError());
03214                     ret = WSAEPROVIDERFAILEDINIT;
03215                     goto cleanup;
03216                 }
03217
03218                 #ifdef DEBUG
03219                 dbgprint("LoadLibrary on: %S", gBaseInfo[x].LibraryPathW);
03220                 #endif
03221             }
03222             else
03223             {
03224                 // We must be on Win9x
03225                 //
03226                 if (WideCharToMultiByte(
03227                     CP_ACP,
03228                     0,
03229                     gBaseInfo[x].ProviderPathW,
03230                     gBaseInfo[x].ProviderPathLen,
03231                     gBaseInfo[x].ProviderPathA,
03232                     gBaseInfo[x].ProviderPathLen,
03233                     NULL,
03234                     NULL) != 0)
03235                 {
03236                     // Expand any environment variables within the ANSI string if needed
03237                     if (ExpandEnvironmentStringsA(gBaseInfo[x].ProviderPathA,
03238                                                    gBaseInfo[x].LibraryPathA,
03239                                                    MAX_PATH-1))
03240                     {
03241                         if ((gBaseInfo[x].hProvider = LoadLibraryA(gBaseInfo[x].ProviderPathA)) == NULL)
03242                         {
03243                             dbgprint("LoadLibrary failed: %d", GetLastError());
03244                             ret = WSAEPROVIDERFAILEDINIT;
03245                             goto cleanup;
03246                         }
03247                     }
03248                     else
03249                     {
03250                         dbgprint("ExpandEnvironmentStrings failed: %d", GetLastError());
03251                         ret = WSAEPROVIDERFAILEDINIT;
03252                         goto cleanup;
03253                     }
03254                 }
03255                 else
03256                 {
03257                     dbgprint("WideCharToMultiByte failed: %d", GetLastError());
03258                     ret = WSAEPROVIDERFAILEDINIT;
03259                     goto cleanup;
03260                 }
03261             }
03262             //
03263             // Call the WSPStartup function on the lower provider's DLL
03264             //
03265             if ((gBaseInfo[x].lpWSPStartup = (LPWSPSTARTUP)
03266                 GetProcAddress(gBaseInfo[x].hProvider, "WSPStartup")) == NULL)
03267             {
03268                 dbgprint("GetProcAddress failed!");
03269                 ret = WSAEPROVIDERFAILEDINIT;
03270                 goto cleanup;
03271             }
03272             pInfo = lpProtocolInfo;
03273             if (gBaseInfo[x].NextProvider.ProtocolChain.ChainLen == BASE_PROTOCOL)
03274             {
03275                 pInfo = &gBaseInfo[x].NextProvider;
03276             }
03277
03278             ret = gBaseInfo[x].lpWSPStartup(wVersion,
03279                                             lpWSPData,
03280                                             pInfo,
03281                                             UpCallTable,
03282                                             &gBaseInfo[x].NextProcTable);
03283             if (ret != 0)
03284             {
03285                 dbgprint("%s->WSPStartup() failed: %d", gBaseInfo[x].NextProvider.szProtocol, ret);
03286                 ret =  WSAEPROVIDERFAILEDINIT;
03287                 goto cleanup;
03288             }
03289             else
03290             {
03291                 ret = NO_ERROR;
03292             }
03293             #ifdef DEBUG
03294             dbgprint("NextProcTable.WSPStartup = 0x%X [%S]", gBaseInfo[x].lpWSPStartup, gBaseInfo[x].NextProvider.szProtocol);
03295             #endif
03296
03297             if (VerifyProcTable(&gBaseInfo[x].NextProcTable) == SOCKET_ERROR)
03298             {
03299                 dbgprint("Provider '%S' returned bad proc table!", &gBaseInfo[x].NextProvider.szProtocol);
03300                 ret = WSAEPROVIDERFAILEDINIT;
03301                 goto cleanup;
03302             }
03303         }
03304         InitOverlappedManager();
03305
03306         FreeProviders(ProtocolInfo);
03307         ProtocolInfo = NULL;
03308
03309         //
03310         // Keep track of how many times we've been loaded
03311         //
03312         gEntryCount++;
03313     }
03314     else
03315     {
03316         //
03317         // Keep track of how many times we've been loaded
03318         //
03319         gEntryCount++;
03320     }
03321     //
03322     // Copy the LSP's proc table to the caller's data structures
03323     //
03324     memcpy(lpWSPData, &gWSPData, sizeof(WSPDATA));
03325     memcpy(lpProcTable, &gProcTable, sizeof(WSPPROC_TABLE));
03326
03327     #ifdef DEBUG
03328     dbgprint("WSPStartup: %d", gEntryCount);
03329     #endif
03330
03331 cleanup:
03332
03333     if (ProtocolInfo)
03334         FreeProviders(ProtocolInfo);
03335
03336     if (ret != NO_ERROR)
03337     {
03338         // Had errors during initialization and gEntryCount is still zero so
03339         // cleanup the internal structures
03340         FreeSocketsAndMemory(&Error);
03341     }
03342
03343     LeaveCriticalSection(&gCriticalSection);
03344
03345     return ret;
03346 }
03347
03348 //
03349 // Function: CopyOffset
03350 //
03351 // Description:
03352 //    Any offset information passed by the application in its OVERLAPPED structure
03353 //    needs to be copied down to the OVERLAPPED structure the LSP passes to the
03354 //    lower layer. This function copies the offset fields.
03355 //
03356 void CopyOffset(WSAOVERLAPPED *ProviderOverlapped, WSAOVERLAPPED *UserOverlapped)
03357 {
03358     ProviderOverlapped->Offset     = UserOverlapped->Offset;
03359     ProviderOverlapped->OffsetHigh = UserOverlapped->OffsetHigh;
03360 }
03361
03362 //
03363 // Function: CopyBuffer
03364 //
03365 // Description:
03366 //    Overlapped send/recv functions pass an array of WSABUF structures to specify
03367 //    the send/recv buffers and their lengths. The Winsock spec says that providers
03368 //    must capture all the WSABUF structures and cannot rely on them being persistent.
03369 //    If we're on NT then we don't have to copy as we immediately call the lower
03370 //    provider's function (and the lower provider captures the WSABUF array). However
03371 //    if the LSP is modified to look at the buffers after the operaiton is queued,
03372 //    then this routine must ALWAYS copy the WSABUF array.  For Win9x since the
03373 //    overlapped operation doesn't immediately execute we have to copy the array.
03374 //
03375 WSABUF *CopyBuffer(WSABUF *BufferArray, DWORD BufferCount)
03376 {
03377     WSABUF      *buffercopy=NULL;
03378     DWORD        i;
03379
03380     if (ghIocp == NULL)
03381     {
03382         // We're on Win9x -- we need to save off the WSABUF structures
03383         // because on Win9x, the overlapped operation does not execute
03384         // immediately and the Winsock spec says apps are free to use
03385         // stack based WSABUF arrays.
03386
03387         buffercopy = (WSABUF *)HeapAlloc(hLspHeap, HEAP_ZERO_MEMORY, sizeof(WSABUF) * BufferCount);
03388         if (buffercopy == NULL)
03389         {
03390             wsprintf(Msg, TEXT("CopyBuffer: HeapAlloc failed: %d\r\n"), GetLastError());
03391             return NULL;
03392         }
03393         for(i=0; i < BufferCount ;i++)
03394         {
03395             buffercopy[i].buf = BufferArray[i].buf;
03396             buffercopy[i].len = BufferArray[i].len;
03397         }
03398         return buffercopy;
03399     }
03400     else
03401     {
03402         // With completion ports, we post the overlapped operation
03403         // immediately to the lower provider which should capture
03404         // the WSABUF array members itself. If your LSP needs to
03405         // look at the buffers after the operation is initiated,
03406         // you'd better always copy the WSABUF array.
03407
03408         return BufferArray;
03409     }
03410 }
03411
03412 //
03413 // Function: FreeBuffer
03414 //
03415 // Description:
03416 //    Read the description for CopyBuffer first! This routine frees the allocated
03417 //    array of WSABUF structures. Normally, the array is copied only on Win9x
03418 //    systems. If your LSP needs to look at the buffers after the overlapped operation
03419 //    is issued, you must always copy the buffers (therefore you must always delete
03420 //    them when done).
03421 //
03422 void FreeBuffer(WSABUF *BufferArray)
03423 {
03424     if (ghIocp == NULL)
03425     {
03426         // If we're on Win9x, the WSABUF array was copied so free it up now
03427
03428         HeapFree(hLspHeap, 0, BufferArray);
03429     }
03430 }
03431
03432 //
03433 // Function: FreeSocketsAndMemory
03434 //
03435 // Description:
03436 //    Go through each provider and close all open sockets. Then call each
03437 //    underlying provider's WSPCleanup and free the reference to its DLL.
03438 //
03439 void FreeSocketsAndMemory(int *lpErrno)
03440 {
03441     int     ret,
03442             i;
03443
03444     for(i=0; i < gLayerCount ;i++)
03445     {
03446         if (gBaseInfo[i].hProvider != NULL)
03447         {
03448             CloseAndFreeSocketInfo(&gBaseInfo[i]);
03449             gBaseInfo[i].SocketList = NULL;
03450
03451             //
03452             // Call the WSPCleanup of the provider's were layered over.
03453             //
03454             ret = gBaseInfo[i].NextProcTable.lpWSPCleanup(lpErrno);
03455
03456             DeleteCriticalSection(&gBaseInfo[i].ProviderCritSec);
03457
03458             FreeLibrary(gBaseInfo[i].hProvider);
03459             gBaseInfo[i].hProvider = NULL;
03460         }
03461     }
03462     if (gBaseInfo != NULL)
03463     {
03464         HeapFree(hLspHeap, 0, gBaseInfo);
03465         gBaseInfo = NULL;
03466     }
03467
03468     if (gAddContextEvent != NULL)
03469     {
03470         CloseHandle(gAddContextEvent);
03471         gAddContextEvent = NULL;
03472     }
03473
03474     if (hLspHeap != NULL)
03475     {
03476         HeapDestroy(hLspHeap);
03477         hLspHeap = NULL;
03478     }
03479 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/_Collection.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

_Collection.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface _Collection
00019 /** @com.interface(iid=00000512-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface _Collection extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=PROPGET, name="Count", name2="getCount", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int getCount();
00025
00026   /** @com.method(vtoffset=5, dispid=4294967292, type=METHOD, name="_NewEnum", addFlagsVtable=4)
00027       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00028   public IUnknown _NewEnum();
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=METHOD, name="Refresh", addFlagsVtable=4)
00031       @com.parameters() */
00032   public void Refresh();
00033
00034
00035   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x512, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00036 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/adddevicedlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

adddevicedlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddDeviceDlg.h:  Header for the CAddDeviceDlg class.  This is a
00014 //                   modeless dialog class used to add device nodes.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDDEVICEDLG_
00019 #define _CLASS_ADDDEVICEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddDeviceDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddDeviceDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddDeviceDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDDEVICEDLG_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/odbcdata.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

odbcdata.h

Go to the documentation of this file.
00001 #include "pooleddata.h"
00002
00003 #ifndef DBNTWIN32
00004 #define DBNTWIN32
00005 #include <SQL.h>
00006 #include <SQLEXT.h>
00007 #include <ODBCSS.H>
00008 #endif
00009 #define SQL_FAILED(rc)  ( (rc) != SQL_SUCCESS && (rc) != SQL_SUCCESS_WITH_INFO)
00010 #define ASSERT_SQL_SUCCESS(rc) { _ASSERTE(rc==SQL_SUCCESS || rc==SQL_SUCCESS_WITH_INFO);}
00011 #define PROCESS_SQL_ERROR(_rc) if (SQL_FAILED(_rc)) { char _szError[1024]; ATLTRACE ("ODBC Execution failed in file %s at line %d, code: %#x\n", __FILE__, __LINE__, _rc); if (m_spObjectContext.p != NULL) m_spObjectContext->SetAbort(); GetODBCError(_szError); return AtlReportError(CLSID_Proxy, _szError, IID_IDataProxy, E_FAIL); }
00012
00013 extern void GetError(HENV henv, HDBC hdbc, HSTMT hstmt, BSTR * sErr);
00014
00015 /*
00016   If you are replacing the CODBCData class (CProxy derives from CODBCData)
00017   with another data access class e.g. using OLEDB then you will need to
00018   derive it from CPooledData, and (re)implement the following protected members:
00019
00020   The members will be called in the order shown below..
00021
00022   1. ManualConstructData
00023     - create a connection to your data source from a given string
00024
00025   2. CloseCurrentStatement
00026     - close any command that has been sent to the data store via ExecuteSQL
00027     i.e. freeing up any binding and cursor data
00028
00029   3. Enlist
00030     - enlist the current data connection into the DTC transaction
00031     that is held within the Object Context
00032
00033   4. ExecuteSQL
00034     - send a string command to the data source, and deal with the
00035     possible single row, single field return value.
00036
00037   5. NextResultsetData
00038     - a query may return multiple resultsets this function is called
00039     to make the next resultset available
00040
00041   6. BindResultMetaData
00042     - gather the metadata from a resultset into the internal structures
00043
00044   7. FetchData (potentially called many times)
00045     - fetch the next row of a resultset and place it's data into the
00046     metadata structures (Binding can make this a trivial implementation)
00047
00048     8. DeactivateData
00049     - IObjectControl::Deactivate has been called, clean up, especially
00050     if you are being pooled.
00051 */
00052
00053 class CODBCData : public CPooledData
00054 {
00055 private:
00056 // Data Items
00057   HENV m_henv;
00058   HDBC m_hdbc;
00059   HSTMT m_hstmt;
00060
00061 // Private Members
00062   void GetODBCError(char *szError);
00063   HRESULT GetConnection(BSTR sDsn, BOOL bUseObjectPool);
00064   HRESULT Enlist(IObjectContext * pObjectContext, const CLSID &clsid, const IID &iid);
00065
00066 protected:
00067   CString m_wszConnection;
00068
00069   CODBCData()
00070   {
00071     m_henv = 0;
00072     m_hdbc = 0;
00073     m_hstmt= 0;
00074   }
00075
00076   ~CODBCData()
00077   {
00078     if (m_hstmt)
00079       SQLFreeStmt(m_hstmt, SQL_DROP);
00080     if (m_hdbc)
00081     {
00082       SQLDisconnect(m_hdbc);
00083       SQLFreeConnect(m_hdbc);
00084     }
00085     if (m_henv)
00086       SQLFreeEnv(m_henv);
00087
00088     m_hstmt = 0;
00089     m_henv = 0;
00090     m_hdbc = 0;
00091   }
00092
00093   STDMETHOD(ManualConstructData)(BSTR strConstruct)
00094   {
00095     HRESULT hr = GetConnection(strConstruct, m_bObjectPooled);
00096     if (FAILED(hr))
00097     {
00098       LPCSTR szError = "Could not connect to the database.";
00099       return AtlReportError(CLSID_Proxy, szError, IID_IDataProxy, hr);
00100     }
00101     m_bConstructed = TRUE;
00102     return S_OK;
00103   }
00104
00105   virtual HRESULT ExecuteSQL(LPCWSTR wszSQL, long *pResult = NULL);
00106   virtual HRESULT BindResultMetaData(FieldMetaData **ppMetaData, short *pCount);
00107   virtual inline HRESULT FetchData()
00108   {
00109     HRESULT hr = S_OK;
00110     RETCODE rc;
00111
00112     rc = SQLFetch(m_hstmt);
00113
00114     PROCESS_SQL_ERROR(rc);
00115
00116     return hr;
00117   }
00118   virtual void CloseCurrentStatement();
00119     virtual void STDMETHODCALLTYPE DeactivateData(void)
00120   {
00121     m_spObjectContext.Release();
00122     return;
00123   }
00124   virtual HRESULT NextResultsetData(long *pResult);
00125 };
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/SampleFSP/Reg.c Source File

  • NetDS
  • fax
  • SampleFSP

Reg.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1997 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007   reg.c
00008
00009 Abstract:
00010
00011   This module implements registry functions for the newfsp service provider
00012
00013 --*/
00014
00015 #include "newfsp.h"
00016
00017 BOOL
00018 GetNewFspRegistryData(
00019     BOOL          *bLoggingEnabled,
00020     LPWSTR        lpszLoggingDirectory,
00021   DWORD     dwLoggingDirectoryBufferSize,
00022     PDEVICE_INFO  *pDeviceInfo,
00023     LPDWORD       pdwNumDevices
00024 )
00025 /*++
00026
00027 Routine Description:
00028
00029   Get the registry data for the newfsp service provider
00030
00031 Arguments:
00032
00033   bLoggingEnabled - indicates if logging is enabled
00034   lpszLoggingDirectory - indicates the logging directory
00035   pDeviceInfo - pointer to the virtual fax devices
00036   pdwNumDevice - pointer to the number of virtual fax devices
00037
00038 Return Value:
00039
00040   TRUE on success
00041
00042 --*/
00043 {
00044     // hServiceProvidersKey is the handle to the fax service providers registry key
00045     HKEY          hServiceProvidersKey;
00046     // hNewFspKey is the handle to the newfsp service provider registry key
00047     HKEY          hNewFspKey;
00048     // hDevicesKey is the handle to the virtual fax devices registry key
00049     HKEY          hDevicesKey;
00050     // dwSubkeys is the number of virtual fax device registry subkeys
00051     DWORD         dwSubkeys;
00052     // dwIndex is a counter to enumerate each virtual fax device registry subkey
00053     DWORD         dwIndex;
00054     // szDeviceSubkey is the name of a virtual fax device registry subkey
00055     WCHAR         szDeviceSubkey[MAX_PATH];
00056     // hDeviceSubkey is the handle to a virtual fax device registry subkey
00057     HKEY          hDeviceSubkey;
00058     DWORD         dwType;
00059
00060     // pCurrentDeviceInfo is a pointer to the current virtual fax device
00061     PDEVICE_INFO  pCurrentDeviceInfo;
00062
00063     DWORD         dwLoggingEnabledSize;
00064   DWORD         dwLoggingDirectorySize = dwLoggingDirectoryBufferSize - 1;
00065     DWORD         dwDirectorySize;
00066
00067     if (bLoggingEnabled != NULL) {
00068         *bLoggingEnabled = FALSE;
00069     }
00070
00071     if (pDeviceInfo != NULL) {
00072         *pDeviceInfo = NULL;
00073     }
00074
00075     if (pdwNumDevices != NULL) {
00076         *pdwNumDevices = 0;
00077     }
00078
00079
00080     // Open the fax service providers registry key
00081     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
00082            FAX_PROVIDERS_REGKEY,
00083            0,
00084            KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
00085            &hServiceProvidersKey) != ERROR_SUCCESS) {
00086         return FALSE;
00087     }
00088
00089     // Open the newfsp service provider registry key
00090     if (RegOpenKeyEx(hServiceProvidersKey,
00091            NEWFSP_PROVIDER,
00092            0,
00093            KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
00094            &hNewFspKey) != ERROR_SUCCESS) {
00095         RegCloseKey(hServiceProvidersKey);
00096         return FALSE;
00097     }
00098
00099     if (bLoggingEnabled != NULL) {
00100         // Get the logging enabled
00101         dwLoggingEnabledSize = sizeof(BOOL);
00102         RegQueryValueEx(hNewFspKey,
00103             NEWFSP_LOGGING_ENABLED,
00104             NULL,
00105             &dwType,
00106             (LPBYTE) bLoggingEnabled,
00107             &dwLoggingEnabledSize);
00108     }
00109
00110     if (lpszLoggingDirectory != NULL) {
00111         // Get the logging directory
00112     if ((RegQueryValueEx(hNewFspKey,
00113               NEWFSP_LOGGING_DIRECTORY,
00114               NULL,
00115               &dwType,
00116               (LPBYTE) lpszLoggingDirectory,
00117               &dwLoggingDirectorySize) != ERROR_SUCCESS)||
00118       (dwLoggingDirectorySize >= MAX_PATH)){
00119       RegCloseKey(hNewFspKey);
00120             RegCloseKey(hServiceProvidersKey);
00121       return FALSE;
00122     }
00123     }
00124
00125     if ((pDeviceInfo != NULL) || (pdwNumDevices != NULL)) {
00126         // Open the virtual fax devices registry key
00127         if (RegOpenKeyEx(hNewFspKey,
00128              NEWFSP_DEVICES,
00129              0,
00130              KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
00131              &hDevicesKey) != ERROR_SUCCESS) {
00132             RegCloseKey(hNewFspKey);
00133             RegCloseKey(hServiceProvidersKey);
00134             return FALSE;
00135         }
00136
00137         // Determine the number of virtual fax device registry subkeys
00138         if (RegQueryInfoKey(hDevicesKey,
00139               NULL,
00140               NULL,
00141               NULL,
00142               &dwSubkeys,
00143               NULL,
00144               NULL,
00145               NULL,
00146               NULL,
00147               NULL,
00148               NULL,
00149               NULL) != ERROR_SUCCESS) {
00150             RegCloseKey(hDevicesKey);
00151             RegCloseKey(hNewFspKey);
00152             RegCloseKey(hServiceProvidersKey);
00153             return FALSE;
00154         }
00155     }
00156
00157     if (pdwNumDevices != NULL) {
00158         if (dwSubkeys < NEWFSP_DEVICE_LIMIT) {
00159             *pdwNumDevices = dwSubkeys;
00160         }
00161         else {
00162             *pdwNumDevices = NEWFSP_DEVICE_LIMIT;
00163         }
00164     }
00165
00166     if (pDeviceInfo != NULL) {
00167         if (dwSubkeys > 0) {
00168             // Allocate a block of memory for the first virtual fax device data
00169             *pDeviceInfo = MemAllocMacro(sizeof(DEVICE_INFO));
00170         }
00171
00172         // Enumerate the virtual fax device registry subkeys
00173         for (pCurrentDeviceInfo = *pDeviceInfo, dwIndex = 0;
00174        (dwIndex < dwSubkeys) && (dwIndex < NEWFSP_DEVICE_LIMIT);
00175        pCurrentDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo, dwIndex++) {
00176             if (pCurrentDeviceInfo == NULL) {
00177                 // A memory allocation for virtual fax device data failed, so go with what we have so far
00178                 *pdwNumDevices = dwIndex;
00179
00180                 break;
00181             }
00182
00183             // Set the name of the virtual fax device registry subkey
00184             wsprintf(szDeviceSubkey, L"%d", dwIndex);
00185             // Set the identifier of the virtual fax device
00186             pCurrentDeviceInfo->DeviceId = dwIndex;
00187
00188             if (RegOpenKeyEx(hDevicesKey,
00189                szDeviceSubkey,
00190                0,
00191                KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
00192                &hDeviceSubkey) == ERROR_SUCCESS) {
00193
00194
00195         // Get the incoming fax directory for the virtual fax device
00196                 dwDirectorySize = sizeof(pCurrentDeviceInfo->Directory)/sizeof(pCurrentDeviceInfo->Directory[0]);
00197                 if (RegQueryValueEx(hDeviceSubkey,
00198                   NEWFSP_DEVICE_DIRECTORY,
00199                   NULL,
00200                   &dwType,
00201                   (LPBYTE) pCurrentDeviceInfo->Directory,
00202                   &dwDirectorySize) != ERROR_SUCCESS) {
00203           RegCloseKey(hDeviceSubkey);
00204           continue;
00205         }
00206                 RegCloseKey(hDeviceSubkey);
00207             }
00208
00209             // Allocate a block of memory for the next virtual fax device data
00210             if ((dwIndex < (dwSubkeys - 1)) && (dwIndex < (NEWFSP_DEVICE_LIMIT - 1))) {
00211                 pCurrentDeviceInfo->pNextDeviceInfo = MemAllocMacro(sizeof(DEVICE_INFO));
00212             }
00213             else {
00214                 pCurrentDeviceInfo->pNextDeviceInfo = NULL;
00215             }
00216         }
00217     }
00218
00219     if ((pDeviceInfo != NULL) || (pdwNumDevices != NULL)) {
00220         RegCloseKey(hDevicesKey);
00221     }
00222
00223     RegCloseKey(hNewFspKey);
00224     RegCloseKey(hServiceProvidersKey);
00225
00226     return TRUE;
00227 }
00228
00229 VOID
00230 SetNewFspRegistryData(
00231     BOOL          bLoggingEnabled,
00232     LPWSTR        lpszLoggingDirectory,
00233     PDEVICE_INFO  pDeviceInfo
00234 )
00235 /*++
00236
00237 Routine Description:
00238
00239   Set the registry data for the newfsp service provider
00240
00241 Arguments:
00242
00243   bLoggingEnabled - indicates if logging is enabled
00244   lpszLoggingDirectory - indicates the logging directory
00245   pDeviceInfo - pointer to the virtual fax devices
00246
00247 Return Value:
00248
00249   None
00250
00251 --*/
00252 {
00253     // hServiceProvidersKey is the handle to the fax service providers registry key
00254     HKEY          hServiceProvidersKey;
00255     // hNewFspKey is the handle to the newfsp service provider registry key
00256     HKEY          hNewFspKey;
00257     // hDevicesKey is the handle to the virtual fax devices registry key
00258     HKEY          hDevicesKey;
00259     // dwSubkeys is the number of virtual fax device registry subkeys
00260     DWORD         dwSubkeys;
00261     // dwIndex is a counter to enumerate each virtual fax device registry subkey
00262     DWORD         dwIndex;
00263     // szDeviceSubkey is the name of a virtual fax device registry subkey
00264     WCHAR         szDeviceSubkey[MAX_PATH];
00265     // hDeviceSubkey is the handle to a virtual fax device registry subkey
00266     HKEY          hDeviceSubkey;
00267     DWORD         dwDisposition;
00268
00269     // pCurrentDeviceInfo is a pointer to the current virtual fax device
00270     PDEVICE_INFO  pCurrentDeviceInfo;
00271
00272     // Open the fax service providers registry key
00273     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
00274            FAX_PROVIDERS_REGKEY,
00275            0,
00276            KEY_CREATE_SUB_KEY,
00277            &hServiceProvidersKey) != ERROR_SUCCESS) {
00278         return;
00279     }
00280
00281     // Open the newfsp service provider registry key
00282     if (RegCreateKeyEx(hServiceProvidersKey,
00283              NEWFSP_PROVIDER,
00284              0,
00285              NULL,
00286              REG_OPTION_NON_VOLATILE,
00287              KEY_CREATE_SUB_KEY|KEY_SET_VALUE,
00288              NULL,
00289              &hNewFspKey,
00290              &dwDisposition) != ERROR_SUCCESS) {
00291         RegCloseKey(hServiceProvidersKey);
00292         return;
00293     }
00294
00295     // Set the logging enabled
00296     RegSetValueEx(hNewFspKey,
00297           NEWFSP_LOGGING_ENABLED,
00298           0,
00299           REG_DWORD,
00300           (LPBYTE) &bLoggingEnabled,
00301           sizeof(bLoggingEnabled));
00302
00303     // Set the logging directory
00304     if (lpszLoggingDirectory != NULL) {
00305         RegSetValueEx(hNewFspKey,
00306             NEWFSP_LOGGING_DIRECTORY,
00307             0,
00308             REG_SZ,
00309             (LPBYTE) lpszLoggingDirectory,
00310             (lstrlen(lpszLoggingDirectory) + 1) * sizeof(WCHAR));
00311     }
00312
00313     // Open the virtual fax devices registry key
00314     if (RegCreateKeyEx(hNewFspKey,
00315              NEWFSP_DEVICES,
00316              0,
00317              NULL,
00318              REG_OPTION_NON_VOLATILE,
00319              KEY_CREATE_SUB_KEY|KEY_ENUMERATE_SUB_KEYS|KEY_QUERY_VALUE|KEY_SET_VALUE,
00320              NULL,
00321              &hDevicesKey,
00322              &dwDisposition) != ERROR_SUCCESS) {
00323         RegCloseKey(hNewFspKey);
00324         RegCloseKey(hServiceProvidersKey);
00325         return;
00326     }
00327
00328     // Determine the number of virtual fax device registry subkeys
00329     if (RegQueryInfoKey(hDevicesKey,
00330             NULL,
00331             NULL,
00332             NULL,
00333             &dwSubkeys,
00334             NULL,
00335             NULL,
00336             NULL,
00337             NULL,
00338             NULL,
00339             NULL,
00340             NULL) != ERROR_SUCCESS) {
00341         RegCloseKey(hDevicesKey);
00342         RegCloseKey(hNewFspKey);
00343         RegCloseKey(hServiceProvidersKey);
00344         return;
00345     }
00346
00347     // Enumerate the virtual fax device registry subkeys
00348     for (pCurrentDeviceInfo = pDeviceInfo, dwIndex = 0;
00349      pCurrentDeviceInfo;
00350      pCurrentDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo, dwIndex++) {
00351         // Set the name of the virtual fax device registry subkey
00352         wsprintf(szDeviceSubkey, L"%d", pCurrentDeviceInfo->DeviceId);
00353         if (RegCreateKeyEx(hDevicesKey,
00354                szDeviceSubkey,
00355                0,
00356                NULL,
00357                REG_OPTION_NON_VOLATILE,
00358                KEY_QUERY_VALUE|KEY_SET_VALUE,
00359                NULL,
00360                &hDeviceSubkey,
00361                &dwDisposition) == ERROR_SUCCESS) {
00362             // Set the incoming fax directory for the virtual fax device
00363             RegSetValueEx(hDeviceSubkey,
00364               NEWFSP_DEVICE_DIRECTORY,
00365               0,
00366               REG_SZ,
00367               (LPBYTE) pCurrentDeviceInfo->Directory,
00368               (lstrlen(pCurrentDeviceInfo->Directory) + 1) * sizeof(WCHAR));
00369
00370             RegCloseKey(hDeviceSubkey);
00371         }
00372     }
00373
00374     // Delete any removed virtual fax device registry subkeys
00375     for ( ; dwIndex < dwSubkeys; dwIndex++) {
00376         // Set the name of the virtual fax device registry subkey
00377         wsprintf(szDeviceSubkey, L"%d", dwIndex);
00378         RegDeleteKey(hDevicesKey, szDeviceSubkey);
00379     }
00380
00381     RegCloseKey(hDevicesKey);
00382     RegCloseKey(hNewFspKey);
00383     RegCloseKey(hServiceProvidersKey);
00384 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CXmlDOM Member List

This is the complete list of members for CXmlDOM, including all inherited members.
Create() | CXmlDOM | [inline, virtual]
CXmlDOM() | CXmlDOM |
LoadFile(VARIANT *pVariant) | CXmlDOM | [inline, virtual]
LoadStream(IUnknown *pIUnkStream) | CXmlDOM | [inline, virtual]
LoadXML(BSTR bstrXML) | CXmlDOM | [inline, virtual]
m_spXMLDocument | CXmlDOM |
PrintAttributes(IXMLDOMNode *spNode, CConsole &rConsole) | CXmlDOM | [virtual]
PrintNode(IXMLDOMNode *spNode, CConsole &rConsole, ULONG ullevel=0) | CXmlDOM | [virtual]
Save(BSTR bstrFileName) | CXmlDOM | [inline, virtual]
Save(VARIANT *pVariant) | CXmlDOM | [inline, virtual]
~CXmlDOM() | CXmlDOM | [virtual]
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/Dispatch.c Source File

  • NetDS
  • WinSock
  • IpxChat

Dispatch.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   dispatch.c
00009 //
00010 //  PURPOSE:  Implement the generic message and command dispatchers.
00011 //
00012 //
00013 //  FUNCTIONS:
00014 //    DispMessage - Call the function associated with a message.
00015 //    DispCommand - Call the function associated with a command.
00016 //    DispDefault - Call the appropriate default window procedure.
00017 //
00018 //  COMMENTS:
00019 //
00020
00021 #include "globals.h"            // prototypes specific to this application
00022 #include <windows.h>            // required for all Windows applications
00023 #include <windowsx.h>
00024
00025
00026
00027 LRESULT DispDefault(EDWP, HWND, UINT, WPARAM, LPARAM);
00028
00029 //
00030 //  FUNCTION: DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM)
00031 //
00032 //  PURPOSE: Call the function associated with a message.
00033 //
00034 //  PARAMETERS:
00035 //    lpmsdi - Structure containing the message dispatch information.
00036 //    hwnd - The window handle
00037 //    uMessage - The message number
00038 //    wparam - Message specific data
00039 //    lparam - Message specific data
00040 //
00041 //  RETURN VALUE:
00042 //    The value returned by the message function that was called.
00043 //
00044 //  COMMENTS:
00045 //    Runs the table of messages stored in lpmsdi->rgmsd searching
00046 //    for a message number that matches uMessage.  If a match is found,
00047 //    call the associated function.  Otherwise, call DispDefault to
00048 //    call the default function, if any, associated with the message
00049 //    structure.  In either case, return the value recieved from the
00050 //    message or default function.
00051 //
00052
00053 LRESULT DispMessage(LPMSDI lpmsdi,
00054                     HWND   hwnd,
00055                     UINT   uMessage,
00056                     WPARAM wparam,
00057                     LPARAM lparam)
00058 {
00059     int  imsd = 0;
00060
00061     MSD *rgmsd = lpmsdi->rgmsd;
00062     int  cmsd  = lpmsdi->cmsd;
00063
00064     for (imsd = 0; imsd < cmsd; imsd++)
00065     {
00066         if (rgmsd[imsd].uMessage == uMessage)
00067             return rgmsd[imsd].pfnmsg(hwnd, uMessage, wparam, lparam);
00068     }
00069
00070     return DispDefault(lpmsdi->edwp, hwnd, uMessage, wparam, lparam);
00071 }
00072
00073 //
00074 //  FUNCTION: DispCommand(LPCMDI, HWND, WPARAM, LPARAM)
00075 //
00076 //  PURPOSE: Call the function associated with a command.
00077 //
00078 //  PARAMETERS:
00079 //    lpcmdi - Structure containing the command dispatch information.
00080 //    hwnd - The window handle
00081 //    GET_WM_COMMAND_ID(wparam, lparam) - Identifier of the menu item,
00082 //      control, or accelerator.
00083 //    GET_WM_COMMAND_CMD(wparam, lparam) - Notification code.
00084 //    GET_WM_COMMAND_HWND(wparam, lparam) - The control handle or NULL.
00085 //
00086 //  RETURN VALUE:
00087 //    The value returned by the command function that was called.
00088 //
00089 //  COMMENTS:
00090 //    Runs the table of commands stored in lpcmdi->rgcmd searching
00091 //    for a command number that matches wCommand.  If a match is found,
00092 //    call the associated function.  Otherwise, call DispDefault to
00093 //    call the default function, if any, associated with the command
00094 //    structure.  In either case, return the value recieved from the
00095 //    command or default function.
00096 //
00097
00098
00099 LRESULT DispCommand(LPCMDI lpcmdi,
00100                     HWND   hwnd,
00101                     WPARAM wparam,
00102                     LPARAM lparam)
00103 {
00104     LRESULT lRet = 0;
00105     WORD    wCommand = GET_WM_COMMAND_ID(wparam, lparam);
00106     int     icmd = 0;
00107
00108     CMD    *rgcmd = lpcmdi->rgcmd;
00109     int     ccmd  = lpcmdi->ccmd;
00110
00111     // Message packing of wparam and lparam have changed for Win32,
00112     // so use the GET_WM_COMMAND macro to unpack the commnad
00113
00114     for (icmd = 0; icmd < ccmd; icmd++)
00115     {
00116         if (rgcmd[icmd].wCommand == wCommand)
00117         {
00118             return rgcmd[icmd].pfncmd(hwnd,
00119                                       wCommand,
00120                                       GET_WM_COMMAND_CMD(wparam, lparam),
00121                                       GET_WM_COMMAND_HWND(wparam, lparam));
00122         }
00123     }
00124
00125     return DispDefault(lpcmdi->edwp, hwnd, WM_COMMAND, wparam, lparam);
00126 }
00127
00128
00129 //
00130 //  FUNCTION: DispDefault(EDWP, HWND, UINT, WPARAM, LPARAM)
00131 //
00132 //  PURPOSE: Call the appropriate default window procedure.
00133 //
00134 //  PARAMETERS:
00135 //    edwp - Enumerate specifying the appropriate default winow procedure.
00136 //    hwnd - The window handle
00137 //    uMessage - The message number
00138 //    wparam - Message specific data
00139 //    lparam - Message specific data
00140 //
00141 //  RETURN VALUE:
00142 //    If there is a default proc, return the value returned by the
00143 //    default proc.  Otherwise, return 0.
00144 //
00145 //  COMMENTS:
00146 //    Calls the default procedure associated with edwp using the specified
00147 //    parameters.
00148 //
00149
00150 LRESULT DispDefault(EDWP   edwp,
00151                     HWND   hwnd,
00152                     UINT   uMessage,
00153                     WPARAM wparam,
00154                     LPARAM lparam)
00155 {
00156     switch (edwp)
00157     {
00158         case edwpNone:
00159             return 0;
00160         case edwpWindow:
00161             return DefWindowProc(hwnd, uMessage, wparam, lparam);
00162         case edwpDialog:
00163             return DefDlgProc(hwnd, uMessage, wparam, lparam);
00164         case edwpMDIFrame:
00165             return DefFrameProc(hwnd, hwndMDIIPXChat, uMessage, wparam, lparam);
00166         case edwpMDIChild:
00167             return DefMDIChildProc(hwnd, uMessage, wparam, lparam);
00168     }
00169     return 0;
00170 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/DCO_DimmerService/DimmerDeviceDCO.h Source File

  • NetDS
  • upnp
  • DCO_DimmerService

DimmerDeviceDCO.h

Go to the documentation of this file.
00001 //
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 // PARTICULAR PURPOSE.
00006 //
00007 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00008 //
00009 //
00010 // DimmerDeviceDCO.h
00011
00012 #ifndef __DimmerDevice_H_
00013 #define __DimmerDevice_H_
00014
00015 // This is equal to the number of devices (root or embedded) in the description doc
00016 #define NUM_TEMPLATE_UDNS_IN_DESCDOC 1
00017
00018 // This  is equal to the maximum number of services in any device in the description doc
00019 #define MAX_NOSERVICE_PER_DEVICE 1
00020
00021
00022
00023 ////////////////////////////////////////////////////////////////
00024 // UPNPDimmerDevice : class definition for the Device Control
00025 //                    Implementation for the Dimmer Device
00026 ////////////////////////////////////////////////////////////////
00027 class ATL_NO_VTABLE UPNPDimmerDevice:
00028    public CComObjectRootEx<CComMultiThreadModel>,
00029    public CComCoClass<UPNPDimmerDevice, &CLSID_UPNPSampleDimmerDevice>,
00030    public IUPnPDeviceControl
00031 {
00032 private:
00033    // variables used internally are declared
00034
00035    // String that stores the description doc that is passed by the
00036    // Device Host during Intialize
00037    BSTR descriptionDoc;
00038
00039    // table to hold mapping from template UDN's to the UDN's actually
00040    // used by the DeviceHost when publishing the device
00041    BSTR UDNmapping[NUM_TEMPLATE_UDNS_IN_DESCDOC][2];
00042
00043    // now for each of the Template UDN's we maintain a list of services
00044    // in it and the IDispatch interface pointers the serviceIDDeviceMap
00045    // table maps between devices (root or embedded) and the service Id's in the device
00046    BSTR serviceIDDeviceMap[NUM_TEMPLATE_UDNS_IN_DESCDOC][MAX_NOSERVICE_PER_DEVICE];
00047
00048    // this table maps between the services in the device (root or embedded)
00049    // and the IDispatch pointers
00050    IDispatch* pDisPtrs[NUM_TEMPLATE_UDNS_IN_DESCDOC][MAX_NOSERVICE_PER_DEVICE];
00051
00052
00053 public:
00054    UPNPDimmerDevice();
00055    ~UPNPDimmerDevice();
00056    STDMETHODIMP UPNPDimmerDevice::Initialize(BSTR bstrXMLDesc,BSTR deviceID,BSTR bstrInitString);
00057    STDMETHODIMP UPNPDimmerDevice::GetServiceObject(BSTR bstrUDN,BSTR bstrServiceId,IDispatch **ppdispService);
00058
00059    DECLARE_REGISTRY_RESOURCEID(IDR_UPNPDIMMERDEVICE)
00060
00061    DECLARE_PROTECT_FINAL_CONSTRUCT()
00062
00063    BEGIN_COM_MAP(UPNPDimmerDevice)
00064       COM_INTERFACE_ENTRY(IUPnPDeviceControl)
00065    END_COM_MAP()
00066
00067 };
00068
00069 #endif //__DimmerDevice_H_
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcProp.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcProp.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "ACProp.h"
00052
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // CAgentCtlPropertySheet properties
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CAgentCtlPropertySheet operations
00059
00060 short CAgentCtlPropertySheet::GetLeft()
00061 {
00062   short result;
00063   InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00064   return result;
00065 }
00066
00067 short CAgentCtlPropertySheet::GetTop()
00068 {
00069   short result;
00070   InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00071   return result;
00072 }
00073
00074 short CAgentCtlPropertySheet::GetHeight()
00075 {
00076   short result;
00077   InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00078   return result;
00079 }
00080
00081 short CAgentCtlPropertySheet::GetWidth()
00082 {
00083   short result;
00084   InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00085   return result;
00086 }
00087
00088 void CAgentCtlPropertySheet::SetVisible(BOOL bNewValue)
00089 {
00090   static BYTE parms[] =
00091     VTS_BOOL;
00092   InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00093      bNewValue);
00094 }
00095
00096 BOOL CAgentCtlPropertySheet::GetVisible()
00097 {
00098   BOOL result;
00099   InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00100   return result;
00101 }
00102
00103 void CAgentCtlPropertySheet::SetPage(LPCTSTR lpszNewValue)
00104 {
00105   static BYTE parms[] =
00106     VTS_BSTR;
00107   InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00108      lpszNewValue);
00109 }
00110
00111 CString CAgentCtlPropertySheet::GetPage()
00112 {
00113   CString result;
00114   InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00115   return result;
00116 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/SampleRoute/Resource.h Source File

  • NetDS
  • fax
  • SampleRoute

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by faxsiren.rc
00004 //
00005
00006 // Next default values for new objects
00007 //
00008 #ifdef APSTUDIO_INVOKED
00009 #ifndef APSTUDIO_READONLY_SYMBOLS
00010 #define _APS_NO_MFC                     1
00011 #define _APS_NEXT_RESOURCE_VALUE        101
00012 #define _APS_NEXT_COMMAND_VALUE         40001
00013 #define _APS_NEXT_CONTROL_VALUE         1000
00014 #define _APS_NEXT_SYMED_VALUE           101
00015 #endif
00016 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/rmapi.h Source File

  • NetDS
  • RRas
  • ip

rmapi.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\rmapi.h
00008
00009 Abstract:
00010
00011     The file contains the header for rmapi.c.
00012
00013 --*/
00014
00015 #ifndef _RMAPI_H_
00016 #define _RMAPI_H_
00017
00018 //
00019 // function declarations for router manager interface:
00020 //
00021
00022 DWORD
00023 APIENTRY
00024 RegisterProtocol(
00025     IN OUT PMPR_ROUTING_CHARACTERISTICS pRoutingChar,
00026     IN OUT PMPR_SERVICE_CHARACTERISTICS pServiceChar
00027     );
00028
00029 #endif // _RMAPI_H_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

PaperForm::PaperForm Member List

This is the complete list of members for PaperForm::PaperForm, including all inherited members.
components | PaperForm::PaperForm | [private]
Dispose(bool disposing) | PaperForm::PaperForm | [inline, protected]
formData | PaperForm::PaperForm | [private]
formDataFile | PaperForm::PaperForm | [private]
InitializeComponent() | PaperForm::PaperForm | [inline, private]
inkPicture1 | PaperForm::PaperForm | [private]
Main() | PaperForm::PaperForm | [inline, private, static]
mainMenu | PaperForm::PaperForm | [private]
menuItem4 | PaperForm::PaperForm | [private]
miClear | PaperForm::PaperForm | [private]
miClear_Click(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
miEdit | PaperForm::PaperForm | [private]
miEdit_Click(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
miEraser | PaperForm::PaperForm | [private]
miEraser_Click(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
miExit | PaperForm::PaperForm | [private]
miExit_Click(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
miInk | PaperForm::PaperForm | [private]
miMode | PaperForm::PaperForm | [private]
miPen | PaperForm::PaperForm | [private]
miPen_Click(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
miRecognize | PaperForm::PaperForm | [private]
miRecognize_Click(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
PaperForm() | PaperForm::PaperForm | [inline]
PaperForm_Load(object sender, System.EventArgs e) | PaperForm::PaperForm | [inline, private]
Recognize() | PaperForm::PaperForm | [inline, private]
UpdateEditMode(InkOverlayEditingMode mode) | PaperForm::PaperForm | [inline, private]
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/Listen.c Source File

  • NetDS
  • WinSock
  • IpxChat

Listen.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   listen.c
00009 //
00010 //  PURPOSE:   Displays the "Listen" dialog box
00011 //
00012 //  FUNCTIONS:
00013 //    CmdListen          - Displays the "Listen" dialog box.
00014 //    Listen             - Processes messages for "Listen" dialog box.
00015 //    MsgListenInit      - Centers dialog and initializes edit controls.
00016 //    MsgListenConnected - Handles Connected message when socket is connected.
00017 //    MsgListenCommand   - Process WM_COMMAND message sent to the listen box.
00018 //    CmdListenDone      - Free the listen box and related data.
00019 //    CmdListenNow       - Sets up listen on specified socket
00020 //
00021 //  COMMENTS:
00022 //
00023 //
00024 #include "globals.h"            // prototypes specific to this application
00025 #include <windows.h>            // required for all Windows applications
00026 #include <windowsx.h>
00027 #include <stdlib.h>
00028 #include <stdio.h>
00029
00030
00031 LRESULT CALLBACK Listen(HWND, UINT, WPARAM, LPARAM);
00032 LRESULT MsgListenInit(HWND, UINT, WPARAM, LPARAM);
00033 LRESULT MsgListenCommand(HWND, UINT, WPARAM, LPARAM);
00034 LRESULT MsgListenConnected(HWND, UINT, WPARAM, LPARAM);
00035 LRESULT CmdListenNow(HWND, WORD, WORD, HWND);
00036 LRESULT CmdListenDone(HWND, WORD, WORD, HWND);
00037
00038 // Listen dialog message table definition.
00039 MSD rgmsdListen[] =
00040 {
00041     {WM_COMMAND,    MsgListenCommand},
00042     {WM_INITDIALOG, MsgListenInit},
00043     {LDM_CONNECTED, MsgListenConnected}
00044 };
00045
00046 MSDI msdiListen =
00047 {
00048     sizeof(rgmsdListen) / sizeof(MSD),
00049     rgmsdListen,
00050     edwpNone
00051 };
00052
00053 // Listen dialog command table definition.
00054 CMD rgcmdListen[] =
00055 {
00056     {IDOK,     CmdListenNow},
00057     {IDCANCEL, CmdListenDone}
00058 };
00059
00060 CMDI cmdiListen =
00061 {
00062     sizeof(rgcmdListen) / sizeof(CMD),
00063     rgcmdListen,
00064     edwpNone
00065 };
00066
00067 // Module specific "globals"  Used when a variable needs to be
00068 // accessed in more than one handler function.
00069
00070 HFONT hfontDlg;
00071
00072 //
00073 //  FUNCTION: CmdListen(HWND, WORD, WORD, HWND)
00074 //
00075 //  PURPOSE: Displays the "Listen" dialog box
00076 //
00077 //  PARAMETERS:
00078 //    hwnd      - Window handle
00079 //    wCommand  - IDM_LISTEN          (unused)
00080 //    wNotify   - Notification number (unused)
00081 //    hwndCtrl  - NULL                (unused)
00082 //
00083 //  RETURN VALUE:
00084 //
00085 //    Always returns 0 - Message handled
00086 //
00087 //  COMMENTS:
00088 //    To process the IDM_LISTEN message, call DialogBox() to display the
00089 //    Listen dialog box.
00090
00091 LRESULT CmdListen(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00092 {
00093     HMENU hmenu;
00094
00095     SetWindowText(hwnd, "IPX Chat Server");     // Change title bar text
00096
00097     // Start Dialog
00098     if(DialogBox(hInst, "ListenBox", hwnd, (DLGPROC)Listen))
00099     {
00100
00101         // Dialog got a connection!  Set Message to indicate
00102         // when we have data to read, or if the connection is
00103         // closed on us.
00104         if (WSAAsyncSelect(sock,
00105                            hwnd,
00106                            MW_DATAREADY,
00107                            FD_READ | FD_CLOSE) == SOCKET_ERROR)
00108         {
00109             MessageBox(hwnd, "WSAAsyncSelect Failed!", NULL, MB_OK);
00110             CleanUp();
00111             return 0;
00112         }
00113
00114         // Fix menus
00115         hmenu = GetMenu(hwnd);
00116         EnableMenuItem(hmenu, IDM_CONNECT, MF_GRAYED);
00117         EnableMenuItem(hmenu, IDM_LISTEN, MF_GRAYED);
00118         EnableMenuItem(hmenu, IDM_DISCONNECT, MF_ENABLED);
00119         return 0;
00120     }
00121
00122     // Listen Failed
00123     SetWindowText(hwnd, szTitle);
00124     return 0;
00125 }
00126
00127
00128 //
00129 //  FUNCTION: Listen(HWND, UINT, WPARAM, LPARAM)
00130 //
00131 //  PURPOSE:  Processes messages for "Listen" dialog box.
00132 //
00133 //  PARAMETERS:
00134 //    hdlg - window handle of the dialog box
00135 //    wMessage - type of message
00136 //    wparam - message-specific information
00137 //    lparam - message-specific information
00138 //
00139 //  RETURN VALUE:
00140 //    TRUE - message handled
00141 //    FALSE - message not handled
00142 //
00143 //  COMMENTS:
00144 //
00145 //     Gets port information from user and then listens
00146 //
00147 //     Listen when user clicks on the OK button.  Kill Dialog when connection
00148 //     established.
00149 //
00150
00151 LRESULT CALLBACK Listen(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
00152 {
00153     return DispMessage(&msdiListen, hdlg, uMessage, wparam, lparam);
00154 }
00155
00156
00157 //
00158 //  FUNCTION: MsgListenInit(HWND, UINT, WPARAM, LPARAM)
00159 //
00160 //  PURPOSE: To center dialog and limit size of edit controls and initialize
00161 //
00162 //  PARAMETERS:
00163 //    hdlg - The window handing the message.
00164 //    uMessage - The message number. (unused).
00165 //    wparam - Message specific data (unused).
00166 //    lparam - Message specific data (unused).
00167 //
00168 //  RETURN VALUE:
00169 //    Always returns 0 - message handled.
00170 //
00171 //  COMMENTS:
00172 //    Set size of edit controls for the following
00173 //           Socket   4  chars (2 2-digit hex numbers)
00174 //
00175
00176 LRESULT MsgListenInit(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
00177 {
00178
00179     // Create a font to use
00180     if(NULL == (hfontDlg = CreateFont(14, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0,
00181                           VARIABLE_PITCH | FF_SWISS, "")))
00182         return FALSE;
00183
00184     // Center the dialog over the application window
00185     CenterWindow (hdlg, GetWindow (hdlg, GW_OWNER));
00186
00187     // Initialize Socket Addresses
00188     SetDlgItemText(hdlg, LD_SOCKET, szListenSocket);
00189
00190     // Limit input to proper size strings
00191     SendDlgItemMessage(hdlg, LD_SOCKET, EM_LIMITTEXT, 4, 0);
00192
00193     return (TRUE);
00194 }
00195
00196 //
00197 //  FUNCTION: MsgListenConnected(HWND, UINT, WPARAM, LPARAM)
00198 //
00199 //  PURPOSE: To handle connected message when socket is connected
00200 //
00201 //  PARAMETERS:
00202 //    hdlg - The window handing the message.
00203 //    uMessage - The message number. (unused).
00204 //    wparam - Message specific data (unused).
00205 //    lparam - Message specific data (unused).
00206 //
00207 //  RETURN VALUE:
00208 //    Always returns 0 - message handled.
00209 //
00210 //  COMMENTS:
00211 //    Performs accept() on incoming socket
00212 //
00213
00214 LRESULT MsgListenConnected(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
00215 {
00216     char outtext[128];
00217
00218     SetDlgItemText(hdlg,
00219                    LD_STATUS,
00220                    "Client Connected!");
00221
00222     SetDlgItemText(hdlg,
00223                    LD_STATUS,
00224                    "Calling accept()");
00225
00226     pRemAddr = (PSOCKADDR_IPX)&addr;
00227     addrlen = sizeof(addr);
00228
00229     // Accept connection
00230     if ((sock = accept(SrvSock, (struct sockaddr *)pRemAddr, &addrlen)) == INVALID_SOCKET)
00231     {
00232         // accept() failed -- show status and clean up dialog
00233         //sprintf(outtext, "Accept() failed, error %u",WSAGetLastError());
00234         StringCchPrintf(outtext,128,"Accept() failed, error %u",WSAGetLastError());
00235         SetDlgItemText(hdlg,
00236                        LD_STATUS,
00237                        outtext);
00238         closesocket(SrvSock);
00239         WSACleanup();
00240         EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
00241         EnableWindow(GetDlgItem(hdlg, LD_SOCKET), TRUE);
00242         SetFocus(GetDlgItem(hdlg, LD_SOCKET));
00243         return(TRUE);
00244     }
00245
00246     // We're connected!
00247     GetAddrString(pRemAddr, outtext);
00248     StringCchCat(outtext,128," connected!");
00249
00250     SetDlgItemText(hdlg,
00251                    LD_STATUS,
00252                    outtext);
00253
00254     EndDialog(hdlg, TRUE);          // Exit the dialog
00255     DeleteObject (hfontDlg);        // Drop font
00256     return (TRUE);
00257 }
00258
00259 //
00260 //  FUNCTION: MsgListenCommand(HWND, UINT, WPARAM, LPARAM)
00261 //
00262 //  PURPOSE: Process WM_COMMAND message sent to the Listen box.
00263 //
00264 //  PARAMETERS:
00265 //    hwnd - The window handing the message.
00266 //    uMessage - The message number. (unused).
00267 //    wparam - Message specific data (unused).
00268 //    lparam - Message specific data (unused).
00269 //
00270 //  RETURN VALUE:
00271 //    Always returns 0 - message handled.
00272 //
00273 //  COMMENTS:
00274 //    Uses this DispCommand function defined in wndproc.c combined
00275 //    with the cmdiListen structure defined in this file to handle
00276 //    the command messages for the Listen dialog box.
00277 //
00278
00279 LRESULT MsgListenCommand(HWND   hwnd,
00280                         UINT   uMessage,
00281                         WPARAM wparam,
00282                         LPARAM lparam)
00283 {
00284     return DispCommand(&cmdiListen, hwnd, wparam, lparam);
00285 }
00286
00287 //
00288 //  FUNCTION: CmdListenDone(HWND, WORD, HWND)
00289 //
00290 //  PURPOSE: Free the Listen box and related data.
00291 //
00292 //  PARAMETERS:
00293 //    hdlg - The window handling the command.
00294 //    wCommand - The command to be handled (unused).
00295 //    wNotify   - Notification number      (unused)
00296 //    hwndCtrl - NULL                      (unused).
00297 //
00298 //  RETURN VALUE:
00299 //    Always returns TRUE.
00300 //
00301 //  COMMENTS:
00302 //    Cleans up sockets then calls EndDialog to finish the dialog session.
00303 //
00304
00305 LRESULT CmdListenDone(HWND hdlg, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00306 {
00307
00308     if (INVALID_SOCKET != SrvSock)
00309     {
00310         closesocket(SrvSock);    // Free any aborted socket resources
00311         SrvSock = INVALID_SOCKET;
00312     }
00313     WSACleanup();
00314     DeleteObject (hfontDlg); // Drop the font
00315     EndDialog(hdlg, FALSE);  // Exit Dialog -- rtrn false since no connection
00316     return TRUE;
00317 }
00318
00319 //
00320 //  FUNCTION: CmdListenNow(HWND, WORD, WORD, HWND)
00321 //
00322 //  PURPOSE: Handles ID_OK message and listens on the specified socket
00323 //
00324 //  PARAMETERS:
00325 //    hwnd - The window handling the command.
00326 //    wCommand - The command to be handled (unused).
00327 //    wNotify   - Notification number (unused)
00328 //    hwndCtrl - NULL (unused).
00329 //
00330 //  RETURN VALUE:
00331 //    Always returns TRUE.
00332 //
00333 //  COMMENTS:
00334 //    Shows Listening address on status bar when listen is successful.
00335 //
00336
00337 LRESULT CmdListenNow(HWND hdlg, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00338 {
00339     char szXferBuffer[5];
00340     WORD wVersionRequested;
00341     WSADATA wsaData;
00342     char outtext[80];
00343
00344     // Get Socket Address
00345     GetDlgItemText(hdlg,
00346          LD_SOCKET,
00347          szXferBuffer,
00348          13);
00349     wVersionRequested = MAKEWORD(1, 1);
00350
00351     SetDlgItemText(hdlg,
00352                   LD_STATUS,
00353                   "Calling WSAStartup");
00354
00355     // Initializes winsock dll
00356     if(WSAStartup(wVersionRequested, &wsaData) != 0)
00357     {
00358
00359         SetDlgItemText(hdlg,
00360                        LD_STATUS,
00361                        "WSAStartup failed");
00362         return TRUE;
00363     }
00364
00365     SetDlgItemText(hdlg,
00366           LD_STATUS,
00367           "WSAStartup Succeeded");
00368
00369     SetDlgItemText(hdlg,
00370           LD_STATUS,
00371           "Calling socket()");
00372
00373     // Allocate socket handle
00374     SrvSock = socket(AF_IPX,         // IPX Family
00375                      SOCK_SEQPACKET, // Gives message mode transfers
00376                      NSPROTO_SPX);   // SPX is connection oriented transport
00377
00378     if(SrvSock == INVALID_SOCKET) {
00379         SetDlgItemText(hdlg,
00380                        LD_STATUS,
00381                        "ERROR on socket()");
00382         WSACleanup();
00383         return TRUE;
00384     }
00385
00386     SetDlgItemText(hdlg,
00387                    LD_STATUS,
00388                    "socket() Succeeded");
00389
00390     // Set up socket address to bind to
00391     memset(&addr, 0, sizeof(addr));    // Clear address
00392     pSockAddr = (PSOCKADDR_IPX)&addr;  // Set pointer
00393     pSockAddr->sa_family = AF_IPX;     // IPX Family
00394     // Make sure socket number is in network order
00395     AtoH(szXferBuffer, (char *)&pSockAddr->sa_socket, 2);
00396
00397     SetDlgItemText(hdlg,
00398                    LD_STATUS,
00399                    "Calling bind()");
00400
00401     // Bind to socket address
00402     if(bind(SrvSock,
00403             (PSOCKADDR) pSockAddr,
00404             sizeof(SOCKADDR_IPX)) == SOCKET_ERROR)
00405     {
00406         SetDlgItemText(hdlg,
00407                        LD_STATUS,
00408                        "Error on bind()");
00409         if (INVALID_SOCKET != SrvSock)
00410         {
00411             closesocket(SrvSock);
00412             SrvSock = INVALID_SOCKET;
00413         }
00414         WSACleanup();
00415         return TRUE;
00416     }
00417
00418     SetDlgItemText(hdlg,
00419                    LD_STATUS,
00420                    "bind() Succeeded");
00421
00422     SetDlgItemText(hdlg,
00423                    LD_STATUS,
00424                    "Calling listen()");
00425
00426     // Set up listen queue - this app only supports one connection so
00427     // queue length is set to 1.
00428     if (listen(SrvSock, 1) == SOCKET_ERROR)
00429     {
00430         StringCchPrintf(outtext,80,"FAILURE: listen() returned %u", WSAGetLastError());
00431         SetDlgItemText(hdlg,
00432                        LD_STATUS,
00433                        outtext);
00434         if (INVALID_SOCKET != SrvSock)
00435         {
00436             closesocket(SrvSock);
00437             SrvSock = INVALID_SOCKET;
00438         }
00439         WSACleanup();
00440         return TRUE;
00441     }
00442
00443     SetDlgItemText(hdlg,
00444                    LD_STATUS,
00445                    "listen() succeeded");
00446
00447     SetDlgItemText(hdlg,
00448                    LD_STATUS,
00449                    "Calling WSAAsyncSelect()");
00450
00451     // Specify message to be posted when client connects
00452     if(WSAAsyncSelect(SrvSock,
00453                       hdlg,
00454                       LDM_CONNECTED,
00455                       FD_ACCEPT) == SOCKET_ERROR)
00456     {
00457         SetDlgItemText(hdlg,
00458                        LD_STATUS,
00459                        "WSAAsyncSelect() failed");
00460         if (INVALID_SOCKET != SrvSock)
00461         {
00462             closesocket(SrvSock);
00463             SrvSock = INVALID_SOCKET;
00464         }
00465         WSACleanup();
00466         return TRUE;
00467     }
00468
00469     SetDlgItemText(hdlg,
00470                    LD_STATUS,
00471                    "WSAAsyncSelect() succeeded");
00472
00473     addrlen = sizeof(addr);
00474
00475     // Get full network.number.socket address
00476     if(getsockname(SrvSock,&addr,&addrlen) == SOCKET_ERROR)
00477     {
00478         StringCchCopy(outtext,80,"ERROR getsocketname()");
00479     }
00480     else
00481     {
00482         StringCchCopy(outtext,80,"Listening on ");
00483         GetAddrString((PSOCKADDR_IPX)&addr, outtext + lstrlen(outtext));
00484     }
00485
00486     SetDlgItemText(hdlg,
00487                    LD_STATUS,
00488                    outtext);
00489
00490
00491     SetFocus(GetDlgItem(hdlg, IDCANCEL));             // Give Cancel Button focus
00492     EnableWindow(GetDlgItem(hdlg, IDOK), FALSE);      // Grey OK button
00493     EnableWindow(GetDlgItem(hdlg, LD_SOCKET), FALSE); // Grey Socket Edit control
00494     return (TRUE);
00495 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/ExplrBar.Cpp Source File

  • WinUI
  • Shell
  • BandObjs

ExplrBar.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ExplorerBar.cpp
00013
00014    Description:   Implements CExplorerBar
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ExplrBar.h"
00023 #include "Guid.h"
00024
00025 /**************************************************************************
00026
00027    CExplorerBar::CExplorerBar()
00028
00029 **************************************************************************/
00030
00031 CExplorerBar::CExplorerBar()
00032 {
00033 m_pSite = NULL;
00034
00035 m_hWnd = NULL;
00036 m_hwndParent = NULL;
00037
00038 m_bFocus = FALSE;
00039
00040 m_dwViewMode = 0;
00041 m_dwBandID = 0;
00042
00043 m_ObjRefCount = 1;
00044 g_DllRefCount++;
00045 }
00046
00047 /**************************************************************************
00048
00049    CExplorerBar::~CExplorerBar()
00050
00051 **************************************************************************/
00052
00053 CExplorerBar::~CExplorerBar()
00054 {
00055 //this should have been freed in a call to SetSite(NULL), but just to be safe
00056 if(m_pSite)
00057    {
00058    m_pSite->Release();
00059    m_pSite = NULL;
00060    }
00061
00062 g_DllRefCount--;
00063 }
00064
00065 ///////////////////////////////////////////////////////////////////////////
00066 //
00067 // IUnknown Implementation
00068 //
00069
00070 /**************************************************************************
00071
00072    CExplorerBar::QueryInterface
00073
00074 **************************************************************************/
00075
00076 STDMETHODIMP CExplorerBar::QueryInterface(REFIID riid, LPVOID *ppReturn)
00077 {
00078 *ppReturn = NULL;
00079
00080 //IUnknown
00081 if(IsEqualIID(riid, IID_IUnknown))
00082    {
00083    *ppReturn = this;
00084    }
00085
00086 //IOleWindow
00087 else if(IsEqualIID(riid, IID_IOleWindow))
00088    {
00089    *ppReturn = (IOleWindow*)this;
00090    }
00091
00092 //IDockingWindow
00093 else if(IsEqualIID(riid, IID_IDockingWindow))
00094    {
00095    *ppReturn = (IDockingWindow*)this;
00096    }
00097
00098 //IInputObject
00099 else if(IsEqualIID(riid, IID_IInputObject))
00100    {
00101    *ppReturn = (IInputObject*)this;
00102    }
00103
00104 //IObjectWithSite
00105 else if(IsEqualIID(riid, IID_IObjectWithSite))
00106    {
00107    *ppReturn = (IObjectWithSite*)this;
00108    }
00109
00110 //IDeskBand
00111 else if(IsEqualIID(riid, IID_IDeskBand))
00112    {
00113    *ppReturn = (IDeskBand*)this;
00114    }
00115
00116 //IPersist
00117 else if(IsEqualIID(riid, IID_IPersist))
00118    {
00119    *ppReturn = (IPersist*)this;
00120    }
00121
00122 //IPersistStream
00123 else if(IsEqualIID(riid, IID_IPersistStream))
00124    {
00125    *ppReturn = (IPersistStream*)this;
00126    }
00127
00128 if(*ppReturn)
00129    {
00130    (*(LPUNKNOWN*)ppReturn)->AddRef();
00131    return S_OK;
00132    }
00133
00134 return E_NOINTERFACE;
00135 }
00136
00137 /**************************************************************************
00138
00139    CExplorerBar::AddRef
00140
00141 **************************************************************************/
00142
00143 STDMETHODIMP_(DWORD) CExplorerBar::AddRef()
00144 {
00145 return ++m_ObjRefCount;
00146 }
00147
00148
00149 /**************************************************************************
00150
00151    CExplorerBar::Release
00152
00153 **************************************************************************/
00154
00155 STDMETHODIMP_(DWORD) CExplorerBar::Release()
00156 {
00157 if(--m_ObjRefCount == 0)
00158    {
00159    delete this;
00160    return 0;
00161    }
00162
00163 return m_ObjRefCount;
00164 }
00165
00166 ///////////////////////////////////////////////////////////////////////////
00167 //
00168 // IOleWindow Implementation
00169 //
00170
00171 /**************************************************************************
00172
00173    CExplorerBar::GetWindow()
00174
00175 **************************************************************************/
00176
00177 STDMETHODIMP CExplorerBar::GetWindow(HWND *phWnd)
00178 {
00179 *phWnd = m_hWnd;
00180
00181 return S_OK;
00182 }
00183
00184 /**************************************************************************
00185
00186    CExplorerBar::ContextSensitiveHelp()
00187
00188 **************************************************************************/
00189
00190 STDMETHODIMP CExplorerBar::ContextSensitiveHelp(BOOL fEnterMode)
00191 {
00192 return E_NOTIMPL;
00193 }
00194
00195 ///////////////////////////////////////////////////////////////////////////
00196 //
00197 // IDockingWindow Implementation
00198 //
00199
00200 /**************************************************************************
00201
00202    CExplorerBar::ShowDW()
00203
00204 **************************************************************************/
00205
00206 STDMETHODIMP CExplorerBar::ShowDW(BOOL fShow)
00207 {
00208 if(m_hWnd)
00209    {
00210    if(fShow)
00211       {
00212       //show our window
00213       ShowWindow(m_hWnd, SW_SHOW);
00214       }
00215    else
00216       {
00217       //hide our window
00218       ShowWindow(m_hWnd, SW_HIDE);
00219       }
00220    }
00221
00222 return S_OK;
00223 }
00224
00225 /**************************************************************************
00226
00227    CExplorerBar::CloseDW()
00228
00229 **************************************************************************/
00230
00231 STDMETHODIMP CExplorerBar::CloseDW(DWORD dwReserved)
00232 {
00233 ShowDW(FALSE);
00234
00235 if(IsWindow(m_hWnd))
00236    DestroyWindow(m_hWnd);
00237
00238 m_hWnd = NULL;
00239
00240 return S_OK;
00241 }
00242
00243 /**************************************************************************
00244
00245    CExplorerBar::ResizeBorderDW()
00246
00247 **************************************************************************/
00248
00249 STDMETHODIMP CExplorerBar::ResizeBorderDW(   LPCRECT prcBorder,
00250                                           IUnknown* punkSite,
00251                                           BOOL fReserved)
00252 {
00253 /*
00254 This method is never called for Band Objects.
00255 */
00256 return E_NOTIMPL;
00257 }
00258
00259 ///////////////////////////////////////////////////////////////////////////
00260 //
00261 // IInputObject Implementation
00262 //
00263
00264 /**************************************************************************
00265
00266    CExplorerBar::UIActivateIO()
00267
00268 **************************************************************************/
00269
00270 STDMETHODIMP CExplorerBar::UIActivateIO(BOOL fActivate, LPMSG pMsg)
00271 {
00272 if(fActivate)
00273    SetFocus(m_hWnd);
00274
00275 return S_OK;
00276 }
00277
00278 /**************************************************************************
00279
00280    CExplorerBar::HasFocusIO()
00281
00282    If this window or one of its decendants has the focus, return S_OK. Return
00283    S_FALSE if we don't have the focus.
00284
00285 **************************************************************************/
00286
00287 STDMETHODIMP CExplorerBar::HasFocusIO(void)
00288 {
00289 if(m_bFocus)
00290    return S_OK;
00291
00292 return S_FALSE;
00293 }
00294
00295 /**************************************************************************
00296
00297    CExplorerBar::TranslateAcceleratorIO()
00298
00299    If the accelerator is translated, return S_OK or S_FALSE otherwise.
00300
00301 **************************************************************************/
00302
00303 STDMETHODIMP CExplorerBar::TranslateAcceleratorIO(LPMSG pMsg)
00304 {
00305 return S_FALSE;
00306 }
00307
00308 ///////////////////////////////////////////////////////////////////////////
00309 //
00310 // IObjectWithSite implementations
00311 //
00312
00313 /**************************************************************************
00314
00315    CExplorerBar::SetSite()
00316
00317 **************************************************************************/
00318
00319 STDMETHODIMP CExplorerBar::SetSite(IUnknown* punkSite)
00320 {
00321 //If a site is being held, release it.
00322 if(m_pSite)
00323    {
00324    m_pSite->Release();
00325    m_pSite = NULL;
00326    }
00327
00328 //If punkSite is not NULL, a new site is being set.
00329 if(punkSite)
00330    {
00331    //Get the parent window.
00332    IOleWindow  *pOleWindow;
00333
00334    m_hwndParent = NULL;
00335
00336    if(SUCCEEDED(punkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow)))
00337       {
00338       pOleWindow->GetWindow(&m_hwndParent);
00339       pOleWindow->Release();
00340       }
00341
00342    if(!m_hwndParent)
00343       return E_FAIL;
00344
00345    if(!RegisterAndCreateWindow())
00346       return E_FAIL;
00347
00348    //Get and keep the IInputObjectSite pointer.
00349    if(SUCCEEDED(punkSite->QueryInterface(IID_IInputObjectSite, (LPVOID*)&m_pSite)))
00350       {
00351       return S_OK;
00352       }
00353
00354    return E_FAIL;
00355    }
00356
00357 return S_OK;
00358 }
00359
00360 /**************************************************************************
00361
00362    CExplorerBar::GetSite()
00363
00364 **************************************************************************/
00365
00366 STDMETHODIMP CExplorerBar::GetSite(REFIID riid, LPVOID *ppvReturn)
00367 {
00368 *ppvReturn = NULL;
00369
00370 if(m_pSite)
00371    return m_pSite->QueryInterface(riid, ppvReturn);
00372
00373 return E_FAIL;
00374 }
00375
00376 ///////////////////////////////////////////////////////////////////////////
00377 //
00378 // IDeskBand implementation
00379 //
00380
00381 /**************************************************************************
00382
00383    CExplorerBar::GetBandInfo()
00384
00385 **************************************************************************/
00386
00387 STDMETHODIMP CExplorerBar::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi)
00388 {
00389 if(pdbi)
00390    {
00391    m_dwBandID = dwBandID;
00392    m_dwViewMode = dwViewMode;
00393
00394    if(pdbi->dwMask & DBIM_MINSIZE)
00395       {
00396       pdbi->ptMinSize.x = MIN_SIZE_X;
00397       pdbi->ptMinSize.y = MIN_SIZE_Y;
00398       }
00399
00400    if(pdbi->dwMask & DBIM_MAXSIZE)
00401       {
00402       pdbi->ptMaxSize.x = -1;
00403       pdbi->ptMaxSize.y = -1;
00404       }
00405
00406    if(pdbi->dwMask & DBIM_INTEGRAL)
00407       {
00408       pdbi->ptIntegral.x = 1;
00409       pdbi->ptIntegral.y = 1;
00410       }
00411
00412    if(pdbi->dwMask & DBIM_ACTUAL)
00413       {
00414       pdbi->ptActual.x = 0;
00415       pdbi->ptActual.y = 0;
00416       }
00417
00418    if(pdbi->dwMask & DBIM_TITLE)
00419       {
00420       lstrcpyW(pdbi->wszTitle, L"Sample Explorer Bar");
00421       }
00422
00423    if(pdbi->dwMask & DBIM_MODEFLAGS)
00424       {
00425       pdbi->dwModeFlags = DBIMF_VARIABLEHEIGHT;
00426       }
00427
00428    if(pdbi->dwMask & DBIM_BKCOLOR)
00429       {
00430       //Use the default background color by removing this flag.
00431       pdbi->dwMask &= ~DBIM_BKCOLOR;
00432       }
00433
00434    return S_OK;
00435    }
00436
00437 return E_INVALIDARG;
00438 }
00439
00440 ///////////////////////////////////////////////////////////////////////////
00441 //
00442 // IPersistStream implementations
00443 //
00444 // This is only supported to allow the desk band to be dropped on the
00445 // desktop and to prevent multiple instances of the desk band from showing
00446 // up in the context menu. This desk band doesn't actually persist any data.
00447 //
00448
00449 /**************************************************************************
00450
00451    CExplorerBar::GetClassID()
00452
00453 **************************************************************************/
00454
00455 STDMETHODIMP CExplorerBar::GetClassID(LPCLSID pClassID)
00456 {
00457 *pClassID = CLSID_SampleExplorerBar;
00458
00459 return S_OK;
00460 }
00461
00462 /**************************************************************************
00463
00464    CExplorerBar::IsDirty()
00465
00466 **************************************************************************/
00467
00468 STDMETHODIMP CExplorerBar::IsDirty(void)
00469 {
00470 return S_FALSE;
00471 }
00472
00473 /**************************************************************************
00474
00475    CExplorerBar::Load()
00476
00477 **************************************************************************/
00478
00479 STDMETHODIMP CExplorerBar::Load(LPSTREAM pStream)
00480 {
00481 return S_OK;
00482 }
00483
00484 /**************************************************************************
00485
00486    CExplorerBar::Save()
00487
00488 **************************************************************************/
00489
00490 STDMETHODIMP CExplorerBar::Save(LPSTREAM pStream, BOOL fClearDirty)
00491 {
00492 return S_OK;
00493 }
00494
00495 /**************************************************************************
00496
00497    CExplorerBar::GetSizeMax()
00498
00499 **************************************************************************/
00500
00501 STDMETHODIMP CExplorerBar::GetSizeMax(ULARGE_INTEGER *pul)
00502 {
00503 return E_NOTIMPL;
00504 }
00505
00506 ///////////////////////////////////////////////////////////////////////////
00507 //
00508 // private method implementations
00509 //
00510
00511 /**************************************************************************
00512
00513    CExplorerBar::WndProc()
00514
00515 **************************************************************************/
00516
00517 LRESULT CALLBACK CExplorerBar::WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
00518 {
00519 CExplorerBar  *pThis = (CExplorerBar*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
00520
00521 switch (uMessage)
00522    {
00523    case WM_NCCREATE:
00524       {
00525       LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00526       pThis = (CExplorerBar*)(lpcs->lpCreateParams);
00527       SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);
00528
00529       //set the window handle
00530       pThis->m_hWnd = hWnd;
00531       }
00532       break;
00533
00534    case WM_PAINT:
00535       return pThis->OnPaint();
00536
00537    case WM_COMMAND:
00538       return pThis->OnCommand(wParam, lParam);
00539
00540    case WM_SETFOCUS:
00541       return pThis->OnSetFocus();
00542
00543    case WM_KILLFOCUS:
00544       return pThis->OnKillFocus();
00545    }
00546
00547 return DefWindowProc(hWnd, uMessage, wParam, lParam);
00548 }
00549
00550 /**************************************************************************
00551
00552    CExplorerBar::OnPaint()
00553
00554 **************************************************************************/
00555
00556 LRESULT CExplorerBar::OnPaint(void)
00557 {
00558 PAINTSTRUCT ps;
00559 RECT        rc;
00560
00561 BeginPaint(m_hWnd, &ps);
00562
00563 GetClientRect(m_hWnd, &rc);
00564 SetTextColor(ps.hdc, RGB(255, 255, 255));
00565 SetBkMode(ps.hdc, TRANSPARENT);
00566 DrawText(ps.hdc, TEXT("Sample Explorer Bar"), -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
00567
00568 EndPaint(m_hWnd, &ps);
00569
00570 return 0;
00571 }
00572
00573 /**************************************************************************
00574
00575    CExplorerBar::OnCommand()
00576
00577 **************************************************************************/
00578
00579 LRESULT CExplorerBar::OnCommand(WPARAM wParam, LPARAM lParam)
00580 {
00581 return 0;
00582 }
00583
00584 /**************************************************************************
00585
00586    CExplorerBar::FocusChange()
00587
00588 **************************************************************************/
00589
00590 void CExplorerBar::FocusChange(BOOL bFocus)
00591 {
00592 m_bFocus = bFocus;
00593
00594 //inform the input object site that the focus has changed
00595 if(m_pSite)
00596    {
00597    m_pSite->OnFocusChangeIS((IDockingWindow*)this, bFocus);
00598    }
00599 }
00600
00601 /**************************************************************************
00602
00603    CExplorerBar::OnSetFocus()
00604
00605 **************************************************************************/
00606
00607 LRESULT CExplorerBar::OnSetFocus(void)
00608 {
00609 FocusChange(TRUE);
00610
00611 return 0;
00612 }
00613
00614 /**************************************************************************
00615
00616    CExplorerBar::OnKillFocus()
00617
00618 **************************************************************************/
00619
00620 LRESULT CExplorerBar::OnKillFocus(void)
00621 {
00622 FocusChange(FALSE);
00623
00624 return 0;
00625 }
00626
00627 /**************************************************************************
00628
00629    CExplorerBar::RegisterAndCreateWindow()
00630
00631 **************************************************************************/
00632
00633 BOOL CExplorerBar::RegisterAndCreateWindow(void)
00634 {
00635 //If the window doesn't exist yet, create it now.
00636 if(!m_hWnd)
00637    {
00638    //Can't create a child window without a parent.
00639    if(!m_hwndParent)
00640       {
00641       return FALSE;
00642       }
00643
00644    //If the window class has not been registered, then do so.
00645    WNDCLASS wc;
00646    if(!GetClassInfo(g_hInst, EB_CLASS_NAME, &wc))
00647       {
00648       ZeroMemory(&wc, sizeof(wc));
00649       wc.style          = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
00650       wc.lpfnWndProc    = (WNDPROC)WndProc;
00651       wc.cbClsExtra     = 0;
00652       wc.cbWndExtra     = 0;
00653       wc.hInstance      = g_hInst;
00654       wc.hIcon          = NULL;
00655       wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
00656       wc.hbrBackground  = (HBRUSH)CreateSolidBrush(RGB(0, 0, 192));
00657       wc.lpszMenuName   = NULL;
00658       wc.lpszClassName  = EB_CLASS_NAME;
00659
00660       if(!RegisterClass(&wc))
00661          {
00662          //If RegisterClass fails, CreateWindow below will fail.
00663          }
00664       }
00665
00666    RECT  rc;
00667
00668    GetClientRect(m_hwndParent, &rc);
00669
00670    //Create the window. The WndProc will set m_hWnd.
00671    CreateWindowEx(   0,
00672                      EB_CLASS_NAME,
00673                      NULL,
00674                      WS_CHILD | WS_CLIPSIBLINGS | WS_BORDER,
00675                      rc.left,
00676                      rc.top,
00677                      rc.right - rc.left,
00678                      rc.bottom - rc.top,
00679                      m_hwndParent,
00680                      NULL,
00681                      g_hInst,
00682                      (LPVOID)this);
00683
00684    }
00685
00686 return (NULL != m_hWnd);
00687 }
00688
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/about.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

about.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Implementation of ISnapinAbout
00014 //
00015
00016
00017 #include "Globals.h"
00018 #include "About.h"
00019 #include "Resource.h"
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 //  Construction/Destruction
00023
00024 //---------------------------------------------------------------------------
00025 CSnapinAbout::CSnapinAbout()
00026 {
00027   m_cRef = 0;
00028   InterlockedIncrement((long*)&g_uObjectCount);
00029
00030   m_hSmallImage = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_16), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00031   m_hLargeImage = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_32), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00032
00033   // This image is displayed when the static node is selected
00034   m_hOpenImage  = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_16), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00035
00036   m_hAppIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_APP_ICON));
00037 }
00038
00039 CSnapinAbout::~CSnapinAbout()
00040 {
00041   SAFE_FREE_BITMAP( m_hSmallImage );
00042   SAFE_FREE_BITMAP( m_hLargeImage );
00043   SAFE_FREE_BITMAP( m_hOpenImage  );
00044   SAFE_FREE_ICON( m_hAppIcon );
00045
00046   InterlockedDecrement((long*)&g_uObjectCount);
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // IUnknown implementation
00051
00052 //---------------------------------------------------------------------------
00053 STDMETHODIMP CSnapinAbout::QueryInterface
00054 (
00055   REFIID   riid,       //[in] Identifier of the requested interface
00056   LPVOID   *ppv        //[out] Address of requested interface
00057 )
00058 {
00059   if( !ppv )
00060     return E_FAIL;
00061
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065     *ppv = static_cast<ISnapinAbout*>(this);
00066   else if( IsEqualIID(riid, IID_ISnapinAbout) )
00067     *ppv = static_cast<ISnapinAbout*>(this);
00068
00069   if( *ppv )
00070   {
00071     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00072     return S_OK;
00073   }
00074
00075   return E_NOINTERFACE;
00076 }
00077
00078 //---------------------------------------------------------------------------
00079 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00080 {
00081   return InterlockedIncrement((long*)&m_cRef);
00082 }
00083
00084 //---------------------------------------------------------------------------
00085 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00086 {
00087   if( 0 == InterlockedDecrement((long*)&m_cRef) )
00088   {
00089     // we need to decrement our object count in the DLL
00090     delete this;
00091     return 0;
00092   }
00093   return m_cRef;
00094 }
00095
00096
00097 /////////////////////////////////////////////////////////////////////////////
00098 // Interface ISnapinAbout
00099
00100 //---------------------------------------------------------------------------
00101 STDMETHODIMP CSnapinAbout::GetSnapinDescription
00102 (
00103   LPOLESTR* pszDescription   //[out] Pointer to the description text
00104 )
00105 {
00106   LONG nLen = wcslen( gwszABOUT_DESCRIPTION ) + 1;
00107   *pszDescription = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00108   if( NULL == *pszDescription )
00109     return E_OUTOFMEMORY;
00110
00111   wcscpy( *pszDescription, gwszABOUT_DESCRIPTION );
00112   return S_OK;
00113 }
00114
00115 //---------------------------------------------------------------------------
00116 STDMETHODIMP CSnapinAbout::GetProvider
00117 (
00118   LPOLESTR* pszProvider      //[out] Pointer to provider text
00119 )
00120 {
00121   LONG nLen = wcslen( gwszABOUT_PROVIDER ) + 1;
00122   *pszProvider = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00123   if( NULL == *pszProvider )
00124     return E_OUTOFMEMORY;
00125
00126   wcscpy( *pszProvider, gwszABOUT_PROVIDER );
00127   return S_OK;
00128 }
00129
00130 //---------------------------------------------------------------------------
00131 STDMETHODIMP CSnapinAbout::GetSnapinVersion
00132 (
00133   LPOLESTR*  pszVersion      //[out] Pointer to version text
00134 )
00135 {
00136   LONG nLen = wcslen( gwszABOUT_VERSION ) + 1;
00137   *pszVersion = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00138   if( NULL == *pszVersion )
00139     return E_OUTOFMEMORY;
00140
00141   wcscpy( *pszVersion, gwszABOUT_VERSION );
00142   return S_OK;
00143 }
00144
00145 //---------------------------------------------------------------------------
00146 STDMETHODIMP CSnapinAbout::GetSnapinImage
00147 (
00148   HICON *hAppIcon            //[out] Pointer to the Snap-in's main icon
00149 )
00150 {
00151   *hAppIcon = m_hAppIcon;
00152   HRESULT hResult = S_FALSE;
00153   (NULL == *hAppIcon ) ? hResult = E_FAIL : hResult = S_OK;
00154
00155   return hResult;
00156 }
00157
00158 //---------------------------------------------------------------------------
00159 STDMETHODIMP CSnapinAbout::GetStaticFolderImage
00160 (
00161   HBITMAP*   hSmallImage,      //[out] Pointer to small image
00162   HBITMAP*   hOpenImage,       //[out] Pointer to open folder image
00163   HBITMAP*   hLargeImage,      //[out] Pointer to large image
00164   COLORREF*  cMask             //[out] Pointer to image color mask
00165 )
00166 {
00167   *hSmallImage = m_hSmallImage;
00168   *hLargeImage = m_hLargeImage;
00169   *hOpenImage  = m_hOpenImage;
00170   *cMask       = RGB(0, 255, 0);
00171
00172   if( NULL == *hSmallImage || NULL == *hLargeImage || NULL == *hOpenImage )
00173     return E_FAIL;
00174
00175   return S_OK;
00176 }
00177
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ICONDIRENTRY Member List

This is the complete list of members for ICONDIRENTRY, including all inherited members.
bColorCount | ICONDIRENTRY
bHeight | ICONDIRENTRY
bReserved | ICONDIRENTRY
bWidth | ICONDIRENTRY
dwBytesInRes | ICONDIRENTRY
dwImageOffset | ICONDIRENTRY
wBitCount | ICONDIRENTRY
wPlanes | ICONDIRENTRY
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/osp/vc/myospobject.cpp Source File

  • Dataaccess
  • osp
  • vc

myospobject.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample OLEDB Simple Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation.  All Rights Reserved.
00004 //
00005 // module MyOSPObject.cpp | MyOSPObject (OLEDBSimpleProvider) object implementation
00006 //
00007 //
00008
00009 ////////////////////////////////////////////////////////
00010 // Includes
00011 //
00012 ////////////////////////////////////////////////////////
00013
00014 #include "Common.h"
00015 #include "MyOSPObject.h"
00016 #include <fstream.h>
00017 #include <stdio.h>
00018 #include <tchar.h>
00019
00020 ////////////////////////////////////////////////////////
00021 // MyOSPObject
00022 //
00023 ////////////////////////////////////////////////////////
00024
00025 MyOSPObject::MyOSPObject()
00026 {
00027   //IUnknown
00028   m_cRef = 0;
00029
00030   //Member variables
00031   m_rvTable   = NULL;
00032   m_cRows     = 0;
00033   m_cColumns    = 0;
00034   m_szFilePath  = NULL;
00035 }
00036
00037
00038 MyOSPObject::~MyOSPObject()
00039 {
00040   LONG    i, j;
00041
00042   // Save the internal table to the data file:
00043   if (m_szFilePath != NULL)
00044     saveData();
00045
00046   // Walk through the internal table.  Free any
00047   // variants, each row, and finally the table.
00048   if (m_rvTable != NULL)
00049   {
00050     for (i = 0; i <= m_cRows; i++)
00051     {
00052       for (j = 1; j <= m_cColumns; j++)
00053       {
00054         if (m_rvTable[i][j].vt == VT_BSTR)
00055           SysFreeString(V_BSTR(&m_rvTable[i][j]));
00056       }
00057       CoTaskMemFree(m_rvTable[i]);
00058     }
00059     CoTaskMemFree(m_rvTable);
00060   }
00061
00062   //Remove all Listeners:
00063   while(!m_listListeners.IsEmpty())
00064     m_listListeners.RemoveHead()->Release();
00065
00066 }
00067
00068
00069 HRESULT MyOSPObject::Init(WCHAR* pwszFilePath)
00070 {
00071   // Store the name of the data file:
00072   m_szFilePath = (LPSTR)CoTaskMemAlloc(FILENAME_MAX);
00073   wcstombs(m_szFilePath, pwszFilePath, FILENAME_MAX);
00074
00075   // Load the file into a table:
00076   return loadData();
00077 }
00078
00079
00080 HRESULT MyOSPObject::QueryInterface(REFIID riid, void** ppv)
00081 {
00082   if (ppv == NULL)
00083     return E_INVALIDARG;
00084
00085   // IUnknown:
00086   if (riid == IID_IUnknown)
00087     *ppv = this;
00088
00089   // OLEDBSimpleProvider:
00090   else if (riid == IID_OLEDBSimpleProvider)
00091     *ppv = this;
00092
00093   // Unsupported:
00094   else
00095   {
00096     *ppv = NULL;
00097     return E_NOINTERFACE;
00098   }
00099
00100   SAFE_ADDREF((IUnknown*)*ppv);
00101   return S_OK;
00102 }
00103
00104 ////////////////////////////////////////////////////////
00105 // Routines to load and save table to file
00106 //
00107 ////////////////////////////////////////////////////////
00108
00109 HRESULT MyOSPObject::loadData()
00110 {
00111   ifstream  myOSPFile;
00112   int     cChar;
00113   BSTR    pwszSeps;   // separator char in file
00114   BSTR    pwszBuffer;   // -> wide character buffer
00115   BSTR    pwszRow;    // -> wide character buffer (position)
00116   BSTR    pwszToken;
00117   LPTSTR    pvInput;    // -> input buffer
00118   LPSTR   pszPos;
00119   LONG    i, j;
00120
00121   // Build the internal array by reading the file:
00122   myOSPFile.open(m_szFilePath, ios::in | ios::nocreate, filebuf::sh_none );
00123     if (!(myOSPFile.is_open()))
00124         return E_FAIL;
00125
00126   // Line 1 contains cRows ; cColumns:
00127   pvInput = new char[MAX_INPUT_BUFFER ];
00128   if (NULL == pvInput)
00129         return E_FAIL;
00130   myOSPFile.getline(pvInput, MAX_INPUT_BUFFER);
00131   pszPos = pvInput;
00132   m_cRows = strtol(pszPos, &pszPos, 10);
00133   pszPos++; // consume delimiter
00134   m_cColumns = strtol(pszPos, &pszPos, 10);
00135
00136   // allocate array of size cRows X cColumns:
00137   m_rvTable = (VARIANT**)CoTaskMemAlloc((m_cRows+1) * sizeof(VARIANT*));
00138   for (i = 0; i <= m_cRows; i++)
00139   {
00140     m_rvTable[i] = (VARIANT*)CoTaskMemAlloc((m_cColumns+1) * sizeof(VARIANT));
00141   }
00142
00143   // read the rest of the file and stuff each line into the next row:
00144   i = 0;
00145   j = 0;
00146   pwszSeps = L";";
00147   pwszBuffer = (BSTR)CoTaskMemAlloc(MAX_WIDE_BUFFER);
00148   do
00149   {
00150     myOSPFile.getline(pvInput, MAX_INPUT_BUFFER);
00151     pwszRow = pwszBuffer;
00152     MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pvInput, -1, pwszRow,
00153               MAX_WIDE_BUFFER);
00154     for (j = 1; j <= m_cColumns; j++)
00155     {
00156       if (pwszRow == NULL)
00157       {
00158         m_rvTable[i][j].vt = VT_NULL;
00159         continue;
00160       }
00161       cChar = wcscspn(pwszRow, pwszSeps);
00162       if (cChar)
00163       {
00164         pwszToken = wcstok(pwszRow, pwszSeps);
00165         m_rvTable[i][j].vt = VT_BSTR;
00166         V_BSTR(&m_rvTable[i][j]) = SysAllocString(pwszToken);
00167         pwszRow += (cChar+1);
00168       }
00169       else
00170       {
00171         m_rvTable[i][j].vt = VT_NULL;
00172         pwszRow += 1;
00173       }
00174     }
00175     i++;
00176     if (i > m_cRows)
00177       break;
00178   }
00179   while (!(myOSPFile.eof()));
00180
00181   myOSPFile.close();
00182   CoTaskMemFree(pwszBuffer);
00183   return S_OK;
00184 }
00185
00186
00187 HRESULT MyOSPObject::saveData()
00188 {
00189   HRESULT   hr = S_OK;
00190   ofstream  myOSPFile;
00191   int     nCnt;
00192   BSTR    pbstrCell;
00193   LONG    i, j;
00194   LPTSTR    pvOutput;   // -> output buffer
00195
00196   // Open the file for output:
00197   myOSPFile.open(m_szFilePath, ios::out | ios::nocreate, filebuf::sh_none);
00198     if (!(myOSPFile.is_open()))
00199         return E_FAIL;
00200
00201   pvOutput = new char[MAX_OUTPUT_BUFFER+1];
00202
00203   // Write the first line containing "rows ; columns":
00204   wsprintf(pvOutput, "%li;%li\n", m_cRows, m_cColumns);
00205   myOSPFile.write(pvOutput, lstrlen(pvOutput));
00206   myOSPFile.flush();
00207
00208   // Write the columns of each row on a line:
00209   for (i = 0; i <= m_cRows && hr == S_OK; i++)
00210   {
00211     nCnt = 0;
00212     for (j = 1; j <= m_cColumns; j++)
00213     {
00214       if (m_rvTable[i][j].vt == VT_NULL)
00215       {
00216         if ((nCnt + lstrlen(";")) >= MAX_OUTPUT_BUFFER)
00217         {
00218           hr = DB_E_DATAOVERFLOW;
00219           break;
00220         }
00221         nCnt += wsprintf(pvOutput+nCnt, ";");
00222       }
00223       else
00224       {
00225         pbstrCell = V_BSTR(&m_rvTable[i][j]);
00226         if ((nCnt + SysStringByteLen(pbstrCell)) >= MAX_OUTPUT_BUFFER)
00227         {
00228           hr = DB_E_DATAOVERFLOW;
00229           break;
00230         }
00231         nCnt += wsprintf(pvOutput+nCnt, "%ws;", pbstrCell);
00232       }
00233     }
00234     if ((nCnt + lstrlen("\n")) >= MAX_OUTPUT_BUFFER)
00235     {
00236       hr = DB_E_DATAOVERFLOW;
00237       break;
00238     }
00239     nCnt += wsprintf(pvOutput+nCnt, "\n");
00240     myOSPFile.write(pvOutput, nCnt);
00241     myOSPFile.flush();
00242   }
00243
00244   // close the file
00245   myOSPFile.close();
00246   delete pvOutput;
00247
00248   return hr;
00249 }
00250
00251 ////////////////////////////////////////////////////////
00252 // Common notification routine:  send event to each
00253 // Listener in the list.
00254 ////////////////////////////////////////////////////////
00255
00256 HRESULT MyOSPObject::Notify(EOSPEVENTS eEvent, ULONG iRow, ULONG iColumn, ULONG cRows)
00257 {
00258   //no-op case
00259   if(m_listListeners.GetCount()==0)
00260     return S_OK;
00261
00262   //obtain first element
00263   HRESULT hr = S_OK;
00264   POS pos = m_listListeners.GetHeadPosition();
00265
00266   //otherwise notify for reason/phase
00267   switch(eEvent)
00268   {
00269     //Multi-Cast
00270     case CHANGECELL_ABOUTTODO:
00271       while(pos)
00272         hr = m_listListeners.GetNext(pos)->aboutToChangeCell(iRow, iColumn);
00273       break;
00274
00275     //Multi-Cast
00276     case CHANGECELL_DIDEVENT:
00277       while(pos)
00278         hr = m_listListeners.GetNext(pos)->cellChanged(iRow, iColumn);
00279       break;
00280
00281     //Multi-Cast
00282     case DELETEROWS_ABOUTTODO:
00283       while(pos)
00284         hr = m_listListeners.GetNext(pos)->aboutToDeleteRows(iRow, cRows);
00285       break;
00286
00287     //Multi-Cast
00288     case DELETEROWS_DIDEVENT:
00289       while(pos)
00290         hr = m_listListeners.GetNext(pos)->deletedRows(iRow, cRows);
00291       break;
00292
00293     //Multi-Cast
00294     case INSERTROWS_ABOUTTODO:
00295       while(pos)
00296         hr = m_listListeners.GetNext(pos)->aboutToInsertRows(iRow, cRows);
00297       break;
00298
00299     //Multi-Cast
00300     case INSERTROWS_DIDEVENT:
00301       while(pos)
00302         hr = m_listListeners.GetNext(pos)->insertedRows(iRow, cRows);
00303       break;
00304
00305     //Multi-Cast
00306     case ROWSAVAILABLE_DIDEVENT:
00307       while(pos)
00308         hr = m_listListeners.GetNext(pos)->rowsAvailable(iRow, cRows);
00309       break;
00310
00311     //Multi-Cast
00312     case TRANSFERCOMPLETE_DIDEVENT:
00313       while(pos)
00314         hr = m_listListeners.GetNext(pos)->transferComplete(OSPXFER_COMPLETE);
00315       break;
00316
00317     //Multi-Cast
00318     case TRANSFERCOMPLETE_FAILEDTODO:
00319       while(pos)
00320         hr = m_listListeners.GetNext(pos)->transferComplete(OSPXFER_ABORT);
00321       break;
00322
00323     default:
00324       //Unknown event?
00325       break;
00326   };
00327
00328   return hr;
00329 }
00330
00331 ////////////////////////////////////////////////////////
00332 // OSPSimpleProvider implementation
00333 //
00334 ////////////////////////////////////////////////////////
00335
00336 HRESULT MyOSPObject::addOLEDBSimpleProviderListener(OLEDBSimpleProviderListener* pospIListener)
00337 {
00338   if(pospIListener==NULL)
00339     return E_INVALIDARG;
00340
00341   //Add the Listener:
00342   pospIListener->AddRef();
00343   m_listListeners.AddTail(pospIListener);
00344
00345   return S_OK;
00346 }
00347
00348 HRESULT MyOSPObject::deleteRows(LONG iRow, LONG cRows, LONG* pcRowsDeleted)
00349 {
00350   LONG    cNewRows, i, j;
00351   VARIANT** rvNewTable;
00352
00353   // Doesn't handle label or wildcard rows
00354   if (iRow <= 0)
00355     return E_FAIL;
00356
00357   // InvalidArg
00358   if (cRows < 0)
00359     return E_INVALIDARG;
00360
00361   // Is starting row within range?
00362   if (iRow > m_cRows)
00363     return E_INVALIDARG;
00364
00365   // Adjust row count to stay within range:
00366   if (iRow + cRows > m_cRows + 1)
00367     cRows = m_cRows - iRow + 1;
00368
00369   // Notify our Listeners:
00370   Notify(DELETEROWS_ABOUTTODO, iRow, -1, cRows);
00371
00372   // Allocate new array with reduced rows:
00373   cNewRows = m_cRows - cRows;
00374   rvNewTable = (VARIANT**)CoTaskMemAlloc((cNewRows+1) * sizeof(VARIANT*));
00375
00376   j = 0;
00377   for (i = 0; i <= m_cRows; i++)
00378   {
00379     if (i < iRow || i > (iRow + cRows - 1))
00380       rvNewTable[j++] = m_rvTable[i];   // retain rows
00381     else
00382       CoTaskMemFree(m_rvTable[i]);    // free deleted row
00383   }
00384
00385   // Free old table, point to new table and adjust count:
00386   CoTaskMemFree(m_rvTable);
00387   m_rvTable = rvNewTable;
00388   m_cRows = cNewRows;
00389
00390   // Save the internal table to the data file:
00391   if (m_szFilePath != NULL)
00392     saveData();
00393
00394   // Notify our Listeners:
00395   Notify(DELETEROWS_DIDEVENT, iRow, -1, cRows);
00396
00397   // Return the count of rows deleted:
00398   *pcRowsDeleted = cRows;
00399     return S_OK;
00400 }
00401
00402
00403 HRESULT MyOSPObject::find(LONG iRowStart, LONG iColumn, VARIANT val, OSPFIND findFlags, OSPCOMP compType, LONG* piRowFound)
00404 {
00405   // Check arguments:
00406   if (piRowFound == NULL)
00407     return E_INVALIDARG;
00408   if (iRowStart <= 0 || iRowStart > m_cRows)
00409     return E_FAIL;
00410   if (iColumn <= 0 || iColumn > m_cColumns)
00411     return E_FAIL;
00412
00413   // Determine search order:
00414   LONG  iRowStop = (findFlags == OSPFIND_UP || findFlags == OSPFIND_UPCASESENSITIVE) ? 0 : m_cRows+1;
00415   BOOL  fCaseSensitive = (findFlags == OSPFIND_CASESENSITIVE || findFlags == OSPFIND_UPCASESENSITIVE);
00416
00417   // Linear search through all rows:
00418   while (iRowStart != iRowStop)
00419   {
00420     LONG iCompVal = CompareVariant(&m_rvTable[iRowStart][iColumn], &val, fCaseSensitive);
00421     switch(compType)
00422     {
00423       case OSPCOMP_EQ:
00424         if (iCompVal == 0)
00425         {
00426           *piRowFound = iRowStart;
00427           return S_OK;
00428         }
00429         break;
00430
00431       case OSPCOMP_LT:
00432         if (iCompVal < 0)
00433         {
00434           *piRowFound = iRowStart;
00435           return S_OK;
00436         }
00437         break;
00438
00439       case OSPCOMP_LE:
00440         if (iCompVal <= 0)
00441         {
00442           *piRowFound = iRowStart;
00443           return S_OK;
00444         }
00445         break;
00446
00447       case OSPCOMP_GE:
00448         if (iCompVal >= 0)
00449         {
00450           *piRowFound = iRowStart;
00451           return S_OK;
00452         }
00453         break;
00454
00455       case OSPCOMP_GT:
00456         if (iCompVal > 0)
00457         {
00458           *piRowFound = iRowStart;
00459           return S_OK;
00460         }
00461         break;
00462
00463       case OSPCOMP_NE:
00464         if (iCompVal != 0)
00465         {
00466           *piRowFound = iRowStart;
00467           return S_OK;
00468         }
00469         break;
00470
00471       default:
00472         break;
00473     };
00474
00475     if (findFlags == OSPFIND_UP || findFlags == OSPFIND_UPCASESENSITIVE)
00476       iRowStart--;
00477     else
00478       iRowStart++;
00479   }
00480   *piRowFound = -1;
00481   return S_FALSE;
00482 }
00483
00484
00485 HRESULT MyOSPObject::insertRows(LONG iRow, LONG cRows, LONG* pcRowsInserted)
00486 {
00487   LONG    cNewRows, i, j, k;
00488   VARIANT** rvNewTable;
00489
00490   // Doesn't handle label or wildcard rows
00491   if (iRow <= 0)
00492     return E_FAIL;
00493
00494   // InvalidArg
00495   if (cRows < 0)
00496     return E_INVALIDARG;
00497
00498   // If called to insert after the end, adjust to insert at the end:
00499   if (iRow > m_cRows)
00500     iRow = m_cRows + 1;
00501
00502   // Notify our Listeners:
00503   Notify(INSERTROWS_ABOUTTODO, iRow, -1, cRows);
00504
00505   // Allocate new array with more rows:
00506   cNewRows = m_cRows + cRows;
00507   rvNewTable = (VARIANT**)CoTaskMemAlloc((cNewRows+1) * sizeof(VARIANT*));
00508   j = 0;
00509   for (i = 0; i <= cNewRows; i++)
00510   {
00511     if (i < iRow || i > (iRow + cRows - 1))
00512       rvNewTable[i] = m_rvTable[j++];   // retain rows
00513     else
00514     {                   // insert new empty row
00515       rvNewTable[i] = (VARIANT*)CoTaskMemAlloc((m_cColumns+1) * sizeof(VARIANT));
00516       for (k = 0; k <= m_cColumns; k++) // initialize new columns
00517         rvNewTable[i][k].vt = VT_NULL;
00518     }
00519   }
00520
00521   // Free old table, point to new table and adjust count:
00522   CoTaskMemFree(m_rvTable);
00523   m_rvTable = rvNewTable;
00524   m_cRows = cNewRows;
00525
00526   // Save the internal table to the data file:
00527   if (m_szFilePath != NULL)
00528     saveData();
00529
00530   // Notify our Listeners:
00531   Notify(INSERTROWS_DIDEVENT, iRow, -1, cRows);
00532
00533   // Return the count of rows inserted:
00534   *pcRowsInserted = cRows;
00535   return S_OK;
00536 }
00537
00538
00539 HRESULT MyOSPObject::getColumnCount(LONG* pcColumns)
00540 {
00541   if (pcColumns == NULL)
00542     return E_INVALIDARG;
00543   *pcColumns = m_cColumns;
00544   return S_OK;
00545 }
00546
00547
00548 HRESULT MyOSPObject::getEstimatedRows(LONG* piRows)
00549 {
00550   return getRowCount(piRows);
00551 }
00552
00553
00554 HRESULT MyOSPObject::getLocale(BSTR* pbstrLocale)
00555 {
00556   if (pbstrLocale == NULL)
00557     return E_INVALIDARG;
00558
00559   // Return default locale:
00560   TCHAR* pszLocale;
00561   int cchData = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SLANGUAGE, NULL, 0);
00562   pszLocale = (TCHAR*)CoTaskMemAlloc(cchData * sizeof(TCHAR));
00563   if (pszLocale)
00564   {
00565     BSTR bstr = SysAllocStringLen(NULL, cchData);
00566     GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SLANGUAGE, pszLocale, cchData);
00567 #if !defined(_UNICODE)
00568     bstr = SysAllocStringLen(NULL, cchData);
00569     mbstowcs(bstr, pszLocale, cchData);
00570 #else
00571     bstr = SysAllocStringLen(pszLocale, cchData);
00572 #endif
00573     *pbstrLocale = bstr;
00574   }
00575   return S_OK;
00576 }
00577
00578
00579 HRESULT MyOSPObject::getRowCount(LONG* pcRows)
00580 {
00581   if (pcRows == NULL)
00582     return E_INVALIDARG;
00583   *pcRows = m_cRows;
00584   return S_OK;
00585 }
00586
00587
00588 HRESULT MyOSPObject::getRWStatus(LONG iRow, LONG iColumn, OSPRW* prwStatus)
00589 {
00590   if (prwStatus == NULL)
00591     return E_INVALIDARG;
00592
00593   // In this sample, column 1 is read-only.  All other columns may be changed:
00594   if (iColumn == 1)
00595     *prwStatus = OSPRW_READONLY;
00596   else
00597     *prwStatus = OSPRW_READWRITE;
00598
00599   return S_OK;
00600 }
00601
00602
00603 HRESULT MyOSPObject::getVariant(LONG iRow, LONG iColumn, OSPFORMAT format, VARIANT* pVar)
00604 {
00605   //INVALIDARG
00606   if (pVar == NULL)
00607     return E_INVALIDARG;
00608
00609   //Doesn't handle wildcards
00610   if (iRow < 0 || iColumn < 0)
00611     return E_FAIL;
00612
00613   //Get Column Value
00614   VariantCopy(pVar, &m_rvTable[iRow][iColumn]);
00615   return S_OK;
00616 }
00617
00618
00619 HRESULT MyOSPObject::isAsync(BOOL* pbAsynch)
00620 {
00621   if(pbAsynch==NULL)
00622     return E_INVALIDARG;
00623
00624   *pbAsynch = FALSE;
00625   return S_OK;
00626 }
00627
00628
00629 HRESULT MyOSPObject::removeOLEDBSimpleProviderListener(OLEDBSimpleProviderListener* pospIListener)
00630 {
00631   if(pospIListener==NULL)
00632     return E_INVALIDARG;
00633
00634   //Find the Listener in the list:
00635   POS pos = m_listListeners.Find(pospIListener);
00636   if (pos == NULL)
00637     return E_FAIL;
00638
00639   //Remove the Listener from the list and release it:
00640   SAFE_RELEASE(pospIListener);
00641   m_listListeners.RemoveAt(pos);
00642
00643   return S_OK;
00644 }
00645
00646 HRESULT MyOSPObject::setVariant(LONG iRow, LONG iColumn, OSPFORMAT format, VARIANT Var)
00647 {
00648   // Doesn't handle wildcards
00649   if (iRow < 0 || iColumn < 0)
00650     return E_FAIL;
00651
00652   // Notify our Listeners:
00653   Notify(CHANGECELL_ABOUTTODO, iRow, iColumn, 1);
00654
00655   // Set Column Value
00656   VariantCopy(&m_rvTable[iRow][iColumn], &Var);
00657
00658   // Save the internal table to the data file:
00659   if (m_szFilePath != NULL)
00660     saveData();
00661
00662   // Notify our Listeners:
00663   Notify(CHANGECELL_DIDEVENT, iRow, iColumn, 1);
00664
00665   return S_OK;
00666 }
00667
00668
00669 HRESULT MyOSPObject::stopTransfer()
00670 {
00671   // Do nothing because we are already populated
00672   return S_OK;
00673 }
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMyWizExtModule Member List

This is the complete list of members for CMyWizExtModule, including all inherited members.
UpdateRegistryCLSID(const CLSID &clsid, BOOL bRegister) CMyWizExtModule
Generated on Wed Nov 13 2024 16:56:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/io/SyncWrite/openf.c Source File

  • Web
  • iis
  • extensions
  • io
  • SyncWrite

openf.c

Go to the documentation of this file.
00001 /* Copyright (c) 1995-2002 Microsoft Corporation
00002
00003   Module Name:
00004
00005     openf.c
00006
00007   Abstract:
00008
00009     This module implements a simple open file handle cache
00010 */
00011
00012 #include "openf.h"
00013
00014 /* internal data structure for maintaining the list of open file handles. */
00015
00016 typedef struct _OPEN_FILE {
00017
00018   HANDLE  hFile;
00019   struct _OPEN_FILE * pNext;
00020   LONG    nHits;
00021   LONG    nRefs;
00022   CHAR    rgchFile[MAX_PATH + 1];
00023
00024 } OPEN_FILE, *LPOPEN_FILE;
00025
00026 LPOPEN_FILE g_pOpenFiles = NULL;
00027 CRITICAL_SECTION g_csOpenFiles;
00028
00029 /* Set up global variables containing the flags for CreateFile. The flags can be masked for Windows 95 system */
00030
00031 DWORD  g_dwCreateFileShareMode = (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE);
00032 DWORD  g_dwCreateFileFlags = (FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED);
00033
00034 VOID InitFileHandleCache(VOID)
00035 {
00036   InitializeCriticalSection(&g_csOpenFiles);
00037 }
00038
00039 DWORD CleanupFileHandleCache(VOID)
00040 {
00041   LPOPEN_FILE  pFileScan;
00042
00043   while (g_pOpenFiles != NULL) {
00044
00045     pFileScan = g_pOpenFiles;
00046
00047     g_pOpenFiles = g_pOpenFiles->pNext;
00048
00049     if (pFileScan->hFile != INVALID_HANDLE_VALUE)
00050       CloseHandle( pFileScan->hFile);
00051
00052     LocalFree(pFileScan);
00053   }
00054
00055   DeleteCriticalSection(&g_csOpenFiles);
00056
00057   return NO_ERROR;
00058 }
00059
00060 /*
00061   Description:
00062
00063     This function opens the file specified in the 'pszFile'.
00064     If the file name starts with a '/' we use the ECB to map
00065     the given path into a physical file path.
00066
00067   Arguments:
00068
00069     pecb - pointer to the ECB block
00070     pszFile - pointer to file name
00071
00072   Returns:
00073
00074     valid File handle on success
00075 */
00076
00077 HANDLE FcOpenFile(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile)
00078 {
00079   LPOPEN_FILE pFileScan;
00080   HANDLE hFile = INVALID_HANDLE_VALUE;
00081
00082   EnterCriticalSection(&g_csOpenFiles);
00083
00084   for (pFileScan =  g_pOpenFiles; NULL != pFileScan; pFileScan = pFileScan->pNext) {
00085
00086     if (0 == lstrcmpi(pFileScan->rgchFile, pszFile)) {
00087
00088       /* there is a file match. */
00089
00090       break;
00091     }
00092   }
00093
00094   if (NULL == pFileScan) {
00095
00096     /* File was not found. Create a new file handle */
00097
00098     CHAR rgchFileName[ MAX_PATH]; /* local copy */
00099     LPCSTR pszInputPath = pszFile;
00100
00101     lstrcpyn(rgchFileName, pszFile, MAX_PATH);
00102
00103     if (*pszFile == '/') {
00104
00105       DWORD cbSize = sizeof(rgchFileName);
00106       BOOL fRet;
00107
00108       /* reset the file pointer, so subsequent use will fail */
00109
00110       pszFile = NULL;
00111
00112       /* Using the ECB map the Virtual path to the Physical path */
00113
00114       fRet = pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_MAP_URL_TO_PATH, rgchFileName, &cbSize, NULL);
00115
00116       if (fRet) {
00117
00118           /* we got the mapping. Use it. */
00119
00120           pszFile = rgchFileName;
00121       }
00122     }
00123
00124     if (NULL != pszFile) {
00125
00126       pFileScan = LocalAlloc(LPTR, sizeof(*pFileScan));
00127
00128       if (NULL != pFileScan) {
00129
00130         SECURITY_ATTRIBUTES sa;
00131
00132         sa.nLength = sizeof(sa);
00133         sa.lpSecurityDescriptor = NULL;
00134         sa.bInheritHandle = FALSE;
00135
00136         pFileScan->hFile = CreateFile(pszFile, GENERIC_READ, g_dwCreateFileShareMode, &sa, OPEN_EXISTING, g_dwCreateFileFlags, NULL);
00137
00138         if (INVALID_HANDLE_VALUE == pFileScan->hFile) {
00139
00140           LocalFree(pFileScan);
00141
00142           pFileScan = NULL;
00143
00144         } else {
00145
00146           /* insert this into the list at the top */
00147
00148           lstrcpyn(pFileScan->rgchFile, pszInputPath, MAX_PATH);
00149
00150           pFileScan->pNext = g_pOpenFiles;
00151
00152           g_pOpenFiles = pFileScan;
00153
00154           pFileScan->nRefs = 1;
00155           pFileScan->nHits = 0;
00156         }
00157       }
00158     }
00159   }
00160
00161   if (NULL != pFileScan) {
00162
00163     hFile = pFileScan->hFile;
00164
00165     pFileScan->nHits++;
00166     pFileScan->nRefs++;
00167   }
00168
00169   LeaveCriticalSection(&g_csOpenFiles);
00170
00171   return hFile;
00172 }
00173
00174 DWORD FcCloseFile(IN HANDLE hFile)
00175 {
00176   LPOPEN_FILE pFileScan;
00177   DWORD dwError = NO_ERROR;
00178
00179   EnterCriticalSection(&g_csOpenFiles);
00180
00181   /* Look for the handle and decrement the ref count. */
00182
00183   for (pFileScan = g_pOpenFiles; NULL != pFileScan; pFileScan = pFileScan->pNext) {
00184
00185     if ( hFile == pFileScan->hFile) {
00186
00187       /*  there is a file match. */
00188
00189       pFileScan->nRefs--;
00190
00191       /*
00192         Note: This is example code. Do not use for production, as there
00193         is no freeing of the file when Ref hits 0
00194       */
00195
00196       break;
00197     }
00198   }
00199
00200   if (NULL == pFileScan) {
00201
00202     /* file handle not found */
00203
00204     dwError = (ERROR_INVALID_HANDLE);
00205   }
00206
00207   LeaveCriticalSection(&g_csOpenFiles);
00208
00209   return dwError;
00210 }
00211
00212 /*
00213   Description:
00214
00215     Reads contents of file [hFile] from the specified offset in the overlapped
00216     structure. The contents are read into the buffer supplied.
00217
00218   Arguments:
00219
00220     hFile        - handle for the File from which to read data
00221     pchBuffer    - pointer to the buffer into which the data is to be read
00222     dwBufferSize - DWORD containing the max size of the buffer supplied
00223     pcbRead      - number of bytes read from the file
00224     pov          - pointer to an overlapped structure that contains the
00225                     offset from where to read the contents. The
00226                     overlapped structure also is used for Overlapped
00227                     IO in NT.
00228
00229   Notes:
00230
00231     This function automatically handles both Windows 95 and NT
00232
00233   Returns:
00234
00235     TRUE on success and FALSE if there is a failure.
00236     Use GetLastError() to get the last error code on failure.
00237 */
00238
00239 BOOL FcReadFromFile(IN HANDLE hFile, OUT CHAR *pchBuffer, IN DWORD dwBufferSize, OUT LPDWORD pcbRead, IN OUT LPOVERLAPPED pov)
00240 {
00241   BOOL fRet = TRUE;
00242
00243   *pcbRead = 0;
00244
00245   ResetEvent(pov->hEvent);
00246
00247   /* read data from file */
00248
00249   if (!ReadFile(hFile, pchBuffer, dwBufferSize, pcbRead, pov)) {
00250
00251     DWORD err = GetLastError();
00252
00253     if ((err != ERROR_IO_PENDING) || !GetOverlappedResult(hFile, pov, pcbRead, TRUE))
00254       fRet = FALSE;
00255   }
00256
00257   if (fRet)
00258     pov->Offset += *pcbRead;
00259
00260   return fRet;
00261 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/FileView.Cpp Source File

  • WinUI
  • Shell
  • FileView

FileView.Cpp

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //    PROGRAM: FILEVIEW.CPP
00009 //
00010 //    PURPOSE:   File Viewer Component Object to work with Windows 95 Explorer.
00011 // This file contains functions not specific to the nature of
00012 // the data to view but contains the non-file-specific DLL
00013 // and component object structure.  This can be used for a
00014 // custom viewer by making modifications marked with //MODIFY
00015 // comments.
00016 //
00017 //    PLATFORMS:    Windows 95
00018 //
00019 //    SPECIAL INSTRUCTIONS: N/A
00020 //
00021
00022 //Define INITGUIDS once in entire module build
00023 #define INITGUIDS
00024 #include "fileview.h"
00025
00026 #include <initguid.h>
00027 #include <shlguid.h>
00028 #include "fvtext.h"     //FileViewer specifics
00029
00030 //Count number of objects and number of locks.
00031 ULONG       g_cObj=0;
00032 ULONG       g_cLock=0;
00033
00034 //Save this from LibMain
00035 HINSTANCE   g_hInst;
00036
00037
00038 //
00039 //   FUNCTION:     LibMain
00040 //
00041 //   PURPOSE:   Entry point for a Win32 DLL
00042 //
00043 extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG ulReason
00044     , PVOID pvReserved)
00045     {
00046     if (DLL_PROCESS_DETACH==ulReason)
00047         {
00048         return TRUE;
00049         }
00050     else
00051         {
00052         if (DLL_PROCESS_ATTACH!=ulReason)
00053             return TRUE;
00054         }
00055
00056     g_hInst=hInstance;
00057     return TRUE;
00058     }
00059 //
00060 //   FUNCTION:     DllGetClassObject
00061 //
00062 //   PURPOSE:  Provides an IClassFactory for a given CLSID that this DLL is
00063 //  registered to support.  This DLL is placed under the CLSID
00064 //  in the registration database as the InProcServer.
00065 //
00066 //   PARAMETERS:
00067 //       clsID           REFCLSID that identifies the class factory
00068 //                  desired.  Since this parameter is passed this
00069 //                  DLL can handle any number of objects simply
00070 //                 by returning different class factories here
00071 //                  for different CLSIDs.
00072 //
00073 //  riid            REFIID specifying the interface the caller wants
00074 //                  on the class object, usually IID_ClassFactory.
00075 //
00076 //  ppv             PPVOID in which to return the interface pointer.
00077 //
00078 //   RETURN VALUE:
00079 //        HRESULT         NOERROR on success, otherwise an error code.
00080 //
00081 HRESULT PASCAL DllGetClassObject(REFCLSID rclsid, REFIID riid
00082     , PPVOID ppv)
00083     {
00084     // Warning:: The shell may not have initialized OLE so
00085     // do it here to be sure...
00086     OleInitialize(NULL);
00087
00088     //MODIFY:  Change CLSID_FileViewerText to your own CLSID
00089     if (!IsEqualCLSID(rclsid, CLSID_FileViewerText))
00090         return ResultFromScode(E_FAIL);
00091
00092     //Check that we can provide the interface
00093     if (!IsEqualIID(riid, IID_IUnknown)
00094         && !IsEqualIID(riid, IID_IClassFactory))
00095         return ResultFromScode(E_NOINTERFACE);
00096
00097     //Return our IClassFactory for our viewer objects
00098     *ppv=(LPVOID)new CFVClassFactory();
00099
00100     if (NULL==*ppv)
00101         return ResultFromScode(E_OUTOFMEMORY);
00102
00103     //AddRef the object through any interface we return
00104     ((LPUNKNOWN)*ppv)->AddRef();
00105
00106     return NOERROR;
00107     }
00108 //
00109 //   FUNCTION: DllCanUnloadNow
00110 //
00111 //   PURPOSE:  Answers if the DLL can be freed, that is, if there are no
00112 //    references to anything this DLL provides.
00113 //
00114 //   RETURN VALUE:
00115 //       BOOL            TRUE if nothing is using us, FALSE otherwise.
00116 //
00117 STDAPI DllCanUnloadNow(void)
00118     {
00119     SCODE   sc;
00120
00121     //Our answer is whether there are any object or locks
00122     sc=(0L==g_cObj && 0L==g_cLock) ? S_OK : S_FALSE;
00123     return ResultFromScode(sc);
00124     }
00125 //
00126 //   FUNCTION:     ObjectDestroyed
00127 //
00128 //   PURPOSE:  Function for the FileViewer object to call when it gets
00129 //  destroyed. Since we're in a DLL we only track the number of
00130 //  objects here, letting DllCanUnloadNow take care of the rest.
00131 //
00132 void PASCAL ObjectDestroyed(void)
00133     {
00134     g_cObj--;
00135     return;
00136     }
00137 //
00138 //   FUNCTION: CFVClassFactory::CFVClassFactory
00139 //
00140 //   PURPOSE:  Constructor
00141 //
00142 CFVClassFactory::CFVClassFactory(void)
00143     {
00144     m_cRef=0L;
00145     return;
00146     }
00147
00148 //
00149 //   FUNCTION: CFVClassFactory::~CFVClassFactory
00150 //
00151 //   PURPOSE:   Destructor
00152 //
00153 CFVClassFactory::~CFVClassFactory(void)
00154     {
00155     return;
00156     }
00157
00158 //
00159 //   FUNCTION:     CFVClassFactory::QueryInterface
00160 //
00161 STDMETHODIMP CFVClassFactory::QueryInterface(REFIID riid
00162     , PPVOID ppv)
00163     {
00164     *ppv=NULL;
00165
00166     //Any interface on this object is the object pointer.
00167     if (IsEqualIID(riid, IID_IUnknown)
00168         || IsEqualIID(riid, IID_IClassFactory))
00169         *ppv=(LPVOID)this;
00170
00171      // If we actually assign an interface to ppv we need to AddRef
00172      // it since we're returning a new pointer.
00173     if (NULL!=*ppv)
00174         {
00175         ((LPUNKNOWN)*ppv)->AddRef();
00176         return NOERROR;
00177         }
00178
00179     return ResultFromScode(E_NOINTERFACE);
00180     }
00181 //
00182 //   FUNCTION:     CFVClassFactory::AddRef
00183 //
00184 STDMETHODIMP_(ULONG) CFVClassFactory::AddRef(void)
00185     {
00186     return ++m_cRef;
00187     }
00188
00189 //
00190 //   FUNCTION:     CFVClassFactory::Release
00191 //
00192 STDMETHODIMP_(ULONG) CFVClassFactory::Release(void)
00193     {
00194     ULONG           cRefT;
00195
00196     cRefT=--m_cRef;
00197
00198     if (0L==m_cRef)
00199         delete this;
00200
00201     return cRefT;
00202     }
00203
00204 //
00205 //   FUNCTION:     CFVClassFactory::CreateInstance
00206 //
00207 //   PURPOSE:    Instantiates a CFileViewer object that will provide the
00208 //  IPersistFile and IFileViewer interfaces for use with the Windows 95 Explorer.
00209 //
00210 //   PARAMETERS:
00211 //  pUnkOuter       LPUNKNOWN to the controlling IUnknown if we are being used in an aggregation.
00212 //  riid            REFIID identifying the interface the caller desires to have for the new object.
00213 //  ppvObj          PPVOID in which to store the desired interface pointer for the new object.
00214 //
00215 //   RETURN VALUE:
00216 //   HRESULT         NOERROR if successful, otherwise E_NOINTERFACE
00217 //                  if we cannot support the requested interface.
00218 //
00219 STDMETHODIMP CFVClassFactory::CreateInstance(LPUNKNOWN pUnkOuter
00220     , REFIID riid, PPVOID ppvObj)
00221     {
00222     PCFileViewer        pObj;
00223     HRESULT             hr;
00224
00225     *ppvObj=NULL;
00226     hr=ResultFromScode(E_OUTOFMEMORY);
00227
00228     //Verify that a controlling unknown asks for IUnknown
00229     if (NULL!=pUnkOuter && !IsEqualIID(riid, IID_IUnknown))
00230         return ResultFromScode(E_NOINTERFACE);
00231
00232      // MODIFY:  If you use a different object than CFileViewer
00233     // be sure to change the name and parameters here.  I do
00234     // recommend that you continue to follow this model, however,
00235     // and just modify CFileViewer as necessary.
00236     //Create the object passing function to notify on destruction.
00237     pObj=new CFileViewer(pUnkOuter, g_hInst, ObjectDestroyed);
00238
00239     if (NULL==pObj)
00240         return hr;
00241
00242     //MODIFY:  Add other parameters to Init as necessary.
00243     hr=pObj->Init();
00244
00245     if (SUCCEEDED(hr))
00246         {
00247         //Return the requested interface
00248         hr=pObj->QueryInterface(riid, ppvObj);
00249
00250         if (SUCCEEDED(hr))
00251             {
00252             //Everything worked:  count the object
00253             g_cObj++;
00254             return NOERROR;
00255             }
00256         }
00257
00258     //Kill the object if anything failed after creation.
00259     delete pObj;
00260
00261     return hr;
00262     }
00263 //
00264 //   FUNCTION: CFVClassFactory::LockServer
00265 //
00266 //   PURPOSE:  Increments or decrements the lock count of the DLL.  If the
00267 //  lock count goes to zero and there are no objects, the DLL
00268 //  is allowed to unload.  See DllCanUnloadNow.
00269 //
00270 //   PARAMETERS:
00271 //    fLock           BOOL specifying whether to increment or decrement the lock count.
00272 //
00273 //   RETURN VALUE:
00274 //     HRESULT         NOERROR always
00275 //
00276 STDMETHODIMP CFVClassFactory::LockServer(BOOL fLock)
00277     {
00278     if (fLock)
00279         g_cLock++;
00280     else
00281         g_cLock--;
00282
00283     return NOERROR;
00284     }
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/DynOut/DynOuts.c Source File

  • NetDS
  • RPC
  • DynOut

DynOuts.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1995 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011 //
00012 // Copyright 1996 - 2000 Microsoft Corporation.  All Rights Reserved.
00013 //
00014 //
00015 // Sample code to show server-side
00016 // memory allocation for an [out] parameter
00017 //
00018 //
00019
00020 #include <stdio.h>
00021 #include <assert.h>
00022 #include <malloc.h>
00023 #include "dynout.h"
00024
00025 #ifdef NODEBUG
00026 #define CHECK_STATUS(x)
00027 #define TRACE(s)
00028 #else
00029 #define CHECK_STATUS(x) {if (x!=RPC_S_OK) { printf("RPC Err: %d\nfile = %s, line=%d.",x,__FILE__,__LINE__); exit(x);}}
00030 #define TRACE(s)  puts(s)
00031 #endif
00032
00033 void main(int argc,char **argv)
00034 {
00035   RPC_STATUS      rpcStatus;
00036   RPC_BINDING_VECTOR  *vectBinding;
00037   unsigned char     *szEntryName;
00038
00039   TRACE("RpcServerRegisterIf");
00040   rpcStatus=RpcServerRegisterIf(MemStuff_v1_0_s_ifspec,0,0);
00041   CHECK_STATUS(rpcStatus);
00042
00043   TRACE("RpcServerUseAllProtseqs");
00044   rpcStatus=RpcServerUseAllProtseqs(RPC_C_PROTSEQ_MAX_REQS_DEFAULT,NULL);
00045   CHECK_STATUS(rpcStatus);
00046
00047   TRACE("RpcServerInqBindings");
00048   rpcStatus=RpcServerInqBindings(&vectBinding);
00049   CHECK_STATUS(rpcStatus);
00050
00051   TRACE("RpcNsBindingExport");
00052   szEntryName="/.:/MyServer";
00053   rpcStatus=RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT,szEntryName,MemStuff_v1_0_s_ifspec,vectBinding,NULL);
00054   CHECK_STATUS(rpcStatus);
00055
00056   TRACE("RpcEpRegister");
00057   rpcStatus=RpcEpRegister(MemStuff_v1_0_s_ifspec,
00058         vectBinding,
00059         NULL,NULL);
00060   CHECK_STATUS(rpcStatus);
00061
00062   TRACE("RpcBindingVectorFree");
00063   rpcStatus=RpcBindingVectorFree(&vectBinding);
00064   CHECK_STATUS(rpcStatus);
00065
00066   puts("\n\n");
00067   puts("(C) Microsoft New Zealand Limited. Written by Michael Howard, " __DATE__);
00068   puts("\nListening....");
00069
00070   rpcStatus=RpcServerListen(1,RPC_C_LISTEN_MAX_CALLS_DEFAULT,FALSE);
00071   CHECK_STATUS(rpcStatus);
00072 }
00073
00074 void  __RPC_FAR * __RPC_API midl_user_allocate(size_t len)
00075 {
00076     return malloc(len);
00077 }
00078
00079 void __RPC_API midl_user_free(void __RPC_FAR * ptr)
00080 {
00081     free(ptr);
00082 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPrintSDIApp Member List

This is the complete list of members for CPrintSDIApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CPrintSDIApp() | CPrintSDIApp |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CPrintSDIApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
OnAppAbout() | CPrintSDIApp |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/sky.h Source File

  • SysMgmt
  • MMC
  • CMenu

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025 class CSkyBasedVehicle : public CDelegationBase {
00026 public:
00027     CSkyBasedVehicle() { }
00028
00029     virtual ~CSkyBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00034
00035 public:
00036     // virtual functions go here (for MMCN_*)
00037     virtual HRESULT OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed);
00038     virtual HRESULT OnMenuCommand(IConsole *pConsole, long lCommandID);
00039
00040 private:
00041     enum { IDM_NEW_SKY = 3 };
00042
00043     // {2974380F-4C4B-11d2-89D8-000021473128}
00044     static const GUID thisGuid;
00045 };
00046
00047
00048
00049 #endif // _SKY_H
00050
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CLoginDlg Member List

This is the complete list of members for CLoginDlg, including all inherited members.
CLoginDlg(CWnd *pParent=NULL) | CLoginDlg |
CLoginDlg(CWnd *pParent=NULL) | CLoginDlg |
CLoginDlg(CWnd *pParent=NULL) | CLoginDlg |
DoDataExchange(CDataExchange *pDX) | CLoginDlg | [protected, virtual]
DoDataExchange(CDataExchange *pDX) | CLoginDlg | [protected, virtual]
DoDataExchange(CDataExchange *pDX) | CLoginDlg | [protected, virtual]
IDD enum value | CLoginDlg |
IsDsEnabledLocaly() | CLoginDlg | [protected]
m_fDsEnabledLocaly | CLoginDlg |
m_strLogin | CLoginDlg |
Generated on Wed Nov 13 2024 16:56:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Hello3/Hello3.h Source File

  • Web
  • MSAgent
  • c
  • Hello3

Hello3.h

Go to the documentation of this file.
00001 #ifndef _HelloAgent3_h_
00002 #define _HelloAgent3_h_
00003
00004
00005 #ifndef STRICT
00006 #define STRICT
00007 #endif
00008
00009
00010 #include <windows.h>
00011 #include <tchar.h>
00012 #include "AgtSvr.h"
00013
00014
00015 #endif
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminCatalogObject.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminCatalogObject.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.class(classid=F618C515-DFB8-11D1-A2CF-00805FC79235,DynamicCasts)
00019     @com.interface(iid=6EB22871-8A19-11D0-81B6-00A0C9231C29, thread=AUTO, type=DUAL) */
00020 public class COMAdminCatalogObject implements IUnknown,com.ms.com.NoAutoScripting,comadmin.ICatalogObject
00021 {
00022   /** @com.method(vtoffset=4, dispid=1, type=PROPGET, name="Value", addFlagsVtable=4)
00023       @com.parameters([in,type=STRING] bstrPropName, [type=VARIANT] return) */
00024   public native Variant getValue(String bstrPropName);
00025
00026   /** @com.method(vtoffset=5, dispid=1, type=PROPPUT, name="Value", addFlagsVtable=4)
00027       @com.parameters([in,type=STRING] bstrPropName, [in,type=VARIANT] retval) */
00028   public native void setValue(String bstrPropName, Variant retval);
00029
00030   /** @com.method(vtoffset=6, dispid=2, type=PROPGET, name="Key", addFlagsVtable=4)
00031       @com.parameters([type=VARIANT] return) */
00032   public native Variant getKey();
00033
00034   /** @com.method(vtoffset=7, dispid=3, type=PROPGET, name="Name", addFlagsVtable=4)
00035       @com.parameters([type=VARIANT] return) */
00036   public native Variant getName();
00037
00038   /** @com.method(vtoffset=8, dispid=4, type=METHOD, name="IsPropertyReadOnly", addFlagsVtable=4)
00039       @com.parameters([in,type=STRING] bstrPropName, [type=BOOLEAN] return) */
00040   public native boolean IsPropertyReadOnly(String bstrPropName);
00041
00042   /** @com.method(vtoffset=9, dispid=5, type=PROPGET, name="Valid", addFlagsVtable=4)
00043       @com.parameters([type=BOOLEAN] return) */
00044   public native boolean getValid();
00045
00046   /** @com.method(vtoffset=10, dispid=6, type=METHOD, name="IsPropertyWriteOnly", addFlagsVtable=4)
00047       @com.parameters([in,type=STRING] bstrPropName, [type=BOOLEAN] return) */
00048   public native boolean IsPropertyWriteOnly(String bstrPropName);
00049
00050
00051   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x6eb22871, (short)0x8a19, (short)0x11d0, (byte)0x81, (byte)0xb6, (byte)0x0, (byte)0xa0, (byte)0xc9, (byte)0x23, (byte)0x1c, (byte)0x29);
00052
00053   public static final com.ms.com._Guid clsid = new com.ms.com._Guid((int)0xf618c515, (short)0xdfb8, (short)0x11d1, (byte)0xa2, (byte)0xcf, (byte)0x0, (byte)0x80, (byte)0x5f, (byte)0xc7, (byte)0x92, (byte)0x35);
00054 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/dll/Select.c Source File

  • Begin
  • dll

Select.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /****************************************************************************
00013
00014     PROGRAM: Select.c
00015
00016     PURPOSE: Contains library routines for selecting a region
00017
00018     FUNCTIONS:
00019
00020         StartSelection(HWND, POINT, LPRECT, int) - begin selection area
00021         UpdateSelection(HWND, POINT, LPRECT, int) - update selection area
00022         EndSelection(POINT, LPRECT) - end selection area
00023         ClearSelection(HWND, LPRECT, int) - clear selection area
00024
00025 *******************************************************************************/
00026
00027 #include "windows.h"
00028 #include "select.h"
00029
00030 /****************************************************************************
00031    FUNCTION: DllMain(HANDLE, DWORD, LPVOID)
00032
00033    PURPOSE:  DllMain is called by Windows when
00034              the DLL is initialized, Thread Attached, and other times.
00035              Refer to SDK documentation, as to the different ways this
00036              may be called.
00037
00038              The DllMain function should perform additional initialization
00039              tasks required by the DLL.  In this example, no initialization
00040              tasks are required.  DllMain should return a value of 1 if
00041              the initialization is successful.
00042
00043 *******************************************************************************/
00044 BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved)
00045 {
00046     return 1;
00047         UNREFERENCED_PARAMETER(hInst);
00048         UNREFERENCED_PARAMETER(ul_reason_being_called);
00049         UNREFERENCED_PARAMETER(lpReserved);
00050 }
00051
00052
00053 /****************************************************************************
00054
00055     FUNCTION: StartSelection(HWND, POINT, LPRECT, int)
00056
00057     PURPOSE: Begin selection of region
00058
00059 ****************************************************************************/
00060
00061 INT APIENTRY StartSelection(
00062     HWND hWnd,
00063     MPOINT ptCurrent,
00064     LPRECT lpSelectRect,
00065     INT fFlags)
00066 {
00067     if (lpSelectRect->left != lpSelectRect->right ||
00068             lpSelectRect->top != lpSelectRect->bottom)
00069         ClearSelection(hWnd, lpSelectRect, fFlags);
00070
00071     lpSelectRect->right = ptCurrent.x;
00072     lpSelectRect->bottom = ptCurrent.y;
00073
00074     /* If you are extending the box, then invert the current rectangle */
00075
00076     if ((fFlags & SL_SPECIAL) == SL_EXTEND)
00077         ClearSelection(hWnd, lpSelectRect, fFlags);
00078
00079     /* Otherwise, set origin to current location */
00080
00081     else {
00082         lpSelectRect->left = ptCurrent.x;
00083         lpSelectRect->top = ptCurrent.y;
00084     }
00085     SetCapture(hWnd);
00086     return 1;
00087 }
00088
00089 /****************************************************************************
00090
00091     FUNCTION: UpdateSelection(HWND, POINT, LPRECT, int) - update selection area
00092
00093     PURPOSE: Update selection
00094
00095 ****************************************************************************/
00096
00097 INT APIENTRY UpdateSelection(
00098     HWND hWnd,
00099     MPOINT ptCurrent,
00100     LPRECT lpSelectRect,
00101     INT fFlags)
00102 {
00103     HDC hDC;
00104     SHORT OldROP;
00105
00106     hDC = GetDC(hWnd);
00107
00108     switch (fFlags & SL_TYPE) {
00109
00110         case SL_BOX:
00111             OldROP = (SHORT)SetROP2(hDC, R2_NOTXORPEN);
00112             MoveToEx(hDC, lpSelectRect->left, lpSelectRect->top, NULL);
00113             LineTo(hDC, lpSelectRect->right, lpSelectRect->top);
00114             LineTo(hDC, lpSelectRect->right, lpSelectRect->bottom);
00115             LineTo(hDC, lpSelectRect->left, lpSelectRect->bottom);
00116             LineTo(hDC, lpSelectRect->left, lpSelectRect->top);
00117             LineTo(hDC, ptCurrent.x, lpSelectRect->top);
00118             LineTo(hDC, ptCurrent.x, ptCurrent.y);
00119             LineTo(hDC, lpSelectRect->left, ptCurrent.y);
00120             LineTo(hDC, lpSelectRect->left, lpSelectRect->top);
00121             SetROP2(hDC, OldROP);
00122             break;
00123
00124         case SL_BLOCK:
00125             PatBlt(hDC,
00126                 lpSelectRect->left,
00127                 lpSelectRect->bottom,
00128                 lpSelectRect->right - lpSelectRect->left,
00129                 ptCurrent.y - lpSelectRect->bottom,
00130                 DSTINVERT);
00131             PatBlt(hDC,
00132                 lpSelectRect->right,
00133                 lpSelectRect->top,
00134                 ptCurrent.x - lpSelectRect->right,
00135                 ptCurrent.y - lpSelectRect->top,
00136                 DSTINVERT);
00137             break;
00138     }
00139     lpSelectRect->right = ptCurrent.x;
00140     lpSelectRect->bottom = ptCurrent.y;
00141     ReleaseDC(hWnd, hDC);
00142     return 1;
00143 }
00144
00145 /****************************************************************************
00146
00147     FUNCTION: EndSelection(POINT, LPRECT)
00148
00149     PURPOSE: End selection of region, release capture of mouse movement
00150
00151 ****************************************************************************/
00152
00153 INT APIENTRY EndSelection(
00154     MPOINT ptCurrent,
00155     LPRECT lpSelectRect)
00156 {
00157     lpSelectRect->right = ptCurrent.x;
00158     lpSelectRect->bottom = ptCurrent.y;
00159     ReleaseCapture();
00160     return 1;
00161 }
00162
00163 /****************************************************************************
00164
00165     FUNCTION: ClearSelection(HWND, LPRECT, int) - clear selection area
00166
00167     PURPOSE: Clear the current selection
00168
00169 ****************************************************************************/
00170
00171 INT APIENTRY ClearSelection(
00172     HWND hWnd,
00173     LPRECT lpSelectRect,
00174     INT fFlags)
00175 {
00176     HDC hDC;
00177     INT2DWORD OldROP;
00178
00179     hDC = GetDC(hWnd);
00180     switch (fFlags & SL_TYPE) {
00181
00182         case SL_BOX:
00183             OldROP = SetROP2(hDC, R2_NOTXORPEN);
00184             MoveToEx(hDC, lpSelectRect->left, lpSelectRect->top, NULL);
00185             LineTo(hDC, lpSelectRect->right, lpSelectRect->top);
00186             LineTo(hDC, lpSelectRect->right, lpSelectRect->bottom);
00187             LineTo(hDC, lpSelectRect->left, lpSelectRect->bottom);
00188             LineTo(hDC, lpSelectRect->left, lpSelectRect->top);
00189             SetROP2(hDC, OldROP);
00190             break;
00191
00192         case SL_BLOCK:
00193             PatBlt(hDC,
00194                 lpSelectRect->left,
00195                 lpSelectRect->top,
00196                 lpSelectRect->right - lpSelectRect->left,
00197                 lpSelectRect->bottom - lpSelectRect->top,
00198                 DSTINVERT);
00199             break;
00200     }
00201     ReleaseDC(hWnd, hDC);
00202     return 1;
00203 }
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/ContextDll.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification

ContextDll.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       ContextDll.cpp
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011 #include "StdAfx.h"
00012 #include "Resource.h"
00013 #include <initguid.h>
00014 #include "ContextDll.h"
00015
00016 #include "ContextPlugin.h"
00017
00018
00019 CComModule _Module;
00020
00021 BEGIN_OBJECT_MAP(ObjectMap)
00022 OBJECT_ENTRY(CLSID_WMSContextPlugin, CContextPlugin)
00023 END_OBJECT_MAP()
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // DLL Entry Point
00027
00028 extern "C"
00029 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00030 {
00031     if (dwReason == DLL_PROCESS_ATTACH)
00032     {
00033         _Module.Init(ObjectMap, hInstance, &LIBID_CONTEXTPLUGINLib);
00034         DisableThreadLibraryCalls(hInstance);
00035     }
00036     else if (dwReason == DLL_PROCESS_DETACH)
00037         _Module.Term();
00038     return TRUE;    // ok
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 // Used to determine whether the DLL can be unloaded by OLE
00043
00044 STDAPI DllCanUnloadNow(void)
00045 {
00046     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // Returns a class factory to create an object of the requested type
00051
00052 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00053 {
00054     return _Module.GetClassObject(rclsid, riid, ppv);
00055 }
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // DllRegisterServer - Adds entries to the system registry
00059
00060 STDAPI DllRegisterServer(void)
00061 {
00062     // registers object, typelib and all interfaces in typelib
00063     return _Module.RegisterServer(TRUE);
00064 }
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // DllUnregisterServer - Removes entries from the system registry
00068
00069 STDAPI DllUnregisterServer(void)
00070 {
00071     return _Module.UnregisterServer(TRUE);
00072 }
00073
00074
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Encode/ALong.h Source File

  • Security
  • CertServices
  • Encode

ALong.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1995 - 2000
00006 //
00007 //  File:       along.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // along.h: Declaration of the CCertEncodeLongArray
00012
00013
00014 #include "resource.h"       // main symbols
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // certenc
00018
00019 #define wszCLASS_CERTENCODELONGARRAY wszCLASS_CERTENCODE TEXT("LongArray")
00020
00021 class CCertEncodeLongArray:
00022     public IDispatchImpl<ICertEncodeLongArray, &IID_ICertEncodeLongArray, &LIBID_CERTENCODELib>,
00023     public ISupportErrorInfoImpl<&IID_ICertEncodeLongArray>,
00024     public CComObjectRoot,
00025     public CComCoClass<CCertEncodeLongArray, &CLSID_CCertEncodeLongArray>
00026 {
00027 public:
00028     CCertEncodeLongArray()
00029     {
00030   m_aValue = NULL;
00031   m_fConstructing = FALSE;
00032     }
00033     ~CCertEncodeLongArray();
00034
00035 BEGIN_COM_MAP(CCertEncodeLongArray)
00036     COM_INTERFACE_ENTRY(IDispatch)
00037     COM_INTERFACE_ENTRY(ISupportErrorInfo)
00038     COM_INTERFACE_ENTRY(ICertEncodeLongArray)
00039 END_COM_MAP()
00040
00041 DECLARE_NOT_AGGREGATABLE(CCertEncodeLongArray)
00042 // Remove the comment from the line above if you don't want your object to
00043 // support aggregation.  The default is to support it
00044
00045 DECLARE_REGISTRY(
00046     CCertEncodeLongArray,
00047     wszCLASS_CERTENCODELONGARRAY TEXT(".1"),
00048     wszCLASS_CERTENCODELONGARRAY,
00049     IDS_CERTENCODELONGARRAY_DESC,
00050     THREADFLAGS_BOTH)
00051
00052 // ICertEncodeLongArray
00053 public:
00054     STDMETHOD(Decode)(
00055     /* [in] */ BSTR const strBinary);
00056
00057     STDMETHOD(GetCount)(
00058     /* [out, retval] */ LONG __RPC_FAR *pCount);
00059
00060     STDMETHOD(GetValue)(
00061     /* [in] */ LONG Index,
00062     /* [out, retval] */ LONG __RPC_FAR *pValue);
00063
00064     STDMETHOD(Reset)(
00065     /* [in] */ LONG Count);
00066
00067     STDMETHOD(SetValue)(
00068     /* [in] */ LONG Index,
00069     /* [in] */ LONG Value);
00070
00071     STDMETHOD(Encode)(
00072     /* [out, retval] */ BSTR __RPC_FAR *pstrBinary);
00073 private:
00074     VOID _Cleanup(VOID);
00075
00076     HRESULT _SetErrorInfo(
00077     IN HRESULT hrError,
00078     IN WCHAR const *pwszDescription);
00079
00080     LONG  *m_aValue;
00081     LONG   m_cValue;
00082     LONG   m_cValuesSet;
00083     BOOL   m_fConstructing;
00084 };
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/NewsEventClass/resource.h Source File

  • Com
  • Services
  • Events
  • EventNews
  • NewsEventClass

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by NewsEventClass.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_NEWSEVENT                   101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_DRVLINE Member List

This is the complete list of members for _DRVLINE, including all inherited members.
bDropInProgress | _DRVLINE
dwCallState | _DRVLINE
dwCallStateMode | _DRVLINE
dwDeviceID | _DRVLINE
dwMediaMode | _DRVLINE
dwMSPHandle | _DRVLINE
hComm | _DRVLINE
htCall | _DRVLINE
htLine | _DRVLINE
htMSPLineHandle | _DRVLINE
Overlapped | _DRVLINE
pfnEventProc | _DRVLINE
szComm | _DRVLINE
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMember Member List

This is the complete list of members for CMember, including all inherited members.
ClearInRosterFlag(void) | CMember | [inline]
CMember(INmMember *) | CMember |
CMember(AppletRecord *) | CMember |
GetName(void) | CMember | [inline]
GetUID(void) | CMember | [inline]
Initialize(void) | CMember | [private]
IsEmptyMember(void) | CMember | [inline]
IsEmptyUID(void) | CMember | [inline]
IsInRoster(void) | CMember | [inline]
IsSameMemberID(AppletNodeID nid) | CMember | [inline]
IsSameUID(AppletUserID uid) | CMember | [inline]
m_eidMember | CMember | [private]
m_fInRoster | CMember | [private]
m_nidMember | CMember | [private]
m_pszMemberName | CMember | [private]
m_uidMember | CMember | [private]
SetInRosterFlag(void) | CMember | [inline]
SetMember(INmMember *, BOOL fFirstTime=FALSE) | CMember |
SetMember(AppletRecord *, BOOL fFirstTime=FALSE) | CMember |
~CMember(void) | CMember |
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/APP.h Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

APP.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012
00013 #ifndef TEXT
00014 // this is non-Unicode Win16 build
00015 #define CHAR   char
00016 #define UCHAR  unsigned char
00017 #define TCHAR  CHAR
00018 #define LPTSTR LPSTR
00019 #define TEXT(x) x
00020 #define COORD   int
00021
00022 #else
00023 #define COORD   LONG
00024 #define HINSTANCE HMODULE
00025 #endif
00026
00027 // Menu item IDs
00028 #define IDM_PRINT       1
00029 #define IDM_EXIT        2
00030 #define IDM_NEXTPAGE    3
00031 #define IDM_PREVPAGE    4
00032 #define IDM_NEXTSECTION 5
00033 #define IDM_PREVSECTION 6
00034 #define IDM_ZOOMIN      7
00035 #define IDM_ZOOMOUT     8
00036 #define IDM_FONT        9
00037 #define IDM_DECIMAL     10
00038 #define IDM_HELP        11
00039 #define IDM_ABOUT       12
00040 #define IDM_ALLPAGES    13
00041
00042 #define IDM_FIRSTPAGE   200  // pseudo menu items
00043 #define IDM_LASTPAGE    201
00044
00045 // String Table IDs
00046 #define IDS_CLASSNAME    1024
00047 #define IDS_MSGCAPTION   1025
00048 #define IDS_UCFONT       1026
00049 #define IDS_ANSIFONT     1027
00050 #define IDS_LABELFONT    1028
00051 #define IDS_HEADERFONT   1029
00052 #define IDS_PRINTERR     1030
00053 #define IDS_NOTIMPLEM    1031
00054
00055 // Manifest Constants
00056 #define DONE TRUE
00057 #define INCH1     1440
00058 #define INCH2      720  // half
00059 #define INCH4      360  // quarter
00060 #define INCH8      180  // eigth
00061 #define INCH10     144  // tenth
00062
00063 // Paper Size: Redefine for non-US
00064 #define PAGEWIDTH  (8*INCH1+INCH2)
00065 #define PAGEHEIGHT (11*INCH1)
00066
00067 #include "resource.h"
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/space.h Source File

  • SysMgmt
  • MMC
  • Menubtn

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "DeleBase.h"
00024 #include "CompData.h"
00025
00026 class CRocket : public CDelegationBase {
00027 public:
00028     CRocket();
00029
00030     virtual ~CRocket();
00031
00032     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00033     virtual const GUID & getNodeType() { return thisGuid; }
00034     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00035
00036     void Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload);
00037
00038 public:
00039     // virtual functions go here (for MMCN_*)
00040     virtual HRESULT OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID);
00041     virtual HMENU   GetMenu(int nMenuId);
00042     virtual HRESULT SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton,
00043         BOOL bScope, BOOL bSelect);
00044     virtual HRESULT OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd);
00045
00046 private:
00047     // {29743810-4C4B-11d2-89D8-000021473128}
00048     static const GUID thisGuid;
00049
00050     _TCHAR *szName;
00051     LONG   lWeight;
00052     LONG   lHeight;
00053     LONG   lPayload;
00054     enum {RUNNING, PAUSED, STOPPED} iStatus;
00055 };
00056
00057 class CSpaceVehicle : public CDelegationBase {
00058 public:
00059     CSpaceVehicle();
00060
00061     virtual ~CSpaceVehicle();
00062
00063     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00064     virtual const GUID & getNodeType() { return thisGuid; }
00065     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00066
00067 public:
00068     // virtual functions go here (for MMCN_*)
00069     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00070
00071 private:
00072     enum { IDM_NEW_SPACE = 4 };
00073
00074     // {29743810-4C4B-11d2-89D8-000021473128}
00075     static const GUID thisGuid;
00076
00077 private:
00078     enum { NUMBER_OF_CHILDREN = 4 };
00079     CRocket *children[NUMBER_OF_CHILDREN];
00080 };
00081
00082 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SEARCH_REQUEST_STATE Member List

This is the complete list of members for _SEARCH_REQUEST_STATE, including all inherited members.
Buffer | _SEARCH_REQUEST_STATE
CurrentOutput | _SEARCH_REQUEST_STATE
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/people.Cpp Source File

  • SysMgmt
  • MMC
  • WMI

people.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00008 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00009 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00010 //  PURPOSE.
00011 //
00012 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00013 //
00014 //
00015 //==============================================================;
00016 #include <stdio.h>
00017 #include "People.h"
00018 #include <commctrl.h>
00019 #include <comdef.h>
00020 #include <windowsx.h>
00021
00022 const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 const GUID CBicycleFolder::thisGuid =    { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00025 const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00026 const GUID CIceSkateFolder::thisGuid =   { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00027
00028 const GUID CBicycle::thisGuid =    { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00029 const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00030 const GUID CIceSkate::thisGuid =   { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00031
00032
00033 #define WM_WMI_CONNECTED WM_APP   // only sent to CBicycleFolder::m_connectHwnd
00034 #define WM_REFRESH_EVENT WM_APP+1   // only sent to CBicycleFolder::m_connectHwnd
00035
00036 //==============================================================
00037 //
00038 // CEventSink implementation
00039 //
00040 class CEventSink : public IWbemObjectSink
00041 {
00042 public:
00043     CEventSink(HWND hwnd) : m_hwnd(hwnd){}
00044     ~CEventSink(){};
00045
00046     STDMETHOD_(SCODE, Indicate)(long lObjectCount,
00047                 IWbemClassObject **pObjArray)
00048   {
00049     // Not actually using the pObjArray. Just need a trigger for the
00050     // refresh.
00051     ::SendMessage(m_hwnd, WM_REFRESH_EVENT, 0, 0);
00052     return S_OK;
00053   }
00054
00055     STDMETHOD_(SCODE, SetStatus)(long lFlags,
00056                   HRESULT hResult,
00057                   BSTR strParam,
00058                   IWbemClassObject *pObjParam)
00059   {
00060     // SetStatus() may be called to indicate that your query becomes
00061     // invalid or valid again  ussually caused by multithreading 'situations'.
00062     return S_OK;
00063   }
00064
00065     // IUnknown members
00066     STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv)
00067   {
00068     if(riid == IID_IUnknown || riid == IID_IWbemObjectSink)
00069     {
00070       *ppv = this;
00071
00072       // you're handing out a copy of yourself so account for it.
00073       AddRef();
00074       return S_OK;
00075     }
00076     else
00077     {
00078       return E_NOINTERFACE;
00079     }
00080   }
00081     STDMETHODIMP_(ULONG) AddRef(void)
00082   {
00083       return InterlockedIncrement(&m_lRef);
00084   }
00085     STDMETHODIMP_(ULONG) Release(void)
00086   {
00087     // InterlockedDecrement() helps with thread safety.
00088     int lNewRef = InterlockedDecrement(&m_lRef);
00089     // when all the copies are released...
00090     if(lNewRef == 0)
00091     {
00092       // kill thyself.
00093       delete this;
00094     }
00095
00096     return lNewRef;
00097   }
00098
00099 private:
00100     long m_lRef;
00101   HWND m_hwnd;
00102 };
00103
00104 //==============================================================
00105 //
00106 // CPeoplePoweredVehicle implementation
00107 //
00108 //
00109 //----------------------------------------------------------
00110 #define TEMP_BUF 255
00111
00112 bool CBicycleFolder::ErrorString(HRESULT hr,
00113                    TCHAR *errMsg, UINT errSize)
00114 {
00115     TCHAR szError[TEMP_BUF] = {0};
00116   TCHAR szFacility[TEMP_BUF] = {0};
00117   IWbemStatusCodeText * pStatus = NULL;
00118
00119     // initialize buffers.
00120   memset(errMsg, 0, errSize * sizeof(TCHAR));
00121
00122   HRESULT hr1 = CoInitialize(NULL);
00123   SCODE sc1 = CoCreateInstance(CLSID_WbemStatusCodeText,
00124                 0, CLSCTX_INPROC_SERVER,
00125                 IID_IWbemStatusCodeText,
00126                 (LPVOID *) &pStatus);
00127
00128   // loaded OK?
00129   if(sc1 == S_OK)
00130   {
00131     BSTR bstr;
00132     sc1 = pStatus->GetErrorCodeText(hr, 0, 0, &bstr);
00133     if(sc1 == S_OK)
00134     {
00135 #ifdef UNICODE
00136       wcsncpy(szError, bstr, TEMP_BUF-1);
00137 #else
00138       wcstombs(szError, bstr, TEMP_BUF-1);
00139 #endif UNICODE
00140       SysFreeString(bstr);
00141       bstr = 0;
00142     }
00143
00144     sc1 = pStatus->GetFacilityCodeText(hr, 0, 0, &bstr);
00145     if(sc1 == S_OK)
00146     {
00147 #ifdef UNICODE
00148       wcsncpy(szFacility, bstr, TEMP_BUF-1);
00149 #else
00150       wcstombs(szFacility, bstr, TEMP_BUF-1);
00151 #endif UNICODE
00152       SysFreeString(bstr);
00153       bstr = 0;
00154     }
00155
00156     // RELEASE
00157     pStatus->Release();
00158     pStatus = NULL;
00159   }
00160   else
00161   {
00162     ::MessageBox(NULL, _T("WBEM error features not available. Upgrade WMI to a newer build."),
00163            _T("Internal Error"), MB_ICONSTOP|MB_OK);
00164   }
00165
00166   // if not msgs returned....
00167   if(_tcslen(szFacility) == 0 || _tcslen(szError) == 0)
00168   {
00169     // format the error nbr as a reasonable default.
00170     _stprintf(errMsg, _T("Error code: 0x%08X"), hr);
00171   }
00172   else
00173   {
00174     // format a readable msg.
00175     _stprintf(errMsg, _T("%s: %s"), szFacility, szError);
00176   }
00177
00178   if(hr1 == S_OK)
00179     CoUninitialize();
00180
00181   return (SUCCEEDED(sc1) && SUCCEEDED(hr1));
00182 }
00183
00184 CPeoplePoweredVehicle::CPeoplePoweredVehicle()
00185 {
00186     children[0] = new CBicycleFolder;
00187     children[1] = new CSkateboardFolder;
00188     children[2] = new CIceSkateFolder;
00189 }
00190
00191 CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
00192 {
00193     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00194         delete children[n];
00195 }
00196
00197 HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00198 {
00199     SCOPEDATAITEM sdi;
00200
00201     if (!bExpanded) {
00202         // create the child nodes, then expand them
00203         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00204             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00205             sdi.mask =  SDI_STR       |   // Displayname is valid
00206             SDI_PARAM     |   // lParam is valid
00207             SDI_IMAGE     |   // nImage is valid
00208             SDI_OPENIMAGE |   // nOpenImage is valid
00209             SDI_PARENT    |   // relativeID is valid
00210             SDI_CHILDREN;     // cChildren is valid
00211
00212             sdi.relativeID  = (HSCOPEITEM)parent;
00213             sdi.nImage      = children[n]->GetBitmapIndex();
00214             sdi.nOpenImage  = INDEX_OPENFOLDER;
00215             sdi.displayname = MMC_CALLBACK;
00216             sdi.lParam      = (LPARAM)children[n];       // The cookie
00217             sdi.cChildren   = 0;
00218
00219             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00220
00221             _ASSERT( SUCCEEDED(hr) );
00222         }
00223     }
00224
00225     return S_OK;
00226 }
00227
00228 CBicycleFolder::CBicycleFolder() :
00229           m_connectHwnd(0),
00230           m_threadId(0), m_thread(0),
00231           m_doWork(0), m_threadCmd(CT_CONNECT),
00232           m_running(false), m_ptrReady(0),
00233           m_pStream(0), m_realWMI(0),
00234           m_pResultData(0), m_pStubSink(0),
00235           m_pUnsecApp(0)
00236 {
00237     WNDCLASS wndClass;
00238
00239     ZeroMemory(&wndClass, sizeof(WNDCLASS));
00240
00241     wndClass.lpfnWndProc = WindowProc;
00242     wndClass.lpszClassName = _T("connectthreadwindow");
00243     wndClass.hInstance = g_hinst;
00244
00245     ATOM atom = RegisterClass(&wndClass);
00246     m_connectHwnd = CreateWindow(
00247             _T("connectthreadwindow"),  // pointer to registered class name
00248             NULL,    // pointer to window name
00249             0,       // window style
00250             0,           // horizontal position of window
00251             0,           // vertical position of window
00252             0,           // window width
00253             0,           // window height
00254             NULL,    // handle to parent or owner window
00255             NULL,        // handle to menu or child-window identifier
00256             g_hinst,     // handle to application instance
00257             (void *)this); // pointer to window-creation data
00258
00259     if (m_connectHwnd)
00260         SetWindowLong(m_connectHwnd, GWL_USERDATA, (LONG)this);
00261
00262     InitializeCriticalSection(&m_critSect);
00263   m_doWork = CreateEvent(NULL, FALSE, FALSE, NULL);
00264   m_ptrReady = CreateEvent(NULL, FALSE, FALSE, NULL);
00265
00266     EnterCriticalSection(&m_critSect);
00267
00268   // NOTE: I'm connecting real early. You may want to connect from some other place.
00269   m_threadCmd = CT_CONNECT;
00270   SetEvent(m_doWork);
00271     m_thread = CreateThread(NULL, 0, ThreadProc, (void *)this, 0, &m_threadId);
00272
00273     LeaveCriticalSection(&m_critSect);
00274 }
00275
00276 CBicycleFolder::~CBicycleFolder()
00277 {
00278   EmptyChildren();
00279   if(m_pResultData)
00280   {
00281     m_pResultData->Release();
00282     m_pResultData = 0;
00283   }
00284
00285   if(m_pStubSink)
00286   {
00287     IWbemServices *service = 0;
00288     HRESULT hr = GetPtr(&service);
00289     if(SUCCEEDED(hr))
00290     {
00291       service->CancelAsyncCall(m_pStubSink);
00292       service->Release();
00293       service = 0;
00294     }
00295     m_pStubSink->Release();
00296     m_pStubSink = NULL;
00297   }
00298
00299   if(m_pUnsecApp)
00300   {
00301     m_pUnsecApp->Release();
00302     m_pUnsecApp = 0;
00303   }
00304
00305     StopThread();
00306
00307     if(m_connectHwnd != NULL)
00308         DestroyWindow(m_connectHwnd);
00309
00310     UnregisterClass(_T("connectthreadwindow"), NULL);
00311     DeleteCriticalSection(&m_critSect);
00312 }
00313
00314 void CBicycleFolder::StopThread()
00315 {
00316     EnterCriticalSection(&m_critSect);
00317     m_running = false;
00318
00319     if (m_thread != NULL)
00320   {
00321     m_threadCmd = CT_EXIT;
00322     SetEvent(m_doWork);
00323     WaitForSingleObject(m_ptrReady, 10000);
00324
00325         CloseHandle(m_thread);
00326
00327         m_thread = NULL;
00328     }
00329     LeaveCriticalSection(&m_critSect);
00330 }
00331
00332 LRESULT CALLBACK CBicycleFolder::WindowProc(
00333                   HWND hwnd,      // handle to window
00334                   UINT uMsg,      // message identifier
00335                   WPARAM wParam,  // first message parameter
00336                   LPARAM lParam)  // second message parameter
00337 {
00338     CBicycleFolder *pThis = (CBicycleFolder *)GetWindowLong(hwnd, GWL_USERDATA);
00339
00340     switch (uMsg)
00341   {
00342     case WM_WMI_CONNECTED:
00343         if(pThis != NULL)
00344     {
00345       IWbemServices *service = 0;
00346       HRESULT hr = pThis->GetPtr(&service);
00347       if(SUCCEEDED(hr))
00348       {
00349         pThis->RegisterEventSink(service);
00350         pThis->EnumChildren(service);
00351
00352         // m_pResultData gets set when an onShow has happened. If set, the user already wants
00353         // to see equipment but the connection was slower than the UI. Catchup now.
00354         if(pThis->m_pResultData)
00355           pThis->DisplayChildren();
00356
00357         // done with the marshaled service ptr.
00358         service->Release();
00359         service = 0;
00360       }
00361     }
00362     else
00363     {
00364       TCHAR errMsg[255] = {0};
00365       pThis->ErrorString((HRESULT)wParam, errMsg, 255);
00366
00367       MessageBox(hwnd, errMsg, _T("WMI Snapin Sample"), MB_OK|MB_ICONSTOP);
00368     }
00369
00370         break;
00371
00372     case WM_REFRESH_EVENT:
00373         if(pThis != NULL)
00374     {
00375       IWbemServices *service = 0;
00376       HRESULT hr = pThis->GetPtr(&service);
00377       if(SUCCEEDED(hr))
00378       {
00379         pThis->EmptyChildren();
00380         pThis->EnumChildren(service);
00381         pThis->DisplayChildren();
00382
00383         // done with the marshaled service ptr.
00384         service->Release();
00385         service = 0;
00386       }
00387     }
00388         break;
00389
00390   } //endswitch
00391
00392     return DefWindowProc(hwnd, uMsg, wParam, lParam);
00393 }
00394
00395 void CBicycleFolder::RegisterEventSink(IWbemServices *service)
00396 {
00397   //NOTE: this logic is from the Wmi documentation,
00398   // "Security Considerations with Asynchronous Calls" so you can
00399   // follow along.
00400
00401   // allocate the sink if its not already allocated.
00402   if(m_pStubSink == 0)
00403   {
00404     CEventSink *pEventSink = 0;
00405     IUnknown* pStubUnk = 0;
00406
00407     // create the 'real' sink.
00408     pEventSink = new CEventSink(m_connectHwnd);
00409     pEventSink->AddRef();
00410
00411     // create an unsecapp object.
00412     CoCreateInstance(CLSID_UnsecuredApartment, NULL,
00413               CLSCTX_LOCAL_SERVER, IID_IUnsecuredApartment,
00414               (void**)&m_pUnsecApp);
00415
00416     // give the 'real' sink to the unsecapp to manage. Get a 'pStubUnk' in return.
00417     m_pUnsecApp->CreateObjectStub(pEventSink, &pStubUnk);
00418
00419     // from that pUnk, get a wrapper to your original sink.
00420     pStubUnk->QueryInterface(IID_IWbemObjectSink, (void **)&m_pStubSink);
00421     pStubUnk->Release();
00422
00423     // release the 'real' sink cuz m_pStubSink "owns" it now.
00424     long ref = pEventSink->Release();
00425   }
00426
00427   HRESULT hRes = S_OK;
00428   BSTR qLang = SysAllocString(L"WQL");
00429   BSTR query = SysAllocString(L"select * from __InstanceCreationEvent where TargetInstance isa \"Bicycle\"");
00430
00431   // execute the query. For *Async, the last parm is a sink object
00432   // that will be sent the resultset instead of returning the normal
00433   // enumerator object.
00434   if(SUCCEEDED(hRes = service->ExecNotificationQueryAsync(qLang, query,
00435                               0L, NULL,
00436                               m_pStubSink)))
00437   {
00438     OutputDebugString(_T("Executed filter query\n"));
00439   }
00440   else
00441   {
00442     OutputDebugString(_T("ExecQuery() failed\n"));
00443
00444   } //endif ExecQuery()
00445
00446   SysFreeString(qLang);
00447   SysFreeString(query);
00448 }
00449
00450 void CBicycleFolder::EmptyChildren(void)
00451 {
00452   if(m_pResultData)
00453   {
00454     HRESULT hr = m_pResultData->DeleteAllRsltItems();
00455
00456     int last = m_children.GetSize();
00457     for (int n = 0; n < last; n++)
00458     {
00459       if (m_children[n] != NULL)
00460         delete m_children[n];
00461     }
00462     m_children.RemoveAll();
00463   }
00464 }
00465
00466 bool CBicycleFolder::EnumChildren(IWbemServices *service)
00467 {
00468   IEnumWbemClassObject *pEnumBikes = NULL;
00469   HRESULT hr = S_OK;
00470
00471   // get the list of bicycles...
00472   if(SUCCEEDED(hr = service->CreateInstanceEnum((bstr_t)L"Bicycle",
00473                       WBEM_FLAG_SHALLOW,
00474                       NULL, &pEnumBikes)))
00475   {
00476     // NOTE: pBike MUST be set to NULL for Next().
00477     IWbemClassObject *pBike = NULL;
00478     CBicycle *pBikeInst = 0;
00479
00480     ULONG uReturned = 1;
00481
00482     while((SUCCEEDED(hr = pEnumBikes->Next(-1, 1, &pBike, &uReturned))) &&
00483         (uReturned != 0))
00484     {
00485       // Add the bike...
00486       pBikeInst = new CBicycle(this, pBike);
00487
00488       m_children.Add(pBikeInst);
00489
00490       // Done with this object. pBikeInst "owns" it now.
00491       if(pBike)
00492       {
00493         pBike->Release();
00494
00495         // NOTE: pBike MUST be reset to NULL for Next().
00496         pBike = NULL;
00497       }
00498
00499     } // endwhile
00500
00501     // Done with this enumerator.
00502     if (pEnumBikes)
00503     {
00504       pEnumBikes->Release();
00505       pEnumBikes = NULL;
00506     }
00507   } // endif CreateInstanceEnum()
00508
00509   return SUCCEEDED(hr);
00510 }
00511
00512 HRESULT CBicycleFolder::GetPtr(IWbemServices **ptr)
00513 {
00514   HRESULT hr = E_FAIL;
00515   m_threadCmd = CT_GET_PTR;
00516   SetEvent(m_doWork);
00517   WaitForSingleObject(m_ptrReady, 10000);
00518
00519   if(ptr && m_pStream)
00520   {
00521     *ptr = 0;
00522     hr = CoGetInterfaceAndReleaseStream(m_pStream,
00523                       IID_IWbemServices,
00524                       (void**)ptr);
00525   }
00526   return hr;
00527 }
00528
00529 DWORD WINAPI CBicycleFolder::ThreadProc(LPVOID lpParameter)
00530 {
00531     CBicycleFolder *pThis = (CBicycleFolder *)lpParameter;
00532   HRESULT hr = S_OK;
00533
00534   CoInitialize(NULL);
00535
00536   while(true)
00537   {
00538     WaitForSingleObject(pThis->m_doWork, -1);
00539
00540     switch(pThis->m_threadCmd)
00541     {
00542     case CT_CONNECT:
00543       {
00544         IWbemLocator *pLocator = 0;
00545         HRESULT hr;
00546
00547         // Create an instance of the WbemLocator interface.
00548         hr = CoCreateInstance(CLSID_WbemLocator,
00549                     NULL, CLSCTX_INPROC_SERVER,
00550                     IID_IWbemLocator, (LPVOID *)&pLocator);
00551
00552         if(SUCCEEDED(hr))
00553         {
00554           hr = pLocator->ConnectServer(L"root\\Vehicles",// Network
00555                           NULL,         // User
00556                           NULL,         // Password
00557                           NULL,         // Locale
00558                           0,            // Security Flags
00559                           NULL,         // Authority
00560                           NULL,         // Context
00561                           &pThis->m_realWMI);  // Namespace
00562
00563           // tell the callback the result of the connection.
00564           if(pThis->m_connectHwnd)
00565             PostMessage(pThis->m_connectHwnd, WM_WMI_CONNECTED, hr, 0);
00566         }
00567       }
00568       break;
00569
00570     case CT_GET_PTR:
00571       if(pThis->m_realWMI != NULL)
00572       {
00573         hr = CoMarshalInterThreadInterfaceInStream(IID_IWbemServices,
00574                               pThis->m_realWMI,
00575                               &(pThis->m_pStream));
00576       }
00577
00578       SetEvent(pThis->m_ptrReady);
00579       break;
00580
00581     case CT_EXIT:
00582       if(pThis->m_realWMI != NULL)
00583       {
00584         pThis->m_realWMI->Release();
00585         pThis->m_realWMI = 0;
00586       }
00587       SetEvent(pThis->m_ptrReady);
00588       return 0;
00589       break;
00590
00591     } //endswitch
00592
00593   } //endwhile(true)
00594
00595     return 0;
00596 }
00597
00598 HRESULT CBicycleFolder::DisplayChildren(void)
00599 {
00600     // insert items here
00601     RESULTDATAITEM rdi;
00602   HRESULT hr = S_OK;
00603   int last = m_children.GetSize();
00604   CBicycle *pBike = 0;
00605
00606     // create the child nodes, then expand them
00607     for (int n = 0; n < last; n++)
00608   {
00609     pBike = (CBicycle *)m_children[n];
00610
00611         ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00612         rdi.mask       =  RDI_STR       |   // Displayname is valid
00613               RDI_IMAGE     |   // nImage is valid
00614               RDI_PARAM;
00615
00616         rdi.nImage      = pBike->GetBitmapIndex();
00617         rdi.str         = MMC_CALLBACK;
00618         rdi.nCol        = 0;
00619         rdi.lParam      = (LPARAM)pBike;
00620
00621     if(m_pResultData)
00622       hr = m_pResultData->InsertItem( &rdi );
00623
00624         _ASSERT( SUCCEEDED(hr) );
00625     }
00626   return hr;
00627 }
00628
00629 HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00630 {
00631     HRESULT      hr = S_OK;
00632
00633     IHeaderCtrl *pHeaderCtrl = NULL;
00634
00635     if (bShow)
00636   {
00637         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00638         _ASSERT( SUCCEEDED(hr) );
00639
00640         hr = pConsole->QueryInterface(IID_IResultData, (void **)&m_pResultData);
00641         _ASSERT( SUCCEEDED(hr) );
00642
00643         // Set the column headers in the results pane
00644         hr = pHeaderCtrl->InsertColumn(0, L"Name", LVCFMT_LEFT, 150);
00645         _ASSERT( S_OK == hr );
00646
00647         hr = pHeaderCtrl->InsertColumn(1, L"Owner", LVCFMT_LEFT, 200);
00648         _ASSERT( S_OK == hr );
00649
00650     if(m_pResultData)
00651     {
00652       hr = m_pResultData->DeleteAllRsltItems();
00653       _ASSERT( SUCCEEDED(hr) );
00654
00655       if(!bExpanded)
00656       {
00657         hr = DisplayChildren();
00658       }
00659
00660       pHeaderCtrl->Release();
00661     }
00662     }
00663
00664     return hr;
00665 }
00666
00667 CIceSkateFolder::CIceSkateFolder()
00668 {
00669     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00670         children[n] = new CIceSkate(n + 1);
00671     }
00672 }
00673
00674 CIceSkateFolder::~CIceSkateFolder()
00675 {
00676     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00677         if (children[n]) {
00678             delete children[n];
00679         }
00680 }
00681
00682 HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00683 {
00684     HRESULT      hr = S_OK;
00685
00686     IHeaderCtrl *pHeaderCtrl = NULL;
00687     IResultData *pResultData = NULL;
00688
00689     if (bShow) {
00690         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00691         _ASSERT( SUCCEEDED(hr) );
00692
00693         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00694         _ASSERT( SUCCEEDED(hr) );
00695
00696         // Set the column headers in the results pane
00697         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00698         _ASSERT( S_OK == hr );
00699
00700         // insert items here
00701         RESULTDATAITEM rdi;
00702
00703         hr = pResultData->DeleteAllRsltItems();
00704         _ASSERT( SUCCEEDED(hr) );
00705
00706         if (!bExpanded)
00707     {
00708             // create the child nodes, then expand them
00709             for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00710       {
00711                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00712                 rdi.mask       = RDI_STR       |    // Displayname is valid
00713                  RDI_IMAGE     |  // nImage is valid
00714                  RDI_PARAM;
00715
00716                 rdi.nImage      = children[n]->GetBitmapIndex();
00717                 rdi.str         = MMC_CALLBACK;
00718                 rdi.nCol        = 0;
00719                 rdi.lParam      = (LPARAM)children[n];
00720
00721                 hr = pResultData->InsertItem( &rdi );
00722
00723                 _ASSERT( SUCCEEDED(hr) );
00724             }
00725         }
00726
00727         pHeaderCtrl->Release();
00728         pResultData->Release();
00729     }
00730
00731     return hr;
00732 }
00733
00734 //================================================
00735 CSkateboardFolder::CSkateboardFolder()
00736 {
00737     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00738         children[n] = new CSkateboard(n + 1);
00739     }
00740 }
00741
00742 CSkateboardFolder::~CSkateboardFolder()
00743 {
00744     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00745         if (children[n]) {
00746             delete children[n];
00747         }
00748 }
00749
00750 HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00751 {
00752     HRESULT      hr = S_OK;
00753
00754     IHeaderCtrl *pHeaderCtrl = NULL;
00755     IResultData *pResultData = NULL;
00756
00757     if (bShow) {
00758         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00759         _ASSERT( SUCCEEDED(hr) );
00760
00761         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00762         _ASSERT( SUCCEEDED(hr) );
00763
00764         // Set the column headers in the results pane
00765         hr = pHeaderCtrl->InsertColumn( 0, L"Name                      ", 0, MMCLV_AUTO );
00766         _ASSERT( S_OK == hr );
00767
00768         // insert items here
00769         RESULTDATAITEM rdi;
00770
00771         hr = pResultData->DeleteAllRsltItems();
00772         _ASSERT( SUCCEEDED(hr) );
00773
00774         if (!bExpanded) {
00775             // create the child nodes, then expand them
00776             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00777                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00778                 rdi.mask       = RDI_STR       |    // Displayname is valid
00779                  RDI_IMAGE     |  // nImage is valid
00780                  RDI_PARAM;
00781
00782                 rdi.nImage      = children[n]->GetBitmapIndex();
00783                 rdi.str         = MMC_CALLBACK;
00784                 rdi.nCol        = 0;
00785                 rdi.lParam      = (LPARAM)children[n];
00786
00787                 hr = pResultData->InsertItem( &rdi );
00788
00789                 _ASSERT( SUCCEEDED(hr) );
00790             }
00791         }
00792
00793         pHeaderCtrl->Release();
00794         pResultData->Release();
00795     }
00796
00797     return hr;
00798 }
00799
00800 //=====================================================
00801 const _TCHAR *CSkateboard::GetDisplayName(int nCol)
00802 {
00803     static _TCHAR buf[128];
00804
00805     _stprintf(buf, _T("Skateboard #%d"), id);
00806
00807     return buf;
00808 }
00809
00810 //=====================================================
00811 const _TCHAR *CIceSkate::GetDisplayName(int nCol)
00812 {
00813     static _TCHAR buf[128];
00814
00815     _stprintf(buf, _T("Ice Skate #%d"), id);
00816
00817     return buf;
00818 }
00819
00820 //========================================
00821 CBicycle::CBicycle(CBicycleFolder *parent, IWbemClassObject *inst) :
00822           m_parent(parent),
00823           m_inst(inst)
00824 {
00825   if(m_inst)
00826     m_inst->AddRef();
00827 }
00828
00829 // helper values for calling GetDisplayName().
00830 #define NAME_COL 0
00831 #define OWNER_COL 1
00832 #define COLOR_COL 2
00833 #define MATERIAL_COL 3
00834
00835 const _TCHAR *CBicycle::GetDisplayName(int nCol)
00836 {
00837     static _TCHAR buf[128];
00838
00839   // Get the corresponding property for nCol. This is in-proc local copy
00840   //    so its pretty fast even if IWbemServices is a remote connection.
00841   if(m_inst)
00842   {
00843     VARIANT pVal;
00844     WCHAR propName[10] = {0};
00845
00846     VariantInit(&pVal);
00847
00848     switch(nCol)
00849     {
00850     case 0:
00851       wcscpy(propName, L"Name");
00852       break;
00853
00854     case 1:
00855       wcscpy(propName, L"Owner");
00856       break;
00857
00858     // these wont be needed by MMC but its makes this routine more useful
00859     // internal to the class.
00860     case 2:
00861       wcscpy(propName, L"Color");
00862       break;
00863
00864     case 3:
00865       wcscpy(propName, L"Material");
00866       break;
00867
00868     } //endswitch
00869
00870     if(m_inst->Get(propName, 0L, &pVal, NULL, NULL) == S_OK)
00871     {
00872       bstr_t temp(pVal);
00873       _tcscpy(buf, (LPTSTR)temp);
00874     }
00875
00876     VariantClear(&pVal);
00877   } //endif (m_inst)
00878
00879     return buf;
00880 }
00881
00882 bool CBicycle::GetGirls(void)
00883 {
00884   VARIANT_BOOL retval = VARIANT_FALSE;
00885   // Here's how to get/interpret a VT_BOOL property.
00886   if(m_inst)
00887   {
00888     VARIANT pVal;
00889     if(m_inst->Get(L"Girls", 0L, &pVal, NULL, NULL) == S_OK)
00890     {
00891       retval = V_BOOL(&pVal);
00892     }
00893
00894     VariantClear(&pVal);
00895   } //endif (m_inst)
00896
00897     return (retval == VARIANT_TRUE);
00898 }
00899
00900 void CBicycle::LoadSurfaces(HWND hwndDlg, BYTE iSurface)
00901 {
00902   HWND hCombo = GetDlgItem(hwndDlg, IDC_PEOPLE_SURFACE);
00903   HRESULT hr = E_FAIL;
00904   IWbemQualifierSet *qualSet = 0;
00905   int selected = 0;
00906
00907   // qualifiers only exist on the class definition. m_inst is a instance.
00908   IWbemClassObject *pClass = 0;
00909   IWbemServices *service = 0;
00910
00911   if(SUCCEEDED(m_parent->GetPtr(&service)))
00912   {
00913     hr = service->GetObject((bstr_t)L"Bicycle", 0,0, &pClass, 0);
00914
00915     if(SUCCEEDED(hr = pClass->GetPropertyQualifierSet((bstr_t)L"Surface",
00916                               &qualSet)))
00917     {
00918       VARIANT vList;
00919       VariantInit(&vList);
00920       if(SUCCEEDED(hr = qualSet->Get((bstr_t)L"Values", 0, &vList, 0)))
00921       {
00922         SAFEARRAY *pma = V_ARRAY(&vList);
00923         long lLowerBound = 0, lUpperBound = 0 ;
00924         UINT idx = 0;
00925
00926         SafeArrayGetLBound(pma, 1, &lLowerBound);
00927         SafeArrayGetUBound(pma, 1, &lUpperBound);
00928
00929         for(long x = lLowerBound; x <= lUpperBound; x++)
00930         {
00931           BSTR vSurface;
00932
00933           SafeArrayGetElement(pma, &x, &vSurface);
00934
00935           // NOTE: taking advantage of the bstr_t's conversion operators.
00936           // really cleans up the code.
00937           bstr_t temp(vSurface);
00938
00939           UINT idx = ComboBox_AddString(hCombo, (LPTSTR)temp);
00940           ComboBox_SetItemData(hCombo, idx, x);
00941
00942           // is this the one we want to select?
00943           if(iSurface == x)
00944           {
00945             selected = x;
00946           }
00947
00948         } //endfor
00949         VariantClear(&vList);
00950         ComboBox_SetCurSel(hCombo, selected);
00951       }
00952
00953       qualSet->Release();
00954       qualSet = 0;
00955     } //endif GetPropertyQualifierSet()
00956
00957     service->Release();
00958
00959   } //endif GetPtr()
00960
00961 }
00962
00963 const TCHAR *CBicycle::ConvertSurfaceValue(BYTE val)
00964 {
00965   // Convert a enum to a string using the Value{} array.
00966   static TCHAR temp[128] = {0};
00967
00968   return temp;
00969 }
00970
00971 HRESULT CBicycle::PutProperty(LPWSTR propName, LPTSTR str)
00972 {
00973   HRESULT hr = E_FAIL;
00974   if(m_inst)
00975   {
00976     VARIANT pVal;
00977     bstr_t temp(str);
00978
00979     VariantInit(&pVal);
00980     V_BSTR(&pVal) = temp;
00981     V_VT(&pVal) = VT_BSTR;
00982
00983     hr = m_inst->Put(propName, 0L, &pVal, 0);
00984
00985     VariantClear(&pVal);
00986   } //endif (m_inst)
00987
00988     return hr;
00989 }
00990
00991 HRESULT CBicycle::PutProperty(LPWSTR propName, BYTE val)
00992 {
00993   HRESULT hr = E_FAIL;
00994   if(m_inst)
00995   {
00996     VARIANT pVal;
00997
00998     VariantInit(&pVal);
00999     V_UI1(&pVal) = val;
01000     V_VT(&pVal) = VT_UI1;
01001
01002     hr = m_inst->Put(propName, 0L, &pVal, 0);
01003
01004     VariantClear(&pVal);
01005   } //endif (m_inst)
01006
01007     return hr;
01008 }
01009
01010 HRESULT CBicycle::PutProperty(LPWSTR propName, bool val)
01011 {
01012   HRESULT hr = E_FAIL;
01013   if(m_inst)
01014   {
01015     VARIANT pVal;
01016
01017     VariantInit(&pVal);
01018     V_BOOL(&pVal) = (val?VARIANT_TRUE: VARIANT_FALSE);
01019     V_VT(&pVal) = VT_BOOL;
01020
01021     hr = m_inst->Put(propName, 0L, &pVal, 0);
01022
01023     VariantClear(&pVal);
01024
01025   } //endif (m_inst)
01026
01027     return hr;
01028 }
01029
01030 // handle anything special when the user clicks Apply or Ok
01031 // on the property sheet.  This sample directly accesses the
01032 // operated-on object, so there's nothing special do to...
01033 HRESULT CBicycle::OnPropertyChange()
01034 {
01035     return S_OK;
01036 }
01037
01038 HRESULT CBicycle::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
01039 {
01040     IConsoleVerb *pConsoleVerb;
01041
01042     HRESULT hr = pConsole->QueryConsoleVerb(&pConsoleVerb);
01043     _ASSERT(SUCCEEDED(hr));
01044
01045     // can't get to properties (via the standard methods) unless
01046     // we tell MMC to display the Properties menu item and
01047     // toolbar button, this wil give the user a visual cue that
01048     // there's "something" to do
01049     hr = pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
01050
01051     pConsoleVerb->Release();
01052
01053     return S_OK;
01054 }
01055
01056 // Implement the dialog proc
01057 BOOL CALLBACK CBicycle::DialogProc(
01058                                   HWND hwndDlg,  // handle to dialog box
01059                                   UINT uMsg,     // message
01060                                   WPARAM wParam, // first message parameter
01061                                   LPARAM lParam  // second message parameter
01062                                   )
01063 {
01064     static CBicycle *pBike = NULL;
01065
01066     switch (uMsg)
01067   {
01068     case WM_INITDIALOG:
01069     {
01070       // catch the "this" pointer so we can actually operate on the object
01071       pBike = reinterpret_cast<CBicycle *>(reinterpret_cast<PROPSHEETPAGE *>(lParam)->lParam);
01072
01073       SetDlgItemText(hwndDlg, IDC_PEOPLE_NAME, pBike->GetDisplayName(NAME_COL));
01074       SetDlgItemText(hwndDlg, IDC_PEOPLE_COLOR, pBike->GetDisplayName(COLOR_COL));
01075       SetDlgItemText(hwndDlg, IDC_PEOPLE_MATERIAL, pBike->GetDisplayName(MATERIAL_COL));
01076       SetDlgItemText(hwndDlg, IDC_PEOPLE_OWNER, pBike->GetDisplayName(OWNER_COL));
01077
01078       Button_SetCheck(GetDlgItem(hwndDlg, IDC_PEOPLE_GIRLS),
01079               (pBike->GetGirls()? BST_CHECKED: BST_UNCHECKED));
01080
01081       VARIANT pVal;
01082       VariantInit(&pVal);
01083       if(SUCCEEDED(pBike->m_inst->Get((bstr_t)L"Surface", 0L, &pVal, NULL, NULL)))
01084       {
01085         pBike->m_iSurface = V_UI1(&pVal);
01086         pBike->LoadSurfaces(hwndDlg, pBike->m_iSurface);
01087
01088         VariantClear(&pVal);
01089       }
01090
01091     }
01092         break;
01093
01094     case WM_COMMAND:
01095         // turn the Apply button on
01096         if (HIWORD(wParam) == EN_CHANGE ||
01097             HIWORD(wParam) == CBN_SELCHANGE)
01098             SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
01099         break;
01100
01101     case WM_DESTROY:
01102         // tell MMC that we're done with the property sheet (we got this
01103         // handle in CreatePropertyPages
01104         MMCFreeNotifyHandle(pBike->m_ppHandle);
01105         break;
01106
01107     case WM_NOTIFY:
01108
01109     switch(((NMHDR *)lParam)->code)
01110     {
01111         case PSN_APPLY:
01112       {
01113         bool changed = false;
01114         TCHAR temp[50] = {0};
01115         HRESULT hr = S_OK;
01116
01117         HWND hWnd = GetDlgItem(hwndDlg, IDC_PEOPLE_NAME);
01118         if(hWnd && Edit_GetModify(hWnd))
01119         {
01120           GetWindowText(hWnd, temp, 50);
01121           changed |= SUCCEEDED(pBike->PutProperty(L"Name", temp));
01122         }
01123
01124         hWnd = GetDlgItem(hwndDlg, IDC_PEOPLE_COLOR);
01125         if(hWnd && Edit_GetModify(hWnd))
01126         {
01127           GetWindowText(hWnd, temp, 50);
01128           changed |= SUCCEEDED(pBike->PutProperty(L"Color", temp));
01129         }
01130
01131         hWnd = GetDlgItem(hwndDlg, IDC_PEOPLE_MATERIAL);
01132         if(hWnd && Edit_GetModify(hWnd))
01133         {
01134           GetWindowText(hWnd, temp, 50);
01135           changed |= SUCCEEDED(pBike->PutProperty(L"Material", temp));
01136         }
01137
01138         hWnd = GetDlgItem(hwndDlg, IDC_PEOPLE_OWNER);
01139         if(hWnd && Edit_GetModify(hWnd))
01140         {
01141           GetWindowText(hWnd, temp, 50);
01142           changed |= SUCCEEDED(hr = pBike->PutProperty(L"Owner", temp));
01143         }
01144
01145         hWnd = GetDlgItem(hwndDlg, IDC_PEOPLE_SURFACE);
01146
01147         if(hWnd)
01148         {
01149           BYTE newValue = ComboBox_GetCurSel(hWnd);
01150           if(newValue != pBike->m_iSurface)
01151           {
01152             changed |= SUCCEEDED(pBike->PutProperty(L"Surface", newValue));
01153           }
01154         }
01155
01156         hWnd = GetDlgItem(hwndDlg, IDC_PEOPLE_GIRLS);
01157         if(hWnd)
01158         {
01159           bool checked = (Button_GetState(hWnd) & BST_CHECKED);
01160           bool wasChecked = pBike->GetGirls();
01161           // did it change?
01162           if(checked != wasChecked)
01163           {
01164             changed |= SUCCEEDED(pBike->PutProperty(L"Girls", checked));
01165           }
01166         }
01167
01168         // if any property changed, write it back to WMI.
01169         if(changed)
01170         {
01171           IWbemServices *service = 0;
01172           // dialogs run in their own thread so use the marshaling helper
01173           // get a useable IWbemServices ptr.
01174           // NOTE: IWbemClassObjects are in-proc so they DONT need to be
01175           // marshaled.
01176           if(SUCCEEDED(pBike->m_parent->GetPtr(&service)))
01177           {
01178             service->PutInstance(pBike->m_inst, WBEM_FLAG_CREATE_OR_UPDATE, 0, 0);
01179             service->Release();
01180                   HRESULT hr = MMCPropertyChangeNotify(pBike->m_ppHandle, (long)pBike);
01181           }
01182         }
01183       }
01184       break;
01185         } // endswitch (((NMHDR *)lParam)->code)
01186
01187         break;
01188
01189     } // endswitch (uMsg)
01190
01191     return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
01192 }
01193
01194
01195 HRESULT CBicycle::HasPropertySheets()
01196 {
01197     // say "yes" when MMC asks if we have pages
01198     return S_OK;
01199 }
01200
01201 HRESULT CBicycle::CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle)
01202 {
01203     PROPSHEETPAGE psp;
01204     HPROPSHEETPAGE hPage = NULL;
01205
01206     // cache this handle so we can call MMCPropertyChangeNotify
01207     m_ppHandle = handle;
01208
01209     // create the property page for this node.
01210     // NOTE: if your node has multiple pages, put the following
01211     // in a loop and create multiple pages calling
01212     // lpProvider->AddPage() for each page.
01213     psp.dwSize = sizeof(PROPSHEETPAGE);
01214     psp.dwFlags = PSP_DEFAULT | PSP_USETITLE;
01215     psp.hInstance = g_hinst;
01216     psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_PEOPLE);
01217     psp.pfnDlgProc = DialogProc;
01218     psp.lParam = reinterpret_cast<LPARAM>(this);
01219     psp.pszTitle = MAKEINTRESOURCE(IDS_BIKE_TITLE);
01220
01221
01222     hPage = CreatePropertySheetPage(&psp);
01223     _ASSERT(hPage);
01224
01225     return lpProvider->AddPage(hPage);
01226 }
01227
01228 HRESULT CBicycle::GetWatermarks(HBITMAP *lphWatermark,
01229                    HBITMAP *lphHeader,
01230                    HPALETTE *lphPalette,
01231                    BOOL *bStretch)
01232 {
01233     return S_FALSE;
01234 }
01235
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDBAuthPlugin Member List

This is the complete list of members for CDBAuthPlugin, including all inherited members.
AddUser(LPCWSTR pwszUserName) | CDBAuthPlugin |
AuthorizeEvent(WMS_EVENT *pEvent, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx, IWMSEventAuthorizationCallback *pCallback, VARIANT Context) | CDBAuthPlugin |
CDBAuthPlugin() | CDBAuthPlugin |
CreateArrayOfEvents(VARIANT *pvarEvents, WMS_EVENT_TYPE *pWMSEvents, long nNumEvents) | CDBAuthPlugin | [private]
DisablePlugin() | CDBAuthPlugin |
EnablePlugin(long *pdwFlags, long *pdwHeartbeatPeriod) | CDBAuthPlugin |
GetAuthorizedEvents(VARIANT *pvarAuthorizedEvents) | CDBAuthPlugin |
GetCustomAdminInterface(IDispatch **ppValue) | CDBAuthPlugin |
GetSIDFromName(LPCWSTR pwszUserName, PSID *ppSid) | CDBAuthPlugin | [private]
GetUsers(BSTR *pbstrUserNames) | CDBAuthPlugin |
InitializePlugin(IWMSContext *pServerContext, IWMSNamedValues *pNamedValues, IWMSClassObject *pClassFactory) | CDBAuthPlugin |
Lock() | CDBAuthPlugin | [private]
m_CritSec | CDBAuthPlugin | [private]
m_pSids | CDBAuthPlugin | [private]
m_spNamedValues | CDBAuthPlugin | [private]
m_spServer | CDBAuthPlugin | [private]
OnAuthorizeOpen(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CDBAuthPlugin | [private]
OnHeartbeat() | CDBAuthPlugin |
RemoveUser(LPCWSTR pwszUserName) | CDBAuthPlugin |
ShutdownPlugin() | CDBAuthPlugin |
Unlock() | CDBAuthPlugin | [private]
VerifySidMembership(PSID pSid, DWORD *pdwIndex) | CDBAuthPlugin | [private]
VerifyUserMembership(LPCWSTR pwszUserName, BOOL *pfFound, DWORD *pdwIndex) | CDBAuthPlugin |
~CDBAuthPlugin() | CDBAuthPlugin |
Generated on Wed Nov 13 2024 16:56:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptServe/AptServe.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptServe

AptServe.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      APTSERVE.H
00003
00004   Summary:   Include file for the APTSERVE code sample application.
00005              In addition to class definitions, this APTSERVE.H file
00006              contains definitions of the application's menu, string,
00007              and other resource IDs.
00008
00009              For a comprehensive tutorial code tour of APTSERVE's
00010              contents and offerings see the tutoorial APTSERVE.HTM file.
00011              For more specific technical details on the internal workings
00012              see the comments dispersed throughout the APTSERVE source code.
00013
00014   Classes:   CMainWindow
00015
00016   Functions: WinMain
00017
00018   Origin:    3-20-96: atrent - Editor-inheritance from the LOCSERVE source.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 #if !defined(APTSERVE_H)
00036 #define APTSERVE_H
00037
00038 #ifdef __cplusplus
00039
00040 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00041   Class:    CMainWindow
00042
00043   Summary:  Class to encapsulate the application's main window, menu, and
00044             message dispatching behavior.
00045
00046   Methods:  CMainWindow
00047               Constructor.
00048             InitInstance
00049               Creates a new instance of the main window.
00050 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00051 class CMainWindow: public CVirWindow
00052 {
00053 public:
00054   CMainWindow();
00055   ~CMainWindow();
00056   BOOL InitInstance(HINSTANCE, int);
00057
00058   // Methods for registering and unregistering this server.
00059   BOOL RegisterServer(void);
00060   BOOL UnregisterServer(void);
00061
00062   // For message box dialogs.
00063   CMsgBox*  m_pMsgBox;
00064   CSendLog* m_pMsgLog;
00065
00066 protected:
00067   LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00068
00069 private:
00070   LRESULT DoMenu(WPARAM wParam, LPARAM lParam);
00071 };
00072
00073 #endif // __cplusplus
00074
00075 // Window Class String Macros.
00076 #define MAIN_WINDOW_TITLE_STR       "APTSERVE: Tutorial Code Sample"
00077 #define MAIN_WINDOW_CLASS_NAME_STR  "APTSERVEWindow"
00078 #define MAIN_WINDOW_CLASS_MENU_STR  "APTSERVEMenu"
00079 #define CLIENT_WINDOW_TITLE         "APTCLIEN: Tutorial Code Sample"
00080
00081 // File Menu Command Identifiers.
00082 #define IDM_FILE_EXIT               1000
00083
00084 // Log Menu Command Identifiers.
00085 #define IDM_LOG_LOGCLEAR            1890
00086 #define IDM_LOG_COPYCLIP            1891
00087
00088 // Help Menu Command Identifiers.
00089 #define IDM_HELP_ABOUT              1905
00090
00091 // Error-related String Identifiers.
00092 #define IDS_COMINITFAILED           2000
00093 #define IDS_APPINITFAILED           2001
00094 #define IDS_OUTOFMEMORY             2002
00095 #define IDS_NOHELPFILE              2003
00096 #define IDS_NOUNICODE               2004
00097 #define IDS_NOSERVER                2005
00098
00099 #define IDS_ASSERT_FAIL             2200
00100
00101 // Notice-related String Identifiers.
00102 #define IDS_NOTIMPLEMENTED          2301
00103
00104 // Log Message String Identifiers.
00105 #define IDS_LOGTO_CLIENT            2400
00106 #define IDS_LOGTO_SERVER            2401
00107
00108 #endif  // APTSERVE_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Child/vc/Child.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Child
  • vc

Child.cpp

Go to the documentation of this file.
00001 // Child.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "stdio.h"
00006 #include "activeds.h"
00007
00008 #define RETURN_ON_FAILURE(hr) if(!SUCCEEDED(hr)) return hr;
00009
00010
00011 int main(int argc, char* argv[])
00012 {
00013   HRESULT hr;
00014
00015   CoInitialize(NULL);
00016
00017   IADsContainer *pCont=NULL;
00018
00019   hr = ADsGetObject(L"LDAP://DC=mydomain2,DC=mydomain1,DC=microsoft,DC=com",
00020                   IID_IADsContainer,
00021             (void**) &pCont );
00022
00023   RETURN_ON_FAILURE(hr);
00024
00025
00026   /////////////////////////////////////////////////////////////
00027   // Get the child from the container
00028   // Note in the LDAP provider you can go down more than one level
00029   ///////////////////////////////////////////////////////////////
00030   IDispatch *pDisp = NULL;
00031   IADs    *pADs  = NULL;
00032   hr = pCont->GetObject(L"user", L"CN=Mike Smith, OU=myou1", &pDisp );
00033   pCont->Release();
00034
00035   RETURN_ON_FAILURE(hr);
00036
00037
00038   hr = pDisp->QueryInterface( IID_IADs, (void**) &pADs );
00039   pDisp->Release();
00040   RETURN_ON_FAILURE(hr);
00041
00042   // ... do something with pADs here .
00043   pADs->Release();
00044
00045
00046   CoUninitialize();
00047   return 0;
00048 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/PreComp.Hxx Source File

  • WinUI
  • GlobalDev
  • CSSamp

PreComp.Hxx

Go to the documentation of this file.
00001 ////    precomp.hxx
00002 //
00003
00004 #include <windows.h>
00005 #include <commdlg.h>
00006
00007 #include "usp10.h"
00008
00009 #include <stdlib.h>
00010 #include <malloc.h>
00011 #include <memory.h>
00012 #include <string.h>
00013
00014 #include "resource.h"
00015
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/Eap/CeapCfg.Cpp Source File

  • NetDS
  • RRas
  • Eap

CeapCfg.Cpp

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1997, Microsoft Corporation, all rights reserved
00004
00005 Description:
00006
00007 History:
00008
00009 */
00010
00011 #include "ceapcfg.h"
00012
00013 extern "C"
00014 DWORD APIENTRY
00015 RasEapInvokeConfigUI(
00016     IN  DWORD       dwEapTypeId,
00017     IN  HWND        hwndParent,
00018     IN  DWORD       dwFlags,
00019     IN  BYTE*       pConnectionDataIn,
00020     IN  DWORD       dwSizeOfConnectionDataIn,
00021     OUT BYTE**      ppConnectionDataOut,
00022     OUT DWORD*      pdwSizeOfConnectionDataOut
00023 );
00024
00025 extern "C"
00026 DWORD
00027 GetIdentity(
00028     IN  HWND    hwndParent,
00029     IN  BYTE*   pUserDataIn,
00030     IN  DWORD   dwSizeOfUserDataIn,
00031     OUT BYTE**  ppUserDataOut,
00032     OUT DWORD*  pdwSizeOfUserDataOut,
00033     OUT WCHAR** ppwszIdentityOut
00034 );
00035
00036 extern "C"
00037 DWORD APIENTRY
00038 RasEapFreeMemory(
00039     IN  BYTE*   pMemory
00040 );
00041
00042 /*
00043
00044 Notes:
00045     Implementation of IEAPProviderConfig::Initialize
00046
00047 */
00048
00049 STDMETHODIMP
00050 CEapCfg::Initialize(
00051     LPCOLESTR   pwszMachineName,
00052     DWORD       dwEapTypeId,
00053     ULONG_PTR*  puConnectionParam
00054 )
00055 {
00056     DWORD       cch;
00057     WCHAR*      pwsz    = NULL;
00058     DWORD       dwErr   = NO_ERROR;
00059
00060     *puConnectionParam = NULL;
00061
00062     //
00063     // Save machine name as connection param.
00064     //
00065
00066     //
00067     // How many chars are there in the name?
00068     //
00069     if ( NULL == pwszMachineName )
00070     {
00071         dwErr = ERROR_INVALID_PARAMETER;
00072         goto LDone;
00073     }
00074     cch = wcslen(pwszMachineName);
00075
00076     pwsz = (WCHAR*) LocalAlloc(LPTR, (cch + 1) * sizeof(WCHAR));
00077
00078     if (NULL == pwsz)
00079     {
00080         dwErr = GetLastError();
00081         goto LDone;
00082     }
00083
00084     //
00085     // Copy machine name
00086     //
00087
00088     wcsncpy(pwsz, pwszMachineName, cch);
00089     *puConnectionParam = (ULONG_PTR)pwsz;
00090     pwsz = NULL;
00091
00092 LDone:
00093
00094     LocalFree(pwsz);
00095
00096     return(HRESULT_FROM_WIN32(dwErr));
00097 }
00098
00099 /*
00100
00101 Notes:
00102     Implementation of IEAPProviderConfig::Uninitialize
00103
00104 */
00105
00106 STDMETHODIMP
00107 CEapCfg::Uninitialize(
00108     DWORD       dwEapTypeId,
00109     ULONG_PTR   uConnectionParam
00110 )
00111 {
00112     LocalFree((VOID*)uConnectionParam);
00113     return(HRESULT_FROM_WIN32(NO_ERROR));
00114 }
00115
00116 /*
00117
00118 Notes:
00119     Implementation of IEAPProviderConfig::ServerInvokeConfigUI
00120         hWnd - handle to the parent window
00121         dwRes1 - reserved parameter (ignore)
00122         dwRes2 - reserved parameter (ignore)
00123
00124 */
00125
00126 STDMETHODIMP
00127 CEapCfg::ServerInvokeConfigUI(
00128     DWORD       dwEapTypeId,
00129     ULONG_PTR   uConnectionParam,
00130     HWND        hWnd,
00131     DWORD_PTR   dwRes1,
00132     DWORD_PTR   dwRes2
00133 )
00134 {
00135     WCHAR*      pwszMachineName;
00136     HRESULT     hr;
00137     DWORD       dwErr;
00138
00139     pwszMachineName = (WCHAR*)uConnectionParam;
00140
00141     if (NULL == pwszMachineName)
00142     {
00143         dwErr = E_FAIL;
00144     }
00145     else
00146     {
00147         MessageBox(hWnd, pwszMachineName, L"You are configuring the EAP on...",
00148             MB_OK | MB_ICONINFORMATION);
00149     }
00150
00151     hr = HRESULT_FROM_WIN32(dwErr);
00152
00153     return(hr);
00154 }
00155
00156 /*
00157
00158 Notes:
00159     Implementation of IEAPProviderConfig::RouterInvokeConfigUI
00160
00161 */
00162
00163 STDMETHODIMP
00164 CEapCfg::RouterInvokeConfigUI(
00165     DWORD       dwEapTypeId,
00166     ULONG_PTR   uConnectionParam,
00167     HWND        hwndParent,
00168     DWORD       dwFlags,
00169     BYTE*       pConnectionDataIn,
00170     DWORD       dwSizeOfConnectionDataIn,
00171     BYTE**      ppConnectionDataOut,
00172     DWORD*      pdwSizeOfConnectionDataOut
00173 )
00174 {
00175     DWORD       dwErr                       = NO_ERROR;
00176     BYTE*       pConnectionDataOut          = NULL;
00177     DWORD       dwSizeOfConnectionDataOut   = 0;
00178
00179     *ppConnectionDataOut = NULL;
00180     *pdwSizeOfConnectionDataOut = 0;
00181
00182     dwErr = RasEapInvokeConfigUI(
00183                 dwEapTypeId,
00184                 hwndParent,
00185                 dwFlags,
00186                 pConnectionDataIn,
00187                 dwSizeOfConnectionDataIn,
00188                 &pConnectionDataOut,
00189                 &dwSizeOfConnectionDataOut);
00190
00191     if (   (NO_ERROR == dwErr)
00192         && (0 != dwSizeOfConnectionDataOut))
00193     {
00194         //
00195         // If we got valid ConnectionDataOut, allocate memory for it...
00196         //
00197
00198         *ppConnectionDataOut = (BYTE*)CoTaskMemAlloc(dwSizeOfConnectionDataOut);
00199
00200         if (NULL == *ppConnectionDataOut)
00201         {
00202             dwErr = ERROR_NOT_ENOUGH_MEMORY;
00203             goto LDone;
00204         }
00205
00206         //
00207         // ... and return it in the OUT parameter
00208         //
00209
00210         CopyMemory(*ppConnectionDataOut, pConnectionDataOut,
00211             dwSizeOfConnectionDataOut);
00212         *pdwSizeOfConnectionDataOut = dwSizeOfConnectionDataOut;
00213     }
00214
00215 LDone:
00216
00217     RasEapFreeMemory(pConnectionDataOut);
00218
00219     return(HRESULT_FROM_WIN32(dwErr));
00220 }
00221
00222 /*
00223
00224 Notes:
00225     Implementation of IEAPProviderConfig::RouterInvokeCredentialsUI
00226
00227 */
00228
00229 STDMETHODIMP
00230 CEapCfg::RouterInvokeCredentialsUI(
00231     DWORD       dwEapTypeId,
00232     ULONG_PTR   uConnectionParam,
00233     HWND        hwndParent,
00234     DWORD       dwFlags,
00235     BYTE*       pConnectionDataIn,
00236     DWORD       dwSizeOfConnectionDataIn,
00237     BYTE*       pUserDataIn,
00238     DWORD       dwSizeOfUserDataIn,
00239     BYTE**      ppUserDataOut,
00240     DWORD*      pdwSizeOfUserDataOut
00241 )
00242 {
00243     BYTE*       pUserDataOut            = NULL;
00244     DWORD       dwSizeOfUserDataOut;
00245     WCHAR*      pwszIdentityOut         = NULL;
00246     DWORD       dwErr                   = NO_ERROR;
00247
00248     *ppUserDataOut = NULL;
00249     *pdwSizeOfUserDataOut = 0;
00250
00251     dwErr = GetIdentity(
00252                     hwndParent,
00253                     NULL /* pUserDataIn */,
00254                     0 /* dwSizeOfUserDataIn */,
00255                     &pUserDataOut,
00256                     &dwSizeOfUserDataOut,
00257                     &pwszIdentityOut);
00258
00259     if (   (NO_ERROR == dwErr)
00260         && (0 != dwSizeOfUserDataOut))
00261     {
00262         //
00263         // If we got valid UserDataOut, allocate memory for it...
00264         //
00265
00266         *ppUserDataOut = (BYTE*)CoTaskMemAlloc(dwSizeOfUserDataOut);
00267
00268         if (NULL == *ppUserDataOut)
00269         {
00270             dwErr = ERROR_NOT_ENOUGH_MEMORY;
00271             goto LDone;
00272         }
00273
00274         //
00275         // ... and return it in the OUT parameter
00276         //
00277
00278         CopyMemory(*ppUserDataOut, pUserDataOut, dwSizeOfUserDataOut);
00279         *pdwSizeOfUserDataOut = dwSizeOfUserDataOut;
00280     }
00281
00282 LDone:
00283
00284     LocalFree(pUserDataOut);
00285     LocalFree((BYTE*)pwszIdentityOut);
00286
00287     return(HRESULT_FROM_WIN32(dwErr));
00288 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/Debug.Cpp Source File

  • WinUI
  • GlobalDev
  • CSSamp

Debug.Cpp

Go to the documentation of this file.
00001 #include "precomp.hxx"
00002 #include <shlwapi.h>
00003 #include "global.h"
00004
00005 ////    DebugMsg - display a message via OutputDebugString
00006 //
00007 //      DebugMsg formats debug messages, including the file name
00008 //      and line number the message originated form.
00009 //
00010 //      Supports the TRACEMSG and TRACE macros.
00011 //
00012 //      The current timer is adjusted to remove debug message
00013 //      output from timing results.
00014
00015 extern "C" void WINAPIV DebugMsg(char *fmt, ...)
00016 {
00017     va_list vargs;
00018     char c[200];
00019
00020 //    TIMESUSPEND;
00021
00022     wnsprintfA(c,sizeof(c),"%s[%d]                   ", strrchr(DG.psFile, '\\')+1, DG.iLine);
00023     c[17] = 0;
00024     OutputDebugStringA(c);
00025
00026     wnsprintfA(c,sizeof(c),"%ld:      ", GetCurrentThreadId());
00027     c[5] = 0;
00028     OutputDebugStringA(c);
00029
00030     va_start(vargs, fmt);
00031     wvnsprintfA(c,sizeof(c),fmt,vargs);
00032     OutputDebugStringA(c);
00033
00034     OutputDebugStringA("\n");
00035
00036 //    TIMERESUME;
00037 }
00038
00039 extern "C" void WINAPIV DebugHr(char *fmt, ...)
00040 {
00041     va_list vargs;
00042     char c[200];
00043
00044 //    TIMESUSPEND;
00045
00046     wsprintfA(c, "%s[%d]                   ", strrchr(DG.psFile, '\\')+1, DG.iLine);
00047     c[17] = 0;
00048     OutputDebugStringA(c);
00049
00050     wsprintfA(c, "%ld:      ", GetCurrentThreadId());
00051     c[5] = 0;
00052     OutputDebugStringA(c);
00053
00054     va_start(vargs, fmt);
00055     wvnsprintfA(c,sizeof(c), fmt, vargs);
00056     OutputDebugStringA(c);
00057
00058     //
00059     // Parse USP and Win32 Errors
00060     //
00061
00062     switch( DG.hrLastError )
00063     {
00064     case USP_E_SCRIPT_NOT_IN_FONT:
00065       lstrcpyA( DG.sLastError , "Selected font doesn't contain requested script\n");
00066       break;
00067
00068     default:
00069       FormatMessageA(
00070           FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
00071           NULL, DG.hrLastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
00072           DG.sLastError, sizeof(DG.sLastError), NULL);
00073     }
00074
00075     wnsprintfA(c,sizeof(c)," -- HRESULT = %x: %s", DG.hrLastError, DG.sLastError);
00076     OutputDebugStringA(c);
00077 //    TIMERESUME;
00078 }
00079
00080
00081
00082
00083
00084
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/Msi/setup.exe/utils.cpp Source File

  • SysMgmt
  • Msi
  • setup.exe

utils.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved.
00004 //
00005 //  File:       utils.cpp
00006 //
00007 //--------------------------------------------------------------------------
00008
00009 #include "setup.h"
00010 #include "resource.h"
00011 #include "common.h"
00012
00013 #include "msi.h"
00014
00015 #include <assert.h>
00016 #include <tchar.h>
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include <stdarg.h>
00020 #include <strsafe.h>
00021
00022 #define WIN // scope W32 API
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // VerifyFileSignature
00026 //
00027 DWORD VerifyFileSignature (LPCSTR lpszModule, LPSTR lpszCmdLine)
00028 {
00029     LPCSTR  pszFirstArgEnd;
00030     LPCSTR  pszFileName;
00031     LPCSTR  pszEnd;
00032     DWORD   Status;
00033
00034     //
00035     // When this function is called, the first argument has already
00036     // been verified. So skip the first argument.
00037     //
00038     GetNextArgument (lpszCmdLine, NULL, &pszFirstArgEnd, NULL);
00039
00040     // Now get the name of the file whose signature needs to be verified.
00041     Status = GetNextArgument (CharNextA(pszFirstArgEnd), &pszFileName, &pszEnd, NULL);
00042
00043     // Must supply a filename
00044     if (ERROR_NO_MORE_ITEMS == Status)
00045         return ERROR_BAD_ARGUMENTS;
00046
00047     // Should not have any more arguments
00048     if ('\0' != *(CharNextA(pszEnd)) &&
00049         ERROR_NO_MORE_ITEMS != GetNextArgument (CharNextA(CharNextA(pszEnd)), NULL, NULL, NULL))
00050     {
00051         return ERROR_BAD_ARGUMENTS;
00052     }
00053
00054     // We have the right arguments. Null terminate the filename.
00055     *(CharNextA(pszEnd)) = '\0';
00056
00057     switch (IsPackageTrusted(lpszModule, pszFileName, NULL))
00058     {
00059     case itvWintrustNotOnMachine:
00060         return TRUST_E_PROVIDER_UNKNOWN;
00061     case itvTrusted:
00062         return ERROR_SUCCESS;
00063     case itvUnTrusted:
00064     default:
00065         return TRUST_E_SUBJECT_NOT_TRUSTED;
00066     }
00067 }
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 // GetExecutionMode
00071 //
00072 emEnum GetExecutionMode (LPCSTR lpszCmdLine)
00073 {
00074     LPCSTR  pszStart = NULL;
00075     LPCSTR  pszEnd = NULL;
00076     DWORD   dwStatus = ERROR_SUCCESS;
00077     bool    fQuoted = false;
00078     //
00079     // Check the first argument and set the execution mode accordingly.
00080     // When run without arguments, it is assumed that the default install
00081     // preset by the package publisher needs to be performed.
00082     //
00083     // In case an invalid option is provided, the help dialog describing the
00084     // usage must be displayed.
00085     //
00086     dwStatus = GetNextArgument (lpszCmdLine, &pszStart, &pszEnd, &fQuoted);
00087
00088     if (ERROR_NO_MORE_ITEMS == dwStatus)
00089         return emPreset;
00090
00091     // The only allowed values in the first argument are /a, /v and /?
00092     if (pszEnd != CharNextA(pszStart) || fQuoted)
00093         return emHelp;
00094
00095     if ('/' != (*pszStart) && '-' != (*pszStart))
00096         return emHelp;
00097
00098     switch (*pszEnd)
00099     {
00100     case 'a':
00101     case 'A':
00102         return emAdminInstall;
00103     case 'v':
00104     case 'V':
00105         return emVerify;
00106     default:
00107         return emHelp;
00108     }
00109 }
00110
00111 /////////////////////////////////////////////////////////////////////////////
00112 // GetNextArgument
00113 //
00114 DWORD GetNextArgument (LPCSTR pszCmdLine, LPCSTR *ppszArgStart, LPCSTR *ppszArgEnd, bool * pfQuoted)
00115 {
00116     bool    fInQuotes = false;
00117     bool    fFoundArgEnd = false;
00118     LPCSTR  pszChar = pszCmdLine;
00119     LPCSTR  pszFirst = NULL;
00120     LPCSTR  pszLast = NULL;
00121
00122     if (NULL == pszChar)
00123         return ERROR_NO_MORE_ITEMS;
00124
00125     // Skip leading spaces.
00126     while (' ' == *pszChar || '\t' == *pszChar)
00127         pszChar = CharNextA(pszChar);
00128
00129     // Check if we have run out of arguments.
00130     if ('\0' == (*pszChar))
00131         return ERROR_NO_MORE_ITEMS;
00132
00133     // Check if we this argument has been enclosed in quotes
00134     if ('\"' == (*pszChar))
00135     {
00136         fInQuotes = true;
00137         pszChar = CharNextA (pszChar);
00138     }
00139
00140     pszFirst = pszChar;
00141
00142     // Now look for the end of the argument
00143     while (! fFoundArgEnd)
00144     {
00145         pszChar = CharNextA(pszChar);
00146
00147         if ('\0' == (*pszChar))
00148             fFoundArgEnd = true;
00149
00150         if (fInQuotes && '\"' == (*pszChar))
00151             fFoundArgEnd = true;
00152
00153         if (!fInQuotes && ' ' == (*pszChar))
00154             fFoundArgEnd = true;
00155
00156         if (!fInQuotes && '\t' == (*pszChar))
00157             fFoundArgEnd = true;
00158     }
00159
00160     pszLast = CharPrevA (pszFirst, pszChar);
00161
00162     if (ppszArgStart)
00163         *ppszArgStart = pszFirst;
00164
00165     if (ppszArgEnd)
00166         *ppszArgEnd = pszLast;
00167
00168     if (pfQuoted)
00169         *pfQuoted = fInQuotes;
00170
00171     return ERROR_SUCCESS;
00172 }
00173
00174 /////////////////////////////////////////////////////////////////////////////
00175 //
00176 //
00177 DWORD GetAdminInstallInfo (bool fPatch, LPSTR lpszCmdLine, LPCSTR * ppszAdminImagePath)
00178 {
00179     LPCSTR  pszFirstArgEnd;
00180     LPCSTR  pszFileName;
00181     LPCSTR  pszEnd;
00182     DWORD   Status;
00183
00184     //
00185     // When this function is called, the first argument has already been
00186     // verified. So skip the first argument.
00187     //
00188     GetNextArgument (lpszCmdLine, NULL, &pszFirstArgEnd, NULL);
00189
00190     // See if there is another argument
00191     Status = GetNextArgument (CharNextA(pszFirstArgEnd), &pszFileName, &pszEnd, NULL);
00192
00193     // If it is not a patch, there should not be any more arguments.
00194     if (!fPatch)
00195     {
00196         if (ERROR_NO_MORE_ITEMS != Status)
00197             return ERROR_BAD_ARGUMENTS;
00198
00199         // If we are here, then we are done, because we have all the information we need.
00200         if (ppszAdminImagePath)
00201             *ppszAdminImagePath = NULL;
00202         return ERROR_SUCCESS;
00203     }
00204
00205     // If we are here, this is a patch. Get the path to the admin. install.
00206     if (ERROR_NO_MORE_ITEMS == Status)
00207         return ERROR_BAD_ARGUMENTS;     // No path was supplied.
00208
00209     // Should not have any more arguments.
00210     if ('\0' != *(CharNextA(pszEnd)) &&
00211         ERROR_NO_MORE_ITEMS != GetNextArgument (CharNextA(CharNextA(pszEnd)), NULL, NULL, NULL))
00212     {
00213         return ERROR_BAD_ARGUMENTS;
00214     }
00215
00216     // We have the right arguments. Null terminate the pathname.
00217     *(CharNextA(pszEnd)) = '\0';
00218
00219     if (ppszAdminImagePath)
00220         *ppszAdminImagePath = pszFileName;
00221
00222     return ERROR_SUCCESS;
00223 }
00224
00225 /////////////////////////////////////////////////////////////////////////////
00226 // LoadResourceString
00227 //
00228 UINT LoadResourceString(HINSTANCE hInst, LPCSTR lpType, LPCSTR lpName, LPSTR lpBuf, DWORD *pdwBufSize)
00229 {
00230     HRSRC   hRsrc   = 0;
00231     HGLOBAL hGlobal = 0;
00232     WCHAR   *pch    = 0;
00233
00234     if ((hRsrc = WIN::FindResource(hInst, lpName, lpType)) != 0
00235         && (hGlobal = WIN::LoadResource(hInst, hRsrc)) != 0)
00236     {
00237         // resource exists
00238         if ((pch = (WCHAR*)LockResource(hGlobal)) != 0)
00239         {
00240             unsigned int cch = WideCharToMultiByte(CP_ACP, 0, pch, -1, NULL, 0, NULL, NULL);
00241             if (cch > *pdwBufSize)
00242             {
00243                 *pdwBufSize = cch;
00244                 return ERROR_MORE_DATA;
00245             }
00246
00247             if (0 == WideCharToMultiByte(CP_ACP, 0, pch, -1, lpBuf, *pdwBufSize, NULL, NULL))
00248                 return ERROR_FUNCTION_FAILED;
00249             *pdwBufSize = cch;
00250
00251         }
00252         else
00253         {
00254             if (1 > *pdwBufSize)
00255             {
00256                 *pdwBufSize = 1;
00257                 return ERROR_MORE_DATA;
00258             }
00259
00260             *pdwBufSize = 1;
00261             *lpBuf = 0;
00262         }
00263
00264         DebugMsg("[Resource] lpName = %s, lpBuf = %s\n", lpName, lpBuf);
00265
00266         return ERROR_SUCCESS;
00267     }
00268
00269     // resource does not exist
00270     DebugMsg("[Resource] lpName = %s NOT FOUND\n", lpName);
00271
00272     return ERROR_RESOURCE_NAME_NOT_FOUND;
00273 }
00274
00275 /////////////////////////////////////////////////////////////////////////////
00276 // SetupLoadResourceString
00277 //
00278
00279 UINT SetupLoadResourceString(HINSTANCE hInst, LPCSTR lpName, LPSTR *lppBuf, DWORD dwBufSize)
00280 {
00281     UINT uiStat = 0;
00282     if (!*lppBuf)
00283     {
00284         dwBufSize = (dwBufSize > 0) ? dwBufSize : 256;
00285         *lppBuf = new char[dwBufSize];
00286         if (!*lppBuf)
00287             return ERROR_OUTOFMEMORY;
00288     }
00289
00290     if (ERROR_SUCCESS != (uiStat = LoadResourceString(hInst, RT_INSTALL_PROPERTY, lpName, *lppBuf, &dwBufSize)))
00291     {
00292         if (uiStat != ERROR_MORE_DATA)
00293             return uiStat;
00294
00295         // resize and try again
00296         delete [] *lppBuf;
00297         *lppBuf = new char[dwBufSize];
00298         if (!*lppBuf)
00299             return ERROR_OUTOFMEMORY;
00300
00301         uiStat = LoadResourceString(hInst, RT_INSTALL_PROPERTY, lpName, *lppBuf, &dwBufSize);
00302     }
00303
00304     return uiStat;
00305 }
00306
00307 /////////////////////////////////////////////////////////////////////////////
00308 // PostResourceNotFoundError
00309 //
00310
00311 void PostResourceNotFoundError(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle, LPCSTR szName)
00312 {
00313     char szError[MAX_STR_LENGTH]  = {0};
00314     char szFormat[MAX_STR_LENGTH] = {0};
00315
00316     WIN::LoadString(hInst, IDS_MISSING_RESOURCE, szFormat, sizeof(szFormat)/sizeof(char));
00317     StringCchPrintf(szError, sizeof(szError), szFormat, szName);
00318     MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONEXCLAMATION);
00319 }
00320
00321 /////////////////////////////////////////////////////////////////////////////
00322 // ReportUserCancelled
00323 //
00324
00325 void ReportUserCancelled(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle)
00326 {
00327     char szError[MAX_STR_LENGTH] = {0};
00328
00329     WIN::LoadString(hInst, IDS_USER_CANCELLED, szError, sizeof(szError)/sizeof(char));
00330     MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONEXCLAMATION);
00331 }
00332
00333 /////////////////////////////////////////////////////////////////////////////
00334 // PostError
00335 //
00336
00337 void PostError(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle, UINT uiErrorId)
00338 {
00339     char szError[MAX_STR_LENGTH]  = {0};
00340
00341     WIN::LoadString(hInst, uiErrorId, szError, sizeof(szError)/sizeof(char));
00342     MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONERROR);
00343 }
00344
00345 /////////////////////////////////////////////////////////////////////////////
00346 // PostError
00347 //
00348
00349 void PostError(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle, UINT uiErrorId, LPCSTR szValue)
00350 {
00351     char szError[MAX_STR_LENGTH]  = {0};
00352     char szFormat[MAX_STR_LENGTH] = {0};
00353
00354     WIN::LoadString(hInst, uiErrorId, szFormat, sizeof(szFormat)/sizeof(char));
00355     StringCchPrintf(szError, sizeof(szError), szFormat, szValue);
00356     MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONERROR);
00357 }
00358
00359 /////////////////////////////////////////////////////////////////////////////
00360 // PostError
00361 //
00362
00363 void PostError(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle, UINT uiErrorId, LPCSTR szValue, int iValue)
00364 {
00365     char szError[MAX_STR_LENGTH]  = {0};
00366     char szFormat[MAX_STR_LENGTH] = {0};
00367
00368     WIN::LoadString(hInst, uiErrorId, szFormat, sizeof(szFormat)/sizeof(char));
00369     StringCchPrintf(szError, sizeof(szError), szFormat, szValue, iValue);
00370     MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONERROR);
00371 }
00372
00373 /////////////////////////////////////////////////////////////////////////////
00374 // PostError
00375 //
00376
00377 void PostError(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle, UINT uiErrorId, int iValue)
00378 {
00379     char szError[MAX_STR_LENGTH]  = {0};
00380     char szFormat[MAX_STR_LENGTH] = {0};
00381
00382     WIN::LoadString(hInst, uiErrorId, szFormat, sizeof(szFormat)/sizeof(char));
00383     StringCchPrintf(szError, sizeof(szError), szFormat, iValue);
00384     MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONERROR);
00385 }
00386
00387 /////////////////////////////////////////////////////////////////////////////
00388 // PostFormattedError
00389 //
00390
00391 void PostFormattedError(HINSTANCE hInst, HWND hwndOwner, LPCSTR szTitle, UINT uiErrorId, LPCSTR szValue)
00392 {
00393     char szFormat[MAX_STR_LENGTH] = {0};
00394     const char* szArgs[1] = {szValue};
00395     LPVOID lpMessage = 0;;
00396
00397     WIN::LoadString(hInst, uiErrorId, szFormat, sizeof(szFormat)/sizeof(char));
00398     FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, (LPVOID)szFormat, 0, 0, (LPSTR)&lpMessage, 0, (va_list*)szArgs);
00399     if (!lpMessage)
00400     {
00401         ReportErrorOutOfMemory(hInst, hwndOwner, szTitle);
00402         return;
00403     }
00404     MessageBox(hwndOwner, (LPCSTR)lpMessage, szTitle, MB_OK | MB_ICONERROR);
00405     LocalFree(lpMessage);
00406 }
00407
00408 /////////////////////////////////////////////////////////////////////////////
00409 // PostMsiError
00410 //
00411
00412 void PostMsiError(HINSTANCE hInst, HINSTANCE hMsi, HWND hwndOwner, LPCSTR szTitle, UINT uiErrorId)
00413 {
00414     switch (uiErrorId)
00415     {
00416     case ERROR_INSTALL_SUSPEND:
00417     case ERROR_INSTALL_USEREXIT:
00418     case ERROR_INSTALL_FAILURE:
00419     case ERROR_SUCCESS_REBOOT_REQUIRED:
00420     case ERROR_SUCCESS_REBOOT_INITIATED:
00421     case ERROR_APPHELP_BLOCK:
00422         break;
00423     case ERROR_FILE_NOT_FOUND:
00424     case ERROR_INVALID_NAME:
00425     case ERROR_PATH_NOT_FOUND:
00426         uiErrorId = ERROR_INSTALL_PACKAGE_OPEN_FAILED;
00427     default:
00428         {
00429             char szError[MAX_STR_LENGTH] = {0};
00430             if (0 == WIN::LoadString(hMsi, uiErrorId, szError, sizeof(szError)/sizeof(char)))
00431             {
00432                 // error string does not exist, use default
00433                 PostError(hInst, hwndOwner, szTitle, IDS_INSTALL_ERROR, uiErrorId);
00434             }
00435             else
00436             {
00437                 MessageBox(hwndOwner, szError, szTitle, MB_OK | MB_ICONERROR);
00438             }
00439             return;
00440         }
00441     }
00442 }
00443
00444 /////////////////////////////////////////////////////////////////////////////
00445 // AlreadyInProgress
00446 //
00447 //  Attempts to create the MSISETUP mutex. Returns TRUE
00448 //  if mutex already exists or failed to create mutex
00449 //
00450
00451 bool AlreadyInProgress()
00452 {
00453     const char *szMutexName = "Global\\_MSISETUP_{2956EBA1-9B5A-4679-8618-357136DA66CA}";
00454     HANDLE hMutex = 0;
00455
00456     hMutex = WIN::CreateMutex(NULL /*default security descriptor*/, FALSE, szMutexName);
00457     if (!hMutex || ERROR_ALREADY_EXISTS == GetLastError())
00458         return true;
00459
00460     return false;
00461 }
00462
00463 /////////////////////////////////////////////////////////////////////////////
00464 // DisplayUsage
00465 //
00466 void DisplayUsage (HINSTANCE hInst, HWND hwndOwner, LPCSTR szCaption)
00467 {
00468     char szMessage[MAX_STR_LENGTH];
00469
00470     WIN::LoadString(hInst, IDS_USAGE, szMessage, sizeof(szMessage)/sizeof(char));
00471     WIN::MessageBox(hwndOwner, szMessage, szCaption, MB_OK | MB_ICONINFORMATION);
00472 }
00473
00474 /////////////////////////////////////////////////////////////////////////////
00475 // ReportErrorOutOfMemory
00476 //
00477
00478 void ReportErrorOutOfMemory(HINSTANCE hInst, HWND hwndOwner, LPCSTR szCaption)
00479 {
00480     char szError[MAX_STR_LENGTH];
00481
00482     WIN::LoadString(hInst, IDS_OUTOFMEM, szError, sizeof(szError)/sizeof(char));
00483     WIN::MessageBox(hwndOwner, szError, szCaption, MB_OK | MB_ICONERROR);
00484 }
00485
00486
00487 /////////////////////////////////////////////////////////////////////////////
00488 // GetFileVersionNumber
00489 //
00490
00491 DWORD GetFileVersionNumber(LPSTR szFilename, DWORD * pdwMSVer, DWORD * pdwLSVer)
00492 {
00493     DWORD             dwResult = NOERROR;
00494     unsigned          uiSize;
00495     DWORD             dwVerInfoSize;
00496     DWORD             dwHandle;
00497     BYTE              *prgbVersionInfo = NULL;
00498     VS_FIXEDFILEINFO  *lpVSFixedFileInfo = NULL;
00499
00500     DWORD dwMSVer = 0xffffffff;
00501     DWORD dwLSVer = 0xffffffff;
00502
00503     dwVerInfoSize = GetFileVersionInfoSize(szFilename, &dwHandle);
00504     if (0 != dwVerInfoSize)
00505     {
00506         prgbVersionInfo = (LPBYTE) WIN::GlobalAlloc(GPTR, dwVerInfoSize);
00507         if (NULL == prgbVersionInfo)
00508         {
00509             dwResult = ERROR_NOT_ENOUGH_MEMORY;
00510             goto Finish;
00511         }
00512
00513         // Read version stamping info
00514         if (GetFileVersionInfo(szFilename, dwHandle, dwVerInfoSize, prgbVersionInfo))
00515         {
00516             // get the value for Translation
00517             if (VerQueryValue(prgbVersionInfo, "\\", (LPVOID*)&lpVSFixedFileInfo, &uiSize) && (uiSize != 0))
00518             {
00519                 dwMSVer = lpVSFixedFileInfo->dwFileVersionMS;
00520                 dwLSVer = lpVSFixedFileInfo->dwFileVersionLS;
00521             }
00522         }
00523         else
00524         {
00525             dwResult = GetLastError();
00526             goto Finish;
00527         }
00528     }
00529     else
00530     {
00531         dwResult = GetLastError();
00532     }
00533
00534 #ifdef DEBUG
00535     char szVersion[255];
00536     StringCchPrintf(szVersion, sizeof(szVersion), "%s is version %d.%d.%d.%d\n", szFilename, HIWORD(dwMSVer), LOWORD(dwMSVer), HIWORD(dwLSVer), LOWORD(dwLSVer));
00537     DebugMsg("[INFO] %s", szVersion);
00538 #endif // DEBUG
00539
00540 Finish:
00541     if (NULL != prgbVersionInfo)
00542         WIN::GlobalFree(prgbVersionInfo);
00543     if (pdwMSVer)
00544         *pdwMSVer = dwMSVer;
00545     if (pdwLSVer)
00546         *pdwLSVer = dwLSVer;
00547
00548     return dwResult;
00549 }
00550
00551 /////////////////////////////////////////////////////////////////////////////
00552 // MimimumWindowsPlatform
00553 //
00554 //  Returns true if running on a platform whose major version, minor version
00555 //  and service pack major are greater than or equal to the ones specifed
00556 //  while making this function call
00557 //
00558 bool MimimumWindowsPlatform(DWORD dwMajorVersion, DWORD dwMinorVersion, WORD wServicePackMajor)
00559 {
00560    OSVERSIONINFOEX osvi;
00561    DWORDLONG dwlConditionMask = 0;
00562
00563    // Initialize the OSVERSIONINFOEX structure.
00564    ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
00565    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
00566    osvi.dwMajorVersion = dwMajorVersion;
00567    osvi.dwMinorVersion = dwMinorVersion;
00568    osvi.wServicePackMajor = wServicePackMajor;
00569
00570    // Initialize the condition mask.
00571    VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
00572    VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
00573    VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
00574
00575    // Perform the test.
00576    return VerifyVersionInfo(&osvi,
00577                             VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,
00578                             dwlConditionMask) ? true : false;
00579 }
00580
00581 /////////////////////////////////////////////////////////////////////////////
00582 // IsOSSupported
00583 //
00584 //  Returns true if running on Windows 2003, Windows XP or
00585 //  Windows 2000 SP3 and above. Else returns false
00586 //
00587 bool IsOSSupported()
00588 {
00589     OSVERSIONINFO sInfoOS;
00590     memset((void*)&sInfoOS, 0x00, sizeof(OSVERSIONINFO));
00591
00592     sInfoOS.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00593     WIN::GetVersionEx(&sInfoOS);
00594
00595     // We do no support any platform prior to Windows 2000
00596     if (5 > sInfoOS.dwMajorVersion)
00597         return false;
00598
00599     // We support:
00600     if(MimimumWindowsPlatform(5, 2, 0) ||   // Windows 2003 and above
00601        MimimumWindowsPlatform(5, 1, 0) ||   // Windows XP and above
00602        MimimumWindowsPlatform(5, 0, 3))     // Windows 2000 SP3 and above
00603         return true;
00604     else
00605         return false;
00606 }
00607
00608 //--------------------------------------------------------------------------------------
00609 // ADVAPI32 API -- delay load
00610 //--------------------------------------------------------------------------------------
00611
00612 #define ADVAPI32_DLL "advapi32.dll"
00613
00614 #define ADVAPI32API_CheckTokenMembership "CheckTokenMembership"
00615 typedef BOOL (WINAPI* PFnCheckTokenMembership)(HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember);
00616
00617 #define ADVAPI32API_AdjustTokenPrivileges "AdjustTokenPrivileges"
00618 typedef BOOL (WINAPI* PFnAdjustTokenPrivileges)(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength);
00619
00620 #define ADVAPI32API_OpenProcessToken "OpenProcessToken"
00621 typedef BOOL (WINAPI* PFnOpenProcessToken)(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle);
00622
00623 #define ADVAPI32API_LookupPrivilegeValue "LookupPrivilegeValueA"
00624 typedef BOOL (WINAPI* PFnLookupPrivilegeValue)(LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid);
00625
00626 /////////////////////////////////////////////////////////////////////////////
00627 // IsAdmin
00628 //
00629 //  Returns true if current user is an administrator (or if on Win9X)
00630 //  Returns false if current user is not an adminstrator
00631 //
00632 //  implemented as per KB Q118626
00633 //
00634
00635 bool IsAdmin()
00636 {
00637     // get the administrator sid
00638     PSID psidAdministrators;
00639     SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY;
00640     if(!AllocateAndInitializeSid(&siaNtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdministrators))
00641         return false;
00642
00643     // on NT5, use the CheckTokenMembershipAPI to correctly handle cases where
00644     // the Adiminstrators group might be disabled. bIsAdmin is BOOL for
00645     BOOL bIsAdmin = FALSE;
00646     // CheckTokenMembership checks if the SID is enabled in the token. NULL for
00647     // the token means the token of the current thread. Disabled groups, restricted
00648     // SIDS, and SE_GROUP_USE_FOR_DENY_ONLY are all considered. If the function
00649     // returns false, ignore the result.
00650
00651     HMODULE hAdvapi32 = LoadLibrary(ADVAPI32_DLL);
00652     if (!hAdvapi32)
00653         bIsAdmin = FALSE;
00654     else
00655     {
00656         PFnCheckTokenMembership pfnCheckTokenMembership = (PFnCheckTokenMembership)GetProcAddress(hAdvapi32, ADVAPI32API_CheckTokenMembership);
00657         if (!pfnCheckTokenMembership || !pfnCheckTokenMembership(NULL, psidAdministrators, &bIsAdmin))
00658             bIsAdmin = FALSE;
00659     }
00660     FreeLibrary(hAdvapi32);
00661     hAdvapi32 = 0;
00662
00663     WIN::FreeSid(psidAdministrators);
00664     return bIsAdmin ? true : false;
00665
00666 }
00667
00668 /////////////////////////////////////////////////////////////////////////////
00669 // AcquireShutdownPrivilege
00670 //
00671 //  Attempts to enable the SE_SHUTDOWN_NAME privilege in the process token
00672 //
00673 bool AcquireShutdownPrivilege()
00674 {
00675     HANDLE hToken = 0;
00676     TOKEN_PRIVILEGES tkp;
00677
00678     HMODULE hAdvapi32 = LoadLibrary(ADVAPI32_DLL);
00679     if (!hAdvapi32)
00680         return false;
00681
00682     PFnOpenProcessToken pfnOpenProcessToken = (PFnOpenProcessToken)GetProcAddress(hAdvapi32, ADVAPI32API_OpenProcessToken);
00683     PFnLookupPrivilegeValue pfnLookupPrivilegeValue = (PFnLookupPrivilegeValue)GetProcAddress(hAdvapi32, ADVAPI32API_LookupPrivilegeValue);
00684     PFnAdjustTokenPrivileges pfnAdjustTokenPrivileges = (PFnAdjustTokenPrivileges)GetProcAddress(hAdvapi32, ADVAPI32API_AdjustTokenPrivileges);
00685     if (!pfnOpenProcessToken || !pfnLookupPrivilegeValue || !pfnAdjustTokenPrivileges)
00686     {
00687         FreeLibrary(hAdvapi32);
00688         return false;
00689     }
00690
00691     // grab this process's token
00692     if (!pfnOpenProcessToken(WIN::GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
00693     {
00694         FreeLibrary(hAdvapi32);
00695         return false;
00696     }
00697
00698     // get the LUID for the shutdown privilege
00699     pfnLookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
00700
00701     tkp.PrivilegeCount = 1; // one privilege to set
00702     tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
00703
00704     // get the shutdown privilege for this process
00705     pfnAdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
00706
00707     // cannot test return value of AdjustTokenPrivileges
00708     if (ERROR_SUCCESS != WIN::GetLastError())
00709     {
00710         FreeLibrary(hAdvapi32);
00711         return false;
00712     }
00713
00714     FreeLibrary(hAdvapi32);
00715
00716     return true;
00717 }
00718
00719 /////////////////////////////////////////////////////////////////////////////
00720 // SetDiagnosticMode
00721 //
00722 //  Turns on debug output if first char of szDebugEnvVar is set to 1
00723 //
00724
00725 int g_dmDiagnosticMode = -1; // -1 until set, then DebugMsg skips fn call if 0
00726
00727 void SetDiagnosticMode()
00728 {
00729     g_dmDiagnosticMode = 0; // disable DebugMsg to start
00730
00731     char rgchBuf[64] = {0};
00732     if (0 != WIN::GetEnvironmentVariable(szDebugEnvVar, rgchBuf, sizeof(rgchBuf)/sizeof(char))
00733         && rgchBuf[0] == '1')
00734     {
00735         g_dmDiagnosticMode = 1; // enable DebugMsg output
00736     }
00737 }
00738
00739 /////////////////////////////////////////////////////////////////////////////
00740 // DebugMsg
00741 //
00742 //  Outputs debugging string to debugger if debug output is enabled
00743 //
00744
00745 void DebugMsg(LPCSTR szFormat, ...)
00746 {
00747     if (-1 == g_dmDiagnosticMode)
00748     {
00749         SetDiagnosticMode();
00750     }
00751
00752     if (0 == g_dmDiagnosticMode)
00753         return; // debug output is not enabled
00754
00755     size_t dwBuf = 512;
00756     char *szDebug = new char[dwBuf];
00757     if (!szDebug)
00758         return ; // out of memory
00759
00760     // store the result debug string
00761     va_list listDebugArg;
00762     va_start(listDebugArg, szFormat);
00763     while (-1 == _vsnprintf(szDebug, dwBuf, szFormat, listDebugArg))
00764     {
00765         dwBuf *= 2;
00766         delete[] szDebug;
00767         szDebug = new char[dwBuf];
00768         if (!szDebug)
00769         {
00770             va_end(listDebugArg);
00771             return; // out of memory
00772         }
00773     }
00774     va_end(listDebugArg);
00775
00776     OutputDebugString(szDebug);
00777 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenuex/registry.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenuex

registry.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include <ObjBase.h>
00016 #include "Registry.h"
00017 #include "Globals.h"
00018
00019
00020 #include "TraceMacro.h"
00021 #undef  MODULESTRING
00022 #define MODULESTRING  _T("Registry")
00023
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Internal helper functions prototypes
00027
00028
00029 // Set the given key and its value.
00030 HRESULT SetKeyAndValue( const TCHAR* pszPath, const TCHAR* szSubkey, const TCHAR* szValue);
00031
00032 // Set the given key and its value in the MMC Snapin location
00033 HRESULT SetSnapInKeyAndValue( const TCHAR* szKey, const TCHAR* szSubkey, const TCHAR* szName, const TCHAR* szValue );
00034
00035 // Set the given valuename under the key to value
00036 HRESULT SetValue( const TCHAR* szKey, const TCHAR* szValueName, const TCHAR* szValue);
00037
00038 // Delete szKeyChild and all of its descendents.
00039 HRESULT RecursiveDeleteKey( HKEY hKeyParent, const TCHAR* szKeyChild );
00040
00041 // Set the nodetype key and subkeys for this extension
00042 HRESULT SetExtensionKey( const TCHAR* szNodeType );
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // Public function implementation
00046
00047
00048 //---------------------------------------------------------------------------
00049 //  Register the component in the registry.  This is the minimalist way
00050 //  to register a component, you may want to add keys for ProgID.
00051 //
00052 HRESULT RegisterServer
00053 (
00054   HMODULE        hModule,          //[in] DLL module handle
00055   const CLSID&   clsid,            //[in] Class ID
00056   const TCHAR*   szFriendlyName    //[in] Name string
00057 )
00058 {
00059   // Get server location.
00060   TCHAR    szModule[512] ;
00061   TCHAR*   pszCLSID = NULL;
00062   LPOLESTR wszCLSID = NULL ;
00063   HRESULT  hResult  = S_FALSE;
00064
00065   DWORD dwResult = ::GetModuleFileName( hModule,
00066                                         szModule,
00067                                         sizeof(szModule)/sizeof(TCHAR)
00068                                       );
00069   if( 0 == dwResult ) return HRESULT_FROM_WIN32( dwResult );
00070
00071   do                         // Fail unless we complete everything
00072   {
00073     // Get CLSID string in wide char
00074     hResult = StringFromCLSID( clsid, &wszCLSID ) ;
00075     if( S_OK != hResult )
00076     {
00077       CoTaskMemFree( wszCLSID );
00078       BREAK_ON_ERROR( hResult );
00079     }
00080
00081     W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00082     CoTaskMemFree( wszCLSID );           // Through with wide version
00083
00084     TCHAR szKey[64];                     // Build the CLSID key string CLSID\\{...}
00085     _tcscpy( szKey, _T("CLSID\\") );
00086     _tcscat( szKey, pszCLSID );
00087
00088     // Add the CLSID to the registry.
00089     hResult = SetKeyAndValue( szKey, NULL, szFriendlyName );
00090     BREAK_ON_ERROR( hResult );
00091
00092     // Add the server filename subkey under the CLSID key.
00093     hResult = SetKeyAndValue( szKey, _T("InprocServer32"), szModule );
00094     BREAK_ON_ERROR( hResult );
00095
00096     // Set the threading model
00097     _tcscat( szKey, _T("\\InprocServer32") );
00098     hResult = SetValue( szKey, _T("ThreadingModel"), _T("Apartment") );
00099     BREAK_ON_ERROR( hResult );
00100
00101   }while( 0 );
00102
00103   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00104
00105   return hResult;
00106 }
00107
00108
00109 //---------------------------------------------------------------------------
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer
00113 (
00114   const CLSID& clsid         //[in] Class ID of component to remove
00115 )
00116 {
00117   HRESULT hResult = S_OK;
00118
00119   // Allocate the CLSID string
00120   LPOLESTR wszCLSID = NULL ;
00121   hResult = StringFromCLSID( clsid, &wszCLSID );
00122   if( S_OK != hResult )
00123   {
00124     CoTaskMemFree( wszCLSID );
00125     return hResult;
00126   }
00127
00128   // Build the key CLSID\\{...}
00129   TCHAR szKey[64];
00130   _tcscpy( szKey, _T("CLSID\\") );
00131
00132   TCHAR* pszCLSID = NULL;
00133   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00134   CoTaskMemFree( wszCLSID );           // Through with wide version
00135
00136   _tcscat( szKey, pszCLSID );
00137   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00138
00139   // Delete the CLSID Key - CLSID\{...}
00140   LONG lResult = RecursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );
00141   if( ERROR_SUCCESS != lResult )
00142     hResult = HRESULT_FROM_WIN32( lResult );
00143
00144   return hResult;
00145 }
00146
00147 //---------------------------------------------------------------------------
00148 // Register the snap-in in the registry.
00149 //
00150 HRESULT RegisterSnapin
00151 (
00152   const  CLSID&  clsid,              //[in] Class ID
00153   const  TCHAR*  szNameString,       //[in] NameString
00154   const  CLSID&  clsidAbout,         //[in] Class Id for About Class
00155   const  BOOL    bSupportExtensions  //[in] TRUE if we support extensions
00156 )
00157 {
00158   HRESULT hResult = S_FALSE;
00159   TCHAR*  pszSnapCLSID = NULL;         // Needed for TCHAR version of the ClassID
00160
00161   // If any part of this process fails, jump out of the loop and return
00162   // the error code
00163   do
00164   {
00165     // Allocate the CLSID string
00166     LPOLESTR wszSnapCLSID  = NULL ;
00167     hResult = StringFromCLSID( clsid, &wszSnapCLSID ) ;
00168     if( S_OK != hResult )
00169     {
00170        CoTaskMemFree( wszSnapCLSID );
00171        continue;
00172     }
00173
00174     W2T( &pszSnapCLSID, wszSnapCLSID );  // W2T is defined in Globals.h
00175     CoTaskMemFree( wszSnapCLSID );       // Through with wide version
00176
00177     // Add the Snap-in's CLSID to the registry
00178     hResult = SetSnapInKeyAndValue( pszSnapCLSID, NULL, _T("NameString"), szNameString );
00179     BREAK_ON_ERROR( hResult );
00180
00181     // Extensions don't support ISnapinAbout, so this is not handled
00182     //
00183     if( TRUE == bSupportExtensions )     // Build the NodeTypesKey
00184     {
00185     }
00186
00187   }while( 0 );
00188
00189   hResult = SetExtensionKey( gtszDEVICE_GUID );
00190
00191   CoTaskMemFree( pszSnapCLSID);
00192   return hResult;
00193 }
00194
00195
00196 //---------------------------------------------------------------------------
00197 // Unregister the snap-in in the registry.
00198 //
00199 HRESULT UnregisterSnapin
00200 (
00201   const CLSID& clsid         //[in] Class ID of object to unregister
00202 )
00203 {
00204   HRESULT hResult = S_OK;
00205
00206   TCHAR    szKeyBuf[1024];
00207   LPOLESTR wszCLSID = NULL;
00208   TCHAR*   pszCLSID = NULL;        // Needed for TCHAR version of the ClassID
00209
00210   // Get CLSID as a wide string
00211   hResult = StringFromCLSID( clsid, &wszCLSID );
00212   if( S_OK != hResult )
00213   {
00214     CoTaskMemFree( wszCLSID );
00215     return hResult;
00216   }
00217
00218   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00219   CoTaskMemFree( wszCLSID );           // Through with wide version
00220
00221   // Load the buffer with the Snap-In Location
00222   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00223
00224   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00225   _tcscat( szKeyBuf, pszCLSID );
00226
00227   // Delete the CLSID Key - CLSID\{...}
00228   LONG lResult = RecursiveDeleteKey( HKEY_LOCAL_MACHINE, szKeyBuf );
00229   if( ERROR_SUCCESS != lResult )
00230     hResult = HRESULT_FROM_WIN32( lResult );
00231
00232   CoTaskMemFree( pszCLSID );
00233   return hResult;
00234 }
00235
00236 //---------------------------------------------------------------------------
00237 // Delete a key and all of its descendents.
00238 //
00239 HRESULT RecursiveDeleteKey
00240 (
00241   HKEY          hKeyParent,    //[in] Parent of key to delete
00242   const TCHAR*  lpszKeyChild   //[in] Key to delete
00243 )
00244 {
00245   // Open the child.
00246   HKEY hKeyChild = NULL;
00247   LONG lResult   = ERROR_SUCCESS;
00248
00249   do                     // We go to all this trouble to prevent any
00250   {                      // possibility of exiting while leaving a key open
00251
00252     lResult = RegOpenKeyEx( hKeyParent,
00253                             lpszKeyChild,
00254                             0,
00255                             KEY_ALL_ACCESS,
00256                             &hKeyChild
00257                           );
00258     if( ERROR_SUCCESS != lResult )
00259       continue;
00260
00261     // Enumerate all of the decendents of this child.
00262     FILETIME time;
00263     _TCHAR szBuffer[256];
00264     DWORD dwSize = 256;
00265     while( S_OK == RegEnumKeyEx(hKeyChild,0,szBuffer,&dwSize,NULL,NULL,NULL,&time) )
00266     {
00267       // Delete the decendents of this child.
00268       lResult = RecursiveDeleteKey( hKeyChild, szBuffer );
00269       if( ERROR_SUCCESS != lResult )
00270       {
00271         continue;
00272       }
00273       dwSize = 256;
00274     }
00275   }while( 0 );
00276
00277   RegCloseKey( hKeyChild );            // Always try to close the child
00278                                        // then delete this child.
00279   return RegDeleteKey( hKeyParent, lpszKeyChild );
00280 }
00281
00282 //---------------------------------------------------------------------------
00283 // Create a Registry Key and set its value.
00284 //   - This helper function was borrowed and modifed from
00285 //     Kraig Brockschmidt's book Inside OLE.
00286 //
00287 HRESULT SetKeyAndValue
00288 (
00289   const TCHAR*  szKey,       //[in] Parent key
00290   const TCHAR*  szSubkey,    //[in] Child key
00291   const TCHAR*  szValue      //[in] Value to set
00292 )
00293 {
00294   HKEY hKey = NULL;
00295   HRESULT hResult = S_FALSE;
00296   TCHAR szKeyBuf[1024];
00297
00298   // Copy keyname into buffer.
00299   _tcscpy( szKeyBuf, szKey );
00300
00301   // Add subkey name to buffer.
00302   if( NULL != szSubkey )
00303   {
00304     _tcscat( szKeyBuf, _T("\\") );
00305     _tcscat( szKeyBuf, szSubkey );
00306   }
00307
00308   do                     // We go to all this trouble to prevent any
00309   {                      // possibility of exiting while leaving a key open
00310
00311     // Create and open key and subkey.
00312     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT,
00313                                    szKeyBuf,
00314                                    0,
00315                                    NULL,
00316                                    REG_OPTION_NON_VOLATILE,
00317                                    KEY_ALL_ACCESS,
00318                                    NULL,
00319                                    &hKey,
00320                                    NULL
00321                                  );
00322     if( ERROR_SUCCESS != lResult )
00323     {
00324       hResult = HRESULT_FROM_WIN32( lResult );
00325       continue;
00326     }
00327
00328     if( NULL != szValue )    // Now set the value
00329     {
00330       hResult = RegSetValueEx( hKey,
00331                                NULL,
00332                                0,
00333                                REG_SZ,
00334                                (BYTE*)szValue,
00335                                BYTE_SIZE( szValue )    // BYTE_SIZE is in Globals.h
00336                              );
00337       BREAK_ON_ERROR( hResult );
00338     }
00339   }while( 0 );
00340
00341   RegCloseKey( hKey );       // Always try to close the key
00342   return hResult;
00343 }
00344
00345
00346 //---------------------------------------------------------------------------
00347 // Open a key value and set it
00348 //
00349 HRESULT SetValue
00350 (
00351   const TCHAR*  szKey,         //[in] Parent key
00352   const TCHAR*  szValueName,   //[in] Name of value
00353   const TCHAR*  szValue        //[in] Value in string format
00354 )
00355 {
00356   HKEY    hKey = NULL;
00357   HRESULT hResult = S_FALSE;
00358   TCHAR szKeyBuf[1024];
00359
00360   // Copy keyname into buffer.
00361   _tcscpy( szKeyBuf, szKey );
00362
00363   do                     // We go to all this trouble to prevent any
00364   {                      // possibility of exiting while leaving a key open
00365
00366     // Create and open key and subkey.
00367     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT ,
00368                                    szKeyBuf,
00369                                    0,
00370                                    NULL,
00371                                    REG_OPTION_NON_VOLATILE,
00372                                    KEY_ALL_ACCESS,
00373                                    NULL,
00374                                    &hKey,
00375                                    NULL
00376                                  );
00377     if( ERROR_SUCCESS != lResult )
00378     {
00379       hResult = HRESULT_FROM_WIN32( lResult );
00380       continue;
00381     }
00382
00383     if( NULL != szValue )    // Now set the value
00384     {
00385       hResult = RegSetValueEx( hKey,
00386                                szValueName,
00387                                0,
00388                                REG_SZ,
00389                                (BYTE*)szValue,
00390                                BYTE_SIZE( szValue )
00391                              );
00392       BREAK_ON_ERROR( hResult );
00393     }
00394   }while( 0 );
00395
00396   RegCloseKey( hKey );       //Always attempt to close the key
00397   return hResult;
00398 }
00399
00400
00401 //---------------------------------------------------------------------------
00402 // Create a key and set its value.
00403 //   - This helper function was borrowed and modifed from
00404 //     Kraig Brockschmidt's book Inside OLE.
00405 //
00406 HRESULT SetSnapInKeyAndValue
00407 (
00408   const TCHAR*  szKey,       //[in] Parent key
00409   const TCHAR*  szSubkey,    //[in] Child key
00410   const TCHAR*  szName,      //[in] Value name
00411   const TCHAR*  szValue      //[in] Value in string format
00412 )
00413 {
00414   HKEY    hKey = NULL;
00415   HRESULT hResult = S_FALSE;
00416   TCHAR   szKeyBuf[1024];
00417
00418   // Load the buffer with the Snap-In Location
00419   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00420
00421   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00422   _tcscat( szKeyBuf, szKey );
00423
00424   if( NULL != szSubkey )               // Add subkey name to buffer.
00425   {
00426     _tcscat( szKeyBuf, _T("\\") );
00427     _tcscat( szKeyBuf, szSubkey );
00428   }
00429
00430   do                     // We go to all this trouble to prevent any
00431   {                      // possibility of exiting while leaving a key open
00432
00433     // Create and open key and subkey.
00434     long lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00435                                    szKeyBuf,
00436                                    0,
00437                                    NULL,
00438                                    REG_OPTION_NON_VOLATILE,
00439                                    KEY_ALL_ACCESS,
00440                                    NULL,
00441                                    &hKey,
00442                                    NULL
00443                                  );
00444     if( ERROR_SUCCESS != lResult )     // Will return S_FALSE
00445       continue;
00446
00447     // Set the Value.
00448     if( szValue != NULL )
00449     {
00450       hResult = RegSetValueEx( hKey,
00451                                szName,
00452                                0,
00453                                REG_SZ,
00454                                (BYTE*)szValue,
00455                                BYTE_SIZE(szValue)
00456                              );
00457       BREAK_ON_ERROR( hResult );
00458     }
00459     else
00460     {                        // Got this far so everything is OK.
00461       hResult = S_OK;
00462     }
00463   }while( 0 );
00464
00465   RegCloseKey( hKey );       //Always attempt to close the key
00466   return hResult;
00467 }
00468
00469 //---------------------------------------------------------------------------
00470 // Adds the keys under the MMC/NodeTypes key to register our
00471 // Snapin as an extension.
00472 //
00473 HRESULT SetExtensionKey
00474 (
00475   const TCHAR*  szNodeType
00476 )
00477 {
00478   HKEY    hNodeKey = NULL;
00479   HRESULT hResult  = S_FALSE;
00480   TCHAR   szKeyBuf[1024];
00481
00482   // Load the buffer with the NodeTypes Location
00483   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes") );
00484
00485   _tcscat( szKeyBuf, _T("\\") );       // Copy NodeType GUID into buffer.
00486   _tcscat( szKeyBuf, szNodeType );
00487
00488   _tcscat( szKeyBuf, _T("\\") );       // Copy Subkeys into buffer
00489   _tcscat( szKeyBuf, _T("Extensions\\ContextMenu") );
00490
00491   long lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00492                                  szKeyBuf,
00493                                  0,
00494                                  NULL,
00495                                  REG_OPTION_NON_VOLATILE,
00496                                  KEY_ALL_ACCESS,
00497                                  NULL,
00498                                  &hNodeKey,
00499                                  NULL
00500                                );
00501
00502   if( ERROR_SUCCESS != lResult )     // Will return S_FALSE
00503   {
00504     RegCloseKey( hNodeKey );
00505     return S_FALSE;
00506   }
00507
00508   hResult = RegSetValueEx( hNodeKey,
00509                            gtszCTXMENUX_GUID,
00510                            0,
00511                            REG_SZ,
00512                            (BYTE*)gtszOBJECT_NAME,
00513                            BYTE_SIZE(gtszOBJECT_NAME)
00514                          );
00515
00516   return hResult;
00517 }
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Cap/Notify.h Source File

  • Web
  • MSAgent
  • c
  • Cap

Notify.h

Go to the documentation of this file.
00001 #ifndef _Notify_h_
00002 #define _Notify_h_
00003
00004
00005 #include "AgtSvr.h"
00006
00007 class MainDlg;
00008
00009
00010 // Agent Notify Sink Implementation
00011
00012 class AgentNotifySink : public IAgentNotifySinkEx {
00013 public:
00014   AgentNotifySink(MainDlg *pMainDlg) : m_cRefs(0), m_pMainDlg(pMainDlg) {}
00015    ~AgentNotifySink() {}
00016
00017     STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
00018     STDMETHODIMP_(ULONG) AddRef();
00019     STDMETHODIMP_(ULONG) Release();
00020
00021   STDMETHODIMP GetTypeInfoCount(UINT *);
00022   STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
00023   STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID, DISPID *);
00024   STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
00025
00026     STDMETHODIMP Command(long dwCommandID, IUnknown * punkUserInput);
00027     STDMETHODIMP ActivateInputState(long dwCharID, long bActivated);
00028     STDMETHODIMP Restart();
00029     STDMETHODIMP Shutdown();
00030     STDMETHODIMP VisibleState(long dwCharID, long bVisible, long lCause);
00031   STDMETHODIMP Click(long dwCharID, short fwKeys, long x, long y);
00032   STDMETHODIMP DblClick(long dwCharID, short fwKeys, long x, long y);
00033   STDMETHODIMP DragStart(long dwCharID, short fwKeys, long x, long y);
00034   STDMETHODIMP DragComplete(long dwCharID, short fwKeys, long x, long y);
00035   STDMETHODIMP RequestStart(long dwRequestID);
00036   STDMETHODIMP RequestComplete(long dwRequestID, long hrStatus);
00037   STDMETHODIMP BookMark(long dwBookMarkID);
00038     STDMETHODIMP Idle(long dwCharID, long bStart);
00039   STDMETHODIMP Move(long dwCharID, long x, long y, long lCause);
00040   STDMETHODIMP Size(long dwCharID, long lWidth, long lHeight);
00041   STDMETHODIMP BalloonVisibleState(long dwCharID, long bVisible);
00042
00043   STDMETHODIMP HelpComplete(long dwCharID, long dwCommandID, long dwCause);
00044   STDMETHODIMP ListeningState(long dwCharID, long bListening, long dwCause);
00045   STDMETHODIMP Suspend();
00046   STDMETHODIMP DefaultCharacterChange(BSTR bszGUID);
00047   STDMETHODIMP AgentPropertyChange();
00048   STDMETHODIMP ActiveClientChange(long dwCharID, long bActive);
00049
00050 private:
00051   ULONG    m_cRefs;
00052   MainDlg   *m_pMainDlg;
00053 };
00054
00055
00056 #endif
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBindings Member List

This is the complete list of members for CBindings, including all inherited members.
AddElement(DBBINDINGelement) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
Attach(CVector &rVector) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
Attach(DBCOUNTITEMcElements, DBBINDING *rgElements) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
CBindings() | CBindings | [inline]
CVector(DBCOUNTITEMulLowerBound=0, DBCOUNTITEMulGrowSize=10) | CVector< DBBINDING, DBCOUNTITEM > |
Detach(DBCOUNTITEM *pcElements, DBBINDING **prgElements) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
FreeData(void *pv, BOOL fSetData=FALSE) | CBindings | [inline]
GetCount() | CVector< DBBINDING, DBCOUNTITEM > | [inline, virtual]
GetElement(DBCOUNTITEMiIndex) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
GetElements() const | CVector< DBBINDING, DBCOUNTITEM > | [inline, virtual]
GetOrdinal(DBORDINAL iOrdinal) | CBindings | [inline]
InsertAt(DBCOUNTITEMiIndex, DBBINDINGelement) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
m_cElements | CVector< DBBINDING, DBCOUNTITEM > | [protected]
m_rgElements | CVector< DBBINDING, DBCOUNTITEM > | [protected]
m_ulGrowSize | CVector< DBBINDING, DBCOUNTITEM > | [protected]
m_ulLowerBound | CVector< DBBINDING, DBCOUNTITEM > | [protected]
m_ulMaxSize | CVector< DBBINDING, DBCOUNTITEM > | [protected]
operator[](DBCOUNTITEMiIndex) | CVector< DBBINDING, DBCOUNTITEM > | [inline, virtual]
RemoveAll() | CBindings | [inline, virtual]
RemoveAt(DBCOUNTITEMiIndex) | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
~CBindings() | CBindings | [inline]
~CVector() | CVector< DBBINDING, DBCOUNTITEM > | [virtual]
Generated on Wed Nov 13 2024 16:55:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/Atsp32/Atsp.c Source File

  • NetDS
  • Tapi
  • Tapi2
  • Atsp32

Atsp.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright 1995 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     atsp.c
00008
00009 Notes:
00010
00011 --*/
00012
00013
00014 #define TAPI_CURRENT_VERSION 0x00030000
00015 #include "atsp.h"
00016
00017
00018 BOOL
00019 WINAPI
00020 DllMain(
00021     HANDLE  hDLL,
00022     DWORD   dwReason,
00023     LPVOID  lpReserved
00024     )
00025 {
00026     if (dwReason ==  DLL_PROCESS_ATTACH)
00027     {
00028         ghInst = hDLL;
00029
00030 #if DBG
00031         {
00032             HKEY    hKey;
00033             DWORD   dwDataSize, dwDataType;
00034             char    szAtsp32DebugLevel[] = "Atsp32DebugLevel";
00035
00036
00037             RegOpenKeyExA(
00038                 HKEY_LOCAL_MACHINE,
00039                 gszAtspKey,
00040                 0,
00041                 KEY_ALL_ACCESS,
00042                 &hKey
00043                 );
00044
00045             dwDataSize = sizeof (DWORD);
00046             gdwDebugLevel=0;
00047
00048             RegQueryValueEx(
00049                 hKey,
00050                 szAtsp32DebugLevel,
00051                 0,
00052                 &dwDataType,
00053                 (LPBYTE) &gdwDebugLevel,
00054                 &dwDataSize
00055                 );
00056
00057             RegCloseKey (hKey);
00058         }
00059 #endif
00060
00061     }
00062
00063     return TRUE;
00064 }
00065
00066
00067 void
00068 CommThread(
00069     PDRVLINE    pLine
00070     )
00071 {
00072     char            buf[4];
00073     DWORD           dwThreadID = GetCurrentThreadId(), dwNumBytes;
00074     HANDLE          hComm = pLine->hComm, hEvent;
00075     LPOVERLAPPED    pOverlapped = &pLine->Overlapped;
00076
00077
00078     DBGOUT((
00079         3,
00080         "CommThread (id=%d): enter, port=%s",
00081         dwThreadID,
00082         pLine->szComm
00083         ));
00084
00085     hEvent = pOverlapped->hEvent;
00086     buf[0] = buf[1] = '.';
00087
00088
00089     //
00090     // Loop waiting for i/o to complete (either the Write done in
00091     // TSPI_lineMakeCall or the Reads done to retrieve status info).
00092     // Note that TSPI_lineDrop or TSPI_lineCloseCall may set the
00093     // event to alert us that they're tearing down the call, in
00094     // which case we just exit.
00095     //
00096
00097     for (;;)
00098     {
00099         if (WaitForSingleObject (hEvent, ATSP_TIMEOUT) == WAIT_OBJECT_0)
00100         {
00101             if (pLine->bDropInProgress == TRUE)
00102             {
00103                 DBGOUT((2, "CommThread (id=%d): drop in progress"));
00104                 goto CommThread_exit;
00105             }
00106
00107             GetOverlappedResult (hComm, pOverlapped, &dwNumBytes, FALSE);
00108             ResetEvent (hEvent);
00109         }
00110         else
00111         {
00112             DBGOUT((2, "CommThread (id=%d): wait timeout"));
00113             SetCallState (pLine, LINECALLSTATE_IDLE, 0);
00114             goto CommThread_exit;
00115         }
00116
00117         buf[1] &= 0x7f; // nuke the parity bit
00118
00119         DBGOUT((
00120             3,
00121             "CommThread (id=%d): read '%c'",
00122             dwThreadID,
00123             (buf[1] == '\r' ? '.' : buf[1])
00124             ));
00125
00126         switch ((buf[0] << 8) + buf[1])
00127         {
00128         case 'CT':  // "CONNECT"
00129         case 'OK':  // "OK"
00130
00131             SetCallState (pLine, LINECALLSTATE_CONNECTED, 0);
00132             goto CommThread_exit;
00133
00134         case 'SY':  // "BUSY"
00135         case 'OR':  // "ERROR"
00136         case 'NO':  // "NO ANSWER", "NO DIALTONE", "NO CARRIER"
00137
00138             SetCallState (pLine, LINECALLSTATE_IDLE, 0);
00139             goto CommThread_exit;
00140
00141         default:
00142
00143             break;
00144         }
00145
00146         buf[0] = buf[1];
00147
00148         ZeroMemory (pOverlapped, sizeof (OVERLAPPED) - sizeof (HANDLE));
00149         ReadFile (hComm, &buf[1], 1, &dwNumBytes, pOverlapped);
00150     }
00151
00152 CommThread_exit:
00153
00154     CloseHandle (hEvent);
00155     DBGOUT((3, "CommThread (id=%d): exit", dwThreadID));
00156     ExitThread (0);
00157 }
00158
00159
00160 //
00161 // We get a slough of C4047 (different levels of indrection) warnings down
00162 // below in the initialization of FUNC_PARAM structs as a result of the
00163 // real func prototypes having params that are types other than DWORDs,
00164 // so since these are known non-interesting warnings just turn them off
00165 //
00166
00167 #pragma warning (disable:4047)
00168
00169
00170 //
00171 // --------------------------- TAPI_lineXxx funcs -----------------------------
00172 //
00173
00174
00175 LONG
00176 TSPIAPI TSPI_lineMSPIdentify(
00177     DWORD               dwDeviceID,
00178     GUID *              pCLSID
00179     )
00180 {
00181
00182    LONG  lResult = 0;
00183
00184 #if DBG
00185     FUNC_PARAM  params[] =
00186     {
00187         { "dwDeviceID", dwDeviceID }
00188     };
00189
00190     FUNC_INFO   info =
00191     {
00192         "TSPI_lineMSPIdentify",
00193         1,
00194         params
00195     };
00196
00197 #endif
00198
00199
00200     Prolog (&info);
00201
00202   //
00203   // Identify the CLSID of the our MSP
00204   // this is the CLSID of Sample MSP in the
00205   // TAPI3 SDK
00206   //
00207
00208     *pCLSID = CLSID_SAMPMSP;
00209
00210     return (Epilog (&info, lResult));
00211
00212 }
00213
00214
00215 LONG
00216 TSPIAPI TSPI_lineReceiveMSPData(
00217   HDRVLINE        hdLine,
00218     HDRVCALL        hdCall,
00219     HDRVMSPLINE     hdMSPLine,
00220     LPBYTE          pBuffer,
00221     DWORD           dwSize
00222     )
00223 {
00224   LONG lResult             = 0;
00225
00226 #if DBG
00227   FUNC_PARAM  params[] =
00228   {
00229     {  gszhdLine, hdLine },
00230     {  gszhdCall, hdCall},
00231     { "hdMSPLine", hdMSPLine},
00232     { "pBuffer"  , pBuffer},
00233     { "dwSize" , dwSize}
00234
00235   };
00236
00237   FUNC_INFO   info =
00238   {
00239     "TSPI_lineReceiveMSPData",
00240     5,
00241     params
00242   };
00243
00244 #endif
00245
00246   Prolog (&info);
00247
00248   //
00249   // Place code to Process Data received from the MSP
00250   //
00251
00252   return (Epilog (&info, lResult));
00253 }
00254
00255 LONG
00256 TSPIAPI
00257 TSPI_lineCreateMSPInstance(
00258     HDRVLINE        hdLine,
00259       DWORD           dwAddressID,
00260       HTAPIMSPLINE    htMSPLine,
00261       LPHDRVMSPLINE   phdMSPLine
00262     )
00263 {
00264     LONG    lResult = 0;
00265   PDRVLINE    pLine   = (PDRVLINE) hdLine;
00266
00267 #if DBG
00268     FUNC_PARAM  params[] =
00269     {
00270         { gszhdLine,      hdLine},
00271         { "dwAddressID",  dwAddressID },
00272         { "htMSPLine",    htMSPLine  }
00273     };
00274     FUNC_INFO   info =
00275     {
00276         "TSPI_lineCreateMSPInstance",
00277         3,
00278         params
00279     };
00280
00281 #endif
00282
00283
00284     Prolog (&info);
00285
00286   //
00287   // we save the TAPI MSP handle as a member value
00288   // in the line in order to be able to send MSP messages
00289   // with the line/client identification to TAPISRV.
00290   // tapisrv identifies the client with the call handle and or the
00291   // MSP handle.. both cannot be ambiguous.
00292   //
00293
00294   pLine->htMSPLineHandle = htMSPLine;
00295
00296
00297   //
00298   // we fake a TTSP handle for TAPI we are not keeping track of this
00299   //
00300
00301   *phdMSPLine = 0;
00302
00303   return (Epilog (&info, lResult));
00304
00305 }
00306
00307 LONG
00308 TSPIAPI TSPI_lineCloseMSPInstance(
00309     HDRVMSPLINE         hdMSPLine
00310         )
00311 {
00312    LONG  lResult = 0;
00313
00314 #if DBG
00315     FUNC_PARAM  params[] =
00316     {
00317         { "hdMSPLine", hdMSPLine}
00318     };
00319
00320     FUNC_INFO   info =
00321     {
00322         "TSPI_lineCloseMSPInstance",
00323         1,
00324         params
00325     };
00326
00327 #endif
00328
00329
00330     Prolog (&info);
00331
00332   //
00333   // no - op there is no information stored with the
00334   // msp so we dont need to free anything or remove anything
00335   //
00336
00337     return (Epilog (&info, lResult));
00338
00339 }
00340
00341
00342
00343
00344 LONG
00345 TSPIAPI
00346 TSPI_lineClose(
00347     HDRVLINE    hdLine
00348     )
00349 {
00350     LONG        lResult = 0;
00351 #if DBG
00352     FUNC_PARAM  params[] =
00353     {
00354         { gszhdLine, hdLine }
00355     };
00356     FUNC_INFO   info =
00357     {
00358         "TSPI_lineClose",
00359         1,
00360         params,
00361     };
00362 #endif
00363
00364     Prolog (&info);
00365     DrvFree ((PDRVLINE) hdLine);
00366     return (Epilog (&info, lResult));
00367 }
00368
00369
00370 LONG
00371 TSPIAPI
00372 TSPI_lineCloseCall(
00373     HDRVCALL    hdCall
00374     )
00375 {
00376     PDRVLINE    pLine = (PDRVLINE) hdCall;
00377 #if DBG
00378     FUNC_PARAM  params[] =
00379     {
00380         { gszhdCall, hdCall  }
00381     };
00382     FUNC_INFO   info =
00383     {
00384         "TSPI_lineCloseCall",
00385         1,
00386         params
00387     };
00388 #endif
00389
00390
00391     //
00392     // Note that in TAPI 2.0 TSPI_lineCloseCall can get called
00393     // without TSPI_lineDrop ever being called, so we need to
00394     // be prepared for either case.
00395     //
00396
00397     Prolog (&info);
00398     DropActiveCall (pLine);
00399     pLine->htCall = NULL;
00400     return (Epilog (&info, 0));
00401 }
00402
00403
00404 LONG
00405 TSPIAPI
00406 TSPI_lineConditionalMediaDetection(
00407     HDRVLINE            hdLine,
00408     DWORD               dwMediaModes,
00409     LPLINECALLPARAMS    const lpCallParams
00410     )
00411 {
00412 #if DBG
00413     FUNC_PARAM  params[] =
00414     {
00415         { gszhdLine,        hdLine       },
00416         { "dwMediaModes",   dwMediaModes },
00417         { gszlpCallParams,  lpCallParams }
00418     };
00419     FUNC_INFO   info =
00420     {
00421         "TSPI_lineConditionalMediaDetection",
00422         3,
00423         params
00424     };
00425 #endif
00426
00427
00428     //
00429     // This func is really a no-op for us, since we don't look
00430     // for incoming calls (though we do say we support them to
00431     // make apps happy)
00432     //
00433
00434     Prolog (&info);
00435     return (Epilog (&info, 0));
00436 }
00437
00438
00439 LONG
00440 TSPIAPI
00441 TSPI_lineDrop(
00442     DRV_REQUESTID   dwRequestID,
00443     HDRVCALL        hdCall,
00444     LPCSTR          lpsUserUserInfo,
00445     DWORD           dwSize
00446     )
00447 {
00448     PDRVLINE    pLine = (PDRVLINE) hdCall;
00449 #if DBG
00450     FUNC_PARAM  params[] =
00451     {
00452         { gszdwRequestID,        dwRequestID     },
00453         { gszhdCall,             hdCall          },
00454         { "lpsUserUserInfo",    lpsUserUserInfo },
00455         { gszdwSize,             dwSize          }
00456     };
00457     FUNC_INFO   info =
00458     {
00459         "TSPI_lineDrop",
00460         4,
00461         params
00462     };
00463 #endif
00464
00465
00466     Prolog (&info);
00467     DropActiveCall (pLine);
00468     SetCallState (pLine, LINECALLSTATE_IDLE, 0);
00469     (*gpfnCompletionProc)(dwRequestID, 0);
00470     return (Epilog (&info, dwRequestID));
00471 }
00472
00473
00474 LONG
00475 TSPIAPI
00476 TSPI_lineGetAddressCaps(
00477     DWORD              dwDeviceID,
00478     DWORD              dwAddressID,
00479     DWORD              dwTSPIVersion,
00480     DWORD              dwExtVersion,
00481     LPLINEADDRESSCAPS  lpAddressCaps
00482     )
00483 {
00484
00485 #if DBG
00486     FUNC_PARAM  params[] =
00487     {
00488         { gszdwDeviceID,     dwDeviceID      },
00489         { "dwAddressID",    dwAddressID     },
00490         { "dwTSPIVersion",  dwTSPIVersion   },
00491         { "dwExtVersion",   dwExtVersion    },
00492         { "lpAddressCaps",  lpAddressCaps   }
00493     };
00494     FUNC_INFO   info =
00495     {
00496         "TSPI_lineGetAddressCaps",
00497         5,
00498         params
00499     };
00500 #endif
00501
00502     LONG        lResult = 0;
00503
00504
00505     Prolog (&info);
00506
00507     if (dwAddressID != 0)
00508     {
00509         lResult = LINEERR_INVALADDRESSID;
00510     }
00511
00512     lpAddressCaps->dwNeededSize =
00513     lpAddressCaps->dwUsedSize   = sizeof(LINEADDRESSCAPS);
00514
00515     lpAddressCaps->dwLineDeviceID       = dwDeviceID;
00516     lpAddressCaps->dwAddressSharing     = LINEADDRESSSHARING_PRIVATE;
00517     lpAddressCaps->dwCallInfoStates     = LINECALLINFOSTATE_MEDIAMODE |
00518                                           LINECALLINFOSTATE_APPSPECIFIC;
00519     lpAddressCaps->dwCallerIDFlags      =
00520     lpAddressCaps->dwCalledIDFlags      =
00521     lpAddressCaps->dwRedirectionIDFlags =
00522     lpAddressCaps->dwRedirectingIDFlags = LINECALLPARTYID_UNAVAIL;
00523     lpAddressCaps->dwCallStates         = LINECALLSTATE_IDLE |
00524                                           LINECALLSTATE_OFFERING |
00525                                           LINECALLSTATE_ACCEPTED |
00526                                           LINECALLSTATE_DIALTONE |
00527                                           LINECALLSTATE_DIALING |
00528                                           LINECALLSTATE_CONNECTED |
00529                                           LINECALLSTATE_PROCEEDING |
00530                                           LINECALLSTATE_DISCONNECTED |
00531                                           LINECALLSTATE_UNKNOWN;
00532     lpAddressCaps->dwDialToneModes      = LINEDIALTONEMODE_UNAVAIL;
00533     lpAddressCaps->dwBusyModes          = LINEBUSYMODE_UNAVAIL;
00534     lpAddressCaps->dwSpecialInfo        = LINESPECIALINFO_UNAVAIL;
00535     lpAddressCaps->dwDisconnectModes    = LINEDISCONNECTMODE_NORMAL |
00536                                           LINEDISCONNECTMODE_BUSY |
00537                                           LINEDISCONNECTMODE_NOANSWER |
00538                                           LINEDISCONNECTMODE_UNAVAIL |
00539                                           LINEDISCONNECTMODE_NODIALTONE;
00540     lpAddressCaps->dwMaxNumActiveCalls  = 1;
00541     lpAddressCaps->dwAddrCapFlags       = LINEADDRCAPFLAGS_DIALED;
00542     lpAddressCaps->dwCallFeatures       = LINECALLFEATURE_ACCEPT |
00543                                           LINECALLFEATURE_ANSWER |
00544                                           LINECALLFEATURE_DROP |
00545                                           LINECALLFEATURE_SETCALLPARAMS;
00546     lpAddressCaps->dwAddressFeatures    = LINEADDRFEATURE_MAKECALL;
00547
00548     return (Epilog (&info, lResult));
00549 }
00550
00551
00552 LONG
00553 TSPIAPI
00554 TSPI_lineGetAddressStatus(
00555     HDRVLINE            hdLine,
00556     DWORD               dwAddressID,
00557     LPLINEADDRESSSTATUS lpAddressStatus
00558     )
00559 {
00560 #if DBG
00561     FUNC_PARAM  params[] =
00562     {
00563         { gszhdLine,             hdLine         },
00564         { "dwAddressID",        dwAddressID     },
00565         { "lpAddressStatus",    lpAddressStatus }
00566     };
00567     FUNC_INFO   info =
00568     {
00569         "TSPI_lineGetAddressStatus",
00570         3,
00571         params
00572     };
00573 #endif
00574
00575     LONG        lResult = 0;
00576     PDRVLINE    pLine = (PDRVLINE) hdLine;
00577
00578
00579     Prolog (&info);
00580
00581     lpAddressStatus->dwNeededSize =
00582     lpAddressStatus->dwUsedSize   = sizeof(LINEADDRESSSTATUS);
00583
00584     lpAddressStatus->dwNumActiveCalls  = (pLine->htCall ? 1 : 0);
00585     lpAddressStatus->dwAddressFeatures = LINEADDRFEATURE_MAKECALL;
00586
00587     return (Epilog (&info, lResult));
00588 }
00589
00590
00591 LONG
00592 TSPIAPI
00593 TSPI_lineGetCallAddressID(
00594     HDRVCALL            hdCall,
00595     LPDWORD             lpdwAddressID
00596     )
00597 {
00598 #if DBG
00599     FUNC_PARAM  params[] =
00600     {
00601         { gszhdCall,        hdCall          },
00602         { "lpdwAddressID",  lpdwAddressID   }
00603     };
00604     FUNC_INFO   info =
00605     {
00606         "TSPI_lineGetCallAddressID",
00607         2,
00608         params
00609     };
00610 #endif
00611
00612
00613     //
00614     // We only support 1 address (id=0)
00615     //
00616
00617     Prolog (&info);
00618     *lpdwAddressID = 0;
00619     return (Epilog (&info, 0));
00620 }
00621
00622
00623 LONG
00624 TSPIAPI
00625 TSPI_lineGetCallInfo(
00626     HDRVCALL        hdCall,
00627     LPLINECALLINFO  lpLineInfo
00628     )
00629 {
00630 #if DBG
00631     FUNC_PARAM  params[] =
00632     {
00633         { gszhdCall,     hdCall      },
00634         { "lpLineInfo", lpLineInfo  }
00635     };
00636     FUNC_INFO   info =
00637     {
00638         "TSPI_lineGetCallInfo",
00639         2,
00640         params
00641     };
00642 #endif
00643     LONG        lResult = 0;
00644     PDRVLINE    pLine = (PDRVLINE) hdCall;
00645
00646
00647     Prolog (&info);
00648
00649     lpLineInfo->dwNeededSize =
00650     lpLineInfo->dwUsedSize   = sizeof(LINECALLINFO);
00651
00652     lpLineInfo->dwBearerMode         = LINEBEARERMODE_VOICE;
00653     lpLineInfo->dwMediaMode          = pLine->dwMediaMode;
00654     lpLineInfo->dwCallStates         = LINECALLSTATE_IDLE |
00655                                        LINECALLSTATE_DIALTONE |
00656                                        LINECALLSTATE_DIALING |
00657                                        LINECALLSTATE_CONNECTED |
00658                                        LINECALLSTATE_PROCEEDING |
00659                                        LINECALLSTATE_DISCONNECTED |
00660                                        LINECALLSTATE_UNKNOWN;
00661     lpLineInfo->dwOrigin             = LINECALLORIGIN_OUTBOUND;
00662     lpLineInfo->dwReason             = LINECALLREASON_DIRECT;
00663     lpLineInfo->dwCallerIDFlags      =
00664     lpLineInfo->dwCalledIDFlags      =
00665     lpLineInfo->dwConnectedIDFlags   =
00666     lpLineInfo->dwRedirectionIDFlags =
00667     lpLineInfo->dwRedirectingIDFlags = LINECALLPARTYID_UNAVAIL;
00668
00669     return (Epilog (&info, lResult));
00670 }
00671
00672
00673 LONG
00674 TSPIAPI
00675 TSPI_lineGetCallStatus(
00676     HDRVCALL            hdCall,
00677     LPLINECALLSTATUS    lpLineStatus
00678     )
00679 {
00680 #if DBG
00681     FUNC_PARAM  params[] =
00682     {
00683         { gszhdCall,         hdCall          },
00684         { "lpLineStatus",   lpLineStatus    }
00685     };
00686     FUNC_INFO   info =
00687     {
00688         "TSPI_lineGetCallStatus",
00689         2,
00690         params
00691     };
00692 #endif
00693     LONG        lResult = 0;
00694     PDRVLINE    pLine = (PDRVLINE) hdCall;
00695
00696
00697     Prolog (&info);
00698
00699     lpLineStatus->dwNeededSize =
00700     lpLineStatus->dwUsedSize   = sizeof(LINECALLSTATUS);
00701
00702     lpLineStatus->dwCallState  = pLine->dwCallState;
00703
00704     if (pLine->dwCallState != LINECALLSTATE_IDLE)
00705     {
00706         lpLineStatus->dwCallFeatures = LINECALLFEATURE_DROP;
00707     }
00708
00709     return (Epilog (&info, lResult));
00710 }
00711
00712
00713 LONG
00714 TSPIAPI
00715 TSPI_lineGetDevCaps(
00716     DWORD           dwDeviceID,
00717     DWORD           dwTSPIVersion,
00718     DWORD           dwExtVersion,
00719     LPLINEDEVCAPS   lpLineDevCaps
00720     )
00721 {
00722 #if DBG
00723     FUNC_PARAM  params[] =
00724     {
00725         { gszdwDeviceID,     dwDeviceID      },
00726         { "dwTSPIVersion",  dwTSPIVersion   },
00727         { "dwExtVersion",   dwExtVersion    },
00728         { "lpLineDevCaps",  lpLineDevCaps   }
00729     };
00730     FUNC_INFO   info =
00731     {
00732         "TSPI_lineGetDevCaps",
00733         4,
00734         params
00735     };
00736 #endif
00737
00738     LONG            lResult = 0;
00739     static WCHAR    szProviderInfo[] = L"AT-compatible modem service provider";
00740
00741     #define PROVIDER_INFO_SIZE (37 * sizeof (WCHAR))
00742
00743     Prolog (&info);
00744
00745     lpLineDevCaps->dwNeededSize = sizeof (LINEDEVCAPS) + PROVIDER_INFO_SIZE +
00746         (MAX_DEV_NAME_LENGTH + 1) * sizeof (WCHAR);
00747
00748     if (lpLineDevCaps->dwTotalSize >= lpLineDevCaps->dwNeededSize)
00749     {
00750         #define LINECONFIG_SIZE   (2 * (MAX_DEV_NAME_LENGTH + 1) + 40)
00751
00752         char    szLineConfig[LINECONFIG_SIZE], szLineN[16], *p;
00753         HKEY    hKey;
00754         DWORD   dwDataSize, dwDataType;
00755
00756
00757         lpLineDevCaps->dwUsedSize = lpLineDevCaps->dwNeededSize;
00758
00759         lpLineDevCaps->dwProviderInfoSize   = PROVIDER_INFO_SIZE;
00760         lpLineDevCaps->dwProviderInfoOffset = sizeof(LINEDEVCAPS);
00761
00762         My_lstrcpyW ((WCHAR *)(lpLineDevCaps + 1), szProviderInfo);
00763
00764         RegOpenKeyEx(
00765             HKEY_LOCAL_MACHINE,
00766             gszAtspKey,
00767             0,
00768             KEY_ALL_ACCESS,
00769             &hKey
00770             );
00771
00772         dwDataSize = LINECONFIG_SIZE;
00773         wsprintf (szLineN, "Line%d", dwDeviceID - gdwLineDeviceIDBase);
00774         strncpy (szLineConfig, gszDefLineConfigParams, LINECONFIG_SIZE-1);
00775     szLineConfig[LINECONFIG_SIZE-1] = '\0';
00776
00777         RegQueryValueEx(
00778             hKey,
00779             szLineN,
00780             0,
00781             &dwDataType,
00782             (LPBYTE) szLineConfig,
00783             &dwDataSize
00784             );
00785
00786         RegCloseKey (hKey);
00787
00788         for (p = szLineConfig; *p != ','; p++);
00789         *p = 0;
00790
00791         lpLineDevCaps->dwLineNameSize   = (lstrlen (szLineConfig) + 1) *
00792             sizeof (WCHAR);
00793         lpLineDevCaps->dwLineNameOffset = sizeof(LINEDEVCAPS) +
00794             PROVIDER_INFO_SIZE;
00795
00796         MultiByteToWideChar(
00797             CP_ACP,
00798             MB_PRECOMPOSED,
00799             szLineConfig,
00800             -1,
00801             (WCHAR *) ((LPBYTE) (lpLineDevCaps + 1) + PROVIDER_INFO_SIZE),
00802             (lpLineDevCaps->dwLineNameSize)/sizeof(WCHAR)
00803             );
00804     }
00805     else
00806     {
00807         lpLineDevCaps->dwUsedSize = sizeof(LINEDEVCAPS);
00808     }
00809
00810     lpLineDevCaps->dwStringFormat      = STRINGFORMAT_ASCII;
00811     lpLineDevCaps->dwAddressModes      = LINEADDRESSMODE_ADDRESSID;
00812     lpLineDevCaps->dwNumAddresses      = 1;
00813     lpLineDevCaps->dwBearerModes       = LINEBEARERMODE_VOICE;
00814     lpLineDevCaps->dwMaxRate           = 9600;
00815     lpLineDevCaps->dwMediaModes        = LINEMEDIAMODE_INTERACTIVEVOICE |
00816                                          LINEMEDIAMODE_DATAMODEM;
00817
00818
00819   //
00820   // Specify  LINEDEVCAPFLAGS_MSP so tapi knows to call lineMSPIdentify for
00821   // the MSP CLSID. Note: version must be 3.0 or higher
00822   //
00823
00824     lpLineDevCaps->dwDevCapFlags       = LINEDEVCAPFLAGS_CLOSEDROP |
00825                                          LINEDEVCAPFLAGS_DIALBILLING |
00826                                          LINEDEVCAPFLAGS_DIALQUIET |
00827                                          LINEDEVCAPFLAGS_DIALDIALTONE |
00828                      LINEDEVCAPFLAGS_MSP;
00829
00830   lpLineDevCaps->dwAddressTypes    =  LINEADDRESSTYPE_PHONENUMBER;
00831
00832     lpLineDevCaps->dwMaxNumActiveCalls = 1;
00833     lpLineDevCaps->dwRingModes         = 1;
00834     lpLineDevCaps->dwLineFeatures      = LINEFEATURE_MAKECALL;
00835
00836     return (Epilog (&info, lResult));
00837 }
00838
00839
00840 LONG
00841 TSPIAPI
00842 TSPI_lineGetID(
00843     HDRVLINE    hdLine,
00844     DWORD       dwAddressID,
00845     HDRVCALL    hdCall,
00846     DWORD       dwSelect,
00847     LPVARSTRING lpDeviceID,
00848     LPCWSTR     lpszDeviceClass,
00849     HANDLE      hTargetProcess
00850     )
00851 {
00852 #if DBG
00853     FUNC_PARAM  params[] =
00854     {
00855         { gszhdLine,             hdLine          },
00856         { "dwAddressID",        dwAddressID     },
00857         { gszhdCall,             hdCall          },
00858         { "dwSelect",           dwSelect        },
00859         { "lpDeviceID",         lpDeviceID      },
00860         { "lpszDeviceClass",    lpszDeviceClass },
00861         { "hTargetProcess",     hTargetProcess  }
00862     };
00863     FUNC_INFO   info =
00864     {
00865         "TSPI_lineGetID",
00866         7,
00867         params
00868     };
00869 #endif
00870
00871     DWORD       dwNeededSize = sizeof(VARSTRING) + sizeof (DWORD);
00872     LONG        lResult = 0;
00873     PDRVLINE    pLine = (dwSelect == LINECALLSELECT_CALL ?
00874                     (PDRVLINE) hdCall : (PDRVLINE) hdLine);
00875
00876
00877     Prolog (&info);
00878
00879     if (lstrcmpiW (lpszDeviceClass, L"tapi/line") == 0)
00880     {
00881         if (lpDeviceID->dwTotalSize < dwNeededSize)
00882         {
00883             lpDeviceID->dwUsedSize = 3*sizeof(DWORD);
00884         }
00885         else
00886         {
00887             lpDeviceID->dwUsedSize = dwNeededSize;
00888
00889             lpDeviceID->dwStringFormat = STRINGFORMAT_BINARY;
00890             lpDeviceID->dwStringSize   = sizeof(DWORD);
00891             lpDeviceID->dwStringOffset = sizeof(VARSTRING);
00892
00893             *((LPDWORD)(lpDeviceID + 1)) = pLine->dwDeviceID;
00894         }
00895
00896         lpDeviceID->dwNeededSize = dwNeededSize;
00897     }
00898     else if (lstrcmpiW (lpszDeviceClass, L"comm/datamodem") == 0)
00899     {
00900 #ifdef _WIN64
00901         dwNeededSize += ((DWORD)strlen(pLine->szComm) + 1) * sizeof (WCHAR);
00902 #else
00903         dwNeededSize += (strlen (pLine->szComm) + 1) * sizeof (WCHAR);
00904 #endif
00905
00906         if (lpDeviceID->dwTotalSize < dwNeededSize)
00907         {
00908             lpDeviceID->dwUsedSize = 3 * sizeof(DWORD);
00909         }
00910         else
00911         {
00912             HANDLE hCommDup = NULL;
00913
00914
00915             if (!pLine->htCall)
00916             {
00917                 DBGOUT((1, "TSPI_lineGetID32: error, no active call"));
00918
00919                 lResult = LINEERR_OPERATIONFAILED;
00920
00921                 goto TSPI_lineGetID_epilog;
00922             }
00923
00924             if (!DuplicateHandle(
00925                     GetCurrentProcess(),
00926                     pLine->hComm,
00927                     hTargetProcess,
00928                     &hCommDup,
00929                     0,
00930                     TRUE,
00931                     DUPLICATE_SAME_ACCESS
00932                     ))
00933             {
00934                 DBGOUT((
00935                     1,
00936                     "TSPI_lineGetID: DupHandle failed, err=%ld",
00937                     GetLastError()
00938                     ));
00939
00940                 lResult = LINEERR_OPERATIONFAILED;
00941
00942                 goto TSPI_lineGetID_epilog;
00943             }
00944
00945             lpDeviceID->dwUsedSize = dwNeededSize;
00946
00947             lpDeviceID->dwStringFormat = STRINGFORMAT_BINARY;
00948             lpDeviceID->dwStringSize   = dwNeededSize - sizeof(VARSTRING);
00949             lpDeviceID->dwStringOffset = sizeof(VARSTRING);
00950
00951             *((HANDLE *)(lpDeviceID + 1)) = hCommDup;
00952
00953             strncpy(
00954                 ((char *)(lpDeviceID + 1)) + sizeof (HANDLE),
00955                 pLine->szComm,
00956         lpDeviceID->dwTotalSize - sizeof(VARSTRING) -sizeof(HANDLE)
00957                 );
00958         *(char * ) (lpDeviceID + lpDeviceID->dwTotalSize-1) = '\0';
00959
00960             MultiByteToWideChar(
00961                 CP_ACP,
00962                 0,
00963                 pLine->szComm,
00964                 -1,
00965                 ((WCHAR *)(lpDeviceID + 1)) + sizeof (HANDLE),
00966                 (lpDeviceID->dwTotalSize - sizeof(VARSTRING) -sizeof(HANDLE))/sizeof(WCHAR)
00967                 );
00968         }
00969
00970         lpDeviceID->dwNeededSize = dwNeededSize;
00971     }
00972     else
00973     {
00974         lResult = LINEERR_NODEVICE;
00975     }
00976
00977 TSPI_lineGetID_epilog:
00978
00979     return (Epilog (&info, lResult));
00980 }
00981
00982
00983 LONG
00984 TSPIAPI
00985 TSPI_lineGetLineDevStatus(
00986     HDRVLINE        hdLine,
00987     LPLINEDEVSTATUS lpLineDevStatus
00988     )
00989 {
00990 #if DBG
00991     FUNC_PARAM  params[] =
00992     {
00993         { gszhdLine,            hdLine          },
00994         { "lpLineDevStatus",    lpLineDevStatus }
00995     };
00996     FUNC_INFO   info =
00997     {
00998         "TSPI_lineGetLineDevStatus",
00999         2,
01000         params
01001     };
01002 #endif
01003
01004     LONG        lResult = 0;
01005     PDRVLINE    pLine = (PDRVLINE) hdLine;
01006
01007
01008     Prolog (&info);
01009
01010     lpLineDevStatus->dwUsedSize =
01011     lpLineDevStatus->dwNeededSize = sizeof (LINEDEVSTATUS);
01012
01013     lpLineDevStatus->dwNumActiveCalls = (pLine->htCall ? 1 : 0);
01014     //lpLineDevStatus->dwLineFeatures =
01015     lpLineDevStatus->dwDevStatusFlags = LINEDEVSTATUSFLAGS_CONNECTED |
01016                                         LINEDEVSTATUSFLAGS_INSERVICE;
01017     return (Epilog (&info, lResult));
01018 }
01019
01020
01021 LONG
01022 TSPIAPI
01023 TSPI_lineGetNumAddressIDs(
01024     HDRVLINE    hdLine,
01025     LPDWORD     lpdwNumAddressIDs
01026     )
01027 {
01028 #if DBG
01029     FUNC_PARAM  params[] =
01030     {
01031         { gszhdLine,            hdLine            },
01032         { "lpdwNumAddressIDs",  lpdwNumAddressIDs }
01033     };
01034     FUNC_INFO   info =
01035     {
01036         "TSPI_lineGetNumAddressIDs",
01037         2,
01038         params
01039     };
01040 #endif
01041
01042     LONG        lResult = 0;
01043     PDRVLINE    pLine = (PDRVLINE) hdLine;
01044
01045
01046     //
01047     // We only support 1 address (id=0)
01048     //
01049
01050     Prolog (&info);
01051     *lpdwNumAddressIDs = 1;
01052     return (Epilog (&info, lResult));
01053 }
01054
01055
01056 LONG
01057 TSPIAPI
01058 TSPI_lineMakeCall(
01059     DRV_REQUESTID       dwRequestID,
01060     HDRVLINE            hdLine,
01061     HTAPICALL           htCall,
01062     LPHDRVCALL          lphdCall,
01063     LPCWSTR             lpszDestAddress,
01064     DWORD               dwCountryCode,
01065     LPLINECALLPARAMS    const lpCallParams
01066     )
01067 {
01068     char        szCommands[64], szCommand[64], szDestAddress[128];
01069     DWORD       dwThreadID, dwNumBytes, dwError;
01070     PDRVLINE    pLine = (PDRVLINE) hdLine;
01071 #if DBG
01072     FUNC_PARAM  params[] =
01073     {
01074         { gszdwRequestID,       dwRequestID     },
01075         { gszhdLine,            hdLine          },
01076         { "htCall",             htCall          },
01077         { "lphdCall",           lphdCall        },
01078         { "lpszDestAddress",    szDestAddress   },
01079         { "dwCountryCode",      dwCountryCode   },
01080         { gszlpCallParams,      lpCallParams    }
01081     };
01082     FUNC_INFO info =
01083     {
01084         "TSPI_lineMakeCall",
01085         7,
01086         params
01087     };
01088 #endif
01089
01090
01091     if (lpszDestAddress)
01092     {
01093         WideCharToMultiByte(
01094             CP_ACP,
01095             0,
01096             lpszDestAddress,
01097             -1,
01098             (LPSTR) szDestAddress,
01099             128,
01100             NULL,
01101             NULL
01102             );
01103     }
01104
01105     Prolog (&info);
01106
01107
01108     //
01109     // Check to see if there's already another call
01110     //
01111
01112     if (pLine->htCall)
01113     {
01114         (*gpfnCompletionProc)(dwRequestID, LINEERR_CALLUNAVAIL);
01115         goto TSPI_lineMakeCall_return;
01116     }
01117
01118
01119     //
01120     // Since we don't support TSPI_lineDial, fail if app tries
01121     // to pass a NULL lpszDestAddress (implying that app just
01122     // wants to go offhook)
01123     //
01124
01125     if (lpszDestAddress == NULL)
01126     {
01127         (*gpfnCompletionProc)(dwRequestID, LINEERR_INVALADDRESS);
01128         goto TSPI_lineMakeCall_return;
01129     }
01130
01131
01132     //
01133     // Get the line's config info
01134     //
01135
01136     {
01137         HKEY    hKey;
01138         DWORD   dwDataSize, dwDataType;
01139         char    szLineN[8], *pszConfig, *p, *p2;
01140
01141
01142         wsprintf(
01143             szLineN,
01144             "Line%d",
01145             ((PDRVLINE) hdLine)->dwDeviceID - gdwLineDeviceIDBase
01146             );
01147
01148         dwDataSize = 256;
01149
01150         pszConfig = DrvAlloc (dwDataSize);
01151
01152         if (!pszConfig) {
01153         (*gpfnCompletionProc)(dwRequestID, LINEERR_NOMEM);
01154           goto TSPI_lineMakeCall_return;
01155         }
01156
01157         RegOpenKeyEx(
01158             HKEY_LOCAL_MACHINE,
01159             gszAtspKey,
01160             0,
01161             KEY_ALL_ACCESS,
01162             &hKey
01163             );
01164
01165         RegQueryValueEx(
01166             hKey,
01167             szLineN,
01168             0,
01169             &dwDataType,
01170             (LPBYTE) pszConfig,
01171             &dwDataSize
01172             );
01173
01174         pszConfig[dwDataSize] = '\0';       // *pszConfig = "MyLine,COM1,L0"
01175
01176         RegCloseKey (hKey);
01177
01178
01179         //
01180         // szComm
01181         //
01182
01183         for (p = pszConfig; *p != ','; p++);
01184         p++;                                // *p = "COM1,L0"
01185         for (p2 = p; *p2 != ','; p2++);
01186         *p2 = 0;                            // *p = "COM1"
01187
01188         strncpy (pLine->szComm, p, 7 );
01189     pLine->szComm[7] = '\0';
01190
01191
01192         //
01193         // szCommands
01194         //
01195
01196         p2++;                               // *p2 = "L0"
01197         strncpy (szCommands, p2, 63);
01198     szCommands[63] = '\0';
01199
01200         DrvFree (pszConfig);
01201     }
01202
01203
01204     //
01205     // Open the port
01206     //
01207
01208     if ((pLine->hComm = CreateFile(
01209             pLine->szComm,
01210             GENERIC_READ | GENERIC_WRITE,
01211             0, //FILE_SHARE_READ | FILE_SHARE_WRITE,
01212             NULL, // no security attrs
01213             OPEN_EXISTING,
01214             FILE_FLAG_OVERLAPPED,
01215             NULL  // no template file
01216
01217             )) == INVALID_HANDLE_VALUE)
01218     {
01219         DBGOUT((
01220             3,
01221             "TSPI_lineMakeCall: CreateFile(%s) failed, err=%ld",
01222             pLine->szComm,
01223             GetLastError()
01224             ));
01225
01226         (*gpfnCompletionProc)(dwRequestID, LINEERR_RESOURCEUNAVAIL);
01227         goto TSPI_lineMakeCall_return;
01228     }
01229
01230
01231     //
01232     // Setup up the modem command string.  If there's an initial 'T'
01233     // or 'P' (for Tone or Pulse) in the dest address then disregard
01234     // it.  Also if it's a voice call add the semi colon so we return
01235     // to cmd mode.
01236     //
01237
01238     {
01239         char *p = (char *) szDestAddress;
01240
01241
01242         if (*p == 'T'  ||  *p == 'P')
01243         {
01244             p++;
01245         }
01246
01247         if (lpCallParams &&
01248             lpCallParams->dwMediaMode != LINEMEDIAMODE_INTERACTIVEVOICE)
01249         {
01250             wsprintf (szCommand, "AT%sDT%s\r", szCommands, p);
01251         }
01252         else
01253         {
01254             wsprintf (szCommand, "AT%sDT%s;\r", szCommands, p);
01255         }
01256     }
01257
01258
01259     //
01260     // Init the data structure & tell tapi our handle to the call
01261     //
01262
01263     pLine->htCall          = htCall;
01264     pLine->bDropInProgress = FALSE;
01265     pLine->dwMediaMode     = (lpCallParams ? lpCallParams->dwMediaMode :
01266         LINEMEDIAMODE_INTERACTIVEVOICE);
01267
01268     *lphdCall = (HDRVCALL) pLine;
01269
01270
01271     //
01272     // Do an overlapped write, the comm thread will deal with the results
01273     //
01274
01275     pLine->Overlapped.hEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
01276
01277     if (!WriteFile(
01278             pLine->hComm,
01279             szCommand,
01280             lstrlen (szCommand),
01281             &dwNumBytes,
01282             &pLine->Overlapped
01283             )
01284
01285         && (dwError = GetLastError()) != ERROR_IO_PENDING)
01286     {
01287         DBGOUT((
01288             1,
01289             "TSPI_lineMakeCall: WriteFile(%s) failed, error=%d",
01290             pLine->szComm,
01291             dwError
01292             ));
01293
01294         pLine->htCall = NULL;
01295         CloseHandle (pLine->hComm);
01296         CloseHandle (pLine->Overlapped.hEvent);
01297         (*gpfnCompletionProc)(dwRequestID, LINEERR_OPERATIONFAILED);
01298         goto TSPI_lineMakeCall_return;
01299     }
01300
01301
01302     //
01303     // Complete the requests & set the initial call state
01304     //
01305
01306     (*gpfnCompletionProc)(dwRequestID, 0);
01307     SetCallState (pLine, LINECALLSTATE_DIALING, 0);
01308
01309
01310     //
01311     // Spin the comm thread to handle the results of the Write above
01312     //
01313
01314     {
01315         HANDLE hCommThread;
01316
01317
01318         if (!(hCommThread = CreateThread(
01319                 (LPSECURITY_ATTRIBUTES) NULL,
01320                 0,
01321                 (LPTHREAD_START_ROUTINE) CommThread,
01322                 pLine,
01323                 0,
01324                 &dwThreadID
01325                 )))
01326         {
01327             DBGOUT((
01328                 1,
01329                 "TSPI_lineMakeCall: CreateThread failed, err=%ld",
01330                 GetLastError()
01331                 ));
01332
01333             GetOverlappedResult(
01334                 pLine->hComm,
01335                 &pLine->Overlapped,
01336                 &dwNumBytes,
01337                 TRUE
01338                 );
01339
01340             SetCallState (pLine, LINECALLSTATE_IDLE, 0);
01341             CloseHandle (pLine->hComm);
01342             CloseHandle (pLine->Overlapped.hEvent);
01343             goto TSPI_lineMakeCall_return;
01344         }
01345
01346         CloseHandle (hCommThread);
01347     }
01348
01349
01350 TSPI_lineMakeCall_return:
01351
01352     return (Epilog (&info, dwRequestID));
01353 }
01354
01355
01356 LONG
01357 TSPIAPI
01358 TSPI_lineNegotiateTSPIVersion(
01359     DWORD   dwDeviceID,
01360     DWORD   dwLowVersion,
01361     DWORD   dwHighVersion,
01362     LPDWORD lpdwTSPIVersion
01363     )
01364 {
01365     LONG        lResult = 0;
01366 #if DBG
01367     FUNC_PARAM  params[] =
01368     {
01369         { gszdwDeviceID,        dwDeviceID      },
01370         { "dwLowVersion",       dwLowVersion    },
01371         { "dwHighVersion",      dwHighVersion   },
01372         { "lpdwTSPIVersion",    lpdwTSPIVersion }
01373     };
01374     FUNC_INFO   info =
01375     {
01376         "TSPI_lineNegotiateTSPIVersion",
01377         4,
01378         params
01379     };
01380 #endif
01381
01382     Prolog (&info);
01383
01384   // version 3.0 to allow MSP usage
01385   //
01386
01387     *lpdwTSPIVersion = 0x00030000;
01388     return (Epilog (&info, lResult));
01389 }
01390
01391
01392 LONG
01393 TSPIAPI
01394 TSPI_lineOpen(
01395     DWORD       dwDeviceID,
01396     HTAPILINE   htLine,
01397     LPHDRVLINE  lphdLine,
01398     DWORD       dwTSPIVersion,
01399     LINEEVENT   lpfnEventProc
01400     )
01401 {
01402     LONG        lResult;
01403     PDRVLINE    pLine;
01404 #if DBG
01405     FUNC_PARAM  params[] =
01406     {
01407         { gszdwDeviceID,    dwDeviceID      },
01408         { "htLine",         htLine          },
01409         { "lphdLine",       lphdLine        },
01410         { "dwTSPIVersion",  dwTSPIVersion   },
01411         { "lpfnEventProc",  lpfnEventProc   }
01412     };
01413     FUNC_INFO   info =
01414     {
01415         "TSPI_lineOpen",
01416         5,
01417         params
01418     };
01419 #endif
01420
01421
01422     Prolog (&info);
01423
01424     if ((pLine = DrvAlloc (sizeof (DRVLINE))))
01425     {
01426         pLine->htLine       = htLine;
01427         pLine->pfnEventProc = lpfnEventProc;
01428         pLine->dwDeviceID   = dwDeviceID;
01429
01430         *lphdLine = (HDRVLINE) pLine;
01431
01432         lResult = 0;
01433     }
01434     else
01435     {
01436         lResult = LINEERR_NOMEM;
01437     }
01438
01439     return (Epilog (&info, lResult));
01440 }
01441
01442
01443 LONG
01444 TSPIAPI
01445 TSPI_lineSetDefaultMediaDetection(
01446     HDRVLINE    hdLine,
01447     DWORD       dwMediaModes
01448     )
01449 {
01450 #if DBG
01451     FUNC_PARAM  params[] =
01452     {
01453         { gszhdLine,        hdLine       },
01454         { "dwMediaModes",   dwMediaModes }
01455     };
01456     FUNC_INFO   info =
01457     {
01458         "TSPI_lineSetDefaultMediaDetection",
01459         2,
01460         params
01461     };
01462 #endif
01463
01464
01465     //
01466     // This func is really a no-op for us, since we don't look
01467     // for incoming calls (though we do say we support them to
01468     // make apps happy)
01469     //
01470
01471     Prolog (&info);
01472     return (Epilog (&info, 0));
01473 }
01474
01475
01476 //
01477 // ------------------------- TSPI_providerXxx funcs ---------------------------
01478 //
01479
01480 LONG
01481 TSPIAPI
01482 TSPI_providerConfig(
01483     HWND    hwndOwner,
01484     DWORD   dwPermanentProviderID
01485     )
01486 {
01487     //
01488     // Although this func is never called by TAPI v2.0, we export
01489     // it so that the Telephony Control Panel Applet knows that it
01490     // can configure this provider via lineConfigProvider(),
01491     // otherwise Telephon.cpl will not consider it configurable
01492     //
01493
01494     return 0;
01495 }
01496
01497
01498 LONG
01499 TSPIAPI
01500 TSPI_providerGenericDialogData(
01501     DWORD_PTR           dwObjectID,
01502     DWORD               dwObjectType,
01503     LPVOID              lpParams,
01504     DWORD               dwSize
01505     )
01506 {
01507     LONG        lResult = 0;
01508 #if DBG
01509     FUNC_PARAM  params[] =
01510     {
01511         { "dwObjectID",     dwObjectID      },
01512         { "dwObjectType",   dwObjectType    },
01513         { "lpParams",       lpParams        },
01514         { "dwSize",         dwSize          }
01515     };
01516     FUNC_INFO   info =
01517     {
01518         "TSPI_providerGenericDialogData",
01519         4,
01520         params
01521     };
01522 #endif
01523
01524
01525     Prolog (&info);
01526     return (Epilog (&info, lResult));
01527 }
01528
01529
01530 LONG
01531 TSPIAPI
01532 TSPI_providerInit(
01533     DWORD               dwTSPIVersion,
01534     DWORD               dwPermanentProviderID,
01535     DWORD               dwLineDeviceIDBase,
01536     DWORD               dwPhoneDeviceIDBase,
01537     DWORD_PTR           dwNumLines,
01538     DWORD_PTR           dwNumPhones,
01539     ASYNC_COMPLETION    lpfnCompletionProc,
01540     LPDWORD             lpdwTSPIOptions
01541     )
01542 {
01543     LONG        lResult = 0;
01544 #if DBG
01545     FUNC_PARAM  params[] =
01546     {
01547         { "dwTSPIVersion",          dwTSPIVersion           },
01548         { gszdwPermanentProviderID, dwPermanentProviderID   },
01549         { "dwLineDeviceIDBase",     dwLineDeviceIDBase      },
01550         { "dwPhoneDeviceIDBase",    dwPhoneDeviceIDBase     },
01551         { "dwNumLines",             dwNumLines              },
01552         { "dwNumPhones",            dwNumPhones             },
01553         { "lpfnCompletionProc",     lpfnCompletionProc      }
01554     };
01555     FUNC_INFO   info =
01556     {
01557         "TSPI_providerInit",
01558         7,
01559         params
01560     };
01561 #endif
01562
01563     Prolog (&info);
01564     gdwLineDeviceIDBase = dwLineDeviceIDBase;
01565     gpfnCompletionProc  = lpfnCompletionProc;
01566     *lpdwTSPIOptions = LINETSPIOPTION_NONREENTRANT;
01567     return (Epilog (&info, lResult));
01568 }
01569
01570
01571 LONG
01572 TSPIAPI
01573 TSPI_providerInstall(
01574     HWND    hwndOwner,
01575     DWORD   dwPermanentProviderID
01576     )
01577 {
01578     //
01579     // Although this func is never called by TAPI v2.0, we export
01580     // it so that the Telephony Control Panel Applet knows that it
01581     // can add this provider via lineAddProvider(), otherwise
01582     // Telephon.cpl will not consider it installable
01583     //
01584     //
01585
01586     return 0;
01587 }
01588
01589
01590 LONG
01591 TSPIAPI
01592 TSPI_providerRemove(
01593     HWND    hwndOwner,
01594     DWORD   dwPermanentProviderID
01595     )
01596 {
01597     //
01598     // Although this func is never called by TAPI v2.0, we export
01599     // it so that the Telephony Control Panel Applet knows that it
01600     // can remove this provider via lineRemoveProvider(), otherwise
01601     // Telephon.cpl will not consider it removable
01602     //
01603
01604     return 0;
01605 }
01606
01607
01608 LONG
01609 TSPIAPI
01610 TSPI_providerShutdown(
01611     DWORD   dwTSPIVersion,
01612     DWORD   dwPermanentProviderID
01613     )
01614 {
01615     LONG        lResult = 0;
01616 #if DBG
01617     FUNC_PARAM  params[] =
01618     {
01619         { "dwTSPIVersion",          dwTSPIVersion },
01620         { gszdwPermanentProviderID, dwPermanentProviderID   }
01621     };
01622     FUNC_INFO   info =
01623     {
01624         "TSPI_providerShutdown",
01625         2,
01626         params
01627     };
01628 #endif
01629
01630
01631     Prolog (&info);
01632
01633     return (Epilog (&info, lResult));
01634 }
01635
01636
01637 LONG
01638 TSPIAPI
01639 TSPI_providerEnumDevices(
01640     DWORD       dwPermanentProviderID,
01641     LPDWORD     lpdwNumLines,
01642     LPDWORD     lpdwNumPhones,
01643     HPROVIDER   hProvider,
01644     LINEEVENT   lpfnLineCreateProc,
01645     PHONEEVENT  lpfnPhoneCreateProc
01646     )
01647 {
01648    HKEY     hKey;
01649    DWORD    dwNumLines, dwDataType, dwDataSize;
01650
01651
01652    //
01653    // Retrieve the number of devices we're
01654    // configured for from our registry section
01655    //
01656
01657    RegOpenKeyEx(
01658        HKEY_LOCAL_MACHINE,
01659        gszAtspKey,
01660        0,
01661        KEY_ALL_ACCESS,
01662        &hKey
01663        );
01664
01665    dwDataSize = sizeof(dwNumLines);
01666    dwNumLines = 0;
01667
01668    RegQueryValueEx(
01669        hKey,
01670        gszNumLines,
01671        0,
01672        &dwDataType,
01673        (LPBYTE) &dwNumLines,
01674        &dwDataSize
01675        );
01676
01677    RegCloseKey (hKey);
01678
01679    *lpdwNumLines  = dwNumLines;
01680    *lpdwNumPhones = 0;
01681    return 0;
01682 }
01683
01684
01685 LONG
01686 TSPIAPI
01687 TSPI_providerUIIdentify(
01688     LPWSTR   lpszUIDLLName
01689     )
01690 {
01691     LONG        lResult = 0;
01692 #if DBG
01693     FUNC_PARAM  params[] =
01694     {
01695         { "lpsUIDLLName",  lpszUIDLLName }
01696     };
01697     FUNC_INFO   info =
01698     {
01699         "TSPI_providerUIIdentify",
01700         1,
01701         params
01702     };
01703 #endif
01704
01705
01706     Prolog (&info);
01707     My_lstrcpyW(lpszUIDLLName, L"atsp32.tsp");
01708     return (Epilog (&info, lResult));
01709 }
01710
01711
01712 //
01713 // ---------------------------- TUISPI_xxx funcs ------------------------------
01714 //
01715
01716 LONG
01717 TSPIAPI
01718 TUISPI_lineConfigDialog(
01719     TUISPIDLLCALLBACK   lpfnUIDLLCallback,
01720     DWORD               dwDeviceID,
01721     HWND                hwndOwner,
01722     LPCWSTR             lpszDeviceClass
01723     )
01724 {
01725     char        szDeviceClass[128];
01726     LONG        lResult = 0;
01727 #if DBG
01728     FUNC_PARAM  params[] =
01729     {
01730         { "lpfnUIDLLCallback",   lpfnUIDLLCallback },
01731         { gszdwDeviceID,         dwDeviceID        },
01732         { gszhwndOwner,          hwndOwner         },
01733         { "lpszDeviceClass",     szDeviceClass     }
01734     };
01735     FUNC_INFO   info =
01736     {
01737         "TUISPI_lineConfigDialog",
01738         4,
01739         params
01740     };
01741 #endif
01742
01743
01744     if (lpszDeviceClass)
01745     {
01746         WideCharToMultiByte(
01747             CP_ACP,
01748             0,
01749             lpszDeviceClass,
01750             -1,
01751             (LPSTR) szDeviceClass,
01752             128,
01753             NULL,
01754             NULL
01755             );
01756     }
01757
01758     Prolog (&info);
01759
01760     DialogBoxParam(
01761         ghInst,
01762         MAKEINTRESOURCE(IDD_DIALOG1),
01763         hwndOwner,
01764         (DLGPROC) ConfigDlgProc,
01765         0
01766         );
01767
01768     return (Epilog (&info, lResult));
01769 }
01770
01771
01772 LONG
01773 TSPIAPI
01774 TUISPI_providerConfig(
01775     TUISPIDLLCALLBACK   lpfnUIDLLCallback,
01776     HWND                hwndOwner,
01777     DWORD               dwPermanentProviderID
01778     )
01779 {
01780     LONG        lResult = 0;
01781 #if DBG
01782     FUNC_PARAM  params[] =
01783     {
01784         { "lpfnUIDLLCallback",      lpfnUIDLLCallback },
01785         { gszhwndOwner,             hwndOwner    },
01786         { gszdwPermanentProviderID, dwPermanentProviderID   }
01787     };
01788     FUNC_INFO   info =
01789     {
01790         "TUISPI_providerConfig",
01791         3,
01792         params
01793     };
01794 #endif
01795
01796
01797     Prolog (&info);
01798
01799     DialogBoxParam(
01800         ghInst,
01801         MAKEINTRESOURCE(IDD_DIALOG1),
01802         hwndOwner,
01803         (DLGPROC) ConfigDlgProc,
01804         0
01805         );
01806
01807     return (Epilog (&info, lResult));
01808 }
01809
01810
01811 LONG
01812 TSPIAPI
01813 TUISPI_providerInstall(
01814     TUISPIDLLCALLBACK   lpfnUIDLLCallback,
01815     HWND                hwndOwner,
01816     DWORD               dwPermanentProviderID
01817     )
01818 {
01819     LONG    lResult;
01820
01821
01822     if ((lResult = ProviderInstall ("atsp32.tsp", TRUE)) == 0)
01823     {
01824         DialogBoxParam(
01825             ghInst,
01826             MAKEINTRESOURCE(IDD_DIALOG1),
01827             hwndOwner,
01828             (DLGPROC) ConfigDlgProc,
01829             0
01830             );
01831     }
01832
01833     return lResult;
01834 }
01835
01836
01837 LONG
01838 TSPIAPI
01839 TUISPI_providerRemove(
01840     TUISPIDLLCALLBACK   lpfnUIDLLCallback,
01841     HWND                hwndOwner,
01842     DWORD               dwPermanentProviderID
01843     )
01844 {
01845     HKEY    hKey;
01846     char    szSoftwareMsft[] = "Software\\Microsoft", szATSP[] = "ATSP";
01847
01848
01849     //
01850     // Clean up our registry section
01851     //
01852
01853     RegOpenKeyExA(
01854         HKEY_LOCAL_MACHINE,
01855         szSoftwareMsft,
01856         0,
01857         KEY_ALL_ACCESS,
01858         &hKey
01859         );
01860
01861     RegDeleteKeyA (hKey, szATSP);
01862     RegCloseKey (hKey);
01863     return 0;
01864 }
01865
01866
01867 #pragma warning (default:4047)
01868
01869
01870 //
01871 // ---------------------- Misc private support routines -----------------------
01872 //
01873
01874 LPWSTR
01875 PASCAL
01876 My_lstrcpyW(
01877     WCHAR   *pString1,
01878     WCHAR   *pString2
01879     )
01880 {
01881     WCHAR *p = pString1;
01882
01883
01884     for (; (*p = *pString2); p++, pString2++);
01885     return pString1;
01886 }
01887
01888
01889 void
01890 PASCAL
01891 EnableChildren(
01892     HWND    hwnd,
01893     BOOL    bEnable
01894     )
01895 {
01896     int i;
01897     static int aiControlIDs[] =
01898     {
01899         IDC_DEVICES,
01900         IDC_NAME,
01901         IDC_PORT,
01902         IDC_COMMANDS,
01903         IDC_REMOVE,
01904         0
01905     };
01906
01907
01908     for (i = 0; aiControlIDs[i]; i++)
01909     {
01910         EnableWindow (GetDlgItem (hwnd, aiControlIDs[i]), bEnable);
01911     }
01912 }
01913
01914
01915 void
01916 PASCAL
01917 SelectDevice(
01918     HWND    hwnd,
01919     LRESULT     iDevice
01920     )
01921 {
01922     SendDlgItemMessage (hwnd, IDC_DEVICES, LB_SETCURSEL, iDevice, 0);
01923     PostMessage(hwnd, WM_COMMAND, IDC_DEVICES | (LBN_SELCHANGE << 16), 0);
01924 }
01925
01926
01927 BOOL
01928 CALLBACK
01929 ConfigDlgProc(
01930     HWND    hwnd,
01931     UINT    msg,
01932     WPARAM  wParam,
01933     LPARAM  lParam
01934     )
01935 {
01936     static  HKEY    hAtspKey;
01937
01938     DWORD   dwDataSize;
01939     DWORD   dwDataType;
01940
01941
01942     switch (msg)
01943     {
01944     case WM_INITDIALOG:
01945     {
01946         char   *pBuf;
01947         DWORD   i, iNumLines;
01948
01949
01950         //
01951         // Create or open our configuration key in the registry.  If the
01952         // create fails it may well be that the current user does not
01953         // have write access to this portion of the registry, so we'll
01954         // just show a "read only" dialog and not allow user to make any
01955         // changes
01956         //
01957
01958         {
01959             LONG    lResult;
01960             DWORD   dwDisposition;
01961
01962
01963             if ((lResult = RegCreateKeyEx(
01964                     HKEY_LOCAL_MACHINE,
01965                     gszAtspKey,
01966                     0,
01967                     "",
01968                     REG_OPTION_NON_VOLATILE,
01969                     KEY_ALL_ACCESS,
01970                     (LPSECURITY_ATTRIBUTES) NULL,
01971                     &hAtspKey,
01972                     &dwDisposition
01973
01974                     )) != ERROR_SUCCESS)
01975             {
01976                 DBGOUT((
01977                     3,
01978                     "RegCreateKeyEx(%s,ALL_ACCESS) failed, err=%d",
01979                     gszAtspKey,
01980                     lResult
01981                     ));
01982
01983                 if ((lResult = RegOpenKeyEx(
01984                         HKEY_LOCAL_MACHINE,
01985                         gszAtspKey,
01986                         0,
01987                         KEY_QUERY_VALUE,
01988                         &hAtspKey
01989
01990                         )) != ERROR_SUCCESS)
01991                 {
01992                     DBGOUT((
01993                         3,
01994                         "RegOpenKeyEx(%s,ALL_ACCESS) failed, err=%d",
01995                         gszAtspKey,
01996                         lResult
01997                         ));
01998
01999                     EndDialog (hwnd, 0);
02000                     return FALSE;
02001                 }
02002
02003                 {
02004                     int i;
02005                     static int aiControlIDs[] =
02006                     {
02007                         IDC_NAME,
02008                         IDC_PORT,
02009                         IDC_COMMANDS,
02010                         IDC_ADD,
02011                         IDC_REMOVE,
02012                         IDOK,
02013                         0
02014                     };
02015
02016
02017                     for (i = 0; aiControlIDs[i]; i++)
02018                     {
02019                         EnableWindow(
02020                             GetDlgItem (hwnd, aiControlIDs[i]),
02021                             FALSE
02022                             );
02023                     }
02024                 }
02025             }
02026         }
02027
02028
02029         //
02030         // Retrieve our configuration info from the registry
02031         //
02032
02033         dwDataSize = sizeof(iNumLines);
02034         iNumLines = 0;
02035
02036         RegQueryValueEx(
02037             hAtspKey,
02038             gszNumLines,
02039             0,
02040             &dwDataType,
02041             (LPBYTE) &iNumLines,
02042             &dwDataSize
02043             );
02044
02045         SendDlgItemMessage(
02046             hwnd,
02047             IDC_NAME,
02048             EM_LIMITTEXT,
02049             MAX_DEV_NAME_LENGTH,
02050             0
02051             );
02052
02053         SendDlgItemMessage(
02054             hwnd,
02055             IDC_COMMANDS,
02056             EM_LIMITTEXT,
02057             MAX_DEV_NAME_LENGTH,
02058             0
02059             );
02060
02061         if (!(pBuf = DrvAlloc (256)))
02062           break;
02063
02064         for (i = 0; i < iNumLines; i++)
02065         {
02066             char           *p, *p2, szLineN[8];
02067             PDRVLINECONFIG  pLineConfig;
02068             LONG            lResult;
02069
02070        if (!(pLineConfig = DrvAlloc (sizeof(DRVLINECONFIG))))
02071         break;
02072
02073             wsprintf (szLineN, "Line%d", i);
02074
02075             dwDataSize = 256;
02076
02077             lResult = RegQueryValueEx(
02078                 hAtspKey,
02079                 szLineN,
02080                 0,
02081                 &dwDataType,
02082                 (LPBYTE) pBuf,
02083                 &dwDataSize
02084                 );
02085
02086
02087             //
02088             // If there was a problem, use the default config
02089             //
02090
02091             if (0 != lResult)
02092             {
02093                strncpy (pBuf, gszDefLineConfigParams, 255);
02094         pBuf[255] = '\0';
02095             }
02096
02097             for (p = pBuf; *p != ','; p++);
02098             *p = 0;
02099
02100             SendDlgItemMessage(
02101                 hwnd,
02102                 IDC_DEVICES,
02103                 LB_ADDSTRING,
02104                 0,
02105                 (LPARAM) pBuf
02106                 );
02107
02108             SendDlgItemMessage(
02109                 hwnd,
02110                 IDC_DEVICES,
02111                 LB_SETITEMDATA,
02112                 i,
02113                 (LPARAM) pLineConfig
02114                 );
02115
02116             p++;
02117             for (p2 = p; *p2 != ','; p2++);
02118             *p2 = 0;
02119
02120             strncpy (pLineConfig->szPort, p, 7 );
02121       pLineConfig->szPort[7] = '\0';
02122
02123             p = p2 + 1;
02124
02125             strncpy (pLineConfig->szCommands, p,63);
02126       pLineConfig->szCommands[63] = '\0';
02127         }
02128
02129         DrvFree (pBuf);
02130
02131
02132         //
02133         // Fill up the various controls with configuration options
02134         //
02135
02136         {
02137             static char *aszPorts[] = { "COM1","COM2","COM3",NULL };
02138
02139             for (i = 0; aszPorts[i]; i++)
02140             {
02141                 SendDlgItemMessage(
02142                     hwnd,
02143                     IDC_PORT,
02144                     LB_ADDSTRING,
02145                     0,
02146                     (LPARAM) aszPorts[i]
02147                     );
02148             }
02149         }
02150
02151         if (iNumLines == 0)
02152         {
02153             EnableChildren (hwnd, FALSE);
02154         }
02155         else
02156         {
02157             SelectDevice (hwnd, 0);
02158         }
02159
02160         break;
02161     }
02162     case WM_COMMAND:
02163     {
02164         LRESULT             iSelection;
02165         PDRVLINECONFIG  pLineConfig;
02166
02167
02168         iSelection = SendDlgItemMessage(
02169             hwnd,
02170             IDC_DEVICES,
02171             LB_GETCURSEL,
02172             0,
02173             0
02174             );
02175
02176         pLineConfig = (PDRVLINECONFIG) SendDlgItemMessage(
02177             hwnd,
02178             IDC_DEVICES,
02179             LB_GETITEMDATA,
02180             (WPARAM) iSelection,
02181             0
02182             );
02183
02184         switch (LOWORD((DWORD)wParam))
02185         {
02186         case IDC_DEVICES:
02187
02188             if (HIWORD(wParam) == LBN_SELCHANGE)
02189             {
02190                 char buf[MAX_DEV_NAME_LENGTH + 1];
02191
02192
02193                 SendDlgItemMessage(
02194                     hwnd,
02195                     IDC_DEVICES,
02196                     LB_GETTEXT,
02197                     iSelection,
02198                     (LPARAM) buf
02199                     );
02200
02201                 SetDlgItemText (hwnd, IDC_NAME, buf);
02202
02203                 SendDlgItemMessage(
02204                     hwnd,
02205                     IDC_PORT,
02206                     LB_SELECTSTRING,
02207                     (WPARAM) -1,
02208                     (LPARAM) pLineConfig->szPort
02209                     );
02210
02211                 SetDlgItemText (hwnd, IDC_COMMANDS, pLineConfig->szCommands);
02212             }
02213
02214             break;
02215
02216         case IDC_NAME:
02217
02218             if ((HIWORD(wParam) == EN_CHANGE) && (iSelection != LB_ERR))
02219             {
02220                 char    buf[MAX_DEV_NAME_LENGTH + 1];
02221
02222
02223                 GetDlgItemText (hwnd, IDC_NAME, buf, MAX_DEV_NAME_LENGTH);
02224
02225                 SendDlgItemMessage(
02226                     hwnd,
02227                     IDC_DEVICES,
02228                     LB_DELETESTRING,
02229                     iSelection,
02230                     0
02231                     );
02232
02233                 SendDlgItemMessage(
02234                     hwnd,
02235                     IDC_DEVICES,
02236                     LB_INSERTSTRING,
02237                     iSelection,
02238                     (LPARAM) buf
02239                     );
02240
02241                 SendDlgItemMessage(
02242                     hwnd,
02243                     IDC_DEVICES,
02244                     LB_SETCURSEL,
02245                     iSelection,
02246                     0
02247                     );
02248
02249                 SendDlgItemMessage(
02250                     hwnd,
02251                     IDC_DEVICES,
02252                     LB_SETITEMDATA,
02253                     iSelection,
02254                     (LPARAM) pLineConfig
02255                     );
02256             }
02257
02258             break;
02259
02260         case IDC_PORT:
02261
02262             if (HIWORD(wParam) == LBN_SELCHANGE)
02263             {
02264                 iSelection = SendDlgItemMessage(
02265                     hwnd,
02266                     IDC_PORT,
02267                     LB_GETCURSEL,
02268                     0,
02269                     0
02270                     );
02271
02272                 SendDlgItemMessage(
02273                     hwnd,
02274                     IDC_PORT,
02275                     LB_GETTEXT,
02276                     iSelection,
02277                     (LPARAM) pLineConfig->szPort
02278                     );
02279             }
02280
02281             break;
02282
02283         case IDC_COMMANDS:
02284
02285             if ((HIWORD(wParam) == EN_CHANGE) && (iSelection != LB_ERR))
02286             {
02287                 GetDlgItemText(
02288                     hwnd,
02289                     IDC_COMMANDS,
02290                     pLineConfig->szCommands,
02291                     63
02292                     );
02293             }
02294
02295             break;
02296
02297         case IDC_ADD:
02298         {
02299             LRESULT             iNumLines;
02300       int       i = 2;
02301             char            szLineName[32];
02302             PDRVLINECONFIG  pLineConfig;
02303
02304             if(!(pLineConfig = DrvAlloc (sizeof(DRVLINECONFIG))))
02305               break;
02306
02307
02308             iNumLines = SendDlgItemMessage(
02309                 hwnd,
02310                 IDC_DEVICES,
02311                 LB_GETCOUNT,
02312                 0,
02313                 0
02314                 );
02315
02316             strncpy (pLineConfig->szPort, "COM1", 7);
02317       pLineConfig->szPort[7] = '\0';
02318
02319             strncpy (szLineName, "my new line",31 );
02320       szLineName[31] = '\0';
02321
02322 find_unique_line_name:
02323
02324             if (SendDlgItemMessage(
02325                     hwnd,
02326                     IDC_DEVICES,
02327                     LB_FINDSTRING,
02328                     (WPARAM) -1,
02329                     (LPARAM) szLineName
02330
02331                     ) != LB_ERR)
02332             {
02333                 wsprintf (szLineName, "my new line%d", i++);
02334                 goto find_unique_line_name;
02335             }
02336
02337             SendDlgItemMessage(
02338                 hwnd,
02339                 IDC_DEVICES,
02340                 LB_ADDSTRING,
02341                 0,
02342                 (LPARAM) szLineName
02343                 );
02344
02345             SendDlgItemMessage(
02346                 hwnd,
02347                 IDC_DEVICES,
02348                 LB_SETITEMDATA,
02349                 iNumLines,
02350                 (LPARAM) pLineConfig
02351                 );
02352
02353             EnableChildren (hwnd, TRUE);
02354
02355             SelectDevice (hwnd, iNumLines);
02356
02357             SetFocus (GetDlgItem (hwnd, IDC_NAME));
02358
02359             SendDlgItemMessage(
02360                 hwnd,
02361                 IDC_NAME,
02362                 EM_SETSEL,
02363                 0,
02364                 (LPARAM) -1
02365                 );
02366
02367             break;
02368         }
02369         case IDC_REMOVE:
02370         {
02371             LRESULT iNumLines;
02372
02373
02374             DrvFree (pLineConfig);
02375
02376             iNumLines = SendDlgItemMessage(
02377                 hwnd,
02378                 IDC_DEVICES,
02379                 LB_DELETESTRING,
02380                 iSelection,
02381                 0
02382                 );
02383
02384             if (iNumLines == 0)
02385             {
02386                 SetDlgItemText (hwnd, IDC_NAME, "");
02387                 SetDlgItemText (hwnd, IDC_COMMANDS, "");
02388
02389                 EnableChildren (hwnd, FALSE);
02390             }
02391             else
02392             {
02393                 SelectDevice (hwnd, 0);
02394             }
02395
02396             break;
02397         }
02398         case IDOK:
02399         {
02400             int     i;
02401       LRESULT iNumLines;
02402             char   *pBuf;
02403
02404
02405             //
02406             // Update the num lines & num phones values
02407             //
02408
02409             if (!(pBuf = DrvAlloc (256)))
02410               break;
02411
02412             iNumLines = SendDlgItemMessage(
02413                 hwnd,
02414                 IDC_DEVICES,
02415                 LB_GETCOUNT,
02416                 0,
02417                 0
02418                 );
02419
02420             RegSetValueEx(
02421                 hAtspKey,
02422                 gszNumLines,
02423                 0,
02424                 REG_DWORD,
02425                 (LPBYTE) &iNumLines,
02426                 sizeof(DWORD)
02427                 );
02428
02429
02430             //
02431             // For each installed device save it's config info
02432             //
02433
02434             for (i = 0; i < iNumLines; i++)
02435             {
02436                 char szLineN[8];
02437                 PDRVLINECONFIG pLineConfig;
02438
02439
02440                 SendDlgItemMessage(
02441                     hwnd,
02442                     IDC_DEVICES,
02443                     LB_GETTEXT,
02444                     i,
02445                     (LPARAM) pBuf
02446                     );
02447
02448                 pLineConfig = (PDRVLINECONFIG) SendDlgItemMessage(
02449                     hwnd,
02450                     IDC_DEVICES,
02451                     LB_GETITEMDATA,
02452                     i,
02453                     0
02454                     );
02455
02456                 wsprintf(
02457                     pBuf + strlen (pBuf),
02458                     ",%s,%s",
02459                     pLineConfig->szPort,
02460                     pLineConfig->szCommands
02461                     );
02462
02463                 wsprintf (szLineN, "Line%d", i);
02464
02465                 RegSetValueEx(
02466                     hAtspKey,
02467                     szLineN,
02468                     0,
02469                     REG_SZ,
02470                     (LPBYTE) pBuf,
02471                     lstrlen (pBuf) + 1
02472                     );
02473
02474                 DrvFree (pLineConfig);
02475             }
02476
02477             DrvFree (pBuf);
02478
02479             // fall thru to EndDialog...
02480         }
02481         case IDCANCEL:
02482
02483             RegCloseKey (hAtspKey);
02484             EndDialog (hwnd, 0);
02485             break;
02486
02487         } // switch (LOWORD((DWORD)wParam))
02488
02489         break;
02490     }
02491     } // switch (msg)
02492
02493     return FALSE;
02494 }
02495
02496
02497 LPVOID
02498 PASCAL
02499 DrvAlloc(
02500     DWORD dwSize
02501     )
02502 {
02503     return (LocalAlloc (LPTR, dwSize));
02504 }
02505
02506
02507 VOID
02508 PASCAL
02509 DrvFree(
02510     LPVOID lp
02511     )
02512 {
02513     LocalFree (lp);
02514 }
02515
02516
02517 void
02518 PASCAL
02519 SetCallState(
02520     PDRVLINE    pLine,
02521     DWORD       dwCallState,
02522     DWORD       dwCallStateMode
02523     )
02524 {
02525     if (dwCallState != pLine->dwCallState)
02526     {
02527         pLine->dwCallState     = dwCallState;
02528         pLine->dwCallStateMode = dwCallStateMode;
02529
02530         (*pLine->pfnEventProc)(
02531             pLine->htLine,
02532             pLine->htCall,
02533             LINE_CALLSTATE,
02534             dwCallState,
02535             dwCallStateMode,
02536             pLine->dwMediaMode
02537             );
02538     }
02539 }
02540
02541
02542 #if DBG
02543
02544 void
02545 PASCAL
02546 Prolog(
02547     PFUNC_INFO  pInfo
02548     )
02549 {
02550     DWORD i;
02551
02552
02553     DBGOUT((3, "%s: enter", pInfo->lpszFuncName));
02554
02555     for (i = 0; i < pInfo->dwNumParams; i++)
02556     {
02557         if (pInfo->aParams[i].dwVal &&
02558             pInfo->aParams[i].lpszVal[3] == 'z') // lpszVal = "lpsz..."
02559         {
02560             DBGOUT((
02561                 3,
02562                 "%s%s=x%lx, '%s'",
02563                 gszTab,
02564                 pInfo->aParams[i].lpszVal,
02565                 pInfo->aParams[i].dwVal,
02566                 pInfo->aParams[i].dwVal
02567                 ));
02568         }
02569         else
02570         {
02571             DBGOUT((
02572                 3,
02573                 "%s%s=x%lx",
02574                 gszTab,
02575                 pInfo->aParams[i].lpszVal,
02576                 pInfo->aParams[i].dwVal
02577                 ));
02578         }
02579     }
02580 }
02581
02582
02583 LONG
02584 PASCAL
02585 Epilog(
02586     PFUNC_INFO  pInfo,
02587     LONG        lResult
02588     )
02589 {
02590     DBGOUT((3, "%s: returning x%x", pInfo->lpszFuncName, lResult));
02591
02592     return lResult;
02593 }
02594
02595
02596 void
02597 CDECL
02598 DebugOutput(
02599     DWORD   dwDbgLevel,
02600     LPCSTR  lpszFormat,
02601     ...
02602     )
02603 {
02604     if (dwDbgLevel <= gdwDebugLevel)
02605     {
02606         char    buf[128] = "ATSP32: ";
02607         va_list ap;
02608
02609
02610         va_start(ap, lpszFormat);
02611
02612         _vsnwprintf(&buf[8], 119, lpszFormat, ap );
02613
02614
02615         strncat (buf, "\n", 127 - strlen(buf));
02616     buf[127] = '\0';
02617
02618         OutputDebugString (buf);
02619
02620         va_end(ap);
02621     }
02622 }
02623
02624 #endif
02625
02626
02627 LONG
02628 PASCAL
02629 ProviderInstall(
02630     char   *pszProviderName,
02631     BOOL    bNoMultipleInstance
02632     )
02633 {
02634     LONG    lResult;
02635
02636
02637     //
02638     // If only one installation instance of this provider is
02639     // allowed then we want to check the provider list to see
02640     // if the provider is already installed
02641     //
02642
02643     if (bNoMultipleInstance)
02644     {
02645         LONG                (WINAPI *pfnGetProviderList)();
02646         DWORD               dwTotalSize, i;
02647         HINSTANCE           hTapi32;
02648         LPLINEPROVIDERLIST  pProviderList;
02649         LPLINEPROVIDERENTRY pProviderEntry;
02650
02651
02652         //
02653         // Load Tapi32.dll & get a pointer to the lineGetProviderList
02654         // func.  We don't want to statically link because this module
02655         // plays the part of both core SP & UI DLL, and we don't want
02656         // to incur the performance hit of automatically loading
02657         // Tapi32.dll when running as a core SP within Tapisrv.exe's
02658         // context.
02659         //
02660
02661         if (!(hTapi32 = LoadLibrary ("tapi32.dll")))
02662         {
02663             DBGOUT((
02664                 1,
02665                 "LoadLibrary(tapi32.dll) failed, err=%d",
02666                 GetLastError()
02667                 ));
02668
02669             lResult = LINEERR_OPERATIONFAILED;
02670             goto ProviderInstall_return;
02671         }
02672
02673         if (!(pfnGetProviderList = (LONG (WINAPI *)())GetProcAddress(
02674                 hTapi32,
02675                 (LPCSTR) "lineGetProviderList"
02676                 )))
02677         {
02678             DBGOUT((
02679                 1,
02680                 "GetProcAddr(lineGetProviderList) failed, err=%d",
02681                 GetLastError()
02682                 ));
02683
02684             lResult = LINEERR_OPERATIONFAILED;
02685             goto ProviderInstall_unloadTapi32;
02686         }
02687
02688
02689         //
02690         // Loop until we get the full provider list
02691         //
02692
02693         dwTotalSize = sizeof (LINEPROVIDERLIST);
02694
02695         goto ProviderInstall_allocProviderList;
02696
02697 ProviderInstall_getProviderList:
02698
02699         if ((lResult = (*pfnGetProviderList)(0x00020000, pProviderList)) != 0)
02700         {
02701             goto ProviderInstall_freeProviderList;
02702         }
02703
02704         if (pProviderList->dwNeededSize > pProviderList->dwTotalSize)
02705         {
02706             dwTotalSize = pProviderList->dwNeededSize;
02707
02708             LocalFree (pProviderList);
02709
02710 ProviderInstall_allocProviderList:
02711
02712             if (!(pProviderList = LocalAlloc (LPTR, dwTotalSize)))
02713             {
02714                 lResult = LINEERR_NOMEM;
02715                 goto ProviderInstall_unloadTapi32;
02716             }
02717
02718             pProviderList->dwTotalSize = dwTotalSize;
02719
02720             goto ProviderInstall_getProviderList;
02721         }
02722
02723
02724         //
02725         // Inspect the provider list entries to see if this provider
02726         // is already installed
02727         //
02728
02729         pProviderEntry = (LPLINEPROVIDERENTRY) (((LPBYTE) pProviderList) +
02730             pProviderList->dwProviderListOffset);
02731
02732         for (i = 0; i < pProviderList->dwNumProviders; i++)
02733         {
02734             char   *pszInstalledProviderName = ((char *) pProviderList) +
02735                         pProviderEntry->dwProviderFilenameOffset,
02736                    *p;
02737
02738
02739             //
02740             // Make sure pszInstalledProviderName points at <filename>
02741             // and not <path>\filename by walking backeards thru the
02742             // string searching for last '\\'
02743             //
02744
02745             p = pszInstalledProviderName +
02746                 lstrlen (pszInstalledProviderName) - 1;
02747
02748             for (; *p != '\\'  &&  p != pszInstalledProviderName; p--);
02749
02750             pszInstalledProviderName =
02751                 (p == pszInstalledProviderName ? p : p + 1);
02752
02753             if (lstrcmpiA (pszInstalledProviderName, pszProviderName) == 0)
02754             {
02755                 lResult = LINEERR_NOMULTIPLEINSTANCE;
02756                 goto ProviderInstall_freeProviderList;
02757             }
02758
02759             pProviderEntry++;
02760         }
02761
02762
02763         //
02764         // If here then the provider isn't currently installed,
02765         // so do whatever configuration stuff is necessary and
02766         // indicate SUCCESS
02767         //
02768
02769         lResult = 0;
02770
02771
02772 ProviderInstall_freeProviderList:
02773
02774         LocalFree (pProviderList);
02775
02776 ProviderInstall_unloadTapi32:
02777
02778         FreeLibrary (hTapi32);
02779     }
02780     else
02781     {
02782         //
02783         // Do whatever configuration stuff is necessary and return SUCCESS
02784         //
02785
02786         lResult = 0;
02787     }
02788
02789 ProviderInstall_return:
02790
02791     return lResult;
02792 }
02793
02794
02795 void
02796 PASCAL
02797 DropActiveCall(
02798     PDRVLINE    pLine
02799     )
02800 {
02801     if (pLine->hComm)
02802     {
02803         DWORD       dwNumBytes, dwError;
02804         OVERLAPPED  overlapped;
02805
02806
02807         pLine->bDropInProgress = TRUE;
02808
02809         SetEvent (pLine->Overlapped.hEvent);
02810
02811         ZeroMemory (&overlapped, sizeof (OVERLAPPED));
02812
02813         overlapped.hEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
02814
02815         if (pLine->dwMediaMode != LINEMEDIAMODE_INTERACTIVEVOICE)
02816         {
02817             if (!WriteFile(
02818                     pLine->hComm,
02819                     "+++\r", 4,
02820                     &dwNumBytes,
02821                     &overlapped
02822                     ))
02823             {
02824                 if ((dwError = GetLastError()) == ERROR_IO_PENDING)
02825                 {
02826                     GetOverlappedResult(
02827                         pLine->hComm,
02828                         &overlapped,
02829                         &dwNumBytes,
02830                         TRUE
02831                         );
02832
02833                     ResetEvent (overlapped.hEvent);
02834                 }
02835                 else
02836                 {
02837                 }
02838             }
02839         }
02840
02841         if (!WriteFile (pLine->hComm, "ATH\r", 4, &dwNumBytes, &overlapped))
02842         {
02843             if ((dwError = GetLastError()) == ERROR_IO_PENDING)
02844             {
02845                 GetOverlappedResult(
02846                     pLine->hComm,
02847                     &overlapped,
02848                     &dwNumBytes,
02849                     TRUE
02850                     );
02851             }
02852             else
02853             {
02854             }
02855         }
02856
02857         CloseHandle (overlapped.hEvent);
02858         CloseHandle (pLine->hComm);
02859         pLine->hComm = NULL;
02860     }
02861 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/comp.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

comp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENT_
00016 #define _CLASS_CCOMPONENT_
00017
00018 #include "Globals.h"
00019
00020
00021 class CComponentData;                  // References
00022
00023
00024 //---------------------------------------------------------------------------
00025 class CComponent : public IComponent2
00026 {
00027   // Construction/Destruction
00028   public:
00029     CComponent( CComponentData* pParent );
00030     ~CComponent();
00031
00032
00033     /////////////////////////////////////////////////////////////////////////
00034     // Interface IUnknown
00035     //
00036     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00037     STDMETHODIMP_(ULONG) AddRef();
00038     STDMETHODIMP_(ULONG) Release();
00039
00040     /////////////////////////////////////////////////////////////////////////
00041     // Interface IComponent2
00042     //
00043     HRESULT STDMETHODCALLTYPE Initialize
00044             ( /*[in]*/ LPCONSOLE ipConsole );
00045
00046     HRESULT STDMETHODCALLTYPE Notify
00047             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00048               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00049               /*[in]*/ LPARAM nArg,
00050               /*[in]*/ LPARAM nParam
00051             );
00052
00053     HRESULT STDMETHODCALLTYPE Destroy
00054             ( /*[in]*/ MMC_COOKIE nCookie );
00055
00056     HRESULT STDMETHODCALLTYPE QueryDataObject
00057             ( /*[in] */ MMC_COOKIE nCookie,
00058               /*[in] */ DATA_OBJECT_TYPES nEnumType,
00059               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00060             );
00061
00062     HRESULT STDMETHODCALLTYPE GetResultViewType
00063             ( /*[in] */ MMC_COOKIE nCookie,
00064               /*[out]*/ LPOLESTR __RPC_FAR* ppViewType,
00065               /*[out]*/ long __RPC_FAR* pViewOptions
00066             );
00067
00068     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00069             ( /*[out][in]*/ RESULTDATAITEM __RPC_FAR* pResultDataItem );
00070
00071     HRESULT STDMETHODCALLTYPE CompareObjects
00072             ( /*[in]*/ LPDATAOBJECT lpDataObjectA,
00073               /*[in]*/ LPDATAOBJECT lpDataObjectB
00074             );
00075
00076     HRESULT STDMETHODCALLTYPE QueryDispatch
00077             ( /*[in] */  MMC_COOKIE  nCookie,
00078               /*[in] */  DATA_OBJECT_TYPES eType,
00079               /*[out]*/  LPDISPATCH* pipDispatch
00080             );
00081
00082     HRESULT STDMETHODCALLTYPE GetResultViewType2
00083             ( /*[in] */    MMC_COOKIE nCookie,
00084               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pRVTinfo
00085             );
00086
00087     HRESULT STDMETHODCALLTYPE RestoreResultView
00088             ( /*[in] */    MMC_COOKIE nCookie,
00089               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pResultViewType
00090             );
00091
00092
00093   // Private data
00094   private:
00095     ULONG            m_cRef;
00096     LPCONSOLE3       m_ipConsole;
00097     LPCONSOLEVERB    m_ipConsoleVerb;
00098     LPRESULTDATA     m_ipResultData;
00099     LPHEADERCTRL2    m_ipHeaderCtrl;
00100     CComponentData*  m_pComponentData;
00101     LONG_PTR         m_pScopeCookie;
00102
00103
00104   ///////////////////////////////////////////////////////////////////////////
00105   //  Handlers for notifications which are not delegated
00106   private:
00107     HRESULT  OnAddImages( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam );
00108
00109
00110   ///////////////////////////////////////////////////////////////////////////
00111   //  Public helpers
00112   public:
00113     HRESULT  GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00114     LONG_PTR GetScopeCookie()  { return m_pScopeCookie; }
00115
00116 };
00117
00118 #endif //_CLASS_CCOMPONENT_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/winhttp/retoptions/RetOptions.cpp Source File

  • Web
  • winhttp
  • retoptions

RetOptions.cpp

Go to the documentation of this file.
00001 /************************************************************
00002 *                                                           *
00003 * RetOptions.cpp                                            *
00004 *                                                           *
00005 * Copyright (c) Microsoft Corporation. All Rights Reserved. *
00006 *                                                           *
00007 ************************************************************/
00008
00009 #include <windows.h>
00010 #include <winhttp.h>
00011 #include <stdio.h>
00012
00013
00014 int main(int argc, char* argv[])
00015 {
00016     HINTERNET hSession;
00017     HINTERNET hConnect;
00018     HINTERNET hRequest;
00019     BOOL httpResult;
00020     DWORD data;
00021     DWORD dwSize = sizeof(DWORD);
00022     LPWSTR pwszURL;
00023
00024
00025     // Print a description of the sample.
00026     printf("This sample demonstrates the process for retrieving WinHTTP\n");
00027     printf("options programmatically from a C/C++ application. WinHTTP\n");
00028     printf("application programming interface (API) functions are used to\n");
00029     printf("determine the default connect time-out value and to find the\n");
00030     printf("current URL after an HTTP request is redirected.\n\n");
00031
00032     // Use WinHttpOpen to obtain a session handle.
00033     hSession = WinHttpOpen(  L"A WinHTTP Example Program/1.0",
00034                              WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
00035                              WINHTTP_NO_PROXY_NAME,
00036                              WINHTTP_NO_PROXY_BYPASS, 0);
00037
00038     // Use WinHttpQueryOption to retrieve Internet options.
00039     httpResult = WinHttpQueryOption( hSession, WINHTTP_OPTION_CONNECT_TIMEOUT,
00040                                      &data, &dwSize);
00041     if (httpResult)
00042         printf("Connect time-out:\t%u ms\n",data);
00043
00044     // Use WinHttpConnect to specify an HTTP server.
00045     hConnect = WinHttpConnect( hSession, L"msdn.microsoft.com",
00046                                INTERNET_DEFAULT_HTTP_PORT, 0);
00047
00048     // Open and Send a Request Header.
00049     hRequest = WinHttpOpenRequest( hConnect, L"GET",
00050                          L"/downloads/samples/internet/winhttp/retoptions/redirect.asp",
00051                          NULL, WINHTTP_NO_REFERER,
00052                          WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
00053     httpResult = WinHttpSendRequest( hRequest, WINHTTP_NO_ADDITIONAL_HEADERS,
00054                                      0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
00055     httpResult = WinHttpReceiveResponse( hRequest, NULL);
00056
00057     // Use WinHttpQueryOption again, this time to obtain a buffer size.
00058     httpResult = WinHttpQueryOption( hRequest, WINHTTP_OPTION_URL,
00059                                      NULL, &dwSize);
00060     pwszURL = new WCHAR[dwSize/sizeof(WCHAR)];
00061
00062     // Use WinHttpQueryOption to retrieve Internet options.
00063     httpResult = WinHttpQueryOption( hRequest, WINHTTP_OPTION_URL,
00064                                      (void *)pwszURL, &dwSize);
00065     printf("Redirected URL:\t\t%S\n",pwszURL);
00066
00067     // Free the allocated memory.
00068     delete [] pwszURL;
00069
00070     // When finished, release the hRequest handle.
00071     httpResult = WinHttpCloseHandle(hRequest);
00072     if (!httpResult)
00073         printf("Could not close the hRequest handle.\n");
00074
00075     // When finished, release the hConnect handle.
00076     httpResult = WinHttpCloseHandle(hConnect);
00077     if (!httpResult)
00078         printf("Could not close the hConnect handle.\n");
00079
00080     // When finished, release the hSession handle.
00081     httpResult = WinHttpCloseHandle(hSession);
00082     if (!httpResult)
00083         printf("Could not close the hSession handle.\n");
00084
00085
00086     return 0;
00087 }
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/GetImage/BitmapUtil.h Source File

  • Multimedia
  • wia
  • GetImage

BitmapUtil.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 --*/
00006
00007 #ifndef __BITMAPUTIL__
00008 #define __BITMAPUTIL__
00009
00010 namespace BitmapUtil
00011 {
00012
00013 //////////////////////////////////////////////////////////////////////////
00014 //
00015 // GetBitmapHeaderSize
00016 //
00017
00018 /*++
00019
00020     The GetBitmapHeaderSize function returns the size of the DIB header
00021
00022
00023     ULONG
00024     GetBitmapHeaderSize(
00025         LPCVOID pDib
00026     );
00027
00028 Parameters
00029
00030     pDib
00031         [in] Pointer to the in-memory DIB that can be represented by
00032         BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or BITMAPV5HEADER.
00033
00034
00035 Return Values
00036
00037     Returns the size of the DIB header in bytes or 0 if the header is
00038     not recognized.
00039
00040 --*/
00041
00042 ULONG
00043 GetBitmapHeaderSize(
00044     LPCVOID pDib
00045 );
00046
00047
00048 //////////////////////////////////////////////////////////////////////////
00049 //
00050 // GetBitmapLineWidthInBytes
00051 //
00052
00053 /*++
00054
00055     The GetBitmapLineWidthInBytes function returns the number of bytes
00056     in one scan line of the image
00057
00058
00059     ULONG
00060     GetBitmapLineWidthInBytes(
00061         ULONG nWidthInPixels,
00062         ULONG nBitCount
00063     );
00064
00065 Parameters
00066
00067     nWidthInPixels
00068         [in] Width of a scan line in pixels
00069
00070     nBitCount
00071         [in] Number of bits per pixel
00072
00073
00074 Return Values
00075
00076     Returns the size one scan line of the image in bytes.
00077
00078 --*/
00079
00080 ULONG
00081 GetBitmapLineWidthInBytes(
00082     ULONG nWidthInPixels,
00083     ULONG nBitCount
00084 );
00085
00086
00087 //////////////////////////////////////////////////////////////////////////
00088 //
00089 // GetBitmapDimensions
00090 //
00091
00092 /*++
00093
00094     The GetBitmapDimensions function returns the width and height of a DIB
00095
00096
00097     BOOL
00098     GetBitmapDimensions(
00099         LPCVOID  pDib,
00100         UINT    *pWidth,
00101         UINT    *pHeight
00102     );
00103
00104
00105 Parameters
00106
00107     pDib
00108         [in] Pointer to the in-memory DIB that can be represented by
00109         BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or BITMAPV5HEADER.
00110
00111     pWidth
00112         [out] Receives the width of the image
00113
00114     pHeight
00115         [out] Receives the height of the image
00116
00117
00118 Return Values
00119
00120     Returns TRUE if the header is recognized, FALSE otherwise.
00121
00122 --*/
00123
00124 BOOL
00125 GetBitmapDimensions(
00126     LPCVOID  pDib,
00127     UINT    *pWidth,
00128     UINT    *pHeight
00129 );
00130
00131
00132 //////////////////////////////////////////////////////////////////////////
00133 //
00134 // GetBitmapSize
00135 //
00136
00137 /*++
00138
00139     The GetBitmapSize function returns total size of the DIB. The size is
00140     the sum of the bitmap header, the color palette (if present), the color
00141     profile data (if present) and the pixel data.
00142
00143
00144     ULONG
00145     GetBitmapSize(
00146         LPCVOID pDib
00147     );
00148
00149
00150 Parameters
00151
00152     pDib
00153         [in] Pointer to the in-memory DIB that can be represented by
00154         BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or BITMAPV5HEADER.
00155
00156
00157 Return Values
00158
00159     Returns the size of the image in bytes or 0 if the header is not
00160     recognized.
00161
00162 --*/
00163
00164 ULONG
00165 GetBitmapSize(
00166     LPCVOID pDib
00167 );
00168
00169
00170 //////////////////////////////////////////////////////////////////////////
00171 //
00172 // GetBitmapOffsetBits
00173 //
00174
00175 /*++
00176
00177     The GetBitmapOffsetBits function returns the offset, in bytes, from the
00178     beginning of the DIB data block to the bitmap bits.
00179
00180
00181     ULONG
00182     GetBitmapOffsetBits(
00183         LPCVOID pDib
00184     );
00185
00186
00187 Parameters
00188
00189     pDib
00190         [in] Pointer to the in-memory DIB that can be represented by
00191         BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or BITMAPV5HEADER.
00192
00193
00194 Return Values
00195
00196     Returns the offset from the beginning of the DIB data block to the bitmap
00197     pixels in bytes or 0 if the header is not recognized.
00198
00199 --*/
00200
00201 ULONG
00202 GetBitmapOffsetBits(
00203     LPCVOID pDib
00204 );
00205
00206
00207 //////////////////////////////////////////////////////////////////////////
00208 //
00209 // FixBitmapHeight
00210 //
00211
00212 /*++
00213
00214     The FixBitmapHeight function calculates the height of the DIB if the
00215     height is not specified in the header and fills in the biSizeImage and
00216     biHeight fields of the header.
00217
00218
00219     BOOL
00220     FixBitmapHeight(
00221         PVOID pDib,
00222         ULONG nSize,
00223         BOOL  bTopDown
00224     );
00225
00226
00227 Parameters
00228
00229     pDib
00230         [in] Pointer to the in-memory DIB that can be represented by
00231         BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or BITMAPV5HEADER.
00232
00233     nSize
00234         [in] The total size of the image in bytes.
00235
00236     bTopDown
00237         [in] TRUE if the first scan line in the memory corresponds to the top
00238         line of the image, FALSE if it corresponds to the bottom line.
00239
00240
00241 Return Values
00242
00243     Returns TRUE if the header is recognized, FALSE otherwise.
00244
00245 --*/
00246
00247 BOOL
00248 FixBitmapHeight(
00249     PVOID pDib,
00250     ULONG nSize,
00251     BOOL  bTopDown
00252 );
00253
00254
00255 //////////////////////////////////////////////////////////////////////////
00256 //
00257 // FillBitmapFileHeader
00258 //
00259
00260 /*++
00261
00262     The FillBitmapFileHeader function fills in a BITMAPFILEHEADER structure
00263     according to the values specified in the DIB.
00264
00265
00266     BOOL
00267     FillBitmapFileHeader(
00268         LPCVOID           pDib,
00269         PBITMAPFILEHEADER pbmfh
00270     );
00271
00272
00273 Parameters
00274
00275     pDib
00276         [in] Pointer to the in-memory DIB that can be represented by
00277         BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or BITMAPV5HEADER.
00278
00279     pbmfh
00280         [out] Receives the BITMAPFILEHEADER structure filled with the
00281         values specified in the DIB
00282
00283
00284 Return Values
00285
00286     Returns TRUE if the header is recognized, FALSE otherwise.
00287
00288 --*/
00289
00290 BOOL
00291 FillBitmapFileHeader(
00292     LPCVOID           pDib,
00293     PBITMAPFILEHEADER pbmfh
00294 );
00295
00296 }; // namespace BitmapUtil
00297
00298 #endif //__BITMAPUTIL__
00299
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_node_tag Member List

This is the complete list of members for _node_tag, including all inherited members.
dwKey | _node_tag
pData | _node_tag
pNext | _node_tag
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPropSheetExtension Member List

This is the complete list of members for CPropSheetExtension, including all inherited members.
CPropSheetExtension() | CPropSheetExtension |
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle, LPDATAOBJECT lpIDataObject) | CPropSheetExtension | [virtual]
DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CPropSheetExtension | [private, static]
ExtractData(IDataObject *piDataObject, CLIPFORMAT cfClipFormat, BYTE *pbData, DWORD cbData) | CPropSheetExtension | [inline, private]
ExtractObjectTypeGUID(IDataObject *piDataObject, GUID *pguidObjectType) | CPropSheetExtension | [inline, private]
ExtractSnapInCLSID(IDataObject *piDataObject, CLSID *pclsidSnapin) | CPropSheetExtension | [inline, private]
ExtractString(IDataObject *piDataObject, CLIPFORMAT cfClipFormat, _TCHAR *pstr, DWORD cchMaxLength) | CPropSheetExtension | [inline, private]
m_cref | CPropSheetExtension | [private]
m_ppHandle | CPropSheetExtension | [private]
QueryInterface(REFIID riid, LPVOID *ppv) | CPropSheetExtension |
QueryPagesFor(LPDATAOBJECT lpDataObject) | CPropSheetExtension | [virtual]
s_cfDisplayName | CPropSheetExtension | [private, static]
s_cfNodeType | CPropSheetExtension | [private, static]
s_cfSnapInCLSID | CPropSheetExtension | [private, static]
STDMETHODIMP_(ULONG) AddRef() | CPropSheetExtension |
STDMETHODIMP_(ULONG) Release() | CPropSheetExtension |
~CPropSheetExtension() | CPropSheetExtension |
Generated on Wed Nov 13 2024 16:57:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IUPnPService_DimmingService_SCPDVtbl Member List

This is the complete list of members for IUPnPService_DimmingService_SCPDVtbl, including all inherited members.
cNames | IUPnPService_DimmingService_SCPDVtbl
dispIdMember | IUPnPService_DimmingService_SCPDVtbl
dLevel | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Power)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_dimLevel)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *PowerOn)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *PowerOff)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetPowerValue)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *SetDimLevel)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetDimLevel)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetConfigDetails)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Power)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_dimLevel)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *PowerOn)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *PowerOff)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetPowerValue)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *SetDimLevel)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetDimLevel)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetConfigDetails)(IUPnPService_DimmingService_SCPD __RPC_FAR *This | IUPnPService_DimmingService_SCPDVtbl
iTInfo | IUPnPService_DimmingService_SCPDVtbl
lcid | IUPnPService_DimmingService_SCPDVtbl
lcid | IUPnPService_DimmingService_SCPDVtbl
lcid | IUPnPService_DimmingService_SCPDVtbl
pctinfo | IUPnPService_DimmingService_SCPDVtbl
pdimLevel | IUPnPService_DimmingService_SCPDVtbl
pDispParams | IUPnPService_DimmingService_SCPDVtbl
pdLevel | IUPnPService_DimmingService_SCPDVtbl
pdLevel | IUPnPService_DimmingService_SCPDVtbl
pExcepInfo | IUPnPService_DimmingService_SCPDVtbl
pPower | IUPnPService_DimmingService_SCPDVtbl
ppowerVal | IUPnPService_DimmingService_SCPDVtbl
ppowerVall | IUPnPService_DimmingService_SCPDVtbl
ppTInfo | IUPnPService_DimmingService_SCPDVtbl
ppvObject | IUPnPService_DimmingService_SCPDVtbl
puArgErr | IUPnPService_DimmingService_SCPDVtbl
pVarResult | IUPnPService_DimmingService_SCPDVtbl
rgDispId | IUPnPService_DimmingService_SCPDVtbl
rgszNames | IUPnPService_DimmingService_SCPDVtbl
riid | IUPnPService_DimmingService_SCPDVtbl
riid | IUPnPService_DimmingService_SCPDVtbl
riid | IUPnPService_DimmingService_SCPDVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(IUPnPService_DimmingService_SCPD __RPC_FAR *This) | IUPnPService_DimmingService_SCPDVtbl
wFlags | IUPnPService_DimmingService_SCPDVtbl
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/baseobj.h Source File

  • Dataaccess
  • oledb
  • sampprov

baseobj.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 //--------------------------------------------------------------------
00003 // Microsoft OLE DB Sample Provider
00004 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00005 //
00006 // @doc
00007 //
00008 // @module BASEOBJ.H | Base object for CCommand,CRowset, and CSession
00009 // definitions
00010 //
00011 //
00012
00013
00014 #ifndef __BASEOBJ_H__
00015 #define __BASEOBJ_H__
00016
00017 // Used to distinguish behavior based on object type.
00018 // (i.e. cast a void* to either CCommand,CRowset,or CSession)
00019 enum EBaseObjectType
00020 {
00021   BOT_UNDEFINED,
00022   BOT_DATASOURCE,
00023   BOT_COMMAND,
00024   BOT_ROWSET,
00025   BOT_SESSION,
00026   BOT_ROW,
00027   BOT_STREAM,
00028   BOT_BINDER,
00029 };
00030
00031
00032 //-----------------------------------------------------------------------------
00033 // Classes
00034 //-----------------------------------------------------------------------------
00035
00036 //----------------------------------------------------------------------------
00037 // @class CBaseObj | Base Object for CCommand  and CRowset
00038 //
00039 //
00040
00041 class CBaseObj : public IUnknown    //@base public | IUnknown
00042 {
00043 private: //@access Private Data Members
00044
00045   //@cmember Base Object Type
00046   EBaseObjectType   m_BaseObjectType;
00047
00048 protected: //@access Protected Member Functions
00049
00050   //@cmember Controlling IUnknown
00051   LPUNKNOWN     m_pUnkOuter;
00052
00053   //@ Constructor
00054   CBaseObj(EBaseObjectType botVal);
00055
00056 public: //@access Public Member Functions
00057   // @cmember DTOR
00058   virtual ~CBaseObj();
00059
00060   // @cmember Get the base object type
00061   EBaseObjectType GetBaseObjectType()
00062   {
00063     return m_BaseObjectType;
00064   }
00065
00066   //@cmember Get the outer unknown.
00067   inline IUnknown * GetOuterUnknown()
00068   {
00069     return m_pUnkOuter;
00070   }
00071 };
00072
00073
00074 #endif  // __BASEOBJ_H__
00075
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/HiPerfClient/SamplCli.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • HiPerfClient

SamplCli.Cpp

Go to the documentation of this file.
00001 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00002 ///////////////////////////////////////////////////////////////////
00003 //
00004 //  SamplCli.cpp : Refresher client implementation file
00005 //
00006 //  RefTest is a simple WMI client that demonstrates how to use a
00007 //  high performance refresher.  It will add a number of
00008 //  Win32_BasicHiPerf instances as well as a single Win32_BasicHiPerf
00009 //  enumerator.  The optional command line argument specifies a remote
00010 //  WMI connection.  The default is the local machine.  The syntax
00011 //  is as follows:
00012 //
00013 //  refreshertest.exe <server name>
00014 //
00015 //    server name: the name of the remote machine where the provider
00016 //    id located.
00017 //
00018 //  Notes:
00019 //
00020 //    1) Ensure that Win32_BasicHiPerf is properly set up.  See the
00021 //      BasicHiPerf\BasicHiPerf.html file.
00022 //
00023 //    2) Error handling has been minimized in the sample code for
00024 //      the purpose of clarity.
00025 //
00026 ///////////////////////////////////////////////////////////////////
00027
00028 #define _WIN32_WINNT 0x0400
00029
00030 #define UNICODE
00031
00032 #include <windows.h>
00033 #include <stdio.h>
00034 #include <wbemcli.h>
00035 #include <strsafe.h>
00036
00037 #include "RefClint.h"
00038
00039 void RefreshLoop();
00040
00041 ///////////////////////////////////////////////////////////////////
00042 //
00043 //  Globals and constants
00044 //
00045 ///////////////////////////////////////////////////////////////////
00046
00047 IWbemServices*  g_pNameSpace = NULL;    // A WMI namespace pointer
00048
00049 ///////////////////////////////////////////////////////////////////
00050 //
00051 //  Code
00052 //
00053 ///////////////////////////////////////////////////////////////////
00054
00055 int main( int argc, char *argv[] )
00056 ///////////////////////////////////////////////////////////////////
00057 //
00058 //  Entry point function to exercise IWbemObjectInternals interface.
00059 //
00060 ///////////////////////////////////////////////////////////////////
00061 {
00062   HRESULT hRes = WBEM_NO_ERROR;
00063
00064   IWbemLocator* pWbemLocator = NULL;
00065
00066   BSTR  bstrNameSpace = NULL;
00067
00068   WCHAR wcsSvrName[MAX_PATH + 1];
00069   StringCbCopyW(wcsSvrName, sizeof(wcsSvrName), L"." );
00070
00071   // Initialize COM
00072   // ==============
00073
00074   hRes = CoInitializeEx( NULL, COINIT_MULTITHREADED );
00075   if ( FAILED( hRes ) )
00076     return 0;
00077
00078   // Setup default security parameters
00079   // =================================
00080   //  NOTE:
00081   //  When using asynchronous WMI API's remotely in an environment where the "Local System" account
00082   //  has no network identity (such as non-Kerberos domains), the authentication level of
00083   //  RPC_C_AUTHN_LEVEL_NONE is needed. However, lowering the authentication level to
00084   //  RPC_C_AUTHN_LEVEL_NONE makes your application less secure. It is wise to
00085   //  use semi-synchronous API's for accessing WMI data and events instead of the asynchronous ones.
00086
00087   hRes = CoInitializeSecurity( NULL, -1, NULL, NULL,
00088                       RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
00089                       RPC_C_IMP_LEVEL_IMPERSONATE,
00090                       NULL,
00091                       EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
00092                       NULL );
00093   if ( FAILED( hRes ) )
00094     goto cleanup;
00095
00096
00097 // Initialize the environment based on the command line arguments
00098 // ==============================================================
00099
00100   if ( argc >= 2 )
00101   {
00102     // The remote server name
00103     // ======================
00104     memset(wcsSvrName, NULL, sizeof(wcsSvrName));
00105
00106     MultiByteToWideChar( CP_ACP, 0L, argv[1], -1, wcsSvrName, sizeof(wcsSvrName)/sizeof (WCHAR) - 1);
00107   }
00108
00109
00110 // Attach to WinMgmt
00111 // =================
00112
00113   // Get the local locator object
00114   // ============================
00115
00116   hRes = CoCreateInstance( CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (void**) &pWbemLocator );
00117   if (FAILED(hRes))
00118     goto cleanup;
00119
00120   // Connect to the desired namespace
00121   // ================================
00122
00123   WCHAR wszNameSpace[MAX_PATH + 20];
00124   StringCbPrintfW(wszNameSpace, sizeof(wszNameSpace), L"\\\\%s\\root\\cimv2", wcsSvrName );
00125
00126   bstrNameSpace = SysAllocString( wszNameSpace );
00127   if (bstrNameSpace == NULL)
00128     goto cleanup;
00129
00130   hRes = pWbemLocator->ConnectServer( bstrNameSpace,  // NameSpace Name
00131                     NULL,     // UserName
00132                     NULL,     // Password
00133                     NULL,     // Locale
00134                     0L,       // Security Flags
00135                     NULL,     // Authority
00136                     NULL,     // Wbem Context
00137                     &g_pNameSpace // Namespace
00138                     );
00139
00140   if ( FAILED( hRes ) )
00141     goto cleanup;
00142
00143   // Start the refresh loop
00144   // ======================
00145
00146   RefreshLoop();
00147
00148
00149 // Cleanup
00150 // =======
00151 cleanup:
00152   SysFreeString( bstrNameSpace );
00153
00154   if ( NULL != g_pNameSpace )
00155     g_pNameSpace->Release();
00156
00157   if ( NULL != pWbemLocator )
00158     pWbemLocator->Release();
00159
00160   CoUninitialize();
00161
00162   return 0;
00163 }
00164
00165 void RefreshLoop()
00166 ///////////////////////////////////////////////////////////////////
00167 //
00168 //  RefreshLoop will create a new refresher and configure it with
00169 //  a set of instances and an enumerator.  It will then enter a loop
00170 //  which refreshes and displays the counter data.  Once it has
00171 //  completed the loop, the members of the refresher are removed.
00172 //
00173 ///////////////////////////////////////////////////////////////////
00174 {
00175   HRESULT   hRes    = WBEM_NO_ERROR;
00176   long    lLoopCount  = 0;    // Refresh loop counter
00177   CRefClient  aRefClient;
00178
00179 // Initialize our container class
00180 // ==============================
00181
00182   hRes = aRefClient.Initialize(g_pNameSpace);
00183   if (FAILED(hRes))
00184     goto cleanup;
00185
00186
00187 // Add items to the refresher
00188 // ==========================
00189
00190   // Add an enumerator
00191   // =================
00192
00193   hRes = aRefClient.AddEnum();
00194   if ( FAILED( hRes ) )
00195     goto cleanup;
00196
00197   // Add objects
00198   // ===========
00199
00200   hRes = aRefClient.AddObjects();
00201   if ( FAILED( hRes ) )
00202     goto cleanup;
00203
00204
00205 // Begin the refreshing loop
00206 // =========================
00207
00208   for ( lLoopCount = 0; lLoopCount < cdwNumReps; lLoopCount++ )
00209   {
00210     // Refresh!!
00211     // =========
00212
00213     hRes = aRefClient.Refresh();
00214     if ( FAILED ( hRes ) )
00215     {
00216       printf("Refresh failed: 0x%X\n", hRes);
00217       goto cleanup;
00218     }
00219
00220     printf( "Refresh number: %d\n", lLoopCount );
00221
00222     aRefClient.ShowObjectData();
00223     aRefClient.ShowEnumeratorData();
00224
00225     printf( "\n" );
00226
00227   } // FOR Refresh
00228
00229 // Cleanup
00230 // =======
00231 cleanup:
00232
00233   aRefClient.RemoveEnum();
00234   aRefClient.RemoveObjects();
00235
00236   return;
00237 }
00238
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/WMIDiskPerf/WMIDiskPerf.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • WMIDiskPerf

WMIDiskPerf.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00006 //
00007 //  File:  WMIDiskPerf.cpp
00008 //
00009 //  Description:
00010 //    Connects to the WMI server and calls DiskPerfDetails( ) to
00011 //    retrieve partition properties.
00012 //
00013 //  Part of : WMIDiskPerf
00014 //
00015 //  History:
00016 //
00017 //***************************************************************************
00018
00019
00020 #include <wbemidl.h>
00021 #include <lmcons.h>
00022 #include <stdio.h>
00023 #include <strsafe.h>
00024
00025
00026 void      DiskPerfDetails( IWbemServices * pIWbemServices );
00027 BOOL      InitSecurity( void );
00028 DWORD WINAPI  WaitThread( HANDLE hWait );
00029
00030
00031 //==============================================================================
00032 //  main( )
00033 //==============================================================================
00034 int main( int argc, char **argv )
00035 {
00036   HRESULT hr;
00037   DWORD ThreadId, dwLen = MAX_COMPUTERNAME_LENGTH + 1;
00038   HANDLE  hWait, hThread;
00039   BSTR  pNamespace;
00040   TCHAR szSysName[MAX_COMPUTERNAME_LENGTH + 3];
00041
00042   IWbemLocator  *pIWbemLocator  = NULL;
00043   IWbemServices *pIWbemServices = NULL;
00044
00045   if ( !SUCCEEDED( CoInitialize( NULL ) ) || !InitSecurity( ) )
00046   {
00047     printf( "COM stuff is hosed!\r\n" );
00048
00049     return 0;
00050   }
00051
00052   // Create an instance of the WbemLocator interface.
00053   if ( CoCreateInstance( CLSID_WbemLocator,
00054                          NULL,
00055                          CLSCTX_INPROC_SERVER,
00056                          IID_IWbemLocator,
00057                          (LPVOID *) &pIWbemLocator ) == S_OK )
00058   {
00059
00060     StringCbCopy(szSysName, sizeof(szSysName), "\\\\");
00061     BOOL bRes = GetComputerName( szSysName + 2, &dwLen );
00062     if (!bRes)
00063     {
00064       printf("Could not get local machine name.\n");
00065       CoUninitialize();
00066       return 0;
00067     }
00068     pNamespace = SysAllocString( L"root\\WMI" );
00069     if (!pNamespace)
00070     {
00071       printf("Out of memory\n");
00072       CoUninitialize();
00073       return 0;
00074     }
00075     // Display connect message and start wait feedback thread
00076     printf( "Connecting to %s WMI server at ", szSysName );
00077     wprintf( L"%s...", pNamespace );
00078
00079     // make a wait event and kick off wait thread
00080     hWait = CreateEvent( NULL, TRUE, FALSE, NULL );
00081     hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) WaitThread, hWait, 0, &ThreadId );
00082
00083     // connect and get the IWbemServices pointer
00084     hr = pIWbemLocator->ConnectServer( pNamespace,
00085                                        NULL,
00086                                        NULL,
00087                                        0L,
00088                                        0L,
00089                                        NULL,
00090                                        NULL,
00091                                        &pIWbemServices );
00092
00093     // kill wait feedback thread
00094     SetEvent( hWait );
00095     // make sure thread is gone
00096     WaitForSingleObject( hThread, INFINITE );
00097     CloseHandle( hWait );
00098     SysFreeString( pNamespace );
00099
00100     // See what WBEM/WMI says about DiskPerf
00101     if ( hr == WBEM_NO_ERROR )
00102     {
00103       printf( "\nConnected with %s\n", szSysName );
00104
00105       // done with locator object
00106       pIWbemLocator->Release( );
00107
00108
00109       // go enumerate diskperf instances...
00110       DiskPerfDetails( pIWbemServices );
00111       pIWbemServices->Release( );
00112     }
00113     else
00114     {
00115       printf( "\nFailed to connect with %s, Error: 0x%8lX\n", szSysName, hr );
00116     }
00117   }
00118   else
00119   {
00120     printf( "WMI services not present or unavailable!\n" );
00121   }
00122
00123   CoUninitialize( );
00124
00125   return 0;
00126 }
00127
00128
00129 //==============================================================================
00130 //  WaitThread( HANDLE hWait )
00131 //==============================================================================
00132 DWORD WINAPI WaitThread( HANDLE hWait )
00133 {
00134   while ( WaitForSingleObject( hWait, 300 ) == WAIT_TIMEOUT )
00135   {
00136     printf(".");
00137   }
00138   printf("\n");
00139
00140   return 0;
00141 }
00142
00143
00144 //==============================================================================
00145 //  InitSecurity( void )
00146 //  Initialize COM security for DCOM services.
00147 //==============================================================================
00148 BOOL InitSecurity( void )
00149 {
00150   // Adjust the security to allow client impersonation.
00151   HRESULT hres = CoInitializeSecurity
00152                 ( NULL, -1, NULL, NULL,
00153                 RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
00154                 RPC_C_IMP_LEVEL_IMPERSONATE,
00155                 NULL,
00156                 EOAC_SECURE_REFS,
00157                 NULL );
00158
00159   return SUCCEEDED( hres );
00160 }
00161
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMFT/Msg.Cpp Source File

  • Web
  • NetMeeting
  • NMFT

Msg.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMFT.EXE
00003 //  File:       MSG.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 typedef LRESULT (*PFNMSG)(HWND, UINT, WPARAM, LPARAM);
00018
00019 // This structure maps messages to message handling functions.
00020 typedef struct _MSD
00021 {
00022   UINT   uMsg;
00023   PFNMSG pfnmsg;
00024 } MSD;                 // MeSsage Dispatch structure
00025 typedef MSD * LPMSD;
00026
00027
00028 VOID CmdClose(void)
00029 {
00030   DestroyWindow(ghwndMain);
00031 }
00032
00033
00034 //****************************************************************************
00035 //
00036 // LRESULT MsgDestroy(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00037 //
00038 // Handle a WM_DESTROY message
00039 //
00040 //****************************************************************************
00041
00042 LRESULT MsgDestroy(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00043 {
00044   PostQuitMessage(0);
00045   return 0;
00046 }
00047
00048
00049 //****************************************************************************
00050 //
00051 // LRESULT MsgClose(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00052 //
00053 // Handle a WM_CLOSE message
00054 //
00055 //****************************************************************************
00056
00057 LRESULT MsgClose(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00058 {
00059   CmdClose();
00060   return 0;
00061 }
00062
00063
00064 //****************************************************************************
00065 //
00066 // LRESULT MsgCmdMain(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00067 //
00068 //****************************************************************************
00069
00070 LRESULT MsgCmdMain(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00071 {
00072   WORD wCmd = GET_WM_COMMAND_ID(wParam, lParam);
00073   switch (wCmd)
00074     {
00075   case IDCANCEL:
00076   {
00077     if (NULL != g_pFt)
00078     {
00079       g_pFt->Cancel();
00080       CmdClose();
00081     }
00082     break;
00083   }
00084
00085   default:
00086     break;
00087     } /* switch wCmd */
00088
00089   return 0L;
00090 }
00091
00092
00093
00094 ////////////////////////////////////////////////////////////////////////////
00095 // Main window message table definition.
00096 static MSD _rgmsdMain[] =
00097 {
00098   {WM_COMMAND,       MsgCmdMain},
00099   {WM_DESTROY,       MsgDestroy},
00100   {WM_CLOSE,         MsgClose},
00101
00102   {0, NULL}  // MUST be the last entry
00103 };
00104
00105
00106 //****************************************************************************
00107 //
00108 // LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00109 //
00110 //****************************************************************************
00111
00112 LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00113 {
00114   for (LPMSD lpmsd = _rgmsdMain; 0 != lpmsd->uMsg; lpmsd++)
00115   {
00116     if (lpmsd->uMsg == uMsg)
00117     {
00118       return lpmsd->pfnmsg(hwnd, uMsg, wParam, lParam);
00119     }
00120   }
00121
00122   return DefWindowProc(hwnd, uMsg, wParam, lParam);
00123 }
00124
00125
00126
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWorkerThread Member List

This is the complete list of members for CWorkerThread, including all inherited members.
CWorkerThread() | CWorkerThread | [inline]
Initialize() | CWorkerThread |
m_hThreadHandle | CWorkerThread | [private]
m_nThreadID | CWorkerThread | [private]
PostMessage(UINT Msg, WPARAM wParam, LPARAM lParam) | CWorkerThread |
Shutdown() | CWorkerThread |
ThreadFunction(void *) | CWorkerThread | [protected, static]
~CWorkerThread() | CWorkerThread | [virtual]
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcOleDB/oledbcomponent.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcOleDB

oledbcomponent.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: OLEDBComponent.h
00003 //
00004 // Description: Declaration of the COLEDBComponent
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022
00023
00024 #ifndef __OLEDBCOMPONENT_H_
00025 #define __OLEDBCOMPONENT_H_
00026 #include "resource.h"       // main symbols
00027 #include <comsvcs.h>
00028
00029 #define UNICODE
00030 #define DBINITCONSTANTS // Initialize OLE constants...
00031 #define INITGUID        // ...once in each app
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 // COLEDBComponent
00035 class ATL_NO_VTABLE COLEDBComponent :
00036   public CComObjectRootEx<CComSingleThreadModel>,
00037   public CComCoClass<COLEDBComponent, &CLSID_OLEDBComponent>,
00038   public IObjectControl,
00039   //public IOLEDBComponent
00040   public IDispatchImpl<IOLEDBComponent, &IID_IOLEDBComponent, &LIBID_OLEDBKBLib>
00041
00042   {
00043 public:
00044   COLEDBComponent()
00045   {
00046   }
00047
00048 DECLARE_REGISTRY_RESOURCEID(IDR_OLEDBCOMPONENT)
00049 DECLARE_NOT_AGGREGATABLE(COLEDBComponent)
00050
00051 BEGIN_COM_MAP(COLEDBComponent)
00052   COM_INTERFACE_ENTRY(IOLEDBComponent)
00053   COM_INTERFACE_ENTRY(IObjectControl)
00054 END_COM_MAP()
00055
00056 // IObjectControl
00057 public:
00058   STDMETHOD(Activate)();
00059   STDMETHOD_(BOOL, CanBePooled)();
00060   STDMETHOD_(void, Deactivate)();
00061
00062   CComPtr<IObjectContext> m_spObjectContext;
00063
00064 // IOLEDBComponent
00065 public:
00066   STDMETHOD(SimpleQuery)(/*[in, out]*/ BSTR * returnval);
00067 };
00068
00069 #endif //__OLEDBCOMPONENT_H_
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/RPCssm/RPCssmp.c Source File

  • NetDS
  • RPC
  • RPCssm

RPCssmp.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         rpcssm Example
00005
00006     FILE:       rpcssmp.c
00007
00008     PURPOSE:    Remote procedures used in server application rpcssms
00009
00010     FUNCTIONS:  InOutList() - Adds new nodes to the list.
00011
00012     COMMENTS:   This distributed application uses the rpcssm package.
00013
00014 ****************************************************************************/
00015
00016 #include <stdlib.h>
00017 #include <stdio.h>
00018 #include <string.h>
00019 #include "rpcssm.h"    // header file generated by MIDL compiler
00020
00021 void AllocateSmList( PBOX * ppBox, short sListSize );
00022 void InitList( PBOX  pBox, long lStartValue );
00023 void PrintList( PBOX pBox );
00024
00025 void * pvPersistent    = NULL;
00026 void * pvNonPersistent = NULL;
00027
00028 void
00029 InOutList( PBOX * ppBox )
00030 {
00031     /* As this routine executes in the enabled memory environment,
00032        a convienient way to allocate a non-persistent memory
00033        is to use RpcSmAllocate or RpcSsAllocate.
00034     */
00035
00036     if ( ppBox) {
00037
00038         PBOX p = *ppBox;
00039         while ( p->next )
00040             p = p->next;
00041
00042         AllocateSmList( & p->next, 2 );
00043     }
00044     else {
00045         AllocateSmList( ppBox, 5 );
00046     }
00047
00048     InitList( *ppBox, 0x98760000 );
00049     PrintList( *ppBox );
00050
00051     /* To allocate a memory to be available after the call, means other
00052        than RpcS*Allocate with default allocators should be used.
00053     */
00054
00055     if ( pvPersistent == NULL )
00056         {
00057         pvPersistent = malloc(100); /* or midl_user_allocate(100) */
00058         }
00059
00060     pvNonPersistent = RpcSsAllocate( 100 );
00061 }
00062
00063 /* The Shutdown procedure tells the server to stop listening */
00064 /* for client requests.                                      */
00065 void Shutdown(void)
00066 {
00067     RPC_STATUS status;
00068
00069     /* Freeing the persistent memory */
00070
00071     if ( pvPersistent )
00072         free( pvPersistent );
00073
00074     printf("Calling RpcMgmtStopServerListening\n");
00075     status = RpcMgmtStopServerListening(NULL);
00076     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00077     if (status) {
00078         exit(status);
00079     }
00080
00081     printf("Calling RpcServerUnregisterIf\n");
00082     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00083     printf("RpcServerUnregisterIf returned 0x%x\n", status);
00084     if (status) {
00085         exit(status);
00086     }
00087 }
00088
00089 //=====================================================================
00090 //        List allocation/deallocation routines
00091 //=====================================================================
00092
00093 void
00094 AllocateSmList( PBOX * ppBox, short sListSize)
00095 {
00096     PBOX    pBox, head;
00097     int     i = 0;
00098
00099     //.. Allocate a list of boxes, if needed (when *ppBox==NULL).
00100
00101     if ( *ppBox == NULL ) {
00102
00103         RPC_STATUS status;
00104
00105         head = 0;
00106         for (i = 0; i < sListSize; i++)
00107         {
00108             pBox = (PBOX) RpcSmAllocate( sizeof(LBOX), &status);
00109             if ( status != RPC_S_OK )
00110             {
00111                 printf("AllocateList FAILED: not enough memory\n");
00112                 break;
00113             }
00114             pBox->next = head;
00115             head = pBox;
00116         }
00117         *ppBox = head;
00118     }
00119     printf("%d nodes allocated.\n", i);
00120 }
00121
00122 //=====================================================================
00123 //        Initialization and pprint routines
00124 //=====================================================================
00125
00126 void  InitList( PBOX  pBox, long lStartValue )
00127 {
00128     int i = 0;
00129
00130     while( pBox ) {
00131         pBox->data = lStartValue + ++i;
00132         pBox = pBox->next;
00133     }
00134     printf("%d nodes inited.\n", i);
00135 }
00136
00137 // --------------------------------------------------------------------
00138
00139 void
00140 PrintList( PBOX  pBox )
00141 {
00142     int i = 0;
00143
00144
00145     while( pBox ) {
00146
00147         if ( (i % 4) != 0 )
00148             printf("  data[%d]= %lx", i, pBox->data);
00149         else
00150             printf("\n  data[%d]= %lx", i, pBox->data);
00151         pBox = pBox->next;
00152         i++;
00153     }
00154     printf("\n" );
00155 }
00156
00157
00158 /* end file rpcssmp.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/funcprov.cpp Source File

  • WinUI
  • tsfapp

funcprov.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation. All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          FuncProv.cpp
00013
00014    Description:   ITfFunctionProvider implementation.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019   #include statements
00020 **************************************************************************/
00021
00022 #include "TSFEdit.h"
00023 #include "globals.h"
00024
00025 /**************************************************************************
00026
00027   CTSFEditWnd::GetType()
00028
00029 **************************************************************************/
00030
00031 STDMETHODIMP CTSFEditWnd::GetType(GUID *pguid)
00032 {
00033     *pguid = GUID_NULL;
00034
00035     return S_OK;
00036 }
00037
00038 /**************************************************************************
00039
00040   CTSFEditWnd::GetDescription()
00041
00042 **************************************************************************/
00043
00044 STDMETHODIMP CTSFEditWnd::GetDescription(BSTR *pbstrDesc)
00045 {
00046     *pbstrDesc = SysAllocString(L"TSFApp Function Provider");
00047
00048     return *pbstrDesc ? S_OK : E_OUTOFMEMORY;
00049 }
00050
00051 /**************************************************************************
00052
00053   CTSFEditWnd::GetFunction()
00054
00055 **************************************************************************/
00056
00057 STDMETHODIMP CTSFEditWnd::GetFunction(REFGUID rguid, REFIID riid, IUnknown **ppunk)
00058 {
00059     HRESULT hr = E_NOINTERFACE;
00060
00061     *ppunk = NULL;
00062
00063     if(IsEqualGUID(rguid, GUID_NULL))
00064     {
00065     }
00066
00067     return hr;
00068 }
00069
00070 /**************************************************************************
00071
00072   CTSFEditWnd::_InitFunctionProvider()
00073
00074 **************************************************************************/
00075
00076 BOOL CTSFEditWnd::_InitFunctionProvider()
00077 {
00078     HRESULT hr = E_FAIL;
00079     ITfSourceSingle *pSourceSingle;
00080
00081     hr = m_pThreadMgr->QueryInterface(&pSourceSingle);
00082     if(SUCCEEDED(hr))
00083     {
00084         hr = pSourceSingle->AdviseSingleSink(m_tfClientID, IID_ITfFunctionProvider, (ITfFunctionProvider*)this);
00085
00086         pSourceSingle->Release();
00087     }
00088
00089     return SUCCEEDED(hr);
00090 }
00091
00092 /**************************************************************************
00093
00094   CTSFEditWnd::_UninitFunctionProvider()
00095
00096 **************************************************************************/
00097
00098 void CTSFEditWnd::_UninitFunctionProvider()
00099 {
00100     HRESULT hr;
00101     ITfSourceSingle *pSourceSingle;
00102
00103     hr = m_pThreadMgr->QueryInterface(&pSourceSingle);
00104     if(SUCCEEDED(hr))
00105     {
00106         hr = pSourceSingle->UnadviseSingleSink(m_tfClientID, IID_ITfFunctionProvider);
00107
00108         pSourceSingle->Release();
00109     }
00110 }
00111
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIRowsetInfo Member List

This is the complete list of members for CImpIRowsetInfo, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetInfo) | CImpIRowsetInfo
GetProperties(const ULONG cPropertySets, const DBPROPIDSET rgPropertySets[], ULONG *pcProperties, DBPROPSET **prgProperties) | CImpIRowsetInfo
GetReferencedRowset(DBORDINAL iOrdinal, REFIID rrid, IUnknown **ppReferencedRowset) | CImpIRowsetInfo
GetSpecification(REFIID, IUnknown **) | CImpIRowsetInfo
Generated on Wed Nov 13 2024 16:56:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

vcacct::IAccount Member List

This is the complete list of members for vcacct::IAccount, including all inherited members.
iid | vcacct::IAccount | [static]
Post(int lAccount, int lAmount) | vcacct::IAccount |
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/COMPlusWizard/VJ/COMPlus.java Source File

  • Com
  • Tools
  • COMPlusWizard
  • VJ

COMPlus.java

Go to the documentation of this file.
00001 /**
00002  * This class is designed to be packaged with a COM DLL output format.
00003  * The class has no standard entry points, other than the constructor.
00004  * Public methods will be exposed as methods on the default COM interface.
00005  * @com.register ( clsid=%GUID1%, typelib=%GUID2% )
00006  */
00007 public class COMPlus
00008 {
00009   // TODO: Add additional methods and code here
00010
00011   // Sample method which uses the COM+ Server Context.
00012   // See the Microsoft COM+ documentation for more information
00013   // about use the Context class and creating COM+ components.
00014   public void Method1()
00015   {
00016     boolean bSuccess = false;
00017     try {
00018       // TODO: Add your method code here.  If successful, set bSuccess
00019         // to true
00020       bSuccess = true;
00021       return;
00022     }
00023
00024     // Most methods in COM+ objects should call setComplete if successful,
00025     // or setAbort if not. This causes this object to be deactivated and
00026     // lose state after the return of this function.  See the COM+
00027     // documentation for more information.
00028     finally {
00029       if (bSuccess)
00030         Context.setComplete();
00031       else
00032         Context.setAbort();
00033     }
00034   }
00035
00036   /**
00037    * NOTE: To add auto-registration code, refer to the documentation
00038    * on the following method
00039    *   public static void onCOMRegister(boolean unRegister) {}
00040    */
00041 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/globaldev/global.c Source File

  • WinUI
  • GlobalDev
  • globaldev

global.c

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 // PARTICULAR PURPOSE.
00007 //
00008 // Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 // Purpose:
00011 // This application demonstrates the different aspects of software globalization:
00012 //
00013 //      A single executable with world-wide functionality (fully Unicode enabled
00014 //      for Windows 2000 and Windows XP).
00015 //
00016 //      - Locale independency by using Windows NLS APIs to display data (dates,
00017 //      numbers, time, etc.) within a user's desired format.
00018 //
00019 //      - Multilingual editing using standard edit controls.
00020 //
00021 //      - Multilingual input locales within edit control fields.
00022 //
00023 //      - Font selection and their affect on displayed data.
00024 //
00025 //      - Multilingual user interface and satellite DLLs.
00026 //
00027 // Written by Houman Pournasseh
00028 //
00029 ///////////////////////////////////////////////////////////////////////////////////////////
00030
00031
00032
00033 ///////////////////////////////////////////////////////////////////////////////////////////
00034 //
00035 //   Module:    GLOBAL.C
00036 //
00037 //   Description:   Main function and entry point of Globaldev application.
00038 //
00039 //   Functions:
00040 //     _tWinMain()              - Main function.
00041 //     CreatePropSheet()        - Creates the property container and adds PS Pages.
00042 //     LoadLanguageResource()   - Initialize and loads the appropriate language DLL.
00043 //
00044 ///////////////////////////////////////////////////////////////////////////////////////////
00045
00046 #include "global.h"
00047
00048
00049 // Declaration of internal functions
00050 BOOL    CreatePropSheet(HWND);
00051 HANDLE  LoadLanguageResource(WORD);
00052
00053
00054 ///////////////////////////////////////////////////////////////////////////////////////////
00055 //  Function:       _tWinMain
00056 //
00057 //  Description:    Program entry point - init application, invoke the creation of
00058 //                  property sheet, and do cleanup on exit.
00059 //
00060 //  Comments:       Windows 2000 and Windows XP are the only platforms really designed for
00061 //                  multilingual computing and therefore this will only run on top of these
00062 //                  platforms. However, the principe and coding can be used on other platforms.
00063 //
00064 ///////////////////////////////////////////////////////////////////////////////////////////
00065 int WINAPI _tWinMain(HINSTANCE  hInstance, HINSTANCE  hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
00066 {
00067     INITCOMMONCONTROLSEX    InitCtrls = {0};
00068     OSVERSIONINFO           VersionInfo = {0};
00069     BOOL                    bSuccess = TRUE;
00070
00071     // Keep a handle to our main instance. That will be handy.
00072     g_hInst = hInstance;
00073
00074     // Register specific common controls classes.
00075     InitCtrls.dwSize = sizeof (INITCOMMONCONTROLSEX);
00076     InitCtrls.dwICC = ICC_BAR_CLASSES ;
00077     InitCommonControlsEx(&InitCtrls);
00078
00079     // We only run on top of Win2000 and Windows XP.
00080     // These are the only two platfroms really designed for multilingual computing
00081     VersionInfo.dwOSVersionInfoSize = sizeof (VersionInfo);
00082     GetVersionEx(&VersionInfo);
00083     if (VersionInfo.dwMajorVersion < 5)
00084     {
00085         MessageBox(NULL,TEXT("This application is designed to run on Windows 2000 and beyond."), TEXT("Global - Error to initialize"), MB_OK|MB_ICONSTOP);
00086         bSuccess =  FALSE;
00087     }
00088     else
00089     {
00090
00091         // Load the appropriate resource DLL.
00092         // If a language is specefied at the command line, then load that language, if not,
00093         // select the resource DLL that matches the system UI language.
00094         if (_tcslen(lpszCmdLine) != 0)
00095         {
00096             // we start the application in a given language...
00097             g_hRes = LoadLanguageResource((LANGID) _tcstoul(lpszCmdLine, NULL, 16));
00098         }
00099         else
00100         {
00101             g_hRes = LoadLanguageResource(0);
00102         }
00103
00104         // We fail to load any language DLL, just let the user know and end program.
00105         if (!g_hRes)
00106         {
00107             TCHAR   tcsErr[MAX_STR];
00108             LoadString(g_hInst, STR_RESDLL_NOTFOUND, tcsErr, MAX_STR);
00109             LoadString(g_hInst, STR_APPTITLE, g_tcsTemp, MAX_STR);
00110             MessageBox(NULL, tcsErr, g_tcsTemp, MB_OK|MB_ICONERROR);
00111             bSuccess =  FALSE;
00112         }
00113         else
00114         {
00115             // Create our application's proprety sheet.
00116             CreatePropSheet(NULL);
00117             // Free resource dll before leaving...
00118             bSuccess = FreeLibrary(g_hRes);
00119         }
00120     }
00121     return bSuccess;
00122 }
00123
00124 ///////////////////////////////////////////////////////////////////////////////////////////
00125 //  Function        CreatePropSheet
00126 //
00127 //  Description:    Create the PS container and adds adds the pages defined in the
00128 //                  specified property sheet header structure.
00129 //
00130 //  Comments:
00131 //
00132 ///////////////////////////////////////////////////////////////////////////////////////////
00133 BOOL CreatePropSheet(HWND hDlg)
00134 {
00135     PROPSHEETPAGE       psp[NBR_PS_PAGE];
00136     PROPSHEETHEADER     psh = {0};
00137     UINT                uiPage = 0;
00138
00139     // Create our "NLS API" page.
00140     // the resource template is coming from the resource DLL loaded at run time.
00141     psp[uiPage].dwSize      = sizeof(PROPSHEETPAGE);
00142     psp[uiPage].dwFlags     = PSP_DEFAULT;
00143     psp[uiPage].hInstance   = g_hRes;
00144     psp[uiPage].pszTemplate = MAKEINTRESOURCE(DLG_NLS);
00145     psp[uiPage].pszIcon     = NULL;
00146     psp[uiPage].pfnDlgProc  = NLSDlgProc;
00147     psp[uiPage].pszTitle    = NULL;
00148     psp[uiPage].lParam      = 0L;
00149     psp[uiPage].pfnCallback = NULL;
00150     uiPage++;
00151
00152     // Create our "TEXT API" page.
00153     // The resource template is coming from the resource DLL loaded at run time.
00154     psp[uiPage].dwSize      = sizeof(PROPSHEETPAGE);
00155     psp[uiPage].dwFlags     = PSP_DEFAULT;
00156     psp[uiPage].hInstance   = g_hRes;
00157     psp[uiPage].pszTemplate = MAKEINTRESOURCE(DLG_TEXT);
00158     psp[uiPage].pszIcon     = NULL;
00159     psp[uiPage].pfnDlgProc  = TextDlgProc;
00160     psp[uiPage].pszTitle    = NULL;
00161     psp[uiPage].lParam      = 0L;
00162     psp[uiPage].pfnCallback = NULL;
00163     uiPage++;
00164
00165     // Create our "General" page.
00166     // The resource template is coming from the resource DLL loaded at run time.
00167     psp[uiPage].dwSize      = sizeof(PROPSHEETPAGE);
00168     psp[uiPage].dwFlags     = PSP_DEFAULT;
00169     psp[uiPage].hInstance   = g_hRes;
00170     psp[uiPage].pszTemplate = MAKEINTRESOURCE(DLG_GENERAL);
00171     psp[uiPage].pszIcon     = NULL;
00172     psp[uiPage].pfnDlgProc  = GeneralDlgProc;
00173     psp[uiPage].pszTitle    = NULL;
00174     psp[uiPage].lParam      = 0L;
00175     psp[uiPage].pfnCallback = NULL;
00176     uiPage++;
00177
00178     psh.dwSize      = sizeof(PROPSHEETHEADER);
00179     psh.dwFlags     = PSH_PROPSHEETPAGE | PSH_USEPAGELANG;
00180     psh.hwndParent  = hDlg;
00181     psh.hInstance   = g_hInst;
00182     psh.hIcon       = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_MAINICON));
00183
00184     LoadString(g_hInst, STR_TITLE, g_tcsTemp, MAX_STR);
00185     psh.pszCaption  = g_tcsTemp;
00186     psh.nPages      = NBR_PS_PAGE;
00187     psh.nStartPage  = 0;
00188     psh.ppsp        = (LPCPROPSHEETPAGE)&psp;
00189     psh.pfnCallback = NULL;
00190
00191     return (PropertySheet(&psh) != -1);
00192 }
00193
00194 ///////////////////////////////////////////////////////////////////////////////////////////
00195 //  Function:       LoadLanguageResource
00196 //
00197 //  Description:    Decide which language resource DLL should be loaded.
00198 //
00199 //  Comments:       The best practice in naming resource DLLs is to go with the LangID
00200 //                  since Win32 APIs would return a langID for the currently selected UI
00201 //                  langauge.
00202 //                  To learn more about how to retrieve the UI language on other platforms
00203 //                 (other than Win2000 and WinXP, check out:
00204 //                  http://www.microsoft.com/globaldev/articles/muiapp.asp
00205 //
00206 ///////////////////////////////////////////////////////////////////////////////////////////
00207 HANDLE  LoadLanguageResource(WORD wLangId)
00208 {
00209     HANDLE  hRes = NULL;
00210
00211     // if wLangId = NULL then load user's language of the UI
00212     // GetUserDefaltUILanguage only works on WinME, Win2000, and WinXP.
00213     // To retrieve the UI language on any other OS, refer to the article at:
00214     // http://www.microsoft.com/globaldev/articles/muiapp.asp
00215     if (wLangId == 0)
00216     {
00217         wLangId = GetUserDefaultUILanguage();
00218     }
00219
00220     // Our naming convention for satellite DLLs is: gres[langID].dll
00221     // Create file name and load the appropriate resource DLL.
00222     _sntprintf(g_tcsTemp,MAX_STR,TEXT("gres%x.dll"), wLangId);
00223     g_wCurLang = wLangId;
00224
00225     if(NULL == (hRes = LoadLibrary(g_tcsTemp)))
00226     {
00227         // We didn't find the desired language satellite DLL, lets go with English
00228         hRes = LoadLibrary(TEXT("gres409.dll"));
00229
00230         // Keep the a copy of our UI language ID (will be handy).
00231         g_wCurLang = 409;
00232     }
00233
00234      return hRes;
00235 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_Events Member List

This is the complete list of members for _Events, including all inherited members.
EventFlag | _Events
EventName | _Events
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDataNotify Member List

This is the complete list of members for CDataNotify, including all inherited members.
AddRef(void) | CDataNotify |
AddRef(void) | CDataNotify |
RefCount::AddRef(void) | RefCount |
CDataNotify() | CDataNotify |
CDataNotify() | CDataNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
Connect(IUnknown *pUnk) | CDataNotify |
Connect(IUnknown *pUnk) | CDataNotify |
CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
DataReceived(INmMember *pMember, ULONG uSize, LPBYTE pb, ULONG dwFlags) | CDataNotify |
DataReceived(INmMember *pMember, ULONG uSize, LPBYTE pb, ULONG dwFlags) | CDataNotify |
DataSent(INmMember *pMember, ULONG uSize, LPBYTE pb) | CDataNotify |
DataSent(INmMember *pMember, ULONG uSize, LPBYTE pb) | CDataNotify |
Disconnect(void) | CDataNotify |
Disconnect(void) | CDataNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CDataNotify |
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CDataNotify |
NmUI(CONFN uNotify) | CDataNotify |
NmUI(CONFN uNotify) | CDataNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CDataNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CDataNotify |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
Release(void) | CDataNotify |
Release(void) | CDataNotify |
RefCount::Release(void) | RefCount |
~CDataNotify() | CDataNotify |
~CDataNotify() | CDataNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
Generated on Wed Nov 13 2024 16:56:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCOrder/Order.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCOrder

Order.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Order.cpp
00003   Summary:   Implementation of COrder class
00004   Classes:   Implemented: COrder
00005        Used: ADO  CLSID_ADOConnection
00006        Used: COM+ ObjectContext
00007   Methods:   put_CustomerId
00008        put_OrderId
00009        LineItem
00010        ProcessOrder
00011 -----------------------------------------------------------------------------
00012
00013 This file is part of the Microsoft COM+ Samples.
00014
00015 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00016
00017 This source code is intended only as a supplement to Microsoft
00018 Development Tools and/or on-line documentation. See these other
00019 materials for detailed information regarding Microsoft code samples.
00020
00021 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00022 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00023 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00024 PARTICULAR PURPOSE.
00025
00026 ==========================================================================+*/
00027
00028 #include "stdafx.h"
00029 #include "..\DataSourceNames.h" // ADO Data Source Names, userid, password
00030 #include <adoid.h>    // ADO OLEDBSDK
00031 #include <adoint.h>   // ADO OLEDBSDK
00032 #include "QCOrder.h"
00033 #include "Order.h"
00034 #include "..\QCOrder\processFlags.h"
00035 #include "..\QCShip\QCShip.h"
00036
00037 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00038   Method:   COrder::put_CustomerId
00039   Summary:  property put for CustomerId property
00040   Args:     long lCustomerId      A customer identifier
00041   Modifies: class member variable m_lCustomerId
00042   Returns:  HRESULT - Always returns S_OK
00043 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00044
00045 STDMETHODIMP COrder::put_CustomerId(long lCustomerId)
00046 {
00047   m_lCustomerId = lCustomerId;
00048   return S_OK;
00049 }
00050
00051 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00052   Method:   COrder::put_OrderId
00053   Summary:  property put for OrderId property
00054   Args:     long lOrderId     An order identifier
00055   Modifies: class member variable m_lOrderId
00056   Returns:  HRESULT - Always returns S_OK
00057 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00058
00059 STDMETHODIMP COrder::put_OrderId(long lOrderId)
00060 {
00061   m_lOrderId = lOrderId;
00062   return S_OK;
00063 }
00064
00065 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00066   Method:   COrder::LineItem
00067   Summary:  Adds a single item to an order
00068   Args:     long lItemId      An item identifier (e.g. stock number)
00069       long lQuantity      Quantity of the item ordered
00070   Modifies: class members m_veclItemId and m_veclQuantity
00071   Returns:  HRESULT - Always returns S_OK
00072 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00073
00074 STDMETHODIMP COrder::LineItem(long lItemId, long lQuantity)
00075 {
00076   m_veclItemId.push_back(lItemId);
00077   m_veclQuantity.push_back(lQuantity);
00078   return S_OK;
00079 }
00080
00081 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00082   Method:   COrder::Process
00083   Summary:  Adds order to Order Entry table.
00084       Sends order to shipping department.
00085   Args:     long  lFlags - option flags - see constants in IDL file
00086   Modifies: Rows in order entry database (DSN = QCSampOrder)
00087       Issues COM+ SetComplete or SetAbort depending on request success
00088   Returns:  HRESULT - returns failure from embedded function requests or S_OK
00089 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00090
00091 STDMETHODIMP COrder::Process(long lFlags)
00092 {
00093   HRESULT hr = S_OK;
00094
00095   _RPT1(_CRT_WARN, "QCSamp1 %d Order\n", m_lOrderId);
00096
00097   if (lFlags & processFlagWriteDB) hr = WriteOrderDB();
00098
00099   if (SUCCEEDED(hr)) hr = InvokeShip(lFlags);
00100
00101   // Invoke SetComplete or SetAbort depending on our success
00102
00103   // We may be able to replace this with an "autodone" attribute
00104
00105   CComPtr<IObjectContext> pIObjectContext;
00106
00107   if (SUCCEEDED(CoGetObjectContext(IID_IObjectContext, (void**)&pIObjectContext)))
00108   {
00109     if (SUCCEEDED(hr))  pIObjectContext->SetComplete();
00110     else        pIObjectContext->SetAbort();
00111   }
00112
00113   return hr;
00114 }
00115
00116 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00117   THIS IS A PRIVATE MEMBER FUNCTION
00118
00119   Method:   COrder::InvokeShip
00120   Summary:  Creates a Ship object to send to the shipping department
00121   Args:     long  lFlags - option flags
00122   Modifies: None
00123   Returns:  HRESULT from the underlying requests
00124 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00125
00126 HRESULT COrder::InvokeShip(long lFlags)
00127 {
00128   LPWSTR pwszDisplayName;
00129
00130   if (lFlags & processFlagQueuedComponents)
00131     pwszDisplayName = L"queue:/new:QCShip.Ship";
00132   else
00133     pwszDisplayName = L"new:QCShip.Ship";
00134
00135   CComPtr<IUnknown> punkShip;
00136
00137   HRESULT hr = CoGetObject(pwszDisplayName, 0, IID_IUnknown, (void **) &punkShip);
00138   if (SUCCEEDED(hr))
00139   {
00140     if (lFlags & processFlagLateBound)
00141       hr = InvokeShipIDispatch(punkShip, lFlags);
00142     else
00143       hr = InvokeShipVtable(punkShip, lFlags);
00144   }
00145   return hr;
00146 }
00147
00148 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00149   THIS IS A PRIVATE MEMBER FUNCTION
00150
00151   Method:   COrder::InvokeShipIDispatch
00152   Summary:  Creates a Ship object to send to the shipping department
00153   Args:     IUnknown *  punkShip - IUnknown * to Shipping object
00154       long    lFlags  - flag longword with option bits
00155   Modifies: None
00156   Returns:  HRESULT from the underlying requests
00157 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00158
00159 HRESULT COrder::InvokeShipIDispatch(IUnknown * punkShip, long lFlags)
00160 {
00161   HRESULT hr = S_OK;
00162
00163   CComQIPtr<IDispatch, &IID_IDispatch> pIDispatch(punkShip);
00164
00165   if (!pIDispatch) hr = E_NOINTERFACE;
00166
00167   // Set CustomerId property
00168
00169   if (SUCCEEDED(hr))
00170   {
00171     const int nNames = 1;   // number of names
00172
00173     OLECHAR * rgszNames[nNames] = { OLESTR("CustomerId") };
00174     DISPID    dispId[nNames];
00175
00176     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00177                     LOCALE_SYSTEM_DEFAULT, dispId);
00178     if (SUCCEEDED(hr))
00179     {
00180       CComVariant varData(m_lCustomerId);
00181       DISPID    dispidPut = DISPID_PROPERTYPUT;
00182       DISPPARAMS  dispparams = {&varData, &dispidPut, 1, 1};
00183
00184       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00185                   DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
00186     }
00187   }
00188
00189   // Set OrderId property
00190
00191   if (SUCCEEDED(hr))
00192   {
00193     const int nNames = 1;
00194
00195     OLECHAR * rgszNames[nNames] = { OLESTR("OrderId") };
00196     DISPID    dispId[nNames];
00197
00198     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00199                     LOCALE_SYSTEM_DEFAULT, dispId);
00200     if (SUCCEEDED(hr))
00201     {
00202       CComVariant varData(m_lOrderId);
00203       DISPID    dispidPut = DISPID_PROPERTYPUT;
00204       DISPPARAMS  dispparams = {&varData, &dispidPut, 1, 1};
00205
00206       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00207                   DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
00208     }
00209   }
00210
00211   // Call LineItem method once for each line item
00212
00213   if (SUCCEEDED(hr))
00214   {
00215     const int nNames = 3;     // number of names to look up
00216
00217     OLECHAR * rgszNames[nNames] = { OLESTR("LineItem"),   // method name
00218                       OLESTR("lItemId"),    // parm name
00219                       OLESTR("lQuantity") };  // parm name
00220     DISPID    dispId[nNames];
00221
00222     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00223                     LOCALE_SYSTEM_DEFAULT, dispId);
00224
00225     for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00226     {
00227       const int nArgs = nNames - 1;   // number of arguments
00228
00229       CComVariant varData[nArgs];     // number of arguments
00230       varData[0] = m_veclItemId[ix];
00231       varData[1] = m_veclQuantity[ix];
00232
00233       DISPPARAMS dispparams = {varData, &dispId[1], nArgs, nArgs};
00234
00235       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00236                   DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
00237     }
00238   }
00239
00240   // Call Process method
00241
00242   if (SUCCEEDED(hr))
00243   {
00244     const int nNames = 2;     // number of names to look up
00245
00246     OLECHAR * rgszNames[nNames] = { OLESTR("Process"),    // method name
00247                       OLESTR("lFlags") };   // parm name
00248     DISPID    dispId[nNames];
00249
00250     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00251                     LOCALE_SYSTEM_DEFAULT, dispId);
00252     if (SUCCEEDED(hr))
00253     {
00254       const int nArgs = nNames - 1; // number of arguments
00255
00256       CComVariant varData[nArgs];   // just the parameters
00257       varData[0] = lFlags;
00258
00259       DISPPARAMS  dispparams = {varData, &dispId[1], nArgs, 0};
00260
00261       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00262                   DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
00263     }
00264   }
00265   return hr;
00266 }
00267
00268 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00269   THIS IS A PRIVATE MEMBER FUNCTION
00270
00271   Method:   COrder::InvokeShipVtable
00272   Summary:  Creates a Ship object to send to the shipping department
00273   Args:     IUnknown *  punkShip - IUnknown * to Shipping object
00274       long    lFlags  - flag longword with option bits
00275   Modifies: None
00276   Returns:  HRESULT from the underlying requests
00277 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00278
00279 HRESULT COrder::InvokeShipVtable(IUnknown * punkShip, long lFlags)
00280 {
00281   HRESULT hr = S_OK;
00282
00283   CComQIPtr<IShip, &IID_IShip> pShip(punkShip);
00284
00285   if (!pShip) hr = E_NOINTERFACE;
00286
00287   if (SUCCEEDED(hr)) hr = pShip->put_CustomerId(m_lCustomerId);
00288
00289   if (SUCCEEDED(hr)) hr = pShip->put_OrderId(m_lOrderId);
00290
00291   for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00292   {
00293     hr = pShip->LineItem(m_veclItemId[ix], m_veclQuantity[ix]);
00294   }
00295
00296   if (SUCCEEDED(hr)) hr = pShip->Process(lFlags);
00297
00298   return hr;
00299 }
00300
00301 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00302   THIS IS A PRIVATE MEMBER FUNCTION
00303
00304   Method:   COrder::WriteOrderDB
00305   Summary:  Writes the order into the Order Entry table.
00306   Args:     None
00307   Modifies: Order Entry table
00308   Returns:  HRESULT from the underlying requests.
00309 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00310
00311 HRESULT COrder::WriteOrderDB()
00312 {
00313   CComPtr<ADOConnection> pADOConnection;
00314
00315   HRESULT hr = CoCreateInstance(  CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,
00316                   IID_IADOConnection, (void **) &pADOConnection);
00317   if (SUCCEEDED(hr))
00318   {
00319     // Connect to the database.  name constants are in DataSourceNames.h
00320
00321     hr = pADOConnection->Open(  _bstr_t(pszOrderDSN), _bstr_t(pszUserId),
00322                   _bstr_t(pszPassword), adOpenUnspecified);
00323
00324     // Write one row per line item
00325     for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00326     {
00327       TCHAR szSQLStmt[512];
00328
00329       LPCTSTR const pszPrototypeInsertStmt =
00330           _T("insert into QCSampleOrder ")
00331           _T("  (order_id, cust_id, line_no, item_id, quantity) ")
00332           _T("  values(%ld, %ld, %ld, %ld, %ld)");
00333
00334       wsprintf( szSQLStmt,
00335             pszPrototypeInsertStmt,
00336             m_lOrderId,
00337             m_lCustomerId,
00338             ix,
00339             m_veclItemId[ix],
00340             m_veclQuantity[ix]);
00341
00342       hr = pADOConnection->Execute(_bstr_t(szSQLStmt), NULL, adCmdText, NULL);
00343       // hr tested in for loop
00344     }
00345   }
00346   return hr;
00347 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/ExplrBar.h Source File

  • WinUI
  • Shell
  • BandObjs

ExplrBar.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ExplorerBar.h
00013
00014    Description:   CExplorerBar definitions.
00015
00016 **************************************************************************/
00017
00018 #include <windows.h>
00019 #include <shlobj.h>
00020
00021 #include "Globals.h"
00022
00023 #ifndef EXPLORERBAR_H
00024 #define EXPLORERBAR_H
00025
00026 #define EB_CLASS_NAME (TEXT("ExplorerBarSampleClass"))
00027
00028 #define MIN_SIZE_X   10
00029 #define MIN_SIZE_Y   10
00030
00031 /**************************************************************************
00032
00033    CExplorerBar class definition
00034
00035 **************************************************************************/
00036
00037 class CExplorerBar : public IDeskBand,
00038                      public IInputObject,
00039                      public IObjectWithSite,
00040                      public IPersistStream
00041 {
00042 protected:
00043    DWORD m_ObjRefCount;
00044
00045 public:
00046    CExplorerBar();
00047    ~CExplorerBar();
00048
00049    //IUnknown methods
00050    STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00051    STDMETHODIMP_(DWORD) AddRef();
00052    STDMETHODIMP_(DWORD) Release();
00053
00054    //IOleWindow methods
00055    STDMETHOD (GetWindow) (HWND*);
00056    STDMETHOD (ContextSensitiveHelp) (BOOL);
00057
00058    //IDockingWindow methods
00059    STDMETHOD (ShowDW) (BOOL fShow);
00060    STDMETHOD (CloseDW) (DWORD dwReserved);
00061    STDMETHOD (ResizeBorderDW) (LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
00062
00063    //IDeskBand methods
00064    STDMETHOD (GetBandInfo) (DWORD, DWORD, DESKBANDINFO*);
00065
00066    //IInputObject methods
00067    STDMETHOD (UIActivateIO) (BOOL, LPMSG);
00068    STDMETHOD (HasFocusIO) (void);
00069    STDMETHOD (TranslateAcceleratorIO) (LPMSG);
00070
00071    //IObjectWithSite methods
00072    STDMETHOD (SetSite) (IUnknown*);
00073    STDMETHOD (GetSite) (REFIID, LPVOID*);
00074
00075    //IPersistStream methods
00076    STDMETHOD (GetClassID) (LPCLSID);
00077    STDMETHOD (IsDirty) (void);
00078    STDMETHOD (Load) (LPSTREAM);
00079    STDMETHOD (Save) (LPSTREAM, BOOL);
00080    STDMETHOD (GetSizeMax) (ULARGE_INTEGER*);
00081
00082 private:
00083   BOOL m_bFocus;
00084   HWND m_hwndParent;
00085   HWND m_hWnd;
00086   DWORD m_dwViewMode;
00087    DWORD m_dwBandID;
00088    IInputObjectSite *m_pSite;
00089
00090 private:
00091   void FocusChange(BOOL);
00092    LRESULT OnKillFocus(void);
00093   LRESULT OnSetFocus(void);
00094   static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00095   LRESULT OnPaint(void);
00096   LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
00097    BOOL RegisterAndCreateWindow(void);
00098 };
00099
00100 #endif   //EXPLORERBAR_H
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/Util.Cpp Source File

  • Web
  • NetMeeting
  • NMChat

Util.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       UTIL.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017
00018 //****************************************************************************
00019 //
00020 // VOID SendText(void)
00021 //
00022 // Send the line of text in the edit control.
00023 //
00024 //****************************************************************************
00025
00026 VOID SendText(void)
00027 {
00028   UINT  cb = 0;
00029   TCHAR sz[MAX_PATH + 1];
00030   ZeroMemory(sz, (MAX_PATH + 1) * sizeof(TCHAR));
00031
00032 #ifdef NM2_CHAT_PROTOCOL
00033   BYTE   buffer[CB_NM2_HDR + (MAX_PATH + 1) * sizeof(WCHAR)];
00034   ZeroMemory(buffer, CB_NMUI_HDR + (MAX_PATH + 1) * sizeof(WCHAR));
00035
00036   // Get the text line
00037   cb = SendMessage(ghwndEdit, WM_GETTEXT, (WPARAM) MAX_PATH, (LPARAM) sz);
00038   SendMessage(ghwndEdit, EM_SETSEL, (WPARAM) 0, (LPARAM)-1);
00039   SendMessage(ghwndEdit, WM_SETTEXT, (WPARAM) 0, (LPARAM) "");
00040
00041   if ((0 != cb) && (NULL != g_pChannelData))
00042   {
00043     INmMember * pMember = GetSelectedMember();
00044     if ((pMember != NULL) && (S_OK == pMember->IsSelf()))
00045     {
00046       // Local Member => Everyone => Broadcast
00047       pMember = NULL;
00048     }
00049
00050     cb++; // include final null
00051 #ifdef UNICODE
00052     lstrcpyn((LPTSTR) &buffer[CB_NM2_HDR], sz, MAX_PATH + 1);
00053 #else
00054     cb = MultiByteToWideChar(CP_ACP, 0, sz, cb, (LPWSTR) &buffer[CB_NM2_HDR], MAX_PATH);
00055     cb *= 2; // adjust for UNICODE
00056 #endif /* !UNICODE */
00057
00058     // Add special prefix
00059     cb += CB_NM2_HDR;
00060     ZeroMemory(buffer, CB_NM2_HDR);
00061     * ((LPDWORD) buffer) = CB_NM2_HDR;
00062
00063     g_pChannelData->SendData(pMember, cb, buffer, 0);
00064   }
00065
00066 #else
00067   // Get the text line
00068   cb = SendMessage(ghwndEdit, WM_GETTEXT, (WPARAM) CCHMAX(sz), (LPARAM) sz);
00069   SendMessage(ghwndEdit, EM_SETSEL, (WPARAM) 0, (LPARAM)-1);
00070   SendMessage(ghwndEdit, WM_SETTEXT, (WPARAM) 0, (LPARAM) "");
00071
00072   if ((0 != cb) && (NULL != g_pChannelData))
00073   {
00074     INmMember * pMember = GetSelectedMember();
00075     if ((pMember != NULL) && (S_OK == pMember->IsSelf()))
00076     {
00077       // Local Member => Everyone => Broadcast
00078       pMember = NULL;
00079     }
00080
00081     cb++; // include final null
00082     g_pChannelData->SendData(pMember, cb, (LPBYTE) sz, 0);
00083   }
00084 #endif /* NM2_CHAT_PROTOCOL */
00085 }
00086
00087
00088 //****************************************************************************
00089 //
00090 // VOID ClearText(void)
00091 //
00092 //****************************************************************************
00093
00094 VOID ClearText(void)
00095 {
00096   ListView_DeleteAllItems(ghwndMsg);
00097 }
00098
00099
00100 //****************************************************************************
00101 //
00102 // VOID SizeMsgWindow(int dx, int dy)
00103 //
00104 //****************************************************************************
00105
00106 VOID SizeMsgWindow(int dx, int dy)
00107 {
00108   MoveWindow(ghwndEdit, XP_LEFT, dy - DYP_EDIT, dx, DYP_EDIT, TRUE);
00109   dy -= (YP_TOP + DYP_EDIT);
00110
00111   MoveWindow(ghwndUser, XP_LEFT, YP_TOP, DXP_USER, dy, TRUE);
00112   dx -= DXP_USER;
00113
00114   MoveWindow(ghwndMsg, XP_LEFT + DXP_USER, YP_TOP, dx, dy, TRUE);
00115 }
00116
00117
00118 //****************************************************************************
00119 //
00120 // VOID RecalcMsgWindow(void)
00121 //
00122 //****************************************************************************
00123
00124 VOID RecalcMsgWindow(void)
00125 {
00126   RECT rc = {0,0,0,0};
00127
00128   GetClientRect(ghwndMain, &rc);
00129   SizeMsgWindow(rc.right, rc.bottom);
00130 }
00131
00132
00133 //****************************************************************************
00134 //
00135 // LPVOID LpvAlloc(int cb)
00136 //
00137 // Return a pointer to an allocated array of bytes
00138 //
00139 //****************************************************************************
00140
00141 LPVOID LpvAlloc(int cb)
00142 {
00143   return LocalAlloc(LMEM_FIXED, cb);
00144 }
00145
00146
00147 //****************************************************************************
00148 //
00149 // LPTSTR PszAlloc(int cch)
00150 //
00151 //****************************************************************************
00152
00153 LPTSTR PszAlloc(int cch)
00154 {
00155   return (LPTSTR) LocalAlloc(LMEM_FIXED, sizeof(TCHAR) * (cch+1));
00156 }
00157
00158
00159 //****************************************************************************
00160 //
00161 // VOID FreePlpv(LPVOID plpv)
00162 //
00163 // Free the data pointed to by plpv and set *plpv to NULL
00164 //
00165 //****************************************************************************
00166
00167 VOID FreePlpv(LPVOID plpv)
00168 {
00169   if ((plpv == NULL) || (*(VOID FAR * FAR *)plpv == NULL))
00170   {
00171     return;
00172   }
00173
00174   LocalFree(*(VOID FAR * FAR *)plpv);
00175   *(VOID FAR * FAR *)plpv = NULL;
00176 }
00177
00178
00179 //****************************************************************************
00180 //
00181 // VOID MaybeDeleteObject(HGDIOBJ * phgdi)
00182 //
00183 // Check usage count, delete if we can
00184 //
00185 //****************************************************************************
00186
00187 VOID MaybeDeleteObject(HGDIOBJ * phgdi)
00188 {
00189   if(NULL == phgdi || NULL == *phgdi)
00190   {
00191     return;
00192   }
00193
00194   DeleteObject(*phgdi);
00195   *phgdi = NULL;
00196 }
00197
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMultiRecoApp Member List

This is the complete list of members for CMultiRecoApp, including all inherited members.
CMultiRecoApp() | CMultiRecoApp | [inline]
const_cast(&mc_AtlFuncInfo[1])) HRESULT __stdcall Stroke(IInkCursor *pIInkCursor | IInkCollectorEventsImpl< CMultiRecoApp > |
CreateChildWindows() | CMultiRecoApp |
CreateRecoContext(IInkRecognizer *pIInkRecognizer) | CMultiRecoApp |
CreateRecoGuides() | CMultiRecoApp |
DIID__IInkCollectorEvents | IInkCollectorEventsImpl< CMultiRecoApp > |
DISPID_CEGesture | IInkCollectorEventsImpl< CMultiRecoApp > |
DoOpen(bool bNew) | CMultiRecoApp |
DoSave(bool bSaveAs, bool bAskUser) | CMultiRecoApp |
Gesture | IInkCollectorEventsImpl< CMultiRecoApp > |
LoadFile(IInkDisp *pInkDisp) | CMultiRecoApp |
LoadMenu() | CMultiRecoApp |
m_bstrCurRecoName | CMultiRecoApp |
m_hwndStatusBar | CMultiRecoApp |
m_iColor | CMultiRecoApp |
m_nCmdRecognizer | CMultiRecoApp |
m_spIInkCollector | CMultiRecoApp |
m_spIInkCustomStrokes | CMultiRecoApp |
m_spIInkDisp | CMultiRecoApp |
m_spIInkRecoContext | CMultiRecoApp |
m_spIInkRecognizers | CMultiRecoApp |
m_spIInkRecoGuideBoxed | CMultiRecoApp |
m_spIInkRecoGuideLined | CMultiRecoApp |
m_spIInkStrokes | CMultiRecoApp |
m_wchFile | CMultiRecoApp |
m_wchFileTitle | CMultiRecoApp |
m_wndInput | CMultiRecoApp |
m_wndResults | CMultiRecoApp |
IInkCollectorEventsImpl< CMultiRecoApp >::mc_AtlFuncInfo | IInkCollectorEventsImpl< CMultiRecoApp > | [static]
IInkRecognitionEventsImpl< CMultiRecoApp >::mc_AtlFuncInfo | IInkRecognitionEventsImpl< CMultiRecoApp > | [static]
mc_crColors | CMultiRecoApp | [static]
mc_cxBoxMargin enum value | CMultiRecoApp |
mc_cyBoxMargin enum value | CMultiRecoApp |
mc_iGuideColWidth enum value | CMultiRecoApp |
mc_iGuideRowHeight enum value | CMultiRecoApp |
mc_iInputWndId enum value | CMultiRecoApp |
mc_iNumRowsCols enum value | CMultiRecoApp |
mc_iOutputWndId enum value | CMultiRecoApp |
mc_iPenWidth enum value | CMultiRecoApp |
mc_iStatusWndId enum value | CMultiRecoApp |
mc_iSubmenuRecognizers enum value | CMultiRecoApp |
OnClear(WORD, WORD, HWND, BOOL &) | CMultiRecoApp |
OnClose(UINT, WPARAM, LPARAM, BOOL &bHandled) | CMultiRecoApp | [inline]
OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CMultiRecoApp |
OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CMultiRecoApp |
OnExit(WORD, WORD, HWND, BOOL &) | CMultiRecoApp | [inline]
OnFileOpen(WORD, WORD wID, HWND, BOOL &) | CMultiRecoApp | [inline]
OnFileSave(WORD, WORD wID, HWND, BOOL &) | CMultiRecoApp | [inline]
OnNewStrokes(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CMultiRecoApp |
OnRecognition(BSTR bstrRecognizedString, VARIANT vCustomParam, InkRecognitionStatus RecognitionStatus) | CMultiRecoApp |
OnRecognitionWithAlternates(pIInkRecoResult, vCustomParam, RecognitionStatus) | IInkRecognitionEventsImpl< CMultiRecoApp > |
OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CMultiRecoApp |
OnStroke(IInkCursor *pIInkCursor, IInkStrokeDisp *pIInkStroke, VARIANT_BOOL *pbCancel) | CMultiRecoApp |
pInkStroke | IInkCollectorEventsImpl< CMultiRecoApp > |
pT | IInkRecognitionEventsImpl< CMultiRecoApp > |
Run(int nCmdShow) | CMultiRecoApp | [static]
SaveStrokeCollection() | CMultiRecoApp |
IInkCollectorEventsImpl< CMultiRecoApp >::SINK_ENTRY_INFO(SINK_ID, DIID__IInkCollectorEvents, DISPID_CEStroke, Stroke, const_cast< _ATL_FUNC_INFO * >(&mc_AtlFuncInfo[0])) SINK_ENTRY_INFO(SINK_ID | IInkCollectorEventsImpl< CMultiRecoApp > |
IInkCollectorEventsImpl< CMultiRecoApp >::SINK_ENTRY_INFO(SINK_ID, DIID__IInkCollectorEvents, DISPID_CEStroke, Stroke, const_cast< _ATL_FUNC_INFO * >(&mc_AtlFuncInfo)) HRESULT __stdcall Stroke(IInkCursor *pIInkCursor | IInkCollectorEventsImpl< CMultiRecoApp > |
IInkRecognitionEventsImpl< CMultiRecoApp >::SINK_ENTRY_INFO(SINK_ID, DIID__IInkRecognitionEvents, DISPID_RERecognitionWithAlternates, RecognitionWithAlternates, const_cast< _ATL_FUNC_INFO * >(&mc_AtlFuncInfo)) HRESULT __stdcall RecognitionWithAlternates(IInkRecognitionResult *pIInkRecoResult | IInkRecognitionEventsImpl< CMultiRecoApp > |
IInkRecognitionEventsImpl< CMultiRecoApp >::SINK_ENTRY_INFO(SINK_ID, DIID__IInkRecognitionEvents, DISPID_RERecognition, Recognition, const_cast< _ATL_FUNC_INFO * >(&mc_AtlFuncInfo)) HRESULT __stdcall Recognition(BSTR bstrRecognizedString | IInkRecognitionEventsImpl< CMultiRecoApp > |
StartNewStrokeCollection() | CMultiRecoApp |
UpdateFilename(WCHAR *pwsFile=NULL, WCHAR *pwsFileTitle=NULL) | CMultiRecoApp |
UpdateLayout() | CMultiRecoApp |
UpdateStatusBar() | CMultiRecoApp |
vCustomParam | IInkRecognitionEventsImpl< CMultiRecoApp > |
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/globals.h Source File

  • SysMgmt
  • MMC
  • Taskpads

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025         #define IDM_BUTTON1    0x100
00026         #define IDM_BUTTON2    0x101
00027
00028         extern HINSTANCE g_hinst;
00029         extern ULONG g_uObjects;
00030
00031         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034         // uncomment the following #define to enable message cracking
00035         // #define MMC_CRACK_MESSAGES
00036         void MMCN_Crack(BOOL bComponentData,
00037                                         IDataObject *pDataObject,
00038                                         IComponentData *pCompData,
00039                                         IComponent *pComp,
00040                                         MMC_NOTIFY_TYPE event,
00041                                         LPARAM arg,
00042                                         LPARAM param);
00043
00044     LPOLESTR CreateResourcePath(HINSTANCE hInst, LPOLESTR szResource);
00045 #endif
00046
00047 //=--------------------------------------------------------------------------=
00048 // allocates a temporary buffer that will disappear when it goes out of scope
00049 // NOTE: be careful of that -- make sure you use the string in the same or
00050 // nested scope in which you created this buffer. people should not use this
00051 // class directly.  use the macro(s) below.
00052 //
00053 class TempBuffer {
00054   public:
00055     TempBuffer(ULONG cBytes) {
00056         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00057         m_fHeapAlloc = (cBytes > 120);
00058     }
00059     ~TempBuffer() {
00060         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00061     }
00062     void *GetBuffer() {
00063         return m_pBuf;
00064     }
00065
00066   private:
00067     void *m_pBuf;
00068     // we'll use this temp buffer for small cases.
00069     //
00070     char  m_szTmpBuf[120];
00071     unsigned m_fHeapAlloc:1;
00072 };
00073
00074 //=--------------------------------------------------------------------------=
00075 // string helpers.
00076 //
00077 // given a _TCHAR, copy it into a wide buffer.
00078 // be careful about scoping when using this macro!
00079 //
00080 // how to use the below two macros:
00081 //
00082 //  ...
00083 //  LPTSTR pszT;
00084 //  pszT = MyGetTStringRoutine();
00085 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00086 //  MyUseWideStringRoutine(pwsz);
00087 //  ...
00088 #ifdef UNICODE
00089 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00090     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00091     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00092     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00093     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00094 #else // ANSI
00095 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00096     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00097     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00098     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00099     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00100     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00101 #endif
00102
00103 #ifdef UNICODE
00104 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00105     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00106     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00107     lstrcpyW((LPWSTR)ptrname, tstr)
00108 #else // ANSI
00109 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00110     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00111     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00112     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00113     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00114 #endif
00115
00116 //
00117 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00118 // have to be declared, and no clean up must be done.
00119 //
00120 // * 2 for DBCS handling in below length computation
00121 //
00122 #ifdef UNICODE
00123 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00124     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00125     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00126     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00127     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00128 #else // ANSI
00129 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00130     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00131     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00132     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00133     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00134 #endif
00135
00136 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/registry.Cpp Source File

  • SysMgmt
  • MMC
  • About

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "globals.h"
00026
00027 ////////////////////////////////////////////////////////
00028 //
00029 // Internal helper functions prototypes
00030 //
00031
00032 // Set the given key and its value.
00033 BOOL setKeyAndValue(const _TCHAR* pszPath,
00034                     const _TCHAR* szSubkey,
00035                     const _TCHAR* szValue) ;
00036
00037 // Set the given key and its value in the MMC Snapin location
00038 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00039                           const _TCHAR* szSubkey,
00040                           const _TCHAR* szName,
00041                           const _TCHAR* szValue);
00042
00043 // Set the given valuename under the key to value
00044 BOOL setValue(const _TCHAR* szKey,
00045               const _TCHAR* szValueName,
00046               const _TCHAR* szValue);
00047
00048 // Delete szKeyChild and all of its descendents.
00049 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // Constants
00054 //
00055
00056 // Size of a CLSID as a string
00057 //const int CLSID_STRING_SIZE = 39 ;
00058
00059 /////////////////////////////////////////////////////////
00060 //
00061 // Public function implementation
00062 //
00063
00064 //
00065 // Register the component in the registry.
00066 //
00067 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00068                        const CLSID& clsid,         // Class ID
00069                        const _TCHAR* szFriendlyName)       //   IDs
00070 {
00071     // Get server location.
00072     _TCHAR szModule[512] ;
00073     DWORD dwResult =
00074         ::GetModuleFileName(hModule,
00075         szModule,
00076         sizeof(szModule)/sizeof(_TCHAR)) ;
00077
00078     assert(dwResult != 0) ;
00079
00080     // Get CLSID
00081     LPOLESTR wszCLSID = NULL ;
00082     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00083
00084     assert(SUCCEEDED(hr)) ;
00085
00086   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00087
00088     // Build the key CLSID\\{...}
00089     _TCHAR szKey[64] ;
00090     _tcscpy(szKey, _T("CLSID\\")) ;
00091   _tcscat(szKey, pszCLSID) ;
00092
00093     // Add the CLSID to the registry.
00094     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00095
00096     // Add the server filename subkey under the CLSID key.
00097     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00098
00099     // set the threading model
00100     _tcscat(szKey, _T("\\InprocServer32"));
00101     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00102
00103     // Free memory.
00104     CoTaskMemFree(wszCLSID) ;
00105
00106     return S_OK ;
00107 }
00108
00109 //
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00113 {
00114     // Get CLSID
00115     LPOLESTR wszCLSID = NULL ;
00116     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00117
00118
00119     // Build the key CLSID\\{...}
00120     _TCHAR szKey[64] ;
00121     _tcscpy(szKey, _T("CLSID\\")) ;
00122
00123   MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00124   _tcscat(szKey, pszT) ;
00125
00126     // Delete the CLSID Key - CLSID\{...}
00127     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00128     assert((lResult == ERROR_SUCCESS) ||
00129          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00130
00131     // Free memory.
00132     CoTaskMemFree(wszCLSID) ;
00133
00134     return S_OK ;
00135 }
00136
00137 //
00138 // Register the snap-in in the registry.
00139 //
00140 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00141                        const _TCHAR* szNameString,   // NameString
00142                        const CLSID& clsidAbout,   // Class Id for About Class
00143                        const BOOL fSupportExtensions)
00144 {
00145     // Get CLSID
00146     LPOLESTR wszCLSID = NULL ;
00147     LPOLESTR wszAboutCLSID = NULL;
00148     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00149
00150     if (IID_NULL != clsidAbout)
00151         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00152
00153   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00154   MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00155
00156
00157     // Add the CLSID to the registry.
00158     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00159     setSnapInKeyAndValue(pszCLSID, _T("StandAlone"), NULL, NULL);
00160     if (IID_NULL != clsidAbout)
00161         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00162
00163     if (fSupportExtensions) {
00164         // Build the key NodeType
00165         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00166
00167         _TCHAR szKey[64] ;
00168         _tcscpy(szKey, pszCLSID) ;
00169         _tcscat(szKey, _T("\\NodeTypes")) ;
00170         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00171     }
00172
00173     // Free memory.
00174     CoTaskMemFree(wszCLSID) ;
00175     if (IID_NULL != clsidAbout)
00176         CoTaskMemFree(wszAboutCLSID);
00177
00178     return S_OK ;
00179 }
00180
00181 //
00182 // Unregister the snap-in in the registry.
00183 //
00184 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00185 {
00186     _TCHAR szKeyBuf[1024];
00187     LPOLESTR wszCLSID = NULL;
00188
00189     // Get CLSID
00190     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00191   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00192
00193     // Load the buffer with the Snap-In Location
00194     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00195
00196     // Copy keyname into buffer.
00197     _tcscat(szKeyBuf, _T("\\"));
00198     _tcscat(szKeyBuf, pszCLSID);
00199
00200     // Delete the CLSID Key - CLSID\{...}
00201     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00202     assert((lResult == ERROR_SUCCESS) ||
00203          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00204
00205     // free the memory
00206     CoTaskMemFree(wszCLSID);
00207
00208     return S_OK;
00209 }
00210
00211 //
00212 // Delete a key and all of its descendents.
00213 //
00214 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00215                         const _TCHAR* lpszKeyChild)  // Key to delete
00216 {
00217     // Open the child.
00218     HKEY hKeyChild ;
00219     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00220         KEY_ALL_ACCESS, &hKeyChild) ;
00221     if (lRes != ERROR_SUCCESS)
00222     {
00223         return lRes ;
00224     }
00225
00226     // Enumerate all of the decendents of this child.
00227     FILETIME time ;
00228     _TCHAR szBuffer[256] ;
00229     DWORD dwSize = 256 ;
00230     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00231         NULL, NULL, &time) == S_OK)
00232     {
00233         // Delete the decendents of this child.
00234         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00235         if (lRes != ERROR_SUCCESS)
00236         {
00237             // Cleanup before exiting.
00238             RegCloseKey(hKeyChild) ;
00239             return lRes;
00240         }
00241         dwSize = 256 ;
00242     }
00243
00244     // Close the child.
00245     RegCloseKey(hKeyChild) ;
00246
00247     // Delete this child.
00248     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00249 }
00250
00251 //
00252 // Create a key and set its value.
00253 //   - This helper function was borrowed and modifed from
00254 //     Kraig Brockschmidt's book Inside OLE.
00255 //
00256 BOOL setKeyAndValue(const _TCHAR* szKey,
00257                     const _TCHAR* szSubkey,
00258                     const _TCHAR* szValue)
00259 {
00260     HKEY hKey;
00261     _TCHAR szKeyBuf[1024] ;
00262
00263     // Copy keyname into buffer.
00264     _tcscpy(szKeyBuf, szKey) ;
00265
00266     // Add subkey name to buffer.
00267     if (szSubkey != NULL)
00268     {
00269         _tcscat(szKeyBuf, _T("\\")) ;
00270         _tcscat(szKeyBuf, szSubkey ) ;
00271     }
00272
00273     // Create and open key and subkey.
00274     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00275         szKeyBuf,
00276         0, NULL, REG_OPTION_NON_VOLATILE,
00277         KEY_ALL_ACCESS, NULL,
00278         &hKey, NULL) ;
00279     if (lResult != ERROR_SUCCESS)
00280     {
00281         return FALSE ;
00282     }
00283
00284     // Set the Value.
00285     if (szValue != NULL)
00286     {
00287         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00288             (BYTE *)szValue,
00289             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00290     }
00291
00292     RegCloseKey(hKey) ;
00293     return TRUE ;
00294 }
00295
00296 //
00297 // Open a key value and set it
00298 //
00299 BOOL setValue(const _TCHAR* szKey,
00300               const _TCHAR* szValueName,
00301               const _TCHAR* szValue)
00302 {
00303     HKEY hKey;
00304     _TCHAR szKeyBuf[1024] ;
00305
00306     // Copy keyname into buffer.
00307     _tcscpy(szKeyBuf, szKey) ;
00308
00309     // Create and open key and subkey.
00310     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00311         szKeyBuf,
00312         0, NULL, REG_OPTION_NON_VOLATILE,
00313         KEY_ALL_ACCESS, NULL,
00314         &hKey, NULL) ;
00315     if (lResult != ERROR_SUCCESS)
00316     {
00317         return FALSE ;
00318     }
00319
00320     // Set the Value.
00321     if (szValue != NULL)
00322     {
00323         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00324             (BYTE *)szValue,
00325             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00326     }
00327
00328     RegCloseKey(hKey) ;
00329     return TRUE ;
00330 }
00331
00332 //
00333 // Create a key and set its value.
00334 //   - This helper function was borrowed and modifed from
00335 //     Kraig Brockschmidt's book Inside OLE.
00336 //
00337 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00338                           const _TCHAR* szSubkey,
00339                           const _TCHAR* szName,
00340                           const _TCHAR* szValue)
00341 {
00342     HKEY hKey;
00343     _TCHAR szKeyBuf[1024] ;
00344
00345     // Load the buffer with the Snap-In Location
00346     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00347
00348     // Copy keyname into buffer.
00349     _tcscat(szKeyBuf, _T("\\")) ;
00350     _tcscat(szKeyBuf, szKey) ;
00351
00352     // Add subkey name to buffer.
00353     if (szSubkey != NULL)
00354     {
00355         _tcscat(szKeyBuf, _T("\\")) ;
00356         _tcscat(szKeyBuf, szSubkey ) ;
00357     }
00358
00359     // Create and open key and subkey.
00360     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00361         szKeyBuf,
00362         0, NULL, REG_OPTION_NON_VOLATILE,
00363         KEY_ALL_ACCESS, NULL,
00364         &hKey, NULL) ;
00365     if (lResult != ERROR_SUCCESS)
00366     {
00367         return FALSE ;
00368     }
00369
00370     // Set the Value.
00371     if (szValue != NULL)
00372     {
00373         RegSetValueEx(hKey, szName, 0, REG_SZ,
00374             (BYTE *)szValue,
00375             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00376     }
00377
00378     RegCloseKey(hKey) ;
00379     return TRUE ;
00380 }
00381
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/CrmFilesCompensator.h Source File

  • Com
  • Services
  • Crm
  • CrmFiles

CrmFilesCompensator.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmFilesCompensator.h
00004
00005
00006 Summary:
00007
00008   This is a sample Compensating Resource Manager (CRM) that creates and deletes files.
00009
00010   The CRM Worker provides an interface for creating or deleting files.
00011
00012   The CRM Compensator implements ICrmCompensator to receive transaction outcome notifications.
00013
00014   The CRM Compensator also implements ICrmFormatLogRecords to support monitoring.
00015
00016   This CRM can be installed in a server application or in a library application.
00017
00018   The CRM Worker requires a transaction. The CRM Compensator should not have a transaction.
00019
00020
00021 Classes:
00022
00023   CCrmFilesCompensator
00024
00025 ----------------------------------------------------------------------------
00026
00027 This file is part of the Microsoft COM+ Samples.
00028
00029
00030
00031 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00032
00033
00034
00035 This source code is intended only as a supplement to Microsoft
00036
00037 Development Tools and/or on-line documentation. See these other
00038
00039 materials for detailed information regarding Microsoft code samples.
00040
00041
00042
00043 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00044
00045 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00046
00047 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00048
00049 PARTICULAR PURPOSE.
00050
00051 ==========================================================================+*/
00052
00053 #ifndef __CRMFILESCOMPENSATOR_H_
00054 #define __CRMFILESCOMPENSATOR_H_
00055
00056 #include "resource.h"     // main symbols
00057
00058 #include <comsvcs.h>      // CRM interfaces
00059
00060 #include "comdef.h"       // for _variant_t etc.
00061
00062 #include "CrmFilesWorker.h"   // for CrmFilesCommandType
00063
00064
00065 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00066
00067 Class: CCrmFilesCompensator
00068
00069   This is the CRM Compensator. After the transaction is completed this
00070   object is created and given the log from the transaction. It can then
00071   commit or abort the transaction.
00072
00073 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00074
00075 /////////////////////////////////////////////////////////////////////////////
00076 // CCrmFilesCompensator
00077 class ATL_NO_VTABLE CCrmFilesCompensator :
00078   public CComObjectRootEx<CComMultiThreadModel>,
00079   public CComCoClass<CCrmFilesCompensator, &CLSID_CrmFilesCompensator>,
00080     public IDispatchImpl<ICrmFilesCompensator, &IID_ICrmFilesCompensator, &LIBID_CRMFILESLib>,
00081     public ICrmCompensator,
00082   public ICrmFormatLogRecords
00083 {
00084 public:
00085   CCrmFilesCompensator() :
00086      m_pICrmLogControl(NULL)
00087   {
00088   }
00089
00090 DECLARE_REGISTRY_RESOURCEID(IDR_CRMFILESCOMPENSATOR)
00091 DECLARE_NOT_AGGREGATABLE(CCrmFilesCompensator)
00092
00093 BEGIN_COM_MAP(CCrmFilesCompensator)
00094   COM_INTERFACE_ENTRY(ICrmFilesCompensator)
00095     COM_INTERFACE_ENTRY(ICrmCompensator)
00096     COM_INTERFACE_ENTRY(ICrmFormatLogRecords)
00097     COM_INTERFACE_ENTRY(IDispatch)
00098 END_COM_MAP()
00099
00100 // ICrmFilesCompensator
00101 public:
00102
00103 // ICrmCompensator
00104 public:
00105
00106     HRESULT STDMETHODCALLTYPE SetLogControl(
00107         /* [in] */ ICrmLogControl __RPC_FAR *pLogControl);
00108
00109     HRESULT STDMETHODCALLTYPE BeginPrepare( void);
00110
00111     HRESULT STDMETHODCALLTYPE PrepareRecord(
00112         /* [in] */ CrmLogRecordRead crmLogRec,
00113         /* [retval][out] */ BOOL __RPC_FAR *pfForget);
00114
00115     HRESULT STDMETHODCALLTYPE EndPrepare(
00116         /* [retval][out] */ BOOL __RPC_FAR *pfOkToPrepare);
00117
00118     HRESULT STDMETHODCALLTYPE BeginCommit(
00119         /* [in] */ BOOL fRecovery);
00120
00121     HRESULT STDMETHODCALLTYPE CommitRecord(
00122         /* [in] */ CrmLogRecordRead crmLogRec,
00123         /* [retval][out] */ BOOL __RPC_FAR *pfForget);
00124
00125     HRESULT STDMETHODCALLTYPE EndCommit( void);
00126
00127     HRESULT STDMETHODCALLTYPE BeginAbort(
00128         /* [in] */ BOOL fRecovery);
00129
00130     HRESULT STDMETHODCALLTYPE AbortRecord(
00131         /* [in] */ CrmLogRecordRead crmLogRec,
00132         /* [retval][out] */ BOOL __RPC_FAR *pfForget);
00133
00134     HRESULT STDMETHODCALLTYPE EndAbort( void);
00135
00136 // NOTE: This is an optional interface that the compensator can implement to help with
00137 // monitoring the log records
00138
00139 // ICrmFormatLogRecords
00140 public:
00141
00142     HRESULT STDMETHODCALLTYPE GetColumnCount(
00143         /* [out] */ long __RPC_FAR *plColumnCount);
00144
00145     HRESULT STDMETHODCALLTYPE GetColumnHeaders(
00146         /* [out] */ LPVARIANT pHeaders);
00147
00148     HRESULT STDMETHODCALLTYPE GetColumn(
00149         /* [in] */ CrmLogRecordRead CrmLogRec,
00150         /* [out] */ LPVARIANT pFormattedLogRecord);
00151
00152     HRESULT STDMETHODCALLTYPE GetColumnVariants(
00153         /* [in] */ VARIANT LogRecord,
00154         /* [out] */ LPVARIANT pFormattedLogRecord);
00155
00156 private:
00157
00158     // process the raw log record into a form that is meaningful for this CRM Compensator
00159
00160     HRESULT ProcessLogRecord(CrmLogRecordRead crmLogRec);
00161
00162   void MakeVariantArray
00163   (
00164     int       i_iNumVariants,
00165     _variant_t    *i_vArray,
00166     LPVARIANT   i_pVarSafeArray
00167   );
00168
00169 private:
00170
00171     ICrmLogControl              *m_pICrmLogControl;
00172
00173     CrmFilesCommandType         m_CommandType;
00174
00175     WCHAR                       m_wszSourceFileName[MAX_PATH];
00176
00177     WCHAR                       m_wszTempFileName[MAX_PATH];
00178
00179 };
00180
00181 #endif //__CRMFILESCOMPENSATOR_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWaitSystemDlg Member List

This is the complete list of members for CWaitSystemDlg, including all inherited members.
CWaitSystemDlg(CWnd *pParent=NULL) | CWaitSystemDlg |
DoDataExchange(CDataExchange *pDX) | CWaitSystemDlg | [protected, virtual]
IDD enum value | CWaitSystemDlg |
m_eventFlags | CWaitSystemDlg |
m_serverName | CWaitSystemDlg |
OnInitDialog() | CWaitSystemDlg | [protected, virtual]
OnOK() | CWaitSystemDlg | [protected, virtual]
serverHandle | CWaitSystemDlg | [private]
serverName | CWaitSystemDlg | [private]
Generated on Wed Nov 13 2024 16:57:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/PersistATL/persistatl.Cpp Source File

  • Com
  • Services
  • Events
  • EventNews
  • PersistATL

persistatl.Cpp

Go to the documentation of this file.
00001 // PersistATL.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f PersistATLps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "PersistATL.h"
00012
00013 #include "PersistATL_i.c"
00014 #include "NewsEvent.h"
00015
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP(ObjectMap)
00020 OBJECT_ENTRY(CLSID_NewsEvent, CNewsEvent)
00021 END_OBJECT_MAP()
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // DLL Entry Point
00025
00026 extern "C"
00027 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00028 {
00029     if (dwReason == DLL_PROCESS_ATTACH)
00030     {
00031         _Module.Init(ObjectMap, hInstance, &LIBID_PERSISTATLLib);
00032         DisableThreadLibraryCalls(hInstance);
00033     }
00034     else if (dwReason == DLL_PROCESS_DETACH)
00035         _Module.Term();
00036     return TRUE;    // ok
00037 }
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // Used to determine whether the DLL can be unloaded by OLE
00041
00042 STDAPI DllCanUnloadNow(void)
00043 {
00044     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00045 }
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 // Returns a class factory to create an object of the requested type
00049
00050 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00051 {
00052     return _Module.GetClassObject(rclsid, riid, ppv);
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // DllRegisterServer - Adds entries to the system registry
00057
00058 STDAPI DllRegisterServer(void)
00059 {
00060     // registers object, typelib and all interfaces in typelib
00061     return _Module.RegisterServer(TRUE);
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // DllUnregisterServer - Removes entries from the system registry
00066
00067 STDAPI DllUnregisterServer(void)
00068 {
00069     return _Module.UnregisterServer(TRUE);
00070 }
00071
00072
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/foldernode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

foldernode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CFolderNode class.
00014 //
00015
00016
00017 #include "FolderNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020 #include "AddVFileDlg.h"
00021                              // Tracing stuff
00022 #include "TraceMacro.h"
00023 #undef  MODULESTRING
00024 #define MODULESTRING  _T("CFolderNode")
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CFolderNode::thisGUID = CLSID_CFolderNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 CFolderNode::CFolderNode()
00035 {
00036   m_SDI.mask        = DEFAULT_SDI_MASK;
00037   m_SDI.displayname = MMC_CALLBACK;
00038   m_SDI.nImage      = IMG_FOLDER_DEFAULT;
00039   m_SDI.nOpenImage  = IMG_FOLDER_DEFAULT;
00040   m_SDI.cChildren   = 0;              // Determines if the '+' is displayed
00041   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00042
00043   m_dwAttributes    = 0;
00044   m_pCompData       = NULL;
00045   m_hAddVFileDlg    = NULL;
00046   m_hMessageWnd     = NULL;
00047
00048 }
00049
00050 CFolderNode::~CFolderNode()
00051 {
00052 }
00053
00054 //---------------------------------------------------------------------------
00055 HRESULT CFolderNode::Initialize( NODE_PROPERTIES* pNodeProps )
00056 {
00057   _ASSERT( NULL != pNodeProps );
00058   HRESULT hResult = S_FALSE;
00059
00060   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00061   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00062   wcscpy( pszTmp, pNodeProps->szNodeName );
00063   if( NULL != m_pwszNodeName )
00064     CoTaskMemFree( m_pwszNodeName );
00065
00066   m_pwszNodeName = pszTmp;
00067   m_pCompData = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00068   // Not using pNodeProps->pParentObject in this node.
00069
00070   RefreshNodeList();         // Create Result Item nodes
00071
00072   // We create a hidden window to allow us to communicate with modeless
00073   // dialogs and other things which run in a seperate thread.
00074
00075   WNDCLASS wc;
00076   ZeroMemory (&wc, sizeof(WNDCLASS));
00077   wc.cbWndExtra    = sizeof(this);
00078   wc.lpfnWndProc   = FolderNodeWndProc;
00079   wc.hInstance     = g_hInst;
00080   wc.lpszClassName = _T("FolderNodeMsgWnd");
00081
00082   RegisterClass( &wc );
00083   m_hMessageWnd = CreateWindow( _T("FolderNodeMsgWnd"), NULL,
00084                                 0, 0, 0, 0, 0, NULL, 0, g_hInst, this);
00085
00086   if( NULL == m_hMessageWnd )
00087     hResult = S_FALSE;
00088
00089   return hResult;
00090 }
00091
00092 //---------------------------------------------------------------------------
00093 //  This is our hidden window which is just used for handling messages.  We
00094 //  go to all this trouble so that we don't ever pass interface pointers or
00095 //  other objects across threads.
00096 //
00097 LRESULT CALLBACK CFolderNode::FolderNodeWndProc
00098 (
00099   HWND   hWnd,     //[in] Handle to window
00100   UINT   uMsg,     //[in] Message identifier
00101   WPARAM wParam,   //[in] First message parameter
00102   LPARAM lParam    //[in] Second message parameter
00103 )
00104 {
00105   switch( uMsg )
00106   {
00107     case WM_CREATE:
00108     {
00109       LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00110       SetWindowLongPtr( hWnd, 0, (LONG_PTR)lpcs->lpCreateParams );
00111       break;
00112     }
00113
00114     case WM_ADD_VIRTUALFILE:
00115     {
00116       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00117       NODE_PROPERTIES* pProps = (NODE_PROPERTIES*)wParam;
00118       pThisNode->AddVirtualFile( pProps );
00119       break;
00120     }
00121
00122     case WM_VIRTUALFILE_CLOSED:
00123     {
00124       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00125       pThisNode->m_hAddVFileDlg = NULL;
00126     }
00127     default:
00128       return DefWindowProc( hWnd, uMsg, wParam, lParam );
00129   }
00130   return 0;
00131 }
00132
00133
00134 /////////////////////////////////////////////////////////////////////////////
00135 // Implementation of virtual methods
00136
00137 //---------------------------------------------------------------------------
00138 HRESULT CFolderNode::GetResultViewType2
00139 (
00140   MMC_COOKIE             nCookie,  //[in] Identifier of object
00141   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00142 )
00143 {
00144   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00145   if( NULL == pszDescStr )
00146     return E_OUTOFMEMORY;
00147
00148   wcscpy( pszDescStr, L"DefaultListView" );
00149   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00150
00151   return S_OK;
00152 }
00153
00154 //---------------------------------------------------------------------------
00155 HRESULT CFolderNode::GetDisplayInfo
00156 (
00157   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00158 )
00159 {
00160   _ASSERT( NULL != pSDI );
00161   pSDI->displayname = m_pwszNodeName;
00162
00163   return S_OK;
00164 }
00165
00166 //---------------------------------------------------------------------------
00167 HRESULT CFolderNode::GetDisplayInfo
00168 (
00169   RESULTDATAITEM* pRDI
00170 )
00171 {
00172   _ASSERT( NULL != pRDI );
00173
00174   HRESULT hResult = S_OK;
00175
00176   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00177   {                                  // for each column
00178     switch( pRDI->nCol )
00179     {
00180       case 0:
00181         pRDI->str = m_pwszNodeName;
00182         break;
00183
00184       case 1:                        // Attributes not supported yet
00185         pRDI->str = L"No attributes";
00186         break;
00187
00188       default:
00189         hResult = S_FALSE;
00190         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00191         break;
00192     }
00193   }
00194   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00195   {
00196     pRDI->nImage = m_SDI.nImage;
00197   }
00198
00199   //TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00200   return hResult;
00201
00202 }
00203
00204 /////////////////////////////////////////////////////////////////////////////
00205 // Implementation of notification handlers
00206
00207
00208 //---------------------------------------------------------------------------
00209 HRESULT CFolderNode::OnSelect
00210 (
00211   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00212   LONG          nArg,          //[in] Bools for context & selection state
00213   LONG          nParam,        //[in] Not used
00214   LONG_PTR      pComponent     //[in] Points calling CComponent
00215 )
00216 {
00217   HRESULT hResult = S_FALSE;
00218
00219   // Not setting verbs for this node
00220
00221   TRACE_HRESULT(_T("OnSelect"), hResult );
00222   return hResult;
00223 }
00224
00225
00226 //---------------------------------------------------------------------------
00227 HRESULT CFolderNode::OnShow
00228 (
00229   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00230   LONG          nArg,          //[in] TRUE if node was selcted
00231   LONG          nParam,        //[in] HSCOPEITEM of selected/deselected item
00232   LONG_PTR      pComponent     //[in] Points calling CComponent
00233 )
00234 {
00235   HRESULT  hResult = S_FALSE;
00236
00237   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00238
00239   LPHEADERCTRL2  ipHeaderCtrl = NULL;
00240   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL, (LONG_PTR*)&ipHeaderCtrl );
00241   if( S_OK != hResult )
00242    return hResult;
00243
00244   LPRESULTDATA  ipResultData = NULL;
00245   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00246   if( S_OK != hResult )
00247    return hResult;
00248
00249
00250   if( TRUE == nArg )         // Selecting a scope node
00251   {
00252     do
00253     {
00254       hResult = ipHeaderCtrl->InsertColumn( 0, L"File Name", 0, 150 );
00255       BREAK_ON_ERROR( hResult );
00256
00257       hResult = ipHeaderCtrl->InsertColumn( 1, L"Attributes", 0, 150 );
00258       BREAK_ON_ERROR( hResult );
00259
00260       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00261       BREAK_ON_ERROR( hResult );
00262
00263       hResult = EnumerateResultItems( ipResultData );
00264       BREAK_ON_ERROR( hResult );
00265
00266     }while(0);
00267   }
00268   else                       // When deselecting, clean up result items.
00269   {
00270     hResult = ipResultData->DeleteAllRsltItems();
00271   }
00272
00273   TRACE_HRESULT(_T("OnShow"), hResult );
00274   return hResult;
00275 }
00276
00277 //---------------------------------------------------------------------------
00278 HRESULT CFolderNode::OnExpand
00279 (
00280   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00281   LONG           nArg,         //[in] TRUE if node was selcted
00282   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00283   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00284 )
00285 {
00286   HRESULT hResult = S_FALSE;
00287
00288   if( NULL == m_pCompData )
00289     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00290
00291
00292   TRACE_HRESULT( _T("OnExpand"), hResult );
00293   return hResult;              // Not expanding anything
00294 }
00295
00296 //---------------------------------------------------------------------------
00297 HRESULT CFolderNode::OnRemoveChildren
00298 (
00299   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00300   LONG           nArg,         //[in] TRUE if node was selcted
00301   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00302   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00303 )
00304 {
00305   HRESULT hResult = S_OK;      // Just delete our child nodes, the
00306                                // corresponding result items are cleaned
00307   RemoveNodes();               // up in MMCN_SHOW -> FALSE
00308
00309   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00310   return hResult;
00311 }
00312
00313 //---------------------------------------------------------------------------
00314 HRESULT CFolderNode::OnViewChange
00315 (
00316   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00317   LONG           nArg,         //[in] TRUE if node was selcted
00318   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00319   LONG_PTR       pComponent    //[in] Points to calling IComponent
00320 )
00321 {
00322   HRESULT hResult = S_FALSE;
00323   LPRESULTDATA ipResultData = NULL;
00324
00325   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00326   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00327   if( S_OK != hResult )
00328     return hResult;
00329
00330   hResult = EnumerateResultItems( ipResultData );
00331
00332   TRACE_HRESULT( _T("OnViewChange"), hResult );
00333   return hResult;
00334 }
00335
00336
00337 /////////////////////////////////////////////////////////////////////////////
00338 //  Support for Context Menus
00339
00340 //---------------------------------------------------------------------------
00341 HRESULT CFolderNode::AddMenuItems
00342 (
00343   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00344   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00345 )
00346 {
00347   _ASSERT( NULL != ipCallback );
00348   HRESULT hResult = S_FALSE;
00349
00350   static CONTEXTMENUITEM ctxMenu;
00351     ctxMenu.lCommandID        = IDM_NEW_VIRTFILE;
00352     ctxMenu.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00353     ctxMenu.fSpecialFlags     = 0;
00354     ctxMenu.strName           = L"New Virtual File...";
00355     ctxMenu.strStatusBarText  = L"Add a new virtual file";
00356
00357
00358   if( NULL == m_hAddVFileDlg )     // If the AddVFile dialog is running
00359     ctxMenu.fFlags = 0;            // gray the menu selection
00360   else
00361     ctxMenu.fFlags = MF_GRAYED;
00362
00363
00364   // Add the 'New Device' option to the New menu if allowed...
00365   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00366   {
00367     hResult = ipCallback->AddItem( &ctxMenu );
00368   }
00369
00370   return hResult;
00371 }
00372
00373 //---------------------------------------------------------------------------
00374 HRESULT CFolderNode::Command
00375 (
00376   long lCommandID          //[in] Indentifier for menu ID
00377 )
00378 {
00379   HRESULT hResult = S_OK;
00380
00381   switch( lCommandID )
00382   {
00383     case IDM_NEW_VIRTFILE:
00384     {
00385       CAddVFileDlg* pDlg = new CAddVFileDlg( IDD_ADDVFILE_DLG, m_hMessageWnd );
00386       m_hAddVFileDlg = pDlg->Create( g_hInst, GetDesktopWindow(), 0 );
00387       break;
00388     }
00389     default:
00390     {
00391       hResult = S_FALSE;
00392       break;
00393     }
00394   }
00395   return hResult;
00396 }
00397
00398 /////////////////////////////////////////////////////////////////////////////
00399 //  Private helpers
00400
00401 //---------------------------------------------------------------------------
00402 HRESULT CFolderNode::RefreshNodeList()
00403 {
00404   NODE_PROPERTIES NodeProps;
00405   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00406   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00407   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00408   NodeProps.dwAttributes   = 0;
00409
00410   WCHAR  szNames[1][32];
00411   wcscpy( szNames[0], L"Virtual File 1" );
00412
00413   RemoveNodes();             // Clean the node list
00414
00415   CVirtualFile* pNode = NULL;
00416   for( DWORD i = 0; i < 1; i++ )
00417   {
00418     wcscpy( NodeProps.szNodeName, szNames[i] );
00419     pNode = new CVirtualFile;
00420     pNode->Initialize( &NodeProps );
00421     m_NodeList.AddTail( pNode );
00422   }
00423
00424   return S_OK;
00425 }
00426
00427 //---------------------------------------------------------------------------
00428 VOID CFolderNode::RemoveNodes()
00429 {
00430   CVirtualFile* pNode = NULL;
00431   POSITION      Pos   = m_NodeList.GetHeadPosition();
00432   while( Pos )
00433   {
00434     pNode = m_NodeList.GetNext( Pos );
00435     delete pNode;
00436   }
00437   m_NodeList.RemoveAll();              // Clean the list
00438 }
00439
00440 //---------------------------------------------------------------------------
00441 VOID CFolderNode::RemoveVirtualFile
00442 (
00443   CVirtualFile* pDeadNode    //[in] CVirtualFile to remove from list
00444 )
00445 {
00446   CVirtualFile* pNode = NULL;
00447   POSITION     NewPos = m_NodeList.GetHeadPosition();
00448   POSITION     OldPos = NULL;
00449   while( NewPos )
00450   {
00451     OldPos = NewPos;                   // Need to save this
00452     pNode = m_NodeList.GetNext( NewPos );
00453     if( pNode == pDeadNode )
00454     {
00455       m_NodeList.RemoveAt( OldPos );
00456       continue;                        // Exit, found it
00457     }
00458   }
00459 }
00460
00461 //---------------------------------------------------------------------------
00462 //  This is where OOP gets to be fun.
00463 //  We use the NodeProperties pointer which originally came from the
00464 //  modeless AddVFileDlg, by way of our hidden window, to create a new
00465 //  Virtual File node and add it to our linked list.
00466 //  This by itself will not cause the new node to be displayed.  To do
00467 //  that we need to call IResultData::InsertItem().  However we don't
00468 //  have a way to get that pointer.  So we have to be indirect.  We call
00469 //  IComponentData::QueryDataObject() to create a data object.  The data
00470 //  object points back to this node.  We can then pass that to
00471 //  IConsole2::UpdateAllViews().  This makes sure all instances of
00472 //  IComponent are called (there may me several running).  Then the
00473 //  MMCN_VIEW_CHANGE notification is delegated back to this node, along
00474 //  with a pointer to the correct IComponent.  With this pointer we can
00475 //  call GetInterface() to get an IResultData pointer which we can then
00476 //  pass to EnumerateResultItems() to display the new Virtual File.
00477 //
00478 HRESULT CFolderNode::AddVirtualFile
00479 (
00480   NODE_PROPERTIES* pProps    //[in] Properties of new node
00481 )
00482 {
00483   _ASSERT( NULL != pProps );
00484   HRESULT hResult = S_FALSE;
00485
00486   pProps->pParentObject  = reinterpret_cast<LONG_PTR>(this);
00487   pProps->pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00488
00489   CVirtualFile* pNode = NULL;
00490   pNode = new CVirtualFile;
00491   pNode->Initialize( pProps );
00492   m_NodeList.AddTail( pNode );
00493
00494   LPCONSOLE3 ipConsole = NULL;
00495   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole );
00496   if( S_OK != hResult )
00497     return hResult;
00498
00499   LPDATAOBJECT pDO = NULL;
00500   m_pCompData->QueryDataObject( (MMC_COOKIE)this, CCT_SCOPE, &pDO );
00501
00502   ipConsole->UpdateAllViews( pDO, 0, 0 );
00503   pDO->Release();
00504
00505   return hResult;
00506 }
00507
00508
00509 //---------------------------------------------------------------------------
00510 HRESULT CFolderNode::EnumerateResultItems
00511 (
00512   LPRESULTDATA ipResultData  //[in] Points to cached IResultData
00513 )
00514 {
00515   _ASSERT( NULL != ipResultData );
00516   HRESULT hResult = S_FALSE;
00517
00518   hResult = ipResultData->DeleteAllRsltItems();
00519
00520   CVirtualFile*  pNode = NULL;
00521   POSITION       Pos   = m_NodeList.GetHeadPosition();
00522   while( Pos )
00523   {
00524     pNode = m_NodeList.GetNext( Pos );
00525     hResult = ipResultData->InsertItem( &pNode->m_RDI );
00526   }
00527
00528   return hResult;
00529 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COptionsSheet Member List

This is the complete list of members for COptionsSheet, including all inherited members.
AddPage(CPropPageLite *pCPropPageLite) | CPropSheetLite | [virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
COptionsSheet() | COptionsSheet |
CPropSheetLite(TCHAR *ptszTitle=NULL, HICON hIcon=NULL) | CPropSheetLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DoModal(HWND hWndParent, INT nStartPage=0) | CPropSheetLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetBindingType(DBTYPE wNativeType=DBTYPE_UDT) | COptionsSheet |
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
LoadOptions() | COptionsSheet |
m_bUnicodeMsg | CWndLite |
m_CAccessor | COptionsSheet |
m_CCommand | COptionsSheet |
m_CDataSource | COptionsSheet |
m_CError | COptionsSheet |
m_CNotify | COptionsSheet |
m_CRowset | COptionsSheet |
m_cRowsToFetch | COptionsSheet |
m_dwAccessorOpts | COptionsSheet |
m_dwCLSCTX | COptionsSheet |
m_dwCommandOpts | COptionsSheet |
m_dwConvFlags | COptionsSheet |
m_dwCreateOpts | COptionsSheet |
m_dwMaxLength | COptionsSheet |
m_dwNotifyOpts | COptionsSheet |
m_dwRowsetOpts | COptionsSheet |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_psHeader | CPropSheetLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wBindingType | COptionsSheet | [protected]
m_wndPlacement | CWndLite |
m_wszRemoteServer | COptionsSheet |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SaveOptions() | COptionsSheet |
SetBindingType(DBTYPE wType) | COptionsSheet | [inline]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CPropSheetLite() | CPropSheetLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/DeskBand.h Source File

  • WinUI
  • Shell
  • BandObjs

DeskBand.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          DeskBand.h
00013
00014    Description:   CDeskBand definitions.
00015
00016 **************************************************************************/
00017
00018 #include <windows.h>
00019 #include <shlobj.h>
00020
00021 #include "Globals.h"
00022
00023 #ifndef DESKBAND_H
00024 #define DESKBAND_H
00025
00026 #define DB_CLASS_NAME (TEXT("DeskBandSampleClass"))
00027
00028 #define DB_MIN_SIZE_X   10
00029 #define DB_MIN_SIZE_Y   10
00030
00031 #define IDM_COMMAND  0
00032
00033 /**************************************************************************
00034
00035    CDeskBand class definition
00036
00037 **************************************************************************/
00038
00039 class CDeskBand : public IDeskBand,
00040                   public IInputObject,
00041                   public IObjectWithSite,
00042                   public IPersistStream,
00043                   public IContextMenu
00044 {
00045 protected:
00046    DWORD m_ObjRefCount;
00047
00048 public:
00049    CDeskBand();
00050    ~CDeskBand();
00051
00052    //IUnknown methods
00053    STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00054    STDMETHODIMP_(DWORD) AddRef();
00055    STDMETHODIMP_(DWORD) Release();
00056
00057    //IOleWindow methods
00058    STDMETHOD (GetWindow) (HWND*);
00059    STDMETHOD (ContextSensitiveHelp) (BOOL);
00060
00061    //IDockingWindow methods
00062    STDMETHOD (ShowDW) (BOOL fShow);
00063    STDMETHOD (CloseDW) (DWORD dwReserved);
00064    STDMETHOD (ResizeBorderDW) (LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
00065
00066    //IDeskBand methods
00067    STDMETHOD (GetBandInfo) (DWORD, DWORD, DESKBANDINFO*);
00068
00069    //IInputObject methods
00070    STDMETHOD (UIActivateIO) (BOOL, LPMSG);
00071    STDMETHOD (HasFocusIO) (void);
00072    STDMETHOD (TranslateAcceleratorIO) (LPMSG);
00073
00074    //IObjectWithSite methods
00075    STDMETHOD (SetSite) (IUnknown*);
00076    STDMETHOD (GetSite) (REFIID, LPVOID*);
00077
00078    //IPersistStream methods
00079    STDMETHOD (GetClassID) (LPCLSID);
00080    STDMETHOD (IsDirty) (void);
00081    STDMETHOD (Load) (LPSTREAM);
00082    STDMETHOD (Save) (LPSTREAM, BOOL);
00083    STDMETHOD (GetSizeMax) (ULARGE_INTEGER*);
00084
00085    //IContextMenu methods
00086    STDMETHOD (QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);
00087    STDMETHOD (InvokeCommand)(LPCMINVOKECOMMANDINFO);
00088    STDMETHOD (GetCommandString)(UINT_PTR, UINT, LPUINT, LPSTR, UINT);
00089
00090 private:
00091   BOOL m_bFocus;
00092   HWND m_hwndParent;
00093   HWND m_hWnd;
00094   DWORD m_dwViewMode;
00095    DWORD m_dwBandID;
00096    IInputObjectSite *m_pSite;
00097
00098 private:
00099   void FocusChange(BOOL);
00100    LRESULT OnKillFocus(void);
00101   LRESULT OnSetFocus(void);
00102   static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00103   LRESULT OnPaint(void);
00104   LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
00105   LRESULT OnSize(LPARAM);
00106    BOOL RegisterAndCreateWindow(void);
00107 };
00108
00109 #endif   //DESKBAND_H
00110
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/debug.h Source File

  • Com
  • async
  • server

debug.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #if !defined(_DEBUG_API_)
00019 #define _DEBUG_API_
00020 #include <tchar.h>
00021 #include <crtdbg.h>
00022 #include <malloc.h>
00023 #if defined(__cplusplus)
00024 extern "C" {
00025 #endif
00026
00027
00028
00029 #define CHAR_CONVERSION static int _convert = 0
00030 LPSTR WINAPI UniCode2Ansi(LPSTR lpa, LPCWSTR lpw, int nChars);
00031 LPWSTR WINAPI Ansi2Unicode(LPWSTR lpw, LPCSTR lpa, int nChars);
00032
00033 #define A2W(lpa) (\
00034   ((LPCSTR)lpa == NULL) ? NULL : (\
00035   _convert = (lstrlenA(lpa)+1),\
00036   Ansi2Unicode((LPWSTR) _alloca(_convert*2), lpa, _convert)))
00037
00038 #define W2A(lpw) (\
00039   ((LPCWSTR)lpw == NULL) ? NULL : (\
00040     _convert = (lstrlenW(lpw)+1),\
00041     UniCode2Ansi((LPSTR) _alloca(_convert), lpw, _convert)))
00042
00043
00044 #if defined(_DEBUG)
00045 void _cdecl DebugTrace(LPCTSTR lpszFormat, ...);
00046 #define DEBUGTRACE    DebugTrace
00047 #define CHECKPOINTER(p) if (!(p)) return E_POINTER
00048 #define RELEASEINTERFACE(p) do {(p)->Release(); (p) = NULL;} while(0)
00049 #else  // !_DEBUG
00050 __inline void DebugTrace(){}
00051 //#define DEBUGTRACE            1 ? (void)0 : DebugTrace
00052 //#define DEBUGTRACE            1 ? (void)0 : (void)0
00053 #ifdef WIN64
00054   #define DEBUGTRACE            __noop
00055   #define CHECKPOINTER(p) __noop
00056 #else
00057   #define DEBUGTRACE            (void)0
00058   #define CHECKPOINTER(p) (void)0
00059 #endif
00060 #define RELEASEINTERFACE(p) (p)->Release()
00061 #endif //_DEBUG
00062 #if defined(__cplusplus)
00063 }
00064 #endif
00065 #endif //_DEBUG_API_
00066
00067
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/NetProviders/LogonNP/LogonNP.c Source File

  • Security
  • NetProviders
  • LogonNP

LogonNP.c

Go to the documentation of this file.
00001 /*---------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 logonnp.cpp
00010 ---------------------------------------------------------------*/
00011
00012
00013 #define UNICODE
00014 #define _UNICODE
00015
00016 #include <windows.h>
00017 #include "npapi.h"
00018 #include "npaux.h"
00019
00020 #ifdef DEBUG
00021 BOOL WriteLogFile(LPTSTR String);
00022 #endif
00023
00024 //
00025 // The authentication type is only used here in a Unicode context
00026 //
00027 #define MSV1_0_AUTH_TYPE    L"MSV1_0:Interactive"
00028
00029 #ifdef DEBUG
00030 // Change this define to a legal location
00031 #define LOGFILE         TEXT("d:\\logonnp.log")
00032 #endif
00033
00034 BOOL
00035 WINAPI
00036 DllMain(
00037        HANDLE hInst,
00038        DWORD dwReason,
00039        LPVOID lpReserved
00040        )
00041 {
00042    if (dwReason == DLL_PROCESS_ATTACH)
00043    {
00044       DisableThreadLibraryCalls(hInst);
00045    }
00046
00047    return TRUE;
00048 }
00049
00050
00051 /****************************************************************************
00052    FUNCTION: NPGetCaps
00053
00054    PURPOSE:  This entry point is called to query the provider.  The parameter
00055              is an index representing the query.  For a credential manager
00056              only the following index values apply:
00057
00058              WNNC_SPEC_VERSION - What version of the provider specification
00059                 was used in developing this provider?  The return value is
00060                 the version number.
00061
00062              WNNC_DRIVER_VERSION - The version of the provider.
00063
00064              WNNC_START - Will the provider start? When? The return values
00065                 are:
00066
00067                     - 0 : Only return this if the provider will *not* start.
00068                     - Estimated Start time in milliseconds : This is how
00069                         long the provider is expected to take to start.
00070                     - 0xFFFFFFFF : Time to start is unknown.
00071                     - 1 : Provider is already started.
00072
00073              A return value of 0 in other cases indicates that the query
00074              is not supported.
00075
00076 *******************************************************************************/
00077 DWORD
00078 WINAPI
00079 NPGetCaps(
00080          DWORD nIndex
00081          )
00082 {
00083    DWORD dwRes;
00084
00085    switch (nIndex)
00086    {
00087
00088    case WNNC_NET_TYPE:
00089       dwRes = WNNC_CRED_MANAGER; // credential manager
00090       break;
00091
00092    case WNNC_SPEC_VERSION:
00093       dwRes = WNNC_SPEC_VERSION51;  // We are using version 5.1 of the spec.
00094       break;
00095
00096    case WNNC_DRIVER_VERSION:
00097       dwRes = 1;  // This driver is version 1.
00098       break;
00099
00100    case WNNC_START:
00101       dwRes = 1;  // We are already "started"
00102       break;
00103
00104    default:
00105       dwRes = 0;  // We don't support anything else
00106       break;
00107    }
00108
00109    return dwRes;
00110
00111 }
00112
00113
00114 /****************************************************************************
00115    FUNCTION: NPLogonNotify
00116
00117    PURPOSE:  This entry point is called when a user logs on.  If the user
00118              authentication fails here, the user will still be logged on
00119              to the local machine.
00120
00121 *******************************************************************************/
00122 DWORD
00123 WINAPI
00124 NPLogonNotify (
00125               PLUID               lpLogonId,
00126               LPCWSTR             lpAuthentInfoType,
00127               LPVOID              lpAuthentInfo,
00128               LPCWSTR             lpPreviousAuthentInfoType,
00129               LPVOID              lpPreviousAuthentInfo,
00130               LPWSTR              lpStationName,
00131               LPVOID              StationHandle,
00132               LPWSTR              *lpLogonScript
00133               )
00134 {
00135    PMSV1_0_INTERACTIVE_LOGON pAuthInfo;
00136
00137    #ifdef DEBUG
00138    TCHAR szBuf[1024];
00139
00140    // For debugging purposes only
00141    MessageBeep(0xFFFFFFFF);
00142
00143    //
00144    // Write out some information about the logon attempt
00145    //
00146    wsprintf(szBuf, L"lpAuthentInfoType=%s lpStationName=%s\r\n",
00147             lpAuthentInfoType, lpStationName);
00148
00149    WriteLogFile(szBuf);
00150    #endif
00151
00152
00153    //
00154    // If the primary authenticator is not MSV1_0, return success.
00155    // Why? Because this is the only auth info structure that we
00156    // understand and we don't want to interact with other types.
00157    //
00158    if ( lstrcmpiW (MSV1_0_AUTH_TYPE, lpAuthentInfoType) )
00159    {
00160
00161       #ifdef DEBUG
00162       wsprintf(szBuf, L"Authenticator is not MSV1_0 - Returning.\n");
00163
00164       WriteLogFile(szBuf);
00165       #endif
00166
00167       SetLastError(NO_ERROR);
00168       return NO_ERROR;
00169    }
00170
00171    //
00172    // Do something with the authentication information
00173    //
00174    pAuthInfo = (PMSV1_0_INTERACTIVE_LOGON) lpAuthentInfo;
00175
00176    #ifdef DEBUG
00177    wsprintf(szBuf, L"LogonDomain=%s User=%s\r\n",
00178             pAuthInfo->LogonDomainName.Buffer,
00179             pAuthInfo->UserName.Buffer);
00180
00181    WriteLogFile(szBuf);
00182    #endif
00183
00184    //
00185    // Let's utilize the logon script capability to display
00186    // our logon information
00187    //
00188
00189    // The Caller MUST free this memory
00190    *lpLogonScript = LocalAlloc(LPTR,1024);
00191
00192    #ifdef DEBUG
00193    wsprintf(*lpLogonScript,L"notepad %s",LOGFILE);
00194    #endif
00195
00196    return NO_ERROR;
00197 }
00198
00199
00200 /****************************************************************************
00201    FUNCTION: NPPasswordChangeNotify
00202
00203    PURPOSE:  This function is used to notify a credential manager provider
00204              of a password change (or, more accurately, an authentication
00205              information change) for an account.
00206
00207 *******************************************************************************/
00208 DWORD
00209 WINAPI
00210 NPPasswordChangeNotify (
00211                        LPCWSTR             lpAuthentInfoType,
00212                        LPVOID              lpAuthentInfo,
00213                        LPCWSTR             lpPreviousAuthentInfoType,
00214                        LPVOID              lpPreviousAuthentInfo,
00215                        LPWSTR              lpStationName,
00216                        LPVOID              StationHandle,
00217                        DWORD               dwChangeInfo
00218                        )
00219 {
00220
00221    return NO_ERROR;
00222 }
00223
00224 #ifdef DEBUG
00225 BOOL
00226 WriteLogFile(
00227             LPTSTR String
00228             )
00229 {
00230    HANDLE hFile;
00231    DWORD dwBytesWritten;
00232
00233    hFile = CreateFile(
00234                      LOGFILE,
00235                      GENERIC_WRITE,
00236                      0,
00237                      NULL,
00238                      OPEN_ALWAYS,
00239                      FILE_FLAG_SEQUENTIAL_SCAN,
00240                      NULL
00241                      );
00242
00243    if (hFile == INVALID_HANDLE_VALUE) return FALSE;
00244
00245    //
00246    // Seek to the end of the file
00247    //
00248    SetFilePointer(hFile, 0, NULL, FILE_END);
00249
00250    WriteFile(
00251             hFile,
00252             String,
00253             lstrlen(String)*sizeof(TCHAR),
00254             &dwBytesWritten,
00255             NULL
00256             );
00257
00258    CloseHandle(hFile);
00259
00260    return TRUE;
00261 }
00262 #endif
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventConsumer/Consumer.h Source File

  • SysMgmt
  • WMI
  • VC
  • EventConsumer

Consumer.h

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  Consumer.h
00006 //
00007 // Description: Event consumer class definition
00008 //
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #include <wbemcli.h>
00015 #include <wbemprov.h>
00016
00017 class CConsumer : public IWbemUnboundObjectSink
00018 {
00019 public:
00020   CConsumer(CListBox      *pOutputList);
00021   ~CConsumer();
00022
00023     // IUnknown members
00024     STDMETHODIMP         QueryInterface(REFIID, LPVOID *);
00025     STDMETHODIMP_(ULONG) AddRef(void);
00026     STDMETHODIMP_(ULONG) Release(void);
00027
00028     STDMETHOD(IndicateToConsumer)(IWbemClassObject *pLogicalConsumer,
00029                   long lNumObjects,
00030                   IWbemClassObject **ppObjects);
00031
00032 private:
00033
00034   DWORD m_cRef;
00035   LPCTSTR ErrorString(HRESULT hRes);
00036   LPWSTR ValueToString(VARIANT *pValue, WCHAR **pbuf);
00037   CListBox        *m_pOutputList;
00038 };
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/SerStrm.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

SerStrm.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright 1992 - 1998 Microsoft Corporation.
00004 //
00005 //  File:       serstrm.hxx
00006 //
00007 //  Contents:   Serial Stream
00008 //
00009 //  Classes:    CSerialStream
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #ifndef __SERSTRM_HXX__
00014 #define __SERSTRM_HXX__
00015
00016
00017 #include <inpstrm.hxx>
00018 #include <charhash.hxx>
00019
00020 const MAX_SPECIAL_CHAR_LENGTH = 20;   // Max length of a special char, such as &agrave;
00021
00022 //+---------------------------------------------------------------------------
00023 //
00024 //  Class:      CSerialStream
00025 //
00026 //  Purpose:    Memory mapped serial stream
00027 //
00028 //----------------------------------------------------------------------------
00029
00030 class CSerialStream
00031 {
00032
00033 public:
00034     CSerialStream();
00035
00036     void    Init( WCHAR *pwszFileName );
00037     WCHAR   GetChar();
00038     void    UnGetChar( WCHAR wch );
00039     BOOL    Eof();
00040
00041 private:
00042     BOOL    IsUnicodeNumber( WCHAR *pwcInputBuf,
00043                              unsigned uLen,
00044                              WCHAR& wch );
00045
00046     WCHAR                           _wch;                      // Char that was ungot
00047     BOOL                            _fUnGotChar;               // Was an UnGetChar called ?
00048     WCHAR                           _awcReadAheadBuf[MAX_SPECIAL_CHAR_LENGTH];    // Buffer for read ahead chars
00049     unsigned                        _cCharsReadAhead;          // # chars read ahead
00050     WCHAR *                         _pCurChar;                 // Current char in read ahead buffer
00051
00052     CMemoryMappedInputStream        _mmInputStream;            // Memory mapped input stream
00053     static CSpecialCharHashTable    _specialCharHash;          // Hash table for Latin I and other chars
00054 };
00055
00056 #endif  //  __SERSTRM_HXX__
00057
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/about.Cpp Source File

  • SysMgmt
  • MMC
  • CMenu

about.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));;
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163   MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164   *lpDest = wszStr;
00165
00166     return S_OK;
00167 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CNode< TYPE > Member List

This is the complete list of members for CNode< TYPE >, including all inherited members.
CNode(CNode *pPrevNode, CNode *pNextNode) | CNode< TYPE > |
CNode(TYPE val, CNode *pPrevNode, CNode *pNextNode) | CNode< TYPE > |
CNode(TYPE val, CNode *pPrevNode, CNode *pNextNode) | CNode< TYPE > |
m_data | CNode< TYPE > |
m_pNext | CNode< TYPE > |
m_pNextNode | CNode< TYPE > |
m_pPrev | CNode< TYPE > |
m_pPrevNode | CNode< TYPE > |
~CNode() | CNode< TYPE > | [virtual]
Generated on Wed Nov 13 2024 16:56:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/Resource.h Source File

  • WinUI
  • GlobalDev
  • CSSamp

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // include file.
00003 // Used by cssamp.rc
00004 //
00005 #define IDC_HORIZ                       1000
00006 #define IDC_VERT                        1001
00007 #define IDC_LTR                         1002
00008 #define IDC_RTL                         1003
00009 #define IDC_NEAR                        1004
00010 #define IDC_CENTER                      1005
00011 #define IDC_JUSTIFY                     1006
00012 #define IDC_FAR                         1007
00013 #define IDC_CONTROL_CHARS               1008
00014 #define IDC_NO_GLYPH_INDEX              1009
00015 #define IDC_HIGHLIGHT_FROM              1010
00016 #define IDC_HIGHLIGHT_TO                1011
00017 #define IDC_CODEPOINT                   1012
00018 #define IDC_INSERT_CODEPOINT            1013
00019 #define IDC_LOGICAL_ORDER               1014
00020 #define IDC_LOGICAL                     1018
00021 #define IDC_LOGICAL_WIDTH               1019
00022 #define IDC_LOGICAL_STYLES              1020
00023 #define IDC_PLAINTEXT                   1021
00024 #define IDC_PLAINTEXT_FONT              1024
00025 #define IDC_PLAINTEXT_SIZE              1025
00026 #define IDC_PLAINTEXT_BOLD              1026
00027 #define IDC_PLAINTEXT_ITALIC            1027
00028 #define IDC_PLAINTEXT_UNDERLINE         1028
00029 #define IDC_PLAINTEXT_CLIP              1029
00030 #define IDC_PLAINTEXT_FIT               1030
00031 #define IDC_PLAINTEXT_DX                1031
00032 #define IDC_PLAINTEXT_TAB               1032
00033 #define IDC_PLAINTEXT_FALLBACK          1033
00034 #define IDC_PLAINTEXT_LINK              1034
00035 #define IDC_PLAINTEXT_HOTKEY            1035
00036 #define IDC_PLAINTEXT_PASSWORD          1036
00037 #define IDC_FORMATTED                   1037
00038 #define IDC_FORMAT1                     1038
00039 #define IDC_CONTROL_CONTEXT             1039
00040 #define IDC_LANGUAGE                    1040
00041 #define IDC_LEGACY_BIDI                 1041
00042 #define IDC_OVERRIDE                    1042
00043 #define IDC_DIGIT_SUBSTITUTE            1043
00044 #define IDC_LINEFILL                    1044
00045 #define IDC_ARANUMCONTEXT               1045
00046 #define IDC_APPLYDIGITSUBST             1046
00047 #define IDC_PRESENTATION                1047
00048 #define IDC_SHOWLEVELS                  1048
00049 #define IDC_FANCY_FONT1                 1062
00050 #define IDC_FANCY_SIZE1                 1063
00051 #define IDC_FANCY_BOLD1                 1064
00052 #define IDC_FANCY_ITALIC1               1065
00053 #define IDC_FANCY_UNDERLINE1            1066
00054 #define IDC_FANCY_FONT2                 1067
00055 #define IDC_FANCY_SIZE2                 1068
00056 #define IDC_FANCY_BOLD2                 1069
00057 #define IDC_FANCY_ITALIC2               1070
00058 #define IDC_FANCY_UNDERLINE2            1071
00059 #define IDC_FANCY_FONT3                 1072
00060 #define IDC_FANCY_SIZE3                 1073
00061 #define IDC_FANCY_BOLD3                 1074
00062 #define IDC_FANCY_ITALIC3               1075
00063 #define IDC_FANCY_UNDERLINE3            1076
00064 #define IDC_FANCY_FONT4                 1077
00065 #define IDC_FANCY_SIZE4                 1078
00066 #define IDC_FANCY_BOLD4                 1079
00067 #define IDC_FANCY_ITALIC4               1080
00068 #define IDC_FANCY_UNDERLINE4            1081
00069 #define IDC_FORMAT2                     1087
00070 #define IDC_FORMAT3                     1090
00071 #define IDC_FORMAT4                     1091
00072 #define IDM_EXIT                        40001
00073
00074 // Next default values for new objects
00075 //
00076 #ifdef APSTUDIO_INVOKED
00077 #ifndef APSTUDIO_READONLY_SYMBOLS
00078 #define _APS_NEXT_RESOURCE_VALUE        105
00079 #define _APS_NEXT_COMMAND_VALUE         40002
00080 #define _APS_NEXT_CONTROL_VALUE         1049
00081 #define _APS_NEXT_SYMED_VALUE           101
00082 #endif
00083 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfcompart/resource.h Source File

  • WinUI
  • tsfcompart

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Compart.rc
00004 //
00005 #define IDD_DIALOG                      101
00006 #define IDC_CLOSE                       1000
00007 #define IDC_TEXT                        1001
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        102
00014 #define _APS_NEXT_COMMAND_VALUE         40001
00015 #define _APS_NEXT_CONTROL_VALUE         1002
00016 #define _APS_NEXT_SYMED_VALUE           101
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/foldernode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

foldernode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CFolderNode class.
00014 //
00015
00016
00017 #include "FolderNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CFolderNode")
00024
00025
00026 // Initialize our static GUID just once
00027 GUID CFolderNode::thisGUID = CLSID_CFolderNode;
00028
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // Construction/Destruction
00032
00033 CFolderNode::CFolderNode()
00034 {
00035   m_SDI.mask        = DEFAULT_SDI_MASK;
00036   m_SDI.displayname = MMC_CALLBACK;
00037   m_SDI.nImage      = IMG_FOLDER_DEFAULT;
00038   m_SDI.nOpenImage  = IMG_FOLDER_DEFAULT;
00039   m_SDI.cChildren   = 0;              // Determines if the '+' is displayed
00040   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00041
00042   m_dwAttributes    = 0;
00043   m_pCompData       = NULL;
00044 }
00045
00046
00047 CFolderNode::~CFolderNode()
00048 {
00049 }
00050
00051 //---------------------------------------------------------------------------
00052 //  This node does not make calls to it's parent so
00053 //  pNodeProps->pParentOject is ignored.
00054 //
00055 HRESULT CFolderNode::Initialize( NODE_PROPERTIES* pNodeProps )
00056 {
00057   _ASSERT( NULL != pNodeProps );
00058
00059   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00060   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00061   wcscpy( pszTmp, pNodeProps->szNodeName );
00062   if( NULL != m_pwszNodeName )
00063     CoTaskMemFree( m_pwszNodeName );
00064
00065   m_pwszNodeName = pszTmp;
00066   m_pCompData    = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00067
00068   return S_OK;
00069 }
00070
00071
00072 /////////////////////////////////////////////////////////////////////////////
00073 // Implementation of virtual methods
00074
00075 //---------------------------------------------------------------------------
00076 HRESULT CFolderNode::GetResultViewType2
00077 (
00078   MMC_COOKIE             nCookie,  //[in] Identifier of object
00079   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00080 )
00081 {
00082   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00083   if( NULL == pszDescStr )
00084     return E_OUTOFMEMORY;
00085
00086   wcscpy( pszDescStr, L"DefaultListView" );
00087   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00088
00089   return S_OK;
00090 }
00091
00092
00093 //---------------------------------------------------------------------------
00094 HRESULT CFolderNode::GetDisplayInfo
00095 (
00096   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00097 )
00098 {
00099   _ASSERT( NULL != pSDI );
00100   pSDI->displayname = m_pwszNodeName;
00101
00102   return S_OK;
00103 }
00104
00105 //---------------------------------------------------------------------------
00106 HRESULT CFolderNode::GetDisplayInfo
00107 (
00108   RESULTDATAITEM* pRDI
00109 )
00110 {
00111   _ASSERT( NULL != pRDI );
00112
00113   HRESULT hResult = S_OK;
00114
00115   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00116   {                                  // for each column
00117     switch( pRDI->nCol )
00118     {
00119       case 0:
00120         pRDI->str = m_pwszNodeName;
00121         break;
00122
00123       case 1:                        // Attributes not supported yet
00124         pRDI->str = L"No attributes";
00125         break;
00126
00127       default:
00128         hResult = S_FALSE;
00129         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00130         break;
00131     }
00132   }
00133   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00134   {
00135     pRDI->nImage = m_SDI.nImage;
00136   }
00137
00138   TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00139   return hResult;
00140
00141 }
00142
00143 /////////////////////////////////////////////////////////////////////////////
00144 // Implementation of notification handlers
00145
00146
00147 //---------------------------------------------------------------------------
00148 HRESULT CFolderNode::OnSelect
00149 (
00150   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00151   LONG          nArg,          //[in] Bools for context & selection state
00152   LONG          nParam,        //[in] Not used
00153   LONG_PTR      pComponent     //[in] Points calling CComponent
00154 )
00155 {
00156   HRESULT hResult = S_FALSE;
00157
00158   // Not setting verbs for this node
00159
00160   TRACE_HRESULT(_T("OnSelect"), hResult );
00161   return hResult;
00162 }
00163
00164
00165 //---------------------------------------------------------------------------
00166 HRESULT CFolderNode::OnShow
00167 (
00168   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00169   LONG          nArg,          //[in] TRUE if node was selcted
00170   LONG          nParam,        //[in] HSCOPEITEM of selected/deselected item
00171   LONG_PTR      pComponent     //[in] Points calling CComponent
00172 )
00173 {
00174   HRESULT  hResult = S_FALSE;
00175
00176   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00177
00178   LPHEADERCTRL2  ipHeaderCtrl2 = NULL;
00179   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL2, (LONG_PTR*)&ipHeaderCtrl2 );
00180   if( S_OK != hResult )
00181    return hResult;
00182
00183   LPRESULTDATA  ipResultData = NULL;
00184   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00185   if( S_OK != hResult )
00186    return hResult;
00187
00188
00189   ipHeaderCtrl2->AddRef();
00190   ipResultData->AddRef();
00191
00192   if( TRUE == nArg )  // Selecting a scope node
00193   {
00194     do
00195     {
00196       hResult = ipHeaderCtrl2->InsertColumn( 0, L"File Name", 0, 150 );
00197       BREAK_ON_ERROR( hResult );
00198
00199       hResult = ipHeaderCtrl2->InsertColumn( 1, L"Attributes", 0, 150 );
00200       BREAK_ON_ERROR( hResult );
00201
00202       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00203       BREAK_ON_ERROR( hResult );
00204
00205     }while(0);
00206   }
00207   else // not handling deselect notifications
00208   {
00209   }
00210
00211   ipHeaderCtrl2->Release();
00212   ipResultData->Release();
00213
00214   TRACE_HRESULT(_T("OnShow"), hResult );
00215   return hResult;
00216 }
00217
00218 //---------------------------------------------------------------------------
00219 HRESULT CFolderNode::OnExpand
00220 (
00221   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00222   LONG           nArg,         //[in] TRUE if node was selcted
00223   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00224   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00225 )
00226 {
00227   HRESULT hResult = S_FALSE;
00228
00229   if( NULL == m_pCompData )
00230     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00231
00232
00233   TRACE_HRESULT( _T("OnExpand"), hResult );
00234   return hResult;              // Not expanding anything
00235 }
00236
00237 //---------------------------------------------------------------------------
00238 HRESULT CFolderNode::OnRemoveChildren
00239 (
00240   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00241   LONG           nArg,         //[in] TRUE if node was selcted
00242   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00243   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00244 )
00245 {
00246   HRESULT hResult = S_FALSE;
00247
00248   // This method not used in this project
00249
00250   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00251   return hResult;
00252 }
00253
00254
00255 /////////////////////////////////////////////////////////////////////////////
00256 //  Support for Context Menus
00257
00258 //---------------------------------------------------------------------------
00259 HRESULT CFolderNode::AddMenuItems
00260 (
00261   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00262   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00263 )
00264 {
00265   return E_NOTIMPL;
00266 }
00267
00268 //---------------------------------------------------------------------------
00269 HRESULT CFolderNode::Command
00270 (
00271   long lCommandID          //[in] Indentifier for menu ID
00272 )
00273 {
00274   return E_NOTIMPL;
00275 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIRowsetChange Member List

This is the complete list of members for CImpIRowsetChange, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetChange) | CImpIRowsetChange
DeleteRows(HCHAPTER, DBCOUNTITEM, const HROW rghRows[], DBROWSTATUS rgRowStatus[]) | CImpIRowsetChange
InsertRow(HCHAPTER hChapter, HACCESSOR hAccessor, void *pData, HROW *phRow) | CImpIRowsetChange
SetData(HROW, HACCESSOR, void *) | CImpIRowsetChange
Generated on Wed Nov 13 2024 16:56:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ConnectPromptEnum Member List

This is the complete list of members for msado15::ConnectPromptEnum, including all inherited members.
adPromptAlways | msado15::ConnectPromptEnum | [static]
adPromptComplete | msado15::ConnectPromptEnum | [static]
adPromptCompleteRequired | msado15::ConnectPromptEnum | [static]
adPromptNever | msado15::ConnectPromptEnum | [static]
Generated on Wed Nov 13 2024 16:58:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/file.cpp Source File

  • Begin
  • sdkdiff

file.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * file.cpp
00013  *
00014  * an object representing a file and the lines of text it contains.
00015  *
00016  * a FILEDATA object is initialised with a DIRITEM handle from which it
00017  * can get a filename. It knows how to supply a list of LINE handles for the
00018  * lines of text in the file.
00019  *
00020  * The file is read into memory optionally on creation of the FILEDATA object:
00021  * otherwise, at the first call to file_getlinelist. It can be discarded
00022  * by calling file_discardlines: in this case, it will be re-read next time
00023  * file_getlinelist is called.
00024  *
00025  * calling file_reset will cause line_reset to be called for all lines
00026  * in the list. This clears any links and forces a recalc of line checksums.
00027  *
00028  * we allocate all memory using HeapAlloc
00029  *
00030  */
00031
00032 #include "precomp.h"
00033 #include "sdkdiff.h"
00034 #include "list.h"
00035 #include "line.h"
00036 #include "scandir.h"
00037 #include "file.h"
00038 #include "wdiffrc.h"
00039
00040 extern HANDLE hHeap;
00041
00042 /*
00043  * we return FILEDATA handles: these are pointers to a
00044  * filedata struct defined here.
00045  */
00046 struct filedata {
00047
00048     DIRITEM diritem;        /* handle to file name information */
00049     LIST lines;             /* NULL if lines not read in */
00050
00051     BOOL fUnicode;
00052 };
00053
00054
00055 void file_readlines(FILEDATA fd);
00056
00057 /*-- external functions ---------------------------------------------- */
00058
00059 /*
00060  * create a new filedata, given the DIRITEM handle which will give us
00061  * the file name. If bRead is TRUE, read the file into memory.
00062  */
00063 FILEDATA
00064 file_new(DIRITEM fiName, BOOL bRead)
00065 {
00066     FILEDATA fd;
00067
00068     fd = (FILEDATA) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct filedata));
00069     if (fd == NULL) {
00070         return(NULL);
00071     }
00072
00073     fd->diritem = fiName;
00074     fd->lines = NULL;
00075
00076     if (bRead) {
00077         file_readlines(fd);
00078     }
00079
00080     return(fd);
00081 }
00082
00083 /*
00084  * return a handle to the DIRITEM used to create this FILEDATA
00085  */
00086 DIRITEM
00087 file_getdiritem(FILEDATA fd)
00088 {
00089     if (fd == NULL) {
00090         return(NULL);
00091     }
00092
00093     return(fd->diritem);
00094 }
00095
00096
00097 /*
00098  * delete a filedata and its associated list of lines. note that the diritem
00099  * is not deleted (this is owned by the DIRLIST, and will be deleted
00100  * when the DIRLIST is deleted)
00101  */
00102 void
00103 file_delete(FILEDATA fd)
00104 {
00105     if (fd == NULL) {
00106         return;
00107     }
00108
00109     /* throw away the line list, if there is one */
00110     file_discardlines(fd);
00111
00112     HeapFree(GetProcessHeap(), NULL, fd);
00113 }
00114
00115 /*
00116  * return a handle to a list of lines in this file. the items in the
00117  * list are LINE handles.
00118  *
00119  * the first call to this function will cause the file to be read into
00120  * memory if bRead was FALSE on the call to file_new, or if file_discardlines
00121  * has since been called.
00122  *
00123  * the list of lines returned should not be deleted except by calls to
00124  * file_delete or file_discardlines.
00125  */
00126 LIST
00127 file_getlinelist(FILEDATA fd)
00128 {
00129     if (fd == NULL) {
00130         return NULL;
00131     }
00132
00133     if (fd->lines == NULL) {
00134         file_readlines(fd);
00135     }
00136     return(fd->lines);
00137 }
00138
00139
00140 /*
00141  * discard the list of lines associated with a file. this will cause
00142  * the file to be re-read next time file_getlinelist is called.
00143  */
00144 void
00145 file_discardlines(FILEDATA fd)
00146 {
00147     LINE line;
00148
00149     if (fd == NULL) {
00150         return;
00151     }
00152
00153     if (fd->lines != NULL) {
00154
00155         /* clear each line to free any memory associated
00156          * with them, then discard the entire list
00157          */
00158     for( line=(LINE)List_First(fd->lines);  line!=NULL;  line = (LINE)List_Next((LPVOID)line)) {
00159             line_delete(line);
00160         }
00161         List_Destroy(&fd->lines);
00162     }
00163
00164     /* this is probably done in List_Destroy, but better do it anyway*/
00165     fd->lines = NULL;
00166 }
00167
00168
00169 /*
00170  * force a reset of each line in the list. line_reset discards any
00171  * links between lines, and any hashcode information. This would be used if
00172  * the compare options or hashcode options have changed.
00173  */
00174 void
00175 file_reset(FILEDATA fd)
00176 {
00177     LINE line;
00178
00179     if (fd == NULL) {
00180         return;
00181     }
00182
00183     if (fd->lines != NULL) {
00184     for( line=(LINE)List_First(fd->lines);  line!=NULL;  line =(LINE) List_Next((LPVOID)line)) {
00185             line_reset(line);
00186         }
00187     }
00188 }
00189
00190 /*
00191  * return a checksum identical to one obtained through dir_getchecksum
00192  * This will recalculate it for local files.
00193  */
00194 DWORD
00195 file_checksum(FILEDATA fd)
00196 {
00197     return(dir_getchecksum(fd->diritem));
00198 }
00199
00200
00201 /*
00202  * Retrieve the checksum that we have for this file, valid or not.
00203  * Indicate in bValid whether it is actually valid or not.
00204  * Do NOT recalculate it or make any new attempt to read the file!
00205  */
00206 DWORD file_retrievechecksum(FILEDATA fd, BOOL * bValid)
00207 {
00208     if (dir_validchecksum(fd->diritem)) {
00209         *bValid = TRUE;
00210         return dir_getchecksum(fd->diritem);
00211     } else {
00212         *bValid = FALSE;
00213         return 0;
00214     }
00215 } /* file_retrievechecksum */
00216
00217
00218 /* retrieve the filetime for the file */
00219 FILETIME file_GetTime(FILEDATA fd)
00220 {  return dir_GetFileTime(fd->diritem);
00221 }
00222
00223 /* --- internal functions -------------------------------------------*/
00224
00225 /*
00226  * read the file into a list of lines.
00227  *
00228  * we use the buffered read functions to read a block at a time, and
00229  * return us a pointer to a line within the block. The line we are
00230  * pointed to is not null terminated. from this we do a line_new: this
00231  * will make a copy of the text (since we want to re-use the buffer), and
00232  * will null-terminate its copy.
00233  *
00234  * we also give each line a number, starting at one.
00235  */
00236 void
00237 file_readlines(FILEDATA fd)
00238 {
00239     LPSTR textp;
00240     LPWSTR pwzText;
00241     int cwch;
00242     HANDLE fh;
00243     FILEBUFFER fbuf;
00244     int linelen;
00245     int linenr = 1;
00246     HCURSOR hcurs;
00247
00248     hcurs = SetCursor(LoadCursor(NULL, IDC_WAIT));
00249
00250     /* open the file */
00251     fh = dir_openfile(fd->diritem);
00252
00253     if (fh == INVALID_HANDLE_VALUE) {
00254         TRACE_ERROR(LoadRcString(IDS_ERR_OPENING_FILE), FALSE);
00255         SetCursor(hcurs);
00256         return;
00257     }
00258     /* initialise the file buffering */
00259     fbuf = readfile_new(fh, &fd->fUnicode);
00260
00261     if (fbuf)
00262     {
00263         /* make an empty list for the files */
00264         fd->lines = List_Create();
00265
00266         while ( (textp = readfile_next(fbuf, &linelen, &pwzText, &cwch)) != NULL) {
00267             if (linelen>0) { /* readfile failure gives linelen==-1 */
00268                 line_new(textp, linelen, pwzText, cwch, linenr++, fd->lines);
00269             } else {
00270                 line_new("!! <unreadable> !!", 20, NULL, 0, linenr++,fd->lines);
00271                 break;
00272             }
00273
00274
00275         }
00276
00277         /* close filehandle and free buffer */
00278         readfile_delete(fbuf);
00279     }
00280
00281     dir_closefile(fd->diritem, fh);
00282
00283     SetCursor(hcurs);
00284 }
00285
00286 BOOL
00287 file_IsUnicode(FILEDATA fd)
00288 {
00289     return fd->fUnicode;
00290 }
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/Inc/PAPGUIDS.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • Inc

PAPGUIDS.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAPGUIDS.H
00003
00004   Summary:   This is the common include file for the GUIDs of drawing
00005              paper-related COM Interfaces and COM Objects. GUIDs are
00006              defined for the Interfaces and CLSIDs for the COM objects
00007              constructed using those interfaces.
00008
00009              This file is global to all the Tutorial Code Samples (kept
00010              in the ..\INC directory).  It is a good practice to
00011              factor out Interface and GUID specifications to reduce the
00012              possibility of GUID or interface conflicts.
00013
00014   Classes:   .
00015
00016   Functions: .
00017
00018   Origin:    8-24-97: atrent - Editor inheritance from BALLGUID.H.
00019                [Revised]
00020
00021 ----------------------------------------------------------------------------
00022   This file is part of the Microsoft COM Tutorial Code Samples.
00023
00024   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00025
00026   This source code is intended only as a supplement to Microsoft
00027   Development Tools and/or on-line documentation.  See these other
00028   materials for detailed information regarding Microsoft code samples.
00029
00030   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00031   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00032   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00033   PARTICULAR PURPOSE.
00034 ==========================================================================+*/
00035
00036 #if !defined(PAPGUIDS_H)
00037 #define PAPGUIDS_H
00038
00039 #if !defined(RC_INCLUDE)
00040
00041
00042 /*---------------------------------------------------------------------------
00043   Here are the IIDs for interfaces and the CLSIDs for the Class Factories
00044   of the drawing paper-related COM components in the STOSERVE, and
00045   STOCLIEN code samples.
00046 ---------------------------------------------------------------------------*/
00047 DEFINE_GUID(IID_IPaper,
00048   0x0002da30, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00049
00050 DEFINE_GUID(IID_IPaperSink,
00051   0x0002da34, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00052
00053 DEFINE_GUID(CLSID_DllPaper,
00054   0x0002da38, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00055
00056
00057 /*---------------------------------------------------------------------------
00058   Here are the IIDs for interfaces and the CLSIDs for the Class Factories
00059   of the drawing paper-related COM components in the DCDSERVE, and
00060   DCOMDRAW code samples.
00061 ---------------------------------------------------------------------------*/
00062 DEFINE_GUID(IID_ISharePaper,
00063   0x0002da31, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00064
00065 DEFINE_GUID(CLSID_SharePaper,
00066   0x0002da32, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00067
00068
00069 #endif // RC_INCLUDE
00070
00071 #endif // PAPGUIDS_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCOrder/Order.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCOrder

Order.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Order.h
00003   Summary:   Declaration of COrder class
00004   Classes:   Declared: COrder
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #ifndef __ORDER_H_
00023 #define __ORDER_H_
00024
00025 #include "resource.h"       // main symbols
00026
00027 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00028   ObjectClass: COrder
00029   Summary:     Writes an order into the Order Entry table.
00030          Sends order to shipping department.
00031   Interfaces:  IUnknown       Standard COM object feature interface
00032                IDispatch      Automation interface
00033              IOrder       Represents an order
00034   Aggregation: Not supported
00035 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00036
00037 class ATL_NO_VTABLE COrder :
00038   public CComObjectRootEx<CComSingleThreadModel>,
00039   public CComCoClass<COrder, &CLSID_Order>,
00040   public IDispatchImpl<IOrder, &IID_IOrder, &LIBID_QCORDERLib>
00041 {
00042 public:
00043   COrder() : m_lCustomerId(0), m_lOrderId(0)
00044   {
00045   }
00046
00047 DECLARE_REGISTRY_RESOURCEID(IDR_ORDER)
00048 DECLARE_NOT_AGGREGATABLE(COrder)
00049
00050 BEGIN_COM_MAP(COrder)
00051   COM_INTERFACE_ENTRY(IOrder)
00052   COM_INTERFACE_ENTRY(IDispatch)
00053 END_COM_MAP()
00054
00055 public: // IOrder methods
00056   STDMETHOD(Process)(long lFlags);
00057   STDMETHOD(LineItem)(long lItemId, long lQuantity);
00058   STDMETHOD(put_OrderId)(long lOrderId);
00059   STDMETHOD(put_CustomerId)(long lCustomerId);
00060
00061 private: // Member data and private helper methods
00062   long        m_lCustomerId;
00063   long        m_lOrderId;
00064   std::vector<long> m_veclItemId;
00065   std::vector<long> m_veclQuantity;
00066
00067   HRESULT WriteOrderDB();
00068   HRESULT InvokeShip(long lFlags);
00069   HRESULT InvokeShipIDispatch(IUnknown * punk, long lFlags);
00070   HRESULT InvokeShipVtable(IUnknown * punk, long lFlags);
00071 };
00072
00073 #endif //__ORDER_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/globals.cpp Source File

  • WinUI
  • TSFcase

globals.cpp

Go to the documentation of this file.
00001 //
00002 // globals.cpp
00003 //
00004 // Global variables.
00005 //
00006
00007 #include "globals.h"
00008
00009 HINSTANCE g_hInst;
00010
00011 LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat
00012
00013 CRITICAL_SECTION g_cs;
00014
00015 /* 6565d455-5030-4c0f-8871-83f6afde514f */
00016 const CLSID c_clsidCaseTextService = { 0x6565d455, 0x5030, 0x4c0f, {0x88, 0x71, 0x83, 0xf6, 0xaf, 0xde, 0x51, 0x4f} };
00017
00018 /* 4d5459db-7543-42c0-9204-9195b91f6fb8 */
00019 const GUID c_guidCaseProfile = { 0x4d5459db, 0x7543, 0x42c0, {0x92, 0x04, 0x91, 0x95, 0xb9, 0x1f, 0x6f, 0xb8} };
00020
00021 /* 01679c88-5141-4ee5-a47f-c8d586ff37e1 */
00022 const GUID c_guidLangBarItemButton = { 0x01679c88, 0x5141, 0x4ee5, {0xa4, 0x7f, 0xc8, 0xd5, 0x86, 0xff, 0x37, 0xe1} };
00023
00024 //+---------------------------------------------------------------------------
00025 //
00026 // ToggleChar
00027 //
00028 // Toggle the case of a single char.
00029 //----------------------------------------------------------------------------
00030
00031 WCHAR ToggleChar(WCHAR ch)
00032 {
00033     // toggle english ascii
00034     if ((ch >= 'a' && ch <= 'z') ||
00035         (ch >= 'A' && ch <= 'Z'))
00036     {
00037         return ch ^ 32;
00038     }
00039
00040     // give up for non-ascii
00041     return ch;
00042 }
00043
00044 //+---------------------------------------------------------------------------
00045 //
00046 // ToggleCase
00047 //
00048 // Toggle the case of all text covered by the range.  The input range is
00049 // collapsed to its end point on exit.
00050 //
00051 // If fIgnoreRangeEnd == TRUE, all text following the start of range will be
00052 // toggled, and the range will be collapsed at the end-of-doc on exit.
00053 //----------------------------------------------------------------------------
00054
00055 void ToggleCase(TfEditCookie ec, ITfRange *pRange, BOOL fIgnoreRangeEnd)
00056 {
00057     ITfRange *pRangeToggle;
00058     ULONG cch;
00059     ULONG i;
00060     DWORD dwFlags;
00061     WCHAR achText[64];
00062
00063     // backup the current range
00064     if (pRange->Clone(&pRangeToggle) != S_OK)
00065         return;
00066
00067     dwFlags = TF_TF_MOVESTART | (fIgnoreRangeEnd ? TF_TF_IGNOREEND : 0);
00068
00069     while (TRUE)
00070     {
00071         // grab the next block of chars
00072         if (pRange->GetText(ec, dwFlags, achText, ARRAYSIZE(achText), &cch) != S_OK)
00073             break;
00074
00075         // out of text?
00076         if (cch == 0)
00077             break;
00078
00079         // toggle the case
00080         for (i=0; i<cch; i++)
00081         {
00082             achText[i] = ToggleChar(achText[i]);
00083         }
00084
00085         // shift pRangeToggle so it covers just the text we read
00086         if (pRangeToggle->ShiftEndToRange(ec, pRange, TF_ANCHOR_START) != S_OK)
00087             break;
00088
00089         // replace the text
00090         pRangeToggle->SetText(ec, 0, achText, cch);
00091
00092         // prepare for next iteration
00093         pRangeToggle->Collapse(ec, TF_ANCHOR_END);
00094     }
00095
00096     pRangeToggle->Release();
00097 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/statnode.h Source File

  • SysMgmt
  • MMC
  • ActiveX

statnode.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _STATICNODE_H
00021 #define _STATICNODE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CStaticNode : public CDelegationBase {
00026 public:
00027     CStaticNode(CComponentData *pComponentData = NULL);
00028
00029     virtual ~CStaticNode();
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) {
00032         static _TCHAR szDisplayName[256];
00033         LoadString(g_hinst, IDS_SNAPINNAME, szDisplayName, (sizeof szDisplayName)/(sizeof szDisplayName[0]));
00034         return szDisplayName;
00035     }
00036     virtual const GUID & getNodeType() { return thisGuid; }
00037     virtual const int GetBitmapIndex() { return INDEX_NONE; }
00038
00039     virtual HRESULT Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00040
00041 private:
00042     enum { NUMBER_OF_CHILDREN = 4 };
00043     CDelegationBase *children[NUMBER_OF_CHILDREN];
00044
00045     // {2974380C-4C4B-11d2-89D8-000021473128}
00046     static const GUID thisGuid;
00047 };
00048
00049 #endif // _STATICNODE_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBox Member List

This is the complete list of members for CBox, including all inherited members.
_Alias | CBox | [protected]
_Block | CBox | [protected]
_bxf | CBox | [protected]
_fontBlock | CBox | [protected]
_fuFormat | CBox | [protected]
_iChar | CBox | [protected]
_sizeBox | CBox | [protected]
CBox(CBoxFormat &bxf, UINT iChar, HFONT hfont) | CBox |
GetSize() | CBox | [inline]
Hittest(CCanvas &canvas, POINT pt) | CBox |
Paint(CCanvas &canvas, POINT pt, RECT rc) | CBox |
SetFormat(UINT fuFormat) | CBox | [inline]
Generated on Wed Nov 13 2024 16:55:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/perstor.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

perstor.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /******************************************************************************
00019
00020   File:          PerStor.h
00021
00022   Description:   CPersistStorage definitions.
00023
00024 ******************************************************************************/
00025
00026 #ifndef PERSISTSTORAGE_H
00027 #define PERSISTSTORAGE_H
00028
00029 /**************************************************************************
00030 #include statements
00031 **************************************************************************/
00032
00033 #include "DOServer.h"
00034
00035 /**************************************************************************
00036
00037   CPersistStorage class definition
00038
00039 **************************************************************************/
00040
00041 class COleDocument;
00042
00043 class CPersistStorage : public IPersistStorage
00044 {
00045   friend class CPersistFile;
00046
00047 private:
00048   COleDocument   *m_pOleDoc;
00049   LPSTORAGE      m_pStorage;
00050   LPSTREAM       m_pColorStream;
00051   BOOL           m_fSameAsLoad;
00052
00053 public:
00054   CPersistStorage(COleDocument*);
00055   ~CPersistStorage();
00056
00057   //IUnknown methods
00058   STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00059   STDMETHODIMP_(DWORD) AddRef();
00060   STDMETHODIMP_(DWORD) Release();
00061
00062   //IPersistStorage methods
00063   STDMETHODIMP InitNew(LPSTORAGE);
00064   STDMETHODIMP GetClassID(LPCLSID);
00065   STDMETHODIMP Save(LPSTORAGE, BOOL);
00066   STDMETHODIMP SaveCompleted(LPSTORAGE);
00067   STDMETHODIMP Load(LPSTORAGE);
00068   STDMETHODIMP IsDirty();
00069   STDMETHODIMP HandsOffStorage();
00070
00071 private:
00072   void ReleaseStreamsAndStorage();
00073   void OpenStreams(LPSTORAGE);
00074   void CreateStreams(LPSTORAGE);
00075   void CreateStreams(LPSTORAGE, LPSTREAM*);
00076
00077 };
00078
00079 #endif   //PERSISTSTORAGE_H
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDisdrawApp Member List

This is the complete list of members for CDisdrawApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CDisdrawApp() | CDisdrawApp |
CDisdrawApp() | CDisdrawApp |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CDisdrawApp | [virtual]
InitInstance() | CDisdrawApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:56:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/scripts.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

scripts.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _SCRIPTS_DEFINED_HEADER_
00015 #define _SCRIPTS_DEFINED_HEADER_
00016
00017
00018 /////////////////////////////////////////////////////////////////////////////
00019 //  These are mini-scripts which can be used to build larger scripts for
00020 //  nodes which use a View Extension.
00021
00022
00023
00024 //---------------------------------------------------------------------------
00025 //  Define the begining and ending of the form
00026 //
00027 LPWSTR GSCRP_BEGIN_FORM     =  L"<BODY><FORM>";
00028 LPWSTR GSCRP_END_FORM       =  L"</BODY></FORM>";
00029
00030
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 //  In these scripts 'external' is a predefined alias for a View Object.
00034 //  These can call methods which have a context menu item.
00035
00036
00037 //---------------------------------------------------------------------------
00038 //  Displays a 'Rename' button.  The script brings up a dialog to get the
00039 //  new name for the node.  The call to external.RenameSelectedItem() will
00040 //  cause MMC to send a MMCN_RENAME notification which can be handled in
00041 //  the normal way.
00042 //
00043 LPWSTR GSCRP_RENAME_BUTTON  =
00044              L"<INPUT TYPE='BUTTON' NAME='btnRename' VALUE='Rename'>"
00045              L"<SCRIPT FOR='btnRename' EVENT='onClick' LANGUAGE='VBScript'>"
00046              L"Dim filename\n"
00047              L"filename=InputBox(\"Enter the new file name\")\n"
00048              L"external.RenameSelectedItem( filename )\n"
00049              L"</SCRIPT>"
00050              L"<BR><BR>";
00051
00052
00053 //---------------------------------------------------------------------------
00054 //  Displays a 'Delete' button.  When the button is clicked the Snap-in will
00055 //  recieve a MMCN_DELETE notification.
00056 //
00057 LPWSTR GSCRP_DELETE_BUTTON  =
00058              L"<INPUT TYPE='BUTTON' NAME='btnDelete' VALUE='Delete'>"
00059              L"<SCRIPT FOR='btnDelete' EVENT='onClick' LANGUAGE='VBScript'>"
00060              L"external.DeleteSelection()\n"
00061              L"</SCRIPT>"
00062              L"<BR><BR>";
00063
00064 //---------------------------------------------------------------------------
00065 //  Displays the text "Link to Corporate Home Page" as a link.  Link takes
00066 //  you to Microsoft.com but you can go somewhere else if you really want to.
00067 //  Note:  "target = "_blank" causes the link to open in a new window.
00068 //
00069 //
00070 LPWSTR GSCRP_LINK_HOMEPAGE  =
00071              L"<a HREF = \"http://www.microsoft.com\" target = \"_blank\">"
00072              L"Link to Corporate Home Page</a></p>"
00073              L"<BR>";
00074
00075
00076 #endif // _SCRIPTS_DEFINED_HEADER_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/EnumStreams/FindStream.h Source File

  • WinBase
  • IO
  • EnumStreams

FindStream.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 ----------------------------------------------------------------*/
00010
00011 // it is assumed that windows.h and tchar.h have been included before this file
00012
00013 #if !defined(_FINDSTREAM_H)
00014
00015    #define _FINDSTREAM_H
00016
00017    #pragma once
00018
00019 typedef struct _STREAM_FIND_DATA
00020 {
00021    LARGE_INTEGER Size;
00022    TCHAR cStreamName[MAX_PATH];
00023 } STREAM_FIND_DATA, *LPSTREAM_FIND_DATA;
00024
00025 HANDLE FindFirstStream(LPCTSTR lpFileName, LPSTREAM_FIND_DATA lpFindStreamData);
00026 BOOL FindNextStream(HANDLE hFindStream, LPSTREAM_FIND_DATA lpFindStreamData);
00027 BOOL FindCloseStream(HANDLE hFindStream);
00028
00029 #endif
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Handler.Cpp Source File

  • NetDS
  • SyncMgr
  • SyncDir

Handler.Cpp

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #include "precomp.h"
00013
00014 extern UINT      g_cRefThisDll;    // Reference count of this DLL.
00015 extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
00016 extern CSettings *g_pSettings;  // ptr to global settings class.
00017
00018 //+---------------------------------------------------------------------------
00019 //
00020 //  Member:     CSyncMgrHandler::CSyncMgrHandler, public
00021 //
00022 //  Synopsis:   Constructor
00023 //
00024 //  Arguments:
00025 //
00026 //  Returns:
00027 //
00028 //  Modifies:
00029 //
00030 //----------------------------------------------------------------------------
00031
00032 CSyncMgrHandler::CSyncMgrHandler()
00033 {
00034     g_cRefThisDll++;
00035
00036     m_cRef = 1;
00037     m_phThread = NULL;
00038     m_pSyncMgrSynchronizeCallback = NULL;
00039     m_pItemsToSyncList = NULL;
00040     m_dwSyncFlags = 0;
00041     m_hwndWorker = FALSE;
00042     m_hwndHandler = FALSE;
00043     m_fSynchronizing = FALSE;
00044     m_fPrepareForSync = FALSE;
00045     m_fStopped = FALSE;
00046
00047 }
00048
00049
00050 //+---------------------------------------------------------------------------
00051 //
00052 //  Member:     CSyncMgrHandler::~CSyncMgrHandler, public
00053 //
00054 //  Synopsis:   Destructor
00055 //
00056 //  Arguments:
00057 //
00058 //  Returns:
00059 //
00060 //  Modifies:
00061 //
00062 //----------------------------------------------------------------------------
00063
00064 CSyncMgrHandler::~CSyncMgrHandler()
00065 {
00066     Assert(NULL == m_pSyncMgrSynchronizeCallback);
00067
00068     Assert(NULL == m_pItemsToSyncList);
00069
00070
00071     if (m_phThread)
00072     {
00073     HANDLE hThread = m_phThread;
00074
00075         m_phThread = NULL;
00076
00077         PostMessage(m_hwndWorker,WM_WORKERMSG_RELEASE,0,0);
00078
00079         WaitForSingleObject(hThread,INFINITE); // wait for thread to go away
00080         CloseHandle(hThread);
00081     }
00082
00083     if (m_hwndHandler)
00084     {
00085         DestroyWindow(m_hwndHandler);
00086         m_hwndHandler = NULL;
00087     }
00088
00089     g_cRefThisDll--;
00090 }
00091
00092
00093 //+---------------------------------------------------------------------------
00094 //
00095 //  Member:     CSyncMgrHandler::QueryInteface, public
00096 //
00097 //  Synopsis:
00098 //
00099 //  Arguments:
00100 //
00101 //  Returns:
00102 //
00103 //  Modifies:
00104 //
00105 //----------------------------------------------------------------------------
00106
00107 STDMETHODIMP CSyncMgrHandler::QueryInterface(REFIID riid, LPVOID FAR *ppv)
00108 {
00109     *ppv = NULL;
00110
00111     if (IsEqualIID(riid, IID_IUnknown))
00112     {
00113         *ppv = (LPUNKNOWN)this;
00114     }
00115     else if (IsEqualIID(riid, IID_ISyncMgrSynchronize))
00116     {
00117         *ppv = (LPSYNCMGRSYNCHRONIZE)this;
00118     }
00119     if (*ppv)
00120     {
00121         AddRef();
00122
00123         return NOERROR;
00124     }
00125
00126     return E_NOINTERFACE;
00127 }
00128
00129 //+---------------------------------------------------------------------------
00130 //
00131 //  Member:     CSyncMgrHandler::AddRef, public
00132 //
00133 //  Synopsis:
00134 //
00135 //  Arguments:
00136 //
00137 //  Returns:
00138 //
00139 //  Modifies:
00140 //
00141 //----------------------------------------------------------------------------
00142
00143 STDMETHODIMP_(ULONG) CSyncMgrHandler::AddRef()
00144 {
00145     return ++m_cRef;
00146 }
00147
00148 //+---------------------------------------------------------------------------
00149 //
00150 //  Member:     CSyncMgrHandler::Release, public
00151 //
00152 //  Synopsis:
00153 //
00154 //  Arguments:
00155 //
00156 //  Returns:
00157 //
00158 //  Modifies:
00159 //
00160 //----------------------------------------------------------------------------
00161
00162 STDMETHODIMP_(ULONG) CSyncMgrHandler::Release()
00163 {
00164     if (--m_cRef)
00165         return m_cRef;
00166
00167    delete this;
00168
00169    return 0L;
00170 }
00171
00172
00173 //+---------------------------------------------------------------------------
00174 //
00175 //  Member:     CSyncMgrHandler::Initialize, public
00176 //
00177 //  Synopsis:
00178 //
00179 //  Arguments:
00180 //
00181 //  Returns:
00182 //
00183 //  Modifies:
00184 //
00185 //----------------------------------------------------------------------------
00186
00187 STDMETHODIMP CSyncMgrHandler::Initialize(DWORD dwReserved,DWORD dwSyncFlags,
00188                     DWORD cbCookie,const BYTE *lpCooke)
00189 {
00190 HRESULT hr = NOERROR;
00191
00192     m_dwSyncFlags = dwSyncFlags;
00193
00194     RegisterHandlerWndClasses();
00195
00196     // create hwnd for main class.
00197     m_hwndHandler = CreateWindowEx(0,
00198               SZ_SAMPLESYNCMGRHANDLERWNDCLASS,
00199               TEXT(""),
00200               // must use WS_POPUP so the window does not get
00201               // assigned a hot key by user.
00202               (WS_DISABLED | WS_POPUP),
00203               CW_USEDEFAULT,
00204               CW_USEDEFAULT,
00205               CW_USEDEFAULT,
00206               CW_USEDEFAULT,
00207               NULL,
00208               NULL,
00209               g_hmodThisDll,
00210               this);
00211
00212     if (NULL == m_hwndHandler)
00213     {
00214         hr =  E_UNEXPECTED;
00215     }
00216
00217
00218     if (NOERROR == hr)
00219     {
00220         hr = CreateWorkerThread();
00221     }
00222
00223     // if hr is not NOERROR then clean up.
00224     if (NOERROR != hr)
00225     {
00226         if (m_phThread)
00227         {
00228         HANDLE hThread = m_phThread;
00229
00230             m_phThread = NULL;
00231
00232             PostMessage(m_hwndWorker,WM_WORKERMSG_RELEASE,0,0);
00233
00234             WaitForSingleObject(hThread,INFINITE); // wait for thread to go away
00235             CloseHandle(hThread);
00236         }
00237
00238         if (m_hwndHandler)
00239         {
00240             DestroyWindow(m_hwndHandler);
00241             m_hwndHandler = NULL;
00242         }
00243
00244     }
00245
00246
00247     return hr;
00248 }
00249
00250 //+---------------------------------------------------------------------------
00251 //
00252 //  Member:     CSyncMgrHandler::CreateWorkerThread, private
00253 //
00254 //  Synopsis:
00255 //
00256 //  Arguments:
00257 //
00258 //  Returns:
00259 //
00260 //  Modifies:
00261 //
00262 //----------------------------------------------------------------------------
00263
00264 HRESULT CSyncMgrHandler::CreateWorkerThread()
00265 {
00266 HRESULT hr = E_FAIL;
00267 HANDLE hNewThread = NULL;
00268 DWORD dwThreadID;
00269 WorkerThreadArgs ThreadArgs;
00270
00271
00272     ThreadArgs.hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
00273     ThreadArgs.pThis = this;
00274
00275     if (ThreadArgs.hEvent)
00276     {
00277     hNewThread = CreateThread(NULL,0,WorkerThread,&ThreadArgs,0,&dwThreadID);
00278
00279     if (hNewThread)
00280     {
00281        WaitForSingleObject(ThreadArgs.hEvent,INFINITE);
00282        if (NOERROR == ThreadArgs.hr)
00283        {
00284                 m_hwndWorker = ThreadArgs.hwnd;
00285                 m_phThread = hNewThread;
00286         hr = NOERROR;
00287        }
00288        else
00289        {
00290         CloseHandle(hNewThread);
00291         hr = ThreadArgs.hr;
00292        }
00293
00294     }
00295     else
00296     {
00297         hr = GetLastError();
00298     }
00299
00300     CloseHandle(ThreadArgs.hEvent);
00301     }
00302
00303     return hr;
00304 }
00305
00306
00307 //+---------------------------------------------------------------------------
00308 //
00309 //  Member:     CSyncMgrHandler::GetHandlerInfo, public
00310 //
00311 //  Synopsis:
00312 //
00313 //  Arguments:
00314 //
00315 //  Returns:
00316 //
00317 //  Modifies:
00318 //
00319 //----------------------------------------------------------------------------
00320
00321 STDMETHODIMP CSyncMgrHandler::GetHandlerInfo(LPSYNCMGRHANDLERINFO *ppSyncMgrHandlerInfo)
00322 {
00323 LPSYNCMGRHANDLERINFO pSyncInfo;
00324
00325     if (!ppSyncMgrHandlerInfo)
00326     {
00327         Assert(ppSyncMgrHandlerInfo)
00328         return E_INVALIDARG;
00329     }
00330
00331     pSyncInfo = (LPSYNCMGRHANDLERINFO) CoTaskMemAlloc(sizeof(SYNCMGRHANDLERINFO));
00332
00333     if (pSyncInfo)
00334     {
00335         pSyncInfo->cbSize = sizeof(SYNCMGRHANDLERINFO);
00336         pSyncInfo->hIcon = LoadIcon(g_hmodThisDll,MAKEINTRESOURCE(IDI_SAMPLEHANDLERICON));
00337         pSyncInfo->SyncMgrHandlerFlags = SYNCMGRHANDLER_HASPROPERTIES;
00338         pSyncInfo->SyncMgrHandlerFlags |= SYNCMGRHANDLER_ALWAYSLISTHANDLER;
00339         lstrcpyW(pSyncInfo->wszHandlerName,L"Sample Handler");
00340     }
00341
00342     *ppSyncMgrHandlerInfo = pSyncInfo;
00343
00344     return *ppSyncMgrHandlerInfo ? NOERROR : E_OUTOFMEMORY;
00345 }
00346
00347
00348 //+---------------------------------------------------------------------------
00349 //
00350 //  Member:     CSyncMgrHandler::GetItemObject, public
00351 //
00352 //  Synopsis:
00353 //
00354 //  Arguments:
00355 //
00356 //  Returns:
00357 //
00358 //  Modifies:
00359 //
00360 //----------------------------------------------------------------------------
00361
00362 STDMETHODIMP CSyncMgrHandler::GetItemObject(REFSYNCMGRITEMID ItemID,REFIID riid,void** ppv)
00363 {
00364
00365     return E_NOTIMPL;
00366 }
00367
00368 //+---------------------------------------------------------------------------
00369 //
00370 //  Member:     CSyncMgrHandler::EnumSyncMgrItems, public
00371 //
00372 //  Synopsis:
00373 //
00374 //  Arguments:
00375 //
00376 //  Returns:
00377 //
00378 //  Modifies:
00379 //
00380 //----------------------------------------------------------------------------
00381
00382 STDMETHODIMP CSyncMgrHandler::EnumSyncMgrItems(ISyncMgrEnumItems** ppenumOffineItems)
00383 {
00384
00385     Assert(g_pSettings);
00386
00387     if (g_pSettings)
00388     {
00389         return g_pSettings->EnumSyncMgrItems(ppenumOffineItems);
00390     }
00391
00392     return E_UNEXPECTED;
00393 }
00394
00395 //+---------------------------------------------------------------------------
00396 //
00397 //  Member:     CSyncMgrHandler::ShowProperties, public
00398 //
00399 //  Synopsis:
00400 //
00401 //  Arguments:
00402 //
00403 //  Returns:
00404 //
00405 //  Modifies:
00406 //
00407 //----------------------------------------------------------------------------
00408
00409 STDMETHODIMP CSyncMgrHandler::ShowProperties(HWND hWndParent,REFSYNCMGRITEMID ItemID)
00410 {
00411 METHODARGS *pMethodArgs;
00412
00413     pMethodArgs = (METHODARGS*) ALLOC(sizeof(METHODARGS));
00414
00415     if (NULL == pMethodArgs)
00416     {
00417         Assert(pMethodArgs);
00418         return E_OUTOFMEMORY;
00419     }
00420
00421     pMethodArgs->fAsync = TRUE;
00422     pMethodArgs->dwWorkerMsg = WM_WORKERMSG_SHOWPROPERTIES;
00423     pMethodArgs->ShowPropertiesMsg.hWndParent = hWndParent;
00424     pMethodArgs->ShowPropertiesMsg.ItemID = ItemID;
00425
00426     PostMessage(m_hwndWorker,WM_WORKERMSG_SHOWPROPERTIES,0,(LPARAM) pMethodArgs);
00427
00428     return NOERROR;
00429 }
00430
00431 //+---------------------------------------------------------------------------
00432 //
00433 //  Member:     CSyncMgrHandler::ShowPropertiesCall, private
00434 //
00435 //  Synopsis:   Called on WorkerThread
00436 //
00437 //  Arguments:
00438 //
00439 //  Returns:
00440 //
00441 //  Modifies:
00442 //
00443 //----------------------------------------------------------------------------
00444
00445 void CSyncMgrHandler::ShowPropertiesCall(HWND hWndParent,REFSYNCMGRITEMID ItemID)
00446 {
00447 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
00448 HRESULT hr = NOERROR;
00449
00450     Assert(g_pSettings);
00451
00452     if (g_pSettings)
00453     {
00454         hr = g_pSettings->ShowProperties(hWndParent,ItemID);
00455     }
00456
00457     if (pCallback)
00458     {
00459         pCallback->ShowPropertiesCompleted(hr);
00460         pCallback->Release();
00461     }
00462
00463     return;
00464 }
00465
00466 //+---------------------------------------------------------------------------
00467 //
00468 //  Member:     CSyncMgrHandler::SetProgressCallback, public
00469 //
00470 //  Synopsis:
00471 //
00472 //  Arguments:
00473 //
00474 //  Returns:
00475 //
00476 //  Modifies:
00477 //
00478 //----------------------------------------------------------------------------
00479
00480 STDMETHODIMP CSyncMgrHandler::SetProgressCallback(ISyncMgrSynchronizeCallback *lpCallBack)
00481 {
00482 LPSYNCMGRSYNCHRONIZECALLBACK pCallbackCurrent;
00483 CLock clock(this);
00484
00485     clock.Enter();
00486
00487     pCallbackCurrent = m_pSyncMgrSynchronizeCallback;
00488
00489     m_pSyncMgrSynchronizeCallback = lpCallBack;
00490
00491     if (m_pSyncMgrSynchronizeCallback)
00492         m_pSyncMgrSynchronizeCallback->AddRef();
00493
00494     if (pCallbackCurrent)
00495         pCallbackCurrent->Release();
00496
00497
00498     clock.Leave();
00499
00500     return NOERROR;
00501 }
00502
00503 //+---------------------------------------------------------------------------
00504 //
00505 //  Member:     CSyncMgrHandler::GetProgressCallback, private
00506 //
00507 //  Synopsis:
00508 //
00509 //  Arguments:
00510 //
00511 //  Returns:
00512 //
00513 //  Modifies:
00514 //
00515 //----------------------------------------------------------------------------
00516
00517 LPSYNCMGRSYNCHRONIZECALLBACK CSyncMgrHandler::GetProgressCallback()
00518 {
00519 #ifdef _USECURRENTTHREADFORCALLBACK
00520 LPSYNCMGRSYNCHRONIZECALLBACK pCallback;
00521 CLock clock(this);
00522
00523     clock.Enter();
00524
00525     pCallback = m_pSyncMgrSynchronizeCallback;
00526
00527     if (pCallback)
00528     {
00529         pCallback->AddRef();
00530     }
00531
00532
00533     clock.Leave();
00534
00535     return pCallback;
00536 #else
00537     return new CCallbackWrapper(m_hwndHandler);
00538 #endif
00539
00540 }
00541
00542
00543 //+---------------------------------------------------------------------------
00544 //
00545 //  Member:     CSyncMgrHandler::PrepareForSync, public
00546 //
00547 //  Synopsis:
00548 //
00549 //  Arguments:
00550 //
00551 //  Returns:
00552 //
00553 //  Modifies:
00554 //
00555 //----------------------------------------------------------------------------
00556
00557 STDMETHODIMP CSyncMgrHandler::PrepareForSync(ULONG cbNumItems,SYNCMGRITEMID *pItemIDs,
00558                             HWND hWndParent,DWORD dwReserved)
00559
00560 {
00561 METHODARGS *pMethodArgs;
00562 SYNCMGRITEMID *pItemIdCopy;
00563 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
00564 CLock clock(this);
00565
00566     if (!pCallback)
00567     {
00568         Assert(pCallback);
00569         return E_UNEXPECTED;
00570     }
00571
00572     pMethodArgs = (METHODARGS*) ALLOC(sizeof(METHODARGS));
00573     pItemIdCopy = (SYNCMGRITEMID *) ALLOC(sizeof(SYNCMGRITEMID) * cbNumItems);
00574
00575     // create items list before kicking off async call so can handle case
00576     // skip and stop come in before PrepareForSyncCall is handled.
00577
00578     clock.Enter();
00579
00580     m_fStopped = FALSE; // always reset stop on a new PrepareForSync, (for example retry came in)
00581     m_fPrepareForSync = TRUE;
00582
00583     Assert(NULL == m_pItemsToSyncList);
00584     m_pItemsToSyncList = CreateItemList();
00585
00586      // lookup and request a lock on the items to synchronize
00587     // we then place the ones that we found and have permission into our
00588     // own private sync queue.
00589
00590     if (g_pSettings && m_pItemsToSyncList)
00591     {
00592     ULONG ulIndex;
00593     SYNCMGRITEMID *pCurItemID;
00594
00595         pCurItemID = pItemIDs;
00596
00597         for (ulIndex = 0 ; ulIndex < cbNumItems; ++ulIndex)
00598         {
00599         BOOL fAdded = FALSE;;
00600
00601             if (g_pSettings->RequestItemLock(this,*pCurItemID))
00602             {
00603             LPHANDLERITEM_SYNCSTATUS pNewItem;
00604
00605                 pNewItem = (LPHANDLERITEM_SYNCSTATUS) AddNewItemToList(m_pItemsToSyncList,sizeof(HANDLERITEM_SYNCSTATUS));
00606
00607                 if (pNewItem)
00608                 {
00609                     pNewItem->ItemID = *pCurItemID;
00610                     fAdded = TRUE;
00611                 }
00612                 else
00613                 {
00614                     // not enough memory to allocate itemList,
00615                     LogError(pCallback,(*pCurItemID),SYNCMGRLOGLEVEL_ERROR,
00616                                     TEXT("Not Enough Memory to Synchronize"));
00617
00618                     // update progress for this item
00619                     ProgressSetItemStatusType(pCallback,(*pCurItemID),SYNCMGRSTATUS_FAILED);
00620                 }
00621
00622             }
00623
00624
00625             if (!fAdded)
00626             {
00627                 // if another instance already syncing set progress
00628                 // to complete since done but don't update statustext
00629                 // so we dont' stomp the running instance.
00630
00631                 Progress(pCallback,(*pCurItemID),
00632                     SYNCMGRPROGRESSITEM_PROGVALUE | SYNCMGRPROGRESSITEM_MAXVALUE,
00633                     NULL,0,100,100);
00634             }
00635
00636
00637             ++pCurItemID;
00638         }
00639     }
00640
00641
00642     if (NULL == pMethodArgs || NULL == pItemIdCopy || NULL == m_pItemsToSyncList)
00643     {
00644         Assert(pMethodArgs);
00645         Assert(pItemIdCopy);
00646
00647         if (pMethodArgs)
00648         {
00649             FREE(pMethodArgs);
00650         }
00651
00652         if (pItemIdCopy)
00653         {
00654             FREE(pItemIdCopy);
00655         }
00656
00657         if (m_pItemsToSyncList)
00658         {
00659             if (0 == Release_ItemList(m_pItemsToSyncList))
00660             {
00661                 m_pItemsToSyncList = NULL;
00662             }
00663         }
00664
00665         clock.Leave();
00666
00667         pCallback->Release();
00668         m_fPrepareForSync = FALSE;
00669
00670         return E_OUTOFMEMORY;
00671     }
00672
00673     clock.Leave();
00674
00675     // now make the async call
00676     pMethodArgs->fAsync = TRUE;
00677     pMethodArgs->dwWorkerMsg = WM_WORKERMSG_PREPFORSYNC;
00678     pMethodArgs->PrepareForSyncMsg.cbNumItems = cbNumItems;
00679     pMethodArgs->PrepareForSyncMsg.hWndParent = hWndParent;
00680     pMethodArgs->PrepareForSyncMsg.dwReserved = dwReserved;
00681
00682     memcpy(pItemIdCopy,pItemIDs,sizeof(SYNCMGRITEMID) * cbNumItems);
00683     pMethodArgs->PrepareForSyncMsg.pItemIDs = pItemIdCopy;
00684
00685     pCallback->Release();
00686
00687     PostMessage(m_hwndWorker,WM_WORKERMSG_PREPFORSYNC,0,(LPARAM) pMethodArgs);
00688
00689     return NOERROR;
00690 }
00691
00692 //+---------------------------------------------------------------------------
00693 //
00694 //  Member:     CSyncMgrHandler::PrepareForSyncCall, private
00695 //
00696 //  Synopsis:   Called on WorkerThread
00697 //
00698 //  Arguments:
00699 //
00700 //  Returns:
00701 //
00702 //  Modifies:
00703 //
00704 //----------------------------------------------------------------------------
00705
00706 void CSyncMgrHandler::PrepareForSyncCall(ULONG cbNumItems,SYNCMGRITEMID* pItemIDs,HWND hWndParent,
00707                     DWORD dwReserved)
00708 {
00709 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
00710 CLock clock(this);
00711
00712     if (!pCallback)
00713     {
00714         Assert(pCallback);
00715         return;
00716     }
00717
00718     clock.Enter();
00719
00720     // if a stop came in then release the sync list if any
00721     if (m_fStopped && m_pItemsToSyncList)
00722     {
00723         if (0 == Release_ItemList(m_pItemsToSyncList))
00724         {
00725             m_pItemsToSyncList = NULL;
00726         }
00727     }
00728
00729     m_fPrepareForSync = FALSE;
00730
00731     clock.Leave();
00732
00733     // currently all PrepareForSync is handled before the async call since we
00734     // just create a list and store it.
00735
00736     pCallback->PrepareForSyncCompleted(NOERROR);
00737     pCallback->Release();
00738
00739
00740     return;
00741 }
00742
00743 //+---------------------------------------------------------------------------
00744 //
00745 //  Member:     CSyncMgrHandler::Synchronize, public
00746 //
00747 //  Synopsis:
00748 //
00749 //  Arguments:
00750 //
00751 //  Returns:
00752 //
00753 //  Modifies:
00754 //
00755 //----------------------------------------------------------------------------
00756
00757 STDMETHODIMP CSyncMgrHandler::Synchronize(HWND hWndParent)
00758 {
00759 METHODARGS *pMethodArgs;
00760 CLock clock(this);
00761
00762     clock.Enter();
00763     m_fSynchronizing = TRUE;
00764     clock.Leave();
00765
00766     pMethodArgs = (METHODARGS*) ALLOC(sizeof(METHODARGS));
00767
00768     if (NULL == pMethodArgs)
00769     {
00770         Assert(pMethodArgs);
00771         return E_OUTOFMEMORY;
00772     }
00773
00774     pMethodArgs->fAsync = TRUE;
00775     pMethodArgs->dwWorkerMsg = WM_WORKERMSG_SYNCHRONIZE;
00776     pMethodArgs->SynchronizeMsg.hWndParent = hWndParent;
00777
00778     PostMessage(m_hwndWorker,WM_WORKERMSG_SYNCHRONIZE,0,(LPARAM) pMethodArgs);
00779
00780     return NOERROR;
00781 }
00782
00783 //+---------------------------------------------------------------------------
00784 //
00785 //  Member:     CSyncMgrHandler::SynchronizeCall, private
00786 //
00787 //  Synopsis:   Called on WorkerThread
00788 //
00789 //  Arguments:
00790 //
00791 //  Returns:
00792 //
00793 //  Modifies:
00794 //
00795 //----------------------------------------------------------------------------
00796
00797 void CSyncMgrHandler::SynchronizeCall(HWND hWndParent)
00798 {
00799 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
00800 CLock clock(this);
00801
00802     if (!pCallback)
00803     {
00804         Assert(pCallback);
00805         clock.Enter();
00806         m_fSynchronizing = FALSE;
00807         clock.Leave();
00808         return;
00809     }
00810
00811     clock.Enter();
00812
00813     // should either have a syncList or receive a Stop Item request.
00814     Assert(m_pItemsToSyncList || m_fStopped);
00815
00816     if (m_pItemsToSyncList)
00817     {
00818     LPHANDLERITEM_SYNCSTATUS pCurItem;
00819
00820         if (g_pSettings)
00821         {
00822             // get first item in the list, sync, remove, repeat
00823             // until no more items in the list.
00824             while (pCurItem = (LPHANDLERITEM_SYNCSTATUS)
00825                             m_pItemsToSyncList->pFirstGenericItem)
00826             {
00827             FILETIME ft;
00828             SYSTEMTIME sysTime;
00829             HANDLERITEMSETTINGS HANDLERITEMSETTINGS;
00830
00831                // if already cancelled such as setItemstatus came in while not synchronizing
00832                // then just skip over
00833
00834                if (!pCurItem->fSynchronizeComplete)
00835                {
00836                    Assert(sizeof(HANDLERITEM_SYNCSTATUS) == pCurItem->genericItem.cbSize);
00837                    Assert(FALSE == pCurItem->fSynchronizing);
00838
00839                    if (g_pSettings->CopyHandlerSyncInfo(pCurItem->ItemID,&HANDLERITEMSETTINGS))
00840                    {
00841                         pCurItem->fSynchronizing = TRUE; // set synchronizing before releasing lock.
00842                         // release lock and call call helper to do the real sync work.
00843
00844                         clock.Leave();
00845                         SyncDirs(hWndParent,pCurItem,&HANDLERITEMSETTINGS);
00846                         clock.Enter();
00847
00848                         // assert that noboday changed the state on us while
00849                         // the sync was in progress.
00850
00851                         Assert(TRUE == pCurItem->fSynchronizing);
00852                         Assert(FALSE == pCurItem->fSynchronizeComplete);
00853
00854                         pCurItem->fSynchronizing = FALSE;
00855                         pCurItem->fSynchronizeComplete = TRUE;
00856                    }
00857
00858                    // only update file time if item wasn't cancelled,
00859                    // no failures occured and no
00860                    // unresolved conflicts.
00861                    if (!pCurItem->fUnresolvedConflicts && !pCurItem->fCancelled
00862                        && (SYNCMGRSTATUS_SUCCEEDED == pCurItem->dwSyncMgrResultStatus) )
00863                    {
00864                        GetSystemTime(&sysTime);
00865                        SystemTimeToFileTime(&sysTime,&ft);
00866                    }
00867                    else
00868                    {
00869                         ft = HANDLERITEMSETTINGS.ft;
00870                    }
00871
00872                    // tell settings class we are done syncing.
00873                     g_pSettings->ReleaseItemLock(this,pCurItem->ItemID,&ft);
00874                     DeleteItemFromList(m_pItemsToSyncList, (LPGENERICITEM) pCurItem);
00875                 }
00876             }
00877         }
00878
00879         // release the item list if this is the last ref then null out
00880         // the member var
00881         if (0 == Release_ItemList(m_pItemsToSyncList))
00882         {
00883             m_pItemsToSyncList = NULL;
00884         }
00885
00886     }
00887
00888
00889     m_fSynchronizing = FALSE;
00890     clock.Leave();
00891
00892
00893     if (pCallback)
00894     {
00895         pCallback->SynchronizeCompleted(NOERROR);
00896         pCallback->Release();
00897     }
00898
00899     return;
00900 }
00901
00902 //+---------------------------------------------------------------------------
00903 //
00904 //  Member:     CSyncMgrHandler::SetItemStatus, public
00905 //
00906 //  Synopsis:
00907 //
00908 //  Arguments:
00909 //
00910 //  Returns:
00911 //
00912 //  Modifies:
00913 //
00914 //----------------------------------------------------------------------------
00915
00916 STDMETHODIMP CSyncMgrHandler::SetItemStatus(REFSYNCMGRITEMID ItemID,DWORD dwSyncMgrStatus)
00917 {
00918 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
00919 CLock clock(this);
00920
00921     if (!pCallback)
00922     {
00923         Assert(pCallback);
00924         return E_UNEXPECTED;
00925     }
00926
00927     clock.Enter();
00928
00929     if (m_pItemsToSyncList)
00930     {
00931     LPHANDLERITEM_SYNCSTATUS  pCurItem =   (LPHANDLERITEM_SYNCSTATUS) m_pItemsToSyncList->pFirstGenericItem;
00932
00933         while (pCurItem)
00934         {
00935         LPHANDLERITEM_SYNCSTATUS  pCurItemNext;
00936
00937
00938            pCurItemNext = (LPHANDLERITEM_SYNCSTATUS) pCurItem->genericItem.pNextGenericItem;
00939
00940            Assert(sizeof(HANDLERITEM_SYNCSTATUS) == pCurItem->genericItem.cbSize);
00941
00942            if ((SYNCMGRSTATUS_SKIPPED == dwSyncMgrStatus &&
00943                ItemID == pCurItem->ItemID)
00944                || SYNCMGRSTATUS_STOPPED == dwSyncMgrStatus)
00945            {
00946                 pCurItem->fCancelled = TRUE;
00947
00948                 if (!pCurItem->fSynchronizeComplete)
00949                 {
00950                     pCurItem->dwSyncMgrResultStatus = dwSyncMgrStatus;
00951                 }
00952
00953                 // if not currently synchronizing and synchronization is
00954                 // not already done on this item set the progress accordingly
00955                 if (!pCurItem->fSynchronizing && !pCurItem->fSynchronizeComplete)
00956                 {
00957                     ProgressSetItemStatusType(pCallback,pCurItem->ItemID,dwSyncMgrStatus);
00958                     ProgressSetItemProgMaxValue(pCallback,pCurItem->ItemID,10);
00959                     ProgressSetItemProgValue(pCallback,pCurItem->ItemID,10);
00960
00961                     pCurItem->fSynchronizeComplete = TRUE;
00962
00963                     // if we have a syncList
00964                     // then delete the items from the list
00965                     // and relesae the lock
00966                     // Note: this code relies on  PrepareForSync
00967                     // not yielding while setting up item table.
00968
00969                     g_pSettings->ReleaseItemLock(this,pCurItem->ItemID);
00970                     DeleteItemFromList(m_pItemsToSyncList, (LPGENERICITEM) pCurItem);
00971
00972                 }
00973
00974                 if (SYNCMGRSTATUS_SKIPPED == dwSyncMgrStatus)
00975                 {
00976                     break; // if skipped done when found a match.
00977                 }
00978            }
00979
00980            pCurItem = pCurItemNext;
00981         }
00982     }
00983
00984     // if not in a synchronize or prepareForSync call when stop is
00985     // pressed release the itemList.
00986     if ((SYNCMGRSTATUS_STOPPED == dwSyncMgrStatus)
00987         && !m_fSynchronizing && !m_fPrepareForSync)
00988     {
00989         m_fStopped = TRUE;
00990
00991         if (m_pItemsToSyncList)
00992         {
00993             if (0 == Release_ItemList(m_pItemsToSyncList))
00994             {
00995                 m_pItemsToSyncList = NULL;
00996             }
00997         }
00998     }
00999
01000
01001     clock.Leave();
01002
01003     pCallback->Release();
01004     return NOERROR;
01005 }
01006
01007 //+---------------------------------------------------------------------------
01008 //
01009 //  Member:     CSyncMgrHandler::ShowError, public
01010 //
01011 //  Synopsis:
01012 //
01013 //  Arguments:
01014 //
01015 //  Returns:
01016 //
01017 //  Modifies:
01018 //
01019 //----------------------------------------------------------------------------
01020
01021 STDMETHODIMP CSyncMgrHandler::ShowError(HWND hWndParent,REFSYNCMGRERRORID ErrorID)
01022 {
01023 METHODARGS *pMethodArgs;
01024
01025     pMethodArgs = (METHODARGS*) ALLOC(sizeof(METHODARGS));
01026
01027     if (NULL == pMethodArgs)
01028     {
01029         Assert(pMethodArgs);
01030         return E_OUTOFMEMORY;
01031     }
01032
01033     pMethodArgs->fAsync = TRUE;
01034     pMethodArgs->dwWorkerMsg = WM_WORKERMSG_SHOWERROR;
01035     pMethodArgs->ShowErrorMsg.hWndParent = hWndParent;
01036     pMethodArgs->ShowErrorMsg.ErrorID = ErrorID;
01037
01038     PostMessage(m_hwndWorker,WM_WORKERMSG_SHOWERROR,0,(LPARAM) pMethodArgs);
01039
01040     return NOERROR;
01041 }
01042
01043 //+---------------------------------------------------------------------------
01044 //
01045 //  Member:     CSyncMgrHandler::ShowErrorCall, private
01046 //
01047 //  Synopsis:   Called on Worker Thread
01048 //
01049 //  Arguments:
01050 //
01051 //  Returns:
01052 //
01053 //  Modifies:
01054 //
01055 //----------------------------------------------------------------------------
01056
01057 void CSyncMgrHandler::ShowErrorCall(HWND hWndParent,REFSYNCMGRERRORID ErrorID)
01058 {
01059 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
01060
01061     if (pCallback)
01062     {
01063         pCallback->ShowErrorCompleted(NOERROR,0,NULL);
01064         pCallback->Release();
01065     }
01066
01067     return;
01068 }
01069
01070 //+---------------------------------------------------------------------------
01071 //
01072 //  Member:     CSyncMgrHandler::Progress, private
01073 //
01074 //  Synopsis:   Helper method for sending progress information.
01075 //
01076 //  Arguments:
01077 //
01078 //  Returns:
01079 //
01080 //  Modifies:
01081 //
01082 //----------------------------------------------------------------------------
01083
01084 void CSyncMgrHandler::Progress(ISyncMgrSynchronizeCallback *lpCallBack,REFSYNCMGRITEMID pItemID,
01085                                 UINT mask,TCHAR *pStatusText,DWORD dwStatusType,
01086                                 int iProgValue,int iMaxValue)
01087 {
01088 SYNCMGRPROGRESSITEM syncProg;
01089     Assert(lpCallBack);
01090
01091     syncProg.cbSize = sizeof(SYNCMGRPROGRESSITEM);
01092     syncProg.mask = mask;
01093
01094     if (SYNCMGRPROGRESSITEM_STATUSTEXT & mask)
01095     {
01096     #ifdef _UNICODE
01097         syncProg.lpcStatusText = pStatusText;
01098     #else
01099         WCHAR wszStatusText[MAX_PATH];
01100
01101        MultiByteToWideChar(CP_ACP, 0,
01102                     pStatusText,
01103                     -1, wszStatusText,MAX_PATH);
01104
01105         syncProg.lpcStatusText = wszStatusText;
01106     #endif // _UNICODE
01107     }
01108
01109     syncProg.dwStatusType = dwStatusType;
01110     syncProg.iProgValue = iProgValue;
01111     syncProg.iMaxValue = iMaxValue;
01112
01113     lpCallBack->Progress(pItemID,&syncProg);
01114 }
01115
01116 //+---------------------------------------------------------------------------
01117 //
01118 //  Member:     CSyncMgrHandler::ProgressSetItemStatusType, private
01119 //
01120 //  Synopsis:   Helper method for sending progress information.
01121 //
01122 //  Arguments:
01123 //
01124 //  Returns:
01125 //
01126 //  Modifies:
01127 //
01128 //----------------------------------------------------------------------------
01129
01130 void CSyncMgrHandler::ProgressSetItemStatusType(ISyncMgrSynchronizeCallback *lpCallBack,
01131                             REFSYNCMGRITEMID pItemID,DWORD dwSyncMgrStatus)
01132 {
01133     Progress(lpCallBack,pItemID,SYNCMGRPROGRESSITEM_STATUSTYPE,
01134                     NULL,dwSyncMgrStatus,0,0);
01135 }
01136
01137 //+---------------------------------------------------------------------------
01138 //
01139 //  Member:     CSyncMgrHandler::ProgressSetItemStatusText, private
01140 //
01141 //  Synopsis:   Helper method for sending progress information.
01142 //
01143 //  Arguments:
01144 //
01145 //  Returns:
01146 //
01147 //  Modifies:
01148 //
01149 //----------------------------------------------------------------------------
01150
01151 void CSyncMgrHandler::ProgressSetItemStatusText(ISyncMgrSynchronizeCallback *lpCallBack,
01152                             REFSYNCMGRITEMID pItemID,TCHAR *pStatusText)
01153 {
01154     Progress(lpCallBack,pItemID,SYNCMGRPROGRESSITEM_STATUSTEXT,
01155                     pStatusText,0,0,0);
01156 }
01157
01158 //+---------------------------------------------------------------------------
01159 //
01160 //  Member:     CSyncMgrHandler::ProgressSetItemProgValue, private
01161 //
01162 //  Synopsis:   Helper method for sending progress information.
01163 //
01164 //  Arguments:
01165 //
01166 //  Returns:
01167 //
01168 //  Modifies:
01169 //
01170 //----------------------------------------------------------------------------
01171
01172 void CSyncMgrHandler::ProgressSetItemProgValue(ISyncMgrSynchronizeCallback *lpCallBack,
01173                             REFSYNCMGRITEMID pItemID,int iProgValue)
01174 {
01175     Progress(lpCallBack,pItemID,SYNCMGRPROGRESSITEM_PROGVALUE,
01176                     NULL,0,iProgValue,0);
01177 }
01178
01179 //+---------------------------------------------------------------------------
01180 //
01181 //  Member:     CSyncMgrHandler::ProgressSetItemMaxValue, private
01182 //
01183 //  Synopsis:   Helper method for sending progress information.
01184 //
01185 //  Arguments:
01186 //
01187 //  Returns:
01188 //
01189 //  Modifies:
01190 //
01191 //----------------------------------------------------------------------------
01192
01193 void CSyncMgrHandler::ProgressSetItemProgMaxValue(ISyncMgrSynchronizeCallback *lpCallBack,
01194                             REFSYNCMGRITEMID pItemID,int iProgMaxValue)
01195 {
01196     Progress(lpCallBack,pItemID,SYNCMGRPROGRESSITEM_MAXVALUE,
01197                     NULL,0,0,iProgMaxValue);
01198 }
01199
01200 //+---------------------------------------------------------------------------
01201 //
01202 //  Member:     CSyncMgrHandler::LogError, private
01203 //
01204 //  Synopsis:   Helper method for logging Error information.
01205 //
01206 //  Arguments:
01207 //
01208 //  Returns:
01209 //
01210 //  Modifies:
01211 //
01212 //----------------------------------------------------------------------------
01213
01214 void CSyncMgrHandler::LogError(ISyncMgrSynchronizeCallback *lpCallBack,REFSYNCMGRITEMID pItemID,
01215               DWORD dwErrorLevel,TCHAR *lpErrorText,DWORD mask,DWORD dwSyncMgrErrorFlags,
01216               SYNCMGRERRORID ErrorID)
01217 {
01218 SYNCMGRLOGERRORINFO logError;
01219 WCHAR *pwszErrorText;
01220
01221     Assert(lpCallBack);
01222
01223     logError.cbSize = sizeof(SYNCMGRLOGERRORINFO);
01224     logError.mask = mask | SYNCMGRLOGERROR_ERRORID | SYNCMGRLOGERROR_ERRORFLAGS;
01225     logError.dwSyncMgrErrorFlags = dwSyncMgrErrorFlags | SYNCMGRERRORFLAG_ENABLEJUMPTEXT;
01226     logError.ErrorID = ErrorID;
01227     logError.ItemID = pItemID;
01228
01229 #ifdef _UNICODE
01230     pwszErrorText = lpErrorText;
01231 #else
01232     WCHAR wszErrorText[MAX_PATH];
01233
01234    MultiByteToWideChar(CP_ACP, 0,
01235                 lpErrorText,
01236                 -1, wszErrorText,MAX_PATH);
01237
01238     pwszErrorText = wszErrorText;
01239 #endif // _UNICODE
01240
01241     lpCallBack->LogError(dwErrorLevel,pwszErrorText,&logError);
01242 }
01243
01244 //+---------------------------------------------------------------------------
01245 //
01246 //  Member:     CSyncMgrHandler::LogError, private
01247 //
01248 //  Synopsis:   Helper method for logging Error information.
01249 //
01250 //  Arguments:
01251 //
01252 //  Returns:
01253 //
01254 //  Modifies:
01255 //
01256 //----------------------------------------------------------------------------
01257
01258 void CSyncMgrHandler::LogError(ISyncMgrSynchronizeCallback *lpCallBack,REFSYNCMGRITEMID pItemID,
01259                       DWORD dwErrorLevel,TCHAR *lpErrorText)
01260 {
01261     LogError(lpCallBack,pItemID,dwErrorLevel,lpErrorText,SYNCMGRLOGERROR_ITEMID,0,GUID_NULL);
01262 }
01263
01264 //+---------------------------------------------------------------------------
01265 //
01266 //  Member:     CSyncMgrHandler::LogError, private
01267 //
01268 //  Synopsis:   Helper method for logging Error information.
01269 //
01270 //  Arguments:
01271 //
01272 //  Returns:
01273 //
01274 //  Modifies:
01275 //
01276 //----------------------------------------------------------------------------
01277
01278 void CSyncMgrHandler::LogError(ISyncMgrSynchronizeCallback *lpCallBack,
01279                       DWORD dwErrorLevel,TCHAR *lpErrorText)
01280 {
01281     LogError(lpCallBack,GUID_NULL,dwErrorLevel,lpErrorText,0,0,GUID_NULL);
01282 }
01283
01284 ////******
01285 ///
01286 //  methods specific to this implementation to sync up file directories
01287 //
01288 ///*******
01289
01290
01291 //+---------------------------------------------------------------------------
01292 //
01293 //  Member:     CSyncMgrHandler::GetFilesForDir, private
01294 //
01295 //  Synopsis:   creates a list of files for the given directory.
01296 //
01297 //  Arguments:
01298 //
01299 //  Returns:
01300 //
01301 //  Modifies:
01302 //
01303 //----------------------------------------------------------------------------
01304
01305 LPFILEOBJECTLIST CSyncMgrHandler::GetFilesForDir(TCHAR *pDirName,BOOL fRecursive)
01306
01307 {
01308 LPFILEOBJECTLIST pDirList;
01309 HANDLE hFind;
01310 BOOL bMore;
01311 WIN32_FIND_DATA finddata;
01312 TCHAR szSearch[MAX_PATH];
01313
01314     pDirList = CreateItemList();
01315
01316     if (!pDirList)
01317     {
01318         return NULL;
01319     }
01320
01321     wsprintf(szSearch,TEXT("%s\\*.*"),pDirName);
01322
01323     hFind = FindFirstFile(szSearch, &finddata);
01324     bMore = (hFind != (HANDLE) -1);
01325
01326     while (bMore) {
01327
01328             if ( (lstrcmp(finddata.cFileName, TEXT(".")) != 0) &&
01329                            ( lstrcmp(finddata.cFileName, TEXT("..")) != 0) )
01330             {
01331             LPFILEOBJECT pFileObject = (LPFILEOBJECT) AddNewItemToList(pDirList,sizeof(FILEOBJECT));
01332             BOOL bIsDir;
01333
01334                 if (!pFileObject) // if alloc ever fails just bail.
01335                 {
01336                     break;
01337                 }
01338
01339                 // init the data.
01340                 lstrcpy(pFileObject->fName,finddata.cFileName);
01341
01342                 bIsDir = (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? TRUE : FALSE;
01343                 pFileObject->fDirectory = bIsDir;
01344
01345                 if (!bIsDir)
01346                 {
01347                 HANDLE hFile;
01348                 FILETIME ftCreate;
01349                 FILETIME ftLastAccess;
01350
01351                     // Review - need to check failure
01352                     // and if way to get modified with openning file.
01353
01354                     wsprintf(szSearch,TEXT("%s\\%s"),pDirName,pFileObject->fName);
01355
01356                     hFile = CreateFile(szSearch, GENERIC_READ, 0, NULL,
01357                                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
01358
01359
01360                     if (GetFileTime(hFile, &ftCreate,
01361                                     &ftLastAccess,&(pFileObject->ftLastUpdate)) )
01362                     {
01363                         pFileObject->fLastUpdateValid = TRUE;
01364                     }
01365
01366                     CloseHandle(hFile);
01367
01368                 }
01369                 else
01370                 {
01371                     // if this is a directory and recursive, get children
01372                     if (fRecursive)
01373                     {
01374                     TCHAR szFullPath[MAX_PATH];
01375
01376                         // fullpath is current dir name + \ + this dir name.
01377                         wsprintf(szFullPath,TEXT("%s\\%s"),pDirName,pFileObject->fName);
01378
01379                         pFileObject->pChildList =
01380                                 GetFilesForDir(szFullPath,fRecursive);
01381                     }
01382                 }
01383             }
01384
01385             bMore = FindNextFile(hFind, &finddata);
01386     }
01387
01388     FindClose(hFind);
01389
01390     return pDirList;
01391 }
01392
01393 //+---------------------------------------------------------------------------
01394 //
01395 //  Member:     CSyncMgrHandler::CreateDirFileListFromPath, private
01396 //
01397 //  Synopsis:   creates a new FileObjectList for the given Directory
01398 //
01399 //  Arguments:
01400 //
01401 //  Returns:
01402 //
01403 //  Modifies:
01404 //
01405 //----------------------------------------------------------------------------
01406
01407 LPFILEOBJECTLIST CSyncMgrHandler::CreateDirFileListFromPath(TCHAR *pDirName,BOOL fRecursive)
01408 {
01409 LPFILEOBJECTLIST pDirObj;
01410 BOOL fValidDir = FALSE;
01411
01412     if (!IsValidDir(pDirName))
01413     {
01414         return NULL;
01415     }
01416
01417     pDirObj = CreateItemList();
01418
01419     if (pDirObj)
01420     {
01421     LPFILEOBJECT pFileObject;
01422
01423         // go ahead and add this as the toplevel dir
01424         pFileObject = (LPFILEOBJECT) AddNewItemToList(pDirObj,sizeof(FILEOBJECT));
01425
01426         if (pFileObject)
01427         {
01428             pFileObject->fDirectory = TRUE;
01429             lstrcpy(pFileObject->fName,pDirName);
01430
01431             pFileObject->pChildList = GetFilesForDir(pFileObject->fName,fRecursive);
01432
01433         }
01434     }
01435
01436     return pDirObj;
01437 }
01438
01439 //+---------------------------------------------------------------------------
01440 //
01441 //  Member:     CSyncMgrHandler::ReleaseFileObjectList, private
01442 //
01443 //  Synopsis:   releases the fileobject list.
01444 //
01445 //  Arguments:
01446 //
01447 //  Returns:
01448 //
01449 //  Modifies:
01450 //
01451 //----------------------------------------------------------------------------
01452
01453 void CSyncMgrHandler::ReleaseFileObjectList(LPFILEOBJECTLIST pfObjList,BOOL fRecursive)
01454 {
01455 LPFILEOBJECT pCurItem;
01456
01457     if (!pfObjList)
01458     {
01459         Assert(pfObjList)
01460         return;
01461     }
01462
01463     // see if object has any childs and free them if they do.
01464
01465     pCurItem= (LPFILEOBJECT) pfObjList->pFirstGenericItem;
01466
01467     while(pCurItem)
01468     {
01469         Assert(sizeof(FILEOBJECT ) == pCurItem->genericItem.cbSize);
01470
01471         if (pCurItem->fDirectory)
01472         {
01473             Assert(pCurItem->pChildList || (!fRecursive));
01474
01475             if (pCurItem->pChildList)
01476             {
01477                 ReleaseFileObjectList(pCurItem->pChildList,fRecursive);
01478             }
01479         }
01480
01481         pCurItem = (LPFILEOBJECT) pCurItem->genericItem.pNextGenericItem;
01482     }
01483
01484     Release_ItemList(pfObjList);
01485 }
01486
01487 //+---------------------------------------------------------------------------
01488 //
01489 //  Member:     CSyncMgrHandler::CountNumberofFilesInList, private
01490 //
01491 //  Synopsis:   returns a total count of the number of items in the list.
01492 //
01493 //  Arguments:
01494 //
01495 //  Returns:
01496 //
01497 //  Modifies:
01498 //
01499 //----------------------------------------------------------------------------
01500
01501 ULONG CSyncMgrHandler::CountNumberOfFilesInList(LPFILEOBJECTLIST pfObjList,BOOL fRecursive)
01502 {
01503 LPFILEOBJECT pCurItem;
01504 ULONG ulTotalCount = 0;
01505
01506     if (!pfObjList)
01507     {
01508         Assert(pfObjList)
01509         return 0;
01510     }
01511
01512     // see if object has any childs and free them if they do.
01513     pCurItem= (LPFILEOBJECT) pfObjList->pFirstGenericItem;
01514
01515     while(pCurItem)
01516     {
01517         Assert(sizeof(FILEOBJECT ) == pCurItem->genericItem.cbSize);
01518
01519         if (pCurItem->fDirectory)
01520         {
01521             Assert(pCurItem->pChildList || (!fRecursive));
01522
01523             if (pCurItem->pChildList)
01524             {
01525                 ulTotalCount += CountNumberOfFilesInList(pCurItem->pChildList,fRecursive);
01526             }
01527         }
01528         else
01529         {
01530             ++ulTotalCount;
01531         }
01532
01533         pCurItem = (LPFILEOBJECT) pCurItem->genericItem.pNextGenericItem;
01534     }
01535
01536     return ulTotalCount;
01537 }
01538
01539 //+---------------------------------------------------------------------------
01540 //
01541 //  Member:     CSyncMgrHandler::FindFileItemWithName, private
01542 //
01543 //  Synopsis:  trys to find the items with with the specified filename in
01544 //              the fileobject list.
01545 //
01546 //  Arguments:
01547 //
01548 //  Returns:
01549 //
01550 //  Modifies:
01551 //
01552 //----------------------------------------------------------------------------
01553
01554 LPFILEOBJECT CSyncMgrHandler::FindFileItemWithName(LPFILEOBJECTLIST pDir,TCHAR *pfName)
01555 {
01556 LPFILEOBJECT pCurItem = NULL;
01557
01558     if (!pDir)
01559     {
01560         Assert(pDir)
01561         return NULL;
01562     }
01563
01564     // see if object has any childs and free them if they do.
01565     pCurItem= (LPFILEOBJECT) pDir->pFirstGenericItem;
01566
01567     while(pCurItem)
01568     {
01569         Assert(sizeof(FILEOBJECT ) == pCurItem->genericItem.cbSize);
01570
01571         if (0 == lstrcmp(pfName,pCurItem->fName))
01572         {
01573             break;
01574         }
01575
01576         pCurItem = (LPFILEOBJECT) pCurItem->genericItem.pNextGenericItem;
01577     }
01578
01579     return pCurItem;
01580 }
01581
01582 //+---------------------------------------------------------------------------
01583 //
01584 //  Member:     CSyncMgrHandler::CopyfileFullPath, private
01585 //
01586 //  Synopsis:   copies file1 to file2 along with attribs.
01587 //
01588 //  Arguments:
01589 //
01590 //  Returns:
01591 //
01592 //  Modifies:
01593 //
01594 //----------------------------------------------------------------------------
01595
01596 BOOL CSyncMgrHandler::CopyFileFullPath(TCHAR *pszFile1,TCHAR *pszFile2)
01597 {
01598 HANDLE hfile;
01599 DWORD dwAttribs;
01600 FILETIME ftCreate,ftLastAccess,ftLastWrite;
01601 BOOL fOk;
01602
01603     fOk = CopyFile(pszFile1, pszFile2, FALSE);
01604
01605     if (fOk)
01606     {
01607     BOOL fFileTime = FALSE;
01608
01609         // having copied the file, now copy the times, attributes
01610         // if fail to get go ahead and say copy succeeded.
01611
01612         hfile = CreateFile(pszFile1, GENERIC_READ, 0, NULL,
01613                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
01614
01615         if (INVALID_HANDLE_VALUE != hfile)
01616         {
01617
01618             fFileTime = GetFileTime(hfile, &ftCreate,
01619                             &ftLastAccess, &ftLastWrite);
01620             CloseHandle(hfile);
01621         }
01622
01623
01624         if (fFileTime)
01625         {
01626             hfile = CreateFile(pszFile2, GENERIC_WRITE, 0, NULL,
01627                             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
01628
01629             if (INVALID_HANDLE_VALUE != hfile)
01630             {
01631                 SetFileTime(hfile, &ftCreate,
01632                                    &ftLastAccess,
01633                                    &ftLastWrite);
01634
01635                 CloseHandle(hfile);
01636             }
01637         }
01638
01639         // update attributes
01640         dwAttribs = GetFileAttributes(pszFile1);
01641         if (-1 != dwAttribs)
01642         {
01643             SetFileAttributes(pszFile2,dwAttribs);
01644         }
01645
01646     }
01647
01648     return fOk;
01649 }
01650
01651 //+---------------------------------------------------------------------------
01652 //
01653 //  Member:     CSyncMgrHandler::CopyFiles, private
01654 //
01655 //  Synopsis:   copies all files from dir1 to dir2
01656 //
01657 //  Arguments:
01658 //
01659 //  Returns:
01660 //
01661 //  Modifies:
01662 //
01663 //----------------------------------------------------------------------------
01664
01665 void CSyncMgrHandler::CopyFiles( LPHANDLERITEM_SYNCSTATUS pHandlerItemID,
01666                                 LPHANDLERITEMSETTINGS pHANDLERITEMSETTINGS,
01667                                 LPSYNCMGRSYNCHRONIZECALLBACK pCallback,
01668                                 DWORD *pdwCurProgValue,
01669                                 TCHAR *pszDir1,
01670                                 LPFILEOBJECTLIST pDir1,
01671                                 TCHAR *pszDir2)
01672 {
01673 LPFILEOBJECT pCurDir1Item;
01674 LPFILEOBJECT pNextDir1Item;
01675
01676     // anything left is list when done is unique and needs to be copied
01677     // walk through each list moving the items.
01678     pNextDir1Item = (LPFILEOBJECT) pDir1->pFirstGenericItem;
01679
01680     while(pNextDir1Item)
01681     {
01682
01683        // each time through the loop check for if item is cancelled
01684        // and if so return;
01685        if (pHandlerItemID->fCancelled)
01686             return;
01687
01688         Assert(sizeof(FILEOBJECT ) == pNextDir1Item->genericItem.cbSize);
01689         pCurDir1Item = pNextDir1Item;
01690
01691         pNextDir1Item = (LPFILEOBJECT) pNextDir1Item->genericItem.pNextGenericItem;
01692
01693         if (pCurDir1Item->fDirectory)
01694         {
01695             if (pCurDir1Item->pChildList)
01696             {
01697             TCHAR szDir1[MAX_PATH];
01698             TCHAR szDir2[MAX_PATH];
01699
01700                 wsprintf(szDir1,TEXT("%s\\%s"),pszDir1,pCurDir1Item->fName);
01701                 wsprintf(szDir2,TEXT("%s\\%s"),pszDir2,pCurDir1Item->fName);
01702
01703                 // create destination dir if necessary.
01704                 CreateDirectory(szDir2,NULL);
01705
01706                 CopyFiles(pHandlerItemID,pHANDLERITEMSETTINGS,pCallback,pdwCurProgValue,
01707                                 szDir1,pCurDir1Item->pChildList,szDir2);
01708             }
01709
01710         }
01711         else
01712         {
01713         TCHAR szFullPath1[MAX_PATH];
01714         TCHAR szFullPath2[MAX_PATH];
01715         TCHAR szProgress[MAX_PATH];
01716
01717             wsprintf(szProgress,TEXT("Copying %s"),pCurDir1Item->fName);
01718             ProgressSetItemStatusText(pCallback,pHANDLERITEMSETTINGS->ItemID,szProgress);
01719
01720             wsprintf(szFullPath1,TEXT("%s\\%s"),pszDir1,pCurDir1Item->fName);
01721             wsprintf(szFullPath2,TEXT("%s\\%s"),pszDir2,pCurDir1Item->fName);
01722
01723             // copy the file over
01724             if (FALSE == CopyFileFullPath(szFullPath1,szFullPath2))
01725             {
01726                 wsprintf(szProgress,TEXT("Error Copying %s"),pCurDir1Item->fName);
01727
01728                 LogError(pCallback,pHANDLERITEMSETTINGS->ItemID,SYNCMGRLOGLEVEL_ERROR,
01729                                     szProgress);
01730             }
01731
01732             // update the progress bar value.
01733              *pdwCurProgValue += 1;
01734             ProgressSetItemProgValue(pCallback,pHANDLERITEMSETTINGS->ItemID,*pdwCurProgValue);
01735
01736             // always release, even on
01737             DeleteItemFromList(pDir1,(LPGENERICITEM) pCurDir1Item);
01738
01739         }
01740
01741     }
01742
01743 }
01744
01745 //+---------------------------------------------------------------------------
01746 //
01747 //  Member:     CSyncMgrHandler::reconcileDir, private
01748 //
01749 //  Synopsis:  does main job of reconciling dir1 and dir2
01750 //
01751 //  Arguments:
01752 //
01753 //  Returns:
01754 //
01755 //  Modifies:
01756 //
01757 //----------------------------------------------------------------------------
01758
01759 void CSyncMgrHandler::ReconcileDir(HWND hWndParent,
01760                                 LPHANDLERITEM_SYNCSTATUS pHandlerItemID,
01761                                 LPHANDLERITEMSETTINGS pHANDLERITEMSETTINGS,
01762                                 LPSYNCMGRSYNCHRONIZECALLBACK pCallback,
01763                                 DWORD *pdwCurProgValue,
01764                                 TCHAR *pszDir1,LPFILEOBJECTLIST pDir1,
01765                                 TCHAR *pszDir2,LPFILEOBJECTLIST pDir2)
01766 {
01767 LPFILEOBJECT pCurDir1Item;
01768 LPFILEOBJECT pCurDir1NextItem;
01769 LPFILEOBJECT pCurDir2Item;
01770
01771     if (!pDir1 || !pDir2 || !pCallback)
01772     {
01773         Assert(pCallback);
01774         Assert(pDir1);
01775         Assert(pDir1);
01776         return;
01777     }
01778     // loop through dir finding and comparing matches,
01779     // if find matching dirs call ReconcileDir
01780     pCurDir1NextItem= (LPFILEOBJECT) pDir1->pFirstGenericItem;
01781
01782     while(pCurDir1NextItem)
01783     {
01784         Assert(sizeof(FILEOBJECT ) == pCurDir1NextItem->genericItem.cbSize);
01785
01786         // each time through the loop check for if item is cancelled
01787         // and if so return;
01788        if (pHandlerItemID->fCancelled)
01789             return;
01790
01791         pCurDir1Item = pCurDir1NextItem;
01792         pCurDir1NextItem = (LPFILEOBJECT) pCurDir1Item->genericItem.pNextGenericItem;
01793
01794         pCurDir2Item = FindFileItemWithName(pDir2,pCurDir1Item->fName);
01795
01796         // if found match, deal with it, else leave in list and
01797         // catch on the copy pass.
01798         if (pCurDir2Item)
01799         {
01800             // if both directies
01801             if (pCurDir1Item->fDirectory && pCurDir2Item->fDirectory)
01802             {
01803                 if (pCurDir1Item->pChildList && pCurDir2Item->pChildList)
01804                 {
01805                 TCHAR szDir1[MAX_PATH];
01806                 TCHAR szDir2[MAX_PATH];
01807
01808                     wsprintf(szDir1,TEXT("%s\\%s"),pszDir1,pCurDir1Item->fName);
01809                     wsprintf(szDir2,TEXT("%s\\%s"),pszDir2,pCurDir2Item->fName);
01810
01811                     ReconcileDir(hWndParent,pHandlerItemID,pHANDLERITEMSETTINGS,
01812                                   pCallback,
01813                                   pdwCurProgValue,
01814                                   szDir1,pCurDir1Item->pChildList,
01815                                   szDir2,pCurDir2Item->pChildList);
01816
01817                 }
01818                 else
01819                 {
01820                     // one of the directories didn't have a child list and
01821                     // one did.
01822
01823                      if (pCurDir1Item->pChildList)
01824                      {
01825                         *pdwCurProgValue += CountNumberOfFilesInList(pCurDir1Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01826                         ReleaseFileObjectList(pCurDir1Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01827                         pCurDir1Item->pChildList = NULL;
01828                      }
01829
01830                      *pdwCurProgValue += 1;
01831                      DeleteItemFromList(pDir1,(LPGENERICITEM) pCurDir1Item);
01832
01833                      if (pCurDir2Item->pChildList)
01834                      {
01835                         *pdwCurProgValue += CountNumberOfFilesInList(pCurDir2Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01836                         ReleaseFileObjectList(pCurDir2Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01837                         pCurDir2Item->pChildList = NULL;
01838                      }
01839
01840                      *pdwCurProgValue += 1;
01841                      DeleteItemFromList(pDir2,(LPGENERICITEM) pCurDir2Item);
01842
01843                     // update the progress value.
01844                     ProgressSetItemProgValue(pCallback,pHANDLERITEMSETTINGS->ItemID,*pdwCurProgValue);
01845
01846                 }
01847             }
01848             else if (!pCurDir1Item->fDirectory && !pCurDir2Item->fDirectory)
01849             {
01850             FILETIME *pftLastUpdate = &(pHANDLERITEMSETTINGS->ft);
01851             int iFileCompare;
01852             BOOL fCopy = FALSE;
01853
01854                 ProgressSetItemStatusText(pCallback,pHANDLERITEMSETTINGS->ItemID,pCurDir1Item->fName);
01855
01856                 // if filestimes are the same do nothing
01857                 // both filetimes are greater than < last sync time, conflict,
01858                 // else copy newer file over.
01859
01860                 if (0 != (iFileCompare  = CompareFileTime(&(pCurDir1Item->ftLastUpdate),&(pCurDir2Item->ftLastUpdate)) ))
01861                 {
01862                 int iFile1UpdateTimeCompare = CompareFileTime(&(pCurDir1Item->ftLastUpdate),pftLastUpdate);
01863                 int iFile2UpdateTimeCompare = CompareFileTime(&(pCurDir2Item->ftLastUpdate),pftLastUpdate);
01864
01865                     if (iFile1UpdateTimeCompare ==  iFile2UpdateTimeCompare)
01866                     {
01867                     RFCDLGPARAM rfcParam;
01868                     int iResolution;
01869                     TCHAR szNetModifiedOnBuf[MAX_PATH];
01870                     TCHAR szLocalModifiedOnBuf[MAX_PATH];
01871
01872                         // !!! Conflict
01873                         memset(&rfcParam,0,sizeof(RFCDLGPARAM));
01874
01875                         rfcParam.dwFlags = 0;
01876                         rfcParam.pszFilename = pCurDir1Item->fName;
01877                         rfcParam.pszLocation = pszDir1;
01878                         rfcParam.pszNewName = pCurDir2Item->fName;
01879                         rfcParam.pszNetworkModifiedOn
01880                                 = FormatDateTime(&(pCurDir1Item->ftLastUpdate),szNetModifiedOnBuf,sizeof(szNetModifiedOnBuf)/sizeof(TCHAR));
01881                         rfcParam.pszLocalModifiedOn
01882                                 = FormatDateTime(&(pCurDir2Item->ftLastUpdate),szLocalModifiedOnBuf,sizeof(szLocalModifiedOnBuf)/sizeof(TCHAR));
01883
01884
01885                        // if can show UI call enable modeless, and show
01886                         // conflict dialog, else log and error and treat
01887                         // as if use chose to keep both.
01888
01889                         if ( (m_dwSyncFlags & SYNCMGRFLAG_MAYBOTHERUSER)
01890                              && (S_OK ==  pCallback->EnableModeless(TRUE)) )
01891                         {
01892                             iResolution = SyncMgrResolveConflict(hWndParent,&rfcParam);
01893                             pCallback->EnableModeless(FALSE);
01894                         }
01895                         else
01896                         {
01897                         TCHAR szLogText[MAX_PATH];
01898
01899                             iResolution = RFC_KEEPBOTH;
01900
01901                             wsprintf(szLogText,TEXT("Conflict occured - %s"),pCurDir1Item->fName);
01902
01903                             LogError(pCallback,pHANDLERITEMSETTINGS->ItemID,SYNCMGRLOGLEVEL_WARNING,
01904                                         szLogText);
01905
01906                         }
01907
01908                         switch (iResolution)
01909                         {
01910                         case RFC_KEEPNETWORK: // treat dir1 as network copy
01911                             iFileCompare = 1;
01912                             fCopy = TRUE;
01913                             break;
01914                         case RFC_KEEPLOCAL: // treat dir2 as local copy.
01915                             iFileCompare = - 1;
01916                             fCopy = TRUE;
01917                             break;
01918                         case RFC_KEEPBOTH: // if keep both wait until next sync.
01919                         default:
01920                             fCopy = FALSE;
01921                             pHandlerItemID->fUnresolvedConflicts = TRUE;
01922                             break;
01923                         }
01924
01925
01926                     }
01927                     else
01928                     {
01929                         fCopy = TRUE;
01930                     }
01931
01932
01933                     if (fCopy)
01934                     {
01935                     TCHAR szProgressText[MAX_PATH];
01936                     TCHAR szFile1FullPath[MAX_PATH],szFile2FullPath[MAX_PATH];
01937                     BOOL fOk;
01938
01939                         wsprintf(szProgressText,TEXT("Updating %s"),pCurDir1Item->fName);
01940                         ProgressSetItemStatusText(pCallback,pHANDLERITEMSETTINGS->ItemID,szProgressText);
01941
01942                         wsprintf(szFile1FullPath,TEXT("%s\\%s"),pszDir1,pCurDir1Item->fName);
01943                         wsprintf(szFile2FullPath,TEXT("%s\\%s"),pszDir2,pCurDir2Item->fName);
01944
01945                          // copy newer file.
01946                          if (0 < iFileCompare)
01947                          {
01948                             // 1 > 2.
01949                             fOk = CopyFileFullPath(szFile1FullPath,szFile2FullPath);
01950                          }
01951                          else
01952                          {
01953                             fOk = CopyFileFullPath(szFile2FullPath,szFile1FullPath);
01954
01955                          }
01956
01957                     }
01958
01959
01960                 }
01961
01962                 // when done incmrement the progress value and release the items.
01963                 *pdwCurProgValue += 2; // incrent progress by 2 since we handled both files.
01964                 ProgressSetItemProgValue(pCallback,pHANDLERITEMSETTINGS->ItemID,*pdwCurProgValue);
01965
01966                 // always release, even on error since don't want copy to kick in.
01967                 DeleteItemFromList(pDir1,(LPGENERICITEM) pCurDir1Item);
01968                 DeleteItemFromList(pDir2,(LPGENERICITEM) pCurDir2Item);
01969
01970             }
01971             else
01972             {
01973             TCHAR szLogError[MAX_PATH];
01974
01975                 wsprintf(szLogError,TEXT("%s is a Directory in one location and file in another.")
01976                                     ,pCurDir1Item->fName);
01977                 LogError(pCallback,pHANDLERITEMSETTINGS->ItemID,SYNCMGRLOGLEVEL_ERROR,szLogError);
01978
01979                 // release both dir and file.
01980                  if (pCurDir1Item->fDirectory && pCurDir1Item->pChildList)
01981                  {
01982                     *pdwCurProgValue += CountNumberOfFilesInList(pCurDir1Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01983                     ReleaseFileObjectList(pCurDir1Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01984                     pCurDir1Item->pChildList = NULL;
01985                  }
01986
01987                 *pdwCurProgValue += 1;
01988                 DeleteItemFromList(pDir1,(LPGENERICITEM) pCurDir1Item);
01989
01990                  if (pCurDir2Item->fDirectory && pCurDir2Item->pChildList)
01991                  {
01992                     *pdwCurProgValue += CountNumberOfFilesInList(pCurDir2Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01993                     ReleaseFileObjectList(pCurDir2Item->pChildList,pHANDLERITEMSETTINGS->fRecursive);
01994                     pCurDir2Item->pChildList = NULL;
01995                  }
01996
01997                 *pdwCurProgValue += 1;
01998                 DeleteItemFromList(pDir2, (LPGENERICITEM) pCurDir2Item);
01999
02000
02001                 // update the progress value.
02002                 ProgressSetItemProgValue(pCallback,pHANDLERITEMSETTINGS->ItemID,*pdwCurProgValue);
02003
02004
02005             }
02006
02007         }
02008
02009     }
02010
02011    // Anything left is a copy
02012    // This sample doesn't properly handle the following cases
02013    //  1)  file has been deleted in one folder and not the other - next sync file will be
02014    //       copied back to folder it was delted from
02015    //  2)  File has been renamed in one folder and not the other - next sync both files will
02016    //        appear.
02017
02018    CopyFiles(pHandlerItemID,pHANDLERITEMSETTINGS,pCallback,pdwCurProgValue,pszDir1,pDir1,pszDir2);
02019    CopyFiles(pHandlerItemID,pHANDLERITEMSETTINGS,pCallback,pdwCurProgValue,pszDir2,pDir2,pszDir1);
02020 }
02021
02022 //+---------------------------------------------------------------------------
02023 //
02024 //  Member:     CSyncMgrHandler::SyncDirs, private
02025 //
02026 //  Synopsis:   Called by SynchronizeCall(). Sets up dirlists
02027 //              for synchronization and then calls the ReconcileDir function.
02028 //
02029 //  Arguments:
02030 //
02031 //  Returns:
02032 //
02033 //  Modifies:
02034 //
02035 //----------------------------------------------------------------------------
02036
02037 void CSyncMgrHandler::SyncDirs(HWND hWndParent,LPHANDLERITEM_SYNCSTATUS pHandlerItemID,
02038                                         LPHANDLERITEMSETTINGS pHANDLERITEMSETTINGS)
02039 {
02040 LPSYNCMGRSYNCHRONIZECALLBACK pCallback = GetProgressCallback();
02041 LPFILEOBJECTLIST pfObjDir1 = NULL,pfObjDir2 = NULL;
02042 ULONG ulProgressMaxValue = 0;
02043 ULONG ulProgressCurValue = 0;
02044 TCHAR szStatusText[MAX_PATH];
02045
02046     // if already cancelled go on.
02047     if (pHandlerItemID->fCancelled)
02048         goto synccomplete;
02049
02050     // synchronizing flag should be TRUE so SetItemStatus knows this is
02051     Assert(TRUE == pHandlerItemID->fSynchronizing);
02052
02053     pHandlerItemID->dwSyncMgrResultStatus = SYNCMGRSTATUS_SUCCEEDED;
02054
02055     ProgressSetItemStatusType(pCallback,pHANDLERITEMSETTINGS->ItemID,SYNCMGRSTATUS_UPDATING);
02056
02057     wsprintf(szStatusText,TEXT("Scanning %s"),pHANDLERITEMSETTINGS->dir1);
02058     ProgressSetItemStatusText(pCallback,pHANDLERITEMSETTINGS->ItemID,szStatusText);
02059
02060     pfObjDir1 = CreateDirFileListFromPath(pHANDLERITEMSETTINGS->dir1,
02061                                                 pHANDLERITEMSETTINGS->fRecursive);
02062
02063     if (pHandlerItemID->fCancelled)
02064         goto synccomplete;
02065
02066     if (!pfObjDir1)
02067     {
02068          wsprintf(szStatusText,TEXT("Error Scanning %s"),pHANDLERITEMSETTINGS->dir1);
02069          LogError(pCallback,pHANDLERITEMSETTINGS->ItemID,SYNCMGRLOGLEVEL_ERROR,szStatusText);
02070          pHandlerItemID->dwSyncMgrResultStatus = SYNCMGRSTATUS_FAILED;
02071     }
02072     else
02073     {
02074         wsprintf(szStatusText,TEXT("Scanning %s"),pHANDLERITEMSETTINGS->dir2);
02075         ProgressSetItemStatusText(pCallback,pHANDLERITEMSETTINGS->ItemID,szStatusText);
02076
02077         pfObjDir2 = CreateDirFileListFromPath(pHANDLERITEMSETTINGS->dir2,
02078                                                     pHANDLERITEMSETTINGS->fRecursive);
02079
02080         if (!pfObjDir2)
02081         {
02082              wsprintf(szStatusText,TEXT("Error Scanning %s"),pHANDLERITEMSETTINGS->dir2);
02083              LogError(pCallback,pHANDLERITEMSETTINGS->ItemID,SYNCMGRLOGLEVEL_ERROR,szStatusText);
02084              pHandlerItemID->dwSyncMgrResultStatus = SYNCMGRSTATUS_FAILED;
02085         }
02086     }
02087
02088     if (pHandlerItemID->fCancelled)
02089         goto synccomplete;
02090
02091     if (pfObjDir1 && pfObjDir2)
02092     {
02093         // Calc the progress Item MaxValue which is the total
02094         // number of items to sync.
02095         ulProgressMaxValue += CountNumberOfFilesInList(pfObjDir1,pHANDLERITEMSETTINGS->fRecursive);
02096         ulProgressMaxValue += CountNumberOfFilesInList(pfObjDir2,pHANDLERITEMSETTINGS->fRecursive);
02097
02098         ProgressSetItemProgMaxValue(pCallback,pHANDLERITEMSETTINGS->ItemID,ulProgressMaxValue);
02099         ProgressSetItemProgValue(pCallback,pHANDLERITEMSETTINGS->ItemID,0);
02100
02101         // want to kick Reconcil off pointing to childlist of each toplevel dir
02102         if (pfObjDir1->pFirstGenericItem && pfObjDir2->pFirstGenericItem)
02103         {
02104         LPFILEOBJECTLIST pfObjStartDir1,pfObjStartDir2;
02105         TCHAR *pszDir1Name,*pszDir2Name;
02106
02107             pfObjStartDir1 = ((LPFILEOBJECT) pfObjDir1->pFirstGenericItem)->pChildList;
02108             pfObjStartDir2 = ((LPFILEOBJECT) pfObjDir2->pFirstGenericItem)->pChildList;
02109
02110             pszDir1Name = ((LPFILEOBJECT) pfObjDir1->pFirstGenericItem)->fName;
02111             pszDir2Name = ((LPFILEOBJECT) pfObjDir2->pFirstGenericItem)->fName;
02112
02113             if (pfObjStartDir1 && pfObjStartDir2)
02114             {
02115                 ReconcileDir(hWndParent,pHandlerItemID,pHANDLERITEMSETTINGS,pCallback,&ulProgressCurValue,
02116                                         pszDir1Name,pfObjStartDir1,pszDir2Name,pfObjStartDir2);
02117             }
02118         }
02119     }
02120
02121 synccomplete:
02122
02123     // set progress to max and clear status
02124     ProgressSetItemProgValue(pCallback,pHANDLERITEMSETTINGS->ItemID,ulProgressMaxValue);
02125     ProgressSetItemStatusText(pCallback,pHANDLERITEMSETTINGS->ItemID,TEXT(""));
02126
02127     // update item status based on result.
02128     ProgressSetItemStatusType(pCallback,pHANDLERITEMSETTINGS->ItemID,pHandlerItemID->dwSyncMgrResultStatus);
02129
02130     if (pCallback)
02131     {
02132         pCallback->Release();
02133     }
02134
02135     if (pfObjDir1)
02136     {
02137         ReleaseFileObjectList(pfObjDir1,pHANDLERITEMSETTINGS->fRecursive);
02138     }
02139
02140     if (pfObjDir2)
02141     {
02142         ReleaseFileObjectList(pfObjDir2,pHANDLERITEMSETTINGS->fRecursive);
02143     }
02144 }
02145
02146
02147 //+---------------------------------------------------------------------------
02148 //
02149 //  Function:   HandlerThreadWndProc, private
02150 //
02151 //  Synopsis:   WndProc for hwnd on thread handler was created on
02152 //
02153 //  Arguments:
02154 //
02155 //  Returns:
02156 //
02157 //  Modifies:
02158 //
02159 //----------------------------------------------------------------------------
02160
02161 LRESULT CALLBACK  HandlerThreadWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
02162 {
02163 CSyncMgrHandler *pThis = (CSyncMgrHandler *) GetWindowLongPtr(hWnd, DWL_THREADWNDPROCCLASS);
02164 METHODARGS *pMethodArgs = (METHODARGS *) lParam;
02165 BOOL fMethodCall = FALSE;
02166
02167     switch (msg)
02168     {
02169     case WM_CREATE :
02170         {
02171         CREATESTRUCT *pCreateStruct = (CREATESTRUCT *) lParam;
02172
02173         SetWindowLongPtr(hWnd, DWL_THREADWNDPROCCLASS,(LONG_PTR) pCreateStruct->lpCreateParams );
02174         pThis = (CSyncMgrHandler *) pCreateStruct->lpCreateParams ;
02175         }
02176         break;
02177         case WM_DESTROY:
02178         break;
02179         case WM_WORKERMSG_PROGRESS:
02180             Assert(pMethodArgs);
02181             fMethodCall = TRUE;
02182
02183             if (pMethodArgs)
02184             {
02185                 pMethodArgs->hr = E_UNEXPECTED;
02186
02187                 if (pThis->m_pSyncMgrSynchronizeCallback)
02188                 {
02189                 PROGRESSMSG *pMsg = &(pMethodArgs->ProgressMsg);
02190
02191                     Assert(msg == pMethodArgs->dwWorkerMsg);
02192
02193                     pMethodArgs->hr =
02194                         pThis->m_pSyncMgrSynchronizeCallback->Progress(
02195                                    pMsg->ItemID,
02196                                    pMsg->lpSyncProgressItem);
02197                 }
02198
02199                 Assert(!pMethodArgs->fAsync);
02200             }
02201             break;
02202         case WM_WORKERMSG_PREPAREFORSYNCCOMPLETED:
02203             Assert(pMethodArgs);
02204             fMethodCall = TRUE;
02205
02206             if (pMethodArgs)
02207             {
02208                 pMethodArgs->hr = E_UNEXPECTED;
02209
02210                 if (pThis->m_pSyncMgrSynchronizeCallback)
02211                 {
02212                 PREPAREFORSYNCCOMPLETEDMSG *pMsg = &(pMethodArgs->PrepareForSyncCompletedMsg);
02213
02214                     Assert(msg == pMethodArgs->dwWorkerMsg);
02215
02216                     pMethodArgs->hr =
02217                         pThis->m_pSyncMgrSynchronizeCallback->PrepareForSyncCompleted(
02218                                    pMsg->hr);
02219                 }
02220
02221                 Assert(!pMethodArgs->fAsync);
02222             }
02223             break;
02224         case WM_WORKERMSG_SYNCHRONIZECOMPLETED:
02225             Assert(pMethodArgs);
02226             fMethodCall = TRUE;
02227
02228             if (pMethodArgs)
02229             {
02230                 pMethodArgs->hr = E_UNEXPECTED;
02231
02232                 if (pThis->m_pSyncMgrSynchronizeCallback)
02233                 {
02234                 SYNCHRONIZECOMPLETEDMSG *pMsg = &(pMethodArgs->SynchronizeCompletedMsg);
02235
02236                     Assert(msg == pMethodArgs->dwWorkerMsg);
02237
02238                     pMethodArgs->hr =
02239                         pThis->m_pSyncMgrSynchronizeCallback->SynchronizeCompleted(
02240                                    pMsg->hr);
02241                 }
02242
02243                 Assert(!pMethodArgs->fAsync);
02244             }
02245             break;
02246         case WM_WORKERMSG_SHOWPROPERTIESCOMPLETED:
02247             Assert(pMethodArgs);
02248             fMethodCall = TRUE;
02249
02250             if (pMethodArgs)
02251             {
02252                 pMethodArgs->hr = E_UNEXPECTED;
02253
02254                 if (pThis->m_pSyncMgrSynchronizeCallback)
02255                 {
02256                 SHOWPROPERTIESCOMPLETEDMSG *pMsg = &(pMethodArgs->ShowPropertiesCompletedMsg);
02257
02258                     Assert(msg == pMethodArgs->dwWorkerMsg);
02259
02260                     pMethodArgs->hr =
02261                         pThis->m_pSyncMgrSynchronizeCallback->ShowPropertiesCompleted(
02262                                   pMsg->hr);
02263                 }
02264
02265                 Assert(!pMethodArgs->fAsync);
02266             }
02267             break;
02268         case WM_WORKERMSG_SHOWERRORCOMPLETED:
02269             Assert(pMethodArgs);
02270             fMethodCall = TRUE;
02271
02272             if (pMethodArgs)
02273             {
02274                 pMethodArgs->hr = E_UNEXPECTED;
02275
02276                 if (pThis->m_pSyncMgrSynchronizeCallback)
02277                 {
02278                 SHOWERRORCOMPLETEDMSG *pMsg = &(pMethodArgs->ShowErrorCompletedMsg);
02279
02280                     Assert(msg == pMethodArgs->dwWorkerMsg);
02281
02282                     pMethodArgs->hr =
02283                         pThis->m_pSyncMgrSynchronizeCallback->ShowErrorCompleted(
02284                                    pMsg->hr,
02285                                    pMsg->cbNumItems,
02286                                    pMsg->pItemIDs
02287                                    );
02288                 }
02289
02290                 Assert(!pMethodArgs->fAsync);
02291             }
02292             break;
02293         case WM_WORKERMSG_ENABLEMODELESS:
02294             Assert(pMethodArgs);
02295             fMethodCall = TRUE;
02296
02297             if (pMethodArgs)
02298             {
02299                 pMethodArgs->hr = E_UNEXPECTED;
02300
02301                 if (pThis->m_pSyncMgrSynchronizeCallback)
02302                 {
02303                 ENABLEMODELESSMSG *pMsg = &(pMethodArgs->EnableModelessMsg);
02304
02305                     Assert(msg == pMethodArgs->dwWorkerMsg);
02306
02307                     pMethodArgs->hr =
02308                         pThis->m_pSyncMgrSynchronizeCallback->EnableModeless(
02309                             pMsg->fEnable);
02310                 }
02311
02312                 Assert(!pMethodArgs->fAsync);
02313             }
02314             break;
02315         case WM_WORKERMSG_LOGERROR:
02316             Assert(pMethodArgs);
02317             fMethodCall = TRUE;
02318
02319             if (pMethodArgs)
02320             {
02321                 pMethodArgs->hr = E_UNEXPECTED;
02322
02323                 if (pThis->m_pSyncMgrSynchronizeCallback)
02324                 {
02325                 LOGERRORMSG *pMsg = &(pMethodArgs->LogErrorMsg);
02326
02327                     Assert(msg == pMethodArgs->dwWorkerMsg);
02328
02329                     pMethodArgs->hr =
02330                         pThis->m_pSyncMgrSynchronizeCallback->LogError(
02331                                    pMsg->dwErrorLevel,
02332                                    pMsg->lpcErrorText,
02333                                    pMsg->lpSyncLogError);
02334                 }
02335
02336                 Assert(!pMethodArgs->fAsync);
02337             }
02338             break;
02339         case WM_WORKERMSG_DELETELOGERROR:
02340             Assert(pMethodArgs);
02341             fMethodCall = TRUE;
02342
02343             if (pMethodArgs)
02344             {
02345                 pMethodArgs->hr = E_UNEXPECTED;
02346
02347                 if (pThis->m_pSyncMgrSynchronizeCallback)
02348                 {
02349                 DELETELOGERRORMSG *pMsg = &(pMethodArgs->DeleteLogErrorMsg);
02350
02351                     Assert(msg == pMethodArgs->dwWorkerMsg);
02352
02353                     pMethodArgs->hr =
02354                         pThis->m_pSyncMgrSynchronizeCallback->DeleteLogError(
02355                                    pMsg->ErrorID,
02356                                    pMsg->dwReserved);
02357                 }
02358
02359                 Assert(!pMethodArgs->fAsync);
02360             }
02361             break;
02362         case WM_WORKERMSG_ESTABLISHCONNECTION:
02363             Assert(pMethodArgs);
02364             fMethodCall = TRUE;
02365
02366             if (pMethodArgs)
02367             {
02368                 pMethodArgs->hr = E_UNEXPECTED;
02369
02370                 if (pThis->m_pSyncMgrSynchronizeCallback)
02371                 {
02372                 ESTABLISHCONNECTIONMSG *pMsg = &(pMethodArgs->EstablishConnectionMsg);
02373
02374                     Assert(msg == pMethodArgs->dwWorkerMsg);
02375
02376                     pMethodArgs->hr =
02377                         pThis->m_pSyncMgrSynchronizeCallback->EstablishConnection(
02378                                    pMsg->lpwszConnection,
02379                                    pMsg->dwReserved
02380                                    );
02381                 }
02382
02383                 Assert(!pMethodArgs->fAsync);
02384             }
02385             break;
02386     default:
02387         break;
02388     }
02389
02390     // if this was a method call and async then free methodArgs,
02391     // on synchronous calls up to the caller to free.
02392     if (fMethodCall && pMethodArgs && pMethodArgs->fAsync)
02393     {
02394         FREE(pMethodArgs);
02395     }
02396
02397     return DefWindowProc(hWnd, msg, wParam, lParam);
02398 }
02399
02400
02401
02402
02403
02404 //+---------------------------------------------------------------------------
02405 //
02406 //  Function:   WorkerThreadWndProc, private
02407 //
02408 //  Synopsis:   WndProc for hwnd on the worker thread.
02409 //
02410 //  Arguments:
02411 //
02412 //  Returns:
02413 //
02414 //  Modifies:
02415 //
02416 //----------------------------------------------------------------------------
02417
02418 LRESULT CALLBACK  WorkerThreadWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
02419 {
02420 CSyncMgrHandler *pThis = (CSyncMgrHandler *) GetWindowLongPtr(hWnd, DWL_THREADWNDPROCCLASS);
02421 METHODARGS *pMethodArgs = (METHODARGS *) lParam;
02422 BOOL fMethodCall = FALSE;
02423
02424     switch (msg)
02425     {
02426     case WM_CREATE :
02427         {
02428         CREATESTRUCT *pCreateStruct = (CREATESTRUCT *) lParam;
02429
02430         SetWindowLongPtr(hWnd, DWL_THREADWNDPROCCLASS,(LONG_PTR) pCreateStruct->lpCreateParams );
02431         pThis = (CSyncMgrHandler *) pCreateStruct->lpCreateParams ;
02432         }
02433         break;
02434     case WM_DESTROY:
02435         PostQuitMessage(0); // shut down this thread.
02436         break;
02437     case WM_WORKERMSG_SHOWPROPERTIES:
02438             Assert(pMethodArgs);
02439             fMethodCall = TRUE;
02440             if (pMethodArgs)
02441             {
02442             SHOWPROPERTIESMSG *pShowPropertiesMsg = &(pMethodArgs->ShowPropertiesMsg);
02443
02444                 Assert(WM_WORKERMSG_SHOWPROPERTIES == pMethodArgs->dwWorkerMsg);
02445
02446                 pThis->ShowPropertiesCall(pShowPropertiesMsg->hWndParent,
02447                                                 pShowPropertiesMsg->ItemID);
02448
02449
02450                 Assert(pMethodArgs->fAsync);
02451             }
02452
02453         break;
02454     case WM_WORKERMSG_PREPFORSYNC:
02455
02456             Assert(pMethodArgs);
02457             fMethodCall = TRUE;
02458
02459             if (pMethodArgs)
02460             {
02461             PREPAREFORSYNCMSG *pPrepareForSyncMsg = &(pMethodArgs->PrepareForSyncMsg);
02462
02463                 Assert(WM_WORKERMSG_PREPFORSYNC == pMethodArgs->dwWorkerMsg);
02464
02465             pThis->PrepareForSyncCall(pPrepareForSyncMsg->cbNumItems,
02466                            pPrepareForSyncMsg->pItemIDs,
02467                pPrepareForSyncMsg->hWndParent,
02468                            pPrepareForSyncMsg->dwReserved);
02469
02470                 if (pPrepareForSyncMsg->pItemIDs)
02471                 {
02472                     FREE(pPrepareForSyncMsg->pItemIDs);
02473                 }
02474
02475                 Assert(pMethodArgs->fAsync);
02476             }
02477         break;
02478     case WM_WORKERMSG_SYNCHRONIZE:
02479             Assert(pMethodArgs);
02480             fMethodCall = TRUE;
02481             if (pMethodArgs)
02482             {
02483             SYNCHRONIZEMSG *pSynchronizeMsg = &(pMethodArgs->SynchronizeMsg);
02484
02485                 Assert(WM_WORKERMSG_SYNCHRONIZE == pMethodArgs->dwWorkerMsg);
02486                 Assert(pMethodArgs->fAsync);
02487                 pThis->SynchronizeCall(pSynchronizeMsg->hWndParent);
02488
02489             }
02490
02491         break;
02492     case WM_WORKERMSG_SHOWERROR:
02493             Assert(pMethodArgs);
02494
02495             fMethodCall = TRUE;
02496             if (pMethodArgs)
02497             {
02498             SHOWERRORMSG *pShowErrorMsg = &(pMethodArgs->ShowErrorMsg);
02499
02500                 Assert(pMethodArgs->fAsync);
02501                 Assert(WM_WORKERMSG_SHOWERROR == pMethodArgs->dwWorkerMsg);
02502
02503                 pThis->ShowErrorCall(pShowErrorMsg->hWndParent,
02504                                                 pShowErrorMsg->ErrorID);
02505
02506             }
02507
02508         break;
02509         case WM_WORKERMSG_RELEASE:
02510             DestroyWindow(hWnd);
02511             break;
02512     default:
02513         break;
02514     }
02515
02516     // if this was a method call and async then free methodArgs,
02517     // on synchronous calls up to the caller to free.
02518     if (fMethodCall && pMethodArgs && pMethodArgs->fAsync)
02519     {
02520         FREE(pMethodArgs);
02521     }
02522
02523     return DefWindowProc(hWnd, msg, wParam, lParam);
02524 }
02525
02526
02527 //+---------------------------------------------------------------------------
02528 //
02529 //  Function:   WorkerThread, private
02530 //
02531 //  Synopsis:   ThreadProc for WorkerThread.
02532 //
02533 //  Arguments:
02534 //
02535 //  Returns:
02536 //
02537 //  Modifies:
02538 //
02539 //----------------------------------------------------------------------------
02540
02541 DWORD WINAPI WorkerThread( LPVOID lpArg )
02542 {
02543 MSG msg;
02544 HRESULT hr;
02545 HRESULT hrCoInitialize;
02546 WorkerThreadArgs *pThreadArgs = (WorkerThreadArgs *) lpArg;
02547 HWND hwndWorker;
02548
02549    pThreadArgs->hr = NOERROR;
02550
02551    hrCoInitialize = CoInitialize(NULL);
02552
02553    // need to do a PeekMessage and then set an event to make sure
02554    // a message loop is created before the first PostMessage is sent.
02555
02556    PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
02557
02558    // initialize the dialog box before returning to main thread.
02559    if (FAILED(hrCoInitialize) )
02560    {
02561     pThreadArgs->hr = E_OUTOFMEMORY;
02562    }
02563    else
02564    {
02565
02566     hwndWorker = CreateWindowEx(0,
02567               SZ_SAMPLESYNCMGRWORKERWNDCLASS,
02568               TEXT(""),
02569               // must use WS_POPUP so the window does not get
02570               // assigned a hot key by user.
02571               (WS_DISABLED | WS_POPUP),
02572               CW_USEDEFAULT,
02573               CW_USEDEFAULT,
02574               CW_USEDEFAULT,
02575               CW_USEDEFAULT,
02576               NULL,
02577               NULL,
02578               g_hmodThisDll,
02579               pThreadArgs->pThis);
02580
02581         pThreadArgs->hwnd = hwndWorker;
02582     pThreadArgs->hr =  hwndWorker ? NOERROR : E_UNEXPECTED;
02583     }
02584
02585    hr = pThreadArgs->hr;
02586
02587    // let the caller know the thread is done initializing.
02588    if (pThreadArgs->hEvent)
02589      SetEvent(pThreadArgs->hEvent);
02590
02591
02592    if (NOERROR == hr)
02593    {
02594        // sit in loop receiving messages.
02595        while (GetMessage(&msg, NULL, 0, 0))
02596        {
02597          TranslateMessage(&msg);
02598          DispatchMessage(&msg);
02599     }
02600    }
02601
02602    if (SUCCEEDED(hrCoInitialize))
02603        CoUninitialize();
02604
02605    return 0;
02606 }
02607
02608 BOOL g_fWndRegistered = FALSE;
02609
02610 BOOL RegisterHandlerWndClasses(void)
02611 {
02612
02613     if (!g_fWndRegistered)
02614     {
02615     ATOM aWndClass;
02616     WNDCLASS        xClass;
02617
02618         // register class for window created on handler thread.
02619     xClass.style         = 0;
02620     xClass.lpfnWndProc   = HandlerThreadWndProc;
02621     xClass.cbClsExtra    = 0;
02622
02623     xClass.cbWndExtra    = sizeof(DWORD); // room for class this ptr
02624     xClass.hInstance     = g_hmodThisDll;
02625     xClass.hIcon         = NULL;
02626     xClass.hCursor       = NULL;
02627     xClass.hbrBackground = (HBRUSH) (COLOR_BACKGROUND + 1);
02628     xClass.lpszMenuName  = NULL;
02629     xClass.lpszClassName = SZ_SAMPLESYNCMGRHANDLERWNDCLASS;
02630
02631     aWndClass = RegisterClass( &xClass );
02632
02633         // Register windows class.we need for handling thread communication
02634     xClass.style         = 0;
02635     xClass.lpfnWndProc   = WorkerThreadWndProc;
02636     xClass.cbClsExtra    = 0;
02637
02638     xClass.cbWndExtra    = sizeof(DWORD); // room for class this ptr
02639     xClass.hInstance     = g_hmodThisDll;
02640     xClass.hIcon         = NULL;
02641     xClass.hCursor       = NULL;
02642     xClass.hbrBackground = (HBRUSH) (COLOR_BACKGROUND + 1);
02643     xClass.lpszMenuName  = NULL;
02644     xClass.lpszClassName = SZ_SAMPLESYNCMGRWORKERWNDCLASS;
02645
02646     aWndClass = RegisterClass( &xClass );
02647
02648
02649
02650         g_fWndRegistered = TRUE;
02651     }
02652
02653
02654     return g_fWndRegistered;
02655
02656
02657 }
02658
02659
02660 // implementation of callback wrappers so all callback calls are sent to
02661 // syncmgr on the thread we were created on. We only implement the
02662 // methods we call.
02663
02664 CCallbackWrapper::CCallbackWrapper(HWND hwndCallback)
02665 {
02666
02667     Assert(hwndCallback);
02668
02669     m_hwndCallback = hwndCallback;
02670     m_cRef = 1;
02671
02672 }
02673
02674 CCallbackWrapper::~CCallbackWrapper()
02675 {
02676     m_hwndCallback = NULL;
02677
02678     Assert(0 == m_cRef);
02679 }
02680
02681
02682 //IUnknown methods
02683 STDMETHODIMP CCallbackWrapper::QueryInterface(REFIID, LPVOID FAR *)
02684 {
02685     return E_NOTIMPL;
02686 }
02687
02688 STDMETHODIMP_(ULONG) CCallbackWrapper::AddRef()
02689 {
02690     ++m_cRef;
02691
02692     return m_cRef;
02693 }
02694
02695 STDMETHODIMP_(ULONG) CCallbackWrapper::Release()
02696 {
02697 DWORD cRefs;
02698
02699     --m_cRef;
02700
02701     cRefs = m_cRef;
02702
02703     if (0 == m_cRef)
02704     {
02705         delete this;
02706     }
02707
02708     return cRefs;
02709 }
02710
02711 // Callback methods.
02712 STDMETHODIMP CCallbackWrapper::Progress(REFSYNCMGRITEMID ItemID,LPSYNCMGRPROGRESSITEM lpSyncProgressItem)
02713 {
02714 METHODARGS MethodArgs;
02715
02716     MethodArgs.fAsync = FALSE;
02717     MethodArgs.hr = E_UNEXPECTED;
02718
02719
02720     MethodArgs.dwWorkerMsg = WM_WORKERMSG_PROGRESS;
02721     MethodArgs.ProgressMsg.ItemID = ItemID;
02722     MethodArgs.ProgressMsg.lpSyncProgressItem = lpSyncProgressItem;
02723
02724     if (m_hwndCallback)
02725     {
02726         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02727     }
02728
02729     return MethodArgs.hr;
02730 }
02731
02732 STDMETHODIMP CCallbackWrapper::PrepareForSyncCompleted(HRESULT hr)
02733 {
02734 METHODARGS MethodArgs;
02735
02736     MethodArgs.fAsync = FALSE;
02737     MethodArgs.hr = E_UNEXPECTED;
02738
02739     MethodArgs.dwWorkerMsg = WM_WORKERMSG_PREPAREFORSYNCCOMPLETED;
02740     MethodArgs.PrepareForSyncCompletedMsg.hr = hr;
02741
02742     if (m_hwndCallback)
02743     {
02744         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02745     }
02746
02747     return MethodArgs.hr;
02748 }
02749
02750 STDMETHODIMP CCallbackWrapper::SynchronizeCompleted(HRESULT hr)
02751 {
02752 METHODARGS MethodArgs;
02753
02754     MethodArgs.fAsync = FALSE;
02755     MethodArgs.hr = E_UNEXPECTED;
02756
02757     MethodArgs.dwWorkerMsg = WM_WORKERMSG_SYNCHRONIZECOMPLETED;
02758     MethodArgs.SynchronizeCompletedMsg.hr = hr;
02759
02760     if (m_hwndCallback)
02761     {
02762         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02763     }
02764
02765     return MethodArgs.hr;
02766 }
02767
02768 STDMETHODIMP CCallbackWrapper::ShowPropertiesCompleted(HRESULT hr)
02769 {
02770 METHODARGS MethodArgs;
02771
02772     MethodArgs.fAsync = FALSE;
02773     MethodArgs.hr = E_UNEXPECTED;
02774
02775     MethodArgs.dwWorkerMsg = WM_WORKERMSG_SHOWPROPERTIESCOMPLETED;
02776     MethodArgs.ShowPropertiesCompletedMsg.hr = hr;
02777
02778     if (m_hwndCallback)
02779     {
02780         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02781     }
02782
02783     return MethodArgs.hr;
02784
02785 }
02786
02787 STDMETHODIMP CCallbackWrapper::ShowErrorCompleted(HRESULT hr,ULONG cbNumItems,SYNCMGRITEMID *pItemIDs)
02788 {
02789 METHODARGS MethodArgs;
02790
02791     MethodArgs.fAsync = FALSE;
02792     MethodArgs.hr = E_UNEXPECTED;
02793
02794     MethodArgs.dwWorkerMsg = WM_WORKERMSG_SHOWERRORCOMPLETED;
02795     MethodArgs.ShowErrorCompletedMsg.hr = hr;
02796     MethodArgs.ShowErrorCompletedMsg.cbNumItems = cbNumItems;
02797     MethodArgs.ShowErrorCompletedMsg.pItemIDs = pItemIDs;
02798
02799     if (m_hwndCallback)
02800     {
02801         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02802     }
02803
02804     return MethodArgs.hr;
02805 }
02806
02807 STDMETHODIMP CCallbackWrapper::EnableModeless(BOOL fEnable)
02808 {
02809 METHODARGS MethodArgs;
02810
02811     MethodArgs.fAsync = FALSE;
02812     MethodArgs.hr = E_UNEXPECTED;
02813
02814     MethodArgs.dwWorkerMsg = WM_WORKERMSG_ENABLEMODELESS;
02815     MethodArgs.EnableModelessMsg.fEnable = fEnable;
02816
02817     if (m_hwndCallback)
02818     {
02819         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02820     }
02821
02822     return MethodArgs.hr;
02823 }
02824
02825 STDMETHODIMP CCallbackWrapper::LogError(DWORD dwErrorLevel,const WCHAR *lpcErrorText,LPSYNCMGRLOGERRORINFO lpSyncLogError)
02826 {
02827 METHODARGS MethodArgs;
02828
02829     MethodArgs.fAsync = FALSE;
02830     MethodArgs.hr = E_UNEXPECTED;
02831
02832
02833     MethodArgs.dwWorkerMsg = WM_WORKERMSG_LOGERROR;
02834     MethodArgs.LogErrorMsg.dwErrorLevel = dwErrorLevel;
02835     MethodArgs.LogErrorMsg.lpcErrorText = lpcErrorText;
02836     MethodArgs.LogErrorMsg.lpSyncLogError = lpSyncLogError;
02837
02838     if (m_hwndCallback)
02839     {
02840         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02841     }
02842
02843     return MethodArgs.hr;
02844 }
02845
02846 STDMETHODIMP CCallbackWrapper::DeleteLogError(REFSYNCMGRERRORID ErrorID,DWORD dwReserved)
02847 {
02848 METHODARGS MethodArgs;
02849
02850     MethodArgs.fAsync = FALSE;
02851     MethodArgs.hr = E_UNEXPECTED;
02852
02853
02854     MethodArgs.dwWorkerMsg = WM_WORKERMSG_DELETELOGERROR;
02855     MethodArgs.DeleteLogErrorMsg.ErrorID = ErrorID;
02856     MethodArgs.DeleteLogErrorMsg.dwReserved = dwReserved;
02857
02858     if (m_hwndCallback)
02859     {
02860         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02861     }
02862
02863     return MethodArgs.hr;
02864 }
02865
02866 STDMETHODIMP CCallbackWrapper::EstablishConnection( WCHAR const * lpwszConnection, DWORD dwReserved)
02867 {
02868 METHODARGS MethodArgs;
02869
02870     MethodArgs.fAsync = FALSE;
02871     MethodArgs.hr = E_UNEXPECTED;
02872
02873
02874     MethodArgs.dwWorkerMsg = WM_WORKERMSG_ESTABLISHCONNECTION;
02875     MethodArgs.EstablishConnectionMsg.lpwszConnection = lpwszConnection;
02876     MethodArgs.EstablishConnectionMsg.dwReserved = dwReserved;
02877
02878     if (m_hwndCallback)
02879     {
02880         SendMessage(m_hwndCallback,MethodArgs.dwWorkerMsg,0,(LPARAM) &MethodArgs);
02881     }
02882
02883     return MethodArgs.hr;
02884 }
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/drawarea.h Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

drawarea.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // drawarea.h : header file
00014 //
00015
00016
00017 #define MAX_MSG_BODY_LEN 32
00018
00019 typedef struct tagLINE
00020 {
00021   CPoint ptStart;
00022   CPoint ptEnd;
00023 } LINE;
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // CDrawArea window
00027
00028 class CDrawArea : public CEdit
00029 {
00030 // Construction
00031 public:
00032   CDrawArea();
00033
00034 // Attributes
00035 public:
00036
00037 protected:
00038   CPoint m_ptLast;
00039   CList<LINE, LINE &> m_listLines;
00040
00041 // Operations
00042 public:
00043   void AddLine(LINE line);
00044   void AddKeystroke(char *mbsKey);
00045
00046 // Overrides
00047   // ClassWizard generated virtual function overrides
00048   //{{AFX_VIRTUAL(CDrawArea)
00049   //}}AFX_VIRTUAL
00050
00051 // Implementation
00052 public:
00053   virtual ~CDrawArea();
00054
00055   // Generated message map functions
00056 protected:
00057   //{{AFX_MSG(CDrawArea)
00058   afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00059   afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00060   afx_msg void OnPaint();
00061   afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
00062   afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
00063   afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00064   afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00065   afx_msg void OnSetFocus(CWnd* pOldWnd);
00066   afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
00067   afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00068   //}}AFX_MSG
00069
00070   DECLARE_MESSAGE_MAP()
00071 };
00072
00073 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

GBGETTEXTA Member List

This is the complete list of members for GBGETTEXTA, including all inherited members.
cch | GBGETTEXTA
psz | GBGETTEXTA
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/AboutDlg.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

AboutDlg.h

Go to the documentation of this file.
00001 /*
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 global functions found in AboutDlg.c
00010 */
00011
00012 LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/xml/mfc_tree/XMLTreeDlg.h Source File

  • Web
  • xml
  • mfc_tree

XMLTreeDlg.h

Go to the documentation of this file.
00001 //=--------------------------------------------------------------------------=
00002 //  (C) Copyright 1996 - 2000 Microsoft Corporation. All Rights Reserved.
00003 //=--------------------------------------------------------------------------=
00004
00005 // XMLTreeDlg.h : header file
00006 //
00007
00008 #if !defined(AFX_XMLTREEDLG_H__3C9F0B07_FD51_11D2_AC35_00600812D7F9__INCLUDED_)
00009 #define AFX_XMLTREEDLG_H__3C9F0B07_FD51_11D2_AC35_00600812D7F9__INCLUDED_
00010
00011 #if _MSC_VER > 1000
00012 #pragma once
00013 #endif // _MSC_VER > 1000
00014
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // CXMLTreeDlg dialog
00018
00019 class CXMLTreeDlg : public CDialog
00020 {
00021 // Construction
00022 public:
00023   CImageList m_imageList;
00024   int MakeTree(MSXML::IXMLDOMElement *node, HTREEITEM ht);
00025   int LoadXML(CString filename);
00026   CXMLTreeDlg(CWnd* pParent = NULL);  // standard constructor
00027
00028 // Dialog Data
00029   //{{AFX_DATA(CXMLTreeDlg)
00030   enum { IDD = IDD_XMLTREE_DIALOG };
00031   CTreeCtrl m_tree;
00032   CString m_filename;
00033   CString m_debug;
00034   //}}AFX_DATA
00035
00036   // ClassWizard generated virtual function overrides
00037   //{{AFX_VIRTUAL(CXMLTreeDlg)
00038   protected:
00039   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00040   //}}AFX_VIRTUAL
00041
00042     virtual void OnOK();
00043 // Implementation
00044 protected:
00045   HICON m_hIcon;
00046
00047   // Generated message map functions
00048   //{{AFX_MSG(CXMLTreeDlg)
00049   virtual BOOL OnInitDialog();
00050   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00051   afx_msg void OnPaint();
00052   afx_msg HCURSOR OnQueryDragIcon();
00053   afx_msg void OnLoad();
00054   afx_msg void OnChangeFilename();
00055   afx_msg void OnOpen();
00056   //}}AFX_MSG
00057   DECLARE_MESSAGE_MAP()
00058 };
00059
00060 //{{AFX_INSERT_LOCATION}}
00061 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00062
00063 #endif // !defined(AFX_XMLTREEDLG_H__3C9F0B07_FD51_11D2_AC35_00600812D7F9__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/BasePage.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

BasePage.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      BasePage.cpp
00007 //
00008 //  Description:
00009 //      Implementation of the CBasePropertyPage class.
00010 //
00011 //  Author:
00012 //      <name> (<e-mail name>) Mmmm DD, 2003
00013 //
00014 //  Revision History:
00015 //
00016 //  Notes:
00017 //
00018 /////////////////////////////////////////////////////////////////////////////
00019
00020 #include "stdafx.h"
00021 #include "File Share SampleEx.h"
00022 #include "ExtObj.h"
00023 #include "BasePage.h"
00024
00025 #ifdef _DEBUG
00026 #define new DEBUG_NEW
00027 #undef THIS_FILE
00028 static char THIS_FILE[] = __FILE__;
00029 #endif
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // CBasePropertyPage property page
00033 /////////////////////////////////////////////////////////////////////////////
00034
00035 IMPLEMENT_DYNCREATE( CBasePropertyPage, CPropertyPage )
00036
00037 /////////////////////////////////////////////////////////////////////////////
00038 // Message Maps
00039 /////////////////////////////////////////////////////////////////////////////
00040
00041 BEGIN_MESSAGE_MAP( CBasePropertyPage, CPropertyPage )
00042     //{{AFX_MSG_MAP(CBasePropertyPage)
00043     ON_WM_CREATE()
00044     ON_WM_DESTROY()
00045     //}}AFX_MSG_MAP
00046 END_MESSAGE_MAP()
00047
00048 /////////////////////////////////////////////////////////////////////////////
00049 //++
00050 //
00051 //  CBasePropertyPage::CBasePropertyPage
00052 //
00053 //  Description:
00054 //      Default constructor.
00055 //
00056 //  Arguments:
00057 //      None.
00058 //
00059 //  Return Value:
00060 //      None.
00061 //
00062 //--
00063 /////////////////////////////////////////////////////////////////////////////
00064 CBasePropertyPage::CBasePropertyPage( void )
00065 {
00066     CommonConstruct();
00067
00068 } //*** CBasePropertyPage::CBasePropertyPage
00069
00070 /////////////////////////////////////////////////////////////////////////////
00071 //++
00072 //
00073 //  CBasePropertyPage::CBasePropertyPage
00074 //
00075 //  Description:
00076 //      Default constructor.
00077 //
00078 //  Arguments:
00079 //      nIDTemplateIn
00080 //          Dialog template resource ID.
00081 //
00082 //      nIDCaptionIn
00083 //          Caption string resource ID.
00084 //
00085 //  Return Value:
00086 //      None.
00087 //
00088 //--
00089 /////////////////////////////////////////////////////////////////////////////
00090 CBasePropertyPage::CBasePropertyPage(
00091       UINT  nIDTemplateIn
00092     , UINT  nIDCaptionIn
00093     )
00094     : CPropertyPage( nIDTemplateIn, nIDCaptionIn )
00095 {
00096     CommonConstruct();
00097
00098 } //*** CBasePropertyPage::CBasePropertyPage
00099
00100 /////////////////////////////////////////////////////////////////////////////
00101 //++
00102 //
00103 //  CBasePropertyPage::CommonConstruct
00104 //
00105 //  Description:
00106 //      Common construction.
00107 //
00108 //  Arguments:
00109 //      None.
00110 //
00111 //  Return Value:
00112 //      None.
00113 //
00114 //--
00115 /////////////////////////////////////////////////////////////////////////////
00116 void
00117 CBasePropertyPage::CommonConstruct( void )
00118 {
00119     //{{AFX_DATA_INIT(CBasePropertyPage)
00120     //}}AFX_DATA_INIT
00121
00122     m_peo = NULL;
00123     m_hpage = NULL;
00124     m_bBackPressed = FALSE;
00125     m_bSaved = FALSE;
00126
00127     m_iddPropertyPage = NULL;
00128     m_iddWizardPage = NULL;
00129     m_idsCaption = NULL;
00130
00131     m_bDoDetach = FALSE;
00132
00133 } //*** CBasePropertyPage::CommonConstruct
00134
00135 /////////////////////////////////////////////////////////////////////////////
00136 //++
00137 //
00138 //  CBasePropertyPage::HrInit
00139 //
00140 //  Description:
00141 //      Initialize the page.
00142 //
00143 //  Arguments:
00144 //      peoInout
00145 //          Pointer to the extension object.
00146 //
00147 //  Return Value:
00148 //      S_OK
00149 //          Page initialized successfully.
00150 //
00151 //      Other HRESULTs
00152 //          Page failed to initialize.
00153 //
00154 //--
00155 /////////////////////////////////////////////////////////////////////////////
00156 HRESULT
00157 CBasePropertyPage::HrInit(
00158     CExtObject * peoInout
00159     )
00160 {
00161     ASSERT( peoInout != NULL );
00162
00163     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00164
00165     HRESULT         hr = S_OK;
00166     CWaitCursor     wc;
00167     DWORD           sc = ERROR_SUCCESS;
00168     CClusPropList   cpl;
00169
00170     m_peo = peoInout;
00171
00172     //
00173     //  Don't display a help button.
00174     //
00175
00176     m_psp.dwFlags &= ~PSP_HASHELP;
00177
00178     //
00179     //  Construct the property page.
00180     //
00181
00182     if ( Peo()->BWizard() )
00183     {
00184         ASSERT( IddWizardPage() != NULL);
00185         Construct( IddWizardPage(), IdsCaption() );
00186     } // if: adding page to wizard
00187     else
00188     {
00189         ASSERT( IddPropertyPage() != NULL );
00190         Construct( IddPropertyPage(), IdsCaption() );
00191     } // else: adding page to property sheet
00192
00193     //
00194     //  Read the properties private to this resource and parse them.
00195     //
00196
00197     ASSERT( Peo() != NULL );
00198     ASSERT( Peo()->PodObjData() );
00199
00200     //
00201     //  Read the properties.
00202     //
00203
00204     switch ( Cot() )
00205     {
00206         case CLUADMEX_OT_CLUSTER:
00207         {
00208             CClusterData * pccd = reinterpret_cast< CClusterData * >( Peo()->PodObjData() );
00209             ASSERT( pccd && (pccd->GetHCluster() != NULL) );
00210             sc = cpl.ScGetClusterProperties(
00211                                       pccd->GetHCluster()
00212                                     , CLUSCTL_CLUSTER_GET_PRIVATE_PROPERTIES
00213                                     );
00214             break;
00215         }
00216         case CLUADMEX_OT_NODE:
00217         {
00218             CNodeData * pcnd = reinterpret_cast< CNodeData * >( Peo()->PodObjData() );
00219             ASSERT( pcnd && (pcnd->GetHNode() != NULL) );
00220             sc = cpl.ScGetNodeProperties(
00221                                       pcnd->GetHNode()
00222                                     , CLUSCTL_NODE_GET_PRIVATE_PROPERTIES
00223                                     );
00224             break;
00225         }
00226         case CLUADMEX_OT_GROUP:
00227         {
00228             CGroupData * pcgd = reinterpret_cast< CGroupData * >( Peo()->PodObjData() );
00229             ASSERT( pcgd && (pcgd->GetHGroup() != NULL) );
00230             sc = cpl.ScGetGroupProperties(
00231                                       pcgd->GetHGroup()
00232                                     , CLUSCTL_GROUP_GET_PRIVATE_PROPERTIES
00233                                     );
00234             break;
00235         }
00236         case CLUADMEX_OT_RESOURCE:
00237         {
00238             CResData * pcrd = reinterpret_cast< CResData * >( Peo()->PodObjData() );
00239             ASSERT( pcrd && (pcrd->GetHResource() != NULL) );
00240             sc = cpl.ScGetResourceProperties(
00241                                       pcrd->GetHResource()
00242                                     , CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES
00243                                     );
00244             break;
00245         }
00246         case CLUADMEX_OT_RESOURCETYPE:
00247         {
00248             CResTypeData * pcrd = reinterpret_cast< CResTypeData * >( Peo()->PodObjData() );
00249             ASSERT( pcrd && (pcrd->StrName().GetLength() > 0) );
00250             sc = cpl.ScGetResourceTypeProperties(
00251                                       Hcluster()
00252                                     , pcrd->StrName()
00253                                     , CLUSCTL_RESOURCE_TYPE_GET_PRIVATE_PROPERTIES
00254                                     );
00255             break;
00256         }
00257         case CLUADMEX_OT_NETWORK:
00258         {
00259             CNetworkData * pcnd = reinterpret_cast< CNetworkData * >( Peo()->PodObjData() );
00260             ASSERT( pcnd && (pcnd->GetHNetwork() != NULL) );
00261             sc = cpl.ScGetNetworkProperties(
00262                                       pcnd->GetHNetwork()
00263                                     , CLUSCTL_NETWORK_GET_PRIVATE_PROPERTIES
00264                                     );
00265             break;
00266         }
00267         case CLUADMEX_OT_NETINTERFACE:
00268         {
00269             CNetInterfaceData * pcnd = reinterpret_cast< CNetInterfaceData * >( Peo()->PodObjData() );
00270             ASSERT( pcnd && (pcnd->GetHNetInterface() != NULL) );
00271             sc = cpl.ScGetNetInterfaceProperties(
00272                                       pcnd->GetHNetInterface()
00273                                     , CLUSCTL_NETINTERFACE_GET_PRIVATE_PROPERTIES
00274                                     );
00275             break;
00276         }
00277         default:
00278             ASSERT( 0 );
00279     } // switch: object type
00280
00281     //
00282     //  Parse the properties.
00283     //
00284
00285     if ( sc == ERROR_SUCCESS )
00286     {
00287         // Parse the properties.
00288         try
00289         {
00290             sc = ScParseProperties( cpl );
00291         } // try
00292         catch ( CMemoryException * pme )
00293         {
00294             hr = E_OUTOFMEMORY;
00295             pme->Delete();
00296         } // catch: CMemoryException
00297     } // if: properties read successfully
00298
00299     if ( sc != ERROR_SUCCESS )
00300     {
00301         hr = HRESULT_FROM_WIN32( sc );
00302         goto Cleanup;
00303     } // if: error parsing getting or parsing properties
00304
00305 Cleanup:
00306
00307     return hr;
00308
00309 } //*** CBasePropertyPage::HrInit
00310
00311 /////////////////////////////////////////////////////////////////////////////
00312 //++
00313 //
00314 //  CBasePropertyPage::HrCreatePage
00315 //
00316 //  Description:
00317 //      Create the page.
00318 //
00319 //  Arguments:
00320 //      None.
00321 //
00322 //  Return Value:
00323 //      S_OK
00324 //          Page created successfully.
00325 //
00326 //      Other HRESULTs
00327 //          Error creating the page.
00328 //
00329 //--
00330 /////////////////////////////////////////////////////////////////////////////
00331 HRESULT
00332 CBasePropertyPage::HrCreatePage( void )
00333 {
00334     ASSERT( m_hpage == NULL );
00335
00336     HRESULT hr = S_OK;
00337
00338     m_hpage = CreatePropertySheetPage( reinterpret_cast< LPPROPSHEETPAGEW >( &m_psp ) );
00339     if ( m_hpage == NULL )
00340     {
00341         hr = HRESULT_FROM_WIN32( GetLastError() );
00342     } // if: error creating the page
00343
00344     return hr;
00345
00346 } //*** CBasePropertyPage::HrCreatePage
00347
00348 /////////////////////////////////////////////////////////////////////////////
00349 //++
00350 //
00351 //  CBasePropertyPage::ScParseProperties
00352 //
00353 //  Description:
00354 //      Parse the properties of the resource.  This is in a separate function
00355 //      from HrInit so that the optimizer can do a better job.
00356 //
00357 //  Arguments:
00358 //      rcplIn
00359 //          Cluster property list to parse.
00360 //
00361 //  Return Values:
00362 //      ERROR_SUCCESS
00363 //          Properties were parsed successfully.
00364 //
00365 //      Other HRESULTs
00366 //          Error parsing the properties.  (Includes any error returned from
00367 //          ScParseUnknownProperty().)
00368 //
00369 //  Exceptions Thrown:
00370 //      Any exceptions from CString::operator=().
00371 //
00372 //--
00373 /////////////////////////////////////////////////////////////////////////////
00374 DWORD
00375 CBasePropertyPage::ScParseProperties(
00376     CClusPropList & rcplIn
00377     )
00378 {
00379     DWORD                   sc = ERROR_SUCCESS;
00380     DWORD                   cprop;
00381     const CObjectProperty * pprop;
00382
00383     ASSERT( rcplIn.PbPropList() != NULL );
00384
00385     sc = rcplIn.ScMoveToFirstProperty();
00386     while ( sc == ERROR_SUCCESS )
00387     {
00388         //
00389         // Parse known properties.
00390         //
00391
00392         for ( pprop = Pprops(), cprop = Cprops() ; cprop > 0 ; pprop++, cprop-- )
00393         {
00394             if ( NIStringCompareW(
00395                                    rcplIn.PszCurrentPropertyName()
00396                                  , pprop->m_pwszName
00397                                  , rcplIn.CbhCurrentPropertyName().pName->cbLength / sizeof( WCHAR )
00398                                  ) == 0
00399                )
00400             {
00401                 if ( rcplIn.CpfCurrentValueFormat() == pprop->m_propFormat )
00402                 {
00403                     switch ( pprop->m_propFormat )
00404                     {
00405                         case CLUSPROP_FORMAT_SZ:
00406                         case CLUSPROP_FORMAT_EXPAND_SZ:
00407                             ASSERT(     (rcplIn.CbCurrentValueLength() == (lstrlenW( rcplIn.CbhCurrentValue().pStringValue->sz ) + 1) * sizeof( WCHAR ))
00408                                     ||  (   (rcplIn.CbCurrentValueLength() == 0)
00409                                         &&  (rcplIn.CbhCurrentValue().pStringValue->sz[ 0 ] == L'\0') ) );
00410                             *pprop->m_value.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00411                             *pprop->m_valuePrev.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00412
00413                             //
00414                             //  See if we need to find an expanded version
00415                             //
00416
00417                             if ( pprop->m_valueEx.pstr != NULL )
00418                             {
00419                                 // Copy the non-expanded one just in case there isn't an expanded version
00420                                 *pprop->m_valueEx.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00421
00422                                 // See if they included an expanded version
00423                                 rcplIn.ScMoveToNextPropertyValue( );
00424                                 if ( rcplIn.CpfCurrentValueFormat( ) == CLUSPROP_FORMAT_EXPANDED_SZ )
00425                                 {
00426                                     *pprop->m_valueEx.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00427                                 } // if: found expanded version
00428
00429                             } // if: *pprop->m_valueEx.pstr is present
00430                             break;
00431
00432                         case CLUSPROP_FORMAT_EXPANDED_SZ:
00433                             ASSERT(     (rcplIn.CbCurrentValueLength() == (lstrlenW( rcplIn.CbhCurrentValue().pStringValue->sz ) + 1) * sizeof( WCHAR ))
00434                                     ||  (   (rcplIn.CbCurrentValueLength() == 0)
00435                                         &&  (rcplIn.CbhCurrentValue().pStringValue->sz[ 0 ] == L'\0') ) );
00436                             *pprop->m_value.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00437                             *pprop->m_valuePrev.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00438
00439                             //
00440                             //  See if we need to find an expanded version
00441                             //
00442
00443                             if ( *pprop->m_valueEx.pstr ) // can not use != NULL because overloading tries to do a string compare!
00444                             {
00445                                 // Copy the expanded version
00446                                 *pprop->m_valueEx.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00447
00448                                 // See if they included a non-expanded version
00449                                 rcplIn.ScMoveToNextPropertyValue( );
00450                                 if ( rcplIn.CpfCurrentValueFormat( ) == CLUSPROP_FORMAT_SZ )
00451                                 {
00452                                     *pprop->m_value.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00453                                     *pprop->m_valuePrev.pstr = rcplIn.CbhCurrentValue().pStringValue->sz;
00454                                 } // if: found non-expanded version
00455
00456                             } // if: *pprop->m_valueEx.pstr is present
00457                             break;
00458
00459                         case CLUSPROP_FORMAT_DWORD:
00460                         case CLUSPROP_FORMAT_LONG:
00461                             ASSERT( rcplIn.CbCurrentValueLength() == sizeof( DWORD ) );
00462                             *pprop->m_value.pdw = rcplIn.CbhCurrentValue().pDwordValue->dw;
00463                             *pprop->m_valuePrev.pdw = rcplIn.CbhCurrentValue().pDwordValue->dw;
00464                             break;
00465
00466                         case CLUSPROP_FORMAT_BINARY:
00467                         case CLUSPROP_FORMAT_MULTI_SZ:
00468                             *pprop->m_value.ppb = rcplIn.CbhCurrentValue().pBinaryValue->rgb;
00469                             *pprop->m_value.pcb = rcplIn.CbhCurrentValue().pBinaryValue->cbLength;
00470                             *pprop->m_valuePrev.ppb = rcplIn.CbhCurrentValue().pBinaryValue->rgb;
00471                             *pprop->m_valuePrev.pcb = rcplIn.CbhCurrentValue().pBinaryValue->cbLength;
00472                             break;
00473
00474                         default:
00475                             ASSERT(0);  // don't know how to deal with this type
00476                     } // switch: property format
00477
00478                     //
00479                     //  Exit the loop since we found the parameter.
00480                     //
00481
00482                     break;
00483                 }// if: found a type match
00484             } // if: found a string match
00485         } // for: each property that we know about
00486
00487         //
00488         // If the property wasn't known, ask the derived class to parse it.
00489         //
00490
00491         if ( cprop == 0 )
00492         {
00493             sc = ScParseUnknownProperty(
00494                           rcplIn.CbhCurrentPropertyName().pName->sz
00495                         , rcplIn.CbhCurrentValue()
00496                         , rcplIn.RPvlPropertyValue().CbDataLeft()
00497                         );
00498             if ( sc != ERROR_SUCCESS )
00499             {
00500                 return sc;
00501             } // if: error parsing the unknown property
00502         } // if: property not parsed
00503
00504         //
00505         // Advance the buffer pointer past the value in the value list.
00506         //
00507
00508         sc = rcplIn.ScMoveToNextProperty();
00509     } // while: more properties to parse
00510
00511     //
00512     // If we reached the end of the properties, fix the return code.
00513     //
00514
00515     if ( sc == ERROR_NO_MORE_ITEMS )
00516     {
00517         sc = ERROR_SUCCESS;
00518     } // if: ended loop after parsing all properties
00519
00520     return sc;
00521
00522 } //*** CBasePropertyPage::ScParseProperties
00523
00524 /////////////////////////////////////////////////////////////////////////////
00525 //++
00526 //
00527 //  CBasePropertyPage::OnCreate
00528 //
00529 //  Description:
00530 //      Handler for the WM_CREATE message.
00531 //
00532 //  Arguments:
00533 //      lpCreateStructIn
00534 //          Window create structure.
00535 //
00536 //  Return Value:
00537 //      -1
00538 //          Error.
00539 //
00540 //      0
00541 //          Success.
00542 //
00543 //--
00544 /////////////////////////////////////////////////////////////////////////////
00545 int
00546 CBasePropertyPage::OnCreate(
00547     LPCREATESTRUCT lpCreateStructIn
00548     )
00549 {
00550     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00551
00552     //
00553     // Attach the window to the property page structure.
00554     // This has been done once already in the main application, since the
00555     // main application owns the property sheet.  It needs to be done here
00556     // so that the window handle can be found in the DLL's handle map.
00557     //
00558
00559     if ( FromHandlePermanent( m_hWnd ) == NULL ) // is the window handle already in the handle map
00560     {
00561         HWND hWnd = m_hWnd;
00562         m_hWnd = NULL;
00563         Attach( hWnd );
00564         m_bDoDetach = TRUE;
00565     } // if: is the window handle in the handle map
00566
00567     return CPropertyPage::OnCreate( lpCreateStructIn );
00568
00569 } //*** CBasePropertyPage::OnCreate
00570
00571 /////////////////////////////////////////////////////////////////////////////
00572 //++
00573 //
00574 //  CBasePropertyPage::OnDestroy
00575 //
00576 //  Description:
00577 //      Handler for the WM_DESTROY message.
00578 //
00579 //  Arguments:
00580 //      None.
00581 //
00582 //  Return Value:
00583 //      None.
00584 //
00585 //--
00586 /////////////////////////////////////////////////////////////////////////////
00587 void
00588 CBasePropertyPage::OnDestroy( void )
00589 {
00590     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00591
00592     //
00593     // Detach the window from the property page structure.
00594     // This will be done again by the main application, since it owns the
00595     // property sheet.  It needs to be done here so that the window handle
00596     // can be removed from the DLL's handle map.
00597     //
00598
00599     if ( m_bDoDetach )
00600     {
00601         if ( m_hWnd != NULL )
00602         {
00603             HWND hWnd = m_hWnd;
00604
00605             Detach();
00606             m_hWnd = hWnd;
00607         } // if: do we have a window handle?
00608     } // if: do we need to balance the attach we did with a detach?
00609
00610     CPropertyPage::OnDestroy();
00611
00612 } //*** CBasePropertyPage::OnDestroy
00613
00614 /////////////////////////////////////////////////////////////////////////////
00615 //++
00616 //
00617 //  CBasePropertyPage::DoDataExchange
00618 //
00619 //  Description:
00620 //      Do data exchange between the dialog and the class.
00621 //
00622 //  Arguments:
00623 //      pDXIn
00624 //          Data exchange object
00625 //
00626 //  Return Value:
00627 //      None.
00628 //
00629 //--
00630 /////////////////////////////////////////////////////////////////////////////
00631 void
00632 CBasePropertyPage::DoDataExchange(
00633     CDataExchange * pDXIn
00634     )
00635 {
00636     if ( ! pDXIn->m_bSaveAndValidate || ! BSaved() )
00637     {
00638         AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00639
00640         //{{AFX_DATA_MAP(CBasePropertyPage)
00641             // NOTE: the ClassWizard will add DDX and DDV calls here
00642         //}}AFX_DATA_MAP
00643
00644         DDX_Control( pDXIn, IDC_PP_ICON, m_staticIcon );
00645         DDX_Control( pDXIn, IDC_PP_TITLE, m_staticTitle );
00646
00647         if ( pDXIn->m_bSaveAndValidate )
00648         {
00649             if ( ! BBackPressed() )
00650             {
00651                 CWaitCursor wc;
00652
00653                 //
00654                 //  Validate the data.
00655                 //
00656
00657                 if ( ! BSetPrivateProps( TRUE /*fValidateOnlyIn*/ ) )
00658                 {
00659                     pDXIn->Fail();
00660                 } // if: error setting private properties
00661             } // if: Back button not pressed
00662         } // if: saving data from dialog
00663         else
00664         {
00665             //
00666             //  Set the title.
00667             //
00668
00669             DDX_Text( pDXIn, IDC_PP_TITLE, m_strTitle );
00670         } // if: not saving data
00671     }  // if: not saving or haven't saved yet
00672
00673     //
00674     //  Call the base class method.
00675     //
00676
00677     CPropertyPage::DoDataExchange( pDXIn );
00678
00679 } //*** CBasePropertyPage::DoDataExchange
00680
00681 /////////////////////////////////////////////////////////////////////////////
00682 //++
00683 //
00684 //  CBasePropertyPage::OnInitDialog
00685 //
00686 //  Description:
00687 //      Handler for the WM_INITDIALOG message.
00688 //
00689 //  Arguments:
00690 //      None.
00691 //
00692 //  Return Value:
00693 //      TRUE
00694 //          We need the focus to be set for us.
00695 //
00696 //      FALSE
00697 //          We already set the focus to the proper control.
00698 //
00699 //--
00700 /////////////////////////////////////////////////////////////////////////////
00701 BOOL
00702 CBasePropertyPage::OnInitDialog( void )
00703 {
00704     ASSERT( Peo() != NULL );
00705     ASSERT( Peo()->PodObjData() != NULL );
00706
00707     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00708
00709     //
00710     //  Set the title string.
00711     //
00712
00713     m_strTitle = Peo()->PodObjData()->StrName();
00714
00715     //
00716     //  Call the base class method.
00717     //
00718
00719     CPropertyPage::OnInitDialog();
00720
00721     //
00722     //  Display an icon for the object.
00723     //
00724
00725     if ( Peo()->Hicon() != NULL )
00726     {
00727         m_staticIcon.SetIcon( Peo()->Hicon() );
00728     } // if: an icon was specified
00729
00730     //
00731     //  Return TRUE unless you set the focus to a control.
00732     //
00733     //  EXCEPTION: OCX Property Pages should return FALSE.
00734     //
00735
00736     return TRUE;
00737
00738 } //*** CBasePropertyPage::OnInitDialog
00739
00740 /////////////////////////////////////////////////////////////////////////////
00741 //++
00742 //
00743 //  CBasePropertyPage::OnSetActive
00744 //
00745 //  Description:
00746 //      Handler for the PSN_SETACTIVE message.
00747 //
00748 //  Arguments:
00749 //      None.
00750 //
00751 //  Return Value:
00752 //      TRUE
00753 //          Page successfully initialized.
00754 //
00755 //      FALSE
00756 //          Page not initialized.
00757 //
00758 //--
00759 /////////////////////////////////////////////////////////////////////////////
00760 BOOL
00761 CBasePropertyPage::OnSetActive( void )
00762 {
00763     HRESULT hr = S_OK;
00764
00765     ASSERT( Peo() != NULL);
00766     ASSERT( Peo()->PodObjData() != NULL );
00767
00768     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00769
00770     //
00771     //  Reread the data.
00772     //
00773
00774     hr = Peo()->HrGetObjectInfo();
00775     if ( FAILED( hr ) )
00776     {
00777         return FALSE;
00778     } // if: error getting object info
00779
00780     //
00781     //  Set the title string.
00782     //
00783
00784     m_strTitle = Peo()->PodObjData()->StrName();
00785
00786     m_bBackPressed = FALSE;
00787     m_bSaved = FALSE;
00788     return CPropertyPage::OnSetActive();
00789
00790 } //*** CBasePropertyPage::OnSetActive
00791
00792 /////////////////////////////////////////////////////////////////////////////
00793 //++
00794 //
00795 //  CBasePropertyPage::OnApply
00796 //
00797 //  Description:
00798 //      Handler for the PSM_APPLY message.
00799 //
00800 //  Arguments:
00801 //      None.
00802 //
00803 //  Return Value:
00804 //      TRUE
00805 //          Page successfully applied.
00806 //
00807 //      FALSE
00808 //          Error applying page.
00809 //
00810 //--
00811 /////////////////////////////////////////////////////////////////////////////
00812 BOOL
00813 CBasePropertyPage::OnApply( void )
00814 {
00815     ASSERT( ! BWizard() );
00816
00817     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00818
00819     CWaitCursor wc;
00820
00821     if ( BApplyChanges() == FALSE )
00822     {
00823         return FALSE;
00824     } // if: error applying changes
00825
00826     return CPropertyPage::OnApply();
00827
00828 } //*** CBasePropertyPage::OnApply
00829
00830 /////////////////////////////////////////////////////////////////////////////
00831 //++
00832 //
00833 //  CBasePropertyPage::OnWizardBack
00834 //
00835 //  Description:
00836 //      Handler for the PSN_WIZBACK message.
00837 //
00838 //  Arguments:
00839 //      None.
00840 //
00841 //  Return Value:
00842 //      -1
00843 //          Don't change the page.
00844 //
00845 //      0
00846 //          Change the page.
00847 //
00848 //--
00849 /////////////////////////////////////////////////////////////////////////////
00850 LRESULT
00851 CBasePropertyPage::OnWizardBack( void )
00852 {
00853     LRESULT lResult = 0L;
00854
00855     ASSERT( BWizard() );
00856
00857     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00858
00859     lResult = CPropertyPage::OnWizardBack();
00860     if ( lResult != -1 )
00861     {
00862         m_bBackPressed = TRUE;
00863     } // if: no error occurred
00864
00865     return lResult;
00866
00867 } //*** CBasePropertyPage::OnWizardBack
00868
00869 /////////////////////////////////////////////////////////////////////////////
00870 //++
00871 //
00872 //  CBasePropertyPage::OnWizardNext
00873 //
00874 //  Description:
00875 //      Handler for the PSN_WIZNEXT message.
00876 //
00877 //  Arguments:
00878 //      None.
00879 //
00880 //  Return Value:
00881 //      -1
00882 //          Don't change the page.
00883 //
00884 //      0
00885 //          Change the page.
00886 //
00887 //--
00888 /////////////////////////////////////////////////////////////////////////////
00889 LRESULT
00890 CBasePropertyPage::OnWizardNext( void )
00891 {
00892     ASSERT( BWizard() );
00893
00894     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00895
00896     CWaitCursor wc;
00897
00898     //
00899     //  Update the data in the class from the page.
00900     //  This necessary because, while OnKillActive() will call UpdateData(),
00901     //  it is called after this method is called, and we need to be sure that
00902     //  data has been saved before we apply them.
00903     //
00904
00905     if ( ! UpdateData( TRUE /*bSaveAndValidate*/ ) )
00906     {
00907         return -1;
00908     } // if: error updating data
00909
00910     //
00911     //  Save the data in the sheet.
00912     //
00913
00914     if ( BApplyChanges() == FALSE )
00915     {
00916         return -1;
00917     } // if: error applying changes
00918
00919     //
00920     //  Create the object.
00921     //
00922
00923     return CPropertyPage::OnWizardNext();
00924
00925 } //*** CBasePropertyPage::OnWizardNext
00926
00927 /////////////////////////////////////////////////////////////////////////////
00928 //++
00929 //
00930 //  CBasePropertyPage::OnWizardFinish
00931 //
00932 //  Description:
00933 //      Handler for the PSN_WIZFINISH message.
00934 //
00935 //  Arguments:
00936 //      None.
00937 //
00938 //  Return Value:
00939 //      FALSE
00940 //          Don't change the page.
00941 //
00942 //      TRUE
00943 //          Change the page.
00944 //
00945 //--
00946 /////////////////////////////////////////////////////////////////////////////
00947 BOOL
00948 CBasePropertyPage::OnWizardFinish( void )
00949 {
00950     ASSERT( BWizard() );
00951
00952     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00953
00954     CWaitCursor wc;
00955
00956     //
00957     //  BUG! There should be no need to call UpdateData in this function.
00958     //  See BUG: Finish Button Fails Data Transfer from Page to Variables
00959     //  KB Article ID: Q150349
00960     //
00961
00962     //
00963     //  Update the data in the class from the page.
00964     //
00965
00966     if ( UpdateData( TRUE /*bSaveAndValidate*/ ) == FALSE )
00967     {
00968         return FALSE;
00969     } // if: error updating data
00970
00971     // Save the data in the sheet.
00972     if ( BApplyChanges() == FALSE )
00973     {
00974         return FALSE;
00975     } // if: error applying changes
00976
00977     return CPropertyPage::OnWizardFinish();
00978
00979 } //*** CBasePropertyPage::OnWizardFinish
00980
00981 /////////////////////////////////////////////////////////////////////////////
00982 //++
00983 //
00984 //  CBasePropertyPage::OnChangeCtrl
00985 //
00986 //  Description:
00987 //      Handler for the messages sent when a control is changed.  This
00988 //      method can be specified in a message map if all that needs to be
00989 //      done is enable the Apply button.
00990 //
00991 //  Arguments:
00992 //      None.
00993 //
00994 //  Return Value:
00995 //      None.
00996 //
00997 //--
00998 /////////////////////////////////////////////////////////////////////////////
00999 void
01000 CBasePropertyPage::OnChangeCtrl( void )
01001 {
01002     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
01003
01004     SetModified( TRUE );
01005
01006 } //*** CBasePropertyPage::OnChangeCtrl
01007
01008 /////////////////////////////////////////////////////////////////////////////
01009 //++
01010 //
01011 //  CBasePropertyPage::EnableNext
01012 //
01013 //  Description:
01014 //      Enables or disables the NEXT or FINISH button.
01015 //
01016 //  Arguments:
01017 //      fEnableIn
01018 //          TRUE = enable the button, FALSE = disable the button.
01019 //
01020 //  Return Value:
01021 //      None.
01022 //
01023 //--
01024 /////////////////////////////////////////////////////////////////////////////
01025 void
01026 CBasePropertyPage::EnableNext(
01027     BOOL fEnableIn      // = TRUE
01028     )
01029 {
01030     ASSERT( BWizard() );
01031     ASSERT( PiWizardCallback() );
01032
01033     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
01034
01035     PiWizardCallback()->EnableNext( reinterpret_cast< LONG * >( Hpage() ), fEnableIn );
01036
01037 } //*** CBasePropertyPage::EnableNext
01038
01039 /////////////////////////////////////////////////////////////////////////////
01040 //++
01041 //
01042 //  CBasePropertyPage::BApplyChanges
01043 //
01044 //  Description:
01045 //      Apply changes made on the page.
01046 //
01047 //  Arguments:
01048 //      None.
01049 //
01050 //  Return Value:
01051 //      TRUE
01052 //          Page successfully applied.
01053 //
01054 //      FALSE
01055 //          Error applying page.
01056 //
01057 //--
01058 /////////////////////////////////////////////////////////////////////////////
01059 BOOL
01060 CBasePropertyPage::BApplyChanges( void )
01061 {
01062     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
01063
01064     CWaitCursor wc;
01065
01066     //
01067     //  Save data.
01068     //
01069
01070     return BSetPrivateProps();
01071
01072 } //*** CBasePropertyPage::BApplyChanges
01073
01074 /////////////////////////////////////////////////////////////////////////////
01075 //++
01076 //
01077 //  CBasePropertyPage::BBuildPropList
01078 //
01079 //  Description:
01080 //      Build the property list.
01081 //
01082 //  Arguments:
01083 //      rcplIn
01084 //          Cluster property list.
01085 //
01086 //      fNoNewPropsIn
01087 //          TRUE = exclude properties marked with opfNew.
01088 //
01089 //  Return Value:
01090 //      TRUE
01091 //          Property list built successfully.
01092 //
01093 //      FALSE
01094 //          Error building property list.
01095 //
01096 //  Exceptions Thrown:
01097 //      Any exceptions thrown by CClusPropList::AddProp().
01098 //
01099 //--
01100 /////////////////////////////////////////////////////////////////////////////
01101 BOOL
01102 CBasePropertyPage::BBuildPropList(
01103       CClusPropList &   rcplIn
01104     , BOOL              fNoNewPropsIn     // = FALSE
01105     )
01106 {
01107     BOOL                    fNewPropsFound = FALSE;
01108     DWORD                   cprop;
01109     const CObjectProperty * pprop;
01110
01111     for ( pprop = Pprops(), cprop = Cprops() ; cprop > 0 ; pprop++, cprop-- )
01112     {
01113         if ( fNoNewPropsIn && (pprop->m_dwFlags & CObjectProperty::opfNew) )
01114         {
01115             fNewPropsFound = TRUE;
01116             continue;
01117         } // if: no new props allowed and this is a new property
01118
01119         switch ( pprop->m_propFormat )
01120         {
01121             case CLUSPROP_FORMAT_SZ:
01122                 rcplIn.ScAddProp(
01123                           pprop->m_pwszName
01124                         , *pprop->m_value.pstr
01125                         , *pprop->m_valuePrev.pstr
01126                         );
01127                 break;
01128
01129             case CLUSPROP_FORMAT_EXPAND_SZ:
01130                 rcplIn.ScAddExpandSzProp(
01131                           pprop->m_pwszName
01132                         , *pprop->m_value.pstr
01133                         , *pprop->m_valuePrev.pstr
01134                         );
01135                 break;
01136
01137             case CLUSPROP_FORMAT_DWORD:
01138                 rcplIn.ScAddProp(
01139                           pprop->m_pwszName
01140                         , *pprop->m_value.pdw
01141                         , *pprop->m_valuePrev.pdw
01142                         );
01143                 break;
01144
01145             case CLUSPROP_FORMAT_LONG:
01146                 rcplIn.ScAddProp(
01147                           pprop->m_pwszName
01148                         , *pprop->m_value.pl
01149                         , *pprop->m_valuePrev.pl
01150                         );
01151                 break;
01152
01153             case CLUSPROP_FORMAT_BINARY:
01154             case CLUSPROP_FORMAT_MULTI_SZ:
01155                 rcplIn.ScAddProp(
01156                           pprop->m_pwszName
01157                         , *pprop->m_value.ppb
01158                         , *pprop->m_value.pcb
01159                         , *pprop->m_valuePrev.ppb
01160                         , *pprop->m_valuePrev.pcb
01161                         );
01162                 break;
01163
01164             default:
01165                 ASSERT( 0 ); // don't know how to deal with this type
01166                 return FALSE;
01167
01168         } // switch: property format
01169     } // for: each property
01170
01171     return ( !( fNoNewPropsIn || fNewPropsFound ) );
01172
01173 } //*** CBasePropertyPage::BBuildPropList
01174
01175 /////////////////////////////////////////////////////////////////////////////
01176 //++
01177 //
01178 //  CBasePropertyPage::BSetPrivateProps
01179 //
01180 //  Description:
01181 //      Set the private properties for this object.
01182 //
01183 //  Arguments:
01184 //      fValidateOnlyIn
01185 //          TRUE = only validate the data.
01186 //
01187 //      fNoNewPropsIn
01188 //          TRUE = exclude properties marked with opfNew.
01189 //
01190 //  Return Value:
01191 //      ERROR_SUCCESS
01192 //          The operation was completed successfully.
01193 //
01194 //      Other Win32 values.
01195 //          Failure.
01196 //
01197 //--
01198 /////////////////////////////////////////////////////////////////////////////
01199 BOOL
01200 CBasePropertyPage::BSetPrivateProps(
01201       BOOL fValidateOnlyIn   // = FALSE
01202     , BOOL fNoNewPropsIn     // = FALSE
01203     )
01204 {
01205     BOOL            fSuccess   = TRUE;
01206     CClusPropList   cpl( BWizard() /*bAlwaysAddProp*/ );
01207
01208     ASSERT( Peo() != NULL );
01209     ASSERT( Peo()->PodObjData() );
01210
01211     //
01212     //  Build the property list.
01213     //
01214
01215     try
01216     {
01217         fSuccess = BBuildPropList( cpl, fNoNewPropsIn );
01218     } // try
01219     catch ( CException * pe )
01220     {
01221         pe->ReportError();
01222         pe->Delete();
01223         fSuccess = FALSE;
01224     } // catch: CException
01225
01226     //
01227     //  Set the data.
01228     //
01229
01230     if ( fSuccess )
01231     {
01232         if ( (cpl.PbPropList() != NULL) && (cpl.CbPropList() > 0) )
01233         {
01234             DWORD       sc = ERROR_SUCCESS;
01235             DWORD       dwControlCode;
01236             DWORD       cbProps;
01237
01238             switch ( Cot() )
01239             {
01240                 case CLUADMEX_OT_NODE:
01241                 {
01242                     CNodeData * pcnd = reinterpret_cast< CNodeData * >( Peo()->PodObjData() );
01243                     ASSERT( pcnd && (pcnd->GetHNode() != NULL) );
01244
01245                     //
01246                     //  Determine which control code to use.
01247                     //
01248
01249                     if ( fValidateOnlyIn )
01250                     {
01251                         dwControlCode = CLUSCTL_NODE_VALIDATE_PRIVATE_PROPERTIES;
01252                     } // if: only validating data
01253                     else
01254                     {
01255                         dwControlCode = CLUSCTL_NODE_SET_PRIVATE_PROPERTIES;
01256                     } // else: setting data
01257
01258                     //
01259                     //  Set private properties.
01260                     //
01261
01262                     sc = ClusterNodeControl(
01263                                       pcnd->GetHNode()
01264                                     , NULL   // hNode
01265                                     , dwControlCode
01266                                     , cpl.PbPropList()
01267                                     , cpl.CbPropList()
01268                                     , NULL   // lpOutBuffer
01269                                     , 0      // nOutBufferSize
01270                                     , &cbProps
01271                                     );
01272                     break;
01273                 } // case:
01274
01275                 case CLUADMEX_OT_GROUP:
01276                 {
01277                     CGroupData * pcgd = reinterpret_cast< CGroupData * >( Peo()->PodObjData() );
01278                     ASSERT( pcgd && (pcgd->GetHGroup() != NULL) );
01279
01280                     //
01281                     //  Determine which control code to use.
01282                     //
01283
01284                     if ( fValidateOnlyIn )
01285                     {
01286                         dwControlCode = CLUSCTL_GROUP_VALIDATE_PRIVATE_PROPERTIES;
01287                     } // if: only validating data
01288                     else
01289                     {
01290                         dwControlCode = CLUSCTL_GROUP_SET_PRIVATE_PROPERTIES;
01291                     } // else: setting data
01292
01293                     //
01294                     //  Set private properties.
01295                     //
01296
01297                     sc = ClusterGroupControl(
01298                                       pcgd->GetHGroup()
01299                                     , NULL   // hNode
01300                                     , dwControlCode
01301                                     , cpl.PbPropList()
01302                                     , cpl.CbPropList()
01303                                     , NULL   // lpOutBuffer
01304                                     , 0      // nOutBufferSize
01305                                     , &cbProps
01306                                     );
01307                     break;
01308                 } // case:
01309
01310                 case CLUADMEX_OT_RESOURCE:
01311                 {
01312                     CResData * pcrd = reinterpret_cast< CResData * >( Peo()->PodObjData() );
01313                     ASSERT( pcrd && (pcrd->GetHResource() != NULL) );
01314
01315                     //
01316                     //  Determine which control code to use.
01317                     //
01318
01319                     if ( fValidateOnlyIn )
01320                     {
01321                         dwControlCode = CLUSCTL_RESOURCE_VALIDATE_PRIVATE_PROPERTIES;
01322                     } // if: only validating data
01323                     else
01324                     {
01325                         dwControlCode = CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES;
01326                     } // else: setting data
01327
01328                     //
01329                     //  Set private properties.
01330                     //
01331
01332                     sc = ClusterResourceControl(
01333                                       pcrd->GetHResource()
01334                                     , NULL   // hNode
01335                                     , dwControlCode
01336                                     , cpl.PbPropList()
01337                                     , cpl.CbPropList()
01338                                     , NULL   // lpOutBuffer
01339                                     , 0      // nOutBufferSize
01340                                     , &cbProps
01341                                     );
01342                     break;
01343                 } // case:
01344
01345                 case CLUADMEX_OT_RESOURCETYPE:
01346                 {
01347                     CResTypeData * pcrd = reinterpret_cast< CResTypeData * >( Peo()->PodObjData() );
01348                     ASSERT( pcrd && (pcrd->StrName().GetLength() > 0) );
01349
01350                     //
01351                     //  Determine which control code to use.
01352                     //
01353
01354                     if ( fValidateOnlyIn )
01355                     {
01356                         dwControlCode = CLUSCTL_RESOURCE_TYPE_VALIDATE_PRIVATE_PROPERTIES;
01357                     } // if: only validating data
01358                     else
01359                     {
01360                         dwControlCode = CLUSCTL_RESOURCE_TYPE_SET_PRIVATE_PROPERTIES;
01361                     } // else: setting data
01362
01363                     //
01364                     //  Set private properties.
01365                     //
01366
01367                     sc = ClusterResourceTypeControl(
01368                                       Hcluster()
01369                                     , pcrd->StrName()
01370                                     , NULL   // hNode
01371                                     , dwControlCode
01372                                     , cpl.PbPropList()
01373                                     , cpl.CbPropList()
01374                                     , NULL   // lpOutBuffer
01375                                     , 0      // nOutBufferSize
01376                                     , &cbProps
01377                                     );
01378                     break;
01379                 } // case:
01380
01381                 case CLUADMEX_OT_NETWORK:
01382                 {
01383                     CNetworkData * pcnd = reinterpret_cast< CNetworkData * >( Peo()->PodObjData() );
01384                     ASSERT( pcnd && (pcnd->GetHNetwork() != NULL) );
01385
01386                     //
01387                     //  Determine which control code to use.
01388                     //
01389
01390                     if ( fValidateOnlyIn )
01391                     {
01392                         dwControlCode = CLUSCTL_NETWORK_VALIDATE_PRIVATE_PROPERTIES;
01393                     } // if: only validating data
01394                     else
01395                     {
01396                         dwControlCode = CLUSCTL_NETWORK_SET_PRIVATE_PROPERTIES;
01397                     } // else: setting data
01398
01399                     //
01400                     //  Set private properties.
01401                     //
01402
01403                     sc = ClusterNetworkControl(
01404                                       pcnd->GetHNetwork()
01405                                     , NULL   // hNode
01406                                     , dwControlCode
01407                                     , cpl.PbPropList()
01408                                     , cpl.CbPropList()
01409                                     , NULL   // lpOutBuffer
01410                                     , 0      // nOutBufferSize
01411                                     , &cbProps
01412                                     );
01413                     break;
01414                 } // case:
01415
01416                 case CLUADMEX_OT_NETINTERFACE:
01417                 {
01418                     CNetInterfaceData * pcnd = reinterpret_cast< CNetInterfaceData * >( Peo()->PodObjData() );
01419                     ASSERT( pcnd && (pcnd->GetHNetInterface() != NULL) );
01420
01421                     //
01422                     //  Determine which control code to use.
01423                     //
01424
01425                     if ( fValidateOnlyIn )
01426                     {
01427                         dwControlCode = CLUSCTL_NETINTERFACE_VALIDATE_PRIVATE_PROPERTIES;
01428                     } // if: only validating data
01429                     else
01430                     {
01431                         dwControlCode = CLUSCTL_NETINTERFACE_SET_PRIVATE_PROPERTIES;
01432                     } // else: setting data
01433
01434                     //
01435                     //  Set private properties.
01436                     //
01437
01438                     sc = ClusterNetInterfaceControl(
01439                                       pcnd->GetHNetInterface()
01440                                     , NULL   // hNode
01441                                     , dwControlCode
01442                                     , cpl.PbPropList()
01443                                     , cpl.CbPropList()
01444                                     , NULL   // lpOutBuffer
01445                                     , 0      // nOutBufferSize
01446                                     , &cbProps
01447                                     );
01448                     break;
01449                 } // case:
01450
01451                 default:
01452                     ASSERT( 0 );
01453
01454             } // switch: object type
01455
01456             //
01457             //  Handle errors.
01458             //
01459
01460             if ( sc != ERROR_SUCCESS )
01461             {
01462                 if ( sc == ERROR_INVALID_PARAMETER )
01463                 {
01464                     if ( ! fNoNewPropsIn )
01465                     {
01466                         fSuccess = BSetPrivateProps( fValidateOnlyIn, TRUE /*fNoNewPropsIn*/ );
01467                     } // if: new props are allowed
01468                     else
01469                         fSuccess = FALSE;
01470                 } // if: invalid parameter error occurred
01471                 else
01472                 {
01473                     fSuccess = FALSE;
01474                 } // else: some other error occurred
01475
01476                 //
01477                 // If an error occurred, display an error message.
01478                 //
01479
01480                 if ( ! fSuccess )
01481                 {
01482                     DisplaySetPropsError( sc, fValidateOnlyIn ? IDS_ERROR_VALIDATING_PROPERTIES : IDS_ERROR_SETTING_PROPERTIES );
01483                     if ( sc == ERROR_RESOURCE_PROPERTIES_STORED )
01484                     {
01485                         fSuccess = TRUE;
01486                     } // if: properties only stored
01487                 } // if: error occurred
01488             } // if: error setting/validating data
01489         } // if: there is data to set
01490     } // if: no errors building the property list
01491
01492     //
01493     //  Save data locally.
01494     //
01495
01496     if ( ! fValidateOnlyIn && fSuccess )
01497     {
01498         //
01499         //  Save new values as previous values.
01500         //
01501
01502         try
01503         {
01504             DWORD                   cprop;
01505             const CObjectProperty * pprop;
01506
01507             for ( pprop = Pprops(), cprop = Cprops() ; cprop > 0 ; pprop++, cprop-- )
01508             {
01509                 switch ( pprop->m_propFormat )
01510                 {
01511                     case CLUSPROP_FORMAT_SZ:
01512                     case CLUSPROP_FORMAT_EXPAND_SZ:
01513                         ASSERT(pprop->m_value.pstr != NULL);
01514                         ASSERT(pprop->m_valuePrev.pstr != NULL);
01515                         *pprop->m_valuePrev.pstr = *pprop->m_value.pstr;
01516                         break;
01517
01518                     case CLUSPROP_FORMAT_DWORD:
01519                     case CLUSPROP_FORMAT_LONG:
01520                         ASSERT( pprop->m_value.pdw != NULL );
01521                         ASSERT( pprop->m_valuePrev.pdw != NULL );
01522                         *pprop->m_valuePrev.pdw = *pprop->m_value.pdw;
01523                         break;
01524
01525                     case CLUSPROP_FORMAT_BINARY:
01526                     case CLUSPROP_FORMAT_MULTI_SZ:
01527                         ASSERT( pprop->m_value.ppb != NULL );
01528                         ASSERT( *pprop->m_value.ppb != NULL );
01529                         ASSERT( pprop->m_value.pcb != NULL );
01530                         ASSERT( pprop->m_valuePrev.ppb != NULL );
01531                         ASSERT( *pprop->m_valuePrev.ppb != NULL );
01532                         ASSERT( pprop->m_valuePrev.pcb != NULL );
01533                         delete [] *pprop->m_valuePrev.ppb;
01534                         *pprop->m_valuePrev.ppb = new BYTE[ *pprop->m_value.pcb ];
01535                         CopyMemory( *pprop->m_valuePrev.ppb, *pprop->m_value.ppb, *pprop->m_value.pcb );
01536                         *pprop->m_valuePrev.pcb = *pprop->m_value.pcb;
01537                         break;
01538
01539                     default:
01540                         ASSERT( 0 ); // don't know how to deal with this type
01541
01542                 } // switch: property format
01543             } // for: each property
01544         } // try
01545         catch ( CException * pe )
01546         {
01547             pe->ReportError();
01548             pe->Delete();
01549             fSuccess = FALSE;
01550         } // catch: CException
01551     } // if: not just validating and successful so far
01552
01553     //
01554     // Indicate we successfully saved the properties.
01555     //
01556
01557     if ( ! fValidateOnlyIn && fSuccess )
01558     {
01559         m_bSaved = TRUE;
01560     } // if: successfully saved data
01561
01562     return fSuccess;
01563
01564 } //*** CBasePropertyPage::BSetPrivateProps
01565
01566 /////////////////////////////////////////////////////////////////////////////
01567 //++
01568 //
01569 //  CBasePropertyPage::DisplaySetPropsError
01570 //
01571 //  Routine Description:
01572 //      Display an error caused by setting or validating properties.
01573 //
01574 //  Arguments:
01575 //      scIn
01576 //          Status to display error on.
01577 //
01578 //      idsOperIn
01579 //          Operation message.
01580 //
01581 //  Return Value:
01582 //      None.
01583 //
01584 //--
01585 /////////////////////////////////////////////////////////////////////////////
01586 void
01587 CBasePropertyPage::DisplaySetPropsError(
01588       DWORD    scIn
01589     , UINT     idsOperIn
01590     ) const
01591 {
01592     CString strErrorMsg;
01593     CString strOperMsg;
01594     CString strMsgIdFmt;
01595     CString strMsgId;
01596     CString strMsg;
01597
01598     UNREFERENCED_PARAMETER( idsOperIn );
01599
01600     strOperMsg.LoadString( IDS_ERROR_SETTING_PROPERTIES );
01601     FormatError( strErrorMsg, scIn );
01602     strMsgIdFmt.LoadString( IDS_ERROR_MSG_ID );
01603     strMsgId.Format( strMsgIdFmt, scIn, scIn );
01604     strMsg.Format( _T("%s\n\n%s%s"), strOperMsg, strErrorMsg, strMsgId );
01605     AfxMessageBox( strMsg );
01606
01607 }  //*** CBasePropertyPage::DisplaySetPropsError
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Include/ansiapi.h Source File

  • Com
  • Fundamentals
  • Include

ansiapi.h

Go to the documentation of this file.
00001 /*
00002  * ansiapi.h
00003  * This file contains prototypes of ANSI version of OLE apis
00004  * and mapping fooA to foo
00005  */
00006 #ifndef _ANSIAPI_INCL
00007 #define _ANSIAPI_INCL
00008
00009 #define UNICODEOLE32
00010
00011 #ifdef WIN32S
00012 #if !defined(UNICODEOLE32)
00013 #pragma message("Compiling for 32bit ANSI Ole!\n");
00014 #endif
00015 #endif
00016
00017 #define WASANSI() {                                                           \
00018                    OutputDebugString("\n\r\t\tUnicode string was ANSI!\r\n"); \
00019                    Assert(0);                                                 \
00020                    _asm { int 3 }                                             \
00021                   }
00022
00023
00024 #ifndef UNICODEOLE32
00025
00026 #define W2A(w, a, cb)     lstrcpy (a, w)
00027 #define A2W(a, w, cb)     lstrcpy (w, a)
00028
00029 #define FREELOCALSTRING(p)
00030 #define MAKE_STR_LOCAL_COPYW2A(s, l)  l = s
00031 #define MAKE_STR_LOCAL_COPYA2W(s, l)  l = s
00032
00033 #define OLESTRCPY                lstrcpy
00034 #define OLESTRCAT                lstrcat
00035 #define OLESTRLEN                lstrlen
00036 #define OLESTRCMP                lstrcmp
00037
00038 #define DeleteFile_AW            DeleteFile
00039 #define _lopen_AW                _lopen
00040 #define _lcreat_AW               _lcreat
00041 #define GlobalAddAtom_AW         GlobalAddAtom
00042 #define GlobalGetAtomName_AW     GlobalGetAtomName
00043 #define RegOpenKey_AW            RegOpenKey
00044
00045 #define CoLoadLibraryA   CoLoadLibrary
00046
00047 #define StringFromCLSID2A    StringFromCLSID2
00048 #define StringFromIID2A      StringFromIID2
00049 #define StringFromGUID2A     StringFromGUID2
00050 #define CLSIDFromProgIDA     CLSIDFromProgID
00051 #define CLSIDFromStringA     CLSIDFromString
00052 #define ProgIDFromCLSIDA     ProgIDFromCLSID
00053 #define StringFromCLSIDA     StringFromCLSID
00054
00055 #define UtDupStringA2W       UtDupString
00056
00057 // Storage APIs
00058 #define StgOpenStorageA      StgOpenStorage
00059
00060 // IPersistFile ansi translation
00061
00062 #define IPersistFile_LoadA(pf, file, mode) (pf)->Load(file, mode)
00063
00064 // IMoniker ansi translation
00065
00066 #define IMoniker_GetDisplayNameA(pm, p1, p2, p3) (pm)->GetDisplayName(p1,p2,p3)
00067
00068 #define CreateFileMonikerA   CreateFileMoniker
00069
00070 #else  // UNICODEOLE32
00071
00072 #define W2A(w, a, cb)     WideCharToMultiByte(                              \
00073                                                CP_ACP,                      \
00074                                                0,                           \
00075                                                w,                           \
00076                                                -1,                          \
00077                                                a,                           \
00078                                                cb,                          \
00079                                                NULL,                        \
00080                                                NULL)
00081
00082 #define A2W(a, w, cb)     MultiByteToWideChar(                              \
00083                                                CP_ACP,                      \
00084                                                0,                           \
00085                                                a,                           \
00086                                                -1,                          \
00087                                                w,                           \
00088                                                cb)
00089
00090
00091 #define FREELOCALSTRING(p)      delete (p)
00092 #define MAKE_STR_LOCAL_COPYW2A(s, l)  {                                   \
00093                                       l = UtDupStringW2A(s);              \
00094                                       if (!l) {                           \
00095                                          return ResultFromScode(S_OOM);   \
00096                                       }                                   \
00097                                    }
00098
00099 #define MAKE_STR_LOCAL_COPYA2W(s, l)  {                                   \
00100                                       l = UtDupStringA2W(s);              \
00101                                       if (!l) {                           \
00102                                          return ResultFromScode(S_OOM);   \
00103                                       }                                   \
00104                                    }
00105
00106 #define OLESTRCPY                wcscpy
00107 #define OLESTRCAT                wcscat
00108 #define OLESTRLEN                wcslen
00109 #define OLESTRCMP                wcscmp
00110
00111 #define DeleteFile_AW            DeleteFileW
00112 #define _lopen_AW                _lopenW
00113 #define _lcreat_AW               _lcreatW
00114 #define GlobalAddAtom_AW         GlobalAddAtomW
00115 #define GlobalGetAtomName_AW     GlobalGetAtomNameW
00116 #define RegOpenKey_AW            RegOpenKeyW
00117
00118 //STDAPI_(HINSTANCE) CoLoadLibraryA(LPSTR lpszLibName, BOOL bAutoFree);
00119
00120 #define StringFromCLSID2A(rclsid, lpsz, cbMax) \
00121     StringFromGUID2A(rclsid, lpsz, cbMax)
00122
00123 #define StringFromIID2A(riid, lpsz, cbMax) \
00124     StringFromGUID2A(riid, lpsz, cbMax)
00125
00126
00127 //STDAPI_(int)  StringFromGUID2A(REFGUID rguid, LPSTR lpsz, int cbMax);
00128 //STDAPI        CLSIDFromProgIDA(LPCSTR szProgID, LPCLSID pclsid);
00129 //STDAPI        CLSIDFromStringA(LPSTR lpsz, LPCLSID lpclsid);
00130 //STDAPI        StringFromCLSIDA(REFCLSID rclsid, LPSTR FAR* lplpsz);
00131 //STDAPI        ProgIDFromCLSIDA (REFCLSID clsid, LPSTR FAR* lplpszProgID);
00132
00133 //LPWSTR UtDupStringA2W(LPCSTR pSrc);
00134 //LPSTR  UtDupStringW2A(LPCWSTR pSrc);
00135
00136 // Storage APIs
00137 //STDAPI StgOpenStorageA(LPCSTR pwcsName,IStorage FAR *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage FAR * FAR *ppstgOpen);
00138
00139 // IPersistFile ansi translation
00140
00141 //HRESULT IPersistFile_LoadA(LPPERSISTFILE pIPF, LPSTR szFile, DWORD dwMode);
00142
00143 // IMoniker ansi translation
00144
00145 //HRESULT IMoniker_GetDisplayNameA(LPMONIKER pm, LPBC p1, LPMONIKER p2, LPSTR FAR *p3);
00146
00147 //OLEAPI CreateFileMonikerA ( LPSTR lpszPathName, LPMONIKER FAR * ppmk );
00148
00149 #endif // !UNICODEOLE32
00150
00151 #endif //  _ANSIAPI_INCL
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocServe/UtilCAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocServe

UtilCAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      UTILCAR.CPP
00003
00004   Summary:   Implementation file for the aggregatable COUtilityCar COM
00005              object class.
00006
00007              UTILCAR showcases the construction of the COUtilityCar COM
00008              object class with the IUnknown, ICar, and IUtility interfaces.
00009              This is done through Containment reuse of COCar's ICar
00010              interface features.
00011
00012              For a comprehensive tutorial code tour of this module's
00013              contents and offerings see the tutorial LOCSERVE.HTM file.
00014              For more specific technical details on the internal workings
00015              see the comments dispersed throughout the module's source code.
00016
00017   Classes:   COUtilityCar.
00018
00019   Functions: none.
00020
00021   Origin:    11-14-95: atrent - Editor-inheritance from UTILCAR.CPP in
00022                the DLLSERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include APPUTIL.H because we will be building this application using
00043     the convenient Virtual Window and Dialog classes and other
00044     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00045   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00046     class, GUID, and CLSID specifications.
00047   We include SERVER.H because it has internal class declarations and
00048     resource ID definitions specific for this DLL.
00049   We include CAR.H because it has the class COCar declarations.
00050   We include UTILCAR.H because it has the class COUtilityCar declarations.
00051 ---------------------------------------------------------------------------*/
00052 #include <windows.h>
00053 #include <ole2.h>
00054 #include <apputil.h>
00055 #include <micars.h>
00056 #include <carguids.h>
00057 #include "server.h"
00058 #include "car.h"
00059 #include "utilcar.h"
00060
00061
00062 /*---------------------------------------------------------------------------
00063   COUtilityCar's implementation of its main COM object class including
00064   Constructor, Destructor, QueryInterface, AddRef, and Release.
00065 ---------------------------------------------------------------------------*/
00066
00067 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00068   Method:   COUtilityCar::COUtilityCar
00069
00070   Summary:  COUtilityCar Constructor. Note the member initializers:
00071             "m_ImpICar(this, pUnkOuter)" and "m_ImpIUtility(this,
00072             pUnkOuter)" which are used to pass the 'this' and
00073             pUnkOuter pointers of this constructor function to the
00074             constructors that instantiate the implementations of
00075             the CImpICar and CImpIUtility interfaces (which are both
00076             nested inside this present COUtilityCar Object Class.
00077
00078   Args:     IUnknown* pUnkOuter,
00079               Pointer to the the outer Unknown.  NULL means this COM Object
00080               is not being Aggregated.  Non NULL means it is being created
00081               on behalf of an outside COM object that is reusing it via
00082               aggregation.
00083             CServer* pServer)
00084               Pointer to the server's control object.
00085
00086   Modifies: m_cRefs, m_pUnkOuter.
00087
00088   Returns:  void
00089 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00090 COUtilityCar::COUtilityCar(
00091   IUnknown* pUnkOuter,
00092   CServer* pServer) :
00093   m_ImpICar(this, pUnkOuter),
00094   m_ImpIUtility(this, pUnkOuter)
00095 {
00096   // Zero the COM object's reference count.
00097   m_cRefs = 0;
00098
00099   // No AddRef necessary if non-NULL, as we're nested.
00100   m_pUnkOuter = pUnkOuter;
00101
00102   // Zero the pointer to the contained COCar object's ICar interface.
00103   m_pICar = NULL;
00104
00105   // Init the pointer to the server's control object.
00106   m_pServer = pServer;
00107
00108   LOGF1("L: COUtilityCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00109
00110   return;
00111 }
00112
00113
00114 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00115   Method:   COUtilityCar::~COUtilityCar
00116
00117   Summary:  COUtilityCar Destructor.
00118
00119   Args:     void
00120
00121   Modifies: .
00122
00123   Returns:  void
00124 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00125 COUtilityCar::~COUtilityCar(void)
00126 {
00127   LOG("L: COUtilityCar::Destructor.");
00128
00129   // Release the contained Car object.
00130   m_pICar->Release();
00131
00132   return;
00133 }
00134
00135
00136 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00137   Method:   COUtilityCar::Init
00138
00139   Summary:  COUtilityCar Initialization method.
00140
00141   Args:     void
00142
00143   Modifies: m_pUnkCar, m_pICar, m_cRefs.
00144
00145   Returns:  HRESULT
00146               Standard result code. NOERROR for success.
00147 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00148 HRESULT COUtilityCar::Init(void)
00149 {
00150   HRESULT hr;
00151
00152   LOG("L: COUtilityCar::Init.");
00153
00154   // Set up the right pIUnknown for delegation.  If we are being
00155   // aggregated then we pass the pUnkOuter in turn to any COM objects
00156   // that we are aggregating.  m_pUnkOuter was set in the Constructor.
00157   IUnknown* pUnkOuter = (NULL == m_pUnkOuter) ? this : m_pUnkOuter;
00158
00159   // We create an instance of the COCar object and do this via the
00160   // Containment reuse technique.  We ask for the new COM object's
00161   // ICar interface directly.  We pass NULL for the pUnkOuter
00162   // aggregation pointer because we are not aggregating.  It is here
00163   // that we are reusing the COCar COM Object through the Containment
00164   // technique.  We cache the requested ICar interface pointer in this
00165   // COUtilityCar COM object for later use.  We don't need to AddRef
00166   // this interface because the CoCreateInstance will do this for us.
00167   hr = CoCreateInstance(
00168          CLSID_LocCar,
00169          NULL,
00170          CLSCTX_LOCAL_SERVER,
00171          IID_ICar,
00172          (PPVOID)&m_pICar);
00173
00174   if (SUCCEEDED(hr))
00175   {
00176     LOG("L: COUtilityCar::Init (New Containment of COCar) Succeeded.");
00177   }
00178   else
00179   {
00180     LOG("L: COUtilityCar::Init (New Containment of COCar) Failed.");
00181   }
00182
00183   return (hr);
00184 }
00185
00186
00187 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00188   Method:   COUtilityCar::QueryInterface
00189
00190   Summary:  QueryInterface of the COUtilityCar non-delegating
00191             IUnknown implementation.
00192
00193   Args:     REFIID riid,
00194               [in] GUID of the Interface being requested.
00195             PPVOID ppv)
00196               [out] Address of the caller's pointer variable that will
00197               receive the requested interface pointer.
00198
00199   Modifies: .
00200
00201   Returns:  HRESULT
00202 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00203 STDMETHODIMP COUtilityCar::QueryInterface(
00204                REFIID riid,
00205                PPVOID ppv)
00206 {
00207   HRESULT hr = E_NOINTERFACE;
00208   *ppv = NULL;
00209
00210   if (IID_IUnknown == riid)
00211   {
00212     *ppv = this;
00213     LOG("L: COUtilityCar::QueryInterface. 'this' pIUnknown returned");
00214   }
00215   else if (IID_ICar == riid)
00216   {
00217     *ppv = &m_ImpICar;
00218     LOG("L: COUtilityCar::QueryInterface. pICar returned");
00219   }
00220   else if (IID_IUtility == riid)
00221   {
00222     *ppv = &m_ImpIUtility;
00223     LOG("L: COUtilityCar::QueryInterface. pIUtility returned");
00224   }
00225
00226   if (NULL != *ppv)
00227   {
00228     // We've handed out a pointer to the interface so obey the COM rules
00229     // and AddRef the reference count.
00230     ((LPUNKNOWN)*ppv)->AddRef();
00231     hr = NOERROR;
00232   }
00233
00234   return (hr);
00235 }
00236
00237
00238 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00239   Method:   COUtilityCar::AddRef
00240
00241   Summary:  AddRef of the COUtilityCar non-delegating IUnknown implementation.
00242
00243   Args:     void
00244
00245   Modifies: m_cRefs.
00246
00247   Returns:  ULONG
00248               New value of m_cRefs (COM object's reference count).
00249 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00250 STDMETHODIMP_(ULONG) COUtilityCar::AddRef(void)
00251 {
00252   m_cRefs++;
00253
00254   LOGF1("L: COUtilityCar::AddRef. New cRefs=%i.", m_cRefs);
00255
00256   return m_cRefs;
00257 }
00258
00259
00260 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00261   Method:   COUtilityCar::Release
00262
00263   Summary:  Release of the COUtilityCar non-delegating IUnknown implementation.
00264
00265   Args:     void
00266
00267   Modifies: m_cRefs.
00268
00269   Returns:  ULONG
00270               New value of m_cRefs (COM object's reference count).
00271 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00272 STDMETHODIMP_(ULONG) COUtilityCar::Release(void)
00273 {
00274   m_cRefs--;
00275
00276   LOGF1("L: COUtilityCar::Release. New cRefs=%i.", m_cRefs);
00277
00278   if (0 == m_cRefs)
00279   {
00280     // We've reached a zero reference count for this COM object.
00281     // So we tell the server housing to decrement its global object
00282     // count so that the server will be unloaded if appropriate.
00283     if (NULL != m_pServer)
00284       m_pServer->ObjectsDown();
00285
00286     // We artificially bump the main ref count to prevent reentrancy
00287     // via the main object destructor.
00288     m_cRefs++;
00289     delete this;
00290   }
00291
00292   return m_cRefs;
00293 }
00294
00295
00296 /*---------------------------------------------------------------------------
00297   COUtilityCar's nested implementation of the ICar interface including
00298   Constructor, Destructor, QueryInterface, AddRef, Release,
00299   Shift, Clutch, Speed, and Steer.
00300 ---------------------------------------------------------------------------*/
00301
00302 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00303   Method:   COUtilityCar::CImpICar::CImpICar
00304
00305   Summary:  Constructor for the CImpICar interface instantiation.
00306
00307   Args:     COUtilityCar* pBackObj,
00308               Back pointer to the parent outer object.
00309             IUnknown* pUnkOuter,
00310               Pointer to the outer Unknown.  For delegation.
00311
00312   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00313
00314   Returns:  void
00315 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00316 COUtilityCar::CImpICar::CImpICar(
00317   COUtilityCar* pBackObj,
00318   IUnknown* pUnkOuter)
00319 {
00320   // Init the Interface Ref Count (used for debugging only).
00321   m_cRefI = 0;
00322
00323   // Init the Back Object Pointer to point to the outer object.
00324   m_pBackObj = pBackObj;
00325
00326   // Init the CImpICar interface's delegating Unknown pointer.  We use
00327   // the Back Object pointer for IUnknown delegation here if we are not
00328   // being aggregated.  If we are being aggregated we use the supplied
00329   // pUnkOuter for IUnknown delegation.  In either case the pointer
00330   // assignment requires no AddRef because the CImpICar lifetime is
00331   // quaranteed by the lifetime of the parent object in which
00332   // CImpICar is nested.
00333   if (NULL == pUnkOuter)
00334   {
00335     m_pUnkOuter = pBackObj;
00336     LOG("L: COUtilityCar::CImpICar Constructor. Non-Aggregating");
00337   }
00338   else
00339   {
00340     m_pUnkOuter = pUnkOuter;
00341     LOG("L: COUtilityCar::CImpICar Constructor. Aggregating");
00342   }
00343
00344   return;
00345 }
00346
00347
00348 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00349   Method:   COUtilityCar::CImpICar::~CImpICar
00350
00351   Summary:  Destructor for the CImpICar interface instantiation.
00352
00353   Args:     void
00354
00355   Modifies: .
00356
00357   Returns:  void
00358 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00359 COUtilityCar::CImpICar::~CImpICar(void)
00360 {
00361   LOG("L: COUtilityCar::CImpICar Destructor.");
00362
00363   return;
00364 }
00365
00366
00367 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00368   Method:   COUtilityCar::CImpICar::QueryInterface
00369
00370   Summary:  The QueryInterface IUnknown member of this ICar interface
00371             implementation that delegates to m_pUnkOuter, whatever it is.
00372
00373   Args:     REFIID riid,
00374               [in] GUID of the Interface being requested.
00375             PPVOID ppv)
00376               [out] Address of the caller's pointer variable that will
00377               receive the requested interface pointer.
00378
00379   Modifies: .
00380
00381   Returns:  HRESULT
00382               Returned by the delegated outer QueryInterface call.
00383 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00384 STDMETHODIMP COUtilityCar::CImpICar::QueryInterface(
00385                REFIID riid,
00386                PPVOID ppv)
00387 {
00388   LOG("L: COUtilityCar::CImpICar::QueryInterface. Delegating.");
00389
00390   // Delegate this call to the outer object's QueryInterface.
00391   return m_pUnkOuter->QueryInterface(riid, ppv);
00392 }
00393
00394
00395 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00396   Method:   COUtilityCar::CImpICar::AddRef
00397
00398   Summary:  The AddRef IUnknown member of this ICar interface
00399             implementation that delegates to m_pUnkOuter, whatever it is.
00400
00401   Args:     void
00402
00403   Modifies: m_cRefI.
00404
00405   Returns:  ULONG
00406               Returned by the delegated outer AddRef call.
00407 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00408 STDMETHODIMP_(ULONG) COUtilityCar::CImpICar::AddRef(void)
00409 {
00410   // Increment the Interface Reference Count.
00411   ++m_cRefI;
00412
00413   LOGF1("L: COUtilityCar::CImpICar::Addref. Delegating. New cI=%i.", m_cRefI);
00414
00415   // Delegate this call to the outer object's AddRef.
00416   return m_pUnkOuter->AddRef();
00417 }
00418
00419
00420 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00421   Method:   COUtilityCar::CImpICar::Release
00422
00423   Summary:  The Release IUnknown member of this ICar interface
00424             implementation that delegates to m_pUnkOuter, whatever it is.
00425
00426   Args:     void
00427
00428   Modifies: .
00429
00430   Returns:  ULONG
00431               Returned by the delegated outer Release call.
00432 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00433 STDMETHODIMP_(ULONG) COUtilityCar::CImpICar::Release(void)
00434 {
00435   // Decrement the Interface Reference Count.
00436   --m_cRefI;
00437
00438   LOGF1("L: COUtilityCar::CImpICar::Release. Delegating. New cI=%i.", m_cRefI);
00439
00440   // Delegate this call to the outer object's Release.
00441   return m_pUnkOuter->Release();
00442 }
00443
00444
00445 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00446   Method:   COUtilityCar::CImpICar::Shift
00447
00448   Summary:  The Shift member method of this ICar interface implementation.
00449             A simple empty method on a COUtilityCar COM object for tutorial
00450             purposes.  Presumably if this Car object were modeling
00451             a real Car then the Shift method would shift to the specified
00452             gear.
00453
00454   Args:     short nGear
00455               0 - Neutral; 1 - 5 First 5 forward gears; 6 - Reverse.
00456
00457   Modifies: .
00458
00459   Returns:  HRESULT
00460               NOERROR
00461 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00462 STDMETHODIMP COUtilityCar::CImpICar::Shift(
00463                short nGear)
00464 {
00465   LOGF1("L: COUtilityCar::CImpICar::Shift. Delegating. nGear=%i.",nGear);
00466
00467   // Delegate to the contained object implementation of ICar.
00468   m_pBackObj->m_pICar->Shift(nGear);
00469
00470   return NOERROR;
00471 }
00472
00473
00474 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00475   Method:   COUtilityCar::CImpICar::Clutch
00476
00477   Summary:  The Clutch member method of this ICar interface implementation.
00478             A simple empty method on a COUtilityCar COM object for tutorial
00479             purposes.  Presumably if this Car object were modeling
00480             a real Car then the Clutch method would engage the clutch the
00481             specified amount.
00482
00483   Args:     short nEngaged)
00484               Percent clutch is engaged (0 to 100%).
00485
00486   Modifies: .
00487
00488   Returns:  HRESULT
00489               NOERROR
00490 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00491 STDMETHODIMP COUtilityCar::CImpICar::Clutch(
00492                short nEngaged)
00493 {
00494   LOGF1("L: COUtilityCar::CImpICar::Clutch. Delegating. nEngaged=%i.", nEngaged);
00495
00496   // Delegate to the contained object implementation of ICar.
00497   m_pBackObj->m_pICar->Clutch(nEngaged);
00498
00499   return NOERROR;
00500 }
00501
00502
00503 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00504   Method:   COUtilityCar::CImpICar::Speed
00505
00506   Summary:  The Propel member method of this ICar interface implementation.
00507             A simple empty method on a COUtilityCar COM object for tutorial
00508             purposes.  Presumably if this Car object were modeling
00509             a real Car then this method would accelerate/brake to bring
00510             the car to the specified speed.
00511
00512   Args:     short nMph
00513               New speed in miles per hour.
00514
00515   Modifies: .
00516
00517   Returns:  HRESULT
00518               NOERROR
00519 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00520 STDMETHODIMP COUtilityCar::CImpICar::Speed(
00521                short nMph)
00522 {
00523   LOGF1("L: COUtilityCar::CImpICar::Speed. Delegating. nMph=%i.",nMph);
00524
00525   // Delegate to the contained object implementation of ICar.
00526   m_pBackObj->m_pICar->Speed(nMph);
00527
00528   return NOERROR;
00529 }
00530
00531
00532 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00533   Method:   COUtilityCar::CImpICar::Steer
00534
00535   Summary:  The Steer member method of this ICar interface implementation.
00536             A simple empty method on a COUtilityCar COM object for tutorial
00537             purposes.  Presumably if this Car object were modeling
00538             a real Car then the Steer method would set the steering
00539             angle of the Car.
00540
00541   Args:     short nAngle)
00542               0 degrees straight ahead, -45 Full left, +45 Full right.
00543
00544   Modifies: .
00545
00546   Returns:  HRESULT
00547               NOERROR
00548 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00549 STDMETHODIMP COUtilityCar::CImpICar::Steer(
00550                short nAngle)
00551 {
00552   LOGF1("L: COUtilityCar::CImpICar::Steer. Delegating. nAngle=%i.",nAngle);
00553
00554   // Delegate to the contained object implementation of ICar.
00555   m_pBackObj->m_pICar->Steer(nAngle);
00556
00557   return NOERROR;
00558 }
00559
00560
00561 /*---------------------------------------------------------------------------
00562   COUtilityCar's nested implementation of the IUtility interface including
00563   Constructor, Destructor, QueryInterface, AddRef, Release,
00564   Offroad, and Winch.
00565 ---------------------------------------------------------------------------*/
00566
00567 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00568   Method:   COUtilityCar::CImpIUtility::CImpIUtility
00569
00570   Summary:  Constructor for the CImpIUtility interface instantiation.
00571
00572   Args:     COUtilityCar* pBackObj,
00573               Back pointer to the parent outer object.
00574             IUnknown* pUnkOuter)
00575               Pointer to the outer Unknown.  For delegation.
00576
00577   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00578
00579   Returns:  void
00580 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00581 COUtilityCar::CImpIUtility::CImpIUtility(
00582   COUtilityCar* pBackObj,
00583   IUnknown* pUnkOuter)
00584 {
00585   // Init the Interface Ref Count (used for debugging only).
00586   m_cRefI = 0;
00587
00588   // Init the Back Object Pointer to point to the outer object.
00589   m_pBackObj = pBackObj;
00590
00591   // Init the CImpIUtility interface's delegating Unknown pointer.  We use
00592   // the Back Object pointer for IUnknown delegation here if we are not
00593   // being aggregated.  If we are being aggregated we use the supplied
00594   // pUnkOuter for IUnknown delegation.  In either case the pointer
00595   // assignment requires no AddRef because the CImpIUtility lifetime is
00596   // quaranteed by the lifetime of the parent object in which
00597   // CImpIUtility is nested.
00598   if (NULL == pUnkOuter)
00599   {
00600     m_pUnkOuter = pBackObj;
00601     LOG("L: COUtilityCar::CImpIUtility Constructor. Non-Aggregating.");
00602   }
00603   else
00604   {
00605     m_pUnkOuter = pUnkOuter;
00606     LOG("L: COUtilityCar::CImpIUtility Constructor. Aggregating.");
00607   }
00608
00609   return;
00610 }
00611
00612
00613 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00614   Method:   COUtilityCar::CImpIUtility::~CImpIUtility
00615
00616   Summary:  Destructor for the CImpIUtility interface instantiation.
00617
00618   Args:     void
00619
00620   Modifies: .
00621
00622   Returns:  void
00623 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00624 COUtilityCar::CImpIUtility::~CImpIUtility(void)
00625 {
00626   LOG("L: COUtilityCar::CImpIUtility Destructor.");
00627
00628   return;
00629 }
00630
00631
00632 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00633   Method:   COUtilityCar::CImpIUtility::QueryInterface
00634
00635   Summary:  The QueryInterface IUnknown member of this IUtility interface
00636             implementation that delegates to m_pUnkOuter, whatever it is.
00637
00638   Args:     REFIID riid,
00639               [in] GUID of the Interface being requested.
00640             PPVOID ppv)
00641               [out] Address of the caller's pointer variable that will
00642               receive the requested interface pointer.
00643
00644   Modifies: .
00645
00646   Returns:  HRESULT
00647               Returned by the delegated outer QueryInterface call.
00648 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00649 STDMETHODIMP COUtilityCar::CImpIUtility::QueryInterface(
00650                REFIID riid,
00651                PPVOID ppv)
00652 {
00653   LOG("L: COUtilityCar::CImpIUtility::QueryInterface. Delegating.");
00654
00655   // Delegate this call to the outer object's QueryInterface.
00656   return m_pUnkOuter->QueryInterface(riid, ppv);
00657 }
00658
00659
00660 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00661   Method:   COUtilityCar::CImpIUtility::AddRef
00662
00663   Summary:  The AddRef IUnknown member of this IUtility interface
00664             implementation that delegates to m_pUnkOuter, whatever it is.
00665
00666   Args:     void
00667
00668   Modifies: m_cRefI.
00669
00670   Returns:  ULONG
00671               Returned by the delegated outer AddRef call.
00672 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00673 STDMETHODIMP_(ULONG) COUtilityCar::CImpIUtility::AddRef(void)
00674 {
00675   // Increment the Interface Reference Count.
00676   ++m_cRefI;
00677
00678   LOGF1("L: COUtilityCar::CImpIUtility::Addref. Delegating. New cI=%i.", m_cRefI);
00679
00680   // Delegate this call to the outer object's AddRef.
00681   return m_pUnkOuter->AddRef();
00682 }
00683
00684
00685 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00686   Method:   COUtilityCar::CImpIUtility::Release
00687
00688   Summary:  The Release IUnknown member of this IUtility interface
00689             implementation that delegates to m_pUnkOuter, whatever it is.
00690
00691   Args:     void
00692
00693   Modifies: .
00694
00695   Returns:  ULONG
00696               Returned by the delegated outer Release call.
00697 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00698 STDMETHODIMP_(ULONG) COUtilityCar::CImpIUtility::Release(void)
00699 {
00700   // Decrement the Interface Reference Count.
00701   --m_cRefI;
00702
00703   LOGF1("L: COUtilityCar::CImpIUtility::Release. Delegating. New cI=%i.", m_cRefI);
00704
00705   // Delegate this call to the outer object's Release.
00706   return m_pUnkOuter->Release();
00707 }
00708
00709
00710 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00711   Method:   COUtilityCar::CImpIUtility::Offroad
00712
00713   Summary:  The Offroad member method of this IUtility interface
00714             implementation.  A simple empty method on a COUtilityCar
00715             COM object for tutorial purposes.  Presumably if this
00716             UtilityCar object were modeling a real Car then the Offroad
00717             method would function the 4-wheel drive transfer case and
00718             shift it to the specified 4-wheel drive mode.
00719
00720   Args:     short nGear
00721               0 = 2H or regular 2-wheel drive;
00722               1 = 4H or 4-wheel drive high speed;
00723               2 = neutral; and
00724               3 = 4L or 4-wheel drive low speed).
00725
00726   Modifies: .
00727
00728   Returns:  HRESULT
00729               NOERROR
00730 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00731 STDMETHODIMP COUtilityCar::CImpIUtility::Offroad(
00732                short nGear)
00733 {
00734   LOGF1("L: COUtilityCar::CImpIUtility::Offroad. Called. nGear=%i.",nGear);
00735
00736   return NOERROR;
00737 }
00738
00739
00740 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00741   Method:   COUtilityCar::CImpIUtility::Winch
00742
00743   Summary:  The Winch member method of this IUtility interface
00744             implementation.  A simple empty method on a COUtilityCar COM
00745             object for tutorial purposes.  Presumably if this UtilityCar
00746             object were modeling a real Car then the Winch method would
00747             turn on/off the front-mounted Winch to the specified RPMs.
00748
00749   Args:     short nRpm
00750               0 = off; 1 - 50 RPM.
00751
00752   Modifies: .
00753
00754   Returns:  HRESULT
00755               NOERROR
00756 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00757 STDMETHODIMP COUtilityCar::CImpIUtility::Winch(
00758                short nRpm)
00759 {
00760   LOGF1("L: COUtilityCar::CImpIUtility::Winch. Called. nRpm=%i.",nRpm);
00761
00762   return NOERROR;
00763 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat2/iapplet.idl Source File

  • Web
  • NetMeeting
  • NMChat2

iapplet.idl

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       iapplet.idl
00004 //
00005 //
00006 //  Copyright (c) Microsoft Corporation 1999-2002
00007 //
00008 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00009 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00010 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00011 // PARTICULAR PURPOSE.
00012 //****************************************************************************
00013
00014 #include <iapplet.idl>
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/RecoDLL/StdAfx.cpp Source File

  • TabletPC
  • RecoDLL

StdAfx.cpp

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //--------------------------------------------------------------------------
00013 //
00014 // stdafx.cpp : source file that includes just the standard includes
00015 //  RecoDll.pch will be the pre-compiled header
00016 //  stdafx.obj will contain the pre-compiled type information
00017 //
00018
00019 #include "stdafx.h"
00020
00021 // TODO: reference any additional headers you need in STDAFX.H
00022 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/DCO_DimmerService/DimmerService.h Source File

  • NetDS
  • upnp
  • DCO_DimmerService

DimmerService.h

Go to the documentation of this file.
00001 //
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 // PARTICULAR PURPOSE.
00006 //
00007 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00008 //
00009 //
00010 // DimmerService.h
00011
00012
00013 #ifndef __UPNPDimmerSERVICE_H_
00014 #define __UPNPDimmerSERVICE_H_
00015
00016
00017 class UPNPDimmerService;
00018
00019 class ATL_NO_VTABLE UPNPDimmerService :
00020    public CComObjectRootEx <CComMultiThreadModel>,
00021    public IDispatchImpl<IUPnPService_DimmingService_SCPD, &IID_IUPnPService_DimmingService_SCPD, &LIBID_SDKDimmerServiceLib>,
00022    public IUPnPEventSource
00023 {
00024
00025 public:
00026
00027    UPNPDimmerService();
00028    ~UPNPDimmerService();
00029
00030    DECLARE_NOT_AGGREGATABLE(UPNPDimmerService)
00031
00032    DECLARE_PROTECT_FINAL_CONSTRUCT()
00033
00034    BEGIN_COM_MAP(UPNPDimmerService)
00035       COM_INTERFACE_ENTRY(IUPnPService_DimmingService_SCPD)
00036       COM_INTERFACE_ENTRY(IDispatch)
00037       COM_INTERFACE_ENTRY(IUPnPEventSource)
00038    END_COM_MAP()
00039
00040 public:
00041
00042    // IUPnPService_DimmingService_SCPD methods (i.e. Dimming Service Methods)
00043    STDMETHOD (get_Power) (VARIANT_BOOL *pval);
00044    STDMETHOD (get_dimLevel) (LONG *dLevel);
00045
00046    STDMETHOD (PowerOn) ();
00047    STDMETHOD (PowerOff) ();
00048
00049    STDMETHOD (GetPowerValue) (VARIANT_BOOL *powerVal);
00050
00051    STDMETHOD (SetDimLevel) (LONG dLevel);
00052    STDMETHOD (GetDimLevel) (LONG *dLevel);
00053    STDMETHOD (GetConfigDetails) (VARIANT_BOOL *powerVal,LONG *dLevel);
00054
00055    // IUPnPEventSource methods
00056    STDMETHOD (Advise) (IUPnPEventSink *punkSubscriber);
00057    STDMETHOD (Unadvise) (IUPnPEventSink *punkSubscriber);
00058
00059 private:
00060    VARIANT_BOOL power;
00061    LONG dimnessLevel;
00062    IUPnPEventSink *esEventingManager;
00063
00064    //to synchronise between multiple requests for the same action
00065    CRITICAL_SECTION csSync;
00066 };
00067
00068 #endif //__DimmerSERVICE_H_
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellExt/Priv.h Source File

  • WinUI
  • Shell
  • ShellExt

Priv.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------
00002 // common user interface routines
00003 //
00004 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00005 //
00006 //--------------------------------------------------------------
00007
00008
00009 #ifndef STRICT
00010 #define STRICT
00011 #endif
00012
00013 #define INC_OLE2        // WIN32, get ole2 from windows.h
00014
00015 #include <windows.h>
00016 #include <windowsx.h>
00017 #include <shlobj.h>
00018
00019 #define ResultFromShort(i)  ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/certpsam.idl Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

certpsam.idl

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        certpsam.idl
00007 //
00008 // Contents:    IDL source for certpsam
00009 //
00010 //---------------------------------------------------------------------------
00011
00012
00013 import "wtypes.idl";
00014 import "certpol.idl";
00015 import "certmod.idl";
00016
00017
00018 //+--------------------------------------------------------------------------
00019 // certpol Type library
00020 //+--------------------------------------------------------------------------
00021
00022 [
00023     uuid(98a77720-c2c8-11d2-b313-00c04f79dc72),
00024     version(1.0),
00025     helpstring("CertPolicySample 1.0 Type Library")
00026 ]
00027
00028 library CERTPOLICYSAMPLELib
00029 {
00030     importlib("stdole2.tlb");
00031
00032     [
00033   uuid(98f87410-c2c8-11d2-b313-00c04f79dc72),
00034   helpstring("CertPolicySample Class")
00035     ]
00036     coclass CCertPolicySample
00037     {
00038   [default] interface ICertPolicy2;
00039     };
00040
00041     [
00042   uuid(98567a30-c2c8-11d2-b313-00c04f79dc72),
00043   helpstring("CertManagePolicyModuleSample Class")
00044     ]
00045     coclass CCertManagePolicyModuleSample
00046     {
00047   [default] interface ICertManageModule;
00048     };
00049 };
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CMDI Member List

This is the complete list of members for _CMDI, including all inherited members.
ccmd | _CMDI
edwp | _CMDI
rgcmd | _CMDI
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

storesh::Win32 Member List

This is the complete list of members for storesh::Win32, including all inherited members.
CertEnumSystemStore(uint dwFlags, uint pvSystemStoreLocationPara, String pvArg, CertEnumSystemStoreCallback pfnEnum) storesh::Win32
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/DCO_DimmerService/DimmerService.cpp Source File

  • NetDS
  • upnp
  • DCO_DimmerService

DimmerService.cpp

Go to the documentation of this file.
00001 //
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 // PARTICULAR PURPOSE.
00006 //
00007 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00008 //
00009 //
00010 // DimmerService.cpp
00011
00012
00013 #include <stdio.h>
00014 #include <windows.h>
00015 #include <tchar.h>
00016 #include <objbase.h>
00017 #include <atlbase.h>
00018 #include "DeviceDll.h"
00019 #include <atlcom.h>
00020 #include <initguid.h>
00021 #include <upnphost.h>
00022 #include "resource.h"
00023 #include "dimmerdevice.h"
00024 #include "DimmerService.h"
00025
00026
00027 UPNPDimmerService::UPNPDimmerService()
00028 {
00029    // Set the default values for the state table variables power and dimLevel
00030    power = VARIANT_FALSE;
00031    dimnessLevel = 0;
00032
00033    InitializeCriticalSection(&csSync);
00034    // Make it NULL and this will be later set when the device host calls the Advise()
00035    esEventingManager = NULL;
00036 }
00037
00038
00039
00040 UPNPDimmerService::~UPNPDimmerService()
00041 {
00042    // Cleanup before the service exits
00043    if (esEventingManager)
00044    {
00045       // we have to release the pointer to the Eventing Manager Interface on shutdown
00046       esEventingManager->Release();
00047       esEventingManager = NULL;
00048    }
00049
00050    DeleteCriticalSection(&csSync);
00051 }
00052
00053
00054
00055 HRESULT UPNPDimmerService::get_Power(VARIANT_BOOL *pval)
00056 {
00057    // Return the value of the state table variable Power
00058    EnterCriticalSection(&csSync);
00059    *pval = power;
00060    LeaveCriticalSection(&csSync);
00061    return S_OK;
00062 }
00063
00064
00065
00066 HRESULT UPNPDimmerService::get_dimLevel(LONG *dLevel)
00067 {
00068    // Return the value of the state table variable dimLevel
00069    EnterCriticalSection(&csSync);
00070    *dLevel = dimnessLevel;
00071    LeaveCriticalSection(&csSync);
00072    return S_OK;
00073 }
00074
00075
00076
00077 HRESULT UPNPDimmerService::PowerOn()
00078 {
00079    DISPID rgdispidChanges[1];
00080
00081    EnterCriticalSection(&csSync);
00082
00083    if (power != VARIANT_TRUE)
00084    {
00085       power = VARIANT_TRUE;
00086       LeaveCriticalSection(&csSync);
00087
00088       // We have to send an event here indicating that the value of Power has changed
00089       if(esEventingManager)
00090       {
00091          // Send the event that power = TRUE through OnStateChanged API exposed by IUPnPEventSource
00092          rgdispidChanges[0]=DISPID_POWER;
00093          esEventingManager->OnStateChanged(1, rgdispidChanges);
00094       }
00095    }
00096    else
00097    {
00098       LeaveCriticalSection(&csSync);
00099    }
00100
00101    return S_OK;
00102 }
00103
00104
00105
00106
00107 HRESULT UPNPDimmerService::PowerOff()
00108 {
00109    DISPID rgdispidChanges[1];
00110
00111    EnterCriticalSection(&csSync);
00112    if (power != VARIANT_FALSE)
00113    {
00114       power = VARIANT_FALSE;
00115       // We have to send an event here since the value of a State table variable
00116       // has changed
00117       LeaveCriticalSection(&csSync);
00118
00119       if(esEventingManager)
00120       {
00121          // Send the event using the OnStateChanged API and indicate the the
00122          // value of the state table variable Power has changed
00123          rgdispidChanges[0]=DISPID_POWER;
00124          esEventingManager->OnStateChanged(1, rgdispidChanges);
00125       }
00126    }
00127    else
00128    {
00129       LeaveCriticalSection(&csSync);
00130    }
00131
00132    return S_OK;
00133 }
00134
00135
00136
00137 HRESULT UPNPDimmerService::GetPowerValue(VARIANT_BOOL*powerVal)
00138 {
00139    EnterCriticalSection(&csSync);
00140    *powerVal = power;
00141    LeaveCriticalSection(&csSync);
00142
00143    // We have no events to send for this action
00144    return S_OK;
00145 }
00146
00147
00148
00149 HRESULT UPNPDimmerService::SetDimLevel(LONG dLevel)
00150 {
00151    DISPID rgdispidChanges[1];
00152
00153    EnterCriticalSection(&csSync);
00154    dimnessLevel = dLevel;
00155    // The possible values for dimnessLevel are 0 - 100
00156    if (dimnessLevel > 100) dimnessLevel = 100;
00157    if (dimnessLevel < 0) dimnessLevel = 0;
00158    LeaveCriticalSection(&csSync);
00159
00160    // We have to send an event here
00161    if(esEventingManager)
00162    {
00163       // Send the event using the OnStateChanged API to indicate that value
00164       // of State table varaible dimLevel has changed
00165       rgdispidChanges[0]=DISPID_DIMLEVEL;
00166       esEventingManager->OnStateChanged(1, rgdispidChanges);
00167    }
00168
00169    return S_OK;
00170 }
00171
00172
00173 HRESULT UPNPDimmerService::GetDimLevel(LONG *dLevel)
00174 {
00175    EnterCriticalSection(&csSync);
00176    *dLevel = dimnessLevel;
00177    LeaveCriticalSection(&csSync);
00178
00179    // We have no events to send here as the state table has not changed
00180    return S_OK;
00181 }
00182
00183
00184
00185 HRESULT UPNPDimmerService::GetConfigDetails(VARIANT_BOOL *powerVal,LONG *dLevel)
00186 {
00187    EnterCriticalSection(&csSync);
00188    *dLevel = dimnessLevel;
00189    *powerVal = power;
00190    LeaveCriticalSection(&csSync);
00191
00192    // We have no events to send here as the state table has not changed
00193    return S_OK;
00194 }
00195
00196
00197 HRESULT UPNPDimmerService::Advise (IUPnPEventSink *punkSubscriber)
00198 {
00199    // We have to get query for the IUPnPEventSink Interface to send events
00200    // later using the OnStateChanged API
00201
00202    HRESULT hr = S_OK;
00203
00204    // Query the pointer passed to the Advise function for the IUPnPEventSink Interface
00205    hr = punkSubscriber->QueryInterface(IID_IUPnPEventSink, (void **)&esEventingManager);
00206    if (FAILED(hr))
00207    {
00208       OutputDebugString(_TEXT("UPNPDimmerService: Query Interface failed.  Could not get pointer to IUPnPEventSink\n"));
00209       esEventingManager = NULL;
00210       return hr;
00211    }
00212
00213    return hr;
00214 }
00215
00216
00217
00218 HRESULT UPNPDimmerService::Unadvise(IUPnPEventSink *punkSubscriber)
00219 {
00220    // Device Host is not interested in receiving more events and so set the
00221    // pointer to the IUPnPEventSink interface to NULL
00222    if (esEventingManager)
00223    {
00224       // esEventingManager is already set by the advise
00225       esEventingManager->Release();
00226       esEventingManager = NULL;
00227    }
00228
00229    return S_OK;
00230 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBrowserHost Member List

This is the complete list of members for CBrowserHost, including all inherited members.
CanInPlaceActivate() | CBrowserHost | [inline, private]
CanInPlaceActivate() | CBrowserHost | [inline, private]
CanInPlaceActivate() | CBrowserHost | [inline, private]
CanInPlaceActivate() | CBrowserHost | [inline, private]
CBrowserHost() | CBrowserHost | [inline]
CBrowserHost() | CBrowserHost |
CBrowserHost() | CBrowserHost |
CBrowserHost() | CBrowserHost |
ContextSensitiveHelp(BOOL fEnterMode) | CBrowserHost | [inline, private]
ContextSensitiveHelp(BOOL fEnterMode) | CBrowserHost | [inline, private]
ContextSensitiveHelp(BOOL fEnterMode) | CBrowserHost | [inline, private]
ContextSensitiveHelp(BOOL fEnterMode) | CBrowserHost | [inline, private]
CreateToolbar() | CBrowserHost | [private]
CreateToolbar() | CBrowserHost | [private]
CreateToolbar() | CBrowserHost | [private]
DeactivateAndUndo(void) | CBrowserHost | [inline, private]
DeactivateAndUndo(void) | CBrowserHost | [inline, private]
DeactivateAndUndo(void) | CBrowserHost | [inline, private]
DeactivateAndUndo(void) | CBrowserHost | [inline, private]
DiscardUndoState() | CBrowserHost | [inline, private]
DiscardUndoState() | CBrowserHost | [inline, private]
DiscardUndoState() | CBrowserHost | [inline, private]
DiscardUndoState() | CBrowserHost | [inline, private]
GetContainer(IOleContainer **ppContainer) | CBrowserHost | [inline, private]
GetContainer(IOleContainer **ppContainer) | CBrowserHost | [inline, private]
GetContainer(IOleContainer **ppContainer) | CBrowserHost | [inline, private]
GetContainer(IOleContainer **ppContainer) | CBrowserHost | [inline, private]
GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) | CBrowserHost | [inline, private]
GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) | CBrowserHost | [inline, private]
GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) | CBrowserHost | [inline, private]
GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) | CBrowserHost | [inline, private]
GetWindow(HWND *phwnd) | CBrowserHost | [inline, private]
GetWindow(HWND *phwnd) | CBrowserHost | [inline, private]
GetWindow(HWND *phwnd) | CBrowserHost | [inline, private]
GetWindow(HWND *phwnd) | CBrowserHost | [inline, private]
GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) | CBrowserHost | [inline, private]
GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) | CBrowserHost | [inline, private]
GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) | CBrowserHost | [inline, private]
GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) | CBrowserHost | [inline, private]
Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) | CBrowserHost | [private]
Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) | CBrowserHost | [private]
Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) | CBrowserHost | [private]
Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) | CBrowserHost | [private]
m_bAtlBrowserHelp | CBrowserHost | [protected]
m_bButton10Down | CBrowserHost | [protected]
m_bButton2Down | CBrowserHost | [protected]
m_bButton3Down | CBrowserHost | [protected]
m_bButton4Down | CBrowserHost | [protected]
m_bButton5Down | CBrowserHost | [protected]
m_bButton6Down | CBrowserHost | [protected]
m_bButton7Down | CBrowserHost | [protected]
m_bButton8Down | CBrowserHost | [protected]
m_bButton9Down | CBrowserHost | [protected]
m_bEnableCtxMenus | CBrowserHost | [protected]
m_bInPlaceActive | CBrowserHost | [protected]
m_bIsChecked | CBrowserHost |
m_dwCookie | CBrowserHost |
m_dwCookie2 | CBrowserHost |
m_dwDLControl | CBrowserHost | [protected]
m_dwDocHostUIDblClk | CBrowserHost | [protected]
m_dwDocHostUIFlags | CBrowserHost | [protected]
m_lCSSlevel | CBrowserHost | [protected]
m_lGridCookie | CBrowserHost | [protected]
m_lLeftBandWidth | CBrowserHost |
m_lSnapIncrement | CBrowserHost | [protected]
m_lTopBandHeight | CBrowserHost |
m_spDoc | CBrowserHost |
m_spGrid | CBrowserHost | [protected]
m_spInPlaceObject | CBrowserHost |
m_spOleCmdTarg | CBrowserHost |
m_spSnap | CBrowserHost | [protected]
m_spWebBrowser | CBrowserHost |
m_wndAddressBox | CBrowserHost |
m_wndBox1 | CBrowserHost |
m_wndBox2 | CBrowserHost |
m_wndBox3 | CBrowserHost |
m_wndBox4 | CBrowserHost |
m_wndButton1 | CBrowserHost |
m_wndButton2 | CBrowserHost |
m_wndButton3 | CBrowserHost |
m_wndButton4 | CBrowserHost |
m_wndButton5 | CBrowserHost |
m_wndButton6 | CBrowserHost |
m_wndButton7 | CBrowserHost |
m_wndCheckBox | CBrowserHost |
m_wndIncrementCombo | CBrowserHost | [protected]
m_wndLeftBand | CBrowserHost |
m_wndStatusBar | CBrowserHost |
m_wndToolBar | CBrowserHost | [protected]
m_wndTopBand | CBrowserHost |
m_wndUrlCombo | CBrowserHost | [protected]
OnAddressBox(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost |
OnBox1(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost |
OnBox2(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost |
OnBox3(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost |
OnBox4(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost |
OnButton1(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton1(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton1(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton1(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton10(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton2(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton2(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton2(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton2(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton3(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton3(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton3(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton3(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton4(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton4(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton4(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton5(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton5(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton5(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton6(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton6(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton7(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnButton7(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton8(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnButton9(WORD, WORD, HWND, BOOL &) | CBrowserHost | [protected]
OnCheckBox(WORD, WORD, HWND, BOOL &) | CBrowserHost |
OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CBrowserHost |
OnCreate(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnCreate(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnCreate(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CBrowserHost |
OnInPlaceActivate() | CBrowserHost | [inline, private]
OnInPlaceActivate() | CBrowserHost | [inline, private]
OnInPlaceActivate() | CBrowserHost | [inline, private]
OnInPlaceActivate() | CBrowserHost | [inline, private]
OnInPlaceDeactivate() | CBrowserHost | [inline, private]
OnInPlaceDeactivate() | CBrowserHost | [inline, private]
OnInPlaceDeactivate() | CBrowserHost | [inline, private]
OnInPlaceDeactivate() | CBrowserHost | [inline, private]
OnKeydown(UINT, WPARAM wParam, LPARAM lParam, BOOL &) | CBrowserHost |
OnKeydown(UINT, WPARAM wParam, LPARAM lParam, BOOL &) | CBrowserHost | [protected]
OnKeydown(UINT, WPARAM wParam, LPARAM lParam, BOOL &) | CBrowserHost | [protected]
OnKeydown(UINT, WPARAM wParam, LPARAM lParam, BOOL &) | CBrowserHost | [protected]
OnNCDestroy(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnNCDestroy(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnNCDestroy(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnPosRectChange(LPCRECT lprcPosRect) | CBrowserHost | [inline, private]
OnPosRectChange(LPCRECT lprcPosRect) | CBrowserHost | [inline, private]
OnPosRectChange(LPCRECT lprcPosRect) | CBrowserHost | [inline, private]
OnPosRectChange(LPCRECT lprcPosRect) | CBrowserHost | [inline, private]
OnShowWindow(BOOL fShow) | CBrowserHost | [inline, private]
OnShowWindow(BOOL fShow) | CBrowserHost | [inline, private]
OnShowWindow(BOOL fShow) | CBrowserHost | [inline, private]
OnShowWindow(BOOL fShow) | CBrowserHost | [inline, private]
OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CBrowserHost |
OnSize(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnSize(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnSize(UINT, WPARAM, LPARAM, BOOL &) | CBrowserHost | [protected]
OnUIActivate() | CBrowserHost | [inline, private]
OnUIActivate() | CBrowserHost | [inline, private]
OnUIActivate() | CBrowserHost | [inline, private]
OnUIActivate() | CBrowserHost | [inline, private]
OnUIDeactivate(BOOL fUndoable) | CBrowserHost | [inline, private]
OnUIDeactivate(BOOL fUndoable) | CBrowserHost | [inline, private]
OnUIDeactivate(BOOL fUndoable) | CBrowserHost | [inline, private]
OnUIDeactivate(BOOL fUndoable) | CBrowserHost | [inline, private]
QueryService(REFGUID guidService, REFIID riid, void **ppv) | CBrowserHost | [private]
RequestNewObjectLayout(void) | CBrowserHost | [inline, private]
RequestNewObjectLayout(void) | CBrowserHost | [inline, private]
RequestNewObjectLayout(void) | CBrowserHost | [inline, private]
RequestNewObjectLayout(void) | CBrowserHost | [inline, private]
Run() | CBrowserHost |
Run() | CBrowserHost |
Run() | CBrowserHost |
Run() | CBrowserHost |
SaveObject(void) | CBrowserHost | [inline, private]
SaveObject(void) | CBrowserHost | [inline, private]
SaveObject(void) | CBrowserHost | [inline, private]
SaveObject(void) | CBrowserHost | [inline, private]
Scroll(SIZE scrollExtant) | CBrowserHost | [inline, private]
Scroll(SIZE scrollExtant) | CBrowserHost | [inline, private]
Scroll(SIZE scrollExtant) | CBrowserHost | [inline, private]
Scroll(SIZE scrollExtant) | CBrowserHost | [inline, private]
ShowObject(void) | CBrowserHost | [inline, private]
ShowObject(void) | CBrowserHost | [inline, private]
ShowObject(void) | CBrowserHost | [inline, private]
ShowObject(void) | CBrowserHost | [inline, private]
Stop() | CBrowserHost |
Stop() | CBrowserHost | [protected]
Stop() | CBrowserHost | [protected]
Stop() | CBrowserHost | [protected]
Generated on Wed Nov 13 2024 16:55:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmDebug/CrmDebugCompensator.h Source File

  • Com
  • Services
  • Crm
  • CrmDebug

CrmDebugCompensator.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmDebugCompensator.h
00004
00005
00006
00007 Summary:
00008
00009   This is a sample CRM Compensator for the Compensating Resource Manager (CRM).
00010
00011   It can be used as a substitute for your own CRM Compensator while developing your CRM.
00012
00013   It simply outputs debug messages for all CRM Compensator notifications.
00014
00015   It implements both ICrmCompensator and ICrmCompensatorVariants.
00016
00017   This file is part of the Microsoft COM Technology Samples.
00018
00019 Classes:
00020
00021   CCrmDebugCompensator
00022
00023 ----------------------------------------------------------------------------
00024
00025 This file is part of the Microsoft COM+ Samples.
00026
00027
00028
00029 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00030
00031
00032
00033 This source code is intended only as a supplement to Microsoft
00034
00035 Development Tools and/or on-line documentation. See these other
00036
00037 materials for detailed information regarding Microsoft code samples.
00038
00039
00040
00041 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00042
00043 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00044
00045 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00046
00047 PARTICULAR PURPOSE.
00048
00049 ==========================================================================+*/
00050
00051 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00052
00053 Class: CCrmDebugCompensator
00054
00055   This is the CRM Compensator. After the transaction is completed this
00056   object is created and given the log from the transaction. It can then
00057   commit or abort the transaction. This compensator prints trace
00058   messages.
00059
00060 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00061
00062 // CrmDebugCompensator.h : Declaration of the CCrmDebugCompensator
00063
00064 #ifndef __CRMDEBUGCOMPENSATOR_H_
00065 #define __CRMDEBUGCOMPENSATOR_H_
00066
00067 #include "resource.h"       // main symbols
00068
00069 #include "comsvcs.h"
00070
00071 /////////////////////////////////////////////////////////////////////////////
00072 // CCrmDebugCompensator
00073 class ATL_NO_VTABLE CCrmDebugCompensator :
00074   public CComObjectRootEx<CComMultiThreadModel>,
00075   public CComCoClass<CCrmDebugCompensator, &CLSID_CrmDebugCompensator>,
00076   public ICrmDebugCompensator,
00077     public ICrmCompensator,
00078     public ICrmCompensatorVariants
00079 {
00080 public:
00081   CCrmDebugCompensator()
00082   {
00083     m_pUnkMarshaler = NULL;
00084   }
00085
00086   /***** /
00087
00088   // for debugging refcount problems
00089
00090   ULONG InternalAddRef();
00091
00092   ULONG InternalRelease();
00093
00094   / *****/
00095
00096 DECLARE_REGISTRY_RESOURCEID(IDR_CRMDEBUGCOMPENSATOR)
00097 DECLARE_GET_CONTROLLING_UNKNOWN()
00098
00099 BEGIN_COM_MAP(CCrmDebugCompensator)
00100   COM_INTERFACE_ENTRY(ICrmDebugCompensator)
00101   COM_INTERFACE_ENTRY(ICrmCompensator)
00102   COM_INTERFACE_ENTRY(ICrmCompensatorVariants)
00103   COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
00104 END_COM_MAP()
00105
00106   HRESULT FinalConstruct();
00107
00108   void FinalRelease();
00109
00110   CComPtr<IUnknown> m_pUnkMarshaler;
00111
00112
00113 // ICrmCompensator
00114
00115     HRESULT STDMETHODCALLTYPE SetLogControl(
00116         /* [in] */ ICrmLogControl __RPC_FAR *pLogControl);
00117
00118     HRESULT STDMETHODCALLTYPE BeginPrepare(void);
00119
00120     HRESULT STDMETHODCALLTYPE PrepareRecord(
00121         /* [in] */ CrmLogRecordRead crmLogRec,
00122         /* [retval][out] */ BOOL __RPC_FAR *pfForget);
00123
00124     HRESULT STDMETHODCALLTYPE EndPrepare(
00125         /* [retval][out] */ BOOL __RPC_FAR *pfOkToPrepare);
00126
00127     HRESULT STDMETHODCALLTYPE BeginCommit(
00128         /* [in] */ BOOL fRecovery);
00129
00130     HRESULT STDMETHODCALLTYPE CommitRecord(
00131         /* [in] */ CrmLogRecordRead crmLogRec,
00132         /* [retval][out] */ BOOL __RPC_FAR *pfForget);
00133
00134     HRESULT STDMETHODCALLTYPE EndCommit(void);
00135
00136     HRESULT STDMETHODCALLTYPE BeginAbort(
00137         /* [in] */ BOOL fRecovery);
00138
00139     HRESULT STDMETHODCALLTYPE AbortRecord(
00140         /* [in] */ CrmLogRecordRead crmLogRec,
00141         /* [retval][out] */ BOOL __RPC_FAR *pfForget);
00142
00143     HRESULT STDMETHODCALLTYPE EndAbort(void);
00144
00145 // ICrmCompensatorVariants
00146
00147     HRESULT STDMETHODCALLTYPE SetLogControlVariants(
00148         /* [in] */ ICrmLogControl __RPC_FAR *pLogControl);
00149
00150     HRESULT STDMETHODCALLTYPE BeginPrepareVariants(void);
00151
00152     HRESULT STDMETHODCALLTYPE PrepareRecordVariants(
00153         /* [in] */ VARIANT __RPC_FAR *pLogRecord,
00154         /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbForget);
00155
00156     HRESULT STDMETHODCALLTYPE EndPrepareVariants(
00157         /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbOkToPrepare);
00158
00159     HRESULT STDMETHODCALLTYPE BeginCommitVariants(
00160         /* [in] */ VARIANT_BOOL bRecovery);
00161
00162     HRESULT STDMETHODCALLTYPE CommitRecordVariants(
00163         /* [in] */ VARIANT __RPC_FAR *pLogRecord,
00164         /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbForget);
00165
00166     HRESULT STDMETHODCALLTYPE EndCommitVariants(void);
00167
00168     HRESULT STDMETHODCALLTYPE BeginAbortVariants(
00169         /* [in] */ VARIANT_BOOL bRecovery);
00170
00171     HRESULT STDMETHODCALLTYPE AbortRecordVariants(
00172         /* [in] */ VARIANT __RPC_FAR *pLogRecord,
00173         /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbForget);
00174
00175     HRESULT STDMETHODCALLTYPE EndAbortVariants(void);
00176
00177 // ICrmDebugCompensator
00178 public:
00179 };
00180
00181 #endif //__CRMDEBUGCOMPENSATOR_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cmdichild.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cmdichild.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CMDICHILD.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 //////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017 #ifdef MTSTXN
00018   #include <xolehlp.h>
00019   #include <txdtc.h>
00020 #endif //MTSTXN
00021
00022
00023 ULONG CMDIChild::m_iChildWindow = 0;  //Static member
00024 ///////////////////////////////////////////////////////////////
00025 // CMDIChild::CMDIChild
00026 //
00027 /////////////////////////////////////////////////////////////////
00028 CMDIChild::CMDIChild(CMainWindow* pCMainWindow)
00029 {
00030   //Objects
00031   ASSERT(pCMainWindow);
00032   m_pCMainWindow = pCMainWindow;
00033
00034   //Controls
00035   m_pCDataGrid      = new CDataGrid(this);
00036   m_pCQueryBox      = new CQueryBox(this);
00037
00038   //Objects
00039   m_pCDataSource      = NULL;   //Deferred
00040   m_pCSession       = NULL;   //Deferred
00041   m_pCCommand       = NULL;   //Deferred
00042   m_pCMultipleResults   = NULL;   //Deferred
00043   m_pCDataAccess      = NULL;   //Deferred
00044
00045   //Data
00046   m_lastSizedEdge = 0;
00047   m_iChildWindow++;
00048   m_pwszConfig  = NULL;
00049
00050   //Only set these "Default" properties, if requested by the user
00051   if(GetOptions()->m_dwRowsetOpts & ROWSET_SETDEFAULTPROPS)
00052   {
00053     //DBPROP_CANHOLDROWS is required by the OLE DB Spec - Level-0 Conformance
00054     //Since it is also legal to set a ReadOnly property, just blindy set it...
00055     m_CDefPropSets.SetProperty(DBPROP_CANHOLDROWS, DBPROPSET_ROWSET, DBTYPE_BOOL, (void*)VARIANT_TRUE, DBPROPOPTIONS_REQUIRED);
00056   }
00057 }
00058
00059
00060 ////////////////////////////////////////////////////////////////
00061 // CMDIChild::~CMDIChild
00062 //
00063 /////////////////////////////////////////////////////////////////
00064 CMDIChild::~CMDIChild()
00065 {
00066   SAFE_RELEASE(m_pCDataAccess);
00067   SAFE_RELEASE(m_pCMultipleResults);
00068   SAFE_RELEASE(m_pCCommand);
00069   SAFE_RELEASE(m_pCSession);
00070   SAFE_RELEASE(m_pCDataSource);
00071
00072   //Controls
00073   SAFE_DELETE(m_pCDataGrid);
00074   SAFE_DELETE(m_pCQueryBox);
00075
00076   //Data
00077   m_iChildWindow--;
00078   SAFE_FREE(m_pwszConfig);
00079 }
00080
00081
00082 ////////////////////////////////////////////////////////////////
00083 // CMDIChild::GetOptions
00084 //
00085 /////////////////////////////////////////////////////////////////
00086 COptionsSheet*  CMDIChild::GetOptions()
00087 {
00088   return m_pCMainWindow->GetOptions();
00089 }
00090
00091
00092 ////////////////////////////////////////////////////////////////
00093 // CMDIChild::SetConfig
00094 //
00095 /////////////////////////////////////////////////////////////////
00096 void CMDIChild::SetConfig(WCHAR* pwszConfig, BOOL fCopy)
00097 {
00098   SAFE_FREE(m_pwszConfig);
00099
00100   //Optmization:  If the caller no longer needs the name,
00101   //no sense in reallocing, copying, freeing, freeing.  Just reference it...
00102   m_pwszConfig = fCopy ? wcsDuplicate(pwszConfig) : pwszConfig;
00103
00104   //Obtain the last Saved Query in the Query Box
00105   if(m_pCQueryBox && m_pwszConfig)
00106   {
00107     WCHAR* pwszQuery = NULL;
00108
00109     //Formulate the key
00110     static WCHAR wszKeyName[MAX_NAME_LEN];
00111     StringFormat(wszKeyName, NUMELE(wszKeyName), L"%s\\%s\\Command", wszCONFIG_KEY, m_pwszConfig);
00112
00113     //Save the Query
00114     GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Query", &pwszQuery);
00115
00116     //Update the Query Box
00117     m_pCQueryBox->SetWindowText(pwszQuery);
00118     SAFE_FREE(pwszQuery);
00119   }
00120 }
00121
00122
00123
00124 ////////////////////////////////////////////////////////////////
00125 // CMDIChild::AutoPosition
00126 //
00127 /////////////////////////////////////////////////////////////////
00128 BOOL CMDIChild::AutoPosition(BOOL fDefaultPosition)
00129 {
00130   if(fDefaultPosition || m_wndPlacement.length == 0)
00131   {
00132     //Default setting, upper right corner (3/4 of the client area)...
00133     SIZE sizeClient = GetClientSize(m_pCMainWindow->m_hWndMDIClient);
00134     return MoveWindow(m_hWnd, (INT)((float)sizeClient.cx * 0.25), 0, (INT)((float)sizeClient.cx * 0.75), (INT)((float)sizeClient.cy * 0.75), TRUE);
00135   }
00136   else
00137   {
00138     return SetWindowPlacement();
00139   }
00140 }
00141
00142
00143 ////////////////////////////////////////////////////////////////
00144 // CMDIChild::OnCreate
00145 //
00146 /////////////////////////////////////////////////////////////////
00147 BOOL CMDIChild::OnCreate(LPCREATESTRUCT lpCreateStruct)
00148 {
00149   // create child windows
00150   // 1. ListView for rowset data
00151   // 2. EditBox for entering SQL Text
00152   // 3. ListBox for notifcations
00153   // 4. ScrollBar for scrolling through the rowset
00154   GetWindowPlacement();
00155   SIZE size = { m_wndPlacement.rcNormalPosition.right - m_wndPlacement.rcNormalPosition.left,
00156           m_wndPlacement.rcNormalPosition.bottom - m_wndPlacement.rcNormalPosition.top };
00157
00158   //Create the SQL Query Box
00159   m_pCQueryBox->Create(m_hWnd, m_pCMainWindow->m_hLibRichEdit20 ? (IsUnicodeOS() ? L"RichEdit20W" : L"RichEdit20A") : L"RICHEDIT", NULL, IDC_EDITBOX,
00160     WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE /* | ES_DISABLENOSCROLL | ES_SELECTIONBAR*/, 0,
00161     0, 0, size.cx, (INT)((float)size.cy * 0.25));
00162   m_pCQueryBox->OnCreate(NULL);
00163   m_pCQueryBox->SetWordWrap(TRUE);
00164
00165   //By default the RichEdit controls have a HUGE text.  Instead of setting it
00166   //to a small size font which is difficult for some international lcids, we will
00167   //set it to the same font as the Tree control...
00168   m_pCQueryBox->SetFont(m_pCMainWindow->m_pCMDIObjects->m_pCObjTree->GetFont());
00169
00170   //Create the DataGrid
00171   m_pCDataGrid->Create(m_hWnd, WC_LISTVIEWW, NULL, IDC_LISTVIEW,
00172     WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | /*LVS_SINGLESEL |*/ LVS_AUTOARRANGE | LVS_REPORT | LVS_EDITLABELS | LVS_SHOWSELALWAYS, WS_EX_CLIENTEDGE,
00173     0, (INT)((float)size.cy * 0.25), size.cx - GetSystemMetrics(SM_CXVSCROLL), (INT)((float)size.cy * 0.75));
00174   m_pCDataGrid->EnableWindow(FALSE);
00175
00176   //Use Extended ListView Styles!
00177   SendMessage(m_pCDataGrid->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
00178   ListView_SetImageList(m_pCDataGrid->m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
00179   m_pCDataGrid->OnCreate(NULL);
00180   m_pCDataGrid->ClearAll(L"No Rowset");
00181
00182   //Set Focus to the Query Box
00183   m_pCQueryBox->SetFocus();
00184
00185   //Setup Splitter Windows...
00186   m_pCQueryBox->SetSplitter(NULL, m_pCDataGrid, NULL, NULL);
00187   m_pCDataGrid->SetSplitter(m_pCQueryBox, NULL, NULL, NULL);
00188
00189   //Load Saved Window Positions
00190   if(m_iChildWindow == 1)
00191   {
00192     memset(&m_wndPlacement, 0, sizeof(m_wndPlacement));
00193     GetRegEntry(HKEY_ROWSETVIEWER, wszMDICHILD_KEY, L"WinPosition", &m_wndPlacement, sizeof(m_wndPlacement), NULL);
00194
00195     //Window Position
00196     AutoPosition(m_wndPlacement.length == 0/*fDefaultPosition*/);
00197   }
00198
00199   return TRUE;
00200 }
00201
00202
00203 ////////////////////////////////////////////////////////////////
00204 // CMDIChild::OnInitialUpdate
00205 //
00206 /////////////////////////////////////////////////////////////////
00207 BOOL CMDIChild::OnInitialUpdate()
00208 {
00209     //Update Window Title
00210   UpdateWndTitle();
00211   return TRUE;
00212 }
00213
00214
00215 ////////////////////////////////////////////////////////////////
00216 // CMDIChild::UpdateControls
00217 //
00218 /////////////////////////////////////////////////////////////////
00219 BOOL CMDIChild::UpdateControls()
00220 {
00221   CDataAccess* pCDataAccess = m_pCDataAccess && m_pCDataAccess->m_pIUnknown ? m_pCDataAccess : NULL;
00222
00223   //ToolBar Buttons
00224   m_pCMainWindow->UpdateControls();
00225
00226   //Disable ListView window
00227   m_pCDataGrid->EnableWindow(pCDataAccess != NULL);
00228
00229   //Update Window Title (in-case things have changed...)
00230   UpdateWndTitle();
00231   return TRUE;
00232 }
00233
00234
00235 ////////////////////////////////////////////////////////////////
00236 // CMDIChild::DisplayDialog
00237 //
00238 /////////////////////////////////////////////////////////////////
00239 INT_PTR   CMDIChild::DisplayDialog(UINT uID, HWND hWndParent, DLGPROC lpDialogFunc, CBase* pCObject, UINT idSource)
00240 {
00241   m_idSource = idSource;
00242   m_pCSource = pCObject;
00243   return ::DisplayDialog(uID, hWndParent, lpDialogFunc, (LPARAM)this);
00244 }
00245
00246
00247 /////////////////////////////////////////////////////////////////////////////
00248 // CMDIChild::OnUpdateCommand
00249 //
00250 /////////////////////////////////////////////////////////////////////////////
00251 BOOL CMDIChild::OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags)
00252 {
00253   //Default
00254   switch(nID)
00255   {
00256     //Edit Window
00257     ON_COMMAND_UI_ENABLED(IDM_PASTEEDITWINDOW,        m_pCQueryBox->CanPaste())
00258     ON_COMMAND_UI_ENABLED(IDM_CLEAREDITWINDOW,        TRUE)
00259
00260     //Cut/Copy is only enabled - if something is selected.
00261     ON_COMMAND_UI_ENABLED(IDM_COPYEDITWINDOW,       m_pCQueryBox->GetSel(NULL, NULL))
00262     ON_COMMAND_UI_ENABLED(IDM_CUTEDITWINDOW,        m_pCQueryBox->GetSel(NULL, NULL))
00263
00264     //Menu Items that are always on
00265     ON_COMMAND_UI_ENABLED(IDM_PROVIDERINFO,         TRUE)
00266     ON_COMMAND_UI_ENABLED(IDM_BROWSE_TABLENAME,       TRUE)
00267   };
00268
00269   return FALSE;
00270 }
00271
00272
00273 /////////////////////////////////////////////////////////////////////
00274 // CMDIChild::OnNotify
00275 //
00276 /////////////////////////////////////////////////////////////////////
00277 BOOL CMDIChild::OnNotify(INT idCtrl, NMHDR* pNMHDR)
00278 {
00279   //CDataGrid
00280   if(m_pCDataGrid->OnNotify(idCtrl, pNMHDR))
00281     return TRUE;
00282
00283   //CQueryBox
00284   if(m_pCQueryBox->OnNotify(idCtrl, pNMHDR))
00285     return TRUE;
00286
00287   //Delegate
00288   return CMDIChildLite::OnNotify(idCtrl, pNMHDR);
00289 }
00290
00291
00292 /////////////////////////////////////////////////////////////////////
00293 // CMDIChild::OnSizing
00294 //
00295 /////////////////////////////////////////////////////////////////////
00296 BOOL CMDIChild::OnSizing(WPARAM nSide, REFPOINTS pts)
00297 {
00298   //Record which edge was touched...
00299   m_lastSizedEdge = nSide;
00300   return TRUE;
00301 }
00302
00303 /////////////////////////////////////////////////////////////////////
00304 // CMDIChild::OnSize
00305 //
00306 /////////////////////////////////////////////////////////////////////
00307 BOOL CMDIChild::OnSize(WPARAM nType, REFPOINTS pts)
00308 {
00309   ASSERT(m_pCDataGrid->m_hWnd);
00310   ASSERT(m_pCQueryBox->m_hWnd);
00311
00312   switch(nType)
00313   {
00314     case SIZE_RESTORED:
00315     case SIZE_MAXIMIZED:
00316     {
00317       if(pts.x && pts.y)
00318       {
00319         //Obtain window sizes...
00320         SIZE sizeEditBox  = GetWindowSize(m_pCQueryBox->m_hWnd);
00321         SIZE sizeListView = GetWindowSize(m_pCDataGrid->m_hWnd);
00322
00323         //The MainWindow has been resized, we need to readjust all
00324         //Child controls, (ScrollBar, ListBox, ListView...)
00325         //Move Windows with respect to the new
00326
00327         switch(m_lastSizedEdge)
00328         {
00329           //Top was moved, resize the Editbox
00330           case WMSZ_TOP:
00331           case WMSZ_TOPLEFT:
00332           case WMSZ_TOPRIGHT:
00333             sizeEditBox.cy = max(0, pts.y - sizeListView.cy);
00334             break;
00335         }
00336
00337         MoveWindow(m_pCQueryBox->m_hWnd, 0, 0, pts.x, sizeEditBox.cy, TRUE);
00338         MoveWindow(m_pCDataGrid->m_hWnd, 0, sizeEditBox.cy, pts.x, pts.y-sizeEditBox.cy, TRUE);
00339         m_lastSizedEdge = 0;
00340       }
00341
00342       //Call default procedure first,
00343       //to let MDI position the child & then move its children
00344       //We simply do this by returning false, to indicate we didn't handle it...
00345       return FALSE;
00346     }
00347   };
00348
00349   return FALSE;
00350 }
00351
00352
00353 /////////////////////////////////////////////////////////////////////
00354 // CMDIChild::OnClose
00355 //
00356 /////////////////////////////////////////////////////////////////////
00357 BOOL CMDIChild::OnClose()
00358 {
00359   //Send Message to the MainWindow to Close
00360   //Mainly used so the MainWindow updates the ToolBar if there
00361   //Are no more child windows...
00362   SendMessage(m_pCMainWindow->GetWnd(), WM_COMMAND, GET_WM_COMMAND_MPS(IDM_CLOSEWINDOW, m_hWnd, 0));
00363   return TRUE;
00364 }
00365
00366
00367 /////////////////////////////////////////////////////////////////////////////
00368 // CMDIChild::OnDestroy
00369 //
00370 /////////////////////////////////////////////////////////////////////////////
00371 BOOL CMDIChild::OnDestroy()
00372 {
00373   //Save the Query in the Query Box (before exiting)
00374   if(m_pCQueryBox && m_pwszConfig)
00375   {
00376     WCHAR* pwszQuery = m_pCQueryBox->GetWindowText();
00377
00378     //Formulate the key
00379     static WCHAR wszKeyName[MAX_NAME_LEN];
00380     StringFormat(wszKeyName, NUMELE(wszKeyName), L"%s\\%s\\Command", wszCONFIG_KEY, m_pwszConfig);
00381
00382     //Save the Query
00383     SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Query",  pwszQuery);
00384     SAFE_FREE(pwszQuery);
00385   }
00386
00387   //Save Window Positions
00388   if(m_iChildWindow == 1)
00389   {
00390     //Window Positions
00391     if(GetWindowPlacement())
00392       SetRegEntry(HKEY_ROWSETVIEWER, wszMDICHILD_KEY, L"WinPosition", &m_wndPlacement,  sizeof(m_wndPlacement));
00393   }
00394
00395   //Delegate
00396   return CMDIChildLite::OnDestroy();
00397 }
00398
00399
00400 /////////////////////////////////////////////////////////////////////
00401 // CMDIChild::OnMDIActivate
00402 //
00403 /////////////////////////////////////////////////////////////////////
00404 BOOL CMDIChild::OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate)
00405 {
00406   //So see if this window is being activated or deactivated
00407   if(hWndActivate == m_hWnd)
00408   {
00409     CObjTree* pCObjTree = m_pCMainWindow->m_pCMDIObjects->m_pCObjTree;
00410     ASSERT(pCObjTree);
00411
00412     //Select the Object in Tree that this Window corresponds to...
00413     //NOTE: If there is already an object selected that belongs to this
00414     //window, then there is no need to switch the objects
00415     CBase* pCObject = pCObjTree->GetSelectedObject();
00416     if(!pCObject || (pCObject->m_pCMDIChild != this))
00417       pCObjTree->SelectObject(GetObject());
00418
00419     //Refresh all Controls
00420     UpdateControls();
00421   }
00422
00423   return TRUE;
00424 }
00425
00426 /////////////////////////////////////////////////////////////////////////////
00427 // CMDIChild::OnSetFocus
00428 //
00429 /////////////////////////////////////////////////////////////////////////////
00430 BOOL CMDIChild::OnSetFocus(HWND hWndPrevFocus)
00431 {
00432   m_pCQueryBox->SetFocus();
00433   return TRUE;
00434 }
00435
00436
00437 /////////////////////////////////////////////////////////////////////
00438 // CMDIChild::OnCommand
00439 //
00440 /////////////////////////////////////////////////////////////////////
00441 BOOL CMDIChild::OnCommand(UINT iID, HWND hWndCtrl)
00442 {
00443   //Get the "this" pointer
00444   CMainWindow*  pCMainWindow  = m_pCMainWindow;
00445   HWND      hWnd      = m_hWnd;
00446   HRESULT hr = S_OK;
00447
00448   //Is there an active object...
00449   CBase*      pCObject      = m_pCMainWindow->m_pCMDIObjects->m_pCObjTree->GetSelectedObject();
00450   CDataAccess*  pCDataAccess    = SOURCE_GETOBJECT(pCObject, CDataAccess);
00451   CRowset*    pCRowset      = SOURCE_GETOBJECT(pCDataAccess, CRowset);
00452   CRow*     pCRow       = SOURCE_GETOBJECT(pCDataAccess, CRow);
00453   CDataset*   pCDataset     = SOURCE_GETOBJECT(pCDataAccess, CDataset);
00454
00455   //Object Types
00456   CBinder*    pCBinder      = SOURCE_GETOBJECT(pCObject, CBinder);
00457   CCommand*   pCCommand     = m_pCCommand;
00458   CSession*   pCSession     = m_pCSession;
00459   CDataSource*  pCDataSource    = m_pCDataSource;
00460   HCHAPTER hChapter = pCRowset ? pCRowset->m_hChapter : NULL;
00461
00462   //Setup the Source info
00463   m_idSource = iID;
00464   m_pCSource = pCObject;
00465
00466   //Most of these commands are "delegates" from CMainWindow, when dealing
00467   //with the ToolBar or Menu for items dealing with MDI children...
00468   switch(iID)
00469   {
00470     case IDM_IDBINFO_GETLITERALINFO:
00471       if(SOURCE_GETINTERFACE(pCObject, IDBInfo))
00472         DisplayDialog(IDD_GETLISTVIEW, hWnd, GetLiteralInfoProc, pCObject, iID);
00473       return TRUE;
00474
00475     case IDM_PROVIDERINFO:
00476       if(pCDataSource)
00477         DisplayDialog(IDD_PROVIDERINFO, hWnd, ProviderInfoProc, pCDataSource, iID);
00478       return TRUE;
00479
00480     case IDM_BROWSE_TABLENAME:
00481       if(m_pCQueryBox->m_hWnd)
00482       {
00483         WCHAR wszBuffer[MAX_QUERY_LEN] = {0};
00484
00485         //Display Common Dialog to obtain TableName...
00486         //This is for providers that use a file for TableName
00487         hr = BrowseOpenFileName(GetAppLite()->m_hInstance, hWnd, L"Browse for TableName", wszBuffer, MAX_QUERY_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0");
00488         if(SUCCEEDED(hr))
00489         {
00490           //Now just need to place this name in the EditBox
00491           //Inserted after the current "caret"
00492           m_pCQueryBox->ReplaceAll(wszBuffer);
00493         }
00494       }
00495       return TRUE;
00496
00497     case IDM_IDBINFO_GETKEYWORDS:
00498       if(pCObject)
00499       {
00500         CWaitCursor waitCursor;
00501         WCHAR* pwszKeywords = NULL;
00502         IDBInfo* pIDBInfo = SOURCE_GETINTERFACE(pCObject, IDBInfo);
00503
00504         //IDBInfo::GetKeywords
00505         if(pIDBInfo)
00506         {
00507           XTEST(hr = pIDBInfo->GetKeywords(&pwszKeywords));
00508           TRACE_METHOD(hr, L"IDBInfo::GetKeywords(&\"%s\")", pwszKeywords);
00509           SAFE_FREE(pwszKeywords);
00510         }
00511       }
00512       return TRUE;
00513
00514     //Create a Session...
00515     case IDM_IDBCREATESESSION_CREATESESSION:
00516       if(pCDataSource)
00517       {
00518         CInterfaceDlg interfaceDlg(IDD_AGGREGATION, L"IDBCreateSession::CreateSession", IID_IOpenRowset);
00519         if(interfaceDlg.DoModal(hWnd) == IDOK)
00520         {
00521           CWaitCursor waitCursor;
00522
00523           //Create a new session (in its own window)
00524           XTEST(hr = pCDataSource->CreateSession(interfaceDlg.GetAggregate(), interfaceDlg.GetSelInterface(), interfaceDlg.ppUnknown()));
00525           if(SUCCEEDED(hr))
00526             m_pCMainWindow->HandleObjectType(pCObject, interfaceDlg.pUnknown(), interfaceDlg.GetSelInterface(), eCSession, 0, NULL, CREATE_NEWWINDOW_IFEXISTS);
00527         }
00528       }
00529       return TRUE;
00530
00531     //IDBDataSourceAdmin
00532     case IDM_IDATASOURCEADMIN_CREATEDATASOURCE:
00533       if(pCDataSource && pCDataSource->m_pIDBDataSourceAdmin)
00534         DisplayDialog(IDD_DATASOURCEADMIN_CREATEDATASOURCE, hWnd, AdminCreateDataSourceProc, pCDataSource, iID);
00535       return TRUE;
00536
00537     case IDM_IDATASOURCEADMIN_DESTROYDATASOURCE:
00538       if(pCDataSource && pCDataSource->m_pIDBDataSourceAdmin)
00539       {
00540         CWaitCursor waitCursor;
00541
00542         //IDBDataSourceAdmin::DestroyDataSource
00543         XTEST(hr = pCDataSource->m_pIDBDataSourceAdmin->DestroyDataSource());
00544         TRACE_METHOD(hr, L"IDBDataSourceAdmin::DestroyDataSource()");
00545       }
00546       return TRUE;
00547
00548     case IDM_IDATASOURCEADMIN_GETCREATIONPROPERTIES:
00549       if(pCDataSource && pCDataSource->m_pIDBDataSourceAdmin)
00550       {
00551         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
00552         sCPropertiesDlg.GetPropertyInfo(hWnd, &DBPROPSET_DBINITALL, IID_IDBDataSourceAdmin, NULL, pCDataSource->m_pIDBDataSourceAdmin);
00553       }
00554       return TRUE;
00555
00556     case IDM_IDATASOURCEADMIN_MODIFYDATASOURCE:
00557       if(pCDataSource && pCDataSource->m_pIDBDataSourceAdmin)
00558       {
00559         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
00560         sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_DBINITALL, IID_IDBDataSourceAdmin, pCDataSource->m_pIDBDataSourceAdmin, NULL, NULL, pCDataSource->m_pIDBDataSourceAdmin);
00561       }
00562       return TRUE;
00563
00564     //IOpenRowset::OpenRowset
00565     case IDM_OPENROWSET:
00566       if(pCSession && pCSession->m_pIOpenRowset)
00567         DisplayDialog(IDD_OPENROWSET, hWnd, OpenRowsetProc, pCSession, iID);
00568       return TRUE;
00569
00570     //IGetDataSource::GetDataSource
00571     case IDM_GETDATASOURCE:
00572       if(pCSession && pCSession->m_pIGetDataSource)
00573       {
00574         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"IGetDataSource::GetDataSource", IID_IDBInitialize);
00575         if(interfaceDlg.DoModal(hWnd) == IDOK)
00576         {
00577           CWaitCursor waitCursor;
00578
00579           //IGetDataSource::GetDataSource
00580           if(SUCCEEDED(hr = pCSession->GetDataSource(interfaceDlg.GetSelInterface(), interfaceDlg.ppUnknown())))
00581             m_pCMainWindow->HandleObjectType(pCSession, interfaceDlg.pUnknown(), interfaceDlg.GetSelInterface(), eCDataSource, 0, NULL, CREATE_FINDWINDOW);
00582         }
00583       }
00584       return TRUE;
00585
00586     //ICommand
00587     case IDM_EXECUTE:
00588         if(pCCommand && pCCommand->m_pICommand)
00589         DisplayDialog(IDD_EXECUTE, hWnd, ExecuteProc, pCCommand, iID);
00590       return TRUE;
00591
00592     case IDM_COMMANDTEXT_EXECUTE:
00593         if(pCCommand && pCCommand->m_pICommandText)
00594         DisplayDialog(IDD_EXECUTE, hWnd, ExecuteProc, pCCommand, iID);
00595       return TRUE;
00596
00597     case IDM_COMMAND_CANCEL:
00598       if(pCCommand && pCCommand->m_pICommand)
00599       {
00600         CWaitCursor waitCursor;
00601
00602         //ICommand::Cancel
00603         XTEST(hr = pCCommand->m_pICommand->Cancel());
00604         TRACE_METHOD(hr, L"ICommand::Cancel()");
00605       }
00606       return TRUE;
00607
00608     case IDM_COMMAND_GETDBSESSION:
00609       if(pCCommand && pCCommand->m_pICommand)
00610       {
00611         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"ICommand::GetDBSession", IID_IOpenRowset);
00612         if(interfaceDlg.DoModal(hWnd) == IDOK)
00613         {
00614           CWaitCursor waitCursor;
00615
00616           //ICommand::GetDBSession
00617           CComPtr<IUnknown> spUnknown;
00618           XTEST(hr = pCCommand->m_pICommand->GetDBSession(interfaceDlg.GetSelInterface(), &spUnknown));
00619           TRACE_METHOD(hr, L"ICommand::GetDBSession(%s, &0x%p)", GetInterfaceName(interfaceDlg.GetSelInterface()), spUnknown);
00620
00621           //Update the Session Object
00622           if(SUCCEEDED(hr))
00623             m_pCMainWindow->HandleObjectType(pCCommand, spUnknown, interfaceDlg.GetSelInterface(), eCSession, 0, NULL, CREATE_FINDWINDOW);
00624         }
00625       }
00626       return TRUE;
00627
00628     ////////////////////////////////////////////////////////////////////////
00629     // IMDDataset
00630     //
00631     ////////////////////////////////////////////////////////////////////////
00632     case IDM_DATASET_GETAXISINFO:
00633         if(pCDataset && pCDataset->m_pIMDDataset)
00634         DisplayDialog(IDD_GETAXISINFO, hWnd, GetAxisInfoProc, pCDataset, iID);
00635       return TRUE;
00636
00637     case IDM_DATASET_GETCELLDATA:
00638         if(pCDataset && pCDataset->m_pIMDDataset)
00639         {
00640         INDEX cRows = 0;
00641         INDEX* rgItems = NULL;
00642         HROW* rghRows = NULL;
00643
00644         //Find all Selected Rows
00645         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
00646         if(cRows == 0)
00647         {
00648           wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONHAND | MB_OK | MB_DEFBUTTON1,
00649             wsz_ERROR, L"Must first select a row...");
00650         }
00651
00652         CWaitCursor waitCursor;
00653
00654         //Display all rows...
00655         for(INDEX i=0; i<cRows; i++)
00656         {
00657           //Display the Data for this row...
00658           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i], MDPROP_AXES, true/*fAlways*/);
00659         }
00660         SAFE_FREE(rgItems);
00661         SAFE_FREE(rghRows);
00662         }
00663         return TRUE;
00664
00665       case IDM_DATASET_GETAXISROWSET:
00666         if(pCDataset && pCDataset->m_pIMDDataset)
00667         DisplayDialog(IDD_GETAXISROWSET, hWnd, GetAxisRowsetProc, pCDataset, iID);
00668       return TRUE;
00669
00670     case IDM_DATASET_FREEAXISINFO:
00671         if(pCDataset && pCDataset->m_pIMDDataset)
00672         pCDataset->FreeAxisInfo(&pCDataset->m_cAxis, &pCDataset->m_rgAxisInfo);
00673       return TRUE;
00674
00675     case IDM_DATASET_GETSPECIFICATION:
00676         if(pCDataset && pCDataset->m_pIMDDataset)
00677       {
00678         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"IMDDataset::GetSpecification", IID_ICommand);
00679         if(interfaceDlg.DoModal(hWnd) == IDOK)
00680         {
00681           CWaitCursor waitCursor;
00682
00683           //IMDDataset::GetSpecification
00684           CComPtr<IUnknown> spUnknown;
00685           XTEST(hr = pCDataset->m_pIMDDataset->GetSpecification(interfaceDlg.GetSelInterface(), &spUnknown));
00686           TRACE_METHOD(hr, L"IMDDataset::GetSpecification(%s, &0x%p)", GetInterfaceName(interfaceDlg.GetSelInterface()), spUnknown);
00687
00688           //What type of object, let our helper determine...
00689           //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
00690           if(SUCCEEDED(hr))
00691             m_pCMainWindow->HandleObjectType(pCDataset, spUnknown, interfaceDlg.GetSelInterface(), eCCommand, 0, NULL, CREATE_FINDWINDOW | CREATE_DETERMINE_TYPE);
00692         }
00693       }
00694       return TRUE;
00695
00696
00697
00698     case IDM_IMULTIPLERESULTS_GETRESULT:
00699     {
00700       CMultipleResultsDlg multipleResultsDlg(this);
00701       multipleResultsDlg.DoModal(hWnd);
00702       return TRUE;
00703     }
00704
00705     case IDM_ITRANSACTION_ABORT:
00706       if(SOURCE_GETINTERFACE(pCObject, ITransaction))
00707         DisplayDialog(IDD_TRANSACTION_ABORT, hWnd, AbortTransactionProc, pCObject, iID);
00708       return TRUE;
00709
00710     case IDM_ITRANSACTION_COMMIT:
00711       if(SOURCE_GETINTERFACE(pCObject, ITransaction))
00712         DisplayDialog(IDD_TRANSACTION_COMMIT, hWnd, CommitTransactionProc, pCObject, iID);
00713       return TRUE;
00714
00715     case IDM_ITRANSACTION_GETTRANSACTIONINFO:
00716       if(SOURCE_GETINTERFACE(pCObject, ITransaction))
00717         DisplayDialog(IDD_TRANSACTION_GETINFO, hWnd, GetTransactionInfo, pCObject, iID);
00718       return TRUE;
00719
00720     case IDM_ITRANSACTIONLOCAL_STARTTRANSACTION:
00721       if(SOURCE_GETINTERFACE(pCObject, ITransactionLocal))
00722         DisplayDialog(IDD_TRANSACTION_START, hWnd, StartTransactionProc, pCObject, iID);
00723       return TRUE;
00724
00725     case IDM_ITRANSACTIONLOCAL_GETOPTIONSOBJECT:
00726     {
00727       ITransactionLocal* pITransactionLocal = SOURCE_GETINTERFACE(pCObject, ITransactionLocal);
00728       if(pITransactionLocal)
00729       {
00730         CWaitCursor waitCursor;
00731         CComPtr<ITransactionOptions>  spTransactionOptions;
00732
00733         //ITransactionLocal::GetOptionsObject
00734         XTEST(hr = pITransactionLocal->GetOptionsObject(&spTransactionOptions));
00735         TRACE_METHOD(hr, L"ITransactionLocal::GetOptionsObject(&0x%p)", spTransactionOptions);
00736
00737         //Delegate
00738         if(SUCCEEDED(hr))
00739           m_pCMainWindow->HandleObjectType(pCObject, spTransactionOptions, IID_ITransactionOptions, eCTransactionOptions, 0, NULL, CREATE_NEWWINDOW_IFEXISTS);
00740       }
00741       return TRUE;
00742     }
00743
00744     case IDM_ITRANSACTIONOBJECT_GETTRANSACTIONOBJECT:
00745     {
00746       ITransactionObject* pITransactionObject = SOURCE_GETINTERFACE(pCObject, ITransactionObject);
00747       if(pITransactionObject)
00748       {
00749         CWaitCursor waitCursor;
00750         CComPtr<ITransaction> spTransaction;
00751
00752         //ITransactionObject::GetTransactionObject
00753         XTEST(hr = pITransactionObject->GetTransactionObject(1, &spTransaction));
00754         TRACE_METHOD(hr, L"ITransactionObject::GetTransactionObject(1, &0x%p)", spTransaction);
00755
00756         //Delegate
00757         if(SUCCEEDED(hr))
00758           m_pCMainWindow->HandleObjectType(pCObject, spTransaction, IID_ITransaction, eCTransaction, 0, NULL, CREATE_NEWWINDOW_IFEXISTS);
00759       }
00760       return TRUE;
00761     }
00762
00763     case IDM_ITRANSACTIONOPTIONS_GETOPTIONS:
00764     {
00765       ITransactionOptions* pITransactionOptions = SOURCE_GETINTERFACE(pCObject, ITransactionOptions);
00766       if(pITransactionOptions)
00767       {
00768         CWaitCursor waitCursor;
00769         XACTOPT XactOptions = {0};
00770
00771         //ITransactionOptions::GetOptions
00772         XTEST(hr = pITransactionOptions->GetOptions(&XactOptions));
00773         TRACE_METHOD(hr, L"ITransactionOptions::GetOptions(%d, \"%s\")", XactOptions.ulTimeout, XactOptions.szDescription);
00774       }
00775       return TRUE;
00776     }
00777
00778     case IDM_ITRANSACTIONOPTIONS_SETOPTIONS:
00779     {
00780       ITransactionOptions* pITransactionOptions = SOURCE_GETINTERFACE(pCObject, ITransactionOptions);
00781       if(pITransactionOptions)
00782         DisplayDialog(IDD_TRANSACTION_SETOPTIONS, hWnd, SetTransactionOptionsProc, pCObject, iID);
00783       return TRUE;
00784     }
00785
00786     case IDM_ITRANSACTIONJOIN_RELEASETRANSACTION:
00787       DisplayDialog(IDD_TRANSACTION_RELEASE, hWnd, ReleaseTransaction, pCObject, iID);
00788       return TRUE;
00789
00790     case IDM_ITRANSACTIONDISPENSOR_BEGINTRANSACTION:
00791       DisplayDialog(IDD_TRANSACTION_START, hWnd, StartTransactionProc, pCObject, iID);
00792       return TRUE;
00793
00794     case IDM_ITRANSACTIONJOIN_GETOPTIONSOBJECT:
00795     {
00796       ITransactionJoin* pITransactionJoin = SOURCE_GETINTERFACE(pCObject, ITransactionJoin);
00797       if(pITransactionJoin)
00798       {
00799         CWaitCursor waitCursor;
00800         CComPtr<ITransactionOptions>  spTransactionOptions;
00801
00802         //ITransactionJoin::GetOptionsObject
00803         XTEST(hr = pITransactionJoin->GetOptionsObject(&spTransactionOptions));
00804         TRACE_METHOD(hr, L"ITransactionJoin::GetOptionsObject(&0x%p)", spTransactionOptions);
00805
00806         //Delegate
00807         if(SUCCEEDED(hr))
00808           m_pCMainWindow->HandleObjectType(pCObject, spTransactionOptions, IID_ITransactionOptions, eCTransactionOptions, 0, NULL, CREATE_NEWWINDOW_IFEXISTS);
00809       }
00810       return TRUE;
00811     }
00812
00813       case IDM_ITRANSACTIONJOIN_JOINTRANSACTION:
00814     {
00815       ITransactionJoin* pITransactionJoin = SOURCE_GETINTERFACE(pCObject, ITransactionJoin);
00816       if(pITransactionJoin)
00817         DisplayDialog(IDD_TRANSACTION_JOIN, hWnd, JoinTransactionProc, pCObject, iID);
00818         return TRUE;
00819     }
00820
00821     case IDM_ICOLUMNSINFO_GETCOLUMNINFO:
00822       if(pCDataAccess && pCDataAccess->m_pIColumnsInfo)
00823         DisplayDialog(IDD_GETLISTVIEW, hWnd, GetColInfoProc, pCDataAccess, iID);
00824       return TRUE;
00825
00826     //ColumnsRowset
00827     case IDM_ICOLUMNSROWSET_GETCOLUMNSROWSET:
00828       if(SOURCE_GETINTERFACE(pCObject, IColumnsRowset))
00829         DisplayDialog(IDD_GETCOLUMNSROWSET, hWnd, GetColumnsRowsetProc, pCObject, iID);
00830       return TRUE;
00831
00832     case IDM_DELETEROWS:
00833       if(pCRowset && pCRowset->m_pIRowsetChange)
00834       {
00835         CWaitCursor waitCursor;
00836         DeleteSelectedRows();
00837       }
00838       return TRUE;
00839
00840     case IDM_SETDATA:
00841       if(pCRowset && pCRowset->m_pIRowsetChange)
00842         ChangeSelectedRow(pCRowset, IDM_SETDATA);
00843       return TRUE;
00844
00845     case IDM_INSERTROW:
00846       if(pCRowset && pCRowset->m_pIRowsetChange)
00847         InsertNewRow();
00848       return TRUE;
00849
00850     case IDM_CLEAREDITWINDOW:
00851       //Select all the Text and Cut it...
00852       //This method allows the text to be undone...
00853       m_pCQueryBox->SetSel(0, -1);
00854       m_pCQueryBox->Cut();
00855       return TRUE;
00856
00857     case IDM_CUTEDITWINDOW:
00858       m_pCQueryBox->Cut();
00859       return TRUE;
00860
00861     case IDM_COPYEDITWINDOW:
00862       m_pCQueryBox->Copy();
00863       return TRUE;
00864
00865     case IDM_PASTEEDITWINDOW:
00866       m_pCQueryBox->Paste();
00867       return TRUE;
00868
00869     case IDM_RESTARTPOSITION:
00870       if(pCRowset && pCRowset->m_pIRowset)
00871         m_pCDataGrid->RestartPosition();
00872       return TRUE;
00873
00874     case IDM_GETNEXTROWS:
00875       if(pCRowset && pCRowset->m_pIRowset)
00876         DisplayDialog(IDD_GETNEXTROWS, hWnd, GetNextRowsProc, pCRowset, iID);
00877       return TRUE;
00878
00879     case IDM_RELEASEROWS:
00880       if(pCRowset && pCRowset->m_pIRowset)
00881         m_pCDataGrid->ReleaseRows(LV_ALLSELITEMS, FALSE/*fOnlyValidRows*/);
00882       return TRUE;
00883
00884     case IDM_ADDREFROWS:
00885       if(pCRowset && pCRowset->m_pIRowset)
00886         m_pCDataGrid->AddRefRows(LV_ALLSELITEMS);
00887       return TRUE;
00888
00889     case IDM_RELEASEALLROWS:
00890       if(pCRowset && pCRowset->m_pIRowset)
00891         m_pCDataGrid->ReleaseRows(LV_ALLITEMS, FALSE/*fOnlyValidRows*/);
00892       return TRUE;
00893
00894     case IDM_GETROWFROMHROW:
00895       if(pCRowset && pCRowset->m_pIGetRow)
00896       {
00897         //Obtain the First selected Row
00898         HROW hRow = NULL;
00899         if(m_pCDataGrid->GetSelectedRow(&hRow) == LVM_ERR)
00900           return TRUE;
00901
00902         CComPtr<IUnknown> spUnknown;
00903         CInterfaceDlg interfaceDlg(IDD_AGGREGATION, L"IGetRow::GetRowFromHROW", IID_IRow);
00904         if(interfaceDlg.DoModal(hWnd) == IDOK)
00905         {
00906           CWaitCursor waitCursor;
00907
00908           //IGetRow::GetRowFromHROW
00909           if(SUCCEEDED(pCRowset->GetRowFromHROW(NULL, hRow, interfaceDlg.GetSelInterface(), &spUnknown)))
00910           {
00911             //Create in new window
00912             CBase* pCObject = m_pCMainWindow->HandleObjectType(pCRowset, spUnknown, interfaceDlg.GetSelInterface(), eCRow, 0, NULL, CREATE_NEWWINDOW | CREATE_NODISPLAY);
00913             if(pCObject)
00914             {
00915               //Fill in which row handle this row was created from...
00916               //Just for display purposes...
00917               CRow* pCRow = SOURCE_GETOBJECT(pCObject, CRow);
00918               if(pCRow)
00919                 pCRow->m_hSourceRow = hRow;
00920
00921               pCObject->DisplayObject();
00922             }
00923           }
00924         }
00925       }
00926       return TRUE;
00927
00928     case IDM_GETURLFROMHROW:
00929       if(pCRowset && pCRowset->m_pIGetRow)
00930       {
00931         CWaitCursor waitCursor;
00932         WCHAR* pwszURL = NULL;
00933
00934         //Obtain the First selected Row
00935         HROW hRow = NULL;
00936         if(m_pCDataGrid->GetSelectedRow(&hRow) == LVM_ERR)
00937           return TRUE;
00938
00939         //IGetRow::GetURLFromHROW
00940         XTEST(hr = pCRowset->m_pIGetRow->GetURLFromHROW(hRow, &pwszURL));
00941         TRACE_METHOD(hr, L"IGetRow::GetURLFromHROW(0x%p, \"%s\")", hRow, pwszURL);
00942
00943         //Update our saved Binding...
00944         if(pCBinder)
00945         {
00946           SAFE_FREE(pCBinder->m_pwszURL);
00947           pCBinder->m_pwszURL = pwszURL;
00948         }
00949       }
00950       return TRUE;
00951
00952     //IRow - methods
00953     case IDM_IROW_GETCOLUMNS:
00954       if(SOURCE_GETINTERFACE(pCObject, IRow))
00955       {
00956         CWaitCursor waitCursor;
00957
00958         //Display the Data for this row...
00959         m_pCDataGrid->DisplayData(0, 1, DBPROP_IRow, true/*fAlways*/);
00960       }
00961       return TRUE;
00962
00963     case IDM_IROW_GETSOURCEROWSET:
00964     {
00965       IRow* pIRow = SOURCE_GETINTERFACE(pCObject, IRow);
00966       if(pIRow)
00967       {
00968         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"IRow::GetSourceRowset", IID_IRowset);
00969         if(interfaceDlg.DoModal(hWnd) == IDOK)
00970         {
00971           CWaitCursor waitCursor;
00972           CComPtr<IUnknown> spUnknown;
00973           HROW hRow = NULL;
00974
00975           //IRow::GetSourceRowset
00976           XTEST(hr = pIRow->GetSourceRowset(interfaceDlg.GetSelInterface(), &spUnknown, &hRow));
00977           TRACE_METHOD(hr, L"IRow::GetSourceRowset(%s, &0x%p, &0x%p)", GetInterfaceName(interfaceDlg.GetSelInterface()), spUnknown, hRow);
00978
00979           //Update the Rowset Object
00980           //NOTE: We don't want to popup a new window if the parent rowset
00981           //is already active in its own window.  We will first try to find the
00982           //parent, otherwise activate a new window...
00983           if(SUCCEEDED(hr))
00984             m_pCMainWindow->HandleObjectType(pCObject, spUnknown, interfaceDlg.GetSelInterface(), eCRowset, 0, NULL, CREATE_FINDWINDOW | CREATE_RESTARTPOSITION);
00985
00986           //Release the Row Handle...
00987           CRowset* pCRowset = SOURCE_GETPARENT(pCObject, CRowset);
00988           if(pCRowset)
00989             pCRowset->ReleaseRows(1, &hRow, NULL);
00990         }
00991       }
00992       return TRUE;
00993     }
00994
00995     case IDM_IDBCREATECOMMAND_CREATECOMMAND:
00996       if(SOURCE_GETINTERFACE(pCObject, IDBCreateCommand))
00997       {
00998         CInterfaceDlg interfaceDlg(IDD_AGGREGATION, L"IDBCreateCommand::CreateCommand", IID_ICommandText);
00999         if(interfaceDlg.DoModal(hWnd) == IDOK)
01000         {
01001           CWaitCursor waitCursor;
01002           CSession* pCSession = SOURCE_GETOBJECT(pCObject, CSession);
01003           CRow* pCRow   = SOURCE_GETOBJECT(pCObject, CRow);
01004           ASSERT(pCSession || pCRow);
01005
01006           //Create a new Command Object (with default properties)
01007           if(pCSession)
01008             hr = pCSession->CreateCommand(interfaceDlg.GetAggregate(), interfaceDlg.GetSelInterface(), interfaceDlg.ppUnknown());
01009           else
01010             hr = pCRow->CreateCommand(interfaceDlg.GetAggregate(), interfaceDlg.GetSelInterface(), interfaceDlg.ppUnknown());
01011
01012           if(SUCCEEDED(hr))
01013             m_pCMainWindow->HandleObjectType(pCObject, interfaceDlg.pUnknown(), interfaceDlg.GetSelInterface(), eCCommand, 0, NULL, CREATE_NEWWINDOW_IFEXISTS);
01014         }
01015       }
01016       return TRUE;
01017
01018       //IRowChange - methods
01019     case IDM_IROW_SETCOLUMNS:
01020       if(pCRow && pCRow->m_pIRowChange)
01021         ChangeSelectedRow(pCRow, IDM_IROW_SETCOLUMNS);
01022       return TRUE;
01023
01024     //IRowSchemaChange - methods
01025     case IDM_IROW_DELETECOLUMNS:
01026       if(pCRow && pCRow->m_pIRowSchemaChange)
01027         ChangeSelectedRow(pCRow, IDM_IROW_DELETECOLUMNS);
01028       return TRUE;
01029
01030     case IDM_IGETSESSION_GETSESSION:
01031     {
01032       IGetSession* pIGetSession = SOURCE_GETINTERFACE(pCObject, IGetSession);
01033       if(pIGetSession)
01034       {
01035         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"IGetSession::GetSession", IID_IOpenRowset);
01036         if(interfaceDlg.DoModal(hWnd) == IDOK)
01037         {
01038           CWaitCursor waitCursor;
01039
01040           //IGetSession::GetSession
01041           CComPtr<IUnknown> spUnknown;
01042           XTEST(hr = pIGetSession->GetSession(interfaceDlg.GetSelInterface(), &spUnknown));
01043           TRACE_METHOD(hr, L"IGetSession::GetSession(%s, &0x%p)", GetInterfaceName(interfaceDlg.GetSelInterface()), spUnknown);
01044
01045           //Update the Session
01046           if(SUCCEEDED(hr))
01047             m_pCMainWindow->HandleObjectType(pCObject, spUnknown, interfaceDlg.GetSelInterface(), eCSession, 0, NULL, CREATE_FINDWINDOW);
01048         }
01049       }
01050       return TRUE;
01051     }
01052
01053     case IDM_IROW_OPEN:
01054       if(SOURCE_GETINTERFACE(pCObject, IRow))
01055         DisplayDialog(IDD_ROW_OPEN, hWnd, RowOpenProc, pCObject, iID);
01056       return TRUE;
01057
01058     case IDM_ISCOPEDOPERATIONS_OPENROWSET:
01059       if(SOURCE_GETINTERFACE(pCObject, IScopedOperations))
01060         DisplayDialog(IDD_OPENROWSET, hWnd, OpenRowsetProc, pCObject, iID);
01061       return TRUE;
01062
01063     case IDM_ISCOPEDOPERATIONS_DELETE:
01064       if(SOURCE_GETINTERFACE(pCObject, IScopedOperations))
01065         DisplayDialog(IDD_ISCO_DELETE, hWnd, ISCO_DeleteProc, pCObject, iID);
01066       return TRUE;
01067
01068     case IDM_ISCOPEDOPERATIONS_COPY:
01069       if(SOURCE_GETINTERFACE(pCObject, IScopedOperations))
01070         DisplayDialog(IDD_ISCO_COPY, hWnd, ISCO_Proc, pCObject, iID);
01071       return TRUE;
01072
01073     case IDM_ISCOPEDOPERATIONS_MOVE:
01074       if(SOURCE_GETINTERFACE(pCObject, IScopedOperations))
01075         DisplayDialog(IDD_ISCO_COPY, hWnd, ISCO_Proc, pCObject, iID);
01076       return TRUE;
01077
01078     case IDM_SETCOMMANDTEXT:
01079       if(pCCommand && pCCommand->m_pICommandText)
01080         DisplayDialog(IDD_SETCOMMANDTEXT, hWnd, SetCommandTextProc, pCCommand, iID);
01081       return TRUE;
01082
01083     case IDM_GETCOMMANDTEXT:
01084       if(pCCommand && pCCommand->m_pICommandText)
01085       {
01086         CWaitCursor waitCursor;
01087
01088         GUID guidDialec = GUID_NULL;
01089         WCHAR wszBuffer[MAX_NAME_LEN+1] = {0};
01090         WCHAR* pwszDialect = NULL;
01091         WCHAR* pwszBuffer = NULL;
01092
01093         XTEST(hr = pCCommand->m_pICommandText->GetCommandText(&guidDialec, &pwszBuffer));
01094
01095         //Try to find a string respentation of the guidDialec
01096         if(!(pwszDialect = GetDialectName(guidDialec)))
01097         {
01098           pwszDialect = wszBuffer;
01099           StringFromGUID2(guidDialec, wszBuffer, MAX_NAME_LEN);
01100         }
01101
01102         TRACE_METHOD(hr, L"ICommandText::GetCommandText(&%s, &\"%s\")", pwszDialect, pwszBuffer);
01103         SAFE_FREE(pwszBuffer);
01104       }
01105       return TRUE;
01106
01107     case IDM_SETCOMMANDSTREAM:
01108       if(pCCommand && pCCommand->m_pICommandStream)
01109         DisplayDialog(IDD_SETCOMMANDSTREAM, hWnd, SetCommandTextProc, pCCommand, iID);
01110       return TRUE;
01111
01112     case IDM_GETCOMMANDSTREAM:
01113       if(pCCommand && pCCommand->m_pICommandStream)
01114       {
01115         CWaitCursor waitCursor;
01116
01117         GUID guidDialec = GUID_NULL;
01118         IID  iid = IID_NULL;
01119         CComPtr<IUnknown> spUnknown;
01120         WCHAR wszBuffer[MAX_NAME_LEN+1] = {0};
01121         WCHAR* pwszDialect = NULL;
01122
01123         //ICommandStream::GetCommandStream
01124         XTEST(hr = pCCommand->m_pICommandStream->GetCommandStream(&iid, &guidDialec, (IUnknown**)&spUnknown));
01125
01126         //Try to find a string respentation of the guidDialec
01127         if(!(pwszDialect = GetDialectName(guidDialec)))
01128         {
01129           pwszDialect = wszBuffer;
01130           StringFromGUID2(guidDialec, wszBuffer, MAX_NAME_LEN);
01131         }
01132         TRACE_METHOD(hr, L"ICommandStream::GetCommandStream(&%s, &%s, &0x%p)", GetInterfaceName(iid), pwszDialect, spUnknown);
01133
01134         //Stand Alone Object (no window required)
01135         if(SUCCEEDED(hr))
01136         {
01137           CStream* pCStream = new CStream(m_pCMainWindow);
01138           pCStream->CreateObject(pCCommand, iid, spUnknown);
01139         }
01140       }
01141       return TRUE;
01142
01143     case IDM_COMMANDPERSIST_GETCURRENTCOMMAND:
01144       if(pCCommand && pCCommand->m_pICommandPersist)
01145       {
01146         CWaitCursor waitCursor;
01147         DBID* pCommandID = NULL;
01148
01149         //ICommandPersist::GetCurrentCommand
01150         XTEST(pCCommand->GetCurrentCommand(&pCommandID));
01151
01152         DBIDFree(pCommandID);
01153         SAFE_FREE(pCommandID);
01154       }
01155       return TRUE;
01156
01157     case IDM_COMMANDPERSIST_DELETECOMMAND:
01158     case IDM_COMMANDPERSIST_LOADCOMMAND:
01159     case IDM_COMMANDPERSIST_SAVECOMMAND:
01160       if(pCCommand && pCCommand->m_pICommandPersist)
01161         DisplayDialog(IDD_COMMANDPERSIST, hWnd, CommandPersistProc, pCCommand, iID);
01162       return TRUE;
01163
01164     case IDM_COMMANDPREPARE:
01165       if(pCCommand && pCCommand->m_pICommandPrepare)
01166       {
01167         CWaitCursor waitCursor;
01168
01169         //ICommand::Prepare
01170         XTEST(hr = pCCommand->Prepare(0));
01171       }
01172       return TRUE;
01173
01174     case IDM_COMMANDUNPREPARE:
01175       if(pCCommand && pCCommand->m_pICommandPrepare)
01176       {
01177         CWaitCursor waitCursor;
01178
01179         //ICommand::Unprepare
01180         XTEST(hr = pCCommand->m_pICommandPrepare->Unprepare());
01181         TRACE_METHOD(hr, L"ICommandPrepare::Unprepare()");
01182       }
01183       return TRUE;
01184
01185     case IDM_GETSCHEMAS:
01186     case IDM_GETSCHEMAROWSET:
01187       if(pCSession && pCSession->m_pIDBSchemaRowset)
01188       {
01189         CSchemaDlg  schemaDlg(this);
01190         schemaDlg.Display();
01191       }
01192       return TRUE;
01193
01194     case IDM_ISESSIONPROPERTIES_GETPROPERTIES:
01195       if(pCSession && pCSession->m_pISessionProperties)
01196       {
01197         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
01198         sCPropertiesDlg.GetProperties(hWnd, &DBPROPSET_SESSIONALL, IID_ISessionProperties, pCSession->m_pISessionProperties, pCDataSource ? pCDataSource->m_pIDBProperties : NULL);
01199       }
01200       return TRUE;
01201
01202     case IDM_COMMAND_GETPROPERTIES:
01203       if(pCCommand && pCCommand->m_pICommandProperties)
01204       {
01205         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
01206         sCPropertiesDlg.GetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_ICommandProperties, pCCommand->m_pICommandProperties, pCDataSource ? pCDataSource->m_pIDBProperties : NULL);
01207       }
01208       return TRUE;
01209
01210     case IDM_IROWSET_GETPROPERTIES:
01211       if(pCRowset && pCRowset->m_pIRowsetInfo)
01212       {
01213         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
01214         sCPropertiesDlg.GetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_IRowsetInfo, pCRowset->m_pIRowsetInfo, pCDataSource ? pCDataSource->m_pIDBProperties : NULL);
01215       }
01216       return TRUE;
01217
01218     //IRowsetInfo
01219     case IDM_GETSPECIFICATION:
01220       if(pCRowset && pCRowset->m_pIRowsetInfo)
01221       {
01222         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"IRowsetInfo::GetSpecification", IID_IOpenRowset);
01223         if(interfaceDlg.DoModal(hWnd) == IDOK)
01224         {
01225           CWaitCursor waitCursor;
01226
01227           //IRowset::GetSpecification
01228           CComPtr<IUnknown> spUnknown;
01229           XTEST(hr = pCRowset->m_pIRowsetInfo->GetSpecification(interfaceDlg.GetSelInterface(), &spUnknown));
01230           TRACE_METHOD(hr, L"IRowset::GetSpecification(%s, &0x%p)", GetInterfaceName(interfaceDlg.GetSelInterface()), spUnknown);
01231
01232           //What type of object, let our helper determine...
01233           //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
01234           if(SUCCEEDED(hr))
01235             m_pCMainWindow->HandleObjectType(pCRowset, spUnknown, interfaceDlg.GetSelInterface(), eCSession, 0, NULL, CREATE_FINDWINDOW | CREATE_DETERMINE_TYPE);
01236         }
01237       }
01238       return TRUE;
01239
01240     case IDM_GETREFERENCEDROWSET:
01241       if(pCRowset && pCRowset->m_pIRowsetInfo)
01242         DisplayDialog(IDD_GETREFERENCEDROWSET, hWnd, GetReferencedRowsetProc, pCRowset, iID);
01243       return TRUE;
01244
01245     case IDM_ISESSIONPROPERTIES_SETPROPERTIES:
01246       if(pCSession && pCSession->m_pISessionProperties)
01247       {
01248         pCDataSource = SOURCE_GETPARENT(pCSession, CDataSource);
01249
01250         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
01251         sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_SESSIONALL, IID_ISessionProperties, pCSession->m_pISessionProperties, pCDataSource ? pCDataSource->m_pIDBProperties : NULL);
01252       }
01253       return TRUE;
01254
01255     case IDM_COMMAND_SETPROPERTIES:
01256       if(pCCommand && pCCommand->m_pICommandProperties)
01257       {
01258         pCDataSource = SOURCE_GETPARENT(pCCommand, CDataSource);
01259
01260         CPropertiesDlg sCPropertiesDlg(pCMainWindow);
01261         sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_ICommandProperties, pCCommand->m_pICommandProperties, pCDataSource ? pCDataSource->m_pIDBProperties : NULL);
01262       }
01263       return TRUE;
01264
01265     case IDM_COMMAND_CLEARCOMMAND:
01266       if(pCCommand && pCSession && pCCommand->m_pIUnknown)
01267       {
01268         CWaitCursor waitCursor;
01269         CComPtr<ICommand> spCommand;
01270
01271         //A little more difficult than ROWSET_CLEARPROPERTIES
01272         //Since any properties set on a command object are set,
01273         //the only way to remove them is to either try and set them
01274         //to the opposite value, or create a new command object...
01275
01276         //Create a new command
01277         //And then re-create our object with the new command (with no properties)...
01278         pCSession->CreateCommand(NULL, IID_ICommand, (IUnknown**)&spCommand);
01279         pCCommand->CreateObject(pCSession, IID_ICommand, spCommand);
01280       }
01281       return TRUE;
01282
01283     ///////////////////////////////////////////////////////////////////
01284     // IConvertType
01285     //
01286     ///////////////////////////////////////////////////////////////////
01287     case IDM_ICONVERTTYPE_CANCONVERT:
01288       if(pCDataAccess->m_pIConvertType)
01289         DisplayDialog(IDD_CANCONVERT, hWnd, CanConvertProc, pCDataAccess, iID);
01290       return TRUE;
01291
01292
01293     ///////////////////////////////////////////////////////////////////
01294     // IAccessor
01295     //
01296     ///////////////////////////////////////////////////////////////////
01297     case IDM_IACCESSOR_GETBINDINGS:
01298       if(pCDataAccess && pCDataAccess->m_pIAccessor)
01299         DisplayDialog(IDD_GETLISTVIEW, hWnd, GetBindingsProc, pCDataAccess, iID);
01300       return TRUE;
01301
01302     case IDM_IACCESSOR_ADDREFACCESSOR:
01303       if(pCDataAccess && pCDataAccess->m_pIAccessor)
01304       {
01305         CWaitCursor waitCursor;
01306
01307         //IAccessor::AddRefAccessor
01308         pCDataAccess->AddRefAccessor(pCDataAccess->m_hAccessor);
01309       }
01310       return TRUE;
01311
01312     case IDM_IACCESSOR_CREATEACCESSOR:
01313       if(pCDataAccess && pCDataAccess->m_pIAccessor)
01314         DisplayDialog(IDD_CREATEACCESSOR, hWnd, CreateAccessorProc, pCDataAccess, iID);
01315       return TRUE;
01316
01317     case IDM_IACCESSOR_RELEASEACCESSOR:
01318       if(pCDataAccess && pCDataAccess->m_pIAccessor)
01319         pCDataAccess->ReleaseAccessor(&pCDataAccess->m_hAccessor, TRUE/*fReleaseAlways*/);
01320       return TRUE;
01321
01322
01323     //ITableDefinition
01324     case IDM_TABLE_CREATETABLE:
01325       if(pCSession && pCSession->m_pITableDefinition)
01326         DisplayDialog(IDD_CREATETABLE, hWnd, CreateTableProc, pCSession, iID);
01327       return TRUE;
01328
01329     case IDM_TABLE_ADDCOLUMN:
01330       if(pCSession && pCSession->m_pITableDefinition)
01331         DisplayDialog(IDD_ADDCOLUMN, hWnd, AddColumnProc, pCSession, iID);
01332       return TRUE;
01333
01334     case IDM_TABLE_DROPCOLUMN:
01335       if(pCSession && pCSession->m_pITableDefinition)
01336         DisplayDialog(IDD_DROPCOLUMN, hWnd, DropColumnProc, pCSession, iID);
01337       return TRUE;
01338
01339     case IDM_TABLE_DROPTABLE:
01340       if(pCSession && pCSession->m_pITableDefinition)
01341         DisplayDialog(IDD_DROPTABLE, hWnd, DropTableProc, pCSession, iID);
01342       return TRUE;
01343
01344     //ITableDefinitionWithConstraints
01345     case IDM_TABLE_CREATETABLEWITHCONSTRAINTS:
01346 //      if(pCSession && pCSession->m_pITableDefinitionWithConstraints)
01347 //        DisplayDialog(IDD_CREATETABLE, hWnd, CreateTableProc, pCSession, iID);
01348       return TRUE;
01349
01350     case IDM_TABLE_ADDCONSTRAINT:
01351       if(pCSession && pCSession->m_pITableDefinitionWithConstraints)
01352       {
01353         CWaitCursor waitCursor;
01354         DBORDINAL     cConsDesc = 1;
01355         DBCONSTRAINTDESC  ConsDesc;
01356         DBCONSTRAINTDESC* rgConsDesc = &ConsDesc;
01357         DBID        TableID;
01358         WCHAR       *pwszTableName = NULL;
01359         CConstraintDlg    ConsDlg(pCMainWindow);
01360
01361         memset(&ConsDesc, 0, sizeof(DBCONSTRAINTDESC));
01362
01363         if (S_OK == ConsDlg.SetConstraintAndTable(hWnd, &ConsDesc, &pwszTableName))
01364         {
01365           TableID.eKind = DBKIND_NAME;
01366           TableID.uName.pwszName = pwszTableName;
01367           XTEST(hr = pCSession->m_pITableDefinitionWithConstraints->AddConstraint(&TableID, &ConsDesc));
01368
01369           TRACE_METHOD(hr, L"ITableDefinitionWithConstraints::AddConstraint(&%s, \"%p\")", pwszTableName, &ConsDesc);
01370         }
01371         SAFE_FREE(pwszTableName);
01372         FreeConstraintDesc(&cConsDesc, &rgConsDesc, FALSE);
01373
01374       }
01375       return TRUE;
01376
01377     case IDM_TABLE_DROPCONSTRAINT:
01378       if(pCSession && pCSession->m_pITableDefinitionWithConstraints)
01379         DisplayDialog(IDD_DROPCONSTRAINT, hWnd, DropConstraintProc, pCSession, iID);
01380       return TRUE;
01381
01382     //IIndexDefinition
01383     case IDM_INDEX_CREATEINDEX:
01384       if(pCSession && pCSession->m_pIIndexDefinition)
01385         DisplayDialog(IDD_CREATEINDEX, hWnd, CreateIndexProc, pCSession, iID);
01386       return TRUE;
01387
01388     case IDM_INDEX_DROPINDEX:
01389       if(pCSession && pCSession->m_pIIndexDefinition)
01390         DisplayDialog(IDD_DROPINDEX, hWnd, DropIndexProc, pCSession, iID);
01391       return TRUE;
01392
01393     // IAlterIndex
01394     case IDM_INDEX_ALTERINDEX:
01395       if(pCSession && pCSession->m_pIAlterIndex)
01396       {
01397         CWaitCursor   waitCursor;
01398         CAlterIndexDlg  AlterIndexDlg(this);
01399         DBID      *pTableID   = NULL;
01400         DBID      *pIndexID   = NULL;
01401         DBID      *pNewIndexID  = NULL;
01402         BOOL      fUseIndexProps  = FALSE;
01403         ULONG     cPropSets   = 0;
01404         DBPROPSET*    rgPropSets    = NULL;
01405
01406         // get index updates
01407         if (S_OK == AlterIndexDlg.AlterIndex(hWnd, &pTableID, &pIndexID, &pNewIndexID,
01408           &fUseIndexProps))
01409         {
01410           //alter the index
01411           if (fUseIndexProps)
01412           {
01413             cPropSets = AlterIndexDlg.m_CPropSets.GetCount();
01414             rgPropSets  = AlterIndexDlg.m_CPropSets.GetPropSets();
01415           }
01416
01417           XTEST(hr = pCSession->m_pIAlterIndex->AlterIndex(pTableID, pIndexID,
01418             pNewIndexID, cPropSets, rgPropSets));
01419
01420           TRACE_METHOD(hr, L"IAlterIndex::AlterIndex(&%p, &%p, &%p, %d, %p)",
01421             pTableID, pIndexID, pNewIndexID, cPropSets, rgPropSets);
01422         }
01423
01424         DBIDFree(pTableID);
01425         SAFE_FREE(pTableID);
01426         DBIDFree(pIndexID);
01427         SAFE_FREE(pIndexID);
01428         DBIDFree(pNewIndexID);
01429         SAFE_FREE(pNewIndexID);
01430       }
01431       return TRUE;
01432
01433
01434     // IAlterTable
01435     case IDM_TABLE_ALTERTABLE:
01436       if(pCSession && pCSession->m_pIAlterTable)
01437       {
01438         CWaitCursor   waitCursor;
01439         CAlterTableDlg  AlterTableDlg(this);
01440         ULONG     cPropSets   = 0;
01441         DBPROPSET*    rgPropSets    = NULL;
01442
01443         // get table updates
01444         if (S_OK == AlterTableDlg.AlterTable(hWnd))
01445         {
01446           //alter table
01447           if (AlterTableDlg.m_fUseTableProps)
01448           {
01449             cPropSets = AlterTableDlg.m_CPropSets.GetCount();
01450             rgPropSets  = AlterTableDlg.m_CPropSets.GetPropSets();
01451           }
01452
01453           XTEST(hr = pCSession->m_pIAlterTable->AlterTable(
01454             AlterTableDlg.m_pTableID,
01455             AlterTableDlg.m_pNewTableID,
01456             cPropSets,
01457             rgPropSets));
01458
01459           TRACE_METHOD(hr, L"IAlterTable::AlterTable(&%p, &%p, %d, %p)",
01460             AlterTableDlg.m_pTableID, AlterTableDlg.m_pNewTableID, cPropSets, rgPropSets);
01461         }
01462       }
01463       return TRUE;
01464
01465     case IDM_TABLE_ALTERCOLUMN:
01466       if(pCSession && pCSession->m_pIAlterTable)
01467       {
01468         CWaitCursor   waitCursor;
01469         CAlterColumnDlg AlterColumnDlg(this);
01470
01471         // get table updates
01472         if (S_OK == AlterColumnDlg.AlterColumn(hWnd))
01473         {
01474           //alter column
01475           XTEST(hr = pCSession->m_pIAlterTable->AlterColumn(
01476             AlterColumnDlg.m_pTableID,
01477             AlterColumnDlg.m_pColumnID,
01478             AlterColumnDlg.m_dwColFlags,
01479             &AlterColumnDlg.m_ColDesc));
01480
01481           TRACE_METHOD(hr, L"IAlterTable::AlterColumn(&%p, &%p, %d, %p)",
01482             AlterColumnDlg.m_pTableID, AlterColumnDlg.m_pColumnID,
01483             AlterColumnDlg.m_dwColFlags, &AlterColumnDlg.m_ColDesc);
01484         }
01485       }
01486       return TRUE;
01487
01488
01489     //IRowsetIdentity
01490     case IDM_IROWSETINDENTITY_ISSAMEROW:
01491       if(pCRowset && pCRowset->m_pIRowsetIdentity)
01492       {
01493         CWaitCursor waitCursor;
01494
01495         //Obtain the First selected Row
01496         INDEX iSelRow   = m_pCDataGrid->GetSelectedRow(NULL, FALSE);
01497         HROW hRow1      = m_pCDataGrid->GetItemParam(iSelRow);
01498
01499         //Obtain the Second selected Row
01500         INDEX iSelRow2    = m_pCDataGrid->GetNextItem(iSelRow, LVNI_SELECTED);
01501         HROW hRow2      = m_pCDataGrid->GetItemParam(iSelRow2 != LVM_ERR ? iSelRow2 : iSelRow);
01502
01503         //IRowsetIdentity::IsSameRow
01504         XTEST(hr = pCRowset->m_pIRowsetIdentity->IsSameRow(hRow1, hRow2));
01505         TRACE_METHOD(hr, L"IRowsetIdentity::IsSameRow(0x%p, 0x%p)", hRow1, hRow2);
01506       }
01507       return TRUE;
01508
01509
01510     //IRowsetScroll
01511     case IDM_IROWSETSCROLL_GETAPPROXIMATEPOSITION:
01512       if(pCRowset && pCRowset->m_pIRowsetScroll)
01513       {
01514         CWaitCursor waitCursor;
01515         DBBKMARK cbBookmark = 0;
01516         BYTE* pBookmark = NULL;
01517         DBCOUNTITEM ulPosition = 0;
01518         DBCOUNTITEM cRows = 0;
01519         HROW  hRow = NULL;
01520
01521         //Obtain the bookmark for the selected row...
01522         if(m_pCDataGrid->GetSelectedRow(&hRow, FALSE)!=LVM_ERR)
01523           hr = pCRowset->GetBookmark(hRow, &cbBookmark, &pBookmark);
01524
01525         //IRowsetScroll::GetApproximatePosition
01526         XTEST(hr = pCRowset->m_pIRowsetScroll->GetApproximatePosition(hChapter, cbBookmark, pBookmark, &ulPosition, &cRows));
01527         TRACE_METHOD(hr, L"IRowsetScroll::GetApproximatePosition(0x%p, %lu, 0x%p, &%lu, &%lu)", hChapter, cbBookmark, pBookmark, ulPosition, cRows);
01528
01529         //Cleanup
01530         SAFE_FREE(pBookmark);
01531       }
01532       return TRUE;
01533
01534
01535     //IRowsetLocate
01536     case IDM_IROWSETLOCATE_COMPARE:
01537       if(pCRowset && pCRowset->m_pIRowsetLocate)
01538       {
01539         CWaitCursor waitCursor;
01540
01541         HROW  rghRows[2] = {NULL, NULL};
01542         DBBKMARK rgcbBookmarks[2] = {0, 0};
01543         const BYTE* rgpBookmarks[2] = {NULL, NULL};
01544         DBCOMPARE dwComparison = 0;
01545
01546         //Obtain the First selected Row
01547         INDEX iSelRow   = m_pCDataGrid->GetSelectedRow(NULL, FALSE);
01548         rghRows[0]      = m_pCDataGrid->GetItemParam(iSelRow);
01549
01550         //Obtain the Second selected Row
01551         INDEX iSelRow2    = m_pCDataGrid->GetNextItem(iSelRow, LVNI_SELECTED);
01552         rghRows[1]      = m_pCDataGrid->GetItemParam(iSelRow2 != LVM_ERR ? iSelRow2 : iSelRow);
01553
01554         //Obtain the bookmark(s) for the selected row(s)...
01555         if(iSelRow!=LVM_ERR)
01556         {
01557           hr = pCRowset->GetBookmark(rghRows[0], &rgcbBookmarks[0], (BYTE**)&rgpBookmarks[0]);
01558           hr = pCRowset->GetBookmark(rghRows[1], &rgcbBookmarks[1], (BYTE**)&rgpBookmarks[1]);
01559         }
01560
01561         //IRowsetLocate::Compare
01562         XTEST(hr = pCRowset->m_pIRowsetLocate->Compare(hChapter, rgcbBookmarks[0], rgpBookmarks[0], rgcbBookmarks[1], rgpBookmarks[1], &dwComparison));
01563         TRACE_METHOD(hr, L"IRowsetLocate::Compare(0x%p, %lu, 0x%p, %lu, 0x%p, &%d)", hChapter, rgcbBookmarks[0], rgpBookmarks[0], rgcbBookmarks[1], rgpBookmarks[1], dwComparison);
01564
01565         //Cleanup
01566         CoTaskMemFree((void*)rgpBookmarks[0]);
01567         CoTaskMemFree((void*)rgpBookmarks[1]);
01568       }
01569       return TRUE;
01570
01571     case IDM_IROWSETLOCATE_HASH:
01572       if(pCRowset && pCRowset->m_pIRowsetLocate)
01573       {
01574         CWaitCursor waitCursor;
01575
01576         INDEX cRows = 0;
01577         HROW* rghRows = NULL;
01578         DBBKMARK rgcbBookmarks[MAX_OPENROWS+1];
01579         const BYTE* rgpBookmarks[MAX_OPENROWS+1];
01580         DBHASHVALUE rgHashedValues[MAX_OPENROWS+1];
01581         DBROWSTATUS rgBookmarkStatus[MAX_OPENROWS+1];
01582
01583         //Obtain all Selected Rows
01584         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, NULL, (LPARAM**)&rghRows);
01585         cRows = min(cRows, MAX_OPENROWS);
01586
01587         //Obtain the bookmark(s) for the selected row(s)...
01588         for(INDEX i=0; i<cRows; i++)
01589         {
01590           hr = pCRowset->GetBookmark(rghRows[i], &rgcbBookmarks[i], (BYTE**)&rgpBookmarks[i]);
01591         }
01592
01593         //IRowsetLocate::Hash
01594         XTEST(hr = pCRowset->m_pIRowsetLocate->Hash(hChapter, cRows, rgcbBookmarks, rgpBookmarks, rgHashedValues, rgBookmarkStatus));
01595         TRACE_METHOD(hr, L"IRowsetLocate::Hash(0x%p, %lu, 0x%p, 0x%p, 0x%p, 0x%p)", hChapter, cRows, rgcbBookmarks, rgpBookmarks, rgHashedValues, rgBookmarkStatus);
01596
01597         //Cleanup
01598         SAFE_FREE(rghRows);
01599         for(i=0; i<cRows; i++)
01600           CoTaskMemFree((void*)rgpBookmarks[i]);
01601       }
01602       return TRUE;
01603
01604     case IDM_IROWSETLOCATE_GETROWSBYBOOKMARK:
01605       if(pCRowset && pCRowset->m_pIRowsetLocate)
01606       {
01607         CWaitCursor waitCursor;
01608
01609         INDEX cSelItems = 0;
01610         INDEX* rgSelItems = 0;
01611         HROW* rghRows = NULL;
01612         DBBKMARK rgcbBookmarks[MAX_OPENROWS+1];
01613         const BYTE* rgpBookmarks[MAX_OPENROWS+1];
01614         DBROWSTATUS rgRowStatus[MAX_OPENROWS+1];
01615
01616         //Obtain all Selected Rows
01617         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cSelItems, &rgSelItems, (LPARAM**)&rghRows);
01618         cSelItems = min(cSelItems, MAX_OPENROWS);
01619
01620         //Obtain the bookmark(s) for the selected row(s)...
01621         for(INDEX i=0; i<cSelItems; i++)
01622           hr = pCRowset->GetBookmark(rghRows[i], &rgcbBookmarks[i], (BYTE**)&rgpBookmarks[i]);
01623
01624         //Release previously fetched rows, (if user requested)
01625         hr = m_pCDataGrid->ReleaseHeldRows();
01626
01627         //IRowsetLocate::GetRowsByBookmark
01628         XTEST(hr = pCRowset->m_pIRowsetLocate->GetRowsByBookmark(hChapter, cSelItems, rgcbBookmarks, rgpBookmarks, rghRows, rgRowStatus));
01629         TRACE_METHOD(hr, L"IRowsetLocate::GetRowsByBookmark(0x%p, %lu, 0x%p, 0x%p, 0x%p, 0x%p)", hChapter, cSelItems, rgcbBookmarks, rgpBookmarks, rghRows, rgRowStatus);
01630
01631         //Display the data rows retrieved...
01632         for(i=0; i<cSelItems; i++)
01633         {
01634           //Some rows might have not been successfully retrived,
01635           //According to the spec, this is denoted with a NULL hRow
01636           if(rghRows[i])
01637             m_pCDataGrid->DisplayData(rghRows[i], rgSelItems[i]);
01638         }
01639
01640         //Cleanup
01641         for(i=0; i<cSelItems; i++)
01642           CoTaskMemFree((void*)rgpBookmarks[i]);
01643         SAFE_FREE(rghRows);
01644         SAFE_FREE(rgSelItems);
01645       }
01646       return TRUE;
01647
01648     case IDM_IROWSETBOOKMARK_POSITIONONBOOKMARK:
01649       if(pCRowset && pCRowset->m_pIRowsetBookmark)
01650       {
01651         CWaitCursor waitCursor;
01652
01653         HROW  hRow = NULL;
01654         DBBKMARK cbBookmark = 0;
01655         const BYTE* pBookmark = NULL;
01656
01657         //Obtain the first selected row...
01658         INDEX iSelRow = m_pCDataGrid->GetSelectedRow(&hRow, FALSE);
01659         if(iSelRow != LVM_ERR && hRow)
01660         {
01661           //Obtain the bookmark
01662           if(SUCCEEDED(hr = pCRowset->GetBookmark(hRow, &cbBookmark, (BYTE**)&pBookmark)))
01663           {
01664             //IRowsetBookmark::PositionOnBookmark
01665             XTEST(hr = pCRowset->m_pIRowsetBookmark->PositionOnBookmark(hChapter, cbBookmark, pBookmark));
01666             TRACE_METHOD(hr, L"IRowsetBookmark::PositionOnBookmark(0x%p, %lu, 0x%p)", hChapter, cbBookmark, pBookmark);
01667
01668             //Move the NFP indicator...
01669             if(SUCCEEDED(hr))
01670             {
01671               //Display the new Fetch Position indicator...
01672               m_pCDataGrid->DisplayFetchPosition(iSelRow, TRUE/*fLastFetchForward*/);
01673             }
01674           }
01675         }
01676
01677         //Cleanup
01678         SAFE_FREE(pBookmark);
01679       }
01680       return TRUE;
01681
01682     case IDM_IROWSETLOCATE_GETROWSAT:
01683       if(pCRowset && pCRowset->m_pIRowsetLocate)
01684         DisplayDialog(IDD_GETNEXTROWS, hWnd, GetNextRowsProc, pCRowset, iID);
01685       return TRUE;
01686
01687     //IRowsetFind
01688     case IDM_IROWSETFIND_FINDNEXTROW:
01689       if(pCRowset && pCRowset->m_pIRowsetFind)
01690         DisplayDialog(IDD_FINDNEXTROW, hWnd, FindNextRowProc, pCRowset, iID);
01691       return TRUE;
01692
01693
01694     //CommandWithParameters
01695     case IDM_MAPPARAMETERNAMES:
01696       return TRUE;
01697
01698     case IDM_SETPARAMETERINFO:
01699       if(pCCommand && pCCommand->m_pICommandWithParameters)
01700         DisplayDialog(IDD_SETPARAMETERINFO, hWnd, SetParameterInfoProc, pCCommand, iID);
01701       return TRUE;
01702
01703     case IDM_GETPARAMETERINFO:
01704       if(pCCommand && pCCommand->m_pICommandWithParameters)
01705         DisplayDialog(IDD_GETLISTVIEW, hWnd, GetParameterInfoProc, pCCommand, iID);
01706       return TRUE;
01707
01708     case IDM_IPERSIST_GETCLASSID:
01709       if(pCDataSource && pCDataSource->m_pIPersist)
01710       {
01711         CLSID clsid;
01712         pCDataSource->GetClassID(&clsid);
01713       }
01714       return TRUE;
01715
01716     case IDM_IPERSISTFILE_LOAD:
01717       if(pCDataSource && pCDataSource->m_pIPersistFile)
01718       {
01719         WCHAR wszBuffer[MAX_QUERY_LEN] = {0};
01720
01721         //Display Common Dialog to obtain File To Load...
01722         hr = BrowseOpenFileName(GetAppLite()->m_hInstance, hWnd, L"IPersistFile::Load", wszBuffer, MAX_QUERY_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0");
01723         if(SUCCEEDED(hr))
01724         {
01725           CWaitCursor waitCursor;
01726
01727           //IPersistFile::Load
01728           XTEST(hr = pCDataSource->m_pIPersistFile->Load(wszBuffer, STGM_READ));
01729           TRACE_METHOD(hr, L"IPersistFile::Load(\"%s\", STGM_READ)", wszBuffer);
01730         }
01731       }
01732       return TRUE;
01733
01734     case IDM_IPERSISTFILE_SAVE:
01735       if(pCDataSource && pCDataSource->m_pIPersistFile)
01736       {
01737         WCHAR wszBuffer[MAX_QUERY_LEN] = {0};
01738
01739         //Display Common Dialog to obtain File To Save...
01740         hr = BrowseSaveFileName(GetAppLite()->m_hInstance, hWnd, L"IPersistFile::Save", wszBuffer, MAX_QUERY_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0");
01741         if(SUCCEEDED(hr))
01742         {
01743           CWaitCursor waitCursor;
01744
01745           //IPersistFile::Save
01746           XTEST(hr = pCDataSource->m_pIPersistFile->Save(wszBuffer, TRUE));
01747           TRACE_METHOD(hr, L"IPersistFile::Save(\"%s\", TRUE)", wszBuffer);
01748         }
01749       }
01750       return TRUE;
01751
01752     case IDM_IPERSISTFILE_SAVECOMPLETED:
01753       if(pCDataSource && pCDataSource->m_pIPersistFile)
01754       {
01755         WCHAR wszBuffer[MAX_QUERY_LEN] = {0};
01756
01757         //Display Common Dialog to obtain File To Save...
01758         hr = BrowseSaveFileName(GetAppLite()->m_hInstance, hWnd, L"IPersistFile::SaveCompleted", wszBuffer, MAX_QUERY_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0");
01759         if(SUCCEEDED(hr))
01760         {
01761           CWaitCursor waitCursor;
01762
01763           //IPersistFile::Save
01764           XTEST(hr = pCDataSource->m_pIPersistFile->SaveCompleted(wszBuffer));
01765           TRACE_METHOD(hr, L"IPersistFile::SaveCompleted(\"%s\")", wszBuffer);
01766         }
01767       }
01768       return TRUE;
01769
01770     case IDM_IPERSISTFILE_GETCURFILE:
01771       if(pCDataSource && pCDataSource->m_pIPersistFile)
01772       {
01773         CWaitCursor waitCursor;
01774         WCHAR* pwszFileName = NULL;
01775
01776         //IPersistFile::GetCurFile
01777         XTEST(hr = pCDataSource->m_pIPersistFile->GetCurFile(&pwszFileName));
01778         TRACE_METHOD(hr, L"IPersistFile::GetCurFile(\"%s\")", pwszFileName);
01779       }
01780       return TRUE;
01781
01782     case IDM_IPERSISTFILE_ISDIRTY:
01783       if(pCDataSource && pCDataSource->m_pIPersistFile)
01784       {
01785         CWaitCursor waitCursor;
01786
01787         //IPersistFile::IsDirty
01788         XTEST(hr = pCDataSource->m_pIPersistFile->IsDirty());
01789         TRACE_METHOD(hr, L"IPersistFile::IsDirty()");
01790       }
01791       return TRUE;
01792
01793     case IDM_GETDATA:
01794     case IDM_IROWSETLOCATE_GETDATA:
01795     case IDM_IROWSETSCROLL_GETDATA:
01796       if(pCRowset && pCRowset->m_pIRowset)
01797       {
01798         INDEX cRows = 0;
01799         INDEX* rgItems = NULL;
01800         HROW* rghRows = NULL;
01801
01802         //Find all Selected Rows
01803         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
01804         if(cRows == 0)
01805         {
01806           wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONHAND | MB_OK | MB_DEFBUTTON1,
01807             wsz_ERROR, L"Must first select a row...");
01808         }
01809
01810         DBPROPID dwSourceID = DBPROP_IRowset;
01811         if(iID == IDM_IROWSETLOCATE_GETDATA)
01812           dwSourceID = DBPROP_IRowsetLocate;
01813         if(iID == IDM_IROWSETSCROLL_GETDATA)
01814           dwSourceID = DBPROP_IRowsetScroll;
01815
01816         CWaitCursor waitCursor;
01817
01818         //Display all rows...
01819         for(INDEX i=0; i<cRows; i++)
01820         {
01821           //Display the Data for this row...
01822           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i], dwSourceID, true/*fAlways*/);
01823         }
01824         SAFE_FREE(rgItems);
01825         SAFE_FREE(rghRows);
01826       }
01827       return TRUE;
01828
01829     case IDM_REFRESH:
01830       if(pCRowset && pCRowset->m_pIRowset)
01831       {
01832         CWaitCursor waitCursor;
01833
01834         //Similar to GetData except for all rows
01835         if(SUCCEEDED(m_pCDataGrid->RestartPosition()))
01836           m_pCDataGrid->RefreshData();
01837       }
01838       return TRUE;
01839
01840     case IDM_GETVISIBLEDATA:
01841       if(pCRowset && pCRowset->m_pIRowsetResynch)
01842       {
01843         INDEX cRows = 0;
01844         INDEX* rgItems = NULL;
01845         HROW* rghRows = NULL;
01846
01847         //Find all Selected Rows
01848         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
01849         if(cRows == 0)
01850         {
01851           wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONHAND | MB_OK | MB_DEFBUTTON1,
01852             wsz_ERROR, L"Must first select a row...");
01853         }
01854
01855         CWaitCursor waitCursor;
01856         for(INDEX i=0; i<cRows; i++)
01857         {
01858           //Display the Data for this row...
01859           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i], DBPROP_IRowsetResynch, true/*fAlways*/);
01860         }
01861         SAFE_FREE(rgItems);
01862         SAFE_FREE(rghRows);
01863       }
01864       return TRUE;
01865
01866     case IDM_RESYNCHROWS:
01867       if(pCRowset && pCRowset->m_pIRowsetResynch)
01868       {
01869         CWaitCursor waitCursor;
01870
01871         INDEX cRows = 0;
01872         HROW* rghRows = NULL;
01873         DBCOUNTITEM cRowsResynched = 0;
01874         HROW* rghRowsResynched = 0;
01875         DBROWSTATUS* rgRowStatus = NULL;
01876         INDEX* rgItems = NULL;
01877
01878         //Get all selected Rows
01879         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
01880
01881         //IRowsetResynch::ResynchRows
01882         XTEST(hr = pCRowset->m_pIRowsetResynch->ResynchRows(cRows, rghRows, &cRowsResynched, &rghRowsResynched, &rgRowStatus));
01883         DisplayRowErrors(hr, cRowsResynched, rghRowsResynched, rgRowStatus);
01884         TRACE_METHOD(hr, L"IRowsetResynch::ResynchRows(%lu, 0x%p, &%lu, &0x%p, &0x%p)", cRows, rghRows, cRowsResynched, rghRowsResynched, rgRowStatus);
01885
01886         //Now GetData for all SelectedRows (a nice helper)
01887         //We won't worry about updating the case for (0,NULL), its not worth
01888         //trying to match the rhgRows returned to the correct hRows.  Worse case
01889         //is the user has to call GetData for one or all rows...
01890         for(INDEX i=0; i<cRows; i++)
01891         {
01892           //Display the Data for this row...
01893           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i]);
01894         }
01895
01896         //Cleanup
01897         SAFE_FREE(rghRows);
01898         SAFE_FREE(rghRowsResynched);
01899         SAFE_FREE(rgRowStatus);
01900         SAFE_FREE(rgItems);
01901       }
01902       return TRUE;
01903
01904     case IDM_GETLASTVISIBLEDATA:
01905       if(pCRowset && pCRowset->m_pIRowsetRefresh)
01906       {
01907         CWaitCursor waitCursor;
01908
01909         INDEX cRows = 0;
01910         INDEX* rgItems = NULL;
01911         HROW* rghRows = NULL;
01912
01913         //Find all Selected Rows
01914         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
01915         if(cRows == 0)
01916         {
01917           wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONHAND | MB_OK | MB_DEFBUTTON1,
01918             wsz_ERROR, L"Must first select a row...");
01919         }
01920
01921         for(INDEX i=0; i<cRows; i++)
01922         {
01923           //Display the Data for this row...
01924           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i], DBPROP_IRowsetRefresh, true/*fAlways*/);
01925         }
01926         SAFE_FREE(rgItems);
01927         SAFE_FREE(rghRows);
01928       }
01929       return TRUE;
01930
01931     case IDM_REFRESHVISIBLEDATA:
01932       if(pCRowset && pCRowset->m_pIRowsetRefresh)
01933       {
01934         CWaitCursor waitCursor;
01935
01936         INDEX i,cRows = 0;
01937         HROW* rghRows = NULL;
01938         BOOL fOverWrite = FALSE;
01939         DBCOUNTITEM cRowsRefreshed = 0;
01940         HROW* rghRowsRefreshed = 0;
01941         DBROWSTATUS* rgRowStatus = NULL;
01942         INDEX* rgItems = NULL;
01943
01944         //Get all selected Rows
01945         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
01946
01947         //IRowsetRefresh::RefreshVisibleData
01948         XTEST(hr = pCRowset->m_pIRowsetRefresh->RefreshVisibleData(hChapter, cRows, rghRows, fOverWrite, &cRowsRefreshed, &rghRowsRefreshed, &rgRowStatus));
01949         DisplayRowErrors(hr, cRowsRefreshed, rghRowsRefreshed, rgRowStatus);
01950         TRACE_METHOD(hr, L"IRowsetRefresh::RefreshVisibleData(0x%p, %lu, 0x%p, %d, &%lu, &0x%p, &0x%p)", hChapter, cRows, rghRows, fOverWrite, cRowsRefreshed, rghRowsRefreshed, rgRowStatus);
01951
01952         //Now GetData for all SelectedRows (a nice helper)
01953         //We won't worry about updating the case for (0,NULL), its not worth
01954         //trying to match the rhgRows returned to the correct hRows.  Worse case
01955         //is the user has to call GetData for one or all rows...
01956         for(i=0; i<cRows; i++)
01957         {
01958           //Display the Data for this row...
01959           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i]);
01960         }
01961
01962         //Cleanup
01963         SAFE_FREE(rghRows);
01964         SAFE_FREE(rghRowsRefreshed);
01965         SAFE_FREE(rgRowStatus);
01966         SAFE_FREE(rgItems);
01967       }
01968       return TRUE;
01969
01970     case IDM_GETORIGINALDATA:
01971       if(pCRowset && pCRowset->m_pIRowsetUpdate)
01972       {
01973         CWaitCursor waitCursor;
01974
01975         INDEX cRows = 0;
01976         INDEX* rgItems = NULL;
01977         HROW* rghRows = NULL;
01978
01979         //Find all Selected Rows
01980         LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
01981         if(cRows == 0)
01982         {
01983           wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONHAND | MB_OK | MB_DEFBUTTON1,
01984             wsz_ERROR, L"Must first select a row...");
01985         }
01986
01987         for(INDEX i=0; i<cRows; i++)
01988         {
01989           //Display the Data for this row...
01990           m_pCDataGrid->DisplayData(rghRows[i], rgItems[i], DBPROP_IRowsetUpdate, true/*fAlways*/);
01991         }
01992         SAFE_FREE(rgItems);
01993         SAFE_FREE(rghRows);
01994       }
01995       return TRUE;
01996
01997     case IDM_GETPENDINGROWS:
01998       if(pCRowset && pCRowset->m_pIRowsetUpdate)
01999       {
02000         CWaitCursor waitCursor;
02001
02002         DBCOUNTITEM cPendingRows = 0;
02003         HROW* rgPendingRows = 0;
02004         DBPENDINGSTATUS* rgPendingStatus = NULL;
02005
02006         //IRowsetUpdate::GetPendingStatus
02007         XTEST(hr = pCRowset->m_pIRowsetUpdate->GetPendingRows(hChapter, DBPENDINGSTATUS_NEW | DBPENDINGSTATUS_CHANGED | DBPENDINGSTATUS_DELETED, &cPendingRows, &rgPendingRows, &rgPendingStatus));
02008         TRACE_METHOD(hr, L"IRowsetUpdate::GetPendingRows(0x%p, DBPENDINGSTATUS_NEW | DBPENDINGSTATUS_CHANGED | DBPENDINGSTATUS_DELETED, &%lu, &0x%p, &0x%p)", hChapter, cPendingRows, rgPendingRows, rgPendingStatus);
02009
02010         //Cleanup
02011         SAFE_FREE(rgPendingRows);
02012         SAFE_FREE(rgPendingStatus);
02013       }
02014       return TRUE;
02015
02016     case IDM_GETROWSTATUS:
02017       if(pCRowset && pCRowset->m_pIRowsetUpdate)
02018       {
02019         CWaitCursor waitCursor;
02020
02021         //Find the SelectedRow
02022         HROW hRow;
02023         if(m_pCDataGrid->GetSelectedRow(&hRow, FALSE) != LVM_ERR)
02024         {
02025           DBPENDINGSTATUS dwPendingStatus = 0;
02026
02027           //IRowsetUpdate::GetRowStatus
02028           XTEST(hr = pCRowset->m_pIRowsetUpdate->GetRowStatus(hChapter, 1, &hRow, &dwPendingStatus));
02029           TRACE_METHOD(hr, L"IRowsetUpdate::GetRowStatus(0x%p, %lu, &0x%p, &0x%p)", hChapter, 1, hRow, dwPendingStatus);
02030         }
02031       }
02032       return TRUE;
02033
02034     case IDM_UNDO:      //Cancel the chagnes that were made.
02035       if(pCRowset && pCRowset->m_pIRowsetUpdate)
02036       {
02037         CWaitCursor waitCursor;
02038         UndoChanges();
02039       }
02040       return TRUE;
02041
02042     case IDM_UPDATE:      //Update the changes that were made.
02043       if(pCRowset && pCRowset->m_pIRowsetUpdate)
02044       {
02045         CWaitCursor waitCursor;
02046         UpdateChanges();
02047       }
02048       return TRUE;
02049
02050     //IServiceProvider
02051     case IDM_ISERVICEPROVIDER:
02052       if(pCDataSource && pCDataSource->m_pIServiceProvider)
02053       {
02054         //Display the Generic interface list...
02055         CInterfaceDlg interfaceDlg(IDD_INTERFACE, L"IServiceProvider::QueryService", IID_ISpecifyPropertyPages);
02056         if(interfaceDlg.DoModal(hWnd) == IDOK)
02057         {
02058           CWaitCursor waitCursor;
02059           CComPtr<IUnknown> spUnknown;
02060
02061           XTEST(hr = pCDataSource->m_pIServiceProvider->QueryService(OLEDB_SVC_DSLPropertyPages, interfaceDlg.GetSelInterface(), (void**)&spUnknown));
02062           TRACE_METHOD(hr, L"IServiceProvider::QueryService(OLEDB_SVC_DSLPropertyPages, %s, &0x%p)", GetInterfaceName(interfaceDlg.GetSelInterface()), spUnknown);
02063         }
02064       }
02065       return TRUE;
02066
02067
02068   };
02069
02070   return FALSE;
02071 }
02072
02073
02074 /////////////////////////////////////////////////////////////////
02075 // CMDIChild::UpdateWndTitle
02076 //
02077 /////////////////////////////////////////////////////////////////
02078 HRESULT CMDIChild::UpdateWndTitle()
02079 {
02080   //Default Info
02081   CBase* pCBase       = GetObject();
02082   CDataSource* pCDataSource = (CDataSource*)GetObject(eCDataSource);
02083   WCHAR* pwszProvider     = NULL;
02084   WCHAR* pwszDesc       = NULL;
02085
02086   if(pCDataSource)
02087   {
02088     pwszProvider = pCDataSource->m_cstrProviderDesc &&  pCDataSource->m_cstrProviderDesc[0] ? pCDataSource->m_cstrProviderDesc : pCDataSource->m_cstrProviderName;
02089     pwszDesc   = pCDataSource->m_cstrDataSource && pCDataSource->m_cstrDataSource[0] ? pCDataSource->m_cstrDataSource : pCDataSource->m_cstrDBMS;
02090   }
02091
02092   //Format text and output to window
02093   wSendMessageFmt(
02094         m_hWnd, WM_SETTEXT, 0, L"%s: %s %s%s%s",
02095         pCBase ? pCBase->GetObjectName() : L"Unknown",
02096         pwszProvider ? pwszProvider : L"",
02097         pwszDesc && pwszDesc[0] ? L"(" : L"",
02098         pwszDesc ? pwszDesc : L"",
02099         pwszDesc && pwszDesc[0] ? L")" : L""
02100         );
02101
02102   return S_OK;
02103 }
02104
02105
02106
02107 ////////////////////////////////////////////////////////////////
02108 // CMDIChild::CreateEnumChild()
02109 //
02110 /////////////////////////////////////////////////////////////////
02111 HRESULT CMDIChild::CreateEnumChild()
02112 {
02113   HRESULT hr = S_OK;
02114   INDEX iSelRow = 0;
02115   WCHAR wszBuffer[MAX_NAME_LEN+1];
02116
02117   CRowset* pCRowset     = (CRowset*)GetObject(eCRowset);
02118   CEnumerator* pCEnumerator = SOURCE_GETPARENT(pCRowset, CEnumerator);
02119   if(pCRowset && pCEnumerator)
02120   {
02121     //If enumertor rowset, double-clicking on a row
02122     //brings up the ParseName object in another window
02123     ULONG iColumn = 1;  //Skip RowHandle column
02124
02125     //Skip bookmark column...
02126     if(pCRowset->m_Bindings.GetCount() && pCRowset->m_Bindings[0].iOrdinal==0)
02127       iColumn = 2;
02128
02129     //Obtain SelectedRow
02130     iSelRow = m_pCDataGrid->GetSelectedRow();
02131     ASSERT(iSelRow != LVM_ERR);
02132
02133     //Obtain SourcesName and description from SelectedRow
02134     ENUMINFO EnumInfo;
02135     //SOURCES_NAME
02136     m_pCDataGrid->GetItemText(iSelRow, iColumn+0, EnumInfo.wszName, MAX_NAME_LEN);
02137     //SOURCES_PARSENAME
02138     m_pCDataGrid->GetItemText(iSelRow, iColumn+1, EnumInfo.wszParseName, MAX_NAME_LEN);
02139     //SOURCES_DESCRIPTION
02140     m_pCDataGrid->GetItemText(iSelRow, iColumn+2, EnumInfo.wszDescription, MAX_NAME_LEN);
02141     //SOURCES_TYPE
02142     m_pCDataGrid->GetItemText(iSelRow, iColumn+3, wszBuffer, MAX_NAME_LEN);
02143     EnumInfo.eType = (DBTYPE)wcstoul(wszBuffer, NULL, 10);
02144     //SOURCES_ISPARENT
02145     m_pCDataGrid->GetItemText(iSelRow, iColumn+4, wszBuffer, MAX_NAME_LEN);
02146     EnumInfo.fIsParent = StringCompare(wszBuffer, L"True") ? TRUE : FALSE;
02147
02148     //Now Connect using the Connect Dialog
02149     ASSERT(m_pCMainWindow);
02150     ASSERT(m_pCMainWindow->m_pCFullConnect);
02151     m_pCMainWindow->m_pCFullConnect->Display(m_hWnd, pCEnumerator, &EnumInfo);
02152   }
02153   return hr;
02154 }
02155
02156
02157
02158 ////////////////////////////////////////////////////////////////
02159 // CMDIChild::DeleteSelectedRows
02160 //
02161 /////////////////////////////////////////////////////////////////
02162 HRESULT CMDIChild::DeleteSelectedRows()
02163 {
02164   //Delete the Selected row in the ListView...
02165   HRESULT hr = E_FAIL;
02166   INDEX cRows = 0;
02167   INDEX* rgItems = NULL;
02168   HROW* rghRows = NULL;
02169   DBROWSTATUS* rgRowStatus = NULL;
02170   LONG dwSelection = IDYES;
02171   CRowset*  pCRowset = (CRowset*)GetObject(eCRowset);
02172
02173   //Is editing the Rowset allowed?
02174   if(!pCRowset || !pCRowset->m_pIRowsetChange)
02175     return E_FAIL;
02176
02177   //Find the Selected Items in the ListView
02178   HCHAPTER hChapter = pCRowset->m_hChapter;
02179   LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
02180   SAFE_ALLOC(rgRowStatus, DBROWSTATUS, cRows);
02181
02182   //Popup a MessageBox, Asking user if really wants to DeleteRow
02183   if(cRows)
02184   {
02185     dwSelection = wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1,
02186       L"IRowsetChange::DeleteRows", L"Do you wish to delete the selected row(s)?");
02187   }
02188
02189   if(dwSelection == IDYES)
02190   {
02191     //DeleteRows from Rowset
02192     XTEST(hr = pCRowset->m_pIRowsetChange->DeleteRows(hChapter, cRows, rghRows, rgRowStatus));
02193     DisplayRowErrors(hr, cRows, rghRows, rgRowStatus);
02194     TESTC(TRACE_METHOD(hr, L"IRowsetChange::DeleteRows(0x%p, %lu, 0x%p, 0x%p)", hChapter, cRows, rghRows, rgRowStatus));
02195
02196     //Loop over the deleted rows...
02197     for(INDEX i=0; i<cRows; i++)
02198     {
02199       //We are "lazy" about updating the ListView.  Since we are not
02200       //sure wither the provider compacts or not after deleted rows,
02201       //its easier and more correct to just display a "deleted" icon form
02202       //of the row, rather than guessing...
02203
02204       //NOTE: We can go off the property DBPROP_REMOVEDELETED, but then we
02205       //need to adjust the "cursor" position we store, forward/backward fetch, etc.
02206       //Probably more useful and useable if its the same for all providers, rather
02207       //than have it just "disappear" on some providers and others it remains...
02208
02209       //NOTE: Also this way allows you to call operations for deleted rows,
02210       //otherwise you can't since its removed from the view...
02211 //      if(pCRowset->m_fRemoveDeleted)
02212 //      {
02213 //        //Remove the row from the listview - since the provider compacts
02214 //        m_pCDataGrid->DeleteItem(rgItems[i]);
02215 //      }
02216 //      else
02217 //      {
02218         //Need to indicate row was deleted, but not compacted, (use "deleted" icon)
02219         m_pCDataGrid->SetItemImage(rgItems[i], 0, IMAGE_DELETE);
02220 //      }
02221     }
02222   }
02223
02224 CLEANUP:
02225   SAFE_FREE(rgRowStatus);
02226   SAFE_FREE(rgItems);
02227   SAFE_FREE(rghRows);
02228   return hr;
02229 }
02230
02231
02232 /////////////////////////////////////////////////////////////////
02233 // CMDIChild::ChangeSelectedRow
02234 //
02235 /////////////////////////////////////////////////////////////////
02236 HRESULT CMDIChild::ChangeSelectedRow(CBase* pCSource, UINT idSource)
02237 {
02238   //If this is a row object - theres only 1 row...
02239   if(SOURCE_GETOBJECT(pCSource, CRow))
02240   {
02241     m_pCDataGrid->m_iSelRow = 0;
02242   }
02243   else
02244   {
02245     //Otherwise find the Selected row
02246     m_pCDataGrid->m_iSelRow = m_pCDataGrid->GetSelectedRow(NULL, TRUE);
02247     if(m_pCDataGrid->m_iSelRow == LVM_ERR)
02248       return E_INVALIDARG;
02249   }
02250
02251   //Create Dialog box, passing the "this" pointer
02252   //NOTE: m_pCSource and m_idSource are already setup...
02253   DisplayDialog(IDD_ROWCHANGE, m_hWnd, RowChangeProc, pCSource, idSource);
02254   return S_OK;
02255 }
02256
02257
02258 ////////////////////////////////////////////////////////////////
02259 // CMDIChild::InsertNewRow
02260 //
02261 /////////////////////////////////////////////////////////////////
02262 HRESULT CMDIChild::InsertNewRow()
02263 {
02264   //Insert a new row into the ListView...
02265   HRESULT hr = E_FAIL;
02266   CRowset*  pCRowset = (CRowset*)GetObject(eCRowset);
02267
02268   //Find the Selected Item in the ListView
02269   m_pCDataGrid->m_iSelRow = m_pCDataGrid->GetSelectedRow(NULL, FALSE);
02270
02271   //Is editing the Rowset allowed?
02272   if(!pCRowset || !pCRowset->m_pIRowsetChange)
02273     return E_FAIL;
02274
02275   //Bring up the Insert Dialog box...
02276   DisplayDialog(IDD_ROWCHANGE, m_hWnd, RowChangeProc, pCRowset, IDM_INSERTROW);
02277   return hr;
02278 }
02279
02280
02281 ////////////////////////////////////////////////////////////////
02282 // CMDIChild::UndoChanges
02283 //
02284 /////////////////////////////////////////////////////////////////
02285 HRESULT CMDIChild::UndoChanges()
02286 {
02287   //Undo all pending changes, (if in buffered mode)...
02288   HRESULT hr = E_FAIL;
02289   CRowset*  pCRowset = (CRowset*)GetObject(eCRowset);
02290
02291   INDEX i,cRows = 0;
02292   HROW* rghRows = NULL;
02293   DBCOUNTITEM cRowsUndone = 0;
02294   HROW* rghRowsUndone = NULL;
02295   INDEX* rgItems = NULL;
02296   DBROWSTATUS* rgRowStatus = NULL;
02297
02298   if(pCRowset && pCRowset->m_pIRowsetUpdate)
02299   {
02300     HCHAPTER hChapter = pCRowset->m_hChapter;
02301
02302     //Get all selected Rows
02303     LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
02304
02305     //IRowsetUpdate::Undo
02306     XTEST(hr = pCRowset->m_pIRowsetUpdate->Undo(hChapter,cRows,rghRows,&cRowsUndone,&rghRowsUndone, &rgRowStatus));
02307     DisplayRowErrors(hr, cRowsUndone, rghRowsUndone, rgRowStatus);
02308     TESTC(TRACE_METHOD(hr, L"IRowsetUpdate::Undo(0x%p, %lu, 0x%p, &%lu, &0x%p, &0x%p)", hChapter, cRows, rghRows, cRowsUndone, rghRowsUndone, rgRowStatus));
02309
02310     //Now GetData for all SelectedRows (a nice helper)
02311     //We won't worry about updating the case for (0,NULL), its not worth
02312     //trying to match the rhgRows returned to the correct hRows.  Worse case
02313     //is the user has to call GetData for one or all rows...
02314     for(i=0; i<cRows; i++)
02315     {
02316       //Need to indicate row was updated, use normal icon
02317       m_pCDataGrid->SetItemImage(rgItems[i], 0, IMAGE_NORMAL);
02318
02319       //Display the Data...
02320       hr = m_pCDataGrid->DisplayData(rghRows[i], rgItems[i]);
02321     }
02322   }
02323
02324 CLEANUP:
02325   SAFE_FREE(rghRows);
02326   SAFE_FREE(rghRowsUndone);
02327   SAFE_FREE(rgRowStatus);
02328   SAFE_FREE(rgItems);
02329   return hr;
02330 }
02331
02332
02333 ////////////////////////////////////////////////////////////////
02334 // CMDIChild::UpdateChanges
02335 //
02336 /////////////////////////////////////////////////////////////////
02337 HRESULT CMDIChild::UpdateChanges()
02338 {
02339   //Update all pending changes, (if in buffered mode)...
02340   HRESULT hr = E_FAIL;
02341   INDEX i,cRows = 0;
02342   HROW* rghRows = NULL;
02343   DBCOUNTITEM cRowsUpdated = 0;
02344   HROW* rghRowsUpdated = NULL;
02345   DBROWSTATUS* rgRowStatus = NULL;
02346   INDEX* rgItems = NULL;
02347   CRowset*  pCRowset = (CRowset*)GetObject(eCRowset);
02348
02349   if(pCRowset && pCRowset->m_pIRowsetUpdate)
02350   {
02351     HCHAPTER hChapter = pCRowset->m_hChapter;
02352
02353     //Get all selected Rows
02354     LV_GetSelItems(m_pCDataGrid->m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
02355
02356     //IRowsetUpdate::Update
02357     XTEST(hr = pCRowset->m_pIRowsetUpdate->Update(hChapter,cRows,rghRows,&cRowsUpdated,&rghRowsUpdated,&rgRowStatus));
02358     DisplayRowErrors(hr, cRowsUpdated, rghRowsUpdated, rgRowStatus);
02359     TESTC(TRACE_METHOD(hr, L"IRowsetUpdate::Update(0x%p, %lu, 0x%p, &%lu, &0x%p, &0x%p)", hChapter, cRows, rghRows, cRowsUpdated, rghRowsUpdated, rgRowStatus));
02360
02361     //Now GetData for all SelectedRows (a nice helper)
02362     //We won't worry about updating the case for (0,NULL), its not worth
02363     //trying to match the rhgRows returned to the correct hRows.  Worse case
02364     //is the user has to call GetData for one or all rows...
02365     for(i=0; i<cRows; i++)
02366     {
02367       //Need to indicate row was updated, use normal icon
02368       m_pCDataGrid->SetItemImage(rgItems[i], 0, IMAGE_NORMAL);
02369
02370       //Display the Data...
02371       hr = m_pCDataGrid->DisplayData(rghRows[i], rgItems[i]);
02372     }
02373   }
02374
02375 CLEANUP:
02376   SAFE_FREE(rghRows);
02377   SAFE_FREE(rghRowsUpdated);
02378   SAFE_FREE(rgRowStatus);
02379   SAFE_FREE(rgItems);
02380   return hr;
02381 }
02382
02383
02384 ////////////////////////////////////////////////////////////////
02385 // CMDIChild::GetListViewValues
02386 //
02387 /////////////////////////////////////////////////////////////////
02388 HRESULT CMDIChild::GetListViewValues(HWND hWndNames, HWND hWndValues, CDataAccess* pCDataAccess, CBindings& rBindings, void* pData)
02389 {
02390   ASSERT(hWndNames);
02391   ASSERT(hWndValues);
02392   ASSERT(pCDataAccess);
02393   HRESULT hr = S_OK;
02394
02395   //Obtain the values from a specified ListView
02396   //And place them into our pData structure according to our bindings...
02397   //this method is mainly used for InsertRow and SetData operations...
02398   WCHAR   wszBuffer[MAX_COL_SIZE+1] = {0};
02399   DBSTATUS  dbStatus    = DBSTATUS_S_OK;
02400   DBTYPE    wBackendType  = DBTYPE_EMPTY;
02401
02402   //Loop through all Columns
02403   for(ULONG i=0; i<rBindings.GetCount(); i++)
02404   {
02405     //Get the Status from the 'insert' ListView
02406     LV_GetItemText(hWndNames, i, 2, wszBuffer, MAX_COL_SIZE);
02407     dbStatus = GetStatusValue(wszBuffer);
02408
02409     //Get the Backend Type (sotred as the item data of the value)
02410     wBackendType = (DBTYPE)LV_GetItemParam(hWndValues, i, 0);
02411
02412     //Get the Item from the 'insert' ListView
02413     LV_GetItemText(hWndValues, i, 0, wszBuffer, MAX_COL_SIZE);
02414
02415     //Get the Image and Param
02416     BOOL bChecked = LV_GetItemState(hWndNames, i, LVIS_STATEIMAGEMASK) & INDEXTOSTATEIMAGEMASK(STATE_CHECKED);
02417     if(bChecked)
02418     {
02419       //Set the ColumnData in our pData buffer
02420       TESTC(hr = pCDataAccess->SetColumnData(&rBindings[i], pData, dbStatus, wcslen(wszBuffer), wszBuffer, CONV_NONE, wBackendType));
02421
02422       //Reset the Item in the ListView in case it got truncated
02423       LV_SetItemText(hWndValues, i, 0, wszBuffer);
02424     }
02425     else
02426     {
02427       //Mark this status as skipped (ignore)
02428       //This allows us to not have to realloc a smaller subset of selected
02429       //columns, and also allows us to be able to reuse the hAccessor
02430       if(STATUS_IS_BOUND(rBindings[i]))
02431         BINDING_STATUS(rBindings[i], pData) = DBSTATUS_S_IGNORE;
02432     }
02433   }
02434
02435 CLEANUP:
02436   return hr;
02437 }
02438
02439
02440 ////////////////////////////////////////////////////////////////
02441 // CMDIChild::RowChangeProc
02442 //
02443 /////////////////////////////////////////////////////////////////
02444 INT_PTR WINAPI CMDIChild::RowChangeProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
02445 {
02446   static BOOL bBeginEdit  = FALSE;
02447   static BOOL s_bClearAll = TRUE;
02448   static CListViewLite  s_listNames;
02449   static CListViewLite  s_listValue;
02450
02451   switch(message)
02452   {
02453     case WM_INITDIALOG:
02454     {
02455       CWaitCursor waitCursor;
02456       bBeginEdit = FALSE;
02457
02458       //Save the "this" pointer
02459       CMDIChild* pThis  = (CMDIChild*)SetThis(hWnd, (void*)lParam);
02460
02461       DWORD dwConvFlags = pThis->GetOptions()->m_dwConvFlags;
02462       HRESULT hr = S_OK;
02463
02464       WCHAR   wszBuffer[MAX_COL_SIZE+1];
02465       DBCOUNTITEM iBind = 0;
02466       DBLENGTH  dbLength = 0;
02467       DBSTATUS  dbStatus = DBSTATUS_S_OK;//DBSTATUS_S_ISNULL;
02468       DBTYPE    wSubType = 0;
02469
02470       //We need to bring up a 2 ListViews.
02471       //left - has column names,
02472       //right - is blank for entering data for the corrsponding column
02473
02474       //Setup column headers
02475       s_listNames.CreateIndirect(hWnd, IDL_NAMES);
02476       s_listValue.CreateIndirect(hWnd, IDL_VALUES);
02477       s_bClearAll = TRUE;
02478
02479       //SubClass the ListViews.
02480       SynchSubProc(s_listNames.m_hWnd, WM_INITDIALOG, 0, (LPARAM)s_listValue.m_hWnd);
02481       SynchSubProc(s_listValue.m_hWnd, WM_INITDIALOG, 0, (LPARAM)s_listNames.m_hWnd);
02482
02483       //Use Extended ListView Styles!
02484       SendMessage(s_listNames.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES);
02485       SendMessage(s_listValue.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
02486
02487       //Set image list to the ListView
02488       ListView_SetImageList(s_listNames.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
02489       ListView_SetImageList(s_listNames.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_STATE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_STATE);
02490       ListView_SetImageList(s_listValue.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
02491
02492       //Insert Column Headers
02493       s_listNames.InsertColumn(0, L"Column");
02494       s_listNames.InsertColumn(1, L"Length");
02495       s_listNames.InsertColumn(2, L"Status");
02496       s_listNames.InsertColumn(3, L"Type");
02497       s_listNames.InsertColumn(4, L"SubType");
02498       s_listValue.InsertColumn(0, L"Data");
02499
02500       //Obtain the data for the selected row
02501       HROW hRow = NULL;
02502
02503       //Determine the object type
02504       CRow* pCRow         = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
02505       CRowset* pCRowset     = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
02506       CDataset* pCDataset     = SOURCE_GETOBJECT(pThis->m_pCSource, CDataset);
02507       CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
02508       CDataGrid* pCDataGrid   = pThis->m_pCDataGrid;
02509       void* pData         = NULL;
02510
02511       //Determine how to get the data...
02512       if(pCRow)
02513       {
02514         //Row Object (extra columns)
02515         hr = pCRow->GetColumns(pCRow->m_cColAccess, pCRow->m_rgColAccess);
02516         pData = pCDataAccess->m_pData;
02517       }
02518       else if(pCDataset)
02519       {
02520         //Dataset Object
02521         hr = pCDataset->GetCellData(pCDataGrid->m_iSelRow, pCDataGrid->m_iSelRow);
02522         pData = pCDataAccess->m_pData;
02523       }
02524       else if(pCRowset)
02525       {
02526         //Rowset
02527         //Obtain the selected row...
02528         if(pCDataGrid->m_iSelRow != LVM_ERR)
02529           hRow = pCDataGrid->GetItemParam(pCDataGrid->m_iSelRow);
02530
02531         //NOTE:  If the user has released the row handle, and then called
02532         //insert row, selecting this row handle, since of erroring out we will just not
02533         //provide the default row of data to insert...
02534         if(hRow || pThis->m_idSource != IDM_INSERTROW)
02535         {
02536           hr = pCRowset->GetData(hRow);
02537           pData = pCDataAccess->m_pData;
02538         }
02539       }
02540
02541       //Relax the errors here.  With Get*Data both DB_S/DB_E will return a bad
02542       //status for 1 or more columns.  Or DataGrid will just display the column
02543       //status if not S_OK.  So for these errors just display the data anyway...
02544       if(FAILED(hr) && hr!= DB_E_ERRORSOCCURRED)
02545         goto CLEANUP2;
02546       hr = S_OK;  //Otherwise dialog is not displayed
02547
02548       //Display ColumnNames in LeftPane, and data in the right pane
02549       for(iBind=0; iBind<pCDataAccess->m_Bindings.GetCount(); iBind++)
02550       {
02551         //Get the Length, Status, Data for this Column
02552         const DBBINDING* pBinding   = &pCDataAccess->m_Bindings[iBind];
02553         const DBCOLUMNINFO* pColInfo  = pCDataAccess->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
02554         wszBuffer[0] = wEOL;
02555
02556         //Obtain the Data...
02557         if(pData)
02558           pCDataAccess->GetColumnData(pBinding, pData, &dbStatus, &dbLength, &wSubType, wszBuffer, MAX_COL_SIZE, dwConvFlags, pColInfo->wType);
02559
02560         //Insert the Data into the list (make an "easy" edit)
02561         s_listValue.InsertItem(iBind, 0, wszBuffer, (LPARAM)pColInfo->wType, pCDataAccess->GetColumnImage(pColInfo, dbStatus));
02562
02563         //Insert the ColumnName
02564         s_listNames.InsertItem(iBind, 0, GetColName(pColInfo));
02565
02566         //Insert the Length into the List
02567         if(LENGTH_IS_BOUND(*pBinding))
02568           StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", dbLength);
02569         else
02570           StringCopy(wszBuffer, L"Not Bound", MAX_COL_SIZE);
02571         s_listNames.InsertItem(iBind, 1, wszBuffer);
02572
02573         //Insert the Status into the List
02574         s_listNames.InsertItem(iBind, 2, STATUS_IS_BOUND(*pBinding) ? GetStatusName(dbStatus) : L"Not Bound");
02575
02576         //Insert the Type into the List
02577         s_listNames.InsertItem(iBind, 3, GetDBTypeName(pColInfo->wType));
02578
02579         //Insert the SubType into the List
02580         if(wSubType || pColInfo->wType == VT_VARIANT)
02581           s_listNames.InsertItem(iBind, 4, GetVariantTypeName(wSubType));
02582
02583         //Set Item State to Checked/Unchecked
02584         s_listNames.SetItemState(iBind, 0,  INDEXTOSTATEIMAGEMASK(pColInfo->dwFlags & (DBCOLUMNFLAGS_WRITE|DBCOLUMNFLAGS_WRITEUNKNOWN) ? STATE_CHECKED : STATE_UNCHECKED),  LVIS_STATEIMAGEMASK);
02585       }
02586
02587       //Update Controls
02588 			::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), (pCRowset && pCRowset->m_pIRowsetChange) || (pCRow && pCRow->m_pIRowChange));
02589
02590       //Update Title and Status
02591       switch(pThis->m_idSource)
02592       {
02593         case IDM_IROW_DELETECOLUMNS:
02594           if(pCRow && pCRow->m_pIRowSchemaChange)
02595           {
02596             SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowSchemaChange::DeleteColumns");
02597             SendMessage(::GetDlgItem(hWnd, IDT_HELPMSG), WM_SETTEXT, 0, (LPARAM)"Deletes the desired columns from the row object");
02598             SendMessage(::GetDlgItem(hWnd, IDOK), WM_SETTEXT, 0, (LPARAM)"Delete");
02599 						::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), TRUE);
02600           }
02601           break;
02602
02603         case IDM_IROW_SETCOLUMNS:
02604           if(pCRow && pCRow->m_pIRowChange)
02605           {
02606             SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowChange::SetColumns");
02607             SendMessage(::GetDlgItem(hWnd, IDT_HELPMSG), WM_SETTEXT, 0, (LPARAM)"Modifies the row object columns");
02608             SendMessage(::GetDlgItem(hWnd, IDOK), WM_SETTEXT, 0, (LPARAM)"SetColumns");
02609 						::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), TRUE);
02610           }
02611           break;
02612
02613         case IDM_INSERTROW:
02614           if(pCRowset && pCRowset->m_pIRowsetChange)
02615           {
02616             SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowsetChange::InsertRow");
02617             SendMessage(::GetDlgItem(hWnd, IDT_HELPMSG), WM_SETTEXT, 0, (LPARAM)"Inserts the desired row of data into the Rowset");
02618             SendMessage(::GetDlgItem(hWnd, IDOK), WM_SETTEXT, 0, (LPARAM)"InsertRow");
02619 						::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), TRUE);
02620           }
02621           break;
02622
02623         case IDM_SETDATA:
02624           if(pCRowset && pCRowset->m_pIRowsetChange)
02625           {
02626             SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowsetChange::SetData");
02627             SendMessage(::GetDlgItem(hWnd, IDT_HELPMSG), WM_SETTEXT, 0, (LPARAM)"Modifies the row data in the Rowset");
02628             SendMessage(::GetDlgItem(hWnd, IDOK), WM_SETTEXT, 0, (LPARAM)"SetData");
02629 						::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), TRUE);
02630           }
02631           break;
02632
02633         default:
02634           //NOTE: The Dialog is already setup with the default window text:
02635           //"Detailed Row Information"
02636 					::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), FALSE);
02637           break;
02638       };
02639
02640       //Free outofline data
02641       //TODO - need to free in the case of errors as well.  But have to be careful
02642       //since the pData may not have been setup yet, or other errors where its undefined...
02643       if(pData)
02644         pCDataAccess->m_Bindings.FreeData(pData);
02645
02646     CLEANUP2:
02647
02648       //AutoSize Columns
02649       for(iBind=0; iBind<=4; iBind++)
02650         s_listNames.SetColumnWidth(iBind, LVSCW_AUTOSIZE_USEHEADER);
02651       s_listValue.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
02652       CenterDialog(hWnd);
02653
02654       if(FAILED(hr))
02655         EndDialog(hWnd, FALSE);
02656       return TRUE;
02657     }
02658
02659     case WM_COMMAND:
02660     {
02661       //Filter out any Control Notification codes
02662       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
02663         break;
02664
02665       switch (GET_WM_COMMAND_ID(wParam, lParam))
02666       {
02667         case IDB_CLEARALL:
02668         {
02669           //Get the "this" pointer
02670           CWaitCursor waitCursor;
02671
02672           //Now that the user has selected to clear all columns, we need to loop through
02673           //all the checked columns and just uncheck them...
02674           INDEX cItems = s_listNames.GetItemCount();
02675           for(INDEX i=0; i<cItems; i++)
02676           {
02677             //Check the property state
02678             s_listNames.SetItemState(i, 0,  INDEXTOSTATEIMAGEMASK(s_bClearAll ? STATE_UNCHECKED : STATE_CHECKED),  LVIS_STATEIMAGEMASK);
02679           }
02680
02681           //Clear All is a toggle...
02682           if(s_bClearAll)
02683           {
02684             s_bClearAll = FALSE;
02685 						::SetWindowText(::GetDlgItem(hWnd, IDB_CLEARALL), "SelectAll");
02686           }
02687           else
02688           {
02689             s_bClearAll = TRUE;
02690 						::SetWindowText(::GetDlgItem(hWnd, IDB_CLEARALL), "ClearAll");
02691           }
02692           return 0;
02693         }
02694
02695         case IDM_DBSTATUS_S_OK:
02696         {
02697           //Insert the Status into the List
02698           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
02699           if(iSelRow == LVM_ERR)
02700             return 0;
02701
02702           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_OK");
02703           return 0;
02704         }
02705
02706         case IDM_DBSTATUS_S_ISNULL:
02707         {
02708           //Insert the Status into the List
02709           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
02710           if(iSelRow == LVM_ERR)
02711             return 0;
02712
02713           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_ISNULL");
02714           return 0;
02715         }
02716
02717         case IDM_DBSTATUS_S_DEFAULT:
02718         {
02719           //Insert the Status into the List
02720           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
02721           if(iSelRow == LVM_ERR)
02722             return 0;
02723
02724           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_DEFAULT");
02725           return 0;
02726         }
02727
02728         case IDM_DBSTATUS_S_IGNORE:
02729         {
02730           //Insert the Status into the List
02731           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
02732           if(iSelRow == LVM_ERR)
02733             return 0;
02734
02735           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_IGNORE");
02736           return 0;
02737         }
02738
02739         case IDM_DISPLAY_HEX:
02740         {
02741           WCHAR wszBuffer[MAX_COL_SIZE+1]={0};
02742
02743           //Find the Selected Row
02744           INDEX iSelRow = s_listValue.GetNextItem(-1, LVNI_SELECTED);
02745           if(iSelRow == LVM_ERR)
02746             return 0;
02747
02748           //Get the Text from the Row
02749           s_listValue.GetItemText(iSelRow, 0, wszBuffer, MAX_COL_SIZE);
02750
02751           //Convert using the Requested converions
02752           if(SUCCEEDED(PostProcessString(wszBuffer, MAX_COL_SIZE, CONV_HEX)))
02753           {
02754             //Insert the Data into the list (make an "easy" edit)
02755             s_listValue.SetItemText(iSelRow, 0, wszBuffer);
02756           }
02757           return 0;
02758         }
02759
02760         case IDOK:
02761         {
02762           CWaitCursor waitCursor;
02763
02764           //Get the "this" pointer
02765           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
02766           HRESULT hr = S_OK;
02767
02768           ULONG i=0;
02769           HROW hRow = NULL;
02770           INDEX iSelItems = 0;
02771
02772           ULONG cColumnIDs = 0;
02773           DBID* rgColumnIDs = NULL;
02774           DBSTATUS* rgStatus = NULL;
02775
02776
02777           //Determine the object type
02778           CRow* pCRow         = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
02779           CRowset* pCRowset     = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
02780           CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
02781           CDataGrid* pCDataGrid   = pThis->m_pCDataGrid;
02782
02783           CBindings& rBindings    = pCDataAccess->m_Bindings;
02784           void* pData         = pCDataAccess->m_pData;
02785
02786           //The ListView will produce IDOK if hitting return after entering
02787           //a value.  The easist way arround this is to just exit if
02788           //we haven't yet received the ENDEDIT message
02789           if(bBeginEdit || (!SOURCE_GETINTERFACE(pCRow, IRowChange) && !SOURCE_GETINTERFACE(pCRowset, IRowsetChange)))
02790             goto CLEANUP;
02791
02792           //Create Accessor binding all selected columns...
02793           iSelItems = s_listNames.GetItemCount();
02794           ASSERT(iSelItems != LVM_ERR);
02795
02796           if(pThis->m_idSource == IDM_IROW_DELETECOLUMNS)
02797           {
02798             SAFE_ALLOC(rgColumnIDs, DBID, iSelItems);
02799             SAFE_ALLOC(rgStatus, DBSTATUS, iSelItems);
02800           }
02801
02802           //Obtain the ListView Values into our pData buffer
02803           //NOTE:  We do this before we filter the selected columns, since the dialog
02804           //contains all columns, and needs to be indexed in the same order,
02805           //without missing columns in the middle...
02806           TESTC(hr = pThis->GetListViewValues(s_listNames.m_hWnd, s_listValue.m_hWnd, pCDataAccess, rBindings, pData));
02807
02808           //Loop through selected bindings
02809           for(i=0; i<rBindings.GetCount(); i++)
02810           {
02811             //Create compacted array of ColumnIDs for IRowSchemaChange::DeleteColumns
02812             if(pThis->m_idSource == IDM_IROW_DELETECOLUMNS)
02813             {
02814               //Get the Image and Param
02815               BOOL bChecked = s_listNames.GetItemState(i, LVIS_STATEIMAGEMASK) & INDEXTOSTATEIMAGEMASK(STATE_CHECKED);
02816               if(bChecked)
02817               {
02818                 memcpy(&rgColumnIDs[cColumnIDs], &pCRow->m_rgColAccess[i].columnid, sizeof(DBID));
02819                 rgStatus[cColumnIDs] = DBSTATUS_S_OK;
02820                 cColumnIDs++;
02821               }
02822             }
02823           }
02824
02825           switch(pThis->m_idSource)
02826           {
02827             case IDM_INSERTROW:
02828               if(pCRowset && pCRowset->m_pIRowsetChange)
02829               {
02830                 HCHAPTER hChapter = pCRowset->m_hChapter;
02831
02832                 //Release previously fetched rows, (if user requested)
02833                 hr = pCDataGrid->ReleaseHeldRows();
02834
02835                 //Now that we have setup the buffer, Insert the data into the rowset
02836                 XTEST(hr = pCRowset->m_pIRowsetChange->InsertRow(hChapter, pCRowset->m_hAccessor, pData, &hRow));
02837                 TRACE_METHOD(hr, L"IRowsetChange::InsertRow(0x%p, 0x%p, 0x%p, &0x%p)", hChapter, pCRowset->m_hAccessor, pData, hRow);
02838
02839                 //Display Data Errors
02840                 TESTC(hr = DisplayBindingErrors(hr, rBindings.GetCount(), rBindings.GetElements(), pData));
02841
02842                 //Release the Retreived Row handle...
02843                 //We could have just passed phRow = NULL, since we don't save the row handle,
02844                 //but its nice for output/trace purposes so the user knows a handle
02845                 //was received...
02846
02847                 //NOTE:  We don't insert the returned row handle into the ListView
02848                 //since we are not sure where the row was inserted.  Inserting it blindly
02849                 //at the end would appear as if the cursor positioning was oof with
02850                 //GetNextRows if it was not truely inserted at the end.
02851                 if(SUCCEEDED(hr))
02852                   pCRowset->ReleaseRows(1, &hRow);
02853               }
02854               break;
02855
02856             case IDM_IROW_DELETECOLUMNS:
02857               if(pCRow && pCRow->m_pIRowSchemaChange)
02858               {
02859                 //DeleteColumns
02860                 XTEST(hr = pCRow->m_pIRowSchemaChange->DeleteColumns(cColumnIDs, rgColumnIDs, rgStatus));
02861                 TRACE_METHOD(hr, L"IRowSchemaChange::DeleteColumns(%lu, 0x%p, 0x%p)", cColumnIDs, rgColumnIDs, rgStatus);
02862
02863                 //Display Data Errors
02864                 TESTC(hr = DisplayColumnErrors(hr, cColumnIDs, rgColumnIDs, rgStatus));
02865               }
02866               break;
02867
02868             case IDM_IROW_SETCOLUMNS:
02869               if(pCRow && pCRow->m_pIRowChange)
02870               {
02871                 //Have to call SetColumns for extra columns
02872                 XTEST(hr = pCRow->m_pIRowChange->SetColumns(pCRow->m_cColAccess, pCRow->m_rgColAccess));
02873                 TRACE_METHOD(hr, L"IRowChange::SetColumns(%lu, 0x%p)", pCRow->m_cColAccess, pCRow->m_rgColAccess);
02874
02875                 //Display Data Errors
02876                 TESTC(hr = DisplayColAccessErrors(hr, pCRow->m_cColAccess, pCRow->m_rgColAccess));
02877               }
02878               break;
02879
02880             case IDM_SETDATA:
02881               if(pCRowset && pCRowset->m_pIRowsetChange)
02882               {
02883                 //Need to obtain the Current hRow value (lParam)
02884                 hRow = pCDataGrid->GetItemParam(pCDataGrid->m_iSelRow);
02885
02886                 //Now that we have setup the buffer, SetData into the rowset
02887                 XTEST(hr = pCRowset->m_pIRowsetChange->SetData(hRow, pCRowset->m_hAccessor, pData));
02888                 TRACE_METHOD(hr, L"IRowsetChange::SetData(0x%p, 0x%p, 0x%p)", hRow, pCRowset->m_hAccessor, pData);
02889
02890                 //Display Data Errors
02891                 TESTC(hr = DisplayBindingErrors(hr, rBindings.GetCount(), rBindings.GetElements(), pData));
02892               }
02893               break;
02894           };
02895
02896           //Its our responsiblity to free the allocated (outofline) data...
02897           //TODO - need to free in the case of errors as well.  But have to be careful
02898           //since the pData may not have been setup yet, or other errors where its undefined...
02899           TESTC(rBindings.FreeData(pData, TRUE/*fSetData*/));
02900
02901           if(pThis->m_idSource != IDM_INSERTROW)
02902           {
02903             //Need to indicate row was modified, use "changed" icon
02904             pCDataGrid->SetItemImage(pCDataGrid->m_iSelRow, 0, IMAGE_CHANGE);
02905
02906             //Display the Data for this Row
02907             TESTC(hr = pCDataGrid->DisplayData(hRow, pCDataGrid->m_iSelRow, pCRow ? DBPROP_IRow : DBPROP_IRowset));
02908           }
02909
02910         CLEANUP:
02911           SAFE_FREE(rgColumnIDs);
02912           SAFE_FREE(rgStatus);
02913
02914           if(SUCCEEDED(hr))
02915             EndDialog(hWnd, TRUE);
02916           return 0;
02917         }
02918
02919         case IDCANCEL:
02920         {
02921           bBeginEdit = FALSE;
02922           EndDialog(hWnd, FALSE);
02923           return 0;
02924         }
02925       }
02926       break;
02927     }//WM_COMMAND
02928
02929
02930     case WM_CONTEXTMENU:
02931     {
02932       HWND hWndSelected = (HWND)wParam;
02933       CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
02934
02935       //Must have selected a row to change status
02936       INDEX iSel = s_listNames.GetNextItem(-1, LVNI_SELECTED);
02937       if(iSel == LVM_ERR)
02938         return FALSE;
02939
02940       //IDL_NAMES
02941       if(hWndSelected == s_listNames.m_hWnd)
02942       {
02943         //Don't need to change the status if readonly
02944         if(!SOURCE_GETINTERFACE(pThis->m_pCSource, IRowChange) && !SOURCE_GETINTERFACE(pThis->m_pCSource, IRowsetChange))
02945           return FALSE;
02946
02947         //Display Menu
02948         DisplayContextMenu(
02949                 hWnd,
02950                 IDM_CHANGESTATUS,
02951                 MAKEPOINTS(lParam),
02952                 hWnd
02953                 );
02954       }
02955
02956       //IDL_VALUES
02957       if(hWndSelected == s_listValue.m_hWnd)
02958       {
02959         //Display Menu
02960         DisplayContextMenu(
02961                 hWnd,
02962                 IDM_CHANGEVALUE,
02963                 MAKEPOINTS(lParam),
02964                 hWnd
02965                 );
02966       }
02967       return FALSE;
02968     }
02969
02970     case WM_NOTIFY:
02971     {
02972       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
02973       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
02974
02975       switch(pDispInfo->hdr.code)
02976       {
02977         //Since we have "TwoClickActive" on this will get sent
02978         //Whenever a row is clicked on twice!
02979         //This functionality used to be done with NM_DBCLK
02980         case LVN_ITEMACTIVATE:
02981         {
02982           //Obtain the SelectedRow
02983           INDEX iSel = (INDEX)SendMessage(::GetDlgItem(hWnd, IDL_VALUES), LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)LVNI_SELECTED);
02984           if(iSel == LVM_ERR)
02985             return 0;
02986
02987           //Need to Send LVM_EDITLABEL
02988           SendMessage(::GetDlgItem(hWnd, IDL_VALUES), LVM_EDITLABEL, iSel, 0);
02989           return 0;
02990         }
02991
02992         case LVN_BEGINLABELEDIT:
02993           bBeginEdit = TRUE;
02994           return FALSE;//allow the user to change the value of the item.
02995
02996         case LVN_ENDLABELEDIT:
02997         {
02998           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
02999           bBeginEdit = FALSE;
03000
03001           //Now update the ListView with the new value
03002           //If IRowsetChange is supported...
03003           if(pDispInfo->item.pszText && (SOURCE_GETINTERFACE(pThis->m_pCSource, IRowChange) || SOURCE_GETINTERFACE(pThis->m_pCSource, IRowsetChange)))
03004           {
03005             WCHAR wszBuffer[MAX_NAME_LEN]={0};
03006             ConvertToWCHAR(pDispInfo->item.pszText, wszBuffer, MAX_NAME_LEN);
03007             s_listValue.SetItemText(pDispInfo->item.iItem, 0, wszBuffer);
03008           }
03009
03010           return TRUE; //Allow the edited change
03011         }
03012
03013         case LVN_ITEMCHANGED:
03014         {
03015           bBeginEdit = FALSE;
03016
03017           if(pNMListView->uNewState & LVNI_FOCUSED &&
03018             pNMListView->uNewState & LVNI_SELECTED)
03019           {
03020             if(wParam == IDL_VALUES)
03021             {
03022               SyncSibling(s_listNames.m_hWnd, s_listValue.m_hWnd);
03023                     return HANDLED_MSG;
03024             }
03025
03026             if(wParam == IDL_NAMES)
03027             {
03028               SyncSibling(s_listValue.m_hWnd, s_listNames.m_hWnd);
03029                       return HANDLED_MSG;
03030             }
03031             return UNHANDLED_MSG; //No return Value
03032           }
03033         }
03034       }
03035     }//WM_NOTIFY
03036   }//switch(message);
03037
03038   return FALSE;
03039 }
03040
03041
03042 ////////////////////////////////////////////////////////////////
03043 // CMDIChild::ColumnChangeProc
03044 //
03045 /////////////////////////////////////////////////////////////////
03046 INT_PTR WINAPI CMDIChild::ColumnChangeProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
03047 {
03048   static BOOL bBeginEdit = FALSE;
03049   static HACCESSOR hAccessor = NULL;
03050   static CListViewLite  s_listNames;
03051   static CListViewLite  s_listValue;
03052
03053   switch(message)
03054   {
03055     case WM_INITDIALOG:
03056     {
03057       CWaitCursor waitCursor;
03058       bBeginEdit = FALSE;
03059       WCHAR wszBuffer[MAX_COL_SIZE+1];
03060       DBLENGTH dbLength = 0;
03061       DBSTATUS dbStatus = 0;
03062       DBTYPE   wSubType = 0;
03063
03064       //Save the "this" pointer
03065       CMDIChild* pThis  = (CMDIChild*)SetThis(hWnd, (void*)lParam);
03066
03067       DWORD dwConvFlags = pThis->GetOptions()->m_dwConvFlags;
03068       INDEX i,iItemCount = 0;
03069       HRESULT hr = S_OK;
03070
03071       //We need to bring up a 2 ListViews.
03072       //left - has column names,
03073       //right - is blank for entering data for the corrsponding column
03074
03075       //Setup column headers
03076       s_listNames.CreateIndirect(hWnd, IDL_NAMES);
03077       s_listValue.CreateIndirect(hWnd, IDL_VALUES);
03078
03079       //Use Extended ListView Styles!
03080       SendMessage(s_listNames.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE , LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
03081       SendMessage(s_listValue.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE , LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
03082
03083       //Set image list to the ListView
03084       ListView_SetImageList(s_listValue.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
03085       ListView_SetImageList(s_listNames.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
03086
03087       //Update Controls
03088 			::EnableWindow(::GetDlgItem(hWnd, IDB_CLEARALL), FALSE);
03089
03090       //Determine the object type
03091       CRow* pCRow         = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
03092       CRowset* pCRowset     = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
03093       CDataset* pCDataset     = SOURCE_GETOBJECT(pThis->m_pCSource, CDataset);
03094       CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
03095       CDataGrid*  pCDataGrid    = pThis->m_pCDataGrid;
03096
03097       //Update Title and Status
03098       switch(pThis->m_idSource)
03099       {
03100         case IDM_IROW_SETCOLUMNS:
03101           if(pCRow && pCRow->m_pIRowChange)
03102           {
03103             SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowChange::SetColumns");
03104             SendMessage(::GetDlgItem(hWnd, IDT_HELPMSG), WM_SETTEXT, 0, (LPARAM)"Modifies the row object columns");
03105             SendMessage(::GetDlgItem(hWnd, IDOK), WM_SETTEXT, 0, (LPARAM)"SetColumns");
03106           }
03107           break;
03108
03109
03110         case IDM_SETDATA:
03111           if(pCRowset && pCRowset->m_pIRowsetChange)
03112           {
03113             SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowsetChange::SetData");
03114             SendMessage(::GetDlgItem(hWnd, IDT_HELPMSG), WM_SETTEXT, 0, (LPARAM)"Modifies the row data in the Rowset");
03115             SendMessage(::GetDlgItem(hWnd, IDOK), WM_SETTEXT, 0, (LPARAM)"SetData");
03116           }
03117           break;
03118       };
03119
03120       //Insert Column Headers
03121       s_listNames.InsertColumn(0, pCDataAccess->GetObjectType() == eCDataset ? L"  Cell Ordinal  " : L"  Row Handle  ");
03122       s_listNames.InsertColumn(1, L"Length");
03123       s_listNames.InsertColumn(2, L"Status");
03124       s_listNames.InsertColumn(3, L"Type");
03125       s_listNames.InsertColumn(4, L"SubType");
03126
03127
03128
03129       const DBBINDING* pBinding   = &pCDataAccess->m_Bindings[pCDataGrid->m_iSelCol];
03130       const DBCOLUMNINFO* pColInfo  = pCDataAccess->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
03131       void* pData           = pCDataAccess->m_pData;
03132
03133       if(!pCRow)
03134       {
03135         //Create An Accessor binding only this column
03136         //Much quicker to get and set using only the column we need.
03137         hr = pCDataAccess->CreateAccessor(DBACCESSOR_ROWDATA, 1, pBinding, 0, &hAccessor);
03138         if(FAILED(hr))
03139           goto CLEANUP2;
03140       }
03141
03142       //Column header is the ColumnName
03143       s_listValue.InsertColumn(0, GetColName(pColInfo), pCDataAccess->GetColumnImage(pColInfo));
03144
03145       //Display Data in the ListView
03146       iItemCount = pCDataGrid->GetItemCount();
03147       for(i=0; i<iItemCount; i++)
03148       {
03149         //Get row handle for the selected row
03150         HROW hRow = pCDataGrid->GetItemParam(i);
03151
03152         if(pCRow)
03153         {
03154           ULONG cColAccess = 1;
03155           DBCOLUMNACCESS* rgColAccess = &pCRow->m_rgColAccess[pCDataGrid->m_iSelCol];
03156
03157           //GetColumn for this row object
03158           //Much quicker to get and set using only the column we need.
03159           hr = pCRow->GetColumns(cColAccess, rgColAccess);
03160         }
03161         else if(pCDataset)
03162         {
03163           //GetCellData
03164           //Note: the "hRow" stored in the listview is the index
03165           hr = pCDataset->GetCellData(hRow, hRow);
03166         }
03167         else if(pCRowset)
03168         {
03169           //GetData for this row from the rowset
03170           //Much quicker to get and set using only the column we need.
03171           hr = pCRowset->GetData(hRow, hAccessor, pData);
03172         }
03173
03174         //Relax the errors here.  With Get*Data both DB_S/DB_E will return a bad
03175         //status for 1 or more columns.  Or DataGrid will just display the column
03176         //status if not S_OK.  So for these errors just display the data anyway...
03177         if(FAILED(hr) && hr!= DB_E_ERRORSOCCURRED)
03178           goto CLEANUP2;
03179         hr = S_OK;  //Otherwise dialog is not displayed
03180
03181         //Get the Length, Status, Data for this Column
03182         pCDataAccess->GetColumnData(pBinding, pData, &dbStatus, &dbLength, &wSubType, wszBuffer, MAX_COL_SIZE, dwConvFlags, pColInfo->wType);
03183
03184         //Insert the Data into the list (make an "easy" edit)
03185         s_listValue.InsertItem(i, 0, wszBuffer, (LPARAM)pColInfo->wType, pCDataAccess->GetColumnImage(pColInfo, dbStatus));
03186
03187         //Display the hRow in the ListView
03188         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", hRow);
03189         s_listNames.InsertItem(i, 0, wszBuffer, 0, 0);
03190
03191         //Insert the Length into the List
03192         if(LENGTH_IS_BOUND(*pBinding))
03193           StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", dbLength);
03194         else
03195           StringCopy(wszBuffer, L"Not Bound", MAX_COL_SIZE);
03196         s_listNames.InsertItem(i, 1, wszBuffer);
03197
03198         //Insert the Status into the List
03199         s_listNames.InsertItem(i, 2, STATUS_IS_BOUND(*pBinding) ? GetStatusName(dbStatus) : L"Not Bound");
03200
03201         //Insert the Type into the List
03202         s_listNames.InsertItem(i, 3, GetDBTypeName(pColInfo->wType));
03203
03204         //Insert the SubType into the List
03205         if(pBinding->wType == DBTYPE_VARIANT)
03206           s_listNames.InsertItem(i, 4, GetVariantTypeName(wSubType));
03207       }
03208
03209       //Free any outofline data
03210       //TODO - need to free in the case of errors as well.  But have to be careful
03211       //since the pData may not have been setup yet, or other errors where its undefined...
03212       if(SUCCEEDED(hr))
03213         FreeBindingData(1, pBinding, pData);
03214
03215       //AutoSize Columns
03216       for(i=0; i<=4; i++)
03217         s_listNames.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);
03218       s_listValue.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
03219
03220     CLEANUP2:
03221       CenterDialog(hWnd);
03222       if(FAILED(hr))
03223       {
03224         pCDataAccess->ReleaseAccessor(&hAccessor);
03225         EndDialog(hWnd, FALSE);
03226       }
03227
03228       return TRUE;
03229     }
03230
03231     case WM_COMMAND:
03232     {
03233       //Filter out any Control Notification codes
03234       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
03235       {
03236         return UNHANDLED_MSG;
03237       }
03238
03239       switch (GET_WM_COMMAND_ID(wParam, lParam))
03240       {
03241         case IDM_DBSTATUS_S_OK:
03242         {
03243           //Insert the Status into the List
03244           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
03245           if(iSelRow == LVM_ERR)
03246             return 0;
03247
03248           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_OK");
03249           return 0;
03250         }
03251
03252         case IDM_DBSTATUS_S_ISNULL:
03253         {
03254           //Insert the Status into the List
03255           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
03256           if(iSelRow == LVM_ERR)
03257             return 0;
03258
03259           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_ISNULL");
03260           return 0;
03261         }
03262
03263         case IDM_DBSTATUS_S_DEFAULT:
03264         {
03265           //Insert the Status into the List
03266           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
03267           if(iSelRow == LVM_ERR)
03268             return 0;
03269
03270           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_DEFAULT");
03271           return 0;
03272         }
03273
03274         case IDM_DBSTATUS_S_IGNORE:
03275         {
03276           //Insert the Status into the List
03277           INDEX iSelRow = s_listNames.GetNextItem(-1, LVNI_SELECTED);
03278           if(iSelRow == LVM_ERR)
03279             return 0;
03280
03281           s_listNames.InsertItem(iSelRow, 2, L"DBSTATUS_S_IGNORE");
03282           return 0;
03283         }
03284
03285         case IDM_DISPLAY_HEX:
03286         {
03287           WCHAR wszBuffer[MAX_COL_SIZE+1] = {0};
03288
03289           //Find the Selected Row
03290           INDEX iSelRow = s_listValue.GetNextItem(-1, LVNI_SELECTED);
03291           if(iSelRow == LVM_ERR)
03292             return 0;
03293
03294           //Get the Text from the Row
03295           s_listValue.GetItemText(iSelRow, 0, wszBuffer, MAX_COL_SIZE);
03296
03297           //Convert using the Requested converions
03298           if(SUCCEEDED(PostProcessString(wszBuffer, MAX_COL_SIZE, CONV_HEX)))
03299           {
03300             //Insert the Data into the list (make an "easy" edit)
03301             s_listValue.SetItemText(iSelRow, 0, wszBuffer);
03302           }
03303           return 0;
03304         }
03305
03306         case IDOK:
03307         {
03308           CWaitCursor waitCursor;
03309           WCHAR wszBuffer[MAX_COL_SIZE+1];
03310
03311           //Get the "this" pointer
03312           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
03313           INDEX i,iItemCount = 0;
03314           HRESULT hr = S_OK;
03315
03316           //Determine the object type
03317           CRow* pCRow         = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
03318           CRowset* pCRowset     = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
03319           CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
03320           CDataGrid*  pCDataGrid    = pThis->m_pCDataGrid;
03321
03322           const DBBINDING* pBinding   = &pCDataAccess->m_Bindings[pCDataGrid->m_iSelCol];
03323           const DBCOLUMNINFO* pColInfo  = pCDataAccess->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
03324           void* pData           = pCDataAccess->m_pData;
03325
03326           //The ListView will produce IDOK if hitting return after entering
03327           //a value.  The easist way arround this is to just exit if
03328           //we haven't yet received the ENDEDIT message
03329           if(bBeginEdit)
03330             goto CLEANUP;
03331
03332           if(!SOURCE_GETINTERFACE(pCRow, IRowChange) && !SOURCE_GETINTERFACE(pCRowset, IRowsetChange))
03333             goto CLEANUP;
03334
03335           //This dialog is a little more complex since were allowing
03336           //the user to change an entire column so every row must be set
03337           //To make our lives a little easier, we will first Get the Data
03338           //for the row, and then Set only the affected column...
03339           iItemCount = s_listValue.GetItemCount();
03340           for(i=0; i<iItemCount; i++)
03341           {
03342             //Get row handle
03343             HROW hRow = pCDataGrid->GetItemParam(i);
03344
03345             //Get the ColumnStatus
03346             s_listNames.GetItemText(i, 2, wszBuffer, MAX_COL_SIZE);
03347             DBSTATUS dbStatus = GetStatusValue(wszBuffer);
03348
03349             //Set the ColumnData in our pData buffer
03350             s_listValue.GetItemText(i, 0, wszBuffer, MAX_COL_SIZE);
03351             TESTC(hr = pCDataAccess->SetColumnData(pBinding, pData, dbStatus, wcslen(wszBuffer), wszBuffer, CONV_NONE, pColInfo->wType));
03352
03353             if(pCRow)
03354             {
03355               ULONG cColAccess = 1;
03356               DBCOLUMNACCESS* rgColAccess = &pCRow->m_rgColAccess[pCDataGrid->m_iSelCol];
03357
03358               //Have to call SetColumns for extra columns
03359               XTEST(hr = pCRow->m_pIRowChange->SetColumns(cColAccess, rgColAccess));
03360               TRACE_METHOD(hr, L"IRowChange::SetColumns(%lu, 0x%p)", cColAccess, rgColAccess);
03361
03362               //Display Data Errors...
03363               TESTC(hr = DisplayColAccessErrors(hr, cColAccess, rgColAccess));
03364             }
03365             else if(pCRowset)
03366             {
03367               //Now that we have setup the buffer, SetData into the rowset
03368               XTEST(hr = pCRowset->m_pIRowsetChange->SetData(hRow, hAccessor, pData));
03369               TRACE_METHOD(hr, L"IRowsetChange::SetData(0x%p, 0x%p, 0x%p)", hRow, hAccessor, pData);
03370
03371               //Display Data Errors...
03372               TESTC(hr = DisplayBindingErrors(hr, 1, pBinding, pData));
03373             }
03374
03375             //Need to indicate row was modified, use "changed" icon
03376             pCDataGrid->SetItemImage(pCDataGrid->m_iSelRow, 0, IMAGE_CHANGE);
03377
03378             //Display the Data for this Row
03379             TESTC(hr = pCDataGrid->DisplayData(hRow, i, pCRow ? DBPROP_IRow : DBPROP_IRowset));
03380           }
03381
03382           //Free outofline data
03383           //TODO - need to free in the case of errors as well.  But have to be careful
03384           //since the pData may not have been setup yet, or other errors where its undefined...
03385           FreeBindingData(1, pBinding, pData, TRUE/*fSetData*/);
03386
03387         CLEANUP:
03388           if(SUCCEEDED(hr))
03389           {
03390             pCDataAccess->ReleaseAccessor(&hAccessor);
03391             EndDialog(hWnd, TRUE);
03392           }
03393           return 0;
03394         }
03395
03396         case IDCANCEL:
03397         {
03398           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
03399           CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
03400           bBeginEdit = FALSE;
03401
03402           pCDataAccess->ReleaseAccessor(&hAccessor);
03403           EndDialog(hWnd, FALSE);
03404           return 0;
03405         }
03406       }
03407       break;
03408     }//WM_COMMAND
03409
03410     case WM_CONTEXTMENU:
03411     {
03412       HWND hWndSelected = (HWND)wParam;
03413       CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
03414
03415       //Must have selected a row to change status
03416       INDEX iSel = s_listNames.GetNextItem(-1, LVNI_SELECTED);
03417       if(iSel == LVM_ERR)
03418         return FALSE;
03419
03420       //IDL_NAMES
03421       if(hWndSelected == s_listNames.m_hWnd)
03422       {
03423         //Don't need to change the status if readonly
03424         if(SOURCE_GETINTERFACE(pThis->m_pCSource, IRowChange) && SOURCE_GETINTERFACE(pThis->m_pCSource, IRowsetChange))
03425           return FALSE;
03426
03427         //Display Menu
03428         DisplayContextMenu(
03429                   hWnd,
03430                   IDM_CHANGESTATUS,
03431                   MAKEPOINTS(lParam),
03432                   hWnd
03433                   );
03434       }
03435
03436       //IDL_VALUES
03437       if(hWndSelected == s_listValue.m_hWnd)
03438       {
03439         //Display Menu
03440         DisplayContextMenu(
03441                 hWnd,
03442                 IDM_CHANGEVALUE,
03443                 MAKEPOINTS(lParam),
03444                 hWnd
03445                 );
03446       }
03447       return FALSE;
03448     }
03449
03450     case WM_NOTIFY:
03451     {
03452       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
03453       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
03454
03455       switch(pDispInfo->hdr.code)
03456       {
03457         //Since we have "TwoClickActive" on this will get sent
03458         //Whenever a row is clicked on twice!
03459         //This functionality used to be done with NM_DBCLK
03460         case LVN_ITEMACTIVATE:
03461         {
03462           //Save the SelectedRow so the new dialog box knows which row were concerned with...
03463           INDEX iSel = (INDEX)SendMessage(::GetDlgItem(hWnd, IDL_VALUES), LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)LVNI_SELECTED);
03464           if(iSel == LVM_ERR)
03465             return 0;
03466
03467           //Need to Send LVM_EDITLABEL
03468           SendMessage(::GetDlgItem(hWnd, IDL_VALUES), LVM_EDITLABEL, iSel, 0);
03469           return FALSE;
03470         }
03471
03472         case LVN_BEGINLABELEDIT:
03473           bBeginEdit = TRUE;
03474           return FALSE;//allow the user to change the value of the item.
03475
03476         case LVN_ENDLABELEDIT:
03477         {
03478           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
03479           bBeginEdit = FALSE;
03480
03481           //Now update the ListView with the new value
03482           if(pDispInfo->item.pszText && (SOURCE_GETINTERFACE(pThis->m_pCSource, IRowChange) || SOURCE_GETINTERFACE(pThis->m_pCSource, IRowsetChange)))
03483           {
03484             WCHAR wszBuffer[MAX_NAME_LEN]={0};
03485             ConvertToWCHAR(pDispInfo->item.pszText, wszBuffer, MAX_NAME_LEN);
03486             s_listValue.SetItemText(pDispInfo->item.iItem, 0, wszBuffer);
03487           }
03488
03489           return TRUE; //Allow the edited change
03490         }
03491
03492         case LVN_ITEMCHANGED:
03493         {
03494           if(pNMListView->uNewState & LVNI_FOCUSED &&
03495             pNMListView->uNewState & LVNI_SELECTED)
03496           {
03497             if(wParam == IDL_VALUES)
03498             {
03499               SyncSibling(s_listNames.m_hWnd, s_listValue.m_hWnd);
03500                     return HANDLED_MSG;
03501             }
03502
03503             if(wParam == IDL_NAMES)
03504             {
03505               SyncSibling(s_listValue.m_hWnd, s_listNames.m_hWnd);
03506                       return HANDLED_MSG;
03507             }
03508             return UNHANDLED_MSG; //No return Value
03509           }
03510         }
03511       }
03512     }//WM_NOTIFY
03513   }//switch(message);
03514
03515   return FALSE;
03516 }
03517
03518
03519 ////////////////////////////////////////////////////////////////
03520 // CMDIChild::GetAxisInfoProc
03521 //
03522 /////////////////////////////////////////////////////////////////
03523 INT_PTR WINAPI CMDIChild::GetAxisInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
03524 {
03525   static BOOL bBeginEdit = FALSE;
03526   static CListViewLite  s_listAxisInfo;
03527   static CComboBoxLite  s_comboAxis;
03528
03529   switch(message)
03530   {
03531     case WM_INITDIALOG:
03532     {
03533       CWaitCursor waitCursor;
03534       bBeginEdit = FALSE;
03535       HRESULT hr = S_OK;
03536
03537       //Save the "this" pointer
03538       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
03539       CDataset* pCDataset = SOURCE_GETOBJECT(pThis->m_pCDataAccess, CDataset);
03540       DBCOUNTITEM cAxis;
03541       MDAXISINFO *rgAxisInfo;
03542       WCHAR wszBuffer[MAX_NAME_LEN];
03543
03544       //Setup the ListView
03545       s_listAxisInfo.CreateIndirect(hWnd, IDL_AXISINFO);
03546       s_comboAxis.CreateIndirect(hWnd, IDCOMBO_AXIS);
03547
03548       //Use Extended ListView Styles!
03549       SendMessage(s_listAxisInfo.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE , LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
03550
03551       //Insert Column Headers
03552       s_listAxisInfo.InsertColumn(0, L"Dimension Names");
03553       s_listAxisInfo.InsertColumn(1, L"Columns");
03554
03555       // get the axis info from the dataset
03556       ASSERT(pCDataset);
03557       hr = pCDataset->GetAxisInfo(&cAxis, &rgAxisInfo);
03558
03559       if (SUCCEEDED(hr) && cAxis != 0)
03560       {
03561         // fill in the axis selection combo
03562         for (ULONG iAxis=0; iAxis<cAxis-1; iAxis++)
03563         {
03564           switch (iAxis)
03565           {
03566             case 0:
03567               s_comboAxis.AddString(L"Columns");
03568               break;
03569
03570             case 1:
03571               s_comboAxis.AddString(L"Rows");
03572               break;
03573
03574             default:
03575               StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", iAxis);
03576               s_comboAxis.AddString(wszBuffer);
03577               break;
03578           };
03579         }
03580
03581         s_comboAxis.AddString(L"Slicer");
03582         s_comboAxis.SetCurSel(0);
03583
03584         wSendMessageFmt(::GetDlgItem(hWnd, IDC_DIMENSIONS), WM_SETTEXT, 0, L"%lu", rgAxisInfo->cDimensions);
03585         wSendMessageFmt(::GetDlgItem(hWnd, IDC_COORDINATES), WM_SETTEXT, 0, L"%lu", rgAxisInfo->cCoordinates);
03586
03587         //Display Dimension Names in LeftPane, and Column Count in right pane
03588         for(ULONG iDim=0; iDim<rgAxisInfo->cDimensions; iDim++)
03589         {
03590           s_listAxisInfo.InsertItem(iDim, 0, rgAxisInfo->rgpwszDimensionNames[iDim]);
03591
03592           StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", rgAxisInfo->rgcColumns[iDim]);
03593           s_listAxisInfo.InsertItem(iDim, 1, wszBuffer);
03594         }
03595       }
03596
03597       //AutoSize Columns
03598       s_listAxisInfo.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
03599       s_listAxisInfo.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
03600       CenterDialog(hWnd);
03601
03602       //Cleanup
03603       pCDataset->FreeAxisInfo(&cAxis, &rgAxisInfo);
03604       return TRUE;
03605     }
03606
03607     case WM_COMMAND:
03608     {
03609       switch (GET_WM_COMMAND_ID(wParam, lParam))
03610       {
03611         case IDOK:
03612         {
03613           CWaitCursor waitCursor;
03614
03615           //The ListView will produce IDOK if hitting return after
03616           //entering a value.  The easist way arround this is to just exit if
03617           //we haven't yet received the ENDEDIT message
03618           if(bBeginEdit)
03619             return FALSE;
03620
03621           EndDialog(hWnd, TRUE);
03622           return 0;
03623         }
03624
03625         case IDCANCEL:
03626         {
03627           EndDialog(hWnd, TRUE);
03628           return 0;
03629         }
03630
03631         case IDCOMBO_AXIS:
03632         {
03633           switch(GET_WM_COMMAND_CMD(wParam, lParam))
03634           {
03635             //Selection change in axis combo box
03636             case CBN_SELCHANGE:
03637             {
03638               HRESULT hr = S_OK;
03639               DBCOUNTITEM cAxis;
03640               MDAXISINFO *rgAxisInfo;
03641               WCHAR wszBuffer[MAX_NAME_LEN];
03642               CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
03643               CDataset* pCDataset = SOURCE_GETOBJECT(pThis->m_pCDataAccess, CDataset);
03644
03645               INDEX iAxis = s_comboAxis.GetCurSel();
03646               s_listAxisInfo.DeleteAllItems();
03647
03648               // get the axis info from the dataset
03649               ASSERT(pCDataset);
03650               hr = pCDataset->GetAxisInfo(&cAxis, &rgAxisInfo);
03651               if (SUCCEEDED(hr) && cAxis >= (DBCOUNTITEM)iAxis)
03652               {
03653                 wSendMessageFmt(::GetDlgItem(hWnd, IDC_DIMENSIONS), WM_SETTEXT, 0, L"%lu", rgAxisInfo[iAxis].cDimensions);
03654                 wSendMessageFmt(::GetDlgItem(hWnd, IDC_COORDINATES), WM_SETTEXT, 0, L"%lu", rgAxisInfo[iAxis].cCoordinates);
03655
03656                 //Display Dimension Names in LeftPane, and Column Count in right pane
03657                 for(ULONG iDim=0; iDim<rgAxisInfo[iAxis].cDimensions; iDim++)
03658                 {
03659                   s_listAxisInfo.InsertItem(iDim, 0, rgAxisInfo[iAxis].rgpwszDimensionNames[iDim]);
03660
03661                   StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", rgAxisInfo[iAxis].rgcColumns[iDim]);
03662                   s_listAxisInfo.InsertItem(iDim, 1, wszBuffer);
03663                 }
03664               }
03665
03666               //Cleanup
03667               pCDataset->FreeAxisInfo(&cAxis, &rgAxisInfo);
03668               return 0;
03669             }
03670           }
03671         }
03672       }
03673       break;
03674     }//WM_COMMAND
03675   }//switch(message);
03676   return FALSE;
03677 }
03678
03679
03680 ////////////////////////////////////////////////////////////////
03681 // CMDIChild::GetAxisRowsetProc
03682 //
03683 /////////////////////////////////////////////////////////////////
03684 INT_PTR WINAPI CMDIChild::GetAxisRowsetProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
03685 {
03686   static CComboBoxGuid    s_CComboInterface;
03687   static CComboBoxLite    s_comboAxis;
03688
03689   static BOOL fUseProps   = TRUE;     //Default
03690   static BOOL fAggregation  = FALSE;    //Default
03691   static BOOL fOutput     = TRUE;     //Default
03692
03693   switch(message)
03694   {
03695     case WM_INITDIALOG:
03696     {
03697       CWaitCursor waitCursor;
03698       HRESULT hr = S_OK;
03699
03700       //Save the "this" pointer
03701       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
03702       CDataset* pCDataset = SOURCE_GETOBJECT(pThis->m_pCDataAccess, CDataset);
03703       DBCOUNTITEM cAxis;
03704       MDAXISINFO *rgAxisInfo;
03705       WCHAR wszBuffer[MAX_NAME_LEN];
03706
03707       //Setup the Combo
03708       s_comboAxis.CreateIndirect(hWnd, IDCOMBO_AXIS);
03709
03710       // get the axis info from the dataset
03711       ASSERT(pCDataset);
03712       hr = pCDataset->GetAxisInfo(&cAxis, &rgAxisInfo);
03713
03714       if(SUCCEEDED(hr) && cAxis)
03715       {
03716         // fill in the axis selection combo
03717         for (ULONG iAxis=0; iAxis<cAxis-1; iAxis++)
03718         {
03719           switch (iAxis)
03720           {
03721             case 0:
03722               s_comboAxis.AddString(L"Columns");
03723               break;
03724
03725             case 1:
03726               s_comboAxis.AddString(L"Rows");
03727               break;
03728
03729             default:
03730               StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", iAxis);
03731               s_comboAxis.AddString(wszBuffer);
03732               break;
03733           };
03734         }
03735
03736         s_comboAxis.AddString(L"Slicer");
03737         s_comboAxis.SetCurSel(0);
03738       }
03739
03740       //Use Properties
03741 			::CheckDlgButton(hWnd, IDB_USEPROPERTIES,  BST2STATE(fUseProps));
03742
03743       //Aggregation
03744 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
03745
03746       //Output (ppIUnknown)
03747 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
03748
03749       //Interface List...
03750       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
03751       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
03752       if(s_CComboInterface.RestoreSelection() == CB_ERR)
03753         s_CComboInterface.SetGuid(IID_IRowset);
03754
03755       //Cleanup
03756       pCDataset->FreeAxisInfo(&cAxis, &rgAxisInfo);
03757       CenterDialog(hWnd);
03758       return TRUE;
03759     }
03760
03761     case WM_COMMAND:
03762     {
03763       switch (GET_WM_COMMAND_ID(wParam, lParam))
03764       {
03765         case IDB_SETPROPERTIES:
03766         {
03767           //Get the "this" pointer
03768           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
03769           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
03770           CDataSource* pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
03771
03772           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
03773           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &pThis->m_CDefPropSets);
03774           return 0;
03775         }
03776
03777         case IDB_AGGREGATION:
03778         {
03779           //Aggregation Combo Selection has changed...
03780           //If we are now using Aggregation, automatically change the requested
03781           //riid to IID_IUnknown, since its an error otherwise...
03782           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
03783             s_CComboInterface.SetGuid(IID_IUnknown);
03784           return 0;
03785         }
03786
03787         case IDOK:
03788         {
03789           CWaitCursor waitCursor;
03790
03791           //Get the "this" pointer
03792           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
03793           CDataset* pCDataset = SOURCE_GETOBJECT(pThis->m_pCDataAccess, CDataset);
03794           CComPtr<IUnknown> spUnknown;
03795           HRESULT hr = S_OK;
03796
03797           ULONG cPropSets = 0;
03798           DBPROPSET* rgPropSets = NULL;
03799
03800           //Obtain the Aggregation argument
03801           CAggregate* pCAggregate = NULL;
03802           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
03803           if(fAggregation)
03804             pCAggregate = new CAggregate();
03805
03806           //Obtain the Output (ppIUnknown) argument
03807           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
03808
03809           //Interface
03810           REFIID riid = s_CComboInterface.GetGuid();
03811
03812           //Use Properties
03813           fUseProps = ::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES);
03814           if(fUseProps)
03815           {
03816             cPropSets = pThis->m_CDefPropSets.GetCount();
03817             rgPropSets = pThis->m_CDefPropSets.GetPropSets();
03818           }
03819
03820           //Obtain the selected Axis
03821           ASSERT(pCDataset);
03822           DBCOUNTITEM iAxis = s_comboAxis.GetCurSel();
03823
03824           //GetAxisRowset
03825           if(SUCCEEDED(hr = pCDataset->GetAxisRowset(pCAggregate, iAxis, riid, cPropSets, rgPropSets, fOutput ? &spUnknown : NULL)))
03826           {
03827             //Now that we have the rowset, display it...
03828             //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
03829             if(!pThis->m_pCMainWindow->HandleObjectType(pCDataset, spUnknown, riid, eCRowset, 0, NULL, CREATE_NEWWINDOW | CREATE_DETERMINE_TYPE))
03830               TESTC(hr = E_FAIL);
03831           }
03832
03833         CLEANUP:
03834           SAFE_RELEASE(pCAggregate);
03835           if(SUCCEEDED(hr))
03836             EndDialog(hWnd, TRUE);
03837           return 0;
03838         }
03839
03840         case IDCANCEL:
03841         {
03842           EndDialog(hWnd, TRUE);
03843           return 0;
03844         }
03845       }
03846       break;
03847     }//WM_COMMAND
03848   }//switch(message);
03849   return FALSE;
03850 }
03851
03852
03853 ////////////////////////////////////////////////////////////////
03854 // CMDIChild::GetColInfoProc
03855 //
03856 /////////////////////////////////////////////////////////////////
03857 INT_PTR WINAPI CMDIChild::GetColInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
03858 {
03859   switch(message)
03860   {
03861     case WM_INITDIALOG:
03862     {
03863       CWaitCursor waitCursor;
03864       WCHAR wszBuffer[MAX_NAME_LEN+1];
03865
03866       //Save the "this" pointer
03867       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
03868       CDataAccess* pCDataAccess = NULL;
03869       HRESULT hr = S_OK;
03870
03871       ULONG i=0;
03872       DBORDINAL cColumns = 0;
03873       DBCOLUMNINFO* rgColInfo = NULL;
03874       WCHAR* pStringBuffer = NULL;
03875       DBORDINAL cHiddenColumns = 0;
03876       CColumnInfo rColumnInfo;
03877
03878       //Setup column headers
03879       //We have 2 listviews.
03880       // 1.  Left - ColInfo types...
03881       // 2.  Right - All ColInfo for all columns
03882       HWND hWndName = ::GetDlgItem(hWnd, IDL_NAMES);
03883       HWND hWndCol  = ::GetDlgItem(hWnd, IDL_VALUES);
03884       HWND hWndHelp = ::GetDlgItem(hWnd, IDT_HELPMSG);
03885
03886       //Set Window Titles
03887       SendMessage(hWnd,   WM_SETTEXT, 0, (LPARAM)"IColumnsInfo::GetColumnInfo");
03888       SendMessage(hWndHelp, WM_SETTEXT, 0, (LPARAM)"Displays the (meta-data) Column Information");
03889
03890       //Use Extended ListView Styles!
03891       SendMessage(hWndName, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
03892       SendMessage(hWndCol, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
03893
03894       //Set image list to the Table Window
03895       ListView_SetImageList(hWndCol, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
03896       ListView_SetImageList(hWndName, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
03897
03898       //Ensure this is a CDataAccess derived class...
03899       pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
03900       ASSERT(pCDataAccess);
03901
03902       //Now Obtain ColumnsInfo
03903       TESTC(hr = pCDataAccess->GetColInfo(&cColumns, &rgColInfo, &pStringBuffer, &cHiddenColumns));
03904       rColumnInfo.Attach(cColumns, rgColInfo, pStringBuffer, cHiddenColumns);
03905
03906       //We need to the ListView
03907       //Headers/Columns contain ColInfo information
03908       //Rows are per columns
03909
03910       //ListView NAMES
03911       LV_InsertColumn(hWndName, 0,      L"ColName");
03912       LV_InsertItem(hWndName,   1,    0,  L"Ordinal");
03913       LV_InsertItem(hWndName,   2,    0,  L"Type");
03914       LV_InsertItem(hWndName,   3,    0,  L"ColumnSize");
03915       LV_InsertItem(hWndName,   4,    0,  L"Precision");
03916       LV_InsertItem(hWndName,   5,    0,  L"Scale");
03917       LV_InsertItem(hWndName,   6,    0,  L"TypeInfo");
03918       LV_InsertItem(hWndName,   7,    0,  L"ColumnID");
03919       LV_InsertItem(hWndName,   8,    0,  L"dwFlags");
03920
03921       //Loop through the ColumnFlags
03922       for(i=0; i<g_cColFlagsMaps; i++)
03923         LV_InsertItem(hWndName,   9+i,  0,  g_rgColFlagsMaps[i].pwszName);
03924
03925       //AutoSize column
03926       SendMessage(hWndName, LVM_SETCOLUMNWIDTH, 0,    (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
03927
03928       for(i=0; i<cColumns; i++)
03929       {
03930         ASSERT(rgColInfo);
03931         const DBCOLUMNINFO* pColInfo = &rColumnInfo[i];
03932
03933         //Column Header
03934         LV_InsertColumn(hWndCol, i, GetColName(pColInfo), pCDataAccess->GetColumnImage(pColInfo)==IMAGE_LOCK ? IMAGE_LOCK : IMAGE_NONE);
03935
03936         //Ordinal (SubItem)
03937         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%ld", pColInfo->iOrdinal);
03938         LV_InsertItem(hWndCol, 0, i, wszBuffer);
03939
03940         //TYPE (subitem)
03941         LV_InsertItem(hWndCol, 1, i, GetDBTypeName(pColInfo->wType));
03942
03943         //ColumnSize (SubItem)
03944         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pColInfo->ulColumnSize);
03945         LV_InsertItem(hWndCol, 2, i, wszBuffer);
03946
03947         //Precision (SubItem)
03948         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pColInfo->bPrecision);
03949         LV_InsertItem(hWndCol, 3, i, wszBuffer);
03950
03951         //Scale (SubItem)
03952         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pColInfo->bScale);
03953         LV_InsertItem(hWndCol, 4, i, wszBuffer);
03954
03955         //TypeInfo (SubItem)
03956         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pColInfo->pTypeInfo);
03957         LV_InsertItem(hWndCol, 5, i, wszBuffer);
03958
03959         //ColumnID (SubItem)  DBID
03960         DBIDToString(&pColInfo->columnid, wszBuffer, MAX_NAME_LEN);
03961         LV_InsertItem(hWndCol, 6, i, wszBuffer);
03962
03963         //dwFlags
03964         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pColInfo->dwFlags);
03965         LV_InsertItem(hWndCol, 7, i, wszBuffer);
03966
03967         //FLAGS (SubItem)
03968         for(ULONG iFlag=0; iFlag<g_cColFlagsMaps; iFlag++)
03969           LV_InsertItem(hWndCol, 8+iFlag, i, NULL, PARAM_NONE, pColInfo->dwFlags & g_rgColFlagsMaps[iFlag].lItem  ? IMAGE_CHECKED : IMAGE_UNCHECKED);
03970       }
03971
03972       //AutoSize all columns
03973       for(i=0; i<cColumns; i++)
03974         SendMessage(hWndCol, LVM_SETCOLUMNWIDTH, (WPARAM)i,   (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
03975
03976     CLEANUP:
03977       CenterDialog(hWnd);
03978       if(FAILED(hr))
03979         EndDialog(hWnd, FALSE);
03980       return TRUE;
03981     }
03982
03983     case WM_COMMAND:
03984     {
03985       //Filter out any Control Notification codes
03986       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
03987       {
03988         return UNHANDLED_MSG;
03989       }
03990
03991       switch (GET_WM_COMMAND_ID(wParam, lParam))
03992       {
03993         case IDOK:
03994         {
03995           CWaitCursor waitCursor;
03996           EndDialog(hWnd, TRUE);
03997           return 0;
03998         }
03999
04000         case IDCANCEL:
04001         {
04002           EndDialog(hWnd, FALSE);
04003           return 0;
04004         }
04005       }
04006       break;
04007     }//WM_COMMAND
04008
04009     case WM_NOTIFY:
04010     {
04011       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
04012       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
04013
04014       //ListView
04015       switch(pDispInfo->hdr.code)
04016       {
04017         //Since we have "TwoClickActive" on this will get sent
04018         //Whenever a row is clicked on twice!
04019         //This functionality used to be done with NM_DBCLK
04020         case LVN_ITEMACTIVATE:
04021           return 0;
04022
04023         case LVN_ITEMCHANGED:
04024         {
04025           HWND hWndName  = ::GetDlgItem(hWnd, IDL_NAMES);
04026           HWND hWndCol   = ::GetDlgItem(hWnd, IDL_VALUES);
04027
04028           if(pNMListView->uNewState & LVNI_FOCUSED &&
04029             pNMListView->uNewState & LVNI_SELECTED)
04030           {
04031             if(wParam == IDL_VALUES)
04032             {
04033               SyncSibling(hWndName, hWndCol);
04034                     return FALSE;
04035             }
04036
04037             if(wParam == IDL_NAMES)
04038             {
04039               SyncSibling(hWndCol, hWndName);
04040                       return FALSE;
04041             }
04042             return UNHANDLED_MSG; //No return Value
04043           }
04044         }
04045       }
04046
04047
04048     }//WM_NOTIFY
04049   }//switch message
04050
04051   return FALSE;
04052 }
04053
04054
04055 ////////////////////////////////////////////////////////////////
04056 // CMDIChild::GetNextRowsProc
04057 //
04058 /////////////////////////////////////////////////////////////////
04059 INT_PTR WINAPI CMDIChild::GetNextRowsProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04060 {
04061   static LONG s_lOffset = 0;  //Default to lOffset==0
04062   static LONG s_cRows   = 1;  //Default to cRows==1
04063
04064   switch(message)
04065   {
04066     case WM_INITDIALOG:
04067     {
04068       CWaitCursor waitCursor;
04069
04070       //Save the "this" pointer
04071       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
04072
04073       //Setup Window Handles
04074       HWND hWndOffset   = ::GetDlgItem(hWnd, IDE_OFFSET);
04075       HWND hWndcRows    = ::GetDlgItem(hWnd, IDE_COUNT);
04076
04077       //SetWindowTitle (default is Rowset::GetNextRows)
04078       if(pThis->m_idSource == IDM_IROWSETLOCATE_GETROWSAT)
04079         SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"IRowsetLocate::GetRowsAt");
04080
04081       //Supply Defaults to the lOffset and cRows
04082       wSendMessageFmt(hWndOffset, WM_SETTEXT, 0, L"%ld", s_lOffset);
04083       wSendMessageFmt(hWndcRows, WM_SETTEXT, 0, L"%ld", s_cRows);
04084
04085       CenterDialog(hWnd);
04086       return TRUE;
04087     }
04088
04089     case WM_COMMAND:
04090     {
04091       //Filter out any Control Notification codes
04092       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
04093       {
04094         return UNHANDLED_MSG;
04095       }
04096
04097       switch (GET_WM_COMMAND_ID(wParam, lParam))
04098       {
04099         case IDOK:
04100         {
04101           CWaitCursor waitCursor;
04102
04103           //Get the "this" pointer
04104           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
04105           CRowset* pCRowset     = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
04106           CDataGrid*  pCDataGrid    = pThis->m_pCDataGrid;
04107           HRESULT hr = S_OK;
04108
04109           //Setup Window Handles
04110           HWND hWndOffset   = ::GetDlgItem(hWnd, IDE_OFFSET);
04111           HWND hWndcRows    = ::GetDlgItem(hWnd, IDE_COUNT);
04112
04113           //Obtain Defaults to the lOffset and cRows
04114           GetEditBoxValue(hWndOffset, &s_lOffset);
04115           GetEditBoxValue(hWndcRows, &s_cRows);
04116
04117           switch(pThis->m_idSource)
04118           {
04119             case IDM_GETNEXTROWS:
04120             {
04121               //Display the indicated rows
04122               TESTC(hr = pCDataGrid->GetNextRows(s_lOffset, s_cRows));
04123               break;
04124             }
04125
04126             case IDM_IROWSETLOCATE_GETROWSAT:
04127             {
04128               INDEX  cSelItems = 0;
04129               INDEX* rgSelItems = 0;
04130               HROW* rghRowsSel = NULL;
04131               DBBKMARK cbBookmark = 0;
04132               BYTE* pBookmark = NULL;
04133               DBCOUNTITEM cRowsObtained = 0;
04134               HROW* rghRows = NULL;
04135
04136               //Obtain all Selected Rows
04137               LV_GetSelItems(pCDataGrid->m_hWnd, &cSelItems, &rgSelItems, (LPARAM**)&rghRowsSel);
04138
04139               //Obtain the bookmark for the first row selected...
04140               if(cSelItems)
04141                 hr = pCRowset->GetBookmark(rghRowsSel[0], &cbBookmark, &pBookmark);
04142
04143               //Release previously fetched rows, (if user requested)
04144               hr = pCDataGrid->ReleaseHeldRows();
04145
04146               //IRowsetLocate::GetRowsAt
04147               XTEST(hr = pCRowset->m_pIRowsetLocate->GetRowsAt(pCRowset->m_hChapter, NULL, cbBookmark, pBookmark, s_lOffset, s_cRows, &cRowsObtained, &rghRows));
04148               TRACE_METHOD(hr, L"IRowsetLocate::GetRowsAt(0x%p, NULL, %lu, 0x%p, %ld, %ld, &%lu, &0x%p)", pCRowset->m_hChapter, cbBookmark, pBookmark, s_lOffset, s_cRows, cRowsObtained, rghRows);
04149
04150               //Display the rows retrieved...
04151               //NOTE: GetRowsAt has a much simplier starting for than GetNextRows.  Its basically
04152               //the bookmark + offset = starting row.  Whereas GetNextRows also depends upon
04153               //what the last fetch direction was, forward or backward.
04154               pCDataGrid->DisplayRows(rgSelItems[0] + s_lOffset, s_cRows, cRowsObtained, rghRows, FALSE/*fAdjustFetchPosition*/);
04155
04156               //Cleanup
04157               SAFE_FREE(rgSelItems);
04158               SAFE_FREE(rghRowsSel);
04159               SAFE_FREE(rghRows);
04160               SAFE_FREE(pBookmark);
04161               break;
04162             }
04163           };
04164
04165         CLEANUP:
04166           if(SUCCEEDED(hr))
04167             EndDialog(hWnd, TRUE);
04168           return 0;
04169         }
04170
04171         case IDCANCEL:
04172         {
04173           EndDialog(hWnd, FALSE);
04174           return 0;
04175         }
04176       }
04177       break;
04178     }//WM_COMMAND
04179
04180     case WM_NOTIFY:
04181     {
04182       NM_UPDOWN* pUpDown = (NM_UPDOWN*)lParam;
04183
04184       //lOffset
04185       if(pUpDown->hdr.idFrom == IDC_SPIN_OFFSET)
04186       {
04187         s_lOffset += pUpDown->iDelta;
04188         wSendMessageFmt(::GetDlgItem(hWnd, IDE_OFFSET), WM_SETTEXT, 0, L"%ld", s_lOffset);
04189       }
04190
04191       //cRows
04192       if(pUpDown->hdr.idFrom == IDC_SPIN_COUNT)
04193       {
04194         s_cRows += pUpDown->iDelta;
04195         wSendMessageFmt(::GetDlgItem(hWnd, IDE_COUNT), WM_SETTEXT, 0, L"%ld", s_cRows);
04196       }
04197
04198       break;
04199     }//WM_NOTIFY
04200   }//switch message
04201
04202   return FALSE;
04203 }
04204
04205
04206 ////////////////////////////////////////////////////////////////
04207 // CMDIChild::GetBindingsProc
04208 //
04209 /////////////////////////////////////////////////////////////////
04210 INT_PTR WINAPI CMDIChild::GetBindingsProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04211 {
04212   switch(message)
04213   {
04214     case WM_INITDIALOG:
04215     {
04216       CWaitCursor waitCursor;
04217       WCHAR wszBuffer[MAX_NAME_LEN+1];
04218
04219       //Save the "this" pointer
04220       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
04221       HRESULT hr = S_OK;
04222
04223       //Determine which object this is called from
04224       CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
04225       ASSERT(pCDataAccess);
04226
04227       ULONG i = 0;
04228       DBCOUNTITEM cBindings = 0;
04229       DBBINDING* rgBindings = NULL;
04230       DBACCESSORFLAGS dwAccessorFlags = 0;
04231
04232       //Setup column headers
04233       HWND hWndName   = ::GetDlgItem(hWnd, IDL_NAMES);
04234       HWND hWndValue    = ::GetDlgItem(hWnd, IDL_VALUES);
04235       HWND hWndHelp   = ::GetDlgItem(hWnd, IDT_HELPMSG);
04236
04237       //Set Window Titles
04238       SendMessage(hWnd,   WM_SETTEXT, 0, (LPARAM)"IAccessor::GetBindings");
04239       SendMessage(hWndHelp, WM_SETTEXT, 0, (LPARAM)"Displays the rgBindings from the Accessor");
04240
04241       //Use Extended ListView Styles!
04242       SendMessage(hWndName, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
04243       SendMessage(hWndValue,  LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
04244
04245       //Set image list to the Window
04246       ListView_SetImageList(hWndName, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
04247       ListView_SetImageList(hWndValue, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
04248
04249       //Now IAccessor::GetBindings
04250       ASSERT(pCDataAccess->m_pIAccessor);
04251       XTEST(hr = pCDataAccess->m_pIAccessor->GetBindings(pCDataAccess->m_hAccessor, &dwAccessorFlags, &cBindings, &rgBindings));
04252       TESTC(TRACE_METHOD(hr, L"IAccessor::GetBindings(0x%p, &0x%08x, &%lu, &0x%p)", pCDataAccess->m_hAccessor, dwAccessorFlags, cBindings, rgBindings));
04253
04254       //We need to the ListView
04255       //Headers/Columns contain ColInfo information
04256       //Rows are per columns
04257
04258       //ListView Columns
04259       LV_InsertColumn(hWndName, 0,    L"ColName");
04260       LV_InsertItem(hWndName,   0,    0,  L"Ordinal");
04261       LV_InsertItem(hWndName,   1,    0,  L"obValue");
04262       LV_InsertItem(hWndName,   2,    0,  L"obLength");
04263       LV_InsertItem(hWndName,   3,    0,  L"obStatus");
04264       LV_InsertItem(hWndName,   4,    0,  L"pTypeInfo");
04265       LV_InsertItem(hWndName,   5,    0,  L"pObject");
04266       LV_InsertItem(hWndName,   6,    0,  L"pBindExt");
04267       LV_InsertItem(hWndName,   7,    0,  L"dwPart");
04268       LV_InsertItem(hWndName,   8,    0,  L"dwMemOwner");
04269       LV_InsertItem(hWndName,   9,    0,  L"eParamIO");
04270       LV_InsertItem(hWndName,   10,   0,  L"cbMaxLen");
04271       LV_InsertItem(hWndName,   11,   0,  L"dwFlags");
04272       LV_InsertItem(hWndName,   12,   0,  L"wType");
04273       LV_InsertItem(hWndName,   13,   0,  L"bPrecision");
04274       LV_InsertItem(hWndName,   14,   0,  L"bScale");
04275
04276       //AutoSize column
04277       SendMessage(hWndName, LVM_SETCOLUMNWIDTH, 0,    (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
04278
04279       for(i=0; i<cBindings; i++)
04280       {
04281         ASSERT(rgBindings);
04282         const DBBINDING* pBinding = &rgBindings[i];
04283         const DBCOLUMNINFO* pColInfo = pCDataAccess->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
04284
04285         //Column Header
04286         LV_InsertColumn(hWndValue, i, GetColName(pColInfo), pCDataAccess->GetColumnImage(pColInfo)==IMAGE_LOCK ? IMAGE_LOCK : IMAGE_NONE);
04287
04288         //Ordinal (SubItem)
04289         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%ld", pBinding->iOrdinal);
04290         LV_InsertItem(hWndValue, 0, i, wszBuffer);
04291
04292         //obValue (SubItem)
04293         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->obValue);
04294         LV_InsertItem(hWndValue, 1, i, wszBuffer);
04295
04296         //obLength (SubItem)
04297         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->obLength);
04298         LV_InsertItem(hWndValue, 2, i, wszBuffer);
04299
04300         //obStatus (SubItem)
04301         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->obStatus);
04302         LV_InsertItem(hWndValue, 3, i, wszBuffer);
04303
04304         //pTypeInfo (SubItem)
04305         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->pTypeInfo);
04306         LV_InsertItem(hWndValue, 4, i, wszBuffer);
04307
04308         //pObject (SubItem)
04309         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->pObject);
04310         LV_InsertItem(hWndValue, 5, i, wszBuffer);
04311
04312         //pBindExt (SubItem)
04313         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->pBindExt);
04314         LV_InsertItem(hWndValue, 6, i, wszBuffer);
04315
04316         //dwPart (SubItem)
04317         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pBinding->dwPart);
04318         LV_InsertItem(hWndValue, 7, i, wszBuffer);
04319
04320         //dwMemOwner (SubItem)
04321         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pBinding->dwMemOwner);
04322         LV_InsertItem(hWndValue, 8, i, wszBuffer);
04323
04324         //eParamIO (SubItem)
04325         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pBinding->eParamIO);
04326         LV_InsertItem(hWndValue, 9, i, wszBuffer);
04327
04328         //cbMaxLen (SubItem)
04329         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pBinding->cbMaxLen);
04330         LV_InsertItem(hWndValue, 10, i, wszBuffer);
04331
04332         //dwFlags (SubItem)
04333         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pBinding->dwFlags);
04334         LV_InsertItem(hWndValue, 11, i, wszBuffer);
04335
04336         //TYPE (subitem)
04337         LV_InsertItem(hWndValue, 12, i, GetDBTypeName(pBinding->wType));
04338
04339         //Precision (SubItem)
04340         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pBinding->bPrecision);
04341         LV_InsertItem(hWndValue, 13, i, wszBuffer);
04342
04343         //Scale (SubItem)
04344         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pBinding->bScale);
04345         LV_InsertItem(hWndValue, 14, i, wszBuffer);
04346       }
04347
04348       //AutoSize all columns
04349       for(i=0; i<cBindings; i++)
04350         SendMessage(hWndValue, LVM_SETCOLUMNWIDTH, (WPARAM)i,   (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
04351
04352     CLEANUP:
04353       CenterDialog(hWnd);
04354       FreeBindings(&cBindings, &rgBindings);
04355       if(FAILED(hr))
04356         EndDialog(hWnd, FALSE);
04357       return TRUE;
04358     }
04359
04360     case WM_COMMAND:
04361     {
04362       //Filter out any Control Notification codes
04363       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
04364       {
04365         return UNHANDLED_MSG;
04366       }
04367
04368       switch (GET_WM_COMMAND_ID(wParam, lParam))
04369       {
04370         case IDOK:
04371         {
04372           CWaitCursor waitCursor;
04373
04374           EndDialog(hWnd, TRUE);
04375           return 0;
04376         }
04377
04378         case IDCANCEL:
04379         {
04380           EndDialog(hWnd, FALSE);
04381           return 0;
04382         }
04383       }
04384       break;
04385     }//WM_COMMAND
04386
04387     case WM_NOTIFY:
04388     {
04389       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
04390       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
04391
04392       //ListView
04393       switch(pDispInfo->hdr.code)
04394       {
04395         //Since we have "TwoClickActive" on this will get sent
04396         //Whenever a row is clicked on twice!
04397         //This functionality used to be done with NM_DBCLK
04398         case LVN_ITEMACTIVATE:
04399           return 0;
04400
04401         case LVN_ITEMCHANGED:
04402         {
04403           HWND hWndName   = ::GetDlgItem(hWnd, IDL_NAMES);
04404           HWND hWndValue  = ::GetDlgItem(hWnd, IDL_VALUES);
04405
04406           if(pNMListView->uNewState & LVNI_FOCUSED &&
04407             pNMListView->uNewState & LVNI_SELECTED)
04408           {
04409             if(wParam == IDL_VALUES)
04410             {
04411               SyncSibling(hWndName, hWndValue);
04412                     return FALSE;
04413             }
04414
04415             if(wParam == IDL_NAMES)
04416             {
04417               SyncSibling(hWndValue, hWndName);
04418                       return FALSE;
04419             }
04420             return UNHANDLED_MSG; //No return Value
04421           }
04422         }
04423       }
04424
04425
04426     }//WM_NOTIFY
04427   }//switch message
04428
04429   return FALSE;
04430 }
04431
04432
04433 ////////////////////////////////////////////////////////////////
04434 // CMDIChild::CreateAccessorProc
04435 //
04436 /////////////////////////////////////////////////////////////////
04437 INT_PTR WINAPI CMDIChild::CreateAccessorProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04438 {
04439   //Bindings
04440   static DBCOUNTITEM  cBindings = 0;
04441   static DBBINDING* rgBindings  = NULL;
04442   static DBLENGTH   cbRowSize = 0;
04443   static BOOL     s_bClearAll = TRUE;
04444
04445   switch(message)
04446   {
04447     case WM_INITDIALOG:
04448     {
04449       CWaitCursor waitCursor;
04450       WCHAR wszBuffer[MAX_NAME_LEN+1];
04451
04452       //Save the "this" pointer
04453       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
04454
04455       //Which object are we calling this from
04456       CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
04457       ASSERT(pCDataAccess);
04458
04459       HRESULT hr = S_OK;
04460
04461       //Setup column headers
04462       HWND hWndValue  = ::GetDlgItem(hWnd, IDL_COLUMNS);
04463       s_bClearAll = TRUE;
04464
04465       //Use Extended ListView Styles!
04466       SendMessage(hWndValue, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES);
04467
04468       //Set image list to the Window
04469       ListView_SetImageList(hWndValue, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
04470       ListView_SetImageList(hWndValue, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_STATE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_STATE);
04471
04472       //Setup Bindings
04473       pCDataAccess->GetColInfo();
04474       pCDataAccess->SetupBindings(BIND_ALLCOLS, &cBindings, &rgBindings, &cbRowSize);
04475
04476       //We need to the ListView
04477       //Headers/Columns contain ColInfo information
04478       //Rows are per columns
04479
04480       //ListView Columns
04481       LV_InsertColumn(hWndValue,    0,    L"ColName");
04482       LV_InsertColumn(hWndValue,    1,    L"Ordinal");
04483       LV_InsertColumn(hWndValue,    2,    L"obValue");
04484       LV_InsertColumn(hWndValue,    3,    L"obLength");
04485       LV_InsertColumn(hWndValue,    4,    L"obStatus");
04486       LV_InsertColumn(hWndValue,    5,    L"pTypeInfo");
04487       LV_InsertColumn(hWndValue,    6,    L"pObject");
04488       LV_InsertColumn(hWndValue,    7,    L"pBindExt");
04489       LV_InsertColumn(hWndValue,    8,    L"dwPart");
04490       LV_InsertColumn(hWndValue,    9,    L"dwMemOwner");
04491       LV_InsertColumn(hWndValue,    10,   L"eParamIO");
04492       LV_InsertColumn(hWndValue,    11,   L"cbMaxLen");
04493       LV_InsertColumn(hWndValue,    12,   L"dwFlags");
04494       LV_InsertColumn(hWndValue,    13,   L"wType");
04495       LV_InsertColumn(hWndValue,    14,   L"bPrecision");
04496       LV_InsertColumn(hWndValue,    15,   L"bScale");
04497
04498       for(ULONG i=0; i<cBindings; i++)
04499       {
04500         ASSERT(rgBindings);
04501         const DBBINDING* pBinding = &rgBindings[i];
04502         const DBCOLUMNINFO* pColInfo = pCDataAccess->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
04503
04504         //Column Header
04505         LV_InsertItem(hWndValue, i, 0, GetColName(pColInfo), PARAM_NONE, pCDataAccess->GetColumnImage(pColInfo)==IMAGE_LOCK ? IMAGE_LOCK : IMAGE_NONE);
04506
04507         //Ordinal (SubItem)
04508         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%ld", pBinding->iOrdinal);
04509         LV_InsertItem(hWndValue, i, 1, wszBuffer);
04510
04511         //obValue (SubItem)
04512         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->obValue);
04513         LV_InsertItem(hWndValue, i, 2, wszBuffer);
04514
04515         //obLength (SubItem)
04516         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->obLength);
04517         LV_InsertItem(hWndValue, i, 3, wszBuffer);
04518
04519         //obStatus (SubItem)
04520         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->obStatus);
04521         LV_InsertItem(hWndValue, i, 4, wszBuffer);
04522
04523         //pTypeInfo (SubItem)
04524         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->pTypeInfo);
04525         LV_InsertItem(hWndValue, i, 5, wszBuffer);
04526
04527         //pObject (SubItem)
04528         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->pObject);
04529         LV_InsertItem(hWndValue, i, 6, wszBuffer);
04530
04531         //pBindExt (SubItem)
04532         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pBinding->pBindExt);
04533         LV_InsertItem(hWndValue, i, 7, wszBuffer);
04534
04535         //dwPart (SubItem)
04536         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pBinding->dwPart);
04537         LV_InsertItem(hWndValue, i, 8, wszBuffer);
04538
04539         //dwMemOwner (SubItem)
04540         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pBinding->dwMemOwner);
04541         LV_InsertItem(hWndValue, i, 9, wszBuffer);
04542
04543         //eParamIO (SubItem)
04544         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pBinding->eParamIO);
04545         LV_InsertItem(hWndValue, i, 10, wszBuffer);
04546
04547         //cbMaxLen (SubItem)
04548         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pBinding->cbMaxLen);
04549         LV_InsertItem(hWndValue, i, 11, wszBuffer);
04550
04551         //dwFlags (SubItem)
04552         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pBinding->dwFlags);
04553         LV_InsertItem(hWndValue, i, 12, wszBuffer);
04554
04555         //TYPE (subitem)
04556         LV_InsertItem(hWndValue, i, 13, GetDBTypeName(pBinding->wType));
04557
04558         //Precision (SubItem)
04559         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pBinding->bPrecision);
04560         LV_InsertItem(hWndValue, i, 14, wszBuffer);
04561
04562         //Scale (SubItem)
04563         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pBinding->bScale);
04564         LV_InsertItem(hWndValue, i, 15, wszBuffer);
04565
04566         //Default to unchecked
04567         LV_SetItemState(hWndValue, i, 0,  INDEXTOSTATEIMAGEMASK(STATE_UNCHECKED),  LVIS_STATEIMAGEMASK);
04568       }
04569
04570
04571       //Go through and check the existing columns, that are in our current bindings
04572       for(i=0; i<pCDataAccess->m_Bindings.GetCount(); i++)
04573       {
04574         DBORDINAL iOrdinal = pCDataAccess->m_Bindings[i].iOrdinal;
04575         DBORDINAL iIndex = (iOrdinal && !pCDataAccess->m_ColumnInfo[0].iOrdinal==0) ? iOrdinal-1 : iOrdinal;
04576         LV_SetItemState(hWndValue, (INDEX)iIndex, 0,  INDEXTOSTATEIMAGEMASK(STATE_CHECKED),  LVIS_STATEIMAGEMASK);
04577       }
04578
04579       //AutoSize columns (column headers);
04580       for(i=0; i<=15; i++)
04581         SendMessage(hWndValue, LVM_SETCOLUMNWIDTH, i, (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
04582
04583       CenterDialog(hWnd);
04584
04585       if(FAILED(hr))
04586       {
04587         //Free Bindings
04588         FreeBindings(&cBindings, &rgBindings);
04589         EndDialog(hWnd, FALSE);
04590       }
04591
04592       return TRUE;
04593     }
04594
04595     case WM_COMMAND:
04596     {
04597       //Filter out any Control Notification codes
04598       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
04599       {
04600         return UNHANDLED_MSG;
04601       }
04602
04603       switch (GET_WM_COMMAND_ID(wParam, lParam))
04604       {
04605         case IDOK:
04606         {
04607           CWaitCursor waitCursor;
04608
04609           //Get the "this" pointer
04610           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
04611
04612           //Which object are we calling this from
04613           CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
04614           ASSERT(pCDataAccess);
04615
04616           DBCOUNTITEM cSelBindings = 0;
04617           DBBINDING* rgSelBindings = NULL;
04618           HWND hWndValue  = ::GetDlgItem(hWnd, IDL_COLUMNS);
04619           HACCESSOR hAccessor = NULL;
04620           DBACCESSORFLAGS dwAccessorFlags = DBACCESSOR_ROWDATA;
04621
04622           INDEX i=0;
04623           HRESULT hr = S_OK;
04624
04625           //Now that the user has selected all the columns they wish to
04626           //have in the Accessor, we need to loop through all the
04627           //checked columns and add them to our list...
04628           INDEX cItems = (INDEX)SendMessage(hWndValue, LVM_GETITEMCOUNT, 0, 0);
04629           SAFE_ALLOC(rgSelBindings, DBBINDING, cItems);
04630
04631           for(i=0; i<cItems; i++)
04632           {
04633             //Get the Image
04634             BOOL bChecked = LV_GetItemState(hWndValue, i, LVIS_STATEIMAGEMASK) & INDEXTOSTATEIMAGEMASK(STATE_CHECKED);
04635
04636             //Only interested in checked items
04637             if(!bChecked)
04638               continue;
04639
04640             ASSERT(cBindings);
04641             ASSERT(rgBindings);
04642
04643             //Mark this Ordinal as checked
04644             CopyBinding(&rgSelBindings[cSelBindings], &rgBindings[i]);
04645             cSelBindings++;
04646           }
04647
04648           //Now that we have the columns, Create the Accessor
04649           hr = pCDataAccess->CreateAccessor(dwAccessorFlags, cSelBindings, rgSelBindings, 0, &hAccessor);
04650
04651           //Free Bindings
04652           FreeBindings(&cBindings, &rgBindings);
04653
04654           if(SUCCEEDED(hr))
04655           {
04656             //Release Previous Accessor
04657             pCDataAccess->ReleaseAccessor(&pCDataAccess->m_hAccessor);
04658
04659             //Use the new Bindings
04660             pCDataAccess->m_hAccessor = hAccessor;
04661             pCDataAccess->m_cbRowSize = cbRowSize;
04662             pCDataAccess->m_Bindings.Attach(cSelBindings, rgSelBindings);
04663
04664             //The new bindings may not be the same size as our original
04665             //Or might not have existined original if AutiQI was off...
04666             SAFE_REALLOC(pCDataAccess->m_pData, BYTE, cbRowSize);
04667
04668             //Now actually refetch the Data with the new Accessor
04669             if(SUCCEEDED(hr = pThis->m_pCDataGrid->RestartPosition()))
04670               hr = pThis->m_pCDataGrid->RefreshData();
04671
04672             EndDialog(hWnd, TRUE);
04673             return 0;
04674           }
04675
04676         CLEANUP:
04677           //Free Bindings
04678           FreeBindings(&cBindings, &rgBindings);
04679           FreeBindings(&cSelBindings, &rgSelBindings);
04680           return 0;
04681         }
04682
04683         case IDCANCEL:
04684         {
04685           //Free Bindings
04686           FreeBindings(&cBindings, &rgBindings);
04687           EndDialog(hWnd, FALSE);
04688           return 0;
04689         }
04690
04691         case IDB_CLEARALL:
04692         {
04693           HWND hWndValue  = ::GetDlgItem(hWnd, IDL_COLUMNS);
04694
04695           //Now that the user has selected to select all columns
04696           //We need to loop through all the unchecked and check them...
04697           INDEX cItems = (INDEX)SendMessage(hWndValue, LVM_GETITEMCOUNT, 0, 0);
04698           for(INDEX i=0; i<cItems; i++)
04699           {
04700             //Check the property state
04701             LV_SetItemState(hWndValue, i, 0,  INDEXTOSTATEIMAGEMASK(s_bClearAll ? STATE_UNCHECKED : STATE_CHECKED),  LVIS_STATEIMAGEMASK);
04702           }
04703
04704           //Clear All is a toggle...
04705           if(s_bClearAll)
04706           {
04707             s_bClearAll = FALSE;
04708 						::SetWindowText(::GetDlgItem(hWnd, IDB_CLEARALL), "SelectAll");
04709           }
04710           else
04711           {
04712             s_bClearAll = TRUE;
04713 						::SetWindowText(::GetDlgItem(hWnd, IDB_CLEARALL), "ClearAll");
04714           }
04715           return 0;
04716         }
04717       }
04718       break;
04719     }//WM_COMMAND
04720
04721   }//switch message
04722
04723   return FALSE;
04724 }
04725
04726
04727 ////////////////////////////////////////////////////////////////
04728 // CMDIChild::SetParameterInfoProc
04729 //
04730 /////////////////////////////////////////////////////////////////
04731 INT_PTR WINAPI CMDIChild::SetParameterInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04732 {
04733   static DWORD  dwSavedFlags  = 0;
04734   static INDEX  iSavedName    = CB_ERR;
04735   static CComboBoxLite  s_CComboTypes;
04736
04737   switch(message)
04738   {
04739     case WM_INITDIALOG:
04740     {
04741       CWaitCursor waitCursor;
04742
04743       //Save the "this" pointer
04744       CMDIChild* pThis  = (CMDIChild*)SetThis(hWnd, (void*)lParam);
04745       INDEX iSel = 0;
04746       HRESULT hr = S_OK;
04747
04748       //Controls
04749       HWND hWndOrdinal  = ::GetDlgItem(hWnd, IDE_ORDINAL);
04750       HWND hWndParamName  = ::GetDlgItem(hWnd, IDC_NAME);
04751       HWND hWndFlags    = ::GetDlgItem(hWnd, IDL_FLAGS);
04752
04753       //Set Ordinal
04754       SendMessage(hWndOrdinal, WM_SETTEXT, 0, (LPARAM)"1");
04755
04756       //Set Parameter Name
04757       SendMessage(hWndParamName, CB_ADDSTRING, 0, (LPARAM)"<NULL>");
04758       iSel = (INDEX)SendMessage(hWndParamName, CB_ADDSTRING, 0, (LPARAM)"Parameter1");
04759       iSavedName = (INDEX)SendMessage(hWndParamName, CB_SETCURSEL, iSavedName!=CB_ERR ? iSavedName : iSel, 0);
04760
04761       //Add support for indicating NULL
04762       s_CComboTypes.CreateIndirect(hWnd, IDC_TYPE);
04763       s_CComboTypes.AddString(L"<NULL>");
04764
04765       //Fill in Combo with "Standard" Defined Type Names (defined in SetParameterInfo)
04766       //NOTE: We could just use the DBTYPE list (g_rgDBTypes), but that gives many
04767       //confusing types (DBTYPE_STR) which people are apt to use but are not standard
04768       //so currently no provider supports them.  So just list all those defined by the spec
04769       //and the combo box allows the user to enter other (not in the list)
04770       s_CComboTypes.AddString(L"DBTYPE_I1");
04771       s_CComboTypes.AddString(L"DBTYPE_I2");
04772       s_CComboTypes.AddString(L"DBTYPE_I4");
04773       s_CComboTypes.AddString(L"DBTYPE_I8");
04774       s_CComboTypes.AddString(L"DBTYPE_UI1");
04775       s_CComboTypes.AddString(L"DBTYPE_UI2");
04776       s_CComboTypes.AddString(L"DBTYPE_UI4");
04777       s_CComboTypes.AddString(L"DBTYPE_UI8");
04778       s_CComboTypes.AddString(L"DBTYPE_R4");
04779       s_CComboTypes.AddString(L"DBTYPE_R8");
04780       s_CComboTypes.AddString(L"DBTYPE_CY");
04781       s_CComboTypes.AddString(L"DBTYPE_DECIMAL");
04782       s_CComboTypes.AddString(L"DBTYPE_NUMERIC");
04783       s_CComboTypes.AddString(L"DBTYPE_BOOL");
04784       s_CComboTypes.AddString(L"DBTYPE_ERROR");
04785       s_CComboTypes.AddString(L"DBTYPE_UDT");
04786       s_CComboTypes.AddString(L"DBTYPE_VARIANT");
04787       s_CComboTypes.AddString(L"DBTYPE_IDISPATCH");
04788       s_CComboTypes.AddString(L"DBTYPE_IUNKNOWN");
04789       s_CComboTypes.AddString(L"DBTYPE_GUID");
04790       s_CComboTypes.AddString(L"DBTYPE_DATE");
04791       s_CComboTypes.AddString(L"DBTYPE_DBDATE");
04792       s_CComboTypes.AddString(L"DBTYPE_DBTIME");
04793       s_CComboTypes.AddString(L"DBTYPE_DBTIMESTAMP");
04794       s_CComboTypes.AddString(L"DBTYPE_BSTR");
04795       s_CComboTypes.AddString(L"DBTYPE_CHAR");
04796       iSel = s_CComboTypes.AddString(L"DBTYPE_VARCHAR");
04797       s_CComboTypes.AddString(L"DBTYPE_LONGVARCHAR");
04798       s_CComboTypes.AddString(L"DBTYPE_WCHAR");
04799       s_CComboTypes.AddString(L"DBTYPE_WVARCHAR");
04800       s_CComboTypes.AddString(L"DBTYPE_WLONGVARCHAR");
04801       s_CComboTypes.AddString(L"DBTYPE_BINARY");
04802       s_CComboTypes.AddString(L"DBTYPE_VARBINARY");
04803       s_CComboTypes.AddString(L"DBTYPE_LONGVARBINARY");
04804       s_CComboTypes.AddString(L"DBTYPE_FILENAME");
04805       s_CComboTypes.AddString(L"DBTYPE_VARNUMERIC");
04806       s_CComboTypes.AddString(L"DBTYPE_PROPVARIANT");
04807
04808       //Set current Selection
04809       if(s_CComboTypes.RestoreSelection() == CB_ERR)
04810         s_CComboTypes.SetCurSel(iSel);
04811
04812       const static WIDENAMEMAP g_rgParamFlags[] =
04813       {
04814         VALUE_WCHAR(DBPARAMFLAGS_ISINPUT),
04815         VALUE_WCHAR(DBPARAMFLAGS_ISOUTPUT),
04816         VALUE_WCHAR(DBPARAMFLAGS_ISSIGNED),
04817         VALUE_WCHAR(DBPARAMFLAGS_ISNULLABLE),
04818         VALUE_WCHAR(DBPARAMFLAGS_ISLONG),
04819         VALUE_WCHAR(DBPARAMFLAGS_SCALEISNEGATIVE),
04820       };
04821
04822       //Populate the Flags ListBox
04823       SendMessage(hWndFlags, LB_RESETCONTENT, 0, 0);
04824       for(ULONG i=0; i<NUMELE(g_rgParamFlags); i++)
04825       {
04826         INDEX iSel = (INDEX)wSendMessage(hWndFlags, LB_ADDSTRING, 0, g_rgParamFlags[i].pwszName);
04827         SendMessage(hWndFlags,  LB_SETITEMDATA, iSel, (LPARAM)g_rgParamFlags[i].lItem);
04828
04829         //Reselect all previously selected items...
04830         SendMessage(hWndFlags, LB_SETSEL, (dwSavedFlags & g_rgParamFlags[i].lItem) == (DWORD)g_rgParamFlags[i].lItem, i);
04831       }
04832
04833       //Send a selection change to the ComboBox so it updates everything
04834       //Size, Precision, and Scale
04835       SendMessage(hWnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDC_TYPE, hWnd, CBN_SELCHANGE));
04836
04837       CenterDialog(hWnd);
04838       if(FAILED(hr))
04839         EndDialog(hWnd, FALSE);
04840       return TRUE;
04841     }
04842
04843     case WM_COMMAND:
04844     {
04845       //Filter out any Control Notification codes
04846       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
04847       {
04848         return UNHANDLED_MSG;
04849       }
04850
04851       //CBN_SELCHANGE
04852       switch(GET_WM_COMMAND_CMD(wParam, lParam))
04853       {
04854         //Selection change in a combo box occurred
04855         case CBN_SELCHANGE:
04856         {
04857           //See which combo box has changed
04858           switch(GET_WM_COMMAND_ID(wParam, lParam))
04859           {
04860             case IDC_TYPE:
04861             {
04862               WCHAR wszBuffer[MAX_NAME_LEN+1];
04863               HWND hWndSize   = ::GetDlgItem(hWnd, IDE_SIZE);
04864               HWND hWndPrecision  = ::GetDlgItem(hWnd, IDE_PRECISION);
04865               HWND hWndScale    = ::GetDlgItem(hWnd, IDE_SCALE);
04866
04867               //Get the Selected Type
04868               s_CComboTypes.GetSelText(wszBuffer, MAX_NAME_LEN);
04869               DBTYPE wType = GetDBType(wszBuffer);
04870               s_CComboTypes.SaveSelection();
04871
04872               //Get Default Size,Prec,Scale for this type...
04873               DBLENGTH ulMaxSize = 0;
04874               BYTE  bPrecision, bScale;
04875               GetDBTypeMaxSize(wType, &ulMaxSize, &bPrecision, &bScale);
04876
04877               //Set Size
04878               wSendMessageFmt(hWndSize,   WM_SETTEXT, 0, L"%lu", ulMaxSize!=0 ? ulMaxSize : 255);
04879               //Set Precision
04880               wSendMessageFmt(hWndPrecision,  WM_SETTEXT, 0, L"%d", bPrecision);
04881               //Set Scale
04882               wSendMessageFmt(hWndScale,    WM_SETTEXT, 0, L"%d", bScale);
04883               return 0;
04884             }
04885           }
04886           break;
04887         }
04888       }
04889
04890       switch (GET_WM_COMMAND_ID(wParam, lParam))
04891       {
04892         case IDOK:
04893         {
04894           CWaitCursor waitCursor;
04895
04896           //Get the "this" pointer
04897           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
04898           CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
04899           WCHAR wszNameBuffer[MAX_NAME_LEN];
04900           WCHAR wszTypeBuffer[MAX_NAME_LEN];
04901           HRESULT hr = S_OK;
04902
04903           //Controls
04904           HWND hWndOrdinal  = ::GetDlgItem(hWnd, IDE_ORDINAL);
04905           HWND hWndFlags    = ::GetDlgItem(hWnd, IDL_FLAGS);
04906           HWND hWndSize   = ::GetDlgItem(hWnd, IDE_SIZE);
04907           HWND hWndPrecision  = ::GetDlgItem(hWnd, IDE_PRECISION);
04908           HWND hWndScale    = ::GetDlgItem(hWnd, IDE_SCALE);
04909
04910           LONG lValue = 0;
04911           ULONG cParams = 0;
04912
04913           //Alloc Params
04914           cParams = 1;
04915           DB_UPARAMS ulParamOrdinal = 0;
04916           DBPARAMBINDINFO dbParamBindInfo;
04917
04918           //Setup ParamBindInfo
04919           CComboBoxLite comboParamName(hWnd, IDC_NAME);
04920           iSavedName = comboParamName.GetSelText(wszNameBuffer, MAX_NAME_LEN);
04921           dbParamBindInfo.pwszName = iSavedName == 0 ? NULL : wszNameBuffer;
04922
04923           GetEditBoxValue(hWndOrdinal,  &lValue, 0/*Min*/);
04924           ulParamOrdinal = lValue;
04925
04926           GetEditBoxValue(hWndSize,   &lValue, 0/*Min*/);
04927           dbParamBindInfo.ulParamSize = lValue;
04928
04929           GetEditBoxValue(hWndPrecision,  &lValue, 0, UCHAR_MAX);
04930           dbParamBindInfo.bPrecision = (BYTE)lValue;
04931
04932           GetEditBoxValue(hWndScale,    &lValue, 0, UCHAR_MAX);
04933           dbParamBindInfo.bScale = (BYTE)lValue;
04934
04935           //Get TypeName
04936           INDEX iSel = s_CComboTypes.GetSelText(wszTypeBuffer, MAX_NAME_LEN);
04937           dbParamBindInfo.pwszDataSourceType = iSel == 0 ? NULL : wszTypeBuffer;
04938
04939           //Obtain all Flags Selected Items...
04940           INDEX iSelCount = (INDEX)SendMessage(hWndFlags, LB_GETSELCOUNT, 0, 0);
04941           ASSERT(iSelCount < 20);
04942           LONG rgSelItems[20];
04943           SendMessage(hWndFlags, LB_GETSELITEMS, (WPARAM)20, (LPARAM)rgSelItems);
04944
04945           dwSavedFlags = 0;
04946           for(LONG i=0; i<iSelCount; i++)
04947             dwSavedFlags |= SendMessage(hWndFlags, LB_GETITEMDATA, rgSelItems[i], 0);
04948           dbParamBindInfo.dwFlags = dwSavedFlags;
04949
04950           //SetParameterInfo
04951           ASSERT(pCCommand->m_pICommandWithParameters);
04952           XTEST(hr = pCCommand->m_pICommandWithParameters->SetParameterInfo(cParams, &ulParamOrdinal, &dbParamBindInfo));
04953           TESTC(TRACE_METHOD(hr, L"ICommandWithParameters::SetParameterInfo(%lu, &%ld, 0x%p)", cParams, ulParamOrdinal, &dbParamBindInfo));
04954
04955         CLEANUP:
04956           return 0;
04957         }
04958
04959         case IDCANCEL:
04960         {
04961           EndDialog(hWnd, FALSE);
04962           return 0;
04963         }
04964
04965         case IDB_RESET:
04966         {
04967           //Get the "this" pointer
04968           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
04969           CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
04970           HRESULT hr = S_OK;
04971
04972           //SetParameterInfo
04973           ASSERT(pCCommand->m_pICommandWithParameters);
04974           XTEST(hr = pCCommand->m_pICommandWithParameters->SetParameterInfo(0, NULL, NULL));
04975           TRACE_METHOD(hr, L"ICommandWithParameters::SetParameterInfo(0, NULL, NULL)");
04976           return 0;
04977         }
04978       }
04979       break;
04980     }//WM_COMMAND
04981
04982   }//switch message
04983
04984   return FALSE;
04985 }
04986
04987
04988
04989 ////////////////////////////////////////////////////////////////
04990 // CMDIChild::GetParameterInfoProc
04991 //
04992 /////////////////////////////////////////////////////////////////
04993 INT_PTR WINAPI CMDIChild::GetParameterInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04994 {
04995   switch(message)
04996   {
04997     case WM_INITDIALOG:
04998     {
04999       CWaitCursor waitCursor;
05000       WCHAR wszBuffer[MAX_NAME_LEN+1];
05001
05002       //Save the "this" pointer
05003       CMDIChild* pThis  = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05004       CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
05005       HRESULT hr = S_OK;
05006
05007       ULONG i = 0;
05008       DB_UPARAMS cParams = 0;
05009       DBPARAMINFO* rgParamInfo = NULL;
05010       WCHAR* pwszNamesBuffer = NULL;
05011
05012       //Setup column headers
05013       HWND hWndName   = ::GetDlgItem(hWnd, IDL_NAMES);
05014       HWND hWndValue    = ::GetDlgItem(hWnd, IDL_VALUES);
05015       HWND hWndHelp   = ::GetDlgItem(hWnd, IDT_HELPMSG);
05016
05017       //Set Window Titles
05018       SendMessage(hWnd,   WM_SETTEXT, 0, (LPARAM)"ICommandWithParameters::GetParameterInfo");
05019       SendMessage(hWndHelp, WM_SETTEXT, 0, (LPARAM)"ParameterInfo");
05020
05021       //Use Extended ListView Styles!
05022       SendMessage(hWndName, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
05023       SendMessage(hWndValue,  LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
05024
05025       //Set image list to the Window
05026       ListView_SetImageList(hWndValue, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
05027       ListView_SetImageList(hWndName, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
05028
05029       //Now ICommandWithParameters::GetParameterInfo
05030       XTESTC(hr = pCCommand->GetParameterInfo(&cParams, &rgParamInfo, &pwszNamesBuffer));
05031
05032       //We need to the ListView
05033       //Headers/Columns contain ColInfo information
05034       //Rows are per columns
05035
05036       //ListView Columns
05037       LV_InsertColumn(hWndName, 0,    L"ParamName");
05038       LV_InsertItem(hWndName,   0,    0,  L"Ordinal");
05039       LV_InsertItem(hWndName,   1,    0,  L"dwFlags");
05040       LV_InsertItem(hWndName,   2,    0,  L"pTypeInfo");
05041       LV_InsertItem(hWndName,   3,    0,  L"wType");
05042       LV_InsertItem(hWndName,   4,    0,  L"ulParamSize");
05043       LV_InsertItem(hWndName,   5,    0,  L"bPrecision");
05044       LV_InsertItem(hWndName,   6,    0,  L"bScale");
05045
05046       //AutoSize column
05047       SendMessage(hWndName, LVM_SETCOLUMNWIDTH, 0,    (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
05048
05049       for(i=0; i<cParams; i++)
05050       {
05051         ASSERT(rgParamInfo);
05052         DBPARAMINFO* pParamInfo = &rgParamInfo[i];
05053
05054         //Column Header
05055         LV_InsertColumn(hWndValue, i, pParamInfo->pwszName, IMAGE_NONE);
05056
05057         //Ordinal (SubItem)
05058         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%ld", pParamInfo->iOrdinal);
05059         LV_InsertItem(hWndValue, 0, i, wszBuffer);
05060
05061         //dwFlags (SubItem)
05062         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pParamInfo->dwFlags);
05063         LV_InsertItem(hWndValue, 1, i, wszBuffer);
05064
05065         //pTypeInfo (SubItem)
05066         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", pParamInfo->pTypeInfo);
05067         LV_InsertItem(hWndValue, 2, i, wszBuffer);
05068
05069         //TYPE (subitem)
05070         LV_InsertItem(hWndValue, 3, i, GetDBTypeName(pParamInfo->wType));
05071
05072         //ulParamSize (SubItem)
05073         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pParamInfo->ulParamSize);
05074         LV_InsertItem(hWndValue, 4, i, wszBuffer);
05075
05076         //Precision (SubItem)
05077         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pParamInfo->bPrecision);
05078         LV_InsertItem(hWndValue, 5, i, wszBuffer);
05079
05080         //Scale (SubItem)
05081         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pParamInfo->bScale);
05082         LV_InsertItem(hWndValue, 6, i, wszBuffer);
05083       }
05084
05085       //AutoSize all columns
05086       for(i=0; i<cParams; i++)
05087         SendMessage(hWndValue, LVM_SETCOLUMNWIDTH, (WPARAM)i,   (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
05088
05089     CLEANUP:
05090       CenterDialog(hWnd);
05091       SAFE_FREE(rgParamInfo);
05092       SAFE_FREE(pwszNamesBuffer);
05093       if(FAILED(hr))
05094         EndDialog(hWnd, FALSE);
05095       return TRUE;
05096     }
05097
05098     case WM_COMMAND:
05099     {
05100       //Filter out any Control Notification codes
05101       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05102       {
05103         return UNHANDLED_MSG;
05104       }
05105
05106       switch (GET_WM_COMMAND_ID(wParam, lParam))
05107       {
05108         case IDOK:
05109         {
05110           CWaitCursor waitCursor;
05111
05112           EndDialog(hWnd, TRUE);
05113           return 0;
05114         }
05115
05116         case IDCANCEL:
05117         {
05118           EndDialog(hWnd, FALSE);
05119           return 0;
05120         }
05121       }
05122       break;
05123     }//WM_COMMAND
05124
05125     case WM_NOTIFY:
05126     {
05127       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
05128       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
05129
05130       //ListView
05131       switch(pDispInfo->hdr.code)
05132       {
05133         //Since we have "TwoClickActive" on this will get sent
05134         //Whenever a row is clicked on twice!
05135         //This functionality used to be done with NM_DBCLK
05136         case LVN_ITEMACTIVATE:
05137           return 0;
05138
05139         case LVN_ITEMCHANGED:
05140         {
05141           HWND hWndName   = ::GetDlgItem(hWnd, IDL_NAMES);
05142           HWND hWndValue  = ::GetDlgItem(hWnd, IDL_VALUES);
05143
05144           if(pNMListView->uNewState & LVNI_FOCUSED &&
05145             pNMListView->uNewState & LVNI_SELECTED)
05146           {
05147             if(wParam == IDL_VALUES)
05148             {
05149               SyncSibling(hWndName, hWndValue);
05150                     return FALSE;
05151             }
05152
05153             if(wParam == IDL_NAMES)
05154             {
05155               SyncSibling(hWndValue, hWndName);
05156                       return FALSE;
05157             }
05158             return UNHANDLED_MSG; //No return Value
05159           }
05160         }
05161       }
05162
05163
05164     }//WM_NOTIFY
05165   }//switch message
05166
05167   return FALSE;
05168 }
05169
05170
05171 ////////////////////////////////////////////////////////////////
05172 // CMDIChild::GetLiteralInfoProc
05173 //
05174 /////////////////////////////////////////////////////////////////
05175 INT_PTR WINAPI CMDIChild::GetLiteralInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05176 {
05177   switch(message)
05178   {
05179     case WM_INITDIALOG:
05180     {
05181       CWaitCursor waitCursor;
05182       WCHAR wszBuffer[MAX_NAME_LEN+1];
05183
05184       //Save the "this" pointer
05185       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05186       IDBInfo* pIDBInfo = SOURCE_GETINTERFACE(pThis->m_pCSource, IDBInfo);
05187       HRESULT hr = S_OK;
05188
05189       ULONG i,cLiteralInfo = 0;
05190       DBLITERALINFO* rgLiteralInfo = NULL;
05191       WCHAR* pStringBuffer = NULL;
05192
05193       //Setup column headers
05194       HWND hWndLiterals   = ::GetDlgItem(hWnd, IDL_VALUES);
05195       HWND hWndNames    = ::GetDlgItem(hWnd, IDL_NAMES);
05196       HWND hWndHelp   = ::GetDlgItem(hWnd, IDT_HELPMSG);
05197
05198       //Set Window Titles
05199       SendMessage(hWnd,   WM_SETTEXT, 0, (LPARAM)"IDBInfo::GetLiteralInfo");
05200       SendMessage(hWndHelp, WM_SETTEXT, 0, (LPARAM)"Information about literals used in text DDL");
05201
05202       const static WIDENAMEMAP rgLiterals[] =
05203       {
05204         VALUE_WCHAR(DBLITERAL_INVALID ),
05205         VALUE_WCHAR(DBLITERAL_BINARY_LITERAL  ),
05206         VALUE_WCHAR(DBLITERAL_CATALOG_NAME  ),
05207         VALUE_WCHAR(DBLITERAL_CATALOG_SEPARATOR ),
05208         VALUE_WCHAR(DBLITERAL_CHAR_LITERAL  ),
05209         VALUE_WCHAR(DBLITERAL_COLUMN_ALIAS  ),
05210         VALUE_WCHAR(DBLITERAL_COLUMN_NAME ),
05211         VALUE_WCHAR(DBLITERAL_CORRELATION_NAME  ),
05212         VALUE_WCHAR(DBLITERAL_CURSOR_NAME ),
05213         VALUE_WCHAR(DBLITERAL_ESCAPE_PERCENT_PREFIX ),
05214         VALUE_WCHAR(DBLITERAL_ESCAPE_PERCENT_SUFFIX  ),
05215         VALUE_WCHAR(DBLITERAL_ESCAPE_UNDERSCORE_PREFIX ),
05216         VALUE_WCHAR(DBLITERAL_ESCAPE_UNDERSCORE_SUFFIX ),
05217         VALUE_WCHAR(DBLITERAL_INDEX_NAME  ),
05218         VALUE_WCHAR(DBLITERAL_LIKE_PERCENT  ),
05219         VALUE_WCHAR(DBLITERAL_LIKE_UNDERSCORE ),
05220         VALUE_WCHAR(DBLITERAL_PROCEDURE_NAME  ),
05221         VALUE_WCHAR(DBLITERAL_QUOTE_PREFIX  ),
05222         VALUE_WCHAR(DBLITERAL_SCHEMA_NAME ),
05223         VALUE_WCHAR(DBLITERAL_TABLE_NAME  ),
05224         VALUE_WCHAR(DBLITERAL_TEXT_COMMAND  ),
05225         VALUE_WCHAR(DBLITERAL_USER_NAME ),
05226         VALUE_WCHAR(DBLITERAL_VIEW_NAME ),
05227
05228         VALUE_WCHAR(DBLITERAL_CUBE_NAME ),
05229         VALUE_WCHAR(DBLITERAL_DIMENSION_NAME  ),
05230         VALUE_WCHAR(DBLITERAL_HIERARCHY_NAME  ),
05231         VALUE_WCHAR(DBLITERAL_LEVEL_NAME  ),
05232         VALUE_WCHAR(DBLITERAL_MEMBER_NAME ),
05233         VALUE_WCHAR(DBLITERAL_PROPERTY_NAME ),
05234
05235         //2.0
05236         VALUE_WCHAR(DBLITERAL_SCHEMA_SEPARATOR  ),
05237         VALUE_WCHAR(DBLITERAL_QUOTE_SUFFIX  ),
05238       };
05239
05240       //Use Extended ListView Styles!
05241       SendMessage(hWndLiterals, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
05242       SendMessage(hWndNames,    LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
05243
05244       //Set image list to the Table Window
05245       ListView_SetImageList(hWndLiterals, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
05246       ListView_SetImageList(hWndNames, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
05247
05248       //Obtain GetLiteralInfo (for all supported literals)
05249       ASSERT(pIDBInfo);
05250       XTEST(hr = pIDBInfo->GetLiteralInfo(0, NULL, &cLiteralInfo, &rgLiteralInfo, &pStringBuffer));
05251       TESTC(TRACE_METHOD(hr, L"IDBInfo::GetLiteralInfo(&%lu, &0x%p, &0x%p)", cLiteralInfo, rgLiteralInfo, pStringBuffer));
05252
05253       //We need to the ListView
05254       //Headers/Columns contain ColInfo information
05255       //Rows are per columns
05256
05257       //ListView NAMES
05258       LV_InsertColumn(hWndNames,  0,    L"DBLITERAL");
05259       LV_InsertItem(hWndNames,  0,    0,  L"LiteralValue");
05260       LV_InsertItem(hWndNames,  1,    0,  L"InvalidChars");
05261       LV_InsertItem(hWndNames,  2,    0,  L"InvalidStartingChars");
05262       LV_InsertItem(hWndNames,  3,    0,  L"Supported");
05263       LV_InsertItem(hWndNames,  4,    0,  L"MaxLen");
05264
05265       //AutoSize column
05266       SendMessage(hWndNames, LVM_SETCOLUMNWIDTH, 0,   (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
05267
05268       for(i=0; i<cLiteralInfo; i++)
05269       {
05270         ASSERT(rgLiteralInfo);
05271         DBLITERALINFO* pLiteralInfo = &rgLiteralInfo[i];
05272
05273         //Try to find the Actual "DBLITERAL" name...
05274         WCHAR* pwszLiteralName = NULL;
05275         for(LONG j=0; j<NUMELE(rgLiterals); j++)
05276         {
05277           if(pLiteralInfo->lt == (DBLITERAL)rgLiterals[j].lItem)
05278             pwszLiteralName = rgLiterals[j].pwszName;
05279         }
05280
05281
05282         //Column Header (DBLITERAL)
05283         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pLiteralInfo->lt);
05284         LV_InsertColumn(hWndLiterals, i, pwszLiteralName ? pwszLiteralName : wszBuffer);
05285
05286         //LiteralValue (SubItem)
05287         LV_InsertItem(hWndLiterals, 0, i, pLiteralInfo->pwszLiteralValue ? pLiteralInfo->pwszLiteralValue : NULL);
05288
05289         //InvalidChars (subitem)
05290         LV_InsertItem(hWndLiterals, 1, i, pLiteralInfo->pwszInvalidChars ? pLiteralInfo->pwszInvalidChars : NULL);
05291
05292         //InvalidChars (subitem)
05293         LV_InsertItem(hWndLiterals, 2, i, pLiteralInfo->pwszInvalidStartingChars ? pLiteralInfo->pwszInvalidStartingChars : NULL);
05294
05295         //Supported (SubItem)
05296         LV_InsertItem(hWndLiterals, 3, i, NULL, PARAM_NONE, pLiteralInfo->fSupported ? IMAGE_CHECKED : IMAGE_UNCHECKED);
05297
05298         //cbMaxLen (SubItem)
05299         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pLiteralInfo->cchMaxLen);
05300         LV_InsertItem(hWndLiterals, 4, i, wszBuffer);
05301       }
05302
05303       //AutoSize all columns
05304       for(i=0; i<cLiteralInfo; i++)
05305         SendMessage(hWndLiterals, LVM_SETCOLUMNWIDTH, (WPARAM)i,    (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
05306
05307     CLEANUP:
05308       CenterDialog(hWnd);
05309       SAFE_FREE(rgLiteralInfo);
05310       SAFE_FREE(pStringBuffer);
05311       if(FAILED(hr))
05312         EndDialog(hWnd, FALSE);
05313       return TRUE;
05314     }
05315
05316     case WM_COMMAND:
05317     {
05318       //Filter out any Control Notification codes
05319       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05320       {
05321         return UNHANDLED_MSG;
05322       }
05323
05324       switch (GET_WM_COMMAND_ID(wParam, lParam))
05325       {
05326         case IDOK:
05327         {
05328           CWaitCursor waitCursor;
05329
05330           EndDialog(hWnd, TRUE);
05331           return 0;
05332         }
05333
05334         case IDCANCEL:
05335         {
05336           EndDialog(hWnd, FALSE);
05337           return 0;
05338         }
05339       }
05340       break;
05341     }//WM_COMMAND
05342
05343     case WM_NOTIFY:
05344     {
05345       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
05346       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
05347
05348       //ListView
05349       switch(pDispInfo->hdr.code)
05350       {
05351         //Since we have "TwoClickActive" on this will get sent
05352         //Whenever a row is clicked on twice!
05353         //This functionality used to be done with NM_DBCLK
05354         case LVN_ITEMACTIVATE:
05355           return 0;
05356
05357         case LVN_ITEMCHANGED:
05358         {
05359           HWND hWndLiterals  = ::GetDlgItem(hWnd, IDL_VALUES);
05360           HWND hWndNames   = ::GetDlgItem(hWnd, IDL_NAMES);
05361
05362           if(pNMListView->uNewState & LVNI_FOCUSED &&
05363             pNMListView->uNewState & LVNI_SELECTED)
05364           {
05365             if(wParam == IDL_VALUES)
05366             {
05367               SyncSibling(hWndNames, hWndLiterals);
05368                     return FALSE;
05369             }
05370
05371             if(wParam == IDL_NAMES)
05372             {
05373               SyncSibling(hWndLiterals, hWndNames);
05374                       return FALSE;
05375             }
05376             return UNHANDLED_MSG; //No return Value
05377           }
05378         }
05379       }
05380
05381
05382     }//WM_NOTIFY
05383   }
05384
05385   return FALSE;
05386 }
05387
05388
05389
05390 ////////////////////////////////////////////////////////////////
05391 // CMDIChild::AbortTransactionProc
05392 //
05393 /////////////////////////////////////////////////////////////////
05394 INT_PTR WINAPI CMDIChild::AbortTransactionProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05395 {
05396   switch(message)
05397   {
05398     case WM_INITDIALOG:
05399     {
05400       CWaitCursor waitCursor;
05401
05402       //Save the "this" pointer
05403       CMDIChild*    pThis     = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05404       HWND      hWndRetaining = ::GetDlgItem(hWnd, IDC_RETAINING);
05405       HWND      hWndAsynch    = ::GetDlgItem(hWnd, IDC_ASYNCH);
05406
05407       //Need to fill in the RETAINING ComboBox
05408       INDEX iSel = (INDEX)SendMessage(hWndRetaining, CB_ADDSTRING,  0, (LPARAM)"TRUE");
05409       SendMessage(hWndRetaining, CB_SETITEMDATA, iSel, (LPARAM)TRUE);
05410       iSel = (INDEX)SendMessage(hWndRetaining, CB_ADDSTRING,  0, (LPARAM)"FALSE");
05411       SendMessage(hWndRetaining, CB_SETITEMDATA, iSel, (LPARAM)FALSE);
05412       //SetDefault - TRUE
05413       SendMessage(hWndRetaining, CB_SETCURSEL,  0, (LPARAM)0);
05414
05415       //Need to fill in the ASYNCH ComboBox
05416       iSel = (INDEX)SendMessage(hWndAsynch, CB_ADDSTRING, 0, (LPARAM)"TRUE");
05417       SendMessage(hWndAsynch, CB_SETITEMDATA, iSel, (LPARAM)TRUE);
05418       iSel = (INDEX)SendMessage(hWndAsynch, CB_ADDSTRING, 0, (LPARAM)"FALSE");
05419       SendMessage(hWndAsynch, CB_SETITEMDATA, iSel, (LPARAM)FALSE);
05420       //SetDefault - FALSE
05421       SendMessage(hWndAsynch, CB_SETCURSEL, 1, 0);
05422
05423       //Need to fill in the Txn ComboBox
05424       pThis->SetupTransactionCombo(::GetDlgItem(hWnd, IDC_TRANSACTION));
05425
05426       CenterDialog(hWnd);
05427       return TRUE;
05428     }
05429
05430     case WM_COMMAND:
05431     {
05432       //Filter out any Control Notification codes
05433       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05434       {
05435         return UNHANDLED_MSG;
05436       }
05437
05438       switch (GET_WM_COMMAND_ID(wParam, lParam))
05439       {
05440         case IDOK:
05441         {
05442           CWaitCursor waitCursor;
05443
05444           //Get the "this" pointer
05445           CMDIChild*    pThis     = (CMDIChild*)GetThis(hWnd);
05446
05447           ITransaction* pITransaction = NULL;
05448           HRESULT     hr        = S_OK;
05449
05450           HWND      hWndRetaining = ::GetDlgItem(hWnd, IDC_RETAINING);
05451           HWND      hWndAsynch    = ::GetDlgItem(hWnd, IDC_ASYNCH);
05452           HWND      hWndTransaction = ::GetDlgItem(hWnd, IDC_TRANSACTION);
05453
05454           //Just Need to Obtain selected RETAINING from Combo
05455           INDEX iSel = (INDEX)SendMessage(hWndRetaining, CB_GETCURSEL, 0, 0);
05456           BOOL fRetaining = (BOOL)SendMessage(hWndRetaining, CB_GETITEMDATA, iSel, 0);
05457
05458           //Just Need to Obtain selected ASYNCH from Combo
05459           iSel = (INDEX)SendMessage(hWndAsynch, CB_GETCURSEL, 0, 0);
05460           BOOL fAsynch = (BOOL)SendMessage(hWndAsynch, CB_GETITEMDATA, iSel, 0);
05461
05462           //get the ITransaction Pointer
05463           iSel = (INDEX)SendMessage(hWndTransaction, CB_GETCURSEL, 0, 0);
05464           if(iSel != CB_ERR)
05465             pITransaction = (ITransaction*)SendMessage(hWndTransaction, CB_GETITEMDATA, iSel, 0);
05466
05467           //Obtain the Transaction interface
05468           if(!pITransaction)
05469             pITransaction = SOURCE_GETINTERFACE(pThis->m_pCSource, ITransaction);
05470           ASSERT(pITransaction);
05471
05472           //Now Abort the Transaction
05473           XTEST(hr = pITransaction->Abort(NULL, fRetaining, fAsynch));
05474           TRACE_METHOD(hr, L"ITransaction::Abort(NULL, %s, %s)", fRetaining ? L"TRUE" : L"FALSE", fAsynch ? L"TRUE" : L"FALSE");
05475
05476           if(SUCCEEDED(hr))
05477             EndDialog(hWnd, TRUE);
05478           return 0;
05479         }
05480
05481         case IDCANCEL:
05482         {
05483           EndDialog(hWnd, FALSE);
05484           return 0;
05485         }
05486       }
05487       break;
05488     }//WM_COMMAND
05489   }
05490   return FALSE;
05491 }
05492
05493
05494 ////////////////////////////////////////////////////////////////
05495 // CMDIChild::CommitTransactionProc
05496 //
05497 /////////////////////////////////////////////////////////////////
05498 INT_PTR WINAPI CMDIChild::CommitTransactionProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05499 {
05500   //Controls
05501   static CComboBoxLite  s_comboXACTTC;
05502   static CComboBoxLite  s_comboRetaining;
05503   static CComboBoxLite  s_comboTransaction;
05504
05505   switch(message)
05506   {
05507     case WM_INITDIALOG:
05508     {
05509       CWaitCursor waitCursor;
05510
05511       //Save the "this" pointer
05512       CMDIChild*    pThis     = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05513
05514       //Controls
05515       s_comboXACTTC.CreateIndirect(hWnd, IDC_XACTTC);
05516       s_comboRetaining.CreateIndirect(hWnd, IDC_RETAINING);
05517       s_comboTransaction.CreateIndirect(hWnd, IDC_TRANSACTION);
05518
05519       //Need to fill in the RETAINING ComboBox
05520       s_comboRetaining.AddString(L"TRUE",   TRUE);
05521       s_comboRetaining.AddString(L"FALSE",  FALSE);
05522       s_comboRetaining.SetSelValue(FALSE);
05523
05524       //Need to fill in the XACTTC ComboBox - and set the defualt
05525       s_comboXACTTC.Populate(g_cXACTTC, g_rgXACTTC);
05526       s_comboXACTTC.AddString(L"0", 0);
05527       s_comboXACTTC.SetSelValue(XACTTC_SYNC_PHASETWO);
05528
05529       //Need to fill in the Txn ComboBox
05530       pThis->SetupTransactionCombo(s_comboTransaction.m_hWnd);
05531
05532       CenterDialog(hWnd);
05533       return TRUE;
05534     }
05535
05536     case WM_COMMAND:
05537     {
05538       //Filter out any Control Notification codes
05539       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05540       {
05541         return UNHANDLED_MSG;
05542       }
05543
05544       switch (GET_WM_COMMAND_ID(wParam, lParam))
05545       {
05546         case IDOK:
05547         {
05548           CWaitCursor waitCursor;
05549           CMDIChild*    pThis     = (CMDIChild*)GetThis(hWnd);
05550           HRESULT     hr        = S_OK;
05551
05552           //Obtain selected RETAINING from Combo
05553           BOOL fRetaining = (BOOL)s_comboRetaining.GetSelValue();
05554
05555           //Obtain selected hWndXACTTC from Combo
05556           DWORD xacttc = (DWORD)s_comboXACTTC.GetSelValue();
05557
05558           //get the ITransactionPointer
05559           ITransaction* pITransaction = (ITransaction*)s_comboTransaction.GetItemParam(s_comboTransaction.GetCurSel());
05560
05561           //Obtain the Transaction interface
05562           if(!pITransaction || (LPARAM)pITransaction==CB_ERR)
05563             pITransaction = SOURCE_GETINTERFACE(pThis->m_pCSource, ITransaction);
05564           ASSERT(pITransaction);
05565
05566           //Now Commit the Transaction
05567           XTEST(hr = pITransaction->Commit(fRetaining, xacttc, 0));
05568           TRACE_METHOD(hr, L"ITransaction::Commit(%s, %d, 0)", fRetaining ? L"TRUE" : L"FALSE", xacttc);
05569
05570           if(SUCCEEDED(hr))
05571             EndDialog(hWnd, TRUE);
05572           return 0;
05573         }
05574
05575         case IDCANCEL:
05576         {
05577           EndDialog(hWnd, FALSE);
05578           return 0;
05579         }
05580       }
05581       break;
05582     }//WM_COMMAND
05583   }
05584   return FALSE;
05585 }
05586
05587
05588 ////////////////////////////////////////////////////////////////
05589 // CMDIChild::GetTransactionInfo
05590 //
05591 /////////////////////////////////////////////////////////////////
05592 INT_PTR WINAPI CMDIChild::GetTransactionInfo(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05593 {
05594   switch(message)
05595   {
05596     case WM_INITDIALOG:
05597     {
05598       CWaitCursor waitCursor;
05599
05600       //Save the "this" pointer
05601       CMDIChild*    pThis       = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05602
05603       //Need to fill in the Txn ComboBox
05604       pThis->SetupTransactionCombo(::GetDlgItem(hWnd, IDC_TRANSACTION));
05605
05606       CenterDialog(hWnd);
05607       return TRUE;
05608     }
05609
05610     case WM_COMMAND:
05611     {
05612       //Filter out any Control Notification codes
05613       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05614       {
05615         return UNHANDLED_MSG;
05616       }
05617
05618       switch (GET_WM_COMMAND_ID(wParam, lParam))
05619       {
05620         case IDOK:
05621         {
05622           CWaitCursor waitCursor;
05623
05624           //Get the "this" pointer
05625           CMDIChild*    pThis       = (CMDIChild*)GetThis(hWnd);
05626
05627           HWND      hWndTransaction   = ::GetDlgItem(hWnd, IDC_TRANSACTION);
05628           ITransaction* pITransaction   = NULL;
05629           XACTTRANSINFO XactInfo      = {0};
05630           HRESULT     hr          = S_OK;
05631
05632           //get the ITransactionPointer
05633           INDEX iSel = (INDEX)SendMessage(hWndTransaction, CB_GETCURSEL, 0, 0);
05634           if(iSel != CB_ERR)
05635             pITransaction = (ITransaction*)SendMessage(hWndTransaction, CB_GETITEMDATA, iSel, 0);
05636
05637           //Obtain the Transaction interface
05638           if(!pITransaction)
05639             pITransaction = SOURCE_GETINTERFACE(pThis->m_pCSource, ITransaction);
05640           ASSERT(pITransaction);
05641
05642           //ITransaction::GetTransactionInfo
05643           XTEST(hr = pITransaction->GetTransactionInfo(&XactInfo));
05644           TRACE_METHOD(hr, L"ITransaction::GetTransactionInfo(%s, %d, %s, %d, %d, %d)", /*XactInfo.uow,*/ GetMapName(XactInfo.isoLevel, g_cIsoLevels, g_rgIsoLevels), XactInfo.isoFlags, GetMapName(XactInfo.grfTCSupported, g_cXACTTC, g_rgXACTTC) , XactInfo.grfRMSupported, XactInfo.grfTCSupportedRetaining, XactInfo.grfRMSupportedRetaining);
05645
05646           if(SUCCEEDED(hr))
05647             EndDialog(hWnd, TRUE);
05648           return 0;
05649         }
05650
05651         case IDCANCEL:
05652         {
05653           EndDialog(hWnd, FALSE);
05654           return 0;
05655         }
05656       }
05657       break;
05658     }//WM_COMMAND
05659   }
05660   return FALSE;
05661 }
05662
05663
05664
05665 ////////////////////////////////////////////////////////////////
05666 // CMDIChild::StartTransactionProc
05667 //
05668 /////////////////////////////////////////////////////////////////
05669 INT_PTR WINAPI CMDIChild::StartTransactionProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05670 {
05671   switch(message)
05672   {
05673     case WM_INITDIALOG:
05674     {
05675       CWaitCursor waitCursor;
05676
05677       //Save the "this" pointer
05678       CMDIChild*    pThis     = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05679       HWND      hWndIsoLevel  = ::GetDlgItem(hWnd, IDC_ISOLEVEL);
05680
05681       //Title
05682       if(pThis->m_idSource == IDM_ITRANSACTIONDISPENSOR_BEGINTRANSACTION)
05683         SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"TransactionDispensor::BeginTransaction");
05684
05685       //Need to fill in the ISOLEVEL ComboBox
05686       for(ULONG i=0; i<g_cIsoLevels; i++)
05687       {
05688         INDEX iSel = (INDEX)wSendMessage(hWndIsoLevel, CB_ADDSTRING,  0, g_rgIsoLevels[i].pwszName);
05689         SendMessage(hWndIsoLevel, CB_SETITEMDATA, iSel, (LPARAM)g_rgIsoLevels[i].lItem);
05690       }
05691
05692       //SetDefault - READUNCOMMITED
05693       SendMessage(hWndIsoLevel, CB_SETCURSEL, 2, (LPARAM)0);
05694
05695       CenterDialog(hWnd);
05696       return TRUE;
05697     }
05698
05699     case WM_COMMAND:
05700     {
05701       //Filter out any Control Notification codes
05702       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05703       {
05704         return UNHANDLED_MSG;
05705       }
05706
05707       switch (GET_WM_COMMAND_ID(wParam, lParam))
05708       {
05709         case IDOK:
05710         {
05711           CWaitCursor waitCursor;
05712
05713           //Get the "this" pointer
05714           CMDIChild*    pThis     = (CMDIChild*)GetThis(hWnd);
05715
05716           HWND      hWndIsoLevel  = ::GetDlgItem(hWnd, IDC_ISOLEVEL);
05717           WCHAR     wszBuffer[MAX_NAME_LEN+1] = {0};
05718           HRESULT     hr = S_OK;
05719
05720           //Just Need to Obtain selected ISOLEVEL from Combo
05721           INDEX   iSel    = (INDEX)SendMessage(hWndIsoLevel, CB_GETCURSEL, 0, 0);
05722           wSendMessage(hWndIsoLevel, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
05723           ISOLEVEL  isoLevel  = (ISOLEVEL)SendMessage(hWndIsoLevel, CB_GETITEMDATA, iSel, 0);
05724
05725           if(pThis->m_idSource != IDM_ITRANSACTIONDISPENSOR_BEGINTRANSACTION)
05726           {
05727             ULONG ulTransactionLevel = 0;
05728             ITransactionLocal* pITransactionLocal = SOURCE_GETINTERFACE(pThis->m_pCSource,  ITransactionLocal);
05729             ASSERT(pITransactionLocal);
05730
05731             //ITransactionLocal::StartTransaction
05732             XTEST(hr = pITransactionLocal->StartTransaction(isoLevel, 0, NULL, &ulTransactionLevel));
05733             TRACE_METHOD(hr, L"ITransactionLocal::StartTransaction(%s, 0, NULL, &%d)", wszBuffer, ulTransactionLevel);
05734           }
05735           else
05736           {
05737 #ifdef MTSTXN
05738             ITransaction*     pITransaction     = NULL;
05739             ITransactionDispenser*  pITransactionDispenser  = NULL;
05740
05741             // Obtain the ITransactionDispenser Interface pointer
05742             // by calling DtcGetTransactionManager()
05743             XTEST(hr = DtcGetTransactionManager
05744                       (
05745                         NULL,               // LPTSTR  pszHost,
05746                         NULL,               // LPTSTR  pszTmName,
05747                         IID_ITransactionDispenser,      // /* in  */ REFIID rid,
05748                         0,                  // /* in  */ DWORD  dwReserved1,
05749                         0,                  // /* in  */ WORD wcbReserved2,
05750                         NULL,               // /* in  */ void FAR * pvReserved2,
05751                         (void**)&pITransactionDispenser   // /* out */ void** ppvObject
05752                       ));
05753             TRACE_METHOD(hr, L"DtcGetTransactionManager(NULL, NULL, IID_ITransactionDispenser, 0, 0, NULL, &0x%p)", pITransactionDispenser);
05754
05755             //start a global transaction
05756             if(SUCCEEDED(hr))
05757             {
05758               XTEST(hr = pITransactionDispenser->BeginTransaction
05759                           (
05760                             NULL,             //  /* [in]  */ IUnknown __RPC_FAR *punkOuter,
05761                             isoLevel,           //  /* [in]  */ ISOLEVEL isoLevel,
05762                             0,                //  /* [in]  */ ULONG isoFlags,
05763                             NULL,             //  /* [in]  */ ITransactionOptions *pOptions
05764                             (ITransaction**)&pITransaction  //  /* [out] */ ITransaction **ppTransaction
05765                           ));
05766               TRACE_METHOD(hr, L"ITransactionDispenser::BeginTransaction(NULL, %s, 0, &0x%p)", wszBuffer, pITransaction);
05767
05768               //Add this transaciton to the list
05769               if(SUCCEEDED(hr))
05770                 pThis->m_pCMainWindow->m_listTransactions.AddTail(pITransaction);
05771             }
05772
05773             SAFE_RELEASE(pITransactionDispenser);
05774 #endif //MTSTXN
05775           }
05776
05777           if(SUCCEEDED(hr))
05778             EndDialog(hWnd, TRUE);
05779           return 0;
05780         }
05781
05782         case IDCANCEL:
05783         {
05784           EndDialog(hWnd, FALSE);
05785           return 0;
05786         }
05787       }
05788       break;
05789     }//WM_COMMAND
05790   }
05791
05792   return FALSE;
05793 }
05794
05795
05796 ////////////////////////////////////////////////////////////////
05797 // CMDIChild::JoinTransactionProc
05798 //
05799 /////////////////////////////////////////////////////////////////
05800 INT_PTR WINAPI CMDIChild::JoinTransactionProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05801 {
05802   switch(message)
05803   {
05804     case WM_INITDIALOG:
05805     {
05806       CWaitCursor waitCursor;
05807
05808       //Save the "this" pointer
05809       CMDIChild*    pThis       = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05810       HWND      hWndIsoLevel    = ::GetDlgItem(hWnd, IDC_ISOLEVEL);
05811
05812       //Need to fill in the ISOLEVEL ComboBox
05813       for(ULONG i=0; i<g_cIsoLevels; i++)
05814       {
05815         INDEX iSel = (INDEX)wSendMessage(hWndIsoLevel, CB_ADDSTRING,  0, g_rgIsoLevels[i].pwszName);
05816         SendMessage(hWndIsoLevel, CB_SETITEMDATA, iSel, (LPARAM)g_rgIsoLevels[i].lItem);
05817       }
05818       //SetDefault - READUNCOMMITED
05819       SendMessage(hWndIsoLevel, CB_SETCURSEL, 2, (LPARAM)0);
05820
05821       //Need to fill in the Txn ComboBox
05822       pThis->SetupTransactionCombo(::GetDlgItem(hWnd, IDC_TRANSACTION));
05823
05824       CenterDialog(hWnd);
05825       return TRUE;
05826     }
05827
05828     case WM_COMMAND:
05829     {
05830       //Filter out any Control Notification codes
05831       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05832       {
05833         return UNHANDLED_MSG;
05834       }
05835
05836       switch (GET_WM_COMMAND_ID(wParam, lParam))
05837       {
05838         case IDOK:
05839         {
05840           CWaitCursor waitCursor;
05841
05842           //Get the "this" pointer
05843           CMDIChild*    pThis       = (CMDIChild*)GetThis(hWnd);
05844
05845           WCHAR     wszBuffer[MAX_NAME_LEN+1] = {0};
05846           HWND      hWndIsoLevel    = ::GetDlgItem(hWnd, IDC_ISOLEVEL);
05847           HWND      hWndTransaction   = ::GetDlgItem(hWnd, IDC_TRANSACTION);
05848           ITransaction* pITransaction   = NULL;
05849           HRESULT     hr          = S_OK;
05850
05851           //Just Need to Obtain selected ISOLEVEL from Combo
05852           INDEX iSel = (INDEX)SendMessage(hWndIsoLevel, CB_GETCURSEL, 0, 0);
05853           wSendMessage(hWndIsoLevel, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
05854           ISOLEVEL isoLevel = (ISOLEVEL)SendMessage(hWndIsoLevel, CB_GETITEMDATA, iSel, 0);
05855
05856           //get the ITransactionPointer
05857           iSel = (INDEX)SendMessage(hWndTransaction, CB_GETCURSEL, 0, 0);
05858           if(iSel != CB_ERR)
05859             pITransaction = (ITransaction*)SendMessage(hWndTransaction, CB_GETITEMDATA, iSel, 0);
05860
05861           ITransactionJoin* pITransactionJoin = SOURCE_GETINTERFACE(pThis->m_pCSource, ITransactionJoin);
05862           ASSERT(pITransactionJoin);
05863
05864           //ITransactionJoin::JoinTransaction
05865           XTEST(hr = pITransactionJoin->JoinTransaction(pITransaction, isoLevel, NULL, NULL));
05866           TRACE_METHOD(hr, L"ITransactionJoin::JoinTransaction(0x%p, %s, 0, NULL)", pITransaction, wszBuffer);
05867
05868           if(SUCCEEDED(hr))
05869             EndDialog(hWnd, TRUE);
05870           return 0;
05871         }
05872
05873         case IDCANCEL:
05874         {
05875           EndDialog(hWnd, FALSE);
05876           return 0;
05877         }
05878       }
05879       break;
05880     }//WM_COMMAND
05881   }
05882   return FALSE;
05883 }
05884
05885
05886
05887 ////////////////////////////////////////////////////////////////
05888 // CMDIChild::SetupTransactionCombo
05889 //
05890 /////////////////////////////////////////////////////////////////
05891 BOOL CMDIChild::SetupTransactionCombo(HWND hWnd)
05892 {
05893   INDEX iSel  = 0;
05894   ULONG cCount  = 0;
05895   WCHAR wszBuffer[MAX_NAME_LEN+1] = {0};
05896
05897
05898   //Need to fill in the Txn ComboBox
05899   POSITION pos = m_pCMainWindow->m_listTransactions.GetHeadPosition();
05900   while(pos)
05901   {
05902     ITransaction* pITransaction = m_pCMainWindow->m_listTransactions.GetNext(pos);
05903     StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d - 0x%p", cCount++, pITransaction);
05904
05905     iSel = (INDEX)wSendMessage(hWnd, CB_ADDSTRING,  0, wszBuffer);
05906     SendMessage(hWnd, CB_SETITEMDATA, iSel, (LPARAM)pITransaction);
05907   }
05908
05909   //SetDefault - 1st txn
05910   SendMessage(hWnd, CB_SETCURSEL, 0, (LPARAM)0);
05911
05912   //Enable or Diable the Combo...
05913 	::EnableWindow(hWnd, !m_pCMainWindow->m_listTransactions.IsEmpty());
05914   return TRUE;
05915 }
05916
05917
05918 ////////////////////////////////////////////////////////////////
05919 // CMDIChild::ReleaseTransaction
05920 //
05921 /////////////////////////////////////////////////////////////////
05922 INT_PTR WINAPI CMDIChild::ReleaseTransaction(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05923 {
05924   switch(message)
05925   {
05926     case WM_INITDIALOG:
05927     {
05928       CWaitCursor waitCursor;
05929
05930       //Save the "this" pointer
05931       CMDIChild*    pThis       = (CMDIChild*)SetThis(hWnd, (void*)lParam);
05932
05933       //Need to fill in the Txn ComboBox
05934       pThis->SetupTransactionCombo(::GetDlgItem(hWnd, IDC_TRANSACTION));
05935
05936       CenterDialog(hWnd);
05937       return TRUE;
05938     }
05939
05940     case WM_COMMAND:
05941     {
05942       //Filter out any Control Notification codes
05943       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
05944       {
05945         return UNHANDLED_MSG;
05946       }
05947
05948       switch (GET_WM_COMMAND_ID(wParam, lParam))
05949       {
05950         case IDOK:
05951         {
05952           CWaitCursor waitCursor;
05953
05954           //Get the "this" pointer
05955           CMDIChild*    pThis       = (CMDIChild*)GetThis(hWnd);
05956
05957           HWND      hWndTransaction   = ::GetDlgItem(hWnd, IDC_TRANSACTION);
05958           ITransaction* pITransaction   = NULL;
05959
05960           //get the ITransactionPointer
05961           INDEX iSel = (INDEX)SendMessage(hWndTransaction, CB_GETCURSEL, 0, 0);
05962           if(iSel != CB_ERR)
05963             pITransaction = (ITransaction*)SendMessage(hWndTransaction, CB_GETITEMDATA, iSel, 0);
05964
05965           if(pITransaction)
05966           {
05967             //Remove from list
05968             POSITION iPos = pThis->m_pCMainWindow->m_listTransactions.Find(pITransaction);
05969             pThis->m_pCMainWindow->m_listTransactions.RemoveAt(iPos);
05970
05971             //ITransaction::Release
05972             TRACE_RELEASE(pITransaction, L"ITransaction");
05973           }
05974
05975           EndDialog(hWnd, TRUE);
05976           return 0;
05977         }
05978
05979         case IDCANCEL:
05980         {
05981           EndDialog(hWnd, FALSE);
05982           return 0;
05983         }
05984       }
05985       break;
05986     }//WM_COMMAND
05987   }
05988   return FALSE;
05989 }
05990
05991
05992 ////////////////////////////////////////////////////////////////
05993 // CMDIChild::SetTransactionOptionsProc
05994 //
05995 /////////////////////////////////////////////////////////////////
05996 INT_PTR WINAPI CMDIChild::SetTransactionOptionsProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
05997 {
05998   switch(message)
05999   {
06000     case WM_INITDIALOG:
06001     {
06002       CWaitCursor waitCursor;
06003
06004       //Save the "this" pointer
06005       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
06006
06007       HWND hWndTimeout  = ::GetDlgItem(hWnd, IDE_TIMEOUT);
06008       HWND hWndDescription= ::GetDlgItem(hWnd, IDE_DESCRIPTION);
06009
06010       //Defaults
06011       SendMessage(hWndTimeout, WM_SETTEXT, 0, (LPARAM)"0");
06012       SendMessage(hWndDescription, WM_SETTEXT, 0, (LPARAM)"");
06013       CenterDialog(hWnd);
06014       return TRUE;
06015     }
06016
06017     case WM_COMMAND:
06018     {
06019       //Filter out any Control Notification codes
06020       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
06021       {
06022         return UNHANDLED_MSG;
06023       }
06024
06025       switch (GET_WM_COMMAND_ID(wParam, lParam))
06026       {
06027         case IDOK:
06028         {
06029           CWaitCursor waitCursor;
06030
06031           //Get the "this" pointer
06032           CMDIChild* pThis              = (CMDIChild*)GetThis(hWnd);
06033           CTransactionOptions* pCTransactionOptions = SOURCE_GETOBJECT(pThis->m_pCSource, CTransactionOptions);
06034           HRESULT hr = S_OK;
06035
06036           HWND hWndTimeout  = ::GetDlgItem(hWnd, IDE_TIMEOUT);
06037           HWND hWndDescription= ::GetDlgItem(hWnd, IDE_DESCRIPTION);
06038
06039           XACTOPT XactOptions;
06040           XactOptions.ulTimeout = 0;
06041           XactOptions.szDescription[0] = EOL;
06042
06043           //Need to Obtain Entered Timeout Value
06044           if(!GetEditBoxValue(hWndTimeout, (LONG*)&XactOptions.ulTimeout, 0/*Min*/))
06045             return FALSE;
06046
06047           //Need to Obtain Description
06048           SendMessage(hWndDescription, WM_GETTEXT, 40-1, (LPARAM)XactOptions.szDescription);
06049
06050           //ITransactionOptions::SetOptions
06051           ASSERT(pCTransactionOptions->m_pITransactionOptions);
06052           XTEST(hr = pCTransactionOptions->m_pITransactionOptions->SetOptions(&XactOptions));
06053           TRACE_METHOD(hr, L"ITransactionOptions::SetOptions(%d, \"%S\")", XactOptions.ulTimeout, XactOptions.szDescription);
06054
06055           if(SUCCEEDED(hr))
06056             EndDialog(hWnd, TRUE);
06057           return 0;
06058         }
06059
06060         case IDCANCEL:
06061         {
06062           EndDialog(hWnd, FALSE);
06063           return 0;
06064         }
06065       }
06066       break;
06067     }//WM_COMMAND
06068   }
06069
06070   return FALSE;
06071 }
06072
06073
06074 ////////////////////////////////////////////////////////////////
06075 // CMDIChild::CanConvertProc
06076 //
06077 /////////////////////////////////////////////////////////////////
06078 INT_PTR WINAPI CMDIChild::CanConvertProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
06079 {
06080   static DBTYPE wSavedFromType = 0;
06081   static DBTYPE wSavedToType = 0;
06082
06083   static INDEX iSavedFromSel = 28;  //DBTYPE_WSTR
06084   static INDEX iSavedToSel = iSavedFromSel;
06085
06086   //We have a problem with DBCONVERTFLAGS being orable, but _COLUMN == 0!
06087   //We will need to keep track of the 0 and non-0 flags,
06088   //inorder to restore the users previous selections correctly...
06089   static LONG fSelColumnFlag = TRUE;            //Default to COLUMN
06090   static LONG dwSavedConvFlags = DBCONVERTFLAGS_COLUMN; //Default to COLUMN
06091
06092   switch(message)
06093   {
06094     case WM_INITDIALOG:
06095     {
06096       CWaitCursor waitCursor;
06097
06098       //Save the "this" pointer
06099       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
06100
06101       HWND hWndFromType = ::GetDlgItem(hWnd, IDC_FROMTYPE);
06102       HWND hWndToType   = ::GetDlgItem(hWnd, IDC_TOTYPE);
06103       HWND hWndConvFlags  = ::GetDlgItem(hWnd, IDL_CONVFLAGS);
06104       INDEX iSel = 0;
06105
06106       const static WIDENAMEMAP rgConvertFlags[] =
06107       {
06108         VALUE_WCHAR(DBCONVERTFLAGS_COLUMN ),
06109         VALUE_WCHAR(DBCONVERTFLAGS_PARAMETER  ),
06110         VALUE_WCHAR(DBCONVERTFLAGS_ISLONG ),
06111         VALUE_WCHAR(DBCONVERTFLAGS_ISFIXEDLENGTH  ),
06112         VALUE_WCHAR(DBCONVERTFLAGS_FROMVARIANT  ),
06113       };
06114
06115       //Need to fill in the From and To Type ComboBoxs
06116       for(ULONG i=0; i<g_cDBTypes; i++)
06117       {
06118         WCHAR* pwszName = g_rgDBTypes[i].pwszName;
06119         DBTYPE wType = (DBTYPE)g_rgDBTypes[i].lItem;
06120
06121         //FromType
06122         iSel = (INDEX)wSendMessage(hWndFromType, CB_ADDSTRING,  0, pwszName);
06123         SendMessage(hWndFromType, CB_SETITEMDATA, iSel, (LPARAM)wType);
06124         //ToType
06125         iSel = (INDEX)wSendMessage(hWndToType, CB_ADDSTRING,  0, pwszName);
06126         SendMessage(hWndToType, CB_SETITEMDATA, iSel, (LPARAM)wType);
06127       }
06128
06129       //Need to select Defaults
06130       SendMessage(hWndFromType, CB_SETCURSEL, iSavedFromSel, 0);
06131       SendMessage(hWndToType, CB_SETCURSEL, iSavedToSel, 0);
06132
06133       //Need to also select Default Modifiers
06134 			::CheckDlgButton(hWnd, IDB_FROM_BYREF,   BST2STATE(wSavedFromType & DBTYPE_BYREF));
06135 			::CheckDlgButton(hWnd, IDB_FROM_ARRAY,   BST2STATE(wSavedFromType & DBTYPE_ARRAY));
06136 			::CheckDlgButton(hWnd, IDB_FROM_VECTOR,    BST2STATE(wSavedFromType & DBTYPE_VECTOR));
06137 			::CheckDlgButton(hWnd, IDB_TO_BYREF,   BST2STATE(wSavedToType & DBTYPE_BYREF));
06138 			::CheckDlgButton(hWnd, IDB_TO_ARRAY,   BST2STATE(wSavedToType & DBTYPE_ARRAY));
06139 			::CheckDlgButton(hWnd, IDB_TO_VECTOR,    BST2STATE(wSavedToType & DBTYPE_VECTOR));
06140
06141       //Need to fill in the ConvertFlags (ListBox)
06142       SendMessage(hWndConvFlags, LB_RESETCONTENT, 0, 0);
06143       for(i=0; i<NUMELE(rgConvertFlags); i++)
06144       {
06145         INDEX iSel = (INDEX)wSendMessage(hWndConvFlags, LB_ADDSTRING, 0, rgConvertFlags[i].pwszName);
06146         SendMessage(hWndConvFlags,  LB_SETITEMDATA, iSel, (LPARAM)rgConvertFlags[i].lItem);
06147
06148         //Select Saved ConvFlags
06149         if((dwSavedConvFlags & rgConvertFlags[i].lItem) || (fSelColumnFlag && rgConvertFlags[i].lItem == DBCONVERTFLAGS_COLUMN))
06150            SendMessage(hWndConvFlags, LB_SETSEL, TRUE, i);
06151       }
06152
06153       CenterDialog(hWnd);
06154       return TRUE;
06155     }
06156
06157     case WM_COMMAND:
06158     {
06159       //Filter out any Control Notification codes
06160       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
06161       {
06162         return UNHANDLED_MSG;
06163       }
06164
06165       switch (GET_WM_COMMAND_ID(wParam, lParam))
06166       {
06167         case IDOK:
06168         {
06169           CWaitCursor waitCursor;
06170
06171           //Get the "this" pointer
06172           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
06173           CDataAccess* pCDataAccess = NULL;
06174           HRESULT hr = S_OK;
06175
06176           HWND hWndFromType = ::GetDlgItem(hWnd, IDC_FROMTYPE);
06177           HWND hWndToType   = ::GetDlgItem(hWnd, IDC_TOTYPE);
06178           HWND hWndConvFlags  = ::GetDlgItem(hWnd, IDL_CONVFLAGS);
06179           HWND hWndResult   = ::GetDlgItem(hWnd, IDT_RESULT);
06180
06181           //Just Need to Obtain selected FromType from Combo
06182           iSavedFromSel = (INDEX)SendMessage(hWndFromType, CB_GETCURSEL, 0, 0);
06183           wSavedFromType = (DBTYPE)SendMessage(hWndFromType, CB_GETITEMDATA, iSavedFromSel, 0);
06184
06185           //Need to obtain any type modifier for the FromType
06186           if(::IsDlgButtonChecked(hWnd, IDB_FROM_BYREF))
06187             wSavedFromType |= DBTYPE_BYREF;
06188           if(::IsDlgButtonChecked(hWnd, IDB_FROM_ARRAY))
06189             wSavedFromType |= DBTYPE_ARRAY;
06190           if(::IsDlgButtonChecked(hWnd, IDB_FROM_VECTOR))
06191             wSavedFromType |= DBTYPE_VECTOR;
06192
06193           //Just Need to Obtain selected ToType from Combo
06194           iSavedToSel = (INDEX)SendMessage(hWndToType, CB_GETCURSEL, 0, 0);
06195           wSavedToType = (DBTYPE)SendMessage(hWndToType, CB_GETITEMDATA, iSavedToSel, 0);
06196
06197           //Need to obtain any type modifier for the ToType
06198           if(::IsDlgButtonChecked(hWnd, IDB_TO_BYREF))
06199             wSavedToType |= DBTYPE_BYREF;
06200           if(::IsDlgButtonChecked(hWnd, IDB_TO_ARRAY))
06201             wSavedToType |= DBTYPE_ARRAY;
06202           if(::IsDlgButtonChecked(hWnd, IDB_TO_VECTOR))
06203             wSavedToType |= DBTYPE_VECTOR;
06204
06205           //Obtain all Selected ConvertFlag items...
06206           INDEX iSelCount = (INDEX)SendMessage(hWndConvFlags, LB_GETSELCOUNT, 0, 0);
06207           ASSERT(iSelCount < 20);
06208           LONG rgSelItems[20];
06209           SendMessage(hWndConvFlags, LB_GETSELITEMS, (WPARAM)20, (LPARAM)rgSelItems);
06210
06211           fSelColumnFlag = FALSE;
06212           dwSavedConvFlags = 0;
06213           for(LONG i=0; i<iSelCount; i++)
06214           {
06215             DWORD dwSelFlag = (DWORD)SendMessage(hWndConvFlags, LB_GETITEMDATA, rgSelItems[i], 0);
06216             if(dwSelFlag == DBCONVERTFLAGS_COLUMN)
06217               fSelColumnFlag = TRUE;
06218             dwSavedConvFlags |= dwSelFlag;
06219           }
06220
06221           //Obtain the Correct IConvertType interface
06222           pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
06223           ASSERT(pCDataAccess);
06224
06225           //Now Just call IConvertType::CanConvert
06226           ASSERT(pCDataAccess->m_pIConvertType);
06227           hr = pCDataAccess->m_pIConvertType->CanConvert(wSavedFromType, wSavedToType, dwSavedConvFlags);
06228           TRACE_METHOD(hr, L"IConvertType::CanConvert(%d=0x%08x, %d=0x%08x, 0x%08x)", wSavedFromType, wSavedFromType, wSavedToType, wSavedToType, dwSavedConvFlags);
06229
06230           //Now display the results
06231           //We always want to display the result even on error...
06232           wSendMessageFmt(hWndResult, WM_SETTEXT, 0, L" %S", GetErrorName(hr));
06233           return 0;
06234         }
06235
06236         case IDCANCEL:
06237         {
06238           EndDialog(hWnd, FALSE);
06239           return 0;
06240         }
06241       }
06242       break;
06243     }//WM_COMMAND
06244   }
06245
06246   return FALSE;
06247 }
06248
06249
06250 ////////////////////////////////////////////////////////////////
06251 // CMDIChild::OpenRowsetProc
06252 //
06253 /////////////////////////////////////////////////////////////////
06254 INT_PTR WINAPI CMDIChild::OpenRowsetProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
06255 {
06256   static CComboBoxGuid    s_CComboInterface;
06257   static CRichEditLite    s_editTableID;
06258   static CRichEditLite    s_editIndexID;
06259
06260   static BOOL fUseProps   = TRUE;     //Default
06261   static BOOL fAggregation  = FALSE;    //Default
06262   static BOOL fOutput     = TRUE;     //Default
06263
06264   switch(message)
06265   {
06266     case WM_INITDIALOG:
06267     {
06268       CWaitCursor waitCursor;
06269
06270       //Save the "this" pointer
06271       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
06272
06273       //Window Title (Default is IOpenRowset::OpenRowset)
06274       if(pThis->m_idSource == IDM_ISCOPEDOPERATIONS_OPENROWSET)
06275 				::SetWindowText(hWnd, "IScopedOperations::OpenRowset");
06276
06277       //Fill In TableID as Default
06278       s_editTableID.CreateIndirect(hWnd, IDE_TABLEID);
06279       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
06280       s_editTableID.SetWindowText(pwszTableName);
06281
06282       //Fill in IndexID as default
06283       s_editIndexID.CreateIndirect(hWnd, IDE_INDEXID);
06284
06285       //Use Properties
06286 			::CheckDlgButton(hWnd, IDB_USEPROPERTIES,  BST2STATE(fUseProps));
06287
06288       //Aggregation
06289 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
06290
06291       //Output (ppIUnknown)
06292 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
06293
06294       //Interface List...
06295       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
06296       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
06297       if(s_CComboInterface.RestoreSelection() == CB_ERR)
06298         s_CComboInterface.SetGuid(IID_IRowset);
06299
06300       SAFE_FREE(pwszTableName);
06301       CenterDialog(hWnd);
06302       return TRUE;
06303     }
06304
06305     case WM_COMMAND:
06306     {
06307       //Filter out any Control Notification codes
06308       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
06309       {
06310         return UNHANDLED_MSG;
06311       }
06312
06313       switch (GET_WM_COMMAND_ID(wParam, lParam))
06314       {
06315         case IDB_SETPROPERTIES:
06316         {
06317           //Get the "this" pointer
06318           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
06319           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
06320           CDataSource* pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
06321
06322           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
06323           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &pThis->m_CDefPropSets);
06324           return 0;
06325         }
06326
06327         case IDB_AGGREGATION:
06328         {
06329           //Aggregation Combo Selection has changed...
06330           //If we are now using Aggregation, automatically change the requested
06331           //riid to IID_IUnknown, since its an error otherwise...
06332           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
06333             s_CComboInterface.SetGuid(IID_IUnknown);
06334           return 0;
06335         }
06336
06337         case IDOK:
06338         {
06339           CWaitCursor waitCursor;
06340
06341           //Get the "this" pointer
06342           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
06343           CSession* pCSession = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
06344           CRow* pCRow     = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
06345
06346           IUnknown* pIUnknown = NULL;
06347           HRESULT hr = S_OK;
06348
06349           ULONG cPropSets = 0;
06350           DBPROPSET* rgPropSets = NULL;
06351
06352           //Obtain the Aggregation argument
06353           CAggregate* pCAggregate = NULL;
06354           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
06355           if(fAggregation)
06356             pCAggregate = new CAggregate();
06357
06358           //Obtain the Output (ppIUnknown) argument
06359           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
06360
06361           //Interface
06362           REFIID riid = s_CComboInterface.GetGuid();
06363
06364           //TableID
06365           CComWSTR cstrTableName;
06366           cstrTableName.Attach(s_editTableID.GetWindowText());
06367
06368           DBID TableID;
06369           TableID.eKind = DBKIND_NAME;
06370           TableID.uName.pwszName = cstrTableName;
06371           DBID* pTableID = cstrTableName ? &TableID : NULL;
06372
06373           //IndexID
06374           //NOTE: Most providers don't support IndexIDs and fail if a non-NULL pointer is
06375           //passed in, so unless the user specified something just use NULL...
06376           CComWSTR cstrIndexName;
06377           cstrIndexName.Attach(s_editIndexID.GetWindowText());
06378
06379           DBID IndexID;
06380           IndexID.eKind = DBKIND_NAME;
06381           IndexID.uName.pwszName = cstrIndexName;
06382           DBID* pIndexID = cstrIndexName ? &IndexID : NULL;
06383
06384           //Use Properties
06385           fUseProps = ::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES);
06386           if(fUseProps)
06387           {
06388             cPropSets = pThis->m_CDefPropSets.GetCount();
06389             rgPropSets = pThis->m_CDefPropSets.GetPropSets();
06390           }
06391
06392           //OpenRowset
06393           ASSERT(pCSession || pCRow);
06394           if(pCSession)
06395             hr = pCSession->OpenRowset(pCAggregate, pTableID, pIndexID, riid, cPropSets, rgPropSets, fOutput ? &pIUnknown : NULL);
06396           else
06397             hr = pCRow->OpenRowset(pCAggregate, pTableID, pIndexID, riid, cPropSets, rgPropSets, fOutput ? &pIUnknown : NULL);
06398
06399           if(SUCCEEDED(hr))
06400           {
06401             //Create an object description from the TableName (and index if used)
06402             //1.  TableName only    - "TableName"
06403             //2.  TableName and Index - "TableName.IndexName"
06404             //3.  IndexName only    - "IndexName"
06405             CComWSTR cstrDesc;
06406             cstrDesc.CopyFrom(cstrTableName);
06407             if(cstrIndexName)
06408             {
06409               if(cstrTableName)
06410                 cstrDesc += L".";
06411               cstrDesc += cstrIndexName;
06412             }
06413
06414             //Delegate to display the object
06415             hr = pThis->HandleRowset(pThis->m_pCSource, pIUnknown, riid, CREATE_NEWWINDOW_IFEXISTS, pCSession ? IID_IOpenRowset : IID_IScopedOperations, cstrDesc);
06416           }
06417
06418           if(SUCCEEDED(hr))
06419           {
06420             //Now just need to place this name in the EditBox
06421             //Inserted after the current "caret"
06422             pThis->m_pCQueryBox->ReplaceAll(cstrTableName, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
06423             EndDialog(hWnd, TRUE);
06424           }
06425
06426           SAFE_RELEASE(pCAggregate);
06427           SAFE_RELEASE(pIUnknown);
06428           return 0;
06429         }
06430
06431         case IDCANCEL:
06432         {
06433           EndDialog(hWnd, FALSE);
06434           return 0;
06435         }
06436       }
06437       break;
06438     }//WM_COMMAND
06439   }
06440
06441   return FALSE;
06442 }
06443
06444
06445 ////////////////////////////////////////////////////////////////
06446 // CMDIChild::RowOpenProc
06447 //
06448 /////////////////////////////////////////////////////////////////
06449 INT_PTR WINAPI CMDIChild::RowOpenProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
06450 {
06451   static INDEX iSavedType = 5;  //DBGUID_STREAM
06452   static CComboBoxGuid    s_CComboInterface;
06453   static BOOL fAggregation  = FALSE;    //Default
06454   static BOOL fOutput     = TRUE;     //Default
06455
06456   switch(message)
06457   {
06458     case WM_INITDIALOG:
06459     {
06460       CWaitCursor waitCursor;
06461
06462       //Save the "this" pointer
06463       CMDIChild* pThis  = (CMDIChild*)SetThis(hWnd, (void*)lParam);
06464       CRow* pCRow     = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
06465
06466       INDEX iSel = 0;
06467
06468       HWND hWndColumns  = ::GetDlgItem(hWnd, IDC_COLUMNS);
06469       HWND hWndObjectType = ::GetDlgItem(hWnd, IDC_OBJECTTYPE);
06470
06471       //Fill In ColumnID drop down
06472       INDEX iDefColumn = -1;
06473       for(ULONG i=0; i<pCRow->m_ColumnInfo.GetCount(); i++)
06474       {
06475         iSel = (INDEX)wSendMessage(hWndColumns, CB_ADDSTRING, 0, GetColName(&pCRow->m_ColumnInfo[i]));
06476         SendMessage(hWndColumns, CB_SETITEMDATA, iSel, (LPARAM)&pCRow->m_ColumnInfo[i].columnid);
06477
06478         //Default the selected column to the first BLOB, Stream, or IUnknown object
06479         if(iDefColumn==-1 && ((pCRow->m_ColumnInfo[i].wType == DBTYPE_IUNKNOWN) || (pCRow->m_ColumnInfo[i].dwFlags & (DBCOLUMNFLAGS_ISLONG | DBCOLUMNFLAGS_ISDEFAULTSTREAM))))
06480           iDefColumn = i;
06481       }
06482
06483       //Now also add the special column guids, which may not be a part of the ColumnInfo
06484       for(i=0; i<g_cRowColMaps; i++)
06485       {
06486         iSel = (INDEX)wSendMessage(hWndColumns, CB_ADDSTRING, 0, g_rgRowColMaps[i].pwszName);
06487         SendMessage(hWndColumns, CB_SETITEMDATA, iSel, (LPARAM)g_rgRowColMaps[i].pDBID);
06488       }
06489
06490       //Set the Default Selection
06491       if(iDefColumn == -1)
06492         iDefColumn = iSel;
06493       SendMessage(hWndColumns, CB_SETCURSEL, iDefColumn, 0);
06494
06495       //Fill In ObjectType drop down
06496       for(i=0; i<g_cObjectTypeMaps; i++)
06497       {
06498         iSel = (INDEX)wSendMessage(hWndObjectType, CB_ADDSTRING, 0, g_rgObjectTypeMaps[i].pwszName);
06499         SendMessage(hWndObjectType, CB_SETITEMDATA, iSel, (LPARAM)&g_rgObjectTypeMaps[i]);
06500       }
06501       SendMessage(hWndObjectType, CB_SETCURSEL, iSavedType, 0);
06502
06503       //Aggregation
06504 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
06505
06506       //Output (ppIUnknown)
06507 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
06508
06509       //Interface List...
06510       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
06511       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
06512       if(s_CComboInterface.RestoreSelection() == CB_ERR)
06513         s_CComboInterface.SetGuid(IID_ISequentialStream);
06514
06515       CenterDialog(hWnd);
06516       return TRUE;
06517     }
06518
06519     case WM_COMMAND:
06520     {
06521       //Filter out any Control Notification codes
06522       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
06523       {
06524         return UNHANDLED_MSG;
06525       }
06526
06527       switch (GET_WM_COMMAND_ID(wParam, lParam))
06528       {
06529         case IDB_AGGREGATION:
06530         {
06531           //Aggregation Combo Selection has changed...
06532           //If we are now using Aggregation, automatically change the requested
06533           //riid to IID_IUnknown, since its an error otherwise...
06534           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
06535             s_CComboInterface.SetGuid(IID_IUnknown);
06536           return 0;
06537         }
06538
06539         case IDOK:
06540         {
06541           CWaitCursor waitCursor;
06542
06543           //Get the "this" pointer
06544           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
06545           CRow* pCRow     = SOURCE_GETOBJECT(pThis->m_pCSource, CRow);
06546           IUnknown* pIUnknown = NULL;
06547           DWORD dwCreateOpts = CREATE_NEWWINDOW;
06548
06549           HWND hWndColumns  = ::GetDlgItem(hWnd, IDC_COLUMNS);
06550           HWND hWndObjectType = ::GetDlgItem(hWnd, IDC_OBJECTTYPE);
06551           HRESULT hr = S_OK;
06552
06553           //ColumnID
06554           INDEX iSel = (INDEX)SendMessage(hWndColumns, CB_GETCURSEL, 0, 0);
06555           DBID* pColID = (DBID*)SendMessage(hWndColumns, CB_GETITEMDATA, iSel, 0);
06556
06557           //ObjectType
06558           iSavedType = (INDEX)SendMessage(hWndObjectType, CB_GETCURSEL, 0, 0);
06559           WIDEGUIDMAP* pObjectMap = (WIDEGUIDMAP*)SendMessage(hWndObjectType, CB_GETITEMDATA, iSavedType, 0);
06560           GUID guidObjectType = *pObjectMap->pGuid;
06561           if(guidObjectType == GUID_NULL)
06562             dwCreateOpts |= CREATE_DETERMINE_TYPE;
06563
06564           //Obtain the Aggregation argument
06565           CAggregate* pCAggregate = NULL;
06566           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
06567           if(fAggregation)
06568             pCAggregate = new CAggregate();
06569
06570           //Obtain the Output (ppIUnknown) argument
06571           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
06572
06573           //Interface
06574           REFIID riid = s_CComboInterface.GetGuid();
06575
06576           //IRow::Open
06577           TESTC(hr = pCRow->Open(pCAggregate, pColID, guidObjectType, riid, fOutput ? &pIUnknown : NULL));
06578
06579           //Handle the returned object type...
06580           //NOTE: We know the object returned, or eCUnknown is passed to determine it
06581           if(!pThis->m_pCMainWindow->HandleObjectType(pCRow, pIUnknown, riid, GuidToSourceType(guidObjectType), 0, NULL, dwCreateOpts))
06582             TESTC(hr = E_FAIL);
06583
06584         CLEANUP:
06585           SAFE_RELEASE(pCAggregate);
06586           SAFE_RELEASE(pIUnknown);
06587
06588           if(SUCCEEDED(hr))
06589             EndDialog(hWnd, TRUE);
06590           return 0;
06591         }
06592
06593         case IDCANCEL:
06594         {
06595           EndDialog(hWnd, FALSE);
06596           return 0;
06597         }
06598       }
06599       break;
06600     }//WM_COMMAND
06601   }
06602
06603   return FALSE;
06604 }
06605
06606
06607 ////////////////////////////////////////////////////////////////
06608 // CMDIChild::GetObject
06609 //
06610 /////////////////////////////////////////////////////////////////
06611 CBase* CMDIChild::GetObject(SOURCE eSource, BOOL fAlways)
06612 {
06613   //First try to obtain the last object...
06614   CBase** ppCBase = GetObjectAddress(eSource);
06615   if(ppCBase)
06616   {
06617     CBase* pCBase = *ppCBase;
06618     if(pCBase && (eSource==eCUnknown || pCBase->GetObjectType()==eSource || pCBase->GetBaseType() & eSource) && (fAlways || pCBase->m_pIUnknown))
06619       return pCBase;
06620   }
06621
06622   return NULL;
06623 }
06624
06625
06626 ////////////////////////////////////////////////////////////////
06627 // CMDIChild::GetObjectAddress
06628 //
06629 /////////////////////////////////////////////////////////////////
06630 CBase** CMDIChild::GetObjectAddress(SOURCE eSource)
06631 {
06632   CBase** ppCObject = NULL;
06633
06634   switch(eSource)
06635   {
06636     case eCDataSource:
06637       ppCObject = (CBase**)&m_pCDataSource;
06638       break;
06639
06640     case eCSession:
06641       ppCObject = (CBase**)&m_pCSession;
06642       break;
06643
06644     case eCCommand:
06645       ppCObject = (CBase**)&m_pCCommand;
06646       break;
06647
06648     case eCMultipleResults:
06649       ppCObject = (CBase**)&m_pCMultipleResults;
06650       break;
06651
06652     case eCDataset:
06653     case eCRowset:
06654     case eCRow:
06655       //Only one of these objects is active at any one time
06656       //Since all of them actually use the "DataGrid" we can only have one per MDIChild
06657       ppCObject = (CBase**)&m_pCDataAccess;
06658       break;
06659
06660     case eCUnknown:
06661       //Determine "Last" object type...
06662       if(m_pCDataAccess && m_pCDataAccess->m_pIUnknown)
06663         return (CBase**)&m_pCDataAccess;
06664       else if(m_pCMultipleResults && m_pCMultipleResults->m_pIUnknown)
06665         return (CBase**)&m_pCMultipleResults;
06666       else if(m_pCCommand && m_pCCommand->m_pIUnknown)
06667         return (CBase**)&m_pCCommand;
06668       else if(m_pCSession && m_pCSession->m_pIUnknown)
06669         return (CBase**)&m_pCSession;
06670       else if(m_pCDataSource && m_pCDataSource->m_pIUnknown)
06671         return (CBase**)&m_pCDataSource;
06672       break;
06673
06674     default:
06675       break;
06676   };
06677
06678   return ppCObject;
06679 }
06680
06681
06682 ////////////////////////////////////////////////////////////////
06683 // CMDIChild::HandleRowset
06684 //
06685 /////////////////////////////////////////////////////////////////
06686 HRESULT CMDIChild::HandleRowset(CBase* pCSource, IUnknown* pIUnknown, REFIID riid, DWORD dwFlags, REFGUID guidSource, WCHAR* pwszTableName, BOOL fSchemaRowset)
06687 {
06688   HRESULT hr = S_OK;
06689
06690   //Handle the Result
06691   //NOTE: Result can be NULL for non-row returning results...
06692   if(pIUnknown)
06693   {
06694     //Don't display the object
06695     dwFlags |= CREATE_NODISPLAY;
06696
06697     //Now Create the object...
06698     //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
06699     CBase* pCObject = m_pCMainWindow->HandleObjectType(pCSource, pIUnknown, riid, eCRowset, 0, NULL, dwFlags | CREATE_DETERMINE_TYPE);
06700     if(pCObject)
06701     {
06702       //Record the source of the object...
06703       pCObject->m_guidSource = guidSource;
06704       CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pCObject, CDataAccess);
06705       if(pCDataAccess)
06706       {
06707         pCDataAccess->m_bSchemaRowset = fSchemaRowset;
06708
06709         //Save the passed in TableName...
06710         pCDataAccess->SetObjectDesc(pwszTableName);
06711       }
06712
06713       //Now Display the object...
06714       pCObject->DisplayObject();
06715     }
06716     else
06717     {
06718       TESTC(hr = E_FAIL);
06719     }
06720   }
06721
06722 CLEANUP:
06723   UpdateControls();
06724   return hr;
06725 }
06726
06727
06728
06729 ////////////////////////////////////////////////////////////////
06730 // CMDIChild::AdminCreateDataSourceProc
06731 //
06732 /////////////////////////////////////////////////////////////////
06733 INT_PTR WINAPI CMDIChild::AdminCreateDataSourceProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
06734 {
06735   static BOOL fUseProps = TRUE; //Default to TRUE
06736
06737   static CPropSets      s_CAdminPropSets;
06738   static CComboBoxGuid    s_CComboInterface;
06739   static BOOL fAggregation  = FALSE;    //Default
06740   static BOOL fOutput     = TRUE;     //Default
06741
06742   switch(message)
06743   {
06744     case WM_INITDIALOG:
06745     {
06746       CWaitCursor waitCursor;
06747
06748       //Save the "this" pointer
06749       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
06750
06751       //Use Properties
06752 			::CheckDlgButton(hWnd, IDB_USEPROPERTIES,  BST2STATE(fUseProps));
06753       //Reset our static properties...
06754       s_CAdminPropSets.RemoveAll();
06755
06756       //Aggregation
06757 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
06758
06759       //Output (ppIUnknown)
06760 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
06761
06762       //Interface List...
06763       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
06764       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
06765       if(s_CComboInterface.RestoreSelection() == CB_ERR)
06766         s_CComboInterface.SetGuid(IID_IOpenRowset);
06767
06768       CenterDialog(hWnd);
06769       return TRUE;
06770     }
06771
06772     case WM_COMMAND:
06773     {
06774       //Filter out any Control Notification codes
06775       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
06776       {
06777         return UNHANDLED_MSG;
06778       }
06779
06780       switch (GET_WM_COMMAND_ID(wParam, lParam))
06781       {
06782         case IDB_SETPROPERTIES:
06783         {
06784           //Get the "this" pointer
06785           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
06786           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
06787           CDataSource* pCDataSource = SOURCE_GETOBJECT(pThis->m_pCSource, CDataSource);
06788
06789           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
06790           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_DBINITALL, IID_IDBProperties, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &s_CAdminPropSets);
06791           return 0;
06792         }
06793
06794         case IDB_AGGREGATION:
06795         {
06796           //Aggregation Combo Selection has changed...
06797           //If we are now using Aggregation, automatically change the requested
06798           //riid to IID_IUnknown, since its an error otherwise...
06799           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
06800             s_CComboInterface.SetGuid(IID_IUnknown);
06801           return 0;
06802         }
06803
06804         case IDOK:
06805         {
06806           CWaitCursor waitCursor;
06807
06808           //Get the "this" pointer
06809           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
06810           CDataSource* pCDataSource = SOURCE_GETOBJECT(pThis->m_pCSource, CDataSource);
06811
06812           HRESULT hr = S_OK;
06813
06814           ULONG cPropSets = 0;
06815           DBPROPSET* rgPropSets = NULL;
06816           IUnknown* pIUnknown = NULL;
06817
06818           //Obtain the Aggregation argument
06819           CAggregate* pCAggregate = NULL;
06820           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
06821           if(fAggregation)
06822             pCAggregate = new CAggregate();
06823
06824           //Obtain the Output (ppIUnknown) argument
06825           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
06826
06827           //Interface
06828           REFIID riid = s_CComboInterface.GetGuid();
06829
06830           //Use Properties
06831           fUseProps = ::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES);
06832           if(fUseProps)
06833           {
06834             cPropSets = s_CAdminPropSets.GetCount();
06835             rgPropSets = s_CAdminPropSets.GetPropSets();
06836           }
06837
06838           //IDBDataSourceAdmin::CreateDataSource
06839           //NOTE: Our helper takes care of aggregation...
06840           hr = pCDataSource->AdminCreateDataSource(pCAggregate, cPropSets, rgPropSets, riid, fOutput ? &pIUnknown : NULL);
06841
06842           //Display the Result
06843           if(SUCCEEDED(hr) && fOutput)
06844           {
06845             //Just pass in a guess for the object type and let our helper figure out what object it is...
06846             if(!pThis->m_pCMainWindow->HandleObjectType(pCDataSource, pIUnknown, riid, eCSession, 0, NULL, CREATE_NEWWINDOW_IFEXISTS))
06847               hr = E_FAIL;
06848           }
06849
06850           //Release
06851           SAFE_RELEASE(pIUnknown);
06852           SAFE_RELEASE(pCAggregate);
06853           pThis->UpdateControls();
06854
06855           if(SUCCEEDED(hr))
06856           {
06857             s_CAdminPropSets.RemoveAll();
06858             EndDialog(hWnd, TRUE);
06859             return 0;
06860           }
06861           return 0;
06862         }
06863
06864         case IDCANCEL:
06865         {
06866           s_CAdminPropSets.RemoveAll();
06867           EndDialog(hWnd, FALSE);
06868           return 0;
06869         }
06870       }
06871       break;
06872     }//WM_COMMAND
06873   }
06874
06875   return FALSE;
06876 }
06877
06878
06879 ////////////////////////////////////////////////////////////////
06880 // CMDIChild::CreateIndexProc
06881 //
06882 /////////////////////////////////////////////////////////////////
06883 INT_PTR WINAPI CMDIChild::CreateIndexProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
06884 {
06885   //NOTE:  These are static variables, just to hold the PropertyInfo
06886   //Information temporarily.  There are messages that need this info which
06887   //gets setup on INITDIALOG.  On OK or CANCEL this info will be freed...
06888   static WCHAR    *pStringBuffer  = NULL;
06889   ULONG       i;
06890   LONG        iSel = 0;
06891   static WCHAR    wszBuffer[MAX_NAME_LEN+1];
06892
06893   switch(message)
06894   {
06895     case WM_INITDIALOG:
06896     {
06897       //Save the "this" pointer
06898       CWaitCursor waitCursor;
06899       CMDIChild   *pThis      = (CMDIChild*)SetThis(hWnd, (void*)lParam);
06900
06901       //Use Extended ListView Styles!
06902       HWND    hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
06903       HWND    hWndTableID     = ::GetDlgItem(hWnd, IDE_TABLEID);
06904       HWND    hWndOrder     = ::GetDlgItem(hWnd, IDC_ORDER);
06905       HWND    hWndColumnID    = ::GetDlgItem(hWnd, IDE_COLUMNID);
06906       RECT    rect;
06907
06908       SendMessage(hWndIndexColumnDesc, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
06909
06910       //Fill In TableID as Default
06911       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
06912       wSendMessage(hWndTableID, WM_SETTEXT, 0, pwszTableName);
06913
06914       //ColumnHeaders for INDEXCOLUMNDESC report
06915       LV_InsertColumn(hWndIndexColumnDesc,   COLUMN_ID, L"Column ID", IMAGE_NONE);
06916       LV_InsertColumn(hWndIndexColumnDesc,   COLUMN_ORDER,L"Order", IMAGE_NONE);
06917
06918       //AutoSize Columns
06919       GetWindowRect(hWndColumnID, (LPRECT)&rect);
06920       SendMessage(hWndIndexColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_ID, (LPARAM)(rect.right-rect.left));
06921       GetWindowRect(hWndOrder, (LPRECT)&rect);
06922       SendMessage(hWndIndexColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_ORDER, (LPARAM)(rect.right-rect.left));
06923
06924       // Order list...
06925       SendMessage(hWndOrder, CB_ADDSTRING, 0, (LPARAM)"Ascendent");
06926       SendMessage(hWndOrder, CB_ADDSTRING, 0, (LPARAM)"Descendent");
06927       SendMessage(hWndOrder, CB_SETCURSEL, 0, 0); // ascendent
06928
06929       //Placement of Dialog, want it just below the "Init" button...
06930       CenterDialog(hWnd);
06931
06932       //Disable fields
06933 			::EnableWindow(::GetDlgItem(hWnd, IDE_COLUMNID), FALSE);
06934 			::EnableWindow(::GetDlgItem(hWnd, IDC_ORDER), FALSE);
06935
06936       SAFE_FREE(pwszTableName)
06937       return TRUE;
06938     }
06939
06940     case WM_COMMAND:
06941     {
06942       switch (GET_WM_COMMAND_CMD(wParam, lParam))
06943       {
06944         case EN_KILLFOCUS:
06945         {
06946           switch((int)LOWORD(wParam))
06947           {
06948             case IDE_COLUMNID:
06949             {
06950               HWND    hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
06951               HWND    hWndColumnID    = ::GetDlgItem(hWnd, IDE_COLUMNID);
06952               HWND    hWndColName     = ::GetDlgItem(hWnd, IDE_COLNAME);
06953               WCHAR   wszBuffer2[MAX_NAME_LEN+1];
06954
06955               // get the selected item
06956               iSel = ListView_GetNextItem(hWndIndexColumnDesc, -1, LVNI_SELECTED);
06957
06958               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
06959               // and to Column Name static field
06960               wSendMessage(hWndColumnID, WM_GETTEXT, MAX_NAME_LEN, wszBuffer2);
06961               StringFormat(wszBuffer, NUMELE(wszBuffer), L"Current item %d (%s)", iSel, wszBuffer2);
06962               LV_SetItemText(hWndIndexColumnDesc, iSel, COLUMN_ID, wszBuffer2);
06963               wSendMessage(hWndColName, WM_SETTEXT, 0, wszBuffer);
06964               return 0;
06965             }
06966           }
06967           return 0;
06968         }
06969       }
06970       //Filter out any Control Notification codes
06971       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
06972       {
06973         return UNHANDLED_MSG;
06974       }
06975
06976       //CBN_SELCHANGE
06977       switch(GET_WM_COMMAND_CMD(wParam, lParam))
06978       {
06979         case CBN_SELCHANGE:
06980         {
06981           switch(GET_WM_COMMAND_ID(wParam, lParam))
06982           {
06983             case IDC_ORDER:
06984             {
06985               HWND    hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
06986               HWND    hWndOrder     = ::GetDlgItem(hWnd, IDC_ORDER);
06987               INDEX   iSelOrder     = (INDEX)SendMessage(hWndOrder, CB_GETCURSEL, 0, 0);
06988
06989               // get the selected item
06990               iSel = ListView_GetNextItem(hWndIndexColumnDesc, -1, LVNI_SELECTED);
06991
06992               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
06993               wSendMessage(hWndOrder, CB_GETLBTEXT, (WPARAM)iSelOrder, wszBuffer);
06994               LV_SetItemText(hWndIndexColumnDesc, iSel, COLUMN_ORDER, wszBuffer);
06995               return 0;
06996             }
06997           }
06998           return 0;
06999         }
07000       }
07001
07002       //Regular command messages
07003       switch(GET_WM_COMMAND_ID(wParam, lParam))
07004       {
07005         case IDB_INDEXPROPERTIES:
07006         {
07007           //Get the "this" pointer
07008           CMDIChild *pThis      = (CMDIChild*)GetThis(hWnd);
07009           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
07010           CDataSource* pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
07011
07012           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
07013           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_INDEXALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &pThis->m_CDefPropSets);
07014           return 0;
07015         }
07016
07017         case IDB_ADD:
07018         {
07019           HWND    hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
07020           ULONG   cItems        = ListView_GetItemCount(hWndIndexColumnDesc);
07021
07022           // make the insertion
07023           StringFormat(wszBuffer, NUMELE(wszBuffer), L"Column%lu", cItems);
07024           LV_InsertItem(hWndIndexColumnDesc, cItems, COLUMN_ID, wszBuffer);
07025
07026           // order
07027           LV_InsertItem(hWndIndexColumnDesc, cItems, COLUMN_ORDER, L"Ascendent");
07028           LV_SetItemState(hWndIndexColumnDesc, cItems, COLUMN_ID, LVIS_SELECTED, LVIS_SELECTED);
07029           return 0;
07030         }
07031
07032         case IDB_DELETE:
07033         {
07034           HWND    hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
07035           INT     cItems        = ListView_GetItemCount(hWndIndexColumnDesc);
07036
07037           // get the selected item
07038           iSel = ListView_GetNextItem(hWndIndexColumnDesc, -1, LVNI_SELECTED);
07039
07040           if (iSel > -1)
07041           {
07042             ListView_DeleteItem(hWndIndexColumnDesc, iSel);
07043             SendMessage(::GetDlgItem(hWnd, IDE_COLNAME), WM_SETTEXT, 0, (LPARAM)"");
07044             LV_SetItemState(hWndIndexColumnDesc, iSel >= cItems-1 ? iSel-1: iSel,
07045               COLUMN_DBCID, LVIS_SELECTED, LVIS_SELECTED);
07046           }
07047           //Disable fields
07048 					::EnableWindow(::GetDlgItem(hWnd, IDE_COLUMNID), FALSE);
07049 					::EnableWindow(::GetDlgItem(hWnd, IDC_ORDER), FALSE);
07050           return 0;
07051         }
07052
07053         case IDCANCEL:
07054         {
07055           //Cleanup any memory allocated
07056           SAFE_FREE(pStringBuffer);
07057           EndDialog(hWnd, FALSE);
07058           return 0;
07059         }
07060
07061         case IDOK:
07062         {
07063           CWaitCursor waitCursor;
07064
07065           //Get the "this" pointer
07066           CMDIChild     *pThis        = (CMDIChild*)GetThis(hWnd);
07067           CSession      *pCSession      = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07068
07069           HWND        hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
07070           HWND        hWndTableID     = ::GetDlgItem(hWnd, IDE_TABLEID);
07071           HWND        hWndIndexID     = ::GetDlgItem(hWnd, IDE_INDEXID);
07072           DBINDEXCOLUMNDESC *rgIndexColumnDesc  = NULL;
07073           ULONG       cIndexColumnDesc  = 0;
07074           DBID        TableID;
07075           WCHAR       wszTableDBID[MAX_QUERY_LEN+1];
07076           DBID        IndexID;
07077           WCHAR       wszIndexDBID[MAX_QUERY_LEN+1];
07078           DBPROPSET     *rgPropSet      = NULL;
07079           ULONG       cPropSet      = 0;
07080           HRESULT       hr;
07081
07082           // alloc space for the column desc array
07083           cIndexColumnDesc = ListView_GetItemCount(hWndIndexColumnDesc);
07084           SAFE_ALLOC(rgIndexColumnDesc, DBINDEXCOLUMNDESC, cIndexColumnDesc);
07085
07086           // get the column desc array
07087           for (i=0; i<cIndexColumnDesc; i++)
07088           {
07089             // initialize the whole structure
07090             memset(&rgIndexColumnDesc[i], 0, sizeof(DBINDEXCOLUMNDESC));
07091
07092             // get column name
07093             LV_GetItemText(hWndIndexColumnDesc, i, COLUMN_ID, wszBuffer, MAX_NAME_LEN);
07094             SAFE_ALLOC(rgIndexColumnDesc[i].pColumnID, DBID, 1);
07095             rgIndexColumnDesc[i].pColumnID->eKind     = DBKIND_NAME;
07096             rgIndexColumnDesc[i].pColumnID->uName.pwszName  = wcsDuplicate(wszBuffer);
07097
07098             // get column order
07099             LV_GetItemText(hWndIndexColumnDesc, i, COLUMN_ORDER, wszBuffer, MAX_NAME_LEN);
07100             if (StringCompare(wszBuffer, L"Descendent"))
07101               rgIndexColumnDesc[i].eIndexColOrder = DBINDEX_COL_ORDER_DESC;
07102             else
07103               rgIndexColumnDesc[i].eIndexColOrder = DBINDEX_COL_ORDER_ASC;
07104           }
07105
07106           // get TableID
07107           TableID.eKind = DBKIND_NAME;
07108           TableID.uName.pwszName = wGetWindowText(hWndTableID);
07109           DBIDToString(&TableID, wszTableDBID, MAX_QUERY_LEN);
07110
07111           // get IndexID
07112           IndexID.eKind     = DBKIND_NAME;
07113           IndexID.uName.pwszName  = wGetWindowText(hWndIndexID);
07114           DBIDToString(&IndexID, wszIndexDBID, MAX_QUERY_LEN);
07115
07116           // check whether rowset/table properties are used
07117           if(::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES))
07118           {
07119             cPropSet  = pThis->m_CDefPropSets.GetCount();
07120             rgPropSet = pThis->m_CDefPropSets.GetPropSets();
07121           }
07122
07123           XTEST(hr = pCSession->m_pIIndexDefinition->CreateIndex(&TableID, &IndexID, cIndexColumnDesc, rgIndexColumnDesc, cPropSet, rgPropSet, NULL));
07124           TESTC(TRACE_METHOD(hr, L"IIndexDefinition::CreateIndex(%s, %s, %lu, 0x%p, %d, 0x%p, NULL)", wszTableDBID, wszIndexDBID, cIndexColumnDesc, rgIndexColumnDesc, cPropSet, rgPropSet));
07125
07126         CLEANUP:
07127           for (i=0; i<cIndexColumnDesc; i++)
07128           {
07129             if (DBKIND_NAME == rgIndexColumnDesc[i].pColumnID->eKind)
07130               SAFE_FREE(rgIndexColumnDesc[i].pColumnID->uName.pwszName);
07131           }
07132
07133           if(SUCCEEDED(hr))
07134           {
07135             //Now just need to place this name in the EditBox
07136             //Inserted after the current "caret"
07137             pThis->m_pCQueryBox->ReplaceAll(TableID.uName.pwszName, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
07138             EndDialog(hWnd, TRUE);
07139           }
07140
07141           SAFE_FREE(rgIndexColumnDesc);
07142           SAFE_FREE(TableID.uName.pwszName);
07143           SAFE_FREE(IndexID.uName.pwszName);
07144           return 0;
07145         }
07146       }
07147       break;
07148     }//WM_COMMAND
07149
07150     case WM_NOTIFY:
07151     {
07152       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
07153
07154       //ListView
07155       switch(pDispInfo->hdr.code)
07156       {
07157         //Since we have "TwoClickActive" on this will get sent
07158         //Whenever a row is clicked on twice!
07159         //This functionality used to be done with NM_DBCLK
07160         case LVN_ITEMACTIVATE:
07161         {
07162           return FALSE;
07163         }
07164
07165         case LVN_ITEMCHANGED:
07166         {
07167           HWND    hWndIndexColumnDesc = ::GetDlgItem(hWnd, IDL_INDEXCOLUMNDESC);
07168           HWND    hWndColumnID    = ::GetDlgItem(hWnd, IDE_COLUMNID);
07169           HWND    hWndOrder     = ::GetDlgItem(hWnd, IDC_ORDER);
07170           HWND    hWndColName     = ::GetDlgItem(hWnd, IDE_COLNAME);
07171           WCHAR   wszBuffer2[MAX_NAME_LEN+1];
07172           NMLISTVIEW  *pLV = (NMLISTVIEW*)lParam;
07173           INDEX   iOrder = 0;
07174
07175           if (pLV->uChanged != LVIF_STATE)
07176             return 0;
07177
07178           // get the selected item
07179           iSel = pLV->iItem;
07180           if (!(pLV->uNewState & LVIS_SELECTED))
07181           {
07182             if (!(pLV->uOldState & LVIS_SELECTED))
07183               return 0;
07184             // this is the previously selected item
07185             // retrieve the column name and copy it to the IDE_COLUMNID field
07186             wSendMessage(hWndColumnID, WM_GETTEXT, MAX_NAME_LEN, wszBuffer2);
07187             LV_SetItemText(hWndIndexColumnDesc, iSel, COLUMN_ID, wszBuffer2);
07188             StringFormat(wszBuffer, NUMELE(wszBuffer), L"Current item %lu (%s)", iSel, wszBuffer2);
07189             wSendMessage(hWndColName, WM_SETTEXT, 0, wszBuffer);
07190
07191             // retrieve the column type and copy it to the IDC_ORDER field
07192             iOrder = (INDEX)SendMessage(hWndOrder, CB_GETCURSEL, 0, 0);
07193             wSendMessage(hWndOrder, CB_GETLBTEXT, iOrder, wszBuffer);
07194             LV_SetItemText(hWndIndexColumnDesc, iSel, COLUMN_ORDER, wszBuffer);
07195           }
07196           else
07197           {
07198             // retrieve the column name and copy it to the IDE_COLUMNID field
07199             LV_GetItemText(hWndIndexColumnDesc, iSel, COLUMN_ID, wszBuffer2, MAX_NAME_LEN);
07200             wSendMessage(hWndColumnID, WM_SETTEXT, 0, wszBuffer2);
07201             StringFormat(wszBuffer, NUMELE(wszBuffer), L"Current item %lu (%s)", iSel, wszBuffer2);
07202             wSendMessage(hWndColName, WM_SETTEXT, 0, wszBuffer);
07203
07204             // retrieve the column type and copy it to the IDC_ORDER field
07205             LV_GetItemText(hWndIndexColumnDesc, iSel, COLUMN_ORDER, wszBuffer, MAX_NAME_LEN);
07206             SendMessage(hWndOrder, CB_SELECTSTRING, -1, (LPARAM)wszBuffer);
07207           }
07208
07209
07210           //Disable fields
07211 					::EnableWindow(::GetDlgItem(hWnd, IDE_COLUMNID), TRUE);
07212 					::EnableWindow(::GetDlgItem(hWnd, IDC_ORDER), TRUE);
07213           return FALSE;
07214         }
07215
07216         case LVN_ITEMCHANGING:
07217         {
07218             return FALSE; //Allow the change
07219         }
07220       }
07221     }//WM_NOTIFY
07222   }//switch message
07223
07224   return FALSE;
07225 } //CMDIChild::CreateIndexProc
07226
07227
07228 ////////////////////////////////////////////////////////////////
07229 // CMDIChild::DropIndexProc
07230 //
07231 /////////////////////////////////////////////////////////////////
07232 INT_PTR WINAPI CMDIChild::DropIndexProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
07233 {
07234   static CRichEditLite    s_editTableID;
07235   static CRichEditLite    s_editIndexID;
07236
07237   switch(message)
07238   {
07239     case WM_INITDIALOG:
07240     {
07241       CWaitCursor waitCursor;
07242
07243       //Save the "this" pointer
07244       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
07245
07246       //Fill In TableID as Default
07247       s_editTableID.CreateIndirect(hWnd, IDE_TABLEID);
07248       WCHAR* pwszIndexName = pThis->m_pCQueryBox->GetSelectedText();
07249       s_editTableID.SetWindowText(pwszIndexName);
07250
07251       //Fill In IndexID
07252       s_editIndexID.CreateIndirect(hWnd, IDE_INDEXID);
07253
07254       CenterDialog(hWnd);
07255       SAFE_FREE(pwszIndexName);
07256       return TRUE;
07257     }
07258
07259     case WM_COMMAND:
07260     {
07261       //Filter out any Control Notification codes
07262       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
07263       {
07264         return UNHANDLED_MSG;
07265       }
07266
07267       switch (GET_WM_COMMAND_ID(wParam, lParam))
07268       {
07269         case IDOK:
07270         {
07271           CWaitCursor waitCursor;
07272
07273           //Get the "this" pointer
07274           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
07275           CSession* pCSession = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07276           WCHAR wszTableDBID[MAX_NAME_LEN+1];
07277           WCHAR wszIndexDBID[MAX_NAME_LEN+1];
07278           HRESULT hr = S_OK;
07279
07280           //TableID
07281           DBID TableID;
07282           TableID.eKind = DBKIND_NAME;
07283           TableID.uName.pwszName = s_editTableID.GetWindowText();
07284           DBID* pTableID = TableID.uName.pwszName ? &TableID : NULL;
07285           DBIDToString(pTableID, wszTableDBID, MAX_NAME_LEN);
07286
07287           //IndexID
07288           DBID IndexID;
07289           IndexID.eKind = DBKIND_NAME;
07290           IndexID.uName.pwszName = s_editIndexID.GetWindowText();
07291           DBID* pIndexID = IndexID.uName.pwszName ? &IndexID : NULL;
07292           DBIDToString(pIndexID, wszIndexDBID, MAX_NAME_LEN);
07293
07294           //IIndexDefinition::DropIndex
07295           XTEST(hr = pCSession->m_pIIndexDefinition->DropIndex(pTableID, pIndexID));
07296           TRACE_METHOD(hr, L"IIndexDefinition::DropIndex(%s, %s)", wszTableDBID, wszIndexDBID);
07297
07298           if(SUCCEEDED(hr))
07299             EndDialog(hWnd, TRUE);
07300
07301           SAFE_FREE(TableID.uName.pwszName);
07302           SAFE_FREE(IndexID.uName.pwszName);
07303           return 0;
07304         }
07305
07306         case IDCANCEL:
07307         {
07308           EndDialog(hWnd, FALSE);
07309           return 0;
07310         }
07311       }
07312       break;
07313     }//WM_COMMAND
07314   }
07315
07316   return FALSE;
07317 }
07318
07319
07320 ////////////////////////////////////////////////////////////////
07321 // CMDIChild::AddColumnProc
07322 //
07323 /////////////////////////////////////////////////////////////////
07324 INT_PTR WINAPI CMDIChild::AddColumnProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
07325 {
07326   static CComboBoxGuid  s_CComboInterface;
07327   static BOOL       fUseProps = TRUE; //Default to TRUE
07328   static WCHAR      wszBuffer[MAX_NAME_LEN+1];
07329   ULONG i;
07330
07331   switch(message)
07332   {
07333     case WM_INITDIALOG:
07334     {
07335       CWaitCursor waitCursor;
07336
07337       //Save the "this" pointer
07338       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
07339       CSession* pCSession = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07340       INDEX iSel = 0;
07341
07342       HWND hWndTableID  = ::GetDlgItem(hWnd, IDE_TABLEID);
07343       HWND hWndTypeName = ::GetDlgItem(hWnd, IDC_TYPENAME);
07344       HWND hWndDataType = ::GetDlgItem(hWnd, IDC_TYPE);
07345       HWND hWndSize   = ::GetDlgItem(hWnd, IDE_SIZE);
07346       HWND hWndPrecision  = ::GetDlgItem(hWnd, IDE_PRECISION);
07347       HWND hWndScale    = ::GetDlgItem(hWnd, IDE_SCALE);
07348
07349       //Make sure we have the Provider Types rowset ahead of time
07350       pCSession->GetProviderTypes();
07351
07352       //Fill In TableID as Default
07353       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
07354       wSendMessage(hWndTableID, WM_SETTEXT, 0, pwszTableName);
07355
07356       //Fill In column size as Default
07357       wSendMessageFmt(hWndSize, WM_SETTEXT, 0, L"%d", 0);
07358
07359       //Fill In column precision as Default
07360       wSendMessageFmt(hWndPrecision, WM_SETTEXT, 0, L"%d", 0);
07361
07362       //Fill In column scale as Default
07363       wSendMessageFmt(hWndScale, WM_SETTEXT, 0, L"%d", 0);
07364
07365       //Use Properties
07366 			::CheckDlgButton(hWnd, IDB_USEPROPERTIES,  BST2STATE(fUseProps));
07367
07368       // Type Name list...
07369       for(i=0; i<pCSession->m_cProvTypes; i++)
07370       {
07371         //Type Name
07372         iSel = (INDEX)wSendMessage(hWndTypeName, CB_ADDSTRING,  0, pCSession->m_rgProvTypes[i].wszTypeName);
07373       }
07374       SendMessage(hWndTypeName, CB_SETCURSEL, 0, 0);
07375
07376       // DBType list
07377       for(i=0; i<g_cDBTypes; i++)
07378       {
07379         //DBTypes
07380         iSel = (INDEX)wSendMessage(hWndDataType, CB_ADDSTRING,  0, g_rgDBTypes[i].pwszName);
07381       }
07382       SendMessage(hWndDataType, CB_SETCURSEL, 0, 0);
07383
07384       for (i=0; i<g_cDBTypes; i++)
07385       {
07386         if (pCSession->m_rgProvTypes[0].wType == g_rgDBTypes[i].lItem)
07387         {
07388           SendMessage(hWndDataType, CB_SETCURSEL, i, 0);
07389           break;
07390         }
07391       }
07392       CenterDialog(hWnd);
07393       SAFE_FREE(pwszTableName);
07394       return TRUE;
07395     }
07396
07397     case WM_COMMAND:
07398     {
07399       //Filter out any Control Notification codes
07400       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
07401       {
07402         return UNHANDLED_MSG;
07403       }
07404
07405       //CBN_SELCHANGE
07406       switch(GET_WM_COMMAND_CMD(wParam, lParam))
07407       {
07408         //Selection change
07409         case CBN_SELCHANGE:
07410         {
07411           //See which combo box has changed
07412           switch(GET_WM_COMMAND_ID(wParam, lParam))
07413           {
07414             case IDC_TYPE:
07415             {
07416               CMDIChild   *pThis      = (CMDIChild*)GetThis(hWnd);
07417               CSession    *pCSession    = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07418               HWND      hWndSize    = ::GetDlgItem(hWnd, IDE_SIZE);
07419               HWND      hWndPrecision = ::GetDlgItem(hWnd, IDE_PRECISION);
07420               HWND      hWndScale   = ::GetDlgItem(hWnd, IDE_SCALE);
07421               INDEX     iSelTypeName;
07422               HWND      hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
07423               //Get the Selected Type
07424               CComboBoxLite comboTypes(hWnd, IDC_TYPE);
07425               comboTypes.GetSelText(wszBuffer, MAX_NAME_LEN);
07426               DBTYPE wType = GetDBType(wszBuffer);
07427
07428               //Get Default Size,Prec,Scale for this type...
07429               DBLENGTH ulMaxSize = 0;
07430               BYTE  bPrecision, bScale;
07431               GetDBTypeMaxSize(wType, &ulMaxSize, &bPrecision, &bScale);
07432
07433               //Set Size
07434               wSendMessageFmt(hWndSize,   WM_SETTEXT, 0, L"%lu", ulMaxSize!=0 ? ulMaxSize : 255);
07435               //Set Precision
07436               wSendMessageFmt(hWndPrecision,  WM_SETTEXT, 0, L"%d", bPrecision);
07437               //Set Scale
07438               wSendMessageFmt(hWndScale,    WM_SETTEXT, 0, L"%d", bScale);
07439
07440
07441               // determine a type on the DBTYPE
07442               for (i = 0; i < pCSession->m_cProvTypes; i++)
07443               {
07444                 if (wType == pCSession->m_rgProvTypes[i].wType)
07445                   iSelTypeName = i;
07446               }
07447               SendMessage(hWndTypeName, CB_SETCURSEL, iSelTypeName, 0);
07448
07449               return 0;
07450             }
07451             break;
07452
07453
07454             case IDC_TYPENAME:
07455             {
07456               CMDIChild*  pThis     = (CMDIChild*)GetThis(hWnd);
07457               CSession* pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07458               HWND    hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
07459               HWND    hWndDataType  = ::GetDlgItem(hWnd, IDC_TYPE);
07460               HWND    hWndColSize   = ::GetDlgItem(hWnd, IDE_SIZE);
07461               HWND    hWndColPrec   = ::GetDlgItem(hWnd, IDE_PRECISION);
07462               HWND    hWndColScale  = ::GetDlgItem(hWnd, IDE_SCALE);
07463               INDEX   iSelTypeName  = (INDEX)SendMessage(hWndTypeName, CB_GETCURSEL, 0, 0);
07464
07465               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07466               wSendMessage(hWndTypeName, CB_GETLBTEXT, (WPARAM)iSelTypeName, wszBuffer);
07467               if (iSelTypeName >= 0)
07468               {
07469                 wSendMessage(hWndDataType, CB_SELECTSTRING, -1, GetDBTypeName(pCSession->m_rgProvTypes[iSelTypeName].wType));
07470                 StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[iSelTypeName].ulColumnSize);
07471                 wSendMessage(hWndColSize, WM_SETTEXT, 0, wszBuffer);
07472                 if (IsNumericType(pCSession->m_rgProvTypes[iSelTypeName].wType))
07473                 {
07474                   StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[iSelTypeName].ulColumnSize);
07475                   wSendMessage(hWndColPrec, WM_SETTEXT, 0, wszBuffer);
07476                 }
07477                 else
07478                 {
07479                   SendMessage(hWndColPrec, WM_SETTEXT, 0, (LPARAM)"0");
07480                 }
07481               }
07482             }
07483             break;
07484
07485
07486           }
07487           break;
07488         }
07489
07490         return FALSE;
07491       }
07492
07493       switch (GET_WM_COMMAND_ID(wParam, lParam))
07494       {
07495         case IDB_SETPROPERTIES:
07496         {
07497           //Get the "this" pointer
07498           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
07499           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
07500           CDataSource* pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
07501
07502           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
07503           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_COLUMNALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &pThis->m_CDefPropSets);
07504           return 0;
07505         }
07506
07507         case IDOK:
07508         {
07509           CWaitCursor waitCursor;
07510
07511           //Get the "this" pointer
07512           CMDIChild*    pThis     = (CMDIChild*)GetThis(hWnd);
07513           CSession*   pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07514
07515           HWND      hWndTableID   = ::GetDlgItem(hWnd, IDE_TABLEID);
07516           HWND      hWndColumnID  = ::GetDlgItem(hWnd, IDE_COLUMNID);
07517           HWND      hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
07518           HWND      hWndSize    = ::GetDlgItem(hWnd, IDE_SIZE);
07519           HWND      hWndPrecision = ::GetDlgItem(hWnd, IDE_PRECISION);
07520           HWND      hWndScale   = ::GetDlgItem(hWnd, IDE_SCALE);
07521           WCHAR     wszTableDBID[MAX_QUERY_LEN+1];
07522           WCHAR     wszBuffer[MAX_NAME_LEN+1];
07523           HRESULT     hr        = S_OK;
07524           DBCOLUMNDESC  ColumnDesc;
07525           LONG      lValue;
07526
07527           // initialize column desc stru
07528           memset(&ColumnDesc, 0, sizeof(DBCOLUMNDESC));
07529
07530           // TableID
07531           DBID TableID;
07532           TableID.eKind = DBKIND_NAME;
07533           TableID.uName.pwszName = wGetWindowText(hWndTableID);
07534           DBIDToString(&TableID, wszTableDBID, MAX_QUERY_LEN);
07535
07536           // ColumnID of ColumnDesc
07537           ColumnDesc.dbcid.eKind      = DBKIND_NAME;
07538           ColumnDesc.dbcid.uName.pwszName = wGetWindowText(hWndColumnID);
07539
07540           // Column Size
07541           GetEditBoxValue(hWndSize, &lValue, 0, LONG_MAX, TRUE);
07542           ColumnDesc.ulColumnSize = lValue;
07543
07544           // Column Precision
07545           GetEditBoxValue(hWndPrecision, &lValue, 0, 255, TRUE);
07546           ColumnDesc.bPrecision = (BYTE)lValue;
07547
07548           // Column Scale
07549           GetEditBoxValue(hWndScale, &lValue, 0, 255, TRUE);
07550           ColumnDesc.bScale = (BYTE)lValue;
07551
07552           //Use Properties
07553           fUseProps = ::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES);
07554           if(fUseProps)
07555           {
07556             ColumnDesc.cPropertySets = pThis->m_CDefPropSets.GetCount();
07557             ColumnDesc.rgPropertySets = pThis->m_CDefPropSets.GetPropSets();
07558           }
07559
07560           // Type Name
07561           ColumnDesc.pwszTypeName = wGetWindowText(hWndTypeName);
07562
07563           // DBType
07564           CComboBoxLite comboTypes(hWnd, IDC_TYPE);
07565           comboTypes.GetSelText(wszBuffer, MAX_NAME_LEN);
07566           ColumnDesc.wType = GetDBType(wszBuffer);
07567
07568           // ITableDefinition::AddColumn
07569           XTEST(hr = pCSession->m_pITableDefinition->AddColumn(&TableID, &ColumnDesc, NULL));
07570           TESTC(TRACE_METHOD(hr, L"ITableDefinition::AddColumn(%s, 0x%p, NULL)", wszTableDBID, &ColumnDesc));
07571           if(SUCCEEDED(hr))
07572           {
07573             //Now just need to place this name in the EditBox
07574             //Inserted after the current "caret"
07575             pThis->m_pCQueryBox->ReplaceAll(TableID.uName.pwszName, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
07576             EndDialog(hWnd, TRUE);
07577           }
07578
07579           SAFE_FREE(TableID.uName.pwszName);
07580           SAFE_FREE(ColumnDesc.dbcid.uName.pwszName);
07581           SAFE_FREE(ColumnDesc.pwszTypeName);
07582           return 0;
07583         }
07584
07585         case IDCANCEL:
07586         {
07587           EndDialog(hWnd, FALSE);
07588           return 0;
07589         }
07590       }
07591       break;
07592     }//WM_COMMAND
07593   }
07594
07595 CLEANUP:
07596   return FALSE;
07597 } // CMDIChild::AddColumnProc
07598
07599
07600 ////////////////////////////////////////////////////////////////
07601 // CMDIChild::CreateTableProc
07602 //
07603 /////////////////////////////////////////////////////////////////
07604 INT_PTR WINAPI CMDIChild::CreateTableProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
07605 {
07606   static CComboBoxGuid  s_CComboInterface;
07607   static  WCHAR wszBuffer[MAX_NAME_LEN+1];
07608   static  BOOL fUseProps      = TRUE;
07609   static  BOOL fAggregation   = FALSE;      //Default
07610   static  BOOL fOutput      = TRUE;       //Default
07611
07612   switch(message)
07613   {
07614     case WM_INITDIALOG:
07615     {
07616       //Save the "this" pointer
07617       CWaitCursor waitCursor;
07618       CMDIChild*    pThis     = (CMDIChild*)SetThis(hWnd, (void*)lParam);
07619       CSession*   pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07620
07621       //Use Extended ListView Styles!
07622       HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07623       HWND    hWndTableID   = ::GetDlgItem(hWnd, IDE_TABLEID);
07624       HWND    hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
07625       HWND    hWndDataType  = ::GetDlgItem(hWnd, IDC_DATATYPE);
07626       HWND    hWndColumnID  = ::GetDlgItem(hWnd, IDE_COLUMNID);
07627       HWND    hWndColSize   = ::GetDlgItem(hWnd, IDE_SIZE);
07628       HWND    hWndColPrec   = ::GetDlgItem(hWnd, IDE_PRECISION);
07629       HWND    hWndColScale  = ::GetDlgItem(hWnd, IDE_SCALE);
07630       RECT    rect;
07631
07632       SendMessage(hWndColumnDesc, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
07633
07634       //ColumnHeaders for COLUMNDESC report
07635       LV_InsertColumn(hWndColumnDesc,   COLUMN_DBCID,   L"Column DBCID",  IMAGE_NONE);
07636       LV_InsertColumn(hWndColumnDesc,   COLUMN_TYPENAME,  L"TypeName",    IMAGE_NONE);
07637       LV_InsertColumn(hWndColumnDesc,   COLUMN_DATATYPE,  L"DataType",    IMAGE_NONE);
07638       LV_InsertColumn(hWndColumnDesc,   COLUMN_SIZE,    L"Size",      IMAGE_NONE);
07639       LV_InsertColumn(hWndColumnDesc,   COLUMN_PREC,    L"Precision",   IMAGE_NONE);
07640       LV_InsertColumn(hWndColumnDesc,   COLUMN_SCALE,   L"Scale",     IMAGE_NONE);
07641
07642       //AutoSize Columns
07643       GetWindowRect(hWndColumnID, (LPRECT)&rect);
07644       SendMessage(hWndColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_DBCID, (LPARAM)(rect.right-rect.left));
07645       GetWindowRect(hWndTypeName, (LPRECT)&rect);
07646       SendMessage(hWndColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_TYPENAME, (LPARAM)(rect.right-rect.left));
07647       GetWindowRect(hWndDataType, (LPRECT)&rect);
07648       SendMessage(hWndColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_DATATYPE, (LPARAM)(rect.right-rect.left));
07649       GetWindowRect(hWndColSize, (LPRECT)&rect);
07650       SendMessage(hWndColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_SIZE, (LPARAM)(rect.right-rect.left));
07651       GetWindowRect(hWndColPrec, (LPRECT)&rect);
07652       SendMessage(hWndColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_PREC, (LPARAM)(rect.right-rect.left));
07653       GetWindowRect(hWndColScale, (LPRECT)&rect);
07654       SendMessage(hWndColumnDesc, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_SCALE, (LPARAM)(rect.right-rect.left));
07655
07656       //Make sure we have the Provider Types rowset ahead of time
07657       pCSession->GetProviderTypes();
07658
07659       // Type Name list...
07660       for(ULONG i=0; i<pCSession->m_cProvTypes; i++)
07661       {
07662         //Type Name
07663         wSendMessage(hWndTypeName, CB_ADDSTRING, 0, pCSession->m_rgProvTypes[i].wszTypeName);
07664       }
07665       SendMessage(hWndTypeName, CB_SETCURSEL, 0, 0);
07666
07667       // DBType list
07668       for(i=0; i<g_cDBTypes; i++)
07669       {
07670         //DBTypes
07671         wSendMessage(hWndDataType, CB_ADDSTRING,  0, g_rgDBTypes[i].pwszName);
07672       }
07673       for (i=0; i<g_cDBTypes; i++)
07674       {
07675         if (pCSession->m_rgProvTypes[0].wType == g_rgDBTypes[i].lItem)
07676         {
07677           SendMessage(hWndDataType, CB_SETCURSEL, i, 0);
07678           break;
07679         }
07680       }
07681
07682       //Use Properties
07683 			::CheckDlgButton(hWnd, IDB_USEPROPERTIES,  BST2STATE(fUseProps));
07684
07685       //Aggregation
07686 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
07687
07688       //Output (ppIUnknown)
07689 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
07690
07691       //Interface List...
07692       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
07693       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
07694       if(s_CComboInterface.RestoreSelection() == CB_ERR)
07695         s_CComboInterface.SetGuid(IID_IRowset);
07696
07697       pCSession->m_listCPropSets.RemoveAll();
07698
07699       //Fill In TableID as Default
07700       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
07701       wSendMessage(hWndTableID, WM_SETTEXT, 0, pwszTableName);
07702
07703       //Placement of Dialog, want it just below the "Init" button...
07704       CenterDialog(hWnd);
07705
07706       //Disable fields
07707 			::EnableWindow(::GetDlgItem(hWnd, IDB_COLPROP),    FALSE);
07708 			::EnableWindow(::GetDlgItem(hWnd, IDE_COLUMNID), FALSE);
07709 			::EnableWindow(::GetDlgItem(hWnd, IDC_TYPENAME), FALSE);
07710 			::EnableWindow(::GetDlgItem(hWnd, IDC_DATATYPE), FALSE);
07711 			::EnableWindow(::GetDlgItem(hWnd, IDE_SIZE),   FALSE);
07712 			::EnableWindow(::GetDlgItem(hWnd, IDE_PRECISION),  FALSE);
07713 			::EnableWindow(::GetDlgItem(hWnd, IDE_SCALE),    FALSE);
07714
07715       SendMessage(hWndTypeName, CB_SETCURSEL, 0, 0);
07716       SAFE_FREE(pwszTableName);
07717       return TRUE;
07718     }
07719
07720     case WM_COMMAND:
07721     {
07722       switch (GET_WM_COMMAND_CMD(wParam, lParam))
07723       {
07724         case EN_KILLFOCUS:
07725         {
07726           switch((int)LOWORD(wParam))
07727           {
07728             case IDE_COLUMNID:
07729             {
07730               HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07731               HWND    hWndColumnID  = ::GetDlgItem(hWnd, IDE_COLUMNID);
07732               HWND    hWndColName   = ::GetDlgItem(hWnd, IDE_COLNAME);
07733               WCHAR   wszBuffer2[MAX_NAME_LEN+1];
07734
07735               // get the selected item
07736               INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07737
07738               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07739               // and to Column Name static field
07740               wSendMessage(hWndColumnID, WM_GETTEXT, MAX_NAME_LEN, wszBuffer2);
07741               StringFormat(wszBuffer, NUMELE(wszBuffer), L"Current item %lu (%s)", iSel, wszBuffer2);
07742               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_DBCID, wszBuffer2);
07743               wSendMessage(hWndColName, WM_SETTEXT, 0, wszBuffer);
07744               break;
07745             }
07746             case IDE_SIZE:
07747             {
07748               HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07749               HWND    hWndColSize   = ::GetDlgItem(hWnd, IDE_SIZE);
07750
07751               // get the selected item
07752               INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07753
07754               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07755               // and to Column Name static field
07756               wSendMessage(hWndColSize, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
07757               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SIZE, wszBuffer);
07758               break;
07759             }
07760             case IDE_PRECISION:
07761             {
07762               HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07763               HWND    hWndColPrec   = ::GetDlgItem(hWnd, IDE_PRECISION);
07764
07765               // get the selected item
07766               INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07767
07768               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07769               // and to Column Name static field
07770               wSendMessage(hWndColPrec, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
07771               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer);
07772               break;
07773             }
07774             case IDE_SCALE:
07775             {
07776               HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07777               HWND    hWndColScale  = ::GetDlgItem(hWnd, IDE_SCALE);
07778
07779               // get the selected item
07780               INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07781
07782               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07783               // and to Column Name static field
07784               wSendMessage(hWndColScale, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
07785               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SCALE, wszBuffer);
07786               break;
07787             }
07788           }
07789           return 0;
07790         }
07791       }
07792       //Filter out any Control Notification codes
07793       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
07794       {
07795         return UNHANDLED_MSG;
07796       }
07797
07798       //CBN_SELCHANGE
07799       switch(GET_WM_COMMAND_CMD(wParam, lParam))
07800       {
07801         case CBN_SELCHANGE:
07802         {
07803           switch(GET_WM_COMMAND_ID(wParam, lParam))
07804           {
07805             case IDC_TYPENAME:
07806             {
07807               CMDIChild*  pThis     = (CMDIChild*)GetThis(hWnd);
07808               CSession* pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07809               HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07810               HWND    hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
07811               HWND    hWndDataType  = ::GetDlgItem(hWnd, IDC_DATATYPE);
07812               HWND    hWndColSize   = ::GetDlgItem(hWnd, IDE_SIZE);
07813               HWND    hWndColPrec   = ::GetDlgItem(hWnd, IDE_PRECISION);
07814               HWND    hWndColScale  = ::GetDlgItem(hWnd, IDE_SCALE);
07815               INDEX   iSelTypeName  = (INDEX)SendMessage(hWndTypeName, CB_GETCURSEL, 0, 0);
07816
07817               // get the selected item
07818               INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07819
07820               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07821               wSendMessage(hWndTypeName, CB_GETLBTEXT, (WPARAM)iSelTypeName, wszBuffer);
07822               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_TYPENAME, wszBuffer);
07823               if (iSelTypeName >= 0)
07824               {
07825                 wSendMessage(hWndDataType, CB_SELECTSTRING, -1, GetDBTypeName(pCSession->m_rgProvTypes[iSelTypeName].wType));
07826                 LV_SetItemText(hWndColumnDesc, iSel, COLUMN_DATATYPE, GetDBTypeName(pCSession->m_rgProvTypes[iSelTypeName].wType));
07827                 StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[iSelTypeName].ulColumnSize);
07828                 wSendMessage(hWndColSize, WM_SETTEXT, 0, wszBuffer);
07829                 LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SIZE, wszBuffer);
07830                 if (IsNumericType(pCSession->m_rgProvTypes[iSelTypeName].wType))
07831                 {
07832                   StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[iSelTypeName].ulColumnSize);
07833                   wSendMessage(hWndColPrec, WM_SETTEXT, 0, wszBuffer);
07834                   LV_SetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer);
07835                 }
07836                 else
07837                 {
07838                   SendMessage(hWndColPrec, WM_SETTEXT, 0, (LPARAM)"0");
07839                   LV_SetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer);
07840                 }
07841               }
07842
07843               StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pCSession->m_rgProvTypes[iSelTypeName].iMaxScale);
07844               wSendMessage(hWndColScale, WM_SETTEXT, 0, wszBuffer);
07845               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SCALE, wszBuffer);
07846             }
07847             break;
07848
07849             case IDC_DATATYPE:
07850             {
07851               CMDIChild*  pThis     = (CMDIChild*)GetThis(hWnd);
07852               CSession* pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07853               HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07854               HWND    hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
07855               HWND    hWndDataType  = ::GetDlgItem(hWnd, IDC_DATATYPE);
07856               HWND    hWndColSize   = ::GetDlgItem(hWnd, IDE_SIZE);
07857               HWND    hWndColPrec   = ::GetDlgItem(hWnd, IDE_PRECISION);
07858               HWND    hWndColScale  = ::GetDlgItem(hWnd, IDE_SCALE);
07859               INDEX   iSelDBType    = (INDEX)SendMessage(hWndDataType, CB_GETCURSEL, 0, 0);
07860               ULONG   i;
07861               INT     iSelTypeName  = 0;
07862               DBTYPE    wType;
07863
07864               // get the selected item
07865               INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07866
07867               // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
07868               wSendMessage(hWndDataType, CB_GETLBTEXT, (WPARAM)iSelDBType, wszBuffer);
07869               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_DATATYPE, wszBuffer);
07870
07871               // determine a type on the DBTYPE
07872               wType = (DBTYPE)g_rgDBTypes[iSelDBType].lItem;
07873               for (i = 0; i < pCSession->m_cProvTypes; i++)
07874               {
07875                 if (wType == pCSession->m_rgProvTypes[i].wType)
07876                   iSelTypeName = i;
07877               }
07878
07879               StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[iSelTypeName].ulColumnSize);
07880               SendMessage(hWndColSize, WM_SETTEXT, 0, (LPARAM)wszBuffer);
07881               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SIZE, wszBuffer);
07882               if(IsNumericType(wType))
07883               {
07884                 StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[iSelTypeName].ulColumnSize);
07885                 wSendMessage(hWndColPrec, WM_SETTEXT, 0, wszBuffer);
07886                 LV_SetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer);
07887               }
07888               else
07889               {
07890                 SendMessage(hWndColPrec, WM_SETTEXT, 0, (LPARAM)"0");
07891                 LV_SetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer);
07892               }
07893
07894               StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pCSession->m_rgProvTypes[iSelTypeName].iMaxScale);
07895               wSendMessage(hWndColScale, WM_SETTEXT, 0, wszBuffer);
07896               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SCALE, wszBuffer);
07897               SendMessage(hWndTypeName, CB_SETCURSEL, iSelTypeName, 0);
07898               LV_SetItemText(hWndColumnDesc, iSel, COLUMN_TYPENAME, pCSession->m_rgProvTypes[iSelTypeName].wszTypeName);
07899             }
07900             break;
07901           }
07902           return 0;
07903         }
07904       }
07905
07906       //Regular command messages
07907       switch(GET_WM_COMMAND_ID(wParam, lParam))
07908       {
07909         case IDB_ROWSETPROPERTIES:
07910         {
07911           //Get the "this" pointer
07912           CMDIChild *pThis      = (CMDIChild*)GetThis(hWnd);
07913           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
07914           CDataSource *pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
07915
07916           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
07917           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &pThis->m_CDefPropSets);
07918           return 0;
07919         }
07920
07921         case IDB_COLPROP:
07922         {
07923           //Get the "this" pointer
07924           CMDIChild *pThis      = (CMDIChild*)GetThis(hWnd);
07925           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
07926           HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07927
07928           CSession* pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07929           CDataSource* pCDataSource = SOURCE_GETPARENT(pCSession, CDataSource);
07930
07931           // get the selected item
07932           ULONG iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07933           if ((LONG)iSel <0)
07934             return 0;
07935
07936           POSITION pos  = pCSession->m_listCPropSets.FindIndex(iSel);
07937           CPropSets* pPropEl = pCSession->m_listCPropSets.GetAt(pos);
07938
07939           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
07940           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_COLUMNALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, pPropEl);
07941           return 0;
07942         }
07943
07944         case IDB_ADD:
07945         {
07946           CMDIChild *pThis      = (CMDIChild*)GetThis(hWnd);
07947           HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07948           CSession* pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07949           ULONG   cItems      = ListView_GetItemCount(hWndColumnDesc);
07950
07951           // make the insertion
07952           StringFormat(wszBuffer, NUMELE(wszBuffer), L"Column%lu", cItems);
07953           LV_InsertItem(hWndColumnDesc, cItems, COLUMN_DBCID, wszBuffer);
07954
07955           // type name
07956           LV_InsertItem(hWndColumnDesc, cItems, COLUMN_TYPENAME, pCSession->m_rgProvTypes[0].wszTypeName);
07957
07958           // data type
07959           for(ULONG i=0; i<g_cDBTypes; i++)
07960           {
07961             if (pCSession->m_rgProvTypes[0].wType == g_rgDBTypes[i].lItem)
07962               break;
07963           }
07964           LV_InsertItem(hWndColumnDesc, cItems, COLUMN_DATATYPE, g_rgDBTypes[i].pwszName);
07965
07966           // Column Size, Precision and Scale
07967           StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[0].ulColumnSize);
07968           LV_InsertItem(hWndColumnDesc, cItems, COLUMN_SIZE, wszBuffer);
07969           LV_InsertItem(hWndColumnDesc, cItems, COLUMN_PREC, wszBuffer);
07970           if (IsNumericType(pCSession->m_rgProvTypes[0].wType))
07971             LV_InsertItem(hWndColumnDesc, cItems, COLUMN_PREC, wszBuffer);
07972           else
07973             LV_InsertItem(hWndColumnDesc, cItems, COLUMN_PREC, L"0");
07974           StringFormat(wszBuffer, NUMELE(wszBuffer), L"%d", pCSession->m_rgProvTypes[0].iMaxScale);
07975           LV_InsertItem(hWndColumnDesc, cItems, COLUMN_SCALE, wszBuffer);
07976
07977           // get the selected item
07978           INDEX iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
07979           if(iSel < 0)
07980           {
07981             LV_SetItemState(hWndColumnDesc, 0, COLUMN_DBCID, LVIS_SELECTED, LVIS_SELECTED);
07982           }
07983
07984           // enable column properties
07985 					::EnableWindow(::GetDlgItem(hWnd, IDB_COLPROP), TRUE);
07986
07987           // set column properties
07988           pCSession->m_listCPropSets.AddTail(new CPropSets());
07989           return 0;
07990         }
07991
07992         case IDB_DELETE:
07993         {
07994           CMDIChild *pThis      = (CMDIChild*)GetThis(hWnd);
07995           HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
07996           CSession* pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
07997           ULONG   cItems      = ListView_GetItemCount(hWndColumnDesc);
07998
07999           // get the selected item
08000           ULONG iSel = ListView_GetNextItem(hWndColumnDesc, -1, LVNI_SELECTED);
08001           if(iSel != -1)
08002           {
08003             ListView_DeleteItem(hWndColumnDesc, iSel);
08004             SendMessage(::GetDlgItem(hWnd, IDE_COLNAME), WM_SETTEXT, 0, (LPARAM)"");
08005
08006             // delete col props
08007             POSITION pos = pCSession->m_listCPropSets.FindIndex(iSel);
08008             CPropSets* pPropEl = pCSession->m_listCPropSets.RemoveAt(pos);
08009             pPropEl->RemoveAll();
08010           }
08011
08012           if (cItems > 1)
08013           {
08014             LV_SetItemState(hWndColumnDesc, iSel == cItems-1 ? iSel-1: iSel, COLUMN_DBCID, LVIS_SELECTED, LVIS_SELECTED);
08015           }
08016           else
08017           {
08018             //Disable fields
08019 						::EnableWindow(::GetDlgItem(hWnd, IDB_COLPROP), FALSE);
08020 						::EnableWindow(::GetDlgItem(hWnd, IDE_COLUMNID), FALSE);
08021 						::EnableWindow(::GetDlgItem(hWnd, IDC_TYPENAME), FALSE);
08022 						::EnableWindow(::GetDlgItem(hWnd, IDC_DATATYPE), FALSE);
08023 						::EnableWindow(::GetDlgItem(hWnd, IDE_SIZE), FALSE);
08024 						::EnableWindow(::GetDlgItem(hWnd, IDE_PRECISION), FALSE);
08025 						::EnableWindow(::GetDlgItem(hWnd, IDE_SCALE), FALSE);
08026           }
08027           return 0;
08028         }
08029
08030         case IDB_AGGREGATION:
08031         {
08032           //Aggregation Combo Selection has changed...
08033           //If we are now using Aggregation, automatically change the requested
08034           //riid to IID_IUnknown, since its an error otherwise...
08035           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
08036             s_CComboInterface.SetGuid(IID_IUnknown);
08037           return 0;
08038         }
08039
08040         case IDCANCEL:
08041         {
08042           //Cleanup any memory allocated
08043           CMDIChild*    pThis     = (CMDIChild*)GetThis(hWnd);
08044           CSession*   pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
08045
08046           pCSession->m_listCPropSets.RemoveAll();
08047           EndDialog(hWnd, FALSE);
08048           return 0;
08049         }
08050
08051         case IDOK:
08052         {
08053           CWaitCursor waitCursor;
08054
08055           //Get the "this" pointer
08056           CMDIChild   *pThis      = (CMDIChild*)GetThis(hWnd);
08057           CSession*   pCSession   = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
08058           HWND      hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
08059           HWND      hWndTableID   = ::GetDlgItem(hWnd, IDE_TABLEID);
08060           DBCOLUMNDESC  *rgColumnDesc = NULL;
08061           ULONG     cColumnDesc   = 0;
08062           IUnknown*   pIUnknown   = NULL;
08063           DBID      TableID;
08064           WCHAR     wszTableDBID[MAX_QUERY_LEN+1];
08065           WCHAR     wszTableName[MAX_NAME_LEN+1];
08066           DBPROPSET   *rgPropSet    = NULL;
08067           ULONG     i,cPropSet    = 0;
08068           HRESULT     hr;
08069           ULONG     ulValue;
08070           POSITION      pos;
08071           CPropSets   *pPropEl    = NULL;
08072
08073           //Use Properties
08074           fUseProps = ::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES);
08075
08076           //Obtain the Aggregation argument
08077           CAggregate* pCAggregate = NULL;
08078           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
08079           if(fAggregation)
08080             pCAggregate = new CAggregate();
08081
08082           //Obtain the Output (ppIUnknown) argument
08083           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
08084
08085           //Interface
08086           REFIID riid = s_CComboInterface.GetGuid();
08087
08088           // alloc space for the column desc array
08089           cColumnDesc = ListView_GetItemCount(hWndColumnDesc);
08090           SAFE_ALLOC(rgColumnDesc, DBCOLUMNDESC, cColumnDesc);
08091
08092           // get the column desc array
08093           for(i=0; i<cColumnDesc; i++)
08094           {
08095             // initialize the whole structure
08096             memset(&rgColumnDesc[i], 0, sizeof(DBCOLUMNDESC));
08097
08098             // get column name
08099             LV_GetItemText(hWndColumnDesc, i, COLUMN_DBCID, wszBuffer, MAX_NAME_LEN);
08100             rgColumnDesc[i].dbcid.eKind       = DBKIND_NAME;
08101             rgColumnDesc[i].dbcid.uName.pwszName  = wcsDuplicate(wszBuffer);
08102
08103             // get column type name
08104             LV_GetItemText(hWndColumnDesc, i, COLUMN_TYPENAME, wszBuffer, MAX_NAME_LEN);
08105             rgColumnDesc[i].pwszTypeName = wcsDuplicate(wszBuffer);
08106
08107             // get column data type
08108             LV_GetItemText(hWndColumnDesc, i, COLUMN_DATATYPE, wszBuffer, MAX_NAME_LEN);
08109             rgColumnDesc[i].wType = GetDBType(wszBuffer);
08110
08111             // get column size
08112             LV_GetItemText(hWndColumnDesc, i, COLUMN_SIZE, wszBuffer, MAX_NAME_LEN);
08113             rgColumnDesc[i].ulColumnSize = wcstoul(wszBuffer, NULL, 10);
08114
08115             // get column precision
08116             LV_GetItemText(hWndColumnDesc, i, COLUMN_PREC, wszBuffer, MAX_NAME_LEN);
08117             ulValue = wcstoul(wszBuffer, NULL, 10);
08118             rgColumnDesc[i].bPrecision = (BYTE)ulValue;
08119
08120             // get column size
08121             LV_GetItemText(hWndColumnDesc, i, COLUMN_SCALE, wszBuffer, MAX_NAME_LEN);
08122             ulValue = wcstoul(wszBuffer, NULL, 10);
08123             rgColumnDesc[i].bScale = (BYTE)ulValue;
08124
08125             // get properties
08126             pos   = pCSession->m_listCPropSets.FindIndex(i);
08127             pPropEl = pCSession->m_listCPropSets.GetAt(pos);
08128             rgColumnDesc[i].cPropertySets = pPropEl->GetCount();
08129             rgColumnDesc[i].rgPropertySets  = pPropEl->GetPropSets();
08130           }
08131
08132           // get TableID
08133           wSendMessage(hWndTableID, WM_GETTEXT, MAX_NAME_LEN, wszTableName);
08134           TableID.eKind = DBKIND_NAME;
08135           TableID.uName.pwszName = wszTableName;
08136           DBIDToString(&TableID, wszTableDBID, MAX_QUERY_LEN);
08137
08138           // check whether rowset/table properties are used
08139           if(fUseProps)
08140           {
08141             cPropSet  = pThis->m_CDefPropSets.GetCount();
08142             rgPropSet = pThis->m_CDefPropSets.GetPropSets();
08143           }
08144
08145           //ITableDefinition::CreateTable
08146           XTEST(hr = pCSession->m_pITableDefinition->CreateTable(pCAggregate, &TableID, cColumnDesc, rgColumnDesc, riid, cPropSet, rgPropSet, NULL, fOutput ? &pIUnknown : NULL));
08147           TESTC(TRACE_METHOD(hr, L"ITableDefinition::CreateTable(0x%p, %s, %lu, 0x%p, %s, %d, 0x%p, NULL, &0x%p)", pCAggregate, wszTableDBID, cColumnDesc, rgColumnDesc, GetInterfaceName(riid), cPropSet, rgPropSet, pIUnknown));
08148
08149           if(fOutput)
08150           {
08151             //Handle Aggregation
08152             if(pCAggregate)
08153               pCAggregate->HandleAggregation(riid, &pIUnknown);
08154
08155             //Display the Result
08156             //Just pass in a guess for the object type and let our helper figure out what object it is...
08157             //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
08158             if(!pThis->m_pCMainWindow->HandleObjectType(pCSession, pIUnknown, riid, eCRowset, 0, NULL, CREATE_NEWWINDOW_IFEXISTS | CREATE_DETERMINE_TYPE))
08159               TESTC(hr = E_FAIL);
08160           }
08161
08162         CLEANUP:
08163           pThis->UpdateControls();
08164           for (i=0; i<cColumnDesc; i++)
08165           {
08166             SAFE_FREE(rgColumnDesc[i].pwszTypeName);
08167             if (DBKIND_NAME == rgColumnDesc[i].dbcid.eKind)
08168               SAFE_FREE(rgColumnDesc[i].dbcid.uName.pwszName);
08169           }
08170           SAFE_FREE(rgColumnDesc);
08171           SAFE_RELEASE(pIUnknown);
08172           SAFE_RELEASE(pCAggregate);
08173
08174           if(SUCCEEDED(hr))
08175           {
08176             //Now just need to place this name in the EditBox
08177             //Inserted after the current "caret"
08178             pThis->m_pCQueryBox->ReplaceAll(wszTableName, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
08179
08180             pCSession->m_listCPropSets.RemoveAll(); //FreeColumnProperties();
08181             EndDialog(hWnd, TRUE);
08182             return 0;
08183           }
08184           return 0;
08185         }
08186       }
08187       break;
08188     }//WM_COMMAND
08189
08190     case WM_NOTIFY:
08191     {
08192       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
08193       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
08194
08195       //ListView
08196       switch(pDispInfo->hdr.code)
08197       {
08198         //Since we have "TwoClickActive" on this will get sent
08199         //Whenever a row is clicked on twice!
08200         //This functionality used to be done with NM_DBCLK
08201         case LVN_ITEMACTIVATE:
08202         {
08203           return FALSE;
08204         }
08205
08206         case LVN_ITEMCHANGED:
08207         {
08208           HWND    hWndColumnDesc  = ::GetDlgItem(hWnd, IDL_COLUMNDESC);
08209           HWND    hWndColumnID  = ::GetDlgItem(hWnd, IDE_COLUMNID);
08210           HWND    hWndTypeName  = ::GetDlgItem(hWnd, IDC_TYPENAME);
08211           HWND    hWndDataType  = ::GetDlgItem(hWnd, IDC_DATATYPE);
08212           HWND    hWndColSize   = ::GetDlgItem(hWnd, IDE_SIZE);
08213           HWND    hWndColPrec   = ::GetDlgItem(hWnd, IDE_PRECISION);
08214           HWND    hWndColScale  = ::GetDlgItem(hWnd, IDE_SCALE);
08215           HWND    hWndColName   = ::GetDlgItem(hWnd, IDE_COLNAME);
08216           WCHAR   wszBuffer2[MAX_NAME_LEN+1];
08217           NMLISTVIEW  *pLV = (NMLISTVIEW*)lParam;
08218
08219           if (pLV->uChanged != LVIF_STATE)
08220             return 0;
08221
08222           // get the selected item
08223           INDEX iSel = pLV->iItem;
08224           if (!(pLV->uNewState & LVIS_SELECTED))
08225           {
08226             if (!(pLV->uOldState & LVIS_SELECTED))
08227               return 0;
08228
08229             // this is the previously selected item
08230             // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
08231             // and to Column Name static field
08232             wSendMessage(hWndColumnID, WM_GETTEXT, MAX_NAME_LEN, wszBuffer2);
08233             StringFormat(wszBuffer, NUMELE(wszBuffer), L"Current item %lu (%s)", iSel, wszBuffer2);
08234             LV_SetItemText(hWndColumnDesc, iSel, COLUMN_DBCID, wszBuffer2);
08235             wSendMessage(hWndColName, WM_SETTEXT, 0, wszBuffer);
08236
08237             // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
08238             // and to Column Name static field
08239             wSendMessage(hWndColSize, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
08240             LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SIZE, wszBuffer);
08241
08242             // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
08243             // and to Column Name static field
08244             wSendMessage(hWndColPrec, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
08245             LV_SetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer);
08246
08247             // retrieve the column type name and copy it to the COLUMN_TYPENAME field of the list view
08248             // and to Column Name static field
08249             wSendMessage(hWndColScale, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
08250             LV_SetItemText(hWndColumnDesc, iSel, COLUMN_SCALE, wszBuffer);
08251           }
08252           else
08253           {
08254             // retrieve the column name and copy it to the IDE_COLUMNID field
08255             LV_GetItemText(hWndColumnDesc, iSel, COLUMN_DBCID, wszBuffer2, MAX_NAME_LEN);
08256             wSendMessage(hWndColumnID, WM_SETTEXT, 0, wszBuffer2);
08257             StringFormat(wszBuffer, NUMELE(wszBuffer), L"Current item %lu (%s)", iSel, wszBuffer2);
08258             wSendMessage(hWndColName, WM_SETTEXT, 0, wszBuffer);
08259
08260             // retrieve the column type and copy it to the IDC_TYPENAME field
08261             LV_GetItemText(hWndColumnDesc, iSel, COLUMN_TYPENAME, wszBuffer, MAX_NAME_LEN);
08262             wSendMessage(hWndTypeName, CB_SELECTSTRING, -1, wszBuffer);
08263
08264             // retrieve the column datatype and copy it to the IDC_DATATYPE field
08265             LV_GetItemText(hWndColumnDesc, iSel, COLUMN_DATATYPE, wszBuffer, MAX_NAME_LEN);
08266             wSendMessage(hWndDataType, CB_SELECTSTRING, -1, wszBuffer);
08267
08268             // retrieve the column size and copy it to the IDE_SIZE field
08269             LV_GetItemText(hWndColumnDesc, iSel, COLUMN_SIZE, wszBuffer, MAX_NAME_LEN);
08270             wSendMessage(hWndColSize, WM_SETTEXT, 0, wszBuffer);
08271
08272             // retrieve the column datatype and copy it to the IDE_PRECISION field
08273             LV_GetItemText(hWndColumnDesc, iSel, COLUMN_PREC, wszBuffer, MAX_NAME_LEN);
08274             wSendMessage(hWndColPrec, WM_SETTEXT, 0, wszBuffer);
08275
08276             // retrieve the column datatype and copy it to the IDE_SCALE field
08277             LV_GetItemText(hWndColumnDesc, iSel, COLUMN_SCALE, wszBuffer, MAX_NAME_LEN);
08278             wSendMessage(hWndColScale, WM_SETTEXT, 0, wszBuffer);
08279
08280             //Enable fields
08281 						::EnableWindow(::GetDlgItem(hWnd, IDB_COLPROP), TRUE);
08282 						::EnableWindow(::GetDlgItem(hWnd, IDE_COLUMNID), TRUE);
08283 						::EnableWindow(::GetDlgItem(hWnd, IDC_TYPENAME), TRUE);
08284 						::EnableWindow(::GetDlgItem(hWnd, IDC_DATATYPE), TRUE);
08285 						::EnableWindow(::GetDlgItem(hWnd, IDE_SIZE),  TRUE);
08286 						::EnableWindow(::GetDlgItem(hWnd, IDE_PRECISION),  TRUE);
08287 						::EnableWindow(::GetDlgItem(hWnd, IDE_SCALE), TRUE);
08288           }
08289           return FALSE;
08290         }
08291
08292         case LVN_ITEMCHANGING:
08293         {
08294             return FALSE; //Allow the change
08295         }
08296       }
08297
08298
08299     }//WM_NOTIFY
08300   }//switch message
08301
08302   return FALSE;
08303 } // CMDIChild::CreateTableProc
08304
08305
08306 ////////////////////////////////////////////////////////////////
08307 // CMDIChild::DropColumnProc
08308 //
08309 /////////////////////////////////////////////////////////////////
08310 INT_PTR WINAPI CMDIChild::DropColumnProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
08311 {
08312   switch(message)
08313   {
08314     case WM_INITDIALOG:
08315     {
08316       CWaitCursor waitCursor;
08317
08318       //Save the "this" pointer
08319       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
08320       HWND hWndTableID  = ::GetDlgItem(hWnd, IDE_TABLEID);
08321
08322       //Fill In TableID as Default
08323       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
08324       wSendMessage(hWndTableID, WM_SETTEXT, 0, pwszTableName);
08325
08326       CenterDialog(hWnd);
08327       SAFE_FREE(pwszTableName);
08328       return TRUE;
08329     }
08330
08331     case WM_COMMAND:
08332     {
08333       //Filter out any Control Notification codes
08334       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
08335       {
08336         return UNHANDLED_MSG;
08337       }
08338
08339       switch (GET_WM_COMMAND_ID(wParam, lParam))
08340       {
08341         case IDOK:
08342         {
08343           CWaitCursor waitCursor;
08344
08345           //Get the "this" pointer
08346           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
08347           CSession* pCSession = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
08348           HWND hWndTableID  = ::GetDlgItem(hWnd, IDE_TABLEID);
08349           HWND hWndColumnID = ::GetDlgItem(hWnd, IDE_COLUMNID);
08350           WCHAR wszTableDBID[MAX_QUERY_LEN+1];
08351           WCHAR wszColumnDBID[MAX_QUERY_LEN+1];
08352           HRESULT hr = S_OK;
08353
08354           //TableID
08355           DBID TableID;
08356           TableID.eKind = DBKIND_NAME;
08357           TableID.uName.pwszName = wGetWindowText(hWndTableID);
08358           DBIDToString(&TableID, wszTableDBID, MAX_QUERY_LEN);
08359
08360           //ColumnID
08361           DBID ColumnID;
08362           ColumnID.eKind = DBKIND_NAME;
08363           ColumnID.uName.pwszName = wGetWindowText(hWndColumnID);
08364           DBIDToString(&ColumnID, wszColumnDBID, MAX_QUERY_LEN);
08365
08366           //ITableDefinition::DropColumn
08367           XTEST(hr = pCSession->m_pITableDefinition->DropColumn(&TableID, &ColumnID));
08368           TESTC(TRACE_METHOD(hr, L"ITableDefinition::DropColumn(%s, %s)", wszTableDBID, wszColumnDBID));
08369
08370           if(SUCCEEDED(hr))
08371           {
08372             EndDialog(hWnd, TRUE);
08373           }
08374
08375           SAFE_FREE(TableID.uName.pwszName);
08376           SAFE_FREE(ColumnID.uName.pwszName);
08377           return 0;
08378         }
08379
08380         case IDCANCEL:
08381         {
08382           EndDialog(hWnd, FALSE);
08383           return 0;
08384         }
08385       }
08386       break;
08387     }//WM_COMMAND
08388   }
08389
08390 CLEANUP:
08391   return FALSE;
08392 } // CMDIChild::DropColumnProc
08393
08394
08395 ////////////////////////////////////////////////////////////////
08396 // CMDIChild::DropTableProc
08397 //
08398 /////////////////////////////////////////////////////////////////
08399 INT_PTR WINAPI CMDIChild::DropTableProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
08400 {
08401   switch(message)
08402   {
08403     case WM_INITDIALOG:
08404     {
08405       CWaitCursor waitCursor;
08406
08407       //Save the "this" pointer
08408       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
08409       HWND hWndTableID  = ::GetDlgItem(hWnd, IDE_TABLEID);
08410
08411       //Fill In TableID as Default
08412       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
08413       wSendMessage(hWndTableID, WM_SETTEXT, 0, pwszTableName);
08414
08415       CenterDialog(hWnd);
08416       SAFE_FREE(pwszTableName);
08417       return TRUE;
08418     }
08419
08420     case WM_COMMAND:
08421     {
08422       //Filter out any Control Notification codes
08423       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
08424       {
08425         return UNHANDLED_MSG;
08426       }
08427
08428       switch (GET_WM_COMMAND_ID(wParam, lParam))
08429       {
08430         case IDOK:
08431         {
08432           CWaitCursor waitCursor;
08433
08434           //Get the "this" pointer
08435           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
08436           CSession* pCSession = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
08437           HWND hWndTableID  = ::GetDlgItem(hWnd, IDE_TABLEID);
08438           WCHAR wszTableDBID[MAX_QUERY_LEN+1];
08439           HRESULT hr = S_OK;
08440
08441           //TableID
08442           DBID TableID;
08443           TableID.eKind = DBKIND_NAME;
08444           TableID.uName.pwszName = wGetWindowText(hWndTableID);
08445           DBIDToString(&TableID, wszTableDBID, MAX_QUERY_LEN);
08446
08447           //ITableDefinition::DropTable
08448           XTEST(hr = pCSession->m_pITableDefinition->DropTable(&TableID));
08449           TRACE_METHOD(hr, L"ITableDefinition::DropTable(%s)", wszTableDBID);
08450
08451           if(SUCCEEDED(hr))
08452           {
08453             EndDialog(hWnd, TRUE);
08454           }
08455
08456           SAFE_FREE(TableID.uName.pwszName);
08457           return 0;
08458         }
08459
08460         case IDCANCEL:
08461         {
08462           EndDialog(hWnd, FALSE);
08463           return 0;
08464         }
08465       }
08466       break;
08467     }//WM_COMMAND
08468   }
08469
08470   return FALSE;
08471 }
08472
08473
08474 ////////////////////////////////////////////////////////////////
08475 // CMDIChild::DropConstraintProc
08476 //
08477 /////////////////////////////////////////////////////////////////
08478 INT_PTR WINAPI CMDIChild::DropConstraintProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
08479 {
08480   switch(message)
08481   {
08482     case WM_INITDIALOG:
08483     {
08484       CWaitCursor waitCursor;
08485
08486       //Save the "this" pointer
08487       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
08488       HWND hWndTableID  = ::GetDlgItem(hWnd, IDE_TABLEID);
08489
08490       //Fill In TableID as Default
08491       WCHAR* pwszTableName = pThis->m_pCQueryBox->GetSelectedText();
08492       wSendMessage(hWndTableID, WM_SETTEXT, 0, pwszTableName);
08493
08494       CenterDialog(hWnd);
08495       SAFE_FREE(pwszTableName);
08496       return TRUE;
08497     }
08498
08499     case WM_COMMAND:
08500     {
08501       //Filter out any Control Notification codes
08502       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
08503       {
08504         return UNHANDLED_MSG;
08505       }
08506
08507       switch (GET_WM_COMMAND_ID(wParam, lParam))
08508       {
08509         case IDOK:
08510         {
08511           CWaitCursor waitCursor;
08512
08513           //Get the "this" pointer
08514           CMDIChild *pThis = (CMDIChild*)GetThis(hWnd);
08515           CSession  *pCSession = SOURCE_GETOBJECT(pThis->m_pCSource, CSession);
08516           HWND    hWndTableID = ::GetDlgItem(hWnd, IDE_TABLEID);
08517           HWND    hWndConsID  = ::GetDlgItem(hWnd, IDE_CONSTRAINTID);
08518           WCHAR   wszTableDBID[MAX_QUERY_LEN+1];
08519           WCHAR   wszConsDBID[MAX_QUERY_LEN+1];
08520           HRESULT   hr = S_OK;
08521
08522           //TableID
08523           DBID TableID;
08524           TableID.eKind = DBKIND_NAME;
08525           TableID.uName.pwszName = wGetWindowText(hWndTableID);
08526           DBIDToString(&TableID, wszTableDBID, MAX_QUERY_LEN);
08527
08528           //ConstraintID
08529           DBID ConstraintID;
08530           ConstraintID.eKind = DBKIND_NAME;
08531           ConstraintID.uName.pwszName = wGetWindowText(hWndConsID);
08532           DBIDToString(&ConstraintID, wszConsDBID, MAX_QUERY_LEN);
08533
08534           //ITableDefinitionWithConstraints::DropConstraint
08535           XTEST(hr = pCSession->m_pITableDefinitionWithConstraints->DropConstraint(&TableID, &ConstraintID));
08536           TESTC(TRACE_METHOD(hr, L"ITableDefinitionWithConstraints::DropConstraint(%s, %s)", wszTableDBID, wszConsDBID));
08537
08538           if(SUCCEEDED(hr))
08539           {
08540             EndDialog(hWnd, TRUE);
08541           }
08542
08543           SAFE_FREE(TableID.uName.pwszName);
08544           SAFE_FREE(ConstraintID.uName.pwszName);
08545           return 0;
08546         }
08547
08548         case IDCANCEL:
08549         {
08550           EndDialog(hWnd, FALSE);
08551           return 0;
08552         }
08553       }
08554       break;
08555     }//WM_COMMAND
08556   }
08557
08558 CLEANUP:
08559   return FALSE;
08560 } // CMDIChild::DropConstraintProc
08561
08562
08563 ////////////////////////////////////////////////////////////////
08564 // CMDIChild::ISCO_DeleteProc
08565 /////////////////////////////////////////////////////////////////
08566 INT_PTR WINAPI CMDIChild::ISCO_DeleteProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
08567 {
08568   const static WIDENAMEMAP rgISODeleteFlags[] =
08569   {
08570     VALUE_WCHAR(DBDELETE_ASYNC),
08571     VALUE_WCHAR(DBDELETE_ATOMIC),
08572   };
08573
08574   switch(message)
08575   {
08576     case WM_INITDIALOG:
08577     {
08578       //Save the "this" pointer
08579       CWaitCursor waitCursor;
08580       CMDIChild*    pThis   = (CMDIChild*)SetThis(hWnd, (void*)lParam);
08581       HWND      hWndFlags = ::GetDlgItem(hWnd, IDC_ISCO_FLAGS);
08582
08583       for(ULONG i=0; i<NUMELE(rgISODeleteFlags); i++)
08584       {
08585         INDEX iSel = SendMessageW(hWndFlags, LB_ADDSTRING, 0, (LPARAM)rgISODeleteFlags[i].pwszName);
08586         SendMessageW(hWndFlags, LB_SETITEMDATA, iSel, rgISODeleteFlags[i].lItem);
08587       }
08588
08589       //Placement of Dialog, want it just below the "Init" button...
08590       CenterDialog(hWnd);
08591       return TRUE;
08592     }
08593
08594     case WM_COMMAND:
08595     {
08596       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
08597       {
08598         return UNHANDLED_MSG;
08599       }
08600
08601       switch (GET_WM_COMMAND_ID(wParam, lParam))
08602       {
08603         case IDB_ADD:
08604         {
08605           HWND    hWndEditURL   = ::GetDlgItem(hWnd, IDE_URL);
08606           HWND    hWndURLs    = ::GetDlgItem(hWnd, IDC_URLs);
08607           CHAR    szURL[MAX_NAME_LEN+1] = "";
08608
08609           // get the text from the edit field
08610           SendMessageA(hWndEditURL, WM_GETTEXT, MAX_NAME_LEN, (LPARAM)szURL);
08611           if (szURL[0])
08612           {
08613             // and add it to the URL list box
08614             SendMessageA(hWndURLs, LB_ADDSTRING, 0, (LPARAM)szURL);
08615           }
08616           else
08617             MessageBox(GetFocus(), "There is no URL to ADD!", "WARNING", MB_OK);
08618
08619           return 0;
08620         }
08621
08622         case IDB_DELETE:
08623         {
08624           HWND    hWndURLs    = ::GetDlgItem(hWnd, IDC_URLs);
08625
08626           INDEX iSel = (INDEX)SendMessage(hWndURLs, LB_GETCURSEL, 0, 0);
08627           if (LB_ERR != iSel)
08628             SendMessage(hWndURLs, LB_DELETESTRING, iSel, 0);
08629
08630           return 0;
08631         }
08632
08633         case IDCANCEL:
08634         {
08635           EndDialog(hWnd, FALSE);
08636           return 0;
08637         }
08638
08639         case IDOK:
08640         {
08641           CWaitCursor waitCursor;
08642
08643           //Get the "this" pointer
08644           CMDIChild *pThis          = (CMDIChild*)GetThis(hWnd);
08645           HWND    hWndURLs        = ::GetDlgItem(hWnd, IDC_URLs);
08646           HWND    hWndFlags       = ::GetDlgItem(hWnd, IDC_ISCO_FLAGS);
08647           DWORD   dwDeleteFlags     = 0;
08648           WCHAR   **rgpwszURLs      = NULL;
08649           WCHAR   wszBuffer[MAX_NAME_LEN+1]= {0};
08650           DBSTATUS  *rgdbStatus       = NULL;
08651           HRESULT   hr;
08652
08653           //Obtain IScopedOperations
08654           IScopedOperations* pIScopedOperations = SOURCE_GETINTERFACE(pThis->m_pCSource, IScopedOperations);
08655           ASSERT(pIScopedOperations);
08656
08657           INDEX nCount = (INDEX)SendMessage(hWndFlags, LB_GETCOUNT, 0, 0);
08658           for(INDEX iSel = 0; iSel < nCount; iSel++)
08659           {
08660             //Is this a selected Item?
08661             if(SendMessage(hWndFlags, LB_GETSEL, iSel, 0) > 0)
08662             {
08663               //We setup the listbox with the item data as the value for each selection
08664               dwDeleteFlags |= SendMessage(hWndFlags, LB_GETITEMDATA, iSel, 0);
08665             }
08666           }
08667
08668           // get URL array
08669           nCount = (ULONG)SendMessage(hWndURLs, LB_GETCOUNT, 0, 0);
08670           if (nCount > 0)
08671           {
08672             SAFE_ALLOC(rgpwszURLs, WCHAR*, nCount);
08673             SAFE_ALLOC(rgdbStatus, DBSTATUS, nCount);
08674           }
08675
08676           for(iSel=0; iSel<nCount; iSel++)
08677           {
08678             wSendMessage(hWndURLs, LB_GETTEXT, iSel, wszBuffer);
08679             rgpwszURLs[iSel] = wcsDuplicate(wszBuffer);
08680           }
08681
08682           XTEST(hr = pIScopedOperations->Delete(nCount, (const WCHAR**)rgpwszURLs, dwDeleteFlags, rgdbStatus));
08683           TESTC(TRACE_METHOD(hr, L"IScopedOperations::Delete(%lu, 0x%p, 0x%08x, 0x%p)", nCount, rgpwszURLs, dwDeleteFlags, rgdbStatus));
08684
08685         CLEANUP:
08686           pThis->UpdateControls();
08687
08688           //Display Status errors...
08689           for(iSel=0; iSel<nCount; iSel++)
08690           {
08691             SAFE_FREE(rgpwszURLs[iSel]);
08692
08693             if(rgdbStatus[iSel] != DBSTATUS_S_OK)
08694               wMessageBox(GetFocus(), MB_OK, wsz_ERROR, L"Status = %s \nrgpwszURL[%lu] = %s", GetStatusName(rgdbStatus[iSel]), iSel, rgpwszURLs[iSel]);
08695           }
08696
08697           SAFE_FREE(rgpwszURLs);
08698           SAFE_FREE(rgdbStatus);
08699
08700           if(SUCCEEDED(hr))
08701             EndDialog(hWnd, TRUE);
08702           return 0;
08703         }
08704       }
08705       break;
08706     }//WM_COMMAND
08707
08708   }//switch message
08709
08710   return FALSE;
08711 } // CMDIChild::ISCO_DeleteProc
08712
08713
08714 ////////////////////////////////////////////////////////////////
08715 // CMDIChild::ISCO_Proc
08716 /////////////////////////////////////////////////////////////////
08717 INT_PTR WINAPI CMDIChild::ISCO_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
08718 {
08719   const static WIDENAMEMAP rgISOCopyFlags[] =
08720   {
08721     VALUE_WCHAR(DBCOPY_REPLACE_EXISTING),
08722     VALUE_WCHAR(DBCOPY_ASYNC),
08723     VALUE_WCHAR(DBCOPY_ALLOW_EMULATION),
08724     VALUE_WCHAR(DBCOPY_NON_RECURSIVE),
08725     VALUE_WCHAR(DBCOPY_ATOMIC),
08726   };
08727
08728   const static WIDENAMEMAP rgISOMoveFlags[] =
08729   {
08730     VALUE_WCHAR(DBMOVE_REPLACE_EXISTING),
08731     VALUE_WCHAR(DBMOVE_ASYNC),
08732     VALUE_WCHAR(DBMOVE_DONT_UPDATE_LINKS),
08733     VALUE_WCHAR(DBMOVE_ALLOW_EMULATION),
08734     VALUE_WCHAR(DBMOVE_ATOMIC),
08735   };
08736
08737
08738   switch(message)
08739   {
08740     case WM_INITDIALOG:
08741     {
08742       //Save the "this" pointer
08743       CWaitCursor waitCursor;
08744       CMDIChild*    pThis   = (CMDIChild*)SetThis(hWnd, (void*)lParam);
08745       HWND      hWndFlags = ::GetDlgItem(hWnd, IDC_ISCO_FLAGS);
08746       HWND      hWndURLs  = ::GetDlgItem(hWnd, IDL_URLs);
08747       RECT    rect;
08748
08749       //Populate the ListBox
08750       if(pThis->m_idSource == IDM_ISCOPEDOPERATIONS_MOVE)
08751       {
08752 				::SetWindowText(hWnd, "IScopedOperations::Move");
08753         for(ULONG i=0; i<NUMELE(rgISOMoveFlags); i++)
08754         {
08755           INDEX iSel = SendMessageW(hWndFlags, LB_ADDSTRING, 0, (LPARAM)rgISOMoveFlags[i].pwszName);
08756           SendMessageW(hWndFlags, LB_SETITEMDATA, iSel, rgISOMoveFlags[i].lItem);
08757         }
08758       }
08759       else
08760       {
08761 				::SetWindowText(hWnd, "IScopedOperations::Copy");
08762         for(ULONG i=0; i<NUMELE(rgISOCopyFlags); i++)
08763         {
08764           INDEX iSel = SendMessageW(hWndFlags, LB_ADDSTRING, 0, (LPARAM)rgISOCopyFlags[i].pwszName);
08765           SendMessageW(hWndFlags, LB_SETITEMDATA, iSel, rgISOCopyFlags[i].lItem);
08766         }
08767       }
08768
08769       SendMessage(hWndURLs, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
08770       LV_InsertColumn(hWndURLs,   COLUMN_ISCO_SRCURL,   L"Source URL",    IMAGE_NONE);
08771       LV_InsertColumn(hWndURLs,   COLUMN_ISCO_DESTURL,  L"Destination URL", IMAGE_NONE);
08772
08773       GetWindowRect(hWndURLs, (LPRECT)&rect);
08774       SendMessage(hWndURLs, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_ISCO_SRCURL, (LPARAM)(rect.right-rect.left)/2);
08775       SendMessage(hWndURLs, LVM_SETCOLUMNWIDTH, (WPARAM)COLUMN_ISCO_DESTURL, (LPARAM)(rect.right-rect.left)/2);
08776
08777       //Placement of Dialog, want it just below the "Init" button...
08778       CenterDialog(hWnd);
08779       return TRUE;
08780     }
08781
08782     case WM_COMMAND:
08783     {
08784       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
08785       {
08786         return UNHANDLED_MSG;
08787       }
08788
08789       switch (GET_WM_COMMAND_ID(wParam, lParam))
08790       {
08791         case IDB_ADD:
08792         {
08793           HWND    hWndSrcURL    = ::GetDlgItem(hWnd, IDE_ISCO_SOURCE);
08794           HWND    hWndDestURL   = ::GetDlgItem(hWnd, IDE_ISCO_DESTINATION);
08795           HWND    hWndURLs    = ::GetDlgItem(hWnd, IDL_URLs);
08796           WCHAR   wszSrcURL[MAX_NAME_LEN+1] = L"";
08797           WCHAR   wszDestURL[MAX_NAME_LEN+1] = L"";
08798           ULONG   cItems      = ListView_GetItemCount(hWndURLs);
08799
08800           // get the text from the edit field
08801           wSendMessage(hWndSrcURL, WM_GETTEXT, MAX_NAME_LEN, wszSrcURL);
08802           wSendMessage(hWndDestURL, WM_GETTEXT, MAX_NAME_LEN, wszDestURL);
08803           if(wszSrcURL[0] || wszDestURL[0])
08804           {
08805             // and add it to the URL list box
08806             // make the insertion
08807             LV_InsertItem(hWndURLs, cItems, COLUMN_ISCO_SRCURL,   wszSrcURL);
08808             LV_InsertItem(hWndURLs, cItems, COLUMN_ISCO_DESTURL,  wszDestURL);
08809           }
08810           else
08811           {
08812             wMessageBox(GetFocus(), MB_OK, wsz_ERROR, L"There is no source or destination URL to ADD!");
08813           }
08814
08815           return 0;
08816         }
08817
08818         case IDB_DELETE:
08819         {
08820           HWND    hWndURLs    = ::GetDlgItem(hWnd, IDL_URLs);
08821           INT     cItems;
08822           INT     iSel;
08823
08824           // get the selected item
08825           iSel = ListView_GetNextItem(hWndURLs, -1, LVNI_SELECTED);
08826
08827           cItems = ListView_GetItemCount(hWndURLs);
08828           if (iSel > -1)
08829             ListView_DeleteItem(hWndURLs, iSel);
08830           if (cItems > 1)
08831             LV_SetItemState(hWndURLs, iSel == cItems-1 ? iSel-1: iSel, COLUMN_ISCO_SRCURL, LVIS_SELECTED, LVIS_SELECTED);
08832           return 0;
08833         }
08834
08835         case IDCANCEL:
08836         {
08837           EndDialog(hWnd, FALSE);
08838           return 0;
08839         }
08840
08841         case IDOK:
08842         {
08843           CWaitCursor waitCursor;
08844
08845           //Get the "this" pointer
08846           CMDIChild *pThis          = (CMDIChild*)GetThis(hWnd);
08847           HWND    hWndURLs        = ::GetDlgItem(hWnd, IDL_URLs);
08848           HWND    hWndFlags       = ::GetDlgItem(hWnd, IDC_ISCO_FLAGS);
08849           DWORD   dwFlags         = 0;
08850           WCHAR   **rgpwszSourceURLs    = NULL;
08851           WCHAR   **rgpwszDestURLs    = NULL;
08852           WCHAR   **rgpwszNewURLs     = NULL;
08853           OLECHAR   *pStringsBuffer     = NULL;
08854           DBSTATUS  *rgdbStatus       = NULL;
08855
08856           WCHAR   wszBuffer[MAX_NAME_LEN+1]= {0};
08857           INDEX   cRows = 0;
08858           HRESULT   hr = S_OK;
08859
08860           //Obtain IScopedOperations
08861           IScopedOperations* pIScopedOperations = SOURCE_GETINTERFACE(pThis->m_pCSource, IScopedOperations);
08862           ASSERT(pIScopedOperations);
08863
08864           INDEX nCount = (INDEX)SendMessage(hWndFlags, LB_GETCOUNT, 0, 0);
08865           for(INDEX iSel = 0; iSel < nCount; iSel++)
08866           {
08867             //Is this a selected Item?
08868             if(SendMessage(hWndFlags, LB_GETSEL, iSel, 0) > 0)
08869             {
08870               //We setup the listbox with the item data as the value for each selection
08871               dwFlags |= SendMessage(hWndFlags, LB_GETITEMDATA, iSel, 0);
08872             }
08873           }
08874
08875           // get URL array
08876           cRows = ListView_GetItemCount(hWndURLs);
08877           SAFE_ALLOC(rgpwszSourceURLs, WCHAR*, cRows);
08878           SAFE_ALLOC(rgpwszDestURLs, WCHAR*, cRows);
08879           SAFE_ALLOC(rgpwszNewURLs, WCHAR*, cRows);
08880           SAFE_ALLOC(rgdbStatus, DBSTATUS, cRows);
08881
08882           // get the arrays of source and destination URLs
08883           for (iSel=0; iSel<cRows; iSel++)
08884           {
08885             // get source URL
08886             LV_GetItemText(hWndURLs, iSel, COLUMN_ISCO_SRCURL, wszBuffer, MAX_NAME_LEN);
08887             rgpwszSourceURLs[iSel] = wcsDuplicate(wszBuffer);
08888
08889             // get destination URL
08890             LV_GetItemText(hWndURLs, iSel, COLUMN_ISCO_DESTURL, wszBuffer, MAX_NAME_LEN);
08891             rgpwszDestURLs[iSel] = wcsDuplicate(wszBuffer);
08892           }
08893
08894           switch(pThis->m_idSource)
08895           {
08896             case IDM_ISCOPEDOPERATIONS_COPY:
08897               XTEST(hr = pIScopedOperations->Copy(cRows, (const WCHAR**)rgpwszSourceURLs, (const WCHAR**)rgpwszDestURLs, dwFlags, NULL, rgdbStatus, rgpwszNewURLs, &pStringsBuffer));
08898               TESTC(TRACE_METHOD(hr, L"IScopedOperations::Copy(%lu, 0x%p, 0x%p, 0x%08x, NULL, 0x%p, 0x%p, &0x%p)", cRows, rgpwszSourceURLs, rgpwszDestURLs, dwFlags, rgdbStatus, rgpwszNewURLs, pStringsBuffer));
08899               break;
08900
08901             case IDM_ISCOPEDOPERATIONS_MOVE:
08902               XTEST(hr = pIScopedOperations->Move(cRows, (const WCHAR**)rgpwszSourceURLs, (const WCHAR**)rgpwszDestURLs, dwFlags, NULL, rgdbStatus, rgpwszNewURLs, &pStringsBuffer));
08903               TESTC(TRACE_METHOD(hr, L"IScopedOperations::Move(%lu, 0x%p, 0x%p, 0x%08x, NULL, 0x%p, 0x%p, &0x%p)", cRows, rgpwszSourceURLs, rgpwszDestURLs, dwFlags, rgdbStatus, rgpwszNewURLs, pStringsBuffer));
08904               break;
08905           };
08906
08907
08908         CLEANUP:
08909           pThis->UpdateControls();
08910           for(iSel = 0; iSel < cRows; iSel++)
08911           {
08912             SAFE_FREE(rgpwszSourceURLs[iSel]);
08913             SAFE_FREE(rgpwszDestURLs[iSel]);
08914           }
08915           SAFE_FREE(rgpwszSourceURLs);
08916           SAFE_FREE(rgpwszDestURLs);
08917           SAFE_FREE(rgdbStatus);
08918           SAFE_FREE(pStringsBuffer);
08919           if (S_OK == hr)
08920             EndDialog(hWnd, TRUE);
08921           return 0;
08922         }
08923       }
08924       break;
08925     }//WM_COMMAND
08926
08927   }//switch message
08928
08929   return FALSE;
08930 } // CMDIChild::ISCO_Proc
08931
08932
08933 ////////////////////////////////////////////////////////////////
08934 // CMDIChild::ExecuteProc
08935 //
08936 /////////////////////////////////////////////////////////////////
08937 INT_PTR WINAPI CMDIChild::ExecuteProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
08938 {
08939   static CComboBoxGuid  s_CComboInterface;
08940   static BOOL fSetCommandText   = TRUE;       //Default to TRUE
08941   static BOOL fSetCommandStream = FALSE;      //Default to FALSE
08942   static BOOL fUseParams      = FALSE;      //Default to FALSE
08943   static BOOL fAggregation    = FALSE;      //Default
08944   static BOOL fOutput       = TRUE;       //Default
08945
08946   switch(message)
08947   {
08948     case WM_INITDIALOG:
08949     {
08950       CWaitCursor waitCursor;
08951
08952       //Save the "this" pointer
08953       CMDIChild* pThis      = (CMDIChild*)SetThis(hWnd, (void*)lParam);
08954       CDataSource* pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
08955
08956       //Fill In CommandText as Default
08957       HWND hWndCmdText  = ::GetDlgItem(hWnd, IDE_COMMANDTEXT);
08958       WCHAR* pwszQuery = pThis->m_pCQueryBox->GetSelectedText();
08959       wSendMessage(hWndCmdText, WM_SETTEXT, 0, pwszQuery);
08960
08961       //Use Parameters
08962 			::CheckDlgButton(hWnd, IDB_USEPARAMS,    BST2STATE(fUseParams));
08963       //SetCommandText
08964 			::CheckDlgButton(hWnd, IDB_SETCOMMANDTEXT, BST2STATE(fSetCommandText));
08965       //SetCommandStream
08966 			::CheckDlgButton(hWnd, IDB_SETCOMMANDSTREAM,BST2STATE(fSetCommandStream));
08967       //None
08968 			::CheckDlgButton(hWnd, IDB_SETCOMMANDNONE, BST2STATE(!(fSetCommandText || fSetCommandStream)));
08969
08970       //Aggregation
08971 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
08972
08973       //Output (ppIUnknown)
08974 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
08975
08976       //Interface List...
08977       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
08978       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
08979       if(s_CComboInterface.RestoreSelection() == CB_ERR)
08980         s_CComboInterface.SetGuid(IID_IRowset);
08981
08982       //Defaults (refiid) other than those last used...
08983       if(pCDataSource && BIT_SET(pCDataSource->m_lDataSourceType, DBPROPVAL_DST_MDP))
08984         s_CComboInterface.SetGuid(IID_IMDDataset);
08985       else if(s_CComboInterface.GetGuid() == IID_IMDDataset)
08986         s_CComboInterface.SetGuid(IID_IRowset);
08987
08988       CenterDialog(hWnd);
08989       SAFE_FREE(pwszQuery);
08990       return TRUE;
08991     }
08992
08993     case WM_COMMAND:
08994     {
08995       //Filter out any Control Notification codes
08996       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
08997       {
08998         return UNHANDLED_MSG;
08999       }
09000
09001       switch (GET_WM_COMMAND_ID(wParam, lParam))
09002       {
09003         case IDB_SETPARAMS:
09004         {
09005           //Get the "this" pointer
09006           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
09007
09008           //Display the Parameter Dialog
09009           CExecuteParamDlg paramDlg(pThis);
09010           if(IDOK == paramDlg.DoModal(hWnd))
09011           {
09012             //Since the user setup the params correctly they probably want to
09013             //now use these parameters with execute.  Check the "use params" box...
09014 						::CheckDlgButton(hWnd, IDB_USEPARAMS, BST2STATE(TRUE));
09015           }
09016           return 0;
09017         }
09018
09019         case IDB_SETPROPERTIES:
09020         {
09021           //Get the "this" pointer
09022           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
09023           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
09024           CCommand* pCCommand     = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
09025           CDataSource* pCDataSource = SOURCE_GETPARENT(pCCommand, CDataSource);
09026           CRowset* pCRowset     = (CRowset*)pThis->GetObject(eCRowset);
09027
09028           //We should release the Open Objects at this point (avoid DB_E_OPENOBJECT)
09029           if(pCCommand && pThis->GetOptions()->m_dwCommandOpts & COMMAND_RELEASE_OPENOBJECTS)
09030           {
09031             pCCommand->ReleaseChildren();
09032             pThis->UpdateControls();
09033           }
09034
09035           //ICommandProperties::SetProperties
09036           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
09037           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_ICommandProperties, pCCommand->m_pICommandProperties, pCDataSource ? pCDataSource->m_pIDBProperties : NULL);
09038           return 0;
09039         }
09040
09041         case IDB_AGGREGATION:
09042         {
09043           //Aggregation Combo Selection has changed...
09044           //If we are now using Aggregation, automatically change the requested
09045           //riid to IID_IUnknown, since its an error otherwise...
09046           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
09047             s_CComboInterface.SetGuid(IID_IUnknown);
09048           return 0;
09049         }
09050
09051         case IDB_SETCOMMANDSTREAM:
09052         {
09053           //By default:  If the user chooses to use ICommandStream::SetCommandStream
09054           //they probably want a stream back as well, set this for them.  They can always
09055           //override this, byt changing it in the combo afterwards...
09056           if(::IsDlgButtonChecked(hWnd, IDB_SETCOMMANDSTREAM))
09057             s_CComboInterface.SetGuid(IID_ISequentialStream);
09058           return 0;
09059         }
09060
09061         case IDOK:
09062         {
09063           CWaitCursor waitCursor;
09064
09065           //Get the "this" pointer
09066           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
09067           CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
09068
09069           HWND hWndCmdText  = ::GetDlgItem(hWnd, IDE_COMMANDTEXT);
09070           HRESULT hr = S_OK;
09071           IUnknown* pIUnknown = NULL;
09072           WCHAR* pwszCommandText = NULL;
09073
09074           //Obtain the Aggregation argument
09075           CAggregate* pCAggregate = NULL;
09076           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
09077           if(fAggregation)
09078             pCAggregate = new CAggregate();
09079
09080           //Obtain the Output (ppIUnknown) argument
09081           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
09082
09083           //Interface
09084           IID iid     = s_CComboInterface.GetGuid();
09085
09086           //Use Parameters
09087           fUseParams    = ::IsDlgButtonChecked(hWnd, IDB_USEPARAMS);
09088
09089           //SetCommandText
09090           fSetCommandText = ::IsDlgButtonChecked(hWnd, IDB_SETCOMMANDTEXT);
09091           fSetCommandStream = ::IsDlgButtonChecked(hWnd, IDB_SETCOMMANDSTREAM);
09092           if(fSetCommandText || fSetCommandStream)
09093             pwszCommandText = wGetWindowText(hWndCmdText);
09094
09095           //Execute the Command
09096           TESTC(hr = pCCommand->Execute(pCAggregate, pwszCommandText, iid, fUseParams, NULL, fOutput ? &pIUnknown : NULL, fSetCommandStream));
09097
09098           //Process the Rowset
09099           TESTC(hr = pThis->HandleRowset(pCCommand, pIUnknown, iid, CREATE_NEWWINDOW_IFEXISTS, IID_ICommand, pwszCommandText));
09100
09101         CLEANUP:
09102           if(SUCCEEDED(hr))
09103           {
09104             //Now just need to place this name in the EditBox
09105             //Inserted after the current "caret"
09106             if(fSetCommandText)
09107               pThis->m_pCQueryBox->ReplaceAll(pwszCommandText, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
09108             EndDialog(hWnd, TRUE);
09109           }
09110
09111           SAFE_RELEASE(pCAggregate);
09112           SAFE_RELEASE(pIUnknown);
09113           SAFE_FREE(pwszCommandText);
09114           pThis->UpdateControls();
09115           return 0;
09116         }
09117
09118         case IDCANCEL:
09119         {
09120           EndDialog(hWnd, FALSE);
09121           return 0;
09122         }
09123       }
09124       break;
09125     }//WM_COMMAND
09126   }
09127
09128   return FALSE;
09129 }
09130
09131
09132 ////////////////////////////////////////////////////////////////
09133 // CMDIChild::CommandPersistProc
09134 //
09135 /////////////////////////////////////////////////////////////////
09136 INT_PTR WINAPI CMDIChild::CommandPersistProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
09137 {
09138   DBCOMMANDPERSISTFLAG dwSavedFlags = DBCOMMANDPERSISTFLAG_DEFAULT;
09139
09140   switch(message)
09141   {
09142     case WM_INITDIALOG:
09143     {
09144       CWaitCursor waitCursor;
09145
09146       //Save the "this" pointer
09147       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
09148       CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
09149       HWND hWndCommandID  = ::GetDlgItem(hWnd, IDE_COMMANDID);
09150       HWND hWndFlags = ::GetDlgItem(hWnd, IDL_FLAGS);
09151       DBID* pCommandID = NULL;
09152       HRESULT hr = S_OK;
09153
09154       //Fill in the correct window title
09155       if(pThis->m_idSource == IDM_COMMANDPERSIST_DELETECOMMAND)
09156       {
09157         //Falgs not a paraemter for DeleteCommand
09158 				::EnableWindow(hWndFlags, FALSE);
09159         SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"ICommandPersist::DeleteCommand");
09160       }
09161       else if(pThis->m_idSource == IDM_COMMANDPERSIST_LOADCOMMAND)
09162       {
09163         SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"ICommandPersist::LoadCommand");
09164       }
09165       else
09166       {
09167         //Default title is SaveCommand
09168         ASSERT(pThis->m_idSource == IDM_COMMANDPERSIST_SAVECOMMAND);
09169       }
09170
09171
09172       //CommandID
09173       //Default to the current command
09174       ASSERT(pCCommand);
09175       hr = pCCommand->GetCurrentCommand(&pCommandID);
09176       if(SUCCEEDED(hr) && pCommandID)
09177       {
09178         //Fill In CommandID as Default
09179          if(pCommandID->eKind==DBKIND_NAME && pCommandID->uName.pwszName)
09180            wSendMessage(hWndCommandID, WM_SETTEXT, 0, pCommandID->uName.pwszName);
09181       }
09182
09183       //dwFlags
09184       const static WIDENAMEMAP rgFlags[] =
09185       {
09186         VALUE_WCHAR(DBCOMMANDPERSISTFLAG_NOSAVE),
09187         VALUE_WCHAR(DBCOMMANDPERSISTFLAG_DEFAULT),
09188         VALUE_WCHAR(DBCOMMANDPERSISTFLAG_PERSISTVIEW),
09189         VALUE_WCHAR(DBCOMMANDPERSISTFLAG_PERSISTPROCEDURE),
09190       };
09191
09192       //Populate the Flags ListBox
09193       SendMessage(hWndFlags, LB_RESETCONTENT, 0, 0);
09194       for(ULONG i=0; i<NUMELE(rgFlags); i++)
09195       {
09196         INDEX iSel = (INDEX)wSendMessage(hWndFlags, LB_ADDSTRING, 0, rgFlags[i].pwszName);
09197         SendMessage(hWndFlags,  LB_SETITEMDATA, iSel, (LPARAM)rgFlags[i].lItem);
09198
09199         //Reselect all previously selected items...
09200         SendMessage(hWndFlags, LB_SETSEL, (dwSavedFlags & rgFlags[i].lItem) == (DBCOMMANDPERSISTFLAG)rgFlags[i].lItem, i);
09201       }
09202
09203       CenterDialog(hWnd);
09204       DBIDFree(pCommandID);
09205       SAFE_FREE(pCommandID);
09206       return TRUE;
09207     }
09208
09209     case WM_COMMAND:
09210     {
09211       //Filter out any Control Notification codes
09212       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
09213       {
09214         return UNHANDLED_MSG;
09215       }
09216
09217       switch (GET_WM_COMMAND_ID(wParam, lParam))
09218       {
09219         case IDOK:
09220         {
09221           CWaitCursor waitCursor;
09222
09223           //Get the "this" pointer
09224           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
09225           CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
09226           HWND hWndCommandID  = ::GetDlgItem(hWnd, IDE_COMMANDID);
09227           HWND hWndFlags    = ::GetDlgItem(hWnd, IDL_FLAGS);
09228           HRESULT hr = S_OK;
09229
09230           //Obtain the CommandID
09231           DBID CommandID;
09232           CommandID.eKind = DBKIND_NAME;
09233           CommandID.uName.pwszName = wGetWindowText(hWndCommandID);
09234
09235           //Obtain all Selected Flags...
09236           INDEX iSelCount = (INDEX)SendMessage(hWndFlags, LB_GETSELCOUNT, 0, 0);
09237           ASSERT(iSelCount < 20);
09238           LONG rgSelItems[20];
09239           SendMessage(hWndFlags, LB_GETSELITEMS, (WPARAM)20, (LPARAM)rgSelItems);
09240           for(LONG i=0; i<iSelCount; i++)
09241           {
09242             DBCOMMANDPERSISTFLAG dwSelFlag = (DBCOMMANDPERSISTFLAG)SendMessage(hWndFlags, LB_GETITEMDATA, rgSelItems[i], 0);
09243             dwSavedFlags |= dwSelFlag;
09244           }
09245
09246           if(pThis->m_idSource == IDM_COMMANDPERSIST_DELETECOMMAND)
09247           {
09248             //ICommandPersist::DeleteCommand
09249             XTEST(hr = pCCommand->m_pICommandPersist->DeleteCommand(&CommandID));
09250             TESTC(TRACE_METHOD(hr, L"ICommandPersist::DeleteCommand({\"%s\"})", CommandID.uName.pwszName));
09251           }
09252           else if(pThis->m_idSource == IDM_COMMANDPERSIST_LOADCOMMAND)
09253           {
09254             //ICommandPersist::LoadCommand
09255             XTEST(hr = pCCommand->m_pICommandPersist->LoadCommand(&CommandID, dwSavedFlags));
09256             TESTC(TRACE_METHOD(hr, L"ICommandPersist::LoadCommand({\"%s\"}, 0x%08x)", CommandID.uName.pwszName, dwSavedFlags));
09257
09258             //The symmantics of LoadCommand replace the "underlying" command.
09259             //so there is no interface to "repopluate" the current command with, and
09260             //all currently held interfaces should still be valid...
09261           }
09262           else
09263           {
09264             //ICommandPersist::SaveCommand
09265             ASSERT(pThis->m_idSource == IDM_COMMANDPERSIST_SAVECOMMAND);
09266             XTEST(hr = pCCommand->m_pICommandPersist->SaveCommand(&CommandID, dwSavedFlags));
09267             TESTC(TRACE_METHOD(hr, L"ICommandPersist::SaveCommand({\"%s\"}, 0x%08x)", CommandID.uName.pwszName, dwSavedFlags));
09268           }
09269
09270         CLEANUP:
09271           SAFE_FREE(CommandID.uName.pwszName);
09272           if(SUCCEEDED(hr))
09273             EndDialog(hWnd, TRUE);
09274           return 0;
09275         }
09276
09277         case IDCANCEL:
09278         {
09279           EndDialog(hWnd, FALSE);
09280           return 0;
09281         }
09282       }
09283       break;
09284     }//WM_COMMAND
09285   }
09286
09287   return FALSE;
09288 }
09289
09290
09291 ////////////////////////////////////////////////////////////////
09292 // CMDIChild::SetCommandTextProc
09293 //
09294 /////////////////////////////////////////////////////////////////
09295 INT_PTR WINAPI CMDIChild::SetCommandTextProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
09296 {
09297   static BOOL fRelOpenObjects = TRUE; //Default
09298   static BOOL fUnicodeStream  = TRUE; //Default
09299   static CComboBoxGuid  s_CComboDialect;
09300   static CComboBoxGuid  s_CComboRefiid;
09301
09302   switch(message)
09303   {
09304     case WM_INITDIALOG:
09305     {
09306       CWaitCursor waitCursor;
09307
09308       //Save the "this" pointer
09309       CMDIChild* pThis  = (CMDIChild*)SetThis(hWnd, (void*)lParam);
09310       CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
09311       HWND hWndCmdText  = ::GetDlgItem(hWnd, IDE_COMMANDTEXT);
09312
09313       //Fill-in Dialect Combo
09314       s_CComboDialect.CreateIndirect(hWnd, IDC_DIALECT);
09315       s_CComboDialect.Populate(g_cDialectMaps, g_rgDialectMaps);
09316       s_CComboDialect.SetGuid(pCCommand->m_guidDialect);
09317
09318       //Fill-in REFIID Combo (ICommandStream)
09319       if(pThis->m_idSource == IDM_SETCOMMANDSTREAM)
09320       {
09321         s_CComboRefiid.CreateIndirect(hWnd, IDC_REFIID);
09322         s_CComboRefiid.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
09323         s_CComboRefiid.SetGuid(IID_ISequentialStream);
09324       }
09325
09326       //Fill In CommandText as Default
09327       WCHAR* pwszQuery = pThis->m_pCQueryBox->GetSelectedText();
09328       wSendMessage(hWndCmdText, WM_SETTEXT, 0, pwszQuery);
09329
09330       //Default Options
09331 			::CheckDlgButton(hWnd, IDB_UNICODE,        BST2STATE(fUnicodeStream));
09332 			::CheckDlgButton(hWnd, IDB_RELEASE_OPENOBJECTS,  BST2STATE(fRelOpenObjects));
09333
09334       CenterDialog(hWnd);
09335       SAFE_FREE(pwszQuery);
09336       return TRUE;
09337     }
09338
09339     case WM_COMMAND:
09340     {
09341       //Filter out any Control Notification codes
09342       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
09343       {
09344         return UNHANDLED_MSG;
09345       }
09346
09347       switch (GET_WM_COMMAND_ID(wParam, lParam))
09348       {
09349         case IDOK:
09350         {
09351           CWaitCursor waitCursor;
09352
09353           //Get the "this" pointer
09354           CMDIChild* pThis  = (CMDIChild*)GetThis(hWnd);
09355           CCommand* pCCommand = SOURCE_GETOBJECT(pThis->m_pCSource, CCommand);
09356           CRowset* pCRowset = (CRowset*)pThis->GetObject(eCRowset);
09357           WCHAR* pwszCommandText = NULL;
09358
09359           HWND hWndCmdText  = ::GetDlgItem(hWnd, IDE_COMMANDTEXT);
09360           HRESULT hr = S_OK;
09361
09362           //Options
09363           fUnicodeStream = ::IsDlgButtonChecked(hWnd, IDB_UNICODE);
09364           fRelOpenObjects = ::IsDlgButtonChecked(hWnd, IDB_RELEASE_OPENOBJECTS);
09365           if(pCCommand && fRelOpenObjects)
09366           {
09367             pCCommand->ReleaseChildren();
09368             pThis->UpdateControls();
09369           }
09370
09371           //Get Guid Dialect
09372           //NOTE: Save it into a temporary in case this fails...
09373           GUID guidDialect = GUID_NULL;
09374           INDEX iSel = s_CComboDialect.GetCurSel();
09375           if(iSel != CB_ERR)
09376           {
09377             //Get ItemData which is the Guid Pointer
09378             guidDialect = s_CComboDialect.GetGuid();
09379           }
09380           else
09381           {
09382             //Convert Users String to a Guid
09383             WCHAR wszBuffer[MAX_NAME_LEN] = {0};
09384             s_CComboDialect.GetSelText(wszBuffer, MAX_NAME_LEN);
09385             XTESTC(hr = CLSIDFromString(wszBuffer, &guidDialect));
09386           }
09387
09388           //ICommand::SetCommandText
09389           pwszCommandText = wGetWindowText(hWndCmdText);
09390           if(pThis->m_idSource == IDM_SETCOMMANDSTREAM)
09391           {
09392             REFIID riid = s_CComboRefiid.GetGuid();
09393             TESTC(hr = pCCommand->SetCommandStream(pwszCommandText,
09394                                 riid,
09395                                 &guidDialect,
09396                                 fUnicodeStream));
09397           }
09398           else
09399           {
09400             TESTC(hr = pCCommand->SetCommandText(pwszCommandText, &guidDialect));
09401           }
09402
09403         CLEANUP:
09404           if(SUCCEEDED(hr))
09405           {
09406             //Now just need to place this name in the EditBox
09407             //Inserted after the current "caret"
09408             pThis->m_pCQueryBox->ReplaceAll(pwszCommandText, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
09409             EndDialog(hWnd, TRUE);
09410           }
09411
09412           SAFE_FREE(pwszCommandText);
09413           return 0;
09414         }
09415
09416         case IDCANCEL:
09417         {
09418           EndDialog(hWnd, FALSE);
09419           return 0;
09420         }
09421       }
09422       break;
09423     }//WM_COMMAND
09424   }
09425
09426   return FALSE;
09427 }
09428
09429
09430 ////////////////////////////////////////////////////////////////
09431 // CMDIChild::GetColumnsRowsetProc
09432 //
09433 /////////////////////////////////////////////////////////////////
09434 INT_PTR WINAPI CMDIChild::GetColumnsRowsetProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
09435 {
09436   static CComboBoxGuid  s_CComboInterface;
09437   static CPropSets    s_CPropSets;
09438
09439   static BOOL fUseProps   = TRUE;   //Default
09440   static bool fOptColumns   = TRUE;   //Default
09441   static BOOL fAggregation  = FALSE;  //Default
09442   static BOOL fOutput     = TRUE;   //Default
09443
09444   switch(message)
09445   {
09446     case WM_INITDIALOG:
09447     {
09448       CWaitCursor waitCursor;
09449
09450       //Save the "this" pointer
09451       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
09452
09453       //Use Optional Columns
09454 			::CheckDlgButton(hWnd, IDB_USEOPTCOLUMNS,  BST2STATE(fOptColumns));
09455       //Use Properties
09456 			::CheckDlgButton(hWnd, IDB_USEPROPERTIES,  BST2STATE(fUseProps));
09457
09458       //Aggregation
09459 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
09460
09461       //Output (ppIUnknown)
09462 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
09463
09464       //Interface List...
09465       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
09466       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
09467       if(s_CComboInterface.RestoreSelection() == CB_ERR)
09468         s_CComboInterface.SetGuid(IID_IRowset);
09469
09470       //Only set these "Default" properties, if requested by the user
09471       if(pThis->GetOptions()->m_dwRowsetOpts & ROWSET_SETDEFAULTPROPS)
09472       {
09473         //DBPROP_CANHOLDROWS is required by the OLE DB Spec - Level-0 Conformance
09474         //Since it is also legal to set a ReadOnly property, just blindy set it...
09475         s_CPropSets.SetProperty(DBPROP_CANHOLDROWS, DBPROPSET_ROWSET, DBTYPE_BOOL, (void*)VARIANT_TRUE, DBPROPOPTIONS_REQUIRED);
09476       }
09477
09478       CenterDialog(hWnd);
09479       return TRUE;
09480     }
09481
09482     case WM_COMMAND:
09483     {
09484       //Filter out any Control Notification codes
09485       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
09486       {
09487         return UNHANDLED_MSG;
09488       }
09489
09490       switch (GET_WM_COMMAND_ID(wParam, lParam))
09491       {
09492         case IDB_SETPROPERTIES:
09493         {
09494           //Get the "this" pointer
09495           CMDIChild* pThis      = (CMDIChild*)GetThis(hWnd);
09496           CMainWindow* pCMainWindow = pThis->m_pCMainWindow;
09497           CDataSource* pCDataSource = SOURCE_GETPARENT(pThis->m_pCSource, CDataSource);
09498
09499           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
09500           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &s_CPropSets);
09501           return 0;
09502         }
09503
09504         case IDB_AGGREGATION:
09505         {
09506           //Aggregation Combo Selection has changed...
09507           //If we are now using Aggregation, automatically change the requested
09508           //riid to IID_IUnknown, since its an error otherwise...
09509           if(::IsDlgButtonChecked(hWnd, IDB_AGGREGATION))
09510             s_CComboInterface.SetGuid(IID_IUnknown);
09511           return 0;
09512         }
09513
09514         case IDOK:
09515         {
09516           CWaitCursor waitCursor;
09517
09518           //Get the "this" pointer
09519           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
09520           CDataAccess* pCDataAccess = SOURCE_GETOBJECT(pThis->m_pCSource, CDataAccess);
09521
09522           HRESULT hr = S_OK;
09523           IUnknown* pIUnknown = NULL;
09524
09525           ULONG cPropSets = 0;
09526           DBPROPSET* rgPropSets = NULL;
09527
09528           //Obtain the Aggregation argument
09529           CAggregate* pCAggregate = NULL;
09530           fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
09531           if(fAggregation)
09532             pCAggregate = new CAggregate();
09533
09534           //Obtain the Output (ppIUnknown) argument
09535           fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
09536
09537           //Interface
09538           REFIID riid = s_CComboInterface.GetGuid();
09539
09540           //Use Properties
09541           fUseProps = ::IsDlgButtonChecked(hWnd, IDB_USEPROPERTIES);
09542           if(fUseProps)
09543           {
09544             cPropSets = s_CPropSets.GetCount();
09545             rgPropSets = s_CPropSets.GetPropSets();
09546           }
09547
09548           //Use Optional Columns
09549           fOptColumns = ::IsDlgButtonChecked(hWnd, IDB_USEOPTCOLUMNS) ? true : false;
09550
09551           //IColumnsRowset::GetColumnsRowset
09552           hr = pCDataAccess->GetColumnsRowset(pCAggregate, fOptColumns, riid, cPropSets, rgPropSets, fOutput ? &pIUnknown : NULL);
09553
09554           if(SUCCEEDED(hr))
09555           {
09556             //Process the Rowset
09557             hr = pThis->HandleRowset(pCDataAccess, pIUnknown, riid, CREATE_NEWWINDOW_IFEXISTS, IID_IColumnsRowset);
09558           }
09559
09560
09561           SAFE_RELEASE(pCAggregate);
09562           SAFE_RELEASE(pIUnknown);
09563
09564           //Have to exit, even if failure.  The failure can happen at any
09565           //point, ie: during accessor creation.  So we end up with a
09566           //valid rowset, but not neccessaryliy something that supports
09567           //IColumnsRowset...
09568           if(SUCCEEDED(hr))
09569             EndDialog(hWnd, TRUE);
09570           return 0;
09571         }
09572
09573         case IDCANCEL:
09574         {
09575           EndDialog(hWnd, FALSE);
09576           return 0;
09577         }
09578       }
09579       break;
09580     }//WM_COMMAND
09581   }
09582
09583   return FALSE;
09584 }
09585
09586
09587 ////////////////////////////////////////////////////////////////
09588 // CMDIChild::GetChapteredChild
09589 //
09590 /////////////////////////////////////////////////////////////////
09591 HRESULT CMDIChild::GetChapteredChild(INDEX iSelectedCol, const DBBINDING* pBinding, REFIID riid)
09592 {
09593   ASSERT(pBinding);
09594   IUnknown* pIUnknown = NULL;
09595   HRESULT hr = S_OK;
09596   CRowset*  pCRowset = (CRowset*)GetObject(eCRowset);
09597   HROW hRow = NULL;
09598   CBase* pCObject = NULL;
09599   INDEX iSelRow = 0;
09600
09601   WCHAR wszChapter[POINTER_DISPLAYSIZE] = {0};
09602   HCHAPTER hChapter = NULL;
09603
09604   if(pCRowset && pCRowset->m_pIRowsetInfo)
09605   {
09606     //IRowsetInfo::GetReferencedRowset
09607     XTEST(hr = pCRowset->m_pIRowsetInfo->GetReferencedRowset(pBinding->iOrdinal, riid, &pIUnknown));
09608     TESTC(TRACE_METHOD(hr, L"IRowsetInfo::GetReferencedRowset(%ld, %s, &0x%p)", pBinding->iOrdinal, GetInterfaceName(riid), pIUnknown));
09609
09610     //Obtain the hChapter from the rowset for the selected row.  If a row is not selected this
09611     //would be to open the entire child rowset.  If the bookmark column is used it useally
09612     //means to return the current rowset - again.  Both cases theres no chapter specified...
09613     iSelRow = m_pCDataGrid->GetSelectedRow(&hRow, FALSE);
09614     if(iSelRow != LVM_ERR && pBinding->iOrdinal!=0)
09615     {
09616       if(hRow)
09617       {
09618         TESTC(hr = pCRowset->GetChapter(hRow, pBinding->iOrdinal, &hChapter));
09619         StringFormat(wszChapter, NUMELE(wszChapter), L"%p", hChapter);
09620       }
09621       else
09622       {
09623         //Get the Item from the 'insert' ListView
09624         m_pCDataGrid->GetItemText(iSelRow, iSelectedCol+1, wszChapter, NUMELE(wszChapter));
09625         hChapter = wcstoul(wszChapter, NULL, 16);
09626       }
09627     }
09628
09629     //Create a new Rowset Window for the result...
09630     //But dont actually display the object, until we set the hChapter
09631     //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
09632     pCObject = m_pCMainWindow->HandleObjectType(pCRowset, pIUnknown, riid, eCRowset, 0, NULL, CREATE_NEWWINDOW | CREATE_NODISPLAY | CREATE_DETERMINE_TYPE);
09633     if(pCObject)
09634     {
09635       //Set the Chapter handle, before displaying rowset...
09636       CRowset* pCRowset = SOURCE_GETOBJECT(pCObject, CRowset);
09637       if(pCRowset)
09638       {
09639         pCRowset->m_hChapter = hChapter;
09640         pCRowset->SetObjectDesc(wszChapter);
09641       }
09642       pCObject->DisplayObject();
09643     }
09644     else
09645     {
09646       TESTC(hr = E_FAIL);
09647     }
09648   }
09649
09650 CLEANUP:
09651   TRACE_RELEASE(pIUnknown, L"Rowset");
09652   return hr;
09653 }
09654
09655
09656 ////////////////////////////////////////////////////////////////
09657 // CMDIChild::GetReferencedRowsetProc
09658 //
09659 /////////////////////////////////////////////////////////////////
09660 INT_PTR WINAPI CMDIChild::GetReferencedRowsetProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
09661 {
09662   static CComboBoxGuid  s_CComboInterface;
09663
09664   switch(message)
09665   {
09666     case WM_INITDIALOG:
09667     {
09668       CWaitCursor waitCursor;
09669
09670       //Save the "this" pointer
09671       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
09672       CRowset* pCRowset = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
09673
09674       INDEX iSel = 0;
09675       HWND hWndColumn   = ::GetDlgItem(hWnd, IDC_COLUMN);
09676
09677       //Column List...
09678       INDEX iSavedCol = CB_ERR;
09679       for(ULONG i=0; i<pCRowset->m_Bindings.GetCount(); i++)
09680       {
09681         //Column Ordinal - Column Name
09682         DBORDINAL iOrdinal = pCRowset->m_Bindings[i].iOrdinal;
09683         const DBCOLUMNINFO* pColInfo = pCRowset->m_ColumnInfo.GetOrdinal(iOrdinal);
09684
09685         //SetDefault to first chaptered column...
09686         if(pColInfo->dwFlags & DBCOLUMNFLAGS_ISCHAPTER)
09687         {
09688           iSel = (INDEX)wSendMessageFmt(hWndColumn, CB_ADDSTRING, 0, L"%2d - %s <ISCHAPTER>", iOrdinal, GetColName(pColInfo));
09689           if(iSavedCol == CB_ERR)
09690             iSavedCol = iSel;
09691         }
09692         else
09693         {
09694           iSel = (INDEX)wSendMessageFmt(hWndColumn, CB_ADDSTRING, 0, L"%2d - %s", iOrdinal, GetColName(pColInfo));
09695         }
09696
09697         //Save the iBinding in ther listview
09698         SendMessage(hWndColumn, CB_SETITEMDATA, iSel, (LPARAM)i);
09699       }
09700
09701       //Set Default...
09702       SendMessage(hWndColumn, CB_SETCURSEL, iSavedCol < (INDEX)pCRowset->m_Bindings.GetCount() && iSavedCol!=CB_ERR ? iSavedCol : 0, 0);
09703
09704       //Interface List...
09705       s_CComboInterface.CreateIndirect(hWnd, IDC_INTERFACE);
09706       s_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
09707       if(s_CComboInterface.RestoreSelection() == CB_ERR)
09708         s_CComboInterface.SetGuid(IID_IRowset);
09709
09710       CenterDialog(hWnd);
09711       return TRUE;
09712     }
09713
09714     case WM_COMMAND:
09715     {
09716       //Filter out any Control Notification codes
09717       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
09718       {
09719         return UNHANDLED_MSG;
09720       }
09721
09722       switch (GET_WM_COMMAND_ID(wParam, lParam))
09723       {
09724         case IDOK:
09725         {
09726           CWaitCursor waitCursor;
09727
09728           //Get the "this" pointer
09729           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
09730           CRowset* pCRowset = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
09731
09732           HWND hWndColumn   = ::GetDlgItem(hWnd, IDC_COLUMN);
09733           HRESULT hr = S_OK;
09734
09735           //Column
09736           INDEX iSavedCol = (INDEX)SendMessage(hWndColumn, CB_GETCURSEL, 0, 0);
09737           DBCOUNTITEM iBinding = SendMessage(hWndColumn, CB_GETITEMDATA, iSavedCol!=CB_ERR ? iSavedCol : 0, 0);
09738           const DBBINDING* pBinding = &pCRowset->m_Bindings[iBinding];
09739
09740           //Interface
09741           REFIID riid = s_CComboInterface.GetGuid();
09742
09743           //Obtain the Child rowset..
09744           hr = pThis->GetChapteredChild(iSavedCol, pBinding, riid);
09745           if(SUCCEEDED(hr))
09746             EndDialog(hWnd, TRUE);
09747           return 0;
09748         }
09749
09750         case IDCANCEL:
09751         {
09752           EndDialog(hWnd, FALSE);
09753           return 0;
09754         }
09755       }
09756       break;
09757     }//WM_COMMAND
09758   }
09759
09760   return FALSE;
09761 }
09762
09763
09764 ////////////////////////////////////////////////////////////////
09765 // CMDIChild::FindNextRowProc
09766 //
09767 /////////////////////////////////////////////////////////////////
09768 INT_PTR WINAPI CMDIChild::FindNextRowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
09769 {
09770   static INDEX  iSavedCol   = 1;    //Default column
09771   static INDEX  iSavedOp    = 2;    //Default DBCOMPAREOPS_EQ
09772   static LONG   cSavedRows    = 1;    //Default to cRows=1
09773   static DWORD  dwCompareOps  = 0;    //Default to not CASESENSITIVE
09774
09775   switch(message)
09776   {
09777     case WM_INITDIALOG:
09778     {
09779       CWaitCursor waitCursor;
09780
09781       //Save the "this" pointer
09782       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
09783       CRowset* pCRowset = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
09784       INDEX iSel = 0;
09785
09786       HWND hWndColumn   = ::GetDlgItem(hWnd, IDC_COLUMN);
09787       HWND hWndCompareOp  = ::GetDlgItem(hWnd, IDC_COMPAREOP);
09788       HWND hWndcRows    = ::GetDlgItem(hWnd, IDE_COUNT);
09789       HWND hWndValue    = ::GetDlgItem(hWnd, IDE_VALUE);
09790
09791       //Column List...
09792       for(ULONG i=0; i<pCRowset->m_Bindings.GetCount(); i++)
09793       {
09794         //Column Ordinal - Column Name
09795         DBORDINAL iOrdinal = pCRowset->m_Bindings[i].iOrdinal;
09796         const DBCOLUMNINFO* pColInfo = pCRowset->m_ColumnInfo.GetOrdinal(iOrdinal);
09797         iSel = (INDEX)wSendMessageFmt(hWndColumn, CB_ADDSTRING, 0, L"%2d - %s", iOrdinal, GetColName(pColInfo));
09798         SendMessage(hWndColumn, CB_SETITEMDATA, iSel, (LPARAM)i);
09799       }
09800
09801       //Set Default...
09802       SendMessage(hWndColumn, CB_SETCURSEL, iSavedCol < (INDEX)pCRowset->m_Bindings.GetCount() && iSavedCol!=CB_ERR ? iSavedCol : 0, 0);
09803
09804       const static WIDENAMEMAP rgCompareOps[] =
09805       {
09806         VALUE_WCHAR(DBCOMPAREOPS_LT),
09807         VALUE_WCHAR(DBCOMPAREOPS_LE),
09808         VALUE_WCHAR(DBCOMPAREOPS_EQ),
09809         VALUE_WCHAR(DBCOMPAREOPS_GE),
09810         VALUE_WCHAR(DBCOMPAREOPS_GT),
09811         VALUE_WCHAR(DBCOMPAREOPS_BEGINSWITH),
09812         VALUE_WCHAR(DBCOMPAREOPS_CONTAINS),
09813         VALUE_WCHAR(DBCOMPAREOPS_NE),
09814         VALUE_WCHAR(DBCOMPAREOPS_IGNORE),
09815         VALUE_WCHAR(DBCOMPAREOPS_NOTBEGINSWITH),
09816         VALUE_WCHAR(DBCOMPAREOPS_NOTCONTAINS),
09817       };
09818
09819       //CompareOp List...
09820       for(i=0; i<NUMELE(rgCompareOps); i++)
09821       {
09822         iSel = (INDEX)wSendMessage(hWndCompareOp, CB_ADDSTRING, 0, rgCompareOps[i].pwszName);
09823         SendMessage(hWndCompareOp, CB_SETITEMDATA, iSel, (LPARAM)rgCompareOps[i].lItem);
09824       }
09825
09826       //Set Default...
09827       iSavedOp = (INDEX)SendMessage(hWndCompareOp, CB_SETCURSEL, iSavedOp != CB_ERR ? iSavedOp : 0, 0);
09828
09829       //dwModifiers
09830       //DBCOMPAREOPS_CASESENSITIVE
09831       //DBCOMPAREOPS_CASEINSENSITIVE
09832 			::CheckDlgButton(hWnd, IDB_CASESENSITIVE,    BST2STATE(dwCompareOps & DBCOMPAREOPS_CASESENSITIVE));
09833 			::CheckDlgButton(hWnd, IDB_CASEINSENSITIVE,    BST2STATE(dwCompareOps & DBCOMPAREOPS_CASEINSENSITIVE));
09834
09835       //cRows
09836       wSendMessageFmt(hWndcRows, WM_SETTEXT, 0, L"%lu", cSavedRows);
09837
09838       //Value
09839       SendMessage(hWndValue, WM_SETTEXT, 0, (LPARAM)"");
09840
09841       CenterDialog(hWnd);
09842       return TRUE;
09843     }
09844
09845     case WM_COMMAND:
09846     {
09847       //Filter out any Control Notification codes
09848       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
09849       {
09850         return UNHANDLED_MSG;
09851       }
09852
09853       switch (GET_WM_COMMAND_ID(wParam, lParam))
09854       {
09855         case IDOK:
09856         {
09857           CWaitCursor waitCursor;
09858
09859           //Get the "this" pointer
09860           CMDIChild* pThis = (CMDIChild*)GetThis(hWnd);
09861           CRowset* pCRowset = SOURCE_GETOBJECT(pThis->m_pCSource, CRowset);
09862           HRESULT hr = S_OK;
09863
09864           HWND hWndColumn   = ::GetDlgItem(hWnd, IDC_COLUMN);
09865           HWND hWndCompareOp  = ::GetDlgItem(hWnd, IDC_COMPAREOP);
09866           HWND hWndcRows    = ::GetDlgItem(hWnd, IDE_COUNT);
09867           HWND hWndValue    = ::GetDlgItem(hWnd, IDE_VALUE);
09868
09869           HACCESSOR hAccessor = NULL;
09870
09871           //Bookmark
09872           DBBKMARK cbBookmark = 0;
09873           BYTE* pBookmark = NULL;
09874
09875           HROW hRow = NULL;
09876           void* pData = pCRowset->m_pData;
09877           DBROWOFFSET lOffset = 0;
09878           DBCOUNTITEM cRowsObtained = 0;
09879           HROW* rghRows = NULL;
09880           HCHAPTER hChapter = pCRowset->m_hChapter;
09881
09882           //Column
09883           iSavedCol = (INDEX)SendMessage(hWndColumn, CB_GETCURSEL, 0, 0);
09884           DBCOUNTITEM iBinding = SendMessage(hWndColumn, CB_GETITEMDATA, iSavedCol!=CB_ERR ? iSavedCol : 0, 0);
09885           const DBBINDING* pBinding   = &pCRowset->m_Bindings[iBinding];
09886           const DBCOLUMNINFO* pColInfo  = pCRowset->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
09887
09888           //CompareOp
09889           iSavedOp = (INDEX)SendMessage(hWndCompareOp, CB_GETCURSEL, 0, 0);
09890           dwCompareOps = (DBCOMPAREOP)SendMessage(hWndCompareOp, CB_GETITEMDATA, iSavedOp != CB_ERR ? iSavedOp : 0, 0);
09891
09892           //dwModifiers
09893           if(::IsDlgButtonChecked(hWnd, IDB_CASESENSITIVE))
09894             dwCompareOps |= DBCOMPAREOPS_CASESENSITIVE;
09895           if(::IsDlgButtonChecked(hWnd, IDB_CASEINSENSITIVE))
09896             dwCompareOps |= DBCOMPAREOPS_CASEINSENSITIVE;
09897
09898           //cRows
09899           GetEditBoxValue(hWndcRows, &cSavedRows);
09900
09901           //Value
09902           WCHAR* pwszValue = wGetWindowText(hWndValue);
09903
09904           //Create An Accessor binding only this column
09905           TESTC(hr = pCRowset->CreateAccessor(DBACCESSOR_ROWDATA, 1, pBinding, 0, &hAccessor));
09906
09907           //Setup the pData buffer containg the users value
09908           TESTC(hr = pCRowset->SetColumnData(pBinding, pData, DBSTATUS_S_OK, pwszValue ? wcslen(pwszValue) : 0, pwszValue ? pwszValue : L"", CONV_NONE, pColInfo->wType));
09909
09910           //Obtain the bookmark(s) for the selected row(s)...
09911           if(pThis->m_pCDataGrid->GetSelectedRow(&hRow, FALSE)!=LVM_ERR)
09912             hr = pCRowset->GetBookmark(hRow, &cbBookmark, (BYTE**)&pBookmark);
09913
09914           //Release previously fetched rows, (if user requested)
09915           TESTC(hr = pThis->m_pCDataGrid->ReleaseHeldRows());
09916
09917           //IRowsetFind::FindNextRow
09918           XTEST(hr = pCRowset->m_pIRowsetFind->FindNextRow(hChapter, hAccessor, pData, dwCompareOps, cbBookmark, pBookmark, lOffset, cSavedRows, &cRowsObtained, &rghRows));
09919           TESTC(TRACE_METHOD(hr, L"IRowsetFind::FindNextRow(0x%p, 0x%p, \"%s\", 0x%08x, %lu, 0x%p, %ld, %ld, &%lu, &0x%p)", hChapter, hAccessor, pwszValue, dwCompareOps, cbBookmark, pBookmark, lOffset, cSavedRows,  cRowsObtained, rghRows));
09920
09921         CLEANUP:
09922           //TODO - need to free in the case of errors as well.  But have to be careful
09923           //since the pData may not have been setup yet, or other errors where its undefined...
09924           if(SUCCEEDED(hr))
09925             FreeBindingData(1, pBinding, pData, TRUE/*SetData*/);
09926
09927           pCRowset->ReleaseAccessor(&hAccessor);
09928           SAFE_FREE(pBookmark);
09929           SAFE_FREE(rghRows);
09930           SAFE_FREE(pwszValue);
09931
09932           if(SUCCEEDED(hr))
09933           {
09934             EndDialog(hWnd, TRUE);
09935             return 0;
09936           }
09937           return 0;
09938         }
09939
09940         case IDCANCEL:
09941         {
09942           EndDialog(hWnd, FALSE);
09943           return 0;
09944         }
09945       }
09946       break;
09947     }//WM_COMMAND
09948   }
09949
09950   return FALSE;
09951 }
09952
09953
09954 ////////////////////////////////////////////////////////////////
09955 // CMDIChild::ProviderInfoProc
09956 //
09957 /////////////////////////////////////////////////////////////////
09958 INT_PTR WINAPI CMDIChild::ProviderInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
09959 {
09960   switch (message)
09961   {
09962     case WM_INITDIALOG:
09963     {
09964       CWaitCursor waitCursor;
09965
09966       CMDIChild* pThis = (CMDIChild*)SetThis(hWnd, (void*)lParam);
09967       CComBSTR cstrString;
09968       CComBSTR cstrString2;
09969       DWORD dwValue = 0;
09970
09971       //Determine which object were on...
09972       IDBProperties* pIDBProperties = SOURCE_GETINTERFACE(pThis->m_pCSource, IDBProperties);
09973       if(pIDBProperties)
09974       {
09975         //DBPROP_PROVIDERFILENAME
09976         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_PROVIDERFILENAME,   DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString);
09977         wSendMessage(::GetDlgItem(hWnd, IDT_PROVIDERFILENAME), WM_SETTEXT, 0, cstrString ? cstrString : L"");
09978         cstrString.Empty();
09979
09980         //DBPROP_PROVIDERFRIENDLYNAME
09981         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_PROVIDERFRIENDLYNAME, DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString);
09982         wSendMessage(::GetDlgItem(hWnd, IDT_PROVIDERDESC), WM_SETTEXT, 0, cstrString ? cstrString : L"");
09983         cstrString.Empty();
09984
09985         //DBPROP_PROVIDERVER
09986         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_PROVIDERVER,  DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString);
09987         //DBPROP_PROVIDEROLEDBVER
09988         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_PROVIDEROLEDBVER, DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString2);
09989         wSendMessageFmt(::GetDlgItem(hWnd, IDT_PROVIDERVERSION), WM_SETTEXT, 0, L"Prov - %s   OLEDB - %s", cstrString ? cstrString : L"Unknown", cstrString2 ? cstrString2 : L"Unknown");
09990         cstrString.Empty();
09991         cstrString2.Empty();
09992
09993         //DBMS / DBMSVER
09994         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_DBMSNAME, DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString);
09995         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_DBMSVER,  DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString2);
09996         wSendMessageFmt(::GetDlgItem(hWnd, IDT_DBMS), WM_SETTEXT, 0, L"%s %s", cstrString ? cstrString : L"", cstrString2 ? cstrString2 : L"");
09997         cstrString.Empty();
09998         cstrString2.Empty();
09999
10000         //DATASOURCE
10001         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_DATASOURCENAME, DBPROPSET_DATASOURCEINFO, DBTYPE_BSTR, &cstrString);
10002         wSendMessage(::GetDlgItem(hWnd, IDT_DATASOURCE), WM_SETTEXT, 0, cstrString ? cstrString : L"");
10003         cstrString.Empty();
10004
10005         //DBPROP_DATASOURCEREADONLY
10006         VARIANT_BOOL bReadOnly = VARIANT_FALSE;
10007         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_DATASOURCEREADONLY, DBPROPSET_DATASOURCEINFO, DBTYPE_BOOL, &bReadOnly);
10008         SendMessage(::GetDlgItem(hWnd, IDT_READONLY), WM_SETTEXT, 0, bReadOnly ? (LPARAM)"Read-Only" : (LPARAM)"Updatable");
10009
10010         //DBPROP_CURRENTCATALOG
10011         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_CURRENTCATALOG,   DBPROPSET_DATASOURCE, DBTYPE_BSTR, &cstrString);
10012         wSendMessage(::GetDlgItem(hWnd, IDT_CATALOG), WM_SETTEXT, 0, cstrString);
10013         cstrString.Empty();
10014
10015         //DBPROP_DSOTHREADMODEL
10016         GetProperty(IID_IDBProperties, pIDBProperties, DBPROP_DSOTHREADMODEL,   DBPROPSET_DATASOURCEINFO, DBTYPE_I4, &dwValue);
10017         SendMessage(::GetDlgItem(hWnd, IDT_THREADMODEL), WM_SETTEXT, 0, (LPARAM)(dwValue & DBPROPVAL_RT_FREETHREAD ? "FreeThreaded" : dwValue & DBPROPVAL_RT_APTMTTHREAD ? "ApartmentModel" : dwValue & DBPROPVAL_RT_SINGLETHREAD ? "SingleThreaded" : "Unknown"));
10018       }
10019
10020       CenterDialog(hWnd);
10021       return TRUE;
10022     }
10023
10024     case WM_COMMAND:
10025     {
10026       //Filter out any Control Notification codes
10027       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
10028       {
10029         return UNHANDLED_MSG;
10030       }
10031
10032       switch (GET_WM_COMMAND_ID(wParam, lParam))
10033       {
10034         case IDOK:
10035         case IDCANCEL:
10036         {
10037           CWaitCursor waitCursor;
10038           EndDialog(hWnd, TRUE);
10039           return TRUE;
10040         }
10041       }
10042       break;
10043     }//WM_COMMAND
10044   }
10045
10046   return FALSE;
10047 }
10048
10049
10050
10051
10052
10053 ////////////////////////////////////////////////////////////////
10054 // CQueryBox::CQueryBox
10055 //
10056 /////////////////////////////////////////////////////////////////
10057 CQueryBox::CQueryBox(CMDIChild* pCMDIChild)
10058 {
10059   ASSERT(pCMDIChild);
10060   m_pCMDIChild = pCMDIChild;
10061 }
10062
10063
10064 ////////////////////////////////////////////////////////////////
10065 // CQueryBox::~CQueryBox
10066 //
10067 /////////////////////////////////////////////////////////////////
10068 CQueryBox::~CQueryBox()
10069 {
10070 }
10071
10072
10073 ////////////////////////////////////////////////////////////////
10074 // CQueryBox::OnRButtonDown
10075 //
10076 /////////////////////////////////////////////////////////////////
10077 BOOL CQueryBox::OnRButtonDown(WPARAM fwKeys, REFPOINTS pts)
10078 {
10079   //NOTE: The right mouse button doesn't automatically activate the MDI window...
10080   m_pCMDIChild->m_pCMainWindow->MDIActivate(m_hWndParent);
10081
10082   //xPos, yPos are Relative to the Client Area...
10083   DisplayContextMenu(
10084             m_hWnd,
10085             IDM_EDITMENU,
10086             pts,
10087             m_pCMDIChild->m_hWnd,
10088             TRUE
10089             );
10090   return TRUE;
10091 }
10092
10093 ////////////////////////////////////////////////////////////////
10094 // CQueryBox::OnContextMenu
10095 //
10096 /////////////////////////////////////////////////////////////////
10097 BOOL CQueryBox::OnContextMenu(HWND hWnd, REFPOINTS pts)
10098 {
10099   DisplayContextMenu(
10100             hWnd,
10101             IDM_EDITMENU,
10102             pts,
10103             m_pCMDIChild->m_hWnd
10104             );
10105   return  TRUE;
10106 }
10107
10108
10109 ////////////////////////////////////////////////////////////////
10110 // CQueryBox::OnKeyDown
10111 //
10112 /////////////////////////////////////////////////////////////////
10113 BOOL CQueryBox::OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData)
10114 {
10115   switch(nVirtKey)
10116   {
10117     case VK_TAB:
10118     {
10119       MSG msg;
10120       m_pCMDIChild->m_pCDataGrid->SetFocus();
10121       PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
10122       return TRUE;
10123     }
10124   };
10125
10126   return FALSE;
10127 }
10128
10129
10130
10131
10132 ////////////////////////////////////////////////////////////////
10133 // CDataGrid::CDataGrid
10134 //
10135 /////////////////////////////////////////////////////////////////
10136 CDataGrid::CDataGrid(CMDIChild* pCMDIChild)
10137 {
10138   ASSERT(pCMDIChild);
10139
10140   //Data
10141   m_pCMDIChild      = pCMDIChild;
10142   m_lMaxRows        = 0;
10143
10144   //Cursor
10145   m_fLastFetchForward   = FALSE;
10146   m_lCurPos       = 0;
10147 }
10148
10149 ////////////////////////////////////////////////////////////////
10150 // CDataGrid::~CDataGrid
10151 //
10152 /////////////////////////////////////////////////////////////////
10153 CDataGrid::~CDataGrid()
10154 {
10155 }
10156
10157
10158 ////////////////////////////////////////////////////////////////
10159 // CDataGrid::GetOptions
10160 //
10161 /////////////////////////////////////////////////////////////////
10162 COptionsSheet*  CDataGrid::GetOptions()
10163 {
10164   return m_pCMDIChild->GetOptions();
10165 }
10166
10167
10168 /////////////////////////////////////////////////////////////////////
10169 // CDataGrid::OnSize
10170 //
10171 /////////////////////////////////////////////////////////////////////
10172 BOOL CDataGrid::OnSize(WPARAM nType, REFPOINTS pts)
10173 {
10174   switch(nType)
10175   {
10176     case SIZE_RESTORED:
10177     case SIZE_MAXIMIZED:
10178     {
10179       if(pts.x && pts.y)
10180       {
10181         //Obtain the total number of available items (subtract for ScrollBar)
10182         m_lMaxRows = GetCountPerPage()-1;
10183         m_lMaxRows = max(m_lMaxRows, 0);  //At least 0
10184       }
10185
10186       return FALSE;
10187     }
10188   };
10189
10190   return FALSE;
10191 }
10192
10193
10194 ////////////////////////////////////////////////////////////////
10195 // CDataGrid::OnRButtonDown
10196 //
10197 /////////////////////////////////////////////////////////////////
10198 BOOL CDataGrid::OnRButtonDown(WPARAM fwKeys, REFPOINTS pts)
10199 {
10200   //NOTE: The right mouse button doesn't automatically activate the MDI window...
10201   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10202
10203   //xPos, yPos are Relative to the Client Area...
10204   if(pCDataAccess)
10205   {
10206     DisplayContextMenu(
10207             m_hWnd,
10208             pCDataAccess->GetObjectMenu(),
10209             pts,
10210             m_pCMDIChild->m_pCMainWindow->m_hWnd,
10211             TRUE
10212             );
10213     return TRUE;
10214   }
10215
10216   return FALSE;
10217 }
10218
10219
10220 ////////////////////////////////////////////////////////////////
10221 // CDataGrid::OnContextMenu
10222 //
10223 /////////////////////////////////////////////////////////////////
10224 BOOL CDataGrid::OnContextMenu(HWND hWnd, REFPOINTS pts)
10225 {
10226   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10227
10228   if(pCDataAccess)
10229   {
10230     DisplayContextMenu(
10231             m_hWnd,
10232             pCDataAccess->GetObjectMenu(),
10233             pts,
10234             m_pCMDIChild->m_pCMainWindow->m_hWnd
10235             );
10236     return TRUE;
10237   }
10238
10239   return FALSE;
10240 }
10241
10242
10243 /////////////////////////////////////////////////////////////////////
10244 // CDataGrid::OnColumnClick
10245 //
10246 /////////////////////////////////////////////////////////////////////
10247 BOOL CDataGrid::OnColumnClick(INT idCtrl, NMLISTVIEW* pNMListView)
10248 {
10249   //Can't edit "Row-Handle" Column
10250   if(pNMListView->iSubItem == 0)
10251     return TRUE;
10252
10253   CWaitCursor waitCursor;
10254
10255   //Save the SelectedCol so the new dialog box knows which Column were concerned with...
10256   m_iSelCol = pNMListView->iSubItem-1;
10257   CRowset* pCRowset = (CRowset*)m_pCMDIChild->GetObject(eCRowset);
10258
10259   //See if the selected column is a chapter column...
10260   if(pCRowset)
10261   {
10262     if((DBCOUNTITEM)m_iSelCol < pCRowset->m_Bindings.GetCount())
10263     {
10264       const DBBINDING* pBinding = &pCRowset->m_Bindings[m_iSelCol];
10265       const DBCOLUMNINFO* pColInfo = pCRowset->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
10266       if(pColInfo->dwFlags & DBCOLUMNFLAGS_ISCHAPTER)
10267       {
10268         //Obtain the Child rowset..
10269         m_pCMDIChild->GetChapteredChild(m_iSelCol, pBinding);
10270         return TRUE;
10271       }
10272     }
10273   }
10274
10275   //Otherwise we will assume the user wants to "edit" the column...
10276   if(GetItemCount())
10277   {
10278     CRow* pCRow     = (CRow*)m_pCMDIChild->GetObject(eCRow);
10279     CDataset* pCDataset = (CDataset*)m_pCMDIChild->GetObject(eCDataset);
10280     CRowset* pCRowset = (CRowset*)m_pCMDIChild->GetObject(eCRowset);
10281
10282     //Determine the Object Type...
10283     if(pCRow)
10284       m_pCMDIChild->DisplayDialog(IDD_ROWCHANGE, m_hWnd, CMDIChild::ColumnChangeProc, pCRow, IDM_IROW_SETCOLUMNS);
10285     else if(pCDataset)
10286       m_pCMDIChild->DisplayDialog(IDD_ROWCHANGE, m_hWnd, CMDIChild::ColumnChangeProc, pCDataset, IDM_DATASET_GETCELLDATA);
10287     else if(pCRowset)
10288       m_pCMDIChild->DisplayDialog(IDD_ROWCHANGE, m_hWnd, CMDIChild::ColumnChangeProc, pCRowset, IDM_SETDATA);
10289   }
10290
10291   return TRUE;
10292 }
10293
10294
10295 /////////////////////////////////////////////////////////////////////
10296 // CDataGrid::OnItemActivate
10297 //
10298 /////////////////////////////////////////////////////////////////////
10299 BOOL CDataGrid::OnItemActivate(INT idCtrl, NMLISTVIEW* pNMListView)
10300 {
10301   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10302   CRow* pCRow     = SOURCE_GETOBJECT(pCDataAccess, CRow);
10303   CDataset* pCDataset = SOURCE_GETOBJECT(pCDataAccess, CDataset);
10304   INDEX iSelCol   = pNMListView->iSubItem-1;
10305
10306   //If this is a row object, then bring up the SetColumns dialog...
10307   if(pCRow)
10308   {
10309     //IRowChange::SetColumns
10310     m_pCMDIChild->ChangeSelectedRow(pCRow, IDM_IROW_SETCOLUMNS);
10311   }
10312   else if(pCDataset)
10313   {
10314     //IMDDataset::GetCellData
10315     m_pCMDIChild->ChangeSelectedRow(pCDataset, IDM_DATASET_GETCELLDATA);
10316   }
10317   else
10318   {
10319     CRowset* pCRowset =  SOURCE_GETOBJECT(pCDataAccess, CRowset);
10320     if(pCRowset)
10321     {
10322       //If the parent object is an enumerator, then Double Clicking on the row
10323       //means you wish to "drill" into that row of the enumerator and call ParseDisplayName...
10324       if(pCRowset->m_pCParent && pCRowset->m_pCParent->GetObjectType() == eCEnumerator)
10325       {
10326         //If enumertor rowset, double-clicking on a row
10327         //brings up the ParseName object in another window
10328         CWaitCursor waitCursor;
10329         m_pCMDIChild->CreateEnumChild();
10330         return TRUE;
10331       }
10332
10333       //See if the selected column is a chapter column...
10334       if((DBCOUNTITEM)iSelCol < pCRowset->m_Bindings.GetCount())
10335       {
10336         const DBBINDING* pBinding = &pCRowset->m_Bindings[iSelCol];
10337         const DBCOLUMNINFO* pColInfo = pCRowset->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
10338         if(pColInfo->dwFlags & DBCOLUMNFLAGS_ISCHAPTER)
10339         {
10340           //Obtain the Child rowset..
10341           m_pCMDIChild->GetChapteredChild(iSelCol, pBinding);
10342           return TRUE;
10343         }
10344       }
10345
10346       //Otherwise we just have a "normal" rowset...
10347       HROW hRow;
10348       if(GetSelectedRow(&hRow, FALSE) != LVM_ERR)
10349       {
10350         CWaitCursor waitCursor;
10351         IUnknown* pIUnknown = NULL;
10352
10353         //So either we are drilling into a row object from the rowset, or
10354         //were are trying to edit the actual data of the row handle
10355         if(SUCCEEDED(pCRowset->GetRowFromHROW(NULL, hRow, IID_IRow, &pIUnknown)))
10356         {
10357           //Create in new window
10358           CBase* pCObject = m_pCMDIChild->m_pCMainWindow->HandleObjectType(pCRowset, pIUnknown, IID_IRow, eCRow, 0, NULL, CREATE_NEWWINDOW | CREATE_NODISPLAY);
10359           if(pCObject)
10360           {
10361             //Fill in which row handle this row was created from...
10362             //Just for display purposes...
10363             CRow* pCRow = SOURCE_GETOBJECT(pCObject, CRow);
10364             if(pCRow)
10365               pCRow->m_hSourceRow = hRow;
10366
10367             pCObject->DisplayObject();
10368           }
10369         }
10370         else
10371         {
10372           //Otherwise were just trying to update or view detailed info...
10373           m_pCMDIChild->ChangeSelectedRow(pCRowset, IDM_SETDATA);
10374         }
10375
10376         SAFE_RELEASE(pIUnknown);
10377       }
10378     }
10379   }
10380
10381   return TRUE;
10382 }
10383
10384
10385 ////////////////////////////////////////////////////////////////
10386 // CDataGrid::OnKeyDown
10387 //
10388 /////////////////////////////////////////////////////////////////
10389 BOOL CDataGrid::OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData)
10390 {
10391   switch(nVirtKey)
10392   {
10393     case VK_DELETE:
10394     {
10395       PostMessage(m_pCMDIChild->m_hWnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_DELETEROWS, 0, 0));
10396       return TRUE;
10397     }
10398
10399     case VK_INSERT:
10400     {
10401       PostMessage(m_pCMDIChild->m_hWnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_INSERTROW, 0, 0));
10402       return TRUE;
10403     }
10404
10405     case VK_UP:
10406       ScrollGrid(-1);
10407       return TRUE;
10408
10409     case VK_DOWN:
10410       ScrollGrid(1);
10411       return TRUE;
10412
10413     case VK_PRIOR:
10414       ScrollGrid(-m_lMaxRows);
10415       return TRUE;
10416
10417     case VK_NEXT:
10418       ScrollGrid(m_lMaxRows);
10419       return TRUE;
10420
10421     case VK_TAB:
10422     {
10423       MSG msg;
10424       m_pCMDIChild->m_pCQueryBox->SetFocus();
10425       PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
10426       return TRUE;
10427     }
10428   };
10429
10430   return FALSE;
10431 }
10432
10433
10434 /////////////////////////////////////////////////////////////////////
10435 // CDataGrid::OnVScroll
10436 //
10437 /////////////////////////////////////////////////////////////////////
10438 BOOL CDataGrid::OnVScroll(int nScrollCode, int nPos, HWND hWnd)
10439 {
10440   switch(nScrollCode)
10441   {
10442     case SB_LINEUP:
10443       ScrollGrid(-1);
10444       break;
10445
10446     case SB_LINEDOWN:
10447       ScrollGrid(1);
10448       break;
10449
10450     case SB_PAGEUP:
10451       ScrollGrid(-m_lMaxRows);
10452       break;
10453
10454     case SB_PAGEDOWN:
10455       ScrollGrid(m_lMaxRows);
10456       break;
10457   };
10458
10459   return FALSE;
10460 }
10461
10462
10463 ////////////////////////////////////////////////////////////////
10464 // CDataGrid::DisplayColumnInfo
10465 //
10466 /////////////////////////////////////////////////////////////////
10467 HRESULT CDataGrid::DisplayColumnInfo()
10468 {
10469   INDEX iResult = 0;
10470   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10471
10472   //Insert the Column Headers.
10473   //Only display the columns for which are bound in the Accessor
10474
10475   //Insert Row Header
10476   InsertColumn(0, pCDataAccess->GetObjectType() == eCDataset ? L"  Cell Ordinal  " : L"  Row Handle  ");
10477
10478   //Loop through the columns
10479   for(ULONG i=0; i<pCDataAccess->m_Bindings.GetCount(); i++)
10480   {
10481     const DBCOLUMNINFO* pColInfo = pCDataAccess->m_ColumnInfo.GetOrdinal(pCDataAccess->m_Bindings[i].iOrdinal);
10482
10483     //Get ColumnName
10484     iResult = InsertColumn(i+1, GetColName(pColInfo), pCDataAccess->GetColumnImage(pColInfo));
10485   }
10486
10487   //AutoSize Columns, (including "Row-Handle" column)
10488   for(i=0; i<pCDataAccess->m_Bindings.GetCount()+1; i++)
10489     SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);
10490
10491   //CLEANUP:
10492     return iResult == LVM_ERR ? E_FAIL : S_OK;
10493 }
10494
10495
10496 ////////////////////////////////////////////////////////////////
10497 // CDataGrid::RefreshData
10498 //
10499 /////////////////////////////////////////////////////////////////
10500 HRESULT CDataGrid::RefreshData()
10501 {
10502   CWaitCursor waitCursor;
10503   HRESULT hr = S_OK;
10504   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10505   CRow* pCRow         = SOURCE_GETOBJECT(pCDataAccess, CRow);
10506   CRowset* pCRowset     = SOURCE_GETOBJECT(pCDataAccess, CRowset);
10507   DWORD dwRowsetOpts      = GetOptions()->m_dwRowsetOpts;
10508
10509   //Clear ListView object
10510   ClearAll();
10511
10512   //Display the Column Headers
10513   //TODO: Would be nice to optimize this to not require a complete dump of all
10514   //columns and redisplay, need to split out between create accessor and refresh...
10515   TESTC(hr = DisplayColumnInfo());
10516
10517   //Row Object?
10518   if(pCRow)
10519   {
10520     //Insert an empty row into the ListView
10521     InsertItem(0, 0, L"", 0, IMAGE_NORMAL);
10522
10523     //Display the row data
10524     TESTC(hr = DisplayData(pCRow->m_hSourceRow, 0, DBPROP_IRow));
10525   }
10526   else
10527   {
10528     //Determine the number of rows the user wants (initially)
10529     //Always obtain more rows than what the grid allows so we can get the scroll bar
10530     //visable.  This way they can use the scroll bar up/dn to populate more rows
10531     DBROWCOUNT cRowsToFetch = m_lMaxRows+3;
10532     if(GetOptions()->m_dwRowsetOpts & ROWSET_ROWSTOFETCH)
10533       cRowsToFetch = GetOptions()->m_cRowsToFetch;
10534
10535     if(cRowsToFetch)
10536       TESTC(hr = GetNextRows(0, cRowsToFetch, TRUE/*fRetry*/));
10537   }
10538
10539 CLEANUP:
10540   m_pCMDIChild->UpdateControls();
10541   return hr;
10542 }
10543
10544
10545 ////////////////////////////////////////////////////////////////
10546 // CDataGrid::DisplayData
10547 //
10548 /////////////////////////////////////////////////////////////////
10549 HRESULT CDataGrid::DisplayData
10550 (
10551   HROW      hRow,
10552   INDEX     iIndex,
10553   DBPROPID    dwSourceID,
10554   bool      fAlways
10555 )
10556 {
10557   ASSERT(iIndex >=0 && iIndex<ULONG_MAX);
10558   HRESULT hr = E_FAIL;
10559   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10560   CRow*    pCRow      = SOURCE_GETOBJECT(pCDataAccess, CRow);
10561   CRowset*   pCRowset   = SOURCE_GETOBJECT(pCDataAccess, CRowset);
10562   CDataset*  pCDataset    = SOURCE_GETOBJECT(pCDataAccess, CDataset);
10563   void* pData = pCDataAccess->m_pData;
10564
10565   DBSTATUS dbStatus = 0;
10566   DWORD i,dwConvFlags = GetOptions()->m_dwConvFlags;
10567   WCHAR wszBuffer[MAX_COL_SIZE+1] = {0};
10568
10569   //NOTE: We obtain/display the data - unless the users wishes to not obtain
10570   //the data by default, or this is called from a method that should always obtain data (ie: GetData)
10571   if(fAlways || !(GetOptions()->m_dwRowsetOpts & ROWSET_NODATA))
10572   {
10573     //This displays data from any source.
10574     if(pCRow && dwSourceID == DBPROP_IRow)
10575     {
10576       //IRow::GetColumns
10577       hr = pCRow->GetColumns(pCRow->m_cColAccess, pCRow->m_rgColAccess);
10578     }
10579     else if(pCRowset)
10580     {
10581       //IRowset::GetData
10582       hr = pCRowset->GetData(hRow, NULL, pData, dwSourceID);
10583     }
10584     else if(pCDataset)
10585     {
10586       hRow = iIndex;
10587
10588       //IMDDataset::GetCellData
10589       hr = pCDataset->GetCellData(hRow, hRow);
10590     }
10591
10592     //Relax the errors here.  With Get*Data both DB_S/DB_E will return a bad
10593     //status for 1 or more columns.  Or DataGrid will just display the column
10594     //status if not S_OK.  So for these errors just display the data anyway...
10595     if(SUCCEEDED(hr) || hr== DB_E_ERRORSOCCURRED)
10596     {
10597       //Display all Columns
10598       for(i=0; i<pCDataAccess->m_Bindings.GetCount(); i++)
10599       {
10600         const DBBINDING* pBinding   = &pCDataAccess->m_Bindings[i];
10601         const DBCOLUMNINFO* pColInfo  = pCDataAccess->m_ColumnInfo.GetOrdinal(pBinding->iOrdinal);
10602
10603         //Obtain the column data...
10604         pCDataAccess->GetColumnData(pBinding, pData, &dbStatus, NULL/*pdbLength*/, NULL, wszBuffer, MAX_COL_SIZE, dwConvFlags | CONV_TYPENAME, pColInfo->wType);
10605
10606         //Set item in ListView
10607           SetItemText(iIndex, i+1, wszBuffer);
10608         SetItemImage(iIndex, i+1, pCDataAccess->GetColumnImage(NULL, dbStatus));
10609       }
10610
10611       //Clean outofline memory data
10612       //TODO - need to free in the case of errors as well.  But have to be careful
10613       //since the pData may not have been setup yet, or other errors where its undefined...
10614       pCDataAccess->m_Bindings.FreeData(pData);
10615     }
10616   }
10617
10618   //Now add the "hRow" indicator
10619   if(hRow)
10620     StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%p", hRow);
10621   else
10622     StringFormat(wszBuffer, NUMELE(wszBuffer), L"No Handle");
10623   SetItemText(iIndex, 0, wszBuffer);
10624   SetItemParam(iIndex, 0, hRow);
10625     return hr;
10626 }
10627
10628
10629 ////////////////////////////////////////////////////////////////
10630 // CDataGrid::DisplayRows
10631 //
10632 /////////////////////////////////////////////////////////////////
10633 HRESULT CDataGrid::DisplayRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, DBCOUNTITEM cRowsObtained, HROW* rghRows, BOOL fAdjustFetchPosition)
10634 {
10635   HRESULT hr = S_OK;
10636   DBROWOFFSET lStartIndex = lOffset;
10637   BOOL fLastFetchForward  = FALSE;
10638
10639   //Obtain total ListItems
10640   INDEX cItems = GetItemCount();
10641   ASSERT(cItems >= 0);
10642
10643   //  Since RowsetViewer displays the abstract "NextFetchPosition" to
10644   //  the user and we need to make sure we put the correct rows obtained into
10645   //  the correct indexs, we need to map the OLE DB Fetch Position into an index
10646   //  based method for our listview.
10647   //
10648   //  The OLE DB Cursor (NextFetchPosition) is always "in-between" rows
10649   //  Meaning its either before or after the row, (not actually on the row).
10650   //  For example: If the NFP is before row 2, and cRows=1, then row 2 will be
10651   //  retrieved, but if it was after then row 3 is retrieved.  Likewise if
10652   //  NFP is before row and cRows=-1, then row 1 is retrived, but if it was
10653   //  after then row 2 is retrieved.  Doing a Forward fetch (cRows++) makes
10654   //  the NFP after that row, and a Backward fetch (cRows--) makes the
10655   //  NFP appear before.
10656
10657   //  +---------------+---------------+---------------------------|-----------------------------------+
10658   //  | LastFetch   | cRows   | StartIndex        | EndIndex            |
10659   //  +---------------+---------------+---------------------------+-----------------------------------+
10660   //  |#1 Forward   | Positive  | CurIndex + Offset + 1 | StartIndex + cRowsObtained - 1  |
10661   //  |#2 Forward   | Negative  | CurIndex + Offset   | StartIndex - cRowsObtained + 1  |
10662   //  |#3 Backward  | Positive  | CurIndex + Offset   | StartIndex + cRowsObtained - 1  |
10663   //  |#4 Backward  | Negative  | CurIndex + Offset - 1 | StartIndex - cRowsObtained + 1  |
10664   //  +---------------+---------------+---------------------------+-----------------------------------+
10665
10666   //Calculate the StartIndex (using the Table Above)
10667   if(fAdjustFetchPosition)
10668   {
10669     //#1, #2, #3, #4 (Common Case) is just CurIndex + Offset
10670     lStartIndex = m_lCurPos + lOffset;
10671     fLastFetchForward = m_fLastFetchForward;
10672
10673     //#1
10674     if(fLastFetchForward && cRows > 0)
10675       lStartIndex += 1;
10676     //#4
10677     if(!fLastFetchForward && cRows < 0)
10678       lStartIndex -= 1;
10679   }
10680
10681   //Determine Ending Index
10682   DBROWOFFSET lEndIndex = lStartIndex;
10683   if(cRowsObtained)
10684   {
10685     if(cRows > 0)
10686     {
10687       //#1, #3
10688       lEndIndex = lStartIndex + cRowsObtained - 1;
10689       fLastFetchForward = TRUE;
10690     }
10691     else
10692     {
10693       //#2, #4
10694       lEndIndex = lStartIndex - cRowsObtained + 1;
10695       fLastFetchForward = FALSE;
10696     }
10697
10698     //Remove Previous Fetch Icon
10699     if(fAdjustFetchPosition)
10700       SetItemImage((INDEX)m_lCurPos, 0, IMAGE_NORMAL);
10701
10702     //Remove Previous Selection Bars
10703     for(INDEX iIndex=0; iIndex<cItems; iIndex++)
10704       SetItemState(iIndex, 0, ~LVIS_SELECTED, LVIS_SELECTED);
10705   }
10706
10707   //Loop over rows obtained, displaying/updating in the ListView
10708   for(DBCOUNTITEM iRow=0; iRow<cRowsObtained; iRow++)
10709   {
10710     ASSERT(rghRows);
10711
10712     //Calulate which direction to start with
10713     HROW hRow = rghRows[iRow];
10714     INDEX iIndex = (INDEX)(cRows > 0 ? lStartIndex + iRow : lStartIndex - iRow);
10715
10716     //We may need extra row padding, if fetched out of sequence...
10717     while(iIndex >= cItems)
10718     {
10719       InsertItem(iIndex, 0, L"", 0, IMAGE_NORMAL);
10720       cItems++;
10721     }
10722
10723     //We may need to insert rows before the beginging if scrolling
10724     //around the rowset...
10725     while(iIndex < 0)
10726     {
10727       InsertItem(0, 0, L"", 0, IMAGE_NORMAL);
10728       cItems++;
10729
10730       //A row is being inserted, meaning this shifts all our
10731       //current indexes by one...
10732       lStartIndex++;
10733       lEndIndex++;
10734       iIndex++;
10735       m_lCurPos++;
10736       }
10737
10738     //Display GetData in the ListView
10739     hr = DisplayData(hRow, iIndex);
10740   }
10741
10742   //Scroll the new rows into view...
10743   if(cRowsObtained)
10744   {
10745     //Adjust our saved Fetched Position
10746     if(fAdjustFetchPosition)
10747     {
10748       //Display the direction of the cursor
10749       DisplayFetchPosition(lEndIndex, fLastFetchForward);
10750     }
10751
10752     //Make sure the item is visible
10753     EnsureVisible(lEndIndex);
10754   }
10755
10756   return hr;
10757 }
10758
10759
10760 ////////////////////////////////////////////////////////////////
10761 // CDataGrid::DisplayFetchPosition
10762 //
10763 /////////////////////////////////////////////////////////////////
10764 HRESULT CDataGrid::DisplayFetchPosition(INDEX iIndex, BOOL fLastFetchForward)
10765 {
10766   //Display the direction of the cursor
10767   SetItemImage(iIndex, 0, fLastFetchForward ? IMAGE_ARROW_DOWN : IMAGE_ARROW_UP);
10768
10769   //Display the new Selection Bar for this row
10770   SetItemState(iIndex, 0, LVIS_SELECTED, LVIS_SELECTED);
10771
10772   //Update our saved cursor position
10773   m_lCurPos     = iIndex;
10774   m_fLastFetchForward = fLastFetchForward;
10775
10776   //Make sure the item is visible
10777   EnsureVisible(iIndex);
10778   return S_OK;
10779 }
10780
10781
10782 ////////////////////////////////////////////////////////////////
10783 // CDataGrid::RestartPosition
10784 //
10785 /////////////////////////////////////////////////////////////////
10786 HRESULT CDataGrid::RestartPosition()
10787 {
10788   CWaitCursor waitCursor;
10789   HRESULT hr = S_OK;
10790   CRowset*  pCRowset = (CRowset*)m_pCMDIChild->GetObject(eCRowset);
10791
10792   if(pCRowset && pCRowset->m_pIRowset)
10793   {
10794     //Release previously fetched rows, (if user requested)
10795     TESTC(hr = ReleaseHeldRows());
10796
10797     //RestartPosition...
10798     TESTC(hr = pCRowset->RestartPosition());
10799   }
10800
10801   //Need to remove the "NextFetchPositon" icon from the "old" row
10802   SetItemImage((INDEX)m_lCurPos, 0, IMAGE_NORMAL);
10803
10804   m_fLastFetchForward = FALSE;
10805   m_lCurPos = 0;
10806
10807   //Need to show the "NextFetchPositon" icon
10808   SetItemImage((INDEX)m_lCurPos, 0, IMAGE_ARROW_UP);
10809   EnsureVisible((INDEX)m_lCurPos);
10810
10811 CLEANUP:
10812   return hr;
10813 }
10814
10815
10816 ////////////////////////////////////////////////////////////////
10817 // CDataGrid::GetNextRows
10818 //
10819 /////////////////////////////////////////////////////////////////
10820 HRESULT CDataGrid::GetNextRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, BOOL fRetry)
10821 {
10822   HRESULT hr    = S_OK;
10823   HRESULT hrGNR = S_OK;
10824   CDataAccess* pCDataAccess = m_pCMDIChild->m_pCDataAccess;
10825   CRowset*  pCRowset    = SOURCE_GETOBJECT(pCDataAccess, CRowset);
10826   CWaitCursor waitCursor;
10827
10828   DBCOUNTITEM   cRowsObtained = 0;
10829   HROW      rghRows[MAX_OPENROWS];
10830   HROW*     phRows = rghRows;
10831
10832   //Only use dynamic memory allocation if more rows than our static array
10833   if((cRows > MAX_OPENROWS) || (cRows < -MAX_OPENROWS))
10834     phRows = NULL;
10835
10836   if(pCRowset)
10837   {
10838     //Retry is dependednt upon ability to release previously held rows...
10839     fRetry = fRetry && (GetOptions()->m_dwRowsetOpts & ROWSET_ALWAYSRELEASEROWS);
10840
10841     while(TRUE)
10842     {
10843       //Release previously fetched rows, (if user requested)
10844       TESTC(hr = ReleaseHeldRows());
10845
10846       //IRowset::GetNextRows
10847       TESTC(hr = hrGNR = pCRowset->GetNextRows(lOffset, cRows, &cRowsObtained, &phRows));
10848
10849       //Now Display the rows...
10850       TESTC(hr = DisplayRows(lOffset, cRows, cRowsObtained, phRows, TRUE/*fAdjustFetchPosition*/));
10851
10852       //Some providers may have limitations on the number of rows that can be returned in
10853       //one call, but the consumer may actually just wish to see all the rows without having
10854       //to "manually" scroll down one row at a time.  The consumer indicates they wish this
10855       //behavior by having "ReleaseRowsAlways" on, so we will do whatever possible to obtain
10856       //all the requested rows - assuming the calling context is "retry-able" - ie: fRetry
10857       if(fRetry && cRowsObtained)
10858       {
10859         //If we are not at the end of the rowset, and not all rows were retrieved
10860         //then retry.  Provider probably returned DB_S_ROWLIMITEXCEEDED
10861         if(hrGNR!=DB_S_ENDOFROWSET && cRowsObtained < (DBCOUNTITEM)ABS(cRows))
10862         {
10863           cRows -= cRowsObtained;
10864           continue;
10865         }
10866       }
10867
10868       //Were done...
10869       break;
10870     }
10871   }
10872   else
10873   {
10874     ASSERT(cRows <= MAX_OPENROWS);
10875     cRowsObtained = ABS(cRows);
10876
10877     //Now Display the rows...
10878     TESTC(hr = DisplayRows(lOffset, cRows, cRowsObtained, phRows, TRUE/*fAdjustFetchPosition*/));
10879   }
10880
10881 CLEANUP:
10882   //Delete the rows if provider allocated
10883   if(phRows != rghRows)
10884     SAFE_FREE(phRows);
10885   return hr;
10886 }
10887
10888
10889 ////////////////////////////////////////////////////////////////
10890 // CDataGrid::GetSelectedRow
10891 //
10892 /////////////////////////////////////////////////////////////////
10893 INDEX CDataGrid::GetSelectedRow(HROW* phRow, BOOL fValidate)
10894 {
10895   //Find the Selected Item in the ListView
10896   INDEX iSelRow = GetNextItem(-1, LVNI_SELECTED);
10897   if(iSelRow == LVM_ERR)
10898   {
10899     if(fValidate)
10900     {
10901       wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONHAND | MB_OK | MB_DEFBUTTON1,
10902         wsz_ERROR, L"Must first select a row...");
10903     }
10904
10905     return iSelRow;
10906   }
10907
10908   //Otherwise we have a valid row...
10909   if(phRow)
10910     *phRow = GetItemParam(iSelRow);
10911
10912   return iSelRow;
10913 }
10914
10915
10916
10917 ////////////////////////////////////////////////////////////////
10918 // CDataGrid::ReleaseHeldRows
10919 //
10920 /////////////////////////////////////////////////////////////////
10921 HRESULT CDataGrid::ReleaseHeldRows()
10922 {
10923   //Release previously fetched rows, (if user requested)
10924   if(GetOptions()->m_dwRowsetOpts & ROWSET_ALWAYSRELEASEROWS)
10925   {
10926     return ReleaseRows(LV_ALLITEMS, TRUE/*fOnlyValidRows*/);
10927   }
10928
10929   return S_OK;
10930 }
10931
10932
10933 ////////////////////////////////////////////////////////////////
10934 // CDataGrid::ReleaseRows
10935 //
10936 /////////////////////////////////////////////////////////////////
10937 HRESULT CDataGrid::ReleaseRows(INDEX iIndex, BOOL fOnlyValidRows)
10938 {
10939   HRESULT hr = S_OK;
10940   CRowset*  pCRowset = (CRowset*)m_pCMDIChild->GetObject(eCRowset);
10941
10942   INDEX i,cRows = 0;
10943   INDEX* rgItems = NULL;
10944   HROW* rghRows = NULL;
10945   ULONG* rgRefCounts = NULL;
10946
10947   //Release all rows
10948   if(iIndex == LV_ALLITEMS)
10949   {
10950     //Find all Rows
10951     LV_GetAllItems(m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
10952   }
10953   //Release all selected rows
10954   else if(iIndex == LV_ALLSELITEMS)
10955   {
10956     //Find all Selected Rows
10957     LV_GetSelItems(m_hWnd, &cRows, &rgItems, (LPARAM**)&rghRows);
10958   }
10959   //Release 1 Row
10960   else
10961   {
10962     //First need to obtain the LPARAM (hRow) to Release it...
10963     //TODO: Shouldn't dynamic allocation here!
10964     cRows = 1;
10965     SAFE_ALLOC(rgItems, INDEX, cRows);
10966     SAFE_ALLOC(rghRows, HROW, cRows);
10967     rgItems[0] = iIndex;
10968     rghRows[0] = GetItemParam(iIndex);
10969   }
10970
10971   //Release only valid rows
10972   if(fOnlyValidRows)
10973   {
10974     //Loop over all rows...
10975     ULONG iLastValid = 0;
10976     for(i=0; i<cRows; i++)
10977     {
10978       //Compact out invalid row handles...
10979       if(rghRows[i] == NULL)
10980         continue;
10981
10982       //Inplace shift...
10983       rghRows[iLastValid] = rghRows[i];
10984       rgItems[iLastValid] = rgItems[i];
10985       iLastValid++;
10986     }
10987     cRows = iLastValid;
10988   }
10989
10990   //Now ReleaseRows in 1 pass
10991   if(pCRowset && pCRowset->GetObjectType() != eCDataset)
10992   {
10993     if(cRows || !fOnlyValidRows)
10994     {
10995       SAFE_ALLOC(rgRefCounts, ULONG, cRows);
10996       TESTC(hr = pCRowset->ReleaseRows(cRows, rghRows, rgRefCounts));
10997     }
10998   }
10999
11000 CLEANUP:
11001   //If any rows have a refcount of 0, we should NULL the row handle
11002   //so we can detect the error before GetData is called on a release row
11003   for(i=0; i<cRows; i++)
11004   {
11005     if(rgRefCounts[i] == 0)
11006     {
11007       //Update the row handle, and the display
11008       SetItemText(rgItems[i], 0, L"");
11009       SetItemParam(rgItems[i], 0, DB_NULL_HROW);
11010     }
11011   }
11012
11013   SAFE_FREE(rgItems);
11014   SAFE_FREE(rghRows);
11015   SAFE_FREE(rgRefCounts);
11016   return hr;
11017 }
11018
11019
11020 ////////////////////////////////////////////////////////////////
11021 // CDataGrid::AddRefRows
11022 //
11023 /////////////////////////////////////////////////////////////////
11024 HRESULT CDataGrid::AddRefRows(INDEX iIndex)
11025 {
11026   HRESULT hr = S_OK;
11027   CRowset*  pCRowset = (CRowset*)m_pCMDIChild->GetObject(eCRowset);
11028
11029   INDEX cRows = 0;
11030   HROW* rghRows = NULL;
11031   ULONG* rgRefCounts = NULL;
11032
11033   //AddRefRows all Rows
11034   if(iIndex == LV_ALLITEMS)
11035   {
11036     //Find all Rows
11037     LV_GetAllItems(m_hWnd, &cRows, NULL, (LPARAM**)&rghRows);
11038   }
11039   //AddRefRows all selected rows
11040   else if(iIndex == LV_ALLSELITEMS)
11041   {
11042     //Find all Selected Rows
11043     LV_GetSelItems(m_hWnd, &cRows, NULL, (LPARAM**)&rghRows);
11044   }
11045   //AddRefRows 1 Row
11046   else
11047   {
11048     //First need to obtain the LPARAM (hRow) to Release it...
11049     cRows = 1;
11050     rghRows[0] = GetItemParam(iIndex);
11051   }
11052
11053   //Now AddRefRows in 1 pass
11054   if(pCRowset && pCRowset->GetObjectType() != eCDataset)
11055   {
11056     SAFE_ALLOC(rgRefCounts, ULONG, cRows);
11057     TESTC(hr = pCRowset->AddRefRows(cRows, rghRows, rgRefCounts));
11058   }
11059
11060 CLEANUP:
11061   SAFE_FREE(rghRows);
11062   SAFE_FREE(rgRefCounts);
11063   return hr;
11064 }
11065
11066
11067
11068 ////////////////////////////////////////////////////////////////
11069 // CDataGrid::ScrollGrid
11070 //
11071 /////////////////////////////////////////////////////////////////
11072 HRESULT CDataGrid::ScrollGrid(DBROWCOUNT cItems)
11073 {
11074   return GetNextRows(0, cItems, TRUE/*fRetry*/);
11075 }
11076
11077
11078 ////////////////////////////////////////////////////////////////
11079 // CDataGrid::ClearAll
11080 //
11081 /////////////////////////////////////////////////////////////////
11082 BOOL CDataGrid::ClearAll(WCHAR* pwszEmptyName)
11083 {
11084   // Delete all of the items. (no need to release rows...)
11085   DeleteAllItems();
11086
11087   // Delete all of the columns and their names.
11088   while(DeleteColumn(0));
11089
11090   //Indicate no Rowset
11091   if(pwszEmptyName)
11092   {
11093     InsertColumn(0, pwszEmptyName);
11094     SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
11095   }
11096
11097   return TRUE;
11098 }
11099
11100
11101
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Ppgeext/ppgeext.h Source File

  • SysMgmt
  • MMC
  • Ppgeext

ppgeext.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _CPropSheetExtension_H_
00020 #define _CPropSheetExtension_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CPropSheetExtension : public IExtendPropertySheet
00026 {
00027
00028 private:
00029     ULONG       m_cref;
00030
00031     // clipboard format
00032     static UINT s_cfDisplayName;
00033     static UINT s_cfSnapInCLSID;
00034     static UINT s_cfNodeType;
00035
00036 public:
00037     CPropSheetExtension();
00038     ~CPropSheetExtension();
00039
00040     ///////////////////////////////
00041     // Interface IUnknown
00042     ///////////////////////////////
00043     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00044     STDMETHODIMP_(ULONG) AddRef();
00045     STDMETHODIMP_(ULONG) Release();
00046
00047     ///////////////////////////////
00048     // Interface IExtendPropertySheet
00049     ///////////////////////////////
00050     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreatePropertyPages(
00051         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00052         /* [in] */ LONG_PTR handle,
00053         /* [in] */ LPDATAOBJECT lpIDataObject);
00054
00055         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryPagesFor(
00056         /* [in] */ LPDATAOBJECT lpDataObject);
00057
00058 private:
00059     LONG_PTR m_ppHandle;
00060
00061     static BOOL CALLBACK DialogProc(HWND hwndDlg,  // handle to dialog box
00062         UINT uMsg,     // message
00063         WPARAM wParam, // first message parameter
00064         LPARAM lParam  // second message parameter
00065         );
00066
00067
00068     ///////////////////////////////
00069     // Private IDataObject support bits
00070     ///////////////////////////////
00071     HRESULT ExtractData( IDataObject* piDataObject,
00072         CLIPFORMAT   cfClipFormat,
00073         BYTE*        pbData,
00074         DWORD        cbData )
00075     {
00076         HRESULT hr = S_OK;
00077
00078         FORMATETC formatetc = {cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
00079         STGMEDIUM stgmedium = {TYMED_HGLOBAL, NULL};
00080
00081         stgmedium.hGlobal = ::GlobalAlloc(GPTR, cbData);
00082         do // false loop
00083         {
00084             if (NULL == stgmedium.hGlobal)
00085             {
00086                 hr = E_OUTOFMEMORY;
00087                 break;
00088             }
00089             hr = piDataObject->GetDataHere( &formatetc, &stgmedium );
00090             if ( FAILED(hr) )
00091             {
00092                 break;
00093             }
00094
00095             BYTE* pbNewData = reinterpret_cast<BYTE*>(stgmedium.hGlobal);
00096             if (NULL == pbNewData)
00097             {
00098                 hr = E_UNEXPECTED;
00099                 break;
00100             }
00101             ::memcpy( pbData, pbNewData, cbData );
00102         } while (FALSE); // false loop
00103
00104         if (NULL != stgmedium.hGlobal)
00105         {
00106             ::GlobalFree(stgmedium.hGlobal);
00107         }
00108         return hr;
00109     } // ExtractData()
00110
00111     HRESULT ExtractString( IDataObject *piDataObject,
00112         CLIPFORMAT   cfClipFormat,
00113         _TCHAR       *pstr,
00114         DWORD        cchMaxLength)
00115     {
00116         return ExtractData( piDataObject, cfClipFormat, (PBYTE)pstr, cchMaxLength );
00117     }
00118
00119     HRESULT ExtractSnapInCLSID( IDataObject* piDataObject, CLSID* pclsidSnapin )
00120     {
00121         return ExtractData( piDataObject, s_cfSnapInCLSID, (PBYTE)pclsidSnapin, sizeof(CLSID) );
00122     }
00123
00124     HRESULT ExtractObjectTypeGUID( IDataObject* piDataObject, GUID* pguidObjectType )
00125     {
00126         return ExtractData( piDataObject, s_cfNodeType, (PBYTE)pguidObjectType, sizeof(GUID) );
00127     }
00128 };
00129
00130 #endif _CPropSheetExtension_H_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/DspPlain.Cpp Source File

  • WinUI
  • GlobalDev
  • CSSamp

DspPlain.Cpp

Go to the documentation of this file.
00001 ////    DspPlain.CPP - Display plaintext and handle caret placement
00002 //
00003 //      Demonstrates use of the ScriptString APIs
00004 //
00005 //      ScriptStringAnalyse          - Calls ScriptItemise, Shape, Place etc.
00006 //      ScriptStringGetLogicalWidths - Returns logical widths for the entire line
00007 //      ScriptStringXtoCP            - Pixel position to character index
00008 //      ScriptStringCPtoX            - Character index to pixel position
00009 //      ScriptString_pSize           - Gets points to SIZE structure for the line
00010 //      ScriptStringOut              - Render line to device
00011 //      ScriptStringFree             - All analyses must be freed
00012
00013 #include "precomp.hxx"
00014 #include "global.h"
00015
00016 ////    PaintPlainTextLine
00017 //
00018 //      Use the ScriptString APIs to analyse and display a line
00019 //      as plain text.
00020 void PaintPlainTextLine(
00021     HDC      hdc,               // In   Device
00022     int     *piY,               // In   Y position
00023     RECT    *prc,               // In   Clipping rectange
00024     int      iFirst,            // In   First character of line
00025     int      iLen,
00026     int      iLineHeight)       // In   Height to advance per line, in pixels
00027 {
00028     int      iX         = 0;
00029     HRESULT  hr         = NULL;
00030     int      iClipWidth = 0;
00031     int      iTrailing  = 0;         // ScriptStringXtoCP result - offset to nearest cluster edge
00032     RECT     rc         = {0};
00033     RECT     rcClear    = {0};
00034     int      iFrom      = 0;
00035     int      iTo        = 0;
00036     DWORD    dwFlags    = 0;
00037
00038     SCRIPT_CONTROL         ScriptControl = {0};
00039     SCRIPT_STATE           ScriptState   = {0};
00040     SCRIPT_STRING_ANALYSIS ssa           = {0};
00041
00042     // Clear each line before displaying it
00043     rcClear        = *prc;
00044     rcClear.top    = *piY;
00045     rcClear.bottom = *piY + iLineHeight;
00046     FillRect(hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00047
00048     if (iLen)
00049     {
00050         // There's at least one character to display
00051         iX = prc->left;
00052
00053         // Prepare string analysis input parameters
00054         dwFlags = g_dwSSAflags | SSA_GLYPHS;    // Require glyph generation for ScriptStringOut
00055
00056         ScriptControl = g_ScriptControl;
00057         ScriptState   = g_ScriptState;
00058
00059         if (ScriptState.uBidiLevel & 1)        // ScriptStringAnalyse requires SSA_RTL for rtl reading order
00060         {
00061             dwFlags |= SSA_RTL;
00062         }
00063
00064         iClipWidth = prc->right - prc->left - 50;
00065
00066         // Analyse the string.
00067         //
00068         // ScriptStringAnalyse calls the ScriptItemize, ScriptShape,
00069         // ScriptPlace and ScriptBreak APIs and returns a pointer to a block
00070         // of memory containing all these results.
00071         if (!g_fOverrideDx)
00072         {
00073             // Normal - no DX override testing required
00074             hr = ScriptStringAnalyse(
00075                     hdc,
00076                     g_wcBuf + iFirst,
00077                     iLen, 0, -1,
00078                     dwFlags,
00079                     iClipWidth,
00080                     g_fNullState ? NULL : &ScriptControl,
00081                     g_fNullState ? NULL : &ScriptState,
00082                     NULL,
00083                     NULL, NULL, &ssa);
00084
00085             // Testing
00086             int iNewLen = *ScriptString_pcOutChars(&ssa);
00087             // End testing
00088         }
00089         else
00090         {
00091             // For logical DX override testing, initialise g_iWidthBuf the
00092             // first time, subsequently follow it's specification.
00093             // The UI allows users to adjust individual logical widths.
00094             if (g_iWidthBuf[iFirst+iLen] == 0)
00095             {
00096                 g_iWidthBuf[iFirst+iLen] = 1;  // Mark this line as measured
00097                 hr = ScriptStringAnalyse(
00098                         hdc,
00099                         g_wcBuf + iFirst,
00100                         iLen, 0, -1,
00101                         dwFlags,
00102                         iClipWidth,
00103                         g_fNullState ? NULL : &ScriptControl,
00104                         g_fNullState ? NULL : &ScriptState,
00105                         NULL,
00106                         NULL, NULL, &ssa);
00107
00108                 if (SUCCEEDED(hr))
00109                 {
00110                     hr = ScriptStringGetLogicalWidths(ssa, g_iWidthBuf + iFirst);
00111                 }
00112
00113                 InvalidateText();   // Need to redisplay logical area with corrected sliders
00114
00115
00116             }
00117             else
00118             {
00119                 hr = ScriptStringAnalyse(
00120                         hdc,
00121                         g_wcBuf + iFirst,
00122                         iLen, 0, -1,
00123                         dwFlags,
00124                         iClipWidth,
00125                         g_fNullState ? NULL : &ScriptControl,
00126                         g_fNullState ? NULL : &ScriptState,
00127                         g_iWidthBuf + iFirst,
00128                         NULL, NULL, &ssa);
00129             }
00130         }
00131
00132         if (SUCCEEDED(hr))
00133         {
00134             // Check whether mouse clicks in this line are waiting to be processed
00135             if (g_fMouseDown  &&  g_iMouseDownY > *piY  &&  g_iMouseDownY < *piY+iLineHeight)
00136             {
00137                 // Record char pos at left button down
00138                 ScriptStringXtoCP(ssa, g_iMouseDownX-prc->left, &g_iFrom, &iTrailing);
00139                 g_iFrom += iTrailing + iFirst; // Snap to closest cluster edge and make relative to buffer
00140                 g_fMouseDown = FALSE;
00141             }
00142
00143
00144             if (g_fMouseUp  &&  g_iMouseUpY > *piY  &&  g_iMouseUpY < *piY+iLineHeight)
00145             {
00146                 // Complete selection processing
00147                 ScriptStringXtoCP(ssa, g_iMouseUpX-prc->left, &g_iTo, &iTrailing);
00148                 g_iTo += iTrailing + iFirst; // Snap to closest cluster edge and make relative to buffer
00149
00150                 // Caret is where mouse was raised
00151                 g_iCurChar = g_iTo;
00152                 g_fMouseUp = FALSE;     // Signal that the mouse up is processed
00153                 g_fUpdateCaret = TRUE;  // Request caret update
00154                 g_iCaretSection = CARET_SECTION_PLAINTEXT;    // in plaintext section
00155             }
00156
00157             // Display this line
00158             rc        = *prc;          // Clip to line height (important for selection marking)
00159             rc.top    = *piY;
00160             rc.bottom = *piY + iLineHeight;
00161
00162             // Support selection range specified in either direction
00163             if (g_iFrom <= g_iTo)
00164             {
00165                 iFrom = g_iFrom - iFirst;
00166                 iTo   = g_iTo   - iFirst;
00167             }
00168             else
00169             {
00170                 iFrom = g_iTo   - iFirst;
00171                 iTo   = g_iFrom - iFirst;
00172             }
00173
00174             hr = ScriptStringOut(
00175                 ssa,
00176                 prc->left,
00177                *piY,
00178                 ETO_CLIPPED,
00179                &rc,
00180                 iFrom,   // ScriptStringOut will ignore From/To that are outside this line
00181                 iTo,
00182                 FALSE);
00183
00184             // Now position the caret if it has moved, either because of a mouse click
00185             // detected above, or because of an editing function such as a cursor key.
00186
00187             if (    g_fUpdateCaret
00188                 &&  g_iCaretSection == CARET_SECTION_PLAINTEXT
00189                 &&  g_iCurChar >= iFirst
00190                 &&  g_iCurChar <= iFirst+iLen)
00191             {
00192                 // Display caret at coordinate corresponding to g_iCurChar
00193                 g_fUpdateCaret = FALSE;
00194                 if (g_iCurChar < iFirst + iLen)
00195                 {
00196                     ScriptStringCPtoX(ssa, g_iCurChar - iFirst, FALSE, &g_iCaretX);
00197                 }
00198                 else
00199                 {
00200                     // represent end of line position by placing caret at right edge
00201                     g_iCaretX = ScriptString_pSize(ssa)->cx;
00202                 }
00203
00204                 ResetCaret(prc->left + g_iCaretX, *piY, iLineHeight);
00205             }
00206
00207             // Show clipping boundary
00208             if (dwFlags & (SSA_FIT | SSA_CLIP))
00209             {
00210                 TEXTMETRIC tma = {0};
00211                 GetTextMetrics(hdc, &tma);
00212
00213                 MoveToEx(hdc, iX-1, *piY, NULL);
00214                 LineTo(hdc,   iX-1, *piY + tma.tmAscent + tma.tmDescent);
00215
00216                 MoveToEx(hdc, iX + iClipWidth, *piY, NULL);
00217                 LineTo(hdc,   iX + iClipWidth, *piY + tma.tmAscent + tma.tmDescent);
00218
00219                 MoveToEx(hdc, iX,              *piY-1, NULL);
00220                 LineTo  (hdc, iX + iClipWidth, *piY-1);
00221
00222                 MoveToEx(hdc, iX,              *piY + tma.tmAscent, NULL);
00223                 LineTo  (hdc, iX + iClipWidth, *piY + tma.tmAscent);
00224
00225                 MoveToEx(hdc, iX,              *piY + tma.tmAscent + tma.tmDescent, NULL);
00226                 LineTo  (hdc, iX + iClipWidth, *piY + tma.tmAscent + tma.tmDescent);
00227             }
00228
00229             ScriptStringFree(&ssa);
00230         }
00231     }
00232     else
00233     {
00234         // Although the line is empty we may still need to display the caret
00235         if (    g_fUpdateCaret
00236             &&  g_iCaretSection == CARET_SECTION_PLAINTEXT
00237             &&  g_iCurChar == iFirst)
00238         {
00239             g_fUpdateCaret = FALSE;
00240             ResetCaret(prc->left, *piY, iLineHeight);
00241         }
00242     }
00243
00244     *piY += iLineHeight;
00245 }
00246
00247 ////    PaintPlainText - Demonstrate ScriptString APIs
00248 //
00249 //
00250 void PaintPlainText(
00251     HDC      hdc,
00252     int     *piY,
00253     RECT    *prc,
00254     int      iLineHeight)
00255 {
00256     int      icpLineStart = 0;     // First character of line
00257     int      icpLineEnd   = 0;       // End of line (end of buffer or index of CR character)
00258     HFONT    hFont        = NULL;
00259     HFONT    hOldFont     = NULL;
00260     LOGFONT  lf           = {0};
00261
00262     icpLineStart = 0;
00263
00264     if (    g_fPresentation
00265         &&  GetObject(g_style[0].hf, sizeof(lf), &lf))
00266     {
00267         // Select font using the entire line height
00268         hFont = CreateFont(
00269             iLineHeight,
00270             0, 0, 0,
00271             lf.lfWeight,
00272             lf.lfItalic,
00273             lf.lfUnderline,
00274             lf.lfStrikeOut,
00275             lf.lfCharSet,
00276             OUT_DEFAULT_PRECIS,
00277             CLIP_DEFAULT_PRECIS,
00278             DEFAULT_QUALITY,
00279             FF_DONTCARE|DEFAULT_PITCH,
00280             lf.lfFaceName);
00281         hOldFont = (HFONT) SelectObject(hdc, hFont);
00282     }
00283     else
00284     {
00285         // Select users font
00286         hOldFont = (HFONT) SelectObject(hdc, g_style[0].hf);
00287     }
00288
00289     // Display line by line
00290     while (icpLineStart < g_iTextLen)
00291     {
00292         // Find end of line or end of buffer
00293         icpLineEnd = icpLineStart;
00294         while (icpLineEnd < g_iTextLen  &&  g_wcBuf[icpLineEnd] != 0x0D)
00295         {
00296             icpLineEnd++;
00297         }
00298
00299         PaintPlainTextLine(
00300             hdc,
00301             piY,
00302             prc,
00303             icpLineStart,
00304             icpLineEnd-icpLineStart,
00305             iLineHeight);
00306
00307         if (g_fPresentation)
00308         {
00309             // Display only one line in presentation mode
00310             icpLineStart = g_iTextLen;
00311         }
00312         else
00313         {
00314             // Advance to next line
00315             if (icpLineEnd < g_iTextLen)
00316             {
00317                 icpLineEnd++;
00318             }
00319             if (icpLineEnd < g_iTextLen  &&  g_wcBuf[icpLineEnd] == 0x0A)
00320             {
00321                 icpLineEnd++;
00322             }
00323             icpLineStart = icpLineEnd;
00324         }
00325     }
00326
00327     if (g_fPresentation)
00328     {
00329         SelectObject(hdc, hOldFont);
00330     }
00331 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/dxtrans/dxsurf2/resource.h Source File

  • Web
  • dxtrans
  • dxsurf2

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by dxsurf2.rc
00004 //
00005 #define IDI_DXTICON                     101
00006
00007 // Next default values for new objects
00008 //
00009 #ifdef APSTUDIO_INVOKED
00010 #ifndef APSTUDIO_READONLY_SYMBOLS
00011 #define _APS_NEXT_RESOURCE_VALUE        103
00012 #define _APS_NEXT_COMMAND_VALUE         40003
00013 #define _APS_NEXT_CONTROL_VALUE         1000
00014 #define _APS_NEXT_SYMED_VALUE           101
00015 #endif
00016 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/about.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

about.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));;
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163         MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164         *lpDest = wszStr;
00165
00166
00167     return S_OK;
00168 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/comp.h Source File

  • SysMgmt
  • MMC
  • Simple

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent
00025 {
00026 private:
00027     ULONG       m_cref;
00028
00029     IConsole*     m_ipConsole;
00030
00031     class CComponentData *m_pComponentData;
00032
00033     public:
00034         CComponent(CComponentData *parent);
00035         ~CComponent();
00036
00037         ///////////////////////////////
00038         // Interface IUnknown
00039         ///////////////////////////////
00040         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00041         STDMETHODIMP_(ULONG) AddRef();
00042         STDMETHODIMP_(ULONG) Release();
00043
00044         ///////////////////////////////
00045         // Interface IComponent
00046         ///////////////////////////////
00047         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00048             /* [in] */ LPCONSOLE lpConsole);
00049
00050             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00051             /* [in] */ LPDATAOBJECT lpDataObject,
00052             /* [in] */ MMC_NOTIFY_TYPE event,
00053             /* [in] */ LPARAM arg,
00054             /* [in] */ LPARAM param);
00055
00056             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00057             /* [in] */ MMC_COOKIE cookie);
00058
00059             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00060             /* [in] */ MMC_COOKIE cookie,
00061             /* [in] */ DATA_OBJECT_TYPES type,
00062             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00063
00064             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00065             /* [in] */ MMC_COOKIE cookie,
00066             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00067             /* [out] */ long __RPC_FAR *pViewOptions);
00068
00069             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00070             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00071
00072             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00073             /* [in] */ LPDATAOBJECT lpDataObjectA,
00074             /* [in] */ LPDATAOBJECT lpDataObjectB);
00075 };
00076
00077 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

InkClipboard::InkClipboard Member List

This is the complete list of members for InkClipboard::InkClipboard, including all inherited members.
applicationMode | InkClipboard::InkClipboard | [private]
centerBottomHandle | InkClipboard::InkClipboard | [private]
centerTopHandle | InkClipboard::InkClipboard | [private]
components | InkClipboard::InkClipboard | [private]
connectorColor | InkClipboard::InkClipboard | [private]
connectorPen | InkClipboard::InkClipboard | [private]
CopyInkToClipboard(InkClipboardModes clipboardModes) | InkClipboard::InkClipboard | [inline, private]
Dispose(bool disposing) | InkClipboard::InkClipboard | [inline, protected]
dotColor | InkClipboard::InkClipboard | [private]
dotEdgeColor | InkClipboard::InkClipboard | [private]
dotEdgePen | InkClipboard::InkClipboard | [private]
dotPen | InkClipboard::InkClipboard | [private]
DotSize | InkClipboard::InkClipboard | [private]
DotSpacing | InkClipboard::InkClipboard | [private]
DrawLasso(Graphics g, int newPacketIndex) | InkClipboard::InkClipboard | [inline]
DrawLassoConnector(int start, int end) | InkClipboard::InkClipboard | [inline, private]
DrawSelectionInkDot(Graphics g, int x, int y) | InkClipboard::InkClipboard | [inline, private]
DrawStrokes(Graphics g) | InkClipboard::InkClipboard | [inline, private]
HasSelection() | InkClipboard::InkClipboard | [inline]
InitializeComponent() | InkClipboard::InkClipboard | [inline, private]
InkClipboard() | InkClipboard::InkClipboard | [inline]
InkClipboard_Load(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
InkClipboard_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) | InkClipboard::InkClipboard | [inline, private]
InkClipboard_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) | InkClipboard::InkClipboard | [inline, private]
InkClipboard_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) | InkClipboard::InkClipboard | [inline, private]
InkClipboard_Paint(object sender, System.Windows.Forms.PaintEventArgs e) | InkClipboard::InkClipboard | [inline, private]
InkSpaceToPixel(Graphics g, ref Rectangle r) | InkClipboard::InkClipboard | [inline, private]
LassoPercent | InkClipboard::InkClipboard | [private]
lassoPoints | InkClipboard::InkClipboard | [private]
lastDrawnLassoDot | InkClipboard::InkClipboard | [private]
leftBottomHandle | InkClipboard::InkClipboard | [private]
leftCenterHandle | InkClipboard::InkClipboard | [private]
leftTopHandle | InkClipboard::InkClipboard | [private]
Main() | InkClipboard::InkClipboard | [inline, private, static]
mainMenu | InkClipboard::InkClipboard | [private]
MediumInkWidth | InkClipboard::InkClipboard | [private]
miBlack | InkClipboard::InkClipboard | [private]
miBlack_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miBlue | InkClipboard::InkClipboard | [private]
miBlue_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miBMP | InkClipboard::InkClipboard | [private]
miBMP_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miClear | InkClipboard::InkClipboard | [private]
miClear_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miColor | InkClipboard::InkClipboard | [private]
miCopy | InkClipboard::InkClipboard | [private]
miCopy_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miCut | InkClipboard::InkClipboard | [private]
miCut_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miEditSeparator | InkClipboard::InkClipboard | [private]
miEMF | InkClipboard::InkClipboard | [private]
miEMF_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miExit | InkClipboard::InkClipboard | [private]
miExit_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miFormatSeparator | InkClipboard::InkClipboard | [private]
miGreen | InkClipboard::InkClipboard | [private]
miGreen_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miInk | InkClipboard::InkClipboard | [private]
miInk_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miInkSeparator | InkClipboard::InkClipboard | [private]
miISF | InkClipboard::InkClipboard | [private]
miISF_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miLassoSelect | InkClipboard::InkClipboard | [private]
miLassoSelect_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miMainAction | InkClipboard::InkClipboard | [private]
miMainEdit | InkClipboard::InkClipboard | [private]
miMainEdit_Popup(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miMainFormat | InkClipboard::InkClipboard | [private]
miMedium | InkClipboard::InkClipboard | [private]
miMedium_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miMetafile | InkClipboard::InkClipboard | [private]
miMetafile_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miNoOLE | InkClipboard::InkClipboard | [private]
miNoOLE_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miPaste | InkClipboard::InkClipboard | [private]
miPaste_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miRed | InkClipboard::InkClipboard | [private]
miRed_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miSInk | InkClipboard::InkClipboard | [private]
miSInk_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miStyle | InkClipboard::InkClipboard | [private]
miThick | InkClipboard::InkClipboard | [private]
miThick_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miThin | InkClipboard::InkClipboard | [private]
miThin_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miTInk | InkClipboard::InkClipboard | [private]
miTInk_Click(object sender, System.EventArgs e) | InkClipboard::InkClipboard | [inline, private]
miWidth | InkClipboard::InkClipboard | [private]
myInkCollector | InkClipboard::InkClipboard | [private]
myInkCollector_NewPackets(object sender, InkCollectorNewPacketsEventArgs e) | InkClipboard::InkClipboard | [inline, private]
myInkCollector_Stroke(object sender, InkCollectorStrokeEventArgs e) | InkClipboard::InkClipboard | [inline, private]
PixelToInkSpace(Graphics g, ref Rectangle r) | InkClipboard::InkClipboard | [inline, private]
rightBottomHandle | InkClipboard::InkClipboard | [private]
rightCenterHandle | InkClipboard::InkClipboard | [private]
rightTopHandle | InkClipboard::InkClipboard | [private]
SelectedInkWidthIncrease | InkClipboard::InkClipboard | [private]
selectedStrokes | InkClipboard::InkClipboard | [private]
selectionHandles | InkClipboard::InkClipboard | [private]
selectionRect | InkClipboard::InkClipboard | [private]
SelectionRectBuffer | InkClipboard::InkClipboard | [private]
SetColor(Color newColor) | InkClipboard::InkClipboard | [inline, private]
SetLocation(PictureBox pb, int xCenter, int yCenter) | InkClipboard::InkClipboard | [inline]
SetSelection(Strokes strokes) | InkClipboard::InkClipboard | [inline, private]
SetWidth(float newWidth) | InkClipboard::InkClipboard | [inline, private]
startMoveLocation | InkClipboard::InkClipboard | [private]
ThickInkWidth | InkClipboard::InkClipboard | [private]
ThinInkWidth | InkClipboard::InkClipboard | [private]
XPacketIndex | InkClipboard::InkClipboard | [private]
YPacketIndex | InkClipboard::InkClipboard | [private]
Generated on Wed Nov 13 2024 16:58:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/dataobj.h Source File

  • SysMgmt
  • MMC
  • Menubtn

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/TextSid/TextSid.c Source File

  • Security
  • Authorization
  • TextSid

TextSid.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2002.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011     textsid.c
00012
00013 Abstract:
00014
00015     This module illustrates how to obtain the textual representation
00016     of a binary Sid.  This is useful in scenarios where it is not appropriate
00017     to obtain the name associated with the Sid, or, when the network is not
00018     available to obtain such information.  The Windows NT event viewer
00019     utility displays Sids in textual form when the username cannot be
00020     looked up.  Furthermore, lookup of local user profiles is facilitated
00021     through conversion of the user Sid to textual form.
00022
00023     This sample obtains the Sid of the current user and then displays the
00024     Sid in textual notation.
00025
00026     A standardized shorthand notation for SIDs makes it simpler to
00027     visualize their components:
00028
00029     S-R-I-S-S...
00030
00031     In the notation shown above,
00032
00033     S identifies the series of digits as an SID,
00034     R is the revision level,
00035     I is the identifier-authority value,
00036     S is subauthority value(s).
00037
00038     An SID could be written in this notation as follows:
00039     S-1-5-32-544
00040
00041     In this example,
00042     the SID has a revision level of 1,
00043     an identifier-authority value of 5,
00044     first subauthority value of 32,
00045     second subauthority value of 544.
00046     (Note that the above Sid represents the local Administrators group)
00047
00048     The GetTextualSid() function will convert a binary Sid to a textual
00049     string.
00050
00051     The resulting string will take one of two forms.  If the
00052     IdentifierAuthority value is not greater than 2^32, then the SID
00053     will be in the form:
00054
00055     S-1-5-21-2127521184-1604012920-1887927527-19009
00056       ^ ^ ^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^
00057       | | |      |          |          |        |
00058       +-+-+------+----------+----------+--------+--- Decimal
00059
00060     Otherwise it will take the form:
00061
00062     S-1-0x206C277C6666-21-2127521184-1604012920-1887927527-19009
00063       ^ ^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^
00064       |       |        |      |          |          |        |
00065       |   Hexidecimal  |      |          |          |        |
00066       +----------------+------+----------+----------+--------+--- Decimal
00067
00068     If the function succeeds, the return value is TRUE.
00069     If the function fails, the return value is FALSE.  To get extended
00070         error information, call the Win32 API GetLastError().
00071
00072 --*/
00073
00074 #define RTN_OK 0
00075 #define RTN_ERROR 13
00076
00077 #include <windows.h>
00078 #include <stdio.h>
00079 #include <tchar.h>
00080 #include <shlwapi.h>
00081
00082
00083 BOOL
00084 GetTextualSid(
00085     PSID pSid,          // binary Sid
00086     LPTSTR TextualSID,  // buffer for Textual representaion of Sid
00087     LPDWORD cchSidSize  // required/provided TextualSid buffersize
00088     );
00089
00090 void
00091 DisplayWinError(
00092     LPSTR szAPI,    // pointer to Ansi function name
00093     DWORD dwError   // DWORD WinError
00094     );
00095
00096
00097 int
00098 __cdecl
00099 main(
00100     void
00101     )
00102 {
00103 #define MY_BUFSIZE 256 // all allocations should be dynamic
00104     HANDLE hToken;
00105     BYTE buf[MY_BUFSIZE];
00106     PTOKEN_USER ptgUser = (PTOKEN_USER)buf;
00107     DWORD cbBuffer=MY_BUFSIZE;
00108
00109     TCHAR szTextualSid[MY_BUFSIZE];
00110     DWORD cchSid=MY_BUFSIZE;
00111
00112     BOOL bSuccess;
00113
00114     //
00115     // obtain current process token
00116     //
00117     if(!OpenProcessToken(
00118                 GetCurrentProcess(), // target current process
00119                 TOKEN_QUERY,         // TOKEN_QUERY access
00120                 &hToken              // resultant hToken
00121                 ))
00122     {
00123         DisplayWinError( TEXT("OpenProcessToken"), GetLastError() );
00124         return RTN_ERROR;
00125     }
00126
00127     //
00128     // obtain user identified by current process' access token
00129     //
00130     bSuccess = GetTokenInformation(
00131                 hToken,    // identifies access token
00132                 TokenUser, // TokenUser info type
00133                 ptgUser,   // retrieved info buffer
00134                 cbBuffer,  // size of buffer passed-in
00135                 &cbBuffer  // required buffer size
00136                 );
00137
00138     // close token handle.  do this even if error above
00139     CloseHandle(hToken);
00140
00141     if(!bSuccess) {
00142         DisplayWinError( TEXT("GetTokenInformation"), GetLastError() );
00143         return RTN_ERROR;
00144     }
00145
00146     //
00147     // obtain the textual representaion of the Sid
00148     //
00149     if(!GetTextualSid(
00150                 ptgUser->User.Sid, // user binary Sid
00151                 szTextualSid,      // buffer for TextualSid
00152                 &cchSid            // size/required buffer
00153                 )) {
00154         DisplayWinError( TEXT("GetTextualSid"), GetLastError() );
00155         return RTN_ERROR;
00156     }
00157
00158     // display the TextualSid representation
00159     _tprintf( TEXT("Process Sid: %s\n"), szTextualSid );
00160
00161     return RTN_OK;
00162 }
00163
00164
00165 BOOL
00166 GetTextualSid(
00167     PSID pSid,          // binary Sid
00168     LPTSTR TextualSid,  // buffer for Textual representaion of Sid
00169     LPDWORD cchSidSize  // required/provided TextualSid buffersize in TCHARs
00170     )
00171 {
00172     PSID_IDENTIFIER_AUTHORITY psia;
00173     DWORD dwSubAuthorities;
00174     DWORD dwCounter;
00175     DWORD cchSidCopy;
00176     DWORD cchMaxLen;
00177
00178     //
00179     // test if parameters passed in are valid, IsValidSid can not take
00180     // a NULL parameter
00181     //
00182     if(!pSid || !IsValidSid(pSid) || !TextualSid || !cchSidSize)
00183     {
00184         SetLastError(ERROR_INVALID_PARAMETER);
00185         return FALSE;
00186     }
00187
00188     // obtain SidIdentifierAuthority
00189     psia = GetSidIdentifierAuthority(pSid);
00190
00191     // obtain sidsubauthority count
00192     dwSubAuthorities = *GetSidSubAuthorityCount(pSid);
00193
00194     //
00195     // compute approximate buffer length
00196     // S-SID_REVISION- + identifierauthority + -subauthorities + NULL
00197     //
00198     cchMaxLen = 6 + 14 + (11 * dwSubAuthorities) + 1;
00199
00200     //
00201     // check provided buffer length.
00202     // If not large enough, indicate proper size and setlasterror
00203     //
00204     if(*cchSidSize < cchMaxLen) {
00205         *cchSidSize = cchMaxLen;
00206         SetLastError(ERROR_INSUFFICIENT_BUFFER);
00207         return FALSE;
00208     }
00209
00210     //
00211     // prepare S-SID_REVISION-
00212     //
00213     cchSidCopy = wnsprintf(TextualSid,
00214                            cchMaxLen,
00215                            TEXT("S-%lu-"),
00216                            SID_REVISION );
00217
00218     //
00219     // prepare SidIdentifierAuthority
00220     //
00221     if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) ) {
00222         cchSidCopy += wnsprintf(TextualSid + cchSidCopy,
00223                     cchMaxLen - cchSidCopy,
00224                     TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
00225                     (USHORT)psia->Value[0],
00226                     (USHORT)psia->Value[1],
00227                     (USHORT)psia->Value[2],
00228                     (USHORT)psia->Value[3],
00229                     (USHORT)psia->Value[4],
00230                     (USHORT)psia->Value[5]);
00231     } else {
00232         cchSidCopy += wnsprintf(TextualSid + cchSidCopy,
00233                     cchMaxLen - cchSidCopy,
00234                     TEXT("%lu"),
00235                     (ULONG)(psia->Value[5]      )   +
00236                     (ULONG)(psia->Value[4] <<  8)   +
00237                     (ULONG)(psia->Value[3] << 16)   +
00238                     (ULONG)(psia->Value[2] << 24)   );
00239     }
00240
00241     //
00242     // loop through SidSubAuthorities
00243     //
00244     for(dwCounter = 0 ; dwCounter < dwSubAuthorities ; dwCounter++) {
00245         cchSidCopy += wnsprintf(TextualSid + cchSidCopy,
00246                     cchMaxLen - cchSidCopy,
00247                     TEXT("-%lu"),
00248                     *GetSidSubAuthority(pSid, dwCounter) );
00249     }
00250
00251     //
00252     // tell the caller how many chars we provided, not including NULL
00253     //
00254     *cchSidSize = cchSidCopy;
00255
00256     return TRUE;
00257 }
00258
00259
00260 void
00261 DisplayWinError(
00262     LPTSTR szAPI,   // pointer to function name
00263     DWORD dwError   // DWORD WinError
00264     )
00265 {
00266     LPTSTR MessageBuffer;
00267     DWORD dwBufferLength;
00268
00269     if( szAPI )
00270     {
00271         _ftprintf( stderr, TEXT("Error in %s\n"), szAPI );
00272     }
00273
00274     dwBufferLength = FormatMessage(
00275             FORMAT_MESSAGE_ALLOCATE_BUFFER |
00276             FORMAT_MESSAGE_FROM_SYSTEM,
00277             NULL,
00278             dwError,
00279             MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00280             (LPTSTR) &MessageBuffer,
00281             0,
00282             NULL
00283             );
00284     if( dwBufferLength )
00285     {
00286         //
00287         // Output message string on stderr
00288         //
00289         _ftprintf( stderr, TEXT("%s"), MessageBuffer );
00290
00291         //
00292         // free the buffer allocated by the system
00293         //
00294         LocalFree(MessageBuffer);
00295     }
00296 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/globals.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

globals.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module GLOBALS.CPP | Global Initialization Object..
00008 //
00009 //
00010
00011 //  Make sure constants get initialized
00012 #define INITGUID
00013 #define DBINITCONSTANTS
00014
00015 // Includes ------------------------------------------------------------------
00016 #include "headers.h"
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinNT/PlgBlt/PlgBlt.c Source File

  • Multimedia
  • Gdi
  • WinNT
  • PlgBlt

PlgBlt.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1992 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /**************************************************************************\
00013 *  plgblt.c -- sample program demonstrating the new PlgBlt() API.
00014 *
00015 *  design:  There is one main window with one dialog box stretched to fill
00016 *   the top of it.  The parameters for the plgblt painted into the main
00017 *   window are stored in the entry fields of this dialog box.  The user
00018 *   may change these values and see the effect on the blt.
00019 \**************************************************************************/
00020
00021 #include <windows.h>
00022 #include <commdlg.h>
00023 #include <math.h>
00024 #include <stdio.h>
00025 #include "plgblt.h"
00026 #include "track.h"
00027 #include "bitmap.h"
00028
00029
00030
00031 /* global variables. */
00032 PTrackObject ptoDest, ptoSrc, ptoMask = NULL;
00033 HDC          hdcDest, hdcSrc, hdcMask;
00034 HBITMAP               hbmSrc, hbmMask = NULL;
00035
00036 HANDLE hInst;
00037 HWND   hwndMain, hwndDlg;
00038
00039 int nSpin;
00040
00041
00042 #define  BACKGROUNDBRUSH GetStockObject(LTGRAY_BRUSH)
00043
00044
00045
00046 /**************************************************************************\
00047 *
00048 *  function:  WinMain()
00049 *
00050 *  input parameters:  c.f. generic sample
00051 *
00052 \**************************************************************************/
00053 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00054                      LPSTR lpCmdLine, int nCmdShow)
00055 {
00056     MSG   msg;
00057     RECT rect;
00058     HANDLE haccel;
00059
00060     UNREFERENCED_PARAMETER( lpCmdLine );
00061
00062
00063     //
00064     // Detect platform and exit gracefully if not Windows NT.
00065     //
00066
00067     {
00068       OSVERSIONINFO osvi;
00069       osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
00070
00071       GetVersionEx (&osvi);
00072       if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) {
00073         MessageBox (NULL,
00074           GetStringRes (IDS_NTONLY),
00075           "PlgBlt", MB_OK | MB_ICONSTOP);
00076         return 0;
00077       }
00078     }
00079
00080
00081     /* Check for previous instance.  If none, then register class. */
00082     if (!hPrevInstance) {
00083         WNDCLASS  wc;
00084
00085         wc.style = 0;
00086         wc.lpfnWndProc = (WNDPROC)MainWndProc;
00087
00088         wc.cbClsExtra = 0;
00089         wc.cbWndExtra = 0;
00090         wc.hInstance = hInstance;
00091         wc.hIcon = LoadIcon(hInstance, "plgbltIcon");
00092         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00093         wc.hbrBackground = BACKGROUNDBRUSH;
00094         wc.lpszMenuName =  "plgbltMenu";
00095         wc.lpszClassName = "plgblt";
00096
00097         if (!RegisterClass(&wc)) return (FALSE);
00098     }  /* class registered o.k. */
00099
00100
00101     /* Create the main window.  Return false if CreateWindow() fails */
00102     hInst = hInstance;
00103
00104     hwndMain = CreateWindow(
00105         "plgblt",
00106         GetStringRes (IDS_WINDOWTITLE),
00107         WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
00108         CW_USEDEFAULT,
00109         CW_USEDEFAULT,
00110         CW_USEDEFAULT,
00111         CW_USEDEFAULT,
00112         NULL,
00113         NULL,
00114         hInstance,
00115         NULL);
00116
00117     if (!hwndMain) return (FALSE);
00118
00119
00120     /* create the top dialog as a child of the main window. */
00121     hwndDlg = CreateDialog (hInst, "plgbltDlg", hwndMain, (DLGPROC)DlgProc);
00122
00123     /* Send main window a WM_SIZE message so that it will size the top
00124      *  dialog correctly.
00125      */
00126     GetClientRect (hwndMain, &rect);
00127     SendMessage (hwndMain, WM_SIZE, 0, (rect.right - rect.left));
00128     ShowWindow (hwndDlg, SW_SHOW);
00129     ShowWindow(hwndMain, nCmdShow);
00130
00131
00132     /* get global handle to the menu */
00133
00134     /* Load the accelerator table that provides clipboard support. */
00135     haccel = LoadAccelerators (hInst, "bltAccel");
00136
00137
00138
00139     /* Loop getting messages and dispatching them. */
00140     while (GetMessage(&msg,NULL, 0,0)) {
00141       if (!TranslateAccelerator(hwndMain, haccel, &msg))
00142       if (!IsDialogMessage (hwndDlg, &msg)){
00143         DispatchMessage(&msg);
00144       }
00145
00146       /* if no messages, and we are spinning, then post spin message. */
00147       if (!PeekMessage (&msg, hwndMain, 0,0, PM_NOREMOVE) && nSpin)
00148         PostMessage (hwndMain, WM_SPIN, 0,0);
00149     }
00150
00151     /* Return the value from PostQuitMessage */
00152     return (int)(msg.wParam);
00153 }
00154
00155
00156
00157
00158 /**************************************************************************\
00159 *
00160 *  function:  MainWndProc()
00161 *
00162 *  input parameters:  normal window procedure parameters.
00163 *
00164 *  There are 6 different HDCs used for the main window (in addition to the
00165 *   temporary one returned from BeginPaint).  There are two for each of the
00166 *   three thirds of the window.  The first one contains the bitmap.  The
00167 *   second one is for the track object and is stored in the TRACKOBJECT
00168 *   structure.
00169 *
00170 *  global variables:
00171 *   hwndDlg - dialog with entry fields containing parameters.
00172 *   ptoDest, ptoSrc, ptoMask - pointers to the direct manipulation objects
00173 *   hdcDest, hdcSrc, hdcMask - HDCs for the 3 sub regions of the window.
00174 *   hbmSrc, hbmMask          - bitmap handles for source and mask.
00175 \**************************************************************************/
00176 LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00177 {
00178 static int miniWidth;
00179 static RECT rect;
00180 static HANDLE hPenGrid, hPenSeparator;
00181
00182   switch (message) {
00183
00184     /**********************************************************************\
00185     *  WM_CREATE
00186     *
00187     * Get three new HDCs, then create three new track objects.
00188     *  Each track object has different allowed tracking modes.
00189     *  Finally create two pens for drawing later on.
00190     \**********************************************************************/
00191     case WM_CREATE:
00192         hdcSrc  = GetDC (hwnd);
00193         hdcDest = GetDC (hwnd);
00194         hdcMask = GetDC (hwnd);
00195
00196         ptoDest = doTrackObject (NULL, TROB_NEW, hwnd,0);
00197         ptoDest->allowedModes = TMALL;
00198         ptoSrc  = doTrackObject (NULL, TROB_NEW, hwnd,0);
00199         ptoSrc->allowedModes = TMMOVE | TMSIZEXY;
00200         ptoMask = doTrackObject (NULL, TROB_NEW, hwnd,0);
00201         ptoMask->allowedModes = TMMOVE;
00202
00203         hPenGrid      = CreatePen (PS_SOLID, 1, GRIDCOLOR);
00204         hPenSeparator = CreatePen (PS_SOLID, 2*SEPARATORWIDTH, (COLORREF) 0x01000000);
00205
00206         { HMENU hMenu;
00207         hMenu = GetMenu (hwnd);
00208         CheckMenuItem(hMenu, IDM_SPINTOPLEFT, MF_CHECKED);
00209         CheckMenuItem(hMenu, IDM_SPINOFF    , MF_CHECKED);
00210         nSpin = FALSE;
00211         }
00212
00213     break;
00214
00215
00216     /**********************************************************************\
00217     *  WM_DESTROY
00218     *
00219     * Complement of WM_CREATE.  Free up all of the HDCs, send all of the
00220     *  track objects their delete messages, delete the pens,
00221     *  then call PostQuitMessage.
00222     \**********************************************************************/
00223     case WM_DESTROY:
00224         ReleaseDC (hwnd, hdcSrc );
00225         ReleaseDC (hwnd, hdcDest);
00226         ReleaseDC (hwnd, hdcMask);
00227         doTrackObject (ptoDest, TROB_DELETE, hwnd,0);
00228         doTrackObject (ptoSrc , TROB_DELETE, hwnd,0);
00229         doTrackObject (ptoMask, TROB_DELETE, hwnd,0);
00230
00231         DeleteObject(hPenGrid);
00232         DeleteObject(hPenSeparator);
00233
00234         PostQuitMessage(0);
00235     break;
00236
00237
00238
00239     /**********************************************************************\
00240     *  WM_SIZE
00241     *
00242     * Stretch the top dialog to fill the width of the main window.
00243     * Adjust the viewport origins of the 6 HDCs.
00244     * Set the clip regions of the 6 HDCs.
00245     \**********************************************************************/
00246     case WM_SIZE: {
00247         HRGN hrgn;
00248
00249         SetWindowPos (hwndDlg, NULL, 0,0, LOWORD(lParam), DIALOGHEIGHT, 0);
00250
00251         GetClientRect (hwndMain, &rect);
00252         miniWidth = rect.right/3;
00253
00254         SetViewportOrgEx (hdcDest,      0,           DIALOGHEIGHT, NULL);
00255         SetViewportOrgEx (ptoDest->hdc, 0,           DIALOGHEIGHT, NULL);
00256         SetViewportOrgEx (hdcSrc,       miniWidth,   DIALOGHEIGHT, NULL);
00257         SetViewportOrgEx (ptoSrc->hdc,  miniWidth,   DIALOGHEIGHT, NULL);
00258         SetViewportOrgEx (hdcMask,      2*miniWidth, DIALOGHEIGHT, NULL);
00259         SetViewportOrgEx (ptoMask->hdc, 2*miniWidth, DIALOGHEIGHT, NULL);
00260
00261         ptoDest->rectClip.left    = 0;
00262         ptoDest->rectClip.top     = DIALOGHEIGHT;
00263         ptoDest->rectClip.right   = miniWidth-2*SEPARATORWIDTH;
00264         ptoDest->rectClip.bottom  = rect.bottom;
00265         hrgn = CreateRectRgnIndirect (&ptoDest->rectClip);
00266         SelectClipRgn (hdcDest,      hrgn);
00267         SelectClipRgn (ptoDest->hdc, hrgn);
00268         DeleteObject (hrgn);
00269
00270         ptoSrc->rectClip.left    = miniWidth;
00271         ptoSrc->rectClip.top     = DIALOGHEIGHT;
00272         ptoSrc->rectClip.right   = 2*miniWidth-2*SEPARATORWIDTH;
00273         ptoSrc->rectClip.bottom  = rect.bottom;
00274         hrgn = CreateRectRgnIndirect (&ptoSrc->rectClip);
00275         SelectClipRgn (hdcSrc,       hrgn);
00276         SelectClipRgn (ptoSrc->hdc,  hrgn);
00277         DeleteObject (hrgn);
00278
00279         ptoMask->rectClip.left    = 2*miniWidth;
00280         ptoMask->rectClip.top     = DIALOGHEIGHT;
00281         ptoMask->rectClip.right   = 3*miniWidth;
00282         ptoMask->rectClip.bottom  = rect.bottom;
00283         hrgn = CreateRectRgnIndirect (&ptoMask->rectClip);
00284         SelectClipRgn (hdcMask,      hrgn);
00285         SelectClipRgn (ptoMask->hdc, hrgn);
00286         DeleteObject (hrgn);
00287
00288         SendMessage (hwndDlg, WM_PUTUPLPOINTS, (DWORD_PTR)hdcDest, (LONG_PTR)ptoDest);
00289         SendMessage (hwndDlg, WM_PUTUPSRCRECT, (DWORD_PTR)hdcSrc,  (LONG_PTR)ptoSrc);
00290         SendMessage (hwndDlg, WM_PUTUPMASKPT,  (DWORD_PTR)hdcMask, (LONG_PTR)ptoMask);
00291
00292         /* repaint the whole window. */
00293         InvalidateRect (hwnd, NULL, TRUE);
00294     } break;
00295
00296
00297
00298     /**********************************************************************\
00299     *  WM_PAINT
00300     *
00301     * miniWidth, rect -- set by WM_SIZE message.
00302     *
00303     * First shift the viewport origin down so that 0,0 is the top left
00304     *  most visible point (out from underneath the top dialog).  Second,
00305     *  draw the grid with wider lines on the axes.  Finally, read the
00306     *  values out of the top dialog, do elementary validation, and then
00307     *  try to call plgblt() with the values.
00308     \**********************************************************************/
00309      case WM_PAINT: {
00310         HDC hdc;
00311         PAINTSTRUCT ps;
00312
00313         hdc = BeginPaint(hwnd, &ps);
00314
00315         /* Draw Separator lines for the three miniareas */
00316         SelectObject(hdc, hPenSeparator);
00317         MoveToEx (hdc,   miniWidth-SEPARATORWIDTH,0, NULL);
00318         LineTo   (hdc,   miniWidth-SEPARATORWIDTH, rect.bottom);
00319         MoveToEx (hdc, 2*miniWidth-SEPARATORWIDTH,0, NULL);
00320         LineTo   (hdc, 2*miniWidth-SEPARATORWIDTH, rect.bottom);
00321
00322         /* Grid the HDCs */
00323         SelectObject(hdcSrc, hPenGrid);
00324         DrawGrids (hdcSrc, miniWidth, rect.bottom);
00325         SelectObject(hdcMask, hPenGrid);
00326         DrawGrids (hdcMask, miniWidth, rect.bottom);
00327
00328         /* Draw bitmaps if any, then draw track objects over them. */
00329         if (hbmSrc)  DrawBitmap (hdcSrc, hbmSrc);
00330         if (hbmMask) DrawBitmap (hdcMask, hbmMask);
00331         doTrackObject (ptoSrc , TROB_PAINT, hwnd, 0);
00332         doTrackObject (ptoMask, TROB_PAINT, hwnd, 0);
00333
00334         /* paint the left third of the window. */
00335         SendMessage (hwnd, WM_PLGBLT, 0,0);
00336
00337         EndPaint (hwnd, &ps);
00338     } return FALSE;
00339
00340
00341
00342     /**********************************************************************\
00343     *  WM_PLGBLT
00344     *
00345     * WM_USER message.  This paints the left third of the window.  It
00346     *  is called on the WM_PAINT message.  It is separated out here because
00347     *  it is common for just the plgblt() to need to be called and not the
00348     *  whole window painted.
00349     \**********************************************************************/
00350     case WM_PLGBLT: {
00351         POINT lpPoint[3];
00352         int XSrc, YSrc, nWidth, nHeight, XMask, YMask;
00353         BOOL success;
00354         RECT cliprect;
00355
00356         doTrackObject (ptoSrc , TROB_PAINT, hwnd, 0);
00357         doTrackObject (ptoMask, TROB_PAINT, hwnd, 0);
00358
00359         GetClipBox (hdcDest, &cliprect);
00360         FillRect (hdcDest, &cliprect,
00361                   (HBRUSH) GetClassLongPtr (hwnd, GCLP_HBRBACKGROUND));
00362         SelectObject(hdcDest, hPenGrid);
00363
00364         DrawGrids (hdcDest, miniWidth, rect.bottom);
00365         if (IsWindow(hwndDlg)) {
00366
00367           /* Grab points out of the dialog entry fields. */
00368           lpPoint[0].x = GetDlgItemInt(hwndDlg, DID_P1X, &success, TRUE);
00369           lpPoint[0].y = GetDlgItemInt(hwndDlg, DID_P1Y, &success, TRUE);
00370           lpPoint[1].x = GetDlgItemInt(hwndDlg, DID_P2X, &success, TRUE);
00371           lpPoint[1].y = GetDlgItemInt(hwndDlg, DID_P2Y, &success, TRUE);
00372           lpPoint[2].x = GetDlgItemInt(hwndDlg, DID_P3X, &success, TRUE);
00373           lpPoint[2].y = GetDlgItemInt(hwndDlg, DID_P3Y, &success, TRUE);
00374           XSrc = GetDlgItemInt(hwndDlg, DID_XSRC, &success, TRUE);
00375           YSrc = GetDlgItemInt(hwndDlg, DID_YSRC, &success, TRUE);
00376           nWidth = GetDlgItemInt(hwndDlg, DID_WIDTH, &success, TRUE);
00377           nHeight = GetDlgItemInt(hwndDlg, DID_HEIGHT, &success, TRUE);
00378           XMask = GetDlgItemInt(hwndDlg, DID_XMASK, &success, TRUE);
00379           YMask = GetDlgItemInt(hwndDlg, DID_YMASK, &success, TRUE);
00380
00381
00382           /**********************************************************/
00383           /**********************************************************/
00384           PlgBlt (hdcDest, lpPoint,
00385                   hdcSrc, XSrc, YSrc, nWidth, nHeight,
00386                   hbmMask, XMask, YMask);
00387           /**********************************************************/
00388           /**********************************************************/
00389         }
00390         doTrackObject (ptoSrc , TROB_PAINT, hwnd, 0);
00391         doTrackObject (ptoMask, TROB_PAINT, hwnd, 0);
00392     } break;
00393
00394
00395
00396     /**********************************************************************\
00397     *  WM_LBUTTONDOWN & WM_RBUTTONDOWN
00398     * On button down messages, hittest on the track object, and if
00399     *  it returns true, then send these messages to the track object.
00400     \**********************************************************************/
00401     case WM_RBUTTONDOWN:
00402     case WM_LBUTTONDOWN:
00403       if (doTrackObject(ptoDest, TROB_HITTEST, hwnd, lParam))
00404          doTrackObject(ptoDest, message, hwnd, lParam);
00405       else if (doTrackObject(ptoSrc, TROB_HITTEST, hwnd, lParam))
00406          doTrackObject(ptoSrc, message, hwnd, lParam);
00407       else if (doTrackObject(ptoMask, TROB_HITTEST, hwnd, lParam))
00408          doTrackObject(ptoMask, message, hwnd, lParam);
00409     break;
00410
00411
00412
00413     /**********************************************************************\
00414     *  WM_LBUTTONUP & WM_RBUTTONDOWN & MW_MOUSEMOVE
00415     * If the track object is in a "tracking mode" then send it these messages.
00416     *  If the transform dialog is not minimized, fill it with numbers.
00417     *  If the mouse dialog is not minimized, fill it with numbers.
00418     \**********************************************************************/
00419     case WM_RBUTTONUP:
00420     case WM_LBUTTONUP:
00421       /* user action complete.  Force plgblt() update. */
00422       PostMessage (hwndMain, WM_PLGBLT, 0,0);
00423     case WM_MOUSEMOVE:
00424       if (ptoDest->Mode) {
00425         doTrackObject(ptoDest, message, hwnd, lParam);
00426         SendMessage (hwndDlg, WM_PUTUPLPOINTS, (DWORD_PTR) hdcDest, (LONG_PTR) ptoDest);
00427       }
00428       if (ptoSrc->Mode) {
00429         doTrackObject(ptoSrc, message, hwnd, lParam);
00430         SendMessage (hwndDlg, WM_PUTUPSRCRECT, (DWORD_PTR) hdcSrc, (LONG_PTR) ptoSrc);
00431       }
00432
00433       if (ptoMask->Mode) {
00434         doTrackObject(ptoMask, message, hwnd, lParam);
00435         SendMessage (hwndDlg, WM_PUTUPMASKPT, (DWORD_PTR) hdcMask, (LONG_PTR) ptoMask);
00436       }
00437
00438     break;
00439
00440
00441
00442     /**********************************************************************\
00443     *  WM_SETFOCUS
00444     *
00445     * The main window should never have the focus.  Set it back
00446     *  to the top dialog.
00447     \**********************************************************************/
00448     case WM_SETFOCUS: SetFocus (hwndDlg);
00449         return 0;
00450
00451
00452
00453     /**********************************************************************\
00454     *  Menu item support.
00455     *
00456     \**********************************************************************/
00457     case WM_COMMAND:
00458       switch (LOWORD(wParam)) {
00459         HBITMAP hbmCompat, hbmOld;
00460         HDC hdcCompat;
00461
00462         /******************************************************************\
00463         *  WM_COMMAND, IDM_COPY
00464         *
00465         * Create a new bitmap, copy the destination HDC bits into it,
00466         *  and send the new bitmap to the clipboard.
00467         \******************************************************************/
00468         case IDM_COPY: {
00469           int X[4],Y[4];
00470           int nWidth, nHeight;
00471           int Xmin, Ymin, Xmax, Ymax;
00472           BOOL success;
00473           int i;
00474
00475           for (i = 0; i<3 ; i++) {
00476             X[i] = GetDlgItemInt(hwndDlg, DID_P1X + 2*i, &success, TRUE);
00477             Y[i] = GetDlgItemInt(hwndDlg, DID_P1Y + 2*i, &success, TRUE);
00478           }
00479
00480           X[3] = (X[1] - X[0]) + X[2];
00481           Y[3] = (Y[2] - Y[0]) + Y[1];
00482
00483           Xmin = Xmax = X[0];
00484           Ymin = Ymax = Y[0];
00485
00486           for (i = 1; i<4 ; i++) {
00487             Xmin = (X[i] < Xmin) ? X[i] : Xmin;
00488             Ymin = (Y[i] < Ymin) ? Y[i] : Ymin;
00489             Xmax = (X[i] > Xmax) ? X[i] : Xmax;
00490             Ymax = (Y[i] > Ymax) ? Y[i] : Ymax;
00491           }
00492
00493           nWidth = Xmax - Xmin;
00494           nHeight = Ymax - Ymin;
00495
00496           hdcCompat = CreateCompatibleDC(hdcDest);
00497           hbmCompat = CreateCompatibleBitmap (hdcDest, nWidth, nHeight);
00498           hbmOld = SelectObject(hdcCompat,hbmCompat);
00499
00500           BitBlt (hdcCompat, 0,0,nWidth, nHeight, hdcDest, Xmin,Ymin, SRCCOPY );
00501
00502           SelectObject(hdcCompat,hbmOld);
00503           DeleteDC(hdcCompat);
00504
00505           OpenClipboard (hwnd);
00506           SetClipboardData (CF_BITMAP,hbmCompat);
00507           CloseClipboard ();
00508
00509           DeleteObject (hbmCompat);
00510
00511         } break;
00512
00513
00514         /******************************************************************\
00515         *  WM_COMMAND, IDM_PASTE
00516         *
00517         * Get bitmap handle from clipboard, create a new bitmap, draw
00518         *  the clipboard bitmap into the new one, and store the new
00519         *  handle in the global hbmSrc.
00520         \******************************************************************/
00521         case IDM_PASTE: {
00522           HBITMAP hbm;
00523           BITMAP bm;
00524
00525           OpenClipboard (hwnd);
00526           if ( hbm = GetClipboardData (CF_BITMAP)) {
00527             DeleteObject (hbmSrc);
00528
00529             GetObject (hbm, sizeof(BITMAP), &bm);
00530
00531             hdcCompat = CreateCompatibleDC(hdcDest);
00532             hbmCompat = CreateCompatibleBitmap (hdcDest, bm.bmWidth, bm.bmHeight);
00533             hbmOld = SelectObject(hdcCompat,hbmCompat);
00534
00535             DrawBitmap (hdcCompat, hbm);
00536
00537             SelectObject(hdcCompat,hbmOld);
00538             DeleteDC(hdcCompat);
00539
00540             hbmSrc = hbmCompat;
00541
00542             InvalidateRect (hwnd, &ptoSrc->rectClip, TRUE);
00543             InvalidateRect (hwnd, &ptoDest->rectClip, TRUE);
00544           }
00545           CloseClipboard ();
00546         } break;
00547
00548         /******************************************************************\
00549         *  WM_COMMAND, IDM_BOTH
00550         *
00551         * Post a COPY and PASTE command message to this window so that with
00552         *  one key stroke the user can copy the DEST image into the clipboard,
00553         *  paste it down into the SRC hdc and cause the blt.
00554         \******************************************************************/
00555         case IDM_BOTH:
00556
00557           PostMessage (hwnd, WM_COMMAND, MAKELONG (IDM_COPY , 1), 0);
00558           PostMessage (hwnd, WM_COMMAND, MAKELONG (IDM_PASTE, 1), 0);
00559
00560         break;
00561
00562
00563
00564         /******************************************************************\
00565         *  WM_COMMAND, IDM_MODE_*
00566         *
00567         * manage mutually exclusive menu.
00568         *  call SetStretchBltMode() for the global destination hdc.
00569         \******************************************************************/
00570         case IDM_MODE_BLACKONWHITE:
00571           { HMENU hMenu;
00572           hMenu = GetMenu (hwnd);
00573
00574           CheckMenuItem(hMenu, IDM_MODE_BLACKONWHITE, MF_CHECKED);
00575           CheckMenuItem(hMenu, IDM_MODE_COLORONCOLOR, MF_UNCHECKED);
00576           CheckMenuItem(hMenu, IDM_MODE_WHITEONBLACK, MF_UNCHECKED);
00577           CheckMenuItem(hMenu, IDM_MODE_HALFTONE    , MF_UNCHECKED);
00578
00579           SetStretchBltMode (hdcDest,BLACKONWHITE);
00580           SendMessage (hwndMain, WM_PLGBLT, 0,0);
00581
00582           } return 0;
00583
00584         case IDM_MODE_COLORONCOLOR:
00585           { HMENU hMenu;
00586           hMenu = GetMenu (hwnd);
00587
00588           CheckMenuItem(hMenu, IDM_MODE_BLACKONWHITE, MF_UNCHECKED);
00589           CheckMenuItem(hMenu, IDM_MODE_COLORONCOLOR, MF_CHECKED);
00590           CheckMenuItem(hMenu, IDM_MODE_WHITEONBLACK, MF_UNCHECKED);
00591           CheckMenuItem(hMenu, IDM_MODE_HALFTONE    , MF_UNCHECKED);
00592
00593           SetStretchBltMode (hdcDest,COLORONCOLOR);
00594           SendMessage (hwndMain, WM_PLGBLT, 0,0);
00595
00596           } return 0;
00597
00598         case IDM_MODE_WHITEONBLACK:
00599           { HMENU hMenu;
00600           hMenu = GetMenu (hwnd);
00601
00602           CheckMenuItem(hMenu, IDM_MODE_BLACKONWHITE, MF_UNCHECKED);
00603           CheckMenuItem(hMenu, IDM_MODE_COLORONCOLOR, MF_UNCHECKED);
00604           CheckMenuItem(hMenu, IDM_MODE_WHITEONBLACK, MF_CHECKED);
00605           CheckMenuItem(hMenu, IDM_MODE_HALFTONE    , MF_UNCHECKED);
00606
00607           SetStretchBltMode (hdcDest,WHITEONBLACK);
00608           SendMessage (hwndMain, WM_PLGBLT, 0,0);
00609
00610           } return 0;
00611
00612         case IDM_MODE_HALFTONE    :
00613           { HMENU hMenu;
00614           hMenu = GetMenu (hwnd);
00615
00616           CheckMenuItem(hMenu, IDM_MODE_BLACKONWHITE, MF_UNCHECKED);
00617           CheckMenuItem(hMenu, IDM_MODE_COLORONCOLOR, MF_UNCHECKED);
00618           CheckMenuItem(hMenu, IDM_MODE_WHITEONBLACK, MF_UNCHECKED);
00619           CheckMenuItem(hMenu, IDM_MODE_HALFTONE    , MF_CHECKED);
00620
00621           SetStretchBltMode (hdcDest,HALFTONE);
00622           SendMessage (hwndMain, WM_PLGBLT, 0,0);
00623
00624           } return 0;
00625
00626
00627
00628
00629
00630         /******************************************************************\
00631         *  WM_COMMAND, IDM_SPIN*
00632         *
00633         * manage mutually exclusive menu.
00634         *
00635         \******************************************************************/
00636         case IDM_SPINOFF:
00637           { HMENU hMenu;
00638           hMenu = GetMenu (hwnd);
00639
00640           CheckMenuItem(hMenu, IDM_SPINOFF, MF_CHECKED);
00641           CheckMenuItem(hMenu, IDM_SPIN5  , MF_UNCHECKED);
00642           CheckMenuItem(hMenu, IDM_SPIN10 , MF_UNCHECKED);
00643           CheckMenuItem(hMenu, IDM_SPIN30 , MF_UNCHECKED);
00644           CheckMenuItem(hMenu, IDM_SPIN60 , MF_UNCHECKED);
00645           CheckMenuItem(hMenu, IDM_SPIN90 , MF_UNCHECKED);
00646
00647           nSpin = FALSE;
00648           SendMessage (hwndMain, WM_PLGBLT, 0,0);
00649
00650           } return 0;
00651
00652         case IDM_SPIN5 :
00653           { HMENU hMenu;
00654           hMenu = GetMenu (hwnd);
00655
00656           CheckMenuItem(hMenu, IDM_SPINOFF, MF_UNCHECKED);
00657           CheckMenuItem(hMenu, IDM_SPIN5  , MF_CHECKED);
00658           CheckMenuItem(hMenu, IDM_SPIN10 , MF_UNCHECKED);
00659           CheckMenuItem(hMenu, IDM_SPIN30 , MF_UNCHECKED);
00660           CheckMenuItem(hMenu, IDM_SPIN60 , MF_UNCHECKED);
00661           CheckMenuItem(hMenu, IDM_SPIN90 , MF_UNCHECKED);
00662
00663           nSpin = 5;
00664
00665           } return 0;
00666
00667         case IDM_SPIN10:
00668           { HMENU hMenu;
00669           hMenu = GetMenu (hwnd);
00670
00671           CheckMenuItem(hMenu, IDM_SPINOFF, MF_UNCHECKED);
00672           CheckMenuItem(hMenu, IDM_SPIN5  , MF_UNCHECKED);
00673           CheckMenuItem(hMenu, IDM_SPIN10 , MF_CHECKED);
00674           CheckMenuItem(hMenu, IDM_SPIN30 , MF_UNCHECKED);
00675           CheckMenuItem(hMenu, IDM_SPIN60 , MF_UNCHECKED);
00676           CheckMenuItem(hMenu, IDM_SPIN90 , MF_UNCHECKED);
00677
00678           nSpin = 10;
00679
00680           } return 0;
00681
00682         case IDM_SPIN30:
00683           { HMENU hMenu;
00684           hMenu = GetMenu (hwnd);
00685
00686           CheckMenuItem(hMenu, IDM_SPINOFF, MF_UNCHECKED);
00687           CheckMenuItem(hMenu, IDM_SPIN5  , MF_UNCHECKED);
00688           CheckMenuItem(hMenu, IDM_SPIN10 , MF_UNCHECKED);
00689           CheckMenuItem(hMenu, IDM_SPIN30 , MF_CHECKED);
00690           CheckMenuItem(hMenu, IDM_SPIN60 , MF_UNCHECKED);
00691           CheckMenuItem(hMenu, IDM_SPIN90 , MF_UNCHECKED);
00692
00693           nSpin = 30;
00694
00695           } return 0;
00696
00697         case IDM_SPIN60:
00698           { HMENU hMenu;
00699           hMenu = GetMenu (hwnd);
00700
00701           CheckMenuItem(hMenu, IDM_SPINOFF, MF_UNCHECKED);
00702           CheckMenuItem(hMenu, IDM_SPIN5  , MF_UNCHECKED);
00703           CheckMenuItem(hMenu, IDM_SPIN10 , MF_UNCHECKED);
00704           CheckMenuItem(hMenu, IDM_SPIN30 , MF_UNCHECKED);
00705           CheckMenuItem(hMenu, IDM_SPIN60 , MF_CHECKED);
00706           CheckMenuItem(hMenu, IDM_SPIN90 , MF_UNCHECKED);
00707
00708           nSpin = 60;
00709
00710           } return 0;
00711
00712         case IDM_SPIN90:
00713           { HMENU hMenu;
00714           hMenu = GetMenu (hwnd);
00715
00716           CheckMenuItem(hMenu, IDM_SPINOFF, MF_UNCHECKED);
00717           CheckMenuItem(hMenu, IDM_SPIN5  , MF_UNCHECKED);
00718           CheckMenuItem(hMenu, IDM_SPIN10 , MF_UNCHECKED);
00719           CheckMenuItem(hMenu, IDM_SPIN30 , MF_UNCHECKED);
00720           CheckMenuItem(hMenu, IDM_SPIN60 , MF_UNCHECKED);
00721           CheckMenuItem(hMenu, IDM_SPIN90 , MF_CHECKED);
00722
00723           nSpin = 90;
00724
00725           } return 0;
00726
00727
00728         case IDM_FLIPONCE:
00729           nSpin = 90;
00730           SendMessage (hwndMain, WM_SPIN, 0,0);
00731           nSpin = FALSE;
00732           return 0;
00733
00734
00735
00736         case IDM_SPINTOPLEFT:
00737           { HMENU hMenu;
00738           hMenu = GetMenu (hwnd);
00739
00740           CheckMenuItem(hMenu, IDM_SPINTOPLEFT, MF_CHECKED);
00741           CheckMenuItem(hMenu, IDM_SPINCENTER , MF_UNCHECKED);
00742
00743           } return 0;
00744
00745         case IDM_SPINCENTER:
00746           { HMENU hMenu;
00747           hMenu = GetMenu (hwnd);
00748
00749           CheckMenuItem(hMenu, IDM_SPINTOPLEFT, MF_UNCHECKED);
00750           CheckMenuItem(hMenu, IDM_SPINCENTER , MF_CHECKED);
00751
00752           } return 0;
00753
00754
00755         /******************************************************************\
00756         *  WM_COMMAND, DID_NEW*
00757         *
00758         * menu equivalents for buttons on top dialog.  Just pass along
00759         *  WM_COMMAND messages to the dialog.
00760         *
00761         \******************************************************************/
00762         case DID_NEWSRC:
00763         case DID_NEWMASK:
00764           SendMessage (hwndDlg, message, wParam, lParam);
00765         return 0;
00766
00767
00768         /******************************************************************\
00769         *  WM_COMMAND, IDM_ABOUT
00770         *
00771         \******************************************************************/
00772         case IDM_ABOUT:
00773           DialogBox (hInst, "aboutBox", hwnd, (DLGPROC)About);
00774         return 0;
00775
00776
00777
00778
00779       }  /* end switch */
00780
00781     break;  /* end wm_command */
00782
00783
00784
00785     /******************************************************************\
00786     *  WM_SPIN
00787     *
00788     * Set up a transform to modify the destination points.
00789     *  (Note that the transform in hdcDest remains the identity.)
00790     *  Loop through, reblitting to the transformed points.
00791     *  Erase behind the old bitmap by keeping track of the region uncovered.
00792     *
00793     \******************************************************************/
00794     case WM_SPIN: {
00795
00796       XFORM  x;
00797       HDC hdc;
00798       float M11, M12, M21, M22;
00799       int nSteps, i;
00800
00801       POINT pivot;
00802       POINT lpPoint[3];
00803       POINT lpRgnErase[4], lpRgnBmp[4];
00804       HRGN hrgnErase, hrgnBmp;
00805       HMENU hMenu;
00806       int XSrc, YSrc, nWidth, nHeight, XMask, YMask;
00807       BOOL success;
00808
00809       /* validate the dialog on top with the parameters in it. */
00810       if (!IsWindow(hwndDlg)) return 0;
00811
00812       /* Grab points out of the dialog entry fields. */
00813       lpPoint[0].x = GetDlgItemInt(hwndDlg, DID_P1X, &success, TRUE);
00814       lpPoint[0].y = GetDlgItemInt(hwndDlg, DID_P1Y, &success, TRUE);
00815       lpPoint[1].x = GetDlgItemInt(hwndDlg, DID_P2X, &success, TRUE);
00816       lpPoint[1].y = GetDlgItemInt(hwndDlg, DID_P2Y, &success, TRUE);
00817       lpPoint[2].x = GetDlgItemInt(hwndDlg, DID_P3X, &success, TRUE);
00818       lpPoint[2].y = GetDlgItemInt(hwndDlg, DID_P3Y, &success, TRUE);
00819       XSrc = GetDlgItemInt(hwndDlg, DID_XSRC, &success, TRUE);
00820       YSrc = GetDlgItemInt(hwndDlg, DID_YSRC, &success, TRUE);
00821       nWidth = GetDlgItemInt(hwndDlg, DID_WIDTH, &success, TRUE);
00822       nHeight = GetDlgItemInt(hwndDlg, DID_HEIGHT, &success, TRUE);
00823       XMask = GetDlgItemInt(hwndDlg, DID_XMASK, &success, TRUE);
00824       YMask = GetDlgItemInt(hwndDlg, DID_YMASK, &success, TRUE);
00825
00826
00827       /* get an HDC we can use to play with transforms. */
00828       hdc = GetDC (hwnd);
00829       SetGraphicsMode (hdc, GM_ADVANCED);
00830
00831
00832
00833       /* check menu check to pivot on top-left corner, or pivot on center. */
00834       hMenu = GetMenu (hwnd);
00835
00836       if (GetMenuState(hMenu, IDM_SPINCENTER, MF_BYCOMMAND) & MF_CHECKED) {
00837         pivot.x = (lpPoint[1].x +lpPoint[2].x)/2;
00838         pivot.y = (lpPoint[1].y +lpPoint[2].y)/2;
00839       } else {
00840         pivot.x = lpPoint[0].x;
00841         pivot.y = lpPoint[0].y;
00842       }
00843
00844       /* nSpin contains values reflecting the number of degrees per step.
00845        *  fill in the number of steps required (360 / nSpin), and fill in
00846        *  the precomputed transformation matrices.
00847        */
00848       switch (nSpin) {
00849
00850         case 5:
00851           nSteps = 72;
00852           M11 =                   M22 = (float)0.9961946980917;
00853           M12 = (float)-0.08715574274766; M21 = (float)0.08715574274766;
00854           break;
00855         case 10:
00856           nSteps = 36;
00857           M11 =                   M22 = (float)0.984808;
00858           M12 = (float)-0.173648; M21 = (float)0.173648;
00859           break;
00860         case 30:
00861           nSteps = 12;
00862           M11 =                   M22 = (float)0.866025;
00863           M12 = (float)-0.5     ; M21 = (float)0.5;
00864           break;
00865         case 60:
00866           nSteps = 6;
00867           M11 =                   M22 = (float)0.5     ;
00868           M12 = (float)-0.866025; M21 = (float)0.866025;
00869           break;
00870         case 90:
00871           nSteps = 4;
00872           M11 =                   M22 = (float)0.0;
00873           M12 = (float)-1.0     ; M21 = (float)1.0;
00874           break;
00875         default:
00876           MessageBox (hwnd,
00877                       GetStringRes (IDS_INVALID),
00878                       NULL, MB_ICONHAND);
00879           return 0;
00880
00881       } /* end switch nSpin */
00882
00883
00884
00885
00886       /* translate objects from pivot point to origin. */
00887       x.eM11 = (float)1.0;
00888       x.eM12 = (float)0.0;
00889       x.eM21 = (float)0.0;
00890       x.eM22 = (float)1.0;
00891       x.eDx = (float)-pivot.x;
00892       x.eDy = (float)-pivot.y;
00893       ModifyWorldTransform (hdc, &x, MWT_RIGHTMULTIPLY);
00894
00895       /* rotate object about origin. */
00896       x.eM11 = M11;
00897       x.eM12 = M12;
00898       x.eM21 = M21;
00899       x.eM22 = M22;
00900       x.eDx = (float)0.0;
00901       x.eDy = (float)0.0;
00902       ModifyWorldTransform (hdc, &x, MWT_RIGHTMULTIPLY);
00903
00904       /* translate objects back to pivot point. */
00905       x.eM11 = (float)1.0;
00906       x.eM12 = (float)0.0;
00907       x.eM21 = (float)0.0;
00908       x.eM22 = (float)1.0;
00909       x.eDx = (float)pivot.x;
00910       x.eDy = (float)pivot.y;
00911       ModifyWorldTransform (hdc, &x, MWT_RIGHTMULTIPLY);
00912
00913
00914
00915       /* fill in initial region for erasure... the region containing bmp */
00916       lpRgnErase[0] = lpPoint[0];
00917       lpRgnErase[1] = lpPoint[1];
00918       lpRgnErase[3] = lpPoint[2];
00919       lpRgnErase[2].x =  lpPoint[1].x - lpPoint[0].x;
00920       lpRgnErase[2].x += lpPoint[2].x - lpPoint[0].x;
00921       lpRgnErase[2].x += lpPoint[0].x;
00922       lpRgnErase[2].y =  lpPoint[1].y - lpPoint[0].y;
00923       lpRgnErase[2].y += lpPoint[2].y - lpPoint[0].y;
00924       lpRgnErase[2].y += lpPoint[0].y;
00925
00926
00927
00928       /* loop through transforming the points on each step. */
00929       for (i= 0; i<nSteps; i++) {
00930
00931
00932         hrgnErase = CreatePolygonRgn (lpRgnErase, 4, ALTERNATE);
00933
00934         /* TRANSFORM the lpPoint[] destination extent points */
00935         LPtoDP (hdc, lpPoint, 3);
00936
00937         /* create a region containing the new bitmap extents */
00938         lpRgnBmp[0] = lpPoint[0];
00939         lpRgnBmp[1] = lpPoint[1];
00940         lpRgnBmp[3] = lpPoint[2];
00941         lpRgnBmp[2].x =  lpPoint[1].x - lpPoint[0].x;
00942         lpRgnBmp[2].x += lpPoint[2].x - lpPoint[0].x;
00943         lpRgnBmp[2].x += lpPoint[0].x;
00944         lpRgnBmp[2].y =  lpPoint[1].y - lpPoint[0].y;
00945         lpRgnBmp[2].y += lpPoint[2].y - lpPoint[0].y;
00946         lpRgnBmp[2].y += lpPoint[0].y;
00947         hrgnBmp = CreatePolygonRgn (lpRgnBmp, 4, ALTERNATE);
00948
00949         /* subtract the new bitmap extents region from the erasure region. */
00950         CombineRgn (hrgnErase, hrgnErase, hrgnBmp, RGN_DIFF);
00951
00952
00953
00954         /* while we are here, get points ready for the next loop erasure */
00955         lpRgnErase[0] = lpPoint[0];
00956         lpRgnErase[1] = lpPoint[1];
00957         lpRgnErase[3] = lpPoint[2];
00958         lpRgnErase[2].x =  lpPoint[1].x - lpPoint[0].x;
00959         lpRgnErase[2].x += lpPoint[2].x - lpPoint[0].x;
00960         lpRgnErase[2].x += lpPoint[0].x;
00961         lpRgnErase[2].y =  lpPoint[1].y - lpPoint[0].y;
00962         lpRgnErase[2].y += lpPoint[2].y - lpPoint[0].y;
00963         lpRgnErase[2].y += lpPoint[0].y;
00964
00965
00966
00967         /**********************************************************/
00968         PlgBlt (hdcDest, lpPoint,
00969                 hdcSrc, XSrc, YSrc, nWidth, nHeight,
00970                 hbmMask, XMask, YMask);
00971         /**********************************************************/
00972
00973         /* need to flush graphics buffer, or regions are erased
00974          *  before the bitmap is drawn.
00975          */
00976         GdiFlush();
00977
00978         /* erase the newly uncovered region. */
00979         FillRgn (hdcDest, hrgnErase, BACKGROUNDBRUSH );
00980         DeleteObject (hrgnErase);
00981         DeleteObject (hrgnBmp);
00982       } /* end for loop */
00983
00984
00985       /* because of roundoff error, the 'nSteps'th rotation will not
00986        *  always bring the parallelogram around to the 0th position.
00987        *  So we special case the last position, and do one more erase.
00988        *  Try commenting this out, and see the little glitches left
00989        *  on the screen if this comment is unclear.
00990        */
00991       lpRgnErase[0] = lpPoint[0];
00992       lpRgnErase[1] = lpPoint[1];
00993       lpRgnErase[3] = lpPoint[2];
00994       lpRgnErase[2].x =  lpPoint[1].x - lpPoint[0].x;
00995       lpRgnErase[2].x += lpPoint[2].x - lpPoint[0].x;
00996       lpRgnErase[2].x += lpPoint[0].x;
00997       lpRgnErase[2].y =  lpPoint[1].y - lpPoint[0].y;
00998       lpRgnErase[2].y += lpPoint[2].y - lpPoint[0].y;
00999       lpRgnErase[2].y += lpPoint[0].y;
01000       hrgnErase = CreatePolygonRgn (lpRgnErase, 4, ALTERNATE);
01001       lpPoint[0].x = GetDlgItemInt(hwndDlg, DID_P1X, &success, TRUE);
01002       lpPoint[0].y = GetDlgItemInt(hwndDlg, DID_P1Y, &success, TRUE);
01003       lpPoint[1].x = GetDlgItemInt(hwndDlg, DID_P2X, &success, TRUE);
01004       lpPoint[1].y = GetDlgItemInt(hwndDlg, DID_P2Y, &success, TRUE);
01005       lpPoint[2].x = GetDlgItemInt(hwndDlg, DID_P3X, &success, TRUE);
01006       lpPoint[2].y = GetDlgItemInt(hwndDlg, DID_P3Y, &success, TRUE);
01007       lpRgnBmp[0] = lpPoint[0];
01008       lpRgnBmp[1] = lpPoint[1];
01009       lpRgnBmp[3] = lpPoint[2];
01010       lpRgnBmp[2].x =  lpPoint[1].x - lpPoint[0].x;
01011       lpRgnBmp[2].x += lpPoint[2].x - lpPoint[0].x;
01012       lpRgnBmp[2].x += lpPoint[0].x;
01013       lpRgnBmp[2].y =  lpPoint[1].y - lpPoint[0].y;
01014       lpRgnBmp[2].y += lpPoint[2].y - lpPoint[0].y;
01015       lpRgnBmp[2].y += lpPoint[0].y;
01016       hrgnBmp = CreatePolygonRgn (lpRgnBmp, 4, ALTERNATE);
01017       CombineRgn (hrgnErase, hrgnErase, hrgnBmp, RGN_DIFF);
01018       FillRgn (hdcDest, hrgnErase, BACKGROUNDBRUSH );
01019       DeleteObject (hrgnErase);
01020       DeleteObject (hrgnBmp);
01021
01022
01023
01024
01025
01026
01027
01028       ReleaseDC (hwnd, hdc);
01029
01030
01031     } return 0; /* end WM_SPIN message */
01032
01033
01034   } /* end switch */
01035   return (DefWindowProc(hwnd, message, wParam, lParam));
01036 }
01037
01038
01039
01040
01041 /**************************************************************************\
01042 *
01043 *  function:  DlgProc()
01044 *
01045 *  input parameters:  normal window procedure parameters.
01046 *
01047 *  Respond to user button presses by getting new bitmaps or by sending
01048 *   the main window a WM_PLGBLT message.  Also handle special user messages
01049 *   for updating the entry fields with the contents of the direct manipulation
01050 *   objects.
01051 *
01052 *  global variables:
01053 *   hwndMain - the main window.  also the parent of this dialog
01054 *   ptoDest, ptoSrc, ptoMask - pointers to the direct manipulation objects
01055 *   hdcDest, hdcSrc, hdcMask - HDCs for the 3 sub regions of the window.
01056 *   hbmSrc, hbmMask          - bitmap handles for source and mask.
01057 \**************************************************************************/
01058 LRESULT CALLBACK DlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
01059 {
01060
01061   switch (message) {
01062     /**********************************************************************\
01063     *  WM_INITDIALOG
01064     *
01065     * Fill the entry fields with sensible original values.
01066     \**********************************************************************/
01067     case WM_INITDIALOG:
01068         SetDlgItemText(hwnd, DID_P1X     , "0");
01069         SetDlgItemText(hwnd, DID_P1Y     , "0");
01070         SetDlgItemText(hwnd, DID_P2X     , "0");
01071         SetDlgItemText(hwnd, DID_P2Y     , "0");
01072         SetDlgItemText(hwnd, DID_P3X     , "0");
01073         SetDlgItemText(hwnd, DID_P3Y     , "0");
01074         SetDlgItemText(hwnd, DID_XSRC    , "0");
01075         SetDlgItemText(hwnd, DID_YSRC    , "0");
01076         SetDlgItemText(hwnd, DID_WIDTH   , "0");
01077         SetDlgItemText(hwnd, DID_HEIGHT  , "0");
01078         SetDlgItemText(hwnd, DID_XMASK   , "0");
01079         SetDlgItemText(hwnd, DID_YMASK   , "0");
01080     return TRUE;
01081
01082
01083
01084     /**********************************************************************\
01085     *  WM_PUTUPLPOINTS
01086     *
01087     * wParam -  HDC with the needed world transform.
01088     * lParam -  Pointer to the track object.
01089     *
01090     * Fill the entry fields for the array of 3 dest parallelogram points.
01091     *  Conditionally change the first point depending on tracking mode.
01092     \**********************************************************************/
01093     case WM_PUTUPLPOINTS: {
01094         POINT p, origin;
01095         PTrackObject pto;
01096         HDC hdc;
01097
01098         hdc = (HDC) wParam;
01099         pto = (PTrackObject) lParam;
01100         GetViewportOrgEx (hdc, &origin);
01101
01102         if (pto->Mode & TMMOVE) {
01103           p.x = pto->rect.left;
01104           p.y = pto->rect.top;
01105           LPtoDP (pto->hdc, &p, 1);
01106           p.x -= origin.x; p.y -= origin.y;
01107
01108           SetDlgItemInt(hwnd, DID_P1X, p.x, TRUE);
01109           SetDlgItemInt(hwnd, DID_P1Y, p.y, TRUE);
01110
01111         }
01112
01113         p.x = pto->rect.right;
01114         p.y = pto->rect.top;
01115         LPtoDP (pto->hdc, &p, 1);
01116         p.x -= origin.x; p.y -= origin.y;
01117
01118         SetDlgItemInt(hwnd, DID_P2X, p.x, TRUE);
01119         SetDlgItemInt(hwnd, DID_P2Y, p.y, TRUE);
01120
01121         p.x = pto->rect.left;
01122         p.y = pto->rect.bottom;
01123         LPtoDP (pto->hdc, &p, 1);
01124         p.x -= origin.x; p.y -= origin.y;
01125         SetDlgItemInt(hwnd, DID_P3X, p.x, TRUE);
01126         SetDlgItemInt(hwnd, DID_P3Y, p.y, TRUE);
01127
01128     } return FALSE;
01129
01130
01131
01132
01133     /**********************************************************************\
01134     *  WM_PUTUPSRCRECT
01135     *
01136     * wParam -  HDC with the needed world transform.
01137     * lParam -  Pointer to the track object.
01138     *
01139     * Fill the entry fields for the source rectangle points.
01140     *  Conditionally change <x,y> or <width,height> depending on tracking mode.
01141     \**********************************************************************/
01142     case WM_PUTUPSRCRECT: {
01143         POINT p1,p2, origin;
01144         PTrackObject pto;
01145         HDC hdc;
01146
01147         hdc = (HDC) wParam;
01148         pto = (PTrackObject) lParam;
01149         GetViewportOrgEx (hdc, &origin);
01150
01151         p1.x = pto->rect.left;
01152         p1.y = pto->rect.top;
01153         LPtoDP (pto->hdc, &p1, 1);
01154
01155         p2.x = pto->rect.right;
01156         p2.y = pto->rect.bottom;
01157         LPtoDP (pto->hdc, &p2, 1);
01158         p2.x -= p1.x; p2.y -= p1.y;
01159
01160         p1.x -= origin.x; p1.y -= origin.y;
01161
01162         if (!(pto->Mode & TMSIZEXY)) {
01163           SetDlgItemInt(hwnd, DID_XSRC, p1.x, TRUE);
01164           SetDlgItemInt(hwnd, DID_YSRC, p1.y, TRUE);
01165         }
01166
01167         if (!(pto->Mode & TMMOVE)) {
01168           SetDlgItemInt(hwnd, DID_WIDTH,  p2.x, TRUE);
01169           SetDlgItemInt(hwnd, DID_HEIGHT, p2.y, TRUE);
01170         }
01171     } return FALSE;
01172
01173
01174
01175     /**********************************************************************\
01176     *  WM_PUTUPMASKPT
01177     *
01178     * wParam -  HDC with the needed world transform.
01179     * lParam -  Pointer to the track object.
01180     *
01181     * Fill the entry fields for the mask location point.
01182     \**********************************************************************/
01183     case WM_PUTUPMASKPT: {
01184         POINT p1, origin;
01185         PTrackObject pto;
01186         HDC hdc;
01187
01188         hdc = (HDC) wParam;
01189         pto = (PTrackObject) lParam;
01190         GetViewportOrgEx (hdc, &origin);
01191
01192         p1.x = pto->rect.left;
01193         p1.y = pto->rect.top;
01194         LPtoDP (pto->hdc, &p1, 1);
01195         p1.x -= origin.x; p1.y -= origin.y;
01196
01197         SetDlgItemInt(hwnd, DID_XMASK, p1.x, TRUE);
01198         SetDlgItemInt(hwnd, DID_YMASK, p1.y, TRUE);
01199
01200     } return FALSE;
01201
01202
01203
01204
01205     /**********************************************************************\
01206     *  WM_COMMAND, DID_DRAW
01207     *
01208     * Draw button hit - send main window message to call PlgBlt().
01209     \**********************************************************************/
01210     case WM_COMMAND: {
01211       HBITMAP hbm;
01212
01213       if (LOWORD(wParam) == DID_DRAW) {
01214           SendMessage (hwndMain, WM_PLGBLT, 0,0);
01215
01216
01217     /**********************************************************************\
01218     *  WM_COMMAND, DID_NEWSRC
01219     *
01220     * Try to get a new source bitmap.  Then
01221     *  invalidate two sub windows so that we force a repaint.
01222     \**********************************************************************/
01223       } else if (LOWORD(wParam) == DID_NEWSRC) {
01224         if ( hbm = GetBitmap (hdcSrc, hInst, FALSE)) {
01225           DeleteObject (hbmSrc);
01226           hbmSrc = hbm;
01227           InvalidateRect (hwndMain, &ptoSrc->rectClip, TRUE);
01228           InvalidateRect (hwndMain, &ptoDest->rectClip, TRUE);
01229         }
01230
01231     /**********************************************************************\
01232     *  WM_COMMAND, DID_Mask
01233     *
01234     * Try to get a new mask bitmap.  Then
01235     *  invalidate two sub windows so that we force a repaint.
01236     \**********************************************************************/
01237       } else if (LOWORD(wParam) == DID_NEWMASK) {
01238         if ( hbm = GetBitmap (hdcMask,  hInst, TRUE)) {
01239           DeleteObject (hbmMask);
01240           hbmMask = hbm;
01241           InvalidateRect (hwndMain, &ptoMask->rectClip, TRUE);
01242           InvalidateRect (hwndMain, &ptoDest->rectClip, TRUE);
01243         }
01244       }
01245
01246     } return FALSE; /* end WM_COMMAND */
01247
01248
01249   } /* end switch */
01250   return 0;
01251 }
01252
01253
01254
01255 #define TICKSPACE     20
01256
01257 /**************************************************************************\
01258 *
01259 *  function:  DrawGrids()
01260 *
01261 *  input parameters:
01262 *   hdc - Device context to draw into.
01263 *   width, height - size of the rectangle to fill with grids.
01264 *
01265 *  global variables:  none.
01266 *
01267 \**************************************************************************/
01268 VOID DrawGrids (HDC hdc, int width, int height)
01269 {
01270 int i;
01271
01272     /* Draw vertical lines. Double at the axis */
01273     for (i = 0; i<= width; i+=TICKSPACE){
01274       MoveToEx (hdc, i, 0, NULL);
01275       LineTo (hdc, i, height);
01276     }
01277     MoveToEx (hdc, 1, 0, NULL);
01278     LineTo (hdc, 1, height);
01279
01280     /* Draw horizontal lines. Double at the axis */
01281     for (i = 0; i<= height; i+=TICKSPACE){
01282       MoveToEx (hdc, 0,i, NULL);
01283       LineTo (hdc, width,i);
01284     }
01285     MoveToEx (hdc, 0, 1, NULL);
01286     LineTo (hdc, width,1);
01287
01288   return;
01289 }
01290
01291
01292
01293
01294 /****************************************************************************
01295     FUNCTION: About
01296 ****************************************************************************/
01297 LRESULT CALLBACK About(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
01298 {
01299   if ((message == WM_COMMAND) && (LOWORD(wParam) == IDOK)) {
01300     EndDialog (hwnd, TRUE);
01301     return TRUE;
01302   }
01303   if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE)) {
01304     EndDialog (hwnd, TRUE);
01305     return TRUE;
01306   }
01307   return FALSE;
01308 }
01309
01310
01311
01312
01313
01314 /******************************************************************************\
01315 *
01316 *  FUNCTION:    GetStringRes (int id INPUT ONLY)
01317 *
01318 *  COMMENTS:    Load the resource string with the ID given, and return a
01319 *               pointer to it.  Notice that the buffer is common memory so
01320 *               the string must be used before this call is made a second time.
01321 *
01322 \******************************************************************************/
01323
01324 LPTSTR   GetStringRes (int id)
01325 {
01326   static TCHAR buffer[MAX_PATH];
01327
01328   buffer[0]=0;
01329   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
01330   return buffer;
01331 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagCMTMLTFMT Member List

This is the complete list of members for tagCMTMLTFMT, including all inherited members.
aemrformat | tagCMTMLTFMT
iComment | tagCMTMLTFMT
ident | tagCMTMLTFMT
nFormats | tagCMTMLTFMT
rclOutput | tagCMTMLTFMT
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/credentials/VC/Credentials.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • credentials
  • VC

Credentials.cpp

Go to the documentation of this file.
00001 /*
00002 **  Credential: Loggon to a current domain with alternate user name/password
00003 **
00004 **  Libraries:   activeds.lib, adsiid.lib
00005 **
00006 **  Copyright (c) 1998 - 2000 Microsoft Corporation
00007 **  All Rights Reserved
00008 */
00009
00010 #include "stdafx.h"
00011
00012
00013 void ReportError(TCHAR *pTxt,DWORD err);
00014
00015 int main(int argc, char* argv[])
00016 {
00017     IADs             *pNS = NULL,
00018                      *pRoot=NULL,
00019                      *pAuth=NULL;
00020
00021     IADsOpenDSObject *pDSObj=NULL;
00022
00023     VARIANT varDSRoot;
00024
00025     TCHAR   adspath[MAX_PATH],username[255],password[255];
00026
00027     HRESULT hr;
00028
00029   hr = CoInitialize(NULL);
00030
00031   //  Get the name of the root container for this domain.
00032   //  Read the Root DSE from the default DS,  which will be the DS for
00033   //  the local domain.  This will get us the name of the schema container,
00034   //  which is stored in the "defaultNamingContext" operational attribute.
00035
00036     hr = ADsGetObject(TEXT("LDAP://RootDSE"),
00037                       IID_IADs,
00038                       (void**)&pRoot);
00039
00040     hr = pRoot->Get(TEXT("defaultNamingContext"),&varDSRoot);
00041   _tprintf(TEXT("\nDomain Name is :%s\n"),varDSRoot.bstrVal);
00042     pRoot->Release();
00043
00044     _tcscpy(adspath,TEXT("LDAP://"));
00045   // get the remaining buffer size; make sure it copies, avoid buffer overrun
00046   int rem =  (sizeof(adspath)/sizeof(TCHAR)) - _tcslen(adspath) -1; //-1 is for NULL
00047   int len = wcslen(varDSRoot.bstrVal);
00048
00049   if ( rem >= len )
00050   {
00051     _tcsncat(adspath,varDSRoot.bstrVal, len);
00052   }
00053   else
00054   {
00055     pRoot->Release();
00056     VariantClear(&varDSRoot);
00057     return 0;
00058   }
00059
00060
00061
00062
00063     hr = ADsGetObject(TEXT("LDAP:"),
00064                       IID_IADs,
00065                       (void**)&pNS);
00066
00067     hr = pNS->QueryInterface(IID_IADsOpenDSObject,(void**)&pDSObj);
00068
00069     //
00070     // Collect the username and password and bind to the Domain using these.
00071     //
00072
00073     if SUCCEEDED(hr)
00074   {
00075         pNS->Release();
00076         _tprintf(TEXT("\nusername:"));
00077         _fgetts(username,sizeof(username)/sizeof(TCHAR),stdin);
00078         _tprintf(TEXT("\npassword:"));
00079         _fgetts(password, sizeof(password)/sizeof(TCHAR), stdin);
00080         hr = pDSObj->OpenDSObject(adspath,username,password,ADS_SECURE_AUTHENTICATION,(IDispatch**)&pAuth);
00081     // NOTE: Alternatively you can use an ADSI wrapper API: ADsOpenObject
00082         if FAILED(hr)
00083     {
00084             ReportError(TEXT("Bind Failed"),(DWORD)hr);
00085         }
00086     else
00087     {
00088       _tprintf(TEXT("Successfully logon!"));
00089
00090     }
00091     }
00092
00093
00094     if (pAuth)
00095   {
00096         pAuth->Release();
00097   }
00098     if (pDSObj)
00099   {
00100         pDSObj->Release();
00101   }
00102
00103     CoUninitialize();
00104     return 0;
00105
00106 }
00107
00108
00109
00110 // Simple error message reporter
00111
00112 void ReportError(TCHAR *pTxt,DWORD err)
00113 {
00114     DWORD   dwStatus;
00115     TCHAR   *pBuf;
00116
00117     dwStatus = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
00118                FORMAT_MESSAGE_ALLOCATE_BUFFER|
00119                FORMAT_MESSAGE_IGNORE_INSERTS,
00120                NULL,
00121                err,
00122                LANG_NEUTRAL,
00123                (USHORT*)&pBuf,
00124                64,
00125                NULL);
00126   if (dwStatus != 0)
00127   {
00128     _tprintf(TEXT("%s %s"),pTxt,pBuf);
00129         LocalFree(pBuf);
00130   } else
00131   {
00132     _tprintf(TEXT("%s %X\n"),pTxt,err);
00133   }
00134 }
00135
00136
00137
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/APIDoc.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

APIDoc.Cpp

Go to the documentation of this file.
00001 // APIDoc.cpp : implementation of the CAPIDoc class
00002 //
00003 //  Copyright 1995-1999, Citrix Systems Inc.
00004 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00005
00006 #include "stdafx.h"
00007 #include "API.h"
00008 #include "string.h"
00009 #include <wtsapi32.h>
00010 #include "APIDoc.h"
00011 #include "ServerDlg.h"
00012 #include "ProcessDlg.h"
00013 #include "SessionDlg.h"
00014 #include "MessageDlg.h"
00015 #include "WaitSystemDlg.h"
00016 #include "ShutdownDlg.h"
00017
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CAPIDoc
00026
00027 IMPLEMENT_DYNCREATE(CAPIDoc, CDocument)
00028
00029 BEGIN_MESSAGE_MAP(CAPIDoc, CDocument)
00030   //{{AFX_MSG_MAP(CAPIDoc)
00031   ON_COMMAND(ID_RUN_TEST, OnRunTest)
00032   ON_COMMAND(ID_PROCESS, OnProcess)
00033   ON_COMMAND(ID_SESSION, OnSession)
00034   ON_COMMAND(ID_SHUTDOWN_SYSTEM, OnShutdownSystem)
00035   ON_COMMAND(ID_SEND_MESSAGE, OnSendMessage)
00036   ON_COMMAND(ID_WAIT_EVENT, OnWaitEvent)
00037   //}}AFX_MSG_MAP
00038 END_MESSAGE_MAP()
00039
00040 /////////////////////////////////////////////////////////////////////////////
00041 // CAPIDoc construction/destruction
00042
00043 CAPIDoc *g_pDoc;
00044
00045 CAPIDoc::CAPIDoc()
00046 {
00047   g_pDoc = this;
00048   serverName = new TCHAR[255];
00049   serverName[0] = NULL;
00050 }
00051
00052 CAPIDoc::~CAPIDoc()
00053 {
00054 }
00055
00056
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // CAPIDoc serialization
00060
00061 void CAPIDoc::Serialize(CArchive& ar)
00062 {
00063   if (ar.IsStoring())
00064   {
00065     // TODO: add storing code here
00066   }
00067   else
00068   {
00069     // TODO: add loading code here
00070   }
00071 }
00072
00073 /////////////////////////////////////////////////////////////////////////////
00074 // CAPIDoc diagnostics
00075
00076 #ifdef _DEBUG
00077 void CAPIDoc::AssertValid() const
00078 {
00079   CDocument::AssertValid();
00080 }
00081
00082 void CAPIDoc::Dump(CDumpContext& dc) const
00083 {
00084   CDocument::Dump(dc);
00085 }
00086 #endif //_DEBUG
00087
00088 /////////////////////////////////////////////////////////////////////////////
00089 // CAPIDoc commands
00090
00091 void CAPIDoc::OnRunTest()
00092 {
00093   CServerDlg dlg;
00094   dlg.DoModal();
00095 }
00096
00097 void CAPIDoc::OnProcess()
00098 {
00099   CProcessDlg dlg;
00100   dlg.DoModal();
00101 }
00102
00103 void CAPIDoc::OnSession()
00104 {
00105   CSessionDlg dlg;
00106   dlg.DoModal();
00107 }
00108
00109 void CAPIDoc::OnShutdownSystem()
00110 {
00111   CShutdownDlg dlg;
00112   dlg.DoModal();
00113 }
00114
00115 void CAPIDoc::OnSendMessage()
00116 {
00117   CMessageDlg dlg;
00118   dlg.DoModal();
00119 }
00120
00121 void CAPIDoc::OnWaitEvent()
00122 {
00123   CWaitSystemDlg dlg;
00124   dlg.DoModal();
00125 }
00126
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/delebase.Cpp Source File

  • SysMgmt
  • MMC
  • Simple

delebase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021
00022 const GUID CDelegationBase::thisGuid = { 0x2974380b, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CDelegationBase implementation
00027 //
00028 //
00029 CDelegationBase::CDelegationBase()
00030 {
00031 }
00032
00033 CDelegationBase::~CDelegationBase()
00034 {
00035 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/addvfiledlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

addvfiledlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddVFileDlg.cpp:  Implementation of the CAddVFileDlg class.
00015 //
00016
00017
00018
00019 #include "AddVFileDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddVFileDlg::CAddVFileDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddVFileDlg::~CAddVFileDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddVFileDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00055
00056   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00057   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00060
00061   lResult = SetWindowText( hDevNameCtrl, _T("") );
00062   SetFocus( hDevNameCtrl );
00063
00064   return 0;
00065 }
00066
00067 //---------------------------------------------------------------------------
00068 LRESULT CAddVFileDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00069 {
00070   LRESULT          lResult = 0;
00071   NODE_PROPERTIES  NodeProps;
00072
00073   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00074
00075   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00076   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00077   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00078   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00079   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00080
00081   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00082     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00083
00084   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00086
00087   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00089
00090   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00092
00093   // Convert to wide characters here for all platforms.  This is the node name
00094   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00095   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00096   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00097   // Probably a good idea to check for NULL name strings here
00098
00099   // This message passes the user supplied info to the Static Node
00100   SendMessage( m_hParentWnd, WM_ADD_VIRTUALFILE, (WPARAM)&NodeProps, 0 );
00101
00102   // Now tell the static node we are deleting ourselves so the
00103   // context menu option can be enabled
00104   SendMessage( m_hParentWnd, WM_VIRTUALFILE_CLOSED, 0, 0 );
00105
00106   // Call the base class to shut down the dialog
00107   CBaseDialog::OnOK( hDlg, wParam, lParam );
00108   return 0;
00109 }
00110
00111 /////////////////////////////////////////////////////////////////////////////
00112 //  Virtual function implementations
00113
00114 //---------------------------------------------------------------------------
00115 BOOL CAddVFileDlg::ProcessMessage
00116 (
00117   HWND     hDlg,           //[in] Handle to dialog box
00118   UINT     uMsg,           //[in] Message
00119   WPARAM   wParam,         //[in] First message parameter
00120   LPARAM   lParam          //[in] Second message parameter
00121 )
00122 {
00123   LRESULT lResult = 0;
00124
00125   switch( uMsg )
00126   {
00127     case WM_INITDIALOG:
00128       lResult = OnInitDialog( hDlg, wParam, lParam );
00129       break;
00130
00131     case WM_DESTROY:
00132       lResult = OnDestroy( hDlg, wParam, lParam );
00133       break;
00134
00135     case WM_NCDESTROY:
00136       lResult = OnNcDestroy( hDlg, wParam, lParam );
00137       break;
00138
00139     case WM_CLOSE:
00140       // Not overriding WM_CLOSE and IDCANCEL so we must send
00141       // WM_DEVICENODE_CLOSED before calling the base class or else
00142       // the context menu will stay grayed
00143       SendMessage( m_hParentWnd, WM_VIRTUALFILE_CLOSED, 0, 0 );
00144       lResult = OnClose( hDlg, wParam, lParam );
00145
00146     case WM_COMMAND:
00147       switch( wParam )
00148       {
00149         case IDOK:
00150           lResult = OnOK( hDlg, wParam, lParam );
00151           break;
00152
00153         case IDCANCEL:
00154           SendMessage( m_hParentWnd, WM_VIRTUALFILE_CLOSED, 0, 0 );
00155           lResult = OnCancel( hDlg, wParam, lParam );
00156           break;
00157
00158         default:
00159           break;
00160       }
00161     default:
00162       break;
00163   }
00164   return (BOOL)lResult;
00165 }
00166
00167
00168
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagENUMLIST Member List

This is the complete list of members for tagENUMLIST, including all inherited members.
pidl | tagENUMLIST
pNext | tagENUMLIST
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/Resource.h Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

Resource.h

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      RESOURCE.H                                                    */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #define STATUS_ID                       10001
00010 #define TOOLBAR_ID                      10002
00011
00012
00013 #define IDC_STATIC                      -1
00014 #define IDB_BMP                         700 // Bitmap ID for the toolbar.
00015
00016 #define IDM_FONT                        10001
00017 #define IDM_ABOUT                       10002
00018
00019 #define IDM_OPENSTATUS                  10010
00020
00021 #define IDM_NATIVEMODE                  10011
00022 #define IDM_FULLHALF                    10012
00023 #define IDM_ROMAN                       10013
00024 #define IDM_CHARCODE                    10014
00025 #define IDM_HANJA                       10015
00026 #define IDM_SOFTKBD                     10016
00027 #define IDM_EUDC                        10017
00028 #define IDM_SYMBOL                      10018
00029
00030 #define IDM_CONVERT                     10020
00031 #define IDM_CANCEL                      10021
00032 #define IDM_REVERT                      10022
00033 #define IDM_COMPLETE                    10023
00034 #define IDM_SHOWCAND                    10024
00035 #define IDM_OPENCAND                    10025
00036 #define IDM_CLOSECAND                   10026
00037 #define IDM_NEXTCAND                    10027
00038 #define IDM_PREVCAND                    10028
00039 #define IDM_NEXTCLAUSE                  10029
00040 #define IDM_PREVCLAUSE                  10030
00041
00042 #define IDM_STARTIMEMENU                20000
00043
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ADCPROP_AUTORECALC_ENUM.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ADCPROP_AUTORECALC_ENUM.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ADCPROP_AUTORECALC_ENUM
00019
00020 public class ADCPROP_AUTORECALC_ENUM extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adRecalcUpFront = 0;
00023   public static final short adRecalcAlways = 1;
00024 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqTestOA/MqTestOA.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqTestOA

MqTestOA.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012
00013 //
00014 // Includes
00015 //
00016 #include <stdio.h>
00017 #include <windows.h>
00018
00019 //
00020 // Unique include file for ActiveX MSMQ applications
00021 //
00022 #include <mqoai.h>
00023
00024 //
00025 // Various defines
00026 //
00027 #define MAX_VAR       20
00028 #define MAX_BUFFER   500
00029
00030 //
00031 // GUID created with the tool "GUIDGEN"
00032 //
00033 static WCHAR strGuidMQTestType[] =
00034   L"{c30e0960-a2c0-11cf-9785-00608cb3e80c}";
00035 //
00036 // Prototypes
00037 //
00038 void PrintError(char *s, HRESULT hr);
00039 HRESULT Syntax();
00040
00041 char mbsMachineName[MAX_COMPUTERNAME_LENGTH + 1];
00042
00043 // Some useful macros
00044 #define RELEASE(punk) if (punk) { (punk)->Release(); (punk) = NULL; }
00045 #define ADDREF(punk) ((punk) ? (punk)->AddRef() : 0)
00046 #define PRINTERROR(s, hr) { PrintError(s, hr); goto Cleanup; }
00047
00048
00049 //-----------------------------------------------------
00050 //
00051 // Check whether the local computer is enabled to
00052 // access the directory service (DS-enabled).
00053 //
00054 //-----------------------------------------------------
00055 short DetectDsConnection(void)
00056 {
00057     IMSMQApplication2 *pqapp = NULL;
00058     short fDsConnection;
00059     HRESULT hresult;
00060
00061     hresult = CoCreateInstance(
00062                    CLSID_MSMQApplication,
00063                    NULL,      // punkOuter
00064                    CLSCTX_SERVER,
00065                    IID_IMSMQApplication2,
00066                    (LPVOID *)&pqapp);
00067
00068     if (FAILED(hresult))
00069   {
00070     printf("The attempt to create an MSMQApplication object failed (0x%X). Exiting...\n", hresult);
00071     RELEASE(pqapp);
00072     exit(1);
00073   }
00074
00075     pqapp->get_IsDsEnabled(&fDsConnection);
00076     RELEASE(pqapp);
00077     return fDsConnection;
00078 }
00079
00080
00081 //-----------------------------------------------------
00082 //
00083 //  Allow a DS-enabled client to connect to a
00084 //  DS-disabled one.
00085 //
00086 //-----------------------------------------------------
00087 bool SetConnectionMode(void)
00088 {
00089
00090     char cDirectMode;
00091
00092
00093     //
00094     // If the local computer is in a domain and not in workgroup mode,
00095     // we have two cases:
00096     //   1. Other side is a computer in a domain.
00097     //   2. Other side is a computer working in workgroup mode.
00098     //
00099
00100     if(DetectDsConnection() != 0)
00101     {
00102             printf("Do you want to connect to a DS-disabled computer (Y or N) ? ");
00103
00104       int iRes = scanf("%c", &cDirectMode);
00105       if (iRes == 0 || iRes == EOF)
00106       {
00107         printf("\nInvalid input was entered.\n");
00108         exit(1);
00109       }
00110
00111             switch(tolower(cDirectMode))
00112             {
00113                 case 'y':
00114                     return true;
00115
00116                 case 'n':
00117                     return false;
00118
00119                 default:
00120                     printf("Bye.\n");
00121                     exit(1);
00122             }
00123
00124     }
00125
00126     return true;     // Local computer is DS-disabled.
00127 }
00128
00129
00130
00131 //--------------------------------------------------------
00132 //
00133 // Receiver Mode
00134 // -------------
00135 // The receiver side does the following:
00136 //    1. Creates a local queue of type "guidMQTestType".
00137 //       The queue is either public or private, depending
00138 //       on the connection that we want to establish.
00139 //    2. Opens the queue.
00140 //    3. In a loop,
00141 //          receives messages and
00142 //          prints the message body and message label.
00143 //    4. Closes the handle to the queue.
00144 //    5. Deletes the queue from the directory service.
00145 //
00146 //--------------------------------------------------------
00147
00148 HRESULT Receiver(bool fDirectMode)
00149 {
00150     IMSMQMessage *pmessageReceive = NULL;
00151     IMSMQQueue *pqReceive = NULL;
00152     IMSMQQueueInfo  *pqinfo = NULL;
00153     BSTR bstrPathName = NULL;
00154     BSTR bstrServiceType = NULL;
00155     BSTR bstrLabel = NULL;
00156     BSTR bstrMsgLabel = NULL;
00157     VARIANT varIsTransactional, varIsWorldReadable, varBody, varBody2, varWantDestQueue, varWantBody, varReceiveTimeout;
00158
00159   WCHAR wcsPathName[MAX_COMPUTERNAME_LENGTH +100];
00160
00161   BOOL fQuit = FALSE;
00162     HRESULT hresult = NOERROR;
00163
00164     printf("\nReceiver Mode on Machine: %s\n\n", mbsMachineName);
00165
00166     //
00167     // Create an MSMQQueueInfo object.
00168     //
00169     hresult = CoCreateInstance(
00170                    CLSID_MSMQQueueInfo,
00171                    NULL,      // punkOuter
00172                    CLSCTX_SERVER,
00173                    IID_IMSMQQueueInfo,
00174                    (LPVOID *)&pqinfo);
00175     if (FAILED(hresult)) {
00176       PRINTERROR("The queue cannot be created", hresult);
00177     }
00178
00179     //
00180     // Prepare properties for creating a queue on the local computer.
00181     //
00182
00183     // Set the path name.
00184     if(fDirectMode)             // Private queue path name
00185     {
00186     if(_snwprintf(wcsPathName,(sizeof(wcsPathName)/sizeof(wcsPathName[0]))-1,
00187     L"%S\\private$\\MSMQTest", mbsMachineName) < 0)
00188     {
00189       // overflow
00190       PRINTERROR("Path name creation failed", hresult);
00191     }
00192     else
00193     {
00194       wcsPathName[(sizeof(wcsPathName)/sizeof(wcsPathName[0]))-1] = L'\0';
00195     }
00196
00197     }
00198     else                       // Public queue path name
00199     {
00200     if(_snwprintf(wcsPathName,(sizeof(wcsPathName)/sizeof(wcsPathName[0]))-1,
00201     L"%S\\MSMQTest", mbsMachineName) < 0)
00202     {
00203       // Overflow occurred.
00204       PRINTERROR("Path name creation failed", hresult);
00205     }
00206     else
00207     {
00208       wcsPathName[(sizeof(wcsPathName)/sizeof(wcsPathName[0]))-1] = L'\0';
00209     }
00210
00211     }
00212
00213     bstrPathName = SysAllocString(wcsPathName);
00214     if (bstrPathName == NULL) {
00215       PRINTERROR("OOM: pathname", E_OUTOFMEMORY);
00216     }
00217     pqinfo->put_PathName(bstrPathName);
00218
00219     //
00220     // Set the type of the queue.
00221     // (This property will be used to locate all the queues of this type.)
00222     //
00223     bstrServiceType = SysAllocString(strGuidMQTestType);
00224     if (bstrServiceType == NULL) {
00225       PRINTERROR("OOM: ServiceType", E_OUTOFMEMORY);
00226     }
00227     pqinfo->put_ServiceTypeGuid(bstrServiceType);
00228
00229     //
00230     // Add a descriptive label to the queue.
00231     // (This property is useful for administration through the MSMQ admin tools.)
00232     //
00233     bstrLabel =
00234       SysAllocString(L"Sample ActiveX application of MSMQ SDK");
00235     if (bstrLabel == NULL) {
00236       PRINTERROR("OOM: label ", E_OUTOFMEMORY);
00237     }
00238     pqinfo->put_Label(bstrLabel);
00239
00240     //
00241     // Specify whether the queue is transactional.
00242     //
00243     VariantInit(&varIsTransactional);
00244     varIsTransactional.vt = VT_BOOL;
00245     varIsTransactional.boolVal = MQ_TRANSACTIONAL_NONE;
00246     VariantInit(&varIsWorldReadable);
00247     varIsWorldReadable.vt = VT_BOOL;
00248     varIsWorldReadable.boolVal = FALSE;
00249     //
00250     // Create the queue.
00251     //
00252     hresult = pqinfo->Create(&varIsTransactional, &varIsWorldReadable);
00253     if (FAILED(hresult)) {
00254       //
00255       // The API failed, but not because the queue exists.
00256       //
00257       if (hresult != MQ_ERROR_QUEUE_EXISTS)
00258         PRINTERROR("The queue cannot be created", hresult);
00259     }
00260
00261     //
00262     // Open the queue with receive access.
00263     //
00264     hresult = pqinfo->Open(MQ_RECEIVE_ACCESS,
00265                            MQ_DENY_NONE,
00266                            &pqReceive);
00267
00268     //
00269     // Things are a little bit tricky. MQCreateQueue succeeded, but in the
00270     // case of a public queue, this does not mean that MQOpenQueue
00271     // will succeed, because replication delays are possible. The queue is
00272     // registered in the DS, but it might take a replication interval
00273     // until the replica reaches the server that I am connected to.
00274     // To overcome this, open the queue in a loop.
00275     //
00276     // In this specific case, this can happen only if this program
00277     // is run on an MSMQ 1.0 backup server controller (BSC) or on
00278     // a client connected to a BSC.
00279     // To be totally on the safe side, we should have put some code
00280     // to exit the loop after a few retries, but this is just a sample.
00281     //
00282     while (hresult == MQ_ERROR_QUEUE_NOT_FOUND) {
00283       printf(".");
00284
00285       // Wait a bit.
00286       Sleep(500);
00287
00288       // Retry.
00289       hresult = pqinfo->Open(MQ_RECEIVE_ACCESS,
00290                              MQ_DENY_NONE,
00291                              &pqReceive);
00292     }
00293     if (FAILED(hresult)) {
00294       PRINTERROR("The queue cannot be opened", hresult);
00295     }
00296
00297     //
00298     // Main receiver loop
00299     //
00300     printf("\nWaiting for messages...\n");
00301     while (!fQuit) {
00302       //
00303       // Receive the message.
00304       //
00305       VariantInit(&varWantDestQueue);
00306       VariantInit(&varWantBody);
00307       VariantInit(&varReceiveTimeout);
00308       varWantDestQueue.vt = VT_BOOL;
00309       varWantDestQueue.boolVal = TRUE;    // Yes, we want the destination queue.
00310       varWantBody.vt = VT_BOOL;
00311       varWantBody.boolVal = TRUE;         // Yes, we want the message body.
00312       varReceiveTimeout.vt = VT_I4;
00313       varReceiveTimeout.lVal = INFINITE;  // Infinite time-out
00314       hresult = pqReceive->Receive(
00315                   NULL,
00316                   &varWantDestQueue,
00317                   &varWantBody,
00318                   &varReceiveTimeout,
00319                   &pmessageReceive);
00320       if (FAILED(hresult)) {
00321         PRINTERROR("Receive failed", hresult);
00322       }
00323
00324       //
00325       // Display the received message.
00326       //
00327       pmessageReceive->get_Label(&bstrMsgLabel);
00328       VariantInit(&varBody);
00329       VariantInit(&varBody2);
00330       hresult = pmessageReceive->get_Body(&varBody);
00331       if (FAILED(hresult)) {
00332         PRINTERROR("The message body cannot be retrieved", hresult);
00333       }
00334       hresult = VariantChangeType(&varBody2,
00335                                   &varBody,
00336                                   0,
00337                                   VT_BSTR);
00338       if (FAILED(hresult)) {
00339         PRINTERROR("The message body cannot be converted to a string", hresult);
00340       }
00341       printf("%S : %s\n", bstrMsgLabel, (char *)V_BSTR(&varBody2));
00342       //
00343       // Check for a request to end the application.
00344       //
00345       if (stricmp((char *)V_BSTR(&varBody2), "quit") == 0) {
00346         fQuit = TRUE;
00347       }
00348
00349       VariantClear(&varBody);
00350       VariantClear(&varBody2);
00351
00352       //
00353       // Release the current message.
00354       //
00355       RELEASE(pmessageReceive);
00356     } /* while (!fQuit) */
00357
00358     //
00359     // Cleanup: Close the handle to the queue.
00360     //
00361     pqReceive->Close();
00362     if (FAILED(hresult)) {
00363       PRINTERROR("The queue cannot be closed", hresult);
00364     }
00365
00366     //
00367     // In the concluding stage, we delete the queue from the directory
00368     // service. (We don't need to do this. In case of a public queue,
00369     // leaving it in the DS enables sender applications to send messages
00370     // even if the receiver is not available.)
00371     //
00372     hresult = pqinfo->Delete();
00373     if (FAILED(hresult)) {
00374       PRINTERROR("The queue cannot be deleted", hresult);
00375     }
00376     // Fall through...
00377
00378 Cleanup:
00379     SysFreeString(bstrPathName);
00380     SysFreeString(bstrMsgLabel);
00381     SysFreeString(bstrServiceType);
00382     SysFreeString(bstrLabel);
00383     RELEASE(pmessageReceive);
00384     RELEASE(pqReceive);
00385     RELEASE(pqinfo);
00386     return hresult;
00387 }
00388
00389
00390
00391 //-----------------------------------------------------
00392 //
00393 // Sender Mode
00394 // -----------
00395 // The sender side does the following:
00396 //
00397 //    In domain (standard) mode:
00398 //    1. Locates all queues of type "guidMQTestType."
00399 //    2. Opens handles to all the queues.
00400 //    3. In a loop,
00401 //          sends messages to all those queues.
00402 //    4. Cleans up handles.
00403 //
00404 //    If we work in workgroup (direct) mode:
00405 //    1. Opens a handle to a private queue labeled
00406 //       "MSMQTest" on the computer specified.
00407 //    2. Sends messages to that queue.
00408 //    3. Cleans up handles.
00409 //-----------------------------------------------------
00410
00411
00412 //-----------------------------------------------------
00413 //
00414 // Sender in domain (standard) mode
00415 //
00416 //-----------------------------------------------------
00417 HRESULT StandardSender()
00418 {
00419     IMSMQQuery *pquery = NULL;
00420     IMSMQQueueInfo *rgpqinfo[MAX_VAR];
00421     IMSMQQueue *rgpqSend[MAX_VAR];
00422     IMSMQQueueInfo *pqinfo = NULL;
00423     IMSMQQueueInfos *pqinfos = NULL;
00424     IMSMQMessage *pmessage = NULL;
00425     char szBuffer[MAX_BUFFER] = {0};
00426     WCHAR wcsMsgLabel[MQ_MAX_MSG_LABEL_LEN] = {0};
00427     BSTR bstrServiceType = NULL;
00428     BSTR bstrLabel = NULL;
00429     BSTR bstrBody = NULL;
00430     VARIANT varBody;
00431     DWORD i;
00432     DWORD cQueue = 0;
00433     HRESULT hresult = NOERROR;
00434
00435     printf("\nSender mode on the computer %s\n\n", mbsMachineName);
00436
00437     //
00438     // Create query object for lookup.
00439     //
00440     hresult = CoCreateInstance(
00441                    CLSID_MSMQQuery,
00442                    NULL,      // punkOuter
00443                    CLSCTX_SERVER,
00444                    IID_IMSMQQuery,
00445                    (LPVOID *)&pquery);
00446     if (FAILED(hresult)) {
00447       PRINTERROR("A query object cannot be created", hresult);
00448     }
00449
00450     //
00451     // Prepare parameters to locate all queues that
00452     // have the test service type GUID.
00453     //
00454     VARIANT varGuidQueue;
00455     VARIANT varStrLabel;
00456     VARIANT varGuidServiceType;
00457     VARIANT varRelServiceType;
00458     VARIANT varRelLabel;
00459     VARIANT varCreateTime;
00460     VARIANT varModifyTime;
00461     VARIANT varRelCreateTime;
00462     VARIANT varRelModifyTime;
00463
00464     VariantInit(&varGuidQueue);
00465     VariantInit(&varStrLabel);
00466     VariantInit(&varGuidServiceType);
00467     VariantInit(&varRelServiceType);
00468     VariantInit(&varRelLabel);
00469     VariantInit(&varCreateTime);
00470     VariantInit(&varModifyTime);
00471     VariantInit(&varRelCreateTime);
00472     VariantInit(&varRelModifyTime);
00473
00474     //
00475     // We only want to specify the service type GUID, so we
00476     // set the other variant parameters to VT_ERROR to simulate
00477     // "missing," i.e. optional, parameters.
00478     //
00479     V_VT(&varGuidQueue) = VT_ERROR;
00480     V_VT(&varStrLabel) = VT_ERROR;
00481     V_VT(&varRelServiceType) = VT_ERROR;
00482     V_VT(&varRelLabel) = VT_ERROR;
00483     V_VT(&varCreateTime) = VT_ERROR;
00484     V_VT(&varModifyTime) = VT_ERROR;
00485     V_VT(&varRelCreateTime) = VT_ERROR;
00486     V_VT(&varRelModifyTime) = VT_ERROR;
00487     bstrServiceType = SysAllocString(strGuidMQTestType);
00488     if (bstrServiceType == NULL) {
00489       PRINTERROR("OOM: Service Type GUID", E_OUTOFMEMORY);
00490     }
00491     V_VT(&varGuidServiceType) = VT_BSTR;
00492     V_BSTR(&varGuidServiceType) = bstrServiceType;
00493
00494     hresult = pquery->LookupQueue(&varGuidQueue,
00495                                   &varGuidServiceType,
00496                                   &varStrLabel,
00497                                   &varCreateTime,
00498                                   &varModifyTime,
00499                                   &varRelServiceType,
00500                                   &varRelLabel,
00501                                   &varRelCreateTime,
00502                                   &varRelModifyTime,
00503                                   &pqinfos);
00504     if (FAILED(hresult)) {
00505       PRINTERROR("LookupQueue failed", hresult);
00506     }
00507
00508     //
00509     // Reset the queue collection object.
00510     //
00511     hresult = pqinfos->Reset();
00512     if (FAILED(hresult)) {
00513       PRINTERROR("Reset failed", hresult);
00514     }
00515
00516     //
00517     // Open each of the queues found.
00518     //
00519     cQueue = 0;
00520     hresult = pqinfos->Next(&rgpqinfo[cQueue]);
00521     if (FAILED(hresult)) {
00522       PRINTERROR("Next failed", hresult);
00523     }
00524     pqinfo = rgpqinfo[cQueue];
00525     while (pqinfo) {
00526       //
00527       // Open the queue with send access.
00528       //
00529
00530       hresult = pqinfo->Open(
00531                   MQ_SEND_ACCESS,
00532                   MQ_DENY_NONE,
00533                   &rgpqSend[cQueue]);
00534       if (FAILED(hresult)) {
00535         PRINTERROR("Open failed", hresult);
00536       }
00537
00538     cQueue++;
00539       hresult = pqinfos->Next(&rgpqinfo[cQueue]);
00540       if (FAILED(hresult)) {
00541         PRINTERROR("Next failed", hresult);
00542       }
00543       pqinfo = rgpqinfo[cQueue];
00544     }
00545
00546     if (cQueue == 0) {
00547       //
00548       // No queue could be found, so exit.
00549       //
00550       PRINTERROR("No queue is registered", hresult = E_INVALIDARG);
00551     }
00552     printf("\tQueue(s) found: %d\n", cQueue);
00553     printf("\nEnter \"quit\" to exit.\n");
00554
00555     //
00556     // Build the message label property.
00557     //
00558
00559   if(_snwprintf(wcsMsgLabel,(sizeof(wcsMsgLabel)/sizeof(wcsMsgLabel[0]))-1,
00560     L"Message from %S", mbsMachineName) < 0)
00561   {
00562     // overflow
00563     PRINTERROR("Label creation failed", hresult);
00564   }
00565   else
00566   {
00567     wcsMsgLabel[(sizeof(wcsMsgLabel)/sizeof(wcsMsgLabel[0]))-1] = L'\0';
00568   }
00569
00570
00571
00572
00573
00574
00575     bstrLabel = SysAllocString(wcsMsgLabel);
00576     if (bstrLabel == NULL)
00577         PRINTERROR("OOM: label", E_OUTOFMEMORY);
00578
00579     fflush(stdin);
00580     //
00581     // Main sender loop
00582     //
00583     while (1) {
00584       //
00585       // Get a string from the console.
00586       //
00587       printf("Enter a string: ");
00588       if (fgets(szBuffer, MAX_BUFFER - 1, stdin) == NULL)
00589         break;
00590
00591       szBuffer[MAX_BUFFER - 1] = '\0';
00592
00593     //
00594     // Delete the new-line character from the string.
00595     //
00596     if(szBuffer[strlen(szBuffer) - 1] == '\n')
00597     {
00598
00599     szBuffer[strlen(szBuffer) - 1] = '\0';
00600
00601     }
00602
00603
00604       //
00605       // Create a message object.
00606       //
00607       hresult = CoCreateInstance(
00608                      CLSID_MSMQMessage,
00609                      NULL,      // punkOuter
00610                      CLSCTX_SERVER,
00611                      IID_IMSMQMessage,
00612                      (LPVOID *)&pmessage);
00613       //
00614       // Send the message to all the queues.
00615       //
00616       for (i = 0; i < cQueue; i++)
00617       {
00618         hresult = pmessage->put_Label(bstrLabel);
00619
00620         //
00621         // This isn't a "true" Unicode string, of course.
00622         //
00623         bstrBody = SysAllocStringByteLen(szBuffer, strlen(szBuffer) + 1);
00624         if (bstrBody == NULL) {
00625           PRINTERROR("OOM: message body", E_OUTOFMEMORY);
00626         }
00627         VariantInit(&varBody);
00628         V_VT(&varBody) = VT_BSTR;
00629         V_BSTR(&varBody) = bstrBody;
00630         hresult = pmessage->put_Body(varBody);
00631         if (FAILED(hresult)) {
00632           PRINTERROR("put_body failed", hresult);
00633         }
00634         hresult = pmessage->Send(rgpqSend[i], NULL);
00635         if (FAILED(hresult)) {
00636           PRINTERROR("Send failed", hresult);
00637         }
00638         VariantClear(&varBody);
00639         bstrBody = NULL;
00640       }
00641       RELEASE(pmessage);
00642
00643       //
00644       // Check for a request to end the application.
00645       //
00646       if (stricmp(szBuffer, "quit") == 0)
00647         break;
00648     } /* while (1) */
00649
00650
00651
00652 Cleanup:
00653     //
00654     // Close and release all the queues.
00655     //
00656     for (i = 0; i < cQueue; i++) {
00657       rgpqSend[i]->Close();
00658       rgpqSend[i]->Release();
00659       rgpqinfo[i]->Release();
00660     }
00661     RELEASE(pqinfos);
00662     RELEASE(pquery);
00663     RELEASE(pmessage);
00664     SysFreeString(bstrLabel);
00665     SysFreeString(bstrBody);
00666     SysFreeString(bstrServiceType);
00667     return hresult;
00668 }
00669
00670
00671 //-----------------------------------------------------
00672 //
00673 // Sender in direct (workgroup) mode
00674 //
00675 //-----------------------------------------------------
00676 HRESULT DirectSender(void)
00677 {
00678     IMSMQQueue *rgpqSend = NULL;
00679     IMSMQQueueInfo *pqinfo = NULL;
00680     IMSMQMessage *pmessage = NULL;
00681     char szBuffer[MAX_BUFFER];
00682     WCHAR wcsMsgLabel[MQ_MAX_MSG_LABEL_LEN] = {0};
00683
00684     WCHAR wcsFormat[MAX_BUFFER + 100] = {0};
00685   WCHAR wcsReceiverComputer[MAX_BUFFER] = {0};
00686     BSTR bstrFormat = NULL;
00687     BSTR bstrServiceType = NULL;
00688     BSTR bstrLabel = NULL;
00689     BSTR bstrBody = NULL;
00690     VARIANT varBody;
00691     DWORD cQueue = 0;
00692     HRESULT hresult = NOERROR;
00693
00694
00695     //
00696     // Get the receiver computer name.
00697     //
00698
00699   //
00700   // Flushing stdin to get rid of the new-line character entered earlier.
00701   //
00702   fflush(stdin);
00703     printf("\nEnter receiver computer name: ");
00704
00705   if (fgetws(wcsReceiverComputer, MAX_BUFFER - 1, stdin) == NULL)
00706         return E_INVALIDARG;
00707
00708   if(wcsReceiverComputer[wcslen(wcsReceiverComputer) - 1] == L'\n')
00709     wcsReceiverComputer[wcslen(wcsReceiverComputer) - 1] = L'\0';
00710
00711
00712   if(wcsReceiverComputer[0] == 0)
00713     {
00714         printf("You have entered an incorrect parameter. Exiting...\n");
00715         return E_INVALIDARG;
00716     }
00717
00718     hresult = CoCreateInstance(
00719                CLSID_MSMQQueueInfo,
00720                NULL,      // punkOuter
00721                CLSCTX_SERVER,
00722                IID_IMSMQQueueInfo,
00723                (LPVOID *)&pqinfo);
00724     if (FAILED(hresult))
00725       PRINTERROR("The queue cannot be opened", hresult);
00726
00727   if(_snwprintf(wcsFormat, (sizeof(wcsFormat)/sizeof(wcsFormat[0])) - 1,
00728   L"DIRECT=OS:%s\\private$\\MSMQTest", wcsReceiverComputer) < 0)
00729   {
00730     // Overflow occurred.
00731     PRINTERROR("The receiver format name is too long for the buffer specified", hresult);
00732   }
00733   else
00734   {
00735     wcsFormat[(sizeof(wcsFormat)/sizeof(wcsFormat[0])) - 1] = L'\0';
00736   }
00737
00738     bstrFormat = SysAllocString(wcsFormat);
00739     hresult = pqinfo->put_FormatName(bstrFormat);
00740     if (FAILED(hresult))
00741         PRINTERROR("Open failed", hresult);
00742
00743     //
00744     // Open the queue with send access.
00745     //
00746     hresult = pqinfo->Open(
00747               MQ_SEND_ACCESS,
00748               MQ_DENY_NONE,
00749               &rgpqSend);
00750
00751
00752     if (FAILED(hresult))
00753         PRINTERROR("Open failed", hresult);
00754
00755     printf("\nSender mode on the computer %s.\n\n", mbsMachineName);
00756     printf("\nEnter \"quit\" to exit.\n");
00757
00758
00759     //
00760     // Build the message label property.
00761     //
00762
00763   if(_snwprintf(wcsMsgLabel,(sizeof(wcsMsgLabel)/sizeof(wcsMsgLabel[0])) - 1,
00764     L"Message from %S", mbsMachineName) < 0)
00765   {
00766     // Overflow occurred.
00767     PRINTERROR("Label creation failed", hresult);
00768   }
00769   else
00770   {
00771     wcsMsgLabel[(sizeof(wcsMsgLabel)/sizeof(wcsMsgLabel[0])) - 1] = L'\0';
00772   }
00773
00774
00775   bstrLabel = SysAllocString(wcsMsgLabel);
00776     if (bstrLabel == NULL)
00777         PRINTERROR("OOM: label", E_OUTOFMEMORY);
00778
00779
00780     fflush(stdin);
00781     //
00782     // Main sender loop.
00783     //
00784     while (1)
00785     {
00786         //
00787         // Get a string from the console.
00788         //
00789         printf("Enter a string: ");
00790         if (fgets(szBuffer,sizeof(szBuffer) - 1, stdin) == NULL)
00791       break;
00792
00793     if(szBuffer[strlen(szBuffer) - 1] == '\n')
00794     {
00795
00796       szBuffer[strlen(szBuffer) - 1] = '\0';
00797
00798     }
00799
00800     //
00801         // Create a message object.
00802         //
00803         hresult = CoCreateInstance(
00804                      CLSID_MSMQMessage,
00805                      NULL,      // punkOuter
00806                      CLSCTX_SERVER,
00807                      IID_IMSMQMessage,
00808                      (LPVOID *)&pmessage);
00809         //
00810         // Send the message.
00811         //
00812
00813         hresult = pmessage->put_Label(bstrLabel);
00814
00815         bstrBody = SysAllocStringByteLen(szBuffer, strlen(szBuffer) + 1);
00816         if (bstrBody == NULL)
00817           PRINTERROR("OOM: body", E_OUTOFMEMORY);
00818
00819         VariantInit(&varBody);
00820         V_VT(&varBody) = VT_BSTR;
00821         V_BSTR(&varBody) = bstrBody;
00822         hresult = pmessage->put_Body(varBody);
00823         if (FAILED(hresult))
00824           PRINTERROR("put_body failed", hresult);
00825
00826         hresult = pmessage->Send(rgpqSend, NULL);
00827         if (FAILED(hresult))
00828           PRINTERROR("Send failed", hresult);
00829
00830         VariantClear(&varBody);
00831         bstrBody = NULL;
00832
00833         RELEASE(pmessage);
00834
00835         //
00836         // Check for a request to end teh application.
00837         //
00838         if (stricmp(szBuffer, "quit") == 0)
00839         break;
00840     } /* while (1) */
00841
00842
00843
00844 Cleanup:
00845   if(rgpqSend != NULL)
00846   {
00847     rgpqSend->Close();
00848     rgpqSend->Release();
00849     }
00850
00851     RELEASE(pqinfo);
00852     RELEASE(pmessage);
00853     SysFreeString(bstrFormat);
00854     SysFreeString(bstrLabel);
00855     SysFreeString(bstrBody);
00856     SysFreeString(bstrServiceType);
00857     return hresult;
00858 }
00859
00860
00861
00862 //------------------------------------------------------
00863 //
00864 // Sender function
00865 //
00866 //------------------------------------------------------
00867 HRESULT Sender(int fDirectMode)
00868 {
00869
00870     if(fDirectMode != 0)
00871         return DirectSender();
00872
00873     else
00874         return StandardSender();
00875 }
00876
00877
00878 //-----------------------------------------------------
00879 //
00880 //  MAIN
00881 //
00882 //-----------------------------------------------------
00883 int main(int argc, char * * argv)
00884 {
00885     DWORD dwNumChars;
00886     HRESULT hresult = NOERROR;
00887     bool fDirectMode;
00888
00889     if (argc != 2)
00890       return Syntax();
00891
00892     hresult = OleInitialize(NULL);
00893     if (FAILED(hresult))
00894       PRINTERROR("OLE cannot be initialized", hresult);
00895
00896     //
00897     // Retrieve the computer name.
00898     //
00899     dwNumChars = MAX_COMPUTERNAME_LENGTH;
00900     if(!GetComputerNameA(mbsMachineName, &dwNumChars))
00901   {
00902     printf("The computer name cannot be obtained. Exiting...\n");
00903     exit(1);
00904   }
00905     //
00906     // Detect DS connection and working mode.
00907     //
00908     fDirectMode = SetConnectionMode();
00909
00910
00911     if (strcmp(argv[1], "-s") == 0)
00912       hresult = Sender(fDirectMode);
00913
00914     else if (strcmp(argv[1], "-r") == 0)
00915       hresult = Receiver(fDirectMode);
00916
00917     else
00918       hresult = Syntax();
00919
00920     printf("\nOK\n");
00921
00922     // Fall through...
00923
00924
00925 Cleanup:
00926     return (int)hresult;
00927 }
00928
00929
00930 void PrintError(char *s, HRESULT hr)
00931 {
00932     printf("%s (0x%X). Exiting...\n", s, hr);
00933 }
00934
00935
00936 HRESULT Syntax()
00937 {
00938     printf("\n");
00939     printf("Syntax: mqtestoa -s | -r\n");
00940     printf("\t-s: Sender\n");
00941     printf("\t-r: Receiver\n");
00942     return E_INVALIDARG;
00943 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/rowchng.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

rowchng.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module ROWCHNG.CPP | IRowsetChange interface implementation
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014
00015 // Code ----------------------------------------------------------------------
00016
00017
00018
00019
00020 //  IRowsetChange specific methods
00021
00022 // CImpIRowsetChange::SetData ------------------------------------------------
00023 //
00024 // @mfunc Sets new data values into fields of a row.
00025 //
00026 // @rdesc HRESULT
00027 //      @flag S_OK                   | The method succeeded
00028 //      @flag E_OUTOFMEMORY          | Out of memory
00029 //      @flag DB_E_BADACCESSORHANDLE | Bad accessor handle
00030 //      @flag DB_E_READONLYACCESSOR  | Tried to write through a read-only accessor
00031 //      @flag DB_E_BADROWHANDLE      | Invalid row handle
00032 //      @flag E_INVALIDARG           | pData was NULL
00033 //      @flag E_FAIL                 | Provider-specific error
00034 //      @flag OTHER                  | Other HRESULTs returned by called functions
00035 //
00036 STDMETHODIMP CImpIRowsetChange::SetData
00037     (
00038     HROW        hRow,       //@parm IN | Handle of the row in which to set the data
00039     HACCESSOR   hAccessor,  //@parm IN | Handle to the accessor to use
00040     void*   pData       //@parm IN | Pointer to the data
00041     )
00042 {
00043     DBORDINAL       cCols;
00044   DBCOUNTITEM   cBind;
00045     BYTE*           pbProvRow;
00046     HRESULT         hr;
00047     DBCOUNTITEM     cBindings;
00048     DBBINDING*      pBinding;
00049     DBCOUNTITEM     cErrorCount;
00050     DBTYPE          dwSrcType;
00051     DBTYPE          dwDstType;
00052     DWORD           dwPart;
00053     ULONG           dwSrcLength;
00054     DWORD           dwSrcStatus;
00055     void*           pSrc;
00056     void*           pDst;
00057     DBLENGTH*   pdwDstLength;
00058     DBLENGTH        cbDstMaxLength;
00059     DWORD*          pdwDstStatus;
00060     PCOLUMNDATA     pColumnData;
00061     PACCESSOR       paccessor = NULL;
00062     BYTE*           rgbRowDataSave = NULL;
00063   DBCOLUMNINFO *  rgdbcolumninfo = NULL;
00064
00065     // Is row handle right?
00066     assert( m_pObj->m_prowbitsIBuffer );
00067     if( (m_pObj->m_prowbitsIBuffer)->IsSlotSet( (ULONG)hRow ) != S_OK )
00068         return( DB_E_BADROWHANDLE );
00069
00070     // Check the Accessor Handle
00071     assert( m_pObj->m_pextbufferAccessor );
00072   if( FAILED(m_pObj->m_pextbufferAccessor->GetItemOfExtBuffer(hAccessor, &paccessor)))
00073         return( DB_E_BADACCESSORHANDLE );
00074
00075     // Ensure a source of data.
00076     assert( paccessor );
00077     if( paccessor->cBindings && !pData )
00078         return( E_INVALIDARG );
00079
00080     pbProvRow = (BYTE *)(m_pObj->GetRowBuff((DBCOUNTITEM) hRow, TRUE ));
00081
00082     // Is row handle deleted?
00083     if( m_pObj->m_pFileio->IsDeleted((DBBKMARK) ((PROWBUFF) pbProvRow)->pbBmk ) == S_OK )
00084         return( DB_E_DELETEDROW );
00085
00086     rgbRowDataSave = (BYTE *) malloc( m_pObj->m_cbTotalRowSize );
00087     if( !rgbRowDataSave )
00088         return( E_OUTOFMEMORY );
00089
00090     // Save the row.
00091     memcpy( rgbRowDataSave, pbProvRow, m_pObj->m_cbTotalRowSize );
00092
00093     cBindings = paccessor->cBindings;
00094     pBinding  = paccessor->rgBindings;
00095
00096     // Apply accessor to data.
00097   rgdbcolumninfo = m_pObj->m_pFileio->GetColInfo();
00098     for (cBind = 0, cErrorCount = 0; cBind < cBindings; cBind++)
00099   {
00100         cCols = pBinding[cBind].iOrdinal;
00101
00102         // make sure column number is in range
00103         if( cCols < 1 || cCols > m_pObj->m_cCols )
00104             return( DB_E_BADORDINAL );
00105
00106     pColumnData    = m_pObj->m_pFileio->GetColumnData(cCols, (ROWBUFF *)pbProvRow);
00107
00108         dwSrcType      = pBinding[cBind].wType;
00109         pDst           = &(pColumnData->bData);
00110         pdwDstLength   = (DBBYTEOFFSET *) &(pColumnData->dwLength);
00111         pdwDstStatus   = &(pColumnData->dwStatus);
00112         cbDstMaxLength = pBinding[cBind].cbMaxLen;
00113
00114         dwPart         = pBinding[cBind].dwPart;
00115         dwDstType      = rgdbcolumninfo[cCols].wType;
00116
00117         // Get the Length
00118     if( dwPart & DBPART_LENGTH )
00119       dwSrcLength = *(ULONG *)((BYTE*)pData + pBinding[cBind].obLength);
00120     else
00121       dwSrcLength = 0;
00122
00123         // Get the Status
00124         if( dwPart & DBPART_STATUS )
00125       dwSrcStatus = *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus);
00126     else
00127       dwSrcStatus = DBSTATUS_S_OK;
00128
00129         // Check the Status for DBSTATUS_S_DEFAULT
00130     if( dwSrcStatus == DBSTATUS_S_DEFAULT )
00131       dwSrcStatus = DBSTATUS_S_ISNULL;
00132
00133         // Check the Status for DBSTATUS_S_IGNORE
00134     if( dwSrcStatus == DBSTATUS_S_IGNORE ||
00135       dwSrcStatus == DBSTATUS_S_ISNULL )
00136       continue;
00137
00138         // Check the Status of the value being sent in
00139     if( dwSrcStatus != DBSTATUS_S_OK )
00140     {
00141       *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus) = DBSTATUS_E_BADSTATUS;
00142       cErrorCount++;
00143       continue;
00144     }
00145
00146         // Get the Value
00147     if( (dwPart & DBPART_VALUE) == 0 )
00148     {
00149             if( dwPart & DBPART_STATUS )
00150         *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus) = DBSTATUS_E_UNAVAILABLE;
00151
00152       cErrorCount++;
00153       continue;
00154     }
00155         else
00156     {
00157             pSrc = (void *) ((BYTE*) pData + pBinding[cBind].obValue);
00158     }
00159
00160     // Check to see if we have a DC
00161     if( !g_pIDataConvert )
00162       return( E_FAIL );
00163
00164     hr = g_pIDataConvert->DataConvert(
00165         dwSrcType,
00166                 dwDstType,
00167                 dwSrcLength,
00168                 pdwDstLength,
00169                 pSrc,
00170                 pDst,
00171                 cbDstMaxLength,
00172                 dwSrcStatus,
00173                 pdwDstStatus,
00174                 pBinding[cBind].bPrecision, // bPrecision for conversion to DBNUMERIC
00175         pBinding[cBind].bScale,   // bScale for conversion to DBNUMERIC
00176         (DBDATACONVERT_SETDATABEHAVIOR |
00177          (!dwSrcLength ? DBDATACONVERT_LENGTHFROMNTS : 0)));
00178
00179         if( dwPart & DBPART_STATUS )
00180       *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus) = *pdwDstStatus;
00181
00182     // fatal error
00183     if( FAILED( hr ) && hr != DB_E_ERRORSOCCURRED )
00184             return hr;
00185
00186     // rounding or truncation or can't coerce
00187     if( hr != S_OK )
00188       cErrorCount++;
00189   }
00190
00191     // Carry out the update.
00192     if( FAILED( m_pObj->m_pFileio->UpdateRow((DBBKMARK) ((PROWBUFF) pbProvRow)->pbBmk, pbProvRow, UPDATE )) )
00193   {
00194         // Restore the row to its previous state
00195         memcpy( pbProvRow, rgbRowDataSave, m_pObj->m_cbTotalRowSize );
00196     free( rgbRowDataSave );
00197         return( E_FAIL );
00198   }
00199
00200     free( rgbRowDataSave );
00201
00202   // If everything went OK except errors in rows use DB_S_ERRORSOCCURRED.
00203   return cErrorCount ? ( cErrorCount < cBindings ) ?
00204     ( DB_S_ERRORSOCCURRED ) : ( DB_E_ERRORSOCCURRED ) : ( S_OK );
00205 }
00206
00207
00208
00209 // CImpIRowsetChange::DeleteRows ---------------------------------------
00210 //
00211 // @mfunc Deletes rows from the provider.  If Errors on individual rows
00212 // occur, the DBERRORINFO array is updated to reflect the error and S_FALSE
00213 // is returned instead of S_OK.
00214 //
00215 // @rdesc HRESULT indicating the status of the method
00216 //      @Flag S_OK                  | All row handles deleted
00217 //      @Flag DB_S_ERRORSOCCURRED   | Some, but not all, row handles deleted
00218 //      @Flag E_INVALIDARG          | Arguments did not match spec.
00219 //      @Flag E_OUTOFMEMORY         | Could not allocated error array
00220 //
00221 STDMETHODIMP CImpIRowsetChange::DeleteRows
00222     (
00223     HCHAPTER    hChapter,       //@parm IN  | The Chapter handle.
00224     DBCOUNTITEM     cRows,      //@parm IN  | Number of rows to delete
00225     const HROW      rghRows[],    //@parm IN  | Array of handles to delete
00226     DBROWSTATUS   rgRowStatus[] //@parm OUT | Error information
00227     )
00228 {
00229     DBCOUNTITEM chRow       = 0L;
00230     DBCOUNTITEM cErrors     = 0L;
00231     BYTE*   pbProvRow = NULL;
00232
00233     // If No Row handle, just return.
00234     if( cRows == 0 )
00235         return( S_OK );
00236
00237     // Check for Invalid Arguments
00238     if ( !rghRows )
00239         return( E_INVALIDARG );
00240
00241     // Process row handles
00242     while (chRow < cRows)
00243     {
00244     if( rgRowStatus )
00245       rgRowStatus[chRow] = DBROWSTATUS_S_OK;
00246
00247         // Is row handle valid
00248         if( (m_pObj->m_prowbitsIBuffer)->IsSlotSet( (ULONG)rghRows[chRow]) != S_OK )
00249         {
00250             // Log Error
00251       if( rgRowStatus )
00252         rgRowStatus[chRow]= DBROWSTATUS_E_INVALID;
00253
00254             cErrors++;
00255             chRow++;
00256             continue;
00257     }
00258
00259         // Get RowBuffer to look at which row this applies to
00260         pbProvRow = (BYTE *) (m_pObj->GetRowBuff((DBCOUNTITEM) rghRows[chRow], TRUE ));
00261
00262         // Has row already been deleted
00263         // S_OK means deleted
00264         if( m_pObj->m_pFileio->IsDeleted((DBBKMARK) ((PROWBUFF) pbProvRow)->pbBmk ) == S_OK )
00265         {
00266       if( rgRowStatus )
00267         rgRowStatus[chRow] = DBROWSTATUS_E_DELETED;
00268             cErrors++;
00269             chRow++;
00270             continue;
00271         }
00272
00273         // Delete the Row,
00274         if( m_pObj->m_pFileio->DeleteRow((DBBKMARK) ((PROWBUFF) pbProvRow)->pbBmk) != S_OK )
00275         {
00276       // Some better decision as to what rowstatus to set could be done here..
00277       if( rgRowStatus )
00278         rgRowStatus[chRow] = DBROWSTATUS_E_FAIL;
00279             cErrors++;
00280             chRow++;
00281             continue;
00282         }
00283
00284     // Delete worked correctly
00285     chRow++;
00286
00287   } //while
00288
00289
00290   // If everything went OK except errors in rows use DB_S_ERRORSOCCURRED.
00291   return cErrors ? ( cErrors < cRows ) ?
00292     ( DB_S_ERRORSOCCURRED ) : ( DB_E_ERRORSOCCURRED ) : ( S_OK );
00293 }
00294
00295 // CImpIRowsetChange::InsetRow  --------------------------------------------
00296 //
00297 // @mfunc Insert row into provider
00298 //
00299 //  Returns:   S_OK                    if data changed successfully
00300 //             E_FAIL                  if Catch all (NULL pData, etc.)
00301 //             E_INVALIDARG            if pcErrors!=NULL and paErrors==NULL
00302 //             E_OUTOFMEMORY           if output error array couldn't be allocated
00303 //             DB_E_BADACCESSORHANDLE  if invalid accessor
00304 //
00305 STDMETHODIMP    CImpIRowsetChange::InsertRow
00306     (
00307     HCHAPTER    hChapter,        //@parm IN | The Chapter handle.
00308     HACCESSOR hAccessor,
00309     void*   pData,
00310     HROW*   phRow
00311   )
00312 {
00313     DBORDINAL       cCols;
00314   DBCOUNTITEM   cBind;
00315     BYTE*           pbProvRow;
00316     HRESULT         hr;
00317     ULONG     irow;
00318     DBCOUNTITEM     cBindings;
00319     DBBINDING*      pBinding;
00320     DBCOUNTITEM     cErrorCount;
00321     DBTYPE          dwSrcType;
00322     DBTYPE          dwDstType;
00323     void*           pSrc;
00324     void*           pDst;
00325     ULONG           dwSrcLength;
00326     DBLENGTH*   pdwDstLength;
00327     DBLENGTH        cbDstMaxLength;
00328     DWORD           dwSrcStatus;
00329     DWORD*          pdwDstStatus;
00330     DWORD           dwPart;
00331     PCOLUMNDATA     pColumnData;
00332     PACCESSOR       paccessor = NULL;
00333     BYTE*           rgbRowDataSave = NULL;
00334   BOOL      fCanHoldRows = FALSE;
00335   DBPROPIDSET   rgPropertyIDSets[1];
00336   ULONG     cPropertySets;
00337   DBPROPSET*    prgPropertySets;
00338   DBPROPID    rgPropId[1];
00339   DBCOLUMNINFO *  rgdbcolumninfo = NULL;
00340
00341   // Initialize values
00342   if( phRow )
00343     *phRow = NULL;
00344
00345     // Check the Accessor Handle
00346   assert( m_pObj->m_pextbufferAccessor );
00347   if( FAILED( m_pObj->m_pextbufferAccessor->GetItemOfExtBuffer(hAccessor, &paccessor)) )
00348         return( DB_E_BADACCESSORHANDLE );
00349
00350     // Ensure a source of data.
00351     assert( paccessor );
00352     if( paccessor->cBindings && !pData )
00353         return( E_INVALIDARG );
00354
00355     // Get the value of the DBPROP_CANHOLDROWS property
00356   rgPropertyIDSets[0].guidPropertySet = DBPROPSET_ROWSET;
00357   rgPropertyIDSets[0].rgPropertyIDs = rgPropId;
00358   rgPropertyIDSets[0].cPropertyIDs  = 1;
00359   rgPropId[0]             = DBPROP_CANHOLDROWS;
00360
00361     assert( m_pObj->m_pUtilProp );
00362   m_pObj->m_pUtilProp->GetProperties(
00363                   PROPSET_ROWSET,
00364                   1,
00365                   rgPropertyIDSets,
00366                   &cPropertySets,
00367                   &prgPropertySets );
00368
00369   // Get the Prompt value
00370   if( V_BOOL(&prgPropertySets->rgProperties->vValue) == VARIANT_TRUE )
00371     fCanHoldRows = TRUE;
00372
00373   // Free the memory
00374   SAFE_FREE(prgPropertySets[0].rgProperties);
00375   SAFE_FREE(prgPropertySets);
00376
00377     // Are there any unreleased rows?
00378     if( ((m_pObj->m_prowbitsIBuffer)->ArrayEmpty() != S_OK) && (!fCanHoldRows) )
00379         return( DB_E_ROWSNOTRELEASED );
00380
00381     if( FAILED( hr = GetNextSlots( m_pObj->m_pIBuffer, 1, &irow )) )
00382         return hr;
00383
00384     if( FAILED( m_pObj->Rebind((BYTE *) m_pObj->GetRowBuff( irow, TRUE ))) )
00385         return( E_FAIL );
00386
00387     // Get the rowbuffer and set the new bookmark
00388   pbProvRow = (BYTE *) (m_pObj->GetRowBuff( irow, TRUE ));
00389     ((PROWBUFF) pbProvRow)->ulRefCount++;
00390     ((PROWBUFF) pbProvRow)->pbBmk = (BYTE*) m_pObj->m_pFileio->GetRowCnt()+1;
00391     m_pObj->m_ulRowRefCount++;
00392
00393     cBindings = paccessor->cBindings;
00394     pBinding  = paccessor->rgBindings;
00395
00396   // NULL Accessor (set Status to NULL)
00397   if( !cBindings )
00398   {
00399     for (cCols = 1; cCols <= m_pObj->m_cCols; cCols++)
00400     {
00401       pColumnData = m_pObj->m_pFileio->GetColumnData(cCols, (ROWBUFF *) pbProvRow);
00402       pColumnData->dwStatus = DBSTATUS_S_ISNULL;
00403     }
00404   }
00405
00406     // Apply accessor to data.
00407   rgdbcolumninfo = m_pObj->m_pFileio->GetColInfo();
00408     for (cBind = 0, cErrorCount = 0; cBind < cBindings; cBind++)
00409   {
00410         cCols = pBinding[cBind].iOrdinal;
00411
00412         // make sure column number is in range
00413         if( cCols < 1 || cCols > m_pObj->m_cCols )
00414             return( DB_E_BADORDINAL );
00415
00416     pColumnData = m_pObj->m_pFileio->GetColumnData(cCols, (ROWBUFF *)pbProvRow);
00417
00418         dwSrcType      = pBinding[cBind].wType;
00419         pDst           = &(pColumnData->bData);
00420         pdwDstLength   = (DBBYTEOFFSET *) &(pColumnData->dwLength);
00421         pdwDstStatus   = &(pColumnData->dwStatus);
00422         cbDstMaxLength = pBinding[cBind].cbMaxLen;
00423
00424         dwPart         = pBinding[cBind].dwPart;
00425         dwDstType      = rgdbcolumninfo[cCols].wType;
00426
00427         // Get the Length
00428     if( dwPart & DBPART_LENGTH )
00429       dwSrcLength = *(ULONG *)((BYTE*)pData + pBinding[cBind].obLength);
00430     else
00431       dwSrcLength = 0;
00432
00433         // Get the Status
00434         if( dwPart & DBPART_STATUS )
00435       dwSrcStatus = *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus);
00436     else
00437       dwSrcStatus = DBSTATUS_S_OK;
00438
00439         // Check the Status for DBSTATUS_S_DEFAULT
00440     if( dwSrcStatus == DBSTATUS_S_DEFAULT )
00441       dwSrcStatus = DBSTATUS_S_ISNULL;
00442
00443         // Check the Status for DBSTATUS_S_IGNORE
00444     if( dwSrcStatus == DBSTATUS_S_IGNORE ||
00445       dwSrcStatus == DBSTATUS_S_ISNULL )
00446       continue;
00447
00448         // Check the Status of the value being sent in
00449     if( dwSrcStatus != DBSTATUS_S_OK )
00450     {
00451       *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus) = DBSTATUS_E_BADSTATUS;
00452       cErrorCount++;
00453       continue;
00454     }
00455
00456         // Get the Value
00457     if( (dwPart & DBPART_VALUE) == 0 )
00458     {
00459             if( dwPart & DBPART_STATUS )
00460         *(ULONG *)((BYTE*)pData + pBinding[cBind].obStatus) = DBSTATUS_E_UNAVAILABLE;
00461
00462       cErrorCount++;
00463       continue;
00464     }
00465         else
00466     {
00467             pSrc = (void *) ((BYTE*) pData + pBinding[cBind].obValue);
00468     }
00469
00470     // Check to see if we have a DC
00471     if( !g_pIDataConvert )
00472       return( E_FAIL );
00473
00474         hr = g_pIDataConvert->DataConvert(
00475         dwSrcType,
00476                 dwDstType,
00477                 dwSrcLength,
00478                 pdwDstLength,
00479                 pSrc,
00480                 pDst,
00481                 cbDstMaxLength,
00482                 dwSrcStatus,
00483                 pdwDstStatus,
00484                 pBinding[cBind].bPrecision, // bPrecision for conversion to DBNUMERIC
00485         pBinding[cBind].bScale,   // bScale for conversion to DBNUMERIC
00486         (DBDATACONVERT_SETDATABEHAVIOR |
00487          (!dwSrcLength ? DBDATACONVERT_LENGTHFROMNTS : 0)));
00488
00489     // fatal error
00490     if( FAILED( hr ) )
00491             return hr;
00492
00493     // rounding or truncation or can't coerce
00494     if( hr != S_OK )
00495             cErrorCount++;
00496   }
00497
00498   // If all bindings are bad and not a NULL Accessor
00499   if( !cBindings || cErrorCount < cBindings )
00500   {
00501     // Carry out the insert.
00502     if( FAILED(m_pObj->m_pFileio->UpdateRow((DBBKMARK) ((PROWBUFF) pbProvRow)->pbBmk, pbProvRow, INSERT )) )
00503       return( E_FAIL );
00504
00505     // Set the RowHandle
00506     if( phRow )
00507       *phRow = irow;
00508   }
00509
00510   // If everything went OK except errors in rows use DB_S_ERRORSOCCURRED.
00511   return cErrorCount ? ( cErrorCount < cBindings ) ?
00512     ( DB_S_ERRORSOCCURRED ) : ( DB_E_ERRORSOCCURRED ) : ( S_OK );
00513 }
00514
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Encode/Pch.Cpp Source File

  • Security
  • CertServices
  • Encode

Pch.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        pch.cpp
00007 //
00008 // Contents:    Cert Server precompiled header
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include <windows.h>
00013
00014 #include <atlbase.h>
00015
00016 //You may derive a class from CComModule and use it if you want to override
00017 //something, but do not change the name of _Module
00018 extern CComModule _Module;
00019
00020 #include <atlcom.h>
00021 #include <certsrv.h>
00022
00023 #pragma hdrstop
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCertEncodeLongArray Member List

This is the complete list of members for CCertEncodeLongArray, including all inherited members.
_Cleanup(VOID) | CCertEncodeLongArray | [private]
_SetErrorInfo(IN HRESULT hrError, IN WCHAR const *pwszDescription) | CCertEncodeLongArray | [private]
CCertEncodeLongArray() | CCertEncodeLongArray | [inline]
Encode(BSTR __RPC_FAR *pstrBinary) | CCertEncodeLongArray |
GetValue(LONG Index, LONG __RPC_FAR *pValue) | CCertEncodeLongArray |
m_aValue | CCertEncodeLongArray | [private]
m_cValue | CCertEncodeLongArray | [private]
m_cValuesSet | CCertEncodeLongArray | [private]
m_fConstructing | CCertEncodeLongArray | [private]
Reset(LONG Count) | CCertEncodeLongArray |
SetValue(LONG Index, LONG Value) | CCertEncodeLongArray |
~CCertEncodeLongArray() | CCertEncodeLongArray |
Generated on Wed Nov 13 2024 16:55:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authentication/AuthenticatePlugin.h Source File

  • Multimedia
  • WindowsMediaServices9
  • Authentication

AuthenticatePlugin.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       AuthenticatePlugin.h
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011
00012
00013 #if !defined(AFX_AUTHENTICATEPLUGIN_H__CDE2E83E_1C92_4439_BC67_6608A797BCCB__INCLUDED_)
00014 #define AFX_AUTHENTICATEPLUGIN_H__CDE2E83E_1C92_4439_BC67_6608A797BCCB__INCLUDED_
00015
00016 #include "resource.h"       // main symbols
00017
00018 #include "WMSContextNames.h"
00019
00020 // Forward declare the CAuthenticateAdmin interface
00021 class CAuthenticateAdmin;
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // CAuthenticatePlugin
00025 class ATL_NO_VTABLE CAuthenticatePlugin :
00026     public CComObjectRootEx<CComMultiThreadModel>,
00027     public CComCoClass<CAuthenticatePlugin, &CLSID_AuthenticatePlugin>,
00028     public IWMSAuthenticationPlugin,
00029     public IWMSBasicPlugin,
00030     public IAuthenticatePlugin
00031 {
00032 public:
00033     CAuthenticatePlugin();
00034     ~CAuthenticatePlugin();
00035
00036 DECLARE_REGISTRY_RESOURCEID(IDR_AUTHENTICATEPLUGIN)
00037
00038 DECLARE_PROTECT_FINAL_CONSTRUCT()
00039
00040 BEGIN_COM_MAP(CAuthenticatePlugin)
00041         COM_INTERFACE_ENTRY(IWMSAuthenticationPlugin)
00042         COM_INTERFACE_ENTRY(IWMSBasicPlugin)
00043         COM_INTERFACE_ENTRY(IAuthenticatePlugin)
00044 END_COM_MAP()
00045
00046 public:
00047     // IWMSBasicPlugin
00048     STDMETHOD( InitializePlugin )( IWMSContext *pServerContext, IWMSNamedValues *pNamedValues, IWMSClassObject *pClassFactory );
00049     STDMETHOD( OnHeartbeat )( );
00050     STDMETHOD( GetCustomAdminInterface )( IDispatch **ppValue );
00051     STDMETHOD( ShutdownPlugin )();
00052     STDMETHOD( EnablePlugin ) ( long *pdwFlags, long *pdwHeartbeatPeriod );
00053     STDMETHOD( DisablePlugin )();
00054
00055     // IWMSAuthenticationPlugin
00056     STDMETHOD( GetPackageName )( BSTR *PackageName );
00057     STDMETHOD( GetProtocolName )( BSTR *ProtocolName );
00058     STDMETHOD( GetFlags )( long *Flags );
00059     STDMETHOD( CreateAuthenticationContext )( IWMSAuthenticationContext **ppAuthenCtx );
00060
00061 private:
00062     // Private Member Functions
00063
00064 private:
00065     // Private Member Variables
00066     CComPtr<IWMSNamedValues>   m_spNamedValues;
00067 };
00068
00069
00070 #endif // !defined(AFX_AUTHENTICATEPLUGIN_H__CDE2E83E_1C92_4439_BC67_6608A797BCCB__INCLUDED_)
00071
00072
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Bluetooth/bthcxn.cpp Source File

  • NetDS
  • Bluetooth

bthcxn.cpp

Go to the documentation of this file.
00001
00002 //
00003 // BTHCxnDemo.cpp - Simple Bluetooth application using Winsock 2.2 and RFCOMM protocol
00004 //
00005 //      This is a part of the Microsoft Source Code Samples.
00006 //      Copyright 1996 - 2002 Microsoft Corporation.
00007 //      All rights reserved.
00008 //      This source code is only intended as a supplement to
00009 //      Microsoft Development Tools and/or WinHelp documentation.
00010 //      See these sources for detailed information regarding the
00011 //      Microsoft samples programs.
00012 //
00013 //      This example demonstrates how to use Winsock-2.2 APIs to connect
00014 //      between two remote bluetooth devices and transfer data between them.
00015 //      This example only supports address family of type AF_BTH,
00016 //      socket of type SOCK_STREAM, protocol of type BTHPROTO_RFCOMM.
00017 //
00018 //      Once this source code is built, the resulting application can be
00019 //      run either in server mode or in client mode.  See command line help
00020 //      for command-line-examples and detailed explanation about all options.
00021 //
00022
00023
00024 #include <stdio.h>
00025 #include <initguid.h>
00026 #include <winsock2.h>
00027 #include <ws2bth.h>
00028
00029
00030 // {B62C4E8D-62CC-404b-BBBF-BF3E3BBB1374}
00031 DEFINE_GUID(g_guidServiceClass, 0xb62c4e8d, 0x62cc, 0x404b, 0xbb, 0xbf, 0xbf, 0x3e, 0x3b, 0xbb, 0x13, 0x74);
00032
00033
00034 #define CXN_BDADDR_STR_LEN                17   // 6 two-digit hex values plus 5 colons
00035 #define CXN_TRANSFER_DATA_LENGTH          100  // length of the data to be transferred
00036 #define CXN_MAX_INQUIRY_RETRY             3
00037 #define CXN_DELAY_NEXT_INQUIRY            15
00038
00039
00040 char g_szRemoteName[BTH_MAX_NAME_SIZE + 1] = {0};  // 1 extra for trailing NULL character
00041 char g_szRemoteAddr[CXN_BDADDR_STR_LEN + 1] = {0}; // 1 extra for trailing NULL character
00042 int  g_ulMaxCxnCycles = 1, g_iOutputLevel = 0;
00043
00044
00045 ULONG NameToBthAddr(IN const char * pszRemoteName, OUT BTH_ADDR * pRemoteBthAddr);
00046 ULONG AddrStringToBtAddr(IN const char * pszRemoteAddr, OUT BTH_ADDR * pRemoteBtAddr);
00047 ULONG RunClientMode(IN ULONGLONG ululRemoteBthAddr, IN int iMaxCxnCycles = 1);
00048 ULONG RunServerMode(IN int iMaxCxnCycles = 1);
00049 void  ShowCmdLineHelp(void);
00050 ULONG ParseCmdLine(IN int argc, IN char * argv[]);
00051
00052
00053 int _cdecl main(int argc, char *argv[])
00054 {
00055     ULONG      ulRetCode = 0;
00056     WSADATA    WSAData = {0};
00057     ULONGLONG  ululRemoteBthAddr = 0;
00058
00059     //
00060     // Parse the command line
00061     //
00062     if ( 0 == ( ulRetCode = ParseCmdLine(argc, argv) ) )
00063     {
00064         //
00065         // Ask for Winsock version 2.2.
00066         //
00067         if ( 0 != ( ulRetCode = WSAStartup(MAKEWORD(2, 2), &WSAData) ) )
00068         {
00069             printf("-FATAL- | Unable to initialize Winsock version 2.2\n");
00070             goto CleanupAndExit;
00071         }
00072
00073         if ( '\0' != g_szRemoteName[0] )
00074         {
00075             //
00076             // Get address from name of the remote device and run the application in client mode
00077             //
00078             if ( 0 != ( ulRetCode = NameToBthAddr(g_szRemoteName, (BTH_ADDR *) &ululRemoteBthAddr) ) )
00079             {
00080                 printf("-FATAL- | Unable to get address of the remote radio having name %s\n", g_szRemoteName);
00081                 goto CleanupAndExit;
00082             }
00083
00084             ulRetCode = RunClientMode(ululRemoteBthAddr, g_ulMaxCxnCycles);
00085         }
00086         else if ( '\0' != g_szRemoteAddr[0] )
00087         {
00088             //
00089             // Get address from formated address-string of the remote device and run the application in client mode
00090             //
00091             // BUGBUG should be calling WSAStringToAddress
00092             //
00093             if ( 0 != ( ulRetCode = AddrStringToBtAddr(g_szRemoteAddr, (BTH_ADDR *) &ululRemoteBthAddr) ) )
00094             {
00095                 printf("-FATAL- | Unable to get address of the remote radio having formated address-string %s\n", g_szRemoteAddr);
00096                 goto CleanupAndExit;
00097             }
00098
00099             ulRetCode = RunClientMode(ululRemoteBthAddr, g_ulMaxCxnCycles);
00100         }
00101         else
00102         {
00103             //
00104             // No remote name/address specified.  Run the application in server mode
00105             //
00106             ulRetCode = RunServerMode(g_ulMaxCxnCycles);
00107         }
00108     }
00109     else if ( 1 == ulRetCode )
00110     {
00111         //
00112         // Command line syntax error.  Display cmd line help
00113         //
00114         ShowCmdLineHelp();
00115     }
00116     else
00117     {
00118         printf("-FATAL- | Error in parsing command line\n");
00119     }
00120
00121 CleanupAndExit:
00122     return (int) (ulRetCode);
00123 }
00124
00125
00126 //
00127 // TODO: use inquiry timeout SDP_DEFAULT_INQUIRY_SECONDS
00128 //
00129
00130 //
00131 // NameToBthAddr converts a bluetooth device name to a bluetooth address,
00132 // if required by performing inquiry with remote name requests.
00133 // This function demonstrates device inquiry, with optional LUP flags.
00134 //
00135 ULONG NameToBthAddr(IN const char * pszRemoteName, OUT BTH_ADDR * pRemoteBtAddr)
00136 {
00137     INT          iResult = 0, iRetryCount = 0;
00138     BOOL         bContinueLookup = FALSE, bRemoteDeviceFound = FALSE;
00139     ULONG        ulFlags = 0, ulPQSSize = sizeof(WSAQUERYSET);
00140     HANDLE       hLookup = 0;
00141     PWSAQUERYSET pWSAQuerySet = NULL;
00142
00143     if ( ( NULL == pszRemoteName ) || ( NULL == pRemoteBtAddr ) )
00144     {
00145         goto CleanupAndExit;
00146     }
00147
00148     if ( NULL == ( pWSAQuerySet = (PWSAQUERYSET) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulPQSSize) ) )
00149     {
00150         printf("!ERROR! | Unable to allocate memory for WSAQUERYSET\n");
00151         goto CleanupAndExit;
00152     }
00153
00154     //
00155     // Search for the device with the correct name
00156     //
00157     for (iRetryCount = 0; !bRemoteDeviceFound && (iRetryCount < CXN_MAX_INQUIRY_RETRY); iRetryCount++)
00158     {
00159         //
00160         // WSALookupService is used for both service search and device inquiry
00161         // LUP_CONTAINERS is the flag which signals that we're doing a device inquiry.
00162         //
00163         ulFlags = LUP_CONTAINERS;
00164
00165         //
00166         // Friendly device name (if available) will be returned in lpszServiceInstanceName
00167         //
00168         ulFlags |= LUP_RETURN_NAME;
00169
00170         //
00171         // BTH_ADDR will be returned in lpcsaBuffer member of WSAQUERYSET
00172         //
00173         ulFlags |= LUP_RETURN_ADDR;
00174
00175         if ( 0 == iRetryCount )
00176         {
00177             printf("*INFO* | Inquiring device from cache...\n");
00178         }
00179         else
00180         {
00181             //
00182             // Flush the device cache for all inquiries, except for the first inquiry
00183             //
00184             // By setting LUP_FLUSHCACHE flag, we're asking the lookup service to do
00185             // a fresh lookup instead of pulling the information from device cache.
00186             //
00187             ulFlags |= LUP_FLUSHCACHE;
00188
00189             //
00190             // Pause for some time before all the inquiries after the first inquiry
00191             //
00192             //
00193             // BUGBUG why sleep. Try to get rid of this
00194             //
00195             // Remote Name requests will arrive after device inquiry has
00196             // completed.  Without a window to receive IN_RANGE notifications,
00197             // we don't have a direct mechanism to determine when remote
00198             // name requests have completed.
00199             //
00200             printf("*INFO* | Unable to find device.  Waiting for %d seconds before re-inquiry...\n", CXN_DELAY_NEXT_INQUIRY);
00201             Sleep(CXN_DELAY_NEXT_INQUIRY * 1000);
00202
00203             printf("*INFO* | Inquiring device ...\n");
00204         }
00205
00206         //
00207         // Start the lookup service
00208         //
00209         iResult = 0;
00210         hLookup = 0;
00211         bContinueLookup = FALSE;
00212         ZeroMemory(pWSAQuerySet, ulPQSSize);
00213         pWSAQuerySet->dwNameSpace = NS_BTH;
00214         pWSAQuerySet->dwSize = sizeof(WSAQUERYSET);
00215         iResult = WSALookupServiceBegin(pWSAQuerySet, ulFlags, &hLookup);
00216
00217         if ( (NO_ERROR == iResult) && (NULL != hLookup) )
00218         {
00219             bContinueLookup = TRUE;
00220         }
00221         else if ( 0 < iRetryCount )
00222         {
00223             printf("=CRITICAL= | WSALookupServiceBegin() failed with error code %d, WSALastError = %d\n", iResult, WSAGetLastError());
00224             goto CleanupAndExit;
00225         }
00226
00227         while ( bContinueLookup )
00228         {
00229             //
00230             // Get information about next bluetooth device
00231             //
00232             // Note you may pass the same WSAQUERYSET from LookupBegin
00233             // as long as you don't need to modify any of the pointer
00234             // members of the structure, etc.
00235             //
00236             // ZeroMemory(pWSAQuerySet, ulPQSSize);
00237             // pWSAQuerySet->dwNameSpace = NS_BTH;
00238             // pWSAQuerySet->dwSize = sizeof(WSAQUERYSET);
00239             if ( NO_ERROR == WSALookupServiceNext(hLookup, ulFlags, &ulPQSSize, pWSAQuerySet) )
00240             {
00241                 //
00242                 // Since we're a non-unicode application, the remote
00243                 // name in lpszServiceInstanceName will have been converted
00244                 // from CP_UTF8 to CP_ACP, this may cause the name match
00245                 // to fail unexpectedly.  If the app is to handle this,
00246                 // the app needs to be unicode.
00247                 //
00248                 if ( ( pWSAQuerySet->lpszServiceInstanceName != NULL ) && ( 0 == _stricmp(pWSAQuerySet->lpszServiceInstanceName, pszRemoteName) ) )
00249                 {
00250                     //
00251                     // Found a remote bluetooth device with matching name.
00252                     // Get the address of the device and exit the lookup.
00253                     //
00254                     CopyMemory(pRemoteBtAddr,
00255                                &((PSOCKADDR_BTH) pWSAQuerySet->lpcsaBuffer->RemoteAddr.lpSockaddr)->btAddr,
00256                                sizeof(*pRemoteBtAddr));
00257                     bRemoteDeviceFound = TRUE;
00258                     bContinueLookup = FALSE;
00259                 }
00260             }
00261             else
00262             {
00263                 if ( WSA_E_NO_MORE == ( iResult = WSAGetLastError() ) ) //No more data
00264                 {
00265                     //
00266                     // No more devices found.  Exit the lookup.
00267                     //
00268                     bContinueLookup = FALSE;
00269                 }
00270                 else if ( WSAEFAULT == iResult )
00271                 {
00272                     //
00273                     // The buffer for QUERYSET was insufficient.
00274                     // In such case 3rd parameter "ulPQSSize" of function "WSALookupServiceNext()" receives
00275                     // the required size.  So we can use this parameter to reallocate memory for QUERYSET.
00276                     //
00277                     HeapFree(GetProcessHeap(), 0, pWSAQuerySet);
00278                     pWSAQuerySet = NULL;
00279                     if ( NULL == ( pWSAQuerySet = (PWSAQUERYSET) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulPQSSize) ) )
00280                     {
00281                         printf("!ERROR! | Unable to allocate memory for WSAQERYSET\n");
00282                         bContinueLookup = FALSE;
00283                     }
00284                 }
00285                 else
00286                 {
00287                     printf("=CRITICAL= | WSALookupServiceNext() failed with error code %d\n", iResult);
00288                     bContinueLookup = FALSE;
00289                 }
00290             }
00291         }
00292
00293         //
00294         // End the lookup service
00295         //
00296         WSALookupServiceEnd(hLookup);
00297     }
00298
00299 CleanupAndExit:
00300     if ( NULL != pWSAQuerySet )
00301     {
00302         HeapFree(GetProcessHeap(), 0, pWSAQuerySet);
00303         pWSAQuerySet = NULL;
00304     }
00305
00306     if ( bRemoteDeviceFound )
00307     {
00308         return(0);
00309     }
00310     else
00311     {
00312         return(1);
00313     }
00314 }
00315
00316 //
00317 // Convert a formatted BTH address string to populate a BTH_ADDR (actually a ULONGLONG)
00318 //
00319 ULONG AddrStringToBtAddr(IN const char * pszRemoteAddr, OUT BTH_ADDR * pRemoteBtAddr)
00320 {
00321     ULONG ulAddrData[6], ulRetCode = 0;
00322     BTH_ADDR BtAddrTemp = 0;
00323
00324     if ( ( NULL == pszRemoteAddr ) || ( NULL == pRemoteBtAddr ) )
00325     {
00326         ulRetCode = 1;
00327         goto CleanupAndExit;
00328     }
00329
00330     *pRemoteBtAddr = 0;
00331
00332     //
00333     // Populate a 6 membered array of unsigned long integers
00334     // by parsing the given address in string format
00335     //
00336     sscanf(pszRemoteAddr,
00337            "%02x:%02x:%02x:%02x:%02x:%02x",
00338            &ulAddrData[0],&ulAddrData[1],&ulAddrData[2],&ulAddrData[3],&ulAddrData[4],&ulAddrData[5]);
00339
00340     //
00341     // Construct a BTH_ADDR from the 6 integers stored in the array
00342     //
00343     for ( int i=0; i<6; i++ )
00344     {
00345         //
00346         // Extract data from the first 8 lower bits.
00347         //
00348         BtAddrTemp = (BTH_ADDR)( ulAddrData[i] & 0xFF );
00349
00350         //
00351         // Push 8 bits to the left
00352         //
00353         *pRemoteBtAddr = ( (*pRemoteBtAddr) << 8 ) + BtAddrTemp;
00354     }
00355
00356 CleanupAndExit:
00357     return ulRetCode;
00358 }
00359
00360 //
00361 // RunClientMode runs the application in client mode.  It opens a socket, connects it to a
00362 // remote socket, transfer some data over the connection and closes the connection.
00363 //
00364 ULONG RunClientMode(ULONGLONG ululRemoteAddr, int iMaxCxnCycles)
00365 {
00366     ULONG              ulRetCode = 0;
00367     int                iCxnCount = 0;
00368     char               szData[CXN_TRANSFER_DATA_LENGTH] = {0};
00369     SOCKET             LocalSocket = INVALID_SOCKET;
00370     SOCKADDR_BTH       SockAddrBthServer = {0};
00371
00372     //
00373     // Setting address family to AF_BTH indicates winsock2 to use Bluetooth sockets
00374     // Port should be set to 0 if ServiceClassId is spesified.
00375     //
00376     SockAddrBthServer.addressFamily = AF_BTH;
00377     SockAddrBthServer.btAddr = (BTH_ADDR) ululRemoteAddr;
00378     SockAddrBthServer.serviceClassId = g_guidServiceClass;
00379     SockAddrBthServer.port = 0;
00380
00381     //
00382     // Create a static data-string, which will be transferred to the remote Bluetooth device
00383     //
00384     //
00385     // BUGBUG make this #define and do strlen of the string
00386     //
00387     strncpy(szData, "~!@#$%^&*()-_=+?<>1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", CXN_TRANSFER_DATA_LENGTH - 1);
00388
00389     //
00390     // Run the connection/data-transfer for user specified number of cycles
00391     //
00392     for ( iCxnCount = 0; (0 == ulRetCode) && (iCxnCount < iMaxCxnCycles || iMaxCxnCycles == 0); iCxnCount++ )
00393     {
00394         printf("\n");
00395
00396         //
00397         // Open a bluetooth socket using RFCOMM protocol
00398         //
00399         if ( INVALID_SOCKET == ( LocalSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM) ) )
00400         {
00401             printf("=CRITICAL= | socket() call failed. WSAGetLastError = [%d]\n", WSAGetLastError());
00402             ulRetCode = 1;
00403             goto CleanupAndExit;
00404         }
00405
00406         if ( 2 <= g_iOutputLevel )
00407         {
00408             printf("*INFO* | socket() call succeeded. Socket = [0x%X]\n", LocalSocket);
00409         }
00410
00411         if ( 1 <= g_iOutputLevel )
00412         {
00413             printf("*INFO* | connect() attempt with Remote BTHAddr = [0x%X]\n", ululRemoteAddr);
00414         }
00415
00416         //
00417         // Connect the socket (pSocket) to a given remote socket represented by address (pServerAddr)
00418         //
00419         if ( SOCKET_ERROR == connect(LocalSocket, (struct sockaddr *) &SockAddrBthServer, sizeof(SOCKADDR_BTH)) )
00420         {
00421             printf("=CRITICAL= | connect() call failed. WSAGetLastError=[%d]\n", WSAGetLastError());
00422             ulRetCode = 1;
00423             goto CleanupAndExit;
00424         }
00425
00426         if ( 2 <= g_iOutputLevel )
00427         {
00428             printf("*INFO* | connect() call succeeded\n");
00429         }
00430
00431         //
00432         // send() call indicates winsock2 to send the given data
00433         // of a specified length over a given connection.
00434         //
00435         printf("*INFO* | Sending following data string:\n%s\n", szData);
00436         if ( SOCKET_ERROR == send(LocalSocket, szData, CXN_TRANSFER_DATA_LENGTH, 0) )
00437         {
00438             printf("=CRITICAL= | send() call failed w/socket = [0x%X], szData = [%p], dataLen = [%d]. WSAGetLastError=[%d]\n", LocalSocket, szData, CXN_TRANSFER_DATA_LENGTH, WSAGetLastError());
00439             ulRetCode = 1;
00440             goto CleanupAndExit;
00441         }
00442
00443         if ( 2 <= g_iOutputLevel )
00444         {
00445             printf("*INFO* | send() call succeeded\n");
00446         }
00447
00448         //
00449         // Close the socket
00450         //
00451         if ( SOCKET_ERROR == closesocket(LocalSocket) )
00452         {
00453             printf("=CRITICAL= | closesocket() call failed w/socket = [0x%X]. WSAGetLastError=[%d]\n", LocalSocket, WSAGetLastError());
00454             ulRetCode = 1;
00455             goto CleanupAndExit;
00456         }
00457
00458         LocalSocket = INVALID_SOCKET;
00459
00460         if ( 2 <= g_iOutputLevel )
00461         {
00462             printf("*INFO* | closesocket() call succeeded");
00463         }
00464     }
00465
00466 CleanupAndExit:
00467     if ( INVALID_SOCKET != LocalSocket )
00468     {
00469         closesocket(LocalSocket);
00470         LocalSocket = INVALID_SOCKET;
00471     }
00472
00473     return ulRetCode;
00474 }
00475
00476 //
00477 // RunServerMode runs the application in server mode.  It opens a socket, connects it to a
00478 // remote socket, transfer some data over the connection and closes the connection.
00479 //
00480 ULONG RunServerMode(int iMaxCxnCycles)
00481 {
00482     ULONG              ulRetCode = 0;
00483     int                iAddrLen = sizeof(SOCKADDR_BTH), iCxnCount = 0, iLengthReceived = 0, iTotalLengthReceived = 0;
00484     char               szDataBuffer[CXN_TRANSFER_DATA_LENGTH] = {0};
00485     char *             pszDataBufferIndex = NULL;
00486     LPTSTR             lptstrThisComputerName = NULL;
00487     DWORD              dwLenComputerName = MAX_COMPUTERNAME_LENGTH + 1;
00488     SOCKET             LocalSocket = INVALID_SOCKET, ClientSocket = INVALID_SOCKET;
00489     WSAVERSION         wsaVersion = {0};
00490     WSAQUERYSET        wsaQuerySet = {0};
00491     SOCKADDR_BTH       SockAddrBthLocal = {0};
00492     LPCSADDR_INFO      lpCSAddrInfo = NULL;
00493
00494     //
00495     // BUGBUG both of these fixed-size allocations can be on the stack
00496     //
00497     if ( NULL == ( lpCSAddrInfo = (LPCSADDR_INFO) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CSADDR_INFO) ) ) )
00498     {
00499         printf("!ERROR! | Unable to allocate memory for CSADDR_INFO\n");
00500         ulRetCode = 1;
00501         goto CleanupAndExit;
00502     }
00503
00504     if ( NULL == ( lptstrThisComputerName = (LPTSTR) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwLenComputerName ) ) )
00505     {
00506         printf("!ERROR! | Unable to allocate memory for CSADDR_INFO\n");
00507         ulRetCode = 1;
00508         goto CleanupAndExit;
00509     }
00510
00511     if ( !GetComputerName(lptstrThisComputerName, &dwLenComputerName) )
00512     {
00513         printf("=CRITICAL= | GetComputerName() call failed. WSAGetLastError=[%d]\n", WSAGetLastError());
00514         ulRetCode = 1;
00515         goto CleanupAndExit;
00516     }
00517
00518     //
00519     // Open a bluetooth socket using RFCOMM protocol
00520     //
00521     if ( INVALID_SOCKET == ( LocalSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM) ) )
00522     {
00523         printf("=CRITICAL= | socket() call failed. WSAGetLastError = [%d]\n", WSAGetLastError());
00524         ulRetCode = 1;
00525         goto CleanupAndExit;
00526     }
00527
00528     if ( 2 <= g_iOutputLevel )
00529     {
00530         printf("*INFO* | socket() call succeeded. Socket = [0x%X]\n", LocalSocket);
00531     }
00532
00533     //
00534     // Setting address family to AF_BTH indicates winsock2 to use Bluetooth port
00535     //
00536     SockAddrBthLocal.addressFamily = AF_BTH;
00537     SockAddrBthLocal.port = BT_PORT_ANY;
00538
00539     //
00540     // bind() associates a local address and port combination
00541     // with the socket just created. This is most useful when
00542     // the application is a server that has a well-known port
00543     // that clients know about in advance.
00544     //
00545     if ( SOCKET_ERROR == bind(LocalSocket, (struct sockaddr *) &SockAddrBthLocal, sizeof(SOCKADDR_BTH) ) )
00546     {
00547         printf("=CRITICAL= | bind() call failed w/socket = [0x%X]. WSAGetLastError=[%d]\n", LocalSocket, WSAGetLastError());
00548         ulRetCode = 1;
00549         goto CleanupAndExit;
00550     }
00551
00552     if ( 2 <= g_iOutputLevel )
00553     {
00554         printf("*INFO* | bind() call succeeded\n");
00555     }
00556
00557     if ( SOCKET_ERROR == ( ulRetCode = getsockname(LocalSocket, (struct sockaddr *)&SockAddrBthLocal, &iAddrLen) ) )
00558     {
00559         printf("=CRITICAL= | getsockname() call failed w/socket = [0x%X]. WSAGetLastError=[%d]\n", LocalSocket, WSAGetLastError());
00560         ulRetCode = 1;
00561         goto CleanupAndExit;
00562     }
00563
00564     //
00565     // CSADDR_INFO
00566     //
00567     lpCSAddrInfo[0].LocalAddr.iSockaddrLength = sizeof( SOCKADDR_BTH );
00568     lpCSAddrInfo[0].LocalAddr.lpSockaddr = (LPSOCKADDR)&SockAddrBthLocal;
00569     lpCSAddrInfo[0].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR_BTH );
00570     lpCSAddrInfo[0].RemoteAddr.lpSockaddr = (LPSOCKADDR)&SockAddrBthLocal;
00571     lpCSAddrInfo[0].iSocketType = SOCK_STREAM;
00572     lpCSAddrInfo[0].iProtocol = BTHPROTO_RFCOMM;
00573
00574     //
00575     // If we got an address, go ahead and advertise it.
00576     //
00577     ZeroMemory(&wsaQuerySet, sizeof(WSAQUERYSET));
00578     wsaQuerySet.dwSize = sizeof(WSAQUERYSET);
00579     wsaQuerySet.lpServiceClassId = (LPGUID) &g_guidServiceClass;
00580     //
00581     // BUGBUG should be something like "Sample Bluetooth Server"
00582     //
00583     wsaQuerySet.lpszServiceInstanceName = lptstrThisComputerName;
00584     wsaQuerySet.lpszComment = "Example Service instance registered in the directory service through RnR";
00585     wsaQuerySet.dwNameSpace = NS_BTH;
00586     wsaQuerySet.dwNumberOfCsAddrs = 1;      // Must be 1.
00587     wsaQuerySet.lpcsaBuffer = lpCSAddrInfo; // Req'd.
00588
00589     //
00590     // As long as we use a blocking accept(), we will have a race
00591     // between advertising the service and actually being ready to
00592     // accept connections.  If we use non-blocking accept, advertise
00593     // the service after accept has been called.
00594     //
00595     if ( SOCKET_ERROR == WSASetService(&wsaQuerySet, RNRSERVICE_REGISTER, 0) )
00596     {
00597         printf("=CRITICAL= | WSASetService() call failed. WSAGetLastError=[%d]\n", WSAGetLastError());
00598         ulRetCode = 1;
00599         goto CleanupAndExit;
00600     }
00601
00602     //
00603     // listen() call indicates winsock2 to listen on a given socket for any incoming connection.
00604     //
00605     if ( SOCKET_ERROR == listen(LocalSocket, SOMAXCONN) )
00606     {
00607         printf("=CRITICAL= | listen() call failed w/socket = [0x%X]. WSAGetLastError=[%d]\n", LocalSocket, WSAGetLastError());
00608         ulRetCode = 1;
00609         goto CleanupAndExit;
00610     }
00611
00612     if ( 2 <= g_iOutputLevel )
00613     {
00614         printf("*INFO* | listen() call succeeded\n");
00615     }
00616
00617     for ( iCxnCount = 0; (0 == ulRetCode) && ( (iCxnCount < iMaxCxnCycles) || (iMaxCxnCycles == 0) ); iCxnCount++ )
00618     {
00619         printf("\n");
00620
00621         //
00622         // accept() call indicates winsock2 to wait for any
00623         // incoming connection request from a remote socket.
00624         // If there are already some connection requests on the queue,
00625         // then accept() extracts the first request and creates a new socket and
00626         // returns the handle to this newly created socket. This newly created
00627         // socket represents the actual connection that connects the two sockets.
00628         //
00629         if ( INVALID_SOCKET == ( ClientSocket = accept(LocalSocket, NULL, NULL) ) )
00630         {
00631             printf("=CRITICAL= | accept() call failed. WSAGetLastError=[%d]\n", WSAGetLastError());
00632             ulRetCode = 1;
00633             break; // Break out of the for loop
00634         }
00635
00636         if ( 2 <= g_iOutputLevel )
00637         {
00638             printf("*INFO* | accept() call succeeded. CientSocket = [0x%X]\n", ClientSocket);
00639         }
00640
00641         //
00642         // Read data from the incoming stream
00643         //
00644         BOOL bContinue = TRUE;
00645         pszDataBufferIndex = &szDataBuffer[0];
00646         while ( bContinue && (iTotalLengthReceived < CXN_TRANSFER_DATA_LENGTH) )
00647         {
00648             //
00649             // recv() call indicates winsock2 to receive data
00650             // of an expected length over a given connection.
00651             // recv() may not be able to get the entire length
00652             // of data at once.  In such case the return value,
00653             // which specifies the number of bytes received,
00654             // can be used to calculate how much more data is
00655             // pending and accordingly recv() can be called again.
00656             //
00657             iLengthReceived = recv(ClientSocket, pszDataBufferIndex, (CXN_TRANSFER_DATA_LENGTH - iTotalLengthReceived), 0);
00658
00659             switch ( iLengthReceived )
00660             {
00661                 case 0: // socket connection has been closed gracefully
00662                     bContinue = FALSE;
00663                     break;
00664
00665                 case SOCKET_ERROR:
00666                     printf("=CRITICAL= | recv() call failed. WSAGetLastError=[%d]\n", WSAGetLastError());
00667                     bContinue = FALSE;
00668                     ulRetCode = 1;
00669                     break;
00670
00671                 default: // most cases when data is being read
00672                     pszDataBufferIndex += iLengthReceived;
00673                     iTotalLengthReceived += iLengthReceived;
00674                     if ( 2 <= g_iOutputLevel )
00675                     {
00676                         printf("*INFO* | Receiving data of length = [%d]. Current Total = [%d]\n", iLengthReceived, iTotalLengthReceived);
00677                     }
00678                     break;
00679             }
00680         }
00681
00682         if ( 0 == ulRetCode )
00683         {
00684             if ( CXN_TRANSFER_DATA_LENGTH != iTotalLengthReceived )
00685             {
00686                 printf("+WARNING+ | Data transfer aborted mid-stream. Expected Length = [%d], Actual Length = [%d]\n", CXN_TRANSFER_DATA_LENGTH, iTotalLengthReceived);
00687             }
00688
00689             printf("*INFO* | Received following data string from remote device:\n%s\n", szDataBuffer);
00690
00691             //
00692             // Close the connection
00693             //
00694             if ( SOCKET_ERROR == closesocket(ClientSocket) )
00695             {
00696                 printf("=CRITICAL= | closesocket() call failed w/socket = [0x%X]. WSAGetLastError=[%d]\n", LocalSocket, WSAGetLastError());
00697                 ulRetCode = 1;
00698             }
00699             else
00700             {
00701                 //
00702                 // Make the connection invalid regardless
00703                 //
00704                 ClientSocket = INVALID_SOCKET;
00705
00706                 if ( 2 <= g_iOutputLevel )
00707                 {
00708                     printf("*INFO* | closesocket() call succeeded w/socket=[0x%X]\n", ClientSocket);
00709                 }
00710             }
00711         }
00712     }
00713
00714 CleanupAndExit:
00715     if ( INVALID_SOCKET != ClientSocket )
00716     {
00717         closesocket(ClientSocket);
00718         ClientSocket = INVALID_SOCKET;
00719     }
00720
00721     if ( INVALID_SOCKET != LocalSocket )
00722     {
00723         closesocket(LocalSocket);
00724         LocalSocket = INVALID_SOCKET;
00725     }
00726
00727     if ( NULL != lptstrThisComputerName )
00728     {
00729         HeapFree(GetProcessHeap(), 0, lptstrThisComputerName);
00730         lptstrThisComputerName = NULL;
00731     }
00732
00733     if ( NULL != lpCSAddrInfo )
00734     {
00735         HeapFree(GetProcessHeap(), 0, lpCSAddrInfo);
00736         lpCSAddrInfo = NULL;
00737     }
00738
00739     return ulRetCode;
00740 }
00741
00742 //
00743 // ShowCmdLineSyntaxHelp displays the command line usage
00744 //
00745 void ShowCmdLineHelp(void)
00746 {
00747     printf(
00748           "\n  Bluetooth example application for demonstrating connection and data transfer."
00749           "\n"
00750           "\n"
00751           "\n  BTHCxnDemo.exe  [-n<RemoteName> | -a<RemoteAddress>] "
00752           "\n                  [-c<ConnectionCycles>] [-o<Output Level>]"
00753           "\n"
00754           "\n"
00755           "\n  Switches applicable for Client mode:"
00756           "\n    -n<RemoteName>        Specifies name of remote BlueTooth-Device."
00757           "\n"
00758           "\n    -a<RemoteAddress>     Specifies address of remote BlueTooth-Device."
00759           "\n                          The address is in form XX:XX:XX:XX:XX:XX"
00760           "\n                          where XX is a hexidecimal byte"
00761           "\n"
00762           "\n                          One of the above two switches is required for client."
00763           "\n"
00764           "\n"
00765           "\n  Switches applicable for both Client and Server mode:"
00766           "\n    -c<ConnectionCycles>  Specifies number of connection cycles."
00767           "\n                          Default value for this parameter is 1.  Specify 0 to "
00768           "\n                          run infinite number of connection cycles."
00769           "\n"
00770           "\n    -o<OutputLevel>       Specifies level of information reporting in cmd window."
00771           "\n                          Default value for this parameter is 0 (minimal info)."
00772           "\n                          Possible values: 1 (more info), 2 (all info)."
00773           "\n"
00774           "\n"
00775           "\n  Command Line Examples:"
00776           "\n    \"BTHCxnDemo.exe -c0\""
00777           "\n    Runs the BTHCxnDemo server for infinite connection cycles."
00778           "\n    The application reports minimal information onto the cmd window."
00779           "\n"
00780           "\n    \"BTHCxnDemo.exe -nServerDevice -c50 -o2\""
00781           "\n    Runs the BTHCxnDemo client connecting to remote device (having name "
00782           "\n    \"ServerDevice\" for 50 connection cycles."
00783           "\n    The application reports minimal information onto the cmd window."
00784           "\n"
00785           );
00786 }
00787
00788 //
00789 // ParseCmdLine parses the command line and sets the global variables accordingly.
00790 // It returns 0 if successful, returns 1 if command line usage is to be displayed,
00791 // returns 2 in case of any other error while parsing
00792 //
00793 ULONG ParseCmdLine (IN int argc, IN char * argv[])
00794 {
00795     int   iStrLen = 0;
00796     ULONG ulRetCode = 0;
00797
00798     for ( int i = 1; i < argc; i++ )
00799     {
00800         char * pszToken = argv[i];
00801         if ( *pszToken == '-' || *pszToken == '/' )
00802         {
00803             char token;
00804
00805             //
00806             // skip over the "-" or "/"
00807             //
00808             pszToken++;
00809
00810             //
00811             // Get the command line option
00812             //
00813             token = *pszToken;
00814
00815             //
00816             // Go one past the option the option-data
00817             //
00818             pszToken++;
00819
00820             //
00821             // Get the option-data
00822             //
00823             switch ( token )
00824             {
00825                 case 'n':
00826                     iStrLen = lstrlen(pszToken);
00827                     if ( (0 < iStrLen) && (BTH_MAX_NAME_SIZE >= iStrLen)  )
00828                     {
00829                         lstrcpy(g_szRemoteName, pszToken);
00830                     }
00831                     else
00832                     {
00833                         ulRetCode = 2;
00834                         printf("!ERROR! | cmd line | Unable to parse -n<RemoteName>, length error (min 1 char, max %d chars)\n", BTH_MAX_NAME_SIZE);
00835                     }
00836                     break;
00837
00838                 case 'a':
00839                     iStrLen = lstrlen(pszToken);
00840                     if ( CXN_BDADDR_STR_LEN == iStrLen )
00841                     {
00842                         lstrcpy(g_szRemoteAddr, pszToken);
00843                     }
00844                     else
00845                     {
00846                         ulRetCode = 2;
00847                         printf("!ERROR! | cmd line | Unable to parse -a<RemoteAddress>, Remote bluetooth radio address string length expected %d | Found: %d)\n", CXN_BDADDR_STR_LEN, iStrLen);
00848                     }
00849                     break;
00850
00851                 case 'c':
00852                     if ( 0 < lstrlen(pszToken) )
00853                     {
00854                         sscanf(pszToken,"%d", &g_ulMaxCxnCycles);
00855                         if ( 0 > g_ulMaxCxnCycles )
00856                         {
00857                             ulRetCode = 2;
00858                             printf("!ERROR! | cmd line | Must provide +ve or 0 value with -c option\n");
00859                         }
00860                     }
00861                     else
00862                     {
00863                         ulRetCode = 2;
00864                         printf("!ERROR! | cmd line | Must provide a value with -c option\n");
00865                     }
00866                     break;
00867
00868                 case 'o':
00869                     if ( 0 < lstrlen(pszToken) )
00870                     {
00871                         sscanf(pszToken,"%d", &g_iOutputLevel);
00872                         if ( 0 > g_iOutputLevel )
00873                         {
00874                             ulRetCode = 2;
00875                             printf("!ERROR! | cmd line | Must provide a +ve or 0 value with -o option");
00876                         }
00877                     }
00878                     else
00879                     {
00880                         ulRetCode = 2;
00881                         printf("!ERROR! | cmd line | Must provide a value with -o option");
00882                     }
00883                     break;
00884
00885                 case '?':
00886                 case 'h':
00887                 case 'H':
00888                 default:
00889                     ulRetCode = 1;
00890             }
00891         }
00892         else
00893         {
00894             ulRetCode = 1;
00895             printf("!ERROR! | cmd line | Bad option prefix, use '/' or '-' \n");
00896         }
00897     }
00898
00899     return ulRetCode;
00900 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

FileRepClient Member List

This is the complete list of members for FileRepClient, including all inherited members.
RequestFile([in] handle_t hFileRepClient,[in, ref, string] STR ServerName,[in, ref, string] STR RemoteFileName,[in, ref, string] STR LocalFileName) | FileRepClient
RequestFile([in] handle_t hFileRepClient,[in, ref, string] STR ServerName,[in, ref, string] STR RemoteFileName,[in, ref, string] STR LocalFileName) | FileRepClient
RequestFile([in] handle_t hFileRepClient,[in, ref, string] STR ServerName,[in, ref, string] STR RemoteFileName,[in, ref, string] STR LocalFileName) | FileRepClient
RequestFile([in] handle_t hFileRepClient,[in, ref, string] STR ServerName,[in, ref, string] STR RemoteFileName,[in, ref, string] STR LocalFileName) | FileRepClient
STR typedef | FileRepClient
STR typedef | FileRepClient
STR typedef | FileRepClient
STR typedef | FileRepClient
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/multichan/stdafx.h Source File

  • Multimedia
  • Audio
  • multichan

stdafx.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) Microsoft Corportation. All rights reserved.
00003 */
00004
00005 // stdafx.h : include file for standard system include files,
00006 //  or project specific include files that are used frequently, but
00007 //      are changed infrequently
00008 //
00009
00010 #if !defined(AFX_STDAFX_H__C382F3EE_96AC_11D2_9012_00C04FC2D3B8__INCLUDED_)
00011 #define AFX_STDAFX_H__C382F3EE_96AC_11D2_9012_00C04FC2D3B8__INCLUDED_
00012
00013 #if _MSC_VER > 1000
00014 #pragma once
00015 #endif // _MSC_VER > 1000
00016
00017 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00018
00019 #include <afxwin.h>         // MFC core and standard components
00020 #include <afxext.h>         // MFC extensions
00021 //#include <afxdtctl.h>   // MFC support for Internet Explorer 4 Common Controls
00022 #ifndef _AFX_NO_AFXCMN_SUPPORT
00023 #include <afxcmn.h>     // MFC support for Windows Common Controls
00024 #endif // _AFX_NO_AFXCMN_SUPPORT
00025
00026 #include <afxtempl.h>
00027 #include <mmsystem.h>
00028 #include <ks.h>
00029 #include <ksmedia.h>
00030
00031
00032 // macros ------------------------------------------------------------------------------
00033 #define IsValidHandle(h)    ((h) != NULL && (h) != INVALID_HANDLE_VALUE)
00034
00035 #define SafeCloseHandle(h)  if(IsValidHandle((h))) CloseHandle((h)); (h) = NULL
00036
00037 #define SafeLocalFree(p)    if((p)) LocalFree((p)); (p) = NULL
00038
00039 #define ARRAY_ELEMENTS(a)   (sizeof((a)) / sizeof((a)[0]))
00040
00041
00042 // structs ------------------------------------------------------------------------------
00043 typedef struct
00044 {
00045     const GUID* pguidConstant;
00046     LPCSTR      pstrRep;
00047
00048 } CONST_GUID_REP, *PCONST_GUID_REP;
00049
00050 typedef struct
00051 {
00052     DWORD   dwConstant;
00053     LPCSTR  pstrRep;
00054
00055 } CONST_DWORD_REP, *PCONST_DWORD_REP;
00056
00057 typedef struct
00058 {
00059     WORD        wTag;
00060     LPCSTR      szRep;
00061 } CONST_WORD_REP, *PCONST_WORD_REP;
00062
00063 extern CONST_DWORD_REP cdrSpeakers[];
00064
00065
00066 //{{AFX_INSERT_LOCATION}}
00067 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00068
00069 #endif // !defined(AFX_STDAFX_H__C382F3EE_96AC_11D2_9012_00C04FC2D3B8__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCIncoming/RTCIncoming.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCIncoming

RTCIncoming.h

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: RTCIncoming.h
00006  * ---------- [ Header Definition File]
00007  *
00008  *
00009  *
00010  ******************************************************/
00011
00012
00013 #ifndef ___RTCINCOMING_H___
00014 #define ___RTCINCOMING_H___
00015
00016
00017
00018 #if _MSC_VER > 1000
00019 #pragma once
00020 #endif // _MSC_VER > 1000
00021
00022 #ifndef __AFXWIN_H__
00023   #error include 'stdafx.h' before including this file for PCH
00024 #endif
00025
00026 #include "resource.h"   // main symbols
00027
00028 /**********************************************************
00029 //@Class CRTCIncomingApp
00030 //
00031 //@Description
00032 //
00033 //  Main RTC APP
00034 //
00035 //
00036 //*********************************************************/
00037
00038 class CRTCIncomingApp : public CWinApp
00039 {
00040 public:
00041   CRTCIncomingApp();
00042
00043   //{{AFX_VIRTUAL(CRTCIncomingApp)
00044   public:
00045   virtual BOOL InitInstance();
00046   //}}AFX_VIRTUAL
00047
00048   // Implementation
00049
00050   //{{AFX_MSG(CRTCIncomingApp)
00051
00052   //}}AFX_MSG
00053   DECLARE_MESSAGE_MAP()
00054 };
00055
00056
00057 #endif // ___RTCINCOMING_H___
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Tbarext/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Tbarext

basesnap.Cpp

Go to the documentation of this file.
00001
00002 //==============================================================;
00003 //
00004 //  This source code is only intended as a supplement to existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include <objbase.h>
00021 #include <olectl.h>
00022 #include <initguid.h>
00023 #include "globals.h"
00024 #include "resource.h"
00025 #include "guids.h"
00026 #include "basesnap.h"
00027 #include "tbarExt.h"
00028 #include "About.h"
00029 #include "Registry.h"
00030 #include "Extend.h"
00031
00032 // our globals
00033 HINSTANCE g_hinst;
00034
00035
00036 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00037                     DWORD fdwReason,
00038                     void* lpvReserved)
00039 {
00040
00041     if (fdwReason == DLL_PROCESS_ATTACH) {
00042         g_hinst = hinstDLL;
00043     }
00044
00045     return TRUE;
00046 }
00047
00048
00049 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00050 {
00051     if ((rclsid != CLSID_CToolBarExtension) && (rclsid != CLSID_CSnapinAbout))
00052         return CLASS_E_CLASSNOTAVAILABLE;
00053
00054
00055     if (!ppvObj)
00056         return E_FAIL;
00057
00058     *ppvObj = NULL;
00059
00060     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00061     // if they ask for anything else.
00062     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00063         return E_NOINTERFACE;
00064
00065     CClassFactory *pFactory = NULL;
00066
00067     // make the factory passing in the creation function for the type of object they want
00068     if (rclsid == CLSID_CToolBarExtension)
00069         pFactory = new CClassFactory(CClassFactory::TOOLBAREXTENSION);
00070     else if (rclsid == CLSID_CSnapinAbout)
00071         pFactory = new CClassFactory(CClassFactory::ABOUT);
00072
00073     if (NULL == pFactory)
00074         return E_OUTOFMEMORY;
00075
00076     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00077
00078     return hr;
00079 }
00080
00081 STDAPI DllCanUnloadNow(void)
00082 {
00083     if (g_uObjects == 0 && g_uSrvLock == 0)
00084         return S_OK;
00085     else
00086         return S_FALSE;
00087 }
00088
00089
00090 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00091 : m_cref(0), m_factoryType(factoryType)
00092 {
00093     OBJECT_CREATED
00094 }
00095
00096 CClassFactory::~CClassFactory()
00097 {
00098     OBJECT_DESTROYED
00099 }
00100
00101 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00102 {
00103     if (!ppv)
00104         return E_FAIL;
00105
00106     *ppv = NULL;
00107
00108     if (IsEqualIID(riid, IID_IUnknown))
00109         *ppv = static_cast<IClassFactory *>(this);
00110     else
00111         if (IsEqualIID(riid, IID_IClassFactory))
00112             *ppv = static_cast<IClassFactory *>(this);
00113
00114         if (*ppv)
00115         {
00116             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00117             return S_OK;
00118         }
00119
00120         return E_NOINTERFACE;
00121 }
00122
00123 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00124 {
00125     return InterlockedIncrement((LONG *)&m_cref);
00126 }
00127
00128 STDMETHODIMP_(ULONG) CClassFactory::Release()
00129 {
00130     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00131     {
00132         delete this;
00133         return 0;
00134     }
00135     return m_cref;
00136 }
00137
00138 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00139 {
00140     HRESULT  hr;
00141     void* pObj;
00142
00143     if (!ppvObj)
00144         return E_FAIL;
00145
00146     *ppvObj = NULL;
00147
00148     // Our object does does not support aggregation, so we need to
00149     // fail if they ask us to do aggregation.
00150     if (pUnkOuter)
00151         return CLASS_E_NOAGGREGATION;
00152
00153     if (TOOLBAREXTENSION == m_factoryType) {
00154         pObj = new CToolBarExtension();
00155     } else {
00156         pObj = new CSnapinAbout();
00157     }
00158
00159     if (!pObj)
00160         return E_OUTOFMEMORY;
00161
00162     // QueryInterface will do the AddRef() for us, so we do not
00163     // do it in this function
00164     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00165
00166     if (FAILED(hr))
00167         delete pObj;
00168
00169     return hr;
00170 }
00171
00172 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00173 {
00174     if (fLock)
00175         InterlockedIncrement((LONG *)&g_uSrvLock);
00176     else
00177         InterlockedDecrement((LONG *)&g_uSrvLock);
00178
00179     return S_OK;
00180 }
00181
00182 //////////////////////////////////////////////////////////
00183 //
00184 // Exported functions
00185 //
00186
00187
00188 //
00189 // Server registration
00190 //
00191 STDAPI DllRegisterServer()
00192 {
00193     HRESULT hr = SELFREG_E_CLASS;
00194
00195     _TCHAR szName[256];
00196     _TCHAR szSnapInName[256];
00197
00198     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00199     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00200
00201     _TCHAR szAboutName[256];
00202
00203     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00204
00205
00206     // register our CoClasses
00207     hr = RegisterServer(g_hinst,
00208         CLSID_CToolBarExtension,
00209         szName);
00210
00211     if SUCCEEDED(hr)
00212         hr = RegisterServer(g_hinst,
00213         CLSID_CSnapinAbout,
00214         szAboutName);
00215
00216     // place the registry information for SnapIns
00217     if SUCCEEDED(hr)
00218         hr = RegisterSnapin(CLSID_CToolBarExtension, szSnapInName, CLSID_CSnapinAbout);
00219
00220     return hr;
00221 }
00222
00223
00224 STDAPI DllUnregisterServer()
00225 {
00226     if (UnregisterServer(CLSID_CToolBarExtension) == S_OK)
00227         return UnregisterSnapin(CLSID_CToolBarExtension);
00228     else
00229         return E_FAIL;
00230 }
00231
00232
00233
00234
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Event_Consumer/Include/Resource.h Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Event_Consumer
  • Include

Resource.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Resource.h
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 //{{NO_DEPENDENCIES}}
00017 // Microsoft Developer Studio generated include file.
00018 // Used by propprov.rc
00019 //
00020
00021 // Next default values for new objects
00022 //
00023 #ifdef APSTUDIO_INVOKED
00024 #ifndef APSTUDIO_READONLY_SYMBOLS
00025 #define _APS_NO_MFC                     1
00026 #define _APS_NEXT_RESOURCE_VALUE        101
00027 #define _APS_NEXT_COMMAND_VALUE         40001
00028 #define _APS_NEXT_CONTROL_VALUE         1000
00029 #define _APS_NEXT_SYMED_VALUE           101
00030 #endif
00031 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/Ras_Statistics/RasGetConnectionStatistics.c Source File

  • NetDS
  • Ras
  • Ras_Statistics

RasGetConnectionStatistics.c

Go to the documentation of this file.
00001 //
00002 //       This is a part of the Microsoft Source Code Samples.
00003 //       Copyright 1993 - 2002 Microsoft Corporation.
00004 //       All rights reserved.
00005 //       This source code is only intended as a supplement to
00006 //       Microsoft Development Tools and/or WinHelp documentation.
00007 //       See these sources for detailed information regarding the
00008 //       Microsoft samples programs.
00009 //
00010
00011 //
00012 //    RasGetConnectionStatistics.c
00013 //
00014 //    Usage:
00015 //    RasGetConnectionStatistics
00016 //
00017 //    RAS API's used:
00018 //      RasEnumConnections
00019 //      RasGetConnectionStatistics
00020 //
00021 #ifndef _WIN32_WINNT
00022 #define _WIN32_WINNT 0x500
00023 #endif
00024
00025 // Macro for counting maximum characters that will fit into a buffer
00026 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00027
00028 #include <windows.h>
00029 #include <stdio.h>
00030 #include <ras.h>
00031 #include <raserror.h>
00032 #include <tchar.h>
00033
00034 int main(void)
00035 {
00036   DWORD   nRet = 0;
00037   LPRASCONN lpRasConn = NULL;
00038     LPRASCONN lpTempRasConn = NULL;
00039   DWORD   cb = sizeof(RASCONN);
00040   DWORD   cConnections = 0;
00041     RAS_STATS *lpStatistics = NULL;
00042     BOOL        fSuccess = FALSE;
00043     DWORD       i = 0;
00044     TCHAR       szTempBuf[256] = {0};
00045
00046   // Allocate buffer with default value
00047   lpRasConn = (LPRASCONN)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00048   if (NULL == lpRasConn)
00049   {
00050     printf("HeapAlloc failed.\n");
00051     return ERROR_OUTOFMEMORY;
00052   }
00053
00054   lpRasConn->dwSize = sizeof(RASCONN);
00055
00056   // Call RasEnumConnections to obtain the handle of the current active RAS connection
00057   nRet = RasEnumConnections(lpRasConn, &cb, &cConnections);
00058
00059     switch (nRet)
00060     {
00061     case ERROR_BUFFER_TOO_SMALL:
00062         if (HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasConn))
00063         {
00064
00065             lpRasConn = (LPRASCONN)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00066           if (NULL == lpRasConn)
00067           {
00068             printf("HeapAlloc failed.\n");
00069             return ERROR_OUTOFMEMORY;
00070           }
00071
00072           lpRasConn->dwSize = sizeof(RASCONN);
00073
00074             nRet = RasEnumConnections(lpRasConn, &cb, &cConnections);
00075             if (ERROR_SUCCESS == nRet)
00076             {
00077                 fSuccess = TRUE;
00078             }
00079             else
00080             {
00081             printf("RasEnumConnections failed: Error = %d\n", nRet);
00082                 goto done;
00083             }
00084         }
00085         else
00086         {
00087             printf("HeapFree failed.\n");
00088             return GetLastError();
00089         }
00090         break;
00091
00092     case ERROR_SUCCESS:
00093             fSuccess = TRUE;
00094             break;
00095
00096     default:
00097     printf("RasEnumConnections failed: Error = %d\n", nRet);
00098         goto done;
00099         break;
00100     }
00101
00102     if (fSuccess)
00103     {
00104       // Allocate buffer to obtain the RAS statistics
00105       lpStatistics = (RAS_STATS*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RAS_STATS));
00106
00107       if (NULL == lpStatistics)
00108       {
00109         printf("HeapAlloc failed.\n");
00110         goto done;
00111       }
00112
00113         lpTempRasConn = lpRasConn;
00114         for (i = 0; i < cConnections; i++)
00115         {
00116             ZeroMemory(lpStatistics, sizeof(RAS_STATS));
00117           lpStatistics->dwSize = sizeof(RAS_STATS);
00118
00119           // Call RasGetConnectionStatistics
00120           nRet = RasGetConnectionStatistics(lpTempRasConn->hrasconn, lpStatistics);
00121           if(ERROR_SUCCESS != nRet) // RasGetConnectionStatistics returned an error
00122           {
00123             printf("RasGetConnectionStatistics failed: Error = %d\n", nRet);
00124                 goto done;
00125           }
00126
00127
00128
00129             // Print the results obtained
00130           _snprintf(szTempBuf, CELEMS(szTempBuf) - 1, "Statistics for %s connection\n\n", lpTempRasConn->szEntryName);
00131             printf(szTempBuf);
00132
00133           printf("Bytes Xmited\t\t\t%d\n", lpStatistics->dwBytesXmited);
00134           printf("Bytes Received\t\t\t%d\n", lpStatistics->dwBytesRcved);
00135           printf("Frames Xmited\t\t\t%d\n", lpStatistics->dwFramesXmited);
00136           printf("Frames Received\t\t\t%d\n", lpStatistics->dwFramesRcved);
00137           printf("Crc Error\t\t\t%d\n", lpStatistics->dwCrcErr);
00138           printf("Timeout Error\t\t\t%d\n", lpStatistics->dwTimeoutErr);
00139           printf("Alignment Error\t\t\t%d\n", lpStatistics->dwAlignmentErr);
00140           printf("Hardware Overrun Error\t\t%d\n", lpStatistics->dwHardwareOverrunErr);
00141           printf("Framing Error\t\t\t%d\n", lpStatistics->dwFramingErr);
00142           printf("Buffer Overrun Error\t\t%d\n", lpStatistics->dwBufferOverrunErr);
00143           printf("Compression Ratio [In]\t\t%d\n", lpStatistics->dwCompressionRatioIn);
00144           printf("Compression Ratio [Out]\t\t%d\n", lpStatistics->dwCompressionRatioOut);
00145           printf("Baud Rate [bps]\t\t\t%d\n", lpStatistics->dwBps);
00146           printf("Connection Duration [mili sec]\t%d\n", lpStatistics->dwConnectDuration);
00147             lpTempRasConn++;
00148         }
00149
00150         nRet = ERROR_SUCCESS;
00151     }
00152
00153 done:
00154   // Clean up
00155   if (lpRasConn)
00156     {
00157         HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasConn);
00158     }
00159
00160     if (lpStatistics)
00161     {
00162       HeapFree(GetProcessHeap(), 0, (LPVOID)lpStatistics);
00163     }
00164
00165   return (int)nRet;
00166 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

STR_BINDING Member List

This is the complete list of members for STR_BINDING, including all inherited members.
fChar | STR_BINDING
indPtr | STR_BINDING
siDisplaySize | STR_BINDING
sNext | STR_BINDING
szBuffer | STR_BINDING
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/CStrTabl.h Source File

  • WinUI
  • Shell
  • FileView

CStrTabl.h

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  PROGRAM:CSTRTABL.H
00009 //
00010 //  PURPOSE: Class and structure definitions for the CStringTable class
00011 //   that helps to manage and retrieve strings from stringtables.
00012 //
00013 //  PLATFORMS:  Windows 95
00014 //
00015 //  SPECIAL INSTRUCTIONS: N/A
00016 //
00017 #ifndef _CSTRTABL_H_
00018 #define _CSTRTABL_H_
00019
00020
00021 /*
00022  * CStringTable providing string table management.  Provides
00023  * simple [] array lookup using a stringtable ID to obtain
00024  * string pointers.
00025  */
00026
00027 class CStringTable
00028     {
00029     protected:
00030         HINSTANCE       m_hInst;
00031         UINT            m_idsMin;
00032         UINT            m_idsMax;
00033         USHORT          m_cStrings;
00034         LPSTR           m_pszStrings;
00035         LPSTR          *m_ppszTable;
00036
00037     public:
00038         CStringTable(HINSTANCE);
00039         ~CStringTable(void);
00040
00041         BOOL FInit(UINT, UINT, UINT);
00042
00043         //Function to resolve an ID into a string pointer.
00044         const LPSTR operator [](const UINT) const;
00045     };
00046
00047 typedef CStringTable * PCStringTable;
00048
00049
00050 #endif //_CSTRTABL_H_
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/FreServe/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • FreServe

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the class factories of the FRESERVE
00005              server.  This server provides the Ball COM component. For
00006              this component, IClassFactory is implemented in an
00007              appropriate class factory COM object: CFBall. The COM
00008              component that can be manufactured by this server is known
00009              outside the server by its CLSID: CLSID_DllBall.
00010
00011              For a comprehensive tutorial code tour of this module's
00012              contents and offerings see the tutorial FRESERVE.HTM
00013              file. For more specific technical details on the internal
00014              workings see the comments dispersed throughout the module's
00015              source code.
00016
00017   Classes:   CFBall.
00018
00019   Functions: .
00020
00021   Origin:    4-6-96: atrent - Editor-inheritance from CAR.CPP in
00022                the DLLSERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include APPUTIL.H because we will be building this DLL using
00043     the convenient Virtual Window and Dialog classes and other
00044     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00045   We include IBALL.H and BALLGUID.H for the common ball-related Interface
00046     class, GUID, and CLSID specifications.
00047   We include SERVER.H because it has the necessary internal class and
00048     resource definitions for this DLL.
00049   We include FACTORY.H because it has the necessary internal class factory
00050     declarations for this DLL component server.  Those factories we will be
00051     implementing in this module.
00052   We include BALL.H, for the object class declarations for the COBall
00053     COM object.
00054 ---------------------------------------------------------------------------*/
00055 #include <windows.h>
00056 #include <ole2.h>
00057 #include <apputil.h>
00058 #include <iball.h>
00059 #include <ballguid.h>
00060 #include "server.h"
00061 #include "factory.h"
00062 #include "ball.h"
00063
00064 /*---------------------------------------------------------------------------
00065   Implementation the CFBall Class Factory.  CFBall is the COM
00066   object class for the Class Factory that can manufacture COBall
00067   COM Components.
00068 ---------------------------------------------------------------------------*/
00069
00070 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00071   Method:   CFBall::CFBall
00072
00073   Summary:  CFBall Constructor. Note the member initializer:
00074             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00075             to pass the 'this', pUnkOuter, and pServer pointers of this
00076             constructor function to the constructor executed in the
00077             instantiation of the CImpIClassFactory interface whose
00078             implementation is nested inside this present object class.
00079
00080   Args:     IUnknown* pUnkOuter,
00081               Pointer to the the outer Unknown.  NULL means this COM Object
00082               is not being Aggregated.  Non NULL means it is being created
00083               on behalf of an outside COM object that is reusing it via
00084               aggregation.
00085             CServer* pServer)
00086               Pointer to the server's control object.
00087
00088   Modifies: m_cRefs, m_pUnkOuter.
00089
00090   Returns:  void
00091 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00092 CFBall::CFBall(
00093   IUnknown* pUnkOuter,
00094   CServer* pServer) :
00095   m_ImpIClassFactory(this, pUnkOuter, pServer)
00096 {
00097   // Zero the COM object's reference count.
00098   m_cRefs = 0;
00099
00100   // No AddRef necessary if non-NULL, as we're nested.
00101   m_pUnkOuter = pUnkOuter;
00102
00103   // Init the pointer to the server control object.
00104   m_pServer = pServer;
00105
00106   return;
00107 }
00108
00109
00110 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00111   Method:   CFBall::~CFBall
00112
00113   Summary:  CFBall Destructor.
00114
00115   Args:     void
00116
00117   Returns:  void
00118 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00119 CFBall::~CFBall(void)
00120 {
00121   return;
00122 }
00123
00124
00125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00126   Method:   CFBall::QueryInterface
00127
00128   Summary:  QueryInterface of the CFBall non-delegating
00129             IUnknown implementation.
00130
00131   Args:     REFIID riid,
00132               [in] GUID of the Interface being requested.
00133             PPVOID ppv)
00134               [out] Address of the caller's pointer variable that will
00135               receive the requested interface pointer.
00136
00137   Returns:  HRESULT
00138               Standard result code. NOERROR for success.
00139 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00140 STDMETHODIMP CFBall::QueryInterface(
00141                REFIID riid,
00142                PPVOID ppv)
00143 {
00144   HRESULT hr = E_NOINTERFACE;
00145
00146   if (OwnThis())
00147   {
00148     *ppv = NULL;
00149
00150     if (IID_IUnknown == riid)
00151       *ppv = this;
00152     else if (IID_IClassFactory == riid)
00153       *ppv = &m_ImpIClassFactory;
00154
00155     if (NULL != *ppv)
00156     {
00157       // We've handed out a pointer to the interface so obey the COM rules
00158       // and AddRef the reference count.
00159       ((LPUNKNOWN)*ppv)->AddRef();
00160       hr = NOERROR;
00161     }
00162
00163     UnOwnThis();
00164   }
00165
00166   return (hr);
00167 }
00168
00169
00170 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00171   Method:   CFBall::AddRef
00172
00173   Summary:  AddRef of the CFBall non-delegating IUnknown implementation.
00174
00175   Args:     void
00176
00177   Modifies: m_cRefs.
00178
00179   Returns:  ULONG
00180               New value of m_cRefs (COM object's reference count).
00181 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00182 STDMETHODIMP_(ULONG) CFBall::AddRef(void)
00183 {
00184   ULONG cRefs;
00185
00186   if (OwnThis())
00187   {
00188     cRefs = ++m_cRefs;
00189
00190     UnOwnThis();
00191   }
00192
00193   return cRefs;
00194 }
00195
00196
00197 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00198   Method:   CFBall::Release
00199
00200   Summary:  Release of the CFBall non-delegating IUnknown implementation.
00201
00202   Args:     void
00203
00204   Modifies: m_cRefs.
00205
00206   Returns:  ULONG
00207               New value of m_cRefs (COM object's reference count).
00208 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00209 STDMETHODIMP_(ULONG) CFBall::Release(void)
00210 {
00211   ULONG cRefs;
00212   CServer* pServer;
00213
00214   if (OwnThis())
00215   {
00216     cRefs = --m_cRefs;
00217
00218     if (0 == cRefs)
00219     {
00220       pServer = m_pServer;
00221
00222       // We artificially bump the main ref count to prevent reentrancy
00223       // via the main object destructor.  Not really needed in this
00224       // CFBall but a good practice because we are aggregatable and
00225       // may at some point in the future add something entertaining like
00226       // some Releases to the CFBall destructor.
00227       m_cRefs++;
00228       UnOwnThis();
00229       delete this;
00230
00231       // We've reached a zero reference count for this COM object.
00232       // So we tell the server housing to decrement its global object
00233       // count so that the server will be unloaded if appropriate.
00234       if (NULL != pServer)
00235         pServer->ObjectsDown();
00236     }
00237     else
00238       UnOwnThis();
00239   }
00240
00241   return cRefs;
00242 }
00243
00244
00245 /*---------------------------------------------------------------------------
00246   CFBall's nested implementation of the IClassFactory interface
00247   including Constructor, Destructor, QueryInterface, AddRef, Release,
00248   CreateInstance, and LockServer methods.
00249 ---------------------------------------------------------------------------*/
00250
00251 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00252   Method:   CFBall::CImpIClassFactory::CImpIClassFactory
00253
00254   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00255
00256   Args:     CFBall* pBackObj,
00257               Back pointer to the parent outer object.
00258             IUnknown* pUnkOuter,
00259               Pointer to the outer Unknown.  For delegation.
00260             CServer* pServer)
00261               Pointer to the server's control object.
00262
00263   Modifies: m_pBackObj, m_pUnkOuter, m_pServer.
00264
00265   Returns:  void
00266 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00267 CFBall::CImpIClassFactory::CImpIClassFactory(
00268   CFBall* pBackObj,
00269   IUnknown* pUnkOuter,
00270   CServer* pServer)
00271 {
00272   // Init the Back Object Pointer to point to the parent object.
00273   m_pBackObj = pBackObj;
00274
00275   // Init the pointer to the server control object.
00276   m_pServer = pServer;
00277
00278   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00279   // We use the Back Object pointer for IUnknown delegation here if we are
00280   // not being aggregated.  If we are being aggregated we use the supplied
00281   // pUnkOuter for IUnknown delegation.  In either case the pointer
00282   // assignment requires no AddRef because the CImpIClassFactory lifetime is
00283   // quaranteed by the lifetime of the parent object in which
00284   // CImpIClassFactory is nested.
00285   if (NULL == pUnkOuter)
00286     m_pUnkOuter = pBackObj;
00287   else
00288     m_pUnkOuter = pUnkOuter;
00289
00290   return;
00291 }
00292
00293
00294 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00295   Method:   CFBall::CImpIClassFactory::~CImpIClassFactory
00296
00297   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00298
00299   Args:     void
00300
00301   Returns:  void
00302 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00303 CFBall::CImpIClassFactory::~CImpIClassFactory(void)
00304 {
00305   return;
00306 }
00307
00308
00309 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00310   Method:   CFBall::CImpIClassFactory::QueryInterface
00311
00312   Summary:  The QueryInterface IUnknown member of this IClassFactory
00313             interface implementation that delegates to m_pUnkOuter,
00314             whatever it is.
00315
00316   Args:     REFIID riid,
00317               [in] GUID of the Interface being requested.
00318             PPVOID ppv)
00319               [out] Address of the caller's pointer variable that will
00320               receive the requested interface pointer.
00321
00322   Returns:  HRESULT
00323               Standard result code. NOERROR for success.
00324               Returned by the delegated outer QueryInterface call.
00325 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00326 STDMETHODIMP CFBall::CImpIClassFactory::QueryInterface(
00327                REFIID riid,
00328                PPVOID ppv)
00329 {
00330   // Delegate this call to the outer object's QueryInterface.
00331   return m_pUnkOuter->QueryInterface(riid, ppv);
00332 }
00333
00334
00335 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00336   Method:   CFBall::CImpIClassFactory::AddRef
00337
00338   Summary:  The AddRef IUnknown member of this IClassFactory interface
00339             implementation that delegates to m_pUnkOuter, whatever it is.
00340
00341   Args:     void
00342
00343   Returns:  ULONG
00344               Returned by the delegated outer AddRef call.
00345 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00346 STDMETHODIMP_(ULONG) CFBall::CImpIClassFactory::AddRef(void)
00347 {
00348   // Delegate this call to the outer object's AddRef.
00349   return m_pUnkOuter->AddRef();
00350 }
00351
00352
00353 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00354   Method:   CFBall::CImpIClassFactory::Release
00355
00356   Summary:  The Release IUnknown member of this IClassFactory interface
00357             implementation that delegates to m_pUnkOuter, whatever it is.
00358
00359   Args:     void
00360
00361   Returns:  ULONG
00362               Returned by the delegated outer Release call.
00363 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00364 STDMETHODIMP_(ULONG) CFBall::CImpIClassFactory::Release(void)
00365 {
00366   // Delegate this call to the outer object's Release.
00367   return m_pUnkOuter->Release();
00368 }
00369
00370
00371 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00372   Method:   CFBall::CImpIClassFactory::CreateInstance
00373
00374   Summary:  The CreateInstance member method of this IClassFactory
00375             interface implementation.  Creates an instance of the COBall
00376             COM component.
00377
00378   Args:     IUnknown* pUnkOuter,
00379               [in] Pointer to the controlling IUnknown.
00380             REFIID riid,
00381               [in] GUID of the Interface being requested.
00382             PPVOID ppvCob)
00383               [out] Address of the caller's pointer variable that will
00384               receive the requested interface pointer.
00385
00386   Returns:  HRESULT
00387               Standard result code. NOERROR for success.
00388 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00389 STDMETHODIMP CFBall::CImpIClassFactory::CreateInstance(
00390                IUnknown* pUnkOuter,
00391                REFIID riid,
00392                PPVOID ppv)
00393 {
00394   HRESULT hr = E_FAIL;
00395   COBall* pCob = NULL;
00396
00397   // NULL the output pointer.
00398   *ppv = NULL;
00399
00400   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00401   // the COM rules state the IUnknown interface MUST also be concomitantly
00402   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00403   // an error must be returned indicating that no aggregate creation of
00404   // the CFBall COM Object can be performed.
00405   if (NULL != pUnkOuter && riid != IID_IUnknown)
00406     hr = CLASS_E_NOAGGREGATION;
00407   else
00408   {
00409     // Instantiate a COBall COM Object.
00410     pCob = new COBall(pUnkOuter, m_pServer);
00411     if (NULL != pCob)
00412     {
00413       // We initially created the new COM object so tell the server
00414       // to increment its global server object count to help ensure
00415       // that the server remains loaded until this partial creation
00416       // of a COM component is completed.
00417       m_pServer->ObjectsUp();
00418
00419       // We QueryInterface this new COM Object not only to deposit the
00420       // main interface pointer to the caller's pointer variable, but to
00421       // also automatically bump the Reference Count on the new COM
00422       // Object after handing out this reference to it.
00423       hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00424       if (FAILED(hr))
00425       {
00426         m_pServer->ObjectsDown();
00427         delete pCob;
00428       }
00429     }
00430     else
00431       hr = E_OUTOFMEMORY;
00432   }
00433
00434   return hr;
00435 }
00436
00437
00438 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00439   Method:   CFBall::CImpIClassFactory::LockServer
00440
00441   Summary:  The LockServer member method of this IClassFactory interface
00442             implementation.
00443
00444   Args:     BOOL fLock)
00445               [in] Flag determining whether to Lock or Unlock the server.
00446
00447   Returns:  HRESULT
00448               Standard result code. NOERROR for success.
00449 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00450 STDMETHODIMP CFBall::CImpIClassFactory::LockServer(
00451                BOOL fLock)
00452 {
00453   HRESULT hr = NOERROR;
00454
00455   if (fLock)
00456     m_pServer->Lock();
00457   else
00458     m_pServer->Unlock();
00459
00460   return hr;
00461 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpcmenu/scpcmenuui.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpcmenu

scpcmenuui.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       scpcmenuui.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef __SCPCMENUUI_H
00012 #define __SCPCMENUUI_H
00013
00014 #define BYTE_OFFSET(base, offset) (((LPBYTE)base)+offset)
00015
00016 class CSCPCMenuDialog : public CDialog
00017 {
00018 public:
00019   CSCPCMenuDialog(IDataObject* pDataObj) : CDialog(IDD_SCP_MENU_DIALOG)
00020   {
00021     m_spDataObj   = pDataObj;
00022     m_szPrefix    = _T("");
00023     m_szUsername  = _T("");
00024     m_szServer    = _T("");
00025     m_szServerConfigPath = _T("");
00026     m_szADsPath   = _T("");
00027     m_szClass     = _T("");
00028   }
00029
00030   ~CSCPCMenuDialog() {}
00031
00032   virtual BOOL OnInitDialog();
00033
00034   void RetrieveData();
00035   void SetUIData();
00036
00037   DECLARE_MESSAGE_MAP()
00038 private:
00039   CComPtr<IDataObject>  m_spDataObj;
00040   CLIPFORMAT            m_cfDsDisplaySpecOptions;
00041   CLIPFORMAT            m_cfDsObjectNames;
00042
00043   CString               m_szPrefix;
00044   CString               m_szUsername;
00045   CString               m_szServer;
00046   CString               m_szServerConfigPath;
00047   CString               m_szADsPath;
00048   CString               m_szClass;
00049 };
00050
00051 #endif // __SCPCMENUUI_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/registry.h Source File

  • SysMgmt
  • MMC
  • About

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MultiSelectCookies Member List

This is the complete list of members for _MultiSelectCookies, including all inherited members.
Cookies | _MultiSelectCookies
count | _MultiSelectCookies
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/Driver/StdAfx.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • Driver

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__EFBDA7A4_E2EF_11D1_821E_C20823B1B03A__INCLUDED_)
00006 #define AFX_STDAFX_H__EFBDA7A4_E2EF_11D1_821E_C20823B1B03A__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014 #if !defined(_WIN32_WINNT)
00015 #define _WIN32_WINNT 0x0500
00016 #endif // !defined(_WIN32_WINNT)
00017
00018 #include <atlbase.h>
00019
00020 #include <crtdbg.h>
00021 #include <comsvcs.h>
00022 #include <stdlib.h>
00023 #include <time.h>
00024 #include <comdef.h>
00025
00026 #endif // !defined(AFX_STDAFX_H__EFBDA7A4_E2EF_11D1_821E_C20823B1B03A__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/Globals.h Source File

  • SysMgmt
  • MMC
  • Help

Globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025   #define IDM_BUTTON1    0x100
00026   #define IDM_BUTTON2    0x101
00027
00028   extern HINSTANCE g_hinst;
00029   extern ULONG g_uObjects;
00030
00031   #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032   #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034   // uncomment the following #define to enable message cracking
00035   // #define MMC_CRACK_MESSAGES
00036   void MMCN_Crack(BOOL bComponentData,
00037           IDataObject *pDataObject,
00038           IComponentData *pCompData,
00039           IComponent *pComp,
00040           MMC_NOTIFY_TYPE event,
00041           LPARAM arg,
00042           LPARAM param);
00043 #endif
00044
00045 //=--------------------------------------------------------------------------=
00046 // allocates a temporary buffer that will disappear when it goes out of scope
00047 // NOTE: be careful of that -- make sure you use the string in the same or
00048 // nested scope in which you created this buffer. people should not use this
00049 // class directly.  use the macro(s) below.
00050 //
00051 class TempBuffer {
00052   public:
00053     TempBuffer(ULONG cBytes) {
00054         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00055         m_fHeapAlloc = (cBytes > 120);
00056     }
00057     ~TempBuffer() {
00058         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00059     }
00060     void *GetBuffer() {
00061         return m_pBuf;
00062     }
00063
00064   private:
00065     void *m_pBuf;
00066     // we'll use this temp buffer for small cases.
00067     //
00068     char  m_szTmpBuf[120];
00069     unsigned m_fHeapAlloc:1;
00070 };
00071
00072 //=--------------------------------------------------------------------------=
00073 // string helpers.
00074 //
00075 // given a _TCHAR, copy it into a wide buffer.
00076 // be careful about scoping when using this macro!
00077 //
00078 // how to use the below two macros:
00079 //
00080 //  ...
00081 //  LPTSTR pszT;
00082 //  pszT = MyGetTStringRoutine();
00083 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00084 //  MyUseWideStringRoutine(pwsz);
00085 //  ...
00086 #ifdef UNICODE
00087 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00088     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00089     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00090     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00091     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00092 #else // ANSI
00093 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00094     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00095     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00096     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00097     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00098     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00099 #endif
00100
00101 #ifdef UNICODE
00102 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00103     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00104     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00105     lstrcpyW((LPWSTR)ptrname, tstr)
00106 #else // ANSI
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00109     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00110     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00111     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00112 #endif
00113
00114 //
00115 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00116 // have to be declared, and no clean up must be done.
00117 //
00118 // * 2 for DBCS handling in below length computation
00119 //
00120 #ifdef UNICODE
00121 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00122     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00123     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00124     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00125     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00126 #else // ANSI
00127 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00128     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00129     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00130     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00131     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00132 #endif
00133
00134 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/Java/Hello/HelloJ.java Source File

  • Web
  • MSAgent
  • Java
  • Hello

HelloJ.java

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright (C) 1997-1998 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011 //
00012 // This sample demonstrates the simplest use of Microsoft Agent from a
00013 // Java Applet.
00014 //
00015 //==========================================================================
00016
00017 // Standard java imports
00018
00019 import java.applet.*;
00020 import java.awt.*;
00021
00022 // COM and Microsoft Agent imports
00023
00024 import com.ms.com.Variant;
00025 import agentsvr.AgentServer;
00026 import agentsvr.IAgentEx;
00027 import agentsvr.IAgentCharacter;
00028 import agentsvr.IAgentCharacterEx;
00029
00030 // The HelloAgentJava class (Single threaded)
00031
00032 public class HelloJ extends Applet
00033 {
00034   // Private members necessary for Agent instantiation
00035
00036   private IAgentEx      m_AgentEx = null;
00037   private IAgentCharacterEx m_Character[] = {null};
00038   private int         m_CharacterID[] = {-1};
00039   private int         m_RequestID[] = {0};
00040   private final String    m_CharacterPathOld = "\\program files\\microsoft agent\\characters\\merlin.acs";
00041
00042   private final int     FALSE = 0;
00043   private final int     TRUE = 1;
00044
00045
00046   public HelloJ()
00047   {
00048     // Constructor left intentionally blank
00049   }
00050
00051   public String getAppletInfo()
00052   {
00053     return "Name: HelloJ\r\n" +
00054            "Author: anonymous\r\n" +
00055            "Created with Microsoft Visual J++ Version 1.1";
00056   }
00057
00058   public void init()
00059   {
00060       resize(0, 0);
00061   }
00062
00063   public void destroy()
00064   {
00065   }
00066
00067   public void paint(Graphics g)
00068   {
00069   }
00070
00071   public void start()
00072   {
00073     // Start the Microsoft Agent Server
00074
00075     m_AgentEx = (IAgentEx) new AgentServer();
00076
00077     try
00078     {
00079       // First try to load a default character
00080
00081       m_AgentEx.Load(new Variant(), m_CharacterID, m_RequestID);
00082
00083     }
00084     catch(com.ms.com.ComException e)
00085     {
00086       // No default character. Try to load Merlin from the directory
00087       // most commonly used in version 1.5 applications.
00088
00089       Variant characterPath = new Variant();
00090       characterPath.putString(m_CharacterPathOld);
00091
00092       try {
00093
00094         m_AgentEx.Load(characterPath, m_CharacterID, m_RequestID);
00095
00096       }
00097       catch(com.ms.com.ComException e2)
00098       {
00099         // Hmmm.  We couldn't load the character so what else
00100         // can we do?
00101
00102         stop();
00103         return;
00104       }
00105     }
00106
00107     try {
00108
00109       // Get the IAgentCharacter interface.
00110       // NOTE NOTE NOTE!!! If you are using Visual J++ or
00111       // other Java environments that can correctly handle
00112       // derived COM types (e.g. IAgentCharacterEx) then you
00113       // can retrieve the character interface with a single
00114       // call to GetCharacterEx.
00115       //
00116       //    m_AgentEx.GetCharacterEx(m_CharacterID[0], m_Character);
00117       //
00118       // Some environments (e.g. Visual J++ 1.1) do not correctly
00119       // handle derived COM types. So retrieving the IAgentCharacterEx
00120       // interface is a 2 step process. First get the IAgentCharacter
00121       // interface.
00122
00123       IAgentCharacter char15[] = {null};
00124       m_AgentEx.GetCharacter(m_CharacterID[0], char15);
00125
00126       // Then get the IAgentCharacterEx interface and release
00127       // the IAgentCharacter interface.
00128
00129       m_Character[0] = (IAgentCharacterEx)char15[0];
00130       char15 = null;
00131
00132       // Set the character's language
00133
00134       m_Character[0].SetLanguageID(0x0409);
00135
00136       // Show the character
00137
00138       m_Character[0].Show(FALSE, m_RequestID);
00139
00140       // And speak hello
00141
00142       m_Character[0].Speak("Hello World!", null, m_RequestID);
00143
00144     }
00145     catch(com.ms.com.ComException e)
00146     {
00147       stop();
00148     }
00149   }
00150
00151   public void stop()
00152   {
00153     if (m_CharacterID[0] > 0)
00154     {
00155       m_Character[0] = null;
00156       m_AgentEx.Unload(m_CharacterID[0]);
00157       m_CharacterID[0] = -1;
00158     }
00159
00160     m_AgentEx = null;
00161   }
00162 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/RootDSE/VC/RootDSE.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • RootDSE
  • VC

RootDSE.cpp

Go to the documentation of this file.
00001 // RootDSE.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005
00006
00007 int main(int argc, char* argv[])
00008 {
00009   IADs    *pRoot=NULL;
00010   VARIANT varDSRoot;
00011   HRESULT hr;
00012
00013   hr = CoInitialize(NULL);
00014
00015
00016   /////////////////////////////////////////////////////////////////////////////
00017   // NOTE: If your client is NT 4.0 or Win 9.x without the DS Client, you
00018   // must put the server name in front of the LDAP://.  For example
00019   // ADsGetObject(L"LDAP://myDC/RootDSE")
00020   // If your client is Windows 2000, you don't need to specify the servername.
00021   // The locator service in Windows 2000 will automatically locate the best DC for you
00022   /////////////////////////////////////////////////////////////////////////////////////
00023
00024   // Get the Directory Object on the root DSE, to get to the server configuration
00025   hr = ADsGetObject(L"LDAP://RootDSE",IID_IADs,(void**)&pRoot);
00026
00027   if(SUCCEEDED(hr) && pRoot != NULL)
00028   {
00029
00030     hr = pRoot->Get(L"defaultNamingContext",&varDSRoot);
00031     if(SUCCEEDED(hr))
00032       printf("\nDefault Naming Context:%S\n",varDSRoot.bstrVal);
00033     VariantClear(&varDSRoot);
00034
00035
00036     hr = pRoot->Get(L"rootDomainNamingContext",&varDSRoot);
00037     if(SUCCEEDED(hr))
00038       printf("\nRoot Domain Naming Context:%S\n",varDSRoot.bstrVal);
00039     VariantClear(&varDSRoot);
00040
00041     hr = pRoot->Get(L"configurationNamingContext",&varDSRoot);
00042     if(SUCCEEDED(hr))
00043       printf("\nConfiguration Naming Context :%S\n",varDSRoot.bstrVal);
00044     VariantClear(&varDSRoot);
00045
00046
00047     hr = pRoot->Get(L"schemaNamingContext",&varDSRoot);
00048     if(SUCCEEDED(hr))
00049       printf("\nSchema Naming context :%S\n",varDSRoot.bstrVal);
00050     VariantClear(&varDSRoot);
00051
00052   }
00053
00054       if (pRoot)
00055         pRoot->Release();
00056
00057
00058   CoUninitialize();
00059
00060   return 0;
00061 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMultipleResults Member List

This is the complete list of members for CMultipleResults, including all inherited members.
AutoQI(DWORD dwCreateOpts) | CMultipleResults | [virtual]
AutoRelease() | CMultipleResults | [virtual]
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CMultipleResults(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CMultipleResults |
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
DisplayObject() | CBase | [virtual]
GetBaseType() | CBase | [inline]
GetDefaultInterface() | CMultipleResults | [inline, virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CMultipleResults | [virtual]
GetObjectDesc() | CBase | [inline, virtual]
GetObjectImage() | CMultipleResults | [inline, virtual]
GetObjectMenu() | CMultipleResults | [inline, virtual]
GetObjectName() | CMultipleResults | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetParent(SOURCE eSource) | CBase | [virtual]
GetResult(CAggregate *pCAggregate, DB_LRESERVE lResultFlag, REFIID riid, DBROWCOUNT *pcRowsAffected, IUnknown **ppIUnknown) | CMultipleResults | [virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_cRef | CBase | [protected]
m_dwCLSCTX | CBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_guidSource | CBase |
m_hTreeItem | CBase |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pIMultipleResults | CMultipleResults |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_strObjectDesc | CBase | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
~CBase() | CBase | [virtual]
~CMultipleResults() | CMultipleResults | [virtual]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTextField Member List

This is the complete list of members for CTextField, including all inherited members.
_font | CTextField | [protected]
_sz | CTextField | [protected]
CTextField(TCHAR *sz) | CTextField |
GetExtent(CCanvas &canvas, SIZE *psize) | CTextField |
Hittest(CCanvas &canvas, POINT pt) | CTextField |
Paint(CCanvas &canvas, int x, int y) | CTextField |
SetFont(HFONT hfont) | CTextField |
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/gfile.cpp Source File

  • Begin
  • sdkdiff

gfile.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * File Open/Create dialogs
00013  *
00014  */
00015
00016 /*
00017  * these dialog functions exist because they were written and
00018  * used before the commmon dialogs existed.
00019  *
00020  * they have now been reduced to just calls to the common file dialog
00021  * functions
00022  */
00023
00024
00025
00026 /*---includes-----------------------------------------------------------*/
00027 #include "precomp.h"
00028 #include "gutilsrc.h"
00029 #include "..\sdkdiff\errorout.h"
00030
00031 /*--functions----------------------------------------------------------*/
00032
00033 /*
00034  * gfile_open
00035  *      dialog asking the user to select an existing file to open.
00036  *
00037  * parameters
00038  *
00039  *  prompt - message to user indicating purpose of file
00040  *     (to be displayed somewhere in dialog box.
00041  *
00042  *  ext    - default file extension if user enters file without
00043  *     extension.
00044  *
00045  *  spec   - default file spec (eg *.*)
00046  *
00047  *  pszFull - buffer where full filename (including path) is returned.
00048  *
00049  *  cchMax - size of pszFull buffer.
00050  *
00051  *  fn     - buffer where filename (just final element) is returned.
00052  *
00053  * returns - true if file selected and exists (tested with OF_EXIST).
00054  *       FALSE if dialog cancelled. If user selects a file that we cannot
00055  *       open, we complain and restart the dialog.
00056  *
00057  *       if TRUE is returned, the file will have been successfully opened,
00058  *       for reading and then closed again.
00059  */
00060
00061 BOOL
00062 FAR
00063 PASCAL
00064 gfile_open(
00065     HWND hwnd,
00066     LPSTR prompt,
00067     LPSTR ext,
00068     LPSTR spec,
00069     LPSTR pszFull,
00070     int cchMax,
00071     LPSTR fn
00072     )
00073 {
00074     OPENFILENAME ofn;
00075     char achFilters[MAX_PATH];
00076     char szTmp[MAX_PATH * 2] = {0};
00077     HANDLE fh;
00078   HRESULT hr;
00079
00080     if (!pszFull)
00081     {
00082         pszFull = szTmp;
00083         cchMax = sizeof(szTmp) / sizeof(szTmp[0]);
00084     }
00085
00086     if (cchMax < 1)
00087         return FALSE;
00088
00089     /* build filter-pair buffer to contain one pair - the spec filter,
00090      * twice (one of the pair should be the filter, the second should be
00091      * the title of the filter - we don't have a title so we use the
00092      * filter both times.
00093      */
00094     hr = StringCchPrintf(achFilters, (sizeof(achFilters)/sizeof(achFilters[0])) - 1, "%s%c%s", spec, 0, spec);
00095   if (FAILED(hr))
00096     OutputError(hr, IDS_SAFE_PRINTF);
00097     /*
00098      * initialise arguments to dialog proc
00099      */
00100     memset(&ofn, 0, sizeof(ofn));
00101     // GetOpenFileName ang GetSaveFileName unfortunately
00102     // validate the size of the structue.  So we need to lie to
00103     // the function if we were built for >=Win2000 and
00104     // running on an earlier OS
00105 #if (_WIN32_WINNT >= 0x0500)
00106     ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
00107 #else
00108     ofn.lStructSize = sizeof(OPENFILENAME);
00109 #endif
00110     ofn.hwndOwner = hwnd;
00111     ofn.hInstance = NULL;
00112     ofn.lpstrFilter = achFilters;
00113     ofn.lpstrCustomFilter = NULL;
00114     ofn.nMaxCustFilter = 0;
00115     ofn.nFilterIndex = 1;       // first filter pair in list
00116     pszFull[0] = '\0';
00117     ofn.lpstrFile = pszFull;        // we need to get the full path to open
00118     ofn.nMaxFile = cchMax;
00119     ofn.lpstrFileTitle = fn;        // return final elem of name here
00120     ofn.nMaxFileTitle = 13;     // assume just big enough for 8.3+null
00121     ofn.lpstrInitialDir = NULL;
00122     ofn.lpstrTitle = prompt;        // dialog title is good place for prompt text
00123     ofn.Flags = OFN_FILEMUSTEXIST |
00124                 OFN_HIDEREADONLY |
00125                 OFN_PATHMUSTEXIST;
00126     ofn.lpstrDefExt = ext;
00127
00128     /*
00129      * loop until the user cancels, or selects a file that we can open
00130      */
00131     do {
00132         if (!GetOpenFileName(&ofn)) {
00133             return(FALSE);
00134         }
00135
00136         fh = CreateFile(pszFull, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
00137
00138         if (fh == INVALID_HANDLE_VALUE) {
00139             if (MessageBox(NULL, "File Could Not Be Opened", "File Open",
00140                            MB_OKCANCEL|MB_ICONSTOP) == IDCANCEL) {
00141                 return(FALSE);
00142             }
00143         }
00144     } while (fh == INVALID_HANDLE_VALUE);
00145
00146     CloseHandle(fh);
00147
00148     return(TRUE);
00149 }
00150
00151
00152
00153
00154
00155 /*
00156  * gfile_new
00157  *      dialog asking the user to name a file for writing to.
00158  *
00159  * parameters
00160  *
00161  *  prompt - message to user indicating purpose of file
00162  *     (to be displayed somewhere in dialog box.
00163  *
00164  *  ext    - default file extension if user enters file without
00165  *     extension.
00166  *
00167  *  spec   - default file spec (eg *.*)
00168  *
00169  *  pszFull - buffer where full filename (including path) is returned.
00170  *
00171  *  cchMax - size of pszFull buffer.
00172  *
00173  *  fn     - buffer where filename (just final element) is returned.
00174  *
00175  * returns - true if file selected and exists (tested with OF_EXIST).
00176  *       FALSE if dialog cancelled. If user selects a file that we cannot
00177  *       open, we complain and restart the dialog.
00178  *
00179  *       if TRUE is returned, the file will have been successfully
00180  *       created and opened for writing and then closed again.
00181  */
00182
00183 BOOL
00184 FAR
00185 PASCAL
00186 gfile_new(
00187     LPSTR prompt,
00188     LPSTR ext,
00189     LPSTR spec,
00190     LPSTR pszFull,
00191     int cchMax,
00192     LPSTR fn
00193     )
00194 {
00195     OPENFILENAME ofn;
00196     char achFilters[MAX_PATH] = {0};
00197     char szTmp[MAX_PATH * 2];
00198     HANDLE fh;
00199   HRESULT hr;
00200
00201     if (!pszFull)
00202     {
00203         pszFull = szTmp;
00204         cchMax = sizeof(szTmp) / sizeof(szTmp[0]);
00205     }
00206
00207     if (cchMax < 1)
00208         return FALSE;
00209
00210     /* build filter-pair buffer to contain one pair - the spec filter,
00211      * twice (one of the pair should be the filter, the second should be
00212      * the title of the filter - we don't have a title so we use the
00213      * filter both times. remember double null at end of list of strings.
00214      */
00215     hr = StringCchPrintf(achFilters,(sizeof(achFilters)/sizeof(achFilters[0])) - 1, "%s%c%s", spec, 0, spec);
00216   if (FAILED(hr))
00217     OutputError(hr, IDS_SAFE_PRINTF);
00218
00219     /*
00220      * initialise arguments to dialog proc
00221      */
00222     memset(&ofn, 0, sizeof(ofn));
00223     // GetOpenFileName ang GetSaveFileName unfortunately
00224     // validate the size of the structue.  So we need to lie to
00225     // the function if we were built for >=Win2000 and
00226     // running on an earlier OS
00227 #if (_WIN32_WINNT >= 0x0500)
00228     ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
00229 #else
00230     ofn.lStructSize = sizeof(OPENFILENAME);
00231 #endif
00232     ofn.hwndOwner = NULL;
00233     ofn.hInstance = NULL;
00234     ofn.lpstrFilter = achFilters;
00235     ofn.lpstrCustomFilter = NULL;
00236     ofn.nMaxCustFilter = 0;
00237     ofn.nFilterIndex = 1;       // first filter pair in list
00238     pszFull[0] = '\0';
00239     ofn.lpstrFile = pszFull;        // we need to get the full path to open
00240     ofn.nMaxFile = cchMax;
00241     ofn.lpstrFileTitle = fn;        // return final elem of name here
00242     ofn.nMaxFileTitle = 13;     // assume just big enough for 8.3+null
00243     ofn.lpstrInitialDir = NULL;
00244     ofn.lpstrTitle = prompt;        // dialog title is good place for prompt text
00245     ofn.Flags = OFN_HIDEREADONLY;
00246     ofn.lpstrDefExt = ext;
00247
00248     /*
00249      * loop until the user cancels, or selects a file that we can create/write
00250      */
00251     do {
00252         if (!GetSaveFileName(&ofn)) {
00253             return(FALSE);
00254         }
00255
00256         fh = CreateFile(pszFull, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
00257
00258         if (fh == INVALID_HANDLE_VALUE) {
00259             if (MessageBox(NULL, "File Could Not Be Created", "File Open",
00260                            MB_OKCANCEL|MB_ICONSTOP) == IDCANCEL) {
00261                 return(FALSE);
00262             }
00263         }
00264     } while (fh == INVALID_HANDLE_VALUE);
00265
00266     CloseHandle(fh);
00267
00268     return(TRUE);
00269 }
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ExpenseBuf Member List

This is the complete list of members for _ExpenseBuf, including all inherited members.
dwAmmount | _ExpenseBuf
dwType | _ExpenseBuf
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/dxtrans/dxsurf2/dxsurf2.cpp Source File

  • Web
  • dxtrans
  • dxsurf2

dxsurf2.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // File: DXSurf2.CPP
00003 //
00004 // Desc: DXSurface example program 2. Demonstrates alpha blending pixels
00005 //       from one image over another using DXSurfaces and Surface Modifiers.
00006 //
00007 // Note: The LoadImage api requires IE4 or greater to be installed
00008 //
00009 // Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
00010 //-----------------------------------------------------------------------------
00011
00012 //-----------------------------------------------------------------------------
00013 // Include files
00014 //-----------------------------------------------------------------------------
00015 #include <windows.h>
00016 #include <stdio.h>
00017 #include <stdarg.h>
00018 #include <initguid.h>
00019 #include <dxtrans.h>  // DXSurface header file
00020 #include <dxbounds.h> // Defines the CDXDBnds class
00021 #include <dxtguid.c>  // Guids for DXSurfaces
00022 #include <dxterror.h> // DXT error codes
00023 #include "resource.h"
00024 #include <strsafe.h>
00025
00026 //-----------------------------------------------------------------------------
00027 // Local definitions
00028 //-----------------------------------------------------------------------------
00029 #define NAME                "DXSurf2"
00030 #define TITLE               "DXSurface Example 2"
00031 #define SAFE_RELEASE( ptr )         \
00032 {                                   \
00033         if (ptr) ptr->Release();    \
00034         ptr=NULL;                   \
00035 }
00036
00037 //-----------------------------------------------------------------------------
00038 // Default settings
00039 //-----------------------------------------------------------------------------
00040 #define TIMER_ID            1
00041
00042 //-----------------------------------------------------------------------------
00043 // Global data
00044 //-----------------------------------------------------------------------------
00045 IDXSurfaceFactory*      g_pSurfFact         = NULL;
00046 IDXSurface*             g_pDXSurf1          = NULL;
00047 IDXSurface*             g_pDXSurf2          = NULL;
00048 IDXSurface*             g_pDXOutSurf        = NULL;
00049 CDXDBnds                g_bnds;             // Boundaries for the output surface
00050 IDXSurface*             g_pDXSurfOnSurfMod  = NULL;
00051 IDXSurfaceModifier*     g_pSurfMod          = NULL;
00052 BOOL                    g_bActive           = FALSE;
00053 BOOL                    g_bBrighten         = TRUE;
00054 float                   g_fOpacity          = .5;
00055 HINSTANCE               g_hInst             = NULL;
00056
00057
00058 //-----------------------------------------------------------------------------
00059 // Name: ReleaseAllObjects()
00060 // Desc: Finished with all objects we use; release them.
00061 //-----------------------------------------------------------------------------
00062 static void ReleaseAllObjects(void)
00063 {
00064     SAFE_RELEASE( g_pSurfMod )
00065     SAFE_RELEASE( g_pDXSurf1 )
00066     SAFE_RELEASE( g_pDXSurf2 )
00067     SAFE_RELEASE( g_pDXSurfOnSurfMod )
00068     SAFE_RELEASE( g_pDXOutSurf )
00069     SAFE_RELEASE( g_pSurfFact )
00070 }
00071
00072 //-----------------------------------------------------------------------------
00073 // Name: InitFail()
00074 // Desc: This function is called if an initialization function fails.
00075 //-----------------------------------------------------------------------------
00076 HRESULT InitFail(HWND hWnd, HRESULT hr, LPCTSTR szError,...)
00077 {
00078     char                    szBuff[128];
00079     va_list                 vl;
00080
00081     g_bActive = FALSE;
00082     va_start( vl, szError );
00083     // Use strsafe.h version of vsprintf.
00084     StringCchVPrintf( szBuff, 128, szError, vl );
00085     MessageBox( hWnd, szBuff, TITLE, MB_OK );
00086     ReleaseAllObjects();
00087     DestroyWindow( hWnd );
00088     va_end( vl );
00089     return hr;
00090 }
00091
00092 //-----------------------------------------------------------------------------
00093 // Name: ModifySurface()
00094 // Desc: Sets the foreground and background for the surface modifier and queries
00095 //       for and IDXSurface interface off the surface modifier.
00096 //-----------------------------------------------------------------------------
00097 HRESULT ModifySurface()
00098 {
00099     HRESULT                 hr;
00100
00101     // Create the Surface Modifier object.
00102     hr = CoCreateInstance( CLSID_DXSurfaceModifier, NULL, CLSCTX_INPROC,
00103                                  IID_IDXSurfaceModifier, (void **)&g_pSurfMod );
00104
00105     // Set the foreground to the parrot.png.
00106     if( SUCCEEDED( hr ) )
00107     {
00108         hr = g_pSurfMod->SetForeground( g_pDXSurf2, FALSE, NULL );
00109     }
00110
00111     // Set the background to tulipshol2.jpg.
00112     if( SUCCEEDED( hr ) )
00113     {
00114         hr = g_pSurfMod->SetBackground( g_pDXSurf1 );
00115     }
00116
00117     // Query the Surface Modifier for an IDXSurface pointer.
00118     if( SUCCEEDED( hr ) )
00119     {
00120         hr = g_pSurfMod->QueryInterface( IID_IDXSurface, (void**)&g_pDXSurfOnSurfMod );
00121     }
00122
00123     return hr;
00124 }
00125
00126 //-----------------------------------------------------------------------------
00127 // Name: RenderToWindow()
00128 // Desc: Blit the surface containing the image to the window.
00129 //-----------------------------------------------------------------------------
00130 HRESULT RenderToWindow( HANDLE hWnd, HDC hdcWnd, float fOpacity )
00131 {
00132     HRESULT                 hr;
00133     char                    szOpacity[256];
00134     CDXDBnds                bnds;
00135     IDXDCLock*              pDCLock = NULL;
00136     RECT                    rect;
00137     HDC                     hdcSurf = NULL;
00138
00139     // This call sets the new Opacity on the foreground surface.
00140     hr =  g_pSurfMod->SetOpacity( fOpacity );
00141     if ( FAILED( hr ) )
00142         return InitFail((HWND)hWnd, hr, "Failed to SetOpacity on Surface Modifier.");
00143
00144     // Blit the DXSurface on associated with the Surface Modifier to the Output DXSurface.
00145     hr = g_pSurfFact->BitBlt( g_pDXOutSurf, NULL, g_pDXSurfOnSurfMod, NULL, DXBOF_DO_OVER );
00146     if ( FAILED( hr ) )
00147         return InitFail( (HWND)hWnd, hr, "BitBlt failed" );
00148
00149     // Call LockSurfaceDC to get the DC of the surface.
00150     hr  = g_pDXOutSurf->LockSurfaceDC( NULL, 3000, 0, &pDCLock );
00151     if ( FAILED( hr ) )
00152         return InitFail( (HWND)hWnd, hr, "LockSurfaceDC failed." );
00153
00154     hdcSurf = pDCLock->GetDC();
00155
00156     GetClientRect( (HWND)hWnd, &rect );
00157
00158     // Use GDI BitBlt to blit the surface DC to the window DC.
00159     BitBlt( hdcWnd, 0, 0, rect.right, rect.bottom, hdcSurf, 0, 0, SRCCOPY );
00160
00161     // Use strsafe.h version of sprintf.
00162     StringCchPrintf( szOpacity, 256, "Parrot alpha blended with %d%% opacity over tulips.",
00163                     (int)((g_fOpacity*100)+.01) );
00164     SetTextColor( hdcWnd, RGB(255, 255, 0) );
00165     SetBkMode( hdcWnd, TRANSPARENT );
00166     DrawText( hdcWnd, szOpacity, -1, &rect, DT_CENTER | DT_BOTTOM | DT_SINGLELINE );
00167
00168     // Release the IDXDCLock pointer which releases the DC lock on the surface as well.
00169     SAFE_RELEASE( pDCLock )
00170
00171     return hr;
00172 }
00173
00174 //-----------------------------------------------------------------------------
00175 // Name: WindowProc()
00176 // Desc: The Main Window Procedure.
00177 //-----------------------------------------------------------------------------
00178 LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
00179 {
00180     HRESULT         hr = S_OK;
00181     RECT            rect;
00182     HDC             hdcWnd;
00183     PAINTSTRUCT     ps;
00184
00185     switch( iMsg )
00186     {
00187     case WM_PAINT:
00188         hdcWnd = BeginPaint( hWnd, &ps );
00189
00190         // Render the DXSurface to the window.
00191         if( g_bActive )
00192         {
00193             RenderToWindow( hWnd, hdcWnd, g_fOpacity );
00194         }
00195
00196         EndPaint( hWnd, &ps );
00197         return 0;
00198
00199     case WM_TIMER:
00200             // Change opacity.
00201             if ( g_bActive && TIMER_ID == wParam )
00202             {
00203                 if ( g_bBrighten )
00204                 {
00205                     g_fOpacity += .05f;
00206                     if( g_fOpacity > 1 )
00207                     {
00208                         g_fOpacity = 1;
00209                         g_bBrighten = FALSE;
00210                     }
00211                 }
00212                 else
00213                 {
00214                     g_fOpacity -= .05f;
00215                     if( g_fOpacity < 0 )
00216                     {
00217                         g_fOpacity = 0;
00218                         g_bBrighten = TRUE;
00219                     }
00220                 }
00221
00222                 GetClientRect( hWnd, &rect );
00223                 InvalidateRect( hWnd, &rect, FALSE );
00224             }
00225             return 0;
00226
00227     case WM_SIZE:
00228         if( g_bActive )
00229         {
00230             // Get the boundaries of the window.
00231             GetClientRect( hWnd, &rect );
00232             g_bnds.SetXYSize( rect.right, rect.bottom );
00233
00234             // Release the existing output DXSurface and create a new one.
00235             SAFE_RELEASE( g_pDXOutSurf )
00236             hr = g_pSurfFact->CreateSurface( NULL, NULL, NULL, &g_bnds, 0,
00237                                 NULL, IID_IDXSurface, (void **)&g_pDXOutSurf );
00238         }
00239         return 0;
00240
00241     case WM_DESTROY:
00242         ReleaseAllObjects();
00243         PostQuitMessage(0);
00244         return 0;
00245     }
00246
00247     return DefWindowProc( hWnd, iMsg, wParam, lParam );
00248 }
00249
00250 //-----------------------------------------------------------------------------
00251 // Name: InitApp()
00252 // Desc: Do work required for every instance of the application:
00253 //          Create the window, initialize data.
00254 //-----------------------------------------------------------------------------
00255 static HRESULT InitApp( HINSTANCE hInstance, int iCmdShow )
00256 {
00257     HRESULT     hr;
00258     HWND        hWnd;
00259     WNDCLASSEX  wndclass;
00260     WCHAR       wstrImagePathAndFile[_MAX_PATH + _MAX_FNAME + _MAX_EXT];
00261     char        szError[256];
00262     char        szAnsiPath[256];
00263     RECT        rect;
00264
00265     wndclass.cbSize         = sizeof( wndclass );
00266     wndclass.style          = CS_HREDRAW | CS_VREDRAW;
00267     wndclass.lpfnWndProc    = WndProc;
00268     wndclass.cbClsExtra     = 0;
00269     wndclass.cbWndExtra     = 0;
00270     wndclass.hInstance      = hInstance;
00271     wndclass.hIcon          = LoadIcon( hInstance, MAKEINTRESOURCE(IDI_DXTICON) );
00272     wndclass.hCursor        = LoadCursor( NULL, IDC_ARROW );
00273     wndclass.hbrBackground  = ( HBRUSH ) GetStockObject( WHITE_BRUSH );
00274     wndclass.lpszMenuName   = NAME;
00275     wndclass.lpszClassName  = NAME;
00276     wndclass.hIconSm        = LoadIcon( hInstance, MAKEINTRESOURCE(IDI_DXTICON) );
00277
00278     RegisterClassEx( &wndclass );
00279     g_hInst = hInstance;
00280
00281     hWnd = CreateWindowEx( NULL,
00282                            NAME,
00283                            TITLE,
00284                            WS_OVERLAPPEDWINDOW,
00285                            CW_USEDEFAULT,
00286                            CW_USEDEFAULT,
00287                            CW_USEDEFAULT,
00288                            CW_USEDEFAULT,
00289                            NULL,
00290                            NULL,
00291                            hInstance,
00292                            NULL );
00293
00294     if ( !hWnd )
00295         return FALSE;
00296     ShowWindow( hWnd, iCmdShow );
00297     UpdateWindow( hWnd );
00298
00299     // Create the Surface Factory and return a pointer
00300     // (note the CLSID says DXTransformFactory but these are the same object).
00301     hr = CoCreateInstance( CLSID_DXTransformFactory, NULL, CLSCTX_INPROC,
00302                              IID_IDXSurfaceFactory, (void **)&g_pSurfFact );
00303     if ( FAILED( hr ) )
00304         return InitFail( hWnd, hr, "Failed to Create Transform/Surface Factory" );
00305
00306     // -- Load the first image
00307
00308     // Create a surface from an image file.
00309     // NOTE: The first parameter is a wide character string.  If your path
00310     // is in ANSI, use mbstowcs() or MultiByteToWideChar().
00311     hr = g_pSurfFact->LoadImage( L"tulipshol2.jpg", NULL, NULL,
00312                                   &DDPF_PMARGB32, IID_IDXSurface, (void**)&g_pDXSurf1 );
00313     if( FAILED( hr ) )
00314     {
00315         if( hr == DXTERR_REQ_IE_DLLNOTFOUND ) // Possibly need IE4.0 or greater.
00316         {
00317             return InitFail( hWnd, hr, "LoadImage failed!\n"
00318                 "Possible cause is that IE4.0 or greater is not installed.");
00319         }
00320         else
00321         {
00322             // Note - some possible errors may include:
00323             // MK_E_SYNTAX - Couldn't find the image directory.
00324             // INET_E_RESOURCE_NOT_FOUND - Couldn't find the image filename.
00325
00326             // Convert the unicode path and file string to ansi.
00327             wcstombs( szAnsiPath, wstrImagePathAndFile, 256 );
00328             // Use strsafe.h version of sprintf.
00329             StringCchPrintf( szError, 256, "LoadImage failed with error code 0x%X.\nTried to load %s",
00330                                 hr, szAnsiPath );
00331             return InitFail( hWnd, hr, szError );
00332         }
00333     }
00334
00335     // -- Load the second image
00336
00337     // Create a surface from an image file.
00338     // NOTE: The first parameter is a wide character string.  If your path
00339     // is in ANSI, use mbstowcs() or MultiByteToWideChar().
00340     hr = g_pSurfFact->LoadImage( L"parrot.png", NULL, NULL,
00341                                   &DDPF_PMARGB32, IID_IDXSurface, (void**)&g_pDXSurf2 );
00342     if( FAILED( hr ) )
00343     {
00344         if( hr == DXTERR_REQ_IE_DLLNOTFOUND ) // Possibly need IE4.0 or greater.
00345         {
00346             return InitFail( hWnd, hr, "LoadImage failed!\n"
00347                 "Possible cause is that IE4.0 or greater is not installed.");
00348         }
00349         else
00350         {
00351             // Convert the unicode path and file string to ansi.
00352             wcstombs( szAnsiPath, wstrImagePathAndFile, 256 );
00353             // Use strsafe.h version of sprintf.
00354             StringCchPrintf( szError, 256, "LoadImage failed with error code 0x%X.\nTried to load %s",
00355                                 hr, szAnsiPath );
00356             return InitFail( hWnd, hr, szError );
00357         }
00358     }
00359
00360     // Call ModifySurface function to apply opacity values to g_pDXSurf2.
00361     hr = ModifySurface();
00362     if ( FAILED( hr ) )
00363         return InitFail( hWnd, hr, "MakeSurfaceOpaque failed" );
00364
00365     GetClientRect( hWnd, &rect );
00366     // Set the boundaries of the Output DXSurface.
00367     g_bnds.SetXYSize( rect.right, rect.bottom );
00368
00369     // Create an output DXSurface.
00370     hr = g_pSurfFact->CreateSurface( NULL, NULL, NULL, &g_bnds, 0,
00371                             NULL, IID_IDXSurface, (void **)&g_pDXOutSurf );
00372     if ( FAILED( hr ) )
00373         return InitFail( hWnd, hr, "Failed to create an output DXSurface." );
00374
00375     // Create a timer to change the opacity of the parrot.
00376     if ( TIMER_ID != SetTimer(hWnd, TIMER_ID, 0, NULL ))
00377         return InitFail( hWnd, E_FAIL, "SetTimer failed." );
00378
00379     g_bActive = TRUE;
00380
00381     return hr;
00382
00383 }
00384
00385 //-----------------------------------------------------------------------------
00386 // Name: WinMain()
00387 // Desc: Initialization, message loop
00388 //-----------------------------------------------------------------------------
00389 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
00390 {
00391     MSG         msg;
00392     HRESULT     hr;
00393
00394     // Initialize the COM library.
00395     hr = CoInitialize( NULL );
00396     if( FAILED ( hr ) )
00397     {
00398         return FALSE;
00399     }
00400
00401     if ( InitApp(hInstance, iCmdShow) != S_OK )
00402     {
00403         ReleaseAllObjects();
00404         return FALSE;
00405     }
00406
00407     while( GetMessage ( &msg, NULL, 0, 0 ) )
00408     {
00409         TranslateMessage( &msg );
00410         DispatchMessage( &msg );
00411     }
00412
00413     // Uninitialize the COM library.
00414     CoUninitialize();
00415
00416     return msg.wParam;
00417 }
00418
00419
00420
00421
00422
00423
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CLListImpl< TYPE, ARG_TYPE > Member List

This is the complete list of members for CLListImpl< TYPE, ARG_TYPE >, including all inherited members.
AddHead(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddHead(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
AddTail(CLListImpl *pNewList) | CLListImpl< TYPE, ARG_TYPE > |
CLListImpl(int nBlockSize=10) | CLListImpl< TYPE, ARG_TYPE > |
CLListImpl(int nBlockSize=10) | CLListImpl< TYPE, ARG_TYPE > |
CLListImpl(int nBlockSize=10) | CLListImpl< TYPE, ARG_TYPE > |
CLListImpl(int nBlockSize=10) | CLListImpl< TYPE, ARG_TYPE > |
CLListImpl(int nBlockSize=10) | CLListImpl< TYPE, ARG_TYPE > |
CLListImpl(int nBlockSize=10) | CLListImpl< TYPE, ARG_TYPE > |
Find(ARG_TYPE SearchValue, POSITION StartAfter=NULL) const | CLListImpl< TYPE, ARG_TYPE > |
Find(ARG_TYPE SearchValue, POSITION StartAfter=NULL) const | CLListImpl< TYPE, ARG_TYPE > |
Find(ARG_TYPE SearchValue, POSITION StartAfter=NULL) const | CLListImpl< TYPE, ARG_TYPE > |
Find(ARG_TYPE SearchValue, POSITION StartAfter=NULL) const | CLListImpl< TYPE, ARG_TYPE > |
Find(ARG_TYPE SearchValue, POSITION StartAfter=NULL) const | CLListImpl< TYPE, ARG_TYPE > |
Find(ARG_TYPE SearchValue, POSITION StartAfter=NULL) const | CLListImpl< TYPE, ARG_TYPE > |
FindIndex(int nIndex) const | CLListImpl< TYPE, ARG_TYPE > |
FindIndex(int nIndex) const | CLListImpl< TYPE, ARG_TYPE > |
FindIndex(int nIndex) const | CLListImpl< TYPE, ARG_TYPE > |
FindIndex(int nIndex) const | CLListImpl< TYPE, ARG_TYPE > |
FindIndex(int nIndex) const | CLListImpl< TYPE, ARG_TYPE > |
FindIndex(int nIndex) const | CLListImpl< TYPE, ARG_TYPE > |
FreeNode(CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
FreeNode(CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
FreeNode(CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
FreeNode(CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
FreeNode(CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
FreeNode(CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
GetAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetAt(POSITION Position) const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) const | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) const | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) const | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) const | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
GetAt(POSITION Position) const | CLListImpl< TYPE, ARG_TYPE > |
GetCount() const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetCount() const | CLListImpl< TYPE, ARG_TYPE > |
GetCount() const | CLListImpl< TYPE, ARG_TYPE > |
GetCount() const | CLListImpl< TYPE, ARG_TYPE > |
GetCount() const | CLListImpl< TYPE, ARG_TYPE > |
GetCount() const | CLListImpl< TYPE, ARG_TYPE > |
GetHead() | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetHead() const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetHead() | CLListImpl< TYPE, ARG_TYPE > |
GetHead() const | CLListImpl< TYPE, ARG_TYPE > |
GetHead() | CLListImpl< TYPE, ARG_TYPE > |
GetHead() const | CLListImpl< TYPE, ARG_TYPE > |
GetHead() | CLListImpl< TYPE, ARG_TYPE > |
GetHead() const | CLListImpl< TYPE, ARG_TYPE > |
GetHead() | CLListImpl< TYPE, ARG_TYPE > |
GetHead() const | CLListImpl< TYPE, ARG_TYPE > |
GetHead() | CLListImpl< TYPE, ARG_TYPE > |
GetHead() const | CLListImpl< TYPE, ARG_TYPE > |
GetHeadPosition() const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetHeadPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetHeadPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetHeadPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetHeadPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetHeadPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetNext(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetNext(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetNext(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetPrev(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetPrev(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) | CLListImpl< TYPE, ARG_TYPE > |
GetPrev(POSITION &rPosition) const | CLListImpl< TYPE, ARG_TYPE > |
GetTail() | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetTail() const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetTail() | CLListImpl< TYPE, ARG_TYPE > |
GetTail() const | CLListImpl< TYPE, ARG_TYPE > |
GetTail() | CLListImpl< TYPE, ARG_TYPE > |
GetTail() const | CLListImpl< TYPE, ARG_TYPE > |
GetTail() | CLListImpl< TYPE, ARG_TYPE > |
GetTail() const | CLListImpl< TYPE, ARG_TYPE > |
GetTail() | CLListImpl< TYPE, ARG_TYPE > |
GetTail() const | CLListImpl< TYPE, ARG_TYPE > |
GetTail() | CLListImpl< TYPE, ARG_TYPE > |
GetTail() const | CLListImpl< TYPE, ARG_TYPE > |
GetTailPosition() const | CLListImpl< TYPE, ARG_TYPE > | [inline]
GetTailPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetTailPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetTailPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetTailPosition() const | CLListImpl< TYPE, ARG_TYPE > |
GetTailPosition() const | CLListImpl< TYPE, ARG_TYPE > |
InsertAfter(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertAfter(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertAfter(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertAfter(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertAfter(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertAfter(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertBefore(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertBefore(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertBefore(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertBefore(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertBefore(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
InsertBefore(POSITION position, ARG_TYPE newElement) | CLListImpl< TYPE, ARG_TYPE > |
IsEmpty() const | CLListImpl< TYPE, ARG_TYPE > | [inline]
IsEmpty() const | CLListImpl< TYPE, ARG_TYPE > |
IsEmpty() const | CLListImpl< TYPE, ARG_TYPE > |
IsEmpty() const | CLListImpl< TYPE, ARG_TYPE > |
IsEmpty() const | CLListImpl< TYPE, ARG_TYPE > |
IsEmpty() const | CLListImpl< TYPE, ARG_TYPE > |
m_nBlockSize | CLListImpl< TYPE, ARG_TYPE > | [protected]
m_nCount | CLListImpl< TYPE, ARG_TYPE > | [protected]
m_pBlocks | CLListImpl< TYPE, ARG_TYPE > | [protected]
m_pNodeFree | CLListImpl< TYPE, ARG_TYPE > | [protected]
m_pNodeHead | CLListImpl< TYPE, ARG_TYPE > | [protected]
m_pNodeTail | CLListImpl< TYPE, ARG_TYPE > | [protected]
NewNode(CNode *, CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
NewNode(CNode *, CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
NewNode(CNode *, CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
NewNode(CNode *, CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
NewNode(CNode *, CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
NewNode(CNode *, CNode *) | CLListImpl< TYPE, ARG_TYPE > | [protected]
RemoveAll() | CLListImpl< TYPE, ARG_TYPE > |
RemoveAll() | CLListImpl< TYPE, ARG_TYPE > |
RemoveAll() | CLListImpl< TYPE, ARG_TYPE > |
RemoveAll() | CLListImpl< TYPE, ARG_TYPE > |
RemoveAll() | CLListImpl< TYPE, ARG_TYPE > |
RemoveAll() | CLListImpl< TYPE, ARG_TYPE > |
RemoveAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
RemoveAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
RemoveAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
RemoveAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
RemoveAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
RemoveAt(POSITION Position) | CLListImpl< TYPE, ARG_TYPE > |
RemoveHead() | CLListImpl< TYPE, ARG_TYPE > |
RemoveHead() | CLListImpl< TYPE, ARG_TYPE > |
RemoveHead() | CLListImpl< TYPE, ARG_TYPE > |
RemoveHead() | CLListImpl< TYPE, ARG_TYPE > |
RemoveHead() | CLListImpl< TYPE, ARG_TYPE > |
RemoveHead() | CLListImpl< TYPE, ARG_TYPE > |
RemoveTail() | CLListImpl< TYPE, ARG_TYPE > |
RemoveTail() | CLListImpl< TYPE, ARG_TYPE > |
RemoveTail() | CLListImpl< TYPE, ARG_TYPE > |
RemoveTail() | CLListImpl< TYPE, ARG_TYPE > |
RemoveTail() | CLListImpl< TYPE, ARG_TYPE > |
RemoveTail() | CLListImpl< TYPE, ARG_TYPE > |
SetAt(POSITION Pos, ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > | [inline]
SetAt(POSITION Pos, ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
SetAt(POSITION Pos, ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
SetAt(POSITION Pos, ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
SetAt(POSITION Pos, ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
SetAt(POSITION Pos, ARG_TYPE NewElement) | CLListImpl< TYPE, ARG_TYPE > |
~CLListImpl() | CLListImpl< TYPE, ARG_TYPE > |
~CLListImpl() | CLListImpl< TYPE, ARG_TYPE > |
~CLListImpl() | CLListImpl< TYPE, ARG_TYPE > |
~CLListImpl() | CLListImpl< TYPE, ARG_TYPE > |
~CLListImpl() | CLListImpl< TYPE, ARG_TYPE > |
~CLListImpl() | CLListImpl< TYPE, ARG_TYPE > |
Generated on Wed Nov 13 2024 16:56:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/suminfo.Cpp Source File

  • Com
  • Fundamentals
  • OleStd

suminfo.Cpp

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2.0 Property Set Utilities
00004 **
00005 **    suminfo.cpp
00006 **
00007 **    This file contains functions that are useful for the manipulation
00008 **    of OLE 2.0 Property Sets particularly to manage the Summary Info
00009 **    property set.
00010 **
00011 **    (c) Copyright Microsoft Corp. 1990 - 2000 All Rights Reserved
00012 **
00013 *************************************************************************/
00014
00015 // Note: this file is designed to be stand-alone; it includes a
00016 // carefully chosen, minimal set of headers.
00017 //
00018 // For conditional compilation we use the ole2 conventions,
00019 //    _MAC      = mac
00020 //    WIN32     = Win32 (NT really)
00021 //    <nothing> = defaults to Win16
00022
00023 // REVIEW: the following needs to modified to handle _MAC
00024 #define STRICT
00025
00026 #include <string.h>
00027 #include <windows.h>
00028 #include <ole2.h>
00029 #include "ansiapi.h"
00030
00031 #ifdef WIN32
00032 #define _fmemset memset
00033 #define _fmemcpy memcpy
00034 #define _fmemcmp memcmp
00035 #define _fstrcpy strcpy
00036 #define _fstrlen strlen
00037 #endif
00038
00039 /* A LPSUMINFO variable is a pointer to an instance of an abstract data
00040 **    type.  There can be an arbitrary number of SummaryInfo streams open
00041 **    simultaneously (subject to available memory); each must have its
00042 **    own LPSUMINFO instance. Each LPSUMINFO instance must
00043 **    be initialized prior to use by calling Init and freed after its
00044 **    last use by calling Free.  The param argument to Init is reserved
00045 **    for future expansion and should be zero initially. Once a LPSUMINFO
00046 **    instance is allocated (by Init), the user can call the Set
00047 **    procedures to initialize fields.  A copy of the arguments is made
00048 **    in every case except SetThumbnail where control of the storage
00049 **    occupied by the METAFILEPICT is merely transferred.  When the
00050 **    Free routine is called, all storage will be deallocated including
00051 **    that of the thumbnail.  The arguments to SetThumbNail and the
00052 **    return values from GetThumbNail correspond to the OLE2.0 spec.
00053 **    Note that on input, the thumbnail is read on demand but all the
00054 **    other properties are pre-loaded.  The thumbnail is manipulated as
00055 **    a windows handle to a METAFILEPICT structure, which in turn
00056 **    contains a handle to the METAFILE.  The transferClip argument on
00057 **    GetThumbNail, when set to true, transfers responsibility for
00058 **    storage management of the thumbnail to the caller; that is, after
00059 **    Free has been called, the handle is still valid. Clear can be
00060 **    used to free storage for all the properties but then you must
00061 **    call Read to load them again.  All the code is based on FAR
00062 **    pointers.
00063 **    CoInitialize MUST be called PRIOR to calling OleStdInitSummaryInfo.
00064 **    Memory is allocated using the currently active IMalloc*
00065 **    allocator (as is returned by call CoGetMalloc(MEMCTX_TASK) ).
00066 **
00067 ** Common scenarios:
00068 **    Read SummaryInfo
00069 **    ----------------
00070 **      OleStdInitSummaryInfo()
00071 **      OleStdReadSummaryInfo()
00072 **      . . . . .
00073 **      call different Get routines
00074 **      . . . . .
00075 **      OleStdFreeSummaryInfo()
00076 **
00077 **    Create SummaryInfo
00078 **    ------------------
00079 **      OleStdInitSummaryInfo()
00080 **      call different Set routines
00081 **      OleStdWriteSummaryInfo()
00082 **      OleStdFreeSummaryInfo()
00083 **
00084 **    Update SummaryInfo
00085 **    ------------------
00086 **      OleStdInitSummaryInfo()
00087 **      OleStdReadSummaryInfo()
00088 **      OleStdGetThumbNailProperty(necessary only if no SetThumb)
00089 **      call different Set routines
00090 **      OleStdWriteSummaryInfo()
00091 **      OleStdFreeSummaryInfo()
00092 */
00093
00094 #define CHAR unsigned char
00095 #define fTrue 1
00096 #define fFalse 0
00097 #define BYTE unsigned char
00098 #define WORD unsigned short
00099 #define DWORD unsigned long
00100 #define LPVOID void FAR *
00101 #define uchar unsigned char
00102 #define ulong unsigned long
00103 #define BOOL unsigned char
00104 #define BF unsigned int
00105
00106 #include "suminfo.h"
00107 #include "wn_dos.h"
00108
00109 #if defined( _DEBUG )
00110 // following is from compobj.dll (ole2)
00111 #define ASSERT(x) (!(x) ? FnAssert(#x, NULL, __FILE__, __LINE__) : 0)
00112 #else
00113 #define ASSERT(x)
00114 #endif
00115
00116
00117 typedef struct _RSUMINFO
00118    {
00119    WORD byteOrder;
00120    WORD formatVersion;
00121    WORD getOSVersion;
00122    WORD osVersion;
00123    CLSID classId;  //from compobj.h
00124    DWORD cSections;
00125    PROPSETLIST rgPropSet[1/*cSections*/]; //one section in standard summary info
00126    STANDARDSECINMEM section;
00127    ULONG fileOffset;   //offset for thumbnail to support demand read
00128    } RSUMINFO;
00129
00130 typedef RSUMINFO FAR * LPRSI;
00131
00132    typedef union _foo{
00133       ULARGE_INTEGER uli;
00134       struct {
00135          DWORD       dw;
00136          DWORD       dwh;
00137          };
00138       struct {
00139          WORD    w0;
00140          WORD    w1;
00141          WORD    w2;
00142          WORD    w3;
00143          };
00144       } Foo;
00145
00146
00147
00148 /* MemAlloc
00149 ** ---------
00150 **    allocate memory using the currently active IMalloc* allocator
00151 */
00152 static LPVOID MemAlloc(ULONG ulSize)
00153 {
00154    LPVOID pout;
00155    LPMALLOC pmalloc;
00156
00157    if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR) {
00158       ASSERT(pmalloc);
00159       return NULL;
00160    }
00161
00162    pout = (LPVOID)pmalloc->Alloc(ulSize);
00163
00164    if (pmalloc != NULL) {
00165       ULONG refs = pmalloc->Release();
00166    }
00167
00168    return pout;
00169 }
00170
00171
00172 /* MemFree
00173 ** -------
00174 **    free memory using the currently active IMalloc* allocator
00175 */
00176 static void MemFree(LPVOID pmem)
00177 {
00178    LPMALLOC pmalloc;
00179
00180    if (pmem == NULL)
00181       return;
00182
00183    if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR) {
00184       ASSERT(pmalloc);
00185       return;
00186    }
00187
00188    pmalloc->Free(pmem);
00189
00190    if (pmalloc != NULL) {
00191       ULONG refs = pmalloc->Release();
00192    }
00193 }
00194
00195 // Replace the first argument with the product of itself and the multiplier
00196 static void ulargeMultiply(ULARGE_INTEGER FAR *ul, USHORT m)
00197 {
00198    Foo out, in;
00199    in.uli = *ul;
00200    out.dw = (ULONG)m * in.w0;      in.w0 = out.w0;
00201    out.dw = (ULONG)m * in.w1 + out.w1; in.w1 = out.w0;
00202    out.dw = (ULONG)m * in.w2 + out.w1; in.w2 = out.w0;
00203    out.dw = (ULONG)m * in.w3 + out.w1; in.w3 = out.w0;
00204    *ul = in.uli;
00205 }
00206
00207 // Replace the first argument with the product of itself and the multiplier
00208 static void ulargeDivide(ULARGE_INTEGER FAR *ul, USHORT m)
00209 {
00210    Foo out, in;
00211    DWORD i;
00212    in.uli = *ul;
00213    out.dwh = in.dwh/(ULONG)m;
00214    i = in.dwh%(ULONG)m;
00215    in.w2 = in.w1;
00216    in.w3 = (WORD)i;
00217    out.w1 = (WORD)(in.dwh/(ULONG)m);
00218    in.w1 = (WORD)(in.dwh%(ULONG)m);
00219    out.w0 = (WORD)(in.dw/(ULONG)m);
00220    *ul = out.uli;
00221 }
00222
00223
00224 static void setStandard(LPRSI lprsi)
00225 {
00226    int i;
00227    lprsi->cSections = 1;
00228    SetSumInfFMTID(&lprsi->rgPropSet[0].formatID);
00229    _fmemcpy(&lprsi->classId, &lprsi->rgPropSet[0].formatID, sizeof(FMTID));
00230    lprsi->rgPropSet[0].byteOffset = cbNewSummaryInfo(1);
00231    for (i=0; i<cPIDSI_STANDARD; i++)
00232       lprsi->section.rgPropId[i].propertyID = PIDSI_TITLE+i;
00233    lprsi->section.cProperties = cPIDSI_STANDARD; //always; do null test to check validity
00234 }
00235
00236 extern "C" {
00237
00238 /*************************************************************************
00239 **
00240 ** OleStdInitSummaryInfo
00241 **
00242 ** Purpose:
00243 **    Initialize a Summary Info structure.
00244 **
00245 ** Parameters:
00246 **    int reserved             - reserverd for future use. must be 0.
00247 **
00248 ** Return Value:
00249 **    LPSUMINFO
00250 **
00251 ** Comments:
00252 **    CoInitialize MUST be called PRIOR to calling OleStdInitSummaryInfo.
00253 **    Memory is allocated using the currently active IMalloc*
00254 **    allocator (as is returned by call CoGetMalloc(MEMCTX_TASK) ).
00255 **    Each LPSUMINFO instance must be initialized prior to use by
00256 **    calling OleStdInitSummaryInfo. Once a LPSUMINFO instance is allocated
00257 **    (by OleStdInitSummaryInfo), the user can call the Set procedures to
00258 **    initialize fields.
00259 *************************************************************************/
00260
00261 STDAPI_(LPSUMINFO) OleStdInitSummaryInfo(int reserved)
00262 {
00263    LPRSI lprsi;
00264
00265    if ((lprsi = (LPRSI)MemAlloc(sizeof(RSUMINFO))) != NULL)
00266    {
00267       ClearSumInf(lprsi, sizeof(RSUMINFO));
00268    } else return NULL;
00269
00270    setStandard(lprsi);
00271    return (LPSUMINFO)lprsi;
00272 }
00273
00274
00275 /*************************************************************************
00276 **
00277 ** OleStdFreeSummaryInfo
00278 **
00279 ** Purpose:
00280 **    Free a Summary Info structure.
00281 **
00282 ** Parameters:
00283 **    LPSUMINFO FAR *lp           - pointer to open Summary Info struct
00284 **
00285 ** Return Value:
00286 **    void
00287 **
00288 ** Comments:
00289 **    Memory is freed using the currently active IMalloc*
00290 **    allocator (as is returned by call CoGetMalloc(MEMCTX_TASK) ).
00291 **    Every LPSUMINFO struct must be freed after its last use.
00292 **    When the OleStdFreeSummaryInfo routine is called, all storage will be
00293 **    deallocated including that of the thumbnail (unless ownership of
00294 **    the thumbnail has been transfered to the caller -- see
00295 **    description of transferClip in GetThumbnail API).
00296 **
00297 *************************************************************************/
00298
00299 STDAPI_(void) OleStdFreeSummaryInfo(LPSUMINFO FAR *lplp)
00300 {
00301    if (lplp==NULL||*lplp==NULL) return;
00302    OleStdClearSummaryInfo(*lplp);
00303    MemFree(*lplp);
00304    *lplp = NULL;
00305 }
00306
00307
00308 /*************************************************************************
00309 **
00310 ** OleStdClearSummaryInfo
00311 **
00312 ** Purpose:
00313 **    Free storage (memory) for all the properties of the LPSUMINFO.
00314 **
00315 ** Parameters:
00316 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00317 **
00318 ** Return Value:
00319 **    void
00320 **
00321 ** Comments:
00322 **    After calling OleStdClearSummaryInfo you must call OleStdReadSummaryInfo to
00323 **    load them again.
00324 **
00325 *************************************************************************/
00326
00327 STDAPI_(void) OleStdClearSummaryInfo(LPSUMINFO lp)
00328 {
00329    OleStdSetStringProperty(lp, PIDSI_TITLE, NULL);
00330    OleStdSetStringProperty(lp, PIDSI_SUBJECT, NULL);
00331    OleStdSetStringProperty(lp, PIDSI_AUTHOR, NULL);
00332    OleStdSetStringProperty(lp, PIDSI_KEYWORDS, NULL);
00333    OleStdSetStringProperty(lp, PIDSI_COMMENTS, NULL);
00334    OleStdSetStringProperty(lp, PIDSI_TEMPLATE, NULL);
00335    OleStdSetStringProperty(lp, PIDSI_REVNUMBER, NULL);
00336    OleStdSetStringProperty(lp, PIDSI_APPNAME, NULL);
00337    OleStdSetThumbNailProperty(NULL, lp, VT_CF_EMPTY, 0, NULL, NULL, 0);
00338    ClearSumInf((LPRSI)lp, sizeof(RSUMINFO));
00339 }
00340
00341
00342 /*************************************************************************
00343 **
00344 ** OleStdReadSummaryInfo
00345 **
00346 ** Purpose:
00347 **    Read all Summary Info properties into memory (except thumbnail
00348 **    which is demand loaded).
00349 **
00350 ** Parameters:
00351 **    LPSTREAM lps                  - open SummaryInfo IStream*
00352 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00353 **
00354 ** Return Value:
00355 **    int                           - 1 for success
00356 **                                  - 0 if error occurs
00357 ** Comments:
00358 **
00359 *************************************************************************/
00360 /*
00361 STDAPI_(int) OleStdReadSummaryInfo(LPSTREAM lpStream, LPSUMINFO lp)
00362 {
00363    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00364    LPRSI lpSumInfo = (LPRSI)lp;
00365    SCODE sc;
00366    ULONG cbRead,i,sectionOffset;
00367    LARGE_INTEGER a;
00368    ULARGE_INTEGER b;
00369    int j,k,l;
00370    union {
00371       RSUMINFO rsi;
00372       STDZ stdz;
00373    };
00374    OleStdClearSummaryInfo(lp);
00375    LISet32(a, 0);
00376    sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00377    if (FAILED(sc)) goto fail;
00378    sectionOffset = cbNewSummaryInfo(1);
00379    sc = GetScode(lpStream->Read(&rsi, sectionOffset, &cbRead));
00380    if (FAILED(sc)||cbRead<sectionOffset) goto fail;
00381    if (!FIntelOrder(&rsi)||rsi.formatVersion!=0) goto fail;
00382    j = (int)rsi.cSections;
00383    while (j-->0) {
00384       if (FEqSumInfFMTID(&rsi.rgPropSet[0].formatID)) {
00385          sectionOffset = rsi.rgPropSet[0].byteOffset;
00386          break;
00387       } else {
00388          sc = GetScode(lpStream->Read(&rsi.rgPropSet[0].formatID, sizeof(PROPSETLIST), &cbRead));
00389          if (FAILED(sc)||cbRead!=sizeof(PROPSETLIST)) goto fail;
00390       }
00391       if (j<=0) goto fail;
00392    }
00393
00394    LISet32(a, sectionOffset);
00395    sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00396    if (FAILED(sc)) goto fail;
00397    sc = GetScode(lpStream->Read(&rsi.section, cbNewSection(1), &cbRead));
00398    if (FAILED(sc)||cbRead!=cbNewSection(1)) goto fail;
00399    i = rsi.section.cBytes+sectionOffset;
00400    j = (int)rsi.section.cProperties;
00401    if (j>cPIDSI_STANDARD) goto fail;
00402    k = 0;
00403    while (j-->0) {
00404       k++;
00405       switch (l=(int)rsi.section.rgPropId[0].propertyID) {
00406          case PIDSI_PAGECOUNT:
00407          case PIDSI_WORDCOUNT:
00408          case PIDSI_CHARCOUNT:
00409          case PIDSI_DOC_SECURITY:
00410             if (l==PIDSI_DOC_SECURITY) l=3; else l-=PIDSI_PAGECOUNT;
00411             cbRead = sectionOffset+rsi.section.rgPropId[0].byteOffset;
00412             if (cbRead>=i) goto fail;
00413             LISet32(a, cbRead);
00414             sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00415             if (FAILED(sc)) goto fail;
00416             sc = GetScode(lpStream->Read(&lpSSIM->rgInts[l], sizeof(INTS), &cbRead));
00417             if (FAILED(sc)||cbRead!=sizeof(INTS)) goto fail;
00418             if (lpSSIM->rgInts[l].vtType==VT_EMPTY) break;
00419             if (lpSSIM->rgInts[l].vtType!=VT_I4) goto fail;
00420             break;
00421          case PIDSI_EDITTIME:
00422          case PIDSI_LASTPRINTED:
00423          case PIDSI_CREATE_DTM:
00424          case PIDSI_LASTSAVE_DTM:
00425             l-=PIDSI_EDITTIME;
00426             cbRead = sectionOffset+rsi.section.rgPropId[0].byteOffset;
00427             if (cbRead>=i) goto fail;
00428             LISet32(a, cbRead);
00429             sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00430             if (FAILED(sc)) goto fail;
00431             sc = GetScode(lpStream->Read(&lpSSIM->rgTime[l], sizeof(TIME), &cbRead));
00432             if (FAILED(sc)||cbRead!=sizeof(TIME)) goto fail;
00433             if (lpSSIM->rgTime[l].vtType==VT_EMPTY) break;
00434             if (lpSSIM->rgTime[l].vtType!=VT_FILETIME) goto fail;
00435             break;
00436          case PIDSI_TITLE:
00437          case PIDSI_SUBJECT:
00438          case PIDSI_AUTHOR:
00439          case PIDSI_KEYWORDS:
00440          case PIDSI_COMMENTS:
00441          case PIDSI_TEMPLATE:
00442          case PIDSI_LASTAUTHOR:
00443          case PIDSI_REVNUMBER:
00444          case PIDSI_APPNAME:
00445             cbRead = sectionOffset+rsi.section.rgPropId[0].byteOffset;
00446             if (cbRead>=i) goto fail;
00447             LISet32(a, cbRead);
00448             sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00449             if (FAILED(sc)) goto fail;
00450             sc = GetScode(lpStream->Read(&stdz, sizeof(STDZ), &cbRead));
00451             if (FAILED(sc)||cbRead<sizeof(DWORD)*2) goto fail;
00452             if (stdz.vtType==VT_EMPTY||stdz.vtByteCount<=1) break;
00453             if (stdz.vtType!=VT_LPSTR||stdz.vtByteCount>WORDMAX) goto fail;
00454             stdz.rgchars[(int)stdz.vtByteCount-1] = '\0';
00455             OleStdSetStringProperty(lp, (DWORD)l, (LPSTR)&stdz.rgchars[0]);
00456             break;
00457          case PIDSI_THUMBNAIL:
00458             cbRead = sectionOffset+rsi.section.rgPropId[0].byteOffset;
00459             if (cbRead>=i) goto fail;
00460             LISet32(a, cbRead);
00461             sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00462             if (FAILED(sc)) goto fail;
00463             lpSumInfo->fileOffset = cbRead+sizeof(DWORD)*3;
00464             sc = GetScode(lpStream->Read(&lpSSIM->thumb, sizeof(DWORD)*4, &cbRead));
00465             if (FAILED(sc)||cbRead!=sizeof(DWORD)*4) {
00466                lpSSIM->thumb.vtType = VT_EMPTY;
00467                goto fail;
00468             }
00469             if (lpSSIM->thumb.vtType == VT_EMPTY) {
00470                lpSSIM->thumb.cBytes = 0;
00471                break;
00472             }
00473             if (lpSSIM->thumb.vtType != VT_CF) {
00474                lpSSIM->thumb.vtType = VT_EMPTY;
00475                goto fail;
00476             }
00477             lpSSIM->thumb.cBytes -= sizeof(DWORD); //for selector
00478             if (lpSSIM->thumb.selector==VT_CF_WIN||lpSSIM->thumb.selector==VT_CF_MAC) {
00479                lpSumInfo->fileOffset += sizeof(DWORD);
00480                lpSSIM->thumb.cBytes -= sizeof(DWORD); //for format val
00481             }
00482             break;
00483             default: ;
00484       }
00485       if (j<=0)
00486       {
00487       // We should fail if the document is password-protected.
00488          if(OleStdGetSecurityProperty(lp)==fSecurityPassworded)
00489             goto fail;
00490          return 1;
00491       }
00492       LISet32(a, sectionOffset+sizeof(DWORD)*2+k*sizeof(PROPIDLIST));
00493       sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00494       if (FAILED(sc)) goto fail;
00495       sc = GetScode(lpStream->Read(&rsi.section.rgPropId[0], sizeof(PROPIDLIST), &cbRead));
00496       if (FAILED(sc)||cbRead!=sizeof(PROPIDLIST)) goto fail;
00497    }
00498
00499 fail:
00500    OleStdClearSummaryInfo(lpSumInfo);
00501    return 0;
00502 }
00503 */
00504
00505 /*************************************************************************
00506 **
00507 ** OleStdWriteSummaryInfo
00508 **
00509 ** Purpose:
00510 **    Write all Summary Info properties to a IStream*
00511 **
00512 ** Parameters:
00513 **    LPSTREAM lps                  - open SummaryInfo IStream*
00514 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00515 **
00516 ** Return Value:
00517 **    int                           - 1 for success
00518 **                                  - 0 if error occurs
00519 ** Comments:
00520 **
00521 *************************************************************************/
00522
00523 STDAPI_(int) OleStdWriteSummaryInfo(LPSTREAM lpStream, LPSUMINFO lp)
00524 {
00525    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00526    // REVIEW: localization issues for propert sets
00527    //         do we need to include a code page and dictionary?
00528
00529    LPRSI lpSumInfo = (LPRSI)lp;
00530    SCODE sc;
00531    ULONG cbWritten;
00532    ULONG cBytes, oBytes, k,l,m,n;
00533    LARGE_INTEGER a;
00534    ULARGE_INTEGER b;
00535    LPOLESTR lps;
00536    LPMETAFILEPICT lpmfp;
00537    int i,j,s;
00538
00539    setStandard(lpSumInfo);
00540    oBytes = cbNewSection(cPIDSI_STANDARD);  //offsets are relative to the section
00541    cBytes = cbNewSection(cPIDSI_STANDARD)+(sizeof(TIME)*MAXTIME)+(sizeof(INTS)*MAXINTS);
00542
00543    lpSSIM->rgPropId[PIDSI_EDITTIME-2].byteOffset = oBytes;
00544    lpSSIM->rgPropId[PIDSI_LASTPRINTED-2].byteOffset = oBytes+sizeof(TIME);
00545    lpSSIM->rgPropId[PIDSI_CREATE_DTM-2].byteOffset = oBytes+sizeof(TIME)*2;
00546    lpSSIM->rgPropId[PIDSI_LASTSAVE_DTM-2].byteOffset = oBytes+sizeof(TIME)*3;
00547
00548    lpSSIM->rgPropId[PIDSI_PAGECOUNT-2].byteOffset = oBytes+(sizeof(TIME)*MAXTIME);
00549    lpSSIM->rgPropId[PIDSI_WORDCOUNT-2].byteOffset = oBytes+(sizeof(TIME)*MAXTIME+sizeof(INTS));
00550    lpSSIM->rgPropId[PIDSI_CHARCOUNT-2].byteOffset = oBytes+(sizeof(TIME)*MAXTIME+sizeof(INTS)*2);
00551    lpSSIM->rgPropId[PIDSI_DOC_SECURITY-2].byteOffset = oBytes+(sizeof(TIME)*MAXTIME+sizeof(INTS)*3);
00552    oBytes += sizeof(TIME)*MAXTIME + sizeof(INTS)*MAXINTS;
00553
00554    lpSSIM->rgPropId[PIDSI_THUMBNAIL-2].byteOffset = oBytes;
00555    l = 0;
00556    if (lpSSIM->thumb.vtType==VT_EMPTY) k = sizeof(DWORD);
00557    else {
00558       l = ((lpSSIM->thumb.cBytes+4-1)>>2)<<2;
00559       if (lpSSIM->thumb.selector==VT_CF_BYTES) k = sizeof(DWORD)*3;
00560       else if (lpSSIM->thumb.selector==VT_CF_FMTID) {k = sizeof(DWORD)*3; l += sizeof(FMTID); }
00561       else if (lpSSIM->thumb.selector==VT_CF_NAME)  {k = sizeof(DWORD)*3; l += (((*lpSSIM->thumb.lpstzName+1+3)>>2)<<2);}
00562       else k = sizeof(DWORD)*4;
00563    }
00564    cBytes += k+l;
00565    oBytes += k+l;
00566
00567    for (i=0; i<MAXSTDZ; i++) {
00568       j = 0;
00569       if (lpSSIM->rglpsz[i]!=NULL) {
00570          j = lpSSIM->rglpsz[i]->VTCB+1/*null*/;
00571          lpSSIM->rglpsz[i]->vtByteCount = j;
00572          j = (((j+4-1)>>2)<<2)+sizeof(DWORD);
00573          cBytes += j;
00574       }
00575       if (i!=MAXSTDZ-1) lpSSIM->rgPropId[i].byteOffset = oBytes;
00576       else lpSSIM->rgPropId[PIDSI_APPNAME-2].byteOffset = oBytes;
00577       oBytes += j+sizeof(DWORD);
00578       cBytes += sizeof(DWORD); //type
00579    }
00580    lpSSIM->cBytes = cBytes;
00581
00582
00583    LISet32(a, 0);
00584    sc = GetScode(lpStream->Seek(a, STREAM_SEEK_SET, &b));
00585    if (FAILED(sc)) return 0;
00586    sc = GetScode(lpStream->Write(lpSumInfo, cbNewSummaryInfo(1), &cbWritten));
00587    if (FAILED(sc)||cbWritten!=cbNewSummaryInfo(1)) return 0;
00588    sc = GetScode(lpStream->Write(lpSSIM, cbNewSection(cPIDSI_STANDARD)+sizeof(TIME)*MAXTIME+sizeof(INTS)*MAXINTS, &cbWritten));
00589    if (FAILED(sc)||cbWritten!=cbNewSection(cPIDSI_STANDARD)+sizeof(TIME)*MAXTIME+sizeof(INTS)*MAXINTS) return 0;
00590
00591    m = lpSSIM->thumb.cBytes;
00592    if (lpSSIM->thumb.lpstzName!=NULL) s = *lpSSIM->thumb.lpstzName;
00593    else s = 0;
00594    if (m!=0) {
00595       lpSSIM->thumb.cBytes = (k-sizeof(DWORD)*2)+
00596          (((lpSSIM->thumb.cBytes+4-1)>>2)<<2)+(((s+4-1)>>2)<<2);
00597       n = lpSSIM->thumb.selector;
00598       lps = lpSSIM->thumb.lpByte;
00599       ASSERT(lps!=NULL);  //maybe a GetThumbNail here
00600       ASSERT(n!=VT_CF_NAME);
00601       if (n==VT_CF_WIN) { //bytes are in global memory
00602          lpmfp = (LPMETAFILEPICT)GlobalLock((HANDLE)(DWORD)lps);
00603          if (lpmfp==NULL) goto fail;
00604          lps = (LPOLESTR)GlobalLock(lpmfp->hMF);
00605       }
00606       if (n==VT_CF_NAME) lpSSIM->thumb.selector = *lpSSIM->thumb.lpstzName+1/*null*/;
00607    }
00608    sc = GetScode(lpStream->Write(&lpSSIM->thumb, k, &cbWritten));
00609    if (FAILED(sc)||cbWritten!=k) goto fail;
00610    if (s!=0) {
00611       k = ((s+1+4-1)>>2)<<2;
00612       sc = GetScode(lpStream->Write(lpSSIM->thumb.lpstzName+1, k, &cbWritten));
00613       if (FAILED(sc)||cbWritten!=k) goto fail;
00614    }
00615    if (m!=0) {
00616       k = ((m+3)>>2)<<2;
00617       if (n==VT_CF_WIN||VT_CF_NAME) { //bytes are in global memory
00618          sc = GetScode(lpStream->Write(lpmfp, sizeof(METAFILEPICT), &cbWritten));
00619          k -= sizeof(METAFILEPICT);
00620       }
00621       sc = GetScode(lpStream->Write(lps, k, &cbWritten));
00622       if (FAILED(sc)||cbWritten!=k) goto fail;
00623       if (n==VT_CF_WIN||VT_CF_NAME) { //bytes are in global memory
00624          GlobalUnlock(lpmfp->hMF);
00625          GlobalUnlock((HANDLE)(DWORD)lpSSIM->thumb.lpByte);
00626       }
00627    }
00628    lpSSIM->thumb.cBytes = m;   //restore in mem value
00629    lpSSIM->thumb.selector = n;
00630
00631    k = VT_EMPTY;
00632    for (i=0; i<MAXSTDZ; i++) {
00633       if (lpSSIM->rglpsz[i]!=NULL) {
00634          l = lpSSIM->rglpsz[i]->vtByteCount;
00635          j = ((((int)l+4-1)/4)*4)+sizeof(DWORD)*2;
00636          sc = GetScode(lpStream->Write(lpSSIM->rglpsz[i], j, &cbWritten));
00637          if (FAILED(sc)||cbWritten!=(ULONG)j) return 0;
00638          lpSSIM->rglpsz[i]->vtByteCount = 0; //restore stz count convention
00639          lpSSIM->rglpsz[i]->VTCB = (int)l;
00640       } else {
00641          sc = GetScode(lpStream->Write(&k, sizeof(DWORD), &cbWritten));
00642          if (FAILED(sc)||cbWritten!=sizeof(DWORD)) return 0;
00643       }
00644    }
00645    return 1;
00646 fail:
00647    lpSSIM->thumb.cBytes = m;   //restore in mem value
00648    lpSSIM->thumb.selector = n;
00649    if (m!=0&&(n==VT_CF_WIN||VT_CF_NAME)) { //bytes are in global memory
00650       GlobalUnlock((HANDLE)(DWORD)lps);
00651    }
00652    return 0;
00653 }
00654
00655
00656 /*************************************************************************
00657 **
00658 ** OleStdGetSecurityProperty
00659 **
00660 ** Purpose:
00661 **    Retrieve the Security Property
00662 **
00663 ** Parameters:
00664 **    LPSUMINFO FAR *lp           - pointer to open Summary Info struct
00665 **
00666 ** Return Value:
00667 **    DWORD                       - security level
00668 **          AllSecurityFlagsEqNone 0    - no security
00669 **          fSecurityPassworded 1       - password required
00670 **          fSecurityRORecommended 2    - read-only is recommended
00671 **          fSecurityRO 4               - read-only is required
00672 **          fSecurityLockedForAnnotations 8 - locked for annotations
00673 **
00674 ** Comments:
00675 **    by noting the (suggested; that is, application-enforced) security
00676 **    level on the document, an application other than the originator
00677 **    of the document can adjust its user interface to the properties
00678 **    appropriately. An application should not display any of the
00679 **    information about a password protected document, and should not
00680 **    allow modifications to enforced read-only or locked for
00681 **    annotations documents. It should warn the user about read-only
00682 **    recommended if the user attempts to modify properties.
00683 **
00684 *************************************************************************/
00685
00686 STDAPI_(DWORD) OleStdGetSecurityProperty(LPSUMINFO lp)
00687 {
00688 STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00689    if (lpSSIM->rgInts[3].vtType == VT_I4) return lpSSIM->rgInts[3].value;
00690    return 0;
00691 }
00692
00693
00694 /*************************************************************************
00695 **
00696 ** OleStdSetSecurityProperty
00697 **
00698 ** Purpose:
00699 **    Set the Security Property
00700 **
00701 ** Parameters:
00702 **    LPSUMINFO FAR *lp           - pointer to open Summary Info struct
00703 **    DWORD security              - security level
00704 **          AllSecurityFlagsEqNone 0    - no security
00705 **          fSecurityPassworded 1       - password required
00706 **          fSecurityRORecommended 2    - read-only is recommended
00707 **          fSecurityRO 4               - read-only is required
00708 **          fSecurityLockedForAnnotations 8 - locked for annotations
00709 **
00710 ** Return Value:
00711 **    int                           - 1 for success
00712 **                                  - 0 if error occurs
00713 **                                    (there are no errors)
00714 **
00715 ** Comments:
00716 **    by noting the (suggested; that is, application-enforced) security
00717 **    level on the document, an application other than the originator
00718 **    of the document can adjust its user interface to the properties
00719 **    appropriately. An application should not display any of the
00720 **    information about a password protected document, and should not
00721 **    allow modifications to enforced read-only or locked for
00722 **    annotations documents. It should warn the user about read-only
00723 **    recommended if the user attempts to modify properties.
00724 **
00725 *************************************************************************/
00726
00727 STDAPI_(int) OleStdSetSecurityProperty(LPSUMINFO lp, DWORD security)
00728 {
00729    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00730
00731    // REVIEW: check valid transitions; how do we know APP called us?
00732
00733    if (security==0) {
00734       lpSSIM->rgInts[3].vtType = VT_EMPTY;
00735       return 1;
00736    }
00737    lpSSIM->rgInts[3].vtType = VT_I4;
00738    lpSSIM->rgInts[3].value = security;
00739    return 1;
00740 }
00741
00742
00743 /*************************************************************************
00744 **
00745 ** OleStdGetStringProperty
00746 **
00747 ** Purpose:
00748 **    Retrieve a String Propety.
00749 **    (returns zero terminated string -- C string)
00750 **
00751 ** Parameters:
00752 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00753 **    DWORD pid                     - ID of String Property
00754 **
00755 ** Return Value:
00756 **    LPSTR                         - value of String Property
00757 **                                      (zero terminated string--C string)
00758 **
00759 ** Comments:
00760 **    String should NOT be freed by caller. Memory for string will be
00761 **    freed when OleStdFreeSummaryInfo is called.
00762 *************************************************************************/
00763
00764 STDAPI_(LPSTR) OleStdGetStringProperty(LPSUMINFO lp, DWORD pid)
00765 {
00766    LPSTR l = OleStdGetStringZProperty(lp,pid);
00767    if (l==NULL) return NULL; else return l+1;
00768 }
00769
00770
00771 /*************************************************************************
00772 **
00773 ** OleStdSetStringProperty
00774 **
00775 ** Purpose:
00776 **    Set a String Propety
00777 **    (takes zero terminated string -- C string)
00778 **
00779 ** Parameters:
00780 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00781 **    DWORD pid                     - ID of String Property
00782 **    LPSTR lpsz                    - new value for String Property.
00783 **                                      zero terminated string -- C string.
00784 **                                      May be NULL, in which case the
00785 **                                      propery is cleared.
00786 **
00787 ** Return Value:
00788 **    int                           - 1 if successful
00789 **                                  - 0 invalid property id
00790 **
00791 ** Comments:
00792 **    The input string is copied.
00793 **
00794 *************************************************************************/
00795
00796 STDAPI_(int) OleStdSetStringProperty(LPSUMINFO lp, DWORD pid, LPOLESTR lpsz)
00797 {
00798    LPRSI lprsi=(LPRSI)lp;
00799    STANDARDSECINMEM FAR* lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00800    int i;
00801    if (pid==PIDSI_APPNAME) {
00802       pid = MAXSTDZ-1;
00803    } else if (pid<PIDSI_TITLE || pid>PIDSI_REVNUMBER) return 0; else pid -= 2;
00804    ASSERT(lpSSIM);
00805    if (lpSSIM->rglpsz[pid]) MemFree(lpSSIM->rglpsz[pid]);
00806    if ((lpsz==NULL)||(*lpsz==0)) {
00807       lpSSIM->rglpsz[pid] = NULL;
00808       return (1);
00809    }
00810    i = OLESTRLEN(lpsz);
00811    lpSSIM->rglpsz[pid] = (STDZ FAR*)MemAlloc(i+1/*null*/+sizeof(DWORD)*2);
00812    if (lpSSIM->rglpsz[pid]==NULL) return 0;
00813    W2A(lpsz, (LPSTR)&lpSSIM->rglpsz[pid]->rgchars, sizeof(&lpSSIM->rglpsz[pid]->rgchars));
00814    lpSSIM->rglpsz[pid]->vtType = VT_LPSTR;
00815    lpSSIM->rglpsz[pid]->vtByteCount = 0;
00816    lpSSIM->rglpsz[pid]->VTCB = i;
00817    return (1);
00818 }
00819
00820
00821 /*************************************************************************
00822 **
00823 ** OleStdGetStringZProperty
00824 **
00825 ** Purpose:
00826 **    Retrieve a String Propety.
00827 **    (returns zero-terminated with leading byte count string)
00828 **
00829 ** Parameters:
00830 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00831 **    DWORD pid                     - ID of Property
00832 **
00833 ** Return Value:
00834 **    LPSTZR                        - value of String Property
00835 **                                      (zero-terminated with leading
00836 **                                      byte count)
00837 **
00838 ** Comments:
00839 **    String should NOT be freed by caller. Memory for string will be
00840 **    freed when OleStdFreeSummaryInfo is called.
00841 *************************************************************************/
00842
00843 STDAPI_(LPSTZR) OleStdGetStringZProperty(LPSUMINFO lp, DWORD pid)
00844 {
00845    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00846    if (pid==PIDSI_APPNAME) {
00847       pid = MAXSTDZ-1;
00848    } else if (pid<PIDSI_TITLE || pid>PIDSI_REVNUMBER) return NULL; else pid -= 2;
00849    if (lpSSIM->rglpsz[pid]!=NULL) {
00850       return (LPSTR)&lpSSIM->rglpsz[pid]->VTCB;
00851    }
00852    return NULL;
00853 }
00854
00855
00856 /*************************************************************************
00857 **
00858 ** OleStdGetDocProperty
00859 **
00860 ** Purpose:
00861 **    Retrieve document properties (no. pages, no. words, no. characters)
00862 **
00863 ** Parameters:
00864 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00865 **    DWORD FAR *nPage              - (OUT) number of pages in document
00866 **    DWORD FAR *nWords             - (OUT) number of words in document
00867 **    DWORD FAR *nChars             - (OUT) number of charactrs in doc
00868 **
00869 ** Return Value:
00870 **    void
00871 **
00872 ** Comments:
00873 **
00874 *************************************************************************/
00875
00876 STDAPI_(void) OleStdGetDocProperty(
00877       LPSUMINFO       lp,
00878       DWORD FAR*      nPage,
00879       DWORD FAR*      nWords,
00880       DWORD FAR*      nChars
00881 )
00882 {
00883 STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00884    *nPage=0; *nWords=0; *nChars=0;
00885    if (lpSSIM->rgInts[0].vtType == VT_I4) *nPage = lpSSIM->rgInts[0].value;
00886    if (lpSSIM->rgInts[1].vtType == VT_I4) *nWords = lpSSIM->rgInts[1].value;
00887    if (lpSSIM->rgInts[2].vtType == VT_I4) *nChars = lpSSIM->rgInts[2].value;
00888 }
00889
00890
00891 /*************************************************************************
00892 **
00893 ** OleStdSetDocProperty
00894 **
00895 ** Purpose:
00896 **    Set document properties (no. pages, no. words, no. characters)
00897 **
00898 ** Parameters:
00899 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00900 **    DWORD nPage                   - number of pages in document
00901 **    DWORD nWords                  - number of words in document
00902 **    DWORD nChars                  - number of charactrs in doc
00903 **
00904 ** Return Value:
00905 **    int                           - 1 for success
00906 **                                  - 0 if error occurs
00907 **                                    (there are no errors)
00908 **
00909 ** Comments:
00910 **
00911 *************************************************************************/
00912
00913 STDAPI_(int) OleStdSetDocProperty(
00914       LPSUMINFO       lp,
00915       DWORD           nPage,
00916       DWORD           nWords,
00917       DWORD           nChars
00918 )
00919 {
00920 DWORD vttype=VT_I4;
00921 STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
00922    if ((nPage|nWords|nChars)==0) {
00923       vttype = VT_EMPTY;
00924       nPage=0; nWords=0; nChars=0;
00925    }
00926    lpSSIM->rgInts[0].vtType = vttype;
00927    lpSSIM->rgInts[1].vtType = vttype;
00928    lpSSIM->rgInts[2].vtType = vttype;
00929    lpSSIM->rgInts[0].value = nPage;
00930    lpSSIM->rgInts[1].value = nWords;
00931    lpSSIM->rgInts[2].value = nChars;
00932    return 1;
00933 }
00934
00935
00936 /*************************************************************************
00937 **
00938 ** OleStdGetThumbNailProperty
00939 **
00940 ** Purpose:
00941 **    Retrieve a Thumbnail Property
00942 **
00943 ** Parameters:
00944 **    LPSTREAM lps
00945 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
00946 **    DWORD FAR* clipFormatNo       - clipboard format for thumbnail
00947 **                                      (type of value depends on vtcf
00948 **                                      return value.)
00949 **                                      NOTE: ONLY VT_CF_WIN is
00950 **                                      implemented, so clipFormatNo
00951 **                                      will be CF_METAFILEPICT
00952 **    LPSTR FAR* lpszName           - format name if VT_CF_NAME is
00953 **                                      returned
00954 **                                      NOTE: NOT IMPLEMENTED
00955 **    THUMBNAIL FAR* clip           - handle to thumbnail
00956 **                                      for VT_CF_WIN clip will be
00957 **                                      handle to MetafilePict
00958 **                                      NOTE: only VT_CF_WIN IMPLEMENTED
00959 **    DWORD FAR* byteCount          - size of thumbnail stream
00960 **                                      for VT_CF_WIN case this should
00961 **                                      be combined size of both the
00962 **                                      Metafile as well as the
00963 **                                      MetafilePict structure.
00964 **    BOOL transferClip             - transfer ownership of thumbnail
00965 **                                      to caller. (see comment)
00966 **
00967 ** Return Value:
00968 **    int vtcfNo                    - OLE thumbnail selector value
00969 **      VT_CF_WIN                   - Windows thumbnail
00970 **                                      (interpret clipFormatNo as
00971 **                                      Windows clipboard format)
00972 **      VT_CF_FMTID                 - (NOT IMPLEMENTED)
00973 **                                      thumbnail format is specified
00974 **                                      by ID. use clipFormatNo.
00975 **                                      (but NOT a Windows format ID)
00976 **
00977 **      VT_CF_NAME                  - (NOT IMPLEMENTED)
00978 **                                      thumbnail format is specified
00979 **                                      by name. use lpszName.
00980 **      VT_CF_EMPTY                 - blank thumbnail
00981 **                                      (clip will be NULL)
00982 **      VT_CF_OOM                   - Memory allocation failure
00983 **
00984 ** Comments:
00985 **    NOTE: Currently there is only proper support for VT_CF_WIN.
00986 **    OleStdSetThumbNailProperty does implement VT_CF_FMTID and VT_CF_NAME,
00987 **    however, OleStdGetThumbNailProperty, OleStdReadSummaryInfo and
00988 **    OleStdWriteSummaryInfo only support VT_CF_WIN.
00989 **
00990 **    Note that on input, the thumbnail is read on demand while all the
00991 **    other properties are pre-loaded.  The thumbnail is manipulated as
00992 **    a windows handle to a METAFILEPICT structure, which in turn
00993 **    contains a handle to the METAFILE.  The transferClip argument on
00994 **    GetThumbNail, when set to true, transfers responsibility for
00995 **    storage management of the thumbnail to the caller; that is, after
00996 **    OleStdFreeSummaryInfo has been called, the handle is still valid.
00997 *************************************************************************/
00998
00999 STDAPI_(int) OleStdGetThumbNailProperty(
01000       LPSTREAM        lps,
01001       LPSUMINFO       lp,
01002       DWORD FAR*      clipFormatNo,
01003       LPOLESTR FAR*   lpszName,
01004       THUMBNAIL FAR*  clip,
01005       DWORD FAR*      byteCount,
01006       BOOL            transferClip
01007 )
01008 {
01009    int i;
01010    LPRSI lprsi=(LPRSI)lp;
01011    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
01012    ULONG cbRead, cbToRead;
01013    LARGE_INTEGER a;
01014    ULARGE_INTEGER b;
01015    LPOLESTR lpst;
01016    LPMETAFILEPICT lpmfp;
01017    HANDLE hst, hmfp;
01018    SCODE sc;
01019    *byteCount = 0;
01020    if (lpSSIM->thumb.cBytes==0) return VT_CF_EMPTY;
01021    if (lpSSIM->thumb.lpByte==NULL) {
01022       LISet32(a, lprsi->fileOffset);
01023       sc = GetScode(lps->Seek(a, STREAM_SEEK_SET, &b));
01024       if (FAILED(sc)) return VT_CF_EMPTY;
01025       i = (int) lpSSIM->thumb.selector;
01026       if (i>0||i==VT_CF_FMTID) {
01027          if (i>255) return VT_CF_EMPTY;
01028          else if (i==VT_CF_FMTID) i = sizeof(FMTID);
01029          else lpSSIM->thumb.selector = (DWORD) VT_CF_NAME;
01030          cbToRead = ((i+3)>>2)<<2;
01031          lpSSIM->thumb.lpstzName=(LPOLESTR)MemAlloc(i+1/*n*/+1);
01032          if (lpSSIM->thumb.lpstzName==NULL) return VT_CF_OOM;
01033          sc = GetScode(lps->Read(lpSSIM->thumb.lpstzName+1, cbToRead, &cbRead));
01034          if (FAILED(sc)||cbRead!=cbToRead) return VT_CF_EMPTY;
01035          *lpSSIM->thumb.lpstzName = i;
01036          *(lpSSIM->thumb.lpstzName+i) = 0;
01037          lpSSIM->thumb.cBytes -= cbToRead+sizeof(DWORD);
01038       }
01039       i = (int) lpSSIM->thumb.selector;
01040       cbToRead = lpSSIM->thumb.cBytes;
01041       if (cbToRead>65535) return VT_CF_OOM;
01042       ASSERT(i!=VT_CF_NAME);
01043       if (i==VT_CF_WIN) {
01044          cbToRead -= sizeof(METAFILEPICT);
01045          hmfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
01046          if (hmfp==NULL) return VT_CF_OOM;
01047          hst = GlobalAlloc(GMEM_MOVEABLE, cbToRead);
01048          if (hst==NULL) {
01049             GlobalFree(hmfp);
01050             return VT_CF_OOM;
01051          }
01052          lpmfp = (LPMETAFILEPICT)GlobalLock(hmfp);
01053          sc = GetScode(lps->Read(lpmfp, sizeof(METAFILEPICT), &cbRead));
01054          if (FAILED(sc)||cbRead!=sizeof(METAFILEPICT)) {
01055             GlobalUnlock(hmfp);
01056             GlobalFree(hmfp);
01057             GlobalFree(hst);
01058             return VT_CF_EMPTY;
01059          }
01060          lpst = (LPOLESTR)GlobalLock(hst);
01061          lpmfp->hMF = (HMETAFILE)hst;
01062          lpSSIM->thumb.lpByte = (LPOLESTR)hmfp;
01063       } else {
01064          lpst = (LPOLESTR)MemAlloc((int)cbToRead);
01065          if (lpst==NULL) return VT_CF_OOM;
01066          lpSSIM->thumb.lpByte = lpst;
01067       }
01068       sc = GetScode(lps->Read(lpst, cbToRead, &cbRead));
01069       if (i==VT_CF_WIN) {
01070          GlobalUnlock(hst);
01071          GlobalUnlock(hmfp);
01072       }
01073       if (FAILED(sc)||cbRead!=cbToRead) {
01074          if (i==VT_CF_WIN) {
01075             GlobalFree(hst);
01076             GlobalFree(hmfp);
01077          } else MemFree(lpst);
01078          lpSSIM->thumb.lpByte = NULL;
01079          if ((i==VT_CF_NAME||i==VT_CF_FMTID)&&(lpSSIM->thumb.lpstzName!=NULL))
01080             MemFree(lpSSIM->thumb.lpstzName);
01081          return VT_CF_EMPTY;
01082       }
01083    }
01084    *clipFormatNo = lpSSIM->thumb.clipFormat;
01085    *byteCount = lpSSIM->thumb.cBytes;
01086    if(lpszName!=NULL)
01087       *lpszName = (LPOLESTR)lpSSIM->thumb.lpstzName+1;
01088    *clip = (char FAR*)lpSSIM->thumb.lpByte;
01089    if (transferClip) lpSSIM->thumb.lpByte=NULL;
01090    return (int)lpSSIM->thumb.selector;
01091 }
01092
01093
01094 /*************************************************************************
01095 **
01096 ** OleStdSetThumbNailProperty
01097 **
01098 ** Purpose:
01099 **    Set a Thumbnail Property
01100 **
01101 ** Parameters:
01102 **    LPSTREAM lps                  - open SummaryInfo IStream*
01103 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
01104 **    int vtcfNo                    - OLE thumbnail selector value
01105 **          VT_CF_WIN                   - Windows thumbnail
01106 **                                        (interpret clipFormatNo as
01107 **                                        Windows clipboard format)
01108 **          VT_CF_FMTID                 - thumbnail format is specified
01109 **                                        by ID. use clipFormatNo.
01110 **                                        (but NOT a Windows format ID)
01111 **
01112 **          VT_CF_NAME                  - thumbnail format is specified
01113 **                                        by name. use lpszName.
01114 **          VT_CF_EMPTY                 - blank thumbnail
01115 **                                        (clip will be NULL)
01116 **
01117 **    DWORD FAR* clipFormatNo       - clipboard format for thumbnail
01118 **                                      used if vtcfNo is VT_CF_WIN or
01119 **                                      VT_CF_FMTID. interpretation of
01120 **                                      value depends on vtcfNo specified.
01121 **                                      (normally vtcfNo==VT_CF_WIN and
01122 **                                      clipFormatNo==CF_METAFILEPICT)
01123 **    LPSTR FAR* lpszName           - format name if vtcfNo is VT_CF_NAME
01124 **    THUMBNAIL clip                - handle to thumbnail
01125 **                                      for VT_CF_WIN clip will be
01126 **                                      handle to MetafilePict
01127 **    DWORD FAR* byteCount          - size of thumbnail stream
01128 **                                      for VT_CF_WIN case this should
01129 **                                      be combined size of both the
01130 **                                      Metafile as well as the
01131 **                                      MetafilePict structure.
01132 **
01133 ** Return Value:
01134 **    int                           - 1 for success
01135 **                                  - 0 if error occurs
01136 **
01137 ** Comments:
01138 **    NOTE: Currently there is only proper support for VT_CF_WIN.
01139 **    OleStdSetThumbNailProperty does implement VT_CF_FMTID and VT_CF_NAME,
01140 **    however, OleStdGetThumbNailProperty, OleStdReadSummaryInfo and
01141 **    OleStdWriteSummaryInfo only support VT_CF_WIN.
01142 **
01143 **    This function copies lpszName but saves the "clip" handle passed.
01144 **
01145 **    NOTE: overwriting or emptying frees space for clip and name.
01146 **    The thumbnail is manipulated as a windows handle to a
01147 **    METAFILEPICT structure, which in turn contains a handle to the
01148 **    METAFILE.
01149 *************************************************************************/
01150
01151 STDAPI_(int) OleStdSetThumbNailProperty(
01152       LPSTREAM        lps,
01153       LPSUMINFO       lp,
01154       int             vtcfNo,
01155       DWORD           clipFormatNo,
01156       LPOLESTR        lpszName,
01157       THUMBNAIL       clip,
01158       DWORD           byteCount
01159 )
01160 {
01161    int i;
01162    LPRSI lprsi=(LPRSI)lp;
01163    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
01164    LPMETAFILEPICT lpmfp;
01165    if (lpSSIM==NULL||vtcfNo>0||vtcfNo<VT_CF_EMPTY||(vtcfNo==VT_CF_NAME&&(lpszName==NULL||*lpszName==0))) {
01166       return 0;
01167    }
01168    if (vtcfNo!=VT_CF_EMPTY&&(clip==0||byteCount==0)) return 0;
01169    i = (int) lpSSIM->thumb.vtType;
01170    if (i!=VT_EMPTY) {
01171       i = (int) lpSSIM->thumb.selector;
01172       ASSERT(i!=VT_CF_NAME);
01173       if (i==VT_CF_WIN) {
01174          if (lpSSIM->thumb.lpByte!=NULL) {
01175             lpmfp = (LPMETAFILEPICT)GlobalLock((HANDLE)(DWORD)lpSSIM->thumb.lpByte);
01176             GlobalFree(lpmfp->hMF);
01177             GlobalUnlock((HANDLE)(DWORD)lpSSIM->thumb.lpByte);
01178             GlobalFree((HANDLE)(DWORD)lpSSIM->thumb.lpByte);
01179          }
01180       } else {
01181          MemFree(lpSSIM->thumb.lpByte);
01182       }
01183       if ((i==VT_CF_NAME||i==VT_CF_FMTID)&&(lpSSIM->thumb.lpstzName!=NULL))
01184          MemFree(lpSSIM->thumb.lpstzName);
01185       lpSSIM->thumb.lpstzName = NULL;
01186       lpSSIM->thumb.lpByte = NULL;
01187    }
01188    if (vtcfNo==VT_CF_EMPTY) {
01189       lpSSIM->thumb.vtType = VT_EMPTY;
01190       lpSSIM->thumb.cBytes = 0;
01191    } else {
01192       lpSSIM->thumb.vtType = VT_CF;
01193       lpSSIM->thumb.selector = vtcfNo;
01194       lpSSIM->thumb.cBytes = byteCount;
01195       lpSSIM->thumb.clipFormat = clipFormatNo;
01196       lpSSIM->thumb.lpByte = (LPOLESTR)clip;    //just save the hnadle
01197       if (vtcfNo==VT_CF_NAME||vtcfNo==VT_CF_FMTID) {
01198          i = OLESTRLEN(lpszName);
01199          if (vtcfNo==VT_CF_FMTID) ASSERT(i==sizeof(FMTID));
01200          lpSSIM->thumb.lpstzName =
01201             (LPOLESTR)MemAlloc(i+1/*n*/+1/*null*/);
01202          if (lpSSIM->thumb.lpstzName==NULL) {
01203             lpSSIM->thumb.vtType = VT_EMPTY;
01204             return 0;
01205          }
01206          W2A (lpszName, (char FAR*)lpSSIM->thumb.lpstzName+1, sizeof(lpSSIM->thumb.lpstzName+1));
01207          *lpSSIM->thumb.lpstzName = i;
01208       }
01209    }
01210    return 1;
01211 }
01212
01213
01214 /*************************************************************************
01215 **
01216 ** OleStdGetDateProperty
01217 **
01218 ** Purpose:
01219 **    Retrieve Data Property
01220 **
01221 ** Parameters:
01222 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
01223 **    DWORD pid                     - ID of Property
01224 **    int FAR *yr                   - (OUT) year
01225 **    int FAR *mo                   - (OUT) month
01226 **    int FAR *dy                   - (OUT) day
01227 **    DWORD FAR *sc                 - (OUT) seconds
01228 **
01229 ** Return Value:
01230 **    void
01231 **
01232 ** Comments:
01233 **
01234 *************************************************************************/
01235
01236 STDAPI_(void) OleStdGetDateProperty(
01237       LPSUMINFO       lp,
01238       DWORD           pid,
01239       int FAR*        yr,
01240       int FAR*        mo,
01241       int FAR*        dy,
01242       DWORD FAR*      sc
01243 )
01244 {
01245    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
01246    SFFS sffs;
01247    pid -= PIDSI_EDITTIME;
01248    *yr = 0; *mo = 0; *dy = 0; *sc = 0;
01249    if (pid<0||pid>=MAXTIME) return;
01250    if (lpSSIM->rgTime[pid].vtType == VT_FILETIME) {
01251       if (pid==0) {
01252          //convert from 100ns to seconds
01253          ulargeDivide((ULARGE_INTEGER FAR*)&lpSSIM->rgTime[0].time, 10000);
01254          ulargeDivide((ULARGE_INTEGER FAR*)&lpSSIM->rgTime[0].time, 1000);
01255          pid = lpSSIM->rgTime[0].time.dwLowDateTime;
01256          *sc = pid%((DWORD)60*60*24);
01257          pid /= (DWORD)60*60*24;
01258          *dy = (int)(pid%(DWORD)30);
01259          pid /= (DWORD)30;
01260          *mo = (int)(pid%(DWORD)12);
01261          *yr = (int)(pid/(DWORD)12);
01262       } else {
01263          if (CoFileTimeToDosDateTime(&lpSSIM->rgTime[pid].time,
01264                   &sffs.dateVariable, &sffs.timeVariable)) {
01265             *yr = sffs.yr+1980;
01266             *mo = sffs.mon;
01267             *dy = sffs.dom;
01268             *sc = (DWORD)sffs.hr*3600+sffs.mint*60+sffs.sec*2;
01269          }
01270       }
01271    }
01272    return;
01273 }
01274
01275
01276
01277 /*************************************************************************
01278 **
01279 ** OleStdSetDateProperty
01280 **
01281 ** Purpose:
01282 **    Set Data Property
01283 **
01284 ** Parameters:
01285 **    LPSUMINFO FAR *lp             - pointer to open Summary Info struct
01286 **    DWORD pid                     - ID of Property
01287 **    int yr                        - year
01288 **    int mo                        - month
01289 **    int dy                        - day
01290 **    DWORD sc                      - seconds
01291 **
01292 ** Return Value:
01293 **    int                           - 1 for success
01294 **                                  - 0 if error occurs
01295 **
01296 ** Comments:
01297 **    Use all zeros to clear.
01298 **    The following is an example of valid input:
01299 **          yr=1993 mo=1(Jan) dy=1(1st) hr=12(noon) mn=30 sc=23
01300 **    for PIDSI_EDITTIME property, the values are a zero-origin duration
01301 **    of time.
01302 **
01303 *************************************************************************/
01304
01305 STDAPI_(int) OleStdSetDateProperty(
01306       LPSUMINFO       lp,
01307       DWORD           pid,
01308       int             yr,
01309       int             mo,
01310       int             dy,
01311       int             hr,
01312       int             mn,
01313       int             sc
01314 )
01315 {
01316    STANDARDSECINMEM FAR *lpSSIM=(STANDARDSECINMEM FAR*)&((LPRSI)lp)->section;
01317    SFFS sffs;
01318    pid -= PIDSI_EDITTIME;
01319    if (pid<0||pid>=MAXTIME) return 0;
01320    if ((yr|mo|dy|hr|mn|sc)==0) {   //all must be zero
01321       lpSSIM->rgTime[pid].vtType = VT_EMPTY;
01322       return 1;
01323    }
01324    lpSSIM->rgTime[pid].vtType = VT_FILETIME;
01325    if (pid==0) {
01326       lpSSIM->rgTime[0].time.dwLowDateTime =
01327             (((((DWORD)yr*365+mo*30)+dy)*24+hr)*60+mn)*60+sc;
01328       lpSSIM->rgTime[0].time.dwHighDateTime = 0;
01329       //10^7 nanoseconds/second
01330       ulargeMultiply((ULARGE_INTEGER FAR*)&lpSSIM->rgTime[0].time, 10000);
01331       //convert to units of 100 ns
01332       ulargeMultiply((ULARGE_INTEGER FAR*)&lpSSIM->rgTime[0].time, 1000);
01333    } else {
01334       sffs.yr = max(yr-1980,0);
01335       sffs.mon = mo;
01336       sffs.dom = dy;
01337       sffs.hr = hr;
01338       sffs.mint= mn;
01339       sffs.sec = sc/2;  //dos is 2 second intervals
01340       if (!CoDosDateTimeToFileTime(sffs.date, sffs.time,
01341             &lpSSIM->rgTime[pid].time)) {
01342          lpSSIM->rgTime[pid].vtType = VT_EMPTY;
01343          return 0;
01344       }
01345    }
01346    return 1;
01347 }
01348
01349 } //END C
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/WMIHelpers.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

WMIHelpers.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      WMIHelpers.h
00005 //
00006 //  Description:
00007 //      This file contains the declaration of the WMI helper functions.
00008 //
00009 //  Implementation Files:
00010 //      WMIHelpers.cpp
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 #pragma once
00015
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Include Files
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 #include "stdafx.h"
00022
00023
00024 //////////////////////////////////////////////////////////////////////////////
00025 // Function Declarations
00026 //////////////////////////////////////////////////////////////////////////////
00027
00028 HRESULT
00029 HrGetWMIProperty(
00030       IWbemClassObject *    pWMIObjectIn
00031     , LPCWSTR               pcszPropertyNameIn
00032     , ULONG                 ulPropertyTypeIn
00033     , VARIANT *             pVariantOut
00034     );
00035
00036 HRESULT
00037 HrSetWbemServices(
00038       IUnknown *        punkIn
00039     , IWbemServices *   pIWbemServicesIn
00040     );
00041
00042 HRESULT
00043 HrInitializeWbemConnection(
00044     IWbemServices ** pIWbemServicesOut
00045     );
00046
00047 HRESULT
00048 HrSetBlanket(
00049     IWbemServices * pIWbemServicesIn
00050     );
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenuExt/registry.Cpp Source File

  • SysMgmt
  • MMC
  • CMenuExt

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "Extend.h"
00026 #include "globals.h"
00027
00028 // list all of the nodes that we extend
00029 EXTENDER_NODE _NodeExtensions[] = {
00030     {ContextMenuExtension,
00031     {0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28}},
00032     {0xce0f5bf0, 0xabfb, 0x11d2, {0x99, 0x3a, 0x0, 0x80, 0xc7, 0x68, 0x78, 0xbf}},
00033     _T("Extension to the People-powered Node Context Menu")},
00034
00035     {DummyExtension,
00036     NULL,
00037     NULL,
00038     NULL}
00039 };
00040
00041 //            0xce0f5bf0, 0xabfb, 0x11d2, 0x99, 0x3a, 0x0, 0x80, 0xc7, 0x68, 0x78, 0xbf);
00042 ////////////////////////////////////////////////////////
00043 //
00044 // Internal helper functions prototypes
00045 //
00046
00047 // Set the given key and its value.
00048 BOOL setKeyAndValue(const _TCHAR* pszPath,
00049                     const _TCHAR* szSubkey,
00050                     const _TCHAR* szValue) ;
00051
00052 // Set the given key and its value in the MMC Snapin location
00053 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00054                           const _TCHAR* szSubkey,
00055                           const _TCHAR* szName,
00056                           const _TCHAR* szValue);
00057
00058 // Set the given valuename under the key to value
00059 BOOL setValue(const _TCHAR* szKey,
00060               const _TCHAR* szValueName,
00061               const _TCHAR* szValue);
00062
00063 // Delete szKeyChild and all of its descendents.
00064 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00065
00066 ////////////////////////////////////////////////////////
00067 //
00068 // Constants
00069 //
00070
00071 // Size of a CLSID as a string
00072 //const int CLSID_STRING_SIZE = 39 ;
00073
00074 /////////////////////////////////////////////////////////
00075 //
00076 // Public function implementation
00077 //
00078
00079 //
00080 // Register the component in the registry.
00081 //
00082 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00083                        const CLSID& clsid,         // Class ID
00084                        const _TCHAR* szFriendlyName)       //   IDs
00085 {
00086     // Get server location.
00087     _TCHAR szModule[512] ;
00088     DWORD dwResult =
00089         ::GetModuleFileName(hModule,
00090         szModule,
00091         sizeof(szModule)/sizeof(_TCHAR)) ;
00092
00093     assert(dwResult != 0) ;
00094
00095     // Get CLSID
00096     LPOLESTR wszCLSID = NULL ;
00097     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00098
00099     assert(SUCCEEDED(hr)) ;
00100
00101   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00102
00103     // Build the key CLSID\\{...}
00104     _TCHAR szKey[64] ;
00105     _tcscpy(szKey, _T("CLSID\\")) ;
00106   _tcscat(szKey, pszCLSID) ;
00107
00108     // Add the CLSID to the registry.
00109     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00110
00111     // Add the server filename subkey under the CLSID key.
00112     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00113
00114     // set the threading model
00115     _tcscat(szKey, _T("\\InprocServer32"));
00116     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00117
00118     // Free memory.
00119     CoTaskMemFree(wszCLSID) ;
00120
00121     return S_OK ;
00122 }
00123
00124 //
00125 // Remove the component from the registry.
00126 //
00127 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00128 {
00129     // Get CLSID
00130     LPOLESTR wszCLSID = NULL ;
00131     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00132
00133
00134     // Build the key CLSID\\{...}
00135     _TCHAR szKey[64] ;
00136     _tcscpy(szKey, _T("CLSID\\")) ;
00137
00138   MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00139   _tcscat(szKey, pszT) ;
00140
00141     // Delete the CLSID Key - CLSID\{...}
00142     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00143     assert((lResult == ERROR_SUCCESS) ||
00144          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00145
00146     // Free memory.
00147     CoTaskMemFree(wszCLSID) ;
00148
00149     return S_OK ;
00150 }
00151
00152 //
00153 // Register the snap-in in the registry.
00154 //
00155
00156 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00157                        const _TCHAR* szNameString,   // NameString
00158                        const CLSID& clsidAbout,   // Class Id for About Class
00159                        const BOOL fSupportExtensions)
00160 {
00161     // Get CLSID
00162     LPOLESTR wszCLSID = NULL ;
00163     LPOLESTR wszAboutCLSID = NULL;
00164     LPOLESTR wszExtendCLSID = NULL;
00165     LPOLESTR wszNodeCLSID = NULL;
00166     EXTENDER_NODE *pNodeExtension;
00167     _TCHAR szKeyBuf[1024] ;
00168     HKEY hKey;
00169
00170
00171     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00172
00173     if (IID_NULL != clsidAbout)
00174         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00175
00176   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00177   MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00178
00179
00180     // Add the CLSID to the registry.
00181     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00182     if (IID_NULL != clsidAbout)
00183         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00184
00185     if (fSupportExtensions) {
00186         // Build the key NodeType
00187         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00188
00189         _TCHAR szKey[64] ;
00190         _tcscpy(szKey, pszCLSID) ;
00191         _tcscat(szKey, _T("\\NodeTypes")) ;
00192         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00193     }
00194
00195     // register each of the node extensions
00196     for (pNodeExtension = &(_NodeExtensions[0]);*pNodeExtension->szDescription;pNodeExtension++)
00197     {
00198         hr = StringFromCLSID(pNodeExtension->guidNode, &wszExtendCLSID);
00199         MAKE_TSTRPTR_FROMWIDE(pszExtendCLSID, wszExtendCLSID);
00200         _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes\\"));
00201         _tcscat(szKeyBuf, pszExtendCLSID);
00202
00203         switch (pNodeExtension->eType) {
00204         case ContextMenuExtension:
00205             _tcscat(szKeyBuf, _T("\\Extensions\\ContextMenu"));
00206             break;
00207         default:
00208             break;
00209         }
00210
00211         // Create and open key and subkey.
00212         long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00213             szKeyBuf,
00214             0, NULL, REG_OPTION_NON_VOLATILE,
00215             KEY_ALL_ACCESS, NULL,
00216             &hKey, NULL) ;
00217
00218         if (lResult != ERROR_SUCCESS)
00219         {
00220             return FALSE ;
00221         }
00222
00223         hr = StringFromCLSID(pNodeExtension->guidExtension, &wszNodeCLSID);
00224         assert(SUCCEEDED(hr));
00225
00226         MAKE_TSTRPTR_FROMWIDE(pszNodeCLSID, wszNodeCLSID);
00227         // Set the Value.
00228         if (pNodeExtension->szDescription != NULL)
00229         {
00230             RegSetValueEx(hKey, pszNodeCLSID, 0, REG_SZ,
00231                 (BYTE *)pNodeExtension->szDescription,
00232                 (_tcslen(pNodeExtension->szDescription)+1)*sizeof(_TCHAR)) ;
00233         }
00234
00235         RegCloseKey(hKey) ;
00236
00237         CoTaskMemFree(wszExtendCLSID);
00238         CoTaskMemFree(wszNodeCLSID);
00239     }
00240
00241
00242     // Free memory.
00243     CoTaskMemFree(wszCLSID) ;
00244     if (IID_NULL != clsidAbout)
00245         CoTaskMemFree(wszAboutCLSID);
00246
00247     return S_OK ;
00248 }
00249
00250 //
00251 // Unregister the snap-in in the registry.
00252 //
00253 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00254 {
00255     _TCHAR szKeyBuf[1024];
00256     LPOLESTR wszCLSID = NULL;
00257
00258     // Get CLSID
00259     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00260   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00261
00262     // Load the buffer with the Snap-In Location
00263     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00264
00265     // Copy keyname into buffer.
00266     _tcscat(szKeyBuf, _T("\\"));
00267     _tcscat(szKeyBuf, pszCLSID);
00268
00269     // Delete the CLSID Key - CLSID\{...}
00270     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00271     assert((lResult == ERROR_SUCCESS) ||
00272          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00273
00274     // free the memory
00275     CoTaskMemFree(wszCLSID);
00276
00277     return S_OK;
00278 }
00279
00280 //
00281 // Delete a key and all of its descendents.
00282 //
00283 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00284                         const _TCHAR* lpszKeyChild)  // Key to delete
00285 {
00286     // Open the child.
00287     HKEY hKeyChild ;
00288     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00289         KEY_ALL_ACCESS, &hKeyChild) ;
00290     if (lRes != ERROR_SUCCESS)
00291     {
00292         return lRes ;
00293     }
00294
00295     // Enumerate all of the decendents of this child.
00296     FILETIME time ;
00297     _TCHAR szBuffer[256] ;
00298     DWORD dwSize = 256 ;
00299     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00300         NULL, NULL, &time) == S_OK)
00301     {
00302         // Delete the decendents of this child.
00303         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00304         if (lRes != ERROR_SUCCESS)
00305         {
00306             // Cleanup before exiting.
00307             RegCloseKey(hKeyChild) ;
00308             return lRes;
00309         }
00310         dwSize = 256 ;
00311     }
00312
00313     // Close the child.
00314     RegCloseKey(hKeyChild) ;
00315
00316     // Delete this child.
00317     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00318 }
00319
00320 //
00321 // Create a key and set its value.
00322 //   - This helper function was borrowed and modifed from
00323 //     Kraig Brockschmidt's book Inside OLE.
00324 //
00325 BOOL setKeyAndValue(const _TCHAR* szKey,
00326                     const _TCHAR* szSubkey,
00327                     const _TCHAR* szValue)
00328 {
00329     HKEY hKey;
00330     _TCHAR szKeyBuf[1024] ;
00331
00332     // Copy keyname into buffer.
00333     _tcscpy(szKeyBuf, szKey) ;
00334
00335     // Add subkey name to buffer.
00336     if (szSubkey != NULL)
00337     {
00338         _tcscat(szKeyBuf, _T("\\")) ;
00339         _tcscat(szKeyBuf, szSubkey ) ;
00340     }
00341
00342     // Create and open key and subkey.
00343     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00344         szKeyBuf,
00345         0, NULL, REG_OPTION_NON_VOLATILE,
00346         KEY_ALL_ACCESS, NULL,
00347         &hKey, NULL) ;
00348     if (lResult != ERROR_SUCCESS)
00349     {
00350         return FALSE ;
00351     }
00352
00353     // Set the Value.
00354     if (szValue != NULL)
00355     {
00356         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00357             (BYTE *)szValue,
00358             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00359     }
00360
00361     RegCloseKey(hKey) ;
00362     return TRUE ;
00363 }
00364
00365 //
00366 // Open a key value and set it
00367 //
00368 BOOL setValue(const _TCHAR* szKey,
00369               const _TCHAR* szValueName,
00370               const _TCHAR* szValue)
00371 {
00372     HKEY hKey;
00373     _TCHAR szKeyBuf[1024] ;
00374
00375     // Copy keyname into buffer.
00376     _tcscpy(szKeyBuf, szKey) ;
00377
00378     // Create and open key and subkey.
00379     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00380         szKeyBuf,
00381         0, NULL, REG_OPTION_NON_VOLATILE,
00382         KEY_ALL_ACCESS, NULL,
00383         &hKey, NULL) ;
00384     if (lResult != ERROR_SUCCESS)
00385     {
00386         return FALSE ;
00387     }
00388
00389     // Set the Value.
00390     if (szValue != NULL)
00391     {
00392         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00393             (BYTE *)szValue,
00394             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00395     }
00396
00397     RegCloseKey(hKey) ;
00398     return TRUE ;
00399 }
00400
00401 //
00402 // Create a key and set its value.
00403 //   - This helper function was borrowed and modifed from
00404 //     Kraig Brockschmidt's book Inside OLE.
00405 //
00406 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00407                           const _TCHAR* szSubkey,
00408                           const _TCHAR* szName,
00409                           const _TCHAR* szValue)
00410 {
00411     HKEY hKey;
00412     _TCHAR szKeyBuf[1024] ;
00413
00414     // Load the buffer with the Snap-In Location
00415     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00416
00417     // Copy keyname into buffer.
00418     _tcscat(szKeyBuf, _T("\\")) ;
00419     _tcscat(szKeyBuf, szKey) ;
00420
00421     // Add subkey name to buffer.
00422     if (szSubkey != NULL)
00423     {
00424         _tcscat(szKeyBuf, _T("\\")) ;
00425         _tcscat(szKeyBuf, szSubkey ) ;
00426     }
00427
00428     // Create and open key and subkey.
00429     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00430         szKeyBuf,
00431         0, NULL, REG_OPTION_NON_VOLATILE,
00432         KEY_ALL_ACCESS, NULL,
00433         &hKey, NULL) ;
00434     if (lResult != ERROR_SUCCESS)
00435     {
00436         return FALSE ;
00437     }
00438
00439     // Set the Value.
00440     if (szValue != NULL)
00441     {
00442         RegSetValueEx(hKey, szName, 0, REG_SZ,
00443             (BYTE *)szValue,
00444             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00445     }
00446
00447     RegCloseKey(hKey) ;
00448     return TRUE ;
00449 }
00450
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/MainWnd.c Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

MainWnd.c

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1996 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Mainwnd: mainwnd.c
00009 //
00010 // PURPOSE: main window functions
00011 //
00012 // PLATFORMS:  Windows NT (only)
00013 //
00014 // FUNCTIONS:
00015 //  DeleteAllCounters()     clears counters from query
00016 //  On_WM_CREATE()          processes WM_CREATE message
00017 //  On_IDM_GET_DATA()       gets the current perf data and updates window
00018 //  On_IDM_ADD_COUNTERS()   displays browser & adds perf. counter to display
00019 //  On_IDM_CLEAR_ALL()      clear all counters & refresh display
00020 //  On_WM_COMMAND()         processes WM_COMMAND messages
00021 //  On_WM_RBUTTONDOWN()     processes Right Mouse button clicks
00022 //  On_WM_PAINT()           draws the current data in the main window
00023 //  On_WM_DESTROY()         closes any open interfaces & memory allocations
00024 //  WndProc()               main window procedure for this app's window
00025 //
00026 // SPECIAL INSTRUCTIONS: N/A
00027 //
00028 #define WIN32_LEAN_AND_MEAN 1
00029 #include <windows.h>
00030 #include <winperf.h>
00031 #include <stdio.h>
00032 #include <pdh.h>
00033 #include <pdhmsg.h>
00034
00035 #include "statlist.h"
00036 #include "winutils.h"
00037 #include "mainwnd.h"
00038 #include "aboutdlg.h"
00039
00040 // font for text in window
00041 static   HFONT hFinePrint = NULL;
00042
00043 // PDH Query Handle for these counters
00044 static HQUERY   hQuery = NULL;
00045
00046 // pointer to first item in counter list
00047 static PCIB    pFirstCib = NULL;
00048
00049 int nTabStops[] = {300, 400, 500, 600, 700};
00050 int nNumTabStops = sizeof(nTabStops) / sizeof(int);
00051
00052 #define NUM_STAT_SAMPLES    100
00053
00054 static
00055 void
00056 DeleteAllCounters ()
00057 {
00058    PCIB   pCib, pCibOld;
00059
00060    // close PDH Query
00061    // this removes all counters from the query as well as
00062    // removes the query item itself
00063    if (hQuery != NULL)
00064    {
00065       PdhCloseQuery (hQuery);
00066       hQuery = NULL;
00067    }
00068
00069    // clean up any memory allocations
00070    pCib = pFirstCib;
00071    while ( pCib != NULL)
00072    {
00073       pCibOld = pCib;
00074       if (pCibOld->pCounterArray != NULL)
00075       {
00076          HeapFree (GetProcessHeap(), 0, pCibOld->pCounterArray);
00077       }
00078       pCib = pCib->pNext;
00079       HeapFree (GetProcessHeap(), 0, pCibOld);
00080    }
00081    pFirstCib = NULL;
00082 }
00083
00084 // windows message functions
00085 static
00086 LRESULT
00087 On_WM_CREATE (
00088              HWND hWnd,
00089              WPARAM wParam,
00090              LPARAM lParam)
00091 {
00092    PDH_STATUS  pdhStatus;
00093
00094    if (hQuery == NULL)
00095    {
00096       pdhStatus = PdhOpenQuery (NULL, 0, &hQuery);
00097    }
00098    if (hFinePrint == NULL)
00099    {
00100       hFinePrint = CreateFont(11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00101                               VARIABLE_PITCH | FF_SWISS, "");
00102    }
00103    return ERROR_SUCCESS;
00104 }
00105
00106 static
00107 LRESULT
00108 On_IDM_GET_DATA (
00109                 HWND hWnd,
00110                 WPARAM wParam,
00111                 LPARAM lParam)
00112 {
00113    PDH_STATUS  pdhStatus;
00114    DWORD       dwType;
00115    PCIB        pCib;
00116    PDH_FMT_COUNTERVALUE    pValue;
00117    PDH_RAW_COUNTER         pRaw;
00118
00119    if (hQuery != NULL)
00120    {
00121       // get the current values of the query data
00122       pdhStatus = PdhCollectQueryData (hQuery);
00123       if (pdhStatus == ERROR_SUCCESS)
00124       {
00125          // loop through all counters and update the display values
00126          // and statistics
00127          for (pCib = pFirstCib; pCib != NULL; pCib = pCib->pNext)
00128          {
00129             // update "Last value"
00130             pdhStatus = PdhGetFormattedCounterValue (
00131                                                     pCib->hCounter, PDH_FMT_DOUBLE, &dwType, &pValue);
00132             pCib->dLastValue = pValue.doubleValue;
00133             // update "Raw Value" and statistics
00134             pdhStatus = PdhGetRawCounterValue (
00135                                               pCib->hCounter, &dwType, &pRaw);
00136             pCib->pCounterArray[pCib->dwNextIndex] = pRaw;
00137             pdhStatus = PdhComputeCounterStatistics (
00138                                                     pCib->hCounter,
00139                                                     PDH_FMT_DOUBLE,
00140                                                     pCib->dwFirstIndex,
00141                                                     ++pCib->dwLastIndex,
00142                                                     pCib->pCounterArray,
00143                                                     &pCib->pdhCurrentStats);
00144             // update pointers & indeces
00145             if (pCib->dwLastIndex < NUM_STAT_SAMPLES)
00146             {
00147                pCib->dwNextIndex = ++pCib->dwNextIndex % NUM_STAT_SAMPLES;
00148             }
00149             else
00150             {
00151                --pCib->dwLastIndex;
00152                pCib->dwNextIndex = pCib->dwFirstIndex;
00153                pCib->dwFirstIndex = ++pCib->dwFirstIndex % NUM_STAT_SAMPLES;
00154             }
00155          }
00156          // cause the window to be repainted with the new values
00157          // (NOTE: This isn't the most efficient method of
00158          // display updating.)
00159          InvalidateRect (hWnd, NULL, TRUE);
00160       }
00161    }
00162    return ERROR_SUCCESS;
00163 }
00164
00165 static
00166 LRESULT
00167 On_IDM_ADD_COUNTERS (
00168                     HWND hWnd,
00169                     WPARAM wParam,
00170                     LPARAM lParam)
00171 {
00172    PDH_BROWSE_DLG_CONFIG  BrowseInfo;
00173    CHAR            szCounterBuffer[COUNTER_STRING_SIZE];
00174    PDH_STATUS      pdhStatus;
00175    PCIB            pNewCib;
00176
00177    BrowseInfo.bIncludeInstanceIndex = FALSE;
00178    BrowseInfo.bSingleCounterPerAdd = TRUE;
00179    BrowseInfo.bSingleCounterPerDialog = TRUE;
00180    BrowseInfo.bLocalCountersOnly = FALSE;
00181    BrowseInfo.bWildCardInstances = FALSE;
00182    BrowseInfo.bHideDetailBox = FALSE;
00183    BrowseInfo.bDisableMachineSelection = FALSE;
00184    BrowseInfo.bInitializePath = FALSE;
00185    BrowseInfo.bIncludeCostlyObjects = TRUE;
00186    BrowseInfo.bReserved = 0;
00187    BrowseInfo.hWndOwner = hWnd;
00188    BrowseInfo.szReturnPathBuffer = szCounterBuffer;
00189    BrowseInfo.cchReturnPathLength = COUNTER_STRING_SIZE;
00190    BrowseInfo.pCallBack = NULL;
00191    BrowseInfo.dwCallBackArg = 0;
00192    BrowseInfo.CallBackStatus = ERROR_SUCCESS;
00193    BrowseInfo.dwDefaultDetailLevel = PERF_DETAIL_WIZARD;
00194    BrowseInfo.szDialogBoxCaption = "Select a counter to monitor";
00195    BrowseInfo.szDataSource = NULL;
00196
00197
00198    pdhStatus = PdhBrowseCounters (&BrowseInfo);
00199
00200    if (pdhStatus == ERROR_SUCCESS)
00201    {
00202       // add counter to the list
00203       pNewCib = (PCIB) HeapAlloc(GetProcessHeap(),
00204                                  HEAP_ZERO_MEMORY, sizeof(CIB));
00205       if (pNewCib != NULL)
00206       {
00207          // try to add the counter to the query
00208          pdhStatus = PdhAddCounter (hQuery,
00209                                     szCounterBuffer, 0, &pNewCib->hCounter);
00210          if (pdhStatus == ERROR_SUCCESS)
00211          {
00212             lstrcpyn(pNewCib->szCounterPath, szCounterBuffer, COUNTER_STRING_SIZE);
00213             // allocate the raw data buffer here
00214             pNewCib->pCounterArray = (PPDH_RAW_COUNTER)HeapAlloc (
00215                                                                  GetProcessHeap(), HEAP_ZERO_MEMORY,
00216                                                                  (sizeof(PDH_RAW_COUNTER) * NUM_STAT_SAMPLES));
00217             pNewCib->dwFirstIndex = 0;
00218             pNewCib->dwNextIndex = 0;
00219             pNewCib->dwLastIndex = 0;
00220             pNewCib->dLastValue = 0.0f;
00221             pNewCib->pdhCurrentStats.dwFormat = 0;
00222             pNewCib->pdhCurrentStats.count = 0;
00223             pNewCib->pdhCurrentStats.min.CStatus = PDH_CSTATUS_INVALID_DATA;
00224             pNewCib->pdhCurrentStats.min.largeValue = 0;
00225             pNewCib->pdhCurrentStats.max.CStatus = PDH_CSTATUS_INVALID_DATA;
00226             pNewCib->pdhCurrentStats.max.largeValue = 0;
00227             pNewCib->pdhCurrentStats.mean.CStatus = PDH_CSTATUS_INVALID_DATA;
00228             pNewCib->pdhCurrentStats.mean.largeValue = 0;
00229
00230             //add to the top of the list
00231             pNewCib->pNext = pFirstCib;
00232             pFirstCib = pNewCib;
00233
00234             // repaint window to get new entry
00235             InvalidateRect (hWnd, NULL, TRUE);
00236          } // else unable to add counter
00237       } // else unable to allocate pointer
00238    } // else user cancelled
00239    return ERROR_SUCCESS;
00240 }
00241
00242 static
00243 LRESULT
00244 On_IDM_CLEAR_ALL (
00245                  HWND hWnd,
00246                  WPARAM wParam,
00247                  LPARAM lParam)
00248 {
00249    PDH_STATUS  pdhStatus;
00250
00251    // delete all current counters, then create a new query
00252    DeleteAllCounters();
00253
00254    pdhStatus = PdhOpenQuery (NULL, 0, &hQuery);
00255
00256    InvalidateRect (hWnd, NULL, TRUE);
00257
00258    return ERROR_SUCCESS;
00259 }
00260
00261 static
00262 LRESULT
00263 On_WM_COMMAND (
00264               HWND hWnd,
00265               WPARAM wParam,
00266               LPARAM lParam)
00267 {
00268    int wmId, wmEvent;
00269    char szHelpFileName[MAX_PATH];
00270    BOOL bGotHelp;
00271
00272    wmId    = LOWORD(wParam); // Remember, these are...
00273    wmEvent = HIWORD(wParam); // ...different for Win32!
00274
00275    //Parse the menu selections:
00276    switch (wmId)
00277    {
00278    // File Menu Item
00279    case IDM_NEW:
00280    case IDM_OPEN:
00281    case IDM_SAVE:
00282    case IDM_SAVEAS:
00283       return (DefWindowProc(hWnd, WM_COMMAND, wParam, lParam));
00284
00285    case IDM_EXIT:
00286       DestroyWindow (hWnd);
00287       return ERROR_SUCCESS;
00288
00289       // configure menu item
00290    case IDM_ADD_COUNTERS:
00291       return On_IDM_ADD_COUNTERS (hWnd, wParam, lParam);
00292
00293    case IDM_CLEAR_ALL:
00294       return On_IDM_CLEAR_ALL (hWnd, wParam, lParam);
00295
00296       // get data menu item
00297    case IDM_GET_DATA:
00298       return On_IDM_GET_DATA (hWnd, wParam, lParam);
00299
00300
00301       // Help Menu Item
00302    case IDM_HELPTOPICS:
00303       _snprintf(szHelpFileName, MAX_PATH, "%s.HLP", APPNAME);
00304       bGotHelp = WinHelp (hWnd, szHelpFileName, HELP_FINDER,(DWORD)0);
00305       if (!bGotHelp)
00306       {
00307          MessageBox (GetFocus(), GetStringRes(IDS_NO_HELP),
00308                      APPNAME, MB_OK|MB_ICONHAND);
00309       }
00310       return ERROR_SUCCESS;
00311
00312    case IDM_ABOUT:
00313       DialogBox((HINSTANCE)(GetWindowLongPtr(hWnd, GWLP_HINSTANCE)),
00314                 "AboutBox", hWnd, (DLGPROC)About);
00315       return ERROR_SUCCESS;
00316
00317    default:
00318       return (DefWindowProc(hWnd, WM_COMMAND, wParam, lParam));
00319    }
00320 }
00321
00322 static LRESULT
00323 On_WM_RBUTTONDOWN (
00324                   HWND hWnd,
00325                   WPARAM wParam,
00326                   LPARAM lParam)
00327 {
00328    POINT pnt;
00329    HMENU hMenu;
00330
00331    pnt.x = LOWORD(lParam);
00332    pnt.y = HIWORD(lParam);
00333    ClientToScreen(hWnd, (LPPOINT) &pnt);
00334    // This is where you would determine the appropriate 'context'
00335    // menu to bring up. Since this app has no real functionality,
00336    // we will just bring up the 'configure' menu:
00337    hMenu = GetSubMenu (GetMenu (hWnd), 1);
00338    if (hMenu)
00339    {
00340       TrackPopupMenu (hMenu, 0, pnt.x, pnt.y, 0, hWnd, NULL);
00341    }
00342    else
00343    {
00344       // Couldn't find the menu...
00345       MessageBeep(0);
00346    }
00347
00348    return ERROR_SUCCESS;
00349 }
00350
00351 static LRESULT
00352 On_WM_PAINT (
00353             HWND hWnd,
00354             WPARAM wParam,
00355             LPARAM lParam)
00356 {
00357    PAINTSTRUCT ps;
00358    HDC hdc;
00359    PCIB    pCib;
00360    int     nX, nY;
00361    LONG    lTextOutReturn;
00362    char    szOutputString[MAX_PATH + COUNTER_STRING_SIZE];
00363    int     nStringLength;
00364
00365    hdc = BeginPaint (hWnd, &ps);
00366
00367    nX = 0;
00368    nY = 0;
00369    // draw Title text
00370    lstrcpyn(szOutputString, "Performance Counter\tLast Value\tMinimum\tMaximum\tAverage", MAX_PATH);
00371    nStringLength = lstrlen(szOutputString) * sizeof(TCHAR);
00372    lTextOutReturn = TabbedTextOut (hdc, nX, nY,
00373                                    szOutputString, nStringLength,
00374                                    nNumTabStops, nTabStops, 0);
00375    nY += HIWORD(lTextOutReturn);
00376
00377    // select the fine print font for this window
00378    SelectObject(hdc, hFinePrint);
00379
00380    // for each CIB in the list draw the current text and value
00381    for (pCib = pFirstCib; pCib != NULL; pCib = pCib->pNext)
00382    {
00383       nStringLength = _snprintf(szOutputString, COUNTER_STRING_SIZE + MAX_PATH, "%s\t%f\t%f\t%f\t%f",
00384                                pCib->szCounterPath, pCib->dLastValue,
00385                                pCib->pdhCurrentStats.min.doubleValue,
00386                                pCib->pdhCurrentStats.max.doubleValue,
00387                                pCib->pdhCurrentStats.mean.doubleValue);
00388       lTextOutReturn = TabbedTextOut (hdc, nX, nY,
00389                                       szOutputString, nStringLength,
00390                                       nNumTabStops, nTabStops, 0);
00391       nY += HIWORD(lTextOutReturn);
00392    }
00393
00394    EndPaint (hWnd, &ps);
00395    return ERROR_SUCCESS;
00396 }
00397
00398 static LRESULT
00399 On_WM_DESTROY (
00400               HWND hWnd,
00401               WPARAM wParam,
00402               LPARAM lParam)
00403 {
00404    char szHelpFileName[MAX_PATH];
00405
00406    _snprintf(szHelpFileName, MAX_PATH, "%s.HLP", APPNAME);
00407    // Tell WinHelp we don't need it any more...
00408    WinHelp (hWnd, szHelpFileName, HELP_QUIT,(DWORD)0);
00409
00410    DeleteAllCounters();
00411
00412    PostQuitMessage(0);
00413    return ERROR_SUCCESS;
00414 }
00415
00416 //  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
00417 //
00418 //  PURPOSE:  Processes messages for the main window.
00419 //
00420 //  MESSAGES:
00421 //
00422 //    WM_COMMAND - process the application menu
00423 //    WM_PAINT - Paint the main window
00424 //    WM_DESTROY - post a quit message and return
00425 //    WM_RBUTTONDOWN - Right mouse click -- put up context menu here if appropriate
00426 //
00427 //
00428 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00429 {
00430    switch (message)
00431    {
00432    case WM_CREATE:
00433       return On_WM_CREATE (hWnd, wParam, lParam);
00434
00435    case WM_COMMAND:
00436       return On_WM_COMMAND (hWnd, wParam, lParam);
00437
00438    case WM_RBUTTONDOWN: // RightClick in windows client area...
00439       return On_WM_RBUTTONDOWN (hWnd, wParam, lParam);
00440
00441    case WM_PAINT:
00442       return On_WM_PAINT (hWnd, wParam, lParam);
00443
00444    case WM_DESTROY:
00445       return On_WM_DESTROY (hWnd, wParam, lParam);
00446
00447    default:
00448       return (DefWindowProc(hWnd, message, wParam, lParam));
00449    }
00450    return (0);
00451 }
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authentication/AuthenticateContext.h Source File

  • Multimedia
  • WindowsMediaServices9
  • Authentication

AuthenticateContext.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       AuthenticateContext.h
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011
00012
00013 #if !defined(AFX_AUTHENTICATECONTEXT_H__D5FB96E8_39EB_4691_B4CA_6340014B116B__INCLUDED_)
00014 #define AFX_AUTHENTICATECONTEXT_H__D5FB96E8_39EB_4691_B4CA_6340014B116B__INCLUDED_
00015
00016 #include "resource.h"       // main symbols
00017
00018 /////////////////////////////////////////////////////////////////////////////
00019 // CAuthenticateContext
00020 class ATL_NO_VTABLE CAuthenticateContext :
00021         public CComObjectRootEx<CComMultiThreadModel>,
00022         public CComCoClass<CAuthenticateContext, &CLSID_AuthenticateContext>,
00023         public IWMSAuthenticationContext
00024 {
00025 public:
00026     CAuthenticateContext();
00027     ~CAuthenticateContext();
00028
00029 DECLARE_REGISTRY_RESOURCEID(IDR_AUTHENTICATECONTEXT)
00030
00031 DECLARE_PROTECT_FINAL_CONSTRUCT()
00032
00033 BEGIN_COM_MAP(CAuthenticateContext)
00034     COM_INTERFACE_ENTRY(IWMSAuthenticationContext)
00035 END_COM_MAP()
00036
00037
00038 public:
00039     STDMETHOD( Initialize )( IWMSAuthenticationPlugin* pAuthenticator );
00040
00041     // IWMSAuthenticationContext methods
00042     STDMETHOD( GetAuthenticationPlugin )( IWMSAuthenticationPlugin **ppAuthenPlugin );
00043     STDMETHOD( Authenticate )(
00044                     VARIANT ResponseBlob,
00045                     IWMSContext *pUserCtx,
00046                     IWMSContext *pPresentationCtx,
00047                     IWMSCommandContext *pCommandContext,
00048                     IWMSAuthenticationCallback *pCallback,
00049                     VARIANT Context );
00050     STDMETHOD( GetLogicalUserID )( BSTR* bstrUserID );
00051     STDMETHOD( GetImpersonationAccountName )( BSTR* bstrAccountName );
00052     STDMETHOD( GetImpersonationToken )( long* Token );
00053
00054 private:
00055     IWMSAuthenticationPlugin            *m_pWMSAuthenticationPlugin;
00056     CRITICAL_SECTION                    m_CritSec;
00057     HANDLE                              m_hToken;
00058     DWORD                               m_State;
00059     CComBSTR                            m_bstrUsername;
00060 };
00061
00062 #endif // !defined(AFX_AUTHENTICATECONTEXT_H__D5FB96E8_39EB_4691_B4CA_6340014B116B__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CConnectDlg Member List

This is the complete list of members for CConnectDlg, including all inherited members.
CConnectDlg(CWnd *pParent=NULL) | CConnectDlg |
CConnectDlg(CWnd *pParent=NULL) | CConnectDlg |
DoDataExchange(CDataExchange *pDX) | CConnectDlg | [protected, virtual]
DoDataExchange(CDataExchange *pDX) | CConnectDlg | [protected, virtual]
IDD enum value | CConnectDlg |
m_CancelButton | CConnectDlg |
m_cContinueButton | CConnectDlg |
m_cRadioDS | CConnectDlg |
m_cRadioWorkgroup | CConnectDlg |
m_edtRemoteComputerName | CConnectDlg |
m_hIcon | CConnectDlg | [protected]
m_iRadioDS | CConnectDlg |
m_nConnectionType | CConnectDlg | [private]
m_pCatalog | CConnectDlg | [private]
m_pParentDlg | CConnectDlg | [private]
m_strLogin | CConnectDlg |
OnClose() | CConnectDlg | [protected]
OnConnect() | CConnectDlg | [protected]
OnInitDialog() | CConnectDlg | [protected, virtual]
OnInitDialog() | CConnectDlg | [protected, virtual]
OnLocalComputer() | CConnectDlg | [protected]
OnOK() | CConnectDlg | [protected, virtual]
OnRemoteComputer() | CConnectDlg | [protected]
ReleaseCatalog() | CConnectDlg | [private]
set_Catalog(ICOMAdminCatalog *pCatalog) | CConnectDlg |
set_ParentDlg(CVCExploreDlg *pDlg) | CConnectDlg |
ToggleEditControl(bool Flag) | CConnectDlg | [private]
Generated on Wed Nov 13 2024 16:55:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Write/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Write
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Write.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/ias.h Source File

  • Com
  • Fundamentals
  • SimpCntr

ias.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IAS.H
00003 //
00004 //      Definition of CAdviseSink
00005 //
00006 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IAS_H_ )
00009 #define _IAS_H_
00010
00011 #include <assert.h>
00012
00013 class CSimpleSite;
00014
00015 interface CAdviseSink : public IAdviseSink
00016 {
00017   int m_nCount;
00018   CSimpleSite FAR * m_pSite;
00019
00020   CAdviseSink(CSimpleSite FAR * pSite) {
00021     OutputDebugString("In IAS's constructor\r\n");
00022     m_pSite = pSite;
00023     m_nCount = 0;
00024     };
00025
00026   ~CAdviseSink() {
00027     OutputDebugString("In IAS's destructor\r\n");
00028     assert(m_nCount == 0);
00029     } ;
00030
00031   STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
00032   STDMETHODIMP_(ULONG) AddRef ();
00033   STDMETHODIMP_(ULONG) Release ();
00034
00035   // *** IAdviseSink methods ***
00036   STDMETHODIMP_(void) OnDataChange (FORMATETC FAR* pFormatetc, STGMEDIUM FAR* pStgmed);
00037   STDMETHODIMP_(void) OnViewChange (DWORD dwAspect, LONG lindex);
00038   STDMETHODIMP_(void) OnRename (LPMONIKER pmk);
00039   STDMETHODIMP_(void) OnSave ();
00040   STDMETHODIMP_(void) OnClose ();
00041 };
00042
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

RUN Member List

This is the complete list of members for RUN, including all inherited members.
analysis | RUN
iLen | RUN
iStyle | RUN
pNext | RUN
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step4/StdAfx.cpp Source File

  • NetDS
  • upnp
  • StepByStep
  • Step4

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/Check_SD/Check_SD.h Source File

  • Security
  • Authorization
  • Check_SD

Check_SD.h

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1997 - 2000.  Microsoft Corporation.  All rights reserved
00008
00009 Module Name:
00010
00011     check_sd.h
00012
00013 Abstract:
00014
00015     This module contains the declarations for the functions used in the check_sd
00016     sample.  The declarations are grouped based on the modules they are located in.
00017
00018 --*/
00019
00020 #ifndef _CHECKSD_
00021 #define _CHECKSD_
00022
00023 #define STRICT
00024
00025 //
00026 // undefine this if you want to build for UNICODE
00027 //
00028 //#define UNICODE
00029 //#define _UNICODE
00030
00031 #include <windows.h>
00032
00033 //
00034 // access for network shares.  these are based on the values set by
00035 // explorer
00036 //
00037 #define READ        0x000001BF
00038 #define CHANGE      0x000000A9
00039 #define WRITE       0x00000040
00040
00041 //
00042 // helper definitions, helper.c
00043 //
00044 #define UNKNOWNSIDS 4
00045
00046 //
00047 // helper functions, helper.c
00048 //
00049 BOOL ConvertSid(PSID pSid, LPTSTR pszSidText, LPDWORD dwBufferLen);
00050 void DisplayError(DWORD dwError, LPTSTR pszAPI);
00051 BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable);
00052 void LookupAccountOtherSid(PSID psidCheck, LPTSTR pszName, LPDWORD pcbName, LPTSTR pszDomain, LPDWORD pcbDomain, PSID_NAME_USE psnu);
00053
00054 //
00055 // functions for obtaining information from a security descriptor, sd.c
00056 //
00057 DWORD DumpAclInfo(PACL pacl, BOOL bDacl);
00058 void  DumpControl(PSECURITY_DESCRIPTOR psd);
00059 void  DumpDacl(PSECURITY_DESCRIPTOR psd, TCHAR c, BOOL bDacl);
00060 void  DumpOwnerGroup(PSECURITY_DESCRIPTOR psd, BOOL bOwner);
00061 void  DumpSD(PSECURITY_DESCRIPTOR psd, TCHAR c);
00062 void  DumpSDInfo(PSECURITY_DESCRIPTOR psd);
00063
00064 //
00065 // functions for obtaining a security descriptor for a variety of securable objects,
00066 // secobjects.c
00067 //
00068 void DumpFile(LPTSTR pszFile, TCHAR c);
00069 void DumpKernelObject(LPTSTR pszObject, TCHAR c);
00070 void DumpNetShare(LPTSTR pszShare);
00071 void DumpPrinter(LPTSTR pszPrinter);
00072 void DumpRegistryKey(LPTSTR pszKey);
00073 void DumpService(LPTSTR pszServer, LPTSTR pszService);
00074 void DumpUserObject(LPTSTR pszObject, TCHAR c);
00075
00076 #endif // _CHECKSD_
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/llistimpl.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

llistimpl.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.h:  Definition and implementation of CLListImpl.  This is a
00013 //                 generic linked list class which emulates CList from MFC.
00014 //
00015
00016
00017 #ifndef __CLASS_CLLISTIMPL__
00018 #define __CLASS_CLLISTIMPL__
00019
00020 #if _MSC_VER > 1000
00021 #pragma once
00022 #endif // _MSC_VER > 1000
00023
00024 #include <CrtDbg.h>
00025 #include <Windows.h>
00026 #include <new.h>
00027
00028
00029 // Abstract iteration position
00030 struct  __POSITION { };
00031 typedef __POSITION*  POSITION;
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 //  CPlex stuff for allocating nodes
00035 //
00036
00037 //---------------------------------------------------------------------------
00038 struct CPlex     // warning variable length structure
00039 {
00040   CPlex* pNext;
00041 //#if (_AFX_PACKING >= 8)
00042   DWORD dwReserved[1];    // align on 8 byte boundary
00043 //#endif
00044
00045   // BYTE data[maxNum*elementSize];
00046
00047   void* data() { return this+1; }
00048
00049   static CPlex* PASCAL Create(CPlex*& head, UINT nMax, UINT cbElement);
00050       // like 'calloc' but no zero fill
00051       // may throw memory exceptions
00052
00053   void FreeDataChain();       // free this one and links
00054 };
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 //  Helpers
00059 //
00060
00061 BOOL IsValidAddress( const void*  lp, UINT nBytes, BOOL bReadWrite = TRUE );
00062
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // CLListImpl<TYPE, ARG_TYPE>
00066
00067 template<class TYPE, class ARG_TYPE>
00068 class CLListImpl
00069 {
00070   public:
00071     CLListImpl( int nBlockSize = 10 );
00072     ~CLListImpl();
00073
00074   protected:
00075     struct CNode
00076     {
00077       CNode* pNext;
00078       CNode* pPrev;
00079       TYPE   data;
00080     };
00081
00082   public:
00083                                          // Attributes (head and tail)
00084    int       GetCount() const;
00085    BOOL      IsEmpty() const;
00086
00087    TYPE&     GetHead();                  // Peek at head and tail
00088    TYPE      GetHead() const;
00089    TYPE&     GetTail();
00090    TYPE      GetTail() const;
00091                                          // Operations
00092    TYPE      RemoveHead();
00093    TYPE      RemoveTail();
00094                                          // Add before head or after tail
00095    POSITION  AddHead( ARG_TYPE NewElement );
00096    POSITION  AddTail( ARG_TYPE NewElement );
00097
00098    void      AddHead(CLListImpl* pNewList);  // Add another list
00099    void      AddTail(CLListImpl* pNewList);
00100
00101    void      RemoveAll();                // Remove all elements
00102
00103    POSITION  GetHeadPosition() const;
00104    POSITION  GetTailPosition() const;
00105    TYPE&     GetNext(POSITION& rPosition);       // return *Position++
00106    TYPE      GetNext(POSITION& rPosition) const; // return *Position++
00107    TYPE&     GetPrev(POSITION& rPosition);       // return *Position--
00108    TYPE      GetPrev(POSITION& rPosition) const; // return *Position--
00109
00110    // Getting/modifying an element at a given position
00111    TYPE&     GetAt(POSITION Position);
00112    TYPE      GetAt(POSITION Position) const;
00113    void      SetAt(POSITION Pos, ARG_TYPE NewElement);
00114    void      RemoveAt(POSITION Position);
00115
00116    // inserting before or after a given position
00117    POSITION InsertBefore(POSITION position, ARG_TYPE newElement);
00118    POSITION InsertAfter(POSITION position, ARG_TYPE newElement);
00119
00120    // Helper functions (note: O(n) speed)
00121
00122    // Defaults to starting at the HEAD, return NULL if not found
00123    POSITION Find(ARG_TYPE SearchValue, POSITION StartAfter = NULL) const;
00124
00125    // Get the 'nIndex'th element (may return NULL)
00126    POSITION FindIndex(int nIndex) const;
00127
00128   // Implementation
00129   protected:
00130     CNode*   m_pNodeHead;
00131     CNode*   m_pNodeTail;
00132     int      m_nCount;
00133     CNode*   m_pNodeFree;
00134     struct   CPlex* m_pBlocks;
00135     int m_nBlockSize;
00136
00137     CNode*   NewNode(CNode*, CNode*);
00138     void     FreeNode(CNode*);
00139
00140 #ifdef _DEBUG
00141
00142   void AssertValid() const;
00143
00144 #endif //_DEBUG
00145
00146 }; //end class CLListImpl
00147
00148 /////////////////////////////////////////////////////////////////////////////
00149 // CLListImpl<TYPE, ARG_TYPE> inline functions
00150
00151 template<class TYPE, class ARG_TYPE>
00152 inline int CLListImpl<TYPE, ARG_TYPE>::GetCount() const
00153   { return m_nCount; }
00154
00155 template<class TYPE, class ARG_TYPE>
00156 inline BOOL CLListImpl<TYPE, ARG_TYPE>::IsEmpty() const
00157   { return m_nCount == 0; }
00158
00159 template<class TYPE, class ARG_TYPE>
00160 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetHead()
00161   {
00162     _ASSERT( NULL != m_pNodeHead );
00163     return m_pNodeHead->data;
00164   }
00165
00166 template<class TYPE, class ARG_TYPE>
00167 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetHead() const
00168   {
00169     _ASSERT( NULL != m_pNodeHead );
00170     return m_pNodeHead->data;
00171   }
00172
00173 template<class TYPE, class ARG_TYPE>
00174 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetTail()
00175   {
00176     _ASSERT( NULL != m_pNodeTail );
00177     return m_pNodeTail->data;
00178   }
00179
00180 template<class TYPE, class ARG_TYPE>
00181 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetTail() const
00182   {
00183     _ASSERT( NULL != m_pNodeTail );
00184     return m_pNodeTail->data;
00185   }
00186
00187 template<class TYPE, class ARG_TYPE>
00188 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetHeadPosition() const
00189   { return (POSITION)m_pNodeHead; }
00190
00191 template<class TYPE, class ARG_TYPE>
00192 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetTailPosition() const
00193   { return (POSITION)m_pNodeTail; }
00194
00195 template<class TYPE, class ARG_TYPE>
00196 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) // return *Position++
00197   {
00198     CNode* pNode = (CNode*) rPosition;
00199     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00200     rPosition = (POSITION) pNode->pNext;
00201     return pNode->data;
00202   }
00203
00204 template<class TYPE, class ARG_TYPE>
00205 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) const // return *Position++
00206   {
00207     CNode* pNode = (CNode*) rPosition;
00208     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00209     rPosition = (POSITION) pNode->pNext;
00210     return pNode->data;
00211   }
00212
00213 template<class TYPE, class ARG_TYPE>
00214 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) // return *Position--
00215   {
00216     CNode* pNode = (CNode*) rPosition;
00217     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00218     rPosition = (POSITION) pNode->pPrev;
00219     return pNode->data;
00220   }
00221
00222 template<class TYPE, class ARG_TYPE>
00223 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) const // return *Position--
00224   {
00225     CNode* pNode = (CNode*) rPosition;
00226     ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00227     rPosition = (POSITION) pNode->pPrev;
00228     return pNode->data;
00229   }
00230
00231 template<class TYPE, class ARG_TYPE>
00232 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position)
00233   {
00234     CNode* pNode = (CNode*)Position;
00235     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00236     return pNode->data;
00237   }
00238
00239 template<class TYPE, class ARG_TYPE>
00240 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position) const
00241   {
00242     CNode* pNode = (CNode*) Position;
00243     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00244     return pNode->data;
00245   }
00246
00247 template<class TYPE, class ARG_TYPE>
00248 inline void CLListImpl<TYPE, ARG_TYPE>::SetAt(POSITION Pos, ARG_TYPE NewElement)
00249   {
00250     CNode* pNode = (CNode*)Pos;
00251     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00252     pNode->data = newElement;
00253   }
00254
00255
00256 template<class TYPE, class ARG_TYPE>
00257 CLListImpl<TYPE, ARG_TYPE>::CLListImpl( int nBlockSize )
00258 {
00259   _ASSERT( nBlockSize > 0 );
00260
00261   m_nCount     = 0;
00262   m_pNodeHead  = m_pNodeTail = m_pNodeFree = NULL;
00263   m_pBlocks    = NULL;
00264   m_nBlockSize = nBlockSize;
00265 }
00266
00267 template<class TYPE, class ARG_TYPE>
00268 void CLListImpl<TYPE, ARG_TYPE>::RemoveAll()
00269 {
00270   // destroy elements
00271   CNode* pNode;
00272   for( pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext )
00273     (pNode->data).~TYPE();
00274
00275   m_nCount = 0;
00276   m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL;
00277   m_pBlocks->FreeDataChain();
00278   m_pBlocks = NULL;
00279 }
00280
00281 template<class TYPE, class ARG_TYPE>
00282 CLListImpl<TYPE, ARG_TYPE>::~CLListImpl()
00283 {
00284   RemoveAll();
00285   _ASSERT(m_nCount == 0);
00286 }
00287
00288
00289 /////////////////////////////////////////////////////////////////////////////
00290 // Node helpers
00291 //
00292 //  Implementation note: CNode's are stored in CPlex blocks and
00293 //  chained together. Free blocks are maintained in a singly linked list
00294 //  using the 'pNext' member of CNode with 'm_pNodeFree' as the head.
00295 //  Used blocks are maintained in a doubly linked list using both 'pNext'
00296 //  and 'pPrev' as links and 'm_pNodeHead' and 'm_pNodeTail'
00297 //  as the head/tail.
00298 //
00299 //  We never free a CPlex block unless the List is destroyed or RemoveAll()
00300 //  is used - so the total number of CPlex blocks may grow large depending
00301 //  on the maximum past size of the list.
00302 //
00303
00304
00305 template<class TYPE, class ARG_TYPE>
00306 CLListImpl<TYPE, ARG_TYPE>::CNode*
00307 CLListImpl<TYPE, ARG_TYPE>::NewNode(CLListImpl::CNode* pPrev, CLListImpl::CNode* pNext)
00308 {
00309   if( NULL == m_pNodeFree )
00310   {
00311     // add another block
00312     CPlex* pNewBlock = CPlex::Create( m_pBlocks, m_nBlockSize, sizeof(CNode) );
00313
00314     // chain them into free list
00315     CNode* pNode = (CNode*) pNewBlock->data();
00316     // free in reverse order to make it easier to debug
00317     pNode += m_nBlockSize - 1;
00318     for( int i = m_nBlockSize-1; i >= 0; i--, pNode-- )
00319     {
00320       pNode->pNext = m_pNodeFree;
00321       m_pNodeFree = pNode;
00322     }
00323   }
00324   _ASSERT( NULL != m_pNodeFree );  // we must have something
00325
00326   CLListImpl::CNode* pNode = m_pNodeFree;
00327   m_pNodeFree = m_pNodeFree->pNext;
00328   pNode->pPrev = pPrev;
00329   pNode->pNext = pNext;
00330   m_nCount++;
00331   _ASSERT(m_nCount > 0);  // make sure we don't overflow
00332
00333   new (&pNode->data) TYPE; // Placement new
00334
00335   return pNode;
00336 }
00337
00338
00339 template<class TYPE, class ARG_TYPE>
00340 void CLListImpl<TYPE, ARG_TYPE>::FreeNode(CLListImpl::CNode* pNode)
00341 {
00342   (pNode->data).~TYPE();
00343   pNode->pNext = m_pNodeFree;
00344   m_pNodeFree = pNode;
00345   m_nCount--;
00346   _ASSERT(m_nCount >= 0);  // make sure we don't underflow
00347
00348   // if no more elements, cleanup completely
00349   if( 0 == m_nCount )
00350     RemoveAll();
00351 }
00352
00353 template<class TYPE, class ARG_TYPE>
00354 POSITION CLListImpl<TYPE, ARG_TYPE>::AddHead( ARG_TYPE NewElement )
00355 {
00356   _ASSERT( NULL != NewElement );
00357
00358   CNode* pNewNode = NewNode( NULL, m_pNodeHead );
00359   pNewNode->data = NewElement;
00360   if( NULL != m_pNodeHead )
00361     m_pNodeHead->pPrev = pNewNode;
00362   else
00363     m_pNodeTail = pNewNode;
00364
00365   m_pNodeHead = pNewNode;
00366   return (POSITION)pNewNode;
00367 }
00368
00369
00370 template<class TYPE, class ARG_TYPE>
00371 POSITION CLListImpl<TYPE, ARG_TYPE>::AddTail(ARG_TYPE NewElement)
00372 {
00373   _ASSERT( NULL != NewElement );
00374
00375   CNode* pNewNode = NewNode( m_pNodeTail, NULL );
00376   pNewNode->data = NewElement;
00377   if( NULL != m_pNodeTail )
00378     m_pNodeTail->pNext = pNewNode;
00379   else
00380     m_pNodeHead = pNewNode;
00381
00382   m_pNodeTail = pNewNode;
00383   return (POSITION)pNewNode;
00384 }
00385
00386
00387 template<class TYPE, class ARG_TYPE>
00388 void CLListImpl<TYPE, ARG_TYPE>::AddHead( CLListImpl* pNewList )
00389 {
00390   _ASSERT( NULL != pNewList );
00391
00392   // Add a list of same elements to head (maintain order)
00393   POSITION Pos = pNewList->GetTailPosition();
00394   while( NULL != Pos )
00395     AddHead(pNewList->GetPrev( Pos ));
00396 }
00397
00398
00399 template<class TYPE, class ARG_TYPE>
00400 void CLListImpl<TYPE, ARG_TYPE>::AddTail(CLListImpl* pNewList)
00401 {
00402   _ASSERT( NULL != pNewList );
00403
00404   // Add a list of same elements
00405   POSITION Pos = pNewList->GetHeadPosition();
00406   while( NULL != Pos )
00407     AddTail(pNewList->GetNext( Pos ));
00408 }
00409
00410
00411 template<class TYPE, class ARG_TYPE>
00412 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveHead()
00413 {
00414   _ASSERT( NULL != m_pNodeHead );  // don't call on empty list !!!
00415   _ASSERT( IsValidAddress( m_pNodeHead, sizeof(CNode)) );
00416
00417   CNode* pOldNode = m_pNodeHead;
00418   TYPE returnValue = pOldNode->data;
00419
00420   m_pNodeHead = pOldNode->pNext;
00421   if( NULL != m_pNodeHead )
00422     m_pNodeHead->pPrev = NULL;
00423   else
00424     m_pNodeTail = NULL;
00425
00426   FreeNode(pOldNode);
00427   return returnValue;
00428 }
00429
00430
00431 template<class TYPE, class ARG_TYPE>
00432 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveTail()
00433 {
00434   _ASSERT( NULL != m_pNodeTail );  // don't call on empty list !!!
00435   _ASSERT( IsValidAddress( m_pNodeTail, sizeof(CNode)) );
00436
00437   CNode* pOldNode = m_pNodeTail;
00438   TYPE returnValue = pOldNode->data;
00439
00440   m_pNodeTail = pOldNode->pPrev;
00441   if( NULL != m_pNodeTail )
00442     m_pNodeTail->pNext = NULL;
00443   else
00444     m_pNodeHead = NULL;
00445
00446   FreeNode(pOldNode);
00447   return returnValue;
00448 }
00449
00450
00451 template<class TYPE, class ARG_TYPE>
00452 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertBefore(POSITION Position, ARG_TYPE NewElement)
00453 {
00454   _ASSERT( NULL != NewElement );
00455
00456   if( NULL == Position )
00457     return AddHead( NewElement ); // insert before nothing -> head of the list
00458
00459   // Insert it before position
00460   CNode* pOldNode = (CNode*)Position;
00461   CNode* pNewNode = NewNode( pOldNode->pPrev, pOldNode );
00462   pNewNode->data  = NewElement;
00463
00464   if( NULL != pOldNode->pPrev )
00465   {
00466     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00467     pOldNode->pPrev->pNext = pNewNode;
00468   }
00469   else
00470   {
00471     _ASSERT( pOldNode == m_pNodeHead );
00472     m_pNodeHead = pNewNode;
00473   }
00474   pOldNode->pPrev = pNewNode;
00475   return (POSITION)pNewNode;
00476 }
00477
00478
00479 template<class TYPE, class ARG_TYPE>
00480 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertAfter(POSITION Position, ARG_TYPE NewElement)
00481 {
00482   ASSERT( NULL != NewElement );
00483
00484   if( NULL == Position )
00485     return AddTail( NewElement ); // insert after nothing -> tail of the list
00486
00487   // Insert it before position
00488   CNode* pOldNode = (CNode*)Position;
00489   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode) ) );
00490   CNode* pNewNode = NewNode( pOldNode, pOldNode->pNext );
00491   pNewNode->data = NewElement;
00492
00493   if( NULL != pOldNode->pNext )
00494   {
00495     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00496     pOldNode->pNext->pPrev = pNewNode;
00497   }
00498   else
00499   {
00500     _ASSERT( pOldNode == m_pNodeTail );
00501     m_pNodeTail = pNewNode;
00502   }
00503   pOldNode->pNext = pNewNode;
00504   return (POSITION)pNewNode;
00505 }
00506
00507
00508 template<class TYPE, class ARG_TYPE>
00509 void CLListImpl<TYPE, ARG_TYPE>::RemoveAt( POSITION Position )
00510 {
00511   _ASSERT( NULL != Position );
00512
00513   CNode* pOldNode = (CNode*)Position;
00514   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode)) );
00515
00516   // Remove pOldNode from list
00517   if( pOldNode == m_pNodeHead )
00518   {
00519     m_pNodeHead = pOldNode->pNext;
00520   }
00521   else
00522   {
00523     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00524     pOldNode->pPrev->pNext = pOldNode->pNext;
00525   }
00526   if( pOldNode == m_pNodeTail )
00527   {
00528     m_pNodeTail = pOldNode->pPrev;
00529   }
00530   else
00531   {
00532     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00533     pOldNode->pNext->pPrev = pOldNode->pPrev;
00534   }
00535   FreeNode( pOldNode );
00536 }
00537
00538
00539 template<class TYPE, class ARG_TYPE>
00540 POSITION CLListImpl<TYPE, ARG_TYPE>::FindIndex(int nIndex) const
00541 {
00542   if( nIndex >= m_nCount || nIndex < 0 )
00543     return NULL;  // went too far
00544
00545   CNode* pNode = m_pNodeHead;
00546   while (nIndex--)
00547   {
00548     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00549     pNode = pNode->pNext;
00550   }
00551   return (POSITION)pNode;
00552 }
00553
00554
00555 template<class TYPE, class ARG_TYPE>
00556 POSITION CLListImpl<TYPE, ARG_TYPE>::Find(ARG_TYPE SearchValue, POSITION StartAfter) const
00557 {
00558   _ASSERT( NULL != SearchValue );
00559
00560   CNode* pNode = (CNode*)StartAfter;
00561   if( NULL == pNode )
00562   {
00563     pNode = m_pNodeHead;  // start at head
00564   }
00565   else
00566   {
00567     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00568     pNode = pNode->pNext;  // start after the one specified
00569   }
00570
00571   for (; pNode != NULL; pNode = pNode->pNext)
00572     if (CompareElements<TYPE>(&pNode->data, &searchValue))
00573       return (POSITION)pNode;
00574
00575   return NULL;
00576 }
00577
00578 #ifdef _DEBUG
00579
00580 template<class TYPE, class ARG_TYPE>
00581 void CLListImpl<TYPE, ARG_TYPE>::AssertValid() const
00582 {
00583   if( 0 == m_nCount )
00584   {
00585     // empty list
00586     _ASSERT( NULL == m_pNodeHead );
00587     _ASSERT( NULL == m_pNodeTail );
00588   }
00589   else
00590   {
00591     // non-empty list
00592     _ASSERT( IsValidAddress(m_pNodeHead, sizeof(CNode)) );
00593     _ASSERT( IsValidAddress(m_pNodeTail, sizeof(CNode)) );
00594   }
00595 }
00596 #endif //_DEBUG
00597
00598 #endif //__CLASS_CLLISTIMPL__
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/table.h Source File

  • Dataaccess
  • oledb
  • tablecopy

table.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1995-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module TABLE.H
00008 //
00009 //-----------------------------------------------------------------------------
00010 #ifndef _TABLE_H_
00011 #define _TABLE_H_
00012
00013
00014 /////////////////////////////////////////////////////////////////
00015 // Includes
00016 //
00017 /////////////////////////////////////////////////////////////////
00018 #include "DataSource.h"
00019 #include "TableCopy.h"
00020
00021
00022
00023 /////////////////////////////////////////////////////////////////
00024 // Defines
00025 //
00026 /////////////////////////////////////////////////////////////////
00027 enum ESQL_STMT
00028 {
00029   ESQL_SELECT,
00030   ESQL_INSERT,
00031   ESQL_CREATE_TABLE,
00032   ESQL_DROP_TABLE
00033 };
00034
00035
00036 /////////////////////////////////////////////////////////////////
00037 // Structs for Column/Index info
00038 //
00039 /////////////////////////////////////////////////////////////////
00040 struct TYPEINFO
00041 {
00042   WCHAR     wszTypeName[MAX_NAME_LEN];
00043   USHORT      wType;
00044   ULONG     ulColumnSize;
00045   WCHAR     wszCreateParams[MAX_NAME_LEN];
00046   VARIANT_BOOL  fIsNullable;
00047   VARIANT_BOOL  fIsAutoInc;
00048 };
00049
00050
00051 struct INDEXINFO
00052 {
00053   //INDEXINFO
00054   WCHAR     wszIndexName[MAX_NAME_LEN];
00055   VARIANT_BOOL  fUnique;
00056   VARIANT_BOOL  fClustered;
00057   DBTYPE      wType;
00058   DWORD     dwFillFactor;
00059   DWORD     dwInitialSize;
00060   DWORD     dwNulls;
00061   VARIANT_BOOL  fSortBookmarks;
00062   VARIANT_BOOL  fAutoUpdate;
00063     DWORD     dwNullCollation;
00064     DWORD     iOrdinal;
00065   WCHAR     wszColName[MAX_NAME_LEN];
00066   DWORD     dwCollation;
00067
00068   //PRIMARYKEY
00069   BOOL      fIsPrimaryKey;
00070 };
00071
00072
00073 struct PRIMARYKEY
00074 {
00075   WCHAR     wszColName[MAX_NAME_LEN];
00076 };
00077
00078
00079 struct TABLEINFO
00080 {
00081   WCHAR     wszCatalogName[MAX_NAME_LEN];
00082   WCHAR     wszSchemaName[MAX_NAME_LEN];
00083   WCHAR     wszTableName[MAX_NAME_LEN];
00084   WCHAR     wszType[MAX_NAME_LEN];
00085 };
00086
00087 struct COLDESC
00088 {
00089   //DBCOLUMNINFO
00090   WCHAR     wszColName[MAX_NAME_LEN];
00091   ULONG     iOrdinal;
00092   DBCOLUMNFLAGS dwFlags;
00093   ULONG     ulColumnSize;
00094   DBTYPE      wType;
00095   BYTE      bPrecision;
00096   BYTE      bScale;
00097
00098   //TYPEINFO
00099   WCHAR     wszTypeName[MAX_NAME_LEN];
00100   ULONG     ulCreateParams;
00101   BOOL      fIsNullable;
00102   BOOL      fIsAutoInc;
00103
00104   //INDEXINFO
00105   BOOL      fIsPrimaryKey;
00106 };
00107
00108
00109 struct BINDINGINFO
00110 {
00111   HACCESSOR hAccessor;
00112   ULONG   cBindings;
00113   DBBINDING*  rgBindings;
00114 };
00115
00116
00117
00118 /////////////////////////////////////////////////////////////////
00119 // CTable
00120 //
00121 /////////////////////////////////////////////////////////////////
00122 class CTable
00123 {
00124 public:
00125   //Constructors
00126   CTable(CWizard* pCWizard);
00127   virtual ~CTable();
00128
00129   //Members
00130   virtual BOOL  Connect(HWND hWnd, CDataSource* pCDataSource = NULL);
00131   virtual BOOL  IsConnected();
00132
00133   virtual BOOL  GetQuotedID(WCHAR* pwszOutBuff, WCHAR* pwszInBuff);
00134   virtual HRESULT GetColInfo(DWORD dwInsertOpt);
00135   virtual HRESULT GetTypeInfo();
00136   virtual HRESULT GetLiteralInfo();
00137   virtual HRESULT GetTypeNameAndParams(ULONG iCol, WCHAR* pwszName);
00138
00139   virtual HRESULT GetColumnDesc(DBCOLUMNDESC** prgColumnDesc);
00140   virtual HRESULT CreateSQLStmt(ESQL_STMT eSqlStmt, WCHAR* pwszSqlStmt, BOOL fShowSql = TRUE);
00141
00142   virtual HRESULT MapTableInfo(CTable* pCSourceTable);
00143   virtual HRESULT CreateTable();
00144
00145   virtual HRESULT AdjustBindings(ULONG cBindings, DBBINDING* rgBindings, void* pData);
00146
00147   virtual HRESULT GetRowset(DWORD dwInsertOpt);
00148   virtual HRESULT CreateAccessors(ULONG* pcBindingInfo, BINDINGINFO** prgBindingInfo, ULONG* pcRowSize, ULONG ulBlobSize, BOOL* pbOutofLine);
00149
00150   virtual HRESULT CopyData(CTable* pCSourceTable, ULONG* pcRowsCopied);
00151   virtual HRESULT CopyIndexes(CTable* pCSourceTable);
00152
00153   virtual HRESULT GetTypeInfoRowset(IAccessor** ppIAccessor, HACCESSOR* phAccessor, IRowset** ppIRowset);
00154
00155   //Data
00156   WCHAR     m_wszIDQuote[MAX_NAME_LEN];
00157   WCHAR     m_wszIDSeperator[MAX_NAME_LEN];
00158
00159   //TableInfo
00160   TABLEINFO m_TableInfo;
00161   WCHAR   m_wszQualTableName[MAX_NAME_LEN];
00162
00163   //Index info
00164   ULONG   m_cIndexes;     // Count of indexes
00165   INDEXINFO*  m_rgIndexInfo;    // Index information
00166
00167   //ColumnInfo
00168   ULONG   m_cColumns;     // Count of columns
00169   COLDESC*  m_rgColDesc;    // Column Information
00170
00171   //DataSource
00172   CDataSource*  m_pCDataSource;
00173   CWizard*    m_pCWizard;
00174
00175   //Rowset
00176   IAccessor*    m_pIAccessor;
00177   IRowset*    m_pIRowset;
00178 };
00179
00180
00181
00182 ///////////////////////////////////////////////////////////////////////////////
00183 // Class CISeqStream
00184 //
00185 // My implementation of ISeqStream interface
00186 ///////////////////////////////////////////////////////////////////////////////
00187 class CISeqStream : public ISequentialStream
00188 {
00189 public:
00190   //Constructors
00191   CISeqStream();
00192   virtual ~CISeqStream();
00193
00194   virtual BOOL Seek(ULONG iPos);
00195   virtual BOOL Clear();
00196   virtual BOOL CompareData(void* pBuffer);
00197   virtual ULONG Length()  { return m_cBufSize; };
00198
00199   virtual operator void* const() { return m_pBuffer; };
00200
00201   STDMETHODIMP_(ULONG)  AddRef(void);
00202   STDMETHODIMP_(ULONG)  Release(void);
00203   STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00204
00205     STDMETHODIMP Read(
00206             /* [out] */ void __RPC_FAR *pv,
00207             /* [in] */ ULONG cb,
00208             /* [out] */ ULONG __RPC_FAR *pcbRead);
00209
00210     STDMETHODIMP Write(
00211             /* [in] */ const void __RPC_FAR *pv,
00212             /* [in] */ ULONG cb,
00213             /* [out] */ ULONG __RPC_FAR *pcbWritten);
00214
00215   virtual HRESULT Write(ISequentialStream* pISeqStream, ULONG* pcbWritten);
00216
00217 protected:
00218   //Data
00219
00220 private:
00221
00222   ULONG   m_cRef;     // reference count
00223
00224   void*       m_pBuffer;    // buffer
00225   ULONG       m_cBufSize;     // buffer size
00226   ULONG       m_iPos;         // current index position in the buffer
00227 };
00228
00229
00230
00231 #endif  //_TABLE_H_
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsError/IADsError.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsError

IADsError.h

Go to the documentation of this file.
00001 // IADsError.h: Definition of the ADsError class
00002 //
00003 //////////////////////////////////////////////////////////////////////
00004
00005 #if !defined(AFX_IADSERROR_H__417D01E1_F1C6_11D2_BC88_00C04FD430AF__INCLUDED_)
00006 #define AFX_IADSERROR_H__417D01E1_F1C6_11D2_BC88_00C04FD430AF__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #include "resource.h"       // main symbols
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // ADsError
00016
00017 class ADsError :
00018   public IDispatchImpl<IADsError, &IID_IADsError, &LIBID_ADSERRORLib>,
00019   public ISupportErrorInfo,
00020   public CComObjectRoot,
00021   public CComCoClass<ADsError,&CLSID_ADsError>
00022 {
00023 public:
00024   ADsError() {}
00025 BEGIN_COM_MAP(ADsError)
00026   COM_INTERFACE_ENTRY(IDispatch)
00027   COM_INTERFACE_ENTRY(IADsError)
00028   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00029 END_COM_MAP()
00030 //DECLARE_NOT_AGGREGATABLE(ADsError)
00031 // Remove the comment from the line above if you don't want your object to
00032 // support aggregation.
00033
00034 DECLARE_REGISTRY_RESOURCEID(IDR_ADsError)
00035 // ISupportsErrorInfo
00036   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00037
00038 // IADsError
00039 public:
00040   STDMETHOD(GetErrorMessage)(/*[in]*/ long hResult, /*[out,retval]*/ BSTR *pbMsg);
00041 };
00042
00043 #endif // !defined(AFX_IADSERROR_H__417D01E1_F1C6_11D2_BC88_00C04FD430AF__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Static_Statistic Member List

This is the complete list of members for Static_Statistic, including all inherited members.
bTaken | Static_Statistic
IpAddress | Static_Statistic
wszPortName | Static_Statistic
wszUserName | Static_Statistic
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/iocp/IocpServerex.Cpp Source File

  • NetDS
  • WinSock
  • iocp

IocpServerex.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      iocpserverex.cpp
00010 //
00011 // Abstract:
00012 //      This program is a Winsock echo server program that demonstrates the usage
00013 //      of AcceptEx with IOCP. The AcceptEx function accepts a new connection,
00014 //      returns the local and remote address, and receives the first block of data
00015 //      sent by the client application. The design of this program is based on that
00016 //      in the iocpserver.cpp. But it uses overlapped AcceptEx on the IOCP also.
00017 //      AcceptEx allows data to be "returned" from an accepted connection.
00018 //
00019 //      Another point worth noting is that the Win32 API CreateThread() does not
00020 //      initialize the C Runtime and therefore, C runtime functions such as
00021 //      printf() have been avoid or rewritten (see myprintf()) to use just Win32 APIs.
00022 //
00023 //
00024 //  Usage:
00025 //      Start the server and wait for connections on port 6001
00026 //          iocpserverex -e:6001
00027 //
00028 //  Build:
00029 //      Use the headers and libs from the April98 Platform SDK or later.
00030 //      Link with ws2_32.lib and mswsock.lib
00031 //
00032 //  Author: Wei Hua, Barry Butterklee - Microsoft Developer Support
00033 //
00034 //
00035
00036 #ifdef _IA64_
00037   #pragma warning(disable:4127 4267)
00038 #endif
00039
00040 #ifndef WIN32_LEAN_AND_MEAN
00041   #define WIN32_LEAN_AND_MEAN
00042 #endif
00043
00044 #define xmalloc(s) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(s))
00045 #define xfree(p)   HeapFree(GetProcessHeap(),0,(p))
00046
00047 #include <winsock2.h>
00048 #include <mswsock.h>
00049 #include <Ws2tcpip.h>
00050 #include <stdio.h>
00051 #include <stdlib.h>
00052
00053 #include "iocpserver.h"
00054
00055 char *g_Port = DEFAULT_PORT;
00056 BOOL g_bEndServer = FALSE;      // set to TRUE on CTRL-C
00057 BOOL g_bRestart = TRUE;       // set to TRUE to CTRL-BRK
00058 BOOL g_bVerbose = FALSE;
00059 HANDLE g_hIOCP = INVALID_HANDLE_VALUE;
00060 SOCKET g_sdListen = INVALID_SOCKET;
00061 HANDLE g_ThreadHandles[MAX_WORKER_THREAD];
00062 WSAEVENT g_hCleanupEvent[1];
00063 PPER_SOCKET_CONTEXT g_pCtxtListenSocket = NULL;
00064 PPER_SOCKET_CONTEXT g_pCtxtList = NULL;   // linked list of context info structures
00065                       // maintained to allow the the cleanup
00066                       // handler to cleanly close all sockets and
00067                       // free resources.
00068
00069 CRITICAL_SECTION g_CriticalSection;   // guard access to the global context list
00070
00071 int myprintf(const char *lpFormat, ...);
00072
00073 void __cdecl main (int argc, char *argv[])  {
00074
00075     SYSTEM_INFO systemInfo;
00076   WSADATA wsaData;
00077   DWORD dwThreadCount = 0;
00078   int nRet = 0;
00079
00080     g_ThreadHandles[0] = (HANDLE)WSA_INVALID_EVENT;
00081
00082   for( int i = 0; i < MAX_WORKER_THREAD; i++ ) {
00083     g_ThreadHandles[i] = INVALID_HANDLE_VALUE;
00084   }
00085
00086   if( !ValidOptions(argc, argv) )
00087     return;
00088
00089   if( !SetConsoleCtrlHandler(CtrlHandler, TRUE) ) {
00090     myprintf("SetConsoleCtrlHandler() failed to install console handler: %d\n",
00091         GetLastError());
00092     return;
00093   }
00094
00095   GetSystemInfo(&systemInfo);
00096   dwThreadCount = systemInfo.dwNumberOfProcessors * 2;
00097
00098   g_hCleanupEvent[0] = WSACreateEvent();
00099   if( g_hCleanupEvent[0] == WSA_INVALID_EVENT ) {
00100     myprintf("WSACreateEvent() failed: %d\n", WSAGetLastError());
00101     return;
00102   }
00103
00104   if( (nRet = WSAStartup(0x202, &wsaData)) != 0 ) {
00105     myprintf("WSAStartup() failed: %d\n",nRet);
00106     SetConsoleCtrlHandler(CtrlHandler, FALSE);
00107     if(g_hCleanupEvent[0] != WSA_INVALID_EVENT) {
00108       WSACloseEvent(g_hCleanupEvent[0]);
00109       g_hCleanupEvent[0] = WSA_INVALID_EVENT;
00110     }
00111     return;
00112   }
00113
00114   InitializeCriticalSection(&g_CriticalSection);
00115
00116   while( g_bRestart ) {
00117     g_bRestart = FALSE;
00118     g_bEndServer = FALSE;
00119     WSAResetEvent(g_hCleanupEvent[0]);
00120
00121     __try {
00122
00123             //
00124       // notice that we will create more worker threads (dwThreadCount) than
00125       // the thread concurrency limit on the IOCP.
00126       //
00127       g_hIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
00128             if( g_hIOCP == NULL ) {
00129         myprintf("CreateIoCompletionPort() failed to create I/O completion port: %d\n",
00130             GetLastError());
00131         __leave;
00132       }
00133
00134       for( DWORD dwCPU=0; dwCPU<dwThreadCount; dwCPU++ ) {
00135
00136         //
00137         // Create worker threads to service the overlapped I/O requests.  The decision
00138         // to create 2 worker threads per CPU in the system is a heuristic.  Also,
00139         // note that thread handles are closed right away, because we will not need them
00140         // and the worker threads will continue to execute.
00141         //
00142         HANDLE  hThread;
00143         DWORD   dwThreadId;
00144
00145         hThread = CreateThread(NULL, 0, WorkerThread, g_hIOCP, 0, &dwThreadId);
00146         if( hThread == NULL ) {
00147           myprintf("CreateThread() failed to create worker thread: %d\n",
00148                GetLastError());
00149           __leave;
00150         }
00151         g_ThreadHandles[dwCPU] = hThread;
00152         hThread = INVALID_HANDLE_VALUE;
00153       }
00154
00155       if( !CreateListenSocket() )
00156         __leave;
00157
00158       if( !CreateAcceptSocket(TRUE) )
00159         __leave;
00160
00161       WSAWaitForMultipleEvents(1, g_hCleanupEvent, TRUE, WSA_INFINITE, FALSE);
00162     }
00163
00164     __finally {
00165
00166       g_bEndServer = TRUE;
00167
00168       //
00169       // Cause worker threads to exit
00170       //
00171       if( g_hIOCP ) {
00172         for( DWORD i = 0; i < dwThreadCount; i++ )
00173           PostQueuedCompletionStatus(g_hIOCP, 0, 0, NULL);
00174       }
00175
00176             //
00177       // Make sure worker threads exits.
00178       //
00179       if( WAIT_OBJECT_0 != WaitForMultipleObjects(dwThreadCount,  g_ThreadHandles, TRUE, 1000) )
00180         myprintf("WaitForMultipleObjects() failed: %d\n", GetLastError());
00181       else
00182         for( DWORD i=0; i<dwThreadCount; i++ ) {
00183           if( g_ThreadHandles[i] != INVALID_HANDLE_VALUE )
00184             CloseHandle(g_ThreadHandles[i]);
00185           g_ThreadHandles[i] = INVALID_HANDLE_VALUE;
00186         }
00187
00188       if( g_sdListen != INVALID_SOCKET ) {
00189         closesocket(g_sdListen);
00190         g_sdListen = INVALID_SOCKET;
00191       }
00192
00193       if( g_pCtxtListenSocket ) {
00194         while( !HasOverlappedIoCompleted((LPOVERLAPPED)&g_pCtxtListenSocket->pIOContext->Overlapped) )
00195           Sleep(0);
00196
00197         if( g_pCtxtListenSocket->pIOContext->SocketAccept != INVALID_SOCKET )
00198           closesocket(g_pCtxtListenSocket->pIOContext->SocketAccept);
00199         g_pCtxtListenSocket->pIOContext->SocketAccept = INVALID_SOCKET;
00200
00201                 //
00202         // We know there is only one overlapped I/O on the listening socket
00203         //
00204         if( g_pCtxtListenSocket->pIOContext )
00205           xfree(g_pCtxtListenSocket->pIOContext);
00206
00207         if( g_pCtxtListenSocket )
00208           xfree(g_pCtxtListenSocket);
00209         g_pCtxtListenSocket = NULL;
00210       }
00211
00212       CtxtListFree();
00213
00214       if( g_hIOCP ) {
00215         CloseHandle(g_hIOCP);
00216         g_hIOCP = NULL;
00217       }
00218     } //finally
00219
00220     if( g_bRestart ) {
00221       myprintf("\niocpserverex is restarting...\n");
00222     } else
00223       myprintf("\niocpserverex is exiting...\n");
00224
00225   } //while (g_bRestart)
00226
00227   DeleteCriticalSection(&g_CriticalSection);
00228   if(g_hCleanupEvent[0] != WSA_INVALID_EVENT) {
00229     WSACloseEvent(g_hCleanupEvent[0]);
00230     g_hCleanupEvent[0] = WSA_INVALID_EVENT;
00231   }
00232   WSACleanup();
00233   SetConsoleCtrlHandler(CtrlHandler, FALSE);
00234 } //main
00235
00236 //
00237 //  Just validate the command line options.
00238 //
00239 BOOL ValidOptions(int argc, char *argv[]) {
00240   BOOL bRet = TRUE;
00241
00242   for( int i=1; i<argc; i++ ) {
00243     if( (argv[i][0] =='-') || (argv[i][0] == '/') ) {
00244       switch( tolower(argv[i][1]) ) {
00245       case 'e':
00246         if( strlen(argv[i]) > 3 )
00247           g_Port = &argv[i][3];
00248         break;
00249
00250       case 'v':
00251         g_bVerbose = TRUE;
00252         break;
00253
00254       case '?':
00255         myprintf("Usage:\n  iocpserver [-p:port] [-v] [-?]\n");
00256         myprintf("  -e:port\tSpecify echoing port number\n");
00257         myprintf("  -v\t\tVerbose\n");
00258         myprintf("  -?\t\tDisplay this help\n");
00259         bRet = FALSE;
00260         break;
00261
00262       default:
00263         myprintf("Unknown options flag %s\n", argv[i]);
00264         bRet = FALSE;
00265         break;
00266       }
00267     }
00268   }
00269
00270   return(bRet);
00271 }
00272
00273 //
00274 //  Intercept CTRL-C or CTRL-BRK events and cause the server to initiate shutdown.
00275 //  CTRL-BRK resets the restart flag, and after cleanup the server restarts.
00276 //
00277 BOOL WINAPI CtrlHandler (DWORD dwEvent) {
00278
00279   switch( dwEvent ) {
00280   case CTRL_BREAK_EVENT:
00281     g_bRestart = TRUE;
00282   case CTRL_C_EVENT:
00283   case CTRL_LOGOFF_EVENT:
00284   case CTRL_SHUTDOWN_EVENT:
00285   case CTRL_CLOSE_EVENT:
00286     if( g_bVerbose )
00287       myprintf("CtrlHandler: closing listening socket\n");
00288
00289     g_bEndServer = TRUE;
00290
00291     WSASetEvent(g_hCleanupEvent[0]);
00292     break;
00293
00294   default:
00295     //
00296     // unknown type--better pass it on.
00297     //
00298
00299     return(FALSE);
00300   }
00301   return(TRUE);
00302 }
00303
00304 //
00305 // Create a socket with all the socket options we need, namely disable buffering
00306 // and set linger.
00307 //
00308 SOCKET CreateSocket(void) {
00309   int nRet = 0;
00310   int nZero = 0;
00311   SOCKET sdSocket = INVALID_SOCKET;
00312
00313   sdSocket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_IP, NULL, 0, WSA_FLAG_OVERLAPPED);
00314   if( sdSocket == INVALID_SOCKET ) {
00315     myprintf("WSASocket(sdSocket) failed: %d\n", WSAGetLastError());
00316     return(sdSocket);
00317   }
00318
00319     //
00320   // Disable send buffering on the socket.  Setting SO_SNDBUF
00321   // to 0 causes winsock to stop buffering sends and perform
00322   // sends directly from our buffers, thereby save one memory copy.
00323   //
00324     // However, this does prevent the socket from ever filling the
00325     // send pipeline. This can lead to packets being sent that are
00326     // not full (i.e. the overhead of the IP and TCP headers is
00327     // great compared to the amount of data being carried).
00328     //
00329     // Disabling the send buffer has less serious repercussions
00330     // than disabling the receive buffer.
00331   //
00332   nZero = 0;
00333   nRet = setsockopt(sdSocket, SOL_SOCKET, SO_SNDBUF, (char *)&nZero, sizeof(nZero));
00334   if( nRet == SOCKET_ERROR) {
00335     myprintf("setsockopt(SNDBUF) failed: %d\n", WSAGetLastError());
00336     return(sdSocket);
00337   }
00338
00339     //
00340     // Don't disable receive buffering. This will cause poor network
00341     // performance since if no receive is posted and no receive buffers,
00342     // the TCP stack will set the window size to zero and the peer will
00343     // no longer be allowed to send data.
00344     //
00345
00346     //
00347     // Do not set a linger value...especially don't set it to an abortive
00348     // close. If you set abortive close and there happens to be a bit of
00349     // data remaining to be transfered (or data that has not been
00350     // acknowledged by the peer), the connection will be forcefully reset
00351     // and will lead to a loss of data (i.e. the peer won't get the last
00352     // bit of data). This is BAD. If you are worried about malicious
00353     // clients connecting and then not sending or receiving, the server
00354     // should maintain a timer on each connection. If after some point,
00355     // the server deems a connection is "stale" it can then set linger
00356     // to be abortive and close the connection.
00357     //
00358
00359     /*
00360   LINGER lingerStruct;
00361
00362   lingerStruct.l_onoff = 1;
00363   lingerStruct.l_linger = 0;
00364   nRet = setsockopt(sdSocket, SOL_SOCKET, SO_LINGER,
00365             (char *)&lingerStruct, sizeof(lingerStruct));
00366   if( nRet == SOCKET_ERROR ) {
00367     myprintf("setsockopt(SO_LINGER) failed: %d\n", WSAGetLastError());
00368     return(sdSocket);
00369   }
00370     */
00371
00372   return(sdSocket);
00373 }
00374
00375 //
00376 //  Create a listening socket, bind, and set up its listening backlog.
00377 //
00378 BOOL CreateListenSocket(void) {
00379
00380   int nRet = 0;
00381   LINGER lingerStruct;
00382   struct addrinfo hints;
00383   struct addrinfo *addrlocal = NULL;
00384
00385   lingerStruct.l_onoff = 1;
00386   lingerStruct.l_linger = 0;
00387
00388   //
00389   // Resolve the interface
00390   //
00391   memset(&hints, 0, sizeof(hints));
00392   hints.ai_flags  = AI_PASSIVE;
00393   hints.ai_family = AF_INET;
00394   hints.ai_socktype = SOCK_STREAM;
00395   hints.ai_protocol = IPPROTO_IP;
00396
00397   if( getaddrinfo(NULL, g_Port, &hints, &addrlocal) != 0 ) {
00398     myprintf("getaddrinfo() failed with error %d\n", WSAGetLastError());
00399         return(FALSE);
00400   }
00401
00402   if( addrlocal == NULL ) {
00403     myprintf("getaddrinfo() failed to resolve/convert the interface\n");
00404         return(FALSE);
00405   }
00406
00407   g_sdListen = CreateSocket();
00408   if( g_sdListen == INVALID_SOCKET) {
00409     freeaddrinfo(addrlocal);
00410     return(FALSE);
00411   }
00412
00413     nRet = bind(g_sdListen, addrlocal->ai_addr, addrlocal->ai_addrlen);
00414   if( nRet == SOCKET_ERROR) {
00415     myprintf("bind() failed: %d\n", WSAGetLastError());
00416     freeaddrinfo(addrlocal);
00417     return(FALSE);
00418   }
00419
00420   nRet = listen(g_sdListen, 5);
00421   if( nRet == SOCKET_ERROR ) {
00422     myprintf("listen() failed: %d\n", WSAGetLastError());
00423     freeaddrinfo(addrlocal);
00424     return(FALSE);
00425   }
00426
00427   freeaddrinfo(addrlocal);
00428
00429   return(TRUE);
00430 }
00431
00432 //
00433 // Create a socket and invoke AcceptEx.  Only the original call to to this
00434 // function needs to be added to the IOCP.
00435 //
00436 // If the expected behaviour of connecting client applications is to NOT
00437 // send data right away, then only posting one AcceptEx can cause connection
00438 // attempts to be refused if a client connects without sending some initial
00439 // data (notice that the associated iocpclient does not operate this way
00440 // but instead makes a connection and starts sending data write away).
00441 // This is because the IOCP packet does not get delivered without the initial
00442 // data (as implemented in this sample) thus preventing the worker thread
00443 // from posting another AcceptEx and eventually the backlog value set in
00444 // listen() will be exceeded if clients continue to try to connect.
00445 //
00446 // One technique to address this situation is to simply cause AcceptEx
00447 // to return right away upon accepting a connection without returning any
00448 // data.  This can be done by setting dwReceiveDataLength=0 when calling AcceptEx.
00449 //
00450 // Another technique to address this situation is to post multiple calls
00451 // to AcceptEx.  Posting multiple calls to AcceptEx is similar in concept to
00452 // increasing the backlog value in listen(), though posting AcceptEx is
00453 // dynamic (i.e. during the course of running your application you can adjust
00454 // the number of AcceptEx calls you post).  It is important however to keep
00455 // your backlog value in listen() high in your server to ensure that the
00456 // stack can accept connections even if your application does not get enough
00457 // CPU cycles to repost another AcceptEx under stress conditions.
00458 //
00459 // This sample implements neither of these techniques and is therefore
00460 // susceptible to the behaviour described above.
00461 //
00462 BOOL CreateAcceptSocket(BOOL fUpdateIOCP) {
00463
00464   int nRet = 0;
00465   DWORD dwRecvNumBytes = 0;
00466   DWORD bytes = 0;
00467
00468   //
00469   // GUID to Microsoft specific extensions
00470   //
00471   GUID acceptex_guid = WSAID_ACCEPTEX;
00472
00473     //
00474   //The context for listening socket uses the SockAccept member to store the
00475   //socket for client connection.
00476   //
00477   if( fUpdateIOCP ) {
00478     g_pCtxtListenSocket = UpdateCompletionPort(g_sdListen, ClientIoAccept, FALSE);
00479     if( g_pCtxtListenSocket == NULL ) {
00480       myprintf("failed to update listen socket to IOCP\n");
00481       return(FALSE);
00482     }
00483
00484         // Load the AcceptEx extension function from the provider for this socket
00485         nRet = WSAIoctl(
00486             g_sdListen,
00487             SIO_GET_EXTENSION_FUNCTION_POINTER,
00488            &acceptex_guid,
00489             sizeof(acceptex_guid),
00490            &g_pCtxtListenSocket->fnAcceptEx,
00491             sizeof(g_pCtxtListenSocket->fnAcceptEx),
00492            &bytes,
00493             NULL,
00494             NULL
00495             );
00496         if (nRet == SOCKET_ERROR)
00497         {
00498             myprintf("failed to load AcceptEx: %d\n", WSAGetLastError());
00499             return (FALSE);
00500         }
00501   }
00502
00503   g_pCtxtListenSocket->pIOContext->SocketAccept = CreateSocket();
00504   if( g_pCtxtListenSocket->pIOContext->SocketAccept == INVALID_SOCKET) {
00505     myprintf("failed to create new accept socket\n");
00506     return(FALSE);
00507   }
00508
00509   //
00510   // pay close attention to these parameters and buffer lengths
00511   //
00512   nRet = g_pCtxtListenSocket->fnAcceptEx(g_sdListen, g_pCtxtListenSocket->pIOContext->SocketAccept,
00513                     (LPVOID)(g_pCtxtListenSocket->pIOContext->Buffer),
00514                     MAX_BUFF_SIZE - (2 * (sizeof(SOCKADDR_STORAGE) + 16)),
00515                     sizeof(SOCKADDR_STORAGE) + 16, sizeof(SOCKADDR_STORAGE) + 16,
00516                     &dwRecvNumBytes,
00517           (LPOVERLAPPED) &(g_pCtxtListenSocket->pIOContext->Overlapped));
00518   if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError()) ) {
00519     myprintf("AcceptEx() failed: %d\n", WSAGetLastError());
00520     return(FALSE);
00521   }
00522
00523   return(TRUE);
00524 }
00525
00526 //
00527 // Worker thread that handles all I/O requests on any socket handle added to the IOCP.
00528 //
00529 DWORD WINAPI WorkerThread (LPVOID WorkThreadContext)  {
00530
00531   HANDLE hIOCP = (HANDLE)WorkThreadContext;
00532   BOOL bSuccess = FALSE;
00533   int nRet = 0;
00534   LPWSAOVERLAPPED lpOverlapped = NULL;
00535   PPER_SOCKET_CONTEXT lpPerSocketContext = NULL;
00536   PPER_SOCKET_CONTEXT lpAcceptSocketContext = NULL;
00537   PPER_IO_CONTEXT lpIOContext = NULL;
00538   WSABUF buffRecv;
00539   WSABUF buffSend;
00540   DWORD dwRecvNumBytes = 0;
00541   DWORD dwSendNumBytes = 0;
00542   DWORD dwFlags = 0;
00543   DWORD dwIoSize = 0;
00544
00545   while( TRUE ) {
00546
00547         //
00548     // continually loop to service io completion packets
00549     //
00550     bSuccess = GetQueuedCompletionStatus(
00551                       hIOCP,
00552                       &dwIoSize,
00553                       (PDWORD_PTR)&lpPerSocketContext,
00554                       (LPOVERLAPPED *)&lpOverlapped,
00555                       INFINITE
00556                       );
00557     if( !bSuccess )
00558       myprintf("GetQueuedCompletionStatus() failed: %d\n", GetLastError());
00559
00560     if( lpPerSocketContext == NULL ) {
00561
00562       //
00563       // CTRL-C handler used PostQueuedCompletionStatus to post an I/O packet with
00564       // a NULL CompletionKey (or if we get one for any reason).  It is time to exit.
00565       //
00566       return(0);
00567     }
00568
00569     if( g_bEndServer ) {
00570
00571       //
00572       // main thread will do all cleanup needed - see finally block
00573       //
00574       return(0);
00575     }
00576
00577     lpIOContext = (PPER_IO_CONTEXT)lpOverlapped;
00578
00579         //
00580     //We should never skip the loop and not post another AcceptEx if the current
00581     //completion packet is for previous AcceptEx
00582     //
00583     if( lpIOContext->IOOperation != ClientIoAccept ) {
00584       if( !bSuccess || (bSuccess && (0 == dwIoSize)) ) {
00585
00586         //
00587         // client connection dropped, continue to service remaining (and possibly
00588         // new) client connections
00589         //
00590         CloseClient(lpPerSocketContext, FALSE);
00591         continue;
00592       }
00593     }
00594
00595         //
00596     // determine what type of IO packet has completed by checking the PER_IO_CONTEXT
00597     // associated with this socket.  This will determine what action to take.
00598     //
00599     switch( lpIOContext->IOOperation ) {
00600     case ClientIoAccept:
00601
00602       //
00603       // When the AcceptEx function returns, the socket sAcceptSocket is
00604       // in the default state for a connected socket. The socket sAcceptSocket
00605       // does not inherit the properties of the socket associated with
00606       // sListenSocket parameter until SO_UPDATE_ACCEPT_CONTEXT is set on
00607       // the socket. Use the setsockopt function to set the SO_UPDATE_ACCEPT_CONTEXT
00608       // option, specifying sAcceptSocket as the socket handle and sListenSocket
00609       // as the option value.
00610       //
00611       nRet = setsockopt(
00612                lpPerSocketContext->pIOContext->SocketAccept,
00613                SOL_SOCKET,
00614                SO_UPDATE_ACCEPT_CONTEXT,
00615                (char *)&g_sdListen,
00616                sizeof(g_sdListen)
00617                );
00618
00619       if( nRet == SOCKET_ERROR ) {
00620
00621         //
00622         //just warn user here.
00623         //
00624         myprintf("setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed to update accept socket\n");
00625         WSASetEvent(g_hCleanupEvent[0]);
00626         return(0);
00627       }
00628
00629       lpAcceptSocketContext = UpdateCompletionPort(
00630                             lpPerSocketContext->pIOContext->SocketAccept,
00631                             ClientIoAccept, TRUE);
00632
00633       if( lpAcceptSocketContext == NULL ) {
00634
00635         //
00636         //just warn user here.
00637         //
00638         myprintf("failed to update accept socket to IOCP\n");
00639         WSASetEvent(g_hCleanupEvent[0]);
00640         return(0);
00641       }
00642
00643       if( dwIoSize ) {
00644         lpAcceptSocketContext->pIOContext->IOOperation = ClientIoWrite;
00645         lpAcceptSocketContext->pIOContext->nTotalBytes  = dwIoSize;
00646         lpAcceptSocketContext->pIOContext->nSentBytes   = 0;
00647         lpAcceptSocketContext->pIOContext->wsabuf.len   = dwIoSize;
00648         CopyMemory(lpAcceptSocketContext->pIOContext->Buffer, lpPerSocketContext->pIOContext->Buffer, sizeof(lpPerSocketContext->pIOContext->Buffer));
00649         lpAcceptSocketContext->pIOContext->wsabuf.buf = lpAcceptSocketContext->pIOContext->Buffer;
00650
00651         nRet = WSASend(
00652                 lpPerSocketContext->pIOContext->SocketAccept,
00653                 &lpAcceptSocketContext->pIOContext->wsabuf, 1,
00654                 &dwSendNumBytes,
00655                 0,
00656                 &(lpAcceptSocketContext->pIOContext->Overlapped), NULL);
00657
00658         if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError()) ) {
00659           myprintf ("WSASend() failed: %d\n", WSAGetLastError());
00660           CloseClient(lpAcceptSocketContext, FALSE);
00661         } else if( g_bVerbose ) {
00662           myprintf("WorkerThread %d: Socket(%d) AcceptEx completed (%d bytes), Send posted\n",
00663                GetCurrentThreadId(), lpPerSocketContext->Socket, dwIoSize);
00664         }
00665       } else {
00666
00667         //
00668         // AcceptEx completes but doesn't read any data so we need to post
00669         // an outstanding overlapped read.
00670         //
00671         lpAcceptSocketContext->pIOContext->IOOperation = ClientIoRead;
00672         dwRecvNumBytes = 0;
00673         dwFlags = 0;
00674         buffRecv.buf = lpAcceptSocketContext->pIOContext->Buffer,
00675         buffRecv.len = MAX_BUFF_SIZE;
00676         nRet = WSARecv(
00677                 lpAcceptSocketContext->Socket,
00678                 &buffRecv, 1,
00679                 &dwRecvNumBytes,
00680                 &dwFlags,
00681                 &lpAcceptSocketContext->pIOContext->Overlapped, NULL);
00682         if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError()) ) {
00683           myprintf ("WSARecv() failed: %d\n", WSAGetLastError());
00684           CloseClient(lpAcceptSocketContext, FALSE);
00685         }
00686       }
00687
00688             //
00689       //Time to post another outstanding AcceptEx
00690       //
00691       if( !CreateAcceptSocket(FALSE) ) {
00692         myprintf("Please shut down and reboot the server.\n");
00693         WSASetEvent(g_hCleanupEvent[0]);
00694         return(0);
00695       }
00696       break;
00697
00698
00699     case ClientIoRead:
00700
00701             //
00702       // a read operation has completed, post a write operation to echo the
00703       // data back to the client using the same data buffer.
00704       //
00705       lpIOContext->IOOperation = ClientIoWrite;
00706       lpIOContext->nTotalBytes = dwIoSize;
00707       lpIOContext->nSentBytes  = 0;
00708       lpIOContext->wsabuf.len  = dwIoSize;
00709       dwFlags = 0;
00710       nRet = WSASend(
00711               lpPerSocketContext->Socket,
00712               &lpIOContext->wsabuf, 1, &dwSendNumBytes,
00713               dwFlags,
00714               &(lpIOContext->Overlapped), NULL);
00715       if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError()) ) {
00716         myprintf("WSASend() failed: %d\n", WSAGetLastError());
00717         CloseClient(lpPerSocketContext, FALSE);
00718       } else if( g_bVerbose ) {
00719         myprintf("WorkerThread %d: Socket(%d) Recv completed (%d bytes), Send posted\n",
00720              GetCurrentThreadId(), lpPerSocketContext->Socket, dwIoSize);
00721       }
00722       break;
00723
00724     case ClientIoWrite:
00725
00726       //
00727       // a write operation has completed, determine if all the data intended to be
00728       // sent actually was sent.
00729       //
00730       lpIOContext->IOOperation = ClientIoWrite;
00731       lpIOContext->nSentBytes  += dwIoSize;
00732       dwFlags = 0;
00733       if( lpIOContext->nSentBytes < lpIOContext->nTotalBytes ) {
00734
00735         //
00736         // the previous write operation didn't send all the data,
00737         // post another send to complete the operation
00738         //
00739         buffSend.buf = lpIOContext->Buffer + lpIOContext->nSentBytes;
00740         buffSend.len = lpIOContext->nTotalBytes - lpIOContext->nSentBytes;
00741         nRet = WSASend (
00742                  lpPerSocketContext->Socket,
00743                  &buffSend, 1, &dwSendNumBytes,
00744                  dwFlags,
00745                  &(lpIOContext->Overlapped), NULL);
00746         if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError()) ) {
00747           myprintf ("WSASend() failed: %d\n", WSAGetLastError());
00748           CloseClient(lpPerSocketContext, FALSE);
00749         } else if( g_bVerbose ) {
00750           myprintf("WorkerThread %d: Socket(%d) Send partially completed (%d bytes), Recv posted\n",
00751                GetCurrentThreadId(), lpPerSocketContext->Socket, dwIoSize);
00752         }
00753       } else {
00754
00755         //
00756         // previous write operation completed for this socket, post another recv
00757         //
00758         lpIOContext->IOOperation = ClientIoRead;
00759         dwRecvNumBytes = 0;
00760         dwFlags = 0;
00761         buffRecv.buf = lpIOContext->Buffer,
00762         buffRecv.len = MAX_BUFF_SIZE;
00763         nRet = WSARecv(
00764                 lpPerSocketContext->Socket,
00765                 &buffRecv, 1, &dwRecvNumBytes,
00766                 &dwFlags,
00767                 &lpIOContext->Overlapped, NULL);
00768         if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError()) ) {
00769           myprintf ("WSARecv() failed: %d\n", WSAGetLastError());
00770           CloseClient(lpPerSocketContext, FALSE);
00771         } else if( g_bVerbose ) {
00772           myprintf("WorkerThread %d: Socket(%d) Send completed (%d bytes), Recv posted\n",
00773                GetCurrentThreadId(), lpPerSocketContext->Socket, dwIoSize);
00774         }
00775       }
00776       break;
00777
00778     } //switch
00779   } //while
00780   return(0);
00781 }
00782
00783 //
00784 //  Allocate a context structures for the socket and add the socket to the IOCP.
00785 //  Additionally, add the context structure to the global list of context structures.
00786 //
00787 PPER_SOCKET_CONTEXT UpdateCompletionPort(SOCKET sd, IO_OPERATION ClientIo,
00788                                          BOOL bAddToList) {
00789
00790   PPER_SOCKET_CONTEXT lpPerSocketContext;
00791
00792   lpPerSocketContext = CtxtAllocate(sd, ClientIo);
00793   if( lpPerSocketContext == NULL )
00794     return(NULL);
00795
00796   g_hIOCP = CreateIoCompletionPort((HANDLE)sd, g_hIOCP, (DWORD_PTR)lpPerSocketContext, 0);
00797   if(g_hIOCP == NULL) {
00798     myprintf("CreateIoCompletionPort() failed: %d\n", GetLastError());
00799     if( lpPerSocketContext->pIOContext )
00800       xfree(lpPerSocketContext->pIOContext);
00801     xfree(lpPerSocketContext);
00802     return(NULL);
00803   }
00804
00805     //
00806   //The listening socket context (bAddToList is FALSE) is not added to the list.
00807   //All other socket contexts are added to the list.
00808   //
00809   if( bAddToList ) CtxtListAddTo(lpPerSocketContext);
00810
00811   if( g_bVerbose )
00812     myprintf("UpdateCompletionPort: Socket(%d) added to IOCP\n", lpPerSocketContext->Socket);
00813
00814   return(lpPerSocketContext);
00815 }
00816
00817 //
00818 //  Close down a connection with a client.  This involves closing the socket (when
00819 //  initiated as a result of a CTRL-C the socket closure is not graceful).  Additionally,
00820 //  any context data associated with that socket is free'd.
00821 //
00822 VOID CloseClient (PPER_SOCKET_CONTEXT lpPerSocketContext, BOOL bGraceful) {
00823
00824   EnterCriticalSection(&g_CriticalSection);
00825
00826   if( lpPerSocketContext ) {
00827     if( g_bVerbose )
00828       myprintf("CloseClient: Socket(%d) connection closing (graceful=%s)\n",
00829            lpPerSocketContext->Socket, (bGraceful?"TRUE":"FALSE"));
00830     if( !bGraceful ) {
00831
00832       //
00833       // force the subsequent closesocket to be abortative.
00834       //
00835       LINGER  lingerStruct;
00836
00837       lingerStruct.l_onoff = 1;
00838       lingerStruct.l_linger = 0;
00839       setsockopt(lpPerSocketContext->Socket, SOL_SOCKET, SO_LINGER,
00840              (char *)&lingerStruct, sizeof(lingerStruct) );
00841     }
00842     if( lpPerSocketContext->pIOContext->SocketAccept != INVALID_SOCKET ) {
00843       closesocket(lpPerSocketContext->pIOContext->SocketAccept);
00844       lpPerSocketContext->pIOContext->SocketAccept = INVALID_SOCKET;
00845     };
00846
00847     closesocket(lpPerSocketContext->Socket);
00848     lpPerSocketContext->Socket = INVALID_SOCKET;
00849     CtxtListDeleteFrom(lpPerSocketContext);
00850     lpPerSocketContext = NULL;
00851   } else {
00852     myprintf("CloseClient: lpPerSocketContext is NULL\n");
00853   }
00854
00855   LeaveCriticalSection(&g_CriticalSection);
00856
00857   return;
00858 }
00859
00860 //
00861 // Allocate a socket context for the new connection.
00862 //
00863 PPER_SOCKET_CONTEXT CtxtAllocate(SOCKET sd, IO_OPERATION ClientIO)  {
00864
00865   PPER_SOCKET_CONTEXT lpPerSocketContext;
00866
00867   EnterCriticalSection(&g_CriticalSection);
00868
00869   lpPerSocketContext = (PPER_SOCKET_CONTEXT)xmalloc(sizeof(PER_SOCKET_CONTEXT));
00870   if( lpPerSocketContext ) {
00871     lpPerSocketContext->pIOContext = (PPER_IO_CONTEXT)xmalloc(sizeof(PER_IO_CONTEXT));
00872     if( lpPerSocketContext->pIOContext ) {
00873       lpPerSocketContext->Socket = sd;
00874       lpPerSocketContext->pCtxtBack = NULL;
00875       lpPerSocketContext->pCtxtForward = NULL;
00876
00877       lpPerSocketContext->pIOContext->Overlapped.Internal = 0;
00878       lpPerSocketContext->pIOContext->Overlapped.InternalHigh = 0;
00879       lpPerSocketContext->pIOContext->Overlapped.Offset = 0;
00880       lpPerSocketContext->pIOContext->Overlapped.OffsetHigh = 0;
00881       lpPerSocketContext->pIOContext->Overlapped.hEvent = NULL;
00882       lpPerSocketContext->pIOContext->IOOperation = ClientIO;
00883       lpPerSocketContext->pIOContext->pIOContextForward = NULL;
00884       lpPerSocketContext->pIOContext->nTotalBytes = 0;
00885       lpPerSocketContext->pIOContext->nSentBytes  = 0;
00886       lpPerSocketContext->pIOContext->wsabuf.buf  = lpPerSocketContext->pIOContext->Buffer;
00887       lpPerSocketContext->pIOContext->wsabuf.len  = sizeof(lpPerSocketContext->pIOContext->Buffer);
00888       lpPerSocketContext->pIOContext->SocketAccept = INVALID_SOCKET;
00889
00890       ZeroMemory(lpPerSocketContext->pIOContext->wsabuf.buf, lpPerSocketContext->pIOContext->wsabuf.len);
00891     } else {
00892       xfree(lpPerSocketContext);
00893       myprintf("HeapAlloc() PER_IO_CONTEXT failed: %d\n", GetLastError());
00894     }
00895
00896   } else {
00897     myprintf("HeapAlloc() PER_SOCKET_CONTEXT failed: %d\n", GetLastError());
00898     return(NULL);
00899   }
00900
00901   LeaveCriticalSection(&g_CriticalSection);
00902
00903   return(lpPerSocketContext);
00904 }
00905
00906 //
00907 //  Add a client connection context structure to the global list of context structures.
00908 //
00909 VOID CtxtListAddTo (PPER_SOCKET_CONTEXT lpPerSocketContext) {
00910
00911   PPER_SOCKET_CONTEXT pTemp;
00912
00913   EnterCriticalSection(&g_CriticalSection);
00914
00915   if( g_pCtxtList == NULL ) {
00916
00917     //
00918     // add the first node to the linked list
00919     //
00920     lpPerSocketContext->pCtxtBack    = NULL;
00921     lpPerSocketContext->pCtxtForward = NULL;
00922     g_pCtxtList = lpPerSocketContext;
00923   } else {
00924
00925     //
00926     // add node to head of list
00927     //
00928     pTemp = g_pCtxtList;
00929
00930     g_pCtxtList = lpPerSocketContext;
00931     lpPerSocketContext->pCtxtBack    = pTemp;
00932     lpPerSocketContext->pCtxtForward = NULL;
00933
00934     pTemp->pCtxtForward = lpPerSocketContext;
00935   }
00936
00937   LeaveCriticalSection(&g_CriticalSection);
00938
00939   return;
00940 }
00941
00942 //
00943 //  Remove a client context structure from the global list of context structures.
00944 //
00945 VOID CtxtListDeleteFrom(PPER_SOCKET_CONTEXT lpPerSocketContext) {
00946
00947   PPER_SOCKET_CONTEXT pBack;
00948   PPER_SOCKET_CONTEXT pForward;
00949   PPER_IO_CONTEXT     pNextIO     = NULL;
00950   PPER_IO_CONTEXT     pTempIO     = NULL;
00951
00952   EnterCriticalSection(&g_CriticalSection);
00953
00954   if( lpPerSocketContext ) {
00955     pBack       = lpPerSocketContext->pCtxtBack;
00956     pForward    = lpPerSocketContext->pCtxtForward;
00957
00958     if( pBack == NULL && pForward == NULL ) {
00959
00960       //
00961       // This is the only node in the list to delete
00962       //
00963       g_pCtxtList = NULL;
00964     } else if( pBack == NULL && pForward != NULL ) {
00965
00966       //
00967       // This is the start node in the list to delete
00968       //
00969       pForward->pCtxtBack = NULL;
00970       g_pCtxtList = pForward;
00971     } else if( pBack != NULL && pForward == NULL ) {
00972
00973       //
00974       // This is the end node in the list to delete
00975       //
00976       pBack->pCtxtForward = NULL;
00977     } else if( pBack && pForward ) {
00978
00979       //
00980       // Neither start node nor end node in the list
00981       //
00982       pBack->pCtxtForward = pForward;
00983       pForward->pCtxtBack = pBack;
00984     }
00985
00986         //
00987     // Free all i/o context structures per socket
00988     //
00989     pTempIO = (PPER_IO_CONTEXT)(lpPerSocketContext->pIOContext);
00990     do {
00991       pNextIO = (PPER_IO_CONTEXT)(pTempIO->pIOContextForward);
00992       if( pTempIO ) {
00993
00994         //
00995         //The overlapped structure is safe to free when only the posted i/o has
00996         //completed. Here we only need to test those posted but not yet received
00997         //by PQCS in the shutdown process.
00998         //
00999         if( g_bEndServer )
01000           while( !HasOverlappedIoCompleted((LPOVERLAPPED)pTempIO) ) Sleep(0);
01001         xfree(pTempIO);
01002         pTempIO = NULL;
01003       }
01004       pTempIO = pNextIO;
01005     } while( pNextIO );
01006
01007     xfree(lpPerSocketContext);
01008     lpPerSocketContext = NULL;
01009   } else {
01010     myprintf("CtxtListDeleteFrom: lpPerSocketContext is NULL\n");
01011   }
01012
01013   LeaveCriticalSection(&g_CriticalSection);
01014
01015   return;
01016 }
01017
01018 //
01019 //  Free all context structure in the global list of context structures.
01020 //
01021 VOID CtxtListFree() {
01022   PPER_SOCKET_CONTEXT pTemp1, pTemp2;
01023
01024   EnterCriticalSection(&g_CriticalSection);
01025
01026   pTemp1 = g_pCtxtList;
01027   while( pTemp1 ) {
01028     pTemp2 = pTemp1->pCtxtBack;
01029     CloseClient(pTemp1, FALSE);
01030     pTemp1 = pTemp2;
01031   }
01032
01033   LeaveCriticalSection(&g_CriticalSection);
01034
01035   return;
01036 }
01037
01038 int myprintf (const char *lpFormat, ... ) {
01039
01040   int nLen = 0;
01041   int nRet = 0;
01042   char cBuffer[512] ;
01043   va_list arglist ;
01044   HANDLE hOut = NULL;
01045
01046   ZeroMemory(cBuffer, sizeof(cBuffer));
01047
01048   va_start(arglist, lpFormat);
01049
01050   nLen = lstrlen( lpFormat ) ;
01051   nRet = wvsprintf( cBuffer, lpFormat, arglist );
01052
01053   if( nRet >= nLen || GetLastError() == 0 ) {
01054     hOut = GetStdHandle(STD_OUTPUT_HANDLE) ;
01055     if( hOut != INVALID_HANDLE_VALUE )
01056       WriteConsole( hOut, cBuffer, lstrlen(cBuffer), (LPDWORD)&nLen, NULL ) ;
01057   }
01058
01059   return nLen ;
01060 }
01061
01062
01063
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/MMbuf.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

MMbuf.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       mmbuf.cxx
00006 //
00007 //  Contents:   Memory Mapped Buffer, Safe ptr to stream
00008 //
00009 //  Classes:    CMmStreamBuf
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <pmmstrm.hxx>
00017
00018 CMmStreamBuf::~CMmStreamBuf()
00019 {
00020     if (_buf && _pStream )
00021         _pStream->Unmap(*this);
00022 }
00023
00024 SMmStream::~SMmStream()
00025 {
00026     delete _pStream;
00027 }
00028
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/Factory.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

Factory.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.H
00003
00004   Summary:   Include file for the class factory COM objects:
00005              CFLicCruiseCar, and CFLicCarSample.  These constitute the
00006              LICSERVE server's Class Factories for those COM components.
00007
00008              The multiple interface COM Object Classes are achieved via
00009              the technique of nested classes: the implementation of the
00010              IClassFactory interfaces are nested inside of the class
00011              factory COM object classes.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial LICSERVE.HTM
00015              file. For more specific technical details on the internal
00016              workings see the comments dispersed throughout the module's
00017              source code.
00018
00019   Classes:   CFLicCruiseCar, CFLicCarSample.
00020
00021   Functions: .
00022
00023   Origin:    10-5-95: atrent - Editor-inheritance from CRUCAR.H in
00024                the DLLSERVE Tutorial Code Sample.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(FACTORY_H)
00042 #define FACTORY_H
00043
00044 #ifdef __cplusplus
00045
00046
00047 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00048   ObjectClass: CFLicCruiseCar
00049
00050   Summary:     Class Factory COM Object Class for LicCruiseCar COM
00051                components.  Used to manufacture COLicCruiseCar COM objects.
00052                The mulitple interfaces on this COM object class are
00053                constructed via the nested interface classes technique.
00054
00055   Interfaces:  IUnknown
00056                  Standard interface providing COM object features.
00057                IClassFactory2
00058                  Standard interface providing COM Class Factory features
00059                  that support licensing of these Cruise Car COM components.
00060
00061   Aggregation: Yes, CFLicCruiseCar COM objects are aggregatable by
00062                passing a non-NULL pUnkOuter IUnknown pointer into the
00063                constructor.
00064 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00065 class CFLicCruiseCar : public IUnknown
00066 {
00067   public:
00068     // Main Object Constructor & Destructor.
00069     CFLicCruiseCar(IUnknown* pUnkOuter, CServer* pServer);
00070     ~CFLicCruiseCar(void);
00071
00072     // A general method for initializing a newly created CFLicCruiseCar.
00073     HRESULT Init(void);
00074
00075     // IUnknown methods. Main object, non-delegating.
00076     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00077     STDMETHODIMP_(ULONG) AddRef(void);
00078     STDMETHODIMP_(ULONG) Release(void);
00079
00080   private:
00081     // A private unconditional create for LicCruiseCar.
00082     STDMETHODIMP CreateLicCruiseCar(IUnknown*, REFIID, PPVOID);
00083
00084     // We declare nested class interface implementations here.
00085
00086     // We implement the IClassFactory2 interface on this LicCruiseCar
00087     // Class Factory to license these COM objects.
00088     class CImpIClassFactory : public IClassFactory2
00089     {
00090       public:
00091         // Interface Implementation Constructor & Destructor.
00092         CImpIClassFactory(
00093           CFLicCruiseCar* pBackObj,
00094           IUnknown* pUnkOuter,
00095           CServer* pServer);
00096         ~CImpIClassFactory(void);
00097
00098         // IUnknown methods.
00099         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00100         STDMETHODIMP_(ULONG) AddRef(void);
00101         STDMETHODIMP_(ULONG) Release(void);
00102
00103         // IClassFactory methods.
00104         STDMETHODIMP         CreateInstance(IUnknown*, REFIID, PPVOID);
00105         STDMETHODIMP         LockServer(BOOL);
00106
00107         // IClassFactory2 methods.
00108         STDMETHODIMP         GetLicInfo(LPLICINFO);
00109         STDMETHODIMP         RequestLicKey(DWORD, BSTR*);
00110         STDMETHODIMP         CreateInstanceLic(
00111                                IUnknown*,
00112                                IUnknown*,
00113                                REFIID,
00114                                BSTR,
00115                                PPVOID);
00116
00117       private:
00118         // Data private to this interface implementation of IClassFactory.
00119         ULONG            m_cRefI;       // Interface Ref Count (debugging).
00120         CFLicCruiseCar*  m_pBackObj;    // Parent Object back pointer.
00121         IUnknown*        m_pUnkOuter;   // Outer unknown for Delegation.
00122         CServer*         m_pServer;     // Server Control Object.
00123     };
00124
00125     // Make the otherwise private and nested IClassFactory interface
00126     // implementation a friend to COM object instantiations of this
00127     // selfsame CFLicCruiseCar COM object class.
00128     friend CImpIClassFactory;
00129
00130     // Private data of CFLicCruiseCar COM objects.
00131
00132     // Nested IClassFactory implementation instantiation.
00133     CImpIClassFactory m_ImpIClassFactory;
00134
00135     // Main Object reference count.
00136     ULONG             m_cRefs;
00137
00138     // Outer unknown (aggregation & delegation). Used when this
00139     // CFLicCruiseCar object is being aggregated.  Otherwise it is used
00140     // for delegation if this object is reused via containment.
00141     IUnknown*         m_pUnkOuter;
00142
00143     // Pointer to this component server's control object.
00144     CServer*          m_pServer;
00145 };
00146
00147 typedef CFLicCruiseCar* PCFLicCruiseCar;
00148
00149
00150 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00151   ObjectClass: CFLicCarSample
00152
00153   Summary:     Class Factory COM Object Class for LicCarSample COM
00154                components.  Used to manufacture COLicCarSample COM
00155                objects.  The mulitple interfaces on this COM object
00156                class are constructed via the nested interface classes
00157                technique.
00158
00159   Interfaces:  IUnknown
00160                  Standard interface providing COM object features.
00161                IClassFactory
00162                  Standard interface providing COM Class Factory features.
00163
00164   Aggregation: Yes, CFLicCarSample COM objects are aggregatable by
00165                passing a non-NULL pUnkOuter IUnknown pointer into the
00166                constructor.
00167 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00168 class CFLicCarSample : public IUnknown
00169 {
00170   public:
00171     // Main Object Constructor & Destructor.
00172     CFLicCarSample(IUnknown* pUnkOuter, CServer* pServer);
00173     ~CFLicCarSample(void);
00174
00175     // A general method for initializing a newly created CFLicCarSample.
00176     HRESULT Init(void);
00177
00178     // IUnknown methods. Main object, non-delegating.
00179     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00180     STDMETHODIMP_(ULONG) AddRef(void);
00181     STDMETHODIMP_(ULONG) Release(void);
00182
00183   private:
00184     // We declare nested class interface implementations here.
00185
00186     // We implement the IClassFactory interface (of course) in this Class
00187     // Factory COM object class.
00188     class CImpIClassFactory : public IClassFactory
00189     {
00190       public:
00191         // Interface Implementation Constructor & Destructor.
00192         CImpIClassFactory(
00193           CFLicCarSample* pBackObj,
00194           IUnknown* pUnkOuter,
00195           CServer* pServer);
00196         ~CImpIClassFactory(void);
00197
00198         // IUnknown methods.
00199         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00200         STDMETHODIMP_(ULONG) AddRef(void);
00201         STDMETHODIMP_(ULONG) Release(void);
00202
00203         // IClassFactory methods.
00204         STDMETHODIMP         CreateInstance(IUnknown*, REFIID, PPVOID);
00205         STDMETHODIMP         LockServer(BOOL);
00206
00207       private:
00208         // Data private to this interface implementation of IClassFactory.
00209         ULONG           m_cRefI;     // Interface Ref Count (for debugging).
00210         CFLicCarSample* m_pBackObj;  // Parent Object back pointer.
00211         IUnknown*       m_pUnkOuter; // Outer unknown for Delegation.
00212         CServer*        m_pServer;   // Server Control Object.
00213     };
00214
00215     // Make the otherwise private and nested IClassFactory interface
00216     // implementation a friend to COM object instantiations of this
00217     // selfsame CFLicCarSample COM object class.
00218     friend CImpIClassFactory;
00219
00220     // Private data of CFLicCarSample COM objects.
00221
00222     // Nested IClassFactory implementation instantiation.
00223     CImpIClassFactory m_ImpIClassFactory;
00224
00225     // Main Object reference count.
00226     ULONG             m_cRefs;
00227
00228     // Outer unknown (aggregation & delegation). Used when this
00229     // CFLicCarSample object is being aggregated.  Otherwise it is used
00230     // for delegation if this object is reused via containment.
00231     IUnknown*         m_pUnkOuter;
00232
00233     // Pointer to this component server's control object.
00234     CServer*          m_pServer;
00235 };
00236
00237 typedef CFLicCarSample* PCFLicCarSample;
00238
00239 #endif // __cplusplus
00240
00241
00242 #endif // FACTORY_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MidiPlyr/GLOBAL.h Source File

  • Multimedia
  • Audio
  • MidiPlyr

GLOBAL.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *
00003 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
00006 *  A PARTICULAR PURPOSE.
00007 *
00008 *  Copyright 1993 - 2000 Microsoft Corporation. All Rights Reserved.
00009 *
00010 ******************************************************************************
00011 *
00012 * Global.H
00013 *
00014 * #define's everybody needs
00015 *
00016 *****************************************************************************/
00017
00018 #ifndef _GLOBAL_
00019 #define _GLOBAL_
00020
00021 #ifndef _WIN32
00022 #define  BCODE                  __based(__segname("_CODE"))
00023 #define  BSTACK                 __based(__segname("_STACK"))
00024 #define  BSEG(x)                __based(__segname(x))
00025 #define  HUGE                   __huge
00026 #else
00027 #define  BCODE
00028 #define  BSTACK
00029 #define  BSEG(x)
00030 #define  HUGE
00031 #endif
00032
00033 /* Allow visibility of static functions for debug
00034 */
00035 #ifdef DEBUG
00036 #define  PUBLIC
00037 #define  PRIVATE
00038 #else
00039 #define  PUBLIC
00040 #define  PRIVATE                static
00041 #endif
00042
00043 #define  FNLOCAL                NEAR PASCAL
00044 #define  FNGLOBAL               FAR PASCAL
00045 #define  FNEXPORT               FAR PASCAL __export __loadds
00046
00047 #endif
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/Resource.h Source File

  • WinUI
  • Shell
  • FileView

Resource.h

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  PROGRAM: RESOURCE.H
00009 //
00010 //  PURPOSE: Definitions specifically pertaining to resources for a FileViewer.
00011 //
00012 //  PLATFORMS:  Windows 95
00013 //
00014 //  SPECIAL INSTRUCTIONS: N/A
00015 //
00016 #ifndef _RESOURCE_H_
00017 #define _RESOURCE_H_
00018
00019 //Resource identifiers
00020 #define IDR_MENU                1
00021 #define IDR_MENUVIEWPORT        2
00022 #define IDR_ACCELERATORS        1
00023 #define IDR_STATMESSAGEMAP      1
00024 #define IDB_TOOLS               1
00025 #define IDD_ABOUT               1
00026
00027
00028 //Toolbar bitmaps indexes and other values
00029 #define IDBT_OPENAS              0
00030 #define IDBT_FONTSIZEINCREASE    1
00031 #define IDBT_FONTSIZEDECREASE    2
00032
00033 #define CTBBUTTONS              4
00034 #define CTBBITMAPS              3
00035
00036
00037
00038 //Menu command identifiers.
00039 #define IDM_FILEOPENAS          100
00040 #define IDM_FILEPAGESETUP       110
00041 #define IDM_FILEPRINT           111
00042 #define IDM_FILEEXIT            120
00043
00044 #define IDM_VIEWTOOLBAR         200
00045 #define IDM_VIEWSTATUSBAR       201
00046 #define IDM_VIEWFONT            210
00047 #define IDM_VIEWFONTINCREASE    211     //Toolbar only
00048 #define IDM_VIEWFONTDECREASE    212     //Toolbar only
00049 #define IDM_VIEWREPLACE         223
00050
00051 #define IDM_HELPCONTENTS        300
00052 #define IDM_HELPABOUT           301
00053
00054
00055
00056 //String identifiers.  Keep sequential for each group.
00057
00058 //Main window strings (messages, other variable strings).
00059 #define IDS_MIN                 0
00060
00061 #define IDS_CLASSFRAME          (IDS_MIN+0)
00062 #define IDS_CLASSVIEWPORT       (IDS_MIN+1)
00063 #define IDS_CAPTION             (IDS_MIN+2)
00064 #define IDS_DOCUMENTTYPE        (IDS_MIN+3)
00065 #define IDS_NOHELP              (IDS_MIN+4)
00066 #define IDS_TOOLTIPOPENAS       (IDS_MIN+5)
00067 #define IDS_TOOLTIPFONTINC      (IDS_MIN+6)
00068 #define IDS_TOOLTIPFONTDEC      (IDS_MIN+7)
00069
00070 #define IDS_MAX                 (IDS_MIN+7)
00071
00072 //Length of longest string in this stringtable.
00073 #define CCHSTRINGMAX            40
00074
00075
00076
00077 //Status bar messages for a message map
00078 #define IDS_STATUSMSGMIN        32
00079
00080 #define IDS_MSGEMPTY            (IDS_STATUSMSGMIN+0)
00081 #define IDS_MSGREADY            (IDS_STATUSMSGMIN+1)
00082 #define IDS_MSGSYS              (IDS_STATUSMSGMIN+2)
00083 #define IDS_MSGSYSRESTORE       (IDS_STATUSMSGMIN+3)
00084 #define IDS_MSGSYSMOVE          (IDS_STATUSMSGMIN+4)
00085 #define IDS_MSGSYSSIZE          (IDS_STATUSMSGMIN+5)
00086 #define IDS_MSGSYSMINIMIZE      (IDS_STATUSMSGMIN+6)
00087 #define IDS_MSGSYSMAXIMIZE      (IDS_STATUSMSGMIN+7)
00088 #define IDS_MSGSYSCLOSE         (IDS_STATUSMSGMIN+8)
00089 #define IDS_MSGSYSTASKLIST      (IDS_STATUSMSGMIN+9)
00090 #define IDS_MSGFILE             (IDS_STATUSMSGMIN+10)
00091 #define IDS_MSGFILEOPENAS       (IDS_STATUSMSGMIN+11)
00092 #define IDS_MSGFILEPAGESETUP    (IDS_STATUSMSGMIN+12)
00093 #define IDS_MSGFILEPRINT        (IDS_STATUSMSGMIN+13)
00094 #define IDS_MSGFILEEXIT         (IDS_STATUSMSGMIN+14)
00095 #define IDS_MSGVIEW             (IDS_STATUSMSGMIN+15)
00096 #define IDS_MSGVIEWTOOLBAR      (IDS_STATUSMSGMIN+16)
00097 #define IDS_MSGVIEWSTATUSBAR    (IDS_STATUSMSGMIN+17)
00098 #define IDS_MSGVIEWFONT         (IDS_STATUSMSGMIN+18)
00099 #define IDS_MSGHELP             (IDS_STATUSMSGMIN+19)
00100 #define IDS_MSGHELPCONTENTS     (IDS_STATUSMSGMIN+20)
00101 #define IDS_MSGHELPABOUT        (IDS_STATUSMSGMIN+21)
00102 #define IDS_MSGTIPFONTINC       (IDS_STATUSMSGMIN+22)
00103 #define IDS_MSGTIPFONTDEC       (IDS_STATUSMSGMIN+23)
00104 #define IDS_MSGCHOOSEOPEN       (IDS_STATUSMSGMIN+24)
00105
00106 #define IDS_STATUSMSGMAX        (IDS_STATUSMSGMIN+24)
00107
00108 #define CCHSTATUSMSGMAX         80
00109
00110 /*
00111  * IDs for status bar mapping of popup menus to string IDs.
00112  * Those for the menus defined between ID_MENUMIN and ID_MENUMAX
00113  * that we send to CStatusHelper::MessageMap must be sequential
00114  * as the popup menu hMenu's are mapped to these values by
00115  * sequential position, so be sure to define these values in
00116  * the same sequence as the menus themselves.
00117  */
00118
00119 #define ID_MSGEMPTY                         1000
00120 #define ID_MSGREADY                         1001
00121 #define ID_MENUSYS                          1002
00122 #define ID_MENUFILE                         1003
00123 #define ID_MENUVIEW                         1004
00124 #define ID_MENUHELP                         1005
00125 #define ID_TIPFONTINC                       1006
00126 #define ID_TIPFONTDEC                       1007
00127 #define ID_MSGCHOOSEOPEN                    1008
00128
00129
00130 #define ID_MENUMIN                          ID_MENUFILE
00131 #define ID_MENUMAX                          ID_MENUHELP
00132
00133
00134 #endif //_RESOURCE_H_
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/main.cpp Source File

  • Com
  • async
  • server

main.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <iostream>
00020
00021 #include "DCOMServer.h"
00022 #include "CFactory.h"
00023 #include "Debug.h"
00024
00025 #if defined(_ASYNC_COM_)
00026 #pragma message(">>> Compiling for Asynchronous COM")
00027 #else
00028 #pragma message(">>> Compiling for Synchronous COM")
00029 #endif
00030
00031 using namespace std;
00032
00033 HMODULE g_hModule;
00034 CLSID g_clsid;
00035 LPOLESTR g_progID;
00036 // Event handle used to signal main thread to exit upon shutdown
00037 HANDLE g_CloseEvent;
00038
00039 // index to TLS
00040 DWORD g_dwTLS;
00041
00042
00043 extern "C"
00044 {
00045   LPWSTR appSource = CServer::GetProgID();
00046 }
00047 CHAR_CONVERSION; // A2W, W2A helpers
00048
00049 extern int g_cFactoryDataEntries;
00050 extern CFactoryData g_FactoryDataArray[];
00051
00052 typedef enum {EMPTY,REGISTER,UNREGISTER} SERVERFLAGS;
00053 SERVERFLAGS UpdateRegistery(char* argv);
00054
00055
00056 main(int argc, char* argv[])
00057 {
00058
00059 // TODO: ADD path to server
00060   cout << "Server side of Asynchronous test" << endl;
00061
00062 #if defined(_APARTMENT_)
00063 #pragma message(">>> Compiling for the Apartment Threaded Apartment")
00064   HRESULT hr = CoInitialize(NULL);
00065 #else // Free Threaded Apartment
00066 #pragma message(">>> Compiling for the Free Threaded Apartment")
00067   HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00068   g_CloseEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
00069   _ASSERT(g_CloseEvent);
00070 #endif // _APARTMENT_
00071   _ASSERT(SUCCEEDED(hr));
00072   g_dwTLS = TlsAlloc();
00073
00074 /*
00075  * Callbacks require the process level security to be non-authenicated
00076  */
00077   hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_ANONYMOUS , NULL, EOAC_NONE, 0);
00078   _ASSERT(SUCCEEDED(hr));
00079
00080   if (argc > 1 && UpdateRegistery(argv[1]) == REGISTER)
00081   {
00082     hr = CFactory::RegisterAll();
00083     if (FAILED(hr))
00084       MessageBox(NULL, "Could not registry app", W2A(CServer::GetProgID()), MB_OK);
00085     else
00086       MessageBox(NULL, "application has been registered", W2A(CServer::GetProgID()), MB_OK);
00087     goto END;
00088   }
00089   else if(argc > 1 && UpdateRegistery(argv[1]) == UNREGISTER)
00090   {
00091     hr = CFactory::UnregisterAll();
00092     if (FAILED(hr))
00093       MessageBox(NULL, "Error unregistering app", W2A(CServer::GetProgID()), MB_OK);
00094     else
00095       MessageBox(NULL, "application has been unregistered", W2A(CServer::GetProgID()), MB_OK);
00096     goto END;
00097   }
00098
00099
00100   cout << "Registering classfactories" << endl;
00101   // Register all ClassFactories
00102   int i;
00103   DWORD *dwCookies;
00104   dwCookies = new DWORD[g_cFactoryDataEntries];
00105   DEBUGTRACE(_T("Register all ClassFactories"));
00106   for (i = 0; i < g_cFactoryDataEntries; i++)
00107   {
00108     const CFactoryData* pData = &g_FactoryDataArray[i] ;
00109
00110     LPUNKNOWN pCF =  new CFactory(pData) ;
00111     if (pCF == NULL)
00112     {
00113       DEBUGTRACE(_T("Error allocating memory for classfactory"));
00114       goto END;
00115     }
00116     hr = CoRegisterClassObject(*pData->m_pCLSID,
00117                 pCF,
00118                 pData->server == LOCAL ? CLSCTX_LOCAL_SERVER : CLSCTX_SERVER,
00119                 REGCLS_MULTIPLEUSE|REGCLS_SUSPENDED,
00120                 &dwCookies[i]);
00121     _ASSERT(SUCCEEDED(hr));
00122   }
00123
00124   hr = CoResumeClassObjects();
00125   _ASSERT(SUCCEEDED(hr));
00126
00127   DEBUGTRACE(_T("Class Factories have been registered ready to handling in comming"));
00128
00129   cout << "Server ready..." << endl;
00130
00131 #if defined(_APARTMENT_)
00132   MSG msg;
00133   while (GetMessage(&msg, NULL, 0, 0))
00134     DispatchMessage(&msg);
00135 #else // Free Threaded Apartment
00136   WaitForSingleObject(g_CloseEvent, INFINITE);
00137 #endif // _APARTMENT_
00138
00139   DEBUGTRACE(_T("Cleaning up and exiting process"));
00140   for (i = 0; i < g_cFactoryDataEntries; i++)
00141     CoRevokeClassObject(dwCookies[i]);
00142
00143 #if !defined(_APARTMENT_)
00144   CloseHandle(g_CloseEvent);
00145 #endif
00146   delete [] dwCookies;
00147   CoUninitialize();
00148   return 0;
00149 END:
00150   CoUninitialize();
00151   return 0;
00152 }
00153
00154 SERVERFLAGS UpdateRegistery(char* argv)
00155 {
00156   char *p = strtok(argv, "-/");
00157   while (p)
00158   {
00159     if (stricmp(p, "RegServer")==0)
00160       return REGISTER;
00161     else if (stricmp(p, "UnregServer")==0)
00162       return UNREGISTER;
00163     p = strtok(NULL, "-/");
00164   }
00165   return EMPTY;
00166 }
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/Server.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

Server.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.CPP
00003
00004   Summary:   Implementation file for the CServer server control C++
00005              object.  This object encapsulates the server's internal
00006              control of global server object and lock counts. The
00007              CThreaded OwnThis mechanism is used to ensure mutually
00008              exclusive access to this CServer object by multiple threads.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial PERDRAW.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   CServer.
00017
00018   Functions: .
00019
00020   Origin:    5-20-97: atrent - Editor-inheritance from SERVER.CPP in
00021                the STOSERVE Tutorial Code Sample.
00022
00023 ----------------------------------------------------------------------------
00024   This file is part of the Microsoft COM Tutorial Code Samples.
00025
00026   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00027
00028   This source code is intended only as a supplement to Microsoft
00029   Development Tools and/or on-line documentation.  See these other
00030   materials for detailed information regarding Microsoft code samples.
00031
00032   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00033   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00034   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00035   PARTICULAR PURPOSE.
00036 ==========================================================================+*/
00037
00038 /*---------------------------------------------------------------------------
00039   We include WINDOWS.H for all Win32 applications.
00040   We include OLE2.H because we will be calling the COM/OLE Libraries.
00041   We include APPUTIL.H because we will be building this DLL using
00042     the convenient Virtual Window and Dialog classes and other
00043     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00044   We include SERVER.H for the class declarations for the C++ CServer
00045     server control object.
00046 ---------------------------------------------------------------------------*/
00047 #include <windows.h>
00048 #include <ole2.h>
00049 #include <apputil.h>
00050 #include "server.h"
00051
00052
00053 /*---------------------------------------------------------------------------
00054   Implementation the internal CServer C++ object.  Used to encapsulate
00055   some server data and the methods for Lock and Object count incrementing
00056   and decrementing.
00057 ---------------------------------------------------------------------------*/
00058
00059 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00060   Method:   CServer::CServer
00061
00062   Summary:  CServer Constructor.
00063
00064   Args:     void
00065
00066   Returns:  void
00067 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00068 CServer::CServer(void)
00069 {
00070   // Initially zero the Object and Lock counts for this attached process.
00071   m_cObjects = 0;
00072   m_cLocks = 0;
00073
00074   return;
00075 }
00076
00077
00078 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00079   Method:   CServer::~CServer
00080
00081   Summary:  CServer Destructor.
00082
00083   Args:     void
00084
00085   Returns:  void
00086 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00087 CServer::~CServer(void)
00088 {
00089   return;
00090 }
00091
00092
00093 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00094   Method:   CServer::Lock
00095
00096   Summary:  Increment the Server's Lock count.
00097
00098   Args:     void
00099
00100   Returns:  void
00101 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00102 void CServer::Lock(void)
00103 {
00104   LONG cLocks;
00105
00106   if (OwnThis())
00107   {
00108     cLocks = ++m_cLocks;
00109
00110     UnOwnThis();
00111   }
00112
00113   return;
00114 }
00115
00116
00117 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00118   Method:   CServer::Unlock
00119
00120   Summary:  Decrement the Server's Lock count.
00121
00122   Args:     void
00123
00124   Returns:  void
00125 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00126 void CServer::Unlock(void)
00127 {
00128   LONG cLocks;
00129
00130   if (OwnThis())
00131   {
00132     cLocks = --m_cLocks;
00133
00134     UnOwnThis();
00135   }
00136
00137   return;
00138 }
00139
00140
00141 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00142   Method:   CServer::ObjectsUp
00143
00144   Summary:  Increment the Server's living Object count.
00145
00146   Args:     void
00147
00148   Returns:  void
00149 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00150 void CServer::ObjectsUp(void)
00151 {
00152   LONG cObjects;
00153
00154   if (OwnThis())
00155   {
00156     cObjects = ++m_cObjects;
00157
00158     UnOwnThis();
00159   }
00160
00161   return;
00162 }
00163
00164
00165 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00166   Method:   CServer::ObjectsDown
00167
00168   Summary:  Decrement the Server's living object count.
00169
00170   Args:     void
00171
00172   Returns:  void
00173 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00174 void CServer::ObjectsDown(void)
00175 {
00176   LONG cObjects;
00177
00178   if (OwnThis())
00179   {
00180     cObjects = --m_cObjects;
00181
00182     UnOwnThis();
00183   }
00184
00185   return;
00186 }
00187
00188
00189 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00190   Method:   CServer::CanUnloadNow
00191
00192   Summary:  Check if the server can be can unloaded (ie, if there are no
00193             longer any living COM objects and no locks).
00194
00195   Args:     void
00196
00197   Returns:  HRESULT
00198               S_OK if this server can be unloaded.
00199               S_FALSE if this server can not be unloaded.
00200 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00201 HRESULT CServer::CanUnloadNow(void)
00202 {
00203   HRESULT hr = S_FALSE;
00204   LONG cObjects, cLocks;
00205
00206   if (OwnThis())
00207   {
00208     cObjects = m_cObjects;
00209     cLocks = m_cLocks;
00210
00211     hr = (0L==cObjects && 0L==cLocks) ? S_OK : S_FALSE;
00212
00213     UnOwnThis();
00214   }
00215
00216   return hr;
00217 }
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqTestOA/Guids.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqTestOA

Guids.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // contains the guids we will define ourselves.
00014 //
00015
00016
00017 #define INITGUID                   // define all the guids.
00018 #include <windows.h>
00019 #include "mqoai.H"
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMainWindow Member List

This is the complete list of members for CMainWindow, including all inherited members.
BindResourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
CFrameWndLite() | CFrameWndLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CMainWindow() | CMainWindow |
CMainWindow() | CMainWindow |
CMDIFrameLite() | CMDIFrameLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, HICON hIcon, DWORD dwStyle=WS_OVERLAPPEDWINDOW, DWORD dwExStyle=WS_EX_APPWINDOW, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CFrameWndLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DisplayDialog(UINT uID, HWND hWndParent, DLGPROC lpDialogFunc, CBase *pCObject, UINT idSource=0) | CMainWindow | [virtual]
DoModal() | CMainWindow |
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EnumPropertiesProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
ErrorRecordsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
FindWindow(WCHAR *pwszClassName=NULL) | CMDIFrameLite | [virtual]
GetActiveWindow(WCHAR *pwszClassName=NULL) | CMDIFrameLite | [virtual]
GetDataSourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetObject(SOURCE eSource=eCUnknown, BOOL fAlways=FALSE) | CMainWindow | [virtual]
GetObjectAddress(SOURCE eSource=eCUnknown) | CMainWindow | [virtual]
GetOptions() | CMainWindow | [inline, virtual]
GetSourcesRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
HandleObjectType(CBase *pCSource, IUnknown *pIUnknown, REFIID riid, SOURCE eSource, ULONG cPropSets, DBPROPSET *rgPropSets, DWORD dwFlags) | CMainWindow | [virtual]
IsDestroyed() | CMDIFrameLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
LoadSettings() | CMainWindow | [virtual]
m_bDisplayWaitCursor | CMainWindow | [private]
m_bUnicodeMsg | CWndLite |
m_cRef | CMainWindow | [private]
m_CStatusBar | CMainWindow |
m_CToolBar | CMainWindow |
m_hCurSizeNS | CMainWindow |
m_hImageList | CMainWindow |
m_hLibRichEdit10 | CMainWindow |
m_hLibRichEdit20 | CMainWindow |
m_hMDIClient | CMainWindow | [private]
m_hStateList | CMainWindow |
m_hWnd | CWndLite |
m_hWndMDIClient | CMDIFrameLite |
m_hWndParent | CWndLite |
m_idSource | CMainWindow |
m_listTransactions | CMainWindow |
m_nID | CWndLite |
m_nNumImages | CMainWindow | [private]
m_pCDataLinks | CMainWindow |
m_pCFullConnect | CMainWindow |
m_pCListener | CMainWindow |
m_pCMDIObjects | CMainWindow |
m_pCMDITrace | CMainWindow |
m_pCOptionsSheet | CMainWindow |
m_pCRootBinder | CMainWindow |
m_pCRootEnumerator | CMainWindow |
m_pCServiceComp | CMainWindow |
m_pCSource | CMainWindow |
m_pEventCallback | CMainWindow | [private]
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
MDIActivate(HWND hWnd) | CMDIFrameLite | [inline, virtual]
MDIDestroy(HWND hWnd) | CMDIFrameLite | [inline, virtual]
OnAbort(CAsynchBase *pCAsynchBase) | CMainWindow | [virtual]
OnAbout() | CMainWindow | [virtual]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnAddRef(CBase *pCBase) | CMainWindow | [virtual]
OnAdvise(CConnectionPoint *pCConnectionPoint) | CMainWindow | [virtual]
OnArrangeIcons() | CMainWindow | [virtual]
OnAutoPosition() | CMDIFrameLite | [virtual]
OnAutoQI(CBase *pCBase) | CMainWindow | [virtual]
OnCascade() | CMainWindow | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CFrameWndLite | [virtual]
OnCloseAll() | CMainWindow | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CMainWindow | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CMDIFrameLite | [virtual]
OnConnect() | CMainWindow | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CMainWindow | [virtual]
CMDIFrameLite::OnCreate(CREATESTRUCT *pCREATESTRUCT) | CMDIFrameLite | [virtual]
OnCreateClient(CREATESTRUCT *pCREATESTRUCT) | CMDIFrameLite | [virtual]
OnCreateFileMoniker() | CMainWindow | [virtual]
OnDataLinks() | CMainWindow | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CMainWindow | [virtual]
OnDisconnect() | CMainWindow | [virtual]
OnDropFiles(HDROP hDrop) | CMainWindow | [virtual]
OnFindConnectionPoint(CContainerBase *pCCPointBase, REFIID riid) | CMainWindow | [virtual]
OnFromScannerOrCamera() | CMainWindow | [private]
OnGetConnectionInterface(CConnectionPoint *pCConnectionPoint) | CMainWindow | [virtual]
OnGetDataSource() | CMainWindow | [virtual]
OnGetStatus(CAsynchBase *pCAsynchBase) | CMainWindow | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialize(CAsynchBase *pCAsynchBase) | CMainWindow | [virtual]
OnInitialUpdate() | CMainWindow | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CMainWindow | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLoadRecentConfig(UINT iID) | CMainWindow | [virtual]
OnLoadRecentFile(UINT iID) | CMainWindow | [virtual]
OnLoadStringFromStorage(WCHAR *pwszFileName=NULL) | CMainWindow | [virtual]
OnMenuSelect(UINT uID) | CMainWindow | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNextWindow(BOOL fNextWindow) | CMainWindow | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CMDIFrameLite | [virtual]
OnObjectsWindow() | CMainWindow | [virtual]
OnOptions() | CMainWindow | [virtual]
OnPromptDataSource(BOOL fAdvanced=FALSE) | CMainWindow | [virtual]
OnPromptFileName(BOOL fAdvanced=FALSE) | CMainWindow | [virtual]
OnQueryInterface(CBase *pCBase) | CMainWindow | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRelease(CBase *pCBase) | CMainWindow | [virtual]
OnReleaseAll(CBase *pCBase, BOOL fChildren=FALSE) | CMainWindow | [virtual]
OnRootBinder() | CMainWindow | [virtual]
OnRootEnumerator() | CMainWindow | [virtual]
OnServiceComponents() | CMainWindow | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CMainWindow | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSupportErrorInfo(CBase *pCBase) | CMainWindow | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTile(BOOL fHorizontal) | CMainWindow | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnToolTip(INT idCtrl, NMHDR *pNMHDR) | CFrameWndLite | [virtual]
OnTraceWindow() | CMainWindow | [virtual]
OnUnadvise(CConnectionPoint *pCConnectionPoint) | CMainWindow | [virtual]
OnUninitialize(CAsynchBase *pCAsynchBase) | CMainWindow | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CMainWindow | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PreTranslateMessage(MSG *pmsg) | CMDIFrameLite | [virtual]
PromptDataSourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
PromptFileNameProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
QueryInterface(REFIID iid, LPVOID *ppvObj) | CMainWindow |
Register() | CMainWindow | [static]
RegisterProviderProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
RemoveAllChildren() | CMainWindow | [virtual]
SaveSettings() | CMainWindow | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
STDMETHOD_(ULONG, AddRef)() | CMainWindow |
STDMETHOD_(ULONG, Release)() | CMainWindow |
StreamViewerProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMainWindow | [static]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIFrameLite | [virtual]
UpdateControls() | CMainWindow | [virtual]
UpdateWindow() | CWndLite | [inline]
WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CMainWindow | [private, static]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CFrameWndLite() | CFrameWndLite | [virtual]
~CMainWindow() | CMainWindow | [virtual]
~CMDIFrameLite() | CMDIFrameLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFVClassFactory Member List

This is the complete list of members for CFVClassFactory, including all inherited members.
CFVClassFactory(void) | CFVClassFactory |
CreateInstance(LPUNKNOWN, REFIID, PPVOID) | CFVClassFactory |
LockServer(BOOL) | CFVClassFactory |
m_cRef | CFVClassFactory | [protected]
QueryInterface(REFIID, PPVOID) | CFVClassFactory |
STDMETHODIMP_(ULONG) AddRef(void) | CFVClassFactory |
STDMETHODIMP_(ULONG) Release(void) | CFVClassFactory |
~CFVClassFactory(void) | CFVClassFactory |
Generated on Wed Nov 13 2024 16:56:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsError/ADsError_i.c Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsError

ADsError_i.c

Go to the documentation of this file.
00001 /* this file contains the actual definitions of */
00002 /* the IIDs and CLSIDs */
00003
00004 /* link this file in with the server and any clients */
00005
00006
00007 /* File created by MIDL compiler version 5.01.0164 */
00008 /* at Tue Apr 13 15:05:07 1999
00009  */
00010 /* Compiler settings for C:\projects\RTK\ADsError\ADsError.idl:
00011     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00012     error checks: allocation ref bounds_check enum stub_data
00013 */
00014 //@@MIDL_FILE_HEADING(  )
00015 #ifdef __cplusplus
00016 extern "C"{
00017 #endif
00018
00019
00020 #ifndef __IID_DEFINED__
00021 #define __IID_DEFINED__
00022
00023 typedef struct _IID
00024 {
00025     unsigned long x;
00026     unsigned short s1;
00027     unsigned short s2;
00028     unsigned char  c[8];
00029 } IID;
00030
00031 #endif // __IID_DEFINED__
00032
00033 #ifndef CLSID_DEFINED
00034 #define CLSID_DEFINED
00035 typedef IID CLSID;
00036 #endif // CLSID_DEFINED
00037
00038 const IID IID_IADsError = {0x417D01DF,0xF1C6,0x11D2,{0xBC,0x88,0x00,0xC0,0x4F,0xD4,0x30,0xAF}};
00039
00040
00041 const IID LIBID_ADSERRORLib = {0x417D01D3,0xF1C6,0x11D2,{0xBC,0x88,0x00,0xC0,0x4F,0xD4,0x30,0xAF}};
00042
00043
00044 const CLSID CLSID_ADsError = {0x417D01E0,0xF1C6,0x11D2,{0xBC,0x88,0x00,0xC0,0x4F,0xD4,0x30,0xAF}};
00045
00046
00047 #ifdef __cplusplus
00048 }
00049 #endif
00050
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/Simple/Simple.c Source File

  • Begin
  • Simple

Simple.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 #include <stdio.h>
00013
00014 main()
00015
00016 {
00017 #ifdef JAPAN
00018         printf ("‚v‚‰‚Ž‚R‚QA‚±‚ê‚ÍŽ–Œ‚¾I");
00019 #else
00020         printf ("Win32, it's happenin'!");
00021 #endif
00022
00023         return(0);
00024 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAPIApp Member List

This is the complete list of members for CAPIApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAPIApp() | CAPIApp |
CAppLite(UINT nAppID) | CAppLite |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CAPIApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
OnAppAbout() | CAPIApp |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:55:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ADCPROP_AUTORECALC_ENUM Member List

This is the complete list of members for msado15::ADCPROP_AUTORECALC_ENUM, including all inherited members.
adRecalcAlways | msado15::ADCPROP_AUTORECALC_ENUM | [static]
adRecalcUpFront | msado15::ADCPROP_AUTORECALC_ENUM | [static]
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/Global.h Source File

  • WinUI
  • GlobalDev
  • CSSamp

Global.h

Go to the documentation of this file.
00001 ////    GLOBAL.H - Global variables for CSSAMP
00002 //
00003 //
00004
00005 ////    Constants
00006 //
00007 //
00008
00009 #define APPNAMEA   "CSSamp"
00010 #define APPTITLEA  "CSSamp - Uniscribe complex script sample application"
00011 #define APPNAMEW   L"CSSamp"
00012 #define APPTITLEW  L"CSSamp - Uniscribe complex script sample application"
00013
00014 const int MAX_STYLES = 5;      // Better implementation would use dynamic memory
00015 const int MAX_TEXT   = 10000;  // Buffer size in Unicode characters
00016
00017 const int CARET_SECTION_LOGICAL    = 0;
00018 const int CARET_SECTION_PLAINTEXT  = 1;
00019 const int CARET_SECTION_FORMATTED  = 2;
00020
00021 ////    RUN - A run of characters with similar attributes
00022 //
00023 //
00024 struct RUN {
00025     struct RUN       *pNext;
00026     int               iLen;
00027     int               iStyle;       // Index to style sheet (global 'g_style').
00028     SCRIPT_ANALYSIS   analysis;     // Uniscribe analysis
00029 };
00030
00031 ////    STYLE - Text attribute
00032 //
00033 struct STYLE {
00034     HFONT         hf;       // Handle to font described by lf
00035     SCRIPT_CACHE  sc;       // Uniscribe cache associated with this style
00036 };
00037
00038 ////    Global variables
00039 //
00040 //
00041 #ifdef GLOBALS_HERE
00042 #define GLOBAL
00043 #define GLOBALINIT(a) = a
00044 #else
00045 #define GLOBAL extern
00046 #define GLOBALINIT(a)
00047 #endif
00048
00049
00050 GLOBAL  HINSTANCE       g_hInstance         GLOBALINIT(NULL);  // The one and only instance
00051 GLOBAL  HWND            g_hSettingsDlg      GLOBALINIT(NULL);  // Settings panel
00052 GLOBAL  HWND            g_hTextWnd          GLOBALINIT(NULL);  // Text display/editing panel
00053 GLOBAL  BOOL            g_bUnicodeWnd       GLOBALINIT(FALSE); // If text window is Unicode
00054 GLOBAL  int             g_iSettingsWidth;
00055 GLOBAL  int             g_iSettingsHeight;
00056 GLOBAL  BOOL            g_fPresentation     GLOBALINIT(FALSE); // Hide settings, show text very large
00057 GLOBAL  BOOL            g_fShowLevels       GLOBALINIT(FALSE); // Show bidi levels for each codepoint
00058 GLOBAL  int             g_iMinWidth;                           // Main window minimum size
00059 GLOBAL  int             g_iMinHeight;
00060
00061 GLOBAL  BOOL            g_fOverrideDx       GLOBALINIT(FALSE);  // Provide UI for changing logical widths
00062 GLOBAL  BOOL            g_fFillLines        GLOBALINIT(TRUE);
00063
00064 GLOBAL  SCRIPT_CONTROL  g_ScriptControl     GLOBALINIT({0});
00065 GLOBAL  SCRIPT_STATE    g_ScriptState       GLOBALINIT({0});
00066 GLOBAL  BOOL            g_fNullState        GLOBALINIT(FALSE);
00067
00068 GLOBAL  BOOL            g_fLogicalOrder     GLOBALINIT(FALSE);
00069 GLOBAL  BOOL            g_fNoGlyphIndex     GLOBALINIT(FALSE);
00070
00071 GLOBAL  BOOL            g_fShowLogical      GLOBALINIT(TRUE);
00072 GLOBAL  BOOL            g_fShowWidths       GLOBALINIT(FALSE);
00073 GLOBAL  BOOL            g_fShowStyles       GLOBALINIT(FALSE);
00074
00075 GLOBAL  BOOL            g_fShowPlainText    GLOBALINIT(TRUE);
00076 GLOBAL  DWORD           g_dwSSAflags        GLOBALINIT(SSA_FALLBACK);
00077
00078 GLOBAL  BOOL            g_fShowFancyText    GLOBALINIT(TRUE);
00079 GLOBAL  STYLE           g_style[MAX_STYLES];                    // 0 for plaintext, 1-4 for formatted text
00080
00081
00082
00083 GLOBAL  WCHAR           g_wcBuf[MAX_TEXT];
00084 GLOBAL  int             g_iWidthBuf[MAX_TEXT];
00085
00086 GLOBAL  RUN            *g_pFirstFormatRun   GLOBALINIT(NULL);   // Formatting info
00087
00088 GLOBAL  int             g_iTextLen          GLOBALINIT(0);
00089
00090 GLOBAL  int             g_iCaretX           GLOBALINIT(0);      // Caret position in text window
00091 GLOBAL  int             g_iCaretY           GLOBALINIT(0);      // Caret position in text window
00092 GLOBAL  int             g_iCaretHeight      GLOBALINIT(0);      // Caret height in pixels
00093 GLOBAL  int             g_fUpdateCaret      GLOBALINIT(TRUE);   // Caret requires updating
00094
00095 GLOBAL  int             g_iCaretSection     GLOBALINIT(CARET_SECTION_LOGICAL);  // Whether caret is in logical, plain or formatted text
00096 GLOBAL  int             g_iCurChar          GLOBALINIT(0);      // Caret sits on leading edge of buffer[iCurChar]
00097
00098 GLOBAL  int             g_iMouseDownX       GLOBALINIT(0);
00099 GLOBAL  int             g_iMouseDownY       GLOBALINIT(0);
00100 GLOBAL  BOOL            g_fMouseDown        GLOBALINIT(FALSE);
00101 GLOBAL  int             g_iMouseUpX         GLOBALINIT(0);
00102 GLOBAL  int             g_iMouseUpY         GLOBALINIT(0);
00103 GLOBAL  BOOL            g_fMouseUp          GLOBALINIT(FALSE);
00104
00105 GLOBAL  int             g_iFrom             GLOBALINIT(0);      // Highlight start
00106 GLOBAL  int             g_iTo               GLOBALINIT(0);      // Highlight end
00107
00108
00109 GLOBAL  HFONT           g_hfCaption         GLOBALINIT(NULL);   // Caption font
00110 GLOBAL  int             g_iLogPixelsY       GLOBALINIT(0);
00111
00112
00113 ////    Function prototypes
00114 //
00115 //
00116
00117 // DspLogcl.cpp
00118 void PaintLogical(
00119     HDC   hdc,
00120     int  *piY,
00121     RECT *prc,
00122     int   iLineHeight);
00123
00124 // DspPlain.cpp
00125 void PaintPlainText(
00126     HDC   hdc,
00127     int  *piY,
00128     RECT *prc,
00129     int   iLineHeight);
00130
00131 //  DspFormt.cpp
00132 void PaintFormattedText(
00133     HDC   hdc,
00134     int  *piY,
00135     RECT *prc,
00136     int   iLineHeight);
00137
00138 // Setting.cpp
00139 INT_PTR CALLBACK SettingsDlgProc(
00140         HWND    hDlg,
00141         UINT    uMsg,
00142         WPARAM  wParam,
00143         LPARAM  lParam);
00144
00145
00146 // Text.cpp
00147 void InitText();
00148
00149 BOOL TextInsert(
00150     int   iPos,
00151     PWCH  pwc,
00152     int   iLen);
00153
00154 BOOL TextDelete(
00155     int iPos,
00156     int iLen);
00157
00158 // TextWnd.cpp
00159 HWND CreateTextWindow();
00160
00161 void ResetCaret(int iX, int iY, int iHeight);
00162
00163 LRESULT CALLBACK TextWndProc(
00164         HWND    hWnd,
00165         UINT    uMsg,
00166         WPARAM  wParam,
00167         LPARAM  lParam);
00168
00169 void InvalidateText();
00170
00171 // Edit.cpp
00172 BOOL EditChar(WCHAR wc);
00173 BOOL EditKeyDown(WCHAR wc);
00174 void EditFreeCaches();
00175 void EditInsertUnicode();
00176
00177 // Style.cpp
00178 void SetStyle(
00179     int     iStyle,
00180     int     iHeight,
00181     int     iWeight,
00182     int     iItalic,
00183     int     iUnderline,
00184     char   *pcFaceName);
00185
00186 void InitStyles();
00187
00188 void FreeStyles();
00189
00190 void SetLogFont(
00191     PLOGFONTA   plf,
00192     int         iHeight,
00193     int         iWeight,
00194     int         iItalic,
00195     int         iUnderline,
00196     char       *pcFaceName);
00197
00198 void StyleDeleteRange(
00199     int     iDelPos,
00200     int     iDelLen);
00201
00202 void StyleExtendRange(
00203     int     iExtPos,
00204     int     iExtLen);
00205
00206 void StyleSetRange(
00207     int    iSetStyle,
00208     int    iSetPos,
00209     int    iSetLen);
00210
00211 BOOL StyleCheckRange();
00212
00213 // Debugging support
00214 #define TRACEMSG(a)   {DG.psFile=__FILE__; DG.iLine=__LINE__; DebugMsg a;}
00215 #define ASSERT(a)     {if (!(a)) TRACEMSG(("Assertion failure: "#a));}
00216 #define ASSERTS(a,b)  {if (!(a)) TRACEMSG(("Assertion failure: "#a" - "#b));}
00217 #define ASSERTHR(a,b) {if (!SUCCEEDED(a)) {DG.psFile=__FILE__; \
00218                         DG.iLine=__LINE__; DG.hrLastError=a; DebugHr b;}}
00219
00220 ///     Debug variables
00221 //
00222 struct DebugGlobals {
00223     char   *psFile;
00224     int     iLine;
00225     HRESULT hrLastError;        // Last hresult from GDI
00226     CHAR    sLastError[100];    // Last error string
00227 };
00228
00229 ///     Debug function prototypes
00230 //
00231 extern "C" void WINAPIV DebugMsg(char *fmt, ...);
00232 extern "C" void WINAPIV DebugHr(char *fmt, ...);
00233
00234 GLOBAL DebugGlobals DG   GLOBALINIT({0});
00235 GLOBAL UINT debug        GLOBALINIT(0);
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/RealTimeStylusPlugin/C#/AssemblyInfo.cs Source File

  • TabletPC
  • RealTimeStylusPlugin
  • C#

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("RealTimeStylusPlugin Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2004 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 //[assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 //[assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/ADsOpenDSObject.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

ADsOpenDSObject.cpp

Go to the documentation of this file.
00001
00002
00003 //----------------------------------------------------------------------------
00004 //
00005 //  Microsoft Active Directory 2.5 Sample Code
00006 //
00007 //  Copyright (C) Microsoft Corporation, 1996 - 2000
00008 //
00009 //  File:       ADsOpenDSObject.cpp
00010 //
00011 //  Contents:   IADsOpenDSObject and ADsOpenObject usage
00012 //
00013 //
00014 //----------------------------------------------------------------------------
00015
00016
00017 #include "stdafx.h"
00018 #include "ADQI.h"
00019 #include "ADsOpenDSObject.h"
00020
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026
00027
00028 void DlgProcIADsOpenDSObject( LPUNKNOWN pUnk, LPUNKNOWN *ppNew)
00029 {
00030    CDlgIADsOpenDSObject dlg( pUnk, ppNew );
00031    dlg.DoModal();
00032 }
00033
00034
00035 /////////////////////////////////////////////////////////////////////////////
00036 // CDlgIADsOpenDSObject dialog
00037
00038
00039 CDlgIADsOpenDSObject::CDlgIADsOpenDSObject( LPUNKNOWN pUnk, LPUNKNOWN *ppNew, CWnd* pParent /*=NULL*/)
00040   : CDialog(CDlgIADsOpenDSObject::IDD, pParent)
00041 {
00042   //{{AFX_DATA_INIT(CDlgIADsOpenDSObject)
00043   m_sPassword = _T("");
00044   m_sUserName = _T("");
00045   m_bEncrypt = FALSE;
00046   m_bReadOnly = FALSE;
00047   m_bSecured = FALSE;
00048   m_bPrompt = FALSE;
00049   m_bNoAuthentication = FALSE;
00050   m_sADsPath = _T("");
00051   m_bClearText = FALSE;
00052   m_bFastBind = FALSE;
00053   m_bSealing = FALSE;
00054   m_bSigning = FALSE;
00055   //}}AFX_DATA_INIT
00056
00057   HRESULT hr;
00058   m_pOpenDS = NULL;
00059   m_ppUnk = ppNew;
00060
00061
00062   hr = pUnk->QueryInterface( IID_IADsOpenDSObject, (void **) &m_pOpenDS );
00063   if ( !SUCCEEDED(hr) )
00064   {
00065     // Give warning... ADsOpenObject has the same functionality as IADsOpenDSObject,
00066     // the only different is the IADsOpenDSObject normally lives on the namespace object
00067     AfxMessageBox(_T("Warning: QI for IADsOpenDSObject failed, we will use ADsOpenObject()"));
00068   }
00069
00070
00071
00072   CComPtr<IADs> pADs=NULL;
00073   BSTR bstr;
00074   hr = pUnk->QueryInterface( IID_IADs, (void**) &pADs );
00075   if ( SUCCEEDED(hr) )
00076   {
00077     pADs->get_ADsPath( &bstr );
00078     m_sADsPath = bstr;
00079         SysFreeString( bstr );
00080   }
00081
00082   pUnk->Release();
00083
00084
00085
00086
00087
00088
00089 }
00090
00091 CDlgIADsOpenDSObject::~CDlgIADsOpenDSObject()
00092 {
00093   if ( m_pOpenDS )
00094   {
00095     m_pOpenDS->Release();
00096   }
00097
00098 }
00099
00100 void CDlgIADsOpenDSObject::DoDataExchange(CDataExchange* pDX)
00101 {
00102   CDialog::DoDataExchange(pDX);
00103   //{{AFX_DATA_MAP(CDlgIADsOpenDSObject)
00104   DDX_Text(pDX, IDC_PASSWORD, m_sPassword);
00105   DDX_Text(pDX, IDC_USERNAME, m_sUserName);
00106   DDX_Check(pDX, IDC_ENCRYPT, m_bEncrypt);
00107   DDX_Check(pDX, IDC_READONLY, m_bReadOnly);
00108   DDX_Check(pDX, IDC_SECURED, m_bSecured);
00109   DDX_Check(pDX, IDC_PROMPTCREDENTIAL, m_bPrompt);
00110   DDX_Check(pDX, IDC_NOAUTHENTICATION, m_bNoAuthentication);
00111   DDX_Text(pDX, IDC_ADSPATH, m_sADsPath);
00112   DDX_Check(pDX, IDC_CLEARTEXT, m_bClearText);
00113   DDX_Check(pDX, IDC_FASTBIND, m_bFastBind);
00114   DDX_Check(pDX, IDC_SEALING, m_bSealing);
00115   DDX_Check(pDX, IDC_SIGNING, m_bSigning);
00116   //}}AFX_DATA_MAP
00117 }
00118
00119
00120 BEGIN_MESSAGE_MAP(CDlgIADsOpenDSObject, CDialog)
00121   //{{AFX_MSG_MAP(CDlgIADsOpenDSObject)
00122   ON_EN_CHANGE(IDC_USERNAME, OnChangeUsername)
00123   ON_EN_CHANGE(IDC_ADSPATH, OnChangeADsPath)
00124   //}}AFX_MSG_MAP
00125 END_MESSAGE_MAP()
00126
00127 /////////////////////////////////////////////////////////////////////////////
00128 // CDlgIADsOpenDSObject message handlers
00129
00130 void CDlgIADsOpenDSObject::OnOK()
00131 {
00132   HRESULT hr;
00133   DWORD dwFlag;
00134
00135   UpdateData(TRUE);
00136
00137
00138   dwFlag = 0;
00139   if ( m_bSecured )
00140   {
00141      dwFlag |=  ADS_SECURE_AUTHENTICATION;
00142   }
00143
00144   if ( m_bReadOnly )
00145   {
00146      dwFlag |= ADS_READONLY_SERVER;
00147   }
00148
00149   if ( m_bEncrypt )
00150   {
00151     dwFlag |=   ADS_USE_ENCRYPTION;
00152   }
00153
00154   if ( m_bPrompt )
00155   {
00156     dwFlag |= ADS_PROMPT_CREDENTIALS;
00157   }
00158
00159   if ( m_bNoAuthentication )
00160   {
00161     dwFlag = ADS_NO_AUTHENTICATION;
00162   }
00163
00164   if ( m_bFastBind )
00165   {
00166     dwFlag |= ADS_FAST_BIND;
00167   }
00168
00169   if ( m_bSigning )
00170   {
00171     dwFlag |= ADS_USE_SIGNING;
00172   }
00173
00174   if ( m_bSealing )
00175   {
00176     dwFlag |= ADS_USE_SEALING;
00177   }
00178
00179
00180
00181   USES_CONVERSION;
00182   LPWSTR pszUser=NULL;
00183   LPWSTR pszPwd=NULL;
00184   IUnknown *pNewUnk;
00185
00186   if ( !m_sUserName.IsEmpty() )
00187   {
00188     pszUser = T2OLE(m_sUserName);
00189   }
00190
00191   pszPwd  = T2OLE(m_sPassword);
00192
00193
00194
00195   if ( pszUser == NULL )
00196   {
00197     hr = ADsGetObject( T2OLE(m_sADsPath), IID_IUnknown, (void**) &pNewUnk );
00198   }
00199   else
00200   {
00201     if ( m_pOpenDS )
00202     {
00203
00204         hr = m_pOpenDS->OpenDSObject( T2OLE(m_sADsPath), pszUser, pszPwd,
00205                                       dwFlag, (IDispatch**) &pNewUnk );
00206
00207     }
00208     else
00209     {
00210       hr = ADsOpenObject( T2OLE(m_sADsPath), pszUser, pszPwd,
00211                           dwFlag, IID_IUnknown, (void**) &pNewUnk );
00212
00213     }
00214   }
00215
00216
00217
00218   if ( !SUCCEEDED(hr) )
00219   {
00220     AfxMessageBox(GetErrorMessage(hr));
00221     return;
00222   }
00223
00224   //////////////////////////////////////////////////////////////////////
00225   // Save it so, somebody can ask the pointer with its credentials have
00226   // been validated
00227   ////////////////////////////////////////////////////////////////////
00228
00229   if (SUCCEEDED(hr) )
00230   {
00231     *m_ppUnk = pNewUnk;  // new validate iunkown;
00232     ////////////////////////////////////////////////////////////
00233     // IMPORTANT!!: DO NOT SAVE THE PASSWORD IN MEMORY
00234     ///////////////////////////////////////////////////////////
00235     if ( pszUser )
00236     {
00237       App->SetCredentials( OLE2T(pszUser), dwFlag ); // save it for later use
00238     }
00239     else
00240     {
00241       App->SetCredentials( _T(""), dwFlag ); // save it for later use
00242     }
00243
00244
00245   }
00246
00247
00248   CDialog::OnOK();
00249 }
00250
00251
00252
00253 void CDlgIADsOpenDSObject::OnChangeUsername()
00254 {
00255
00256   BOOL bADsLength;
00257
00258   //////////////////////////////////////////////////////////////
00259   // Turn off/on the OK button depending if ADsPath Edit box is filled.
00260   //////////////////////////////////////////////////////////////////////
00261
00262   bADsLength  = GetDlgItem(IDC_ADSPATH)->GetWindowTextLength() > 0 ? TRUE : FALSE;
00263
00264   GetDlgItem( IDOK )->EnableWindow( bADsLength );
00265 }
00266
00267
00268 void CDlgIADsOpenDSObject::OnChangeADsPath()
00269 {
00270    OnChangeUsername();
00271 }
00272
00273
00274 BOOL CDlgIADsOpenDSObject::OnInitDialog()
00275 {
00276   CDialog::OnInitDialog();
00277
00278   // Get the current DN;
00279     OnChangeUsername();
00280
00281
00282   UpdateData(FALSE); // update to relect the UI
00283   return TRUE;  // return TRUE unless you set the focus to a control
00284                 // EXCEPTION: OCX Property Pages should return FALSE
00285 }
00286
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/enumtask.Cpp Source File

  • SysMgmt
  • MMC
  • Taskpads

enumtask.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 //
00020 // EnumTASK.cpp: implementation of the CEnumTASK class.
00021 //
00022 //////////////////////////////////////////////////////////////////////
00023
00024 #include "EnumTASK.h"
00025
00026 //////////////////////////////////////////////////////////////////////
00027 // Construction/Destruction
00028 //////////////////////////////////////////////////////////////////////
00029
00030 CEnumTASK::CEnumTASK(MMC_TASK *pTaskList, ULONG nTasks)
00031     : m_pTaskList(pTaskList), m_TaskCount(nTasks), m_CurrTask(0)
00032 {
00033 }
00034
00035 CEnumTASK::~CEnumTASK()
00036 {
00037     if (m_pTaskList)
00038         delete [] m_pTaskList;
00039 }
00040
00041 STDMETHODIMP CEnumTASK::QueryInterface(REFIID riid, LPVOID *ppv)
00042 {
00043     if (!ppv)
00044         return E_FAIL;
00045
00046     *ppv = NULL;
00047
00048     if (IsEqualIID(riid, IID_IUnknown))
00049         *ppv = static_cast<IEnumTASK *>(this);
00050     else if (IsEqualIID(riid, IID_IEnumTASK))
00051         *ppv = static_cast<IEnumTASK *>(this);
00052
00053     if (*ppv)
00054     {
00055         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00056         return S_OK;
00057     }
00058
00059     return E_NOINTERFACE;
00060 }
00061
00062 STDMETHODIMP_(ULONG) CEnumTASK::AddRef()
00063 {
00064     return InterlockedIncrement((LONG *)&m_cref);
00065 }
00066
00067 STDMETHODIMP_(ULONG) CEnumTASK::Release()
00068 {
00069     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00070     {
00071         delete this;
00072         return 0;
00073     }
00074     return m_cref;
00075
00076 }
00077
00078 HRESULT CEnumTASK::Next(
00079     /* [in] */ ULONG celt,
00080     /* [length_is][size_is][out] */ MMC_TASK __RPC_FAR *rgelt,
00081     /* [out] */ ULONG __RPC_FAR *pceltFetched)
00082 {
00083     *pceltFetched = 0;
00084
00085   if (m_CurrTask < m_TaskCount) {
00086     if (rgelt != NULL) {
00087       CopyMemory(rgelt, &m_pTaskList[m_CurrTask++], sizeof(MMC_TASK));
00088       *pceltFetched = 1;
00089     }
00090   }
00091
00092     return (*pceltFetched != 0) ? S_OK : S_FALSE;
00093 }
00094
00095 HRESULT CEnumTASK::Skip(
00096     /* [in] */ ULONG celt)
00097 {
00098     return E_NOTIMPL;
00099 }
00100
00101 HRESULT CEnumTASK::Reset( void)
00102 {
00103     m_CurrTask = 0;
00104
00105     return S_OK;
00106 }
00107
00108 HRESULT CEnumTASK::Clone(
00109     /* [out] */ IEnumTASK __RPC_FAR *__RPC_FAR *ppenum)
00110 {
00111     return E_NOTIMPL;
00112 }
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/ids.Cpp Source File

  • Com
  • Fundamentals
  • SimpDnd

ids.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IDS.CPP
00003 //
00004 //      Implementation file for CDropSource
00005 //
00006 // Functions:
00007 //
00008 //      See IDS.H for class definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "doc.h"
00015 #include "site.h"
00016 #include "dxferobj.h"
00017
00018
00019 //**********************************************************************
00020 //
00021 // CSimpleDoc::QueryDrag
00022 //
00023 // Purpose:
00024 //
00025 //      Check to see if Drag operation should be initiated based on the
00026 //      current position of the mouse.
00027 //
00028 // Parameters:
00029 //
00030 //      POINT pt                - position of mouse
00031 //
00032 // Return Value:
00033 //
00034 //      BOOL                    - TRUE if drag should take place,
00035 //                                else FALSE
00036 //
00037 // Function Calls:
00038 //      Function                    Location
00039 //
00040 //      CSimpleSite::GetObjRect     SITE.CPP
00041 //      PtInRect                    Windows API
00042 //
00043 // Comments:
00044 //
00045 //********************************************************************
00046
00047 BOOL CSimpleDoc::QueryDrag(POINT pt)
00048 {
00049   // if pt is within rect of object, then start drag
00050   if (m_lpSite)
00051     {
00052     RECT rect;
00053     m_lpSite->GetObjRect(&rect);
00054     return ( PtInRect(&rect, pt) ? TRUE : FALSE );
00055     }
00056   else
00057     return FALSE;
00058 }
00059
00060
00061 //**********************************************************************
00062 //
00063 // CSimpleDoc::DoDragDrop
00064 //
00065 // Purpose:
00066 //
00067 //      Actually perform a drag/drop operation with the current
00068 //      selection in the source document.
00069 //
00070 // Parameters:
00071 //
00072 //      none.
00073 //
00074 // Return Value:
00075 //
00076 //      DWORD                    - returns the result effect of the
00077 //                                 drag/drop operation:
00078 //                                      DROPEFFECT_NONE,
00079 //                                      DROPEFFECT_COPY,
00080 //                                      DROPEFFECT_MOVE, or
00081 //                                      DROPEFFECT_LINK
00082 //
00083 // Function Calls:
00084 //      Function                    Location
00085 //
00086 //      CDataXferObj::Create        DXFEROBJ.CPP
00087 //      CDataXferObj::QueryInterface DXFEROBJ.CPP
00088 //      CDataXferObj::Release       DXFEROBJ.CPP
00089 //      DoDragDrop                  OLE API
00090 //      OutputDebugString           Windows API
00091 //
00092 // Comments:
00093 //
00094 //********************************************************************
00095
00096 DWORD CSimpleDoc::DoDragDrop (void)
00097 {
00098   DWORD       dwEffect     = 0;
00099   LPDATAOBJECT lpDataObj;
00100
00101   OutputDebugString("In CSimpleDoc::DoDragDrop\r\n");
00102
00103   // Create a data transfer object by cloning the existing OLE object
00104   CDataXferObj FAR* pDataXferObj = CDataXferObj::Create(m_lpSite,NULL);
00105
00106   if (! pDataXferObj) {
00107     MessageBox(NULL,"Out-of-memory","SimpDnD",MB_SYSTEMMODAL|MB_ICONHAND);
00108     return DROPEFFECT_NONE;
00109   }
00110
00111   // initially obj is created with 0 refcnt. this QI will make it go to 1.
00112   pDataXferObj->QueryInterface(IID_IDataObject, (LPVOID FAR*)&lpDataObj);
00113   assert(lpDataObj);
00114
00115   m_fLocalDrop     = FALSE;
00116   m_fLocalDrag     = TRUE;
00117
00118 	::DoDragDrop ( lpDataObj,
00119          &m_DropSource,
00120          DROPEFFECT_COPY,   // we only allow copy
00121          &dwEffect
00122   );
00123
00124   m_fLocalDrag     = FALSE;
00125
00126   /* if after the Drag/Drop modal (mouse capture) loop is finished
00127   **    and a drag MOVE operation was performed, then we must delete
00128   **    the selection that was dragged.
00129   */
00130   if ( (dwEffect & DROPEFFECT_MOVE) != 0 ) {
00131     // ... delete source object here (we do NOT support MOVE)
00132   }
00133
00134   pDataXferObj->Release();    // this should destroy the DataXferObj
00135   return dwEffect;
00136 }
00137
00138
00139
00140 //**********************************************************************
00141 //
00142 // CDropSource::QueryInterface
00143 //
00144 // Purpose:
00145 //
00146 //      Return a pointer to a requested interface
00147 //
00148 // Parameters:
00149 //
00150 //      REFIID riid         -   ID of interface to be returned
00151 //      LPVOID FAR* ppvObj  -   Location to return the interface
00152 //
00153 // Return Value:
00154 //
00155 //      S_OK                -   Interface supported
00156 //      E_NOINTERFACE       -   Interface NOT supported
00157 //
00158 // Function Calls:
00159 //      Function                    Location
00160 //
00161 //      OutputDebugString           Windows API
00162 //      CSimpleDoc::QueryInterface  DOC.CPP
00163 //
00164 // Comments:
00165 //
00166 //********************************************************************
00167
00168 STDMETHODIMP CDropSource::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00169 {
00170   OutputDebugString("In IDS::QueryInterface\r\n");
00171
00172   // delegate to the document
00173   return m_pDoc->QueryInterface(riid, ppvObj);
00174 }
00175
00176
00177 //**********************************************************************
00178 //
00179 // CDropSource::AddRef
00180 //
00181 // Purpose:
00182 //
00183 //      Increments the reference count on this interface
00184 //
00185 // Parameters:
00186 //
00187 //      None
00188 //
00189 // Return Value:
00190 //
00191 //      The current reference count on this interface.
00192 //
00193 // Function Calls:
00194 //      Function                    Location
00195 //
00196 //      CSimpleObj::AddReff         OBJ.CPP
00197 //      OutputDebugString           Windows API
00198 //
00199 // Comments:
00200 //
00201 //      This function adds one to the ref count of the interface,
00202 //      and calls then calls CSimpleDoc to increment its ref.
00203 //      count.
00204 //
00205 //********************************************************************
00206
00207 STDMETHODIMP_(ULONG) CDropSource::AddRef()
00208 {
00209   OutputDebugString("In IDS::AddRef\r\n");
00210
00211   // increment the interface reference count (for debugging only)
00212   ++m_nCount;
00213
00214   // delegate to the document Object
00215   return m_pDoc->AddRef();
00216 }
00217
00218 //**********************************************************************
00219 //
00220 // CDropSource::Release
00221 //
00222 // Purpose:
00223 //
00224 //      Decrements the reference count on this interface
00225 //
00226 // Parameters:
00227 //
00228 //      None
00229 //
00230 // Return Value:
00231 //
00232 //      The current reference count on this interface.
00233 //
00234 // Function Calls:
00235 //      Function                    Location
00236 //
00237 //      CSimpleObj::Release         OBJ.CPP
00238 //      OutputDebugString           Windows API
00239 //
00240 // Comments:
00241 //
00242 //      This function subtracts one from the ref count of the interface,
00243 //      and calls then calls CSimpleDoc to decrement its ref.
00244 //      count.
00245 //
00246 //********************************************************************
00247
00248 STDMETHODIMP_(ULONG) CDropSource::Release()
00249 {
00250   OutputDebugString("In IDS::Release\r\n");
00251
00252   // decrement the interface reference count (for debugging only)
00253   --m_nCount;
00254
00255   // delegate to the document object
00256   return m_pDoc->Release();
00257 }
00258
00259 //**********************************************************************
00260 //
00261 // CDropSource::QueryContinueDrag
00262 //
00263 // Purpose:
00264 //
00265 //      Called to determine if a drop should take place or be canceled.
00266 //
00267 // Parameters:
00268 //
00269 //      BOOL fEscapePressed - TRUE if ESCAPE key has been pressed
00270 //      DWORD grfKeyState   - key state
00271 //
00272 // Return Value:
00273 //
00274 //      DRAGDROP_S_CANCEL   - drag operation should be canceled
00275 //      DRAGDROP_S_DROP     - drop operation should be performed
00276 //      S_OK                - dragging should continue
00277 //
00278 //
00279 // Function Calls:
00280 //      Function                    Location
00281 //
00282 //                   OLE API
00283 //
00284 // Comments:
00285 //
00286 //********************************************************************
00287
00288 STDMETHODIMP CDropSource::QueryContinueDrag (
00289     BOOL    fEscapePressed,
00290     DWORD   grfKeyState
00291 )
00292 {
00293   if (fEscapePressed)
00294     return DRAGDROP_S_CANCEL;
00295   else if (!(grfKeyState & MK_LBUTTON))
00296     return DRAGDROP_S_DROP;
00297   else
00298     return NOERROR;
00299 }
00300
00301
00302 //**********************************************************************
00303 //
00304 // CDropSource::GiveFeedback
00305 //
00306 // Purpose:
00307 //
00308 //      Called to set cursor feedback
00309 //
00310 // Parameters:
00311 //
00312 //      DWORD dwEffect      - drop operation to give feedback for
00313 //
00314 // Return Value:
00315 //
00316 //      DRAGDROP_S_USEDEFAULTCURSORS  - tells OLE to use standard cursors
00317 //
00318 // Function Calls:
00319 //      Function                    Location
00320 //
00321 //                   OLE API
00322 //
00323 // Comments:
00324 //
00325 //********************************************************************
00326
00327 STDMETHODIMP CDropSource::GiveFeedback (DWORD dwEffect)
00328 {
00329   return DRAGDROP_S_USEDEFAULTCURSORS;
00330 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/HttpAuth/Get_Sock.c Source File

  • Security
  • SSPI
  • HttpAuth

Get_Sock.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 Module Name:
00011
00012     get_sock.c
00013
00014 Abstract:
00015
00016     This does a get using raw sockets
00017
00018 --*/
00019
00020 #include <windows.h>
00021 #include <winsock.h>
00022
00023 #include <stdio.h>
00024 #include <stdarg.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 #include <tchar.h>
00028 #include <io.h>
00029 #include <fcntl.h>
00030 #include <sys/types.h>
00031 #include <sys/stat.h>
00032
00033 #include "httpauth.h"
00034
00035 // globals
00036
00037 #define HD_AUTHENTICATE         "WWW-Authenticate:"
00038 #define HD_LENGTH               "Content-Length:"
00039 #define HD_CONNECTION           "Connection:"
00040
00041 // list of Authentication methods to support
00042
00043 char      achAuth[256];
00044
00045
00046 // Helper functions
00047
00048 void SkipWhite(PSTR *ppS )
00049 {
00050     PSTR pS = *ppS;
00051
00052     while ( *pS && isspace(*pS) )
00053         ++pS;
00054
00055     *ppS = pS;
00056 }
00057
00058
00059 void SkipNonWhite(PSTR *ppS )
00060 {
00061     PSTR pS = *ppS;
00062
00063     while ( *pS && !isspace(*pS) )
00064         ++pS;
00065
00066     *ppS = pS;
00067 }
00068
00069
00070
00071 BOOL
00072 HttpGetSocket(
00073     char * Verb,
00074     char * Server,
00075     char * URL,
00076     BOOL   DisplayHeaders,
00077     DWORD  ClientDataSize,
00078     PSTR   pchUserName,
00079     PSTR   pchPassword,
00080     PSTR   pszStore,
00081     PSTR   pszPref
00082     )
00083 /*++
00084
00085  Routine Description:
00086
00087     Issue a command to a HTTP server using authentication
00088
00089  Arguments:
00090
00091     Verb                HTTP command : GET / HEAD / ...
00092     Server              server name
00093     URL                 URL to send to the server
00094     DisplayHeaders      TRUE to display headers as received
00095     ClientDataSize      number of bytes to send in the request
00096     pchUserName         user name for authentication
00097     pchPassword         password for authentication
00098     pszStore            file name where to dump reply from server
00099
00100  Return Value:
00101
00102     Returns TRUE is successful; otherwise FALSE is returned.
00103
00104 --*/
00105 {
00106     char               ReceiveBuffer[8*1024];
00107     int                Error;
00108     BYTE               Request[1024];
00109     int                RequestSize;
00110     char *             AcceptTypes[2] = {"*/*", NULL};
00111     SOCKET             Socket = INVALID_SOCKET;
00112     WSADATA            WsaData;
00113     struct sockaddr_in Address;
00114     struct hostent *   HostEntry;
00115     char               Headers[] =
00116                            "HTTP/1.0\r\n"
00117                            "User-Agent: AuthClient\r\n"
00118                            "Accept: */*\r\n";
00119     char               CrLf[] = "\r\n";
00120     BYTE               ClientData[64*1024];
00121     BOOL               fKeepAlive = FALSE;
00122     int                cRec;
00123     DWORD              cLen;
00124     BOOL               fInHeader;
00125     PSTR               pchAuthData;
00126     BOOL               fServerKeepAlive = FALSE;
00127     BOOL               fNeedMoreData;
00128     BOOL               fNeedAuthenticate;
00129     PSTR               pH;
00130     PSTR               pN;
00131     BOOL               fStatusLine;
00132     int                Status = -1;
00133     DWORD              cToRead;
00134     PSTR               paAuth = achAuth;
00135     BOOL               fSt = FALSE;
00136     int                hnd = EOF;
00137
00138     Error = WSAStartup (0x101, &WsaData);
00139
00140     if (Error == SOCKET_ERROR)
00141     {
00142         fprintf(stderr, "Error in WSAStartup = %d\n", GetLastError());
00143         return FALSE;
00144     }
00145
00146     if ( !InitAuthorizationHeader() )
00147     {
00148         fprintf(stderr, "Cannot initialize security module\n" );
00149         return FALSE;
00150     }
00151
00152     memset( achAuth, '\0', sizeof(achAuth) );
00153     pchAuthData = NULL;
00154     fNeedAuthenticate = FALSE;
00155
00156     //
00157     // Connect to the server
00158     //
00159
00160     if  ( pszStore != NULL )
00161         if ( (hnd = _open( pszStore, _O_BINARY | _O_CREAT | _O_TRUNC | _O_RDWR, S_IREAD|S_IWRITE )) == EOF )
00162         {
00163             fprintf( stderr, "Can't create file %s\n", pszStore );
00164             return FALSE;
00165         }
00166
00167 again:
00168
00169     if ( Socket == INVALID_SOCKET )
00170     {
00171         Socket = socket(AF_INET, SOCK_STREAM, 0);
00172
00173         if (Socket == INVALID_SOCKET)
00174         {
00175             fprintf(stderr, "Error creating socket = %d\n", GetLastError());
00176             fSt = FALSE;
00177             goto ex;
00178         }
00179
00180         Address.sin_family = AF_INET;
00181         Address.sin_port = 0;
00182         Address.sin_addr.s_addr = INADDR_ANY;
00183
00184         Error =
00185         bind(
00186             Socket,
00187             (struct sockaddr *) &Address,
00188             sizeof(Address));
00189
00190         if (Error)
00191         {
00192             fprintf(stderr, "Error in bind = %d\n", GetLastError());
00193             fSt = FALSE;
00194             goto ex;
00195         }
00196
00197         Address.sin_family = AF_INET;
00198         Address.sin_port = htons(80);
00199         Address.sin_addr.s_addr = inet_addr(Server);
00200
00201         if (Address.sin_addr.s_addr == -1)
00202         {
00203             //
00204             // Must be a server name
00205             //
00206             HostEntry = gethostbyname(Server);
00207             if (HostEntry == NULL)
00208             {
00209                 printf("unable to resolve %s\n", Server);
00210                 fSt = FALSE;
00211                 goto ex;
00212             } else
00213             {
00214                 Address.sin_addr.s_addr = *((unsigned long *) HostEntry->h_addr);
00215             }
00216         }
00217
00218         Error =
00219         connect(
00220             Socket,
00221             (struct sockaddr *) &Address,
00222             sizeof(Address));
00223
00224         if (Error)
00225         {
00226             fprintf(stderr, "Error connecting to %s = %d\n", Server, GetLastError());
00227             fSt = FALSE;
00228             goto ex;
00229         }
00230     }
00231
00232     //
00233     // Send the client request
00234     //
00235
00236     strcpy(Request, Verb);
00237     strcat(Request, " ");
00238     strcat(Request, URL);
00239     strcat(Request, " ");
00240     strcat(Request, Headers);
00241     if (ClientDataSize)
00242     {
00243         sprintf(ClientData, "Content-Length: %d\r\n", ClientDataSize);
00244         strcat(Request, ClientData);
00245     }
00246     if ( fKeepAlive )
00247     {
00248         strcat(Request, "Connection: Keep-Alive\r\n" );
00249     }
00250
00251     if ( !AddAuthorizationHeader( Request + strlen(Request), achAuth, pchAuthData, pchUserName, pchPassword, &fNeedMoreData ) )
00252     {
00253         printf( "Authentication failed\n" );
00254         fSt = FALSE;
00255         goto ex;
00256     }
00257
00258     strcat(Request, CrLf);
00259
00260     RequestSize = (int)strlen(Request);
00261
00262     Error =
00263     send(
00264         Socket,
00265         Request,
00266         RequestSize,
00267         0);
00268
00269     if (Error != RequestSize)
00270     {
00271         printf("Error in client send = %d, %d\n", Error, GetLastError());
00272         fSt = FALSE;
00273         goto ex;
00274     }
00275
00276     if (ClientDataSize)
00277     {
00278         memset( ClientData, ' ', ClientDataSize );
00279
00280         //
00281         // Send the client data
00282         //
00283
00284         Error =
00285         send(
00286             Socket,
00287             ClientData,
00288             ClientDataSize,
00289             0);
00290
00291         if ( (DWORD)Error != ClientDataSize)
00292         {
00293             printf("Error in client send = %d, %d\n", Error, GetLastError());
00294             fSt = FALSE;
00295             goto ex;
00296         }
00297     }
00298
00299     // parse status & header
00300
00301     cLen = (DWORD)-1;
00302     fInHeader = TRUE;
00303     fServerKeepAlive = FALSE;
00304     fNeedAuthenticate = FALSE;
00305
00306     for ( pH = ReceiveBuffer, fStatusLine = TRUE ; fInHeader ; )
00307     {
00308         cRec = recv( Socket, pH, (int)(ReceiveBuffer+sizeof(ReceiveBuffer)-pH), 0 );
00309         if ( cRec <= 0 )
00310         {
00311             closesocket( Socket );
00312             Socket = INVALID_SOCKET;
00313             break;
00314         }
00315         pH[ cRec ] = '\0';
00316
00317         // Iterate on header fields
00318
00319         while ( pN = strstr(pH, "\r\n" ) )
00320         {
00321             *pN = '\0';
00322
00323             if ( DisplayHeaders )
00324             {
00325                 printf( "%s\n", pH );
00326             }
00327
00328             if ( fStatusLine )
00329             {
00330                 // This is the status line, decode status
00331
00332                 SkipNonWhite( &pH );
00333                 SkipWhite( &pH );
00334                 Status = atoi( pH );
00335                 if ( Status == 401 )
00336                 {
00337                     fNeedAuthenticate = TRUE;
00338                 }
00339                 fStatusLine = FALSE;
00340             }
00341             else if ( pN == pH )    // end of header fields
00342             {
00343                 if ( hnd != EOF )
00344                     write( hnd, pH+2, (int)(ReceiveBuffer+cRec-pH-2) );
00345
00346                 cLen -= (int)(ReceiveBuffer+cRec-pH-2 );
00347                 fInHeader = FALSE;
00348                 break;
00349             }
00350             else if ( !strnicmp( pH, HD_AUTHENTICATE, sizeof(HD_AUTHENTICATE)-1 ) )
00351             {
00352                 SkipNonWhite( &pH );
00353                 SkipWhite( &pH );
00354
00355                 // check if we are already in the authentication sequence
00356
00357                 if ( !IsInAuthorizationSequence() )
00358                 {
00359                     // append to list of supported authentication methods
00360
00361                     strcpy( paAuth, pH );
00362                     paAuth += strlen( pH ) + 1;
00363                 }
00364                 else
00365                 {
00366                     // store pointer to authenticate blob
00367
00368                     SkipNonWhite( &pH );
00369                     SkipWhite( &pH );
00370                     pchAuthData = pH;
00371                 }
00372             }
00373             else if ( !strnicmp( pH, HD_LENGTH, sizeof(HD_LENGTH)-1 ) )
00374             {
00375                 // get content length
00376
00377                 SkipNonWhite( &pH );
00378                 SkipWhite( &pH );
00379                 cLen = atoi( pH );
00380             }
00381             else if ( !strnicmp( pH, HD_CONNECTION, sizeof(HD_CONNECTION)-1 ) )
00382             {
00383                 // check for keep-alive flag
00384
00385                 SkipNonWhite( &pH );
00386                 SkipWhite( &pH );
00387                 if ( !strnicmp( pH, "Keep-Alive", sizeof("Keep-Alive")-1 ) )
00388                     fServerKeepAlive = TRUE;
00389             }
00390
00391             pH = pN + 2;
00392         }
00393     }
00394
00395     // add final delimiter to list of supported authentication methods
00396
00397     if ( !IsInAuthorizationSequence() && fNeedAuthenticate )
00398     {
00399         *paAuth = '\0';
00400
00401         // Insure specified methods are supported localy
00402
00403         if ( !ValidateAuthenticationMethods( achAuth, pszPref ) )
00404         {
00405             // None of the server specified authentication methods
00406             // are supported localy.
00407
00408             SetLastError( ERROR_ACCESS_DENIED );
00409
00410             fprintf( stderr, "No supported authentication method\n" );
00411
00412             fSt = FALSE;
00413             goto ex;
00414         }
00415     }
00416
00417     // read message body
00418
00419     if ( Socket != INVALID_SOCKET )
00420     {
00421         for ( ; cLen ; )
00422         {
00423             if ( (cToRead = sizeof(ReceiveBuffer)) > cLen )
00424                 cToRead = cLen;
00425             cRec = recv( Socket, ReceiveBuffer, cToRead, 0 );
00426
00427             if ( cRec <= 0 )
00428             {
00429                 closesocket( Socket );
00430                 Socket = INVALID_SOCKET;
00431                 break;
00432             }
00433             if ( hnd != EOF )
00434                 write( hnd, ReceiveBuffer, cRec );
00435
00436             cLen -= cRec;
00437         }
00438     }
00439
00440     if ( !fServerKeepAlive )
00441     {
00442         if ( IsInAuthorizationSequence() )
00443         {
00444             fprintf( stderr, "Authentication rejected by server\n" );
00445
00446             fNeedAuthenticate = FALSE;  // authentication failed
00447         }
00448
00449         closesocket( Socket );
00450         Socket = INVALID_SOCKET;
00451     }
00452
00453     if ( fNeedAuthenticate )
00454     {
00455         fKeepAlive = TRUE;
00456         goto again;
00457     }
00458
00459     if ( Socket != INVALID_SOCKET )
00460         closesocket(Socket);
00461
00462     fSt = Status == 200;
00463
00464 ex:
00465     TerminateAuthorizationHeader();
00466
00467     if ( hnd != EOF )
00468         close( hnd );
00469
00470     return fSt;
00471 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/Utility.h Source File

  • Com
  • Fundamentals
  • OleStd

Utility.h

Go to the documentation of this file.
00001 /*
00002  * UTILITY.H
00003  *
00004  * Miscellaneous prototypes and definitions for OLE UI dialogs.
00005  *
00006  * Copyright (c)1992 - 2000 Microsoft Corporation, All Right Reserved
00007  */
00008
00009
00010 #ifndef _UTILITY_H_
00011 #define _UTILITY_H_
00012
00013 //Function prototypes
00014 //UTILITY.C
00015 HCURSOR  WINAPI HourGlassOn(void);
00016 void     WINAPI HourGlassOff(HCURSOR);
00017
00018 BOOL     WINAPI Browse(HWND, LPSTR, LPSTR, UINT, UINT, DWORD);
00019 int      WINAPI ReplaceCharWithNull(LPSTR, int);
00020 int      WINAPI ErrorWithFile(HWND, HINSTANCE, UINT, LPSTR, UINT);
00021 HFILE WINAPI DoesFileExist(LPSTR lpszFile, OFSTRUCT FAR* lpOpenBuf);
00022
00023
00024 HICON FAR PASCAL    HIconAndSourceFromClass(REFCLSID, LPSTR, UINT FAR *);
00025 BOOL FAR PASCAL FIconFileFromClass(REFCLSID, LPSTR, UINT, UINT FAR *);
00026 LPSTR FAR PASCAL PointerToNthField(LPSTR, int, char);
00027 BOOL FAR PASCAL GetAssociatedExecutable(LPSTR, LPSTR);
00028 HICON    WINAPI HIconFromClass(LPSTR);
00029 BOOL     WINAPI FServerFromClass(LPSTR, LPSTR, UINT);
00030 UINT     WINAPI UClassFromDescription(LPSTR, LPSTR, UINT);
00031 UINT     WINAPI UDescriptionFromClass(LPSTR, LPSTR, UINT);
00032 BOOL     WINAPI FVerbGet(LPSTR, UINT, LPSTR);
00033 LPSTR    WINAPI ChopText(HWND hwndStatic, int nWidth, LPSTR lpch);
00034 void     WINAPI OpenFileError(HWND hDlg, UINT nErrCode, LPSTR lpszFile);
00035
00036
00037 #endif //_UTILITY_H_
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConServe/Connect.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConServe

Connect.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.H
00003
00004   Summary:   Include file declaring COM object classes and constants for
00005              managing the connection points (and their connections)
00006              exposed by the connectable objects in the CONSERVE server.
00007
00008              For a comprehensive tutorial code tour of this module's
00009              contents and offerings see the tutorial CONSERVE.HTM
00010              file. For more specific technical details on the internal
00011              workings see the comments dispersed throughout the module's
00012              source code.
00013
00014   Functions: .
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Origin:    6-3-96: atrent - Created for the CONSERVE Tutorial
00020              Code Sample.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 #if !defined(CONNECT_H)
00038 #define CONNECT_H
00039
00040 #ifdef __cplusplus
00041
00042 // An enumeration giving symbol names array indexes of the connection
00043 // points offered by the DllSndBall component in this server.
00044 enum
00045 {
00046   CONNPOINT_BALLSINK = 0
00047 };
00048
00049 enum
00050 {
00051   // The maximum number of connection points offered by the DllSndBall
00052   // component in this CONSERVE server.  The number of items in the
00053   // connection point enumeration above.
00054   MAX_CONNECTION_POINTS = 1,
00055
00056   // A constant for the number of connections to add to the allocation
00057   // of the dynamic connection array.
00058   ALLOC_CONNECTIONS = 8,
00059
00060   // The start value for the connection key (cookie) counter.
00061   COOKIE_START_VALUE = 400
00062 };
00063
00064
00065 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00066   ObjectClass: COEnumConnectionPoints
00067
00068   Summary:     COM object class for enumerating the Connection Points of
00069                offered by a connectable object.
00070
00071   Interfaces:  IUnknown
00072                  Standard interface providing COM object features.
00073                IEnumConnectionPoints
00074                  Interface for connection point enumeration.
00075
00076   Aggregation: COEnumConnectionPoints COM Objects are not aggregatable.
00077 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00078 class COEnumConnectionPoints : public IEnumConnectionPoints
00079 {
00080   public:
00081     // Main Object Constructor & Destructor.
00082     COEnumConnectionPoints(IUnknown* pHostObj);
00083     ~COEnumConnectionPoints(void);
00084
00085     // A general method for initializing this newly created object.
00086     // Creates any subordinate arrays, structures, or objects.
00087     HRESULT Init(
00088               ULONG cConnPts,
00089               IConnectionPoint** paConnPts,
00090               ULONG iEnumIndex);
00091
00092     // IUnknown methods. Main object, non-delegating.
00093     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00094     STDMETHODIMP_(ULONG) AddRef(void);
00095     STDMETHODIMP_(ULONG) Release(void);
00096
00097     // IEnumConnectionPoints methods.
00098     STDMETHODIMP         Next(ULONG, IConnectionPoint**, ULONG*);
00099     STDMETHODIMP         Skip(ULONG);
00100     STDMETHODIMP         Reset(void);
00101     STDMETHODIMP         Clone(IEnumConnectionPoints**);
00102
00103   private:
00104     // Private data of COEnumConnectionPoints COM objects.
00105
00106     // Main Object reference count.
00107     ULONG              m_cRefs;
00108
00109     // IUnknown pointer to host COM object being enumerated.
00110     IUnknown*          m_pHostObj;
00111
00112     // Connection Point index variable.
00113     ULONG              m_iEnumIndex;
00114
00115     // Number of Connection Points being enumerated.
00116     ULONG              m_cConnPts;
00117
00118     // Allocated array of Connection Point interface pointers.
00119     IConnectionPoint** m_paConnPts;
00120 };
00121
00122 typedef COEnumConnectionPoints* PCOEnumConnectionPoints;
00123
00124
00125 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00126   ObjectClass: COConnectionPoint
00127
00128   Summary:     Connection Point COM object class. Implements a native
00129                IConnectionPoint interface. The Advise, Unadvise, and
00130                EnumConnections methods use the CThreaded OwnThis mechanism
00131                to provide thread-safe mutually exclusive access to this
00132                connection point object.
00133
00134   Interfaces:  IUnknown
00135                  Standard interface providing COM object features.
00136                IConnectionPoint
00137                  Interface for connection point features.
00138
00139   Aggregation: COConnectionPoint COM Objects are not aggregatable.
00140 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00141 class COConnectionPoint : public IConnectionPoint, public CThreaded
00142 {
00143   public:
00144     // Main Object Constructor & Destructor.
00145     COConnectionPoint(IUnknown* pHostObj);
00146     ~COConnectionPoint(void);
00147
00148     // A general method for initializing this newly created object.
00149     // Creates any subordinate arrays, structures, or objects.
00150     HRESULT Init(REFIID riid);
00151
00152     // IUnknown methods. Main object, non-delegating.
00153     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00154     STDMETHODIMP_(ULONG) AddRef(void);
00155     STDMETHODIMP_(ULONG) Release(void);
00156
00157     // IConnectionPoint methods.
00158     STDMETHODIMP GetConnectionInterface(IID*);
00159     STDMETHODIMP GetConnectionPointContainer(IConnectionPointContainer**);
00160     STDMETHODIMP Advise(IUnknown*, DWORD*);
00161     STDMETHODIMP Unadvise(DWORD);
00162     STDMETHODIMP EnumConnections(IEnumConnections**);
00163
00164   private:
00165     // Private utility methods of COConnectionPoint.
00166     HRESULT GetSlot(UINT* puiFreeSlot);
00167     HRESULT FindSlot(DWORD dwCookie, UINT* puiSlot);
00168
00169     // Private data of COConnectionPoint COM objects.
00170
00171     // Main Object reference count.
00172     ULONG          m_cRefs;
00173
00174     // IUnknown pointer to host COM object offering this connection point.
00175     IUnknown*      m_pHostObj;
00176
00177     // The IID of the sink interface associated with this connection point.
00178     IID            m_iidSink;
00179
00180     // The current connection cookie (key) counter.
00181     DWORD          m_dwNextCookie;
00182
00183     // The current number of live sink connections to this connection point.
00184     UINT           m_cConnections;
00185
00186     // The current maximum index into the dynamic connection array.
00187     UINT           m_uiMaxIndex;
00188
00189     // The dynamic array of sink connections to this connection point.
00190     CONNECTDATA*   m_paConnections;
00191 };
00192
00193 typedef COConnectionPoint* PCOConnectionPoint;
00194
00195
00196 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00197   ObjectClass: COEnumConnections
00198
00199   Summary:     COM object class for enumerating the connections of
00200                a connection point of a connectable object.
00201
00202   Interfaces:  IUnknown
00203                  Standard interface providing COM object features.
00204                IEnumConnections
00205                  Interface for connection enumeration features.
00206
00207   Aggregation: COEnumConnections COM Objects are not aggregatable.
00208 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00209 class COEnumConnections : public IEnumConnections
00210 {
00211   public:
00212     // Main Object Constructor & Destructor.
00213     COEnumConnections(IUnknown* pHostObj);
00214     ~COEnumConnections(void);
00215
00216     // A general method for initializing this newly created object.
00217     // Creates any subordinate arrays, structures, or objects.
00218     HRESULT Init(
00219               ULONG cConnections,
00220               CONNECTDATA* paConnections,
00221               ULONG iEnumIndex);
00222
00223     // IUnknown methods. Main object, non-delegating.
00224     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00225     STDMETHODIMP_(ULONG) AddRef(void);
00226     STDMETHODIMP_(ULONG) Release(void);
00227
00228     // IEnumConnections methods.
00229     STDMETHODIMP         Next(ULONG, CONNECTDATA*, ULONG*);
00230     STDMETHODIMP         Skip(ULONG);
00231     STDMETHODIMP         Reset(void);
00232     STDMETHODIMP         Clone(IEnumConnections**);
00233
00234   private:
00235     // Private data of COEnumConnections COM objects.
00236
00237     // Main Object reference count.
00238     ULONG            m_cRefs;
00239
00240     // IUnknown pointer to host connection point COM object being
00241     // enumerated.
00242     IUnknown*        m_pHostObj;
00243
00244     // Connection index variable.
00245     ULONG            m_iEnumIndex;
00246
00247     // Number of Connections being enumerated.
00248     ULONG            m_cConnections;
00249
00250     // Allocated array of live Connections only.
00251     CONNECTDATA*     m_paConnections;
00252 };
00253
00254 typedef COEnumConnections* PCOEnumConnections;
00255
00256 #endif // __cplusplus
00257
00258
00259 #endif // CONNECT_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/UtilLib/WbemSec.h Source File

  • SysMgmt
  • WMI
  • VC
  • UtilLib

WbemSec.h

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  WBEMSEC.H
00006
00007 //
00008
00009 //  Purpose: Provides prototypes for some security helper functions.
00010
00011 //
00012
00013 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00014 //
00015 //***************************************************************************
00016
00017 #ifndef _WBEMSEC_H_
00018 #define _WBEMSEC_H_
00019
00020 HRESULT InitializeSecurity(DWORD dwAuthLevel, DWORD dwImpLevel);
00021 SCODE GetAuthImp(IUnknown * pFrom, DWORD * pdwAuthLevel, DWORD * pdwImpLevel);
00022 HRESULT SetInterfaceSecurity(IUnknown * pInterface, LPWSTR pDomain, LPWSTR pUser, LPWSTR pPassword, DWORD dwAuthLevel, DWORD dwImpLevel);
00023
00024 #endif // _WBEMSEC_H_
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/Enumidl.h Source File

  • WinUI
  • Shell
  • SampView

Enumidl.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          EnumIDL.h
00013
00014    Description:   CEnumIDList definitions.
00015
00016 **************************************************************************/
00017
00018 #ifndef ENUMIDLIST_H
00019 #define ENUMIDLIST_H
00020
00021 #include <windows.h>
00022 #include <shlobj.h>
00023
00024 #include "PidlMgr.h"
00025 #include "Utility.h"
00026
00027 /**************************************************************************
00028    structure defintions
00029 **************************************************************************/
00030
00031 typedef struct tagENUMLIST
00032    {
00033    struct tagENUMLIST   *pNext;
00034    LPITEMIDLIST         pidl;
00035    }ENUMLIST, FAR *LPENUMLIST;
00036
00037 /**************************************************************************
00038
00039    CEnumIDList class definition
00040
00041 **************************************************************************/
00042
00043 class CEnumIDList : public IEnumIDList
00044 {
00045 private:
00046    DWORD       m_ObjRefCount;
00047    LPMALLOC    m_pMalloc;
00048    LPENUMLIST  m_pFirst;
00049    LPENUMLIST  m_pLast;
00050    LPENUMLIST  m_pCurrent;
00051    CPidlMgr    *m_pPidlMgr;
00052    DWORD       m_dwFlags;
00053    TCHAR       m_szPath[MAX_PATH];
00054
00055 public:
00056    CEnumIDList(LPCTSTR, DWORD);
00057    ~CEnumIDList();
00058
00059    //IUnknown methods
00060    STDMETHOD (QueryInterface)(REFIID, LPVOID*);
00061    STDMETHOD_ (DWORD, AddRef)();
00062    STDMETHOD_ (DWORD, Release)();
00063
00064    //IEnumIDList
00065    STDMETHOD (Next) (DWORD, LPITEMIDLIST*, LPDWORD);
00066    STDMETHOD (Skip) (DWORD);
00067    STDMETHOD (Reset) (VOID);
00068    STDMETHOD (Clone) (LPENUMIDLIST*);
00069
00070 private:
00071    BOOL CreateEnumList(VOID);
00072    BOOL AddToEnumList(LPITEMIDLIST);
00073    BOOL DeleteList(VOID);
00074 };
00075
00076 #endif   //ENUMIDLIST_H
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSimpleArray< T > Member List

This is the complete list of members for CSimpleArray< T >, including all inherited members.
Add(T &t) | CSimpleArray< T > | [inline]
CSimpleArray() | CSimpleArray< T > | [inline]
Find(T &t) const | CSimpleArray< T > | [inline]
GetData() const | CSimpleArray< T > | [inline]
GetSize() const | CSimpleArray< T > | [inline]
m_aT | CSimpleArray< T > |
m_nAllocSize | CSimpleArray< T > |
m_nSize | CSimpleArray< T > |
operator[](int nIndex) const | CSimpleArray< T > | [inline]
Remove(T &t) | CSimpleArray< T > | [inline]
RemoveAll() | CSimpleArray< T > | [inline]
RemoveAt(int nIndex) | CSimpleArray< T > | [inline]
SetAtIndex(int nIndex, T &t) | CSimpleArray< T > | [inline]
~CSimpleArray() | CSimpleArray< T > | [inline]
Generated on Wed Nov 13 2024 16:57:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

pipe_state Member List

This is the complete list of members for pipe_state, including all inherited members.
hNew | pipe_state
hOld | pipe_state
pszNewName | pipe_state
pszOldName | pipe_state
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSpyCon Member List

This is the complete list of members for CSpyCon, including all inherited members.
CanInPlaceActivate(void) | CSpyCon | [inline]
ContextSensitiveHelp(BOOL fEnterMode) | CSpyCon | [inline]
CSpyCon() | CSpyCon | [inline]
DeactivateAndUndo(void) | CSpyCon | [inline]
DiscardUndoState(void) | CSpyCon | [inline]
FinalRelease() | CSpyCon | [inline]
GetContainer(IOleContainer **ppContainer) | CSpyCon | [inline]
GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) | CSpyCon | [inline]
GetWindow(HWND *phwnd) | CSpyCon | [inline]
GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) | CSpyCon | [inline]
m_bInPlaceActive | CSpyCon | [private]
m_bSaveOnExit | CSpyCon |
m_bTopmost | CSpyCon |
m_pOleObject | CSpyCon | [private]
m_pSpy | CSpyCon | [private]
m_wp | CSpyCon |
OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnAlwaysOnTop(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnChooseFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnChooseLogFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnErase(UINT, WPARAM, LPARAM, BOOL &bHandled) | CSpyCon | [inline]
OnExit(WORD, WORD, HWND, BOOL &) | CSpyCon |
OnInitMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CSpyCon |
OnInPlaceActivate(void) | CSpyCon | [inline]
OnInPlaceDeactivate(void) | CSpyCon | [inline]
OnLogToFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnNCDestroy(UINT, WPARAM, LPARAM, BOOL &) | CSpyCon | [inline]
OnPosRectChange(LPCRECT lprcPosRect) | CSpyCon | [inline]
OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnSaveNow(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnSelectFilter(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnShowWindow(BOOL fShow) | CSpyCon | [inline]
OnSize(UINT, WPARAM, LPARAM, BOOL &) | CSpyCon | [inline]
OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CSpyCon |
OnToggleGridLines(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnToggleSaveOnExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnToggleShowOnScreen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSpyCon |
OnUIActivate(void) | CSpyCon | [inline]
OnUIDeactivate(BOOL fUndoable) | CSpyCon | [inline]
RequestNewObjectLayout(void) | CSpyCon | [inline]
Run() | CSpyCon |
SaveObject(void) | CSpyCon | [inline]
SaveSettings() | CSpyCon |
Scroll(SIZE scrollExtant) | CSpyCon | [inline]
ShowObject(void) | CSpyCon | [inline]
~CSpyCon() | CSpyCon | [inline]
Generated on Wed Nov 13 2024 16:57:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/sky.h Source File

  • SysMgmt
  • MMC
  • Extens

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025 class CSkyBasedVehicle : public CDelegationBase {
00026 public:
00027     CSkyBasedVehicle() { }
00028
00029     virtual ~CSkyBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00034
00035 private:
00036     enum { IDM_NEW_SKY = 3 };
00037
00038     // {2974380F-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellExt/ShellExt.Cpp Source File

  • WinUI
  • Shell
  • ShellExt

ShellExt.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   shellext.cpp
00009 //
00010 // Purpose:  Implements the class factory code as well as CShellExt::QI,
00011 //           CShellExt::AddRef and CShellExt::Release code.
00012
00013 #include "priv.h"
00014
00015 //
00016 // Initialize GUIDs (should be done only and at-least once per DLL/EXE)
00017 //
00018 #pragma data_seg(".text")
00019 #define INITGUID
00020 #include <initguid.h>
00021 #include <shlguid.h>
00022 #include "shellext.h"
00023 #pragma data_seg()
00024
00025 //
00026 // Global variables
00027 //
00028 UINT      g_cRefThisDll = 0;    // Reference count of this DLL.
00029 HINSTANCE g_hmodThisDll = NULL; // Handle to this DLL itself.
00030
00031 extern "C" int APIENTRY
00032 DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00033 {
00034     if (dwReason == DLL_PROCESS_ATTACH)
00035     {
00036         ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n");
00037
00038         // Extension DLL one-time initialization
00039
00040         g_hmodThisDll = hInstance;
00041     }
00042     else if (dwReason == DLL_PROCESS_DETACH)
00043     {
00044         ODS("In DLLMain, DLL_PROCESS_DETACH\r\n");
00045     }
00046
00047     return 1;   // ok
00048 }
00049
00050 //---------------------------------------------------------------------------
00051 // DllCanUnloadNow
00052 //---------------------------------------------------------------------------
00053
00054 STDAPI DllCanUnloadNow(void)
00055 {
00056     ODS("In DLLCanUnloadNow\r\n");
00057
00058     return (g_cRefThisDll == 0 ? S_OK : S_FALSE);
00059 }
00060
00061 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
00062 {
00063     ODS("In DllGetClassObject\r\n");
00064
00065     *ppvOut = NULL;
00066
00067     if (IsEqualIID(rclsid, CLSID_ShellExtension))
00068     {
00069         CShellExtClassFactory *pcf = new CShellExtClassFactory;
00070
00071         return pcf->QueryInterface(riid, ppvOut);
00072     }
00073
00074     return CLASS_E_CLASSNOTAVAILABLE;
00075 }
00076
00077 CShellExtClassFactory::CShellExtClassFactory()
00078 {
00079     ODS("CShellExtClassFactory::CShellExtClassFactory()\r\n");
00080
00081     m_cRef = 0L;
00082
00083     g_cRefThisDll++;
00084 }
00085
00086 CShellExtClassFactory::~CShellExtClassFactory()
00087 {
00088     g_cRefThisDll--;
00089 }
00090
00091 STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid,
00092                                                    LPVOID FAR *ppv)
00093 {
00094     ODS("CShellExtClassFactory::QueryInterface()\r\n");
00095
00096     *ppv = NULL;
00097
00098     // Any interface on this object is the object pointer
00099
00100     if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
00101     {
00102         *ppv = (LPCLASSFACTORY)this;
00103
00104         AddRef();
00105
00106         return NOERROR;
00107     }
00108
00109     return E_NOINTERFACE;
00110 }
00111
00112 STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef()
00113 {
00114     return ++m_cRef;
00115 }
00116
00117 STDMETHODIMP_(ULONG) CShellExtClassFactory::Release()
00118 {
00119     if (--m_cRef)
00120         return m_cRef;
00121
00122     delete this;
00123
00124     return 0L;
00125 }
00126
00127 STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
00128                                                       REFIID riid,
00129                                                       LPVOID *ppvObj)
00130 {
00131     ODS("CShellExtClassFactory::CreateInstance()\r\n");
00132
00133     *ppvObj = NULL;
00134
00135     // Shell extensions typically don't support aggregation (inheritance)
00136
00137     if (pUnkOuter)
00138         return CLASS_E_NOAGGREGATION;
00139
00140     // Create the main shell extension object.  The shell will then call
00141     // QueryInterface with IID_IShellExtInit--this is how shell extensions are
00142     // initialized.
00143
00144     LPCSHELLEXT pShellExt = new CShellExt();  //Create the CShellExt object
00145
00146     if (NULL == pShellExt)
00147         return E_OUTOFMEMORY;
00148
00149     return pShellExt->QueryInterface(riid, ppvObj);
00150 }
00151
00152
00153 STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock)
00154 {
00155     return NOERROR;
00156 }
00157
00158 // *********************** CShellExt *************************
00159 CShellExt::CShellExt()
00160 {
00161     ODS("CShellExt::CShellExt()\r\n");
00162
00163     m_cRef = 0L;
00164     m_pDataObj = NULL;
00165
00166     g_cRefThisDll++;
00167 }
00168
00169 CShellExt::~CShellExt()
00170 {
00171     if (m_pDataObj)
00172         m_pDataObj->Release();
00173
00174     g_cRefThisDll--;
00175 }
00176
00177 STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv)
00178 {
00179     *ppv = NULL;
00180
00181     if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown))
00182     {
00183         ODS("CShellExt::QueryInterface()==>IID_IShellExtInit\r\n");
00184
00185         *ppv = (LPSHELLEXTINIT)this;
00186     }
00187     else if (IsEqualIID(riid, IID_IContextMenu))
00188     {
00189         ODS("CShellExt::QueryInterface()==>IID_IContextMenu\r\n");
00190
00191         *ppv = (LPCONTEXTMENU)this;
00192     }
00193     else if (IsEqualIID(riid, IID_IExtractIcon))
00194     {
00195         ODS("CShellExt::QueryInterface()==>IID_IExtractIcon\r\n");
00196
00197         *ppv = (LPEXTRACTICON)this;
00198     }
00199     else if (IsEqualIID(riid, IID_IPersistFile))
00200     {
00201         ODS("CShellExt::QueryInterface()==>IPersistFile\r\n");
00202
00203         *ppv = (LPPERSISTFILE)this;
00204     }
00205     else if (IsEqualIID(riid, IID_IShellPropSheetExt))
00206     {
00207         ODS("CShellExt::QueryInterface()==>IShellPropSheetExt\r\n");
00208
00209         *ppv = (LPSHELLPROPSHEETEXT)this;
00210     }
00211     else if (IsEqualIID(riid, IID_IShellCopyHook))
00212     {
00213         ODS("CShellExt::QueryInterface()==>ICopyHook\r\n");
00214
00215         *ppv = (LPCOPYHOOK)this;
00216     }
00217
00218     if (*ppv)
00219     {
00220         AddRef();
00221
00222         return NOERROR;
00223     }
00224
00225     ODS("CShellExt::QueryInterface()==>Unknown Interface!\r\n");
00226
00227     return E_NOINTERFACE;
00228 }
00229
00230 STDMETHODIMP_(ULONG) CShellExt::AddRef()
00231 {
00232     ODS("CShellExt::AddRef()\r\n");
00233
00234     return ++m_cRef;
00235 }
00236
00237 STDMETHODIMP_(ULONG) CShellExt::Release()
00238 {
00239     ODS("CShellExt::Release()\r\n");
00240
00241     if (--m_cRef)
00242         return m_cRef;
00243
00244     delete this;
00245
00246     return 0L;
00247 }
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/configmgr.c Source File

  • NetDS
  • RRas
  • ip

configmgr.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\configurationmanager.c
00008
00009 Abstract:
00010
00011     The file contains global configuration related functions,
00012     implementing the configuration manager.
00013
00014 --*/
00015
00016 #include "pchsample.h"
00017 #pragma hdrstop
00018
00019 // global variables...
00020
00021 CONFIGURATION_ENTRY g_ce;
00022
00023
00024
00025 // functions...
00026
00027 BOOL
00028 ValidateGlobalConfig (
00029     IN  PIPSAMPLE_GLOBAL_CONFIG pigc)
00030 /*++
00031
00032 Routine Description
00033     Checks to see if the global configuration is OK. It is good practice to
00034     do this because a corrupt registry can change configuration causing all
00035     sorts of debugging headaches if it is not found early
00036
00037 Locks
00038     None
00039
00040 Arguments
00041     pigc                pointer to ip sample's global configuration
00042
00043 Return Value
00044     TRUE                if the configuration is good
00045     FALSE               o/w
00046
00047 --*/
00048 {
00049     DWORD dwErr = NO_ERROR;
00050
00051     do                          // breakout loop
00052     {
00053         if (pigc is NULL)
00054         {
00055             dwErr = ERROR_INVALID_PARAMETER;
00056             TRACE0(CONFIGURATION, "Error null global config");
00057
00058             break;
00059         }
00060
00061         //
00062         // check range of each field
00063         //
00064
00065         // ensure that the logging level is within bounds
00066         if((pigc->dwLoggingLevel < IPSAMPLE_LOGGING_NONE) or
00067            (pigc->dwLoggingLevel > IPSAMPLE_LOGGING_INFO))
00068         {
00069             dwErr = ERROR_INVALID_PARAMETER;
00070             TRACE0(CONFIGURATION, "Error log level out of range");
00071
00072             break;
00073         }
00074
00075         // add more here...
00076
00077     } while (FALSE);
00078
00079     if (!(dwErr is NO_ERROR))
00080     {
00081         TRACE0(CONFIGURATION, "Error corrupt global config");
00082         LOGERR0(CORRUPT_GLOBAL_CONFIG, dwErr);
00083
00084         return FALSE;
00085     }
00086
00087     return TRUE;
00088 }
00089
00090
00091
00092 ////////////////////////////////////////
00093 // WORKERFUNCTIONS
00094 ////////////////////////////////////////
00095
00096 VOID
00097 CM_WorkerFinishStopProtocol (
00098     IN      PVOID   pvContext)
00099 /*++
00100
00101 Routine Description
00102     WORKERFUNCTION.  Queued by CM_StopProtocol.
00103     Waits for all active and queued threads to exit and cleans up
00104     configuration entry.
00105
00106 Locks
00107     Acquires exclusively g_ce.rwlLock
00108     Releases             g_ce.rwlLock
00109
00110 Arguments
00111     pvContext           ulActivityCount
00112
00113 Return Value
00114     None
00115
00116 --*/
00117 {
00118     DWORD           dwErr = NO_ERROR;
00119     MESSAGE         mMessage;
00120
00121     ULONG           ulThreadCount = 0;
00122
00123     ulThreadCount = (ULONG)pvContext;
00124
00125     TRACE1(ENTER, "Entering WorkerFinishStopProtocol: active threads %u",
00126            ulThreadCount);
00127
00128     // NOTE: since this is called while the router is stopping, there is no
00129     // need for it to use ENTER_SAMPLE_WORKER()/LEAVE_SAMPLE_WORKER()
00130
00131     // waits for all threads to stop
00132     while (ulThreadCount-- > 0)
00133         WaitForSingleObject(g_ce.hActivitySemaphore, INFINITE);
00134
00135
00136    // acquire the lock and release it, just to be sure that all threads
00137    // have quit their calls to LeaveSampleWorker()
00138
00139     ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock));
00140     RELEASE_WRITE_LOCK(&(g_ce.rwlLock));
00141
00142     // NOTE: there is no need to acquire g_ce.rwlLock for the call to
00143     // CE_Cleanup since there are no threads competing for access to the
00144     // fields being cleaned up.  new competing threads aren't created till
00145     // CE_Cleanup sets the protocol state to IPSAMPLE_STATUS_STOPPED, which
00146     // is the last thing it does.
00147
00148     CE_Cleanup(&g_ce, TRUE);
00149
00150     LOGINFO0(SAMPLE_STOPPED, NO_ERROR);
00151
00152     // inform router manager that we are done
00153     ZeroMemory(&mMessage, sizeof(MESSAGE));
00154     if (EnqueueEvent(ROUTER_STOPPED, mMessage) is NO_ERROR)
00155         SetEvent(g_ce.hMgrNotificationEvent);
00156
00157     TRACE0(LEAVE, "Leaving  WorkerFinishStopProtocol");
00158 }
00159
00160
00161
00162 ////////////////////////////////////////
00163 // APIFUNCTIONS
00164 ////////////////////////////////////////
00165
00166 DWORD
00167 CM_StartProtocol (
00168     IN  HANDLE                  hMgrNotificationEvent,
00169     IN  PSUPPORT_FUNCTIONS      psfSupportFunctions,
00170     IN  PVOID                   pvGlobalInfo)
00171 /*++
00172
00173 Routine Description
00174     Called by StartProtocol.  Initializes configuration entry.
00175
00176 Locks
00177     Acquires exclusively g_ce.rwlLock
00178     Releases             g_ce.rwlLock
00179
00180 Arguments
00181     hMgrNotificationEvent   event used to notify ip router manager
00182     psfSupportFunctions     functions exported by ip router manager
00183     pvGlobalInfo            global configuration set in registry
00184
00185 Return Value
00186     NO_ERROR            if successfully initiailzed
00187     Failure code        o/w
00188
00189 --*/
00190 {
00191     DWORD dwErr = NO_ERROR;
00192
00193     // NOTE: since this is called when SAMPLE is stopped, there is no need
00194     // for it to use ENTER_SAMPLE_API()/LEAVE_SAMPLE_API()
00195
00196     ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock));
00197
00198     do                          // breakout loop
00199     {
00200         if (g_ce.iscStatus != IPSAMPLE_STATUS_STOPPED)
00201         {
00202             TRACE0(CONFIGURATION, "Error ip sample already installed");
00203             LOGWARN0(SAMPLE_ALREADY_STARTED, NO_ERROR);
00204             dwErr = ERROR_CAN_NOT_COMPLETE;
00205
00206             break;
00207         }
00208
00209         if (!ValidateGlobalConfig((PIPSAMPLE_GLOBAL_CONFIG) pvGlobalInfo))
00210         {
00211             dwErr = ERROR_INVALID_PARAMETER;
00212             break;
00213         }
00214
00215         dwErr = CE_Initialize(&g_ce,
00216                               hMgrNotificationEvent,
00217                               psfSupportFunctions,
00218                               (PIPSAMPLE_GLOBAL_CONFIG) pvGlobalInfo);
00219     } while (FALSE);
00220
00221     RELEASE_WRITE_LOCK(&(g_ce.rwlLock));
00222
00223     if (dwErr is NO_ERROR)
00224     {
00225         TRACE0(CONFIGURATION, "ip sample has successfully started");
00226         LOGINFO0(SAMPLE_STARTED, dwErr);
00227     }
00228     else
00229     {
00230         TRACE1(CONFIGURATION, "Error ip sample failed to start", dwErr);
00231         LOGERR0(SAMPLE_START_FAILED, dwErr);
00232     }
00233
00234     return dwErr;
00235 }
00236
00237
00238
00239 DWORD
00240 CM_StopProtocol (
00241     )
00242 /*++
00243
00244 Routine Description
00245     Called by StopProtocol.  It queues a WORKERFUNCTION which waits for all
00246     active threads to exit and then cleans up the configuration entry.
00247
00248 Locks
00249     Acquires exclusively g_ce.rwlLock
00250     Releases             g_ce.rwlLock
00251
00252 Arguments
00253     None
00254
00255 Return Value
00256     ERROR_PROTOCOL_STOP_PENDING     if successfully queued
00257     Failure code                    o/w
00258
00259 --*/
00260 {
00261     DWORD dwErr         = NO_ERROR;
00262     BOOL  bSuccess      = FALSE;
00263     ULONG ulThreadCount = 0;
00264
00265     // NOTE: no need to use ENTER_SAMPLE_API()/LEAVE_SAMPLE_API()
00266     // Does not use QueueSampleWorker
00267
00268     ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock));
00269
00270     do                          // breakout loop
00271     {
00272         // cannot stop if already stopped
00273         if (g_ce.iscStatus != IPSAMPLE_STATUS_RUNNING)
00274         {
00275             TRACE0(CONFIGURATION, "Error ip sample already stopped");
00276             LOGWARN0(SAMPLE_ALREADY_STOPPED, NO_ERROR);
00277             dwErr = ERROR_CAN_NOT_COMPLETE;
00278
00279             break;
00280         }
00281
00282
00283         // set IPSAMPLE's status to STOPPING; this prevents any more
00284         // work-items from being queued, and it prevents the ones already
00285         // queued from executing
00286         g_ce.iscStatus = IPSAMPLE_STATUS_STOPPING;
00287
00288
00289         // find out how many threads are either queued or active in SAMPLE;
00290         // we will have to wait for this many threads to exit before we
00291         // clean up SAMPLE's resources
00292         ulThreadCount = g_ce.ulActivityCount;
00293         TRACE1(CONFIGURATION,
00294                "%u threads are active in SAMPLE", ulThreadCount);
00295     } while (FALSE);
00296
00297     RELEASE_WRITE_LOCK(&(g_ce.rwlLock));
00298
00299
00300     if (dwErr is NO_ERROR)
00301     {
00302         bSuccess = QueueUserWorkItem(
00303             (LPTHREAD_START_ROUTINE)CM_WorkerFinishStopProtocol,
00304             (PVOID) ulThreadCount,
00305             0); // no flags
00306
00307         dwErr = (bSuccess) ? ERROR_PROTOCOL_STOP_PENDING : GetLastError();
00308     }
00309
00310     return dwErr;
00311 }
00312
00313
00314
00315 DWORD
00316 CM_GetGlobalInfo (
00317     IN      PVOID               pvGlobalInfo,
00318     IN OUT  PULONG              pulBufferSize,
00319     OUT     PULONG              pulStructureVersion,
00320     OUT     PULONG              pulStructureSize,
00321     OUT     PULONG              pulStructureCount)
00322 /*++
00323
00324 Routine Description
00325     See if there's space enough to return ip sample global config. If yes,
00326     we return it, otherwise return the size needed.
00327
00328 Locks
00329     Acquires shared g_ce.rwlLock
00330     Releases        g_ce.rwlLock
00331
00332 Arguments
00333     pvGlobalInfo        pointer to allocated buffer to store our config
00334     pulBufferSize       IN  size of buffer received
00335                         OUT size of our global config
00336
00337 Return Value
00338     NO_ERROR            if success
00339     Failure code        o/w
00340
00341 --*/
00342 {
00343     DWORD                   dwErr = NO_ERROR;
00344     PIPSAMPLE_GLOBAL_CONFIG pigc;
00345     ULONG                   ulSize = sizeof(IPSAMPLE_GLOBAL_CONFIG);
00346
00347     if (!ENTER_SAMPLE_API()) { return ERROR_CAN_NOT_COMPLETE; }
00348
00349     do                          // breakout loop
00350     {
00351         if((*pulBufferSize < ulSize) or (pvGlobalInfo is NULL))
00352         {
00353             // either the size was too small or there was no storage
00354             dwErr = ERROR_INSUFFICIENT_BUFFER;
00355             TRACE1(CONFIGURATION,
00356                    "CM_GetGlobalInfo: *ulBufferSize %u",
00357                    *pulBufferSize);
00358
00359             *pulBufferSize = ulSize;
00360
00361             break;
00362         }
00363
00364         *pulBufferSize = ulSize;
00365
00366         if (pulStructureVersion)    *pulStructureVersion    = 1;
00367         if (pulStructureSize)       *pulStructureSize       = ulSize;
00368         if (pulStructureCount)      *pulStructureCount      = 1;
00369
00370
00371         // so we have a good buffer to write our info into...
00372         pigc = (PIPSAMPLE_GLOBAL_CONFIG) pvGlobalInfo;
00373
00374         // copy out the global configuration
00375         ACQUIRE_READ_LOCK(&(g_ce.rwlLock));
00376
00377         pigc->dwLoggingLevel = g_ce.dwLogLevel;
00378
00379         RELEASE_READ_LOCK(&(g_ce.rwlLock));
00380     } while (FALSE);
00381
00382     LEAVE_SAMPLE_API();
00383
00384     return dwErr;
00385 }
00386
00387
00388
00389 DWORD
00390 CM_SetGlobalInfo (
00391     IN      PVOID               pvGlobalInfo)
00392 /*++
00393
00394 Routine Description
00395     Set ip sample's global configuration.
00396
00397 Locks
00398     Acquires exclusively g_ce.rwlLock
00399     Releases             g_ce.rwlLock
00400
00401 Arguments
00402     pvGlobalInfo        buffer with new global configuration
00403
00404 Return Value
00405     NO_ERROR            if success
00406     Failure code        o/w
00407
00408 --*/
00409 {
00410     DWORD                   dwErr = NO_ERROR;
00411     PIPSAMPLE_GLOBAL_CONFIG pigc;
00412
00413     if (!ENTER_SAMPLE_API()) { return ERROR_CAN_NOT_COMPLETE; }
00414
00415     do                          // breakout loop
00416     {
00417         pigc = (PIPSAMPLE_GLOBAL_CONFIG) pvGlobalInfo;
00418
00419         if (!ValidateGlobalConfig(pigc))
00420         {
00421             dwErr = ERROR_INVALID_PARAMETER;
00422             break;
00423         }
00424
00425         // copy in the global configuration
00426         ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock));
00427
00428         g_ce.dwLogLevel = pigc->dwLoggingLevel;
00429
00430         RELEASE_WRITE_LOCK(&(g_ce.rwlLock));
00431     } while (FALSE);
00432
00433     LEAVE_SAMPLE_API();
00434
00435     return dwErr;
00436 }
00437
00438
00439
00440 DWORD
00441 CM_GetEventMessage (
00442     OUT ROUTING_PROTOCOL_EVENTS *prpeEvent,
00443     OUT MESSAGE                 *pmMessage)
00444 /*++
00445
00446 Routine Description
00447     Get the next event in queue for the ip router manager.
00448
00449 Locks
00450     None
00451
00452 Arguments
00453     prpeEvent           routing protocol event type
00454     pmMessage           message associated with the event
00455
00456 Return Value
00457     NO_ERROR            if success
00458     Failure code        o/w
00459
00460 --*/
00461 {
00462     DWORD           dwErr       = NO_ERROR;
00463
00464     // NOTE: this can be called after the protocol is stopped, as in when
00465     // the ip router manager is retrieving the ROUTER_STOPPED message, so
00466     // we do not call ENTER_SAMPLE_API()/LEAVE_SAMPLE_API()
00467
00468     dwErr = DequeueEvent(prpeEvent, pmMessage);
00469
00470     return dwErr;
00471 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Printer/Getcaps.h Source File

  • Multimedia
  • Gdi
  • Printer

Getcaps.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /******************************************************************************\
00013 *
00014 *                               GETCAPS.H
00015 *
00016 \******************************************************************************/
00017
00018
00019 /******************************************************************************\
00020 *                           SYMBOLIC CONSTANTS
00021 \******************************************************************************/
00022
00023 #define MAX_DEVICE_CAPS     34     // num entries in gaCaps table
00024
00025 #define MAX_TECHNOLOGY_CAPS 7      // num entries in gaTechnologyCaps table
00026 #define MAX_CURVE_CAPS      10     // num entries in gaCurveCaps table
00027 #define MAX_LINE_CAPS       8      // num entries in gaLineCaps table
00028 #define MAX_POLYGON_CAPS    10     // num entries in gaPolygonCaps table
00029 #define MAX_TEXT_CAPS       16     // num entries in gaTextCaps table
00030 #define MAX_RASTER_CAPS     17     // num entries in gaRasterCaps table
00031 #define MAX_CLIP_CAPS       3      // num entries in gaClipCaps table
00032
00033 #define BLANKS              "                 \t" // see gaCaps to get spacing
00034
00035 #define ERR_MOD_NAME       IDS_ERR_GETCAPS
00036
00037
00038
00039 /******************************************************************************\
00040 *                                TYPEDEFS
00041 \******************************************************************************/
00042
00043 typedef struct tagCAPSLOOKUP
00044 {
00045   int     iValue;
00046   LPTSTR  szValue;
00047
00048 } CAPSLOOKUP;
00049
00050
00051
00052 /******************************************************************************\
00053 *                            GLOBAL VARIABLES
00054 \******************************************************************************/
00055
00056 HWND ghwndDevCaps;
00057
00058 CAPSLOOKUP gaCaps[] =
00059
00060     { { DRIVERVERSION,   "DRIVERVERSION:   \t%ld" },
00061       { TECHNOLOGY,      "TECHNOLOGY:      \t"    },
00062       { HORZSIZE,        "HORZSIZE:        \t%ld" },
00063       { VERTSIZE,        "VERTSIZE:        \t%ld" },
00064       { HORZRES,         "HORZRES:         \t%ld" },
00065       { VERTRES,         "VERTRES:         \t%ld" },
00066       { BITSPIXEL,       "BITSPIXEL:       \t%ld" },
00067       { PLANES,          "PLANES:          \t%ld" },
00068       { NUMBRUSHES,      "NUMBRUSHES:      \t%ld" },
00069       { NUMPENS,         "NUMPENS:         \t%ld" },
00070       { NUMMARKERS,      "NUMMARKERS:      \t%ld" },
00071       { NUMFONTS,        "NUMFONTS:        \t%ld" },
00072       { NUMCOLORS,       "NUMCOLORS:       \t%ld" },
00073       { PDEVICESIZE,     "PDEVICESIZE:     \t%ld" },
00074       { CURVECAPS,       "CURVECAPS:       \t"    },
00075       { LINECAPS,        "LINECAPS:        \t"    },
00076       { POLYGONALCAPS,   "POLYGONALCAPS:   \t"    },
00077       { TEXTCAPS,        "TEXTCAPS:        \t"    },
00078       { CLIPCAPS,        "CLIPCAPS:        \t"    },
00079       { RASTERCAPS,      "RASTERCAPS:      \t"    },
00080       { ASPECTX,         "ASPECTX:         \t%ld" },
00081       { ASPECTY,         "ASPECTY:         \t%ld" },
00082       { ASPECTXY,        "ASPECTXY:        \t%ld" },
00083       { LOGPIXELSX,      "LOGPIXELSX:      \t%ld" },
00084       { LOGPIXELSY,      "LOGPIXELSY:      \t%ld" },
00085       { SIZEPALETTE,     "SIZEPALETTE:     \t%ld" },
00086       { NUMRESERVED,     "NUMRESERVED:     \t%ld" },
00087       { COLORRES,        "COLORRES:        \t%ld" },
00088       { PHYSICALWIDTH,   "PHYSICALWIDTH:   \t%ld" },
00089       { PHYSICALHEIGHT,  "PHYSICALHEIGHT:  \t%ld" },
00090       { PHYSICALOFFSETX, "PHYSICALOFFSETX: \t%ld" },
00091       { PHYSICALOFFSETY, "PHYSICALOFFSETY: \t%ld" },
00092       { SCALINGFACTORX,  "SCALINGFACTORX:  \t%ld" },
00093       { SCALINGFACTORY,  "SCALINGFACTORY:  \t%ld" }  };
00094
00095
00096 CAPSLOOKUP gaTechnologyCaps[] =
00097
00098     { { DT_PLOTTER,      "DT_PLOTTER "      },
00099       { DT_RASDISPLAY,   "DT_RASDISPLAY "   },
00100       { DT_RASPRINTER,   "DT_RASPRINTER "   },
00101       { DT_RASCAMERA,    "DT_RASCAMERA "    },
00102       { DT_CHARSTREAM,   "DT_CHARSTREAM "   },
00103       { DT_METAFILE,     "DT_METAFILE "     },
00104       { DT_DISPFILE,     "DT_DISPFILE "     } };
00105
00106 CAPSLOOKUP gaCurveCaps[] =
00107
00108     { { CC_NONE,         "CC_NONE "         },
00109       { CC_CIRCLES,      "CC_CIRCLES "      },
00110       { CC_PIE,          "CC_PIE "          },
00111       { CC_CHORD,        "CC_CHORD "        },
00112       { CC_ELLIPSES,     "CC_ELLIPSES "     },
00113       { CC_WIDE,         "CC_WIDE "         },
00114       { CC_STYLED,       "CC_STYLED "       },
00115       { CC_WIDESTYLED,   "CC_WIDESTYLED "   },
00116       { CC_INTERIORS,    "CC_INTERIORS "    },
00117       { CC_ROUNDRECT,    "CC_ROUNDRECT "    } };
00118
00119 CAPSLOOKUP gaLineCaps[] =
00120
00121     { { LC_NONE,         "LC_NONE "         },
00122       { LC_POLYLINE,     "LC_POLYLINE "     },
00123       { LC_MARKER,       "LC_MARKER "       },
00124       { LC_POLYMARKER,   "LC_POLYMARKER "   },
00125       { LC_WIDE,         "LC_WIDE "         },
00126       { LC_STYLED,       "LC_STYLED "       },
00127       { LC_WIDESTYLED,   "LC_WIDESTYLED "   },
00128       { LC_INTERIORS,    "LC_INTERIORS "    } };
00129
00130 CAPSLOOKUP gaPolygonCaps[] =
00131
00132     { { PC_NONE,         "PC_NONE "         },
00133       { PC_POLYGON,      "PC_POLYGON "      },
00134       { PC_RECTANGLE,    "PC_RECTANGLE "    },
00135       { PC_WINDPOLYGON,  "PC_WINDPOLYGON"   },
00136       { PC_TRAPEZOID,    "PC_TRAPEZOID"     },
00137       { PC_SCANLINE,     "PC_SCANLINE"      },
00138       { PC_WIDE,         "PC_WIDE"          },
00139       { PC_STYLED,       "PC_STYLED"        },
00140       { PC_WIDESTYLED,   "PC_WIDESTYLED"    },
00141       { PC_INTERIORS,    "PC_INTERIORS"     } };
00142
00143 CAPSLOOKUP gaTextCaps[] =
00144
00145     { { TC_OP_CHARACTER, "TC_OP_CHARACTER"  },
00146       { TC_OP_STROKE,    "TC_OP_STROKE"     },
00147       { TC_CP_STROKE,    "TC_CP_STROKE"     },
00148       { TC_CR_90,        "TC_CR_90"         },
00149       { TC_CR_ANY,       "TC_CR_ANY"        },
00150       { TC_SF_X_YINDEP,  "TC_SF_X_YINDEP "  },
00151       { TC_SA_DOUBLE,    "TC_SA_DOUBLE "    },
00152       { TC_SA_INTEGER,   "TC_SA_INTEGER "   },
00153       { TC_SA_CONTIN,    "TC_SA_CONTIN "    },
00154       { TC_EA_DOUBLE,    "TC_EA_DOUBLE "    },
00155       { TC_IA_ABLE,      "TC_IA_ABLE "      },
00156       { TC_UA_ABLE,      "TC_UA_ABLE "      },
00157       { TC_SO_ABLE,      "TC_SO_ABLE "      },
00158       { TC_RA_ABLE,      "TC_RA_ABLE "      },
00159       { TC_VA_ABLE,      "TC_VA_ABLE "      },
00160       { TC_RESERVED,     "TC_RESERVED "     },
00161       { TC_SCROLLBLT,    "TC_SCROLLBLT "     } };
00162
00163 CAPSLOOKUP gaRasterCaps[] =
00164
00165     { { 0,               "RC_NONE "         }, // !!! RC_NONE not #def'd
00166       { RC_BITBLT,       "RC_BITBLT "       },
00167       { RC_BANDING,      "RC_BANDING "      },
00168       { RC_SCALING,      "RC_SCALING "      },
00169       { RC_BITMAP64,     "RC_BITMAP64 "     },
00170       { RC_GDI20_OUTPUT, "RC_GDI20_OUTPUT " },
00171       { RC_GDI20_STATE,  "RC_GDI20_STATE "  },
00172       { RC_SAVEBITMAP,   "RC_SAVEBITMAP "   },
00173       { RC_DI_BITMAP,    "RC_DI_BITMAP "    },
00174       { RC_PALETTE,      "RC_PALETTE "      },
00175       { RC_DIBTODEV,     "RC_DIBTODEV "     },
00176       { RC_BIGFONT,      "RC_BIGFONT "      },
00177       { RC_STRETCHBLT,   "RC_STRETCHBLT "   },
00178       { RC_FLOODFILL,    "RC_FLOODFILL "    },
00179       { RC_STRETCHDIB,   "RC_STRETCHDIB "   },
00180       { RC_OP_DX_OUTPUT, "RC_OP_DX_OUTPUT " },
00181       { RC_DEVBITS,      "RC_DEVBITS "      } };
00182
00183 CAPSLOOKUP gaClipCaps[] =
00184
00185     { { CP_NONE,         "CP_NONE "         },
00186       { CP_RECTANGLE,    "CP_RECTANGLE "    },
00187       { CP_REGION,       "CP_REGION "       } };
00188
00189
00190
00191 /******************************************************************************\
00192 *                          EXTERNAL VARIABLES
00193 \******************************************************************************/
00194
00195 extern HWND ghwndMain;
00196 extern char gszDeviceName [];
00197 extern char gszDriverName [];
00198 extern char gszPort       [];
00199
00200
00201
00202 /******************************************************************************\
00203 *                          FUNCTION PROTOTYPES
00204 \******************************************************************************/
00205
00206 BOOL DisplayDeviceCapsInfo (void);
00207 void TranslateDeviceCaps   (int, int, int);
00208 void ComplexDeviceCapsLine (char *, CAPSLOOKUP *, int, int, int);
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: UDDI/wsdldiscovery/controls/categorytree.cs Source File

  • UDDI
  • wsdldiscovery
  • controls

categorytree.cs

Go to the documentation of this file.
00001 /*=====================================================================
00002   This file is part of the Microsoft UDDI SDK Code Samples.
00003
00004   Copyright (C) Microsoft Corporation.  All rights reserved.
00005
00006 This source code is intended only as a supplement to Microsoft
00007 Development Tools and/or on-line documentation.  See these other
00008 materials for detailed information regarding Microsoft code samples.
00009
00010 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00011 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00012 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00013 PARTICULAR PURPOSE.
00014 =====================================================================*/
00015
00016 using System;
00017 using System.Collections;
00018 using System.ComponentModel;
00019 using System.Drawing;
00020 using System.Data;
00021 using System.Windows.Forms;
00022
00023 using Microsoft.Uddi;
00024 using Microsoft.Uddi.TModels;
00025 using Microsoft.Uddi.Extensions;
00026
00027 namespace UDDI.Tools
00028 {
00029   /// <summary>
00030   /// Summary description for categorytree.
00031   /// </summary>
00032   public class CategoryTreeView : TreeView
00033   {
00034     /// <summary>
00035     /// Required designer variable.
00036     /// </summary>
00037     private System.ComponentModel.Container components = null;
00038     private UddiConnection _connection;
00039
00040     public CategoryTreeView(  )
00041     {
00042       // This call is required by the Windows.Forms Form Designer.
00043       InitializeComponent();
00044
00045     }
00046
00047     public CategoryTreeView( UddiConnection connection ) : this()
00048     {
00049       _connection = connection;
00050     }
00051
00052     public UddiConnection Connection
00053     {
00054       get{ return _connection; }
00055       set{ _connection = (UddiConnection)value; }
00056     }
00057
00058
00059     /// <summary>
00060     /// Clean up any resources being used.
00061     /// </summary>
00062     protected override void Dispose( bool disposing )
00063     {
00064       if( disposing )
00065       {
00066         if(components != null)
00067         {
00068           components.Dispose();
00069         }
00070       }
00071       base.Dispose( disposing );
00072     }
00073
00074
00075
00076     public void LoadTModels( )
00077     {
00078       FindTModel ft = new FindTModel();
00079       ft.CategoryBag.Add( CommonCanonical.UddiOrgTypes, "categorization", "Categorization (taxonomy)" );
00080
00081       TModelList list = null;
00082       try
00083       {
00084         list = ft.Send( _connection );
00085       }
00086       catch( Exception e )
00087       {
00088         MessageBox.Show( this, e.Message, @"Error loading Category Tree", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
00089         return;
00090       }
00091
00092       if( null == list )
00093       {
00094         MessageBox.Show( this, @"An unknown error occurred while loading the Category Tree.", @"Error loading Category Tree", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
00095         return;
00096       }
00097
00098       GetRelatedCategories grc = new GetRelatedCategories();
00099       Category c = new Category();
00100       c.RelationshipQualifiers.Add( RelationshipQualifier.root );
00101
00102       foreach( TModelInfo info in list.TModelInfos )
00103       {
00104         bool categorization = false;
00105         c.TModelKey = info.TModelKey;
00106         grc.Categories.Add( c );
00107
00108         CategoryList cl = null;
00109         try
00110         {
00111           cl = grc.Send( _connection );
00112           categorization = true;
00113         }
00114         catch( InvalidKeyPassedException )
00115         {
00116           //
00117           // tModel doesn't represent a categorization.  So, don't show
00118           // it in the tree.
00119           //
00120         }
00121         catch( Exception e )
00122         {
00123           //
00124           // if anything else happened, re-throw & let the app deal with it.
00125           //
00126           throw e;
00127         }
00128
00129         if( categorization )
00130         {
00131           //
00132           // Create a new node and wrap the tModelInfo into a
00133           // CategoryInfo object.
00134           //
00135           CategoryTreeNode catnode = new CategoryTreeNode( new CategoryInfo( info.TModelKey ) );
00136
00137           catnode.Nodes.Clear();
00138
00139           //
00140           // Set the Text of the node to the text of the tModel.
00141           //
00142           catnode.Text =  info.Name.Text;
00143
00144           CategoryValueCollection values = cl.CategoryInfos[ 0 ].Roots;
00145
00146           foreach( CategoryValue val in values )
00147           {
00148             CategoryTreeNode subnode = new CategoryTreeNode( val );
00149             subnode.CategoryValue.TModelKey = catnode.CategoryValue.TModelKey;
00150             catnode.Nodes.Add( subnode );
00151           }
00152
00153           catnode.HasDownloadedChildren = true;
00154
00155           //
00156           // Add the node to the root.
00157           //
00158           Nodes.Add( catnode );
00159         }
00160       }
00161     }
00162
00163
00164     private void GetChildren( CategoryTreeNode node )
00165     {
00166       node.Nodes.Clear();
00167
00168       GetRelatedCategories grc = new GetRelatedCategories();
00169
00170       Category cat = new Category( node.CategoryValue.TModelKey, node.CategoryValue.KeyValue );
00171       grc.Categories.Add( cat );
00172
00173
00174       //
00175       // If the Parent is null, it is a root node (tModel)
00176       //
00177       if( node.IsSchemeNode )
00178         grc.Categories[ 0 ].RelationshipQualifiers.Add( RelationshipQualifier.root );
00179       else
00180         grc.Categories[ 0 ].RelationshipQualifiers.Add( RelationshipQualifier.child );
00181
00182       CategoryList list = null;
00183       try
00184       {
00185         list = grc.Send( _connection );
00186       }
00187       catch( Exception e )
00188       {
00189         MessageBox.Show( this, e.Message, "Error Loading Tree Node" );
00190         return;
00191       }
00192
00193
00194       CategoryValueCollection values;
00195
00196       if( node.IsSchemeNode )
00197         values = list.CategoryInfos[ 0 ].Roots;
00198       else
00199         values = list.CategoryInfos[ 0 ].Children;
00200
00201       foreach( CategoryValue val in values )
00202       {
00203         CategoryTreeNode subnode = new CategoryTreeNode( val );
00204         subnode.CategoryValue.TModelKey = node.CategoryValue.TModelKey;
00205         node.Nodes.Add( subnode );
00206       }
00207
00208       node.HasDownloadedChildren = true;
00209
00210
00211     }
00212
00213     #region Component Designer generated code
00214     /// <summary>
00215     /// Required method for Designer support - do not modify
00216     /// the contents of this method with the code editor.
00217     /// </summary>
00218     private void InitializeComponent()
00219     {
00220       //
00221       // CategoryTree
00222       //
00223       this.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.CategoryTree_BeforeExpand);
00224
00225     }
00226     #endregion
00227
00228     private void CategoryTree_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
00229     {
00230       CategoryTreeNode node = (CategoryTreeNode)e.Node;
00231       if( !node.HasDownloadedChildren )
00232       {
00233         GetChildren( node );
00234       }
00235     }
00236   }
00237
00238   public class CategoryTreeNode : TreeNode
00239   {
00240     private CategoryTreeNode(){}
00241     public CategoryTreeNode( CategoryValue val )
00242     {
00243       _categoryValue = val;
00244
00245       Text = val.KeyName;
00246       //
00247       // Add a blank node to force the + sign.
00248       //
00249       Nodes.Add( new TreeNode() );
00250     }
00251
00252     private CategoryValue _categoryValue;
00253     private bool _hasDownloadedChildren;
00254
00255     public CategoryValue CategoryValue
00256     {
00257       get{ return _categoryValue; }
00258     }
00259     internal bool IsSchemeNode
00260     {
00261       get{ return null == Parent; }
00262     }
00263     internal bool HasDownloadedChildren
00264     {
00265       get{ return _hasDownloadedChildren; }
00266       set{ _hasDownloadedChildren = value; }
00267     }
00268   }
00269 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/ido.h Source File

  • Com
  • Fundamentals
  • SimpSvr

ido.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: ido.h
00003 //
00004 //      Definition of CDataObject
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IDO_H_)
00009 #define _IDO_H_
00010
00011
00012 #include <ole2.h>
00013 #include "obj.h"
00014
00015 class CSimpSvrObj;
00016
00017 interface CDataObject : public IDataObject
00018 {
00019 private:
00020   CSimpSvrObj FAR * m_lpObj;
00021   int m_nCount;
00022
00023 public:
00024   CDataObject::CDataObject(CSimpSvrObj FAR * lpSimpSvrObj)
00025     {
00026     m_lpObj = lpSimpSvrObj;
00027     m_nCount = 0;
00028     };
00029
00030   CDataObject::~CDataObject() {};
00031
00032   STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppvObj);
00033   STDMETHODIMP_(ULONG) AddRef ();
00034   STDMETHODIMP_(ULONG) Release ();
00035
00036   STDMETHODIMP DAdvise  ( FORMATETC FAR* pFormatetc, DWORD advf,
00037           LPADVISESINK pAdvSink, DWORD FAR* pdwConnection);
00038   STDMETHODIMP DUnadvise  ( DWORD dwConnection);
00039   STDMETHODIMP EnumDAdvise  ( LPENUMSTATDATA FAR* ppenumAdvise);
00040   STDMETHODIMP EnumFormatEtc  ( DWORD dwDirection,
00041                   LPENUMFORMATETC FAR* ppenumFormatEtc);
00042   STDMETHODIMP GetCanonicalFormatEtc  ( LPFORMATETC pformatetc,
00043                       LPFORMATETC pformatetcOut);
00044   STDMETHODIMP GetData  ( LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium );
00045   STDMETHODIMP GetDataHere  ( LPFORMATETC pformatetc, LPSTGMEDIUM pmedium );
00046   STDMETHODIMP QueryGetData  ( LPFORMATETC pformatetc );
00047   STDMETHODIMP SetData  ( LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium,
00048               BOOL fRelease);
00049
00050
00051 };
00052
00053 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBasePropertyPage Member List

This is the complete list of members for CBasePropertyPage, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
BApplyChanges(void) | CBasePropertyPage | [protected, virtual]
BApplyChanges(void) | CBasePropertyPage | [protected, virtual]
BBackPressed(void) const | CBasePropertyPage | [inline, protected]
BBackPressed(void) const | CBasePropertyPage | [inline, protected]
BBuildPropList(CClusPropList &rcplInout, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected, virtual]
BBuildPropList(CClusPropList &rcplInout, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected, virtual]
BSaved(void) const | CBasePropertyPage | [inline, protected]
BSaved(void) const | CBasePropertyPage | [inline, protected]
BSetPrivateProps(BOOL fValidateOnlyIn=FALSE, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected]
BSetPrivateProps(BOOL fValidateOnlyIn=FALSE, BOOL fNoNewPropsIn=FALSE) | CBasePropertyPage | [protected]
BWizard(void) const | CBasePropertyPage | [inline, protected]
BWizard(void) const | CBasePropertyPage | [inline, protected]
CBasePropertyPage(void) | CBasePropertyPage |
CBasePropertyPage(UINT nIDTemplateIn, UINT nIDCaptionIn=0) | CBasePropertyPage |
CBasePropertyPage(void) | CBasePropertyPage |
CBasePropertyPage(UINT nIDTemplateIn, UINT nIDCaptionIn=0) | CBasePropertyPage |
CommonConstruct(void) | CBasePropertyPage | [protected]
CommonConstruct(void) | CBasePropertyPage | [protected]
Cot(void) const | CBasePropertyPage | [inline]
Cot(void) const | CBasePropertyPage | [inline]
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
Cprops(void) const | CBasePropertyPage | [inline, protected, virtual]
Cprops(void) const | CBasePropertyPage | [inline, protected, virtual]
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
DisplaySetPropsError(DWORD scIn, UINT idsOperIn) const | CBasePropertyPage | [protected, virtual]
DisplaySetPropsError(DWORD scIn, UINT idsOperIn) const | CBasePropertyPage | [protected, virtual]
DoDataExchange(CDataExchange *pDX) | CBasePropertyPage | [protected, virtual]
DoDataExchange(CDataExchange *pDX) | CBasePropertyPage | [protected, virtual]
EnableNext(BOOL fEnableIn=TRUE) | CBasePropertyPage | [protected]
EnableNext(BOOL fEnableIn=TRUE) | CBasePropertyPage | [protected]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [virtual]
Hcluster(void) const | CBasePropertyPage | [inline, protected]
Hcluster(void) const | CBasePropertyPage | [inline, protected]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
Hpage(void) const | CBasePropertyPage | [inline]
Hpage(void) const | CBasePropertyPage | [inline]
HrCreatePage(void) | CBasePropertyPage |
HrCreatePage(void) | CBasePropertyPage |
HrInit(CExtObject *peoInout) | CBasePropertyPage | [virtual]
HrInit(CExtObject *peoInout) | CBasePropertyPage | [virtual]
IDD enum value | CBasePropertyPage |
IddPropertyPage(void) const | CBasePropertyPage | [inline, protected]
IddPropertyPage(void) const | CBasePropertyPage | [inline, protected]
IddWizardPage(void) const | CBasePropertyPage | [inline, protected]
IddWizardPage(void) const | CBasePropertyPage | [inline, protected]
IdsCaption(void) const | CBasePropertyPage | [inline, protected]
IdsCaption(void) const | CBasePropertyPage | [inline, protected]
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_bBackPressed | CBasePropertyPage | [protected]
m_bDoDetach | CBasePropertyPage | [protected]
m_bSaved | CBasePropertyPage | [protected]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hpage | CBasePropertyPage | [protected]
m_hWnd | CPropertyPage | [protected]
m_iddPropertyPage | CBasePropertyPage | [protected]
m_iddWizardPage | CBasePropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_idsCaption | CBasePropertyPage | [protected]
m_peo | CBasePropertyPage | [protected]
m_pIPropertyPageSite | CPropertyPage | [protected]
m_staticIcon | CBasePropertyPage |
m_staticTitle | CBasePropertyPage |
m_strTitle | CBasePropertyPage |
Move(LPCRECT pRect) | CPropertyPage |
OnApply() | CBasePropertyPage | [virtual]
OnApply() | CBasePropertyPage | [virtual]
OnChangeCtrl() | CBasePropertyPage | [protected]
OnChangeCtrl() | CBasePropertyPage | [protected]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CBasePropertyPage | [protected]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CBasePropertyPage | [protected]
OnDestroy() | CBasePropertyPage | [protected]
OnDestroy() | CBasePropertyPage | [protected]
OnInitDialog() | CBasePropertyPage | [protected, virtual]
OnInitDialog() | CBasePropertyPage | [protected, virtual]
OnSetActive() | CBasePropertyPage | [virtual]
OnSetActive() | CBasePropertyPage | [virtual]
OnWizardBack() | CBasePropertyPage | [virtual]
OnWizardBack() | CBasePropertyPage | [virtual]
OnWizardFinish() | CBasePropertyPage | [virtual]
OnWizardFinish() | CBasePropertyPage | [virtual]
OnWizardNext() | CBasePropertyPage | [virtual]
OnWizardNext() | CBasePropertyPage | [virtual]
Peo(void) const | CBasePropertyPage | [inline, protected]
Peo(void) const | CBasePropertyPage | [inline, protected]
PiWizardCallback(void) const | CBasePropertyPage | [inline, protected]
PiWizardCallback(void) const | CBasePropertyPage | [inline, protected]
Pprops(void) const | CBasePropertyPage | [inline, protected, virtual]
Pprops(void) const | CBasePropertyPage | [inline, protected, virtual]
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
ScParseProperties(CClusPropList &rcplIn) | CBasePropertyPage | [protected]
ScParseProperties(CClusPropList &rcplIn) | CBasePropertyPage | [protected]
ScParseUnknownProperty(LPCWSTR pwszNameIn, const CLUSPROP_BUFFER_HELPER &rvalueIn, DWORD cbBufIn) | CBasePropertyPage | [inline, protected, virtual]
ScParseUnknownProperty(LPCWSTR pwszNameIn, const CLUSPROP_BUFFER_HELPER &rvalueIn, DWORD cbBufIn) | CBasePropertyPage | [inline, protected, virtual]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
~CBasePropertyPage(void) | CBasePropertyPage | [inline, virtual]
~CBasePropertyPage(void) | CBasePropertyPage | [inline, virtual]
~CPropertyPage() | CPropertyPage | [virtual]
Generated on Wed Nov 13 2024 16:55:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/malspy.c Source File

  • Com
  • Fundamentals
  • OleStd

malspy.c

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright (C) Microsoft Corporation, 1994 - 2000.
00005 //
00006 //  File:       cmallspy.c
00007 //
00008 //  Contents:   Sample implementation of IMallocSpy.  The implementation here
00009 //              is pretty simple.  It assumes that all we want to do is keep
00010 //              a header on the front of all allocations so we can note
00011 //              interesting information.
00012 //
00013 //  Classes:    CMallocSpy
00014 //
00015 //----------------------------------------------------------------------
00016
00017 #include <ole2.h>
00018 #include <olestd.h>
00019
00020 OLEDBGDATA
00021
00022 #include "malspy.h"
00023
00024 #define TOKEN 0xDEAD
00025
00026 typedef struct tagHeader
00027 {
00028     UINT    uiTag;
00029     ULONG   cbSize;
00030 } HEADER, * LPHEADER;
00031
00032 // The following macro is used to ensure that the token placed at the
00033 // end of each memory block is always aligned on a dword boundary.
00034 // This is necessary to avoid alignment faults on some systems.
00035 #define DWORDALIGN(x) ((x + 3) & (~3))
00036
00037 typedef struct CMallocSpy {
00038   IMallocSpyVtbl FAR*     lpVtbl;
00039   ULONG                   m_cRef;   // interface specific ref count.
00040   ULONG                   m_cbRequested;
00041 } CMALLOCSPY, *LPCMALLOCSPY;
00042
00043 STDMETHODIMP MallocSpy_QueryInterface(
00044       LPMALLOCSPY             this,
00045       REFIID                  riid,
00046       LPVOID FAR*             lplpUnk);
00047
00048 STDMETHODIMP_(ULONG) MallocSpy_AddRef(
00049     LPMALLOCSPY this);
00050
00051 STDMETHODIMP_(ULONG) MallocSpy_Release(
00052     LPMALLOCSPY this);
00053
00054 STDMETHODIMP_(ULONG) MallocSpy_PreAlloc(
00055     LPMALLOCSPY this,
00056     ULONG cbRequest);
00057
00058 STDMETHODIMP_(void *) MallocSpy_PostAlloc(
00059     LPMALLOCSPY this,
00060     void *pActual);
00061
00062 STDMETHODIMP_(void *) MallocSpy_PreFree(
00063     LPMALLOCSPY this,
00064     void *pRequest, BOOL fSpyed);
00065
00066 STDMETHODIMP_(void) MallocSpy_PostFree(
00067     LPMALLOCSPY this,
00068     BOOL fSpyed);
00069
00070 STDMETHODIMP_(ULONG) MallocSpy_PreRealloc(
00071     LPMALLOCSPY this,
00072     void *pRequest,
00073     ULONG cbRequest,
00074     void **ppNewRequest,
00075     BOOL fSpyed);
00076
00077 STDMETHODIMP_(void *) MallocSpy_PostRealloc(
00078     LPMALLOCSPY this,
00079     void *pActual,
00080     BOOL fSpyed);
00081
00082 STDMETHODIMP_(void *) MallocSpy_PreGetSize(
00083     LPMALLOCSPY this,
00084     void *pRequest,
00085     BOOL fSpyed);
00086
00087 STDMETHODIMP_(ULONG) MallocSpy_PostGetSize(
00088     LPMALLOCSPY this,
00089     ULONG cbActual,
00090     BOOL fSpyed);
00091
00092 STDMETHODIMP_(void *) MallocSpy_PreDidAlloc(
00093     LPMALLOCSPY this,
00094     void *pRequest,
00095     BOOL fSpyed);
00096
00097 STDMETHODIMP_(BOOL) MallocSpy_PostDidAlloc(
00098     LPMALLOCSPY this,
00099     void *pRequest,
00100     BOOL fSpyed,
00101     BOOL fActual);
00102
00103 STDMETHODIMP_(void) MallocSpy_PreHeapMinimize(
00104     LPMALLOCSPY this);
00105
00106 STDMETHODIMP_(void) MallocSpy_PostHeapMinimize(
00107     LPMALLOCSPY this);
00108
00109
00110 IMallocSpyVtbl g_MallocSpyVtbl;
00111
00112 BOOL InitializeMallocSpy(void)
00113 {
00114     BOOL fStatus;
00115     LPCMALLOCSPY lpcMallocSpy = NULL;
00116     HRESULT hr;
00117
00118     OleStdInitVtbl(
00119           &g_MallocSpyVtbl,
00120           sizeof(g_MallocSpyVtbl));
00121
00122     g_MallocSpyVtbl.QueryInterface      = MallocSpy_QueryInterface;
00123     g_MallocSpyVtbl.AddRef              = MallocSpy_AddRef;
00124     g_MallocSpyVtbl.Release             = MallocSpy_Release;
00125     g_MallocSpyVtbl.PreAlloc            = MallocSpy_PreAlloc;
00126     g_MallocSpyVtbl.PostAlloc           = MallocSpy_PostAlloc;
00127     g_MallocSpyVtbl.PreFree             = MallocSpy_PreFree;
00128     g_MallocSpyVtbl.PostFree            = MallocSpy_PostFree;
00129     g_MallocSpyVtbl.PreRealloc          = MallocSpy_PreRealloc;
00130     g_MallocSpyVtbl.PostRealloc         = MallocSpy_PostRealloc;
00131     g_MallocSpyVtbl.PreGetSize          = MallocSpy_PreGetSize;
00132     g_MallocSpyVtbl.PostGetSize         = MallocSpy_PostGetSize;
00133     g_MallocSpyVtbl.PreDidAlloc         = MallocSpy_PreDidAlloc;
00134     g_MallocSpyVtbl.PostDidAlloc        = MallocSpy_PostDidAlloc;
00135     g_MallocSpyVtbl.PreHeapMinimize     = MallocSpy_PreHeapMinimize;
00136     g_MallocSpyVtbl.PostHeapMinimize    = MallocSpy_PostHeapMinimize;
00137
00138     fStatus = OleStdCheckVtbl(
00139           &g_MallocSpyVtbl,
00140           sizeof(g_MallocSpyVtbl),
00141           OLESTR("IMallocSpy"));
00142     if (! fStatus)
00143         return FALSE;
00144
00145     lpcMallocSpy = malloc(sizeof(CMALLOCSPY));
00146
00147     if (NULL == lpcMallocSpy)
00148     {
00149         return FALSE;
00150     }
00151     lpcMallocSpy->lpVtbl = &g_MallocSpyVtbl;
00152     lpcMallocSpy->m_cRef = 0;
00153
00154     hr = CoRegisterMallocSpy((LPMALLOCSPY)lpcMallocSpy);
00155
00156     return(SUCCEEDED(hr));
00157 }
00158
00159 void UninitializeMallocSpy()
00160 {
00161     CoRevokeMallocSpy();
00162 }
00163
00164 //+---------------------------------------------------------------------------
00165 //
00166 //  Function:   CbUserFromCbActual
00167 //
00168 //  Synopsis:   adjusts the size to account for the header and footer
00169 //
00170 //  Arguments:  [cbActual] - actual size of the memory block
00171 //
00172 //  Returns:    size reported to the user
00173 //
00174 //----------------------------------------------------------------------------
00175
00176 ULONG CbUserFromCbActual(ULONG cbActual)
00177 {
00178     return(cbActual - (sizeof(HEADER) + sizeof(UINT)));
00179 }
00180
00181 //+---------------------------------------------------------------------------
00182 //
00183 //  Function:   CbActualFromCbUser
00184 //
00185 //  Synopsis:   adjusts the size to account for the header and footer
00186 //
00187 //  Arguments:  [cbUser] - size reported to the user
00188 //
00189 //  Returns:    actual size of the memory block
00190 //
00191 //----------------------------------------------------------------------------
00192
00193 ULONG CbActualFromCbUser(ULONG cbUser)
00194 {
00195     return(DWORDALIGN(cbUser) + sizeof(HEADER) + sizeof(UINT));
00196 }
00197
00198 //+---------------------------------------------------------------------------
00199 //
00200 //  Function:   PActualFromPUser
00201 //
00202 //  Synopsis:   adjusts the pointer to account for the header, verifying
00203 //              the memory integrity in the process
00204 //
00205 //  Arguments:  [pUser] - pointer reported to the user
00206 //
00207 //  Returns:    acutal pointer to the memory block
00208 //
00209 //----------------------------------------------------------------------------
00210
00211 void * PActualFromPUser(void * pUser)
00212 {
00213     HEADER * pHeader;
00214     UINT * puiFooter;
00215     pHeader = ((LPHEADER)pUser) - 1;
00216     puiFooter = (UINT *)(((BYTE *)pUser) + DWORDALIGN(pHeader->cbSize));
00217
00218     OleDbgAssertSz(TOKEN == pHeader->uiTag, "Illegal memory block.");
00219     OleDbgAssertSz(TOKEN == *puiFooter, "Memory block was overrun.");
00220
00221     if (TOKEN != pHeader->uiTag)
00222     {
00223         // Just to be safe, if we don't find the TOKEN we'll not adjust the
00224         // pointer
00225         return(pUser);
00226     }
00227     return ((void *) (pHeader));
00228 }
00229
00230 //+---------------------------------------------------------------------------
00231 //
00232 //  Function:   PUserFromPActual
00233 //
00234 //  Synopsis:   adjusts the pointer to account for the header, initializing
00235 //              the header and footer in the process to allow verification of
00236 //              memory integrity
00237 //
00238 //  Arguments:  [pActual]    - actual pointer to the memory block
00239 //              [cbDataSize] - size of the memory block requested by the user
00240 //
00241 //  Returns:    pointer to the data which the user may modify
00242 //
00243 //----------------------------------------------------------------------------
00244
00245 void * PUserFromPActual(void * pActual, ULONG cbDataSize)
00246 {
00247     // Mark the block with a TOKEN at the front and the end
00248     // and its size so we can tell if it is bogus
00249     LPHEADER pHeader = pActual;
00250     UINT* puiFooter;
00251
00252     pHeader->uiTag = TOKEN;
00253     pHeader->cbSize = cbDataSize;
00254
00255     pActual = (void *)(pHeader + 1);
00256
00257     puiFooter = (UINT *)(((BYTE *) pActual) + DWORDALIGN(pHeader->cbSize));
00258     *puiFooter = TOKEN;
00259     return(pActual);
00260 }
00261
00262 STDMETHODIMP MallocSpy_QueryInterface(
00263       LPMALLOCSPY  this,
00264       REFIID riid,
00265       LPVOID *                ppUnk)
00266 {
00267     HRESULT hr = S_OK;
00268
00269     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMallocSpy))
00270     {
00271         *ppUnk = this;
00272     }
00273     else
00274     {
00275         *ppUnk = NULL;
00276         hr =  E_NOINTERFACE;
00277     }
00278     this->lpVtbl->AddRef((LPMALLOCSPY)this);
00279     return hr;
00280 }
00281
00282 STDMETHODIMP_(ULONG) MallocSpy_AddRef(
00283     LPMALLOCSPY this)
00284 {
00285     return ++(((LPCMALLOCSPY)this)->m_cRef);
00286 }
00287
00288 STDMETHODIMP_(ULONG) MallocSpy_Release(
00289     LPMALLOCSPY this)
00290 {
00291     ULONG cRef;
00292
00293     cRef = --(((LPCMALLOCSPY)this)->m_cRef);
00294     if (cRef == 0)
00295     {
00296         free(this);
00297     }
00298     return cRef;
00299 }
00300
00301 //+---------------------------------------------------------------------
00302 //
00303 //  Member:     CMallocSpy::PreAlloc
00304 //
00305 //  Synopsis:   Called prior to OLE calling IMalloc::Alloc
00306 //
00307 //  Arguments:  [cbRequest] -- The number of bytes the caller of
00308 //                             is requesting IMalloc::Alloc
00309 //
00310 //  Returns:    The count of bytes to actually allocate
00311 //
00312 //----------------------------------------------------------------------
00313 STDMETHODIMP_(ULONG) MallocSpy_PreAlloc(
00314     LPMALLOCSPY this,
00315     ULONG cbRequest)
00316 {
00317     ((LPCMALLOCSPY)this)->m_cbRequested = cbRequest;
00318     return CbActualFromCbUser(cbRequest);
00319 }
00320
00321 #ifdef TRACEMEM
00322 char szScratch[256];
00323 #endif
00324
00325 //+---------------------------------------------------------------------
00326 //
00327 //  Member:     CMallocSpy::PostAlloc
00328 //
00329 //  Synopsis:   Called after OLE calls IMalloc::Alloc
00330 //
00331 //  Arguments:  [pActual] -- The allocation returned by IMalloc::Alloc
00332 //
00333 //  Returns:    The allocation pointer to return to the caller of
00334 //              IMalloc::Alloc
00335 //
00336 //----------------------------------------------------------------------
00337 STDMETHODIMP_(void *) MallocSpy_PostAlloc(
00338     LPMALLOCSPY this,
00339     void *pActual)
00340 {
00341     void * pUser = PUserFromPActual(pActual, ((LPCMALLOCSPY)this)->m_cbRequested);
00342
00343 #ifdef TRACEMEM
00344     wsprintf(szScratch, "IMalloc: 0x%08lX allocated\n", pUser);
00345     OleDbgOut1(szScratch);
00346 #endif
00347
00348     return(pUser);
00349 }
00350
00351 //+---------------------------------------------------------------------
00352 //
00353 //  Member:     CMallocSpy::PreFree
00354 //
00355 //  Synopsis:   Called prior to OLE calling IMalloc::Free
00356 //
00357 //  Arguments:  [pRequest] -- The allocation to be freed
00358 //              [fSpyed]   -- Whether it was allocated with a spy active
00359 //
00360 //----------------------------------------------------------------------
00361 STDMETHODIMP_(void *) MallocSpy_PreFree(
00362     LPMALLOCSPY this,
00363     void *pRequest, BOOL fSpyed)
00364 {
00365     // Check for NULL
00366     if (pRequest == NULL)
00367     {
00368         return NULL;
00369     }
00370
00371 #ifdef TRACEMEM
00372     wsprintf(szScratch, "IMalloc: 0x%08lX freeing\n", pRequest);
00373     OleDbgOut1(szScratch);
00374 #endif
00375
00376     // Undo the offset
00377     if (fSpyed)
00378     {
00379         return(PActualFromPUser(pRequest));
00380     }
00381     else
00382     {
00383         return pRequest;
00384     }
00385 }
00386
00387
00388 //+---------------------------------------------------------------------
00389 //
00390 //  Member:     CMallocSpy::PostFree
00391 //
00392 //  Synopsis:   Called after OLE calls IMalloc::Free
00393 //
00394 //  Arguments:  [fSpyed]   -- Whether it was allocated with a spy active
00395 //
00396 //  Returns:
00397 //
00398 //----------------------------------------------------------------------
00399 STDMETHODIMP_(void) MallocSpy_PostFree(
00400     LPMALLOCSPY this,
00401     BOOL fSpyed)
00402 {
00403     return;
00404 }
00405
00406 //+---------------------------------------------------------------------
00407 //
00408 //  Member:     CMallocSpy::PreRealloc
00409 //
00410 //  Synopsis:   Called prior to OLE calling IMalloc::Realloc
00411 //
00412 //  Arguments:  [pRequest]     -- The buffer to be reallocated
00413 //              [cbRequest]    -- The requested new size of the buffer
00414 //              [ppNewRequest] -- Where to store the new buffer pointer
00415 //                                to be reallocated
00416 //              [fSpyed]       -- Whether it was allocated with a spy active
00417 //
00418 //  Returns:    The new size to actually be allocated
00419 //
00420 //----------------------------------------------------------------------
00421 STDMETHODIMP_(ULONG) MallocSpy_PreRealloc(
00422     LPMALLOCSPY this,
00423     void *pRequest,
00424     ULONG cbRequest,
00425     void **ppNewRequest,
00426     BOOL fSpyed)
00427 {
00428 #ifdef TRACEMEM
00429     wsprintf(szScratch, "IMalloc: 0x%08lX realocating\n", pRequest);
00430     OleDbgOut1(szScratch);
00431 #endif
00432
00433     if (fSpyed)
00434     {
00435         *ppNewRequest = PActualFromPUser(pRequest);
00436         ((LPCMALLOCSPY)this)->m_cbRequested = cbRequest;
00437         return CbActualFromCbUser(cbRequest);
00438     }
00439     else
00440     {
00441         *ppNewRequest = pRequest;
00442         return cbRequest;
00443     }
00444 }
00445
00446 //+---------------------------------------------------------------------
00447 //
00448 //  Member:     CMallocSpy::PostRealloc
00449 //
00450 //  Synopsis:   Called after OLE calls IMalloc::Realloc
00451 //
00452 //  Arguments:  [pActual] -- Pointer to the reallocated buffer
00453 //              [fSpyed]  -- Whether it was allocated with a spy active
00454 //
00455 //  Returns:    The buffer pointer to return
00456 //
00457 //----------------------------------------------------------------------
00458 STDMETHODIMP_(void *) MallocSpy_PostRealloc(
00459     LPMALLOCSPY this,
00460     void *pActual,
00461     BOOL fSpyed)
00462 {
00463     void * pUser;
00464
00465     if (fSpyed)
00466     {
00467         pUser = PUserFromPActual(pActual, ((LPCMALLOCSPY)this)->m_cbRequested);
00468     }
00469     else
00470     {
00471         pUser = pActual;
00472     }
00473
00474 #ifdef TRACEMEM
00475     wsprintf(szScratch, "IMalloc: 0x%08lX reallocated\n", pUser);
00476     OleDbgOut1(szScratch);
00477 #endif
00478
00479     return(pUser);
00480 }
00481
00482
00483 //+---------------------------------------------------------------------
00484 //
00485 //  Member:     CMallocSpy::PreGetSize
00486 //
00487 //  Synopsis:   Called prior to OLE calling IMalloc::GetSize
00488 //
00489 //  Arguments:  [pRequest] -- The buffer whose size is to be returned
00490 //              [fSpyed]   -- Whether it was allocated with a spy active
00491 //
00492 //  Returns:    The actual buffer with which to call IMalloc::GetSize
00493 //
00494 //----------------------------------------------------------------------
00495 STDMETHODIMP_(void *) MallocSpy_PreGetSize(
00496     LPMALLOCSPY this,
00497     void *pRequest,
00498     BOOL fSpyed)
00499 {
00500     if (fSpyed)
00501     {
00502         return(PActualFromPUser(pRequest));
00503     }else
00504     {
00505         return pRequest;
00506     }
00507 }
00508
00509 //+---------------------------------------------------------------------
00510 //
00511 //  Member:     CMallocSpy::PostGetSize
00512 //
00513 //  Synopsis:   Called after OLE calls IMalloc::GetSize
00514 //
00515 //  Arguments:  [cbActual] -- The result of IMalloc::GetSize
00516 //              [fSpyed]   -- Whether it was allocated with a spy active
00517 //
00518 //  Returns:    The size to return to the IMalloc::GetSize caller
00519 //
00520 //----------------------------------------------------------------------
00521 STDMETHODIMP_(ULONG) MallocSpy_PostGetSize(
00522     LPMALLOCSPY this,
00523     ULONG cbActual,
00524     BOOL fSpyed)
00525 {
00526     if (fSpyed)
00527     {
00528         return CbUserFromCbActual(cbActual);
00529     }
00530     else
00531     {
00532         return cbActual;
00533     }
00534 }
00535
00536 //+---------------------------------------------------------------------
00537 //
00538 //  Member:     CMallocSpy::PreDidAlloc
00539 //
00540 //  Synopsis:   Called prior to OLE calling IMalloc::DidAlloc
00541 //
00542 //  Arguments:  [pRequest] -- The buffer whose allocation is being tested
00543 //              [fSpyed]   -- Whether it was allocated with a spy active
00544 //
00545 //  Returns:    The buffer whose allocation is actually to be tested
00546 //
00547 //----------------------------------------------------------------------
00548 STDMETHODIMP_(void *) MallocSpy_PreDidAlloc(
00549     LPMALLOCSPY this,
00550     void *pRequest,
00551     BOOL fSpyed)
00552 {
00553     if (fSpyed)
00554     {
00555         return(PActualFromPUser(pRequest));
00556     }
00557     else
00558     {
00559         return pRequest;
00560     }
00561 }
00562
00563 //+---------------------------------------------------------------------
00564 //
00565 //  Function:   PostDidAlloc
00566 //
00567 //  Synopsis:   Called after OLE calls the IMalloc::DidAlloc
00568 //
00569 //  Arguments:  [pRequest] -- The passed allocation
00570 //              [fSpyed]   -- Whether it was allocated with a spy active
00571 //              [fActual]  -- The result of IMalloc::DidAlloc
00572 //
00573 //  Returns:    The result of IMalloc::DidAlloc
00574 //
00575 //----------------------------------------------------------------------
00576 STDMETHODIMP_(BOOL) MallocSpy_PostDidAlloc(
00577     LPMALLOCSPY this,
00578     void *pRequest,
00579     BOOL fSpyed,
00580     BOOL fActual)
00581 {
00582     return fActual;
00583 }
00584
00585 //+---------------------------------------------------------------------
00586 //
00587 //  Member:     CMallocSpy::PreHeapMinimize
00588 //
00589 //  Synopsis:   Called prior to OLE calling the IMalloc::HeapMinimize
00590 //
00591 //  Returns:
00592 //
00593 //----------------------------------------------------------------------
00594 STDMETHODIMP_(void) MallocSpy_PreHeapMinimize(
00595     LPMALLOCSPY this)
00596 {
00597     return;
00598 }
00599
00600
00601
00602
00603
00604 //+---------------------------------------------------------------------
00605 //
00606 //  Member:     CMallocSpy::PostHeapMinimize
00607 //
00608 //  Synopsis:   Called after OLE calls the IMalloc::HeapMinimize
00609 //
00610 //  Returns:
00611 //
00612 //----------------------------------------------------------------------
00613 STDMETHODIMP_(void) MallocSpy_PostHeapMinimize(
00614     LPMALLOCSPY this)
00615 {
00616     return;
00617 }
00618
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Object/CallAs/call_as.c Source File

  • Com
  • Fundamentals
  • Object
  • CallAs

call_as.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                        Microsoft RPC
00003                 Copyright Microsoft Corp. 1992-2000
00004                   object call_as Example
00005
00006     FILE:       call_as.c
00007
00008     PURPOSE:    [call_as] Glue routines for proxy DLL
00009
00010     FUNCTIONS:  IHelloCallAs_HelloProc_Proxy
00011                 IHelloCallAs_HelloProc_Stub
00012
00013     COMMENTS:   This version of the Ole2 distributed application that
00014                 prints "hello, world" (or other string) on the server
00015                 features a non-rpcable custom interface being remoted with
00016                 [call_as].
00017
00018 ****************************************************************************/
00019
00020 #include <stdio.h>
00021 #include "rpcproxy.h"
00022 #define INC_OLE2
00023 #include <windows.h>
00024 #include "callas.h" // this is the header file generated by midl
00025
00026
00027 // this file provides the conversion routines between the remoted
00028 // interface and the local view of the interface.  This allows an interface
00029 // with apparently non-remotable methods to be remoted.  The conversions
00030 // may be similar to transmit_as or represent_as conversions, or they
00031 // can be more dramatic, such as synthesizing additional parameters, etc.
00032 // in this case, the return type is changed
00033
00034
00035 // The IHelloCallAs_HelloProc_Proxy routine goes into the vtable for
00036 // the clients IHelloCallAs objects, so the client calls this first
00037 // when they invoke the HelloProc method on an IHelloCallAs object.
00038
00039 // The IHelloCallAs_HelloProc_Stub routine is called by the server
00040 // side stub when the remoted call comes in.  It does any conversions
00041 // needed and then invokes the real HelloProc method on the servers
00042 // IHelloCallAs object implementation.
00043
00044 // both of these must be provided in the proxy DLL, because the
00045 // SAME proxy dll is used for both the client and server sides.
00046
00047
00048
00049
00050 // this routine goes into the client side "proxy" object for the server.
00051 // it has the parameter list of the non-remoted (local) flavor of the
00052 // call, and converts it to the remoted flavor of the call.  It can also
00053 // do special case memory management, have debugging hooks, etc.
00054
00055 MyBoolean
00056 STDMETHODCALLTYPE
00057 IHelloCallAs_HelloProc_Proxy (
00058      IHelloCallAs        * pThis,
00059      unsigned char * pszString
00060     )
00061 {
00062     HRESULT     rc;
00063
00064     printf("Proxy: %s\n", pszString);
00065     rc = IHelloCallAs_RemoteHelloProc_Proxy(pThis, pszString);
00066
00067     return FAILED(rc);
00068 }
00069
00070
00071 // this routine is directly called by the server-side stub code.
00072 // it is called with the remoted param list, and must convert to the
00073 // local flavor.  As with the proxy side routine, this one can also
00074 // do special case memory management, have debugging hooks, etc.
00075
00076 HRESULT
00077 RPC_ENTRY
00078 IHelloCallAs_HelloProc_Stub (
00079      IHelloCallAs        * pThis,
00080      unsigned char * pszString
00081      )
00082 {
00083     MyBoolean   rc;
00084
00085     rc = pThis->lpVtbl->HelloProc(pThis, pszString);
00086     return rc ? S_OK : E_FAIL;
00087 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Property.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Property.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Property
00019 /** @com.interface(iid=00000503-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Property extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=0, type=PROPGET, name="Value", name2="getValue", addFlagsVtable=4)
00023       @com.parameters([type=VARIANT] return) */
00024   public Variant getValue();
00025
00026   /** @com.method(vtoffset=5, dispid=0, type=PROPPUT, name="Value", name2="putValue", addFlagsVtable=4)
00027       @com.parameters([in,type=VARIANT] pval) */
00028   public void setValue(Variant pval);
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=PROPGET, name="Name", name2="getName", addFlagsVtable=4)
00031       @com.parameters([type=STRING] return) */
00032   public String getName();
00033
00034   /** @com.method(vtoffset=7, dispid=1610743811, type=PROPGET, name="Type", name2="getType", addFlagsVtable=4)
00035       @com.parameters([type=I4] return) */
00036   public int getType();
00037
00038   /** @com.method(vtoffset=8, dispid=1610743812, type=PROPGET, name="Attributes", name2="getAttributes", addFlagsVtable=4)
00039       @com.parameters([type=I4] return) */
00040   public int getAttributes();
00041
00042   /** @com.method(vtoffset=9, dispid=1610743812, type=PROPPUT, name="Attributes", name2="putAttributes", addFlagsVtable=4)
00043       @com.parameters([in,type=I4] plAttributes) */
00044   public void setAttributes(int plAttributes);
00045
00046
00047   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x503, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00048 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::GetRowsOptionEnum Member List

This is the complete list of members for msado15::GetRowsOptionEnum, including all inherited members.
adGetRowsRest msado15::GetRowsOptionEnum [static]
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userwizard/stdafx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userwizard

stdafx.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       StdAfx.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // stdafx.cpp : source file that includes just the standard includes
00012 //  stdafx.pch will be the pre-compiled header
00013 //  stdafx.obj will contain the pre-compiled type information
00014
00015 #include "stdafx.h"
00016
00017 #include <atlimpl.cpp>
00018
00019 HRESULT WINAPI CMyWizExtModule::UpdateRegistryCLSID(const CLSID& clsid, BOOL bRegister)
00020 {
00021   static const WCHAR szIPS32[] = _T("InprocServer32");
00022   static const WCHAR szCLSID[] = _T("CLSID");
00023
00024   HRESULT hRes = S_OK;
00025
00026   LPOLESTR lpOleStrCLSIDValue;
00027   ::StringFromCLSID(clsid, &lpOleStrCLSIDValue);
00028
00029   CRegKey key;
00030   if (bRegister)
00031   {
00032     LONG lRes = key.Open(HKEY_CLASSES_ROOT, szCLSID);
00033     if (lRes == ERROR_SUCCESS)
00034     {
00035       lRes = key.Create(key, lpOleStrCLSIDValue);
00036       if (lRes == ERROR_SUCCESS)
00037       {
00038         WCHAR szModule[_MAX_PATH];
00039         ::GetModuleFileName(m_hInst, szModule, _MAX_PATH);
00040         key.SetKeyValue(szIPS32, szModule);
00041       }
00042     }
00043     if (lRes != ERROR_SUCCESS)
00044       hRes = HRESULT_FROM_WIN32(lRes);
00045   }
00046   else
00047   {
00048     key.Attach(HKEY_CLASSES_ROOT);
00049     if (key.Open(key, szCLSID) == ERROR_SUCCESS)
00050       key.RecurseDeleteKey(lpOleStrCLSIDValue);
00051   }
00052   ::CoTaskMemFree(lpOleStrCLSIDValue);
00053   return hRes;
00054 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/RTCOutgoing.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

RTCOutgoing.h

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: RTCOutgoing.h
00006  * ---------- [ Header Declaration File]
00007  *
00008  *
00009  *
00010  ******************************************************/
00011
00012
00013
00014 #ifndef ___RTCOUTGOING_H____
00015 #define ___RTCOUTGOING_H____
00016
00017
00018
00019 #if _MSC_VER > 1000
00020 #pragma once
00021 #endif // _MSC_VER > 1000
00022
00023 #ifndef __AFXWIN_H__
00024   #error include 'stdafx.h' before including this file for PCH
00025 #endif
00026
00027
00028
00029 #include "resource.h"   // main symbols
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // CRTCOutgoingApp:
00033 // See RTCOutgoing.cpp for the implementation of this class
00034 //
00035
00036 class CRTCOutgoingApp : public CWinApp
00037 {
00038 public:
00039   CRTCOutgoingApp();
00040
00041   // Overrides
00042   // ClassWizard generated virtual function overrides
00043   //{{AFX_VIRTUAL(CRTCOutgoingApp)
00044   public:
00045   virtual BOOL InitInstance();
00046   //}}AFX_VIRTUAL
00047
00048   // Implementation
00049
00050   //{{AFX_MSG(CRTCOutgoingApp)
00051     // NOTE - the ClassWizard will add and remove member functions here.
00052     //    DO NOT EDIT what you see in these blocks of generated code !
00053   //}}AFX_MSG
00054   DECLARE_MESSAGE_MAP()
00055 };
00056
00057
00058 #endif // ___RTCOUTGOING_H____
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/capicom/c_sharp/xmldsig/Messages.cs Source File

  • Security
  • capicom
  • c_sharp
  • xmldsig

Messages.cs

Go to the documentation of this file.
00001 namespace Sample {
00002     internal class Messages {
00003         internal static string ExceptionTitle = "An exception was caught!";
00004         internal static string DemoTitle = ".NET/CAPICOM demo";
00005         internal static string SuccessMessage = "The verification of the XML fragment succeeded!";
00006         internal static string FailureMessage = "The verification of the XML fragment failed!";
00007         internal static string CopyrightMessage = "Copyright © 2002 Microsoft Corp.  All rights reserved.";
00008         internal static string ChooseCertMessage = "Select the certificate you want to use:";
00009         internal static string ChooseCertUnableToConstructKey = "Unable to get the private key";
00010         internal static string ChooseCertNoPrivateKey = "This certificate does not have a private key associated with it";
00011         internal static string ChooseCertKeyAlgorithm = "The key associated with this certificate is not an RSA key";
00012     }
00013 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/MultiUI/MultiUI.C Source File

  • WinUI
  • Input
  • Ime
  • MultiUI

MultiUI.C

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      MULTIUI.C                                                     */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                     */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #include <windows.h>
00010 #include <imm.h>
00011 #include <tchar.h>
00012 #include <stdio.h>
00013 #include "resource.h"
00014 #include "multiui.h"
00015
00016
00017 /**********************************************************************/
00018 /*                                                                    */
00019 /*    WinMain (HANDLE, HANDLE, LPSTR, int)                            */
00020 /*                                                                    */
00021 /**********************************************************************/
00022 int APIENTRY WinMain (
00023     HINSTANCE hInstance,
00024     HINSTANCE hPrevInstance,
00025     LPSTR lpCmdLine,
00026     INT nCmdShow)
00027 {
00028     MSG msg = {0};
00029     BOOL bSuccess = TRUE;
00030     BOOL bRet = FALSE;
00031
00032     if (!InitApplication(hInstance))
00033     {
00034         bSuccess = FALSE;
00035         goto exit_func;
00036     }
00037
00038     if (!InitInstance(hInstance, nCmdShow))
00039     {
00040         bSuccess = FALSE;
00041         goto exit_func;
00042     }
00043
00044
00045     while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
00046     {
00047         if (bRet == -1)
00048         {
00049             // handle the error and possibly exit
00050             bSuccess = FALSE;
00051         }
00052         else
00053         {
00054             TranslateMessage(&msg);
00055             DispatchMessage(&msg);
00056         }
00057     }
00058
00059
00060 exit_func:
00061     if (bSuccess)
00062     {
00063         return (int)(msg.wParam);
00064     }
00065     else
00066     {
00067         return 0;
00068     }
00069 }
00070
00071 /**********************************************************************/
00072 /*                                                                    */
00073 /*    InitApplication (HANDLE)                                        */
00074 /*                                                                    */
00075 /**********************************************************************/
00076 BOOL InitApplication (
00077     HANDLE hInstance)
00078 {
00079     WNDCLASS wc = {0};
00080     BOOL bSuccess = TRUE;
00081
00082     wc.lpfnWndProc   = (WNDPROC)MainWndProc;
00083     wc.hInstance     = hInstance;
00084     wc.hIcon         = LoadIcon(hInstance,TEXT("MyIcon"));
00085     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00086     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
00087     wc.lpszMenuName  = TEXT("MultiUiMenu");
00088     wc.lpszClassName = TEXT("MultiUiWClass");
00089
00090     if (! RegisterClass (&wc))
00091     {
00092         bSuccess = FALSE;
00093         goto exit_func;
00094     }
00095
00096
00097     wc.style         = CS_DBLCLKS;
00098     wc.lpfnWndProc   = (WNDPROC)NoUINoIMCWndProc;
00099     wc.cbClsExtra    = 0;
00100     wc.cbWndExtra    = WNDEXTRA_NOUINOIMC;
00101     wc.hInstance     = hInstance;
00102     wc.hIcon         = 0;
00103     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00104     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
00105     wc.lpszMenuName  = NULL;
00106     wc.lpszClassName = TEXT("NoUINoIMCWClass");
00107
00108     if (! RegisterClass (&wc))
00109     {
00110         bSuccess = FALSE;
00111         goto exit_func;
00112     }
00113
00114     wc.style         = CS_DBLCLKS;
00115     wc.lpfnWndProc   = (WNDPROC)NoUIOwnIMCWndProc;
00116     wc.cbClsExtra    = 0;
00117     wc.cbWndExtra    = WNDEXTRA_NOUIOWNIMC;
00118     wc.hInstance     = hInstance;
00119     wc.hIcon         = 0;
00120     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00121     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
00122     wc.lpszMenuName  = NULL;
00123     wc.lpszClassName = TEXT("NoUIOwnIMCWClass");
00124
00125     if (! RegisterClass (&wc))
00126     {
00127         bSuccess = FALSE;
00128         goto exit_func;
00129     }
00130
00131     wc.style         = CS_DBLCLKS;
00132     wc.lpfnWndProc   = (WNDPROC)OwnUIOwnIMCWndProc;
00133     wc.cbClsExtra    = 0;
00134     wc.cbWndExtra    = WNDEXTRA_OWNUIOWNIMC;
00135     wc.hInstance     = hInstance;
00136     wc.hIcon         = 0;
00137     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00138     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
00139     wc.lpszMenuName  = NULL;
00140     wc.lpszClassName = TEXT("OwnUIOwnIMCWClass");
00141
00142     if (! RegisterClass (&wc))
00143     {
00144         bSuccess = FALSE;
00145         goto exit_func;
00146     }
00147
00148 exit_func:
00149     return bSuccess;
00150 }
00151
00152 /**********************************************************************/
00153 /*                                                                    */
00154 /*    InitInstance (HANDLE, int)                                      */
00155 /*                                                                    */
00156 /**********************************************************************/
00157 BOOL InitInstance (
00158     HANDLE hInstance,
00159     int nCmdShow)
00160 {
00161     RECT       rc          = {0};
00162     int        iDesc       = 0;
00163     HDC        hIC         = NULL;
00164     TEXTMETRIC tm          = {0};
00165     HFONT      hFont       = GetDefaultGUIFont();
00166     BOOL       bSuccess    = TRUE;
00167     TCHAR      szTitle[20] =  TEXT("MultiUi TestTool");
00168
00169
00170     hInst = hInstance;
00171
00172     hWndMain = CreateWindow(TEXT("MultiUiWClass"), szTitle,
00173                             WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
00174                             CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
00175                             NULL, NULL, hInstance, NULL);
00176     if (!hWndMain)
00177     {
00178         bSuccess = FALSE;
00179         goto exit_func;
00180     }
00181
00182
00183     GetClientRect(hWndMain,&rc);
00184
00185     rc.right  /= 2;
00186     rc.bottom /= 3;
00187
00188     hIC = CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL);
00189
00190     SelectObject(hIC, hFont);
00191
00192     GetTextMetrics(hIC,&tm);
00193
00194     if (rc.bottom >= tm.tmHeight)
00195     {
00196         iDesc = tm.tmHeight + tm.tmExternalLeading;
00197     }
00198
00199     DeleteDC(hIC);
00200
00201     if (!(hWndDef1 = CreateWindowEx(
00202                         WS_EX_CLIENTEDGE, TEXT("NoUINoIMCWClass"), TEXT(""),
00203                         WS_CHILD | WS_VISIBLE,
00204                         rc.left, rc.top + iDesc, rc.right, rc.bottom - iDesc,
00205                         hWndMain, NULL, hInstance, NULL)))
00206     {
00207         bSuccess = FALSE;
00208         goto exit_func;
00209     }
00210
00211     if (!(hWndDef2 = CreateWindowEx(
00212                         WS_EX_CLIENTEDGE, TEXT("NoUINoIMCWClass"), TEXT(""),
00213                         WS_CHILD | WS_VISIBLE,
00214                         rc.right, rc.top + iDesc, rc.right, rc.bottom - iDesc,
00215                         hWndMain, NULL, hInstance, NULL)))
00216     {
00217         bSuccess = FALSE;
00218         goto exit_func;
00219     }
00220
00221     if (!(hWndIMC1 = CreateWindowEx(
00222                         WS_EX_CLIENTEDGE, TEXT("NoUIOwnIMCWClass"), TEXT(""),
00223                         WS_CHILD | WS_VISIBLE,
00224                         rc.left, rc.bottom + iDesc, rc.right, rc.bottom - iDesc,
00225                         hWndMain, NULL, hInstance, NULL)))
00226     {
00227         bSuccess = FALSE;
00228         goto exit_func;
00229     }
00230
00231     if (!(hWndIMC2 = CreateWindowEx(
00232                         WS_EX_CLIENTEDGE, TEXT("NoUIOwnIMCWClass"), TEXT(""),
00233                         WS_CHILD | WS_VISIBLE,
00234                         rc.right, rc.bottom + iDesc, rc.right, rc.bottom - iDesc,
00235                         hWndMain, NULL, hInstance, NULL)))
00236     {
00237         bSuccess = FALSE;
00238         goto exit_func;
00239     }
00240
00241     if (!(hWndIMCUI1 = CreateWindowEx(
00242                         WS_EX_CLIENTEDGE, TEXT("OwnUIOwnIMCWClass"), TEXT(""),
00243                         WS_CHILD | WS_VISIBLE,
00244                         rc.left, rc.bottom * 2 + iDesc, rc.right, rc.bottom - iDesc,
00245                         hWndMain, NULL, hInstance, NULL)))
00246     {
00247         bSuccess = FALSE;
00248         goto exit_func;
00249     }
00250
00251     if (!(hWndIMCUI2 = CreateWindowEx(
00252                         WS_EX_CLIENTEDGE, TEXT("OwnUIOwnIMCWClass"), TEXT(""),
00253                         WS_CHILD | WS_VISIBLE,
00254                         rc.right, rc.bottom * 2 + iDesc, rc.right, rc.bottom - iDesc,
00255                         hWndMain, NULL, hInstance, NULL)))
00256     {
00257         bSuccess = FALSE;
00258         goto exit_func;
00259     }
00260
00261
00262     /* display each windows */
00263     ShowWindow (hWndMain, nCmdShow);
00264     UpdateWindow (hWndMain);
00265
00266 exit_func:
00267     return bSuccess;
00268 }
00269
00270
00271 /**********************************************************************/
00272 /*                                                                    */
00273 /*    MainWndProc (HWND, UINT, WPARAM, LPARAM)                        */
00274 /*                                                                    */
00275 /**********************************************************************/
00276 LRESULT CALLBACK MainWndProc (
00277     HWND hWnd,
00278     UINT message,
00279     WPARAM wParam,
00280     LPARAM lParam)
00281 {
00282     PAINTSTRUCT ps          = {0};
00283     HDC         hDC         = NULL;
00284     RECT        rc          = {0};
00285     int         iDesc       = 0;
00286     HDC         hIC         = NULL;
00287     TEXTMETRIC  tm          = {0};
00288     HFONT       hFont       = NULL;
00289     HFONT       hOldFont    = NULL;
00290     HIMC        hIMC        = NULL;
00291     HWND        hIMEWnd     = NULL;
00292     TCHAR       szDesc[128] = {0};
00293     BOOL        bRetDWP     = FALSE;
00294
00295     switch (message)
00296     {
00297         case WM_CREATE:
00298             break;
00299
00300         case WM_SIZE:
00301             switch (wParam)
00302             {
00303                 case SIZENORMAL: /* fall-through */
00304                 case SIZEFULLSCREEN:
00305                     GetClientRect(hWndMain,&rc);
00306                     rc.right  /= 2;
00307                     rc.bottom /= 3;
00308
00309                     hFont = GetDefaultGUIFont();
00310                     hIC = CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL);
00311
00312                     SelectObject(hIC, hFont);
00313
00314                     GetTextMetrics(hIC,&tm);
00315
00316                     iDesc = 0;
00317                     if (rc.bottom >= tm.tmHeight)
00318                     {
00319                         iDesc = tm.tmHeight + tm.tmExternalLeading;
00320                     }
00321
00322                     DeleteDC(hIC);
00323
00324                     MoveWindow(hWndDef1,
00325                                rc.left,rc.top + iDesc,
00326                                rc.right,rc.bottom - iDesc,TRUE);
00327                     MoveWindow(hWndDef2,
00328                                rc.right,rc.top + iDesc,
00329                                rc.right,rc.bottom - iDesc,TRUE);
00330                     MoveWindow(hWndIMC1,
00331                                rc.left,rc.bottom + iDesc,
00332                                rc.right,rc.bottom - iDesc,TRUE);
00333                     MoveWindow(hWndIMC2,
00334                                rc.right,rc.bottom + iDesc,
00335                                rc.right,rc.bottom - iDesc,TRUE);
00336                     MoveWindow(hWndIMCUI1,
00337                                rc.left,rc.bottom * 2 + iDesc,
00338                                rc.right,rc.bottom - iDesc,TRUE);
00339                     MoveWindow(hWndIMCUI2,
00340                                rc.right,rc.bottom * 2 + iDesc,
00341                                rc.right,rc.bottom - iDesc,TRUE);
00342
00343                     InvalidateRect(hWnd,NULL,TRUE);
00344                     break;
00345
00346                 case SIZEICONIC:
00347                     bRetDWP = TRUE;
00348                     goto exit_func;
00349                     break;
00350
00351             }
00352             break;
00353
00354         case WM_PAINT:
00355             hDC = BeginPaint (hWnd, &ps);
00356             hFont = GetDefaultGUIFont();
00357             hOldFont = SelectObject(hDC, hFont);
00358
00359             GetClientRect(hWndMain,&rc);
00360             rc.right  /= 2;
00361             rc.bottom /= 3;
00362
00363             _sntprintf (szDesc, sizeof(szDesc)/sizeof(szDesc[0]) - 1,
00364                         TEXT("%08lX Default IMC and Default IME window"),
00365                         (DWORD_PTR)hWndDef1);
00366             TextOut (hDC, rc.left,rc.top, szDesc, lstrlen(szDesc));
00367
00368             _sntprintf (szDesc, sizeof(szDesc)/sizeof(szDesc[0]) - 1,
00369                         TEXT("%08lX Default IMC and Default IME window"),
00370                         (DWORD_PTR)hWndDef2);
00371             TextOut (hDC, rc.right, rc.top, szDesc, lstrlen(szDesc));
00372
00373             hIMC = (HIMC)GetWindowLongPtr(hWndIMC1,MYGWL_IMC);
00374             _sntprintf (szDesc, sizeof(szDesc)/sizeof(szDesc[0]) - 1,
00375                         TEXT("%08lX IMC[%08lX] and Default IME window"),
00376                         (DWORD_PTR)hWndIMC1, (DWORD_PTR)hIMC);
00377             TextOut (hDC, rc.left, rc.bottom, szDesc, lstrlen(szDesc));
00378
00379             hIMC = (HIMC)GetWindowLongPtr(hWndIMC2,MYGWL_IMC);
00380             _sntprintf (szDesc, sizeof(szDesc)/sizeof(szDesc[0]) - 1,
00381                         TEXT("%08lX IMC[%08lX] and Default IME window"),
00382                         (DWORD_PTR)hWndIMC2, (DWORD_PTR)hIMC);
00383             TextOut (hDC, rc.right, rc.bottom, szDesc, lstrlen(szDesc));
00384
00385             hIMC = (HIMC)GetWindowLongPtr(hWndIMCUI1,MYGWL_IMC);
00386             hIMEWnd = (HWND)GetWindowLongPtr(hWndIMCUI1,MYGWL_IMEWND);
00387             _sntprintf (szDesc, sizeof(szDesc)/sizeof(szDesc[0]) - 1,
00388                         TEXT("%08lX IMC[%08lX] and IME window[%08lX]"),
00389                         (DWORD_PTR)hWndIMCUI1, (DWORD_PTR)hIMC ,(DWORD_PTR)hIMEWnd);
00390             TextOut (hDC, rc.left, rc.bottom * 2, szDesc, lstrlen(szDesc));
00391
00392             hIMC = (HIMC)GetWindowLongPtr(hWndIMCUI2,MYGWL_IMC);
00393             hIMEWnd = (HWND)GetWindowLongPtr(hWndIMCUI2,MYGWL_IMEWND);
00394             _sntprintf (szDesc, sizeof(szDesc)/sizeof(szDesc[0]) - 1,
00395                         TEXT("%08lX IMC[%08lX] and IME window[%08lX]"),
00396                         (DWORD_PTR)hWndIMCUI2, (DWORD_PTR)hIMC ,(DWORD_PTR)hIMEWnd);
00397             TextOut (hDC, rc.right, rc.bottom * 2, szDesc, lstrlen(szDesc));
00398
00399             SelectObject(hDC, hOldFont);
00400             EndPaint (hWnd, &ps);
00401             break;
00402
00403         case WM_COMMAND:
00404             switch(WMCOMMANDWPARAM(wParam))
00405             {
00406               case IDM_ABOUT:
00407                   DialogBox(hInst, TEXT("ABOUTBOX"), hWnd, (DLGPROC)AboutDlg);
00408                   break;
00409             }
00410             break;
00411
00412         case WM_DESTROY:
00413             PostQuitMessage(0);
00414             break;
00415
00416         default:
00417             bRetDWP = TRUE;
00418             goto exit_func;
00419     }
00420
00421 exit_func:
00422     if (bRetDWP)
00423     {
00424         return DefWindowProc(hWnd, message, wParam, lParam);
00425     }
00426     else
00427     {
00428         return 0L;
00429     }
00430 }
00431
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/Imp_Draw/Imp_Dlg.Cpp Source File

  • NetDS
  • MessageQueuing
  • Imp_Draw

Imp_Dlg.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // Imp_DrawDlg.cpp : implementation file
00013 //
00014
00015
00016 #include "stdafx.h"
00017 #include <afxdisp.h>
00018 #include "Imp_Draw.h"
00019 #include "Imp_Dlg.h"
00020 #include "logindlg.h"
00021
00022 #ifdef _DEBUG
00023 #define new DEBUG_NEW
00024 #undef THIS_FILE
00025 static char THIS_FILE[] = __FILE__;
00026 #endif
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CImp_DrawDlg dialog
00030
00031 CImp_DrawDlg::CImp_DrawDlg(CWnd* pParent /*=NULL*/)
00032   : CDialog(CImp_DrawDlg::IDD, pParent)
00033 {
00034   //{{AFX_DATA_INIT(CImp_DrawDlg)
00035   m_csFriendName = _T("");
00036   m_iRadio = 0;
00037   //}}AFX_DATA_INIT
00038     m_iRadioDS = 0;
00039     m_strRemoteComputerName = _T("");
00040
00041   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32.
00042   m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00043
00044   // Initialize my data members
00045   m_vtguidDraw = "{151ceac0-acb5-11cf-8b51-0020af929546}";
00046   m_vtFriendName = "";
00047   m_pHandler = NULL;
00048 }
00049
00050 CImp_DrawDlg::~CImp_DrawDlg()
00051 {
00052   if (m_pHandler)
00053     delete m_pHandler;  // Handler's destructor releases the event object.
00054 };
00055
00056 void CImp_DrawDlg::DoDataExchange(CDataExchange* pDX)
00057 {
00058   CDialog::DoDataExchange(pDX);
00059   //{{AFX_DATA_MAP(CImp_DrawDlg)
00060   DDX_Control(pDX, IDC_DRAWAREA_SCRIBLLE, m_drawScribble);
00061   DDX_Text(pDX, IDC_EDIT_FRIEND, m_csFriendName);
00062   DDV_MaxChars(pDX, m_csFriendName, 50);
00063   DDX_Radio(pDX, IDC_RADIO_EXPRESS, m_iRadio);
00064   DDX_Control(pDX, IDC_STATIC_C_LABEL, m_cComputerLabel);
00065   DDX_Control(pDX, IDCANCEL, m_CancelButton);
00066   DDX_Control(pDX, IDC_STATIC_Q_LABEL, m_cQueueLabel);
00067   DDX_Control(pDX, IDC_STATIC_CHOOSE_MESSAGE, m_cMessageFrame);
00068   DDX_Control(pDX, IDC_STATIC_CHOOSE_DS, m_cDsFrame);
00069   DDX_Control(pDX, IDC_RADIO_EXPRESS, m_cRadioExpress);
00070   DDX_Control(pDX, IDC_RADIO_DS, m_cRadioDS);
00071   DDX_Control(pDX, IDC_EDIT_FRIEND_COMPUTER, m_cComputerInput);
00072   DDX_Control(pDX, IDC_EDIT_FRIEND, m_cQueueInput);
00073   DDX_Control(pDX, IDC_CONTINUE, m_cContinueButton);
00074   DDX_Control(pDX, IDC_BUTTON_ATTACH, m_btnAttach);
00075   DDX_Radio(pDX, IDC_RADIO_DS, m_iRadioDS);
00076   DDX_Text(pDX, IDC_EDIT_FRIEND_COMPUTER, m_strRemoteComputerName);
00077   DDV_MaxChars(pDX, m_strRemoteComputerName, 50);
00078     DDX_Control(pDX, IDC_RADIO_WORKGROUP, m_cRadioWorkgroup);
00079     DDX_Control(pDX, IDC_RADIO_RECOVERABLE, m_cRadioRecoverable);
00080   //}}AFX_DATA_MAP
00081
00082
00083
00084 }
00085
00086 BEGIN_MESSAGE_MAP(CImp_DrawDlg, CDialog)
00087   //{{AFX_MSG_MAP(CImp_DrawDlg)
00088   ON_WM_PAINT()
00089   ON_WM_QUERYDRAGICON()
00090   ON_BN_CLICKED(IDC_BUTTON_ATTACH, OnButtonAttach)
00091   ON_BN_CLICKED(IDC_CONTINUE, OnConnect)
00092   //}}AFX_MSG_MAP
00093 END_MESSAGE_MAP()
00094
00095
00096 //=--------------------------------------------------------------------------=
00097 // CImp_DrawDlg::GetUserName
00098 // CImp_DrawDlg::GetComputerName
00099 //=--------------------------------------------------------------------------=
00100 // Purpose: These functions wrap the GetUserName and GetComputerName Win32 APIs
00101 //
00102 // Parameters:
00103 //    none
00104 //
00105 // Output:
00106 //    CString - the user name of the currently logged in user,
00107 //          or the computer name of this computer.
00108 //
00109
00110 CString CImp_DrawDlg::GetUserName()
00111 {
00112   DWORD dwsize = 255;
00113   char username[255];
00114   if (::GetUserName(&username[0], &dwsize))
00115     return username;
00116   return "";
00117 };
00118
00119 CString CImp_DrawDlg::GetComputerName()
00120 {
00121   DWORD dwsize = 255;
00122   char username[255];
00123   if (::GetComputerName(&username[0], &dwsize))
00124     return username;
00125   return "";
00126 }
00127
00128 //=--------------------------------------------------------------------------=
00129 // CImp_DrawDlg::LoginPrompt
00130 //=--------------------------------------------------------------------------=
00131 // Purpose: This function pops up a logon dialog box and returns the name given.
00132 //
00133 //
00134 // Parameters:
00135 //    CString - This name will be given as a default name in the dialog box.
00136 //
00137 // Output:
00138 //    CString - This is the name given by the user.
00139 //
00140 //
00141 CString CImp_DrawDlg::LoginPrompt(CString DefaultName)
00142 {
00143   CLoginDlg dialog;
00144   dialog.m_strLogin = DefaultName;
00145   UINT uId = dialog.DoModal();
00146     if (uId ==IDCANCEL)
00147     {
00148         //
00149         // exit
00150         //
00151         OnCancel();
00152     }
00153   return dialog.m_strLogin;
00154 };
00155
00156 //=--------------------------------------------------------------------------=
00157 // CImp_DrawDlg::SendMouseMovement
00158 //=--------------------------------------------------------------------------=
00159 // Purpose: This function sends my mouse movement information to the m_qFriend queue.
00160 //
00161 //
00162 // Parameters:
00163 //    LINE    - a custom type defined in Drawarea.h
00164 //
00165 // Output:
00166 //    none
00167 //
00168 // Notes:
00169 //    This function encodes line data into a string and passes that string
00170 //    as the body of an MSMQ message. This function is called by the
00171 //    CDrawArea class, which was ported from the MSMQ C_Draw sample.
00172 //
00173 void CImp_DrawDlg::SendMouseMovement(LINE line)
00174 {
00175   try
00176   {
00177     if (m_qFriend != NULL && m_qFriend->IsOpen)
00178     {
00179       m_msgOut->Priority = 3;
00180
00181       /* Pack the data into one line (twice). */
00182       WCHAR wcsBody[MAX_MSG_BODY_LEN];
00183       swprintf(wcsBody, L"%07ld%07ld%07ld%07ld",
00184            line.ptStart.x, line.ptStart.y, line.ptEnd.x, line.ptEnd.y);
00185
00186       WCHAR wcsLabel[MQ_MAX_MSG_LABEL_LEN];
00187       swprintf(wcsLabel, L"%07ld,%07ld To %07ld,%07ld",
00188            line.ptStart.x, line.ptStart.y, line.ptEnd.x, line.ptEnd.y);
00189
00190       /* Initialize a variant with the wcsbody data. */
00191       _variant_t  vtBody(wcsBody);
00192
00193       // Setup the message properties.
00194       m_msgOut->Body = vtBody;
00195       m_msgOut->Label = wcsLabel;
00196       m_msgOut->Delivery = m_iRadio;
00197
00198       // Send the message.
00199       m_msgOut->Send(m_qFriend);
00200     };
00201   }
00202   catch(_com_error &comerr)
00203   {
00204     HandleErrors(comerr);
00205   };
00206 };
00207
00208 //=--------------------------------------------------------------------------=
00209 // CImp_DrawDlg::SendKeystroke
00210 //=--------------------------------------------------------------------------=
00211 // Purpose: This function sends my mouse movement information to the m_qFriend
00212 //      queue.
00213 //
00214 //
00215 // Parameters:
00216 //    uChar   - Character value of the keystroke to send.
00217 //
00218 // Output:
00219 //    none
00220 //
00221 // Notes:
00222 //    This function provides a straightforward way to send an MSMQ message.
00223 //    This function is called by the CDrawArea class, which was ported from
00224 //    the MSMQ C_Draw sample.
00225 //
00226 //
00227 void CImp_DrawDlg::SendKeystroke(UINT uChar)
00228 {
00229   try
00230   {
00231     // First, the friend queue must be defined and opened.
00232     if (m_qFriend != NULL && m_qFriend->IsOpen)
00233     {
00234       // Next, push the character into a variant.
00235       _variant_t vtChar((char*)&uChar);
00236
00237       // Now set up the message properties.
00238       m_msgOut->Priority = 4;
00239       m_msgOut->Body = &vtChar;
00240       m_msgOut->Label = "Key: " + uChar;
00241       m_msgOut->Delivery = m_iRadio;
00242
00243       // Lastly, send the message.
00244       m_msgOut->Send(m_qFriend);
00245     };
00246   }
00247   catch(_com_error &comerr)
00248   {
00249     HandleErrors(comerr);
00250   };
00251 };
00252
00253 //=--------------------------------------------------------------------------=
00254 // CImp_DrawDlg::Arrived
00255 //=--------------------------------------------------------------------------=
00256 // Purpose: This function handles events received from the opened queue.
00257 //
00258 //
00259 // Parameters:
00260 //    IDispatch*    - The queue sending the event
00261 //    lErrorCode    - S_OK if no error, otherwise the error code sent
00262 //              along with the queue event
00263 //    lCursor     - Cursor value sent with the event. Unused in
00264 //              this function.
00265 //
00266 // Output:
00267 //    none
00268 //
00269 // Notes:
00270 //    The queue is opened in the OnInitDialog() function. An error event will
00271 //    popup a dialog box and return from the function. For a normal event, retrieve
00272 //    the message body, and interpret it either as a keystroke or as line data.
00273 //    After you are finished handling an event, you must signal your queue that you
00274 //    are ready to receive another event.
00275 //
00276 void CImp_DrawDlg::Arrived(IDispatch* pdispQueue, long lErrorCode, long lCursor)
00277 {
00278   if (lErrorCode != S_OK)
00279   {
00280     // This code is what will run if the _DMSMQEventEvents->ArrivedError() Event is called.
00281     char szErr[30]  = "";
00282     itoa(lErrorCode, szErr, 16);
00283     CString tempString = "Method returned HRESULT: ";
00284     tempString += szErr;
00285     MessageBox(tempString, NULL, MB_ICONSTOP | MB_OK);
00286     return;
00287   };
00288
00289   IMSMQMessagePtr msgIn;
00290   LINE      line;
00291   char*     strTextIn = "";
00292   _variant_t    vtTimeout((short) 100);
00293   _bstr_t     btBody;
00294
00295
00296   try
00297   {
00298     IMSMQQueuePtr q(pdispQueue);    // Creates an MSMQQueue smart pointer pointing to pdispQueue
00299     msgIn = q->Receive(&vtMissing, &vtMissing, &vtMissing, &vtTimeout); // Any messages?
00300     btBody = msgIn->Body;       // Copy the message body to my own bstr.
00301
00302     strTextIn = (char*) btBody;     // Convert to char*.
00303     if (msgIn->BodyLength == 2)
00304       m_drawScribble.AddKeystroke(strTextIn);
00305     else
00306     {
00307       int iRes = sscanf(strTextIn, "%07ld%07ld%07ld%07ld",
00308         &line.ptStart.x, &line.ptStart.y,
00309         &line.ptEnd.x, &line.ptEnd.y);
00310
00311       if (iRes != 0 && iRes != EOF)
00312       {
00313         m_drawScribble.AddLine(line);
00314       }
00315     };
00316   }
00317   catch(_com_error &comerr)
00318   {
00319     HandleErrors(comerr);
00320   };
00321
00322   m_queue->EnableNotification(m_qevent);    // IMPORTANT: After you receive an event, you must re-enable
00323                         // event notification.
00324 };
00325
00326
00327 //=--------------------------------------------------------------------------=
00328 // CImp_DrawDlg::HandleErrors
00329 //=--------------------------------------------------------------------------=
00330 // Purpose: This function pops up an error dialog box and aborts further execution.
00331 //
00332 //
00333 // Parameters:
00334 //    _com_error
00335 //
00336 // Output:
00337 //    none
00338 //
00339 // Notes:
00340 //    This function demonstrates how to pull an HRESULT from the _com_error class.
00341 //
00342 void CImp_DrawDlg::HandleErrors(_com_error &comerr)
00343 {
00344   HRESULT hr = comerr.Error();
00345   char szErr[30] = "";
00346   itoa(hr, szErr, 16);
00347   CString tempString = "The method returned the error code 0x";
00348   tempString += szErr;
00349   tempString += ".  Exiting.";
00350   MessageBox(tempString, NULL, MB_ICONSTOP | MB_OK);
00351   AfxAbort();
00352 };
00353
00354 /////////////////////////////////////////////////////////////////////////////
00355 // CImp_DrawDlg message handlers
00356
00357 //=--------------------------------------------------------------------------=
00358 // CImp_DrawDlg::OnInitDialog
00359 //=--------------------------------------------------------------------------=
00360 // Purpose: This function handles the WM_INITDIALOG message by getting a logon
00361 //      name from the user, opening the user's queue (creating it if need
00362 //          be) and registering for events from that queue.
00363 //
00364 //
00365 // Parameters:
00366 //    none
00367 //
00368 // Output:
00369 //    BOOL  - Indicates success or failure to initialize the dialog box.
00370 //
00371 // Notes:
00372 //    This is the dialog initialization code. The algorithm used in the try-catch
00373 //    block is taken from the MSMQ VB_Draw sample, in many cases on a
00374 //    line-for-line basis.
00375 //
00376
00377 BOOL CImp_DrawDlg::OnInitDialog()
00378 {
00379   CDialog::OnInitDialog();
00380
00381   // Set the icon for this dialog. The framework does this automatically
00382   // when the application's main window is not a dialog box.
00383   SetIcon(m_hIcon, TRUE);     // Set big icon
00384   SetIcon(m_hIcon, FALSE);    // Set small icon
00385
00386     //
00387     // Display the Logon dialog box.
00388     //
00389     CString csDefaultQueueName = GetUserName();
00390   m_csLogin = LoginPrompt(csDefaultQueueName);
00391     while (m_csLogin == "")
00392     {
00393       m_csLogin = LoginPrompt(csDefaultQueueName);
00394     }
00395     SetWindowText(m_csLogin);
00396
00397     //
00398     // First, we have to initialize COM.
00399     //
00400   if (!AfxOleInit())
00401   {
00402     MessageBox("Failed to initialize COM.");
00403     exit(1);
00404   }
00405
00406
00407     //
00408     // Establish whether the local computer is enabled to access the directory
00409   // service (DS) and set the UI accordingly.
00410     //
00411     m_fDsEnabledLocaly = IsDsEnabledLocaly();
00412
00413     if(!m_fDsEnabledLocaly)
00414     {
00415         //
00416         // The computer is DS-disabled. This is the right place to open the receiving queue
00417         // because it is a local private queue. This operation is not time-consuming.
00418         //
00419         //
00420       // Open the receiving queue and receive incoming messages.
00421       //
00422         if (!OpenPrivateReceiveQueue())
00423         {
00424             //
00425             // The attempt to open the receiving queue failed.
00426             //
00427             MessageBox("The receiving queue cannot be opened.");
00428
00429         }
00430     }
00431     initializeUI(m_fDsEnabledLocaly);
00432
00433
00434     return TRUE;  // Return TRUE unless you set the focus to a control.
00435 }
00436
00437 //=--------------------------------------------------------------------------=
00438 // CImp_DrawDlg::OnButtonAttach
00439 //=--------------------------------------------------------------------------=
00440 // Purpose: This function handles the Attach button by looking for the friend
00441 //          queue that the user indicated and then opening that queue if possible.
00442 //
00443 //
00444 // Parameters:
00445 //    none
00446 //
00447 // Output:
00448 //    none
00449 //
00450 // Notes:
00451 //    This is a straightforward way to look for a queue and then open it.
00452 //    This is the last function modified for this project. The next two
00453 //    functions below were generated by MFC.
00454 //
00455
00456 void CImp_DrawDlg::OnButtonAttach()
00457 {
00458
00459     //
00460     // Change the cursor to an hourglass. The constructor changes the cursor.
00461     // When the object goes out of scope, the cursor returns back to normal
00462     //
00463     CWaitCursor wait ;
00464
00465     UpdateData(TRUE);
00466     IMSMQQueryPtr   queryFriend("MSMQ.MSMQQuery");  // Creates an MSMQQuery object
00467   IMSMQQueueInfoPtr qinfoFriend;
00468   IMSMQQueueInfosPtr  qinfos;
00469
00470   try
00471     {
00472
00473       if(m_fDsEnabledLocaly && m_iRadioDS == 0)
00474         {
00475             //
00476             // Connect to a computer in domain (standard) mode.
00477             //
00478
00479         m_csFriendName.MakeUpper();
00480         m_vtFriendName = m_csFriendName;
00481
00482             //
00483             // Locate the queue.
00484             //
00485         qinfos = queryFriend->LookupQueue(&vtMissing,&m_vtguidDraw, &m_vtFriendName);
00486         qinfos->Reset();
00487         qinfoFriend = qinfos->Next();
00488         if (qinfoFriend == NULL)
00489         {
00490           MessageBox("No such friend queue was found.");
00491         return;
00492         }
00493
00494         }
00495         else if(!m_fDsEnabledLocaly || m_iRadioDS == 1)
00496         {
00497             //
00498             // Connect to a computer in workgroup (direct) mode.
00499             //
00500
00501         //
00502             // Obtain the remote queue name and the computer name.
00503             //
00504
00505         m_csFriendName.MakeUpper();
00506             if (m_strRemoteComputerName == TEXT(""))
00507             {
00508                 //
00509                 // If no remote computer name was entered, connect to the local computer.
00510                 //
00511
00512                 m_strRemoteComputerName = TEXT(GetComputerName()) ;
00513             }
00514             m_strRemoteComputerName.MakeUpper();
00515             //
00516             // Construct the direct format name.
00517             //
00518         qinfoFriend.CreateInstance("MSMQ.MSMQQueueInfo");
00519             CString strTemp = "DIRECT=OS:";
00520         qinfoFriend->FormatName = (_bstr_t) LPCTSTR(strTemp + m_strRemoteComputerName + "\\private$\\" + m_csFriendName);
00521         qinfoFriend->Label = (_bstr_t) LPCTSTR(m_csLogin);
00522             //
00523             // When working in workgroup (direct) mode, we must use private queues. We are
00524             // unable to know whether a given private queue on another computer exists or not,
00525             // so here we shall just assume that it does. To make the application more robust,
00526             // an acknowledgment queue should be created on the local computer, and
00527             // a request for acknowledgment messages should be added to the sent messages.
00528             // Then the application can notify the user when a NACK message is received.
00529             //
00530
00531         }
00532         //
00533     // If we have another friend queue open, close it.
00534         //
00535     if (m_qFriend != NULL && m_qFriend->IsOpen)
00536         {
00537       m_qFriend->Close();
00538         }
00539         //
00540         // Open the remote queue.
00541         //
00542     m_qFriend = qinfoFriend->Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
00543     SetWindowText(m_csLogin + " - Connected to " + m_csFriendName);
00544     }
00545     catch (_com_error &comerr)
00546   {
00547         HRESULT hr = comerr.Error();
00548     if (hr != MQ_ERROR_QUEUE_NOT_FOUND )
00549         {
00550         HandleErrors(comerr);
00551         }
00552         else
00553         {
00554             MessageBox("The friend queue cannot be opened.");
00555         }
00556
00557     }
00558
00559 }
00560
00561 // If you add a minimize button to your dialog box, you will need the code below
00562 // to draw the icon. For MFC applications using the document/view model,
00563 // this is done automatically for you by the framework.
00564
00565 void CImp_DrawDlg::OnPaint()
00566 {
00567   if (IsIconic())
00568   {
00569     CPaintDC dc(this); // Device context for painting
00570
00571     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
00572
00573     // Center the icon the in client rectangle.
00574     int cxIcon = GetSystemMetrics(SM_CXICON);
00575     int cyIcon = GetSystemMetrics(SM_CYICON);
00576     CRect rect;
00577     GetClientRect(&rect);
00578     int x = (rect.Width() - cxIcon + 1) / 2;
00579     int y = (rect.Height() - cyIcon + 1) / 2;
00580
00581     // Draw the icon.
00582     dc.DrawIcon(x, y, m_hIcon);
00583   }
00584   else
00585   {
00586     CDialog::OnPaint();
00587   }
00588 }
00589
00590 // The system calls this function to obtain the cursor to display while
00591 // the user drags the minimized window.
00592 HCURSOR CImp_DrawDlg::OnQueryDragIcon()
00593 {
00594   return (HCURSOR) m_hIcon;
00595 }
00596
00597
00598 BOOL CImp_DrawDlg::IsDsEnabledLocaly()
00599 {
00600     BOOL fDSConnection = FALSE;
00601      IMSMQApplicationPtr qapp;
00602     //
00603     // This should work on Windows NT 4.0 and on Windows 2000 and later.
00604     //
00605     try
00606     {
00607      qapp.CreateInstance("MSMQ.MSMQApplication");
00608     }
00609     catch(_com_error &comerr)
00610   {
00611         HandleErrors(comerr);
00612   };
00613
00614
00615     //
00616     // This part handles the diffrence between Windows NT 4.0 and Windows 2000 and later.
00617     // It should work only on Windows 2000 and later.
00618     //
00619     try
00620     {
00621         IMSMQApplication2Ptr qapp2 = qapp;
00622         fDSConnection = qapp2->GetIsDsEnabled();
00623     }
00624   catch(_com_error &comerr)
00625   {
00626         HRESULT hr = comerr.Error();
00627     if (hr == E_NOINTERFACE || hr == E_POINTER)
00628         {
00629       //
00630             // No such interface is implemented, we must be using MSMQ 1.0.
00631             // We can continue as if the local computer is DS-enabled.
00632             //
00633             return TRUE;
00634         }
00635         else
00636         {
00637             HandleErrors(comerr);
00638         }
00639   };
00640     return fDSConnection;
00641 }
00642
00643 void CImp_DrawDlg::initializeUI(BOOL fConnectedToDS)
00644 {
00645     if(fConnectedToDS)
00646     {
00647         //
00648         // The local computer is DS-enabled. Show the relevant controls.
00649         //
00650         m_cDsFrame.ShowWindow(SW_SHOW);
00651         m_cRadioDS.ShowWindow(SW_SHOW);
00652         m_cRadioWorkgroup.ShowWindow(SW_SHOW);
00653         m_cContinueButton.ShowWindow(SW_SHOW);
00654         m_CancelButton.ShowWindow(SW_SHOW);
00655     }
00656     else
00657     {
00658         //
00659         // The local computer is DS-disabled. Show the relevant controls.
00660         //
00661         m_cMessageFrame.ShowWindow(SW_SHOW);
00662         m_cRadioExpress.ShowWindow(SW_SHOW);
00663         m_cRadioRecoverable.ShowWindow(SW_SHOW);
00664         m_cQueueInput.ShowWindow(SW_SHOW);
00665         m_cQueueLabel.ShowWindow(SW_SHOW);
00666         m_cComputerInput.ShowWindow(SW_SHOW);
00667         m_cComputerLabel.ShowWindow(SW_SHOW);
00668         m_CancelButton.ShowWindow(SW_SHOW);
00669         m_btnAttach.ShowWindow(SW_SHOW);
00670     }
00671
00672
00673 }
00674
00675 void CImp_DrawDlg::OnConnect()
00676 {
00677     //
00678     // See what the user selected.
00679     //
00680     UpdateData(TRUE);
00681     if(m_iRadioDS == 0)
00682     {
00683         //
00684         // Access to the DS is enabled, and the user chose to connect in domain (standard) mode.
00685         //
00686         //
00687       // Open the receiving queue and receive incoming messages.
00688       //
00689         CWaitCursor wait;
00690         if (!OpenReceiveQueue())
00691         {
00692             //
00693             // The attempt to open the receiving queue failed.
00694             //
00695             MessageBox("The receiving queue cannot be opened.");
00696
00697         }
00698
00699         //
00700         // Hide relevant controls.
00701         //
00702         m_cDsFrame.ShowWindow(SW_HIDE);
00703         m_cRadioDS.ShowWindow(SW_HIDE);
00704         m_cRadioWorkgroup.ShowWindow(SW_HIDE);
00705         m_cContinueButton.ShowWindow(SW_HIDE);
00706
00707         //
00708         // -> Show relevant controls.
00709         //
00710
00711         m_cMessageFrame.ShowWindow(SW_SHOW);
00712         m_cRadioExpress.ShowWindow(SW_SHOW);
00713         m_cRadioRecoverable.ShowWindow(SW_SHOW);
00714         m_cQueueInput.ShowWindow(SW_SHOW);
00715         m_cQueueLabel.ShowWindow(SW_SHOW);
00716
00717         m_CancelButton.ShowWindow(SW_SHOW);
00718         m_btnAttach.ShowWindow(SW_SHOW);
00719
00720     }
00721     else//m_iRadio == 1
00722     {
00723         //
00724         // Access to the DS is enabled, and the user chose to connect in workgroup (direct) mode.
00725         //
00726         //
00727       // Open the receiving queue and receive incoming messages.
00728       //
00729         CWaitCursor wait ;
00730         if (!OpenPrivateReceiveQueue())
00731         {
00732             //
00733             // The attempt to open the receiving queue failed.
00734             //
00735             MessageBox("The receiving queue cannot be opened.");
00736
00737         }
00738
00739         //
00740         // ->Hide relevant controls.
00741         //
00742         m_cDsFrame.ShowWindow(SW_HIDE);
00743         m_cRadioDS.ShowWindow(SW_HIDE);
00744         m_cRadioWorkgroup.ShowWindow(SW_HIDE);
00745         m_cContinueButton.ShowWindow(SW_HIDE);
00746
00747         //
00748         //-> Show relevant controls.
00749         //
00750         m_cMessageFrame.ShowWindow(SW_SHOW);
00751         m_cRadioExpress.ShowWindow(SW_SHOW);
00752         m_cRadioRecoverable.ShowWindow(SW_SHOW);
00753         m_cQueueInput.ShowWindow(SW_SHOW);
00754         m_cQueueLabel.ShowWindow(SW_SHOW);
00755         m_cComputerInput.ShowWindow(SW_SHOW);
00756         m_cComputerLabel.ShowWindow(SW_SHOW);
00757         m_CancelButton.ShowWindow(SW_SHOW);
00758         m_btnAttach.ShowWindow(SW_SHOW);
00759
00760     }
00761 }
00762
00763 BOOL CImp_DrawDlg::OpenReceiveQueue()
00764 {
00765     try
00766   {
00767
00768     CString csComputerName;
00769     IMSMQQueryPtr   query("MSMQ.MSMQQuery");
00770     IMSMQQueueInfoPtr qinfo;
00771     IMSMQQueueInfosPtr  qinfos;
00772
00773         //
00774     // Note:  You can instantiate a smart pointer from a ProgID using one of
00775     // two methods. As above (the query object), you can pass the ProgID during
00776     // construction or, as below (m_msgOut), you can call the CreateInstance()
00777     // member function.
00778         //
00779     m_msgOut.CreateInstance("MSMQ.MSMQMessage");
00780     m_csLogin.MakeUpper();
00781
00782     m_vtLogin = m_csLogin;
00783     qinfos = query->LookupQueue(&vtMissing,&m_vtguidDraw, &m_vtLogin);  // Look for the user's queue.
00784     qinfos->Reset();
00785     qinfo = qinfos->Next();
00786
00787         //
00788         // If the queue does not exist, create it.
00789         //
00790     if (qinfo == NULL)
00791     {
00792       qinfo.CreateInstance("MSMQ.MSMQQueueInfo");
00793       csComputerName = GetComputerName();
00794       if (csComputerName == "")
00795             {
00796         csComputerName = ".";
00797             }
00798       qinfo->PathName = (_bstr_t) LPCTSTR(csComputerName + "\\" + m_csLogin);
00799       qinfo->Label = (_bstr_t) LPCTSTR(m_csLogin);
00800       qinfo->ServiceTypeGuid = (_bstr_t) m_vtguidDraw;
00801       qinfo->Create();      // Create this queue.
00802     };
00803
00804     for (int i = 0; i < 5; i++)
00805         {
00806       // Try to open it five times in case its creation takes time to replicate.
00807       try
00808       {
00809         m_queue = NULL;
00810         m_queue = qinfo->Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);
00811         if (m_queue != NULL)
00812                 {
00813                     //
00814                     // The queue was found.
00815                     //
00816                     break;
00817                 }
00818       }
00819       catch (_com_error &comerr)
00820       {
00821         HRESULT hr = comerr.Error();
00822         if (hr != MQ_ERROR_QUEUE_NOT_FOUND)
00823                 {
00824           throw comerr;
00825                 }
00826       }
00827     }
00828
00829         if (m_queue == NULL)
00830     {
00831       //
00832             // The queue cannot be opened.
00833             //
00834       return FALSE;
00835     };
00836
00837     // Now we'll link up with the event source.
00838     // The first five lines below imitate the following VB lines.
00839
00840     // Dim WithEvents m_qevent as MSMQ.MSMQEvent
00841     // Set m_qevent = new MSMQ.MSMQEvent
00842
00843     m_qevent.CreateInstance("MSMQ.MSMQEvent");
00844     if (m_pHandler)
00845         {
00846       delete m_pHandler;
00847         }
00848     m_pHandler = new CMSMQEventHandler();
00849     HRESULT hr = m_pHandler->AdviseSource(m_qevent);
00850
00851     if (SUCCEEDED(hr))
00852         {
00853             //
00854             // If we connected in Advise Source,
00855         // tell MSMQ that we want events.
00856             //
00857       hr = m_queue->EnableNotification(m_qevent);
00858         }
00859   }
00860   catch (_com_error &comerr)
00861   {
00862     HandleErrors(comerr);
00863   };
00864
00865     return TRUE; // The queue was opened successfully.
00866
00867 }
00868
00869 BOOL CImp_DrawDlg::OpenPrivateReceiveQueue()
00870 {
00871     try
00872   {
00873
00874
00875     IMSMQQueueInfoPtr qinfo;
00876     m_msgOut.CreateInstance("MSMQ.MSMQMessage");
00877     m_csLogin.MakeUpper();
00878     m_vtLogin = m_csLogin;
00879
00880         //
00881         // Private queues cannot be located using a regular LookupQueue call.
00882         // If the queue doesn't exist, we'll try to create it and open it.
00883         //
00884         try
00885         {
00886         qinfo.CreateInstance("MSMQ.MSMQQueueInfo");
00887         CString csComputerName = GetComputerName();
00888         if (csComputerName == "")
00889             {
00890           csComputerName = ".";
00891             }
00892             qinfo->PathName = (_bstr_t) LPCTSTR(csComputerName + "\\private$\\" + m_csLogin);
00893         qinfo->Label = (_bstr_t) LPCTSTR(m_csLogin);
00894         qinfo->ServiceTypeGuid = (_bstr_t) m_vtguidDraw;
00895         qinfo->Create();      // Create this queue.
00896         }
00897         catch (_com_error &comerr)
00898         {
00899             HRESULT hr = comerr.Error();
00900       if (hr != MQ_ERROR_QUEUE_EXISTS )
00901             {
00902         throw comerr;
00903             }
00904         }
00905
00906     for (int i = 0; i < 5; i++)
00907         {
00908       // We'll try to open it five times in case its creation takes time to replicate
00909       try
00910       {
00911         m_queue = NULL;
00912         m_queue = qinfo->Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);
00913         if (m_queue != NULL)
00914                 {
00915                     //
00916                     // The queue was found.
00917                     //
00918                     break;
00919                 }
00920       }
00921       catch (_com_error &comerr)
00922       {
00923         HRESULT hr = comerr.Error();
00924         if (hr != MQ_ERROR_QUEUE_NOT_FOUND )
00925                 {
00926           throw comerr;
00927                 }
00928       }
00929     }
00930
00931         if (m_queue == NULL)
00932     {
00933       //
00934             // The queue cannot be opened.
00935             //
00936       return FALSE;
00937     };
00938
00939     // Now we'll link up with the event source.
00940     // The first five lines below imitate the following VB lines.
00941
00942     // Dim WithEvents m_qevent as MSMQ.MSMQEvent
00943     // Set m_qevent = new MSMQ.MSMQEvent
00944
00945     m_qevent.CreateInstance("MSMQ.MSMQEvent");
00946     if (m_pHandler)
00947         {
00948       delete m_pHandler;
00949         }
00950     m_pHandler = new CMSMQEventHandler();
00951     HRESULT hr = m_pHandler->AdviseSource(m_qevent);
00952
00953     if (SUCCEEDED(hr))
00954         {
00955             //
00956             // If we connected in Advise Source,
00957         // tell MSMQ that we want events.
00958             //
00959       hr = m_queue->EnableNotification(m_qevent);
00960         }
00961   }
00962   catch (_com_error &comerr)
00963   {
00964
00965         HandleErrors(comerr);
00966   }
00967
00968     return TRUE; // The queue was opened successfully.
00969
00970 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/crmsub.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

crmsub.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "ComSpyCtl.h"
00019 #include <comsvcs.h>
00020 #include "SysLCESub.h"
00021 #include "ComSpyAudit.h"
00022
00023 #include "CComSpy.h"
00024 #include "crmsub.h"
00025
00026
00027 STDMETHODIMP CCRMSub::OnCRMRecoveryStart(
00028       COMSVCSEVENTINFO * pInfo,
00029       GUID guidApp)
00030 {
00031   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMRecoveryStart"), GuidToBstr(pInfo->guidApp));
00032
00033   IF_AUDIT_DO(OnCRMRecoveryStart)(pInfo->perfCount, GuidToBstr(pInfo->guidApp));
00034
00035   return S_OK;
00036
00037 } // CCRMSub::OnCRMRecoveryStart
00038
00039
00040 STDMETHODIMP CCRMSub::OnCRMRecoveryDone(
00041       COMSVCSEVENTINFO * pInfo,
00042       GUID guidApp)
00043 {
00044   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMRecoveryDone"), GuidToBstr(pInfo->guidApp));
00045
00046   IF_AUDIT_DO(OnCRMRecoveryDone)(pInfo->perfCount, GuidToBstr(pInfo->guidApp));
00047
00048   return S_OK;
00049
00050 } // CCRMSub::OnCRMRecoveryDone
00051
00052
00053 STDMETHODIMP CCRMSub::OnCRMCheckpoint(
00054       COMSVCSEVENTINFO * pInfo,
00055       GUID guidApp)
00056 {
00057   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMCheckpoint"), GuidToBstr(pInfo->guidApp));
00058
00059   IF_AUDIT_DO(OnCRMCheckpoint)(pInfo->perfCount, GuidToBstr(pInfo->guidApp));
00060
00061   return S_OK;
00062
00063 } // CCRMSub::OnCRMCheckpoint
00064
00065
00066 STDMETHODIMP CCRMSub::OnCRMBegin(
00067       COMSVCSEVENTINFO * pInfo,
00068       GUID guidClerkCLSID,
00069       GUID guidActivity,
00070       GUID guidTx,
00071       WCHAR szProgIdCompensator[64],      // NOTE: hardcoded
00072       WCHAR szDescription[64])        // NOTE: hardcoded
00073 {
00074   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMBegin"), GuidToBstr(pInfo->guidApp));
00075
00076   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00077   m_pSpy->AddParamValueToList(L"Activity ID", GuidToBstr(guidActivity));
00078   m_pSpy->AddParamValueToList(L"Transaction UOW ID", GuidToBstr(guidTx));
00079   m_pSpy->AddParamValueToList(L"Compensator Prog ID", szProgIdCompensator);
00080   m_pSpy->AddParamValueToList(L"Description", szDescription);
00081
00082   IF_AUDIT_DO(OnCRMBegin)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00083                  GuidToBstr(guidClerkCLSID),
00084                  GuidToBstr(guidActivity),
00085                  GuidToBstr(guidTx),
00086                  szProgIdCompensator,
00087                  szDescription
00088                  );
00089
00090   return S_OK;
00091
00092 } // CCRMSub::OnCRMBegin
00093
00094
00095 STDMETHODIMP CCRMSub::OnCRMPrepare(
00096       COMSVCSEVENTINFO * pInfo,
00097       GUID guidClerkCLSID)
00098 {
00099   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMPrepare"), GuidToBstr(pInfo->guidApp));
00100
00101   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00102
00103   IF_AUDIT_DO(OnCRMPrepare)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00104                GuidToBstr(guidClerkCLSID)
00105                );
00106
00107
00108   return S_OK;
00109
00110 } // CCRMSub::OnCRMPrepare
00111
00112
00113 STDMETHODIMP CCRMSub::OnCRMCommit(
00114       COMSVCSEVENTINFO * pInfo,
00115       GUID guidClerkCLSID)
00116 {
00117   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMCommit"), GuidToBstr(pInfo->guidApp));
00118
00119   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00120
00121   IF_AUDIT_DO(OnCRMCommit)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00122                GuidToBstr(guidClerkCLSID)
00123                );
00124
00125
00126   return S_OK;
00127
00128 } // CCRMSub::OnCRMCommit
00129
00130
00131
00132 STDMETHODIMP CCRMSub::OnCRMAbort(
00133       COMSVCSEVENTINFO * pInfo,
00134       GUID guidClerkCLSID)
00135 {
00136   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMAbort"), GuidToBstr(pInfo->guidApp));
00137
00138   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00139
00140   IF_AUDIT_DO(OnCRMAbort)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00141                GuidToBstr(guidClerkCLSID)
00142                );
00143
00144
00145   return S_OK;
00146
00147 } // CCRMSub::OnCRMAbort
00148
00149
00150 STDMETHODIMP CCRMSub::OnCRMIndoubt(
00151       COMSVCSEVENTINFO * pInfo,
00152       GUID guidClerkCLSID)
00153 {
00154   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMIndoubt"), GuidToBstr(pInfo->guidApp));
00155
00156   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00157
00158   IF_AUDIT_DO(OnCRMIndoubt)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00159                GuidToBstr(guidClerkCLSID)
00160                );
00161
00162
00163   return S_OK;
00164
00165 } // CCRMSub::OnCRMIndoubt
00166
00167
00168 STDMETHODIMP CCRMSub::OnCRMDone(
00169       COMSVCSEVENTINFO * pInfo,
00170       GUID guidClerkCLSID)
00171 {
00172   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMDone"), GuidToBstr(pInfo->guidApp));
00173
00174   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00175
00176   IF_AUDIT_DO(OnCRMDone)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00177                GuidToBstr(guidClerkCLSID)
00178                );
00179
00180   return S_OK;
00181
00182 } // CCRMSub::OnCRMDone
00183
00184
00185 STDMETHODIMP CCRMSub::OnCRMRelease(
00186       COMSVCSEVENTINFO * pInfo,
00187       GUID guidClerkCLSID)
00188 {
00189   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMRelease"), GuidToBstr(pInfo->guidApp));
00190
00191   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00192
00193   IF_AUDIT_DO(OnCRMRelease)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00194                GuidToBstr(guidClerkCLSID)
00195                );
00196
00197
00198   return S_OK;
00199
00200 } // CCRMSub::OnCRMRelease
00201
00202
00203 STDMETHODIMP CCRMSub::OnCRMAnalyze(
00204       COMSVCSEVENTINFO * pInfo,
00205       GUID guidClerkCLSID,
00206       DWORD dwCrmRecordType,
00207       DWORD dwRecordSize)
00208 {
00209   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMAnalyze"), GuidToBstr(pInfo->guidApp));
00210
00211   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00212
00213   // internals info from CrmLogRecordFormat.h
00214
00215   DWORD dwRecordTypeIndex = (dwCrmRecordType >= 0x20 ? dwCrmRecordType - 0x20 + 4 : dwCrmRecordType);
00216
00217   TCHAR * aRecordType[] =
00218   {
00219     L"None",      // 0x00
00220     L"LogInfo",     // 0x01
00221     L"NewClerk",    // 0x02
00222     L"ClerkList",   // 0x03
00223     L"ClerkBegin",    // 0x20
00224     L"Write",     // 0x21
00225     L"Forget",      // 0x22
00226     L"ClerkEnd",    // 0x23
00227   };
00228
00229   m_pSpy->AddParamValueToList(L"Record Type", aRecordType[dwRecordTypeIndex]);
00230
00231   TCHAR szRecordSize[32];
00232   wsprintf(szRecordSize, L"%d", dwRecordSize);
00233   m_pSpy->AddParamValueToList(L"Record Size", szRecordSize);
00234
00235   IF_AUDIT_DO(OnCRMAnalyze)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00236                GuidToBstr(guidClerkCLSID),
00237                aRecordType[dwRecordTypeIndex],
00238                dwRecordSize
00239                );
00240
00241
00242   return S_OK;
00243
00244 } // CCRMSub::OnCRMAnalyze
00245
00246
00247 STDMETHODIMP CCRMSub::OnCRMWrite(
00248       COMSVCSEVENTINFO * pInfo,
00249       GUID guidClerkCLSID,
00250       BOOL bVariants,
00251       DWORD dwRecordSize)
00252 {
00253   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMWrite"), GuidToBstr(pInfo->guidApp));
00254
00255   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00256
00257   m_pSpy->AddParamValueToList(L"Variants?",  (bVariants ? L"Yes" : L"No"));
00258
00259   TCHAR szRecordSize[32];
00260   wsprintf(szRecordSize, L"%d", dwRecordSize);
00261   m_pSpy->AddParamValueToList(L"Record Size", szRecordSize);
00262
00263   IF_AUDIT_DO(OnCRMWrite)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00264              GuidToBstr(guidClerkCLSID),
00265              bVariants,
00266              dwRecordSize
00267              );
00268
00269   return S_OK;
00270
00271 } // CCRMSub::OnCRMWrite
00272
00273
00274 STDMETHODIMP CCRMSub::OnCRMForget(
00275       COMSVCSEVENTINFO * pInfo,
00276       GUID guidClerkCLSID)
00277 {
00278   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMForget"), GuidToBstr(pInfo->guidApp));
00279
00280   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00281
00282   IF_AUDIT_DO(OnCRMForget)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00283              GuidToBstr(guidClerkCLSID)
00284              );
00285
00286   return S_OK;
00287
00288 } // CCRMSub::OnCRMForget
00289
00290
00291 STDMETHODIMP CCRMSub::OnCRMForce(
00292       COMSVCSEVENTINFO * pInfo,
00293       GUID guidClerkCLSID)
00294 {
00295   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMForce"), GuidToBstr(pInfo->guidApp));
00296
00297   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00298
00299   IF_AUDIT_DO(OnCRMForce)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00300              GuidToBstr(guidClerkCLSID)
00301              );
00302
00303
00304   return S_OK;
00305
00306 } // CCRMSub::OnCRMForce
00307
00308
00309 STDMETHODIMP CCRMSub::OnCRMDeliver(
00310       COMSVCSEVENTINFO * pInfo,
00311       GUID guidClerkCLSID,
00312       BOOL bVariants,
00313       DWORD dwRecordSize)
00314 {
00315   m_pSpy->AddEventToList(pInfo->perfCount, _TEXT("OnCRMDeliver"), GuidToBstr(pInfo->guidApp));
00316
00317   m_pSpy->AddParamValueToList(L"Clerk CLSID", GuidToBstr(guidClerkCLSID));
00318
00319   m_pSpy->AddParamValueToList(L"Variants?",  (bVariants ? L"Yes" : L"No"));
00320
00321   TCHAR szRecordSize[32];
00322   wsprintf(szRecordSize, L"%d", dwRecordSize);
00323   m_pSpy->AddParamValueToList(L"Record Size", szRecordSize);
00324
00325
00326   IF_AUDIT_DO(OnCRMDeliver)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00327              GuidToBstr(guidClerkCLSID),
00328              bVariants,
00329              dwRecordSize
00330              );
00331
00332
00333   return S_OK;
00334
00335 } // CCRMSub::OnCRMDeliver
00336
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/devicenode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

devicenode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CDeviceNode class.
00014 //
00015
00016
00017 #include "DeviceNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CDeviceNode")
00024
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CDeviceNode::thisGUID = CLSID_DeviceNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 CDeviceNode::CDeviceNode()
00035 {
00036   m_SDI.mask        = DEFAULT_SDI_MASK;
00037   m_SDI.displayname = MMC_CALLBACK;
00038   m_SDI.cChildren   = 1;              // Determines if the '+' is displayed
00039   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00040
00041   m_hParentNode     = NULL;
00042   m_dwAttributes    = 0;
00043   m_wzStatus        = NULL;
00044   m_pCompData       = NULL;
00045 }
00046
00047
00048 CDeviceNode::~CDeviceNode()
00049 {
00050 }
00051
00052 //---------------------------------------------------------------------------
00053 //  This node does not call it's parent so
00054 //  pNodeProps->pParentObject is not used.
00055 //
00056 HRESULT CDeviceNode::Initialize( NODE_PROPERTIES* pNodeProps )
00057 {
00058   _ASSERT( NULL != pNodeProps );
00059
00060   SIZE_T  nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00061   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00062   wcscpy( pszTmp, pNodeProps->szNodeName );
00063   if( NULL != m_pwszNodeName )
00064     CoTaskMemFree( m_pwszNodeName );
00065
00066   m_pwszNodeName = pszTmp;
00067   m_pCompData = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00068
00069   RefreshNodeList();                   // Add child nodes
00070                                        // and set images
00071
00072   if( pNodeProps->dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00073   {
00074     m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00075     m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00076     m_dwAttributes   |= ATTRIBUTE_BACKUP_DEVICE;
00077   }
00078   else
00079   {
00080     m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00081     m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00082     m_dwAttributes   |= ~ATTRIBUTE_BACKUP_DEVICE;
00083   }
00084
00085   m_wzStatus      = L"Online";    // Node successfully initialized
00086   m_bOnlineStatus = STATUS_ONLINE;
00087
00088   return S_OK;
00089 }
00090
00091
00092 /////////////////////////////////////////////////////////////////////////////
00093 // Implementation of virtual methods
00094
00095
00096 //---------------------------------------------------------------------------
00097 HRESULT CDeviceNode::GetResultViewType2
00098 (
00099   MMC_COOKIE             nCookie,  //[in] Identifier of object
00100   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00101 )
00102 {
00103   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00104   if( NULL == pszDescStr )
00105     return E_OUTOFMEMORY;
00106
00107   wcscpy( pszDescStr, L"DefaultListView" );
00108   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00109
00110   return S_OK;
00111 }
00112
00113 //---------------------------------------------------------------------------
00114 HRESULT CDeviceNode::GetDisplayInfo
00115 (
00116   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00117 )
00118 {
00119   _ASSERT( NULL != pSDI );
00120   pSDI->displayname = m_pwszNodeName;
00121
00122   return S_OK;
00123 }
00124
00125 //---------------------------------------------------------------------------
00126 HRESULT CDeviceNode::GetDisplayInfo
00127 (
00128   RESULTDATAITEM* pRDI
00129 )
00130 {
00131   _ASSERT( NULL != pRDI );
00132
00133   HRESULT hResult = S_OK;
00134
00135   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00136   {                                  // for each column
00137     switch( pRDI->nCol )
00138     {
00139       case 0:
00140         pRDI->str = m_pwszNodeName;
00141         break;
00142
00143       case 1:                        // Attributes not supported yet
00144         pRDI->str = m_wzStatus;
00145         break;
00146
00147       default:
00148         hResult = S_FALSE;
00149         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00150         break;
00151     }
00152   }
00153   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00154   {
00155     pRDI->nImage = m_SDI.nImage;
00156   }
00157
00158   TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00159   return hResult;
00160
00161 }
00162
00163 /////////////////////////////////////////////////////////////////////////////
00164 // Implementation of notification handlers
00165
00166
00167 //---------------------------------------------------------------------------
00168 HRESULT CDeviceNode::OnSelect
00169 (
00170   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00171   LPARAM        nArg,          //[in] Bools for context & selection state
00172   LPARAM        nParam,        //[in] Not used
00173   LONG_PTR      pComponent     //[in] Points calling CComponent
00174 )
00175 {
00176   HRESULT hResult = S_FALSE;
00177
00178   // Not setting verbs for this node
00179
00180   TRACE_HRESULT(_T("OnSelect"), hResult );
00181   return hResult;
00182 }
00183
00184
00185 //---------------------------------------------------------------------------
00186 HRESULT CDeviceNode::OnShow
00187 (
00188   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00189   LPARAM        nArg,          //[in] TRUE if node was selcted
00190   LPARAM        nParam,        //[in] HSCOPEITEM of selected/deselected item
00191   LONG_PTR      pComponent     //[in] Points to calling IComponent
00192 )
00193 {
00194   HRESULT  hResult = S_FALSE;
00195
00196   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00197
00198   LPHEADERCTRL2  ipHeaderCtrl2 = NULL;
00199   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL2, (LONG_PTR*)&ipHeaderCtrl2 );
00200   if( S_OK != hResult )
00201    return hResult;
00202
00203   LPRESULTDATA  ipResultData = NULL;
00204   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00205   if( S_OK != hResult )
00206    return hResult;
00207
00208
00209   if( TRUE == nArg )  // Selecting a scope node
00210   {
00211     do
00212     {
00213       hResult = ipHeaderCtrl2->InsertColumn( 0, L"Folder Name", 0, 150 );
00214       BREAK_ON_ERROR( hResult );
00215
00216       hResult = ipHeaderCtrl2->InsertColumn( 1, L"Attributes", 0, 150 );
00217       BREAK_ON_ERROR( hResult );
00218
00219       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00220       BREAK_ON_ERROR( hResult );
00221
00222     }while(0);
00223   }
00224   else // not handling deselect notifications
00225   {
00226   }
00227
00228
00229   TRACE_HRESULT(_T("OnShow"), hResult );
00230   return hResult;
00231 }
00232
00233 //---------------------------------------------------------------------------
00234 HRESULT CDeviceNode::OnExpand
00235 (
00236   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00237   LPARAM         nArg,         //[in] TRUE if node was selcted
00238   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00239   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00240 )
00241 {
00242   HRESULT hResult = S_FALSE;
00243
00244   if( NULL == m_pCompData )
00245     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00246
00247   // Request an IConsoleNameSpace2 pointer from CComponentData
00248   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00249   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00250   if( S_OK != hResult )
00251     return hResult;
00252
00253   m_hParentNode = (HSCOPEITEM)nParam;  // Cache HSCOPEITEM of Parent
00254
00255   hResult = DeleteChildItems( ipCNS2 );
00256   hResult = InsertChildItems( ipCNS2 );
00257
00258   TRACE_HRESULT( _T("OnExpand"), hResult );
00259   return hResult;
00260 }
00261
00262
00263 //---------------------------------------------------------------------------
00264 HRESULT CDeviceNode::OnRemoveChildren
00265 (
00266   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00267   LPARAM         nArg,         //[in] TRUE if node was selcted
00268   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00269   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00270 )
00271 {
00272   HRESULT hResult = S_FALSE;
00273
00274   if( NULL == m_pCompData )
00275     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00276
00277   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00278   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00279   if( S_OK != hResult )
00280     return hResult;
00281                                        // Deletes HSCOPEITEMS only...
00282   hResult = DeleteChildItems( ipCNS2 );
00283
00284   POSITION   Pos   = m_NodeList.GetHeadPosition();
00285   LPBASENODE pNode = NULL;
00286   while( Pos )                         // Delete everything...
00287   {
00288     pNode = m_NodeList.GetNext( Pos );
00289     pNode->OnRemoveChildren( ipDataObject, nArg, nParam, pCompData );
00290     delete pNode;
00291   }
00292
00293   m_NodeList.RemoveAll();            // Cleans up the list
00294
00295   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00296   return hResult;
00297
00298 }
00299
00300 //---------------------------------------------------------------------------
00301 //  MMC_HELP:  This gets called when a DeviceNode is selected and
00302 //  the F1 key is pressed.
00303 //
00304 HRESULT CDeviceNode::OnContextHelp
00305 (
00306   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00307   LPARAM        nArg,          //[in] Not used
00308   LPARAM        nParam,        //[in] Not used
00309   LONG_PTR      pComponent     //[in] Points calling CComponent
00310 )
00311 {
00312   HRESULT   hResult = S_FALSE;
00313   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00314
00315   LPOLESTR pszBaseHelpPath  = GetHelpFilePath();
00316   LPOLESTR pszTopicPath     = L"::/DeviceNodes.html";
00317
00318   // Allocate space for the topic string
00319   SIZE_T nBasePathLen  = wcslen( pszBaseHelpPath );
00320   SIZE_T nTopicPathLen = wcslen( pszTopicPath );
00321   SIZE_T nBufferSize   = (nBasePathLen + nTopicPathLen + 1) * sizeof(WCHAR);
00322
00323   // Build the topic string
00324   LPOLESTR pszThisTopicPath = (LPOLESTR)CoTaskMemAlloc( nBufferSize );
00325   wcscpy( pszThisTopicPath, pszBaseHelpPath );
00326   wcscat( pszThisTopicPath, pszTopicPath );
00327
00328   // Request a pointer to IDisplayHelp
00329   IDisplayHelp* ipDisplayHelp = NULL;
00330   pComp->GetInterface( REQUEST_IDISPLAYHELP, (LONG_PTR*)&ipDisplayHelp );
00331
00332   hResult = ipDisplayHelp->ShowTopic( pszThisTopicPath );
00333
00334   TRACE_HRESULT(_T("OnContextHelp"), hResult );   // Return value is not used
00335   return hResult;
00336 }
00337
00338 /////////////////////////////////////////////////////////////////////////////
00339 //  Private Helpers
00340
00341 //---------------------------------------------------------------------------
00342 HRESULT CDeviceNode::DeleteChildItems
00343 (
00344   LPCONSOLENAMESPACE2 ipCNS2
00345 )
00346 {
00347   _ASSERT( NULL != ipCNS2 );
00348
00349   POSITION    Pos     = m_NodeList.GetHeadPosition();
00350   HSCOPEITEM  hItem   = NULL;
00351   LPBASENODE  pNode   = NULL;
00352   HRESULT     hResult = S_FALSE;
00353
00354   while( Pos )                         // Delete everything...
00355   {
00356     pNode = m_NodeList.GetNext( Pos );
00357     hItem = (HSCOPEITEM)pNode->m_SDI.ID;
00358     if( 0 != hItem )
00359       hResult = ipCNS2->DeleteItem( hItem, TRUE );
00360   }
00361
00362   return hResult;
00363 }
00364
00365
00366 //---------------------------------------------------------------------------
00367 HRESULT CDeviceNode::InsertChildItems
00368 (
00369   LPCONSOLENAMESPACE2 ipCNS2
00370 )
00371 {
00372   _ASSERT( NULL != ipCNS2 );
00373   _ASSERT( NULL != m_hParentNode );
00374
00375   HRESULT    hResult = S_FALSE;
00376   POSITION   Pos     = m_NodeList.GetHeadPosition();
00377   LPBASENODE pNode   = NULL;
00378
00379   while( Pos )
00380   {
00381     pNode   = m_NodeList.GetNext( Pos );
00382     pNode->m_SDI.relativeID = m_hParentNode;
00383     hResult = ipCNS2->InsertItem( &pNode->m_SDI );
00384   }
00385
00386   return hResult;
00387 }
00388
00389
00390 //---------------------------------------------------------------------------
00391 //  Only add one child node in this sample
00392 //
00393 HRESULT CDeviceNode::RefreshNodeList()
00394 {
00395   NODE_PROPERTIES NodeProps;
00396   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00397   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00398
00399   WCHAR  szNames[1][32];
00400   wcscpy( szNames[0], L"Root Folder" );
00401
00402   RemoveNodes();             // Clean the node list
00403
00404   LPBASENODE pNode = NULL;
00405   for( DWORD i = 0; i < 1; i++ )
00406   {
00407     wcscpy( NodeProps.szNodeName, szNames[i] );
00408     pNode = new CFolderNode;
00409     pNode->Initialize( &NodeProps );
00410     m_NodeList.AddTail( pNode );
00411   }
00412
00413   return S_OK;
00414 }
00415
00416 //---------------------------------------------------------------------------
00417 //  We do this instead of just calling RemoveAll() because our list contains
00418 //  CBaseNode pointers and so RemoveAll() does not call the destructor for
00419 //  the derived class object.
00420 //
00421 VOID CDeviceNode::RemoveNodes()
00422 {
00423   LPBASENODE pNode = NULL;
00424   POSITION   Pos   = m_NodeList.GetHeadPosition();
00425   while( Pos )
00426   {
00427     pNode = m_NodeList.GetNext( Pos );
00428     delete pNode;
00429   }
00430   m_NodeList.RemoveAll();              // Clean the list
00431 }
00432
00433 /////////////////////////////////////////////////////////////////////////////
00434 //  Public helpers
00435
00436 //---------------------------------------------------------------------------
00437 VOID CDeviceNode::ToggleStatus()
00438 {
00439   // First we have to set the image indexes according to the Online Status
00440   // and the device type
00441   //
00442   if( STATUS_ONLINE == m_bOnlineStatus )
00443   {
00444     m_bOnlineStatus = STATUS_OFFLINE;
00445     m_wzStatus      = L"Offline";
00446     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00447     {
00448       m_SDI.nImage      = IMG_DEVICE_OFFLINE;
00449       m_SDI.nOpenImage  = IMG_DEVICE_OFFLINE;
00450     }
00451     else
00452     {
00453       m_SDI.nImage      = IMG_DRIVE_OFFLINE;
00454       m_SDI.nOpenImage  = IMG_DRIVE_OFFLINE;
00455     }
00456   }
00457   else
00458   {
00459     m_bOnlineStatus = STATUS_ONLINE;
00460     m_wzStatus      = L"Online";
00461     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00462     {
00463       m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00464       m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00465     }
00466     else
00467     {
00468       m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00469       m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00470     }
00471   }
00472   // This is a scope node, so GetDisplayInfo will only ask for images for
00473   // this node when it is in the Result Pane.  To change the image for the
00474   // the Scope Pane we need to call IConsoleNameSpace2::SetItem().  This
00475   // call forces the scope node to be redrawn.
00476   //
00477   SCOPEDATAITEM  sdi;
00478   ZeroMemory( &sdi, sizeof(SCOPEDATAITEM) );
00479   sdi.mask        = SDI_IMAGE | SDI_OPENIMAGE ;
00480   sdi.ID          = m_SDI.ID;
00481   sdi.nImage      = m_SDI.nImage;
00482   sdi.nOpenImage  = m_SDI.nOpenImage;
00483
00484   // Request an IConsoleNameSpace2 pointer from CComponentData
00485   HRESULT  hResult = S_FALSE;
00486   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00487   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00488   if( S_OK == hResult )
00489     hResult = ipCNS2->SetItem( &sdi );
00490
00491 }
00492
00493
00494 /////////////////////////////////////////////////////////////////////////////
00495 //  Support for Context Menus
00496
00497 //---------------------------------------------------------------------------
00498 //  Devices can only add a folder
00499 //
00500 HRESULT CDeviceNode::AddMenuItems
00501 (
00502   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00503   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00504 )
00505 {
00506   _ASSERT( NULL != ipCallback );
00507   HRESULT hResult = S_FALSE;
00508
00509   static CONTEXTMENUITEM ctxMenu[2];
00510     ctxMenu[0].lCommandID        = IDM_NEW_FOLDER;
00511     ctxMenu[0].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00512     ctxMenu[0].fFlags            = MF_GRAYED;
00513     ctxMenu[0].fSpecialFlags     = 0;
00514     ctxMenu[0].strName           = L"New Folder...";
00515     ctxMenu[0].strStatusBarText  = L"Add a new folder";
00516
00517     ctxMenu[1].lCommandID        = IDM_TOGGLE_STATUS;
00518     ctxMenu[1].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
00519     ctxMenu[1].fFlags            = 0;
00520     ctxMenu[1].fSpecialFlags     = 0;
00521     ctxMenu[1].strName           = L"Toggle Online Status";
00522     ctxMenu[1].strStatusBarText  = L"Toggles the device status";
00523
00524
00525   // Add the Add new folder command
00526   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00527   {
00528     hResult = ipCallback->AddItem( &ctxMenu[0] );
00529   }
00530
00531   // Add the Toggle item to the Task menu if allowed...
00532   if( CCM_INSERTIONALLOWED_TOP & *pInsertionAllowed )
00533   {
00534     hResult = ipCallback->AddItem( &ctxMenu[1] );
00535   }
00536
00537   return hResult;
00538 }
00539
00540 //---------------------------------------------------------------------------
00541 HRESULT CDeviceNode::Command
00542 (
00543   long lCommandID          //[in] Indentifier for menu ID
00544 )
00545 {
00546   HRESULT hResult = S_OK;
00547
00548   switch( lCommandID )
00549   {
00550     case IDM_TOGGLE_STATUS:
00551     {
00552       ToggleStatus();
00553       break;
00554     }
00555     case IDM_NEW_FOLDER:
00556     {
00557       // Not handling this command in this sample
00558       break;
00559     }
00560     default:
00561       hResult = S_FALSE;
00562       break;
00563
00564   }
00565   return hResult;
00566 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CExtBuffer Member List

This is the complete list of members for CExtBuffer, including all inherited members.
CExtBuffer(const CExtBuffer &p) | CExtBuffer | [private]
CExtBuffer(void) | CExtBuffer |
FInit(ULONG cItemMax, ULONG cbItem, ULONG cbPage) | CExtBuffer |
GetFirstLastItemH(HACCESSOR &hItemFirst, HACCESSOR &hItemLast) | CExtBuffer |
GetItemOfExtBuffer(HACCESSOR hItem, VOID *pvItem) | CExtBuffer |
InsertIntoExtBuffer(VOID *pvItem, HACCESSOR &hItem) | CExtBuffer |
m_cbAlloc | CExtBuffer | [private]
m_cbItem | CExtBuffer | [private]
m_cbReserved | CExtBuffer | [private]
m_cItem | CExtBuffer | [private]
m_dbAlloc | CExtBuffer | [private]
m_rgItem | CExtBuffer | [private]
operator=(const CExtBuffer &p) | CExtBuffer | [private]
operator[](DBCOUNTITEM nIndex) | CExtBuffer |
~CExtBuffer(void) | CExtBuffer |
Generated on Wed Nov 13 2024 16:56:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/pluggable/plgtermsample.idl Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • pluggable

plgtermsample.idl

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 1998-2001  Microsoft Corporation
00003 //
00004
00005 cpp_quote("/* Copyright (c) 1998-2001  Microsoft Corporation  */")
00006
00007 // This file will be processed by the MIDL tool to
00008 // produce the type library (XXX.tlb) and marshalling code.
00009
00010
00011 #ifndef __PLG_TERMSAMPLE_IDL__
00012 #define __PLG_TERMSAMPLE_IDL__
00013
00014
00015 import "Objsafe.idl";
00016 import "msp.idl";     // for MSP_HANDLE
00017
00018
00019 [
00020     uuid(490BF91E-A979-49EF-8E9D-C794F58E7253),
00021     version(1.0),
00022     helpstring("TAPI3 Pluggable Terminal Sample 1.0 Type Library")
00023 ]
00024
00025 library PLGTRMSMPLib
00026 {
00027     importlib("stdole32.tlb");
00028     importlib("stdole2.tlb");
00029
00030     [
00031         uuid(9488FBA9-FFD2-413B-ADA1-85646C1488D0), //CLSID_PlgTermSample
00032         helpstring("TAPI 3.0 PlgTermSample Class")
00033     ]
00034
00035   coclass PlgTermSample
00036   {
00037     [default] interface ITTerminal;
00038     interface IObjectSafety;
00039     interface ITPluggableTerminalEventSinkRegistration;
00040   };
00041
00042 };
00043
00044 #endif // __PLG_TERMSAMPLE_IDL__
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CGenericUCPDlg Member List

This is the complete list of members for CGenericUCPDlg, including all inherited members.
AddDevice(IUPnPDevice *pDevice) | CGenericUCPDlg |
CGenericUCPDlg(CWnd *pParent=NULL) | CGenericUCPDlg |
ClearAllDataStructures(BOOL fClearFindCombo) | CGenericUCPDlg | [private]
ClearDeviceCombo() | CGenericUCPDlg | [private]
ClearServiceCombo() | CGenericUCPDlg | [private]
DoDataExchange(CDataExchange *pDX) | CGenericUCPDlg | [protected, virtual]
fFileExists(LPTSTR ptszFileName) | CGenericUCPDlg | [private]
IDD enum value | CGenericUCPDlg |
InitializeDevTypeArray() | CGenericUCPDlg | [private]
InitializeUDNList() | CGenericUCPDlg | [private]
iNumberOfInArguments(TCHAR *tszString) | CGenericUCPDlg | [private]
m_ActionInArgument | CGenericUCPDlg |
m_ActionName | CGenericUCPDlg |
m_ActionOutArgument | CGenericUCPDlg |
m_astrDevType | CGenericUCPDlg | [private]
m_AsyncFind | CGenericUCPDlg |
m_CloseApp | CGenericUCPDlg |
m_DeviceCombo | CGenericUCPDlg |
m_DeviceProperties | CGenericUCPDlg |
m_EventText | CGenericUCPDlg |
m_fAsyncFindRunning | CGenericUCPDlg | [private]
m_FindByType | CGenericUCPDlg |
m_FindByUDN | CGenericUCPDlg |
m_FindCombo | CGenericUCPDlg |
m_hIcon | CGenericUCPDlg | [protected]
m_InvokeAction | CGenericUCPDlg |
m_lAsyncFindHandle | CGenericUCPDlg | [private]
m_pDeviceFinder | CGenericUCPDlg | [private]
m_pDeviceFinderCallback | CGenericUCPDlg | [private]
m_Presentation | CGenericUCPDlg |
m_pServiceCallback | CGenericUCPDlg | [private]
m_QueryVariable | CGenericUCPDlg |
m_SCPDURL | CGenericUCPDlg |
m_ServiceCombo | CGenericUCPDlg |
m_StartDiscovery | CGenericUCPDlg |
m_StatusText | CGenericUCPDlg |
m_VariableName | CGenericUCPDlg |
m_ViewSCPD | CGenericUCPDlg |
OnAppAbout() | CGenericUCPDlg | [protected]
OnAsyncFind() | CGenericUCPDlg | [protected]
OnClose() | CGenericUCPDlg | [protected]
OnCloseClick() | CGenericUCPDlg | [protected]
OnDevpropClick() | CGenericUCPDlg | [protected]
OnDiscoveryClicked() | CGenericUCPDlg | [protected]
OnFindByType() | CGenericUCPDlg | [protected]
OnFindbyUDN() | CGenericUCPDlg | [protected]
OnInitDialog() | CGenericUCPDlg | [protected, virtual]
OnInvokeAction() | CGenericUCPDlg | [protected]
OnPaint() | CGenericUCPDlg | [protected]
OnQueryDragIcon() | CGenericUCPDlg | [protected]
OnQueryVariable() | CGenericUCPDlg | [protected]
OnSelEndOkComboDevice() | CGenericUCPDlg | [protected]
OnSelEndOkComboService() | CGenericUCPDlg | [protected]
OnSysCommand(UINT nID, LPARAM lParam) | CGenericUCPDlg | [protected]
PreTranslateMessage(MSG *) | CGenericUCPDlg | [protected, virtual]
ProcessAsyncFind(BSTR bstrSearchType) | CGenericUCPDlg | [private]
ProcessFindByType(BSTR bstrSearchType) | CGenericUCPDlg | [private]
ProcessFindByUDN(BSTR bstrSearchType) | CGenericUCPDlg | [private]
RemoveDevice(BSTR bstrUDN) | CGenericUCPDlg |
StopAsyncFindIfStarted() | CGenericUCPDlg | [private]
~CGenericUCPDlg() | CGenericUCPDlg |
Generated on Wed Nov 13 2024 16:56:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/guids.h Source File

  • SysMgmt
  • MMC
  • Openserv

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {C3F68021-94F3-11d2-9967-0080C7DCB3DC}
00020 DEFINE_GUID(CLSID_CComponentData,
00021             0xc3f68021, 0x94f3, 0x11d2, 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc);
00022
00023 // {CC288C90-94F3-11d2-9967-0080C7DCB3DC}
00024 DEFINE_GUID(CLSID_CSnapinAbout,
00025             0xcc288c90, 0x94f3, 0x11d2, 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CColumnInfo Member List

This is the complete list of members for CColumnInfo, including all inherited members.
AddElement(DBCOLUMNINFOelement) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
Attach(DBORDINAL cColumnInfo, DBCOLUMNINFO *rgColumnInfo, WCHAR *pwszStringBuffer, DBORDINAL cHiddenColumns=0) | CColumnInfo | [inline]
CVector< DBCOLUMNINFO, DBORDINAL >::Attach(CVector &rVector) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
CVector< DBCOLUMNINFO, DBORDINAL >::Attach(DBORDINALcElements, DBCOLUMNINFO *rgElements) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
CColumnInfo() | CColumnInfo | [inline]
CVector(DBORDINALulLowerBound=0, DBORDINALulGrowSize=10) | CVector< DBCOLUMNINFO, DBORDINAL > |
Detach(DBORDINAL *pcElements, DBCOLUMNINFO **prgElements) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
GetCount() | CVector< DBCOLUMNINFO, DBORDINAL > | [inline, virtual]
GetElement(DBORDINALiIndex) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
GetElements() const | CVector< DBCOLUMNINFO, DBORDINAL > | [inline, virtual]
GetOrdinal(DBORDINAL iOrdinal) | CColumnInfo | [inline]
InsertAt(DBORDINALiIndex, DBCOLUMNINFOelement) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
IsHidden(DBORDINAL iOrdinal) | CColumnInfo | [inline]
m_cElements | CVector< DBCOLUMNINFO, DBORDINAL > | [protected]
m_cHiddenColumns | CColumnInfo | [protected]
m_cstrStringBuffer | CColumnInfo | [protected]
m_rgElements | CVector< DBCOLUMNINFO, DBORDINAL > | [protected]
m_ulGrowSize | CVector< DBCOLUMNINFO, DBORDINAL > | [protected]
m_ulLowerBound | CVector< DBCOLUMNINFO, DBORDINAL > | [protected]
m_ulMaxSize | CVector< DBCOLUMNINFO, DBORDINAL > | [protected]
operator[](DBORDINALiIndex) | CVector< DBCOLUMNINFO, DBORDINAL > | [inline, virtual]
RemoveAll() | CColumnInfo | [inline, virtual]
RemoveAt(DBORDINALiIndex) | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
~CColumnInfo() | CColumnInfo | [inline]
~CVector() | CVector< DBCOLUMNINFO, DBORDINAL > | [virtual]
Generated on Wed Nov 13 2024 16:55:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/StoClien.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

StoClien.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      STOCLIEN.H
00003
00004   Summary:   Include file for the STOCLIEN code sample application. In
00005              addition to class definitions, this STOCLIEN.H file contains
00006              definitions of the application's menu, string, and other
00007              resource IDs.
00008
00009              For a comprehensive tutorial code tour of STOCLIEN's contents
00010              and offerings see the tutorial STOCLIEN.HTM file. For
00011              more specific technical details on the internal workings see
00012              the comments dispersed throughout the STOCLIEN source code.
00013
00014   Classes:   CMainWindow.
00015
00016   Functions: WinMain.
00017
00018   Origin:    6-10-96: atrent - Editor-inheritance from CONCLIEN source.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 #if !defined(STOCLIEN_H)
00036 #define STOCLIEN_H
00037
00038 #ifdef __cplusplus
00039
00040
00041 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00042   Class:    CMainWindow
00043
00044   Summary:  Class to encapsulate the application's main window, menu, and
00045             message dispatching behavior.
00046
00047   Methods:  CMainWindow
00048               Constructor.
00049             InitInstance
00050               Creates a new instance of the main window.
00051 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00052 class CMainWindow: public CVirWindow
00053 {
00054   public:
00055     CMainWindow();
00056     ~CMainWindow();
00057     BOOL InitInstance(HINSTANCE hInst, LPSTR pszCmdLine, int nCmdShow);
00058
00059     TCHAR m_szFileName[MAX_PATH];
00060     CMsgBox*   m_pMsgBox;
00061     CGuiPaper* m_pGuiPaper;
00062
00063   protected:
00064     LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00065
00066   private:
00067     LRESULT DoMenu(WPARAM wParam, LPARAM lParam);
00068
00069     WORD m_wWidth;
00070     WORD m_wHeight;
00071     TCHAR m_szFileTitle[MAX_PATH];
00072     TCHAR m_szHelpFile[MAX_PATH];
00073     TEXTMETRIC m_tm;
00074     OPENFILENAME m_ofnFile;
00075 };
00076
00077
00078 #endif // __cplusplus
00079
00080 // Window Class String Macros.
00081 #define MAIN_APP_NAME_STR           "STOCLIEN: "
00082 #define MAIN_WINDOW_TITLE_STR       "STOCLIEN: stoclien.pap"
00083 #define MAIN_WINDOW_CLASS_NAME_STR  "STOCLIENWindow"
00084 #define MAIN_WINDOW_CLASS_MENU_STR  "STOCLIENMenu"
00085
00086 // File Name String Macros.
00087 #define SERVER_TUTFILE_STR          "stoserve.htm"
00088
00089 // OpenFile-related String Macros.
00090 #define OFN_DEFAULTFILES_STR "All Files (*.*)\0*.*\0"
00091 #define OFN_DEFAULTTITLE_STR "Open File"
00092
00093 // Some compile-time constants for ink thickness in pixels.
00094 enum
00095 {
00096   INK_THIN = 2,
00097   INK_MEDIUM = 10,
00098   INK_THICK = 20
00099 };
00100
00101
00102 // File Menu Command Identifiers.
00103 #define IDM_FILE_OPEN               1000
00104 #define IDM_FILE_SAVE               1001
00105 #define IDM_FILE_SAVEAS             1002
00106 #define IDM_FILE_EXIT               1020
00107
00108 // Draw Menu Command Identifiers.
00109 #define IDM_DRAW_ON                 1100
00110 #define IDM_DRAW_OFF                1101
00111 #define IDM_DRAW_REDRAW             1102
00112 #define IDM_DRAW_ERASE              1103
00113
00114 // PEN Menu Command Identifiers.
00115 #define IDM_PEN_COLOR               1200
00116 #define IDM_PEN_THIN                1201
00117 #define IDM_PEN_MEDIUM              1202
00118 #define IDM_PEN_THICK               1203
00119
00120 // Sink Menu Command Identifiers.
00121 #define IDM_SINK_ON                 1300
00122 #define IDM_SINK_OFF                1301
00123
00124 // Help Menu Command Identifiers.
00125 #define IDM_HELP_CONTENTS           1900
00126 #define IDM_HELP_TUTORIAL           1901
00127 #define IDM_HELP_TUTSERVER          1902
00128 #define IDM_HELP_READSOURCE         1904
00129 #define IDM_HELP_ABOUT              1905
00130 #define IDM_HELP_ABOUTSERVER        1906
00131
00132 // Error-related String Identifiers.
00133 #define IDS_COMINITFAILED           2000
00134 #define IDS_APPINITFAILED           2001
00135 #define IDS_OUTOFMEMORY             2002
00136 #define IDS_NOUNICODE               2003
00137 #define IDS_NOSERVER                2004
00138 #define IDS_NOTIMPLEMENTED          2005
00139
00140 #define IDS_ASSERT_FAIL             2200
00141
00142 // Notice-related String Identifiers.
00143 #define IDS_DRAWING_CHANGED         2300
00144 #define IDS_ASK_SAVE                2301
00145 #define IDS_OFN_PAPFILES            2302
00146 #define IDS_OFN_PAPOPEN             2303
00147 #define IDS_OFN_PAPSAVE             2304
00148
00149 #endif
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/progadmin/ABO/EnumerateKeys/EnumerateKeys.cpp Source File

  • Web
  • iis
  • progadmin
  • ABO
  • EnumerateKeys

EnumerateKeys.cpp

Go to the documentation of this file.
00001 /*******************************************
00002 *
00003 * EnumerateKeys.CPP
00004 *
00005 * This is a simple program to enumerate the
00006 * IIS metabase keys using the IMSAdminBase
00007 * interface.
00008 *
00009 ********************************************/
00010
00011
00012 #define STRICT
00013 #define INITGUID
00014 #define WINVER 0x0400
00015 #define _WIN32_DCOM
00016
00017 #include <WINDOWS.H>
00018 #include <OLE2.H>
00019 #include <coguid.h>
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023
00024 #include "iadmw.h"
00025 #include "iiscnfg.h"
00026
00027 int __cdecl wmain(
00028     int                 argc,
00029     wchar_t             *argv[])
00030 {
00031   HRESULT             hr = S_OK;
00032   DWORD               dwEnumIndex;
00033   WCHAR               wszChildKeyName[METADATA_MAX_NAME_LEN];
00034   WCHAR               wszEnumPath[METADATA_MAX_NAME_LEN];
00035     COSERVERINFO        csiMachineName;
00036   OLECHAR             wszMachineName[MAX_PATH];
00037   IClassFactory       *pClassFactory = NULL;
00038   IMSAdminBase        *pAdminBase = NULL;   //interface pointer
00039
00040   if ( (argc < 2) || (argc > 3 ) )
00041   {
00042     _putws( L"ERROR! Wrong number of parameters" );
00043     _putws( L"    You must supply at least the machine name\n" );
00044
00045     hr = E_INVALIDARG;
00046         goto exit;
00047   }
00048
00049     if ( wcslen( argv[1] ) >= MAX_PATH )
00050     {
00051     _putws( L"ERROR! bad" );
00052
00053     hr = E_INVALIDARG;
00054         goto exit;
00055     }
00056
00057   if ( ( argc == 3 ) && ( wcslen( argv[2] ) > METADATA_MAX_NAME_LEN ) )
00058   {
00059     _putws( L"ERROR! bad" );
00060
00061     hr = E_INVALIDARG;
00062         goto exit;
00063   }
00064
00065   //fill the structure for CoGetClassObject
00066   wcsncpy (wszMachineName, argv[1], MAX_PATH-1 );
00067   wszMachineName[MAX_PATH-1] = L'\0';
00068
00069   csiMachineName.pAuthInfo = NULL;
00070   csiMachineName.dwReserved1 = 0;
00071   csiMachineName.dwReserved2 = 0;
00072   csiMachineName.pwszName = wszMachineName;
00073
00074   // Initialize COM
00075     hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
00076     if (FAILED(hr))
00077   {
00078     wprintf( L"ERROR: CoInitialize Failed! Error: 0x%08x\n", hr );
00079         goto exit;
00080   }
00081
00082   hr = CoGetClassObject( CLSID_MSAdminBase, CLSCTX_SERVER, &csiMachineName,
00083                            IID_IClassFactory, (void**) &pClassFactory);
00084   if (FAILED(hr))
00085   {
00086     wprintf( L"ERROR: CoGetClassObject Failed! Error: 0x%08x\n", hr );
00087         goto exit;
00088   }
00089
00090   hr = pClassFactory->CreateInstance(NULL, IID_IMSAdminBase, (void **) &pAdminBase);
00091   if (FAILED(hr))
00092   {
00093     wprintf( L"ERROR: CreateInstance Failed! Error: 0x%08x\n", hr );
00094         goto exit;
00095   }
00096
00097   if (argc != 3)
00098   {
00099     // Set up a default path.
00100     wszEnumPath[0] = L'/';
00101     wszEnumPath[1] = L'\0';
00102   }
00103   else
00104   {
00105       wcsncpy( wszEnumPath, argv[2], METADATA_MAX_NAME_LEN-1 );
00106       wszMachineName[METADATA_MAX_NAME_LEN-1]=L'\0';
00107   }
00108
00109   wprintf( L"Enumerating Path: %s\n", wszEnumPath );
00110
00111   // Enumerate the data
00112   for ( dwEnumIndex = 0; SUCCEEDED(hr); dwEnumIndex++ )
00113   {
00114     hr = pAdminBase -> EnumKeys( METADATA_MASTER_ROOT_HANDLE,
00115                                    wszEnumPath,
00116                                    wszChildKeyName,
00117                                    dwEnumIndex);
00118     if ( SUCCEEDED(hr) )
00119     {
00120         wprintf( L"[%s]\n", wszChildKeyName );
00121     }
00122   }
00123
00124   if ( hr != HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) )
00125   {
00126     wprintf( L"EnumIndex: %d \n", dwEnumIndex );
00127     wprintf( L"EnumKeys return code: 0x%08x\n", hr );
00128
00129     goto exit;
00130   }
00131
00132   hr = S_OK;
00133
00134 exit:
00135   if ( pClassFactory != NULL )
00136   {
00137       pClassFactory->Release();
00138       pClassFactory = NULL;
00139   }
00140   if ( pAdminBase != NULL )
00141   {
00142       pAdminBase->Release();
00143       pAdminBase = NULL;
00144   }
00145
00146   if ( FAILED(hr) )
00147   {
00148       wprintf( L"the example failed with 0x%08x\n", hr );
00149   }
00150
00151   return hr;
00152 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DfV/bitmaps.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DfV

bitmaps.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright 1992 - 2000 Microsoft Corporation.
00005 //
00006 //  File:       bitmaps.h
00007 //
00008 //  Contents:   bitmap helper functions
00009 //
00010 //  Classes:
00011 //
00012 //  Functions:  DDBChangeColor
00013 //              LoadAndStretch
00014 //
00015 //  History:    6-24-94   stevebl   Created
00016 //
00017 //----------------------------------------------------------------------------
00018
00019 #ifndef __BITMAPS_H__
00020 #define __BITMAPS_H__
00021
00022 #define DSPDxax 0x00E20746L
00023
00024 BOOL DDBChangeColor (
00025     HBITMAP hBitmap,
00026     COLORREF crFrom,
00027     COLORREF crTo);
00028
00029 BOOL LoadAndStretch (
00030     HINSTANCE hinst,
00031     HBITMAP hbmpDest,
00032     LPTSTR lpszResource,
00033     UINT cxBitmap,
00034     UINT cyBitmap,
00035     COLORREF crHigh,
00036     COLORREF crNorm);
00037
00038 #endif //__BITMAPS_H__
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCJAVA/Components/qcShip/Ship.java Source File

  • Com
  • Services
  • Queued_Components
  • QCJAVA
  • Components
  • qcShip

Ship.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc1E6.tmp" /nologo /d "D:\ComPlusSamples\Source\QCSample1" "D:\ComPlusSamples\Source\QCSample1\QCShip.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package qcship;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017 import com.ms.wfc.data.*;
00018 import java.util.Vector;
00019
00020
00021 /** @com.register(clsid=CB34A1A5-28C2-11D2-B5B6-00C04FC340EE, typelib=6DD1E6CF-28C1-11D2-B5B6-00C04FC340EE, version="1.0", description="Ship Class")*/
00022 public class Ship implements IUnknown,com.ms.com.NoAutoScripting,qcship.IShipDefault
00023 {
00024   private int   customerID    = 0;
00025   private int   orderID     = 0;
00026   private Vector  itemVect    = null;
00027   private Vector  quantityVect  = null;
00028   private Vector  shipStatusVect  = null;
00029
00030   public Ship()
00031   {
00032     itemVect    = new Vector();
00033     quantityVect  = new Vector();
00034     shipStatusVect  = new Vector();
00035   }
00036
00037   /**
00038      * property put for CustomerId property
00039      *
00040      * @param       customerID        A customer identifier
00041      * @return      ---
00042      *
00043      **/
00044   public void setCustomerId(int customerID)
00045   {
00046     this.customerID = customerID;
00047   }
00048
00049   /**
00050      * property put for OrderId property
00051      *
00052      * @param       orderID        An order identifier
00053      * @return      ---
00054      *
00055      **/
00056   public void setOrderId(int orderID)
00057   {
00058     this.orderID  = orderID;
00059   }
00060
00061   /**
00062      * Adds a single item to an order
00063      *
00064      * @param       itemID        An item identifier
00065      * @param   quantity    Quantity of the item ordered
00066      * @return      ---
00067      *
00068      **/
00069   public void LineItem(int itemID, int quantity)
00070   {
00071     if((itemVect != null) && (quantityVect != null) &&(shipStatusVect != null))
00072     {
00073       itemVect.addElement(new Integer(itemID));
00074       quantityVect.addElement(new Integer(quantity));
00075       shipStatusVect.addElement(randomShipStatus());
00076     }
00077   }
00078
00079   /**
00080      * Adds order to Shipping table and notify requestor of shipping status.
00081      *
00082      * @param       lFlags        option flags
00083      * @return      ---
00084      *
00085      **/
00086   public void Process(int lFlags)
00087   {
00088     boolean dataInsertFlag    = false;
00089     boolean notifyInvokeFlag  = false;
00090
00091     dataInsertFlag  = WriteShipDB();
00092     if(dataInsertFlag)
00093     {
00094       notifyInvokeFlag  = InvokeNotify();
00095     }
00096     com.ms.mtx.IObjectContext ctxObj = com.ms.mtx.Context.getObjectContext();
00097     if(ctxObj != null)
00098      {
00099       if(notifyInvokeFlag)
00100       {
00101         ctxObj.SetComplete();
00102       }
00103       else
00104       {
00105         ctxObj.SetAbort();
00106       }
00107      }
00108   }
00109
00110   /**
00111      * Writes the order into the Shipping table.
00112      *
00113      * @param       ---
00114      * @return      boolean     True if successful else return false
00115      * @see     com.ms.wfc.data.Connection
00116      **/
00117   private boolean WriteShipDB()
00118   {
00119     int     result    = 0;
00120     Connection  con     = null;
00121     String    conDetail = null;
00122     boolean   returnValue = false;
00123
00124     conDetail = "Data Source=" + helper.DatabaseSettings.DSN + ";" + "User Id=" + helper.DatabaseSettings.User + ";" + "Password=" + helper.DatabaseSettings.Pass + ";";
00125     con     = new Connection();
00126     con.open(conDetail);
00127     for(int index = 0;index < itemVect.size(); index++)
00128     {
00129       String value =  String.valueOf(orderID) + "," + String.valueOf(customerID) + "," + String.valueOf(index) + "," + ((Integer)itemVect.elementAt(index)).toString() + "," +((Integer)quantityVect.elementAt(index)).toString() + ", '" + (String)(shipStatusVect.elementAt(index)) + "'" ;
00130       System.out.println(value);
00131       result  = con.executeUpdate("Insert into QCSampleShip (order_id,cust_id,line_no,item_id,quantity,ship_status) values(" + value + ")");
00132       if(result > 0)
00133       {
00134         returnValue = true;
00135       }
00136       else
00137       {
00138         returnValue = false;
00139         break;
00140       }
00141     }
00142     con.close();
00143     return returnValue;
00144   }
00145
00146   /**
00147      * Creates a Notify object to notify requestor of shipping status.
00148      *
00149      * @param       ---
00150      * @return      boolean     True if successful else return false
00151      * @see     com.ms.win32.ole32.CoGetObject
00152      **/
00153   private boolean InvokeNotify()
00154   {
00155     boolean       returnValue   = false;
00156     qcnotify.INotify  notify_obj    = null;
00157     try
00158     {
00159       // Using Queue moniker to create queued component
00160       notify_obj =  (qcnotify.INotify)com.ms.win32.Ole32.CoGetObject("queue:/new:QCNotifyLib.Notify",null,qcnotify.INotify.iid);
00161       if(notify_obj != null)
00162       {
00163         notify_obj.setCustomerId(customerID);
00164         notify_obj.setOrderId(orderID);
00165         for(int index = 0;index < itemVect.size(); index++)
00166         {
00167           notify_obj.LineItem(((Integer)(itemVect.elementAt(index))).intValue(),((Integer)(quantityVect.elementAt(index))).intValue(),shipStatusValue((String)(shipStatusVect.elementAt(index))));
00168         }
00169         notify_obj.Process(0);
00170         returnValue = true;
00171       }
00172     }
00173     catch(com.ms.com.ComFailException exp)
00174     {
00175       System.out.println("Exception calling Notify :  " + exp);
00176     }
00177
00178     return returnValue;
00179   }
00180
00181   /**
00182      * Determines shipping status for a particular line item.
00183      *
00184      * @param       ---
00185      * @return      String      Shipping status string
00186      **/
00187   private String randomShipStatus()
00188   {
00189     double randomStatusValue  = 0.0;
00190     String shipStatus     = null;
00191
00192     randomStatusValue = java.lang.Math.random() * 100;
00193     if(randomStatusValue < 80)
00194     {
00195       shipStatus  = "ssShipped";
00196     }
00197     else if(randomStatusValue < 93)
00198     {
00199       shipStatus  = "ssBackOrdered";
00200     }
00201     else if(randomStatusValue < 97)
00202     {
00203       shipStatus  = "ssNotStocked";
00204     }
00205     else
00206     {
00207       shipStatus  = "ssUnrecognizedItem";
00208     }
00209     return shipStatus;
00210   }
00211
00212   /**
00213      * Determines shipping status value based on shipping status string
00214      *
00215      * @param       ---
00216      * @return      int     Shipping status value
00217      **/
00218   private int shipStatusValue(String shipStatus)
00219   {
00220     int returnValue   = 0;
00221     if(shipStatus.equals("ssShipped"))
00222     {
00223       returnValue = qcnotify._ShipStatus.ssShipped;
00224     }
00225     else if(shipStatus.equals("ssBackOrdered"))
00226     {
00227       returnValue = qcnotify._ShipStatus.ssBackOrdered;
00228     }
00229     else if(shipStatus.equals("ssNotStocked"))
00230     {
00231       returnValue = qcnotify._ShipStatus.ssNotStocked;
00232     }
00233     else if(shipStatus.equals("ssUnrecognizedItem"))
00234     {
00235       returnValue = qcnotify._ShipStatus.ssUnrecognizedItem;
00236     }
00237     return returnValue;
00238
00239   }
00240
00241
00242 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/proxy_except.Cpp Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

proxy_except.Cpp

Go to the documentation of this file.
00001 // Proxy.cpp : Implementation of CProxy
00002 #include "stdafx.h"
00003 #include "Data.h"
00004 #include "Entity.h"
00005 #include "Dynamic.h"
00006 #include "Resultset.h"
00007 #include "odbcdata.h"
00008 #include "Proxy.h"
00009 #include <wchar.h>
00010
00011 /////////////////////////////////////////////////////////////////////////////
00012 // CProxy methods that require exceptions turned on
00013
00014 STDMETHODIMP CProxy::RSQuery(BSTR QueryText, VARIANT *Result, _Recordset **rs)
00015 {
00016   HRESULT hr = S_OK;
00017
00018   if (m_spObjectContext.p != NULL)
00019     m_spObjectContext->SetComplete();
00020
00021   try
00022   {
00023     _CommandPtr spCommand(__uuidof(Command));
00024     _RecordsetPtr spRecordset(__uuidof(Recordset));
00025
00026     if ((_Connection*)m_spConnection == NULL)
00027     {
00028       m_spConnection.CreateInstance(__uuidof(Connection));
00029       m_spConnection->Open(_bstr_t(m_wszConnection), "", "", -1);
00030     }
00031
00032     spCommand->PutActiveConnection((_Connection*)m_spConnection);
00033     spCommand->CommandText = QueryText;
00034     spCommand->CommandType = adCmdText;
00035     spCommand->Parameters->Append(spCommand->CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, sizeof(int)));
00036
00037     spRecordset->CursorLocation = adUseClient;
00038     spRecordset->Open((_Command*)spCommand, &vtMissing, adOpenForwardOnly, adLockReadOnly, -1);
00039     spCommand->PutRefActiveConnection(NULL);
00040
00041     try
00042     {
00043       if (spRecordset->Fields->Count > 0)
00044       {
00045         spRecordset->PutRefActiveConnection(NULL);
00046         *rs = spRecordset.Detach();
00047       }
00048     }
00049     catch (_com_error e)
00050     {
00051     }
00052
00053     if (spCommand->Parameters->Count > 0)
00054       *Result = spCommand->Parameters->Item["RETURN_VALUE"]->Value;
00055     else
00056       *Result = _variant_t(1L);
00057   }
00058   catch (_com_error e)
00059   {
00060     *Result = _variant_t(-1L);
00061     if (m_spObjectContext.p != NULL)
00062       m_spObjectContext->SetAbort();
00063
00064     hr = AtlReportError(CLSID_Proxy, (LPCSTR)e.Description(), IID_IDataProxy, e.Error());
00065   }
00066   return hr;
00067 }
00068
00069 STDMETHODIMP CProxy::RSQueryRW(BSTR QueryText, VARIANT *Result, _Recordset **rs)
00070 {
00071   HRESULT hr = S_OK;
00072
00073   if (m_spObjectContext.p != NULL)
00074     m_spObjectContext->SetComplete();
00075
00076   try
00077   {
00078     _CommandPtr spCommand(__uuidof(Command));
00079     _RecordsetPtr spRecordset(__uuidof(Recordset));
00080
00081     if ((_Connection*)m_spConnection == NULL)
00082     {
00083       m_spConnection.CreateInstance(__uuidof(Connection));
00084       m_spConnection->Open(_bstr_t(m_wszConnection), "", "", -1);
00085     }
00086
00087     spCommand->PutActiveConnection((_Connection*)m_spConnection);
00088     spCommand->CommandText = QueryText;
00089     spCommand->CommandType = adCmdText;
00090     spCommand->Parameters->Append(spCommand->CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, sizeof(int)));
00091
00092     spRecordset->CursorLocation = adUseClient;
00093     spRecordset->Open((_Command*)spCommand, &vtMissing,  adOpenStatic,  adLockBatchOptimistic, -1);
00094
00095     spCommand->PutRefActiveConnection(NULL);
00096     try
00097     {
00098       if (spRecordset->Fields->Count > 0)
00099       {
00100         spRecordset->PutRefActiveConnection(NULL);
00101         *rs = spRecordset.Detach();
00102       }
00103     }
00104     catch (_com_error e)
00105     {
00106     }
00107
00108     if (spCommand->Parameters->Count > 0)
00109       *Result = spCommand->Parameters->Item["RETURN_VALUE"]->Value;
00110     else
00111       *Result = _variant_t(1L);
00112   }
00113   catch (_com_error e)
00114   {
00115     *Result = _variant_t(-1L);
00116
00117     if (m_spObjectContext.p != NULL)
00118       m_spObjectContext->SetAbort();
00119
00120     hr = AtlReportError(CLSID_Proxy, (LPCSTR)e.Description(), IID_IDataProxy, e.Error());
00121   }
00122   return hr;
00123 }
00124
00125 STDMETHODIMP CProxy::RSUpdate(_Recordset *rs)
00126 {
00127   HRESULT hr = S_OK;
00128
00129   if (m_spObjectContext.p != NULL)
00130     m_spObjectContext->SetComplete();
00131
00132   try
00133   {
00134     if ((_Connection*)m_spConnection == NULL)
00135     {
00136       m_spConnection.CreateInstance(__uuidof(Connection));
00137       m_spConnection->Open(_bstr_t(m_wszConnection), "", "", -1);
00138     }
00139
00140     _RecordsetPtr spRecordset(__uuidof(Recordset));
00141     spRecordset->PutActiveConnection((_Connection*)m_spConnection);
00142     spRecordset->PutRefSource(rs);
00143     spRecordset->put_CursorLocation(adUseClient);
00144     spRecordset->Open(&vtMissing, &vtMissing,adOpenStatic,adLockBatchOptimistic,-1);
00145     spRecordset->UpdateBatch(adAffectAll);
00146     spRecordset->putref_ActiveConnection(NULL);
00147   }
00148   catch(_com_error e)
00149   {
00150     if (m_spObjectContext.p != NULL)
00151       m_spObjectContext->SetAbort();
00152
00153     hr = AtlReportError(CLSID_Proxy, (LPCSTR)e.Description(), IID_IDataProxy, e.Error());
00154   }
00155   return hr;
00156 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/PersistATL/newsevent.h Source File

  • Com
  • Services
  • Events
  • EventNews
  • PersistATL

newsevent.h

Go to the documentation of this file.
00001 // NewsEvent.h : Declaration of the CNewsEvent
00002
00003 #ifndef __NEWSEVENT_H_
00004 #define __NEWSEVENT_H_
00005
00006 #include "resource.h"       // main symbols
00007
00008 /////////////////////////////////////////////////////////////////////////////
00009 // CNewsEvent
00010 class ATL_NO_VTABLE CNewsEvent :
00011   public CComObjectRootEx<CComMultiThreadModel>,
00012   public CComCoClass<CNewsEvent, &__uuidof(NewsEvent)>,
00013   public ISupportErrorInfo,
00014   public IDispatchImpl<INewsEvent, &__uuidof(INewsEvent), &LIBID_PERSISTATLLib>
00015 {
00016 public:
00017   CNewsEvent()
00018   {
00019   }
00020
00021 DECLARE_REGISTRY_RESOURCEID(IDR_NEWSEVENT)
00022
00023 DECLARE_PROTECT_FINAL_CONSTRUCT()
00024
00025 BEGIN_COM_MAP(CNewsEvent)
00026   COM_INTERFACE_ENTRY(INewsEvent)
00027   COM_INTERFACE_ENTRY(IDispatch)
00028   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00029 END_COM_MAP()
00030
00031 // ISupportsErrorInfo
00032   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00033
00034 // INewsEvent
00035 public:
00036   STDMETHOD(LongQuote)( /*[in]*/ BSTR Symbol, /*[in]*/ double BidPrice, /*[in]*/ double AskPrice,/*[in]*/ BSTR LastTradeTime, /*[in]*/ double LastTradePrice, /*[in]*/ double NetChange, /*[in]*/ double DailyHigh, /*[in]*/ double DailyLow,/*[in]*/ long AskSize, /*[in]*/ long BidSize, /*[in]*/ double OpenPrice, /*[in]*/ double ClosePrice, /*[in]*/ BSTR CloseDate );
00037   STDMETHOD(ShortQuote)( /*[in]*/ BSTR Symbol, /*[in]*/ double BidPrice, /*[in]*/ double AskPrice, /*[in]*/ DATE LastTradeTime, /*[in]*/ double LastTradePrice, /*[in]*/ double NetChange, /*[in]*/ double DailyHigh, /*[in]*/ double DailyLow );
00038   STDMETHOD(NewsFlash)(/*[in]*/ DATE dtTimeStamp, /*[in]*/ BSTR Symbol, /*[in]*/ BSTR Headline,/*[in]*/ BSTR URL );
00039 };
00040
00041 #endif //__NEWSEVENT_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCShip/Resource.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCShip

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by QCShip.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_SHIP                        101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/SINK.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

SINK.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SINK.H
00003
00004   Summary:   Include file for the COPaperSink COM object class.
00005
00006              COPaperSink offers a main IUnknown interface and the custom
00007              IPaperSink interface (outgoing connection events from COPaper
00008              drawing paper objects). This multiple interface COM Object
00009              Class is achieved via the technique of nested classes.  The
00010              implementation of the IPaperSink interface is nested inside
00011              of the COPaperSink Class.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial STOCLIEN.HTM
00015              file. For more specific technical details on the internal
00016              workings see the comments dispersed throughout the module's
00017              source code.
00018
00019   Functions: .
00020
00021   Classes:   COPaperSink.
00022
00023   Origin:    6-10-96: atrent - Editor-inheritance from BALL.H in the
00024              CONSERVE Tutorial Code Sample.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(SINK_H)
00042 #define SINK_H
00043
00044 #ifdef __cplusplus
00045
00046
00047 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00048   ObjectClass: COPaperSink
00049
00050   Summary:     The main Sink COM object class for COPaperSink COM objects.
00051                COM objects of this class offer the IPaperSink sink
00052                interface supporting various drawing paper events. The
00053                mulitple interfaces on this COM object are constructed via
00054                the nested interface classes technique.
00055
00056   Interfaces:  IUnknown
00057                  Standard interface providing COM object features.
00058                IPaperSink
00059                  Sink interface for Paper events.
00060
00061   Aggregation: Yes, COPaperSink COM Objects are aggregatable by passing
00062                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00063 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00064 class COPaperSink : public IUnknown
00065 {
00066   public:
00067     // Main Object Constructor & Destructor.
00068     COPaperSink(IUnknown* pUnkOuter, CGuiPaper* pGuiPaper);
00069     ~COPaperSink(void);
00070
00071     // IUnknown methods. Main object, non-delegating.
00072     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00073     STDMETHODIMP_(ULONG) AddRef(void);
00074     STDMETHODIMP_(ULONG) Release(void);
00075
00076   private:
00077     // We declare nested class interface implementations here.
00078
00079     class CImpIPaperSink : public IPaperSink
00080     {
00081       public:
00082         // Interface Implementation Constructor & Destructor.
00083         CImpIPaperSink(COPaperSink* pBackObj, IUnknown* pUnkOuter);
00084         ~CImpIPaperSink(void);
00085
00086         // IUnknown methods.
00087         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00088         STDMETHODIMP_(ULONG) AddRef(void);
00089         STDMETHODIMP_(ULONG) Release(void);
00090
00091         // IPaperSink methods.
00092         STDMETHODIMP         Locked(void);
00093         STDMETHODIMP         Unlocked(void);
00094         STDMETHODIMP         Loaded(void);
00095         STDMETHODIMP         Saved(void);
00096         STDMETHODIMP         InkStart(
00097                                SHORT nX,
00098                                SHORT nY,
00099                                SHORT nWidth,
00100                                COLORREF crInkColor);
00101         STDMETHODIMP         InkDraw(
00102                                SHORT nX,
00103                                SHORT nY);
00104         STDMETHODIMP         InkStop(
00105                                SHORT nX,
00106                                SHORT nY);
00107         STDMETHODIMP         Erased(void);
00108         STDMETHODIMP         Resized(SHORT nWidth, SHORT nHeight);
00109
00110       private:
00111         // Data private to this interface implementation of IPaper.
00112         COPaperSink* m_pBackObj;     // Parent Object back pointer.
00113         IUnknown*    m_pUnkOuter;    // Outer unknown for Delegation.
00114     };
00115
00116     // Make the otherwise private and nested IPaperSink interface
00117     // implementation a friend to COM object instantiations of this
00118     // COPaperSink COM object class.
00119     friend CImpIPaperSink;
00120
00121     // Private data of COPaperSink COM objects.
00122
00123     // Nested IPaperSink implementation instantiation.  This IPaperSink
00124     // interface is instantiated inside this COPaperSink object as a
00125     // native interface.
00126     CImpIPaperSink   m_ImpIPaperSink;
00127
00128     // Main Object reference count.
00129     ULONG            m_cRefs;
00130
00131     // Outer unknown (aggregation delegation). Used when this COM object
00132     // is being aggregated.
00133     IUnknown*        m_pUnkOuter;
00134
00135     // Pointer to the main object that can service the Sink events.
00136     CGuiPaper*       m_pGuiPaper;
00137 };
00138
00139 typedef COPaperSink* PCOPaperSink;
00140
00141 #endif // __cplusplus
00142
00143
00144 #endif // SINK_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/NetMon/experts/blrplate/blrplate.h Source File

  • NetDS
  • NetMon
  • experts
  • blrplate

blrplate.h

Go to the documentation of this file.
00001 //============================================================================
00002 //  MODULE: BLRPLATE.h
00003 //
00004 //  Description:
00005 //
00006 //  BLRPLATE expert module
00007 //
00008 //  Modification History:
00009 //
00010 //  Your Name Here      01/01/70    Created
00011 //============================================================================
00012
00013 #ifndef _BLRPLATE_H_
00014 #define _BLRPLATE_H_
00015
00016 #include <windows.h>
00017 #include <netmon.h>
00018
00019 #pragma warning(disable:4200)
00020
00021 //////////////////////////////////////////////////////////////////////////////
00022 // Global Variables
00023 extern HINSTANCE g_hInstance;
00024 extern char g_StatusString[];
00025
00026 //////////////////////////////////////////////////////////////////////////////
00027 // Data Structures
00028
00029 // BLRPLATECONFIG
00030 typedef struct _BLRPLATECONFIG
00031 {
00032     DWORD nTotalLength;
00033
00034     // TODO: put interesting Info here.
00035
00036 } BLRPLATECONFIG;
00037 typedef BLRPLATECONFIG *PBLRPLATECONFIG;
00038
00039
00040 //////////////////////////////////////////////////////////////////////////////
00041 // Function Prototypes
00042
00043 // In BLRPLATE.cpp
00044 BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved);
00045 BOOL WINAPI Register( PEXPERTENUMINFO lpExpertInfo);
00046 BOOL WINAPI Configure( HEXPERTKEY hExpertKey,
00047                        PEXPERTCONFIG* ppConfig,
00048                        PEXPERTSTARTUPINFO pStartupInfo,
00049                        DWORD StartupFlags,
00050                        HWND hWnd );
00051 BOOL WINAPI Run( HEXPERTKEY hExpertKey, PEXPERTCONFIG lpConfig, HWND hwnd);
00052
00053 // In Config.cpp
00054 BOOL ConfigBLRPLATEDlg_Do(HWND hwnd,
00055                           PBLRPLATECONFIG * ppBLRPLATEConfig,
00056                           HEXPERTKEY hExpertKey);
00057
00058
00059 #pragma warning(default:4200)
00060
00061 #endif // _BLRPLATE_H_
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/dataobj.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

dataobj.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _CLASS_CDATAOBJECT_
00015 #define _CLASS_CDATAOBJECT_
00016
00017 #include "Globals.h"
00018 #include "StaticNode.h"
00019 #include "LListImpl.h"       // MULTISELECT:  Need to keep a list of nodes
00020
00021
00022
00023 //---------------------------------------------------------------------------
00024 typedef struct _MultiSelectCookies
00025 {
00026   DWORD    count;
00027   LONG_PTR Cookies[1];
00028
00029 } MULTISELECT_COOKIES;
00030
00031
00032
00033 //---------------------------------------------------------------------------
00034 class CDataObject : public IDataObject
00035 {
00036   private:
00037     ULONG     m_cRef;
00038     INT_PTR   m_nCookie;
00039     ULONG     m_uContext;
00040
00041   public:
00042     CDataObject();
00043     ~CDataObject();
00044
00045   public:  // Interface IUnknown
00046     STDMETHODIMP QueryInterface( REFIID riid, LPVOID* ppv );
00047     STDMETHODIMP_(ULONG) AddRef();
00048     STDMETHODIMP_(ULONG) Release();
00049
00050   public:  // IDataObject methods
00051     STDMETHODIMP GetDataHere( FORMATETC* pFormatEtc, STGMEDIUM* pStgMedium );
00052
00053     STDMETHODIMP GetData( FORMATETC* pFormatEtc, STGMEDIUM* pStgMedium );
00054
00055     // The rest are not implemented
00056     //
00057     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00058     { return E_NOTIMPL; };
00059
00060     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00061     { return E_NOTIMPL; };
00062
00063     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00064     { return E_NOTIMPL; };
00065
00066     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00067     { return E_NOTIMPL; };
00068
00069     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00070     { return E_NOTIMPL; };
00071
00072     STDMETHODIMP DUnadvise (DWORD dwConnection)
00073     { return E_NOTIMPL; };
00074
00075     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00076     { return E_NOTIMPL; };
00077
00078   ///////////////////////////////////////////////////////////////////////////
00079   // Custom Methods
00080   public:
00081     VOID   SetPrivateData( INT_PTR nCookie, ULONG uContext );
00082
00083     // For future use, not used in this sample
00084     ULONG    GetContext() { return m_uContext; }
00085     INT_PTR  GetCookie()  { return m_nCookie;  }
00086
00087   ///////////////////////////////////////////////////////////////////////////
00088   // Handlers for required clipboard formats
00089   private:
00090     HRESULT  RetrieveDisplayString( IStream* ipStream );
00091     HRESULT  RetrieveSnapInClassID( IStream* ipStream );
00092     HRESULT  RetrieveNodeTypeGuid( IStream* ipStream );
00093     HRESULT  RetrieveGuidString( IStream* ipStream );
00094     HRESULT  RetrieveBaseNodePtr( IStream* ipStream );
00095     HRESULT  RetrieveDataObjPtr( IStream* ipStream );
00096
00097   ///////////////////////////////////////////////////////////////////////////
00098   // MULTISELECT:  New methods to support multiselect
00099   public:
00100     HRESULT  AddMultiSelectCookie( LONG_PTR nCookie );
00101     HRESULT  AddMultiSelectGuid( GUID* pGuid );
00102
00103     HRESULT  RetrieveMultiSelectCookies( STGMEDIUM* pStgMedium );
00104     HRESULT  RetrieveMultiSelectTypes( STGMEDIUM* pStgMedium );
00105
00106   private:
00107     CLListImpl<LONG_PTR, LONG_PTR >  m_CookieList;
00108     CLListImpl<GUID*,GUID*>          m_GuidList;
00109
00110 };
00111
00112 #endif //_CLASS_CDATAOBJECT_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPlex Member List

This is the complete list of members for CPlex, including all inherited members.
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
Create(CPlex *&head, UINT nMax, UINT cbElement) | CPlex | [static]
data() | CPlex | [inline]
data() | CPlex | [inline]
data() | CPlex | [inline]
data() | CPlex | [inline]
data() | CPlex | [inline]
data() | CPlex | [inline]
data() | CPlex | [inline]
dwReserved | CPlex |
FreeDataChain() | CPlex |
FreeDataChain() | CPlex |
FreeDataChain() | CPlex |
FreeDataChain() | CPlex |
FreeDataChain() | CPlex |
FreeDataChain() | CPlex |
FreeDataChain() | CPlex |
pNext | CPlex |
Generated on Wed Nov 13 2024 16:57:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/RecordTypeEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

RecordTypeEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: RecordTypeEnum
00019
00020 public class RecordTypeEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adSimpleRecord = 0;
00023   public static final short adCollectionRecord = 1;
00024   public static final short adStructDoc = 2;
00025 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/GetImage/GetImage.cpp Source File

  • Multimedia
  • wia
  • GetImage

GetImage.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 --*/
00006
00007 #include "stdafx.h"
00008 #include "resource.h"
00009
00010 #include "BitmapWnd.h"
00011 #include "MainWnd.h"
00012
00013 //////////////////////////////////////////////////////////////////////////
00014 //
00015 // Global variable that holds the module instance
00016 //
00017
00018 HINSTANCE g_hInstance = 0;
00019
00020 void RunGetImage()
00021 {
00022     CComPtr<CMainWindow> pMainWindow = new CMainWindow;
00023
00024     if (pMainWindow != NULL)
00025     {
00026         TCHAR szTitle[DEFAULT_STRING_SIZE] = _T("");
00027
00028       LoadString(g_hInstance, IDS_MAIN_WINDOW_TITLE, szTitle, COUNTOF(szTitle));
00029
00030         HWND hWnd = CreateWindowEx(
00031             0,
00032             _T("MainWindow"),
00033             szTitle,
00034             WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE,
00035             CW_USEDEFAULT,
00036             CW_USEDEFAULT,
00037             CW_USEDEFAULT,
00038             CW_USEDEFAULT,
00039             NULL,
00040             NULL,
00041             g_hInstance,
00042             pMainWindow
00043         );
00044
00045         if (hWnd != NULL)
00046         {
00047             pMainWindow->DoModal();
00048         }
00049     }
00050 }
00051
00052
00053 //////////////////////////////////////////////////////////////////////////
00054 //
00055 // Main entry point of the application
00056 //
00057
00058 int
00059 APIENTRY
00060 WinMain(
00061     HINSTANCE hInstance,
00062     HINSTANCE hPrevInstance,
00063     PSTR      pCmdLine,
00064     int       nCmdShow
00065 )
00066 {
00067     // Initialize the global module instance value
00068
00069     g_hInstance = hInstance;
00070
00071     // Initialize the GDI+ library
00072
00073     CGdiplusInit GdiplusInit;
00074
00075     // Register window classes
00076
00077     INITCOMMONCONTROLSEX iccex;
00078
00079     iccex.dwSize = sizeof(iccex);
00080     iccex.dwICC  = ICC_BAR_CLASSES;
00081
00082     InitCommonControlsEx(&iccex);
00083
00084     CBitmapWnd::Register();
00085
00086     CMainWindow::Register();
00087
00088     // Initialize the COM library
00089
00090     HRESULT hr = CoInitialize(NULL);
00091
00092     if (SUCCEEDED(hr))
00093     {
00094         // Create the main window and enter the message loop
00095
00096         RunGetImage();
00097
00098         // Close the COM library
00099
00100         CoUninitialize();
00101     }
00102
00103     return 0;
00104 }
00105
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook ServerEx/ExtObjData.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook ServerEx

ExtObjData.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ExtObjData.cpp
00007 //
00008 //  Description:
00009 //      Implementation of the context menu functions and functions for
00010 //      returning the property sheet and wizard pages.
00011 //
00012 //  Author:
00013 //      <name> (<e-mail name>) Mmmm DD, 2003
00014 //
00015 //  Revision History:
00016 //
00017 //  Notes:
00018 //
00019 /////////////////////////////////////////////////////////////////////////////
00020
00021 #include "stdafx.h"
00022 #include "ClipBook ServerEx.h"
00023 #include "ExtObjData.h"
00024 #include "resprop.h"
00025
00026 #include "resource.h"
00027
00028 #ifdef _DEBUG
00029 #define new DEBUG_NEW
00030 #undef THIS_FILE
00031 static char THIS_FILE[] = __FILE__;
00032 #endif
00033
00034 /////////////////////////////////////////////////////////////////////////////
00035 // Constant Definitions
00036 /////////////////////////////////////////////////////////////////////////////
00037
00038 #define CLUSTER_MENU_BASE_ID        0
00039 #define CLUSTER_MENU_ID_1           (CLUSTER_MENU_BASE_ID + 1)
00040
00041 #define NODE_MENU_BASE_ID           10
00042 #define NODE_MENU_ID_1              (NODE_MENU_BASE_ID + 1)
00043
00044 #define GROUP_MENU_BASE_ID          20
00045 #define GROUP_MENU_ID_1             (GROUP_MENU_BASE_ID + 1)
00046
00047 #define RESOURCE_MENU_BASE_ID       30
00048 #define RESOURCE_MENU_ID_1          (RESOURCE_MENU_BASE_ID + 1)
00049
00050 #define ALL_RESOURCES_MENU_BASE_ID  40
00051 #define ALL_RESOURCES_MENU_ID_1     (ALL_RESOURCES_MENU_BASE_ID + 1)
00052
00053 #define RESTYPE_MENU_BASE_ID        50
00054 #define RESTYPE_MENU_ID_1           (RESTYPE_MENU_BASE_ID + 1)
00055
00056 #define ALL_RESTYPES_MENU_BASE_ID   60
00057 #define ALL_RESTYPES_MENU_ID_1      (ALL_RESTYPES_MENU_BASE_ID + 1)
00058
00059 #define NETWORK_MENU_BASE_ID        70
00060 #define NETWORK_MENU_ID_1           (NETWORK_MENU_BASE_ID + 1)
00061
00062 #define NETINTERFACE_MENU_BASE_ID   80
00063 #define NETINTERFACE_MENU_ID_1      (NETINTERFACE_MENU_BASE_ID + 1)
00064
00065 /////////////////////////////////////////////////////////////////////////////
00066 // CObjData implementation
00067 /////////////////////////////////////////////////////////////////////////////
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 //++
00071 //
00072 //  CObjData::S_HrCreateObject
00073 //
00074 //  Description:
00075 //      Create a CObjData-derived object based on the requesting object type.
00076 //
00077 //  Arguments:
00078 //
00079 //  Return Value:
00080 //
00081 //--
00082 /////////////////////////////////////////////////////////////////////////////
00083 HRESULT
00084 CObjData::S_HrCreateObject(
00085       IUnknown *    piDataIn
00086     , CObjData **   ppodOut
00087     )
00088 {
00089     HRESULT                 hr = S_OK;
00090     CObjData *              podData = NULL;
00091     CLUADMEX_OBJECT_TYPE    cot;
00092     IGetClusterObjectInfo * piObjInfo = NULL;
00093
00094     ASSERT( piDataIn != NULL );
00095     ASSERT( ppodOut != NULL );
00096
00097     hr = piDataIn->QueryInterface( IID_IGetClusterObjectInfo, reinterpret_cast< LPVOID * >( &piObjInfo ) );
00098     if ( FAILED( hr ) )
00099     {
00100         goto Cleanup;
00101     } // if: error querying for interface
00102
00103     cot = piObjInfo->GetObjectType( 0 );
00104     piObjInfo->Release();
00105     piObjInfo = NULL;
00106
00107     switch ( cot )
00108     {
00109         case CLUADMEX_OT_RESOURCE:
00110             podData = new CResData();
00111             break;
00112
00113         case CLUADMEX_OT_RESOURCETYPE:
00114             podData = new CResTypeData();
00115             break;
00116
00117         default:
00118             hr = E_NOTIMPL;
00119             goto Cleanup;
00120             break;
00121     } // switch: object type
00122
00123     if ( podData == NULL )
00124     {
00125         hr = E_OUTOFMEMORY;
00126         goto Cleanup;
00127     } // if: error allocating the object
00128
00129     hr = podData->HrInitialize( piDataIn );
00130     if ( FAILED( hr ) )
00131     {
00132         goto Cleanup;
00133     } // if: error initializing the object
00134
00135     *ppodOut = podData;
00136     podData = NULL;         // We gave away ownership.
00137
00138 Cleanup:
00139
00140     if ( piObjInfo != NULL )
00141     {
00142         piObjInfo->Release();
00143     } // if:
00144
00145     delete podData;
00146
00147     return hr;
00148
00149 } //*** CObjData::S_HrCreateObject
00150
00151 /////////////////////////////////////////////////////////////////////////////
00152 //++
00153 //
00154 //  CObjData::AddContextMenuItem
00155 //
00156 //  Description:
00157 //      Add a context menu item.
00158 //
00159 //  Arguments:
00160 //      piCallbackIn
00161 //          Pointer to an IWCContextMenuCallback interface for adding menu
00162 //          items to the context menu.
00163 //
00164 //  Return Value:
00165 //      S_OK
00166 //          Menu items added successfully.
00167 //
00168 //      hr
00169 //          Any errors returned by IWCContextMenuCallback
00170 //          ::AddExtensionMenuItem().
00171 //
00172 //--
00173 /////////////////////////////////////////////////////////////////////////////
00174 HRESULT
00175 CObjData::AddContextMenuItem(
00176       IWCContextMenuCallback *  piCallbackIn
00177     , UINT                      nMenuItem
00178     , UINT                      nMenuItemDesc
00179     , UINT                      nBaseID
00180     , ULONG                     uFlags
00181     )
00182 {
00183     HRESULT hr = S_OK;
00184     CString strMenuItem;
00185     CString strStatusBarText;
00186     LPWSTR  pwszMenuItem = NULL;
00187     LPWSTR  pwszStatusBarText = NULL;
00188
00189     ASSERT( piCallbackIn != NULL );
00190
00191     //
00192     //  Get strings.
00193     //
00194
00195     strMenuItem.LoadString( nMenuItem );
00196     strStatusBarText.LoadString( nMenuItemDesc );
00197     pwszMenuItem = strMenuItem.GetBuffer( 1 );
00198     pwszStatusBarText = strStatusBarText.GetBuffer( 1 );
00199
00200     //
00201     //  Add item to the context menu.
00202     //
00203
00204     hr = piCallbackIn->AddExtensionMenuItem(
00205                               pwszMenuItem            // lpszName
00206                             , pwszStatusBarText       // lpszStatusBarText
00207                             , nBaseID                 // lCommandID
00208                             , 0                       // lSubCommandID - reserved, must be 0
00209                             , uFlags                  // uFlags
00210                             );
00211
00212     //
00213     //  Release strings.
00214     //
00215
00216     strMenuItem.ReleaseBuffer();
00217     strStatusBarText.ReleaseBuffer();
00218
00219     return hr;
00220
00221 } //*** CObjData::AddContextMenuItem
00222
00223 /////////////////////////////////////////////////////////////////////////////
00224 //++
00225 //
00226 //  CObjData::HrInitialize
00227 //
00228 //  Description:
00229 //      Initializes the object.
00230 //
00231 //  Description:
00232 //
00233 //  Arguments:
00234 //
00235 //  Return Value:
00236 //
00237 //--
00238 /////////////////////////////////////////////////////////////////////////////
00239 HRESULT
00240 CObjData::HrInitialize(
00241       IUnknown *    piDataIn
00242     )
00243 {
00244     HRESULT                 hr = S_OK;
00245     BSTR                    bstrName = NULL;
00246     LONG                    cchName = 0;
00247     IGetClusterObjectInfo * piObjInfo = NULL;
00248
00249     ASSERT( piDataIn != NULL );
00250
00251     //
00252     // Get an interface pointer to IGetClusterObjectInfo.
00253     //
00254
00255     hr = piDataIn->QueryInterface( IID_IGetClusterObjectInfo, reinterpret_cast< LPVOID * >( &piObjInfo ) );
00256     if ( FAILED( hr ) )
00257     {
00258         goto Cleanup;
00259     } // if: error querying for interface
00260
00261     //
00262     // Allocate a buffer for the object name.
00263     //
00264
00265     hr = piObjInfo->GetObjectName( 0, NULL, &cchName );
00266     if ( FAILED( hr ) )
00267     {
00268         goto Cleanup;
00269     } // if: error getting the name length
00270
00271     bstrName = SysAllocStringLen( NULL, cchName );
00272     if ( bstrName == NULL )
00273     {
00274         hr = E_OUTOFMEMORY;
00275         goto Cleanup;
00276     } // if: error allocating a string
00277
00278     //
00279     // Retrieve the object name.
00280     //
00281
00282     hr = piObjInfo->GetObjectName( 0, bstrName, &cchName );
00283     if ( FAILED( hr ) )
00284     {
00285         goto Cleanup;
00286     } // if: error getting the name
00287
00288     //
00289     // The CString assignment operator makes a copy.
00290     //
00291
00292     m_strName = bstrName;
00293
00294 Cleanup:
00295
00296     SysFreeString( bstrName );
00297
00298     if ( piObjInfo != NULL )
00299     {
00300         piObjInfo->Release();
00301     } // if:
00302
00303     return hr;
00304
00305 } //*** CObjData::HrInitialize
00306
00307 /////////////////////////////////////////////////////////////////////////////
00308 // CClusterData implementation
00309 /////////////////////////////////////////////////////////////////////////////
00310
00311 /////////////////////////////////////////////////////////////////////////////
00312 //++
00313 //
00314 //  CClusterData::HrInitialize
00315 //
00316 //  Description:
00317 //      Initializes the object.
00318 //
00319 //  Arguments:
00320 //
00321 //  Return Value:
00322 //
00323 //--
00324 /////////////////////////////////////////////////////////////////////////////
00325 HRESULT
00326 CClusterData::HrInitialize(
00327     IUnknown * piDataIn
00328     )
00329 {
00330     HRESULT                 hr = S_OK;
00331     IGetClusterDataInfo *   piClusInfo = NULL;
00332     LONG                    cchClusterName = 0;
00333     BSTR                    bstrClusterName = NULL;
00334
00335     ASSERT( piDataIn != NULL );
00336
00337     //
00338     // Initialize the base class.
00339     //
00340
00341     hr = CObjData::HrInitialize( piDataIn );
00342     if ( FAILED( hr ) )
00343     {
00344         goto Cleanup;
00345     } // if: error initializing the base class
00346
00347     //
00348     // Initialize member variables to default values.
00349     //
00350
00351     m_hCluster = NULL;
00352
00353     //
00354     // Set the object type.
00355     //
00356
00357     m_cot = CLUADMEX_OT_CLUSTER;
00358
00359     //
00360     // Get an interface pointer to IGetClusterDataInfo.
00361     //
00362
00363     hr = piDataIn->QueryInterface( IID_IGetClusterDataInfo, reinterpret_cast< LPVOID * >( &piClusInfo ) );
00364     if ( FAILED( hr ) )
00365     {
00366         goto Cleanup;
00367     } // if: error querying for interface
00368
00369     //
00370     // Get a copy of the handle.  Don't free this handle - it's just a copy.
00371     //
00372
00373     m_hCluster = piClusInfo->GetClusterHandle();
00374     ASSERT( m_hCluster != NULL );
00375     if ( m_hCluster == NULL )
00376     {
00377         hr = E_HANDLE;
00378         goto Cleanup;
00379     } // if: error querying for interface
00380
00381     //
00382     // Allocate a buffer for and retrieve the name.
00383     //
00384
00385     hr = piClusInfo->GetClusterName( NULL, &cchClusterName );
00386     if ( FAILED( hr ) )
00387     {
00388         goto Cleanup;
00389     } // if: error getting the name length
00390
00391     bstrClusterName = SysAllocStringLen( NULL, cchClusterName );
00392     if ( bstrClusterName == NULL )
00393     {
00394         hr = E_OUTOFMEMORY;
00395         goto Cleanup;
00396     } // if: error allocating a string
00397
00398     hr = piClusInfo->GetClusterName( bstrClusterName, &cchClusterName );
00399     if ( FAILED( hr ) )
00400     {
00401         goto Cleanup;
00402     } // if: error getting the name
00403
00404     //
00405     // The CString assignment operator makes a copy.
00406     //
00407
00408     m_strClusterName = bstrClusterName;
00409
00410 Cleanup:
00411
00412     if ( piClusInfo != NULL )
00413     {
00414         piClusInfo->Release();
00415     } // if:
00416
00417     SysFreeString( bstrClusterName );
00418
00419     return hr;
00420
00421 } //*** CClusterData::HrInitialize
00422
00423 /////////////////////////////////////////////////////////////////////////////
00424 //++
00425 //
00426 //  CClusterData::AddContextMenuItems
00427 //
00428 //  Description:
00429 //      Add menu items to the cluster object context menu.
00430 //
00431 //  Arguments:
00432 //      piCallbackIn
00433 //          Pointer to an IWCContextMenuCallback interface for adding menu
00434 //          items to the context menu.
00435 //
00436 //  Return Value:
00437 //      S_OK
00438 //          Menu items added successfully.
00439 //
00440 //      hr
00441 //          Any errors returned by IWCContextMenuCallback
00442 //          ::AddExtensionMenuItem().
00443 //
00444 //--
00445 /////////////////////////////////////////////////////////////////////////////
00446 HRESULT
00447 CClusterData::AddContextMenuItems(
00448       IWCContextMenuCallback * piCallbackIn
00449     )
00450 {
00451     HRESULT hr = S_OK;
00452
00453     ASSERT( piCallbackIn != NULL );
00454
00455     hr = AddContextMenuItem(
00456                   piCallbackIn
00457                 , IDS_CLUSTER_MENU_ITEM_1
00458                 , IDS_CLUSTER_MENU_ITEM_1_DESC
00459                 , CLUSTER_MENU_ID_1
00460                 , MF_ENABLED
00461                 );
00462
00463     return hr;
00464
00465 } //*** CClusterData::AddContextMenuItems
00466
00467 /////////////////////////////////////////////////////////////////////////////
00468 //++
00469 //
00470 //  CClusterData::InvokeCommand
00471 //
00472 //  Description:
00473 //      Invoke a command we added to a context menu.
00474 //
00475 //  Arguments:
00476 //      nCommandIDIn
00477 //          ID of the menu item to execute.  This is the same ID passed to the
00478 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
00479 //
00480 //  Return Value:
00481 //      HRESULT
00482 //
00483 //--
00484 /////////////////////////////////////////////////////////////////////////////
00485 HRESULT
00486 CClusterData::InvokeCommand(
00487     ULONG nCommandIDIn
00488     )
00489 {
00490     HRESULT hr = S_OK;
00491
00492     switch ( nCommandIDIn )
00493     {
00494         case CLUSTER_MENU_ID_1:
00495
00496             //
00497             //  TODO:  Implement your menu item here.
00498             //
00499
00500             hr = S_OK;
00501             break;
00502
00503         default:
00504             hr = E_NOTIMPL;
00505             break;
00506     } // switch: nCommandIDIn
00507
00508     return hr;
00509
00510 } //*** CClusterData::InvokeCommand
00511
00512 /////////////////////////////////////////////////////////////////////////////
00513 // CNodeData implementation
00514 /////////////////////////////////////////////////////////////////////////////
00515
00516 /////////////////////////////////////////////////////////////////////////////
00517 //++
00518 //
00519 //  CNodeData::HrInitialize
00520 //
00521 //  Description:
00522 //      Initializes the object.
00523 //
00524 //  Arguments:
00525 //
00526 //  Return Value:
00527 //
00528 //--
00529 /////////////////////////////////////////////////////////////////////////////
00530 HRESULT
00531 CNodeData::HrInitialize(
00532     IUnknown * piDataIn
00533     )
00534 {
00535     HRESULT                 hr = S_OK;
00536     IGetClusterNodeInfo *   piNodeInfo = NULL;
00537
00538     ASSERT( piDataIn != NULL );
00539
00540     //
00541     // Initialize the base class.
00542     //
00543
00544     hr = CObjData::HrInitialize( piDataIn );
00545     if ( FAILED( hr ) )
00546     {
00547         goto Cleanup;
00548     } // if: error initializing the base class
00549
00550     //
00551     // Initialize member variables to default values.
00552     //
00553
00554     m_hNode = NULL;
00555
00556     //
00557     // Set the object type.
00558     //
00559
00560     m_cot = CLUADMEX_OT_NODE;
00561
00562     //
00563     // Get an interface pointer to IGetClusterNodeInfo.
00564     //
00565
00566     hr = piDataIn->QueryInterface( IID_IGetClusterNodeInfo, reinterpret_cast< LPVOID * >( &piNodeInfo ) );
00567     if ( FAILED( hr ) )
00568     {
00569         goto Cleanup;
00570     } // if: error querying for interface
00571
00572     //
00573     // Get a copy of the handle.  Don't free this handle - it's just a copy.
00574     //
00575
00576     m_hNode = piNodeInfo->GetNodeHandle( 0 );
00577     ASSERT( m_hNode != NULL );
00578     if ( m_hNode == NULL )
00579     {
00580         hr = E_HANDLE;
00581         goto Cleanup;
00582     } // if: error getting the node handle
00583
00584 Cleanup:
00585
00586     if ( piNodeInfo != NULL )
00587     {
00588         piNodeInfo->Release();
00589     } // if:
00590
00591     return hr;
00592
00593 } //*** CNodeData::HrInitialize
00594
00595 /////////////////////////////////////////////////////////////////////////////
00596 //++
00597 //
00598 //  CNodeData::AddContextMenuItems
00599 //
00600 //  Description:
00601 //      Add menu items to the node object context menu.
00602 //
00603 //  Arguments:
00604 //      piCallbackIn
00605 //          Pointer to an IWCContextMenuCallback interface for adding menu
00606 //          items to the context menu.
00607 //
00608 //  Return Value:
00609 //      S_OK
00610 //          Menu items added successfully.
00611 //
00612 //      hr
00613 //          Any errors returned by IWCContextMenuCallback
00614 //          ::AddExtensionMenuItem().
00615 //
00616 //--
00617 /////////////////////////////////////////////////////////////////////////////
00618 HRESULT
00619 CNodeData::AddContextMenuItems(
00620     IWCContextMenuCallback * piCallbackIn
00621     )
00622 {
00623     HRESULT hr = S_OK;
00624
00625     ASSERT( piCallbackIn != NULL );
00626
00627     hr = AddContextMenuItem(
00628               piCallbackIn
00629             , IDS_NODE_MENU_ITEM_1
00630             , IDS_NODE_MENU_ITEM_1_DESC
00631             , NODE_MENU_ID_1
00632             , MF_ENABLED
00633             );
00634
00635     return hr;
00636
00637 } //*** CNodeData::AddContextMenuItems
00638
00639 /////////////////////////////////////////////////////////////////////////////
00640 //++
00641 //
00642 //  CNodeData::InvokeCommand
00643 //
00644 //  Description:
00645 //      Invoke a command we added to a context menu.
00646 //
00647 //  Arguments:
00648 //      nCommandIDIn
00649 //          ID of the menu item to execute.  This is the same ID passed to the
00650 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
00651 //
00652 //  Return Value:
00653 //      S_OK        Command invoked successfully.
00654 //      E_NOTIMPL   Command ID not recognized.
00655 //
00656 //--
00657 /////////////////////////////////////////////////////////////////////////////
00658 HRESULT
00659 CNodeData::InvokeCommand(
00660     ULONG nCommandIDIn
00661     )
00662 {
00663     HRESULT hr = S_OK;
00664
00665     switch ( nCommandIDIn )
00666     {
00667         case NODE_MENU_ID_1:
00668
00669             //
00670             //  TODO:  Implement your menu item here
00671             //
00672
00673             hr = S_OK;
00674             break;
00675
00676         default:
00677             hr = E_NOTIMPL;
00678             break;
00679     } // switch: nCommandIDIn
00680
00681     return hr;
00682
00683 } //*** CNodeData::InvokeCommand
00684
00685 /////////////////////////////////////////////////////////////////////////////
00686 // CGroupData implementation
00687 /////////////////////////////////////////////////////////////////////////////
00688
00689 /////////////////////////////////////////////////////////////////////////////
00690 //++
00691 //
00692 //  CGroupData::HrInitialize
00693 //
00694 //  Description:
00695 //      Initializes the object.
00696 //
00697 //  Arguments:
00698 //
00699 //  Return Value:
00700 //
00701 //--
00702 /////////////////////////////////////////////////////////////////////////////
00703 HRESULT
00704 CGroupData::HrInitialize(
00705     IUnknown * piDataIn
00706     )
00707 {
00708     HRESULT                 hr = S_OK;
00709     IGetClusterGroupInfo *  piGroupInfo = NULL;
00710
00711     ASSERT( piDataIn != NULL );
00712
00713     //
00714     // Initialize the base class.
00715     //
00716
00717     hr = CObjData::HrInitialize( piDataIn );
00718     if ( FAILED( hr ) )
00719     {
00720         goto Cleanup;
00721     } // if: error initializing the base class
00722
00723     //
00724     // Initialize member variables to default values.
00725     //
00726
00727     m_hGroup = NULL;
00728
00729     //
00730     // Set the object type.
00731     //
00732
00733     m_cot = CLUADMEX_OT_GROUP;
00734
00735     //
00736     // Get an interface pointer to IGetClusterGroupInfo.
00737     //
00738
00739     hr = piDataIn->QueryInterface( IID_IGetClusterGroupInfo, reinterpret_cast< LPVOID * >( &piGroupInfo ) );
00740     if ( FAILED( hr ) )
00741     {
00742         goto Cleanup;
00743     } // if: error querying for interface
00744
00745     //
00746     // Get a copy of the handle.  Don't free this handle - it's just a copy.
00747     //
00748
00749     m_hGroup = piGroupInfo->GetGroupHandle( 0 );
00750     ASSERT( m_hGroup != NULL );
00751     if ( m_hGroup == NULL )
00752     {
00753         hr = E_HANDLE;
00754         goto Cleanup;
00755     } // if: error getting the group handle
00756
00757 Cleanup:
00758
00759     if ( piGroupInfo != NULL )
00760     {
00761         piGroupInfo->Release();
00762     } // if:
00763
00764     return hr;
00765
00766 } //*** CGroupData::HrInitialize
00767
00768 /////////////////////////////////////////////////////////////////////////////
00769 //++
00770 //
00771 //  CGroupData::AddContextMenuItems
00772 //
00773 //  Description:
00774 //      Add menu items to the group object context menu.
00775 //
00776 //  Arguments:
00777 //      piCallbackIn
00778 //          Pointer to an IWCContextMenuCallback interface for adding menu
00779 //          items to the context menu.
00780 //
00781 //  Return Value:
00782 //      S_OK
00783 //          Menu items added successfully.
00784 //
00785 //      hr
00786 //          Any errors returned by IWCContextMenuCallback
00787 //          ::AddExtensionMenuItem().
00788 //
00789 //--
00790 /////////////////////////////////////////////////////////////////////////////
00791 HRESULT CGroupData::AddContextMenuItems(
00792       IWCContextMenuCallback * piCallbackIn
00793       )
00794 {
00795     HRESULT hr = S_OK;
00796
00797     ASSERT( piCallbackIn != NULL );
00798
00799     hr = AddContextMenuItem(
00800               piCallbackIn
00801             , IDS_GROUP_MENU_ITEM_1
00802             , IDS_GROUP_MENU_ITEM_1_DESC
00803             , GROUP_MENU_ID_1
00804             , MF_ENABLED
00805             );
00806
00807     return hr;
00808
00809 } //*** CGroupData::AddContextMenuItems
00810
00811 /////////////////////////////////////////////////////////////////////////////
00812 //++
00813 //
00814 //  CGroupData::InvokeCommand
00815 //
00816 //  Description:
00817 //      Invoke a command we added to a context menu.
00818 //
00819 //  Arguments:
00820 //      nCommandIDIn
00821 //          ID of the menu item to execute.  This is the same ID passed to the
00822 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
00823 //
00824 //  Return Value:
00825 //      S_OK        Command invoked successfully.
00826 //      E_NOTIMPL   Command ID not recognized.
00827 //
00828 //--
00829 /////////////////////////////////////////////////////////////////////////////
00830 HRESULT CGroupData::InvokeCommand( ULONG nCommandIDIn )
00831 {
00832     HRESULT hr = S_OK;
00833
00834     switch ( nCommandIDIn )
00835     {
00836         case GROUP_MENU_ID_1:
00837
00838             //
00839             //  TODO:  Implement your menu item here
00840             //
00841
00842             hr = S_OK;
00843             break;
00844
00845         default:
00846             hr = E_NOTIMPL;
00847             break;
00848     } // switch: nCommandIDIn
00849
00850     return hr;
00851
00852 } //*** CGroupData::InvokeCommand
00853
00854 /////////////////////////////////////////////////////////////////////////////
00855 // CResData implementation
00856 /////////////////////////////////////////////////////////////////////////////
00857
00858 //
00859 // Note: Since we don't have any properties to display we won't display
00860 //       the Wizard or Property Sheet pages.  To have them shown uncomment
00861 //       the line below.
00862 //
00863
00864 static CRuntimeClass * g_rgprtcResPSPages[] = {
00865 //    RUNTIME_CLASS( CClipBookServerParamsPage ),
00866     NULL
00867     };
00868
00869 /////////////////////////////////////////////////////////////////////////////
00870 //++
00871 //
00872 //  CResData::HrInitialize
00873 //
00874 //  Description:
00875 //      Initializes the object.
00876 //
00877 //  Arguments:
00878 //
00879 //  Return Value:
00880 //
00881 //--
00882 /////////////////////////////////////////////////////////////////////////////
00883 HRESULT
00884 CResData::HrInitialize(
00885     IUnknown * piDataIn
00886     )
00887 {
00888     HRESULT                     hr = S_OK;
00889     IGetClusterResourceInfo *   piResInfo = NULL;
00890     LONG                        cchTypeName = 0;
00891     BSTR                        bstrTypeName = NULL;
00892     LPCWSTR                     pwszResTypes = g_wszResourceTypeNames;
00893
00894     ASSERT( piDataIn != NULL );
00895
00896     //
00897     // Initialize the base class.
00898     //
00899
00900     hr = CObjData::HrInitialize( piDataIn );
00901     if ( FAILED( hr ) )
00902     {
00903         goto Cleanup;
00904     } // if: error initializing the base class
00905
00906     //
00907     // Initialize member variables to default values.
00908     //
00909
00910     m_hResource = NULL;
00911     m_fSupportedType = FALSE;
00912
00913     //
00914     // Set the object type.
00915     //
00916
00917     m_cot = CLUADMEX_OT_RESOURCE;
00918
00919     //
00920     // Set the pointers to our resource property sheet and wizard pages.
00921     //
00922
00923     m_rgprtcPSPages = g_rgprtcResPSPages;
00924     m_rgprtcWizPages = g_rgprtcResPSPages;
00925
00926     //
00927     // Get an interface pointer to IGetClusterResourceInfo.
00928     //
00929
00930     hr = piDataIn->QueryInterface( IID_IGetClusterResourceInfo, reinterpret_cast< LPVOID * >( &piResInfo ) );
00931     if ( FAILED( hr ) )
00932     {
00933         goto Cleanup;
00934     } // if: error querying for interface
00935
00936     //
00937     // Get a copy of the handle.  Don't free this handle, it's just a copy.
00938     //
00939
00940     m_hResource = piResInfo->GetResourceHandle( 0 );
00941     ASSERT( m_hResource != NULL );
00942     if ( m_hResource == NULL )
00943     {
00944         hr = E_HANDLE;
00945         goto Cleanup;
00946     } // if: error querying for interface
00947
00948     //
00949     // Allocate a buffer for and retrieve the resource type name.
00950     //
00951
00952     hr = piResInfo->GetResourceTypeName( 0, NULL, &cchTypeName );
00953     if ( FAILED( hr ) )
00954     {
00955         goto Cleanup;
00956     } // if:
00957
00958     bstrTypeName = SysAllocStringLen( NULL, cchTypeName );
00959     if ( bstrTypeName == NULL )
00960     {
00961         hr = E_OUTOFMEMORY;
00962         goto Cleanup;
00963     } // if:
00964
00965     hr = piResInfo->GetResourceTypeName( 0, bstrTypeName, &cchTypeName );
00966     if ( FAILED( hr ) )
00967     {
00968         goto Cleanup;
00969     } // if:
00970
00971     //
00972     // The CString assignment operator makes a copy.
00973     //
00974
00975     m_strResTypeName = bstrTypeName;
00976
00977     //
00978     // Determine whether this is a supported type.
00979     //
00980
00981     m_fSupportedType = FALSE;
00982     while ( *pwszResTypes != L'\0' )
00983     {
00984         if ( m_strResTypeName.CompareNoCase( pwszResTypes ) == 0 )
00985         {
00986             m_fSupportedType = TRUE;
00987             break;
00988         } // if:
00989
00990         pwszResTypes += lstrlenW( pwszResTypes ) + 1;
00991     }  // while:  more resource types
00992
00993 Cleanup:
00994
00995     if ( piResInfo != NULL )
00996     {
00997         piResInfo->Release();
00998     } // if:
00999
01000     SysFreeString( bstrTypeName );
01001
01002     return hr;
01003
01004 } //*** CResData::HrInitialize
01005
01006 /////////////////////////////////////////////////////////////////////////////
01007 //++
01008 //
01009 //  CResData::AddContextMenuItems
01010 //
01011 //  Description:
01012 //      Add menu items to the resource object context menu.
01013 //
01014 //  Arguments:
01015 //      piCallbackIn
01016 //          Pointer to an IWCContextMenuCallback interface for adding menu
01017 //          items to the context menu.
01018 //
01019 //  Return Value:
01020 //      S_OK
01021 //          Menu items added successfully.
01022 //
01023 //      hr
01024 //          Any errors returned by IWCContextMenuCallback
01025 //          ::AddExtensionMenuItem().
01026 //
01027 //--
01028 /////////////////////////////////////////////////////////////////////////////
01029 HRESULT
01030 CResData::AddContextMenuItems(
01031     IWCContextMenuCallback * piCallbackIn
01032     )
01033 {
01034     HRESULT hr = S_OK;
01035
01036     UNREFERENCED_PARAMETER( piCallbackIn );
01037
01038     //
01039     // TODO: Uncomment the following code to add context menus
01040     //       to ClipBookServer resources.
01041     //
01042     /*
01043
01044     ASSERT( piCallbackIn != NULL );
01045
01046     hr = AddContextMenuItem(
01047               piCallbackIn
01048             , IDS_RESOURCE_MENU_ITEM_1
01049             , IDS_RESOURCE_MENU_ITEM_1_DESC
01050             , RESOURCE_MENU_ID_1
01051             , MF_ENABLED
01052             );
01053     */
01054
01055     return hr;
01056
01057 } //*** CResData::AddContextMenuItems
01058
01059 /////////////////////////////////////////////////////////////////////////////
01060 //++
01061 //
01062 //  CResData::InvokeCommand
01063 //
01064 //  Description:
01065 //      Invoke a command we added to a context menu.
01066 //
01067 //  Arguments:
01068 //      nCommandIDIn
01069 //          ID of the menu item to execute.  This is the same ID passed to the
01070 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
01071 //
01072 //  Return Value:
01073 //      S_OK        Command invoked successfully.
01074 //      E_NOTIMPL   Command ID not recognized.
01075 //
01076 //--
01077 /////////////////////////////////////////////////////////////////////////////
01078 HRESULT
01079 CResData::InvokeCommand(
01080     ULONG nCommandIDIn
01081     )
01082 {
01083     HRESULT hr = S_OK;
01084
01085     switch ( nCommandIDIn )
01086     {
01087         case RESOURCE_MENU_ID_1:
01088
01089             //
01090             //  TODO:  Implement your menu item here
01091             //
01092
01093             hr = S_OK;
01094             break;
01095
01096         case ALL_RESOURCES_MENU_ID_1:
01097             hr = S_OK;
01098             break;
01099
01100         default:
01101             hr = E_NOTIMPL;
01102             break;
01103     } // switch: nCommandIDIn
01104
01105     return hr;
01106
01107 } //*** CResData::InvokeCommand
01108
01109 /////////////////////////////////////////////////////////////////////////////
01110 //++
01111 //
01112 //  CResData::GetPropertySheetPages
01113 //
01114 //  Description:
01115 //
01116 //  Arguments:
01117 //
01118 //  Return Value:
01119 //      S_OK        Success.
01120 //      E_NOTIMPL   No property sheet pages for this resource.
01121 //
01122 //--
01123 /////////////////////////////////////////////////////////////////////////////
01124 HRESULT
01125 CResData::GetPropertySheetPages(
01126     CRuntimeClass *** ppaPropSheetsOut
01127     )
01128 {
01129     HRESULT hr = E_NOTIMPL;
01130
01131     ASSERT( ppaPropSheetsOut != NULL );
01132
01133     //
01134     // This class only extends ClipBook Server resources.
01135     //
01136
01137     if ( m_fSupportedType == FALSE )
01138     {
01139         goto Cleanup;
01140     } // if:
01141
01142     if ( m_rgprtcPSPages != NULL )
01143     {
01144         hr = S_OK;
01145         *ppaPropSheetsOut = m_rgprtcPSPages;
01146     } // if:
01147
01148 Cleanup:
01149
01150     return hr;
01151
01152 } //*** CResData::GetPropertySheetPages
01153
01154 /////////////////////////////////////////////////////////////////////////////
01155 //++
01156 //
01157 //  CResData::GetWizardPages
01158 //
01159 //  Description:
01160 //
01161 //  Arguments:
01162 //
01163 //  Return Value:
01164 //      S_OK        Success.
01165 //      E_NOTIMPL   No property sheet pages for this resource.
01166 //
01167 //--
01168 /////////////////////////////////////////////////////////////////////////////
01169 HRESULT
01170 CResData::GetWizardPages(
01171     CRuntimeClass *** ppaWizardPagesOut
01172     )
01173 {
01174     HRESULT hr = E_NOTIMPL;
01175
01176     ASSERT( ppaWizardPagesOut != NULL );
01177
01178     //
01179     // This class only extends ClipBook Server resources.
01180     //
01181
01182     if ( m_fSupportedType == FALSE )
01183     {
01184         goto Cleanup;
01185     } // if:
01186
01187     if ( m_rgprtcWizPages != NULL )
01188     {
01189         hr = S_OK;
01190         *ppaWizardPagesOut = m_rgprtcWizPages;
01191     } // if:
01192
01193 Cleanup:
01194
01195     return hr;
01196
01197 } //*** CResData::GetWizardPages
01198
01199 /////////////////////////////////////////////////////////////////////////////
01200 // CResTypeData implementation
01201 /////////////////////////////////////////////////////////////////////////////
01202
01203 /////////////////////////////////////////////////////////////////////////////
01204 //++
01205 //
01206 //  CResTypeData::HrInitialize
01207 //
01208 //  Description:
01209 //      Initializes the object.
01210 //
01211 //  Arguments:
01212 //
01213 //  Return Value:
01214 //
01215 //--
01216 /////////////////////////////////////////////////////////////////////////////
01217 HRESULT
01218 CResTypeData::HrInitialize(
01219     IUnknown * piDataIn
01220     )
01221 {
01222     HRESULT hr = S_OK;
01223     LPCWSTR pwszResTypes = g_wszResourceTypeNames;
01224
01225     ASSERT( piDataIn != NULL );
01226
01227     //
01228     // Initialize the base class.
01229     //
01230
01231     hr = CObjData::HrInitialize( piDataIn );
01232     if ( FAILED( hr ) )
01233     {
01234         goto Cleanup;
01235     } // if: error initializing the base class
01236
01237     //
01238     // Set the object type.
01239     //
01240
01241     m_cot = CLUADMEX_OT_RESOURCETYPE;
01242
01243     m_fSupportedType = FALSE;
01244     while ( *pwszResTypes != L'\0' )
01245     {
01246         if ( StrName().CompareNoCase( pwszResTypes ) == 0 )
01247         {
01248             m_fSupportedType = TRUE;
01249             break;
01250         } // if:
01251
01252         pwszResTypes += lstrlenW( pwszResTypes ) + 1;
01253     }  // while:  more resource types
01254
01255 Cleanup:
01256
01257     return hr;
01258
01259 } //*** CResTypeData::HrInitialize
01260
01261 /////////////////////////////////////////////////////////////////////////////
01262 //++
01263 //
01264 //  CResTypeData::AddContextMenuItems
01265 //
01266 //  Description:
01267 //      Add menu items to the resource type object context menu.
01268 //
01269 //  Arguments:
01270 //      piCallbackIn
01271 //          Pointer to an IWCContextMenuCallback interface for adding menu
01272 //          items to the context menu.
01273 //
01274 //  Return Value:
01275 //      S_OK
01276 //          Menu items added successfully.
01277 //
01278 //      hr
01279 //          Any errors returned by IWCContextMenuCallback
01280 //          ::AddExtensionMenuItem().
01281 //
01282 //--
01283 /////////////////////////////////////////////////////////////////////////////
01284 HRESULT
01285 CResTypeData::AddContextMenuItems(
01286     IWCContextMenuCallback * piCallbackIn
01287     )
01288 {
01289     HRESULT hr = S_OK;
01290
01291     UNREFERENCED_PARAMETER( piCallbackIn );
01292
01293     return hr;
01294
01295 } //*** CResTypeData::AddContextMenuItems
01296
01297 /////////////////////////////////////////////////////////////////////////////
01298 //++
01299 //
01300 //  CResTypeData::InvokeCommand
01301 //
01302 //  Description:
01303 //      Invoke a command we added to a context menu.
01304 //
01305 //  Arguments:
01306 //      nCommandIDIn
01307 //          ID of the menu item to execute.  This is the same ID passed to the
01308 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
01309 //
01310 //  Return Value:
01311 //      S_OK        Command invoked successfully.
01312 //      E_NOTIMPL   Command ID not recognized.
01313 //
01314 //--
01315 /////////////////////////////////////////////////////////////////////////////
01316 HRESULT
01317 CResTypeData::InvokeCommand(
01318     ULONG nCommandIDIn
01319     )
01320 {
01321     HRESULT hr = S_OK;
01322
01323     switch ( nCommandIDIn )
01324     {
01325         case RESTYPE_MENU_ID_1:
01326
01327             //
01328             //  TODO:  Implement your menu item here
01329             //
01330
01331             hr = S_OK;
01332             break;
01333
01334         case ALL_RESTYPES_MENU_ID_1:
01335             hr = S_OK;
01336             break;
01337
01338         default:
01339             hr = E_NOTIMPL;
01340             break;
01341     } // switch: nCommandIDIn
01342
01343     return hr;
01344
01345 } //*** CResTypeData::InvokeCommand
01346
01347 /////////////////////////////////////////////////////////////////////////////
01348 // CNetworkData implementation
01349 /////////////////////////////////////////////////////////////////////////////
01350
01351 /////////////////////////////////////////////////////////////////////////////
01352 //++
01353 //
01354 //  CNetworkData::HrInitialize
01355 //
01356 //  Description:
01357 //      Initializes the object.
01358 //
01359 //  Arguments:
01360 //
01361 //  Return Value:
01362 //
01363 //--
01364 /////////////////////////////////////////////////////////////////////////////
01365 HRESULT
01366 CNetworkData::HrInitialize(
01367     IUnknown * piDataIn
01368     )
01369 {
01370     HRESULT                     hr = S_OK;
01371     IGetClusterNetworkInfo *    piNetInfo = NULL;
01372
01373     ASSERT( piDataIn != NULL );
01374
01375     //
01376     // Initialize the base class.
01377     //
01378
01379     hr = CObjData::HrInitialize( piDataIn );
01380     if ( FAILED( hr ) )
01381     {
01382         goto Cleanup;
01383     } // if: error initializing the base class
01384
01385     //
01386     // Initialize member variables to default values.
01387     //
01388
01389     m_hNetwork = NULL;
01390
01391     //
01392     // Set the object type.
01393     //
01394
01395     m_cot = CLUADMEX_OT_NETWORK;
01396
01397     //
01398     // Get an interface pointer to IGetClusterNetworkInfo.
01399     //
01400
01401     hr = piDataIn->QueryInterface( IID_IGetClusterNetworkInfo, reinterpret_cast< LPVOID * >( &piNetInfo ) );
01402     if ( FAILED( hr ) )
01403     {
01404         goto Cleanup;
01405     } // if: error querying for interface
01406
01407     //
01408     // Get a copy of the handle.  Don't free this handle - it's just a copy.
01409     //
01410
01411     m_hNetwork = piNetInfo->GetNetworkHandle( 0 );
01412     ASSERT( m_hNetwork != NULL );
01413     if ( m_hNetwork == NULL )
01414     {
01415         hr = E_HANDLE;
01416         goto Cleanup;
01417     } // if: error getting the network handle
01418
01419 Cleanup:
01420
01421     if ( piNetInfo != NULL )
01422     {
01423         piNetInfo->Release();
01424     } // if:
01425
01426     return hr;
01427
01428 } //*** CNetworkData::HrInitialize
01429
01430 /////////////////////////////////////////////////////////////////////////////
01431 //++
01432 //
01433 //  CNetworkData::AddContextMenuItems
01434 //
01435 //  Description:
01436 //      Add menu items to the network object context menu.
01437 //
01438 //  Arguments:
01439 //      piCallbackIn
01440 //          Pointer to an IWCContextMenuCallback interface for adding menu
01441 //          items to the context menu.
01442 //
01443 //  Return Value:
01444 //      S_OK
01445 //          Menu items added successfully.
01446 //
01447 //      hr
01448 //          Any errors returned by IWCContextMenuCallback
01449 //          ::AddExtensionMenuItem().
01450 //
01451 //--
01452 /////////////////////////////////////////////////////////////////////////////
01453 HRESULT CNetworkData::AddContextMenuItems(
01454       IWCContextMenuCallback * piCallbackIn
01455     )
01456 {
01457     HRESULT     hr = S_OK;
01458
01459     ASSERT( piCallbackIn != NULL );
01460
01461     hr = AddContextMenuItem(
01462               piCallbackIn
01463             , IDS_NETWORK_MENU_ITEM_1
01464             , IDS_NETWORK_MENU_ITEM_1_DESC
01465             , NETWORK_MENU_ID_1
01466             , MF_ENABLED
01467             );
01468
01469     return hr;
01470
01471 } //*** CNetworkData::AddContextMenuItems
01472
01473 /////////////////////////////////////////////////////////////////////////////
01474 //++
01475 //
01476 //  CNetworkData::InvokeCommand
01477 //
01478 //  Description:
01479 //      Invoke a command we added to a context menu.
01480 //
01481 //  Arguments:
01482 //      nCommandIDIn
01483 //          ID of the menu item to execute.  This is the same ID passed to the
01484 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
01485 //
01486 //  Return Value:
01487 //      S_OK        Command invoked successfully.
01488 //      E_NOTIMPL   Command ID not recognized.
01489 //
01490 //--
01491 /////////////////////////////////////////////////////////////////////////////
01492 HRESULT
01493 CNetworkData::InvokeCommand(
01494     ULONG nCommandIDIn
01495     )
01496 {
01497     HRESULT hr = S_OK;
01498
01499     switch ( nCommandIDIn )
01500     {
01501         case NETWORK_MENU_ID_1:
01502
01503             //
01504             //  TODO:  Implement your menu item here
01505             //
01506
01507             hr = S_OK;
01508             break;
01509
01510         default:
01511             hr = E_NOTIMPL;
01512             break;
01513     } // switch: nCommandIDIn
01514
01515     return hr;
01516
01517 } //*** CNetworkData::InvokeCommand
01518
01519 /////////////////////////////////////////////////////////////////////////////
01520 // CNetInterfaceData implementation
01521 /////////////////////////////////////////////////////////////////////////////
01522
01523 /////////////////////////////////////////////////////////////////////////////
01524 //++
01525 //
01526 //  CNetInterfaceData::HrInitialize
01527 //
01528 //  Description:
01529 //      Initializes the object.
01530 //
01531 //  Arguments:
01532 //
01533 //  Return Value:
01534 //
01535 //--
01536 /////////////////////////////////////////////////////////////////////////////
01537 HRESULT
01538 CNetInterfaceData::HrInitialize(
01539     IUnknown * piDataIn
01540     )
01541 {
01542     HRESULT                         hr = S_OK;
01543     IGetClusterNetInterfaceInfo *   piNetInterfaceInfo = NULL;
01544
01545     ASSERT( piDataIn != NULL );
01546
01547     //
01548     // Initialize the base class.
01549     //
01550
01551     hr = CObjData::HrInitialize( piDataIn );
01552     if ( FAILED( hr ) )
01553     {
01554         goto Cleanup;
01555     } // if: error initializing the base class
01556
01557     //
01558     // Initialize member variables to default values.
01559     //
01560
01561     m_hNetInterface = NULL;
01562
01563     //
01564     // Set the object type.
01565     //
01566
01567     m_cot = CLUADMEX_OT_NETINTERFACE;
01568
01569     //
01570     // Get an interface pointer to IGetClusterNetInterfaceInfo.
01571     //
01572
01573     hr = piDataIn->QueryInterface( IID_IGetClusterNetInterfaceInfo, reinterpret_cast< LPVOID * >( &piNetInterfaceInfo ) );
01574     if ( FAILED( hr ) )
01575     {
01576         goto Cleanup;
01577     } // if: error querying for interface
01578
01579     //
01580     // Get a copy of the handle.  Don't free this handle - it's just a copy.
01581     //
01582
01583     m_hNetInterface = piNetInterfaceInfo->GetNetInterfaceHandle( 0 );
01584     ASSERT( m_hNetInterface != NULL );
01585     if ( m_hNetInterface == NULL )
01586     {
01587         hr = E_HANDLE;
01588         goto Cleanup;
01589     } // if: error getting the netinterface handle
01590
01591 Cleanup:
01592
01593     if ( piNetInterfaceInfo != NULL )
01594     {
01595         piNetInterfaceInfo->Release();
01596     } // if:
01597
01598     return hr;
01599
01600 } //*** CNetInterfaceData::HrInitialize
01601
01602 /////////////////////////////////////////////////////////////////////////////
01603 //++
01604 //
01605 //  CNetInterfaceData::AddContextMenuItems
01606 //
01607 //  Description:
01608 //      Add menu items to the network interface object context menu.
01609 //
01610 //  Arguments:
01611 //      piCallbackIn
01612 //          Pointer to an IWCContextMenuCallback interface for adding menu
01613 //          items to the context menu.
01614 //
01615 //  Return Value:
01616 //      S_OK
01617 //          Menu items added successfully.
01618 //
01619 //      hr
01620 //          Any errors returned by IWCContextMenuCallback
01621 //          ::AddExtensionMenuItem().
01622 //
01623 //--
01624 /////////////////////////////////////////////////////////////////////////////
01625 HRESULT
01626 CNetInterfaceData::AddContextMenuItems(
01627     IWCContextMenuCallback * piCallbackIn
01628     )
01629 {
01630     HRESULT hr = S_OK;
01631
01632     ASSERT( piCallbackIn != NULL );
01633
01634     hr = AddContextMenuItem(
01635               piCallbackIn
01636             , IDS_NETINTERFACE_MENU_ITEM_1
01637             , IDS_NETINTERFACE_MENU_ITEM_1_DESC
01638             , NETINTERFACE_MENU_ID_1
01639             , MF_ENABLED
01640             );
01641
01642     return hr;
01643
01644 } //*** CNetInterfaceData::AddContextMenuItems
01645
01646 /////////////////////////////////////////////////////////////////////////////
01647 //++
01648 //
01649 //  CNetInterfaceData::InvokeCommand
01650 //
01651 //  Description:
01652 //      Invoke a command we added to a context menu.
01653 //
01654 //  Arguments:
01655 //      nCommandIDIn
01656 //          ID of the menu item to execute.  This is the same ID passed to the
01657 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
01658 //
01659 //  Return Value:
01660 //      S_OK        Command invoked successfully.
01661 //      E_NOTIMPL   Command ID not recognized.
01662 //
01663 //--
01664 /////////////////////////////////////////////////////////////////////////////
01665 HRESULT
01666 CNetInterfaceData::InvokeCommand(
01667     ULONG nCommandIDIn
01668     )
01669 {
01670     HRESULT hr = S_OK;
01671
01672     switch ( nCommandIDIn )
01673     {
01674         case NETINTERFACE_MENU_ID_1:
01675
01676             //
01677             //  TODO:  Implement your menu item here
01678             //
01679
01680             hr = S_OK;
01681             break;
01682
01683         default:
01684             hr = E_NOTIMPL;
01685             break;
01686     } // switch: nCommandIDIn
01687
01688     return hr;
01689
01690 } //*** CNetInterfaceData::InvokeCommand
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagENABLEMODELESSMSG Member List

This is the complete list of members for _tagENABLEMODELESSMSG, including all inherited members.
fEnable _tagENABLEMODELESSMSG
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/globaldev/resource.h Source File

  • WinUI
  • GlobalDev
  • globaldev

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Used by Global.rc
00003 //
00004 #define STR_RESDLL_NOTFOUND             1
00005 #define STR_APPTITLE                    2
00006 #define STR_TITLE                       3
00007 #define STR_LARGEPOSNUMBER              4
00008 #define STR_LARGENEGNUMBER              5
00009 #define STR_POSCURRENCY                 6
00010 #define STR_NEGCURRENCY                 7
00011 #define IDI_MAINICON                    101
00012
00013 // Next default values for new objects
00014 //
00015 #ifdef APSTUDIO_INVOKED
00016 #ifndef APSTUDIO_READONLY_SYMBOLS
00017 #define _APS_NEXT_RESOURCE_VALUE        102
00018 #define _APS_NEXT_COMMAND_VALUE         40001
00019 #define _APS_NEXT_CONTROL_VALUE         1000
00020 #define _APS_NEXT_SYMED_VALUE           101
00021 #endif
00022 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/sky.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

sky.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Sky.h"
00021
00022 const GUID CSkyBasedVehicle::thisGuid = { 0x2974380f, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CSkyBasedVehicle implementation
00027 //
00028 //
00029 HRESULT CSkyBasedVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00030 {
00031   HRESULT hr;
00032   IUnknown *pUnk = NULL;
00033   IMessageView *pMessageView = NULL;
00034
00035   hr = pConsole->QueryResultView(&pUnk);
00036
00037   if (SUCCEEDED(hr)) {
00038     hr = pUnk->QueryInterface(IID_IMessageView, (void **)&pMessageView);
00039
00040     if (SUCCEEDED(hr)) {
00041       pMessageView->SetIcon(Icon_Information);
00042       pMessageView->SetTitleText(L"Sky-based vehicles");
00043       pMessageView->SetBodyText(L"Sky-based vehicles have no child nodes.");
00044
00045       pMessageView->Release();
00046     }
00047
00048     pUnk->Release();
00049   }
00050
00051   return S_FALSE;
00052 }
00053
00054 HRESULT CSkyBasedVehicle::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
00055 {
00056     // error message control
00057   LPOLESTR lpOleStr = NULL;
00058   HRESULT hr = StringFromCLSID(CLSID_MessageView, &lpOleStr);
00059     *ppViewType = lpOleStr;
00060
00061   return hr;
00062 }
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/HiPerfProvider/Factory.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • HiPerfProvider

Factory.Cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////
00002
00003 //
00004
00005 //  Factory.cpp
00006
00007 //
00008
00009 //  Module: WMI high performance provider sample code
00010
00011 //
00012
00013 //  This is a standard class factory implementation for the CHiPerfProvider
00014
00015 //  object.
00016
00017 //
00018 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00019 //
00020 ////////////////////////////////////////////////////////////////////////
00021
00022 #include <windows.h>
00023
00024 #include "BasicHiPerf.h"
00025 #include "Factory.h"
00026
00027 #define _UNICODE
00028 #define UNICODE
00029
00030 extern long g_lObjects;
00031 extern long g_lLocks;
00032
00033 //////////////////////////////////////////////////////////////
00034 //
00035 //
00036 //  CClassFactory
00037 //
00038 //
00039 //////////////////////////////////////////////////////////////
00040
00041 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, void** ppv)
00042 //////////////////////////////////////////////////////////////
00043 //
00044 //  Standard QueryInterface
00045 //
00046 //  Parameters:
00047 //    riid  - the ID of the requested interface
00048 //    ppv   - a pointer to the interface pointer
00049 //
00050 //////////////////////////////////////////////////////////////
00051 {
00052     if(riid == IID_IUnknown)
00053         *ppv = (LPVOID)(IUnknown*)this;
00054     else if(riid == IID_IClassFactory)
00055         *ppv = (LPVOID)(IClassFactory*)this;
00056   else return E_NOINTERFACE;
00057
00058   ((IUnknown*)*ppv)->AddRef();
00059   return S_OK;
00060 }
00061
00062 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00063 //////////////////////////////////////////////////////////////
00064 //
00065 //  Standard COM AddRef
00066 //
00067 //////////////////////////////////////////////////////////////
00068 {
00069     return InterlockedIncrement(&m_lRef);
00070 }
00071
00072 STDMETHODIMP_(ULONG) CClassFactory::Release()
00073 //////////////////////////////////////////////////////////////
00074 //
00075 //  Standard COM Release
00076 //
00077 //////////////////////////////////////////////////////////////
00078 {
00079     long lRef = InterlockedDecrement(&m_lRef);
00080     if(lRef == 0)
00081         delete this;
00082
00083     return lRef;
00084 }
00085
00086 STDMETHODIMP CClassFactory::CreateInstance(
00087     /* [in] */ IUnknown* pUnknownOuter,
00088     /* [in] */ REFIID iid,
00089     /* [out] */ LPVOID *ppv)
00090 //////////////////////////////////////////////////////////////
00091 //
00092 //  Standard COM CreateInstance
00093 //
00094 //////////////////////////////////////////////////////////////
00095 {
00096   HRESULT hRes;
00097   CHiPerfProvider *pProvider = NULL;
00098
00099   *ppv = NULL;
00100
00101   // We do not support aggregation
00102   // =============================
00103
00104   if (pUnknownOuter)
00105     return CLASS_E_NOAGGREGATION;
00106
00107   // Create the provider object
00108   // ==========================
00109
00110   pProvider = new CHiPerfProvider;
00111
00112   if (!pProvider)
00113     return E_OUTOFMEMORY;
00114
00115   // Retrieve the requested interface
00116   // ================================
00117
00118   hRes = pProvider->QueryInterface(iid, ppv);
00119   if (FAILED(hRes))
00120   {
00121     delete pProvider;
00122     return hRes;
00123   }
00124
00125   return S_OK;
00126 }
00127
00128 STDMETHODIMP CClassFactory::LockServer(
00129     /* [in] */ BOOL bLock)
00130 //////////////////////////////////////////////////////////////
00131 //
00132 //  Standard COM LockServer
00133 //
00134 //////////////////////////////////////////////////////////////
00135 {
00136   if (bLock)
00137     InterlockedIncrement(&g_lLocks);
00138   else
00139     InterlockedDecrement(&g_lLocks);
00140
00141   return S_OK;
00142 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/src/IsapiRequest.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • src

IsapiRequest.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiRequest.h
00006
00007 Abstract:
00008
00009     A class to do common ISAPI extension
00010     processing tasks
00011
00012 Author:
00013
00014     ISAPI developer (Microsoft employee), October 2002
00015
00016 --*/
00017
00018 #include <IsapiTools.h>
00019
00020 //
00021 // Define the entity for a generic 500 server error response
00022 //
00023
00024 #define SERVER_ERROR    \
00025     "<html>\r\n"                                         \
00026     "<head> <title>500 Server Error</title> </head>\r\n" \
00027     "<h1> Server Error </h1>\r\n"                        \
00028     "<hr>\r\n"                                           \
00029     "The server was unable to process your request.\r\n" \
00030     "</html>"
00031
00032 //
00033 // Declare instance of static OS major version variable
00034 //
00035
00036 DWORD   ISAPI_REQUEST::_dwOsMajorVersion = 0;
00037
00038 ISAPI_REQUEST::ISAPI_REQUEST(
00039     EXTENSION_CONTROL_BLOCK *   pEcb
00040     )
00041     : _pEcb( pEcb ),
00042       _dwMaxSyncWriteSize( 0 ), // Use ISAPI_STRING default
00043       _fNeedDoneWithSession( FALSE ),
00044       _fClientIsConnected( TRUE ),
00045       _hImpersonationToken( NULL )
00046 /*++
00047
00048 Purpose:
00049
00050     Initializes the ISAPI_REQUEST object
00051
00052     During initialization, this object will determine
00053     the IIS version.
00054
00055 Arguments:
00056
00057     pEcb - The ECB for the request to associate with this object
00058
00059 Returns:
00060
00061     None
00062
00063 --*/
00064 {
00065     //
00066     // Set the max response buffer size
00067     //
00068
00069     _ResponseBuffer.SetMaxAlloc( DEFAULT_RESPONSE_BUFFER_SIZE );
00070
00071     //
00072     // Get the IIS version info from the ECB.
00073     //
00074
00075     _dwIISMajorVersion = pEcb->dwVersion >> 16;
00076     _dwIISMinorVersion = pEcb->dwVersion & 0xffff;
00077
00078     //
00079     // Note that not all versions of IIS return
00080     // their version correctly.
00081     //
00082     // In particular, IIS version 4.0 and 5.0 will
00083     // both return 4.  IIS versions 5.1 and 6.0 do
00084     // correctly set this value in the ECB.
00085     //
00086     // Therefore, if we see a major version of 4,
00087     // we'll look at the OS version to break the tie.
00088     //
00089
00090     if ( _dwIISMajorVersion == 4 &&
00091          _dwIISMinorVersion == 0 )
00092     {
00093         _dwIISMajorVersion = QueryOsMajorVersion();
00094     }
00095 }
00096
00097 ISAPI_REQUEST::~ISAPI_REQUEST(
00098     VOID
00099     )
00100 /*++
00101
00102 Purpose:
00103
00104     Destructor for the ISAPI_REQUEST object.
00105
00106     If the extension called AsyncTransmitBufferedResponse, then
00107     this code will take responsibility for notifying IIS that
00108     the request has been completed.
00109
00110 Arguments:
00111
00112     None
00113
00114 Returns:
00115
00116     None
00117
00118 --*/
00119 {
00120     DWORD   dwState;
00121
00122     //
00123     // If we send the response back via this object's
00124     // buffer, then we need to let IIS know that we
00125     // are done with the session.
00126     //
00127
00128     if ( _fNeedDoneWithSession )
00129     {
00130         //
00131         // Since buffered responses always send a content-length,
00132         // we should go ahead and keep the connection open
00133         //
00134
00135         dwState = HSE_STATUS_SUCCESS_AND_KEEP_CONN;
00136
00137         _pEcb->ServerSupportFunction( _pEcb->ConnID,
00138                                       HSE_REQ_DONE_WITH_SESSION,
00139                                       &dwState,
00140                                       NULL,
00141                                       NULL );
00142     }
00143 }
00144
00145 BOOL
00146 ISAPI_REQUEST::SyncSendStatusAndHeaders(
00147     CHAR *  szStatus,
00148     CHAR *  szHeaders
00149     )
00150 /*++
00151
00152 Purpose:
00153
00154     Synchronously sends the specified HTTP status codes
00155     and response headers to the client.
00156
00157 Arguments:
00158
00159     szStatus  - The status to send (ie. "200 OK")
00160     szHeaders - The response headers to send
00161
00162 Returns:
00163
00164     TRUE on success, FALSE on failure
00165
00166 --*/
00167 {
00168     DWORD   cchHeaders;
00169     DWORD   dwStatus;
00170     BOOL    fResult;
00171
00172     //
00173     // Set defaults if needed
00174     //
00175
00176     if ( szStatus == NULL )
00177     {
00178         szStatus = DEFAULT_STATUS;
00179     }
00180
00181     if ( szHeaders == NULL )
00182     {
00183         szHeaders = DEFAULT_HEADERS;
00184     }
00185
00186     //
00187     // Make sure that headers are properly terminated
00188     //
00189
00190     cchHeaders = strlen( szHeaders );
00191
00192     if ( strcmp( szHeaders, DEFAULT_HEADERS ) != 0 )
00193     {
00194         //
00195         // If we are not using the default value, szHeaders
00196         // must end with "\r\n\r\n" (the first "\r\n" pair is
00197         // to mark the end of the last header value, and the
00198         // second is to mark the end of all headers.
00199         //
00200
00201         if ( cchHeaders < 4 )
00202         {
00203             SetLastError( ERROR_INVALID_PARAMETER );
00204             goto Failed;
00205         }
00206
00207         if ( strcmp( szHeaders + cchHeaders - 4, "\r\n\r\n" ) != 0 )
00208         {
00209             SetLastError( ERROR_INVALID_PARAMETER );
00210             goto Failed;
00211         }
00212     }
00213
00214     //
00215     // To ensure proper logging, we need to set the dwHttpStatusCode
00216     // member on the ECB to reflect the proper value.  We'll get
00217     // this from the szStatus string, and ensure that it is in the
00218     // range of 100 to 999.
00219     //
00220
00221     dwStatus = atoi( szStatus );
00222
00223     if ( dwStatus < 100 ||
00224          dwStatus > 999 )
00225     {
00226         SetLastError( ERROR_INVALID_PARAMETER );
00227         goto Failed;
00228     }
00229
00230     _pEcb->dwHttpStatusCode = dwStatus;
00231
00232     //
00233     // Send the response now.
00234     //
00235     // Note that HSE_REQ_SEND_RESPONSE header will take care
00236     // of managing proper keep-alive behavior.  Basically, if
00237     // the headers contains a content-length, then IIS will
00238     // cause the response to honor keep-alive.  If not, then
00239     // IIS will close the connection when the ISAPI extension
00240     // is done processing.
00241     //
00242
00243     fResult =  _pEcb->ServerSupportFunction( _pEcb->ConnID,
00244                                              HSE_REQ_SEND_RESPONSE_HEADER,
00245                                              szStatus,
00246                                              NULL,
00247                                              (DWORD*)szHeaders );
00248
00249     if ( !fResult )
00250     {
00251         //
00252         // Since the call failed, we should assume
00253         // that the client is no longer connected.
00254         //
00255
00256         _fClientIsConnected = FALSE;
00257
00258         goto Failed;
00259     }
00260
00261     return TRUE;
00262
00263 Failed:
00264
00265     //
00266     // No special cleanup required
00267     //
00268
00269     return FALSE;
00270 }
00271
00272 BOOL
00273 ISAPI_REQUEST::SyncWriteClientArgs(
00274     CHAR *  szFormat,
00275     va_list args
00276     )
00277 /*++
00278
00279 Purpose:
00280
00281     Synchronously sends a string to the client using
00282     vsprintf-style formatting and a va_list of arguments.
00283
00284 Arguments:
00285
00286     szFormat - The string format to send
00287     args     - A va_list of additional arguments
00288
00289 Returns:
00290
00291     TRUE on success, FALSE on failure
00292
00293 --*/
00294 {
00295     ISAPI_STRING    IsapiString( _dwMaxSyncWriteSize );
00296     DWORD           cbData;
00297     BOOL            fResult;
00298
00299     //
00300     // Build the formatted data
00301     //
00302
00303     fResult = IsapiString.Vsprintf( szFormat,
00304                                     args );
00305
00306     if ( !fResult )
00307     {
00308         goto Failed;
00309     }
00310
00311     //
00312     // Send it
00313     //
00314
00315     cbData = IsapiString.QueryCCH();
00316
00317     fResult = _pEcb->WriteClient( _pEcb->ConnID,
00318                                   IsapiString.QueryStr(),
00319                                   &cbData,
00320                                   HSE_IO_SYNC | HSE_IO_NODELAY );
00321
00322     if ( !fResult )
00323     {
00324         //
00325         // Since the call failed, we should assume
00326         // that the client is no longer connected.
00327         //
00328
00329         _fClientIsConnected = FALSE;
00330     }
00331
00332     return fResult;
00333
00334 Failed:
00335
00336     //
00337     // No special cleanup required
00338     //
00339
00340     return FALSE;
00341 }
00342
00343 BOOL
00344 ISAPI_REQUEST::SyncWriteClientString(
00345     CHAR *  szFormat,
00346     ...
00347     )
00348 /*++
00349
00350 Purpose:
00351
00352     Synchronously sends a string to the client using
00353     printf-style formatting an a variable number of
00354     arguments
00355
00356 Arguments:
00357
00358     szFormat - The string format
00359     ...      - Zero or more additional arguments
00360
00361 Returns:
00362
00363     TRUE on success, FALSE on failure
00364
00365 --*/
00366 {
00367     BOOL    fResult;
00368     va_list args;
00369
00370     //
00371     // Let SyncWriteClientArgs do the work
00372     //
00373
00374     va_start( args, szFormat );
00375
00376     fResult = SyncWriteClientArgs( szFormat,
00377                                    args );
00378
00379     va_end( args );
00380
00381     return fResult;
00382 }
00383
00384 BOOL
00385 ISAPI_REQUEST::SyncWriteCompleteResponse(
00386     CHAR *  szStatus,
00387     CHAR *  szHeaders,
00388     CHAR *  szFormat,
00389     ...
00390     )
00391 /*++
00392
00393 Purpose:
00394
00395     Synchronously sends a complete response to the client
00396     using the specified status and headers, with a formatted
00397     string with variable arguments as the entity.
00398
00399 Arguments:
00400
00401     szStatus  - The status to send (ie. "200 OK")
00402     szHeaders - The response headers to send
00403     szFormat  - The string format
00404     ...       - Zero or more additional arguments
00405
00406 Returns:
00407
00408     TRUE on success, FALSE on failure
00409
00410 --*/
00411 {
00412     va_list args;
00413     BOOL    fResult;
00414
00415     //
00416     // Send the status and headers
00417     //
00418
00419     fResult = SyncSendStatusAndHeaders( szStatus,
00420                                         szHeaders );
00421
00422     if ( !fResult )
00423     {
00424         goto Failed;
00425     }
00426
00427     //
00428     // Send the entity
00429     //
00430
00431     va_start( args, szFormat );
00432
00433     fResult = SyncWriteClientArgs( szFormat,
00434                                    args );
00435
00436     va_end( args );
00437
00438     return fResult;
00439
00440 Failed:
00441
00442     //
00443     // No special cleanup required
00444     //
00445
00446     return FALSE;
00447 }
00448
00449 BOOL
00450 ISAPI_REQUEST::GetServerVariable(
00451     CHAR *          szVariable,
00452     ISAPI_STRING *  pIsapiString
00453     )
00454 /*++
00455
00456 Purpose:
00457
00458     Gets a server variable value.
00459
00460 Arguments:
00461
00462     szVariable   - The variable to get
00463     pIsapiString - ISAPI_STRING object to store the value on return
00464
00465 Returns:
00466
00467     TRUE on success, FALSE on failure
00468
00469 --*/
00470 {
00471     DWORD   cbData;
00472     BOOL    fResult;
00473
00474     //
00475     // If the caller is trying to get a Unicode value,
00476     // the this is the wrong function to call.  They
00477     // should pass an ISAPI_STRINGW instead of an
00478     // ISAPI_STRING to get the correct overloaded function.
00479     //
00480
00481     if ( strnicmp( szVariable,
00482                    "UNICODE_",
00483                    sizeof("UNICODE_") - 1 ) == 0 )
00484     {
00485         SetLastError( ERROR_INVALID_PARAMETER );
00486         goto Failed;
00487     }
00488
00489     //
00490     // Try and get the variable with the
00491     // buffer "as is".
00492     //
00493
00494     cbData = pIsapiString->QueryBufferSize();
00495
00496     fResult = _pEcb->GetServerVariable( _pEcb->ConnID,
00497                                         szVariable,
00498                                         pIsapiString->QueryStr(),
00499                                         &cbData );
00500
00501     if ( !fResult )
00502     {
00503         //
00504         // If the failure was not due to the size of the
00505         // buffer, then just fail.
00506         //
00507
00508         if ( GetLastError() != ERROR_INSUFFICIENT_BUFFER )
00509         {
00510             goto Failed;
00511         }
00512
00513         //
00514         // Resize the buffer and try again
00515         //
00516
00517         if ( !pIsapiString->ResizeBuffer( cbData ) )
00518         {
00519             goto Failed;
00520         }
00521
00522         fResult = _pEcb->GetServerVariable( _pEcb->ConnID,
00523                                             szVariable,
00524                                             pIsapiString->QueryStr(),
00525                                             &cbData );
00526     }
00527
00528     if ( fResult )
00529     {
00530         //
00531         // Adjust string size
00532         //
00533
00534         pIsapiString->SetLen( cbData - sizeof(CHAR) );
00535     }
00536
00537     return fResult;
00538
00539 Failed:
00540
00541     //
00542     // No special cleanup required
00543     //
00544
00545     return FALSE;
00546 }
00547
00548 BOOL
00549 ISAPI_REQUEST::GetServerVariable(
00550     CHAR *  szVariable,
00551     ISAPI_STRINGW * pIsapiStringW
00552     )
00553 /*++
00554
00555 Purpose:
00556
00557     Gets a Unicode server variable value.
00558
00559 Arguments:
00560
00561     szVariable    - The variable to get
00562     pIsapiStringW - ISAPI_STRINGW object to store the value on return
00563
00564 Returns:
00565
00566     TRUE on success, FALSE on failure
00567
00568 --*/
00569 {
00570     DWORD   cbData;
00571     BOOL    fResult;
00572
00573     //
00574     // If the caller is not trying to get a Unicode value,
00575     // the this is the wrong function to call.  They
00576     // should pass an ISAPI_STRING instead of an
00577     // ISAPI_STRINGW to get the correct overloaded function.
00578     //
00579
00580     if ( strnicmp( szVariable,
00581                    "UNICODE_",
00582                    sizeof("UNICODE_") - 1 ) != 0 )
00583     {
00584         SetLastError( ERROR_INVALID_PARAMETER );
00585         goto Failed;
00586     }
00587
00588     //
00589     // Try and get the variable with the
00590     // buffer "as is".
00591     //
00592
00593     cbData = pIsapiStringW->QueryBufferSize();
00594
00595     fResult = _pEcb->GetServerVariable( _pEcb->ConnID,
00596                                         szVariable,
00597                                         pIsapiStringW->QueryStr(),
00598                                         &cbData );
00599
00600     if ( !fResult )
00601     {
00602         //
00603         // If the failure was not due to the size of the
00604         // buffer, then just fail.
00605         //
00606
00607         if ( GetLastError() != ERROR_INSUFFICIENT_BUFFER )
00608         {
00609             goto Failed;
00610         }
00611
00612         //
00613         // Resize the buffer and try again
00614         //
00615
00616         if ( !pIsapiStringW->ResizeBuffer( cbData ) )
00617         {
00618             goto Failed;
00619         }
00620
00621         fResult = _pEcb->GetServerVariable( _pEcb->ConnID,
00622                                             szVariable,
00623                                             pIsapiStringW->QueryStr(),
00624                                             &cbData );
00625     }
00626
00627     if ( fResult )
00628     {
00629         //
00630         // Adjust string size
00631         //
00632
00633         pIsapiStringW->SetLen( cbData / sizeof(WCHAR) - 1 );
00634     }
00635
00636     return fResult;
00637
00638 Failed:
00639
00640     //
00641     // No special cleanup required
00642     //
00643
00644     return FALSE;
00645 }
00646
00647 BOOL
00648 ISAPI_REQUEST::ReadAllEntity(
00649     ISAPI_BUFFER *  pBuffer
00650     )
00651 /*++
00652
00653 Purpose:
00654
00655     Reads all request entity into the specified ISAPI_BUFFER.
00656
00657     Note that this function will fail if the max allocation
00658     size of the target ISAPI_BUFFER is less than the size of
00659     the request's entity data.
00660
00661 Arguments:
00662
00663     pBuffer - The ISAPI_BUFFER to store the result on return
00664
00665 Returns:
00666
00667     TRUE on success, FALSE on failure
00668
00669 --*/
00670 {
00671     ISAPI_STRING    TransferEncoding;
00672     BYTE            pInline[INLINE_READ_SIZE];
00673     BYTE *          pNewData;
00674     DWORD           cbRemaining;
00675     DWORD           cbReadThisTime;
00676     BOOL            fChunked = FALSE;
00677
00678     //
00679     // Is this a chunked request?
00680     //
00681
00682     if ( GetServerVariable( "HTTP_TRANSFER_ENCODING",
00683                             &TransferEncoding ) )
00684     {
00685         if ( stricmp( TransferEncoding.QueryStr(), "chunked" ) == 0 )
00686         {
00687             fChunked = TRUE;
00688         }
00689     }
00690
00691     //
00692     // If the request is not chunked, go ahead and resize
00693     // the buffer now, so that no new allocations will be
00694     // done while reading stuff in.
00695     //
00696
00697     if ( !fChunked && !pBuffer->Resize( _pEcb->cbTotalBytes ) )
00698     {
00699         return FALSE;
00700     }
00701
00702     //
00703     // Copy the already available bytes into the buffer
00704     //
00705
00706     if ( !pBuffer->SetData( _pEcb->lpbData, _pEcb->cbAvailable ) )
00707     {
00708         return FALSE;
00709     }
00710
00711     //
00712     // Loop on ReadClient until we've got all the data
00713     //
00714
00715     cbRemaining = _pEcb->cbTotalBytes - _pEcb->cbAvailable;
00716     pNewData = pInline;
00717
00718     while ( fChunked || cbRemaining )
00719     {
00720         //
00721         // If the request is not chunked, then read directly
00722         // into the buffer
00723         //
00724
00725         if ( !fChunked )
00726         {
00727             pNewData = (BYTE*)pBuffer->QueryPtr() +
00728                        _pEcb->cbTotalBytes -
00729                        cbRemaining;
00730         }
00731
00732         //
00733         // Read the data
00734         //
00735
00736         cbReadThisTime = cbRemaining;
00737
00738         if ( fChunked && cbRemaining > INLINE_READ_SIZE )
00739         {
00740             cbReadThisTime = INLINE_READ_SIZE;
00741         }
00742
00743         if ( !_pEcb->ReadClient( _pEcb->ConnID,
00744                                  pNewData,
00745                                  &cbReadThisTime ) )
00746         {
00747             //
00748             // Since the call failed, we should assume
00749             // that the client is no longer connected.
00750             //
00751
00752             _fClientIsConnected = FALSE;
00753
00754             return FALSE;
00755         }
00756
00757         //
00758         // If the request is not chunked, then we just need
00759         // to decrement the remaining byte count, else we
00760         // need to do some extra processing to handle the
00761         // chunk.
00762         //
00763
00764         if ( !fChunked )
00765         {
00766             cbRemaining -= cbReadThisTime;
00767         }
00768         else
00769         {
00770             //
00771             // If we successfully read zero bytes, then we
00772             // are done.
00773             //
00774
00775             if ( cbReadThisTime == 0 )
00776             {
00777                 return TRUE;
00778             }
00779
00780             //
00781             // We got some data.  Append it to the buffer.
00782             //
00783
00784             if ( !pBuffer->AppendData( pInline, cbReadThisTime ) )
00785             {
00786                 return FALSE;
00787             }
00788         }
00789     }
00790
00791     //
00792     // We need to update the buffer to reflect the data
00793     // placed there in the read loop.
00794     //
00795
00796     if ( !pBuffer->SetDataSize( _pEcb->cbTotalBytes ) )
00797     {
00798         return FALSE;
00799     }
00800
00801     //
00802     // Done.
00803     //
00804
00805     return TRUE;
00806 }
00807
00808 BOOL
00809 ISAPI_REQUEST::SetBufferedResponseStatus(
00810     CHAR *  szStatus
00811     )
00812 /*++
00813
00814 Purpose:
00815
00816     Sets the HTTP status code to be used in a buffered response
00817
00818 Arguments:
00819
00820     szStatus - The status (ie. "200 OK") to be sent with the response
00821
00822 Returns:
00823
00824     TRUE on success, FALSE on failure
00825
00826 --*/
00827 {
00828     return _StatusBuffer.Copy( szStatus );
00829 }
00830
00831 BOOL
00832 ISAPI_REQUEST::AddHeaderToBufferedResponse(
00833     CHAR *  szName,
00834     CHAR *  szValue
00835     )
00836 /*++
00837
00838 Purpose:
00839
00840     Adds a response header to be used in a buffered response
00841
00842 Arguments:
00843
00844     szName  - The name of the header to add
00845     szValie - The value of the header to add
00846
00847 Returns:
00848
00849     TRUE on success, FALSE on failure
00850
00851 --*/
00852 {
00853     ISAPI_STRING    CookedHeader;
00854     BOOL            fResult;
00855
00856     //
00857     // Build a cooked header in the form of
00858     // "name: value\r\n"
00859     //
00860
00861     fResult = CookedHeader.Printf( "%s: %s\r\n",
00862                                    szName,
00863                                    szValue );
00864
00865     if ( !fResult )
00866     {
00867         goto Failed;
00868     }
00869
00870     //
00871     // Append the cooked header into the buffer
00872     //
00873
00874     fResult = _HeaderBuffer.Append( CookedHeader.QueryStr() );
00875
00876     return fResult;
00877
00878 Failed:
00879
00880     //
00881     // No special cleanup required
00882     //
00883
00884     return FALSE;
00885 }
00886
00887 BOOL
00888 ISAPI_REQUEST::PrintfToResponseBuffer(
00889     CHAR *  szFormat,
00890     ...
00891     )
00892 /*++
00893
00894 Purpose:
00895
00896     Appends string data to the response buffer using printf-style
00897     formatting and a variable number of arguments.
00898
00899     Note that if this data causes the size of the buffer to exceed
00900     its max allocation, then this function will fail.
00901
00902 Arguments:
00903
00904     szFormat - The string format
00905     ...      - Zero or more additional arguments
00906
00907 Returns:
00908
00909     TRUE on success, FALSE on failure
00910
00911 --*/
00912 {
00913     ISAPI_STRING    CurrentChunk( _dwMaxSyncWriteSize );
00914     va_list         args;
00915     BOOL            fResult;
00916
00917     //
00918     // Build a formatted chunk to append to the response
00919     // buffer.  We'll use the max sync write size value
00920     // as the limit to the size that the formatted chunk
00921     // can be.
00922     //
00923
00924     va_start( args, szFormat );
00925
00926     fResult = CurrentChunk.Vsprintf( szFormat,
00927                                      args );
00928
00929     va_end( args );
00930
00931     if ( !fResult )
00932     {
00933         goto Failed;
00934     }
00935
00936     //
00937     // Append the chunk to the response buffer.
00938     //
00939
00940     fResult = _ResponseBuffer.AppendData( CurrentChunk.QueryStr(),
00941                                           CurrentChunk.QueryCCH() );
00942
00943     return fResult;
00944
00945 Failed:
00946
00947     //
00948     // No special cleanup required.
00949     //
00950
00951     return FALSE;
00952 }
00953
00954 BOOL
00955 ISAPI_REQUEST::AddDataToResponseBuffer(
00956     VOID *  pData,
00957     DWORD   cbData
00958     )
00959 /*++
00960
00961 Purpose:
00962
00963     Adds data to the response buffer.
00964
00965     Note that if this data causes the size of the buffer to exceed
00966     its max allocation, then this function will fail.
00967
00968 Arguments:
00969
00970     pData  - The data to append
00971     cbData - The size of the data to append
00972
00973 Returns:
00974
00975     TRUE on success, FALSE on failure
00976
00977 --*/
00978 {
00979     return _ResponseBuffer.AppendData( pData,
00980                                        cbData );
00981 }
00982
00983 BOOL
00984 ISAPI_REQUEST::AsyncTransmitBufferedResponse(
00985     PFN_HSE_IO_COMPLETION   pfnCompletion,
00986     DWORD                   dwExpireSeconds
00987     )
00988 /*++
00989
00990 Purpose:
00991
00992     Asynchronously sends the complete, buffered response
00993     to the client.
00994
00995     This function automatically calculates and adds an "Expires"
00996     header, based on the expiration specified by the caller. It
00997     also calculates and adds a content-length header, and
00998     keep-alive will be supported if the client requested it.
00999
01000     Note that various versions of IIS have different capabilities
01001     for sending asynchronous responses.  This function will
01002     check the IIS version and call a function to send the data
01003     in the most appropriate way.
01004
01005 Arguments:
01006
01007     pfnCompletion   - The function to call on completion of the send
01008     dwExpireSeconds - If NO_EXPIRATION, then no expiration header will
01009                       be added to the response.  If 0, then an
01010                       "Expires: 0" header will be added to the
01011                       response.  Otherwise a valid expiration time
01012                       will be calculated and added as an Expires
01013                       header.  On IIS 6, this will mark the request
01014                       as eligible for the http.sys response cache.
01015
01016 Returns:
01017
01018     TRUE on success, FALSE on failure
01019
01020 --*/
01021 {
01022     CHAR            szContentLength[32];
01023     ISAPI_STRING    strExpires;
01024     BOOL            fIIS6Cacheable = FALSE;
01025     BOOL            fResult;
01026
01027     //
01028     // If a status has not been set, use the default
01029     //
01030
01031     if ( _StatusBuffer.QueryCCH() == 0 )
01032     {
01033         fResult = _StatusBuffer.Copy( DEFAULT_STATUS );
01034
01035         if ( !fResult )
01036         {
01037             goto Failed;
01038         }
01039     }
01040
01041     //
01042     // Calculate the content-length and add the header.
01043     // This is required for keep-alive.
01044     //
01045
01046     itoa( _ResponseBuffer.QueryDataSize(),
01047           szContentLength,
01048           10 );
01049
01050     fResult = AddHeaderToBufferedResponse( "Content-Length",
01051                                            szContentLength );
01052
01053     if ( !fResult )
01054     {
01055         goto Failed;
01056     }
01057
01058     //
01059     // Add an expires header if specified
01060     //
01061
01062     if ( dwExpireSeconds != NO_EXPIRATION )
01063     {
01064         if ( dwExpireSeconds == IMMEDIATE_EXPIRATION )
01065         {
01066             fResult = strExpires.Copy( "0" );
01067         }
01068         else
01069         {
01070             FILETIME        ft;
01071
01072             if ( GetCurrentTimeAsFileTime( &ft ) == FALSE )
01073             {
01074                 goto Failed;
01075             }
01076
01077             //
01078             // Add the cache milliseconds.  Note that FILETIME
01079             // is a count of 100 nanosecond invervals, thus we
01080             // need to multiply by 10000000 to get seconds
01081             //
01082
01083             ((LARGE_INTEGER*)&ft)->QuadPart += dwExpireSeconds * 10000000;
01084
01085             fResult = GetFileTimeAsString( &ft, &strExpires );
01086
01087             //
01088             // On IIS 6, this response should be marked as
01089             // cacheable.
01090             //
01091
01092             fIIS6Cacheable = TRUE;
01093         }
01094
01095         if ( !fResult )
01096         {
01097             goto Failed;
01098         }
01099
01100         if ( AddHeaderToBufferedResponse( "Expires",
01101                                           strExpires.QueryStr() ) == FALSE )
01102         {
01103             goto Failed;
01104         }
01105     }
01106
01107     //
01108     // Terminate the header string
01109     //
01110
01111     fResult = _HeaderBuffer.Append( "\r\n" );
01112
01113     if ( !fResult )
01114     {
01115         goto Failed;
01116     }
01117
01118     //
01119     // Call the private member function appropriate to
01120     // the IIS version being used.
01121     //
01122
01123     if ( _dwIISMajorVersion <= 4 )
01124     {
01125         fResult = AsyncSendResponseIIS4( pfnCompletion );
01126     }
01127     else if ( _dwIISMajorVersion == 5 )
01128     {
01129         fResult = AsyncSendResponseIIS5( pfnCompletion );
01130     }
01131     else
01132     {
01133         fResult = AsyncSendResponseIIS6( pfnCompletion,
01134                                          fIIS6Cacheable );
01135     }
01136
01137     return fResult;
01138
01139
01140 Failed:
01141
01142     //
01143     // No special cleanup required
01144     //
01145
01146     return FALSE;
01147
01148 }
01149
01150 DWORD
01151 ISAPI_REQUEST::QueryMaxSyncWriteSize(
01152     VOID
01153     )
01154 /*++
01155
01156 Purpose:
01157
01158     Returns the maximum write size supported in a single call to
01159     one of the following member functions:
01160
01161       SyncWriteClientArgs
01162       SyncWriteClientString
01163       SyncWriteCompleteResponse
01164       PrintfToResponseBuffer
01165
01166 Arguments:
01167
01168     None
01169
01170 Returns:
01171
01172     The maximum write size
01173
01174 --*/
01175 {
01176     return _dwMaxSyncWriteSize;
01177 }
01178
01179 VOID
01180 ISAPI_REQUEST::SetMaxSyncWriteSize(
01181     DWORD   dwMaxSyncWriteSize
01182     )
01183 /*++
01184
01185 Purpose:
01186
01187     Sets the maximum write size supported in a single call to
01188     one of the following member functions:
01189
01190       SyncWriteClientArgs
01191       SyncWriteClientString
01192       SyncWriteCompleteResponse
01193       PrintfToResponseBuffer
01194
01195 Arguments:
01196
01197     The maximum write size
01198
01199 Returns:
01200
01201     None
01202
01203 --*/
01204 {
01205     _dwMaxSyncWriteSize = dwMaxSyncWriteSize;
01206 }
01207
01208 DWORD
01209 ISAPI_REQUEST::QueryMaxResponseBufferSize(
01210     VOID
01211     )
01212 /*++
01213
01214 Purpose:
01215
01216     Returns the maximum size of the response buffer
01217
01218 Arguments:
01219
01220     None
01221
01222 Returns:
01223
01224     The maximum response buffer size
01225
01226 --*/
01227 {
01228     return _ResponseBuffer.QueryMaxAlloc();
01229 }
01230
01231 VOID
01232 ISAPI_REQUEST::SetMaxResponseBufferSize(
01233     DWORD   dwMaxResponseBufferSize
01234     )
01235 /*++
01236
01237 Purpose:
01238
01239     Sets the maximum size of the response buffer
01240
01241 Arguments:
01242
01243     The maximum buffer size
01244
01245 Returns:
01246
01247     None
01248
01249 --*/
01250 {
01251     _ResponseBuffer.SetMaxAlloc( dwMaxResponseBufferSize );
01252 }
01253
01254 EXTENSION_CONTROL_BLOCK *
01255 ISAPI_REQUEST::QueryEcb(
01256     VOID
01257     )
01258 /*++
01259
01260 Purpose:
01261
01262     Returns the ECB associated with this ISAPI_REQUEST object
01263
01264 Arguments:
01265
01266     None
01267
01268 Returns:
01269
01270     The EXTENSION_CONTROL_BLOCK
01271
01272 --*/
01273 {
01274     return _pEcb;
01275 }
01276
01277 DWORD
01278 ISAPI_REQUEST::QueryIISMajorVersion(
01279     VOID
01280     )
01281 /*++
01282
01283 Purpose:
01284
01285     Returns the IIS major version
01286
01287 Arguments:
01288
01289     None
01290
01291 Returns:
01292
01293     The IIS major version
01294
01295 --*/
01296 {
01297     return _dwIISMajorVersion;
01298 }
01299
01300 DWORD
01301 ISAPI_REQUEST::QueryIISMinorVersion(
01302     VOID
01303     )
01304 /*++
01305
01306 Purpose:
01307
01308     Returns the IIS minor version
01309
01310 Arguments:
01311
01312     None
01313
01314 Returns:
01315
01316     The IIS minor version
01317
01318 --*/
01319 {
01320     return _dwIISMinorVersion;
01321 }
01322
01323 BOOL
01324 ISAPI_REQUEST::QueryIsClientConnected(
01325     VOID
01326     )
01327 /*++
01328
01329 Purpose:
01330
01331     Determines if the client is still connected
01332
01333 Arguments:
01334
01335     None
01336
01337 Returns:
01338
01339     TRUE if the client is connected, FALSE if not.
01340
01341 --*/
01342 {
01343     //
01344     // Check to see if the client is connected
01345     //
01346     // Note that this call is somewhat expensive in the
01347     // OOP case, since an RPC call must occur between the
01348     // dllhost and inetinfo processes.  It should be used
01349     // sparingly.
01350     //
01351     // In the spirit of this, we will only make the call
01352     // if we believe that the client is still connected.
01353     //
01354
01355     if ( _fClientIsConnected == TRUE )
01356     {
01357         if ( _pEcb->ServerSupportFunction( _pEcb->ConnID,
01358                                            HSE_REQ_IS_CONNECTED,
01359                                            &_fClientIsConnected,
01360                                            NULL,
01361                                            NULL ) == FALSE )
01362         {
01363             //
01364             // If the call fails, we should assume that the
01365             // client is really still connected.
01366             //
01367
01368             _fClientIsConnected = TRUE;
01369         }
01370     }
01371
01372     //
01373     // If the client has been disconnected, set the last
01374     // error to WSAECONNRESET, as this is generally the
01375     // error that will result if an extension attempts to
01376     // do IO with a client that has disconnected.
01377     //
01378
01379     if ( !_fClientIsConnected )
01380     {
01381         SetLastError( WSAECONNRESET );
01382     }
01383
01384     return _fClientIsConnected;
01385 }
01386
01387 BOOL
01388 ISAPI_REQUEST::UnimpersonateClient(
01389     VOID
01390     )
01391 /*++
01392
01393 Purpose:
01394
01395     Removes an impersonation token from the calling
01396     thread.  On the first call per object, the authenticated
01397     client token will be cached so that it can be easily
01398     reapplied by ImpersonateClient.
01399
01400 Arguments:
01401
01402     None
01403
01404 Returns:
01405
01406     TRUE on success, FALSE on failure
01407
01408 --*/
01409 {
01410     BOOL    fResult = TRUE;
01411
01412     //
01413     // If we haven't already got the client's impersonation
01414     // token, then we need to get it now.
01415     //
01416
01417     if ( _hImpersonationToken == NULL )
01418     {
01419         fResult = _pEcb->ServerSupportFunction( _pEcb->ConnID,
01420                                                 HSE_REQ_GET_IMPERSONATION_TOKEN,
01421                                                 &_hImpersonationToken,
01422                                                 NULL,
01423                                                 NULL );
01424
01425         if ( !fResult )
01426         {
01427             goto Failed;
01428         }
01429     }
01430
01431     return RevertToSelf();
01432
01433 Failed:
01434
01435     return FALSE;
01436 }
01437
01438 BOOL
01439 ISAPI_REQUEST::ImpersonateClient(
01440     VOID
01441     )
01442 /*++
01443
01444 Purpose:
01445
01446     Sets an impersonation token for the authenticated client
01447     on the calling thread.  If the token has been previously
01448     cached, use it.  Otherwise, get the correct token from ISAPI.
01449
01450 Arguments:
01451
01452     None
01453
01454 Returns:
01455
01456     TRUE on success, FALSE on failure
01457
01458 --*/
01459 {
01460     BOOL    fResult;
01461
01462     if ( _hImpersonationToken == NULL )
01463     {
01464         //
01465         // Get the token from the ISAPI
01466         //
01467
01468         fResult = _pEcb->ServerSupportFunction( _pEcb->ConnID,
01469                                                 HSE_REQ_GET_IMPERSONATION_TOKEN,
01470                                                 &_hImpersonationToken,
01471                                                 NULL,
01472                                                 NULL );
01473
01474         if ( !fResult )
01475         {
01476             goto Failed;
01477         }
01478     }
01479
01480     return SetThreadToken( NULL, _hImpersonationToken );
01481
01482 Failed:
01483
01484     return FALSE;
01485 }
01486
01487
01488 BOOL
01489 ISAPI_REQUEST::AsyncSendResponseIIS4(
01490     PFN_HSE_IO_COMPLETION   pfnCompletion
01491     )
01492 /*++
01493
01494 Purpose:
01495
01496     Asynchronously sends the buffered response using calls
01497     that will work on IIS 4.
01498
01499 Arguments:
01500
01501     pfnCompletion - The function to call on completion of the I/O
01502
01503 Returns:
01504
01505     TRUE on success, FALSE on failure
01506
01507 --*/
01508 {
01509     DWORD   cbResponse;
01510     BOOL    fResult;
01511
01512     //
01513     // Before doing an asynchronous write, we need to set
01514     // the completion routine.  We'll use a this pointer
01515     // as the completion context.
01516     //
01517
01518     fResult = _pEcb->ServerSupportFunction( _pEcb->ConnID,
01519                                             HSE_REQ_IO_COMPLETION,
01520                                             pfnCompletion,
01521                                             NULL,
01522                                             (DWORD*)this );
01523
01524     if ( !fResult )
01525     {
01526         goto Failed;
01527     }
01528
01529     //
01530     // There is no mechanism in IIS 4 and earlier to send
01531     // status and headers asynchronously, unless you are using
01532     // TRANSMIT_FILE with a valid file handle.  As a result,
01533     // we need to synchronously send the status and headers.
01534     //
01535
01536     fResult = SyncSendStatusAndHeaders( _StatusBuffer.QueryStr(),
01537                                         _HeaderBuffer.QueryStr() );
01538
01539     if ( !fResult )
01540     {
01541         goto Failed;
01542     }
01543
01544     //
01545     // Now, we can send the entity body asynchronously
01546     //
01547     // We'll need to properly set the state of this
01548     // object so that the destructor knows to do
01549     // DONE_WITH_SESSION.
01550     //
01551
01552     cbResponse = _ResponseBuffer.QueryDataSize();
01553
01554     _fNeedDoneWithSession = TRUE;
01555
01556     fResult = _pEcb->WriteClient( _pEcb->ConnID,
01557                                   _ResponseBuffer.QueryPtr(),
01558                                   &cbResponse,
01559                                   HSE_IO_ASYNC | HSE_IO_NODELAY );
01560
01561     if ( !fResult )
01562     {
01563         //
01564         // Reset the state so that this object knows not
01565         // to do DONE_WITH_SESSION in the destructor
01566         //
01567
01568         _fNeedDoneWithSession = FALSE;
01569
01570         goto Failed;
01571     }
01572
01573     return TRUE;
01574
01575 Failed:
01576
01577     //
01578     // No special cleanup required
01579     //
01580
01581     return FALSE;
01582 }
01583
01584 BOOL
01585 ISAPI_REQUEST::AsyncSendResponseIIS5(
01586     PFN_HSE_IO_COMPLETION   pfnCompletion
01587     )
01588 /*++
01589
01590 Purpose:
01591
01592     Asynchronously sends the buffered response using calls
01593     that will work on IIS 5.
01594
01595 Arguments:
01596
01597     pfnCompletion - The function to call on completion of the I/O
01598
01599 Returns:
01600
01601     TRUE on success, FALSE on failure
01602
01603 --*/
01604 {
01605     HSE_TF_INFO TfInfo;
01606     BOOL        fResult;
01607
01608     TfInfo.pfnHseIO = pfnCompletion;
01609     TfInfo.pszStatusCode = _StatusBuffer.QueryStr();
01610
01611     //
01612     // We'll send the buffered response headers in the
01613     // pHead member.
01614     //
01615
01616     TfInfo.pHead = _HeaderBuffer.QueryStr();
01617     TfInfo.HeadLength = _HeaderBuffer.QueryCCH() + sizeof(CHAR);
01618
01619     //
01620     // Since we're not sending a file, we'll use a NULL
01621     // file handle and set the offset and length to zero
01622     //
01623
01624     TfInfo.hFile = NULL;
01625     TfInfo.Offset = 0;
01626     TfInfo.BytesToWrite = 0;
01627
01628     //
01629     // We'll send the buffered response entity in the tail
01630     //
01631
01632     TfInfo.pTail = _ResponseBuffer.QueryPtr();
01633     TfInfo.TailLength = _ResponseBuffer.QueryDataSize();
01634
01635     //
01636     // Pass a pointer to this object as the context.
01637     //
01638     // Note that it is very important that this object
01639     // was allocated via "new" and not declared as an
01640     // object on HttpExtensionProc's stack.  If it was
01641     // declared on the stack, intermittent failures may
01642     // result, depending on whether HttpExtensionProc
01643     // returns before or after the completion.
01644     //
01645
01646     TfInfo.pContext = this;
01647
01648     //
01649     // Set the following flags:
01650     //
01651     // HSE_IO_ASYNC        - Always required for TRANSMIT_FILE
01652     // HSE_IO_SEND_HEADERS - Have TRANSMIT_FILE send the response headers
01653     // HSE_IO_NODELAY      - Dont nagle (IIS 5 only. This no-ops on IIS 6)
01654     //
01655
01656     TfInfo.dwFlags = HSE_IO_ASYNC | HSE_IO_SEND_HEADERS | HSE_IO_NODELAY;
01657
01658     //
01659     // Transmit the data
01660     //
01661     // Note that there is some state housekeeping that we need to do
01662     // here.  After HttpExtensionProc calls this function, it will
01663     // need to return HSE_STATUS_PENDING.  Cleanup of the request,
01664     // including this object, will then be done in the completion
01665     // routine, which will generally just delete this object. The
01666     // destructor for this object will call HSE_REQ_DONE_WITH_SESSION
01667     // if the below flag is so set.
01668     //
01669     // It is important to consider that the completion routine
01670     // might get called before any code following ServerSupportFunction
01671     // has a chance to run.  If this happens, the _fNeedDoneWithSession
01672     // flag needs to be already set for the destructor to work
01673     // properly.  Also, any attempts to touch members of this object
01674     // will result in an access violation.  Such failures may be
01675     // difficult to debug.
01676     //
01677
01678     _fNeedDoneWithSession = TRUE;
01679
01680     fResult = _pEcb->ServerSupportFunction( _pEcb->ConnID,
01681                                             HSE_REQ_TRANSMIT_FILE,
01682                                             &TfInfo,
01683                                             NULL,
01684                                             NULL );
01685
01686     if ( !fResult )
01687     {
01688         //
01689         // Since the ServerSupportFunction failed, we know that no
01690         // completion will occur.  It is therefore safe for us to
01691         // touch members of this object.
01692         //
01693         // We will do so now, to reset the below flag back to the
01694         // state where HSE_REQ_DONE_WITH_SESSION is not called by
01695         // the destructor.
01696         //
01697
01698         _fNeedDoneWithSession = FALSE;
01699     }
01700
01701     return fResult;
01702 }
01703
01704 BOOL
01705 ISAPI_REQUEST::AsyncSendResponseIIS6(
01706     PFN_HSE_IO_COMPLETION   pfnCompletion,
01707     BOOL                    fCacheResponse
01708     )
01709 /*++
01710
01711 Purpose:
01712
01713     Asynchronously sends the buffered response using calls
01714     that will work on IIS 6
01715
01716 Arguments:
01717
01718     pfnCompletion  - The function to call on completion of the I/O
01719     fCacheResponse - If TRUE, then the response will be marked as
01720                      cacheable in the http.sys response cache.  Note
01721                      that this is just a "suggestion" to http.sys.
01722                      If something about the request disqualifies it
01723                      for caching, then http.sys is not required to
01724                      add this response to the cache.
01725
01726 Returns:
01727
01728     TRUE on success, FALSE on failure
01729
01730 --*/
01731 {
01732     HSE_VECTOR_ELEMENT  Element;
01733     HSE_RESPONSE_VECTOR Vector;
01734     BOOL                fResult;
01735
01736     //
01737     // Declare a single element containing the contents
01738     // of the response buffer.
01739     //
01740
01741     Element.ElementType = HSE_VECTOR_ELEMENT_TYPE_MEMORY_BUFFER;
01742     Element.pvContext = _ResponseBuffer.QueryPtr();
01743     Element.cbOffset = 0;
01744     Element.cbSize = _ResponseBuffer.QueryDataSize();
01745
01746     //
01747     // Declare our response vector containing a single
01748     // element in the array, and using the ISAPI_REQUEST's
01749     // status and headers.
01750     //
01751     // We will set the following IO flags for all calls:
01752     //
01753     //   HSE_IO_ASYNC        - Do an asynchronous send
01754     //   HSE_IO_FINAL_SEND   - Optimization, since we know
01755     //                         that this send is the complete
01756     //                         response (note that this is
01757     //                         required to be able to cache
01758     //                         the response in http.sys)
01759     //   HSE_IO_SEND_HEADERS - Specifies that we are sending
01760     //                         response headers in this call
01761     //
01762
01763     Vector.dwFlags = HSE_IO_ASYNC | HSE_IO_FINAL_SEND | HSE_IO_SEND_HEADERS;
01764
01765     //
01766     // If the response is cacheable, then we should add
01767     // HSE_IO_CACHE_RESPONSE
01768     //
01769
01770     if ( fCacheResponse )
01771     {
01772         Vector.dwFlags |= HSE_IO_CACHE_RESPONSE;
01773     }
01774
01775     //
01776     // Set the status and headers
01777     //
01778
01779     Vector.pszStatus = _StatusBuffer.QueryStr();
01780     Vector.pszHeaders = _HeaderBuffer.QueryStr();
01781
01782     //
01783     // Finally, we have a single element array.  Note
01784     // that the elements of this array need to stay valid
01785     // until the completion occurs.  This will be taken
01786     // care of automatically by the ISAPI_REQUEST object,
01787     // since it doesn't free the response buffer until
01788     // the completion.
01789     //
01790
01791     Vector.nElementCount = 1;
01792     Vector.lpElementArray = &Element;
01793
01794     //
01795     // Before doing an asynchronous vector send, we need to set
01796     // the completion routine.  We'll use a this pointer
01797     // as the completion context.
01798     //
01799
01800     fResult = _pEcb->ServerSupportFunction( _pEcb->ConnID,
01801                                             HSE_REQ_IO_COMPLETION,
01802                                             pfnCompletion,
01803                                             NULL,
01804                                             (DWORD*)this );
01805
01806     if ( !fResult )
01807     {
01808         goto Failed;
01809     }
01810
01811     //
01812     // Send the data
01813     //
01814     // Note that there is some state housekeeping that we need to do
01815     // here.  After HttpExtensionProc calls this function, it will
01816     // need to return HSE_STATUS_PENDING.  Cleanup of the request,
01817     // including this object, will then be done in the completion
01818     // routine, which will generally just delete this object. The
01819     // destructor for this object will call HSE_REQ_DONE_WITH_SESSION
01820     // if the below flag is so set.
01821     //
01822     // It is important to consider that the completion routine
01823     // might get called before any code following ServerSupportFunction
01824     // has a chance to run.  If this happens, the _fNeedDoneWithSession
01825     // flag needs to be already set for the destructor to work
01826     // properly.  Also, any attempts to touch members of this object
01827     // will result in an access violation.  Such failures may be
01828     // difficult to debug.
01829     //
01830
01831     _fNeedDoneWithSession = TRUE;
01832
01833     fResult = _pEcb->ServerSupportFunction( _pEcb->ConnID,
01834                                             HSE_REQ_VECTOR_SEND,
01835                                             &Vector,
01836                                             NULL,
01837                                             NULL );
01838
01839     if ( !fResult )
01840     {
01841         //
01842         // Since the ServerSupportFunction failed, we know that no
01843         // completion will occur.  It is therefore safe for us to
01844         // touch members of this object.
01845         //
01846         // We will do so now, to reset the below flag back to the
01847         // state where HSE_REQ_DONE_WITH_SESSION is not called by
01848         // the destructor.
01849         //
01850
01851         _fNeedDoneWithSession = FALSE;
01852     }
01853
01854     return fResult;
01855
01856 Failed:
01857
01858     //
01859     // No special cleanup required
01860     //
01861
01862     return FALSE;
01863 }
01864
01865 DWORD
01866 ISAPI_REQUEST::QueryOsMajorVersion(
01867     VOID
01868     )
01869 /*++
01870
01871 Purpose:
01872
01873     Returns the major version of the OS.
01874
01875     Since this requires a system call, the result will be
01876     stored in a static member of this function so that we
01877     only need to do it once for all ISAPI_REQUEST instances.
01878
01879 Arguments:
01880
01881     None
01882
01883 Returns:
01884
01885     The OS major version
01886
01887 --*/
01888 {
01889     OSVERSIONINFO   OsVersionInfo;
01890     BOOL            fResult;
01891
01892     //
01893     // If we've already determined the major version,
01894     // use the data already acquired.
01895     //
01896     // Note that _dwOsMajorVersion is static, so we don't
01897     // do the below system call for every instance of this
01898     // object.
01899     //
01900
01901     if ( _dwOsMajorVersion != 0 )
01902     {
01903         goto Done;
01904     }
01905
01906     //
01907     // Otherwise, get it
01908     //
01909
01910     fResult = GetVersionEx( &OsVersionInfo );
01911
01912     if ( !fResult )
01913     {
01914         //
01915         // Hmmm.  Better to assume 4, I guess.
01916         //
01917
01918         _dwOsMajorVersion = 4;
01919
01920         goto Done;
01921     }
01922
01923     _dwOsMajorVersion = OsVersionInfo.dwMajorVersion;
01924
01925 Done:
01926
01927     return _dwOsMajorVersion;
01928 }
01929
01930 DWORD
01931 SyncSendGenericServerError(
01932     EXTENSION_CONTROL_BLOCK *   pecb
01933     )
01934 /*++
01935
01936 Purpose:
01937
01938     Synchronously sends a generic "500 Server Error" response
01939
01940 Arguments:
01941
01942     pecb - The EXTENSION_CONTROL_BLOCK of this request
01943
01944 Returns:
01945
01946     HSE_STATUS_ERROR
01947
01948 --*/
01949 {
01950     ISAPI_REQUEST   Request( pecb );
01951
01952     Request.SyncWriteCompleteResponse( "500 Server Error",
01953                                        "Content-Type: text/html\r\n\r\n",
01954                                        SERVER_ERROR );
01955
01956     return HSE_STATUS_ERROR;
01957 }
01958
01959
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/dataobj.h Source File

  • SysMgmt
  • MMC
  • About

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/msdfhdl.idl Source File

  • Dataaccess
  • rds
  • handler
  • vc

msdfhdl.idl

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:    msdfhdl.idl
00004 //
00005 // Copyright: Copyright (c) 1991-1999 Microsoft Corporation
00006 //
00007 // Contents:
00008 //
00009 // Comments:
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 [
00014   uuid(D80DE8B3-0001-11d1-91E6-00C04FBBBFB3),
00015   version(1.0)
00016 ]
00017 library MSDFHDL
00018 {
00019     importlib("stdole32.tlb");
00020 #ifdef WIN32
00021     importlib("stdole2.tlb");
00022 #else
00023     importlib("stdole.tlb");
00024 #endif
00025
00026     // *********** MSADO15.DLL must be registered on your machine ***********
00027     // TLib : Microsoft ActiveX Data Objects 2.1 Library
00028     // {00000200-0000-0010-8000-00AA006D2EA4}
00029     // To build MSDFMAP_VC you must have the ADO dll at the location specified below:
00030     importlib("C:\Program Files\Common Files\System\ado\msado15.dll");
00031
00032     [
00033       odl,
00034       uuid(D80DE8B5-0001-11d1-91E6-00C04FBBBFB3),
00035       version(1.0)
00036     ]
00037     interface IDataFactoryHandler : IUnknown
00038   {
00039     // The Recordset returned from GetRecordset:
00040     //    must be created with CursorLocation = AdUseClientBatch,
00041     //    and adRunAsync must NOT be used! (use adUnknown or 8 in rs.Open)
00042     HRESULT _stdcall GetRecordset(
00043       [in] BSTR conn,
00044       [in] BSTR args,
00045       [in] BSTR query,
00046       [out, retval] _Recordset **ppRS);
00047
00048     // DataFactory will use the ActiveConnection property
00049     // on the recordset after calling Reconnect.
00050     HRESULT _stdcall Reconnect(
00051       [in] BSTR conn,
00052       [in] BSTR args,
00053       [in] _Recordset *pRS);
00054
00055     // New method for MDAC 2.1
00056     HRESULT _stdcall OpenConnection(
00057       [in] BSTR conn,
00058       [in] BSTR args,
00059       [in] long lFlags,  // 1=WriteAccess, 2=ModifyQuery
00060       [in, out] BSTR * pQuery,
00061       [out, retval] _Connection **ppConnection);
00062     };
00063 };
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/rtcsample/rtcwin.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • rtcsample

rtcwin.cpp

Go to the documentation of this file.
00001 // rtcwin.h
00002 //
00003
00004 #include "stdafx.h"
00005
00006 /////////////////////////////////////////////
00007 //
00008 // CRTCWin::CRTCWin
00009 //
00010
00011 CRTCWin::CRTCWin()
00012 {
00013     m_hWnd = NULL;
00014     m_hStatusBar = NULL;
00015     m_hBuddyList = NULL;
00016     m_pClient = NULL;
00017     m_pProfile = NULL;
00018     m_pEvents = NULL;
00019     m_enState = RTCRS_NOT_REGISTERED;
00020     m_fPresenceEnabled = FALSE;
00021 }
00022
00023 /////////////////////////////////////////////
00024 //
00025 // CRTCWin::~CRTCWin
00026 //
00027
00028 CRTCWin::~CRTCWin()
00029 {
00030 }
00031
00032 /////////////////////////////////////////////
00033 //
00034 // CRTCWin::RegisterClass
00035 //
00036
00037 HRESULT CRTCWin::RegisterClass()
00038 {
00039     // Register the window class
00040     WNDCLASS wc;
00041     ATOM atom;
00042
00043     ZeroMemory(&wc, sizeof(WNDCLASS));
00044
00045     wc.style         = CS_HREDRAW | CS_VREDRAW;
00046     wc.lpfnWndProc   = (WNDPROC)CRTCWin::WindowProc;
00047     wc.hInstance     = GetModuleHandle(NULL);
00048     wc.hIcon         = NULL;
00049     wc.hCursor       =
00050         LoadCursor(NULL, IDC_ARROW);
00051     wc.hbrBackground =
00052         GetSysColorBrush(COLOR_3DFACE);
00053     wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU_APP);
00054     wc.lpszClassName = APP_CLASS;
00055
00056     atom = ::RegisterClass( &wc );
00057
00058     if ( !atom )
00059     {
00060         // RegisterClass failed
00061         return E_FAIL;
00062     }
00063
00064     return S_OK;
00065 }
00066
00067 /////////////////////////////////////////////
00068 //
00069 // CRTCWin::AddSession
00070 //
00071
00072 HRESULT CRTCWin::AddSession(IRTCSession * pSession, RTC_SESSION_TYPE enType)
00073 {
00074     // Is this an audio/video session?
00075     BOOL fAVSession = (enType != RTCST_IM);
00076
00077     // Create the session window
00078     HWND hWnd;
00079
00080     hWnd = CreateWindowExW(
00081                 0,
00082                 (fAVSession) ? AV_CLASS : IM_CLASS,
00083                 (fAVSession) ? AV_TITLE : IM_TITLE,
00084                 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
00085                 CW_USEDEFAULT, CW_USEDEFAULT,
00086                 (fAVSession) ? AV_WIDTH : IM_WIDTH,
00087                 (fAVSession) ? AV_HEIGHT : IM_HEIGHT,
00088                 NULL,
00089                 NULL,
00090                 GetModuleHandle(NULL),
00091                 NULL);
00092
00093     if ( !hWnd )
00094     {
00095         // CreateWindowExW failed
00096         return E_FAIL;
00097     }
00098
00099     // Initialize the window
00100     CRTCSession * pSessWindow =
00101         (CRTCSession *)GetWindowLong(hWnd, GWL_USERDATA);
00102
00103     pSessWindow->m_pSession = pSession;
00104     pSessWindow->m_pSession->AddRef();
00105     pSessWindow->m_pWin = this;
00106
00107     // Make the main window visible
00108     ShowWindow( hWnd, SW_SHOW );
00109     UpdateWindow( hWnd );
00110
00111     // Add window to the list
00112     m_SessionList.push_back(pSessWindow);
00113
00114     return S_OK;
00115 }
00116
00117 /////////////////////////////////////////////
00118 //
00119 // CRTCWin::RemoveSession
00120 //
00121
00122 HRESULT CRTCWin::RemoveSession(CRTCSession * pSessWindow)
00123 {
00124     std::vector<CRTCSession *>::iterator it;
00125
00126     if (!m_SessionList.empty())
00127     {
00128         // Find the window
00129         for(it=m_SessionList.begin();
00130             it < m_SessionList.end();
00131             it++)
00132         {
00133             if (*it == pSessWindow)
00134             {
00135                 // Remove the window
00136                 m_SessionList.erase(it);
00137                 break;
00138             }
00139         }
00140     }
00141
00142     return S_OK;
00143 }
00144
00145 /////////////////////////////////////////////
00146 //
00147 // CRTCWin::FindSession
00148 //
00149
00150 HRESULT CRTCWin::FindSession(IRTCSession * pSession,
00151                     CRTCSession ** ppSessWindow)
00152 {
00153     std::vector<CRTCSession *>::iterator it;
00154
00155     if (!m_SessionList.empty())
00156     {
00157         for(it=m_SessionList.begin();
00158             it < m_SessionList.end();
00159             it++)
00160         {
00161             if ((*it)->m_pSession == pSession)
00162             {
00163                 *ppSessWindow = (*it);
00164                 return S_OK;
00165             }
00166         }
00167     }
00168
00169     *ppSessWindow = NULL;
00170     return E_FAIL;
00171 }
00172
00173 /////////////////////////////////////////////
00174 //
00175 // CRTCWin::CleanupSessions
00176 //
00177
00178 HRESULT CRTCWin::CleanupSessions()
00179 {
00180     std::vector<CRTCSession *>::iterator it;
00181
00182     if (!m_SessionList.empty())
00183     {
00184         for(it=m_SessionList.begin();
00185             it < m_SessionList.end();
00186             it++)
00187         {
00188             PostMessage((*it)->m_hWnd, WM_CLOSE, 0, 0);
00189         }
00190     }
00191
00192     return S_OK;
00193 }
00194
00195 /////////////////////////////////////////////
00196 //
00197 // CRTCWin::ShowMessageBox
00198 //
00199
00200 void CRTCWin::ShowMessageBox(PWSTR szText)
00201 {
00202     MessageBoxW(m_hWnd, szText, APP_TITLE, MB_OK);
00203 }
00204
00205 /////////////////////////////////////////////
00206 //
00207 // CRTCWin::SetStatusText
00208 //
00209
00210 void CRTCWin::SetStatusText(PWSTR szText)
00211 {
00212     SetWindowTextW(m_hStatusBar, szText);
00213     InvalidateRect(m_hStatusBar, NULL, FALSE);
00214 }
00215
00216 /////////////////////////////////////////////
00217 //
00218 // CRTCWin::GetUserURI
00219 //
00220
00221 HRESULT CRTCWin::GetUserURI(BSTR *pbstrURI)
00222 {
00223     HRESULT hr;
00224
00225     if (m_pProfile != NULL)
00226     {
00227         // Get the user URI from the profile
00228         hr = m_pProfile->get_UserURI(pbstrURI);
00229
00230         if (FAILED(hr))
00231         {
00232             // get_UserURI failed
00233             return hr;
00234         }
00235     }
00236     else
00237     {
00238         // Get the user URI from the client
00239         hr = m_pClient->get_LocalUserURI(pbstrURI);
00240
00241         if (FAILED(hr))
00242         {
00243             // get_LocalUserURI failed
00244             return hr;
00245         }
00246     }
00247
00248     return S_OK;
00249 }
00250
00251 /////////////////////////////////////////////
00252 //
00253 // CRTCWin::UpdateBuddyList
00254 //
00255
00256 HRESULT CRTCWin::UpdateBuddyList(IRTCBuddy * pBuddy)
00257 {
00258     HRESULT hr;
00259
00260     // Get the buddy status
00261     RTC_PRESENCE_STATUS enStatus;
00262
00263     hr = pBuddy->get_Status(&enStatus);
00264
00265     if (FAILED(hr))
00266     {
00267         // get_Status failed
00268         return hr;
00269     }
00270
00271     // Get the buddy name
00272     BSTR bstrName = NULL;
00273
00274     hr = pBuddy->get_Name(&bstrName);
00275
00276     if (SUCCEEDED(hr) && !wcscmp(bstrName, L""))
00277     {
00278         // Treat an emptry string as a failure
00279         SAFE_FREE_STRING(bstrName);
00280         hr = E_FAIL;
00281     }
00282
00283     if (FAILED(hr))
00284     {
00285         // get_Name failed, get the URI instead
00286         hr = pBuddy->get_PresentityURI(&bstrName);
00287
00288         if (SUCCEEDED(hr) && !wcscmp(bstrName, L""))
00289         {
00290             // Treat an emptry string as a failure
00291             SAFE_FREE_STRING(bstrName);
00292             hr = E_FAIL;
00293         }
00294
00295         if (FAILED(hr))
00296         {
00297             // get_PresentityURI failed
00298             return hr;
00299         }
00300     }
00301
00302     // Build a string for the listbox
00303     WCHAR szBuddy[MAX_STRING];
00304
00305     switch(enStatus)
00306     {
00307     case RTCXS_PRESENCE_OFFLINE:
00308         _snwprintf(szBuddy, MAX_STRING, L"%ws (Offline)", bstrName);
00309         break;
00310     case RTCXS_PRESENCE_ONLINE:
00311         _snwprintf(szBuddy, MAX_STRING, L"%ws (Online)", bstrName);
00312         break;
00313     case RTCXS_PRESENCE_AWAY:
00314         _snwprintf(szBuddy, MAX_STRING, L"%ws (Away)", bstrName);
00315         break;
00316     case RTCXS_PRESENCE_IDLE:
00317         _snwprintf(szBuddy, MAX_STRING, L"%ws (Idle)", bstrName);
00318         break;
00319     case RTCXS_PRESENCE_BUSY:
00320         _snwprintf(szBuddy, MAX_STRING, L"%ws (Busy)", bstrName);
00321         break;
00322     case RTCXS_PRESENCE_BE_RIGHT_BACK:
00323         _snwprintf(szBuddy, MAX_STRING, L"%ws (Be right back)", bstrName);
00324         break;
00325     case RTCXS_PRESENCE_ON_THE_PHONE:
00326         _snwprintf(szBuddy, MAX_STRING, L"%ws (On the phone)", bstrName);
00327         break;
00328     case RTCXS_PRESENCE_OUT_TO_LUNCH:
00329         _snwprintf(szBuddy, MAX_STRING, L"%ws (Out to lunch)", bstrName);
00330         break;
00331     default:
00332         _snwprintf(szBuddy, MAX_STRING, L"%ws", bstrName);
00333         break;
00334     }
00335
00336     szBuddy[MAX_STRING-1] = L'\0';
00337
00338     SAFE_FREE_STRING(bstrName);
00339
00340     // Is the buddy in the list?
00341     LVFINDINFO lvfi;
00342     ZeroMemory(&lvfi, sizeof(LVFINDINFO));
00343
00344     lvfi.flags = LVFI_PARAM;
00345     lvfi.lParam = (LPARAM)pBuddy;
00346
00347     int iRes = ListView_FindItem(m_hBuddyList, -1, &lvfi);
00348
00349     if (iRes == -1)
00350     {
00351         // Buddy is not in the list
00352         // Add the buddy to the list
00353         LVITEM lvi;
00354         ZeroMemory(&lvi, sizeof(LVITEM));
00355
00356         lvi.mask = LVIF_TEXT | LVIF_PARAM;
00357         lvi.pszText = szBuddy;
00358         lvi.lParam = (LPARAM)pBuddy;
00359
00360         iRes = ListView_InsertItem(m_hBuddyList, &lvi);
00361
00362         if (iRes == -1)
00363         {
00364             // ListView_InsertItem failed
00365             return E_FAIL;
00366         }
00367
00368         // An RTC buddy reference will be kept by the list
00369         // Add the reference here
00370         pBuddy->AddRef();
00371     }
00372     else
00373     {
00374         // Buddy is in the list
00375         // Update the list entry
00376         LVITEM lvi;
00377         ZeroMemory(&lvi, sizeof(LVITEM));
00378
00379         lvi.mask = LVIF_TEXT;
00380         lvi.pszText = szBuddy;
00381         lvi.iItem = iRes;
00382
00383         iRes = ListView_SetItem(m_hBuddyList, &lvi);
00384
00385         if (iRes == -1)
00386         {
00387             // ListView_SetItem failed
00388             return E_FAIL;
00389         }
00390     }
00391
00392     return S_OK;
00393 }
00394
00395 /////////////////////////////////////////////
00396 //
00397 // CRTCWin::ClearBuddyList
00398 //
00399
00400 HRESULT CRTCWin::ClearBuddyList()
00401 {
00402     LVITEM lvi;
00403     ZeroMemory(&lvi, sizeof(LVITEM));
00404
00405     lvi.mask = LVIF_PARAM;
00406
00407     // Iterate through the list and remove each item
00408     while (ListView_GetItem(m_hBuddyList, &lvi))
00409     {
00410         IRTCBuddy * pBuddy = (IRTCBuddy *)(lvi.lParam);
00411
00412         // Release the buddy reference
00413         SAFE_RELEASE(pBuddy);
00414
00415         ListView_DeleteItem(m_hBuddyList, 0);
00416     }
00417
00418     return S_OK;
00419 }
00420
00421 /////////////////////////////////////////////
00422 //
00423 // CRTCWin::DoLogOn
00424 //
00425
00426 HRESULT CRTCWin::DoLogOn(BSTR bstrURI, BSTR bstrServer, BSTR bstrTransport)
00427 {
00428     HRESULT hr;
00429
00430     if (m_pProfile)
00431     {
00432         // Already logged on
00433         ShowMessageBox(L"Already logged on!");
00434
00435         return S_FALSE;
00436     }
00437
00438     // Build an XML provisioning document
00439     BSTR bstrXML = NULL;
00440
00441     hr = DoGenerateProvisioning(
00442         bstrURI, bstrServer, bstrTransport, &bstrXML);
00443
00444     if (FAILED(hr))
00445     {
00446         // DoGenerateProvisioning failed
00447         ShowMessageBox(L"Logon failed!");
00448
00449         return hr;
00450     }
00451
00452     // Get the RTC client provisioning interface
00453     IRTCClientProvisioning * pProv = NULL;
00454
00455     hr = m_pClient->QueryInterface(
00456             IID_IRTCClientProvisioning,
00457             (void **)&pProv);
00458
00459     if (FAILED(hr))
00460     {
00461         // QueryInterface failed
00462         ShowMessageBox(L"Logon failed!");
00463
00464         return hr;
00465     }
00466
00467     // Create a RTC profile object from the XML
00468     // provisioning document
00469     hr = pProv->CreateProfile(bstrXML, &m_pProfile);
00470
00471     SAFE_FREE_STRING(bstrXML);
00472
00473     if (FAILED(hr))
00474     {
00475         // CreateProfile failed
00476         ShowMessageBox(L"Logon failed!");
00477
00478         SAFE_RELEASE(pProv);
00479         return hr;
00480     }
00481
00482     // Enable the RTC profile object
00483     hr = pProv->EnableProfile(m_pProfile, RTCRF_REGISTER_ALL);
00484
00485     SAFE_RELEASE(pProv);
00486
00487     if (FAILED(hr))
00488     {
00489         // EnableProfile failed
00490         SAFE_RELEASE(m_pProfile);
00491
00492         ShowMessageBox(L"Logon failed!");
00493         return hr;
00494     }
00495
00496     // Enable presence
00497     // It is best to enable presence immediately after enabling the
00498     // profile so that incoming watchers will not be lost.
00499     hr = DoEnablePresence(TRUE);
00500
00501     if (FAILED(hr))
00502     {
00503         // DoEnablePresence failed
00504         DoLogOff();
00505
00506         ShowMessageBox(L"Logon failed!");
00507         return hr;
00508     }
00509
00510     return S_OK;
00511 }
00512
00513 /////////////////////////////////////////////
00514 //
00515 // CRTCWin::OnLoggingOn
00516 //
00517
00518 HRESULT CRTCWin::OnLoggingOn()
00519 {
00520     // Enable/disable menu items
00521     HMENU hMenu = GetMenu(m_hWnd);
00522
00523     EnableMenuItem(hMenu, ID_FILE_LOGON, MF_GRAYED);
00524     EnableMenuItem(hMenu, ID_FILE_LOGOFF, MF_ENABLED);
00525
00526     return S_OK;
00527 }
00528
00529 /////////////////////////////////////////////
00530 //
00531 // CRTCWin::OnLoggedOn
00532 //
00533
00534 HRESULT CRTCWin::OnLoggedOn()
00535 {
00536     HRESULT hr;
00537
00538     // Get the RTC client presence interface
00539     IRTCClientPresence * pPresence = NULL;
00540
00541     hr = m_pClient->QueryInterface(
00542             IID_IRTCClientPresence,
00543             (void **)&pPresence);
00544
00545     if (FAILED(hr))
00546     {
00547         // QueryInterface failed
00548         return hr;
00549     }
00550
00551     // Enumerate buddies and populate list
00552     IRTCEnumBuddies * pEnum = NULL;
00553     IRTCBuddy * pBuddy = NULL;
00554
00555     hr = pPresence->EnumerateBuddies(&pEnum);
00556
00557     SAFE_RELEASE(pPresence);
00558
00559     if (FAILED(hr))
00560     {
00561         // Enumerate buddies failed
00562         return hr;
00563     }
00564
00565     while (pEnum->Next(1, &pBuddy, NULL) == S_OK)
00566     {
00567         // Update the buddy list entry
00568         UpdateBuddyList(pBuddy);
00569
00570         SAFE_RELEASE(pBuddy);
00571     }
00572
00573     SAFE_RELEASE(pEnum);
00574
00575     // Enable/disable menu items
00576     HMENU hMenu = GetMenu(m_hWnd);
00577
00578     EnableMenuItem(hMenu, ID_FILE_LOGON, MF_GRAYED);
00579     EnableMenuItem(hMenu, ID_FILE_LOGOFF, MF_ENABLED);
00580     EnableMenuItem(hMenu, ID_ACTION_ADDBUDDY, MF_ENABLED);
00581
00582     return S_OK;
00583 }
00584
00585 /////////////////////////////////////////////
00586 //
00587 // CRTCWin::DoLogOff
00588 //
00589
00590 HRESULT CRTCWin::DoLogOff()
00591 {
00592     HRESULT hr;
00593
00594     if (!m_pProfile)
00595     {
00596         // Already logged off
00597         return S_OK;
00598     }
00599
00600     // Get the RTC client provisioning interface
00601     IRTCClientProvisioning * pProv = NULL;
00602
00603     hr = m_pClient->QueryInterface(
00604             IID_IRTCClientProvisioning,
00605             (void **)&pProv);
00606
00607     if (FAILED(hr))
00608     {
00609         // QueryInterface failed
00610         return hr;
00611     }
00612
00613     // Disable the profile
00614     pProv->DisableProfile(m_pProfile);
00615
00616     SAFE_RELEASE(m_pProfile);
00617     SAFE_RELEASE(pProv);
00618
00619     return S_OK;
00620 }
00621
00622 /////////////////////////////////////////////
00623 //
00624 // CRTCWin::OnLoggingOff
00625 //
00626
00627 HRESULT CRTCWin::OnLoggingOff()
00628 {
00629     // Enable/disable menu items
00630     HMENU hMenu = GetMenu(m_hWnd);
00631
00632     EnableMenuItem(hMenu, ID_FILE_LOGON, MF_GRAYED);
00633     EnableMenuItem(hMenu, ID_FILE_LOGOFF, MF_GRAYED);
00634     EnableMenuItem(hMenu, ID_ACTION_ADDBUDDY, MF_GRAYED);
00635
00636     return S_OK;
00637 }
00638
00639 /////////////////////////////////////////////
00640 //
00641 // CRTCWin::OnLoggedOff
00642 //
00643
00644 HRESULT CRTCWin::OnLoggedOff()
00645 {
00646     // Disable presence
00647     DoEnablePresence(FALSE);
00648
00649     // Enable/disable menu items
00650     HMENU hMenu = GetMenu(m_hWnd);
00651
00652     EnableMenuItem(hMenu, ID_FILE_LOGON, MF_ENABLED);
00653     EnableMenuItem(hMenu, ID_FILE_LOGOFF, MF_GRAYED);
00654     EnableMenuItem(hMenu, ID_ACTION_ADDBUDDY, MF_GRAYED);
00655
00656     return S_OK;
00657 }
00658
00659 /////////////////////////////////////////////
00660 //
00661 // CRTCWin::DoGenerateProvisioning
00662 //
00663
00664 HRESULT CRTCWin::DoGenerateProvisioning(BSTR bstrURI, BSTR bstrServer,
00665                                         BSTR bstrTransport, BSTR *pbstrXML)
00666 {
00667     WCHAR szXML[MAX_XML_STRING];
00668     WCHAR szRealm[MAX_STRING];
00669
00670     // Allow basic authentication if the protocol is TLS
00671     BOOL fBasicAuth = !_wcsicmp(bstrTransport, L"TLS");
00672
00673     // Use the domain of the user uri as the realm
00674     WCHAR *ch = wcschr(bstrURI, L'@');
00675
00676     if (ch == NULL)
00677     {
00678         // User URI has no domain, use empty string
00679         wcsncpy(szRealm, L"", MAX_STRING);
00680         szRealm[MAX_STRING-1] = L'\0';
00681     }
00682     else
00683     {
00684         // Found the domain, copy the string
00685         ch++;
00686         wcsncpy(szRealm, ch, MAX_STRING);
00687         szRealm[MAX_STRING-1] = L'\0';
00688     }
00689
00690     // Generate the XML provisioning document
00691     _snwprintf(
00692         szXML,
00693         MAX_XML_STRING,
00694         L"<provision key=\"RTC Sample\" name=\"RTC Sample\">"
00695         L"<user uri=\"%s\" account=\"\" password=\"\" realm=\"%s\" />"
00696         L"<sipsrv addr=\"%s\" protocol=\"%s\" %s role=\"proxy\">"
00697         L"<session party=\"first\" type=\"pc2pc\" />"
00698         L"<session party=\"first\" type=\"pc2ph\" />"
00699         L"<session party=\"first\" type=\"im\" />"
00700         L"</sipsrv>"
00701         L"<sipsrv addr=\"%s\" protocol=\"%s\" %s role=\"registrar\" />"
00702         L"</provision>",
00703         bstrURI, szRealm,
00704         bstrServer, bstrTransport, fBasicAuth ? L"auth=\"basic\"" : L"",
00705         bstrServer, bstrTransport, fBasicAuth ? L"auth=\"basic\"" : L""
00706         );
00707
00708     szXML[MAX_XML_STRING-1] = L'\0';
00709
00710     *pbstrXML = SysAllocString(szXML);
00711
00712     if (!(*pbstrXML))
00713     {
00714         // Out of memory
00715         return E_OUTOFMEMORY;
00716     }
00717
00718     return S_OK;
00719 }
00720
00721 /////////////////////////////////////////////
00722 //
00723 // CRTCWin::DoAuth
00724 //
00725
00726 HRESULT CRTCWin::DoAuth(BSTR bstrURI, BSTR bstrAccount, BSTR bstrPassword)
00727 {
00728     HRESULT hr;
00729
00730     // Update the credentials in the profile
00731     hr = m_pProfile->SetCredentials(bstrURI, bstrAccount, bstrPassword);
00732
00733     if (FAILED(hr))
00734     {
00735         // SetCredentials failed
00736         return hr;
00737     }
00738
00739     // Get the RTC client provisioning interface
00740     IRTCClientProvisioning * pProv = NULL;
00741
00742     hr = m_pClient->QueryInterface(
00743             IID_IRTCClientProvisioning,
00744             (void **)&pProv);
00745
00746     if (FAILED(hr))
00747     {
00748         // QueryInterface failed
00749         return hr;
00750     }
00751
00752     // Re-enable the RTC profile object
00753     hr = pProv->EnableProfile(m_pProfile, RTCRF_REGISTER_ALL);
00754
00755     SAFE_RELEASE(pProv);
00756
00757     if (FAILED(hr))
00758     {
00759         // EnableProfile failed
00760         return hr;
00761     }
00762
00763     // Re-enable presence
00764     hr = DoEnablePresence(TRUE);
00765
00766     if (FAILED(hr))
00767     {
00768         // DoEnablePresence failed
00769         return hr;
00770     }
00771
00772     return S_OK;
00773 }
00774
00775 /////////////////////////////////////////////
00776 //
00777 // CRTCWin::DoEnablePresence
00778 //
00779
00780 HRESULT CRTCWin::DoEnablePresence(BOOL fEnable)
00781 {
00782     IRTCClientPresence * pPresence = NULL;
00783     HRESULT hr;
00784
00785     // Cleanup the buddy list
00786     ClearBuddyList();
00787
00788     // Get the RTC client presence interface
00789     hr = m_pClient->QueryInterface(
00790             IID_IRTCClientPresence,
00791             (void **)&pPresence);
00792
00793     if (FAILED(hr))
00794     {
00795         // QueryInterface failed
00796         return hr;
00797     }
00798
00799     // Get the location of the presence storage
00800     VARIANT varStorage;
00801     VariantInit(&varStorage);
00802     varStorage.vt = VT_BSTR;
00803     varStorage.bstrVal = SysAllocString(L"presence.xml");
00804
00805     // If we are disabling presence, save the latest
00806     // copy of the presence data
00807     if (!fEnable && m_fPresenceEnabled)
00808     {
00809         hr = pPresence->Export(varStorage);
00810
00811         if (FAILED(hr))
00812         {
00813             // Export failed
00814             SAFE_RELEASE(pPresence);
00815             VariantClear(&varStorage);
00816             return hr;
00817         }
00818     }
00819
00820     // Enable presence
00821     hr = pPresence->EnablePresence(
00822         fEnable ? VARIANT_TRUE : VARIANT_FALSE, varStorage);
00823
00824     VariantClear(&varStorage);
00825
00826     if (FAILED(hr))
00827     {
00828         // EnablePresence failed
00829         SAFE_RELEASE(pPresence);
00830         return hr;
00831     }
00832
00833     // Set the enabled flag
00834     m_fPresenceEnabled = fEnable;
00835
00836     // If we are disabling presence, cleanup the
00837     // presence data
00838     if (!fEnable)
00839     {
00840         // Cleanup buddies
00841         IRTCEnumBuddies * pEnumBuddy = NULL;
00842         IRTCBuddy * pBuddy = NULL;
00843
00844         hr = pPresence->EnumerateBuddies(&pEnumBuddy);
00845
00846         if (FAILED(hr))
00847         {
00848             // Enumerate buddies failed
00849             SAFE_RELEASE(pPresence);
00850             return hr;
00851         }
00852
00853         while (pEnumBuddy->Next(1, &pBuddy, NULL) == S_OK)
00854         {
00855             pPresence->RemoveBuddy(pBuddy);
00856
00857             SAFE_RELEASE(pBuddy);
00858         }
00859
00860         SAFE_RELEASE(pEnumBuddy);
00861
00862         // Cleanup watchers
00863         IRTCEnumWatchers * pEnumWatcher = NULL;
00864         IRTCWatcher * pWatcher = NULL;
00865
00866         hr = pPresence->EnumerateWatchers(&pEnumWatcher);
00867
00868         if (FAILED(hr))
00869         {
00870             // Enumerate watchers failed
00871             SAFE_RELEASE(pPresence);
00872             return hr;
00873         }
00874
00875         while (pEnumWatcher->Next(1, &pWatcher, NULL) == S_OK)
00876         {
00877             pPresence->RemoveWatcher(pWatcher);
00878
00879             SAFE_RELEASE(pWatcher);
00880         }
00881
00882         SAFE_RELEASE(pEnumWatcher);
00883     }
00884
00885     SAFE_RELEASE(pPresence);
00886
00887     return S_OK;
00888 }
00889
00890 /////////////////////////////////////////////
00891 //
00892 // CRTCWin::DoAddBuddy
00893 //
00894
00895 HRESULT CRTCWin::DoAddBuddy(BSTR bstrURI, BSTR bstrName)
00896 {
00897     HRESULT hr;
00898
00899     // Get the RTC client presence interface
00900     IRTCClientPresence * pPresence = NULL;
00901
00902     hr = m_pClient->QueryInterface(
00903             IID_IRTCClientPresence,
00904             (void **)&pPresence);
00905
00906     if (FAILED(hr))
00907     {
00908         // QueryInterface failed
00909         return hr;
00910     }
00911
00912     // Add the buddy
00913     IRTCBuddy * pBuddy = NULL;
00914
00915     hr = pPresence->AddBuddy(
00916             bstrURI,
00917             bstrName,
00918             NULL,
00919             VARIANT_TRUE,
00920             NULL,
00921             0,
00922             &pBuddy);
00923
00924     SAFE_RELEASE(pPresence);
00925
00926     if (FAILED(hr))
00927     {
00928         // Addbuddy failed
00929         SAFE_RELEASE(pBuddy);
00930         return hr;
00931     }
00932
00933     // Update the buddy list entry
00934     UpdateBuddyList(pBuddy);
00935     SAFE_RELEASE(pBuddy);
00936
00937     return S_OK;
00938 }
00939
00940 /////////////////////////////////////////////
00941 //
00942 // CRTCWin::DoRemoveBuddy
00943 //
00944
00945 HRESULT CRTCWin::DoRemoveBuddy(IRTCBuddy *pBuddy)
00946 {
00947     HRESULT hr;
00948
00949     // Get the RTC client presence interface
00950     IRTCClientPresence * pPresence = NULL;
00951
00952     hr = m_pClient->QueryInterface(
00953             IID_IRTCClientPresence,
00954             (void **)&pPresence);
00955
00956     if (FAILED(hr))
00957     {
00958         // QueryInterface failed
00959         return hr;
00960     }
00961
00962     // Remove the buddy
00963     hr = pPresence->RemoveBuddy(pBuddy);
00964
00965     SAFE_RELEASE(pPresence);
00966
00967     if (FAILED(hr))
00968     {
00969         // RemoveBuddy failed
00970         return hr;
00971     }
00972
00973     return S_OK;
00974 }
00975
00976 /////////////////////////////////////////////
00977 //
00978 // CRTCWin::DoCall
00979 //
00980
00981 HRESULT CRTCWin::DoCall(RTC_SESSION_TYPE enType, BSTR bstrURI)
00982 {
00983     HRESULT hr;
00984
00985     if (enType != RTCST_IM)
00986     {
00987         // Is there already an AV session? We can only
00988         // allow one at a time
00989         if (CRTCAVSession::m_Singleton != NULL)
00990         {
00991             ShowMessageBox(L"An audio/video call is in progress!");
00992
00993             return S_FALSE;
00994         }
00995     }
00996
00997     // Create the session
00998     IRTCSession * pSession = NULL;
00999
01000     hr = m_pClient->CreateSession(
01001         enType,
01002         NULL,
01003         NULL,
01004         0,
01005         &pSession
01006         );
01007
01008     if (FAILED(hr))
01009     {
01010         // CreateSession failed
01011         return hr;
01012     }
01013
01014     // Add the participant to the session
01015     hr = pSession->AddParticipant(
01016         bstrURI,
01017         NULL,
01018         NULL
01019         );
01020
01021     if (FAILED(hr))
01022     {
01023         // AddParticipant failed
01024         SAFE_RELEASE(pSession);
01025         return hr;
01026     }
01027
01028     // Add the session to the session list
01029     // This will create the session window
01030     hr = AddSession(pSession, enType);
01031
01032     SAFE_RELEASE(pSession);
01033
01034     if (FAILED(hr))
01035     {
01036         // AddSession failed
01037         return hr;
01038     }
01039
01040     return S_OK;
01041 }
01042
01043 /////////////////////////////////////////////
01044 //
01045 // CRTCWin::DoTuningWizard
01046 //
01047
01048 HRESULT CRTCWin::DoTuningWizard()
01049 {
01050     HRESULT hr;
01051
01052     // Is there already an AV session? We can only
01053     // allow one at a time
01054     if (CRTCAVSession::m_Singleton != NULL)
01055     {
01056         ShowMessageBox(L"An audio/video call is in progress!");
01057
01058         return S_FALSE;
01059     }
01060
01061     // Show the tuning wizard
01062     hr = m_pClient->InvokeTuningWizard((OAHWND)m_hWnd);
01063
01064     if (FAILED(hr))
01065     {
01066         // InvokeTuningWizard failed
01067         return hr;
01068     }
01069
01070     return S_OK;
01071 }
01072
01073 /////////////////////////////////////////////
01074 //
01075 // CRTCWin::DoSetPresence
01076 //
01077
01078 HRESULT CRTCWin::DoSetPresence(RTC_PRESENCE_STATUS enStatus)
01079 {
01080     HRESULT hr;
01081     UINT id = 0;
01082
01083     // Check the appropriate menu item
01084     switch(enStatus)
01085     {
01086     case RTCXS_PRESENCE_OFFLINE:
01087         id = ID_FILE_PRESENCESTATUS_OFFLINE;
01088         break;
01089
01090     case RTCXS_PRESENCE_ONLINE:
01091         id = ID_FILE_PRESENCESTATUS_ONLINE;
01092         break;
01093
01094     case RTCXS_PRESENCE_AWAY:
01095         id = ID_FILE_PRESENCESTATUS_AWAY;
01096         break;
01097
01098     case RTCXS_PRESENCE_IDLE:
01099         id = ID_FILE_PRESENCESTATUS_IDLE;
01100         break;
01101
01102     case RTCXS_PRESENCE_BUSY:
01103         id = ID_FILE_PRESENCESTATUS_BUSY;
01104         break;
01105
01106     case RTCXS_PRESENCE_BE_RIGHT_BACK:
01107         id = ID_FILE_PRESENCESTATUS_BERIGHTBACK;
01108         break;
01109
01110     case RTCXS_PRESENCE_ON_THE_PHONE:
01111         id = ID_FILE_PRESENCESTATUS_ONTHEPHONE;
01112         break;
01113
01114     case RTCXS_PRESENCE_OUT_TO_LUNCH:
01115         id = ID_FILE_PRESENCESTATUS_OUTTOLUNCH;
01116         break;
01117     }
01118
01119     CheckMenuRadioItem(
01120         GetMenu(m_hWnd),   // handle to menu
01121         ID_FILE_PRESENCESTATUS_OFFLINE,  // identifier or position of first item
01122         ID_FILE_PRESENCESTATUS_OUTTOLUNCH,   // identifier or position of last item
01123         id,  // identifier or position of menu item
01124         MF_BYCOMMAND    // function options
01125         );
01126
01127     // Get the RTC client presence interface
01128     IRTCClientPresence * pPresence = NULL;
01129
01130     hr = m_pClient->QueryInterface(
01131             IID_IRTCClientPresence,
01132             (void **)&pPresence);
01133
01134     if (FAILED(hr))
01135     {
01136         // QueryInterface failed
01137         return hr;
01138     }
01139
01140     // Set the local presence status
01141     hr = pPresence->SetLocalPresenceInfo(enStatus, NULL);
01142
01143     SAFE_RELEASE(pPresence);
01144
01145     if (FAILED(hr))
01146     {
01147         // SetLocalPresenceInfo failed
01148         return hr;
01149     }
01150
01151     return S_OK;
01152 }
01153
01154 /////////////////////////////////////////////
01155 //
01156 // CRTCWin::WindowProc
01157 //
01158
01159 LRESULT CALLBACK CRTCWin::WindowProc(
01160   HWND hWnd,      // handle to window
01161   UINT uMsg,      // message identifier
01162   WPARAM wParam,  // first message parameter
01163   LPARAM lParam   // second message parameter
01164 )
01165 {
01166     CRTCWin * me = NULL;
01167     LRESULT  lr = 0;
01168
01169     if ( uMsg == WM_CREATE )
01170     {
01171         // Create an instance of the class
01172         me = new CRTCWin;
01173         me->m_hWnd = hWnd;
01174
01175         // Store the class instance pointer in the
01176         // window's user data for later retrieval
01177         SetWindowLong(hWnd, GWL_USERDATA, (LONG)me);
01178
01179         lr = me->OnCreate(uMsg, wParam, lParam);
01180     }
01181     else
01182     {
01183         // Retrieve the class instance pointer from the
01184         // window's user data
01185         me = (CRTCWin *)GetWindowLong(hWnd, GWL_USERDATA);
01186
01187         switch( uMsg )
01188         {
01189         case WM_DESTROY:
01190             lr = me->OnDestroy(uMsg, wParam, lParam);
01191
01192             // Delete the object instance
01193             delete me;
01194
01195             // Quit the application
01196             PostQuitMessage(0);
01197             break;
01198
01199         case WM_CLOSE:
01200             lr = me->OnClose(uMsg, wParam, lParam);
01201             break;
01202
01203         case WM_SIZE:
01204             lr = me->OnSize(uMsg, wParam, lParam);
01205             break;
01206
01207         case WM_COMMAND:
01208             lr = me->OnCommand(uMsg, wParam, lParam);
01209             break;
01210
01211         case WM_NOTIFY:
01212             lr = me->OnNotify(uMsg, wParam, lParam);
01213             break;
01214
01215         case WM_RTC_EVENT:
01216             lr = me->OnRTCEvent(uMsg, wParam, lParam);
01217             break;
01218
01219         default:
01220             lr = DefWindowProc( hWnd, uMsg, wParam, lParam );
01221         }
01222     }
01223
01224     return lr;
01225 }
01226
01227 /////////////////////////////////////////////
01228 //
01229 // CRTCWin::OnCreate
01230 //
01231
01232 LRESULT CRTCWin::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam)
01233 {
01234     // Create the status bar
01235     m_hStatusBar = CreateStatusWindow(
01236         WS_CHILD | WS_VISIBLE,
01237         NULL,
01238         m_hWnd,
01239         IDC_STATUSBAR
01240         );
01241
01242     if ( !m_hStatusBar )
01243     {
01244         // CreateStatusWindow failed
01245         return -1;
01246     }
01247
01248     // Create the buddy list
01249     m_hBuddyList = CreateWindowExW(
01250         WS_EX_CLIENTEDGE,
01251         L"SysListView32",
01252         NULL,
01253         WS_CHILD | WS_VISIBLE |
01254         LVS_SINGLESEL | LVS_SORTASCENDING |
01255         LVS_AUTOARRANGE | LVS_SMALLICON,
01256         0, 0,
01257         0, 0,
01258         m_hWnd,
01259         (HMENU)IDC_BUDDYLIST,
01260         GetModuleHandle(NULL),
01261         NULL);
01262
01263     if ( !m_hBuddyList )
01264     {
01265         // CreateWindowExW failed
01266         return -1;
01267     }
01268
01269     // Create the RTC client
01270     HRESULT hr;
01271
01272     hr = CoCreateInstance(
01273         CLSID_RTCClient,
01274         NULL,
01275         CLSCTX_INPROC_SERVER,
01276         IID_IRTCClient,
01277         (LPVOID *)&m_pClient
01278         );
01279
01280     if (FAILED(hr))
01281     {
01282         // CoCreateInstance failed
01283         return -1;
01284     }
01285
01286     // Initialize the RTC client
01287     hr = m_pClient->Initialize();
01288
01289     if (FAILED(hr))
01290     {
01291         // Initialize failed
01292         SAFE_RELEASE(m_pClient);
01293         return -1;
01294     }
01295
01296     // Set the event filter for the RTC client
01297     hr = m_pClient->put_EventFilter(
01298                  RTCEF_REGISTRATION_STATE_CHANGE |
01299                  RTCEF_SESSION_STATE_CHANGE |
01300                  RTCEF_PARTICIPANT_STATE_CHANGE |
01301                  RTCEF_MESSAGING |
01302                  RTCEF_MEDIA |
01303                  RTCEF_INTENSITY |
01304                  RTCEF_CLIENT |
01305                  RTCEF_BUDDY |
01306                  RTCEF_WATCHER
01307                  );
01308
01309     if ( FAILED(hr) )
01310     {
01311         // put_EventFilter failed
01312         SAFE_RELEASE(m_pClient);
01313         return -1;
01314     }
01315
01316     // Set the listen mode for RTC client
01317     // RTCLM_BOTH opens the standard SIP port 5060, as well as
01318     // a dynamic port.
01319     hr = m_pClient->put_ListenForIncomingSessions(RTCLM_BOTH);
01320
01321     if ( FAILED(hr) )
01322     {
01323         // put_ListenMode failed
01324         SAFE_RELEASE(m_pClient);
01325         return -1;
01326     }
01327
01328     // Create the event sink object
01329     m_pEvents = new CRTCEvents;
01330
01331     if (!m_pEvents)
01332     {
01333         // Out of memory
01334         SAFE_RELEASE(m_pClient);
01335         return -1;
01336     }
01337
01338     // Advise for events from the RTC client
01339     hr = m_pEvents->Advise( m_pClient, m_hWnd );
01340
01341     if ( FAILED(hr) )
01342     {
01343         // Advise failed
01344         SAFE_RELEASE(m_pClient);
01345         return -1;
01346     }
01347
01348     // Initialize presence status
01349     DoSetPresence(RTCXS_PRESENCE_ONLINE);
01350
01351     // Show the logon dialog
01352     PostMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(ID_FILE_LOGON, 0), 0);
01353
01354     return 0;
01355 }
01356
01357 /////////////////////////////////////////////
01358 //
01359 // CRTCWin::OnDestroy
01360 //
01361
01362 LRESULT CRTCWin::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam)
01363 {
01364     // Release the RTC profile
01365     SAFE_RELEASE(m_pProfile);
01366
01367     if (m_pClient)
01368     {
01369         if (m_pEvents)
01370         {
01371             // Unadvise for events from the RTC client
01372             m_pEvents->Unadvise(m_pClient);
01373             m_pEvents = NULL;
01374         }
01375
01376         // Shutdown the RTC client
01377         m_pClient->Shutdown();
01378
01379         // Release the RTC client
01380         SAFE_RELEASE(m_pClient);
01381     }
01382
01383     return 0;
01384 }
01385
01386 /////////////////////////////////////////////
01387 //
01388 // CRTCWin::OnClose
01389 //
01390
01391 LRESULT CRTCWin::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam)
01392 {
01393     HRESULT hr = S_OK;
01394
01395     // Cleanup the existing session windows
01396     CleanupSessions();
01397
01398     if (m_pClient)
01399     {
01400         // Prepare the RTC client object for shutdown
01401         hr = m_pClient->PrepareForShutdown();
01402     }
01403
01404     if (!m_pClient || FAILED(hr))
01405     {
01406         // The RTC client object either doesn't exist, or
01407         // failed to prepare for shutdown. Destroy the
01408         // window now
01409         DestroyWindow(m_hWnd);
01410     }
01411     else
01412     {
01413         // The RTC client object is preparing to shutdown.
01414         // We should wait for the RTCCET_ASYNC_CLEANUP_DONE
01415         // event before we shutdown the RTC client. For now
01416         // just hide the window
01417         ShowWindow(m_hWnd, SW_HIDE);
01418     }
01419
01420     return 0;
01421 }
01422
01423 /////////////////////////////////////////////
01424 //
01425 // CRTCWin::OnSize
01426 //
01427
01428 LRESULT CRTCWin::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam)
01429 {
01430     RECT rcWnd, rcStatusBar, rcBuddyList;
01431
01432     const int SIZE_EDGE = 5;
01433
01434     GetClientRect(m_hWnd, &rcWnd);
01435
01436     // Resize the status bar
01437     SendMessage(m_hStatusBar, uMsg, wParam, lParam);
01438
01439     GetClientRect(m_hStatusBar, &rcStatusBar);
01440
01441     // Resize the buddy list
01442     rcBuddyList.bottom = rcWnd.bottom -
01443         (rcStatusBar.bottom - rcStatusBar.top) -
01444         SIZE_EDGE;
01445     rcBuddyList.top = rcWnd.top + SIZE_EDGE;
01446     rcBuddyList.right = rcWnd.right - SIZE_EDGE;
01447     rcBuddyList.left = rcWnd.left + SIZE_EDGE;
01448
01449     MoveWindow(
01450         m_hBuddyList,
01451         rcBuddyList.left,
01452         rcBuddyList.top,
01453         (rcBuddyList.right - rcBuddyList.left),
01454         (rcBuddyList.bottom - rcBuddyList.top),
01455         TRUE);
01456
01457     SendMessage(m_hBuddyList, LVM_SETCOLUMNWIDTH,
01458         (WPARAM)0, MAKELPARAM(rcBuddyList.right - rcBuddyList.left,0));
01459
01460     return 0;
01461 }
01462
01463 /////////////////////////////////////////////
01464 //
01465 // CRTCWin::OnCommand
01466 //
01467
01468 LRESULT CRTCWin::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
01469 {
01470     HRESULT hr;
01471
01472     switch(LOWORD(wParam))
01473     {
01474     case ID_FILE_LOGON:
01475         {
01476             BSTR bstrURI = NULL;
01477             BSTR bstrServer = NULL;
01478             BSTR bstrTransport = NULL;
01479
01480             hr = ShowLogonDialog(
01481                 m_hWnd, &bstrURI, &bstrServer, &bstrTransport);
01482
01483             if (FAILED(hr))
01484             {
01485                 // ShowLogonDialog failed
01486                 break;
01487             }
01488
01489             DoLogOn(bstrURI, bstrServer, bstrTransport);
01490
01491             SAFE_FREE_STRING(bstrURI);
01492             SAFE_FREE_STRING(bstrServer);
01493             SAFE_FREE_STRING(bstrTransport);
01494         }
01495         break;
01496
01497     case ID_FILE_LOGOFF:
01498         DoLogOff();
01499         break;
01500
01501     case ID_FILE_EXIT:
01502         PostMessage(m_hWnd, WM_CLOSE, 0, 0);
01503         break;
01504
01505     case ID_ACTION_ADDBUDDY:
01506         {
01507             BSTR bstrURI = NULL;
01508             BSTR bstrName = NULL;
01509
01510             // Show the add buddy dialog
01511             hr = ShowAddressDialog(m_hWnd, L"Add Buddy", TRUE, &bstrURI, &bstrName);
01512
01513             if (FAILED(hr))
01514             {
01515                 // ShowAddressDialog failed
01516                 break;
01517             }
01518
01519             // Add the buddy
01520             DoAddBuddy(bstrURI, bstrName);
01521
01522             SAFE_FREE_STRING(bstrURI);
01523             SAFE_FREE_STRING(bstrName);
01524         }
01525         break;
01526
01527     case ID_ACTION_CALL:
01528         {
01529             BSTR bstrURI = NULL;
01530
01531             // Show the call dialog
01532             hr = ShowAddressDialog(m_hWnd, L"Call To", FALSE, &bstrURI, NULL);
01533
01534             if (FAILED(hr))
01535             {
01536                 // ShowAddressDialog failed
01537                 break;
01538             }
01539
01540             // Call the user
01541             DoCall(RTCST_PC_TO_PC, bstrURI);
01542
01543             SAFE_FREE_STRING(bstrURI);
01544         }
01545         break;
01546
01547     case ID_ACTION_MESSAGE:
01548         {
01549             BSTR bstrURI = NULL;
01550
01551             // Show the call dialog
01552             hr = ShowAddressDialog(m_hWnd, L"Message To", FALSE, &bstrURI, NULL);
01553
01554             if (FAILED(hr))
01555             {
01556                 // ShowAddressDialog failed
01557                 break;
01558             }
01559
01560             // Send a message to the user
01561             DoCall(RTCST_IM, bstrURI);
01562
01563             SAFE_FREE_STRING(bstrURI);
01564         }
01565         break;
01566
01567     case ID_TOOLS_TUNINGWIZARD:
01568         DoTuningWizard();
01569         break;
01570
01571     case ID_FILE_PRESENCESTATUS_OFFLINE:
01572         DoSetPresence(RTCXS_PRESENCE_OFFLINE);
01573         break;
01574
01575     case ID_FILE_PRESENCESTATUS_ONLINE:
01576         DoSetPresence(RTCXS_PRESENCE_ONLINE);
01577         break;
01578
01579     case ID_FILE_PRESENCESTATUS_AWAY:
01580         DoSetPresence(RTCXS_PRESENCE_AWAY);
01581         break;
01582
01583     case ID_FILE_PRESENCESTATUS_IDLE:
01584         DoSetPresence(RTCXS_PRESENCE_IDLE);
01585         break;
01586
01587     case ID_FILE_PRESENCESTATUS_BUSY:
01588         DoSetPresence(RTCXS_PRESENCE_BUSY);
01589         break;
01590
01591     case ID_FILE_PRESENCESTATUS_BERIGHTBACK:
01592         DoSetPresence(RTCXS_PRESENCE_BE_RIGHT_BACK);
01593         break;
01594
01595     case ID_FILE_PRESENCESTATUS_ONTHEPHONE:
01596         DoSetPresence(RTCXS_PRESENCE_ON_THE_PHONE);
01597         break;
01598
01599     case ID_FILE_PRESENCESTATUS_OUTTOLUNCH:
01600         DoSetPresence(RTCXS_PRESENCE_OUT_TO_LUNCH);
01601         break;
01602     }
01603
01604     return 0;
01605 }
01606
01607 /////////////////////////////////////////////
01608 //
01609 // CRTCWin::OnNotify
01610 //
01611
01612 LRESULT CRTCWin::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam)
01613 {
01614     int idCtrl = (int)wParam;
01615     LPNMHDR pnmh = (LPNMHDR)lParam;
01616     HRESULT hr;
01617
01618     if ( (pnmh->code == NM_CLICK) ||
01619          (pnmh->code == NM_RCLICK) )
01620     {
01621         if ( idCtrl == IDC_BUDDYLIST )
01622         {
01623             // The user clicked on the buddy list
01624             LVHITTESTINFO lvht;
01625             ZeroMemory(&lvht, sizeof(LVHITTESTINFO));
01626
01627             POINT pt;
01628             GetCursorPos(&pt);
01629
01630             lvht.pt = pt;
01631             MapWindowPoints(NULL, pnmh->hwndFrom, &lvht.pt, 1 );
01632
01633             int iRes = ListView_HitTest(pnmh->hwndFrom, &lvht);
01634
01635             if (iRes == -1)
01636             {
01637                 // ListView_HitTest failed
01638                 return 0;
01639             }
01640
01641             if (lvht.flags & LVHT_ONITEM)
01642             {
01643                 // The user clicked on a buddy
01644                 LVITEM lvi;
01645                 ZeroMemory(&lvi, sizeof(LVITEM));
01646
01647                 lvi.mask = LVIF_PARAM;
01648                 lvi.iItem = iRes;
01649
01650                 // Get the buddy item
01651                 if (!ListView_GetItem(m_hBuddyList, &lvi))
01652                 {
01653                     // ListView_GetItem failed;
01654                     return 0;
01655                 }
01656
01657                 IRTCBuddy * pBuddy = (IRTCBuddy *)(lvi.lParam);
01658                 BSTR bstrURI = NULL;
01659
01660                 // Get the buddy URI
01661                 hr = pBuddy->get_PresentityURI(&bstrURI);
01662
01663                 if (FAILED(hr))
01664                 {
01665                     // get_UserURI failed
01666                     return 0;
01667                 }
01668
01669                 // Show the buddy menu
01670                 HMENU hMenuRes = LoadMenu(
01671                     GetModuleHandle(NULL),
01672                     MAKEINTRESOURCE(IDR_MENU_BUDDY));
01673
01674                 HMENU hMenu = GetSubMenu(hMenuRes, 0);
01675
01676                 UINT uID = TrackPopupMenu(hMenu,
01677                     TPM_LEFTALIGN | TPM_RIGHTBUTTON |
01678                     TPM_NONOTIFY | TPM_RETURNCMD,
01679                     pt.x, pt.y, 0, m_hWnd, NULL);
01680
01681                 switch (uID)
01682                 {
01683                 case ID_BUDDY_CALL:
01684                     // Call the buddy
01685                     DoCall(RTCST_PC_TO_PC, bstrURI);
01686                     break;
01687
01688                 case ID_BUDDY_MESSAGE:
01689                     // Send a message to the buddy
01690                     DoCall(RTCST_IM, bstrURI);
01691                     break;
01692
01693                 case ID_BUDDY_REMOVE:
01694                     // Remove the buddy
01695                     DoRemoveBuddy(pBuddy);
01696
01697                     // Release the buddy reference
01698                     SAFE_RELEASE(pBuddy);
01699
01700                     // Delete the buddy from the list
01701                     ListView_DeleteItem(m_hBuddyList, iRes);
01702                     break;
01703                 }
01704
01705                 SAFE_FREE_STRING(bstrURI);
01706             }
01707         }
01708     }
01709
01710     return 0;
01711 }
01712
01713 /////////////////////////////////////////////
01714 //
01715 // CRTCWin::OnRTCEvent
01716 //
01717
01718 LRESULT CRTCWin::OnRTCEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
01719 {
01720     IDispatch * pDisp = (IDispatch *)lParam;
01721     RTC_EVENT enEvent = (RTC_EVENT)wParam;
01722     HRESULT hr;
01723
01724     // Based on the RTC_EVENT type, query for the
01725     // appropriate event interface and call a helper
01726     // method to handle the event
01727     switch ( wParam )
01728     {
01729         case RTCE_REGISTRATION_STATE_CHANGE:
01730             {
01731                 IRTCRegistrationStateChangeEvent * pEvent = NULL;
01732
01733                 hr = pDisp->QueryInterface( IID_IRTCRegistrationStateChangeEvent,
01734                                             (void **)&pEvent );
01735
01736                 if (SUCCEEDED(hr))
01737                 {
01738                     OnRTCRegistrationStateChangeEvent(pEvent);
01739                     SAFE_RELEASE(pEvent);
01740                 }
01741             }
01742             break;
01743
01744         case RTCE_SESSION_STATE_CHANGE:
01745             {
01746                 IRTCSessionStateChangeEvent * pEvent = NULL;
01747
01748                 hr = pDisp->QueryInterface( IID_IRTCSessionStateChangeEvent,
01749                                             (void **)&pEvent );
01750
01751                 if (SUCCEEDED(hr))
01752                 {
01753                     OnRTCSessionStateChangeEvent(pEvent);
01754                     SAFE_RELEASE(pEvent);
01755                 }
01756             }
01757             break;
01758
01759         case RTCE_PARTICIPANT_STATE_CHANGE:
01760             {
01761                 IRTCParticipantStateChangeEvent * pEvent = NULL;
01762
01763                 hr = pDisp->QueryInterface( IID_IRTCParticipantStateChangeEvent,
01764                                             (void **)&pEvent );
01765
01766                 if (SUCCEEDED(hr))
01767                 {
01768                     OnRTCParticipantStateChangeEvent(pEvent);
01769                     SAFE_RELEASE(pEvent);
01770                 }
01771             }
01772             break;
01773
01774         case RTCE_MESSAGING:
01775             {
01776                 IRTCMessagingEvent * pEvent = NULL;
01777
01778                 hr = pDisp->QueryInterface( IID_IRTCMessagingEvent,
01779                                             (void **)&pEvent );
01780
01781                 if (SUCCEEDED(hr))
01782                 {
01783                     OnRTCMessagingEvent(pEvent);
01784                     SAFE_RELEASE(pEvent);
01785                 }
01786             }
01787             break;
01788
01789         case RTCE_MEDIA:
01790             {
01791                 IRTCMediaEvent * pEvent = NULL;
01792
01793                 hr = pDisp->QueryInterface( IID_IRTCMediaEvent,
01794                                             (void **)&pEvent );
01795
01796                 if (SUCCEEDED(hr))
01797                 {
01798                     OnRTCMediaEvent(pEvent);
01799                     SAFE_RELEASE(pEvent);
01800                 }
01801             }
01802             break;
01803
01804         case RTCE_INTENSITY:
01805             {
01806                 IRTCIntensityEvent * pEvent = NULL;
01807
01808                 hr = pDisp->QueryInterface( IID_IRTCIntensityEvent,
01809                                             (void **)&pEvent );
01810
01811                 if (SUCCEEDED(hr))
01812                 {
01813                     OnRTCIntensityEvent(pEvent);
01814                     SAFE_RELEASE(pEvent);
01815                 }
01816             }
01817             break;
01818
01819         case RTCE_CLIENT:
01820             {
01821                 IRTCClientEvent * pEvent = NULL;
01822
01823                 hr = pDisp->QueryInterface( IID_IRTCClientEvent,
01824                                             (void **)&pEvent );
01825
01826                 if (SUCCEEDED(hr))
01827                 {
01828                     OnRTCClientEvent(pEvent);
01829                     SAFE_RELEASE(pEvent);
01830                 }
01831             }
01832             break;
01833
01834         case RTCE_BUDDY:
01835             {
01836                 IRTCBuddyEvent * pEvent = NULL;
01837
01838                 hr = pDisp->QueryInterface( IID_IRTCBuddyEvent,
01839                                             (void **)&pEvent );
01840
01841                 if (SUCCEEDED(hr))
01842                 {
01843                     OnRTCBuddyEvent(pEvent);
01844                     SAFE_RELEASE(pEvent);
01845                 }
01846             }
01847             break;
01848
01849         case RTCE_WATCHER:
01850             {
01851                 IRTCWatcherEvent * pEvent = NULL;
01852
01853                 hr = pDisp->QueryInterface( IID_IRTCWatcherEvent,
01854                                             (void **)&pEvent );
01855
01856                 if (SUCCEEDED(hr))
01857                 {
01858                     OnRTCWatcherEvent(pEvent);
01859                     SAFE_RELEASE(pEvent);
01860                 }
01861             }
01862             break;
01863     }
01864
01865     // Release the event
01866     SAFE_RELEASE(pDisp);
01867
01868     return 0;
01869 }
01870
01871 /////////////////////////////////////////////
01872 //
01873 // CRTCWin::OnRTCRegistrationStateChangeEvent
01874 //
01875
01876 void CRTCWin::OnRTCRegistrationStateChangeEvent(
01877             IRTCRegistrationStateChangeEvent *pEvent
01878             )
01879 {
01880     HRESULT hr;
01881
01882     // Get the registration state
01883     RTC_REGISTRATION_STATE enState;
01884     long lStatusCode;
01885
01886     hr = pEvent->get_State(&enState);
01887
01888     if (FAILED(hr))
01889     {
01890         // get_State failed
01891         return;
01892     }
01893
01894     // Get the status code
01895     hr = pEvent->get_StatusCode(&lStatusCode);
01896
01897     if (FAILED(hr))
01898     {
01899         // get_StatusCode failed
01900         return;
01901     }
01902
01903     switch(enState)
01904     {
01905     case RTCRS_UNREGISTERING:
01906         // Logoff in progress
01907         SetStatusText(L"Logging off");
01908
01909         OnLoggingOff();
01910         break;
01911
01912     case RTCRS_NOT_REGISTERED:
01913         // Logged off
01914         SetStatusText(L"Logged off");
01915
01916         OnLoggedOff();
01917         break;
01918
01919     case RTCRS_REGISTERING:
01920         // Logon in progress
01921         SetStatusText(L"Logging on");
01922
01923         OnLoggingOn();
01924         break;
01925
01926     case RTCRS_REGISTERED:
01927         // Logged on
01928         SetStatusText(L"Logged on");
01929
01930         OnLoggedOn();
01931         break;
01932
01933     case RTCRS_REJECTED:
01934     case RTCRS_ERROR:
01935         {
01936             // Logon failed. Most likely the server could no be found,
01937             // or the user needs to authenticate.
01938             SetStatusText(L"Logged off");
01939
01940             HRESULT hr = lStatusCode;
01941
01942             // Check if we need to authenticate
01943             if ((hr == RTC_E_STATUS_CLIENT_UNAUTHORIZED) ||
01944                 (hr == RTC_E_STATUS_CLIENT_PROXY_AUTHENTICATION_REQUIRED))
01945             {
01946                 BSTR bstrOldURI = NULL;
01947                 BSTR bstrURI = NULL;
01948                 BSTR bstrAccount = NULL;
01949                 BSTR bstrPassword = NULL;
01950
01951                 // Get the old user URI
01952                 hr = GetUserURI(&bstrOldURI);
01953
01954                 if (FAILED(hr))
01955                 {
01956                     // GetUserURI failed
01957                     break;
01958                 }
01959
01960                 // Display the authentication dialog
01961                 hr = ShowAuthDialog(m_hWnd, bstrOldURI,
01962                     &bstrURI, &bstrAccount, &bstrPassword);
01963
01964                 SAFE_FREE_STRING(bstrOldURI);
01965
01966                 if (FAILED(hr))
01967                 {
01968                     // ShowAuthDialog failed
01969                     break;
01970                 }
01971
01972                 // Do the authentication
01973                 hr = DoAuth(bstrURI, bstrAccount, bstrPassword);
01974
01975                 SAFE_FREE_STRING(bstrURI);
01976                 SAFE_FREE_STRING(bstrAccount);
01977                 SAFE_FREE_STRING(bstrPassword);
01978             }
01979
01980             if (FAILED(hr))
01981             {
01982                 DoLogOff();
01983                 OnLoggedOff();
01984
01985                 // If we were logging on the show error
01986                 if (m_enState == RTCRS_REGISTERING)
01987                 {
01988                     ShowMessageBox(L"Logon failed!");
01989                 }
01990             }
01991         }
01992         break;
01993
01994     case RTCRS_LOGGED_OFF:
01995         // The user logged on at another client
01996         // The user is logged off from this client
01997         SetStatusText(L"Logged off");
01998
01999         DoLogOff();
02000         OnLoggedOff();
02001         break;
02002
02003     case RTCRS_LOCAL_PA_LOGGED_OFF:
02004         // The user logged on at another client
02005         // The user's presence state is no longer sent from this client
02006
02007         SetStatusText(L"Logged on (Presence disabled)");
02008         break;
02009
02010     case RTCRS_REMOTE_PA_LOGGED_OFF:
02011         // The user logged off on another client that was sending his
02012         // presence state. We can ignore this.
02013         break;
02014     }
02015
02016     m_enState = enState;
02017 }
02018
02019 /////////////////////////////////////////////
02020 //
02021 // CRTCWin::OnRTCSessionStateChangeEvent
02022 //
02023
02024 void CRTCWin::OnRTCSessionStateChangeEvent(
02025             IRTCSessionStateChangeEvent *pEvent
02026             )
02027 {
02028     IRTCSession * pSession = NULL;
02029     CRTCSession * pSessWindow = NULL;
02030     RTC_SESSION_STATE enState;
02031     HRESULT hr;
02032
02033     hr = pEvent->get_State(&enState);
02034
02035     if (FAILED(hr))
02036     {
02037         // get_State failed
02038         return;
02039     }
02040
02041     hr = pEvent->get_Session(&pSession);
02042
02043     if (FAILED(hr))
02044     {
02045         // get_Session failed
02046         return;
02047     }
02048
02049     // Is this session in our session list?
02050     hr = FindSession(pSession, &pSessWindow);
02051
02052     if (FAILED(hr))
02053     {
02054         // FindSession failed
02055         if (enState == RTCSS_INCOMING)
02056         {
02057             // This is a new session
02058             RTC_SESSION_TYPE enType;
02059
02060             hr = pSession->get_Type(&enType);
02061
02062             if (FAILED(hr))
02063             {
02064                 // get_Type failed
02065                 SAFE_RELEASE(pSession);
02066                 return;
02067             }
02068
02069             if (enType == RTCST_IM)
02070             {
02071                 // This is an IM call
02072                 m_pClient->PlayRing(RTCRT_MESSAGE, VARIANT_TRUE);
02073             }
02074             else
02075             {
02076                 // This is an AV call
02077                 if (CRTCAVSession::m_Singleton != NULL)
02078                 {
02079                     // If another AV call is in progress, then
02080                     // we are already busy.
02081                     pSession->Terminate(RTCTR_BUSY);
02082
02083                     SAFE_RELEASE(pSession);
02084                     return;
02085                 }
02086
02087                 // Get the participant object
02088                 IRTCEnumParticipants * pEnum = NULL;
02089                 IRTCParticipant * pParticipant = NULL;
02090
02091                 hr = pSession->EnumerateParticipants(&pEnum);
02092
02093                 if (FAILED(hr))
02094                 {
02095                     // EnumerateParticipants failed
02096                     SAFE_RELEASE(pSession);
02097                     return;
02098                 }
02099
02100                 hr = pEnum->Next(1, &pParticipant, NULL);
02101
02102                 SAFE_RELEASE(pEnum);
02103
02104                 if (hr != S_OK)
02105                 {
02106                     // Next failed
02107                     SAFE_RELEASE(pSession);
02108                     return;
02109                 }
02110
02111                 // Get the participant URI
02112                 BSTR bstrURI = NULL;
02113
02114                 hr = pParticipant->get_UserURI(&bstrURI);
02115
02116                 if (FAILED(hr))
02117                 {
02118                     // get_UserURI failed
02119                     SAFE_RELEASE(pSession);
02120                     SAFE_RELEASE(pParticipant);
02121                     return;
02122                 }
02123
02124                 // Get the participant name
02125                 BSTR bstrName = NULL;
02126
02127                 hr = pParticipant->get_Name(&bstrName);
02128
02129                 SAFE_RELEASE(pParticipant);
02130
02131                 if (FAILED(hr))
02132                 {
02133                     // get_PresentityURI failed
02134                     SAFE_FREE_STRING(bstrURI);
02135                     SAFE_RELEASE(pSession);
02136                     return;
02137                 }
02138
02139                 // Ring the bell
02140                 m_pClient->PlayRing(RTCRT_PHONE, VARIANT_TRUE);
02141
02142                 // Show the session dialog
02143                 BOOL fAccept;
02144
02145                 hr = ShowSessionDialog(m_hWnd, bstrName, bstrURI, &fAccept);
02146
02147                 SAFE_FREE_STRING(bstrURI);
02148                 SAFE_FREE_STRING(bstrName);
02149
02150                 if (FAILED(hr))
02151                 {
02152                     // ShowSessionDialog failed
02153                     SAFE_RELEASE(pSession);
02154                     return;
02155                 }
02156
02157                 if (fAccept)
02158                 {
02159                     // Accept the session
02160                     hr = pSession->Answer();
02161
02162                     if (FAILED(hr))
02163                     {
02164                         // Answer failed
02165                         SAFE_RELEASE(pSession);
02166                         return;
02167                     }
02168                 }
02169                 else
02170                 {
02171                     // Reject the session
02172                     pSession->Terminate(RTCTR_REJECT);
02173
02174                     SAFE_RELEASE(pSession);
02175                     return;
02176                 }
02177             }
02178
02179             // Add the session to the session list
02180             // This will create the session window
02181             hr = AddSession(pSession, enType);
02182
02183             if (FAILED(hr))
02184             {
02185                 // AddSession failed
02186                 SAFE_RELEASE(pSession);
02187                 return;
02188             }
02189         }
02190
02191         SAFE_RELEASE(pSession);
02192
02193         return;
02194     }
02195
02196     SAFE_RELEASE(pSession);
02197
02198     // Deliver the session state to the session window
02199     pSessWindow->DeliverSessionState(enState);
02200 }
02201
02202 /////////////////////////////////////////////
02203 //
02204 // CRTCWin::OnRTCParticipantStateChangeEvent
02205 //
02206
02207 void CRTCWin::OnRTCParticipantStateChangeEvent(
02208             IRTCParticipantStateChangeEvent *pEvent
02209             )
02210 {
02211     IRTCSession * pSession = NULL;
02212     CRTCSession * pSessWindow = NULL;
02213     IRTCParticipant * pParticipant = NULL;
02214     RTC_PARTICIPANT_STATE enState;
02215     HRESULT hr;
02216
02217     hr = pEvent->get_Participant(&pParticipant);
02218
02219     if (FAILED(hr))
02220     {
02221         // get_Participant failed
02222         return;
02223     }
02224
02225     hr = pParticipant->get_Session(&pSession);
02226
02227     if (FAILED(hr))
02228     {
02229         // get_Session failed
02230         SAFE_RELEASE(pParticipant);
02231         return;
02232     }
02233
02234     hr = FindSession(pSession, &pSessWindow);
02235
02236     SAFE_RELEASE(pSession);
02237
02238     if (FAILED(hr))
02239     {
02240         // FindSession failed
02241         SAFE_RELEASE(pParticipant);
02242         return;
02243     }
02244
02245     // Get the participant state
02246     hr = pEvent->get_State(&enState);
02247
02248     if (FAILED(hr))
02249     {
02250         // get_State failed
02251         SAFE_RELEASE(pParticipant);
02252         return;
02253     }
02254
02255     // Deliver the participant state to the session window
02256     pSessWindow->DeliverParticipantState(pParticipant, enState);
02257
02258     SAFE_RELEASE(pParticipant);
02259 }
02260
02261 /////////////////////////////////////////////
02262 //
02263 // CRTCWin::OnRTCMessagingEvent
02264 //
02265
02266 void CRTCWin::OnRTCMessagingEvent(
02267             IRTCMessagingEvent *pEvent
02268             )
02269 {
02270     IRTCSession * pSession = NULL;
02271     CRTCSession * pSessWindow = NULL;
02272     IRTCParticipant * pParticipant = NULL;
02273     RTC_MESSAGING_EVENT_TYPE enType;
02274     RTC_MESSAGING_USER_STATUS enStatus;
02275     BSTR bstrContentType = NULL;
02276     BSTR bstrMessage = NULL;
02277     HRESULT hr;
02278
02279     hr = pEvent->get_Session(&pSession);
02280
02281     if (FAILED(hr))
02282     {
02283         // get_Session failed
02284         return;
02285     }
02286
02287     hr = FindSession(pSession, &pSessWindow);
02288
02289     SAFE_RELEASE(pSession);
02290
02291     if (FAILED(hr))
02292     {
02293         // FindSession failed
02294         return;
02295     }
02296
02297     hr = pEvent->get_EventType(&enType);
02298
02299     if (FAILED(hr))
02300     {
02301         // get_EventType failed
02302         return;
02303     }
02304
02305     hr = pEvent->get_Participant(&pParticipant);
02306
02307     if (FAILED(hr))
02308     {
02309         // get_Participant failed
02310         return;
02311     }
02312
02313     if (enType == RTCMSET_MESSAGE)
02314     {
02315         hr = pEvent->get_MessageHeader(&bstrContentType);
02316
02317         if (FAILED(hr))
02318         {
02319             // get_MessageHeader failed
02320             SAFE_RELEASE(pParticipant);
02321             return;
02322         }
02323
02324         hr = pEvent->get_Message(&bstrMessage);
02325
02326         if (FAILED(hr))
02327         {
02328             // get_Message failed
02329             SAFE_RELEASE(pParticipant);
02330             SAFE_FREE_STRING(bstrContentType);
02331             return;
02332         }
02333
02334         // Deliver the message to the session window
02335         pSessWindow->DeliverMessage(pParticipant, bstrContentType, bstrMessage);
02336
02337         SAFE_FREE_STRING(bstrContentType);
02338         SAFE_FREE_STRING(bstrMessage);
02339     }
02340     else if (enType == RTCMSET_STATUS)
02341     {
02342         hr = pEvent->get_UserStatus(&enStatus);
02343
02344         if (FAILED(hr))
02345         {
02346             // get_UserStatus failed
02347             return;
02348         }
02349
02350         // Deliver the user status to the session window
02351         pSessWindow->DeliverUserStatus(pParticipant, enStatus);
02352     }
02353
02354     SAFE_RELEASE(pParticipant);
02355 }
02356
02357 /////////////////////////////////////////////
02358 //
02359 // CRTCWin::OnRTCMediaEvent
02360 //
02361
02362 void CRTCWin::OnRTCMediaEvent(
02363             IRTCMediaEvent *pEvent
02364             )
02365 {
02366     long lMediaType;
02367     RTC_MEDIA_EVENT_TYPE enType;
02368     RTC_MEDIA_EVENT_REASON enReason;
02369     HRESULT hr;
02370
02371     hr = pEvent->get_MediaType(&lMediaType);
02372
02373     if (FAILED(hr))
02374     {
02375         // get_MediaType failed
02376         return;
02377     }
02378
02379     hr = pEvent->get_EventType(&enType);
02380
02381     if (FAILED(hr))
02382     {
02383         // get_EventType failed
02384         return;
02385     }
02386
02387     hr = pEvent->get_EventReason(&enReason);
02388
02389     if (FAILED(hr))
02390     {
02391         // get_EventReason failed
02392         return;
02393     }
02394
02395     if (CRTCAVSession::m_Singleton != NULL)
02396     {
02397         // Deliver the media state to the session window
02398         (CRTCAVSession::m_Singleton)->DeliverMedia(lMediaType, enType, enReason);
02399     }
02400 }
02401
02402 /////////////////////////////////////////////
02403 //
02404 // CRTCWin::OnRTCIntensityEvent
02405 //
02406
02407 void CRTCWin::OnRTCIntensityEvent(
02408             IRTCIntensityEvent *pEvent
02409             )
02410 {
02411     RTC_AUDIO_DEVICE enDevice;
02412     long lLevel, lMin, lMax;
02413     HRESULT hr;
02414
02415     hr = pEvent->get_Direction(&enDevice);
02416
02417     if (FAILED(hr))
02418     {
02419         // get_Direction failed
02420         return;
02421     }
02422
02423     hr = pEvent->get_Level(&lLevel);
02424
02425     if (FAILED(hr))
02426     {
02427         // get_Level failed
02428         return;
02429     }
02430
02431     hr = pEvent->get_Min(&lMin);
02432
02433     if (FAILED(hr))
02434     {
02435         // get_Min failed
02436         return;
02437     }
02438
02439     hr = pEvent->get_Max(&lMax);
02440
02441     if (FAILED(hr))
02442     {
02443         // get_Max failed
02444         return;
02445     }
02446
02447     // Normalize level to between zero and 100
02448     if ((lMax - lMin) == 0)
02449     {
02450         lLevel = 0;
02451     }
02452     else
02453     {
02454         lLevel = (lLevel - lMin) * 100 / (lMax - lMin);
02455     }
02456
02457     if (CRTCAVSession::m_Singleton != NULL)
02458     {
02459         // Deliver the intensity state to the session window
02460         (CRTCAVSession::m_Singleton)->DeliverIntensity(enDevice, lLevel);
02461     }
02462 }
02463
02464 /////////////////////////////////////////////
02465 //
02466 // CRTCWin::OnRTCClientEvent
02467 //
02468
02469 void CRTCWin::OnRTCClientEvent(
02470             IRTCClientEvent *pEvent
02471             )
02472 {
02473     HRESULT hr;
02474
02475     // Get the client event tyoe
02476     RTC_CLIENT_EVENT_TYPE enEventType;
02477
02478     hr = pEvent->get_EventType(&enEventType);
02479
02480     if (FAILED(hr))
02481     {
02482         // get_EventType failed
02483         return;
02484     }
02485
02486     if ( enEventType == RTCCET_ASYNC_CLEANUP_DONE )
02487     {
02488         // The RTC client has finished preparing for
02489         // shutdown. Destroy the window now.
02490         DestroyWindow(m_hWnd);
02491     }
02492     else
02493     {
02494         if (CRTCAVSession::m_Singleton != NULL)
02495         {
02496             // Deliver the client state to the session window
02497             (CRTCAVSession::m_Singleton)->DeliverClient(enEventType);
02498         }
02499     }
02500 }
02501
02502 /////////////////////////////////////////////
02503 //
02504 // CRTCWin::OnRTCBuddyEvent
02505 //
02506
02507 void CRTCWin::OnRTCBuddyEvent(
02508             IRTCBuddyEvent *pEvent
02509             )
02510 {
02511     HRESULT hr;
02512
02513     // Get the buddy object
02514     IRTCBuddy * pBuddy = NULL;
02515
02516     hr = pEvent->get_Buddy(&pBuddy);
02517
02518     if (FAILED(hr))
02519     {
02520         // get_Buddy failed
02521         return;
02522     }
02523
02524     // Update the buddy list entry
02525     hr = UpdateBuddyList(pBuddy);
02526
02527     SAFE_RELEASE(pBuddy);
02528
02529     if (FAILED(hr))
02530     {
02531         // UpdateBuddyState failed
02532         return;
02533     }
02534 }
02535
02536 /////////////////////////////////////////////
02537 //
02538 // CRTCWin::OnRTCWatcherEvent
02539 //
02540
02541 void CRTCWin::OnRTCWatcherEvent(
02542             IRTCWatcherEvent *pEvent
02543             )
02544 {
02545     HRESULT hr;
02546
02547     // Get the watcher object
02548     IRTCWatcher * pWatcher = NULL;
02549
02550     hr = pEvent->get_Watcher(&pWatcher);
02551
02552     if (FAILED(hr))
02553     {
02554         // get_Watcher failed
02555         return;
02556     }
02557
02558     // Get the watcher URI
02559     BSTR bstrURI = NULL;
02560
02561     hr = pWatcher->get_PresentityURI(&bstrURI);
02562
02563     if (FAILED(hr))
02564     {
02565         // get_PresentityURI failed
02566         SAFE_RELEASE(pWatcher);
02567         return;
02568     }
02569
02570     // Get the watcher name
02571     BSTR bstrName = NULL;
02572
02573     hr = pWatcher->get_Name(&bstrName);
02574
02575     if (FAILED(hr))
02576     {
02577         // get_PresentityURI failed
02578         SAFE_FREE_STRING(bstrURI);
02579         SAFE_RELEASE(pWatcher);
02580         return;
02581     }
02582
02583     // Show the incoming watcher dialog
02584     BOOL fAllow, fAddBuddy;
02585
02586     hr = ShowWatcherDialog(m_hWnd, bstrName, bstrURI, &fAllow, &fAddBuddy);
02587
02588     if (FAILED(hr))
02589     {
02590         // ShowWatcherDialog failed
02591         SAFE_FREE_STRING(bstrURI);
02592         SAFE_FREE_STRING(bstrName);
02593         SAFE_RELEASE(pWatcher);
02594         return;
02595     }
02596
02597     // Set the watcher to be allowed or blocked
02598     hr = pWatcher->put_State(fAllow ? RTCWS_ALLOWED : RTCWS_BLOCKED);
02599
02600     SAFE_RELEASE(pWatcher);
02601
02602     if (FAILED(hr))
02603     {
02604         // put_State failed
02605         SAFE_FREE_STRING(bstrURI);
02606         SAFE_FREE_STRING(bstrName);
02607         return;
02608     }
02609
02610     // Shall we add the user as a buddy?
02611     if (fAddBuddy)
02612     {
02613         hr = DoAddBuddy(bstrURI, bstrName);
02614
02615         if (FAILED(hr))
02616         {
02617             // DoAddBuddy failed
02618             SAFE_FREE_STRING(bstrURI);
02619             SAFE_FREE_STRING(bstrName);
02620             return;
02621         }
02622     }
02623
02624     SAFE_FREE_STRING(bstrURI);
02625     SAFE_FREE_STRING(bstrName);
02626 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Encode/ALong.Cpp Source File

  • Security
  • CertServices
  • Encode

ALong.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        along.cpp
00007 //
00008 // Contents:    Cert Server Extension Encoding/Decoding implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013
00014 #pragma hdrstop
00015
00016 #include <assert.h>
00017 #include "resource.h"
00018 #include "along.h"
00019 #include "celib.h"
00020
00021
00022 //+--------------------------------------------------------------------------
00023 // CCertEncodeLongArray::~CCertEncodeLongArray -- destructor
00024 //
00025 // free memory associated with this instance
00026 //+--------------------------------------------------------------------------
00027
00028 CCertEncodeLongArray::~CCertEncodeLongArray()
00029 {
00030     _Cleanup();
00031 }
00032
00033
00034 //+--------------------------------------------------------------------------
00035 // CCertEncodeLongArray::_Cleanup -- release all resources
00036 //
00037 // free memory associated with this instance
00038 //+--------------------------------------------------------------------------
00039
00040 VOID
00041 CCertEncodeLongArray::_Cleanup()
00042 {
00043     if (NULL != m_aValue)
00044     {
00045   LocalFree(m_aValue);
00046   m_aValue = NULL;
00047     }
00048     m_cValue = 0;
00049     m_cValuesSet = 0;
00050     m_fConstructing = FALSE;
00051 }
00052
00053
00054 //+--------------------------------------------------------------------------
00055 // CCertEncodeLongArray::Decode -- Decode LongArray
00056 //
00057 // Returns S_OK on success.
00058 //+--------------------------------------------------------------------------
00059
00060 STDMETHODIMP
00061 CCertEncodeLongArray::Decode(
00062     /* [in] */ BSTR const strBinary)
00063 {
00064     HRESULT hr = S_OK;
00065     CRYPT_SEQUENCE_OF_ANY *pSequence = NULL;
00066     DWORD cbSequence;
00067     LONG i;
00068
00069     _Cleanup();
00070
00071     if (NULL == strBinary)
00072     {
00073   hr = E_POINTER;
00074   ceERRORPRINTLINE("NULL parm", hr);
00075   goto error;
00076     }
00077
00078     // Decode to an array of ASN blobs:
00079
00080     if (!ceDecodeObject(
00081         X509_ASN_ENCODING,
00082         X509_SEQUENCE_OF_ANY,
00083         (BYTE *) strBinary,
00084         SysStringByteLen(strBinary),
00085         FALSE,
00086         (VOID **) &pSequence,
00087         &cbSequence))
00088     {
00089   hr = ceHLastError();
00090   ceERRORPRINTLINE("ceDecodeObject", hr);
00091   goto error;
00092     }
00093
00094     m_cValue = pSequence->cValue;
00095     m_aValue = (LONG *) LocalAlloc(LMEM_FIXED, m_cValue * sizeof(m_aValue[0]));
00096     if (NULL == m_aValue)
00097     {
00098   hr = E_OUTOFMEMORY;
00099   ceERRORPRINTLINE("LocalAlloc", hr);
00100   goto error;
00101     }
00102     for (i = 0; i < m_cValue; i++)
00103     {
00104   DWORD cb;
00105
00106   // Decode each ASN blob to an integer:
00107
00108   cb = sizeof(m_aValue[i]);
00109   if (!CryptDecodeObject(
00110       X509_ASN_ENCODING,
00111       X509_INTEGER,
00112       pSequence->rgValue[i].pbData,
00113       pSequence->rgValue[i].cbData,
00114       0,                  // dwFlags
00115       (VOID *) &m_aValue[i],
00116       &cb))
00117   {
00118       hr = ceHLastError();
00119       ceERRORPRINTLINE("CryptDecodeObject", hr);
00120       goto error;
00121   }
00122   assert(sizeof(m_aValue[i]) == cb);
00123     }
00124
00125 error:
00126     if (NULL != pSequence)
00127     {
00128   LocalFree(pSequence);
00129     }
00130     if (S_OK != hr)
00131     {
00132   _Cleanup();
00133     }
00134     return(_SetErrorInfo(hr, L"CCertEncodeLongArray::Decode"));
00135 }
00136
00137
00138 //+--------------------------------------------------------------------------
00139 // CCertEncodeLongArray::GetCount -- Get Array count
00140 //
00141 // Returns S_OK on success.
00142 //+--------------------------------------------------------------------------
00143
00144 STDMETHODIMP
00145 CCertEncodeLongArray::GetCount(
00146     /* [out, retval] */ LONG __RPC_FAR *pCount)
00147 {
00148     HRESULT hr = S_OK;
00149
00150     if (NULL == pCount)
00151     {
00152   hr = E_POINTER;
00153   ceERRORPRINTLINE("NULL parm", hr);
00154   goto error;
00155     }
00156     if (NULL == m_aValue)
00157     {
00158   hr = E_INVALIDARG;
00159   ceERRORPRINTLINE("bad parameter", hr);
00160   goto error;
00161     }
00162     *pCount = m_cValue;
00163 error:
00164     return(_SetErrorInfo(hr, L"CCertEncodeLongArray::GetCount"));
00165 }
00166
00167
00168 //+--------------------------------------------------------------------------
00169 // CCertEncodeLongArray::GetValue -- Fetch the indexed long
00170 //
00171 // Returns S_OK on success.
00172 //+--------------------------------------------------------------------------
00173
00174 STDMETHODIMP
00175 CCertEncodeLongArray::GetValue(
00176     /* [in] */ LONG Index,
00177     /* [out, retval] */ LONG __RPC_FAR *pValue)
00178 {
00179     HRESULT hr = S_OK;
00180     BYTE *pb;
00181
00182     if (NULL == pValue)
00183     {
00184   hr = E_POINTER;
00185   ceERRORPRINTLINE("NULL parm", hr);
00186   goto error;
00187     }
00188     if (NULL == m_aValue || Index >= m_cValue)
00189     {
00190   hr = E_INVALIDARG;
00191   ceERRORPRINTLINE("bad parameter", hr);
00192   goto error;
00193     }
00194
00195     // Bitmap only exists when constrcuting!
00196
00197     if (m_fConstructing)
00198     {
00199   pb = (BYTE *) &m_aValue[m_cValue];
00200   if (!GETBIT(pb, Index))
00201   {
00202       hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
00203       ceERRORPRINTLINE("uninitialized", hr);
00204       goto error;
00205   }
00206     }
00207     *pValue = m_aValue[Index];
00208
00209 error:
00210     return(_SetErrorInfo(hr, L"CCertEncodeLongArray::GetValue"));
00211 }
00212
00213
00214 //+--------------------------------------------------------------------------
00215 // CCertEncodeLongArray::Reset -- clear out data, and set up to encode new data
00216 //
00217 // Returns S_OK on success.
00218 //+--------------------------------------------------------------------------
00219
00220 STDMETHODIMP
00221 CCertEncodeLongArray::Reset(
00222     /* [in] */ LONG Count)
00223 {
00224     HRESULT hr = S_OK;
00225     DWORD cbAlloc;
00226
00227     _Cleanup();
00228     m_fConstructing = TRUE;
00229     if (CENCODEMAX < Count || 0 > Count)
00230     {
00231   hr = E_INVALIDARG;
00232   ceERRORPRINTLINE("bad count parameter", hr);
00233   goto error;
00234     }
00235     cbAlloc = Count * sizeof(m_aValue[0]) + BITSTOBYTES(Count);
00236     m_aValue = (LONG *) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, cbAlloc);
00237     if (NULL == m_aValue)
00238     {
00239   hr = E_OUTOFMEMORY;
00240   ceERRORPRINTLINE("LocalAlloc", hr);
00241   goto error;
00242     }
00243     m_cValue = Count;
00244
00245 error:
00246     return(_SetErrorInfo(hr, L"CCertEncodeLongArray::Reset"));
00247 }
00248
00249
00250 //+--------------------------------------------------------------------------
00251 // CCertEncodeLongArray::SetValue -- Set an array long
00252 //
00253 // Returns S_OK on success.
00254 //+--------------------------------------------------------------------------
00255
00256 STDMETHODIMP
00257 CCertEncodeLongArray::SetValue(
00258     /* [in] */ LONG Index,
00259     /* [in] */ LONG Value)
00260 {
00261     HRESULT hr = S_OK;
00262     BYTE *pb;
00263
00264     if (!m_fConstructing ||
00265   NULL == m_aValue ||
00266   Index >= m_cValue ||
00267   m_cValuesSet >= m_cValue)
00268     {
00269   hr = E_INVALIDARG;
00270   ceERRORPRINTLINE("bad parameter", hr);
00271   goto error;
00272     }
00273     pb = (BYTE *) &m_aValue[m_cValue];
00274     if (GETBIT(pb, Index))
00275     {
00276   hr = E_INVALIDARG;
00277   ceERRORPRINTLINE("already set", hr);
00278   goto error;
00279     }
00280     SETBIT(pb, Index);
00281     m_aValue[Index] = Value;
00282     m_cValuesSet++;
00283
00284 error:
00285     return(_SetErrorInfo(hr, L"CCertEncodeLongArray::SetValue"));
00286 }
00287
00288
00289 //+--------------------------------------------------------------------------
00290 // CCertEncodeLongArray::Encode -- Encode LongArray
00291 //
00292 // Returns S_OK on success.
00293 //+--------------------------------------------------------------------------
00294
00295 STDMETHODIMP
00296 CCertEncodeLongArray::Encode(
00297     /* [out, retval] */ BSTR __RPC_FAR *pstrBinary)
00298 {
00299     HRESULT hr = S_OK;
00300     LONG i;
00301     CRYPT_SEQUENCE_OF_ANY Sequence;
00302     BYTE *pbEncoded = NULL;
00303     DWORD cbEncoded;
00304
00305     Sequence.cValue = 0;
00306     Sequence.rgValue = NULL;
00307
00308     if (NULL == pstrBinary)
00309     {
00310   hr = E_POINTER;
00311   ceERRORPRINTLINE("NULL parm", hr);
00312   goto error;
00313     }
00314     ceFreeBstr(pstrBinary);
00315     if (!m_fConstructing || NULL == m_aValue)
00316     {
00317   hr = E_INVALIDARG;
00318   ceERRORPRINTLINE("bad parameter", hr);
00319   goto error;
00320     }
00321     if (m_cValuesSet != m_cValue)
00322     {
00323   hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00324   ceERRORPRINTLINE("m_cValuesSet", hr);
00325   goto error;
00326     }
00327
00328     Sequence.rgValue = (CRYPT_DER_BLOB *) LocalAlloc(
00329             LMEM_FIXED,
00330             m_cValue * sizeof(Sequence.rgValue[0]));
00331     if (NULL == Sequence.rgValue)
00332     {
00333   hr = E_OUTOFMEMORY;
00334   ceERRORPRINTLINE("LocalAlloc", hr);
00335   goto error;
00336     }
00337
00338     for (i = 0; i < m_cValue; i++)
00339     {
00340   // Encode each integer into an ASN blob:
00341
00342   if (!ceEncodeObject(
00343       X509_ASN_ENCODING,
00344       X509_INTEGER,
00345       &m_aValue[i],
00346       0,
00347       FALSE,
00348       &Sequence.rgValue[i].pbData,
00349       &Sequence.rgValue[i].cbData))
00350   {
00351       hr = ceHLastError();
00352       ceERRORPRINTLINE("ceEncodeObject", hr);
00353       goto error;
00354   }
00355   Sequence.cValue++;
00356     }
00357     assert((LONG) Sequence.cValue == m_cValue);
00358
00359     // Encode each integer into an ASN blob:
00360
00361     if (!ceEncodeObject(
00362         X509_ASN_ENCODING,
00363         X509_SEQUENCE_OF_ANY,
00364         &Sequence,
00365         0,
00366         FALSE,
00367         &pbEncoded,
00368         &cbEncoded))
00369     {
00370   hr = ceHLastError();
00371   ceERRORPRINTLINE("ceEncodeObject", hr);
00372   goto error;
00373     }
00374     if (!ceConvertWszToBstr(
00375       pstrBinary,
00376       (WCHAR const *) pbEncoded,
00377       cbEncoded))
00378     {
00379   hr = E_OUTOFMEMORY;
00380   ceERRORPRINTLINE("ceConvertWszToBstr", hr);
00381   goto error;
00382     }
00383
00384 error:
00385     if (NULL != pbEncoded)
00386     {
00387   LocalFree(pbEncoded);
00388     }
00389     if (NULL != Sequence.rgValue)
00390     {
00391   assert((LONG) Sequence.cValue <= m_cValue);
00392   for (i = 0; i < (LONG) Sequence.cValue; i++)
00393   {
00394       assert(NULL != Sequence.rgValue[i].pbData);
00395       LocalFree(Sequence.rgValue[i].pbData);
00396   }
00397   LocalFree(Sequence.rgValue);
00398     }
00399     return(_SetErrorInfo(hr, L"CCertEncodeLongArray::Encode"));
00400 }
00401
00402
00403 //+--------------------------------------------------------------------------
00404 // CCertEncodeLongArray::_SetErrorInfo -- set error object information
00405 //
00406 // Returns passed HRESULT
00407 //+--------------------------------------------------------------------------
00408
00409 HRESULT
00410 CCertEncodeLongArray::_SetErrorInfo(
00411     IN HRESULT hrError,
00412     IN WCHAR const *pwszDescription)
00413 {
00414     assert(FAILED(hrError) || S_OK == hrError || S_FALSE == hrError);
00415     if (FAILED(hrError))
00416     {
00417   HRESULT hr;
00418
00419   hr = ceDispatchSetErrorInfo(
00420           hrError,
00421           pwszDescription,
00422           wszCLASS_CERTENCODELONGARRAY,
00423           &IID_ICertEncodeLongArray);
00424   assert(hr == hrError);
00425     }
00426     return(hrError);
00427 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/basesnap.h Source File

  • SysMgmt
  • MMC
  • Proppage

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/idt.Cpp Source File

  • Com
  • Fundamentals
  • SimpDnd

idt.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IDT.CPP
00003 //
00004 //      Implementation file for CDropTarget
00005 //
00006 // Functions:
00007 //
00008 //      See IDT.H for class definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "app.h"
00017 #include "site.h"
00018 #include "doc.h"
00019 #include "idt.h"
00020
00021 extern CLIPFORMAT g_cfObjectDescriptor;
00022
00023
00024 //**********************************************************************
00025 //
00026 // CDropTarget::QueryDrop
00027 //
00028 // Purpose:
00029 //
00030 //      Check if the desired drop operation (identified by the given key
00031 //      state) is possible at the current mouse position (pointl).
00032 //
00033 // Parameters:
00034 //
00035 //      DWORD grfKeyState       - current key state
00036 //      POINTL pointl           - position of mouse
00037 //      BOOL fDragScroll        - TRUE if drag scrolling cursor should
00038 //                                be shown.
00039 //      LPDWORD pdwEffect       - (OUT) drag effect that should occur
00040 //
00041 // Return Value:
00042 //
00043 //      BOOL                    - TRUE if drop could take place,
00044 //                                else FALSE
00045 //
00046 // Function Calls:
00047 //      Function                    Location
00048 //
00049 //      OleStdGetDropEffect         OLESTD API
00050 //
00051 // Comments:
00052 //
00053 //********************************************************************
00054
00055 BOOL CDropTarget::QueryDrop (
00056         DWORD           grfKeyState,
00057         POINTL          pointl,
00058         BOOL            fDragScroll,
00059         LPDWORD         pdwEffect
00060 )
00061 {
00062         DWORD      dwScrollEffect = 0L;
00063         DWORD      dwOKEffects = *pdwEffect;
00064
00065         /* check if the cursor is in the active scroll area, if so need the
00066         **    special scroll cursor.
00067         */
00068         if (fDragScroll)
00069                 dwScrollEffect = DROPEFFECT_SCROLL;
00070
00071         /* if we have already determined that the source does NOT have any
00072         **    acceptable data for us, the return NO-DROP
00073         */
00074         if (! m_fCanDropCopy && ! m_fCanDropLink)
00075                 goto dropeffect_none;
00076
00077         /* OLE2NOTE: determine what type of drop should be performed given
00078         **    the current modifier key state. we rely on the standard
00079         **    interpretation of the modifier keys:
00080         **          no modifier -- DROPEFFECT_MOVE or whatever is allowed by src
00081         **          SHIFT       -- DROPEFFECT_MOVE
00082         **          CTRL        -- DROPEFFECT_COPY
00083         **          CTRL-SHIFT  -- DROPEFFECT_LINK
00084         */
00085
00086         *pdwEffect = OleStdGetDropEffect(grfKeyState);
00087         if (*pdwEffect == 0) {
00088                 // No modifier keys given. Try in order MOVE, COPY, LINK.
00089                 if ((DROPEFFECT_MOVE & dwOKEffects) && m_fCanDropCopy)
00090                         *pdwEffect = DROPEFFECT_MOVE;
00091                 else if ((DROPEFFECT_COPY & dwOKEffects) && m_fCanDropCopy)
00092                         *pdwEffect = DROPEFFECT_COPY;
00093                 else if ((DROPEFFECT_LINK & dwOKEffects) && m_fCanDropLink)
00094                         *pdwEffect = DROPEFFECT_LINK;
00095                 else
00096                         goto dropeffect_none;
00097         } else {
00098                 /* OLE2NOTE: we should check if the drag source application allows
00099                 **    the desired drop effect.
00100                 */
00101                 if (!(*pdwEffect & dwOKEffects))
00102                         goto dropeffect_none;
00103
00104                 if ((*pdwEffect == DROPEFFECT_COPY || *pdwEffect == DROPEFFECT_MOVE)
00105                                 && ! m_fCanDropCopy)
00106                         goto dropeffect_none;
00107
00108                 if (*pdwEffect == DROPEFFECT_LINK && ! m_fCanDropLink)
00109                         goto dropeffect_none;
00110         }
00111
00112         *pdwEffect |= dwScrollEffect;
00113         return TRUE;
00114
00115 dropeffect_none:
00116
00117         *pdwEffect = DROPEFFECT_NONE;
00118         return FALSE;
00119 }
00120
00121
00122 //**********************************************************************
00123 //
00124 // CDropTarget::QueryDrop
00125 //
00126 // Purpose:
00127 //
00128 //     Check to see if Drag scroll operation should be initiated.
00129 //
00130 // Parameters:
00131 //
00132 //      POINTL pointl           - position of mouse
00133 //
00134 // Return Value:
00135 //
00136 //      BOOL                    - TRUE if scroll cursor should be given
00137 //                                else FALSE
00138 //
00139 // Function Calls:
00140 //      Function                    Location
00141 //
00142 //      ScreenToClient              WINDOWS API
00143 //      GetClientRect               WINDOWS API
00144 //
00145 // Comments:
00146 //     A Drag scroll operation should be initiated when the mouse has
00147 //     remained in the active scroll area (11 pixels frame around border
00148 //     of window) for a specified amount of time (50ms).
00149 //
00150 //********************************************************************
00151
00152 BOOL CDropTarget::DoDragScroll (POINTL pointl)
00153 {
00154         DWORD dwScrollDir = SCROLLDIR_NULL;
00155         DWORD dwTime = GetCurrentTime();
00156         int nScrollInset = m_pDoc->m_lpApp->m_nScrollInset;
00157         int nScrollDelay = m_pDoc->m_lpApp->m_nScrollDelay;
00158         int nScrollInterval = m_pDoc->m_lpApp->m_nScrollInterval;
00159         POINT point;
00160         RECT rect;
00161
00162         point.x = (int)pointl.x;
00163         point.y = (int)pointl.y;
00164
00165         ScreenToClient( m_pDoc->m_hDocWnd, &point);
00166         GetClientRect ( m_pDoc->m_hDocWnd, (LPRECT) &rect );
00167
00168         if (rect.top <= point.y && point.y<=(rect.top+nScrollInset))
00169                 dwScrollDir = SCROLLDIR_UP;
00170         else if ((rect.bottom-nScrollInset) <= point.y && point.y <= rect.bottom)
00171                 dwScrollDir = SCROLLDIR_DOWN;
00172         else if (rect.left <= point.x && point.x <= (rect.left+nScrollInset))
00173                 dwScrollDir = SCROLLDIR_LEFT;
00174         else if ((rect.right-nScrollInset) <= point.x && point.x <= rect.right)
00175                 dwScrollDir = SCROLLDIR_RIGHT;
00176
00177         if (m_dwTimeEnterScrollArea) {
00178
00179                 /* cursor was already in Scroll Area */
00180
00181                 if (! dwScrollDir) {
00182                         /* cusor moved OUT of scroll area.
00183                         **      clear "EnterScrollArea" time.
00184                         */
00185                         m_dwTimeEnterScrollArea = 0L;
00186                         m_dwNextScrollTime = 0L;
00187                         m_dwLastScrollDir = SCROLLDIR_NULL;
00188
00189                 } else if (dwScrollDir != m_dwLastScrollDir) {
00190                         /* cusor moved into a different direction scroll area.
00191                         **      reset "EnterScrollArea" time to start a new 50ms delay.
00192                         */
00193                         m_dwTimeEnterScrollArea = dwTime;
00194                         m_dwNextScrollTime = dwTime + (DWORD)nScrollDelay;
00195                         m_dwLastScrollDir = dwScrollDir;
00196
00197                 } else if (dwTime && dwTime >= m_dwNextScrollTime) {
00198                         m_pDoc->Scroll ( dwScrollDir );    // Scroll document now
00199                         m_dwNextScrollTime = dwTime + (DWORD)nScrollInterval;
00200                 }
00201         } else {
00202                 if (dwScrollDir) {
00203                         /* cusor moved INTO a scroll area.
00204                         **      reset "EnterScrollArea" time to start a new 50ms delay.
00205                         */
00206                         m_dwTimeEnterScrollArea = dwTime;
00207                         m_dwNextScrollTime = dwTime + (DWORD)nScrollDelay;
00208                         m_dwLastScrollDir = dwScrollDir;
00209                 }
00210         }
00211
00212         return (dwScrollDir ? TRUE : FALSE);
00213 }
00214
00215
00216 // Support functions/macros
00217 #define SetTopLeft(rc, pt)      \
00218         ((rc)->top = (pt)->y,(rc)->left = (pt)->x)
00219 #define SetBottomRight(rc, pt)      \
00220         ((rc)->bottom = (pt)->y,(rc)->right = (pt)->x)
00221 #define OffsetPoint(pt, dx, dy)     \
00222         ((pt)->x += dx, (pt)->y += dy)
00223
00224
00225 /* HighlightRect
00226 ** -------------
00227 **    Invert rectangle on screen. used for drop target feedback.
00228 */
00229
00230 static int HighlightRect(HWND hwnd, HDC hdc, LPRECT rc)
00231 {
00232         POINT pt1, pt2;
00233         int old = SetROP2(hdc, R2_NOT);
00234         HPEN hpen;
00235         HGDIOBJ hold;
00236
00237         pt1.x = rc->left;
00238         pt1.y = rc->top;
00239         pt2.x = rc->right;
00240         pt2.y = rc->bottom;
00241
00242         ScreenToClient(hwnd, &pt1);
00243         ScreenToClient(hwnd, &pt2);
00244
00245         hold = SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
00246         hpen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 2,
00247                                                   GetSysColor(COLOR_ACTIVEBORDER)));
00248
00249         Rectangle(hdc, pt1.x, pt1.y, pt2.x, pt2.y);
00250
00251         SetROP2(hdc, old);
00252
00253         hold = SelectObject(hdc, hold);
00254         hpen = (HPEN) SelectObject(hdc, hpen);
00255
00256         DeleteObject(hpen);
00257
00258   return 0;
00259 }
00260
00261
00262 //**********************************************************************
00263 //
00264 // CDropTarget::InitDragFeedback
00265 //
00266 // Purpose:
00267 //
00268 //      Initialize data used to draw drop target feedback.
00269 //      As feedback we draw a rectangle the size of the object.
00270 //
00271 // Parameters:
00272 //
00273 //      LPDATAOBJECT pDataObj   - IDataObject from Drop source
00274 //      POINTL pointl           - position of mouse
00275 //
00276 // Return Value:
00277 //
00278 //      none.
00279 //
00280 // Function Calls:
00281 //      Function                    Location
00282 //
00283 //      IDataObject::GetData        Object
00284 //      XformSizeInHimetricToPixels OLESTD Library
00285 //      GlobalLock                  WINDOWS API
00286 //      GlobalUnlock                WINDOWS API
00287 //      ReleaseStgMedium            OLE2 API
00288 //      OffsetPoint                 IDT.CPP
00289 //      SetTopLeft                  IDT.CPP
00290 //      SetBottomRight              IDT.CPP
00291 //
00292 // Comments:
00293 //      In order to known the size of the object before the object
00294 //      is actually dropped, we render CF_OBJECTDESCRIPTOR format.
00295 //      this data format tells us both the size of the object as
00296 //      well as which aspect is the object is displayed as in the
00297 //      source. if the object is currently displayed as DVASPECT_ICON
00298 //      then we want to create the object also as DVASPECT_ICON.
00299 //
00300 //********************************************************************
00301
00302 void CDropTarget::InitDragFeedback(LPDATAOBJECT pDataObj, POINTL pointl)
00303 {
00304         FORMATETC fmtetc;
00305         STGMEDIUM stgmed;
00306         POINT pt;
00307         int height, width;
00308         HRESULT hrErr;
00309
00310         height = width = 100; // some default values
00311         pt.x = (int)pointl.x;
00312         pt.y = (int)pointl.y;
00313
00314         // do a GetData for CF_OBJECTDESCRIPTOR format to get the size of the
00315         // object as displayed in the source. using this size, initialize the
00316         // size for the drag feedback rectangle.
00317         fmtetc.cfFormat = g_cfObjectDescriptor;
00318         fmtetc.ptd = NULL;
00319         fmtetc.lindex = -1;
00320         fmtetc.dwAspect = DVASPECT_CONTENT;
00321         fmtetc.tymed = TYMED_HGLOBAL;
00322
00323         hrErr = pDataObj->GetData(&fmtetc, &stgmed);
00324         if (hrErr == NOERROR) {
00325                 LPOBJECTDESCRIPTOR pOD=(LPOBJECTDESCRIPTOR)GlobalLock(stgmed.hGlobal);
00326                 if (pOD != NULL) {
00327                         XformSizeInHimetricToPixels(NULL, &pOD->sizel, &pOD->sizel);
00328
00329                         width = (int)pOD->sizel.cx;
00330                         height = (int)pOD->sizel.cy;
00331                         m_dwSrcAspect = pOD->dwDrawAspect;
00332                 }
00333
00334                 GlobalUnlock(stgmed.hGlobal);
00335                 ReleaseStgMedium(&stgmed);
00336         }
00337
00338         m_ptLast = pt;
00339         m_fDragFeedbackDrawn = FALSE;
00340
00341         OffsetPoint(&pt, -(width/2), -(height/2));
00342         SetTopLeft(&m_rcDragRect, &pt);
00343
00344         OffsetPoint(&pt, width, height);
00345         SetBottomRight(&m_rcDragRect, &pt);
00346 }
00347
00348
00349 //**********************************************************************
00350 //
00351 // CDropTarget::UndrawDragFeedback
00352 //
00353 // Purpose:
00354 //
00355 //      Erase any drop target feedback.
00356 //      As feedback we draw a rectangle the size of the object.
00357 //
00358 // Parameters:
00359 //
00360 //      none.
00361 //
00362 // Return Value:
00363 //
00364 //      none.
00365 //
00366 // Function Calls:
00367 //      Function                    Location
00368 //
00369 //      GetDC                       WINDOWS API
00370 //      ReleaseDC                   WINDOWS API
00371 //      GlobalUnlock                WINDOWS API
00372 //      HighlightRect               IDT.CPP
00373 //
00374 // Comments:
00375 //      In order to known the size of the object before the object
00376 //      is actually dropped, we render CF_OBJECTDESCRIPTOR format.
00377 //      this data format tells us both the size of the object as
00378 //      well as which aspect is the object is displayed as in the
00379 //      source. if the object is currently displayed as DVASPECT_ICON
00380 //      then we want to create the object also as DVASPECT_ICON.
00381 //
00382 //********************************************************************
00383
00384 void CDropTarget::UndrawDragFeedback( void )
00385 {
00386         if (m_fDragFeedbackDrawn) {
00387                 m_fDragFeedbackDrawn = FALSE;
00388                 HDC hDC = GetDC(m_pDoc->m_hDocWnd);
00389                 HighlightRect(m_pDoc->m_hDocWnd, hDC, &m_rcDragRect);
00390                 ReleaseDC(m_pDoc->m_hDocWnd, hDC);
00391         }
00392 }
00393
00394
00395 //**********************************************************************
00396 //
00397 // CDropTarget::DrawDragFeedback
00398 //
00399 // Purpose:
00400 //
00401 //      Compute new position of drop target feedback rectangle and
00402 //      erase old rectangle and draw new rectangle.
00403 //      As feedback we draw a rectangle the size of the object.
00404 //
00405 // Parameters:
00406 //
00407 //      POINTL pointl           - position of mouse
00408 //
00409 // Return Value:
00410 //
00411 //      none.
00412 //
00413 // Function Calls:
00414 //      Function                    Location
00415 //
00416 //      OffsetPoint                 IDT.CPP
00417 //      HighlightRect               IDT.CPP
00418 //      GetDC                       WINDOWS API
00419 //      ReleaseDC                   WINDOWS API
00420 //
00421 // Comments:
00422 //
00423 //********************************************************************
00424
00425 void CDropTarget::DrawDragFeedback( POINTL pointl )
00426 {
00427         POINT ptDiff;
00428
00429         ptDiff.x = (int)pointl.x - m_ptLast.x;
00430         ptDiff.y = (int)pointl.y - m_ptLast.y;
00431
00432         if (m_fDragFeedbackDrawn && (ptDiff.x == 0 && ptDiff.y == 0))
00433                 return;     // mouse did not move; leave rectangle as drawn
00434
00435         HDC hDC = GetDC(m_pDoc->m_hDocWnd);
00436         if (m_fDragFeedbackDrawn) {
00437                 m_fDragFeedbackDrawn = FALSE;
00438                 HighlightRect(m_pDoc->m_hDocWnd, hDC, &m_rcDragRect);
00439         }
00440
00441         OffsetRect(&m_rcDragRect, ptDiff.x, ptDiff.y);
00442         HighlightRect(m_pDoc->m_hDocWnd, hDC, &m_rcDragRect);
00443         m_fDragFeedbackDrawn = TRUE;
00444         m_ptLast.x = (int)pointl.x;
00445         m_ptLast.y = (int)pointl.y;
00446         ReleaseDC(m_pDoc->m_hDocWnd, hDC);
00447 }
00448
00449
00450 //**********************************************************************
00451 //
00452 // CDropTarget::QueryInterface
00453 //
00454 // Purpose:
00455 //
00456 //      Return a pointer to a requested interface
00457 //
00458 // Parameters:
00459 //
00460 //      REFIID riid         -   ID of interface to be returned
00461 //      LPVOID FAR* ppvObj  -   Location to return the interface
00462 //
00463 // Return Value:
00464 //
00465 //      S_OK                -   Interface supported
00466 //      E_NOINTERFACE       -   Interface NOT supported
00467 //
00468 // Function Calls:
00469 //      Function                    Location
00470 //
00471 //      OutputDebugString           Windows API
00472 //      CSimpleDoc::QueryInterface  DOC.CPP
00473 //
00474 // Comments:
00475 //
00476 //********************************************************************
00477
00478 STDMETHODIMP CDropTarget::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00479 {
00480         OutputDebugString("In IDT::QueryInterface\r\n");
00481
00482         // delegate to the document
00483         return m_pDoc->QueryInterface(riid, ppvObj);
00484 }
00485
00486
00487 //**********************************************************************
00488 //
00489 // CDropTarget::AddRef
00490 //
00491 // Purpose:
00492 //
00493 //      Increments the reference count on this interface
00494 //
00495 // Parameters:
00496 //
00497 //      None
00498 //
00499 // Return Value:
00500 //
00501 //      The current reference count on this interface.
00502 //
00503 // Function Calls:
00504 //      Function                    Location
00505 //
00506 //      CSimpleDoc::AddReff         DOC.CPP
00507 //      OutputDebugString           Windows API
00508 //
00509 // Comments:
00510 //
00511 //      This function adds one to the ref count of the interface,
00512 //      and calls then calls CSimpleObj to increment its ref.
00513 //      count.
00514 //
00515 //********************************************************************
00516
00517 STDMETHODIMP_(ULONG) CDropTarget::AddRef()
00518 {
00519         OutputDebugString("In IDT::AddRef\r\n");
00520
00521         // increment the interface reference count (for debugging only)
00522         ++m_nCount;
00523
00524         // delegate to the document Object
00525         return m_pDoc->AddRef();
00526 }
00527
00528 //**********************************************************************
00529 //
00530 // CDropTarget::Release
00531 //
00532 // Purpose:
00533 //
00534 //      Decrements the reference count on this interface
00535 //
00536 // Parameters:
00537 //
00538 //      None
00539 //
00540 // Return Value:
00541 //
00542 //      The current reference count on this interface.
00543 //
00544 // Function Calls:
00545 //      Function                    Location
00546 //
00547 //      CSimpleDoc::Release         DOC.CPP
00548 //      OutputDebugString           Windows API
00549 //
00550 // Comments:
00551 //
00552 //      This function subtracts one from the ref count of the interface,
00553 //      and calls then calls CSimpleDoc to decrement its ref.
00554 //      count.
00555 //
00556 //********************************************************************
00557
00558 STDMETHODIMP_(ULONG) CDropTarget::Release()
00559 {
00560         OutputDebugString("In IDT::Release\r\n");
00561
00562         // decrement the interface reference count (for debugging only)
00563         --m_nCount;
00564
00565         // delegate to the document object
00566         return m_pDoc->Release();
00567 }
00568
00569
00570 //**********************************************************************
00571 //
00572 // CDropTarget::DragEnter
00573 //
00574 // Purpose:
00575 //
00576 //      Called when the mouse first enters our DropTarget window
00577 //
00578 // Parameters:
00579 //
00580 //      LPDATAOBJECT pDataObj   - IDataObject from Drop source
00581 //      DWORD grfKeyState       - current key state
00582 //      POINTL pointl           - position of mouse
00583 //      LPDWORD pdwEffect       - (IN-OUT) drag effect that should occur
00584 //                                ON INPUT, this is dwOKEffects that source
00585 //                                passed to DoDragDrop API.
00586 //                                ON OUTPUT, this is the effect that we
00587 //                                want to take effect (used to determine
00588 //                                cursor feedback).
00589 //
00590 // Return Value:
00591 //
00592 //      S_OK
00593 //
00594 // Function Calls:
00595 //      Function                    Location
00596 //
00597 //      OutputDebugString           Windows API
00598 //      OleQueryCreateFromData      OLE2 API
00599 //      DoDragScroll                IDT.CPP
00600 //      QueryDrop                   IDT.CPP
00601 //      InitDragFeedback            IDT.CPP
00602 //      DrawDragFeedback            IDT.CPP
00603 //      UndrawDragFeedback          IDT.CPP
00604 //
00605 // Comments:
00606 //      Callee should honor the dwEffects as passed in to determine
00607 //      if the caller allows DROPEFFECT_MOVE.
00608 //
00609 //********************************************************************
00610
00611 STDMETHODIMP CDropTarget::DragEnter (LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pointl, LPDWORD pdwEffect)
00612 {
00613         OutputDebugString("In IDT::DragEnter\r\n");
00614
00615         /* Determine if the drag source data object offers a data format
00616         **  that we understand. we accept only creating embedded objects.
00617         */
00618         m_fCanDropCopy = ((OleQueryCreateFromData(pDataObj) == NOERROR) ?
00619                         TRUE : FALSE);
00620         m_fCanDropLink = FALSE; // linking NOT supported in this simple sample
00621
00622         if (m_fCanDropCopy || m_fCanDropLink)
00623                 InitDragFeedback(pDataObj, pointl);
00624
00625         BOOL fDragScroll = DoDragScroll ( pointl );
00626
00627         if (QueryDrop(grfKeyState,pointl,fDragScroll,pdwEffect))
00628                 DrawDragFeedback( pointl );
00629
00630         return NOERROR;
00631 }
00632
00633
00634 //**********************************************************************
00635 //
00636 // CDropTarget::DragOver
00637 //
00638 // Purpose:
00639 //
00640 //      Called when the mouse moves, key state changes, or a time
00641 //      interval passes while the mouse is still within our DropTarget
00642 //      window.
00643 //
00644 // Parameters:
00645 //
00646 //      DWORD grfKeyState       - current key state
00647 //      POINTL pointl           - position of mouse
00648 //      LPDWORD pdwEffect       - (IN-OUT) drag effect that should occur
00649 //                                ON INPUT, this is dwOKEffects that source
00650 //                                passed to DoDragDrop API.
00651 //                                ON OUTPUT, this is the effect that we
00652 //                                want to take effect (used to determine
00653 //                                cursor feedback).
00654 //
00655 // Return Value:
00656 //
00657 //      S_OK
00658 //
00659 // Function Calls:
00660 //      Function                    Location
00661 //
00662 //      OutputDebugString           Windows API
00663 //      DoDragScroll                IDT.CPP
00664 //      QueryDrop                   IDT.CPP
00665 //      DrawDragFeedback            IDT.CPP
00666 //      UndrawDragFeedback          IDT.CPP
00667 //
00668 // Comments:
00669 //      Callee should honor the dwEffects as passed in to determine
00670 //      if the caller allows DROPEFFECT_MOVE. OLE pulses the DragOver
00671 //      calls in order that the DropTarget can implement drag scrolling
00672 //
00673 //********************************************************************
00674
00675 STDMETHODIMP CDropTarget::DragOver  (DWORD grfKeyState, POINTL pointl, LPDWORD pdwEffect)
00676 {
00677         OutputDebugString("In IDT::DragOver\r\n");
00678
00679         BOOL fDragScroll = DoDragScroll ( pointl );
00680
00681         if (QueryDrop(grfKeyState,pointl,fDragScroll,pdwEffect))
00682                 DrawDragFeedback( pointl );
00683         else
00684                 UndrawDragFeedback();
00685
00686         return NOERROR;
00687 }
00688
00689
00690 //**********************************************************************
00691 //
00692 // CDropTarget::DragLeave
00693 //
00694 // Purpose:
00695 //
00696 //      Called when the mouse leaves our DropTarget window
00697 //
00698 // Parameters:
00699 //
00700 //      none.
00701 //
00702 // Return Value:
00703 //
00704 //      S_OK
00705 //
00706 // Function Calls:
00707 //      Function                    Location
00708 //
00709 //      OutputDebugString           Windows API
00710 //      UndrawDragFeedback          IDT.CPP
00711 //                   OLE2 API
00712 //
00713 // Comments:
00714 //
00715 //********************************************************************
00716
00717 STDMETHODIMP CDropTarget::DragLeave ()
00718 {
00719         OutputDebugString("In IDT::DragLeave\r\n");
00720
00721         UndrawDragFeedback();
00722
00723         return S_OK;
00724 }
00725
00726
00727 //**********************************************************************
00728 //
00729 // CDropTarget::Drop
00730 //
00731 // Purpose:
00732 //
00733 //      Called when a Drop operation should take place.
00734 //
00735 // Parameters:
00736 //
00737 //      LPDATAOBJECT pDataObj   - IDataObject from Drop source
00738 //      DWORD grfKeyState       - current key state
00739 //      POINTL pointl           - position of mouse
00740 //      LPDWORD pdwEffect       - (IN-OUT) drag effect that should occur
00741 //                                ON INPUT, this is dwOKEffects that source
00742 //                                passed to DoDragDrop API.
00743 //                                ON OUTPUT, this is the effect that we
00744 //                                want to take effect (used to determine
00745 //                                cursor feedback).
00746 //
00747 // Return Value:
00748 //
00749 //      S_OK
00750 //
00751 // Function Calls:
00752 //      Function                    Location
00753 //
00754 //      OutputDebugString           Windows API
00755 //      CSimpleSite::Create         SITE.CPP
00756 //      CSimpleSite::InitObject     SITE.CPP
00757 //      OleCreateFromData           OLE2 API
00758 //      DoDragScroll                IDT.CPP
00759 //      QueryDrop                   IDT.CPP
00760 //      InitDragFeedback            IDT.CPP
00761 //      DrawDragFeedback            IDT.CPP
00762 //      UndrawDragFeedback          IDT.CPP
00763 //                          OLE2 API
00764 //                   OLE2 API
00765 //
00766 // Comments:
00767 //      Callee should honor the dwEffects as passed in to determine
00768 //      if the caller allows DROPEFFECT_MOVE.
00769 //
00770 //********************************************************************
00771
00772 STDMETHODIMP CDropTarget::Drop (LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pointl, LPDWORD pdwEffect)
00773 {
00774         FORMATETC fmtetc;
00775         SCODE sc = S_OK;
00776
00777         OutputDebugString("In IDT::Drop\r\n");
00778
00779         UndrawDragFeedback();
00780
00781         if (pDataObj && QueryDrop(grfKeyState,pointl,FALSE,pdwEffect))
00782                 {
00783                 m_pDoc->m_lpSite = CSimpleSite::Create(m_pDoc);
00784                 // keep same aspect as drop source
00785                 m_pDoc->m_lpSite->m_dwDrawAspect = m_dwSrcAspect;
00786
00787                 // in order to specify a particular drawing Aspect we must
00788                 // pass a FORMATETC* to OleCreateFromData
00789                 fmtetc.cfFormat = NULL;             // use whatever for drawing
00790                 fmtetc.ptd = NULL;
00791                 fmtetc.lindex = -1;
00792                 fmtetc.dwAspect = m_dwSrcAspect;    // desired drawing aspect
00793                 fmtetc.tymed = TYMED_NULL;
00794
00795                 HRESULT hrErr = OleCreateFromData (
00796                                                         pDataObj,
00797                                                         IID_IOleObject,
00798                                                         OLERENDER_DRAW,
00799                                                         &fmtetc,
00800                                                         &m_pDoc->m_lpSite->m_OleClientSite,
00801                                                         m_pDoc->m_lpSite->m_lpObjStorage,
00802                                                         (LPVOID FAR *)&m_pDoc->m_lpSite->m_lpOleObject);
00803
00804                 if (hrErr == NOERROR)
00805                         {
00806                         m_pDoc->m_lpSite->InitObject(FALSE /* fCreateNew */);
00807                         m_pDoc->DisableInsertObject();
00808                         }
00809                 else
00810                         sc = hrErr;
00811                 }
00812
00813         return sc;
00814 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/socket.c Source File

  • NetDS
  • RRas
  • ip

socket.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\socket.c
00008     Assumes an IPv4 IPADDRESS for now...
00009
00010 Abstract:
00011
00012     The file contains functions to deal with sockets.
00013     Assumes an IPv4 IPADDRESS for now...
00014
00015 --*/
00016
00017 #include "pchsample.h"
00018 #pragma hdrstop
00019
00020
00021 #define START_SAMPLE_IO()       ENTER_SAMPLE_API()
00022
00023 #define FINISH_SAMPLE_IO()      LEAVE_SAMPLE_API()
00024
00025
00026
00027 ////////////////////////////////////////
00028 // CALLBACKFUNCTIONS
00029 ////////////////////////////////////////
00030
00031 VOID
00032 WINAPI
00033 SocketCallbackSendCompletion (
00034     IN  DWORD                   dwErr,
00035     IN  DWORD                   dwNumSent,
00036     IN  LPOVERLAPPED            lpOverlapped
00037     )
00038 /*++
00039
00040 Routine Description
00041     This routine is invoked by the I/O system upon completion of an
00042     operation.  Runs in the context of an RTUTILS.DLL worker thread.
00043
00044 Locks
00045     None.
00046
00047 Arguments:
00048     dwErr                   system-supplied error code
00049     dwNumSent               system-supplied byte-count
00050     lpOverlapped            caller-supplied context area
00051
00052 Return Value:
00053     None.
00054
00055 --*/
00056 {
00057     PPACKET pPacket = CONTAINING_RECORD(lpOverlapped, PACKET, oOverlapped);
00058
00059     TRACE3(ENTER, "Entering SocketCallbackSendCompletion: %u %u 0x%08x",
00060            dwErr, dwNumSent, lpOverlapped);
00061     PacketDisplay(pPacket);
00062
00063
00064     if ((dwErr != NO_ERROR) or                      // operation aborted
00065         (dwNumSent != pPacket->wsaBuffer.len))      // data not sent entirely
00066     {
00067         TRACE1(NETWORK, "Error %u sending packet", dwErr);
00068         LOGERR0(SENDTO_FAILED, dwErr);
00069
00070     }
00071
00072     PacketDestroy(pPacket);     // destroy the packet structure
00073
00074
00075     TRACE0(LEAVE, "Leaving  SocketCallbackSendCompletion");
00076
00077     FINISH_SAMPLE_IO();
00078 }
00079
00080
00081
00082 ////////////////////////////////////////
00083 // APIFUNCTIONS
00084 ////////////////////////////////////////
00085
00086
00087 DWORD
00088 SocketCreate (
00089     IN  IPADDRESS               ipAddress,
00090     IN  HANDLE                  hEvent,
00091     OUT SOCKET                  *psSocket)
00092 /*++
00093
00094 Routine Description
00095     Creates a socket.
00096
00097 Locks
00098     None
00099
00100 Arguments
00101     ipAddress           ip address to bind the socket to
00102     hEvent              the event to set when a packet arrives
00103     psSocket            address of the socket to create
00104
00105 Return Value
00106     NO_ERROR            success
00107     Error Code          o/w
00108
00109 --*/
00110 {
00111     DWORD           dwErr = NO_ERROR;
00112     PCHAR           pszBuffer;
00113     SOCKADDR_IN     sinSockAddr;
00114     BOOL            bDontLinger, bReuse, bLoopback;
00115     struct linger   lLinger = { 0, 0 };
00116     UCHAR           ucTTL;
00117     struct ip_mreq  imMulticast;
00118
00119
00120     // validate parameters
00121     if ((!psSocket or (*psSocket != INVALID_SOCKET)) or
00122         !IP_VALID(ipAddress) or
00123         (hEvent is INVALID_HANDLE_VALUE))
00124         return ERROR_INVALID_PARAMETER;
00125
00126     // default return value
00127     *psSocket = INVALID_SOCKET;
00128
00129
00130     pszBuffer = INET_NTOA(ipAddress);
00131
00132     do                          // breakout loop
00133     {
00134         // create socket
00135         *psSocket = WSASocket(AF_INET,            // address family
00136                               SOCK_RAW,           // type
00137                               PROTO_IP_SAMPLE,    // protocol
00138                               NULL,
00139                               0,
00140                               WSA_FLAG_OVERLAPPED);
00141         if(*psSocket is INVALID_SOCKET)
00142         {
00143             dwErr = WSAGetLastError();
00144             TRACE0(NETWORK, "Could not create socket");
00145             break;
00146         }
00147
00148         // associate the socket with our I/O completion port.  the callback
00149         // function is invoked when an overlapped I/O operation completes.
00150         // this would be the send operation!
00151         dwErr = SetIoCompletionProc((HANDLE) *psSocket,
00152                                     SocketCallbackSendCompletion);
00153         if (dwErr != NO_ERROR)
00154         {
00155             TRACE0(NETWORK, "Could not associate callback function");
00156             break;
00157         }
00158
00159
00160         // set SO_LINGER to off
00161         // do not linger on close waiting for unsent data to be sent
00162         bDontLinger = TRUE;
00163         if (setsockopt(*psSocket,
00164                        SOL_SOCKET,
00165                        SO_DONTLINGER,
00166                        (const char *) &bDontLinger,
00167                        sizeof(BOOL)) is SOCKET_ERROR)
00168         {
00169             TRACE2(NETWORK,
00170                    "Error %u setting linger option on %s, continuing...",
00171                    WSAGetLastError(), pszBuffer);
00172         }
00173
00174         // set to SO_REUSEADDR
00175         // allow socket to be bound to an address that is already in use
00176         bReuse = TRUE;
00177         if (setsockopt(*psSocket,
00178                        SOL_SOCKET,
00179                        SO_REUSEADDR,
00180                        (const char *) &bReuse,
00181                        sizeof(BOOL)) is SOCKET_ERROR)
00182         {
00183             TRACE2(NETWORK,
00184                    "Error %u seting reuse option on %s, continuing...",
00185                    WSAGetLastError(), pszBuffer);
00186         }
00187
00188         // bind to the specified IPv4 addresses
00189         ZeroMemory(&sinSockAddr, sizeof(SOCKADDR_IN));
00190         sinSockAddr.sin_family      = AF_INET;
00191         sinSockAddr.sin_addr.s_addr = ipAddress;
00192         sinSockAddr.sin_port        = 0;
00193         if (bind(*psSocket, (LPSOCKADDR) &sinSockAddr, sizeof(SOCKADDR_IN))
00194             is SOCKET_ERROR)
00195         {
00196             dwErr = WSAGetLastError();
00197             TRACE0(NETWORK, "Could not bind socket");
00198             LOGERR1(BIND_IF_FAILED, pszBuffer, dwErr);
00199             break;
00200         }
00201
00202
00203         // allow multicast traffic to be sent out this interface
00204         if (setsockopt(*psSocket,
00205                        IPPROTO_IP,
00206                        IP_MULTICAST_IF,
00207                        (const char *) &sinSockAddr.sin_addr,
00208                        sizeof(IN_ADDR)) is SOCKET_ERROR)
00209         {
00210             dwErr = WSAGetLastError();
00211             TRACE2(NETWORK,
00212                    "Error %u setting interface %s as multicast...",
00213                    dwErr, pszBuffer);
00214             LOGERR1(SET_MCAST_IF_FAILED, pszBuffer, dwErr);
00215             break;
00216         }
00217
00218         // set loopback to ignore self generated packets.
00219         bLoopback   = FALSE;
00220         if (setsockopt(*psSocket,
00221                        IPPROTO_IP,
00222                        IP_MULTICAST_LOOP,
00223                        (const char *) &bLoopback,
00224                        sizeof(BOOL)) is SOCKET_ERROR)
00225         {
00226             TRACE2(NETWORK,
00227                    "Error %u setting loopback to FALSE on %s, continuing...",
00228                    WSAGetLastError(), pszBuffer);
00229         }
00230
00231         // set TTL to 1 to restrict packet to within subnet (default anyway)
00232         ucTTL  = 1;
00233         if (setsockopt(*psSocket,
00234                        IPPROTO_IP,
00235                        IP_MULTICAST_TTL,
00236                        (const char *) &ucTTL,
00237                        sizeof(UCHAR)) is SOCKET_ERROR)
00238         {
00239             TRACE2(NETWORK,
00240                    "Error %u setting mcast ttl to 1 on %s, continuing...",
00241                    WSAGetLastError(), pszBuffer);
00242         }
00243
00244         // join the multicast session on SAMPLE_PROTOCOL_MULTICAST_GROUP.
00245         imMulticast.imr_multiaddr.s_addr = SAMPLE_PROTOCOL_MULTICAST_GROUP;
00246         imMulticast.imr_interface.s_addr = ipAddress;
00247         if (setsockopt(*psSocket,
00248                        IPPROTO_IP,
00249                        IP_ADD_MEMBERSHIP,
00250                        (const char *) &imMulticast,
00251                        sizeof(struct ip_mreq)) is SOCKET_ERROR)
00252         {
00253             dwErr = WSAGetLastError();
00254             TRACE0(NETWORK, "Could not join multicast group on socket");
00255             LOGERR1(JOIN_GROUP_FAILED, pszBuffer, dwErr);
00256             break;
00257         }
00258
00259
00260         // associate hReceiveEvent with the receive network event
00261         if (WSAEventSelect(*psSocket, (WSAEVENT) hEvent, FD_READ)
00262             is SOCKET_ERROR)
00263         {
00264             dwErr = WSAGetLastError();
00265             TRACE1(NETWORK, "Error %u calling WSAEventSelect()", dwErr);
00266             LOGERR0(EVENTSELECT_FAILED, dwErr);
00267             break;
00268         }
00269     } while(FALSE);
00270
00271     if (dwErr != NO_ERROR)
00272     {
00273         TRACE2(NETWORK, "Error %u creating socket for %s", dwErr, pszBuffer);
00274         LOGERR0(CREATE_SOCKET_FAILED, dwErr);
00275         SocketDestroy(*psSocket);
00276         *psSocket = INVALID_SOCKET;
00277     }
00278
00279     return dwErr;
00280 }
00281
00282
00283
00284 DWORD
00285 SocketDestroy (
00286     IN  SOCKET                  sSocket)
00287 /*++
00288
00289 Routine Description
00290     Closes a socket.
00291
00292 Locks
00293     None
00294
00295 Arguments
00296     sSocket             the socket to close
00297
00298 Return Value
00299     NO_ERROR            success
00300     Error Code          o/w
00301
00302 --*/
00303 {
00304     DWORD dwErr = NO_ERROR;
00305
00306     if (sSocket is INVALID_SOCKET)
00307         return NO_ERROR;
00308
00309     /*
00310     // closing a socket with closesocket also cancels the association and
00311     // selection of network events specified in WSAEventSelect.  redundant!
00312     if (WSAEventSelect(sSocket, (WSAEVENT) NULL, 0) is SOCKET_ERROR)
00313     {
00314         dwErr = WSAGetLastError();
00315         TRACE1(NETWORK, "Error %u clearing socket-event association", dwErr);
00316         LOGERR0(EVENTSELECT_FAILED, dwErr);
00317     }
00318     */
00319
00320     // close the socket
00321     if (closesocket(sSocket) != NO_ERROR)
00322     {
00323         dwErr = WSAGetLastError();
00324         TRACE1(NETWORK, "Error %u closing socket", dwErr);
00325         LOGERR0(DESTROY_SOCKET_FAILED, dwErr);
00326     }
00327
00328     return dwErr;
00329 }
00330
00331
00332
00333 DWORD
00334 SocketSend (
00335     IN  SOCKET                  sSocket,
00336     IN  IPADDRESS               ipDestination,
00337     IN  PPACKET                 pPacket)
00338 /*++
00339
00340 Routine Description
00341     Send a packet to its destination and destroy it.
00342     Asynchronous.
00343
00344 Locks
00345     None
00346
00347 Arguments
00348     sSocket             the socket to send the packet over
00349     ipDestination       the packet's destination
00350     pPacket             the packet to send out
00351
00352 Return Value
00353     NO_ERROR            success
00354     Error Code          o/w
00355
00356 --*/
00357 {
00358     DWORD           dwErr = NO_ERROR;
00359     SOCKADDR_IN     sinDestination;
00360     DWORD           dwScratch;
00361
00362     if (!START_SAMPLE_IO()) { return ERROR_CAN_NOT_COMPLETE; }
00363
00364
00365     // validate parameters
00366     if ((sSocket is INVALID_SOCKET) or !pPacket)
00367         return ERROR_INVALID_PARAMETER;
00368
00369
00370     ZeroMemory(&sinDestination, sizeof(SOCKADDR_IN));
00371     sinDestination.sin_family      = AF_INET;
00372     sinDestination.sin_addr.s_addr = ipDestination;
00373     sinDestination.sin_port        = 0;
00374     dwErr = WSASendTo(sSocket,
00375                       &(pPacket->wsaBuffer),        // buffer and length
00376                       1,                            // only one wsabuf exists
00377                       &dwScratch,                   // unused
00378                       0,                            // no flags
00379                       (PSOCKADDR) &sinDestination,
00380                       sizeof(SOCKADDR_IN),
00381                       &pPacket->oOverlapped,        // context upon completion
00382                       NULL);                        // no completion routine
00383
00384     // completion routine (SocketCallbackSendCompletion) queued
00385     if (((dwErr is SOCKET_ERROR) and (WSAGetLastError() is WSA_IO_PENDING)) or
00386         (dwErr is NO_ERROR))
00387     {
00388         return NO_ERROR;
00389     }
00390
00391     // completion routine (SocketCallbackSendCompletion) not queued
00392     dwErr = WSAGetLastError();
00393     TRACE1(NETWORK, "Error %u sending packet", dwErr);
00394     LOGERR0(SENDTO_FAILED, dwErr);
00395
00396     FINISH_SAMPLE_IO();
00397
00398     return dwErr;
00399 }
00400
00401
00402
00403 DWORD
00404 SocketReceive (
00405     IN  SOCKET                  sSocket,
00406     IN  PPACKET                 pPacket)
00407 /*++
00408
00409 Routine Description
00410     Receive a packet on a socket.
00411
00412     This routine is written so that it could dynamically allocate a buffer,
00413     not knowing a priori the maximum size of the protocol's packet.  It is
00414     synchronous, treating sSocket as a non overlapped socket.
00415
00416 Locks
00417     None
00418
00419 Arguments
00420     sSocket             the socket to send the packet over
00421     pPacket             the packet to send out
00422
00423 Return Value
00424     NO_ERROR            success
00425     Error Code          o/w
00426
00427 --*/
00428 #define IPv4_PREVIEW_SIZE               4
00429 #define IPv4_LENGTH_OFFSET              2
00430 {
00431     DWORD       dwErr = NO_ERROR;
00432     BYTE        rgbyPreview[IPv4_PREVIEW_SIZE];
00433     DWORD       dwNumReceived, dwFlags;
00434     INT         iSourceLength;
00435     SOCKADDR_IN sinSource;
00436     DWORD       dwPacketLength;
00437
00438     // validate parameters
00439     if ((sSocket is INVALID_SOCKET) or !pPacket)
00440         return ERROR_INVALID_PARAMETER;
00441
00442     do                          // breakout loop
00443     {
00444         // read enuf to figure length
00445         pPacket->wsaBuffer.buf  = rgbyPreview;
00446         pPacket->wsaBuffer.len  = IPv4_PREVIEW_SIZE;
00447         dwFlags                 = MSG_PEEK;
00448         iSourceLength = sizeof(SOCKADDR_IN);
00449
00450         dwErr = WSARecvFrom(sSocket,
00451                             &(pPacket->wsaBuffer),  // buffer and length
00452                             1,                      // only one wsabuf exists
00453                             &dwNumReceived,         // # bytes received
00454                             &dwFlags,               // flags
00455                             (PSOCKADDR) &sinSource,
00456                             &iSourceLength,
00457                             NULL,                   // no context
00458                             NULL);                  // no completion routine
00459         if (dwErr != SOCKET_ERROR)  // there should have been an error
00460             break;
00461         dwErr = WSAGetLastError();
00462         if (dwErr != WSAEMSGSIZE)   // of this kind
00463             break;
00464         if (dwNumReceived != pPacket->wsaBuffer.len)
00465         {
00466             dwErr = ERROR_CAN_NOT_COMPLETE;
00467             break;
00468         }
00469
00470
00471         // calculate the packet length
00472         dwPacketLength = ntohs(*((PUSHORT)(rgbyPreview + IPv4_LENGTH_OFFSET)));
00473         if (dwPacketLength > MAX_PACKET_LENGTH)
00474         {
00475             dwErr = ERROR_CAN_NOT_COMPLETE;
00476             break;
00477         }
00478
00479         // read the entire packet, the buffer could be dynamically allocated
00480         pPacket->wsaBuffer.buf  = pPacket->rgbyBuffer;
00481         pPacket->wsaBuffer.len  = dwPacketLength;
00482         dwFlags                 = 0;
00483         iSourceLength = sizeof(SOCKADDR_IN);
00484
00485         dwErr = WSARecvFrom(sSocket,
00486                             &(pPacket->wsaBuffer),  // buffer and length
00487                             1,                      // only one wsabuf exists
00488                             &dwNumReceived,         // # bytes received
00489                             &dwFlags,               // flags
00490                             (PSOCKADDR) &sinSource,
00491                             &iSourceLength,
00492                             NULL,                   // no context
00493                             NULL);                  // no completion routine
00494         if (dwErr is SOCKET_ERROR)
00495         {
00496             dwErr = WSAGetLastError();
00497             break;
00498         }
00499         if (dwPacketLength != dwNumReceived)
00500         {
00501             dwErr = ERROR_CAN_NOT_COMPLETE;
00502             break;
00503         }
00504
00505         pPacket->ipSource       = sinSource.sin_addr.s_addr;
00506         pPacket->wsaBuffer.len  = dwNumReceived;
00507
00508         dwErr = NO_ERROR;
00509     } while (FALSE);
00510
00511     if (dwErr != NO_ERROR)
00512     {
00513         TRACE1(NETWORK, "Error %u receiving packet", dwErr);
00514         LOGERR0(RECVFROM_FAILED, dwErr);
00515     }
00516
00517     return dwErr;
00518 }
00519
00520
00521
00522 BOOL
00523 SocketReceiveEvent (
00524     IN  SOCKET                  sSocket)
00525 /*++
00526
00527 Routine Description
00528     Indicates whether a receive event occured on a socket.  The recording
00529     of network events commences when WSAEventSelect is called with a
00530     nonzero lNetworkEvents parameter (i.e. the socket is activated) and
00531     remains in effect until another call is made to WSAEventSelect with the
00532     lNetworkEvents parameter set to zero (i.e. the socket is deactivated).
00533
00534 Locks
00535     None
00536
00537 Arguments
00538     sSocket             the socket to check for packet reception
00539
00540 Return Value
00541     TRUE                receive event did occur
00542     FALSE               o/w
00543
00544 --*/
00545 {
00546     DWORD               dwErr = NO_ERROR;
00547     WSANETWORKEVENTS    wsaEvent;
00548
00549     // validate parameters
00550     if (sSocket is INVALID_SOCKET)
00551         return ERROR_INVALID_PARAMETER;
00552
00553     do                          // breakout loop
00554     {
00555         // enumerate network events to see if any packets have arrived on
00556         dwErr = WSAEnumNetworkEvents(sSocket, NULL, &wsaEvent);
00557         if (dwErr != NO_ERROR)
00558         {
00559             TRACE1(NETWORK, "Error %u enumerating network events", dwErr);
00560             LOGERR0(ENUM_NETWORK_EVENTS_FAILED, dwErr);
00561             break;
00562         }
00563
00564         // see if the input bit is set
00565         if (!(wsaEvent.lNetworkEvents & FD_READ))
00566         {
00567             dwErr = SOCKET_ERROR;
00568             break;
00569         }
00570
00571         // the input bit is set, now see if there was an error
00572         dwErr = wsaEvent.iErrorCode[FD_READ_BIT];
00573         if (dwErr != NO_ERROR)
00574         {
00575             TRACE1(NETWORK, "Error %u in input record", dwErr);
00576             LOGERR0(INPUT_RECORD_ERROR, dwErr);
00577             break;
00578         }
00579     } while (FALSE);
00580
00581     if (dwErr is NO_ERROR)
00582         return TRUE;
00583
00584     return FALSE;
00585 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPersistStorage Member List

This is the complete list of members for CPersistStorage, including all inherited members.
CPersistFile class | CPersistStorage | [friend]
CPersistStorage(COleDocument *) | CPersistStorage |
CreateStreams(LPSTORAGE) | CPersistStorage | [private]
CreateStreams(LPSTORAGE, LPSTREAM *) | CPersistStorage | [private]
GetClassID(LPCLSID) | CPersistStorage |
HandsOffStorage() | CPersistStorage |
InitNew(LPSTORAGE) | CPersistStorage |
IsDirty() | CPersistStorage |
Load(LPSTORAGE) | CPersistStorage |
m_fSameAsLoad | CPersistStorage | [private]
m_pColorStream | CPersistStorage | [private]
m_pOleDoc | CPersistStorage | [private]
m_pStorage | CPersistStorage | [private]
OpenStreams(LPSTORAGE) | CPersistStorage | [private]
QueryInterface(REFIID, LPVOID *) | CPersistStorage |
ReleaseStreamsAndStorage() | CPersistStorage | [private]
Save(LPSTORAGE, BOOL) | CPersistStorage |
SaveCompleted(LPSTORAGE) | CPersistStorage |
STDMETHODIMP_(DWORD) AddRef() | CPersistStorage |
STDMETHODIMP_(DWORD) Release() | CPersistStorage |
~CPersistStorage() | CPersistStorage |
Generated on Wed Nov 13 2024 16:57:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPrintRequest Member List

This is the complete list of members for CPrintRequest, including all inherited members.
_hdc | CPrintRequest | [protected]
_hDevNames | CPrintRequest | [protected]
_hwnd | CPrintRequest | [protected]
_nFromPage | CPrintRequest | [protected]
_nToPage | CPrintRequest | [protected]
_pModel | CPrintRequest | [protected]
_pView | CPrintRequest | [protected]
_status | CPrintRequest | [protected]
Cancelled() | CPrintRequest | [inline]
CPrintCanvas class | CPrintRequest | [friend]
CPrintRequest(HWND hwnd, UINT minPage=1, UINT maxPage=1) | CPrintRequest |
Error() | CPrintRequest | [inline]
Print(HINSTANCE hInst, CCanvas &canvas, CModel *pModel) | CPrintRequest |
~CPrintRequest() | CPrintRequest |
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Handles/usrdef/Usrdefp.c Source File

  • NetDS
  • RPC
  • Handles
  • usrdef

Usrdefp.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         usrdef Example
00005
00006     FILE:       usrdefp.c
00007
00008     PURPOSE:    Remote procedures that are linked with the server
00009                 side of RPC distributed application
00010
00011     FUNCTIONS:  UsrdefProc() -
00012
00013     COMMENTS:   This distributed application uses a user-defined handle.
00014
00015 ****************************************************************************/
00016
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include "usrdef.h"    // header file generated by MIDL compiler
00020
00021 void UsrdefProc(DATA_HANDLE_TYPE dh, unsigned char * pszString)
00022 {
00023     printf("%s\n", pszString);
00024 }
00025
00026 void Shutdown(DATA_HANDLE_TYPE dh)
00027 {
00028     RPC_STATUS status;
00029
00030     printf("Calling RpcMgmtStopServerListening\n");
00031     status = RpcMgmtStopServerListening(NULL);
00032     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00033     if (status) {
00034         exit(status);
00035     }
00036
00037     printf("Calling RpcServerUnregisterIf\n");
00038     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00039     printf("RpcServerUnregisterIf returned 0x%x\n", status);
00040     if (status) {
00041         exit(status);
00042     }
00043 }
00044
00045 /* end file usrdefp.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share Sample/StringUtils.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share Sample

StringUtils.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      StringUtils.cpp
00007 //
00008 //  Description:
00009 //      Implementation of string manipulation routines.
00010 //
00011 //  Author:
00012 //      <name> (<e-mail name>) Mmmm DD, 2003
00013 //
00014 //  Revision History:
00015 //
00016 //  Notes:
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019
00020 //////////////////////////////////////////////////////////////////////////////
00021 // Include Files
00022 //////////////////////////////////////////////////////////////////////////////
00023
00024 #include "StringUtils.h"
00025
00026
00027 //////////////////////////////////////////////////////////////////////////////
00028 // String comparison routines
00029 //////////////////////////////////////////////////////////////////////////////
00030
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 //++
00034 //
00035 //  WrapCompareString
00036 //
00037 //  Description:
00038 //      Wraps the call to CompareString
00039 //
00040 //  Arguments:
00041 //      fCaseSensitive      TRUE for a case sensitive compare
00042 //                          FALSE for a case insensitive compare
00043 //      pcwszString1In      The first string.
00044 //      cch1In              The count of characters in the first string.
00045 //                          If -1 then it's assumed to be null-terminated.
00046 //      pcwszString2In      The second string.
00047 //      cchIn               The count of characters in the second string.
00048 //                          If -1 then it's assumed to be null-terminated.
00049 //  Return Value:
00050 //       0  Strings are equal.
00051 //     > 0  String1 greater than String2.
00052 //     < 0  String1 less than String2.
00053 //
00054 //--
00055 /////////////////////////////////////////////////////////////////////////////
00056 int
00057 WrapCompareString(
00058       BOOL      fCaseSensitive
00059     , LPCWSTR   pcwszString1In
00060     , size_t    cch1In
00061     , LPCWSTR   pcwszString2In
00062     , size_t    cch2In
00063     )
00064 {
00065     int nRet;
00066
00067     nRet = CompareStringW(
00068               LOCALE_SYSTEM_DEFAULT
00069             , fCaseSensitive ? 0 : NORM_IGNORECASE
00070             , pcwszString1In
00071             , static_cast< DWORD >( cch1In )
00072             , pcwszString2In
00073             , static_cast< DWORD >( cch2In )
00074             );
00075
00076     return nRet - CSTR_EQUAL; // CSTR_LT < CSTR_EQUAL < CSTR_GT
00077
00078 } // *** WrapCompareString
00079
00080 //
00081 // Full string compares.
00082 //
00083
00084 int
00085 IBSTRCompareW(
00086       BSTR  bstrString1In
00087     , BSTR  bstrString2In
00088     )
00089 {
00090     return WrapCompareString(
00091                   FALSE
00092                 , static_cast< LPCWSTR >( bstrString1In )
00093                 , SysStringLen( bstrString1In )
00094                 , static_cast< LPCWSTR >( bstrString2In )
00095                 , SysStringLen( bstrString2In )
00096                 );
00097 } //*** IBSTRCompareW
00098
00099 int
00100 BSTRCompareW(
00101       BSTR  bstrString1In
00102     , BSTR  bstrString2In
00103     )
00104 {
00105     return WrapCompareString(
00106                   TRUE
00107                 , static_cast< LPCWSTR >( bstrString1In )
00108                 , SysStringLen( bstrString1In )
00109                 , static_cast< LPCWSTR >( bstrString2In )
00110                 , SysStringLen( bstrString2In )
00111                 );
00112 } //*** BSTRCompareW
00113
00114 int
00115 IStringCompareW(
00116       LPCWSTR pcwszString1In
00117     , LPCWSTR pcwszString2In
00118     )
00119 {
00120     return WrapCompareString(
00121                   FALSE
00122                 , pcwszString1In
00123                 , static_cast< size_t >( -1 )
00124                 , pcwszString2In
00125                 , static_cast< size_t >( -1 )
00126             );
00127 } //*** IStringCompareW
00128
00129 int
00130 StringCompareW(
00131       LPCWSTR pcwszString1In
00132     , LPCWSTR pcwszString2In
00133     )
00134 {
00135     return WrapCompareString(
00136                   TRUE
00137                 , pcwszString1In
00138                 , static_cast< size_t >( -1 )
00139                 , pcwszString2In
00140                 , static_cast< size_t >( -1 )
00141                 );
00142 } //*** StringCompareW
00143
00144 int
00145 IStringCompareW(
00146       LPCWSTR   pcwszString1In
00147     , size_t    cch1In
00148     , LPCWSTR   pcwszString2In
00149     , size_t    cch2In
00150     )
00151 {
00152     return WrapCompareString(
00153                   FALSE
00154                 , pcwszString1In
00155                 , cch1In
00156                 , pcwszString2In
00157                 , cch2In
00158                 );
00159 } //*** IStringCompareW
00160
00161 int
00162 StringCompareW(
00163       LPCWSTR   pcwszString1In
00164     , size_t    cch1In
00165     , LPCWSTR   pcwszString2In
00166     , size_t    cch2In
00167     )
00168 {
00169     return WrapCompareString(
00170                   TRUE
00171                 , pcwszString1In
00172                 , cch1In
00173                 , pcwszString2In
00174                 , cch2In
00175                 );
00176 } //*** StringCompareW
00177
00178 //
00179 // Partial string compares.  They use whichever one's length is shortest
00180 // if both are specified or the NBSTR routines are used.
00181 //
00182
00183 int
00184 NIBSTRCompareW(
00185       BSTR  bstrString1In
00186     , BSTR  bstrString2In
00187     )
00188 {
00189     size_t cchMin;
00190
00191     cchMin = min( SysStringLen( bstrString1In ), SysStringLen( bstrString2In ) );
00192
00193     return WrapCompareString(
00194                   FALSE
00195                 , static_cast< LPCWSTR >( bstrString1In )
00196                 , cchMin
00197                 , static_cast< LPCWSTR >( bstrString2In )
00198                 , cchMin
00199                 );
00200 } //*** NIBSTRCompareW
00201
00202 int
00203 NBSTRCompareW(
00204       BSTR  bstrString1In
00205     , BSTR  bstrString2In
00206     )
00207 {
00208     size_t cchMin;
00209
00210     cchMin = min( SysStringLen( bstrString1In ), SysStringLen( bstrString2In ) );
00211
00212     return WrapCompareString(
00213                   TRUE
00214                 , static_cast< LPCWSTR >( bstrString1In )
00215                 , cchMin
00216                 , static_cast< LPCWSTR >( bstrString2In )
00217                 , cchMin
00218                 );
00219 } //*** NBSTRCompareW
00220
00221 int
00222 NIStringCompareW(
00223       LPCWSTR   pcwszString1In
00224     , LPCWSTR   pcwszString2In
00225     , size_t    cchIn
00226     )
00227 {
00228     return WrapCompareString(
00229                   FALSE
00230                 , pcwszString1In
00231                 , cchIn
00232                 , pcwszString2In
00233                 , cchIn
00234                 );
00235 } //*** NIStringCompareW
00236
00237 int
00238 NStringCompareW(
00239       LPCWSTR   pcwszString1In
00240     , LPCWSTR   pcwszString2In
00241     , size_t    cchIn
00242     )
00243 {
00244     return WrapCompareString(
00245                   TRUE
00246                 , pcwszString1In
00247                 , cchIn
00248                 , pcwszString2In
00249                 , cchIn
00250                 );
00251 } //*** NIStringCompareW
00252
00253 int
00254 NIStringCompareW(
00255       LPCWSTR   pcwszString1In
00256     , size_t    cch1In
00257     , LPCWSTR   pcwszString2In
00258     , size_t    cch2In
00259     )
00260 {
00261     return WrapCompareString(
00262                   FALSE
00263                 , pcwszString1In
00264                 , min( cch1In, cch2In )
00265                 , pcwszString2In
00266                 , min( cch1In, cch2In )
00267                 );
00268 } //*** NIStringCompareW
00269
00270 int
00271 NStringCompareW(
00272       LPCWSTR   pcwszString1In
00273     , size_t    cch1In
00274     , LPCWSTR   pcwszString2In
00275     , size_t    cch2In
00276     )
00277 {
00278     return WrapCompareString(
00279                   TRUE
00280                 , pcwszString1In
00281                 , min( cch1In, cch2In )
00282                 , pcwszString2In
00283                 , min( cch1In, cch2In )
00284                 );
00285 } //*** NStringCompareW
00286
00287
00288
00289 //////////////////////////////////////////////////////////////////////////////
00290 // Load string routines
00291 //////////////////////////////////////////////////////////////////////////////
00292
00293
00294 //////////////////////////////////////////////////////////////////////////////
00295 //++
00296 //
00297 //  HrLoadStringIntoBSTR
00298 //
00299 //  Description:
00300 //      Retrieves the string resource idsIn from the string table and makes it
00301 //      into a BSTR. If the BSTR is not NULL coming it, it will assume that
00302 //      you are trying reuse an existing BSTR.
00303 //
00304 //  Arguments:
00305 //      hInstanceIn
00306 //          Handle to an instance of the module whose executable file
00307 //          contains the string resource.  If not specified, defaults to
00308 //          g_hInstance.
00309 //
00310 //      langidIn
00311 //          Language ID of string table resource.
00312 //
00313 //      idsIn
00314 //          Specifies the integer identifier of the string to be loaded.
00315 //
00316 //      pbstrInout
00317 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00318 //          may be the same or NULL.
00319 //
00320 //  Return Values:
00321 //      S_OK
00322 //          The call succeeded.
00323 //
00324 //      E_OUTOFMEMORY
00325 //          Out of memory.
00326 //
00327 //      E_POINTER
00328 //          pbstrInout is NULL.
00329 //
00330 //      Other HRESULTs
00331 //          The call failed.
00332 //
00333 //  Remarks:
00334 //      This routine uses LoadResource so that it can get the actual length
00335 //      of the string resource.  If we didn't do this, we would need to call
00336 //      LoadString and allocate memory in a loop.  Very inefficient!
00337 //
00338 //--
00339 //////////////////////////////////////////////////////////////////////////////
00340 HRESULT
00341 HrLoadStringIntoBSTR(
00342       HINSTANCE hInstanceIn
00343     , LANGID    langidIn
00344     , UINT      idsIn
00345     , BSTR *    pbstrInout
00346     )
00347
00348 {
00349     HRESULT hr              = S_OK;
00350     HRSRC   hrsrc           = NULL;
00351     HGLOBAL hgbl            = NULL;
00352     int     cch             = 0;
00353     PBYTE   pbStringData;
00354     PBYTE   pbStringDataMax;
00355     PBYTE   pbStringTable;
00356     int     cbStringTable;
00357     int     nTable;
00358     int     nOffset;
00359     int     idxString;
00360
00361     assert( idsIn != 0 );
00362     assert( pbstrInout != NULL );
00363
00364     if ( pbstrInout == NULL )
00365     {
00366         hr = E_POINTER;
00367         goto Cleanup;
00368     } // if:
00369
00370     if ( hInstanceIn == NULL )
00371     {
00372         hInstanceIn = g_hInstance;
00373     } // if:
00374
00375     //
00376     //  The resource Id specified must be converted to an index into
00377     //  a Windows StringTable.
00378     //
00379
00380     nTable = idsIn / 16;
00381     nOffset = idsIn - (nTable * 16);
00382
00383     //
00384     //  Internal Table Id's start at 1 not 0.
00385     //
00386
00387     nTable++;
00388
00389     //
00390     // Find the part of the string table where the string resides.
00391     //
00392
00393     //
00394     //  Find the table containing the string.
00395     // First try to load the language specified.  If we can't find it we
00396     // try the "neutral" language.
00397     //
00398
00399     hrsrc = FindResourceEx( hInstanceIn, RT_STRING, MAKEINTRESOURCE( nTable ), langidIn );
00400     if ( ( hrsrc == NULL ) && ( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND ) )
00401     {
00402         hrsrc = FindResourceEx(
00403                       hInstanceIn
00404                     , RT_STRING
00405                     , MAKEINTRESOURCE( nTable )
00406                     , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00407                     );
00408     } // if: FindResourceEx failed
00409
00410     if ( hrsrc == NULL )
00411     {
00412         hr = HRESULT_FROM_WIN32( GetLastError() );
00413         goto Cleanup;
00414     } // if:
00415
00416     //
00417     //  Load the table.
00418     //
00419
00420     hgbl = LoadResource( hInstanceIn, hrsrc );
00421     if ( hgbl == NULL )
00422     {
00423         hr = HRESULT_FROM_WIN32( GetLastError() );
00424         goto Cleanup;
00425     } // if:
00426
00427     //
00428     //  Lock the table so we access its data.
00429     //
00430
00431     pbStringTable = reinterpret_cast< PBYTE >( LockResource( hgbl ) );
00432     if ( pbStringTable == NULL )
00433     {
00434         hr = HRESULT_FROM_WIN32( GetLastError() );
00435         goto Cleanup;
00436     } // if:
00437
00438     cbStringTable = SizeofResource( hInstanceIn, hrsrc );
00439     assert( cbStringTable != 0 );
00440
00441     //
00442     //  Set the data pointer to the beginning of the table.
00443     //
00444
00445     pbStringData = pbStringTable;
00446     pbStringDataMax = pbStringTable + cbStringTable;
00447
00448     //
00449     // Skip strings in the block of 16 which are before the desired string.
00450     //
00451
00452     for ( idxString = 0 ; idxString <= nOffset ; idxString++ )
00453     {
00454         assert( pbStringData != NULL );
00455         assert( pbStringData < pbStringDataMax );
00456
00457         //
00458         //  Get the number of characters excluding the '\0'.
00459         //
00460
00461         cch = * ( (USHORT *) pbStringData );
00462
00463         //
00464         //  Found the string.
00465         //
00466
00467         if ( idxString == nOffset )
00468         {
00469             if ( cch == 0 )
00470             {
00471                 hr = HRESULT_FROM_WIN32( ERROR_RESOURCE_NAME_NOT_FOUND );
00472                 goto Cleanup;
00473             } // if:
00474
00475             //
00476             //  Skip over the string length to get the string.
00477             //
00478
00479             pbStringData += sizeof( WCHAR );
00480
00481             break;
00482         } // if: found the string
00483
00484         //
00485         //  Add one to account for the string length.
00486         //  A string length of 0 still takes 1 WCHAR for the length portion.
00487         //
00488
00489         cch++;
00490
00491         //
00492         //  Skip over this string to get to the next string.
00493         //
00494
00495         pbStringData += ( cch * sizeof( WCHAR ) );
00496
00497     } // for: each string in the block of 16 strings in the table
00498
00499     //
00500     //  Note: nStringLen is the number of characters in the string not including the '\0'.
00501     //
00502
00503     //
00504     // If previously allocated free it before re-allocating it.
00505     //
00506
00507     if ( *pbstrInout != NULL )
00508     {
00509         SysFreeString( *pbstrInout );
00510         *pbstrInout = NULL;
00511     } // if: string was allocated previously
00512
00513     //
00514     // Allocate a BSTR for the string.
00515     //
00516
00517     *pbstrInout = SysAllocStringLen( (OLECHAR *) pbStringData, cch );
00518     if ( *pbstrInout == NULL )
00519     {
00520         hr = E_OUTOFMEMORY;
00521         goto Cleanup;
00522     } // if:
00523
00524 Cleanup:
00525
00526     return hr;
00527
00528 } //*** HrLoadStringIntoBSTR
00529
00530
00531 //////////////////////////////////////////////////////////////////////////////
00532 // Format string ID routines
00533 //////////////////////////////////////////////////////////////////////////////
00534
00535
00536 //////////////////////////////////////////////////////////////////////////////
00537 //++
00538 //
00539 //  HrFormatStringIntoBSTR
00540 //
00541 //  Description:
00542 //      Format a string (specified by idsIn, a string resource ID) and
00543 //      variable arguments into a BSTR using the FormatMessage() Win32 API.
00544 //      If the BSTR is not NULL on entry, the BSTR will be reused.
00545 //
00546 //      Calls HrFormatStringWithVAListIntoBSTR to perform the actual work.
00547 //
00548 //  Arguments:
00549 //      hInstanceIn
00550 //          Handle to an instance of the module whose executable file
00551 //          contains the string resource.
00552 //
00553 //      langidIn
00554 //          Language ID of string table resource.
00555 //
00556 //      idsIn
00557 //          Specifies the integer identifier of the string to be loaded.
00558 //
00559 //      pbstrInout
00560 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00561 //          may be the same or NULL.
00562 //
00563 //      ...
00564 //          Arguments for substitution points in the status text message.
00565 //          The FormatMessage() API is used for formatting the string, so
00566 //          substitution points must of the form %1!ws! and not %ws.
00567 //
00568 //  Return Values:
00569 //      S_OK
00570 //          The call succeeded.
00571 //
00572 //      Other HRESULTs
00573 //          The call failed.
00574 //
00575 //--
00576 //////////////////////////////////////////////////////////////////////////////
00577 HRESULT
00578 HrFormatStringIntoBSTR(
00579       HINSTANCE hInstanceIn
00580     , LANGID    langidIn
00581     , UINT      idsIn
00582     , BSTR *    pbstrInout
00583     , ...
00584     )
00585 {
00586     HRESULT hr;
00587     va_list valist;
00588
00589     va_start( valist, pbstrInout );
00590
00591     hr = HrFormatStringWithVAListIntoBSTR(
00592                           hInstanceIn
00593                         , langidIn
00594                         , idsIn
00595                         , pbstrInout
00596                         , valist
00597                         );
00598
00599     va_end( valist );
00600
00601     return hr;
00602
00603 } //*** HrFormatStringIntoBSTR
00604
00605 //////////////////////////////////////////////////////////////////////////////
00606 //++
00607 //
00608 //  HrFormatStringWithVAListIntoBSTR
00609 //
00610 //  Description:
00611 //      Format a string (specified by idsIn, a string resource ID) and
00612 //      variable arguments into a BSTR using the FormatMessage() Win32 API.
00613 //      If the BSTR is not NULL on entry, the BSTR will be reused.
00614 //
00615 //  Arguments:
00616 //      hInstanceIn
00617 //          Handle to an instance of the module whose executable file
00618 //          contains the string resource.
00619 //
00620 //      langidIn
00621 //          Language ID of string table resource.
00622 //
00623 //      idsIn
00624 //          Specifies the integer identifier of the string to be loaded.
00625 //
00626 //      pbstrInout
00627 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00628 //          may be the same or NULL.
00629 //
00630 //      valistIn
00631 //          Arguments for substitution points in the status text message.
00632 //          The FormatMessage() API is used for formatting the string, so
00633 //          substitution points must of the form %1!ws! and not %ws.
00634 //
00635 //  Return Values:
00636 //      S_OK
00637 //          The call succeeded.
00638 //
00639 //      E_OUTOFMEMORY
00640 //          Out of memory.
00641 //
00642 //      E_POINTER
00643 //          pbstrInout is NULL.
00644 //
00645 //      Other HRESULTs
00646 //          The call failed.
00647 //
00648 //--
00649 //////////////////////////////////////////////////////////////////////////////
00650 HRESULT
00651 HrFormatStringWithVAListIntoBSTR(
00652       HINSTANCE hInstanceIn
00653     , LANGID    langidIn
00654     , UINT      idsIn
00655     , BSTR *    pbstrInout
00656     , va_list   valistIn
00657     )
00658 {
00659     HRESULT hr = S_OK;
00660     BSTR    bstrStringResource = NULL;
00661     DWORD   cch;
00662     LPWSTR  pwsz = NULL;
00663
00664     assert( pbstrInout != NULL );
00665
00666     if ( pbstrInout == NULL )
00667     {
00668         hr = E_POINTER;
00669         goto Cleanup;
00670     } // if:
00671
00672     //
00673     // Load the string resource.
00674     //
00675
00676     hr = HrLoadStringIntoBSTR( hInstanceIn, langidIn, idsIn, &bstrStringResource );
00677     if ( FAILED( hr ) )
00678     {
00679         goto Cleanup;
00680     } // if:
00681
00682     //
00683     // Format the message with the arguments.
00684     //
00685
00686     cch = FormatMessage(
00687                       ( FORMAT_MESSAGE_ALLOCATE_BUFFER
00688                       | FORMAT_MESSAGE_FROM_STRING )
00689                     , bstrStringResource
00690                     , 0
00691                     , 0
00692                     , (LPWSTR) &pwsz
00693                     , 0
00694                     , &valistIn
00695                     );
00696     if ( cch == 0 )
00697     {
00698         hr = HRESULT_FROM_WIN32( GetLastError() );
00699         goto Cleanup;
00700     } // if:
00701
00702     //
00703     // If previously allocated free it before re-allocating it.
00704     //
00705
00706     if ( *pbstrInout != NULL )
00707     {
00708         SysFreeString( *pbstrInout );
00709         *pbstrInout = NULL;
00710     } // if:
00711
00712     //
00713     // Allocate a BSTR for the string.
00714     //
00715
00716     *pbstrInout = SysAllocStringLen( pwsz, cch );
00717     if ( *pbstrInout == NULL )
00718     {
00719         hr = E_OUTOFMEMORY;
00720         goto Cleanup;
00721     } // if:
00722
00723 Cleanup:
00724
00725     SysFreeString( bstrStringResource );
00726     LocalFree( pwsz );
00727
00728     return hr;
00729
00730 } //*** HrFormatStringWithVAListIntoBSTR
00731
00732
00733 //////////////////////////////////////////////////////////////////////////////
00734 // Format string routines
00735 //////////////////////////////////////////////////////////////////////////////
00736
00737
00738 //////////////////////////////////////////////////////////////////////////////
00739 //++
00740 //
00741 //  HrFormatStringIntoBSTR
00742 //
00743 //  Description:
00744 //      Format a string (specified by pcwszFmtIn) and variable arguments into
00745 //      a BSTR using the FormatMessage() Win32 API.  If the BSTR is not NULL
00746 //      on entry, the BSTR will be reused.
00747 //
00748 //      Calls HrFormatStringWithVAListIntoBSTR to perform the actual work.
00749 //
00750 //  Arguments:
00751 //      pcwszFmtIn
00752 //          Specifies the format string.
00753 //
00754 //      pbstrInout
00755 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00756 //          may be the same or NULL.
00757 //
00758 //      ...
00759 //          Arguments for substitution points in the status text message.
00760 //          The FormatMessage() API is used for formatting the string, so
00761 //          substitution points must of the form %1!ws! and not %ws.
00762 //
00763 //  Return Values:
00764 //      S_OK
00765 //          The call succeeded.
00766 //
00767 //      Other HRESULTs
00768 //          The call failed.
00769 //
00770 //--
00771 //////////////////////////////////////////////////////////////////////////////
00772 HRESULT
00773 HrFormatStringIntoBSTR(
00774       LPCWSTR   pcwszFmtIn
00775     , BSTR *    pbstrInout
00776     , ...
00777     )
00778 {
00779     HRESULT hr = S_OK;
00780     va_list valist;
00781
00782     va_start( valist, pbstrInout );
00783
00784     hr = HrFormatStringWithVAListIntoBSTR( pcwszFmtIn, pbstrInout, valist );
00785
00786     va_end( valist );
00787
00788     return hr;
00789
00790 } //*** HrFormatStringIntoBSTR
00791
00792 //////////////////////////////////////////////////////////////////////////////
00793 //++
00794 //
00795 //  HrFormatStringWithVAListIntoBSTR
00796 //
00797 //  Description:
00798 //      Format a string (specified by pcwszFmtIn) and variable arguments into
00799 //      a BSTR using the FormatMessage() Win32 API.  If the BSTR is not NULL
00800 //      on entry, the BSTR will be reused.
00801 //
00802 //  Arguments:
00803 //      pcwszFmtIn
00804 //          Specifies the format string.
00805 //
00806 //      pbstrInout
00807 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00808 //          may be the same or NULL.
00809 //
00810 //      valistIn
00811 //          Arguments for substitution points in the status text message.
00812 //          The FormatMessage() API is used for formatting the string, so
00813 //          substitution points must of the form %1!ws! and not %ws.
00814 //
00815 //  Return Values:
00816 //      S_OK
00817 //          The call succeeded.
00818 //
00819 //      E_OUTOFMEMORY
00820 //          Out of memory.
00821 //
00822 //      E_POINTER
00823 //          pcwszFmtIn or pbstrInout is NULL.
00824 //
00825 //      Other HRESULTs
00826 //          The call failed.
00827 //
00828 //--
00829 //////////////////////////////////////////////////////////////////////////////
00830 HRESULT
00831 HrFormatStringWithVAListIntoBSTR(
00832       LPCWSTR   pcwszFmtIn
00833     , BSTR *    pbstrInout
00834     , va_list   valistIn
00835     )
00836 {
00837     HRESULT hr = S_OK;
00838     DWORD   cch;
00839     LPWSTR  pwsz = NULL;
00840
00841     if (    ( pbstrInout == NULL )
00842         ||  ( pcwszFmtIn == NULL )
00843        )
00844     {
00845         hr = E_POINTER;
00846         goto Cleanup;
00847     } // if:
00848
00849     //
00850     // Format the message with the arguments.
00851     //
00852
00853     cch = FormatMessage(
00854                       ( FORMAT_MESSAGE_ALLOCATE_BUFFER
00855                       | FORMAT_MESSAGE_FROM_STRING )
00856                     , pcwszFmtIn
00857                     , 0
00858                     , 0
00859                     , (LPWSTR) &pwsz
00860                     , 0
00861                     , &valistIn
00862                     );
00863     if ( cch == 0 )
00864     {
00865         hr = HRESULT_FROM_WIN32( GetLastError() );
00866         goto Cleanup;
00867     } // if:
00868
00869     //
00870     // If previously allocated free it before re-allocating it.
00871     //
00872
00873     if ( *pbstrInout != NULL )
00874     {
00875         SysFreeString( *pbstrInout );
00876         *pbstrInout = NULL;
00877     } // if:
00878
00879     //
00880     // Allocate a BSTR for the string.
00881     //
00882
00883     *pbstrInout = SysAllocStringLen( pwsz, cch );
00884     if ( *pbstrInout == NULL )
00885     {
00886         hr = E_OUTOFMEMORY;
00887         goto Cleanup;
00888     } // if:
00889
00890 Cleanup:
00891
00892     LocalFree( pwsz );
00893
00894     return hr;
00895
00896 } //*** HrFormatStringWithVAListIntoBSTR
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DiskCleanupHandler/Resource.h Source File

  • WinUI
  • Shell
  • DiskCleanupHandler

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Cleanup.rc
00004 //
00005 #define IDS_DESCRIPTION                 1
00006 #define IDS_DISPLAY                     2
00007 #define IDS_CLSID                       3
00008 #define IDS_EMPTYVC_SUBKEY              4
00009 #define IDS_BUTTONTEXT                  5
00010 #define IDI_MSDEV                       102
00011 #define IDI_ICON                        102
00012
00013 // Next default values for new objects
00014 //
00015 #ifdef APSTUDIO_INVOKED
00016 #ifndef APSTUDIO_READONLY_SYMBOLS
00017 #define _APS_NEXT_RESOURCE_VALUE        103
00018 #define _APS_NEXT_COMMAND_VALUE         40001
00019 #define _APS_NEXT_CONTROL_VALUE         1000
00020 #define _APS_NEXT_SYMED_VALUE           101
00021 #endif
00022 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAgentCtlEx Member List

This is the complete list of members for CAgentCtlEx, including all inherited members.
Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, CCreateContext *pContext=NULL) | CAgentCtlEx | [inline, virtual]
Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, CFile *pPersist=NULL, BOOL bStorage=FALSE, BSTR bstrLicKey=NULL) | CAgentCtlEx | [inline]
GetAudioOutput() | CAgentCtlEx |
GetCharacters() | CAgentCtlEx |
GetClsid() | CAgentCtlEx | [inline]
GetCommandsWindow() | CAgentCtlEx |
GetConnected() | CAgentCtlEx |
GetPropertySheet() | CAgentCtlEx |
GetRaiseRequestErrors() | CAgentCtlEx |
GetSpeechInput() | CAgentCtlEx |
GetSuspended() | CAgentCtlEx |
SetConnected(BOOL bNewValue) | CAgentCtlEx |
SetRaiseRequestErrors(BOOL bNewValue) | CAgentCtlEx |
ShowDefaultCharacterProperties(const VARIANT &x, const VARIANT &y) | CAgentCtlEx |
Generated on Wed Nov 13 2024 16:55:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCOrder/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCOrder

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/ProxyStub/iid.c Source File

  • Com
  • Common
  • ProxyStub

iid.c

Go to the documentation of this file.
00001 //
00002 // iid.c
00003 //
00004 #include "copyfilerm_i.c"
00005 #include "simplelog_i.c"
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/cshare.h Source File

  • Web
  • NetMeeting
  • NMUI

cshare.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       CSHARE.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 //****************************************************************************
00017 //
00018 // CLASS CAppShareNotify
00019 //
00020 //****************************************************************************
00021
00022 class CAppShareNotify : public RefCount, public CNotify, public INmChannelAppShareNotify
00023 {
00024 public:
00025   CAppShareNotify();
00026   ~CAppShareNotify();
00027
00028   // INmChannelAppShareNotify
00029   HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
00030   HRESULT STDMETHODCALLTYPE MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember * pMember);
00031   HRESULT STDMETHODCALLTYPE StateChanged(NM_SHAPP_STATE uState, INmSharableApp *pApp);
00032
00033   // ICNotify methods
00034   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00035   HRESULT STDMETHODCALLTYPE Disconnect(void);
00036
00037   // IUnknown methods
00038   ULONG STDMETHODCALLTYPE AddRef(void);
00039   ULONG STDMETHODCALLTYPE Release(void);
00040   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00041 };
00042
00043
00044 //****************************************************************************
00045 //
00046 // Global Variables
00047 //
00048 //****************************************************************************
00049
00050 extern INmChannelAppShare * g_pChannelAppShare;
00051 extern CAppShareNotify    * g_pNotifyAppShare;
00052
00053
00054 //****************************************************************************
00055 //
00056 // Global Routines
00057 //
00058 //****************************************************************************
00059
00060 HRESULT HookAppShare(INmChannel * pAppShare);
00061 VOID DoCreateAppShareChannel(INmConference *pConference);
00062 VOID FreeAppShareChannel(void);
00063
00064
00065 //****************************************************************************
00066 //
00067 // msgType values
00068 //
00069 //****************************************************************************
00070
00071
00072
00073
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/WinUtils.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

WinUtils.h

Go to the documentation of this file.
00001 /*
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 global functions in winutils.c
00010 */
00011
00012 BOOL CenterWindow (HWND hwndChild, HWND hwndParent);
00013 LPTSTR   GetStringRes (int id);
00014
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DfV/WinMain.Cxx Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DfV

WinMain.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright 1992 - 2000 Microsoft Corporation.
00005 //
00006 //  File:       winmain.cxx
00007 //
00008 //  Contents:   main entry point for Stereo Shop
00009 //
00010 //  Classes:
00011 //
00012 //  Functions:  WinMain
00013 //
00014 //  History:    6-08-94   stevebl   Created
00015 //
00016 //----------------------------------------------------------------------------
00017
00018 #include "dfv.h"
00019 #include "mwclass.h"
00020 #include <ole2ver.h>
00021
00022 //+---------------------------------------------------------------------------
00023 //
00024 //  Function:   InitApplication
00025 //
00026 //  Synopsis:   initializes the application and registers its window class
00027 //              (called once for all instances)
00028 //
00029 //  Arguments:  [hInstance] - handle to the first instance
00030 //
00031 //  Returns:    TRUE on success
00032 //
00033 //  History:    4-11-94   stevebl   Created for MFract
00034 //              6-08-94   stevebl   Stolen from MFract
00035 //
00036 //----------------------------------------------------------------------------
00037
00038 BOOL InitApplication(HINSTANCE hInstance)
00039 {
00040     WNDCLASS wc;
00041
00042     wc.style = 0;
00043     wc.lpfnWndProc = &WindowProc;
00044     wc.cbClsExtra = 0;
00045     wc.cbWndExtra = 0;
00046     wc.hInstance = hInstance;
00047     wc.hIcon = LoadIcon(hInstance, TEXT("StreamIcon"));
00048     wc.hCursor = (HCURSOR) LoadCursor(NULL, IDC_ARROW);
00049     wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00050     wc.lpszMenuName = NULL;
00051     wc.lpszClassName = TEXT(STREAM_VIEW_CLASS_NAME);
00052     ATOM aReturn = RegisterClass(&wc);
00053     if (!aReturn)
00054     {
00055         return(aReturn);
00056     }
00057     wc.style = CS_DBLCLKS;
00058     wc.hIcon = LoadIcon(hInstance, TEXT("AppIcon"));
00059     wc.lpszMenuName = TEXT(MAIN_WINDOW_CLASS_MENU_STR);
00060     wc.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME);
00061     return(RegisterClass(&wc));
00062 }
00063
00064 //+---------------------------------------------------------------------------
00065 //
00066 //  Function:   WinMain
00067 //
00068 //  Synopsis:   main window proceedure
00069 //
00070 //  Arguments:  [hInstance]     - instance handle
00071 //              [hPrevInstance] - handle of the previous instance (if any)
00072 //              [lpCmdLine]     - pointer to the command line
00073 //              [nCmdShow]      - show state
00074 //
00075 //  History:    4-11-94   stevebl   Created for MFract
00076 //              6-08-94   stevebl   Stolen from MFract
00077 //
00078 //  Notes:      initializes application and starts message loop
00079 //
00080 //----------------------------------------------------------------------------
00081
00082 extern "C" int PASCAL WinMain(HINSTANCE hInstance,
00083             HINSTANCE hPrevInstance,
00084             LPSTR lpCmdLine,
00085             int nCmdShow)
00086 {
00087     DWORD dwBuildVersion = CoBuildVersion();
00088     if (HIWORD(dwBuildVersion) != rmm || LOWORD(dwBuildVersion) < rup)
00089     {
00090         // alert the caller that the OLE version is incompatible
00091         // with this build.
00092         MessageBoxFromStringIdsAndArgs(
00093             NULL,
00094             hInstance,
00095             IDS_OLEINCOMPATIBLE,
00096             IDS_ERROR,
00097             MB_OK | MB_ICONEXCLAMATION,
00098             rmm, rup);
00099         return(FALSE);
00100     }
00101     if (FAILED(CoInitialize(NULL)))
00102     {
00103         // alert the caller that OLE couldn't be initialized
00104         MessageBoxFromStringIds(
00105             NULL,
00106             hInstance,
00107             IDS_OLEINITFAILED,
00108             IDS_ERROR,
00109             MB_OK | MB_ICONEXCLAMATION);
00110         return(FALSE);
00111     }
00112     if (!hPrevInstance)
00113     {
00114         if (!InitApplication(hInstance))
00115         {
00116             CoUninitialize();
00117             return(FALSE);
00118         }
00119     }
00120     CMainWindow * pw = new CMainWindow;
00121     if (pw == NULL)
00122     {
00123         CoUninitialize();
00124         return(FALSE);
00125     }
00126     if (!pw->InitInstance(hInstance, nCmdShow))
00127     {
00128         // Note, if InitInstance has failed then it would have
00129         // already deleted pw for me so I don't delete it here.
00130         // This is because when WM_CREATE returns -1 (failure)
00131         // Windows sends the WM_DESTROY message to the window
00132         // and the the CHlprWindow class destroys itself whenever
00133         // it receives this message.
00134         CoUninitialize();
00135         return(FALSE);
00136     }
00137
00138     // check command line and try and load as a file
00139
00140     if (strlen(lpCmdLine) > 0)
00141     {
00142 #ifdef UNICODE
00143         mbstowcs(pw->_szFileName, lpCmdLine, MAX_PATH - 1);
00144 #else
00145         strncpy(pw->_szFileName, lpCmdLine, MAX_PATH - 1);
00146 #endif
00147         pw->OpenFile();
00148     }
00149
00150     MSG msg;
00151     HACCEL haccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
00152     if (haccel == NULL)
00153     {
00154         CoUninitialize();
00155         return(FALSE);
00156     }
00157
00158     while (GetMessage(&msg, NULL, 0, 0))
00159     {
00160         if (!TranslateAccelerator(
00161             pw->GetHwnd(),
00162             haccel,
00163             &msg))
00164         {
00165             TranslateMessage(&msg);
00166             DispatchMessage(&msg);
00167         }
00168     }
00169     CoUninitialize();
00170     return (int)(msg.wParam);
00171 }
00172
00173
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoServe/Connect.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoServe

Connect.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.CPP
00003
00004   Summary:   Implementation file for the connection points (and their
00005              connections) offered by the connectable objects in the
00006              STOSERVE server sample. COM objects are implemented for
00007              Connection Point Enumerators, Connection Points, and
00008              Connection Enumerators.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial STOSERVE.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Functions: none.
00020
00021   Origin:    6-10-96: atrent - Editor inheritance from CONSERVE COM
00022              Tutorial Code Sample. Very little change was required.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039
00040 /*---------------------------------------------------------------------------
00041   We include WINDOWS.H for all Win32 applications.
00042   We include OLE2.H because we will be calling the COM/OLE Libraries.
00043   We include OLECTL.H because it has definitions for connectable objects.
00044   We include APPUTIL.H because we will be building this application using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IPAPER.H and PAPGUIDS.H for the common paper-related
00048     Interface class, GUID, and CLSID specifications.
00049   We include SERVER.H because it has internal class declarations and
00050     resource ID definitions specific for this DLL.
00051   We include CONNECT.H for object class declarations for the various
00052     connection point and connection COM objects used in CONSERVE.
00053   We include PAPER.H because it has the class COEnumConnectionPoints
00054     declarations as well as the COPaper class declaration.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <olectl.h>
00059 #include <apputil.h>
00060 #include <ipaper.h>
00061 #include <papguids.h>
00062 #include "server.h"
00063 #include "connect.h"
00064 #include "paper.h"
00065
00066
00067 /*---------------------------------------------------------------------------
00068   COEnumConnectionPoints's implementation of its main COM object class
00069   including Constructor, Destructor, QueryInterface, AddRef, Release,
00070   Next, Skip, Reset, and Clone.
00071 ---------------------------------------------------------------------------*/
00072
00073 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00074   Method:   COEnumConnectionPoints::COEnumConnectionPoints
00075
00076   Summary:  COEnumConnectionPoints Constructor.
00077
00078   Args:     IUnknown* pHostObj
00079               Pointer to the host object whose connection points are
00080               being enumerated.
00081
00082   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnPts, and m_paConnPts.
00083
00084   Returns:  void
00085 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00086 COEnumConnectionPoints::COEnumConnectionPoints(
00087   IUnknown* pHostObj)
00088 {
00089   // Zero the COM object's reference count.
00090   m_cRefs = 0;
00091
00092   // Assign the Host Object pointer.
00093   m_pHostObj = pHostObj;
00094
00095   // Initialize the Connection Point enumerator variables.
00096   m_iEnumIndex = 0;
00097   m_cConnPts = 0;
00098   m_paConnPts = NULL;
00099
00100   return;
00101 }
00102
00103
00104 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00105   Method:   COEnumConnectionPoints::~COEnumConnectionPoints
00106
00107   Summary:  COEnumConnectionPoints Destructor.
00108
00109   Args:     void
00110
00111   Modifies: m_paConnPts.
00112
00113   Returns:  void
00114 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00115 COEnumConnectionPoints::~COEnumConnectionPoints(void)
00116 {
00117   if (NULL != m_paConnPts)
00118   {
00119     UINT i;
00120
00121     // Release all the connection point interface pointers.
00122     for (i=0; i<m_cConnPts; i++)
00123       if (NULL != m_paConnPts[i])
00124         m_paConnPts[i]->Release();
00125
00126     // Delete the array of interface pointers.
00127     delete [] m_paConnPts;
00128   }
00129
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   COEnumConnectionPoints::Init
00136
00137   Summary:  COEnumConnectionPoints Initialization method.  Create any
00138             necessary arrays, structures, and objects.
00139
00140   Args:     ULONG cConnPts,
00141               Number of Connections Points.
00142             IConnectionPoint** paConnPts,
00143               Pointer to array of connection point interface pointers.
00144             ULONG iEnumIndex
00145               The initial Enumerator index value.
00146
00147   Modifies: m_cConnPts, m_paConnPts, m_iEnumIndex.
00148
00149   Returns:  HRESULT
00150               Standard result code. NOERROR for success.
00151 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00152 HRESULT COEnumConnectionPoints::Init(
00153           ULONG cConnPts,
00154           IConnectionPoint** paConnPts,
00155           ULONG iEnumIndex)
00156 {
00157   HRESULT hr = NOERROR;
00158   UINT i;
00159
00160   // Remember the number of Connection points.
00161   m_cConnPts = cConnPts;
00162
00163   // Remember the initial enumerator index.
00164   m_iEnumIndex = iEnumIndex;
00165
00166   // Create a copy of the array of connection points and keep it inside
00167   // this enumerator COM object.
00168   m_paConnPts = new IConnectionPoint* [(UINT) cConnPts];
00169
00170   // Fill the array copy with the IConnectionPoint interface pointers from
00171   // the array passed. AddRef for each new Interface pointer copy made.
00172   if (NULL != m_paConnPts)
00173   {
00174     for (i=0; i<cConnPts; i++)
00175     {
00176       m_paConnPts[i] = paConnPts[i];
00177       m_paConnPts[i]->AddRef();
00178     }
00179   }
00180   else
00181     hr = E_OUTOFMEMORY;
00182
00183   return (hr);
00184 }
00185
00186
00187 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00188   Method:   COEnumConnectionPoints::QueryInterface
00189
00190   Summary:  QueryInterface of the COEnumConnectionPoints non-delegating
00191             IUnknown implementation.
00192
00193   Args:     REFIID riid,
00194               [in] GUID of the Interface being requested.
00195             PPVOID ppv)
00196               [out] Address of the caller's pointer variable that will
00197               receive the requested interface pointer.
00198
00199   Modifies: .
00200
00201   Returns:  HRESULT
00202               Standard result code. NOERROR for success.
00203 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00204 STDMETHODIMP COEnumConnectionPoints::QueryInterface(
00205                REFIID riid,
00206                PPVOID ppv)
00207 {
00208   HRESULT hr = E_NOINTERFACE;
00209
00210   *ppv = NULL;
00211
00212   // The IEnumConnectionPoints interface is implemented directly in
00213   // this COM object rather than being a nested interface implementation.
00214   if (IID_IUnknown == riid || IID_IEnumConnectionPoints == riid)
00215     *ppv = (LPVOID)this;
00216
00217   if (NULL != *ppv)
00218   {
00219     // We've handed out a pointer to the interface so obey the COM rules
00220     // and AddRef the reference count.
00221     ((LPUNKNOWN)*ppv)->AddRef();
00222     hr = NOERROR;
00223   }
00224
00225   return (hr);
00226 }
00227
00228
00229 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00230   Method:   COEnumConnectionPoints::AddRef
00231
00232   Summary:  AddRef of the COEnumConnectionPoints non-delegating IUnknown
00233             implementation.
00234
00235   Args:     void
00236
00237   Modifies: m_cRefs.
00238
00239   Returns:  ULONG
00240               New value of m_cRefs (COM object's reference count).
00241 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00242 STDMETHODIMP_(ULONG) COEnumConnectionPoints::AddRef(void)
00243 {
00244   ULONG cRefs;
00245
00246   cRefs = ++m_cRefs;
00247
00248   // Also AddRef the host object to ensure it stays around as long as
00249   // this enumerator.
00250   m_pHostObj->AddRef();
00251
00252   return cRefs;
00253 }
00254
00255
00256 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00257   Method:   COEnumConnectionPoints::Release
00258
00259   Summary:  Release of the COEnumConnectionPoints non-delegating IUnknown
00260             implementation.
00261
00262   Args:     void
00263
00264   Modifies: m_cRefs.
00265
00266   Returns:  ULONG
00267               New value of m_cRefs (COM object's reference count).
00268 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00269 STDMETHODIMP_(ULONG) COEnumConnectionPoints::Release(void)
00270 {
00271   ULONG cRefs;
00272
00273   // Pass this release along to the Host object being enumerated.
00274   m_pHostObj->Release();
00275
00276   cRefs = --m_cRefs;
00277
00278   if (0 == cRefs)
00279   {
00280     // We artificially bump the main ref count to prevent reentrancy via
00281     // the main object destructor.
00282     m_cRefs++;
00283     delete this;
00284   }
00285
00286   return cRefs;
00287 }
00288
00289
00290 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00291   Method:   COEnumConnectionPoints::Next
00292
00293   Summary:  The Next member method of this IEnumConnectionPoints interface
00294             implementation. Called by outside clients of a
00295             COEnumConnectionPoints object to request that a number of next
00296             connection point interface pointers be deposited into an array
00297             supplied by the caller.
00298
00299   Args:     ULONG cReq
00300               Number of connection points requested for return (starting at
00301               the current Enumerator index).
00302             IConnectionPoint** paConnPts,
00303               Pointer to a caller's output array that will receive the
00304               enumerated IConnectionPoint interface pointers.
00305             ULONG* cEnumerated)
00306               Pointer to a ULONG variable that will contain the number of
00307               connection points actually enumerated by this call.
00308
00309   Modifies: .
00310
00311   Returns:  HRESULT
00312               Standard result code. NOERROR for success.
00313 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00314 STDMETHODIMP COEnumConnectionPoints::Next(
00315                ULONG cReq,
00316                IConnectionPoint** paConnPts,
00317                ULONG* pcEnumerated)
00318 {
00319   HRESULT hr = NOERROR;
00320   ULONG cRet = 0;
00321
00322   // Make sure the argument values passed are valid.
00323   if (NULL != m_paConnPts)
00324   {
00325     if (NULL != paConnPts)
00326     {
00327       if (NULL != *paConnPts && m_iEnumIndex < m_cConnPts)
00328       {
00329         if (NULL != pcEnumerated)
00330           *pcEnumerated = 0L;
00331         else
00332           if (1L != cReq)
00333             hr = E_POINTER;
00334       }
00335       else
00336         hr = S_FALSE;
00337     }
00338     else
00339       hr = E_POINTER;
00340   }
00341   else
00342     hr = S_FALSE;
00343
00344   if (SUCCEEDED(hr))
00345   {
00346     // Starting at the current Enumerator index, loop to assign the
00347     // requested number of output connection point interface pointers.
00348     for (; m_iEnumIndex < m_cConnPts && cReq > 0;
00349            paConnPts++, cRet++, cReq--)
00350     {
00351       // Assign from the inside Enumerator array to the specified receiving
00352       // array.
00353       *paConnPts = m_paConnPts[m_iEnumIndex++];
00354       // After assigning a copy of an IConnectionPoint pointer, AddRef it.
00355       if (NULL != *paConnPts)
00356         (*paConnPts)->AddRef();
00357     }
00358
00359     // Assign the output number of connection points enumerated.
00360     if (NULL != pcEnumerated)
00361       *pcEnumerated = cRet;
00362   }
00363
00364   return hr;
00365 }
00366
00367
00368 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00369   Method:   COEnumConnectionPoints::Skip
00370
00371   Summary:  The Skip member method of this IEnumConnectionPoints interface
00372             implementation. Starting at the current Enumerator index, skip
00373             the specified number of connection point items.
00374
00375   Args:     ULONG cSkip
00376               Number of Connection Point items to skip.
00377
00378   Modifies: .
00379
00380   Returns:  HRESULT
00381               Standard result code. NOERROR for success.
00382 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00383 STDMETHODIMP COEnumConnectionPoints::Skip(
00384                ULONG cSkip)
00385 {
00386   HRESULT hr = NOERROR;
00387
00388   // If there really is a connection point array and the requested
00389   // amount of skip does not exceed the number of connection points,
00390   // then bump the index by the requested skip amount.
00391   if (NULL != m_paConnPts && (m_iEnumIndex + cSkip) < m_cConnPts)
00392     m_iEnumIndex += cSkip;
00393   else
00394     hr = S_FALSE;
00395
00396   return hr;
00397 }
00398
00399
00400 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00401   Method:   COEnumConnectionPoints::Reset
00402
00403   Summary:  The Reset member method of the IEnumConnectionPoints interface
00404             implementation. Resets the Enumeration index to the first
00405             connection point item in the array.
00406
00407   Args:     void.
00408
00409   Modifies: .
00410
00411   Returns:  HRESULT
00412               Standard result code. NOERROR for success.
00413 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00414 STDMETHODIMP COEnumConnectionPoints::Reset(
00415                void)
00416 {
00417   // Zero the main Enumerator index.
00418   m_iEnumIndex = 0;
00419
00420   return NOERROR;
00421 }
00422
00423
00424 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00425   Method:   COEnumConnectionPoints::Clone
00426
00427   Summary:  The Clone member method of this IEnumConnectionPoints
00428             interface implementation. Creates a new clone of this entire
00429             Connection Point enumerator COM object.
00430
00431   Args:     IEnumConnectionPoints** ppIEnum
00432               Address of the caller's output pointer variable that will
00433               receive the IEnumConnectionPoints interface pointer of the
00434               new enumerator clone.
00435
00436   Modifies: ...
00437
00438   Returns:  HRESULT
00439               Standard result code. NOERROR for success.
00440 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00441 STDMETHODIMP COEnumConnectionPoints::Clone(
00442                IEnumConnectionPoints** ppIEnum)
00443 {
00444   HRESULT hr;
00445   COEnumConnectionPoints* pCOEnum;
00446
00447   // NULL the output variable first.
00448   *ppIEnum = NULL;
00449
00450   // Create the Clone Enumerator COM object.
00451   pCOEnum = new COEnumConnectionPoints(m_pHostObj);
00452   if (NULL != pCOEnum)
00453   {
00454     // Initialize it with same values as in this existing enumerator.
00455     hr = pCOEnum->Init(m_cConnPts, m_paConnPts, m_iEnumIndex);
00456     if (SUCCEEDED(hr))
00457     {
00458       // QueryInterface to return the requested interface pointer.
00459       // An AddRef will be conveniently done by the QI.
00460       if (SUCCEEDED(hr))
00461         hr = pCOEnum->QueryInterface(
00462                         IID_IEnumConnectionPoints,
00463                         (PPVOID)ppIEnum);
00464     }
00465   }
00466   else
00467     hr = E_OUTOFMEMORY;
00468
00469   return hr;
00470 }
00471
00472
00473 /*---------------------------------------------------------------------------
00474   COConnectionPoint's implementation of its main COM object class
00475   including Constructor, Destructor, QueryInterface, AddRef, Release,
00476   GetConnectionInterface, GetConnectionPointContainer, Advise, Unadvise,
00477   and EnumConnections.
00478 ---------------------------------------------------------------------------*/
00479
00480 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00481   Method:   COConnectionPoint::COConnectionPoint
00482
00483   Summary:  COConnectionPoint Constructor.
00484
00485   Args:     IUnknown* pHostObj
00486               Pointer to IUnknown of the connectable object offering this
00487               connection point.
00488
00489   Modifies: ...
00490
00491   Returns:  void
00492 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00493 COConnectionPoint::COConnectionPoint(
00494   IUnknown* pHostObj)
00495 {
00496   // Zero the COM object's reference count.
00497   m_cRefs = 0;
00498
00499   // Remember an IUnknown pointer to the connectable object that offers
00500   // this connection point. Since this connection point object's lifetime
00501   // is geared to that of the connectable object there is no need to
00502   // AddRef the following copied pointer to the connectable object.
00503   m_pHostObj = pHostObj;
00504
00505   // Initialize the Connection Point variables.
00506   m_dwNextCookie = COOKIE_START_VALUE;
00507   m_uiMaxIndex = 0;
00508   m_cConnections = 0;
00509   m_paConnections = NULL;
00510
00511   return;
00512 }
00513
00514
00515 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00516   Method:   COConnectionPoint::~COConnectionPoint
00517
00518   Summary:  COConnectionPoint Destructor.
00519
00520   Args:     void
00521
00522   Modifies: m_paConnections.
00523
00524   Returns:  void
00525 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00526 COConnectionPoint::~COConnectionPoint(void)
00527 {
00528   UINT i;
00529   IUnknown* pUnk;
00530
00531   if (NULL != m_paConnections)
00532   {
00533     // Release all the connection sink interface pointers.
00534     for (i=0; i<m_uiMaxIndex; i++)
00535     {
00536       pUnk = m_paConnections[i].pUnk;
00537       if (NULL != pUnk)
00538         pUnk->Release();
00539     }
00540
00541     // Delete the array of interface pointers.
00542     delete [] m_paConnections;
00543   }
00544
00545   return;
00546 }
00547
00548
00549 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00550   Method:   COConnectionPoint::Init
00551
00552   Summary:  COConnectionPoint Initialization method.  Create any
00553             necessary arrays, structures, and subordinate objects.
00554
00555   Args:     REFIID riid
00556               Reference to the IID of the Sink interface associated with
00557               this connection point.
00558
00559   Modifies: ...
00560
00561   Returns:  HRESULT
00562               Standard result code. NOERROR for success.
00563 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00564 HRESULT COConnectionPoint::Init(
00565           REFIID riid)
00566 {
00567   HRESULT hr = NOERROR;
00568   CONNECTDATA* paConns;
00569
00570   // Keep a copy of the reference to the IID of the sink interface
00571   // associated with this connection point. Needed for later
00572   // use by the GetConnectionInterface method.
00573   m_iidSink = riid;
00574
00575   // Build the initial dynamic array for connections.
00576   paConns = new CONNECTDATA[ALLOC_CONNECTIONS];
00577   if (NULL != paConns)
00578   {
00579     // Zero the array.
00580     memset(paConns, 0, ALLOC_CONNECTIONS * sizeof(CONNECTDATA));
00581
00582     // Rig this connection point object so that it will use the
00583     // new internal array of connections.
00584     m_uiMaxIndex = ALLOC_CONNECTIONS;
00585     m_paConnections = paConns;
00586   }
00587   else
00588     hr = E_OUTOFMEMORY;
00589
00590   return (hr);
00591 }
00592
00593
00594 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00595   Method:   COConnectionPoint::QueryInterface
00596
00597   Summary:  QueryInterface of the COConnectionPoint non-delegating
00598             IUnknown implementation.
00599
00600   Args:     REFIID riid,
00601               [in] GUID of the Interface being requested.
00602             PPVOID ppv)
00603               [out] Address of the caller's pointer variable that will
00604               receive the requested interface pointer.
00605
00606   Modifies: .
00607
00608   Returns:  HRESULT
00609               Standard result code. NOERROR for success.
00610 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00611 STDMETHODIMP COConnectionPoint::QueryInterface(
00612                REFIID riid,
00613                PPVOID ppv)
00614 {
00615   HRESULT hr = E_NOINTERFACE;
00616
00617   *ppv = NULL;
00618
00619   // The IConnectionPoint interface is implemented directly in this
00620   // COM object rather than being a nested interface implementation.
00621   if (IID_IUnknown == riid || IID_IConnectionPoint == riid)
00622     *ppv = (LPVOID)this;
00623
00624   if (NULL != *ppv)
00625   {
00626     // We've handed out a pointer to the interface so obey the COM rules
00627     // and AddRef the reference count.
00628     ((LPUNKNOWN)*ppv)->AddRef();
00629     hr = NOERROR;
00630   }
00631
00632   return (hr);
00633 }
00634
00635
00636 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00637   Method:   COConnectionPoint::AddRef
00638
00639   Summary:  AddRef of the COConnectionPoint non-delegating IUnknown
00640             implementation.
00641
00642   Args:     void
00643
00644   Modifies: m_cRefs.
00645
00646   Returns:  ULONG
00647               New value of m_cRefs (COM object's reference count).
00648 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00649 STDMETHODIMP_(ULONG) COConnectionPoint::AddRef(void)
00650 {
00651   ULONG cRefs;
00652
00653   if (OwnThis())
00654   {
00655     cRefs = ++m_cRefs;
00656
00657     UnOwnThis();
00658   }
00659
00660   return cRefs;
00661 }
00662
00663
00664 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00665   Method:   COConnectionPoint::Release
00666
00667   Summary:  Release of the COConnectionPoint non-delegating IUnknown
00668             implementation.
00669
00670   Args:     void
00671
00672   Modifies: m_cRefs.
00673
00674   Returns:  ULONG
00675               New value of m_cRefs (COM object's reference count).
00676 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00677 STDMETHODIMP_(ULONG) COConnectionPoint::Release(void)
00678 {
00679   ULONG cRefs;
00680
00681   if (OwnThis())
00682   {
00683     cRefs = --m_cRefs;
00684
00685     if (0 == cRefs)
00686     {
00687       // We artificially bump the main ref count to prevent reentrancy via
00688       // the main object destructor. We relinquish thread ownership of this
00689       // object prior to deleting it--a good practice.
00690       m_cRefs++;
00691       UnOwnThis();
00692       delete this;
00693     }
00694     else
00695       UnOwnThis();
00696   }
00697
00698   return cRefs;
00699 }
00700
00701
00702 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00703   Method:   COConnectionPoint::GetSlot
00704
00705   Summary:  An internal private utility member method to obtain a free
00706             slot in the dynamic connections array. GetSlot will expand the
00707             dynamic array for more entries if needed. To guarantee thread
00708             safety, this private method should always be called within the
00709             protection of a bracketed OwnThis, UnOwnThis pair.
00710
00711   Args:     UINT* puiFreeSlot
00712               Address of an output variable to receive the free slot index.
00713
00714   Modifies: m_uiMaxIndex, m_paConnections.
00715
00716   Returns:  HRESULT
00717               Standard result code. NOERROR for success.
00718 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00719 HRESULT COConnectionPoint::GetSlot(
00720           UINT* puiFreeSlot)
00721 {
00722   HRESULT hr = NOERROR;
00723   BOOL bOpen = FALSE;
00724   UINT i;
00725   CONNECTDATA* paConns;
00726
00727   // Zero the output variable.
00728   *puiFreeSlot = 0;
00729
00730   // Loop to find an empty slot.
00731   for (i=0; i<m_uiMaxIndex; i++)
00732   {
00733     if (m_paConnections[i].dwCookie == 0)
00734     {
00735       // We found an open empty slot.
00736       *puiFreeSlot = i;
00737       bOpen = TRUE;
00738       break;
00739     }
00740   }
00741
00742   if (!bOpen)
00743   {
00744     // We didn't find an existing open slot in the array--it's full.
00745     // Expand the array by ALLOC_CONNECTIONS entries and assign the
00746     // appropriate output index.
00747     paConns = new CONNECTDATA[m_uiMaxIndex + ALLOC_CONNECTIONS];
00748     if (NULL != paConns)
00749     {
00750       // Copy the content of the old full array to the new larger array.
00751       for (i=0; i<m_uiMaxIndex; i++)
00752       {
00753         paConns[i].pUnk = m_paConnections[i].pUnk;
00754         paConns[i].dwCookie = m_paConnections[i].dwCookie;
00755       }
00756
00757       // Zero (ie mark as empty) the expanded portion of the new array.
00758       for (i=m_uiMaxIndex; i<m_uiMaxIndex+ALLOC_CONNECTIONS; i++)
00759       {
00760         paConns[i].pUnk = NULL;
00761         paConns[i].dwCookie = 0;
00762       }
00763
00764       // New larger array is ready--delete the old array.
00765       delete [] m_paConnections;
00766
00767       // Rig the connection point to use the new larger array.
00768       m_paConnections = paConns;
00769
00770       // Assign the output free slot as first entry in new expanded area.
00771       *puiFreeSlot = m_uiMaxIndex;
00772
00773       // Calculate the new max index.
00774       m_uiMaxIndex += ALLOC_CONNECTIONS;
00775     }
00776     else
00777       hr = E_OUTOFMEMORY;
00778   }
00779
00780   return hr;
00781 }
00782
00783
00784 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00785   Method:   COConnectionPoint::FindSlot
00786
00787   Summary:  An internal private utility member method to find an existing
00788             slot (identified by the specified dwCookie value) in the
00789             dynamic connections array.
00790
00791   Args:     DWORD dwCookie,
00792               The connection key (cookie) to find.
00793             UINT* puiSlot)
00794               Address of an output variable to receive the slot index.
00795
00796   Modifies: ...
00797
00798   Returns:  HRESULT
00799               Standard result code. NOERROR for success.
00800 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00801 HRESULT COConnectionPoint::FindSlot(
00802           DWORD dwCookie,
00803           UINT* puiSlot)
00804 {
00805   HRESULT hr = CONNECT_E_NOCONNECTION;
00806   UINT i;
00807
00808   // Loop to find the Cookie.
00809   for (i=0; i<m_uiMaxIndex; i++)
00810   {
00811     if (dwCookie == m_paConnections[i].dwCookie)
00812     {
00813       // If a cookie match is found, assign the output slot index.
00814       *puiSlot = i;
00815       hr = NOERROR;
00816       break;
00817     }
00818   }
00819
00820   return hr;
00821 }
00822
00823
00824 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00825   Method:   COConnectionPoint::GetConnectionInterface
00826
00827   Summary:  The GetConnectionInterface member method of this
00828             IConnectionPoint interface implementation. Called to get the
00829             IID of the Sink interface associated with this connection
00830             point.
00831
00832   Args:     IID* piidSink
00833               Pointer to the IID of the associated sink interface.
00834
00835   Modifies: .
00836
00837   Returns:  HRESULT
00838               Standard result code. NOERROR for success.
00839 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00840 STDMETHODIMP COConnectionPoint::GetConnectionInterface(
00841                IID* piidSink)
00842 {
00843   HRESULT hr = NOERROR;
00844
00845   if (NULL != piidSink)
00846     *piidSink = m_iidSink;
00847   else
00848     hr = E_POINTER;
00849
00850   return hr;
00851 }
00852
00853
00854 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00855   Method:   COConnectionPoint::GetConnectionPointContainer
00856
00857   Summary:  The GetConnectionPointContainer member method of this
00858             IConnectionPoint interface implementation. Called to get the
00859             connection point container that contains this connection
00860             point.
00861
00862   Args:     IConnectionPointContainer** ppConnPtCon
00863               Address of the pointer variable that will recieve the
00864               IConnectionPointContainer interface pointer.
00865
00866   Modifies: .
00867
00868   Returns:  HRESULT
00869               Standard result code. NOERROR for success.
00870 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00871 STDMETHODIMP COConnectionPoint::GetConnectionPointContainer(
00872                IConnectionPointContainer** ppConnPtCon)
00873 {
00874   HRESULT hr;
00875
00876   // Use QueryInterface to get the interface pointer and to perform the
00877   // needed AddRef on the returned pointer.
00878   hr = m_pHostObj->QueryInterface(
00879                      IID_IConnectionPointContainer,
00880                      (PPVOID) ppConnPtCon);
00881
00882   return hr;
00883 }
00884
00885
00886 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00887   Method:   COConnectionPoint::Advise
00888
00889   Summary:  The Advise member method of this IConnectionPoint interface
00890             implementation. Called by clients to establish a connection of
00891             their sink to this connection point. Uses the CThreaded
00892             OwnThis mechanism to provide mutually exclusive access by
00893             multiple threads.
00894
00895   Args:     IUnknown* pUnkSink
00896               IUnknown interface pointer of the Sink object in the client.
00897             DWORD* pdwCookie
00898               Pointer to a DWORD in the client that will receive a unique
00899               key used by the client to refer to the connection established
00900               by this Advise call.
00901
00902   Modifies: ...
00903
00904   Returns:  HRESULT
00905               Standard result code. NOERROR for success.
00906 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00907 STDMETHODIMP COConnectionPoint::Advise(
00908                IUnknown* pUnkSink,
00909                DWORD* pdwCookie)
00910 {
00911   HRESULT hr = NOERROR;
00912   UINT uiFreeSlot = 0;
00913   IUnknown* pISink = NULL;
00914
00915   if (OwnThis())
00916   {
00917     // Zero the output connection key.
00918     *pdwCookie = 0;
00919
00920     // Get the specific associated client Sink interface that this
00921     // connection point expects to use for notifications.
00922     hr = pUnkSink->QueryInterface(m_iidSink, (PPVOID)&pISink);
00923     if (SUCCEEDED(hr))
00924     {
00925       // Store the specific sink interface in this connection point's
00926       // array of live connections. First find a free slot (expand the
00927       // array if needed).
00928       hr = GetSlot(&uiFreeSlot);
00929       if (SUCCEEDED(hr))
00930       {
00931         // Assign the new slot with the connection entry.
00932         m_paConnections[uiFreeSlot].pUnk = pISink;
00933         m_paConnections[uiFreeSlot].dwCookie = m_dwNextCookie;
00934
00935         // Assign the output Cookie value.
00936         *pdwCookie = m_dwNextCookie;
00937
00938         // Increment the Cookie counter.
00939         m_dwNextCookie++;
00940
00941         // Increment the number of live connections.
00942         m_cConnections++;
00943       }
00944     }
00945     else if (hr == E_NOINTERFACE)
00946     {
00947        // The sink does not support m_iidSink.
00948        hr = CONNECT_E_CANNOTCONNECT;
00949     }
00950
00951     UnOwnThis();
00952   }
00953
00954   return hr;
00955 }
00956
00957
00958 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00959   Method:   COConnectionPoint::Unadvise
00960
00961   Summary:  The Unadvise member method of this IConnectionPoint interface
00962             implementation. Called by clients to disconnect a connection
00963             of their sink to this connection point. The connection is
00964             identified by the dwCookie argument (obtained by a previous
00965             Advise call). Uses the CThreaded OwnThis mechanism to provide
00966             mutually exclusive access by multiple threads.
00967
00968   Args:     DWORD dwCookie
00969               Connection key that was obtained by a previous Advise call.
00970
00971   Modifies: .
00972
00973   Returns:  HRESULT
00974               Standard result code. NOERROR for success.
00975 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00976 STDMETHODIMP COConnectionPoint::Unadvise(
00977                DWORD dwCookie)
00978 {
00979   HRESULT hr = NOERROR;
00980   UINT uiSlot;
00981
00982   if (0 != dwCookie)
00983   {
00984     if (OwnThis())
00985     {
00986       hr = FindSlot(dwCookie, &uiSlot);
00987       if (SUCCEEDED(hr))
00988       {
00989         // Release the sink interface.
00990         RELEASE_INTERFACE(m_paConnections[uiSlot].pUnk);
00991
00992         // Mark the array entry as empty.
00993         m_paConnections[uiSlot].dwCookie = 0;
00994
00995         // Decrement the number of live connections.
00996         m_cConnections--;
00997       }
00998
00999       UnOwnThis();
01000     }
01001   }
01002   else
01003     hr = E_INVALIDARG;
01004
01005   return hr;
01006 }
01007
01008
01009 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01010   Method:   COConnectionPoint::EnumConnections
01011
01012   Summary:  The EnumConnections member method of this IConnectionPoint
01013             interface implementation. Called to obtain an IEnumConnections
01014             enumerator interface that can be used to enumerate the
01015             connections of this connection point. Uses the CThreaded
01016             OwnThis mechanism to ensure mutually exclusive access by
01017             multiple threads.
01018
01019   Args:     IEnumConnections** ppIEnum
01020               Address of the caller's output pointer variable that will
01021               receive the enumerator IEnumConnections interface pointer.
01022
01023   Modifies: ...
01024
01025   Returns:  HRESULT
01026               Standard result code. NOERROR for success.
01027 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01028 STDMETHODIMP COConnectionPoint::EnumConnections(
01029                IEnumConnections** ppIEnum)
01030 {
01031   HRESULT hr = OLE_E_NOCONNECTION;
01032   CONNECTDATA* paConns;
01033   COEnumConnections* pCOEnum;
01034   UINT i,j;
01035
01036   if (OwnThis())
01037   {
01038     // Zero the output enumerator interface pointer.
01039     *ppIEnum = NULL;
01040
01041     if (0 != m_cConnections)
01042     {
01043       // Create an array of CONNECTDATA structures.
01044       paConns = new CONNECTDATA[(UINT)m_cConnections];
01045       if (NULL != paConns)
01046       {
01047         for (i=0, j=0; i<m_uiMaxIndex && j<m_cConnections; i++)
01048         {
01049           // Copy non-empty entries only.
01050           if (0 != m_paConnections[i].dwCookie)
01051           {
01052             // Assign the occupied entry.
01053             paConns[j].pUnk = (IUnknown*)m_paConnections[i].pUnk;
01054             paConns[j].dwCookie = m_paConnections[i].dwCookie;
01055             j++;
01056           }
01057         }
01058
01059         // Create a new COM object for enumerating connections. Pass
01060         // 'this' as a pHostObj pointer used later to ensure the host
01061         // connection point object stays alive as long as the enumerator
01062         // that enumerates connections to that connection point.
01063         pCOEnum = new COEnumConnections(this);
01064         if (NULL != pCOEnum)
01065         {
01066           // Use the previously constructed (paConns) array of connections
01067           // to init the new COEnumConnections COM object. The Init will
01068           // build yet another internal copy of this array. Set the
01069           // initial enumerator index to 0.
01070           hr = pCOEnum->Init(m_cConnections, paConns, 0);
01071
01072           // QueryInterface to return the requested interface pointer.
01073           // An AddRef will be conveniently done by the QI.
01074           if (SUCCEEDED(hr))
01075             hr = pCOEnum->QueryInterface(
01076                             IID_IEnumConnections,
01077                             (PPVOID)ppIEnum);
01078         }
01079         else
01080           hr = E_OUTOFMEMORY;
01081
01082         // We're done with the locally constructed array copy--delete it.
01083         delete [] paConns;
01084       }
01085       else
01086         hr = E_OUTOFMEMORY;
01087     }
01088
01089     UnOwnThis();
01090   }
01091
01092   return hr;
01093 }
01094
01095
01096 /*---------------------------------------------------------------------------
01097   COEnumConnections's implementation of its main COM object class
01098   including Constructor, Destructor, QueryInterface, AddRef, Release,
01099   Next, Skip, Reset, and Clone.
01100 ---------------------------------------------------------------------------*/
01101
01102 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01103   Method:   COEnumConnections::COEnumConnections
01104
01105   Summary:  COEnumConnections Constructor.
01106
01107   Args:     IUnknown* pHostObj
01108               Pointer to IUnknown interface of the host Connection Point
01109               COM object whose connections are being enumerated.
01110
01111   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnections,
01112             and m_paConnections.
01113
01114   Returns:  void
01115 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01116 COEnumConnections::COEnumConnections(
01117   IUnknown* pHostObj)
01118 {
01119   // Zero the COM object's reference count.
01120   m_cRefs = 0;
01121
01122   // Assign the Host Object pointer.
01123   m_pHostObj = pHostObj;
01124
01125   // Initialize the Connection Point enumerator variables.
01126   m_iEnumIndex = 0;
01127   m_cConnections = 0;
01128   m_paConnections = NULL;
01129
01130   return;
01131 }
01132
01133
01134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01135   Method:   COEnumConnections::~COEnumConnections
01136
01137   Summary:  COEnumConnections Destructor.
01138
01139   Args:     void
01140
01141   Modifies: m_paConnections.
01142
01143   Returns:  void
01144 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01145 COEnumConnections::~COEnumConnections(void)
01146 {
01147   if (NULL != m_paConnections)
01148   {
01149     UINT i;
01150
01151     // Release all the connected sink interface pointers.
01152     for (i=0; i<m_cConnections; i++)
01153       m_paConnections[i].pUnk->Release();
01154
01155     // Delete the array of connections.
01156     delete [] m_paConnections;
01157   }
01158
01159   return;
01160 }
01161
01162
01163 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01164   Method:   COEnumConnections::Init
01165
01166   Summary:  COEnumConnections Initialization method.  Create any
01167             necessary arrays, structures, and objects.
01168
01169   Args:     ULONG cConnections
01170               Number of Connections.
01171             CONNECTDATA* paConnections,
01172               Pointer to array of connections.
01173             ULONG iEnumIndex
01174               The Enumerator index initial value.
01175
01176   Modifies: m_cConnections, m_paConnections, m_pHostObj, m_iEnumIndex.
01177
01178   Returns:  HRESULT
01179               Standard result code. NOERROR for success.
01180 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01181 HRESULT COEnumConnections::Init(
01182           ULONG cConnections,
01183           CONNECTDATA* paConnections,
01184           ULONG iEnumIndex)
01185 {
01186   HRESULT hr = NOERROR;
01187   UINT i;
01188
01189   // Remember the number of live Connections.
01190   m_cConnections = cConnections;
01191
01192   // Remember the initial enumerator index.
01193   m_iEnumIndex = iEnumIndex;
01194
01195   // Create a copy of the array of connections and keep it inside
01196   // this enumerator COM object.
01197   m_paConnections = new CONNECTDATA [(UINT) cConnections];
01198
01199   // Fill the array copy with the connection data from the connections
01200   // array passed. AddRef for each new sink Interface pointer copy made.
01201   if (NULL != m_paConnections)
01202   {
01203     for (i=0; i<cConnections; i++)
01204     {
01205       m_paConnections[i] = paConnections[i];
01206       m_paConnections[i].pUnk->AddRef();
01207     }
01208   }
01209   else
01210     hr = E_OUTOFMEMORY;
01211
01212   return (hr);
01213 }
01214
01215
01216 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01217   Method:   COEnumConnections::QueryInterface
01218
01219   Summary:  QueryInterface of the COEnumConnections non-delegating
01220             IUnknown implementation.
01221
01222   Args:     REFIID riid,
01223               [in] GUID of the Interface being requested.
01224             PPVOID ppv)
01225               [out] Address of the caller's pointer variable that will
01226               receive the requested interface pointer.
01227
01228   Modifies: .
01229
01230   Returns:  HRESULT
01231               Standard result code. NOERROR for success.
01232 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01233 STDMETHODIMP COEnumConnections::QueryInterface(
01234                REFIID riid,
01235                PPVOID ppv)
01236 {
01237   HRESULT hr = E_NOINTERFACE;
01238
01239   *ppv = NULL;
01240
01241   // The IEnumConnections interface is implemented directly in
01242   // this COM object rather than being a nested interface implementation.
01243   if (IID_IUnknown == riid || IID_IEnumConnections == riid)
01244     *ppv = (LPVOID)this;
01245
01246   if (NULL != *ppv)
01247   {
01248     // We've handed out a pointer to the interface so obey the COM rules
01249     // and AddRef the reference count.
01250     ((LPUNKNOWN)*ppv)->AddRef();
01251     hr = NOERROR;
01252   }
01253
01254   return (hr);
01255 }
01256
01257
01258 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01259   Method:   COEnumConnections::AddRef
01260
01261   Summary:  AddRef of the COEnumConnections non-delegating IUnknown
01262             implementation.
01263
01264   Args:     void
01265
01266   Modifies: m_cRefs.
01267
01268   Returns:  ULONG
01269               New value of m_cRefs (COM object's reference count).
01270 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01271 STDMETHODIMP_(ULONG) COEnumConnections::AddRef(void)
01272 {
01273   ULONG cRefs;
01274
01275   cRefs = ++m_cRefs;
01276
01277   // Also AddRef the host object to ensure it stays around as long as
01278   // this enumerator.
01279   m_pHostObj->AddRef();
01280
01281   return cRefs;
01282 }
01283
01284
01285 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01286   Method:   COEnumConnections::Release
01287
01288   Summary:  Release of the COEnumConnections non-delegating IUnknown
01289             implementation.
01290
01291   Args:     void
01292
01293   Modifies: m_cRefs.
01294
01295   Returns:  ULONG
01296               New value of m_cRefs (COM object's reference count).
01297 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01298 STDMETHODIMP_(ULONG) COEnumConnections::Release(void)
01299 {
01300   ULONG cRefs;
01301
01302   // Pass this release along to the Host object being enumerated.
01303   m_pHostObj->Release();
01304
01305   cRefs = --m_cRefs;
01306
01307   if (0 == cRefs)
01308   {
01309     // We artificially bump the main ref count to prevent reentrancy via
01310     // the main object destructor.
01311     m_cRefs++;
01312     delete this;
01313   }
01314
01315   return cRefs;
01316 }
01317
01318
01319 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01320   Method:   COEnumConnections::Next
01321
01322   Summary:  The Next member method of this IEnumConnections interface
01323             implementation. Called by outside clients of a
01324             COEnumConnections object to request a number of next
01325             connections be returned in an array supplied by the caller.
01326
01327   Args:     ULONG cReq
01328               Number of connection points requested for return (starting at
01329               the current Enumerator index).
01330             CONNECTDATA* paConnections,
01331               Pointer to a caller's output array that will receive the
01332               enumerated connection data structures.
01333             ULONG* pcEnumerated)
01334               Pointer to a ULONG variable that will contain the number of
01335               connection points actually enumerated by this call.
01336
01337   Modifies: .
01338
01339   Returns:  HRESULT
01340               Standard result code. NOERROR for success.
01341 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01342 STDMETHODIMP COEnumConnections::Next(
01343                ULONG cReq,
01344                CONNECTDATA* paConnections,
01345                ULONG* pcEnumerated)
01346 {
01347   HRESULT hr = NOERROR;
01348   ULONG cRet = 0;
01349
01350   // Make sure the argument values passed are valid.
01351   if (NULL != m_paConnections)
01352   {
01353     if (NULL != paConnections)
01354     {
01355       if (m_iEnumIndex < m_cConnections)
01356       {
01357         if (NULL != pcEnumerated)
01358           *pcEnumerated = 0L;
01359         else
01360           if (1L != cReq)
01361             hr = E_POINTER;
01362       }
01363       else
01364         hr = S_FALSE;
01365     }
01366     else
01367       hr = E_POINTER;
01368   }
01369   else
01370     hr = S_FALSE;
01371
01372   if (SUCCEEDED(hr))
01373   {
01374     // Starting at the current Enumerator index, loop to assign the
01375     // requested number of output connection data structures.
01376     for (; m_iEnumIndex < m_cConnections && cReq > 0;
01377            paConnections++, m_iEnumIndex++, cRet++, cReq--)
01378     {
01379       // Because we are assigning a copy of a connection's data, AddRef
01380       // its sink interface pointer.
01381       if (NULL != m_paConnections[m_iEnumIndex].pUnk)
01382         m_paConnections[m_iEnumIndex].pUnk->AddRef();
01383
01384       // Assign a connection's data from the inside Enumerator array to
01385       // the specified output receiving array.
01386       *paConnections = m_paConnections[m_iEnumIndex];
01387     }
01388
01389     // Assign the output number of connections enumerated.
01390     if (NULL != pcEnumerated)
01391       *pcEnumerated = cRet;
01392   }
01393
01394   return hr;
01395 }
01396
01397
01398 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01399   Method:   COEnumConnections::Skip
01400
01401   Summary:  The Skip member method of this IEnumConnections interface
01402             implementation. Starting at the current Enumerator index, skip
01403             the specified number of connection items.
01404
01405   Args:     ULONG cSkip
01406               Number of Connection items to skip.
01407
01408   Modifies: .
01409
01410   Returns:  HRESULT
01411               Standard result code. NOERROR for success.
01412 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01413 STDMETHODIMP COEnumConnections::Skip(
01414                ULONG cSkip)
01415 {
01416   HRESULT hr = NOERROR;
01417
01418   // If there really is a connection array and the requested
01419   // amount of skip does not exceed the number of connections,
01420   // then bump the index by the requested skip amount.
01421   if (NULL != m_paConnections && (m_iEnumIndex + cSkip) < m_cConnections)
01422     m_iEnumIndex += cSkip;
01423   else
01424     hr = S_FALSE;
01425
01426   return hr;
01427 }
01428
01429
01430 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01431   Method:   COEnumConnections::Reset
01432
01433   Summary:  The Reset member method of the IEnumConnections interface
01434             implementation. Resets the Enumeration index to the first
01435             connection item in the array.
01436
01437   Args:     void.
01438
01439   Modifies: .
01440
01441   Returns:  HRESULT
01442               Standard result code. NOERROR for success.
01443 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01444 STDMETHODIMP COEnumConnections::Reset(
01445                void)
01446 {
01447   // Zero the main Enumerator index.
01448   m_iEnumIndex = 0;
01449
01450   return NOERROR;
01451 }
01452
01453
01454 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01455   Method:   COEnumConnections::Clone
01456
01457   Summary:  The Clone member method of this IEnumConnections interface
01458             implementation. Creates a new clone of this entire Connection
01459             enumerator COM object and returns a pointer to its
01460             IEnumConnections interface.
01461
01462   Args:     IEnumConnections** ppIEnum
01463               Address of the caller's output pointer variable that will
01464               receive the IEnumConnections interface pointer of the
01465               new enumerator clone.
01466
01467   Modifies: ...
01468
01469   Returns:  HRESULT
01470               Standard result code. NOERROR for success.
01471 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01472 STDMETHODIMP COEnumConnections::Clone(
01473                IEnumConnections** ppIEnum)
01474 {
01475   HRESULT hr;
01476   COEnumConnections* pCOEnum;
01477
01478   // NULL the output variable first.
01479   *ppIEnum = NULL;
01480
01481   // Create the Clone Enumerator COM object.
01482   pCOEnum = new COEnumConnections(m_pHostObj);
01483   if (NULL != pCOEnum)
01484   {
01485     // Initialize it with same values as in this existing enumerator.
01486     hr = pCOEnum->Init(m_cConnections, m_paConnections, m_iEnumIndex);
01487     if (SUCCEEDED(hr))
01488     {
01489       // QueryInterface to return the requested interface pointer.
01490       // An AddRef will be conveniently done by the QI.
01491       if (SUCCEEDED(hr))
01492         hr = pCOEnum->QueryInterface(
01493                         IID_IEnumConnections,
01494                         (PPVOID)ppIEnum);
01495     }
01496   }
01497   else
01498     hr = E_OUTOFMEMORY;
01499
01500   return hr;
01501 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/XactAttributeEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

XactAttributeEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: XactAttributeEnum
00019
00020 public class XactAttributeEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final int adXactCommitRetaining = 131072;
00023   public static final int adXactAbortRetaining = 262144;
00024   public static final int adXactAsyncPhaseOne = 524288;
00025   public static final int adXactSyncPhaseOne = 1048576;
00026 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/rcvall/resolve.h Source File

  • NetDS
  • WinSock
  • rcvall

resolve.h

Go to the documentation of this file.
00001 //
00002 // This file contains function prototypes for resolve.cpp
00003 //
00004 // These are common routines for resolving and printing IPv4 and IPv6
00005 // addresses.
00006 //
00007 #ifndef _RESOLVE_H_
00008 #define _RESOLVE_H_
00009
00010 #ifdef _cplusplus
00011 extern "C" {
00012 #endif
00013
00014 int              PrintAddress(SOCKADDR *sa, int salen);
00015 int              FormatAddress(SOCKADDR *sa, int salen, char *addrbuf, int addrbuflen);
00016 int              ReverseLookup(SOCKADDR *sa, int salen, char *namebuf, int namebuflen);
00017 struct addrinfo *ResolveAddress(char *addr, char *port, int af, int type, int proto);
00018
00019 #ifdef _cplusplus
00020 }
00021 #endif
00022
00023 #endif
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/Module.h Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

Module.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        module.h
00007 //
00008 // Contents:    CCertManageExitModuleSample definition
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "certxsam.h"
00013 #include "resource.h"       // main symbols
00014
00015
00016 class CCertManageExitModuleSample:
00017     public CComDualImpl<ICertManageModule, &IID_ICertManageModule, &LIBID_CERTEXITSAMPLELib>,
00018     public CComObjectRoot,
00019     public CComCoClass<CCertManageExitModuleSample, &CLSID_CCertManageExitModuleSample>
00020 {
00021 public:
00022     CCertManageExitModuleSample() {}
00023     ~CCertManageExitModuleSample() {}
00024
00025 BEGIN_COM_MAP(CCertManageExitModuleSample)
00026     COM_INTERFACE_ENTRY(IDispatch)
00027     COM_INTERFACE_ENTRY(ICertManageModule)
00028 END_COM_MAP()
00029
00030 DECLARE_NOT_AGGREGATABLE(CCertManageExitModuleSample)
00031 // Remove the comment from the line above if you don't want your object to
00032 // support aggregation.  The default is to support it
00033
00034 // UNDONE UNDONE
00035 DECLARE_REGISTRY(
00036     CCertManageExitModuleSample,
00037     wszCLASS_CERTMANAGEEXITMODULE TEXT(".1"),
00038     wszCLASS_CERTMANAGEEXITMODULE,
00039     IDS_CERTMANAGEEXITMODULE_DESC,
00040     THREADFLAGS_BOTH)
00041
00042 // ICertManageModule
00043 public:
00044     STDMETHOD (GetProperty) (
00045             /* [in] */ const BSTR strConfig,
00046             /* [in] */ BSTR strStorageLocation,
00047             /* [in] */ BSTR strPropertyName,
00048             /* [in] */ LONG dwFlags,
00049             /* [retval][out] */ VARIANT __RPC_FAR *pvarProperty);
00050
00051     STDMETHOD (SetProperty)(
00052             /* [in] */ const BSTR strConfig,
00053             /* [in] */ BSTR strStorageLocation,
00054             /* [in] */ BSTR strPropertyName,
00055             /* [in] */ LONG dwFlags,
00056             /* [in] */ VARIANT const __RPC_FAR *pvarProperty);
00057
00058     STDMETHOD (Configure)(
00059             /* [in] */ const BSTR strConfig,
00060             /* [in] */ BSTR strStorageLocation,
00061             /* [in] */ LONG dwFlags);
00062 };
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProgress Member List

This is the complete list of members for CProgress, including all inherited members.
Cancel() | CProgress | [virtual]
CDialogBase(HWND hWnd, HINSTANCE hInst) | CDialogBase |
CProgress(HWND hWnd, HINSTANCE hInst) | CProgress |
Destroy() | CProgress | [virtual]
Display() | CProgress | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CProgress | [static]
m_fCancel | CProgress |
m_hInst | CDialogBase |
m_hWnd | CDialogBase |
SetHeading(WCHAR *pwszText) | CProgress | [virtual]
SetText(WCHAR *pwszText) | CProgress | [virtual]
Update(WCHAR *pwszText) | CProgress | [virtual]
~CDialogBase() | CDialogBase | [virtual]
~CProgress() | CProgress | [virtual]
Generated on Wed Nov 13 2024 16:57:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/igetrow.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

igetrow.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module IGETROW.CPP | IGetRow interface implementation
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014
00015 // Code ----------------------------------------------------------------------
00016
00017 //  IGetRow specific interface methods
00018
00019 // CImpIGetRow::GetRowFromHROW -----------------------------------------------
00020 //
00021 // @mfunc Returns a row object given an HROW
00022 //
00023 // @rdesc HRESULT
00024 //      @flag S_OK           | Method Succeeded
00025 //    @flag E_INVALIDARG           | ppUnk was NULL
00026 //    @flag E_OUTOFMEMORY          | Out of memory
00027 //      @flag DB_E_BADROWHANDLE      | Invalid row handle given
00028 //      @flag OTHER                  | Other HRESULTs returned by called functions
00029 //
00030 STDMETHODIMP CImpIGetRow::GetRowFromHROW
00031 (
00032   IUnknown *  pIUnkOuter,
00033   HROW    hRow,
00034   REFIID    riid,
00035   IUnknown ** ppUnk
00036 )
00037 {
00038   HRESULT hr = S_OK;
00039   CRow* pCRow = NULL;
00040
00041   if( NULL == ppUnk )
00042     return E_INVALIDARG;
00043
00044   *ppUnk = NULL;
00045
00046   if( pIUnkOuter && riid != IID_IUnknown )
00047     return DB_E_NOAGGREGATION;
00048
00049   if( DB_NULL_HROW == hRow )
00050     return DB_E_BADROWHANDLE;
00051
00052   //Create a CRow object
00053   pCRow = new CRow(pIUnkOuter);
00054   if( NULL == pCRow || !pCRow->FInit(m_pObj) )
00055     return E_OUTOFMEMORY;
00056
00057   hr = pCRow->QueryInterface(riid, (void**)ppUnk);
00058   if( SUCCEEDED(hr) )
00059   {
00060     //Set the row handle to this object...
00061     hr = pCRow->SetRowHandle(hRow);
00062   }
00063   else
00064   {
00065     delete pCRow;
00066   }
00067
00068   return hr;
00069 }
00070
00071
00072 // CImpIGetRow::GetURLFromHROW -----------------------------------------------
00073 //
00074 // @mfunc Returns a row object given an HROW
00075 //
00076 // @rdesc HRESULT
00077 //      @flag S_OK           | Method Succeeded
00078 //    @flag E_INVALIDARG           | ppwszURL was NULL
00079 //      @flag DB_E_BADROWHANDLE      | Invalid row handle given
00080 //      @flag OTHER                  | Other HRESULTs returned by called functions
00081 //
00082 STDMETHODIMP CImpIGetRow::GetURLFromHROW
00083 (
00084   HROW    hRow,
00085   LPOLESTR *  ppwszURL
00086 )
00087 {
00088   ULONG     cchLenURL = 0;
00089   ROWBUFF *   pRowBuff = NULL;
00090   static WCHAR  s_wszURLFmt[] = L"SampProv:Datasource=%s,File=%s,Row=%d";
00091
00092   assert( m_pObj );
00093
00094   if( !ppwszURL )
00095     return E_INVALIDARG;
00096
00097   *ppwszURL = NULL;
00098
00099   if( DB_NULL_HROW == hRow ||
00100     m_pObj->m_prowbitsIBuffer->IsSlotSet( (ULONG)hRow ) != S_OK )
00101         return DB_E_BADROWHANDLE;
00102
00103   pRowBuff = m_pObj->GetRowBuff( hRow, TRUE );
00104     assert( pRowBuff && pRowBuff->ulRefCount );
00105
00106   if ( m_pObj->m_pFileio &&
00107      m_pObj->m_pFileio->IsDeleted( (DBBKMARK) pRowBuff->pbBmk ) == S_OK )
00108     return DB_E_DELETEDROW;
00109
00110   cchLenURL = wcslen(s_wszURLFmt) + (2 * MAX_PATH) + INT_DISPLAY_SIZE;
00111   *ppwszURL = (WCHAR *)PROVIDER_ALLOC( cchLenURL * sizeof(WCHAR));
00112
00113   if( *ppwszURL )
00114   {
00115     swprintf(*ppwszURL, s_wszURLFmt, m_pObj->m_wszDataSourcePath,
00116           m_pObj->m_wszFilePath, (DBBKMARK) pRowBuff->pbBmk);
00117
00118     return S_OK;
00119   }
00120   else
00121     return E_OUTOFMEMORY;
00122 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/Grid.cpp Source File

  • Web
  • Browser
  • EditHost

Grid.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // Grid.cpp : Implementation of CGrid
00006 #include "stdafx.h"
00007 #include "EdHost.h"
00008 #include "Grid.h"
00009
00010 /////////////////////////////////////////////////////////////////////////////
00011 // CGrid
00012
00013
00014 // IGrid
00015 STDMETHODIMP CGrid::get_GridSize(long *pVal)
00016 {
00017   pVal = &m_lGridSize;
00018
00019   return S_OK;
00020 }
00021
00022 STDMETHODIMP CGrid::put_GridSize(long newVal)
00023 {
00024   m_lGridSize = newVal;
00025   m_spPaintSite->InvalidateRect(NULL);
00026
00027   return S_OK;
00028 }
00029
00030 // IElementBehavior
00031 STDMETHODIMP CGrid::Init(IElementBehaviorSite* pBehaviorSite)
00032 {
00033   HRESULT hr;
00034   IHTMLElement* pBody;
00035   IHTMLElement2* pBody2;
00036
00037   pBehaviorSite->GetElement(&pBody);
00038   pBody->QueryInterface(IID_IHTMLElement2, (void**)&pBody2);
00039
00040   pBody2->get_clientTop(&m_lClientTop);
00041   pBody2->get_clientLeft(&m_lClientLeft);
00042   m_spSite = pBehaviorSite;
00043
00044   hr = m_spSite->QueryInterface(IID_IHTMLPaintSite, (void**)&m_spPaintSite);
00045
00046
00047   return hr;
00048 }
00049
00050 STDMETHODIMP CGrid::Notify(LONG lEvent, VARIANT * pVar)
00051 {
00052   if (pVar == NULL)
00053     return E_POINTER;
00054
00055   return E_NOTIMPL;
00056 }
00057
00058 STDMETHODIMP CGrid::Detach()
00059 {
00060   m_spPaintSite->InvalidateRect(NULL);
00061   return S_OK;
00062 }
00063
00064 // IHTMLPainter
00065 STDMETHODIMP CGrid::Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject)
00066 {
00067   HPEN redPen = (HPEN)CreatePen(PS_DOT, 0, RGB(0xff, 0x99, 0x99));
00068   HPEN oldPen = (HPEN)SelectObject(hdc, redPen);
00069
00070   long lFirstLine = rcBounds.left;
00071
00072   for (int i = lFirstLine; i <= rcBounds.right; i += m_lGridSize)
00073   {
00074     MoveToEx(hdc, i, rcBounds.top, NULL);
00075     LineTo(hdc, i, rcBounds.bottom);
00076   }
00077
00078   lFirstLine = rcBounds.top;
00079
00080   for (i = lFirstLine ; i <= rcBounds.bottom; i += m_lGridSize)
00081   {
00082     MoveToEx(hdc, rcBounds.left, i,  NULL);
00083     LineTo(hdc, rcBounds.right, i);
00084   }
00085
00086   return S_OK;
00087 }
00088
00089 STDMETHODIMP CGrid::OnResize(SIZE size) {return S_OK;}
00090
00091 STDMETHODIMP CGrid::GetPainterInfo(HTML_PAINTER_INFO * pInfo)
00092 {
00093   if (pInfo == NULL)
00094     return E_POINTER;
00095
00096   pInfo->lFlags = HTMLPAINTER_TRANSPARENT;
00097   pInfo->lZOrder = HTMLPAINT_ZORDER_BELOW_CONTENT;
00098
00099   memset(&pInfo->iidDrawObject, 0, sizeof(IID));
00100
00101   pInfo->rcExpand.left = 0;
00102   pInfo->rcExpand.right = 0;
00103   pInfo->rcExpand.top = 0;
00104   pInfo->rcExpand.bottom = 0;
00105
00106   return S_OK;
00107 }
00108
00109 STDMETHODIMP CGrid::HitTestPoint(POINT pt, BOOL* pbHit, LONG* plPartID)
00110 {
00111   if (pbHit == NULL)
00112     return E_POINTER;
00113
00114   if (plPartID == NULL)
00115     return E_POINTER;
00116
00117   return E_NOTIMPL;
00118 }
00119
00120 // IObjectSafety
00121 STDMETHODIMP CGrid::SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions)
00122 {
00123      // Set the safety options we have been asked to set.
00124   m_dwCurrentSafety = m_dwCurrentSafety  & ~dwEnabledOptions | dwOptionSetMask;
00125   return S_OK;
00126 }
00127
00128 // CFactory
00129
00130 STDMETHODIMP
00131 CGrid::FindBehavior(BSTR bstrBehavior, BSTR bstrBehaviorUrl, IElementBehaviorSite* pSite, IElementBehavior** ppBehavior)
00132 {
00133   HRESULT hr;
00134
00135   hr = this->QueryInterface(IID_IElementBehavior, (void**)ppBehavior );
00136
00137   return hr;
00138 }
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/io/ASyncTrans/ftrans.c Source File

  • Web
  • iis
  • extensions
  • io
  • ASyncTrans

ftrans.c

Go to the documentation of this file.
00001 /* Copyright (c) 1995-2002 Microsoft Corporation
00002
00003   Module Name:
00004
00005     ftrans.c
00006
00007   Abstract:
00008
00009     This module demonstrates a simple file transfer using ISAPI application
00010     using the Async TransmitFile support with callback.
00011 */
00012
00013 #include <windows.h>
00014 #include "httpext.h"
00015 #include "openf.h"
00016
00017 LIST_ENTRY g_lWorkItems;
00018 CRITICAL_SECTION g_csWorkItems;
00019
00020 #define USE_WORK_QUEUE 0
00021 # define MAX_BUFFER_SIZE 400
00022
00023 typedef struct _AIO_WORK_ITEM {
00024
00025     LIST_ENTRY    listEntry;
00026     EXTENSION_CONTROL_BLOCK *pecb;
00027     HSE_TF_INFO   hseTf;
00028     CHAR          pchBuffer[MAX_BUFFER_SIZE ];
00029
00030 } AIO_WORK_ITEM, *PAWI;
00031
00032 DWORD SendHeaderToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszErrorMsg);
00033 DWORD SendFileToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile);
00034 DWORD SendFileOver(IN EXTENSION_CONTROL_BLOCK *pecb, IN HANDLE hFile, IN LPCSTR pszFile);
00035
00036 /*
00037   Description:
00038
00039     This function DllMain() is the main initialization function for
00040     this DLL. It initializes local variables and prepares it to be invoked
00041     subsequently.
00042
00043   Arguments:
00044
00045     hinstDll          Instance Handle of the DLL
00046     fdwReason         Reason why NT called this DLL
00047     lpvReserved       Reserved parameter for future use.
00048
00049   Returns:
00050
00051     TRUE is successful; otherwise FALSE is returned.
00052 */
00053
00054 BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD fdwReason, IN LPVOID lpvContext OPTIONAL)
00055 {
00056   BOOL fReturn = TRUE;
00057
00058   switch (fdwReason) {
00059
00060     case DLL_PROCESS_ATTACH :
00061
00062       OutputDebugString(" Initializing the global data in ftrans.dll\n");
00063
00064       /* Initialize various data and modules. */
00065
00066       InitializeCriticalSection(&g_csWorkItems);
00067       InitializeListHead(&g_lWorkItems);
00068       InitFileHandleCache();
00069
00070       break;
00071
00072     case DLL_PROCESS_DETACH :
00073
00074       /*
00075         Only cleanup when we are called because of a FreeLibrary() (i.e., when lpvContext == NULL)
00076         If we are called because of a process termination, dont free anything. System will free resources and memory for us.
00077       */
00078
00079       CleanupFileHandleCache();
00080
00081       if (lpvContext != NULL)
00082         DeleteCriticalSection(&g_csWorkItems);
00083
00084       break;
00085
00086     default :
00087
00088         break;
00089   }
00090
00091   return fReturn;
00092 }
00093
00094 /*
00095   Description:
00096
00097     This function performs the necessary action to send response for the
00098     request received from the client. It picks up the name of a file from
00099     the pecb->lpszQueryString and transmits that file to the client.
00100
00101   Arguments:
00102
00103     pecb          pointer to ECB containing parameters related to the request.
00104
00105   Returns:
00106
00107     Returns HSE_* status codes
00108 */
00109
00110 DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pecb)
00111 {
00112   DWORD hseStatus;
00113
00114   if (pecb->lpszQueryString == NULL || *pecb->lpszQueryString == '\0')
00115     hseStatus = SendHeaderToClient( pecb, "File Not Specified");
00116   else
00117     hseStatus = SendFileToClient( pecb, pecb->lpszQueryString);
00118
00119   return hseStatus;
00120 }
00121
00122 /*
00123   Description:
00124
00125     Sets the ISAPI extension version information.
00126
00127   Arguments:
00128
00129     Version     pointer to HSE_VERSION_INFO structure
00130
00131   Return Value:
00132
00133     TRUE
00134 */
00135
00136 BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
00137 {
00138   pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
00139
00140   lstrcpyn((LPSTR) pVer->lpszExtensionDesc, "File Transfer using TransmitFile", HSE_MAX_EXT_DLL_NAME_LEN);
00141
00142   return TRUE;
00143 }
00144
00145 /*
00146   Description:
00147
00148     This is optional ISAPI extension DLL entry point.
00149     If present, it will be called before unloading the DLL,
00150     giving it a chance to perform any shutdown procedures.
00151
00152   Arguments:
00153
00154     dwFlags - specifies whether the DLL can refuse to unload or not
00155
00156   Returns:
00157
00158     TRUE, if the DLL can be unloaded
00159 */
00160
00161 BOOL WINAPI TerminateExtension(DWORD dwFlags)
00162 {
00163   return TRUE;
00164 }
00165
00166 DWORD SendHeaderToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszErrorMsg)
00167 {
00168   HSE_SEND_HEADER_EX_INFO SendHeaderExInfo;
00169   char szStatus[]     = "200 OK";
00170   char szHeader[1024];
00171
00172   /*  Note the HTTP header block is terminated by a blank '\r\n' pair, followed by the document body */
00173
00174   wsprintf(szHeader, "Content-Type: text/html\r\n\r\n<head><title>Simple File Transfer (Transmit File)</title></head>\n<body><h1>%s</h1>\n", pszErrorMsg);
00175
00176   /* Populate SendHeaderExInfo struct */
00177
00178   SendHeaderExInfo.pszStatus = szStatus;
00179   SendHeaderExInfo.pszHeader = szHeader;
00180   SendHeaderExInfo.cchStatus = lstrlen(szStatus);
00181   SendHeaderExInfo.cchHeader = lstrlen(szHeader);
00182   SendHeaderExInfo.fKeepConn = FALSE;
00183
00184   /* Send header - use the EX Version to send the header blob */
00185
00186   if (!pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &SendHeaderExInfo, NULL, NULL))
00187     return HSE_STATUS_ERROR;
00188
00189   return HSE_STATUS_SUCCESS;
00190 }
00191
00192 DWORD SendFileToClient(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile)
00193 {
00194   CHAR    pchBuffer[1024];
00195   HANDLE  hFile;
00196   DWORD   hseStatus = HSE_STATUS_SUCCESS;
00197
00198   hFile = FcOpenFile(pecb, pszFile);
00199
00200   if (INVALID_HANDLE_VALUE == hFile) {
00201
00202     wsprintfA(pchBuffer, "OpenFailed: Error (%d) while opening the file %s.\n", GetLastError(), pszFile);
00203
00204     hseStatus = SendHeaderToClient(pecb, pchBuffer);
00205
00206   } else {
00207
00208     #if SEPARATE_HEADERS
00209       hseStatus = SendHeaderToClient(pecb, "File Transfer begins");
00210     #else
00211       hseStatus = HSE_STATUS_SUCCESS;
00212     #endif
00213
00214     if (hseStatus == HSE_STATUS_SUCCESS) {
00215
00216       hseStatus = SendFileOver(pecb, hFile, pszFile);
00217
00218       if (hseStatus != HSE_STATUS_PENDING) {
00219
00220         /* assume that the data is transmitted. */
00221
00222         if (hseStatus != HSE_STATUS_SUCCESS) {
00223
00224           /* Error in transmitting the file. Send error message. */
00225
00226           wsprintfA(pchBuffer, "Send Failed: Error (%d) for file %s.\n", GetLastError(), pszFile);
00227
00228           SendHeaderToClient(pecb, pchBuffer);
00229         }
00230       }
00231     }
00232
00233     if (hseStatus != HSE_STATUS_PENDING) {
00234
00235       /* file handle is closed for all non-pending cases if the status is pending, file handle is cleaned up in callback */
00236
00237       FcCloseFile(hFile);
00238     }
00239   }
00240
00241   return hseStatus;
00242 }
00243
00244 VOID CleanupAW(IN PAWI paw, IN BOOL fDoneWithSession)
00245 {
00246   DWORD err = GetLastError();
00247
00248   if (paw->hseTf.hFile != INVALID_HANDLE_VALUE)
00249     FcCloseFile(paw->hseTf.hFile);
00250
00251   if (fDoneWithSession)
00252     paw->pecb->ServerSupportFunction( paw->pecb->ConnID, HSE_REQ_DONE_WITH_SESSION, NULL, NULL, NULL);
00253
00254   SetLastError(err);
00255
00256   /* Remove from work items list */
00257
00258   #if USE_WORK_QUEUE
00259     EnterCriticalSection(&g_csWorkItems);
00260     RemoveEntryList(&paw->listEntry);
00261     LeaveCriticalSection(&g_csWorkItems);
00262   # endif
00263
00264   LocalFree(paw);
00265 }
00266
00267 /*
00268   Description:
00269
00270     This is the callback function for handling completions of asynchronous IO.
00271     This function performs necessary cleanup and resubmits additional IO
00272     (if required). In this case, this function is called at the end of a
00273     successful TransmitFile() operation. This function primarily cleans up
00274     the data and worker queue item and exits.
00275
00276   Arguments:
00277
00278     pecb          pointer to ECB containing parameters related to the request.
00279     pContext      context information supplied with the asynchronous IO call.
00280     cbIO          count of bytes of IO in the last call.
00281     dwError       Error if any, for the last IO operation.
00282
00283   Returns:
00284
00285     None.
00286 */
00287
00288 VOID WINAPI HseIoCompletion(IN EXTENSION_CONTROL_BLOCK *pECB, IN PVOID pContext, IN DWORD cbIO, IN DWORD dwError)
00289 {
00290   PAWI paw = (PAWI)pContext;
00291   EXTENSION_CONTROL_BLOCK *pecb = paw->pecb;
00292
00293   CleanupAW(paw, TRUE);
00294 }
00295
00296 DWORD SendFileOver(IN EXTENSION_CONTROL_BLOCK *pecb, IN HANDLE hFile, IN LPCSTR pszFile)
00297 {
00298   PAWI paw;
00299   DWORD hseStatus = HSE_STATUS_PENDING;
00300
00301   paw = (PAWI)LocalAlloc(LMEM_FIXED, sizeof(AIO_WORK_ITEM));
00302
00303   if (NULL == paw) {
00304
00305     SetLastError(ERROR_NOT_ENOUGH_MEMORY);
00306
00307     return HSE_STATUS_ERROR;
00308   }
00309
00310   /* Fill in all the data in AIO_WORK_ITEM */
00311
00312   paw->pecb = pecb;
00313
00314   InitializeListHead(&paw->listEntry);
00315
00316   paw->hseTf.pfnHseIO = HseIoCompletion;
00317   paw->hseTf.pContext = paw;
00318   paw->hseTf.dwFlags = (HSE_IO_ASYNC | HSE_IO_DISCONNECT_AFTER_SEND);
00319
00320   paw->hseTf.hFile = hFile;
00321   paw->hseTf.BytesToWrite = GetFileSize(hFile, NULL);
00322   paw->hseTf.Offset = 0;
00323   paw->hseTf.pTail = NULL;
00324   paw->hseTf.TailLength = 0;
00325
00326   /* Set up the header to be sentout for the file */
00327
00328   #if SEPARATE_HEADERS
00329     paw->hseTf.HeadLength = 0;
00330     paw->hseTf.pHead = NULL;
00331   #else
00332     paw->hseTf.HeadLength = wsprintfA(paw->pchBuffer, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<head><title>Simple File Transfer (TransmitFile) </title></head>\n<h1> Transferred file contains...</h1>\n");
00333     paw->hseTf.pHead = paw->pchBuffer;
00334   #endif
00335
00336   /* Add to the list */
00337
00338   #if USE_WORK_QUEUE
00339     EnterCriticalSection(&g_csWorkItems);
00340     InsertTailList(&g_lWorkItems, &paw->listEntry);
00341     LeaveCriticalSection(&g_csWorkItems);
00342   #endif
00343
00344   /* Setup the Async TransmitFile */
00345
00346   if (!pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_TRANSMIT_FILE, &paw->hseTf, NULL, NULL)) {
00347
00348     /* Do cleanup and return error */
00349
00350     /* File handle will be freed by the caller for errors */
00351
00352     paw->hseTf.hFile = INVALID_HANDLE_VALUE;
00353
00354     CleanupAW(paw, FALSE);
00355
00356     hseStatus =  HSE_STATUS_ERROR;
00357   }
00358
00359   return hseStatus;
00360 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSimpleDoc Member List

This is the complete list of members for CSimpleDoc, including all inherited members.
Close(void) | CSimpleDoc |
Close(void) | CSimpleDoc |
CopyObjectToClip(void) | CSimpleDoc |
Create(CSimpleApp FAR *lpApp, LPRECT lpRect, HWND hWnd) | CSimpleDoc | [static]
Create(CSimpleApp FAR *lpApp, LPRECT lpRect, HWND hWnd) | CSimpleDoc | [static]
CSafeRefCount() | CSafeRefCount |
CSimpleDoc() | CSimpleDoc |
CSimpleDoc(CSimpleApp FAR *lpApp, HWND hWnd) | CSimpleDoc |
CSimpleDoc() | CSimpleDoc |
CSimpleDoc(CSimpleApp FAR *lpApp, HWND hWnd) | CSimpleDoc |
DecrementNestCount() | CSafeRefCount |
DisableInsertObject(void) | CSimpleDoc |
DisableInsertObject(void) | CSimpleDoc |
DoDragDrop(void) | CSimpleDoc |
IncrementNestCount() | CSafeRefCount |
InsertObject(void) | CSimpleDoc |
InsertObject(void) | CSimpleDoc |
lAddVerbs(void) | CSimpleDoc |
lAddVerbs(void) | CSimpleDoc |
lResizeDoc(LPRECT lpRect) | CSimpleDoc |
lResizeDoc(LPRECT lpRect) | CSimpleDoc |
m_DropSource | CSimpleDoc |
m_DropTarget | CSimpleDoc |
m_fAddMyUI | CSimpleDoc |
m_fCanDropCopy | CSimpleDoc |
m_fCanDropLink | CSimpleDoc |
m_fDragLeave | CSimpleDoc |
m_fInPlaceActive | CSimpleDoc |
m_fLocalDrag | CSimpleDoc |
m_fLocalDrop | CSimpleDoc |
m_fModifiedMenu | CSimpleDoc |
m_fPendingDrag | CSimpleDoc |
m_fRegDragDrop | CSimpleDoc |
m_hDocWnd | CSimpleDoc |
m_lpActiveObject | CSimpleDoc |
m_lpApp | CSimpleDoc |
m_lpSite | CSimpleDoc |
m_lpStorage | CSimpleDoc |
m_ptButDown | CSimpleDoc |
PaintDoc(HDC hDC) | CSimpleDoc |
PaintDoc(HDC hDC) | CSimpleDoc |
QueryDrag(POINT pt) | CSimpleDoc |
QueryInterface(REFIID riid, LPVOID FAR *ppvObj) | CSimpleDoc |
QueryInterface(REFIID riid, LPVOID FAR *ppvObj) | CSimpleDoc |
SafeAddRef() | CSafeRefCount |
SafeRelease() | CSafeRefCount |
Scroll(DWORD dwScrollDir) | CSimpleDoc | [inline]
STDMETHODIMP_(ULONG) AddRef() | CSimpleDoc |
STDMETHODIMP_(ULONG) Release() | CSimpleDoc |
STDMETHODIMP_(ULONG) AddRef() | CSimpleDoc |
STDMETHODIMP_(ULONG) Release() | CSimpleDoc |
~CSafeRefCount() | CSafeRefCount | [virtual]
~CSimpleDoc() | CSimpleDoc |
~CSimpleDoc() | CSimpleDoc |
Generated on Wed Nov 13 2024 16:57:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/EnumDesk/list.h Source File

  • WinUI
  • Shell
  • EnumDesk

list.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          List.h
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023
00024 /**************************************************************************
00025    function prototypes
00026 **************************************************************************/
00027
00028 HWND List_Create(HINSTANCE, HWND, HIMAGELIST, HIMAGELIST);
00029 void List_ReleaseCurrentFolder(void);
00030 HRESULT List_DisplayFolder(HWND, LPITEMINFO);
00031 HRESULT List_Refresh(HWND);
00032 LRESULT List_Notify(HWND, LPARAM);
00033 void List_DoContextMenu(HWND, LPPOINT);
00034
00035 /**************************************************************************
00036    global variables and definitions
00037 **************************************************************************/
00038
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/atl/atlcontrol.idl Source File

  • SysMgmt
  • MMC
  • ActiveX
  • atl

atlcontrol.idl

Go to the documentation of this file.
00001 // ATLControl.idl : IDL source for ATLControl.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (ATLControl.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 #include "olectl.h"
00009
00010
00011   [
00012     object,
00013     uuid(831DF6C8-C754-11D2-952C-00C04FB92EC2),
00014     dual,
00015     helpstring("IMMCControl Interface"),
00016     pointer_default(unique)
00017   ]
00018   interface IMMCControl : IDispatch
00019   {
00020     [id(1), helpstring("Start Animation")] HRESULT StartAnimation();
00021     [id(2), helpstring("Stop Animation")] HRESULT StopAnimation();
00022     [id(3), helpstring("method DoHelp")] HRESULT DoHelp();
00023   };
00024
00025 [
00026   uuid(65CC8C10-C754-11D2-952C-00C04FB92EC2),
00027   version(1.0),
00028   helpstring("ATLControl 1.0 Type Library")
00029 ]
00030 library ATLCONTROLLib
00031 {
00032   importlib("stdole32.tlb");
00033   importlib("stdole2.tlb");
00034
00035   [
00036     uuid(9A12FB62-C754-11D2-952C-00C04FB92EC2),
00037     helpstring("MMCControl Class")
00038   ]
00039   coclass MMCControl
00040   {
00041     [default] interface IMMCControl;
00042   };
00043 };
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120     MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122     // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal) {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/FullIME/CANDUI.C Source File

  • WinUI
  • Input
  • Ime
  • FullIME

CANDUI.C

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include <windows.h>
00003 #include <imm.h>
00004 #include "FullIME.h"
00005
00006 //********************************************************************
00007 //
00008 // int WINAPI CandWndProc()
00009 //
00010 // Window procedure of candidate window.
00011 //
00012 //********************************************************************
00013 int WINAPI CandWndProc(
00014     HWND hwnd,
00015     UINT msg,
00016     WPARAM wParam,
00017     LPARAM lParam )
00018 {
00019
00020     switch( msg )
00021     {
00022
00023         case WM_PAINT:
00024
00025             CandUIPaint( hwnd );
00026             break;
00027
00028         default:
00029
00030             return (int) DefWindowProc( hwnd, msg, wParam, lParam );
00031     }
00032
00033     return 0;
00034 }
00035
00036 //********************************************************************
00037 //
00038 // void DislpayCandStrings()
00039 //
00040 // Displays candidate strings.
00041 //
00042 //********************************************************************
00043
00044 void DisplayCandStrings(
00045     HWND hwnd,
00046     LPCANDIDATELIST lpCandList )
00047 {
00048
00049     HDC         hdc;            // Storage for device context handle.
00050     LPSTR       lpStr;          // Storage for LP to a string.
00051     DWORD       dwNumPerPage;   // Storage for num per page
00052     DWORD       dwStartIndex;   // Storage for candidate index
00053     DWORD       dwEndIndex;     // Storage for candidate index
00054     RECT        rect;           // Storage for client rect.
00055     int         y = 0;          //
00056     DWORD       dwBackColor;    // Storage for background color value
00057     DWORD       dwTextColor;
00058
00059     //
00060     // Determine how many candidate strings per page.
00061     //
00062
00063     dwNumPerPage = ( !lpCandList->dwPageSize ) ?
00064                      DEFAULT_CAND_NUM_PER_PAGE :
00065                      lpCandList->dwPageSize;
00066
00067     //
00068     // Determine the dwStartIndex from which the candidate string will
00069     // start displaying.
00070     //
00071
00072     dwStartIndex = lpCandList->dwPageStart;
00073
00074     //
00075     // Determine the dwEndIndex which indicate the last candidate string
00076     // will be displayed.
00077     //
00078
00079     dwEndIndex = dwStartIndex + dwNumPerPage;
00080
00081     dwEndIndex = ( dwEndIndex >= lpCandList->dwCount ) ?
00082                  lpCandList->dwCount : dwEndIndex;
00083
00084
00085     //
00086     // Dissplay candidate strings.
00087     // First paint background color.
00088     //
00089
00090     hdc = GetDC( hwnd );
00091
00092     dwBackColor = SetBkColor( hdc, RGB( 0xbf, 0xbf, 0xbf ) );
00093
00094     GetClientRect( hwnd, &rect );
00095
00096     ExtTextOut( hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0 );
00097
00098
00099     //
00100     // Set background color of selected candidate string to be blue.
00101     //
00102
00103     rect.top = rect.top +
00104                ( lpCandList->dwSelection - dwStartIndex ) * cyMetrics;
00105
00106     rect.bottom = rect.top + cyMetrics;
00107
00108     SetBkColor( hdc,RGB( 0x00, 0x00, 0xff ) );
00109
00110     ExtTextOut( hdc, 0, rect.top, ETO_OPAQUE, &rect, NULL, 0, 0 );
00111
00112     //
00113     // Display candidate strings.
00114     //
00115
00116     SetBkMode( hdc, TRANSPARENT );
00117
00118     dwTextColor = GetTextColor( hdc );
00119
00120     for ( ; dwStartIndex < dwEndIndex; dwStartIndex++, y++ )
00121     {
00122
00123         lpStr = (LPSTR) lpCandList +
00124                 lpCandList->dwOffset[ dwStartIndex ];
00125
00126         if ( dwStartIndex == lpCandList->dwSelection )
00127             SetTextColor( hdc, RGB( 255, 255, 255 ) );
00128         else
00129             SetTextColor( hdc, dwTextColor );
00130
00131         TextOut( hdc, 3, y * cyMetrics, lpStr, lstrlen( lpStr ) );
00132     }
00133
00134
00135     SetTextColor( hdc, dwTextColor );
00136
00137     SetBkColor( hdc, dwBackColor );
00138
00139     ReleaseDC( hwnd, hdc );
00140
00141 }
00142
00143 //**********************************************************************
00144 //
00145 // void CandUIPaint()
00146 //
00147 // Handler routine of WM_PAINT message.
00148 //
00149 //**********************************************************************
00150
00151 void CandUIPaint(
00152     HWND hwnd )
00153 {
00154     int             index;
00155     LPCANDIDATELIST lpCandList;
00156     HDC             hdc;
00157     PAINTSTRUCT     ps;
00158
00159
00160     hdc = BeginPaint( hwnd, &ps );
00161
00162     //
00163     // Determine which candidate window needs to repaint.
00164     //
00165
00166     for ( index = 0; index < MAX_LISTCAND; index ++ )
00167         if ( gImeUIData.hListCand[ index ] == hwnd )
00168             break;
00169
00170     //
00171     // If index == MAX_LISTCAND, then something wrong, do nothing.
00172     //
00173
00174     if ( index == MAX_LISTCAND )
00175         goto exit;
00176
00177     if ( !gImeUIData.hListCandMem[ index ] ||
00178          (lpCandList = (LPCANDIDATELIST)
00179               GlobalLock( gImeUIData.hListCandMem[ index ] ) ) == NULL )
00180     {
00181         goto exit;
00182     }
00183
00184     DisplayCandStrings( hwnd, lpCandList );
00185
00186     GlobalUnlock( gImeUIData.hListCandMem[ index ] );
00187
00188 exit:
00189
00190     EndPaint( hwnd, &ps );
00191
00192 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagLOGERRORMSG Member List

This is the complete list of members for _tagLOGERRORMSG, including all inherited members.
dwErrorLevel | _tagLOGERRORMSG
lpcErrorText | _tagLOGERRORMSG
lpSyncLogError | _tagLOGERRORMSG
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/Resource.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by MQApitst.rc
00004 //
00005 #define IDD_ABOUTBOX                    100
00006 #define IDR_MAINFRAME                   128
00007 #define IDR_TESTTYPE                    129
00008 #define IDD_CREATE_QUEUE_DIALOG         130
00009 #define IDD_DELETE_QUEUE_DIALOG         131
00010 #define IDD_OPEN_QUEUE_DIALOG           132
00011 #define IDD_CLOSE_QUEUE_DIALOG          133
00012 #define IDD_SEND_MESSAGE_DIALOG         134
00013 #define IDD_RECEIVE_MESSAGE_DIALOG      135
00014 #define IDD_WAIT_DIALOG                 136
00015 #define IDD_LOCATE_DIALOG               137
00016 #define IDC_QUEUE_PATHNAME              1000
00017 #define IDC_QUEUE_LABEL                 1001
00018 #define IDC_DELETE_QUEUE_COMBO          1003
00019 #define IDC_MQ_PEEK_ACCESS              1007
00020 #define IDC_MQ_SEND_ACCESS              1008
00021 #define IDC_IDC_MQ_RECEIVE_ACCESS       1009
00022 #define IDC_PATHNAME_COMBO              1010
00023 #define IDC_COMBO                       1011
00024 #define IDC_FORMATNAME_COMBO2           1011
00025 #define IDC_ADMIN_COMBO                 1012
00026 #define IDC_MESSAGE_PRIORITY            1013
00027 #define IDC_DELIVERY_EXPRESS_RADIO      1014
00028 #define IDC_DELIVERY_RECOVERABLE_RADIO  1015
00029 #define IDC_ACK_FULL_RADIO              1016
00030 #define IDC_ACK_FULL_REACH_QUEUE_RADIO  1016
00031 #define IDC_ACK_NEG_RADIO               1017
00032 #define IDC_ACK_FULL_RECEIVE_RADIO      1017
00033 #define IDC_ACK_NONE_RADIO              1018
00034 #define IDC_LABEL                       1020
00035 #define IDC_BODY                        1021
00036 #define IDC_TIMEOUT                     1022
00037 #define IDC_TARGET_COMBO                1024
00038 #define IDC_LOCATE_LABEL                1025
00039 #define IDC_JOURNAL                     1026
00040 #define IDC_DEAD_LETTER                 1027
00041 #define IDC_AUTHENTICATED               1029
00042 #define IDC_TIME_TO_BE_RECEIVED         1030
00043 #define IDC_NACK_REACH_QUEUE_RADIO      1031
00044 #define IDC_NACK_RECEIVE_RADIO          1032
00045 #define IDC_TIME_TO_REACH_QUEUE         1033
00046 #define IDC_EDIT1                       1035
00047 #define IDC_RADIO3                      1036
00048 #define IDC_EDT_BODY_SIZE               1037
00049 #define IDC_ENCRYPTED                   1038
00050 #define IDC_RADIO1                      1042
00051 #define IDC_RADIO2                      1043
00052 #define IDC_RADIO4                      1044
00053 #define ID_API_CREATE_QUEUE             32771
00054 #define ID_API_DELETE_QUEUE             32772
00055 #define ID_API_OPEN_QUEUE               32773
00056 #define ID_API_CLOSE_QUEUE              32774
00057 #define ID_API_SEND_MESSAGE             32775
00058 #define ID_API_RECEIVE_MESSAGE          32776
00059 #define ID_API_LOCATE                   32777
00060
00061 // Next default values for new objects
00062 //
00063 #ifdef APSTUDIO_INVOKED
00064 #ifndef APSTUDIO_READONLY_SYMBOLS
00065 #define _APS_3D_CONTROLS                     1
00066 #define _APS_NEXT_RESOURCE_VALUE        141
00067 #define _APS_NEXT_COMMAND_VALUE         32785
00068 #define _APS_NEXT_CONTROL_VALUE         1043
00069 #define _APS_NEXT_SYMED_VALUE           101
00070 #endif
00071 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/EventSink/EventSink.cpp Source File

  • TabletPC
  • EventSink

EventSink.cpp

Go to the documentation of this file.
00001 //
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      EventSink.cpp
00013 //
00014 // Description:
00015 //      This program demonstrates how to build an application that
00016 //      captures InkCollector events using only C++.  It uses the
00017 //      InkCollectorEvents base class (also included with this sample)
00018 //      to convert the IDispatch event notification into a call to the
00019 //      appropriate event handler.
00020 //
00021 //      This program co-creates an InkCollector object to enable inking
00022 //      in the window. It displays a message box whenever a Stroke event
00023 //      is received.
00024 //
00025 //      The only code specific to the Tablet PC SDK is located in the
00026 //      WndProc method.
00027 //
00028 //      This application is discussed in the Getting Started guide.
00029 //
00030 //      The interfaces used are:
00031 //      IInkCollector
00032 //
00033 //--------------------------------------------------------------------------
00034
00035 // Windows Header Files:
00036 #include <windows.h>
00037 // C RunTime Header Files
00038 #include <stdlib.h>
00039 #include <malloc.h>
00040 #include <memory.h>
00041 #include <assert.h>
00042
00043 #define interface struct
00044 #include <msinkaut.h>
00045 #include "TpcConpt.h"
00046 #include "EventSink.h"
00047 #define MAX_LOADSTRING 100
00048 #include <msinkaut_i.c>
00049
00050 // Global Variables:
00051 HINSTANCE hInst;                // current instance
00052 TCHAR szTitle[MAX_LOADSTRING];          // The title bar text
00053 TCHAR szWindowClass[MAX_LOADSTRING];      // the main window class name
00054
00055 // Forward declarations of functions included in this code module:
00056 ATOM        MyRegisterClass(HINSTANCE hInstance);
00057 BOOL        InitInstance(HINSTANCE, int);
00058 LRESULT CALLBACK  WndProc(HWND, UINT, WPARAM, LPARAM);
00059 LRESULT CALLBACK  About(HWND, UINT, WPARAM, LPARAM);
00060
00061
00062 /////////////////////////////////////////////////////////
00063 //
00064 // WinMain
00065 //
00066 //      The WinMain function is called by the system as the
00067 //      initial entry point for a Win32-based application.
00068 //      It contains typical boilerplate code to create and
00069 //      show the main window, and pump messages.
00070 //
00071 // Parameters:
00072 //      HINSTANCE hInstance,      : [in] handle to current instance
00073 //      HINSTANCE hPrevInstance,  : [in] handle to previous instance
00074 //      LPSTR lpCmdLine,          : [in] command line
00075 //      int nCmdShow              : [in] show state
00076 //
00077 // Return Values:
00078 //      0 : The function terminated before entering the message loop.
00079 //      non zero: Value of the wParam when receiving the WM_QUIT message
00080 //
00081 /////////////////////////////////////////////////////////
00082 int APIENTRY WinMain(
00083     HINSTANCE hInstance,
00084     HINSTANCE hPrevInstance,
00085     LPSTR lpCmdLine,
00086     int nCmdShow)
00087 {
00088   CoInitialize(NULL);
00089   MSG msg;
00090   HACCEL hAccelTable;
00091
00092   // Initialize global strings
00093   LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
00094   LoadString(hInstance, IDC_EVENTSINK, szWindowClass, MAX_LOADSTRING);
00095   MyRegisterClass(hInstance);
00096
00097   // Perform application initialization:
00098   if (!InitInstance (hInstance, nCmdShow))
00099   {
00100     return FALSE;
00101   }
00102
00103   hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_EVENTSINK);
00104
00105   // Main message loop:
00106   while (GetMessage(&msg, NULL, 0, 0))
00107   {
00108     if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
00109     {
00110       TranslateMessage(&msg);
00111       DispatchMessage(&msg);
00112     }
00113   }
00114
00115     CoUninitialize();
00116   return (int) msg.wParam;
00117 }
00118
00119
00120
00121 /////////////////////////////////////////////////////////
00122 //
00123 // MyRegisterClass
00124 //
00125 //      This registers the main window class.
00126 //
00127 // Parameters:
00128 //      HINSTANCE hInstance,      : [in] handle to current instance
00129 //
00130 // Return Values:
00131 //      0 : The function failed
00132 //      non zero: Class was registered successfully
00133 //
00134 /////////////////////////////////////////////////////////
00135 ATOM MyRegisterClass(
00136     HINSTANCE hInstance)
00137 {
00138   WNDCLASSEX wcex;
00139
00140   wcex.cbSize = sizeof(WNDCLASSEX);
00141
00142   wcex.style      = CS_HREDRAW | CS_VREDRAW;
00143   wcex.lpfnWndProc  = (WNDPROC)WndProc;
00144   wcex.cbClsExtra   = 0;
00145   wcex.cbWndExtra   = 0;
00146   wcex.hInstance    = hInstance;
00147   wcex.hIcon      = LoadIcon(hInstance, (LPCTSTR)IDI_EVENTSINK);
00148   wcex.hCursor    = LoadCursor(NULL, IDC_ARROW);
00149   wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
00150   wcex.lpszMenuName = (LPCTSTR)IDC_EVENTSINK;
00151   wcex.lpszClassName  = szWindowClass;
00152   wcex.hIconSm    = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
00153
00154   return RegisterClassEx(&wcex);
00155 }
00156
00157 /////////////////////////////////////////////////////////
00158 //
00159 // MyRegisterClass
00160 //
00161 //      Saves instance handle and creates main window. In this
00162 //      function, we save the instance handle in a global variable and
00163 //      create and display the main program window.
00164 //
00165 // Parameters:
00166 //      HINSTANCE hInstance,      : [in] handle to current instance
00167 //      int nCmdShow              : [in] how window is to be shown
00168 //
00169 // Return Values:
00170 //      FALSE : Could not create window
00171 //      TRUE:   Window successfully created
00172 //
00173 /////////////////////////////////////////////////////////
00174 BOOL InitInstance(
00175     HINSTANCE hInstance,
00176     int nCmdShow)
00177 {
00178    HWND hWnd;
00179
00180    hInst = hInstance; // Store instance handle in our global variable
00181
00182    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
00183       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
00184
00185    if (!hWnd)
00186    {
00187       return FALSE;
00188    }
00189
00190    ShowWindow(hWnd, nCmdShow);
00191    UpdateWindow(hWnd);
00192
00193    return TRUE;
00194 }
00195
00196 /////////////////////////////////////////////////////////
00197 //
00198 // WndProc
00199 //
00200 //      Processes messages for the main window. The two
00201 //      important messages are WM_CREATE and WM_DESTROY.
00202 //      For WM_CREATE, the object which maintains the
00203 //      InkCollector information is created and attaches
00204 //      an InkCollector to the window. WM_DESTROY frees
00205 //      the object which in turn frees all resources
00206 //      connected with the InkCollector.
00207 //
00208 // Parameters:
00209 //      HWND hWnd                   :   [in] Window
00210 //      UINT message                :   [in] Message id
00211 //      WPARAM wParam               :   [in] wParam for message
00212 //      LPARAM lParam               :   [in] lParam for message
00213 //
00214 // Return Values:
00215 //      0 :     Successfully processed message
00216 //      Non-0:  Error occurred
00217 //
00218 /////////////////////////////////////////////////////////
00219 LRESULT CALLBACK WndProc(
00220     HWND hWnd,
00221     UINT message,
00222     WPARAM wParam,
00223     LPARAM lParam)
00224 {
00225     static CMyInkCollector *pmic = NULL;
00226   int wmId, wmEvent;
00227
00228   switch (message)
00229   {
00230   case WM_CREATE:
00231
00232       // Allocate and initialize memory for object
00233       pmic = new CMyInkCollector();
00234
00235       if (pmic != NULL)
00236       {
00237           // Real initialization. This consists of creating
00238           //  an ink collector object and attaching it to
00239           //  the current window.
00240           if (SUCCEEDED(pmic->Init(hWnd)))
00241           {
00242               return 0;
00243           }
00244
00245           // Failure free resources.
00246           delete pmic;
00247           pmic = NULL;
00248       }
00249
00250       return -1;
00251
00252   case WM_COMMAND:
00253
00254     wmId    = LOWORD(wParam);
00255     wmEvent = HIWORD(wParam);
00256
00257     // Parse the menu selections:
00258     switch (wmId)
00259     {
00260     case IDM_ABOUT:
00261       DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
00262       break;
00263
00264     case IDM_EXIT:
00265       DestroyWindow(hWnd);
00266       break;
00267
00268     default:
00269       return DefWindowProc(hWnd, message, wParam, lParam);
00270     }
00271     break;
00272
00273   case WM_DESTROY:
00274       // The destructor for the object handles releasing the
00275       //  InkCollector and disconnecting the InkCollector
00276       //  from the object's event sink.
00277         delete pmic;
00278         pmic = NULL;
00279     PostQuitMessage(0);
00280     break;
00281
00282   default:
00283     return DefWindowProc(hWnd, message, wParam, lParam);
00284   }
00285
00286   return 0;
00287 }
00288
00289 /////////////////////////////////////////////////////////
00290 //
00291 // About
00292 //
00293 //      Message handler for About dialog box.
00294 //
00295 // Parameters:
00296 //      HWND hDlg               :   [in] handle to dialog box
00297 //      UINT message            :   [in] message id
00298 //      WPARAM wParam           :   [in] wParam
00299 //      LPARAM lParam           :   [in] lParam
00300 //
00301 // Return Values:
00302 //      FALSE:  Did not process message
00303 //      TRUE:   Processed message.
00304 //
00305 /////////////////////////////////////////////////////////
00306 LRESULT CALLBACK About(
00307     HWND hDlg,
00308     UINT message,
00309     WPARAM wParam,
00310     LPARAM lParam)
00311 {
00312   switch (message)
00313   {
00314   case WM_INITDIALOG:
00315     return TRUE;
00316
00317   case WM_COMMAND:
00318     if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
00319     {
00320       EndDialog(hDlg, LOWORD(wParam));
00321       return TRUE;
00322     }
00323     break;
00324
00325   }
00326
00327   return FALSE;
00328 }
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/Computer.h Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

Computer.h

Go to the documentation of this file.
00001 // Filename: Computer.h
00002 //
00003 // Description:  Definition of CComputer
00004 //
00005 // This file is provided as part of the Microsoft Transaction Server Samples
00006 //
00007 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00008 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00009 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00010 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00011 // PURPOSE.
00012 //
00013 // Copyright (C) 1997 - 2000 Microsoft Corporation, All rights reserved
00014
00015 #if !defined(AFX_COMPUTER_H__AA22C9A7_FD72_11D0_B5DC_00C04FB957D8__INCLUDED_)
00016 #define AFX_COMPUTER_H__AA22C9A7_FD72_11D0_B5DC_00C04FB957D8__INCLUDED_
00017
00018 #if _MSC_VER >= 1000
00019 #pragma once
00020 #endif // _MSC_VER >= 1000
00021
00022 #include "resource.h"       // main symbols
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CComputer
00026
00027 class CComputer :
00028   public CComDualImpl<IComputer, &IID_IComputer, &LIBID_TSERVERLib>,
00029   public ISupportErrorInfo,
00030   public CComObjectRoot,
00031   public CComCoClass<CComputer,&CLSID_Computer>
00032 {
00033 public:
00034   CComputer() {}
00035
00036 private:
00037   long plField [3][3];
00038
00039   float CComputer::Evaluate (long lX, long lY);
00040   long CComputer::LineScan (long lPlayer, long& lX, long& lY);
00041   bool CComputer::IsWin (long lPlayer);
00042   long CComputer::HowManyTurns ();
00043   void CComputer::GetMove (long lGameID, VARIANT_BOOL bEasy, long& lX, long& lY);
00044   HRESULT CComputer::LoadArray (long lGameID);
00045   HRESULT CComputer::SaveArray (long lGameID);
00046   void inline CComputer::InitArray () {
00047     for (int i = 0; i < 3; i ++)
00048       for (int j = 0; j < 3; j ++)
00049         plField[i][j] = 0;
00050   }
00051
00052 BEGIN_COM_MAP(CComputer)
00053   COM_INTERFACE_ENTRY(IDispatch)
00054   COM_INTERFACE_ENTRY(IComputer)
00055   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00056 END_COM_MAP()
00057 //DECLARE_NOT_AGGREGATABLE(CComputer)
00058 // Remove the comment from the line above if you don't want your object to
00059 // support aggregation.
00060
00061 DECLARE_REGISTRY_RESOURCEID(IDR_Computer)
00062 // ISupportsErrorInfo
00063   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00064
00065 // IComputer
00066 public:
00067   STDMETHODIMP AddNewGame (IN VARIANT_BOOL bEasy, OUT VARIANT* pvGameID, OUT VARIANT* pvOrder, OUT VARIANT* pvX, OUT VARIANT* pvY);
00068   STDMETHODIMP NewMove (IN long lGameID, IN VARIANT_BOOL bEasy, IN long lX, IN long lY, OUT VARIANT* pvMyX, OUT VARIANT* pvMyY, OUT VARIANT* pvWin);
00069
00070 };
00071
00072 #endif // !defined(AFX_COMPUTER_H__AA22C9A7_FD72_11D0_B5DC_00C04FB957D8__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Framer/ICliSite.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Framer

ICliSite.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*
00019  * ICLISITE.CPP
00020  * IOleClientSite for Document Objects CSite class
00021  *
00022  */
00023
00024
00025 #include "framer.h"
00026
00027
00028 /*
00029  * CImpIOleClientSite::CImpIOleClientSite
00030  * CImpIOleClientSite::~CImpIOleClientSite
00031  *
00032  * Parameters (Constructor):
00033  *  pSite           PCSite of the site we're in.
00034  *  pUnkOuter       LPUNKNOWN to which we delegate.
00035  */
00036
00037 CImpIOleClientSite::CImpIOleClientSite(PCSite pSite
00038     , LPUNKNOWN pUnkOuter)
00039     {
00040     m_cRef=0;
00041     m_pSite=pSite;
00042     m_pUnkOuter=pUnkOuter;
00043     return;
00044     }
00045
00046 CImpIOleClientSite::~CImpIOleClientSite(void)
00047     {
00048     return;
00049     }
00050
00051
00052
00053
00054 /*
00055  * CImpIOleClientSite::QueryInterface
00056  * CImpIOleClientSite::AddRef
00057  * CImpIOleClientSite::Release
00058  *
00059  * Purpose:
00060  *  IUnknown members for CImpIOleClientSite object.
00061  */
00062
00063 STDMETHODIMP CImpIOleClientSite::QueryInterface(REFIID riid
00064     , void **ppv)
00065     {
00066     return m_pUnkOuter->QueryInterface(riid, ppv);
00067     }
00068
00069
00070 STDMETHODIMP_(ULONG) CImpIOleClientSite::AddRef(void)
00071     {
00072     ++m_cRef;
00073     return m_pUnkOuter->AddRef();
00074     }
00075
00076 STDMETHODIMP_(ULONG) CImpIOleClientSite::Release(void)
00077     {
00078     --m_cRef;
00079     return m_pUnkOuter->Release();
00080     }
00081
00082
00083
00084
00085 /*
00086  * CImpIOleClientSite::SaveObject
00087  *
00088  * Purpose:
00089  *  Requests that the container call OleSave for the object that
00090  *  lives here.  Typically this happens on server shutdown.
00091  *
00092  * Parameters:
00093  *  None
00094  *
00095  * Return Value:
00096  *  HRESULT         Standard.
00097  */
00098
00099 STDMETHODIMP CImpIOleClientSite::SaveObject(void)
00100     {
00101     m_pSite->Update();
00102     return NOERROR;
00103     }
00104
00105
00106
00107
00108 /*
00109  * Unimplemented/trivial members
00110  *  GetMoniker
00111  *  GetContainer
00112  *  RequestNewObjectLayout
00113  *  OnShowWindow
00114  *  ShowObject
00115  */
00116
00117 STDMETHODIMP CImpIOleClientSite::GetMoniker(DWORD dwAssign
00118     , DWORD dwWhich, LPMONIKER *ppmk)
00119     {
00120     return E_NOTIMPL;
00121     }
00122
00123 STDMETHODIMP CImpIOleClientSite::GetContainer(LPOLECONTAINER
00124     * ppContainer)
00125     {
00126     *ppContainer=NULL;
00127     return E_NOINTERFACE;
00128     }
00129
00130 STDMETHODIMP CImpIOleClientSite::RequestNewObjectLayout(void)
00131     {
00132     return E_NOTIMPL;
00133     }
00134
00135 STDMETHODIMP CImpIOleClientSite::OnShowWindow(BOOL fShow)
00136     {
00137     return NOERROR;
00138     }
00139
00140 STDMETHODIMP CImpIOleClientSite::ShowObject(void)
00141     {
00142     return NOERROR;
00143     }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/STAObject/StdAfx.Cpp Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • STAObject

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COLEDBComponent Member List

This is the complete list of members for COLEDBComponent, including all inherited members.
Activate() | COLEDBComponent |
COLEDBComponent() | COLEDBComponent | [inline]
m_spObjectContext | COLEDBComponent |
SimpleQuery(BSTR *returnval) | COLEDBComponent |
STDMETHOD_(BOOL, CanBePooled)() | COLEDBComponent |
STDMETHOD_(void, Deactivate)() | COLEDBComponent |
Generated on Wed Nov 13 2024 16:56:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagACCESSOR Member List

This is the complete list of members for tagACCESSOR, including all inherited members.
cBindings | tagACCESSOR
cRef | tagACCESSOR
dwAccessorFlags | tagACCESSOR
rgBindings | tagACCESSOR
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DfV/bitmaps.Cxx Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DfV

bitmaps.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright 1992 - 2000 Microsoft Corporation.
00005 //
00006 //  File:       bitmaps.cxx
00007 //
00008 //  Contents:   bitmap helper functions
00009 //
00010 //  Classes:
00011 //
00012 //  Functions:  DDBChangeColor
00013 //              LoadAndStretch
00014 //
00015 //  History:    6-24-94   stevebl   Created
00016 //
00017 //----------------------------------------------------------------------------
00018
00019 #include <windows.h>
00020 #include "bitmaps.h"
00021
00022 //+---------------------------------------------------------------------------
00023 //
00024 //  Function:   LoadAndStretch
00025 //
00026 //  Synopsis:   Loads a bitmap from our resources, and creates a bitmap
00027 //              "array."  The red portions of the bitmap are considered
00028 //              clear.  Each resource consists of two bitmaps side by
00029 //              side:  an "open folder" and a "closed folder".  These
00030 //              bitmaps are turned into 4 bitmaps:  two selected, and
00031 //              two unselected bitmaps.
00032 //
00033 //  Arguments:  [hinst]        - instance containing the bitmap
00034 //              [hbmpDest]     - destination bitmap array
00035 //              [lpszResource] - name of the bitmap resource
00036 //              [cxBitmap]     - width to stretch to
00037 //              [cyBitmap]     - height to stretch to
00038 //              [crHigh]       - color of the highlighted background
00039 //              [crNorm]       - color of the normal background
00040 //
00041 //  Returns:    TRUE on success.
00042 //              FALSE on failure.
00043 //
00044 //  History:    6-24-94   stevebl   Stolen and modified from original DFView
00045 //
00046 //----------------------------------------------------------------------------
00047
00048 BOOL LoadAndStretch (
00049     HINSTANCE hinst,
00050     HBITMAP hbmpDest,
00051     LPTSTR lpszResource,
00052     UINT cxBitmap,
00053     UINT cyBitmap,
00054     COLORREF crHigh,
00055     COLORREF crNorm)
00056 {
00057     HBITMAP hbmpOld1, hbmpOld2, hbmp;
00058     BITMAP bm;
00059     int i;
00060     HDC hdcDest = CreateCompatibleDC(NULL);
00061     HDC hdcSrc = CreateCompatibleDC(NULL);
00062
00063     if (NULL == hdcDest || NULL == hdcSrc)
00064     {
00065         DeleteDC(hdcSrc);
00066         DeleteDC(hdcDest);
00067         return(FALSE);
00068     }
00069     for (i=0;  i < 2;  i++)
00070     {
00071         hbmp = LoadBitmap(hinst, lpszResource);
00072         if (NULL == hbmp)
00073         {
00074             DeleteDC(hdcSrc);
00075             DeleteDC(hdcDest);
00076             return FALSE;
00077         }
00078
00079         DDBChangeColor(hbmp, RGB (255,0,0), ((i == 0) ? crHigh : crNorm));
00080         GetObject(hbmp, sizeof (bm), &bm);
00081
00082         hbmpOld1 = (HBITMAP) SelectObject(hdcDest, hbmpDest);
00083         hbmpOld2 = (HBITMAP) SelectObject(hdcSrc, hbmp);
00084
00085         SetStretchBltMode(hdcDest, COLORONCOLOR);
00086         StretchBlt(
00087             hdcDest,
00088             i * cxBitmap * 2,
00089             0,
00090             cxBitmap * 2,
00091             cyBitmap,
00092             hdcSrc,
00093             0,
00094             0,
00095             bm.bmWidth,
00096             bm.bmHeight,
00097             SRCCOPY);
00098
00099         SelectObject(hdcDest, hbmpOld1);
00100         SelectObject(hdcSrc,  hbmpOld2);
00101         DeleteObject(hbmp);
00102     }
00103
00104     DeleteDC(hdcSrc);
00105     DeleteDC(hdcDest);
00106     return TRUE;
00107 }
00108
00109
00110
00111 //+---------------------------------------------------------------------------
00112 //
00113 //  Function:   DDBChangeColor
00114 //
00115 //  Synopsis:   Change a particular color in a bitmap to another color.
00116 //              Strategy is to create a monochrome mask, where each pixel
00117 //              in the source bitmap that matches the color we're converting
00118 //              from is set to white (1), and all other colors to black.
00119 //              We then Blt this mask into the original bitmap, with a ROP
00120 //              code that does:
00121 //
00122 //                (~Mask&Source) | (~Mask&Pattern)
00123 //
00124 //              where Pattern is the color we're changing to.
00125 //
00126 //              In other words, wherever the Mask is 1, we want to put the pattern;
00127 //              wherever the Mask is 0, we want to leave the source alone.  By
00128 //              using a Truth Table, you'll find that this ROP code is equivalent
00129 //              to DSPDxax or ROP code 0x00E20746.
00130 //
00131 //              For info on figuring out ROP codes given a set of boolean ops,
00132 //              check out the Windows 3.0 SDK, Reference Volume 2, chapter 11.
00133 //
00134 //  Arguments:  [hBitmap] - bitmap handle
00135 //              [crFrom]  - color to change
00136 //              [crTo]    - new color
00137 //
00138 //  Returns:    TRUE on success.  FALSE on failur
00139 //
00140 //  History:    6-24-94   stevebl   Stolen from original DFView code
00141 //
00142 //----------------------------------------------------------------------------
00143
00144 BOOL DDBChangeColor (HBITMAP hBitmap, COLORREF crFrom, COLORREF crTo)
00145 {
00146     register int cx, cy;
00147     BITMAP       bm;
00148     HDC          hdcBmp, hdcMask;
00149     HBITMAP      hbmMask, hbmOld1, hbmOld2;
00150     HBRUSH       hBrush, hbrOld;
00151
00152     if (!hBitmap)
00153           return FALSE;
00154
00155     GetObject (hBitmap, sizeof (bm), &bm);
00156     cx = bm.bmWidth;
00157     cy = bm.bmHeight;
00158
00159     hbmMask = CreateBitmap(cx, cy, 1, 1, NULL);
00160     hdcMask = CreateCompatibleDC(NULL);
00161     hdcBmp = CreateCompatibleDC(NULL);
00162     hBrush = CreateSolidBrush(crTo);
00163
00164     if (!hdcMask || !hdcBmp || !hBrush || !hbmMask)
00165     {
00166         DeleteObject(hbmMask);
00167         DeleteObject(hBrush);
00168         DeleteDC(hdcMask);
00169         DeleteDC(hdcBmp);
00170         return FALSE;
00171     }
00172
00173     hbmOld1 = (HBITMAP) SelectObject (hdcBmp,  hBitmap);
00174     hbmOld2 = (HBITMAP) SelectObject (hdcMask, hbmMask);
00175     hbrOld  = (HBRUSH) SelectObject (hdcBmp, hBrush);
00176
00177     SetBkColor(hdcBmp, crFrom);
00178     BitBlt(hdcMask, 0, 0, cx, cy, hdcBmp,  0, 0, SRCCOPY);
00179     SetBkColor(hdcBmp, RGB(255,255,255));
00180     BitBlt(hdcBmp,  0, 0, cx, cy, hdcMask, 0, 0, DSPDxax);
00181
00182     SelectObject(hdcBmp,  hbrOld);
00183     SelectObject(hdcBmp,  hbmOld1);
00184     SelectObject(hdcMask, hbmOld2);
00185     DeleteDC(hdcBmp);
00186     DeleteDC(hdcMask);
00187     DeleteObject(hBrush);
00188     DeleteObject(hbmMask);
00189
00190     return TRUE;
00191 }
00192
00193
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSplitterLite Member List

This is the complete list of members for CSplitterLite, including all inherited members.
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CSplitterLite(HWND hWndParent=NULL, UINT nID=0) | CSplitterLite |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DrawSplitter(HDC hDC, BOOL fVertical, REFRECT rectLeft, REFRECT rectRight, REFPOINTS ptsClient) | CSplitterLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hCursorOld | CSplitterLite |
m_hCursorRight | CSplitterLite |
m_hCursorTop | CSplitterLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iBorderCX | CSplitterLite |
m_iBorderCY | CSplitterLite |
m_nID | CWndLite |
m_pCWndBottom | CSplitterLite |
m_pCWndLeft | CSplitterLite |
m_pCWndRight | CSplitterLite |
m_pCWndTop | CSplitterLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnBorder(REFPOINTS pts, INT iBorder) | CSplitterLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetSplitter(CSplitterLite *pCWndTop, CSplitterLite *pCWndBottom=NULL, CSplitterLite *pCWndLeft=NULL, CSplitterLite *pCWndRight=NULL) | CSplitterLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
StartTracking(REFPOINTS ptsScreen, REFRECT rectLeft, REFRECT rectRight, BOOL fVertical, POINT *pPoint) | CSplitterLite | [virtual]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/DsSrch/main.cxx Source File

  • NetDS
  • ADSI
  • samples
  • General
  • DsSrch

main.cxx

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright (C) Microsoft Corporation, 1996 - 2000.
00005 //
00006 //  File:       drt.cxx
00007 //
00008 //  Contents:   Main for DS Srch
00009 //
00010 //
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 //
00015 // System Includes
00016 //
00017
00018 #define INC_OLE2
00019 #include <windows.h>
00020
00021 //
00022 // CRunTime Includes
00023 //
00024
00025 #include <stdlib.h>
00026 #include <limits.h>
00027 #include <io.h>
00028 #include <stdio.h>
00029
00030 //
00031 // Public OleDs includes
00032 //
00033
00034
00035 //
00036 // Private defines
00037 //
00038
00039 #define BAIL_ON_NULL(p)       \
00040         if (!(p)) {           \
00041                 goto error;   \
00042         }
00043
00044 #define BAIL_ON_FAILURE(hr)   \
00045         if (FAILED(hr)) {     \
00046                 goto error;   \
00047         }
00048
00049 #include "activeds.h"
00050 #include "main.hxx"
00051
00052 //
00053 // Globals representing the parameters
00054 //
00055
00056 LPWSTR pszSearchBase, pszSearchFilter, pszAttrNames[10], pszAttrList;
00057 DWORD dwNumberAttributes = -1, dwMaxRows = (DWORD) -1;
00058
00059
00060 //
00061 // Preferences
00062 //
00063 BOOL fASynchronous=FALSE, fDerefAliases=FALSE, fAttrsOnly=FALSE;
00064 DWORD fSizeLimit, fTimeLimit, dwTimeOut, dwPageSize, dwSearchScope;
00065
00066 ADS_SEARCHPREF_INFO pSearchPref[10];
00067 ADS_SORTKEY pSortKey[10];
00068 DWORD nSortKeys = 0;
00069 DWORD dwCurrPref = 0;
00070
00071 LPWSTR pszUserName=NULL, pszPassword=NULL;
00072 DWORD dwAuthFlags=0;
00073 DWORD cErr=0;
00074
00075 char *prefNameLookup[] =
00076     {
00077     "ADS_SEARCHPREF_ASYNCHRONOUS",
00078     "ADS_SEARCHPREF_DEREF_ALIASES",
00079     "ADS_SEARCHPREF_SIZE_LIMIT",
00080     "ADS_SEARCHPREF_TIME_LIMIT",
00081     "ADS_SEARCHPREF_ATTRIBTYPES_ONLY",
00082     "ADS_SEARCHPREF_SEARCH_SCOPE",
00083     "ADS_SEARCHPREF_TIMEOUT",
00084     "ADS_SEARCHPREF_PAGESIZE",
00085     "ADS_SEARCHPREF_PAGED_TIME_LIMIT",
00086     "ADS_SEARCHPREF_CHASE_REFERRALS"
00087     "ADS_SEARCHPREF_CACHE_RESULTS"
00088     };
00089
00090
00091 //+---------------------------------------------------------------------------
00092 //
00093 //  Function:   main
00094 //
00095 //  Synopsis:
00096 //
00097 //----------------------------------------------------------------------------
00098 INT main(int argc, char * argv[])
00099 {
00100     HRESULT hr=S_OK;
00101     IDirectorySearch *pDSSearch=NULL;
00102     ADS_SEARCH_HANDLE hSearchHandle=NULL;
00103     ADS_SEARCH_COLUMN Column;
00104     DWORD nRows = 0, i;
00105     LPWSTR pszColumnName = NULL;
00106
00107 #if 0       // Enable if you want to test binary values in filters and send
00108             // pszBinaryFilter instead of pszSearchFilter in ExecuteSearch
00109
00110     WCHAR pszBinaryFilter[256] = L"objectSid=";
00111
00112     LPWSTR pszDest = NULL;
00113
00114     BYTE column[100] = {
00115                     0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00,
00116                     0x00, 0x00, 0x59, 0x51, 0xb8, 0x17, 0x66, 0x72, 0x5d, 0x25,
00117                     0x64, 0x63, 0x3b, 0x0b, 0x29, 0x99, 0x21, 0x00 };
00118
00119     hr = ADsEncodeBinaryData (
00120        column,
00121        28,
00122        &pszDest
00123        );
00124
00125     wcsncat( pszBinaryFilter, pszDest ,wcslen(pszDest) );
00126
00127     FreeADsMem( pszDest );
00128
00129 #endif
00130
00131
00132     //
00133     // Sets the global variables with the parameters
00134     //
00135     hr = ProcessArgs(argc, argv);
00136     BAIL_ON_FAILURE(hr);
00137
00138     hr = CoInitialize(NULL);
00139
00140     if (FAILED(hr)) {
00141         printf("CoInitialize failed\n") ;
00142         return(1) ;
00143     }
00144
00145     hr = ADsOpenObject(
00146         pszSearchBase,
00147         pszUserName,
00148         pszPassword,
00149         dwAuthFlags,
00150         IID_IDirectorySearch,
00151         (void **)&pDSSearch
00152         );
00153
00154
00155 if(pszUserName) ZeroMemory((PVOID)pszUserName,wcslen(pszUserName)*sizeof(WCHAR));
00156 if(pszPassword) ZeroMemory((PVOID)pszPassword,wcslen(pszPassword)*sizeof(WCHAR));
00157
00158 #if 0 // If you want to go with the default credentials
00159
00160     hr = ADsGetObject(
00161                 pszSearchBase,
00162                 IID_IDirectorySearch,
00163                 (void **)&pDSSearch
00164                 );
00165
00166 #endif
00167
00168     BAIL_ON_FAILURE(hr);
00169
00170     if (dwCurrPref) {
00171         hr = pDSSearch->SetSearchPreference(
00172                  pSearchPref,
00173                  dwCurrPref
00174                  );
00175         BAIL_ON_FAILURE(hr);
00176
00177         if (hr != S_OK) {
00178             for (i=0; i<dwCurrPref; i++) {
00179                 if (pSearchPref[i].dwStatus != ADS_STATUS_S_OK) {
00180                     printf(
00181                         "Error in setting the preference %s: status = %d\n",
00182                            prefNameLookup[pSearchPref[i].dwSearchPref],
00183                            pSearchPref[i].dwStatus
00184                            );
00185                     cErr++;
00186                 }
00187             }
00188
00189         }
00190     }
00191
00192     hr = pDSSearch->ExecuteSearch(
00193              pszSearchFilter,
00194              pszAttrNames,
00195              dwNumberAttributes,
00196              &hSearchHandle
00197               );
00198     BAIL_ON_FAILURE(hr);
00199
00200     hr = pDSSearch->GetNextRow(
00201              hSearchHandle
00202              );
00203     BAIL_ON_FAILURE(hr);
00204
00205     while (hr != S_ADS_NOMORE_ROWS && nRows < dwMaxRows) {
00206         nRows++;
00207
00208         if (dwNumberAttributes == -1) {
00209             hr = pDSSearch->GetNextColumnName(
00210                      hSearchHandle,
00211                      &pszColumnName
00212                      );
00213             BAIL_ON_FAILURE(hr);
00214
00215             while (hr != S_ADS_NOMORE_COLUMNS) {
00216                 hr = pDSSearch->GetColumn(
00217                          hSearchHandle,
00218                          pszColumnName,
00219                          &Column
00220                          );
00221
00222                 if (FAILED(hr)  && hr != E_ADS_COLUMN_NOT_SET)
00223                     goto error;
00224
00225                 if (SUCCEEDED(hr)) {
00226                     PrintColumn(&Column, pszColumnName);
00227                     pDSSearch->FreeColumn(&Column);
00228                 }
00229
00230                 FreeADsMem(pszColumnName);
00231                 hr = pDSSearch->GetNextColumnName(
00232                          hSearchHandle,
00233                          &pszColumnName
00234                          );
00235                 BAIL_ON_FAILURE(hr);
00236             }
00237             printf("\n");
00238         }
00239         else {
00240             for ( i=0; i<dwNumberAttributes; i++) {
00241                 hr = pDSSearch->GetColumn(
00242                          hSearchHandle,
00243                          pszAttrNames[i],
00244                          &Column
00245                          );
00246
00247                 if (hr == E_ADS_COLUMN_NOT_SET)
00248                     continue;
00249
00250                 BAIL_ON_FAILURE(hr);
00251
00252                 PrintColumn(&Column, pszAttrNames[i]);
00253
00254                 pDSSearch->FreeColumn(&Column);
00255             }
00256         printf("\n");
00257         }
00258
00259         hr = pDSSearch->GetNextRow(
00260                  hSearchHandle
00261                  );
00262         BAIL_ON_FAILURE(hr);
00263     }
00264
00265     wprintf (L"Total Rows: %d\n", nRows);
00266
00267     if (cErr) {
00268         wprintf (L"%d warning(s) ignored", cErr);
00269     }
00270
00271     if (hSearchHandle)
00272         pDSSearch->CloseSearchHandle(hSearchHandle);
00273
00274     FREE_INTERFACE(pDSSearch);
00275
00276     FREE_UNICODE_STRING(pszSearchBase) ;
00277     FREE_UNICODE_STRING(pszSearchFilter) ;
00278     FREE_UNICODE_STRING(pszAttrList) ;
00279     FREE_UNICODE_STRING(pszUserName) ;
00280     FREE_UNICODE_STRING(pszPassword) ;
00281     for(i=0;i<nSortKeys;i++)    FREE_UNICODE_STRING(pSortKey[i].pszAttrType);
00282     CoUninitialize();
00283
00284     return(0) ;
00285
00286 error:
00287
00288     if (hSearchHandle)
00289         pDSSearch->CloseSearchHandle(hSearchHandle);
00290
00291     FREE_INTERFACE(pDSSearch);
00292
00293     FREE_UNICODE_STRING(pszSearchBase) ;
00294     FREE_UNICODE_STRING(pszSearchFilter) ;
00295     FREE_UNICODE_STRING(pszAttrList) ;
00296     FREE_UNICODE_STRING(pszUserName) ;
00297     FREE_UNICODE_STRING(pszPassword) ;
00298     for(i=0;i<nSortKeys;i++)    FREE_UNICODE_STRING(pSortKey[i].pszAttrType);
00299     wprintf (L"Error! hr = 0x%x\n", hr);
00300     return(1) ;
00301 }
00302
00303
00304 //+---------------------------------------------------------------------------
00305 //
00306 //  Function:   ProcessArgs
00307 //
00308 //  Synopsis:
00309 //
00310 //----------------------------------------------------------------------------
00311
00312 HRESULT
00313 ProcessArgs(
00314     int argc,
00315     char * argv[]
00316     )
00317 {
00318     argc--;
00319     int currArg = 1;
00320     LPWSTR pTemp;
00321     char *pszCurrPref, *pszCurrPrefValue;
00322
00323     char *pszAttr;
00324     DWORD nAttr=0;
00325
00326     while (argc) {
00327         if (argv[currArg][0] != '/' && argv[currArg][0] != '-')
00328             BAIL_ON_FAILURE (E_FAIL);
00329         switch (argv[currArg][1]) {
00330         case 'b':
00331             argc--;
00332             currArg++;
00333             if (argc <= 0)
00334                 BAIL_ON_FAILURE (E_FAIL);
00335             pszSearchBase = AllocateUnicodeString(argv[currArg]);
00336             BAIL_ON_NULL(pszSearchBase);
00337             break;
00338
00339         case 'f':
00340             argc--;
00341             currArg++;
00342             if (argc <= 0)
00343                 BAIL_ON_FAILURE (E_FAIL);
00344             pszSearchFilter = AllocateUnicodeString(argv[currArg]);
00345             BAIL_ON_NULL(pszSearchFilter);
00346             break;
00347
00348         case 'a':
00349             argc--;
00350             currArg++;
00351             if (argc <= 0)
00352                 BAIL_ON_FAILURE (E_FAIL);
00353             pszAttrList = AllocateUnicodeString(argv[currArg]);
00354             BAIL_ON_NULL(pszAttrList);
00355
00356             dwNumberAttributes = 0;
00357             pTemp = wcstok(pszAttrList, L",");
00358             pszAttrNames[dwNumberAttributes] = RemoveWhiteSpaces(pTemp);
00359             dwNumberAttributes++;
00360
00361             while (pTemp) {
00362                 pTemp = wcstok(NULL, L",");
00363                 pszAttrNames[dwNumberAttributes] = RemoveWhiteSpaces(pTemp);
00364                 dwNumberAttributes++;
00365             }
00366             dwNumberAttributes--;
00367             break;
00368
00369         case 'u':
00370             argc--;
00371             currArg++;
00372             if (argc <= 0)
00373                 BAIL_ON_FAILURE (E_FAIL);
00374             pszUserName = AllocateUnicodeString(argv[currArg]);
00375             BAIL_ON_NULL(pszSearchBase);
00376             argc--;
00377             currArg++;
00378             if (argc <= 0)
00379                 BAIL_ON_FAILURE (E_FAIL);
00380             pszPassword = AllocateUnicodeString(argv[currArg]);
00381             BAIL_ON_NULL(pszSearchBase);
00382             break;
00383
00384         case 't':
00385             argc--;
00386             currArg++;
00387             if (argc <= 0)
00388                 BAIL_ON_FAILURE (E_FAIL);
00389
00390             pszCurrPref = strtok(argv[currArg], "=");
00391             pszCurrPrefValue = strtok(NULL, "=");
00392             if (!pszCurrPref || !pszCurrPrefValue)
00393                 BAIL_ON_FAILURE(E_FAIL);
00394
00395             if (!_stricmp(pszCurrPref, "SecureAuth")) {
00396                 if (!_stricmp(pszCurrPrefValue, "yes" ))
00397                     dwAuthFlags |= ADS_SECURE_AUTHENTICATION;
00398                 else if (!_stricmp(pszCurrPrefValue, "no" ))
00399                     dwAuthFlags &= ~ADS_SECURE_AUTHENTICATION;
00400                 else
00401                     BAIL_ON_FAILURE(E_FAIL);
00402             }
00403             else if (!_stricmp(pszCurrPref, "UseEncrypt")) {
00404                 if (!_stricmp(pszCurrPrefValue, "yes" ))
00405                     dwAuthFlags |= ADS_USE_ENCRYPTION;
00406                 else if (!_stricmp(pszCurrPrefValue, "no" ))
00407                     dwAuthFlags &= ~ADS_USE_ENCRYPTION;
00408                 else
00409                     BAIL_ON_FAILURE(E_FAIL);
00410             }
00411             else
00412                 BAIL_ON_FAILURE(E_FAIL);
00413             break;
00414
00415         case 'p':
00416             argc--;
00417             currArg++;
00418             if (argc <= 0)
00419                 BAIL_ON_FAILURE (E_FAIL);
00420
00421             pszCurrPref = strtok(argv[currArg], "=");
00422             pszCurrPrefValue = strtok(NULL, "=");
00423             if (!pszCurrPref || !pszCurrPrefValue)
00424                 BAIL_ON_FAILURE(E_FAIL);
00425
00426             if (!_stricmp(pszCurrPref, "asynchronous")) {
00427                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_ASYNCHRONOUS;
00428                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_BOOLEAN;
00429                 if (!_stricmp(pszCurrPrefValue, "yes" ))
00430                     pSearchPref[dwCurrPref].vValue.Boolean = TRUE;
00431                 else if (!_stricmp(pszCurrPrefValue, "no" ))
00432                     pSearchPref[dwCurrPref].vValue.Boolean = FALSE;
00433                 else
00434                     BAIL_ON_FAILURE(E_FAIL);
00435             }
00436             else if (!_stricmp(pszCurrPref, "attrTypesOnly")) {
00437                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_ATTRIBTYPES_ONLY;
00438                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_BOOLEAN;
00439                 if (!_stricmp(pszCurrPrefValue, "yes" ))
00440                     pSearchPref[dwCurrPref].vValue.Boolean = TRUE;
00441                 else if (!_stricmp(pszCurrPrefValue, "no" ))
00442                     pSearchPref[dwCurrPref].vValue.Boolean = FALSE;
00443                 else
00444                     BAIL_ON_FAILURE(E_FAIL);
00445             }
00446             else if (!_stricmp(pszCurrPref, "derefAliases")) {
00447                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_DEREF_ALIASES;
00448                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00449                 if (!_stricmp(pszCurrPrefValue, "yes" ))
00450                     pSearchPref[dwCurrPref].vValue.Integer = ADS_DEREF_ALWAYS;
00451                 else if (!_stricmp(pszCurrPrefValue, "no" ))
00452                     pSearchPref[dwCurrPref].vValue.Integer = ADS_DEREF_NEVER;
00453                 else
00454                     BAIL_ON_FAILURE(E_FAIL);
00455             }
00456             else if (!_stricmp(pszCurrPref, "timeOut")) {
00457                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_TIMEOUT;
00458                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00459                 pSearchPref[dwCurrPref].vValue.Integer = atoi(pszCurrPrefValue);
00460             }
00461             else if (!_stricmp(pszCurrPref, "timeLimit")) {
00462                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_TIME_LIMIT;
00463                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00464                 pSearchPref[dwCurrPref].vValue.Integer = atoi(pszCurrPrefValue);
00465             }
00466             else if (!_stricmp(pszCurrPref, "sizeLimit")) {
00467                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT;
00468                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00469                 pSearchPref[dwCurrPref].vValue.Integer = atoi(pszCurrPrefValue);
00470             }
00471             else if (!_stricmp(pszCurrPref, "PageSize")) {
00472                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_PAGESIZE;
00473                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00474                 pSearchPref[dwCurrPref].vValue.Integer = atoi(pszCurrPrefValue);
00475             }
00476             else if (!_stricmp(pszCurrPref, "PagedTimeLimit")) {
00477                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_PAGED_TIME_LIMIT;
00478                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00479                 pSearchPref[dwCurrPref].vValue.Integer = atoi(pszCurrPrefValue);
00480             }
00481             else if (!_stricmp(pszCurrPref, "SearchScope")) {
00482                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
00483                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00484                 if (!_stricmp(pszCurrPrefValue, "Base" ))
00485                     pSearchPref[dwCurrPref].vValue.Integer = ADS_SCOPE_BASE;
00486                 else if (!_stricmp(pszCurrPrefValue, "OneLevel" ))
00487                     pSearchPref[dwCurrPref].vValue.Integer = ADS_SCOPE_ONELEVEL;
00488                 else if (!_stricmp(pszCurrPrefValue, "Subtree" ))
00489                     pSearchPref[dwCurrPref].vValue.Integer = ADS_SCOPE_SUBTREE;
00490                 else
00491                     BAIL_ON_FAILURE(E_FAIL);
00492             }
00493             else if (!_stricmp(pszCurrPref, "ChaseReferrals")) {
00494                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS;
00495                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_INTEGER;
00496                 if (!_stricmp(pszCurrPrefValue, "always" ))
00497                     pSearchPref[dwCurrPref].vValue.Integer = ADS_CHASE_REFERRALS_ALWAYS;
00498                 else if (!_stricmp(pszCurrPrefValue, "never" ))
00499                     pSearchPref[dwCurrPref].vValue.Integer = ADS_CHASE_REFERRALS_NEVER;
00500                 else if (!_stricmp(pszCurrPrefValue, "external" ))
00501                     pSearchPref[dwCurrPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL;
00502                 else if (!_stricmp(pszCurrPrefValue, "subordinate" ))
00503                     pSearchPref[dwCurrPref].vValue.Integer = ADS_CHASE_REFERRALS_SUBORDINATE;
00504                 else
00505                     BAIL_ON_FAILURE(E_FAIL);
00506             }
00507             else if (!_stricmp(pszCurrPref, "SortOn")) {
00508                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_SORT_ON;
00509                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_PROV_SPECIFIC;
00510
00511                 pszAttr = strtok(pszCurrPrefValue, ",");
00512
00513                 for (nAttr=0; pszAttr && nAttr < 10; nAttr++) {
00514
00515                     pSortKey[nAttr].pszAttrType = AllocateUnicodeString(pszAttr);
00516                     pSortKey[nAttr].pszReserved = NULL;
00517                     pSortKey[nAttr].fReverseorder = 0;
00518           nSortKeys++;
00519
00520                     pszAttr = strtok(NULL, ",");
00521                 }
00522                 if (nAttr == 0 && nAttr >= 10) {
00523                     BAIL_ON_FAILURE(E_FAIL);
00524                 }
00525
00526                 pSearchPref[dwCurrPref].vValue.ProviderSpecific.dwLength = sizeof(ADS_SORTKEY) * nAttr;
00527                 pSearchPref[dwCurrPref].vValue.ProviderSpecific.lpValue = (LPBYTE) pSortKey;
00528             }
00529             else if (!_stricmp(pszCurrPref, "cacheResults")) {
00530                 pSearchPref[dwCurrPref].dwSearchPref = ADS_SEARCHPREF_CACHE_RESULTS;
00531                 pSearchPref[dwCurrPref].vValue.dwType = ADSTYPE_BOOLEAN;
00532                 if (!_stricmp(pszCurrPrefValue, "yes" ))
00533                     pSearchPref[dwCurrPref].vValue.Boolean = TRUE;
00534                 else if (!_stricmp(pszCurrPrefValue, "no" ))
00535                     pSearchPref[dwCurrPref].vValue.Boolean = FALSE;
00536                 else
00537                     BAIL_ON_FAILURE(E_FAIL);
00538             }
00539             else
00540                 BAIL_ON_FAILURE(E_FAIL);
00541
00542             dwCurrPref++;
00543             break;
00544
00545         case 'n':
00546             argc--;
00547             currArg++;
00548             if (argc <= 0)
00549                 BAIL_ON_FAILURE (E_FAIL);
00550             dwMaxRows = atoi(argv[currArg]);
00551             break;
00552
00553        default:
00554             BAIL_ON_FAILURE(E_FAIL);
00555         }
00556
00557         argc--;
00558         currArg++;
00559     }
00560
00561     //
00562     // Check for Mandatory arguments;
00563     //
00564
00565     if (!pszSearchBase || !pszSearchFilter)
00566         BAIL_ON_FAILURE(E_FAIL);
00567
00568     if (dwNumberAttributes == 0) {
00569         //
00570         // Get all the attributes
00571         //
00572         dwNumberAttributes = -1;
00573     }
00574
00575     return (S_OK);
00576 error:
00577
00578     PrintUsage();
00579     return E_FAIL;
00580
00581 }
00582
00583
00584 LPWSTR
00585 RemoveWhiteSpaces(
00586     LPWSTR pszText)
00587 {
00588     LPWSTR pChar;
00589
00590     if(!pszText)
00591         return (pszText);
00592
00593     while(*pszText && iswspace(*pszText))
00594         pszText++;
00595
00596     for(pChar = pszText + wcslen(pszText) - 1; pChar >= pszText; pChar--) {
00597         if(!iswspace(*pChar))
00598             break;
00599         else
00600             *pChar = L'\0';
00601     }
00602
00603     return pszText;
00604 }
00605
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the class factories of the PERTEXT
00005              server.  This server provides the TextPage COM component.
00006              For this component, IClassFactory is implemented in an
00007              appropriate class factory COM object: CFTextPage. The COM
00008              component that can be manufactured by this server is known
00009              outside the server by its CLSID: CLSID_TextPage.
00010
00011              The class factories in this server use the CThreaded
00012              OwnThis mechanism to ensure mutually exclusive access by
00013              contending multiple threads.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial PERTEXT.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   CFTextPage.
00022
00023   Functions: .
00024
00025   Origin:    5-12-97: atrent - Editor-inheritance from FACTORY.CPP in
00026                the STOSERVE Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 /*---------------------------------------------------------------------------
00044   We include WINDOWS.H for all Win32 applications.
00045   We include OLE2.H because we will be calling the COM/OLE Libraries.
00046   We include OLECTL.H because it has definitions for connectable objects.
00047   We include APPUTIL.H because we will be building this DLL using
00048     the convenient Virtual Window and Dialog classes and other
00049     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00050   We include IPAGES.H and PAGEGUID.H for the common page-related
00051     Interface class, GUID, and CLSID specifications.
00052   We include SERVER.H because it has the necessary internal class
00053     definitions for the server housing of this DLL.
00054   We include FACTORY.H because it has the necessary internal class factory
00055     declarations for this DLL component server.  Those factories we will be
00056     implementing in this module.
00057   We include CONNECT.H for object class declarations for the various
00058     connection point and connection COM objects used in PERTEXT.
00059   We include TEXTPAGE.H, for the object class declarations for the
00060     COTextPage COM object.
00061 ---------------------------------------------------------------------------*/
00062 #include <windows.h>
00063 #include <ole2.h>
00064 #include <olectl.h>
00065 #include <apputil.h>
00066 #include <ipages.h>
00067 #include <pageguid.h>
00068 #include "server.h"
00069 #include "factory.h"
00070 #include "connect.h"
00071 #include "textpage.h"
00072
00073 /*---------------------------------------------------------------------------
00074   Implementation the CFTextPage Class Factory.  CFTextPage is the COM
00075   object class for the Class Factory that can manufacture COTextPage
00076   COM Components.
00077 ---------------------------------------------------------------------------*/
00078
00079 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00080   Method:   CFTextPage::CFTextPage
00081
00082   Summary:  CFTextPage Constructor. Note the member initializer:
00083             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00084             to pass the 'this', pUnkOuter, and pServer pointers of this
00085             constructor function to the constructor executed in the
00086             instantiation of the CImpIClassFactory interface whose
00087             implementation is nested inside this present object class.
00088
00089   Args:     IUnknown* pUnkOuter,
00090               Pointer to the the outer Unknown.  NULL means this COM Object
00091               is not being Aggregated.  Non NULL means it is being created
00092               on behalf of an outside COM object that is reusing it via
00093               aggregation.
00094             CServer* pServer)
00095               Pointer to the server's control object.
00096
00097   Modifies: m_cRefs, m_pUnkOuter.
00098
00099   Returns:  void
00100 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00101 CFTextPage::CFTextPage(
00102   IUnknown* pUnkOuter,
00103   CServer* pServer) :
00104   m_ImpIClassFactory(this, pUnkOuter, pServer)
00105 {
00106   // Zero the COM object's reference count.
00107   m_cRefs = 0;
00108
00109   // No AddRef necessary if non-NULL, as we're nested.
00110   m_pUnkOuter = pUnkOuter;
00111
00112   // Init the pointer to the server control object.
00113   m_pServer = pServer;
00114
00115   return;
00116 }
00117
00118
00119 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00120   Method:   CFTextPage::~CFTextPage
00121
00122   Summary:  CFTextPage Destructor.
00123
00124   Args:     void
00125
00126   Returns:  void
00127 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00128 CFTextPage::~CFTextPage(void)
00129 {
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   CFTextPage::QueryInterface
00136
00137   Summary:  QueryInterface of the CFTextPage non-delegating
00138             IUnknown implementation.
00139
00140   Args:     REFIID riid,
00141               [in] GUID of the Interface being requested.
00142             PPVOID ppv)
00143               [out] Address of the caller's pointer variable that will
00144               receive the requested interface pointer.
00145
00146   Returns:  HRESULT
00147               Standard result code. NOERROR for success.
00148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00149 STDMETHODIMP CFTextPage::QueryInterface(
00150                REFIID riid,
00151                PPVOID ppv)
00152 {
00153   HRESULT hr = E_NOINTERFACE;
00154
00155   if (OwnThis())
00156   {
00157     *ppv = NULL;
00158
00159     if (IID_IUnknown == riid)
00160       *ppv = this;
00161     else if (IID_IClassFactory == riid)
00162       *ppv = &m_ImpIClassFactory;
00163
00164     if (NULL != *ppv)
00165     {
00166       // We've handed out a pointer to the interface so obey the COM rules
00167       // and AddRef the reference count.
00168       ((LPUNKNOWN)*ppv)->AddRef();
00169       hr = NOERROR;
00170     }
00171
00172     UnOwnThis();
00173   }
00174
00175   return (hr);
00176 }
00177
00178
00179 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00180   Method:   CFTextPage::AddRef
00181
00182   Summary:  AddRef of the CFTextPage non-delegating IUnknown implementation.
00183
00184   Args:     void
00185
00186   Modifies: m_cRefs.
00187
00188   Returns:  ULONG
00189               New value of m_cRefs (COM object's reference count).
00190 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00191 STDMETHODIMP_(ULONG) CFTextPage::AddRef(void)
00192 {
00193   ULONG cRefs;
00194
00195   if (OwnThis())
00196   {
00197     cRefs = ++m_cRefs;
00198
00199     UnOwnThis();
00200   }
00201
00202   return cRefs;
00203 }
00204
00205
00206 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00207   Method:   CFTextPage::Release
00208
00209   Summary:  Release of the CFTextPage non-delegating IUnknown implementation.
00210
00211   Args:     void
00212
00213   Modifies: m_cRefs.
00214
00215   Returns:  ULONG
00216               New value of m_cRefs (COM object's reference count).
00217 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00218 STDMETHODIMP_(ULONG) CFTextPage::Release(void)
00219 {
00220   ULONG cRefs;
00221
00222   if (OwnThis())
00223   {
00224     cRefs = --m_cRefs;
00225
00226     if (0 == cRefs)
00227     {
00228       // We've reached a zero reference count for this COM object.
00229       // So we tell the server housing to decrement its global object
00230       // count so that the server will be unloaded if appropriate.
00231       if (NULL != m_pServer)
00232         m_pServer->ObjectsDown();
00233
00234       // We artificially bump the main ref count to prevent reentrancy
00235       // via the main object destructor.  Not really needed in this
00236       // CFPageList but a good practice because we are aggregatable and
00237       // may at some point in the future add something entertaining like
00238       // some Releases to the CFPageList destructor.
00239       m_cRefs++;
00240       UnOwnThis();
00241       delete this;
00242     }
00243     else
00244       UnOwnThis();
00245   }
00246
00247   return cRefs;
00248 }
00249
00250
00251 /*---------------------------------------------------------------------------
00252   CFTextPage's nested implementation of the IClassFactory interface
00253   including Constructor, Destructor, QueryInterface, AddRef, Release,
00254   CreateInstance, and LockServer methods.
00255 ---------------------------------------------------------------------------*/
00256
00257 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00258   Method:   CFTextPage::CImpIClassFactory::CImpIClassFactory
00259
00260   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00261
00262   Args:     CFTextPage* pCO,
00263               Back pointer to the parent outer object.
00264             IUnknown* pUnkOuter,
00265               Pointer to the outer Unknown.  For delegation.
00266             CServer* pServer)
00267               Pointer to the server's control object.
00268
00269   Modifies: m_pCO, m_pUnkOuter, m_pServer.
00270
00271   Returns:  void
00272 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00273 CFTextPage::CImpIClassFactory::CImpIClassFactory(
00274   CFTextPage* pCO,
00275   IUnknown* pUnkOuter,
00276   CServer* pServer)
00277 {
00278   // Init the Main Object Pointer to point to the parent object.
00279   m_pCO = pCO;
00280
00281   // Init the pointer to the server control object.
00282   m_pServer = pServer;
00283
00284   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00285   // We use the Main Object pointer for IUnknown delegation here if we are
00286   // not being aggregated. If we are being aggregated we use the supplied
00287   // pUnkOuter for IUnknown delegation. In either case the pointer
00288   // assignment requires no AddRef because the CImpIClassFactory lifetime
00289   // is quaranteed by the lifetime of the parent object in which
00290   // CImpIClassFactory is nested.
00291   if (NULL == pUnkOuter)
00292     m_pUnkOuter = pCO;
00293   else
00294     m_pUnkOuter = pUnkOuter;
00295
00296   return;
00297 }
00298
00299
00300 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00301   Method:   CFTextPage::CImpIClassFactory::~CImpIClassFactory
00302
00303   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00304
00305   Args:     void
00306
00307   Returns:  void
00308 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00309 CFTextPage::CImpIClassFactory::~CImpIClassFactory(void)
00310 {
00311   return;
00312 }
00313
00314
00315 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00316   Method:   CFTextPage::CImpIClassFactory::QueryInterface
00317
00318   Summary:  The QueryInterface IUnknown member of this IClassFactory
00319             interface implementation that delegates to m_pUnkOuter,
00320             whatever it is.
00321
00322   Args:     REFIID riid,
00323               [in] GUID of the Interface being requested.
00324             PPVOID ppv)
00325               [out] Address of the caller's pointer variable that will
00326               receive the requested interface pointer.
00327
00328   Returns:  HRESULT
00329               Standard result code. NOERROR for success.
00330               Returned by the delegated outer QueryInterface call.
00331 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00332 STDMETHODIMP CFTextPage::CImpIClassFactory::QueryInterface(
00333                REFIID riid,
00334                PPVOID ppv)
00335 {
00336   // Delegate this call to the outer object's QueryInterface.
00337   return m_pUnkOuter->QueryInterface(riid, ppv);
00338 }
00339
00340
00341 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00342   Method:   CFTextPage::CImpIClassFactory::AddRef
00343
00344   Summary:  The AddRef IUnknown member of this IClassFactory interface
00345             implementation that delegates to m_pUnkOuter, whatever it is.
00346
00347   Args:     void
00348
00349   Returns:  ULONG
00350               Returned by the delegated outer AddRef call.
00351 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00352 STDMETHODIMP_(ULONG) CFTextPage::CImpIClassFactory::AddRef(void)
00353 {
00354   // Delegate this call to the outer object's AddRef.
00355   return m_pUnkOuter->AddRef();
00356 }
00357
00358
00359 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00360   Method:   CFTextPage::CImpIClassFactory::Release
00361
00362   Summary:  The Release IUnknown member of this IClassFactory interface
00363             implementation that delegates to m_pUnkOuter, whatever it is.
00364
00365   Args:     void
00366
00367   Returns:  ULONG
00368               Returned by the delegated outer Release call.
00369 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00370 STDMETHODIMP_(ULONG) CFTextPage::CImpIClassFactory::Release(void)
00371 {
00372   // Delegate this call to the outer object's Release.
00373   return m_pUnkOuter->Release();
00374 }
00375
00376
00377 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00378   Method:   CFTextPage::CImpIClassFactory::CreateInstance
00379
00380   Summary:  The CreateInstance member method of this IClassFactory
00381             interface implementation.  Creates an instance of the
00382             COTextPage COM component.
00383
00384   Args:     IUnknown* pUnkOuter,
00385               [in] Pointer to the controlling IUnknown.
00386             REFIID riid,
00387               [in] GUID of the Interface being requested.
00388             PPVOID ppv)
00389               [out] Address of the caller's pointer variable that will
00390               receive the requested interface pointer.
00391
00392   Returns:  HRESULT
00393               Standard result code. NOERROR for success.
00394 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00395 STDMETHODIMP CFTextPage::CImpIClassFactory::CreateInstance(
00396                IUnknown* pUnkOuter,
00397                REFIID riid,
00398                PPVOID ppv)
00399 {
00400   HRESULT hr = E_FAIL;
00401   COTextPage* pCO = NULL;
00402
00403   // NULL the output pointer.
00404   *ppv = NULL;
00405
00406   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00407   // the COM rules state the IUnknown interface MUST also be concomitantly
00408   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00409   // an error must be returned indicating that no aggregate creation of
00410   // the CFTextPage COM Object can be performed.
00411   if (NULL != pUnkOuter && riid != IID_IUnknown)
00412     hr = CLASS_E_NOAGGREGATION;
00413   else
00414   {
00415     // Instantiate a COTextPage COM Object.
00416     pCO = new COTextPage(pUnkOuter, m_pServer);
00417     if (NULL != pCO)
00418     {
00419       // Create and initialize any subordinate objects. Rig connectivity.
00420       hr = pCO->Init();
00421       if (SUCCEEDED(hr))
00422       {
00423         // We successfully created the new COM object so tell the server
00424         // to increment its global server object count to help ensure
00425         // that the server remains loaded until this partial creation
00426         // of a COM component is completed.
00427         m_pServer->ObjectsUp();
00428
00429         // We QueryInterface this new COM Object not only to deposit the
00430         // main interface pointer to the caller's pointer variable, but to
00431         // also automatically bump the Reference Count on the new COM
00432         // Object after handing out this reference to it.
00433         hr = pCO->QueryInterface(riid, (PPVOID)ppv);
00434         if (FAILED(hr))
00435         {
00436           m_pServer->ObjectsDown();
00437           delete pCO;
00438         }
00439       }
00440       else
00441         delete pCO;
00442     }
00443     else
00444       hr = E_OUTOFMEMORY;
00445   }
00446
00447   return hr;
00448 }
00449
00450
00451 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00452   Method:   CFTextPage::CImpIClassFactory::LockServer
00453
00454   Summary:  The LockServer member method of this IClassFactory interface
00455             implementation.
00456
00457   Args:     BOOL bLock)
00458               [in] Flag determining whether to Lock or Unlock the server.
00459
00460   Returns:  HRESULT
00461               Standard result code. NOERROR for success.
00462 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00463 STDMETHODIMP CFTextPage::CImpIClassFactory::LockServer(
00464                BOOL bLock)
00465 {
00466   HRESULT hr = NOERROR;
00467
00468   if (bLock)
00469     m_pServer->Lock();
00470   else
00471     m_pServer->Unlock();
00472
00473   return hr;
00474 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/guids.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

guids.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Note that the GUIDs for CComponentData and CSnapinAbout are different
00014 //  from the ScopeNode project.  The Node GUIDs can stay the same since
00015 //  they are not really COM objects.
00016
00017
00018 #ifndef _PROPPAGEX_PROJECT_GUIDS_
00019 #define _PROPPAGEX_PROJECT_GUIDS_
00020
00021 // {489f991a-9a75-4553-885b-6ee881c50a26}
00022 DEFINE_GUID( CLSID_CExtendPropertySheet2,
00023              0x489f991a, 0x9a75, 0x4553, 0x88, 0x5b, 0x6e, 0xe8, 0x81, 0xc5, 0x0a, 0x26);
00024
00025
00026 #endif //_PROPPAGEX_PROJECT_GUIDS_
00027
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/TextFx/GuidE.c Source File

  • Multimedia
  • Gdi
  • TextFx

GuidE.c

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1992 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \*****************************************************************************/
00010 /*****************************************************************************
00011  *                                       *
00012  *  FX.C                                                 *
00013  *                                       *
00014  *  PURPOSE:  Routines for rendering text with stange effects                *
00015  *                                       *
00016  *  GetGuideLine       - Retrieves a guide line from the user.  A guide line *
00017  *             is just an array of line segments.            *
00018  *                                       *
00019  *  ShowGuide      - Displays a guide line into a DC                     *
00020  *                                       *
00021  *****************************************************************************/
00022
00023 #include <windows.h>
00024 #include "guide.h"
00025
00026 /**********************************************************************
00027  *                                                                    *
00028  * FUNCTION:  GetGuideLine(HWND, LPPOINT, LPDWORD)                    *
00029  *                                    *
00030  * PURPOSE:   Gets a guide line that is entered by the user.  This is *
00031  *            initiated on a WM_LBUTTONDOWN.                          *
00032  *                                                                    *
00033  *********************************************************************/
00034 BOOL GetGuideLine(HWND hWnd, LPPOINT *lpPoint, LPDWORD lpdwNumPts)
00035 {
00036     MSG msg;
00037     HDC hDC = GetDC(hWnd);
00038     BOOL bFirstTime = TRUE;
00039     DWORD dwPos = 0;
00040     RECT rect;
00041
00042     SetCapture(hWnd);
00043     GetClientRect(hWnd, &rect);
00044
00045     // Allocate enough room for a reasonable line
00046     *lpPoint = (LPPOINT)GlobalAlloc(GPTR, MAXGUIDESEGMENTS * sizeof(POINT));
00047
00048     /* Eat mouse messages until a WM_LBUTTONUP is encountered. Meanwhile
00049      * continue to draw a line that follows the mouse
00050      */
00051     for (;;){
00052         WaitMessage();
00053         if (PeekMessage(&msg,NULL,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE)) {
00054
00055             // Make sure we are still tracking in our client area
00056             if ((LOWORD(msg.lParam) < rect.right) && (HIWORD(msg.lParam) < rect.bottom)) {
00057
00058                 // Set the CP to our starting position if we are starting
00059                 if (bFirstTime) {
00060                   bFirstTime = FALSE;
00061             MoveToEx(hDC, LOWORD(msg.lParam), HIWORD(msg.lParam), NULL);
00062           }
00063
00064                 // If we dont have more points than we want...
00065                 if (dwPos < MAXGUIDESEGMENTS) {
00066
00067                 // Store the point in our array
00068                 (*lpPoint)[dwPos].x = LOWORD(msg.lParam);
00069                 (*lpPoint)[dwPos].y = HIWORD(msg.lParam);
00070
00071                 // Draw from the last point to this one
00072                 LineTo(hDC, (*lpPoint)[dwPos].x, (*lpPoint)[dwPos].y);
00073
00074                 // Increment our "number of points" counter
00075                 dwPos++;
00076           }
00077             }
00078
00079             // Bail when the user lets the left button up
00080             if (msg.message == WM_LBUTTONUP)
00081                break;
00082         }
00083         else
00084             continue;
00085     }
00086
00087     *lpdwNumPts = dwPos;
00088
00089     ReleaseDC(hWnd, hDC);
00090
00091     ReleaseCapture();
00092
00093     return TRUE;
00094 }
00095
00096 /**********************************************************************
00097  *                                                                    *
00098  * FUNCTION:  ShowGuide(HDC, LPPOINT, DWORD)                          *
00099  *                                    *
00100  * PURPOSE:   Draws a guide line into a DC                *
00101  *                                                                    *
00102  *********************************************************************/
00103 BOOL ShowGuide(HDC hDC, LPPOINT lpPoints, DWORD dwNumPts)
00104 {
00105   HPEN hOldBrush;
00106
00107   // Draw the line
00108   Polyline(hDC, lpPoints, dwNumPts);
00109
00110   // Draw green circle to indicate line starting point
00111   hOldBrush = SelectObject(hDC, CreateSolidBrush(RGB(0,255,0)));
00112   Ellipse(hDC, lpPoints[0].x-5, lpPoints[0].y-5,
00113                lpPoints[0].x+5, lpPoints[0].y+5);
00114
00115   // Draw red circle to indicate line ending point
00116   DeleteObject(SelectObject(hDC, CreateSolidBrush(RGB(255,0,0))));
00117   Ellipse(hDC, lpPoints[dwNumPts-1].x-5, lpPoints[dwNumPts-1].y-5,
00118                lpPoints[dwNumPts-1].x+5, lpPoints[dwNumPts-1].y+5);
00119   DeleteObject(SelectObject(hDC, hOldBrush));
00120
00121   return TRUE;
00122 }
00123
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/tracemacro.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

tracemacro.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  TraceMacro.h : Defines custom tracing helpers.
00014 //
00015
00016
00017 #ifndef _TRACE_MACRO_HEADER_
00018 #define _TRACE_MACRO_HEADER_
00019
00020 //---------------------------------------------------------------------------
00021 //  Function prototypes
00022 //
00023 VOID Trace_Start( LPCTSTR pszClass, LPCTSTR pszFunction );
00024 VOID Trace_HR( LPCTSTR pszClass, LPCTSTR pszFunction, HRESULT hr );
00025 VOID Trace_Value( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszValueName, LONG nValue );
00026 VOID Trace_Pointer( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszAction, ULONG ulValue );
00027 VOID Trace_Event( LPCTSTR pszClass, LPCTSTR pszFunction, LONG nEvent );
00028 VOID MapEvent( LONG Event, LPTSTR szEventStr );
00029
00030
00031 // Alternate version provides complete path to the file
00032 // #define TRACE_HRESULT(str,hr)  Trace_HR( _T(__FILE__), (str), (hr) )
00033
00034 #ifdef _DEBUG
00035
00036 #undef  TRACE_HRESULT
00037 #define TRACE_HRESULT(s1,hr) Trace_HR( (MODULESTRING),(s1),(hr) )
00038
00039 #undef  TRACE_VAL
00040 #define TRACE_VAL(s1,s2,val) Trace_Value( (MODULESTRING),(s1),(s2),(val) )
00041
00042 #undef  TRACE_PTR
00043 #define TRACE_PTR(s1,s2,val) Trace_Pointer( (MODULESTRING),(s1),(s2),(val) )
00044
00045 #undef  TRACE_EVENT
00046 #define TRACE_EVENT(s1,val)  Trace_Event( (MODULESTRING),(s1),(val) )
00047
00048 #undef  TRACE_START
00049 #define TRACE_START( s1 )    Trace_Start( (MODULESTRING),(s1) )
00050
00051
00052 #else
00053
00054 #undef  TRACE_HRESULT
00055 #define TRACE_HRESULT
00056
00057 #undef  TRACE_VAL
00058 #define TRACE_VAL
00059
00060 #undef  TRACE_PTR
00061 #define TRACE_PTR
00062
00063 #undef  TRACE_EVENT
00064 #define TRACE_EVENT
00065
00066 #undef  TRACE_START
00067 #define TRACE_START
00068
00069 #endif //_DEBUG
00070
00071
00072 #endif //_TRACE_MACRO_HEADER_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/Simple/Simple.cpp Source File

  • Web
  • iis
  • extensions
  • Simple

Simple.cpp

Go to the documentation of this file.
00001 //  Copyright (c) 1997-2002  Microsoft Corporation
00002 //
00003 //  Module Name:
00004 //
00005 //    Simple.cpp
00006 //
00007 //  Abstract:
00008 //
00009 //    This module shows the basic functions needed for ISAPI extensions
00010
00011 #define WIN32_LEAN_AND_MEAN
00012 #include <windows.h>
00013 #include <httpext.h>
00014
00015 //  Function:
00016 //
00017 //    DllMain
00018 //
00019 //  Description:
00020 //
00021 //    The initialization function for this DLL.
00022 //
00023 //  Arguments:
00024 //
00025 //    hinstDll - Instance handle of the DLL
00026 //    dwReason - Reason why NT called this DLL
00027 //    lpvContext - Reserved parameter for future use
00028 //
00029 //  Return Value:
00030 //
00031 //    Returns TRUE if successfull; otherwise FALSE.
00032
00033 BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD dwReason, IN LPVOID lpvContext)
00034 {
00035   // Note that appropriate initialization and termination code
00036   // would be written within the switch statement below.  Because
00037   // this example is very simple, none is currently needed.
00038
00039   switch(dwReason) {
00040
00041     case DLL_PROCESS_ATTACH :
00042
00043       break;
00044
00045     case DLL_PROCESS_DETACH :
00046
00047       break;
00048   }
00049
00050   return TRUE;
00051 }
00052
00053 //  Function:
00054 //
00055 //    GetExtensionVersion
00056 //
00057 //  Description:
00058 //
00059 //    The first function called after IIS successfully loads the DLL.  The function should use the
00060 //    version structure provided by IIS to set the ISAPI architectural version number of this extension.
00061 //
00062 //    A simple text-string is also set so that administrators can identify the DLL.
00063 //
00064 //    Note that HSE_VERSION_MINOR and HSE_VERSION_MAJOR are constants defined in httpext.h.
00065 //
00066 //  Arguments:
00067 //
00068 //    pVer - points to extension version structure
00069 //
00070 //  Return Value:
00071 //
00072 //    TRUE if successful; FALSE otherwise.
00073
00074 BOOL WINAPI GetExtensionVersion(OUT HSE_VERSION_INFO *pVer)
00075 {
00076   pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
00077
00078   lstrcpyn(pVer->lpszExtensionDesc, "IIS SDK Simple ISAPI Extension", HSE_MAX_EXT_DLL_NAME_LEN - 1);
00079
00080   return TRUE;
00081 }
00082
00083 //  Function:
00084 //
00085 //    HttpExtensionProc
00086 //
00087 //  Description:
00088 //
00089 //    Function called by the IIS Server when a request for the ISAPI dll
00090 //    arrives. The HttpExtensionProc function processes the request and
00091 //    outputs the appropriate response to the web client using WriteClient().
00092 //
00093 //  Argument:
00094 //
00095 //    pECB - pointer to extention control block.
00096 //
00097 //  Return Value:
00098 //
00099 //    HSE_STATUS_SUCCESS
00100
00101 DWORD WINAPI HttpExtensionProc(IN EXTENSION_CONTROL_BLOCK *pECB)
00102 {
00103   static char szMessage[] =
00104   "<HTML>"
00105   "<HEAD><TITLE> Simple ISAPI Extension DLL </TITLE>"
00106   "</HEAD>\r\n"
00107   "<BODY>"
00108   "<P>Hello from Simple ISAPI Extension DLL!</P>\r\n"
00109   "</BODY></HTML>\r\n\r\n";
00110
00111   HSE_SEND_HEADER_EX_INFO HeaderExInfo;
00112
00113   // prepare headers
00114
00115   HeaderExInfo.pszStatus = "200 OK";
00116   HeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n";
00117   HeaderExInfo.cchStatus = strlen(HeaderExInfo.pszStatus);
00118   HeaderExInfo.cchHeader = strlen(HeaderExInfo.pszHeader);
00119   HeaderExInfo.fKeepConn = FALSE;
00120
00121   // send headers using IIS-provided callback
00122   //
00123   // Note - if we needed to keep connection open, we would set fKeepConn
00124   // to TRUE *and* we would need to provide correct Content-Length: header
00125
00126   pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL);
00127
00128   // Calculate length of string to output to client
00129
00130   DWORD dwBytesToWrite = strlen( szMessage );
00131
00132   // send text using IIS-provied callback
00133
00134   pECB->WriteClient( pECB->ConnID, szMessage, &dwBytesToWrite, 0 );
00135
00136   // Indicate that the call to HttpExtensionProc was successful
00137
00138   return HSE_STATUS_SUCCESS;
00139 }
00140
00141 //  Function:
00142 //
00143 //    TerminateExtension
00144 //
00145 //  Description:
00146 //
00147 //    This function is called when the WWW service is shutdown
00148 //
00149 //  Arguments:
00150 //
00151 //    dwFlags - HSE_TERM_ADVISORY_UNLOAD or HSE_TERM_MUST_UNLOAD
00152 //
00153 //  Return Value:
00154 //
00155 //    TRUE if extension is ready to be unloaded, FALSE otherwise
00156
00157 BOOL WINAPI TerminateExtension(IN DWORD dwFlags)
00158 {
00159   // Note: We must not agree to be unloaded if we have any pending requests.
00160
00161   return TRUE;
00162 }
00163
00164
00165
00166
00167
00168
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFullConnectSecurity Member List

This is the complete list of members for CFullConnectSecurity, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CFullConnectSecurity() | CFullConnectSecurity |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_dwCacheProp | CFullConnectSecurity |
m_dwEncryptPasswordProp | CFullConnectSecurity |
m_dwImpersonateProp | CFullConnectSecurity |
m_dwMaskPasswordProp | CFullConnectSecurity |
m_dwPersistEncryptProp | CFullConnectSecurity |
m_dwPersistProp | CFullConnectSecurity |
m_dwProtectionProp | CFullConnectSecurity |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
m_wszIntegrated | CFullConnectSecurity |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | CPropPageLite | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CFullConnectSecurity | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CFullConnectSecurity | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CFullConnectSecurity | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSetActive() | CFullConnectSecurity | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
RefreshSecurity() | CFullConnectSecurity | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateSecurity() | CFullConnectSecurity | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/RasEnumDevices/c/RasEnumDevices.c Source File

  • NetDS
  • Ras
  • RasEnumDevices
  • c

RasEnumDevices.c

Go to the documentation of this file.
00001 //
00002 //       This is a part of the Microsoft Source Code Samples.
00003 //       Copyright 1993 - 2002 Microsoft Corporation.
00004 //       All rights reserved.
00005 //       This source code is only intended as a supplement to
00006 //       Microsoft Development Tools and/or WinHelp documentation.
00007 //       See these sources for detailed information regarding the
00008 //       Microsoft samples programs.
00009 //
00010
00011 //
00012 //    RasEnumDevices.c
00013 //
00014 //    Usage:
00015 //    RasEnumDevices
00016 //
00017 //    RAS API's used:
00018 //      RasEnumDevices
00019 //
00020 #ifndef _WIN32_WINNT
00021 #define _WIN32_WINNT 0x500
00022 #endif
00023
00024 #include <windows.h>
00025 #include <stdio.h>
00026 #include <ras.h>
00027 #include <raserror.h>
00028 #include <tchar.h>
00029
00030 // Macro for counting maximum characters that will fit into a buffer
00031 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00032
00033 int main(void)
00034 {
00035   DWORD         i = 0;
00036   DWORD         dwRet = 0;
00037   DWORD         cb = sizeof(RASDEVINFO);
00038   DWORD         cDevices = 0;
00039   LPRASDEVINFO    lpRasDevInfo;
00040   LPRASDEVINFO    lpTempRasDevInfo;
00041     BOOL            fSuccess = FALSE;
00042     TCHAR           szTempBuf[256] = {0};
00043
00044
00045     // Allocate buffer with space for at least one structure
00046     lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00047     if (NULL == lpRasDevInfo)
00048     {
00049         printf("HeapAlloc failed.\n");
00050         return ERROR_OUTOFMEMORY;
00051     }
00052
00053     lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
00054
00055     dwRet = RasEnumDevices(lpRasDevInfo, &cb, &cDevices);
00056
00057     switch(dwRet)   // Check whether RasEnumDevices succeeded
00058     {
00059     case ERROR_BUFFER_TOO_SMALL:
00060         // If the buffer is too small, free the allocated memory and allocate a bigger buffer.
00061         HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo);
00062         lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00063         if (NULL == lpRasDevInfo)
00064         {
00065             printf("HeapAlloc failed.\n");
00066             return ERROR_OUTOFMEMORY;
00067         }
00068
00069         lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
00070
00071         dwRet = RasEnumDevices(lpRasDevInfo, &cb, &cDevices);
00072         if (ERROR_SUCCESS == dwRet)
00073         {
00074             fSuccess = TRUE;
00075         }
00076         else
00077         {
00078             printf("RasEnumDevices failed: Error = %d\n", dwRet);
00079             goto done;
00080         }
00081         break;
00082
00083     case ERROR_SUCCESS:
00084             fSuccess = TRUE;
00085             break;
00086
00087     default:
00088         printf("RasEnumDevices failed: Error = %d\n", dwRet);
00089         goto done;
00090     }
00091
00092   if (fSuccess)
00093   {
00094     printf("The following RAS capable devices were found on this machine:\n\n");
00095     printf("Device\t\t\tCategory\n\n");
00096     lpTempRasDevInfo = lpRasDevInfo;
00097     for (i = 0; i < cDevices; i++)
00098     {
00099             ZeroMemory((LPVOID)szTempBuf, sizeof(szTempBuf));
00100             _snprintf(szTempBuf, CELEMS(szTempBuf) - 1, "%s\t%s\n",lpTempRasDevInfo->szDeviceName, lpTempRasDevInfo->szDeviceType);
00101       printf(szTempBuf);
00102       lpTempRasDevInfo++;
00103     }
00104   }
00105
00106 done:
00107   HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo);
00108   return (int)dwRet;
00109 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/Main.h Source File

  • Com
  • Services
  • Concurrency
  • SyncComp

Main.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: Main.h
00004
00005 Summary: Declaration of CMain
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021 // Main.h : Declaration of the CMain
00022
00023 #ifndef __MAIN_H_
00024 #define __MAIN_H_
00025
00026 #include "windows.h"
00027 #include "resource.h"       // main symbols
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CMain
00031 class CMain :
00032   public CDialogImpl<CMain>
00033 {
00034 private:
00035   enum {
00036     eSTA = STA_OFFSET,
00037     eFree = FREE_OFFSET,
00038     eCOMPlus = COMSYNC_OFFSET
00039   } e_compType;
00040
00041   DWORD volatile m_dwMaxTime, m_dwMinTime; // volatile due to compares in code
00042   DWORD   m_dwTotalIters, m_dwTotalTime;
00043   DWORD m_curThreadCount;
00044   int   m_iIters;
00045   DWORD m_iCookie;
00046   BOOL  m_bStop;
00047
00048 public:
00049   CMain()
00050   {
00051     m_dwMaxTime = m_dwMinTime = m_dwTotalIters = m_dwTotalTime = 0 ;
00052     m_curThreadCount = 0;
00053     m_bStop = 0;
00054   }
00055
00056   ~CMain()
00057   {
00058   }
00059
00060   enum { IDD = IDD_MAIN };
00061
00062 BEGIN_MSG_MAP(CMain)
00063   MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
00064   COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
00065   MESSAGE_HANDLER(WM_SIZE, OnSize)
00066   COMMAND_HANDLER(IDC_RADIO_COMSYNC, BN_CLICKED, OnClickedRadio_COMPlusSync)
00067   COMMAND_HANDLER(IDC_RADIO_FREE, BN_CLICKED, OnClickedRadio_Free)
00068   COMMAND_HANDLER(IDC_RADIO_STA, BN_CLICKED, OnClickedRadio_STA)
00069   COMMAND_HANDLER(IDC_START, BN_CLICKED, OnClickedStart)
00070   MESSAGE_HANDLER(WM_TIMER, OnTimer)
00071 END_MSG_MAP()
00072 // Handler prototypes:
00073 //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00074 //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00075 //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
00076
00077   LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00078   {
00079     EndDialog(wID);
00080     return 0;
00081   }
00082   LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00083   {
00084     // TODO : Add Code for message handler. Call DefWindowProc if necessary.
00085     return 0;
00086   }
00087
00088   LRESULT OnClickedRadio_COMPlusSync(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00089   {
00090     e_compType = eCOMPlus;
00091     return 0;
00092   }
00093   LRESULT OnClickedRadio_Free(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00094   {
00095     e_compType = eFree;
00096     return 0;
00097   }
00098   LRESULT OnClickedRadio_STA(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00099   {
00100     e_compType = eSTA;
00101     return 0;
00102   }
00103   LRESULT OnClickedStart(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00104   LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00105   LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00106
00107   void UpdateCounters(DWORD lDelta);
00108   static LRESULT ThreadStart(LPVOID lp);
00109   void UpdateUI(void);
00110 };
00111
00112 #endif //__MAIN_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/FileRepService.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

FileRepService.cpp

Go to the documentation of this file.
00001 /*
00002
00003     File Replication Sample
00004     Server System Service
00005
00006     FILE: FileRepService.cpp
00007
00008     PURPOSE: Provides file replication services.
00009
00010     USAGE:
00011         FileRepService
00012
00013     FUNCTIONS:
00014         main() - calls the StartServiceCtrlDispatcher function to
00015             connect to the SCM and start the control dispatcher thread.
00016         ServiceMain() - the entry point for the service.
00017         ServiceCtrl() - this function is called by the dispatcher thread.
00018             It handles the control code passed to it.
00019         ServiceStart() - performs actual initialization and starts the service.
00020             Makes the RPC server listen for calls.
00021         ServiceStop() - stops listening for RPCs.
00022
00023     COMMENTS:
00024
00025 */
00026
00027 // Common definitions
00028 #include "common.h"
00029
00030 #define SECURITY_WIN32
00031
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <process.h>
00035 #include <tchar.h>
00036 #include <rpc.h>
00037 #include <Ntdsapi.h>
00038 #include <Ntsecapi.h>
00039 #include <Security.h>
00040 #include <Secext.h>
00041 #include <Dsgetdc.h>
00042 #include <Lm.h>
00043
00044 // Generated by the MIDL compiler
00045 #include "FileRepServer.h"
00046 #include "FileRepClient.h"
00047
00048 // Contains declarations for system service functions.
00049 #include "Service.h"
00050
00051 #ifdef PROF
00052 #include "Prof.h"
00053 #endif
00054
00055 #ifdef DEBUG1
00056 #include "DbgMsg.h"
00057 #endif
00058
00059 /*
00060     Internal funtion declarations.
00061     See definitions for more info.
00062 */
00063
00064 VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv);
00065
00066 VOID WINAPI ServiceCtrl(DWORD Opcode);
00067
00068 VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
00069
00070 VOID ServiceStop();
00071
00072 /*
00073     FUNCTION: main()
00074
00075     PURPOSE: main() calls StartServiceCtrlDispatcher to register the
00076         main service thread.    When this call returns,
00077         the service has stopped.
00078
00079     PARAMETERS:
00080         dwArgc - number of command line arguments
00081         lpszArgv - array of command line arguments
00082
00083     RETURN VALUE:
00084         none
00085
00086     COMMENTS:
00087 */
00088 VOID _cdecl main(int argc, char **argv){
00089
00090     // Since we provide a single service there is only
00091     // one entry in the service dispatch table
00092     SERVICE_TABLE_ENTRY DispatchTable[] = {
00093         { SERVICENAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain },
00094         { NULL, NULL }
00095     };
00096
00097     // The service control manager may be starting the service with
00098     // this call, so we must call StartServiceCtrlDispatcher.
00099     if (!StartServiceCtrlDispatcher(DispatchTable)) {
00100         AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed"));
00101     }
00102 }
00103
00104 /*
00105     FUNCTION: ServiceMain
00106
00107     PURPOSE: To perform actual initialization of the client service.    It
00108         is the entry point into the service.
00109
00110     PARAMETERS:
00111         dwArgc - number of command line arguments
00112         lpszArgv - array of command line arguments
00113
00114     RETURN VALUE:
00115         none
00116
00117     COMMENTS:
00118         This routine performs the service initialization and then calls
00119         the user defined ServiceStart() routine to perform majority
00120         of the work.
00121 */
00122 VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) {
00123
00124     // Initial service configuration
00125     ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
00126     ssStatus.dwCurrentState = SERVICE_START_PENDING;
00127     ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
00128     ssStatus.dwWin32ExitCode = 0;
00129     ssStatus.dwServiceSpecificExitCode = 0;
00130     ssStatus.dwCheckPoint = 0;
00131     ssStatus.dwWaitHint = 0;
00132
00133     sshStatusHandle = RegisterServiceCtrlHandler(SERVICENAME, ServiceCtrl);
00134
00135     // Tell the SCM that the service is starting up.
00136     if (!SetServiceStatus(sshStatusHandle, &ssStatus)) {
00137         AddToMessageLog(TEXT("ServiceMain: SetServiceStatus failed\n"));
00138         return;
00139     }
00140
00141     // Initialize the service and start it.
00142     ServiceStart(dwArgc, lpszArgv);
00143
00144     return;
00145 }
00146
00147 /*
00148     FUNCTION: ServiceCtrl
00149
00150     PURPOSE: This function is called by the SCM whenever
00151         ControlService() is called on this service.
00152
00153     PARAMETERS:
00154         dwCtrlCode - type of control requested
00155
00156     RETURN VALUE:
00157         none
00158
00159     COMMENTS:
00160 */
00161
00162 VOID WINAPI ServiceCtrl(DWORD Opcode) {
00163
00164     // We only handle the STOP control requsts.
00165     switch(Opcode) {
00166
00167         case SERVICE_CONTROL_STOP:
00168             // Stop the service.
00169             ServiceStop();
00170             break;
00171
00172         default:
00173             AddToMessageLog(TEXT("ServiceCtrl: unrecognized or unimplemented opcode\n"));
00174     }
00175
00176     return;
00177 }
00178
00179 /*
00180     FUNCTION: ServiceStart
00181
00182     PURPOSE: Actual code of the service
00183              that does the work.
00184
00185     PARAMETERS:
00186         dwArgc - number of command line arguments
00187         lpszArgv - array of command line arguments
00188
00189     RETURN VALUE:
00190         none
00191
00192     COMMENTS:
00193         Starts the service listening for RPC requests.
00194 */
00195 VOID ServiceStart (DWORD dwArgc, LPTSTR *szArgList){
00196   RPC_STATUS status;
00197
00198     // Report the status to the service control manager.
00199     if (!ReportStatusToSCMgr(&sshStatusHandle, &ssStatus, SERVICE_START_PENDING, NO_ERROR, 1000)) {
00200         AddToMessageLog(TEXT("ServiceStart: ReportStatusToSCMgr failed\n"));
00201         ServiceStop();
00202         return;
00203     }
00204
00205     // Allow the user to override settings with command line switches.
00206     for (unsigned i = 1; i < dwArgc; i++) {
00207         // Well-formed argument switches start with '/' or '-' and are
00208         // two characters long.
00209         if (((*szArgList[i] == TEXT('-')) || (*szArgList[i] == TEXT('/'))) && _tcsclen(szArgList[i]) == 2) {
00210
00211             switch (_totlower(*(szArgList[i]+1))) {
00212
00213                 case TEXT('f'):
00214       bNoFileIO = true;
00215       break;
00216
00217                 default:
00218       AddToMessageLog(TEXT("ServiceStart: bad arguments"));
00219       ServiceStop();
00220       return;
00221             }
00222         }
00223         else {
00224     AddToMessageLog(TEXT("ServiceStart: bad arguments"));
00225     ServiceStop();
00226     return;
00227         }
00228     }
00229
00230
00231     if (!StartFileRepServer()) {
00232       ServiceStop();
00233     }
00234     else {
00235       bServerListening = TRUE;
00236
00237       // Tell The SCM that the service is running.
00238       if (!ReportStatusToSCMgr(&sshStatusHandle, &ssStatus, SERVICE_RUNNING, NO_ERROR, 0)){
00239         AddToMessageLog(TEXT("ServiceStart: ReportStatusToSCMgr failed"));
00240         ServiceStop();
00241         return;
00242       }
00243
00244       // RpcMgmtWaitServerListen() will block until the server has
00245       // stopped listening.
00246       status = RpcMgmtWaitServerListen();
00247       if (status != RPC_S_OK){
00248         AddToMessageLogProcFailureEEInfo(TEXT("ServiceStart: RpcMgmtWaitServerListen"), status);
00249         ServiceStop();
00250         return;
00251       }
00252     }
00253
00254     return;
00255 }
00256
00257 VOID ServiceStop(VOID) {
00258   ServerStop();
00259 }
00260
00261 // end FileRepService.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPropIDSets Member List

This is the complete list of members for CPropIDSets, including all inherited members.
AddElement(DBPROPIDSETelement) | CVector< DBPROPIDSET > | [virtual]
AddPropSet(REFGUID guidPropertySet) | TPropSetBase< DBPROPIDSET, CPropertyIDs > | [virtual]
Attach(CVector &rVector) | CVector< DBPROPIDSET > | [virtual]
Attach(ULONGcElements, DBPROPIDSET *rgElements) | CVector< DBPROPIDSET > | [virtual]
CPropIDSets(ULONG cPropIDSets=0, DBPROPIDSET *rgPropIDSets=NULL) | CPropIDSets |
CVector(ULONGulLowerBound=0, ULONGulGrowSize=10) | CVector< DBPROPIDSET > |
Detach(ULONG *pcElements, DBPROPIDSET **prgElements) | CVector< DBPROPIDSET > | [virtual]
FindProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet) | CPropIDSets | [virtual]
FindPropSet(REFGUID guidPropertySet) | TPropSetBase< DBPROPIDSET, CPropertyIDs > | [virtual]
GetCount() | CVector< DBPROPIDSET > | [inline, virtual]
GetElement(ULONGiIndex) | CVector< DBPROPIDSET > | [virtual]
GetElements() const | CVector< DBPROPIDSET > | [inline, virtual]
GetPropSets() | TPropSetBase< DBPROPIDSET, CPropertyIDs > | [inline, virtual]
InsertAt(ULONGiIndex, DBPROPIDSETelement) | CVector< DBPROPIDSET > | [virtual]
m_cElements | CVector< DBPROPIDSET > | [protected]
m_rgElements | CVector< DBPROPIDSET > | [protected]
m_ulGrowSize | CVector< DBPROPIDSET > | [protected]
m_ulLowerBound | CVector< DBPROPIDSET > | [protected]
m_ulMaxSize | CVector< DBPROPIDSET > | [protected]
operator[](ULONGiIndex) | CVector< DBPROPIDSET > | [inline, virtual]
RemoveAll() | TPropSetBase< DBPROPIDSET, CPropertyIDs > | [virtual]
RemoveAt(ULONGiIndex) | CVector< DBPROPIDSET > | [virtual]
SetProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet) | CPropIDSets | [virtual]
TPropSetBase(ULONG cElements=0, DBPROPIDSET *rgElements=NULL) | TPropSetBase< DBPROPIDSET, CPropertyIDs > |
~CPropIDSets() | CPropIDSets | [virtual]
~CVector() | CVector< DBPROPIDSET > | [virtual]
~TPropSetBase() | TPropSetBase< DBPROPIDSET, CPropertyIDs > | [virtual]
Generated on Wed Nov 13 2024 16:57:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Resource.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Resource.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #define NUMBER_COLUMNS                  6
00018 #define IDS_PROJNAME                    100
00019 #define IDR_COMSpy1                     100
00020 #define IDR_COMSPY                      101
00021 #define IDS_TITLEComSpyPropPage         102
00022 #define IDR_TXSINK                      103
00023 #define IDS_HELPFILEComSpyPropPage      106
00024 #define IDS_DOCSTRINGComSpyPropPage     107
00025 #define IDR_COMSPYPROPPAGE              108
00026 #define IDD_COMSPYPROPPAGE              109
00027 #define IDR_SPYMENU                     201
00028 #define IDR_SHOWEVENTS                  201
00029 #define IDC_SHOW_GRID_LINES             201
00030 #define IDC_LOG_FILE                    202
00031 #define IDI_MAIN                        203
00032 #define IDC_WIDTH                       203
00033 #define IDC_LOG_TO_FILE                 204
00034 #define IDC_COLUMN_NAMES                205
00035 #define IDD_CONFIGUREEVENTSDLG          205
00036 #define IDC_SHOW_ON_SCREEN              206
00037 #define IDC_AUDIT_TO_DB                 207
00038 #define IDC_LIST_APPS                   208
00039 #define IDC_LIST_EVENTS                 209
00040 #define IDC_STATIC_CURRENTAPP           210
00041 #define IDC_EVENTS_FRAME                214
00042 #define IDC_STATIC_EVENTPLACEHOLDER     216
00043 #define IDC_LISTVIEWEVENTS              220
00044 #define IDC_CHECK_ALLAPPS               222
00045 #define IDC_STATIC_TYPE                 223
00046 #define IDC_LISTVIEWSYSEVENTS           224
00047 #define ID_DEBUG_BEGIN                  500
00048 #define ID_DEBUG_END                    599
00049 #define ID_LOG                          32768
00050 #define IDM_SELECT_APPLICATIONS         32769
00051 #define ID_CHOOSEFONT                   32770
00052 #define ID_SAVE                         32771
00053 #define ID_CHOOSE_LOG_FILE_NAME         32772
00054 #define ID_CLEAR                        32773
00055 #define ID_OPTIONS_GRID_LINES           32774
00056 #define ID_SHOW_ON_SCREEN               32776
00057 #define IDM_ABOUT                       32777
00058 #define ID_SPY_DEBUG_NORUNNINGAPPLICATIONS  32779
00059 #define ID_AUDIT                        32780
00060
00061 // Next default values for new objects
00062 //
00063 #ifdef APSTUDIO_INVOKED
00064 #ifndef APSTUDIO_READONLY_SYMBOLS
00065 #define _APS_NEXT_RESOURCE_VALUE        206
00066 #define _APS_NEXT_COMMAND_VALUE         32781
00067 #define _APS_NEXT_CONTROL_VALUE         225
00068 #define _APS_NEXT_SYMED_VALUE           113
00069 #endif
00070 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/AsyncRPC/AsyncRPCp.c Source File

  • NetDS
  • RPC
  • AsyncRPC

AsyncRPCp.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright Microsoft Corp. 1992 - 2000
00007 //
00008 // FILE:      AsyncRPCp.c
00009 //
00010 // PURPOSE:   Remote procedures that are linked with the server
00011 //            side of RPC distributed application
00012 //
00013 // COMMENTS:  The Microsoft RPC AsyncRPC sample program demonstrates
00014 //            the use of the [async] attribute and the related asynchronous
00015 //            RPC API functions. The asynchronous function will take certain
00016 //            amount of time to finish. In the process, it also periodically
00017 //            checks whether the call has been cancelled by the client.
00018 //            For more information, see MSDN online reference.
00019 //
00020 // WRITTEN BY:    Mike Liu
00021 //
00022
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 #include "AsyncRPC.h" // header file generated by MIDL compiler
00026
00027 const char PERCENT = '%';
00028 const unsigned long DEFAULT_NONASYNC_DELAY     = 1000;  // in miliseconds
00029 const unsigned long ASYNC_CANCEL_CHECK         = 500;   // in miliseconds
00030
00031 // Non-asynchronous routine which can be called
00032 // by a client when an asynchronous routine is running.
00033 void NonAsyncFunc(IN RPC_BINDING_HANDLE hBinding,
00034                   IN unsigned char * pszMessage)
00035 {
00036    Sleep(DEFAULT_NONASYNC_DELAY);
00037    fprintf(stderr, "\n\nReceived (%s) via NonAsyncFunc\n\n", pszMessage);
00038 }
00039
00040
00041 // Asynchronous routine. It sends back the notification
00042 // when it is done.
00043 void AsyncFunc(IN PRPC_ASYNC_STATE pAsync,
00044                IN RPC_BINDING_HANDLE hBinding,
00045                IN unsigned long nAsychDelay)
00046 {
00047    int nReply = 1;
00048    RPC_STATUS status;
00049    unsigned long nTmpAsychDelay;
00050    int i;
00051
00052    if (nAsychDelay < 0)
00053       nAsychDelay = DEFAULT_ASYNC_DELAY;
00054
00055    nAsychDelay *= 1000;  // convert to ms
00056
00057    // We only call RpcServerTestCancel if the call
00058    // takes longer than ASYNC_CANCEL_CHECK ms
00059    if (nAsychDelay > ASYNC_CANCEL_CHECK)
00060    {
00061       nTmpAsychDelay = nAsychDelay/100;
00062
00063       for (i = 0; i < 100; i++)
00064       {
00065          Sleep(nTmpAsychDelay);
00066
00067          if (i%5 == 0)
00068          {
00069             // Report the progress of the asynchronous function
00070             fprintf(stderr, "\rRunning AsyncFunc (%lu ms) (%d%c) ... ",
00071                     nAsychDelay, i+5, PERCENT);
00072
00073             // Check whether the call is cancelled by the client
00074             status = RpcServerTestCancel(RpcAsyncGetCallHandle(pAsync));
00075             if (status == RPC_S_OK)
00076             {
00077                fprintf(stderr, "\nAsyncFunc has been cancelled!!!\n");
00078                break;
00079             }
00080             else if (status != RPC_S_CALL_IN_PROGRESS)
00081             {
00082                printf("RpcServerTestCancel returned 0x%x\n", status);
00083                exit(status);
00084             }
00085          }
00086       }
00087    }
00088    else
00089       Sleep(nAsychDelay);
00090
00091    printf("\nCalling RpcAsyncCompleteCall\n");
00092    status = RpcAsyncCompleteCall(pAsync, &nReply);
00093    printf("RpcAsyncCompleteCall returned 0x%x\n", status);
00094    if (status)
00095       exit(status);
00096 }
00097
00098
00099 void Shutdown(IN RPC_BINDING_HANDLE hBinding)
00100 {
00101    RPC_STATUS status;
00102
00103    printf("Calling RpcMgmtStopServerListening\n");
00104    status = RpcMgmtStopServerListening(NULL);
00105    printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00106    if (status)
00107       exit(status);
00108
00109    printf("Calling RpcServerUnregisterIf\n");
00110    status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00111    printf("RpcServerUnregisterIf returned 0x%x\n", status);
00112    if (status)
00113       exit(status);
00114 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/resource.h Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Account.rc
00004 //
00005 #define IDS_ACCOUNT_DESC                1
00006 #define IDR_Account                     1
00007 #define IDS_MOVEMONEY_DESC              2
00008 #define IDR_MoveMoney                   2
00009 #define IDS_UPDATERECEIPT_DESC          114
00010 #define IDR_UpdateReceipt               115
00011 #define IDS_GETRECEIPT_DESC             116
00012 #define IDR_GetReceipt                  117
00013 #define IDS_UPDATERECEIPT_DESC1         118
00014 #define IDR_UpdateReceipt1              119
00015
00016 // Next default values for new objects
00017 //
00018 #ifdef APSTUDIO_INVOKED
00019 #ifndef APSTUDIO_READONLY_SYMBOLS
00020 #define _APS_NEXT_RESOURCE_VALUE        201
00021 #define _APS_NEXT_COMMAND_VALUE         32768
00022 #define _APS_NEXT_CONTROL_VALUE         201
00023 #define _APS_NEXT_SYMED_VALUE           120
00024 #endif
00025 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PROPVALUE Member List

This is the complete list of members for _PROPVALUE, including all inherited members.
vtType | _PROPVALUE
vtValue | _PROPVALUE
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerServe/PageList.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerServe

PageList.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAGELIST.CPP
00003
00004   Summary:   Implementation file for the COPageList COM Object Class (for
00005              connectable COPageList COM Objects). COPageList encapsulates
00006              into a persistent COM object the management of a page list.
00007              The list holds items that represent pages of user-editable
00008              information. Currently, two page types are supported in this
00009              sample: Text pages and Drawing pages. The client can use the
00010              custom IPageList interface to perform such operations on the
00011              list as: Get a list item, Set a list item, Add an item to the
00012              list, Delete an item from the list, and Clear the list.
00013              COPageList objects expose the IPersistStream interface and
00014              thus support its method of stream persistence for the list
00015              data. This persistence support is covered in detail in
00016              PERSERVE.HTM.
00017
00018              Connectable object technology is used in COPageList to notify
00019              connected clients of various events like when a page item is
00020              added to the list.
00021
00022              COPageList offers a main standard IUnknown interface (basic
00023              COM object features), the standard IConnectionPointContainer
00024              interface (connectable COM object features), the standard
00025              IPersistStream interface (stream persistence features), and
00026              the custom IPageList interface (PageList related features).
00027              This multiple interface COM Object Class is achieved via the
00028              technique of nested classes.  The implementations of the
00029              various interfaces are nested inside the COPageList Class.
00030
00031              For a comprehensive tutorial code tour of this module's
00032              contents and offerings see the tutorial PERSERVE.HTM
00033              file. For more specific technical details on the internal
00034              workings see the comments dispersed throughout the module's
00035              source code.
00036
00037   Classes:   COPageList.
00038
00039   Functions: none.
00040
00041   Origin:    2-5-97: atrent - Editor-inheritance from PAPER.CPP in
00042              the STOSERVE Tutorial Code Sample.
00043
00044 ----------------------------------------------------------------------------
00045   This file is part of the Microsoft COM Tutorial Code Samples.
00046
00047   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00048
00049   This source code is intended only as a supplement to Microsoft
00050   Development Tools and/or on-line documentation.  See these other
00051   materials for detailed information regarding Microsoft code samples.
00052
00053   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00054   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00055   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00056   PARTICULAR PURPOSE.
00057 ==========================================================================+*/
00058
00059
00060 /*---------------------------------------------------------------------------
00061   We include WINDOWS.H for all Win32 applications.
00062   We include OLE2.H because we will be calling the COM/OLE Libraries.
00063   We include OLECTL.H because it has definitions for connectable objects.
00064   We include APPUTIL.H because we will be building this application using
00065     the convenient Virtual Window and Dialog classes and other
00066     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00067   We include IPAGES.H and PAGEGUID.H for the common PageList-related
00068     Interface class, GUID, and CLSID specifications.
00069   We include SERVER.H because it has internal class declarations for
00070     the server's control object.
00071   We include CONNECT.H for object class declarations for the various
00072     connection point and connection COM objects used in PERSERVE.
00073   We include PAGELIST.H because it has the COPageList class declarations.
00074 ---------------------------------------------------------------------------*/
00075 #include <windows.h>
00076 #include <ole2.h>
00077 #include <olectl.h>
00078 #include <apputil.h>
00079 #include <ipages.h>
00080 #include <pageguid.h>
00081 #include "server.h"
00082 #include "connect.h"
00083 #include "pagelist.h"
00084
00085
00086 /*---------------------------------------------------------------------------
00087   COPageList's implementation of its main COM object class including
00088   Constructor, Destructor, QueryInterface, AddRef, and Release.
00089 ---------------------------------------------------------------------------*/
00090
00091 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00092   Method:   COPageList::COPageList
00093
00094   Summary:  COPageList Constructor. Note the member initializer:
00095             "m_ImpIPageList(this, pUnkOuter)" which is used to pass the
00096             'this' and pUnkOuter pointers of the constructor function to
00097             the constructor in the instantiation of the implementation of
00098             the CImpIPageList interface (which is nested inside this
00099             present COPageList Object Class). Same technique is used for
00100             the other nested interface implementations.
00101
00102   Args:     IUnknown* pUnkOuter,
00103               Pointer to the the outer Unknown.  NULL means this COM Object
00104               is not being Aggregated.  Non NULL means it is being created
00105               on behalf of an outside COM object that is reusing it via
00106               aggregation.
00107             CServer* pServer)
00108               Pointer to the server's control object.
00109
00110   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00111
00112   Returns:  void
00113 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00114 COPageList::COPageList(
00115   IUnknown* pUnkOuter,
00116   CServer* pServer) :
00117   m_ImpIPageList(this, pUnkOuter),
00118   m_ImpIPersistStream(this, pUnkOuter),
00119   m_ImpIConnectionPointContainer(this, pUnkOuter)
00120 {
00121   UINT i;
00122
00123   // Zero the COM object's reference count.
00124   m_cRefs = 0;
00125
00126   // No AddRef necessary if non-NULL, as we're nested.
00127   m_pUnkOuter = pUnkOuter;
00128
00129   // Assign the pointer to the server control object.
00130   m_pServer = pServer;
00131
00132   // Null all entries in the connection point array.
00133   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00134     m_aConnectionPoints[i] = NULL;
00135
00136   // Now initialize the PageList itself.
00137   m_lPageListEnd = 0;
00138   m_lPageListMax = 0;
00139   m_paPageList   = NULL;
00140   m_bDirty       = TRUE;
00141   m_ClassID      = CLSID_PageList;
00142
00143   return;
00144 }
00145
00146
00147 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00148   Method:   COPageList::~COPageList
00149
00150   Summary:  COPageList Destructor.
00151
00152   Args:     void
00153
00154   Returns:  void
00155 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00156 COPageList::~COPageList(void)
00157 {
00158   UINT i;
00159   IConnectionPoint* pIConnectionPoint;
00160   PAGEITEM* paPageList;
00161
00162   // Do final release of the connection point objects.
00163   // If this isn't the final release, then the client has an outstanding
00164   // unbalanced reference to a connection point and a memory leak may
00165   // likely result because the host COPageList object is now going away yet
00166   // a connection point for this host object will not end up deleting
00167   // itself (and its connections array).
00168   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00169   {
00170     pIConnectionPoint = m_aConnectionPoints[i];
00171     RELEASE_INTERFACE(pIConnectionPoint);
00172   }
00173
00174   // NULL the pointer first and then delete the entire PageList array.
00175   paPageList = m_paPageList;
00176   m_paPageList = NULL;
00177   if (NULL != paPageList)
00178     delete [] paPageList;
00179
00180   return;
00181 }
00182
00183
00184 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00185   Method:   COPageList::Init
00186
00187   Summary:  COPageList initialization method.  Create any necessary
00188             arrays, structures, and subordinate objects. In this case the
00189             COM object is initialized as a connectable object.
00190
00191   Args:     void
00192
00193   Modifies: m_aConnectionPoints.
00194
00195   Returns:  HRESULT
00196               Standard result code. NOERROR for success.
00197 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00198 HRESULT COPageList::Init(void)
00199 {
00200   HRESULT hr = NOERROR;
00201   COConnectionPoint* pCOConnPt;
00202
00203   // Rig this COPageList COM object to be connectable. Assign the
00204   // connection point array. This object's connection points are
00205   // determined at compile time--it currently has only one connection
00206   // point: the CONNPOINT_PAGELISTSINK connection point. Create a
00207   // connection point object for this and assign it into the array. This
00208   // array could easily grow to support additional connection points in
00209   // the future.
00210
00211   // First try creating a new connection point object. Pass 'this' as the
00212   // pHostObj pointer used by the connection point to pass its AddRef and
00213   // Release calls back to the host connectable object.
00214   pCOConnPt = new COConnectionPoint(this);
00215   if (NULL != pCOConnPt)
00216   {
00217     // If creation succeeded then initialize it (including creating
00218     // its initial dynamic connection array).
00219     hr = pCOConnPt->Init(IID_IPageListSink);
00220
00221     // If the init succeeded then use QueryInterface to obtain the
00222     // IConnectionPoint interface on the new connection point object.
00223     // The interface pointer is assigned directly into the
00224     // connection point array. The QI also does the needed AddRef.
00225     if (SUCCEEDED(hr))
00226     {
00227       hr = pCOConnPt->QueryInterface(
00228              IID_IConnectionPoint,
00229              (PPVOID)&m_aConnectionPoints[CONNPOINT_PAGELISTSINK]);
00230       if (SUCCEEDED(hr))
00231       {
00232         // Build the initial empty dynamic array of PageList Items.
00233         hr = Clear();
00234
00235         // Mark new empty Page List as clean.
00236         m_bDirty = FALSE;
00237       }
00238     }
00239
00240     if (FAILED(hr))
00241       delete pCOConnPt;
00242   }
00243   else
00244     hr = E_OUTOFMEMORY;
00245
00246   return hr;
00247 }
00248
00249
00250 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00251   Method:   COPageList::QueryInterface
00252
00253   Summary:  QueryInterface of the COPageList non-delegating IUnknown
00254             implementation.
00255
00256   Args:     REFIID riid,
00257               [in] GUID of the Interface being requested.
00258             PPVOID ppv)
00259               [out] Address of the caller's pointer variable that will
00260               receive the requested interface pointer.
00261
00262   Returns:  HRESULT
00263               Standard result code. NOERROR for success.
00264 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00265 STDMETHODIMP COPageList::QueryInterface(
00266                REFIID riid,
00267                PPVOID ppv)
00268 {
00269   HRESULT hr = E_NOINTERFACE;
00270
00271   *ppv = NULL;
00272
00273   if (IID_IUnknown == riid)
00274     *ppv = this;
00275   else if (IID_IConnectionPointContainer == riid)
00276     *ppv = &m_ImpIConnectionPointContainer;
00277   else if (IID_IPersistStream == riid)
00278     *ppv = &m_ImpIPersistStream;
00279   else if (IID_IPageList == riid)
00280     *ppv = &m_ImpIPageList;
00281
00282   if (NULL != *ppv)
00283   {
00284     // We've handed out a pointer to the interface so obey the COM rules
00285     // and AddRef the reference count.
00286     ((LPUNKNOWN)*ppv)->AddRef();
00287     hr = NOERROR;
00288   }
00289
00290   return (hr);
00291 }
00292
00293
00294 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00295   Method:   COPageList::AddRef
00296
00297   Summary:  AddRef of the COPageList non-delegating IUnknown implementation.
00298
00299   Args:     void
00300
00301   Returns:  ULONG
00302               New value of m_cRefs (COM object's reference count).
00303 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00304 STDMETHODIMP_(ULONG) COPageList::AddRef(void)
00305 {
00306   ULONG cRefs;
00307
00308   cRefs = ++m_cRefs;
00309
00310   return cRefs;
00311 }
00312
00313
00314 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00315   Method:   COPageList::Release
00316
00317   Summary:  Release of the COPageList non-delegating IUnknown implementation.
00318
00319   Args:     void
00320
00321   Modifies: m_cRefs.
00322
00323   Returns:  ULONG
00324               New value of m_cRefs (COM object's reference count).
00325 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00326 STDMETHODIMP_(ULONG) COPageList::Release(void)
00327 {
00328   ULONG cRefs;
00329
00330   cRefs = --m_cRefs;
00331
00332   if (0 == cRefs)
00333   {
00334     // We've reached a zero reference count for this COM object.
00335     // So we tell the server housing to decrement its global object
00336     // count so that the server will be unloaded if appropriate.
00337     if (NULL != m_pServer)
00338       m_pServer->ObjectsDown();
00339
00340     // We artificially bump the main ref count to prevent reentrancy
00341     // via the main object destructor.  Not really needed in this
00342     // COPageList but a good practice because we are aggregatable and
00343     // may at some point in the future add something entertaining like
00344     // some Releases to the COPageList destructor. We relinquish thread
00345     // ownership of this object prior to deleting it--a good practice.
00346     m_cRefs++;
00347     delete this;
00348   }
00349
00350   return cRefs;
00351 }
00352
00353
00354 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00355   Method:   COPageList::NotifySinks
00356
00357   Summary:  Internal utility method of this COM object used to fire event
00358             notification calls to all listening connection sinks in the
00359             clients.
00360
00361   Args:     PAGELIST_EVENT PageListEvent
00362               Type of notification event.
00363
00364   Returns:  HRESULT
00365               Standard result code. NOERROR for success.
00366 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00367 HRESULT COPageList::NotifySinks(
00368        PAGELIST_EVENT PageListEvent,
00369        INT iPage)
00370 {
00371   HRESULT hr = NOERROR;
00372   IConnectionPoint* pIConnectionPoint;
00373   IEnumConnections* pIEnum;
00374   CONNECTDATA ConnData;
00375
00376   // If there was a PageList event, broadcast appropriate notifications to
00377   // all Sinks connected to each connection point.
00378   if (PAGELIST_EVENT_NONE != PageListEvent)
00379   {
00380     // Here is the section for the PageListSink connection point--currently
00381     // this is the only connection point offered by COPageList objects.
00382     pIConnectionPoint = m_aConnectionPoints[CONNPOINT_PAGELISTSINK];
00383     if (NULL != pIConnectionPoint)
00384     {
00385       pIConnectionPoint->AddRef();
00386       hr = pIConnectionPoint->EnumConnections(&pIEnum);
00387       if (SUCCEEDED(hr))
00388       {
00389         // Loop thru the connection point's connections and if the
00390         // listening connection supports IPageListSink (ie, PageListSink
00391         // events) then dispatch the PageListEvent event notification to
00392         // that sink.
00393         while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
00394         {
00395           IPageListSink* pIPageListSink;
00396
00397           hr = ConnData.pUnk->QueryInterface(
00398                                 IID_IPageListSink,
00399                                 (PPVOID)&pIPageListSink);
00400           if (SUCCEEDED(hr))
00401           {
00402             switch (PageListEvent)
00403             {
00404               case PAGELIST_EVENT_LOADED:
00405                 pIPageListSink->Loaded();
00406                 break;
00407               case PAGELIST_EVENT_SAVED:
00408                 pIPageListSink->Saved();
00409                 break;
00410               case PAGELIST_EVENT_CLEARED:
00411                 pIPageListSink->Cleared();
00412                 break;
00413               case PAGELIST_EVENT_PAGEADDED:
00414                 pIPageListSink->PageAdded(iPage);
00415                 break;
00416               case PAGELIST_EVENT_PAGEDELETED:
00417                 pIPageListSink->PageDeleted(iPage);
00418                 break;
00419               case PAGELIST_EVENT_PAGESET:
00420                 pIPageListSink->PageSet(iPage);
00421                 break;
00422               default:
00423                 break;
00424             }
00425             pIPageListSink->Release();
00426           }
00427           ConnData.pUnk->Release();
00428         }
00429         pIEnum->Release();
00430       }
00431       pIConnectionPoint->Release();
00432     }
00433   }
00434
00435   return hr;
00436 }
00437
00438
00439 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00440   Method:   COPageList::Clear
00441
00442   Summary:  Internal utility method of this COM object used to clear
00443             the PageList array.
00444
00445   Args:     none.
00446
00447   Returns:  HRESULT
00448               Standard result code. NOERROR for success.
00449 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00450 HRESULT COPageList::Clear(
00451           void)
00452 {
00453   HRESULT hr = E_FAIL;
00454   PAGEITEM* paPageList;
00455
00456   // Allocate new array space for a fresh empty Page List array.
00457   paPageList = new PAGEITEM[(LONG)(PAGELIST_ALLOC_INIT)];
00458   if (NULL != paPageList)
00459   {
00460     // Zero the array.
00461     memset(paPageList, 0, PAGELIST_ALLOC_INIT * sizeof(PAGEITEM));
00462
00463     // New array is ready--delete the old array.
00464     if (NULL != m_paPageList)
00465       delete [] m_paPageList;
00466
00467     // Rig the PageList to use the new array.
00468     m_paPageList = paPageList;
00469     m_lPageListMax = PAGELIST_ALLOC_INIT;
00470     m_lPageListEnd = 0;
00471
00472     // Zero the PageList Properties structure. Init the PageList version.
00473     memset(&m_PageListProps, 0, sizeof(PAGELISTPROPS));
00474     m_PageListProps.lPageListVersion = PAGELIST_VERSION10;
00475
00476     // Mark PageList as dirty.
00477     m_bDirty = TRUE;
00478     hr = NOERROR;
00479   }
00480   else
00481     hr = E_OUTOFMEMORY;
00482
00483   return hr;
00484 }
00485
00486
00487 /*---------------------------------------------------------------------------
00488   COPageList's nested implementation of the COM standard
00489   IConnectionPointContainer interface including Constructor, Destructor,
00490   QueryInterface, AddRef, Release, FindConnectionPoint, and
00491   EnumConnectionPoints.
00492 ---------------------------------------------------------------------------*/
00493
00494 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00495   Method:   COPageList::CImpIConnectionPointContainer
00496               ::CImpIConnectionPointContainer
00497
00498   Summary:  Constructor for the CImpIConnectionPointContainer interface
00499             instantiation.
00500
00501   Args:     COPageList* pCO,
00502               Back pointer to the parent outer object.
00503             IUnknown* pUnkOuter
00504               Pointer to the outer Unknown.  For delegation.
00505
00506   Modifies: m_pCO, m_pUnkOuter.
00507
00508   Returns:  void
00509 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00510 COPageList::CImpIConnectionPointContainer::CImpIConnectionPointContainer(
00511   COPageList* pCO,
00512   IUnknown* pUnkOuter)
00513 {
00514   // Init the Main Object Pointer to point to the parent object.
00515   m_pCO = pCO;
00516
00517   // Init the CImpIConnectionPointContainer interface's delegating Unknown
00518   // pointer.  We use the Main Object pointer for IUnknown delegation here
00519   // if we are not being aggregated.  If we are being aggregated we use
00520   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00521   // pointer assignment requires no AddRef because the
00522   // CImpIConnectionPointContainer lifetime is quaranteed by the lifetime
00523   // of the parent object in which CImpIConnectionPointContainer is
00524   // nested.
00525   if (NULL == pUnkOuter)
00526     m_pUnkOuter = pCO;
00527   else
00528     m_pUnkOuter = pUnkOuter;
00529
00530   return;
00531 }
00532
00533
00534 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00535   Method:   COPageList::CImpIConnectionPointContainer
00536               ::~CImpIConnectionPointContainer
00537
00538   Summary:  Destructor for the CImpIConnectionPointContainer interface
00539             instantiation.
00540
00541   Args:     void
00542
00543   Returns:  void
00544 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00545 COPageList::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
00546 {
00547   return;
00548 }
00549
00550
00551 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00552   Method:   COPageList::CImpIConnectionPointContainer::QueryInterface
00553
00554   Summary:  The QueryInterface IUnknown member of this interface
00555             implementation that delegates to m_pUnkOuter, whatever it is.
00556
00557   Args:     REFIID riid,
00558               [in] GUID of the Interface being requested.
00559             PPVOID ppv)
00560               [out] Address of the caller's pointer variable that will
00561               receive the requested interface pointer.
00562
00563   Returns:  HRESULT
00564               Standard result code. NOERROR for success.
00565               Returned by the delegated outer QueryInterface call.
00566 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00567 STDMETHODIMP COPageList::CImpIConnectionPointContainer::QueryInterface(
00568                REFIID riid,
00569                PPVOID ppv)
00570 {
00571   // Delegate this call to the outer object's QueryInterface.
00572   return m_pUnkOuter->QueryInterface(riid, ppv);
00573 }
00574
00575
00576 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00577   Method:   COPageList::CImpIConnectionPointContainer::AddRef
00578
00579   Summary:  The AddRef IUnknown member of this IPageList interface
00580             implementation that delegates to m_pUnkOuter, whatever it is.
00581
00582   Args:     void
00583
00584   Returns:  ULONG
00585               Returned by the delegated outer AddRef call.
00586 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00587 STDMETHODIMP_(ULONG) COPageList::CImpIConnectionPointContainer::AddRef(void)
00588 {
00589   // Delegate this call to the outer object's AddRef.
00590   return m_pUnkOuter->AddRef();
00591 }
00592
00593
00594 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00595   Method:   COPageList::CImpIConnectionPointContainer::Release
00596
00597   Summary:  The Release IUnknown member of this interface implementation
00598             that delegates to m_pUnkOuter, whatever it is.
00599
00600   Args:     void
00601
00602   Returns:  ULONG
00603               Returned by the delegated outer Release call.
00604 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00605 STDMETHODIMP_(ULONG) COPageList::CImpIConnectionPointContainer::Release(void)
00606 {
00607   // Delegate this call to the outer object's Release.
00608   return m_pUnkOuter->Release();
00609 }
00610
00611
00612 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00613   Method:   COPageList::CImpIConnectionPointContainer::FindConnectionPoint
00614
00615   Summary:  Given an IID for a connection point sink find and return the
00616             interface pointer for that connection point sink.
00617
00618   Args:     REFIID riid
00619               Reference to an IID
00620             IConnectionPoint** ppConnPt
00621               Address of the caller's IConnectionPoint interface pointer
00622               variable that will receive the requested interface pointer.
00623
00624   Returns:  HRESULT
00625               Standard result code. NOERROR for success.
00626 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00627 STDMETHODIMP COPageList::CImpIConnectionPointContainer::FindConnectionPoint(
00628                REFIID riid,
00629                IConnectionPoint** ppConnPt)
00630 {
00631   HRESULT hr = E_NOINTERFACE;
00632   IConnectionPoint* pIConnPt;
00633
00634   // NULL the output variable.
00635   *ppConnPt = NULL;
00636
00637   pIConnPt = m_pCO->m_aConnectionPoints[CONNPOINT_PAGELISTSINK];
00638   if (NULL != pIConnPt)
00639   {
00640     // This connectable COPageList object currently has only the
00641     // PageList Sink connection point. If the associated interface is
00642     // requested, use QI to get the Connection Point interface and
00643     // perform the needed AddRef.
00644     if (IID_IPageListSink == riid)
00645       hr = pIConnPt->QueryInterface(
00646                        IID_IConnectionPoint,
00647                        (PPVOID)ppConnPt);
00648   }
00649
00650   return hr;
00651 }
00652
00653
00654 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00655   Method:   COPageList::CImpIConnectionPointContainer::EnumConnectionPoints
00656
00657   Summary:  Return Enumerator for the connectable object's contained
00658             connection points.
00659
00660   Args:     IEnumConnectionPoints** ppIEnum
00661               Address of the caller's Enumerator interface pointer
00662               variable. An output variable that will receive a pointer to
00663               the connection point enumerator COM object.
00664
00665   Returns:  HRESULT
00666               Standard result code. NOERROR for success.
00667 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00668 STDMETHODIMP COPageList::CImpIConnectionPointContainer::EnumConnectionPoints(
00669                IEnumConnectionPoints** ppIEnum)
00670 {
00671   HRESULT hr = NOERROR;
00672   IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
00673   COEnumConnectionPoints* pCOEnum;
00674   UINT i;
00675
00676   // Zero the output interface pointer.
00677   *ppIEnum = NULL;
00678
00679   // Make a copy on the stack of the array of connection point
00680   // interfaces. The copy is used below in the creation of the new
00681   // Enumerator object.
00682   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00683     aConnPts[i] = (IConnectionPoint*)m_pCO->m_aConnectionPoints[i];
00684
00685   // Create a Connection Point enumerator COM object for the connection
00686   // points offered by this COPageList object. Pass 'this' to be used to
00687   // hook the lifetime of the host object to the life time of this
00688   // enumerator object.
00689   pCOEnum = new COEnumConnectionPoints(this);
00690   if (NULL != pCOEnum)
00691   {
00692     // Use the array copy to Init the new Enumerator COM object.
00693     // Set the initial Enumerator index to 0.
00694     hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
00695     if (SUCCEEDED(hr))
00696     {
00697       // QueryInterface to return the requested interface pointer.
00698       // An AddRef will be conveniently done by the QI.
00699       if (SUCCEEDED(hr))
00700         hr = pCOEnum->QueryInterface(
00701                         IID_IEnumConnectionPoints,
00702                         (PPVOID)ppIEnum);
00703     }
00704   }
00705   else
00706     hr = E_OUTOFMEMORY;
00707
00708   return hr;
00709 }
00710
00711
00712 /*---------------------------------------------------------------------------
00713   COPageList's nested implementation of the COM standard
00714   IPersistStream interface including Constructor, Destructor,
00715   QueryInterface, AddRef, Release, GetClassID, IsDirty, Load, Save,
00716   and GetSizeMax.
00717 ---------------------------------------------------------------------------*/
00718
00719 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00720   Method:   COPageList::CImpIPersistStream::CImpIPersistStream
00721
00722   Summary:  Constructor for the CImpIPersistStream interface
00723             instantiation.
00724
00725   Args:     COPageList* pCO,
00726               Back pointer to the parent outer object.
00727             IUnknown* pUnkOuter
00728               Pointer to the outer Unknown.  For delegation.
00729
00730   Modifies: m_pCO, m_pUnkOuter.
00731
00732   Returns:  void
00733 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00734 COPageList::CImpIPersistStream::CImpIPersistStream(
00735   COPageList* pCO,
00736   IUnknown* pUnkOuter)
00737 {
00738   // Init the Back Object Pointer to point to the parent object.
00739   m_pCO = pCO;
00740
00741   // Init the CImpIPersistStream interface's delegating Unknown
00742   // pointer.  We use the Main Object pointer for IUnknown delegation here
00743   // if we are not being aggregated.  If we are being aggregated we use
00744   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00745   // pointer assignment requires no AddRef because the
00746   // pIPersistStream lifetime is quaranteed by the lifetime of the
00747   // parent object in which CImpIPersistStream is nested.
00748   if (NULL == pUnkOuter)
00749     m_pUnkOuter = pCO;
00750   else
00751     m_pUnkOuter = pUnkOuter;
00752
00753   return;
00754 }
00755
00756
00757 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00758   Method:   COPageList::CImpIPersistStream::~CImpIPersistStream
00759
00760   Summary:  Destructor for the CImpIPersistStreamIint interface
00761             instantiation.
00762
00763   Args:     void
00764
00765   Returns:  void
00766 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00767 COPageList::CImpIPersistStream::~CImpIPersistStream(void)
00768 {
00769   return;
00770 }
00771
00772
00773 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00774   Method:   COPageList::CImpIPersistStream::QueryInterface
00775
00776   Summary:  The QueryInterface IUnknown member of this interface
00777             implementation that delegates to m_pUnkOuter, whatever it is.
00778
00779   Args:     REFIID riid,
00780               [in] GUID of the Interface being requested.
00781             PPVOID ppv)
00782               [out] Address of the caller's pointer variable that will
00783               receive the requested interface pointer.
00784
00785   Returns:  HRESULT
00786               Standard result code. NOERROR for success.
00787               Returned by the delegated outer QueryInterface call.
00788 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00789 STDMETHODIMP COPageList::CImpIPersistStream::QueryInterface(
00790                REFIID riid,
00791                PPVOID ppv)
00792 {
00793   // Delegate this call to the outer object's QueryInterface.
00794   return m_pUnkOuter->QueryInterface(riid, ppv);
00795 }
00796
00797
00798 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00799   Method:   COPageList::CImpIPersistStream::AddRef
00800
00801   Summary:  The AddRef IUnknown member of this interface implementation
00802             that delegates to m_pUnkOuter, whatever it is.
00803
00804   Args:     void
00805
00806   Returns:  ULONG
00807               Returned by the delegated outer AddRef call.
00808 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00809 STDMETHODIMP_(ULONG) COPageList::CImpIPersistStream::AddRef(void)
00810 {
00811   // Delegate this call to the outer object's AddRef.
00812   return m_pUnkOuter->AddRef();
00813 }
00814
00815
00816 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00817   Method:   COPageList::CImpIPersistStream::Release
00818
00819   Summary:  The Release IUnknown member of this interface implementation
00820             that delegates to m_pUnkOuter, whatever it is.
00821
00822   Args:     void
00823
00824   Returns:  ULONG
00825               Returned by the delegated outer Release call.
00826 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00827 STDMETHODIMP_(ULONG) COPageList::CImpIPersistStream::Release(void)
00828 {
00829   // Delegate this call to the outer object's Release.
00830   return m_pUnkOuter->Release();
00831 }
00832
00833
00834 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00835   Method:   COPageList::CImpIPersistStream::GetClassID
00836
00837   Summary:  A method inherited from IPersist. Get the Class ID of this
00838             COM object.
00839
00840   Args:     CLSID* pClassID
00841               [out] Address of caller's CLSID variable to hold Class ID.
00842
00843   Returns:  HRESULT
00844               Standard result code. NOERROR for success.
00845 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00846 STDMETHODIMP COPageList::CImpIPersistStream::GetClassID(
00847                CLSID* pClassID)
00848 {
00849   HRESULT hr = E_POINTER;
00850
00851   if (NULL != pClassID)
00852   {
00853     // Use overloaded '=' operator to copy the Class ID.
00854     *pClassID = m_pCO->m_ClassID;
00855     hr = NOERROR;
00856   }
00857
00858   return hr;
00859 }
00860
00861
00862 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00863   Method:   COPageList::CImpIPersistStream::IsDirty
00864
00865   Summary:  Called to determine if changes were made to this COM object's
00866             data since it was last loaded, initialized, or saved.
00867
00868   Args:     none.
00869
00870   Returns:  HRESULT
00871               Standard result code. S_OK if dirty; S_FALSE if not.
00872 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00873 STDMETHODIMP COPageList::CImpIPersistStream::IsDirty(
00874                void)
00875 {
00876   HRESULT hr = E_FAIL;
00877
00878   hr = m_pCO->m_bDirty ? S_OK : S_FALSE;
00879
00880   return hr;
00881 }
00882
00883
00884 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00885   Method:   COPageList::CImpIPersistStream::Load
00886
00887   Summary:  Asks this COM object to load its persistent data from the
00888             specified stream at the current seek pointer. This function
00889             assumes the seek pointer is the same as it was before Save
00890             was last called. This function must leave the seek pointer
00891             the same as it was when Save was last completed regardless
00892             of success or failure. This function should not store a copy
00893             of pIStream in the COM object and should release it when done.
00894
00895             Load is called when this COM object already has a persistent
00896             state stored in a stream. Notifies all other connected clients
00897             when the load is complete.
00898
00899   Args:     IStream* pIStream
00900               IStream interface pointer for stream to load from.
00901
00902   Returns:  HRESULT
00903               Standard result code. NOERROR for success.
00904 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00905 STDMETHODIMP COPageList::CImpIPersistStream::Load(
00906                IStream* pIStream)
00907 {
00908   HRESULT hr = E_POINTER;
00909   PAGEITEM* paPageList;
00910   ULONG ulToRead, ulReadIn;
00911   LONG lNewArraySize;
00912   PAGELISTPROPS NewProps;
00913
00914   if (NULL != pIStream)
00915   {
00916     // We have the PageList data stream. First read the
00917     // PageList Properties.
00918     ulToRead = sizeof(PAGELISTPROPS);
00919     hr = pIStream->Read(
00920                      &NewProps,
00921                      ulToRead,
00922                      &ulReadIn);
00923     if (SUCCEEDED(hr) && ulToRead != ulReadIn)
00924       hr = E_FAIL;
00925     if (SUCCEEDED(hr))
00926     {
00927       // Deal with the different PageList versions.
00928       switch (NewProps.lPageListVersion)
00929       {
00930         case PAGELIST_VERSION10:
00931           // Allocate a page list array big enough--add some extra
00932           // for later expansion by user.
00933           lNewArraySize = NewProps.lPageListSize + PAGELIST_ALLOC;
00934           paPageList = new PAGEITEM[(LONG) lNewArraySize];
00935           if (NULL != paPageList)
00936           {
00937             // Delete the entire old Page List array.
00938             if (NULL != m_pCO->m_paPageList)
00939               delete [] m_pCO->m_paPageList;
00940
00941             // Assign the new array.
00942             m_pCO->m_paPageList = paPageList;
00943             m_pCO->m_lPageListMax = lNewArraySize;
00944
00945             // Now read the complete array of Page List items.
00946             ulToRead = NewProps.lPageListSize * sizeof(PAGEITEM);
00947             hr = pIStream->Read(m_pCO->m_paPageList, ulToRead, &ulReadIn);
00948             if (SUCCEEDED(hr) && ulToRead != ulReadIn)
00949               hr = E_FAIL;
00950             if (SUCCEEDED(hr))
00951             {
00952               // Rig COPageList to use the PAGELISTPROPS info.
00953               m_pCO->m_lPageListEnd = NewProps.lPageListSize - 1;
00954
00955               // Copy the new properties into current properties.
00956               memcpy(
00957                 &m_pCO->m_PageListProps,
00958                 &NewProps,
00959                 sizeof(PAGELISTPROPS));
00960             }
00961           }
00962           else
00963             hr = E_OUTOFMEMORY;
00964           break;
00965         default:
00966           hr = E_FAIL;  // Bad version.
00967           break;
00968       }
00969     }
00970   }
00971
00972   // Notify all other connected clients that PageList is now loaded.
00973   // If we didn't load then clear to a safe, empty Page List array.
00974   if (SUCCEEDED(hr))
00975     m_pCO->NotifySinks(PAGELIST_EVENT_LOADED,0);
00976   else
00977     m_pCO->Clear();
00978
00979   return hr;
00980 }
00981
00982
00983 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00984   Method:   COPageList::CImpIPersistStream::Save
00985
00986   Summary:  Called to save the persistent data of this COM object to a
00987             stream using the specified IStream interface. This call stores
00988             data from the current seek pointer offset. On exit from this
00989             method the seek pointer is assumed to be at the end of the
00990             data saved. This allows a series of contiguous persistent
00991             objects to be saved into the same stream. Notifies all other
00992             connected clients when the save is complete.
00993
00994   Args:     IStream* pIStream
00995               IStream interface pointer for stream to load from.
00996             BOOL bClearDirty
00997               Determines if this method should clear the COM object's
00998               dirty flag. If bClearDirty is TRUE then clear the dirty
00999               flag.
01000
01001   Returns:  HRESULT
01002               Standard result code. NOERROR for success.
01003 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01004 STDMETHODIMP COPageList::CImpIPersistStream::Save(
01005                IStream* pIStream,
01006                BOOL bClearDirty)
01007 {
01008   HRESULT hr = E_POINTER;
01009   ULONG ulToWrite, ulWritten;
01010
01011   if (NULL != pIStream)
01012   {
01013     // Got a stream. Now write data into it.
01014     // First write PAGELISTPROPS structure.
01015     m_pCO->m_PageListProps.lPageListSize = m_pCO->m_lPageListEnd + 1;
01016     ulToWrite = sizeof(PAGELISTPROPS);
01017     hr = pIStream->Write(&m_pCO->m_PageListProps, ulToWrite, &ulWritten);
01018     if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01019       hr = STG_E_CANTSAVE;
01020     if (SUCCEEDED(hr))
01021     {
01022       // Now write the complete array of Page List Data.
01023       ulToWrite = m_pCO->m_PageListProps.lPageListSize * sizeof(PAGEITEM);
01024       hr = pIStream->Write(m_pCO->m_paPageList, ulToWrite, &ulWritten);
01025       if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01026         hr = STG_E_CANTSAVE;
01027       if (SUCCEEDED(hr))
01028       {
01029         // Clear this COM object's dirty flag if instructed. Otherwise,
01030         // preserve its content.
01031         if (bClearDirty)
01032           m_pCO->m_bDirty = FALSE;
01033       }
01034     }
01035   }
01036
01037   // Notify all other connected clients that PageList is now saved.
01038   if (SUCCEEDED(hr))
01039     m_pCO->NotifySinks(PAGELIST_EVENT_SAVED,-1);
01040
01041   return hr;
01042 }
01043
01044
01045 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01046   Method:   COPageList::CImpIPersistStream::GetSizeMax
01047
01048   Summary:  Called to obtain the maximum size of the chunk of data that
01049             could be saved when Save is next called.
01050
01051   Args:     ULARGE_INTEGER* pcbSize
01052               Address of the caller's ULARGE_INTEGER variable to receive
01053               the data size that Save would next write into the stream.
01054
01055   Returns:  HRESULT
01056               Standard result code. NOERROR for success.
01057 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01058 STDMETHODIMP COPageList::CImpIPersistStream::GetSizeMax(
01059                ULARGE_INTEGER* pcbSize)
01060 {
01061   HRESULT hr = E_POINTER;
01062   DWORD dwProps, dwData;
01063
01064   if (NULL != pcbSize)
01065   {
01066     dwProps = sizeof(PAGELISTPROPS);
01067     dwData = (m_pCO->m_lPageListEnd+1) * sizeof(PAGEITEM);
01068     ULISet32(*pcbSize, dwProps+dwData);
01069     hr = NOERROR;
01070   }
01071
01072   return hr;
01073 }
01074
01075
01076 /*---------------------------------------------------------------------------
01077   COPageList's nested implementation of the custom IPageList interface
01078   including Constructor, Destructor, QueryInterface, AddRef, Release,
01079   Get, Set, Add, Delete, and Clear.
01080 ---------------------------------------------------------------------------*/
01081
01082 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01083   Method:   COPageList::CImpIPageList::CImpIPageList
01084
01085   Summary:  Constructor for the CImpIPageList interface instantiation.
01086
01087   Args:     COPageList* pCO,
01088               Back pointer to the parent outer object.
01089             IUnknown* pUnkOuter
01090               Pointer to the outer Unknown.  For delegation.
01091
01092   Modifies: m_pCO, m_pUnkOuter.
01093
01094   Returns:  void
01095 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01096 COPageList::CImpIPageList::CImpIPageList(
01097   COPageList* pCO,
01098   IUnknown* pUnkOuter)
01099 {
01100   // Init the Main Object Pointer to point to the parent object.
01101   m_pCO = pCO;
01102
01103   // Init the CImpIPageList interface's delegating Unknown pointer.  We
01104   // use the Main Object pointer for IUnknown delegation here if we are
01105   // not being aggregated.  If we are being aggregated we use the supplied
01106   // pUnkOuter for IUnknown delegation.  In either case the pointer
01107   // assignment requires no AddRef because the CImpIPageList lifetime is
01108   // quaranteed by the lifetime of the parent object in which
01109   // CImpIPageList is nested.
01110   if (NULL == pUnkOuter)
01111     m_pUnkOuter = pCO;
01112   else
01113     m_pUnkOuter = pUnkOuter;
01114
01115   return;
01116 }
01117
01118
01119 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01120   Method:   COPageList::CImpIPageList::~CImpIPageList
01121
01122   Summary:  Destructor for the CImpIPageList interface instantiation.
01123
01124   Args:     void
01125
01126   Returns:  void
01127 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01128 COPageList::CImpIPageList::~CImpIPageList(void)
01129 {
01130
01131   return;
01132 }
01133
01134
01135 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01136   Method:   COPageList::CImpIPageList::QueryInterface
01137
01138   Summary:  The QueryInterface IUnknown member of this IPageList interface
01139             implementation that delegates to m_pUnkOuter, whatever it is.
01140
01141   Args:     REFIID riid,
01142               [in] GUID of the Interface being requested.
01143             PPVOID ppv)
01144               [out] Address of the caller's pointer variable that will
01145               receive the requested interface pointer.
01146
01147   Returns:  HRESULT
01148               Standard result code. NOERROR for success.
01149               Returned by the delegated outer QueryInterface call.
01150 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01151 STDMETHODIMP COPageList::CImpIPageList::QueryInterface(
01152                REFIID riid,
01153                PPVOID ppv)
01154 {
01155   // Delegate this call to the outer object's QueryInterface.
01156   return m_pUnkOuter->QueryInterface(riid, ppv);
01157 }
01158
01159
01160 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01161   Method:   COPageList::CImpIPageList::AddRef
01162
01163   Summary:  The AddRef IUnknown member of this IPageList interface
01164             implementation that delegates to m_pUnkOuter, whatever it is.
01165
01166   Args:     void
01167
01168   Returns:  ULONG
01169               Returned by the delegated outer AddRef call.
01170 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01171 STDMETHODIMP_(ULONG) COPageList::CImpIPageList::AddRef(void)
01172 {
01173   // Delegate this call to the outer object's AddRef.
01174   return m_pUnkOuter->AddRef();
01175 }
01176
01177
01178 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01179   Method:   COPageList::CImpIPageList::Release
01180
01181   Summary:  The Release IUnknown member of this IPageList interface
01182             implementation that delegates to m_pUnkOuter, whatever it is.
01183
01184   Args:     void
01185
01186   Returns:  ULONG
01187               Returned by the delegated outer Release call.
01188 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01189 STDMETHODIMP_(ULONG) COPageList::CImpIPageList::Release(void)
01190 {
01191   // Delegate this call to the outer object's Release.
01192   return m_pUnkOuter->Release();
01193 }
01194
01195
01196 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01197   Method:   COPageList::CImpIPageList::FindSlot
01198
01199   Summary:  An internal private utility member method to find the PageList
01200             array slot index of a specified page sequence number.
01201
01202   Args:     INT iPage
01203               Requested Page number of the item to find.
01204             LONG* plSlot
01205               Address of variable to receive slot index of found page.
01206
01207   Returns:  HRESULT
01208               Standard result code. NOERROR for success.
01209 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01210 HRESULT COPageList::CImpIPageList::FindSlot(
01211           INT iPage,
01212           LONG* plSlot)
01213 {
01214   HRESULT hr = E_FAIL;
01215   LONG i;
01216
01217   // Loop thru the current PageList array and find the requested
01218   // page number.
01219   for (i=0; i<=m_pCO->m_lPageListEnd; i++)
01220   {
01221     if (PAGETYPE_NONE != m_pCO->m_paPageList[i].nType &&
01222         iPage == m_pCO->m_paPageList[i].iPage)
01223     {
01224       *plSlot = i;
01225       hr = NOERROR;
01226       break;
01227     }
01228   }
01229
01230   return hr;
01231 }
01232
01233
01234 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01235   Method:   COPageList::CImpIPageList::NextSlot
01236
01237   Summary:  An internal private utility member method to obtain the next
01238             slot in the dynamic PageList array. If the requested page
01239             number lies within the existing ordered sequence, it is
01240             inserted before the current item of the same page number. If
01241             the requested page number is < 0 then the new item is assumed
01242             to be a new last page number. This method pre-assigns the
01243             expected page number of the item. NextSlot will expand the
01244             dynamic array for more entries if needed.
01245
01246   Args:     INT iPage
01247               Requested Page order number of the new addition. If this
01248               page number is < 0 then add new item to end of list.
01249             LONG* plSlot
01250               Address of slot variable to receive index of new slot.
01251
01252   Modifies: m_lPageListEnd, m_lPageListMax, m_paPageList.
01253
01254   Returns:  HRESULT
01255               Standard result code. NOERROR for success.
01256 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01257 HRESULT COPageList::CImpIPageList::NextSlot(
01258           INT iPage,
01259           LONG* plSlot)
01260 {
01261   HRESULT hr = E_FAIL;
01262   PAGEITEM* paPgList;
01263   LONG i, lNewEnd = m_pCO->m_lPageListEnd;
01264   LONG lSlot = 0;
01265   SHORT nLastPage;
01266
01267   // Loop thru the current PageList array and find first empty slot.
01268   for (i=0; i<=lNewEnd; i++)
01269   {
01270     if (PAGETYPE_NONE == m_pCO->m_paPageList[i].nType)
01271     {
01272       // Assign new slot number as first empty slot found.
01273       lSlot = i;
01274       hr = NOERROR;
01275       break;
01276     }
01277   }
01278
01279   if (FAILED(hr))
01280   {
01281     hr = NOERROR;
01282     lNewEnd++;
01283
01284     // No empty slots so expand the array.
01285     if (lNewEnd >= m_pCO->m_lPageListMax)
01286     {
01287       // No more room in PageList array. Allocate new array space.
01288       paPgList = new PAGEITEM[(LONG)(m_pCO->m_lPageListMax+PAGELIST_ALLOC)];
01289       if (NULL != paPgList)
01290       {
01291         // Copy the content of the old full array to the new larger array.
01292         memcpy(paPgList, m_pCO->m_paPageList, lNewEnd * sizeof(PAGEITEM));
01293
01294         // Zero (& mark as empty) the expanded portion of the new array.
01295         memset(
01296           &(paPgList[lNewEnd]),
01297           0,
01298           PAGELIST_ALLOC * sizeof(PAGEITEM));
01299
01300         // New larger array is ready--delete the old array.
01301         if (NULL != m_pCO->m_paPageList)
01302           delete [] m_pCO->m_paPageList;
01303
01304         // Rig the PageList to use the new larger array.
01305         m_pCO->m_paPageList = paPgList;
01306
01307         // Calculate the new max index.
01308         m_pCO->m_lPageListMax += PAGELIST_ALLOC;
01309       }
01310       else
01311         hr = E_OUTOFMEMORY;
01312     }
01313
01314     if (SUCCEEDED(hr))
01315     {
01316       // Assign new List End.
01317       m_pCO->m_lPageListEnd = lNewEnd;
01318
01319       // Assign new slot number as last item of new item list.
01320       lSlot = lNewEnd;
01321     }
01322   }
01323
01324   if (SUCCEEDED(hr))
01325   {
01326     if (iPage < 0)
01327     {
01328       nLastPage = -1;
01329
01330       // Find the last page number.
01331       for (i=0; i<=lNewEnd; i++)
01332       {
01333         if (PAGETYPE_NONE != m_pCO->m_paPageList[i].nType
01334             && m_pCO->m_paPageList[i].iPage > nLastPage)
01335           nLastPage = m_pCO->m_paPageList[i].iPage;
01336       }
01337
01338       // Assign the Page Number of the new last entry.
01339       m_pCO->m_paPageList[lSlot].iPage = nLastPage + 1;
01340     }
01341     else
01342     {
01343       // Renumber the existing page items to make room for the new one.
01344       for (i=0; i<=lNewEnd; i++)
01345       {
01346         if (PAGETYPE_NONE != m_pCO->m_paPageList[i].nType
01347             && iPage >= m_pCO->m_paPageList[i].iPage)
01348           m_pCO->m_paPageList[i].iPage += 1;
01349       }
01350
01351       // Assign the Page Number.
01352       m_pCO->m_paPageList[lSlot].iPage = iPage;
01353     }
01354
01355     // Assign the output slot number.
01356     *plSlot = lSlot;
01357   }
01358
01359   return hr;
01360 }
01361
01362
01363 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01364   Method:   COPageList::CImpIPageList::NextName
01365
01366   Summary:  An internal private utility member method to generate the next
01367             internal name for the storage or stream that will be used to
01368             store pages.
01369
01370   Args:     SHORT nType,
01371               Page Type of the new page.
01372             WCHAR* pwszName
01373               Pointer to the wide char string to receive the new name.
01374
01375   Returns:  HRESULT
01376               Standard result code. NOERROR for success.
01377 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01378 HRESULT COPageList::CImpIPageList::NextName(
01379           SHORT nType,
01380           WCHAR* pwszName)
01381 {
01382   HRESULT hr = E_POINTER;
01383   TCHAR szName[PAGE_NAME_SIZE];
01384   TCHAR szNameCount[PAGE_NAME_SIZE];
01385
01386   if (NULL != pwszName)
01387   {
01388     hr = NOERROR;
01389
01390     // Assign the page type string.
01391     switch (nType)
01392     {
01393       case PAGETYPE_DRAWING:
01394         lstrcpyn(szName, TEXT(DRAWING_STR), sizeof(szName)/sizeof(TCHAR));
01395         break;
01396       case PAGETYPE_TEXT:
01397         lstrcpyn(szName, TEXT(TEXT_STR), sizeof(szName)/sizeof(TCHAR));
01398         break;
01399       default:
01400         hr = E_FAIL;
01401         break;
01402     }
01403
01404     if (SUCCEEDED(hr))
01405     {
01406       // Calculate the next name count and make a name string.
01407
01408       // Bump the page name counter.
01409       m_pCO->m_PageListProps.lPageNameCounter += 1;
01410
01411       // This change means we should mark the PageList as dirty.
01412       // A save to file of the PageList object is now needed.
01413       m_pCO->m_bDirty = TRUE;
01414
01415 #ifdef UNICODE
01416       _ltow(m_pCO->m_PageListProps.lPageNameCounter, szNameCount, 10);
01417       lstrncat(szName, szNameCount, sizeof(szName)/sizeof(TCHAR) -
01418         lstrlen(szName));
01419       lstrcpyn(pwszName, szName, sizeof(pwszName)/sizeof(TCHAR));
01420 #else
01421       _ltoa(m_pCO->m_PageListProps.lPageNameCounter, szNameCount, 10);
01422       lstrncat(szName, szNameCount, sizeof(szName)/sizeof(TCHAR) -
01423         lstrlen(szName));
01424       // Convert to WideChar if we are NOT compiled for Unicode.
01425       AnsiToUc(szName, pwszName, PAGE_NAME_SIZE);
01426 #endif
01427     }
01428   }
01429
01430   return hr;
01431 }
01432
01433
01434 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01435   Method:   COPageList::CImpIPageList::Get
01436
01437   Summary:  Get a Page List Item for a given page number. Get back
01438             open status, page type, page title, and page data name.
01439
01440   Args:     INT iPage,
01441               Page sequence number of the item to get (0-based).
01442             BOOL* pbOpen,
01443               Address of a boolean variable to receive the page open status.
01444               If NULL then don't get this value.
01445             SHORT* pnType,
01446               Address of a PageType variable to receive the page type.
01447               If NULL then don't get this value.
01448             WCHAR* pwszTitle,
01449               Address of a wide character string to receive the page title.
01450               If NULL then don't get this value.
01451             WCHAR* pwszDataName)
01452               Address of a wide character string to receive the data name.
01453               If NULL then don't get this value.
01454
01455   Returns:  HRESULT
01456               Standard result code. NOERROR for success.
01457 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01458 STDMETHODIMP COPageList::CImpIPageList::Get(
01459                INT     iPage,
01460                BOOL*   pbOpen,
01461                SHORT*  pnType,
01462                WCHAR*  pwszTitle,
01463                WCHAR*  pwszDataName)
01464 {
01465   HRESULT hr = E_POINTER;
01466   LONG lSlot;
01467
01468   hr = FindSlot(iPage, &lSlot);
01469   if (SUCCEEDED(hr))
01470   {
01471     // Assign the caller's open status variable.
01472     if (NULL != pbOpen)
01473       *pbOpen = m_pCO->m_paPageList[lSlot].bOpen;
01474
01475     // Assign the caller's page type variable.
01476     if (NULL != pnType)
01477       *pnType = m_pCO->m_paPageList[lSlot].nType;
01478
01479     // Copy the page title to the caller's variable.
01480     if (NULL != pwszTitle)
01481       memcpy(
01482         pwszTitle,
01483         m_pCO->m_paPageList[lSlot].wszTitle,
01484         PAGE_TITLE_SIZE*sizeof(WCHAR));
01485
01486     // Copy the page data name to the caller's variable.
01487     if (NULL != pwszDataName)
01488       memcpy(
01489         pwszDataName,
01490         m_pCO->m_paPageList[lSlot].wszDataName,
01491         PAGE_NAME_SIZE*sizeof(WCHAR));
01492   }
01493
01494   return hr;
01495 }
01496
01497
01498 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01499   Method:   COPageList::CImpIPageList::Set
01500
01501   Summary:  Set a Page List Item of specified page number with a
01502             new Title and the page's current open status.
01503
01504   Args:     INT iPage
01505               Page sequence number of the item to put (0-based).
01506             SHORT   nOpenStatus,
01507               Status of whether the page is open or not.
01508             WCHAR* pwszNewTitle);
01509               New Title for the page.
01510
01511   Returns:  HRESULT
01512               Standard result code. NOERROR for success.
01513 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01514 STDMETHODIMP COPageList::CImpIPageList::Set(
01515                INT     iPage,
01516                SHORT   nOpenStatus,
01517                WCHAR*  pwszNewTitle)
01518 {
01519   HRESULT hr = E_FAIL;
01520   LONG lSlot;
01521
01522   if (NULL != pwszNewTitle || OPENSTATE_NONE != nOpenStatus)
01523   {
01524     hr = FindSlot(iPage, &lSlot);
01525     if (SUCCEEDED(hr))
01526     {
01527       switch (nOpenStatus)
01528       {
01529         case OPENSTATE_YES:
01530           m_pCO->m_paPageList[lSlot].bOpen = TRUE;
01531           break;
01532         case OPENSTATE_NO:
01533           m_pCO->m_paPageList[lSlot].bOpen = FALSE;
01534           break;
01535         default:
01536           break;
01537       }
01538
01539       if (NULL != pwszNewTitle)
01540       {
01541         // Copy the caller's new title into the specified list item.
01542         memcpy(
01543           m_pCO->m_paPageList[lSlot].wszTitle,
01544           pwszNewTitle,
01545           PAGE_TITLE_SIZE*sizeof(WCHAR));
01546       }
01547
01548       // Mark PageList as dirty. Save to file is needed.
01549       m_pCO->m_bDirty = TRUE;
01550
01551       // Notify all other connected clients that a page list
01552       // item was set/changed.
01553       m_pCO->NotifySinks(PAGELIST_EVENT_PAGESET, iPage);
01554     }
01555   }
01556
01557   return hr;
01558 }
01559
01560
01561 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01562   Method:   COPageList::CImpIPageList::Add
01563
01564   Summary:  Add/Insert a new Page List Item of specified type with
01565             specified title. Inserts before the entry with the
01566             specified page number. If iPage < 0 then add the new item
01567             to the end of the list.
01568
01569   Args:     INT     iPage,
01570               Page sequence number to insert. If < 0 then add to end of
01571               page number sequence and assign *piNewPage with the new
01572               page number.
01573             SHORT   nType,
01574               Page Type of the new page.
01575             WCHAR*  pwszTitle,
01576               Pointer to the wide character string that will be the new
01577               page's title.
01578             INT* piNewPage
01579               Address of integer variable to receive new Page number.
01580
01581   Returns:  HRESULT
01582               Standard result code. NOERROR for success.
01583 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01584 STDMETHODIMP COPageList::CImpIPageList::Add(
01585                INT iPage,
01586                SHORT nType,
01587                WCHAR* pwszTitle,
01588                INT* piNewPage)
01589 {
01590   HRESULT hr = E_POINTER;
01591   LONG lSlot;
01592
01593   if (NULL != pwszTitle && PAGETYPE_NONE != nType)
01594   {
01595     // Find the next slot and assign its page number.
01596     hr = NextSlot(iPage, &lSlot);
01597     if (SUCCEEDED(hr))
01598     {
01599       // Create and assign a new storage/stream name.
01600       hr = NextName(nType, m_pCO->m_paPageList[lSlot].wszDataName);
01601       if (SUCCEEDED(hr))
01602       {
01603         // Copy the caller's new title into the specified page list item.
01604         memcpy(
01605           m_pCO->m_paPageList[lSlot].wszTitle,
01606           pwszTitle,
01607           PAGE_TITLE_SIZE*sizeof(WCHAR));
01608
01609         // Assign the new page type.
01610         m_pCO->m_paPageList[lSlot].nType = nType;
01611
01612         // Inform the caller of the new page number.
01613         *piNewPage = m_pCO->m_paPageList[lSlot].iPage;
01614
01615         // Mark PageList as dirty. Save to file is needed.
01616         m_pCO->m_bDirty = TRUE;
01617
01618         // Notify all other connected clients that a new page list
01619         // item was added.
01620         m_pCO->NotifySinks(
01621                   PAGELIST_EVENT_PAGEADDED,
01622                   m_pCO->m_paPageList[lSlot].iPage);
01623       }
01624     }
01625   }
01626
01627   return hr;
01628 }
01629
01630
01631 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01632   Method:   COPageList::CImpIPageList::Delete
01633
01634   Summary:  Delete a Page List Item for the specified page number.
01635
01636   Args:     INT iPage
01637               Page number of the page item to delete (0-based).
01638
01639   Returns:  HRESULT
01640               Standard result code. NOERROR for success.
01641 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01642 STDMETHODIMP COPageList::CImpIPageList::Delete(
01643                INT iPage)
01644 {
01645   HRESULT hr = E_FAIL;
01646   INT iLastPage = iPage;
01647   INT iPg;
01648   LONG lSlot, i;
01649
01650   hr = FindSlot(iPage, &lSlot);
01651   if (SUCCEEDED(hr))
01652   {
01653     // Mark item as empty.
01654     m_pCO->m_paPageList[lSlot].nType = PAGETYPE_NONE;
01655
01656     // Renumber the remaining pages to account for the missing page.
01657     for (i=0; i<=m_pCO->m_lPageListEnd; i++)
01658     {
01659       iPg = m_pCO->m_paPageList[i].iPage;
01660       if (PAGETYPE_NONE != m_pCO->m_paPageList[i].nType
01661           && iPg >= 0 && iPg > iPage)
01662       {
01663         if (iPg > 0)
01664           iPg--;
01665         m_pCO->m_paPageList[i].iPage = iPg;
01666         if (iPg > iLastPage)
01667           iLastPage = iPg;
01668       }
01669     }
01670
01671     // Mark PageList as dirty.
01672     m_pCO->m_bDirty = TRUE;
01673
01674     // Notify all other connected clients that a page list
01675     // item was deleted.
01676     iPg = (iPage <= iLastPage) ? iPage : iLastPage;
01677     m_pCO->NotifySinks(PAGELIST_EVENT_PAGEDELETED, iPg);
01678   }
01679
01680   return hr;
01681 }
01682
01683
01684 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01685   Method:   COPageList::CImpIPageList::Clear
01686
01687   Summary:  Clears the entire page list. Removes all entries.
01688
01689   Args:     none.
01690
01691   Returns:  HRESULT
01692               Standard result code. NOERROR for success.
01693 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01694 STDMETHODIMP COPageList::CImpIPageList::Clear(
01695                void)
01696 {
01697   HRESULT hr = E_FAIL;
01698
01699   hr = m_pCO->Clear();
01700
01701   // Notify all other connected clients that the list was cleared.
01702   if (SUCCEEDED(hr))
01703     m_pCO->NotifySinks(PAGELIST_EVENT_CLEARED,0);
01704
01705   return hr;
01706 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEnumConnections Member List

This is the complete list of members for CEnumConnections, including all inherited members.
AddRef() | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
CEnumConnections() | CEnumConnections | [private]
CEnumConnections(const CEnumConnections &) | CEnumConnections | [private]
CEnumConnections(LPUNKNOWN lpUnk, DWORD nCount) | CEnumConnections |
CEnumXXX(LPUNKNOWN lpUnk, REFIID iid, DWORD nCount) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [protected]
Clone(IEnumConnections **ppenum) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
Copy(CONNECTDATA *connLeft, CONNECTDATA &connRight) | CEnumConnections |
Create(LPUNKNOWN lpUnk, DWORD nCount, CONNECTDATA *elemlist) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [static]
FinalRelease() | CEnumConnections | [virtual]
Init(CONNECTDATA *elemlist) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [protected, virtual]
m_cELT | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > |
m_cRef | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > |
m_iCur | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > |
m_iid | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > |
m_lpunk | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > |
m_prgELT | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > |
Next(ULONG celt, CONNECTDATA *rgelt, PULONG pceltFetched) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
operator&() | CEnumConnections | [private]
operator&() const | CEnumConnections | [private]
operator=(const CEnumConnections &) | CEnumConnections | [private]
QueryInterface(REFIID iid, PVOID *ppv) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
Release() | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
Reset(void) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
Skip(ULONG celt) | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
~CEnumConnections() | CEnumConnections |
~CEnumXXX() | CEnumXXX< CEnumConnections, CONNECTDATA, IEnumConnections > | [virtual]
Generated on Wed Nov 13 2024 16:56:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Framer/Site.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Framer

Site.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*
00019  * SITE.H
00020  * View Site for Document Objects.
00021  *
00022  */
00023
00024
00025 #ifndef _SITE_H_
00026 #define _SITE_H_
00027
00028
00029 class CImpIOleClientSite : public IOleClientSite
00030     {
00031     protected:
00032         ULONG               m_cRef;
00033         class CSite        *m_pSite;
00034         LPUNKNOWN           m_pUnkOuter;
00035
00036     public:
00037         CImpIOleClientSite(class CSite *, IUnknown *);
00038         ~CImpIOleClientSite(void);
00039
00040         STDMETHODIMP QueryInterface(REFIID, void **);
00041         STDMETHODIMP_(ULONG) AddRef(void);
00042         STDMETHODIMP_(ULONG) Release(void);
00043
00044         STDMETHODIMP SaveObject(void);
00045         STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
00046         STDMETHODIMP GetContainer(LPOLECONTAINER *);
00047         STDMETHODIMP ShowObject(void);
00048         STDMETHODIMP OnShowWindow(BOOL);
00049         STDMETHODIMP RequestNewObjectLayout(void);
00050     };
00051
00052 typedef CImpIOleClientSite *PCImpIOleClientSite;
00053
00054
00055
00056 class CImpIAdviseSink : public IAdviseSink
00057     {
00058     protected:
00059         ULONG               m_cRef;
00060         class CSite        *m_pSite;
00061         LPUNKNOWN           m_pUnkOuter;
00062
00063     public:
00064         CImpIAdviseSink(class CSite *, IUnknown *);
00065         ~CImpIAdviseSink(void);
00066
00067         STDMETHODIMP QueryInterface(REFIID, void **);
00068         STDMETHODIMP_(ULONG) AddRef(void);
00069         STDMETHODIMP_(ULONG) Release(void);
00070
00071         STDMETHODIMP_(void)  OnDataChange(LPFORMATETC, LPSTGMEDIUM);
00072         STDMETHODIMP_(void)  OnViewChange(DWORD, LONG);
00073         STDMETHODIMP_(void)  OnRename(LPMONIKER);
00074         STDMETHODIMP_(void)  OnSave(void);
00075         STDMETHODIMP_(void)  OnClose(void);
00076     };
00077
00078
00079 typedef CImpIAdviseSink *PCImpIAdviseSink;
00080
00081
00082 class CImpIOleInPlaceSite : public IOleInPlaceSite
00083     {
00084     protected:
00085         ULONG               m_cRef;
00086         class CSite        *m_pSite;
00087         LPUNKNOWN           m_pUnkOuter;
00088
00089     public:
00090         CImpIOleInPlaceSite(class CSite *, IUnknown *);
00091         ~CImpIOleInPlaceSite(void);
00092
00093         STDMETHODIMP QueryInterface(REFIID, void **);
00094         STDMETHODIMP_(ULONG) AddRef(void);
00095         STDMETHODIMP_(ULONG) Release(void);
00096
00097         STDMETHODIMP GetWindow(HWND *);
00098         STDMETHODIMP ContextSensitiveHelp(BOOL);
00099         STDMETHODIMP CanInPlaceActivate(void);
00100         STDMETHODIMP OnInPlaceActivate(void);
00101         STDMETHODIMP OnUIActivate(void);
00102         STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME *
00103                         , LPOLEINPLACEUIWINDOW *, LPRECT, LPRECT
00104                         , LPOLEINPLACEFRAMEINFO);
00105         STDMETHODIMP Scroll(SIZE);
00106         STDMETHODIMP OnUIDeactivate(BOOL);
00107         STDMETHODIMP OnInPlaceDeactivate(void);
00108         STDMETHODIMP DiscardUndoState(void);
00109         STDMETHODIMP DeactivateAndUndo(void);
00110         STDMETHODIMP OnPosRectChange(LPCRECT);
00111     };
00112
00113 typedef CImpIOleInPlaceSite *PCImpIOleInPlaceSite;
00114
00115
00116 class CImpIOleDocumentSite : public IOleDocumentSite
00117     {
00118     protected:
00119         ULONG               m_cRef;
00120         class CSite        *m_pSite;
00121         LPUNKNOWN           m_pUnkOuter;
00122
00123     public:
00124         CImpIOleDocumentSite(class CSite *, IUnknown *);
00125         ~CImpIOleDocumentSite(void);
00126
00127         STDMETHODIMP QueryInterface(REFIID, void **);
00128         STDMETHODIMP_(ULONG) AddRef(void);
00129         STDMETHODIMP_(ULONG) Release(void);
00130
00131         STDMETHODIMP ActivateMe(IOleDocumentView *);
00132     };
00133
00134 typedef CImpIOleDocumentSite *PCImpIOleDocumentSite;
00135
00136
00137
00138 /*
00139  * The CSite class, a COM object with the interfaces IOleClientSite,
00140  * IAdviseSink, IOleInPlaceSite, and IOleDocumentSite.
00141  */
00142
00143
00144 class CSite : public IUnknown
00145     {
00146     friend CImpIOleClientSite;
00147     friend CImpIAdviseSink;
00148     friend CImpIOleInPlaceSite;
00149     friend CImpIOleDocumentSite;
00150
00151     private:
00152         ULONG           m_cRef;
00153         DWORD           m_dwID;
00154         HWND            m_hWnd; //Client area window of parent
00155
00156         class CFrame   *m_pFR;
00157
00158         BOOL            m_fInitialized; //Something here?
00159         LPSTORAGE       m_pIStorage;    //Storage for object
00160     LPSTREAM    m_pIStream;   //Info stream for object
00161
00162         //Object interfaces
00163         IUnknown          *m_pObj;
00164         IOleObject        *m_pIOleObject;
00165         IOleInPlaceObject *m_pIOleIPObject;
00166         IOleDocumentView  *m_pIOleDocView;
00167
00168         BOOL               m_fDocObj;   //Document object here?
00169
00170         //Our interfaces
00171         PCImpIOleClientSite   m_pImpIOleClientSite;
00172         PCImpIAdviseSink      m_pImpIAdviseSink;
00173         PCImpIOleInPlaceSite  m_pImpIOleIPSite;
00174         PCImpIOleDocumentSite m_pImpIOleDocumentSite;
00175
00176
00177     protected:
00178         BOOL    ObjectInitialize(LPUNKNOWN);
00179
00180     public:
00181         CSite(DWORD, HWND, CFrame *);
00182         ~CSite(void);
00183
00184         //Gotta have an IUnknown for delegation
00185         STDMETHODIMP QueryInterface(REFIID, void **);
00186         STDMETHODIMP_(ULONG) AddRef(void);
00187         STDMETHODIMP_(ULONG) Release(void);
00188
00189         BOOL        Create(LPTSTR, IStorage *);
00190         BOOL        CreateStorage(IStorage *);
00191         void        Close(BOOL);
00192         void        Update(void);
00193         void        Destroy(IStorage *);
00194         void        Activate(LONG);
00195         void        UpdateObjectRects(void);
00196     };
00197
00198
00199 typedef CSite *PCSite;
00200
00201 #endif //_SITE_H_
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Instance_Provider/Main.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Instance_Provider

Main.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Main.cpp
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #include <precomp.h>
00017 #include <objbase.h>
00018 #include <stdio.h>
00019 #include <tchar.h>
00020 #include <wbemcli.h>
00021 #include <wbemprov.h>
00022 #include "Globals.h"
00023 #include "Service.h"
00024
00025 /******************************************************************************
00026  *
00027  *  Name: WindowsMainProc
00028  *
00029  *
00030  *  Description:
00031  *
00032  *      Spin processing windows messages
00033  *
00034  *****************************************************************************/
00035
00036 LRESULT CALLBACK WindowsMainProc ( HWND a_hWnd , UINT a_message , WPARAM a_wParam , LPARAM a_lParam )
00037 {
00038   LRESULT t_rc = 0 ;
00039
00040   switch ( a_message )
00041   {
00042     case WM_DESTROY:
00043     {
00044       PostMessage ( a_hWnd , WM_QUIT , 0 , 0 ) ;
00045     }
00046     break ;
00047
00048     default:
00049     {
00050       t_rc = DefWindowProc ( a_hWnd , a_message , a_wParam , a_lParam ) ;
00051     }
00052     break ;
00053   }
00054
00055   return ( t_rc ) ;
00056 }
00057
00058 /******************************************************************************
00059  *
00060  *  Name: WindowsInit
00061  *
00062  *
00063  *  Description:
00064  *
00065  *      Initialize a window so that we can close the app down.
00066  *
00067  *****************************************************************************/
00068
00069 HWND WindowsInit ( HINSTANCE a_HInstance )
00070 {
00071   static wchar_t *t_TemplateCode = L"TemplateCode" ;
00072
00073   WNDCLASS  t_wc ;
00074
00075   t_wc.style            = CS_HREDRAW | CS_VREDRAW ;
00076   t_wc.lpfnWndProc      = WindowsMainProc ;
00077   t_wc.cbClsExtra       = 0 ;
00078   t_wc.cbWndExtra       = 0 ;
00079   t_wc.hInstance        = a_HInstance ;
00080   t_wc.hIcon            = LoadIcon(NULL, IDI_HAND) ;
00081   t_wc.hCursor          = LoadCursor(NULL, IDC_ARROW) ;
00082   t_wc.hbrBackground    = (HBRUSH) (COLOR_WINDOW + 1) ;
00083   t_wc.lpszMenuName     = NULL ;
00084   t_wc.lpszClassName    = t_TemplateCode ;
00085
00086   ATOM t_winClass = RegisterClass ( &t_wc ) ;
00087
00088   HWND t_HWnd = CreateWindow (
00089
00090     t_TemplateCode ,              // see RegisterClass() call
00091     t_TemplateCode ,                      // text for window title bar
00092     WS_OVERLAPPEDWINDOW | WS_MINIMIZE ,               // window style
00093     CW_USEDEFAULT ,                     // default horizontal position
00094     CW_USEDEFAULT ,                     // default vertical position
00095     CW_USEDEFAULT ,                     // default width
00096     CW_USEDEFAULT ,                     // default height
00097     NULL ,                              // overlapped windows have no parent
00098     NULL ,                              // use the window class menu
00099     a_HInstance ,
00100     NULL                                // pointer not needed
00101   ) ;
00102
00103   ShowWindow ( t_HWnd, SW_SHOW ) ;
00104   //ShowWindow ( t_HWnd, SW_HIDE ) ;
00105
00106   return t_HWnd ;
00107 }
00108
00109 /******************************************************************************
00110  *
00111  *  Name: WindowsStop
00112  *
00113  *
00114  *  Description:
00115  *
00116  *      Cleanup window
00117  *
00118  *****************************************************************************/
00119
00120 void WindowsStop ( HWND a_HWnd )
00121 {
00122   DestroyWindow ( a_HWnd ) ;
00123 }
00124
00125 /******************************************************************************
00126  *
00127  *  Name: WindowsStart
00128  *
00129  *
00130  *  Description:
00131  *
00132  *      Initialize windows dependant resources.
00133  *
00134  *****************************************************************************/
00135
00136 HWND WindowsStart ( HINSTANCE a_Handle )
00137 {
00138   HWND t_HWnd = NULL ;
00139   if ( ! ( t_HWnd = WindowsInit ( a_Handle ) ) )
00140   {
00141     }
00142
00143   return t_HWnd ;
00144 }
00145
00146 /******************************************************************************
00147  *
00148  *  Name: WindowsDispatch
00149  *
00150  *
00151  *  Description:
00152  *
00153  *      Standard message pump.
00154  *
00155  *****************************************************************************/
00156
00157 void WindowsDispatch ()
00158 {
00159   BOOL t_GetMessage ;
00160   MSG t_lpMsg ;
00161
00162   while ( ( t_GetMessage = GetMessage ( & t_lpMsg , NULL , 0 , 0 ) ) == TRUE )
00163   {
00164     TranslateMessage ( & t_lpMsg ) ;
00165     DispatchMessage ( & t_lpMsg ) ;
00166   }
00167 }
00168
00169 /******************************************************************************
00170  *
00171  *  Name: UninitComServer
00172  *
00173  *
00174  *  Description:
00175  *
00176  *      Uninitialize COM dependant resources,
00177  *
00178  *****************************************************************************/
00179
00180 HRESULT UninitComServer ()
00181 {
00182   CoUninitialize () ;
00183
00184   return S_OK ;
00185 }
00186
00187 /******************************************************************************
00188  *
00189  *  Name: InitComServer
00190  *
00191  *
00192  *  Description:
00193  *
00194  *      Initialize COM dependant resources.
00195  *
00196  *****************************************************************************/
00197
00198 HRESULT InitComServer ( DWORD a_AuthenticationLevel , DWORD a_ImpersonationLevel )
00199 {
00200   HRESULT t_Result = S_OK ;
00201
00202     t_Result = CoInitializeEx (
00203
00204     0,
00205     COINIT_MULTITHREADED
00206   );
00207
00208 #ifndef EOAC_DYNAMIC_CLOAKING
00209 #define EOAC_DYNAMIC_CLOAKING 0x40
00210 #endif
00211
00212   if ( SUCCEEDED ( t_Result ) )
00213   {
00214     t_Result = CoInitializeSecurity (
00215
00216       NULL,
00217       -1,
00218       NULL,
00219       NULL,
00220       a_AuthenticationLevel,
00221       a_ImpersonationLevel,
00222       NULL,
00223       EOAC_DYNAMIC_CLOAKING,
00224       0
00225     );
00226
00227     if ( FAILED ( t_Result ) )
00228     {
00229       CoUninitialize () ;
00230       return t_Result ;
00231     }
00232   }
00233
00234   if ( FAILED ( t_Result ) )
00235   {
00236     CoUninitialize () ;
00237   }
00238
00239   return t_Result  ;
00240 }
00241
00242 /******************************************************************************
00243  *
00244  *  Name: RegisterDecoupledInstance
00245  *
00246  *
00247  *  Description:
00248  *
00249  *      Register a decoupled instance provider object with WMI.
00250  *      We pass in an implementation of IWbemServices so
00251  *      that WMI can instance retrieval requests.
00252  *
00253  *****************************************************************************/
00254
00255 HRESULT RegisterDecoupledInstance (
00256
00257   IWbemDecoupledRegistrar *&a_Registrar
00258 )
00259 {
00260 /*
00261  *  Cleanup out arguments
00262  */
00263
00264   a_Registrar = NULL ;
00265
00266 /*
00267  *  Create the registrar for the instance provider, so that we can register with WMI.
00268  */
00269
00270   HRESULT t_Result = Provider_Globals :: CreateInstance (
00271
00272     CLSID_WbemDecoupledRegistrar ,
00273     NULL ,
00274     CLSCTX_INPROC_SERVER ,
00275     IID_IWbemDecoupledRegistrar ,
00276     ( void ** ) & a_Registrar
00277   ) ;
00278
00279   if ( SUCCEEDED ( t_Result ) )
00280   {
00281 /*
00282  *  Create our implementation instance of the instance provider
00283  */
00284
00285     CProvider_IWbemServices *t_Service = new CProvider_IWbemServices () ;
00286     if ( t_Service )
00287     {
00288       t_Service->AddRef () ;
00289
00290       IUnknown *t_Unknown = NULL ;
00291       t_Result = t_Service->QueryInterface ( IID_IUnknown , ( void ** ) & t_Unknown ) ;
00292       if ( SUCCEEDED ( t_Result ) )
00293       {
00294 /*
00295  *  Register the provider inteface with WMI, specifying the namespace and provider instance of __Win32provider
00296  */
00297
00298         t_Result = a_Registrar->Register (
00299
00300           0 ,
00301           NULL ,
00302           NULL ,
00303           NULL ,
00304           L"root\\cimv2" ,
00305           L"DecoupledInstanceProvider" ,
00306           t_Unknown
00307         ) ;
00308
00309         t_Unknown->Release () ;
00310       }
00311
00312       t_Service->Release () ;
00313     }
00314   }
00315
00316   if ( FAILED ( t_Result ) )
00317   {
00318     if ( a_Registrar )
00319     {
00320       a_Registrar->Release () ;
00321       a_Registrar = NULL ;
00322     }
00323   }
00324
00325   return t_Result ;
00326 }
00327
00328 /******************************************************************************
00329  *
00330  *  Name:   Process_DecoupledInstance
00331  *
00332  *
00333  *  Description:
00334  *
00335  *        Register the provider and just sit spinning until the
00336  *        application window is destroyed.
00337  *
00338  *****************************************************************************/
00339
00340 HRESULT Process_DecoupledInstance ()
00341 {
00342   IWbemDecoupledRegistrar *t_InstanceRegistrar = NULL ;
00343
00344   HRESULT t_Result = RegisterDecoupledInstance ( t_InstanceRegistrar ) ;
00345   if ( SUCCEEDED ( t_Result ) )
00346   {
00347     WindowsDispatch () ;
00348   }
00349
00350   if ( t_InstanceRegistrar )
00351   {
00352     t_InstanceRegistrar->UnRegister () ;
00353     t_InstanceRegistrar->Release () ;
00354   }
00355
00356   return t_Result ;
00357 }
00358
00359 /******************************************************************************
00360  *
00361  *  Name: Process
00362  *
00363  *
00364  *  Description:
00365  *
00366  *      Main work routine, initialize com components and performs
00367  *      event consumer dispatch loop.
00368  *
00369  *****************************************************************************/
00370
00371 HRESULT Process ()
00372 {
00373   DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
00374   DWORD t_AuthenticationLevel = RPC_C_AUTHN_LEVEL_CONNECT ;
00375
00376   HRESULT t_Result = InitComServer ( t_AuthenticationLevel , t_ImpersonationLevel ) ;
00377   if ( SUCCEEDED ( t_Result ) )
00378   {
00379     try
00380     {
00381       t_Result = Process_DecoupledInstance () ;
00382     }
00383     catch ( ... )
00384     {
00385     }
00386
00387     UninitComServer () ;
00388   }
00389
00390   return t_Result ;
00391 }
00392
00393 /******************************************************************************
00394  *
00395  *  Name: Main
00396  *
00397  *
00398  *  Description:
00399  *
00400  *    Main entry point, initialize global resources, windows components and then
00401  *    perform provider work.
00402  *
00403  *****************************************************************************/
00404
00405 int WINAPI WinMain (
00406
00407     HINSTANCE hInstance,    // handle to current instance
00408     HINSTANCE hPrevInstance,  // handle to previous instance
00409     LPSTR lpCmdLine,      // pointer to command line
00410     int nShowCmd        // show state of window
00411 )
00412 {
00413   HRESULT t_Result = Provider_Globals :: Global_Startup () ;
00414   if ( SUCCEEDED ( t_Result ) )
00415   {
00416     HWND t_Window = WindowsStart ( hInstance ) ;
00417     if ( t_Window )
00418     {
00419       t_Result = Process () ;
00420
00421       WindowsStop ( t_Window ) ;
00422     }
00423
00424     t_Result = Provider_Globals :: Global_Shutdown () ;
00425   }
00426
00427   return 0 ;
00428 }
00429
00430
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/DComPerm/AclMgmt.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • DComPerm

AclMgmt.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <stdio.h>
00020 #include <conio.h>
00021 #include <tchar.h>
00022 #include "ntsecapi.h"
00023 #include "dcomperm.h"
00024
00025
00026 /*---------------------------------------------------------------------------*\
00027  * NAME: CopyACL                                                             *
00028  * --------------------------------------------------------------------------*
00029  * DESCRIPTION:
00030  *
00031 \*---------------------------------------------------------------------------*/
00032 DWORD CopyACL (
00033     PACL paclOld,
00034     PACL paclNew
00035     )
00036 {
00037     ACL_SIZE_INFORMATION  aclSizeInfo = {0};
00038     LPVOID                pvAce       = NULL;
00039     ACE_HEADER            *pAceHeader = NULL;
00040     ULONG                 i;
00041
00042
00043
00044     if(!GetAclInformation (paclOld,
00045                            (LPVOID) &aclSizeInfo,
00046                            (DWORD) sizeof (aclSizeInfo),
00047                            AclSizeInformation))
00048     {
00049         return GetLastError();
00050     }
00051
00052     // Copy all of the ACEs to the new ACL
00053     for (i = 0; i < aclSizeInfo.AceCount; i++)
00054     {
00055         // Get the ACE and header info
00056         if (!GetAce (paclOld, i, &pvAce))
00057             return GetLastError();
00058
00059         pAceHeader = (ACE_HEADER *) pvAce;
00060
00061         // Add the ACE to the new list
00062         if (!AddAce (paclNew, ACL_REVISION, 0xffffffff, pvAce, pAceHeader->AceSize))
00063             return GetLastError();
00064     }
00065
00066     return ERROR_SUCCESS;
00067 }
00068
00069
00070 /*---------------------------------------------------------------------------*\
00071  * NAME: AddAccessDeniedACEToACL                                             *
00072  * --------------------------------------------------------------------------*
00073  * DESCRIPTION: Adds an Access Denied ACE with the designate access mask to
00074  * the supplied ACL.
00075 \*---------------------------------------------------------------------------*/
00076 DWORD AddAccessDeniedACEToACL (
00077     PACL *paclOrig,
00078     DWORD dwAccessMask,
00079     LPTSTR tszPrincipal
00080     )
00081 {
00082     ACL_SIZE_INFORMATION  aclSizeInfo   = {0};
00083     int                   cbAclSize     = 0;
00084     DWORD                 dwReturnValue = ERROR_SUCCESS;
00085     PSID                  psidPrincipal = NULL;
00086     PACL                  paclOld       = NULL;
00087     PACL                  paclNew       = NULL;
00088
00089     if(!paclOrig) return ERROR_BAD_ARGUMENTS;
00090
00091     paclOld = *paclOrig;
00092
00093     dwReturnValue = GetPrincipalSID (tszPrincipal, &psidPrincipal);
00094     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00095
00096     if(!GetAclInformation (paclOld,
00097                            (LPVOID) &aclSizeInfo,
00098                            (DWORD) sizeof (ACL_SIZE_INFORMATION),
00099                            AclSizeInformation))
00100     {
00101         dwReturnValue = GetLastError();
00102         goto CLEANUP;
00103     }
00104
00105     cbAclSize = aclSizeInfo.AclBytesInUse +
00106               sizeof (ACL) + sizeof (ACCESS_DENIED_ACE) +
00107               GetLengthSid (psidPrincipal) - sizeof (DWORD);
00108
00109     paclNew = (PACL) malloc(cbAclSize);
00110     if(!paclNew)
00111     {
00112         dwReturnValue = ERROR_OUTOFMEMORY;
00113         goto CLEANUP;
00114     }
00115
00116     if (!InitializeAcl (paclNew, cbAclSize, ACL_REVISION))
00117     {
00118         dwReturnValue = GetLastError();
00119         goto CLEANUP;
00120     }
00121
00122     if (!AddAccessDeniedAce (paclNew,
00123                              ACL_REVISION2,
00124                              dwAccessMask,
00125                              psidPrincipal))
00126     {
00127         dwReturnValue = GetLastError();
00128         goto CLEANUP;
00129     }
00130
00131     dwReturnValue = CopyACL (paclOld, paclNew);
00132     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00133
00134     *paclOrig = paclNew;
00135
00136 CLEANUP:
00137
00138     if(psidPrincipal) free (psidPrincipal);
00139
00140     return dwReturnValue;
00141 }
00142
00143
00144 /*---------------------------------------------------------------------------*\
00145  * NAME: AddAccessAllowedACEToACL                                            *
00146  * --------------------------------------------------------------------------*
00147  * DESCRIPTION: Adds an Access Allowed ACE with the designated mask to the
00148  * supplied ACL.
00149 \*---------------------------------------------------------------------------*/
00150 DWORD AddAccessAllowedACEToACL (
00151     PACL *paclOrig,
00152     DWORD dwAccessMask,
00153     LPTSTR tszPrincipal
00154     )
00155 {
00156     ACL_SIZE_INFORMATION  aclSizeInfo   = {0};
00157     int                   cbAclSize     = 0;
00158     DWORD                 dwReturnValue = ERROR_SUCCESS;
00159     PSID                  psidPrincipal = NULL;
00160     PACL                  paclOld       = NULL;
00161     PACL                  paclNew       = NULL;
00162
00163     if(!paclOrig) return ERROR_BAD_ARGUMENTS;
00164
00165     paclOld = *paclOrig;
00166
00167     dwReturnValue = GetPrincipalSID (tszPrincipal, &psidPrincipal);
00168     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00169
00170     if(!GetAclInformation (paclOld,
00171                            (LPVOID) &aclSizeInfo,
00172                            (DWORD) sizeof (ACL_SIZE_INFORMATION),
00173                            AclSizeInformation))
00174     {
00175         dwReturnValue = GetLastError();
00176         goto CLEANUP;
00177     }
00178
00179     cbAclSize = aclSizeInfo.AclBytesInUse +
00180               sizeof (ACL) + sizeof (ACCESS_ALLOWED_ACE) +
00181               GetLengthSid (psidPrincipal) - sizeof (DWORD);
00182
00183     paclNew = (PACL) malloc(cbAclSize);
00184     if(!paclNew)
00185     {
00186         dwReturnValue = ERROR_OUTOFMEMORY;
00187         goto CLEANUP;
00188     }
00189
00190     if (!InitializeAcl (paclNew, cbAclSize, ACL_REVISION))
00191     {
00192         dwReturnValue = GetLastError();
00193         goto CLEANUP;
00194     }
00195
00196     dwReturnValue = CopyACL (paclOld, paclNew);
00197     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00198
00199
00200     if (!AddAccessAllowedAce (paclNew,
00201                               ACL_REVISION2,
00202                               dwAccessMask,
00203                               psidPrincipal))
00204     {
00205         dwReturnValue = GetLastError();
00206         goto CLEANUP;
00207     }
00208
00209     *paclOrig = paclNew;
00210
00211 CLEANUP:
00212
00213     if(dwReturnValue != ERROR_SUCCESS && paclNew)
00214     {
00215         free(paclNew);
00216     }
00217
00218     if(psidPrincipal) free (psidPrincipal);
00219
00220     return dwReturnValue;
00221 }
00222
00223 /*---------------------------------------------------------------------------*\
00224  * NAME: UpdatePrincipalInACL                                                *
00225  * --------------------------------------------------------------------------*
00226  * DESCRIPTION: Updates the access mask in all of the ace types in the
00227  * designated ACL.
00228 \*---------------------------------------------------------------------------*/
00229 DWORD UpdatePrincipalInACL (
00230     PACL paclOrig,
00231     LPTSTR tszPrincipal,
00232     DWORD dwAccessMask,
00233     BOOL fRemove,
00234     DWORD fAceType
00235     )
00236 {
00237     ACL_SIZE_INFORMATION    aclSizeInfo        = {0};
00238     LONG                   i;
00239     LPVOID                  pvAce              = NULL;
00240     ACCESS_ALLOWED_ACE      *pAccessAllowedAce = NULL;
00241     ACCESS_DENIED_ACE       *pAccessDeniedAce  = NULL;
00242     SYSTEM_AUDIT_ACE        *pSystemAuditAce   = NULL;
00243     PSID                    psidPrincipal      = NULL;
00244     DWORD                   dwReturnValue      = ERROR_SUCCESS;
00245     ACE_HEADER              *pAceHeader        = NULL;
00246     DWORD                   dwFoundValue       = ERROR_FILE_NOT_FOUND;
00247
00248     //Construct a SID for this principal
00249     dwReturnValue = GetPrincipalSID (tszPrincipal, &psidPrincipal);
00250     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00251
00252     if(!GetAclInformation (paclOrig,
00253                            (LPVOID) &aclSizeInfo,
00254                            (DWORD) sizeof (ACL_SIZE_INFORMATION),
00255                            AclSizeInformation))
00256     {
00257         dwReturnValue = GetLastError();
00258         goto CLEANUP;
00259     }
00260
00261     //Iterate through all of the ACEs in this ACL looking for a SID that corresponds
00262     //to the principal.
00263     for (i = aclSizeInfo.AceCount-1; i >= 0; i--)
00264     {
00265         if (!GetAce (paclOrig, i, &pvAce))
00266         {
00267             dwReturnValue = GetLastError();
00268             goto CLEANUP;
00269         }
00270
00271         pAceHeader = (ACE_HEADER *) pvAce;
00272
00273         if ((fAceType == ACCESS_ALLOWED_ACE_TYPE ||
00274              fAceType == ACE_TYPE_ALL) &&
00275             pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE)
00276         {
00277             pAccessAllowedAce = (ACCESS_ALLOWED_ACE *) pvAce;
00278
00279             if (EqualSid (psidPrincipal, (PSID) &pAccessAllowedAce->SidStart))
00280             {
00281                 //We've found an ACE.  Let's modify the mask bits
00282                 if(fRemove && (pAccessAllowedAce->Mask & SPECIFIC_RIGHTS_ALL))
00283                 {
00284                     pAccessAllowedAce->Mask &= ~dwAccessMask;
00285                     //If there are any COM rights reamining we must ensure
00286                     //COM_RIGHTS_EXECUTE is set before leaving.
00287                     if(pAccessAllowedAce->Mask & (COM_RIGHTS_ACTIVATE_LOCAL  |
00288                                                   COM_RIGHTS_ACTIVATE_REMOTE |
00289                                                   COM_RIGHTS_EXECUTE_LOCAL   |
00290                                                   COM_RIGHTS_EXECUTE_REMOTE))
00291                     {
00292                         pAccessAllowedAce->Mask |= COM_RIGHTS_EXECUTE;
00293                     }
00294                     else if((pAccessAllowedAce->Mask & SPECIFIC_RIGHTS_ALL) == 0)
00295                     {
00296                         //If there are no more specific rights on this ACE we
00297                         //may delete it.
00298                         DeleteAce (paclOrig, i);
00299                     }
00300
00301                 }
00302                 else
00303                 {
00304                     pAccessAllowedAce->Mask |= dwAccessMask;
00305                 }
00306                 dwFoundValue = ERROR_SUCCESS;
00307             }
00308         }
00309         else if ((fAceType == ACCESS_DENIED_ACE_TYPE ||
00310                   fAceType == ACE_TYPE_ALL) &&
00311                  pAceHeader->AceType == ACCESS_DENIED_ACE_TYPE)
00312         {
00313             pAccessDeniedAce = (ACCESS_DENIED_ACE *) pvAce;
00314
00315             if (EqualSid (psidPrincipal, (PSID) &pAccessDeniedAce->SidStart))
00316             {
00317                 //We've found an ACE.  Let's modify the mask bits
00318                 if(fRemove && (pAccessDeniedAce->Mask & SPECIFIC_RIGHTS_ALL))
00319                 {
00320                     pAccessDeniedAce->Mask &= ~dwAccessMask;
00321
00322                     //If there are any COM rights reamining we must ensure
00323                     //COM_RIGHTS_EXECUTE is set before leaving.
00324                     if(pAccessDeniedAce->Mask & (COM_RIGHTS_ACTIVATE_LOCAL  |
00325                                                  COM_RIGHTS_ACTIVATE_REMOTE |
00326                                                  COM_RIGHTS_EXECUTE_LOCAL   |
00327                                                  COM_RIGHTS_EXECUTE_REMOTE))
00328                     {
00329                         pAccessDeniedAce->Mask |= COM_RIGHTS_EXECUTE;
00330                     }
00331                     else if((pAccessDeniedAce->Mask & SPECIFIC_RIGHTS_ALL) == 0)
00332                     {
00333                         //If there are no more specific rights on this ACE we
00334                         //may delete it.
00335                         DeleteAce (paclOrig, i);
00336                     }
00337                 }
00338                 else
00339                 {
00340                     pAccessDeniedAce->Mask |= dwAccessMask;
00341                 }
00342                 dwFoundValue = ERROR_SUCCESS;
00343             }
00344         }
00345         else if ((fAceType == SYSTEM_AUDIT_ACE_TYPE ||
00346                   fAceType == ACE_TYPE_ALL) &&
00347                  pAceHeader->AceType == SYSTEM_AUDIT_ACE_TYPE)
00348         {
00349             pSystemAuditAce = (SYSTEM_AUDIT_ACE *) pvAce;
00350
00351             if (EqualSid (psidPrincipal, (PSID) &pSystemAuditAce->SidStart))
00352             {
00353                 //We've found an ACE.  Let's modify the mask bits
00354                 if(fRemove && (pSystemAuditAce->Mask & SPECIFIC_RIGHTS_ALL))
00355                 {
00356                     pSystemAuditAce->Mask &= ~dwAccessMask;
00357
00358                     //If there are any COM rights reamining we must ensure
00359                     //COM_RIGHTS_EXECUTE is set before leaving.
00360                     if(pSystemAuditAce->Mask & (COM_RIGHTS_ACTIVATE_LOCAL  |
00361                                                 COM_RIGHTS_ACTIVATE_REMOTE |
00362                                                 COM_RIGHTS_EXECUTE_LOCAL   |
00363                                                 COM_RIGHTS_EXECUTE_REMOTE))
00364                     {
00365                         pSystemAuditAce->Mask |= COM_RIGHTS_EXECUTE;
00366                     }
00367                     else if((pSystemAuditAce->Mask & SPECIFIC_RIGHTS_ALL) == 0)
00368                     {
00369                         //If there are no more specific rights on this ACE we
00370                         //may delete it.
00371                         DeleteAce (paclOrig, i);
00372                     }
00373                 }
00374                 else
00375                 {
00376                     pSystemAuditAce->Mask |= dwAccessMask;
00377                 }
00378                 dwFoundValue = ERROR_SUCCESS;
00379             }
00380         }
00381     }
00382
00383 CLEANUP:
00384
00385     if(psidPrincipal) free (psidPrincipal);
00386
00387     if(dwReturnValue == ERROR_SUCCESS) dwReturnValue = dwFoundValue;
00388
00389     return dwReturnValue;
00390 }
00391
00392
00393 /*---------------------------------------------------------------------------*\
00394  * NAME: RemovePrincipalFromACL                                              *
00395  * --------------------------------------------------------------------------*
00396  * DESCRIPTION: Deletes all of the ACEs belonging to the designated
00397  * principal in this ACL.
00398 \*---------------------------------------------------------------------------*/
00399 DWORD RemovePrincipalFromACL (
00400     PACL paclOrig,
00401     LPTSTR tszPrincipal,
00402     DWORD fAceType
00403     )
00404 {
00405     ACL_SIZE_INFORMATION    aclSizeInfo        = {0};
00406     LONG                   i;
00407     LPVOID                  pvAce              = NULL;
00408     ACCESS_ALLOWED_ACE      *pAccessAllowedAce = NULL;
00409     ACCESS_DENIED_ACE       *pAccessDeniedAce  = NULL;
00410     SYSTEM_AUDIT_ACE        *pSystemAuditAce   = NULL;
00411     PSID                    psidPrincipal      = NULL;
00412     DWORD                   dwReturnValue      = ERROR_SUCCESS;
00413     ACE_HEADER              *pAceHeader        = NULL;
00414     DWORD                   dwFoundValue       = ERROR_FILE_NOT_FOUND;
00415
00416     dwReturnValue = GetPrincipalSID (tszPrincipal, &psidPrincipal);
00417     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00418
00419     if(!GetAclInformation (paclOrig,
00420                            (LPVOID) &aclSizeInfo,
00421                            (DWORD) sizeof (ACL_SIZE_INFORMATION),
00422                            AclSizeInformation))
00423     {
00424         dwReturnValue = GetLastError();
00425         goto CLEANUP;
00426     }
00427
00428     for (i = aclSizeInfo.AceCount-1; i >= 0; i--)
00429     {
00430         if (!GetAce (paclOrig, i, &pvAce))
00431         {
00432             dwReturnValue = GetLastError();
00433             goto CLEANUP;
00434         }
00435
00436         pAceHeader = (ACE_HEADER *) pvAce;
00437
00438         if ((fAceType == ACCESS_ALLOWED_ACE_TYPE ||
00439              fAceType == ACE_TYPE_ALL) &&
00440             pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE)
00441         {
00442             pAccessAllowedAce = (ACCESS_ALLOWED_ACE *) pvAce;
00443
00444             if (EqualSid (psidPrincipal, (PSID) &pAccessAllowedAce->SidStart))
00445             {
00446                 if(pAccessAllowedAce->Mask & SPECIFIC_RIGHTS_ALL)
00447                 {
00448                     DeleteAce (paclOrig, i);
00449                 }
00450                 dwFoundValue = ERROR_SUCCESS;
00451             }
00452         }
00453         else if ((fAceType == ACCESS_DENIED_ACE_TYPE ||
00454                   fAceType == ACE_TYPE_ALL) &&
00455                  pAceHeader->AceType == ACCESS_DENIED_ACE_TYPE)
00456         {
00457             pAccessDeniedAce = (ACCESS_DENIED_ACE *) pvAce;
00458
00459             if (EqualSid (psidPrincipal, (PSID) &pAccessDeniedAce->SidStart))
00460             {
00461                 if(pAccessDeniedAce->Mask & SPECIFIC_RIGHTS_ALL)
00462                 {
00463                     DeleteAce (paclOrig, i);
00464                 }
00465                 dwFoundValue = ERROR_SUCCESS;
00466             }
00467         }
00468         else if ((fAceType == SYSTEM_AUDIT_ACE_TYPE ||
00469                   fAceType == ACE_TYPE_ALL) &&
00470                  pAceHeader->AceType == SYSTEM_AUDIT_ACE_TYPE)
00471         {
00472             pSystemAuditAce = (SYSTEM_AUDIT_ACE *) pvAce;
00473
00474             if (EqualSid (psidPrincipal, (PSID) &pSystemAuditAce->SidStart))
00475             {
00476                 if(pSystemAuditAce->Mask & SPECIFIC_RIGHTS_ALL)
00477                 {
00478                     DeleteAce (paclOrig, i);
00479                 }
00480                 dwFoundValue = ERROR_SUCCESS;
00481             }
00482         }
00483     }
00484
00485 CLEANUP:
00486
00487     if(psidPrincipal) free (psidPrincipal);
00488
00489     if(dwReturnValue == ERROR_SUCCESS) dwReturnValue = dwFoundValue;
00490
00491     return dwReturnValue;
00492 }
00493
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/BrochureMachine/StdAfx.cpp Source File

  • Web
  • Browser
  • BrochureMachine

StdAfx.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.cpp : source file that includes just the standard includes
00006 //  stdafx.pch will be the pre-compiled header
00007 //  stdafx.obj will contain the pre-compiled type information
00008
00009 #include "stdafx.h"
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptClien/AptClien.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptClien

AptClien.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      APTCLIEN.H
00003
00004   Summary:   Main include file for the APTCLIEN executable. In addition to
00005              class definitions, this APTCLIEN.H file contains definitions
00006              of the application's menu, string, and other resource IDs.
00007
00008              Based largely on the LOCCLIEN.EXE source code, this include
00009              file adds resource IDs for the set of menus for exercising
00010              the several COM Components manipulated in this code sample
00011              as a COM Client of those components housed the the APTSERVE
00012              apartment threaded local server.
00013
00014              For a comprehensive tutorial code tour of APTCLIEN's contents
00015              and offerings see the tutorial APTCLIEN.HTM file. For more
00016              specific technical details on the internal workings see the
00017              comments dispersed throughout the APTCLIEN source code.
00018
00019   Classes:   CMainWindow
00020
00021   Functions: WinMain
00022
00023   Origin:    3-20-96: atrent - Editor-inheritance from the LOCCLIEN source.
00024
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040 #if !defined(APTCLIEN_H)
00041 #define APTCLIEN_H
00042
00043 #ifdef __cplusplus
00044
00045 extern CMsgLog* g_pMsgLog;
00046
00047 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00048   Class:    CMainWindow
00049
00050   Summary:  Class to encapsulate the application's main window, menu, and
00051             message dispatching behavior.
00052
00053   Methods:  CMainWindow
00054               Constructor.
00055             InitInstance
00056               Creates a new instance of the main window.
00057 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00058 class CMainWindow: public CVirWindow
00059 {
00060 public:
00061   CMainWindow();
00062   ~CMainWindow();
00063   BOOL InitInstance(HINSTANCE, int);
00064
00065   TCHAR m_szFileName[MAX_PATH];
00066   CMsgBox*  m_pMsgBox;
00067   CMsgLog*  m_pMsgLog;
00068
00069   // A method for getting an interface on a COM object.
00070   BOOL GetInterface(IUnknown* pObj, REFIID riid, PPVOID ppv);
00071   // Some member variables to store pointers to Car-like COM Objects.
00072   // We save pointers to each COM objects controlling IUnknown.
00073   IUnknown* m_pCar;
00074   IUnknown* m_pUtilityCar;
00075   IUnknown* m_pCruiseCar;
00076   IUnknown* m_pUtilityCruiseCar;
00077
00078 protected:
00079   LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00080
00081 private:
00082   LRESULT DoMenu(WPARAM wParam, LPARAM lParam);
00083
00084   WORD m_wWidth;
00085   WORD m_wHeight;
00086   TCHAR m_szHelpFile[MAX_PATH];
00087   TCHAR m_szFileTitle[MAX_PATH];
00088   TEXTMETRIC m_tm;
00089   OPENFILENAME m_ofnFile;
00090 };
00091
00092 #endif // __cplusplus
00093
00094 // Window Class String Macros.
00095 #define MAIN_WINDOW_TITLE_STR       "APTCLIEN: Tutorial Code Sample"
00096 #define MAIN_WINDOW_CLASS_NAME_STR  "APTCLIENWindow"
00097 #define MAIN_WINDOW_CLASS_MENU_STR  "APTCLIENMenu"
00098 #define SERVER_WINDOW_TITLE_STR     "APTSERVE: Tutorial Code Sample"
00099
00100 // File Name String Macros.
00101 #define SERVER_TUTFILE_STR          "aptserve.htm"
00102 #define MARSHAL_TUTFILE_STR         "marshal.htm"
00103
00104 // OpenFile-related String Macros.
00105 #define OFN_DEFAULTFILES_STR "All Files (*.*)\0*.*\0"
00106 #define OFN_DEFAULTTITLE_STR "Open File"
00107
00108 // File Menu Command Identifiers.
00109 #define IDM_FILE_EXIT               1000
00110
00111 // Car Menu Command Identifiers.
00112 #define IDM_CAR_CREATE              1100
00113 #define IDM_CAR_RELEASE             1101
00114 #define IDM_CAR_SHIFT               1102
00115 #define IDM_CAR_CLUTCH              1103
00116 #define IDM_CAR_SPEED               1104
00117 #define IDM_CAR_STEER               1105
00118
00119 // UtilityCar Menu Command Identifiers.
00120 #define IDM_UCAR_CREATE             1200
00121 #define IDM_UCAR_RELEASE            1201
00122 #define IDM_UCAR_SHIFT              1202
00123 #define IDM_UCAR_CLUTCH             1203
00124 #define IDM_UCAR_SPEED              1204
00125 #define IDM_UCAR_STEER              1205
00126 #define IDM_UCAR_OFFROAD            1206
00127 #define IDM_UCAR_WINCH              1207
00128
00129 // CruiseCar Menu Command Identifiers.
00130 #define IDM_CCAR_CREATE             1300
00131 #define IDM_CCAR_RELEASE            1301
00132 #define IDM_CCAR_SHIFT              1302
00133 #define IDM_CCAR_CLUTCH             1303
00134 #define IDM_CCAR_SPEED              1304
00135 #define IDM_CCAR_STEER              1305
00136 #define IDM_CCAR_ENGAGE             1306
00137 #define IDM_CCAR_ADJUST             1307
00138
00139 // UtilityCruiseCar Menu Command Identifiers.
00140 #define IDM_UCRU_CREATE             1400
00141 #define IDM_UCRU_RELEASE            1401
00142 #define IDM_UCRU_SHIFT              1402
00143 #define IDM_UCRU_CLUTCH             1403
00144 #define IDM_UCRU_SPEED              1404
00145 #define IDM_UCRU_STEER              1405
00146 #define IDM_UCRU_ENGAGE             1406
00147 #define IDM_UCRU_ADJUST             1407
00148 #define IDM_UCRU_OFFROAD            1408
00149 #define IDM_UCRU_WINCH              1409
00150
00151 // Log Menu Command Identifiers.
00152 #define IDM_LOG_LOGCLEAR            1890
00153 #define IDM_LOG_LOGGING             1891
00154 #define IDM_LOG_COPYCLIP            1892
00155
00156 // Help Menu Command Identifiers.
00157 #define IDM_HELP_CONTENTS           1900
00158 #define IDM_HELP_TUTORIAL           1901
00159 #define IDM_HELP_TUTSERVER          1902
00160 #define IDM_HELP_TUTMARSHAL         1903
00161 #define IDM_HELP_READSOURCE         1904
00162 #define IDM_HELP_ABOUT              1905
00163 #define IDM_HELP_ABOUTSERVER        1906
00164
00165 // Error-related String Identifiers.
00166 #define IDS_COMINITFAILED           2000
00167 #define IDS_APPINITFAILED           2001
00168 #define IDS_OUTOFMEMORY             2002
00169 #define IDS_NOUNICODE               2003
00170 #define IDS_NOSERVER                2004
00171
00172 #define IDS_ASSERT_FAIL             2200
00173
00174 // Notice-related String Identifiers.
00175 #define IDS_NOTIMPLEMENTED          2301
00176
00177 // Log Message String Identifiers.
00178 #define IDS_START_MESSAGE_LOG       2400
00179
00180 #endif
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/space.h Source File

  • SysMgmt
  • MMC
  • Proppage

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CRocket : public CDelegationBase {
00026 public:
00027     CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload);
00028     virtual ~CRocket();
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00033
00034 public:
00035     // virtual functions go here (for MMCN_*)
00036     virtual HRESULT OnRename(LPOLESTR pszNewName);
00037     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00038
00039     virtual HRESULT CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle);
00040     virtual HRESULT HasPropertySheets();
00041     virtual HRESULT GetWatermarks(HBITMAP *lphWatermark,
00042         HBITMAP *lphHeader,
00043         HPALETTE *lphPalette,
00044         BOOL *bStretch);
00045
00046     virtual HRESULT OnPropertyChange(IConsole *pConsole);
00047
00048 private:
00049     // {29743810-4C4B-11d2-89D8-000021473128}
00050     static const GUID thisGuid;
00051
00052     _TCHAR *szName;
00053     LONG   lWeight;
00054     LONG   lHeight;
00055     LONG   lPayload;
00056     int    nId;
00057     enum ROCKET_STATUS {RUNNING, PAUSED, STOPPED} iStatus;
00058
00059     LONG_PTR m_ppHandle;
00060
00061     static BOOL CALLBACK DialogProc(
00062         HWND hwndDlg,  // handle to dialog box
00063         UINT uMsg,     // message
00064         WPARAM wParam, // first message parameter
00065         LPARAM lParam  // second message parameter
00066         );
00067
00068 };
00069
00070 class CSpaceVehicle : public CDelegationBase {
00071 public:
00072     CSpaceVehicle();
00073
00074     virtual ~CSpaceVehicle();
00075
00076     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00077     virtual const GUID & getNodeType() { return thisGuid; }
00078     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00079
00080 public:
00081     // virtual functions go here (for MMCN_*)
00082     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00083
00084 private:
00085     enum { IDM_NEW_SPACE = 4 };
00086
00087     // {29743810-4C4B-11d2-89D8-000021473128}
00088     static const GUID thisGuid;
00089
00090 private:
00091     enum { NUMBER_OF_CHILDREN = 4 };
00092     CRocket *children[NUMBER_OF_CHILDREN];
00093 };
00094
00095 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

WsdlDiscovery::frmMain Member List

This is the complete list of members for WsdlDiscovery::frmMain, including all inherited members.
_categories | WsdlDiscovery::frmMain | [private]
_categories_AfterSelect(object sender, TreeViewEventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_categorizationLabel | WsdlDiscovery::frmMain | [private]
_descriptionLabel | WsdlDiscovery::frmMain | [private]
_extensionLabel | WsdlDiscovery::frmMain | [private]
_extensionUrl | WsdlDiscovery::frmMain | [private]
_extensionUrl_TextChanged(object sender, EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_groupBox1 | WsdlDiscovery::frmMain | [private]
_groupBox2 | WsdlDiscovery::frmMain | [private]
_groupBox3 | WsdlDiscovery::frmMain | [private]
_inquireLabel | WsdlDiscovery::frmMain | [private]
_inquireUrl | WsdlDiscovery::frmMain | [private]
_inquireUrl_TextChanged(object sender, EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_loadSchemes | WsdlDiscovery::frmMain | [private]
_loadSchemes_Click(object sender, System.EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_okToReloadSchemes | WsdlDiscovery::frmMain | [private]
_providerLabel | WsdlDiscovery::frmMain | [private]
_providerName | WsdlDiscovery::frmMain | [private]
_providerName_TextChanged(object sender, EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_results | WsdlDiscovery::frmMain | [private]
_resultsLabel | WsdlDiscovery::frmMain | [private]
_searchCategorization | WsdlDiscovery::frmMain | [private]
_searchCategorization_Click(object sender, System.EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_searchProvider | WsdlDiscovery::frmMain | [private]
_searchProvider_Click(object sender, System.EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_searchService | WsdlDiscovery::frmMain | [private]
_searchService_Click(object sender, System.EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
_serviceLabel | WsdlDiscovery::frmMain | [private]
_serviceName | WsdlDiscovery::frmMain | [private]
_serviceName_TextChanged(object sender, EventArgs e) | WsdlDiscovery::frmMain | [inline, private]
components | WsdlDiscovery::frmMain | [private]
ContainsInsensitive(string str, StringCollection coll) | WsdlDiscovery::frmMain | [inline, private]
ContainsInsensitive(string tModelKey, TModelCollection tModels) | WsdlDiscovery::frmMain | [inline, private]
Dispose(bool disposing) | WsdlDiscovery::frmMain | [inline, protected]
FillResultsControl(BusinessEntityCollection businessEntities, StringCollection serviceKeys, TModelCollection wsdlTModels) | WsdlDiscovery::frmMain | [inline, private]
frmMain() | WsdlDiscovery::frmMain | [inline]
GetTModel(string tModelKey, TModelCollection tModels) | WsdlDiscovery::frmMain | [inline, private]
InitializeComponent() | WsdlDiscovery::frmMain | [inline, private]
Main() | WsdlDiscovery::frmMain | [inline, private, static]
SetLoadSchemesButtonState() | WsdlDiscovery::frmMain | [inline, private]
SetSearchProviderButtonState() | WsdlDiscovery::frmMain | [inline, private]
SetSearchServiceButtonState() | WsdlDiscovery::frmMain | [inline, private]
Generated on Wed Nov 13 2024 16:58:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/DUnion/DUnions.c Source File

  • NetDS
  • RPC
  • Data
  • DUnion

DUnions.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                     Discriminated Union Example
00005
00006     FILE:       dunions.c
00007
00008     USAGE:      dunions  -p protocol_sequence
00009                          -e endpoint
00010                          -m max calls
00011                          -n min calls
00012                          -f flag for RpcServerListen
00013
00014     PURPOSE:    Server side of RPC distributed application dunion
00015
00016     FUNCTIONS:  main() - registers server as RPC server
00017
00018     COMMENTS:   This distributed application illustrates discriminated
00019                 union.
00020
00021 ****************************************************************************/
00022
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 #include <ctype.h>
00026 #include "dunion.h"    // header file generated by MIDL compiler
00027
00028 #define PURPOSE \
00029 "This Microsoft RPC Version 2.0 sample program demonstrates\n\
00030 two ways to specify a discriminated union. For more information\n\
00031 about the attributes and the RPC API functions, see the\n\
00032 RPC programming guide and reference.\n\n"
00033
00034 void Usage(char * pszProgramName)
00035 {
00036     fprintf(stderr, "%s", PURPOSE);
00037     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00038     fprintf(stderr, " -p protocol_sequence\n");
00039     fprintf(stderr, " -e endpoint\n");
00040     fprintf(stderr, " -m maxcalls\n");
00041     fprintf(stderr, " -n mincalls\n");
00042     fprintf(stderr, " -f flag_wait_op\n");
00043     exit(1);
00044 }
00045
00046 void __cdecl main(int argc, char * argv[])
00047 {
00048     RPC_STATUS status;
00049     unsigned char * pszProtocolSequence = "ncacn_np";
00050     unsigned char * pszSecurity         = NULL;
00051     unsigned char * pszEndpoint         = "\\pipe\\dunion";
00052     unsigned int    cMinCalls           = 1;
00053     unsigned int    cMaxCalls           = 20;
00054     unsigned int    fDontWait           = FALSE;
00055     int i;
00056
00057     /* allow the user to override settings with command line switches */
00058     for (i = 1; i < argc; i++) {
00059         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00060             switch (tolower(*(argv[i]+1))) {
00061             case 'p':  // protocol sequence
00062                 pszProtocolSequence = argv[++i];
00063                 break;
00064             case 'e':
00065                 pszEndpoint = argv[++i];
00066                 break;
00067             case 'm':
00068                 cMaxCalls = (unsigned int) atoi(argv[++i]);
00069                 break;
00070             case 'n':
00071                 cMinCalls = (unsigned int) atoi(argv[++i]);
00072                 break;
00073             case 'f':
00074                 fDontWait = (unsigned int) atoi(argv[++i]);
00075                 break;
00076             case 'h':
00077             case '?':
00078             default:
00079                 Usage(argv[0]);
00080             }
00081         }
00082         else
00083             Usage(argv[0]);
00084      }
00085
00086      status = RpcServerUseProtseqEp(pszProtocolSequence,
00087                                     cMaxCalls,
00088                                     pszEndpoint,
00089                                     pszSecurity);  // Security descriptor
00090      printf("RpcServerUseProtseqEp returned 0x%x\n", status);
00091      if (status) {
00092          exit(status);
00093      }
00094
00095      status = RpcServerRegisterIf(dunion_ServerIfHandle,// interface to register
00096                                   NULL,   // MgrTypeUuid
00097                                   NULL);  // MgrEpv; null means use default
00098      printf("RpcServerRegisterIf returned 0x%x\n", status);
00099      if (status) {
00100          exit(status);
00101      }
00102
00103      printf("Calling RpcServerListen\n");
00104      status = RpcServerListen(cMinCalls,
00105                               cMaxCalls,
00106                               fDontWait);
00107      printf("RpcServerListen returned: 0x%x\n", status);
00108      if (status) {
00109          exit(status);
00110      }
00111
00112      if (fDontWait) {
00113          printf("Calling RpcMgmtWaitServerListen\n");
00114          status = RpcMgmtWaitServerListen();  //  wait operation
00115          printf("RpcMgmtWaitServerListen returned: 0x%x\n", status);
00116          if (status) {
00117              exit(status);
00118          }
00119      }
00120
00121 }  // end main()
00122
00123
00124 /*********************************************************************/
00125 /*                 MIDL allocate and free                            */
00126 /*********************************************************************/
00127
00128 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00129 {
00130     return(malloc(len));
00131 }
00132
00133 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00134 {
00135     free(ptr);
00136 }
00137
00138 /* end file dunions.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_APPMEM_COUNTERS Member List

This is the complete list of members for _APPMEM_COUNTERS, including all inherited members.
CounterBlock | _APPMEM_COUNTERS
dwAppMemAllocs | _APPMEM_COUNTERS
dwAppMemAllocsSec | _APPMEM_COUNTERS
dwAppMemBytesAllocated | _APPMEM_COUNTERS
dwAppMemFrees | _APPMEM_COUNTERS
dwAppMemFreesSec | _APPMEM_COUNTERS
dwAppMemReAllocs | _APPMEM_COUNTERS
dwAppMemReAllocsSec | _APPMEM_COUNTERS
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/site.Cpp Source File

  • Com
  • Fundamentals
  • SimpDnd

site.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: SITE.CPP
00003 //
00004 //      Implementation file for CSimpleSite
00005 //
00006 // Functions:
00007 //
00008 //      See SITE.H for class definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "app.h"
00017 #include "site.h"
00018 #include "doc.h"
00019
00020 //**********************************************************************
00021 //
00022 // CSimpleSite::Create
00023 //
00024 // Purpose:
00025 //
00026 //      Creation routine for CSimpleSite
00027 //
00028 // Parameters:
00029 //
00030 //      CSimpleDoc FAR *lpDoc   - Pointer to CSimpleDoc
00031 //
00032 // Return Value:
00033 //
00034 //      None
00035 //
00036 // Function Calls:
00037 //      Function                    Location
00038 //
00039 //      IStorage::CreateStorage     OLE API
00040 //      assert                      C Runtime
00041 //
00042 // Comments:
00043 //
00044 //********************************************************************
00045
00046 CSimpleSite FAR * CSimpleSite::Create(CSimpleDoc FAR *lpDoc)
00047 {
00048   CSimpleSite FAR * lpTemp = new CSimpleSite(lpDoc);
00049
00050   if (!lpTemp)
00051     return NULL;
00052
00053   // create a sub-storage for the object
00054   //@@WTK WIN32, UNICODE
00055   //HRESULT hErr = lpDoc->m_lpStorage->CreateStorage( "Object",
00056   HRESULT hErr = lpDoc->m_lpStorage->CreateStorage( OLESTR("Object"),
00057         STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
00058         0,
00059         0,
00060         &lpTemp->m_lpObjStorage);
00061
00062   assert(hErr == NOERROR);
00063
00064   if (hErr != NOERROR)
00065     {
00066     delete lpTemp;
00067     return NULL;
00068     }
00069
00070   // we will add one ref count on our Site. later when we want to destroy
00071   // the Site object we will release this  ref count. when the Site's ref
00072   // count goes to 0, it will be deleted.
00073   lpTemp->AddRef();
00074
00075   return lpTemp;
00076 }
00077
00078 //**********************************************************************
00079 //
00080 // CSimpleSite::CSimpleSite
00081 //
00082 // Purpose:
00083 //
00084 //      Constructor for CSimpleSite
00085 //
00086 // Parameters:
00087 //
00088 //      CSimpleDoc FAR *lpDoc   - Pointer to CSimpleDoc
00089 //
00090 // Return Value:
00091 //
00092 //      None
00093 //
00094 // Function Calls:
00095 //      Function                    Location
00096 //
00097 // Comments:
00098 //
00099 //********************************************************************
00100 #pragma warning(disable : 4355)  // turn off this warning.  This warning
00101                 // tells us that we are passing this in
00102                 // an initializer, before "this" is through
00103                 // initializing.  This is ok, because
00104                 // we just store the ptr in the other
00105                 // constructors
00106
00107 CSimpleSite::CSimpleSite (CSimpleDoc FAR *lpDoc) : m_OleClientSite(this),
00108                          m_AdviseSink(this)
00109 #pragma warning (default : 4355)  // Turn the warning back on
00110 {
00111   // remember the pointer to the doc
00112   m_lpDoc = lpDoc;
00113
00114   // clear the reference count
00115   m_nCount = 0;
00116
00117   m_dwDrawAspect = DVASPECT_CONTENT;
00118   m_lpOleObject = NULL;
00119   m_fObjectOpen = FALSE;
00120 }
00121
00122 //**********************************************************************
00123 //
00124 // CSimpleSite::~CSimpleSite
00125 //
00126 // Purpose:
00127 //
00128 //      Destructor for CSimpleSite
00129 //
00130 // Parameters:
00131 //
00132 //      None
00133 //
00134 // Return Value:
00135 //
00136 //      None
00137 //
00138 // Function Calls:
00139 //      Function                                Location
00140 //
00141 //      OutputDebugString                       Windows API
00142 //      IOleObject::Release                     Object
00143 //      IStorage::Release                       OLE API
00144 //
00145 // Comments:
00146 //
00147 //********************************************************************
00148
00149 CSimpleSite::~CSimpleSite ()
00150 {
00151   OutputDebugString ("In CSimpleSite's Destructor \r\n");
00152
00153   if (m_lpOleObject)
00154      m_lpOleObject->Release();
00155
00156   if (m_lpObjStorage)
00157      m_lpObjStorage->Release();
00158 }
00159
00160
00161 //**********************************************************************
00162 //
00163 // CSimpleSite::CloseOleObject
00164 //
00165 // Purpose:
00166 //
00167 //      Call IOleObject::Close on the object of the CSimpleSite
00168 //
00169 // Parameters:
00170 //
00171 //      None
00172 //
00173 // Return Value:
00174 //
00175 //      None
00176 //
00177 // Function Calls:
00178 //      Function                                Location
00179 //
00180 //      OutputDebugString                       Windows API
00181 //      IOleObject::Close                       Object
00182 //
00183 // Comments:
00184 //
00185 //********************************************************************
00186
00187 void CSimpleSite::CloseOleObject (void)
00188 {
00189   LPVIEWOBJECT lpViewObject = NULL;
00190
00191   OutputDebugString ("In CSimpleSite::CloseOleObject \r\n");
00192
00193   if (m_lpOleObject)
00194      {
00195      m_lpOleObject->Close(OLECLOSE_NOSAVE);
00196      }
00197 }
00198
00199
00200 //**********************************************************************
00201 //
00202 // CSimpleSite::UnloadOleObject
00203 //
00204 // Purpose:
00205 //
00206 //      Close and release all pointers to the object of the CSimpleSite
00207 //
00208 // Parameters:
00209 //
00210 //      None
00211 //
00212 // Return Value:
00213 //
00214 //      None
00215 //
00216 // Function Calls:
00217 //      Function                                Location
00218 //
00219 //      OutputDebugString                       Windows API
00220 //      CSimpleSite::CloseOleObject             SITE.CPP
00221 //      IOleObject::QueryInterface              Object
00222 //      IViewObject::SetAdvise                  Object
00223 //      IViewObject::Release                    Object
00224 //      IStorage::Release                       OLE API
00225 //
00226 // Comments:
00227 //
00228 //********************************************************************
00229
00230 void CSimpleSite::UnloadOleObject (void)
00231 {
00232   OutputDebugString ("In CSimpleSite::UnloadOleObject \r\n");
00233
00234   if (m_lpOleObject)
00235      {
00236      LPVIEWOBJECT lpViewObject;
00237      CloseOleObject();    // ensure object is closed; NOP if already closed
00238
00239      m_lpOleObject->QueryInterface(IID_IViewObject, (LPVOID FAR *)&lpViewObject);
00240
00241      if (lpViewObject)
00242        {
00243        // Remove the view advise
00244        lpViewObject->SetAdvise(m_dwDrawAspect, 0, NULL);
00245        lpViewObject->Release();
00246        }
00247
00248      m_lpOleObject->Release();
00249      m_lpOleObject = NULL;
00250      }
00251 }
00252
00253
00254 //**********************************************************************
00255 //
00256 // CSimpleSite::QueryInterface
00257 //
00258 // Purpose:
00259 //
00260 //      Used for interface negotiation of the container Site.
00261 //
00262 // Parameters:
00263 //
00264 //      REFIID riid         -   A reference to the interface that is
00265 //                              being queried.
00266 //
00267 //      LPVOID FAR* ppvObj  -   An out parameter to return a pointer to
00268 //                              the interface.
00269 //
00270 // Return Value:
00271 //
00272 //      S_OK    -   The interface is supported.
00273 //      S_FALSE -   The interface is not supported
00274 //
00275 // Function Calls:
00276 //      Function                    Location
00277 //
00278 //      OutputDebugString           Windows API
00279 //      IsEqualIID                  OLE API
00280 //                   OLE API
00281 //      CSimpleSite::AddRef          OBJ.CPP
00282 //      COleClientSite::AddRef      IOCS.CPP
00283 //      CAdviseSink::AddRef         IAS.CPP
00284 //
00285 // Comments:
00286 //
00287 //
00288 //********************************************************************
00289
00290 STDMETHODIMP CSimpleSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00291 {
00292   OutputDebugString("In CSimpleSite::QueryInterface\r\n");
00293
00294   *ppvObj = NULL;     // must set out pointer parameters to NULL
00295
00296   if ( riid == IID_IUnknown)
00297     {
00298     AddRef();
00299     *ppvObj = this;
00300     return S_OK;
00301     }
00302
00303   if ( riid == IID_IOleClientSite)
00304     {
00305     m_OleClientSite.AddRef();
00306     *ppvObj = &m_OleClientSite;
00307     return S_OK;
00308     }
00309
00310   if ( riid == IID_IAdviseSink)
00311     {
00312     m_AdviseSink.AddRef();
00313     *ppvObj = &m_AdviseSink;
00314     return S_OK;
00315     }
00316
00317   // Not a supported interface
00318   return E_NOINTERFACE;
00319 }
00320
00321 //**********************************************************************
00322 //
00323 // CSimpleSite::AddRef
00324 //
00325 // Purpose:
00326 //
00327 //      Increments the reference count of the container Site.
00328 //
00329 // Parameters:
00330 //
00331 //      None
00332 //
00333 // Return Value:
00334 //
00335 //      ULONG   -   The new reference count of the site.
00336 //
00337 // Function Calls:
00338 //      Function                    Location
00339 //
00340 //      OutputDebugString           Windows API
00341 //
00342 // Comments:
00343 //
00344 //********************************************************************
00345
00346 STDMETHODIMP_(ULONG) CSimpleSite::AddRef()
00347 {
00348   OutputDebugString("In CSimpleSite::AddRef\r\n");
00349
00350   return ++m_nCount;
00351 }
00352
00353 //**********************************************************************
00354 //
00355 // CSimpleSite::Release
00356 //
00357 // Purpose:
00358 //
00359 //      Decrements the reference count of the container Site
00360 //
00361 // Parameters:
00362 //
00363 //      None
00364 //
00365 // Return Value:
00366 //
00367 //      ULONG   -   The new reference count of the Site.
00368 //
00369 // Function Calls:
00370 //      Function                    Location
00371 //
00372 //      OutputDebugString           Windows API
00373 //
00374 // Comments:
00375 //
00376 //********************************************************************
00377
00378 STDMETHODIMP_(ULONG) CSimpleSite::Release()
00379 {
00380   OutputDebugString("In CSimpleSite::Release\r\n");
00381
00382   if (--m_nCount == 0) {
00383     delete this;
00384     return 0;
00385   }
00386   return m_nCount;
00387 }
00388
00389 //**********************************************************************
00390 //
00391 // CSimpleSite::InitObject
00392 //
00393 // Purpose:
00394 //
00395 //      Used to initialize a newly create object (can't be done in the
00396 //      constructor).
00397 //
00398 // Parameters:
00399 //
00400 //      BOOL fCreateNew -   TRUE if insert NEW object
00401 //                          FALSE if create object FROM FILE
00402 //
00403 // Return Value:
00404 //
00405 //      None
00406 //
00407 // Function Calls:
00408 //      Function                        Location
00409 //
00410 //      IOleObject::SetHostNames        Object
00411 //      IOleObject::QueryInterface      Object
00412 //      IViewObject2::GetExtent         Object
00413 //      IOleObject::DoVerb              Object
00414 //      IViewObject::SetAdvise          Object
00415 //      IViewObject::Release            Object
00416 //      GetClientRect                   Windows API
00417 //      OleSetContainedObject           OLE API
00418 //
00419 // Comments:
00420 //
00421 //********************************************************************
00422
00423 void CSimpleSite::InitObject(BOOL fCreateNew)
00424 {
00425   LPVIEWOBJECT2 lpViewObject2;
00426   RECT rect;
00427
00428   // Set a View Advise
00429   m_lpOleObject->QueryInterface(IID_IViewObject2,(LPVOID FAR *)&lpViewObject2);
00430   lpViewObject2->SetAdvise(m_dwDrawAspect, ADVF_PRIMEFIRST, &m_AdviseSink);
00431
00432   // get the initial size of the object
00433   lpViewObject2->GetExtent(m_dwDrawAspect, -1 /*lindex*/, NULL /*ptd*/, &m_sizel);
00434   GetObjRect(&rect);  // get the rectangle of the object in pixels
00435   lpViewObject2->Release();
00436
00437   // give the object the name of the container app/document
00438   //@@WTK WIN32, UNICODE
00439   //m_lpOleObject->SetHostNames("Simple Application", "Simple OLE 2.0 Drag/Drop Container");
00440   m_lpOleObject->SetHostNames(OLESTR("Simple Application"), OLESTR("Simple OLE 2.0 Drag/Drop Container"));
00441
00442   // inform object handler/DLL object that it is used in the embedding container's context
00443   OleSetContainedObject(m_lpOleObject, TRUE);
00444
00445   if (fCreateNew) {
00446      // force new object to save to guarantee valid object in our storage.
00447      // OLE 1.0 objects may close w/o saving. this is NOT necessary if the
00448      // object is created FROM FILE; its data in storage is already valid.
00449      m_OleClientSite.SaveObject();
00450
00451      // we only want to DoVerb(SHOW) if this is an InsertNew object.
00452      // we should NOT DoVerb(SHOW) if the object is created FromFile.
00453      m_lpOleObject->DoVerb(
00454          OLEIVERB_SHOW,
00455          NULL,
00456          &m_OleClientSite,
00457          -1,
00458          m_lpDoc->m_hDocWnd,
00459          &rect);
00460   }
00461 }
00462
00463 //**********************************************************************
00464 //
00465 // CSimpleSite::PaintObj
00466 //
00467 // Purpose:
00468 //
00469 //      Paints the object
00470 //
00471 // Parameters:
00472 //
00473 //      HDC hDC     - Device context of the document window
00474 //
00475 // Return Value:
00476 //
00477 // Function Calls:
00478 //      Function                        Location
00479 //
00480 //      IOleObject::QueryInterface      Object
00481 //      IViewObject::GetColorSet        Object
00482 //      IViewObject::Release            Object
00483 //      SetMapMode                      Windows API
00484 //      LPtoDP                          Windows API
00485 //      CreateHatchBrush                Windows API
00486 //      SelectObject                    Windows API
00487 //      DeleteObject                    Windows API
00488 //      CreatePalette                   Windows API
00489 //      SelectPalette                   Windows API
00490 //      RealizePalette                  Windows API
00491 //      OleStdFree                      OUTLUI Function
00492 //      OleDraw                         OLE API
00493 //
00494 // Comments:
00495 //
00496 //********************************************************************
00497
00498 void CSimpleSite::PaintObj(HDC hDC)
00499 {
00500 RECT rect;
00501
00502   // need to check to make sure there is a valid object
00503   // available.  This is needed if there is a paint msg
00504   // between the time that CSimpleSite is instantiated
00505   // and OleUIInsertObject returns.
00506   if (!m_lpOleObject)
00507     return;
00508
00509   // convert it to pixels
00510   GetObjRect(&rect);
00511
00512   LPLOGPALETTE pColorSet = NULL;
00513   LPVIEWOBJECT lpView = NULL;
00514
00515   // get a pointer to IViewObject
00516   m_lpOleObject->QueryInterface(IID_IViewObject,(LPVOID FAR *) &lpView);
00517
00518   // if the QI succeeds, get the LOGPALETTE for the object
00519   if (lpView)
00520     lpView->GetColorSet(m_dwDrawAspect, -1, NULL, NULL, NULL, &pColorSet);
00521
00522   HPALETTE hPal=NULL;
00523   HPALETTE hOldPal=NULL;
00524
00525   // if a LOGPALETTE was returned (not guarateed), create the palette and
00526   // realize it.  NOTE: A smarter application would want to get the LOGPALETTE
00527   // for each of its visible objects, and try to create a palette that
00528   // satisfies all of the visible objects.  ALSO: OleStdFree() is use to
00529   // free the returned LOGPALETTE.
00530   if ((pColorSet))
00531     {
00532     hPal = CreatePalette((const LPLOGPALETTE) pColorSet);
00533     hOldPal = SelectPalette(hDC, hPal, FALSE);
00534     RealizePalette(hDC);
00535     OleStdFree(pColorSet);
00536     }
00537
00538   // draw the object
00539   OleDraw(m_lpOleObject, m_dwDrawAspect, hDC, &rect);
00540
00541   // if the object is open, draw a hatch rect.
00542   if (m_fObjectOpen)
00543     {
00544     HBRUSH hBrush = CreateHatchBrush ( HS_BDIAGONAL, RGB(0,0,0) );
00545     HBRUSH hOldBrush = (HBRUSH) SelectObject (hDC, hBrush);
00546     SetROP2(hDC, R2_MASKPEN);
00547     Rectangle (hDC, rect.left, rect.top, rect.right, rect.bottom);
00548     SelectObject(hDC, hOldBrush);
00549     DeleteObject(hBrush);
00550     }
00551
00552   // if we created a palette, restore the old one, and destroy
00553   // the object.
00554   if (hPal)
00555     {
00556     SelectPalette(hDC,hOldPal,FALSE);
00557     DeleteObject(hPal);
00558     }
00559
00560   // if a view pointer was successfully returned, it needs to be released.
00561   if (lpView)
00562     lpView->Release();
00563 }
00564
00565 //**********************************************************************
00566 //
00567 // CSimpleSite::GetObjRect
00568 //
00569 // Purpose:
00570 //
00571 //      Retrieves the rect of the object in pixels
00572 //
00573 // Parameters:
00574 //
00575 //      LPRECT lpRect - Rect structure filled with object's rect in pixels
00576 //
00577 // Return Value:
00578 //
00579 // Function Calls:
00580 //      Function                        Location
00581 //
00582 //      XformWidthInHimetricToPixels    OUTLUI Function
00583 //      XformHeightInHimetricToPixels   OUTLUI Function
00584 //
00585 // Comments:
00586 //
00587 //********************************************************************
00588
00589 void CSimpleSite::GetObjRect(LPRECT lpRect)
00590 {
00591   // convert it to pixels
00592   lpRect->left = lpRect->top = 0;
00593   lpRect->right = XformWidthInHimetricToPixels(NULL,(int)m_sizel.cx);
00594   lpRect->bottom = XformHeightInHimetricToPixels(NULL,(int)m_sizel.cy);
00595 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

THREAD_STRUCT Member List

This is the complete list of members for THREAD_STRUCT, including all inherited members.
hdbc | THREAD_STRUCT
henv | THREAD_STRUCT
rgFieldInfo | THREAD_STRUCT
szTableName | THREAD_STRUCT
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

NewsSubscriber Member List

This is the complete list of members for NewsSubscriber, including all inherited members.
addCatalog(comadmin.ICatalogCollection appCollec, String appName) | NewsSubscriber | [inline, private]
admin | NewsSubscriber | [package]
appNameLB | NewsSubscriber | [package]
appNameTF | NewsSubscriber | [package]
cascadeAppName | NewsSubscriber | [package]
cascadeHeading | NewsSubscriber | [package]
cascadePersisRB | NewsSubscriber | [package]
cascadeTransRB | NewsSubscriber | [package]
checkForAppAlreadyInstalled(comadmin.ICatalogCollection appCollec, String appName) | NewsSubscriber | [inline, private]
checkForApplication(comadmin.ICatalogCollection appCollec, boolean appProcessFlag, String appName, String compName, String subName, String eventCLSID, boolean subProcessFlag) | NewsSubscriber | [inline, private]
checkForComponent(comadmin.ICatalogCollection compCollec, String compName, String subName, String eventCLSID, boolean subProcessFlag) | NewsSubscriber | [inline, private]
clearButton | NewsSubscriber | [package]
clearButton_click(Object source, Event e) | NewsSubscriber | [inline, private]
components | NewsSubscriber | [package]
directPersisRB | NewsSubscriber | [package]
directTransRB | NewsSubscriber | [package]
dispose() | NewsSubscriber | [inline]
dllPathLB | NewsSubscriber | [package]
dllPathTF | NewsSubscriber | [package]
eventList | NewsSubscriber | [package]
initAdminCatlog() | NewsSubscriber | [inline, private]
initForm() | NewsSubscriber | [inline, private]
installCascadeButton | NewsSubscriber | [package]
installCascadeButton_click(Object source, Event e) | NewsSubscriber | [inline, private]
LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate) | NewsSubscriber | [inline]
main(String args[]) | NewsSubscriber | [inline, static]
NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL) | NewsSubscriber | [inline]
NewsSubscriber() | NewsSubscriber | [inline]
persistentHeading | NewsSubscriber | [package]
queuedCascadeCB | NewsSubscriber | [package]
queuedPersisCB | NewsSubscriber | [package]
removeSubscription(comadmin.ICatalogCollection subCollec, String subName) | NewsSubscriber | [inline, private]
ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow) | NewsSubscriber | [inline]
subscribePersisButton | NewsSubscriber | [package]
subscribePersisButton_click(Object source, Event e) | NewsSubscriber | [inline, private]
subscribeTransButton | NewsSubscriber | [package]
subscribeTransButton_click(Object source, Event e) | NewsSubscriber | [inline, private]
transientHeading | NewsSubscriber | [package]
uninstallCascadeEvent() | NewsSubscriber | [inline, private]
updateSubscription(comadmin.ICatalogCollection subCollec, String subName, String eventCLSID, boolean subProcessFlag) | NewsSubscriber | [inline, private]
Generated on Wed Nov 13 2024 16:57:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/comp.h Source File

  • SysMgmt
  • MMC
  • Menubtn

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent,
00025 IExtendControlbar
00026
00027 {
00028 private:
00029     ULONG       m_cref;
00030
00031     IConsole*   m_ipConsole;
00032     IDisplayHelp* m_ipDisplayHelp;
00033     IControlbar*    m_ipControlBar;
00034     IMenuButton*    m_ipMenuButton;
00035
00036     class CComponentData *m_pComponentData;
00037
00038     public:
00039         CComponent(CComponentData *parent);
00040         ~CComponent();
00041
00042         ///////////////////////////////
00043         // Interface IUnknown
00044         ///////////////////////////////
00045         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046         STDMETHODIMP_(ULONG) AddRef();
00047         STDMETHODIMP_(ULONG) Release();
00048
00049         ///////////////////////////////
00050         // Interface IComponent
00051         ///////////////////////////////
00052         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053             /* [in] */ LPCONSOLE lpConsole);
00054
00055             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00056             /* [in] */ LPDATAOBJECT lpDataObject,
00057             /* [in] */ MMC_NOTIFY_TYPE event,
00058             /* [in] */ LPARAM arg,
00059             /* [in] */ LPARAM param);
00060
00061             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00062             /* [in] */ MMC_COOKIE cookie);
00063
00064             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00065             /* [in] */ MMC_COOKIE cookie,
00066             /* [in] */ DATA_OBJECT_TYPES type,
00067             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00068
00069             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00070             /* [in] */ MMC_COOKIE cookie,
00071             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00072             /* [out] */ long __RPC_FAR *pViewOptions);
00073
00074             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00075             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00076
00077             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00078             /* [in] */ LPDATAOBJECT lpDataObjectA,
00079             /* [in] */ LPDATAOBJECT lpDataObjectB);
00080
00081             ///////////////////////////////
00082             // Interface IExtendControlBar
00083             ///////////////////////////////
00084             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetControlbar(
00085             /* [in] */ LPCONTROLBAR pControlbar);
00086
00087             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE ControlbarNotify(
00088             /* [in] */ MMC_NOTIFY_TYPE event,
00089             /* [in] */ LPARAM arg,
00090             /* [in] */ LPARAM param);
00091 };
00092
00093 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCaseTextService Member List

This is the complete list of members for CCaseTextService, including all inherited members.
_cRef | CCaseTextService | [private]
_dwTextEditSinkCookie | CCaseTextService | [private]
_dwThreadFocusSinkCookie | CCaseTextService | [private]
_dwThreadMgrEventSinkCookie | CCaseTextService | [private]
_fFlipKeys | CCaseTextService | [private]
_fShowSnoop | CCaseTextService | [private]
_GetClientId() | CCaseTextService | [inline]
_GetThreadMgr() | CCaseTextService | [inline]
_InitKeystrokeSink() | CCaseTextService | [private]
_InitLanguageBar() | CCaseTextService | [private]
_InitPreservedKey() | CCaseTextService | [private]
_InitSnoopWnd() | CCaseTextService | [private]
_InitTextEditSink(ITfDocumentMgr *pDocMgr) | CCaseTextService | [private]
_InitThreadMgrSink() | CCaseTextService | [private]
_IsKeyFlipping() | CCaseTextService | [inline]
_IsSnoopWndVisible() | CCaseTextService | [inline]
_Menu_FlipDoc(CCaseTextService *_this) | CCaseTextService | [static]
_Menu_FlipKeys(CCaseTextService *_this) | CCaseTextService | [static]
_Menu_FlipSel(CCaseTextService *_this) | CCaseTextService | [static]
_Menu_HelloWord(CCaseTextService *_this) | CCaseTextService | [static]
_Menu_ShowSnoopWnd(CCaseTextService *_this) | CCaseTextService | [static]
_pLangBarItem | CCaseTextService | [private]
_pSnoopWnd | CCaseTextService | [private]
_pTextEditSinkContext | CCaseTextService | [private]
_pThreadMgr | CCaseTextService | [private]
_tfClientId | CCaseTextService | [private]
_UninitKeystrokeSink() | CCaseTextService | [private]
_UninitLanguageBar() | CCaseTextService | [private]
_UninitPreservedKey() | CCaseTextService | [private]
_UninitSnoopWnd() | CCaseTextService | [private]
_UninitThreadMgrSink() | CCaseTextService | [private]
Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId) | CCaseTextService |
CCaseTextService() | CCaseTextService |
CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj) | CCaseTextService | [static]
Deactivate() | CCaseTextService |
OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) | CCaseTextService |
OnInitDocumentMgr(ITfDocumentMgr *pDocMgr) | CCaseTextService |
OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten) | CCaseTextService |
OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten) | CCaseTextService |
OnKillThreadFocus() | CCaseTextService |
OnPopContext(ITfContext *pContext) | CCaseTextService |
OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pfEaten) | CCaseTextService |
OnPushContext(ITfContext *pContext) | CCaseTextService |
OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus) | CCaseTextService |
OnSetFocus(BOOL fForeground) | CCaseTextService |
OnSetThreadFocus() | CCaseTextService |
OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten) | CCaseTextService |
OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten) | CCaseTextService |
OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr) | CCaseTextService |
QueryInterface(REFIID riid, void **ppvObj) | CCaseTextService |
RegisterCategories(BOOL fRegister) | CCaseTextService | [static]
RegisterProfiles() | CCaseTextService | [static]
RegisterServer() | CCaseTextService | [static]
STDMETHODIMP_(ULONG) AddRef(void) | CCaseTextService |
STDMETHODIMP_(ULONG) Release(void) | CCaseTextService |
UnregisterProfiles() | CCaseTextService | [static]
UnregisterServer() | CCaseTextService | [static]
~CCaseTextService() | CCaseTextService |
Generated on Wed Nov 13 2024 16:55:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/inc/rusocket.h Source File

  • NetDS
  • RRas
  • rqs
  • inc

rusocket.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       RuSocket.h
00004 //
00005 //      Synopsis:   Simple socket abstraction.
00006 //
00007 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //+--------------------------------------------------------------------------
00010
00011 #pragma once
00012
00013 #include <winsock2.h>
00014
00015 #ifdef __cplusplus
00016 extern "C" {
00017 #endif
00018
00019 //
00020 //  Typedef and utility function for looking up WSAEventSelect dynamically
00021 //
00022 typedef int (WINAPI *pfnWSAEventSelectSpec)(SOCKET, WSAEVENT, long);
00023 pfnWSAEventSelectSpec LookupWSAEventSelect();
00024
00025 struct _RU_SOCKET;
00026 typedef struct _RU_SOCKET* HSOCKET;
00027
00028 //+--------------------------------------------------------------------------
00029 //
00030 // Synopsis: Information needed to create a socket
00031 //
00032 //      args:
00033 //          dwPort      Port to connect to (client) or listen on (server)
00034 //          pszDest     IpAddress or DNS name to connect to (client) or bind
00035 //                      to (server)
00036 //
00037 //+--------------------------------------------------------------------------
00038 typedef struct _RU_SOCKET_CREATE_DATA
00039 {
00040     UINT uiPort;
00041     CHAR* pszDest;
00042     CHAR* pszSrc;
00043
00044 } RU_SOCKET_CREATE_DATA;
00045
00046 HRESULT
00047 RuSocketInit ();
00048
00049 HRESULT
00050 RuSocketCleanup ();
00051
00052 HRESULT
00053 RuSocketCreate (
00054     IN  RU_SOCKET_CREATE_DATA* pCreateData,
00055     OUT HSOCKET* phSocket);
00056
00057 HRESULT
00058 RuSocketCreateServer (
00059     IN  RU_SOCKET_CREATE_DATA* pCreateData,
00060     OUT HSOCKET* phServerSock);
00061
00062 HRESULT
00063 RuSocketListen (
00064     IN  HSOCKET hServerSock,
00065     OUT HSOCKET* phSocket);
00066
00067 HRESULT
00068 RuSocketClose (
00069     IN  HSOCKET IN phSocket);
00070
00071 HRESULT
00072 RuSocketRead (
00073     IN      HSOCKET hSocket,
00074     IN      BYTE*  pbBuffer,
00075     IN OUT  UINT*  lpuiBufSize);
00076
00077 HRESULT
00078 RuSocketReadBlock(
00079     IN      HSOCKET hSocket,
00080     IN      BYTE*  pbBuffer,
00081     IN OUT  UINT*  lpuiBufSize);
00082
00083 HRESULT
00084 RuSocketReadCurrent (
00085     IN      HSOCKET hSocket,
00086     IN      BYTE*  pbBuffer,
00087     IN OUT  UINT*  lpuiBufSize,
00088     OUT     BOOL*  pbNoMore);
00089
00090 HRESULT
00091 RuSocketReadLine (
00092     IN      HSOCKET hSocket,
00093     IN      BYTE*  pbBuffer,
00094     IN OUT  UINT*  lpuiBufSize);
00095
00096 HRESULT
00097 RuSocketWrite (
00098     IN      HSOCKET hSocket,
00099     IN      BYTE*  pbBuffer,
00100     IN OUT  UINT*  lpuiBufSize);
00101
00102 HRESULT
00103 RuSocketWriteLine (
00104     IN      HSOCKET hSocket,
00105     IN      BYTE*  pbBuffer,
00106     IN OUT  UINT*  lpuiBufSize);
00107
00108 HRESULT
00109 RuSocketGetAddress(
00110     IN  HSOCKET hSocket,
00111     OUT DWORD*  lpdwAddress);
00112
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116
00117 #ifdef __cplusplus
00118 //----------------------------------------------------------------------------
00119 //
00120 //                  C++ implementation (RuSocket class)
00121 //
00122 //----------------------------------------------------------------------------
00123 class RuSocket
00124 {
00125 public:
00126     RuSocket();
00127     ~RuSocket();
00128
00129     static HRESULT Initialize();
00130     static HRESULT Cleanup();
00131
00132     VOID Assign(IN HSOCKET hSocket);
00133
00134     HRESULT
00135     Open(
00136         IN UINT uiPort,
00137         IN CHAR* pszHostOrIpDst,
00138         IN CHAR* pszIpSrc = NULL);
00139
00140     VOID Close();
00141
00142     HRESULT GetAddress(OUT DWORD*  lpdwAddress);
00143
00144     HRESULT
00145     Read(
00146         IN      BYTE*  pbBuffer,
00147         IN OUT  UINT*  lpuiBufSize,
00148         IN      BOOL   fBlock = TRUE);
00149
00150     HRESULT
00151     ReadLine(
00152         IN      BYTE*  pbBuffer,
00153         IN OUT  UINT*  lpuiBufSize);
00154
00155     HRESULT
00156     ReadCurrent(
00157         IN      BYTE*  pbBuffer,
00158         IN OUT  UINT*  lpuiBufSize,
00159         OUT     BOOL*  pbNoMore);
00160
00161     HRESULT
00162     Write (
00163         IN      BYTE*  pbBuffer,
00164         IN OUT  UINT*  lpuiBufSize);
00165
00166     HRESULT
00167     WriteLine (
00168         IN      BYTE*  pbBuffer,
00169         IN OUT  UINT*  lpuiBufSize);
00170
00171     HRESULT SetEvent(IN HANDLE hEvent, IN LONG lFlags);
00172
00173 private:
00174     HSOCKET m_hSocket;
00175     pfnWSAEventSelectSpec m_pfnWSAEventSelect;
00176 };
00177
00178 class RuServerSocket
00179 {
00180 public:
00181     RuServerSocket();
00182     ~RuServerSocket();
00183
00184     HRESULT
00185     Create(
00186         IN  UINT uiPort,
00187         IN OPTIONAL CHAR* pszLocalIpAddress = NULL);
00188
00189     VOID Close();
00190
00191     HRESULT Listen(OUT RuSocket* pClient);
00192
00193     HRESULT SetEvent(IN HANDLE hEvent, IN LONG lFlags = FD_ACCEPT);
00194
00195 private:
00196     HSOCKET m_hSocket;
00197     pfnWSAEventSelectSpec m_pfnWSAEventSelect;
00198 };
00199
00200
00201 #endif
00202
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_TIME Member List

This is the complete list of members for _TIME, including all inherited members.
time | _TIME
vtType | _TIME
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/GdiDemo/Bounce.h Source File

  • Multimedia
  • Gdi
  • GdiDemo

Bounce.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012
00013 #ifdef WIN16
00014 #define APIENTRY FAR PASCAL
00015 typedef WORD WPARAM;
00016 #endif
00017
00018 #define BOUNCECLASS  "BOUNCEDEMO"
00019
00020
00021 typedef struct _MYXFORM
00022 {
00023     int xForm[3][3];
00024 } MYXFORM;
00025 typedef MYXFORM      *PMYXFORM;
00026 typedef MYXFORM NEAR *NPMYXFORM;
00027 typedef MYXFORM FAR  *LPMYXFORM;
00028
00029
00030 /*
00031 ** BALL OBJECT
00032 */
00033 typedef struct _BALLDATA
00034 {
00035     HWND     hWnd;
00036     int      nWidth;
00037     int      nHeight;
00038     int      xDirection;
00039     int      yDirection;
00040     BOOL     bNewPosition;
00041     int      xPosition;
00042     int      yPosition;
00043     COLORREF crColor;
00044     MYXFORM  xForm;
00045 } BALLDATA;
00046 typedef BALLDATA      *PBALLDATA;
00047 typedef BALLDATA NEAR *NPBALLDATA;
00048 typedef BALLDATA FAR  *LPBALLDATA;
00049
00050 HANDLE ballCreate(HWND,int,int,COLORREF);
00051 BOOL   ballDestroy(HANDLE);
00052 VOID   ballBounce(HANDLE);
00053 BOOL   ballSetDimensions(HANDLE,int,int);
00054 BOOL   ballGetDimensions(HANDLE,LPPOINT);
00055 BOOL   ballSetDirection(HANDLE,int,int);
00056 BOOL   ballGetDirection(HANDLE,LPPOINT);
00057 BOOL   ballGetPosition(HANDLE,LPPOINT);
00058 BOOL   ballSetPosition(HANDLE,int,int);
00059
00060
00061
00062
00063 typedef struct _BOUNCEDATA
00064 {
00065     HANDLE hBall1;
00066     HANDLE hBall2;
00067     HANDLE hBall3;
00068     HANDLE hBall4;
00069 } BOUNCEDATA;
00070 typedef BOUNCEDATA      *PBOUNCEDATA;
00071 typedef BOUNCEDATA NEAR *NPBOUNCEDATA;
00072 typedef BOUNCEDATA FAR  *LPBOUNCEDATA;
00073
00074
00075 /*
00076 ** DRAW WINDOW ROUTINES (draw.c)
00077 */
00078 HWND  FAR      CreateBounceWindow(HWND,int);
00079 LRESULT  CALLBACK BounceProc(HWND,UINT,WPARAM,LPARAM);
00080 BOOL           BounceCreateProc(HWND);
00081 VOID           BounceDestroyProc(HWND);
00082 BOOL           BounceCommandProc(HWND,WPARAM,LPARAM);
00083 VOID           BouncePaintProc(HWND);
00084
00085 VOID           BounceObjects(HWND);
00086 VOID           BounceRefresh(HWND);
00087
00088
00089 VOID           CheckEdgePosition(HWND,HANDLE);
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Query Member List

This is the complete list of members for Query, including all inherited members.
Display(PrintStream PS) | Query | [inline, package]
Execute() | Query | [inline, package]
m_RS | Query | [private]
m_SqlText | Query | [private]
Query() | Query | [inline, package]
SetRawSql(String RawSql) | Query | [inline, package]
SetSqlWhere(String Where) | Query | [inline, package]
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_IPSAMPLE_IF_STATS Member List

This is the complete list of members for _IPSAMPLE_IF_STATS, including all inherited members.
ulNumPackets _IPSAMPLE_IF_STATS
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMDIObjects Member List

This is the complete list of members for CMDIObjects, including all inherited members.
AutoPosition(BOOL fDefaultPosition=TRUE) | CMDIObjects | [virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CMDIChildLite() | CMDIChildLite |
CMDIObjects(CMainWindow *pCMainWindow) | CMDIObjects |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, HICON hIcon, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CMDIChildLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCMainWindow | CMDIObjects |
m_pCObjTree | CMDIObjects |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
MDIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [static]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CMDIObjects | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CMDIObjects | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CMDIObjects | [virtual]
CMDIChildLite::OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CMDIObjects | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CMDIObjects | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate) | CMDIObjects | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CMDIObjects | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CMDIObjects | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CMDIObjects | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CMDIObjects | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CMDIObjects | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [virtual]
UpdateControls() | CMDIObjects | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CMDIChildLite() | CMDIChildLite | [virtual]
~CMDIObjects() | CMDIObjects | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ConnectModeEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ConnectModeEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ConnectModeEnum
00019
00020 public class ConnectModeEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adModeUnknown = 0;
00023   public static final short adModeRead = 1;
00024   public static final short adModeWrite = 2;
00025   public static final short adModeReadWrite = 3;
00026   public static final short adModeShareDenyRead = 4;
00027   public static final short adModeShareDenyWrite = 8;
00028   public static final short adModeShareExclusive = 12;
00029   public static final short adModeShareDenyNone = 16;
00030   public static final short adModeRecursive = 32;
00031   public static final short adoModeUnknown = 0;
00032   public static final short adoModeRead = 1;
00033   public static final short adoModeWrite = 2;
00034   public static final short adoModeReadWrite = 3;
00035   public static final short adoModeShareDenyRead = 4;
00036   public static final short adoModeShareDenyWrite = 8;
00037   public static final short adoModeShareExclusive = 12;
00038   public static final short adoModeShareNone = 16;
00039   public static final short adoModeRecursive = 32;
00040 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

icmp_hdr Member List

This is the complete list of members for icmp_hdr, including all inherited members.
icmp_checksum | icmp_hdr
icmp_code | icmp_hdr
icmp_id | icmp_hdr
icmp_sequence | icmp_hdr
icmp_type | icmp_hdr
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/pstore.h Source File

  • WinUI
  • TSFmark

pstore.h

Go to the documentation of this file.
00001 //
00002 // pstore.h
00003 //
00004 // CCustomPropertyStore
00005 //
00006
00007 #ifndef PSTORE_H
00008 #define PSTORE_H
00009
00010 class CCustomPropertyStore : public ITfPropertyStore
00011 {
00012 public:
00013     CCustomPropertyStore();
00014     ~CCustomPropertyStore();
00015
00016     // IUnknown
00017     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00018     STDMETHODIMP_(ULONG) AddRef(void);
00019     STDMETHODIMP_(ULONG) Release(void);
00020
00021     // ITfPropertyStore
00022     STDMETHODIMP GetType(GUID *pguidType);
00023     STDMETHODIMP GetDataType(DWORD *pdwReserved);
00024     STDMETHODIMP GetData(VARIANT *pvarValue);
00025     STDMETHODIMP OnTextUpdated(DWORD dwFlags, ITfRange *pRangeNew, BOOL *pfAccept);
00026     STDMETHODIMP Shrink(ITfRange *pRangeNew, BOOL *pfFree);
00027     STDMETHODIMP Divide(ITfRange *pRangeThis, ITfRange *pRangeNew, ITfPropertyStore **ppPropertyStore);
00028     STDMETHODIMP Clone(ITfPropertyStore **ppClone);
00029     STDMETHODIMP GetPropertyRangeCreator(CLSID *pclsid);
00030     STDMETHODIMP Serialize(IStream *pStream, ULONG *pcb);
00031
00032     void _SetState(DWORD dwState)
00033     {
00034         _dwState = dwState;
00035     }
00036
00037 private:
00038     DWORD _dwState;
00039     LONG _cRef;     // COM ref count
00040 };
00041
00042 #endif // PSTORE_H
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_WIDENAMEMAP Member List

This is the complete list of members for _WIDENAMEMAP, including all inherited members.
lItem | _WIDENAMEMAP
pwszName | _WIDENAMEMAP
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCShip2/Ship2.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCShip2

Ship2.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Ship2.cpp
00003   Summary:   Implementation of COShip2 class
00004   Classes:   Implemented: COShip2
00005        Used: ADO  CLSID_ADOConnection
00006        Used: COM+ ObjectContext
00007   Methods:   put_CustomerId
00008        put_OrderId
00009        LineItem
00010        ProcessOrder
00011   Origin:    Implementation of case study in Queued Components specification
00012 ----------------------------------------------------------------------------
00013   Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00014
00015     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00016     ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00017     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018     PARTICULAR PURPOSE
00019 ==========================================================================+*/
00020
00021 #include "stdafx.h"
00022 #include "..\DataSourceNames.h" // ADO Data Source Names, userid, password
00023 #include <adoid.h>    // OLEDBSDK ADO
00024 #include <adoint.h>   // OLEDBSDK ADO
00025 #include "QCShip2.h"    // Generated by MIDL from QCShip2.idl
00026 #include "Ship2.h"    // Our class header
00027 #include "..\QCOrder\processFlags.h"
00028
00029 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00030   Method:   COShip2::put_CustomerId
00031   Summary:  property put for CustomerId property
00032   Args:     long lCustomerId      A customer identifier.
00033   Modifies: class member variable m_lCustomerId
00034   Returns:  HRESULT - Always returns S_OK
00035 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00036
00037 STDMETHODIMP COShip2::put_CustomerId(long lCustomerId)
00038 {
00039   m_lCustomerId = lCustomerId;
00040   return S_OK;
00041 }
00042
00043 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00044   Method:   COShip2::put_OrderId
00045   Summary:  property put for OrderId property
00046   Args:     long lOrderId     An order identifier.
00047   Modifies: class member variable m_lOrderId
00048   Returns:  HRESULT - Always returns S_OK
00049 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00050
00051 STDMETHODIMP COShip2::put_OrderId(long lOrderId)
00052 {
00053   m_lOrderId = lOrderId;
00054   return S_OK;
00055 }
00056
00057 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00058   Method:   COShip2::LineItem
00059   Summary:  Adds a single item to an order
00060   Args:     long lItemId      An item identifier (e.g. stock identifier)
00061       long lQuantity      The quantity of the item ordered
00062   Modifies: class members m_veclItemId, m_veclQuantity, m_vecShipStatus
00063   Returns:  HRESULT - Always returns S_OK
00064 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00065
00066 STDMETHODIMP COShip2::LineItem(long lItemId, long lQuantity)
00067 {
00068   m_veclItemId.push_back(lItemId);
00069   m_veclQuantity.push_back(lQuantity);
00070   m_vecShipStatus.push_back(RandomShipStatus());  // assign shipping status
00071   return S_OK;
00072 }
00073
00074 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00075   Method:   COShip2::Process
00076   Summary:  Writes order to Shipping database.
00077       Creates Notify object to inform requestor of shipping statuses.
00078   Args:     long  lFlags - option flags (see constants in IDL file)
00079   Modifies: Rows in Shipping table (DSN = QCSampOrder)
00080       Issues COM+ SetComplete or SetAbort depending on request success.
00081   Returns:  HRESULT - returns failure from embedded function requests or S_OK.
00082 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00083
00084 STDMETHODIMP COShip2::Process(long lFlags, IUnknown *punk)
00085 {
00086   HRESULT hr = S_OK;
00087
00088   _RPT1(_CRT_WARN, "QCSamp2 %d Ship2\n", m_lOrderId);
00089
00090   if (lFlags & processFlagWriteDB) hr = WriteShipDB();
00091
00092   if (SUCCEEDED(hr)) hr = NotifyRequestor(lFlags, punk);
00093
00094   // Invoke SetComplete or SetAbort depending on our success
00095
00096   CComPtr<IObjectContext> pIObjectContext;
00097
00098   if (SUCCEEDED(CoGetObjectContext(IID_IObjectContext, (void**)&pIObjectContext)))
00099   {
00100     if (SUCCEEDED(hr))  pIObjectContext->SetComplete();
00101     else        pIObjectContext->SetAbort();
00102   }
00103
00104   return hr;
00105 }
00106
00107 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00108   THIS IS A PRIVATE MEMBER FUNCTION
00109
00110   Method:   COShip2::WriteShipDB
00111   Summary:  Writes order to Shipping database.
00112   Args:     None
00113   Modifies: Adds rows in Shipping table (DSN = QCSampleShip)
00114   Returns:  HRESULT - returns failure from embedded function requests or S_OK.
00115 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00116
00117 HRESULT COShip2::WriteShipDB()
00118 {
00119   CComPtr<ADOConnection> pADOConnection;
00120
00121   HRESULT hr = CoCreateInstance(  CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,
00122                   IID_IADOConnection, (void **) &pADOConnection);
00123   if (SUCCEEDED(hr))
00124   {
00125     // Connect to the Shipping Database. Names in DataSourceNames.h
00126
00127     hr = pADOConnection->Open(  _bstr_t(pszShipDSN), _bstr_t(pszUserId),
00128                   _bstr_t(pszPassword), adOpenUnspecified);
00129
00130     // Write one row per line item
00131
00132     for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00133     {
00134       TCHAR szSQLStmt[1024];  // SQL statement buffer
00135
00136       LPCTSTR pszPrototypeInsertStmt =
00137         _T("insert into QCSampleShip ")
00138         _T(" (order_id, cust_id, line_no, ")
00139         _T("  item_id, quantity, ship_status_enum) ")
00140         _T("values(%ld, %ld, %ld, %ld, %ld, %ld)");
00141
00142       wsprintf( szSQLStmt,
00143             pszPrototypeInsertStmt,
00144             m_lOrderId,
00145             m_lCustomerId,
00146             ix,
00147             m_veclItemId[ix],
00148             m_veclQuantity[ix],
00149             m_vecShipStatus[ix]);
00150
00151       hr = pADOConnection->Execute(_bstr_t(szSQLStmt), NULL, adCmdText, NULL);
00152     }
00153   }
00154
00155   return hr;
00156 }
00157
00158 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00159   THIS IS A PRIVATE MEMBER FUNCTION
00160
00161   Method:   COShip2::NotifyRequestor
00162   Summary:  Creates Notify object to return shipping status to requestor.
00163   Args:     long  lFlags - processing option flags
00164   Modifies: None
00165   Returns:  HRESULT - returns failure from embedded function requests or S_OK.
00166 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00167
00168 HRESULT COShip2::NotifyRequestor(long lFlags, IUnknown *punkNotify)
00169 {
00170   HRESULT hr = S_OK;
00171
00172   if (lFlags & processFlagLateBound)
00173     hr = InvokeNotifyIDispatch(punkNotify, lFlags);
00174   else
00175     hr = InvokeNotifyVtable(punkNotify, lFlags);
00176   return hr;
00177 }
00178
00179 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00180   THIS IS A PRIVATE MEMBER FUNCTION
00181
00182   Method:   COShip2::InvokeNotifyIDispatch
00183   Summary:  Invoke Notify object methods using IDispatch
00184   Args:     IUnknown *  punkShip - IUnknown * to Notify object
00185       long    lFlags  - flag longword with option bits
00186   Modifies: None
00187   Returns:  HRESULT from the underlying requests
00188 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00189
00190 HRESULT COShip2::InvokeNotifyIDispatch(IUnknown * punkNotify, long lFlags)
00191 {
00192   HRESULT hr = S_OK;
00193
00194   MessageBox(NULL, "Inside InvokeNotifyIDispatch!", "Arghh!", MB_OK);
00195   CComQIPtr<IDispatch, &IID_IDispatch> pIDispatch(punkNotify);
00196
00197   if (!pIDispatch) hr = E_NOINTERFACE;
00198
00199   // Set CustomerId property
00200
00201   if (SUCCEEDED(hr))
00202   {
00203     const int nNames = 1;
00204
00205     OLECHAR * rgszNames[nNames] = { OLESTR("CustomerId") };
00206     DISPID    dispId[nNames];
00207
00208     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00209                     LOCALE_SYSTEM_DEFAULT, dispId);
00210     if (SUCCEEDED(hr))
00211     {
00212       CComVariant varData(m_lCustomerId);
00213       DISPID    dispidPut = DISPID_PROPERTYPUT;
00214       DISPPARAMS  dispparams = {&varData, &dispidPut, 1, 1};
00215
00216       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00217                   DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
00218     }
00219   }
00220
00221   // Set OrderId property
00222
00223   if (SUCCEEDED(hr))
00224   {
00225     const int nNames = 1;
00226
00227     OLECHAR * rgszNames[nNames] = { OLESTR("OrderId") };
00228     DISPID    dispId[nNames];
00229
00230     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00231                     LOCALE_SYSTEM_DEFAULT, dispId);
00232     if (SUCCEEDED(hr))
00233     {
00234       CComVariant varData(m_lOrderId);
00235       DISPID    dispidPut = DISPID_PROPERTYPUT;
00236       DISPPARAMS  dispparams = {&varData, &dispidPut, 1, 1};
00237
00238       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00239                   DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
00240     }
00241   }
00242
00243   // Call LineItem method once for each line item
00244
00245   if (SUCCEEDED(hr))
00246   {
00247     const int nNames = 4;
00248
00249     OLECHAR * rgszNames[nNames] = { OLESTR("LineItem"),   // method name
00250                       OLESTR("lItemId"),    // parm name
00251                       OLESTR("lQuantity"),
00252                       OLESTR("shipStatus") }; // parm name
00253     DISPID    dispId[nNames];
00254
00255     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00256                     LOCALE_SYSTEM_DEFAULT, dispId);
00257
00258     for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00259     {
00260       const int nArgs = nNames - 1;
00261
00262       CComVariant varData[nArgs];   // 2 Arguments
00263       varData[0] = m_veclItemId[ix];
00264       varData[1] = m_veclQuantity[ix];
00265       varData[2] = m_vecShipStatus[ix];
00266
00267       DISPPARAMS dispparams = {varData, &dispId[1], nArgs, nArgs};
00268
00269       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00270                   DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
00271     }
00272   }
00273
00274   // Call Process method
00275
00276   if (SUCCEEDED(hr))
00277   {
00278     const int nNames = 2;
00279
00280     OLECHAR * rgszNames[nNames] = { OLESTR("Process"),    // method name
00281                       OLESTR("lFlags") };   // parm name
00282     DISPID    dispId[nNames];
00283
00284     hr = pIDispatch->GetIDsOfNames( IID_NULL, rgszNames, nNames,
00285                     LOCALE_SYSTEM_DEFAULT, dispId);
00286     if (SUCCEEDED(hr))
00287     {
00288       const int nArgs = nNames - 1;
00289
00290       CComVariant varData[nArgs]; // just the parameters
00291       varData[0] = lFlags;
00292
00293       DISPPARAMS  dispparams = {varData, &dispId[1], nArgs, 0};
00294
00295       hr = pIDispatch->Invoke(dispId[0], IID_NULL, LOCALE_USER_DEFAULT,
00296                   DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
00297     }
00298   }
00299   return hr;
00300 }
00301
00302 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00303   THIS IS A PRIVATE MEMBER FUNCTION
00304
00305   Method:   COShip2::InvokeNotifyVtable
00306   Summary:  Calls Notify object methods using vtable
00307   Args:     long  lFlags - processing option flags
00308   Modifies: None
00309   Returns:  HRESULT - returns failure from embedded function requests or S_OK.
00310 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00311
00312 HRESULT COShip2::InvokeNotifyVtable(IUnknown * punkNotify, long lFlags)
00313 {
00314   HRESULT hr = S_OK;
00315
00316   CComQIPtr<INotify, &IID_INotify> pNotify(punkNotify);
00317
00318   if (!pNotify) hr = E_NOINTERFACE;
00319
00320   if (SUCCEEDED(hr)) hr = pNotify->put_CustomerId(m_lCustomerId);
00321
00322   if (SUCCEEDED(hr)) hr = pNotify->put_OrderId(m_lOrderId);
00323
00324   for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00325   {
00326     hr = pNotify->LineItem(m_veclItemId[ix], m_veclQuantity[ix], m_vecShipStatus[ix]);
00327   }
00328
00329   if (SUCCEEDED(hr)) hr = pNotify->Process(lFlags);
00330
00331   return hr;
00332 }
00333
00334 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00335   THIS IS A PRIVATE MEMBER FUNCTION
00336
00337   Method:   COShip2::RandomShipStatus
00338   Summary:  Determines shipping status for a particular line item.
00339       The status is derived from a random number, but is skewed
00340       so that most shipments are successful.
00341   Args:     None
00342   Modifies: None
00343   Returns:  ShipStatus - an enumeration declared in QCSamp2.idl
00344 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00345
00346 ShipStatus COShip2::RandomShipStatus()
00347 {
00348   const int iRandom = rand() % 100;
00349
00350   if (iRandom < 80) return ssShipped;   // 80% are shipped
00351   if (iRandom < 93) return ssBackOrdered; // 13% are back ordered
00352   if (iRandom < 97) return ssNotStocked;  //  4% are not stocked
00353             return ssUnrecognizedItem;  //  3% have an invalid item number
00354 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/ondiskdetails.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

ondiskdetails.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  OnDiskDetails.cpp
00006 //
00007 // Description:
00008 //  This file implements the OnDiskDetails() routine which
00009 //    demonstrates how to enumerate properties on your C:
00010 //    drive.
00011 //
00012 // History:
00013 //
00014 // **************************************************************************
00015
00016
00017 #include "stdafx.h"
00018 #include "AdvClientDlg.h"
00019
00020 // **************************************************************************
00021 //
00022 //  CAdvClientDlg::OnDiskdetails()
00023 //
00024 // Description:
00025 //    Enumerates the properties of the C: drive using the 'GetNames()'
00026 //    technique. The technique uses safearrays.
00027 //
00028 // Parameters:
00029 //    None.
00030 //
00031 // Returns:
00032 //    Nothing.
00033 //
00034 // Globals accessed:
00035 //    None.
00036 //
00037 // Globals modified:
00038 //    None.
00039 //
00040 //===========================================================================
00041 void CAdvClientDlg::OnDiskdetails()
00042 {
00043   HRESULT  hRes;
00044   long lLower, lUpper, lCount;
00045   SAFEARRAY *psaNames = NULL;
00046   BSTR PropName = NULL;
00047   VARIANT varString, pVal;
00048   WCHAR *pBuf;
00049   CString clMyBuff;
00050
00051   IWbemClassObject *pDriveInst = NULL;
00052   IWbemQualifierSet *pQualSet = NULL;
00053
00054   VariantInit(&varString);
00055   VariantInit(&pVal);
00056
00057   m_outputList.ResetContent();
00058   m_outputList.AddString(_T("working..."));
00059
00060   //-------------------------------
00061   // Get the instance for C: drive.
00062   BSTR driveName = SysAllocString(L"Win32_LogicalDisk.DeviceID=\"C:\"");
00063   if (!driveName)
00064   {
00065     TRACE(_T("SysAllocString failed: not enough memory\n"));
00066     return;
00067   }
00068   BSTR cimType = SysAllocString(L"CIMTYPE");
00069   if (!cimType)
00070   {
00071     SysFreeString(driveName);
00072     TRACE(_T("SysAllocString failed: not enough memory\n"));
00073     return;
00074   }
00075   BSTR keyQual = SysAllocString(L"key");
00076   if (!keyQual)
00077   {
00078     SysFreeString(driveName);
00079     SysFreeString(cimType);
00080     TRACE(_T("SysAllocString failed: not enough memory\n"));
00081     return;
00082   }
00083
00084     if((hRes = m_pIWbemServices->GetObject(driveName,
00085                     0L,
00086                     NULL,
00087                     &pDriveInst,
00088                     NULL)) == S_OK)
00089   {
00090
00091     m_outputList.ResetContent();
00092
00093     //-------------------------------
00094     // Get the property names
00095     if((hRes = pDriveInst->GetNames(NULL,
00096                     WBEM_FLAG_ALWAYS |
00097                     WBEM_FLAG_NONSYSTEM_ONLY,
00098                     NULL,
00099                     &psaNames)) == S_OK)
00100     {
00101       //-------------------------------
00102       // Get the upper and lower bounds of the Names array
00103       if((hRes = SafeArrayGetLBound(psaNames, 1, &lLower)) != S_OK)
00104       {
00105         TRACE(_T("Couldn't get safe array lbound\n"));
00106         SafeArrayDestroy(psaNames);
00107         return;
00108       }
00109
00110       //-------------------------------
00111       if((hRes = SafeArrayGetUBound(psaNames, 1, &lUpper)) != S_OK)
00112       {
00113         TRACE(_T("Couldn't get safe array ubound\n"));
00114         SafeArrayDestroy(psaNames);
00115         return;
00116       }
00117
00118
00119       //-------------------------------
00120       // For all properties...
00121       for (lCount = lLower; lCount <= lUpper; lCount++)
00122       {
00123         //-----------------------------------------------
00124         // I'm formatting each property as:
00125         //   name (type) ==> value
00126         //-----------------------------------------------
00127
00128         //-------------------------------
00129         // get the property name for this element
00130         if((hRes = SafeArrayGetElement(psaNames,
00131                         &lCount,
00132                         &PropName)) == S_OK)
00133         {
00134           clMyBuff = PropName;
00135
00136           // print variable type for property value
00137           clMyBuff += _T(" (");
00138
00139           // Get pointer to property qualifiers
00140           // this mess is due to the fact that system properties don't have qualifiers
00141           if ((pDriveInst->GetPropertyQualifierSet(PropName, &pQualSet)) == S_OK)
00142           {
00143             // Get and print syntax attribute (if any)
00144             if ((pQualSet->Get(cimType, 0L, &pVal, NULL)) == S_OK)
00145             {
00146                clMyBuff += V_BSTR(&pVal);
00147             }
00148             else if (hRes != WBEM_E_NOT_FOUND)
00149             {  // some other error
00150                TRACE(_T("Could not get syntax qualifier\n"));
00151                break;
00152             }
00153             VariantClear(&pVal);
00154
00155             //-------------------------------
00156             // If this is a key field, print an asterisk
00157             if(((hRes = pQualSet->Get(keyQual,
00158                         0L,
00159                         &pVal,
00160                         NULL)) == S_OK) &&
00161               (pVal.boolVal))
00162             { // Yes, it's a key
00163                clMyBuff += _T(")*");
00164             }
00165             else if (hRes == WBEM_E_NOT_FOUND)
00166             {  // not a key qualifier
00167                clMyBuff += _T(")");
00168             }
00169             else
00170             { // some other error
00171                TRACE(_T("Could not get key qualifier\n"));
00172                break;
00173             }
00174             // done with the qualifierSet.
00175             if (pQualSet)
00176             {
00177               pQualSet->Release();
00178               pQualSet = NULL;
00179             }
00180           }
00181           else
00182           {
00183             clMyBuff += _T(")");
00184           } //endif pDriveClass->GetPropertyQualifierSet()
00185
00186           //-------------------------------
00187           // Get the value for the property.
00188           if((hRes = pDriveInst->Get(PropName,
00189                         0L,
00190                         &varString,
00191                         NULL, NULL)) == S_OK)
00192           {
00193             // Print the value
00194             clMyBuff += _T("   ==> ");
00195             clMyBuff += ValueToString(&varString, &pBuf);
00196
00197             m_outputList.AddString(clMyBuff);
00198
00199             free(pBuf); // allocated by ValueToString()
00200           }
00201           else
00202           {
00203             TRACE(_T("Couldn't get Property Value\n"));
00204             break;
00205           } //endif pDriveClass->Get()
00206
00207           VariantClear(&varString);
00208           VariantClear(&pVal);
00209         }
00210         else // SafeArrayGetElement() failed
00211         {
00212           TRACE(_T("Couldn't get safe array element\n"));
00213           break;
00214         } //endif SafeArrayGetElement()
00215
00216       } // endfor
00217
00218       // cleanup.
00219       SysFreeString(PropName);
00220       SysFreeString(keyQual);
00221       SysFreeString(cimType);
00222       SafeArrayDestroy(psaNames);
00223       VariantClear(&varString);
00224       VariantClear(&pVal);
00225     }
00226     else // pDriveClass->GetNames() failed
00227     {
00228       TRACE(_T("Couldn't GetNames\n"));
00229     } //endif pDriveClass->GetNames()
00230
00231     // done with drive instance.
00232     if (pDriveInst)
00233     {
00234       pDriveInst->Release();
00235       pDriveInst = NULL;
00236     }
00237   } //endif GetObject()
00238 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSampleMSPStream Member List

This is the complete list of members for CSampleMSPStream, including all inherited members.
ConfigureTransport(void) | CSampleMSPStream | [virtual]
ConnectTerminal(ITTerminal *pTerminal) | CSampleMSPStream | [private]
ConnectToTerminalPin(IPin *pTerminalPin) | CSampleMSPStream | [private]
CSampleMSPStream() | CSampleMSPStream |
FinalRelease() | CSampleMSPStream | [virtual]
FireEvent(IN MSP_CALL_EVENT type, IN HRESULT hrError, IN MSP_CALL_EVENT_CAUSE cause) | CSampleMSPStream | [virtual]
get_Name(OUT BSTR *ppName) | CSampleMSPStream |
m_ActualGraphState | CSampleMSPStream | [protected]
m_DesiredGraphState | CSampleMSPStream | [protected]
m_fTerminalConnected | CSampleMSPStream | [protected]
m_fTransportConfigured | CSampleMSPStream | [protected]
PauseStream() | CSampleMSPStream |
ProcessGraphEvent(IN long lEventCode, IN long lParam1, IN long lParam2) | CSampleMSPStream | [virtual]
SelectTerminal(IN ITTerminal *pTerminal) | CSampleMSPStream |
StartStream() | CSampleMSPStream |
StopStream() | CSampleMSPStream |
UnselectTerminal(IN ITTerminal *pTerminal) | CSampleMSPStream |
~CSampleMSPStream() | CSampleMSPStream | [virtual]
Generated on Wed Nov 13 2024 16:57:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/GUIPAPER.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

GUIPAPER.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUIPAPER.H
00003
00004   Summary:   Include file for the CGuiPaper C++ class. A GuiPaper is a C++
00005              object that displays and stores mouse movements as free-form
00006              line drawing or "scribbling" in the client area of a
00007              designated window. GuiPaper is anchored to the Windows GUI
00008              (Graphical User Interface) environment. This GuiPaper object
00009              relies on a virtual Paper object that is instantiated as a
00010              COM object (a COPaper) in a separate In-process server,
00011              STOSERVE, to store the "ink" data that is drawn.
00012
00013              For a comprehensive tutorial code tour of GUIPAPER's contents
00014              and offerings see the tutorial STOCLIEN.HTM file. For
00015              more specific technical details on the internal workings see
00016              the comments dispersed throughout the GUIPAPER source code.
00017
00018   Classes:   CGuiPaper.
00019
00020   Origin:    6-10-96: atrent - Editor inheritance from GUIBALL.H in the
00021              CONCLIEN source.
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 #if !defined(GUIPAPER_H)
00038 #define GUIPAPER_H
00039
00040 #if defined(__cplusplus)
00041
00042
00043 #define PAP_EXT "PAP"
00044 #define PAP_FILE_EXT ".PAP"
00045
00046
00047 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00048   Class:    CGuiPaper
00049
00050   Summary:  Class to encapsulate the displayable Graphical User Interface
00051             GUI Paper object.
00052
00053   Methods:  CGuiPaper
00054               Constructor.
00055             ~CGuiPaper
00056               Destructor.
00057             BOOL Init(HINSTANCE hInst, HWND hWnd, TCHAR* pszCmdLineFile);
00058               Initialize the GuiPaper.
00059             HRESULT DrawOn(void);
00060               Lock paper for drawing.
00061             HRESULT DrawOff(void);
00062               Unlock paper for drawing.
00063             HRESULT ClearWin(void);
00064               Clear display window but retain ink data.
00065             HRESULT PaintWin(void);
00066               Clear window and Repaint the window with ink data.
00067             HRESULT Erase(void);
00068               Erase current drawn content and clear display window.
00069             HRESULT Resize(WORD wWidth, WORD wHeight);
00070               Resize the display window.
00071             HRESULT InkSaving(BOOL bInkSaving);
00072               Turn Ink data saving in COPaper on and off.
00073             HRESULT InkWidth(SHORT nInkWidth);
00074               Set current ink line width for drawing.
00075             HRESULT InkColor(COLORREF crInkColor);
00076               Set current ink color for drawing.
00077             HRESULT InkStart(SHORT nX, SHORT nY);
00078               Start ink drawing sequence.
00079             HRESULT InkDraw(SHORT nX, SHORT nY);
00080               Draw ink sequence data.
00081             HRESULT InkStop(SHORT nX, SHORT nY);
00082               Stop ink drawing sequence.
00083             HRESULT ConnectPaperSink(void);
00084               Connect the PaperSink to the server COPaper source.
00085             HRESULT DisconnectPaperSink(void);
00086               Disconnect the PaperSink from the server COPaper source.
00087             IConnectionPoint* GetConnectionPoint(REFIID riid);
00088               Private method to obtain a connection point interface.
00089             HRESULT Load(void);
00090               Load Ink Data from current compound file.
00091             HRESULT Save(void);
00092               Save existing Ink Data to current compound file.
00093             INT AskSave(void);
00094               Check if new ink data, ask user, save if user says to.
00095             HRESULT Open(void);
00096               Common dialog. Open existing Ink Data compound file.
00097             HRESULT SaveAs(void);
00098               Common dialog. Save current Ink Data file in renamed file.
00099             COLORREF PickColor(void);
00100               Common dialog. Ask user to choose new pen color.
00101 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00102 class CGuiPaper
00103 {
00104   public:
00105     CGuiPaper(void);
00106     ~CGuiPaper(void);
00107     BOOL Init(HINSTANCE hInst, HWND hWnd, TCHAR* pszCmdLineFile);
00108     HRESULT DrawOn(void);
00109     HRESULT DrawOff(void);
00110     HRESULT ClearWin(void);
00111     HRESULT PaintWin(void);
00112     HRESULT Erase(void);
00113     HRESULT Resize(WORD wWidth, WORD wHeight);
00114     HRESULT InkSaving(BOOL bInkSaving);
00115     HRESULT InkWidth(SHORT nInkWidth);
00116     HRESULT InkColor(COLORREF crInkColor);
00117     HRESULT InkStart(SHORT nX, SHORT nY);
00118     HRESULT InkDraw(SHORT nX, SHORT nY);
00119     HRESULT InkStop(SHORT nX, SHORT nY);
00120     HRESULT ConnectPaperSink(void);
00121     HRESULT DisconnectPaperSink(void);
00122     HRESULT Load(void);
00123     HRESULT Save(void);
00124     INT     AskSave(void);
00125     HRESULT Open(void);
00126     HRESULT SaveAs(void);
00127     COLORREF PickColor(void);
00128
00129   private:
00130     HINSTANCE  m_hInst;
00131     HWND       m_hWnd;
00132     HDC        m_hDC;
00133     RECT       m_WinRect;
00134     IPaper*    m_pIPaper;
00135     SHORT      m_nLockKey;
00136     HPEN       m_hPen;
00137     SHORT      m_nInkWidth;
00138     COLORREF   m_crInkColor;
00139     BOOL       m_bInkSaving;
00140     BOOL       m_bInking;
00141     BOOL       m_bPainting;
00142     POINT      m_OldPos;
00143     IUnknown*  m_pCOPaperSink;
00144     DWORD      m_dwPaperSink;
00145     BOOL       m_bDirty;
00146     CPapFile*    m_pPapFile;
00147     OPENFILENAME m_ofnFile;
00148     TCHAR        m_szFileFilter[MAX_PATH];
00149     TCHAR        m_szFileName[MAX_PATH];
00150     TCHAR        m_szFileTitle[MAX_PATH];
00151     CHOOSECOLOR  m_ChooseColor;
00152     COLORREF     m_acrCustColors[16];
00153
00154     IConnectionPoint* GetConnectionPoint(REFIID riid);
00155 };
00156
00157
00158 #endif // __cplusplus
00159
00160 #endif
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/resource.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by RowsetViewer.RC
00004 //
00005 #define IDB_OPTIONS                     3
00006 #define IDB_ADD                         4
00007 #define IDB_RESET                       5
00008 #define IDB_ADDSET                      5
00009 #define IDB_DELETE                      6
00010 #define IDB_DELETESET                   7
00011 #define IDC_PROVIDER                    10
00012 #define IDC_EDITBOX                     20
00013 #define IDE_USERID                      30
00014 #define IDE_LOCATION                    31
00015 #define IDE_PASSWORD                    40
00016 #define IDE_PROVSTRING                  42
00017 #define IDD_FULLCONNECT_PROVIDER        60
00018 #define IDD_ABOUT                       80
00019 #define IDD_MDICHILD                    90
00020 #define IDR_ROWSETVIEWER                100
00021 #define ID_STATUSBAR                    101
00022 #define ID_MDICLIENT                    102
00023 #define ID_TOOLBAR                      103
00024 #define ID_TREEVIEW                     107
00025 #define ID_TIMER                        108
00026 #define IDM_RECENTCONFIG1               111
00027 #define IDM_RECENTCONFIG2               112
00028 #define IDM_RECENTCONFIG3               113
00029 #define IDM_RECENTCONFIG4               114
00030 #define IDM_RECENTCONFIG5               115
00031 #define IDM_RECENTCONFIG6               116
00032 #define IDM_RECENTCONFIG7               117
00033 #define IDM_RECENTCONFIG8               118
00034 #define IDM_RECENTCONFIG9               119
00035 #define IDM_RECENTCONFIG10              120
00036 #define IDM_RECENTFILE1                 121
00037 #define IDM_RECENTFILE2                 122
00038 #define IDM_RECENTFILE3                 123
00039 #define IDM_RECENTFILE4                 124
00040 #define IDM_RECENTFILE5                 125
00041 #define IDM_RECENTFILE6                 126
00042 #define IDM_RECENTFILE7                 127
00043 #define IDM_RECENTFILE8                 128
00044 #define IDM_RECENTFILE9                 129
00045 #define IDM_RECENTFILE10                130
00046 #define IDD_ROWCHANGE                   131
00047 #define ID_MDITRACE                     137
00048 #define ID_MDIOBJECTS                   138
00049 #define ID_OBJECTTREE                   139
00050 #define IDB_TOOLBAR                     158
00051 #define IDD_SCHEMAROWSET                170
00052 #define IDM_ROWSETMENU                  172
00053 #define IDM_EDITMENU                    173
00054 #define IDM_NOTIFYMENU                  175
00055 #define IDB_STATE                       177
00056 #define IDB_IMAGE                       179
00057 #define IDD_SETPROPERTIES               184
00058 #define IDD_TRANSACTION_START           193
00059 #define IDD_TRANSACTION_ABORT           194
00060 #define IDD_CANCONVERT                  196
00061 #define IDD_INTERFACE                   198
00062 #define IDM_CHANGESTATUS                199
00063 #define IDD_TRANSACTION_SETOPTIONS      201
00064 #define IDD_OPTIONS_ROWSET              202
00065 #define IDD_FULLCONNECT_OPTIONS         203
00066 #define IDD_FULLCONNECT_PROPERTIES      204
00067 #define IDD_FULLCONNECT_SECURITY        205
00068 #define IDD_PROVIDERINFO                206
00069 #define IDD_SCHEMATREEVIEW              208
00070 #define IDM_TREESCHEMA                  211
00071 #define IDM_BROWSE_OPTION               212
00072 #define IDD_BROWSE_ENUM                 215
00073 #define IDM_TILEHORIZONTAL              220
00074 #define IDD_OPTIONS_NOTIFICATIONS       222
00075 #define IDM_CHANGEVALUE                 223
00076 #define IDD_OPTIONS_ERRORS              224
00077 #define IDD_GETLISTVIEW                 225
00078 #define IDD_SETPARAMETERINFO            226
00079 #define IDD_PARAMEXECUTE                227
00080 #define IDD_OPTIONS_COMMAND             228
00081 #define IDD_OPENROWSET                  229
00082 #define IDM_CASCADE                     230
00083 #define IDD_GETCOLUMNSROWSET            230
00084 #define IDD_GETSOURCESROWSET            231
00085 #define IDD_EXECUTE                     232
00086 #define IDD_DROPINDEX                   233
00087 #define IDD_DROPTABLE                   234
00088 #define IDD_FINDNEXTROW                 235
00089 #define IDD_SETCOMMANDTEXT              236
00090 #define IDD_CREATEACCESSOR              238
00091 #define IDD_DATAINIT_GETDATASOURCE      239
00092 #define IDM_ARRANGEICONS                240
00093 #define IDD_GETAXISINFO                 243
00094 #define IDD_DATASOURCEADMIN_CREATEDATASOURCE 244
00095 #define IDD_GETNEXTROWS                 245
00096 #define IDD_ROW_OPEN                    247
00097 #define IDD_BINDRESOURCE                248
00098 #define IDM_CLOSEALL                    250
00099 #define IDD_TRANSACTION_JOIN            251
00100 #define IDD_TRANSACTION_COMMIT          252
00101 #define IDD_TRANSACTION_GETINFO         254
00102 #define IDD_TRANSACTION_RELEASE         255
00103 #define IDD_DROPCOLUMN                  256
00104 #define IDD_ADDCOLUMN                   257
00105 #define IDD_CREATETABLE                 258
00106 #define IDD_CREATEINDEX                 259
00107 #define IDD_PROMPTDATASOURCE            260
00108 #define IDM_ABOUT                       280
00109 #define IDC_MDICHILD                    290
00110 #define IDD_OPTIONS_ACCESSOR            300
00111 #define IDD_ISCO_DELETE                 301
00112 #define IDD_ISCO_COPY                   302
00113 #define IDM_ROWMENU                     302
00114 #define IDD_GETREFERENCEDROWSET         303
00115 #define IDD_URLMAPPING                  310
00116 #define IDD_PROMPTFILENAME              311
00117 #define IDM_DATASOURCEMENU              312
00118 #define IDM_SESSIONMENU                 313
00119 #define IDM_COMMANDMENU                 314
00120 #define IDM_ERRORMENU                   315
00121 #define IDM_ROWPOSITIONMENU             316
00122 #define IDM_DATASETMENU                 317
00123 #define IDR_TRANSACTIONMENU             318
00124 #define IDM_TRANSACTIONMENU             318
00125 #define IDM_ENUMERATOR                  319
00126 #define IDM_ENUMERATORMENU              319
00127 #define IDM_BINDERMENU                  320
00128 #define IDM_MULTIPLERESULTSMENU         321
00129 #define IDM_STREAMMENU                  322
00130 #define IDM_SERVICECOMPMENU             323
00131 #define IDM_UNKNOWNMENU                 324
00132 #define IDD_AGGREGATION                 325
00133 #define IDM_POOLMENU                    329
00134 #define IDD_SETVALUE                    330
00135 #define IDR_BROWSE_PROPERTY             331
00136 #define IDD_SIMPLE_LISTBOX              332
00137 #define IDD_COMMANDPERSIST              333
00138 #define IDM_TRANSACTIONOPTIONSMENU      334
00139 #define IDM_CONNECTIONPOINTMENU         335
00140 #define IDM_DATALINKSMENU               336
00141 #define IDM_CUSTOMERRORMENU             337
00142 #define IDD_MSPERSIST                   338
00143 #define IDD_ERRORRECORDS                339
00144 #define IDD_STREAM_VIEWER               342
00145 #define IDD_GETAXISROWSET               343
00146 #define IDD_ADDCONSTRAINTDESC           344
00147 #define IDD_DROPCONSTRAINT              345
00148 #define IDD_ALTERINDEX                  346
00149 #define IDD_ALTERTABLE                  347
00150 #define IDD_ALTERCOLUMN                 348
00151 #define IDD_SETCOMMANDSTREAM            349
00152 #define IDD_MULTIPLERESULTS             351
00153 #define IDM_CLEARNOTIFYWINDOW           410
00154 #define IDC_LISTVIEW                    1012
00155 #define IDL_VALUES                      1033
00156 #define IDC_LISTBOX                     1037
00157 #define IDC_SCROLLBAR                   1038
00158 #define IDE_DATASOURCE                  1040
00159 #define IDT_RESTRICTION1                1049
00160 #define IDE_RESTRICTION1                1050
00161 #define IDE_RESTRICTION2                1051
00162 #define IDE_RESTRICTION7                1052
00163 #define IDE_RESTRICTION3                1053
00164 #define IDE_RESTRICTION4                1054
00165 #define IDE_RESTRICTION5                1055
00166 #define IDE_RESTRICTION6                1056
00167 #define IDT_RESTRICTION2                1057
00168 #define IDT_RESTRICTION3                1058
00169 #define IDT_RESTRICTION4                1059
00170 #define IDT_RESTRICTION5                1060
00171 #define IDT_RESTRICTION6                1061
00172 #define IDT_RESTRICTION7                1062
00173 #define IDC_RESTRICTION1                1063
00174 #define IDC_RESTRICTION5                1064
00175 #define IDC_RESTRICTION7                1065
00176 #define IDC_RESTRICTION6                1066
00177 #define IDC_RESTRICTION3                1067
00178 #define IDC_RESTRICTION2                1068
00179 #define IDC_RESTRICTION4                1069
00180 #define IDL_PROPERTY                    1077
00181 #define IDC_PROPEDIT_VALUE              1079
00182 #define IDC_PROPEDIT_TYPE               1080
00183 #define IDE_PROPEDIT_NAME               1081
00184 #define IDE_PROPERTY_HELP               1082
00185 #define IDC_PROPEDIT_OPTIONS            1083
00186 #define IDE_PROPINFO_FLAGS              1085
00187 #define IDE_PROPINFO_VALUE              1086
00188 #define IDC_SCHEMAS                     1090
00189 #define IDL_NAMES                       1094
00190 #define IDC_ISOLEVEL                    1095
00191 #define IDC_RETAINING                   1096
00192 #define IDC_ASYNCH                      1097
00193 #define IDC_XACTTC                      1099
00194 #define IDB_INPROC_SERVER               1104
00195 #define IDB_LOCAL_SERVER                1105
00196 #define IDB_REMOTE_SERVER               1106
00197 #define IDB_INPROC_HANDLER              1107
00198 #define IDB_USEPROPERTIES               1108
00199 #define IDB_USERESTRICTIONS             1109
00200 #define IDB_USEOPTCOLUMNS               1109
00201 #define IDB_CURSORENGINE                1109
00202 #define IDC_FROMTYPE                    1110
00203 #define IDC_TOTYPE                      1111
00204 #define IDB_FROM_BYREF                  1112
00205 #define IDB_FROM_ARRAY                  1113
00206 #define IDB_FROM_VECTOR                 1114
00207 #define IDB_TO_BYREF                    1115
00208 #define IDB_TO_ARRAY                    1116
00209 #define IDB_TO_VECTOR                   1117
00210 #define IDB_OWNED_PROVIDER              1118
00211 #define IDT_RESULT                      1119
00212 #define IDC_NAME                        1119
00213 #define IDT_HELPMSG                     1125
00214 #define IDB_INIT_SETPROPERTIES          1128
00215 #define IDB_INIT_INITIALIZE             1129
00216 #define IDB_QI_MANDATORY                1130
00217 #define IDB_QI_OPTIONAL                 1131
00218 #define IDC_INTERFACE                   1132
00219 #define IDC_LCID                        1133
00220 #define IDC_INTERFACESTREAM             1133
00221 #define IDC_RESERVED                    1133
00222 #define IDE_TIMEOUT                     1134
00223 #define IDE_DESCRIPTION                 1135
00224 #define IDB_MOREPROPERTIES              1138
00225 #define IDC_PROMPT                      1152
00226 #define IDB_CACHEINFO                   1155
00227 #define IDE_INTEGRATED                  1158
00228 #define IDB_PERSISTINFO                 1159
00229 #define IDB_ENCRYPTINFO                 1160
00230 #define IDC_IMPERSONATE                 1161
00231 #define IDC_PROTECTION                  1162
00232 #define IDL_MODE                        1163
00233 #define IDC_LOCALE                      1164
00234 #define IDB_MASKPASSWORD                1166
00235 #define IDB_ENCRYPTPASSWORD             1167
00236 #define IDT_PROVIDERFILENAME            1169
00237 #define IDT_PROVIDERDESC                1170
00238 #define IDT_PROVIDERVERSION             1171
00239 #define IDT_DBMS                        1173
00240 #define IDT_DATASOURCE                  1175
00241 #define IDT_CATALOG                     1176
00242 #define IDT_THREADMODEL                 1177
00243 #define IDB_DEFAULTS                    1178
00244 #define IDT_READONLY                    1178
00245 #define IDB_BROWSE_LOCATION             1179
00246 #define IDB_BROWSE_DATASOURCE           1180
00247 #define IDB_TEST                        1182
00248 #define IDC_TREEVIEW                    1186
00249 #define IDT_COLUMNNAME                  1190
00250 #define IDB_DISPLAYTREE                 1191
00251 #define IDC_CONFIG                      1192
00252 #define IDB_CONFIG_SAVE                 1195
00253 #define IDB_CONFIG_REMOVE               1196
00254 #define IDL_LISTVIEW                    1199
00255 #define IDB_CONNECT                     1200
00256 #define IDB_BROWSE_INTEGRATED           1201
00257 #define IDB_BROWSE_PROVSTRING           1202
00258 #define IDI_ABOUTICON                   1203
00259 #define IDB_BIND_BOOKMARK               1209
00260 #define IDB_DISPLAY_HEXADECIMAL         1210
00261 #define IDB_DISPLAY_OLEDB               1211
00262 #define IDB_BLOB_INLINE                 1212
00263 #define IDB_USE_TRACEPROVIDER           1212
00264 #define IDB_DISPLAY_ADDREF              1213
00265 #define IDB_BLOB_ISEQSTREAM             1213
00266 #define IDB_DISPLAY_RELEASE             1214
00267 #define IDB_BLOB_ILOCKBYTES             1214
00268 #define IDB_DISPLAY_QI                  1215
00269 #define IDB_BLOB_ISTORAGE               1215
00270 #define IDB_BLOB_ISTREAM                1216
00271 #define IDB_ERRORINFO_ALWAYS            1218
00272 #define IDB_ERRORINFO_FAILURE           1219
00273 #define IDB_ERRORINFO_NEVER             1220
00274 #define IDB_HRESULT_ALWAYS              1221
00275 #define IDB_HRESULT_FAILURE             1222
00276 #define IDB_HRESULT_NEVER               1223
00277 #define IDB_REFCOUNT_FAILURE            1224
00278 #define IDB_IMALLOC_SPY                 1225
00279 #define IDB_IMALLOC_ALLOCS              1226
00280 #define IDB_BREAKID                     1228
00281 #define IDE_TABLEID                     1232
00282 #define IDE_PRECISION                   1233
00283 #define IDE_INDEXID                     1233
00284 #define IDE_REFERENCEDTABLE             1233
00285 #define IDE_SCALE                       1234
00286 #define IDE_NewIndexID                  1234
00287 #define IDC_TYPE                        1235
00288 #define IDE_CONSTEXT                    1235
00289 #define IDE_SIZE                        1236
00290 #define IDE_ORDINAL                     1237
00291 #define IDE_COLUMN                      1237
00292 #define IDE_DATA                        1238
00293 #define IDL_PARAMNAMES                  1240
00294 #define IDL_PARAMVALUES                 1241
00295 #define IDB_DISPLAY_ROWSAFFECTED        1243
00296 #define IDC_DEFAULTDIALECT              1246
00297 #define IDC_DIALECT                     1246
00298 #define IDB_RELEASE_OPENOBJECTS         1247
00299 #define IDB_SETDEFAULTPROPS             1249
00300 #define IDB_ALWAYSRELEASEROWS           1250
00301 #define IDB_HRESULT_NOERRORINFO         1251
00302 #define IDT_STATIC                      1252
00303 #define IDT_STATIC2                     1253
00304 #define IDT_STATIC3                     1254
00305 #define IDB_DISPLAY_PROMPTVETO          1254
00306 #define IDB_SETPROPERTIES               1255
00307 #define IDT_STATIC5                     1255
00308 #define IDB_CLEARALL                    1256
00309 #define IDT_STATIC4                     1256
00310 #define IDB_USEPARAMS                   1257
00311 #define IDT_STATIC6                     1257
00312 #define IDB_SETPARAMS                   1258
00313 #define IDT_STATIC9                     1258
00314 #define IDT_STATIC10                    1259
00315 #define IDC_COLUMN                      1260
00316 #define IDT_STATIC11                    1260
00317 #define IDE_VALUE                       1261
00318 #define IDC_COMPAREOP                   1262
00319 #define IDE_COUNT                       1263
00320 #define IDB_USESERVICECOMP              1265
00321 #define IDC_PROPSET                     1266
00322 #define IDL_COLUMNS                     1267
00323 #define IDB_UNICODE                     1271
00324 #define IDB_BROWSE_PROVIDER             1272
00325 #define IDL_CONVFLAGS                   1275
00326 #define IDB_DISPLAY_IDBASYNCHNOTIFY     1276
00327 #define IDB_DISPLAY_IROWSETNOTIFY       1277
00328 #define IDB_DISPLAY_IROWPOSITIONCHANGE  1278
00329 #define IDB_SETCOMMANDTEXT              1280
00330 #define IDC_SPIN_OFFSET                 1282
00331 #define IDC_SPIN_COUNT                  1283
00332 #define IDE_OFFSET                      1285
00333 #define IDC_CATALOG                     1286
00334 #define IDB_SHOWSUPPORTED               1287
00335 #define IDE_COMMANDTEXT                 1288
00336 #define IDE_REMOTESERVER                1290
00337 #define IDC_TRANSACTION                 1292
00338 #define IDC_COLUMNS                     1293
00339 #define IDC_OBJECTTYPE                  1294
00340 #define IDE_URL                         1295
00341 #define IDL_BINDFLAGS                   1296
00342 #define IDE_COLNAME                     1297
00343 #define IDL_COLUMNDESC                  1298
00344 #define IDB_CASESENSITIVE               1298
00345 #define IDB_ROWSETPROPERTIES            1299
00346 #define IDB_CASEINSENSITIVE             1299
00347 #define IDE_MAXLENGTH                   1299
00348 #define IDC_ORDER                       1300
00349 #define IDL_INDEXCOLUMNDESC             1301
00350 #define IDB_INDEXPROPERTIES             1302
00351 #define IDE_COLUMNID                    1303
00352 #define IDC_TYPENAME                    1304
00353 #define IDE_ISCO_DESTINATION            1304
00354 #define IDB_COLPROP                     1305
00355 #define IDC_CONSTYPE                    1305
00356 #define IDC_DATATYPE                    1306
00357 #define IDT_STATIC7                     1311
00358 #define IDT_STATIC8                     1312
00359 #define IDC_Aggregate                   1314
00360 #define IDB_EXISTING_DSO                1315
00361 #define IDB_BIND_STATUS                 1320
00362 #define IDB_BIND_LENGTH                 1321
00363 #define IDB_BIND_VALUE                  1322
00364 #define IDC_ISCO_FLAGS                  1323
00365 #define IDC_URLs                        1324
00366 #define IDE_ISCO_SOURCE                 1326
00367 #define IDL_URLs                        1327
00368 #define IDL_FLAGS                       1328
00369 #define IDE_DIRECTORY                   1329
00370 #define IDB_DIRECTORY                   1330
00371 #define IDE_FILENAME                    1331
00372 #define IDB_FILENAME                    1332
00373 #define IDL_OPTIONS                     1333
00374 #define IDL_TYPEFILTER                  1334
00375 #define IDL_PROVIDERFILTER              1335
00376 #define IDB_ADDDEFINEDPROPS             1337
00377 #define IDE_ROWSTOFETCH                 1338
00378 #define IDB_DEFAULTFETCH                1339
00379 #define IDB_ROWSTOFETCH                 1340
00380 #define IDB_AGGREGATION                 1342
00381 #define IDB_OUTPUT                      1343
00382 #define IDB_AUTOSAVE                    1344
00383 #define IDT_VALUE                       1345
00384 #define IDB_HIDDENCOLUMNS               1347
00385 #define IDB_FETCHDATA                   1348
00386 #define IDE_INITSTRING                  1349
00387 #define IDE_COMMANDID                   1354
00388 #define IDB_MSDADC_ONLY                 1356
00389 #define IDC_BINDINGTYPE                 1357
00390 #define IDE_BREAKID                     1358
00391 #define IDB_XML                         1359
00392 #define IDB_ADTG                        1360
00393 #define IDC_RECORD                      1360
00394 #define IDC_DEFERRABILITY               1369
00395 #define IDC_COLLIST                     1370
00396 #define IDC_COLNAME                     1371
00397 #define IDC_ADDCOL                      1372
00398 #define IDB_ADDCOL                      1372
00399 #define IDC_DELCOL                      1373
00400 #define IDB_DELCOL                      1373
00401 #define IDC_MATCHTYPE                   1374
00402 #define IDC_UPDATERULE                  1375
00403 #define IDC_DELETERULE                  1376
00404 #define IDE_CONSNAME                    1377
00405 #define IDC_FKCOLLIST                   1378
00406 #define IDC_FKCOLNAME                   1379
00407 #define IDE_FKCOLNAME                   1379
00408 #define IDC_ADDFKCOL                    1380
00409 #define IDB_ADDFKCOL                    1380
00410 #define IDC_DELFKCOL                    1381
00411 #define IDB_DELFKCOL                    1381
00412 #define IDE_CONSTRAINTID                1382
00413 #define IDC_ChangeIndexID               1383
00414 #define IDB_TABLEPROPERTIES             1384
00415 #define IDE_NewTableID                  1385
00416 #define IDL_CDFLAGS                     1386
00417 #define IDC_COMBO1                      1388
00418 #define IDC_REFIID                      1388
00419 #define IDC_RADIO_SETTEXT               1389
00420 #define IDC_RADIO_SETSTREAM             1390
00421 #define IDB_SETCOMMANDSTREAM            1390
00422 #define IDB_SETCOMMANDNONE              1391
00423 #define IDB_XML_BROWSER                 1392
00424 #define IDP_TABS                        1393
00425 #define IDB_XML_DOM                     1394
00426 #define IDB_XML_EDITBOX                 1395
00427 #define IDM_HELP                        40013
00428 #define IDM_REFRESH                     40015
00429 #define IDM_IDBINITIALIZE_INITIALIZE    40043
00430 #define IDM_IDBINITIALIZE_UNINITIALIZE  40044
00431 #define IDM_OPENROWSET                  40056
00432 #define IDM_IDBCREATECOMMAND_CREATECOMMAND 40057
00433 #define IDM_EXECUTE                     40070
00434 #define IDM_COMMAND_GETDBSESSION        40071
00435 #define IDM_SETCOMMANDTEXT              40073
00436 #define IDM_GETCOMMANDTEXT              40074
00437 #define IDM_DATASET_GETNEXTAXISROW      40075
00438 #define IDM_ADDREFROWS                  40091
00439 #define IDM_GETDATA                     40092
00440 #define IDM_GETNEXTROWS                 40093
00441 #define IDM_RELEASEROWS                 40094
00442 #define IDM_RESTARTPOSITION             40096
00443 #define IDM_DELETEROWS                  40103
00444 #define IDM_INSERTROW                   40104
00445 #define IDM_SETDATA                     40105
00446 #define IDM_GETORIGINALDATA             40106
00447 #define IDM_GETPENDINGROWS              40107
00448 #define IDM_GETROWSTATUS                40108
00449 #define IDM_UNDO                        40109
00450 #define IDM_UPDATE                      40110
00451 #define IDM_GETSCHEMAS                  40111
00452 #define IDM_ISOURCESROWSET_GETSOURCESROWSET 40117
00453 #define IDM_IDBCREATESESSION_CREATESESSION 40149
00454 #define IDM_EXIT                        40150
00455 #define IDM_TILEVERTICAL                40155
00456 #define IDM_CLOSEWINDOW                 40156
00457 #define IDM_NEXTWINDOW                  40157
00458 #define IDM_PREVWINDOW                  40158
00459 #define IDM_ICOLUMNSROWSET_GETAVAILABLECOLUMNS 40160
00460 #define IDM_ICOLUMNSROWSET_GETCOLUMNSROWSET 40161
00461 #define IDM_INVALID                     40162
00462 #define IDM_ERRORRECORDS                40163
00463 #define IDM_DISPLAYALLERRORS            40166
00464 #define IDM_IDBPROPERTIES_GETPROPERTYINFO 40169
00465 #define IDM_IDBPROPERTIES_GETPROPERTIES 40170
00466 #define IDM_ISESSIONPROPERTIES_GETPROPERTIES 40174
00467 #define IDM_ISESSIONPROPERTIES_SETPROPERTIES 40175
00468 #define IDM_COMMAND_SETPROPERTIES       40261
00469 #define IDM_ITRANSACTIONOBJECT_GETTRANSACTIONOBJECT 40272
00470 #define IDM_ISUPPORTERRORINFO           40275
00471 #define IDM_IPERSIST_GETCLASSID         40281
00472 #define IDM_GETDATASOURCE               40282
00473 #define IDM_TABLE_ADDCOLUMN             40283
00474 #define IDM_TABLE_CREATETABLE           40284
00475 #define IDM_TABLE_DROPCOLUMN            40285
00476 #define IDM_TABLE_DROPTABLE             40286
00477 #define IDM_INDEX_CREATEINDEX           40287
00478 #define IDM_INDEX_DROPINDEX             40288
00479 #define IDM_IDBINFO_GETKEYWORDS         40299
00480 #define IDM_IDBINFO_GETLITERALINFO      40300
00481 #define IDM_IPERSISTFILE_ISDIRTY        40301
00482 #define IDM_IPERSISTFILE_LOAD           40302
00483 #define IDM_IPERSISTFILE_SAVE           40303
00484 #define IDM_IPERSISTFILE_SAVECOMPLETED  40304
00485 #define IDM_IPERSISTFILE_GETCURFILE     40305
00486 #define IDM_DATASET_GETAXISINFO         40318
00487 #define IDM_DATASET_GETAXISROWSET       40319
00488 #define IDM_DATASET_GETCELLDATA         40320
00489 #define IDM_IUNKNOWN_RELEASE            40322
00490 #define IDCOMBO_AXIS                    40323
00491 #define IDC_DIMENSIONS                  40324
00492 #define IDC_COORDINATES                 40325
00493 #define IDL_AXISINFO                    40326
00494 #define IDM_DATASET_FREEAXISINFO        40327
00495 #define IDM_BINDING_VARIANT             40432
00496 #define IDM_IROWPOS_CLEARROWPOSITION    40434
00497 #define IDM_IROWPOS_SETROWPOSITION      40435
00498 #define IDM_IROWPOS_GETROWPOSITION      40436
00499 #define IDM_IROWPOS_INITIALIZE          40439
00500 #define IDM_IROWPOS_GETROWSET           40440
00501 #define IDM_OPTIONS                     40442
00502 #define IDM_IROWSETPROPERTIES           40444
00503 #define IDM_IROWSET_GETPROPERTIES       40447
00504 #define IDM_GETREFERENCEDROWSET         40448
00505 #define IDM_GETSPECIFICATION            40449
00506 #define IDM_COMMAND_GETPROPERTIES       40450
00507 #define IDM_IDBPROPERTIES_SETPROPERTIES 40453
00508 #define IDM_GETSCHEMAROWSET             40454
00509 #define IDM_COMMANDPREPARE              40462
00510 #define IDM_COMMANDUNPREPARE            40463
00511 #define IDM_ICOLUMNSINFO_GETCOLUMNINFO  40464
00512 #define IDM_ICOLUMNSINFO_MAPCOLUMNIDS   40465
00513 #define IDM_CLEAREDITWINDOW             40471
00514 #define IDM_RELEASEALLROWS              40474
00515 #define IDM_ICONVERTTYPE_CANCONVERT     40475
00516 #define IDM_GETVISIBLEDATA              40477
00517 #define IDM_RESYNCHROWS                 40478
00518 #define IDM_IROWSETNOTIFY_S_OK          40486
00519 #define IDM_IROWSETNOTIFY_S_FALSE       40487
00520 #define IDM_IROWSETNOTIFY_E_FAIL        40490
00521 #define IDM_IROWPOSITION_S_OK           40491
00522 #define IDM_IROWPOSITION_S_FALSE        40492
00523 #define IDM_IROWPOSITION_E_FAIL         40495
00524 #define IDM_IROWSETNOTIFY_S_UNWANTEDPHASE 40496
00525 #define IDM_IROWSETNOTIFY_S_UNWANTEDREASON 40497
00526 #define IDM_IROWPOSITION_S_UNWANTEDPHASE 40498
00527 #define IDM_IROWPOSITION_S_UNWANTEDREASON 40499
00528 #define IDM_FULLDISCONNECT              40502
00529 #define IDM_FULLCONNECT                 40503
00530 #define IDM_COMMAND_CLEARCOMMAND        40507
00531 #define IDM_IUNKNOWN_RELEASEALL         40509
00532 #define IDM_IDBASYNCHNOTIFY_S_OK        40516
00533 #define IDM_IDBASYNCHNOTIFY_S_FALSE     40517
00534 #define IDM_IDBASYNCHNOTIFY_S_UNWANTEDPHASE 40518
00535 #define IDM_IDBASYNCHNOTIFY_S_UNWANTEDREASON 40519
00536 #define IDM_IDBASYNCHNOTIFY_E_FAIL      40520
00537 #define IDM_IDBASYNCHSTATUS_ABORT       40521
00538 #define IDM_IDBASYNCHSTATUS_GETSTATUS   40522
00539 #define IDM_DBSTATUS_S_OK               40528
00540 #define IDM_DBSTATUS_S_ISNULL           40529
00541 #define IDM_DBSTATUS_S_DEFAULT          40530
00542 #define IDM_ITRANSACTIONLOCAL_GETOPTIONSOBJECT 40531
00543 #define IDM_ITRANSACTIONJOIN_GETOPTIONSOBJECT 40532
00544 #define IDM_ITRANSACTIONJOIN_JOINTRANSACTION 40533
00545 #define IDM_ITRANSACTION_GETTRANSACTIONINFO 40536
00546 #define IDM_ITRANSACTIONOPTIONS_GETOPTIONS 40537
00547 #define IDM_ITRANSACTIONOPTIONS_SETOPTIONS 40538
00548 #define IDM_ITRANSACTIONLOCAL_STARTTRANSACTION 40539
00549 #define IDM_PROVIDERINFO                40542
00550 #define IDM_BROWSE_TABLENAME            40544
00551 #define IDM_COPYTEXT                    40549
00552 #define IDM_BROWSE_FILE                 40550
00553 #define IDM_BROWSE_ENUM                 40551
00554 #define IDM_DISPLAY_HEX                 40554
00555 #define IDM_ACCESSOR_ADDREF             40555
00556 #define IDM_IACCESSOR_GETBINDINGS       40560
00557 #define IDM_IACCESSOR_CREATEACCESSOR    40561
00558 #define IDM_IACCESSOR_ADDREFACCESSOR    40562
00559 #define IDM_IACCESSOR_RELEASEACCESSOR   40563
00560 #define IDM_GETPARAMETERINFO            40568
00561 #define IDM_MAPPARAMETERNAMES           40569
00562 #define IDM_SETPARAMETERINFO            40570
00563 #define IDM_COMMAND_CANCEL              40572
00564 #define IDM_DATASOURCE_ADDREF           40573
00565 #define IDM_IUNKNOWN_QUERYINTERFACE     40575
00566 #define IDM_SESSION_ADDREF              40577
00567 #define IDM_COMMAND_ADDREF              40580
00568 #define IDM_ROWSET_ADDREF               40583
00569 #define IDM_TRANSACTION_ADDREF          40586
00570 #define IDM_ENUMERATOR_ADDREF           40589
00571 #define IDM_ERROR_ADDREF                40592
00572 #define IDM_ROWPOS_ADDREF               40595
00573 #define IDM_GETERRORINFO                40606
00574 #define IDM_SETERRORINFO                40607
00575 #define IDM_ERRORINFO_GETDESCRIPTION    40611
00576 #define IDM_ERRORINFO_GETGUID           40612
00577 #define IDM_ERRORINFO_GETHELPCONTEXT    40613
00578 #define IDM_ERRORINFO_GETHELPFILE       40614
00579 #define IDM_ERRORINFO_GETSOURCE         40615
00580 #define IDM_ERRORRECORDS_ADDERRORRECORD 40616
00581 #define IDM_ERRORRECORDS_GETBASICERRORINFO 40617
00582 #define IDM_ERRORRECORDS_GETCUSTOMERROROBJECT 40618
00583 #define IDM_ERRORRECORDS_GETERRORINFO   40619
00584 #define IDM_ERRORRECORDS_GETERRORPARAMETERS 40620
00585 #define IDM_ERRORRECORDS_GETRECORDCOUNT 40621
00586 #define IDM_SQLERRORINFO_GETSQLINFO     40622
00587 #define IDM_PARSEDISPLAYNAME            40623
00588 #define IDM_IROWSETLOCATE_COMPARE       40626
00589 #define IDM_IROWSETLOCATE_GETROWSBYBOOKMARK 40628
00590 #define IDM_IROWSETLOCATE_GETROWSAT     40629
00591 #define IDM_IROWSETLOCATE_HASH          40630
00592 #define IDM_IROWSETINDENTITY_ISSAMEROW  40631
00593 #define IDM_IROWSETSCROLL_GETAPPROXIMATEPOSITION 40632
00594 #define IDM_IROWSETSCROLL_GETROWSATRATIO 40633
00595 #define IDM_IROWSETFIND_FINDNEXTROW     40634
00596 #define IDM_CHAPTERED_ADDREFCHAPTER     40635
00597 #define IDM_CHAPTERED_RELEASECHAPTER    40636
00598 #define IDM_DISPLAYERRORINFO            40643
00599 #define IDM_ICPC_FINDCONNECTIONPOINT    40644
00600 #define IDM_ICPC_ENUMCONNECTIONPOINTS   40645
00601 #define IDM_ICONNECTIONPOINT_GETCONNECTIONINTERFACE 40649
00602 #define IDM_ICONNECTIONPOINT_GETCONNECTIONPOINTCONTAINER 40650
00603 #define IDM_ICONNECTIONPOINT_ADVISE     40651
00604 #define IDM_ICONNECTIONPOINT_UNADVISE   40652
00605 #define IDM_ICONNECTIONPOINT_ENUMCONNECTIONS 40653
00606 #define IDM_IMULTIPLERESULTS_GETRESULT  40668
00607 #define IDM_IROWSETVIEW_CREATEVIEW      40672
00608 #define IDM_IROWSETVIEW_GETVIEW         40673
00609 #define IDM_MULTIPLERESULTS_ADDREF      40675
00610 #define IDM_ITRANSACTION_ABORT          40685
00611 #define IDM_ITRANSACTION_COMMIT         40686
00612 #define IDM_IDATAINITIALIZE_CREATEDBINSTANCE 40689
00613 #define IDM_IDATAINITIALIZE_CREATEDBINSTANCEEX 40690
00614 #define IDM_IDATAINITIALIZE_GETDATASOURCE 40691
00615 #define IDM_IDATAINITIALIZE_GETINITIALIZATIONSTRING 40692
00616 #define IDM_IDATAINITIALIZE_LOADSTRINGFROMSTORAGE 40693
00617 #define IDM_IDBPROMPTINITIALIZE_PROMPTFILENAME 40696
00618 #define IDM_IDATAINITIALIZE_WRITESTRINGTOSTORAGE 40697
00619 #define IDM_COPYEDITWINDOW              40698
00620 #define IDM_CUTEDITWINDOW               40699
00621 #define IDM_PASTEEDITWINDOW             40700
00622 #define IDM_COPYNOTIFYWINDOW            40702
00623 #define IDM_IDBPROMPTINITIALIZE_PROMPTDATASOURCE 40707
00624 #define IDM_IDATASOURCEADMIN_CREATEDATASOURCE 40708
00625 #define IDM_IDATASOURCEADMIN_GETCREATIONPROPERTIES 40710
00626 #define IDM_IDATASOURCEADMIN_MODIFYDATASOURCE 40711
00627 #define IDM_IDATASOURCEADMIN_DESTROYDATASOURCE 40712
00628 #define IDM_ITRANSACTIONDISPENSOR_BEGINTRANSACTION 40714
00629 #define IDM_IDATAINITIALIZE_GETINITIALIZATIONSTRING_NOPASSWORD 40725
00630 #define IDM_ITRANSACTION_RELEASETRANSACTION 40726
00631 #define IDM_GETROWFROMHROW              40733
00632 #define IDM_GETURLFROMHROW              40734
00633 #define IDM_ROW_ADDREF                  40735
00634 #define IDM_ICOLUMNSINFO2_GETRESTRICTEDCOLUMNINFO 40751
00635 #define IDM_IROW_GETCOLUMNS             40752
00636 #define IDM_IROW_GETSOURCEROWSET        40754
00637 #define IDM_IROW_OPEN                   40755
00638 #define IDM_IGETSESSION_GETSESSION      40756
00639 #define IDM_IROW_SETCOLUMNS             40761
00640 #define IDM_IROW_DELETECOLUMNS          40762
00641 #define IDM_IROW_ADDCOLUMNS             40763
00642 #define IDM_ISCOPEDOPERATIONS_COPY      40765
00643 #define IDM_ISCOPEDOPERATIONS_DELETE    40766
00644 #define IDM_ISCOPEDOPERATIONS_MOVE      40767
00645 #define IDM_ISCOPEDOPERATIONS_OPENROWSET 40768
00646 #define IDM_IBINDRESOURCE_BIND          40771
00647 #define IDM_ICREATEROW_CREATEROW        40773
00648 #define IDM_IDBBINDERPROPERTIES_RESET   40777
00649 #define IDM_IREGISTERPROVIDER_GETURLMAPPING 40779
00650 #define IDM_IREGISTERPROVIDER_SETURLMAPPING 40780
00651 #define IDM_IREGISTERPROVIDER_UNREGISTERPROVIDER 40781
00652 #define IDM_BINDER_ADDREF               40782
00653 #define IDM_DBSTATUS_S_IGNORE           40787
00654 #define IDM_NOTIFY_S_OK                 40792
00655 #define IDM_NOTIFY_S_FALSE              40793
00656 #define IDM_NOTIFY_S_UNWANTEDREASON     40794
00657 #define IDM_NOTIFY_S_UNWANTEDPHASE      40795
00658 #define IDM_NOTIFY_E_FAIL               40796
00659 #define IDM_MSPERSIST_ROWSET_SAVE       40797
00660 #define IDM_MSPERSIST_ROWSET_LOAD       40798
00661 #define IDM_IROWSET_CURSORENGINE        40800
00662 #define IDM_CREATE_ROOTBINDER           40819
00663 #define IDM_GETLASTVISIBLEDATA          40826
00664 #define IDM_REFRESHVISIBLEDATA          40828
00665 #define IDM_IROWSETLOCATE_GETDATA       40829
00666 #define IDM_IROWSETSCROLL_GETDATA       40830
00667 #define IDM_COMMANDTEXT_EXECUTE         40831
00668 #define IDM_TRACEWINDOW                 40832
00669 #define IDM_OBJECTSWINDOW               40833
00670 #define IDM_STREAM_ADDREF               40836
00671 #define IDM_ISERVICEPROVIDER            40840
00672 #define IDM_UNKNOWN_ADDREF              40843
00673 #define IDM_ISEQSTREAM_READ             40848
00674 #define IDM_ISEQSTREAM_WRITE            40849
00675 #define IDM_ISTREAM_SEEK                40850
00676 #define IDM_ISTREAM_SETSIZE             40851
00677 #define IDM_ISTREAM_COPYTO              40852
00678 #define IDM_ISTREAM_COMMIT              40853
00679 #define IDM_ISTREAM_REVERT              40854
00680 #define IDM_ISTREAM_LOCKREGION          40855
00681 #define IDM_ISTREAM_UNLOCKREGION        40856
00682 #define IDM_ISTREAM_STAT                40857
00683 #define IDM_ISTREAM_CLONE               40858
00684 #define IDM_ILOCKBYTES_READAT           40859
00685 #define IDM_ILOCKBYTES_WRITE            40860
00686 #define IDM_ILOCKBYTES_FLUSH            40861
00687 #define IDM_ILOCKBYTES_SETSIZE          40862
00688 #define IDM_ILOCKBYTES_LOCKREGION       40863
00689 #define IDM_ILOCKBYTES_UNLOCKREGION     40864
00690 #define IDM_ILOCKBYTES_STAT             40865
00691 #define IDM_ISTREAM_READ                40866
00692 #define IDM_ISTREAM_WRITE               40867
00693 #define IDM_IUNKNOWN_AUTOQI             40869
00694 #define IDM_DATASET_ADDREF              40882
00695 #define IDM_SERVICECOMP_ADDREF          40886
00696 #define IDM_POOLMNGR_ENUMPOOLS          40900
00697 #define IDM_POOLINFO_ADDREF             40901
00698 #define IDM_POOLMNGR_REFRESH            40907
00699 #define IDM_IPOOLINFO_GETCOUNT          40908
00700 #define IDM_IPOOLINFO_SETRETRYTIMEOUT   40911
00701 #define IDM_IPOOLINFO_SETPOOLTIMEOUT    40912
00702 #define IDM_IPOOLINFO_GETPOOLTIMEOUT    40913
00703 #define IDM_IPOOLINFO_GETRETRYTIMEOUT   40914
00704 #define IDM_IPOOLINFO_GETPOOLID         40915
00705 #define IDM_IPOOLINFO_GETPROTOTYPE      40916
00706 #define IDM_IPOOLINFO_REFRESH           40917
00707 #define IDM_IGETPOOL_GETPOOL            40918
00708 #define IDM_IGETPOOL_GETPOOLSTATE       40919
00709 #define IDM_AUTOPOSITION                40923
00710 #define IDM_CREATEFILEMONIKER           40924
00711 #define IDM_COMMANDPERSIST_DELETECOMMAND 40925
00712 #define IDM_COMMANDPERSIST_GETCURRENTCOMMAND 40926
00713 #define IDM_COMMANDPERSIST_LOADCOMMAND  40927
00714 #define IDM_COMMANDPERSIST_SAVECOMMAND  40928
00715 #define IDM_TRANSACTIONOPTIONS_ADDREF   40966
00716 #define IDM_RELEASE_JOINEDTRANSACTION   40970
00717 #define IDM_ITRANSACTIONJOIN_RELEASETRANSACTION 40971
00718 #define IDM_CONNECTIONPOINT_ADDREF      40972
00719 #define IDM_CREATE_SERVICECOMPONENTS    40973
00720 #define IDM_CREATE_ROOTENUMERATOR       40974
00721 #define IDM_DATALINKS_ADDREF            40975
00722 #define IDM_CREATE_DATALINKS            40976
00723 #define IDM_IDBPROMPTINITIALIZE_PROMPTDATASOURCE_ADVANCED 40977
00724 #define IDM_IDBPROMPTINITIALIZE_PROMPTFILENAME_ADVANCED 40979
00725 #define IDM_CREATE_ROWPOSITION          40981
00726 #define IDM_CUSTOMERROR_ADDREF          40982
00727 #define IDM_IMDFIND_FINDCELL            40983
00728 #define IDM_IMDFIND_FINDTUPEL           40984
00729 #define IDM_IMDRANGEROWSET_GETRANGEROWSET 40985
00730 #define IDM_DATASET_GETSPECIFICATION    40986
00731 #define IDM_TABLE_ADDCONSTRAINT         40987
00732 #define IDM_TABLE_CREATETABLEWITHCONSTRAINTS 40988
00733 #define IDM_TABLE_DROPCONSTRAINT        40989
00734 #define IDM_INDEX_ALTERINDEX            40990
00735 #define IDM_TABLE_ALTERTABLE            40991
00736 #define IDM_TABLE_ALTERCOLUMN           40992
00737 #define IDM_GETCOMMANDSTREAM            40993
00738 #define IDM_SETCOMMANDSTREAM            40994
00739 #define IDM_IUNKNOWN_RELEASECHILDREN    40995
00740 #define IDM_IROWSETBOOKMARK_POSITIONONBOOKMARK 40996
00741 #define IDC_STATIC                      -1
00742 #define IDT_FILEDESC                    65535
00743 #define IDT_FILEINFO                    65535
00744
00745 // Next default values for new objects
00746 //
00747 #ifdef APSTUDIO_INVOKED
00748 #ifndef APSTUDIO_READONLY_SYMBOLS
00749 #define _APS_NEXT_RESOURCE_VALUE        352
00750 #define _APS_NEXT_COMMAND_VALUE         40997
00751 #define _APS_NEXT_CONTROL_VALUE         1394
00752 #define _APS_NEXT_SYMED_VALUE           140
00753 #endif
00754 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/Policy.Cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

Policy.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        policy.cpp
00007 //
00008 // Contents:    Cert Server Policy Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013 #pragma hdrstop
00014
00015 #include <assert.h>
00016 #include "celibw2k.h"
00017 #include "policy.h"
00018 #include "module.h"
00019
00020 #ifndef szOID_CERTTYPE_EXTENSION
00021 # define szOID_CERTTYPE_EXTENSION szOID_ENROLL_CERTTYPE_EXTENSION
00022 #endif
00023
00024 #ifndef wszCERTTYPE_SUBORDINATE_CA
00025 # define wszCERTTYPE_SUBORDINATE_CA L"SubCA"
00026 #endif
00027
00028 BOOL fDebug = DBG_CERTSRV;
00029 extern HINSTANCE g_hInstance;
00030
00031 #ifndef DBG_CERTSRV
00032 #error -- DBG_CERTSRV not defined!
00033 #endif
00034
00035 #ifndef ISSCERT_FILEURL
00036 # define ISSCERT_FILEURL    ISSCERT_FILEURL_OLD
00037 # define ISSCERT_FTPURL     ISSCERT_FTPURL_OLD
00038 # define ISSCERT_HTTPURL    ISSCERT_HTTPURL_OLD
00039 # define ISSCERT_LDAPURL    ISSCERT_LDAPURL_OLD
00040 # define REVEXT_CDPFILEURL    REVEXT_CDPFILEURL_OLD
00041 # define REVEXT_CDPFTPURL   REVEXT_CDPFTPURL_OLD
00042 # define REVEXT_CDPHTTPURL    REVEXT_CDPHTTPURL_OLD
00043 # define REVEXT_CDPLDAPURL    REVEXT_CDPLDAPURL_OLD
00044 # define wszREGFILEISSUERCERTURL  wszREGFILEISSUERCERTURL_OLD
00045 # define wszREGFILEREVOCATIONCRLURL wszREGFILEREVOCATIONCRLURL_OLD
00046 # define wszREGFTPISSUERCERTURL   wszREGFTPISSUERCERTURL_OLD
00047 # define wszREGFTPREVOCATIONCRLURL  wszREGFTPREVOCATIONCRLURL_OLD
00048 # define wszREGISSUERCERTURL    wszREGISSUERCERTURL_OLD
00049 # define wszREGLDAPISSUERCERTURL  wszREGLDAPISSUERCERTURL_OLD
00050 # define wszREGLDAPREVOCATIONCRLURL wszREGLDAPREVOCATIONCRLURL_OLD
00051 # define wszREGREVOCATIONCRLURL   wszREGREVOCATIONCRLURL_OLD
00052 #endif
00053
00054 #ifndef wszPROPVALIDITYPERIODSTRING
00055 # define wszPROPVALIDITYPERIODSTRING  wszPROPVALIDITYPERIOD
00056 # define wszPROPVALIDITYPERIODCOUNT wszPROPVALIDITYPERIODUNITS
00057 #endif
00058
00059 // worker
00060 HRESULT
00061 GetServerCallbackInterface(
00062     ICertServerPolicy** ppServer,
00063     LONG Context)
00064 {
00065     HRESULT hr;
00066
00067     if (NULL == ppServer)
00068     {
00069         hr = E_POINTER;
00070   _JumpError(hr, error, "Policy:GetServerCallbackInterface");
00071     }
00072
00073     hr = CoCreateInstance(
00074                     CLSID_CCertServerPolicy,
00075                     NULL,               // pUnkOuter
00076                     CLSCTX_INPROC_SERVER,
00077                     IID_ICertServerPolicy,
00078                     (VOID **) ppServer);
00079     _JumpIfError(hr, error, "Policy:CoCreateInstance");
00080
00081     if (*ppServer == NULL)
00082     {
00083         hr = E_UNEXPECTED;
00084   _JumpError(hr, error, "Policy:CoCreateInstance");
00085     }
00086
00087     // only set context if nonzero
00088     if (0 != Context)
00089     {
00090         hr = (*ppServer)->SetContext(Context);
00091         _JumpIfError(hr, error, "Policy:SetContext");
00092     }
00093
00094 error:
00095     return hr;
00096 }
00097
00098
00099 //+--------------------------------------------------------------------------
00100 // CCertPolicySample::~CCertPolicySample -- destructor
00101 //
00102 // free memory associated with this instance
00103 //+--------------------------------------------------------------------------
00104
00105 CCertPolicySample::~CCertPolicySample()
00106 {
00107     _Cleanup();
00108 }
00109
00110
00111 VOID
00112 CCertPolicySample::_FreeStringArray(
00113     IN OUT DWORD *pcString,
00114     IN OUT LPWSTR **papstr)
00115 {
00116     BSTR *apstr = *papstr;
00117     DWORD i;
00118
00119     if (NULL != apstr)
00120     {
00121         for (i = *pcString; i-- > 0; )
00122         {
00123             if (NULL != apstr[i])
00124             {
00125                 DBGPRINT((fDebug, "_FreeStringArray[%u]: '%ws'\n", i, apstr[i]));
00126                 LocalFree(apstr[i]);
00127             }
00128         }
00129         LocalFree(apstr);
00130         *papstr = NULL;
00131     }
00132     *pcString = 0;
00133 }
00134
00135
00136 //+--------------------------------------------------------------------------
00137 // CCertPolicySample::_Cleanup -- free memory associated with this instance
00138 //
00139 // free memory associated with this instance
00140 //+--------------------------------------------------------------------------
00141
00142 VOID
00143 CCertPolicySample::_Cleanup()
00144 {
00145     DWORD i;
00146
00147     if(m_bstrDescription)
00148     {
00149         SysFreeString(m_bstrDescription);
00150         m_bstrDescription = NULL;
00151     }
00152
00153     // RevocationExtension variables:
00154     _FreeStringArray(&m_cCDPRevocationURL, &m_apstrCDPRevocationURL);
00155
00156     if (NULL != m_wszASPRevocationURL)
00157     {
00158         LocalFree(m_wszASPRevocationURL);
00159       m_wszASPRevocationURL = NULL;
00160     }
00161
00162
00163     // SubjectAltNameExtension variables:
00164
00165     for (i = 0; i < 2; i++)
00166     {
00167   if (NULL != m_astrSubjectAltNameProp[i])
00168   {
00169       SysFreeString(m_astrSubjectAltNameProp[i]);
00170       m_astrSubjectAltNameProp[i] = NULL;
00171   }
00172   if (NULL != m_astrSubjectAltNameObjectId[i])
00173   {
00174       SysFreeString(m_astrSubjectAltNameObjectId[i]);
00175       m_astrSubjectAltNameObjectId[i] = NULL;
00176   }
00177     }
00178
00179
00180     // AuthorityInfoAccessExtension variables:
00181
00182     _FreeStringArray(&m_cIssuerCertURL, &m_apstrIssuerCertURL);
00183
00184     _FreeStringArray(&m_cEnableRequestExtensions, &m_apstrEnableRequestExtensions);
00185     _FreeStringArray(&m_cDisableExtensions, &m_apstrDisableExtensions);
00186
00187     if (NULL != m_bstrCAName)
00188     {
00189         SysFreeString(m_bstrCAName);
00190         m_bstrCAName = NULL;
00191     }
00192     if (NULL != m_bstrCASanitizedName)
00193     {
00194         SysFreeString(m_bstrCASanitizedName);
00195         m_bstrCASanitizedName = NULL;
00196     }
00197     if (NULL != m_bstrCASanitizedDSName)
00198     {
00199         SysFreeString(m_bstrCASanitizedDSName);
00200         m_bstrCASanitizedDSName = NULL;
00201     }
00202
00203     if (NULL != m_wszRegStorageLoc)
00204     {
00205         LocalFree(m_wszRegStorageLoc);
00206         m_wszRegStorageLoc = NULL;
00207     }
00208
00209     if (NULL != m_pCert)
00210     {
00211         CertFreeCertificateContext(m_pCert);
00212         m_pCert = NULL;
00213     }
00214
00215     if(m_bstrMachineDNSName)
00216     {
00217         SysFreeString(m_bstrMachineDNSName);
00218         m_bstrMachineDNSName=NULL;
00219     }
00220
00221 }
00222
00223
00224 HRESULT
00225 CCertPolicySample::_ReadRegistryString(
00226     IN HKEY hkey,
00227     IN BOOL fURL,
00228     IN WCHAR const *pwszRegName,
00229     IN WCHAR const *pwszSuffix,
00230     OUT LPWSTR *ppwszOut)
00231 {
00232     HRESULT hr;
00233     WCHAR *pwszRegValue = NULL;
00234     DWORD cbValue;
00235     DWORD dwType;
00236
00237     *ppwszOut = NULL;
00238     hr = RegQueryValueEx(
00239         hkey,
00240         pwszRegName,
00241         NULL,           // lpdwReserved
00242         &dwType,
00243         NULL,
00244         &cbValue);
00245     _JumpIfErrorStr2(hr, error, "Policy:RegQueryValueEx", pwszRegName, ERROR_FILE_NOT_FOUND);
00246
00247     if (REG_SZ != dwType && REG_MULTI_SZ != dwType)
00248     {
00249         hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00250         _JumpErrorStr(hr, error, "Policy:RegQueryValueEx TYPE", pwszRegName);
00251     }
00252     if (NULL != pwszSuffix)
00253     {
00254   cbValue += (DWORD)(wcslen(pwszSuffix) * sizeof(WCHAR));
00255     }
00256     pwszRegValue = (WCHAR *) LocalAlloc(LMEM_FIXED, cbValue + sizeof(WCHAR));
00257     if (NULL == pwszRegValue)
00258     {
00259         hr = E_OUTOFMEMORY;
00260         _JumpErrorStr(hr, error, "Policy:LocalAlloc", pwszRegName);
00261     }
00262     hr = RegQueryValueEx(
00263         hkey,
00264         pwszRegName,
00265         NULL,           // lpdwReserved
00266         &dwType,
00267         (BYTE *) pwszRegValue,
00268         &cbValue);
00269     _JumpIfErrorStr(hr, error, "Policy:RegQueryValueEx", pwszRegName);
00270
00271     // Handle malformed registry values cleanly:
00272
00273     pwszRegValue[cbValue / sizeof(WCHAR)] = L'\0';
00274     if (NULL != pwszSuffix)
00275     {
00276   wcscat(pwszRegValue, pwszSuffix);
00277     }
00278
00279     hr = ceFormatCertsrvStringArray(
00280       fURL,     // fURL
00281       m_bstrMachineDNSName,   // pwszServerName_p1_2
00282       m_bstrCASanitizedName,  // pwszSanitizedName_p3_7
00283       m_iCert,    // iCert_p4
00284       L"",    // pwszDomainDN_p5
00285       L"",  // pwszConfigDN_p6
00286       m_iCRL,     // iCRL_p8
00287       FALSE,      // fDeltaCRL_p9
00288       TRUE,     // fDSAttrib_p10_11
00289       1,          // cStrings
00290       (LPCWSTR *) &pwszRegValue, // apwszStringsIn
00291       ppwszOut);    // apwszStringsOut
00292     _JumpIfError(hr, error, "Policy:ceFormatCertsrvStringArray");
00293
00294 error:
00295     if (NULL != pwszRegValue)
00296     {
00297         LocalFree(pwszRegValue);
00298     }
00299     return(ceHError(hr));
00300 }
00301
00302
00303 #if DBG_CERTSRV
00304
00305 VOID
00306 CCertPolicySample::_DumpStringArray(
00307     IN char const *pszType,
00308     IN DWORD count,
00309     IN BSTR const *apstr)
00310 {
00311     DWORD i;
00312     WCHAR const *pwszName;
00313
00314     for (i = 0; i < count; i++)
00315     {
00316   pwszName = L"";
00317   if (iswdigit(apstr[i][0]))
00318   {
00319       pwszName = ceGetOIDName(apstr[i]);  // Static: do not free!
00320   }
00321   DBGPRINT((
00322     fDebug,
00323     "%s[%u]: %ws%s%ws\n",
00324     pszType,
00325     i,
00326     apstr[i],
00327     L'\0' != *pwszName? " -- " : "",
00328     pwszName));
00329     }
00330 }
00331 #endif // DBG_CERTSRV
00332
00333
00334
00335
00336 HRESULT
00337 CCertPolicySample::_AddStringArray(
00338     IN WCHAR const *pwszzValue,
00339     IN BOOL fURL,
00340     IN OUT DWORD *pcStrings,
00341     IN OUT LPWSTR **papstrRegValues)
00342 {
00343     HRESULT hr = S_OK;
00344     DWORD cString = 0;
00345     WCHAR const *pwsz;
00346
00347
00348     LPCWSTR *awszFormatStrings = NULL;
00349     LPWSTR *awszOutputStrings = NULL;
00350
00351
00352     // Count the number of strings we're adding
00353     for (pwsz = pwszzValue; L'\0' != *pwsz; pwsz += wcslen(pwsz) + 1)
00354     {
00355         cString++;
00356     }
00357     if (0 == cString)   // no strings
00358     {
00359         goto error;
00360     }
00361     awszFormatStrings = (LPCWSTR *) LocalAlloc(
00362           LMEM_FIXED | LMEM_ZEROINIT,
00363           cString * sizeof(LPWSTR));
00364     if (NULL == awszFormatStrings)
00365     {
00366         hr = E_OUTOFMEMORY;
00367         _JumpError(hr, error, "Policy:LocalAlloc");
00368     }
00369
00370     cString = 0;
00371     for (pwsz = pwszzValue; L'\0' != *pwsz; pwsz += wcslen(pwsz) + 1)
00372     {
00373         // Skip strings that start with a an unescaped minus sign.
00374         // Strings with an escaped minus sign (2 minus signs) are not skipped.
00375
00376         if (L'-' == *pwsz)
00377         {
00378       pwsz++;
00379       if (L'-' != *pwsz)
00380       {
00381                 continue;
00382       }
00383         }
00384         awszFormatStrings[cString++] = pwsz;
00385     }
00386
00387     // if no strings to add, don't modify
00388     if (cString > 0)
00389     {
00390         awszOutputStrings = (LPWSTR *) LocalAlloc(
00391               LMEM_FIXED | LMEM_ZEROINIT,
00392               (cString + *pcStrings)  * sizeof(LPWSTR));
00393         if (NULL == awszOutputStrings)
00394         {
00395             hr = E_OUTOFMEMORY;
00396             _JumpError(hr, error, "Policy:LocalAlloc");
00397         }
00398
00399         if (0 != *pcStrings)
00400         {
00401             assert(NULL != *papstrRegValues);
00402             CopyMemory(awszOutputStrings, *papstrRegValues, *pcStrings * sizeof(LPWSTR));
00403         }
00404
00405         hr = ceFormatCertsrvStringArray(
00406         fURL,     // fURL
00407         m_bstrMachineDNSName, // pwszServerName_p1_2
00408         m_bstrCASanitizedName,  // pwszSanitizedName_p3_7
00409         m_iCert,      // iCert_p4
00410         L"",      // pwszDomainDN_p5
00411         L"",      // pwszConfigDN_p6
00412         m_iCRL,     // iCRL_p8
00413         FALSE,      // fDeltaCRL_p9
00414         TRUE,     // fDSAttrib_p10_11
00415         cString,      // cStrings
00416         awszFormatStrings,    // apwszStringsIn
00417         awszOutputStrings + (*pcStrings)); // apwszStringsOut
00418         _JumpIfError(hr, error, "Policy:ceFormatCertsrvStringArray");
00419
00420         *pcStrings = (*pcStrings) + cString;
00421         if(*papstrRegValues)
00422         {
00423             LocalFree(*papstrRegValues);
00424         }
00425         *papstrRegValues = awszOutputStrings;
00426         awszOutputStrings = NULL;
00427     }
00428
00429 error:
00430
00431     if(awszOutputStrings)
00432     {
00433         LocalFree(awszOutputStrings);
00434     }
00435     if(awszFormatStrings)
00436     {
00437         LocalFree(awszFormatStrings);
00438     }
00439     return(ceHError(hr));
00440 }
00441
00442
00443 HRESULT
00444 CCertPolicySample::_ReadRegistryStringArray(
00445     IN HKEY hkey,
00446     IN BOOL fURL,
00447     IN DWORD dwFlags,
00448     IN DWORD cRegNames,
00449     IN DWORD *aFlags,
00450     IN WCHAR const * const *apwszRegNames,
00451     IN OUT DWORD *pcStrings,
00452     IN OUT LPWSTR **papstrRegValues)
00453 {
00454     HRESULT hr;
00455     DWORD i;
00456     WCHAR *pwszzValue = NULL;
00457     DWORD cbValue;
00458     DWORD dwType;
00459
00460     for (i = 0; i < cRegNames; i++)
00461     {
00462         if (0 == (dwFlags & aFlags[i]))
00463         {
00464       continue;
00465         }
00466         if (NULL != pwszzValue)
00467         {
00468       LocalFree(pwszzValue);
00469       pwszzValue = NULL;
00470         }
00471         hr = RegQueryValueEx(
00472             hkey,
00473             apwszRegNames[i],
00474             NULL,           // lpdwReserved
00475             &dwType,
00476             NULL,
00477             &cbValue);
00478         if (S_OK != hr)
00479         {
00480       _PrintErrorStr2(hr, "Policy:RegQueryValueEx", apwszRegNames[i], ERROR_FILE_NOT_FOUND);
00481       continue;
00482         }
00483         if (REG_SZ != dwType && REG_MULTI_SZ != dwType)
00484         {
00485       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00486       _PrintErrorStr(hr, "Policy:RegQueryValueEx TYPE", apwszRegNames[i]);
00487       continue;
00488         }
00489
00490         // Handle malformed registry values cleanly by adding two WCHAR L'\0's
00491   // allocate space for 3 WCHARs to allow for unaligned (odd) cbValue;
00492
00493         pwszzValue = (WCHAR *) LocalAlloc(
00494                 LMEM_FIXED,
00495                 cbValue + 3 * sizeof(WCHAR));
00496         if (NULL == pwszzValue)
00497         {
00498       hr = E_OUTOFMEMORY;
00499       _JumpErrorStr(hr, error, "Policy:LocalAlloc", apwszRegNames[i]);
00500         }
00501         hr = RegQueryValueEx(
00502             hkey,
00503             apwszRegNames[i],
00504             NULL,           // lpdwReserved
00505             &dwType,
00506             (BYTE *) pwszzValue,
00507             &cbValue);
00508         if (S_OK != hr)
00509         {
00510       _PrintErrorStr(hr, "Policy:RegQueryValueEx", apwszRegNames[i]);
00511       continue;
00512         }
00513
00514         // Handle malformed registry values cleanly:
00515
00516         pwszzValue[cbValue / sizeof(WCHAR)] = L'\0';
00517         pwszzValue[cbValue / sizeof(WCHAR) + 1] = L'\0';
00518
00519         hr = _AddStringArray(pwszzValue, fURL, pcStrings, papstrRegValues);
00520         _JumpIfErrorStr(hr, error, "_AddStringArray", apwszRegNames[i]);
00521     }
00522     hr = S_OK;
00523
00524 error:
00525     if (NULL != pwszzValue)
00526     {
00527         LocalFree(pwszzValue);
00528     }
00529     return(hr);
00530 }
00531
00532
00533 //+--------------------------------------------------------------------------
00534 // CCertPolicySample::_InitRevocationExtension
00535 //
00536 //+--------------------------------------------------------------------------
00537
00538 VOID
00539 CCertPolicySample::_InitRevocationExtension(
00540     IN HKEY hkey)
00541 {
00542     HRESULT hr;
00543     DWORD dwType;
00544     DWORD cb;
00545     DWORD adwFlags[] = {
00546     REVEXT_CDPLDAPURL,
00547     REVEXT_CDPHTTPURL,
00548     REVEXT_CDPFTPURL,
00549     REVEXT_CDPFILEURL,
00550       };
00551     WCHAR *apwszRegNames[] = {
00552     wszREGLDAPREVOCATIONCRLURL,
00553     wszREGREVOCATIONCRLURL,
00554     wszREGFTPREVOCATIONCRLURL,
00555     wszREGFILEREVOCATIONCRLURL,
00556       };
00557
00558     cb = sizeof(m_dwRevocationFlags);
00559     hr = RegQueryValueEx(
00560                 hkey,
00561                 wszREGREVOCATIONTYPE,
00562                 NULL,           // lpdwReserved
00563                 &dwType,
00564                 (BYTE *) &m_dwRevocationFlags,
00565                 &cb);
00566     if (S_OK != hr ||
00567   REG_DWORD != dwType ||
00568   sizeof(m_dwRevocationFlags) != cb)
00569     {
00570         goto error;
00571     }
00572     DBGPRINT((fDebug, "Revocation Flags = %x\n", m_dwRevocationFlags));
00573
00574
00575     // clean up from previous call
00576     if(m_apstrCDPRevocationURL)
00577     {
00578         _FreeStringArray(&m_cCDPRevocationURL, &m_apstrCDPRevocationURL);
00579     }
00580
00581     if(m_wszASPRevocationURL)
00582     {
00583         LocalFree(m_wszASPRevocationURL);
00584         m_wszASPRevocationURL = NULL;
00585     }
00586
00587     if (REVEXT_CDPENABLE & m_dwRevocationFlags)
00588     {
00589
00590
00591         assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNames));
00592         hr = _ReadRegistryStringArray(
00593           hkey,
00594           TRUE,     // fURL
00595           m_dwRevocationFlags,
00596           ARRAYSIZE(adwFlags),
00597           adwFlags,
00598           apwszRegNames,
00599           &m_cCDPRevocationURL,
00600           &m_apstrCDPRevocationURL);
00601         _JumpIfError(hr, error, "_ReadRegistryStringArray");
00602
00603         _DumpStringArray("CDP", m_cCDPRevocationURL, m_apstrCDPRevocationURL);
00604     }
00605
00606     if (REVEXT_ASPENABLE & m_dwRevocationFlags)
00607     {
00608         hr = _ReadRegistryString(
00609           hkey,
00610           TRUE,     // fURL
00611           wszREGREVOCATIONURL,  // pwszRegName
00612           L"?",     // pwszSuffix
00613           &m_wszASPRevocationURL);  // pstrRegValue
00614         _JumpIfErrorStr(hr, error, "_ReadRegistryString", wszREGREVOCATIONURL);
00615         _DumpStringArray("ASP", 1, &m_wszASPRevocationURL);
00616     }
00617
00618 error:
00619     ;
00620 }
00621
00622
00623 //+--------------------------------------------------------------------------
00624 // CCertPolicySample::_InitAuthorityInfoAccessExtension
00625 //
00626 //+--------------------------------------------------------------------------
00627
00628 VOID
00629 CCertPolicySample::_InitAuthorityInfoAccessExtension(
00630     IN HKEY hkey)
00631 {
00632     HRESULT hr;
00633     DWORD dwType;
00634     DWORD cb;
00635     DWORD adwFlags[] = {
00636     ISSCERT_LDAPURL,
00637     ISSCERT_HTTPURL,
00638     ISSCERT_FTPURL,
00639     ISSCERT_FILEURL,
00640       };
00641     WCHAR *apwszRegNames[] = {
00642     wszREGLDAPISSUERCERTURL,
00643     wszREGISSUERCERTURL,
00644     wszREGFTPISSUERCERTURL,
00645     wszREGFILEISSUERCERTURL,
00646       };
00647
00648     // clean up from previous call
00649     if(m_apstrIssuerCertURL)
00650     {
00651         _FreeStringArray(&m_cIssuerCertURL, &m_apstrIssuerCertURL);
00652     }
00653
00654
00655
00656     cb = sizeof(m_dwIssuerCertURLFlags);
00657     hr = RegQueryValueEx(
00658                 hkey,
00659     wszREGISSUERCERTURLFLAGS,
00660                 NULL,           // lpdwReserved
00661                 &dwType,
00662                 (BYTE *) &m_dwIssuerCertURLFlags,
00663                 &cb);
00664     if (S_OK != hr ||
00665   REG_DWORD != dwType ||
00666   sizeof(m_dwIssuerCertURLFlags) != cb)
00667     {
00668         goto error;
00669     }
00670     DBGPRINT((fDebug, "Issuer Cert Flags = %x\n", m_dwIssuerCertURLFlags));
00671
00672     if (ISSCERT_ENABLE & m_dwIssuerCertURLFlags)
00673     {
00674         assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNames));
00675         hr = _ReadRegistryStringArray(
00676                                         hkey,
00677                                         TRUE,     // fURL
00678                                         m_dwIssuerCertURLFlags,
00679                                         ARRAYSIZE(adwFlags),
00680                                         adwFlags,
00681                                         apwszRegNames,
00682                                         &m_cIssuerCertURL,
00683                                         &m_apstrIssuerCertURL);
00684         _JumpIfError(hr, error, "_ReadRegistryStringArray");
00685
00686         _DumpStringArray("Issuer Cert", m_cIssuerCertURL, m_apstrIssuerCertURL);
00687     }
00688
00689 error:
00690     ;
00691 }
00692
00693
00694 //+--------------------------------------------------------------------------
00695 // CCertPolicySample::_InitRequestExtensionList
00696 //
00697 //+--------------------------------------------------------------------------
00698
00699 VOID
00700 CCertPolicySample::_InitRequestExtensionList(
00701     IN HKEY hkey)
00702 {
00703     HRESULT hr;
00704     DWORD adwFlags[] = {
00705     EDITF_REQUESTEXTENSIONLIST,
00706       };
00707     WCHAR *apwszRegNames[] = {
00708     wszREGENABLEREQUESTEXTENSIONLIST,
00709       };
00710
00711     assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNames));
00712
00713     // clean up from previous call
00714     if(m_apstrEnableRequestExtensions)
00715     {
00716         _FreeStringArray(&m_cEnableRequestExtensions, &m_apstrEnableRequestExtensions);
00717     }
00718
00719
00720     hr = _ReadRegistryStringArray(
00721       hkey,
00722       FALSE,      // fURL
00723       m_dwEditFlags,
00724       ARRAYSIZE(adwFlags),
00725       adwFlags,
00726       apwszRegNames,
00727       &m_cEnableRequestExtensions,
00728       &m_apstrEnableRequestExtensions);
00729     _JumpIfError(hr, error, "_ReadRegistryStringArray");
00730
00731     _DumpStringArray("Request", m_cEnableRequestExtensions, m_apstrEnableRequestExtensions);
00732
00733 error:
00734     ;
00735 }
00736
00737
00738 //+--------------------------------------------------------------------------
00739 // CCertPolicySample::_InitDisableExtensionList
00740 //
00741 //+--------------------------------------------------------------------------
00742
00743 VOID
00744 CCertPolicySample::_InitDisableExtensionList(
00745     IN HKEY hkey)
00746 {
00747     HRESULT hr;
00748     DWORD adwFlags[] = {
00749     EDITF_DISABLEEXTENSIONLIST,
00750       };
00751     WCHAR *apwszRegNames[] = {
00752     wszREGDISABLEEXTENSIONLIST,
00753       };
00754
00755     assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNames));
00756     // clean up from previous call
00757     if(m_apstrDisableExtensions)
00758     {
00759         _FreeStringArray(&m_cDisableExtensions, &m_apstrDisableExtensions);
00760     }
00761
00762
00763     hr = _ReadRegistryStringArray(
00764       hkey,
00765       FALSE,      // fURL
00766       m_dwEditFlags,
00767       ARRAYSIZE(adwFlags),
00768       adwFlags,
00769       apwszRegNames,
00770       &m_cDisableExtensions,
00771       &m_apstrDisableExtensions);
00772     _JumpIfError(hr, error, "_ReadRegistryStringArray");
00773
00774     _DumpStringArray("Disable", m_cDisableExtensions, m_apstrDisableExtensions);
00775
00776 error:
00777     ;
00778 }
00779
00780
00781 //+--------------------------------------------------------------------------
00782 // CCertPolicySample::_InitSubjectAltNameExtension
00783 //
00784 // Returns S_OK on success.
00785 //+--------------------------------------------------------------------------
00786
00787 VOID
00788 CCertPolicySample::_InitSubjectAltNameExtension(
00789     IN HKEY hkey,
00790     IN WCHAR const *pwszRegName,
00791     IN WCHAR const *pwszObjectId,
00792     IN DWORD iAltName)
00793 {
00794     DWORD err;
00795     DWORD dwType;
00796     DWORD cbbuf;
00797     WCHAR awcbuf[MAX_PATH];
00798
00799     cbbuf = sizeof(awcbuf) - 2 * sizeof(WCHAR);
00800     err = RegQueryValueEx(
00801         hkey,
00802         pwszRegName,
00803         NULL,         // lpdwReserved
00804         &dwType,
00805         (BYTE *) awcbuf,
00806         &cbbuf);
00807     if (ERROR_SUCCESS != err ||
00808         REG_SZ != dwType ||
00809         sizeof(awcbuf) - 2 * sizeof(WCHAR) <= cbbuf)
00810     {
00811         goto error;
00812     }
00813     if (0 == lstrcmpi(awcbuf, wszATTREMAIL1) ||
00814   0 == lstrcmpi(awcbuf, wszATTREMAIL2))
00815     {
00816         if (!ceConvertWszToBstr(
00817       &m_astrSubjectAltNameObjectId[iAltName],
00818       pwszObjectId,
00819       -1))
00820   {
00821       _JumpError(E_OUTOFMEMORY, error, "Policy:ceConvertWszToBstr");
00822   }
00823
00824         if (!ceConvertWszToBstr(
00825       &m_astrSubjectAltNameProp[iAltName],
00826       wszPROPSUBJECTEMAIL,
00827       -1))
00828   {
00829       _JumpError(E_OUTOFMEMORY, error, "Policy:ceConvertWszToBstr");
00830   }
00831     }
00832     DBGPRINT((
00833   fDebug,
00834   "Policy: %ws(RDN=%ws): %ws\n",
00835   pwszRegName,
00836   awcbuf,
00837   m_astrSubjectAltNameProp[iAltName]));
00838
00839 error:
00840     ;
00841 }
00842
00843
00844
00845 //+--------------------------------------------------------------------------
00846 // CCertPolicySample::Initialize
00847 //
00848 // Returns S_OK on success.
00849 //+--------------------------------------------------------------------------
00850
00851 STDMETHODIMP
00852 CCertPolicySample::Initialize(
00853     /* [in] */ BSTR const strConfig)
00854 {
00855     HRESULT     hr;
00856     DWORD       err;
00857     HKEY        hkey = NULL;
00858     WCHAR       sz[MAX_PATH];
00859     DWORD       dwType;
00860     DWORD       dwSize;
00861
00862     LPWSTR      wszShortMachineName = NULL;
00863     ICertServerPolicy* pServer = NULL;
00864     VARIANT varValue;
00865
00866     CERT_RDN_ATTR rdnAttr = { szOID_COMMON_NAME, CERT_RDN_ANY_TYPE, };
00867     CERT_RDN rdn = { 1, &rdnAttr };
00868
00869     rdnAttr.Value.pbData = NULL;
00870     VariantInit(&varValue);
00871
00872     DBGPRINT((fDebug, "Policy:Initialize:\n"));
00873
00874     EnterCriticalSection(&m_PolicyCriticalSection);
00875
00876     _Cleanup();
00877
00878     m_bstrCAName = SysAllocString(strConfig);
00879
00880     // get server callbacks
00881
00882     hr = GetServerCallbackInterface(&pServer, 0);
00883     _JumpIfError(hr, error, "Policy:GetServerCallbackInterface");
00884
00885     // get storage location
00886     hr = pServer->GetCertificateProperty(wszPROPMODULEREGLOC, PROPTYPE_STRING, &varValue);
00887     _JumpIfError(hr, error, "Policy:GetCertificateProperty : wszPROPMODULEREGLOC");
00888
00889     m_wszRegStorageLoc = (LPWSTR)LocalAlloc(LMEM_FIXED, (wcslen(varValue.bstrVal)+1) *sizeof(WCHAR));
00890     if (NULL == m_wszRegStorageLoc)
00891     {
00892         hr = E_OUTOFMEMORY;
00893         _JumpError(hr, error, "Policy:LocalAlloc");
00894     }
00895
00896     wcscpy(m_wszRegStorageLoc, varValue.bstrVal);
00897     VariantClear(&varValue);
00898
00899
00900     assert(wcslen(wsz_SAMPLE_DESCRIPTION) < ARRAYSIZE(sz));
00901     wcscpy(sz, wsz_SAMPLE_DESCRIPTION);
00902
00903     m_bstrDescription = SysAllocString(sz);
00904     if (NULL == m_bstrDescription)
00905     {
00906         hr = E_OUTOFMEMORY;
00907         _JumpError(hr, error, "Policy:SysAllocString");
00908     }
00909
00910     // get CA type
00911     hr = pServer->GetCertificateProperty(wszPROPCATYPE, PROPTYPE_LONG, &varValue);
00912     _JumpIfErrorStr(hr, error, "Policy:GetCertificateProperty", wszPROPCATYPE);
00913
00914     m_CAType = (ENUM_CATYPES)varValue.lVal;
00915     VariantClear(&varValue);
00916
00917
00918
00919     // get sanitized name
00920     hr = pServer->GetCertificateProperty(wszPROPSANITIZEDCANAME, PROPTYPE_STRING, &varValue);
00921     _JumpIfErrorStr(hr, error, "Policy:GetCertificateProperty", wszPROPSANITIZEDCANAME);
00922
00923     m_bstrCASanitizedName = SysAllocString(varValue.bstrVal);
00924     if (NULL == m_bstrCASanitizedName)
00925     {
00926         hr = E_OUTOFMEMORY;
00927         _JumpError(hr, error, "Policy:SysAllocString");
00928     }
00929     VariantClear(&varValue);
00930
00931     // get sanitized name
00932     hr = pServer->GetCertificateProperty(wszPROPSANITIZEDSHORTNAME, PROPTYPE_STRING, &varValue);
00933     _JumpIfErrorStr(hr, error, "Policy:GetCertificateProperty", wszPROPSANITIZEDSHORTNAME);
00934
00935     m_bstrCASanitizedDSName = SysAllocString(varValue.bstrVal);
00936     if (NULL == m_bstrCASanitizedDSName)
00937     {
00938         hr = E_OUTOFMEMORY;
00939         _JumpError(hr, error, "Policy:SysAllocString");
00940     }
00941     VariantClear(&varValue);
00942
00943
00944     err = RegOpenKeyEx(
00945                 HKEY_LOCAL_MACHINE,
00946                 m_wszRegStorageLoc,
00947                 0,              // dwReserved
00948                 KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE,
00949                 &hkey);
00950
00951     if (ERROR_SUCCESS != err)
00952     {
00953         hr = HRESULT_FROM_WIN32(err);
00954
00955         _JumpErrorStr(hr, error, "Policy:Initialize:RegOpenKeyEx", m_wszRegStorageLoc);
00956     }
00957
00958     // Ignore error codes.
00959
00960     dwSize = sizeof(m_dwDispositionFlags);
00961     err = RegQueryValueEx(
00962         hkey,
00963         wszREGREQUESTDISPOSITION,
00964         0,
00965         &dwType,
00966         (BYTE *) &m_dwDispositionFlags,
00967         &dwSize);
00968     if (ERROR_SUCCESS != err)
00969     {
00970         m_dwDispositionFlags = 0;
00971     }
00972     DBGPRINT((fDebug, "Disposition Flags = %x\n", m_dwDispositionFlags));
00973
00974     dwSize = sizeof(m_dwEditFlags);
00975     err = RegQueryValueEx(
00976         hkey,
00977         wszREGEDITFLAGS,
00978         0,
00979         &dwType,
00980         (BYTE *) &m_dwEditFlags,
00981         &dwSize);
00982     if (ERROR_SUCCESS != err)
00983     {
00984         m_dwEditFlags = 0;
00985     }
00986     DBGPRINT((fDebug, "Edit Flags = %x\n", m_dwEditFlags));
00987
00988     dwSize = sizeof(m_CAPathLength);
00989     err = RegQueryValueEx(
00990         hkey,
00991         wszREGCAPATHLENGTH,
00992         0,
00993         &dwType,
00994         (BYTE *) &m_CAPathLength,
00995         &dwSize);
00996     if (ERROR_SUCCESS != err)
00997     {
00998   m_CAPathLength = CAPATHLENGTH_INFINITE;
00999     }
01000     DBGPRINT((fDebug, "CAPathLength = %x\n", m_CAPathLength));
01001
01002
01003     // Initialize the insertion string array.
01004     // Machine DNS name (%1)
01005     VariantClear(&varValue);
01006
01007     hr = pServer->GetCertificateProperty(wszPROPMACHINEDNSNAME, PROPTYPE_STRING, &varValue);
01008     _JumpIfErrorStr(hr, error, "Policy:GetCertificateProperty", wszPROPMACHINEDNSNAME);
01009
01010     m_bstrMachineDNSName = SysAllocString(varValue.bstrVal);
01011     if (NULL == m_bstrMachineDNSName)
01012     {
01013         hr = E_OUTOFMEMORY;
01014         _JumpError(hr, error, "Policy:SysAllocString");
01015     }
01016     VariantClear(&varValue);
01017
01018
01019     hr = pServer->GetCertificateProperty(wszPROPCERTCOUNT, PROPTYPE_LONG, &varValue);
01020     _JumpIfErrorStr(hr, error, "Policy:GetCertificateProperty", wszPROPCERTCOUNT);
01021     m_iCert = varValue.lVal - 1;
01022
01023     hr = pServer->GetCertificateProperty(wszPROPCRLINDEX, PROPTYPE_LONG, &varValue);
01024     _JumpIfErrorStr(hr, error, "Policy:GetCertificateProperty", wszPROPCRLINDEX);
01025     m_iCRL = varValue.lVal;
01026
01027
01028
01029
01030     _InitRevocationExtension(hkey);
01031     _InitAuthorityInfoAccessExtension(hkey);
01032     _InitRequestExtensionList(hkey);
01033     _InitDisableExtensionList(hkey);
01034
01035     {
01036         _InitSubjectAltNameExtension(
01037           hkey,
01038           wszREGSUBJECTALTNAME,
01039           TEXT(szOID_SUBJECT_ALT_NAME),
01040           0);
01041         _InitSubjectAltNameExtension(
01042           hkey,
01043           wszREGSUBJECTALTNAME2,
01044           TEXT(szOID_SUBJECT_ALT_NAME2),
01045           1);
01046     }
01047
01048
01049     hr = S_OK;
01050
01051 error:
01052     VariantClear(&varValue);
01053
01054     if (NULL != hkey)
01055     {
01056         RegCloseKey(hkey);
01057     }
01058
01059     VariantClear(&varValue);
01060
01061     if (pServer)
01062         pServer->Release();
01063
01064     LeaveCriticalSection(&m_PolicyCriticalSection);
01065     return(hr);
01066 }
01067
01068
01069 BOOL
01070 IsStringInList(
01071     IN BSTR const str,
01072     IN DWORD count,
01073     IN BSTR const *apstr)
01074 {
01075     DWORD i;
01076     BOOL fInList = FALSE;
01077
01078     for (i = 0; i < count; i++)
01079     {
01080   if (0 == wcscmp(str, apstr[i]))
01081   {
01082       fInList = TRUE;
01083       break;
01084   }
01085     }
01086     return(fInList);
01087 }
01088
01089
01090 HRESULT
01091 CCertPolicySample::_EnumerateExtensions(
01092     IN ICertServerPolicy *pServer,
01093     IN LONG bNewRequest,
01094     OPTIONAL OUT BOOL *pfCA)
01095 {
01096     HRESULT hr;
01097     HRESULT hr2;
01098     BSTR strName = NULL;
01099     LONG ExtFlags;
01100     VARIANT varValue;
01101     BOOL fClose = FALSE;
01102     BOOL fFirstPass = NULL != pfCA;
01103     BOOL fEnable;
01104     BOOL fDisable;
01105
01106     if (NULL != pfCA)
01107     {
01108   *pfCA = FALSE;
01109     }
01110     VariantInit(&varValue);
01111
01112     hr = pServer->EnumerateExtensionsSetup(0);
01113     _JumpIfError(hr, error, "Policy:EnumerateExtensionsSetup");
01114
01115     fClose = TRUE;
01116     while (TRUE)
01117     {
01118         hr = pServer->EnumerateExtensions(&strName);
01119         if (S_FALSE == hr)
01120         {
01121             hr = S_OK;
01122             break;
01123         }
01124         _JumpIfError(hr, error, "Policy:EnumerateExtensions");
01125
01126         hr = pServer->GetCertificateExtension(
01127                                         strName,
01128                                         PROPTYPE_BINARY,
01129                                         &varValue);
01130         _JumpIfError(hr, error, "Policy:GetCertificateExtension");
01131
01132         hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
01133   _JumpIfError(hr, error, "Policy:GetCertificateExtensionFlags");
01134
01135   fEnable = FALSE;
01136   fDisable = FALSE;
01137
01138         if (fFirstPass)
01139         {
01140       {
01141     if (0 == wcscmp(strName, TEXT(szOID_CERTTYPE_EXTENSION)))
01142     {
01143         CERT_NAME_VALUE *pCAType;
01144         DWORD cbCAType;
01145
01146         if (VT_BSTR == varValue.vt)
01147         {
01148       if (!ceDecodeObject(
01149           X509_ASN_ENCODING,
01150           X509_UNICODE_ANY_STRING,
01151           (BYTE const *) varValue.bstrVal,
01152           SysStringByteLen(varValue.bstrVal),
01153           FALSE,
01154           (VOID **) &pCAType,
01155           &cbCAType))
01156       {
01157           hr = GetLastError();
01158           _PrintError(hr, "Policy:ceDecodeObject");
01159       }
01160       else
01161       {
01162           if (0 == lstrcmpi(
01163               wszCERTTYPE_SUBORDINATE_CA,
01164               (WCHAR *) pCAType->Value.pbData))
01165           {
01166         *pfCA = TRUE;
01167           }
01168           LocalFree(pCAType);
01169       }
01170         }
01171         else
01172         {
01173       _PrintError(
01174         HRESULT_FROM_WIN32(ERROR_INVALID_DATA),
01175         "Policy:Incorrect CertType Extension type");
01176         }
01177     }
01178       }
01179             if (bNewRequest && (EXTENSION_DISABLE_FLAG & ExtFlags))
01180             {
01181                 switch (EXTENSION_ORIGIN_MASK & ExtFlags)
01182                 {
01183                     case EXTENSION_ORIGIN_REQUEST:
01184                     case EXTENSION_ORIGIN_RENEWALCERT:
01185                     case EXTENSION_ORIGIN_PKCS7:
01186                     if ((EDITF_ENABLEREQUESTEXTENSIONS & m_dwEditFlags) ||
01187       IsStringInList(
01188                         strName,
01189                         m_cEnableRequestExtensions,
01190                         m_apstrEnableRequestExtensions))
01191                     {
01192       fEnable = TRUE;
01193                     }
01194                     break;
01195                 }
01196             }
01197         }
01198         else
01199         {
01200             if (0 == (EXTENSION_DISABLE_FLAG & ExtFlags) &&
01201     IsStringInList(
01202           strName,
01203           m_cDisableExtensions,
01204           m_apstrDisableExtensions))
01205             {
01206                 fDisable = TRUE;
01207             }
01208         }
01209
01210         if (fDisable || fEnable)
01211         {
01212             if (fEnable)
01213             {
01214                 ExtFlags &= ~EXTENSION_DISABLE_FLAG;
01215             }
01216             else
01217             {
01218                 ExtFlags |= EXTENSION_DISABLE_FLAG;
01219             }
01220             hr = pServer->SetCertificateExtension(
01221                   strName,
01222                   PROPTYPE_BINARY,
01223                   ExtFlags,
01224                   &varValue);
01225             _JumpIfError(hr, error, "Policy:SetCertificateExtension");
01226         }
01227
01228         if (fFirstPass || fDisable || fEnable)
01229         {
01230       DBGPRINT((
01231     fDebug,
01232                 "Policy:EnumerateExtensions(%ws, Flags=%x, %x bytes)%s\n",
01233                 strName,
01234                 ExtFlags,
01235                 SysStringByteLen(varValue.bstrVal),
01236     fDisable? " DISABLING" : (fEnable? " ENABLING" : "")));
01237         }
01238         VariantClear(&varValue);
01239     }
01240
01241 error:
01242     if (fClose)
01243     {
01244         hr2 = pServer->EnumerateExtensionsClose();
01245         if (S_OK != hr2)
01246         {
01247             if (S_OK == hr)
01248             {
01249                 hr = hr2;
01250             }
01251       _PrintError(hr2, "Policy:EnumerateExtensionsClose");
01252         }
01253     }
01254     if (NULL != strName)
01255     {
01256         SysFreeString(strName);
01257     }
01258     VariantClear(&varValue);
01259     return(hr);
01260 }
01261
01262
01263 HRESULT
01264 EnumerateAttributes(
01265     IN ICertServerPolicy *pServer)
01266 {
01267     HRESULT hr;
01268     HRESULT hr2;
01269     BSTR strName = NULL;
01270     BOOL fClose = FALSE;
01271     BSTR strValue = NULL;
01272
01273     hr = pServer->EnumerateAttributesSetup(0);
01274     _JumpIfError(hr, error, "Policy:EnumerateAttributesSetup");
01275
01276     fClose = TRUE;
01277     while (TRUE)
01278     {
01279         hr = pServer->EnumerateAttributes(&strName);
01280   if (S_FALSE == hr)
01281   {
01282       hr = S_OK;
01283       break;
01284   }
01285   _JumpIfError(hr, error, "Policy:EnumerateAttributes");
01286
01287         hr = pServer->GetRequestAttribute(strName, &strValue);
01288   _JumpIfError(hr, error, "Policy:GetRequestAttribute");
01289
01290   DBGPRINT((
01291     fDebug,
01292                 "Policy:EnumerateAttributes(%ws = %ws)\n",
01293                 strName,
01294                 strValue));
01295         if (NULL != strValue)
01296         {
01297             SysFreeString(strValue);
01298             strValue = NULL;
01299         }
01300     }
01301
01302 error:
01303     if (fClose)
01304     {
01305         hr2 = pServer->EnumerateAttributesClose();
01306         if (S_OK != hr2)
01307         {
01308       _PrintError(hr2, "Policy:EnumerateAttributesClose");
01309             if (S_OK == hr)
01310             {
01311                 hr = hr2;
01312             }
01313             goto error;
01314         }
01315     }
01316
01317     if (NULL != strName)
01318     {
01319         SysFreeString(strName);
01320     }
01321     if (NULL != strValue)
01322     {
01323         SysFreeString(strValue);
01324     }
01325     return(hr);
01326 }
01327
01328
01329 HRESULT
01330 CheckRequestProperties(
01331     IN ICertServerPolicy *pServer)
01332 {
01333     HRESULT hr;
01334     VARIANT varValue;
01335     BSTR strName = NULL;
01336
01337     VariantInit(&varValue);
01338
01339     strName = SysAllocString(wszPROPREQUESTREQUESTID);
01340     if (NULL == strName)
01341     {
01342         hr = E_OUTOFMEMORY;
01343   _JumpError(hr, error, "Policy:SysAllocString");
01344     }
01345
01346     hr = pServer->GetRequestProperty(strName, PROPTYPE_LONG, &varValue);
01347     _JumpIfError(hr, error, "Policy:GetRequestProperty");
01348
01349     DBGPRINT((
01350   fDebug,
01351   "Policy:CheckRequestProperties(%ws = %u)\n",
01352   strName,
01353   varValue.lVal));
01354
01355 error:
01356     VariantClear(&varValue);
01357     if (NULL != strName)
01358     {
01359         SysFreeString(strName);
01360     }
01361     return(hr);
01362 }
01363
01364
01365 //+--------------------------------------------------------------------------
01366 // CCertPolicySample::_AddRevocationExtension
01367 //
01368 // Returns S_OK on success.
01369 //+--------------------------------------------------------------------------
01370
01371 HRESULT
01372 CCertPolicySample::_AddRevocationExtension(
01373     IN ICertServerPolicy *pServer)
01374 {
01375     HRESULT hr = S_OK;
01376     ICertEncodeCRLDistInfo *pCRLDist = NULL;
01377     BSTR strCDPExtension = NULL;
01378     BSTR strASPExtension = NULL;
01379     VARIANT varExtension;
01380     DWORD i;
01381
01382     varExtension.vt = VT_BSTR;
01383     if (NULL != m_apstrCDPRevocationURL)
01384     {
01385   hr = CoCreateInstance(
01386       CLSID_CCertEncodeCRLDistInfo,
01387       NULL,               // pUnkOuter
01388       CLSCTX_INPROC_SERVER,
01389       IID_ICertEncodeCRLDistInfo,
01390       (VOID **) &pCRLDist);
01391   _JumpIfError(hr, error, "Policy:CoCreateInstance");
01392
01393   hr = pCRLDist->Reset(m_cCDPRevocationURL);
01394   _JumpIfError(hr, error, "Policy:CRLDist:Reset");
01395
01396   for (i = 0; i < m_cCDPRevocationURL; i++)
01397   {
01398       DWORD j;
01399
01400       hr = pCRLDist->SetNameCount(i, 1);
01401       _JumpIfError(hr, error, "Policy:CRLDist:SetNameCount");
01402
01403       for (j = 0; j < 1; j++)
01404       {
01405     hr = pCRLDist->SetNameEntry(
01406           i,
01407           j,
01408           CERT_ALT_NAME_URL,
01409           m_apstrCDPRevocationURL[i]);
01410     _JumpIfError(hr, error, "Policy:CRLDist:SetNameEntry");
01411       }
01412   }
01413   hr = pCRLDist->Encode(&strCDPExtension);
01414   _JumpIfError(hr, error, "Policy:CRLDist:Encode");
01415
01416
01417   varExtension.bstrVal = strCDPExtension;
01418   hr = pServer->SetCertificateExtension(
01419         TEXT(szOID_CRL_DIST_POINTS),
01420         PROPTYPE_BINARY,
01421         0,
01422         &varExtension);
01423   _JumpIfErrorStr(hr, error, "Policy:SetCertificateExtension", L"CDP");
01424     }
01425     if (NULL != m_wszASPRevocationURL)
01426     {
01427   strASPExtension = SysAllocString(m_wszASPRevocationURL);
01428   if (NULL == strASPExtension)
01429   {
01430       hr = E_OUTOFMEMORY;
01431       _JumpError(hr, error, "Policy:SysAllocString");
01432   }
01433
01434   varExtension.bstrVal = strASPExtension;
01435   hr = pServer->SetCertificateExtension(
01436         TEXT(szOID_NETSCAPE_REVOCATION_URL),
01437         PROPTYPE_STRING,
01438         0,
01439         &varExtension);
01440   _JumpIfErrorStr(hr, error, "Policy:SetCertificateExtension", L"ASP");
01441     }
01442
01443 error:
01444     if (NULL != strCDPExtension)
01445     {
01446         SysFreeString(strCDPExtension);
01447     }
01448     if (NULL != strASPExtension)
01449     {
01450         SysFreeString(strASPExtension);
01451     }
01452     if (NULL != pCRLDist)
01453     {
01454         pCRLDist->Release();
01455     }
01456     return(hr);
01457 }
01458
01459
01460 #define HIGHBIT(bitno)  (1 << (7 - (bitno)))  // bit counted from high end
01461
01462 #define SSLBIT_CLIENT ((BYTE) HIGHBIT(0)) // certified for client auth
01463 #define SSLBIT_SERVER ((BYTE) HIGHBIT(1)) // certified for server auth
01464 #define SSLBIT_SMIME  ((BYTE) HIGHBIT(2)) // certified for S/MIME
01465 #define SSLBIT_SIGN ((BYTE) HIGHBIT(3)) // certified for signing
01466
01467 #define SSLBIT_RESERVED ((BYTE) HIGHBIT(4)) // reserved for future use
01468
01469 #define SSLBIT_CASSL  ((BYTE) HIGHBIT(5)) // CA for SSL auth certs
01470 #define SSLBIT_CASMIME  ((BYTE) HIGHBIT(6)) // CA for S/MIME certs
01471 #define SSLBIT_CASIGN ((BYTE) HIGHBIT(7)) // CA for signing certs
01472
01473 #define NSCERTTYPE_CLIENT  ((BYTE) SSLBIT_CLIENT)
01474 #define NSCERTTYPE_SERVER  ((BYTE) (SSLBIT_SERVER | SSLBIT_CLIENT))
01475 #define NSCERTTYPE_SMIME   ((BYTE) SSLBIT_SMIME)
01476 #define NSCERTTYPE_CA    ((BYTE) (SSLBIT_CASSL | SSLBIT_CASMIME | SSLBIT_CASIGN))
01477
01478 //+--------------------------------------------------------------------------
01479 // CCertPolicySample::_AddCertTypeExtension
01480 //
01481 // Returns S_OK on success.
01482 //+--------------------------------------------------------------------------
01483
01484 HRESULT
01485 CCertPolicySample::_AddCertTypeExtension(
01486     IN ICertServerPolicy *pServer,
01487     IN BOOL fCA)
01488 {
01489     HRESULT hr = S_OK;
01490     ICertEncodeBitString *pBitString = NULL;
01491     BSTR strExtension = NULL;
01492     VARIANT varExtension;
01493     BSTR strBitString = NULL;
01494     BSTR strCertType = NULL;
01495     CERT_BASIC_CONSTRAINTS2_INFO Constraints;
01496     VARIANT varConstraints;
01497     DWORD cb;
01498
01499     VariantInit(&varConstraints);
01500
01501     if (EDITF_ADDOLDCERTTYPE & m_dwEditFlags)
01502     {
01503   BYTE CertType;
01504
01505   if (!fCA)
01506   {
01507       hr = pServer->GetCertificateExtension(
01508           TEXT(szOID_BASIC_CONSTRAINTS2),
01509           PROPTYPE_BINARY,
01510           &varConstraints);
01511       if (S_OK == hr)
01512       {
01513     cb = sizeof(Constraints);
01514     if (!CryptDecodeObject(
01515             X509_ASN_ENCODING,
01516             X509_BASIC_CONSTRAINTS2,
01517             (BYTE const *) varConstraints.bstrVal,
01518             SysStringByteLen(varConstraints.bstrVal),
01519             0,
01520             &Constraints,
01521             &cb))
01522     {
01523         hr = ceHLastError();
01524         _JumpError(hr, error, "Policy:CryptDecodeObject");
01525     }
01526     fCA = Constraints.fCA;
01527       }
01528   }
01529
01530   hr = CoCreateInstance(
01531       CLSID_CCertEncodeBitString,
01532       NULL,               // pUnkOuter
01533       CLSCTX_INPROC_SERVER,
01534       IID_ICertEncodeBitString,
01535       (VOID **) &pBitString);
01536   _JumpIfError(hr, error, "Policy:CoCreateInstance");
01537
01538   CertType = NSCERTTYPE_CLIENT; // Default to client auth. cert
01539   if (fCA)
01540   {
01541       CertType = NSCERTTYPE_CA;
01542   }
01543   else
01544   {
01545       hr = pServer->GetRequestAttribute(wszPROPCERTTYPE, &strCertType);
01546       if (S_OK == hr)
01547       {
01548     if (0 == lstrcmpi(strCertType, L"server"))
01549     {
01550         CertType = NSCERTTYPE_SERVER;
01551     }
01552       }
01553   }
01554
01555         if (!ceConvertWszToBstr(
01556         &strBitString,
01557         (WCHAR const *) &CertType,
01558         sizeof(CertType)))
01559   {
01560       hr = E_OUTOFMEMORY;
01561       _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01562   }
01563
01564   hr = pBitString->Encode(
01565           sizeof(CertType) * 8,
01566           strBitString,
01567           &strExtension);
01568   _JumpIfError(hr, error, "Policy:BitString:Encode");
01569
01570         varExtension.vt = VT_BSTR;
01571   varExtension.bstrVal = strExtension;
01572   hr = pServer->SetCertificateExtension(
01573         TEXT(szOID_NETSCAPE_CERT_TYPE),
01574         PROPTYPE_BINARY,
01575         0,
01576         &varExtension);
01577   _JumpIfError(hr, error, "Policy:SetCertificateExtension");
01578     }
01579
01580 error:
01581     VariantClear(&varConstraints);
01582     if (NULL != strExtension)
01583     {
01584         SysFreeString(strExtension);
01585     }
01586     if (NULL != strBitString)
01587     {
01588         SysFreeString(strBitString);
01589     }
01590     if (NULL != strCertType)
01591     {
01592         SysFreeString(strCertType);
01593     }
01594     if (NULL != pBitString)
01595     {
01596         pBitString->Release();
01597     }
01598     return(hr);
01599 }
01600
01601
01602 //+--------------------------------------------------------------------------
01603 // CCertPolicySample::_AddAuthorityInfoAccessExtension
01604 //
01605 // Returns S_OK on success.
01606 //+--------------------------------------------------------------------------
01607
01608 HRESULT
01609 CCertPolicySample::_AddAuthorityInfoAccessExtension(
01610     IN ICertServerPolicy *pServer)
01611 {
01612     HRESULT hr = S_OK;
01613     BYTE *pbEncoded = NULL;
01614     DWORD cbEncoded;
01615     BSTR strExtension = NULL;
01616     VARIANT varExtension;
01617     DWORD i;
01618
01619     CERT_AUTHORITY_INFO_ACCESS caio;
01620     caio.rgAccDescr = NULL;
01621
01622     if (NULL == m_apstrIssuerCertURL)
01623     {
01624   goto error;
01625     }
01626
01627     caio.cAccDescr = m_cIssuerCertURL;
01628     caio.rgAccDescr = (CERT_ACCESS_DESCRIPTION *) LocalAlloc(
01629       LMEM_FIXED,
01630       sizeof(CERT_ACCESS_DESCRIPTION) * m_cIssuerCertURL);
01631     if (NULL == caio.rgAccDescr)
01632     {
01633         hr = E_OUTOFMEMORY;
01634   _JumpError(hr, error, "Policy:LocalAlloc");
01635     }
01636
01637     for (i = 0; i < m_cIssuerCertURL; i++)
01638     {
01639   caio.rgAccDescr[i].pszAccessMethod = szOID_PKIX_CA_ISSUERS;
01640   caio.rgAccDescr[i].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
01641   caio.rgAccDescr[i].AccessLocation.pwszURL = m_apstrIssuerCertURL[i];
01642     }
01643
01644     if (!ceEncodeObject(
01645         X509_ASN_ENCODING,
01646         X509_AUTHORITY_INFO_ACCESS,
01647         &caio,
01648         0,
01649         FALSE,
01650         &pbEncoded,
01651         &cbEncoded))
01652     {
01653   hr = ceHLastError();
01654   _JumpError(hr, error, "Policy:ceEncodeObject");
01655     }
01656     if (!ceConvertWszToBstr(
01657       &strExtension,
01658       (WCHAR const *) pbEncoded,
01659       cbEncoded))
01660     {
01661   hr = E_OUTOFMEMORY;
01662   _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01663     }
01664
01665     varExtension.vt = VT_BSTR;
01666     varExtension.bstrVal = strExtension;
01667     hr = pServer->SetCertificateExtension(
01668           TEXT(szOID_AUTHORITY_INFO_ACCESS),
01669           PROPTYPE_BINARY,
01670           0,
01671           &varExtension);
01672     _JumpIfError(hr, error, "Policy:SetCertificateExtension(AuthInfoAccess)");
01673
01674 error:
01675     if (NULL != pbEncoded)
01676     {
01677   LocalFree(pbEncoded);
01678     }
01679     if (NULL != strExtension)
01680     {
01681         SysFreeString(strExtension);
01682     }
01683     if (NULL != caio.rgAccDescr)
01684     {
01685         LocalFree(caio.rgAccDescr);
01686     }
01687     return(hr);
01688 }
01689
01690
01691 //+--------------------------------------------------------------------------
01692 // CCertPolicySample::_AddAuthorityKeyId
01693 //
01694 // Returns S_OK on success.
01695 //+--------------------------------------------------------------------------
01696
01697 HRESULT
01698 CCertPolicySample::_AddAuthorityKeyId(
01699     IN ICertServerPolicy *pServer)
01700 {
01701     HRESULT hr = S_OK;
01702     BYTE *pbEncoded = NULL;
01703     DWORD cbEncoded;
01704     BSTR strExtension = NULL;
01705     VARIANT varExtension;
01706     PCERT_AUTHORITY_KEY_ID2_INFO pInfo = NULL;
01707     DWORD cbInfo = 0;
01708     LONG ExtFlags = 0;
01709
01710     // Optimization
01711
01712     if ((EDITF_ENABLEAKIKEYID |
01713    EDITF_ENABLEAKIISSUERNAME |
01714    EDITF_ENABLEAKIISSUERSERIAL) ==
01715   ((EDITF_ENABLEAKIKEYID |
01716     EDITF_ENABLEAKIISSUERNAME |
01717     EDITF_ENABLEAKIISSUERSERIAL |
01718     EDITF_ENABLEAKICRITICAL) & m_dwEditFlags))
01719     {
01720         goto error;
01721     }
01722
01723     hr = pServer->GetCertificateExtension(
01724                                     TEXT(szOID_AUTHORITY_KEY_IDENTIFIER2),
01725                                     PROPTYPE_BINARY,
01726                                     &varExtension);
01727     _JumpIfError(hr, error, "Policy:GetCertificateExtension");
01728
01729     hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
01730     _JumpIfError(hr, error, "Policy:GetCertificateExtensionFlags");
01731
01732     if (VT_BSTR != varExtension.vt)
01733     {
01734   hr = E_INVALIDARG;
01735   _JumpError(hr, error, "Policy:GetCertificateExtension");
01736     }
01737
01738     cbInfo = 0;
01739     if (!ceDecodeObject(
01740         X509_ASN_ENCODING,
01741                     X509_AUTHORITY_KEY_ID2,
01742                     (PBYTE)varExtension.bstrVal,
01743                     SysStringByteLen(varExtension.bstrVal),
01744         FALSE,
01745                     (PVOID *)&pInfo,
01746                     &cbInfo))
01747     {
01748   hr = ceHLastError();
01749   _JumpIfError(hr, error, "Policy:ceDecodeObject");
01750     }
01751
01752     // Make Any Modifications Here
01753
01754     if (0 == (EDITF_ENABLEAKIKEYID & m_dwEditFlags))
01755     {
01756         pInfo->KeyId.cbData = 0;
01757         pInfo->KeyId.pbData = NULL;
01758     }
01759     if (0 == (EDITF_ENABLEAKIISSUERNAME & m_dwEditFlags))
01760     {
01761         pInfo->AuthorityCertIssuer.cAltEntry = 0;
01762         pInfo->AuthorityCertIssuer.rgAltEntry = NULL;
01763     }
01764     if (0 == (EDITF_ENABLEAKIISSUERSERIAL & m_dwEditFlags))
01765     {
01766         pInfo->AuthorityCertSerialNumber.cbData = 0;
01767         pInfo->AuthorityCertSerialNumber.pbData = NULL;
01768     }
01769     if (EDITF_ENABLEAKICRITICAL & m_dwEditFlags)
01770     {
01771   ExtFlags |= EXTENSION_CRITICAL_FLAG;
01772     }
01773     if (0 ==
01774   ((EDITF_ENABLEAKIKEYID |
01775     EDITF_ENABLEAKIISSUERNAME |
01776     EDITF_ENABLEAKIISSUERSERIAL) & m_dwEditFlags))
01777     {
01778   ExtFlags |= EXTENSION_DISABLE_FLAG;
01779     }
01780
01781     VariantClear(&varExtension);
01782
01783     if (!ceEncodeObject(
01784         X509_ASN_ENCODING,
01785         X509_AUTHORITY_KEY_ID2,
01786         pInfo,
01787         0,
01788         FALSE,
01789         &pbEncoded,
01790         &cbEncoded))
01791     {
01792   hr = ceHLastError();
01793   _JumpError(hr, error, "Policy:ceEncodeObject");
01794     }
01795     if (!ceConvertWszToBstr(
01796       &strExtension,
01797       (WCHAR const *) pbEncoded,
01798       cbEncoded))
01799     {
01800   hr = E_OUTOFMEMORY;
01801   _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01802     }
01803
01804     varExtension.vt = VT_BSTR;
01805     varExtension.bstrVal = strExtension;
01806     hr = pServer->SetCertificateExtension(
01807           TEXT(szOID_AUTHORITY_KEY_IDENTIFIER2),
01808           PROPTYPE_BINARY,
01809           ExtFlags,
01810           &varExtension);
01811     _JumpIfError(hr, error, "Policy:SetCertificateExtension(AuthorityKeyId2)");
01812
01813 error:
01814     if (NULL != pInfo)
01815     {
01816   LocalFree(pInfo);
01817     }
01818     if (NULL != pbEncoded)
01819     {
01820   LocalFree(pbEncoded);
01821     }
01822     if (NULL != strExtension)
01823     {
01824         SysFreeString(strExtension);
01825     }
01826     return(hr);
01827 }
01828
01829
01830 //+--------------------------------------------------------------------------
01831 // CCertPolicy::_AddDefaultKeyUsageExtension
01832 //
01833 // Returns S_OK on success.
01834 //+--------------------------------------------------------------------------
01835
01836 HRESULT
01837 CCertPolicySample::_AddDefaultKeyUsageExtension(
01838     IN ICertServerPolicy *pServer,
01839     IN BOOL fCA)
01840 {
01841     HRESULT hr;
01842     BSTR strName = NULL;
01843     ICertEncodeBitString *pBitString = NULL;
01844     BSTR strExtension = NULL;
01845     VARIANT varExtension;
01846     BSTR strBitString = NULL;
01847     CERT_BASIC_CONSTRAINTS2_INFO Constraints;
01848     VARIANT varConstraints;
01849     VARIANT varKeyUsage;
01850     CRYPT_BIT_BLOB *pKeyUsage = NULL;
01851     DWORD cb;
01852     BYTE abKeyUsage[1];
01853     BYTE *pbKeyUsage;
01854     DWORD cbKeyUsage;
01855
01856     VariantInit(&varConstraints);
01857     VariantInit(&varKeyUsage);
01858
01859     if (EDITF_ADDOLDKEYUSAGE & m_dwEditFlags)
01860     {
01861   BOOL fModified = FALSE;
01862
01863   if (!fCA)
01864   {
01865       hr = pServer->GetCertificateExtension(
01866           TEXT(szOID_BASIC_CONSTRAINTS2),
01867           PROPTYPE_BINARY,
01868           &varConstraints);
01869       if (S_OK == hr)
01870       {
01871     cb = sizeof(Constraints);
01872     if (!CryptDecodeObject(
01873             X509_ASN_ENCODING,
01874             X509_BASIC_CONSTRAINTS2,
01875             (BYTE const *) varConstraints.bstrVal,
01876             SysStringByteLen(varConstraints.bstrVal),
01877             0,
01878             &Constraints,
01879             &cb))
01880     {
01881         hr = ceHLastError();
01882         _JumpError(hr, error, "Policy:CryptDecodeObject");
01883     }
01884     fCA = Constraints.fCA;
01885       }
01886   }
01887
01888   ZeroMemory(abKeyUsage, sizeof(abKeyUsage));
01889   pbKeyUsage = abKeyUsage;
01890   cbKeyUsage = sizeof(abKeyUsage);
01891
01892   hr = pServer->GetCertificateExtension(
01893             TEXT(szOID_KEY_USAGE),
01894             PROPTYPE_BINARY,
01895             &varKeyUsage);
01896   if (S_OK == hr)
01897   {
01898       if (!ceDecodeObject(
01899           X509_ASN_ENCODING,
01900           X509_KEY_USAGE,
01901           (BYTE const *) varKeyUsage.bstrVal,
01902           SysStringByteLen(varKeyUsage.bstrVal),
01903           FALSE,
01904           (VOID **) &pKeyUsage,
01905           &cb))
01906       {
01907     hr = GetLastError();
01908     _PrintError(hr, "Policy:ceDecodeObject");
01909       }
01910       else if (0 != cb && NULL != pKeyUsage && 0 != pKeyUsage->cbData)
01911       {
01912     pbKeyUsage = pKeyUsage->pbData;
01913     cbKeyUsage = pKeyUsage->cbData;
01914       }
01915   }
01916
01917   if ((CERT_KEY_ENCIPHERMENT_KEY_USAGE & pbKeyUsage[0]) &&
01918       (CERT_KEY_AGREEMENT_KEY_USAGE & pbKeyUsage[0]))
01919   {
01920       pbKeyUsage[0] &= ~CERT_KEY_AGREEMENT_KEY_USAGE;
01921       pbKeyUsage[0] |= CERT_DIGITAL_SIGNATURE_KEY_USAGE |
01922         CERT_NON_REPUDIATION_KEY_USAGE;
01923       fModified = TRUE;
01924   }
01925   if (fCA)
01926   {
01927       pbKeyUsage[0] |= CERT_KEY_CERT_SIGN_KEY_USAGE |
01928         CERT_CRL_SIGN_KEY_USAGE |
01929         CERT_DIGITAL_SIGNATURE_KEY_USAGE |
01930         CERT_NON_REPUDIATION_KEY_USAGE;
01931       fModified = TRUE;
01932   }
01933   if (fModified)
01934   {
01935       hr = CoCreateInstance(
01936           CLSID_CCertEncodeBitString,
01937           NULL,               // pUnkOuter
01938           CLSCTX_INPROC_SERVER,
01939           IID_ICertEncodeBitString,
01940           (VOID **) &pBitString);
01941       _JumpIfError(hr, error, "Policy:CoCreateInstance");
01942
01943       if (!ceConvertWszToBstr(
01944       &strBitString,
01945       (WCHAR const *) pbKeyUsage,
01946       cbKeyUsage))
01947       {
01948     hr = E_OUTOFMEMORY;
01949     _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01950       }
01951
01952       hr = pBitString->Encode(cbKeyUsage * 8, strBitString, &strExtension);
01953       _JumpIfError(hr, error, "Policy:Encode");
01954
01955       if (!ceConvertWszToBstr(&strName, TEXT(szOID_KEY_USAGE), -1))
01956       {
01957     hr = E_OUTOFMEMORY;
01958     _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01959       }
01960       varExtension.vt = VT_BSTR;
01961       varExtension.bstrVal = strExtension;
01962       hr = pServer->SetCertificateExtension(
01963             strName,
01964             PROPTYPE_BINARY,
01965             0,
01966             &varExtension);
01967       _JumpIfError(hr, error, "Policy:SetCertificateExtension");
01968   }
01969     }
01970     hr = S_OK;
01971
01972 error:
01973     VariantClear(&varConstraints);
01974     VariantClear(&varKeyUsage);
01975     if (NULL != pKeyUsage)
01976     {
01977         LocalFree(pKeyUsage);
01978     }
01979     if (NULL != strName)
01980     {
01981         SysFreeString(strName);
01982     }
01983     if (NULL != strExtension)
01984     {
01985         SysFreeString(strExtension);
01986     }
01987     if (NULL != strBitString)
01988     {
01989         SysFreeString(strBitString);
01990     }
01991     if (NULL != pBitString)
01992     {
01993         pBitString->Release();
01994     }
01995     return(hr);
01996 }
01997
01998 //+--------------------------------------------------------------------------
01999 // CCertPolicy::_AddDefaultBasicConstraintsExtension
02000 //
02001 // Returns S_OK on success.
02002 //+--------------------------------------------------------------------------
02003
02004 HRESULT
02005 CCertPolicySample::_AddDefaultBasicConstraintsExtension(
02006     IN ICertServerPolicy *pServer,
02007     IN BOOL               fCA)
02008 {
02009     HRESULT hr;
02010     VARIANT varExtension;
02011     LONG ExtFlags;
02012     CERT_EXTENSION Ext;
02013     CERT_EXTENSION *pExtension = NULL;
02014     BSTR strCertType = NULL;
02015
02016     VariantInit(&varExtension);
02017
02018     if (EDITF_BASICCONSTRAINTSCA & m_dwEditFlags)
02019     {
02020         hr = pServer->GetCertificateExtension(
02021                 TEXT(szOID_BASIC_CONSTRAINTS2),
02022                 PROPTYPE_BINARY,
02023                 &varExtension);
02024         if (S_OK == hr)
02025         {
02026       CERT_BASIC_CONSTRAINTS2_INFO Constraints;
02027       DWORD cb;
02028
02029       hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
02030       if (S_OK == hr)
02031       {
02032                 Ext.pszObjId = szOID_BASIC_CONSTRAINTS2;
02033                 Ext.fCritical = FALSE;
02034                 if (EXTENSION_CRITICAL_FLAG & ExtFlags)
02035                 {
02036                     Ext.fCritical = TRUE;
02037                 }
02038                 Ext.Value.pbData = (BYTE *) varExtension.bstrVal;
02039                 Ext.Value.cbData = SysStringByteLen(varExtension.bstrVal);
02040     pExtension = &Ext;
02041
02042     cb = sizeof(Constraints);
02043     if (!fCA && CryptDecodeObject(
02044               X509_ASN_ENCODING,
02045               X509_BASIC_CONSTRAINTS2,
02046               Ext.Value.pbData,
02047               Ext.Value.cbData,
02048               0,
02049               &Constraints,
02050               &cb))
02051     {
02052         fCA = Constraints.fCA;
02053     }
02054       }
02055   }
02056     }
02057
02058     if (EDITF_ATTRIBUTECA & m_dwEditFlags)
02059     {
02060         if (!fCA)
02061         {
02062             hr = pServer->GetRequestAttribute(
02063                     wszPROPCERTTYPE,
02064                     &strCertType);
02065             if (S_OK == hr)
02066             {
02067                 if (0 == lstrcmpi(strCertType, L"ca"))
02068                 {
02069                     fCA = TRUE;
02070                 }
02071             }
02072         }
02073         if (!fCA)
02074         {
02075             hr = pServer->GetRequestAttribute(
02076                     wszPROPCERTTEMPLATE,
02077                     &strCertType);
02078             if (S_OK == hr)
02079             {
02080                 if (0 == lstrcmpi(strCertType, wszCERTTYPE_SUBORDINATE_CA))
02081                 {
02082                     fCA = TRUE;
02083                 }
02084             }
02085   }
02086     }
02087
02088     // For standalone, the extension is only enabled if it's a CA
02089
02090     hr = AddBasicConstraintsCommon(pServer, pExtension, fCA, fCA);
02091     _JumpIfError(hr, error, "Policy:AddBasicConstraintsCommon");
02092
02093 error:
02094     VariantClear(&varExtension);
02095     if (NULL != strCertType)
02096     {
02097         SysFreeString(strCertType);
02098     }
02099     return(hr);
02100 }
02101
02102
02103 HRESULT
02104 CCertPolicySample::AddBasicConstraintsCommon(
02105     IN ICertServerPolicy *pServer,
02106     IN CERT_EXTENSION const *pExtension,
02107     IN BOOL fCA,
02108     IN BOOL fEnableExtension)
02109 {
02110     HRESULT hr;
02111     BSTR strExtension = NULL;
02112     VARIANT varExtension;
02113     CERT_CONTEXT const *pIssuerCert;
02114     CERT_EXTENSION *pIssuerExtension;
02115     LONG ExtFlags = 0;
02116     BYTE *pbConstraints = NULL;
02117     CERT_BASIC_CONSTRAINTS2_INFO Constraints;
02118     CERT_BASIC_CONSTRAINTS2_INFO IssuerConstraints;
02119     ZeroMemory(&IssuerConstraints, sizeof(IssuerConstraints));
02120
02121     DWORD cb;
02122
02123     pIssuerCert = _GetIssuer(pServer);
02124     if (NULL == pIssuerCert)
02125     {
02126         hr = E_POINTER;
02127         _JumpError(hr, error, "_GetIssuer");
02128     }
02129
02130     if (NULL != pExtension)
02131     {
02132         cb = sizeof(Constraints);
02133         if (!CryptDecodeObject(
02134       X509_ASN_ENCODING,
02135       X509_BASIC_CONSTRAINTS2,
02136       pExtension->Value.pbData,
02137       pExtension->Value.cbData,
02138       0,
02139       &Constraints,
02140       &cb))
02141         {
02142       hr = ceHLastError();
02143       _JumpError(hr, error, "Policy:CryptDecodeObject");
02144         }
02145
02146         // Cert templates use CAPATHLENGTH_INFINITE to indicate
02147         // fPathLenConstraint should be FALSE.
02148
02149         if (CAPATHLENGTH_INFINITE == Constraints.dwPathLenConstraint)
02150         {
02151
02152             // NOTE: This is ok as certcli already sets fPathLenConstraint to FALSE
02153             // for templates in this case.
02154       Constraints.fPathLenConstraint = FALSE;
02155
02156             // NOTE: This is ok as autoenrollment ignores dwPathLenConstraint
02157             // if fPathLenConstraint is FALSE;
02158       Constraints.dwPathLenConstraint = 0;
02159         }
02160         if (pExtension->fCritical)
02161         {
02162       ExtFlags = EXTENSION_CRITICAL_FLAG;
02163         }
02164     }
02165     else
02166     {
02167   Constraints.fCA = fCA;
02168   Constraints.fPathLenConstraint = FALSE;
02169   Constraints.dwPathLenConstraint = 0;
02170     }
02171     if (EDITF_BASICCONSTRAINTSCRITICAL & m_dwEditFlags)
02172     {
02173         ExtFlags = EXTENSION_CRITICAL_FLAG;
02174     }
02175
02176     // Check basic constraints against the issuer's cert.
02177
02178     pIssuerExtension = CertFindExtension(
02179         szOID_BASIC_CONSTRAINTS2,
02180         pIssuerCert->pCertInfo->cExtension,
02181         pIssuerCert->pCertInfo->rgExtension);
02182     if (NULL != pIssuerExtension)
02183     {
02184         cb = sizeof(IssuerConstraints);
02185         if (!CryptDecodeObject(
02186               X509_ASN_ENCODING,
02187               X509_BASIC_CONSTRAINTS2,
02188               pIssuerExtension->Value.pbData,
02189               pIssuerExtension->Value.cbData,
02190               0,
02191               &IssuerConstraints,
02192               &cb))
02193         {
02194             hr = ceHLastError();
02195             _JumpError(hr, error, "Policy:CryptDecodeObject");
02196         }
02197         if (!IssuerConstraints.fCA)
02198         {
02199             hr = CERTSRV_E_INVALID_CA_CERTIFICATE;
02200             _JumpError(hr, error, "Policy:CA cert not a CA cert");
02201         }
02202     }
02203
02204     if (Constraints.fCA)
02205     {
02206         if (IssuerConstraints.fPathLenConstraint)
02207         {
02208             if (0 == IssuerConstraints.dwPathLenConstraint)
02209             {
02210                 hr = CERTSRV_E_INVALID_CA_CERTIFICATE;
02211                 _JumpError(hr, error, "Policy:CA cert is a leaf CA cert");
02212             }
02213             if (!Constraints.fPathLenConstraint ||
02214                 Constraints.dwPathLenConstraint >
02215               IssuerConstraints.dwPathLenConstraint - 1)
02216             {
02217                 Constraints.fPathLenConstraint = TRUE;
02218                 Constraints.dwPathLenConstraint =
02219                 IssuerConstraints.dwPathLenConstraint - 1;
02220             }
02221         }
02222         if (CAPATHLENGTH_INFINITE != m_CAPathLength)
02223         {
02224             if (0 == m_CAPathLength)
02225             {
02226                 hr = CERTSRV_E_INVALID_CA_CERTIFICATE;
02227                 _JumpError(hr, error, "Policy:Registry says not to issue CA certs");
02228             }
02229             if (!Constraints.fPathLenConstraint ||
02230                 Constraints.dwPathLenConstraint > m_CAPathLength - 1)
02231             {
02232                 Constraints.fPathLenConstraint = TRUE;
02233                 Constraints.dwPathLenConstraint = m_CAPathLength - 1;
02234             }
02235         }
02236     }
02237
02238     if(!fEnableExtension)
02239     {
02240         ExtFlags |= EXTENSION_DISABLE_FLAG;
02241     }
02242
02243     if (!ceEncodeObject(
02244         X509_ASN_ENCODING,
02245                     X509_BASIC_CONSTRAINTS2,
02246                     &Constraints,
02247         0,
02248         FALSE,
02249                     &pbConstraints,
02250                     &cb))
02251     {
02252         hr = ceHLastError();
02253         _JumpError(hr, error, "Policy:ceEncodeObject");
02254     }
02255
02256     if (!ceConvertWszToBstr(
02257       &strExtension,
02258       (WCHAR const *) pbConstraints,
02259       cb))
02260     {
02261         hr = E_OUTOFMEMORY;
02262         _JumpError(hr, error, "Policy:ceConvertWszToBstr");
02263     }
02264
02265     varExtension.vt = VT_BSTR;
02266     varExtension.bstrVal = strExtension;
02267     hr = pServer->SetCertificateExtension(
02268           TEXT(szOID_BASIC_CONSTRAINTS2),
02269           PROPTYPE_BINARY,
02270           ExtFlags,
02271           &varExtension);
02272     _JumpIfError(hr, error, "Policy:SetCertificateExtensioo");
02273
02274 error:
02275     if (NULL != pbConstraints)
02276     {
02277         LocalFree(pbConstraints);
02278     }
02279     if (NULL != strExtension)
02280     {
02281         SysFreeString(strExtension);
02282     }
02283
02284     return(hr);
02285 }
02286
02287
02288 //+--------------------------------------------------------------------------
02289 // CCertPolicy::_SetValidityPeriod
02290 //
02291 // Returns S_OK on success.
02292 //+--------------------------------------------------------------------------
02293
02294 HRESULT
02295 CCertPolicySample::_SetValidityPeriod(
02296     IN ICertServerPolicy *pServer)
02297 {
02298     HRESULT hr;
02299     BSTR strNamePeriodString = NULL;
02300     BSTR strNamePeriodCount = NULL;
02301     BSTR strPeriodString = NULL;
02302     BSTR strPeriodCount = NULL;
02303     VARIANT varValue;
02304     LONG lDelta;
02305     ENUM_PERIOD enumValidityPeriod;
02306     BOOL fValidDigitString;
02307
02308     VariantInit(&varValue);
02309
02310     if (!(EDITF_ATTRIBUTEENDDATE & m_dwEditFlags))
02311     {
02312   hr = S_OK;
02313   goto error;
02314     }
02315
02316     hr = E_OUTOFMEMORY;
02317     strNamePeriodString = SysAllocString(wszPROPVALIDITYPERIODSTRING);
02318     if (NULL == strNamePeriodString)
02319     {
02320         assert(E_OUTOFMEMORY == hr);
02321   _JumpError(hr, error, "Policy:SysAllocString");
02322     }
02323
02324     strNamePeriodCount = SysAllocString(wszPROPVALIDITYPERIODCOUNT);
02325     if (NULL == strNamePeriodCount)
02326     {
02327         assert(E_OUTOFMEMORY == hr);
02328         _JumpError(hr, error, "Policy:SysAllocString");
02329     }
02330
02331     hr = pServer->GetRequestAttribute(strNamePeriodString, &strPeriodString);
02332     if (S_OK != hr)
02333     {
02334   _PrintErrorStr2(
02335     hr,
02336     "Policy:GetRequestAttribute",
02337     strNamePeriodString,
02338     CERTSRV_E_PROPERTY_EMPTY);
02339   if (CERTSRV_E_PROPERTY_EMPTY == hr)
02340   {
02341       hr = S_OK;
02342   }
02343   goto error;
02344     }
02345     hr = pServer->GetRequestAttribute(strNamePeriodCount, &strPeriodCount);
02346     if (S_OK != hr)
02347     {
02348   _PrintErrorStr2(
02349     hr,
02350     "Policy:GetRequestAttribute",
02351     strNamePeriodCount,
02352     CERTSRV_E_PROPERTY_EMPTY);
02353   if (CERTSRV_E_PROPERTY_EMPTY == hr)
02354   {
02355       hr = S_OK;
02356   }
02357   goto error;
02358     }
02359
02360     // Swap Count and String BSTRs if backwards -- Windows 2000 had it wrong.
02361
02362     lDelta = ceWtoI(strPeriodCount, &fValidDigitString);
02363     if (!fValidDigitString)
02364     {
02365   BSTR str = strPeriodCount;
02366
02367   strPeriodCount = strPeriodString;
02368   strPeriodString = str;
02369   lDelta = ceWtoI(strPeriodCount, &fValidDigitString);
02370   if (!fValidDigitString)
02371   {
02372       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
02373       _JumpError(hr, error, "Policy:ceWtoI");
02374   }
02375     }
02376
02377     hr = ceTranslatePeriodUnits(strPeriodString, lDelta, &enumValidityPeriod, &lDelta);
02378     _JumpIfError(hr, error, "Policy:ceTranslatePeriodUnits");
02379
02380     hr = pServer->GetCertificateProperty(
02381         wszPROPCERTIFICATENOTBEFOREDATE,
02382         PROPTYPE_DATE,
02383         &varValue);
02384     _JumpIfError(hr, error, "Policy:GetCertificateProperty");
02385
02386     hr = ceMakeExprDate(&varValue.date, lDelta, enumValidityPeriod);
02387     _JumpIfError(hr, error, "Policy:ceMakeExprDate");
02388
02389     hr = pServer->SetCertificateProperty(
02390         wszPROPCERTIFICATENOTAFTERDATE,
02391         PROPTYPE_DATE,
02392         &varValue);
02393     _JumpIfError(hr, error, "Policy:SetCertificateProperty");
02394
02395     hr = S_OK;
02396
02397 error:
02398     VariantClear(&varValue);
02399     if (NULL != strNamePeriodString)
02400     {
02401   SysFreeString(strNamePeriodString);
02402     }
02403     if (NULL != strNamePeriodCount)
02404     {
02405   SysFreeString(strNamePeriodCount);
02406     }
02407     if (NULL != strPeriodString)
02408     {
02409   SysFreeString(strPeriodString);
02410     }
02411     if (NULL != strPeriodCount)
02412     {
02413   SysFreeString(strPeriodCount);
02414     }
02415     return(hr);
02416 }
02417
02418
02419 //+--------------------------------------------------------------------------
02420 // CCertPolicySample::_AddSubjectAltNameExtension
02421 //
02422 // Returns S_OK on success.
02423 //+--------------------------------------------------------------------------
02424 HRESULT
02425 CCertPolicySample::_AddSubjectAltNameExtension(
02426     IN ICertServerPolicy *pServer,
02427     IN DWORD iAltName)
02428 {
02429     HRESULT hr = S_OK;
02430     ICertEncodeAltName *pAltName = NULL;
02431     BSTR strExtension = NULL;
02432     VARIANT varExtension;
02433     BSTR strCertType = NULL;
02434     BSTR strName = NULL;
02435     VARIANT varValue;
02436
02437     VariantInit(&varValue);
02438     if (NULL != m_astrSubjectAltNameProp[iAltName])
02439     {
02440   hr = CoCreateInstance(
02441       CLSID_CCertEncodeAltName,
02442       NULL,               // pUnkOuter
02443       CLSCTX_INPROC_SERVER,
02444       IID_ICertEncodeAltName,
02445       (VOID **) &pAltName);
02446   _JumpIfError(hr, error, "Policy:CoCreateInstance");
02447
02448   hr = pServer->GetRequestProperty(
02449             m_astrSubjectAltNameProp[iAltName],
02450             PROPTYPE_STRING,
02451             &varValue);
02452   if (S_OK != hr)
02453   {
02454       DBGPRINT((
02455     fDebug,
02456     "Policy:GetRequestProperty(%ws):%s %x\n",
02457     m_astrSubjectAltNameProp[iAltName],
02458     CERTSRV_E_PROPERTY_EMPTY == hr? " MISSING ATTRIBUTE" : "",
02459     hr));
02460       if (CERTSRV_E_PROPERTY_EMPTY == hr)
02461       {
02462     hr = S_OK;
02463       }
02464       goto error;
02465   }
02466         if (VT_BSTR != varValue.vt)
02467   {
02468       hr = E_INVALIDARG;
02469       _JumpError(hr, error, "Policy:varValue.vt");
02470   }
02471
02472         if (L'\0' == varValue.bstrVal[0])
02473   {
02474       hr = S_OK;
02475       goto error;
02476   }
02477         if (!ceConvertWszToBstr(&strName, varValue.bstrVal, -1))
02478   {
02479       hr = E_OUTOFMEMORY;
02480       _JumpError(hr, error, "Policy:ceConvertWszToBstr");
02481   }
02482
02483   hr = pAltName->Reset(1);
02484   _JumpIfError(hr, error, "Policy:AltName:Reset");
02485
02486   hr = pAltName->SetNameEntry(0, CERT_ALT_NAME_RFC822_NAME, strName);
02487   _JumpIfError(hr, error, "Policy:AltName:SetNameEntry");
02488
02489   hr = pAltName->Encode(&strExtension);
02490   _JumpIfError(hr, error, "Policy:AltName:Encode");
02491
02492         varExtension.vt = VT_BSTR;
02493   varExtension.bstrVal = strExtension;
02494   hr = pServer->SetCertificateExtension(
02495         m_astrSubjectAltNameObjectId[iAltName],
02496         PROPTYPE_BINARY,
02497         0,
02498         &varExtension);
02499   _JumpIfError(hr, error, "Policy:SetCertificateExtension");
02500     }
02501
02502 error:
02503     if (NULL != strName)
02504     {
02505         SysFreeString(strName);
02506     }
02507     if (NULL != strExtension)
02508     {
02509         SysFreeString(strExtension);
02510     }
02511     if (NULL != pAltName)
02512     {
02513         pAltName->Release();
02514     }
02515     VariantClear(&varValue);
02516     return(hr);
02517 }
02518
02519
02520 STDMETHODIMP
02521 CCertPolicySample::VerifyRequest(
02522     /* [in] */ BSTR const strConfig,
02523     /* [in] */ LONG Context,
02524     /* [in] */ LONG bNewRequest,
02525     /* [in] */ LONG Flags,
02526     /* [out, retval] */ LONG __RPC_FAR *pDisposition)
02527 {
02528     HRESULT hr = E_FAIL;
02529     ICertServerPolicy *pServer = NULL;
02530     BOOL fCA = FALSE;
02531     BSTR strName = NULL;
02532     BSTR strDisposition = NULL;
02533
02534
02535     EnterCriticalSection(&m_PolicyCriticalSection);
02536
02537     if (NULL == pDisposition)
02538     {
02539         hr = E_POINTER;
02540         _JumpError(hr, error, "Policy:pDisposition");
02541     }
02542     *pDisposition = VR_INSTANT_BAD;
02543
02544     hr = GetServerCallbackInterface(&pServer, Context);
02545     _JumpIfError(hr, error, "Policy:GetServerCallbackInterface");
02546
02547
02548     // only need to check user access for original submitter: resubmittal is restricted to admin
02549     if(bNewRequest && (0 == (m_dwEditFlags & EDITF_IGNOREREQUESTERGROUP)))
02550     {
02551         BOOL fRequesterAccess = FALSE;
02552         VARIANT varValue;
02553         VariantInit(&varValue);
02554
02555         // Is this user allowed to request certs?
02556         hr = pServer->GetCertificateProperty(
02557             wszPROPREQUESTERCAACCESS,
02558             PROPTYPE_LONG,
02559             &varValue);
02560   _PrintIfErrorStr(hr, "Policy:GetCertificateProperty", wszPROPREQUESTERCAACCESS);
02561         if(hr == S_OK)
02562         {
02563             fRequesterAccess = varValue.lVal;
02564         }
02565         VariantClear(&varValue);
02566
02567         if(!fRequesterAccess)
02568         {
02569             hr = E_ACCESSDENIED;
02570             _JumpError(hr, deny, "Policy:fRequesterAccess");
02571         }
02572     }
02573
02574
02575     hr = _EnumerateExtensions(pServer, bNewRequest, &fCA);
02576     _JumpIfError(hr, error, "_EnumerateExtensions");
02577
02578     {
02579         hr = _SetValidityPeriod(pServer);
02580         _JumpIfError(hr, error, "_SetValidityPeriod");
02581
02582         hr = _AddDefaultBasicConstraintsExtension(pServer, fCA);
02583         _JumpIfError(hr, error, "_AddDefaultBasicConstraintsExtension");
02584
02585         hr = _AddDefaultKeyUsageExtension(pServer, fCA);
02586         _JumpIfError(hr, error, "_AddDefaultKeyUsageExtension");
02587
02588         hr = _AddSubjectAltNameExtension(pServer, 0);
02589         _JumpIfError(hr, error, "_AddSubjectAltNameExtension");
02590
02591         hr = _AddSubjectAltNameExtension(pServer, 1);
02592         _JumpIfError(hr, error, "_AddSubjectAltNameExtension");
02593     }
02594
02595     hr = EnumerateAttributes(pServer);
02596     _JumpIfError(hr, error, "Policy:EnumerateAttributes");
02597
02598     hr = _AddRevocationExtension(pServer);
02599     _JumpIfError(hr, error, "_AddRevocationExtension");
02600
02601     hr = _AddCertTypeExtension(pServer, fCA);
02602     _JumpIfError(hr, error, "_AddCertTypeExtension");
02603
02604     hr = _AddAuthorityInfoAccessExtension(pServer);
02605     _JumpIfError(hr, error, "_AddAuthorityInfoAccessExtension");
02606
02607     hr = _AddAuthorityKeyId(pServer);
02608     _JumpIfError(hr, error, "_AddAuthorityKeyId");
02609
02610
02611
02612     hr = CheckRequestProperties(pServer);
02613     _JumpIfError(hr, deny, "Policy:CheckRequestProperties"); // pass hr as Disposition
02614
02615     if (EDITF_DISABLEEXTENSIONLIST & m_dwEditFlags)
02616     {
02617   hr = _EnumerateExtensions(pServer, bNewRequest, NULL);
02618   _JumpIfError(hr, error, "_EnumerateExtensions");
02619     }
02620
02621     if (bNewRequest && (REQDISP_PENDINGFIRST & m_dwDispositionFlags))
02622     {
02623   *pDisposition = VR_PENDING;
02624     }
02625     else switch (REQDISP_MASK & m_dwDispositionFlags)
02626     {
02627   default:
02628   case REQDISP_PENDING:
02629       *pDisposition = VR_PENDING;
02630       break;
02631
02632   case REQDISP_ISSUE:
02633       *pDisposition = VR_INSTANT_OK;
02634       break;
02635
02636   case REQDISP_DENY:
02637       *pDisposition = VR_INSTANT_BAD;
02638       break;
02639
02640   case REQDISP_USEREQUESTATTRIBUTE:
02641       *pDisposition = VR_INSTANT_OK;
02642
02643       strName = SysAllocString(wszPROPDISPOSITION);
02644       if (NULL == strName)
02645       {
02646           hr = E_OUTOFMEMORY;
02647     _JumpError(hr, error, "Policy:SysAllocString");
02648       }
02649       hr = pServer->GetRequestAttribute(strName, &strDisposition);
02650       if (S_OK == hr)
02651       {
02652     if (0 == lstrcmpi(wszPROPDISPOSITIONDENY, strDisposition))
02653     {
02654         *pDisposition = VR_INSTANT_BAD;
02655     }
02656     if (0 == lstrcmpi(wszPROPDISPOSITIONPENDING, strDisposition))
02657     {
02658         *pDisposition = VR_PENDING;
02659     }
02660       }
02661       hr = S_OK;
02662       break;
02663     }
02664
02665 deny:
02666     if (FAILED(hr))
02667     {
02668         *pDisposition = hr; // pass failed HRESULT back as Disposition
02669     }
02670     else if(hr != S_OK)
02671     {
02672         *pDisposition = VR_INSTANT_BAD;
02673     }
02674     hr = S_OK;
02675
02676 error:
02677     if (NULL != strName)
02678     {
02679   SysFreeString(strName);
02680     }
02681     if (NULL != strDisposition)
02682     {
02683   SysFreeString(strDisposition);
02684     }
02685     if (NULL != pServer)
02686     {
02687         pServer->Release();
02688     }
02689     LeaveCriticalSection(&m_PolicyCriticalSection);
02690     //_PrintIfError(hr, "Policy:VerifyRequest(hr)");
02691     //_PrintError(*pDisposition, "Policy:VerifyRequest(*pDisposition)");
02692     return(hr);
02693 }
02694
02695
02696 //+--------------------------------------------------------------------------
02697 // CCertPolicySample::GetDescription
02698 //
02699 // Returns S_OK on success.
02700 //+--------------------------------------------------------------------------
02701
02702 STDMETHODIMP
02703 CCertPolicySample::GetDescription(
02704     /* [out, retval] */ BSTR __RPC_FAR *pstrDescription)
02705 {
02706     HRESULT hr = S_OK;
02707
02708     if (NULL != *pstrDescription)
02709     {
02710         SysFreeString(*pstrDescription);
02711     }
02712
02713     *pstrDescription = SysAllocString(m_bstrDescription);
02714     if (NULL == *pstrDescription)
02715     {
02716         hr = E_OUTOFMEMORY;
02717     }
02718     return(hr);
02719 }
02720
02721
02722 //+--------------------------------------------------------------------------
02723 // CCertPolicySample::ShutDown
02724 //
02725 // Returns S_OK on success.
02726 //+--------------------------------------------------------------------------
02727
02728 STDMETHODIMP
02729 CCertPolicySample::ShutDown(VOID)
02730 {
02731     // called once, as Server unloading policy dll
02732     _Cleanup();
02733
02734
02735     return(S_OK);
02736 }
02737
02738
02739 //+--------------------------------------------------------------------------
02740 // CCertPolicySample::_GetIssuer
02741 //
02742 // Returns S_OK on success.
02743 //+--------------------------------------------------------------------------
02744
02745 PCCERT_CONTEXT
02746 CCertPolicySample::_GetIssuer(
02747     IN ICertServerPolicy *pServer)
02748 {
02749     HRESULT hr;
02750     VARIANT varValue;
02751     if(m_pCert)
02752     {
02753         return m_pCert;
02754     }
02755     VariantInit(&varValue);
02756     hr = pServer->GetCertificateProperty(wszPROPRAWCACERTIFICATE, PROPTYPE_BINARY, &varValue);
02757     if(hr != S_OK)
02758     {
02759         return NULL;
02760     }
02761
02762     m_pCert = CertCreateCertificateContext(X509_ASN_ENCODING, (PBYTE)varValue.bstrVal, SysStringByteLen(varValue.bstrVal));
02763
02764     VariantClear(&varValue);
02765     return(m_pCert);
02766 }
02767
02768
02769 STDMETHODIMP
02770 CCertPolicySample::InterfaceSupportsErrorInfo(
02771     IN REFIID riid)
02772 {
02773     static const IID *arr[] =
02774     {
02775         &IID_ICertPolicy,
02776     };
02777
02778     for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
02779     {
02780         if (IsEqualGUID(*arr[i], riid))
02781         {
02782             return(S_OK);
02783         }
02784     }
02785     return(S_FALSE);
02786 }
02787
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/Help source/mmcsample.h Source File

  • SysMgmt
  • MMC
  • Help
  • Help source

mmcsample.h

Go to the documentation of this file.
00001 //
00002 // MMCSample.h
00003 //
00004 //   Contains header information for HTML API calls
00005 //  so that our sample MMC snap-ins can find help information
00006 //
00007 #define HELP_STEPONE    101
00008 #define HELP_STEPTWO    102
00009 #define HELP_STEPTHREE  103
00010 #define HELP_STEPFOUR   104
00011
00012 #define HELP_DEFAULT    0
00013 #define HELP_INTRO      1
00014
00015
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/guids.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

guids.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Note that the GUIDs for CComponentData and CSnapinAbout are different
00014 //  from the ScopeNode project.  The Node GUIDs can stay the same since
00015 //  they are not really COM objects.
00016
00017
00018 #ifndef _DRAGDROP_PROJECT_GUIDS_
00019 #define _DRAGDROP_PROJECT_GUIDS_
00020
00021 // {c6f2200f-7e99-4313-8c30-69555ff913de}
00022 DEFINE_GUID( CLSID_CComponentData,
00023              0xc6f2200f, 0x7e99, 0x4313, 0x8c, 0x30, 0x69, 0x55, 0x5f, 0xf9, 0x13, 0xde);
00024
00025 // {8abe0b8c-bf73-4065-bbd0-afb8a617ac23}
00026 DEFINE_GUID( CLSID_CSnapinAbout,
00027              0x8abe0b8c, 0xbf73, 0x4065, 0xbb, 0xd0, 0xaf, 0xb8, 0xa6, 0x17, 0xac, 0x23);
00028
00029 // {520F23F9-775D-4015-B437-98A24B9D085E}
00030 DEFINE_GUID( CLSID_DeviceNode,
00031              0x520F23f9, 0x775D, 0x4015, 0xB4, 0x37, 0x98, 0xA2, 0x4B, 0x9D, 0x8, 0x5E);
00032
00033
00034 // {520F23FA-775D-4015-B437-98A24B9D085E}
00035 DEFINE_GUID( CLSID_CFolderNode,
00036              0x520F23fA, 0x775D, 0x4015, 0xb4, 0x37, 0x98, 0xA2, 0x4B, 0x9D, 0x8, 0x5E);
00037
00038 // {f0091c49-c869-4941-a81c-c719ad8174cc}
00039 DEFINE_GUID( CLSID_CVirtualFile,
00040              0xf0091c49, 0xc869, 0x4941, 0xa8, 0x1c, 0xc7, 0x19, 0xad, 0x81, 0x74, 0xcc);
00041
00042
00043 #endif //_DRAGDROP_PROJECT_GUIDS_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/StatNode.Cpp Source File

  • SysMgmt
  • MMC
  • Help

StatNode.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "StatNode.h"
00021
00022 const GUID CStaticNode::thisGuid = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CStaticNode implementation
00027 //
00028 //
00029 CStaticNode::CStaticNode()
00030 {
00031 }
00032
00033 CStaticNode::~CStaticNode()
00034 {
00035 }
00036
00037 HRESULT CStaticNode::OnShowContextHelp(IDisplayHelp *pDisplayHelp, LPOLESTR helpFile)
00038 {
00039     WCHAR topicName[MAX_PATH];
00040
00041     wcscpy(topicName, helpFile);
00042
00043     // we should read this from a resource file
00044     wcscat(topicName, L"::/default.htm");
00045
00046     LPOLESTR pszTopic = static_cast<LPOLESTR>(CoTaskMemAlloc((wcslen(topicName) + 1) * sizeof(WCHAR)));
00047
00048     wcscpy(pszTopic, topicName);
00049
00050     return pDisplayHelp->ShowTopic(pszTopic);
00051 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

EDITARGS Member List

This is the complete list of members for EDITARGS, including all inherited members.
option | EDITARGS
selection | EDITARGS
view | EDITARGS
Generated on Wed Nov 13 2024 16:57:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/DUnion/DUnion.Idl Source File

  • NetDS
  • RPC
  • Data
  • DUnion

DUnion.Idl

Go to the documentation of this file.
00001 [ uuid (87E5BFA0-CA46-1067-B31B-00DD010662DA),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface dunion
00006 {
00007
00008 typedef [switch_type(short)] union {
00009     [case(0)] short          sVal;
00010     [case(1)] float          fVal;
00011     [case(2)] unsigned char  chVal;
00012     [default] ;
00013 } DISCRIM_UNION_PARAM_TYPE;
00014
00015 typedef DISCRIM_UNION_PARAM_TYPE DISCRIM_UNION_FIELD_TYPE;
00016
00017 typedef struct {
00018     short                                          sDiscrim;
00019     [switch_is(sDiscrim)] DISCRIM_UNION_FIELD_TYPE u;
00020 } DISCRIM_UNION_STRUCT_TYPE;
00021
00022
00023 void UnionParamProc(
00024     [in, switch_is(sDiscrim)] DISCRIM_UNION_PARAM_TYPE *UnionParam,
00025     [in]                      short                    sDiscrim
00026     );
00027
00028 void UnionStructProc(
00029     [in] DISCRIM_UNION_STRUCT_TYPE *UnionStruct);
00030
00031 void Shutdown(void);
00032
00033 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/RecoDLL/RecoDll.cpp Source File

  • TabletPC
  • RecoDLL

RecoDll.cpp

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //--------------------------------------------------------------------------
00013 //
00014 // RecoDll.cpp : Defines the entry point for the DLL application.
00015 //
00016
00017 #include "stdafx.h"
00018 #include "RecApis.h"
00019 #include "assert.h"
00020
00021 const WCHAR *RECO_SUBKEY = L"Software\\Microsoft\\TPG\\Recognizers\\{6D0087D7-61D2-495f-9293-5B7B1C3FCEAB}";
00022 const WCHAR *FULL_PATH_VALUE = L"Recognizer dll";
00023 const WCHAR *RECO_MANAGER_KEY = L"CLSID\\{DE815B00-9460-4F6E-9471-892ED2275EA5}\\InprocServer32";
00024 const WCHAR *RECOGNIZER_SUBKEY = L"CLSID\\{6D0087D7-61D2-495f-9293-5B7B1C3FCEAB}\\InprocServer32";
00025 const WCHAR *RECOPROC_SUBKEY = L"{6D0087D7-61D2-495f-9293-5B7B1C3FCEAB}\\InprocServer32";
00026 const WCHAR *CLSID_KEY = L"CLSID";
00027 const WCHAR *RECOCLSID_SUBKEY = L"{6D0087D7-61D2-495f-9293-5B7B1C3FCEAB}";
00028 const WCHAR *RECO_LANGUAGES = L"Recognized Languages";
00029 const WCHAR *RECO_CAPABILITIES = L"Recognizer Capability Flags";
00030 const WCHAR *RECOGNIZER_SUBPATH = L"Software\\Microsoft\\TPG\\Recognizers";
00031 const WCHAR *TPG_SUBPATH = L"Software\\Microsoft\\TPG";
00032 const WCHAR *RECO_SHORT_NAME = L"Recognizer Short Name";
00033 const WCHAR *RECO_VENDOR_NAME = L"Vendor Name";
00034
00035 HANDLE m_hModule;
00036
00037 BOOL APIENTRY DllMain( HANDLE hModule,
00038                        DWORD ul_reason_for_call,
00039                        void* lpReserved
00040                      )
00041 {
00042     switch (ul_reason_for_call)
00043     {
00044         case DLL_PROCESS_ATTACH:
00045             m_hModule = hModule;
00046         case DLL_THREAD_ATTACH:
00047         case DLL_THREAD_DETACH:
00048         case DLL_PROCESS_DETACH:
00049             break;
00050     }
00051     return TRUE;
00052 }
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // DllRegisterServer - Adds entries to the system registry
00056
00057 // This recognizer GUID is going to be
00058 // {6D0087D7-61D2-495f-9293-5B7B1C3FCEAB}
00059 // Each recognizer HAS to have a different GUID
00060
00061 STDAPI DllRegisterServer(void)
00062 {
00063     HKEY        hKeyReco = NULL;
00064     HKEY        hKeyRecoManager = NULL;
00065     LONG        lRes = 0;
00066     HKEY        hkeyMyReco;
00067     DWORD       dwLength = 0, dwType = 0, dwSize = 0;
00068     DWORD       dwDisposition;
00069     WCHAR       szRecognizerPath[MAX_PATH];
00070     HRESULT     hr = S_OK;
00071     RECO_ATTRS  recoAttr;
00072
00073     // Write the path to this dll in the registry under
00074     // the recognizer subkey
00075
00076     // Wipe out the previous values
00077     lRes = RegDeleteKeyW(HKEY_LOCAL_MACHINE, RECO_SUBKEY);
00078     // Create the new key
00079     lRes = RegCreateKeyExW(HKEY_LOCAL_MACHINE, RECO_SUBKEY, 0, NULL,
00080         REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyMyReco, &dwDisposition);
00081     assert(lRes == ERROR_SUCCESS);
00082     if (lRes != ERROR_SUCCESS)
00083     {
00084         RegCloseKey(hkeyMyReco);
00085         return E_UNEXPECTED;
00086     }
00087     // Get the current path
00088     // Try to get the path of the RecoObj.dll
00089     // It should be the same as the one for the RecoCom.dll
00090     dwLength = GetModuleFileNameW((HMODULE)m_hModule, szRecognizerPath, MAX_PATH);
00091     // Write the path to the dll as a value
00092     lRes = RegSetValueExW(hkeyMyReco, FULL_PATH_VALUE, NULL, REG_SZ,
00093         (BYTE*)szRecognizerPath, sizeof(WCHAR)*(wcslen(szRecognizerPath)+1));
00094     assert(lRes == ERROR_SUCCESS);
00095     if (lRes != ERROR_SUCCESS)
00096     {
00097         RegCloseKey(hkeyMyReco);
00098         return E_UNEXPECTED;
00099     }
00100     // We get the reco attributes
00101     // Here we pass NULL for the hrec because we only have one recognizer
00102     // we would need to loop though all the recognizer and register each
00103     // of them if there were more than one.
00104     hr = GetRecoAttributes(NULL, &recoAttr);
00105     if (FAILED(hr))
00106     {
00107         RegCloseKey(hkeyMyReco);
00108         return E_UNEXPECTED;
00109     }
00110     lRes = RegSetValueExW(hkeyMyReco, RECO_LANGUAGES, 0, REG_BINARY,
00111         (BYTE*)recoAttr.awLanguageId, 64 * sizeof(WORD));
00112     assert(lRes == ERROR_SUCCESS);
00113     if (lRes != ERROR_SUCCESS)
00114     {
00115         RegCloseKey(hkeyMyReco);
00116         return E_UNEXPECTED;
00117     }
00118     lRes = RegSetValueExW(hkeyMyReco, RECO_CAPABILITIES, 0, REG_DWORD,
00119         (BYTE*)&(recoAttr.dwRecoCapabilityFlags), sizeof(DWORD));
00120     assert(lRes == ERROR_SUCCESS);
00121     if (lRes != ERROR_SUCCESS)
00122     {
00123         RegCloseKey(hkeyMyReco);
00124         return E_UNEXPECTED;
00125     }
00126     RegCloseKey(hkeyMyReco);
00127
00128     return S_OK;
00129 }
00130
00131 /////////////////////////////////////////////////////////////////////////////
00132 // DllUnregisterServer - Removes entries from the system registry
00133
00134 STDAPI DllUnregisterServer(void)
00135 {
00136     LONG        lRes1 = 0;
00137
00138     // Wipe out the registry information
00139     lRes1 = RegDeleteKeyW(HKEY_LOCAL_MACHINE, RECO_SUBKEY);
00140
00141     // Try to erase the local machine\software\microsoft\tpg\recognizer
00142     // if necessary (don't care if it fails)
00143     RegDeleteKeyW(HKEY_LOCAL_MACHINE, RECOGNIZER_SUBPATH);
00144     RegDeleteKeyW(HKEY_LOCAL_MACHINE, TPG_SUBPATH);
00145
00146     if (lRes1 != ERROR_SUCCESS && lRes1 != ERROR_FILE_NOT_FOUND)
00147     {
00148         return E_UNEXPECTED;
00149     }
00150     return S_OK ;
00151 }
00152
00153 ////////////////////////
00154 // IRecognizer
00155 ////////////////////////
00156 HRESULT WINAPI CreateRecognizer(CLSID *pCLSID, HRECOGNIZER *phrec)
00157 {
00158     return E_NOTIMPL;
00159 }
00160 HRESULT WINAPI DestroyRecognizer(HRECOGNIZER hrec)
00161 {
00162     return E_NOTIMPL;
00163 }
00164 HRESULT WINAPI GetRecoAttributes(HRECOGNIZER hrec, RECO_ATTRS* pRecoAttrs)
00165 {
00166     // Check the the hrec
00167     // TODO
00168
00169     // Check the pRecoAttrs pointer
00170     if (IsBadWritePtr(pRecoAttrs, sizeof(RECO_ATTRS)))
00171         return E_POINTER;
00172
00173     // Initialize the Reco Attribute structure
00174     ZeroMemory(pRecoAttrs, sizeof(RECO_ATTRS));
00175
00176     // Fill in the vendor name and the recognizer "friendly" name
00177     wcsncpy(pRecoAttrs->awcVendorName, RECO_VENDOR_NAME, wcslen(RECO_VENDOR_NAME)+1);
00178     wcsncpy(pRecoAttrs->awcFriendlyName, RECO_SHORT_NAME, wcslen(RECO_SHORT_NAME)+1);
00179     // Put the languages supported by the recognizer in the awLanguageId array
00180     pRecoAttrs->awLanguageId[0] = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
00181     // Set the reco capability flag
00182     pRecoAttrs->dwRecoCapabilityFlags = 0;
00183     return S_OK;
00184 }
00185 HRESULT WINAPI CreateContext(HRECOGNIZER hrec, HRECOCONTEXT *phrc)
00186 {
00187     return E_NOTIMPL;
00188 }
00189 HRESULT WINAPI DestroyContext(HRECOCONTEXT hrc)
00190 {
00191     return E_NOTIMPL;
00192 }
00193 HRESULT WINAPI GUIDToIndex(HRECOGNIZER hrec, GUID* pGUID, ULONG* pIndex)
00194 {
00195     return E_NOTIMPL;
00196 }
00197 HRESULT WINAPI IndexToGUID(HRECOGNIZER hrec, ULONG Index, GUID* pGUID)
00198 {
00199     return E_NOTIMPL;
00200 }
00201 HRESULT WINAPI GetResultPropertyList(HRECOGNIZER hrec, ULONG* pPropertyCount, ULONG*pPropIndexes)
00202 {
00203     return E_NOTIMPL;
00204 }
00205 HRESULT WINAPI GetPreferredPacketDescription(HRECOGNIZER hrec, PACKET_DESCRIPTION* pPacketDescription)
00206 {
00207     return E_NOTIMPL;
00208 }
00209
00210 ////////////////////////
00211 // IRecoContext
00212 ////////////////////////
00213 HRESULT WINAPI AddStroke(HRECOCONTEXT hrc, PACKET_DESCRIPTION* pPacketDesc, ULONG cbPacket, BYTE *pPacket, const XFORM *pXForm)
00214 {
00215     return E_NOTIMPL;
00216 }
00217 HRESULT WINAPI GetBestResultString(HRECOCONTEXT hrc, ULONG *pcbSize, WCHAR* pszBestResult)
00218 {
00219     return E_NOTIMPL;
00220 }
00221 HRESULT WINAPI GetBestAlternate(HRECOCONTEXT hrc, HRECOALT* pHrcAlt)
00222 {
00223     return E_NOTIMPL;
00224 }
00225 HRESULT WINAPI DestroyAlternate(HRECOALT hrcalt)
00226 {
00227     return E_NOTIMPL;
00228 }
00229 HRESULT WINAPI SetGuide(HRECOCONTEXT hrc, const RECO_GUIDE* pGuide, ULONG iIndex)
00230 {
00231     return E_NOTIMPL;
00232 }
00233 HRESULT WINAPI GetGuide(HRECOCONTEXT hrc, RECO_GUIDE* pGuide, ULONG *piIndex)
00234 {
00235     return E_NOTIMPL;
00236 }
00237 HRESULT WINAPI AdviseInkChange(HRECOCONTEXT hrc, BOOL bNewStroke)
00238 {
00239     return E_NOTIMPL;
00240 }
00241 HRESULT WINAPI SetCACMode(HRECOCONTEXT hrc, int iMode)
00242 {
00243     return E_NOTIMPL;
00244 }
00245 HRESULT WINAPI EndInkInput(HRECOCONTEXT hrc)
00246 {
00247     return E_NOTIMPL;
00248 }
00249 HRESULT WINAPI CloneContext(HRECOCONTEXT hrc, HRECOCONTEXT* pCloneHrc)
00250 {
00251     return E_NOTIMPL;
00252 }
00253 HRESULT WINAPI ResetContext(HRECOCONTEXT hrc)
00254 {
00255     return E_NOTIMPL;
00256 }
00257 HRESULT WINAPI GetAlternateList(HRECOCONTEXT hrc, RECO_RANGE* pRecoRange, ULONG*pcAlt, HRECOALT*phrcalt, ULONG iBreak)
00258 {
00259     return E_NOTIMPL;
00260 }
00261 HRESULT WINAPI Process(HRECOCONTEXT hrc, BOOL *pbPartialProcessing)
00262 {
00263     return E_NOTIMPL;
00264 }
00265 HRESULT WINAPI GetLatticePtr(HRECOCONTEXT hrc, RECO_LATTICE **ppLattice)
00266 {
00267     return E_NOTIMPL;
00268 }
00269
00270
00271 ////////////////////////
00272 // IAlternate
00273 ////////////////////////
00274 HRESULT WINAPI GetString(HRECOALT hrcalt, RECO_RANGE *pRecoRange, ULONG* pcSize, WCHAR* szString)
00275 {
00276     return E_NOTIMPL;
00277 }
00278 HRESULT WINAPI GetStrokeRanges(HRECOALT hrcalt, RECO_RANGE* pRecoRange, ULONG* pcRanges, STROKE_RANGE* pStrokeRange)
00279 {
00280     return E_NOTIMPL;
00281 }
00282 HRESULT WINAPI GetSegmentAlternateList(HRECOALT hrcalt, RECO_RANGE* pRecoRange, ULONG *pcAlts, HRECOALT* pAlts)
00283 {
00284     return E_NOTIMPL;
00285 }
00286 HRESULT WINAPI GetMetrics(HRECOALT hrcalt, RECO_RANGE* pRecoRange, LINE_METRICS lm, LINE_SEGMENT* pls)
00287 {
00288     return E_NOTIMPL;
00289 }
00290 HRESULT WINAPI GetGuideIndex(HRECOALT hrcalt, RECO_RANGE* pRecoRange, RECO_GUIDE* pGuide, ULONG iIndex)
00291 {
00292     return E_NOTIMPL;
00293 }
00294 HRESULT WINAPI GetConfidenceLevel(HRECOALT hrcalt, RECO_RANGE* pRecoRange, CONFIDENCE_LEVEL* pcl)
00295 {
00296     return E_NOTIMPL;
00297 }
00298 HRESULT WINAPI GetPropertyRanges(HRECOALT hrcalt, ULONG id, ULONG* pcRanges, RECO_RANGE* pRecoRange)
00299 {
00300     return E_NOTIMPL;
00301 }
00302 HRESULT WINAPI GetRangePropertyValue(HRECOALT hrcalt, ULONG id, RECO_RANGE* pRecoRange, ULONG*cbSize, BYTE* pProperty)
00303 {
00304     return E_NOTIMPL;
00305 }
00306
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

FLAGMAPPING Member List

This is the complete list of members for FLAGMAPPING, including all inherited members.
name | FLAGMAPPING
realname | FLAGMAPPING
value | FLAGMAPPING
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/registry.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

registry.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef __Registry_H__
00015 #define __Registry_H__
00016
00017 #include <tchar.h>
00018
00019 // This function will register a component in the Registry.
00020 // The component calls this function from its DllRegisterServer function.
00021 HRESULT RegisterServer( HMODULE hModule,
00022                         const CLSID& clsid,
00023                         const TCHAR* szFriendlyName) ;
00024
00025 // This function will unregister a component.  Components
00026 // call this function from their DllUnregisterServer function.
00027 HRESULT UnregisterServer( const CLSID& clsid ) ;
00028
00029
00030 // This function will register a Snap-In component.  Components
00031 // call this function from their DllRegisterServer function.
00032 HRESULT RegisterSnapin( const CLSID& clsid,            // Class ID
00033                         const TCHAR* szNameString,     // NameString
00034                         const CLSID& clsidAbout,       // Class Id for About Class
00035                         const BOOL fSupportExtensions = FALSE
00036                       );
00037
00038 HRESULT UnregisterSnapin( const CLSID& clsid );        // Class ID
00039
00040 #endif //__Registry_H__
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/HttpAuth/HttpGet.c Source File

  • Security
  • SSPI
  • HttpAuth

HttpGet.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011     httpget.c
00012
00013 Abstract:
00014
00015     This is a web command line application.  It will allow a user to get a
00016     html document from the command line.
00017
00018 Environment:
00019
00020     console app
00021
00022 --*/
00023
00024 #include <windows.h>
00025 #include <stdio.h>
00026 #include <io.h>
00027 #include <fcntl.h>
00028 #include <stdlib.h>
00029 #include <time.h>
00030 #include <malloc.h>
00031 #include "const.h"
00032 #include "proto.h"
00033
00034 void
00035 PrintUsage(void);
00036
00037 #define SOCKETS_METHOD 1
00038
00039 void
00040 __cdecl
00041 main(
00042     int argc,
00043     char * argv[])
00044 {
00045     char *        Server;
00046     char *        URL;
00047     char *        Verb = "GET";
00048     char *        Gateway = NULL;
00049     char *        AcceptTypes[2] = {"*/*", NULL};
00050     char          Headers[] =
00051                       "Accept: */*\r\n"
00052                       "User-Agent: Httpget\r\n"
00053                       "Referer: Httpget\r\n"
00054                       "\r\n";
00055     int           Method = SOCKETS_METHOD;
00056     BOOL          DisplayHeaders = FALSE;
00057     DWORD         ClientDataSize = 0;
00058     PSTR          pszUserName = "";
00059     PSTR          pszPassword = "";
00060     PSTR          pszStore = NULL;
00061     PSTR          pszPref = NULL;
00062
00063     //
00064     // Parse the command line
00065     //
00066
00067     if (argc < 3)
00068     {
00069         PrintUsage();
00070         return;
00071     }
00072
00073     while (argc > 3)
00074     {
00075         //
00076         // parse options
00077         //
00078
00079         if (argv[1][0] == '-')
00080         {
00081             switch (argv[1][1])
00082             {
00083             case 'V' :
00084             case 'v' :
00085                 //
00086                 // Input verb
00087                 //
00088
00089                 Verb = &argv[1][3];
00090
00091                 break;
00092
00093             case 'H' :
00094             case 'h' :
00095                 //
00096                 // Display headers
00097                 //
00098
00099                 DisplayHeaders = TRUE;
00100
00101                 break;
00102
00103             case 'D' :
00104             case 'd' :
00105                 //
00106                 // Amount of data to send
00107                 //
00108
00109                 if (sscanf(&argv[1][3], "%u", &ClientDataSize) != 1)
00110                 {
00111                     PrintUsage();
00112                     return;
00113                 }
00114                 break;
00115
00116             case 'G' :
00117             case 'g' :
00118                 //
00119                 // Gateway
00120                 //
00121
00122                 Gateway = &argv[1][3];
00123
00124                 break;
00125
00126             case 'M':
00127             case 'm':
00128                 // User name
00129                 pszPref = &argv[1][3];
00130                 break;
00131
00132             case 'N':
00133             case 'n':
00134                 // User name
00135                 pszUserName = &argv[1][3];
00136                 break;
00137
00138             case 'P':
00139             case 'p':
00140                 // Password
00141                 pszPassword = &argv[1][3];
00142                 break;
00143
00144             case 'S':
00145             case 's':
00146                 pszStore = &argv[1][3];
00147                 break;
00148
00149             default:
00150                 PrintUsage();
00151                 return;
00152                 break;
00153             }
00154         }
00155         else
00156         {
00157             PrintUsage();
00158             return;
00159         }
00160
00161         argc --;
00162         argv ++;
00163     }
00164
00165     Server = argv[1];
00166
00167     URL = argv[2];
00168
00169     switch (Method)
00170     {
00171     case SOCKETS_METHOD:
00172         HttpGetSocket(
00173             Verb,
00174             Server,
00175             URL,
00176             DisplayHeaders,
00177             ClientDataSize,
00178             pszUserName,
00179             pszPassword,
00180             pszStore,
00181             pszPref );
00182         break;
00183     }
00184
00185     return;
00186 }
00187
00188 void
00189 PrintUsage()
00190 {
00191     fprintf(stderr,
00192         "httpauth  [-h] [-d:<size>] [-m:<methodlist>] [-v:<verb>] [-n:<username>]\n"
00193                 "\t  [-p:<password>] [-g:gateway] [-s:storefile] <server> <path>\n"
00194         "\t-h           - display result headers\n"
00195         "\t<size>       - amount of client data to send\n"
00196         "\t<verb>       - HTTP verb to use (default is GET)\n"
00197         "\t<username>   - user name for authentication\n"
00198         "\t<password>   - password for authentication\n"
00199         "\t<methodlist> - comma separated list of authentication methods in order\n"
00200         "\t               of preference (Default is to use first supported method\n"
00201         "\t               returned by the HTTP server (e.g., -m:NTLM,BASIC)\n"
00202         "\t<storefile>  - file where to store result message body\n"
00203         "\t<server>     - web server to connect to (without http:)\n"
00204         "\t<path>       - resource to get (e.g., /default.htm)\n"
00205     );
00206 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIFileViewer Member List

This is the complete list of members for CImpIFileViewer, including all inherited members.
CImpIFileViewer(PCFileViewer, LPUNKNOWN) | CImpIFileViewer |
m_pObj | CImpIFileViewer | [private]
m_pUnkOuter | CImpIFileViewer | [private]
PrintTo(LPSTR, BOOL) | CImpIFileViewer |
QueryInterface(REFIID, PPVOID) | CImpIFileViewer |
Show(LPFVSHOWINFO pvsi) | CImpIFileViewer |
ShowInitialize(LPFILEVIEWERSITE lpfsi) | CImpIFileViewer |
STDMETHODIMP_(ULONG) AddRef(void) | CImpIFileViewer |
STDMETHODIMP_(ULONG) Release(void) | CImpIFileViewer |
~CImpIFileViewer(void) | CImpIFileViewer |
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/Inc/TxFileDisp.Idl Source File

  • Com
  • Common
  • Inc

TxFileDisp.Idl

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 ********************************************************************************
00004 * Filename: TxFileDisp.idl
00005 *
00006 * Description: IDL source for TxFileDisp.dll
00007 *
00008 *        This file will be processed by the MIDL tool to
00009 *        produce the type library (TxFileDisp.tlb) and marshalling code.
00010 *
00011 *
00012 * This file is provided as part of the Microsoft Transaction Server
00013 * Software Development Kit
00014 *
00015 *THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00016 *WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00017 *INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00018 *OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00019 *PURPOSE.
00020 *
00021 * Copyright (C) 1997 Microsoft Corporation, All rights reserved
00022 ********************************************************************************
00023 \******************************************************************************/
00024
00025 import "oaidl.idl";
00026
00027
00028
00029   [
00030
00031     object,
00032     uuid(8A7339E3-5397-11D0-B151-00AA00BA3258),
00033     dual,
00034     helpstring("IFileRmPxy Interface"),
00035     pointer_default(unique)
00036   ]
00037   interface IFileRmPxy : IDispatch
00038   {
00039
00040     [helpstring("add a file to copy")]
00041     HRESULT AddFile([in] long hConnection, [in] BSTR sSource, [in] BSTR sDestination);
00042
00043     [helpstring("copy the list of files")]
00044     HRESULT CopyFilesInCopyList([in] long hConnection);
00045
00046     [helpstring("copies a directory")]
00047     HRESULT CopyDirTx([in] long hConnection,[in] BSTR sSource,[in] BSTR sDestination);
00048
00049     [helpstring("connection based file copy")]
00050     HRESULT CopyFileTx([in] long hConnection,[in] BSTR sSource,[in] BSTR sDestination, BOOL bFailIfExists);
00051
00052     [helpstring("connection based file move")]
00053     HRESULT MoveFileTx([in] long hConnection,[in] BSTR sSource,[in] BSTR sDestination);
00054
00055     [helpstring("connection based file delete")]
00056     HRESULT DeleteFileTx([in] long hConnection,[in] BSTR sFileName);
00057
00058
00059 /* Connection Management */
00060     [helpstring("connect to the rm")]
00061     HRESULT Connect([out] long *hConnection);
00062     [helpstring("disconnect from the rm")]
00063     HRESULT Disconnect([in] long hConnection);
00064   };
00065
00066 [
00067   uuid(8A7339E1-5397-11D0-B151-00AA00BA3258),
00068   version(1.0),
00069   helpstring("TxFileDisp 1.0 Type Library")
00070 ]
00071 library TXFILEDISPLib
00072 {
00073   importlib("stdole2.tlb");
00074
00075   [
00076     uuid(8A7339E4-5397-11D0-B151-00AA00BA3258),
00077     helpstring("FileRmPxy Class")
00078   ]
00079   coclass FileRmPxy
00080   {
00081     [default] interface IFileRmPxy;
00082   };
00083
00084 };
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Enum/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Enum
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Enum.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyCapabilities/StdAfx.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyCapabilities

StdAfx.h

Go to the documentation of this file.
00001 //
00002 // stdafx.h : include file for standard system include files,
00003 //      or project specific include files that are used frequently,
00004 //      but are changed infrequently
00005 //
00006
00007 #define STRICT
00008 #ifndef _WIN32_WINNT
00009 #define _WIN32_WINNT 0x0502
00010 #endif
00011 #define _ATL_APARTMENT_THREADED
00012
00013 #include <atlbase.h>
00014 //You may derive a class from CComModule and use it if you want to override
00015 //something, but do not change the name of _Module
00016 extern CComModule _Module;
00017 #include <atlcom.h>
00018
00019 // Categories and ClusCfg GUIDS
00020 #include <ClusCfgGuids.h>
00021
00022 // Interface definitions for IClusCfgCapabilities
00023 #include <ClusCfgServer.h>
00024
00025 // Safe string functions
00026 #include <strsafe.h>
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADSIDump/AdsiDump.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADSIDump

AdsiDump.cpp

Go to the documentation of this file.
00001
00002 /----------------------------------------------------------------------------
00003 //
00004 //  Microsoft Active Directory 2.5 Sample Code
00005 //
00006 //  Copyright (C) Microsoft Corporation, 1996 - 2000
00007 //
00008 //  File:       ADSIDump.cxx
00009 //
00010 //
00011 //----------------------------------------------------------------------------
00012
00013
00014
00015 #include "stdafx.h"
00016 #include <stdio.h>
00017 #include <string>
00018 typedef std::basic_string<WCHAR> stringW;
00019
00020
00021 //-----------------------------------------------------------------------------
00022 //
00023 //    Function:        CchSzLen
00024 //
00025 //    Description:    Returns the length of a wide string.
00026 //
00027 //    Return values:    INT (length of string, in characters, not counting null)
00028 //
00029 //    Threadsafe:        no
00030 //
00031 //-----------------------------------------------------------------------------
00032 INT CchSzLen
00033 (
00034 CSZ cszString
00035 )
00036     {
00037     Assert(cszString);
00038
00039     const WCHAR * pwch = cszString;
00040     while (*pwch)
00041         pwch++;
00042
00043     return (pwch - cszString);
00044     }
00045
00046
00047 ///////////////////////////////////////////////////////////////////////////////
00048 //
00049 //    class:        CStringException
00050 //
00051 //    Simple exception class.
00052 //
00053 //    hungarian:    strex
00054 //
00055 ///////////////////////////////////////////////////////////////////////////////
00056 class CStringException
00057 {
00058 public:
00059     CStringException(CSZ cszError) throw()
00060         {
00061         Assert(cszError);
00062         m_strError = cszError;
00063         }
00064
00065     operator CSZ (VOID) throw()
00066         { return m_strError.c_str(); }
00067
00068 private:
00069     stringW m_strError;
00070 };
00071
00072
00073 // return-value checking
00074 #define CheckHresultADs(hr) { HRESULT hr_ADSxyz = (hr);  if (!SUCCEEDED(hr_ADSxyz)) VThrowAdsError(); }
00075 #define CheckHresult(hr,sz) { HRESULT hr_xyz = (hr);  \
00076     if (!SUCCEEDED(hr_xyz)) { \
00077         WCHAR szBuf[1024];  \
00078         swprintf(szBuf, L"Error: 0x%x  %s", hr, sz); \
00079     throw CStringException(szBuf);} }
00080
00081 //-----------------------------------------------------------------------------
00082 //
00083 //    Function:        VThrowAdsError
00084 //
00085 //    Description:    Throws a string with an ADs error description.
00086 //
00087 //    Return values:    none (always throws!)
00088 //
00089 //    Threadsafe:        no
00090 //
00091 //-----------------------------------------------------------------------------
00092 VOID VThrowAdsError
00093 (
00094 VOID
00095 )
00096     {
00097     DWORD dwCode = 0;
00098     const dwLen = 2048;
00099     WCHAR szError[dwLen];
00100     WCHAR szProvider[dwLen];
00101     if (SUCCEEDED(::ADsGetLastError(&dwCode,
00102                                     szError,
00103                                     dwLen,
00104                                     szProvider,
00105                                     dwLen)))
00106         {
00107         stringW strError;
00108
00109         strError = TEXT("An ADSI error has occured.  Provider = '");
00110         strError += szProvider;
00111         strError += TEXT("'  Error message = \"");
00112         strError += szError;
00113         strError += TEXT("\"  Error code = 0x");
00114
00115         TCHAR szNum[16];
00116         ::_ltow(dwCode, szNum, 16);    // BASE-16
00117         strError += szNum;
00118
00119         throw CStringException(strError.c_str());
00120         }
00121     else
00122         {
00123         throw CStringException(TEXT("Unknown ADSI error"));
00124         }
00125     }
00126
00127
00128 typedef VOID (*pfnArrayCallback)(CSZ cszValue, IADs * piads, FILE * pfile);
00129 //-----------------------------------------------------------------------------
00130 //
00131 //    Function:        VIterateSafeArray
00132 //
00133 //    Description:    Given a safe array, this function iterates through the
00134 //                    array, and calls the specified callback for each element.
00135 //
00136 //    Return values:    none
00137 //
00138 //    Threadsafe:        no
00139 //
00140 //-----------------------------------------------------------------------------
00141 VOID VIterateSafeArray
00142 (
00143 SAFEARRAY * psa,    // safe array to iterate
00144 VARTYPE vt,            // type of array (VT_ARRAY | VT_BSTR, or something)
00145 IADs * piads,        // directory services object
00146 FILE * pfile,        // output file
00147 pfnArrayCallback fnCallback    // callback function
00148 )
00149     {
00150     Assert(psa);
00151     Assert(1 == ::SafeArrayGetDim(psa));
00152     Assert(VT_ARRAY == (vt & VT_ARRAY) && "Should be an array");
00153     Assert(piads);
00154     Assert(pfile);
00155     //Assert(pfnArrayCallback);
00156
00157     vt -= VT_ARRAY;
00158
00159     long lLBound, lUBound;
00160     Verify(SUCCEEDED(::SafeArrayGetLBound(psa, 1, &lLBound)));
00161     Verify(SUCCEEDED(::SafeArrayGetUBound(psa, 1, &lUBound)));
00162
00163     switch (vt)
00164         {
00165         default:
00166 #ifdef DEBUG
00167             Assert(false && "Unknown variant type");
00168             break;
00169
00170         case VT_VARIANT:
00171 #endif    // _DEBUG
00172             {
00173             for (long i = lLBound; i <= lUBound; i++)
00174                 {
00175                 CComVariant svar;
00176                 Verify(SUCCEEDED(::SafeArrayGetElement(psa, &i, &svar)));
00177                 if (VT_BSTR == svar.vt && svar.bstrVal)
00178                     fnCallback(svar.bstrVal, piads, pfile);
00179                 }
00180             break;
00181             }
00182
00183         case VT_BSTR:
00184             {
00185             for (long i = lLBound; i <= lUBound; i++)
00186                 {
00187                 CComBSTR sbstr;
00188                 Verify(SUCCEEDED(::SafeArrayGetElement(psa, &i, &sbstr)));
00189                 if (sbstr)
00190                     fnCallback(sbstr, piads, pfile);
00191                 }
00192             break;
00193             }
00194         }
00195     }
00196
00197
00198 //-----------------------------------------------------------------------------
00199 //
00200 //    Function:        VDumpArray
00201 //
00202 //    Description:    Given a value, write it out to the provided text file.
00203 //
00204 //    Return values:    none
00205 //
00206 //    Threadsafe:        no
00207 //
00208 //-----------------------------------------------------------------------------
00209 VOID VDumpArray
00210 (
00211 CSZ cszValue,    // value
00212 IADs * piads,    // object to query (not used for this callback)
00213 FILE * pfile    // output file
00214 )
00215     {
00216     Assert(cszValue);
00217     Assert(pfile);
00218
00219     UNUSED(piads);
00220
00221     ::fprintf(pfile, "  \"%S\"", cszValue);
00222     }
00223
00224
00225 //-----------------------------------------------------------------------------
00226 //
00227 //    Function:        VDumpAttribute
00228 //
00229 //    Description:    Given an object and an attribute name, dumps the attribute
00230 //                    to a text file.
00231 //
00232 //    Return values:    none
00233 //
00234 //    Threadsafe:        no
00235 //
00236 //-----------------------------------------------------------------------------
00237 VOID VDumpAttribute
00238 (
00239 CSZ cszAttribute,    // name of attribute
00240 IADs * piads,        // object to query
00241 FILE * pfile        // output file
00242 )
00243     {
00244     Assert(piads);
00245     Assert(cszAttribute);
00246     Assert(pfile);
00247
00248     CComVariant svar;
00249     CComBSTR sbstr(cszAttribute);
00250     HRESULT hr = S_OK;
00251     hr = piads->Get(sbstr, &svar);
00252     if (E_ADS_PROPERTY_NOT_FOUND != hr) CheckHresult(hr, TEXT("Failed to Get value of an attribute"));
00253
00254     ::fprintf(pfile, "\n    %S : ", (SZ) sbstr);
00255
00256     switch (svar.vt)
00257         {
00258         default:
00259             ::fprintf(pfile, "(Unknown variant type)");
00260             break;
00261
00262         case VT_BSTR:
00263             ::fprintf(pfile, "(BSTR) \"%S\"", svar.bstrVal);
00264             break;
00265
00266         case (VT_ARRAY | VT_BSTR):
00267         case (VT_ARRAY | VT_VARIANT):
00268             {
00269             if (svar.parray)
00270                 {
00271                 ::fprintf(pfile, "(ARRAY) [");
00272                 ::VIterateSafeArray(svar.parray,
00273                                     svar.vt,
00274                                     piads,
00275                                     pfile,
00276                                     VDumpArray);
00277                 ::fprintf(pfile, "]");
00278                 }
00279             break;
00280             }
00281
00282         case VT_I1:
00283         case VT_I4:
00284         case VT_UI1:
00285         case VT_UI2:
00286         case VT_INT:
00287         case VT_UINT:
00288             fprintf(pfile, "(INT) %d", svar.intVal);
00289             break;
00290
00291         case VT_I8:
00292         case VT_UI8:
00293             ::fprintf(pfile, "(INT8) %ld", svar.uintVal);
00294             break;
00295
00296         case VT_BOOL:
00297             ::fprintf(pfile, "(BOOL) %s", (svar.boolVal) ? "TRUE" : "FALSE");
00298             break;
00299         }
00300     }
00301
00302
00303 //-----------------------------------------------------------------------------
00304 //
00305 //    Function:        VDumpObject
00306 //
00307 //    Description:    Given an IADs object, its parent and an output file, this
00308 //                    routine writes out all of the attributes it can find.
00309 //
00310 //    Return values:    none
00311 //
00312 //    Threadsafe:        no
00313 //
00314 //-----------------------------------------------------------------------------
00315 VOID VDumpObject
00316 (
00317 CSZ cszParent,        // name of parent (can be null)
00318 IADs * piads,        // object to dump
00319 FILE * pfile        // output file
00320 )
00321     {
00322     Assert(piads);
00323     Assert(pfile);
00324
00325     // pull down information from server
00326     CheckHresultADs(piads->GetInfo());
00327
00328     // start dumping
00329     ::fprintf(pfile, "\n\n=======================================================\n");
00330
00331     // name
00332     CComBSTR sbstrName;
00333     CheckHresultADs(piads->get_Name(&sbstrName));
00334     ::fprintf(pfile, "\n***  %S  ***", (SZ) sbstrName);
00335     ::wprintf(L"\n  %s...", sbstrName);
00336
00337     // parent
00338     if (cszParent)
00339         ::fprintf(pfile, "\n  Child of %S", cszParent);
00340     else
00341         ::fprintf(pfile, "\n  ROOT OBJECT");
00342
00343     // full path
00344     CComBSTR sbstrPath;
00345     CheckHresultADs(piads->get_ADsPath(&sbstrPath));
00346     ::fprintf(pfile, "\n  Full ADs path: \"%S\"", (SZ) sbstrPath);
00347
00348     // class
00349     CComBSTR sbstrClass;
00350     CheckHresultADs(piads->get_Class(&sbstrClass));
00351     ::fprintf(pfile, "\n  Class: %S", (SZ) sbstrClass);
00352
00353     // schema
00354     CComBSTR sbstrSchema;
00355     CheckHresultADs(piads->get_Schema(&sbstrSchema));
00356     ::fprintf(pfile, "\n  Schema: %S", (SZ) sbstrSchema);
00357
00358     // attributes
00359     ::fprintf(pfile, "\n  Attributes -------------------");
00360
00361     // open the class, get all the attributes
00362     CComPtr<IADsClass> srpiaclass;
00363     CheckHresultADs(::ADsGetObject(sbstrSchema,
00364                                      IID_IADsClass,
00365                                      (PVOID *) &srpiaclass));
00366     Assert(srpiaclass);
00367
00368     VARIANT var;
00369     var.vt = VT_EMPTY;
00370     var.parray = NULL;
00371     CheckHresultADs(srpiaclass->get_MandatoryProperties(&var));
00372     if (VT_ARRAY == (var.vt & VT_ARRAY))
00373         {
00374         Assert(var.parray);
00375         ::VIterateSafeArray(var.parray, var.vt, piads, pfile, VDumpAttribute);
00376         ::SafeArrayDestroy(var.parray);
00377         }
00378
00379     var.vt = VT_EMPTY;
00380     var.parray = NULL;
00381     CheckHresultADs(srpiaclass->get_OptionalProperties(&var));
00382     if (VT_ARRAY == (var.vt & VT_ARRAY))
00383         {
00384         Assert(var.parray);
00385         ::VIterateSafeArray(var.parray, var.vt, piads, pfile, VDumpAttribute);
00386         ::SafeArrayDestroy(var.parray);
00387         }
00388
00389     ::fprintf(pfile, "\n");
00390     }
00391
00392
00393 //-----------------------------------------------------------------------------
00394 //
00395 //    Function:        VDumpTree
00396 //
00397 //    Description:    Recursively dumps all of the children of this node.
00398 //
00399 //    Return values:    none
00400 //
00401 //    Threadsafe:        no
00402 //
00403 //-----------------------------------------------------------------------------
00404 VOID VDumpTree
00405 (
00406 CSZ cszParent,    // name of parent object
00407 IADs * piads,    // object to dump (dump its children as well)
00408 FILE * pfile    // file to which we dump
00409 )
00410     {
00411     Assert(piads);
00412     Assert(pfile);
00413
00414     // dump this object
00415     ::VDumpObject(cszParent, piads, pfile);
00416
00417     // get name
00418     CComBSTR sbstrName;
00419     CheckHresultADs(piads->get_Name(&sbstrName));
00420
00421     // iterate through children, and dump them
00422     CComPtr<IADsContainer> srpiac;
00423     HRESULT hr = S_OK;
00424     CheckHresult(piads->QueryInterface(IID_IADsContainer,(PVOID *) &srpiac),
00425                     TEXT("Failed to QI to IADsContainer interface"));
00426
00427     if (srpiac)
00428         {
00429         CComPtr<IEnumVARIANT> srpiev;
00430         CheckHresult(srpiac->get__NewEnum((IUnknown **) &srpiev), TEXT("Failed to get_NewEnum"));
00431
00432         if (srpiev)
00433             {
00434             while (true)
00435                 {
00436                 CComVariant svar;
00437                 ULONG cFetched = 0;
00438                 hr = srpiev->Next(1, &svar, &cFetched);
00439                 if (S_OK != hr)
00440                     break;
00441
00442                 Assert(1 == cFetched);
00443                 Assert(VT_DISPATCH == svar.vt);
00444                 Assert(svar.pdispVal);
00445
00446                 CComPtr<IADs> srpiads;
00447                 CheckHresultADs(svar.pdispVal->QueryInterface(IID_IADs,
00448                                 (PVOID *) &srpiads));
00449                 Assert(srpiads);
00450
00451                 // dump the object and its children
00452                 ::VDumpTree(sbstrName, srpiads, pfile);
00453                 }
00454             }
00455         }
00456     }
00457
00458
00459 //-----------------------------------------------------------------------------
00460 //
00461 //    Function:        main
00462 //
00463 //    Description:    Entry point of the executable.  Reads the command-line
00464 //                    paramters, and starts the dump.
00465 //
00466 //    Return values:    none
00467 //
00468 //    Threadsafe:        no
00469 //
00470 //-----------------------------------------------------------------------------
00471 void main
00472 (
00473 int argc,
00474 char* argv[]
00475 )
00476     {
00477     FILE * pfile = NULL;
00478
00479     try
00480         {
00481
00482         // initialize COM
00483         CheckHresult(::CoInitialize(NULL), TEXT("Could not initialize COM"));
00484
00485         // validate input
00486         if (3 != argc)
00487             {
00488             MessageBox(NULL,
00489                        TEXT("Usage is AdsiDump <ADSI path> <Output file>"),
00490                        TEXT("Usage"),
00491                        MB_OK);
00492             return;
00493             }
00494
00495         // convert LDAP path to ANSI
00496         UINT cchLdapPath = ::strlen(argv[1]);
00497         SZ szLdapPath = (SZ) alloca((cchLdapPath + 1) * sizeof(WCHAR));
00498         ::MultiByteToWideChar(CP_ACP,
00499                               0,
00500                               argv[1],
00501                               -1,
00502                               szLdapPath,
00503                               cchLdapPath + 1);
00504
00505         // open the file
00506         pfile = ::fopen(argv[2], "w");
00507         if (!pfile)
00508             {
00509             ::MessageBox(NULL,
00510                          TEXT("Could not open output file for writing"),
00511                          TEXT("Error"),
00512                          MB_OK);
00513             return;
00514             }
00515
00516         // open the object
00517         CComPtr<IADs> srpiads;
00518         CheckHresult(::ADsGetObject(szLdapPath,
00519                                     IID_IADs,
00520                                     (PVOID *) &srpiads),
00521                      TEXT("Could not open LDAP path"));
00522         Assert(srpiads);
00523
00524         // dump the tree
00525         ::VDumpTree(NULL, srpiads, pfile);
00526
00527         }
00528     catch (CStringException& rstrex)
00529         {
00530         ::MessageBox(NULL, rstrex, TEXT("Error"), MB_OK);
00531         }
00532
00533     // close the file
00534     if (pfile)
00535         ::fclose(pfile);
00536
00537     ::printf("\n");
00538     }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/llistimpl.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

llistimpl.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.cpp: implementation of CLListImpl helper functions
00013 //
00014
00015
00016 #include "LListImpl.h"
00017
00018
00019 //---------------------------------------------------------------------------
00020 CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
00021 {
00022   _ASSERT( nMax > 0 && cbElement > 0 );
00023   CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
00024       // may throw exception
00025   p->pNext = pHead;
00026   pHead = p;  // change head (adds in reverse order for simplicity)
00027   return p;
00028
00029 } //end Create()
00030
00031 //---------------------------------------------------------------------------
00032 // Free this one and links
00033 //
00034 void CPlex::FreeDataChain()
00035 {
00036   CPlex* p = this;
00037   while (p != NULL)
00038   {
00039     BYTE* bytes = (BYTE*) p;
00040     CPlex* pNext = p->pNext;
00041     delete[] bytes;
00042     p = pNext;
00043   }
00044 } //end FreeDataChain()
00045
00046 //---------------------------------------------------------------------------
00047 // IsValidAddress() returns TRUE if the passed parameter points
00048 // to at least nBytes of accessible memory. If bReadWrite is TRUE,
00049 // the memory must be writeable; if bReadWrite is FALSE, the memory
00050 // may be const.
00051 //
00052 BOOL IsValidAddress
00053 (
00054   const void*  lp,
00055   UINT         nBytes,
00056   BOOL         bReadWrite /* TRUE */
00057 )
00058 {
00059   // Simple version using Win-32 APIs for pointer validation.
00060   return (lp != NULL && !IsBadReadPtr(lp, nBytes) &&
00061          (!bReadWrite || !IsBadWritePtr((LPVOID)lp, nBytes)));
00062
00063 } //end IsValidAddress()
00064
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/rtmapi.c Source File

  • NetDS
  • RRas
  • ip

rtmapi.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\rtmapi.c
00008
00009 Abstract:
00010
00011     The file contains RTMv2 API implementations.
00012
00013 --*/
00014
00015 #include "pchsample.h"
00016 #pragma hdrstop
00017
00018
00019 #ifdef DEBUG
00020 DWORD
00021 RTM_DisplayDestInfo(
00022     IN  PRTM_DEST_INFO          prdi)
00023 /*++
00024
00025 Routine Description
00026     Displays an RTM_DEST_INFO object.
00027
00028 Locks
00029     None
00030
00031 Arguments
00032     prdi                buffer containing the rtm dest info
00033
00034 Return Value
00035     NO_ERROR            always
00036
00037 --*/
00038 {
00039     IPADDRESS   ip;
00040
00041     if (!prdi)
00042         return NO_ERROR;
00043
00044     RTM_GetAddress(&ip, &(prdi->DestAddress));
00045     TRACE2(NETWORK, "RtmDestInfo Destination %s/%u",
00046            INET_NTOA(ip), (prdi->DestAddress).NumBits);
00047
00048     return NO_ERROR;
00049 }
00050 #else
00051 #define DisplayRtmDestInfo(prdi)
00052 #endif // DEBUG
00053
00054
00055
00056 DWORD
00057 RTM_NextHop (
00058     IN  PRTM_DEST_INFO              prdiDestination,
00059     OUT PDWORD                      pdwIfIndex,
00060     OUT PIPADDRESS                  pipNeighbor)
00061 /*++
00062
00063 Routine Description
00064     Obtain the next hop for a destination (typically a data source or an RP).
00065
00066 Locks
00067     None
00068
00069 Arguments
00070     prdiDestination     destination information obtained from rtm
00071     dwIfIndex           next hop interface index
00072     pipNeighbor         ip address of next hop neighbor
00073
00074 Return Value
00075     NO_ERROR            success
00076     Error Code          o/w
00077
00078 --*/
00079 {
00080     DWORD               dwErr = NO_ERROR;
00081     PRTM_ROUTE_INFO     prriRoute;
00082     RTM_NEXTHOP_INFO    rniNextHop;
00083     BOOL                bRoute, bNextHop;
00084
00085     // flags indicating handles held
00086     bRoute = bNextHop = FALSE;
00087
00088     do                          // breakout loop
00089     {
00090         // allocate route info structure
00091         MALLOC(&prriRoute,
00092                RTM_SIZE_OF_ROUTE_INFO(g_ce.rrpRtmProfile.MaxNextHopsInRoute),
00093                &dwErr);
00094         if (dwErr != NO_ERROR)
00095             break;
00096
00097         // get route info (best route in mcast view)
00098         dwErr = RtmGetRouteInfo (
00099             g_ce.hRtmHandle,
00100             prdiDestination->ViewInfo[0].Route,
00101             prriRoute,
00102             NULL);
00103         if (dwErr != NO_ERROR)
00104         {
00105             TRACE1(ANY, "Error %u getting route", dwErr);
00106             break;
00107         }
00108         bRoute = TRUE;
00109
00110         // get nexthop info (first next hop for now...)
00111         dwErr = RtmGetNextHopInfo(
00112             g_ce.hRtmHandle,
00113             prriRoute->NextHopsList.NextHops[0],
00114             &rniNextHop);
00115         if (dwErr != NO_ERROR)
00116         {
00117             TRACE1(ANY, "Error %u getting next hop", dwErr);
00118             break;
00119         }
00120         bNextHop = TRUE;
00121
00122         // finally!!! THIS SHOULD NOT BE A REMOTE NEXT HOP!!!
00123         *(pdwIfIndex) = rniNextHop.InterfaceIndex;
00124         RTM_GetAddress(pipNeighbor,
00125                        &(rniNextHop.NextHopAddress));
00126     } while (FALSE);
00127
00128     if (dwErr != NO_ERROR)
00129         TRACE1(ANY, "Error %u obtaining next hop", dwErr);
00130
00131     // release the handle to the next hop
00132     if (bNextHop)
00133     {
00134         if (RtmReleaseNextHopInfo(g_ce.hRtmHandle, &rniNextHop) != NO_ERROR)
00135             TRACE0(ANY, "Error releasing next hop, continuing...");
00136     }
00137
00138     // release the handle to the route
00139     if (bRoute)
00140     {
00141         if (RtmReleaseRouteInfo(g_ce.hRtmHandle, prriRoute) != NO_ERROR)
00142             TRACE0(ANY, "Error releasing route, continuing...");
00143     }
00144
00145     // deallocate route info structure
00146     if (prriRoute)
00147         FREE(prriRoute);
00148
00149     return dwErr;
00150 }
00151
00152
00153
00154 ////////////////////////////////////////
00155 // CALLBACKFUNCTIONS
00156 ////////////////////////////////////////
00157
00158 DWORD
00159 APIENTRY
00160 RTM_CallbackEvent (
00161     IN  RTM_ENTITY_HANDLE   hRtmHandle, // registration handle
00162     IN  RTM_EVENT_TYPE      retEvent,
00163     IN  PVOID               pvContext1,
00164     IN  PVOID               pvContext2)
00165 /*++
00166
00167 Routine Description
00168     Processes an RTMv2 event.  Used to inform entities of new entities
00169     registering, entities deregistering, route expiration, route changes.
00170
00171 Locks
00172    None (for now)
00173
00174 Arguments
00175    retEvent                 rtmv2 event type
00176
00177 Return Value
00178    NO_ERROR                 success
00179    Error Code               o/w
00180
00181 --*/
00182 {
00183     DWORD dwErr = NO_ERROR;
00184
00185     TRACE1(ENTER, "Entering RTM_CallbackEvent: %u", retEvent);
00186
00187     do                          // breakout loop
00188     {
00189         UNREFERENCED_PARAMETER(hRtmHandle);
00190         UNREFERENCED_PARAMETER(pvContext1);
00191         UNREFERENCED_PARAMETER(pvContext2);
00192
00193         // only route change notifications are processed
00194         if (retEvent != RTM_CHANGE_NOTIFICATION)
00195         {
00196             dwErr = ERROR_NOT_SUPPORTED;
00197             break;
00198         }
00199
00200         dwErr = NM_ProcessRouteChange();
00201     } while (FALSE);
00202
00203     TRACE0(LEAVE, "Leaving  RTM_CallbackEvent");
00204
00205     return dwErr;
00206 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/Resource.h Source File

  • Web
  • MSAgent
  • c
  • CapMFC

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by CapMFC.rc
00004 //
00005 #define IDS_ANIMATIONS_LABEL            2
00006 #define IDM_ABOUTBOX                    0x0010
00007 #define IDD_ABOUTBOX                    100
00008 #define IDS_ABOUTBOX                    101
00009 #define IDD_CAPMFC_DIALOG               102
00010 #define IDS_COMMAND_PROPERTIES          102
00011 #define IDR_MAINFRAME                   128
00012 #define IDR_MENU                        130
00013 #define IDC_ANIMATIONS                  1000
00014 #define IDC_PLAY                        1001
00015 #define IDC_STOP                        1002
00016 #define IDC_AGENT                       1003
00017 #define IDC_SPEAK                       1004
00018 #define IDC_MOVE                        1005
00019 #define IDC_STOPBEFOREPLAY              1012
00020 #define IDC_ANIMATIONS_LABEL            1014
00021 #define IDC_SFX                         1015
00022 #define IDC_SPEECHOUTPUT_LABEL          1016
00023 #define IDC_EDIT1                       1017
00024 #define IDC_SPEAKTEXT                   1017
00025 #define IDC_BALLOON_USE                 1018
00026 #define IDC_BALLOON_AUTOHIDE            1019
00027 #define IDC_BALLOON_AUTOPACE            1020
00028 #define IDC_BALLOON_SIZETOTEXT          1021
00029 #define IDC_POSITION_LABEL              1022
00030 #define IDC_X_LABEL                     1023
00031 #define IDC_MOVE_X                      1024
00032 #define IDC_MOVE_Y                      1025
00033 #define IDC_VERSION                     1025
00034 #define IDC_Y_LABEL                     1026
00035 #define ID_FILE_EXIT                    32772
00036 #define ID_HELP_ABOUT                   32773
00037
00038 // Next default values for new objects
00039 //
00040 #ifdef APSTUDIO_INVOKED
00041 #ifndef APSTUDIO_READONLY_SYMBOLS
00042 #define _APS_NEXT_RESOURCE_VALUE        134
00043 #define _APS_NEXT_COMMAND_VALUE         32774
00044 #define _APS_NEXT_CONTROL_VALUE         1026
00045 #define _APS_NEXT_SYMED_VALUE           101
00046 #endif
00047 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllServe/Server.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllServe

Server.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.CPP
00003
00004   Summary:   Implementation file for the CServer server-related utility
00005              C++ object.  This object encapsulates the server's internal
00006              control of global server object and lock counts.
00007
00008              For a comprehensive tutorial code tour of this module's
00009              contents and offerings see the tutorial DLLSERVE.HTM file.
00010              For more specific technical details on the internal workings
00011              see the comments dispersed throughout the module's source code.
00012
00013   Classes:   CServer.
00014
00015   Functions:
00016
00017   Origin:    9-11-95: atrent - Editor-inheritance from COMOBJ.CPP in
00018                the COMOBJ Tutorial Code Sample.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 /*---------------------------------------------------------------------------
00036   We include WINDOWS.H for all Win32 applications.
00037   We include OLE2.H because we will be calling the COM/OLE Libraries.
00038   We include APPUTIL.H because we will be building this DLL using
00039     the convenient Virtual Window and Dialog classes and other
00040     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00041   We include SERVER.H for the object class declarations for the
00042     C++ CServer server control object.
00043 ---------------------------------------------------------------------------*/
00044 #include <windows.h>
00045 #include <ole2.h>
00046 #include <apputil.h>
00047 #include "server.h"
00048
00049
00050 /*---------------------------------------------------------------------------
00051   Implementation the internal CServer C++ object.  Used to encapsulate
00052   some server data and the methods for Lock and Object count incrementing
00053   and decrementing.
00054 ---------------------------------------------------------------------------*/
00055
00056 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00057   Method:   CServer::CServer
00058
00059   Summary:  CServer Constructor.
00060
00061   Args:     void
00062
00063   Modifies: .
00064
00065   Returns:  void
00066 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00067 CServer::CServer(void)
00068 {
00069   m_hDllInst = NULL;
00070   m_hWndParent = NULL;
00071   m_pMsgBox = NULL;
00072
00073   // Zero the Object and Lock counts for this attached process.
00074   m_cObjects = 0;
00075   m_cLocks = 0;
00076
00077   return;
00078 }
00079
00080
00081 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00082   Method:   CServer::~CServer
00083
00084   Summary:  CServer Destructor.
00085
00086   Args:     void
00087
00088   Modifies: .
00089
00090   Returns:  void
00091 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00092 CServer::~CServer(void)
00093 {
00094   return;
00095 }
00096
00097
00098 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00099   Method:   CServer::Lock
00100
00101   Summary:  Increment the Server's Lock count.
00102
00103   Args:     void
00104
00105   Modifies: .
00106
00107   Returns:  void
00108 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00109 void CServer::Lock(void)
00110 {
00111   InterlockedIncrement((PLONG) &m_cLocks);
00112
00113   LOGF1("S: CServer::Lock. New cLocks=%i.", m_cLocks);
00114
00115   return;
00116 }
00117
00118
00119 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00120   Method:   CServer::Unlock
00121
00122   Summary:  Decrement the Server's Lock count.
00123
00124   Args:     void
00125
00126   Modifies: .
00127
00128   Returns:  void
00129 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00130 void CServer::Unlock(void)
00131 {
00132   InterlockedDecrement((PLONG) &m_cLocks);
00133
00134   LOGF1("S: CServer::Unlock. New cLocks=%i.", m_cLocks);
00135
00136   return;
00137 }
00138
00139
00140 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00141   Method:   CServer::ObjectsUp
00142
00143   Summary:  Increment the Server's living Object count.
00144
00145   Args:     void
00146
00147   Modifies: .
00148
00149   Returns:  void
00150 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00151 void CServer::ObjectsUp(void)
00152 {
00153   InterlockedIncrement((PLONG) &m_cObjects);
00154
00155   LOGF1("S: CServer::ObjectsUp. New cObjects=%i.", m_cObjects);
00156
00157   return;
00158 }
00159
00160
00161 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00162   Method:   CServer::ObjectsDown
00163
00164   Summary:  Decrement the Server's living object count.
00165
00166   Args:     void
00167
00168   Modifies: .
00169
00170   Returns:  void
00171 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00172 void CServer::ObjectsDown(void)
00173 {
00174   InterlockedDecrement((PLONG) &m_cObjects);
00175
00176   LOGF1("S: CServer::ObjectsDown. New cObjects=%i.", m_cObjects);
00177
00178   return;
00179 }
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmMonitor/CrmMonComp.Idl Source File

  • Com
  • Services
  • Crm
  • CrmMonitor

CrmMonComp.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmMonComp.idl
00004
00005
00006 ----------------------------------------------------------------------------
00007
00008 This file is part of the Microsoft COM+ Samples.
00009
00010
00011
00012 Copyright (C) 1995-1998 Microsoft Corporation. All rights reserved.
00013
00014
00015
00016 This source code is intended only as a supplement to Microsoft
00017
00018 Development Tools and/or on-line documentation. See these other
00019
00020 materials for detailed information regarding Microsoft code samples.
00021
00022
00023
00024 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00025
00026 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00027
00028 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00029
00030 PARTICULAR PURPOSE.
00031
00032 ==========================================================================+*/
00033
00034 // CrmMonComp.idl : IDL source for CrmMonComp.dll
00035 //
00036
00037 // This file will be processed by the MIDL tool to
00038 // produce the type library (CrmMonComp.tlb) and marshalling code.
00039
00040 import "oaidl.idl";
00041 import "ocidl.idl";
00042
00043   [
00044
00045     uuid(1721CAC3-E9BA-11D1-A8D7-00A0C91EEDE9),
00046
00047     helpstring("ICrmMonComp Interface"),
00048     pointer_default(unique)
00049   ]
00050   interface ICrmMonComp : IUnknown
00051   {
00052     [propput, helpstring("property TransactionUOW")] HRESULT TransactionUOW([in] VARIANT newVal);
00053     [propget, helpstring("property FindClerks")] HRESULT FindClerks([out, retval] long * plNumberOfClerks);
00054     [helpstring("method SetClerk")] HRESULT SetClerk([in] long lClerkNumber);
00055     [propget, helpstring("property TransactionState")] HRESULT TransactionState([out, retval] VARIANT *pVal);
00056     [propget, helpstring("property ActivityId")] HRESULT ActivityId([out, retval] VARIANT *pVal);
00057     [propget, helpstring("property ProgId")] HRESULT ProgId([out, retval] VARIANT *pVal);
00058     [propget, helpstring("property Description")] HRESULT Description([out, retval] VARIANT *pVal);
00059     [propget, helpstring("property NumberOfLogRecords")] HRESULT NumberOfLogRecords([out, retval] long *pVal);
00060     [helpstring("method AbortTransaction")] HRESULT AbortTransaction();
00061     [helpstring("method SetRecord")] HRESULT SetRecord([in] long lRecordNumber);
00062     [propget, helpstring("property ColumnHeaders")] HRESULT ColumnHeaders([out, retval] VARIANT *pVal);
00063     [propget, helpstring("property FormattedRecord")] HRESULT FormattedRecord([out, retval] VARIANT *pVal);
00064   };
00065 [
00066   uuid(1721CAB4-E9BA-11D1-A8D7-00A0C91EEDE9),
00067   version(1.0),
00068   helpstring("CrmMonComp 1.0 Type Library")
00069 ]
00070 library CRMMONCOMPLib
00071 {
00072   importlib("stdole32.tlb");
00073   importlib("stdole2.tlb");
00074
00075   [
00076     uuid(1721CAC4-E9BA-11D1-A8D7-00A0C91EEDE9),
00077     helpstring("CrmMonComp Class")
00078   ]
00079   coclass CrmMonComp
00080   {
00081     [default] interface ICrmMonComp;
00082   };
00083 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/Check_SD/SD.c Source File

  • Security
  • Authorization
  • Check_SD

SD.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1997 - 2000.  Microsoft Corporation.  All rights reserved
00008
00009 Module Name:
00010
00011     sd.c
00012
00013 Abstract:
00014
00015     This module contains functions to obtain a variety of different components contained in a
00016     Security Descriptor.  This includes an owner (SID), a primary group (SID), a discretionary
00017     ACL (DACL), and a system ACL (SACL).
00018
00019     DumpAclInfo()    - obtains a variety of information on an ACL applies to
00020                        both DACLs and SACLs
00021     DumpControl()    - returns control information which describes the format
00022                        of the security descriptor, absolute or relative, whether a
00023                        DACL and/or SACL is present and whether they were set using
00024                        a default mechanism
00025     DumpDacl()       - returns information associated with the DACL or SACL and
00026                        all ACEs.  NOTE: in order to obtain a SACL for an object, you need
00027                        ACCESS_SYSTEM_SECURITY access to the securable object plus the process
00028                        obtaining the SACL needs to have the SE_SECURITY_NAME ("manager auditing
00029                        and security log") privilege which also needs to be enabled.
00030     DumpOwnerGroup() - returns information on either the owner or primary group
00031     DumpSD()         - bundles up all the other security descriptor calls to one function
00032                        call
00033     DumpSDInfo()     - returns whether the security descriptor is valid and it's
00034                        length
00035
00036 --*/
00037
00038 #include "check_sd.h"
00039 #include <tchar.h>
00040 #include <stdio.h>
00041 #include <lmcons.h>
00042
00043 DWORD DumpAclInfo(PACL pacl, BOOL bDacl)
00044 {
00045      ACL_INFORMATION_CLASS    aic;
00046      BYTE                     pByte[2][12];
00047
00048      //
00049      // is the acl valid
00050      //
00051      _tprintf(TEXT("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"));
00052      if (bDacl)
00053           _tprintf(TEXT(">>                 DACL INFORMATION                    >>\n"));
00054      else
00055           _tprintf(TEXT(">>                 SACL INFORMATION                    >>\n"));
00056
00057      _tprintf(TEXT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"));
00058      _tprintf(TEXT("valid .............. "));
00059
00060      if (!IsValidAcl(pacl)){
00061           _tprintf(TEXT("no\n"));
00062           return 0;
00063      }
00064      else
00065           _tprintf(TEXT("yes\n"));
00066
00067      for (aic=1; aic<3; aic++){
00068           if (!GetAclInformation(pacl, (LPVOID)pByte[aic-1], sizeof(ACL_SIZE_INFORMATION), aic))
00069                DisplayError(GetLastError(), TEXT("GetAclInformation"));
00070      }
00071
00072      _tprintf(TEXT("revision ........... %u\n\n"), *((PACL_REVISION_INFORMATION)pByte[0]));
00073      _tprintf(TEXT("ace count .......... %u\n"), ((PACL_SIZE_INFORMATION)pByte[1])->AceCount);
00074      _tprintf(TEXT("acl bytes in use ... %u byte(s)\n"), ((PACL_SIZE_INFORMATION)pByte[1])->AclBytesInUse);
00075      _tprintf(TEXT("acl bytes free ..... %u byte(s)\n"), ((PACL_SIZE_INFORMATION)pByte[1])->AclBytesFree);
00076
00077      return ((PACL_SIZE_INFORMATION)pByte[1])->AceCount;
00078 }
00079
00080 void DumpControl(PSECURITY_DESCRIPTOR psd)
00081 {
00082      DWORD                       dwRevision;
00083      SECURITY_DESCRIPTOR_CONTROL sdc;
00084
00085      if (!GetSecurityDescriptorControl(psd, &sdc, &dwRevision))
00086           DisplayError(GetLastError(), TEXT("GetSecurityDescriptorControl"));
00087
00088      _tprintf(TEXT("revision ........... %u\n"), dwRevision);
00089      _tprintf(TEXT("control bits ....... 0x%X\n"), sdc);
00090
00091      if ((sdc & SE_DACL_DEFAULTED) == SE_DACL_DEFAULTED)
00092           _tprintf(TEXT(".................... SE_DACL_DEFAULTED\n"));
00093      if ((sdc & SE_DACL_PRESENT) == SE_DACL_PRESENT)
00094           _tprintf(TEXT(".................... SE_DACL_PRESENT\n"));
00095      if ((sdc & SE_GROUP_DEFAULTED) == SE_GROUP_DEFAULTED)
00096           _tprintf(TEXT(".................... SE_GROUP_DEFAULTED\n"));
00097      if ((sdc & SE_OWNER_DEFAULTED) == SE_OWNER_DEFAULTED)
00098           _tprintf(TEXT(".................... SE_OWNER_DEFAULTED\n"));
00099      if ((sdc & SE_SACL_DEFAULTED) == SE_SACL_DEFAULTED)
00100           _tprintf(TEXT(".................... SE_SACL_DEFAULTED\n"));
00101      if ((sdc & SE_SACL_PRESENT) == SE_SACL_PRESENT)
00102           _tprintf(TEXT(".................... SE_SACL_PRESENT\n"));
00103      if ((sdc & SE_SELF_RELATIVE) == SE_SELF_RELATIVE)
00104           _tprintf(TEXT(".................... SE_SELF_RELATIVE\n"));
00105      if ((sdc & SE_DACL_AUTO_INHERITED) == SE_DACL_AUTO_INHERITED) // NT5.0
00106           _tprintf(TEXT(".................... SE_DACL_AUTO_INHERITED\n"));
00107      if ((sdc & SE_SACL_AUTO_INHERITED) == SE_SACL_AUTO_INHERITED) // NT5.0
00108           _tprintf(TEXT(".................... SE_SACL_AUTO_INHERITED\n"));
00109      if ((sdc & SE_SACL_PROTECTED) == SE_SACL_PROTECTED) // NT5.0
00110           _tprintf(TEXT(".................... SE_SACL_PROTECTED\n"));
00111      if ((sdc & SE_DACL_PROTECTED) == SE_DACL_PROTECTED) // NT5.0
00112           _tprintf(TEXT(".................... SE_DACL_PROTECTED\n"));
00113 }
00114
00115 void DumpDacl(PSECURITY_DESCRIPTOR psd, TCHAR c, BOOL bDacl)
00116 {
00117      ACCESS_ALLOWED_ACE *pace;
00118      BOOL                bDaclPresent;
00119      BOOL                bDaclDefaulted;
00120      DWORD               dwAceCount;
00121      DWORD               cbName;
00122      DWORD               cbReferencedDomainName;
00123      DWORD               dwSize;
00124      int                 i;
00125      PACL                pacl;
00126      PSID                psid = NULL;
00127      SID_NAME_USE        snu;
00128      TCHAR               szName[UNLEN];
00129      TCHAR               szReferencedDomainName[DNLEN];
00130      TCHAR               szSidText[256];
00131      TCHAR               szSidType[][17] = {TEXT("User"), TEXT("Group"), TEXT("Domain"), TEXT("Alias"), TEXT("Well Known Group"), TEXT("Deleted Account"), TEXT("Invalid"), TEXT("Unknown")};
00132
00133      if (bDacl){
00134           if (!GetSecurityDescriptorDacl(psd, &bDaclPresent, &pacl, &bDaclDefaulted))
00135                DisplayError(GetLastError(), TEXT("GetSecurityDescriptorDacTEXT("));
00136      }
00137      else{
00138           if (!GetSecurityDescriptorSacl(psd, &bDaclPresent, &pacl, &bDaclDefaulted))
00139                DisplayError(GetLastError(), TEXT("GetSecurityDescriptorSacTEXT("));
00140      }
00141
00142      if (bDaclPresent){
00143           //
00144           // dump the dacl
00145           //
00146           if (pacl == NULL){
00147                if (bDacl)
00148                     _tprintf(TEXT("\ndacl ............... NULL\n"));
00149                else
00150                     _tprintf(TEXT("\nsacl ............... NULL\n"));
00151           }
00152           else{
00153                dwAceCount = DumpAclInfo(pacl, bDacl);
00154
00155                for (i = 0; i < (int)dwAceCount; i++){
00156                     if (!GetAce(pacl, i, (LPVOID)&pace))
00157                          DisplayError(GetLastError(), TEXT("GetAce"));
00158
00159                     _tprintf(TEXT("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"));
00160                     _tprintf(TEXT(">>                  ACE #%u                             >>\n"), i+1);
00161                     _tprintf(TEXT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"));
00162                     _tprintf(TEXT("type ............... "));
00163
00164                     switch(pace->Header.AceType){
00165                          case ACCESS_ALLOWED_ACE_TYPE:
00166                               _tprintf(TEXT("ACCESS_ALLOWED_ACE\n"));
00167                               break;
00168                          case ACCESS_DENIED_ACE_TYPE:
00169                               _tprintf(TEXT("ACCESS_DENIED_ACE\n"));
00170                               break;
00171                          case SYSTEM_AUDIT_ACE_TYPE:
00172                               _tprintf(TEXT("SYSTEM_AUDIT_ACE\n"));
00173                               break;
00174                          case ACCESS_ALLOWED_OBJECT_ACE_TYPE: // NT5.0
00175                               _tprintf(TEXT("ACCESS_ALLOWED_OBJECT_ACE_TYPE\n"));
00176                               break;
00177                          case ACCESS_DENIED_OBJECT_ACE_TYPE: // NT5.0
00178                               _tprintf(TEXT("ACCESS_DENIED_OBJECT_ACE_TYPE\n"));
00179                               break;
00180                          case SYSTEM_AUDIT_OBJECT_ACE_TYPE: // NT5.0
00181                               _tprintf(TEXT("SYSTEM_AUDIT_OBJECT_ACE_TYPE\n"));
00182                               break;
00183                     }
00184
00185                     _tprintf(TEXT("flags .............. 0x%X\n"), pace->Header.AceFlags);
00186
00187                     if ((pace->Header.AceFlags & CONTAINER_INHERIT_ACE) == CONTAINER_INHERIT_ACE)
00188                          _tprintf(TEXT(".................... CONTAINER_INHERIT_ACE\n"));
00189
00190                     if ((pace->Header.AceFlags & INHERIT_ONLY_ACE) == INHERIT_ONLY_ACE)
00191                          _tprintf(TEXT(".................... INHERIT_ONLY_ACE\n"));
00192
00193                     if ((pace->Header.AceFlags & NO_PROPAGATE_INHERIT_ACE) == NO_PROPAGATE_INHERIT_ACE)
00194                          _tprintf(TEXT(".................... NO_PROPAGATE_INHERIT_ACE\n"));
00195
00196                     if ((pace->Header.AceFlags & OBJECT_INHERIT_ACE) == OBJECT_INHERIT_ACE)
00197                          _tprintf(TEXT(".................... OBJECT_INHERIT_ACE\n"));
00198
00199                     if ((pace->Header.AceFlags & FAILED_ACCESS_ACE_FLAG) == FAILED_ACCESS_ACE_FLAG)
00200                          _tprintf(TEXT(".................... FAILED_ACCESS_ACE_FLAG\n"));
00201
00202                     if ((pace->Header.AceFlags & SUCCESSFUL_ACCESS_ACE_FLAG) == SUCCESSFUL_ACCESS_ACE_FLAG)
00203                          _tprintf(TEXT(".................... SUCCESSFUL_ACCESS_ACE_FLAG\n"));
00204
00205                     if ((pace->Header.AceFlags & INHERITED_ACE) == INHERITED_ACE) // NT5.0
00206                          _tprintf(TEXT(".................... INHERITED_ACE\n"));
00207
00208                     _tprintf(TEXT("size ............... %u byte(s)\n"), pace->Header.AceSize);
00209                     _tprintf(TEXT("mask ............... 0x%X\n"), pace->Mask);
00210
00211                     switch (c){
00212                          case 'r':
00213                               //
00214                               // registry SPECIFIC access rights
00215                               //
00216                               if ((pace->Mask & KEY_CREATE_LINK) == KEY_CREATE_LINK)
00217                                    _tprintf(TEXT(".................... KEY_CREATE_LINK\n"));
00218                               if ((pace->Mask & KEY_CREATE_SUB_KEY) == KEY_CREATE_SUB_KEY)
00219                                    _tprintf(TEXT(".................... KEY_CREATE_SUB_KEY\n"));
00220                               if ((pace->Mask & KEY_ENUMERATE_SUB_KEYS) == KEY_ENUMERATE_SUB_KEYS)
00221                                    _tprintf(TEXT(".................... KEY_ENUMERATE_SUB_KEYS\n"));
00222                               if ((pace->Mask & KEY_EXECUTE) == KEY_EXECUTE)
00223                                    _tprintf(TEXT(".................... KEY_EXECUTE\n"));
00224                               if ((pace->Mask & KEY_NOTIFY) == KEY_NOTIFY)
00225                                    _tprintf(TEXT(".................... KEY_NOTIFY\n"));
00226                               if ((pace->Mask & KEY_QUERY_VALUE) == KEY_QUERY_VALUE)
00227                                    _tprintf(TEXT(".................... KEY_QUERY_VALUE\n"));
00228                               if ((pace->Mask & KEY_READ) == KEY_READ)
00229                                    _tprintf(TEXT(".................... KEY_READ\n"));
00230                               if ((pace->Mask & KEY_SET_VALUE) == KEY_SET_VALUE)
00231                                    _tprintf(TEXT(".................... KEY_SET_VALUE\n"));
00232                               if ((pace->Mask & KEY_WRITE) == KEY_WRITE)
00233                                    _tprintf(TEXT(".................... KEY_WRITE\n"));
00234                               break;
00235                          case 'f':
00236                               if ((pace->Mask & FILE_READ_DATA) == FILE_READ_DATA)
00237                                    _tprintf(TEXT(".................... FILE_READ_DATA\n"));
00238                               if ((pace->Mask & FILE_WRITE_DATA) == FILE_WRITE_DATA)
00239                                    _tprintf(TEXT(".................... FILE_WRITE_DATA\n"));
00240                               if ((pace->Mask & FILE_APPEND_DATA) == FILE_APPEND_DATA)
00241                                    _tprintf(TEXT(".................... FILE_APPEND_DATA\n"));
00242                               if ((pace->Mask & FILE_READ_EA) == FILE_READ_EA)
00243                                    _tprintf(TEXT(".................... FILE_READ_EA\n"));
00244                               if ((pace->Mask & FILE_WRITE_EA) == FILE_WRITE_EA)
00245                                    _tprintf(TEXT(".................... FILE_WRITE_EA\n"));
00246                               if ((pace->Mask & FILE_EXECUTE) == FILE_EXECUTE)
00247                                    _tprintf(TEXT(".................... FILE_EXECUTE\n"));
00248                               if ((pace->Mask & FILE_READ_ATTRIBUTES) == FILE_READ_ATTRIBUTES)
00249                                    _tprintf(TEXT(".................... FILE_READ_ATTRIBUTES\n"));
00250                               if ((pace->Mask & FILE_WRITE_ATTRIBUTES) == FILE_WRITE_ATTRIBUTES)
00251                                    _tprintf(TEXT(".................... FILE_WRITE_ATTRIBUTES\n"));
00252                               break;
00253                          case 'd':
00254                               if ((pace->Mask & FILE_LIST_DIRECTORY) == FILE_LIST_DIRECTORY)
00255                                    _tprintf(TEXT(".................... FILE_LIST_DIRECTORY\n"));
00256                               if ((pace->Mask & FILE_ADD_FILE) == FILE_ADD_FILE)
00257                                    _tprintf(TEXT(".................... FILE_ADD_FILE\n"));
00258                               if ((pace->Mask & FILE_ADD_SUBDIRECTORY) == FILE_ADD_SUBDIRECTORY)
00259                                    _tprintf(TEXT(".................... FILE_ADD_SUBDIRECTORY\n"));
00260                               if ((pace->Mask & FILE_READ_EA) == FILE_READ_EA)
00261                                    _tprintf(TEXT(".................... FILE_READ_EA\n"));
00262                               if ((pace->Mask & FILE_WRITE_EA) == FILE_WRITE_EA)
00263                                    _tprintf(TEXT(".................... FILE_WRITE_EA\n"));
00264                               if ((pace->Mask & FILE_TRAVERSE) == FILE_TRAVERSE)
00265                                    _tprintf(TEXT(".................... FILE_TRAVERSE\n"));
00266                               if ((pace->Mask & FILE_DELETE_CHILD) == FILE_DELETE_CHILD)
00267                                    _tprintf(TEXT(".................... FILE_DELETE_CHILD\n"));
00268                               if ((pace->Mask & FILE_READ_ATTRIBUTES) == FILE_READ_ATTRIBUTES)
00269                                    _tprintf(TEXT(".................... FILE_READ_ATTRIBUTES\n"));
00270                               if ((pace->Mask & FILE_WRITE_ATTRIBUTES) == FILE_WRITE_ATTRIBUTES)
00271                                    _tprintf(TEXT(".................... FILE_WRITE_ATTRIBUTES\n"));
00272                               break;
00273                          case 'e':
00274                               if ((pace->Mask & EVENT_MODIFY_STATE) == EVENT_MODIFY_STATE)
00275                                    _tprintf(TEXT(".................... EVENT_MODIFY_STATE\n"));
00276                               break;
00277                          case 'm':
00278                               if ((pace->Mask & MUTANT_QUERY_STATE) == MUTANT_QUERY_STATE)
00279                                    _tprintf(TEXT(".................... MUTANT_QUERY_STATE\n"));
00280                               break;
00281                          case 's':
00282                               if ((pace->Mask & SEMAPHORE_MODIFY_STATE) == SEMAPHORE_MODIFY_STATE)
00283                                    _tprintf(TEXT(".................... SEMAPHORE_MODIFY_STATE\n"));
00284                               break;
00285                          case 'p':
00286                               if ((pace->Mask & PROCESS_TERMINATE) == PROCESS_TERMINATE)
00287                                    _tprintf(TEXT(".................... PROCESS_TERMINATE\n"));
00288                               if ((pace->Mask & PROCESS_CREATE_THREAD) == PROCESS_CREATE_THREAD)
00289                                    _tprintf(TEXT(".................... PROCESS_CREATE_THREAD\n"));
00290                               if ((pace->Mask & PROCESS_VM_OPERATION) == PROCESS_VM_OPERATION)
00291                                    _tprintf(TEXT(".................... PROCESS_VM_OPERATION\n"));
00292                               if ((pace->Mask & PROCESS_VM_READ) == PROCESS_VM_READ)
00293                                    _tprintf(TEXT(".................... PROCESS_VM_READ\n"));
00294                               if ((pace->Mask & PROCESS_VM_WRITE) == PROCESS_VM_WRITE)
00295                                    _tprintf(TEXT(".................... PROCESS_VM_WRITE\n"));
00296                               if ((pace->Mask & PROCESS_DUP_HANDLE) == PROCESS_DUP_HANDLE)
00297                                    _tprintf(TEXT(".................... PROCESS_DUP_HANDLE\n"));
00298                               if ((pace->Mask & PROCESS_CREATE_PROCESS) == PROCESS_CREATE_PROCESS)
00299                                    _tprintf(TEXT(".................... PROCESS_CREATE_PROCESS\n"));
00300                               if ((pace->Mask & PROCESS_SET_QUOTA) == PROCESS_SET_QUOTA)
00301                                    _tprintf(TEXT(".................... PROCESS_SET_QUOTA\n"));
00302                               if ((pace->Mask & PROCESS_SET_INFORMATION) == PROCESS_SET_INFORMATION)
00303                                    _tprintf(TEXT(".................... PROCESS_SET_INFORMATION\n"));
00304                               if ((pace->Mask & PROCESS_QUERY_INFORMATION) == PROCESS_QUERY_INFORMATION)
00305                                    _tprintf(TEXT(".................... PROCESS_QUERY_INFORMATION\n"));
00306                               break;
00307                          case 'i':
00308                               if ((pace->Mask & SECTION_QUERY) == SECTION_QUERY)
00309                                    _tprintf(TEXT(".................... SECTION_QUERY\n"));
00310                               if ((pace->Mask & SECTION_MAP_WRITE) == SECTION_MAP_WRITE)
00311                                    _tprintf(TEXT(".................... SECTION_MAP_WRITE\n"));
00312                               if ((pace->Mask & SECTION_MAP_READ) == SECTION_MAP_READ)
00313                                    _tprintf(TEXT(".................... SECTION_MAP_READ\n"));
00314                               if ((pace->Mask & SECTION_MAP_EXECUTE) == SECTION_MAP_EXECUTE)
00315                                    _tprintf(TEXT(".................... SECTION_MAP_EXECUTE\n"));
00316                               if ((pace->Mask & SECTION_EXTEND_SIZE) == SECTION_EXTEND_SIZE)
00317                                    _tprintf(TEXT(".................... SECTION_EXTEND_SIZE\n"));
00318                               break;
00319                          case 'v':
00320                               if ((pace->Mask & SERVICE_CHANGE_CONFIG) == SERVICE_CHANGE_CONFIG)
00321                                    _tprintf(TEXT(".................... SERVICE_CHANGE_CONFIG\n"));
00322                               if ((pace->Mask & SERVICE_ENUMERATE_DEPENDENTS) == SERVICE_ENUMERATE_DEPENDENTS)
00323                                    _tprintf(TEXT(".................... SERVICE_ENUMERATE_DEPENDENTS\n"));
00324                               if ((pace->Mask & SERVICE_INTERROGATE) == SERVICE_INTERROGATE)
00325                                    _tprintf(TEXT(".................... SERVICE_INTERROGATE\n"));
00326                               if ((pace->Mask & SERVICE_PAUSE_CONTINUE) == SERVICE_PAUSE_CONTINUE)
00327                                    _tprintf(TEXT(".................... SERVICE_PAUSE_CONTINUE\n"));
00328                               if ((pace->Mask & SERVICE_QUERY_CONFIG) == SERVICE_QUERY_CONFIG)
00329                                    _tprintf(TEXT(".................... SERVICE_QUERY_CONFIG\n"));
00330                               if ((pace->Mask & SERVICE_QUERY_STATUS) == SERVICE_QUERY_STATUS)
00331                                    _tprintf(TEXT(".................... SERVICE_QUERY_STATUS\n"));
00332                               if ((pace->Mask & SERVICE_START) == SERVICE_START)
00333                                    _tprintf(TEXT(".................... SERVICE_START\n"));
00334                               if ((pace->Mask & SERVICE_STOP) == SERVICE_STOP)
00335                                    _tprintf(TEXT(".................... SERVICE_STOP\n"));
00336                               if ((pace->Mask & SERVICE_USER_DEFINED_CONTROL) == SERVICE_USER_DEFINED_CONTROL)
00337                                    _tprintf(TEXT(".................... SERVICE_USER_DEFINED_CONTROL\n"));
00338                               break;
00339                          case 'w':
00340                               if ((pace->Mask & WINSTA_ACCESSCLIPBOARD) == WINSTA_ACCESSCLIPBOARD)
00341                                    _tprintf(TEXT(".................... WINSTA_ACCESSCLIPBOARD\n"));
00342                               if ((pace->Mask & WINSTA_ACCESSGLOBALATOMS) == WINSTA_ACCESSGLOBALATOMS)
00343                                    _tprintf(TEXT(".................... WINSTA_ACCESSGLOBALATOMS\n"));
00344                               if ((pace->Mask & WINSTA_CREATEDESKTOP) == WINSTA_CREATEDESKTOP)
00345                                    _tprintf(TEXT(".................... WINSTA_CREATEDESKTOP\n"));
00346                               if ((pace->Mask & WINSTA_ENUMDESKTOPS) == WINSTA_ENUMDESKTOPS)
00347                                    _tprintf(TEXT(".................... WINSTA_ENUMDESKTOPS\n"));
00348                               if ((pace->Mask & WINSTA_ENUMERATE) == WINSTA_ENUMERATE)
00349                                    _tprintf(TEXT(".................... WINSTA_ENUMERATE\n"));
00350                               if ((pace->Mask & WINSTA_EXITWINDOWS) == WINSTA_EXITWINDOWS)
00351                                    _tprintf(TEXT(".................... WINSTA_EXITWINDOWS\n"));
00352                               if ((pace->Mask & WINSTA_READATTRIBUTES) == WINSTA_READATTRIBUTES)
00353                                    _tprintf(TEXT(".................... WINSTA_READATTRIBUTES\n"));
00354                               if ((pace->Mask & WINSTA_READSCREEN) == WINSTA_READSCREEN)
00355                                    _tprintf(TEXT(".................... WINSTA_READSCREEN\n"));
00356                               if ((pace->Mask & WINSTA_WRITEATTRIBUTES) == WINSTA_WRITEATTRIBUTES)
00357                                    _tprintf(TEXT(".................... WINSTA_WRITEATTRIBUTES\n"));
00358                               break;
00359                          case 'k':
00360                               if ((pace->Mask & DESKTOP_CREATEMENU) == DESKTOP_CREATEMENU)
00361                                    _tprintf(TEXT(".................... DESKTOP_CREATEMENU\n"));
00362                               if ((pace->Mask & DESKTOP_CREATEWINDOW) == DESKTOP_CREATEWINDOW)
00363                                    _tprintf(TEXT(".................... DESKTOP_CREATEWINDOW\n"));
00364                               if ((pace->Mask & DESKTOP_ENUMERATE) == DESKTOP_ENUMERATE)
00365                                   _tprintf(TEXT(".................... DESKTOP_ENUMERATE\n"));
00366                               if ((pace->Mask & DESKTOP_HOOKCONTROL) == DESKTOP_HOOKCONTROL)
00367                                    _tprintf(TEXT(".................... DESKTOP_HOOKCONTROL\n"));
00368                               if ((pace->Mask & DESKTOP_JOURNALPLAYBACK) == DESKTOP_JOURNALPLAYBACK)
00369                                    _tprintf(TEXT(".................... DESKTOP_JOURNALPLAYBACK\n"));
00370                               if ((pace->Mask & DESKTOP_JOURNALRECORD) == DESKTOP_JOURNALRECORD)
00371                                    _tprintf(TEXT(".................... DESKTOP_JOURNALRECORD\n"));
00372                               if ((pace->Mask & DESKTOP_READOBJECTS) == DESKTOP_READOBJECTS)
00373                                    _tprintf(TEXT(".................... DESKTOP_READOBJECTS\n"));
00374                               if ((pace->Mask & DESKTOP_SWITCHDESKTOP) == DESKTOP_SWITCHDESKTOP)
00375                                    _tprintf(TEXT(".................... DESKTOP_SWITCHDESKTOP\n"));
00376                               if ((pace->Mask & DESKTOP_WRITEOBJECTS) == DESKTOP_WRITEOBJECTS)
00377                                    _tprintf(TEXT(".................... DESKTOP_WRITEOBJECTS\n"));
00378                               break;
00379                          case 'l':
00380                               if ((pace->Mask & SERVER_ACCESS_ADMINISTER) == SERVER_ACCESS_ADMINISTER)
00381                                    _tprintf(TEXT(".................... SERVER_ACCESS_ADMINISTER\n"));
00382                               if ((pace->Mask & SERVER_ACCESS_ENUMERATE) == SERVER_ACCESS_ENUMERATE)
00383                                    _tprintf(TEXT(".................... SERVER_ACCESS_ENUMERATE\n"));
00384                               if ((pace->Mask & PRINTER_ACCESS_ADMINISTER) == PRINTER_ACCESS_ADMINISTER)
00385                                    _tprintf(TEXT(".................... PRINTER_ACCESS_ADMINISTER\n"));
00386                               if ((pace->Mask & PRINTER_ACCESS_USE) == PRINTER_ACCESS_USE)
00387                                     _tprintf(TEXT(".................... PRINTER_ACCESS_USE\n"));
00388                               if ((pace->Mask & JOB_ACCESS_ADMINISTER) == JOB_ACCESS_ADMINISTER)
00389                                    _tprintf(TEXT(".................... JOB_ACCESS_ADMINISTER\n"));
00390                               break;
00391                          case 't':
00392                               if ((pace->Mask & READ) == READ)
00393                                    _tprintf(TEXT(".................... READ\n"));
00394                               if ((pace->Mask & CHANGE) == CHANGE)
00395                                    _tprintf(TEXT(".................... CHANGE\n"));
00396                               if ((pace->Mask & WRITE) == WRITE)
00397                                    _tprintf(TEXT(".................... WRITE\n"));
00398                               break;
00399                          case 'o':
00400                               if ((pace->Mask & TOKEN_ADJUST_DEFAULT) == TOKEN_ADJUST_DEFAULT)
00401                                    _tprintf(TEXT(".................... TOKEN_ADJUST_DEFAULT\n"));
00402                               if ((pace->Mask & TOKEN_ADJUST_GROUPS) == TOKEN_ADJUST_GROUPS)
00403                                    _tprintf(TEXT(".................... TOKEN_ADJUST_GROUPSE\n"));
00404                               if ((pace->Mask & TOKEN_ADJUST_PRIVILEGES) == TOKEN_ADJUST_PRIVILEGES)
00405                                   _tprintf(TEXT(".................... TOKEN_ADJUST_PRIVILEGES\n"));
00406                               if ((pace->Mask & TOKEN_ALL_ACCESS) == TOKEN_ALL_ACCESS)
00407                                   _tprintf(TEXT(".................... TOKEN_ALL_ACCESS\n"));
00408                               if ((pace->Mask & TOKEN_ASSIGN_PRIMARY) == TOKEN_ASSIGN_PRIMARY)
00409                                   _tprintf(TEXT(".................... TOKEN_ASSIGN_PRIMARY\n"));
00410                               if ((pace->Mask & TOKEN_DUPLICATE) == TOKEN_DUPLICATE)
00411                                   _tprintf(TEXT(".................... TOKEN_DUPLICATE\n"));
00412                               if ((pace->Mask & TOKEN_EXECUTE) == TOKEN_EXECUTE)
00413                                   _tprintf(TEXT(".................... TOKEN_EXECUTE\n"));
00414                               if ((pace->Mask & TOKEN_IMPERSONATE) == TOKEN_IMPERSONATE)
00415                                   _tprintf(TEXT(".................... TOKEN_IMPERSONATE\n"));
00416                               if ((pace->Mask & TOKEN_QUERY) == TOKEN_QUERY)
00417                                   _tprintf(TEXT(".................... TOKEN_QUERY\n"));
00418                               if ((pace->Mask & TOKEN_QUERY_SOURCE) == TOKEN_QUERY_SOURCE)
00419                                   _tprintf(TEXT(".................... TOKEN_QUERY_SOURCE\n"));
00420                               if ((pace->Mask & TOKEN_READ) == TOKEN_READ)
00421                                   _tprintf(TEXT(".................... TOKEN_READ\n"));
00422                               if ((pace->Mask & TOKEN_WRITE) == TOKEN_WRITE)
00423                                   _tprintf(TEXT(".................... TOKEN_WRITE\n"));
00424                               break;
00425                          case 'n':
00426                          case 'a':
00427                               break;
00428                          default:
00429                               break;
00430                     }
00431
00432                //
00433                // object rights
00434                //
00435                if ((pace->Mask & READ_CONTROL) == READ_CONTROL)
00436                     _tprintf(TEXT(".................... READ_CONTROL\n"));
00437                if ((pace->Mask & WRITE_OWNER) == WRITE_OWNER)
00438                     _tprintf(TEXT(".................... WRITE_OWNER\n"));
00439                if ((pace->Mask & WRITE_DAC) == WRITE_DAC)
00440                     _tprintf(TEXT(".................... WRITE_DAC\n"));
00441                if ((pace->Mask & DELETE) == DELETE)
00442                     _tprintf(TEXT(".................... DELETE\n"));
00443                if ((pace->Mask & SYNCHRONIZE) == SYNCHRONIZE)
00444                     _tprintf(TEXT(".................... SYNCHRONIZE\n"));
00445                if ((pace->Mask & ACCESS_SYSTEM_SECURITY) == ACCESS_SYSTEM_SECURITY)
00446                     _tprintf(TEXT(".................... ACCESS_SYSTEM_SECURITY\n"));
00447
00448                //
00449                // GENERIC access rights
00450                //
00451                if ((pace->Mask & GENERIC_ALL) == GENERIC_ALL)
00452                     _tprintf(TEXT(".................... GENERIC_ALL\n"));
00453                if ((pace->Mask & GENERIC_EXECUTE) == GENERIC_EXECUTE)
00454                     _tprintf(TEXT(".................... GENERIC_EXECUTE\n"));
00455                if ((pace->Mask & GENERIC_READ) == GENERIC_READ)
00456                     _tprintf(TEXT(".................... GENERIC_READ\n"));
00457                if ((pace->Mask & GENERIC_WRITE) == GENERIC_WRITE)
00458                     _tprintf(TEXT(".................... GENERIC_WRITE\n"));
00459
00460                //
00461                // display sid
00462                //
00463                cbName = sizeof(szName);
00464                cbReferencedDomainName = sizeof(szReferencedDomainName);
00465                ZeroMemory(szName, cbName);
00466                ZeroMemory(szReferencedDomainName, cbReferencedDomainName);
00467
00468                if (!LookupAccountSid(NULL, &(pace->SidStart), szName, &cbName, szReferencedDomainName, &cbReferencedDomainName, &snu)){
00469                     if (GetLastError() == ERROR_NONE_MAPPED)
00470                          LookupAccountOtherSid(&(pace->SidStart), szName, &cbName, szReferencedDomainName, &cbReferencedDomainName, &snu);
00471                     else
00472                          DisplayError(GetLastError(), TEXT("LookupAccountSid"));
00473                }
00474
00475                _tprintf(TEXT("\nuser ............... %s\\%s\n"), szReferencedDomainName, szName);
00476                dwSize = sizeof(szSidText);
00477                ZeroMemory(szSidText, dwSize);
00478                ConvertSid(&(pace->SidStart), szSidText, &dwSize);
00479                _tprintf(TEXT("sid ................ %s\n"), szSidText);
00480                _tprintf(TEXT("sid type ........... %s\n"), szSidType[snu-1]);
00481                _tprintf(TEXT("sid size ........... %u bytes\n"), GetLengthSid(&(pace->SidStart)));
00482          }
00483           }
00484          }
00485      else{
00486           _tprintf(TEXT("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"));
00487           if (bDacl)
00488                _tprintf(TEXT(">>                 NO DACL PRESENT                     >>\n"));
00489           else
00490                _tprintf(TEXT(">>                 NO SACL PRESENT                     >>\n"));
00491
00492
00493           _tprintf(TEXT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"));
00494      }
00495 }
00496
00497 void DumpOwnerGroup(PSECURITY_DESCRIPTOR psd, BOOL bOwner)
00498 {
00499      BOOL         bOwnerDefaulted;
00500      TCHAR        szSidType[][17] = {TEXT("User"), TEXT("Group"), TEXT("Domain"), TEXT("Alias"), TEXT("Well Known Group"), TEXT("Deleted Account"), TEXT("Invalid"), TEXT("Unknown")};
00501      PSID         psid = NULL;
00502      SID_NAME_USE snu;
00503      TCHAR        szName[UNLEN];
00504      TCHAR        szReferencedDomainName[DNLEN];
00505      DWORD        cbName = sizeof(szName);
00506      DWORD        cbReferencedDomainName = sizeof(szReferencedDomainName);
00507      TCHAR        szSidText[256] = TEXT("");
00508      DWORD        dwSize = sizeof(szSidText);
00509      TCHAR        szType[6]      = TEXT("");
00510
00511      if (bOwner){
00512           if (!GetSecurityDescriptorOwner(psd, &psid, &bOwnerDefaulted))
00513                DisplayError(GetLastError(), TEXT("GetSecurityDescriptorOwner"));
00514                if (!lstrcpy(szType, TEXT("owner")))
00515                     DisplayError(GetLastError(), TEXT("lstrcpy"));
00516          }
00517      else{
00518           if (!GetSecurityDescriptorGroup(psd, &psid, &bOwnerDefaulted))
00519                DisplayError(GetLastError(), TEXT("GetSecurityDescriptorGroup"));
00520                if(!lstrcpy(szType, TEXT("group")))
00521                     DisplayError(GetLastError(), TEXT("lstrcpy"));
00522          }
00523
00524      if (psid == NULL)
00525           _tprintf(TEXT("%s .............. none\n"), szType);
00526      else{
00527           ZeroMemory(szName, cbName);
00528           ZeroMemory(szReferencedDomainName, cbReferencedDomainName);
00529
00530           //
00531           // get the owner of the sid
00532           //
00533           if (!LookupAccountSid(NULL, psid, szName, &cbName, szReferencedDomainName, &cbReferencedDomainName, &snu)){
00534                if (GetLastError() != ERROR_NONE_MAPPED)
00535                     DisplayError(GetLastError(), TEXT("LookupAccountSid"));
00536           }
00537
00538           _tprintf(TEXT("\n%s .............. %s\\%s\n"), szType, szReferencedDomainName, szName);
00539           ConvertSid(psid, szSidText, &dwSize);
00540           _tprintf(TEXT("sid ................ %s\n"), szSidText);
00541           _tprintf(TEXT("sid type ........... %s\n"), szSidType[snu-1]);
00542      }
00543 }
00544
00545 void DumpSD(PSECURITY_DESCRIPTOR psd, TCHAR c)
00546 {
00547      //
00548      // dump security descriptor information
00549      //
00550      DumpSDInfo(psd);
00551
00552      //
00553      // dump the control bits
00554      //
00555      DumpControl(psd);
00556
00557      //
00558      // get the owner
00559      //
00560      DumpOwnerGroup(psd, TRUE);
00561
00562      //
00563      // get the group
00564      //
00565      DumpOwnerGroup(psd, FALSE);
00566
00567      //
00568      // get the dacl
00569      //
00570      DumpDacl(psd, c, TRUE);
00571
00572      //
00573      // get the sacl
00574      //
00575      DumpDacl(psd, c, FALSE);
00576 }
00577
00578 void DumpSDInfo(PSECURITY_DESCRIPTOR psd)
00579 {
00580      DWORD dwSDLength;
00581
00582      //
00583      // is the security descriptor valid
00584      //
00585      _tprintf(TEXT("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"));
00586      _tprintf(TEXT(">>          SECURITY DESCRIPTOR INFORMATION            >>\n"));
00587      _tprintf(TEXT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nvalid .............. "));
00588
00589      if (!IsValidSecurityDescriptor(psd)){
00590           _tprintf(TEXT("no\n"));
00591           return;
00592      }
00593      else
00594           _tprintf(TEXT("yes\n"));
00595
00596      //
00597      // security descriptor size???
00598      //
00599      dwSDLength = GetSecurityDescriptorLength(psd);
00600
00601      _tprintf(TEXT("length ............. %u byte(s)\n"), dwSDLength);
00602 }
00603
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Wepcode.c Source File

  • Multimedia
  • Gdi
  • WinCap32

Wepcode.c

Go to the documentation of this file.
00001 // -----------------------------------------------------------------
00002 // File name:  WEPCODE.C
00003 //
00004 // This is the source file that contains the DLL's Windows Exit
00005 // Procedure (WEP).
00006 //
00007 // Description of functions:
00008 //
00009 //    WEP         -     The Windows Exit Procedure.  Every DLL must have
00010 //                      one of these.
00011 //
00012 //
00013 // Written by Microsoft Product Support Services, Windows Developer Support.
00014 //
00015 // Copyright 1991 - 2000 Microsoft Corporation.  All rights reserved.
00016 // -----------------------------------------------------------------
00017
00018 #define     STRICT      // enable strict type checking
00019
00020 #include <windows.h>
00021
00022 // -----------------------------------------------------------------
00023 //
00024 // WEP()
00025 //
00026 // Purpose:  Called by Windows just before Windows unloads the DLL.
00027 //
00028 // Parameters:  int  nParameter     -  This is a dummy parameter.
00029 //                                     Windows expects this parameter
00030 //                                     so be sure to include it.
00031 //
00032 // Return Value:  Always returns 1 to indicate success.
00033 //
00034 // Comments:  Every DLL MUST have a WEP.  WEP, as defined here, is the
00035 //            proper way to define a WEP; do not do anything else
00036 //            except return 1 because the WEP is called on the Windows
00037 //            Kernel's stack, which is very small.
00038 //
00039 // -----------------------------------------------------------------
00040
00041
00042 int APIENTRY WEP (int nParameter)
00043 {
00044     return (1);
00045 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCapMFCDlg Member List

This is the complete list of members for CCapMFCDlg, including all inherited members.
CCapMFCDlg(CWnd *pParent=NULL) | CCapMFCDlg |
DoDataExchange(CDataExchange *pDX) | CCapMFCDlg | [protected, virtual]
IDD enum value | CCapMFCDlg |
LoadCharacter(CString pszFilename) | CCapMFCDlg | [private]
m_Agent | CCapMFCDlg |
m_Animations | CCapMFCDlg |
m_AnimationsLabel | CCapMFCDlg |
m_BalloonAutoHide | CCapMFCDlg |
m_BalloonAutoPace | CCapMFCDlg |
m_BalloonEnabled | CCapMFCDlg |
m_BalloonSizeToText | CCapMFCDlg |
m_bHasMRUSeparator | CCapMFCDlg | [private]
m_hIcon | CCapMFCDlg | [protected]
m_Move | CCapMFCDlg |
m_MoveX | CCapMFCDlg |
m_MoveY | CCapMFCDlg |
m_Play | CCapMFCDlg |
m_PositionLabel | CCapMFCDlg |
m_pszCurCharID | CCapMFCDlg | [private]
m_Sfx | CCapMFCDlg |
m_Speak | CCapMFCDlg |
m_SpeakText | CCapMFCDlg |
m_SpeechOutputLabel | CCapMFCDlg |
m_Stop | CCapMFCDlg |
m_StopBeforePlay | CCapMFCDlg |
m_XLabel | CCapMFCDlg |
m_YLabel | CCapMFCDlg |
MakeEllipsisPath(LPCTSTR pszPath, LPTSTR pszEllipsisPath, UINT cchMaxEllipsisPath) | CCapMFCDlg | [private]
OnActivateApp(BOOL bActive, DWORD hTask) | CCapMFCDlg | [protected]
OnAgentPropertyChange() | CCapMFCDlg | [protected]
OnBalloonUse() | CCapMFCDlg | [protected]
OnChangeSpeakText() | CCapMFCDlg | [protected]
OnCommand(WPARAM wParam, LPARAM lParam) | CCapMFCDlg | [protected, virtual]
OnCommandAgent(LPDISPATCH UserInput) | CCapMFCDlg | [protected]
OnDblclkAnimations() | CCapMFCDlg | [protected]
OnDropFiles(HDROP hDropInfo) | CCapMFCDlg | [protected]
OnFileExit() | CCapMFCDlg | [protected]
OnFileOpen() | CCapMFCDlg | [protected]
OnFinalRelease() | CCapMFCDlg | [virtual]
OnHelpAbout() | CCapMFCDlg | [protected]
OnInitDialog() | CCapMFCDlg | [protected, virtual]
OnInitMenuPopup(CMenu *pPopupMenu, UINT uIndex, BOOL bSysMenu) | CCapMFCDlg | [protected]
OnMove() | CCapMFCDlg | [protected]
OnMoveAgent(LPCTSTR CharacterID, short x, short y, short Cause) | CCapMFCDlg | [protected]
OnPaint() | CCapMFCDlg | [protected]
OnPlay() | CCapMFCDlg | [protected]
OnQueryDragIcon() | CCapMFCDlg | [protected]
OnRecentFile(UINT uFile) | CCapMFCDlg | [private]
OnSetFocusAnimations() | CCapMFCDlg | [protected]
OnSetFocusMoveX() | CCapMFCDlg | [protected]
OnSetFocusMoveY() | CCapMFCDlg | [protected]
OnSetFocusSpeakText() | CCapMFCDlg | [protected]
OnSfx() | CCapMFCDlg | [protected]
OnSpeak() | CCapMFCDlg | [protected]
OnStop() | CCapMFCDlg | [protected]
OnSysCommand(UINT nID, LPARAM lParam) | CCapMFCDlg | [protected]
UpdateRecentFiles(LPCTSTR pszFilename) | CCapMFCDlg | [private]
Generated on Wed Nov 13 2024 16:55:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CShellFolder Member List

This is the complete list of members for CShellFolder, including all inherited members.
AddFolder(LPCTSTR, LPITEMIDLIST *) | CShellFolder | [private]
AddItem(LPCTSTR, LPCTSTR, LPITEMIDLIST *) | CShellFolder | [private]
BindToObject(LPCITEMIDLIST, LPBC, REFIID, LPVOID *) | CShellFolder |
BindToStorage(LPCITEMIDLIST, LPBC, REFIID, LPVOID *) | CShellFolder |
CContextMenu class | CShellFolder | [friend]
CDataObject class | CShellFolder | [friend]
CDropTarget class | CShellFolder | [friend]
CompareIDs(LPARAM, LPCITEMIDLIST, LPCITEMIDLIST) | CShellFolder |
CompareItems(LPCITEMIDLIST, LPCITEMIDLIST) | CShellFolder | [private]
CopyItems(CShellFolder *, LPITEMIDLIST *, UINT) | CShellFolder | [private]
CreateFQPidl(LPCITEMIDLIST) | CShellFolder | [private]
CreateViewObject(HWND, REFIID, LPVOID *) | CShellFolder |
CShellFolder(CShellFolder *pParent=NULL, LPCITEMIDLIST pidl=NULL) | CShellFolder |
CShellView class | CShellFolder | [friend]
DeleteItems(LPITEMIDLIST *, UINT) | CShellFolder | [private]
EnumObjects(HWND, DWORD, LPENUMIDLIST *) | CShellFolder |
GetAttributesOf(UINT, LPCITEMIDLIST *, LPDWORD) | CShellFolder |
GetClassID(LPCLSID) | CShellFolder |
GetDisplayNameOf(LPCITEMIDLIST, DWORD, LPSTRRET) | CShellFolder |
GetFullName(LPCITEMIDLIST, LPTSTR, DWORD, DWORD) | CShellFolder | [private]
GetPath(LPCITEMIDLIST, LPTSTR, DWORD) | CShellFolder | [private]
GetUIObjectOf(HWND, UINT, LPCITEMIDLIST *, REFIID, LPUINT, LPVOID *) | CShellFolder |
GetUniqueName(BOOL, LPTSTR, DWORD) | CShellFolder | [private]
HasSubFolder(LPCITEMIDLIST) | CShellFolder | [private]
Initialize(LPCITEMIDLIST) | CShellFolder |
m_ObjRefCount | CShellFolder | [private]
m_pidlFQ | CShellFolder | [private]
m_pidlRel | CShellFolder | [private]
m_pMalloc | CShellFolder | [private]
m_pPidlMgr | CShellFolder | [private]
m_psfParent | CShellFolder | [private]
NotifyViews(DWORD, LPCITEMIDLIST, LPCITEMIDLIST) | CShellFolder | [private]
ParseDisplayName(HWND, LPBC, LPOLESTR, LPDWORD, LPITEMIDLIST *, LPDWORD) | CShellFolder |
QueryInterface(REFIID riid, LPVOID *ppvObj) | CShellFolder |
SetItemData(LPCITEMIDLIST, LPCTSTR) | CShellFolder | [private]
SetNameOf(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST *) | CShellFolder |
STDMETHOD_(ULONG, AddRef)(VOID) | CShellFolder |
STDMETHOD_(ULONG, Release)(VOID) | CShellFolder |
~CShellFolder() | CShellFolder |
Generated on Wed Nov 13 2024 16:57:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/AffectEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

AffectEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: AffectEnum
00019
00020 public class AffectEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adAffectCurrent = 1;
00023   public static final short adAffectGroup = 2;
00024   public static final short adAffectAll = 3;
00025   public static final short adAffectAllChapters = 4;
00026 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/space.Cpp Source File

  • SysMgmt
  • MMC
  • Openserv

space.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include <windows.h>
00021 #include "Space.h"
00022 #include "Comp.h"
00023 #include "resource.h"
00024 #define STRSAFE_NO_DEPRECATE
00025 #include <strsafe.h>
00026
00027 const GUID CSpaceVehicle::thisGuid = { 0x29743810, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00028 const GUID CRocket::thisGuid = { 0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00029
00030 //==============================================================
00031 //
00032 // CSpaceVehicle implementation
00033 //
00034 //
00035 CSpaceVehicle::CSpaceVehicle()
00036 {
00037     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00038         children[n] = new CRocket(_T("Rocket"), n+1, 500000, 265, 75000);
00039     }
00040 }
00041
00042 CSpaceVehicle::~CSpaceVehicle()
00043 {
00044     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00045         if (children[n]) {
00046             delete children[n];
00047         }
00048 }
00049
00050 HRESULT CSpaceVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00051 {
00052     HRESULT      hr = S_OK;
00053
00054     IHeaderCtrl *pHeaderCtrl = NULL;
00055     IResultData *pResultData = NULL;
00056
00057     if (bShow) {
00058         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00059         _ASSERT( SUCCEEDED(hr) );
00060
00061         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00062         _ASSERT( SUCCEEDED(hr) );
00063
00064         // Set the column headers in the results pane
00065         hr = pHeaderCtrl->InsertColumn( 0, L"Rocket Class", 0, MMCLV_AUTO );
00066         _ASSERT( S_OK == hr );
00067         hr = pHeaderCtrl->InsertColumn( 1, L"Rocket Weight", 0, MMCLV_AUTO );
00068         _ASSERT( S_OK == hr );
00069         hr = pHeaderCtrl->InsertColumn( 2, L"Rocket Height", 0, MMCLV_AUTO );
00070         _ASSERT( S_OK == hr );
00071         hr = pHeaderCtrl->InsertColumn( 3, L"Rocket Payload", 0, MMCLV_AUTO );
00072         _ASSERT( S_OK == hr );
00073         hr = pHeaderCtrl->InsertColumn( 4, L"Status", 0, MMCLV_AUTO );
00074         _ASSERT( S_OK == hr );
00075
00076         // insert items here
00077         RESULTDATAITEM rdi;
00078
00079         hr = pResultData->DeleteAllRsltItems();
00080         _ASSERT( SUCCEEDED(hr) );
00081
00082         if (!bExpanded) {
00083             // create the child nodes, then expand them
00084             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00085                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00086                 rdi.mask       = RDI_STR       |   // Displayname is valid
00087                     RDI_IMAGE     |
00088                     RDI_PARAM;        // nImage is valid
00089
00090                 rdi.nImage      = children[n]->GetBitmapIndex();
00091                 rdi.str         = MMC_CALLBACK;
00092                 rdi.nCol        = 0;
00093                 rdi.lParam      = (LPARAM)children[n];
00094
00095                 hr = pResultData->InsertItem( &rdi );
00096
00097                 children[n]->SetHandle((HANDLE)rdi.itemID);
00098
00099                 _ASSERT( SUCCEEDED(hr) );
00100             }
00101         }
00102
00103         pHeaderCtrl->Release();
00104         pResultData->Release();
00105     }
00106
00107     return hr;
00108 }
00109
00110 //==============================================================
00111 //
00112 // CRocket implementation
00113 //
00114 //
00115 CRocket::CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload)
00116 : szName(NULL), lWeight(0), lHeight(0), lPayload(0), iStatus(STOPPED)
00117 {
00118     if (szName) {
00119         this->szName = new _TCHAR[(_tcslen(szName) + 1) * sizeof(_TCHAR)];
00120         _tcscpy(this->szName, szName);
00121     }
00122
00123     this->nId = id;
00124     this->lWeight = lWeight;
00125     this->lHeight = lHeight;
00126     this->lPayload = lPayload;
00127 }
00128
00129 CRocket::~CRocket()
00130 {
00131     if (szName)
00132         delete [] szName;
00133 }
00134
00135 const _TCHAR *CRocket::GetDisplayName(int nCol)
00136 {
00137     const size_t cchBuffer = 128;
00138     static _TCHAR buf[cchBuffer];
00139
00140     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00141     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00142
00143     switch (nCol) {
00144     case 0:
00145         StringCchPrintf(buf, cchBuffer, _T("%s (#%d)"), szName ? szName : _T(""), nId);
00146         break;
00147
00148     case 1:
00149         StringCchPrintf(buf, cchBuffer, _T("%ld metric tons"), lWeight);
00150         break;
00151
00152     case 2:
00153         StringCchPrintf(buf, cchBuffer, _T("%ld meters"), lHeight);
00154         break;
00155
00156     case 3:
00157         StringCchPrintf(buf, cchBuffer, _T("%ld kilos"), lPayload);
00158         break;
00159
00160     case 4:
00161         StringCchPrintf(buf, cchBuffer, _T("%s"),
00162             iStatus == RUNNING ? _T("running") :
00163         iStatus == PAUSED ? _T("paused") :
00164         iStatus == STOPPED ? _T("stopped") : _T("unknown"));
00165         break;
00166
00167     }
00168
00169     return buf;
00170 }
00171
00172 HRESULT CRocket::OnRename(LPOLESTR pszNewName)
00173 {
00174     if (szName) {
00175         delete [] szName;
00176         szName = NULL;
00177     }
00178
00179     MAKE_TSTRPTR_FROMWIDE(ptrname, pszNewName);
00180     szName = new _TCHAR[(_tcslen(ptrname) + 1) * sizeof(_TCHAR)];
00181     _tcscpy(szName, ptrname);
00182
00183     return S_OK;
00184 }
00185
00186 HRESULT CRocket::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
00187 {
00188     IConsoleVerb *pConsoleVerb;
00189
00190     HRESULT hr = pConsole->QueryConsoleVerb(&pConsoleVerb);
00191     _ASSERT(SUCCEEDED(hr));
00192
00193     hr = pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, TRUE);
00194     hr = pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
00195
00196     pConsoleVerb->Release();
00197
00198     return S_OK;
00199 }
00200
00201 BOOL CALLBACK CRocket::DialogProc(
00202                                   HWND hwndDlg,  // handle to dialog box
00203                                   UINT uMsg,     // message
00204                                   WPARAM wParam, // first message parameter
00205                                   LPARAM lParam  // second message parameter
00206                                   )
00207 {
00208     static CRocket *pRocket = NULL;
00209
00210     switch (uMsg) {
00211     case WM_INITDIALOG:
00212         pRocket = reinterpret_cast<CRocket *>(reinterpret_cast<PROPSHEETPAGE *>(lParam)->lParam);
00213
00214         SetDlgItemText(hwndDlg, IDC_ROCKET_NAME, pRocket->szName);
00215         SetDlgItemInt(hwndDlg, IDC_ROCKET_HEIGHT, pRocket->lHeight, FALSE);
00216         SetDlgItemInt(hwndDlg, IDC_ROCKET_WEIGHT, pRocket->lWeight, FALSE);
00217         SetDlgItemInt(hwndDlg, IDC_ROCKET_PAYLOAD, pRocket->lPayload, FALSE);
00218
00219         _ASSERT( CB_ERR != SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_INSERTSTRING, 0, (LPARAM)_T("Running")) );
00220         _ASSERT( CB_ERR != SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_INSERTSTRING, 1, (LPARAM)_T("Paused")) );
00221         _ASSERT( CB_ERR != SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_INSERTSTRING, 2, (LPARAM)_T("Stopped")) );
00222
00223         SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_SETCURSEL, (WPARAM)pRocket->iStatus, 0);
00224
00225         break;
00226
00227     case WM_COMMAND:
00228         if (HIWORD(wParam) == EN_CHANGE ||
00229             HIWORD(wParam) == CBN_SELCHANGE)
00230             SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
00231         break;
00232
00233     case WM_NOTIFY:
00234         switch (((NMHDR *) lParam)->code) {
00235         case PSN_APPLY:
00236             if (pRocket->szName) {
00237                 delete [] pRocket->szName;
00238                 pRocket->szName = NULL;
00239             }
00240
00241             {
00242                 int n = SendDlgItemMessage(hwndDlg, IDC_ROCKET_NAME, WM_GETTEXTLENGTH, 0, 0);
00243                 if (n != 0) {
00244                     pRocket->szName = new _TCHAR[n + 1];
00245                     GetDlgItemText(hwndDlg, IDC_ROCKET_NAME, pRocket->szName, n + 1);
00246                 }
00247             }
00248             pRocket->lHeight = GetDlgItemInt(hwndDlg, IDC_ROCKET_HEIGHT, NULL, FALSE);
00249             pRocket->lWeight = GetDlgItemInt(hwndDlg, IDC_ROCKET_WEIGHT, NULL, FALSE);
00250             pRocket->lPayload = GetDlgItemInt(hwndDlg, IDC_ROCKET_PAYLOAD, NULL, FALSE);
00251
00252             pRocket->iStatus = (ROCKET_STATUS)SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_GETCURSEL, 0, 0);
00253
00254
00255             return PSNRET_NOERROR;
00256         }
00257         break;
00258     }
00259
00260     return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
00261 }
00262
00263
00264 HRESULT CRocket::HasPropertySheets()
00265 {
00266     return S_OK;
00267 }
00268
00269 HRESULT CRocket::CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle)
00270 {
00271     PROPSHEETPAGE psp;
00272     HPROPSHEETPAGE hPage = NULL;
00273
00274     psp.dwSize = sizeof(PROPSHEETPAGE);
00275     psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEICONID;
00276     psp.hInstance = g_hinst;
00277     psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE);
00278     psp.pfnDlgProc = DialogProc;
00279     psp.lParam = reinterpret_cast<LPARAM>(this);
00280     psp.pszTitle = MAKEINTRESOURCE(IDS_PST_ROCKET);
00281     psp.pszIcon = MAKEINTRESOURCE(IDI_PSI_ROCKET);
00282
00283     hPage = CreatePropertySheetPage(&psp);
00284     _ASSERT(hPage);
00285
00286     return lpProvider->AddPage(hPage);
00287 }
00288
00289 HRESULT CRocket::GetWatermarks(HBITMAP *lphWatermark,
00290                                HBITMAP *lphHeader,
00291                                HPALETTE *lphPalette,
00292                                BOOL *bStretch)
00293 {
00294     return S_FALSE;
00295 }
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMySink Member List

This is the complete list of members for CMySink, including all inherited members.
CMySink() | CMySink | [inline]
Indicate(long lObjectCount, IWbemClassObject __RPC_FAR *__RPC_FAR *ppObjArray) | CMySink | [virtual]
m_cRef | CMySink | [private]
QueryInterface(REFIID, LPVOID *) | CMySink |
SetStatus(long lFlags, HRESULT hResult, BSTR strParam, IWbemClassObject __RPC_FAR *pObjParam) | CMySink | [virtual]
STDMETHODIMP_(ULONG) AddRef(void) | CMySink |
STDMETHODIMP_(ULONG) Release(void) | CMySink |
~CMySink() | CMySink | [inline]
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step1/ADsFirstExt.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step1

ADsFirstExt.cpp

Go to the documentation of this file.
00001 // ADsFirstExt.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "ADsFirstExt.h"
00012
00013 #include "ADsFirstExt_i.c"
00014 #include "HelloWorld.h"
00015
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP(ObjectMap)
00020 OBJECT_ENTRY(CLSID_HelloWorld, HelloWorld)
00021 END_OBJECT_MAP()
00022
00023 class CADsFirstExtApp : public CWinApp
00024 {
00025 public:
00026
00027 // Overrides
00028   // ClassWizard generated virtual function overrides
00029   //{{AFX_VIRTUAL(CADsFirstExtApp)
00030   public:
00031     virtual BOOL InitInstance();
00032     virtual int ExitInstance();
00033   //}}AFX_VIRTUAL
00034
00035   //{{AFX_MSG(CADsFirstExtApp)
00036     // NOTE - the ClassWizard will add and remove member functions here.
00037     //    DO NOT EDIT what you see in these blocks of generated code !
00038   //}}AFX_MSG
00039   DECLARE_MESSAGE_MAP()
00040 };
00041
00042
00043 STDAPI RegisterADsExt(void);
00044 STDAPI UnRegisterADsExt(void);
00045
00046 BEGIN_MESSAGE_MAP(CADsFirstExtApp, CWinApp)
00047   //{{AFX_MSG_MAP(CADsFirstExtApp)
00048     // NOTE - the ClassWizard will add and remove mapping macros here.
00049     //    DO NOT EDIT what you see in these blocks of generated code!
00050   //}}AFX_MSG_MAP
00051 END_MESSAGE_MAP()
00052
00053 CADsFirstExtApp theApp;
00054
00055 BOOL CADsFirstExtApp::InitInstance()
00056 {
00057     _Module.Init(ObjectMap, m_hInstance, &LIBID_ADSFIRSTEXTLib);
00058     return CWinApp::InitInstance();
00059 }
00060
00061 int CADsFirstExtApp::ExitInstance()
00062 {
00063     _Module.Term();
00064     return CWinApp::ExitInstance();
00065 }
00066
00067 /////////////////////////////////////////////////////////////////////////////
00068 // Used to determine whether the DLL can be unloaded by OLE
00069
00070 STDAPI DllCanUnloadNow(void)
00071 {
00072     AFX_MANAGE_STATE(AfxGetStaticModuleState());
00073     return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
00074 }
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // Returns a class factory to create an object of the requested type
00078
00079 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00080 {
00081     return _Module.GetClassObject(rclsid, riid, ppv);
00082 }
00083
00084 /////////////////////////////////////////////////////////////////////////////
00085 // DllRegisterServer - Adds entries to the system registry
00086
00087 STDAPI DllRegisterServer(void)
00088 {
00089     // registers object, typelib and all interfaces in typelib
00090   if ( SUCCEEDED(_Module.RegisterServer(TRUE) ) )
00091   {
00092          return RegisterADsExt();
00093   }
00094     return E_FAIL;
00095 }
00096
00097 /////////////////////////////////////////////////////////////////////////////
00098 // DllUnregisterServer - Removes entries from the system registry
00099
00100 STDAPI DllUnregisterServer(void)
00101 {
00102   UnRegisterADsExt();
00103     return _Module.UnregisterServer(TRUE);
00104 }
00105
00106 STDAPI RegisterADsExt(void)
00107 {
00108   HRESULT hr;
00109   HKEY hKey;
00110   DWORD dwDisposition;
00111
00112
00113   hr = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00114                      _T("SOFTWARE\\Microsoft\\ADs\\Providers\\LDAP\\Extensions\\User\\{E1E3EDF8-48D1-11D2-B22B-0000F87A6B50}"),
00115              0,
00116              NULL,
00117              REG_OPTION_NON_VOLATILE,
00118              KEY_WRITE,
00119              NULL,
00120              &hKey,
00121              &dwDisposition );
00122
00123   if ( !SUCCEEDED(hr) )
00124   {
00125     return hr;
00126   }
00127
00128
00129   ///////////////////////////////////////////
00130   // Interface
00131   ////////////////////////////////////////////
00132   const wchar_t szIf[] = L"{E1E3EDF7-48D1-11D2-B22B-0000F87A6B50}\0\0";
00133
00134
00135   hr = RegSetValueEx( hKey, _T("Interfaces"), 0, REG_BINARY, (const BYTE *) szIf, sizeof(szIf));
00136
00137
00138
00139   RegCloseKey(hKey);
00140
00141   return hr;
00142 }
00143
00144
00145 STDAPI UnRegisterADsExt(void)
00146 {
00147
00148   LONG lResult;
00149   lResult = RegDeleteKey(  HKEY_LOCAL_MACHINE,
00150     _T("SOFTWARE\\Microsoft\\ADs\\Providers\\LDAP\\Extensions\\User\\{E1E3EDF8-48D1-11D2-B22B-0000F87A6B50}") );
00151
00152   if ( lResult == ERROR_SUCCESS )
00153   {
00154     return S_OK;
00155
00156   }
00157
00158     return E_FAIL;
00159 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/SIndexedDisk.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

SIndexedDisk.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      SIndexedDisk.cpp
00005 //
00006 //  Description:
00007 //      This file contains the definition of the SIndexedDisk class.
00008 //
00009 //      The SIndexedDisk structure associates a pointer to a disk object with
00010 //      the disk object's Index property.
00011 //
00012 //  Header File:
00013 //      SIndexedDisk.h
00014 //
00015 //////////////////////////////////////////////////////////////////////////////
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Include Files
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 #include "stdafx.h"
00022 #include "SIndexedDisk.h"
00023
00024 //****************************************************************************
00025 //
00026 // SIndexedDisk class
00027 //
00028 //****************************************************************************
00029
00030
00031 //////////////////////////////////////////////////////////////////////////////
00032 //++
00033 //
00034 //  SIndexedDisk::HrInit
00035 //
00036 //  Description:
00037 //      Initialize this instance from a disk object; punkDiskIn must
00038 //      support the IStorageProperties interface.
00039 //
00040 //  Arguments:
00041 //      punkDiskIn
00042 //          The disk object for initialization.
00043 //
00044 //  Return Values:
00045 //      S_OK
00046 //          Success.
00047 //
00048 //      Other
00049 //          An error occurred.
00050 //
00051 //--
00052 //////////////////////////////////////////////////////////////////////////////
00053 HRESULT
00054 SIndexedDisk::HrInit(
00055     IUnknown * punkDiskIn
00056     )
00057 {
00058     HRESULT                 hr = S_OK;
00059     IStorageProperties *    pisdp = NULL;
00060
00061     if ( punkDiskIn == NULL )
00062     {
00063         hr = E_POINTER;
00064         goto Cleanup;
00065     }
00066
00067     //
00068     // QI for IStorageProperties.
00069     //
00070
00071     hr = punkDiskIn->TypeSafeQI( IStorageProperties, &pisdp );
00072
00073     if ( FAILED( hr ) )
00074     {
00075         goto Cleanup;
00076     }
00077
00078     //
00079     // Get index from IStorageProperties.
00080     //
00081
00082     hr = pisdp->HrGetDeviceIndex( &idxDisk );
00083
00084     if ( FAILED( hr ) )
00085     {
00086         goto Cleanup;
00087     }
00088
00089     punkDisk = punkDiskIn;
00090
00091 Cleanup:
00092
00093     if ( pisdp != NULL )
00094     {
00095         pisdp->Release();
00096     }
00097
00098     return hr;
00099
00100 } //*** SIndexedDisk::HrInit
00101
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

TPropBase< TYPE > Member List

This is the complete list of members for TPropBase< TYPE >, including all inherited members.
AddElement(TYPE element) | CVector< TYPE > | [virtual]
AddProperty(DBPROPID dwPropertyID, const DBID &colid) | TPropBase< TYPE > | [virtual]
Attach(CVector &rVector) | CVector< TYPE > | [virtual]
Attach(ULONGcElements, TYPE *rgElements) | CVector< TYPE > | [virtual]
CVector(ULONGulLowerBound=0, ULONGulGrowSize=10) | CVector< TYPE > |
Detach(ULONG *pcElements, TYPE **prgElements) | CVector< TYPE > | [virtual]
FindProperty(DBPROPID dwPropertyID, const DBID &colid)=0 | TPropBase< TYPE > | [pure virtual]
GetCount() | CVector< TYPE > | [inline, virtual]
GetElement(ULONGiIndex) | CVector< TYPE > | [virtual]
GetElements() const | CVector< TYPE > | [inline, virtual]
GetProperties() | TPropBase< TYPE > | [inline, virtual]
InsertAt(ULONGiIndex, TYPE element) | CVector< TYPE > | [virtual]
m_cElements | CVector< TYPE > | [protected]
m_rgElements | CVector< TYPE > | [protected]
m_ulGrowSize | CVector< TYPE > | [protected]
m_ulLowerBound | CVector< TYPE > | [protected]
m_ulMaxSize | CVector< TYPE > | [protected]
operator[](ULONGiIndex) | CVector< TYPE > | [inline, virtual]
RemoveAll() | CVector< TYPE > | [virtual]
RemoveAt(ULONGiIndex) | CVector< TYPE > | [virtual]
TPropBase(ULONG cElements=0, TYPE *rgElements=NULL) | TPropBase< TYPE > |
~CVector() | CVector< TYPE > | [virtual]
~TPropBase() | TPropBase< TYPE > | [virtual]
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/Resource.h Source File

  • Com
  • Services
  • Concurrency
  • SyncComp

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by SyncComp.rc
00004 //
00005 #define STA_OFFSET                      0
00006 #define FREE_OFFSET                     1
00007 #define COMSYNC_OFFSET                  2
00008 #define IDS_PROJNAME                    100
00009 #define IDR_Test1                       100
00010 #define IDD_MAIN                        101
00011 #define IDC_RADIO_BASE                  201
00012 #define IDC_RADIO_STA                   201
00013 #define IDC_RADIO_FREE                  202
00014 #define IDC_RADIO_COMSYNC               203
00015 #define IDC_THREADCOUNT                 204
00016 #define IDC_ITERCOUNT                   205
00017 #define IDC_ITERTOTAL                   206
00018 #define IDC_START                       207
00019 #define IDC_MAXTIMEBASE                 208
00020 #define IDC_MAXTIME1                    208
00021 #define IDC_MAXTIME2                    209
00022 #define IDC_MAXTIME3                    210
00023 #define IDC_MINTIMEBASE                 211
00024 #define IDC_MINTIME1                    211
00025 #define IDC_MINTIME2                    212
00026 #define IDC_MINTIME3                    213
00027 #define IDC_AVGTIMEBASE                 214
00028 #define IDC_AVGTIME1                    214
00029 #define IDC_AVGTIME2                    215
00030 #define IDC_AVGTIME3                    216
00031 #define IDC_THREADRUNNING               217
00032
00033 // Next default values for new objects
00034 //
00035 #ifdef APSTUDIO_INVOKED
00036 #ifndef APSTUDIO_READONLY_SYMBOLS
00037 #define _APS_NEXT_RESOURCE_VALUE        202
00038 #define _APS_NEXT_COMMAND_VALUE         32768
00039 #define _APS_NEXT_CONTROL_VALUE         217
00040 #define _APS_NEXT_SYMED_VALUE           102
00041 #endif
00042 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/getIcon.c Source File

  • Com
  • Fundamentals
  • OleStd

getIcon.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 ** The following API's are now OBSOLETE because equivalent API's have been
00004 ** added to the OLE2.DLL library
00005 **      GetIconOfFile       superceeded by OleGetIconOfFile
00006 **      GetIconOfClass      superceeded by OleGetIconOfClass
00007 **      OleUIMetafilePictFromIconAndLabel
00008 **                          superceeded by OleMetafilePictFromIconAndLabel
00009 *************************************************************************/
00010
00011 /*
00012  *  GETICON.C
00013  *
00014  *  Functions to create DVASPECT_ICON metafile from filename or classname.
00015  *
00016  *  GetIconOfFile
00017  *  GetIconOfClass
00018  *  OleUIMetafilePictFromIconAndLabel
00019  *  HIconAndSourceFromClass Extracts the first icon in a class's server path
00020  *                          and returns the path and icon index to caller.
00021  *  FIconFileFromClass      Retrieves the path to the exe/dll containing the
00022  *                           default icon, and the index of the icon.
00023  *  OleStdIconLabelTextOut  Draw icon label text (line break if necessary)
00024  *
00025  *    (c) Copyright Microsoft Corp. 1992 - 2000 All Rights Reserved
00026  */
00027
00028
00029 /*******
00030  *
00031  * ICON (DVASPECT_ICON) METAFILE FORMAT:
00032  *
00033  * The metafile generated with OleUIMetafilePictFromIconAndLabel contains
00034  * the following records which are used by the functions in DRAWICON.C
00035  * to draw the icon with and without the label and to extract the icon,
00036  * label, and icon source/index.
00037  *
00038  *  SetWindowOrg
00039  *  SetWindowExt
00040  *  DrawIcon:
00041  *      Inserts records of DIBBITBLT or DIBSTRETCHBLT, once for the
00042  *      AND mask, one for the image bits.
00043  *  Escape with the comment "IconOnly"
00044  *      This indicates where to stop record enumeration to draw only
00045  *      the icon.
00046  *  SetTextColor
00047  *  SetTextAlign
00048  *  SetBkColor
00049  *  CreateFont
00050  *  SelectObject on the font.
00051  *  ExtTextOut
00052  *      One or more ExtTextOuts occur if the label is wrapped.  The
00053  *      text in these records is used to extract the label.
00054  *  SelectObject on the old font.
00055  *  DeleteObject on the font.
00056  *  Escape with a comment that contains the path to the icon source.
00057  *  Escape with a comment that is the ASCII of the icon index.
00058  *
00059  *******/
00060
00061 #define STRICT  1
00062 #include "olestd.h"
00063
00064 #include <stdlib.h>
00065 #include <string.h>
00066 #include <ctype.h>
00067 #include <commdlg.h>
00068 #include <memory.h>
00069 #include <cderr.h>
00070 #include "common.h"
00071 #include "utility.h"
00072
00073 static char szSeparators[] = " \t\\/!:";
00074
00075 #define IS_SEPARATOR(c)         ( (c) == ' ' || (c) == '\\' || (c) == '/' || (c) == '\t' || (c) == '!' || (c) == ':' )
00076 #define IS_FILENAME_DELIM(c)    ( (c) == '\\' || (c) == '/' || (c) == ':' )
00077
00078
00079 #if defined( OBSOLETE )
00080 static HINSTANCE  s_hInst;
00081
00082 static char szMaxWidth[] ="WWWWWWWWWW";
00083
00084 //Strings for metafile comments.
00085 static OLECHAR szIconOnly[]= OLESTR("IconOnly");        //Where to stop to exclude label.
00086
00087
00088 static char szOLE2DLL[] = "ole2.dll";   // name of OLE 2.0 library
00089
00090 #define ICONINDEX              0
00091
00092 #define AUXUSERTYPE_SHORTNAME  USERCLASSTYPE_SHORT  // short name
00093 #define HIMETRIC_PER_INCH   2540      // number HIMETRIC units per inch
00094 #define PTS_PER_INCH          72      // number points (font size) per inch
00095
00096 #define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
00097 #define MAP_LOGHIM_TO_PIX(x,ppli)   MulDiv((ppli), (x), HIMETRIC_PER_INCH)
00098
00099 static char szVanillaDocIcon[] = "DefIcon";
00100
00101 static char szDocument[40] = "";
00102
00103
00104 /*
00105  * GetIconOfFile(HINSTANCE hInst, LPSTR lpszPath, BOOL fUseFileAsLabel)
00106  *
00107  * Purpose:
00108  *  Returns a hMetaPict containing an icon and label (filename) for the
00109  *  specified filename.
00110  *
00111  * Parameters:
00112  *  hinst
00113  *  lpszPath        LPSTR path including filename to use
00114  *  fUseFileAsLabel BOOL TRUE if the icon's label is the filename, FALSE if
00115  *                  there should be no label.
00116  *
00117  * Return Value:
00118  *  HGLOBAL         hMetaPict containing the icon and label - if there's no
00119  *                  class in reg db for the file in lpszPath, then we use
00120  *                  Document.  If lpszPath is NULL, then we return NULL.
00121  */
00122
00123 STDAPI_(HGLOBAL) GetIconOfFile(HINSTANCE hInst, LPSTR lpszPath, BOOL fUseFileAsLabel)
00124 {
00125   char     szIconFile[OLEUI_CCHPATHMAX];
00126   char     szLabel[OLEUI_CCHLABELMAX];
00127   LPSTR    lpszClsid = NULL;
00128   CLSID    clsid;
00129   HICON    hDefIcon = NULL;
00130   UINT     IconIndex = 0;
00131   HGLOBAL  hMetaPict;
00132   HRESULT  hResult;
00133
00134   if (NULL == lpszPath)  // even if fUseFileAsLabel is FALSE, we still
00135    return NULL;             // need a valid filename to get the class.
00136
00137   s_hInst = hInst;
00138
00139   hResult = GetClassFile(lpszPath, &clsid);
00140
00141   if (NOERROR == hResult)  // use the clsid we got to get to the icon
00142   {
00143      hDefIcon = HIconAndSourceFromClass(&clsid,
00144                                szIconFile,
00145                                &IconIndex);
00146   }
00147
00148   if ( (NOERROR != hResult) || (NULL == hDefIcon) )
00149   {
00150     // Here, either GetClassFile failed or HIconAndSourceFromClass failed.
00151
00152     LPSTR lpszTemp;
00153
00154     lpszTemp = lpszPath;
00155
00156     while ((*lpszTemp != '.') && (*lpszTemp != '\0'))
00157       lpszTemp++;
00158
00159
00160     if ('.' != *lpszTemp)
00161       goto UseVanillaDocument;
00162
00163
00164     if (FALSE == GetAssociatedExecutable(lpszTemp, szIconFile))
00165       goto UseVanillaDocument;
00166
00167     hDefIcon = ExtractIcon(s_hInst, szIconFile, IconIndex);
00168   }
00169
00170   if (hDefIcon <= (HICON)1) // ExtractIcon returns 1 if szExecutable is not exe,
00171   {                         // 0 if there are no icons.
00172 UseVanillaDocument:
00173
00174    OLESTRCPY(szIconFile, szOLE2DLL);
00175    IconIndex = ICONINDEX;
00176    hDefIcon = ExtractIcon(s_hInst, szIconFile, IconIndex);
00177
00178   }
00179
00180   // Now let's get the label we want to use.
00181
00182   if (fUseFileAsLabel)   // strip off path, so we just have the filename.
00183   {
00184     int istrlen;
00185     LPSTR lpszBeginFile;
00186
00187     istrlen = lstrlen(lpszPath);
00188
00189     // set pointer to END of path, so we can walk backwards through it.
00190     lpszBeginFile = lpszPath + istrlen -1;
00191
00192     while ( (lpszBeginFile >= lpszPath)
00193           && (!IS_FILENAME_DELIM(*lpszBeginFile)) )
00194      lpszBeginFile--;
00195
00196
00197     lpszBeginFile++;  // step back over the delimiter
00198
00199
00200     LSTRCPYN(szLabel, lpszBeginFile, OLEUI_CCHLABELMAX);
00201   }
00202
00203   else   // use the short user type (AuxUserType2) for the label
00204   {
00205
00206      if (0 == OleStdGetAuxUserType(&clsid, AUXUSERTYPE_SHORTNAME,
00207                            szLabel, OLEUI_CCHLABELMAX, NULL)) {
00208
00209        if ('\0'==szDocument[0]) {
00210           LoadString(
00211              s_hInst,IDS_DEFICONLABEL,szDocument,sizeof(szDocument));
00212        }
00213        lstrcpy(szLabel, szDocument);
00214      }
00215   }
00216
00217
00218   hMetaPict = OleUIMetafilePictFromIconAndLabel(hDefIcon,
00219                                     szLabel,
00220                                     szIconFile,
00221                                     IconIndex);
00222
00223   DestroyIcon(hDefIcon);
00224
00225   return hMetaPict;
00226
00227 }
00228
00229
00230 /*
00231  * GetIconOfClass(HINSTANCE hInst, REFCLSID rclsid, LPSTR lpszLabel, BOOL fUseTypeAsLabel)
00232  *
00233  * Purpose:
00234  *  Returns a hMetaPict containing an icon and label (human-readable form
00235  *  of class) for the specified clsid.
00236  *
00237  * Parameters:
00238  *  hinst
00239  *  rclsid          REFCLSID pointing to clsid to use.
00240  *  lpszLabel       label to use for icon.
00241  *  fUseTypeAsLabel Use the clsid's user type name as the icon's label.
00242  *
00243  * Return Value:
00244  *  HGLOBAL         hMetaPict containing the icon and label - if we
00245  *                  don't find the clsid in the reg db then we
00246  *                  return NULL.
00247  */
00248
00249 STDAPI_(HGLOBAL)    GetIconOfClass(HINSTANCE hInst, REFCLSID rclsid, LPSTR lpszLabel, BOOL fUseTypeAsLabel)
00250 {
00251
00252   char    szLabel[OLEUI_CCHLABELMAX];
00253   char    szIconFile[OLEUI_CCHPATHMAX];
00254   HICON   hDefIcon;
00255   UINT    IconIndex;
00256   HGLOBAL hMetaPict;
00257
00258   s_hInst = hInst;
00259
00260   if (!fUseTypeAsLabel)  // Use string passed in as label
00261   {
00262    if (NULL != lpszLabel)
00263       LSTRCPYN(szLabel, lpszLabel, sizeof(szLabel));
00264    else
00265       *szLabel = '\0';
00266   }
00267   else   // Use AuxUserType2 (short name) as label
00268   {
00269
00270      if (0 == OleStdGetAuxUserType(rclsid,
00271                            AUXUSERTYPE_SHORTNAME,
00272                            szLabel,
00273                            OLEUI_CCHLABELMAX,
00274                            NULL))
00275
00276       // If we can't get the AuxUserType2, then try the long name
00277       if (0 == OleStdGetUserTypeOfClass(rclsid, szLabel, OLEUI_CCHKEYMAX, NULL)) {
00278        if ('\0'==szDocument[0]) {
00279           LoadString(
00280              s_hInst,IDS_DEFICONLABEL,szDocument,sizeof(szDocument));
00281        }
00282        lstrcpy(szLabel, szDocument);  // last resort
00283       }
00284   }
00285
00286   // Get the icon, icon index, and path to icon file
00287   hDefIcon = HIconAndSourceFromClass(rclsid,
00288               szIconFile,
00289               &IconIndex);
00290
00291   if (NULL == hDefIcon)  // Use Vanilla Document
00292   {
00293    OLESTRCPY(szIconFile, szOLE2DLL);
00294    IconIndex = ICONINDEX;
00295    hDefIcon = ExtractIcon(s_hInst, szIconFile, IconIndex);
00296   }
00297
00298   // Create the metafile
00299   hMetaPict = OleUIMetafilePictFromIconAndLabel(hDefIcon, szLabel,
00300                                     szIconFile, IconIndex);
00301
00302   DestroyIcon(hDefIcon);
00303
00304   return hMetaPict;
00305
00306 }
00307
00308
00309 /*
00310  * OleUIMetafilePictFromIconAndLabel
00311  *
00312  * Purpose:
00313  *  Creates a METAFILEPICT structure that container a metafile in which
00314  *  the icon and label are drawn.  A comment record is inserted between
00315  *  the icon and the label code so our special draw function can stop
00316  *  playing before the label.
00317  *
00318  * Parameters:
00319  *  hIcon           HICON to draw into the metafile
00320  *  pszLabel        LPSTR to the label string.
00321  *  pszSourceFile   LPSTR containing the local pathname of the icon
00322  *                  as we either get from the user or from the reg DB.
00323  *  iIcon           UINT providing the index into pszSourceFile where
00324  *                  the icon came from.
00325  *
00326  * Return Value:
00327  *  HGLOBAL         Global memory handle containing a METAFILEPICT where
00328  *                  the metafile uses the MM_ANISOTROPIC mapping mode.  The
00329  *                  extents reflect both icon and label.
00330  */
00331
00332 STDAPI_(HGLOBAL) OleUIMetafilePictFromIconAndLabel(HICON hIcon, LPSTR pszLabel
00333    , LPSTR pszSourceFile, UINT iIcon)
00334    {
00335    HDC             hDC, hDCScreen;
00336    HMETAFILE       hMF;
00337    HGLOBAL         hMem;
00338    LPMETAFILEPICT  pMF;
00339    UINT            cxIcon, cyIcon;
00340    UINT            cxText, cyText;
00341    UINT            cx, cy;
00342    UINT            cchLabel = 0;
00343    HFONT           hFont, hFontT;
00344    int             cyFont;
00345    char            szIndex[10];
00346    RECT            TextRect;
00347    SIZE            size;
00348    POINT           point;
00349    UINT            fuAlign;
00350
00351    if (NULL==hIcon)  // null label is valid but NOT a null icon
00352       return NULL;
00353
00354    //Create a memory metafile
00355    hDC=(HDC)CreateMetaFile(NULL);
00356
00357    if (NULL==hDC)
00358       return NULL;
00359
00360    //Allocate the metafilepict
00361    hMem=GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, sizeof(METAFILEPICT));
00362
00363    if (NULL==hMem)
00364       {
00365       hMF=CloseMetaFile(hDC);
00366       DeleteMetaFile(hMF);
00367       return NULL;
00368       }
00369
00370
00371    if (NULL!=pszLabel)
00372       {
00373       cchLabel=lstrlen(pszLabel);
00374
00375       if (cchLabel >= OLEUI_CCHLABELMAX)
00376          pszLabel[cchLabel] = '\0';   // truncate string
00377       }
00378
00379    //Need to use the screen DC for these operations
00380    hDCScreen=GetDC(NULL);
00381    cyFont=-(8*GetDeviceCaps(hDCScreen, LOGPIXELSY))/72;
00382
00383    //cyFont was calculated to give us 8 point.
00384    hFont=CreateFont(cyFont, 5, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET
00385       , OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY
00386       , FF_SWISS, "MS Sans Serif");
00387
00388    hFontT=SelectObject(hDCScreen, hFont);
00389
00390    GetTextExtentPoint(hDCScreen,szMaxWidth,lstrlen(szMaxWidth),&size);
00391    SelectObject(hDCScreen, hFontT);
00392
00393    cxText = size.cx;
00394    cyText = size.cy * 2;
00395
00396    cxIcon = GetSystemMetrics(SM_CXICON);
00397    cyIcon = GetSystemMetrics(SM_CYICON);
00398
00399
00400    // If we have no label, then we want the metafile to be the width of
00401    // the icon (plus margin), not the width of the fattest string.
00402    if ( (NULL == pszLabel) || ('\0' == *pszLabel) )
00403       cx = cxIcon + cxIcon / 4;
00404    else
00405       cx = max(cxText, cxIcon);
00406
00407    cy=cyIcon+cyText+4;
00408
00409    //Set the metafile size to fit the icon and label
00410    SetWindowOrgEx(hDC, 0, 0, &point);
00411    SetWindowExtEx(hDC, cx, cy, &size);
00412
00413    //Set up rectangle to pass to OleStdIconLabelTextOut
00414    SetRectEmpty(&TextRect);
00415
00416    TextRect.right = cx;
00417    TextRect.bottom = cy;
00418
00419    //Draw the icon and the text, centered with respect to each other.
00420    DrawIcon(hDC, (cx-cxIcon)/2, 0, hIcon);
00421
00422    //String that indicates where to stop if we're only doing icons
00423    Escape(hDC, MFCOMMENT, lstrlen(szIconOnly)+1, szIconOnly, NULL);
00424
00425    SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
00426    SetBkMode(hDC, TRANSPARENT);
00427    fuAlign = SetTextAlign(hDC, TA_LEFT | TA_TOP | TA_NOUPDATECP);
00428
00429    OleStdIconLabelTextOut(hDC,
00430                      hFont,
00431                      0,
00432                      cy - cyText,
00433                      ETO_CLIPPED,
00434                      &TextRect,
00435                      pszLabel,
00436                      cchLabel,
00437                      NULL);
00438
00439    //Write comments containing the icon source file and index.
00440    if (NULL!=pszSourceFile)
00441       {
00442       //+1 on string lengths insures the null terminator is embedded.
00443       Escape(hDC, MFCOMMENT, lstrlen(pszSourceFile)+1, pszSourceFile, NULL);
00444
00445       cchLabel=wsprintf(szIndex, "%u", iIcon);
00446       Escape(hDC, MFCOMMENT, cchLabel+1, szIndex, NULL);
00447       }
00448
00449    SetTextAlign(hDC, fuAlign);
00450
00451    //All done with the metafile, now stuff it all into a METAFILEPICT.
00452    hMF=CloseMetaFile(hDC);
00453
00454    if (NULL==hMF)
00455       {
00456       GlobalFree(hMem);
00457       ReleaseDC(NULL, hDCScreen);
00458       return NULL;
00459       }
00460
00461    //Fill out the structure
00462    pMF=(LPMETAFILEPICT)GlobalLock(hMem);
00463
00464    //Transform to HIMETRICS
00465    cx=XformWidthInPixelsToHimetric(hDCScreen, cx);
00466    cy=XformHeightInPixelsToHimetric(hDCScreen, cy);
00467    ReleaseDC(NULL, hDCScreen);
00468
00469    pMF->mm=MM_ANISOTROPIC;
00470    pMF->xExt=cx;
00471    pMF->yExt=cy;
00472    pMF->hMF=hMF;
00473
00474    GlobalUnlock(hMem);
00475
00476    DeleteObject(hFont);
00477
00478    return hMem;
00479    }
00480
00481 #endif  // OBSOLETE
00482
00483
00484 /*
00485  * GetAssociatedExecutable
00486  *
00487  * Purpose:  Finds the executable associated with the provided extension
00488  *
00489  * Parameters:
00490  *   lpszExtension   LPSTR points to the extension we're trying to find
00491  *                   an exe for. Does **NO** validation.
00492  *
00493  *   lpszExecutable  LPSTR points to where the exe name will be returned.
00494  *                   No validation here either - pass in 128 char buffer.
00495  *
00496  * Return:
00497  *   BOOL            TRUE if we found an exe, FALSE if we didn't.
00498  *
00499  */
00500
00501 BOOL FAR PASCAL GetAssociatedExecutable(LPSTR lpszExtension, LPSTR lpszExecutable)
00502
00503 {
00504    HKEY    hKey;
00505    LONG    dw;
00506    LRESULT lRet;
00507    char    szValue[OLEUI_CCHKEYMAX];
00508    char    szKey[OLEUI_CCHKEYMAX];
00509    LPSTR   lpszTemp, lpszExe;
00510
00511
00512    lRet = RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
00513
00514    if (ERROR_SUCCESS != lRet)
00515      return FALSE;
00516
00517    dw = OLEUI_CCHPATHMAX;
00518    lRet = RegQueryValue(hKey, lpszExtension, szValue, &dw);  //ProgId
00519
00520    if (ERROR_SUCCESS != lRet)
00521    {
00522      RegCloseKey(hKey);
00523      return FALSE;
00524    }
00525
00526
00527    // szValue now has ProgID
00528    lstrcpy(szKey, szValue);
00529    lstrcat(szKey, "\\Shell\\Open\\Command");
00530
00531
00532    dw = OLEUI_CCHPATHMAX;
00533    lRet = RegQueryValue(hKey, szKey, szValue, &dw);
00534
00535    if (ERROR_SUCCESS != lRet)
00536    {
00537      RegCloseKey(hKey);
00538      return FALSE;
00539    }
00540
00541    // szValue now has an executable name in it.  Let's null-terminate
00542    // at the first post-executable space (so we don't have cmd line
00543    // args.
00544
00545    lpszTemp = szValue;
00546
00547    while (('\0' != *lpszTemp) && (isspace(*lpszTemp)))
00548      lpszTemp++;     // Strip off leading spaces
00549
00550    lpszExe = lpszTemp;
00551
00552    while (('\0' != *lpszTemp) && (!isspace(*lpszTemp)))
00553      lpszTemp++;     // Step through exe name
00554
00555    *lpszTemp = '\0';  // null terminate at first space (or at end).
00556
00557
00558    lstrcpy(lpszExecutable, lpszExe);
00559
00560    return TRUE;
00561
00562 }
00563
00564
00565 /*
00566  * HIconAndSourceFromClass
00567  *
00568  * Purpose:
00569  *  Given an object class name, finds an associated executable in the
00570  *  registration database and extracts the first icon from that
00571  *  executable.  If none is available or the class has no associated
00572  *  executable, this function returns NULL.
00573  *
00574  * Parameters:
00575  *  rclsid          pointer to clsid to look up.
00576  *  pszSource       LPSTR in which to place the source of the icon.
00577  *                  This is assumed to be OLEUI_CCHPATHMAX
00578  *  puIcon          UINT FAR * in which to store the index of the
00579  *                  icon in pszSource.
00580  *
00581  * Return Value:
00582  *  HICON           Handle to the extracted icon if there is a module
00583  *                  associated to pszClass.  NULL on failure to either
00584  *                  find the executable or extract and icon.
00585  */
00586
00587 HICON FAR PASCAL HIconAndSourceFromClass(REFCLSID rclsid, LPSTR pszSource, UINT FAR *puIcon)
00588    {
00589    HICON           hIcon;
00590    UINT            IconIndex;
00591
00592    if (NULL==rclsid || NULL==pszSource || IsEqualCLSID(rclsid,&CLSID_NULL))
00593       return NULL;
00594
00595    if (!FIconFileFromClass(rclsid, pszSource, OLEUI_CCHPATHMAX, &IconIndex))
00596       return NULL;
00597
00598    hIcon=ExtractIcon(ghInst, pszSource, IconIndex);
00599
00600    if ((HICON)32 > hIcon)
00601       hIcon=NULL;
00602    else
00603       *puIcon= IconIndex;
00604
00605    return hIcon;
00606    }
00607
00608
00609 /*
00610  * PointerToNthField
00611  *
00612  * Purpose:
00613  *  Returns a pointer to the beginning of the nth field.
00614  *  Assumes null-terminated string.
00615  *
00616  * Parameters:
00617  *  lpszString        string to parse
00618  *  nField            field to return starting index of.
00619  *  chDelimiter       char that delimits fields
00620  *
00621  * Return Value:
00622  *  LPSTR             pointer to beginning of nField field.
00623  *                    NOTsE: If the null terminator is found
00624  *                          Before we find the Nth field, then
00625  *                          we return a pointer to the null terminator -
00626  *                          calling app should be sure to check for
00627  *                          this case.
00628  *
00629  */
00630 LPSTR FAR PASCAL PointerToNthField(LPSTR lpszString, int nField, char chDelimiter)
00631 {
00632    LPSTR lpField = lpszString;
00633    int   cFieldFound = 1;
00634
00635    if (1 ==nField)
00636      return lpszString;
00637
00638    while (*lpField != '\0')
00639    {
00640
00641      if (*lpField++ == chDelimiter)
00642      {
00643
00644        cFieldFound++;
00645
00646        if (nField == cFieldFound)
00647          return lpField;
00648      }
00649    }
00650
00651    return lpField;
00652
00653 }
00654
00655
00656 /*
00657  * FIconFileFromClass
00658  *
00659  * Purpose:
00660  *  Looks up the path to executable that contains the class default icon.
00661  *
00662  * Parameters:
00663  *  rclsid          pointer to CLSID to look up.
00664  *  pszEXE          LPSTR at which to store the server name
00665  *  cch             UINT size of pszEXE
00666  *  lpIndex         LPUINT to index of icon within executable
00667  *
00668  * Return Value:
00669  *  BOOL            TRUE if one or more characters were loaded into pszEXE.
00670  *                  FALSE otherwise.
00671  */
00672
00673 BOOL FAR PASCAL FIconFileFromClass(REFCLSID rclsid, LPSTR pszEXE, UINT cch, UINT FAR *lpIndex)
00674 {
00675
00676    LONG          dw;
00677    LONG          lRet;
00678    HKEY          hKey;
00679    LPMALLOC      lpIMalloc;
00680    HRESULT       hrErr;
00681    LPSTR         lpBuffer;
00682    LPSTR         lpIndexString;
00683    UINT          cBufferSize = 136;// room for 128 char path and icon's index
00684    char          szKey[264];
00685    char          pszClass[256];
00686    LPOLESTR      pszUniClass;
00687
00688
00689    if (NULL==rclsid || NULL==pszEXE || 0==cch || IsEqualCLSID(rclsid,&CLSID_NULL))
00690       return FALSE;
00691
00692    //Here, we use CoGetMalloc and alloc a buffer (maxpathlen + 8) to
00693    //pass to RegQueryValue.  Then, we copy the exe to pszEXE and the
00694    //index to *lpIndex.
00695
00696    hrErr = CoGetMalloc(MEMCTX_TASK, &lpIMalloc);
00697
00698    if (NOERROR != hrErr)
00699      return FALSE;
00700
00701    lpBuffer = /*(LPSTR)*/lpIMalloc->lpVtbl->Alloc(lpIMalloc, cBufferSize);
00702
00703    if (NULL == lpBuffer)
00704    {
00705      lpIMalloc->lpVtbl->Release(lpIMalloc);
00706      return FALSE;
00707    }
00708
00709
00710    if (CoIsOle1Class(rclsid))
00711    {
00712
00713      LPOLESTR lpszUniProgID;
00714      char lpszProgID[256];
00715
00716      // we've got an ole 1.0 class on our hands, so we look at
00717      // progID\protocol\stdfileedting\server to get the
00718      // name of the executable.
00719
00720      ProgIDFromCLSID(rclsid, &lpszUniProgID);
00721      W2A (lpszUniProgID, lpszProgID, 256);
00722
00723      //Open up the class key
00724      lRet=RegOpenKey(HKEY_CLASSES_ROOT, lpszProgID, &hKey);
00725
00726      if (ERROR_SUCCESS != lRet)
00727      {
00728        lpIMalloc->lpVtbl->Free(lpIMalloc, lpszUniProgID);
00729        lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00730        lpIMalloc->lpVtbl->Release(lpIMalloc);
00731        return FALSE;
00732      }
00733
00734      dw=(LONG)cBufferSize;
00735      lRet = RegQueryValue(hKey, "Protocol\\StdFileEditing\\Server", lpBuffer, &dw);
00736
00737      if (ERROR_SUCCESS != lRet)
00738      {
00739
00740        RegCloseKey(hKey);
00741        lpIMalloc->lpVtbl->Free(lpIMalloc, lpszUniProgID);
00742        lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00743        lpIMalloc->lpVtbl->Release(lpIMalloc);
00744        return FALSE;
00745      }
00746
00747
00748      // Use server and 0 as the icon index
00749      LSTRCPYN(pszEXE, lpBuffer, cch);
00750
00751      *lpIndex = 0;
00752
00753      RegCloseKey(hKey);
00754      lpIMalloc->lpVtbl->Free(lpIMalloc, lpszUniProgID);
00755      lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00756      lpIMalloc->lpVtbl->Release(lpIMalloc);
00757      return TRUE;
00758
00759    }
00760
00761
00762
00763    /*
00764     * We have to go walking in the registration database under the
00765     * classname, so we first open the classname key and then check
00766     * under "\\DefaultIcon" to get the file that contains the icon.
00767     */
00768
00769
00770    StringFromCLSID(rclsid, &pszUniClass);
00771    W2A (pszUniClass, pszClass, 256);
00772
00773    lstrcpy(szKey, "CLSID\\");
00774    lstrcat(szKey, pszClass);
00775
00776    //Open up the class key
00777    lRet=RegOpenKey(HKEY_CLASSES_ROOT, szKey, &hKey);
00778
00779    if (ERROR_SUCCESS != lRet)
00780    {
00781       lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00782       lpIMalloc->lpVtbl->Free(lpIMalloc, pszUniClass);
00783       lpIMalloc->lpVtbl->Release(lpIMalloc);
00784       return FALSE;
00785    }
00786
00787    //Get the executable path and icon index.
00788
00789    dw=(LONG)cBufferSize;
00790    lRet=RegQueryValue(hKey, "DefaultIcon", lpBuffer, &dw);
00791
00792    if (ERROR_SUCCESS != lRet)
00793    {
00794      // no DefaultIcon  key...try LocalServer
00795
00796      dw=(LONG)cBufferSize;
00797 #ifdef WIN32
00798      lRet=RegQueryValue(hKey, "LocalServer32", lpBuffer, &dw);
00799 #else
00800      lRet=RegQueryValue(hKey, "LocalServer", lpBuffer, &dw);
00801 #endif
00802
00803      if (ERROR_SUCCESS != lRet)
00804      {
00805        // no LocalServer entry either...they're outta luck.
00806
00807        RegCloseKey(hKey);
00808        lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00809        lpIMalloc->lpVtbl->Free(lpIMalloc, pszUniClass);
00810        lpIMalloc->lpVtbl->Release(lpIMalloc);
00811        return FALSE;
00812      }
00813
00814
00815      // Use server from LocalServer or Server and 0 as the icon index
00816      LSTRCPYN(pszEXE, lpBuffer, cch);
00817
00818      *lpIndex = 0;
00819
00820      RegCloseKey(hKey);
00821      lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00822      lpIMalloc->lpVtbl->Free(lpIMalloc, pszUniClass);
00823      lpIMalloc->lpVtbl->Release(lpIMalloc);
00824      return TRUE;
00825    }
00826
00827    RegCloseKey(hKey);
00828
00829    // lpBuffer contains a string that looks like "<pathtoexe>,<iconindex>",
00830    // so we need to separate the path and the icon index.
00831
00832    lpIndexString = PointerToNthField(lpBuffer, 2, ',');
00833
00834    if ('\0' == *lpIndexString)  // no icon index specified - use 0 as default.
00835    {
00836       *lpIndex = 0;
00837
00838    }
00839    else
00840    {
00841       LPSTR lpTemp;
00842       static char  szTemp[16];
00843
00844       lstrcpy(szTemp, lpIndexString);
00845
00846       // Put the icon index part into *pIconIndex
00847       *lpIndex = atoi((const char *)szTemp);
00848
00849       // Null-terminate the exe part.
00850       lpTemp = AnsiPrev(lpBuffer, lpIndexString);
00851       *lpTemp = '\0';
00852    }
00853
00854    if (!LSTRCPYN(pszEXE, lpBuffer, cch))
00855    {
00856       lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00857       lpIMalloc->lpVtbl->Free(lpIMalloc, pszUniClass);
00858       lpIMalloc->lpVtbl->Release(lpIMalloc);
00859       return FALSE;
00860    }
00861
00862    // Free the memory we alloc'd and leave.
00863    lpIMalloc->lpVtbl->Free(lpIMalloc, lpBuffer);
00864    lpIMalloc->lpVtbl->Free(lpIMalloc, pszUniClass);
00865    lpIMalloc->lpVtbl->Release(lpIMalloc);
00866    return TRUE;
00867 }
00868
00869
00870
00871 /*
00872  * OleStdIconLabelTextOut
00873  *
00874  * Purpose:
00875  *  Replacement for DrawText to be used in the "Display as Icon" metafile.
00876  *  Uses ExtTextOut to output a string center on (at most) two lines.
00877  *  Uses a very simple word wrap algorithm to split the lines.
00878  *
00879  * Parameters:  (same as for ExtTextOut, except for hFont)
00880  *  hDC           device context to draw into; if this is NULL, then we don't
00881  *                ETO the text, we just return the index of the beginning
00882  *                of the second line
00883  *  hFont         font to use
00884  *  nXStart       x-coordinate of starting position
00885  *  nYStart       y-coordinate of starting position
00886  *  fuOptions     rectangle type
00887  *  lpRect        rect far * containing rectangle to draw text in.
00888  *  lpszString    string to draw
00889  *  cchString     length of string (truncated if over OLEUI_CCHLABELMAX)
00890  *  lpDX          spacing between character cells
00891  *
00892  * Return Value:
00893  *  UINT          Index of beginning of last line (0 if there's only one
00894  *                line of text).
00895  *
00896  */
00897
00898 STDAPI_(UINT) OleStdIconLabelTextOut(HDC        hDC,
00899                             HFONT      hFont,
00900                             int        nXStart,
00901                             int        nYStart,
00902                             UINT       fuOptions,
00903                             RECT FAR * lpRect,
00904                             LPOLESTR   lpszString,
00905                             UINT       cchString,
00906                             int FAR *  lpDX)
00907 {
00908
00909   HDC          hDCScreen;
00910   static char  szTempBuff[OLEUI_CCHLABELMAX];
00911   int          cxString, cyString, cxMaxString;
00912   int          cxFirstLine, cyFirstLine, cxSecondLine;
00913   int          index;
00914   int          cch = cchString;
00915   char         chKeep;
00916   LPSTR        lpszSecondLine;
00917   HFONT        hFontT;
00918   BOOL         fPrintText = TRUE;
00919   UINT         iLastLineStart = 0;
00920   SIZE         size;
00921
00922   // Initialization stuff...
00923
00924   if (NULL == hDC)  // If we got NULL as the hDC, then we don't actually call ETO
00925    fPrintText = FALSE;
00926
00927
00928   // Make a copy of the string (NULL or non-NULL) that we're using
00929   if (NULL == lpszString)
00930    *szTempBuff = '\0';
00931
00932   else
00933   {
00934      W2A (lpszString, szTempBuff, OLEUI_CCHLABELMAX);
00935   }
00936
00937   // set maximum width
00938   cxMaxString = lpRect->right - lpRect->left;
00939
00940   // get screen DC to do text size calculations
00941   hDCScreen = GetDC(NULL);
00942
00943   hFontT=SelectObject(hDCScreen, hFont);
00944
00945   // get the extent of our label
00946   GetTextExtentPoint(hDCScreen, szTempBuff, cch, &size);
00947
00948   cxString = size.cx;
00949   cyString = size.cy;
00950
00951   // Select in the font we want to use
00952   if (fPrintText)
00953     SelectObject(hDC, hFont);
00954
00955   // String is smaller than max string - just center, ETO, and return.
00956   if (cxString <= cxMaxString)
00957   {
00958
00959    if (fPrintText)
00960       ExtTextOut(hDC,
00961               nXStart + (lpRect->right - cxString) / 2,
00962               nYStart,
00963               fuOptions,
00964               lpRect,
00965               szTempBuff,
00966               cch,
00967               NULL);
00968
00969    iLastLineStart = 0;  // only 1 line of text
00970    goto CleanupAndLeave;
00971   }
00972
00973   // String is too long...we've got to word-wrap it.
00974
00975
00976   // Are there any spaces, slashes, tabs, or bangs in string?
00977
00978   if (lstrlen(szTempBuff) != (int)strcspn(szTempBuff, szSeparators))
00979   {
00980     // Yep, we've got spaces, so we'll try to find the largest
00981     // space-terminated string that will fit on the first line.
00982
00983     index = cch;
00984
00985
00986     while (index >= 0)
00987     {
00988
00989       char cchKeep;
00990
00991       // scan the string backwards for spaces, slashes, tabs, or bangs
00992
00993       while (!IS_SEPARATOR(szTempBuff[index]) )
00994        index--;
00995
00996
00997       if (index <= 0)
00998        break;
00999
01000       cchKeep = szTempBuff[index];  // remember what char was there
01001
01002       szTempBuff[index] = '\0';  // just for now
01003
01004       GetTextExtentPoint(
01005             hDCScreen, szTempBuff,lstrlen(szTempBuff),&size);
01006
01007       cxFirstLine = size.cx;
01008       cyFirstLine = size.cy;
01009
01010       szTempBuff[index] = cchKeep;   // put the right char back
01011
01012       if (cxFirstLine <= cxMaxString)
01013       {
01014
01015          iLastLineStart = index + 1;
01016
01017          if (!fPrintText)
01018           goto CleanupAndLeave;
01019
01020          ExtTextOut(hDC,
01021                  nXStart +  (lpRect->right - cxFirstLine) / 2,
01022                  nYStart,
01023                  fuOptions,
01024                  lpRect,
01025                  szTempBuff,
01026                  index + 1,
01027                  lpDX);
01028
01029          lpszSecondLine = szTempBuff;
01030
01031          lpszSecondLine += index + 1;
01032
01033          GetTextExtentPoint(hDCScreen,
01034                            lpszSecondLine,
01035                            lstrlen(lpszSecondLine),
01036                            &size);
01037
01038          // If the second line is wider than the rectangle, we
01039          // just want to clip the text.
01040          cxSecondLine = min(size.cx, cxMaxString);
01041
01042          ExtTextOut(hDC,
01043                  nXStart + (lpRect->right - cxSecondLine) / 2,
01044                  nYStart + cyFirstLine,
01045                  fuOptions,
01046                  lpRect,
01047                  lpszSecondLine,
01048                  lstrlen(lpszSecondLine),
01049                  lpDX);
01050
01051          goto CleanupAndLeave;
01052
01053       }  // end if
01054
01055       index--;
01056
01057     }  // end while
01058
01059   }  // end if
01060
01061   // Here, there are either no spaces in the string (strchr(szTempBuff, ' ')
01062   // returned NULL), or there spaces in the string, but they are
01063   // positioned so that the first space terminated string is still
01064   // longer than one line. So, we walk backwards from the end of the
01065   // string until we find the largest string that will fit on the first
01066   // line , and then we just clip the second line.
01067
01068   cch = lstrlen(szTempBuff);
01069
01070   chKeep = szTempBuff[cch];
01071   szTempBuff[cch] = '\0';
01072
01073   GetTextExtentPoint(hDCScreen, szTempBuff, lstrlen(szTempBuff),&size);
01074
01075   cxFirstLine = size.cx;
01076   cyFirstLine = size.cy;
01077
01078   while (cxFirstLine > cxMaxString)
01079   {
01080     // We allow 40 characters in the label, but the metafile is
01081     // only as wide as 10 W's (for aesthetics - 20 W's wide looked
01082     // dumb.  This means that if we split a long string in half (in
01083     // terms of characters), then we could still be wider than the
01084     // metafile.  So, if this is the case, we just step backwards
01085     // from the halfway point until we get something that will fit.
01086     // Since we just let ETO clip the second line
01087
01088     szTempBuff[cch--] = chKeep;
01089     if (0 == cch)
01090       goto CleanupAndLeave;
01091
01092     chKeep = szTempBuff[cch];
01093     szTempBuff[cch] = '\0';
01094
01095     GetTextExtentPoint(
01096           hDCScreen, szTempBuff, lstrlen(szTempBuff), &size);
01097     cxFirstLine = size.cx;
01098   }
01099
01100   iLastLineStart = cch;
01101
01102   if (!fPrintText)
01103    goto CleanupAndLeave;
01104
01105   ExtTextOut(hDC,
01106           nXStart + (lpRect->right - cxFirstLine) / 2,
01107           nYStart,
01108           fuOptions,
01109           lpRect,
01110           szTempBuff,
01111           lstrlen(szTempBuff),
01112           lpDX);
01113
01114   szTempBuff[cch] = chKeep;
01115   lpszSecondLine = szTempBuff;
01116   lpszSecondLine += cch;
01117
01118   GetTextExtentPoint(
01119         hDCScreen, lpszSecondLine, lstrlen(lpszSecondLine), &size);
01120
01121   // If the second line is wider than the rectangle, we
01122   // just want to clip the text.
01123   cxSecondLine = min(size.cx, cxMaxString);
01124
01125   ExtTextOut(hDC,
01126           nXStart + (lpRect->right - cxSecondLine) / 2,
01127           nYStart + cyFirstLine,
01128           fuOptions,
01129           lpRect,
01130           lpszSecondLine,
01131           lstrlen(lpszSecondLine),
01132           lpDX);
01133
01134 CleanupAndLeave:
01135   SelectObject(hDCScreen, hFontT);
01136   ReleaseDC(NULL, hDCScreen);
01137   return iLastLineStart;
01138
01139 }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/DllDatax.h Source File

  • Com
  • Services
  • Crm
  • CrmFiles

DllDatax.h

Go to the documentation of this file.
00001 #if !defined(AFX_DLLDATAX_H__43A7D832_B492_11D1_82F1_00A0C91EEDE9__INCLUDED_)
00002 #define AFX_DLLDATAX_H__43A7D832_B492_11D1_82F1_00A0C91EEDE9__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007
00008 #ifdef _MERGE_PROXYSTUB
00009
00010 extern "C"
00011 {
00012 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
00013   LPVOID lpReserved);
00014 STDAPI PrxDllCanUnloadNow(void);
00015 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
00016 STDAPI PrxDllRegisterServer(void);
00017 STDAPI PrxDllUnregisterServer(void);
00018 }
00019
00020 #endif
00021
00022 //{{AFX_INSERT_LOCATION}}
00023 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00024
00025 #endif // !defined(AFX_DLLDATAX_H__43A7D832_B492_11D1_82F1_00A0C91EEDE9__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/About.h Source File

  • SysMgmt
  • MMC
  • Help

About.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/src/IsapiDebug.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • src

IsapiDebug.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiDebug.cpp
00006
00007 Abstract:
00008
00009     Debug functions for ISAPI tools library
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee), October 2002
00014
00015 --*/
00016
00017 #include <IsapiTools.h>
00018 #include <stdio.h>
00019
00020 //
00021 // Local prototypes
00022 //
00023
00024 VOID
00025 WriteDebugArgs(
00026     CHAR *  szFormat,
00027     va_list args
00028     );
00029
00030 //
00031 // Function implementations
00032 //
00033
00034 VOID
00035 IsapiAssert(
00036     CHAR *  szExpr,
00037     CHAR *  szFile,
00038     DWORD   dwLine
00039     )
00040 /*++
00041
00042 Purpose:
00043
00044     Calls a DebugBreak and reports the expression, source
00045     filename, and line number to the debugger.
00046
00047     This function is called by the ISAPI_ASSERT macro, which
00048     provides the expression, source file, and line information.
00049
00050 Arguments:
00051
00052     szExpr - The expression that failed the assertion
00053     szFile - The name of the source file that contains the expression
00054     dwLine - The line number of the expression
00055
00056 Returns:
00057
00058     None
00059
00060 --*/
00061 {
00062     va_list args;
00063
00064     args = (va_list)&szExpr;
00065
00066     WriteDebugArgs( "ISAPIASSERT Failed:  \"%s\", File=\"%s\", Line=%d.\r\n",
00067                 args );
00068
00069     va_end( args );
00070
00071     DebugBreak();
00072 }
00073
00074 VOID
00075 WriteDebug(
00076     CHAR *  szFormat,
00077     ...
00078     )
00079 /*++
00080
00081 Purpose:
00082
00083     Writes a line to an attached debugger using printf-style
00084     formatting.
00085
00086 Arguments:
00087
00088     szFormat - The format string
00089     ...      - Zero or more additional arguments
00090
00091 Returns:
00092
00093     None
00094
00095 --*/
00096 {
00097     va_list args;
00098
00099     va_start( args, szFormat );
00100
00101     WriteDebugArgs( szFormat, args );
00102
00103     va_end( args );
00104 }
00105
00106 VOID
00107 WriteDebugArgs(
00108     CHAR *  szFormat,
00109     va_list args
00110     )
00111 /*++
00112
00113 Purpose:
00114
00115     Writes a line to an attached debugger using printf-style
00116     formatting and a va_list of args.
00117
00118 Arguments:
00119
00120     szFormat - The format string
00121     args     - The va_list of additional arguments
00122
00123 Returns:
00124
00125     None
00126
00127 --*/
00128 {
00129     CHAR    szOutput[MAX_DEBUG_OUTPUT];
00130     INT     nWritten = 0;
00131
00132     //
00133     // Put the module name into the output buffer.
00134     //
00135
00136     nWritten = _snprintf( szOutput,
00137                           MAX_DEBUG_OUTPUT,
00138                           "[%s.dll] ",
00139                           g_szModuleName );
00140
00141     if ( nWritten == -1 )
00142     {
00143         //
00144         // Ouch.  Buffer was too small for even the module name
00145         //
00146
00147         return;
00148     }
00149
00150     //
00151     // Now write the rest of the data into the buffer
00152     //
00153
00154     nWritten = _vsnprintf( szOutput + nWritten,
00155                            MAX_DEBUG_OUTPUT - nWritten,
00156                            szFormat,
00157                            args );
00158
00159     //
00160     // If we overran the buffer, truncate the data
00161     // with \r\n\0
00162     //
00163
00164     if ( nWritten == -1 )
00165     {
00166         //
00167         // If, for some reason, we have a pathologically
00168         // small MAX_DEBUG_OUTPUT, don't overrun the buffer
00169         //
00170
00171         if ( MAX_DEBUG_OUTPUT < 3 )
00172         {
00173             return;
00174         }
00175
00176         szOutput[MAX_DEBUG_OUTPUT - 3] = '\r';
00177         szOutput[MAX_DEBUG_OUTPUT - 2] = '\n';
00178         szOutput[MAX_DEBUG_OUTPUT - 1] = '\0';
00179     }
00180
00181     //
00182     // Write it
00183     //
00184
00185     OutputDebugString( szOutput );
00186 }
00187
00188
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COBNODE Member List

This is the complete list of members for COBNODE, including all inherited members.
pItem | COBNODE
pNext | COBNODE
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/Cancel/Local/Mta/SServer.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • Cancel
  • Local
  • Mta

SServer.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #define _WIN32_WINNT 0x0500
00018 #include <stdio.h>
00019 #include <tchar.h>
00020 #include <windows.h>
00021 #include <WindowsX.h>
00022
00023 #include <initguid.h>
00024
00025 HANDLE g_hEventDone;
00026 CRITICAL_SECTION g_cs;
00027
00028 // {37824811-ADBA-11d1-B6FB-00A024A85A1F}
00029 DEFINE_GUID(CLSID_MTACancelObject, 0x37824812, 0xadba, 0x11d1, 0xb6, 0xfb, 0x0, 0xa0, 0x24, 0xa8, 0x5a, 0x1f);
00030
00031
00032 typedef struct tagCONSOLEDATA
00033 {
00034   int x;
00035   int y;
00036 } CONSOLEDATA;
00037
00038 CONSOLEDATA g_ConsoleData;
00039
00040 // %%Classes: ----------------------------------------------------------------
00041
00042 // simple class-factory: only knows how to create CSimpleObject instances
00043 class CClassFactory : public IClassFactory
00044 {
00045   public:
00046     // IUnknown
00047     STDMETHODIMP    QueryInterface (REFIID riid, void** ppv);
00048     STDMETHODIMP_(ULONG) AddRef(void)  { return 2; };
00049     STDMETHODIMP_(ULONG) Release(void) { return 1; }
00050
00051     // IClassFactory
00052     STDMETHODIMP    CreateInstance (LPUNKNOWN punkOuter, REFIID iid, void **ppv);
00053     STDMETHODIMP    LockServer (BOOL fLock) {
00054     if (fLock)
00055       CoAddRefServerProcess();
00056     else
00057     {
00058       if (!CoReleaseServerProcess())
00059       {
00060         SetEvent(g_hEventDone);
00061       }
00062     }
00063     return S_OK;
00064   }
00065
00066     CClassFactory()  { }
00067
00068   private:
00069     };
00070
00071 class CSimpleObject : public IPersist
00072 {
00073   public:
00074     // IUnknown
00075     STDMETHODIMP    QueryInterface (REFIID iid, void **ppv);
00076     STDMETHODIMP_(ULONG) AddRef(void)  {InterlockedIncrement(&m_cRef);return m_cRef;}
00077     STDMETHODIMP_(ULONG) Release(void) {
00078     if (InterlockedDecrement(&m_cRef) == 0)
00079     { delete this; return 0;}
00080     else
00081       return m_cRef;
00082   }
00083
00084     // IPersist
00085     STDMETHODIMP    GetClassID(CLSID *pClsID);
00086
00087     // constructors/destructors
00088     CSimpleObject()     {
00089     m_cRef = 1; xy.X = 0; xy.Y = (short)g_ConsoleData.y;
00090     hConsole = CreateFile(TEXT("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
00091       FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
00092     if (INVALID_HANDLE_VALUE == hConsole)
00093       hConsole = 0;
00094     CoAddRefServerProcess();
00095   }
00096     ~CSimpleObject()    { if (hConsole) CloseHandle(hConsole);
00097       if (!CoReleaseServerProcess())
00098       {
00099         SetEvent(g_hEventDone);
00100       }
00101   }
00102     STDMETHODIMP    WasteTime(TCHAR *szMessage);
00103
00104   private:
00105     LONG        m_cRef;
00106   COORD       xy;
00107   HANDLE hConsole;
00108
00109     };
00110
00111 // %%Globals: ----------------------------------------------------------------
00112
00113 CClassFactory   g_ClassFactory;
00114
00115 // ---------------------------------------------------------------------------
00116 // %%Function: Message
00117 //
00118 //  Formats and displays a message to the console.
00119 // ---------------------------------------------------------------------------
00120 void
00121 Message(LPTSTR szPrefix, HRESULT hr)
00122 {
00123     LPTSTR   szMessage;
00124   TCHAR szDisplay[1000];
00125
00126     if (hr == S_OK)
00127         {
00128     _stprintf(szDisplay, TEXT("%s"), szPrefix);
00129     MessageBox(0, szDisplay, TEXT("Msg"),MB_SERVICE_NOTIFICATION);
00130         return;
00131         }
00132
00133     if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
00134         hr = HRESULT_CODE(hr);
00135
00136     FormatMessage(
00137         FORMAT_MESSAGE_ALLOCATE_BUFFER |
00138         FORMAT_MESSAGE_FROM_SYSTEM,
00139         NULL,
00140         hr,
00141         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00142         (LPTSTR)&szMessage,
00143         0,
00144         NULL );
00145
00146     _stprintf(szDisplay, TEXT("%s: %s(%lx)"), szPrefix, szMessage, hr);
00147   MessageBox(0, szDisplay, TEXT("Service:Msg"),MB_SERVICE_NOTIFICATION);
00148     LocalFree(szMessage);
00149 }  // Message
00150
00151
00152 // ---------------------------------------------------------------------------
00153 // %%Function: CSimpleObject::QueryInterface
00154 // ---------------------------------------------------------------------------
00155  STDMETHODIMP
00156 CSimpleObject::QueryInterface(REFIID riid, void** ppv)
00157 {
00158     if (ppv == NULL)
00159         return E_INVALIDARG;
00160     *ppv = NULL;
00161     if (riid == IID_IUnknown || riid == IID_IPersist)
00162     {
00163         *ppv =  this;
00164         ((IUnknown*)*ppv)->AddRef();
00165         return S_OK;
00166   }
00167
00168     return E_NOINTERFACE;
00169 }  // CSimpleObject::QueryInterface
00170
00171 STDMETHODIMP Busy(HANDLE hConsole, COORD& xy, int nIter)
00172 {
00173   HRESULT hr = S_OK;
00174   SetConsoleCursorPosition(hConsole, xy);
00175   TCHAR *szMessage = TEXT("!!!Call cancelled!!!");
00176   TCHAR *szBuf[4]={TEXT("|"), TEXT("/"), TEXT("-"), TEXT("\\")};
00177   for (int i = 0; i < nIter; i++)
00178   {
00179     Sleep(5);
00180     WriteConsole(hConsole, szBuf[0], 1, NULL, NULL);
00181     SetConsoleCursorPosition(hConsole, xy);
00182     WriteConsole(hConsole, szBuf[1], 1, NULL, NULL);
00183     SetConsoleCursorPosition(hConsole, xy);
00184     WriteConsole(hConsole, szBuf[2], 1, NULL, NULL);
00185     SetConsoleCursorPosition(hConsole, xy);
00186     WriteConsole(hConsole, szBuf[3], 1, NULL, NULL);
00187     SetConsoleCursorPosition(hConsole, xy);
00188     if (RPC_E_CALL_CANCELED == CoTestCancel())
00189     {
00190       hr = RPC_E_CALL_CANCELED;
00191       WriteConsole(hConsole, szMessage, lstrlen(szMessage), NULL, NULL);
00192       break;
00193     }
00194   }
00195   return hr;
00196 }
00197
00198 STDMETHODIMP
00199 CSimpleObject::WasteTime(TCHAR *szMessage)
00200 {
00201   if (hConsole)
00202   {
00203     SetConsoleCursorPosition(hConsole, xy);
00204     WriteConsole(hConsole, szMessage, lstrlen(szMessage), NULL, NULL);
00205     xy.X += 50;
00206     return Busy(hConsole, xy, 5000);
00207   }
00208   return S_OK;
00209 }
00210
00211
00212 STDMETHODIMP
00213 CSimpleObject::GetClassID(CLSID *pClsID)
00214 {
00215   UNREFERENCED_PARAMETER(pClsID);
00216   MessageBeep(0);
00217   xy.X = 0;
00218   return WasteTime(TEXT("In Call                               "));
00219 }
00220
00221 // ---------------------------------------------------------------------------
00222 // %%Function: CClassFactory::QueryInterface
00223 // ---------------------------------------------------------------------------
00224  STDMETHODIMP
00225 CClassFactory::QueryInterface(REFIID riid, void** ppv)
00226 {
00227     if (ppv == NULL)
00228         return E_INVALIDARG;
00229     if (riid == IID_IClassFactory || riid == IID_IUnknown)
00230         {
00231         *ppv = (IClassFactory *) this;
00232         AddRef();
00233         return S_OK;
00234         }
00235     *ppv = NULL;
00236     return E_NOINTERFACE;
00237 }  // CClassFactory::QueryInterface
00238
00239 // ---------------------------------------------------------------------------
00240 // %%Function: CClassFactory::CreateInstance
00241 // ---------------------------------------------------------------------------
00242
00243  STDMETHODIMP
00244 CClassFactory::CreateInstance(LPUNKNOWN punkOuter, REFIID riid, void** ppv)
00245 {
00246   HRESULT hr = S_OK;
00247     *ppv = NULL;
00248   CSimpleObject *p;
00249
00250     if (punkOuter != NULL)
00251         return CLASS_E_NOAGGREGATION;
00252   EnterCriticalSection(&g_cs);
00253   g_ConsoleData.y++;
00254   p = new CSimpleObject;
00255   LeaveCriticalSection(&g_cs);
00256     if (p == NULL)
00257         return E_OUTOFMEMORY;
00258   if (RPC_E_CALL_CANCELED == p->WasteTime(TEXT("Creating Object")))
00259   {
00260     p->Release();
00261     return hr;
00262   }
00263     hr = p->QueryInterface(riid, ppv);
00264   p->Release();
00265   return hr;
00266 }  // CClassFactory::CreateInstance
00267
00268
00269
00270 void main()
00271 {
00272     HRESULT hr;
00273     DWORD   dwRegister;
00274
00275     // create the event which is signaled when the instance is deleted
00276     g_hEventDone = CreateEvent(NULL, FALSE, FALSE, NULL);
00277     if (g_hEventDone == NULL)
00278     {
00279         Message(TEXT("Server: CreateEvent Error"), GetLastError());
00280         exit(-1);
00281     }
00282   InitializeCriticalSection(&g_cs);
00283     // initialize COM for free-threading
00284     hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00285   if (FAILED(hr))
00286     {
00287         Message(TEXT("Server: CoInitializeEx Error"), hr);
00288         exit(-1);
00289     }
00290
00291   hr = CoInitializeSecurity(
00292       NULL,
00293       -1,
00294       NULL,
00295       NULL,
00296       RPC_C_AUTHN_LEVEL_NONE,
00297       RPC_C_IMP_LEVEL_IMPERSONATE,
00298       NULL,
00299       EOAC_NONE,
00300       NULL);
00301     if (FAILED(hr))
00302         {
00303     CoUninitialize();
00304         Message(TEXT("Client: CoInitializeSecurity Error"), hr);
00305         exit(hr);
00306         }
00307   // register the class-object with OLE
00308     hr = CoRegisterClassObject(CLSID_MTACancelObject, &g_ClassFactory,
00309         CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &dwRegister);
00310
00311   if (FAILED(hr))
00312     {
00313     CoUninitialize();
00314         Message(TEXT("Server: CoRegisterClassObject Error"), hr);
00315         exit(-1);
00316     }
00317   WaitForSingleObject(g_hEventDone, INFINITE);
00318   hr = CoRevokeClassObject(dwRegister);
00319   if (FAILED(hr))
00320     {
00321     CoUninitialize();
00322         Message(TEXT("Server: CoRevokeClassObject Error"), hr);
00323         exit(-1);
00324     }
00325     CoUninitialize();
00326   CloseHandle(g_hEventDone);
00327   DeleteCriticalSection(&g_cs);
00328     _tprintf(TEXT("Server: Done"));
00329 }  // main
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_TYPEMAP Member List

This is the complete list of members for _TYPEMAP, including all inherited members.
pwszTypeName | _TYPEMAP
wType | _TYPEMAP
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/MethCli/MethCli.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • MethCli

MethCli.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 //
00004
00005 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00006 //
00007 // File:  methcli.cpp
00008 //
00009 // Description:
00010 //        WMI Method Client Sample.
00011 //      This sample shows how to call a method on an object in WMI
00012 //
00013 // History:
00014 //
00015 // **************************************************************************
00016
00017 #include <objbase.h>
00018 #include <windows.h>
00019 #include <stdio.h>
00020 #include <wbemidl.h>
00021
00022 //***************************************************************************
00023 //
00024 // main
00025 //
00026 // Purpose: Initialized Ole, call the method, and cleanup.
00027 //
00028 //***************************************************************************
00029
00030 BOOL g_bInProc = FALSE;
00031
00032 int main(int iArgCnt, char ** argv)
00033 {
00034     IWbemLocator *pLocator = NULL;
00035     IWbemServices *pNamespace = 0;
00036     IWbemClassObject * pClass = NULL;
00037     IWbemClassObject * pOutInst = NULL;
00038     IWbemClassObject * pInClass = NULL;
00039     IWbemClassObject * pInInst = NULL;
00040   BSTR Text = NULL;
00041   HRESULT hr = S_OK;
00042
00043     BSTR path = SysAllocString(L"root\\default");
00044     BSTR ClassPath = SysAllocString(L"MethProvSamp");
00045     BSTR MethodName = SysAllocString(L"Echo");
00046     BSTR ArgName = SysAllocString(L"sInArg");
00047
00048   if (!path || ! ClassPath || !MethodName || ! ArgName)
00049   {
00050     printf("SysAllocString failed. Out of memory.\n");
00051     goto cleanup;
00052   }
00053
00054
00055     // Initialize COM and connect up to CIMOM
00056
00057     hr = CoInitialize(0);
00058   if (FAILED(hr))
00059   {
00060       printf("CoInitialize returned 0x%x:", hr);
00061     goto cleanup;
00062   }
00063
00064   //  NOTE:
00065   //  When using asynchronous WMI API's remotely in an environment where the "Local System" account
00066   //  has no network identity (such as non-Kerberos domains), the authentication level of
00067   //  RPC_C_AUTHN_LEVEL_NONE is needed. However, lowering the authentication level to
00068   //  RPC_C_AUTHN_LEVEL_NONE makes your application less secure. It is wise to
00069   //  use semi-synchronous API's for accessing WMI data and events instead of the asynchronous ones.
00070
00071     hr = CoInitializeSecurity ( NULL, -1, NULL, NULL,
00072           RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
00073           RPC_C_IMP_LEVEL_IMPERSONATE,
00074           NULL,
00075           EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
00076           NULL );
00077   if (FAILED(hr))
00078   {
00079       printf("CoInitializeSecurity returned 0x%x:", hr);
00080     goto cleanup;
00081   }
00082
00083     hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
00084             IID_IWbemLocator, (LPVOID *) &pLocator);
00085   if (FAILED(hr))
00086   {
00087       printf("CoCreateInstance returned 0x%x:", hr);
00088     goto cleanup;
00089   }
00090     hr = pLocator->ConnectServer(path, NULL, NULL, NULL, 0, NULL, NULL, &pNamespace);
00091     printf("\n\nConnectServer returned 0x%x:", hr);
00092     if(hr != WBEM_S_NO_ERROR)
00093     goto cleanup;
00094
00095     // Get the class object
00096
00097     hr = pNamespace->GetObject(ClassPath, 0, NULL, &pClass, NULL);
00098     printf("\nGetObject returned 0x%x:", hr);
00099     if(hr != WBEM_S_NO_ERROR)
00100     goto cleanup;
00101
00102     // Get the input argument and set the property
00103
00104     hr = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
00105     printf("\nGetMethod returned 0x%x:", hr);
00106     if(hr != WBEM_S_NO_ERROR)
00107     goto cleanup;
00108
00109     hr = pInClass->SpawnInstance(0, &pInInst);
00110     printf("\nSpawnInstance returned 0x%x:", hr);
00111     if(hr != WBEM_S_NO_ERROR)
00112     goto cleanup;
00113
00114     VARIANT var;
00115     var.vt = VT_BSTR;
00116     var.bstrVal= SysAllocString(L"hello");
00117     if (var.bstrVal == NULL)
00118     goto cleanup;
00119     hr = pInInst->Put(ArgName, 0, &var, 0);
00120     VariantClear(&var);
00121
00122     // Call the method
00123
00124     hr = pNamespace->ExecMethod(ClassPath, MethodName, 0, NULL, pInInst, &pOutInst, NULL);
00125     printf("\nExecMethod returned 0x%x:", hr);
00126     if(hr != WBEM_S_NO_ERROR)
00127     goto cleanup;
00128
00129
00130     // Display the results.
00131
00132     hr = pOutInst->GetObjectText(0, &Text);
00133   if(hr != WBEM_S_NO_ERROR)
00134     goto cleanup;
00135     printf("\n\nThe object text of the output object is:\n%S", Text);
00136
00137   printf("Terminating normally\n");
00138
00139
00140   // Free up resources
00141 cleanup:
00142
00143     SysFreeString(path);
00144     SysFreeString(ClassPath);
00145     SysFreeString(MethodName);
00146     SysFreeString(ArgName);
00147     SysFreeString(Text);
00148
00149   if (pClass)
00150     pClass->Release();
00151   if (pInInst)
00152     pInInst->Release();
00153   if (pInClass)
00154     pInClass->Release();
00155   if (pOutInst)
00156     pOutInst->Release();
00157   if (pLocator)
00158     pLocator->Release();
00159   if (pNamespace)
00160     pNamespace->Release();
00161     CoUninitialize();
00162     return 0;
00163 }
00164
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/PingResp/PingResp.Idl Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • PingResp

PingResp.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: PingResp.idl
00004
00005 Summary:  Defines the IPingResponder and AsyncIPingResponder interfaces
00006
00007 ----------------------------------------------------------------------------
00008
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021
00022 ==========================================================================+*/
00023
00024 // PingResp.idl : IDL source for PingResp.dll
00025 //
00026
00027 // This file will be processed by the MIDL tool to
00028 // produce the type library (PingResp.tlb) and marshalling code.
00029
00030 import "oaidl.idl";
00031 import "ocidl.idl";
00032   [
00033     object,
00034     uuid(8C0B3D3F-DB1F-11D2-8C2B-00A0C9F422B8),
00035     async_uuid(8C0B3D3E-DB1F-11D2-8C2B-00A0C9F422B8),
00036     helpstring("IPingResponder Interface"),
00037     pointer_default(unique)
00038   ]
00039   interface IPingResponder : IUnknown
00040   {
00041     HRESULT Ping();
00042   };
00043
00044 [
00045   uuid(8C0B3D31-DB1F-11D2-8C2B-00A0C9F422B8),
00046   version(1.0),
00047   helpstring("PingResp 1.0 Type Library")
00048 ]
00049 library PINGRESPLib
00050 {
00051   importlib("stdole32.tlb");
00052   importlib("stdole2.tlb");
00053
00054   [
00055     uuid(8C0B3D40-DB1F-11D2-8C2B-00A0C9F422B8),
00056     helpstring("PingResponder Class")
00057   ]
00058   coclass PingResponder
00059   {
00060     [default] interface IPingResponder;
00061   };
00062 };
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/Java/CapJ/capj.java Source File

  • Web
  • MSAgent
  • Java
  • CapJ

capj.java

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright (C) 1997-1998 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011 //
00012 // CapJ is the WFC Java version of the Character Animation Previewer sample.
00013 // It demonstrates loading characters, playing animations, speaking, moving,
00014 // etc.
00015 //
00016 //==========================================================================
00017
00018 import com.ms.wfc.app.*;
00019 import com.ms.wfc.core.*;
00020 import com.ms.wfc.ui.*;
00021 import com.ms.wfc.io.*;
00022 import com.ms.fx.*;
00023
00024 // We want access to 2 native APIs so we'll add the
00025 // import directive here so that we don't have to do
00026 // it for each API. Note the use of the auto parameter.
00027 // This tells J/Direct to use the UNICODE APIs on NT and
00028 // ANSI everywhere else.
00029
00030 /** @dll.import("USER32", auto) */
00031 public class CapJ extends Form
00032 {
00033   // Native APIs
00034
00035   private static native int GetForegroundWindow();
00036   private static native int GetWindowText(int hWnd, StringBuffer text, int nMaxCount);
00037
00038   // Class globals
00039
00040   private agentctl.IAgentCtlCharacterEx m_pCharacter = null;
00041
00042   // Constants
00043
00044   private final String kpszRecentFilesSubkey = "Software\\Microsoft\\Microsoft Agent\\Tools\\Character Previewer\\Recent Files";
00045   private final String kpszRecentFilesItem = "File";
00046
00047   private final String kpszCharacterWindowTitle = "Microsoft Agent";
00048   private final String kpszOptionsWindowTitle = "Advanced Character Options";
00049
00050   private final int MAX_RECENT_FILES = 4;
00051   private final int MAX_RECENT_FILENAME = 32;
00052
00053   // Constants from AgtSvr.h
00054
00055   private final int UserHid = 0;
00056   private final int UserHidViaCharacterMenu = 7;
00057
00058   // Constructor
00059
00060   public CapJ()
00061   {
00062     super();
00063
00064     initForm();
00065
00066     // Ensure that we're connected to Microsoft Agent
00067
00068     agent1.setConnected(true);
00069
00070     // Update the recent file list in the File menu
00071
00072     UpdateRecentFiles(null);
00073   }
00074
00075   public void dispose()
00076   {
00077     super.dispose();
00078     components.dispose();
00079   }
00080
00081   private void LoadCharacter(String path)
00082   {
00083     com.ms.com.IEnumVariant enum = null;
00084     com.ms.com.Variant vName[] = {null};
00085     int iRetrieved[] = {-1};
00086     int iBalloonStyle;
00087     boolean bHasAnims;
00088
00089     com.ms.com.Variant vPath = new com.ms.com.Variant();
00090     com.ms.com.Variant vFast = new com.ms.com.Variant();
00091
00092     // Was a path specified
00093
00094     if (path == "")
00095     {
00096       // Nope. Create a file dialog object.
00097
00098       OpenFileDialog fOpenDlg = new OpenFileDialog();
00099
00100       fOpenDlg.setFilter("Agent Character Files (*.acs)|*.acs|Agent Character Files (*.acf)|*.acf|All files (*.*)|*.*");
00101       fOpenDlg.setCheckFileExists(true);
00102       fOpenDlg.setCheckPathExists(true);
00103
00104       // Show it
00105
00106       if (fOpenDlg.showDialog() == DialogResult.OK)
00107         vPath.putString(fOpenDlg.getFileName());
00108       else
00109         return;
00110     }
00111     else
00112     {
00113       vPath.putString(path);
00114     }
00115
00116     // If we already have a character loaded, unload it and
00117     // clear the animation name list box.
00118
00119     if (m_pCharacter != null)
00120     {
00121       agent1.getCharacters().Unload("characterID");
00122       m_pCharacter = null;
00123       this.AnimationsListBox.removeAll();
00124     }
00125
00126     // Load the character
00127
00128     try
00129     {
00130       agent1.getCharacters().Load("characterID",vPath);
00131     }
00132     catch (com.ms.com.ComFailException e)
00133     {
00134       return;
00135     }
00136
00137     // Save the character interface/object
00138
00139     m_pCharacter = agent1.getCharacters().Character("characterID");
00140
00141     // Move the character to the right of the window
00142
00143     Rectangle rcWindow = new Rectangle(this.getLocation().x,
00144                        this.getLocation().y,
00145                        this.getSize().x,
00146                        this.getSize().y);
00147
00148     // Make sure we'll fit to the right (NOTE: a production
00149     // quality app would handle multi-monitor!!!)
00150
00151     int charLeft;
00152
00153     charLeft = rcWindow.getRight();
00154
00155     if ((charLeft + m_pCharacter.getWidth()) > FxToolkit.getSystemMetric(FxToolkit.SCREEN_WIDTH))
00156       charLeft = rcWindow.x - m_pCharacter.getWidth();
00157
00158     // Position the character
00159
00160     m_pCharacter.MoveTo((short)charLeft, (short)rcWindow.y, new com.ms.com.Variant(0));
00161
00162     // And show it
00163
00164     m_pCharacter.Show(vFast);
00165
00166     // Enumerate the character's animation names
00167
00168     enum = (com.ms.com.IEnumVariant)m_pCharacter.getAnimationNames().getEnum();
00169
00170     while (true) {
00171       enum.Next(1, vName, iRetrieved);
00172       if (iRetrieved[0] != 1)
00173         break;
00174       this.AnimationsListBox.addItem(vName[0].getString());
00175     }
00176
00177     // Initialize the animation list box label with the character's
00178     // name.
00179
00180     AnimationsLabel.setText("Animations for " + m_pCharacter.getName());
00181
00182     // Initialize controls
00183
00184     UseSfx.setChecked(m_pCharacter.getSoundEffectsOn());
00185
00186     bHasAnims = AnimationsListBox.getItemCount() > 0;
00187
00188     if (bHasAnims)
00189       AnimationsListBox.setSelectedIndex(0);
00190
00191     AnimationsLabel.setEnabled(bHasAnims);
00192     AnimationsListBox.setEnabled(bHasAnims);
00193     UseSfx.setEnabled(bHasAnims && agent1.getAudioOutput().getSoundEffects());
00194     StopBeforePlay.setEnabled(bHasAnims);
00195     PlayButton.setEnabled(bHasAnims);
00196     StopButton.setEnabled(bHasAnims);
00197     SpeechOutputLabel.setEnabled(bHasAnims);
00198     SpeakText.setEnabled(bHasAnims);
00199     SpeakButton.setEnabled(bHasAnims);
00200
00201     PositionLabel.setEnabled(bHasAnims);
00202     XLabel.setEnabled(bHasAnims);
00203     X.setEnabled(bHasAnims);
00204     YLabel.setEnabled(bHasAnims);
00205     Y.setEnabled(bHasAnims);
00206     Move.setEnabled(bHasAnims);
00207
00208     iBalloonStyle = m_pCharacter.getBalloon().getStyle();
00209
00210     UseBalloon.setChecked((iBalloonStyle & 1) == 1);
00211     SizeToText.setChecked((iBalloonStyle & 2) == 2);
00212     AutoHide.setChecked((iBalloonStyle & 4) == 4);
00213     AutoPace.setChecked((iBalloonStyle & 8) == 8);
00214
00215     UseBalloon.setEnabled(bHasAnims);
00216     AutoHide.setEnabled(bHasAnims && UseBalloon.getChecked());
00217     AutoPace.setEnabled(bHasAnims && UseBalloon.getChecked());
00218     SizeToText.setEnabled(bHasAnims && UseBalloon.getChecked());
00219
00220     // Add commands
00221
00222     m_pCharacter.getCommands().Add("PropSheet",
00223                      new com.ms.com.Variant("&Advanced Character Properties"),
00224                      new com.ms.com.Variant(),
00225                      new com.ms.com.Variant(),
00226                      new com.ms.com.Variant());
00227
00228     // Add the loaded character to the recent file list
00229
00230     UpdateRecentFiles(vPath.getString());
00231   }
00232
00233   private String MakeEllipsisPath(String pszPath, int iMaxLength)
00234   {
00235     // This function takes a full path and truncates to a fixed
00236     // specified size using ellipses as necessary.
00237
00238     int iPathPartLen;
00239     int iEndDir;
00240     int i;
00241     String pszFilename;
00242
00243     // If the specified path fits, then just copy it and return
00244
00245     if (pszPath.length() <= iMaxLength)
00246       return new String(pszPath);
00247
00248     // See if the filename alone is too big
00249
00250     i = pszPath.lastIndexOf("\\");
00251
00252     if (i >= 0)
00253       pszFilename = pszPath.substring(i+1, pszPath.length());
00254     else
00255       pszFilename = new String(pszPath);
00256
00257     if (pszFilename.length() >= iMaxLength)
00258       return pszFilename.substring(0, iMaxLength-3) + "...";
00259
00260     // Make a copy
00261
00262     String pszPathCopy = new String(pszPath);
00263
00264     if (pszPathCopy.startsWith("\\\\"))
00265       iEndDir = 3;
00266     else
00267       iEndDir = pszPathCopy.indexOf('\\') + 1;
00268
00269     iEndDir = pszPathCopy.indexOf('\\', iEndDir);
00270
00271     // If we couldn't find the first directory component, give up
00272     // and just return the filename only.
00273
00274     if (iEndDir < 0)
00275       return pszFilename;
00276     else
00277       iEndDir++;
00278
00279     if (iEndDir < (iMaxLength - pszFilename.length() - 4))
00280       iPathPartLen = iEndDir;
00281     else
00282       iPathPartLen = iMaxLength - pszFilename.length() - 4;
00283
00284     return new String(pszPathCopy.substring(0, iPathPartLen) + "...\\" + pszFilename);
00285   }
00286
00287   private void UpdateRecentFiles(String pszFilename)
00288   {
00289     Registry reg;
00290     RegistryKey rk;
00291
00292     int iNumExisting = 0;
00293     int iFind = -1;
00294     int iCount;
00295     String pszEllipsis;
00296     String[] rgpszRecentFiles = new String[MAX_RECENT_FILES];
00297
00298     // Create/Open the recent files registry subkey
00299
00300     reg = new Registry();
00301
00302     rk = reg.CURRENT_USER.createSubKey(kpszRecentFilesSubkey);
00303
00304     for (int i=1; i <= MAX_RECENT_FILES; i++)
00305     {
00306       // Get the registry value of the form "File<#>"
00307
00308       Integer i2 = new Integer(i);
00309
00310       rgpszRecentFiles[i-1] = (String)rk.getValue(kpszRecentFilesItem + i2.toString());
00311
00312       // Did we find a value
00313
00314       if (rgpszRecentFiles[i-1] != null)
00315       {
00316         // If a filename was specified, see if it matches this one
00317
00318         if (pszFilename != null)
00319         {
00320           if (pszFilename.equals(rgpszRecentFiles[iNumExisting]))
00321           {
00322             // If the specified file is the first file we find,
00323             // then we're done.
00324
00325             if (iNumExisting == 0)
00326             {
00327               rk.close();
00328               return;
00329             }
00330
00331             iFind = iNumExisting;
00332           }
00333         }
00334
00335         ++iNumExisting;
00336       }
00337     }
00338
00339     // If no filename was specified, and we don't have any
00340     // existing files, we're done.
00341
00342     if ((pszFilename == null) && (iNumExisting == 0))
00343     {
00344       recentSeparator.setVisible(false);
00345       return;
00346     }
00347
00348     // If a file was specified, we have to update the registry
00349
00350     if (pszFilename != null)
00351     {
00352       // Write the new filename to the registry
00353
00354       rk.setValue(kpszRecentFilesItem + "1", pszFilename);
00355
00356       // If we previously had the maximum number of files, and
00357       // the new one is not one of them, we disregard the last
00358       // one.
00359
00360       if ((iNumExisting == MAX_RECENT_FILES) && (iFind < 0))
00361         --iNumExisting;
00362
00363       // Now, write the remaining items
00364
00365       iCount = 1;
00366
00367       for (int i=0; i < iNumExisting; i++)
00368       {
00369         if (i != iFind)
00370         {
00371           Integer i2 = new Integer(++iCount);
00372           rk.setValue(kpszRecentFilesItem + i2.toString(), rgpszRecentFiles[i]);
00373         }
00374       }
00375     }
00376
00377     // Set the recent file menu items to be non-visible
00378
00379     recent1.setVisible(false);
00380     recent2.setVisible(false);
00381     recent3.setVisible(false);
00382     recent4.setVisible(false);
00383
00384     // Create an ellipsis path from the specified filename and
00385     // insert it into the menu.
00386
00387     if (pszFilename != null)
00388     {
00389       pszEllipsis = MakeEllipsisPath(pszFilename, MAX_RECENT_FILENAME);
00390       String pszMenuItemText = new String("&1 " + pszEllipsis);
00391       recent1.setText(pszMenuItemText);
00392       recent1.setVisible(true);
00393       iCount = 1;
00394     }
00395     else
00396     {
00397       iCount = 0;
00398     }
00399
00400     // Then do the same for the remaining items
00401
00402     for (int i=0; i < iNumExisting; i++)
00403     {
00404       if (i != iFind)
00405       {
00406         Integer i2 = new Integer(iCount+1);
00407
00408         pszEllipsis = MakeEllipsisPath(rgpszRecentFiles[i], MAX_RECENT_FILENAME);
00409
00410         String pszMenuItemText = new String("&" + i2.toString() + " " + pszEllipsis);
00411
00412         if (iCount == 0)
00413         {
00414           recent1.setText(pszMenuItemText);
00415           recent1.setVisible(true);
00416         }
00417         else if (iCount == 1)
00418         {
00419           recent2.setText(pszMenuItemText);
00420           recent2.setVisible(true);
00421         }
00422         else if (iCount == 2)
00423         {
00424           recent3.setText(pszMenuItemText);
00425           recent3.setVisible(true);
00426         }
00427         else if (iCount == 3)
00428         {
00429           recent4.setText(pszMenuItemText);
00430           recent4.setVisible(true);
00431         }
00432
00433         ++iCount;
00434       }
00435     }
00436
00437     // Show/Hide the separator as appropriate
00438
00439     if ((iNumExisting == 0) && (pszFilename == null))
00440       recentSeparator.setVisible(false);
00441     else
00442       recentSeparator.setVisible(true);
00443
00444     rk.close();
00445   }
00446
00447   private void OnRecentFile(int iFile)
00448   {
00449     Registry reg = new Registry();
00450     RegistryKey rk;
00451     Integer i = new Integer(iFile);
00452
00453     // Open the registry subkey
00454
00455     rk = reg.CURRENT_USER.createSubKey(kpszRecentFilesSubkey);
00456
00457     // Try to find a value name of "File<iFile>"
00458
00459     String pszFilename = (String)rk.getValue(kpszRecentFilesItem + i.toString());
00460
00461     // Did we find it?
00462
00463     if (pszFilename == null)
00464       return;
00465
00466     // Load the character
00467
00468     LoadCharacter(pszFilename);
00469   }
00470
00471   public void exitMenu_click(Object sender, Event e)
00472   {
00473     // Unload the character (if necessary)
00474
00475     if (m_pCharacter != null) {
00476       m_pCharacter = null;
00477       agent1.getCharacters().Unload("characterID");
00478     }
00479
00480     Application.exit();
00481   }
00482
00483   private void aboutMenu_click(Object sender, Event e)
00484   {
00485     About myAbout = new About();
00486     myAbout.showDialog();
00487   }
00488
00489   private void openMenu_click(Object source, Event e)
00490   {
00491     LoadCharacter("");
00492   }
00493
00494   private void recent1_click(Object source, Event e)
00495   {
00496     OnRecentFile(1);
00497   }
00498
00499   private void recent2_click(Object source, Event e)
00500   {
00501     OnRecentFile(2);
00502   }
00503
00504   private void recent3_click(Object source, Event e)
00505   {
00506     OnRecentFile(3);
00507   }
00508
00509   private void recent4_click(Object source, Event e)
00510   {
00511     OnRecentFile(4);
00512   }
00513
00514   private void OnListDblClick(Object sender, Event e)
00515   {
00516     PlayButton_click(sender, e);
00517   }
00518
00519   private void PlayButton_click(Object sender, Event e)
00520   {
00521     String curAnim = new String("");
00522
00523     if (m_pCharacter == null)
00524       return;
00525
00526     curAnim = (String)this.AnimationsListBox.getSelectedItem();
00527
00528     if (curAnim != "")
00529     {
00530       if (this.StopBeforePlay.getChecked())
00531         m_pCharacter.StopAll(new com.ms.com.Variant());
00532
00533       m_pCharacter.Play(curAnim);
00534     }
00535   }
00536
00537   private void StopButton_click(Object source, Event e)
00538   {
00539     if (m_pCharacter != null)
00540       m_pCharacter.StopAll(new com.ms.com.Variant());
00541   }
00542
00543   private void SpeakButton_click(Object source, Event e)
00544   {
00545     int iStyle;
00546
00547     if (m_pCharacter == null)
00548       return;
00549
00550     iStyle = 0;
00551
00552     if (UseBalloon.getChecked())
00553       iStyle |= 1;
00554
00555     if (SizeToText.getChecked())
00556       iStyle |= 2;
00557
00558     if (AutoHide.getChecked())
00559       iStyle |= 4;
00560
00561     if (AutoPace.getChecked())
00562       iStyle |= 8;
00563
00564     m_pCharacter.getBalloon().setStyle(iStyle);
00565
00566     if (SpeakText.getText().length() != 0)
00567       m_pCharacter.Speak(new com.ms.com.Variant(SpeakText.getText()), new com.ms.com.Variant());
00568   }
00569
00570   private void Move_click(Object source, Event e)
00571   {
00572     Short x;
00573     Short y;
00574
00575     if (m_pCharacter == null)
00576       return;
00577
00578     if ((X.getText().length() == 0) || (Y.getText().length() == 0))
00579       return;
00580
00581     try
00582     {
00583       x = new Short(X.getText());
00584     }
00585     catch (NumberFormatException exc)
00586     {
00587       X.setSelectionStart(0);
00588       X.setSelectionEnd(-1);
00589       return;
00590     }
00591
00592     try
00593     {
00594       y = new Short(Y.getText());
00595     }
00596     catch (NumberFormatException exc)
00597     {
00598       Y.selectAll();
00599       return;
00600     }
00601
00602     if (this.StopBeforePlay.getChecked())
00603       m_pCharacter.StopAll(new com.ms.com.Variant());
00604
00605     m_pCharacter.MoveTo(x.shortValue(), y.shortValue(), new com.ms.com.Variant());
00606   }
00607
00608   private void UseSfx_click(Object source, Event e)
00609   {
00610     if (m_pCharacter == null)
00611       return;
00612
00613     m_pCharacter.setSoundEffectsOn(UseSfx.getChecked());
00614   }
00615
00616   private void UseBalloon_click(Object source, Event e)
00617   {
00618     boolean bUseBalloon;
00619
00620     bUseBalloon = UseBalloon.getChecked();
00621
00622     AutoHide.setEnabled(bUseBalloon);
00623     AutoPace.setEnabled(bUseBalloon);
00624     SizeToText.setEnabled(bUseBalloon);
00625   }
00626
00627   private void agent1_command(Object sender, agentctl.Agent.CommandEvent e)
00628   {
00629     // The user selected a command from the popup menu.
00630
00631     agentctl.IAgentCtlUserInput ui = (agentctl.IAgentCtlUserInput)(e.UserInput);
00632
00633     if (ui.getName().equals("PropSheet"))
00634     {
00635       agentctl.IAgentCtlPropertySheet ps = agent1.getPropertySheet();
00636       short sX = (short)(ps.getLeft() + ps.getWidth()/2);
00637       short sY = (short)(ps.getTop() + ps.getHeight()/2);
00638
00639       // Stop the character
00640
00641       m_pCharacter.StopAll(new com.ms.com.Variant());
00642
00643       // Gesture at the center of the property sheet
00644
00645       m_pCharacter.GestureAt(sX, sY);
00646
00647       // And show the property sheet
00648
00649       ps.setVisible(true);
00650     }
00651   }
00652
00653   private void agent1_move(Object sender, agentctl.Agent.MoveEvent e)
00654   {
00655     // The character moved. Resync our window to the
00656     // new position.
00657
00658     Short sX = new Short(e.x);
00659     Short sY = new Short(e.y);
00660     X.setText(sX.toString());
00661     Y.setText(sY.toString());
00662   }
00663
00664   private void agent1_agentPropertyChange(Object sender, Event e)
00665   {
00666     // When an Agent property changes (via the Advanced Character
00667     // Options property sheet), we need to resync our window with
00668     // the current state of Agent's properties.
00669
00670     UseSfx.setEnabled(agent1.getAudioOutput().getSoundEffects() &&
00671               AnimationsListBox.getItemCount() > 0);
00672
00673     boolean bEnable = m_pCharacter.getBalloon().getEnabled();
00674
00675     UseBalloon.setEnabled(bEnable);
00676
00677     bEnable = bEnable && UseBalloon.getChecked();
00678
00679     SizeToText.setEnabled(bEnable);
00680     AutoHide.setEnabled(bEnable);
00681     AutoPace.setEnabled(bEnable);
00682   }
00683
00684
00685   private void CapJ_closing(Object source, CancelEvent e)
00686   {
00687     // Unload the character (if necessary)
00688
00689     if (m_pCharacter != null) {
00690       m_pCharacter = null;
00691       agent1.getCharacters().Unload("characterID");
00692     }
00693   }
00694
00695   private void AnimationsListBox_doubleClick(Object source, Event e)
00696   {
00697     PlayButton_click(source, e);
00698   }
00699
00700   private void CapJ_activate(Object source, Event e)
00701   {
00702     // Is a character currently loaded?
00703
00704     if (m_pCharacter != null)
00705     {
00706       // We never want to show the character if the window
00707       // is minimized (i.e. state == 1).
00708
00709       if (getWindowState() != 1)
00710       {
00711         // We want to show the character on activation but there's
00712         // a special case. If the user hid the character we could get
00713         // an activate message after the character window hides.
00714         // In that case, we sure don't want to show the character. So
00715         // check the visibility cause of the character. If the user hid
00716         // it, we won't show it.
00717
00718         if ((m_pCharacter.getVisibilityCause() == UserHid) ||
00719           (m_pCharacter.getVisibilityCause() == UserHidViaCharacterMenu))
00720           return;
00721
00722         m_pCharacter.Show(new com.ms.com.Variant(true));
00723       }
00724     }
00725   }
00726
00727   private void CapJ_deactivate(Object source, Event e)
00728   {
00729     // When the window is deactivated, we'll hide the character
00730     // (non-animated). This code also demonstrates the use of
00731     // J/Direct.
00732
00733     // Is a character currently loaded?
00734
00735     if (m_pCharacter != null)
00736     {
00737       // Use J/Direct to get the foreground window
00738
00739       int hWnd = GetForegroundWindow();
00740
00741       // Create a StringBuffer to get the window title
00742       // of the foreground window.
00743
00744       StringBuffer title = new StringBuffer(256);
00745
00746       // Get the title of the foreground window using
00747       // J/Direct.
00748
00749       if (GetWindowText(hWnd, title, 256) > 0)
00750       {
00751         // We don't want to hide the character if it is the
00752         // foreground window.
00753
00754         if (title.toString().equalsIgnoreCase(kpszCharacterWindowTitle))
00755           return;
00756
00757         // Check to see if it's the Agent Character Property
00758         // Sheet. NOTE: this currently only works on English
00759         // systems. A more robust way to do this would be to
00760         // use the process id of the window that is getting
00761         // focus, and make sure that it's not AgentSvr.exe.
00762
00763         if (title.toString().equalsIgnoreCase(kpszOptionsWindowTitle))
00764           return;
00765       }
00766
00767       // Hide the character (no animation)
00768
00769       m_pCharacter.Hide(new com.ms.com.Variant(true));
00770     }
00771   }
00772
00773   Container components = new Container();
00774   MainMenu mainMenu1 = new MainMenu();
00775   MenuItem openMenu = new MenuItem();
00776   GroupBox AnimationsLabel = new GroupBox();
00777   MenuItem recentSeparator = new MenuItem();
00778   ListBox AnimationsListBox = new ListBox();
00779   MenuItem aboutMenu = new MenuItem();
00780   MenuItem fileMenu = new MenuItem();
00781   CheckBox AutoHide = new CheckBox();
00782   Button PlayButton = new Button();
00783   Button StopButton = new Button();
00784   CheckBox UseSfx = new CheckBox();
00785   CheckBox StopBeforePlay = new CheckBox();
00786   GroupBox SpeechOutputLabel = new GroupBox();
00787   Edit SpeakText = new Edit();
00788   CheckBox UseBalloon = new CheckBox();
00789   MenuItem exitMenu = new MenuItem();
00790   MenuItem helpMenu = new MenuItem();
00791   agentctl.Agent.Agent agent1 = new agentctl.Agent.Agent();
00792   CheckBox AutoPace = new CheckBox();
00793   CheckBox SizeToText = new CheckBox();
00794   Button SpeakButton = new Button();
00795   GroupBox PositionLabel = new GroupBox();
00796   Label XLabel = new Label();
00797   Edit X = new Edit();
00798   Label YLabel = new Label();
00799   Edit Y = new Edit();
00800   Button Move = new Button();
00801   MenuItem menuItem1 = new MenuItem();
00802   MenuItem recent2 = new MenuItem();
00803   MenuItem recent3 = new MenuItem();
00804   MenuItem recent4 = new MenuItem();
00805   MenuItem recent1 = new MenuItem();
00806
00807   private void initForm()
00808   {
00809     // NOTE:  This form is storing resource information in an
00810     // external file.  Do not modify the string parameter to any
00811     // resources.getObject() function call. For example, do not
00812     // modify "foo1_location" in the following line of code
00813     // even if the name of the Foo object changes:
00814     //   foo1.setLocation((Point)resources.getObject("foo1_location"));
00815
00816     IResourceManager resources = new ResourceManager(this, "CapJ");
00817     components.add(openMenu, "openMenu");
00818     openMenu.setShortcut(Shortcut.CTRL_O);
00819     openMenu.setText("&Open...");
00820     openMenu.addOnClick(new EventHandler(this.openMenu_click));
00821
00822     components.add(AnimationsLabel, "AnimationsLabel");
00823     AnimationsLabel.setEnabled(false);
00824     AnimationsLabel.setLocation(new Point(8, 8));
00825     AnimationsLabel.setSize(new Point(280, 168));
00826     AnimationsLabel.setTabIndex(2);
00827     AnimationsLabel.setTabStop(false);
00828     AnimationsLabel.setText("&Animations");
00829
00830     components.add(recentSeparator, "recentSeparator");
00831     recentSeparator.setText("-");
00832
00833     components.add(AnimationsListBox, "AnimationsListBox");
00834     AnimationsListBox.setEnabled(false);
00835     AnimationsListBox.setLocation(new Point(16, 24));
00836     AnimationsListBox.setSize(new Point(264, 108));
00837     AnimationsListBox.setTabIndex(1);
00838     AnimationsListBox.setText("listBox1");
00839     AnimationsListBox.setSorted(true);
00840     AnimationsListBox.setUseTabStops(true);
00841     AnimationsListBox.addOnDoubleClick(new EventHandler(this.AnimationsListBox_doubleClick));
00842
00843     components.add(aboutMenu, "aboutMenu");
00844     aboutMenu.setText("&About Microsoft Character Animation Previewer");
00845     aboutMenu.addOnClick(new EventHandler(this.aboutMenu_click));
00846
00847     components.add(AutoHide, "AutoHide");
00848     AutoHide.setEnabled(false);
00849     AutoHide.setLocation(new Point(32, 112));
00850     AutoHide.setSize(new Point(64, 16));
00851     AutoHide.setTabIndex(2);
00852     AutoHide.setText("Auto hi&de");
00853
00854     components.add(PlayButton, "PlayButton");
00855     PlayButton.setEnabled(false);
00856     PlayButton.setLocation(new Point(304, 24));
00857     PlayButton.setSize(new Point(96, 24));
00858     PlayButton.setTabIndex(3);
00859     PlayButton.setText("&Play");
00860     PlayButton.addOnClick(new EventHandler(this.PlayButton_click));
00861
00862     components.add(StopButton, "StopButton");
00863     StopButton.setEnabled(false);
00864     StopButton.setLocation(new Point(304, 64));
00865     StopButton.setSize(new Point(96, 24));
00866     StopButton.setTabIndex(4);
00867     StopButton.setText("S&top");
00868     StopButton.addOnClick(new EventHandler(this.StopButton_click));
00869
00870     components.add(UseSfx, "UseSfx");
00871     UseSfx.setEnabled(false);
00872     UseSfx.setLocation(new Point(8, 136));
00873     UseSfx.setSize(new Point(112, 16));
00874     UseSfx.setTabIndex(0);
00875     UseSfx.setText("Play sound &effects");
00876     UseSfx.addOnClick(new EventHandler(this.UseSfx_click));
00877
00878     components.add(StopBeforePlay, "StopBeforePlay");
00879     StopBeforePlay.setEnabled(false);
00880     StopBeforePlay.setLocation(new Point(136, 136));
00881     StopBeforePlay.setSize(new Point(128, 16));
00882     StopBeforePlay.setTabIndex(1);
00883     StopBeforePlay.setText("Stop &before next action");
00884
00885     components.add(SpeechOutputLabel, "SpeechOutputLabel");
00886     SpeechOutputLabel.setEnabled(false);
00887     SpeechOutputLabel.setLocation(new Point(8, 184));
00888     SpeechOutputLabel.setSize(new Point(280, 144));
00889     SpeechOutputLabel.setTabIndex(5);
00890     SpeechOutputLabel.setTabStop(false);
00891     SpeechOutputLabel.setText("Speech &Output");
00892
00893     components.add(SpeakText, "SpeakText");
00894     SpeakText.setEnabled(false);
00895     SpeakText.setLocation(new Point(8, 16));
00896     SpeakText.setSize(new Point(264, 64));
00897     SpeakText.setTabIndex(0);
00898     SpeakText.setText("");
00899     SpeakText.setMultiline(true);
00900     SpeakText.setScrollBars(ScrollBars.VERTICAL);
00901
00902     components.add(UseBalloon, "UseBalloon");
00903     UseBalloon.setEnabled(false);
00904     UseBalloon.setLocation(new Point(8, 88));
00905     UseBalloon.setSize(new Point(120, 16));
00906     UseBalloon.setTabIndex(1);
00907     UseBalloon.setText("Display &word balloon");
00908     UseBalloon.addOnClick(new EventHandler(this.UseBalloon_click));
00909
00910     components.add(exitMenu, "exitMenu");
00911     exitMenu.setText("E&xit");
00912     exitMenu.addOnClick(new EventHandler(this.exitMenu_click));
00913
00914     components.add(helpMenu, "helpMenu");
00915     helpMenu.setMenuItems(new MenuItem[] {
00916                 aboutMenu});
00917     helpMenu.setText("&Help");
00918
00919     components.add(agent1, "agent1");
00920     agent1.setLocation(new Point(368, 96));
00921     agent1.setSize(new Point(32, 32));
00922     agent1.setTabIndex(0);
00923     agent1.setOcxState((AxHost.State)resources.getObject("agent1_ocxState"));
00924     agent1.addOnCommand(new agentctl.Agent.CommandHandler(this.agent1_command));
00925     agent1.addOnMove(new agentctl.Agent.MoveHandler(this.agent1_move));
00926     agent1.addOnAgentPropertyChange(new EventHandler(this.agent1_agentPropertyChange));
00927
00928     components.add(AutoPace, "AutoPace");
00929     AutoPace.setEnabled(false);
00930     AutoPace.setLocation(new Point(112, 112));
00931     AutoPace.setSize(new Point(72, 16));
00932     AutoPace.setTabIndex(3);
00933     AutoPace.setText("Auto pa&ce");
00934
00935     components.add(SizeToText, "SizeToText");
00936     SizeToText.setEnabled(false);
00937     SizeToText.setLocation(new Point(192, 112));
00938     SizeToText.setSize(new Point(72, 16));
00939     SizeToText.setTabIndex(4);
00940     SizeToText.setText("Si&ze to text");
00941
00942     components.add(SpeakButton, "SpeakButton");
00943     SpeakButton.setEnabled(false);
00944     SpeakButton.setLocation(new Point(304, 200));
00945     SpeakButton.setSize(new Point(96, 24));
00946     SpeakButton.setTabIndex(6);
00947     SpeakButton.setText("&Speak");
00948     SpeakButton.addOnClick(new EventHandler(this.SpeakButton_click));
00949
00950     components.add(PositionLabel, "PositionLabel");
00951     PositionLabel.setEnabled(false);
00952     PositionLabel.setLocation(new Point(8, 336));
00953     PositionLabel.setSize(new Point(280, 56));
00954     PositionLabel.setTabIndex(7);
00955     PositionLabel.setTabStop(false);
00956     PositionLabel.setText("Position");
00957
00958     components.add(XLabel, "XLabel");
00959     XLabel.setEnabled(false);
00960     XLabel.setLocation(new Point(16, 24));
00961     XLabel.setSize(new Point(16, 16));
00962     XLabel.setTabIndex(0);
00963     XLabel.setTabStop(false);
00964     XLabel.setText("&X:");
00965
00966     components.add(X, "X");
00967     X.setEnabled(false);
00968     X.setLocation(new Point(32, 24));
00969     X.setSize(new Point(40, 20));
00970     X.setTabIndex(1);
00971     X.setText("");
00972
00973     components.add(YLabel, "YLabel");
00974     YLabel.setEnabled(false);
00975     YLabel.setLocation(new Point(112, 24));
00976     YLabel.setSize(new Point(16, 16));
00977     YLabel.setTabIndex(2);
00978     YLabel.setTabStop(false);
00979     YLabel.setText("&Y:");
00980
00981     components.add(Y, "Y");
00982     Y.setEnabled(false);
00983     Y.setLocation(new Point(136, 24));
00984     Y.setSize(new Point(40, 20));
00985     Y.setTabIndex(3);
00986     Y.setText("");
00987
00988     components.add(Move, "Move");
00989     Move.setEnabled(false);
00990     Move.setLocation(new Point(304, 360));
00991     Move.setSize(new Point(96, 24));
00992     Move.setTabIndex(9);
00993     Move.setText("&Move");
00994     Move.addOnClick(new EventHandler(this.Move_click));
00995
00996     components.add(menuItem1, "menuItem1");
00997     menuItem1.setText("-");
00998
00999     components.add(recent2, "recent2");
01000     recent2.setText("");
01001     recent2.setVisible(false);
01002     recent2.addOnClick(new EventHandler(this.recent2_click));
01003
01004     components.add(recent3, "recent3");
01005     recent3.setText("");
01006     recent3.setVisible(false);
01007     recent3.addOnClick(new EventHandler(this.recent3_click));
01008
01009     components.add(recent4, "recent4");
01010     recent4.setText("");
01011     recent4.setVisible(false);
01012     recent4.addOnClick(new EventHandler(this.recent4_click));
01013
01014     components.add(recent1, "recent1");
01015     recent1.setText("");
01016     recent1.setVisible(false);
01017     recent1.addOnClick(new EventHandler(this.recent1_click));
01018
01019     components.add(fileMenu, "fileMenu");
01020     fileMenu.setMenuItems(new MenuItem[] {
01021                 openMenu,
01022                 recentSeparator,
01023                 recent1,
01024                 recent2,
01025                 recent3,
01026                 recent4,
01027                 menuItem1,
01028                 exitMenu});
01029     fileMenu.setText("&File");
01030
01031     components.add(mainMenu1, "mainMenu1");
01032     mainMenu1.setMenuItems(new MenuItem[] {
01033                  fileMenu,
01034                  helpMenu});
01035     /* @designTimeOnly mainMenu1.setLocation(new Point(320, 136)); */
01036
01037     this.setAllowDrop(true);
01038     this.setAnchor(ControlAnchor.ALL);
01039     this.setLocation(new Point(298, 88));
01040     this.setText("Microsoft Character Animation Previewer");
01041     this.setAutoScaleBaseSize(new Point(5, 13));
01042     this.setClientSize(new Point(414, 403));
01043     this.setIcon((Icon)resources.getObject("this_icon"));
01044     this.setMaximizeBox(false);
01045     this.setMenu(mainMenu1);
01046     this.setStartPosition(FormStartPosition.CENTER_SCREEN);
01047     this.addOnActivate(new EventHandler(this.CapJ_activate));
01048     this.addOnDeactivate(new EventHandler(this.CapJ_deactivate));
01049     this.addOnClosing(new CancelEventHandler(this.CapJ_closing));
01050
01051     this.setNewControls(new Control[] {
01052               Move,
01053               PositionLabel,
01054               SpeakButton,
01055               SpeechOutputLabel,
01056               StopButton,
01057               PlayButton,
01058               AnimationsListBox,
01059               agent1,
01060               AnimationsLabel});
01061     AnimationsLabel.setNewControls(new Control[] {
01062                      StopBeforePlay,
01063                      UseSfx});
01064     SpeechOutputLabel.setNewControls(new Control[] {
01065                      SizeToText,
01066                      AutoPace,
01067                      AutoHide,
01068                      UseBalloon,
01069                      SpeakText});
01070     PositionLabel.setNewControls(new Control[] {
01071                    Y,
01072                    YLabel,
01073                    X,
01074                    XLabel});
01075
01076     agent1.begin();
01077   }
01078
01079   public static void main(String args[])
01080   {
01081     Application.run(new CapJ());
01082   }
01083 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ColumnProvider/clsid.Cpp Source File

  • WinUI
  • Shell
  • ColumnProvider

clsid.Cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  Clsid.cpp
00011 //
00012 //      Functions to retrieve the CLSID of the object.
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #include "ShortName.h"
00017 #include "Resource.h"
00018
00019 extern HINSTANCE hDllInstance;
00020
00021 BOOL WINAPI GetObjectClsid (LPTSTR lpszClsid, DWORD cbClsid)
00022 {
00023     if (!LoadString (hDllInstance, IDS_CLSID, lpszClsid, cbClsid))
00024         return FALSE;
00025     return TRUE;
00026 }
00027
00028
00029 BOOL WINAPI GetObjectClsid (LPCLSID pClsid)
00030 {
00031     if (pClsid == NULL)
00032         return FALSE;
00033
00034     TCHAR szClsid[40];
00035     WCHAR wszClsid[40];
00036
00037     if (!GetObjectClsid (szClsid, 40))
00038         return FALSE;
00039
00040 #ifndef UNICODE
00041     MultiByteToWideChar (CP_ACP, 0, szClsid, -1, wszClsid, 40);
00042 #else
00043     lstrcpyn (wszClsid, szClsid, ARRAYSIZE(wszClsid));
00044 #endif
00045
00046     if (FAILED(CLSIDFromString (wszClsid, pClsid)))
00047         return FALSE;
00048     return TRUE;
00049 }
00050
00051
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SInfo Member List

This is the complete list of members for SInfo, including all inherited members.
wchName | SInfo
wchVersion | SInfo
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/basedialog.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

basedialog.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  BaseDialog.h:  Interface for the CBaseDialog class.  This is the base
00014 //                 class for modeless dialogs.
00015 //
00016
00017
00018 #ifndef _CLASS_BASEDIALOG_
00019 #define _CLASS_BASEDIALOG_
00020
00021 #include <Windows.h>
00022
00023
00024 #if _MSC_VER > 1000
00025 #pragma once
00026 #endif // _MSC_VER > 1000
00027
00028
00029 //---------------------------------------------------------------------------
00030 class CBaseDialog
00031 {
00032   private:
00033     HWND     m_hWnd;         // Handle from CreateDialogParam
00034     ULONG    m_nTemplate;    // Dialog template ID
00035     DLGPROC  m_DlgProc;      // Points to Dialog Proc
00036     DWORD    m_dwFlags;      // Create flags
00037
00038   public:
00039     CBaseDialog( ULONG nTemplate = 0 );
00040     virtual ~CBaseDialog();
00041
00042     virtual HWND Create( HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags = 0 );
00043
00044   protected:
00045     static BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00046
00047     virtual LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00048     virtual LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00049     virtual LRESULT OnCancel( HWND hDlg, WPARAM wParam, LPARAM lParam );
00050     virtual LRESULT OnNcDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam );
00051     virtual LRESULT OnDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam );
00052     virtual LRESULT OnClose( HWND hDlg, WPARAM wParam, LPARAM lParam );
00053
00054   public:
00055     virtual BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) = 0;
00056
00057 };
00058
00059
00060 #endif //_CLASS_BASEDIALOG_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/LogWriter/StdAfx.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest
  • LogWriter

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Start.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

Start.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright 1992 - 1998 Microsoft Corporation
00004 //
00005 //  File:       start.hxx
00006 //
00007 //  Contents:   Start of file element class
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #if !defined( __START_HXX__ )
00012 #define __START_HXX__
00013
00014 #include <htmlelem.hxx>
00015
00016
00017 //+-------------------------------------------------------------------------
00018 //
00019 //  Class:      CStartOfFileElement
00020 //
00021 //  Purpose:    Parsing element at the beginning of an Html file
00022 //
00023 //--------------------------------------------------------------------------
00024
00025 class CStartOfFileElement : public CHtmlElement
00026 {
00027
00028 public:
00029     CStartOfFileElement( CHtmlIFilter& htmlIFilter, CSerialStream& serialStream );
00030
00031     virtual SCODE   GetChunk( STAT_CHUNK *pStat );
00032     virtual SCODE   GetText( ULONG *pcwcBuffer, WCHAR *awcBuffer );
00033
00034     virtual void    InitStatChunk( STAT_CHUNK *pStat );
00035 };
00036
00037
00038 #endif // __START_HXX__
00039
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIAccessor Member List

This is the complete list of members for CImpIAccessor, including all inherited members.
AddRefAccessor(HACCESSOR hAccessor, DBREFCOUNT *pcRefCounts) | CImpIAccessor |
CCommand class | CImpIAccessor | [friend]
CImpIAccessor class | CImpIAccessor | [friend]
CopyAccessors(LPEXTBUFFER pextbufferAccessor) | CImpIAccessor |
CreateAccessor(DBACCESSORFLAGS, DBCOUNTITEM, const DBBINDING rgBindings[], DBLENGTH, HACCESSOR *, DBBINDSTATUS rgStatus[]) | CImpIAccessor |
CRowset class | CImpIAccessor | [friend]
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIAccessor) | CImpIAccessor |
FInit(BOOL fUnderRowset) | CImpIAccessor |
GetBindings(HACCESSOR, DBACCESSORFLAGS *, DBCOUNTITEM *, DBBINDING **) | CImpIAccessor |
m_pextbufferAccessor | CImpIAccessor | [private]
ReleaseAccessor(HACCESSOR, DBREFCOUNT *) | CImpIAccessor |
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/Inc/CpyImage.Idl Source File

  • Com
  • Common
  • Inc

CpyImage.Idl

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 ********************************************************************************
00004 * Filename: CpyImage.idl
00005 *
00006 * Description: IDL source for CpyImage.dll
00007
00008  This file will be processed by the MIDL tool to
00009  produce the type library (CpyImage.tlb) and marshalling code.
00010
00011 *
00012 * This file is provided as part of the Microsoft Transaction Server
00013 * Software Development Kit
00014 *
00015 *THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00016 *WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00017 *INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00018 *OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00019 *PURPOSE.
00020 *
00021 * Copyright (C) 1997 Microsoft Corporation, All rights reserved
00022 ********************************************************************************
00023 \******************************************************************************/
00024
00025
00026 import "oaidl.idl";
00027
00028   [
00029
00030     object,
00031
00032     uuid(F2C67D15-5447-11D0-B152-00AA00BA3258),
00033
00034     dual,
00035
00036     helpstring("ICpyImage Interface"),
00037     pointer_default(unique)
00038   ]
00039   interface ICpyImage : IDispatch
00040   {
00041
00042     [helpstring("Copies a file and inserts the tag data in SQL Server")]
00043     HRESULT InsertData([in] BSTR sFromFile, [in] BSTR sToFile,
00044                [in] BSTR sDescription, [in] BSTR sMainColor,
00045                [in] BSTR sTheme, [out] BSTR * msg);
00046
00047     [helpstring("Commits the Tx")]
00048     HRESULT SetComplete();
00049
00050     [helpstring("Aborts the Tx")]
00051     HRESULT SetAbort();
00052
00053     HRESULT Test([out] BSTR * msg);
00054
00055   };
00056 [
00057   uuid(F2C67D13-5447-11D0-B152-00AA00BA3258),
00058   version(1.0),
00059   helpstring("CpyImage 1.0 Type Library")
00060 ]
00061 library CPYIMAGELib
00062 {
00063   importlib("stdole2.tlb");
00064
00065   [
00066     uuid(F2C67D17-5447-11D0-B152-00AA00BA3258),
00067     helpstring("CpyImage Class")
00068   ]
00069   coclass CpyImage
00070   {
00071     [default] interface ICpyImage;
00072   };
00073 };
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/TextPage.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

TextPage.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      TEXTPAGE.H
00003
00004   Summary:   Include file for the connectable COTextPage COM object class.
00005
00006              COTextPage offers a main standard IUnknown interface (basic
00007              COM object features), an implementation of the standard
00008              IConnectionPointContainer interface (connectable object
00009              features), an implementation of the standard
00010              IPersistStreamInit interface (stream persistent object
00011              features), and an implementation of the custom ITextPage
00012              interface (editable TextPage features). This multiple
00013              interface COM Object Class is achieved via the technique of
00014              nested classes.  The implementation of the various interfaces
00015              are nested inside of the COTextPage Class.
00016
00017              For a comprehensive tutorial code tour of this module's
00018              contents and offerings see the tutorial PERTEXT.HTM file.
00019              For more specific technical details on the internal workings
00020              see the comments dispersed throughout the module's source code.
00021
00022   Functions: .
00023
00024   Classes:   COTextPage.
00025
00026   Origin:    5-20-97: atrent - Editor-inheritance from PAPER.H in
00027              the STOSERVE Tutorial Code Sample.
00028
00029 ----------------------------------------------------------------------------
00030   This file is part of the Microsoft COM Tutorial Code Samples.
00031
00032   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00033
00034   This source code is intended only as a supplement to Microsoft
00035   Development Tools and/or on-line documentation.  See these other
00036   materials for detailed information regarding Microsoft code samples.
00037
00038   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00039   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00040   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00041   PARTICULAR PURPOSE.
00042 ==========================================================================+*/
00043
00044 #if !defined(TEXTPAGE_H)
00045 #define TEXTPAGE_H
00046
00047 #ifdef __cplusplus
00048
00049
00050 // Current format version of TextPage is 1.0. Thus, the format version
00051 // is a compile-time constant.
00052 #define TEXTPAGE_VERSION10 MAKELONG(0,1)
00053
00054 // TextPage allocation sizes for the TextPage.
00055 enum
00056 {
00057   TEXTPAGE_V10_MAX = 32000
00058 };
00059
00060 // Properties of the TextPage.
00061 typedef struct _TEXTPROPS
00062 {
00063   ULONG ulVersion;
00064   ULONG ulMaxLength;
00065   ULONG ulLength;
00066   WCHAR wszTitle[PAGE_TITLE_SIZE];
00067 } TEXTPROPS;
00068
00069
00070 // TextPage event constants.
00071 enum TEXTPAGE_EVENT
00072 {
00073   TEXTPAGE_EVENT_NONE = 0,
00074   TEXTPAGE_EVENT_LOADED,
00075   TEXTPAGE_EVENT_SAVED,
00076   TEXTPAGE_EVENT_PUT,
00077   TEXTPAGE_EVENT_CLEARED
00078 };
00079
00080
00081 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00082   ObjectClass: COTextPage
00083
00084   Summary:     COM object class for COTextPage COM objects.  COM objects
00085                of this class offer custom ITextPage interface features,
00086                GetLength, GetText, PutText, and Clear. To make COTextPage
00087                objects connectable, the standard IConnectionPointContainer
00088                interface features, FindConnectionPoint and
00089                EnumConnectionPoints are also implemented. The mulitple
00090                interfaces on this COM object are constructed via the
00091                nested interface classes technique.
00092
00093   Interfaces:  IUnknown
00094                  Standard interface providing COM object features.
00095                IConnectionPointContainer
00096                  Standard Connection Point container features rendering
00097                  COTextPage objects connectable objects.
00098                IPersistStreamInit
00099                  Standard Stream Persistance features rendering
00100                  COTextPage objects persistent objects.
00101                ITextPage
00102                  Custom interface providing basic TextPage features.
00103
00104   Aggregation: Yes, COTextPage COM Objects are aggregatable by passing
00105                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00106 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00107 class COTextPage : public IUnknown
00108 {
00109   public:
00110     // Main COM Object Constructor & Destructor.
00111     COTextPage(IUnknown* pUnkOuter, CServer* pServer);
00112     ~COTextPage(void);
00113
00114     // A general public method for initializing this newly created
00115     // object. Creates any subordinate arrays, structures, or objects.
00116     // Not exposed as part of an interface. Used by Class Factory.
00117     HRESULT Init(void);
00118
00119     // Main COM Object IUnknown interface. Non-delegating.
00120     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00121     STDMETHODIMP_(ULONG) AddRef(void);
00122     STDMETHODIMP_(ULONG) Release(void);
00123
00124   private:
00125     // We declare nested class interface implementations here.
00126
00127     // Standard Connectable Object features.
00128     class CImpIConnectionPointContainer : public IConnectionPointContainer
00129     {
00130       public:
00131         // Interface Implementation Constructor & Destructor.
00132         CImpIConnectionPointContainer(COTextPage* pCO, IUnknown* pUnkOuter);
00133         ~CImpIConnectionPointContainer(void);
00134
00135         // IUnknown methods.
00136         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00137         STDMETHODIMP_(ULONG) AddRef(void);
00138         STDMETHODIMP_(ULONG) Release(void);
00139
00140         // IConnectionPointContainer methods.
00141         STDMETHODIMP         FindConnectionPoint(REFIID, IConnectionPoint**);
00142         STDMETHODIMP         EnumConnectionPoints(IEnumConnectionPoints**);
00143
00144       private:
00145         // Data private to this interface implementation.
00146         COTextPage*   m_pCO;          // Parent Object back pointer.
00147         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00148     };
00149
00150     // Standard Object Persistence (in Streams) features.
00151     class CImpIPersistStreamInit : public IPersistStreamInit
00152     {
00153       public:
00154         // Interface Implementation Constructor & Destructor.
00155         CImpIPersistStreamInit(COTextPage* pCO, IUnknown* pUnkOuter);
00156         ~CImpIPersistStreamInit(void);
00157
00158         // IUnknown methods.
00159         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00160         STDMETHODIMP_(ULONG) AddRef(void);
00161         STDMETHODIMP_(ULONG) Release(void);
00162
00163         // IPersistStreamInit methods.
00164         STDMETHODIMP         GetClassID(CLSID* pClassID);
00165         STDMETHODIMP         IsDirty(void);
00166         STDMETHODIMP         Load(IStream* pIStream);
00167         STDMETHODIMP         Save(IStream* pIStream, BOOL bClearDirty);
00168         STDMETHODIMP         GetSizeMax(ULARGE_INTEGER* pcbSize);
00169         STDMETHODIMP         InitNew(void);
00170
00171       private:
00172         // Data private to this interface implementation.
00173         COTextPage*   m_pCO;          // Parent Object back pointer.
00174         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00175     };
00176
00177     // Custom Text Entry/Edit page features.
00178     class CImpITextPage : public ITextPage
00179     {
00180       public:
00181         // Interface Implementation Constructor & Destructor.
00182         CImpITextPage(COTextPage* pCO, IUnknown* pUnkOuter);
00183         ~CImpITextPage(void);
00184
00185         // IUnknown methods.
00186         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00187         STDMETHODIMP_(ULONG) AddRef(void);
00188         STDMETHODIMP_(ULONG) Release(void);
00189
00190         // ITextPage methods.
00191         STDMETHODIMP         GetLength(INT* piLength);
00192         STDMETHODIMP         GetText(WCHAR* pwszText);
00193         STDMETHODIMP         PutText(WCHAR* pwszText, INT iLength);
00194         STDMETHODIMP         Clear(BOOL bSaveNeeded);
00195
00196       private:
00197         // Data private to this interface implementation of ITextPage.
00198         COTextPage*   m_pCO;          // Parent Object back pointer.
00199         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00200     };
00201
00202     // Make the otherwise private and nested interface implementations
00203     // friends to instantiations of this COTextPage COM object class.
00204     friend CImpIConnectionPointContainer;
00205     friend CImpIPersistStreamInit;
00206     friend CImpITextPage;
00207
00208     // Private Methods of COTextPage COM objects.
00209
00210     // Method to clear the COTextPage's current page text and reset
00211     // the page properties appropriately.
00212     HRESULT Clear(BOOL bSaveNeeded);
00213
00214     // Method of main connectable COTextPage COM object to broadcast
00215     // event notifications to all connected listening sinks.
00216     HRESULT NotifySinks(TEXTPAGE_EVENT TextPageEvent);
00217
00218     // Private Data of COTextPage COM objects.
00219
00220     // Nested IConnectionPointContainer implementation instantiation.
00221     CImpIConnectionPointContainer m_ImpIConnectionPointContainer;
00222
00223     // Nested IPersistStreamInit implementation instantiation.
00224     CImpIPersistStreamInit m_ImpIPersistStreamInit;
00225
00226     // Nested ITextPage implementation instantiation. This ITextPage
00227     // interface is instantiated as a native interface of COTextPage.
00228     CImpITextPage     m_ImpITextPage;
00229
00230     // Main Object reference count.
00231     ULONG             m_cRefs;
00232
00233     // Outer unknown (aggregation & delegation).
00234     IUnknown*         m_pUnkOuter;
00235
00236     // Pointer to this component server's control object.
00237     CServer*          m_pServer;
00238
00239     // The array of connection points for this connectable COM object.
00240     IConnectionPoint* m_aConnectionPoints[MAX_CONNECTION_POINTS];
00241
00242     // The following private data and methods constitute the working
00243     // heart of COTextPage as an actual application object.
00244     TEXTPROPS         m_TextProps;    // For saving properties in stream.
00245     CLSID             m_ClassID;      // CLSID of this COM Object.
00246     WCHAR*            m_pwszPageText; // The text to edit.
00247     BOOL              m_bInitNew;     // TRUE=>obj newly initialized in RAM.
00248     BOOL              m_bDirty;       // RAM no match file--save needed.
00249 };
00250
00251 #endif // __cplusplus
00252
00253
00254 #endif // TEXTPAGE_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDataGrid Member List

This is the complete list of members for CDataGrid, including all inherited members.
AddRefRows(INDEX iIndex) | CDataGrid | [virtual]
CaptureImage() | CDataGrid |
CDataGrid(CMDIChild *pCMDIChild) | CDataGrid |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
ClearAll(WCHAR *pwszEmptyHeader=NULL) | CDataGrid | [virtual]
ClearFields() | CDataGrid |
ClearSelCols() | CDataGrid |
CListViewLite(HWND hWndParent=NULL, UINT nID=0) | CListViewLite |
ColContaining(float X) | CDataGrid |
Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, CCreateContext *pContext=NULL) | CDataGrid | [inline, virtual]
Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, CFile *pPersist=NULL, BOOL bStorage=FALSE, BSTR bstrLicKey=NULL) | CDataGrid | [inline]
CListViewLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CSplitterLite(HWND hWndParent=NULL, UINT nID=0) | CSplitterLite |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeleteAllItems() | CListViewLite | [inline]
DeleteColumn(INDEX nCol) | CListViewLite | [inline]
DeleteItem(INDEX iItem) | CListViewLite | [inline]
DestroyWindow() | CWndLite | [virtual]
DisplayColumnInfo() | CDataGrid | [virtual]
DisplayData(HROW hRow, INDEX iIndex, DBPROPID dwSourceID=DBPROP_IRowset, bool fAlways=FALSE) | CDataGrid | [virtual]
DisplayFetchPosition(INDEX iIndex, BOOL fLastFetchForward) | CDataGrid | [virtual]
DisplayRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, DBCOUNTITEM cRowsObtained, HROW *rghRows, BOOL fAdjustFetchPosition=TRUE) | CDataGrid | [virtual]
DrawSplitter(HDC hDC, BOOL fVertical, REFRECT rectLeft, REFRECT rectRight, REFPOINTS ptsClient) | CSplitterLite | [virtual]
EditLabel(INDEX iItem) | CListViewLite | [inline]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EnsureVisible(INDEX iItem, bool fPartialOK=FALSE) | CListViewLite | [inline]
GetAddNewMode() | CDataGrid |
GetAllowAddNew() | CDataGrid |
GetAllowArrows() | CDataGrid |
GetAllowDelete() | CDataGrid |
GetAllowRowSizing() | CDataGrid |
GetAllowUpdate() | CDataGrid |
GetAppearance() | CDataGrid |
GetApproxCount() | CDataGrid |
GetBackColor() | CDataGrid |
GetBookmark() | CDataGrid |
GetBookmark(long RowNum) | CDataGrid |
GetBorderStyle() | CDataGrid |
GetCaption() | CDataGrid |
GetClsid() | CDataGrid | [inline]
GetCol() | CDataGrid |
GetColumnHeaders() | CDataGrid |
GetColumns() | CDataGrid |
GetColumnWidth(INDEX nCol) | CListViewLite | [inline]
GetCountPerPage() | CListViewLite | [inline]
GetCurrentCellModified() | CDataGrid |
GetCurrentCellVisible() | CDataGrid |
GetDataChanged() | CDataGrid |
GetDataFormats() | CDataGrid |
GetDataMember() | CDataGrid |
GetDataSource() | CDataGrid |
GetDefColWidth() | CDataGrid |
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetEditActive() | CDataGrid |
GetEnabled() | CDataGrid |
GetErrorText() | CDataGrid |
GetFirstRow() | CDataGrid |
GetFont() | CDataGrid |
GetForeColor() | CDataGrid |
GetHeadFont() | CDataGrid |
GetHeadLines() | CDataGrid |
GetHWnd() | CDataGrid |
GetHWndEditor() | CDataGrid |
GetItemCount() | CListViewLite | [inline]
GetItemImage(INDEX iItem, INDEX iSubItem=0) | CListViewLite |
GetItemParam(INDEX iItem) | CListViewLite |
GetItemState(INDEX iItem, UINT nMask) | CListViewLite | [inline]
GetItemText(INDEX iItem, INDEX iSubItem, WCHAR *wszName, ULONG ulMaxChars) | CListViewLite |
GetLeftCol() | CDataGrid |
GetMarqueeStyle() | CDataGrid |
GetNextItem(INDEX iItem, INT nFlags) | CListViewLite | [inline]
GetNextRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, BOOL fRetry=FALSE) | CDataGrid | [virtual]
GetOptions() | CDataGrid | [virtual]
GetRecordSelectors() | CDataGrid |
GetRightToLeft() | CDataGrid |
GetRow() | CDataGrid |
GetRowDividerStyle() | CDataGrid |
GetRowHeight() | CDataGrid |
GetScrollBars() | CDataGrid |
GetSelBookmarks() | CDataGrid |
GetSelectedRow(HROW *phRow=NULL, BOOL fValidate=TRUE) | CDataGrid | [virtual]
GetSelEndCol() | CDataGrid |
GetSelLength() | CDataGrid |
GetSelStart() | CDataGrid |
GetSelStartCol() | CDataGrid |
GetSelText() | CDataGrid |
GetSplit() | CDataGrid |
GetSplits() | CDataGrid |
GetTabAcrossSplits() | CDataGrid |
GetTabAction() | CDataGrid |
GetText() | CDataGrid |
GetVisibleCols() | CDataGrid |
GetVisibleRows() | CDataGrid |
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
GetWrapCellPointer() | CDataGrid |
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
HitTest(REFPOINTS pts, UINT *pFlags=NULL, BOOL fClientCoords=TRUE) | CListViewLite |
HoldFields() | CDataGrid |
InsertColumn(INDEX iColumn, WCHAR *wszName, INT iImage=IMAGE_NONE) | CListViewLite |
InsertItem(INDEX iItem, INDEX iSubItem, WCHAR *wszName, LPARAM lParam=PARAM_NONE, INT iImage=IMAGE_NONE, UINT iState=IMAGE_NONE, UINT iStateMask=IMAGE_NONE) | CListViewLite |
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_fLastFetchForward | CDataGrid |
m_hCursorOld | CSplitterLite |
m_hCursorRight | CSplitterLite |
m_hCursorTop | CSplitterLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iBorderCX | CSplitterLite |
m_iBorderCY | CSplitterLite |
m_iSelCol | CDataGrid |
m_iSelRow | CDataGrid |
m_lCurPos | CDataGrid |
m_lMaxRows | CDataGrid |
m_nID | CWndLite |
m_pCMDIChild | CDataGrid |
m_pCWndBottom | CSplitterLite |
m_pCWndLeft | CSplitterLite |
m_pCWndRight | CSplitterLite |
m_pCWndTop | CSplitterLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnBorder(REFPOINTS pts, INT iBorder) | CSplitterLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnColumnClick(INT idCtrl, NMLISTVIEW *pNMListView) | CDataGrid | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CDataGrid | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CListViewLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnItemActivate(INT idCtrl, NMLISTVIEW *pNMListView) | CDataGrid | [virtual]
OnItemChanged(INT idCtrl, NMLISTVIEW *pNMListView) | CListViewLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CDataGrid | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CListViewLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CDataGrid | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CDataGrid | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CDataGrid | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
ReBind() | CDataGrid |
Refresh() | CDataGrid |
RefreshData() | CDataGrid | [virtual]
ReleaseHeldRows() | CDataGrid | [virtual]
ReleaseRows(INDEX iIndex, BOOL fOnlyValidRows) | CDataGrid | [virtual]
RestartPosition() | CDataGrid | [virtual]
RowBookmark(short RowNum) | CDataGrid |
RowContaining(float Y) | CDataGrid |
RowTop(short RowNum) | CDataGrid |
Scroll(long Cols, long Rows) | CDataGrid |
ScrollGrid(DBROWCOUNT cItems) | CDataGrid | [virtual]
SetAllowAddNew(BOOL bNewValue) | CDataGrid |
SetAllowArrows(BOOL bNewValue) | CDataGrid |
SetAllowDelete(BOOL bNewValue) | CDataGrid |
SetAllowRowSizing(BOOL bNewValue) | CDataGrid |
SetAllowUpdate(BOOL bNewValue) | CDataGrid |
SetAppearance(long nNewValue) | CDataGrid |
SetBackColor(unsigned long newValue) | CDataGrid |
SetBookmark(const VARIANT &newValue) | CDataGrid |
SetBorderStyle(long nNewValue) | CDataGrid |
SetCaption(LPCTSTR lpszNewValue) | CDataGrid |
SetCol(short nNewValue) | CDataGrid |
SetColumn(INDEX iColumn, WCHAR *wszName, INT iImage=IMAGE_NONE) | CListViewLite |
SetColumnHeaders(BOOL bNewValue) | CDataGrid |
SetColumnWidth(INDEX nCol, INT cx) | CListViewLite | [inline]
SetCurrentCellModified(BOOL bNewValue) | CDataGrid |
SetCurrentCellVisible(BOOL bNewValue) | CDataGrid |
SetDataChanged(BOOL bNewValue) | CDataGrid |
SetDataMember(LPCTSTR lpszNewValue) | CDataGrid |
SetDefColWidth(float newValue) | CDataGrid |
SetEditActive(BOOL bNewValue) | CDataGrid |
SetEnabled(BOOL bNewValue) | CDataGrid |
SetFirstRow(const VARIANT &newValue) | CDataGrid |
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetForeColor(unsigned long newValue) | CDataGrid |
SetHeadLines(float newValue) | CDataGrid |
SetItemImage(INDEX iItem, INDEX iSubItem, INT iImage) | CListViewLite |
SetItemParam(INDEX iItem, INDEX iSubItem, LPARAM lParam) | CListViewLite |
SetItemState(INDEX iItem, INDEX iSubItem, UINT iState, UINT iStateMask) | CListViewLite |
SetItemText(INDEX iItem, INDEX iSubItem, WCHAR *pwszName) | CListViewLite |
SetLeftCol(short nNewValue) | CDataGrid |
SetMarqueeStyle(long nNewValue) | CDataGrid |
SetRecordSelectors(BOOL bNewValue) | CDataGrid |
SetRefDataSource(LPUNKNOWN newValue) | CDataGrid |
SetRefFont(LPDISPATCH newValue) | CDataGrid |
SetRefHeadFont(LPDISPATCH newValue) | CDataGrid |
SetRightToLeft(BOOL bNewValue) | CDataGrid |
SetRow(short nNewValue) | CDataGrid |
SetRowDividerStyle(long nNewValue) | CDataGrid |
SetRowHeight(float newValue) | CDataGrid |
SetScrollBars(long nNewValue) | CDataGrid |
SetSelEndCol(short nNewValue) | CDataGrid |
SetSelLength(long nNewValue) | CDataGrid |
SetSelStart(long nNewValue) | CDataGrid |
SetSelStartCol(short nNewValue) | CDataGrid |
SetSelText(LPCTSTR lpszNewValue) | CDataGrid |
SetSplit(short nNewValue) | CDataGrid |
SetSplitter(CSplitterLite *pCWndTop, CSplitterLite *pCWndBottom=NULL, CSplitterLite *pCWndLeft=NULL, CSplitterLite *pCWndRight=NULL) | CSplitterLite | [virtual]
SetTabAcrossSplits(BOOL bNewValue) | CDataGrid |
SetTabAction(long nNewValue) | CDataGrid |
SetText(LPCTSTR lpszNewValue) | CDataGrid |
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
SetWrapCellPointer(BOOL bNewValue) | CDataGrid |
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SplitContaining(float X, float Y) | CDataGrid |
StartTracking(REFPOINTS ptsScreen, REFRECT rectLeft, REFRECT rectRight, BOOL fVertical, POINT *pPoint) | CSplitterLite | [virtual]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDataGrid() | CDataGrid | [virtual]
~CListViewLite() | CListViewLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/CEnumStorageResource.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

CEnumStorageResource.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      CEnumStorageResource.cpp
00005 //
00006 //  Description:
00007 //      This file contains the definition of the CEnumStorageResource class.
00008 //
00009 //      The class CEnumStorageResource is the enumeration of cluster storage
00010 //      devices.  It implements the IEnumClusCfgManagedResources interface.
00011 //
00012 //  Header File:
00013 //      CEnumStorageResource.h
00014 //
00015 //////////////////////////////////////////////////////////////////////////////
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Include Files
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 #include "stdafx.h"
00022 #include "CEnumStorageResource.h"
00023 #include "SIndexedDisk.h"
00024 #include "WMIHelpers.h"
00025 #include "PropList.h"
00026 #include "InsertionSort.h"
00027
00028 #pragma warning( push )
00029 #include <resapi.h>
00030 #pragma warning( pop )
00031
00032
00033 //////////////////////////////////////////////////////////////////////////////
00034 // CEnumStorageResource class
00035 //////////////////////////////////////////////////////////////////////////////
00036
00037
00038 //////////////////////////////////////////////////////////////////////////////
00039 //++
00040 //
00041 //  CEnumStorageResource::CEnumStorageResource
00042 //
00043 //  Description:
00044 //      Constructor of the CEnumStorageResource class. This initializes
00045 //      the m_cRef variable to 1 instead of 0 to account of possible
00046 //      QueryInterface failure in DllGetClassObject.
00047 //
00048 //  Arguments:
00049 //      None.
00050 //
00051 //  Return Value:
00052 //      None.
00053 //
00054 //--
00055 //////////////////////////////////////////////////////////////////////////////
00056 CEnumStorageResource::CEnumStorageResource( void )
00057     : m_fLoadedDevices( FALSE )
00058 {
00059     m_pIWbemServices = NULL;
00060     m_prgDisks = NULL;
00061     m_idxNext = 0;
00062     m_idxEnumNext = 0;
00063     m_bstrBootDevice = NULL;
00064     m_bstrSystemDevice = NULL;
00065     m_bstrBootLogicalDisk = NULL;
00066     m_bstrSystemLogicalDisk = NULL;
00067     m_bstrSystemWMIDeviceID = NULL;
00068     m_cDiskCount = 0;
00069     m_bstrCrashDumpLogicalDisk = NULL;
00070
00071 } //*** CEnumStorageResource::CEnumStorageResource
00072
00073
00074 //////////////////////////////////////////////////////////////////////////////
00075 //++
00076 //
00077 //  CEnumStorageResource::~CEnumStorageResource
00078 //
00079 //  Description:
00080 //      Desstructor of the CEnumStorageResource class.
00081 //
00082 //  Arguments:
00083 //      None.
00084 //
00085 //  Return Value:
00086 //      None.
00087 //
00088 //--
00089 //////////////////////////////////////////////////////////////////////////////
00090 CEnumStorageResource::~CEnumStorageResource( void )
00091 {
00092     ULONG   idx;
00093
00094     if ( m_pIWbemServices != NULL )
00095     {
00096         m_pIWbemServices->Release();
00097     } // if:
00098
00099     for ( idx = 0; idx < m_idxNext; idx++ )
00100     {
00101         //
00102         //  Sparse array so we need to check for NULL...
00103         //
00104
00105         if ( (*m_prgDisks)[ idx ] != NULL )
00106         {
00107             ((*m_prgDisks)[ idx ])->Release();
00108         } // end if: is there a pointer at the index?
00109     } // for: each index in the array...
00110
00111     HeapFree( GetProcessHeap(), 0, m_prgDisks );
00112
00113     SysFreeString( m_bstrBootDevice );
00114     SysFreeString( m_bstrSystemDevice );
00115     SysFreeString( m_bstrBootLogicalDisk );
00116     SysFreeString( m_bstrSystemLogicalDisk );
00117     SysFreeString( m_bstrSystemWMIDeviceID );
00118     SysFreeString( m_bstrCrashDumpLogicalDisk );
00119
00120 } //*** CEnumStorageResource::~CEnumStorageResource
00121
00122
00123 //////////////////////////////////////////////////////////////////////////////
00124 // CEnumStorageResource -- IClusCfgInitialize interface.
00125 //////////////////////////////////////////////////////////////////////////////
00126
00127
00128 //////////////////////////////////////////////////////////////////////////////
00129 //++
00130 //
00131 //  CEnumStorageResource::Initialize
00132 //
00133 //  Description:
00134 //      Initialize this component.
00135 //
00136 //  Arguments:
00137 //      punkCallbackIn
00138 //          Interface on which to query for the IClusCfgCallback interface.
00139 //
00140 //      lcidIn
00141 //          Locale ID.
00142 //
00143 //  Return Value:
00144 //      S_OK            - Success
00145 //      E_POINTER       - Expected pointer argument specified as NULL.
00146 //      E_OUTOFMEMORY   - Error allocating memory.
00147 //      Other HRESULTs.
00148 //
00149 //--
00150 //////////////////////////////////////////////////////////////////////////////
00151 STDMETHODIMP
00152 CEnumStorageResource::Initialize(
00153       IUnknown *    punkCallbackIn
00154     , LCID          lcidIn
00155     )
00156 {
00157     HRESULT         hr = S_OK;
00158     IWbemServices * pIWbemServices = NULL;
00159
00160     //
00161     // Initialize the base class.
00162     //
00163
00164     hr = CMgdClusCfgInit::Initialize( punkCallbackIn, lcidIn );
00165     if ( FAILED( hr ) )
00166     {
00167         //
00168         //  Base class will log the error if possible.
00169         //
00170
00171         goto Cleanup;
00172     } // if: base classs initialization failed
00173
00174     //
00175     // Do custom initialization - get a handle to the WBEM service.
00176     //
00177
00178     hr = HrInitializeWbemConnection( &pIWbemServices );
00179     if ( FAILED( hr ) )
00180     {
00181         STATUS_REPORT_REF(
00182                       TASKID_Major_Find_Devices
00183                     , TASKID_Minor_InitWbem_Enum_StorageResource
00184                     , IDS_ERROR_WBEM_CONNECTION_FAILURE
00185                     , IDS_ERROR_WBEM_CONNECTION_FAILURE_REF
00186                     , hr
00187                     );
00188         goto Cleanup;
00189     } // if: HrInitializeWbemConnection failed
00190
00191     hr = SetWbemServices( pIWbemServices );
00192     if ( FAILED( hr ) )
00193     {
00194         STATUS_REPORT_REF(
00195                       TASKID_Major_Find_Devices
00196                     , TASKID_Minor_InitWbem_Enum_StorageResource
00197                     , IDS_ERROR_WBEM_CONNECTION_FAILURE
00198                     , IDS_ERROR_WBEM_CONNECTION_FAILURE_REF
00199                     , hr
00200                     );
00201         goto Cleanup;
00202     } // if: SetWbemServices failed
00203
00204     hr = HrGetSystemDevice( &m_bstrSystemDevice );
00205     if ( FAILED( hr ) )
00206     {
00207         goto Cleanup;
00208     } // if:
00209
00210     hr = HrConvertDeviceVolumeToLogicalDisk( m_bstrSystemDevice, &m_bstrSystemLogicalDisk );
00211     if ( HRESULT_CODE( hr ) == ERROR_INVALID_FUNCTION )
00212     {
00213
00214         //
00215         // System volume is an EFI volume on IA64 and won't have a logical disk.
00216         //
00217
00218         hr = HrConvertDeviceVolumeToWMIDeviceID( m_bstrSystemDevice, &m_bstrSystemWMIDeviceID );
00219         assert( m_bstrSystemLogicalDisk == NULL );
00220         assert( m_bstrSystemWMIDeviceID != NULL );
00221     } // if:
00222
00223     if ( FAILED( hr ) )
00224     {
00225         goto Cleanup;
00226     } // if:
00227
00228     hr = HrGetBootLogicalDisk( &m_bstrBootLogicalDisk );
00229     if ( FAILED( hr ) )
00230     {
00231         goto Cleanup;
00232     } // if:
00233
00234     hr = HrIsLogicalDiskNTFS( m_bstrBootLogicalDisk );
00235     if ( hr == S_FALSE )
00236     {
00237         STATUS_REPORT_REF(
00238                   TASKID_Major_Find_Devices
00239                 , TASKID_Minor_Boot_Partition_Not_NTFS
00240                 , IDS_WARN_BOOT_PARTITION_NOT_NTFS
00241                 , IDS_WARN_BOOT_PARTITION_NOT_NTFS_REF
00242                 , hr
00243                 );
00244         hr = S_OK;
00245     } // if:
00246
00247     hr = HrGetCrashDumpLogicalDisk( &m_bstrCrashDumpLogicalDisk );
00248     if ( FAILED( hr ) )
00249     {
00250         goto Cleanup;
00251     } // if:
00252
00253 Cleanup:
00254
00255     if ( pIWbemServices != NULL )
00256     {
00257         pIWbemServices->Release();
00258     } // if:
00259
00260     return hr;
00261
00262 } //*** CEnumStorageResource::Initialize
00263
00264
00265 //////////////////////////////////////////////////////////////////////////////
00266 // CEnumStorageResource -- IWMIService interface.
00267 //////////////////////////////////////////////////////////////////////////////
00268
00269
00270 //////////////////////////////////////////////////////////////////////////////
00271 //++
00272 //
00273 //  CEnumStorageResource::SetWbemServices
00274 //
00275 //  Description:
00276 //      Set the WBEM services provider.
00277 //
00278 //  Arguments:
00279 //    IN  IWbemServices  pIWbemServicesIn
00280 //
00281 //  Return Value:
00282 //      S_OK
00283 //          Success
00284 //
00285 //      E_POINTER
00286 //          The pIWbemServicesIn param is NULL.
00287 //
00288 //--
00289 //////////////////////////////////////////////////////////////////////////////
00290 STDMETHODIMP
00291 CEnumStorageResource::SetWbemServices(
00292     IWbemServices * pIWbemServicesIn
00293     )
00294 {
00295     HRESULT hr = S_OK;
00296
00297     //
00298     // Make sure required arguments were specified.
00299     //
00300
00301     if ( pIWbemServicesIn == NULL )
00302     {
00303         hr = E_POINTER;
00304         STATUS_REPORT_REF(
00305               TASKID_Major_Find_Devices
00306             , TASKID_Minor_SetWbemServices_Enum_StorageResource
00307             , IDS_ERROR_NULL_POINTER
00308             , IDS_ERROR_NULL_POINTER_REF
00309             , hr
00310             );
00311         goto Cleanup;
00312     } // if:
00313
00314     m_pIWbemServices = pIWbemServicesIn;
00315     m_pIWbemServices->AddRef();
00316
00317 Cleanup:
00318
00319     return hr;
00320
00321 } //*** CEnumStorageResource::SetWbemServices
00322
00323
00324 //////////////////////////////////////////////////////////////////////////////
00325 // CEnumStorageResource -- IEnumClusCfgManagedResources interface.
00326 //////////////////////////////////////////////////////////////////////////////
00327
00328
00329 //////////////////////////////////////////////////////////////////////////////
00330 //++
00331 //
00332 //  CEnumStorageResource::Next
00333 //
00334 //  Description:
00335 //      Get the next set of objects in the enumeration.
00336 //
00337 //  Arguments:
00338 //      cNumberRequestedIn
00339 //          Number of objects the caller is requesting to be returned.
00340 //
00341 //      rgpManagedResourceInfoOut
00342 //          An array of pointers in which to return the objects from the
00343 //          enumeration.
00344 //
00345 //      pcNumberFetchedOut
00346 //          The number of objects returned in rgpManagedResourceInfoOut.
00347 //
00348 //  Return Value:
00349 //      S_OK
00350 //          The number of objects requested was returned.
00351 //
00352 //      S_FALSE
00353 //          The number of objects requested was NOT returned.
00354 //          pcNumberFetchedOut should be checked to determine the number of
00355 //          objects that were actually returned.
00356 //
00357 //      E_POINTER
00358 //          Required output arguments were not specified.
00359 //
00360 //      Other HRESULTs.
00361 //
00362 //  Remarks:
00363 //
00364 //  This is the entry point were the real work of this enumerator is done.
00365 //  COM enumerators have few entry points so you will need to be careful
00366 //  with loading them.  We have chosen to make this one a lazy load
00367 //  enumerator so the first call to this method will load the data.
00368 //
00369 //  This method is one where you will place the code that know how to
00370 //  find and load your resource (device) type.
00371 //
00372 //--
00373 //////////////////////////////////////////////////////////////////////////////
00374 STDMETHODIMP
00375 CEnumStorageResource::Next(
00376       ULONG                             cNumberRequestedIn
00377     , IClusCfgManagedResourceInfo **    rgpManagedResourceInfoOut
00378     , ULONG *                           pcNumberFetchedOut
00379     )
00380 {
00381     HRESULT                         hr = S_FALSE;
00382     ULONG                           cFetched = 0;
00383     IClusCfgManagedResourceInfo *   pccsdi;
00384     IUnknown *                      punk;
00385     ULONG                           ulStop;
00386
00387     //
00388     // Make sure required arguments were specified.
00389     //
00390
00391     if ( rgpManagedResourceInfoOut == NULL )
00392     {
00393         hr = E_POINTER;
00394         STATUS_REPORT_REF(
00395               TASKID_Major_Find_Devices
00396             , TASKID_Minor_Next_Enum_StorageResource
00397             , IDS_ERROR_NULL_POINTER
00398             , IDS_ERROR_NULL_POINTER_REF
00399             , hr
00400             );
00401         goto Cleanup;
00402     } // if:
00403
00404     //
00405     //  TODO:
00406     //
00407     //  Replace the following sample code with code that finds and loads your
00408     //  resources (device) of your resource type.
00409     //
00410
00411     //
00412     // Load the enumeration if not already done.
00413     //
00414
00415     if ( m_fLoadedDevices == FALSE )
00416     {
00417         hr = HrLoadEnum();
00418         if ( FAILED( hr ) )
00419         {
00420             goto Cleanup;
00421         } // if:
00422     } // if: enumeration not loaded yet
00423
00424     //
00425     // Return the number of objects requested by the caller in the
00426     // caller's pointer array.
00427     //
00428
00429     ulStop = min( cNumberRequestedIn, ( m_idxNext - m_idxEnumNext ) );
00430
00431     for ( hr = S_OK; ( cFetched < ulStop ) && ( m_idxEnumNext < m_idxNext ); m_idxEnumNext++ )
00432     {
00433         //
00434         //  This is a sparse array...
00435         //
00436
00437         punk = (*m_prgDisks)[ m_idxEnumNext ];
00438         if ( punk != NULL )
00439         {
00440             hr = punk->TypeSafeQI( IClusCfgManagedResourceInfo, &pccsdi );
00441             if ( FAILED( hr ) )
00442             {
00443                 break;
00444             } // if:
00445
00446             rgpManagedResourceInfoOut[ cFetched++ ] = pccsdi;
00447         } // if: entry found in the enumeration
00448     } // for: each resource to be returned to the caller
00449
00450     //
00451     // If a failure occurs, release the objects that have already been added
00452     // to the caller's pointer array.
00453     //
00454
00455     if ( FAILED( hr ) )
00456     {
00457         //
00458         //  Back up the enum index
00459         //
00460
00461         m_idxEnumNext -= cFetched;
00462
00463         while ( cFetched != 0 )
00464         {
00465             (rgpManagedResourceInfoOut[ --cFetched ])->Release();
00466             rgpManagedResourceInfoOut[ cFetched ] = NULL;
00467         } // for: each pointer in the out array
00468
00469         goto Cleanup;
00470     } // if: failure occurred getting objects from the enumeration
00471
00472     //
00473     //  If the number returned is less than the number requested then we must
00474     //  return S_FALSE -- even if we are out of data.  That is the contract
00475     //  that we have as a COM enumerator...
00476     //
00477
00478     if ( cFetched < cNumberRequestedIn )
00479     {
00480         hr = S_FALSE;
00481     } // if:
00482
00483 Cleanup:
00484
00485     if ( pcNumberFetchedOut != NULL )
00486     {
00487         *pcNumberFetchedOut = cFetched;
00488     } // if:
00489
00490     return hr;
00491
00492 } //*** CEnumStorageResource::Next
00493
00494
00495 //////////////////////////////////////////////////////////////////////////////
00496 //++
00497 //
00498 //  CEnumStorageResource::Skip
00499 //
00500 //  Description:
00501 //      Skip the specified number of objects in the enumeration.
00502 //
00503 //  Arguments:
00504 //      cNumberToSkipIn - Number of objects to skip.
00505 //
00506 //  Return Value:
00507 //      S_OK        - Operation completed successfully.
00508 //      S_FALSE     - Fewer than the requested number of objects were skipped.
00509 //
00510 //--
00511 //////////////////////////////////////////////////////////////////////////////
00512 STDMETHODIMP
00513 CEnumStorageResource::Skip(
00514     ULONG cNumberToSkipIn
00515     )
00516 {
00517     HRESULT hr = S_OK;
00518
00519     m_idxEnumNext += cNumberToSkipIn;
00520     if ( m_idxEnumNext >= m_idxNext )
00521     {
00522         //
00523         //  Could not skip the full amount...  Set the enum index to the end
00524         //  of the data and return S_FALSE.
00525         //
00526
00527         m_idxEnumNext = m_idxNext;
00528         hr = S_FALSE;
00529     } // if:
00530
00531     return hr;
00532
00533 } //*** CEnumStorageResource::Skip
00534
00535
00536 //////////////////////////////////////////////////////////////////////////////
00537 //++
00538 //
00539 //  CEnumStorageResource::Reset
00540 //
00541 //  Description:
00542 //      Reset to the beginning of the enumeration.
00543 //
00544 //  Arguments:
00545 //      None.
00546 //
00547 //  Return Value:
00548 //      S_OK    - Operation completed successfully.
00549 //
00550 //--
00551 //////////////////////////////////////////////////////////////////////////////
00552 STDMETHODIMP
00553 CEnumStorageResource::Reset( void )
00554 {
00555     m_idxEnumNext = 0;
00556
00557     return S_OK;
00558
00559 } //*** CEnumStorageResource::Reset
00560
00561
00562 //////////////////////////////////////////////////////////////////////////////
00563 //++
00564 //
00565 //  CEnumStorageResource::Clone
00566 //
00567 //  Description:
00568 //      Perform a deep copy of the enumeration.
00569 //
00570 //  Arguments:
00571 //      ppEnumClusCfgStorageDevicesOut
00572 //          Pointer to clone of enumeration interface.
00573 //
00574 //  Return Value:
00575 //      S_OK        - Operation completed successfully.
00576 //      E_POINTER   - Required output argument not specified.
00577 //      E_NOTIMPL   - Operation not implemented or supported.
00578 //
00579 //--
00580 //////////////////////////////////////////////////////////////////////////////
00581 STDMETHODIMP
00582 CEnumStorageResource::Clone(
00583     IEnumClusCfgManagedResources ** ppEnumClusCfgStorageDevicesOut
00584     )
00585 {
00586     HRESULT hr = S_OK;
00587
00588     //
00589     // Make sure required arguments were specified.
00590     //
00591
00592     if ( ppEnumClusCfgStorageDevicesOut == NULL )
00593     {
00594         hr = E_POINTER;
00595         STATUS_REPORT_REF(
00596               TASKID_Major_Find_Devices
00597             , TASKID_Minor_Clone_Enum_StorageResource
00598             , IDS_ERROR_NULL_POINTER
00599             , IDS_ERROR_NULL_POINTER_REF
00600             , hr
00601             );
00602         goto Cleanup;
00603     } // if:
00604
00605     //
00606     // TODO: perform a deep copy of the objects in the enumeration.
00607     //
00608
00609     hr = E_NOTIMPL;
00610
00611 Cleanup:
00612
00613     return hr;
00614
00615 } //*** CEnumStorageResource::Clone
00616
00617
00618 //////////////////////////////////////////////////////////////////////////////
00619 //++
00620 //
00621 //  CEnumStorageResource::Count
00622 //
00623 //  Description:
00624 //      Return the count of items in the enumeration.
00625 //
00626 //  Arguments:
00627 //      pnCountOut  - The number of items in the enumeration.
00628 //
00629 //  Return Value:
00630 //      S_OK        - Operation completed successfully.
00631 //      E_POINTER   - Required argument not specified.
00632 //      Other HRESULTs.
00633 //
00634 //  Remarks:
00635 //      This is not a standard COM enumerator method, but it is required of
00636 //      ClusCfg plug in components.
00637 //
00638 //--
00639 //////////////////////////////////////////////////////////////////////////////
00640 STDMETHODIMP
00641 CEnumStorageResource::Count( DWORD * pnCountOut )
00642 {
00643     HRESULT hr = S_OK;
00644
00645     //
00646     // Make sure required arguments were specified.
00647     //
00648
00649     if ( pnCountOut == NULL )
00650     {
00651         hr = E_POINTER;
00652         goto Cleanup;
00653     } // if:
00654
00655     //
00656     // Load the enumeration if not already done.
00657     //
00658
00659     if ( m_fLoadedDevices == FALSE )
00660     {
00661         hr = HrLoadEnum();
00662         if ( FAILED( hr ) )
00663         {
00664             goto Cleanup;
00665         } // if:
00666     } // if:
00667
00668     //
00669     // Return the number of items in the enumeration.
00670     //
00671
00672     *pnCountOut = m_cDiskCount;
00673
00674 Cleanup:
00675
00676     return hr;
00677
00678 } //*** CEnumStorageResource::Count
00679
00680
00681 //////////////////////////////////////////////////////////////////////////////
00682 // CEnumStorageResource class -- Private Methods.
00683 //////////////////////////////////////////////////////////////////////////////
00684
00685
00686 //////////////////////////////////////////////////////////////////////////////
00687 //++
00688 //
00689 //  CEnumStorageResource::HrGetDisks
00690 //
00691 //  Description:
00692 //      Load the enumeration.
00693 //
00694 //  Arguments:
00695 //      None.
00696 //
00697 //  Return Value:
00698 //      S_OK            - Operation completed successfully.
00699 //      E_OUTOFMEMORY   - Error allocating memory.
00700 //      Other HRESULTs.
00701 //
00702 //  Remarks:
00703 //      This method is an example of finding and processing physical disks
00704 //      using WMI.  You are not expected to use this in your specific
00705 //      ClusCfg managed resource plug in.
00706 //
00707 //--
00708 //////////////////////////////////////////////////////////////////////////////
00709 HRESULT
00710 CEnumStorageResource::HrGetDisks( void )
00711 {
00712     HRESULT                 hr = S_OK;
00713     BSTR                    bstrClass;
00714     IEnumWbemClassObject *  piewcoDisks = NULL;
00715     ULONG                   ulReturned;
00716     IWbemClassObject *      piwcoDisk = NULL;
00717
00718     //
00719     // Create the WMI class string for creating the enumeration.
00720     //
00721
00722     bstrClass = SysAllocString( L"Win32_DiskDrive" );
00723     if ( bstrClass == NULL )
00724     {
00725         hr = E_OUTOFMEMORY;
00726         STATUS_REPORT_REF(
00727               TASKID_Major_Find_Devices
00728             , TASKID_Minor_HrGetDisks
00729             , IDS_ERROR_OUTOFMEMORY
00730             , IDS_ERROR_OUTOFMEMORY_REF
00731             , hr
00732             );
00733         goto Cleanup;
00734     } // if:
00735
00736     //
00737     // Create the enumeration by querying WMI for objects of the specified class.
00738     //
00739
00740     hr = m_pIWbemServices->CreateInstanceEnum( bstrClass, WBEM_FLAG_SHALLOW, NULL, &piewcoDisks );
00741     if ( FAILED( hr ) )
00742     {
00743         goto Cleanup;
00744     } // if:
00745
00746     //
00747     // Loop through the enumeration returned from WMI and add objects to our
00748     // enumeration if they meet our criteria.
00749     //
00750
00751     for ( ; ; )
00752     {
00753         hr = piewcoDisks->Next( WBEM_INFINITE, 1, &piwcoDisk, &ulReturned );
00754         if ( ( hr == S_OK ) && ( ulReturned == 1 ) )
00755         {
00756             //
00757             // Log information about this item to the log file.
00758             //
00759
00760             hr = HrLogDiskInfo( piwcoDisk );
00761             if ( FAILED( hr ) )
00762             {
00763                 goto Cleanup;
00764             } // if:
00765
00766             //
00767             // Find out if this is a SCSI disk or not.  Only add the disk
00768             // if it is a SCSI disk.
00769             //
00770             // TODO: Determine if this is valid for your storage resource.
00771             //
00772
00773             hr = IsDiskSCSI( piwcoDisk );
00774             if ( FAILED( hr ) )
00775             {
00776                 goto Cleanup;
00777             } // if: failed to get SCSI info about disk
00778
00779             //
00780             // Create a local copy of the disk info and add it to our array
00781             // if it is a SCSI disk.
00782             //
00783
00784             if ( hr == S_OK )
00785             {
00786                 hr = HrProcessWMIDiskObject( piwcoDisk );
00787                 if ( FAILED( hr ) )
00788                 {
00789                     goto Cleanup;
00790                 } // if: failed to create and add disk to the array
00791             } // if: disk is SCSI
00792
00793             piwcoDisk->Release();
00794             piwcoDisk = NULL;
00795         } // if: an object was returned
00796         else if ( ( hr == S_FALSE ) && ( ulReturned == 0 ) )
00797         {
00798             hr = S_OK;
00799             break;
00800         } // else if: no objects returned
00801         else
00802         {
00803             STATUS_REPORT_STRING_REF(
00804                       TASKID_Major_Find_Devices
00805                     , TASKID_Minor_WQL_Disk_Qry_Next_Failed
00806                     , IDS_ERROR_WQL_QRY_NEXT_FAILED
00807                     , bstrClass
00808                     , IDS_ERROR_WQL_QRY_NEXT_FAILED_REF
00809                     , hr
00810                     );
00811             goto Cleanup;
00812         } // else: error getting next object
00813     } // for: ever
00814
00815     //
00816     // Reset the enumeration index to the beginning and indicate that we have
00817     // loaded the enumeration.
00818     //
00819
00820     m_idxEnumNext = 0;
00821     m_fLoadedDevices = TRUE;
00822
00823 Cleanup:
00824
00825     if ( piwcoDisk != NULL )
00826     {
00827         piwcoDisk->Release();
00828     } // if:
00829
00830     if ( piewcoDisks != NULL )
00831     {
00832         piewcoDisks->Release();
00833     } // if:
00834
00835     SysFreeString( bstrClass );
00836
00837     return hr;
00838
00839 } //*** CEnumStorageResource::HrGetDisks
00840
00841
00842 /////////////////////////////////////////////////////////////////////////////
00843 //++
00844 //
00845 //  CEnumStorageResource::HrProcessWMIDiskObject
00846 //
00847 //  Description:
00848 //      Create an CStorageResource object from the passed in WMI disk object
00849 //      and add it to the array of punks.
00850 //
00851 //  Arguments:
00852 //      pDiskIn         - WMI disk to create from.
00853 //
00854 //  Return Value:
00855 //      S_OK            - Operation was successful.
00856 //      E_OUTOFMEMORY   - Error allocating memory.
00857 //
00858 //--
00859 //////////////////////////////////////////////////////////////////////////////
00860 HRESULT
00861 CEnumStorageResource::HrProcessWMIDiskObject(
00862     IWbemClassObject * pDiskIn
00863     )
00864 {
00865     assert( m_pIWbemServices != NULL );
00866
00867     HRESULT             hr = S_FALSE;
00868     IUnknown *          punk = NULL;
00869     IWMIObject *        piwo = NULL;
00870     BOOL                fRetainObject = TRUE;
00871
00872     //
00873     // Create an instance of the CStorageResource object.
00874     //
00875
00876     hr = CoCreateInstance( CLSID_CStorageResource, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, reinterpret_cast< void ** >( &punk ) );
00877     if ( FAILED( hr ) )
00878     {
00879         goto Cleanup;
00880     } // if:
00881
00882     assert( punk != NULL );
00883
00884     //
00885     // Initialize the newly created object.
00886     //
00887
00888     hr = HrSetInitialize( punk, GetCallback(), GetLCID() );
00889     if ( FAILED( hr ) )
00890     {
00891         goto Cleanup;
00892     } // if:
00893
00894     hr = HrSetWbemServices( punk, m_pIWbemServices );
00895     if ( FAILED( hr ) )
00896     {
00897         goto Cleanup;
00898     } // if:
00899
00900     hr = punk->TypeSafeQI( IWMIObject, &piwo );
00901     if ( FAILED( hr ) )
00902     {
00903         goto Cleanup;
00904     } // if:
00905
00906     assert( piwo != NULL );
00907
00908     hr = piwo->SetWbemObject( pDiskIn, &fRetainObject );
00909     if ( FAILED( hr ) )
00910     {
00911         goto Cleanup;
00912     } // if:
00913
00914     if ( fRetainObject )
00915     {
00916         hr = HrAddObjectToArray( punk );
00917     } // if:
00918
00919 Cleanup:
00920
00921     if ( piwo != NULL )
00922     {
00923         piwo->Release();
00924     } // if:
00925
00926     if ( punk != NULL )
00927     {
00928         punk->Release();
00929     } // if:
00930
00931     return hr;
00932
00933 } //*** CEnumStorageResource::HrProcessWMIDiskObject
00934
00935
00936 /////////////////////////////////////////////////////////////////////////////
00937 //++
00938 //
00939 //  CEnumStorageResource::HrPruneSystemDisks
00940 //
00941 //  Description:
00942 //      Prune all system disks from the list.  System disks are disks that
00943 //      are booted, are running the OS, have page files, have hibernation
00944 //      files, or have crash dumps on them.
00945 //
00946 //  Arguments:
00947 //      None.
00948 //
00949 //  Return Value:
00950 //      S_OK    - Operation was successful.
00951 //      Other HRESULTs.
00952 //
00953 //--
00954 //////////////////////////////////////////////////////////////////////////////
00955 HRESULT
00956 CEnumStorageResource::HrPruneSystemDisks( void )
00957 {
00958     assert( m_bstrSystemLogicalDisk != NULL );
00959     assert( m_bstrBootLogicalDisk != NULL );
00960
00961     HRESULT                 hr = S_OK;
00962     ULONG                   idx;
00963     ULONG                   ulSCSIBus;
00964     ULONG                   ulSCSIPort;
00965     IStorageProperties *    piccpdp = NULL;
00966     IUnknown *              punk = NULL;
00967     ULONG                   cRemoved = 0;
00968     ULONG                   cTemp = 0;
00969     BOOL                    fSystemAndBootTheSame;
00970     BOOL                    fPruneBus = FALSE;
00971
00972     //
00973     //  Minor optimization when the system and boot disk are the same disk.
00974     //
00975
00976     fSystemAndBootTheSame =   ( m_bstrSystemLogicalDisk != NULL )
00977                             ? ( m_bstrBootLogicalDisk[ 0 ] == m_bstrSystemLogicalDisk[ 0 ] )
00978                             : FALSE;
00979
00980     //
00981     //  The system bus is usually not managed.  It is managed when a registry
00982     //  entry has been made to make it managed.  It is usually done when the
00983     //  system bus is a storage area network.
00984     //
00985     //  NB:
00986     //      This is only applicable to physical disks.  Your custom resource
00987     //      type will most likely not care about this.
00988     //
00989
00990     hr = HrIsSystemBusManaged();
00991     if ( FAILED( hr ) )
00992     {
00993         goto Cleanup;
00994     } // if:
00995
00996     //
00997     //  If the system bus is not managed then we need to prune the disks on those buses
00998     //  that contain system, boot, and pagefile disks.
00999     //
01000
01001     fPruneBus = ( hr == S_FALSE );
01002
01003     //
01004     //  Prune the disks on the system buses.  If the system disks are IDE they won't
01005     //  be in the list.
01006     //
01007
01008     //
01009     //  Find the boot disk(s).  Could be a volume with more than one disk.
01010     //
01011
01012     for ( ; ; )
01013     {
01014         hr = HrFindDiskWithLogicalDisk( m_bstrBootLogicalDisk[ 0 ], &idx );
01015         if ( FAILED( hr ) )
01016         {
01017             goto Cleanup;
01018         } // if:
01019
01020         if ( hr == S_OK )
01021         {
01022
01023             //
01024             //  Should we prune the whole bus, or just the boot disk itself?
01025             //  Typically we need to prune the entire bus, but when the
01026             //  special registry entry tells us not to then we only prune the
01027             //  spindles themselves.
01028             //
01029
01030             if ( fPruneBus )
01031             {
01032                 hr = HrGetSCSIInfo( idx, &ulSCSIBus, &ulSCSIPort );
01033                 if ( FAILED( hr ) )
01034                 {
01035                     goto Cleanup;
01036                 } // if:
01037
01038                 //
01039                 //  Tell the UI that we are pruning the boot disk bus...
01040                 //
01041
01042                 STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_Pruning_Boot_Disk_Bus, IDS_INFO_PRUNING_BOOTDISK_BUS, hr );
01043                 hr = HrPruneDisks(
01044                                   ulSCSIBus
01045                                 , ulSCSIPort
01046                                 , &TASKID_Minor_Pruning_Boot_Disk_Bus
01047                                 , IDS_INFO_BOOTDISK_PRUNED
01048                                 , IDS_INFO_BOOTDISK_PRUNED_REF
01049                                 , &cTemp
01050                                 );
01051                 if ( FAILED( hr ) )
01052                 {
01053                     goto Cleanup;
01054                 } // if:
01055
01056                 cRemoved += cTemp;
01057             } // if: prune all disks from the boot disk SCSI bus
01058             else
01059             {
01060                 RemoveDiskFromArray( idx );
01061                 cRemoved++;
01062             } // else: only prune boot disk
01063
01064             continue;
01065         } // if:
01066
01067         break;
01068     } // for: each volume in the logical disk
01069
01070     //
01071     //  Prune the system disk bus if it is not the same as the boot disk bus.
01072     //
01073
01074     if ( fSystemAndBootTheSame == FALSE )
01075     {
01076         if ( m_bstrSystemLogicalDisk != NULL )
01077         {
01078             assert( m_bstrSystemWMIDeviceID == NULL );
01079             hr = HrFindDiskWithLogicalDisk( m_bstrSystemLogicalDisk[ 0 ], &idx );
01080         } // if:
01081         else
01082         {
01083             assert( m_bstrSystemLogicalDisk == NULL );
01084             hr = HrFindDiskWithWMIDeviceID( m_bstrSystemWMIDeviceID, &idx );
01085         } // else:
01086
01087         if ( FAILED( hr ) )
01088         {
01089             goto Cleanup;
01090         } // if:
01091
01092         if ( hr == S_OK )
01093         {
01094             //
01095             //  Should we prune the whole bus, or just the system disk itself?
01096             //
01097
01098             if ( fPruneBus )
01099             {
01100                 hr = HrGetSCSIInfo( idx, &ulSCSIBus, &ulSCSIPort );
01101                 if ( FAILED( hr ) )
01102                 {
01103                     goto Cleanup;
01104                 } // if:
01105
01106                 //
01107                 //  Tell the UI that we are pruning the system disk bus...
01108                 //
01109
01110                 STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_Pruning_System_Disk_Bus, IDS_INFO_PRUNING_SYSTEMDISK_BUS, hr );
01111                 hr = HrPruneDisks(
01112                                   ulSCSIBus
01113                                 , ulSCSIPort
01114                                 , &TASKID_Minor_Pruning_System_Disk_Bus
01115                                 , IDS_INFO_SYSTEMDISK_PRUNED
01116                                 , IDS_INFO_SYSTEMDISK_PRUNED_REF
01117                                 , &cTemp
01118                                 );
01119                 if ( FAILED( hr ) )
01120                 {
01121                     goto Cleanup;
01122                 } // if:
01123
01124                 cRemoved += cTemp;
01125             } // if: prune system disk bus
01126             else
01127             {
01128                 RemoveDiskFromArray( idx );
01129                 cRemoved++;
01130             } // else: only prune the system disk
01131         } // if:
01132     } // if:
01133
01134     //
01135     //  Now prune the busses that have page file disks on them.
01136     //
01137
01138     hr = HrPrunePageFileDiskBuses( fPruneBus, &cTemp );
01139     if ( FAILED( hr ) )
01140     {
01141         goto Cleanup;
01142     } // if:
01143
01144     cRemoved += cTemp;
01145
01146     //
01147     //  Now prune the bus that has a crash dump file disk.
01148     //
01149
01150     hr = HrPruneCrashDumpBus( fPruneBus, &cTemp );
01151     if ( FAILED( hr ) )
01152     {
01153         goto Cleanup;
01154     } // if:
01155
01156     cRemoved += cTemp;
01157
01158     //
01159     //  Now prune the off any remaining dynamic disks.  Dynamic disks cannot
01160     //  be physical disks.  There may be a different plug in component that
01161     //  managed those disks.
01162     //
01163
01164     hr = HrPruneDynamicDisks( &cTemp );
01165     if ( FAILED( hr ) )
01166     {
01167         goto Cleanup;
01168     } // if:
01169
01170     cRemoved += cTemp;
01171
01172     //
01173     //  Now prune the off any remaining GPT disks.  GPT disks are not
01174     //  compatible with clustering at this time.
01175     //
01176
01177     hr = HrPruneGPTDisks( &cTemp );
01178     if ( FAILED( hr ) )
01179     {
01180         goto Cleanup;
01181     } // if:
01182
01183     cRemoved += cTemp;
01184
01185     //
01186     //  Last ditch effort to properly set the managed state of the remaining disks.
01187     //
01188
01189     for ( idx = 0; ( cRemoved < m_idxNext ) && ( idx < m_idxNext ); idx++ )
01190     {
01191         //
01192         //  Sparse array.
01193         //
01194
01195         punk = (*m_prgDisks)[ idx ];    // don't ref
01196         if ( punk != NULL )
01197         {
01198             hr = punk->TypeSafeQI( IStorageProperties, &piccpdp );
01199             if ( FAILED( hr ) )
01200             {
01201                 LOG_STATUS_REPORT( L"Could not query for the IStorageProperties interface.", hr );
01202                 goto Cleanup;
01203             } // if:
01204
01205             //
01206             //  Give the disk a chance to figure out for itself if it should be managed.
01207             //
01208
01209             hr = piccpdp->CanBeManaged();
01210             if ( FAILED( hr ) )
01211             {
01212                 goto Cleanup;
01213             } // if:
01214
01215             piccpdp->Release();
01216             piccpdp = NULL;
01217         } // if: index has a pointer
01218     } // for: each index in the array
01219
01220     //
01221     //  Minor optimization.  If we removed all of the elements reset the enum next to 0.
01222     //
01223
01224     if ( cRemoved == m_idxNext )
01225     {
01226         m_idxNext = 0;
01227     } // if:
01228
01229     hr = S_OK;
01230     goto Cleanup;
01231
01232 Cleanup:
01233
01234     if ( piccpdp != NULL )
01235     {
01236         piccpdp->Release();
01237     } // if:
01238
01239     return hr;
01240
01241 } //*** CEnumStorageResource::HrPruneSystemDisks
01242
01243
01244 /////////////////////////////////////////////////////////////////////////////
01245 //++
01246 //
01247 //  CEnumStorageResource::IsDiskSCSI
01248 //
01249 //  Description:
01250 //      Determine if this disk is on a SCSI bus.
01251 //
01252 //  Arguments:
01253 //      pDiskIn     - WBEM class object for the disk to query.
01254 //
01255 //  Return Value:
01256 //      S_OK        - Disk is SCSI.
01257 //      S_FALSE     - Disk is not SCSI.
01258 //      Other HRESULTs.
01259 //
01260 //--
01261 //////////////////////////////////////////////////////////////////////////////
01262 HRESULT
01263 CEnumStorageResource::IsDiskSCSI(
01264     IWbemClassObject * pDiskIn
01265     )
01266 {
01267     assert( pDiskIn != NULL );
01268
01269     HRESULT hr;
01270     VARIANT var;
01271
01272     VariantInit( &var );
01273
01274     hr = HrGetWMIProperty( pDiskIn, L"InterfaceType", VT_BSTR, &var );
01275     if ( SUCCEEDED( hr ) )
01276     {
01277         if ( ( NStringCompareW( L"SCSI", RTL_NUMBER_OF( L"SCSI" ), var.bstrVal, SysStringLen( var.bstrVal ) ) == 0 ) )
01278         {
01279             hr = S_OK;
01280         } // if:
01281         else
01282         {
01283             hr = S_FALSE;
01284         } // else:
01285     } // if:
01286
01287     VariantClear( &var );
01288
01289     return hr;
01290
01291 } //*** CEnumStorageResource::IsDiskSCSI
01292
01293
01294 /////////////////////////////////////////////////////////////////////////////
01295 //++
01296 //
01297 //  CEnumStorageResource:HrAddObjectToArray
01298 //
01299 //  Description:
01300 //      Add the passed in disk to the array of punks that holds the disks.
01301 //
01302 //  Arguments:
01303 //      punkIn
01304 //
01305 //  Return Value:
01306 //      S_OK            - Operation completed successfully.
01307 //      E_OUTOFMEMORY   - Error allocating memory.
01308 //
01309 //--
01310 //////////////////////////////////////////////////////////////////////////////
01311 HRESULT
01312 CEnumStorageResource::HrAddObjectToArray(
01313     IUnknown * punkIn
01314     )
01315 {
01316     assert( punkIn != NULL );
01317
01318     HRESULT     hr = S_OK;
01319     IUnknown *  ((*prgpunks)[]) = NULL;
01320
01321     //
01322     //  Grow the array to hold the passed in object.
01323     //
01324
01325     prgpunks = (IUnknown *((*)[])) HEAPREALLOC( m_prgDisks, sizeof( IUnknown * ) * ( m_idxNext + 1 ), HEAP_ZERO_MEMORY );
01326     if ( prgpunks == NULL )
01327     {
01328         hr = E_OUTOFMEMORY;
01329         STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_HrAddObjectToArray, IDS_ERROR_OUTOFMEMORY, IDS_ERROR_OUTOFMEMORY_REF, hr );
01330         goto Cleanup;
01331     } // if:
01332
01333     m_prgDisks = prgpunks;
01334
01335     (*m_prgDisks)[ m_idxNext++ ] = punkIn;
01336     punkIn->AddRef();
01337     m_cDiskCount += 1;
01338
01339     goto Cleanup;
01340
01341 Cleanup:
01342
01343     return hr;
01344
01345 } //*** CEnumStorageResource::HrAddObjectToArray
01346
01347
01348 /////////////////////////////////////////////////////////////////////////////
01349 //++
01350 //
01351 //  CEnumStorageResource:HrFixupDisks
01352 //
01353 //  Description:
01354 //      Tweak the disks to better reflect how they are managed by this node.
01355 //
01356 //  Arguments:
01357 //      None.
01358 //
01359 //  Return Value:
01360 //      S_OK
01361 //          Success.
01362 //
01363 //      Win32 Error
01364 //          something failed.
01365 //
01366 //  Remarks:
01367 //      None.
01368 //
01369 //--
01370 //////////////////////////////////////////////////////////////////////////////
01371 HRESULT
01372 CEnumStorageResource::HrFixupDisks( void )
01373 {
01374     HRESULT hr = S_OK;
01375
01376     //
01377     //  If the cluster service is running then load any managed disk
01378     //  resources that we own.
01379     //
01380
01381     hr = HrIsClusterServiceRunning();
01382     if ( hr == S_OK )
01383     {
01384         hr = HrEnumNodeResources( GetNodeName() );
01385     } // if: the cluster service is running on this node
01386     else if ( hr == S_FALSE )
01387     {
01388         hr = S_OK;
01389     } // else: cluster service is not running on this node
01390
01391     return hr;
01392
01393 } //*** CEnumStorageResource::HrFixupDisks
01394
01395
01396 /////////////////////////////////////////////////////////////////////////////
01397 //++
01398 //
01399 //  CEnumStorageResource:HrNodeResourceCallback
01400 //
01401 //  Description:
01402 //      Called by CClusterUtils::HrEnumNodeResources() when it finds a
01403 //      resource for this node.
01404 //
01405 //  Arguments:
01406 //      hResourceIn
01407 //          A physical disk resource that is owned by this node.
01408 //
01409 //  Return Value:
01410 //      S_OK
01411 //          Success.
01412 //
01413 //      Win32 Error
01414 //          something failed.
01415 //
01416 //  Remarks:
01417 //      None.
01418 //
01419 //--
01420 //////////////////////////////////////////////////////////////////////////////
01421 HRESULT
01422 CEnumStorageResource::HrNodeResourceCallback(
01423     HRESOURCE hResourceIn
01424     )
01425 {
01426     HRESULT                 hr = S_OK;
01427     CLUS_SCSI_ADDRESS       csa;
01428     DWORD                   dwSignature;
01429     BOOL                    fIsQuorum;
01430     BSTR                    bstrResourceName = NULL;
01431
01432     //
01433     //  NB:
01434     //
01435     //  Since this example is for physical disks we have used that string here.
01436     //  In your own plug in component you wll use your resource type here.
01437     //
01438
01439     if ( ResUtilResourceTypesEqual( GetResTypeName(), hResourceIn ) == FALSE )
01440     {
01441         //
01442         //  If this resource is not a managed disk then we simply want to
01443         //  skip it.
01444         //
01445
01446         hr = S_FALSE;
01447         goto Cleanup;
01448     } // if:
01449
01450     hr = HrIsCoreResource( hResourceIn );
01451     if ( FAILED( hr ) )
01452     {
01453         goto Cleanup;
01454     } // if:
01455
01456     fIsQuorum = ( hr == S_OK );
01457
01458     hr = HrGetClusterDiskInfo( hResourceIn, &csa, &dwSignature );
01459     if ( FAILED( hr ) )
01460     {
01461         goto Cleanup;
01462     } // if:
01463
01464     hr = HrGetClusterProperties( hResourceIn, &bstrResourceName );
01465     if ( FAILED( hr ) )
01466     {
01467         goto Cleanup;
01468     } // if:
01469
01470     hr = HrSetThisDiskToBeManaged( csa.TargetId, csa.Lun, fIsQuorum, bstrResourceName, dwSignature );
01471     if ( FAILED( hr ) )
01472     {
01473         goto Cleanup;
01474     } // if:
01475
01476     goto Cleanup;
01477
01478 Cleanup:
01479
01480     SysFreeString( bstrResourceName );
01481
01482     return hr;
01483
01484
01485 } //*** CEnumStorageResource::HrNodeResourceCallback
01486
01487
01488 /////////////////////////////////////////////////////////////////////////////
01489 //++
01490 //
01491 //  CEnumStorageResource:HrGetClusterDiskInfo
01492 //
01493 //  Description:
01494 //
01495 //
01496 //  Arguments:
01497 //
01498 //
01499 //  Return Value:
01500 //      S_OK
01501 //          Success.
01502 //
01503 //      Win32 Error
01504 //          something failed.
01505 //
01506 //  Remarks:
01507 //      None.
01508 //
01509 //--
01510 //////////////////////////////////////////////////////////////////////////////
01511 HRESULT
01512 CEnumStorageResource::HrGetClusterDiskInfo(
01513       HRESOURCE             hResourceIn
01514     , CLUS_SCSI_ADDRESS *   pcsaOut
01515     , DWORD *               pdwSignatureOut
01516     )
01517 {
01518     HRESULT                 hr = S_OK;
01519     DWORD                   sc;
01520     CClusPropValueList      cpvl;
01521     CLUSPROP_BUFFER_HELPER  cbhValue = { NULL };
01522
01523     sc = cpvl.ScGetResourceValueList( hResourceIn, CLUSCTL_RESOURCE_STORAGE_GET_DISK_INFO );
01524     if ( sc != ERROR_SUCCESS )
01525     {
01526         hr = HRESULT_FROM_WIN32( sc );
01527         goto Cleanup;
01528     } // if:
01529
01530     sc = cpvl.ScMoveToFirstValue();
01531     if ( sc != ERROR_SUCCESS )
01532     {
01533         hr = HRESULT_FROM_WIN32( sc );
01534         goto Cleanup;
01535     } // if:
01536
01537
01538     for ( ; ; )
01539     {
01540         cbhValue = cpvl;
01541
01542         switch ( cbhValue.pSyntax->dw )
01543         {
01544             case CLUSPROP_SYNTAX_PARTITION_INFO :
01545             {
01546                 break;
01547             } // case: CLUSPROP_SYNTAX_PARTITION_INFO
01548
01549             case CLUSPROP_SYNTAX_DISK_SIGNATURE :
01550             {
01551                 *pdwSignatureOut = cbhValue.pDiskSignatureValue->dw;
01552                 break;
01553             } // case: CLUSPROP_SYNTAX_DISK_SIGNATURE
01554
01555             case CLUSPROP_SYNTAX_SCSI_ADDRESS :
01556             {
01557                 pcsaOut->dw = cbhValue.pScsiAddressValue->dw;
01558                 break;
01559             } // case: CLUSPROP_SYNTAXscSI_ADDRESS
01560
01561             case CLUSPROP_SYNTAX_DISK_NUMBER :
01562             {
01563                 break;
01564             } // case: CLUSPROP_SYNTAX_DISK_NUMBER
01565
01566         } // switch:
01567
01568         sc = cpvl.ScMoveToNextValue();
01569         if ( sc == ERROR_SUCCESS )
01570         {
01571             continue;
01572         } // if:
01573
01574         if ( sc == ERROR_NO_MORE_ITEMS )
01575         {
01576             break;
01577         } // if: error occurred moving to the next value
01578
01579         hr = HRESULT_FROM_WIN32( sc );
01580         goto Cleanup;
01581     } // for: each value in the value list
01582
01583 Cleanup:
01584
01585     return hr;
01586
01587 } //*** CEnumStorageResource::HrGetClusterDiskInfo
01588
01589
01590 /////////////////////////////////////////////////////////////////////////////
01591 //++
01592 //
01593 //  CEnumStorageResource:HrSetThisDiskToBeManaged
01594 //
01595 //  Description:
01596 //
01597 //
01598 //  Arguments:
01599 //
01600 //
01601 //  Return Value:
01602 //      S_OK
01603 //          Success.
01604 //
01605 //      Win32 Error
01606 //          something failed.
01607 //
01608 //  Remarks:
01609 //      None.
01610 //
01611 //--
01612 //////////////////////////////////////////////////////////////////////////////
01613 HRESULT
01614 CEnumStorageResource::HrSetThisDiskToBeManaged(
01615       ULONG ulSCSITidIn
01616     , ULONG ulSCSILunIn
01617     , BOOL  fIsQuorumIn
01618     , BSTR  bstrResourceNameIn
01619     , DWORD dwSignatureIn
01620     )
01621 {
01622     HRESULT                         hr = S_OK;
01623     ULONG                           idx;
01624     IUnknown *                      punk = NULL;
01625     IClusCfgManagedResourceInfo *   piccmri = NULL;
01626     WCHAR                           sz[ 64 ];
01627     BSTR                            bstrUID = NULL;
01628     DWORD                           dwSignature;
01629     IStorageProperties *            piccpdp = NULL;
01630
01631     UNREFERENCED_PARAMETER( dwSignatureIn );
01632
01633     hr = StringCchPrintfW( sz, RTL_NUMBER_OF( sz ), L"%s SCSI Tid %ld, SCSI Lun %ld", GetDisplayName(), ulSCSITidIn, ulSCSILunIn );
01634     if ( FAILED( hr ) )
01635     {
01636         goto Cleanup;
01637     } // if:
01638
01639     //
01640     //  Find the disk that has the passes in TID and Lun and set it
01641     //  to be managed.
01642     //
01643
01644     for ( idx = 0; idx < m_idxNext; idx++ )
01645     {
01646         punk = (*m_prgDisks)[ idx ];                                                        // don't ref
01647         if ( punk != NULL )
01648         {
01649             hr = punk->TypeSafeQI( IClusCfgManagedResourceInfo, &piccmri );
01650             if ( FAILED( hr ) )
01651             {
01652                 goto Cleanup;
01653             } // if:
01654
01655             hr = piccmri->GetUID( &bstrUID );
01656             if ( FAILED( hr ) )
01657             {
01658                 goto Cleanup;
01659             } // if:
01660
01661             if ( NIStringCompareW( bstrUID, SysStringLen( bstrUID ), sz, RTL_NUMBER_OF( sz ) ) == 0 )
01662             {
01663                 hr = piccmri->TypeSafeQI( IStorageProperties, &piccpdp );
01664                 if ( FAILED( hr ) )
01665                 {
01666                     goto Cleanup;
01667                 } // if:
01668
01669                 hr = piccpdp->HrGetSignature( &dwSignature );
01670                 if ( FAILED( hr ) )
01671                 {
01672                     goto Cleanup;
01673                 } // if:
01674
01675                 hr = piccpdp->HrSetFriendlyName( bstrResourceNameIn );
01676                 if ( FAILED( hr ) )
01677                 {
01678                     goto Cleanup;
01679                 } // if:
01680
01681                 piccpdp->Release();
01682                 piccpdp = NULL;
01683
01684                 //
01685                 //  May want to do more with this later...
01686                 //
01687
01688                 assert( dwSignatureIn == dwSignature );
01689
01690                 hr = piccmri->SetManaged( TRUE );
01691                 if ( FAILED( hr ) )
01692                 {
01693                     goto Cleanup;
01694                 } // if:
01695
01696                 hr = piccmri->SetQuorumResource( fIsQuorumIn );
01697                 if ( FAILED( hr ) )
01698                 {
01699                     goto Cleanup;
01700                 } // if:
01701
01702                 break;
01703             } // if:
01704
01705             SysFreeString( bstrUID );
01706             bstrUID = NULL;
01707             piccmri->Release();
01708             piccmri = NULL;
01709         } // if:
01710     } // for:
01711
01712 Cleanup:
01713
01714     if ( piccpdp != NULL )
01715     {
01716         piccpdp->Release();
01717     } // if:
01718
01719     if ( piccmri != NULL )
01720     {
01721         piccmri->Release();
01722     } // if:
01723
01724     SysFreeString( bstrUID );
01725
01726     return hr;
01727
01728 } //*** CEnumStorageResource::HrSetThisDiskToBeManaged
01729
01730
01731 /////////////////////////////////////////////////////////////////////////////
01732 //++
01733 //
01734 //  CEnumStorageResource:HrFindDiskWithLogicalDisk
01735 //
01736 //  Description:
01737 //      Find the disk with the passed in logical disk ID.
01738 //
01739 //  Arguments:
01740 //      None.
01741 //
01742 //  Return Value:
01743 //      S_OK
01744 //          Success.  Found the disk.
01745 //
01746 //      S_FALSE
01747 //          Success.  Did not find the disk.
01748 //
01749 //      Win32 Error
01750 //          something failed.
01751 //
01752 //  Remarks:
01753 //      None.
01754 //
01755 //--
01756 //////////////////////////////////////////////////////////////////////////////
01757 HRESULT
01758 CEnumStorageResource::HrFindDiskWithLogicalDisk(
01759     WCHAR   cLogicalDiskIn,
01760     ULONG * pidxDiskOut
01761     )
01762 {
01763     assert( pidxDiskOut != NULL );
01764
01765     HRESULT                             hr = S_OK;
01766     IStorageProperties *                piccpdp = NULL;
01767     ULONG                               idx;
01768     bool                                fFoundIt = false;
01769     IUnknown *                          punk;
01770
01771     for ( idx = 0; idx < m_idxNext; idx++ )
01772     {
01773         punk = (*m_prgDisks)[ idx ];    // don't ref
01774         if ( punk != NULL )
01775         {
01776             hr = punk->TypeSafeQI( IStorageProperties, &piccpdp );
01777             if ( FAILED( hr ) )
01778             {
01779                 goto Cleanup;
01780             } // if:
01781
01782             hr = piccpdp->IsThisLogicalDisk( cLogicalDiskIn );
01783             if ( FAILED( hr ) )
01784             {
01785                 goto Cleanup;
01786             } // if:
01787
01788             if ( hr == S_OK )
01789             {
01790                 fFoundIt = true;
01791                 break;
01792             } // if:
01793
01794             piccpdp->Release();
01795             piccpdp = NULL;
01796         } // if:
01797     } // for:
01798
01799     if ( fFoundIt == FALSE )
01800     {
01801         hr = S_FALSE;
01802     } // if:
01803
01804     if ( pidxDiskOut != NULL )
01805     {
01806         *pidxDiskOut = idx;
01807     } // if:
01808
01809 Cleanup:
01810
01811     if ( piccpdp != NULL )
01812     {
01813         piccpdp->Release();
01814     } // if:
01815
01816     return hr;
01817
01818 } //*** CEnumStorageResource::HrFindDiskWithLogicalDisk
01819
01820
01821 /////////////////////////////////////////////////////////////////////////////
01822 //++
01823 //
01824 //  CEnumStorageResource:HrGetSCSIInfo
01825 //
01826 //  Description:
01827 //      Get the SCSI info for the disk at the passed in index.
01828 //
01829 //  Arguments:
01830 //      None.
01831 //
01832 //  Return Value:
01833 //      S_OK
01834 //          Success.
01835 //
01836 //      Win32 Error
01837 //          something failed.
01838 //
01839 //  Remarks:
01840 //      None.
01841 //
01842 //--
01843 //////////////////////////////////////////////////////////////////////////////
01844 HRESULT
01845 CEnumStorageResource::HrGetSCSIInfo(
01846     ULONG   idxDiskIn,
01847     ULONG * pulSCSIBusOut,
01848     ULONG * pulSCSIPortOut
01849     )
01850 {
01851     assert( pulSCSIBusOut != NULL );
01852     assert( pulSCSIPortOut != NULL );
01853
01854     HRESULT                             hr = S_OK;
01855     IStorageProperties *                piccpdp = NULL;
01856
01857     hr = ((*m_prgDisks)[ idxDiskIn ])->TypeSafeQI( IStorageProperties, &piccpdp );
01858     if ( FAILED( hr ) )
01859     {
01860         goto Cleanup;
01861     } // if:
01862
01863     hr = piccpdp->HrGetSCSIBus( pulSCSIBusOut );
01864     if ( FAILED( hr ) )
01865     {
01866         goto Cleanup;
01867     } // if:
01868
01869     hr = piccpdp->HrGetSCSIPort( pulSCSIPortOut );
01870     if ( FAILED( hr ) )
01871     {
01872         goto Cleanup;
01873     } // if:
01874
01875 Cleanup:
01876
01877     if ( piccpdp != NULL )
01878     {
01879         piccpdp->Release();
01880     } // if:
01881
01882     return hr;
01883
01884 } //*** CEnumStorageResource::HrGetSCSIInfo
01885
01886
01887 /////////////////////////////////////////////////////////////////////////////
01888 //++
01889 //
01890 //  CEnumStorageResource:HrPruneDisks
01891 //
01892 //  Description:
01893 //      Get the SCSI info for the disk at the passed in index.
01894 //
01895 //  Arguments:
01896 //      None.
01897 //
01898 //  Return Value:
01899 //      S_OK
01900 //          Success.
01901 //
01902 //      Win32 Error
01903 //          something failed.
01904 //
01905 //  Remarks:
01906 //      None.
01907 //
01908 //--
01909 //////////////////////////////////////////////////////////////////////////////
01910 HRESULT
01911 CEnumStorageResource::HrPruneDisks(
01912       ULONG         ulSCSIBusIn
01913     , ULONG         ulSCSIPortIn
01914     , const GUID *  pcguidMajorIdIn
01915     , int           nMsgIdIn
01916     , int           nRefIdIn
01917     , ULONG *       pulRemovedOut
01918     )
01919 {
01920     assert( pulRemovedOut != NULL );
01921
01922     HRESULT                             hr = S_OK;
01923     IStorageProperties *                piccpdp = NULL;
01924     ULONG                               idx;
01925     IUnknown *                          punk;
01926     ULONG                               ulSCSIBus;
01927     ULONG                               ulSCSIPort;
01928     ULONG                               cRemoved = 0;
01929
01930     for ( idx = 0; idx < m_idxNext; idx++ )
01931     {
01932         punk = (*m_prgDisks)[ idx ];                                                        // don't ref
01933         if ( punk != NULL )
01934         {
01935             hr = punk->TypeSafeQI( IStorageProperties, &piccpdp );
01936             if ( FAILED( hr ) )
01937             {
01938                 goto Cleanup;
01939             } // if:
01940
01941             hr = piccpdp->HrGetSCSIBus( &ulSCSIBus );
01942             if ( FAILED( hr ) )
01943             {
01944                 goto Cleanup;
01945             } // if:
01946
01947             hr = piccpdp->HrGetSCSIPort( &ulSCSIPort );
01948             if ( FAILED( hr ) )
01949             {
01950                 goto Cleanup;
01951             } // if:
01952
01953             if ( ( ulSCSIBusIn == ulSCSIBus ) && ( ulSCSIPortIn == ulSCSIPort ) )
01954             {
01955                 BSTR                            bstr = NULL;
01956                 IClusCfgManagedResourceInfo *   piccmri = NULL;
01957                 HRESULT                         hrTemp;
01958                 CLSID   clsidMinorId;
01959
01960                 hrTemp = CoCreateGuid( &clsidMinorId );
01961                 if ( FAILED( hrTemp ) )
01962                 {
01963                     LOG_STATUS_REPORT( L"[MyStorageResource] Could not create a guid for a pruning disk minor task ID", S_OK );
01964                     clsidMinorId = IID_NULL;
01965                 } // if:
01966
01967                 LogPrunedDisk( punk, ulSCSIBusIn, ulSCSIPortIn );
01968
01969                 ((*m_prgDisks)[ idx ])->TypeSafeQI( IClusCfgManagedResourceInfo, &piccmri );
01970                 piccmri->GetName( &bstr );
01971                 if ( piccmri != NULL )
01972                 {
01973                     piccmri->Release();
01974                 } // if:
01975
01976                 STATUS_REPORT_STRING_REF( *pcguidMajorIdIn, clsidMinorId, nMsgIdIn, bstr != NULL ? bstr : L"????", nRefIdIn, hr );
01977                 RemoveDiskFromArray( idx );
01978                 cRemoved++;
01979                 SysFreeString( bstr );
01980             } // if:
01981
01982             piccpdp->Release();
01983             piccpdp = NULL;
01984         } // if:
01985     } // for:
01986
01987     if ( pulRemovedOut != NULL )
01988     {
01989         *pulRemovedOut = cRemoved;
01990     } // if:
01991
01992 Cleanup:
01993
01994     if ( piccpdp != NULL )
01995     {
01996         piccpdp->Release();
01997     } // if:
01998
01999     return hr;
02000
02001 } //*** CEnumStorageResource::HrPruneDisks
02002
02003
02004 /////////////////////////////////////////////////////////////////////////////
02005 //++
02006 //
02007 //  CEnumStorageResource:LogPrunedDisk
02008 //
02009 //  Description:
02010 //      Get the SCSI info for the disk at the passed in index.
02011 //
02012 //  Arguments:
02013 //      None.
02014 //
02015 //  Return Value:
02016 //      S_OK
02017 //          Success.
02018 //
02019 //      Win32 Error
02020 //          something failed.
02021 //
02022 //  Remarks:
02023 //      None.
02024 //
02025 //--
02026 //////////////////////////////////////////////////////////////////////////////
02027 void
02028 CEnumStorageResource::LogPrunedDisk(
02029     IUnknown *  punkIn,
02030     ULONG       ulSCSIBusIn,
02031     ULONG       ulSCSIPortIn
02032     )
02033 {
02034     assert( punkIn != NULL );
02035
02036     HRESULT                             hr = S_OK;
02037     IClusCfgManagedResourceInfo *       piccmri = NULL;
02038     IStorageProperties *                piccpdp = NULL;
02039     BSTR                                bstrName = NULL;
02040     BSTR                                bstrUID = NULL;
02041     BSTR                                bstr = NULL;
02042
02043     hr = punkIn->TypeSafeQI( IClusCfgManagedResourceInfo, &piccmri );
02044     if ( SUCCEEDED( hr ) )
02045     {
02046         hr = piccmri->GetUID( &bstrUID );
02047         piccmri->Release();
02048     } // if:
02049
02050     if ( FAILED( hr ) )
02051     {
02052         bstrUID = SysAllocString( L"<Unknown>" );
02053     } // if:
02054
02055     hr = punkIn->TypeSafeQI( IStorageProperties, &piccpdp );
02056     if ( SUCCEEDED( hr ) )
02057     {
02058         hr = piccpdp->HrGetDeviceID( &bstrName );
02059         piccpdp->Release();
02060     } // if:
02061
02062     if ( FAILED( hr ) )
02063     {
02064         bstrName = SysAllocString( L"<Unknown>" );
02065     } // if:
02066
02067     hr = HrFormatStringIntoBSTR(
02068                   L"[MyStorageResource] Pruning SCSI disk '%1!ws!', on Bus '%2!d!' and Port '%3!d!'; at '%4!ws!'"
02069                 , &bstr
02070                 , bstrName
02071                 , ulSCSIBusIn
02072                 , ulSCSIPortIn
02073                 , bstrUID
02074                 );
02075     if ( FAILED( hr ) )
02076     {
02077         goto Cleanup;
02078     } // if:
02079
02080     LOG_STATUS_REPORT( bstr, hr );
02081
02082 Cleanup:
02083
02084     SysFreeString( bstrName );
02085     SysFreeString( bstrUID );
02086     SysFreeString( bstr );
02087
02088 } //*** CEnumStorageResource::LogPrunedDisk
02089
02090
02091 /////////////////////////////////////////////////////////////////////////////
02092 //++
02093 //
02094 //  CEnumStorageResource:HrIsLogicalDiskNTFS
02095 //
02096 //  Description:
02097 //      Is the passed in logical disk NTFS?
02098 //
02099 //  Arguments:
02100 //      bstrLogicalDiskIn
02101 //
02102 //  Return Value:
02103 //      S_OK            - The disk is NTFS.
02104 //      S_FALSE         - The disk is not NTFS.
02105 //      E_OUTOFMEMORY   - Error allocating memory.
02106 //      Other HRESULTs.
02107 //
02108 //--
02109 //////////////////////////////////////////////////////////////////////////////
02110 HRESULT
02111 CEnumStorageResource::HrIsLogicalDiskNTFS( BSTR bstrLogicalDiskIn )
02112 {
02113     assert( bstrLogicalDiskIn != NULL );
02114
02115     HRESULT             hr = S_OK;
02116     IWbemClassObject *  pLogicalDisk = NULL;
02117     BSTR                bstrPath = NULL;
02118     WCHAR               sz[ 64 ];
02119     VARIANT             var;
02120     size_t              cch;
02121
02122     VariantInit( &var );
02123
02124     cch = wcslen( bstrLogicalDiskIn );
02125     if ( cch > 3 )
02126     {
02127         hr = E_INVALIDARG;
02128         STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_HrIsLogicalDiskNTFS_InvalidArg, IDS_ERROR_INVALIDARG, IDS_ERROR_INVALIDARG_REF, hr );
02129         goto Cleanup;
02130     } // if:
02131
02132     //
02133     //  truncate off any trailing \'s
02134     //
02135     if ( bstrLogicalDiskIn[ cch - 1 ] == L'\\' )
02136     {
02137         bstrLogicalDiskIn[ cch - 1 ] = '\0';
02138     } // if:
02139
02140     //
02141     //  If we have just the logical disk without the trailing colon...
02142     //
02143     if ( wcslen( bstrLogicalDiskIn ) == 1 )
02144     {
02145         hr = StringCchPrintfW( sz, RTL_NUMBER_OF( sz ), L"Win32_LogicalDisk.DeviceID=\"%ws:\"", bstrLogicalDiskIn );
02146     } // if:
02147     else
02148     {
02149         hr = StringCchPrintfW( sz, RTL_NUMBER_OF( sz ), L"Win32_LogicalDisk.DeviceID=\"%ws\"", bstrLogicalDiskIn );
02150     } // else:
02151
02152     if ( FAILED( hr ) )
02153     {
02154         goto Cleanup;
02155     } // if:
02156
02157     bstrPath = SysAllocString( sz );
02158     if ( bstrPath == NULL )
02159     {
02160         hr = E_OUTOFMEMORY;
02161         STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_HrIsLogicalDiskNTFS, IDS_ERROR_OUTOFMEMORY, IDS_ERROR_OUTOFMEMORY_REF, hr );
02162     } // if:
02163
02164     hr = m_pIWbemServices->GetObject( bstrPath, WBEM_FLAG_RETURN_WBEM_COMPLETE, NULL, &pLogicalDisk, NULL );
02165     if ( FAILED( hr ) )
02166     {
02167         STATUS_REPORT_STRING_REF(
02168                   TASKID_Major_Find_Devices
02169                 , TASKID_Minor_WMI_Get_LogicalDisk_Failed
02170                 , IDS_ERROR_WMI_GET_LOGICALDISK_FAILED
02171                 , bstrLogicalDiskIn
02172                 , IDS_ERROR_WMI_GET_LOGICALDISK_FAILED_REF
02173                 , hr
02174                 );
02175         goto Cleanup;
02176     } // if:
02177
02178     hr = HrGetWMIProperty( pLogicalDisk, L"FileSystem", VT_BSTR, &var );
02179     if (FAILED( hr ) )
02180     {
02181         goto Cleanup;
02182     } // if:
02183
02184     CharUpper( var.bstrVal );
02185
02186     if ( NStringCompareW( var.bstrVal, SysStringLen( var.bstrVal ), L"NTFS", RTL_NUMBER_OF( L"NTFS" ) ) != 0 )
02187     {
02188         hr = S_FALSE;
02189     } // if:
02190
02191 Cleanup:
02192
02193     if ( pLogicalDisk != NULL )
02194     {
02195         pLogicalDisk->Release();
02196     } // if:
02197
02198     VariantClear( &var );
02199
02200     SysFreeString( bstrPath );
02201
02202     return hr;
02203
02204 } //*** CEnumStorageResource::HrIsLogicalDiskNTFS
02205
02206
02207 /////////////////////////////////////////////////////////////////////////////
02208 //++
02209 //
02210 //  CEnumStorageResource:HrLogDiskInfo
02211 //
02212 //  Description:
02213 //      Write the info about this disk into the log.
02214 //
02215 //  Arguments:
02216 //      pDiskIn
02217 //
02218 //  Return Value:
02219 //      S_OK
02220 //
02221 //      Win32 Error
02222 //          something failed.
02223 //
02224 //  Remarks:
02225 //      None.
02226 //
02227 //--
02228 //////////////////////////////////////////////////////////////////////////////
02229 HRESULT
02230 CEnumStorageResource::HrLogDiskInfo( IWbemClassObject * pDiskIn )
02231 {
02232     assert( pDiskIn != NULL );
02233
02234     HRESULT hr = S_OK;
02235     VARIANT varDeviceID;
02236     VARIANT varSCSIBus;
02237     VARIANT varSCSIPort;
02238     VARIANT varSCSILun;
02239     VARIANT varSCSITid;
02240     BSTR    bstr = NULL;
02241
02242     VariantInit( &varDeviceID );
02243     VariantInit( &varSCSIBus );
02244     VariantInit( &varSCSIPort );
02245     VariantInit( &varSCSILun );
02246     VariantInit( &varSCSITid );
02247
02248     hr = HrGetWMIProperty( pDiskIn, L"DeviceID", VT_BSTR, &varDeviceID );
02249     if ( FAILED( hr ) )
02250     {
02251         goto Cleanup;
02252     } // if:
02253
02254     hr = IsDiskSCSI( pDiskIn );
02255     if ( FAILED( hr ) )
02256     {
02257         goto Cleanup;
02258     } // if:
02259
02260     //
02261     // Disk is SCSI...
02262     //
02263     if ( hr == S_OK )
02264     {
02265         hr = HrGetWMIProperty( pDiskIn, L"SCSIBus", VT_I4, &varSCSIBus );
02266         if ( FAILED( hr ) )
02267         {
02268             goto Cleanup;
02269         } // if:
02270
02271         hr = HrGetWMIProperty( pDiskIn, L"SCSITargetId", VT_I4, &varSCSITid );
02272         if ( FAILED( hr ) )
02273         {
02274             goto Cleanup;
02275         } // if:
02276
02277         hr = HrGetWMIProperty( pDiskIn, L"SCSILogicalUnit", VT_I4, &varSCSILun );
02278         if ( FAILED( hr ) )
02279         {
02280             goto Cleanup;
02281         } // if:
02282
02283         hr = HrGetWMIProperty( pDiskIn, L"SCSIPort", VT_I4, &varSCSIPort );
02284         if ( FAILED( hr ) )
02285         {
02286             goto Cleanup;
02287         } // if:
02288
02289         hr = HrFormatStringIntoBSTR(
02290                       L"[MyStorageResource] Found SCSI disk '%1!ws!' on Bus '%2!d!' and Port '%3!d!'; at TID '%4!d!' and LUN '%5!d!'"
02291                     , &bstr
02292                     , varDeviceID.bstrVal
02293                     , varSCSIBus.iVal
02294                     , varSCSIPort.iVal
02295                     , varSCSITid.iVal
02296                     , varSCSILun.iVal
02297                     );
02298
02299         if ( FAILED( hr ) )
02300         {
02301             goto Cleanup;
02302         } // if:
02303
02304         LOG_STATUS_REPORT( bstr, hr );
02305     } // if:
02306     else
02307     {
02308         HRESULT hrTemp;
02309         CLSID   clsidMinorId;
02310
02311         hrTemp = CoCreateGuid( &clsidMinorId );
02312         if ( FAILED( hrTemp ) )
02313         {
02314             LOG_STATUS_REPORT( L"[MyStorageResource] Could not create a guid for a non-scsi disk minor task ID", S_OK );
02315             clsidMinorId = IID_NULL;
02316         } // if:
02317
02318         //
02319         //  Reset hr to S_OK since we don't want a yellow bang in the UI.  Finding non-scsi disks is expected
02320         //  and should cause as little concern as possible.
02321         //
02322         hr = S_OK;
02323         STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_Non_SCSI_Disks, IDS_INFO_NON_SCSI_DISKS, IDS_INFO_NON_SCSI_DISKS_REF, hr );
02324         STATUS_REPORT_STRING_REF( TASKID_Minor_Non_SCSI_Disks, clsidMinorId, IDS_ERROR_FOUND_NON_SCSI_DISK, varDeviceID.bstrVal, IDS_ERROR_FOUND_NON_SCSI_DISK_REF, hr );
02325     } // else:
02326
02327 Cleanup:
02328
02329     VariantClear( &varDeviceID );
02330     VariantClear( &varSCSIBus );
02331     VariantClear( &varSCSIPort );
02332     VariantClear( &varSCSILun );
02333     VariantClear( &varSCSITid );
02334
02335     SysFreeString( bstr );
02336
02337     return hr;
02338
02339 } //*** CEnumStorageResource::HrLogDiskInfo
02340
02341
02342 /////////////////////////////////////////////////////////////////////////////
02343 //++
02344 //
02345 //  CEnumStorageResource:HrFindDiskWithWMIDeviceID
02346 //
02347 //  Description:
02348 //      Find the disk with the passed in WMI device ID.
02349 //
02350 //  Arguments:
02351 //      None.
02352 //
02353 //  Return Value:
02354 //      S_OK
02355 //          Success.  Found the disk.
02356 //
02357 //      S_FALSE
02358 //          Success.  Did not find the disk.
02359 //
02360 //      Win32 Error
02361 //          something failed.
02362 //
02363 //  Remarks:
02364 //      None.
02365 //
02366 //--
02367 //////////////////////////////////////////////////////////////////////////////
02368 HRESULT
02369 CEnumStorageResource::HrFindDiskWithWMIDeviceID(
02370     BSTR    bstrWMIDeviceIDIn,
02371     ULONG * pidxDiskOut
02372     )
02373 {
02374     assert( pidxDiskOut != NULL );
02375
02376     HRESULT                             hr = S_OK;
02377     IStorageProperties *                piccpdp = NULL;
02378     ULONG                               idx;
02379     bool                                fFoundIt = false;
02380     IUnknown *                          punk;
02381     BSTR                                bstrDeviceID = NULL;
02382
02383     for ( idx = 0; idx < m_idxNext; idx++ )
02384     {
02385         punk = (*m_prgDisks)[ idx ];    // don't ref
02386         if ( punk != NULL )
02387         {
02388             hr = punk->TypeSafeQI( IStorageProperties, &piccpdp );
02389             if ( FAILED( hr ) )
02390             {
02391                 goto Cleanup;
02392             } // if:
02393
02394             hr = piccpdp->HrGetDeviceID( &bstrDeviceID );
02395             if ( FAILED( hr ) )
02396             {
02397                 goto Cleanup;
02398             } // if:
02399
02400             if ( NBSTRCompareW( bstrWMIDeviceIDIn, bstrDeviceID ) == 0 )
02401             {
02402                 fFoundIt = true;
02403                 break;
02404             } // if:
02405
02406             piccpdp->Release();
02407             piccpdp = NULL;
02408
02409             SysFreeString( bstrDeviceID );
02410             bstrDeviceID = NULL;
02411         } // if:
02412     } // for:
02413
02414     if ( fFoundIt == FALSE )
02415     {
02416         hr = S_FALSE;
02417     } // if:
02418
02419     if ( pidxDiskOut != NULL )
02420     {
02421         *pidxDiskOut = idx;
02422     } // if:
02423
02424 Cleanup:
02425
02426     if ( piccpdp != NULL )
02427     {
02428         piccpdp->Release();
02429     } // if:
02430
02431     SysFreeString( bstrDeviceID );
02432
02433     return hr;
02434
02435 } //*** CEnumStorageResource::HrFindDiskWithWMIDeviceID
02436
02437
02438 /////////////////////////////////////////////////////////////////////////////
02439 //++
02440 //
02441 //  CEnumStorageResource:HrIsSystemBusManaged
02442 //
02443 //  Description:
02444 //      Is the system bus managed by the cluster service?
02445 //
02446 //  Arguments:
02447 //      None.
02448 //
02449 //  Return Value:
02450 //      S_OK
02451 //          Success.  The system bus is managed.
02452 //
02453 //      S_FALSE
02454 //          Success.  The system bus is not managed.
02455 //
02456 //      Win32 Error
02457 //          something failed.
02458 //
02459 //  Remarks:
02460 //      None.
02461 //
02462 //--
02463 //////////////////////////////////////////////////////////////////////////////
02464 HRESULT
02465 CEnumStorageResource::HrIsSystemBusManaged( void )
02466 {
02467     HRESULT hr = S_FALSE;
02468     DWORD   sc;
02469     HKEY    hKey = NULL;
02470     DWORD   dwData;
02471     DWORD   cbData = sizeof( dwData );
02472     DWORD   dwType;
02473
02474     sc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"SYSTEM\\CURRENTCONTROLSET\\SERVICES\\ClusSvc\\Parameters", 0, KEY_READ, &hKey );
02475     if ( sc == ERROR_FILE_NOT_FOUND )
02476     {
02477         goto Cleanup;       // not yet a cluster node.  Return S_FALSE.
02478     } // if:
02479
02480     if ( sc != ERROR_SUCCESS )
02481     {
02482         hr = HRESULT_FROM_WIN32( sc );
02483         LOG_STATUS_REPORT( L"[MyStorageResource] RegOpenKeyEx() failed.", hr );
02484         goto Cleanup;
02485     } // if:
02486
02487     sc = RegQueryValueEx( hKey, L"ManageDisksOnSystemBuses", NULL, &dwType, (LPBYTE) &dwData, &cbData );
02488     if ( sc == ERROR_FILE_NOT_FOUND )
02489     {
02490         goto Cleanup;       // value not found.  Return S_FALSE.
02491     } // if:
02492
02493     if ( sc != ERROR_SUCCESS )
02494     {
02495         hr = HRESULT_FROM_WIN32( sc );
02496         LOG_STATUS_REPORT( L"[MyStorageResource] RegQueryValueEx() failed.", hr );
02497         goto Cleanup;
02498     } // if:
02499
02500     if (dwType != REG_DWORD)
02501     {
02502         HRESULT hrTemp = S_OK;
02503         hr = HRESULT_FROM_WIN32( ERROR_DATATYPE_MISMATCH );
02504         LOG_STATUS_REPORT_STRING( L"[MyStorageResource] RegQueryValueEx() invalid data type %1!d!.", dwType, hrTemp );
02505     }
02506     else if ( dwData > 0)
02507     {
02508         hr = S_OK;
02509     } // if:
02510
02511 Cleanup:
02512
02513     if ( hKey != NULL )
02514     {
02515         RegCloseKey( hKey );
02516     } // if:
02517
02518     return hr;
02519
02520 } //*** CEnumStorageResource::HrIsSystemBusManaged
02521
02522
02523 /////////////////////////////////////////////////////////////////////////////
02524 //++
02525 //
02526 //  CEnumStorageResource:HrGetClusterProperties
02527 //
02528 //  Description:
02529 //      Return the asked for cluster properties.
02530 //
02531 //  Arguments:
02532 //
02533 //
02534 //  Return Value:
02535 //      S_OK
02536 //          Success.
02537 //
02538 //      Win32 Error
02539 //          something failed.
02540 //
02541 //  Remarks:
02542 //      None.
02543 //
02544 //--
02545 //////////////////////////////////////////////////////////////////////////////
02546 HRESULT
02547 CEnumStorageResource::HrGetClusterProperties(
02548       HRESOURCE hResourceIn
02549     , BSTR *    pbstrResourceNameOut
02550     )
02551 {
02552     assert( hResourceIn != NULL );
02553     assert( pbstrResourceNameOut != NULL );
02554
02555     HRESULT                 hr = S_OK;
02556     DWORD                   sc;
02557     DWORD                   cbBuffer;
02558     WCHAR *                 pwszBuffer = NULL;
02559
02560     cbBuffer = 0;
02561     sc = ClusterResourceControl(
02562                         hResourceIn,
02563                         NULL,
02564                         CLUSCTL_RESOURCE_GET_NAME,
02565                         NULL,
02566                         NULL,
02567                         NULL,
02568                         cbBuffer,
02569                         &cbBuffer
02570                         );
02571
02572     if ( sc != ERROR_SUCCESS )
02573     {
02574         hr = HRESULT_FROM_WIN32( sc );
02575         goto Cleanup;
02576     }
02577
02578     // cbBuffer contains the byte count, not the char count.
02579     pwszBuffer = new WCHAR[(cbBuffer/sizeof(WCHAR))+1];
02580
02581     if ( pwszBuffer == NULL )
02582     {
02583         hr = ERROR_OUTOFMEMORY;
02584         goto Cleanup;
02585     }
02586
02587     sc = ClusterResourceControl(
02588                         hResourceIn,
02589                         NULL,
02590                         CLUSCTL_RESOURCE_GET_NAME,
02591                         NULL,
02592                         NULL,
02593                         pwszBuffer,
02594                         cbBuffer,
02595                         &cbBuffer
02596                         );
02597     if ( sc != ERROR_SUCCESS )
02598     {
02599         hr = HRESULT_FROM_WIN32( sc );
02600         goto Cleanup;
02601     }
02602
02603     if ( wcslen( pwszBuffer ) == 0 )
02604     {
02605         LOG_STATUS_REPORT_STRING( L"The Name of a %1!ws! resource was empty!", GetResTypeName(), hr );
02606     }
02607
02608     *pbstrResourceNameOut = SysAllocString( pwszBuffer );
02609
02610     hr = S_OK;
02611
02612 Cleanup:
02613
02614     delete [] pwszBuffer;
02615
02616     return hr;
02617
02618 } //*** CEnumStorageResource::HrGetClusterProperties
02619
02620
02621 /////////////////////////////////////////////////////////////////////////////
02622 //++
02623 //
02624 //  CEnumStorageResource::RemoveDiskFromArray
02625 //
02626 //  Description:
02627 //      Release the disk at the specified index in the array and decrease the disk count.
02628 //
02629 //  Arguments:
02630 //      idxDiskIn - the index of the disk to remove; must be less than the array size.
02631 //
02632 //  Return Value:
02633 //      None.
02634 //
02635 //  Remarks:
02636 //      None.
02637 //
02638 //--
02639 //////////////////////////////////////////////////////////////////////////////
02640 void
02641 CEnumStorageResource::RemoveDiskFromArray(
02642     ULONG idxDiskIn
02643     )
02644 {
02645     assert( idxDiskIn < m_idxNext );
02646
02647     ((*m_prgDisks)[ idxDiskIn ])->Release();
02648     (*m_prgDisks)[ idxDiskIn ] = NULL;
02649
02650     m_cDiskCount -= 1;
02651
02652 } //*** CEnumStorageResource::RemoveDiskFromArray
02653
02654
02655 /////////////////////////////////////////////////////////////////////////////
02656 //++
02657 //
02658 //  CEnumStorageResource::HrLoadEnum
02659 //
02660 //  Description:
02661 //      Load the enum and filter out any devices that don't belong.
02662 //
02663 //  Arguments:
02664 //      None.
02665 //
02666 //  Return Value:
02667 //      S_OK
02668 //          Success.
02669 //
02670 //      Other HRESULT errors.
02671 //
02672 //  Remarks:
02673 //      None.
02674 //
02675 //--
02676 //////////////////////////////////////////////////////////////////////////////
02677 HRESULT
02678 CEnumStorageResource::HrLoadEnum( void )
02679 {
02680     HRESULT hr = S_OK;
02681
02682     hr = HrGetDisks();
02683     if ( FAILED( hr ) )
02684     {
02685         goto Cleanup;
02686     } // if:
02687
02688     hr = HrPruneSystemDisks();
02689     if ( FAILED( hr ) )
02690     {
02691         goto Cleanup;
02692     } // if:
02693
02694     hr = HrSortDisksByIndex();
02695     if ( FAILED( hr ) )
02696     {
02697         goto Cleanup;
02698     } // if:
02699
02700     hr = HrIsNodeClustered();
02701     if ( FAILED( hr ) )
02702     {
02703         goto Cleanup;
02704     } // if:
02705
02706     if ( hr == S_OK )
02707     {
02708         hr = HrFixupDisks();
02709         if ( FAILED( hr ) )
02710         {
02711             goto Cleanup;
02712         } // if:
02713     } // if:
02714
02715     hr = S_OK;  // could have been S_FALSE
02716
02717 Cleanup:
02718
02719     return hr;
02720
02721 } //*** CEnumStorageResource::HrLoadEnum
02722
02723
02724 /////////////////////////////////////////////////////////////////////////////
02725 //++
02726 //
02727 //  CEnumStorageResource::HrSortDisksByIndex
02728 //
02729 //  Description:
02730 //      Sort a (possibly sparse) array of pointers to disk objects by their
02731 //      WMI "Index" property.
02732 //
02733 //  Arguments:
02734 //      ppunkDisksIn
02735 //          A pointer to an array of (possibly null) IUnknown pointers to
02736 //          objects that implement the IStorageProperties interface.
02737 //
02738 //      cArraySizeIn
02739 //          The total number of pointers in the array, including NULLs.
02740 //
02741 //  Return Value:
02742 //      S_OK            - Operation completed successfully.
02743 //      E_OUTOFMEMORY   - Error allocating memory.
02744 //      Other HRESULTs.
02745 //
02746 //--
02747 //////////////////////////////////////////////////////////////////////////////
02748 HRESULT
02749 CEnumStorageResource::HrSortDisksByIndex( void )
02750 {
02751     HRESULT         hr = S_OK;
02752     SIndexedDisk *  prgIndexedDisks = NULL;
02753     size_t          idxCurrentDisk = 0;
02754     size_t          idxSortedDisk = 0;
02755     size_t          cDisks = 0;
02756
02757     //
02758     //  Count the number of non-null pointers in the array
02759     //
02760
02761     for ( idxCurrentDisk = 0; idxCurrentDisk < m_idxNext; ++idxCurrentDisk )
02762     {
02763         if ( (*m_prgDisks)[ idxCurrentDisk ] != NULL )
02764         {
02765             cDisks += 1;
02766         } // if:
02767     } // for:
02768
02769     if ( cDisks < 2 ) // no sorting to do; also avoid calling new[] with zero array size
02770     {
02771         goto Cleanup;
02772     } // if:
02773
02774     //
02775     //  Make a compact array of indexed disks
02776     //
02777
02778     prgIndexedDisks = new SIndexedDisk[ cDisks ];
02779     if ( prgIndexedDisks == NULL )
02780     {
02781         hr = E_OUTOFMEMORY;
02782         goto Cleanup;
02783     } // if:
02784
02785     //
02786     //  Initialize the array of indexed disks
02787     //
02788
02789     for ( idxCurrentDisk = 0; idxCurrentDisk < m_idxNext; ++idxCurrentDisk )
02790     {
02791         if ( (*m_prgDisks)[ idxCurrentDisk ] != NULL )
02792         {
02793             hr = prgIndexedDisks[ idxSortedDisk ].HrInit( (*m_prgDisks)[ idxCurrentDisk ] );
02794             if ( FAILED( hr ) )
02795             {
02796                 goto Cleanup;
02797             } // if:
02798
02799             idxSortedDisk += 1;
02800         } // if current disk pointer in original array is not null
02801     } // for each disk pointer in the original array
02802
02803     InsertionSort( prgIndexedDisks, cDisks, SIndexedDiskLessThan() );
02804
02805     //
02806     //  Copy the sorted pointers back into the original array, padding extra
02807     //  space with nulls
02808     //
02809
02810     for ( idxCurrentDisk = 0; idxCurrentDisk < m_idxNext; ++idxCurrentDisk)
02811     {
02812         if ( idxCurrentDisk < cDisks)
02813         {
02814             (*m_prgDisks)[ idxCurrentDisk ] = prgIndexedDisks[ idxCurrentDisk ].punkDisk;
02815         } // if:
02816         else
02817         {
02818             (*m_prgDisks)[ idxCurrentDisk ] = NULL;
02819         } // else:
02820     } // for each slot in the original array
02821
02822 Cleanup:
02823
02824     delete [] prgIndexedDisks;
02825
02826     return hr;
02827
02828 } //*** CEnumStorageResource::HrSortDisksByIndex
02829
02830
02831 /////////////////////////////////////////////////////////////////////////////
02832 //++
02833 //
02834 //  CEnumStorageResource::HrPrunePageFileDiskBuses
02835 //
02836 //  Description:
02837 //      Prune from the list of disks those that have pagefiles on them and
02838 //      the other disks on those same SCSI busses.
02839 //
02840 //  Arguments:
02841 //      fPruneBusIn
02842 //
02843 //      pcPrunedInout
02844 //
02845 //  Return Value:
02846 //      S_OK        - Operation completed successfully.
02847 //
02848 //--
02849 //////////////////////////////////////////////////////////////////////////////
02850 HRESULT
02851 CEnumStorageResource::HrPrunePageFileDiskBuses(
02852       BOOL    fPruneBusIn
02853     , ULONG * pcPrunedInout
02854     )
02855 {
02856     assert( pcPrunedInout != NULL );
02857
02858     HRESULT         hr = S_OK;
02859     WCHAR           szPageFileDisks[ 26 ];
02860     int             cPageFileDisks = 0;
02861     int             idxPageFileDisk;
02862     ULONG           ulSCSIBus;
02863     ULONG           ulSCSIPort;
02864     ULONG           idx;
02865     ULONG           cPruned = 0;
02866
02867     //
02868     //  Prune the bus with disks that have paging files.
02869     //
02870
02871     hr = HrGetPageFileLogicalDisks( GetCallback(), szPageFileDisks, &cPageFileDisks );
02872     if ( FAILED( hr ) )
02873     {
02874         goto Cleanup;
02875     } // if:
02876
02877     if ( cPageFileDisks > 0 )
02878     {
02879         for ( idxPageFileDisk = 0; idxPageFileDisk < cPageFileDisks; idxPageFileDisk++ )
02880         {
02881             hr = HrFindDiskWithLogicalDisk( szPageFileDisks[ idxPageFileDisk ], &idx );
02882             if ( FAILED( hr ) )
02883             {
02884                 goto Cleanup;
02885             } // if:
02886
02887             if ( hr == S_OK )
02888             {
02889                 //
02890                 //  Should we prune the whole bus, or just the system disk itself?
02891                 //
02892
02893                 if ( fPruneBusIn )
02894                 {
02895                     hr = HrGetSCSIInfo( idx, &ulSCSIBus, &ulSCSIPort );
02896                     if ( FAILED( hr ) )
02897                     {
02898                         goto Cleanup;
02899                     } // if:
02900
02901                     STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_Pruning_PageFile_Disk_Bus, IDS_INFO_PRUNING_PAGEFILEDISK_BUS, hr );
02902                     hr = HrPruneDisks(
02903                                       ulSCSIBus
02904                                     , ulSCSIPort
02905                                     , &TASKID_Minor_Pruning_PageFile_Disk_Bus
02906                                     , IDS_INFO_PAGEFILEDISK_PRUNED
02907                                     , IDS_INFO_PAGEFILEDISK_PRUNED_REF
02908                                     , &cPruned
02909                                     );
02910                     if ( FAILED( hr ) )
02911                     {
02912                         goto Cleanup;
02913                     } // if:
02914                 } // if:
02915                 else
02916                 {
02917                     RemoveDiskFromArray( idx );
02918                     cPruned++;
02919                 } // else:
02920             } // if:
02921         } // for:
02922     } // if:
02923
02924     *pcPrunedInout = cPruned;
02925     hr = S_OK;
02926
02927 Cleanup:
02928
02929     return hr;
02930
02931 } //*** CEnumStorageResource::HrPrunePageFileDiskBuses
02932
02933
02934 /////////////////////////////////////////////////////////////////////////////
02935 //++
02936 //
02937 //  CEnumStorageResource::HrPruneCrashDumpBus
02938 //
02939 //  Description:
02940 //      Prune from the list of disks those that have pagefiles on them and
02941 //      the other disks on those same SCSI busses.
02942 //
02943 //  Arguments:
02944 //      fPruneBusIn
02945 //
02946 //      pcPrunedInout
02947 //
02948 //  Return Value:
02949 //      S_OK        - Operation completed successfully.
02950 //
02951 //--
02952 //////////////////////////////////////////////////////////////////////////////
02953 HRESULT
02954 CEnumStorageResource::HrPruneCrashDumpBus(
02955       BOOL    fPruneBusIn
02956     , ULONG * pcPrunedInout
02957     )
02958 {
02959     assert( pcPrunedInout != NULL );
02960     assert( m_bstrCrashDumpLogicalDisk != NULL );
02961
02962     HRESULT hr = S_OK;
02963     ULONG   ulSCSIBus;
02964     ULONG   ulSCSIPort;
02965     ULONG   idx;
02966     ULONG   cPruned = 0;
02967
02968     //
02969     //  Prune the bus with disks that have paging files.
02970     //
02971
02972     hr = HrFindDiskWithLogicalDisk( m_bstrCrashDumpLogicalDisk[ 0 ], &idx );
02973     if ( FAILED( hr ) )
02974     {
02975         goto Cleanup;
02976     } // if:
02977
02978     if ( hr == S_OK )
02979     {
02980         //
02981         //  Should we prune the whole bus, or just the system disk itself?
02982         //
02983
02984         if ( fPruneBusIn )
02985         {
02986             hr = HrGetSCSIInfo( idx, &ulSCSIBus, &ulSCSIPort );
02987             if ( FAILED( hr ) )
02988             {
02989                 goto Cleanup;
02990             } // if:
02991
02992             STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_Pruning_CrashDump_Disk_Bus, IDS_INFO_PRUNING_CRASHDUMP_BUS, hr );
02993             hr = HrPruneDisks(
02994                               ulSCSIBus
02995                             , ulSCSIPort
02996                             , &TASKID_Minor_Pruning_CrashDump_Disk_Bus
02997                             , IDS_INFO_CRASHDUMPDISK_PRUNED
02998                             , IDS_INFO_CRASHDUMPDISK_PRUNED_REF
02999                             , &cPruned
03000                             );
03001             if ( FAILED( hr ) )
03002             {
03003                 goto Cleanup;
03004             } // if:
03005         } // if:
03006         else
03007         {
03008             RemoveDiskFromArray( idx );
03009             cPruned++;
03010         } // else:
03011     } // if:
03012
03013     *pcPrunedInout = cPruned;
03014     hr = S_OK;
03015
03016 Cleanup:
03017
03018     return hr;
03019
03020 } //*** CEnumStorageResource::HrPruneCrashDumpBus
03021
03022
03023 /////////////////////////////////////////////////////////////////////////////
03024 //++
03025 //
03026 //  CEnumStorageResource::HrPruneDynamicDisks
03027 //
03028 //  Description:
03029 //      Prune from the list of disks those that have dynamic partitions
03030 //      on them.
03031 //
03032 //  Arguments:
03033 //      pcPrunedInout
03034 //
03035 //  Return Value:
03036 //      S_OK        - Operation completed successfully.
03037 //
03038 //--
03039 //////////////////////////////////////////////////////////////////////////////
03040 HRESULT
03041 CEnumStorageResource::HrPruneDynamicDisks(
03042     ULONG * pcPrunedInout
03043     )
03044 {
03045     assert( pcPrunedInout != NULL );
03046
03047     HRESULT                             hr = S_OK;
03048     ULONG                               idx;
03049     ULONG                               cPruned = 0;
03050     IStorageProperties *                piccpdp = NULL;
03051     HRESULT                             hrTemp;
03052     CLSID                               clsidMinorId;
03053     BSTR                                bstrDiskName = NULL;
03054     BSTR                                bstrDeviceName = NULL;
03055
03056     for ( idx = 0; idx < m_idxNext; idx++ )
03057     {
03058         if ( (*m_prgDisks)[ idx ] != NULL )
03059         {
03060             hr = ((*m_prgDisks)[ idx ])->TypeSafeQI( IStorageProperties, &piccpdp );
03061             if ( FAILED( hr ) )
03062             {
03063                 goto Cleanup;
03064             } // if:
03065
03066             hr = piccpdp->HrIsDynamicDisk();
03067             if ( FAILED( hr ) )
03068             {
03069                 goto Cleanup;
03070             } // if:
03071
03072             if ( hr == S_OK )
03073             {
03074                 ((*m_prgDisks)[ idx ])->Release();
03075                 (*m_prgDisks)[ idx ] = NULL;
03076                 cPruned++;
03077
03078                 hrTemp = piccpdp->HrGetDiskNames( &bstrDiskName, &bstrDeviceName );
03079                 if ( FAILED( hrTemp ) )
03080                 {
03081                     LOG_STATUS_REPORT( L"Could not get the name of the disk", hrTemp );
03082                     bstrDiskName = NULL;
03083                     bstrDeviceName = NULL;
03084                 } // if:
03085
03086                 hrTemp = CoCreateGuid( &clsidMinorId );
03087                 if ( FAILED( hrTemp ) )
03088                 {
03089                     LOG_STATUS_REPORT( L"Could not create a guid for a dynamic disk minor task ID", hrTemp );
03090                     clsidMinorId = IID_NULL;
03091                 } // if:
03092
03093                 STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_Non_SCSI_Disks, IDS_INFO_NON_SCSI_DISKS, IDS_INFO_NON_SCSI_DISKS_REF, hr );
03094                 STATUS_REPORT_STRING2_REF(
03095                           TASKID_Minor_Non_SCSI_Disks
03096                         , clsidMinorId
03097                         , IDS_ERROR_LDM_DISK
03098                         , bstrDeviceName != NULL ? bstrDeviceName : L"<unknown>"
03099                         , bstrDiskName != NULL ? bstrDiskName : L"<unknown>"
03100                         , IDS_ERROR_LDM_DISK_REF
03101                         , hr
03102                         );
03103             } // if:
03104
03105             piccpdp->Release();
03106             piccpdp = NULL;
03107
03108             SysFreeString( bstrDiskName );
03109             bstrDiskName = NULL;
03110
03111             SysFreeString( bstrDeviceName );
03112             bstrDeviceName = NULL;
03113         } // end if:
03114     } // for:
03115
03116     *pcPrunedInout = cPruned;
03117     hr = S_OK;
03118
03119 Cleanup:
03120
03121     if ( piccpdp != NULL )
03122     {
03123         piccpdp->Release();
03124     } // if:
03125
03126     SysFreeString( bstrDiskName );
03127     SysFreeString( bstrDeviceName );
03128
03129     return hr;
03130
03131 } //*** CEnumStorageResource::HrPruneDynamicDisks
03132
03133
03134 /////////////////////////////////////////////////////////////////////////////
03135 //++
03136 //
03137 //  CEnumStorageResource::HrPruneGPTDisks
03138 //
03139 //  Description:
03140 //      Prune from the list of disks those that have GPT partitions
03141 //      on them.
03142 //
03143 //  Arguments:
03144 //      pcPrunedInout
03145 //
03146 //  Return Value:
03147 //      S_OK
03148 //          Success.
03149 //
03150 //--
03151 //////////////////////////////////////////////////////////////////////////////
03152 HRESULT
03153 CEnumStorageResource::HrPruneGPTDisks(
03154     ULONG * pcPrunedInout
03155     )
03156 {
03157     assert( pcPrunedInout != NULL );
03158
03159     HRESULT                             hr = S_OK;
03160     ULONG                               idx;
03161     ULONG                               cPruned = 0;
03162     IStorageProperties *                piccpdp = NULL;
03163     HRESULT                             hrTemp;
03164     CLSID                               clsidMinorId;
03165     BSTR                                bstrDiskName = NULL;
03166     BSTR                                bstrDeviceName = NULL;
03167
03168     for ( idx = 0; idx < m_idxNext; idx++ )
03169     {
03170         if ( (*m_prgDisks)[ idx ] != NULL )
03171         {
03172             hr = ((*m_prgDisks)[ idx ])->TypeSafeQI( IStorageProperties, &piccpdp );
03173             if ( FAILED( hr ) )
03174             {
03175                 goto Cleanup;
03176             } // if:
03177
03178             hr = piccpdp->HrIsGPTDisk();
03179             if ( FAILED( hr ) )
03180             {
03181                 goto Cleanup;
03182             } // if:
03183
03184             if ( hr == S_OK )
03185             {
03186                 ((*m_prgDisks)[ idx ])->Release();
03187                 (*m_prgDisks)[ idx ] = NULL;
03188                 cPruned++;
03189
03190                 hrTemp = piccpdp->HrGetDiskNames( &bstrDiskName, &bstrDeviceName );
03191                 if ( FAILED( hrTemp ) )
03192                 {
03193                     LOG_STATUS_REPORT( L"Could not get the name of the disk", hrTemp );
03194                     bstrDiskName = NULL;
03195                     bstrDeviceName = NULL;
03196                 } // if:
03197
03198                 hrTemp = CoCreateGuid( &clsidMinorId );
03199                 if ( FAILED( hrTemp ) )
03200                 {
03201                     LOG_STATUS_REPORT( L"Could not create a guid for a dynamic disk minor task ID", hrTemp );
03202                     clsidMinorId = IID_NULL;
03203                 } // if:
03204
03205                 STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_Non_SCSI_Disks, IDS_INFO_NON_SCSI_DISKS, IDS_INFO_NON_SCSI_DISKS_REF, hr );
03206                 STATUS_REPORT_STRING2_REF(
03207                           TASKID_Minor_Non_SCSI_Disks
03208                         , clsidMinorId
03209                         , IDS_INFO_GPT_DISK
03210                         , bstrDeviceName != NULL ? bstrDeviceName : L"<unknown>"
03211                         , bstrDiskName != NULL ? bstrDiskName : L"<unknown>"
03212                         , IDS_ERROR_LDM_DISK_REF
03213                         , hr
03214                         );
03215             } // if:
03216
03217             piccpdp->Release();
03218             piccpdp = NULL;
03219
03220             SysFreeString( bstrDiskName );
03221             bstrDiskName = NULL;
03222
03223             SysFreeString( bstrDeviceName );
03224             bstrDeviceName = NULL;
03225         } // end if:
03226     } // for:
03227
03228     *pcPrunedInout = cPruned;
03229     hr = S_OK;
03230
03231 Cleanup:
03232
03233     if ( piccpdp != NULL )
03234     {
03235         piccpdp->Release();
03236     } // if:
03237
03238     SysFreeString( bstrDiskName );
03239     SysFreeString( bstrDeviceName );
03240
03241     return hr;
03242
03243 } //*** CEnumStorageResource::HrPruneGPTDisks
03244
03245
03246 /////////////////////////////////////////////////////////////////////////////
03247 //++
03248 //
03249 //  CEnumStorageResource::HrConvertDeviceVolumeToLogicalDisk
03250 //
03251 //  Description:
03252 //      Convert a device volume to a logical disk.
03253 //
03254 //  Arguments:
03255 //
03256 //
03257 //  Return Value:
03258 //      S_OK
03259 //          Success.
03260 //
03261 //      Win32 Error
03262 //          something failed.
03263 //
03264 //  Remarks:
03265 //      None.
03266 //
03267 //--
03268 //////////////////////////////////////////////////////////////////////////////
03269 HRESULT
03270 CEnumStorageResource::HrConvertDeviceVolumeToLogicalDisk(
03271       BSTR      bstrDeviceVolumeIn
03272     , BSTR *    pbstrLogicalDiskOut
03273     )
03274 {
03275     assert( pbstrLogicalDiskOut != NULL );
03276
03277     HRESULT     hr = S_OK;
03278     BOOL        fRet = FALSE;
03279     size_t      cchMountPoint = 0;
03280     WCHAR *     pwszMountPoint = NULL;
03281     WCHAR       szVolume[  MAX_PATH ];
03282     DWORD       sc = ERROR_SUCCESS;
03283     DWORD       cchPaths = 64;
03284     WCHAR *     pwszPaths = NULL;
03285     WCHAR *     pwszEOS = NULL;
03286
03287     cchMountPoint = wcslen( g_szNameSpaceRoot ) + wcslen( bstrDeviceVolumeIn ) + 2;
03288     pwszMountPoint = new WCHAR[ cchMountPoint ];
03289     if ( pwszMountPoint == NULL )
03290     {
03291         hr = E_OUTOFMEMORY;
03292         goto Cleanup;
03293     } // if:
03294
03295     hr = StringCchCopyW( pwszMountPoint, cchMountPoint, g_szNameSpaceRoot );
03296     if ( FAILED( hr ) )
03297     {
03298         goto Cleanup;
03299     } // if:
03300
03301     hr = StringCchCatExW( pwszMountPoint, cchMountPoint, bstrDeviceVolumeIn, &pwszEOS, NULL, 0 );
03302     if ( FAILED( hr ) )
03303     {
03304         goto Cleanup;
03305     } // if:
03306
03307     //
03308     //  Append a trailing \ and re-terminate the string.
03309     //
03310
03311     pwszEOS[ 0 ] = L'\\';
03312     pwszEOS[ 1 ] = L'\0';
03313
03314     fRet = GetVolumeNameForVolumeMountPoint( pwszMountPoint, szVolume, RTL_NUMBER_OF( szVolume ) );
03315     if ( fRet == FALSE )
03316     {
03317         sc = GetLastError();
03318         hr = HRESULT_FROM_WIN32( sc );
03319
03320         LOG_STATUS_REPORT_STRING( L"[MyStorageResource] GetVolumeNameForVolumeMountPoint() failed.  Mount point is '%1!ws!'.", pwszMountPoint, hr );
03321
03322         //
03323         //  GetVolumeNameForVolumeMountPoint() is no longer supported for IA64 EFI partitions.  If the error is
03324         //  ERROR_INVALID_FUNCTION then we should try to get the device number using an IOCTL.
03325         //
03326         if ( HRESULT_CODE( hr ) == ERROR_INVALID_FUNCTION )
03327         {
03328             LOG_STATUS_REPORT_STRING( L"[MyStorageResource] Device volume '%1!ws!' must be an IA64 EFI volume.", bstrDeviceVolumeIn, hr );
03329         } // if:
03330
03331         goto Cleanup;
03332     } // if:
03333
03334     pwszPaths = new WCHAR[ cchPaths ];
03335     if ( pwszPaths == NULL )
03336     {
03337         hr = E_OUTOFMEMORY;
03338         goto Cleanup;
03339     } // if:
03340
03341     //
03342     //  Since the device name that is passed in is for a volume there will never be more than
03343     //  one logical disk in the multisz pwszPaths.
03344     //
03345
03346     fRet = GetVolumePathNamesForVolumeName( szVolume, pwszPaths, cchPaths, &cchPaths );
03347     if ( fRet == FALSE )
03348     {
03349         sc = GetLastError();
03350         if ( sc == ERROR_MORE_DATA )
03351         {
03352             cchPaths++;
03353
03354             delete [] pwszPaths;
03355             pwszPaths = new WCHAR[ cchPaths ];
03356             if ( pwszPaths == NULL )
03357             {
03358                 hr = E_OUTOFMEMORY;
03359                 goto Cleanup;
03360             } // if:
03361
03362             fRet = GetVolumePathNamesForVolumeName( szVolume, pwszPaths, cchPaths, &cchPaths );
03363         } // if:
03364     } // else:
03365
03366     if ( fRet == FALSE )
03367     {
03368         sc = GetLastError();
03369         hr = HRESULT_FROM_WIN32( sc );
03370         LOG_STATUS_REPORT_STRING( L"[MyStorageResource] GetVolumePathNamesForVolumeName() failed. Volume is is '%1!ws!'.", szVolume, hr );
03371         goto Cleanup;
03372     } // if:
03373
03374     *pbstrLogicalDiskOut = SysAllocString( pwszPaths );
03375     if ( *pbstrLogicalDiskOut == NULL )
03376     {
03377         hr = E_OUTOFMEMORY;
03378         goto Cleanup;
03379     } // if:
03380
03381 Cleanup:
03382
03383     delete [] pwszPaths;
03384
03385     delete [] pwszMountPoint;
03386
03387     return hr;
03388
03389 } //*** CEnumStorageResource::HrConvertDeviceVolumeToLogicalDisk
03390
03391
03392 /////////////////////////////////////////////////////////////////////////////
03393 //++
03394 //
03395 //  CEnumStorageResource::HrConvertDeviceVolumeToWMIDeviceID
03396 //
03397 //  Description:
03398 //      Since IA64 EFI partitions no longer support the call to
03399 //      GetVolumeNameForVolumeMountPoint() to convert the device name
03400 //      into a logical disk, since there will not longer be logical disks
03401 //      for these partitions.
03402 //
03403 //  Arguments:
03404 //
03405 //
03406 //  Return Value:
03407 //      S_OK
03408 //          Success
03409 //
03410 //  Remarks:
03411 //      None.
03412 //
03413 //--
03414 //////////////////////////////////////////////////////////////////////////////
03415 HRESULT
03416 CEnumStorageResource::HrConvertDeviceVolumeToWMIDeviceID(
03417       BSTR      bstrDeviceVolumeIn
03418     , BSTR *    pbstrWMIDeviceIDOut
03419     )
03420 {
03421     HRESULT                 hr = S_OK;
03422     HANDLE                  hVolume = NULL;
03423     DWORD                   dwSize;
03424     DWORD                   sc;
03425     STORAGE_DEVICE_NUMBER   sdnDevNumber;
03426     BOOL                    fRet;
03427     size_t                  cchDevice;
03428     WCHAR *                 pwszDevice = NULL;
03429     WCHAR                   sz[ 64 ];
03430
03431     cchDevice = wcslen( g_szNameSpaceRoot ) + wcslen( bstrDeviceVolumeIn ) + 2;
03432     pwszDevice = new WCHAR[ cchDevice ];
03433     if ( pwszDevice == NULL )
03434     {
03435         hr = E_OUTOFMEMORY;
03436         goto Cleanup;
03437     } // if:
03438
03439     hr = StringCchCopyW( pwszDevice, cchDevice, g_szNameSpaceRoot );
03440     if ( FAILED( hr ) )
03441     {
03442         goto Cleanup;
03443     } // if:
03444
03445     hr = StringCchCatW( pwszDevice, cchDevice, bstrDeviceVolumeIn );
03446     if ( FAILED( hr ) )
03447     {
03448         goto Cleanup;
03449     } // if:
03450
03451     //
03452     // get handle to partition
03453     //
03454
03455     hVolume = CreateFileW(
03456                         pwszDevice
03457                       , GENERIC_READ
03458                       , FILE_SHARE_READ
03459                       , NULL
03460                       , OPEN_EXISTING
03461                       , FILE_ATTRIBUTE_NORMAL
03462                       , NULL
03463                       );
03464
03465     if ( hVolume == INVALID_HANDLE_VALUE )
03466     {
03467         sc = GetLastError();
03468         hr = HRESULT_FROM_WIN32( sc );
03469         goto Cleanup;
03470     } // if:
03471
03472     //
03473     // issue storage class ioctl to get drive and partition numbers
03474     // for this device
03475     //
03476
03477     fRet = DeviceIoControl(
03478                           hVolume
03479                         , IOCTL_STORAGE_GET_DEVICE_NUMBER
03480                         , NULL
03481                         , 0
03482                         , &sdnDevNumber
03483                         , sizeof( sdnDevNumber )
03484                         , &dwSize
03485                         , NULL
03486                         );
03487     if ( fRet == FALSE )
03488     {
03489         sc = GetLastError();
03490         hr = HRESULT_FROM_WIN32( sc );
03491         goto Cleanup;
03492     } // if:
03493
03494     hr = StringCchPrintfW( sz, RTL_NUMBER_OF( sz ), g_szPhysicalDriveFormat, sdnDevNumber.DeviceNumber );
03495     if ( FAILED( hr ) )
03496     {
03497         goto Cleanup;
03498     } // if:
03499
03500     *pbstrWMIDeviceIDOut = SysAllocString( sz );
03501     if ( *pbstrWMIDeviceIDOut == NULL )
03502     {
03503         hr = E_OUTOFMEMORY;
03504         goto Cleanup;
03505     } // if:
03506
03507 Cleanup:
03508
03509     if ( hVolume != NULL )
03510     {
03511         CloseHandle( hVolume );
03512     } // if:
03513
03514     delete [] pwszDevice;
03515
03516     return hr;
03517
03518 } //*** CEnumStorageResource::HrConvertDeviceVolumeToWMIDeviceID
03519
03520
03521 /////////////////////////////////////////////////////////////////////////////
03522 //++
03523 //
03524 //  CEnumStorageResource::HrGetPageFileLogicalDisks
03525 //
03526 //  Description:
03527 //      Mark the drives that have paging files on them.
03528 //
03529 //  Arguments:
03530 //
03531 //
03532 //  Return Value:
03533 //      S_OK
03534 //          Success.
03535 //
03536 //--
03537 //////////////////////////////////////////////////////////////////////////////
03538 HRESULT
03539 CEnumStorageResource::HrGetPageFileLogicalDisks(
03540       IClusCfgCallback *    picccIn
03541     , WCHAR                 szLogicalDisksOut[ 26 ]
03542     , int *                 pcLogicalDisksOut
03543     )
03544 {
03545     HRESULT                 hr = S_FALSE;
03546     IEnumWbemClassObject *  pPagingFiles = NULL;
03547     BSTR                    bstrClass;
03548     ULONG                   ulReturned;
03549     IWbemClassObject *      pPagingFile = NULL;
03550     VARIANT                 var;
03551     int                     idx;
03552
03553     UNREFERENCED_PARAMETER( picccIn );
03554
03555     bstrClass = SysAllocString( L"Win32_PageFile" );
03556     if ( bstrClass == NULL )
03557     {
03558         hr = E_OUTOFMEMORY;
03559         goto Cleanup;
03560     } // if:
03561
03562     hr = m_pIWbemServices->CreateInstanceEnum( bstrClass, WBEM_FLAG_SHALLOW, NULL, &pPagingFiles );
03563     if ( FAILED( hr ) )
03564     {
03565         goto Cleanup;
03566     } // if:
03567
03568     VariantInit( &var );
03569
03570     for ( idx = 0; idx < sizeof( szLogicalDisksOut ); idx++ )
03571     {
03572         hr = pPagingFiles->Next( WBEM_INFINITE, 1, &pPagingFile, &ulReturned );
03573         if ( ( hr == S_OK ) && ( ulReturned == 1 ) )
03574         {
03575             VariantClear( &var );
03576
03577             hr = HrGetWMIProperty( pPagingFile, L"Drive", VT_BSTR, &var );
03578             if ( FAILED( hr ) )
03579             {
03580                 goto Cleanup;
03581             } // if:
03582
03583             CharUpper( var.bstrVal );
03584
03585             szLogicalDisksOut[ idx ] = var.bstrVal[ 0 ];
03586
03587             pPagingFile->Release();
03588             pPagingFile = NULL;
03589         } // if:
03590         else if ( ( hr == S_FALSE ) && ( ulReturned == 0 ) )
03591         {
03592             hr = S_OK;
03593             break;
03594         } // else if:
03595         else
03596         {
03597             goto Cleanup;
03598         } // else:
03599     } // for:
03600
03601     if ( pcLogicalDisksOut != NULL )
03602     {
03603         *pcLogicalDisksOut = idx;
03604     } // if:
03605
03606 Cleanup:
03607
03608     VariantClear( &var );
03609
03610     SysFreeString( bstrClass );
03611
03612     if ( pPagingFile != NULL )
03613     {
03614         pPagingFile->Release();
03615     } // if:
03616
03617     if ( pPagingFiles != NULL )
03618     {
03619         pPagingFiles->Release();
03620     } // if:
03621
03622     return hr;
03623
03624 } //*** CEnumStorageResource::HrGetPageFileLogicalDisks
03625
03626
03627 /////////////////////////////////////////////////////////////////////////////
03628 //++
03629 //
03630 //  CEnumStorageResource::HrGetSystemDevice
03631 //
03632 //  Description:
03633 //      Returns the system device.  The system drive is the drive that was
03634 //      booted and has ntldr.exe on it.
03635 //
03636 //  Arguments:
03637 //
03638 //
03639 //  Return Value:
03640 //      None.
03641 //
03642 //--
03643 //////////////////////////////////////////////////////////////////////////////
03644 HRESULT
03645 CEnumStorageResource::HrGetSystemDevice( BSTR * pbstrSystemDeviceOut )
03646 {
03647     assert( pbstrSystemDeviceOut != NULL );
03648
03649     HRESULT hr = S_OK;
03650     DWORD   sc;
03651     HKEY    hKey = NULL;
03652     WCHAR * pwszSystemDevice = NULL;
03653     DWORD   cbSystemDevice = 0;
03654     DWORD   dwType;
03655
03656     sc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"System\\Setup", 0, KEY_READ, &hKey );
03657     if ( sc != ERROR_SUCCESS )
03658     {
03659         hr = HRESULT_FROM_WIN32( sc );
03660         LOG_STATUS_REPORT( L"[MyStorageResource] RegOpenKeyEx() failed.", hr );
03661         goto Cleanup;
03662     } // if:
03663
03664     sc = RegQueryValueEx( hKey, L"SystemPartition", NULL, NULL, NULL, &cbSystemDevice );
03665     if ( sc != ERROR_SUCCESS )
03666     {
03667         hr = HRESULT_FROM_WIN32( sc );
03668         LOG_STATUS_REPORT( L"[MyStorageResource] RegQueryValueEx() failed.", hr );
03669         goto Cleanup;
03670     } // if:
03671
03672     pwszSystemDevice = new WCHAR[ cbSystemDevice / sizeof( WCHAR ) ];
03673     if ( pwszSystemDevice == NULL )
03674     {
03675         hr = E_OUTOFMEMORY;
03676         goto Cleanup;
03677     } // if:
03678
03679     sc = RegQueryValueEx( hKey, L"SystemPartition", NULL, &dwType, (BYTE *) pwszSystemDevice, &cbSystemDevice );
03680     if ( sc != ERROR_SUCCESS )
03681     {
03682         hr = HRESULT_FROM_WIN32( sc );
03683         LOG_STATUS_REPORT( L"[MyStorageResource] RegQueryValueEx() failed.", hr );
03684         goto Cleanup;
03685     } // if:
03686
03687     if (dwType != REG_SZ)
03688     {
03689         hr = ERROR_DATATYPE_MISMATCH;
03690         LOG_STATUS_REPORT_STRING( L"[MyStorageResource] RegQueryValueEx() invalid type %1!d!", dwType, hr );
03691         goto Cleanup;
03692     } // if:
03693
03694     *pbstrSystemDeviceOut = SysAllocString( pwszSystemDevice );
03695     if ( *pbstrSystemDeviceOut == NULL )
03696     {
03697         hr = E_OUTOFMEMORY;
03698         goto Cleanup;
03699     } // if:
03700
03701 Cleanup:
03702
03703     delete [] pwszSystemDevice;
03704
03705     if ( hKey != NULL )
03706     {
03707         RegCloseKey( hKey );
03708     } // if:
03709
03710     return hr;
03711
03712 } //*** CEnumStorageResource::HrGetSystemDevice
03713
03714
03715 /////////////////////////////////////////////////////////////////////////////
03716 //++
03717 //
03718 //  CEnumStorageResource::HrGetBootLogicalDisk
03719 //
03720 //  Description:
03721 //      Returns the boot logical disk.  The boot disk is where the OS is
03722 //      installed.
03723 //
03724 //  Arguments:
03725 //      pbstrBootLogicalDiskOut
03726 //
03727 //  Return Value:
03728 //      S_OK
03729 //      Other HRESULT errors.
03730 //
03731 //--
03732 //////////////////////////////////////////////////////////////////////////////
03733 HRESULT
03734 CEnumStorageResource::HrGetBootLogicalDisk(
03735     BSTR * pbstrBootLogicalDiskOut
03736     )
03737 {
03738     assert( pbstrBootLogicalDiskOut != NULL );
03739
03740     HRESULT hr = S_OK;
03741     DWORD   sc;
03742     WCHAR   szWindowsDir[ MAX_PATH ];
03743     WCHAR   szVolume[ MAX_PATH ];
03744     BOOL    fRet;
03745
03746     sc = GetWindowsDirectoryW( szWindowsDir, RTL_NUMBER_OF( szWindowsDir ) );
03747     if ( sc == 0 )
03748     {
03749         sc = GetLastError();
03750         hr = HRESULT_FROM_WIN32( sc );
03751         LOG_STATUS_REPORT( L"[MyStorageResource] GetWindowsDirectory() failed.", hr );
03752         goto Cleanup;
03753     } // if:
03754
03755     fRet = GetVolumePathName( szWindowsDir, szVolume, RTL_NUMBER_OF( szVolume ) );
03756     if ( fRet == FALSE )
03757     {
03758         sc = GetLastError();
03759         hr = HRESULT_FROM_WIN32( sc );
03760         LOG_STATUS_REPORT( L"[MyStorageResource] GetVolumePathName() failed.", hr );
03761         goto Cleanup;
03762     } // if:
03763
03764     *pbstrBootLogicalDiskOut = SysAllocString( szVolume );
03765     if ( *pbstrBootLogicalDiskOut == NULL )
03766     {
03767         hr = E_OUTOFMEMORY;
03768     } // if:
03769
03770 Cleanup:
03771
03772     return hr;
03773
03774 } //*** CEnumStorageResource::HrGetBootLogicalDisk
03775
03776
03777 /////////////////////////////////////////////////////////////////////////////
03778 //++
03779 //
03780 //  CEnumStorageResource::HrGetCrashDumpLogicalDisk
03781 //
03782 //  Description:
03783 //      Returns the logical disk of the system crash dump file.
03784 //
03785 //  Arguments:
03786 //      pbstrCrashDumpLogicalDiskOut
03787 //
03788 //  Return Value:
03789 //      S_OK
03790 //          Success.
03791 //
03792 //      Other HRESULTs as errors.
03793 //
03794 //--
03795 //////////////////////////////////////////////////////////////////////////////
03796 HRESULT
03797 CEnumStorageResource::HrGetCrashDumpLogicalDisk(
03798     BSTR * pbstrCrashDumpLogicalDiskOut
03799     )
03800 {
03801     assert( pbstrCrashDumpLogicalDiskOut != NULL );
03802
03803     HRESULT hr = S_OK;
03804     DWORD   sc;
03805     HKEY    hKey = NULL;
03806     WCHAR * pwszDumpFile = NULL;
03807     WCHAR * pwszExpandedDumpFile = NULL;
03808     DWORD   cbDumpFile = 0;
03809     DWORD   cchExpandedDumpFile = 0;
03810     BSTR    bstr = NULL;
03811     DWORD   dwType;
03812
03813     sc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\CrashControl", 0, KEY_READ, &hKey );
03814     if ( sc != ERROR_SUCCESS )
03815     {
03816         hr = HRESULT_FROM_WIN32( sc );
03817         LOG_STATUS_REPORT( L"[MyStorageResource] [HrGetCrashDumpLogicalDisk] RegOpenKeyEx() failed.", hr );
03818         goto Cleanup;
03819     } // if:
03820
03821     sc = RegQueryValueEx( hKey, L"DumpFile", NULL, NULL, NULL, &cbDumpFile );
03822     if ( sc != ERROR_SUCCESS )
03823     {
03824         hr = HRESULT_FROM_WIN32( sc );
03825         LOG_STATUS_REPORT( L"[MyStorageResource] [HrGetCrashDumpLogicalDisk] RegQueryValueEx() failed.", hr );
03826         goto Cleanup;
03827     } // if:
03828
03829     pwszDumpFile = new WCHAR[ cbDumpFile / sizeof( WCHAR ) ];
03830     if ( pwszDumpFile == NULL )
03831     {
03832         hr = E_OUTOFMEMORY;
03833         goto Cleanup;
03834     } // if:
03835
03836     sc = RegQueryValueEx( hKey, L"DumpFile", NULL, &dwType, (BYTE *) pwszDumpFile, &cbDumpFile );
03837     if ( sc != ERROR_SUCCESS )
03838     {
03839         hr = HRESULT_FROM_WIN32( sc );
03840         LOG_STATUS_REPORT( L"[MyStorageResource] [HrGetCrashDumpLogicalDisk] RegQueryValueEx() failed.", hr );
03841         goto Cleanup;
03842     } // if:
03843
03844     if ( ( dwType != REG_SZ ) && ( dwType != REG_EXPAND_SZ ) )
03845     {
03846         hr = ERROR_DATATYPE_MISMATCH;
03847         LOG_STATUS_REPORT_STRING( L"[MyStorageResource] RegQueryValueEx() invalid type %1!d!", dwType, hr );
03848         goto Cleanup;
03849     } // if:
03850
03851     cchExpandedDumpFile = ExpandEnvironmentStrings( pwszDumpFile, NULL, 0 );
03852     if ( cchExpandedDumpFile > 0 )
03853     {
03854         pwszExpandedDumpFile = new WCHAR[ cchExpandedDumpFile ];
03855         if( pwszExpandedDumpFile == NULL )
03856         {
03857             hr = E_OUTOFMEMORY;
03858             goto Cleanup;
03859         } // if:
03860         cchExpandedDumpFile = ExpandEnvironmentStrings( pwszDumpFile, pwszExpandedDumpFile, cchExpandedDumpFile );
03861     } // if: success
03862
03863     if ( cchExpandedDumpFile == 0 )
03864     {
03865         hr = HRESULT_FROM_WIN32( GetLastError() );
03866         goto Cleanup;
03867     } // if:
03868
03869     bstr = SysAllocString( pwszExpandedDumpFile );
03870     if ( bstr == NULL )
03871     {
03872         hr = E_OUTOFMEMORY;
03873         goto Cleanup;
03874     } // if:
03875
03876     *pbstrCrashDumpLogicalDiskOut = bstr;
03877     bstr = NULL;
03878
03879 Cleanup:
03880
03881     SysFreeString( bstr );
03882
03883     delete [] pwszExpandedDumpFile;
03884     delete [] pwszDumpFile;
03885
03886     if ( hKey != NULL )
03887     {
03888         RegCloseKey( hKey );
03889     } // if:
03890
03891     return hr;
03892
03893 } //*** CEnumStorageResource::HrGetCrashDumpLogicalDisk
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/makefile.inc Source File

  • NetDS
  • RRas
  • ip

makefile.inc

Go to the documentation of this file.
00001 ipsamplemsg.mc:   .\log.h
00002     mapmsg NET IPSAMPLELOG_BASE .\log.h > ipsamplemsg.mc
00003
00004 ipsamplemsg.h msg00001.bin:   ipsamplemsg.mc
00005     mc -v ipsamplemsg.mc
00006
00007 ipsample.rc:   msg00001.bin
00008
00009 clean::
00010     -del ipsamplemsg.mc ipsamplemsg.h ipsamplemsg.rc msg00001.bin
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Security/VC/VCSecuritySampleCLASS.Cpp Source File

  • Com
  • Services
  • Security
  • VC

VCSecuritySampleCLASS.Cpp

Go to the documentation of this file.
00001 // VCSecuritySampleClass.cpp : Implementation of CVCSecuritySampleClass
00002 #include "stdafx.h"
00003 #include "VCSecuritySample.h"
00004 #include "VCSecuritySampleClass.h"
00005 // If targeting COM+ uncomment the following line:
00006 // #define _complus
00007 #include <comsvcs.h>
00008
00009 /////////////////////////////////////////////////////////////////////////////
00010 // CVCSecuritySampleClass
00011
00012
00013 STDMETHODIMP CVCSecuritySampleClass::AmIAnAdministrator(short * retval)
00014 {
00015 IObjectContext * pObjCtx;
00016 HRESULT hr;
00017 int fIsInRole;
00018
00019
00020 hr = CoGetObjectContext(IID_IObjectContext, (void**)&pObjCtx);
00021 if(FAILED(hr))
00022 {
00023   *retval = 2;
00024   return S_OK;
00025 }
00026
00027 if(NULL == pObjCtx)
00028 {
00029     //Return Error Code
00030   *retval = 2;
00031   return S_OK;
00032 }
00033
00034 if(!pObjCtx->IsSecurityEnabled())
00035 {
00036     //Return Error Code
00037   *retval = 2;
00038   return S_OK;
00039 }
00040
00041 BSTR strAdminRole = SysAllocString(L"Administrator");
00042 hr = pObjCtx->IsCallerInRole(strAdminRole, &fIsInRole);
00043 SysFreeString(strAdminRole);
00044
00045 //An error will be caused if the Administrator role does
00046 //not exist.
00047 if(CONTEXT_E_ROLENOTFOUND == hr)
00048 {
00049   *retval = 0;
00050   return S_OK;
00051 }
00052
00053 if(FAILED(hr))
00054 {
00055   *retval = 2;
00056   return S_OK;
00057 }
00058
00059 if (fIsInRole)
00060   *retval = 1;
00061 else
00062   *retval = 0;
00063
00064 return S_OK;
00065
00066 }
00067
00068
00069 STDMETHODIMP CVCSecuritySampleClass::WhoAmI(BSTR * retval)
00070 {
00071 IObjectContext * pIObjCtx = NULL;
00072 ISecurityProperty* pISecurityProperty = NULL;
00073 DWORD     cbDomain = 20;
00074 DWORD     cbUserName = 20 ;
00075 OLECHAR     lpwstrDomain[20 + 20 + 2] = _T("");
00076 OLECHAR     lpwstrUserName[20] = _T("");
00077 PSID      pSID = NULL;
00078 SID_NAME_USE  peUse;
00079
00080
00081 if(FAILED(CoGetObjectContext(IID_IObjectContext, (void**)&pIObjCtx)))
00082   goto error;
00083
00084 if(NULL == pIObjCtx)
00085   goto error;
00086
00087 if(!pIObjCtx->IsSecurityEnabled())
00088   goto error;
00089
00090 if(FAILED(pIObjCtx->QueryInterface(IID_ISecurityProperty,
00091   (void**)&pISecurityProperty)))
00092   goto error;
00093
00094 if(FAILED(pISecurityProperty->GetDirectCallerSID(&pSID)))
00095   goto error;
00096
00097 if(!LookupAccountSid(NULL, pSID,lpwstrUserName,&cbUserName,
00098   lpwstrDomain, &cbDomain, &peUse))
00099   goto error;
00100
00101 if((!cbDomain) || (!cbUserName))
00102   goto error;
00103
00104 _tcsncat(lpwstrDomain, _T("\\"),1);
00105 _tcsncat(lpwstrDomain, lpwstrUserName, _tcslen(lpwstrUserName));
00106 *retval = SysAllocString(lpwstrDomain);
00107 goto cleanup;
00108
00109 error:
00110 *retval = SysAllocString(L"");
00111 goto cleanup;
00112
00113 cleanup:
00114 if(pSID)
00115   pISecurityProperty->ReleaseSID(pSID);
00116 if(pIObjCtx)
00117   pIObjCtx->Release();
00118 if(pISecurityProperty)
00119   pISecurityProperty->Release();
00120 return S_OK;
00121 }
00122
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Dt_Dll2/Dt_Dll.Cpp Source File

  • NetDS
  • WinSock
  • Dt_Dll2

Dt_Dll.Cpp

Go to the documentation of this file.
00001 // Filename  : dt_dll.cpp
00002 // Abstract  : The main dt_dll.dll source file.  It creates a
00003 //             SocketMonitor object which is inherited from DTHandler
00004 //             to provide custom DT Winsock API hooking.  It exports
00005 //             the requires API calls per the DT specification.
00006 //             (Please review the dt_dll sample on the Platform SDK.)
00007 // Author    : Jeffrey C. Venable, Sr.
00008 // Copyright : THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00009 //             WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00010 //             INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
00011 //             MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00012 //             Copyright (C) 1998 - 2001,  Microsoft Corporation.
00013 //             All rights reserved.
00014
00015 #include "SocketMon.hpp"
00016
00017
00018 SocketMonitor gSocketMonitor;
00019
00020
00021 BOOL WINAPI
00022 DllMain(HINSTANCE, DWORD reason, LPVOID) {
00023
00024     switch (reason) {
00025
00026         case DLL_PROCESS_ATTACH :
00027             break;
00028
00029         case DLL_THREAD_ATTACH :
00030             break;
00031
00032         case DLL_PROCESS_DETACH :
00033             break;
00034
00035         case DLL_THREAD_DETACH :
00036             break;
00037
00038         default :
00039             return (FALSE);
00040
00041     } // switch (reason)
00042
00043     return (TRUE);
00044
00045 } // DllMain
00046
00047
00048 // Function     : WSAPreApiNotify
00049 // Description  : Builds a string for output and passes it, along with
00050 //                information about the call, to a handler function.
00051 // Arguments    : 'NotificationCode'
00052 //                  Specifies which API function called us.
00053 //                'ReturnCode'
00054 //                  A generic pointer to the return value of the API function.
00055 //                  Can be used to change the return value in the case of a
00056 //                  short-circuit (see how the return value from PreApiNotify
00057 //                  works for more information on short-circuiting the API
00058 //                  function).
00059 //                'LibraryName'
00060 //                  A string pointing to the name of the library that called us.
00061 //                '...'
00062 //                  Variable number argument list.  These are pointers to the
00063 //                  actual parameters of the API functions.
00064 // Return Value : Returns TRUE if we want to short-circuit the API function;
00065 //                in other words, returning non-zero here forces the API
00066 //                function to return immediately before any other actions take
00067 //                place.  Returns FALSE if we want to proceed with the API
00068 //                function.
00069
00070 BOOL WINAPIV
00071 WSAPreApiNotify(IN INT NotificationCode, OUT LPVOID ReturnCode, IN LPSTR LibraryName, ...) {
00072
00073     va_list vl;
00074
00075     // Protect against system calls within the hook; save the previous error.
00076     const int lastError = GetLastError();
00077
00078     va_start(vl, LibraryName);
00079     BOOL rVal = gSocketMonitor.dispatch(NotificationCode, ReturnCode, LibraryName, true, vl);
00080     va_end(vl);
00081
00082     // Restore the previous error.
00083     SetLastError(lastError);
00084
00085     return (rVal);
00086
00087 } // WSAPreApiNotify
00088
00089
00090 // Function     : WSAPostApiNotify
00091 // Description  : Like PreApiNotify, builds a string and passes it, along with
00092 //                information about the call, to a handler function.
00093 // Arguments    : 'NotificationCode'
00094 //                  Specifies which API function called us.
00095 //                'ReturnCode'
00096 //                  A generic pointer to the return value of the API function.
00097 //                'LibraryName'
00098 //                  A string pointing to the name of the library that called us.
00099 //                '...'
00100 //                  Variable number argument list.  These are pointers to the
00101 //                  actual parameters of the API functions.
00102 // Return Value : Return value is currently meaningless.
00103
00104 BOOL WINAPIV
00105 WSAPostApiNotify(IN INT NotificationCode, OUT LPVOID ReturnCode, IN LPSTR LibraryName, ...) {
00106
00107   va_list vl;
00108
00109   // Protect against system calls within the hook; save the previous error.
00110   const int lastError = GetLastError();
00111
00112   va_start(vl, LibraryName);
00113   BOOL rVal = gSocketMonitor.dispatch(NotificationCode, ReturnCode, LibraryName, false, vl);
00114   va_end(vl);
00115
00116   // Restore the previous error.
00117   SetLastError(lastError);
00118
00119   return (rVal);
00120
00121 } // WSAPostApiNotify
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/statnode.Cpp Source File

  • SysMgmt
  • MMC
  • CutCopy

statnode.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "StatNode.h"
00021
00022 #include "Space.h"
00023 #include "Sky.h"
00024 #include "People.h"
00025 #include "Land.h"
00026 #include "Backgrnd.h"
00027
00028 const GUID CStaticNode::thisGuid = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00029
00030 //==============================================================
00031 //
00032 // CStaticNode implementation
00033 //
00034 //
00035 CStaticNode::CStaticNode()
00036 {
00037     children[0] = new CPeoplePoweredVehicle;
00038     children[1] = new CLandBasedVehicle;
00039     children[2] = new CSkyBasedVehicle;
00040     children[3] = new CSpaceFolder;
00041     children[4] = new CBackgroundFolder;
00042 }
00043
00044 CStaticNode::~CStaticNode()
00045 {
00046     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00047         if (children[n]) {
00048             delete children[n];
00049         }
00050
00051   if (m_pBMapSm != NULL)
00052     DeleteObject(m_pBMapSm);
00053
00054   if (m_pBMapLg != NULL)
00055     DeleteObject(m_pBMapLg);
00056 }
00057
00058 HRESULT CStaticNode::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00059 {
00060     SCOPEDATAITEM sdi;
00061
00062     if (!bExpanded) {
00063         // create the child nodes, then expand them
00064         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00065             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00066             sdi.mask = SDI_STR       |   // Displayname is valid
00067                 SDI_PARAM     |   // lParam is valid
00068                 SDI_IMAGE     |   // nImage is valid
00069                 SDI_OPENIMAGE |   // nOpenImage is valid
00070                 SDI_PARENT    |
00071                 SDI_CHILDREN;
00072
00073             sdi.relativeID  = (HSCOPEITEM)parent;
00074             sdi.nImage      = children[n]->GetBitmapIndex();
00075             sdi.nOpenImage  = INDEX_OPENFOLDER;
00076             sdi.displayname = MMC_CALLBACK;
00077             sdi.lParam      = (LPARAM)children[n];   // The cookie
00078             sdi.cChildren   = (n == 0 || n == 3);    // Only first and fourth
00079                            // children have child nodes
00080
00081             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00082
00083             _ASSERT( SUCCEEDED(hr) );
00084
00085         children[n]->SetHandle((HANDLE)sdi.ID);
00086         }
00087     }
00088
00089     return S_OK;
00090 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkRecognition/C#/InkRecognition.cs Source File

  • TabletPC
  • InkRecognition
  • C#

InkRecognition.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: InkRecognition.cs
00013 //  Simple Ink Recognition Sample Application
00014 //
00015 //  This program demonstrates how one can build a basic handwriting
00016 //  recognition application using Microsoft Tablet PC Automation API.
00017 //  It first creates an InkCollector object to enable inking
00018 //  in the window. Upon receiving the "Recognize!" command, fired
00019 //  from the application's button, ToString() is invoked on the
00020 //  collected ink strokes to retrieve the best match using the
00021 //  default recognizer.  The results are presented in a message box.
00022 //
00023 //  The features used are: InkCollector, Ink, Strokes,
00024 //  RecognizerContext, and RecognizerResult
00025 //
00026 //--------------------------------------------------------------------------
00027
00028 using System;
00029 using System.Drawing;
00030 using System.Windows.Forms;
00031
00032 // The Ink namespace, which contains the Tablet PC Platform API
00033 using Microsoft.Ink;
00034
00035 namespace InkRecognition
00036 {
00037     /// <summary>
00038     /// The InkRecognition Sample Application form class
00039     /// </summary>
00040   public class InkRecognition : System.Windows.Forms.Form
00041   {
00042         // Declare the Ink Collector object
00043         private InkCollector myInkCollector;
00044
00045         // myRecognizers is used to retrieve the number of installed recognizers
00046         Recognizers myRecognizers;
00047
00048         #region Standard Template Code
00049         private System.Windows.Forms.GroupBox gbInkArea;
00050         private System.Windows.Forms.Button btnRecognize;
00051         private System.Windows.Forms.TextBox txtResults;
00052     private System.ComponentModel.Container components = null;
00053         #endregion
00054
00055         /// <summary>
00056         /// Initialize the form and ink collector
00057         /// </summary>
00058     public InkRecognition()
00059     {
00060             #region Standard Template Code
00061       //
00062       // Required for Windows Form Designer support
00063       //
00064       InitializeComponent();
00065             #endregion
00066
00067         }
00068
00069         #region Standard Template Code
00070     /// <summary>
00071     /// Clean up any resources being used.
00072     /// </summary>
00073     protected override void Dispose( bool disposing )
00074     {
00075       if( disposing )
00076       {
00077         if (components != null)
00078         {
00079           components.Dispose();
00080         }
00081       }
00082       base.Dispose( disposing );
00083     }
00084         #endregion
00085
00086     #region Windows Form Designer generated code
00087     /// <summary>
00088     /// Required method for Designer support - do not modify
00089     /// the contents of this method with the code editor.
00090     /// </summary>
00091     private void InitializeComponent()
00092     {
00093             this.gbInkArea = new System.Windows.Forms.GroupBox();
00094             this.btnRecognize = new System.Windows.Forms.Button();
00095             this.txtResults = new System.Windows.Forms.TextBox();
00096             this.SuspendLayout();
00097             //
00098             // gbInkArea
00099             //
00100             this.gbInkArea.Location = new System.Drawing.Point(8, 0);
00101             this.gbInkArea.Name = "gbInkArea";
00102             this.gbInkArea.Size = new System.Drawing.Size(280, 136);
00103             this.gbInkArea.TabIndex = 0;
00104             this.gbInkArea.TabStop = false;
00105             this.gbInkArea.Text = "Ink Here";
00106             //
00107             // btnRecognize
00108             //
00109             this.btnRecognize.Location = new System.Drawing.Point(8, 144);
00110             this.btnRecognize.Name = "btnRecognize";
00111             this.btnRecognize.Size = new System.Drawing.Size(280, 23);
00112             this.btnRecognize.TabIndex = 1;
00113             this.btnRecognize.Text = "Recognize Ink";
00114             this.btnRecognize.Click += new System.EventHandler(this.btnRecognize_Click);
00115             //
00116             // txtResults
00117             //
00118             this.txtResults.BackColor = System.Drawing.SystemColors.Window;
00119             this.txtResults.ForeColor = System.Drawing.SystemColors.WindowText;
00120             this.txtResults.Location = new System.Drawing.Point(8, 176);
00121             this.txtResults.Name = "txtResults";
00122             this.txtResults.ReadOnly = true;
00123             this.txtResults.Size = new System.Drawing.Size(280, 20);
00124             this.txtResults.TabIndex = 2;
00125             this.txtResults.Text = "";
00126             //
00127             // InkRecognition
00128             //
00129             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00130             this.ClientSize = new System.Drawing.Size(292, 206);
00131             this.Controls.AddRange(new System.Windows.Forms.Control[] {
00132                                                                           this.txtResults,
00133                                                                           this.btnRecognize,
00134                                                                           this.gbInkArea});
00135             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
00136             this.MaximizeBox = false;
00137             this.Name = "InkRecognition";
00138             this.Text = "Ink Recognition Sample";
00139             this.Load += new System.EventHandler(this.InkRecognition_Load);
00140             this.ResumeLayout(false);
00141
00142         }
00143     #endregion
00144
00145         #region Standard Template Code
00146     /// <summary>
00147     /// The main entry point for the application.
00148     /// </summary>
00149     [STAThread]
00150     static void Main()
00151     {
00152       Application.Run(new InkRecognition());
00153     }
00154         #endregion
00155
00156         /// <summary>
00157         /// Event Handler from Form Load Event
00158         /// Setup the ink collector for collection
00159         /// </summary>
00160         /// <param name="sender">The control that raised the event.</param>
00161         /// <param name="e">The event arguments.</param>
00162         private void InkRecognition_Load(object sender, System.EventArgs e)
00163         {
00164             // Create the recognizers collection
00165             myRecognizers = new Recognizers();
00166
00167             // Create a new ink collector that uses the group box handle
00168             myInkCollector = new InkCollector(gbInkArea.Handle);
00169
00170             // Turn the ink collector on
00171             myInkCollector.Enabled = true;
00172
00173         }
00174
00175         /// <summary>
00176         /// Event Handle recognize button click event
00177         /// </summary>
00178         /// <param name="sender">The control that raised the event.</param>
00179         /// <param name="e">The event arguments.</param>
00180         private void btnRecognize_Click(object sender, System.EventArgs e)
00181         {
00182             // Check to ensure that the user has at least one recognizer installed
00183             // Note that this is a preventive check - otherwise, an exception will
00184             // occur during recognition.
00185             if (0 == myRecognizers.Count)
00186             {
00187                 MessageBox.Show("There are no handwriting recognizers installed.  You need to have at least one in order to recognize ink.");
00188             }
00189             else
00190             {
00191
00192                 // Note that the Strokes' ToString() method is a
00193                 // shortcut  for retrieving the best match using the
00194                 // default recognizer.  The same result can also be
00195                 // obtained using the RecognizerContext.  For an
00196                 // example, uncomment the following lines of code:
00197                 //
00198                 // RecognizerContext myRecoContext = new RecognizerContext();
00199                 // RecognitionStatus status;
00200                 // RecognitionResult recoResult;
00201                 //
00202                 // myRecoContext.Strokes = myInkCollector.Ink.Strokes;
00203                 // recoResult = myRecoContext.Recognize(out status);
00204                 // txtResults.SelectedText = recoResult.TopString;
00205                 //
00206                 txtResults.SelectedText = myInkCollector.Ink.Strokes.ToString();
00207
00208                 // If the mouse is pressed, do not perform the deletion -
00209                 // this prevents deleting a stroke that is still being drawn
00210                 if (!myInkCollector.CollectingInk)
00211                 {
00212                     // Once the strokes have been recognized, delete them
00213                     myInkCollector.Ink.DeleteStrokes();
00214
00215                     // Repaint the drawing area
00216                     gbInkArea.Refresh();
00217                 }
00218             }
00219         }
00220   }
00221 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MidiPlyr/SMF.c Source File

  • Multimedia
  • Audio
  • MidiPlyr

SMF.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *
00003 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
00006 *  A PARTICULAR PURPOSE.
00007 *
00008 *  Copyright 1993 - 2000 Microsoft Corporation. All Rights Reserved.
00009 *
00010 ******************************************************************************
00011 *
00012 * SMF.C
00013 *
00014 * MIDI File access routines.
00015 *
00016 *****************************************************************************/
00017 #include <windows.h>
00018 #include <windowsx.h>
00019 #include <mmsystem.h>
00020 #include <memory.h>
00021 #include "muldiv32.h"
00022 #include "smf.h"
00023 #include "smfi.h"
00024 #include "debug.h"
00025
00026 PRIVATE SMFRESULT FNLOCAL smfInsertParmData(
00027     PSMF                    pSmf,
00028     TICKS                   tkDelta,
00029     LPMIDIHDR               lpmh);
00030
00031 /*****************************************************************************
00032 *
00033 * smfOpenFile
00034 *
00035 * This function opens a MIDI file for access.
00036 *
00037 * psofs                     - Specifies the file to open and associated
00038 *                             parameters. Contains a valid HSMF handle
00039 *                             on success.
00040 *
00041 * Returns
00042 *   SMF_SUCCESS The specified file was opened.
00043 *
00044 *   SMF_OPEN_FAILED The specified file could not be opened because it
00045 *     did not exist or could not be created on the disk.
00046 *
00047 *   SMF_INVALID_FILE The specified file was corrupt or not a MIDI file.
00048 *
00049 *   SMF_NO_MEMORY There was insufficient memory to open the file.
00050 *
00051 *   SMF_INVALID_PARM The given flags or time division in the
00052 *     SMFOPENFILESTRUCT were invalid.
00053 *
00054 *****************************************************************************/
00055 SMFRESULT FNLOCAL smfOpenFile(
00056     PSMFOPENFILESTRUCT      psofs)
00057 {
00058     HMMIO                   hmmio = (HMMIO)NULL;
00059     PSMF                    pSmf;
00060     SMFRESULT               smfrc = SMF_SUCCESS;
00061     MMIOINFO                mmioinfo;
00062     MMCKINFO                ckRIFF;
00063     MMCKINFO                ckDATA;
00064
00065     assert(psofs != NULL);
00066     assert(psofs->pstrName != NULL);
00067
00068     /* Verify that the file can be opened or created
00069     */
00070     _fmemset(&mmioinfo, 0, sizeof(mmioinfo));
00071
00072     hmmio = mmioOpen(psofs->pstrName, &mmioinfo, MMIO_READ|MMIO_ALLOCBUF);
00073     if ((HMMIO)NULL == hmmio)
00074     {
00075         DPF(1, "smfOpenFile: mmioOpen failed!");
00076         return SMF_OPEN_FAILED;
00077     }
00078
00079     /* Now see if we can create the handle structure
00080     */
00081     pSmf = (PSMF)LocalAlloc(LPTR, sizeof(SMF));
00082     if (NULL == pSmf)
00083     {
00084         DPF(1, "smfOpenFile: LocalAlloc failed!");
00085         smfrc = SMF_NO_MEMORY;
00086         goto smf_Open_File_Cleanup;
00087     }
00088
00089     lstrcpyn(pSmf->szName, psofs->pstrName, 128);
00090     pSmf->fdwSMF = 0;
00091     pSmf->pTempoMap = NULL;
00092
00093     /* Pull the entire file into a block of memory.
00094     */
00095     _fmemset(&ckRIFF, 0, sizeof(ckRIFF));
00096
00097     if (0 == mmioDescend(hmmio, &ckRIFF, NULL, MMIO_FINDRIFF) &&
00098         ckRIFF.fccType == FOURCC_RMID)
00099     {
00100         ckDATA.ckid = FOURCC_data;
00101
00102         if (0 == mmioDescend(hmmio, &ckDATA, &ckRIFF, MMIO_FINDCHUNK))
00103         {
00104             pSmf->cbImage   = ckDATA.cksize;
00105         }
00106         else
00107         {
00108             DPF(1, "smfOpenFile: Could not descend into RIFF DATA chunk!");
00109             smfrc = SMF_INVALID_FILE;
00110             goto smf_Open_File_Cleanup;
00111         }
00112     }
00113     else
00114     {
00115         mmioSeek(hmmio, 0L, SEEK_SET);
00116
00117         pSmf->cbImage = mmioSeek(hmmio, 0L, SEEK_END);
00118         mmioSeek(hmmio, 0L, SEEK_SET);
00119     }
00120
00121     if (NULL == (pSmf->hpbImage = GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE, pSmf->cbImage)))
00122     {
00123         DPF(1, "smfOpenFile: No memory for image! [%08lX]", pSmf->cbImage);
00124         smfrc = SMF_NO_MEMORY;
00125         goto smf_Open_File_Cleanup;
00126     }
00127
00128     if (pSmf->cbImage != (DWORD)mmioRead(hmmio, pSmf->hpbImage, pSmf->cbImage))
00129     {
00130         DPF(1, "smfOpenFile: Read error on image!");
00131         smfrc = SMF_INVALID_FILE;
00132         goto smf_Open_File_Cleanup;
00133     }
00134
00135     /* If the file exists, parse it just enough to pull out the header and
00136     ** build a track index.
00137     */
00138     smfrc = smfBuildFileIndex((PSMF BSTACK *)&pSmf);
00139     if (MMSYSERR_NOERROR != smfrc)
00140     {
00141         DPF(1, "smfOpenFile: smfBuildFileIndex failed! [%lu]", (DWORD)smfrc);
00142     }
00143
00144 smf_Open_File_Cleanup:
00145
00146     mmioClose(hmmio, 0);
00147
00148     if (SMF_SUCCESS != smfrc)
00149     {
00150         if (NULL != pSmf)
00151         {
00152             if (NULL != pSmf->hpbImage)
00153             {
00154                 GlobalFreePtr(pSmf->hpbImage);
00155             }
00156
00157             LocalFree((HLOCAL)pSmf);
00158         }
00159     }
00160     else
00161     {
00162         psofs->hSmf = (HSMF)pSmf;
00163     }
00164
00165     return smfrc;
00166 }
00167
00168 /*****************************************************************************
00169 *
00170 * smfCloseFile
00171 *
00172 * This function closes an open MIDI file.
00173 *
00174 * hSmf                      - The handle of the open file to close.
00175 *
00176 * Returns
00177 *   SMF_SUCCESS The specified file was closed.
00178 *   SMF_INVALID_PARM The given handle was not valid.
00179 *
00180 * Any track handles opened from this file handle are invalid after this
00181 * call.
00182 *
00183 *****************************************************************************/
00184 SMFRESULT FNLOCAL smfCloseFile(
00185     HSMF                    hSmf)
00186 {
00187     PSMF                    pSmf        = (PSMF)hSmf;
00188
00189     assert(pSmf != NULL);
00190
00191     /*
00192     ** Free up handle memory
00193     */
00194
00195     if (NULL != pSmf->hpbImage)
00196         GlobalFreePtr(pSmf->hpbImage);
00197
00198     LocalFree((HLOCAL)pSmf);
00199
00200     return SMF_SUCCESS;
00201 }
00202
00203 /******************************************************************************
00204 *
00205 * smfGetFileInfo This function gets information about the MIDI file.
00206 *
00207 * hSmf                      - Specifies the open MIDI file to inquire about.
00208 *
00209 * psfi                      - A structure which will be filled in with
00210 *                             information about the file.
00211 *
00212 * Returns
00213 *   SMF_SUCCESS Information was gotten about the file.
00214 *   SMF_INVALID_PARM The given handle was invalid.
00215 *
00216 *****************************************************************************/
00217 SMFRESULT FNLOCAL smfGetFileInfo(
00218     HSMF                    hSmf,
00219     PSMFFILEINFO            psfi)
00220 {
00221     PSMF                    pSmf = (PSMF)hSmf;
00222
00223     assert(pSmf != NULL);
00224     assert(psfi != NULL);
00225
00226     /*
00227     ** Just fill in the structure with useful information.
00228     */
00229     psfi->dwTracks      = pSmf->dwTracks;
00230     psfi->dwFormat      = pSmf->dwFormat;
00231     psfi->dwTimeDivision= pSmf->dwTimeDivision;
00232     psfi->tkLength      = pSmf->tkLength;
00233
00234     return SMF_SUCCESS;
00235 }
00236
00237 /******************************************************************************
00238 *
00239 * smfTicksToMillisecs
00240 *
00241 * This function returns the millisecond offset into the file given the
00242 * tick offset.
00243 *
00244 * hSmf                      - Specifies the open MIDI file to perform
00245 *                             the conversion on.
00246 *
00247 * tkOffset                  - Specifies the tick offset into the stream
00248 *                             to convert.
00249 *
00250 * Returns the number of milliseconds from the start of the stream.
00251 *
00252 * The conversion is performed taking into account the file's time division and
00253 * tempo map from the first track. Note that the same millisecond value
00254 * might not be valid at a later time if the tempo track is rewritten.
00255 *
00256 *****************************************************************************/
00257 DWORD FNLOCAL smfTicksToMillisecs(
00258     HSMF                    hSmf,
00259     TICKS                   tkOffset)
00260 {
00261     PSMF                    pSmf            = (PSMF)hSmf;
00262     PTEMPOMAPENTRY          pTempo;
00263     UINT                    idx;
00264     UINT                    uSMPTE;
00265     DWORD                   dwTicksPerSec;
00266
00267     assert(pSmf != NULL);
00268
00269     if (tkOffset > pSmf->tkLength)
00270     {
00271         DPF(1, "sTTM: Clipping ticks to file length!");
00272         tkOffset = pSmf->tkLength;
00273     }
00274
00275     /* SMPTE time is easy -- no tempo map, just linear conversion
00276     ** Note that 30-Drop means nothing to us here since we're not
00277     ** converting to a colonized format, which is where dropping
00278     ** happens.
00279     */
00280     if (pSmf->dwTimeDivision & 0x8000)
00281     {
00282         uSMPTE = -(int)(char)((pSmf->dwTimeDivision >> 8)&0xFF);
00283         if (29 == uSMPTE)
00284             uSMPTE = 30;
00285
00286         dwTicksPerSec = (DWORD)uSMPTE *
00287                         (DWORD)(BYTE)(pSmf->dwTimeDivision & 0xFF);
00288
00289         return (DWORD)muldiv32(tkOffset, 1000L, dwTicksPerSec);
00290     }
00291
00292     /* Walk the tempo map and find the nearest tick position. Linearly
00293     ** calculate the rest (using MATH.ASM)
00294     */
00295
00296     pTempo = pSmf->pTempoMap;
00297     assert(pTempo != NULL);
00298
00299     for (idx = 0; idx < pSmf->cTempoMap; idx++, pTempo++)
00300         if (tkOffset < pTempo->tkTempo)
00301             break;
00302     pTempo--;
00303
00304     /* pTempo is the tempo map entry preceding the requested tick offset.
00305     */
00306
00307     return pTempo->msBase + muldiv32(tkOffset-pTempo->tkTempo,
00308                                      pTempo->dwTempo,
00309                                      1000L*pSmf->dwTimeDivision);
00310
00311 }
00312
00313
00314 /******************************************************************************
00315 *
00316 * smfMillisecsToTicks
00317 *
00318 * This function returns the nearest tick offset into the file given the
00319 * millisecond offset.
00320 *
00321 * hSmf                      - Specifies the open MIDI file to perform the
00322 *                             conversion on.
00323 *
00324 * msOffset                  - Specifies the millisecond offset into the stream
00325 *                             to convert.
00326 *
00327 * Returns the number of ticks from the start of the stream.
00328 *
00329 * The conversion is performed taking into account the file's time division and
00330 * tempo map from the first track. Note that the same tick value
00331 * might not be valid at a later time if the tempo track is rewritten.
00332 * If the millisecond value does not exactly map to a tick value, then
00333 * the tick value will be rounded down.
00334 *
00335 *****************************************************************************/
00336 TICKS FNLOCAL smfMillisecsToTicks(
00337     HSMF                    hSmf,
00338     DWORD                   msOffset)
00339 {
00340     PSMF                    pSmf            = (PSMF)hSmf;
00341     PTEMPOMAPENTRY          pTempo;
00342     UINT                    idx;
00343     UINT                    uSMPTE;
00344     DWORD                   dwTicksPerSec;
00345     TICKS                   tkOffset;
00346
00347     assert(pSmf != NULL);
00348
00349     /* SMPTE time is easy -- no tempo map, just linear conversion
00350     ** Note that 30-Drop means nothing to us here since we're not
00351     ** converting to a colonized format, which is where dropping
00352     ** happens.
00353     */
00354     if (pSmf->dwTimeDivision & 0x8000)
00355     {
00356         uSMPTE = -(int)(char)((pSmf->dwTimeDivision >> 8)&0xFF);
00357         if (29 == uSMPTE)
00358             uSMPTE = 30;
00359
00360         dwTicksPerSec = (DWORD)uSMPTE *
00361                         (DWORD)(BYTE)(pSmf->dwTimeDivision & 0xFF);
00362
00363         return (DWORD)muldiv32(msOffset, dwTicksPerSec, 1000L);
00364     }
00365
00366     /* Walk the tempo map and find the nearest millisecond position. Linearly
00367     ** calculate the rest (using MATH.ASM)
00368     */
00369     pTempo = pSmf->pTempoMap;
00370     assert(pTempo != NULL);
00371
00372     for (idx = 0; idx < pSmf->cTempoMap; idx++, pTempo++)
00373         if (msOffset < pTempo->msBase)
00374             break;
00375     pTempo--;
00376
00377     /* pTempo is the tempo map entry preceding the requested tick offset.
00378     */
00379
00380     tkOffset = pTempo->tkTempo + muldiv32(msOffset-pTempo->msBase,
00381                                      1000L*pSmf->dwTimeDivision,
00382                                      pTempo->dwTempo);
00383
00384     if (tkOffset > pSmf->tkLength)
00385     {
00386         DPF(1, "sMTT: Clipping ticks to file length!");
00387         tkOffset = pSmf->tkLength;
00388     }
00389
00390     return tkOffset;
00391 }
00392
00393 /******************************************************************************
00394 *
00395 * smfReadEvents
00396 *
00397 * This function reads events from a track.
00398 *
00399 * hSmf                      - Specifies the file to read data from.
00400 *
00401 * lpmh                      - Contains information about the buffer to fill.
00402 *
00403 * tkMax                     - Specifies a cutoff point in the stream
00404 *                             beyond which events will not be read.
00405 *
00406 * Return@rdes
00407 *   SMF_SUCCESS The events were successfully read.
00408 *   SMF_END_OF_TRACK There are no more events to read in this track.
00409 *   SMF_INVALID_FILE A disk error occured on the file.
00410 *
00411 * @xref <f smfWriteEvents>
00412 *****************************************************************************/
00413 SMFRESULT FNLOCAL smfReadEvents(
00414     HSMF                    hSmf,
00415     LPMIDIHDR               lpmh,
00416     TICKS                   tkMax)
00417 {
00418     PSMF                    pSmf = (PSMF)hSmf;
00419     SMFRESULT               smfrc;
00420     EVENT                   event;
00421     LPDWORD                 lpdw;
00422     DWORD                   dwTempo;
00423
00424     assert(pSmf != NULL);
00425     assert(lpmh != NULL);
00426
00427     /*
00428     ** Read events from the track and pack them into the buffer in polymsg
00429     ** format.
00430     **
00431     ** If a SysEx or meta would go over a buffer boundry, split it.
00432     */
00433     lpmh->dwBytesRecorded = 0;
00434     if (pSmf->dwPendingUserEvent)
00435     {
00436         smfrc = smfInsertParmData(pSmf, (TICKS)0, lpmh);
00437         if (SMF_SUCCESS != smfrc)
00438         {
00439             DPF(1, "smfInsertParmData() -> %u", (UINT)smfrc);
00440             return smfrc;
00441         }
00442     }
00443
00444     lpdw = (LPDWORD)(lpmh->lpData + lpmh->dwBytesRecorded);
00445
00446     if (pSmf->fdwSMF & SMF_F_EOF)
00447     {
00448         return SMF_END_OF_FILE;
00449     }
00450
00451     while(TRUE)
00452     {
00453         assert(lpmh->dwBytesRecorded <= lpmh->dwBufferLength);
00454
00455         /* If we know ahead of time we won't have room for the
00456         ** event, just break out now. We need 2 DWORD's for the
00457         ** terminator event and at least 2 DWORD's for any
00458         ** event we might store - this will allow us a full
00459         ** short event or the delta time and stub for a long
00460         ** event to be split.
00461         */
00462         if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 4*sizeof(DWORD))
00463         {
00464             break;
00465         }
00466
00467         smfrc = smfGetNextEvent(pSmf, (SPEVENT)&event, tkMax);
00468         if (SMF_SUCCESS != smfrc)
00469         {
00470             /* smfGetNextEvent doesn't set this because smfSeek uses it
00471             ** as well and needs to distinguish between reaching the
00472             ** seek point and reaching end-of-file.
00473             **
00474             ** To the user, however, we present the selection between
00475             ** their given tkBase and tkEnd as the entire file, therefore
00476             ** we want to translate this into EOF.
00477             */
00478             if (SMF_REACHED_TKMAX == smfrc)
00479             {
00480                 pSmf->fdwSMF |= SMF_F_EOF;
00481             }
00482
00483             DPF(1, "smfReadEvents: smfGetNextEvent() -> %u", (UINT)smfrc);
00484             break;
00485         }
00486
00487
00488         if (MIDI_SYSEX > EVENT_TYPE(event))
00489         {
00490             *lpdw++ = (DWORD)event.tkDelta;
00491             *lpdw++ = 0;
00492             *lpdw++ = (((DWORD)MEVT_SHORTMSG)<<24) |
00493                       ((DWORD)EVENT_TYPE(event)) |
00494                       (((DWORD)EVENT_CH_B1(event)) << 8) |
00495                       (((DWORD)EVENT_CH_B2(event)) << 16);
00496
00497             lpmh->dwBytesRecorded += 3*sizeof(DWORD);
00498         }
00499         else if (MIDI_META == EVENT_TYPE(event) &&
00500                  MIDI_META_EOT == EVENT_META_TYPE(event))
00501         {
00502             /* These are ignoreable since smfReadNextEvent()
00503             ** takes care of track merging
00504             */
00505         }
00506         else if (MIDI_META == EVENT_TYPE(event) &&
00507                  MIDI_META_TEMPO == EVENT_META_TYPE(event))
00508         {
00509             if (event.cbParm != 3)
00510             {
00511                 DPF(1, "smfReadEvents: Corrupt tempo event");
00512                 return SMF_INVALID_FILE;
00513             }
00514
00515             dwTempo = (((DWORD)MEVT_TEMPO)<<24)|
00516                       (((DWORD)event.hpbParm[0])<<16)|
00517                       (((DWORD)event.hpbParm[1])<<8)|
00518                       ((DWORD)event.hpbParm[2]);
00519
00520             *lpdw++ = (DWORD)event.tkDelta;
00521             *lpdw++ = 0;
00522             *lpdw++ = dwTempo;
00523
00524             lpmh->dwBytesRecorded += 3*sizeof(DWORD);
00525         }
00526         else if (MIDI_META != EVENT_TYPE(event))
00527         {
00528             /* Must be F0 or F7 system exclusive or FF meta
00529             ** that we didn't recognize
00530             */
00531             pSmf->cbPendingUserEvent = event.cbParm;
00532             pSmf->hpbPendingUserEvent = event.hpbParm;
00533             pSmf->fdwSMF &= ~SMF_F_INSERTSYSEX;
00534
00535             switch(EVENT_TYPE(event))
00536             {
00537                 case MIDI_SYSEX:
00538                     pSmf->fdwSMF |= SMF_F_INSERTSYSEX;
00539
00540                     ++pSmf->cbPendingUserEvent;
00541
00542                     /* Falling through...
00543                     */
00544
00545                 case MIDI_SYSEXEND:
00546                     pSmf->dwPendingUserEvent = ((DWORD)MEVT_LONGMSG) << 24;
00547                     break;
00548             }
00549
00550             smfrc = smfInsertParmData(pSmf, event.tkDelta, lpmh);
00551             if (SMF_SUCCESS != smfrc)
00552             {
00553                 DPF(1, "smfInsertParmData[2] %u", (UINT)smfrc);
00554                 return smfrc;
00555             }
00556
00557             lpdw = (LPDWORD)(lpmh->lpData + lpmh->dwBytesRecorded);
00558         }
00559     }
00560
00561     return (pSmf->fdwSMF & SMF_F_EOF) ? SMF_END_OF_FILE : SMF_SUCCESS;
00562 }
00563
00564 /******************************************************************************
00565 *
00566 * smfInsertParmData
00567 *
00568 * Inserts pending long data from a track into the given buffer.
00569 *
00570 * pSmf                      - Specifies the file to read data from.
00571 *
00572 * tkDelta                   - Specfices the tick delta for the data.
00573 *
00574 * lpmh                      - Contains information about the buffer to fill.
00575 *
00576 * Returns
00577 *   SMF_SUCCESS The events were successfully read.
00578 *   SMF_INVALID_FILE A disk error occured on the file.
00579 *
00580 * Fills as much data as will fit while leaving room for the buffer
00581 * terminator.
00582 *
00583 * If the long data is depleted, resets pSmf->dwPendingUserEvent so
00584 * that the next event may be read.
00585 *
00586 *****************************************************************************/
00587 PRIVATE SMFRESULT FNLOCAL smfInsertParmData(
00588     PSMF                    pSmf,
00589     TICKS                   tkDelta,
00590     LPMIDIHDR               lpmh)
00591 {
00592     DWORD                   dwLength;
00593     DWORD                   dwRounded;
00594     LPDWORD                 lpdw;
00595
00596     assert(pSmf != NULL);
00597     assert(lpmh != NULL);
00598
00599     /* Can't fit 4 DWORD's? (tkDelta + stream-id + event + some data)
00600     ** Can't do anything.
00601     */
00602     assert(lpmh->dwBufferLength >= lpmh->dwBytesRecorded);
00603
00604     if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 4*sizeof(DWORD))
00605     {
00606         if (0 == tkDelta)
00607             return SMF_SUCCESS;
00608
00609         /* If we got here with a real delta, that means smfReadEvents screwed
00610         ** up calculating left space and we should flag it somehow.
00611         */
00612         DPF(1, "Can't fit initial piece of SysEx into buffer!");
00613         return SMF_INVALID_FILE;
00614     }
00615
00616     lpdw = (LPDWORD)(lpmh->lpData + lpmh->dwBytesRecorded);
00617
00618     dwLength = lpmh->dwBufferLength - lpmh->dwBytesRecorded - 3*sizeof(DWORD);
00619     dwLength = min(dwLength, pSmf->cbPendingUserEvent);
00620
00621     *lpdw++ = (DWORD)tkDelta;
00622     *lpdw++ = 0L;
00623     *lpdw++ = (pSmf->dwPendingUserEvent & 0xFF000000L) | (dwLength & 0x00FFFFFFL);
00624
00625     dwRounded = (dwLength + 3) & (~3L);
00626
00627     if (pSmf->fdwSMF & SMF_F_INSERTSYSEX)
00628     {
00629         *((LPBYTE)lpdw)++ = MIDI_SYSEX;
00630         pSmf->fdwSMF &= ~SMF_F_INSERTSYSEX;
00631         --dwLength;
00632         --pSmf->cbPendingUserEvent;
00633     }
00634
00635     if (dwLength & 0x80000000L)
00636     {
00637         DPF(1, "dwLength %08lX  dwBytesRecorded %08lX  dwBufferLength %08lX", dwLength, lpmh->dwBytesRecorded, lpmh->dwBufferLength);
00638         DPF(1, "cbPendingUserEvent %08lX  dwPendingUserEvent %08lX dwRounded %08lX", pSmf->cbPendingUserEvent, pSmf->dwPendingUserEvent, dwRounded);
00639         DPF(1, "Offset into MIDI image %08lX", (DWORD)(pSmf->hpbPendingUserEvent - pSmf->hpbImage));
00640         DPF(1, "!hmemcpy is about to fault");
00641     }
00642
00643     hmemcpy(lpdw, pSmf->hpbPendingUserEvent, dwLength);
00644     if (0 == (pSmf->cbPendingUserEvent -= dwLength))
00645         pSmf->dwPendingUserEvent = 0;
00646
00647     lpmh->dwBytesRecorded += 3*sizeof(DWORD) + dwRounded;
00648
00649     return SMF_SUCCESS;
00650 }
00651
00652 /******************************************************************************
00653 *
00654 * smfSeek
00655 *
00656 * This function moves the file pointer within a track
00657 * and gets the state of the track at the new position. It returns a buffer of
00658 * state information which can be used to set up to play from the new position.
00659 *
00660 * hSmf                      - Handle of file to seek within
00661 *
00662 * tkPosition                - The position to seek to in the track.
00663 *
00664 * lpmh                      - A buffer to contain the state information.
00665 *
00666 * Returns
00667 *   SMF_SUCCESS | The state was successfully read.
00668 *   SMF_END_OF_TRACK | The pointer was moved to end of track and no state
00669 *     information was returned.
00670 *   SMF_INVALID_PARM | The given handle or buffer was invalid.
00671 *   SMF_NO_MEMORY | There was insufficient memory in the given buffer to
00672 *     contain all of the state data.
00673 *
00674 * The state information in the buffer includes patch changes, tempo changes,
00675 * time signature, key signature,
00676 * and controller information. Only the most recent of these paramters before
00677 * the current position will be stored. The state buffer will be returned
00678 * in polymsg format so that it may be directly transmitted over the MIDI
00679 * bus to bring the state up to date.
00680 *
00681 * The buffer is mean to be sent as a streaming buffer; i.e. immediately
00682 * followed by the first data buffer. If the requested tick position
00683 * does not exist in the file, the last event in the buffer
00684 * will be a MEVT_NOP with a delta time calculated to make sure that
00685 * the next stream event plays at the proper time.
00686 *
00687 * The meta events (tempo, time signature, key signature) will be the
00688 * first events in the buffer if they exist.
00689 *
00690 * Use smfGetStateMaxSize to determine the maximum size of the state
00691 * information buffer. State information that will not fit into the given
00692 * buffer will be lost.
00693 *
00694 * On return, the dwBytesRecorded field of lpmh will contain the
00695 * actual number of bytes stored in the buffer.
00696 *
00697 *****************************************************************************/
00698
00699 typedef struct tag_keyframe
00700 {
00701     /*
00702     ** Meta events. All FF's indicates never seen.
00703     */
00704     BYTE        rbTempo[3];
00705
00706     /*
00707     ** MIDI channel messages. FF indicates never seen.
00708     */
00709     BYTE        rbProgram[16];
00710     BYTE        rbControl[16*120];
00711 }   KEYFRAME,
00712     FAR *PKEYFRAME;
00713
00714 #define KF_EMPTY ((BYTE)0xFF)
00715
00716 SMFRESULT FNLOCAL smfSeek(
00717     HSMF                    hSmf,
00718     TICKS                   tkPosition,
00719     LPMIDIHDR               lpmh)
00720 {
00721     PSMF                    pSmf    = (PSMF)hSmf;
00722     PTRACK                  ptrk;
00723     DWORD                   idxTrack;
00724     SMFRESULT               smfrc;
00725     EVENT                   event;
00726     LPDWORD                 lpdw;
00727     BYTE                    bEvent;
00728     UINT                    idx;
00729     UINT                    idxChannel;
00730     UINT                    idxController;
00731
00732     static KEYFRAME         kf;
00733
00734     _fmemset(&kf, 0xFF, sizeof(kf));
00735
00736     pSmf->tkPosition = 0;
00737     pSmf->fdwSMF &= ~SMF_F_EOF;
00738
00739     for (ptrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; ptrk++)
00740     {
00741         ptrk->pSmf              = pSmf;
00742         ptrk->tkPosition        = 0;
00743         ptrk->cbLeft            = ptrk->smti.cbLength;
00744         ptrk->hpbImage          = pSmf->hpbImage + ptrk->idxTrack;
00745         ptrk->bRunningStatus    = 0;
00746         ptrk->fdwTrack          = 0;
00747     }
00748
00749     while (SMF_SUCCESS == (smfrc = smfGetNextEvent(pSmf, (SPEVENT)&event, tkPosition)))
00750     {
00751         if (MIDI_META == (bEvent = EVENT_TYPE(event)))
00752         {
00753             if (EVENT_META_TYPE(event) == MIDI_META_TEMPO)
00754             {
00755                 if (event.cbParm != sizeof(kf.rbTempo))
00756                     return SMF_INVALID_FILE;
00757
00758                 hmemcpy((HPBYTE)kf.rbTempo, event.hpbParm, event.cbParm);
00759             }
00760         }
00761         else switch(bEvent & 0xF0)
00762         {
00763             case MIDI_PROGRAMCHANGE:
00764                 kf.rbProgram[bEvent & 0x0F] = EVENT_CH_B1(event);
00765                 break;
00766
00767             case MIDI_CONTROLCHANGE:
00768                 kf.rbControl[(((WORD)bEvent & 0x0F)*120) + EVENT_CH_B1(event)] =
00769                     EVENT_CH_B2(event);
00770                 break;
00771         }
00772     }
00773
00774     if (SMF_REACHED_TKMAX != smfrc)
00775     {
00776         return smfrc;
00777     }
00778
00779     /* Build lpmh from keyframe
00780     */
00781     lpmh->dwBytesRecorded = 0;
00782     lpdw = (LPDWORD)lpmh->lpData;
00783
00784     /* Tempo change event?
00785     */
00786     if (KF_EMPTY != kf.rbTempo[0] ||
00787         KF_EMPTY != kf.rbTempo[1] ||
00788         KF_EMPTY != kf.rbTempo[2])
00789     {
00790         if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 3*sizeof(DWORD))
00791             return SMF_NO_MEMORY;
00792
00793         *lpdw++ = 0;
00794         *lpdw++ = 0;
00795         *lpdw++ = (((DWORD)kf.rbTempo[0])<<16)|
00796                   (((DWORD)kf.rbTempo[1])<<8)|
00797                   ((DWORD)kf.rbTempo[2])|
00798                   (((DWORD)MEVT_TEMPO) << 24);
00799
00800         lpmh->dwBytesRecorded += 3*sizeof(DWORD);
00801     }
00802
00803     /* Program change events?
00804     */
00805     for (idx = 0; idx < 16; idx++)
00806     {
00807         if (KF_EMPTY != kf.rbProgram[idx])
00808         {
00809             if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 3*sizeof(DWORD))
00810                 return SMF_NO_MEMORY;
00811
00812             *lpdw++ = 0;
00813             *lpdw++ = 0;
00814             *lpdw++ = (((DWORD)MEVT_SHORTMSG) << 24)      |
00815                       ((DWORD)MIDI_PROGRAMCHANGE)         |
00816                       ((DWORD)idx)                        |
00817                       (((DWORD)kf.rbProgram[idx]) << 8);
00818
00819             lpmh->dwBytesRecorded += 3*sizeof(DWORD);
00820         }
00821     }
00822
00823     /* Controller events?
00824     */
00825     idx = 0;
00826     for (idxChannel = 0; idxChannel < 16; idxChannel++)
00827     {
00828         for (idxController = 0; idxController < 120; idxController++)
00829         {
00830             if (KF_EMPTY != kf.rbControl[idx])
00831             {
00832                 if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 3*sizeof(DWORD))
00833                     return SMF_NO_MEMORY;
00834
00835                 *lpdw++ = 0;
00836                 *lpdw++ = 0;
00837                 *lpdw++ = (((DWORD)MEVT_SHORTMSG << 24)     |
00838                           ((DWORD)MIDI_CONTROLCHANGE)       |
00839                           ((DWORD)idxChannel)               |
00840                           (((DWORD)idxController) << 8)     |
00841                           (((DWORD)kf.rbControl[idx]) << 16));
00842
00843
00844                 lpmh->dwBytesRecorded += 3*sizeof(DWORD);
00845             }
00846
00847             idx++;
00848         }
00849     }
00850
00851     /* Force all tracks to be at tkPosition. We are guaranteed that
00852     ** all tracks will be past the event immediately preceding tkPosition;
00853     ** this will force correct delta-ticks to be generated so that events
00854     ** on all tracks will line up properly on a seek into the middle of the
00855     ** file.
00856     */
00857     for (ptrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; ptrk++)
00858     {
00859         ptrk->tkPosition        = tkPosition;
00860     }
00861
00862     return SMF_SUCCESS;
00863 }
00864
00865 /******************************************************************************
00866 *
00867 * smfGetStateMaxSize
00868 *
00869 * This function returns the maximum sizeof buffer that is needed to
00870 * hold the state information returned by f smfSeek.
00871 *
00872 * pdwSize                   - Gets the size in bytes that should be allocated
00873 *                             for the state buffer.
00874 *
00875 * Returns the state size in bytes.
00876 *
00877 *****************************************************************************/
00878 DWORD FNLOCAL smfGetStateMaxSize(
00879     VOID)
00880 {
00881     return  3*sizeof(DWORD) +           /* Tempo                */
00882             3*16*sizeof(DWORD) +        /* Patch changes        */
00883             3*16*120*sizeof(DWORD) +    /* Controller changes   */
00884             3*sizeof(DWORD);            /* Time alignment NOP   */
00885 }
00886
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/JavaClient/FullSvr/AsyncFullServ.java Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • JavaClient
  • FullSvr

AsyncFullServ.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc958.tmp" /nologo /d "D:\mssdk\Samples\COM\Fundamentals\AsyncCalls\JavaClient" "D:\mssdk\Samples\COM\Fundamentals\AsyncCalls\FullSvr\Debug\FullSvr.exe")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package fullsvr;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.class(classid=F03BE176-A8DE-40D1-9161-A36BCBE1FEA6,DynamicCasts)
00019     @com.interface(iid=D3140113-D43F-4718-9119-EF62D631F2AB, thread=AUTO) */
00020 public class AsyncFullServ implements IUnknown,com.ms.com.NoAutoScripting,fullsvr.AsyncIFullServ,fullsvr.ISynchronize,fullsvr.ICancelMethodCalls
00021 {
00022   /** @com.method(vtoffset=0, addFlagsVtable=4)
00023       @com.parameters([in,type=I4] i, [in,type=I4] j) */
00024   public native void Begin_Sum(int i, int j);
00025
00026   /** @com.method(vtoffset=1, addFlagsVtable=4)
00027       @com.parameters([type=I4] return) */
00028   public native int Finish_Sum();
00029
00030
00031   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0xd3140113, (short)0xd43f, (short)0x4718, (byte)0x91, (byte)0x19, (byte)0xef, (byte)0x62, (byte)0xd6, (byte)0x31, (byte)0xf2, (byte)0xab);
00032   /** @com.method()
00033       @hidden */
00034   public native void Wait(int dwFlags, int dwMilliseconds);
00035
00036   /** @com.method()
00037       @hidden */
00038   public native void Signal();
00039
00040   /** @com.method()
00041       @hidden */
00042   public native void Reset();
00043
00044   /** @com.method()
00045       @hidden */
00046   public native void Cancel(int ulSeconds);
00047
00048   /** @com.method()
00049       @hidden */
00050   public native void TestCancel();
00051
00052
00053   public static final com.ms.com._Guid clsid = new com.ms.com._Guid((int)0xf03be176, (short)0xa8de, (short)0x40d1, (byte)0x91, (byte)0x61, (byte)0xa3, (byte)0x6b, (byte)0xcb, (byte)0xe1, (byte)0xfe, (byte)0xa6);
00054 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/ioipf.Cpp Source File

  • Com
  • Fundamentals
  • SimpCntr

ioipf.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOIPF.CPP
00003 //
00004 //      Implementation file for COleInPlaceFrame
00005 //
00006 // Functions:
00007 //
00008 //      See IOIPF.H for class definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "ioipf.h"
00017 #include "ioips.h"
00018 #include "app.h"
00019 #include "site.h"
00020 #include "doc.h"
00021
00022
00023 //**********************************************************************
00024 //
00025 // CSimpleApp::QueryInterface
00026 //
00027 // Purpose:
00028 //
00029 //      Used for interface negotiation at the Interface level.
00030 //
00031 // Parameters:
00032 //
00033 //      REFIID riid         -   A reference to the interface that is
00034 //                              being queried.
00035 //
00036 //      LPVOID FAR* ppvObj  -   An out parameter to return a pointer to
00037 //                              the interface.
00038 //
00039 // Return Value:
00040 //
00041 //      S_OK    -   The interface is supported.
00042 //      S_FALSE -   The interface is not supported
00043 //
00044 // Function Calls:
00045 //      Function                    Location
00046 //
00047 //      OutputDebugString           Windows API
00048 //      CSimpleApp::QueryInterface  APP.CPP
00049 //
00050 // Comments:
00051 //
00052 //********************************************************************
00053
00054 STDMETHODIMP COleInPlaceFrame::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00055 {
00056         OutputDebugString("In IOIPF::QueryInterface\r\n");
00057
00058 // delegate to the document Object
00059         return m_pApp->QueryInterface(riid, ppvObj);
00060 }
00061
00062 //**********************************************************************
00063 //
00064 // CSimpleApp::AddRef
00065 //
00066 // Purpose:
00067 //
00068 //      Adds to the reference count at the interface level.
00069 //
00070 // Parameters:
00071 //
00072 //      None
00073 //
00074 // Return Value:
00075 //
00076 //      ULONG   -   The new reference count of the interface.
00077 //
00078 // Function Calls:
00079 //      Function                    Location
00080 //
00081 //      OutputDebugString           Windows API
00082 //
00083 // Comments:
00084 //
00085 //********************************************************************
00086
00087 STDMETHODIMP_(ULONG) COleInPlaceFrame::AddRef()
00088 {
00089         OutputDebugString("In IOIPF::AddRef\r\n");
00090
00091 // delegate to the document Object
00092         m_pApp->AddRef();
00093 // increment the interface reference count
00094         return ++m_nCount;
00095 }
00096
00097 //**********************************************************************
00098 //
00099 // CSimpleApp::Release
00100 //
00101 // Purpose:
00102 //
00103 //      Decrements the reference count at this level
00104 //
00105 // Parameters:
00106 //
00107 //      None
00108 //
00109 // Return Value:
00110 //
00111 //      ULONG   -   The new reference count of the interface.
00112 //
00113 // Function Calls:
00114 //      Function                    Location
00115 //
00116 //      OutputDebugString           Windows API
00117 //      CSimpleApp::Release         APP.CPP
00118 //
00119 // Comments:
00120 //
00121 //********************************************************************
00122
00123 STDMETHODIMP_(ULONG) COleInPlaceFrame::Release()
00124 {
00125         OutputDebugString("In IOIPF::Release\r\n");
00126
00127 // delegate to the document object
00128         m_pApp->Release();
00129
00130 // decrement the interface reference count
00131         return --m_nCount;
00132 }
00133
00134 //**********************************************************************
00135 //
00136 // COleInPlaceFrame::GetWindow
00137 //
00138 // Purpose:
00139 //
00140 //      Returns the frame window handle
00141 //
00142 // Parameters:
00143 //
00144 //      HWND FAR* lphwnd    - Location to return the window handle
00145 //
00146 // Return Value:
00147 //
00148 //      S_OK
00149 //
00150 // Function Calls:
00151 //      Function                    Location
00152 //
00153 //      OutputDebugString           Windows API
00154 //                   OLE API
00155 //
00156 // Comments:
00157 //
00158 //********************************************************************
00159
00160 STDMETHODIMP COleInPlaceFrame::GetWindow (HWND FAR* lphwnd)
00161 {
00162         OutputDebugString("In IOIPF::GetWindow\r\n");
00163         CStabilize stabilize(m_pApp);
00164         *lphwnd = m_pApp->m_hAppWnd;
00165         return S_OK;
00166 }
00167
00168 //**********************************************************************
00169 //
00170 // COleInPlaceFrame::ContextSensitiveHelp
00171 //
00172 // Purpose:
00173 //
00174 //      Used in implementing Context sensitive help
00175 //
00176 // Parameters:
00177 //
00178 //      BOOL fEnterMode -   TRUE if starting Context Sensitive help mode
00179 //
00180 // Return Value:
00181 //
00182 //      S_OK
00183 //
00184 // Function Calls:
00185 //      Function                    Location
00186 //
00187 //      OutputDebugString           Windows API
00188 //                   OLE API
00189 //
00190 // Comments:
00191 //
00192 //      Be sure to read the technotes in the OLE toolkit.
00193 //
00194 //********************************************************************
00195
00196 STDMETHODIMP COleInPlaceFrame::ContextSensitiveHelp (BOOL fEnterMode)
00197 {
00198         OutputDebugString("In IOIPF::ContextSensitiveHelp\r\n");
00199         CStabilize stabilize(m_pApp);
00200
00201         m_pApp->m_fMenuMode = fEnterMode;
00202
00203         return S_OK;
00204 }
00205 //**********************************************************************
00206 //
00207 // COleInPlaceFrame::GetBorder
00208 //
00209 // Purpose:
00210 //
00211 //      Returns the outermost border that frame adornments can be attached
00212 //      during InPlace Activation.
00213 //
00214 // Parameters:
00215 //
00216 //      LPRECT lprectBorder - return parameter to contain the outermost
00217 //                            rect for frame adornments
00218 //
00219 // Return Value:
00220 //
00221 //      S_OK
00222 //
00223 // Function Calls:
00224 //      Function                    Location
00225 //
00226 //      OutputDebugString           Windows API
00227 //      GetClientRect               Windows API
00228 //      CopyRect                    Windows API
00229 //                   OLE API
00230 //
00231 // Comments:
00232 //
00233 //********************************************************************
00234
00235 STDMETHODIMP COleInPlaceFrame::GetBorder (LPRECT lprectBorder)
00236 {
00237         RECT rect;
00238
00239         OutputDebugString("In IOIPF::GetBorder\r\n");
00240
00241         // get the rect for the entire frame.
00242         GetClientRect(m_pApp->m_hAppWnd, &rect);
00243
00244         CopyRect(lprectBorder, &rect);
00245
00246         return S_OK;
00247 }
00248
00249 //**********************************************************************
00250 //
00251 // COleInPlaceFrame::RequestBorderSpace
00252 //
00253 // Purpose:
00254 //
00255 //      Approves/Denies requests for border space during InPlace
00256 //      negotiation.
00257 //
00258 // Parameters:
00259 //
00260 //      LPCBORDERWIDTHS lpborderwidths  - The width in pixels needed on
00261 //                                        each side of the frame.
00262 //
00263 // Return Value:
00264 //
00265 //      S_OK
00266 //
00267 // Function Calls:
00268 //      Function                    Location
00269 //
00270 //      OutputDebugString           Windows API
00271 //                   OLE API
00272 //
00273 // Comments:
00274 //
00275 //      This implementation doesn't care about how much border space
00276 //      is used.  It always returns S_OK.
00277 //
00278 //********************************************************************
00279
00280 STDMETHODIMP COleInPlaceFrame::RequestBorderSpace (LPCBORDERWIDTHS lpborderwidths)
00281 {
00282         OutputDebugString("In IOIPF::RequestBorderSpace\r\n");
00283
00284         // always approve the request
00285         return S_OK;
00286 }
00287
00288 //**********************************************************************
00289 //
00290 // COleInPlaceFrame::SetBorderSpace
00291 //
00292 // Purpose:
00293 //
00294 //      The object calls this method when it is actually going to
00295 //      start using the border space.
00296 //
00297 // Parameters:
00298 //
00299 //      LPCBORDERWIDTHS lpborderwidths  - Border space actually being used
00300 //                                        by the object
00301 //
00302 // Return Value:
00303 //
00304 //      S_OK
00305 //
00306 // Function Calls:
00307 //      Function                        Location
00308 //
00309 //      CSimpleApp::AddFrameLevelTools  APP.CPP
00310 //      OutputDebugString               Windows API
00311 //      GetClientRect                   Windows API
00312 //      MoveWindow                      Windows API
00313 //                       Windows API
00314 //
00315 // Comments:
00316 //
00317 //      This routine could be a little smarter and check to see if
00318 //      the object is requesting the entire client area of the
00319 //      window.
00320 //
00321 //********************************************************************
00322
00323 STDMETHODIMP COleInPlaceFrame::SetBorderSpace (LPCBORDERWIDTHS lpborderwidths)
00324 {
00325
00326         OutputDebugString("In IOIPF::SetBorderSpace\r\n");
00327         CStabilize stabilize(m_pApp);
00328
00329         if (lpborderwidths == NULL)
00330                 m_pApp->AddFrameLevelTools();
00331         else
00332                 {
00333                 RECT rect;
00334
00335                 GetClientRect(m_pApp->m_hAppWnd, &rect);
00336
00337                 MoveWindow( m_pApp->m_lpDoc->m_hDocWnd,
00338                                         rect.left + lpborderwidths->left,
00339                                         rect.top + lpborderwidths->top,
00340                                         rect.right - lpborderwidths->right - lpborderwidths->left,
00341                                         rect.bottom - lpborderwidths->bottom - lpborderwidths->top,
00342                                         TRUE);
00343                 }
00344         return S_OK;
00345 }
00346
00347 //**********************************************************************
00348 //
00349 // COleInPlaceFrame::SetActiveObject
00350 //
00351 // Purpose:
00352 //
00353 //
00354 // Parameters:
00355 //
00356 //      LPOLEINPLACEACTIVEOBJECT lpActiveObject     -   Pointer to the
00357 //                                                      objects
00358 //                                                      IOleInPlaceActiveObject
00359 //                                                      interface
00360 //
00361 //@@WTK WIN32, UNICODE
00362 //      //LPCSTR lpszObjName                          -   Name of the object
00363 //      LPCOLESTR lpszObjName                          -   Name of the object
00364 //
00365 // Return Value:
00366 //
00367 //      S_OK
00368 //
00369 // Function Calls:
00370 //      Function                            Location
00371 //
00372 //      OutputDebugString                   Windows API
00373 //      IOleInPlaceActiveObject::AddRef     Object
00374 //      IOleInPlaceActiveObject::Release    Object
00375 //                           OLE API
00376 //
00377 // Comments:
00378 //
00379 //********************************************************************
00380
00381 //@@WTK WIN32, UNICODE
00382 //STDMETHODIMP COleInPlaceFrame::SetActiveObject (LPOLEINPLACEACTIVEOBJECT lpActiveObject,LPCSTR lpszObjName)
00383 STDMETHODIMP COleInPlaceFrame::SetActiveObject (
00384 LPOLEINPLACEACTIVEOBJECT lpActiveObject,
00385 LPCOLESTR lpszObjName)
00386 {
00387
00388         OutputDebugString("In IOIPF::SetActiveObject\r\n");
00389         CStabilize stabilize(m_pApp);
00390
00391         // AddRef() it and save it...
00392         if (lpActiveObject)
00393                 {
00394                 lpActiveObject->AddRef();
00395
00396                 lpActiveObject->GetWindow(&m_pApp->m_hwndUIActiveObj);
00397                 if (m_pApp->m_hwndUIActiveObj)
00398                         SendMessage(m_pApp->m_hwndUIActiveObj, WM_QUERYNEWPALETTE, 0, 0L);
00399                 }
00400         else
00401                 {
00402                 if (m_pApp->m_lpDoc->m_lpActiveObject)
00403                         m_pApp->m_lpDoc->m_lpActiveObject->Release();
00404                 m_pApp->m_hwndUIActiveObj = NULL;
00405                 }
00406
00407         // in an MDI app, this method really shouldn't be called,
00408         // this method associated with the doc is called instead.
00409
00410         m_pApp->m_lpDoc->m_lpActiveObject = lpActiveObject;
00411         // should set window title here
00412
00413         return S_OK;
00414 }
00415
00416 //**********************************************************************
00417 //
00418 // COleInPlaceFrame::InsertMenus
00419 //
00420 // Purpose:
00421 //
00422 //      Inserts the container menu into the combined menu
00423 //
00424 // Parameters:
00425 //
00426 //      HMENU hmenuShared                   -   Menu Handle to be set.
00427 //      LPOLEMENUGROUPWIDTHS lpMenuWidths   -   Width of menus
00428 //
00429 // Return Value:
00430 //
00431 // Function Calls:
00432 //      Function                    Location
00433 //
00434 //      OutputDebugString           Windows API
00435 //      AppendMenu                  Windows API
00436 //                   OLE API
00437 //
00438 // Comments:
00439 //
00440 //********************************************************************
00441
00442 STDMETHODIMP COleInPlaceFrame::InsertMenus (HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
00443 {
00444         OutputDebugString("In IOIPF::InsertMenus\r\n");
00445         CStabilize stabilize(m_pApp);
00446
00447   //@@WTK WIN32, UNICODE
00448         //AppendMenu(hmenuShared, MF_BYPOSITION | MF_POPUP, m_pApp->m_hFileMenu, "&File");
00449         //AppendMenu(hmenuShared, MF_BYPOSITION | MF_POPUP, m_pApp->m_hHelpMenu, "&Other");
00450         AppendMenu(hmenuShared, MF_BYPOSITION | MF_POPUP, (UINT)m_pApp->m_hFileMenu, "&File");
00451         AppendMenu(hmenuShared, MF_BYPOSITION | MF_POPUP, (UINT)m_pApp->m_hHelpMenu, "&Other");
00452
00453         lpMenuWidths->width[0] = 1;
00454         lpMenuWidths->width[2] = 0;
00455         lpMenuWidths->width[4] = 1;
00456
00457         return S_OK;
00458 }
00459
00460
00461 //**********************************************************************
00462 //
00463 // COleInPlaceFrame::SetMenu
00464 //
00465 // Purpose:
00466 //
00467 //      Sets the application menu to the combined menu
00468 //
00469 // Parameters:
00470 //
00471 //      HMENU hmenuShared       - The combined menu
00472 //
00473 //      HOLEMENU holemenu       - Used by OLE
00474 //
00475 //      HWND hwndActiveObject   - Used by OLE
00476 //
00477 // Return Value:
00478 //
00479 //      S_OK
00480 //
00481 // Function Calls:
00482 //      Function                    Location
00483 //
00484 //      OutputDebugString           Windows API
00485 //      SetMenu                     Windows API
00486 //      OleSetMenuDescriptor        OLE API
00487 //                   OLE API
00488 //
00489 // Comments:
00490 //
00491 //********************************************************************
00492
00493 STDMETHODIMP COleInPlaceFrame::SetMenu (HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
00494 {
00495
00496         OutputDebugString("In IOIPF::SetMenu\r\n");
00497         CStabilize stabilize(m_pApp);
00498
00499         HMENU hMenu = m_pApp->m_hMainMenu;
00500
00501         if (holemenu)
00502                 hMenu = hmenuShared;
00503
00504         // call the windows api, not this method
00505         ::SetMenu (m_pApp->m_hAppWnd, hMenu);
00506
00507         OleSetMenuDescriptor(holemenu, m_pApp->m_hAppWnd, hwndActiveObject, this, m_pApp->m_lpDoc->m_lpActiveObject);
00508
00509         return S_OK;
00510 }
00511
00512
00513 //**********************************************************************
00514 //
00515 // COleInPlaceFrame::RemoveMenus
00516 //
00517 // Purpose:
00518 //
00519 //      Removes the container menus from the combined menu
00520 //
00521 // Parameters:
00522 //
00523 //      HMENU hmenuShared   - Handle to the combined menu.
00524 //
00525 // Return Value:
00526 //
00527 //      S_OK
00528 //
00529 // Function Calls:
00530 //      Function                    Location
00531 //
00532 //      OutputDebugString           Windows API
00533 //      GetMenuItemCount            Windows API
00534 //      RemoveMenu                  Windows API
00535 //                   OLE API
00536 //
00537 // Comments:
00538 //
00539 //********************************************************************
00540
00541 STDMETHODIMP COleInPlaceFrame::RemoveMenus (HMENU hmenuShared)
00542 {
00543         int retval;
00544
00545         OutputDebugString("In IOIPF::RemoveMenus\r\n");
00546
00547         while ((retval = GetMenuItemCount(hmenuShared)) && (retval != -1))
00548                 RemoveMenu(hmenuShared, 0, MF_BYPOSITION);
00549
00550         return S_OK;
00551 }
00552
00553 //**********************************************************************
00554 //
00555 // COleInPlaceFrame::SetStatusText
00556 //
00557 // Purpose:
00558 //
00559 //      Not Implemented
00560 //
00561 // Parameters:
00562 //
00563 //      Not Implemented
00564 //
00565 // Return Value:
00566 //
00567 //      Not Implemented
00568 //
00569 // Function Calls:
00570 //      Function                    Location
00571 //
00572 //      OutputDebugString           Windows API
00573 //
00574 // Comments:
00575 //
00576 //      This function is not implemented due to the fact
00577 //      that this application does not have a status bar.
00578 //
00579 //********************************************************************
00580
00581 //@@WTK WIN32, UNICODE
00582 //STDMETHODIMP COleInPlaceFrame::SetStatusText (LPCSTR lpszStatusText)
00583 STDMETHODIMP COleInPlaceFrame::SetStatusText (LPCOLESTR lpszStatusText)
00584 {
00585         OutputDebugString("In IOIPF::SetStatusText\r\n");
00586         return E_FAIL;
00587 }
00588
00589 //**********************************************************************
00590 //
00591 // COleInPlaceFrame::EnableModeless
00592 //
00593 // Purpose:
00594 //
00595 //      Enables/Disables container modeless dialogs
00596 //
00597 // Parameters:
00598 //
00599 //      BOOL fEnable    - Enable/Disable
00600 //
00601 // Return Value:
00602 //
00603 //      S_OK
00604 //
00605 // Function Calls:
00606 //      Function                    Location
00607 //
00608 //      OutputDebugString           Windows API
00609 //
00610 // Comments:
00611 //
00612 //      There are no modeless dialogs in this application, so the
00613 //      implementation of this method is trivial.
00614 //
00615 //********************************************************************
00616
00617 STDMETHODIMP COleInPlaceFrame::EnableModeless (BOOL fEnable)
00618 {
00619         OutputDebugString("In IOIPF::EnableModeless\r\n");
00620         return S_OK;
00621 }
00622
00623 //**********************************************************************
00624 //
00625 // COleInPlaceFrame::TranslateAccelerator
00626 //
00627 // Purpose:
00628 //
00629 //      Not Implemented
00630 //
00631 // Parameters:
00632 //
00633 //      Not Implemented
00634 //
00635 // Return Value:
00636 //
00637 //      Not Implemented
00638 //
00639 // Function Calls:
00640 //      Function                    Location
00641 //
00642 //      OutputDebugString           Windows API
00643 //
00644 // Comments:
00645 //
00646 //      Not Implemented
00647 //
00648 //********************************************************************
00649
00650 STDMETHODIMP COleInPlaceFrame::TranslateAccelerator (LPMSG lpmsg, WORD wID)
00651 {
00652         OutputDebugString("In IOIPF::TranslateAccelerator\r\n");
00653         return S_FALSE;
00654 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/ViewDIB/DIBSectn.c Source File

  • Multimedia
  • Gdi
  • ViewDIB

DIBSectn.c

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *
00003 *       THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *       ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *       TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 *       PARTICULAR PURPOSE.
00007 *
00008 *       Copyright (C) 1999  Microsoft Corporation.  All rights reserved.
00009 *
00010 \*****************************************************************************/
00011
00012 /* **********************************************************************
00013 DIBSectn.C  Sample source to demonstrate the use of DIBSections
00014
00015   Contains the following functions for Creating/Saving/Drawing:
00016     DSCreateDIBSection()
00017     DSLoadDIBSectionFromBMPFile()
00018     DSDrawDIBSectionOnDC()
00019     DSStoreDIBSectionInBMPFile()
00020
00021   Contains the following helper functions:
00022     DSCreatePaletteForDIBSection()
00023     DSGetBITMAPINFOForDIBSection()
00024     DSColorTableSize()
00025     DSImageBitsSize()
00026     DSTotalBytesSize()
00027     DSGetPointerToDIBSectionImageBits()
00028     DSCreateSpectrumPalette()
00029   DSBitsperPixel()
00030   DSGetOptimalDIBFormat()
00031   DSGetRGBBitsPerPixel()
00032   DSGetDIBSectionFromClipboard()
00033   DSPutDIBSectionOnClipboard()
00034   DSCopyBitmapEx()
00035   DSCopyBitmap()
00036
00037   Notes:
00038     * Most of the functions in this module which are passed an HBITMAP
00039       as a parameter assume the HBITMAP is not selected into a device
00040       context at the time of the call. Since the underlying APIs usually
00041       require this, so do these functions.
00042     * Throughout this module, code is in place to handle color tables
00043       in DIBSections (in the BITMAPINFO) even when it is not necessary.
00044       This helps the re-usability of the code, since it is often desirable
00045       to include a "suggested" color table when storing 16bpp or higher
00046       BMP files.
00047     *
00048
00049 ********************************************************************** */
00050
00051 #include <Windows.h>
00052 #include <stdlib.h>
00053 #include <stdio.h>
00054 #include "DibSectn.h"
00055
00056 // Macro to determine the number of bytes per line in the DIB bits. This
00057 //  accounts for DWORD alignment by adding 31 bits, then dividing by 32,
00058 //  then rounding up to the next highest count of 4-bytes. Then, we
00059 //  multiply by 4 to get the total byte count.
00060
00061 #define BYTESPERLINE(Width, BPP) ((WORD)((((DWORD)(Width) * (DWORD)(BPP) + 31) >> 5)) << 2)
00062 #define NEW_DIB_FORMAT(lpbih) (lpbih->biSize != sizeof(BITMAPCOREHEADER))
00063
00064 /* Macro to swap two values */
00065 #define SWAP(x, y)   ((x)^=(y)^=(x)^=(y))
00066
00067 /* **********************************************************************
00068   HBITMAP DSCreateDIBSection(DWORD dwX, DWORD dwY, WORD wBits)
00069
00070   PARAMETERS:
00071     DWORD dwX    - Desired width of the DIBSection
00072     DWORD dwY    - Desired height of the DIBSection
00073     WORD  wBits  - Desired bit-depth of the DIBSection
00074
00075   RETURNS:
00076     HBITMAP      - a DIBSection HBITMAP of the desired size and bit-depth
00077                    NULL on failure
00078
00079   REMARKS:
00080     Creates a DIBSection based on the criteria passed in as parameters.
00081     The DIBSection is created with a default color table - for 8bpp and
00082     above, this is a spectrum palette. For 4bpp, it is a stock 16 color
00083     table, and for 1bpp it is black and white.
00084
00085 ********************************************************************** */
00086
00087 HBITMAP WINAPI DSCreateDIBSection(DWORD dwX, DWORD dwY, WORD wBits)
00088 {
00089     HBITMAP         hBitmap;
00090     LPBYTE          pBits;
00091     int             nInfoSize;
00092     LPBITMAPINFO    pbmi;
00093     HDC             hRefDC;
00094
00095     nInfoSize = sizeof(BITMAPINFOHEADER);
00096
00097     if(wBits <= 8)
00098         nInfoSize += sizeof(RGBQUAD) * (1 << wBits);
00099
00100     if((wBits == 16) || (wBits == 15) || (wBits == 32))
00101         nInfoSize += 3 * sizeof(DWORD);
00102
00103     // Create the header big enough to contain color table and bitmasks if needed
00104     pbmi = (LPBITMAPINFO)malloc(nInfoSize);
00105     if ( !pbmi )
00106         return (HBITMAP)NULL;
00107
00108     ZeroMemory(pbmi, nInfoSize);
00109     pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
00110     pbmi->bmiHeader.biWidth = dwX;
00111     pbmi->bmiHeader.biHeight = dwY;
00112     pbmi->bmiHeader.biPlanes = 1;
00113     pbmi->bmiHeader.biBitCount = wBits;
00114     pbmi->bmiHeader.biCompression = BI_RGB; // override below for 16 and 32bpp
00115
00116     switch(wBits)
00117     {
00118         case 24:
00119             // 24bpp requires no special handling
00120         break;
00121
00122         case 15:
00123     {   // if it's 15bpp, fill in the masks and override the compression
00124             // these are the default masks - you could change them if needed
00125             LPDWORD pMasks = (LPDWORD)(pbmi->bmiColors);
00126             pMasks[0] = 0x00007c00;
00127             pMasks[1] = 0x000003e0;
00128             pMasks[2] = 0x0000001f;
00129             pbmi->bmiHeader.biCompression = BI_BITFIELDS;
00130       pbmi->bmiHeader.biBitCount = 16;  // 15 bpp is really 16 bpp
00131         }
00132         break;
00133
00134     case 16:
00135         {   // if it's 16bpp, fill in the masks and override the compression
00136             // these are the default masks - you could change them if needed
00137             LPDWORD pMasks = (LPDWORD)(pbmi->bmiColors);
00138             pMasks[0] = 0x0000f800;
00139             pMasks[1] = 0x000007e0;
00140             pMasks[2] = 0x0000001f;
00141             pbmi->bmiHeader.biCompression = BI_BITFIELDS;
00142         }
00143         break;
00144
00145         case 32:
00146         {   // if it's 32bpp, fill in the masks and override the compression
00147             // these are the default masks - you could change them if needed
00148             LPDWORD pMasks = (LPDWORD)(pbmi->bmiColors);
00149             pMasks[0] = 0x00ff0000;
00150             pMasks[1] = 0x0000ff00;
00151             pMasks[2] = 0x000000ff;
00152             pbmi->bmiHeader.biCompression = BI_BITFIELDS;
00153         }
00154         break;
00155
00156         case 8:
00157         {
00158             HPALETTE        hPal;
00159             PALETTEENTRY    pe[256];
00160             int             i;
00161
00162             // at this point, prgb points to the color table, even
00163             // if bitmasks are present
00164             hPal = DSCreateSpectrumPalette();
00165             GetPaletteEntries(hPal, 0, 256, pe);
00166
00167             for(i=0;i<256;i++)
00168             {
00169                 pbmi->bmiColors[i].rgbRed = pe[i].peRed;
00170                 pbmi->bmiColors[i].rgbGreen = pe[i].peGreen;
00171                 pbmi->bmiColors[i].rgbBlue = pe[i].peBlue;
00172                 pbmi->bmiColors[i].rgbReserved = 0;
00173             }
00174
00175             DeleteObject(hPal);
00176             pbmi->bmiHeader.biClrUsed = 256;
00177         }
00178         break;
00179
00180         case 4:
00181         {   // Use a default 16 color table for 4bpp DIBSections
00182             RGBTRIPLE       rgb[16] = { { 0x00, 0x00, 0x00 }, // black
00183                                         { 0x80, 0x00, 0x00 }, // dark red
00184                                         { 0x00, 0x80, 0x00 }, // dark green
00185                                         { 0x80, 0x80, 0x00 }, // dark yellow
00186                                         { 0x00, 0x00, 0x80 }, // dark blue
00187                                         { 0x80, 0x00, 0x80 }, // dark magenta
00188                                         { 0x00, 0x80, 0x80 }, // dark cyan
00189                                         { 0xC0, 0xC0, 0xC0 }, // light gray
00190                                     //  { 0xC0, 0xDC, 0xC0 }, // money green
00191                                     //  { 0xA6, 0xCA, 0xF0 }, // sky blue
00192                                     //  { 0xFF, 0xFB, 0xF0 }, // cream
00193                                     //  { 0xA0, 0xA0, 0xA4 }, // light gray
00194                                         { 0x80, 0x80, 0x80 }, // medium gray
00195                                         { 0xFF, 0x00, 0x00 }, // red
00196                                         { 0x00, 0xFF, 0x00 }, // green
00197                                         { 0xFF, 0xFF, 0x00 }, // yellow
00198                                         { 0x00, 0x00, 0xFF }, // blue
00199                                         { 0xFF, 0x00, 0xFF }, // magenta
00200                                         { 0x00, 0xFF, 0xFF }, // cyan
00201                                         { 0xFF, 0xFF, 0xFF } }; // white
00202             int             i;
00203
00204             for(i=0;i<16;i++)
00205             {
00206                 pbmi->bmiColors[i].rgbRed = rgb[i].rgbtRed;
00207                 pbmi->bmiColors[i].rgbGreen = rgb[i].rgbtGreen;
00208                 pbmi->bmiColors[i].rgbBlue = rgb[i].rgbtBlue;
00209                 pbmi->bmiColors[i].rgbReserved = 0;
00210             }
00211             pbmi->bmiHeader.biClrUsed = 16;
00212         }
00213         break;
00214
00215         case 1: // BW
00216             pbmi->bmiColors[0].rgbRed = pbmi->bmiColors[0].rgbGreen = pbmi->bmiColors[0].rgbBlue = 0;
00217             pbmi->bmiColors[1].rgbRed = pbmi->bmiColors[1].rgbGreen = pbmi->bmiColors[1].rgbBlue = 255;
00218             pbmi->bmiColors[0].rgbReserved = pbmi->bmiColors[1].rgbReserved = 0;
00219         break;
00220     }
00221
00222     hRefDC = GetDC(NULL);
00223     hBitmap = CreateDIBSection(hRefDC, pbmi, DIB_RGB_COLORS, &pBits, NULL, 0);
00224     nInfoSize = GetLastError();
00225     ReleaseDC(NULL, hRefDC);
00226     free(pbmi);
00227
00228     if(hBitmap == NULL)
00229     {
00230         TCHAR   szTemp[64];
00231         _snprintf(szTemp, sizeof(szTemp)-1, "Error %d", nInfoSize);
00232         szTemp[sizeof(szTemp)-1] = '\0';
00233         MessageBox(NULL, szTemp, "Error", MB_OK);
00234     }
00235
00236     return hBitmap;
00237 }
00238
00239 /* ******************************************************************* */
00240
00241 /* **********************************************************************
00242   BOOL DSLoadDIBSectionFromBMPFile(LPTSTR, HBITMAP *, HPALETTE *)
00243
00244   PARAMETERS:
00245     LPTSTR     - Name of (BMP) file from which to obtain DIBSection
00246     HBITMAP *  - Pointer to handle which receives HBITMAP DIBSection
00247     HPALETTE * - Pointer to handle which receives Palette
00248
00249   RETURNS:
00250     BOOL    - TRUE for success, FALSE for failure
00251
00252   REMARKS:
00253     Creates a DIBSection based on the contents of a BMP file.
00254     If the HPALETTE pointer is NULL, no palette is retreived.
00255     If the HPALETTE pointer is non-NULL, the palette is created by
00256     calling DSCreatePaletteForDIBSection. See its comments for
00257     information regarding its functionality.
00258
00259     The LoadImage() API is used to load the bitmap.
00260
00261 ********************************************************************** */
00262
00263 BOOL WINAPI DSLoadDIBSectionFromBMPFile(LPTSTR szFileName, HBITMAP *phBitmap, HPALETTE *phPalette)
00264 {
00265     if(phBitmap == NULL)
00266         return FALSE;
00267
00268   *phBitmap = NULL;
00269
00270     if(phPalette != NULL)
00271         *phPalette = NULL;
00272
00273     // Use LoadImage() to get the image loaded into a DIBSection
00274     *phBitmap = LoadImage(NULL, szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE);
00275     if(*phBitmap == NULL)
00276         return FALSE;
00277
00278   // if they want a palette, get one
00279     if(phPalette != NULL)
00280         *phPalette = DSCreatePaletteForDIBSection(*phBitmap);
00281
00282   return TRUE;
00283 }
00284
00285 /* ******************************************************************* */
00286
00287 /* **********************************************************************
00288   BOOL DSDrawDIBSectionOnDC(HDC, HBITMAP, LPRECT)
00289
00290   PARAMETERS:
00291     HDC     - HDC on which to draw the DIBSection
00292     HBITMAP - the DIBSection to be drawn
00293     LPRECT  - pointer to a rectangle containing the target coordinates
00294
00295   RETURNS:
00296     BOOL    - TRUE for success, FALSE for failure
00297
00298   REMARKS:
00299     Draws a DIBSection on a target DC.
00300     The bitmap is drawn using StretchBlt() if the target DC is a screen
00301     DC and StretchDIBits() otherwise.
00302     A pallete is used, only if the target DC is a screen DC. A more
00303     robust implementation might check RASTERCAPS to see if the target
00304     device is a palettized device.
00305     Also, the palette is selected as a background palette. If it is
00306     desirable to have the palette as a foreground palette, simply
00307     obtain and realize the palette in the foreground before calling
00308     this function.
00309
00310 ********************************************************************** */
00311
00312 BOOL WINAPI DSDrawDIBSectionOnDC(HDC hDC, HBITMAP hBitmap, LPRECT pRect)
00313 {
00314     DIBSECTION  ds;
00315     HPALETTE    hPal, hOldPal;
00316     BOOL        bRes;
00317
00318     GetObject(hBitmap, sizeof(DIBSECTION), &ds);
00319
00320     if(GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)
00321     {   // if it's a palette device, select and realize a palette
00322         // as a background palette (won't cause a problem is the
00323         // palette was not selected in the foreground in the main app
00324         hPal = DSCreatePaletteForDIBSection(hBitmap);
00325         hOldPal = SelectPalette(hDC, hPal, TRUE);
00326         RealizePalette(hDC);
00327     }
00328
00329     if(GetDeviceCaps(hDC, TECHNOLOGY) == DT_RASDISPLAY)
00330     { // going to the screen, use StretchBlt()
00331         HDC hMemDC;
00332         HBITMAP hOldBitmap;
00333
00334         hMemDC = CreateCompatibleDC(hDC);
00335         hOldBitmap = SelectObject(hMemDC, hBitmap);
00336         bRes = StretchBlt(hDC, pRect->left, pRect->top,
00337                 pRect->right-pRect->left, pRect->bottom-pRect->top,
00338                 hMemDC, 0, 0, ds.dsBm.bmWidth, ds.dsBm.bmHeight, SRCCOPY);
00339         SelectObject(hMemDC, hOldBitmap);
00340         DeleteDC(hMemDC);
00341     }
00342     else
00343     { // going to the printer, use StretchDIBits()
00344         LPBITMAPINFO    pbmi;
00345
00346         // if the printer is palettized,
00347         pbmi = DSGetBITMAPINFOForDIBSection(hBitmap);
00348         if ( !pbmi )
00349             return FALSE;
00350
00351         bRes = (GDI_ERROR != StretchDIBits(hDC, pRect->left, pRect->top,
00352                 pRect->right-pRect->left, pRect->bottom-pRect->top,
00353                 0, 0, ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBits,
00354                 pbmi, DIB_RGB_COLORS, SRCCOPY));
00355         free(pbmi);
00356     }
00357
00358     if(GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)
00359     {
00360         SelectPalette(hDC, hOldPal, TRUE);
00361         DeleteObject(hPal);
00362     }
00363
00364     return bRes;
00365 }
00366
00367 /* ******************************************************************* */
00368
00369 /* **********************************************************************
00370   BOOL DSStoreDIBSectionInBMPFile(LPTSTR, HBITMAP)
00371
00372   PARAMETERS:
00373     LPTSTR     - Name of (BMP) file in which to store the DIBSection
00374     HBITMAP    - handle for HBITMAP DIBSection to be stored
00375
00376   RETURNS:
00377     BOOL    - TRUE for success, FALSE for failure
00378
00379   REMARKS:
00380     Stores the DIBSection in a BMP file.
00381
00382 ********************************************************************** */
00383
00384 BOOL WINAPI DSStoreDIBSectionInBMPFile(LPTSTR szFileName, HBITMAP hBitmap)
00385 {
00386     HANDLE              hFile;
00387     BITMAPFILEHEADER    bfh;
00388     LPBITMAPINFO        pbmi;
00389     DWORD               dwTotalDIBBytes, dwSize, dwWritten;
00390     LPBYTE              pBits;
00391
00392     // Open the file for writing (overwrites any previous version of that file)
00393     if((hFile=CreateFile(szFileName,GENERIC_WRITE,0,NULL ,CREATE_ALWAYS, SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS,NULL)) == INVALID_HANDLE_VALUE)
00394         return FALSE;
00395
00396     if ( GetFileType(hFile) != FILE_TYPE_DISK )
00397     {
00398         CloseHandle(hFile);
00399         return FALSE;
00400     }
00401
00402     // Get the BITMAPINFO for the DIBSection
00403     if((pbmi = DSGetBITMAPINFOForDIBSection(hBitmap)) == NULL)
00404     {
00405         CloseHandle(hFile);
00406         return FALSE;
00407     }
00408
00409     // What's the total size of the DIB information (not counting file header)?
00410     dwTotalDIBBytes = DSTotalBytesSize(pbmi);
00411
00412     // Construct the file header
00413     ZeroMemory(&bfh, sizeof(BITMAPFILEHEADER));
00414     bfh.bfType          = 0x4d42; // 'BM'
00415     bfh.bfSize          = dwTotalDIBBytes + sizeof(BITMAPFILEHEADER);
00416     bfh.bfReserved1     = 0;
00417     bfh.bfReserved2     = 0;
00418     bfh.bfOffBits       = (DWORD)(sizeof(BITMAPFILEHEADER) + pbmi->bmiHeader.biSize + DSColorTableSize(pbmi));
00419
00420     // Write the file header
00421     if((! WriteFile(hFile, &bfh, sizeof(BITMAPFILEHEADER), &dwWritten, NULL)) ||
00422         (dwWritten != sizeof(BITMAPFILEHEADER)))
00423     {
00424         free(pbmi);
00425         CloseHandle(hFile);
00426         return FALSE;
00427     }
00428
00429     // Write the BITMAPINFO
00430     dwSize = sizeof(BITMAPINFOHEADER) + DSColorTableSize(pbmi);
00431
00432     if((! WriteFile(hFile, pbmi, dwSize, &dwWritten, NULL)) ||
00433         (dwWritten != dwSize))
00434     {
00435         free(pbmi);
00436         CloseHandle(hFile);
00437         return FALSE;
00438     }
00439
00440     // Write the bits
00441     pBits = DSGetPointerToDIBSectionImageBits(hBitmap);
00442     dwSize = DSImageBitsSize(pbmi);
00443
00444     if((! WriteFile(hFile, pBits, dwSize, &dwWritten, NULL)) ||
00445         (dwWritten != dwSize))
00446     {
00447         free(pbmi);
00448         CloseHandle(hFile);
00449         return FALSE;
00450     }
00451
00452     // clean up and leave
00453     free(pbmi);
00454     CloseHandle(hFile);
00455
00456     return TRUE;
00457 }
00458
00459 /* ******************************************************************* */
00460
00461 /* **********************************************************************
00462   HPALETTE DSCreatePaletteForDIBSection(HBITMAP)
00463
00464   PARAMETERS:
00465     HBITMAP - a DIBSection for which to get a palette
00466
00467   RETURNS:
00468     HPALETTE - a palette which can be used to display the DIBSection
00469                on palettized devices
00470
00471   REMARKS:
00472     Creates a palette to be used to display the DIBSection on a
00473     palettized display device.
00474
00475     If the DIBSection contains a color table, those colors are used
00476     to create the palette. However, if the DIBSection is greater than
00477     8bpp (ie sans color table), then a suitable palette is derived
00478     from either CreateHalftonePalette() or GetStockObject() depending
00479     on the video mode.
00480
00481 ********************************************************************** */
00482
00483 HPALETTE WINAPI DSCreatePaletteForDIBSection(HBITMAP hBitmap)
00484 {
00485     BITMAP      bm;
00486     HPALETTE    hPalette;
00487
00488     // Get the color depth of the DIBSection
00489     if (!GetObject(hBitmap, sizeof(BITMAP), &bm))
00490     return (HPALETTE)NULL;
00491
00492     // If the DIBSection is 256 color or less, it has a color table
00493     if((bm.bmBitsPixel * bm.bmPlanes) <= 8)
00494     {
00495         HDC             hMemDC;
00496         HBITMAP         hOldBitmap;
00497         RGBQUAD         rgb[256];
00498         LPLOGPALETTE    pLogPal;
00499         WORD            i;
00500         int             nColors;
00501
00502         // Find out how many colors are in the color table
00503         nColors = 1 << (bm.bmBitsPixel * bm.bmPlanes);
00504
00505         // Create a memory DC and select the DIBSection into it
00506         hMemDC = CreateCompatibleDC(NULL);
00507         hOldBitmap = SelectObject(hMemDC, hBitmap);
00508
00509         ZeroMemory(rgb, sizeof(rgb));
00510
00511     // Get the DIBSection's color table
00512         GetDIBColorTable(hMemDC, 0, nColors, rgb);
00513
00514         // Create a palette from the color table
00515         pLogPal = malloc(sizeof(LOGPALETTE) + (nColors*sizeof(PALETTEENTRY)));
00516         if ( !pLogPal )
00517         {
00518             DeleteDC(hMemDC);
00519             return (HPALETTE)NULL;
00520         }
00521
00522         pLogPal->palVersion = 0x300;
00523         pLogPal->palNumEntries = (WORD)nColors;
00524
00525         for(i=0;i<nColors;i++)
00526         {
00527             pLogPal->palPalEntry[i].peRed = rgb[i].rgbRed;
00528             pLogPal->palPalEntry[i].peGreen = rgb[i].rgbGreen;
00529             pLogPal->palPalEntry[i].peBlue = rgb[i].rgbBlue;
00530             pLogPal->palPalEntry[i].peFlags = 0;
00531         }
00532
00533         hPalette = CreatePalette(pLogPal);
00534
00535         // Clean up
00536         free(pLogPal);
00537         SelectObject(hMemDC, hOldBitmap);
00538         DeleteDC(hMemDC);
00539
00540   } else  {  // It has no color table, so make one for the current video mode
00541     HDC hdc = GetDC(NULL);
00542     int iBitsPixel = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
00543
00544     if (iBitsPixel <= 8)
00545       hPalette = CreateHalftonePalette(hdc);
00546     else
00547       hPalette = GetStockObject(DEFAULT_PALETTE);
00548
00549     ReleaseDC(NULL, hdc);
00550   }
00551
00552   return hPalette;
00553 }
00554
00555 /* ******************************************************************* */
00556
00557 /* **********************************************************************
00558   LPBITMAPINFO DSGetBITMAPINFOForDIBSection(HBITMAP)
00559
00560   PARAMETERS:
00561     HBITMAP - a DIBSection for which to get the BITMAPINFO
00562
00563   RETURNS:
00564     LPBITMAPINFO - a pointer to a newly allocated memory block containing
00565                    the BITMAPINFO structure which describes the DIBSection.
00566
00567   REMARKS:
00568     Allocates and returns a pointer to a BITMAPINFO for the DIBSection.
00569     The returned BITMAPINFO contains a color table, even if the
00570     bit-depth does not require one - this way the caller can override
00571     the optional color table if need be.
00572     The caller is responsible for de-allocating the memory block using
00573     the CRT function free().
00574
00575 ********************************************************************** */
00576
00577 LPBITMAPINFO WINAPI DSGetBITMAPINFOForDIBSection(HBITMAP hBitmap)
00578 {
00579     LPBITMAPINFO    pbmi;
00580     DIBSECTION      ds;
00581     LPRGBQUAD       prgb;
00582
00583     GetObject(hBitmap, sizeof(DIBSECTION), &ds);
00584
00585     // load the header and the bitmasks if present
00586     // per function comments above, we allocate space for a color
00587     // table even if it is not needed
00588     if(ds.dsBmih.biCompression == BI_BITFIELDS)
00589     {   // has a bitmask - be sure to allocate for and copy them
00590         pbmi = malloc(sizeof(BITMAPINFOHEADER) + (3*sizeof(DWORD)) + (256*sizeof(RGBQUAD)));
00591         if ( !pbmi )
00592             return (LPBITMAPINFO)NULL;
00593
00594         CopyMemory(&(pbmi->bmiHeader), &(ds.dsBmih), sizeof(BITMAPINFOHEADER) + (3*sizeof(DWORD)));
00595         prgb = (LPRGBQUAD)&(pbmi->bmiColors[3]);
00596     }
00597     else
00598     {   // no bitmask - just the header and color table
00599         pbmi = malloc(sizeof(BITMAPINFOHEADER) + (256*sizeof(RGBQUAD)));
00600         if ( !pbmi )
00601             return (LPBITMAPINFO)NULL;
00602
00603         CopyMemory(&(pbmi->bmiHeader), &(ds.dsBmih), sizeof(BITMAPINFOHEADER));
00604         prgb = pbmi->bmiColors;
00605     }
00606
00607     // at this point, prgb points to the color table, even
00608     // if bitmasks are present
00609
00610     // Now for the color table
00611     if((ds.dsBm.bmBitsPixel * ds.dsBm.bmPlanes) <= 8)
00612     {   // the DIBSection is 256 color or less (has color table)
00613         HDC             hMemDC;
00614         HBITMAP         hOldBitmap;
00615         hMemDC = CreateCompatibleDC(NULL);
00616         hOldBitmap = SelectObject(hMemDC, hBitmap);
00617         GetDIBColorTable(hMemDC, 0, 1<<(ds.dsBm.bmBitsPixel*ds.dsBm.bmPlanes), prgb);
00618         SelectObject(hMemDC, hOldBitmap);
00619         DeleteDC(hMemDC);
00620     }
00621     else
00622     {   // the DIBSection is >8bpp (has no color table) so make one up
00623         HPALETTE        hPal;
00624         PALETTEENTRY    pe[256];
00625         int             i;
00626
00627         // where are we going to get the colors? from a spectrum palette
00628         hPal = DSCreateSpectrumPalette();
00629         GetPaletteEntries(hPal, 0, 256, pe);
00630
00631         for(i=0;i<256;i++)
00632         {
00633             prgb[i].rgbRed = pe[i].peRed;
00634             prgb[i].rgbGreen = pe[i].peGreen;
00635             prgb[i].rgbBlue = pe[i].peBlue;
00636             prgb[i].rgbReserved = 0;
00637         }
00638
00639         DeleteObject(hPal);
00640         pbmi->bmiHeader.biClrUsed = 256;
00641     }
00642
00643     return pbmi;
00644 }
00645
00646 /* ******************************************************************* */
00647
00648 /* **********************************************************************
00649   DWORD DSColorTableSize(LPBITMAPINFO pbmi)
00650
00651   PARAMETERS:
00652     LPBITMAPINFO - pointer to a BITMAPINFO describing a DIB
00653
00654   RETURNS:
00655     DWORD    - the size, in bytes, of the color table for the DIB
00656
00657   REMARKS:
00658     Calculates and returns the size, in bytes, of the color table for
00659     the DIB described by the BITMAPINFO.
00660
00661 ********************************************************************** */
00662
00663 DWORD WINAPI DSColorTableSize(LPBITMAPINFO pbmi)
00664 {
00665     DWORD dwColors;
00666
00667     dwColors = 0;
00668     if(pbmi->bmiHeader.biClrUsed != 0)
00669         dwColors = pbmi->bmiHeader.biClrUsed;
00670     else if(pbmi->bmiHeader.biBitCount > 8)
00671         dwColors = 0;
00672     else
00673         dwColors = 1 << (pbmi->bmiHeader.biBitCount * pbmi->bmiHeader.biPlanes);
00674
00675     if(pbmi->bmiHeader.biCompression == BI_BITFIELDS)
00676         return (sizeof(DWORD)*3) + (dwColors*sizeof(RGBQUAD));
00677
00678     return (dwColors*sizeof(RGBQUAD));
00679 }
00680
00681 /* ******************************************************************* */
00682
00683 /* **********************************************************************
00684   DWORD DSImageBitsSize(LPBITMAPINFO pbmi)
00685
00686   PARAMETERS:
00687     LPBITMAPINFO - pointer to a BITMAPINFO describing a DIB
00688
00689   RETURNS:
00690     DWORD    - the size, in bytes, of the DIB's image bits
00691
00692   REMARKS:
00693     Calculates and returns the size, in bytes, of the image bits for
00694     the DIB described by the BITMAPINFO.
00695
00696 ********************************************************************** */
00697
00698 DWORD WINAPI DSImageBitsSize(LPBITMAPINFO pbmi)
00699 {
00700     switch(pbmi->bmiHeader.biCompression)
00701     {
00702         case BI_RLE8:
00703         case BI_RLE4:
00704             return pbmi->bmiHeader.biSizeImage;
00705         break;
00706
00707     case BI_RGB:
00708         case BI_BITFIELDS:
00709             return BYTESPERLINE(pbmi->bmiHeader.biWidth,pbmi->bmiHeader.biBitCount*pbmi->bmiHeader.biPlanes)*pbmi->bmiHeader.biHeight;
00710         break;
00711     }
00712
00713     return 0;
00714 }
00715
00716 /* ******************************************************************* */
00717
00718 /* **********************************************************************
00719   DWORD DSTotalBytesSize(LPBITMAPINFO pbmi)
00720
00721   PARAMETERS:
00722     LPBITMAPINFO - pointer to a BITMAPINFO describing a DIB
00723
00724   RETURNS:
00725     DWORD    - the size, in bytes, of the DIB's memory footprint
00726
00727   REMARKS:
00728     Calculates and returns the size, in bytes, of the entire CF_DIB
00729     bitmap described by the BITMAPINFO - including header, color table,
00730     and image bits.
00731
00732 ********************************************************************** */
00733
00734 DWORD WINAPI DSTotalBytesSize(LPBITMAPINFO pbmi)
00735 {
00736     return DSImageBitsSize(pbmi) + sizeof(BITMAPINFOHEADER) + DSColorTableSize(pbmi);
00737 }
00738
00739 /* ******************************************************************* */
00740
00741 /* **********************************************************************
00742   LPBYTE DSGetPointerToDIBSectionImageBits(HBITMAP hBitmap)
00743
00744   PARAMETERS:
00745     HBITMAP    - handle for HBITMAP DIBSection
00746
00747   RETURNS:
00748     LPBYTE     - pointer to the bitmap's bits
00749
00750   REMARKS:
00751     Returns a pointer to the DIBSection's image bits.
00752
00753 ********************************************************************** */
00754
00755 // get a pointer which points to the image bits for a DIBSection
00756 LPBYTE WINAPI DSGetPointerToDIBSectionImageBits(HBITMAP hBitmap)
00757 {
00758     DIBSECTION  ds;
00759
00760     if (!GetObject(hBitmap, sizeof(DIBSECTION), &ds))
00761     return NULL;
00762
00763     return ds.dsBm.bmBits;
00764 }
00765
00766 /* ******************************************************************* */
00767
00768 /* **********************************************************************
00769   HPALETTE DSCreateSpectrumPalette(void)
00770
00771   PARAMETERS:
00772     void
00773
00774   RETURNS:
00775     HPALETTE - a handle to a spectrum palette - NULL on failure
00776
00777   REMARKS:
00778     This function was stolen from Mike Irvine's SEEDIB sample. There's
00779     no source code comments in his version either :)
00780
00781     This function will build a palette with a spectrum of colors.  It is
00782     useful when you want to display a number of DIBs each with a different
00783     palette yet still have an a good selection of colors to which the
00784     DIBs' colors will be mapped.
00785
00786 ********************************************************************** */
00787
00788 HPALETTE WINAPI DSCreateSpectrumPalette(void)
00789 {
00790     HPALETTE hPal;
00791     LPLOGPALETTE lplgPal;
00792     BYTE red, green, blue;
00793     int i;
00794
00795     lplgPal = (LPLOGPALETTE)GlobalAlloc(GPTR, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * 256);
00796
00797     if (!lplgPal)
00798       return NULL;
00799
00800     lplgPal->palVersion = 0x300;
00801     lplgPal->palNumEntries = 256;
00802
00803     red = green = blue = 0;
00804
00805     for (i = 0; i < 256; i++) {
00806         lplgPal->palPalEntry[i].peRed   = red;
00807         lplgPal->palPalEntry[i].peGreen = green;
00808         lplgPal->palPalEntry[i].peBlue  = blue;
00809         lplgPal->palPalEntry[i].peFlags = (BYTE)0;
00810
00811         if (!(red += 32))
00812             if (!(green += 32))
00813                 blue += 64;
00814     }
00815
00816     hPal = CreatePalette(lplgPal);
00817     GlobalFree(lplgPal);
00818
00819     return hPal;
00820 }
00821
00822 /* ******************************************************************* */
00823
00824 /* **********************************************************************
00825   DWORD DSBitsPerPixel(HBITMAP)
00826
00827   PARAMETERS:
00828   The handle of the DIB Section to evaluate
00829
00830   RETURNS:
00831     DWORD - the total number of color bits used by the surface
00832
00833 ********************************************************************** */
00834
00835 DWORD WINAPI DSBitsPerPixel (HBITMAP hBitmap)
00836 {
00837     DIBSECTION  ds;
00838
00839     GetObject(hBitmap, sizeof(DIBSECTION), &ds);
00840     return (ds.dsBmih.biBitCount * ds.dsBmih.biPlanes);
00841 }
00842
00843 /* ******************************************************************* */
00844
00845 /* **********************************************************************
00846   BOOL DSGetOptimalDIBFormat(HDC, BITMAPINFOHEADER*)
00847
00848   PURPOSE:
00849   Retrieves the optimal DIB format for a display
00850   device. The optimal DIB format is the format that
00851   exactly matches the format of the target device.
00852   Obtaining this is very important when dealing with
00853   16bpp modes because you need to know what bitfields
00854   value to use (555 or 565 for example).
00855
00856   You normally use this function to get the best
00857   format to pass to CreateDIBSection() in order to
00858   maximize blt'ing performance.
00859
00860   PARAMETERS:
00861   hdc - Device to get the optimal format for.
00862   pbi - Pointer to a BITMAPINFO + color table
00863     (room for 256 colors is assumed).
00864
00865   OUTPUT:
00866   pbi - Contains the optimal DIB format. In the
00867     <= 8bpp case, the color table will contain the
00868     system palette. In the >=16bpp case, the "color
00869     table" will contain the correct bit fields (see
00870     BI_BITFIELDS in the Platform SDK documentation
00871     for more information).
00872
00873   RETURNS:
00874     Returns TRUE if the function succeeds
00875
00876   NOTES:
00877   If you are going to use this function on a 8bpp device
00878   you should make sure the color table contains a identity
00879   palette for optimal blt'ing.
00880
00881 ********************************************************************** */
00882
00883 BOOL WINAPI DSGetOptimalDIBFormat(HDC hdc, BITMAPINFOHEADER *pbi)
00884 {
00885    HBITMAP hbm;
00886    BOOL bRet = TRUE;
00887
00888    // Create a memory bitmap that is compatible with the
00889    // format of the target device.
00890    hbm = CreateCompatibleBitmap(hdc, 1, 1);
00891    if (!hbm)
00892        return FALSE;
00893
00894    // Initialize the header.
00895    ZeroMemory(pbi, sizeof(BITMAPINFOHEADER));
00896    pbi->biSize = sizeof(BITMAPINFOHEADER);
00897
00898    // First call to GetDIBits will fill in the optimal biBitCount.
00899    bRet = GetDIBits(hdc, hbm, 0, 1, NULL, (BITMAPINFO*)pbi, DIB_RGB_COLORS);
00900
00901    // Second call to GetDIBits will get the optimal color table, o
00902    // or the optimal bitfields values.
00903    if (bRet)
00904        bRet = GetDIBits(hdc, hbm, 0, 1, NULL, (BITMAPINFO*)pbi, DIB_RGB_COLORS);
00905
00906    // Clean up.
00907    DeleteObject(hbm);
00908
00909    return bRet;
00910 }
00911
00912 /* ******************************************************************* */
00913 // CountBits(DWORD)
00914 //
00915 // Counts the number of set bits in a DWORD.
00916 BYTE CountBits(DWORD dw)
00917 {
00918    int iBits = 0;
00919
00920    while (dw) {
00921        iBits += (dw & 1);
00922        dw >>= 1;
00923    }
00924
00925    return (BYTE)iBits;
00926 }
00927
00928 /* **********************************************************************
00929   BOOL DSGetRGBBitsPerPixel(HDC, PINT, PINT, PINT)
00930
00931   PURPOSE:
00932   Retrieves the number of bits of color resolution for each
00933   color channel of a specified.
00934
00935   PARAMETERS:
00936   hdc - Device to get the color information for.
00937
00938   OUTPUT:
00939   pRed   - Number of distinct red levels the device can display.
00940   pGreen - Number of distinct green levels the device can display.
00941   pBlue  - Number of distinct blue levels the device can display.
00942
00943   RETURNS:
00944     Returns TRUE if the function succeeds
00945
00946   NOTES:
00947   This function does not return any meaningful information for
00948   palette-based devices.
00949
00950 ********************************************************************** */
00951
00952 BOOL WINAPI DSGetRGBBitsPerPixel(HDC hdc, PINT pRed, PINT pGreen, PINT pBlue)
00953 {
00954    BITMAPINFOHEADER *pbi;
00955    LPDWORD lpdw;
00956    BOOL bRet = TRUE;
00957
00958    // If the target device is palette-based, then bail because there is no
00959    // meaningful way to determine separate RGB bits per pixel.
00960    if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
00961        return FALSE;
00962
00963    // Shortcut for handling 24bpp cases.
00964    if (GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL) == 24) {
00965        *pRed = *pGreen = *pBlue = 8;
00966        return TRUE;
00967    }
00968
00969    // Allocate room for a header and a color table.
00970    pbi = (BITMAPINFOHEADER *)GlobalAlloc(GPTR, sizeof(BITMAPINFOHEADER) +
00971                                                sizeof(RGBQUAD)*256);
00972    if (!pbi)
00973        return FALSE;
00974
00975    // Retrieve a description of the device surface.
00976    if (DSGetOptimalDIBFormat(hdc, pbi)) {
00977        // Get a pointer to the bitfields.
00978        lpdw = (LPDWORD)((LPBYTE)pbi + sizeof(BITMAPINFOHEADER));
00979
00980        *pRed   = CountBits(lpdw[0]);
00981        *pGreen = CountBits(lpdw[1]);
00982        *pBlue  = CountBits(lpdw[2]);
00983    } else
00984        bRet = FALSE;
00985
00986    // Clean up.
00987    GlobalFree(pbi);
00988
00989    return bRet;
00990 }
00991
00992 /* ******************************************************************* */
00993
00994 /******************************************************************************
00995  *                                                                            *
00996  *  FUNCTION   : DIBNumColors(LPVOID lpv)                                     *
00997  *                                                                            *
00998  *  PURPOSE    : Determines the number of colors in the DIB by looking at     *
00999  *               the BitCount and ClrUsed fields in the info block.           *
01000  *                                                                            *
01001  *  RETURNS    : The number of colors in the DIB. With DIBS with more than    *
01002  *               8-bits-per-pixel that have a color table table included,     *
01003  *               then the return value will be the number of colors in the    *
01004  *               color table rather than the number of colors in the DIB.     *
01005  *                                                                            *
01006  *                                                                            *
01007  *****************************************************************************/
01008
01009 WORD DIBNumColors (LPVOID lpv)
01010 {
01011     INT                 bits;
01012     LPBITMAPINFOHEADER  lpbih = (LPBITMAPINFOHEADER)lpv;
01013     LPBITMAPCOREHEADER  lpbch = (LPBITMAPCOREHEADER)lpv;
01014
01015     /*  With the BITMAPINFO format headers, the size of the palette
01016      *  is in biClrUsed, whereas in the BITMAPCORE - style headers, it
01017      *  is dependent on the bits per pixel (= 2 raised to the power of
01018      *  bits/pixel).
01019      */
01020
01021     if (NEW_DIB_FORMAT(lpbih)) {
01022       if (lpbih->biClrUsed != 0)
01023         return (WORD)lpbih->biClrUsed;
01024       bits = lpbih->biBitCount;
01025     }
01026     else
01027       bits = lpbch->bcBitCount;
01028
01029     if (bits > 8)
01030       return 0; /* Since biClrUsed is 0, we dont have a an optimal palette */
01031     else
01032       return (WORD)(1 << bits);
01033 }
01034
01035 /* ******************************************************************* */
01036
01037 /******************************************************************************
01038  *                                                                            *
01039  *  FUNCTION   :  DIBColorTableSize(LPVOID lpv)                               *
01040  *                                                                            *
01041  *  PURPOSE    :  Calculates the palette size in bytes. If the info. block    *
01042  *                is of the BITMAPCOREHEADER type, the number of colors is    *
01043  *                multiplied by 3 to give the palette size, otherwise the     *
01044  *                number of colors is multiplied by 4.                        *
01045  *                                                                            *
01046  *  RETURNS    :  Color table size in number of bytes.                        *
01047  *                                                                            *
01048  *****************************************************************************/
01049
01050 WORD DIBColorTableSize (LPVOID lpv)
01051 {
01052     LPBITMAPINFOHEADER lpbih = (LPBITMAPINFOHEADER)lpv;
01053
01054     if (NEW_DIB_FORMAT(lpbih))
01055     {
01056       if (((LPBITMAPINFOHEADER)(lpbih))->biCompression == BI_BITFIELDS)
01057          /* Remember that 16/32bpp dibs can still have a color table */
01058          return (sizeof(DWORD) * 3) + (DIBNumColors (lpbih) * sizeof (RGBQUAD));
01059       else
01060          return (DIBNumColors (lpbih) * sizeof (RGBQUAD));
01061     }
01062     else
01063       return (DIBNumColors (lpbih) * sizeof (RGBTRIPLE));
01064 }
01065
01066 /* ******************************************************************* */
01067
01068 /* **********************************************************************
01069
01070   HBITMAP DSGetDIBSectionFromClipboard(void)
01071
01072   RETURNS:
01073     HBITMAP      - a DIBSection HBITMAP or NULL on failure
01074
01075   REMARKS:
01076     Creates a DIBSection based on the attributes of the clipboard
01077
01078 ********************************************************************** */
01079
01080 HBITMAP WINAPI DSGetDIBSectionFromClipboard()
01081 {
01082     HBITMAP         hBitmap = NULL;
01083     HANDLE      hClipData;
01084   HDC       hdcRef;
01085
01086   // Is there any bitmap data (that we can use) on the cliboard?
01087   if (!IsClipboardFormatAvailable(CF_DIB) && !IsClipboardFormatAvailable(CF_BITMAP))
01088     return (HBITMAP)NULL;  // Nope, bail
01089
01090   if (!OpenClipboard(NULL))
01091     return FALSE;
01092
01093   // Get a reference DC
01094   hdcRef = GetDC(NULL);
01095
01096   if (IsClipboardFormatAvailable(CF_DIB)) {
01097     PBYTE           pBitsDS, pBitsDIB;
01098     LPBITMAPINFO    pbmi;
01099
01100     hClipData = GetClipboardData(CF_DIB);
01101     if (hClipData) {
01102       pbmi = (LPBITMAPINFO)GlobalLock(hClipData);
01103
01104       // Create a DIB section compatible with the clipboard contents
01105       hBitmap = CreateDIBSection(hdcRef, pbmi, DIB_RGB_COLORS, &pBitsDS, NULL, 0);
01106
01107       // Get a pinter to the surface bits
01108       pBitsDIB = (LPBYTE)pbmi + sizeof(BITMAPINFOHEADER) + DIBColorTableSize(pbmi);
01109
01110       // Copy the surface contents to the surface of our DIB section
01111       CopyMemory(pBitsDS, pBitsDIB, pbmi->bmiHeader.biSizeImage);
01112
01113       GlobalUnlock(hClipData);
01114     }
01115   }
01116
01117   // If we couldn't get a DIB (or we didn't want one) try to get a DDB
01118   if (!hBitmap && IsClipboardFormatAvailable(CF_BITMAP)) {
01119     HPALETTE    hPal;
01120
01121     hClipData = GetClipboardData(CF_BITMAP);
01122     hPal = GetClipboardData(CF_PALETTE);
01123
01124     hBitmap = DSCopyBitmap((HBITMAP)hClipData, hPal);
01125   }
01126
01127   ReleaseDC(NULL, hdcRef);
01128   CloseClipboard();
01129
01130     return hBitmap;
01131 }
01132
01133 /* ******************************************************************* */
01134
01135 HBITMAP WINAPI DSCreateDDBForDS(HBITMAP hbmp)
01136 {
01137     HBITMAP   hBitmap;
01138   HPALETTE  hPal;
01139   BITMAP    bm;
01140   HDC     hdcSrc, hdcDst;
01141   HDC     hdcScreen;
01142
01143   // Get information about the surface
01144   if (!GetObject(hbmp, sizeof(BITMAP), &bm))
01145     return (HBITMAP)NULL;
01146
01147   hdcScreen = GetDC(NULL);
01148   hPal = DSCreatePaletteForDIBSection(hbmp);
01149
01150   // Create a DIB section to hold our copy of the data
01151   hBitmap = CreateCompatibleBitmap(hdcScreen, bm.bmWidth, bm.bmHeight);
01152   hdcSrc = CreateCompatibleDC(hdcScreen);
01153   hdcDst = CreateCompatibleDC(hdcScreen);
01154
01155   // Prepare the source bitmap
01156   SelectObject(hdcSrc, hbmp);
01157   SelectPalette(hdcSrc, hPal, FALSE);
01158   RealizePalette(hdcSrc);
01159
01160   // Prepare the destination bitmap
01161   SelectObject(hdcDst, hBitmap);
01162   SelectPalette(hdcDst, hPal, FALSE);
01163   RealizePalette(hdcDst);
01164
01165   // Copy the contents of the surface from the source to the destination
01166   BitBlt(hdcDst, 0,0, bm.bmWidth, bm.bmHeight, hdcSrc, 0,0, SRCCOPY);
01167
01168   // Clean up
01169   DeleteDC(hdcSrc);
01170   DeleteDC(hdcDst);
01171   DeleteObject(hPal);
01172
01173     return hBitmap;
01174 }
01175
01176 /* **********************************************************************
01177   BOOL DSPutDIBSectionOnClipboard(HBITMAP)
01178
01179   RETURNS:
01180     HBITMAP      - Returns TRUE if the call succeeds
01181
01182   REMARKS:
01183     Places a DIB section on the clipboard in CF_DIB format
01184
01185 ********************************************************************** */
01186
01187 BOOL WINAPI DSPutDIBSectionOnClipboard(HBITMAP hbm)
01188 {
01189     HGLOBAL         hDIB;
01190   BOOL            bRet;
01191
01192   if (!OpenClipboard(NULL))
01193     return FALSE;
01194
01195   if (!(hDIB = DSGetDIBFromDIBSection(hbm)))
01196     return FALSE;
01197
01198   // Clear the clipboard
01199   EmptyClipboard();
01200
01201   // Add our bitmap to the clipboard
01202   bRet = (SetClipboardData(CF_DIB, hDIB) != NULL);
01203
01204   CloseClipboard();
01205
01206     return bRet;
01207 }
01208 /* ******************************************************************* */
01209
01210
01211 /* **********************************************************************
01212
01213   HBITMAP WINAPI DSCopyBitmapEx(HBITMAP, HPALETTE, WORD)
01214
01215   RETURNS:
01216     HBITMAP - a DIBSection copy of the HBITMAP passed in
01217
01218   REMARKS:
01219     Makes a copy of a DIBSection or DDB/Palette.  Use a NULL HPALETTE
01220   if the HBITMAP parameter is a DIBSection
01221
01222 ********************************************************************** */
01223
01224 HBITMAP WINAPI DSCopyBitmapEx(HBITMAP hbmp, HPALETTE hPal, WORD wBits)
01225 {
01226     HBITMAP         hBitmap = NULL;
01227   BOOL      bNeedToCleanUp = FALSE;
01228     BITMAP      bm;
01229   HDC       hdcSrc, hdcDst;
01230   RGBQUAD     rgbq[256];
01231   int       iNumColors, i;
01232
01233   if (!GetObject(hbmp, sizeof(BITMAP), &bm))
01234     return (HBITMAP)NULL;
01235
01236   // Create a DIB section to hold our copy of the data
01237   hBitmap = DSCreateDIBSection(bm.bmWidth, bm.bmHeight, wBits);
01238
01239   hdcSrc = CreateCompatibleDC(NULL);
01240   hdcDst = CreateCompatibleDC(NULL);
01241
01242   if (hPal) {
01243     // Get the colors from the palette and copy them to our color table
01244     iNumColors = GetPaletteEntries(hPal, 0, 256, (LPPALETTEENTRY)rgbq);
01245
01246     // RGB in PALETTEENTRYs and RGBQUADs are in different order so adjust
01247     for (i=0; i<iNumColors; i++) {
01248       SWAP(rgbq[i].rgbBlue, rgbq[i].rgbRed);
01249       rgbq[i].rgbReserved = 0;
01250     }
01251   } else
01252     if (wBits <= 8) { // We need some sort of color table for the target image
01253       // We're creating the palette rather than using one that was
01254       // passed in so we need to remember to clean it up before returning
01255       bNeedToCleanUp = TRUE;
01256
01257       // Get the palette from the source images
01258       hPal = DSCreatePaletteForDIBSection(hbmp);
01259
01260       // Convert it to RGBQUAD format
01261       iNumColors = GetPaletteEntries(hPal, 0, 256, (LPPALETTEENTRY)rgbq);
01262
01263       // RGB in PALETTEENTRYs and RGBQUADs are in different order so adjust
01264       for (i=0; i<iNumColors; i++) {
01265         SWAP(rgbq[i].rgbBlue, rgbq[i].rgbRed);
01266         rgbq[i].rgbReserved = 0;
01267       }
01268     } else {
01269       hPal = GetStockObject(DEFAULT_PALETTE);
01270       iNumColors = 0;
01271     }
01272
01273   // Prepare the source bitmap
01274   SelectObject(hdcSrc, hbmp);
01275   SelectPalette(hdcSrc, hPal, FALSE);
01276   RealizePalette(hdcSrc);
01277
01278   // Prepare the destination bitmap
01279   SelectObject(hdcDst, hBitmap);
01280   SelectPalette(hdcDst, hPal, FALSE);
01281   RealizePalette(hdcDst);
01282   if (iNumColors)
01283     SetDIBColorTable(hdcDst, 0, iNumColors, rgbq);
01284
01285   BitBlt(hdcDst, 0,0, bm.bmWidth, bm.bmHeight, hdcSrc, 0,0, SRCCOPY);
01286
01287   DeleteDC(hdcSrc);
01288   DeleteDC(hdcDst);
01289
01290   if (bNeedToCleanUp)
01291     DeleteObject(hPal);
01292
01293     return hBitmap;
01294 }
01295 /* ******************************************************************* */
01296
01297
01298 /* **********************************************************************
01299   HBITMAP WINAPI DSCopyBitmap(HBITMAP, HPALETTE)
01300
01301   RETURNS:
01302     HBITMAP - a DIBSection copy of the HBITMAP passed in
01303
01304   REMARKS:
01305     Makes a copy of a DIBSection or DDB/Palette.  Use a NULL HPALETTE
01306   if the HBITMAP parameter is a DIBSection
01307
01308 ********************************************************************** */
01309
01310 HBITMAP WINAPI DSCopyBitmap(HBITMAP hbmp, HPALETTE hPal)
01311 {
01312     BITMAP      bm;
01313
01314   if (!GetObject(hbmp, sizeof(BITMAP), &bm))
01315     return (HBITMAP)NULL;
01316
01317   // Create a DIB section to hold our copy of the data
01318   return DSCopyBitmapEx(hbmp, hPal, (WORD)(bm.bmPlanes*bm.bmBitsPixel));
01319 }
01320 /* ******************************************************************* */
01321
01322 /***************************************************************************\
01323 * DSGetDIBFromDIBSection
01324 *
01325 * Creates a memory block in CF_DIB format
01326 *
01327 * CF_DIB format consists of a BITMAPINFOHEADER + RGB colors + DIB bits.
01328 *
01329 \***************************************************************************/
01330
01331 HGLOBAL WINAPI DSGetDIBFromDIBSection(HBITMAP  hbmp)
01332 {
01333   HGLOBAL    hDIB;
01334   LPBYTE       pDIB;
01335   LPBITMAPINFO pbmi;
01336   LPBYTE       pBits;
01337   DWORD    dwSize;
01338
01339   // Attempt to get a pointer to the image bits
01340     pBits = DSGetPointerToDIBSectionImageBits(hbmp);
01341
01342   // Did we get one?
01343   if (!pBits)
01344     return NULL; // No.  It's not a DIB section
01345
01346   // Get a BITMAPINFO that describes the surface
01347     if (!(pbmi = DSGetBITMAPINFOForDIBSection(hbmp)))
01348     return NULL;
01349
01350   // Get the size of the entire CF_DIB image
01351   dwSize = sizeof(BITMAPINFOHEADER) + DSColorTableSize(pbmi) + DSImageBitsSize(pbmi);
01352
01353   // Allocate memory to hold the CF_DIB image
01354   if (!(hDIB = GlobalAlloc(GPTR, dwSize))) {
01355     free(pbmi);
01356     return NULL;
01357   }
01358
01359   // Get a pointer to the memory block
01360   pDIB = (LPBYTE)GlobalLock(hDIB);
01361
01362   // Copy over the DIB header information and the color table
01363   CopyMemory(pDIB, pbmi, sizeof(BITMAPINFOHEADER) + DSColorTableSize(pbmi));
01364
01365   // Advance the pointer to where the surface bits should go
01366   pDIB += sizeof(BITMAPINFOHEADER) + DSColorTableSize(pbmi);
01367
01368   CopyMemory(pDIB, pBits, DSImageBitsSize(pbmi));
01369
01370     // clean up and leave
01371     free(pbmi);
01372
01373     GlobalUnlock(hDIB);
01374
01375   return hDIB;
01376 }
01377
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/EdHost.cpp Source File

  • Web
  • Browser
  • EditHost

EdHost.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // EdHost.cpp : Implementation of WinMain
00006
00007 // Note: Proxy/Stub Information
00008 // To build a separate proxy/stub DLL,
00009 // run nmake -f EdHostps.mk in the project directory.
00010
00011 #include "stdafx.h"
00012 #include "resource.h"
00013 #include <initguid.h>
00014 #include "EdHost.h"
00015
00016 #include "EdHost_i.c"
00017 #include "BrowserHost.h"
00018 #include "Grid.h"
00019 #include "Snap.h"
00020
00021 const DWORD dwTimeOut = 5000; // time for EXE to be idle before shutting down
00022 const DWORD dwPause = 1000; // time to wait for threads to finish up
00023
00024 // Passed to CreateThread to monitor the shutdown event
00025 static DWORD WINAPI MonitorProc(void* pv)
00026 {
00027   CExeModule* p = (CExeModule*)pv;
00028   p->MonitorShutdown();
00029   return 0;
00030 }
00031
00032 LONG CExeModule::Unlock()
00033 {
00034   LONG l = CComModule::Unlock();
00035   if (l == 0)
00036   {
00037     bActivity = true;
00038     SetEvent(hEventShutdown); // tell monitor that we transitioned to zero
00039   }
00040   return l;
00041 }
00042
00043 //Monitors the shutdown event
00044 void CExeModule::MonitorShutdown()
00045 {
00046   while (1)
00047   {
00048     WaitForSingleObject(hEventShutdown, INFINITE);
00049     DWORD dwWait=0;
00050     do
00051     {
00052       bActivity = false;
00053       dwWait = WaitForSingleObject(hEventShutdown, dwTimeOut);
00054     } while (dwWait == WAIT_OBJECT_0);
00055
00056     // timed out
00057     if (!bActivity && m_nLockCnt == 0) // if no activity let's really bail
00058     {
00059 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00060       CoSuspendClassObjects();
00061       if (!bActivity && m_nLockCnt == 0)
00062 #endif
00063         break;
00064     }
00065   }
00066
00067   CloseHandle(hEventShutdown);
00068   PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00069 }
00070
00071 bool CExeModule::StartMonitor()
00072 {
00073   // CODE REVIEW: Add following security comment.
00074   /* The following use of CreateEvent is simplified for illustrative
00075   purposes. This simplified use in production code can expose a
00076   security risk in some situations. The first parameter might require
00077   specific security attributes. */
00078   hEventShutdown = CreateEvent(NULL, false, false, NULL);
00079   if (hEventShutdown == NULL)
00080     return false;
00081   DWORD dwThreadID;
00082   HANDLE h = CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
00083   return (h != NULL);
00084 }
00085
00086 CExeModule _Module;
00087
00088 BEGIN_OBJECT_MAP(ObjectMap)
00089   OBJECT_ENTRY(CLSID_BrowserHost, CBrowserHost)
00090   OBJECT_ENTRY(CLSID_Grid, CGrid)
00091   OBJECT_ENTRY(CLSID_Snap, CSnap)
00092 END_OBJECT_MAP()
00093
00094
00095 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
00096 {
00097   while (p1 != NULL && *p1 != NULL)
00098   {
00099     LPCTSTR p = p2;
00100     while (p != NULL && *p != NULL)
00101     {
00102       if (*p1 == *p)
00103         return CharNext(p1);
00104
00105       p = CharNext(p);
00106     }
00107
00108     p1 = CharNext(p1);
00109   }
00110   return NULL;
00111 }
00112
00113 /////////////////////////////////////////////////////////////////////////////
00114 //
00115 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00116                 HINSTANCE /*hPrevInstance*/,
00117                 LPTSTR lpCmdLine,
00118                 int /*nShowCmd*/)
00119 {
00120   lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
00121
00122 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00123   HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00124 #else
00125   HRESULT hRes = CoInitialize(NULL);
00126 #endif
00127
00128   _ASSERTE(SUCCEEDED(hRes));
00129   _Module.Init(ObjectMap, hInstance, &LIBID_EDHOSTLib);
00130   _Module.dwThreadID = GetCurrentThreadId();
00131   TCHAR szTokens[] = _T("-/");
00132
00133   HRESULT hr = E_FAIL;
00134   BOOL bRun = TRUE;
00135   LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
00136   while (lpszToken != NULL)
00137   {
00138     if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
00139     {
00140       _Module.UpdateRegistryFromResource(IDR_EdHost, FALSE);
00141       hr = _Module.UnregisterServer(TRUE);
00142       bRun = FALSE;
00143       //if (SUCCEEDED(hr)) MessageBox(NULL, _T("Unregistration Successful"), NULL, NULL);
00144       break;
00145     }
00146
00147     if (lstrcmpi(lpszToken, _T("RegServer"))==0)
00148     {
00149       _Module.UpdateRegistryFromResource(IDR_EdHost, TRUE);
00150       hr = _Module.RegisterServer(TRUE);
00151       bRun = FALSE;
00152       //if (SUCCEEDED(hr)) MessageBox(NULL, _T("Registration Successful"), NULL, NULL);
00153       break;
00154     }
00155
00156     lpszToken = FindOneOf(lpszToken, szTokens);
00157   }
00158
00159   if (bRun)
00160   {
00161     _Module.StartMonitor();
00162
00163 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00164     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00165                       REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
00166     _ASSERTE(SUCCEEDED(hRes));
00167     hRes = CoResumeClassObjects();
00168 #else
00169     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00170                       REGCLS_MULTIPLEUSE);
00171 #endif
00172
00173     _ASSERTE(SUCCEEDED(hRes));
00174
00175     // Create the Browser Window
00176     CComPtr<IBrowserHost> pApp;
00177     CoCreateInstance(CLSID_BrowserHost,
00178              NULL,
00179              CLSCTX_INPROC_SERVER,
00180              IID_IBrowserHost,
00181              (void**)&pApp);
00182     if (pApp)
00183     {
00184       pApp->Run();
00185
00186       long hwnd;
00187       HWND hwndApp;
00188       pApp->GetHwnd(&hwnd);
00189       hwndApp = (HWND)hwnd;
00190
00191       MSG msg;
00192       while (GetMessage(&msg, 0, 0, 0))
00193       {
00194         // Avoid the beep when in the combo box
00195         if (msg.wParam != VK_RETURN && msg.wParam != VK_TAB)
00196           TranslateMessage(&msg);
00197
00198         // If we get a keydown message, we must send the message
00199         // to the container window so that the message can be routed to
00200         // the correct window.  This is necessary so that the container
00201         // window can call TranslateAccelerator on the in-place active
00202         // object and so that VK_RETURN and VK_TAB messages received from
00203         // the combobox in the toolbar will be processed correctly.
00204         if (msg.message == WM_KEYDOWN)
00205           SendMessage(hwndApp, msg.message, msg.wParam, msg.lParam);
00206
00207         DispatchMessage(&msg);
00208       }
00209
00210       _Module.RevokeClassObjects();
00211       Sleep(dwPause); //wait for any threads to finish
00212     }
00213   }
00214
00215   _Module.Term();
00216   CoUninitialize();
00217   return hr;
00218 }
00219 #include "Snap.h"
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/delebase.h Source File

  • SysMgmt
  • MMC
  • Taskpads

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CDelegationBase {
00030 public:
00031     CDelegationBase();
00032     virtual ~CDelegationBase();
00033
00034     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00035     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00036
00037     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00038     virtual const int GetBitmapIndex() = 0;
00039
00040     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00041
00042 public:
00043     // virtual functions go here (for MMCN_*)
00044     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00045     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00046     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00047     virtual HRESULT OnRename(LPOLESTR pszNewName) { return S_FALSE; }
00048     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00049     virtual HRESULT OnListpad(IConsole *pConsole, BOOL bAttaching) { return S_FALSE; }
00050
00051   // taskpad support
00052     virtual HRESULT TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) { return S_FALSE; }
00053     virtual MMC_TASK *GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) { return NULL; }
00054   virtual HRESULT GetTaskpadTitle(LPOLESTR *pszTitle) { return S_FALSE; }
00055   virtual HRESULT GetTaskpadDescription(LPOLESTR *pszDescription) { return S_FALSE; }
00056   virtual HRESULT GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) { return S_FALSE; }
00057   virtual HRESULT GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) { return S_FALSE; }
00058
00059 public:
00060     static HBITMAP m_pBMapSm;
00061     static HBITMAP m_pBMapLg;
00062
00063 protected:
00064     static void LoadBitmaps() {
00065         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00066         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00067     }
00068
00069     BOOL bExpanded;
00070
00071 private:
00072     // {2974380B-4C4B-11d2-89D8-000021473128}
00073     static const GUID thisGuid;
00074 };
00075
00076 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMSOmniProvSession Member List

This is the complete list of members for CMSOmniProvSession, including all inherited members.
CMSOmniProvSession() | CMSOmniProvSession | [inline]
FinalConstruct() | CMSOmniProvSession | [inline]
OpenRowset(IUnknown *pUnk, DBID *pTID, DBID *pInID, REFIID riid, ULONG cSets, DBPROPSET rgSets[], IUnknown **ppRowset) | CMSOmniProvSession | [inline]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CVectorEx< TYPE, IDX > Member List

This is the complete list of members for CVectorEx< TYPE, IDX >, including all inherited members.
AddElement(TYPE element) | CVector< TYPE, IDX > | [virtual]
Attach(CVector &rVector) | CVector< TYPE, IDX > | [virtual]
Attach(IDX cElements, TYPE *rgElements) | CVector< TYPE, IDX > | [virtual]
CVector(IDX ulLowerBound=0, IDX ulGrowSize=10) | CVector< TYPE, IDX > |
CVectorEx(IDX ulLowerBound=0, IDX ulGrowSize=10) | CVectorEx< TYPE, IDX > |
Detach(IDX *pcElements, TYPE **prgElements) | CVector< TYPE, IDX > | [virtual]
FindElement(TYPE element) | CVectorEx< TYPE, IDX > | [virtual]
GetCount() | CVector< TYPE, IDX > | [inline, virtual]
GetElement(IDX iIndex) | CVector< TYPE, IDX > | [virtual]
GetElements() const | CVector< TYPE, IDX > | [inline, virtual]
InsertAt(IDX iIndex, TYPE element) | CVector< TYPE, IDX > | [virtual]
m_cElements | CVector< TYPE, IDX > | [protected]
m_rgElements | CVector< TYPE, IDX > | [protected]
m_ulGrowSize | CVector< TYPE, IDX > | [protected]
m_ulLowerBound | CVector< TYPE, IDX > | [protected]
m_ulMaxSize | CVector< TYPE, IDX > | [protected]
operator[](IDX iIndex) | CVector< TYPE, IDX > | [inline, virtual]
RemoveAll() | CVector< TYPE, IDX > | [virtual]
RemoveAt(IDX iIndex) | CVector< TYPE, IDX > | [virtual]
RemoveElement(TYPE element) | CVectorEx< TYPE, IDX > | [virtual]
~CVector() | CVector< TYPE, IDX > | [virtual]
~CVectorEx() | CVectorEx< TYPE, IDX > | [virtual]
Generated on Wed Nov 13 2024 16:57:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/RecoDLL/StdAfx.h Source File

  • TabletPC
  • RecoDLL

StdAfx.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //--------------------------------------------------------------------------
00013 //
00014 // stdafx.h : include file for standard system include files,
00015 //  or project specific include files that are used frequently, but
00016 //      are changed infrequently
00017 //
00018
00019 #if !defined(AFX_STDAFX_H__C86B53F4_6290_497B_9948_8ADDCD1026A4__INCLUDED_)
00020 #define AFX_STDAFX_H__C86B53F4_6290_497B_9948_8ADDCD1026A4__INCLUDED_
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 // Insert your headers here
00028 #define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers
00029
00030 #include <windows.h>
00031
00032 // TODO: reference additional headers your program requires here
00033
00034 //{{AFX_INSERT_LOCATION}}
00035 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00036
00037 #endif // !defined(AFX_STDAFX_H__C86B53F4_6290_497B_9948_8ADDCD1026A4__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/winmain.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

winmain.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module WINMAIN.CPP
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011
00012 ///////////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 ///////////////////////////////////////////////////////////////////////
00016 #include "winmain.h"
00017 #include "wizard.h"
00018 #include "common.h"
00019 #include "tablecopy.h"
00020 #include "table.h"
00021 #include "spy.h"
00022
00023 //////////////////////////////////////////////////////////////////
00024 // int WINAPI WinMain
00025 //
00026 // Main application entry point
00027 //////////////////////////////////////////////////////////////////
00028 int WINAPI WinMain( HINSTANCE hInstance,
00029                     HINSTANCE hPrevInstance,
00030                     CHAR*  pszCmdLine,
00031                     INT    nCmdShow)
00032 {
00033   HRESULT hr = E_FAIL;
00034   CMallocSpy* pCMallocSpy = NULL;
00035   CWizard* pCWizard = NULL;
00036
00037   //Register IMallocSpy
00038   XTESTC(hr = MallocSpyRegister(&pCMallocSpy));
00039
00040   pCWizard = new CWizard(NULL, hInstance);
00041
00042   //CoInitialize - COM/OLE
00043   XTESTC(hr = CoInitialize(NULL));
00044
00045   //Initlialize Window Controls
00046   InitCommonControls();
00047
00048   //Main Execution
00049   pCWizard->Display();
00050
00051 CLEANUP:
00052   delete pCWizard;
00053   MallocSpyUnRegister(pCMallocSpy);
00054   CoUninitialize();
00055
00056   //Dump all the leaks
00057   MallocSpyDump(pCMallocSpy);
00058   delete pCMallocSpy;
00059
00060   return (hr==S_OK);
00061 }
00062
00063
00064 //////////////////////////////////////////////////////////////////
00065 // void SyncSibling
00066 //
00067 //////////////////////////////////////////////////////////////////
00068 void SyncSibling(HWND hToWnd, HWND hFromWnd)
00069 {
00070   ASSERT(hToWnd && hFromWnd);
00071
00072   //Make both windows synched,
00073   //Get the current selection from the Source
00074   LONG iItem = SendMessage(hFromWnd, LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)LVNI_SELECTED);
00075
00076   //Tell the Target to select the same selection
00077   if(iItem != LVM_ERR)
00078   {
00079     //Get the current selection from the Target and Unselect it
00080     LONG iOldItem = SendMessage(hToWnd, LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)LVNI_SELECTED);
00081     if(iItem != iOldItem)
00082     {
00083       //Unselect previous one
00084       LV_SetItemState(hToWnd, iOldItem, 0, 0, LVIS_SELECTED);
00085
00086       //Select the new one
00087       LV_SetItemState(hToWnd, iItem, 0, LVIS_SELECTED, LVNI_SELECTED);
00088
00089       //Ensure that it is visible
00090       SendMessage(hToWnd, LVM_ENSUREVISIBLE, (WPARAM)iItem, (LPARAM)FALSE);
00091     }
00092   }
00093 }
00094
00095
00096 //////////////////////////////////////////////////////////////////
00097 // int InternalAssert
00098 //
00099 //////////////////////////////////////////////////////////////////
00100 int InternalAssert(         // 1 to break, 0 to skip.
00101     char* pszExp,         // The expression causing assert
00102   char* pszFile,        // The file name
00103   UINT  iLine         // Line number of assert
00104   )
00105 {
00106   CHAR  szMsg[MAX_QUERY_LEN];
00107   _snprintf(szMsg, MAX_NAME_LEN, "Assertion Error!\n File '%s', Line '%lu'\n"
00108           "Expression '%s'\n\n"
00109           "Do you wish to Continue?  (Press 'OK' to ignore the assertion."
00110           "  Press 'Cancel to debug.)",pszFile, iLine, pszExp);
00111
00112   //Popup a MessageBox
00113   LONG dwSelection = MessageBoxA(NULL, szMsg, "Microsoft OLE DB TableCopy - Error",
00114     MB_TASKMODAL | MB_ICONSTOP | MB_OKCANCEL | MB_DEFBUTTON1 );
00115
00116   switch(dwSelection)
00117   {
00118     case IDOK:
00119       return 0;
00120     case IDCANCEL:
00121       return 1;
00122     default:
00123       ASSERT(!L"Unhandled Choice");
00124   }
00125
00126   return 0;
00127 }
00128
00129
00130 //////////////////////////////////////////////////////////////////
00131 // void InternalTrace
00132 //
00133 //////////////////////////////////////////////////////////////////
00134 void InternalTrace(WCHAR* pwszFmt, ...)
00135 {
00136   va_list   marker;
00137   WCHAR   wszBuffer[MAX_NAME_LEN];
00138   CHAR    szBuffer[MAX_NAME_LEN];
00139
00140   // Use format and arguements as input
00141   //This version will not overwrite the stack, since it only copies
00142   //upto the max size of the array
00143   va_start(marker, pwszFmt);
00144   _vsnwprintf(wszBuffer, MAX_NAME_LEN, pwszFmt, marker);
00145   va_end(marker);
00146
00147   //Make sure there is a NULL Terminator, vsnwprintf will not copy
00148   //the terminator if length==MAX_NAME_LEN
00149   wszBuffer[MAX_NAME_LEN-1] = EOL;
00150
00151   //Convert to MBCS
00152   ConvertToMBCS(wszBuffer, szBuffer, MAX_NAME_LEN);
00153
00154   //Output to the DebugWindow
00155   OutputDebugString(szBuffer);
00156 }
00157
00158
00159 //////////////////////////////////////////////////////////////////
00160 // void InternalTrace
00161 //
00162 //////////////////////////////////////////////////////////////////
00163 void InternalTrace(CHAR*  pszFmt, ...)
00164 {
00165   va_list   marker;
00166   CHAR    szBuffer[MAX_NAME_LEN];
00167
00168   // Use format and arguements as input
00169   //This version will not overwrite the stack, since it only copies
00170   //upto the max size of the array
00171   va_start(marker, pszFmt);
00172   _vsnprintf(szBuffer, MAX_NAME_LEN, pszFmt, marker);
00173   va_end(marker);
00174
00175   //Make sure there is a NULL Terminator, vsnwprintf will not copy
00176   //the terminator if length==MAX_NAME_LEN
00177   szBuffer[MAX_NAME_LEN-1] = '\0';
00178
00179   OutputDebugStringA(szBuffer);
00180 }
00181
00182
00183 //////////////////////////////////////////////////////////////////
00184 // void Busy
00185 //
00186 //////////////////////////////////////////////////////////////////
00187 void Busy(BOOL bValue)
00188 {
00189   static HCURSOR  hWaitCursor = LoadCursor(NULL, IDC_WAIT);
00190
00191   if(bValue)
00192     SetCursor(hWaitCursor);
00193   else
00194     SetCursor(NULL);
00195 }
00196
00197
00198 //////////////////////////////////////////////////////////////////
00199 // void OutOfMemory
00200 //
00201 //////////////////////////////////////////////////////////////////
00202 void OutOfMemory(HWND hWnd)
00203 {
00204   //Unicode version is supported on Win95/WinNT
00205   MessageBoxW(hWnd, L"Out of memory", wsz_ERROR, MB_TASKMODAL | MB_OK);
00206 }
00207
00208
00209 //////////////////////////////////////////////////////////////////
00210 // BOOL CenterDialog
00211 //
00212 //////////////////////////////////////////////////////////////////
00213 BOOL CenterDialog(HWND hdlg)
00214 {
00215   RECT  rcParent;                         // Parent window client rect
00216   RECT  rcDlg;                            // Dialog window rect
00217   int   nLeft, nTop;                      // Top-left coordinates
00218   int   cWidth, cHeight;                  // Width and height
00219   HWND  hwnd;
00220
00221   // Get frame window client rect in screen coordinates
00222   hwnd = GetParent(hdlg);
00223   if(hwnd == NULL || hwnd == GetDesktopWindow())
00224   {
00225     rcParent.top = rcParent.left = 0;
00226     rcParent.right = GetSystemMetrics(SM_CXFULLSCREEN);
00227     rcParent.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
00228   }
00229   else
00230     GetWindowRect(hwnd, &rcParent);
00231
00232   // Determine the top-left point for the dialog to be centered
00233   GetWindowRect(hdlg, &rcDlg);
00234   cWidth  = rcDlg.right  - rcDlg.left;
00235   cHeight = rcDlg.bottom - rcDlg.top;
00236   nLeft   = rcParent.left +
00237             (((rcParent.right  - rcParent.left) - cWidth ) / 2);
00238   nTop    = rcParent.top  +
00239             (((rcParent.bottom - rcParent.top ) - cHeight) / 2);
00240   if (nLeft < 0) nLeft = 0;
00241   if (nTop  < 0) nTop  = 0;
00242
00243   // Place the dialog
00244   return MoveWindow(hdlg, nLeft, nTop, cWidth, cHeight, TRUE);
00245 }
00246
00247
00248 //////////////////////////////////////////////////////////////////
00249 // ULONG wMessageBox
00250 //
00251 //////////////////////////////////////////////////////////////////
00252 INT wMessageBox(
00253   HWND hwnd,              // Parent window for message display
00254   UINT uiStyle,           // Style of message box
00255   WCHAR* pwszTitle,         // Title for message
00256   WCHAR* pwszFmt,           // Format string
00257   ...                 // Substitution parameters
00258   )
00259 {
00260   va_list   marker;
00261   WCHAR   wszBuffer[MAX_QUERY_LEN];
00262
00263   // Use format and arguements as input
00264   //This version will not overwrite the stack, since it only copies
00265   //upto the max size of the array
00266   va_start(marker, pwszFmt);
00267   _vsnwprintf(wszBuffer, MAX_QUERY_LEN, pwszFmt, marker);
00268   va_end(marker);
00269
00270   //Make sure there is a NULL Terminator, vsnwprintf will not copy
00271   //the terminator if length==MAX_QUERY_LEN
00272   wszBuffer[MAX_QUERY_LEN-1] = EOL;
00273
00274   //Unicode version is supported on both Win95 / WinNT do need to convert
00275   return MessageBoxW(hwnd, wszBuffer, pwszTitle, uiStyle);
00276 }
00277
00278
00279
00280
00281 //////////////////////////////////////////////////////////////////
00282 // void wSetDlgItemText
00283 //
00284 //////////////////////////////////////////////////////////////////
00285 void wSetDlgItemText(HWND hWnd, INT DlgItem, WCHAR* pwszFmt, ...)
00286 {
00287   va_list   marker;
00288   WCHAR   wszBuffer[MAX_NAME_LEN];
00289   CHAR    szBuffer[MAX_NAME_LEN];
00290
00291   // Use format and arguements as input
00292   //This version will not overwrite the stack, since it only copies
00293   //upto the max size of the array
00294   va_start(marker, pwszFmt);
00295   _vsnwprintf(wszBuffer, MAX_NAME_LEN, pwszFmt, marker);
00296   va_end(marker);
00297
00298   //Make sure there is a NULL Terminator, vsnwprintf will not copy
00299   //the terminator if length==MAX_NAME_LEN
00300   wszBuffer[MAX_NAME_LEN-1] = EOL;
00301
00302   //convert to MBCS
00303   ConvertToMBCS(wszBuffer, szBuffer, MAX_NAME_LEN);
00304
00305   SetDlgItemTextA(hWnd, DlgItem, szBuffer);
00306 }
00307
00308
00309 //////////////////////////////////////////////////////////////////
00310 // UINT wGetDlgItemText
00311 //
00312 //////////////////////////////////////////////////////////////////
00313 UINT wGetDlgItemText(HWND hWnd, INT DlgItem, WCHAR* pwsz, INT nMaxSize)
00314 {
00315   ASSERT(pwsz);
00316   CHAR szBuffer[MAX_NAME_LEN];
00317
00318   UINT iReturn = GetDlgItemTextA(hWnd, DlgItem, szBuffer, MAX_NAME_LEN);
00319
00320   //convert to WCHAR
00321   ConvertToWCHAR(szBuffer, pwsz, MAX_NAME_LEN);
00322   return iReturn;
00323 }
00324
00325
00326
00327 //////////////////////////////////////////////////////////////////
00328 // LRESULT wSendMessage
00329 //
00330 //////////////////////////////////////////////////////////////////
00331 LRESULT wSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, WCHAR* pwszBuffer)
00332 {
00333   CHAR szBuffer[MAX_NAME_LEN];
00334   szBuffer[0] = '\0';
00335
00336   if(pwszBuffer && Msg != WM_GETTEXT && Msg != LVM_GETITEM && Msg != CB_GETLBTEXT)
00337   {
00338     //Convert to ANSI before sending, since we don't know if this was a GET/SET message
00339     ConvertToMBCS(pwszBuffer, szBuffer, MAX_NAME_LEN);
00340   }
00341
00342   //Send the message with an ANSI Buffer
00343   LRESULT lResult = SendMessageA(hWnd, Msg, (WPARAM)wParam, (LPARAM)szBuffer);
00344
00345   if(pwszBuffer && Msg == WM_GETTEXT || Msg == LVM_GETITEM || Msg == CB_GETLBTEXT)
00346   {
00347     //Now convert the result into the users WCHAR buffer
00348     ConvertToWCHAR(szBuffer, pwszBuffer, MAX_NAME_LEN);
00349   }
00350   return lResult;
00351 }
00352
00353
00354 //////////////////////////////////////////////////////////////////
00355 // BOOL GetEditBoxValue
00356 //
00357 //////////////////////////////////////////////////////////////////
00358 BOOL GetEditBoxValue(HWND hEditWnd, ULONG ulMin, ULONG ulMax, ULONG* pulCount)
00359 {
00360   ASSERT(hEditWnd);
00361   ASSERT(pulCount);
00362
00363   ULONG ulCount = 0;
00364   WCHAR wszBuffer[MAX_NAME_LEN];
00365   WCHAR*  pwszEnd = NULL;
00366
00367   //Get the EditText
00368   wSendMessage(hEditWnd, WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
00369
00370   //Convert to ULONG
00371   ulCount = wcstoul(wszBuffer, &pwszEnd, 10);
00372   if(!wszBuffer[0] || ulCount<ulMin || ulCount>ulMax || pwszEnd==NULL || pwszEnd[0]!=EOL)
00373   {
00374     wMessageBox(hEditWnd, MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK,  wsz_ERROR,
00375       wsz_INVALID_VALUE_, wszBuffer, ulMin, ulMax);
00376     SetFocus(hEditWnd);
00377     return FALSE;
00378   }
00379
00380   *pulCount = ulCount;
00381   return TRUE;
00382 }
00383
00384
00385 //////////////////////////////////////////////////////////////////
00386 // BOOL LV_InsertColumn
00387 //
00388 //////////////////////////////////////////////////////////////////
00389 LONG LV_InsertColumn(HWND hWnd, LONG iColumn, CHAR* szName)
00390 {
00391   //Setup LV_COLUMNINFO
00392   LV_COLUMN lvColumnHeader = { LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM, LVCFMT_LEFT, 0, szName, MAX_NAME_LEN, 0};
00393
00394   //LVM_INSERTCOLUMN
00395   return SendMessage(hWnd, LVM_INSERTCOLUMN, (WPARAM)iColumn, (LPARAM)&lvColumnHeader);
00396 }
00397
00398
00399 //////////////////////////////////////////////////////////////////
00400 // BOOL LV_InsertItem
00401 //
00402 //////////////////////////////////////////////////////////////////
00403 LONG LV_InsertItem(HWND hWnd, LONG iItem, LONG iSubItem, CHAR* szName, LONG iParam, LONG iImage)
00404 {
00405   //LVM_INSERTITEM
00406   if(iSubItem==0)
00407   {
00408     LV_ITEM lvItem = { LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM, iItem, iSubItem, 0, 0, szName, 0, iImage, iParam};
00409     return SendMessage(hWnd, LVM_INSERTITEM, (WPARAM)0, (LPARAM)&lvItem);
00410   }
00411   //LVM_SETITEM
00412   else
00413   {
00414     LV_ITEM lvItem = { LVIF_TEXT, iItem, iSubItem, 0, 0, szName, 0, 0, iParam};
00415     return SendMessage(hWnd, LVM_SETITEM, (WPARAM)0, (LPARAM)&lvItem);
00416   }
00417 }
00418
00419
00420 //////////////////////////////////////////////////////////////////
00421 // BOOL LV_SetItemState
00422 //
00423 //////////////////////////////////////////////////////////////////
00424 LONG LV_SetItemState(HWND hWnd, LONG iItem, LONG iSubItem, LONG lState, LONG lStateMask)
00425 {
00426   //LVM_SETITEM
00427   LV_ITEM lvItem = { LVIF_STATE, iItem, iSubItem, lState, lStateMask, NULL, 0, 0, 0};
00428   return SendMessage(hWnd, LVM_SETITEMSTATE, (WPARAM)iItem, (LPARAM)&lvItem);
00429 }
00430
00431
00432 //////////////////////////////////////////////////////////////////
00433 // BOOL LV_SetItemText
00434 //
00435 //////////////////////////////////////////////////////////////////
00436 LONG LV_SetItemText(HWND hWnd, LONG iItem, LONG iSubItem, CHAR* szName)
00437 {
00438   //LVM_SETITEM
00439   LV_ITEM lvItem = { LVIF_TEXT, iItem, iSubItem, 0, 0, szName, 0, 0, 0};
00440   return SendMessage(hWnd, LVM_SETITEMTEXT, (WPARAM)iItem, (LPARAM)&lvItem);
00441 }
00442
00443
00444 //////////////////////////////////////////////////////////////////
00445 // BOOL LV_FindItem
00446 //
00447 //////////////////////////////////////////////////////////////////
00448 LONG LV_FindItem(HWND hWnd, CHAR* szName, LONG iStart)
00449 {
00450   //LVM_FINDITEM
00451   LV_FINDINFO lvFindInfo = { LVFI_STRING, szName, 0, 0, 0};
00452   return SendMessage(hWnd, LVM_FINDITEM, (WPARAM)iStart, (LPARAM)&lvFindInfo);
00453 }
00454
00455
00456 //////////////////////////////////////////////////////////////////
00457 // BOOL TV_InsertItem
00458 //
00459 //////////////////////////////////////////////////////////////////
00460 HTREEITEM TV_InsertItem(HWND hWnd, HTREEITEM hParent, HTREEITEM hInsAfter, CHAR* szName, LONG iParam, LONG iImage, LONG iSelectedImage)
00461 {
00462   TV_INSERTSTRUCT tvInsertStruct = { hParent, hInsAfter, { TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, 0, 0, 0, szName, 0, iImage, iSelectedImage, 0, iParam} };
00463
00464   //TVM_INSERTITEM
00465   return (HTREEITEM)SendMessage(hWnd, TVM_INSERTITEM, (WPARAM)0, (LPARAM)&tvInsertStruct);
00466 }
00467
00468
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

storesh::Storesh Member List

This is the complete list of members for storesh::Storesh, including all inherited members.
_currFilter | storesh::Storesh | [private, static]
_currStoreLocation | storesh::Storesh | [private, static]
_currStoreName | storesh::Storesh | [private, static]
_oCurrStore | storesh::Storesh | [private, static]
CAPICOM_ENCODED_DATA_FORMAT_MULTI_LINES | storesh::Storesh | [private]
CERT_SYSTEM_STORE_CURRENT_USER | storesh::Storesh | [private]
CERT_SYSTEM_STORE_LOCAL_MACHINE | storesh::Storesh | [private]
CertEnumSystemStoreCallback(String pvSystemStore, uint dwFlags, ref CERT_SYSTEM_STORE_INFO pStoreInfo, uint pvReserved, String pvArg) | storesh::Storesh | [inline, static]
CERTNAME_LENGTH | storesh::Storesh | [private]
CurrentUser | storesh::Storesh | [private]
DisplayCertificate(Certificate Certificate, String Title) | storesh::Storesh | [inline, static]
DisplayEKU(EKUs EKUs) | storesh::Storesh | [inline, static]
DisplayHelp() | storesh::Storesh | [inline, static]
FRIENDLYNAME_LENGTH | storesh::Storesh | [private]
GetCertByIndex(int idx) | storesh::Storesh | [inline, static]
HELP_PAD | storesh::Storesh | [private]
Listing enum name | storesh::Storesh | [private]
LocalMachine | storesh::Storesh | [private]
Main(string[] args) | storesh::Storesh | [inline, private, static]
ParseArgs(String input) | storesh::Storesh | [inline, private, static]
parseCommandLine(String input) | storesh::Storesh | [inline, private, static]
THUMBPRINT_LENGTH | storesh::Storesh | [private]
ToColumn(String s, int i) | storesh::Storesh | [inline, static]
VALIDITY_LENGTH | storesh::Storesh | [private]
waitForInput() | storesh::Storesh | [inline, private, static]
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/Factory.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

Factory.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.H
00003
00004   Summary:   Include file for the class factory COM object: CFDrawPage.
00005              This constitutes the PERDRAW server's class factory for the
00006              DrawPage COM component.
00007
00008              The multiple interface COM Object Class is achieved via the
00009              technique of nested classes: the implementation of the
00010              standard IClassFactory interface is nested inside of the
00011              class factory COM object class. APPUTIL's CThreaded OwnThis
00012              mechanism is used to ensure mutually exclusive access to the
00013              class factory by contending multiple threads.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial PERDRAW.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   CFDrawPage.
00022
00023   Functions: .
00024
00025   Origin:    5-20-97: atrent - Editor-inheritance from FACTORY.H in
00026                the STOSERVE Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 #if !defined(FACTORY_H)
00044 #define FACTORY_H
00045
00046 #ifdef __cplusplus
00047
00048 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00049   ObjectClass: CFDrawPage
00050
00051   Summary:     Class Factory COM Object Class for DrawPage COM components.
00052                Used to manufacture CODrawPage COM objects.  The mulitple
00053                interfaces on this COM object class are constructed via the
00054                nested interface classes technique.
00055
00056   Interfaces:  IUnknown
00057                  Standard interface providing COM object features.
00058                IClassFactory
00059                  Standard interface providing COM Class Factory features.
00060
00061   Aggregation: Yes, CFDrawPage COM objects are aggregatable by
00062                passing a non-NULL pUnkOuter IUnknown pointer into the
00063                constructor.
00064 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00065 class CFDrawPage : public IUnknown, public CThreaded
00066 {
00067   public:
00068     // Main Object Constructor & Destructor.
00069     CFDrawPage(IUnknown* pUnkOuter, CServer* pServer);
00070     ~CFDrawPage(void);
00071
00072     // IUnknown methods. Main object, non-delegating.
00073     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00074     STDMETHODIMP_(ULONG) AddRef(void);
00075     STDMETHODIMP_(ULONG) Release(void);
00076
00077     // We declare nested class interface implementations here.
00078
00079     // We implement the IClassFactory interface in this class
00080     // factory COM object class. Derive also from abstract CThreaded
00081     // to provide the OwnThis/UnownThis thread-safety mechanism.
00082     class CImpIClassFactory : public IClassFactory, public CThreaded
00083     {
00084       public:
00085         // Interface Implementation Constructor & Destructor.
00086         CImpIClassFactory(
00087           CFDrawPage* pCO,
00088           IUnknown* pUnkOuter,
00089           CServer* pServer);
00090         ~CImpIClassFactory(void);
00091
00092         // IUnknown methods.
00093         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00094         STDMETHODIMP_(ULONG) AddRef(void);
00095         STDMETHODIMP_(ULONG) Release(void);
00096
00097         // IClassFactory methods.
00098         STDMETHODIMP         CreateInstance(IUnknown*, REFIID, PPVOID);
00099         STDMETHODIMP         LockServer(BOOL);
00100
00101       private:
00102         // Data private to this interface implementation of IClassFactory.
00103         CFDrawPage*   m_pCO;         // Parent Object back pointer.
00104         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00105         CServer*      m_pServer;     // Server's control object.
00106     };
00107
00108     // Make the otherwise private and nested IClassFactory interface
00109     // implementation a friend to COM object instantiations of this
00110     // CFDrawPage COM object class.
00111     friend CImpIClassFactory;
00112
00113   private:
00114     // Private data of CFDrawPage COM objects.
00115
00116     // Nested IClassFactory implementation instantiation.
00117     CImpIClassFactory m_ImpIClassFactory;
00118
00119     // Main Object reference count.
00120     ULONG             m_cRefs;
00121
00122     // Outer unknown (aggregation & delegation). Used when this
00123     // CFDrawPage object is being aggregated.  Otherwise it is used
00124     // for delegation if this object is reused via containment.
00125     IUnknown*         m_pUnkOuter;
00126
00127     // Pointer to this component server's control object.
00128     CServer*          m_pServer;
00129 };
00130
00131
00132 #endif // __cplusplus
00133
00134
00135 #endif // FACTORY_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIOpenRowset Member List

This is the complete list of members for CImpIOpenRowset, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CDBSession, CImpIOpenRowset) | CImpIOpenRowset
OpenRowset(IUnknown *, DBID *, DBID *, REFIID, ULONG, DBPROPSET[], IUnknown **) | CImpIOpenRowset
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminFileFlags Member List

This is the complete list of members for comadmin::COMAdminFileFlags, including all inherited members.
COMAdminFileFlagAlreadyInstalled | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagBadTLB | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagClassNotAvailable | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagCOM | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagContainsComp | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagContainsPS | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagContainsTLB | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagDLLRegsvrFailed | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagDoesNotExist | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagError | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagGetClassObjFailed | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagLoadable | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagNoRegistrar | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagRegistrar | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagRegistrarFailed | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagRegTLBFailed | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagSelfReg | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagSelfUnReg | comadmin::COMAdminFileFlags | [static]
COMAdminFileFlagUnloadableDLL | comadmin::COMAdminFileFlags | [static]
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCNotify/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCNotify

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/pluggable/guids.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • pluggable

guids.h

Go to the documentation of this file.
00001 // {c0c93fd9-ae0c-43db-a3d0-d060b7847ae2}
00002 DEFINE_GUID(CLSID_PlgTermSampleClass,
00003 0xc0c93fd9, 0xae0c, 0x43db, 0xa3, 0xd0, 0xd0, 0x60, 0xb7, 0x84, 0x7a, 0xe2);
00004
00005 // {41b0921d-7119-4ba4-9b6b-d315c52b93b2}
00006 DEFINE_GUID(CLSID_PlgSuperSampleClass,
00007 0x41b0921d, 0x7119, 0x4ba4, 0x9b, 0x6b, 0xd3, 0x15, 0xc5, 0x2b, 0x93, 0xb2);
00008
00009 // {880b259b-e851-4315-ab63-e7cdc8703e41}
00010 DEFINE_GUID(CLSID_PlgSampleFilter,
00011 0x880b259b, 0xe851, 0x4315, 0xab, 0x63, 0xe7, 0xcd, 0xc8, 0x70, 0x3e, 0x41);
00012
00013 // {9702faaa-40da-4a37-902e-f050bf3bb637}
00014 DEFINE_GUID(CLSID_PlgSamplePin,
00015 0x9702faaa, 0x40da, 0x4a37, 0x90, 0x2e, 0xf0, 0x50, 0xbf, 0x3b, 0xb6, 0x37);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/ido.Cpp Source File

  • Com
  • Fundamentals
  • SimpSvr

ido.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IDO.CPP
00003 //
00004 //    Implementation file for the CDataObject Class
00005 //
00006 // Functions:
00007 //
00008 //    See ido.h for a list of member functions.
00009 //
00010 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "obj.h"
00015 #include "ido.h"
00016 #include "app.h"
00017 #include "doc.h"
00018
00019 //**********************************************************************
00020 //
00021 // CDataObject::QueryInterface
00022 //
00023 // Purpose:
00024 //
00025 //
00026 // Parameters:
00027 //
00028 //      REFIID riid         -   Interface being queried for.
00029 //
00030 //      LPVOID FAR *ppvObj  -   Out pointer for the interface.
00031 //
00032 // Return Value:
00033 //
00034 //      S_OK            - Success
00035 //      E_NOINTERFACE   - Failure
00036 //
00037 // Function Calls:
00038 //      Function                    Location
00039 //
00040 //      CSimpSvrObj::QueryInterface OBJ.CPP
00041 //
00042 // Comments:
00043 //
00044 //
00045 //********************************************************************
00046
00047
00048 STDMETHODIMP CDataObject::QueryInterface ( REFIID riid, LPVOID FAR* ppvObj)
00049 {
00050   OutputDebugString("In CDataObject::QueryInterface\r\n");
00051
00052   return m_lpObj->QueryInterface(riid, ppvObj);
00053 };
00054
00055 //**********************************************************************
00056 //
00057 // CDataObject::AddRef
00058 //
00059 // Purpose:
00060 //
00061 //      Increments the reference count on CClassFactory and the application
00062 //      object.
00063 //
00064 // Parameters:
00065 //
00066 //      None
00067 //
00068 // Return Value:
00069 //
00070 //      The Reference count on CDataObject
00071 //
00072 // Function Calls:
00073 //      Function                    Location
00074 //
00075 //      OuputDebugString            Windows API
00076 //      CSimpSvrObj::AddRef         OBJ.CPP
00077 //
00078 // Comments:
00079 //
00080 //
00081 //********************************************************************
00082
00083 STDMETHODIMP_(ULONG) CDataObject::AddRef ()
00084 {
00085   OutputDebugString("In CDataObject::AddRef\r\n");
00086   ++m_nCount;
00087   return m_lpObj->AddRef();
00088 };
00089
00090 //**********************************************************************
00091 //
00092 // CDataObject::Release
00093 //
00094 // Purpose:
00095 //
00096 //      Decrements the reference count of CDataObject
00097 //
00098 // Parameters:
00099 //
00100 //      None
00101 //
00102 // Return Value:
00103 //
00104 //      The new reference count
00105 //
00106 // Function Calls:
00107 //      Function                    Location
00108 //
00109 //      OutputDebugString           Windows API
00110 //      CSimpSvrObj::Release        OBJ.CPP
00111 //
00112 // Comments:
00113 //
00114 //
00115 //********************************************************************
00116
00117
00118 STDMETHODIMP_(ULONG) CDataObject::Release ()
00119 {
00120   OutputDebugString("In CDataObject::Release\r\n");
00121   --m_nCount;
00122   return m_lpObj->Release();
00123 };
00124
00125 //**********************************************************************
00126 //
00127 // CDataObject::QueryGetData
00128 //
00129 // Purpose:
00130 //
00131 //      Called to determine if our object supports a particular
00132 //      FORMATETC.
00133 //
00134 // Parameters:
00135 //
00136 //      LPFORMATETC pformatetc  - Pointer to the FORMATETC being queried for.
00137 //
00138 // Return Value:
00139 //
00140 //      DATA_E_FORMATETC    - The FORMATETC is not supported
00141 //      S_OK                - The FORMATETC is supported.
00142 //
00143 //
00144 // Function Calls:
00145 //      Function                    Location
00146 //
00147 //      OutputDebugString           Windows API
00148 //                   OLE API
00149 //
00150 // Comments:
00151 //
00152 //
00153 //********************************************************************
00154
00155
00156 STDMETHODIMP CDataObject::QueryGetData  ( LPFORMATETC pformatetc )
00157 {
00158   SCODE sc = DATA_E_FORMATETC;
00159
00160   OutputDebugString("In CDataObject::QueryGetData\r\n");
00161
00162   // check the validity of the formatetc.
00163   if ( (pformatetc->cfFormat == CF_METAFILEPICT)  &&
00164      (pformatetc->dwAspect == DVASPECT_CONTENT) &&
00165      (pformatetc->tymed == TYMED_MFPICT) )
00166     sc = S_OK;
00167
00168   return sc;
00169 };
00170
00171 //**********************************************************************
00172 //
00173 // CDataObject::DAdvise
00174 //
00175 // Purpose:
00176 //
00177 //      Called by the container when it would like to be notified of
00178 //      changes in the object data.
00179 //
00180 // Parameters:
00181 //
00182 //      FORMATETC FAR* pFormatetc   - The format the container is interested in.
00183 //
00184 //      DWORD advf                  - The type of advise to be set up.
00185 //
00186 //      LPADVISESINK pAdvSink       - Pointer to the containers IAdviseSink
00187 //
00188 //      DWORD FAR* pdwConnection    - Out parameter to return a unique connection id.
00189 //
00190 // Return Value:
00191 //
00192 //      passed on from IDataAdviseHolder
00193 //
00194 // Function Calls:
00195 //      Function                    Location
00196 //
00197 //      OutputDebugString           Windows API
00198 //      CreateDataAdviseHolder      OLE API
00199 //      IDataAdviseHolder::Advise   OLE API
00200 //
00201 // Comments:
00202 //
00203 //
00204 //********************************************************************
00205
00206
00207 STDMETHODIMP CDataObject::DAdvise  ( FORMATETC FAR* pFormatetc, DWORD advf,
00208                    LPADVISESINK pAdvSink, DWORD FAR* pdwConnection)
00209 {
00210   OutputDebugString("In CDataObject::DAdvise\r\n");
00211
00212   // if no DataAdviseHolder has been created, then create one.
00213   if (!m_lpObj->m_lpDataAdviseHolder)
00214     CreateDataAdviseHolder(&m_lpObj->m_lpDataAdviseHolder);
00215
00216   // pass on to the DataAdviseHolder
00217   return m_lpObj->m_lpDataAdviseHolder->Advise( this, pFormatetc, advf,
00218                           pAdvSink, pdwConnection);
00219 }
00220
00221 //**********************************************************************
00222 //
00223 // CDataObject::GetData
00224 //
00225 // Purpose:
00226 //
00227 //      Returns the data in the format specified in pformatetcIn.
00228 //
00229 // Parameters:
00230 //
00231 //      LPFORMATETC pformatetcIn    -   The format requested by the caller
00232 //
00233 //      LPSTGMEDIUM pmedium         -   The medium requested by the caller
00234 //
00235 // Return Value:
00236 //
00237 //      DATA_E_FORMATETC    - Format not supported
00238 //      S_OK                - Success
00239 //
00240 // Function Calls:
00241 //      Function                        Location
00242 //
00243 //      OutputDebugString               Windows API
00244 //      CSimpSvrObj::GetMetaFilePict()  OBJ.CPP
00245 //                       OLE API
00246 //
00247 // Comments:
00248 //
00249 //
00250 //********************************************************************
00251
00252
00253 STDMETHODIMP CDataObject::GetData  ( LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium )
00254 {
00255   SCODE sc = DATA_E_FORMATETC;
00256
00257   OutputDebugString("In CDataObject::GetData\r\n");
00258
00259   // Check to the FORMATETC and fill pmedium if valid.
00260   if ( (pformatetcIn->cfFormat == CF_METAFILEPICT)  &&
00261      (pformatetcIn->dwAspect == DVASPECT_CONTENT) &&
00262      (pformatetcIn->tymed & TYMED_MFPICT) )
00263     {
00264     HANDLE hmfPict = m_lpObj->GetMetaFilePict();
00265     pmedium->tymed = TYMED_MFPICT;
00266     pmedium->hGlobal = hmfPict;
00267     pmedium->pUnkForRelease = NULL;
00268     sc = S_OK;
00269     }
00270
00271   return  sc ;
00272 };
00273
00274 //**********************************************************************
00275 //
00276 // CDataObject::DUnadvise
00277 //
00278 // Purpose:
00279 //
00280 //      Breaks down an Advise connection.
00281 //
00282 // Parameters:
00283 //
00284 //      DWORD dwConnection  - Advise connection ID.
00285 //
00286 // Return Value:
00287 //
00288 //      Returned from the DataAdviseHolder.
00289 //
00290 // Function Calls:
00291 //      Function                    Location
00292 //
00293 //      OutputDebugString           Windows API
00294 //      IDataAdviseHolder::Unadvise OLE
00295 //
00296 // Comments:
00297 //
00298 //
00299 //********************************************************************
00300
00301
00302 STDMETHODIMP CDataObject::DUnadvise  ( DWORD dwConnection)
00303 {
00304   OutputDebugString("In CDataObject::DUnadvise\r\n");
00305
00306   return m_lpObj->m_lpDataAdviseHolder->Unadvise(dwConnection);
00307 };
00308
00309 //**********************************************************************
00310 //
00311 // CDataObject::GetDataHere
00312 //
00313 // Purpose:
00314 //
00315 //      Called to get a data format in a caller supplied location
00316 //
00317 // Parameters:
00318 //
00319 //      LPFORMATETC pformatetc  - FORMATETC requested
00320 //
00321 //      LPSTGMEDIUM pmedium     - Medium to return the data
00322 //
00323 // Return Value:
00324 //
00325 //      DATA_E_FORMATETC    - We don't support the requested format
00326 //
00327 // Function Calls:
00328 //      Function                    Location
00329 //
00330 //      OutputDebugString           Windows API
00331 //
00332 // Comments:
00333 //
00334 //      In this simple implementation, we don't really support this
00335 //      method, we just always return DATA_E_FORMATETC.
00336 //
00337 //********************************************************************
00338
00339
00340 STDMETHODIMP CDataObject::GetDataHere  ( LPFORMATETC pformatetc,
00341                      LPSTGMEDIUM pmedium )
00342 {
00343   OutputDebugString("In CDataObject::GetDataHere\r\n");
00344   return  DATA_E_FORMATETC;
00345 };
00346
00347 //**********************************************************************
00348 //
00349 // CDataObject::GetCanonicalFormatEtc
00350 //
00351 // Purpose:
00352 //
00353 //      Returns a FORMATETC that is equivalent to the one passed in.
00354 //
00355 // Parameters:
00356 //
00357 //      LPFORMATETC pformatetc      - FORMATETC to be tested.
00358 //
00359 //      LPFORMATETC pformatetcOut   - Out ptr for returned FORMATETC.
00360 //
00361 // Return Value:
00362 //
00363 //      DATA_S_SAMEFORMATETC    - Use the same formatetc as was passed.
00364 //
00365 // Function Calls:
00366 //      Function                    Location
00367 //
00368 //      OutputDebugString           Windows API
00369 //      CoGetMalloc                 OLE API
00370 //      IMalloc::Alloc              OLE
00371 //      IMalloc::Release            OLE
00372 //      _fmemcpy                    C run-time
00373 //
00374 // Comments:
00375 //
00376 //
00377 //********************************************************************
00378
00379
00380 STDMETHODIMP CDataObject::GetCanonicalFormatEtc  ( LPFORMATETC pformatetc,
00381                            LPFORMATETC pformatetcOut)
00382 {
00383   HRESULT hresult;
00384   OutputDebugString("In CDataObject::GetCanonicalFormatEtc\r\n");
00385
00386   if (!pformatetcOut)
00387     return E_INVALIDARG;
00388
00389   /* OLE2NOTE: we must make sure to set all out parameters to NULL. */
00390   pformatetcOut->ptd = NULL;
00391
00392   if (!pformatetc)
00393     return E_INVALIDARG;
00394
00395   // OLE2NOTE: we must validate that the format requested is supported
00396   if ((hresult = QueryGetData(pformatetc)) != NOERROR)
00397     return hresult;
00398
00399   /* OLE2NOTE: an app that is insensitive to target device (as
00400   **    SimpSvr is) should fill in the lpformatOut parameter
00401   **    but NULL out the "ptd" field; it should return NOERROR if the
00402   **    input formatetc->ptd what non-NULL. this tells the caller
00403   **    that it is NOT necessary to maintain a separate screen
00404   **    rendering and printer rendering. if should return
00405   **    DATA_S_SAMEFORMATETC if the input and output formatetc's are
00406   **    identical.
00407   */
00408
00409   *pformatetcOut = *pformatetc;
00410   if (pformatetc->ptd == NULL)
00411     return DATA_S_SAMEFORMATETC;
00412   else
00413     {
00414     pformatetcOut->ptd = NULL;
00415     return NOERROR;
00416     }
00417 };
00418
00419 //**********************************************************************
00420 //
00421 // CDataObject::SetData
00422 //
00423 // Purpose:
00424 //
00425 //      Called to set the data for the object.
00426 //
00427 // Parameters:
00428 //
00429 //      LPFORMATETC pformatetc      - the format of the data being passed
00430 //
00431 //      STGMEDIUM FAR * pmedium     - the location of the data.
00432 //
00433 //      BOOL fRelease               - Defines the ownership of the medium
00434 //
00435 // Return Value:
00436 //
00437 //      DATA_E_FORMATETC    - Not a valid FORMATETC for this object
00438 //
00439 // Function Calls:
00440 //      Function                    Location
00441 //
00442 //      OutputDebugString           Windows API
00443 //
00444 // Comments:
00445 //
00446 //      This simple object does not support having its data set, so an
00447 //      error value is always returned.
00448 //
00449 //********************************************************************
00450
00451
00452 STDMETHODIMP CDataObject::SetData  ( LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium,
00453                    BOOL fRelease)
00454 {
00455   OutputDebugString("In CDataObject::SetData\r\n");
00456   return  DATA_E_FORMATETC ;
00457 };
00458
00459 //**********************************************************************
00460 //
00461 // CDataObject::EnumFormatEtc
00462 //
00463 // Purpose:
00464 //
00465 //      Enumerates the formats supported by this object.
00466 //
00467 // Parameters:
00468 //
00469 //      DWORD dwDirection                       - Order of enumeration.
00470 //
00471 //      LPENUMFORMATETC FAR* ppenumFormatEtc    - Place to return a pointer
00472 //                                                to the enumerator.
00473 //
00474 // Return Value:
00475 //
00476 //      OLE_S_USEREG    - Indicates that OLE should consult the REG DB
00477 //                        to enumerate the formats.
00478 //
00479 // Function Calls:
00480 //      Function                    Location
00481 //
00482 //      OutputDebugString           Windows API
00483 //
00484 // Comments:
00485 //
00486 //
00487 //********************************************************************
00488
00489
00490 STDMETHODIMP CDataObject::EnumFormatEtc  ( DWORD dwDirection,
00491                        LPENUMFORMATETC FAR* ppenumFormatEtc)
00492 {
00493   OutputDebugString("In CDataObject::EnumFormatEtc\r\n");
00494   // need to NULL the out parameter
00495   *ppenumFormatEtc = NULL;
00496   return  OLE_S_USEREG ;
00497 };
00498
00499 //**********************************************************************
00500 //
00501 // CDataObject::EnumDAdvise
00502 //
00503 // Purpose:
00504 //
00505 //      Returns an enumerator that enumerates all of the advises
00506 //      set up on this data object.
00507 //
00508 // Parameters:
00509 //
00510 //      LPENUMSTATDATA FAR* ppenumAdvise    - An out ptr in which to
00511 //                                            return the enumerator.
00512 //
00513 // Return Value:
00514 //
00515 //      Passed back from IDataAdviseHolder::EnumAdvise
00516 //
00517 // Function Calls:
00518 //      Function                        Location
00519 //
00520 //      OutputDebugString               Windows API
00521 //      IDAtaAdviseHolder::EnumAdvise   OLE
00522 //
00523 // Comments:
00524 //
00525 //      This just delegates to the DataAdviseHolder.
00526 //
00527 //********************************************************************
00528
00529
00530 STDMETHODIMP CDataObject::EnumDAdvise  ( LPENUMSTATDATA FAR* ppenumAdvise)
00531 {
00532   OutputDebugString("In CDataObject::EnumDAdvise\r\n");
00533   // need to NULL the out parameter
00534   *ppenumAdvise = NULL;
00535
00536   return m_lpObj->m_lpDataAdviseHolder->EnumAdvise(ppenumAdvise);
00537 };
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/IPArp/IPArp.Cpp Source File

  • NetDS
  • IPHelp
  • IPArp

IPArp.Cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002     Copyright (c) 1998 - 2000  Microsoft Corporation
00003     Module Name: IpArp.exe
00004     File       : IpArp.cpp
00005     Description: This file demonstrates the use of IP Helper APIs to
00006                  manipulate ARP cache.
00007     Author:
00008     Frank Li           April 16, 1998
00009
00010
00011     Revision History:
00012     Who         When        What
00013     --------    --------    ----------------------------------
00014     Frank Li    04-16-98    created
00015 ---------------------------------------------------------------------------*/
00016
00017 #include "IpArp.h"
00018
00019
00020 void Usage(char * pszProgramName)
00021 {
00022     printf("%s -s inet_addr eth_addr [if_addr]\n", pszProgramName);
00023     printf("%s -d inet_addr [if_addr]\n", pszProgramName);
00024     printf("%s -a\n", pszProgramName);
00025
00026     printf("-a            Displays current ARP entries by interrogating the current\n");
00027     printf("              protocol data.\n");
00028     printf("-d            Deletes the host specified by inet_addr.\n");
00029     printf("-s            Adds the host and associates the Internet address inet_addr\n");
00030     printf("              with the Physical address eth_addr.  The Physical address is\n");
00031     printf("              given as 6 hexadecimal bytes separated by hyphens. The entry\n");
00032     printf("              is permanent.\n");
00033     printf("eth_addr      Specifies a physical address.\n");
00034     printf("if_addr       If present, this specifies the Internet address of the\n");
00035     printf("              interface whose address translation table should be modified.\n");
00036     printf("              If not present, the first applicable interface will be used.\n");
00037     printf("Example:\n");
00038     printf("   >IpArp -s 157.55.85.212   00-aa-bb-cc-dd-ee 0x2000003 .... Add a static\n");
00039     printf("                                  arp entry on interface number 0x2000003.\n");
00040     printf("   >IpArp -a                                    ....Displays the arp table.\n");
00041     printf("   >IpArp -d 157.55.85.212                      ....Delete an entry.\n");
00042     WSACleanup();
00043     exit(1);
00044 }
00045
00046
00047 void _cdecl main(int argc, char **argv)
00048 {
00049     WORD wVersionRequested = MAKEWORD(1,1);
00050     WSADATA wsaData;
00051     int nRet;
00052
00053     nRet = WSAStartup(wVersionRequested, &wsaData);
00054     if (wsaData.wVersion != wVersionRequested)
00055     {
00056         fprintf(stderr,"\n Wrong version\n");
00057         return;
00058     }
00059
00060
00061     if ((argc < 2) || (argv[1][0] != '-'))
00062         Usage("IpArp");
00063     if (strlen(argv[1]) > 2)
00064         Usage("IpArp");
00065
00066     switch(argv[1][1])
00067     {
00068     case 'a':
00069         // Print arp table
00070         DoGetIpNetTable();
00071         break;
00072     case 's':
00073         //Update or add an ARP Internet/Ethernet Address entry
00074         if (argc == 4)
00075             DoSetIpNetEntry(argv[2], argv[3]);
00076         else if (argc == 5)
00077             DoSetIpNetEntry(argv[2], argv[3], argv[4]);
00078         else
00079             Usage("IpArp");
00080         break;
00081     case 'd':
00082         //Delete an Internet/Ethernet Address pair from the ARP table
00083         if (argc == 3)
00084             DoDeleteIpNetEntry(argv[2]);
00085         else if (argc == 4)
00086             DoDeleteIpNetEntry(argv[2], argv[3]);
00087         else
00088             Usage("IpArp");
00089         break;
00090     default:
00091         // help
00092         Usage("IpArp");
00093         break;
00094     }
00095     WSACleanup();
00096 }
00097
00098
00099 void DoGetIpNetTable()
00100 {
00101     DWORD dwStatus;
00102     PMIB_IPNETTABLE pIpArpTab = NULL;
00103
00104
00105     if ( (dwStatus = MyGetIpNetTable(pIpArpTab, TRUE)) == NO_ERROR)
00106     {
00107         PrintIpNetTable(pIpArpTab);
00108         free(pIpArpTab);
00109         return;
00110     }
00111     else if ( dwStatus == ERROR_NO_DATA)
00112     {
00113         printf("No entries in arp cache.\n");
00114         if (pIpArpTab)
00115             free (pIpArpTab);
00116         return;
00117     }
00118     else
00119     {
00120         if (pIpArpTab)
00121             free (pIpArpTab);
00122         printf("IpArp returned 0x%x\n", dwStatus);
00123         return;
00124     }
00125
00126 }
00127
00128 //----------------------------------------------------------------------------
00129 // Add an arp entry with ip dotted decimal address of "pszDottedInetAddr" and
00130 // physical address of "pszPhysAddr" in 00-aa-bb-cc-dd-ee format on interface
00131 // index of "pszInterface" in hex form.
00132 //----------------------------------------------------------------------------
00133 void DoSetIpNetEntry(char* pszDottedInetAddr, char* pszPhysAddr, char* pszInterface)
00134 {
00135     DWORD dwInetAddr = 0; // ip address
00136     DWORD dwStatus;
00137     BYTE bPhysAddr[MAXLEN_PHYSADDR];
00138
00139     if (pszDottedInetAddr == NULL || pszPhysAddr == NULL)
00140     {
00141         printf("IpArp: Bad Argument\n");
00142         return;
00143     }
00144
00145     dwInetAddr = inet_addr(pszDottedInetAddr); // convert dotted ip addr. to ip addr.
00146     if (dwInetAddr == INADDR_NONE)
00147     {
00148         printf("IpArp: Bad Argument %s\n", pszDottedInetAddr);
00149         return;
00150     }
00151
00152     if (StringToPhysAddr(pszPhysAddr, (char*)bPhysAddr ) != 0)
00153     {
00154         printf("IpArp: Bad Argument %s\n", pszPhysAddr);
00155         return;
00156     }
00157     MIB_IPNETROW arpEntry; // an arp entry
00158     if (pszInterface)
00159     {
00160         // User provides a interface index number
00161         sscanf(pszInterface, "%X",&(arpEntry.dwIndex));
00162     }
00163     else
00164     {
00165         // add this to the first available interface
00166         PMIB_IPADDRTABLE pIpAddrTable = NULL;
00167         if ( (dwStatus = MyGetIpAddrTable(pIpAddrTable)) != NO_ERROR)
00168         {
00169             printf("IpArp: Couldn't find a interface number to add your arp entry\n");
00170             return;
00171         }
00172         arpEntry.dwIndex = pIpAddrTable->table[0].dwIndex;
00173         free(pIpAddrTable);
00174     }
00175     arpEntry.dwPhysAddrLen = 6;
00176     memcpy(arpEntry.bPhysAddr, bPhysAddr, 6);
00177     arpEntry.dwAddr = dwInetAddr;
00178     arpEntry.dwType = MIB_IPNET_TYPE_STATIC; //static arp entry
00179     dwStatus = SetIpNetEntry(&arpEntry);
00180     if (dwStatus != NO_ERROR)
00181     {
00182         printf("IpArp: couldn't add (%s, %s), dwStatus = %lu.\n",
00183                     pszDottedInetAddr, pszPhysAddr, dwStatus);
00184     }
00185 }
00186 //----------------------------------------------------------------------------
00187 // Delete an arp entry with ip dotted decimal address of "pszDottedInetAddr"
00188 // and interface index of "pszInterface" in hex form.
00189 //----------------------------------------------------------------------------
00190 void DoDeleteIpNetEntry(char* pszDottedInetAddr, char* pszInterface)
00191 {
00192     DWORD dwInetAddr = 0; // ip address
00193     DWORD dwStatus;
00194
00195     if (pszDottedInetAddr == NULL)
00196     {
00197         printf("IpArp: Bad Argument\n");
00198         return;
00199     }
00200     dwInetAddr = inet_addr(pszDottedInetAddr); // convert dotted ip addr. to ip addr.
00201     if (dwInetAddr == INADDR_NONE)
00202     {
00203         printf("IpArp: Bad Argument %s\n", pszDottedInetAddr);
00204         return;
00205     }
00206
00207     MIB_IPNETROW arpEntry; // an arp entry
00208     if (pszInterface)
00209     {
00210         // User provides a interface index number
00211         sscanf(pszInterface, "%X",&(arpEntry.dwIndex));
00212     }
00213     else
00214     {
00215         // try to delete this from first available interface
00216         PMIB_IPADDRTABLE pIpAddrTable = NULL;
00217         if ( (dwStatus = MyGetIpAddrTable(pIpAddrTable)) != NO_ERROR)
00218         {
00219             printf("IpArp: Couldn't find a interface number to add your arp entry\n");
00220             return;
00221         }
00222         arpEntry.dwIndex = pIpAddrTable->table[0].dwIndex;
00223         free(pIpAddrTable);
00224     }
00225
00226     arpEntry.dwAddr = dwInetAddr;
00227     dwStatus = DeleteIpNetEntry(&arpEntry);
00228     if (dwStatus != NO_ERROR)
00229     {
00230         printf("IpArp: couldn't delete (%s), dwStatus = %lu.\n",
00231                     pszDottedInetAddr, dwStatus);
00232     }
00233
00234
00235 }
00236 //----------------------------------------------------------------------------
00237 // Inputs: pIpAddrTable is the IP address table
00238 //         dwIndex is the Interface Number
00239 // Output: If it returns TRUE, str contains the ip address of the interface
00240 //----------------------------------------------------------------------------
00241 bool InterfaceIdxToInterfaceIp(PMIB_IPADDRTABLE pIpAddrTable, DWORD dwIndex, char str[])
00242 {
00243     struct in_addr inadTmp;
00244     char* szIpAddr;
00245
00246     if (pIpAddrTable == NULL ||  str == NULL)
00247         return FALSE;
00248     str[0] = '\0';
00249     for (DWORD dwIdx = 0; dwIdx < pIpAddrTable->dwNumEntries; dwIdx++)
00250     {
00251         if (dwIndex == pIpAddrTable->table[dwIdx].dwIndex)
00252         {
00253             inadTmp.s_addr = pIpAddrTable->table[dwIdx].dwAddr;
00254             szIpAddr = inet_ntoa(inadTmp);
00255             if (szIpAddr)
00256             {
00257                 strcpy(str, szIpAddr);
00258                 return TRUE;
00259             }
00260             else
00261                 return FALSE;
00262         }
00263     }
00264     return FALSE;
00265
00266 }
00267
00268 //-------------------------------------------------------------------------
00269 // Input: str points to an ethernet address of the form 00-aa-bb-cc-dd-ee
00270 // If it returns 0, ret contains the 6 bytes ethernet address.
00271 //-------------------------------------------------------------------------
00272
00273 int StringToPhysAddr(char* szInEther,  char* szOutEther)
00274 {
00275     const char DASH = '-';
00276     register char c;
00277     register int val;
00278
00279     // check szInEther for the correct format
00280     if (strlen(szInEther) != 17)
00281         return (-1);
00282     if (szInEther[2] != DASH || szInEther[5] != DASH || szInEther[8] != DASH ||
00283         szInEther[8] != DASH || szInEther[14] != DASH)
00284         return (-1);
00285     if (!isxdigit(szInEther[0]) || !isxdigit(szInEther[1]) ||
00286         !isxdigit(szInEther[3]) || !isxdigit(szInEther[4]) ||
00287         !isxdigit(szInEther[6]) || !isxdigit(szInEther[7]) ||
00288         !isxdigit(szInEther[9]) || !isxdigit(szInEther[10]) ||
00289         !isxdigit(szInEther[12]) || !isxdigit(szInEther[13]) ||
00290         !isxdigit(szInEther[15]) || !isxdigit(szInEther[16]))
00291         return (-1);
00292     // convert the 12 hex decimals back to 6 digit decimals
00293     for (int i = 0; i < 6; i++)
00294     {
00295         val = 0;
00296         c = toupper(szInEther[i*3]);
00297         c = c - (isdigit(c) ? '0' : ('A' - 10)); //offset adjustment
00298         val += c;
00299         val = (val << 4); // val * 16
00300         c = toupper(szInEther[i*3 + 1]);
00301         c = c - (isdigit(c) ? '0' : ('A' - 10)); // offset adjustement
00302         val += c;
00303         szOutEther[i] = val;
00304     }
00305     return (0);
00306 }
00307
00308 //----------------------------------------------------------------------------
00309 // Inputs: PhysAddr is the hardware address in bytes
00310 //         PhysAddrLen is the length of the PhysAddr
00311 // Outputs: if it returns TRUE, str is the hex formated string of the hardware
00312 //          address.
00313 // NOTE: make sure str is TRIPLE as big as PhysAddrLen
00314 //----------------------------------------------------------------------------
00315 bool PhysAddrToString(BYTE PhysAddr[], DWORD PhysAddrLen, char str[])
00316 {
00317     if (PhysAddr == NULL || PhysAddrLen == 0 || str == NULL)
00318         return FALSE;
00319     str[0] = '\0';
00320     for (DWORD dwIdx = 0; dwIdx < PhysAddrLen; dwIdx++)
00321     {
00322         if (dwIdx == PhysAddrLen-1)
00323             sprintf(str+(dwIdx*3), "%02X", ((int)PhysAddr[dwIdx])&0xff);
00324         else
00325             sprintf(str+(dwIdx*3), "%02X-", ((int)PhysAddr[dwIdx])&0xff);
00326
00327     }
00328     return TRUE;
00329 }
00330 //----------------------------------------------------------------------------
00331 //   arp table format to be printed:
00332 // Interface: 157.61.239.34 on Interface 2
00333 //   Internet Address      Physical Address      Type
00334 //   159.61.230.39         00-aa-00-61-5d-a4     dynamic
00335 //
00336 // Interface: 157.54.178.219 on Interface 3
00337 //   Internet Address      Physical Address      Type
00338 //   159.54.170.1          00-10-54-42-c0-88     dynamic
00339 //   159.54.170.113        00-aa-00-c0-80-2e     dynamic
00340 //----------------------------------------------------------------------------
00341 void PrintIpNetTable(PMIB_IPNETTABLE pIpNetTable)
00342 {
00343     DWORD i, dwStatus, dwCurrIndex;
00344     struct in_addr inadTmp;
00345     char szPrintablePhysAddr[256];
00346     char szType[128];
00347     char szIpAddr[128];
00348     PMIB_IPADDRTABLE pIpAddrTable = NULL;
00349
00350     if (pIpNetTable == NULL)
00351     {
00352         printf( "pIpNetTable == NULL in line %d\n", __LINE__);
00353         return;
00354     }
00355     // get IP Address Table for mapping interface index number to ip address
00356     if ( (dwStatus = MyGetIpAddrTable(pIpAddrTable)) != NO_ERROR)
00357     {
00358         printf("GetIpAddrTable returned 0x%x\n", dwStatus);
00359         if (pIpAddrTable)
00360             free(pIpAddrTable);
00361         return;
00362     }
00363     assert(pIpAddrTable);
00364     // Note: the ARP table should be sorted in interface index
00365     dwCurrIndex = pIpNetTable->table[0].dwIndex;
00366     if (InterfaceIdxToInterfaceIp(pIpAddrTable, dwCurrIndex, szIpAddr))
00367     {
00368         printf("\nInterface: %s on Interface 0x%X\n", szIpAddr, dwCurrIndex);
00369         printf("  Internet Address      Physical Address      Type\n");
00370     }
00371     else
00372     {
00373         printf("Error: Could not convert Interface number 0x%X to IP address.\n",
00374                     pIpNetTable->table[0].dwIndex);
00375         return;
00376     }
00377
00378
00379     for (i = 0; i < pIpNetTable->dwNumEntries; ++i)
00380     {
00381         if (pIpNetTable->table[i].dwIndex != dwCurrIndex)
00382         {
00383             dwCurrIndex = pIpNetTable->table[i].dwIndex;
00384             if (InterfaceIdxToInterfaceIp(pIpAddrTable, dwCurrIndex, szIpAddr))
00385             {
00386                 printf("Interface: %s on Interface 0x%X\n", szIpAddr, dwCurrIndex);
00387                 printf("  Internet Address      Physical Address      Type\n");
00388             }
00389             else
00390             {
00391                 printf("Error: Could not convert Interface number 0x%X to IP address.\n",
00392                     pIpNetTable->table[0].dwIndex);
00393                 return;
00394             }
00395         }
00396         PhysAddrToString(pIpNetTable->table[i].bPhysAddr, pIpNetTable->table[i].dwPhysAddrLen, szPrintablePhysAddr);
00397         inadTmp.s_addr = pIpNetTable->table[i].dwAddr;
00398         switch (pIpNetTable->table[i].dwType)
00399         {
00400         case 1:
00401             strcpy(szType,"other");
00402             break;
00403         case 2:
00404             strcpy(szType,"invalidated");
00405             break;
00406         case 3:
00407             strcpy(szType,"dynamic");
00408             break;
00409         case 4:
00410             strcpy(szType,"static");
00411             break;
00412         default:
00413             strcpy(szType,"invalidType");
00414         }
00415         printf("  %-16s      %-17s     %-11s\n", inet_ntoa(inadTmp), szPrintablePhysAddr, szType);
00416
00417     }
00418     if (pIpAddrTable)
00419         free(pIpAddrTable);
00420 }
00421
00422
00423 //----------------------------------------------------------------------------
00424 //  Format of IP Address Table:
00425 //  ipAdEntAddr   ifAdEntIfIndex  ipAdEntNetMask   ipAdEntBcastAddr  ipAdEntReasmMaxSize
00426 //----------------------------------------------------------------------------
00427 void PrintIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable)
00428 {
00429     DWORD i;
00430     struct in_addr inadTmp1;
00431     struct in_addr inadTmp2;
00432     char szAddr[128];
00433     char szMask[128];
00434
00435     if (pIpAddrTable == NULL)
00436     {
00437         printf( "pIpAddrTable == NULL in line %d\n", __LINE__);
00438         return;
00439     }
00440     printf("ipAdEntAddr\t ifAdEntIfIndex\t ipAdEntNetMask\t ipAdEntBcastAddr\t ipAdEntReasmMaxSize\n");
00441     for (i = 0; i < pIpAddrTable->dwNumEntries; ++i)
00442     {
00443         inadTmp1.s_addr = pIpAddrTable->table[i].dwAddr;
00444         strcpy(szAddr, inet_ntoa(inadTmp1));
00445         inadTmp2.s_addr = pIpAddrTable->table[i].dwMask;
00446         strcpy(szMask, inet_ntoa(inadTmp2));
00447         printf("  %s\t 0x%X\t %s\t %s\t %u\n",
00448                 szAddr,
00449                 pIpAddrTable->table[i].dwIndex,
00450                 szMask,
00451                 (pIpAddrTable->table[i].dwBCastAddr ? "255.255.255.255" : "0.0.0.0"),
00452                 pIpAddrTable->table[i].dwReasmSize);
00453
00454     }
00455 }
00456
00457 //----------------------------------------------------------------------------
00458 // Input : fOrder -- sorts the output IP Addr Table
00459 // Output: If it returns NO_ERROR, pIpAddrTable points to the IP Addr Table
00460 //----------------------------------------------------------------------------
00461 DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE& pIpAddrTable, bool fOrder)
00462 {
00463     DWORD status = NO_ERROR;
00464     DWORD statusRetry = NO_ERROR;
00465     DWORD dwActualSize = 0;
00466
00467
00468     // query for buffer size needed
00469     status = GetIpAddrTable(pIpAddrTable, &dwActualSize, fOrder);
00470
00471     if (status == NO_ERROR)
00472     {
00473         printf("No error\n");
00474         return status;
00475     }
00476     else if (status == ERROR_INSUFFICIENT_BUFFER)
00477     {
00478         // need more space
00479
00480         pIpAddrTable = (PMIB_IPADDRTABLE) malloc(dwActualSize);
00481         assert(pIpAddrTable);
00482
00483         statusRetry = GetIpAddrTable(pIpAddrTable, &dwActualSize, fOrder);
00484         return statusRetry;
00485     }
00486     else
00487     {
00488         return status;
00489     }
00490 }
00491
00492 //----------------------------------------------------------------------------
00493 // Input : fOrder -- sorts the output IP Net Table
00494 // Output: If it returns NO_ERROR, pIpNetTable points to the IP Net Table
00495 //----------------------------------------------------------------------------
00496 DWORD MyGetIpNetTable(PMIB_IPNETTABLE& pIpNetTable, bool fOrder)
00497 {
00498     DWORD status = NO_ERROR;
00499     DWORD statusRetry = NO_ERROR;
00500     DWORD dwActualSize = 0;
00501
00502     // query for buffer size needed
00503     dwActualSize = 0;
00504     status = GetIpNetTable(pIpNetTable, &dwActualSize, fOrder);
00505
00506     if (status == NO_ERROR)
00507     {
00508         return status;
00509     }
00510     else if (status == ERROR_INSUFFICIENT_BUFFER)
00511     {
00512         // need more space
00513
00514         pIpNetTable = (PMIB_IPNETTABLE) malloc(dwActualSize);
00515         assert(pIpNetTable);
00516
00517         statusRetry = GetIpNetTable(pIpNetTable, &dwActualSize, fOrder);
00518
00519         if (statusRetry != NO_ERROR)
00520         {
00521 #ifdef _DEBUG
00522             printf("Retry failed.\n");
00523 #endif
00524             return statusRetry;
00525         }
00526         else
00527         {
00528             return statusRetry;
00529         }
00530     }
00531     else
00532     {
00533 #ifdef _DEBUG
00534         printf("first getipnettable call failed\n");
00535 #endif
00536         return status;
00537     }
00538 }
00539
00540
00541
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/OpenQDlg.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

OpenQDlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // OpenQDlg.h : header file
00013 //
00014
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // COpenQueueDialog dialog
00018 #ifndef _OPENQDLG_H
00019 #define _OPENQDLG_H
00020
00021 #define OPENQDLG_CLEAR_COMBOBOX -1
00022 class COpenQueueDialog : public CDialog
00023 {
00024 // Construction
00025 public:
00026   COpenQueueDialog(CArray <ARRAYQ*, ARRAYQ*>*, CWnd* pParent = NULL);   // standard constructor
00027
00028 // Dialog Data
00029   //{{AFX_DATA(COpenQueueDialog)
00030   enum { IDD = IDD_OPEN_QUEUE_DIALOG };
00031   CComboBox m_FormatNameCB;
00032   CComboBox m_PathNameCB;
00033   CString m_szPathName;
00034   CString m_szFormatName;
00035   int   m_iAccessRight;
00036   //}}AFX_DATA
00037
00038   /* pointer to the array with the strings for the combo box (Queues PathName). */
00039   CArray <ARRAYQ*, ARRAYQ*>* m_pStrArray ;
00040
00041 // Overrides
00042   // ClassWizard generated virtual function overrides
00043   //{{AFX_VIRTUAL(COpenQueueDialog)
00044   protected:
00045   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00046   //}}AFX_VIRTUAL
00047
00048 // Implementation
00049 protected:
00050
00051   // Generated message map functions
00052   //{{AFX_MSG(COpenQueueDialog)
00053   virtual BOOL OnInitDialog();
00054   afx_msg void OnSelchangeFormatnameCombo2();
00055   afx_msg void OnSelchangePathnameCombo();
00056   afx_msg void OnEditupdateFormatnameCombo2();
00057   afx_msg void OnEditupdatePathnameCombo();
00058   //}}AFX_MSG
00059   DECLARE_MESSAGE_MAP()
00060
00061 protected:
00062
00063 public:
00064   void GetFormatName(TCHAR szFormatName[BUFFERSIZE]);
00065
00066
00067
00068   void GetPathName(TCHAR szPathName[BUFFERSIZE])
00069   {
00070     ASSERT(szPathName != NULL);
00071
00072     _tcsncpy (szPathName, m_szPathName, BUFFERSIZE-1);
00073     szPathName[BUFFERSIZE-1] = '\0';
00074
00075   }
00076
00077   DWORD GetAccess()
00078   {
00079     switch (m_iAccessRight)
00080     {
00081       case 0:
00082         return MQ_SEND_ACCESS;
00083         break;
00084       case 1:
00085         return MQ_RECEIVE_ACCESS;
00086         break;
00087       case 2:
00088         return MQ_PEEK_ACCESS;
00089         break;
00090       default:
00091         return 0;
00092         break;
00093     }
00094   }
00095 };
00096
00097 #endif
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/land.h Source File

  • SysMgmt
  • MMC
  • ActiveX

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include <mmc.h>
00024 #include "DeleBase.h"
00025
00026 class CLandBasedVehicle : public CDelegationBase {
00027 public:
00028     CLandBasedVehicle(CComponentData *pComponentData = NULL)
00029     { m_pComponentData = pComponentData; }
00030
00031     virtual ~CLandBasedVehicle() {}
00032
00033     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00034     virtual const GUID & getNodeType() { return thisGuid; }
00035     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00036
00037 private:
00038     enum { IDM_NEW_LAND = 2 };
00039
00040     // {2974380E-4C4B-11d2-89D8-000021473128}
00041     static const GUID thisGuid;
00042 };
00043
00044 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/keys.cpp Source File

  • WinUI
  • TSFcase

keys.cpp

Go to the documentation of this file.
00001 //
00002 // keys.cpp
00003 //
00004 // ITfKeyEventSink implementation.
00005 //
00006
00007 #include "globals.h"
00008 #include "case.h"
00009 #include "editsess.h"
00010
00011 class CKeystrokeEditSession : public CEditSessionBase
00012 {
00013 public:
00014     CKeystrokeEditSession(ITfContext *pContext, WPARAM wParam) : CEditSessionBase(pContext)
00015     {
00016         _wParam = wParam;
00017     }
00018
00019     // ITfEditSession
00020     STDMETHODIMP DoEditSession(TfEditCookie ec);
00021
00022 private:
00023     WPARAM _wParam;
00024 };
00025
00026
00027 /* 5d6d1b1e-64f2-47cd-9fe1-4e032c2dae77 */
00028 static const GUID GUID_PRESERVEDKEY_FLIPCASE = { 0x5d6d1b1e, 0x64f2, 0x47cd, {0x9f, 0xe1, 0x4e, 0x03, 0x2c, 0x2d, 0xae, 0x77} };
00029 // arbitrary hotkey: ctl-f
00030 static const TF_PRESERVEDKEY c_FlipCaseKey = { 'F', TF_MOD_CONTROL };
00031
00032
00033 //+---------------------------------------------------------------------------
00034 //
00035 // IsKeyEaten
00036 //
00037 //----------------------------------------------------------------------------
00038
00039 inline BOOL IsKeyEaten(BOOL fFlipKeys, WPARAM wParam)
00040 {
00041     // we're only interested in VK_A - VK_Z, when the "Flip Keys" menu option
00042     // is on
00043     return fFlipKeys && (wParam >= 'A') && (wParam <= 'Z');
00044 }
00045
00046 //+---------------------------------------------------------------------------
00047 //
00048 // _Menu_FlipKeys
00049 //
00050 // Advise or unadvise a keystroke sink.
00051 //----------------------------------------------------------------------------
00052
00053 /* static */
00054 void CCaseTextService::_Menu_FlipKeys(CCaseTextService *_this)
00055 {
00056     _this->_fFlipKeys = !_this->_fFlipKeys;
00057 }
00058
00059 //+---------------------------------------------------------------------------
00060 //
00061 // _InitKeystrokeSink
00062 //
00063 // Advise a keystroke sink.
00064 //----------------------------------------------------------------------------
00065
00066 BOOL CCaseTextService::_InitKeystrokeSink()
00067 {
00068     ITfKeystrokeMgr *pKeystrokeMgr;
00069     HRESULT hr;
00070
00071     if (_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&pKeystrokeMgr) != S_OK)
00072         return FALSE;
00073
00074     hr = pKeystrokeMgr->AdviseKeyEventSink(_tfClientId, (ITfKeyEventSink *)this, TRUE);
00075
00076     pKeystrokeMgr->Release();
00077
00078     return (hr == S_OK);
00079 }
00080
00081 //+---------------------------------------------------------------------------
00082 //
00083 // _UninitKeystrokeSink
00084 //
00085 // Unadvise a keystroke sink.  Assumes we have advised one already.
00086 //----------------------------------------------------------------------------
00087
00088 void CCaseTextService::_UninitKeystrokeSink()
00089 {
00090     ITfKeystrokeMgr *pKeystrokeMgr;
00091
00092     if (_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&pKeystrokeMgr) != S_OK)
00093         return;
00094
00095     pKeystrokeMgr->UnadviseKeyEventSink(_tfClientId);
00096
00097     pKeystrokeMgr->Release();
00098 }
00099
00100 //+---------------------------------------------------------------------------
00101 //
00102 // _InitPreservedKey
00103 //
00104 // Register a hot key.
00105 //----------------------------------------------------------------------------
00106
00107 BOOL CCaseTextService::_InitPreservedKey()
00108 {
00109     ITfKeystrokeMgr *pKeystrokeMgr;
00110     HRESULT hr;
00111
00112     if (_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&pKeystrokeMgr) != S_OK)
00113         return FALSE;
00114
00115     hr = pKeystrokeMgr->PreserveKey(_tfClientId, GUID_PRESERVEDKEY_FLIPCASE,
00116                                     &c_FlipCaseKey, L"Toggle Case",
00117                                     wcslen(L"Toggle Case"));
00118
00119     pKeystrokeMgr->Release();
00120
00121     return (hr == S_OK);
00122 }
00123
00124 //+---------------------------------------------------------------------------
00125 //
00126 // _UninitPreservedKey
00127 //
00128 // Uninit a hot key.
00129 //----------------------------------------------------------------------------
00130
00131 void CCaseTextService::_UninitPreservedKey()
00132 {
00133     ITfKeystrokeMgr *pKeystrokeMgr;
00134
00135     if (_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&pKeystrokeMgr) != S_OK)
00136         return;
00137
00138     pKeystrokeMgr->UnpreserveKey(GUID_PRESERVEDKEY_FLIPCASE, &c_FlipCaseKey);
00139
00140     pKeystrokeMgr->Release();
00141 }
00142
00143 //+---------------------------------------------------------------------------
00144 //
00145 // OnSetFocus
00146 //
00147 // Called by the system whenever this service gets the keystroke device focus.
00148 //----------------------------------------------------------------------------
00149
00150 STDAPI CCaseTextService::OnSetFocus(BOOL fForeground)
00151 {
00152     return S_OK;
00153 }
00154
00155 //+---------------------------------------------------------------------------
00156 //
00157 // OnTestKeyDown
00158 //
00159 // Called by the system to query this service wants a potential keystroke.
00160 //----------------------------------------------------------------------------
00161
00162 STDAPI CCaseTextService::OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00163 {
00164     *pfEaten = IsKeyEaten(_fFlipKeys, wParam);
00165     return S_OK;
00166 }
00167
00168 //+---------------------------------------------------------------------------
00169 //
00170 // OnKeyDown
00171 //
00172 // Called by the system to offer this service a keystroke.  If *pfEaten == TRUE
00173 // on exit, the application will not handle the keystroke.
00174 //----------------------------------------------------------------------------
00175
00176 STDAPI CCaseTextService::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00177 {
00178     CKeystrokeEditSession *pEditSession;
00179     HRESULT hr = S_OK;
00180
00181     *pfEaten = IsKeyEaten(_fFlipKeys, wParam);
00182
00183     if (*pfEaten)
00184     {
00185         // we'll insert a char ourselves in place of this keystroke
00186         if ((pEditSession = new CKeystrokeEditSession(pContext, wParam)) == NULL)
00187         {
00188             hr = E_OUTOFMEMORY;
00189             goto Exit;
00190         }
00191
00192         // we need a lock to do our work
00193         // nb: this method is one of the few places where it is legal to use
00194         // the TF_ES_SYNC flag
00195         if (pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_SYNC | TF_ES_READWRITE, &hr) != S_OK)
00196         {
00197             hr = E_FAIL;
00198         }
00199
00200         pEditSession->Release();
00201     }
00202
00203 Exit:
00204     if (hr != S_OK)
00205     {
00206         *pfEaten = FALSE;
00207     }
00208     return S_OK;
00209 }
00210
00211 //+---------------------------------------------------------------------------
00212 //
00213 // DoEditSession
00214 //
00215 //----------------------------------------------------------------------------
00216
00217 STDAPI CKeystrokeEditSession::DoEditSession(TfEditCookie ec)
00218 {
00219     WCHAR wc;
00220
00221     // we want to toggle the english case of the keystroke
00222     // nb: this is quick-and-dirty code, not intended to demonstrate the
00223     // correct way to flip capitalization!
00224
00225     if (GetKeyState(VK_SHIFT) & 0x8000)
00226     {
00227         // shift-key, make it lowercase
00228         wc = (WCHAR)(_wParam | 32);
00229     }
00230     else
00231     {
00232         // else make it capital
00233         wc = (WCHAR)_wParam;
00234     }
00235
00236     InsertTextAtSelection(ec, _pContext, &wc, 1);
00237
00238     return S_OK;
00239 }
00240
00241 //+---------------------------------------------------------------------------
00242 //
00243 // OnTestKeyUp
00244 //
00245 // Called by the system to query this service wants a potential keystroke.
00246 //----------------------------------------------------------------------------
00247
00248 STDAPI CCaseTextService::OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00249 {
00250     *pfEaten = IsKeyEaten(_fFlipKeys, wParam);
00251     return S_OK;
00252 }
00253
00254 //+---------------------------------------------------------------------------
00255 //
00256 // OnKeyUp
00257 //
00258 // Called by the system to offer this service a keystroke.  If *pfEaten == TRUE
00259 // on exit, the application will not handle the keystroke.
00260 //----------------------------------------------------------------------------
00261
00262 STDAPI CCaseTextService::OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00263 {
00264     *pfEaten = IsKeyEaten(_fFlipKeys, wParam);
00265     return S_OK;
00266 }
00267
00268 //+---------------------------------------------------------------------------
00269 //
00270 // OnPreservedKey
00271 //
00272 // Called when a hotkey (registered by us, or by the system) is typed.
00273 //----------------------------------------------------------------------------
00274
00275 STDAPI CCaseTextService::OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pfEaten)
00276 {
00277     if (IsEqualGUID(rguid, GUID_PRESERVEDKEY_FLIPCASE))
00278     {
00279         _Menu_FlipDoc(this);
00280         *pfEaten = TRUE;
00281     }
00282     else
00283     {
00284         *pfEaten = FALSE;
00285     }
00286
00287     return S_OK;
00288 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/ComSyncObject/StdAfx.h Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • ComSyncObject

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__5F663AB1_F6A8_11D2_A10B_0080C71F306F__INCLUDED_)
00006 #define AFX_STDAFX_H__5F663AB1_F6A8_11D2_A10B_0080C71F306F__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__5F663AB1_F6A8_11D2_A10B_0080C71F306F__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

PROVIDERINFO Member List

This is the complete list of members for PROVIDERINFO, including all inherited members.
wszDescription | PROVIDERINFO
wszName | PROVIDERINFO
wszParseName | PROVIDERINFO
wType | PROVIDERINFO
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/tracemacro.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

tracemacro.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  TraceMacro.h : Defines custom tracing helpers.
00014 //
00015
00016
00017 #ifndef _TRACE_MACRO_HEADER_
00018 #define _TRACE_MACRO_HEADER_
00019
00020 //---------------------------------------------------------------------------
00021 //  Function prototypes
00022 //
00023 VOID Trace_Start( LPCTSTR pszClass, LPCTSTR pszFunction );
00024 VOID Trace_HR( LPCTSTR pszClass, LPCTSTR pszFunction, HRESULT hr );
00025 VOID Trace_Value( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszValueName, LONG nValue );
00026 VOID Trace_Pointer( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszObject, ULONG ulValue );
00027 VOID Trace_Event( LPCTSTR pszClass, LPCTSTR pszFunction, LONG nEvent );
00028 VOID MapEvent( LONG Event, LPTSTR szEventStr );
00029
00030
00031 // Alternate version provides complete path to the file
00032 // #define TRACE_HRESULT(str,hr)  Trace_HR( _T(__FILE__), (str), (hr) )
00033
00034 #ifdef _DEBUG
00035
00036 #undef  TRACE_HRESULT
00037 #define TRACE_HRESULT(s1,hr) Trace_HR( (MODULESTRING),(s1),(hr) )
00038
00039 #undef  TRACE_VAL
00040 #define TRACE_VAL(s1,s2,val) Trace_Value( (MODULESTRING),(s1),(s2),(val) )
00041
00042 #undef  TRACE_PTR
00043 #define TRACE_PTR(s1,s2,val) Trace_Pointer( (MODULESTRING),(s1),(s2),(val) )
00044
00045 #undef  TRACE_EVENT
00046 #define TRACE_EVENT(s1,val)  Trace_Event( (MODULESTRING),(s1),(val) )
00047
00048 #undef  TRACE_START
00049 #define TRACE_START( s1 )    Trace_Start( (MODULESTRING),(s1) )
00050
00051
00052 #else
00053
00054 #undef  TRACE_HRESULT
00055 #define TRACE_HRESULT
00056
00057 #undef  TRACE_VAL
00058 #define TRACE_VAL
00059
00060 #undef  TRACE_PTR
00061 #define TRACE_PTR
00062
00063 #undef  TRACE_EVENT
00064 #define TRACE_EVENT
00065
00066 #undef  TRACE_START
00067 #define TRACE_START
00068
00069 #endif //_DEBUG
00070
00071
00072 #endif //_TRACE_MACRO_HEADER_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the Class Factories of the LICSERVE
00005              server.  This server provides a licensed factory for the
00006              LicCruiseCar COM component. Thus this COM object factory
00007              implements IClassFactory2. In addition, a non-licensed
00008              CFLicCarSample class factory is included to provide a
00009              component with the Code Sample utility interface ISample.
00010              This interface is primarily for use within the code samples
00011              for the purposes of setting them up as samples (eg, setting
00012              up the server so that it trace logs to the client's trace log
00013              facility).  The COM Components that can be manufactured by
00014              this server are known outside the server by their respective
00015              CLSIDs: CLSID_LicCruiseCar and CLSID_LicCarSample.
00016
00017              For a comprehensive tutorial code tour of this module's
00018              contents and offerings see the tutorial LICSERVE.HTM file.
00019              For more specific technical details on the internal workings
00020              see the comments dispersed throughout the module's source code.
00021
00022   Classes:   CFLicCruiseCar, CFLicCarSample.
00023
00024   Functions: .
00025
00026   Origin:    10-5-95: atrent - Editor-inheritance from FACTORY.CPP in
00027                the DLLSERVE Tutorial Code Sample.
00028
00029 ----------------------------------------------------------------------------
00030   This file is part of the Microsoft COM Tutorial Code Samples.
00031
00032   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00033
00034   This source code is intended only as a supplement to Microsoft
00035   Development Tools and/or on-line documentation.  See these other
00036   materials for detailed information regarding Microsoft code samples.
00037
00038   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00039   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00040   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00041   PARTICULAR PURPOSE.
00042 ==========================================================================+*/
00043
00044 /*---------------------------------------------------------------------------
00045   We include WINDOWS.H for all Win32 applications.
00046   We include OLE2.H because we will be calling the COM/OLE Libraries
00047     in future exploitation of this DLL skeleton.
00048   We include OLECTL.H because we will be using IClassFactory2.
00049   We include APPUTIL.H because we will be building this DLL using
00050     the convenient Virtual Window and Dialog classes and other
00051     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00052   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00053     class, GUID, and CLSID specifications.
00054   We include SERVER.H because it has the necessary internal class and
00055     resource definitions for this DLL.
00056   We include FACTORY.H because it has the necessary internal class factory
00057     declarations for this DLL component server.  Those factories we will be
00058     implementing in this module.
00059   We include CRUCAR.H for the object class declarations for the
00060     COLicCruiseCar COM object.
00061   We include SAMPLE.H for the utility Sample class COLicCarSample.
00062 ---------------------------------------------------------------------------*/
00063 #include <windows.h>
00064 #include <ole2.h>
00065 #include <olectl.h>
00066 #include <apputil.h>
00067 #include <icars.h>
00068 #include <carguids.h>
00069 #include "server.h"
00070 #include "factory.h"
00071 #include "crucar.h"
00072 #include "sample.h"
00073
00074
00075 /*---------------------------------------------------------------------------
00076   Implementation the CFLicCruiseCar Class Factory.  CFLicCruiseCar is the
00077   COM object class for the Class Factory that can manufacture
00078   COLicCruiseCar COM Components.  As part of the LICSERVE code sample
00079   CFLicCruiseCar implements the IClassFactory2 interface to provide
00080   licensing services.
00081 ---------------------------------------------------------------------------*/
00082
00083 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00084   Method:   CFLicCruiseCar::CFLicCruiseCar
00085
00086   Summary:  CFLicCruiseCar Constructor. Note the member initializer:
00087             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00088             to pass the 'this', pUnkOuter, and pServer pointers of this
00089             constructor function to the constructor executed in the
00090             instantiation of the CImpIClassFactory interface whose
00091             implementation is nested inside this present object class.
00092
00093   Args:     IUnknown* pUnkOuter,
00094               Pointer to the the outer Unknown.  NULL means this COM Object
00095               is not being Aggregated.  Non NULL means it is being created
00096               on behalf of an outside COM object that is reusing it via
00097               aggregation.
00098             CServer* pServer)
00099               Pointer to the server's control object.
00100
00101   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00102
00103   Returns:  void
00104 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00105 CFLicCruiseCar::CFLicCruiseCar(
00106   IUnknown* pUnkOuter,
00107   CServer* pServer) :
00108   m_ImpIClassFactory(this, pUnkOuter, pServer)
00109 {
00110   // Zero the COM object's reference count.
00111   m_cRefs = 0;
00112
00113   // No AddRef necessary if non-NULL, as we're nested.
00114   m_pUnkOuter = pUnkOuter;
00115
00116   // Init the pointer to the server control object.
00117   m_pServer = pServer;
00118
00119   LOGF1("P: CFLicCruiseCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00120
00121   return;
00122 }
00123
00124
00125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00126   Method:   CFLicCruiseCar::~CFLicCruiseCar
00127
00128   Summary:  CFLicCruiseCar Destructor.
00129
00130   Args:     void
00131
00132   Modifies: .
00133
00134   Returns:  void
00135 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00136 CFLicCruiseCar::~CFLicCruiseCar(void)
00137 {
00138   LOG("P: CFLicCruiseCar::Destructor.");
00139
00140   return;
00141 }
00142
00143
00144 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00145   Method:   CFLicCruiseCar::QueryInterface
00146
00147   Summary:  QueryInterface of the CFLicCruiseCar non-delegating
00148             IUnknown implementation.
00149
00150   Args:     REFIID riid,
00151               [in] GUID of the Interface being requested.
00152             PPVOID ppv)
00153               [out] Address of the caller's pointer variable that will
00154               receive the requested interface pointer.
00155
00156   Returns:  HRESULT
00157               Standard result code. NOERROR for success.
00158 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00159 STDMETHODIMP CFLicCruiseCar::QueryInterface(
00160                REFIID riid,
00161                PPVOID ppv)
00162 {
00163   HRESULT hr = E_NOINTERFACE;
00164   *ppv = NULL;
00165
00166   if (IID_IUnknown == riid)
00167   {
00168     *ppv = this;
00169     LOG("P: CFLicCruiseCar::QueryInterface. 'this' pIUnknown returned.");
00170   }
00171   else if (IID_IClassFactory == riid)
00172   {
00173     *ppv = &m_ImpIClassFactory;
00174     LOG("P: CFLicCruiseCar::QueryInterface. pIClassFactory returned.");
00175   }
00176   else if (IID_IClassFactory2 == riid)
00177   {
00178     *ppv = &m_ImpIClassFactory;
00179     LOG("P: CFLicCruiseCar::QueryInterface. pIClassFactory2 returned.");
00180   }
00181
00182   if (NULL != *ppv)
00183   {
00184     // We've handed out a pointer to the interface so obey the COM rules
00185     // and AddRef the reference count.
00186     ((LPUNKNOWN)*ppv)->AddRef();
00187     hr = NOERROR;
00188   }
00189
00190   return (hr);
00191 }
00192
00193
00194 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00195   Method:   CFLicCruiseCar::AddRef
00196
00197   Summary:  AddRef of the CFLicCruiseCar non-delegating IUnknown
00198             implementation.
00199
00200   Args:     void
00201
00202   Modifies: m_cRefs.
00203
00204   Returns:  ULONG
00205               New value of m_cRefs (COM object's reference count).
00206 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00207 STDMETHODIMP_(ULONG) CFLicCruiseCar::AddRef(void)
00208 {
00209   m_cRefs++;
00210
00211   LOGF1("P: CFLicCruiseCar::AddRef. New cRefs=%i.", m_cRefs);
00212
00213   return m_cRefs;
00214 }
00215
00216
00217 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00218   Method:   CFLicCruiseCar::Release
00219
00220   Summary:  Release of the CFLicCruiseCar non-delegating IUnknown
00221             implementation.
00222
00223   Args:     void
00224
00225   Modifies: m_cRefs.
00226
00227   Returns:  ULONG
00228               New value of m_cRefs (COM object's reference count).
00229 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00230 STDMETHODIMP_(ULONG) CFLicCruiseCar::Release(void)
00231 {
00232   m_cRefs--;
00233
00234   LOGF1("P: CFLicCruiseCar::Release. New cRefs=%i.", m_cRefs);
00235
00236   if (0 == m_cRefs)
00237   {
00238     // We've reached a zero reference count for this COM object.
00239     // So we tell the server housing to decrement its global object
00240     // count so that the server will be unloaded if appropriate.
00241     if (NULL != m_pServer)
00242       m_pServer->ObjectsDown();
00243
00244     // We artificially bump the main ref count to prevent reentrancy
00245     // via the main object destructor.  Not really needed in this
00246     // CFLicCruiseCar but a good practice because we are aggregatable and
00247     // may at some point in the future add something entertaining like
00248     // some Releases to the CFLicCruiseCar destructor.
00249     m_cRefs++;
00250     delete this;
00251   }
00252
00253   return m_cRefs;
00254 }
00255
00256
00257 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00258   Method:   CFLicCruiseCar::CreateLicCruiseCar
00259
00260   Summary:  Unconditionally create a LicCruiseCar COM object.  Called
00261             internally in this class from CreateInstance and
00262             CreateInstanceLic.
00263
00264   Args:     IUnknown* pUnkOuter,
00265               [in] Pointer to the aggregation controlling outer IUnknown.
00266             REFIID riid,
00267               [in] The GUID of the interface that is being requested.
00268             PPVOID ppvCob)
00269               [out] Address of the caller's pointer variable that will
00270               receive the requested interface pointer.
00271
00272   Returns:  HRESULT
00273               Standard result code. NOERROR for success.
00274               Returned by a QueryInterface call.
00275 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00276 STDMETHODIMP CFLicCruiseCar::CreateLicCruiseCar(
00277                IUnknown* pUnkOuter,
00278                REFIID riid,
00279                PPVOID ppvCob)
00280 {
00281   HRESULT hr = E_FAIL;
00282   COLicCruiseCar* pCob = NULL;
00283
00284   LOGF1("P: CFLicCruiseCar::CreateLicCruiseCar. pUnkOuter=0x%X.",pUnkOuter);
00285
00286   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00287   // the COM rules state the IUnknown interface MUST also be concomitantly
00288   // be requested.  If it is not so requested ( riid != IID_IUnknown) then
00289   // an error must be returned indicating that no aggregate creation of
00290   // the COLicCruiseCarFactory COM Object can be performed.
00291   if (NULL != pUnkOuter && riid != IID_IUnknown)
00292     hr = CLASS_E_NOAGGREGATION;
00293   else
00294   {
00295     // Instantiate a COLicCruiseCar COM Object.
00296     pCob = new COLicCruiseCar(pUnkOuter, m_pServer);
00297     if (NULL != pCob)
00298     {
00299       // We initially created the new COM object so tell the server
00300       // to increment its global server object count to help ensure
00301       // that the server remains loaded until this partial creation
00302       // of a COM component is completed.
00303       m_pServer->ObjectsUp();
00304
00305       // If we have succeeded in instantiating the COM object we
00306       // initialize it to set up any subordinate objects.
00307       hr = pCob->Init();
00308       if (SUCCEEDED(hr))
00309       {
00310         // We QueryInterface this new COM Object not only to deposit the
00311         // main interface pointer to the caller's pointer variable, but to
00312         // also automatically bump the Reference Count on the new COM
00313         // Object after handing out this reference to it.
00314         hr = pCob->QueryInterface(riid, (PPVOID)ppvCob);
00315       }
00316
00317       if (FAILED(hr))
00318       {
00319         m_pServer->ObjectsDown();
00320         delete pCob;
00321       }
00322     }
00323     else
00324       hr = E_OUTOFMEMORY;
00325   }
00326
00327   if (SUCCEEDED(hr))
00328   {
00329     LOGF1("P: CFLicCruiseCar::CreateLicCruiseCar Succeeded. *ppv=0x%X.",*ppvCob);
00330   }
00331   else
00332   {
00333     LOG("P: CFLicCruiseCar::CreateLicCruiseCar Failed.");
00334   }
00335
00336   return hr;
00337 }
00338
00339
00340 /*---------------------------------------------------------------------------
00341   CFLicCruiseCar's nested implementation of the IClassFactory2 interface
00342   including Constructor, Destructor, QueryInterface, AddRef, Release,
00343   CreateInstance, LockServer, CreateInstanceLic, RequestLicKey, and
00344   GetLicInfo methods.
00345 ---------------------------------------------------------------------------*/
00346
00347 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00348   Method:   CFLicCruiseCar::CImpIClassFactory::CImpIClassFactory
00349
00350   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00351
00352   Args:     CFLicCruiseCar* pBackObj,
00353               Back pointer to the parent outer object.
00354             IUnknown* pUnkOuter,
00355               Pointer to the outer Unknown.  For delegation.
00356             CServer* pServer)
00357               Pointer to the server's control object.
00358
00359   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
00360
00361   Returns:  void
00362 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00363 CFLicCruiseCar::CImpIClassFactory::CImpIClassFactory(
00364   CFLicCruiseCar* pBackObj,
00365   IUnknown* pUnkOuter,
00366   CServer* pServer)
00367 {
00368   // Init the Interface Ref Count (used for debugging only).
00369   m_cRefI = 0;
00370
00371   // Init the Back Object Pointer to point to the parent object.
00372   m_pBackObj = pBackObj;
00373
00374   // Init the pointer to the server control object.
00375   m_pServer = pServer;
00376
00377   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00378   // We use the Back Object pointer for IUnknown delegation here if we are
00379   // not being aggregated.  If we are being aggregated we use the supplied
00380   // pUnkOuter for IUnknown delegation.  In either case the pointer
00381   // assignment requires no AddRef because the CImpIClassFactory lifetime
00382   // is quaranteed by the lifetime of the parent object in which
00383   // CImpIClassFactory is nested.
00384   if (NULL == pUnkOuter)
00385   {
00386     m_pUnkOuter = pBackObj;
00387     LOG("P: CFLicCruiseCar::CImpIClassFactory Constructor. Non-Aggregating.");
00388   }
00389   else
00390   {
00391     m_pUnkOuter = pUnkOuter;
00392     LOG("P: CFLicCruiseCar::CImpIClassFactory Constructor. Aggregating.");
00393   }
00394
00395   return;
00396 }
00397
00398
00399 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00400   Method:   CFLicCruiseCar::CImpIClassFactory::~CImpIClassFactory
00401
00402   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00403
00404   Args:     void
00405
00406   Modifies: .
00407
00408   Returns:  void
00409 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00410 CFLicCruiseCar::CImpIClassFactory::~CImpIClassFactory(void)
00411 {
00412   LOG("P: CFLicCruiseCar::CImpIClassFactory Destructor.");
00413
00414   return;
00415 }
00416
00417
00418 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00419   Method:   CFLicCruiseCar::CImpIClassFactory::QueryInterface
00420
00421   Summary:  The QueryInterface IUnknown member of this IClassFactory
00422             interface implementation that delegates to m_pUnkOuter,
00423             whatever it is.
00424
00425   Args:     REFIID riid,
00426               [in] GUID of the Interface being requested.
00427             PPVOID ppv)
00428               [out] Address of the caller's pointer variable that will
00429               receive the requested interface pointer.
00430
00431   Returns:  HRESULT
00432               Standard result code. NOERROR for success.
00433               Returned by the delegated outer QueryInterface call.
00434 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00435 STDMETHODIMP CFLicCruiseCar::CImpIClassFactory::QueryInterface(
00436                REFIID riid,
00437                PPVOID ppv)
00438 {
00439   LOG("P: CFLicCruiseCar::CImpIClassFactory::QueryInterface. Delegating.");
00440
00441   // Delegate this call to the outer object's QueryInterface.
00442   return m_pUnkOuter->QueryInterface(riid, ppv);
00443 }
00444
00445
00446 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00447   Method:   CFLicCruiseCar::CImpIClassFactory::AddRef
00448
00449   Summary:  The AddRef IUnknown member of this IClassFactory interface
00450             implementation that delegates to m_pUnkOuter, whatever it is.
00451
00452   Args:     void
00453
00454   Modifies: m_cRefI.
00455
00456   Returns:  ULONG
00457               Returned by the delegated outer AddRef call.
00458 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00459 STDMETHODIMP_(ULONG) CFLicCruiseCar::CImpIClassFactory::AddRef(void)
00460 {
00461   // Increment the Interface Reference Count.
00462   ++m_cRefI;
00463
00464   LOGF1("P: CFLicCruiseCar::CImpIClassFactory::Addref. Delegating. New cI=%i.",m_cRefI);
00465
00466   // Delegate this call to the outer object's AddRef.
00467   return m_pUnkOuter->AddRef();
00468 }
00469
00470
00471 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00472   Method:   CFLicCruiseCar::CImpIClassFactory::Release
00473
00474   Summary:  The Release IUnknown member of this IClassFactory interface
00475             implementation that delegates to m_pUnkOuter, whatever it is.
00476
00477   Args:     void
00478
00479   Modifies: .
00480
00481   Returns:  ULONG
00482               Returned by the delegated outer Release call.
00483 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00484 STDMETHODIMP_(ULONG) CFLicCruiseCar::CImpIClassFactory::Release(void)
00485 {
00486   // Decrement the Interface Reference Count.
00487   --m_cRefI;
00488
00489   LOGF1("P: CFLicCruiseCar::CImpIClassFactory::Release. Delegating. New cI=%i.",m_cRefI);
00490
00491   // Delegate this call to the outer object's Release.
00492   return m_pUnkOuter->Release();
00493 }
00494
00495
00496 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00497   Method:   CFLicCruiseCar::CImpIClassFactory::CreateInstance
00498
00499   Summary:  The CreateInstance member method of this IClassFactory
00500             interface implementation.  Creates an instance of the
00501             COLicCruiseCar COM component.  Pays due heed to licensing and
00502             only completes the create if the server was confirmed as
00503             licensed.
00504
00505   Args:     IUnknown* pUnkOuter,
00506               [in] Pointer to the controlling IUnknown.
00507             REFIID riid,
00508               [in] GUID of the Interface being requested.
00509             PPVOID ppvCob)
00510               [out] Address of the caller's pointer variable that will
00511               receive the requested interface pointer.
00512
00513   Returns:  HRESULT
00514               Standard result code. NOERROR for success.
00515 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00516 STDMETHODIMP CFLicCruiseCar::CImpIClassFactory::CreateInstance(
00517                IUnknown* pUnkOuter,
00518                REFIID riid,
00519                PPVOID ppv)
00520 {
00521   HRESULT hr = CLASS_E_NOTLICENSED;
00522
00523   LOGF1("P: CFLicCruiseCar::CImpIClassFactory::CreateInstance. pUnkOuter=0x%X.",pUnkOuter);
00524
00525   if (g_pServer->m_bLicensed)
00526     hr = m_pBackObj->CreateLicCruiseCar(pUnkOuter, riid, ppv);
00527   else
00528   {
00529     LOG("P: CFLicCruiseCar::CImpIClassFactory::CreateInstance. No Machine License.");
00530   }
00531
00532   if (SUCCEEDED(hr))
00533   {
00534     LOGF1("P: CFLicCruiseCar::CImpIClassFactory::CreateInstance Succeeded. *ppv=0x%X.",*ppv);
00535   }
00536   else
00537   {
00538     LOG("P: CFLicCruiseCar::CImpIClassFactory::CreateInstance Failed.");
00539   }
00540
00541   return hr;
00542 }
00543
00544
00545 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00546   Method:   CFLicCruiseCar::CImpIClassFactory::LockServer
00547
00548   Summary:  The LockServer member method of this IClassFactory interface
00549             implementation.
00550
00551   Args:     BOOL fLock)
00552               [in] Flag determining whether to Lock or Unlock the server.
00553
00554   Returns:  HRESULT
00555               Standard result code. NOERROR for success.
00556 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00557 STDMETHODIMP CFLicCruiseCar::CImpIClassFactory::LockServer(
00558                BOOL fLock)
00559 {
00560   HRESULT hr = NOERROR;
00561
00562   LOG("P: CFLicCruiseCar::CImpIClassFactory::LockServer.");
00563
00564   if (fLock)
00565     m_pServer->Lock();
00566   else
00567     m_pServer->Unlock();
00568
00569   return hr;
00570 }
00571
00572
00573 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00574   Method:   CFLicCruiseCar::CImpIClassFactory::GetLicInfo
00575
00576
00577   Summary:  The GetLicInfo member method of the IClassFactory2 interface
00578             implementation.
00579
00580   Args:     LPLICINFO lpLicInfo
00581               Pointer to the license info structure to fill.
00582
00583   Returns:  HRESULT
00584               Standard result code. NOERROR for success.
00585 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00586 STDMETHODIMP CFLicCruiseCar::CImpIClassFactory::GetLicInfo(
00587                LPLICINFO pLicInfo)
00588 {
00589   HRESULT hr = NOERROR;
00590
00591   LOG("P: CFLicCruiseCar::CImpIClassFactory::GetLicInfo.");
00592
00593   if (NULL != pLicInfo)
00594   {
00595     pLicInfo->cbLicInfo = sizeof(LICINFO);
00596
00597     // Inform whether RequestLicKey will work.
00598     pLicInfo->fRuntimeKeyAvail = g_pServer->m_bLicensed;
00599
00600     // Inform whether the standard CreateInstance will work.
00601     pLicInfo->fLicVerified = g_pServer->m_bLicensed;
00602   }
00603   else
00604     hr = E_POINTER;
00605
00606   return hr;
00607 }
00608
00609
00610 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00611   Method:   CFLicCruiseCar::CImpIClassFactory::RequestLicKey
00612
00613
00614   Summary:  The RequestLicKey member method of the IClassFactory2
00615             interface implementation.  Returns a license key string
00616             for this Class Factory.  The key string is used in calls
00617             to the CreateInstanceLic IClassFactory2 method.
00618
00619   Args:     DWORD dwReserved,
00620               Reserved for future use with multiple licenses.
00621             BSTR* pbstrKey
00622               Pointer to the buffer in which to return the key string.
00623
00624   Returns:  HRESULT
00625               Standard result code. NOERROR for success.
00626 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00627 STDMETHODIMP CFLicCruiseCar::CImpIClassFactory::RequestLicKey(
00628                DWORD dwReserved,
00629                BSTR* pbstrKey)
00630 {
00631   HRESULT hr = CLASS_E_NOTLICENSED;
00632   OLECHAR szLicKey[MAX_LICENSEKEY];
00633
00634   LOG("P: CFLicCruiseCar::CImpIClassFactory::RequestLicKey.");
00635
00636   // Only return the license key if the server machine license was verified.
00637   if (g_pServer->m_bLicensed)
00638   {
00639     // Convert our ANSI license string to Wide Char and then alloc as BSTR.
00640     mbstowcs(szLicKey, g_pServer->m_szLicenseKey, g_pServer->m_cLicenseLen);
00641     *pbstrKey = SysAllocString(szLicKey);
00642     hr = (NULL != *pbstrKey) ? NOERROR : E_OUTOFMEMORY;
00643   }
00644
00645   return hr;
00646 }
00647
00648
00649 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00650   Method:   CFLicCruiseCar::CImpIClassFactory::CreateInstanceLic
00651
00652   Summary:  The CreateInstanceLic member method of the IClassFactory2
00653             interface implementation.  Creates an instance of the managed
00654             COM object given a proper license key string.
00655
00656   Args:     IUnknown* pUnkOuter,
00657               Pointer to the aggregation controlling IUnknown.
00658             IUnknown* pUnkReserved,
00659               Reserved.
00660             REFIID riid,
00661               A reference to the GUID of the interface requested on the
00662               new object.
00663             BSTR bstrKey,
00664               The license key string.
00665             PPVOID ppvCob
00666               Address of the caller's pointer variable that will
00667               receive the requested interface pointer.
00668
00669   Returns:  HRESULT
00670               Standard result code. NOERROR for success.
00671 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00672 STDMETHODIMP CFLicCruiseCar::CImpIClassFactory::CreateInstanceLic(
00673                IUnknown* pUnkOuter,
00674                IUnknown* pUnkReserved,
00675                REFIID riid,
00676                BSTR bstrKey,
00677                PPVOID ppvCob)
00678 {
00679   HRESULT hr;
00680   BOOL    bMatch = FALSE;
00681   BSTR    bstrTemp;
00682   UINT    cch = g_pServer->m_cLicenseLen;
00683   OLECHAR szLicKey[MAX_LICENSEKEY];
00684
00685   LOG("P: CFLicCruiseCar::CImpIClassFactory::CreateInstanceLic.");
00686
00687   *ppvCob = NULL;
00688
00689   // Convert our ANSI license string to Wide Char and then alloc as BSTR.
00690   mbstowcs(szLicKey, g_pServer->m_szLicenseKey, cch);
00691   bstrTemp = SysAllocString(szLicKey);
00692   if (NULL != bstrTemp)
00693   {
00694     if (NULL != bstrKey)
00695       bMatch = (0 == memcmp(bstrTemp, bstrKey, cch * sizeof(OLECHAR)));
00696
00697     SysFreeString(bstrTemp);
00698
00699     if (bMatch)
00700       hr = m_pBackObj->CreateLicCruiseCar(pUnkOuter, riid, ppvCob);
00701     else
00702     {
00703       LOG("P: CFLicCruiseCar::CImpIClassFactory::CreateInstanceLic. No Runtime License.");
00704       hr = CLASS_E_NOTLICENSED;
00705     }
00706   }
00707   else
00708     hr = E_OUTOFMEMORY;
00709
00710   return hr;
00711 }
00712
00713
00714 /*---------------------------------------------------------------------------
00715   Implementation the CFLicCarSample Class Factory (IClassFactory).
00716   CFLicCarSample is the COM object class for the Class Factory that can
00717   manufacture COLicCarSample COM Components.
00718 ---------------------------------------------------------------------------*/
00719
00720 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00721   Method:   CFLicCarSample::CFLicCarSample
00722
00723   Summary:  CFLicCruiseCar Constructor. Note the member initializer:
00724             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00725             to pass the 'this', pUnkOuter, and pServer pointers of this
00726             constructor function to the constructor executed in the
00727             instantiation of the CImpIClassFactory interface whose
00728             implementation is nested inside this present object class.
00729
00730   Args:     IUnknown* pUnkOuter,
00731               Pointer to the the outer Unknown.  NULL means this COM Object
00732               is not being Aggregated.  Non NULL means it is being created
00733               on behalf of an outside COM object that is reusing it via
00734               aggregation.
00735             CServer* pServer)
00736               Pointer to the server's control object.
00737
00738   Modifies: m_cRefs, m_pUnkOuter.
00739
00740   Returns:  void
00741 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00742 CFLicCarSample::CFLicCarSample(
00743   IUnknown* pUnkOuter,
00744   CServer* pServer) :
00745   m_ImpIClassFactory(this, pUnkOuter, pServer)
00746 {
00747   // Zero the COM object's reference count.
00748   m_cRefs = 0;
00749
00750   // No AddRef necessary if non-NULL, as we're nested.
00751   m_pUnkOuter = pUnkOuter;
00752
00753   // Init the pointer to the server control object.
00754   m_pServer = pServer;
00755
00756   LOGF1("P: CFLicCarSample Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00757
00758   return;
00759 }
00760
00761
00762 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00763   Method:   CFLicCarSample::~CFLicCarSample
00764
00765   Summary:  CFLicCarSample Destructor.
00766
00767   Args:     void
00768
00769   Modifies: .
00770
00771   Returns:  void
00772 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00773 CFLicCarSample::~CFLicCarSample(void)
00774 {
00775   LOG("P: CFLicCarSample::Destructor.");
00776
00777   return;
00778 }
00779
00780
00781 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00782   Method:   CFLicCarSample::QueryInterface
00783
00784   Summary:  QueryInterface of the CFLicCarSample non-delegating
00785             IUnknown implementation.
00786
00787   Args:     REFIID riid,
00788               [in] GUID of the Interface being requested.
00789             PPVOID ppv)
00790               [out] Address of the caller's pointer variable that will
00791               receive the requested interface pointer.
00792
00793   Returns:  HRESULT
00794               Standard result code. NOERROR for success.
00795 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00796 STDMETHODIMP CFLicCarSample::QueryInterface(
00797                REFIID riid,
00798                PPVOID ppv)
00799 {
00800   HRESULT hr = E_NOINTERFACE;
00801   *ppv = NULL;
00802
00803   if (IID_IUnknown == riid)
00804   {
00805     *ppv = this;
00806     LOG("P: CFLicCarSample::QueryInterface. 'this' pIUnknown returned.");
00807   }
00808   else if (IID_IClassFactory == riid)
00809   {
00810     *ppv = &m_ImpIClassFactory;
00811     LOG("P: CFLicCarSample::QueryInterface. pIClassFactory returned.");
00812   }
00813
00814   if (NULL != *ppv)
00815   {
00816     // We've handed out a pointer to the interface so obey the COM rules
00817     //   and AddRef the reference count.
00818     ((LPUNKNOWN)*ppv)->AddRef();
00819     hr = NOERROR;
00820   }
00821
00822   return (hr);
00823 }
00824
00825
00826 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00827   Method:   CFLicCarSample::AddRef
00828
00829   Summary:  AddRef of the CFLicCarSample non-delegating IUnknown
00830             implementation.
00831
00832   Args:     void
00833
00834   Modifies: m_cRefs.
00835
00836   Returns:  ULONG
00837               New value of m_cRefs (COM object's reference count).
00838 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00839 STDMETHODIMP_(ULONG) CFLicCarSample::AddRef(void)
00840 {
00841   m_cRefs++;
00842
00843   LOGF1("P: CFLicCarSample::AddRef. New cRefs=%i.", m_cRefs);
00844
00845   return m_cRefs;
00846 }
00847
00848
00849 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00850   Method:   CFLicCarSample::Release
00851
00852   Summary:  Release of the CFLicCarSample non-delegating IUnknown
00853             implementation.
00854
00855   Args:     void
00856
00857   Modifies: m_cRefs.
00858
00859   Returns:  ULONG
00860               New value of m_cRefs (COM object's reference count).
00861 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00862 STDMETHODIMP_(ULONG) CFLicCarSample::Release(void)
00863 {
00864   m_cRefs--;
00865
00866   LOGF1("P: CFLicCarSample::Release. New cRefs=%i.", m_cRefs);
00867
00868   if (0 == m_cRefs)
00869   {
00870     // We've reached a zero reference count for this COM object.
00871     // So we tell the server housing to decrement its global object
00872     // count so that the server will be unloaded if appropriate.
00873     if (NULL != m_pServer)
00874       m_pServer->ObjectsDown();
00875
00876     // We artificially bump the main ref count to prevent reentrancy
00877     // via the main object destructor.  Not really needed in this
00878     // CFLicCarSample but a good practice because we are aggregatable and
00879     // may at some point in the future add something entertaining like
00880     // some Releases to the CFLicCarSample destructor.
00881     m_cRefs++;
00882     delete this;
00883   }
00884
00885   return m_cRefs;
00886 }
00887
00888
00889 /*---------------------------------------------------------------------------
00890   CFLicCarSample's nested implementation of the IClassFactory interface
00891   including Constructor, Destructor, QueryInterface, AddRef, Release,
00892   CreateInstance, and LockServer methods.
00893 ---------------------------------------------------------------------------*/
00894
00895 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00896   Method:   CFLicCarSample::CImpIClassFactory::CImpIClassFactory
00897
00898   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00899
00900   Args:     CFLicCarSample* pBackObj,
00901               Back pointer to the parent outer object.
00902             IUnknown* pUnkOuter,
00903               Pointer to the outer Unknown.  For delegation.
00904             CServer* pServer)
00905               Pointer to the server's control object.
00906
00907   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
00908
00909   Returns:  void
00910 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00911 CFLicCarSample::CImpIClassFactory::CImpIClassFactory(
00912   CFLicCarSample* pBackObj,
00913   IUnknown* pUnkOuter,
00914   CServer* pServer)
00915 {
00916   // Init the Interface Ref Count (used for debugging only).
00917   m_cRefI = 0;
00918
00919   // Init the Back Object Pointer to point to the parent object.
00920   m_pBackObj = pBackObj;
00921
00922   // Init the pointer to the server control object.
00923   m_pServer = pServer;
00924
00925   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00926   // We use the Back Object pointer for IUnknown delegation here if we are
00927   // not being aggregated.  If we are being aggregated we use the supplied
00928   // pUnkOuter for IUnknown delegation.  In either case the pointer
00929   // assignment requires no AddRef because the CImpIClassFactory lifetime
00930   // is quaranteed by the lifetime of the parent object in which
00931   // CImpIClassFactory is nested.
00932   if (NULL == pUnkOuter)
00933   {
00934     m_pUnkOuter = pBackObj;
00935     LOG("P: CFLicCarSample::CImpIClassFactory Constructor. Non-Aggregating.");
00936   }
00937   else
00938   {
00939     m_pUnkOuter = pUnkOuter;
00940     LOG("P: CFLicCarSample::CImpIClassFactory Constructor. Aggregating.");
00941   }
00942
00943   return;
00944 }
00945
00946
00947 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00948   Method:   CFLicCarSample::CImpIClassFactory::~CImpIClassFactory
00949
00950   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00951
00952   Args:     void
00953
00954   Modifies: .
00955
00956   Returns:  void
00957 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00958 CFLicCarSample::CImpIClassFactory::~CImpIClassFactory(void)
00959 {
00960   LOG("P: CFLicCarSample::CImpIClassFactory Destructor.");
00961
00962   return;
00963 }
00964
00965
00966 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00967   Method:   CFLicCarSample::CImpIClassFactory::QueryInterface
00968
00969   Summary:  The QueryInterface IUnknown member of this IClassFactory
00970             interface implementation that delegates to m_pUnkOuter,
00971             whatever it is.
00972
00973   Args:     REFIID riid,
00974               [in] GUID of the Interface being requested.
00975             PPVOID ppv)
00976               [out] Address of the caller's pointer variable that will
00977               receive the requested interface pointer.
00978
00979   Returns:  HRESULT
00980               Standard result code. NOERROR for success.
00981               Returned by the delegated outer QueryInterface call.
00982 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00983 STDMETHODIMP CFLicCarSample::CImpIClassFactory::QueryInterface(
00984                REFIID riid,
00985                PPVOID ppv)
00986 {
00987   LOG("P: CFLicCarSample::CImpIClassFactory::QueryInterface. Delegating.");
00988
00989   // Delegate this call to the outer object's QueryInterface.
00990   return m_pUnkOuter->QueryInterface(riid, ppv);
00991 }
00992
00993
00994 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00995   Method:   CFLicCarSample::CImpIClassFactory::AddRef
00996
00997   Summary:  The AddRef IUnknown member of this IClassFactory interface
00998             implementation that delegates to m_pUnkOuter, whatever it is.
00999
01000   Args:     void
01001
01002   Modifies: m_cRefI.
01003
01004   Returns:  ULONG
01005               Returned by the delegated outer AddRef call.
01006 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01007 STDMETHODIMP_(ULONG) CFLicCarSample::CImpIClassFactory::AddRef(void)
01008 {
01009   // Increment the Interface Reference Count.
01010   ++m_cRefI;
01011
01012   LOGF1("P: CFLicCarSample::CImpIClassFactory::Addref. Delegating. New cI=%i.",m_cRefI);
01013
01014   // Delegate this call to the outer object's AddRef.
01015   return m_pUnkOuter->AddRef();
01016 }
01017
01018
01019 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01020   Method:   CFLicCarSample::CImpIClassFactory::Release
01021
01022   Summary:  The Release IUnknown member of this IClassFactory interface
01023             implementation that delegates to m_pUnkOuter, whatever it is.
01024
01025   Args:     void
01026
01027   Modifies: .
01028
01029   Returns:  ULONG
01030               Returned by the delegated outer Release call.
01031 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01032 STDMETHODIMP_(ULONG) CFLicCarSample::CImpIClassFactory::Release(void)
01033 {
01034   // Decrement the Interface Reference Count.
01035   --m_cRefI;
01036
01037   LOGF1("P: CFLicCarSample::CImpIClassFactory::Release. Delegating. New cI=%i.",m_cRefI);
01038
01039   // Delegate this call to the outer object's Release.
01040   return m_pUnkOuter->Release();
01041 }
01042
01043
01044 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01045   Method:   CFLicCarSample::CImpIClassFactory::CreateInstance
01046
01047   Summary:  The CreateInstance member method of this IClassFactory
01048             interface implementation.  Creates an instance of the
01049             COLicCarSample COM component.
01050
01051   Args:     IUnknown* pUnkOuter,
01052               [in] Pointer to the controlling IUnknown.
01053             REFIID riid,
01054               [in] GUID of the Interface being requested.
01055             PPVOID ppv)
01056               [out] Address of the caller's pointer variable that will
01057               receive the requested interface pointer.
01058
01059   Returns:  HRESULT
01060               Standard result code. NOERROR for success.
01061 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01062 STDMETHODIMP CFLicCarSample::CImpIClassFactory::CreateInstance(
01063                IUnknown* pUnkOuter,
01064                REFIID riid,
01065                PPVOID ppv)
01066 {
01067   HRESULT hr = E_FAIL;
01068   COLicCarSample* pCob = NULL;
01069
01070   LOGF1("P: CFLicCarSample::CImpIClassFactory::CreateInstance. pUnkOuter=0x%X.",pUnkOuter);
01071
01072   // If the creation call is requesting aggregation (pUnkOuter != NULL),
01073   // the COM rules state the IUnknown interface MUST also be concomitantly
01074   // be requested.  If it is not so requested ( riid != IID_IUnknown) then
01075   // an error must be returned indicating that no aggregate creation of
01076   // the CFLicCarSample COM Object can be performed.
01077   if (NULL != pUnkOuter && riid != IID_IUnknown)
01078     hr = CLASS_E_NOAGGREGATION;
01079   else
01080   {
01081     // Instantiate a COLicCarSample COM Object.
01082     pCob = new COLicCarSample(pUnkOuter, m_pServer);
01083     if (NULL != pCob)
01084     {
01085       // We initially created the new COM object so tell the server
01086       // to increment its global server object count to help ensure
01087       // that the server remains loaded until this partial creation
01088       // of a COM component is completed.
01089       m_pServer->ObjectsUp();
01090
01091       // We QueryInterface this new COM Object not only to deposit the
01092       // main interface pointer to the caller's pointer variable, but to
01093       // also automatically bump the Reference Count on the new COM
01094       // Object after handing out this reference to it.
01095       hr = pCob->QueryInterface(riid, (PPVOID)ppv);
01096       if (FAILED(hr))
01097       {
01098         m_pServer->ObjectsDown();
01099         delete pCob;
01100       }
01101     }
01102     else
01103       hr = E_OUTOFMEMORY;
01104   }
01105
01106   if (SUCCEEDED(hr))
01107   {
01108     LOGF1("P: CFLicCarSample::CImpIClassFactory::CreateInstance Succeeded. *ppv=0x%X.",*ppv);
01109   }
01110   else
01111   {
01112     LOG("P: CFLicCarSample::CImpIClassFactory::CreateInstance Failed.");
01113   }
01114
01115   return hr;
01116 }
01117
01118
01119 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01120   Method:   CFLicCarSample::CImpIClassFactory::LockServer
01121
01122   Summary:  The LockServer member method of this IClassFactory interface
01123             implementation.
01124
01125   Args:     BOOL fLock)
01126               [in] Flag determining whether to Lock or Unlock the server.
01127
01128   Returns:  HRESULT
01129               Standard result code. NOERROR for success.
01130 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01131 STDMETHODIMP CFLicCarSample::CImpIClassFactory::LockServer(
01132                BOOL fLock)
01133 {
01134   HRESULT hr = NOERROR;
01135
01136   LOG("P: CFLicCarSample::CImpIClassFactory::LockServer.");
01137
01138   if (fLock)
01139     m_pServer->Lock();
01140   else
01141     m_pServer->Unlock();
01142
01143   return hr;
01144 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/simple/Simplec.c Source File

  • NetDS
  • WinSock
  • simple

Simplec.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 * simplec.c - Simple TCP/UDP client using Winsock 1.1
00003 *
00004 *       This is a part of the Microsoft Source Code Samples.
00005 *       Copyright 1996 - 2000 Microsoft Corporation.
00006 *       All rights reserved.
00007 *       This source code is only intended as a supplement to
00008 *       Microsoft Development Tools and/or WinHelp documentation.
00009 *       See these sources for detailed information regarding the
00010 *       Microsoft samples programs.
00011 \******************************************************************************/
00012 #ifdef _IA64_
00013     #pragma warning(disable:4127)
00014 #endif
00015
00016 #ifndef WIN32_LEAN_AND_MEAN
00017 #define WIN32_LEAN_AND_MEAN
00018 #endif
00019
00020 #include <winsock2.h>
00021 #include <ws2tcpip.h>
00022 #include <wspiapi.h>
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026
00027 #define DEFAULT_PORT            "5001"          // Default server port
00028 #define DEFAULT_PROTO           SOCK_STREAM     // Default protocol (TCP)
00029 #define DEFAULT_BUFFER_LEN      4096            // Default send/recv buffer length
00030
00031 //
00032 // Function: Usage
00033 //
00034 // Description:
00035 //    Print the parameters and exit.
00036 //
00037 void Usage(char *progname)
00038 {
00039     fprintf(stderr, "Usage\n%s -p [protocol] -n [server] -e [endpoint] -l [iterations] [-4] [-6]\n"
00040             "Where:\n"
00041             "\t-p protocol   - is one of TCP or UDP\n"
00042             "\t-n server     - is the string address or name of server\n"
00043             "\t-e endpoint   - is the port to listen on\n"
00044             "\t-l iterations - is the number of loops to execute\n"
00045             "\t   -l by itself makes client run in an infinite loop,"
00046             "\t   Hit Ctrl-C to terminate it)\n"
00047             "\t-4            - force IPv4\n"
00048             "\t-6            - force IPv6\n"
00049             "\n"
00050             "Defaults are TCP, localhost and 5001\n",
00051             progname
00052            );
00053     WSACleanup();
00054     exit(1);
00055 }
00056
00057
00058 //
00059 // Function: main
00060 //
00061 // Description:
00062 //    Parse the command line and attempt to connect to the given server.
00063 //    The client will attempt to connect to each address returned by the
00064 //    getaddrinfo call until one succeeds afterwhich it will initiate
00065 //    echoing the data. Once the requested number of sends are issued,
00066 //    the connection is closed. For UDP, this is simply connecting the
00067 //    UDP socket to and endpoint and issuing the requested number of
00068 //    datagram sends and receives.
00069 //
00070 int __cdecl main(int argc, char **argv)
00071 {
00072     WSADATA          wsaData;
00073     SOCKET           conn_socket = INVALID_SOCKET;
00074     struct addrinfo *results = NULL,
00075     *addrptr = NULL,
00076     hints;
00077     char            *server_name = "localhost",
00078     *port = DEFAULT_PORT,
00079     Buffer[DEFAULT_BUFFER_LEN],
00080     hoststr[NI_MAXHOST],
00081     servstr[NI_MAXSERV];
00082     int              address_family = AF_UNSPEC,
00083     socket_type = DEFAULT_PROTO;
00084     int              retval,
00085     loopflag = 0,
00086     loopcount,
00087     maxloop = -1,
00088     i;
00089
00090     // Parse the command line
00091     if (argc >1)
00092     {
00093         for (i=1; i < argc; i++)
00094         {
00095             if ( (strlen(argv[i]) == 2) && ((argv[i][0] == '-') || (argv[i][0] == '/') ) )
00096             {
00097                 switch (tolower(argv[i][1]))
00098                 {
00099                 case '4':           // Force IPv4
00100                     address_family = AF_INET;
00101                     break;
00102
00103                 case '6':           // Force IPv6
00104                     address_family = AF_INET6;
00105                     break;
00106
00107                 case 'p':           // Protocol (UDP or TCP)
00108                     if (!_strnicmp(argv[i+1], "TCP", 3) )
00109                         socket_type = SOCK_STREAM;
00110                     else if (!_strnicmp(argv[i+1], "UDP", 3) )
00111                         socket_type = SOCK_DGRAM;
00112                     else
00113                         Usage(argv[0]);
00114                     i++;
00115                     break;
00116
00117                 case 'n':           // Server name to connect to
00118                     server_name = argv[++i];
00119                     break;
00120
00121                 case 'e':           // Port number to connect to
00122                     port = argv[++i];
00123                     break;
00124
00125                 case 'l':           // Number of iterations
00126                     loopflag = 1;
00127                     if (i+1 >= argc)
00128                         Usage(argv[0]);
00129                     if (argv[i+1][0] != '-')
00130                         maxloop = atoi(argv[i+1]);
00131                     else
00132                         maxloop = -1;
00133                     i++;
00134                     break;
00135
00136                 default:
00137                     Usage(argv[0]);
00138                     break;
00139                 }
00140             }
00141             else
00142                 Usage(argv[0]);
00143         }
00144     }
00145
00146     // Load Winsock
00147     if ((retval = WSAStartup(MAKEWORD(2,2), &wsaData)) != 0)
00148     {
00149         fprintf(stderr,"WSAStartup failed with error %d\n",retval);
00150         WSACleanup();
00151         return -1;
00152     }
00153
00154     // Make sure the wildcard port wasn't specified
00155     if (_strnicmp(port, "0", 1) == 0)
00156         Usage(argv[0]);
00157
00158     //
00159     // Resolve the server name
00160     //
00161     memset(&hints, 0, sizeof(hints));
00162     hints.ai_family = address_family;
00163     hints.ai_socktype = socket_type;
00164     hints.ai_protocol = ((socket_type == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP);
00165
00166     retval = getaddrinfo(
00167                         server_name,
00168                         port,
00169                         &hints,
00170                         &results
00171                         );
00172     if (retval != 0)
00173     {
00174         fprintf(stderr, "getaddrinfo failed: %d\n", retval);
00175         goto cleanup;
00176     }
00177
00178     // Make sure we got at least one address
00179     if (results == NULL)
00180     {
00181         fprintf(stderr, "Server (%s) name could not be resolved!\n", server_name);
00182         goto cleanup;
00183     }
00184
00185     //
00186     // Walk through the list of addresses returned and connect to each one.
00187     //    Take the first successful connection.
00188     //
00189     addrptr = results;
00190     while (addrptr)
00191     {
00192         conn_socket = socket(addrptr->ai_family, addrptr->ai_socktype, addrptr->ai_protocol);
00193         if (conn_socket == INVALID_SOCKET)
00194         {
00195             fprintf(stderr, "socket failed: %d\n", WSAGetLastError());
00196             goto cleanup;
00197         }
00198
00199         //
00200         // Notice that nothing in this code is specific to whether we
00201         // are using UDP or TCP.
00202         // We achieve this by using a simple trick.
00203         //    When connect() is called on a datagram socket, it does not
00204         //    actually establish the connection as a stream (TCP) socket
00205         //    would. Instead, TCP/IP establishes the remote half of the
00206         //    ( LocalIPAddress, LocalPort, RemoteIP, RemotePort) mapping.
00207         //    This enables us to use send() and recv() on datagram sockets,
00208         //    instead of recvfrom() and sendto()
00209
00210         retval = getnameinfo(
00211                             addrptr->ai_addr,
00212                             (socklen_t)addrptr->ai_addrlen,
00213                             hoststr,
00214                             NI_MAXHOST,
00215                             servstr,
00216                             NI_MAXSERV,
00217                             NI_NUMERICHOST | NI_NUMERICSERV
00218                             );
00219         if (retval != 0)
00220         {
00221             fprintf(stderr, "getnameinfo failed: %d\n", retval);
00222             goto cleanup;
00223         }
00224
00225         printf("Client attempting connection to: %s port: %s\n", hoststr, servstr);
00226
00227         retval = connect(conn_socket, addrptr->ai_addr, (int)addrptr->ai_addrlen);
00228         if (retval == SOCKET_ERROR)
00229         {
00230             closesocket(conn_socket);
00231             conn_socket = INVALID_SOCKET;
00232
00233             addrptr = addrptr->ai_next;
00234         }
00235         else
00236         {
00237             break;
00238         }
00239     }
00240
00241     freeaddrinfo(results);
00242     results = NULL;
00243
00244     // Make sure we got a connection established
00245     if (conn_socket == INVALID_SOCKET)
00246     {
00247         printf("Unable to establish connection...\n");
00248         goto cleanup;
00249     }
00250     else
00251     {
00252         printf("Connection established...\n");
00253     }
00254
00255     //
00256     // cook up a string to send
00257     //
00258     loopcount = 0;
00259     for (;;)
00260     {
00261         _snprintf(Buffer, DEFAULT_BUFFER_LEN-1,
00262                   "This is a small test message [number %d]",
00263                   loopcount++
00264                  );
00265
00266         // Send the data
00267         retval = send(conn_socket, Buffer, lstrlen(Buffer)+1, 0);
00268         if (retval == SOCKET_ERROR)
00269         {
00270             fprintf(stderr,"send failed: error %d\n", WSAGetLastError());
00271             goto cleanup;
00272         }
00273
00274         printf("wrote %d bytes\n", retval);
00275
00276         // Receive the data back
00277         retval = recv(conn_socket, Buffer, DEFAULT_BUFFER_LEN, 0);
00278         if (retval == SOCKET_ERROR)
00279         {
00280             fprintf(stderr, "recv failed: error %d\n", WSAGetLastError());
00281             goto cleanup;
00282         }
00283         //
00284         // We are not likely to see this with UDP, since there is no
00285         // 'connection' established.
00286         //
00287         if (retval == 0)
00288         {
00289             printf("Server closed connection\n");
00290
00291             break;
00292         }
00293
00294         printf("read %d bytes, data [%s] from server\n", retval, Buffer);
00295
00296         // See if we need to break out of the loop
00297         if (loopflag)
00298         {
00299             if ( (loopcount >= maxloop) && (maxloop > 0) )
00300                 break;
00301         }
00302         else
00303         {
00304             break;
00305         }
00306     }
00307
00308     cleanup:
00309
00310     //
00311     // clean up the client connection
00312     //
00313
00314     if (conn_socket != INVALID_SOCKET)
00315     {
00316         // Indicate no more data to send
00317         retval = shutdown(conn_socket, SD_SEND);
00318         if (retval == SOCKET_ERROR)
00319         {
00320             fprintf(stderr, "shutdown failed: %d\n", WSAGetLastError());
00321         }
00322
00323         // Close the socket
00324         retval = closesocket(conn_socket);
00325         if (retval == SOCKET_ERROR)
00326         {
00327             fprintf(stderr, "closesocket failed: %d\n", WSAGetLastError());
00328         }
00329
00330         conn_socket = INVALID_SOCKET;
00331     }
00332
00333     if (results != NULL)
00334     {
00335         freeaddrinfo(results);
00336         results = NULL;
00337     }
00338
00339     WSACleanup();
00340
00341     return 0;
00342 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Tbarext/about.Cpp Source File

  • SysMgmt
  • MMC
  • Tbarext

about.Cpp

Go to the documentation of this file.
00001
00002 //==============================================================;
00003 //
00004 //  This source code is only intended as a supplement to existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "About.h"
00021 #include "resource.h"
00022 #include "globals.h"
00023 #include <crtdbg.h>
00024
00025 CSnapinAbout::CSnapinAbout()
00026 : m_cref(0)
00027 {
00028     OBJECT_CREATED
00029
00030         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00031     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00032
00033     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00034
00035     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00036 }
00037
00038 CSnapinAbout::~CSnapinAbout()
00039 {
00040     if (m_hSmallImage != NULL)
00041         FreeResource(m_hSmallImage);
00042
00043     if (m_hLargeImage != NULL)
00044         FreeResource(m_hLargeImage);
00045
00046     if (m_hSmallImageOpen != NULL)
00047         FreeResource(m_hSmallImageOpen);
00048
00049     if (m_hAppIcon != NULL)
00050         FreeResource(m_hAppIcon);
00051
00052     m_hSmallImage = NULL;
00053     m_hLargeImage = NULL;
00054     m_hSmallImageOpen = NULL;
00055     m_hAppIcon = NULL;
00056
00057     OBJECT_DESTROYED
00058 }
00059
00060 ///////////////////////
00061 // IUnknown implementation
00062 ///////////////////////
00063
00064 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00065 {
00066     if (!ppv)
00067         return E_FAIL;
00068
00069     *ppv = NULL;
00070
00071     if (IsEqualIID(riid, IID_IUnknown))
00072         *ppv = static_cast<ISnapinAbout *>(this);
00073     else if (IsEqualIID(riid, IID_ISnapinAbout))
00074         *ppv = static_cast<ISnapinAbout *>(this);
00075
00076     if (*ppv)
00077     {
00078         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00079         return S_OK;
00080     }
00081
00082     return E_NOINTERFACE;
00083 }
00084
00085 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00086 {
00087     return InterlockedIncrement((LONG *)&m_cref);
00088 }
00089
00090 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00091 {
00092     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00093     {
00094         // we need to decrement our object count in the DLL
00095         delete this;
00096         return 0;
00097     }
00098     return m_cref;
00099
00100 }
00101
00102 ///////////////////////////////
00103 // Interface ISnapinAbout
00104 ///////////////////////////////
00105 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00106                                                 /* [out] */ LPOLESTR *lpDescription)
00107 {
00108     _TCHAR szDesc[MAX_PATH];
00109
00110     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00111
00112     return AllocOleStr(lpDescription, szDesc);
00113 }
00114
00115
00116 STDMETHODIMP CSnapinAbout::GetProvider(
00117                                        /* [out] */ LPOLESTR *lpName)
00118 {
00119     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00120 }
00121
00122
00123 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00124                                             /* [out] */ LPOLESTR *lpVersion)
00125 {
00126     return AllocOleStr(lpVersion, _T("1.0"));;
00127 }
00128
00129
00130 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00131                                           /* [out] */ HICON *hAppIcon)
00132 {
00133     *hAppIcon = m_hAppIcon;
00134
00135     if (*hAppIcon == NULL)
00136         return E_FAIL;
00137     else
00138         return S_OK;
00139 }
00140
00141
00142 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00143                                                 /* [out] */ HBITMAP *hSmallImage,
00144                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00145                                                 /* [out] */ HBITMAP *hLargeImage,
00146                                                 /* [out] */ COLORREF *cMask)
00147 {
00148     *hSmallImage = m_hSmallImage;
00149     *hLargeImage = m_hLargeImage;
00150
00151     *hSmallImageOpen = m_hSmallImageOpen;
00152
00153     *cMask = RGB(0, 128, 128);
00154
00155     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00156         return E_FAIL;
00157     else
00158         return S_OK;
00159 }
00160
00161 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00162 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00163 {
00164   MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00165   *lpDest = wszStr;
00166
00167     return S_OK;
00168 }
00169
00170
00171
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/Guid.h Source File

  • WinUI
  • Shell
  • BandObjs

Guid.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Guid.h
00013
00014    Description:   Private GUID definition.
00015
00016 **************************************************************************/
00017
00018 // {85E0B170-04FA-11d1-B7DA-00A0C90348D6}
00019 DEFINE_GUID(CLSID_SampleDeskBand,
00020 0x85e0b170, 0x4fa, 0x11d1, 0xb7, 0xda, 0x0, 0xa0, 0xc9, 0x3, 0x48, 0xd6);
00021
00022 // {85E0B171-04FA-11d1-B7DA-00A0C90348D6}
00023 DEFINE_GUID(CLSID_SampleExplorerBar,
00024 0x85e0b171, 0x4fa, 0x11d1, 0xb7, 0xda, 0x0, 0xa0, 0xc9, 0x3, 0x48, 0xd6);
00025
00026 // {85E0B172-04FA-11d1-B7DA-00A0C90348D6}
00027 DEFINE_GUID(CLSID_SampleCommBand,
00028 0x85e0b172, 0x4fa, 0x11d1, 0xb7, 0xda, 0x0, 0xa0, 0xc9, 0x3, 0x48, 0xd6);
00029
00030 // {85E0B173-04FA-11d1-B7DA-00A0C90348D6}
00031 DEFINE_GUID(CLSID_SampleToolBand,
00032 0x85e0b173, 0x4fa, 0x11d1, 0xb7, 0xda, 0x0, 0xa0, 0xc9, 0x3, 0x48, 0xd6);
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyCapabilities/StdAfx.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyCapabilities

StdAfx.cpp

Go to the documentation of this file.
00001 //
00002 //  stdafx.cpp : source file that includes just the standard includes
00003 //  stdafx.pch will be the pre-compiled header
00004 //  stdafx.obj will contain the pre-compiled type information
00005 //
00006
00007 #include "stdafx.h"
00008
00009 #ifdef _ATL_STATIC_REGISTRY
00010 #include <statreg.h>
00011 #endif
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/NewsEventClass/newseventclass.Cpp Source File

  • Com
  • Services
  • Events
  • EventNews
  • NewsEventClass

newseventclass.Cpp

Go to the documentation of this file.
00001 // NewsEventClass.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f NewsEventClassps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "NewsEventClass.h"
00012
00013 #include "NewsEventClass_i.c"
00014 #include "NewsEvent.h"
00015
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP(ObjectMap)
00020 OBJECT_ENTRY(CLSID_NewsEvent, CNewsEvent)
00021 END_OBJECT_MAP()
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // DLL Entry Point
00025
00026 extern "C"
00027 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00028 {
00029     if (dwReason == DLL_PROCESS_ATTACH)
00030     {
00031         _Module.Init(ObjectMap, hInstance, &LIBID_NEWSEVENTCLASSLib);
00032         DisableThreadLibraryCalls(hInstance);
00033     }
00034     else if (dwReason == DLL_PROCESS_DETACH)
00035         _Module.Term();
00036     return TRUE;    // ok
00037 }
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // Used to determine whether the DLL can be unloaded by OLE
00041
00042 STDAPI DllCanUnloadNow(void)
00043 {
00044     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00045 }
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 // Returns a class factory to create an object of the requested type
00049
00050 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00051 {
00052     return _Module.GetClassObject(rclsid, riid, ppv);
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // DllRegisterServer - Adds entries to the system registry
00057
00058 STDAPI DllRegisterServer(void)
00059 {
00060     // registers object, typelib and all interfaces in typelib
00061     return _Module.RegisterServer(TRUE);
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // DllUnregisterServer - Removes entries from the system registry
00066
00067 STDAPI DllUnregisterServer(void)
00068 {
00069     return _Module.UnregisterServer(TRUE);
00070 }
00071
00072
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDimmerService Member List

This is the complete list of members for CDimmerService, including all inherited members.
Advise(IUPnPEventSink *pesSubscriber) | CDimmerService | [inline]
Advise(IUPnPEventSink *pesSubscriber) | CDimmerService | [inline]
Advise(IUPnPEventSink *punkSubscriber) | CDimmerService |
CDimmerService() | CDimmerService | [inline]
CDimmerService() | CDimmerService | [inline]
CDimmerService() | CDimmerService |
csSync | CDimmerService | [private]
dimnessLevel | CDimmerService | [private]
esEventingManager | CDimmerService | [private]
get_dimLevel(LONG *pdimLevel) | CDimmerService | [inline]
get_dimLevel(LONG *dLevel) | CDimmerService |
get_Power(VARIANT_BOOL *pPower) | CDimmerService | [inline]
get_Power(VARIANT_BOOL *pval) | CDimmerService |
GetConfigDetails(VARIANT_BOOL *ppowerVal, LONG *pdLevel) | CDimmerService | [inline]
GetConfigDetails(VARIANT_BOOL *powerVal, LONG *dLevel) | CDimmerService |
GetDimLevel(LONG *pdLevel) | CDimmerService | [inline]
GetDimLevel(LONG *dLevel) | CDimmerService |
GetPowerValue(VARIANT_BOOL *ppowerVall) | CDimmerService | [inline]
GetPowerValue(VARIANT_BOOL *powerVal) | CDimmerService |
power | CDimmerService | [private]
PowerOff() | CDimmerService | [inline]
PowerOff() | CDimmerService |
PowerOn() | CDimmerService | [inline]
PowerOn() | CDimmerService |
SetDimLevel(LONG dLevel) | CDimmerService | [inline]
SetDimLevel(LONG dLevel) | CDimmerService |
Unadvise(IUPnPEventSink *pesSubscriber) | CDimmerService | [inline]
Unadvise(IUPnPEventSink *pesSubscriber) | CDimmerService | [inline]
Unadvise(IUPnPEventSink *punkSubscriber) | CDimmerService |
~CDimmerService() | CDimmerService |
Generated on Wed Nov 13 2024 16:56:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Simple/Resource.h Source File

  • Web
  • iis
  • Components
  • Cpp
  • Simple

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by CATLSmpl.rc
00004 //
00005 #define IDS_SIMPLE_DESC 1
00006
00007
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           101
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/compdata.h Source File

  • SysMgmt
  • MMC
  • Openserv

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData,
00028 IExtendPropertySheet2,  // 2 for wizard
00029 IPersistStream
00030
00031 {
00032     friend class CComponent;
00033
00034 private:
00035     ULONG       m_cref;
00036     LPCONSOLE     m_ipConsole;
00037     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00038
00039     CStaticNode     *m_pStaticNode;
00040
00041 public:
00042     CComponentData();
00043     ~CComponentData();
00044
00045     ///////////////////////////////
00046     // Interface IUnknown
00047     ///////////////////////////////
00048     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00049     STDMETHODIMP_(ULONG) AddRef();
00050     STDMETHODIMP_(ULONG) Release();
00051
00052     ///////////////////////////////
00053     // Interface IComponentData
00054     ///////////////////////////////
00055     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00056         /* [in] */ LPUNKNOWN pUnknown);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00059         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00060
00061         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00062         /* [in] */ LPDATAOBJECT lpDataObject,
00063         /* [in] */ MMC_NOTIFY_TYPE event,
00064         /* [in] */ LPARAM arg,
00065         /* [in] */ LPARAM param);
00066
00067         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00068
00069     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00070         /* [in] */ MMC_COOKIE cookie,
00071         /* [in] */ DATA_OBJECT_TYPES type,
00072         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00075         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00076
00077         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00078         /* [in] */ LPDATAOBJECT lpDataObjectA,
00079         /* [in] */ LPDATAOBJECT lpDataObjectB);
00080
00081         //////////////////////////////////
00082         // Interface IExtendPropertySheet2
00083         //////////////////////////////////
00084         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreatePropertyPages(
00085         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00086         /* [in] */ LONG_PTR handle,
00087         /* [in] */ LPDATAOBJECT lpIDataObject);
00088
00089         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryPagesFor(
00090         /* [in] */ LPDATAOBJECT lpDataObject);
00091
00092         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetWatermarks(
00093         /* [in] */ LPDATAOBJECT lpIDataObject,
00094         /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00095         /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00096         /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00097         /* [out] */ BOOL __RPC_FAR *bStretch);
00098
00099         ///////////////////////////////
00100         // Interface IPersistStream
00101         ///////////////////////////////
00102         virtual HRESULT STDMETHODCALLTYPE GetClassID(
00103         /* [out] */ CLSID __RPC_FAR *pClassID);
00104
00105         virtual HRESULT STDMETHODCALLTYPE IsDirty( void);
00106
00107     virtual HRESULT STDMETHODCALLTYPE Load(
00108         /* [unique][in] */ IStream __RPC_FAR *pStm);
00109
00110         virtual HRESULT STDMETHODCALLTYPE Save(
00111         /* [unique][in] */ IStream __RPC_FAR *pStm,
00112         /* [in] */ BOOL fClearDirty);
00113
00114         virtual HRESULT STDMETHODCALLTYPE GetSizeMax(
00115         /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbSize);
00116 };
00117
00118 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/devicenode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

devicenode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CDeviceNode class.
00014 //
00015
00016
00017 #include "DeviceNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CDeviceNode")
00024
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CDeviceNode::thisGUID = CLSID_DeviceNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 CDeviceNode::CDeviceNode()
00035 {
00036   m_SDI.mask        = DEFAULT_SDI_MASK;
00037   m_SDI.displayname = MMC_CALLBACK;
00038   m_SDI.cChildren   = 1;              // Determines if the '+' is displayed
00039   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00040
00041   m_hParentNode     = NULL;
00042   m_dwAttributes    = 0;
00043   m_wzStatus        = NULL;
00044   m_pCompData       = NULL;
00045 }
00046
00047
00048 CDeviceNode::~CDeviceNode()
00049 {
00050 }
00051
00052 //---------------------------------------------------------------------------
00053 HRESULT CDeviceNode::Initialize( NODE_PROPERTIES* pNodeProps )
00054 {
00055   _ASSERT( NULL != pNodeProps );
00056   _ASSERT( NULL != pNodeProps->pComponentData );
00057
00058   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00059   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00060   wcscpy( pszTmp, pNodeProps->szNodeName );
00061   if( NULL != m_pwszNodeName )
00062     CoTaskMemFree( m_pwszNodeName );
00063
00064   m_pwszNodeName = pszTmp;
00065   m_pCompData = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00066
00067   RefreshNodeList();                   // Add child nodes
00068                                        // and set images
00069
00070   if( pNodeProps->dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00071   {
00072     m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00073     m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00074     m_dwAttributes   |= ATTRIBUTE_BACKUP_DEVICE;
00075   }
00076   else
00077   {
00078     m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00079     m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00080     m_dwAttributes   |= ~ATTRIBUTE_BACKUP_DEVICE;
00081   }
00082
00083   m_wzStatus      = L"Online";    // Node successfully initialized
00084   m_bOnlineStatus = STATUS_ONLINE;
00085
00086   return S_OK;
00087 }
00088
00089
00090 /////////////////////////////////////////////////////////////////////////////
00091 // Implementation of virtual methods
00092
00093
00094 //---------------------------------------------------------------------------
00095 HRESULT CDeviceNode::GetResultViewType2
00096 (
00097   MMC_COOKIE             nCookie,  //[in] Identifier of object
00098   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00099 )
00100 {
00101   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00102   if( NULL == pszDescStr )
00103     return E_OUTOFMEMORY;
00104
00105   wcscpy( pszDescStr, L"DefaultListView" );
00106   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00107
00108   return S_OK;
00109 }
00110
00111 //---------------------------------------------------------------------------
00112 HRESULT CDeviceNode::GetDisplayInfo
00113 (
00114   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00115 )
00116 {
00117   _ASSERT( NULL != pSDI );
00118   pSDI->displayname = m_pwszNodeName;
00119
00120   return S_OK;
00121 }
00122
00123 //---------------------------------------------------------------------------
00124 HRESULT CDeviceNode::GetDisplayInfo
00125 (
00126   RESULTDATAITEM* pRDI
00127 )
00128 {
00129   _ASSERT( NULL != pRDI );
00130
00131   HRESULT hResult = S_OK;
00132
00133   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00134   {                                  // for each column
00135     switch( pRDI->nCol )
00136     {
00137       case 0:
00138         pRDI->str = m_pwszNodeName;
00139         break;
00140
00141       case 1:                        // Attributes not supported yet
00142         pRDI->str = m_wzStatus;
00143         break;
00144
00145       default:
00146         hResult = S_FALSE;
00147         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00148         break;
00149     }
00150   }
00151   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00152   {
00153     pRDI->nImage = m_SDI.nImage;
00154   }
00155
00156   //TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00157   return hResult;
00158
00159 }
00160
00161 /////////////////////////////////////////////////////////////////////////////
00162 // Implementation of notification handlers
00163
00164
00165 //---------------------------------------------------------------------------
00166 HRESULT CDeviceNode::OnSelect
00167 (
00168   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00169   LONG          nArg,          //[in] Bools for context & selection state
00170   LONG          nParam,        //[in] Not used
00171   LONG_PTR      pComponent     //[in] Points calling CComponent
00172 )
00173 {
00174   HRESULT hResult = S_FALSE;
00175
00176   // Not setting verbs for this node
00177
00178   TRACE_HRESULT(_T("OnSelect"), hResult );
00179   return hResult;
00180 }
00181
00182
00183 //---------------------------------------------------------------------------
00184 HRESULT CDeviceNode::OnShow
00185 (
00186   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00187   LONG          nArg,          //[in] TRUE if node was selcted
00188   LONG          nParam,        //[in] HSCOPEITEM of selected/deselected item
00189   LONG_PTR      pComponent     //[in] Points to calling IComponent
00190 )
00191 {
00192   HRESULT  hResult = S_FALSE;
00193
00194   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00195
00196   LPHEADERCTRL2  ipHeaderCtrl = NULL;
00197   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL, (LONG_PTR*)&ipHeaderCtrl );
00198   if( S_OK != hResult )
00199    return hResult;
00200
00201   LPRESULTDATA  ipResultData = NULL;
00202   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00203   if( S_OK != hResult )
00204    return hResult;
00205
00206   if( TRUE == nArg )         // Selecting a scope node
00207   {
00208     do
00209     {
00210       hResult = ipHeaderCtrl->InsertColumn( 0, L"Folder Name", 0, 150 );
00211       BREAK_ON_ERROR( hResult );
00212
00213       hResult = ipHeaderCtrl->InsertColumn( 1, L"Attributes", 0, 150 );
00214       BREAK_ON_ERROR( hResult );
00215
00216       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00217       BREAK_ON_ERROR( hResult );
00218
00219     }while(0);
00220   }
00221   else                       // Not handling deselect notification
00222   {
00223   }
00224
00225   TRACE_HRESULT(_T("OnShow"), hResult );
00226   return hResult;
00227 }
00228
00229 //---------------------------------------------------------------------------
00230 HRESULT CDeviceNode::OnExpand
00231 (
00232   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00233   LONG           nArg,         //[in] TRUE if node was selcted
00234   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00235   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00236 )
00237 {
00238   HRESULT hResult = S_FALSE;
00239
00240   // Cache HSCOPEITEM of Parent
00241   m_hParentNode = static_cast<HSCOPEITEM>(nParam);
00242
00243   if( NULL == m_pCompData )
00244     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00245
00246   // Request an IConsoleNameSpace2 pointer from CComponentData
00247   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00248   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00249   if( S_OK != hResult )
00250     return hResult;
00251
00252
00253   hResult = DeleteChildItems( ipCNS2 );
00254   hResult = InsertChildItems( ipCNS2 );
00255
00256   //TRACE_HRESULT( _T("OnExpand"), hResult );
00257   return hResult;
00258 }
00259
00260
00261 //---------------------------------------------------------------------------
00262 HRESULT CDeviceNode::OnRemoveChildren
00263 (
00264   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00265   LONG           nArg,         //[in] TRUE if node was selcted
00266   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00267   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00268 )
00269 {
00270   HRESULT hResult = S_FALSE;
00271
00272   if( NULL == m_pCompData )
00273     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00274
00275   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00276   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00277   if( S_OK != hResult )
00278     return hResult;
00279
00280                                        // Deletes HSCOPEITEMS only...
00281   hResult = DeleteChildItems( ipCNS2 );
00282
00283   POSITION   Pos   = m_NodeList.GetHeadPosition();
00284   LPBASENODE pNode = NULL;
00285   while( Pos )                         // Delete everything...
00286   {
00287     pNode = m_NodeList.GetNext( Pos );
00288     pNode->OnRemoveChildren( ipDataObject, nArg, nParam, pCompData );
00289     delete pNode;
00290   }
00291
00292   m_NodeList.RemoveAll();            // Cleans up the list
00293
00294   //TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00295   return hResult;
00296
00297 }
00298
00299
00300 /////////////////////////////////////////////////////////////////////////////
00301 //  Private Helpers
00302
00303 //---------------------------------------------------------------------------
00304 HRESULT CDeviceNode::DeleteChildItems
00305 (
00306   LPCONSOLENAMESPACE2 ipCNS2
00307 )
00308 {
00309   _ASSERT( NULL != ipCNS2 );
00310
00311   POSITION    Pos     = m_NodeList.GetHeadPosition();
00312   HSCOPEITEM  hItem   = NULL;
00313   LPBASENODE  pNode   = NULL;
00314   HRESULT     hResult = S_FALSE;
00315
00316   while( Pos )                         // Delete everything...
00317   {
00318     pNode = m_NodeList.GetNext( Pos );
00319     hItem = (HSCOPEITEM)pNode->m_SDI.ID;
00320     if( 0 != hItem )
00321       hResult = ipCNS2->DeleteItem( hItem, TRUE );
00322   }
00323
00324   return hResult;
00325 }
00326
00327
00328 //---------------------------------------------------------------------------
00329 HRESULT CDeviceNode::InsertChildItems
00330 (
00331   LPCONSOLENAMESPACE2 ipCNS2
00332 )
00333 {
00334   _ASSERT( NULL != ipCNS2 );
00335   _ASSERT( NULL != m_hParentNode );
00336
00337   HRESULT    hResult = S_FALSE;
00338   POSITION   Pos     = m_NodeList.GetHeadPosition();
00339   LPBASENODE pNode   = NULL;
00340
00341   while( Pos )
00342   {
00343     pNode   = m_NodeList.GetNext( Pos );
00344     pNode->m_SDI.relativeID = m_hParentNode;
00345     hResult = ipCNS2->InsertItem( &pNode->m_SDI );
00346   }
00347
00348   return hResult;
00349 }
00350
00351
00352 //---------------------------------------------------------------------------
00353 //  Only add one child node in this sample
00354 //
00355 HRESULT CDeviceNode::RefreshNodeList()
00356 {
00357   NODE_PROPERTIES NodeProps;
00358   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00359   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00360   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00361
00362   WCHAR  szNames[1][32];
00363   wcscpy( szNames[0], L"Root Folder" );
00364
00365   RemoveNodes();             // Clean the node list
00366
00367   LPBASENODE pNode = NULL;
00368   for( DWORD i = 0; i < 1; i++ )
00369   {
00370     wcscpy( NodeProps.szNodeName, szNames[i] );
00371     pNode = new CFolderNode;
00372     pNode->Initialize( &NodeProps );
00373     m_NodeList.AddTail( pNode );
00374   }
00375
00376   return S_OK;
00377 }
00378
00379 //---------------------------------------------------------------------------
00380 //  We do this instead of just calling RemoveAll() because our list contains
00381 //  CBaseNode pointers and so RemoveAll() does not call the destructor for
00382 //  the derived class object.
00383 //
00384 VOID CDeviceNode::RemoveNodes()
00385 {
00386   LPBASENODE pNode = NULL;
00387   POSITION   Pos   = m_NodeList.GetHeadPosition();
00388   while( Pos )
00389   {
00390     pNode = m_NodeList.GetNext( Pos );
00391     delete pNode;
00392   }
00393   m_NodeList.RemoveAll();              // Clean the list
00394 }
00395
00396 /////////////////////////////////////////////////////////////////////////////
00397 //  Public helpers
00398
00399 //---------------------------------------------------------------------------
00400 VOID CDeviceNode::ToggleStatus()
00401 {
00402   // First we have to set the image indexes according to the Online Status
00403   // and the device type
00404   //
00405   if( STATUS_ONLINE == m_bOnlineStatus )
00406   {
00407     m_bOnlineStatus = STATUS_OFFLINE;
00408     m_wzStatus      = L"Offline";
00409     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00410     {
00411       m_SDI.nImage      = IMG_DEVICE_OFFLINE;
00412       m_SDI.nOpenImage  = IMG_DEVICE_OFFLINE;
00413     }
00414     else
00415     {
00416       m_SDI.nImage      = IMG_DRIVE_OFFLINE;
00417       m_SDI.nOpenImage  = IMG_DRIVE_OFFLINE;
00418     }
00419   }
00420   else
00421   {
00422     m_bOnlineStatus = STATUS_ONLINE;
00423     m_wzStatus      = L"Online";
00424     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00425     {
00426       m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00427       m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00428     }
00429     else
00430     {
00431       m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00432       m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00433     }
00434   }
00435   // This is a scope node, so GetDisplayInfo will only ask for images for
00436   // this node when it is in the Result Pane.  To change the image for the
00437   // the Scope Pane we need to call IConsoleNameSpace2::SetItem().  This
00438   // call forces the scope node to be redrawn.
00439   //
00440   SCOPEDATAITEM  sdi;
00441   ZeroMemory( &sdi, sizeof(SCOPEDATAITEM) );
00442   sdi.mask        = SDI_IMAGE | SDI_OPENIMAGE ;
00443   sdi.ID          = m_SDI.ID;
00444   sdi.nImage      = m_SDI.nImage;
00445   sdi.nOpenImage  = m_SDI.nOpenImage;
00446
00447   // Request an IConsoleNameSpace2 pointer from CComponentData
00448   HRESULT  hResult = S_FALSE;
00449   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00450   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG*)&ipCNS2 );
00451   if( S_OK == hResult )
00452     hResult = ipCNS2->SetItem( &sdi );
00453
00454 }
00455
00456
00457 /////////////////////////////////////////////////////////////////////////////
00458 //  Support for Context Menus
00459
00460 //---------------------------------------------------------------------------
00461 //  Devices can only add a folder
00462 //
00463 HRESULT CDeviceNode::AddMenuItems
00464 (
00465   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00466   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00467 )
00468 {
00469   _ASSERT( NULL != ipCallback );
00470   HRESULT hResult = S_FALSE;
00471
00472   static CONTEXTMENUITEM ctxMenu[2];
00473     ctxMenu[0].lCommandID        = IDM_NEW_FOLDER;
00474     ctxMenu[0].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00475     ctxMenu[0].fFlags            = MF_GRAYED;
00476     ctxMenu[0].fSpecialFlags     = 0;
00477     ctxMenu[0].strName           = L"New Folder...";
00478     ctxMenu[0].strStatusBarText  = L"Add a new folder";
00479
00480     ctxMenu[1].lCommandID        = IDM_TOGGLE_STATUS;
00481     ctxMenu[1].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
00482     ctxMenu[1].fFlags            = 0;
00483     ctxMenu[1].fSpecialFlags     = 0;
00484     ctxMenu[1].strName           = L"Toggle Online Status";
00485     ctxMenu[1].strStatusBarText  = L"Toggles the device status";
00486
00487
00488   // Add the Add new folder command
00489   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00490   {
00491     hResult = ipCallback->AddItem( &ctxMenu[0] );
00492   }
00493
00494   // Add the Toggle item to the Task menu if allowed...
00495   if( CCM_INSERTIONALLOWED_TOP & *pInsertionAllowed )
00496   {
00497     hResult = ipCallback->AddItem( &ctxMenu[1] );
00498   }
00499
00500   return hResult;
00501 }
00502
00503 //---------------------------------------------------------------------------
00504 HRESULT CDeviceNode::Command
00505 (
00506   long lCommandID          //[in] Indentifier for menu ID
00507 )
00508 {
00509   HRESULT hResult = S_OK;
00510
00511   switch( lCommandID )
00512   {
00513     case IDM_TOGGLE_STATUS:
00514     {
00515       ToggleStatus();
00516       break;
00517     }
00518     case IDM_NEW_FOLDER:
00519     {
00520       // Not handling this command in this sample
00521       break;
00522     }
00523     default:
00524       hResult = S_FALSE;
00525       break;
00526
00527   }
00528   return hResult;
00529 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenuex/contextmenuex.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenuex

contextmenuex.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCONTEXTMENUX_
00016 #define _CLASS_CCONTEXTMENUX_
00017
00018
00019 #include "Globals.h"
00020
00021 //---------------------------------------------------------------------------
00022 class CExtendContextMenuEx : public IExtendContextMenu
00023 {
00024   private:
00025     ULONG          m_cRef;
00026
00027   public:
00028     CExtendContextMenuEx();
00029     ~CExtendContextMenuEx();
00030
00031   ///////////////////////////////////////////////////////////////////////////
00032   // Interface IUnknown
00033   public:
00034     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00035     STDMETHODIMP_(ULONG) AddRef();
00036     STDMETHODIMP_(ULONG) Release();
00037
00038
00039     /////////////////////////////////////////////////////////////////////////
00040     // Interface IExtendContextMenu
00041     //
00042     HRESULT STDMETHODCALLTYPE AddMenuItems
00043             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00044               /*[in]*/ LPCONTEXTMENUCALLBACK ipCallback,
00045               /*[out,in]*/ long __RPC_FAR* pInsertionAllowed
00046             );
00047
00048     HRESULT STDMETHODCALLTYPE Command
00049             ( /*[in]*/ long lCommandID,
00050               /*[in]*/ LPDATAOBJECT piDataObject
00051             );
00052
00053   private:
00054
00055 };
00056
00057 #endif //_CLASS_CCONTEXTMENUX_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Serialization::SerializationForm Member List

This is the complete list of members for Serialization::SerializationForm, including all inherited members.
components | Serialization::SerializationForm | [private]
Dispose(bool disposing) | Serialization::SerializationForm | [inline, protected]
ExitMenu | Serialization::SerializationForm | [private]
ExitMenu_Click(object sender, System.EventArgs e) | Serialization::SerializationForm | [inline, private]
FileMenu | Serialization::SerializationForm | [private]
FirstName | Serialization::SerializationForm | [private]
FirstNameBox | Serialization::SerializationForm | [private]
FirstNameLabel | Serialization::SerializationForm | [private]
ic | Serialization::SerializationForm | [private]
InitializeComponent() | Serialization::SerializationForm | [inline, private]
LastName | Serialization::SerializationForm | [private]
LastNameBox | Serialization::SerializationForm | [private]
LastNameLabel | Serialization::SerializationForm | [private]
LoadISF(Stream s) | Serialization::SerializationForm | [inline, private]
LoadXML(Stream s) | Serialization::SerializationForm | [inline, private]
Main() | Serialization::SerializationForm | [inline, private, static]
MenuBar | Serialization::SerializationForm | [private]
NewMenu | Serialization::SerializationForm | [private]
NewMenu_Click(object sender, System.EventArgs e) | Serialization::SerializationForm | [inline, private]
OpenMenu | Serialization::SerializationForm | [private]
OpenMenu_Click(object sender, System.EventArgs e) | Serialization::SerializationForm | [inline, private]
SaveAsMenu | Serialization::SerializationForm | [private]
SaveAsMenu_Click(object sender, System.EventArgs e) | Serialization::SerializationForm | [inline, private]
SaveHTML(Stream s, String nameBase) | Serialization::SerializationForm | [inline, private]
SaveISF(Stream s) | Serialization::SerializationForm | [inline, private]
SaveXML(Stream s) | Serialization::SerializationForm | [inline, private]
SeperatorMenu | Serialization::SerializationForm | [private]
SerializationForm() | Serialization::SerializationForm | [inline]
Signature | Serialization::SerializationForm | [private]
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/HelpDll/stdafx.Cpp Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • HelpDll

stdafx.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 // stdafx.cpp : source file that includes just the standard includes
00019 //  HelpDll.pch will be the pre-compiled header
00020 //  stdafx.obj will contain the pre-compiled type information
00021
00022 #include "stdafx.h"
00023
00024 // TODO: reference any additional headers you need in STDAFX.H
00025 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IComSpy Member List

This is the complete list of members for IComSpy, including all inherited members.
About() | IComSpy
Audit([out, retval] BOOL *pVal) | IComSpy
Audit([in] BOOL newVal) | IComSpy
ChooseFont() | IComSpy
ChooseLogFile([out] BSTR *sLogFileName,[out] BOOL *bCanceled) | IComSpy
ClearAllEvents() | IComSpy
ColWidth(short nColumn,[out, retval] long *pVal) | IComSpy
ColWidth(short nColumn,[in] long newVal) | IComSpy
Font([in]IFontDisp *pFont) | IComSpy
Font([in]IFontDisp *pFont) | IComSpy
Font([out, retval]IFontDisp **ppFont) | IComSpy
LogFile([out, retval] BSTR *pVal) | IComSpy
LogFile([in] BSTR newVal) | IComSpy
LogToFile([out, retval] BOOL *pVal) | IComSpy
LogToFile([in] BOOL newVal) | IComSpy
SaveToFile() | IComSpy
SelectApplications() | IComSpy
ShowGridLines([out, retval] BOOL *pVal) | IComSpy
ShowGridLines([in] BOOL newVal) | IComSpy
ShowOnScreen([out, retval] BOOL *pVal) | IComSpy
ShowOnScreen([in] BOOL newVal) | IComSpy
Window([out, retval]LONG_PTR *phwnd) | IComSpy
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/http/serviceconfig/precomp.h Source File

  • NetDS
  • http
  • serviceconfig

precomp.h

Go to the documentation of this file.
00001 /*++
00002  Copyright (c) 2002 - 2002 Microsoft Corporation.  All Rights Reserved.
00003
00004  THIS CODE AND INFORMATION IS PROVIDED "AS-IS" WITHOUT WARRANTY OF
00005  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00006  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00007  PARTICULAR PURPOSE.
00008
00009  THIS CODE IS NOT SUPPORTED BY MICROSOFT.
00010
00011 --*/
00012
00013 #ifndef _PRECOMP_H_
00014 #define _PRECOMP_H_
00015
00016 #include    <nt.h>
00017 #include    <ntrtl.h>
00018 #include    <nturtl.h>
00019 #define NOGDI
00020 #define NOMINMAX
00021 #include    <windows.h>
00022 #include    <stdio.h>
00023 #include    <stdlib.h>
00024 #include    <ctype.h>
00025 #include    <io.h>
00026 #include    <winsock2.h>
00027 #include    <ws2tcpip.h>
00028 #include    <ntddip6.h>
00029 #include    <objbase.h>
00030 #include    <wtypes.h>
00031 #include    "http.h"
00032 #include    "nlstxt.h"
00033
00034
00035
00036 typedef enum _HTTPCFG_TYPE
00037 {
00038     HttpCfgTypeSet,
00039     HttpCfgTypeQuery,
00040     HttpCfgTypeDelete,
00041     HttpCfgTypeMax
00042
00043 } HTTPCFG_TYPE, *PHTTPCFG_TYPE;
00044
00045 int DoSsl(
00046     int          argc,
00047     WCHAR        **argv,
00048     HTTPCFG_TYPE Type
00049     );
00050
00051 int DoUrlAcl(
00052     int          argc,
00053     WCHAR        **argv,
00054     HTTPCFG_TYPE Type
00055     );
00056
00057 int DoIpListen(
00058     int          argc,
00059     WCHAR        **argv,
00060     HTTPCFG_TYPE Type
00061     );
00062
00063 DWORD
00064 GetAddress(
00065     PWCHAR  pIp,
00066     PVOID   pBuffer,
00067     ULONG   Length
00068     );
00069
00070 UINT
00071 NlsPutMsg (
00072     IN UINT MsgNumber,
00073     IN ...
00074     );
00075
00076
00077 #endif  // _PRECOMP_H_
00078
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RU_SOCKET_CREATE_DATA Member List

This is the complete list of members for _RU_SOCKET_CREATE_DATA, including all inherited members.
pszDest | _RU_SOCKET_CREATE_DATA
pszSrc | _RU_SOCKET_CREATE_DATA
uiPort | _RU_SOCKET_CREATE_DATA
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CNullModem Member List

This is the complete list of members for CNullModem, including all inherited members.
CNullModem(void) | CNullModem |
DoConnect(void) | CNullModem | [private]
DropCall(void) | CNullModem | [private]
GetCommLink(void) | CNullModem | [inline]
m_DefaultTimeouts | CNullModem | [private]
m_dwEventMask | CNullModem | [private]
m_fCommPortInUse | CNullModem | [private]
m_fInitialized | CNullModem | [private]
m_hevtOverlapped | CNullModem | [private]
m_Line | CNullModem | [private]
m_nConnectionID | CNullModem | [private]
m_nTransportID | CNullModem | [private]
m_Overlapped | CNullModem | [private]
SetBuffers(void) | CNullModem | [private]
SetComPortState(void) | CNullModem | [private]
SetConnectedPort(void) | CNullModem | [private]
SetTimeouts(void) | CNullModem | [private]
TPhysConnectRequest(LPTSTR pszComPort) | CNullModem |
TPhysDisconnect(void) | CNullModem |
TPhysInitialize(UINT transport_id) | CNullModem |
TPhysTerminate(void) | CNullModem |
WaitForConnection(void) | CNullModem | [private]
~CNullModem(void) | CNullModem |
Generated on Wed Nov 13 2024 16:56:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPlgTermSample Member List

This is the complete list of members for CPlgTermSample, including all inherited members.
AddFiltersToGraph() | CPlgTermSample | [virtual]
CPlgTermSample() | CPlgTermSample |
CreateFilter() | CPlgTermSample | [private]
FinalConstruct(void) | CPlgTermSample | [virtual]
FindPin() | CPlgTermSample | [private]
FireEvent(long lEventCode) | CPlgTermSample |
GetInterfaceSafetyOptions(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) | CPlgTermSample |
GetSupportedMediaTypes() | CPlgTermSample | [virtual]
InitializeDynamic(IN IID iidTerminalClass, IN DWORD dwMediaType, IN TERMINAL_DIRECTION Direction, IN MSP_HANDLE htAddress) | CPlgTermSample | [virtual]
m_bKnownSafeContext | CPlgTermSample | [private]
m_pEventSink | CPlgTermSample | [private]
m_pFTM | CPlgTermSample | [private]
RegisterSink(IN ITPluggableTerminalEventSink *pSink) | CPlgTermSample |
SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions) | CPlgTermSample |
SetTerminalInfo() | CPlgTermSample | [private]
UnregisterSink() | CPlgTermSample |
~CPlgTermSample() | CPlgTermSample | [virtual]
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/c_draw/LoginDlg.Cpp Source File

  • NetDS
  • MessageQueuing
  • c_draw

LoginDlg.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // logindlg.cpp : implementation file
00013 //
00014 //
00015
00016
00017 #include "stdafx.h"
00018 #include "disdraw.h"
00019 #include "logindlg.h"
00020
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // CLoginDlg dialog
00029
00030
00031 CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
00032   : CDialog(CLoginDlg::IDD, pParent)
00033 {
00034   //{{AFX_DATA_INIT(CLoginDlg)
00035   m_strLogin = _T("");
00036   //}}AFX_DATA_INIT
00037 }
00038
00039
00040 void CLoginDlg::DoDataExchange(CDataExchange* pDX)
00041 {
00042   CDialog::DoDataExchange(pDX);
00043   //{{AFX_DATA_MAP(CLoginDlg)
00044   DDX_Text(pDX, IDC_EDIT_LOGIN, m_strLogin);
00045   //}}AFX_DATA_MAP
00046 }
00047
00048
00049 BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
00050   //{{AFX_MSG_MAP(CLoginDlg)
00051     // NOTE: the ClassWizard will add message map macros here
00052   //}}AFX_MSG_MAP
00053 END_MESSAGE_MAP()
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // CLoginDlg message handlers
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/SecurObj/Privobji.Cpp Source File

  • Security
  • Authorization
  • SecurObj

Privobji.Cpp

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1997 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009    Module Name:
00010
00011        PrivObSI.CPP
00012
00013
00014    Description:
00015
00016        This file contains the implementation of the CPrivSecurity class
00017
00018 --*/
00019
00020 #define UNICODE
00021 #define _UNICODE
00022
00023 #include <aclui.h>
00024 #include "resource.h"
00025 #include "Main.h"
00026
00027 //
00028 // from Main.cpp
00029 //
00030 extern HINSTANCE g_hInstance;
00031
00032 //
00033 // defined in Security.cpp
00034 //
00035 extern GENERIC_MAPPING ObjMap;
00036 HANDLE GetClientToken( WORD wIndex );
00037
00038
00039 #define INHERIT_FULL            (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE)
00040
00041 //
00042 // DESCRIPTION OF ACCESS FLAG AFFECTS
00043 //
00044 // SI_ACCESS_GENERAL shows up on general properties page
00045 // SI_ACCESS_SPECIFIC shows up on advanced page
00046 // SI_ACCESS_CONTAINER shows on general page IF object is a container
00047 //
00048 // The following array defines the permission names for my objects.
00049 //
00050 SI_ACCESS g_siObjAccesses[] =
00051 {
00052     { &GUID_NULL, ACCESS_READ,      MAKEINTRESOURCE(IDS_PRIV_READ),      SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC },
00053     { &GUID_NULL, ACCESS_MODIFY,    MAKEINTRESOURCE(IDS_PRIV_MODIFY),    SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC },
00054     { &GUID_NULL, ACCESS_DELETE,    MAKEINTRESOURCE(IDS_PRIV_DELETE),    SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC },
00055     { &GUID_NULL, ACCESS_ALL,       MAKEINTRESOURCE(IDS_PRIV_ALL),       SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC },
00056 };
00057
00058 #define g_iObjDefAccess    1   // ACCESS_READ
00059
00060 // The following array defines the inheritance types for my containers.
00061 SI_INHERIT_TYPE g_siObjInheritTypes[] =
00062 {
00063     &GUID_NULL, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE,   MAKEINTRESOURCE(IDS_INH_ALL),
00064     &GUID_NULL, CONTAINER_INHERIT_ACE,                        MAKEINTRESOURCE(IDS_INH_CONTAINER),
00065     &GUID_NULL, INHERIT_ONLY_ACE | OBJECT_INHERIT_ACE,        MAKEINTRESOURCE(IDS_INH_OBJECT),
00066     &GUID_NULL, 0,                                            MAKEINTRESOURCE(IDS_INH_NONE),
00067 };
00068
00069
00070 HRESULT
00071 LocalAllocString(LPWSTR* ppResult, LPCWSTR pString)
00072 {
00073     if (!ppResult || !pString)
00074         return E_INVALIDARG;
00075
00076     *ppResult = (LPWSTR)LocalAlloc(LPTR, (lstrlen(pString) + 1) * sizeof(WCHAR));
00077
00078     if (!*ppResult)
00079         return E_OUTOFMEMORY;
00080
00081     lstrcpy(*ppResult, pString);
00082     return S_OK;
00083 }
00084
00085 void
00086 LocalFreeString(LPWSTR* ppString)
00087 {
00088     if (ppString)
00089     {
00090         if (*ppString)
00091             LocalFree(*ppString);
00092         *ppString = NULL;
00093     }
00094 }
00095
00096 class CObjSecurity : public ISecurityInformation
00097 {
00098 protected:
00099     ULONG                   m_cRef;
00100     DWORD                   m_dwSIFlags;
00101     PSECURITY_DESCRIPTOR    *m_ppSD;
00102     WORD                    m_wClient;
00103     LPWSTR                  m_pszServerName;
00104     LPWSTR                  m_pszObjectName;
00105
00106 public:
00107     CObjSecurity() : m_cRef(1) {}
00108     virtual ~CObjSecurity();
00109
00110     STDMETHOD(Initialize)(DWORD dwFlags,
00111                           PSECURITY_DESCRIPTOR *ppSD,
00112                           WORD wClient,
00113                           LPCWSTR pszServer,
00114                           BOOL fContainer);
00115
00116     // IUnknown methods
00117     STDMETHOD(QueryInterface)(REFIID, LPVOID *);
00118     STDMETHOD_(ULONG, AddRef)();
00119     STDMETHOD_(ULONG, Release)();
00120
00121     // ISecurityInformation methods
00122     STDMETHOD(GetObjectInformation)(PSI_OBJECT_INFO pObjectInfo);
00123     STDMETHOD(GetSecurity)(SECURITY_INFORMATION si,
00124                            PSECURITY_DESCRIPTOR *ppSD,
00125                            BOOL fDefault);
00126     STDMETHOD(SetSecurity)(SECURITY_INFORMATION si,
00127                            PSECURITY_DESCRIPTOR pSD);
00128     STDMETHOD(GetAccessRights)(const GUID* pguidObjectType,
00129                                DWORD dwFlags,
00130                                PSI_ACCESS *ppAccess,
00131                                ULONG *pcAccesses,
00132                                ULONG *piDefaultAccess);
00133     STDMETHOD(MapGeneric)(const GUID *pguidObjectType,
00134                           UCHAR *pAceFlags,
00135                           ACCESS_MASK *pmask);
00136     STDMETHOD(GetInheritTypes)(PSI_INHERIT_TYPE *ppInheritTypes,
00137                                ULONG *pcInheritTypes);
00138     STDMETHOD(PropertySheetPageCallback)(HWND hwnd,
00139                                          UINT uMsg,
00140                                          SI_PAGE_TYPE uPage);
00141 };
00142
00143 ///////////////////////////////////////////////////////////////////////////////
00144 //
00145 //  This is the entry point function called from our code that establishes
00146 //  what the ACLUI interface is going to need to know.
00147 //
00148 //
00149 ///////////////////////////////////////////////////////////////////////////////
00150
00151 extern "C"
00152 HRESULT
00153 CreateObjSecurityInfo(
00154     DWORD dwFlags,           // e.g. SI_EDIT_ALL | SI_ADVANCED | SI_CONTAINER
00155     PSECURITY_DESCRIPTOR *ppSD,        // Pointer to security descriptor
00156     LPSECURITYINFO *ppObjSI,
00157     WORD wClient,           // Index for client token
00158     LPCWSTR pszServerName,  // Name of server on which SIDs will be resolved
00159     BOOL    fContainer)     // This is the only way to name my generic objects
00160 {
00161     HRESULT hr;
00162     CObjSecurity *psi;
00163
00164     *ppObjSI = NULL;
00165
00166     psi = new CObjSecurity();
00167     if (!psi)
00168         return E_OUTOFMEMORY;
00169
00170     hr = psi->Initialize(dwFlags, ppSD, wClient, pszServerName, fContainer);
00171
00172     if (SUCCEEDED(hr))
00173         *ppObjSI = psi;
00174     else
00175         delete psi;
00176
00177     return hr;
00178 }
00179
00180
00181 CObjSecurity::~CObjSecurity()
00182 {
00183     LocalFreeString(&m_pszServerName);
00184     LocalFreeString(&m_pszObjectName);
00185
00186
00187 }
00188
00189 STDMETHODIMP
00190 CObjSecurity::Initialize(DWORD                      dwFlags,
00191                          PSECURITY_DESCRIPTOR       *ppSD,
00192                          WORD                       wClient,
00193                          LPCWSTR                    pszServer,
00194                          BOOL                       fContainer)
00195 {
00196     HRESULT hr;
00197
00198     m_dwSIFlags = dwFlags;
00199     if(fContainer)
00200         m_dwSIFlags |= SI_CONTAINER;
00201     m_ppSD = ppSD;
00202     m_wClient = wClient;
00203
00204     hr = LocalAllocString(&m_pszServerName, pszServer);
00205
00206     if(SUCCEEDED(hr))
00207     {
00208         if(fContainer)
00209             hr = LocalAllocString(&m_pszObjectName,L"Container");
00210         else
00211             hr = LocalAllocString(&m_pszObjectName,L"Object");
00212     }
00213
00214     return hr;
00215 }
00216
00217
00218 ///////////////////////////////////////////////////////////
00219 //
00220 // IUnknown methods
00221 //
00222 ///////////////////////////////////////////////////////////
00223
00224 STDMETHODIMP_(ULONG)
00225 CObjSecurity::AddRef()
00226 {
00227     return ++m_cRef;
00228 }
00229
00230 STDMETHODIMP_(ULONG)
00231 CObjSecurity::Release()
00232 {
00233     if (--m_cRef == 0)
00234     {
00235         delete this;
00236         return 0;
00237     }
00238
00239     return m_cRef;
00240 }
00241
00242 STDMETHODIMP
00243 CObjSecurity::QueryInterface(REFIID riid, LPVOID FAR* ppv)
00244 {
00245     if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ISecurityInformation))
00246     {
00247         *ppv = (LPSECURITYINFO)this;
00248         m_cRef++;
00249         return S_OK;
00250     }
00251     else
00252     {
00253         *ppv = NULL;
00254         return E_NOINTERFACE;
00255     }
00256 }
00257
00258
00259 ///////////////////////////////////////////////////////////
00260 //
00261 // ISecurityInformation methods
00262 //
00263 ///////////////////////////////////////////////////////////
00264
00265 STDMETHODIMP
00266 CObjSecurity::GetObjectInformation(PSI_OBJECT_INFO pObjectInfo)
00267 {
00268     pObjectInfo->dwFlags = m_dwSIFlags;
00269     pObjectInfo->hInstance = g_hInstance;
00270     pObjectInfo->pszServerName = m_pszServerName;
00271     pObjectInfo->pszObjectName = m_pszObjectName;
00272
00273     return S_OK;
00274 }
00275
00276 STDMETHODIMP
00277 CObjSecurity::GetSecurity(SECURITY_INFORMATION si,
00278                            PSECURITY_DESCRIPTOR *ppSD,
00279                            BOOL fDefault)
00280 {
00281     DWORD dwLength = 0;
00282     DWORD dwErr = 0;
00283
00284     *ppSD = NULL;
00285
00286     if (fDefault)
00287         return E_NOTIMPL;
00288
00289     //
00290     // Assume that required privileges have already been enabled
00291     //
00292     GetPrivateObjectSecurity(*m_ppSD, si, NULL, 0, &dwLength);
00293     if (dwLength)
00294     {
00295         *ppSD = LocalAlloc(LPTR, dwLength);
00296         if (*ppSD &&
00297             !GetPrivateObjectSecurity(*m_ppSD, si, *ppSD, dwLength, &dwLength))
00298         {
00299             dwErr = GetLastError();
00300             LocalFree(*ppSD);
00301             *ppSD = NULL;
00302         }
00303     }
00304     else
00305         dwErr = GetLastError();
00306
00307
00308     return HRESULT_FROM_WIN32(dwErr);
00309 }
00310
00311 STDMETHODIMP
00312 CObjSecurity::SetSecurity(SECURITY_INFORMATION si,
00313                            PSECURITY_DESCRIPTOR pSD)
00314 {
00315     DWORD dwErr = 0;
00316
00317     //
00318     // Assume that required privileges have already been enabled
00319     //
00320     if (!SetPrivateObjectSecurity(si, pSD, m_ppSD, &ObjMap, GetClientToken(m_wClient)))
00321         dwErr = GetLastError();
00322
00323
00324
00325     return HRESULT_FROM_WIN32(dwErr);
00326 }
00327
00328 STDMETHODIMP
00329 CObjSecurity::GetAccessRights(const GUID* /*pguidObjectType*/,
00330                                DWORD /*dwFlags*/,
00331                                PSI_ACCESS *ppAccesses,
00332                                ULONG *pcAccesses,
00333                                ULONG *piDefaultAccess)
00334 {
00335     *ppAccesses = g_siObjAccesses;
00336     *pcAccesses = sizeof(g_siObjAccesses)/sizeof(g_siObjAccesses[0]);
00337     *piDefaultAccess = g_iObjDefAccess;
00338
00339     return S_OK;
00340 }
00341
00342 STDMETHODIMP
00343 CObjSecurity::MapGeneric(const GUID* /*pguidObjectType*/,
00344                           UCHAR * /*pAceFlags*/,
00345                           ACCESS_MASK *pmask)
00346 {
00347     MapGenericMask(pmask, &ObjMap);
00348
00349     return S_OK;
00350 }
00351
00352 STDMETHODIMP
00353 CObjSecurity::GetInheritTypes(PSI_INHERIT_TYPE *ppInheritTypes,
00354                                ULONG *pcInheritTypes)
00355 {
00356     *ppInheritTypes = g_siObjInheritTypes;
00357     *pcInheritTypes = sizeof(g_siObjInheritTypes)/sizeof(g_siObjInheritTypes[0]);
00358
00359     return S_OK;
00360 }
00361
00362 STDMETHODIMP
00363 CObjSecurity::PropertySheetPageCallback(HWND /*hwnd*/,
00364                                          UINT /*uMsg*/,
00365                                          SI_PAGE_TYPE /*uPage*/)
00366 {
00367     return S_OK;
00368 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/about.Cpp Source File

  • SysMgmt
  • MMC
  • About

about.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));;
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163   MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164   *lpDest = wszStr;
00165
00166     return S_OK;
00167 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_WORK_QUEUE_ITEM Member List

This is the complete list of members for _WORK_QUEUE_ITEM, including all inherited members.
List | _WORK_QUEUE_ITEM
Reason | _WORK_QUEUE_ITEM
WorkQueue | _WORK_QUEUE_ITEM
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SENDARGS Member List

This is the complete list of members for _SENDARGS, including all inherited members.
dwBufferCount | _SENDARGS
dwFlags | _SENDARGS
dwNumberOfBytesSent | _SENDARGS
lpBuffers | _SENDARGS
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/IsolationLevelEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

IsolationLevelEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: IsolationLevelEnum
00019
00020 public class IsolationLevelEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final int adXactUnspecified = -1;
00023   public static final int adXactChaos = 16;
00024   public static final int adXactReadUncommitted = 256;
00025   public static final int adXactBrowse = 256;
00026   public static final int adXactCursorStability = 4096;
00027   public static final int adXactReadCommitted = 4096;
00028   public static final int adXactRepeatableRead = 65536;
00029   public static final int adXactSerializable = 1048576;
00030   public static final int adXactIsolated = 1048576;
00031 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_FUNC_INFO Member List

This is the complete list of members for _FUNC_INFO, including all inherited members.
lResult _FUNC_INFO
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFileLite Member List

This is the complete list of members for CFileLite, including all inherited members.
CFileLite() | CFileLite |
Close() | CFileLite | [virtual]
DetermineUnicode() | CFileLite | [virtual]
Flush() | CFileLite | [virtual]
IsEOF() | CFileLite | [inline, virtual]
IsOpen() | CFileLite | [inline, virtual]
IsUnicode() | CFileLite | [inline, virtual]
m_bEOF | CFileLite | [private]
m_bUnicode | CFileLite | [private]
m_cbRead | CFileLite | [private]
m_cbWritten | CFileLite | [private]
m_hFile | CFileLite | [private]
Open(LPCWSTR pwszFileName, DWORD dwDesiredAccess=GENERIC_READ, DWORD dwShareMode=FILE_SHARE_READ, DWORD dwCreationDisposition=OPEN_EXISTING, BOOL fDisplayDialog=FALSE, HWND hWndParent=NULL) | CFileLite | [virtual]
Open(LPCSTR pszFileName, DWORD dwDesiredAccess=GENERIC_READ, DWORD dwShareMode=FILE_SHARE_READ, DWORD dwCreationDisposition=OPEN_EXISTING, BOOL fDisplayDialog=FALSE, HWND hWndParent=NULL) | CFileLite | [virtual]
Read(ULONG cbBytes, WCHAR *pwszText, ULONG *pcbRead=NULL) | CFileLite | [virtual]
Read(ULONG cbBytes, CHAR *pszText, ULONG *pcbRead=NULL) | CFileLite | [virtual]
ReadBytes(ULONG cbBytes, BYTE *rgBytes, ULONG *pcbRead=NULL) | CFileLite | [virtual]
Seek(LONG lDistanceToMove, DWORD dwOrigin) | CFileLite | [virtual]
SetUnicode(BOOL bUnicode=TRUE) | CFileLite | [inline, virtual]
Write(LPCWSTR pwszText, ULONG *pcbWritten=NULL) | CFileLite | [virtual]
Write(LPCSTR pszText, ULONG *pcbWritten=NULL) | CFileLite | [virtual]
WriteBytes(ULONG cBytes, BYTE *rgBytes, ULONG *pcbWritten=NULL) | CFileLite | [virtual]
WriteFormat(LPCWSTR pwszFmt,...) | CFileLite | [virtual]
WriteQuoted(LPCWSTR pwszText) | CFileLite | [virtual]
~CFileLite() | CFileLite | [virtual]
Generated on Wed Nov 13 2024 16:56:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/server.cpp Source File

  • WinUI
  • TSFmark

server.cpp

Go to the documentation of this file.
00001 //
00002 // server.cpp
00003 //
00004 // COM server exports.
00005 //
00006
00007 #include "globals.h"
00008 #include "mark.h"
00009
00010 void FreeGlobalObjects(void);
00011
00012 class CClassFactory;
00013 static CClassFactory *g_ObjectInfo[1] = { NULL };
00014
00015 //+---------------------------------------------------------------------------
00016 //
00017 //  DllAddRef
00018 //
00019 //----------------------------------------------------------------------------
00020
00021 LONG DllAddRef(void)
00022 {
00023     return InterlockedIncrement(&g_cRefDll) + 1;
00024 }
00025
00026 //+---------------------------------------------------------------------------
00027 //
00028 //  DllRelease
00029 //
00030 //----------------------------------------------------------------------------
00031
00032 LONG DllRelease(void)
00033 {
00034     if (InterlockedDecrement(&g_cRefDll) < 0) // g_cRefDll == -1 with zero refs
00035     {
00036         EnterCriticalSection(&g_cs);
00037
00038         // need to check ref again after grabbing mutex
00039         if (g_ObjectInfo[0] != NULL)
00040         {
00041             FreeGlobalObjects();
00042         }
00043         assert(g_cRefDll == -1);
00044
00045         LeaveCriticalSection(&g_cs);
00046     }
00047
00048     return g_cRefDll+1;
00049 }
00050
00051 //+---------------------------------------------------------------------------
00052 //
00053 //  CClassFactory declaration with IClassFactory Interface
00054 //
00055 //----------------------------------------------------------------------------
00056
00057 class CClassFactory : public IClassFactory
00058 {
00059 public:
00060     // IUnknown methods
00061     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00062     STDMETHODIMP_(ULONG) AddRef(void);
00063     STDMETHODIMP_(ULONG) Release(void);
00064
00065     // IClassFactory methods
00066     STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
00067     STDMETHODIMP LockServer(BOOL fLock);
00068
00069     // Constructor
00070     CClassFactory(REFCLSID rclsid, HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid, void **ppvObj))
00071         : _rclsid(rclsid)
00072     {
00073         _pfnCreateInstance = pfnCreateInstance;
00074     }
00075
00076 public:
00077     REFCLSID _rclsid;
00078     HRESULT (*_pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
00079 };
00080
00081 //+---------------------------------------------------------------------------
00082 //
00083 //  CClassFactory::QueryInterface
00084 //
00085 //----------------------------------------------------------------------------
00086
00087 STDAPI CClassFactory::QueryInterface(REFIID riid, void **ppvObj)
00088 {
00089     if (IsEqualIID(riid, IID_IClassFactory) || IsEqualIID(riid, IID_IUnknown))
00090     {
00091         *ppvObj = this;
00092         DllAddRef();
00093         return NOERROR;
00094     }
00095     *ppvObj = NULL;
00096     return E_NOINTERFACE;
00097 }
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 //  CClassFactory::AddRef
00102 //
00103 //----------------------------------------------------------------------------
00104
00105 STDAPI_(ULONG) CClassFactory::AddRef()
00106 {
00107     DllAddRef();
00108     return g_cRefDll+1; // -1 w/ no refs
00109 }
00110
00111 //+---------------------------------------------------------------------------
00112 //
00113 //  CClassFactory::Release
00114 //
00115 //----------------------------------------------------------------------------
00116
00117 STDAPI_(ULONG) CClassFactory::Release()
00118 {
00119     DllRelease();
00120     return g_cRefDll+1; // -1 w/ no refs
00121 }
00122
00123 //+---------------------------------------------------------------------------
00124 //
00125 //  CClassFactory::CreateInstance
00126 //
00127 //----------------------------------------------------------------------------
00128
00129 STDAPI CClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
00130 {
00131     return _pfnCreateInstance(pUnkOuter, riid, ppvObj);
00132 }
00133
00134 //+---------------------------------------------------------------------------
00135 //
00136 //  CClassFactory::LockServer
00137 //
00138 //----------------------------------------------------------------------------
00139
00140 STDAPI CClassFactory::LockServer(BOOL fLock)
00141 {
00142     if (fLock)
00143     {
00144         DllAddRef();
00145     }
00146     else
00147     {
00148         DllRelease();
00149     }
00150
00151     return S_OK;
00152 }
00153
00154 //+---------------------------------------------------------------------------
00155 //
00156 //  BuildGlobalObjects
00157 //
00158 //----------------------------------------------------------------------------
00159
00160 void BuildGlobalObjects(void)
00161 {
00162     // Build CClassFactory Objects
00163
00164     g_ObjectInfo[0] = new CClassFactory(c_clsidMarkTextService,
00165                                         CMarkTextService::CreateInstance);
00166
00167     // You can add more object info here.
00168     // Don't forget to increase number of item for g_ObjectInfo[],
00169 }
00170
00171 //+---------------------------------------------------------------------------
00172 //
00173 //  FreeGlobalObjects
00174 //
00175 //----------------------------------------------------------------------------
00176
00177 void FreeGlobalObjects(void)
00178 {
00179     // Free CClassFactory Objects
00180     for (int i = 0; i < ARRAYSIZE(g_ObjectInfo); i++)
00181     {
00182         if (NULL != g_ObjectInfo[i])
00183         {
00184             delete g_ObjectInfo[i];
00185             g_ObjectInfo[i] = NULL;
00186         }
00187     }
00188 }
00189
00190 //+---------------------------------------------------------------------------
00191 //
00192 //  DllGetClassObject
00193 //
00194 //----------------------------------------------------------------------------
00195
00196 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppvObj)
00197 {
00198     if (g_ObjectInfo[0] == NULL)
00199     {
00200         EnterCriticalSection(&g_cs);
00201
00202             // need to check ref again after grabbing mutex
00203             if (g_ObjectInfo[0] == NULL)
00204             {
00205                 BuildGlobalObjects();
00206             }
00207
00208         LeaveCriticalSection(&g_cs);
00209     }
00210
00211     if (IsEqualIID(riid, IID_IClassFactory) ||
00212         IsEqualIID(riid, IID_IUnknown))
00213     {
00214         for (int i = 0; i < ARRAYSIZE(g_ObjectInfo); i++)
00215         {
00216             if (NULL != g_ObjectInfo[i] &&
00217                 IsEqualGUID(rclsid, g_ObjectInfo[i]->_rclsid))
00218             {
00219                 *ppvObj = (void *)g_ObjectInfo[i];
00220                 DllAddRef();    // class factory holds DLL ref count
00221                 return NOERROR;
00222             }
00223         }
00224     }
00225
00226     *ppvObj = NULL;
00227
00228     return CLASS_E_CLASSNOTAVAILABLE;
00229 }
00230
00231 //+---------------------------------------------------------------------------
00232 //
00233 //  DllCanUnloadNow
00234 //
00235 //----------------------------------------------------------------------------
00236
00237 STDAPI DllCanUnloadNow(void)
00238 {
00239     if (g_cRefDll >= 0) // -1 with no refs
00240         return S_FALSE;
00241
00242     return S_OK;
00243 }
00244
00245 //+---------------------------------------------------------------------------
00246 //
00247 //  DllUnregisterServer
00248 //
00249 //----------------------------------------------------------------------------
00250
00251 STDAPI DllUnregisterServer(void)
00252 {
00253     CMarkTextService::RegisterCategories(FALSE);
00254     CMarkTextService::UnregisterProfiles();
00255     CMarkTextService::UnregisterServer();
00256
00257     return S_OK;
00258 }
00259
00260 //+---------------------------------------------------------------------------
00261 //
00262 //  DllRegisterServer
00263 //
00264 //----------------------------------------------------------------------------
00265
00266 STDAPI DllRegisterServer(void)
00267 {
00268     // register this service's profile with the tsf
00269     if (!CMarkTextService::RegisterServer() ||
00270         !CMarkTextService::RegisterProfiles() ||
00271         !CMarkTextService::RegisterCategories(TRUE))
00272     {
00273         DllUnregisterServer(); // cleanup any loose ends
00274         return E_FAIL;
00275     }
00276
00277     return S_OK;
00278 }
00279
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcAudio.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcAudio.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created with ClassWizard
00045
00046 #include "stdafx.h"
00047 #include "ACAudio.h"
00048
00049 #ifdef _DEBUG
00050 #define new DEBUG_NEW
00051 #undef THIS_FILE
00052 static char THIS_FILE[] = __FILE__;
00053 #endif
00054
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CAgentCtlAudioObject properties
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // CAgentCtlAudioObject operations
00062
00063 BOOL CAgentCtlAudioObject::GetEnabled()
00064 {
00065   BOOL result;
00066   InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00067   return result;
00068 }
00069
00070 BOOL CAgentCtlAudioObject::GetSoundEffects()
00071 {
00072   BOOL result;
00073   InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00074   return result;
00075 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/FreeObject/FreeTest.Cpp Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • FreeObject

FreeTest.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: FreeTest.cpp
00004
00005 Summary: Implementation of CFreeTest
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021
00022 #include "stdafx.h"
00023 #include "FreeObject.h"
00024 #include "FreeTest.h"
00025
00026 #define LOOPCOUNT 10000
00027
00028 extern CRITICAL_SECTION g_csSync;
00029
00030 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00031
00032 Class: CFreeTest
00033
00034 CFreeTest is a simply object that does nothing but is marked as FREE threaded.
00035 It's purpose is just so our client has a free threaded object to call
00036
00037 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00038
00039 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00040
00041 Method: Exercise
00042
00043 Summary: Exercise simply loops for a while doing some math on the stack.
00044      Utilize a CritSec here just so we are doing some syncronization since
00045      this sample compares syncronization methods
00046
00047 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00048
00049 STDMETHODIMP CFreeTest::Exercise(void)
00050 {
00051
00052   DWORD dwCount, dwValue = 0;
00053
00054   // we only use a CriticalSection for time comparisons with the other clases.
00055   // There is nothing in this function that would require a critsec
00056
00057   // get into our critical section
00058   EnterCriticalSection(&g_csSync);
00059
00060   for (dwCount = 0; dwCount < LOOPCOUNT; dwCount++)
00061     dwValue += dwCount;
00062
00063   LeaveCriticalSection(&g_csSync);
00064
00065   return S_OK;
00066 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/Resource.h Source File

  • Web
  • NetMeeting
  • NMChat

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by res.rc
00004 //
00005 #define IDS_APP_TITLE                   1
00006 #define IDS_VERSION                     2
00007 #define IDS_SYSMENU                     4
00008 #define ICO_MAIN                        101
00009 #define IDM_APP                         104
00010 #define ID_APPACCEL                     105
00011 #define IDD_OPTIONS                     123
00012 #define IDM_SAVE_AS                     40001
00013 #define IDM_EXIT                        40002
00014 #define IDM_VIEW_FONT                   40011
00015 #define IDM_VIEW_CLEAR                  40012
00016 #define IDM_OPTIONS                     40013
00017 #define IDM_EJECT                       40021
00018 #define IDM_HELP                        40090
00019 #define IDM_HELP_CONTENTS               40091
00020 #define IDM_ABOUT                       40092
00021 #define IDM_VIEW_NAME                   40142
00022 #define IDM_VIEW_TIME                   40143
00023 #define IDM_VIEW_USERS                  40144
00024
00025 // Next default values for new objects
00026 //
00027 #ifdef APSTUDIO_INVOKED
00028 #ifndef APSTUDIO_READONLY_SYMBOLS
00029 #define _APS_NEXT_RESOURCE_VALUE        124
00030 #define _APS_NEXT_COMMAND_VALUE         40145
00031 #define _APS_NEXT_CONTROL_VALUE         1028
00032 #define _APS_NEXT_SYMED_VALUE           101
00033 #endif
00034 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CComponent Member List

This is the complete list of members for CComponent, including all inherited members.
AddMenuItems(LPDATAOBJECT piDataObject, LPCONTEXTMENUCALLBACK piCallback, long __RPC_FAR *pInsertionAllowed) | CComponent | [virtual]
AddMenuItems(LPDATAOBJECT piDataObject, LPCONTEXTMENUCALLBACK piCallback, long __RPC_FAR *pInsertionAllowed) | CComponent | [virtual]
CacheHint(int nStartIndex, int nEndIndex) | CComponent | [virtual]
CacheHint(int nStartIndex, int nEndIndex) | CComponent | [virtual]
CacheHint(int nStartIndex, int nEndIndex) | CComponent | [virtual]
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *pParent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
CComponent(CComponentData *parent) | CComponent |
Command(long lCommandID, LPDATAOBJECT piDataObject) | CComponent | [virtual]
Command(long lCommandID, LPDATAOBJECT piDataObject) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent |
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB) | CComponent | [virtual]
ControlbarNotify(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
ControlbarNotify(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
ControlbarNotify(MMC_NOTIFY_TYPE MmcEvent, LPARAM nArg, LPARAM lParam) | CComponent |
ControlbarNotify(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle, LPDATAOBJECT lpIDataObject) | CComponent | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle, LPDATAOBJECT lpIDataObject) | CComponent | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR Handle, LPDATAOBJECT ipIDataObject) | CComponent |
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR Handle, LPDATAOBJECT ipIDataObject) | CComponent |
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle, LPDATAOBJECT lpIDataObject) | CComponent | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle, LPDATAOBJECT lpIDataObject) | CComponent | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle, LPDATAOBJECT lpIDataObject) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE nCookie) | CComponent |
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
Destroy(MMC_COOKIE cookie) | CComponent | [virtual]
DisplayMessageBox(CDelegationBase *base) | CComponent |
EnumTasks(IDataObject __RPC_FAR *pdo, LPOLESTR szTaskGroup, IEnumTASK __RPC_FAR *__RPC_FAR *ppEnumTASK) | CComponent | [virtual]
FindItem(LPRESULTFINDINFO pFindInfo, int __RPC_FAR *pnFoundIndex) | CComponent | [virtual]
FindItem(LPRESULTFINDINFO pFindInfo, int __RPC_FAR *pnFoundIndex) | CComponent | [virtual]
FindItem(LPRESULTFINDINFO pFindInfo, int __RPC_FAR *pnFoundIndex) | CComponent | [virtual]
GetBackground(LPOLESTR pszGroup, MMC_TASK_DISPLAY_OBJECT __RPC_FAR *pTDO) | CComponent | [virtual]
GetCurrentSelections(CDataObject *pMultiSelectDataObject) | CComponent |
GetDescriptiveText(LPOLESTR pszGroup, LPOLESTR __RPC_FAR *pszDescriptiveText) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent |
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetDisplayInfo(RESULTDATAITEM __RPC_FAR *pResultDataItem) | CComponent | [virtual]
GetInterface(DWORD dwRequestedInterface, LONG_PTR *ppInterface) | CComponent |
GetInterface(DWORD dwRequestedInterface, LONG_PTR *ppInterface) | CComponent |
GetInterface(DWORD dwRequestedInterface, LONG_PTR *ppInterface) | CComponent |
GetInterface(DWORD dwRequestedInterface, LONG_PTR *ppInterface) | CComponent |
GetInterface(DWORD dwRequestedInterface, LONG_PTR *ppInterface) | CComponent |
GetInterface(DWORD dwRequestedInterface, LONG_PTR *ppInterface) | CComponent |
GetListPadInfo(LPOLESTR pszGroup, MMC_LISTPAD_INFO __RPC_FAR *lpListPadInfo) | CComponent | [virtual]
GetParent() | CComponent | [inline]
GetProperty(LPDATAOBJECT ipDataObject, BSTR szPropertyName, PBSTR pbstrProperty) | CComponent |
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE nCookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent |
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType(MMC_COOKIE cookie, LPOLESTR __RPC_FAR *ppViewType, long __RPC_FAR *pViewOptions) | CComponent | [virtual]
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CComponent |
GetScopeCookie() | CComponent | [inline]
GetScopeCookie() | CComponent | [inline]
GetScopeCookie() | CComponent | [inline]
GetTitle(LPOLESTR pszGroup, LPOLESTR __RPC_FAR *pszTitle) | CComponent | [virtual]
getToolbar() | CComponent | [inline]
getToolbar() | CComponent | [inline]
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent | [virtual]
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent | [virtual]
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent |
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent |
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent | [virtual]
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent | [virtual]
GetWatermarks(LPDATAOBJECT lpIDataObject, HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE ipConsole) | CComponent |
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
Initialize(LPCONSOLE lpConsole) | CComponent | [virtual]
m_bIsTaskpadPreferred | CComponent | [private]
m_bTaskpadView | CComponent | [private]
m_cref | CComponent | [private]
m_cRef | CComponent | [private]
m_hImageStrip16 | CComponent | [private]
m_hImageStrip32 | CComponent | [private]
m_ipConsole | CComponent | [private]
m_ipConsole | CComponent | [private]
m_ipConsole | CComponent | [private]
m_ipConsole2 | CComponent | [private]
m_ipConsoleVerb | CComponent | [private]
m_ipControlbar | CComponent | [private]
m_ipControlBar | CComponent | [private]
m_ipDeviceToolbar | CComponent | [private]
m_ipDisplayHelp | CComponent | [private]
m_ipHeaderCtrl | CComponent | [private]
m_ipHeaderCtrl2 | CComponent | [private]
m_ipMenuButton | CComponent | [private]
m_ipResultData | CComponent | [private]
m_ipResultData | CComponent | [private]
m_ipStaticToolbar | CComponent | [private]
m_ipToolbar | CComponent | [private]
m_ipVFileToolbar | CComponent | [private]
m_pComponentData | CComponent | [private]
m_pComponentData | CComponent | [private]
m_pLastNode | CComponent | [private]
m_pParent | CComponent | [private]
m_pScopeCookie | CComponent | [private]
m_pScopeCookie | CComponent | [private]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LONG nArg, LONG nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LONG nArg, LONG nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LPARAM nArg, LPARAM nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LPARAM nArg, LPARAM nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LONG nArg, LONG nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LONG nArg, LONG nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LPARAM nArg, LPARAM nParam) | CComponent |
Notify(LPDATAOBJECT ipDataObject, MMC_NOTIFY_TYPE MmcEvent, LONG nArg, LONG nParam) | CComponent |
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param) | CComponent | [virtual]
OleDuplicateString(LPOLESTR lpStr) | CComponent | [inline, private]
OnAddImages(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam) | CComponent | [private]
OnAddImages(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam) | CComponent | [private]
OnAddImages(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam) | CComponent | [private]
OnAddImages(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam) | CComponent | [private]
OnAddImages(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam) | CComponent | [private]
OnAddImages(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam) | CComponent | [private]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent |
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT __RPC_FAR *ppDataObject) | CComponent | [virtual]
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryDispatch(MMC_COOKIE nCookie, DATA_OBJECT_TYPES eType, LPDISPATCH *pipDispatch) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryInterface(REFIID riid, LPVOID *ppv) | CComponent |
QueryMultiSelDataObject(MMC_COOKIE nCookie, DATA_OBJECT_TYPES nEnumType, CDataObject **ppDataObject) | CComponent |
QueryPagesFor(LPDATAOBJECT lpDataObject) | CComponent | [virtual]
QueryPagesFor(LPDATAOBJECT lpDataObject) | CComponent | [virtual]
QueryPagesFor(LPDATAOBJECT ipDataObject) | CComponent |
QueryPagesFor(LPDATAOBJECT ipDataObject) | CComponent |
QueryPagesFor(LPDATAOBJECT lpDataObject) | CComponent | [virtual]
QueryPagesFor(LPDATAOBJECT lpDataObject) | CComponent | [virtual]
QueryPagesFor(LPDATAOBJECT lpDataObject) | CComponent | [virtual]
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
RestoreResultView(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pResultViewType) | CComponent |
SetControlbar(LPCONTROLBAR pControlbar) | CComponent | [virtual]
SetControlbar(LPCONTROLBAR pControlbar) | CComponent | [virtual]
SetControlbar(LPCONTROLBAR ipControlbar) | CComponent |
SetControlbar(LPCONTROLBAR pControlbar) | CComponent | [virtual]
SortItems(int nColumn, DWORD dwSortOptions, LPARAM lUserParam) | CComponent | [virtual]
SortItems(int nColumn, DWORD dwSortOptions, LPARAM lUserParam) | CComponent | [virtual]
SortItems(int nColumn, DWORD dwSortOptions, LPARAM lUserParam) | CComponent | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
STDMETHODIMP_(ULONG) AddRef() | CComponent |
STDMETHODIMP_(ULONG) Release() | CComponent |
TaskNotify(IDataObject __RPC_FAR *pdo, VARIANT __RPC_FAR *arg, VARIANT __RPC_FAR *param) | CComponent | [virtual]
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
~CComponent() | CComponent |
Generated on Wed Nov 13 2024 16:55:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CShellExtClassFactory Member List

This is the complete list of members for CShellExtClassFactory, including all inherited members.
CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *) | CShellExtClassFactory |
CShellExtClassFactory() | CShellExtClassFactory |
LockServer(BOOL) | CShellExtClassFactory |
m_cRef | CShellExtClassFactory | [protected]
QueryInterface(REFIID, LPVOID FAR *) | CShellExtClassFactory |
STDMETHODIMP_(ULONG) AddRef() | CShellExtClassFactory |
STDMETHODIMP_(ULONG) Release() | CShellExtClassFactory |
~CShellExtClassFactory() | CShellExtClassFactory |
Generated on Wed Nov 13 2024 16:57:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/FreServe/Factory.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • FreServe

Factory.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.H
00003
00004   Summary:   Include file for the class factory COM object: CFBall. This
00005              constitutes the FRESERVE server's class factory for this COM
00006              component.
00007
00008              The multiple interface COM Object Classe is achieved via
00009              the technique of nested classes: the implementation of the
00010              IClassFactory interface is nested inside of the class
00011              factory COM object class.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial FRESERVE.HTM file.
00015              For more specific technical details on the internal workings
00016              see the comments dispersed throughout the module's source code.
00017
00018   Classes:   CFBall.
00019
00020   Functions: .
00021
00022   Origin:    4-5-96: atrent - Editor-inheritance from FACTORY.H in
00023                the DLLSERVE Tutorial Code Sample.
00024
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040 #if !defined(FACTORY_H)
00041 #define FACTORY_H
00042
00043 #ifdef __cplusplus
00044
00045 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00046   ObjectClass: CFBall
00047
00048   Summary:     Class Factory COM Object Class for Ball COM components.
00049                Used to manufacture COBall COM objects.  The mulitple
00050                interfaces on this COM object class are constructed via
00051                the nested interface classes technique.
00052
00053   Interfaces:  IUnknown
00054                  Standard interface providing COM object features.
00055                IClassFactory
00056                  Standard interface providing COM Class Factory features.
00057
00058   Aggregation: Yes, CFBall COM objects are aggregatable by
00059                passing a non-NULL pUnkOuter IUnknown pointer into the
00060                constructor.
00061 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00062 class CFBall : public IUnknown, public CThreaded
00063 {
00064   public:
00065     // Main Object Constructor & Destructor.
00066     CFBall(IUnknown* pUnkOuter, CServer* pServer);
00067     ~CFBall(void);
00068
00069     // IUnknown methods. Main object, non-delegating.
00070     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00071     STDMETHODIMP_(ULONG) AddRef(void);
00072     STDMETHODIMP_(ULONG) Release(void);
00073
00074     // We declare nested class interface implementations here.
00075
00076     // We implement the IClassFactory interface (ofcourse) in this class
00077     // factory COM object class.
00078     class CImpIClassFactory : public IClassFactory, public CThreaded
00079     {
00080       public:
00081         // Interface Implementation Constructor & Destructor.
00082         CImpIClassFactory(
00083           CFBall* pBackObj,
00084           IUnknown* pUnkOuter,
00085           CServer* pServer);
00086         ~CImpIClassFactory(void);
00087
00088         // IUnknown methods.
00089         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00090         STDMETHODIMP_(ULONG) AddRef(void);
00091         STDMETHODIMP_(ULONG) Release(void);
00092
00093         // IClassFactory methods.
00094         STDMETHODIMP         CreateInstance(IUnknown*, REFIID, PPVOID);
00095         STDMETHODIMP         LockServer(BOOL);
00096
00097       private:
00098         // Data private to this interface implementation of IClassFactory.
00099         CFBall*       m_pBackObj;    // Parent Object back pointer.
00100         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00101         CServer*      m_pServer;     // Server's control object.
00102     };
00103
00104     // Make the otherwise private and nested IClassFactory interface
00105     // implementation a friend to COM object instantiations of this
00106     // selfsame CFBall COM object class.
00107     friend CImpIClassFactory;
00108
00109   private:
00110     // Private data of CFBall COM objects.
00111
00112     // Nested IClassFactory implementation instantiation.
00113     CImpIClassFactory m_ImpIClassFactory;
00114
00115     // Main Object reference count.
00116     ULONG             m_cRefs;
00117
00118     // Outer unknown (aggregation & delegation). Used when this
00119     // CFBall object is being aggregated.  Otherwise it is used
00120     // for delegation if this object is reused via containment.
00121     IUnknown*         m_pUnkOuter;
00122
00123     // Pointer to this component server's control object.
00124     CServer*          m_pServer;
00125 };
00126
00127 typedef CFBall* PCFBall;
00128
00129
00130 #endif // __cplusplus
00131
00132
00133 #endif // FACTORY_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/enumfetc.c Source File

  • Com
  • Fundamentals
  • OleStd

enumfetc.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2 Utility Code
00004 **
00005 **    enumfetc.c
00006 **
00007 **    This file contains a standard implementation of IEnumFormatEtc
00008 **    interface.
00009 **    This file is part of the OLE 2.0 User Interface support library.
00010 **
00011 **    (c) Copyright Microsoft Corp. 1990 - 2000 All Rights Reserved
00012 **
00013 *************************************************************************/
00014
00015 #define STRICT  1
00016 #include "olestd.h"
00017
00018
00019 typedef struct tagOleStdEnumFmtEtc {
00020   IEnumFORMATETCVtbl FAR* lpVtbl;
00021   ULONG m_dwRefs;       /* referance count */
00022   ULONG m_nIndex;       /* current index in list */
00023   ULONG m_nCount;       /* how many items in list */
00024   LPFORMATETC m_lpEtc;  /* list of formatetc */
00025 } OLESTDENUMFMTETC, FAR* LPOLESTDENUMFMTETC;
00026
00027 VOID  OleStdEnumFmtEtc_Destroy(LPOLESTDENUMFMTETC pEtc);
00028
00029 STDMETHODIMP OleStdEnumFmtEtc_QueryInterface(
00030                 LPENUMFORMATETC lpThis, REFIID riid, LPVOID FAR* ppobj);
00031 STDMETHODIMP_(ULONG)  OleStdEnumFmtEtc_AddRef(LPENUMFORMATETC lpThis);
00032 STDMETHODIMP_(ULONG)  OleStdEnumFmtEtc_Release(LPENUMFORMATETC lpThis);
00033 STDMETHODIMP  OleStdEnumFmtEtc_Next(LPENUMFORMATETC lpThis, ULONG celt,
00034                                                                   LPFORMATETC rgelt, ULONG FAR* pceltFetched);
00035 STDMETHODIMP  OleStdEnumFmtEtc_Skip(LPENUMFORMATETC lpThis, ULONG celt);
00036 STDMETHODIMP  OleStdEnumFmtEtc_Reset(LPENUMFORMATETC lpThis);
00037 STDMETHODIMP  OleStdEnumFmtEtc_Clone(LPENUMFORMATETC lpThis,
00038                                                                          LPENUMFORMATETC FAR* ppenum);
00039
00040 static IEnumFORMATETCVtbl g_EnumFORMATETCVtbl = {
00041                 OleStdEnumFmtEtc_QueryInterface,
00042                 OleStdEnumFmtEtc_AddRef,
00043                 OleStdEnumFmtEtc_Release,
00044                 OleStdEnumFmtEtc_Next,
00045                 OleStdEnumFmtEtc_Skip,
00046                 OleStdEnumFmtEtc_Reset,
00047                 OleStdEnumFmtEtc_Clone,
00048 };
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051
00052
00053 STDAPI_(LPENUMFORMATETC)
00054   OleStdEnumFmtEtc_Create(ULONG nCount, LPFORMATETC lpEtc)
00055 //----------------------------------------------------------------------------
00056 //
00057 //----------------------------------------------------------------------------
00058 {
00059   LPMALLOC lpMalloc=NULL;
00060   LPOLESTDENUMFMTETC lpEF=NULL;
00061   DWORD dwSize;
00062   WORD i;
00063   HRESULT hRes;
00064
00065   hRes = CoGetMalloc(MEMCTX_TASK, &lpMalloc);
00066   if (hRes != NOERROR) {
00067         return NULL;
00068   }
00069
00070   lpEF = (LPOLESTDENUMFMTETC)lpMalloc->lpVtbl->Alloc(lpMalloc,
00071                                                                                                  sizeof(OLESTDENUMFMTETC));
00072   if (lpEF == NULL) {
00073         goto errReturn;
00074   }
00075
00076   lpEF->lpVtbl = &g_EnumFORMATETCVtbl;
00077   lpEF->m_dwRefs = 1;
00078   lpEF->m_nCount = nCount;
00079   lpEF->m_nIndex = 0;
00080
00081   dwSize = sizeof(FORMATETC) * lpEF->m_nCount;
00082
00083   lpEF->m_lpEtc = (LPFORMATETC)lpMalloc->lpVtbl->Alloc(lpMalloc, dwSize);
00084   if (lpEF->m_lpEtc == NULL)
00085         goto errReturn;
00086
00087   lpMalloc->lpVtbl->Release(lpMalloc);
00088
00089   for (i=0; i<nCount; i++) {
00090         OleStdCopyFormatEtc(
00091                         (LPFORMATETC)&(lpEF->m_lpEtc[i]), (LPFORMATETC)&(lpEtc[i]));
00092   }
00093
00094   g_dwObjectCount++ ;
00095
00096   return (LPENUMFORMATETC)lpEF;
00097
00098 errReturn:
00099   if (lpEF != NULL)
00100         lpMalloc->lpVtbl->Free(lpMalloc, lpEF);
00101
00102   if (lpMalloc != NULL)
00103         lpMalloc->lpVtbl->Release(lpMalloc);
00104
00105   return NULL;
00106
00107 } /* OleStdEnumFmtEtc_Create()
00108    */
00109
00110
00111 VOID
00112   OleStdEnumFmtEtc_Destroy(LPOLESTDENUMFMTETC lpEF)
00113 //----------------------------------------------------------------------------
00114 //
00115 //----------------------------------------------------------------------------
00116 {
00117         LPMALLOC lpMalloc=NULL;
00118         WORD i;
00119
00120         if (lpEF != NULL) {
00121
00122                 if (CoGetMalloc(MEMCTX_TASK, &lpMalloc) == NOERROR) {
00123
00124                         /* NOTE: we MUST free any memory that was allocated for
00125                         **    TARGETDEVICES contained within the FORMATETC elements.
00126                         */
00127                         for (i=0; i<lpEF->m_nCount; i++) {
00128                                 OleStdFree(lpEF->m_lpEtc[i].ptd);
00129                         }
00130
00131                         if (lpEF->m_lpEtc != NULL) {
00132                                 lpMalloc->lpVtbl->Free(lpMalloc, lpEF->m_lpEtc);
00133                         }
00134
00135                         lpMalloc->lpVtbl->Free(lpMalloc, lpEF);
00136                         lpMalloc->lpVtbl->Release(lpMalloc);
00137                 }
00138         }
00139
00140         g_dwObjectCount-- ;
00141
00142 } /* OleStdEnumFmtEtc_Destroy()
00143    */
00144
00145
00146 STDMETHODIMP
00147   OleStdEnumFmtEtc_QueryInterface(
00148                                 LPENUMFORMATETC lpThis, REFIID riid, LPVOID FAR* ppobj)
00149 //----------------------------------------------------------------------------
00150 //
00151 //----------------------------------------------------------------------------
00152 {
00153   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00154   *ppobj = NULL;
00155
00156   if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IEnumFORMATETC)){
00157         *ppobj = (LPVOID)lpEF;
00158   }
00159
00160   if (*ppobj == NULL) return E_NOINTERFACE;
00161   else{
00162         OleStdEnumFmtEtc_AddRef(lpThis);
00163         return NOERROR;
00164   }
00165
00166 } /* OleStdEnumFmtEtc_QueryInterface()
00167    */
00168
00169
00170 STDMETHODIMP_(ULONG)
00171   OleStdEnumFmtEtc_AddRef(LPENUMFORMATETC lpThis)
00172 //----------------------------------------------------------------------------
00173 //
00174 //----------------------------------------------------------------------------
00175 {
00176   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00177   return lpEF->m_dwRefs++;
00178
00179 } /* OleStdEnumFmtEtc_AddRef()
00180    */
00181
00182
00183 STDMETHODIMP_(ULONG)
00184   OleStdEnumFmtEtc_Release(LPENUMFORMATETC lpThis)
00185 //----------------------------------------------------------------------------
00186 //
00187 //----------------------------------------------------------------------------
00188 {
00189   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00190   DWORD dwRefs = --lpEF->m_dwRefs;
00191
00192   if (dwRefs == 0)
00193         OleStdEnumFmtEtc_Destroy(lpEF);
00194
00195   return dwRefs;
00196
00197 } /* OleStdEnumFmtEtc_Release()
00198    */
00199
00200
00201 STDMETHODIMP
00202   OleStdEnumFmtEtc_Next(LPENUMFORMATETC lpThis, ULONG celt, LPFORMATETC rgelt,
00203                                           ULONG FAR* pceltFetched)
00204 //----------------------------------------------------------------------------
00205 //
00206 //----------------------------------------------------------------------------
00207 {
00208   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00209   ULONG i=0;
00210   ULONG nOffset;
00211
00212   if (rgelt == NULL) {
00213         return E_INVALIDARG;
00214   }
00215
00216   while (i < celt) {
00217         nOffset = lpEF->m_nIndex + i;
00218
00219         if (nOffset < lpEF->m_nCount) {
00220           OleStdCopyFormatEtc(
00221                         (LPFORMATETC)&(rgelt[i]), (LPFORMATETC)&(lpEF->m_lpEtc[nOffset]));
00222           i++;
00223         }else{
00224           break;
00225         }
00226   }
00227
00228   lpEF->m_nIndex += (WORD)i;
00229
00230   if (pceltFetched != NULL) {
00231         *pceltFetched = i;
00232   }
00233
00234   if (i != celt) {
00235         return S_FALSE;
00236   }
00237
00238   return NOERROR;
00239 } /* OleStdEnumFmtEtc_Next()
00240    */
00241
00242
00243 STDMETHODIMP
00244   OleStdEnumFmtEtc_Skip(LPENUMFORMATETC lpThis, ULONG celt)
00245 //----------------------------------------------------------------------------
00246 //
00247 //----------------------------------------------------------------------------
00248 {
00249   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00250   ULONG i=0;
00251   ULONG nOffset;
00252
00253   while (i < celt) {
00254         nOffset = lpEF->m_nIndex + i;
00255
00256         if (nOffset < lpEF->m_nCount) {
00257           i++;
00258         }else{
00259           break;
00260         }
00261   }
00262
00263   lpEF->m_nIndex += (WORD)i;
00264
00265   if (i != celt) {
00266         return S_FALSE;
00267   }
00268
00269   return NOERROR;
00270 } /* OleStdEnumFmtEtc_Skip()
00271    */
00272
00273
00274 STDMETHODIMP
00275   OleStdEnumFmtEtc_Reset(LPENUMFORMATETC lpThis)
00276 //----------------------------------------------------------------------------
00277 //
00278 //----------------------------------------------------------------------------
00279 {
00280   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00281   lpEF->m_nIndex = 0;
00282
00283   return NOERROR;
00284 } /* OleStdEnumFmtEtc_Reset()
00285    */
00286
00287
00288 STDMETHODIMP
00289   OleStdEnumFmtEtc_Clone(LPENUMFORMATETC lpThis, LPENUMFORMATETC FAR* ppenum)
00290 //----------------------------------------------------------------------------
00291 //
00292 //----------------------------------------------------------------------------
00293 {
00294   LPOLESTDENUMFMTETC lpEF = (LPOLESTDENUMFMTETC)lpThis;
00295
00296   if (ppenum == NULL) {
00297         return E_INVALIDARG;
00298   }
00299
00300   *ppenum = OleStdEnumFmtEtc_Create(lpEF->m_nCount, lpEF->m_lpEtc);
00301
00302   // make sure cloned enumerator has same index state as the original
00303   if (*ppenum) {
00304           LPOLESTDENUMFMTETC lpEFClone = (LPOLESTDENUMFMTETC)*ppenum;
00305           lpEFClone->m_nIndex = lpEF->m_nIndex;
00306           return NOERROR;
00307   } else
00308           return E_OUTOFMEMORY;
00309
00310 } /* OleStdEnumFmtEtc_Clone()
00311    */
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/networkentry.c Source File

  • NetDS
  • RRas
  • ip

networkentry.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\networkentry.c
00008
00009 Abstract:
00010
00011     The file contains functions to deal with the network entry and its
00012     associated data structures.
00013
00014 --*/
00015
00016 #include "pchsample.h"
00017 #pragma hdrstop
00018
00019
00020 DWORD
00021 BE_CreateTable (
00022     IN  PIP_ADAPTER_BINDING_INFO    pBinding,
00023     OUT PBINDING_ENTRY              *ppbeBindingTable,
00024     OUT PIPADDRESS                  pipLowestAddress)
00025 /*++
00026
00027 Routine Description
00028     Creates a table of binding entries and returns the binding with the
00029     lowest ip address.  Ensures that there is atleast one binding.
00030
00031 Locks
00032     None
00033
00034 Arguments
00035     pBinding            structure containing info about addresses bindings
00036     ppbeBindingTable    pointer to the binding table address
00037     pipLowestAddress    pointer to the lowest ip address in the binding
00038
00039 Return Value
00040     NO_ERROR            if success
00041     Failure code        o/w
00042
00043 --*/
00044 {
00045     ULONG               i;
00046     DWORD               dwErr = NO_ERROR;
00047     PBINDING_ENTRY      pbe; // scratch
00048
00049     // validate parameters
00050     if (!pBinding or !ppbeBindingTable or !pipLowestAddress)
00051         return ERROR_INVALID_PARAMETER;
00052
00053     // a binding already exists
00054     if (*ppbeBindingTable != NULL)
00055         return ERROR_INVALID_PARAMETER;
00056
00057     IP_ASSIGN(pipLowestAddress, IP_HIGHEST);
00058
00059     do                          // breakout loop
00060     {
00061         if (pBinding->AddressCount is 0)
00062         {
00063             dwErr = ERROR_INVALID_PARAMETER;
00064             TRACE0(NETWORK, "Error, no bindings specified");
00065             break;
00066         }
00067
00068         for (i = 0; i < pBinding->AddressCount; i++)
00069             if (!IP_VALID((pBinding->Address)[i].Address))
00070                 break;
00071         if (i != pBinding->AddressCount)
00072         {
00073             dwErr = ERROR_INVALID_PARAMETER;
00074             TRACE0(NETWORK, "Error, an invalid binding specified");
00075             break;
00076         }
00077
00078         // allocate the binding table
00079         MALLOC(&pbe, pBinding->AddressCount * sizeof(BINDING_ENTRY), &dwErr);
00080         if (dwErr != NO_ERROR)
00081             break;
00082
00083         for (i = 0; i < pBinding->AddressCount; i++)
00084         {
00085             // initialize fields
00086             IP_ASSIGN(&(pbe[i].ipAddress), (pBinding->Address)[i].Address);
00087             IP_ASSIGN(&(pbe[i].ipMask), pBinding->Address[i].Mask);
00088
00089             // update lowest ip address
00090             if (IP_COMPARE(pbe[i].ipAddress, *pipLowestAddress) is -1)
00091                 IP_ASSIGN(pipLowestAddress,pbe[i].ipAddress);
00092         }
00093
00094         *ppbeBindingTable = pbe;
00095
00096     } while (FALSE);
00097
00098     return dwErr;
00099 }
00100
00101
00102
00103 DWORD
00104 BE_DestroyTable (
00105     IN  PBINDING_ENTRY              pbeBindingTable)
00106 /*++
00107
00108 Routine Description
00109     Destroys a binding table.
00110
00111 Locks
00112     None.
00113
00114 Arguments
00115     pbeBindingTable     pointer to the table of binding entries
00116
00117 Return Value
00118     NO_ERROR            always
00119
00120 --*/
00121 {
00122     if (!pbeBindingTable)
00123         return NO_ERROR;
00124
00125     FREE(pbeBindingTable);
00126
00127     return NO_ERROR;
00128 }
00129
00130
00131
00132 #ifdef DEBUG
00133 DWORD
00134 BE_DisplayTable (
00135     IN  PBINDING_ENTRY              pbeBindingTable,
00136     IN  ULONG                       ulNumBindings)
00137 /*++
00138
00139 Routine Description
00140     Displays a binding entry.
00141
00142 Locks
00143     None.
00144
00145 Arguments
00146     pbeBindingTable     pointer to the table of binding entries
00147     ulNumBindings       # binding entries in the table
00148
00149 Return Value
00150     NO_ERROR            always
00151
00152 --*/
00153 {
00154     ULONG i;
00155
00156     if (!pbeBindingTable)
00157         return NO_ERROR;
00158
00159     for (i = 0; i < ulNumBindings; i++)
00160     {
00161         TRACE1(NETWORK, "ipAddress %s",
00162                INET_NTOA(pbeBindingTable[i].ipAddress));
00163         TRACE1(NETWORK, "ipMask %s",
00164                INET_NTOA(pbeBindingTable[i].ipMask));
00165     }
00166
00167     return NO_ERROR;
00168 }
00169 #endif // DEBUG
00170
00171
00172
00173 #ifdef DEBUG
00174 static
00175 VOID
00176 DisplayInterfaceEntry (
00177     IN  PLIST_ENTRY                 pleEntry)
00178 /*++
00179
00180 Routine Description
00181     Displays an INTERFACE_ENTRY object.
00182
00183 Locks
00184     None
00185
00186 Arguments
00187     pleEntry            address of the 'leInterfaceTableLink' field
00188
00189 Return Value
00190     None
00191
00192 --*/
00193 {
00194     IE_Display(CONTAINING_RECORD(pleEntry,
00195                                  INTERFACE_ENTRY,
00196                                  leInterfaceTableLink));
00197 }
00198 #else
00199 #define DisplayInterfaceEntry       NULL
00200 #endif // DEBUG
00201
00202
00203
00204 static
00205 VOID
00206 FreeInterfaceEntry (
00207     IN  PLIST_ENTRY                 pleEntry)
00208 /*++
00209
00210 Routine Description
00211     Called by HT_Destroy, the destructor of the primary access structure.
00212     Removes an INTERFACE_ENTRY object from all secondary access structures.
00213
00214 Locks
00215     None
00216
00217 Arguments
00218     pleEntry            address of the 'leInterfaceTableLink' field
00219
00220 Return Value
00221     None
00222
00223 --*/
00224 {
00225     PINTERFACE_ENTRY pie = NULL;
00226
00227     pie = CONTAINING_RECORD(pleEntry, INTERFACE_ENTRY, leInterfaceTableLink);
00228
00229     // remove from all secondary access structures.
00230     RemoveEntryList(&(pie->leIndexSortedListLink));
00231
00232     // initialize pointers to indicate that the entry has been deleted
00233     InitializeListHead(&(pie->leInterfaceTableLink));
00234     InitializeListHead(&(pie->leIndexSortedListLink));
00235
00236     IE_Destroy(pie);
00237 }
00238
00239
00240
00241 static
00242 ULONG
00243 HashInterfaceEntry (
00244     IN  PLIST_ENTRY                 pleEntry)
00245 /*++
00246
00247 Routine Description
00248     Computes the hash value of an INTERFACE_ENTRY object.
00249
00250 Locks
00251     None
00252
00253 Arguments
00254     pleEntry            address of the 'leInterfaceTableLink' field
00255
00256 Return Value
00257     None
00258
00259 --*/
00260 {
00261     PINTERFACE_ENTRY pie = CONTAINING_RECORD(pleEntry,
00262                                              INTERFACE_ENTRY,
00263                                              leInterfaceTableLink);
00264
00265     return (pie->dwIfIndex % INTERFACE_TABLE_BUCKETS);
00266 }
00267
00268
00269
00270 static
00271 LONG
00272 CompareInterfaceEntry (
00273     IN  PLIST_ENTRY                 pleKeyEntry,
00274     IN  PLIST_ENTRY                 pleTableEntry)
00275 /*++
00276
00277 Routine Description
00278     Compares the interface indices of two INTERFACE_ENTRY objects.
00279
00280 Locks
00281     None
00282
00283 Arguments
00284     pleTableEntry       address of the 'leInterfaceTableLink' fields
00285     pleKeyEntry             within the two objects
00286
00287 Return Value
00288     None
00289
00290 --*/
00291 {
00292     PINTERFACE_ENTRY pieA, pieB;
00293     pieA = CONTAINING_RECORD(pleKeyEntry,
00294                              INTERFACE_ENTRY,
00295                              leInterfaceTableLink);
00296     pieB = CONTAINING_RECORD(pleTableEntry,
00297                              INTERFACE_ENTRY,
00298                              leInterfaceTableLink);
00299
00300     if (pieA->dwIfIndex < pieB->dwIfIndex)
00301         return -1;
00302     else if (pieA->dwIfIndex is pieB->dwIfIndex)
00303         return 0;
00304     else
00305         return 1;
00306 }
00307
00308
00309
00310 #ifdef DEBUG
00311 static
00312 VOID
00313 DisplayIndexInterfaceEntry (
00314     IN  PLIST_ENTRY                 pleEntry)
00315 /*++
00316
00317 Routine Description
00318     Displays an INTERFACE_ENTRY object.
00319
00320 Locks
00321     None
00322
00323 Arguments
00324     pleEntry            address of the 'leIndexSortedListLink' field
00325
00326 Return Value
00327     None
00328
00329 --*/
00330 {
00331     IE_Display(CONTAINING_RECORD(pleEntry,
00332                                  INTERFACE_ENTRY,
00333                                  leIndexSortedListLink));
00334 }
00335 #else
00336 #define DisplayIndexInterfaceEntry  NULL
00337 #endif // DEBUG
00338
00339
00340
00341 static
00342 LONG
00343 CompareIndexInterfaceEntry (
00344     IN  PLIST_ENTRY                 pleKeyEntry,
00345     IN  PLIST_ENTRY                 pleTableEntry)
00346 /*++
00347
00348 Routine Description
00349     Compares the interface indices of two INTERFACE_ENTRY objects.
00350
00351 Locks
00352     None
00353
00354 Arguments
00355     pleTableEntry       address of the 'leIndexSortedListLink' fields
00356     pleKeyEntry             within the two objects
00357
00358 Return Value
00359     None
00360
00361 --*/
00362 {
00363     PINTERFACE_ENTRY pieA, pieB;
00364     pieA = CONTAINING_RECORD(pleKeyEntry,
00365                              INTERFACE_ENTRY,
00366                              leIndexSortedListLink);
00367     pieB = CONTAINING_RECORD(pleTableEntry,
00368                              INTERFACE_ENTRY,
00369                              leIndexSortedListLink);
00370
00371     if (pieA->dwIfIndex < pieB->dwIfIndex)
00372         return -1;
00373     else if (pieA->dwIfIndex is pieB->dwIfIndex)
00374         return 0;
00375     else
00376         return 1;
00377 }
00378
00379
00380
00381 DWORD
00382 IE_Create (
00383     IN  PWCHAR                      pwszIfName,
00384     IN  DWORD                       dwIfIndex,
00385     IN  WORD                        wAccessType,
00386     OUT PINTERFACE_ENTRY            *ppieInterfaceEntry)
00387 /*++
00388
00389 Routine Description
00390     Creates an interface entry.
00391
00392 Locks
00393     None
00394
00395 Arguments
00396     ppieInterfaceEntry  pointer to the interface entry address
00397
00398 Return Value
00399     NO_ERROR            if success
00400     Failure code        o/w
00401
00402 --*/
00403 {
00404     DWORD               dwErr = NO_ERROR;
00405     ULONG               ulNameLength;
00406     PINTERFACE_ENTRY    pieEntry; // scratch
00407
00408     // validate parameters
00409     if (!ppieInterfaceEntry || !pwszIfName)
00410         return ERROR_INVALID_PARAMETER;
00411
00412     *ppieInterfaceEntry = NULL;
00413
00414     do                          // breakout loop
00415     {
00416         // allocate and zero out the interface entry structure
00417         MALLOC(&pieEntry, sizeof(INTERFACE_ENTRY), &dwErr);
00418         if (dwErr != NO_ERROR)
00419             break;
00420
00421
00422         // initialize fields with default values
00423
00424         InitializeListHead(&(pieEntry->leInterfaceTableLink));
00425         InitializeListHead(&(pieEntry->leIndexSortedListLink));
00426
00427         // pieEntry->pwszIfName         = NULL;
00428
00429         pieEntry->dwIfIndex             = dwIfIndex;
00430
00431         // pieEntry->ulNumBindings      = 0;
00432         // pieEntry->pbeBindingTable    = NULL;
00433
00434
00435         // pieEntry->dwFlags            = 0; // disabled unbound pointtopoint
00436         if (wAccessType is IF_ACCESS_BROADCAST)
00437             pieEntry->dwFlags           |= IEFLAG_MULTIACCESS;
00438
00439         IP_ASSIGN(&(pieEntry->ipAddress), IP_LOWEST);
00440         pieEntry->sRawSocket            = INVALID_SOCKET;
00441
00442         // pieEntry->hReceiveEvent      = NULL;
00443         // pieEntry->hReceiveWait       = NULL;
00444
00445         // pieEntry->hPeriodicTimer     = NULL;
00446
00447         // pieEntry->ulMetric           = 0;
00448
00449         // pieEntry->iisStats           zero'ed out
00450
00451
00452         // initialize name
00453         ulNameLength = wcslen(pwszIfName) + 1;
00454         MALLOC(&(pieEntry->pwszIfName), ulNameLength * sizeof(WCHAR), &dwErr);
00455         if(dwErr != NO_ERROR)
00456             break;
00457         wcsncpy(pieEntry->pwszIfName, pwszIfName, ulNameLength-1);
00458
00459
00460         // initialize   ReceiveEvent (signalled when input arrives).
00461         // Auto-Reset Event: state automatically reset to nonsignaled after
00462         // a single waiting thread is released.  Initially non signalled
00463         pieEntry->hReceiveEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00464         if (pieEntry->hReceiveEvent is NULL)
00465         {
00466             dwErr = GetLastError();
00467             TRACE1(NETWORK, "Error %u creating Receive Event", dwErr);
00468             LOGERR0(CREATE_EVENT_FAILED, dwErr);
00469
00470             break;
00471         }
00472
00473
00474         // register     ReceiveWait for this interface
00475         if (!RegisterWaitForSingleObject(&(pieEntry->hReceiveWait),
00476                                          pieEntry->hReceiveEvent,
00477                                          NM_CallbackNetworkEvent,
00478                                          (PVOID) dwIfIndex,
00479                                          INFINITE,
00480                                          WT_EXECUTEONLYONCE))
00481         {
00482             dwErr = GetLastError();
00483             TRACE1(NETWORK, "Error %u registering ReceiveWait", dwErr);
00484             LOGERR0(REGISTER_WAIT_FAILED, dwErr);
00485
00486             break;
00487         }
00488
00489
00490         *ppieInterfaceEntry = pieEntry; // all's well :)
00491     } while (FALSE);
00492
00493     if (dwErr != NO_ERROR)
00494     {
00495         // something went wrong, so cleanup.
00496         TRACE2(NETWORK, "Failed to create interface entry for %S (%u)",
00497                pwszIfName, dwIfIndex);
00498         IE_Destroy(pieEntry);
00499     }
00500
00501     return dwErr;
00502 }
00503
00504
00505
00506 DWORD
00507 IE_Destroy (
00508     IN  PINTERFACE_ENTRY            pieInterfaceEntry)
00509 /*++
00510
00511 Routine Description
00512     Destroys an interface entry.
00513
00514 Locks
00515     Assumes exclusive access to the entry by virute of it having been
00516     removed from all access data structures (lists, tables, ...)
00517
00518     NOTE: Should NOT be called with g_ce.neNetworkEntry.rwlLock held!  The
00519     call to UnregisterWaitEx blocks till all queued callbacks for
00520     pieInterfaceEntry->hReceiveEvent finish execution.  These callbacks may
00521     acquire g_ce.neNetworkEntry.rwlLock, causing deadlock.
00522
00523 Arguments
00524     pieInterfaceEntry   pointer to the interface entry
00525
00526 Return Value
00527     NO_ERROR            always
00528
00529 --*/
00530 {
00531     if (!pieInterfaceEntry)
00532         return NO_ERROR;
00533
00534     if (INTERFACE_IS_BOUND(pieInterfaceEntry))
00535         IE_UnBindInterface(pieInterfaceEntry);
00536
00537     if (INTERFACE_IS_ACTIVE(pieInterfaceEntry))
00538         IE_DeactivateInterface(pieInterfaceEntry);
00539
00540
00541     // PeriodicTimer should have been destroyed
00542     RTASSERT(pieInterfaceEntry->hPeriodicTimer is NULL);
00543
00544     // deregister   ReceiveWait
00545     if (pieInterfaceEntry->hReceiveWait)
00546         UnregisterWaitEx(pieInterfaceEntry->hReceiveWait,
00547                          INVALID_HANDLE_VALUE);
00548
00549     // delete       ReceiveEvent
00550     if (pieInterfaceEntry->hReceiveEvent)
00551         CloseHandle(pieInterfaceEntry->hReceiveEvent);
00552
00553     // BindingTable and RawSocket should have been destroyed
00554     RTASSERT(pieInterfaceEntry->pbeBindingTable is NULL);
00555     RTASSERT(pieInterfaceEntry->sRawSocket is INVALID_SOCKET);
00556
00557     // delete       IfName
00558     FREE(pieInterfaceEntry->pwszIfName);
00559
00560     // Entry should have been removed from all access structures
00561     RTASSERT(IsListEmpty(&(pieInterfaceEntry->leInterfaceTableLink)));
00562     RTASSERT(IsListEmpty(&(pieInterfaceEntry->leIndexSortedListLink)));
00563
00564     // deallocate the interface entry structure
00565     FREE(pieInterfaceEntry);
00566
00567     return NO_ERROR;
00568 }
00569
00570
00571
00572 #ifdef DEBUG
00573 DWORD
00574 IE_Display (
00575     IN  PINTERFACE_ENTRY            pieInterfaceEntry)
00576 /*++
00577
00578 Routine Description
00579     Displays an interface entry.
00580
00581 Locks
00582     Assumes the interface entry is locked for reading.
00583
00584 Arguments
00585     pieInterfaceEntry   pointer to the interface entry to be displayed
00586
00587 Return Value
00588     NO_ERROR            always
00589
00590 --*/
00591 {
00592     if (!pieInterfaceEntry)
00593         return NO_ERROR;
00594
00595     TRACE3(NETWORK,
00596            "IfName %S, IfIndex %u, AccessType %u",
00597            pieInterfaceEntry->pwszIfName,
00598            pieInterfaceEntry->dwIfIndex,
00599            INTERFACE_IS_MULTIACCESS(pieInterfaceEntry));
00600
00601     TRACE1(NETWORK, "NumBindings %u", pieInterfaceEntry->ulNumBindings);
00602     BE_DisplayTable(pieInterfaceEntry->pbeBindingTable,
00603                     pieInterfaceEntry->ulNumBindings);
00604
00605     TRACE2(NETWORK,
00606            "IfAddress %s Flags %u",
00607            INET_NTOA(pieInterfaceEntry->ipAddress),
00608            pieInterfaceEntry->dwFlags);
00609
00610     TRACE2(NETWORK,
00611            "Metric %u, NumPackets %u",
00612            pieInterfaceEntry->ulMetric,
00613            pieInterfaceEntry->iisStats.ulNumPackets);
00614
00615     return NO_ERROR;
00616 }
00617 #endif // DEBUG
00618
00619
00620
00621 DWORD
00622 IE_Insert (
00623     IN  PINTERFACE_ENTRY            pieIfEntry)
00624 /*++
00625
00626 Routine Description
00627     Inserts an interface entry in all access structures,
00628     primary and secondary.
00629
00630 Locks
00631     Assumes exclusive access to the interface table and index sorted list
00632     i.e. (g_ce.pneNetworkEntry)->rwlLock held in write mode.
00633
00634 Arguments
00635     pieIfEntry              pointer to the interface entry
00636
00637 Return Value
00638     NO_ERROR                success
00639     ERROR_INVALID_PARAMETER o/w (interface entry already exists)
00640
00641 --*/
00642 {
00643     DWORD dwErr = NO_ERROR;
00644
00645     do                          // breakout loop
00646     {
00647         dwErr = HT_InsertEntry((g_ce.pneNetworkEntry)->phtInterfaceTable,
00648                                &(pieIfEntry->leInterfaceTableLink));
00649         if (dwErr != NO_ERROR)
00650         {
00651             TRACE2(NETWORK, "Error interface %S (%u) already exists",
00652                    pieIfEntry->pwszIfName, pieIfEntry->dwIfIndex);
00653             LOGERR0(INTERFACE_PRESENT, dwErr);
00654             break;
00655         }
00656
00657         // insert in all tables, lists...
00658         InsertSortedList(&((g_ce.pneNetworkEntry)->leIndexSortedList),
00659                          &(pieIfEntry->leIndexSortedListLink),
00660                          CompareIndexInterfaceEntry);
00661     } while (FALSE);
00662
00663     return dwErr;
00664 }
00665
00666
00667
00668 DWORD
00669 IE_Delete (
00670     IN  DWORD                       dwIfIndex,
00671     OUT PINTERFACE_ENTRY            *ppieIfEntry)
00672 /*++
00673
00674 Routine Description
00675     Deletes an interface entry from all access structures,
00676     primary and secondary.
00677
00678 Locks
00679     Assumes exclusive access to the interface table and index sorted list
00680     i.e. (g_ce.pneNetworkEntry)->rwlLock held in write mode.
00681
00682 Arguments
00683     dwIfIndex       the positive integer used to identify the interface.
00684     ppieIfEntry     address of the pointer to the interface entry
00685
00686 Return Value
00687     NO_ERROR                success
00688     ERROR_INVALID_PARAMETER o/w (interface entry does not exist)
00689
00690 --*/
00691 {
00692     DWORD           dwErr           = NO_ERROR;
00693     INTERFACE_ENTRY ieKey;
00694     PLIST_ENTRY     pleListEntry    = NULL;
00695
00696     *ppieIfEntry = NULL;
00697
00698     do                          // breakout loop
00699     {
00700         // remove from interface table (primary)
00701         ZeroMemory(&ieKey, sizeof(INTERFACE_ENTRY));
00702         ieKey.dwIfIndex = dwIfIndex;
00703
00704         dwErr = HT_DeleteEntry((g_ce.pneNetworkEntry)->phtInterfaceTable,
00705                                &(ieKey.leInterfaceTableLink),
00706                                &pleListEntry);
00707         if (dwErr != NO_ERROR)
00708         {
00709             TRACE1(NETWORK, "Error interface %u has vanished", dwIfIndex);
00710             LOGWARN0(INTERFACE_ABSENT, dwErr);
00711             break;
00712         }
00713
00714         *ppieIfEntry = CONTAINING_RECORD(pleListEntry,
00715                                          INTERFACE_ENTRY,
00716                                          leInterfaceTableLink);
00717
00718         // remove from all other tables, lists... (secondary)
00719         RemoveEntryList(&((*ppieIfEntry)->leIndexSortedListLink));
00720
00721         // initialize pointers to indicate that the entry has been deleted
00722         InitializeListHead(&((*ppieIfEntry)->leInterfaceTableLink));
00723         InitializeListHead(&((*ppieIfEntry)->leIndexSortedListLink));
00724     } while (FALSE);
00725
00726     return dwErr;
00727 }
00728
00729
00730
00731 BOOL
00732 IE_IsPresent (
00733     IN  DWORD                       dwIfIndex)
00734 /*++
00735
00736 Routine Description
00737     Is interface entry present in interface table?
00738
00739 Locks
00740     Assumes shared access to the interface table
00741     i.e. (g_ce.pneNetworkEntry)->rwlLock held in read mode.
00742
00743 Arguments
00744     dwIfIndex       the positive integer used to identify the interface.
00745
00746 Return Value
00747     TRUE            entry present
00748     FALSE           o/w
00749
00750 --*/
00751 {
00752     DWORD           dwErr = NO_ERROR;
00753     INTERFACE_ENTRY ieKey;
00754
00755     ZeroMemory(&ieKey, sizeof(INTERFACE_ENTRY));
00756     ieKey.dwIfIndex = dwIfIndex;
00757
00758     return HT_IsPresentEntry((g_ce.pneNetworkEntry)->phtInterfaceTable,
00759                              &(ieKey.leInterfaceTableLink));
00760 }
00761
00762
00763
00764 DWORD
00765 IE_Get (
00766     IN  DWORD                       dwIfIndex,
00767     OUT PINTERFACE_ENTRY            *ppieIfEntry)
00768 /*++
00769
00770 Routine Description
00771     Retrieves an interface entry from the interface table,
00772     the primary address strucutre.
00773
00774 Locks
00775     Assumes shared access to the interface table
00776     i.e. (g_ce.pneNetworkEntry)->rwlLock held in read mode.
00777
00778 Arguments
00779     dwIfIndex       the positive integer used to identify the interface.
00780     ppieIfEntry     address of the pointer to the interface entry
00781
00782 Return Value
00783     NO_ERROR                success
00784     ERROR_INVALID_PARAMETER o/w (interface entry does not exist)
00785
00786 --*/
00787 {
00788     DWORD           dwErr           = NO_ERROR;
00789     INTERFACE_ENTRY ieKey;
00790     PLIST_ENTRY     pleListEntry    = NULL;
00791
00792     *ppieIfEntry = NULL;
00793
00794     do                          // breakout loop
00795     {
00796         ZeroMemory(&ieKey, sizeof(INTERFACE_ENTRY));
00797         ieKey.dwIfIndex = dwIfIndex;
00798
00799         dwErr = HT_GetEntry((g_ce.pneNetworkEntry)->phtInterfaceTable,
00800                             &(ieKey.leInterfaceTableLink),
00801                             &pleListEntry);
00802
00803         if (dwErr != NO_ERROR)
00804         {
00805             TRACE1(NETWORK, "Error interface %u has vanished", dwIfIndex);
00806             LOGWARN0(INTERFACE_ABSENT, dwErr);
00807             break;
00808         }
00809
00810         *ppieIfEntry = CONTAINING_RECORD(pleListEntry,
00811                                          INTERFACE_ENTRY,
00812                                          leInterfaceTableLink);
00813     } while (FALSE);
00814
00815     return dwErr;
00816 }
00817
00818
00819
00820 DWORD
00821 IE_GetIndex (
00822     IN  DWORD                       dwIfIndex,
00823     IN  MODE                        mMode,
00824     OUT PINTERFACE_ENTRY            *ppieIfEntry)
00825 /*++
00826
00827 Routine Description
00828     Retrieves an interface entry from the index sorted list,
00829     the secondary address strucutre.
00830
00831 Locks
00832     Assumes shared access to the index sorted list
00833     i.e. (g_ce.pneNetworkEntry)->rwlLock held in read mode.
00834
00835 Arguments
00836     dwIfIndex       the positive integer used to identify the interface.
00837     mMode           mode of access (GET_EXACT, GET_FIRST, GET_NEXT)
00838     ppieIfEntry     address of the pointer to the interface entry
00839
00840 Return Value
00841     NO_ERROR                success
00842     ERROR_NO_MORE_ITEMS     o/w
00843
00844 --*/
00845 {
00846     INTERFACE_ENTRY ieKey;
00847     PLIST_ENTRY     pleHead = NULL, pleEntry = NULL;
00848
00849     if (!ppieIfEntry)
00850     {
00851         return ERROR_INVALID_PARAMETER;
00852     }
00853
00854     *ppieIfEntry = NULL;
00855
00856     pleHead = &((g_ce.pneNetworkEntry)->leIndexSortedList);
00857
00858     if (IsListEmpty(pleHead))
00859         return ERROR_NO_MORE_ITEMS;
00860
00861     ZeroMemory(&ieKey, sizeof(INTERFACE_ENTRY));
00862     ieKey.dwIfIndex = (mMode is GET_FIRST) ? 0 : dwIfIndex;
00863
00864     // this either gets the exact match or the next entry
00865     FindSortedList(pleHead,
00866                    &(ieKey.leIndexSortedListLink),
00867                    &pleEntry,
00868                    CompareIndexInterfaceEntry);
00869
00870     // reached end of list
00871     if (pleEntry is NULL)
00872     {
00873         RTASSERT(mMode != GET_FIRST); // should have got the first entry
00874         return ERROR_NO_MORE_ITEMS;
00875     }
00876
00877     *ppieIfEntry = CONTAINING_RECORD(pleEntry,
00878                                      INTERFACE_ENTRY,
00879                                      leIndexSortedListLink);
00880
00881     switch (mMode)
00882     {
00883         case GET_FIRST:
00884             return NO_ERROR;
00885
00886         case GET_EXACT:
00887             // found an exact match
00888             if ((*ppieIfEntry)->dwIfIndex is dwIfIndex)
00889                 return NO_ERROR;
00890             else
00891             {
00892                 *ppieIfEntry = NULL;
00893                 return ERROR_NO_MORE_ITEMS;
00894             }
00895
00896         case GET_NEXT:
00897             // found an exact match
00898             if ((*ppieIfEntry)->dwIfIndex is dwIfIndex)
00899             {
00900                 pleEntry = pleEntry->Flink; // get next entry
00901                 if (pleEntry is pleHead)    // end of list
00902                 {
00903                     *ppieIfEntry = NULL;
00904                     return ERROR_NO_MORE_ITEMS;
00905                 }
00906
00907                 *ppieIfEntry = CONTAINING_RECORD(pleEntry,
00908                                                  INTERFACE_ENTRY,
00909                                                  leIndexSortedListLink);
00910             }
00911
00912             return NO_ERROR;
00913
00914         default:
00915             RTASSERT(FALSE);    // never reached
00916     }
00917
00918     return NO_ERROR;
00919 }
00920
00921
00922
00923 DWORD
00924 IE_BindInterface (
00925     IN  PINTERFACE_ENTRY            pie,
00926     IN  PIP_ADAPTER_BINDING_INFO    pBinding)
00927 /*++
00928
00929 Routine Description
00930     Binds an interface.
00931
00932 Locks
00933     Assumes the interface entry is locked for writing.
00934
00935 Arguments
00936     pie                 pointer to the interface entry
00937     pBinding            info about the addresses on the interface
00938
00939 Return Value
00940     NO_ERROR            success
00941     Error Code          o/w
00942
00943 --*/
00944 {
00945     DWORD   dwErr = NO_ERROR;
00946
00947     do                          // breakout loop
00948     {
00949         // fail if the interface is already bound
00950         if (INTERFACE_IS_BOUND(pie))
00951         {
00952             dwErr = ERROR_INVALID_PARAMETER;
00953             TRACE2(NETWORK, "Error interface %S (%u) is already bound",
00954                    pie->pwszIfName, pie->dwIfIndex);
00955             break;
00956         }
00957
00958
00959         dwErr = BE_CreateTable (pBinding,
00960                                 &(pie->pbeBindingTable),
00961                                 &(pie->ipAddress));
00962         if (dwErr != NO_ERROR)
00963             break;
00964
00965         pie->ulNumBindings = pBinding->AddressCount;
00966
00967         // set the "bound" flag
00968         pie->dwFlags |= IEFLAG_BOUND;
00969     } while (FALSE);
00970
00971     return dwErr;
00972 }
00973
00974
00975
00976 DWORD
00977 IE_UnBindInterface (
00978     IN  PINTERFACE_ENTRY            pie)
00979 /*++
00980
00981 Routine Description
00982     UnBinds an interface.
00983
00984 Locks
00985     Assumes the interface entry is locked for writing.
00986
00987 Arguments
00988     pie                 pointer to the interface entry
00989
00990 Return Value
00991     NO_ERROR            success
00992     Error Code          o/w
00993
00994 --*/
00995 {
00996     DWORD   dwErr = NO_ERROR;
00997
00998     do                          // breakout loop
00999     {
01000         // fail if the interface is already unbound
01001         if (INTERFACE_IS_UNBOUND(pie))
01002         {
01003             dwErr = ERROR_INVALID_PARAMETER;
01004             TRACE2(NETWORK, "interface %S (%u) already unbound",
01005                    pie->pwszIfName, pie->dwIfIndex);
01006             break;
01007         }
01008
01009         // clear the "bound" flag
01010         pie->dwFlags &= ~IEFLAG_BOUND;
01011
01012         IP_ASSIGN(&(pie->ipAddress), IP_LOWEST);
01013
01014         BE_DestroyTable(pie->pbeBindingTable);
01015         pie->pbeBindingTable    = NULL;
01016         pie->ulNumBindings      = 0;
01017     } while (FALSE);
01018
01019     return dwErr;
01020 }
01021
01022
01023
01024 DWORD
01025 IE_ActivateInterface (
01026     IN  PINTERFACE_ENTRY            pie)
01027 /*++
01028
01029 Routine Description
01030     Activates an interface by creating a socket and starting a timer.
01031     The socket is bound to the interface address.
01032     Interface is assumed to have atleast one binding.
01033
01034 Locks
01035     Assumes the interface entry is locked for writing.
01036
01037 Arguments
01038     pie                 pointer to the interface entry
01039
01040 Return Value
01041     NO_ERROR            success
01042     Error Code          o/w
01043
01044 --*/
01045 {
01046     DWORD   dwErr = NO_ERROR;
01047
01048     do                          // breakout loop
01049     {
01050         // fail if the interface is already active
01051         if (INTERFACE_IS_ACTIVE(pie))
01052         {
01053             dwErr = ERROR_INVALID_PARAMETER;
01054             TRACE0(NETWORK, "Interface already active");
01055             break;
01056         }
01057
01058         // set the "active" flag
01059         pie->dwFlags |= IEFLAG_ACTIVE;
01060
01061         // create a socket for the interface
01062         dwErr = SocketCreate(pie->ipAddress,
01063                              pie->hReceiveEvent,
01064                              &(pie->sRawSocket));
01065         if (dwErr != NO_ERROR)
01066         {
01067             TRACE1(NETWORK, "Error creating socket for %s",
01068                    INET_NTOA(pie->ipAddress));
01069             break;
01070         }
01071
01072         // start timer for sending protocol packets
01073         CREATE_TIMER(&pie->hPeriodicTimer ,
01074                      NM_CallbackPeriodicTimer,
01075                      (PVOID) pie->dwIfIndex,
01076                      PERIODIC_INTERVAL,
01077                      &dwErr);
01078         if (dwErr != NO_ERROR)
01079             break;
01080     } while (FALSE);
01081
01082     if (dwErr != NO_ERROR)
01083     {
01084         TRACE3(NETWORK, "Error %u activating interface %S (%u)",
01085                dwErr, pie->pwszIfName, pie->dwIfIndex);
01086         IE_DeactivateInterface(pie);
01087     }
01088
01089     return dwErr;
01090 }
01091
01092
01093
01094 DWORD
01095 IE_DeactivateInterface (
01096     IN  PINTERFACE_ENTRY            pie)
01097 /*++
01098
01099 Routine Description
01100     Deactivates an interface by stopping the timer and destroying the socket.
01101
01102 Locks
01103     Assumes the interface entry is locked for writing.
01104
01105 Arguments
01106     pie                 pointer to the interface entry
01107
01108 Return Value
01109     NO_ERROR            success
01110     Error Code          o/w
01111
01112 --*/
01113 {
01114     DWORD   dwErr = NO_ERROR;
01115
01116     do                          // breakout loop
01117     {
01118         // fail if the interface is already inactive
01119         if (INTERFACE_IS_INACTIVE(pie))
01120         {
01121             dwErr = ERROR_INVALID_PARAMETER;
01122             TRACE2(NETWORK, "interface %S (%u) already inactive",
01123                    pie->pwszIfName, pie->dwIfIndex);
01124             break;
01125         }
01126
01127         // stop the timer
01128         if (pie->hPeriodicTimer)
01129             DELETE_TIMER(pie->hPeriodicTimer, &dwErr);
01130         pie->hPeriodicTimer = NULL;
01131
01132         // destroy the socket for the interface
01133         dwErr = SocketDestroy(pie->sRawSocket);
01134         pie->sRawSocket     = INVALID_SOCKET;
01135
01136         // clear the "active" flag
01137         pie->dwFlags &= ~IEFLAG_ACTIVE;
01138     } while (FALSE);
01139
01140     return dwErr;
01141 }
01142
01143
01144
01145 DWORD
01146 NE_Create (
01147     OUT PNETWORK_ENTRY              *ppneNetworkEntry)
01148 /*++
01149
01150 Routine Description
01151     Creates a network entry.
01152
01153 Locks
01154     None
01155
01156 Arguments
01157     ppneNetworkEntry    pointer to the network entry address
01158
01159 Return Value
01160     NO_ERROR            if success
01161     Failure code        o/w
01162
01163 --*/
01164 {
01165     DWORD           dwErr = NO_ERROR;
01166     PNETWORK_ENTRY  pneEntry;   // scratch
01167
01168     // validate parameters
01169     if (!ppneNetworkEntry)
01170         return ERROR_INVALID_PARAMETER;
01171
01172     *ppneNetworkEntry = NULL;
01173
01174     do                          // breakout loop
01175     {
01176         // allocate and zero out the network entry structure
01177         MALLOC(&pneEntry, sizeof(NETWORK_ENTRY), &dwErr);
01178         if (dwErr != NO_ERROR)
01179             break;
01180
01181
01182         // initialize fields with default values
01183
01184         // pneEntry->rwlLock                zero'ed out
01185
01186         // pneEntry->phtInterfaceTable      = NULL;
01187
01188         InitializeListHead(&(pneEntry->leIndexSortedList));
01189
01190
01191         // initialize the read-write lock
01192         dwErr = CREATE_READ_WRITE_LOCK(&(pneEntry->rwlLock));
01193         if (dwErr != NO_ERROR)
01194         {
01195             TRACE1(NETWORK, "Error %u creating read-write-lock", dwErr);
01196             LOGERR0(CREATE_RWL_FAILED, dwErr);
01197
01198             break;
01199         }
01200
01201
01202         // allocate the interface table
01203         dwErr = HT_Create(GLOBAL_HEAP,
01204                           INTERFACE_TABLE_BUCKETS,
01205                           DisplayInterfaceEntry,
01206                           FreeInterfaceEntry,
01207                           HashInterfaceEntry,
01208                           CompareInterfaceEntry,
01209                           &(pneEntry->phtInterfaceTable));
01210         if (dwErr != NO_ERROR)
01211         {
01212             TRACE1(NETWORK, "Error %u creating hash-table", dwErr);
01213             LOGERR0(CREATE_HASHTABLE_FAILED, dwErr);
01214
01215             break;
01216         }
01217
01218
01219         *ppneNetworkEntry = pneEntry;
01220     } while (FALSE);
01221
01222     if (dwErr != NO_ERROR)
01223     {
01224         // something went wrong, so cleanup.
01225         TRACE0(NETWORK, "Failed to create nework entry");
01226         NE_Destroy(pneEntry);
01227         pneEntry = NULL;
01228     }
01229
01230     return dwErr;
01231 }
01232
01233
01234
01235 DWORD
01236 NE_Destroy (
01237     IN  PNETWORK_ENTRY              pneNetworkEntry)
01238 /*++
01239
01240 Routine Description
01241     Destroys a network entry.
01242
01243 Locks
01244     Assumes exclusive access to rwlLock by virtue of of no competing threads.
01245
01246 Arguments
01247     pneNetworkEntry     pointer to the network entry
01248
01249 Return Value
01250     NO_ERROR            always
01251
01252 --*/
01253 {
01254     if (!pneNetworkEntry)
01255         return NO_ERROR;
01256
01257     // deallocate the interface table...
01258     // this removes the interface entries from all secondary access
01259     // structures (IndexSortedList, ...) as well since all of them
01260     // share interface entries by containing pointers to the same object.
01261     HT_Destroy(GLOBAL_HEAP, pneNetworkEntry->phtInterfaceTable);
01262     pneNetworkEntry->phtInterfaceTable = NULL;
01263
01264     RTASSERT(IsListEmpty(&(pneNetworkEntry->leIndexSortedList)));
01265
01266     // delete read-write-lock
01267     if (READ_WRITE_LOCK_CREATED(&(pneNetworkEntry->rwlLock)))
01268         DELETE_READ_WRITE_LOCK(&(pneNetworkEntry->rwlLock));
01269
01270     // deallocate the network entry structure
01271     FREE(pneNetworkEntry);
01272
01273     return NO_ERROR;
01274 }
01275
01276
01277
01278 #ifdef DEBUG
01279 DWORD
01280 NE_Display (
01281     IN  PNETWORK_ENTRY              pneNetworkEntry)
01282 /*++
01283
01284 Routine Description
01285     Displays a network entry.
01286
01287 Locks
01288     Acquires shared pneNetworkEntry->rwlLock
01289     Releases        pneNetworkEntry->rwlLock
01290
01291 Arguments
01292     pne                 pointer to the network entry to be displayed
01293
01294 Return Value
01295     NO_ERROR            always
01296
01297 --*/
01298 {
01299     if (!pneNetworkEntry)
01300         return NO_ERROR;
01301
01302
01303     ACQUIRE_READ_LOCK(&(pneNetworkEntry->rwlLock));
01304
01305     TRACE0(NETWORK, "Network Entry...");
01306
01307     TRACE1(NETWORK,
01308            "Interface Table Size %u",
01309            HT_Size(pneNetworkEntry->phtInterfaceTable));
01310
01311     TRACE0(NETWORK, "Interface Table...");
01312     HT_Display(pneNetworkEntry->phtInterfaceTable);
01313
01314     TRACE0(NETWORK, "Index Sorted List...");
01315     MapCarList(&(pneNetworkEntry->leIndexSortedList),
01316                DisplayIndexInterfaceEntry);
01317
01318     RELEASE_READ_LOCK(&(pneNetworkEntry->rwlLock));
01319
01320
01321     return NO_ERROR;
01322 }
01323 #endif // DEBUG
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/STAObject/STAObject.Cpp Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • STAObject

STAObject.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: STAObject.cpp
00004
00005 Summary: Implementation DLL Exports
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021
00022
00023 // Note: Proxy/Stub Information
00024 //      To build a separate proxy/stub DLL,
00025 //      run nmake -f STAObjectps.mk in the project directory.
00026
00027 #include "stdafx.h"
00028 #include "resource.h"
00029 #include <initguid.h>
00030 #include "STAObject.h"
00031
00032 #include "STAObject_i.c"
00033 #include "STATest.h"
00034
00035
00036 CComModule _Module;
00037
00038 BEGIN_OBJECT_MAP(ObjectMap)
00039 OBJECT_ENTRY(CLSID_STATest, CSTATest)
00040 END_OBJECT_MAP()
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 // DLL Entry Point
00044
00045 extern "C"
00046 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00047 {
00048     if (dwReason == DLL_PROCESS_ATTACH)
00049     {
00050         _Module.Init(ObjectMap, hInstance, &LIBID_STAOBJECTLib);
00051         DisableThreadLibraryCalls(hInstance);
00052     }
00053     else if (dwReason == DLL_PROCESS_DETACH)
00054         _Module.Term();
00055     return TRUE;    // ok
00056 }
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // Used to determine whether the DLL can be unloaded by OLE
00060
00061 STDAPI DllCanUnloadNow(void)
00062 {
00063     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00064 }
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // Returns a class factory to create an object of the requested type
00068
00069 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00070 {
00071     return _Module.GetClassObject(rclsid, riid, ppv);
00072 }
00073
00074 /////////////////////////////////////////////////////////////////////////////
00075 // DllRegisterServer - Adds entries to the system registry
00076
00077 STDAPI DllRegisterServer(void)
00078 {
00079     // registers object, typelib and all interfaces in typelib
00080     return _Module.RegisterServer(TRUE);
00081 }
00082
00083 /////////////////////////////////////////////////////////////////////////////
00084 // DllUnregisterServer - Removes entries from the system registry
00085
00086 STDAPI DllUnregisterServer(void)
00087 {
00088     return _Module.UnregisterServer(TRUE);
00089 }
00090
00091
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMFT/clUtil.h Source File

  • Web
  • NetMeeting
  • NMFT

clUtil.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMFT.EXE
00003 //  File:       CLUTIL.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 // Utility Classes
00017
00018 #ifndef _CL_UTIL_H_
00019 #define _CL_UTIL_H_
00020
00021
00022 //****************************************************************************
00023 //
00024 // CLASS RefCount
00025 //
00026 //****************************************************************************
00027
00028 class RefCount
00029 {
00030 private:
00031    LONG m_cRef;
00032
00033 public:
00034    RefCount();
00035    // Virtual destructor defers to destructor of derived class.
00036    virtual ~RefCount();
00037
00038    // IUnknown methods
00039
00040    ULONG STDMETHODCALLTYPE AddRef(void);
00041    ULONG STDMETHODCALLTYPE Release(void);
00042 };
00043
00044
00045 //****************************************************************************
00046 //
00047 // CLASS CNotify
00048 //
00049 // Notification sink
00050 //
00051 //****************************************************************************
00052
00053 class CNotify
00054 {
00055 private:
00056     DWORD  m_dwCookie;
00057   IUnknown * m_pUnk;
00058     IConnectionPoint           * m_pcnp;
00059     IConnectionPointContainer  * m_pcnpcnt;
00060 public:
00061     CNotify(void);
00062     ~CNotify();
00063
00064     HRESULT Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN);
00065     HRESULT Disconnect(void);
00066
00067     IUnknown * GetPunk() {return m_pUnk;}
00068 };
00069
00070
00071 //****************************************************************************
00072 //
00073 // CLASS COBLIST
00074 //
00075 //****************************************************************************
00076
00077 #define POSITION COBNODE*
00078
00079 struct COBNODE
00080 {
00081   POSITION  pNext;
00082   void*   pItem;
00083 };
00084
00085 class COBLIST
00086 {
00087 protected:
00088   POSITION m_pHead;
00089   POSITION m_pTail;
00090   int      m_cItem;
00091     virtual BOOL Compare(void* pItemToCompare, void* pComparator)
00092                        { return(pItemToCompare == pComparator); }
00093 public:
00094   COBLIST() : m_pHead(NULL), m_pTail(NULL), m_cItem(0) { }
00095     virtual         ~COBLIST();
00096
00097   virtual void *  RemoveAt(POSITION rPos);
00098     void            EmptyList();
00099   POSITION      AddTail(void* pItem);
00100   void *        GetNext(POSITION& rPos);
00101     void *          SafeGetFromPosition(POSITION rPos);
00102     POSITION        GetPosition(void* pItem);
00103     POSITION        Lookup(void* pComparator);
00104   POSITION      GetHeadPosition()  { return (m_pHead); }
00105   POSITION      GetTailPosition()  { return (m_pTail); }
00106   BOOL        IsEmpty()          { return (!m_pHead); }
00107   int             GetItemCount()     { return (m_cItem); }
00108 #ifdef DEBUG
00109   void *        GetHead();
00110   void *        GetTail();
00111   void *        RemoveHead();
00112   void *          RemoveTail();
00113   void *        GetFromPosition(POSITION rPos);
00114 #else
00115   void *        GetHead()          { return GetFromPosition(GetHeadPosition());}
00116   void *          GetTail()          { return m_pTail->pItem;}
00117   void *        RemoveHead()       { return RemoveAt(m_pHead); }
00118   void *          RemoveTail()       { return RemoveAt(m_pTail); }
00119   void *        GetFromPosition(POSITION rPos){return(rPos->pItem);}
00120 #endif
00121 };
00122
00123 //****************************************************************************
00124 //
00125 // Utility Functions
00126 //
00127 //****************************************************************************
00128
00129 POSITION AddNode(PVOID pv, COBLIST ** ppList);
00130 PVOID RemoveNode(POSITION * pPos, COBLIST *pList);
00131
00132
00133 //****************************************************************************
00134 //
00135 // CLASS BSTRING
00136 //
00137 //****************************************************************************
00138
00139 class BSTRING
00140 {
00141 private:
00142   BSTR   m_bstr;
00143
00144 public:
00145   // Constructors
00146   BSTRING() {m_bstr = NULL;}
00147
00148   inline BSTRING(LPCWSTR lpcwString);
00149
00150 #if !defined(UNICODE)
00151   // We don't support construction from an ANSI string in the Unicode build.
00152   BSTRING(LPCSTR lpcString);
00153 #endif // !defined(UNICODE)
00154
00155   // Destructor
00156   inline ~BSTRING();
00157
00158   // Cast to BSTR
00159   operator BSTR() {return m_bstr;}
00160   inline LPBSTR GetLPBSTR(void);
00161 };
00162
00163
00164 BSTRING::BSTRING(LPCWSTR lpcwString)
00165 {
00166   if (NULL != lpcwString)
00167   {
00168     m_bstr = SysAllocString(lpcwString);
00169     ASSERT(NULL != m_bstr);
00170   }
00171   else
00172   {
00173     m_bstr = NULL;
00174   }
00175 }
00176
00177 BSTRING::~BSTRING()
00178 {
00179   if (NULL != m_bstr)
00180   {
00181     SysFreeString(m_bstr);
00182     m_bstr = NULL;
00183   }
00184 }
00185
00186 inline LPBSTR BSTRING::GetLPBSTR(void)
00187 {
00188   ASSERT(NULL == m_bstr);
00189
00190   return &m_bstr;
00191 }
00192
00193
00194 //****************************************************************************
00195 //
00196 // CLASS BTSTR
00197 //
00198 //****************************************************************************
00199
00200 class BTSTR
00201 {
00202 private:
00203   LPTSTR m_psz;
00204
00205 public:
00206   BTSTR(BSTR bstr);
00207   ~BTSTR();
00208
00209   // Cast to BSTR
00210   operator LPTSTR() {return (NULL == m_psz) ? TEXT("<null>") : m_psz;}
00211 };
00212
00213 LPTSTR PszFromBstr(BSTR bst);
00214
00215
00216 #endif  // _CL_UTIL_H_
00217
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/Resource.h Source File

  • Web
  • NetMeeting
  • NMUI

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by res.rc
00004 //
00005 #define IDS_APP_TITLE                   1
00006 #define IDS_VERSION                     2
00007 #define IDS_SYSMENU                     4
00008 #define ICO_MAIN                        101
00009 #define IDM_APP                         104
00010 #define ID_APPACCEL                     105
00011 #define IDD_CONFERENCE                  106
00012 #define IDD_CALL                        107
00013 #define IDD_SENDFILE                    112
00014 #define IDC_TOOLBAR                     112
00015 #define IDB_TBAR                        114
00016 #define ICO_NOAUDIO                     116
00017 #define ICO_PHONE                       118
00018 #define ICO_SPEAKER                     119
00019 #define ICO_AUDIO                       120
00020 #define IDD_OPTIONS                     123
00021 #define IDD_AUDIO                       124
00022 #define IDD_SHARE                       125
00023 #define IDD_CALL_CONF                   126
00024 #define IDD_SWITCH                      127
00025 #define IDD_LAUNCH                      128
00026 #define IDD_EJECT                       130
00027 #define ICO_TOPMOST                     130
00028 #define IDD_SHOWLOCAL                   131
00029 #define IDD_LOGONOFF                    132
00030 #define IDE_ADDR                        1001
00031 #define IDE_PASSWORD                    1002
00032 #define IDE_APPLICATION                 1010
00033 #define IDE_DATA                        1010
00034 #define IDE_COMMANDLINE                 1011
00035 #define IDE_USERID                      1011
00036 #define IDE_HCONF                       1011
00037 #define IDE_DIRECTORY                   1012
00038 #define IDC_HCONFNOTIFY                 1014
00039 #define IDC_DWUSERID                    1016
00040 #define IDC_USERNAME                    1016
00041 #define IDE_FILENAME                    1017
00042 #define IDB_BROWSE                      1018
00043 #define IDC_USERID                      1022
00044 #define IDL_ADDR_TYPE                   1024
00045 #define IDC_MONITOR                     1025
00046 #define IDL_CALL_TYPE                   1025
00047 #define IDC_HOST                        1026
00048 #define IDE_CONFERENCE_NAME             1027
00049 #define IDC_CALL_USER                   1028
00050 #define IDE_LEVEL                       1028
00051 #define IDE_USER_NAME                   1029
00052 #define IDC_SPIN                        1029
00053 #define IDC_UI_CALL                     1030
00054 #define IDB_ACTIVATE                    1030
00055 #define IDC_UI_JOIN                     1031
00056 #define IDB_SET_LEVEL                   1031
00057 #define IDC_UI_APP_SHARE                1032
00058 #define IDL_APP                         1032
00059 #define IDC_UI_FT                       1033
00060 #define IDB_SHARE                       1033
00061 #define IDC_MSG_OBJECTS                 1034
00062 #define IDB_UNSHARE                     1034
00063 #define IDE_CONFERENCE                  1034
00064 #define IDC_MSG_NOTIFY                  1035
00065 #define IDB_UPDATE                      1035
00066 #define IDB_SWITCH                      1035
00067 #define IDC_ACTIVE                      1036
00068 #define IDC_AUTO_CHAT                   1036
00069 #define IDB_COLLAB                      1036
00070 #define IDC_MSG_TRACE                   1037
00071 #define IDC_PAUSE                       1037
00072 #define IDB_UNCOLLAB                    1037
00073 #define IDL_GUID                        1038
00074 #define IDC_MSG_STATE                   1038
00075 #define IDC_UPDATE                      1049
00076 #define IDC_NOUI                        1050
00077 #define IDC_SHORT                       1051
00078 #define IDC_TALL                        1052
00079 #define IDC_THIN                        1053
00080 #define IDC_WIDE                        1054
00081 #define IDC_VISIBLE                     1055
00082 #define IDC_UP                          1056
00083 #define IDC_DOWN                        1057
00084 #define IDC_LEFT                        1058
00085 #define IDC_RIGHT                       1059
00086 #define IDC_TOPMOST                     1060
00087 #define IDC_E_AUTOSIZE                  1061
00088 #define IDC_PB_AUTOSIZE                 1062
00089 #define IDR_INIT_NORMAL                 1064
00090 #define IDR_INIT_CONTROL                1065
00091 #define IDR_INIT_NO_LAUNCH              1066
00092 #define IDC_S_AUTOSIZE                  1067
00093 #define IDR_INIT_BACKGROUND             1069
00094 #define IDC_LEVEL                       1069
00095 #define IDC_APP_CODE                    1071
00096 #define IDC_SERVER_NAME                 1072
00097 #define IDC_SHOW_FT                     1073
00098 #define IDC_SHOW_CHAT                   1074
00099 #define IDC_SHOW_WB                     1075
00100 #define IDC_SHOW_AS                     1076
00101 #define IDC_SHOW_T126WB                 1077
00102 #define IDC_FINDSOMEONE                 1078
00103 #define IDC_NMCH_FIRST                  5001
00104 #define IDC_NMCH_DATA                   5001
00105 #define IDC_NMCH_AUDIO                  5002
00106 #define IDC_NMCH_SKIPP_THIS_ONE         5004
00107 #define IDC_NMCH_AS                     5005
00108 #define IDC_NMCH_FT                     5006
00109 #define IDC_NMCH_LAST                   5006
00110 #define IDE_NAME                        6000
00111 #define IDL_CONFERENCE                  6001
00112 #define IDL_USERS                       6002
00113 #define IDM_VIEW_SBAR                   40014
00114 #define IDM_VIEW_FONT                   40016
00115 #define IDM_EXIT                        40017
00116 #define IDM_CMD_ENUMCONF                40044
00117 #define IDM_CMD_ENUMUSER                40045
00118 #define IDM_CMD_SETRECDIR               40048
00119 #define IDM_VIEW_CLEAR                  40055
00120 #define IDM_VIEW_ENVIRON                40058
00121 #define IDM_CMD_SETGUID                 40059
00122 #define IDM_CMD_LAUNCHREMOTE            40060
00123 #define IDT_CMD_LAUNCHREMOTE            40061
00124 #define IDM_VIEW_TBAR                   40062
00125 #define IDM_HELP_CONTENTS               40063
00126 #define IDM_CONF_START                  40064
00127 #define IDM_CONF_STOP                   40065
00128 #define IDM_SYSINFO                     40066
00129 #define IDM_CHANNEL_AUDIO               40067
00130 #define IDM_CHANNEL_FT                  40069
00131 #define IDM_CHANNEL_SHARE               40070
00132 #define IDM_CALL                        40071
00133 #define IDM_EJECT                       40072
00134 #define IDM_CHANNEL_DATA                40073
00135 #define IDM_CALL_CANCEL                 40074
00136 #define IDM_MONITOR                     40084
00137 #define IDM_VIEW_MSG                    40085
00138 #define ID_BUTTON40100                  40100
00139 #define ID_BUTTON40101                  40101
00140 #define ID_BUTTON40102                  40102
00141 #define ID_BUTTON40103                  40103
00142 #define ID_BUTTON40104                  40104
00143 #define ID_BUTTON40105                  40105
00144 #define ID_BUTTON40106                  40106
00145 #define ID_BUTTON40107                  40107
00146 #define ID_BUTTON40108                  40108
00147 #define ID_BUTTON40109                  40109
00148 #define ID_BUTTON40110                  40110
00149 #define ID_BUTTON40111                  40111
00150 #define ID_BUTTON40112                  40112
00151 #define ID_BUTTON40113                  40113
00152 #define ID_BUTTON40114                  40114
00153 #define ID_BUTTON40115                  40115
00154 #define ID_BUTTON40116                  40116
00155 #define ID_BUTTON40117                  40117
00156 #define ID_BUTTON40118                  40118
00157 #define ID_BUTTON40119                  40119
00158 #define ID_BUTTON40120                  40120
00159 #define ID_BUTTON40121                  40121
00160 #define ID_BUTTON40122                  40122
00161 #define ID_BUTTON40123                  40123
00162 #define ID_BUTTON40124                  40124
00163 #define ID_BUTTON40125                  40125
00164 #define ID_BUTTON40126                  40126
00165 #define ID_BUTTON40127                  40127
00166 #define ID_BUTTON40140                  40140
00167 #define IDM_OPTIONS                     40141
00168 #define IDM_SWITCH                      40142
00169 #define IDM_CALL_CONF                   40143
00170 #define IDM_VIEW_CHAT                   40144
00171 #define IDM_LAUNCH                      40145
00172 #define IDM_UPDATE                      40146
00173 #define IDM_HELP                        40999
00174 #define IDM_ABOUT                       41000
00175 #define IDM_CMD_CONNECT                 41001
00176 #define IDM_CMD_DISCONNECT              41002
00177 #define IDM_CMD_GETINFO                 41003
00178 #define IDM_CMD_SETINFO                 41004
00179 #define IDM_CMD_SENDDATA                41005
00180 #define IDM_CMD_SENDFILE                41006
00181 #define IDM_CMD_SHAREWINDOW             41007
00182 #define IDM_CMD_ISWINDOWSHARED          41008
00183 #define IDM_CMD_UNSHAREWINDOW           41009
00184 #define IDM_CMD_CANCELTRANSFER          41010
00185 #define IDM_CMD_LISTEN                  41011
00186 #define IDM_CMD_SETNOTIFY               41012
00187 #define IDM_CMD_REMOVENOTIFY            41013
00188 #define IDM_FT_CANCEL                   41014
00189 #define IDM_CONFINFO                    41015
00190 #define IDM_CALL_ACCEPT                 41016
00191 #define IDM_CALL_REJECT                 41017
00192 #define IDM_DATA_ENABLE                 41018
00193 #define IDM_CONF_LEAK                   41019
00194 #define IDM_CONF_LEAK2                  41020
00195 #define IDM_TOPMOST                     41022
00196 #define IDM_SYS_LOGON                   41023
00197 #define IDM_SYS_LOGOFF                  41024
00198 #define IDS_DLLNAME                     41025
00199 #define IDS_SETUPDD_FUNC                41026
00200 #define IDM_SHOWLOCAL                   41027
00201 #define IDM_LOGONOFF                    41028
00202 #define IDM_ENABLE_APPSHARING           41030
00203 #define IDM_IS_SHARING_ENABLED          41031
00204
00205 // Next default values for new objects
00206 //
00207 #ifdef APSTUDIO_INVOKED
00208 #ifndef APSTUDIO_READONLY_SYMBOLS
00209 #define _APS_NEXT_RESOURCE_VALUE        131
00210 #define _APS_NEXT_COMMAND_VALUE         41033
00211 #define _APS_NEXT_CONTROL_VALUE         1074
00212 #define _APS_NEXT_SYMED_VALUE           101
00213 #endif
00214 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Server/BYOTTxEnlister/StdAfx.h Source File

  • Com
  • Services
  • BYOT
  • Server
  • BYOTTxEnlister

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__4C236071_C852_11D2_848F_0080C7A03FC6__INCLUDED_)
00006 #define AFX_STDAFX_H__4C236071_C852_11D2_848F_0080C7A03FC6__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__4C236071_C852_11D2_848F_0080C7A03FC6__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Hello/Hello.Idl Source File

  • NetDS
  • RPC
  • Hello

Hello.Idl

Go to the documentation of this file.
00001 [ uuid (906B0CE0-C70B-1067-B317-00DD010662DA),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface hello
00006 {
00007
00008 void HelloProc([in, string] unsigned char * pszString);
00009
00010 void Shutdown(void);
00011
00012 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/basesnap.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

basesnap.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  This file contains implementations for IClassFactory
00014 //             and the Snap-in's DLL exported functions
00015
00016
00017 #include <ObjBase.h>
00018 #include <InitGuid.h>
00019 #include "Globals.h"
00020 #include "BaseSnap.h"
00021 #include "CompData.h"
00022 #include "About.h"
00023 #include "Registry.h"
00024
00025
00026 #include "TraceMacro.h"
00027 #undef  MODULESTRING
00028 #define MODULESTRING  _T("BaseSnap")
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 //  Implementation of IClassFactory for CComponentData
00033
00034 //---------------------------------------------------------------------------
00035 CClassFactory::CClassFactory( FACTORY_TYPE eFactoryType )
00036 {
00037   m_cRef = 0;
00038   m_FactoryType = eFactoryType;
00039
00040   InterlockedIncrement((long*)&g_uObjectCount);
00041 }
00042
00043
00044 //---------------------------------------------------------------------------
00045 CClassFactory::~CClassFactory()
00046 {
00047   InterlockedDecrement((long*)&g_uObjectCount);
00048 }
00049
00050
00051 //---------------------------------------------------------------------------
00052 STDMETHODIMP CClassFactory::QueryInterface
00053 (
00054   REFIID   riid,             //[in] Identifier of the requested interface
00055   LPVOID*  ppv               //[out] Address of requested interface
00056 )
00057 {
00058   if( NULL == ppv )
00059     return E_FAIL;
00060
00061   HRESULT hResult = E_NOINTERFACE;
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065   {
00066     *ppv = static_cast<IClassFactory*>(this);
00067   }
00068   else if( IsEqualIID(riid, IID_IClassFactory) )
00069   {
00070     *ppv = static_cast<IClassFactory*>(this);
00071   }
00072
00073   if( *ppv )
00074   {
00075     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00076     hResult = S_OK;
00077   }
00078
00079   return hResult;
00080 }
00081
00082
00083 //---------------------------------------------------------------------------
00084 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00085 {
00086   return InterlockedIncrement( (long*)&m_cRef );
00087 }
00088
00089
00090 //---------------------------------------------------------------------------
00091 STDMETHODIMP_(ULONG) CClassFactory::Release()
00092 {
00093   if( 0 == InterlockedDecrement( (long*)&m_cRef) )
00094   {
00095     delete this;
00096     return 0;
00097   }
00098   return m_cRef;
00099 }
00100
00101 //---------------------------------------------------------------------------
00102 //  Creates an instance of the object type which was passed in the
00103 //  class constructor
00104 //
00105 STDMETHODIMP CClassFactory::CreateInstance
00106 (
00107   LPUNKNOWN  pUnkOuter,      //[in] NULL unless object is part of aggregate
00108   REFIID     riid,           //[in] Reference to interface indentifier
00109   LPVOID*    ppvObj          //[out] Address of requested interface pointer
00110 )
00111 {
00112   HRESULT  hResult = E_FAIL;
00113   void*    pObject = NULL;
00114
00115   if( NULL == ppvObj )
00116     return hResult;
00117
00118   *ppvObj = NULL;
00119
00120   // Our object does does not support aggregation, so we need to
00121   // fail if they ask us to do aggregation.
00122   if( pUnkOuter )
00123     return CLASS_E_NOAGGREGATION;
00124
00125   // Support for providing CSnapinAbout/CComponentData objects
00126   switch( m_FactoryType )
00127   {
00128     case COMPONENTDATA:
00129       pObject = new CComponentData();
00130       break;
00131
00132     case ABOUT:
00133       pObject = new CSnapinAbout();
00134       break;
00135
00136     default:
00137       pObject = NULL;
00138   }
00139
00140   if( NULL == pObject )                // Failed to create an object
00141     return E_INVALIDARG;               // due to bad argument
00142
00143   // QueryInterface will do the AddRef() for us, don't do it here
00144   hResult = ( (LPUNKNOWN)pObject)->QueryInterface( riid, ppvObj );
00145
00146   if( S_OK != hResult )
00147     delete pObject;
00148
00149   return hResult;
00150 }
00151
00152
00153 //---------------------------------------------------------------------------
00154 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00155 {
00156   if( TRUE == fLock )
00157     InterlockedIncrement((long*)&g_uServerLocks);
00158   else
00159     InterlockedDecrement((long*)&g_uServerLocks);
00160
00161   return S_OK;
00162 }
00163
00164
00165 /////////////////////////////////////////////////////////////////////////////
00166 //  Our Snap-in's exported functions
00167 //
00168
00169 //---------------------------------------------------------------------------
00170 //  Entry point into our Snap-in DLL
00171 //
00172 BOOL WINAPI DllMain
00173 (
00174   HINSTANCE  hInstDLL,         //[in] Handle to DLL module
00175   DWORD      fdwReason,        //[in] Reason for calling function
00176   void*      lpvReserved       //[in] Reserved
00177 )
00178 {
00179   if( DLL_PROCESS_ATTACH == fdwReason )
00180   {
00181      g_hInst = hInstDLL;
00182   }
00183
00184   return TRUE;
00185 }
00186
00187
00188 //---------------------------------------------------------------------------
00189 STDAPI DllGetClassObject
00190 (
00191   REFCLSID   rclsid,         //[in] CLSID for the class object
00192   REFIID     riid,           //[in] Reference to interface identifier
00193   LPVOID     *ppvObj         //[out] Object which recieves interface pointer
00194 )
00195 {
00196   // Test for CSnapinAbout
00197   if( (rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout) )
00198     return CLASS_E_CLASSNOTAVAILABLE;
00199
00200   if( !ppvObj )
00201     return E_FAIL;
00202
00203   *ppvObj = NULL;
00204
00205   // We can only hand out IUnknown and IClassFactory pointers.  Fail
00206   // if caller asks for anything else.
00207   if( !IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory) )
00208     return E_NOINTERFACE;
00209
00210   CClassFactory *pFactory = NULL;
00211
00212   // Create the new class factory.  Pass in the type of object to create
00213   if( rclsid == CLSID_CComponentData )
00214     pFactory = new CClassFactory(CClassFactory::COMPONENTDATA);
00215   else if( rclsid == CLSID_CSnapinAbout )
00216     pFactory = new CClassFactory(CClassFactory::ABOUT);
00217
00218
00219   HRESULT hResult = pFactory->QueryInterface( riid, ppvObj );
00220
00221   return hResult;
00222 }
00223
00224
00225 //---------------------------------------------------------------------------
00226 STDAPI DllCanUnloadNow(void)
00227 {
00228   if( 0 == g_uObjectCount && 0 == g_uServerLocks )
00229     return S_OK;
00230   else
00231     return S_FALSE;
00232 }
00233
00234
00235 //---------------------------------------------------------------------------
00236 STDAPI DllRegisterServer()
00237 {
00238   HRESULT hResult = S_FALSE;
00239
00240   do
00241   { // Support ISnapinAbout
00242     hResult = RegisterServer( g_hInst, CLSID_CSnapinAbout, gtszABOUT_NAME );
00243     BREAK_ON_ERROR( hResult );
00244
00245     hResult = RegisterServer( g_hInst, CLSID_CComponentData, gtszSNAPIN_NAME );
00246     BREAK_ON_ERROR( hResult );
00247
00248     hResult = RegisterSnapin( CLSID_CComponentData, gtszSNAPIN_NAME, CLSID_CSnapinAbout, TRUE );
00249     BREAK_ON_ERROR( hResult );
00250
00251   }while( 0 );
00252
00253   return hResult;
00254 }
00255
00256
00257 //---------------------------------------------------------------------------
00258 STDAPI DllUnregisterServer()
00259 {
00260   if( S_OK != UnregisterServer( CLSID_CComponentData )  ||
00261       S_OK != UnregisterServer( CLSID_CSnapinAbout   )  ||
00262       S_OK != UnregisterSnapin( CLSID_CComponentData )
00263     )
00264     return E_UNEXPECTED;
00265   else
00266     return S_OK;
00267 }
00268
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/tsfedit.h Source File

  • WinUI
  • tsfapp

tsfedit.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          TSFEdit.h
00013
00014    Description:   CTSFEditWnd Class Declaration
00015
00016 **************************************************************************/
00017
00018 #ifndef TSFEDITWND_H
00019 #define TSFEDITWND_H
00020
00021 /**************************************************************************
00022    #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <windowsx.h>
00027 #include <msctf.h>
00028 #include <olectl.h>
00029 #include <commctrl.h>
00030 #include "resource.h"
00031
00032 /**************************************************************************
00033    global variables and definitions
00034 **************************************************************************/
00035
00036 #define EDIT_VIEW_COOKIE    0
00037
00038 #define IDC_EDIT            1000
00039 #define IDC_STATUSBAR       1001
00040
00041 typedef struct
00042 {
00043     IUnknown                *punkID;
00044     ITextStoreACPSink       *pTextStoreACPSink;
00045     DWORD                   dwMask;
00046 }ADVISE_SINK, *PADVISE_SINK;
00047
00048 #define NUM_SUPPORTED_ATTRS 3
00049
00050 #define ATTR_INDEX_MODEBIAS             0
00051 #define ATTR_INDEX_TEXT_ORIENTATION     1
00052 #define ATTR_INDEX_TEXT_VERTICALWRITING 2
00053
00054 #define ATTR_FLAG_NONE      0
00055 #define ATTR_FLAG_REQUESTED 1
00056 #define ATTR_FLAG_DEFAULT   2
00057
00058 #define MAX_COMPOSITIONS    5
00059
00060 typedef struct
00061 {
00062     DWORD   dwFlags;
00063     const TS_ATTRID *attrid;
00064     VARIANT varValue;
00065     VARIANT varDefaultValue;
00066 }ATTRIBUTES, *PATTRIBUTES;
00067
00068 /**************************************************************************
00069
00070    CTSFEditWnd class definition
00071
00072 **************************************************************************/
00073
00074 class CTSFEditWnd : public ITextStoreACP,
00075                     public ITfContextOwnerCompositionSink,
00076                     public ITfFunctionProvider
00077 {
00078 private:
00079     DWORD                   m_ObjRefCount;
00080     HINSTANCE               m_hInst;
00081     HWND                    m_hWnd;
00082     HWND                    m_hwndParent;
00083     HWND                    m_hwndEdit;
00084     HWND                    m_hwndStatus;
00085     ITfThreadMgr            *m_pThreadMgr;
00086     TfClientId              m_tfClientID;
00087     ITfDocumentMgr          *m_pDocMgr;
00088     ITfDocumentMgr          *m_pPrevDocMgr;
00089     ITfContext              *m_pContext;
00090     TfEditCookie            m_EditCookie;
00091     ADVISE_SINK             m_AdviseSink;
00092     BOOL                    m_fLocked;
00093     DWORD                   m_dwLockType;
00094     BOOL                    m_fPendingLockUpgrade;
00095     DWORD                   m_dwInternalLockType;
00096     LONG                    m_acpStart;
00097     LONG                    m_acpEnd;
00098     BOOL                    m_fInterimChar;
00099     TsActiveSelEnd          m_ActiveSelEnd;
00100     ITextStoreACPServices   *m_pServices;
00101     ULONG                   m_cCompositions;
00102     ITfCompositionView*     m_rgCompositions[MAX_COMPOSITIONS];
00103     ATTRIBUTES              m_rgAttributes[NUM_SUPPORTED_ATTRS];
00104     ITfCategoryMgr          *m_pCategoryMgr;
00105     ITfDisplayAttributeMgr  *m_pDisplayAttrMgr;
00106     BOOL                    m_fLayoutChanged;
00107     BOOL                    m_fNotify;
00108     ULONG                   m_cchOldLength;
00109
00110 public:
00111     CTSFEditWnd(HINSTANCE hInstance, HWND hwndParent);
00112     ~CTSFEditWnd();
00113
00114     //public utility methods
00115     BOOL _Initialize(ITfThreadMgr *pThreadMgr, TfClientId tfcId);
00116     void _Uninitialize();
00117     HWND _GetWindow();
00118     HRESULT _OnGetPreservedKey();
00119     void _OnTest(void);
00120     void _GetDisplayAttributes(void);
00121     void _GetTextOwner(void);
00122     void _GetReadingText(void);
00123     void _GetComposing(void);
00124     HRESULT _TerminateAllCompositions(void);
00125     void _Reconvert(void);
00126     void _Playback(void);
00127     void _OnUpdate(void);
00128     LRESULT _OnInitMenuPopup(WPARAM, LPARAM);
00129     void _SaveToFile(LPTSTR pszFile);
00130     void _LoadFromFile(LPTSTR pszFile);
00131
00132     //IUnknown methods
00133     STDMETHOD (QueryInterface)(REFIID, LPVOID*);
00134     STDMETHOD_ (DWORD, AddRef)();
00135     STDMETHOD_ (DWORD, Release)();
00136
00137     //ITextStoreACP methods
00138     STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD dwMask);
00139     STDMETHODIMP UnadviseSink(IUnknown *punk);
00140     STDMETHODIMP RequestLock(DWORD dwLockFlags, HRESULT *phrSession);
00141     STDMETHODIMP GetStatus(TS_STATUS *pdcs);
00142     STDMETHODIMP QueryInsert(LONG acpTestStart, LONG acpTestEnd, ULONG cch, LONG *pacpResultStart, LONG *pacpResultEnd);
00143     STDMETHODIMP GetSelection(ULONG ulIndex, ULONG ulCount, TS_SELECTION_ACP *pSelection, ULONG *pcFetched);
00144     STDMETHODIMP SetSelection(ULONG ulCount, const TS_SELECTION_ACP *pSelection);
00145     STDMETHODIMP GetText(LONG acpStart, LONG acpEnd, WCHAR *pchPlain, ULONG cchPlainReq, ULONG *pcchPlainOut, TS_RUNINFO *prgRunInfo, ULONG ulRunInfoReq, ULONG *pulRunInfoOut, LONG *pacpNext);
00146     STDMETHODIMP SetText(DWORD dwFlags, LONG acpStart, LONG acpEnd, const WCHAR *pchText, ULONG cch, TS_TEXTCHANGE *pChange);
00147     STDMETHODIMP GetFormattedText(LONG acpStart, LONG acpEnd, IDataObject **ppDataObject);
00148     STDMETHODIMP GetEmbedded(LONG acpPos, REFGUID rguidService, REFIID riid, IUnknown **ppunk);
00149     STDMETHODIMP QueryInsertEmbedded(const GUID *pguidService, const FORMATETC *pFormatEtc, BOOL *pfInsertable);
00150     STDMETHODIMP InsertEmbedded(DWORD dwFlags, LONG acpStart, LONG acpEnd, IDataObject *pDataObject, TS_TEXTCHANGE *pChange);
00151     STDMETHODIMP RequestSupportedAttrs(DWORD dwFlags, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs);
00152     STDMETHODIMP RequestAttrsAtPosition(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags);
00153     STDMETHODIMP RequestAttrsTransitioningAtPosition(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags);
00154     STDMETHODIMP FindNextAttrTransition(LONG acpStart, LONG acpHalt, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags, LONG *pacpNext, BOOL *pfFound, LONG *plFoundOffset);
00155     STDMETHODIMP RetrieveRequestedAttrs(ULONG ulCount, TS_ATTRVAL *paAttrVals, ULONG *pcFetched);
00156     STDMETHODIMP GetEndACP(LONG *pacp);
00157     STDMETHODIMP GetActiveView(TsViewCookie *pvcView);
00158     STDMETHODIMP GetACPFromPoint(TsViewCookie vcView, const POINT *pt, DWORD dwFlags, LONG *pacp);
00159     STDMETHODIMP GetTextExt(TsViewCookie vcView, LONG acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped);
00160     STDMETHODIMP GetScreenExt(TsViewCookie vcView, RECT *prc);
00161     STDMETHODIMP GetWnd(TsViewCookie vcView, HWND *phwnd);
00162     STDMETHODIMP InsertTextAtSelection(DWORD dwFlags, const WCHAR *pchText, ULONG cch, LONG *pacpStart, LONG *pacpEnd, TS_TEXTCHANGE *pChange);
00163     STDMETHODIMP InsertEmbeddedAtSelection(DWORD dwFlags, IDataObject *pDataObject, LONG *pacpStart, LONG *pacpEnd, TS_TEXTCHANGE *pChange);
00164
00165     //ITfContextOwnerCompositionSink methods
00166     STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk);
00167     STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew);
00168     STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition);
00169
00170     // ITfFunctionProvider
00171     STDMETHODIMP GetType(GUID *pguid);
00172     STDMETHODIMP GetDescription(BSTR *pbstrDesc);
00173     STDMETHODIMP GetFunction(REFGUID rguid, REFIID riid, IUnknown **ppunk);
00174
00175 private:
00176     static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00177     STDMETHODIMP _TestInsert(LONG acpTestStart, LONG acpTestEnd, ULONG cch, LONG *pacpResultStart, LONG *pacpResultEnd);
00178     LRESULT _OnCreate(VOID);
00179     LRESULT _OnDestroy(VOID);
00180     LRESULT _OnCommand(WORD, WORD, HWND);
00181     LRESULT _OnSetFocus(VOID);
00182     LRESULT _OnKillFocus(VOID);
00183     LRESULT _OnEditSetFocus(VOID);
00184     LRESULT _OnEditKillFocus(VOID);
00185     LRESULT _OnEditChange(void);
00186     LRESULT _OnNotify(UINT, LPNMHDR);
00187     LRESULT _OnSize(WPARAM, LPARAM);
00188     HRESULT _ClearAdviseSink(PADVISE_SINK pAdviseSink);
00189     BOOL _LockDocument(DWORD dwLockFlags);
00190     void _UnlockDocument();
00191     BOOL _InternalLockDocument(DWORD dwLockFlags);
00192     void _InternalUnlockDocument();
00193     BOOL _IsLocked(DWORD dwLockType);
00194     BOOL _GetCurrentSelection(void);
00195     void _UpdateStatusBar(void);
00196     void _ClearRequestedAttributes(void);
00197     void _ClearText(void);
00198     HRESULT _GetText(LPWSTR *ppwsz, LPLONG pcch = NULL);
00199     BOOL _InitFunctionProvider();
00200     void _UninitFunctionProvider();
00201     BOOL _CanReconvertSelection(void);
00202     BOOL _CanPlaybackSelection(void);
00203     void _Save(IStream *pStream);
00204     void _Load(IStream *pStream);
00205
00206 };
00207
00208 #endif   //TSFEDITWND_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IInkCollectorEventsImpl< T > Member List

This is the complete list of members for IInkCollectorEventsImpl< T >, including all inherited members.
const_cast(&mc_AtlFuncInfo[1])) HRESULT __stdcall Stroke(IInkCursor *pIInkCursor | IInkCollectorEventsImpl< T > |
DIID__IInkCollectorEvents | IInkCollectorEventsImpl< T > |
DISPID_CEGesture | IInkCollectorEventsImpl< T > |
Gesture | IInkCollectorEventsImpl< T > |
mc_AtlFuncInfo | IInkCollectorEventsImpl< T > | [static]
pInkStroke | IInkCollectorEventsImpl< T > |
SINK_ENTRY_INFO(SINK_ID, DIID__IInkCollectorEvents, DISPID_CEStroke, Stroke, const_cast< _ATL_FUNC_INFO * >(&mc_AtlFuncInfo[0])) SINK_ENTRY_INFO(SINK_ID | IInkCollectorEventsImpl< T > |
SINK_ENTRY_INFO(SINK_ID, DIID__IInkCollectorEvents, DISPID_CEStroke, Stroke, const_cast< _ATL_FUNC_INFO * >(&mc_AtlFuncInfo)) HRESULT __stdcall Stroke(IInkCursor *pIInkCursor | IInkCollectorEventsImpl< T > |
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/evtstoresub.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

evtstoresub.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "ComSpyCtl.h"
00019 #include "ComSpyAudit.h"
00020 #include "SysLCESub.h"    // Include our base class.
00021 #include "CComSpy.h"
00022 #include "evtstoresub.h"
00023
00024
00025 STDMETHODIMP CEvtStoreSub::ChangedSubscription
00026    (/* [in] */ EOC_ChangeType changeType,
00027   /* [in] */ BSTR bstrSubscriptionID)
00028 {
00029
00030   LONGLONG perfCount = 0;
00031   ::QueryPerformanceCounter( (LARGE_INTEGER *)&perfCount );
00032   LPOLESTR lpOperation;
00033   switch (changeType)
00034   {
00035     case EOC_NewObject:
00036       lpOperation = OLESTR("New Subscription");
00037       break;
00038     case EOC_ModifiedObject:
00039       lpOperation = OLESTR("Modified Subscription");
00040       break;
00041     case EOC_DeletedObject:
00042       lpOperation = OLESTR("Deleted Subscription");
00043       break;
00044   }
00045   m_pSpy -> AddEventToList(perfCount, lpOperation, OLESTR("COM+ Event Store"));
00046   m_pSpy -> AddParamValueToList(L"Subscription ID", bstrSubscriptionID);
00047   //TODO: Add Auditing code for subscription change
00048   AddSubscriptionInfo( m_pSpy, bstrSubscriptionID );
00049   return S_OK;
00050 }
00051
00052 STDMETHODIMP CEvtStoreSub::ChangedEventClass
00053    (/* [in] */ EOC_ChangeType changeType,
00054   /* [in] */ BSTR bstrEventClassID)
00055 {
00056   LONGLONG perfCount = 0;
00057   ::QueryPerformanceCounter( (LARGE_INTEGER *)&perfCount );
00058   LPOLESTR lpOperation;
00059   switch (changeType)
00060   {
00061     case EOC_NewObject:
00062       lpOperation = OLESTR("New Event Class");
00063       break;
00064     case EOC_ModifiedObject:
00065       lpOperation = OLESTR("Modified Event Class");
00066       break;
00067     case EOC_DeletedObject:
00068       lpOperation = OLESTR("Deleted Event Class");
00069       break;
00070   }
00071   m_pSpy -> AddEventToList(perfCount, lpOperation, OLESTR("COM+ Event Store"));
00072   m_pSpy -> AddParamValueToList(L"Event Class ID", bstrEventClassID);
00073
00074   //TODO: Add Auditing code for event class change
00075   AddEventClassInfo( m_pSpy, bstrEventClassID );
00076   return S_OK;
00077 }
00078
00079 STDMETHODIMP CEvtStoreSub::ChangedPublisher
00080    (/* [in] */ EOC_ChangeType changeType,
00081   /* [in] */ BSTR bstrPublisherID)
00082 {
00083   LONGLONG perfCount = 0;
00084   ::QueryPerformanceCounter( (LARGE_INTEGER *)&perfCount );
00085   LPOLESTR lpOperation;
00086   switch (changeType)
00087   {
00088     case EOC_NewObject:
00089       lpOperation = OLESTR("New Publisher");
00090       break;
00091     case EOC_ModifiedObject:
00092       lpOperation = OLESTR("Modified Publisher");
00093       break;
00094     case EOC_DeletedObject:
00095       lpOperation = OLESTR("Deleted Publisher");
00096       break;
00097   }
00098   m_pSpy -> AddEventToList(perfCount, lpOperation, OLESTR("COM+ Event Store"));
00099   m_pSpy -> AddParamValueToList(L"Publisher ID", bstrPublisherID);
00100   //TODO: Add Auditing code for Publisher Change
00101   AddPublisherInfo( m_pSpy, bstrPublisherID );
00102   return S_OK;
00103 }
00104
00105
00106
00107 ///////////
00108 STDMETHODIMP CEvtStoreSub::AddSubscriptionInfo
00109 //-----------------------------------------------------------------
00110 // Function Description:
00111 //
00112 //  Given a subscription ID, query the Event Store for information.
00113 //
00114 // Return Value:
00115 //
00116 //  Arguments:
00117    (/* [in] */ CComSpy* pSpy,
00118   /* [in] */ BSTR bstrSubscriptionID)
00119 //
00120 //-----------------------------------------------------------------
00121 {
00122   HRESULT hr = S_OK;
00123   // Variables initialized to NULL here to ensure error returns are valid.
00124   CComPtr<IEventSystem> spIEventSystem = NULL;
00125
00126   hr = CoCreateInstance(CLSID_CEventSystem,
00127               NULL,
00128               CLSCTX_SERVER,
00129               IID_IEventSystem,
00130               (void**)&spIEventSystem);
00131   if (FAILED(hr))
00132   {
00133     ATLTRACE(L"Failed to create CEventSystem");
00134     return hr;
00135   }
00136
00137   // ----------------------------------------------
00138   // Query for the subscription info
00139   // ----------------------------------------------
00140
00141   int errorIndex;
00142
00143   CComBSTR bstrCriteria;
00144   bstrCriteria = "SubscriptionID=";
00145   bstrCriteria += bstrSubscriptionID;
00146
00147   CComPtr<IUnknown> pUnk = NULL;
00148   hr = spIEventSystem->Query(PROGID_EventSubscription, bstrCriteria, &errorIndex, &pUnk);
00149   if (FAILED(hr))
00150   {
00151     ATLTRACE(L"Query for SubcriptionID failed");
00152     return hr;
00153   }
00154
00155   // Got something - now get the info and blast it to Spy.
00156   CComQIPtr<IEventSubscription, &IID_IEventSubscription> spIEventSubscription;
00157   spIEventSubscription = pUnk;
00158   if (!spIEventSubscription)
00159   {
00160     ATLTRACE(L"QI for IEventSubscription failed");
00161     return hr;
00162   }
00163
00164   CComBSTR bstrSubscriptionName;
00165   CComBSTR bstrEventClassID;
00166   CComBSTR bstrDescription;
00167
00168   spIEventSubscription->get_SubscriptionName( &bstrSubscriptionName );
00169   spIEventSubscription->get_EventClassID( &bstrEventClassID );
00170   spIEventSubscription->get_Description( &bstrDescription );
00171   if (FAILED(hr))
00172   {
00173     ATLTRACE(L"Get of Subscription EventClass failed");
00174     return hr;
00175   } else
00176   {
00177     pSpy -> AddParamValueToList(L"Subscription Name", bstrSubscriptionName);
00178     pSpy -> AddParamValueToList(L"Event Class ID", bstrEventClassID);
00179     pSpy -> AddParamValueToList(L"Description", bstrDescription);
00180     //TODO: Add Auditing code for subscription change
00181   }
00182
00183   return hr;
00184
00185 }
00186
00187 STDMETHODIMP CEvtStoreSub::AddEventClassInfo
00188 //-----------------------------------------------------------------
00189 // Function Description:
00190 //
00191 //  Given an Event Class ID, query the Event Store for information.
00192 //
00193 // Return Value:
00194 //
00195 //  Arguments:
00196    (/* [in] */ CComSpy* pSpy,
00197   /* [in] */ BSTR bstrEventClassID)
00198 //
00199 //-----------------------------------------------------------------
00200 {
00201   HRESULT hr = S_OK;
00202   // Variables initialized to NULL here to ensure error returns are valid.
00203   CComPtr<IEventSystem> spIEventSystem = NULL;
00204
00205   hr = CoCreateInstance(CLSID_CEventSystem,
00206               NULL,
00207               CLSCTX_SERVER,
00208               IID_IEventSystem,
00209               (void**)&spIEventSystem);
00210   if (FAILED(hr))
00211   {
00212     ATLTRACE(L"Failed to create CEventSystem");
00213     return hr;
00214   }
00215
00216   // ----------------------------------------------
00217   // Query for the EventClass info
00218   // ----------------------------------------------
00219
00220   int errorIndex;
00221
00222   CComBSTR bstrCriteria;
00223   bstrCriteria = "EventClassID=";
00224   bstrCriteria += bstrEventClassID;
00225
00226   CComPtr<IUnknown> pUnk = NULL;
00227   hr = spIEventSystem->Query(PROGID_EventClass, bstrCriteria, &errorIndex, &pUnk);
00228   if (FAILED(hr))
00229   {
00230     ATLTRACE(L"Query for SubcriptionID failed");
00231     return hr;
00232   }
00233
00234   // Got something - now get the info and blast it to Spy.
00235   CComQIPtr<IEventClass, &IID_IEventClass> spIEventClass;
00236   spIEventClass = pUnk;
00237   if (!spIEventClass)
00238   {
00239     ATLTRACE(L"QI for IEventClass failed");
00240     return hr;
00241   }
00242
00243   CComBSTR bstrEventClassName;
00244   CComBSTR bstrFiringInterfaceID;
00245   CComBSTR bstrOwnerSID;
00246   CComBSTR bstrDescription;
00247
00248   spIEventClass->get_EventClassName( &bstrEventClassName );
00249   spIEventClass->get_FiringInterfaceID( &bstrFiringInterfaceID );
00250   spIEventClass->get_Description( &bstrDescription );
00251   spIEventClass->get_OwnerSID( &bstrOwnerSID );
00252   if (FAILED(hr))
00253   {
00254     ATLTRACE(L"Get of EventClass EventClass failed");
00255     return hr;
00256   } else
00257   {
00258     pSpy -> AddParamValueToList(L"EventClass Name", bstrEventClassName);
00259     pSpy -> AddParamValueToList(L"Firing Interface ID", bstrFiringInterfaceID);
00260     pSpy -> AddParamValueToList(L"Description", bstrDescription);
00261     pSpy -> AddParamValueToList(L"Owner SID", bstrOwnerSID);
00262     //TODO: Add Auditing code for EventClass change
00263   }
00264
00265
00266   return hr;
00267
00268 }
00269
00270 STDMETHODIMP CEvtStoreSub::AddPublisherInfo
00271 //-----------------------------------------------------------------
00272 // Function Description:
00273 //
00274 //  Given a Publisher ID, query the Event Store for information.
00275 //
00276 // Return Value:
00277 //
00278 //  Arguments:
00279    (/* [in] */ CComSpy* pSpy,
00280   /* [in] */ BSTR bstrPublisherID)
00281 //
00282 //-----------------------------------------------------------------
00283 {
00284   HRESULT hr = S_OK;
00285   // Variables initialized to NULL here to ensure error returns are valid.
00286   CComPtr<IEventSystem> spIEventSystem = NULL;
00287
00288   hr = CoCreateInstance(CLSID_CEventSystem,
00289               NULL,
00290               CLSCTX_SERVER,
00291               IID_IEventSystem,
00292               (void**)&spIEventSystem);
00293   if (FAILED(hr))
00294   {
00295     ATLTRACE(L"Failed to create CEventSystem");
00296     return hr;
00297   }
00298
00299   // ----------------------------------------------
00300   // Query for the Publisher info
00301   // ----------------------------------------------
00302
00303   int errorIndex;
00304
00305   CComBSTR bstrCriteria;
00306   bstrCriteria = "PublisherID=";
00307   bstrCriteria += bstrPublisherID;
00308
00309   CComPtr<IUnknown> pUnk = NULL;
00310   hr = spIEventSystem->Query(PROGID_EventPublisher, bstrCriteria, &errorIndex, &pUnk);
00311   if (FAILED(hr))
00312   {
00313     ATLTRACE(L"Query for SubcriptionID failed");
00314     return hr;
00315   }
00316
00317   // Got something - now get the info and blast it to Spy.
00318   CComQIPtr<IEventPublisher, &IID_IEventPublisher> spIEventPublisher;
00319   spIEventPublisher = pUnk;
00320   if (!spIEventPublisher)
00321   {
00322     ATLTRACE(L"QI for IEventPublisher failed");
00323     return hr;
00324   }
00325
00326   CComBSTR bstrPublisherName;
00327   CComBSTR bstrPublisherType;
00328   CComBSTR bstrDescription;
00329   CComBSTR bstrOwnerSID;
00330
00331   spIEventPublisher->get_PublisherName( &bstrPublisherName );
00332   spIEventPublisher->get_PublisherType( &bstrPublisherType );
00333   spIEventPublisher->get_Description( &bstrDescription );
00334   spIEventPublisher->get_OwnerSID( &bstrOwnerSID );
00335   if (FAILED(hr))
00336   {
00337     ATLTRACE(L"Get of Publisher Publisher failed");
00338     return hr;
00339   } else
00340   {
00341     pSpy -> AddParamValueToList(L"Publisher Name", bstrPublisherName);
00342     pSpy -> AddParamValueToList(L"Publisher Type", bstrPublisherType);
00343     pSpy -> AddParamValueToList(L"Description", bstrDescription);
00344     pSpy -> AddParamValueToList(L"Owner SID", bstrOwnerSID);
00345     //TODO: Add Auditing code for Publisher change
00346   }
00347
00348   return hr;
00349
00350 }
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/PropertyList/vc/main.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • PropertyList
  • vc

main.cpp

Go to the documentation of this file.
00001
00002
00003 // ADsPropertyList Main.cpp
00004 // Active Directory Sample
00005 /*
00006   Demonstrates use of the following
00007   ADSI COM interfaces from C++:
00008
00009     IADs
00010     IADsPropertyList
00011     IADsPropertyEntry
00012     IADsPropertyValue
00013
00014   ADSI Functions:
00015     ADsOpenObject()
00016
00017
00018     This sample binds to a server using RootDSE, then IADsPropertyList to list all
00019     the properties on this object
00020
00021 */
00022
00023
00024 //
00025
00026
00027 #define INC_OLE2
00028 #define UNICODE 1
00029 #define _WIN32_DCOM
00030
00031 #include <windows.h>
00032 #include <winuser.h>
00033
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 #include <malloc.h>
00037 #include <winldap.h>
00038 #include <adsiid.h>
00039 #include <string.h>
00040 #include <activeds.h>
00041
00042 #include "ADSIhelpers.h"
00043
00044
00045 int IS_BUFFER_ENOUGH(UINT maxAlloc, LPWSTR pszTarget, LPCWSTR pszSource, int toCopy=-1);
00046 void main()
00047 {
00048     // COM result variable
00049   HRESULT hr;
00050
00051   // Interface Pointers
00052   IDirectorySearch    *   pDSSearch=NULL;
00053   IADs              *   pIADs = NULL;
00054   IADsPropertyList    *   pIADpl = NULL;
00055   VARIANT                 vRet;
00056   LONG                    lCount;
00057     IADs                *   pIADsrootDSE = NULL;
00058     BSTR                    bsNamingContext;
00059     VARIANT                 vResult;
00060     WCHAR                   wszActualLDAPPath[MAX_PATH];
00061
00062   VariantInit(&vRet);
00063
00064   // Initialize COM
00065   CoInitialize(0);
00066
00067   // Bind Through RootDSE
00068     _putws(L"Binding to a server using LDAP://rootDSE");
00069
00070     hr = ADsGetObject(  L"LDAP://rootDSE", IID_IADs,(void **)&pIADsrootDSE);
00071
00072   if (FAILED(hr))
00073     return;
00074
00075      // Get the defaultNamingContext attribute and for binding
00076     // to the actual DC
00077     bsNamingContext = SysAllocString(L"defaultNamingContext");
00078     VariantInit(&vResult);
00079
00080     // Get the defaultNamingContext Attribute
00081     hr = pIADsrootDSE->Get(bsNamingContext,&vResult);
00082
00083     if (SUCCEEDED(hr))
00084     {
00085             // Make sure it's a BSTR
00086             hr = VariantChangeType(&vResult,&vResult,NULL,VT_BSTR);
00087
00088             if (SUCCEEDED(hr))
00089             {
00090                 // Build a binding string
00091         wcscpy(wszActualLDAPPath, L"LDAP://");
00092         if ( IS_BUFFER_ENOUGH(MAX_PATH, wszActualLDAPPath, vResult.bstrVal) > 0 )
00093         {
00094                    wcscat(wszActualLDAPPath,vResult.bstrVal );
00095            wprintf(L"\nBinding to the path %s\n",wszActualLDAPPath);
00096         }
00097         else
00098         {
00099           pIADsrootDSE->Release();
00100           wprintf(L"Buffer is too small to hold the domain DN");
00101         }
00102
00103
00104
00105                 // Bind to the actual server
00106                 hr = ADsGetObject(  wszActualLDAPPath, IID_IADs,(void **)&pIADs);
00107             }
00108             VariantClear(&vResult);
00109     }
00110     SysFreeString(bsNamingContext);
00111
00112     // Relase the RootDse binding...
00113     pIADsrootDSE->Release();
00114     pIADsrootDSE = NULL;
00115
00116   if (FAILED(hr))
00117     return;
00118
00119     wprintf(L"\n\nSuccessfully bound to %s\n",wszActualLDAPPath);
00120
00121     // Print some general info about the object we are bound to
00122     PrintIADSObject(pIADs);
00123
00124   if (FAILED(hr))
00125     return;
00126
00127     wprintf(L"\n\nEnumerating this object's properties using the IADsPropertyList interface\n\n");
00128
00129   //Call GetInfo to load all the properties. Call GetInfoEx to load only specific ones.
00130   hr = pIADs->GetInfo();
00131
00132   if (FAILED(hr))
00133     return;
00134
00135   //QueryInterface() for IADsPropertyList ptr.
00136   hr = pIADs->QueryInterface( IID_IADsPropertyList,(void **)&pIADpl);
00137
00138   if (FAILED(hr))
00139     return;
00140
00141   // Retrieve a COUNT of all the properties in the propertylist
00142   hr = pIADpl->get_PropertyCount(  &lCount  );
00143
00144   // Output the property count obtained from the IADsPropertyList interface
00145   printf("\n The Object has %d properties\n",lCount);
00146
00147   // Move to the FIRST property in the list
00148   hr = pIADpl->Next(&vRet);
00149   CheckHRESULT(hr,"pIADpl->Next(&vRet);");
00150
00151   for (long lElement = 0; lElement < lCount; lElement++)
00152   {
00153
00154     IDispatch * pDisp = V_DISPATCH(&vRet);
00155     IADsPropertyEntry * pAdsEntry = NULL;
00156
00157     // QueryInterface for a IADsPropertyEntry interace on the current property
00158     hr = pDisp->QueryInterface(IID_IADsPropertyEntry,(void**) &pAdsEntry);
00159
00160     if (SUCCEEDED(hr))
00161     {
00162       BSTR  bsName ;
00163       VARIANT vValue;
00164       VariantInit(&vValue);
00165
00166       // Get the NAME of the current property
00167       hr = pAdsEntry->get_Name( &bsName);
00168
00169       if (SUCCEEDED(hr))
00170       {
00171         wprintf(L"\n NAME:%s \t\n",(LPOLESTR)bsName);
00172         SysFreeString(bsName);
00173       }
00174
00175       // Get the values
00176             hr = pAdsEntry->get_Values(&vValue);
00177
00178       puts("The Values Variant style is :");
00179       puts(GetVariantStyle(vValue.vt));
00180
00181       if (SUCCEEDED(hr))
00182       {
00183         // We should now have a VARAIANT ARRAY of IDispath *'s
00184                 // So, read the safe array, enumeraing each IDispatch *
00185                 // The IDispatch * is then QI'd for the IADsPropertyValue
00186                 // interface. This interface provides the property information
00187         if (HAS_BIT_STYLE(vValue.vt,VT_ARRAY))
00188         {
00189           LONG dwSLBound = 0;
00190           LONG dwSUBound = 0;
00191           LONG i;
00192
00193           hr = SafeArrayGetLBound(V_ARRAY(&vValue),1,(long FAR *)&dwSLBound);
00194
00195           hr = SafeArrayGetUBound(V_ARRAY(&vValue),1,(long FAR *)&dwSUBound);
00196
00197           for (i = dwSLBound; i <= dwSUBound; i++)
00198           {
00199             VARIANT v;
00200             VariantInit(&v);
00201             hr = SafeArrayGetElement(V_ARRAY(&vValue),(long FAR *)&i,&v);
00202
00203             if (SUCCEEDED(hr))
00204             {
00205               if (HAS_BIT_STYLE(v.vt,VT_DISPATCH))
00206               {
00207                 IDispatch * pDispEntry = V_DISPATCH(&v);
00208                 IADsPropertyValue * pAdsPV = NULL;
00209
00210                 hr = pDispEntry->QueryInterface(IID_IADsPropertyValue,(void **) &pAdsPV);
00211
00212                 if (SUCCEEDED(hr))
00213                 {
00214                   BSTR bValue;
00215
00216                   // Get the value as a BSTR
00217                                     hr = GetIADsPropertyValueAsBSTR(&bValue,pAdsEntry,pAdsPV);
00218
00219                   if (SUCCEEDED(hr))
00220                   {
00221                     wprintf(L"<%s>\n",(LPOLESTR)bValue);
00222                     SysFreeString(bValue);
00223                   }
00224                   pAdsPV->Release();
00225                   pAdsPV =NULL;
00226                 }
00227               }
00228               else
00229                 puts("!!NO DISPATCH ENTRY!!");
00230
00231               VariantClear(&v);
00232             }
00233           }
00234           VariantClear(&vValue);
00235         }
00236         else
00237           wprintf(L" NAME:%s \t",(LPOLESTR)V_BSTR(&vValue));
00238
00239       }
00240       pAdsEntry->Release();
00241       pAdsEntry = NULL;
00242     }
00243     hr = pIADpl->Next(&vRet);
00244   }
00245
00246   CoUninitialize();
00247
00248 }
00249
00250 int IS_BUFFER_ENOUGH(UINT maxAlloc, LPWSTR pszTarget, LPCWSTR pszSource, int toCopy)
00251
00252 {
00253          if (toCopy == -1)
00254
00255           {
00256                toCopy = wcslen(pszSource);
00257           }
00258
00259       return maxAlloc - (wcslen(pszTarget) + toCopy + 1);
00260 }
00261
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

qcship::IShip Member List

This is the complete list of members for qcship::IShip, including all inherited members.
iid | qcship::IShip | [static]
LineItem(int lItemId, int lQuantity) | qcship::IShip |
Process(int lFlags) | qcship::IShip |
setCustomerId(int _jcomparam_0) | qcship::IShip |
setOrderId(int _jcomparam_0) | qcship::IShip |
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MidiPlyr/Debug.h Source File

  • Multimedia
  • Audio
  • MidiPlyr

Debug.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *
00003 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
00006 *  A PARTICULAR PURPOSE.
00007 *
00008 *  Copyright 1993 - 2000 Microsoft Corporation. All Rights Reserved.
00009 *
00010 ******************************************************************************
00011 *
00012 * Debug.H
00013 *
00014 * Public include file for debug output
00015 *
00016 *****************************************************************************/
00017
00018 #ifndef _INC_DEBUG
00019 #define _INC_DEBUG
00020 #ifdef __cplusplus
00021 extern "C"
00022 {
00023 #endif
00024
00025 #define  ISRDEBUG             1
00026 #define  DEBUG_SECTION        "debug"        /* section name for                */
00027 #define  DEBUG_MODULE_NAME    "MIDIPLYR"     /* key name and prefix for output  */
00028 #define  DEBUG_MAX_LINE_LEN   255            /* max line length (bytes)         */
00029
00030 #define  DRV_ENABLE_DEBUG     (DRV_USER+1)   /* Enable/disable debug message    */
00031 #define  DRV_SET_DEBUG_LEVEL  (DRV_USER+2)   /* Message to set the debug level  */
00032
00033 #ifdef DEBUG
00034     VOID WINAPI WinAssert(LPSTR lpstrExp, LPSTR lpstrFile, DWORD dwLine);
00035     BOOL WINAPI DbgEnable(BOOL fEnable);
00036     UINT WINAPI DbgSetLevel(UINT uLevel);
00037     UINT WINAPI DbgInitialize(BOOL fEnable);
00038
00039     void FAR CDECL dprintf(UINT uDbgLevel, LPSTR szFmt, ...);
00040
00041     #define assert(exp) \
00042         ( (exp) ? (void) 0 : WinAssert(#exp, __FILE__, __LINE__) )
00043
00044     #define DPF                  dprintf
00045
00046     #define D1(sz)               dprintf(1,sz)
00047     #define D2(sz)               dprintf(2,sz)
00048     #define D3(sz)               dprintf(3,sz)
00049     #define D4(sz)               dprintf(4,sz)
00050 #else
00051     #define assert(exp)          ((void)0)
00052
00053     #define DbgEnable(x)         FALSE
00054     #define DbgSetLevel(x)       0
00055     #define DbgInitialize(x)     0
00056
00057     #define DPF                  1 ? (void)0 : (void)
00058
00059     #define D1(sz)
00060     #define D2(sz)
00061     #define D3(sz)
00062     #define D4(sz)
00063 #endif
00064
00065
00066 #ifdef __cplusplus
00067 }
00068 #endif
00069 #endif
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/Inc/RmWorker.Idl Source File

  • Com
  • Common
  • Inc

RmWorker.Idl

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 ********************************************************************************
00004 * Filename: RmWorker.idl
00005 *
00006 * Description: IDL source for RmWorker.dll
00007 *
00008 * This file will be processed by the MIDL tool to
00009 * produce the type library (RmWorker.tlb) and marshalling code.
00010 *
00011 *
00012 * This file is provided as part of the Microsoft Transaction Server
00013 * Software Development Kit
00014 *
00015 *THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00016 *WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00017 *INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00018 *OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00019 *PURPOSE.
00020 *
00021 * Copyright (C) 1997 Microsoft Corporation, All rights reserved
00022 ********************************************************************************
00023 \******************************************************************************/
00024
00025 import "oaidl.idl";
00026
00027 //---------------------------------------------------------------------
00028 //  RMRC:
00029 //  Definition of the resource manager return code type.
00030 //---------------------------------------------------------------------
00031
00032 typedef enum  tagRMSTATUS
00033 {
00034   RM_STATUS_SUCCESS,
00035   RM_STATUS_FAILURE,
00036   RM_STATUS_UNDO_ERROR,
00037   RM_STATUS_LOG_ERROR,
00038   RM_STATUS_COPY_FAILURE,
00039   RM_STATUS_DELETE_FAILURE,
00040   RM_STATUS_RENAME_FAILURE,
00041   RM_STATUS_MOVE_FAILURE,
00042   RM_STATUS_IN_MEMORY_LIST,
00043   RM_STATUS_OVERWRITE_EXISTING,
00044   RM_STATUS_FILE_NOT_FOUND,
00045   RM_STATUS_INTERFACE,
00046   RM_STATUS_NO_MEMORY,
00047   RM_STATUS_INVALID_PARM,
00048   RM_STATUS_IMPORT_ERROR,
00049   RM_STATUS_ENLIST_ERROR,
00050   RM_STATUS_INVALID_STATE,
00051   RM_STATUS_TM_DOWN,
00052   RM_STATUS_RECOVERY_FAILURE
00053 } RMSTATUS;
00054
00055 //---------------------------------------------------------------------
00056 // RECOVERYRC:
00057 // Return codes for recovery functions.
00058 //---------------------------------------------------------------------
00059
00060 typedef enum tagRECOVERYRC
00061 {
00062   REC_S_SUCCESS,
00063   REC_E_NO_MEMORY,
00064   REC_E_ORPHANED_TRANSACTION,
00065   REC_E_INVALID_STATE,
00066   REC_E_PREPARE_SEQUENCE,
00067   REC_E_UNDO_SEQUENCE,
00068   REC_E_END_TRANSACTION_SEQUENCE,
00069   REC_E_FORGET_SEQUENCE,
00070   REC_E_BEGINUNDO_SEQUENCE,
00071   REC_E_ENDUNDO_SEQUENCE,
00072   REC_E_COMMIT_SEQUENCE,
00073   REC_E_TRANSACTION_DUPLICATED,
00074   REC_E_INVALID_LOG_RECORD,
00075   REC_E_LOG_FAILURE,
00076   REC_E_STATE_UNKNOWN,
00077   REC_E_UNDO_INCOMPLETE,
00078   REC_E_INDOUBT_INVALID,
00079   REC_E_REENLIST,
00080   REC_E_TM_DOWN,
00081   REC_E_OUTCOMEACTION
00082 } RECOVERYRC;
00083
00084
00085 //---------------------------------------------------------------------
00086 // RECOVERY_STATE:
00087 // State of a recovering transaction.
00088 //---------------------------------------------------------------------
00089
00090 typedef enum tagRECOVERY_STATE
00091 {
00092   REC_STATE_ACTIVE,
00093   REC_STATE_COMPLETED,
00094   REC_STATE_DORMANT,
00095   REC_STATE_INDOUBT,
00096   REC_STATE_ABORTING
00097 } RECOVERY_STATE;
00098
00099 //---------------------------------------------------------------------
00100 // TXSTATE:
00101 // Definition of Resource Manager states.
00102 // NB:  The Resource Manager only processes one transaction at a time.
00103 //      After initialization the Resource Manager states reflect the
00104 //      transaction states.
00105 //
00106
00107 typedef enum
00108 {
00109   TX_UNINITIALIZED,
00110   TX_INITIALIZING,
00111   TX_INITIALIZED,
00112   TX_ENLISTING,
00113   TX_ENLISTED,
00114   TX_PREPARING,
00115   TX_PREPARED,
00116   TX_COMMITTING,
00117   TX_COMMITTED,
00118   TX_ABORTING,
00119   TX_ABORTED,
00120   TX_DONE,
00121   TX_TMDOWN,
00122   TX_INVALID_STATE
00123 } TXSTATE;
00124
00125 typedef enum
00126 {
00127   RM_COPY,
00128   RM_DELETE,
00129   RM_MOVE,
00130   RM_RENAME,
00131   RM_UNDO,
00132   RM_NONE,
00133   RM_FORGET,
00134   RM_UNDO_BEGIN,
00135   RM_UNDO_END
00136
00137 } FILE_OPERATION;
00138
00139
00140   [
00141
00142     object,
00143     uuid(FC005CE6-3F0B-11D0-9693-00AA00C149A6),
00144     helpstring("IRmWorker Interface"),
00145     pointer_default(unique)
00146   ]
00147   interface IRmWorker : IUnknown
00148   {
00149
00150     [helpstring("copy a file")]
00151     HRESULT FileCopyTx([in] BSTR sSource, [in] BSTR sDestination, BOOL bFailIfExists);
00152
00153     [helpstring("rename a file")]
00154     HRESULT FileRenameTx([in] BSTR sSource, [in] BSTR sDestination);
00155
00156     [helpstring("add a file to copy")]
00157     HRESULT AddFile([in] BSTR sSource, [in] BSTR sDestination);
00158
00159     [helpstring("copy the list of files")]
00160     HRESULT CopyListTx();
00161
00162
00163     [helpstring("Move a file")]
00164     HRESULT FileMoveTxt([in] BSTR sSource, [in] BSTR sDestination);
00165
00166     [helpstring("delete a file")]
00167     HRESULT FileDeleteTx([in] BSTR sFileName);
00168
00169     [helpstring("Exports the Tx")]
00170     HRESULT ExportTx([in] ULONG cbTranCookie, [out]BYTE *rgbTranCookie);
00171
00172     [helpstring("Initializes the Worker")]
00173     HRESULT Init([in] IUnknown * pUnkLog, [in] IUnknown * pUnkDtcResMgr, [in]IUnknown *pUnkDtc, [in] BSTR sRecDir);
00174
00175     [helpstring("Returns the Tx ID as a GUID converted to a string")]
00176     HRESULT GetTransactionId([out] BSTR * guidTx);
00177
00178     [helpstring("Recovers any transactions that need it")]
00179     HRESULT Recover(IStorage * pStorage);
00180
00181     [helpstring("Resets a completed transaction to a resusable state")]
00182     HRESULT Reset();
00183
00184     [helpstring("called by CopyFileRm when the TM goes down and the worker was not enlisted")]
00185     HRESULT TMDown();
00186
00187
00188
00189   };
00190
00191
00192   [
00193
00194     object,
00195     uuid(FC005CE2-3F0B-11D0-9693-00AA00C149A6),
00196     helpstring("IRmWorkerPriv Interface"),
00197     pointer_default(unique)
00198   ]
00199   interface IRmWorkerPriv : IUnknown
00200   {
00201     import "oaidl.idl";
00202     HRESULT PrepareTx (void);
00203     HRESULT CommitTx (void);
00204     HRESULT AbortTx (void);
00205     HRESULT GetState([out] TXSTATE *eState);
00206     HRESULT SetState([in]  TXSTATE eState);
00207     HRESULT CleanupTx (void);
00208     HRESULT GetDTCUnknown([out] IUnknown ** pUnk);
00209   };
00210
00211
00212   [
00213     uuid(FC005CE3-3F0B-11D0-9693-00AA00C149A6),
00214     version(1.0),
00215     helpstring("RmWorker 1.0 Type Library")
00216   ]
00217   library RMWORKERLib
00218   {
00219     importlib("stdole2.tlb");
00220
00221
00222
00223     [
00224       uuid(FC005CE5-3F0B-11D0-9693-00AA00C149A6),
00225       helpstring("RmWorker Class")
00226     ]
00227     coclass CRmWorkerObj
00228     {
00229       [default] interface IRmWorker;
00230       interface IRmWorkerPriv;
00231     };
00232   };
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/foldernode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

foldernode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CFolderNode class.  This node is a child of
00014 //                CDeviceNode.  It represents a Virtual Storage folder
00015 //
00016 //
00017
00018
00019 #ifndef _CLASS_CFOLDERNODE_
00020 #define _CLASS_CFOLDERNODE_
00021
00022 #include "Globals.h"
00023 #include "BaseNode.h"
00024
00025
00026 class CComponentData;        // References
00027
00028 //---------------------------------------------------------------------------
00029 class CFolderNode : public CBaseNode
00030 {
00031   public:
00032     CFolderNode();
00033     virtual ~CFolderNode();
00034
00035     HRESULT Initialize( NODE_PROPERTIES* pNodeProps );
00036
00037   ///////////////////////////////////////////////////////////////////////////
00038   // Virtual methods
00039   public:
00040     ULONG   GetNodeType() { return NODETYPE_FOLDER; }
00041     GUID&   GetNodeGUID() { return thisGUID; }
00042
00043     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00044     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00045     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00046
00047   ///////////////////////////////////////////////////////////////////////////
00048   //  Notification handlers
00049   //
00050   public:
00051     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00052     HRESULT OnShow( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00053     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData );
00054     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData );
00055
00056   ///////////////////////////////////////////////////////////////////////////
00057   //  Context Menu methods
00058   //
00059   HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00060   HRESULT Command( long lCommandID );
00061
00062   private:
00063     static GUID      thisGUID;
00064     DWORD            m_dwAttributes;
00065     CComponentData*  m_pCompData;
00066 };
00067
00068 #endif //_CLASS_CFOLDERNODE_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Margin Member List

This is the complete list of members for Margin, including all inherited members.
bottom | Margin
bottominner | Margin
left | Margin
right | Margin
top | Margin
topinner | Margin
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/list.h Source File

  • Dataaccess
  • oledb
  • tablecopy

list.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module LIST.H
00008 //
00009 //-----------------------------------------------------------------------------
00010 #ifndef _LIST_H_
00011 #define _LIST_H_
00012
00013 /////////////////////////////////////////////////////////////////////////////
00014 // Includes
00015 //
00016 /////////////////////////////////////////////////////////////////////////////
00017
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // Defines
00021 //
00022 /////////////////////////////////////////////////////////////////////////////
00023 typedef void* LISTPOS;
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // CNode
00028 //
00029 /////////////////////////////////////////////////////////////////////////////
00030 template <class TYPE> class CNode
00031 {
00032 public:
00033   // constructors
00034   CNode(TYPE val, CNode* pPrevNode, CNode* pNextNode);
00035
00036   // members
00037   TYPE     m_data;       // element data
00038   CNode*   m_pNextNode;  // next CNode
00039   CNode*   m_pPrevNode;  // prev CNode
00040 };
00041
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // CNode::CNode
00045 //
00046 /////////////////////////////////////////////////////////////////////////////
00047 template <class TYPE> CNode<TYPE>::CNode(TYPE data, CNode* pPrevNode, CNode* pNextNode)
00048 {
00049   //Constructor
00050   m_data = data;
00051   m_pPrevNode = pPrevNode;
00052   m_pNextNode = pNextNode;
00053 }
00054
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CList
00059 //
00060 /////////////////////////////////////////////////////////////////////////////
00061 template <class TYPE> class CList
00062 {
00063 public:
00064
00065   //constructors
00066   CList();
00067   virtual ~CList();
00068
00069   //members
00070
00071   //list modifying operations
00072   virtual LISTPOS AddHead(TYPE element);    // Add to Head
00073   virtual LISTPOS AddTail(TYPE element);    // Add to Tail
00074
00075   virtual LISTPOS InsertBefore(LISTPOS position, TYPE element); // Add before position
00076   virtual LISTPOS InsertAfter(LISTPOS position, TYPE element);  // Add after position
00077
00078   virtual TYPE  RemoveHead();       // Remove from Head
00079   virtual TYPE  RemoveTail();       // Remove from Tail
00080   virtual TYPE  RemoveAt(LISTPOS position); // RemoveAt position
00081   virtual void  RemoveAll();        // Remove all elements
00082
00083   //Seeking methods
00084   virtual LISTPOS Find(TYPE element);         // Find element
00085
00086   //Peek methods
00087   virtual LISTPOS GetHeadPosition();      // Head Position
00088   virtual LISTPOS GetTailPosition();      // Tail Position
00089
00090   virtual TYPE    GetHead();          // Head element
00091   virtual TYPE    GetTail();          // Tail element
00092   virtual TYPE    GetNext(LISTPOS& position); // Next element
00093   virtual TYPE    GetPrev(LISTPOS& position); // Prev element
00094
00095   //Data methods
00096   virtual TYPE    GetAt(LISTPOS position) const;      //Get element value
00097   virtual TYPE    SetAt(LISTPOS position, TYPE element);  //Set element value
00098
00099   //Array-like methods
00100   virtual LISTPOS FindIndex(ULONG iIndex);  //Index element
00101
00102   //informational methods
00103   virtual BOOL    IsEmpty();          // IsEmpty
00104   virtual ULONG   GetCount();         // Elements in the list
00105
00106 private:
00107   //data
00108   CNode<TYPE>*    m_pHeadNode;        // Head of CList
00109   CNode<TYPE>*    m_pTailNode;        // Tail of CList
00110
00111   ULONG       m_ulElements;       // Elements in the list
00112 };
00113
00114
00115 /////////////////////////////////////////////////////////////////////////////
00116 // CList::CList
00117 //
00118 /////////////////////////////////////////////////////////////////////////////
00119 template <class TYPE> CList<TYPE>::CList()
00120 {
00121   //constructor
00122   m_pHeadNode = NULL;
00123   m_pTailNode = NULL;
00124   m_ulElements = 0;
00125 }
00126
00127 /////////////////////////////////////////////////////////////////////////////
00128 // CList::~CList
00129 //
00130 /////////////////////////////////////////////////////////////////////////////
00131 template <class TYPE> CList<TYPE>::~CList()
00132 {
00133   //Remove all elements
00134   RemoveAll();
00135 }
00136
00137
00138 /////////////////////////////////////////////////////////////////////////////
00139 // CList::AddHead
00140 //
00141 /////////////////////////////////////////////////////////////////////////////
00142 template <class TYPE> LISTPOS CList<TYPE>::AddHead(TYPE element)
00143 {
00144   //Add to the Head of the CList, (stack)
00145   CNode<TYPE>* pHeadNode = new CNode<TYPE>(element, NULL, m_pHeadNode);
00146   ASSERT(pHeadNode);
00147
00148   //If there was a list hook the head->prev to the new head
00149   if(m_pHeadNode)
00150     m_pHeadNode->m_pPrevNode = pHeadNode;
00151
00152   //If there isn't a tail element, hook it to the head
00153   if(!m_pTailNode)
00154     m_pTailNode = pHeadNode;
00155
00156   m_pHeadNode = pHeadNode;
00157   m_ulElements++;
00158   return m_pHeadNode;
00159 }
00160
00161
00162 /////////////////////////////////////////////////////////////////////////////
00163 // CList::AddTail
00164 //
00165 /////////////////////////////////////////////////////////////////////////////
00166 template <class TYPE> LISTPOS CList<TYPE>::AddTail(TYPE element)
00167 {
00168   //Add to the m_pTailNode of the CList
00169   CNode<TYPE>* pTailNode = new CNode<TYPE>(element, m_pTailNode, 0);
00170   ASSERT(pTailNode);
00171
00172   //if previously empty
00173   if(!m_pHeadNode)
00174     m_pHeadNode = pTailNode;
00175   else
00176     m_pTailNode->m_pNextNode = pTailNode;
00177
00178   m_pTailNode = pTailNode;
00179   m_ulElements++;
00180   return m_pTailNode;
00181 }
00182
00183
00184
00185 /////////////////////////////////////////////////////////////////////////////
00186 // CList::GetHeadPosition
00187 //
00188 /////////////////////////////////////////////////////////////////////////////
00189 template <class TYPE> inline LISTPOS CList<TYPE>::GetHeadPosition()
00190 {
00191   //return Head element Position
00192   return m_pHeadNode;
00193 }
00194
00195 /////////////////////////////////////////////////////////////////////////////
00196 // CList::GetTailPosition
00197 //
00198 /////////////////////////////////////////////////////////////////////////////
00199 template <class TYPE> inline LISTPOS CList<TYPE>::GetTailPosition()
00200 {
00201   //return Tail element Position
00202   return m_pTailNode;
00203 }
00204
00205 /////////////////////////////////////////////////////////////////////////////
00206 // CList::GetHead
00207 //
00208 /////////////////////////////////////////////////////////////////////////////
00209 template <class TYPE> inline TYPE CList<TYPE>::GetHead()
00210 {
00211   //return Head element value
00212   ASSERT(m_pHeadNode);
00213   return m_pHeadNode->m_data;
00214 }
00215
00216 /////////////////////////////////////////////////////////////////////////////
00217 // CList::AddTail
00218 //
00219 /////////////////////////////////////////////////////////////////////////////
00220 template <class TYPE> inline TYPE CList<TYPE>::GetTail()
00221 {
00222   // return Tail element value
00223   ASSERT(m_pTailNode);
00224   return m_pTailNode->m_data;
00225 }
00226
00227
00228 /////////////////////////////////////////////////////////////////////////////
00229 // CList::GetNext
00230 //
00231 /////////////////////////////////////////////////////////////////////////////
00232 template <class TYPE> inline TYPE CList<TYPE>::GetNext(LISTPOS& position)
00233 {
00234   ASSERT(position);
00235
00236   //Set position to the next element
00237   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00238   position = pNode->m_pNextNode;
00239
00240   //return the current element
00241   return pNode->m_data;
00242 }
00243
00244
00245 /////////////////////////////////////////////////////////////////////////////
00246 // CList::GetPrev
00247 //
00248 /////////////////////////////////////////////////////////////////////////////
00249 template <class TYPE> inline TYPE CList<TYPE>::GetPrev(LISTPOS& position)
00250 {
00251   ASSERT(position);
00252
00253   //Set position to the next element
00254   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00255   position = pNode->m_pPrevNode;
00256
00257   //return the current element
00258   return pNode->m_data;
00259 }
00260
00261
00262 /////////////////////////////////////////////////////////////////////////////
00263 // CList::GetAt
00264 //
00265 /////////////////////////////////////////////////////////////////////////////
00266 template <class TYPE> inline TYPE CList<TYPE>::GetAt(LISTPOS position) const
00267 {
00268   ASSERT(position);
00269   return ((CNode<TYPE>*)position)->m_data;
00270 }
00271
00272 /////////////////////////////////////////////////////////////////////////////
00273 // CList::SetAt
00274 //
00275 /////////////////////////////////////////////////////////////////////////////
00276 template <class TYPE> inline TYPE CList<TYPE>::SetAt(LISTPOS position, TYPE element)
00277 {
00278   ASSERT(position);
00279
00280   //Save the old data
00281   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00282   TYPE oldData = pNode->m_data;
00283
00284   //Store new data
00285   pNode->m_data = element;
00286
00287   //return olddata
00288   return oldData;
00289 }
00290
00291
00292 /////////////////////////////////////////////////////////////////////////////
00293 // CList::Find
00294 //
00295 /////////////////////////////////////////////////////////////////////////////
00296 template <class TYPE> LISTPOS CList<TYPE>::Find(TYPE element)
00297 {
00298   //return pointer to found element
00299   for(CNode<TYPE>* p = m_pHeadNode; p; p = p->m_pNextNode)
00300     if(p->m_data == element)
00301     return p;   // return position to found CNode
00302
00303   return NULL;  // return NULL if not found
00304 }
00305
00306
00307 /////////////////////////////////////////////////////////////////////////////
00308 // CList::IsEmpty
00309 //
00310 /////////////////////////////////////////////////////////////////////////////
00311 template <class TYPE> inline BOOL CList<TYPE>::IsEmpty()
00312 {
00313   // returns TRUE if Empty
00314   return m_ulElements == 0;
00315 }
00316
00317
00318
00319 /////////////////////////////////////////////////////////////////////////////
00320 // CList::RemoveHead
00321 //
00322 /////////////////////////////////////////////////////////////////////////////
00323 template <class TYPE> TYPE CList<TYPE>::RemoveHead()
00324 {
00325   //Remove and return from the Head of the List
00326   ASSERT(m_pHeadNode);
00327
00328   CNode<TYPE>* pHeadNode = m_pHeadNode; // pointer to the Removed node
00329   TYPE element = GetHead();       //make a copy, before deleteing
00330
00331   m_pHeadNode = pHeadNode->m_pNextNode;   // reroute Head to exclude the first element
00332   if(m_pHeadNode)
00333     m_pHeadNode->m_pPrevNode = NULL;
00334   else
00335     m_pTailNode = NULL;
00336
00337   m_ulElements--;
00338   delete pHeadNode;           // delete head
00339   return element;
00340 }
00341
00342
00343 /////////////////////////////////////////////////////////////////////////////
00344 // CList::RemoveTail
00345 //
00346 /////////////////////////////////////////////////////////////////////////////
00347 template <class TYPE> TYPE CList<TYPE>::RemoveTail()
00348 {
00349   //Remove and return from the m_pTailNode of the CList
00350   ASSERT(m_pTailNode);
00351
00352   CNode<TYPE>* pTailNode = m_pTailNode->m_pPrevNode;
00353   TYPE element = GetTail();  //make a copy before deleteing
00354
00355   m_pTailNode = pTailNode;
00356   if(m_pTailNode)
00357     m_pTailNode->m_pNextNode = NULL;
00358   else
00359     m_pHeadNode = NULL;
00360
00361   m_ulElements--;
00362   delete m_pTailNode;
00363   return element;
00364 }
00365
00366
00367 /////////////////////////////////////////////////////////////////////////////
00368 // CList::RemoveAt
00369 //
00370 /////////////////////////////////////////////////////////////////////////////
00371 template <class TYPE> TYPE CList<TYPE>::RemoveAt(LISTPOS position)
00372 {
00373   //Remove CList[position]
00374   ASSERT(position);
00375
00376   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00377   TYPE oldData = pNode->m_data;
00378
00379   // If removing the head
00380   if (pNode == m_pHeadNode)
00381     m_pHeadNode = pNode->m_pNextNode;
00382   else
00383     pNode->m_pPrevNode->m_pNextNode = pNode->m_pNextNode;
00384
00385   //If removing the tail
00386   if (pNode == m_pTailNode)
00387     m_pTailNode = pNode->m_pPrevNode;
00388   else
00389     pNode->m_pNextNode->m_pPrevNode = pNode->m_pPrevNode;
00390
00391   m_ulElements--;
00392   delete pNode;
00393   return oldData;
00394 }
00395
00396
00397 /////////////////////////////////////////////////////////////////////////////
00398 // CList::RemoveAll
00399 //
00400 /////////////////////////////////////////////////////////////////////////////
00401 template <class TYPE> void CList<TYPE>::RemoveAll()
00402 {
00403   // Remove all items from the CList
00404   CNode<TYPE>* pNode = m_pHeadNode;
00405   while(pNode)
00406   {
00407     CNode<TYPE>* pTemp = pNode;
00408     pNode = pNode->m_pNextNode;
00409     delete pTemp;
00410   }
00411
00412   m_pHeadNode   = NULL;
00413   m_pTailNode   = NULL;
00414   m_ulElements    = 0;
00415 }
00416
00417
00418 /////////////////////////////////////////////////////////////////////////////
00419 // CList::GetCount
00420 //
00421 /////////////////////////////////////////////////////////////////////////////
00422 template <class TYPE> inline ULONG CList<TYPE>::GetCount()
00423 {
00424   // return the Length
00425   return m_ulElements;
00426 }
00427
00428
00429 /////////////////////////////////////////////////////////////////////////////
00430 // CList::InsertBefore
00431 //
00432 /////////////////////////////////////////////////////////////////////////////
00433 template <class TYPE> LISTPOS CList<TYPE>::InsertBefore(LISTPOS position, TYPE element)
00434 {
00435   //insert before the position
00436   if(position == m_pHeadNode)    // Add before Head
00437     return AddHead(element);
00438
00439   CNode<TYPE>* pOldNode = (CNode<TYPE>*)position;
00440
00441   //otherwise a little more difficult
00442   CNode<TYPE>* pNewNode = new CNode<TYPE>(element, pOldNode->m_pPrevNode, pOldNode);
00443
00444   //Create the new node
00445   pNewNode->m_pNextNode = new CNode<TYPE>(element, pOldNode->m_pPrevNode, pOldNode->m_pNextNode);
00446
00447   //Hook up before after nodes to it
00448   pOldNode->m_pPrevNode->m_pNextNode = pNewNode;
00449   pOldNode->m_pPrevNode = pNewNode;
00450
00451   m_ulElements++;
00452   return pNewNode;
00453 }
00454
00455
00456
00457 /////////////////////////////////////////////////////////////////////////////
00458 // CList::InsertAfter
00459 //
00460 /////////////////////////////////////////////////////////////////////////////
00461 template <class TYPE> LISTPOS CList<TYPE>::InsertAfter(LISTPOS position, TYPE element)
00462 {
00463   //insert after the position
00464   if(position == m_pTailNode)     // Add after the m_pTailNode
00465     return AddTail(element);
00466
00467   CNode<TYPE>* pOldNode = (CNode<TYPE>*)position;
00468
00469   //other wise a little more difficult
00470   CNode<TYPE>* pNewNode = new CNode<TYPE>(element, pOldNode, pOldNode->m_pNextNode);
00471
00472   //Hook up before after nodes to it
00473   pOldNode->m_pNextNode->m_pPrevNode = pNewNode;
00474   pOldNode->m_pNextNode = pNewNode;
00475
00476   m_ulElements++;
00477   return pNewNode;
00478 }
00479
00480
00481 /////////////////////////////////////////////////////////////////////////////
00482 // CList::FindIndex
00483 //
00484 /////////////////////////////////////////////////////////////////////////////
00485 template <class TYPE> LISTPOS CList<TYPE>::FindIndex(ULONG iIndex)
00486 {
00487   ASSERT(iIndex>=0 && iIndex<m_ulElements);
00488
00489   CNode<TYPE>* pNode = m_pHeadNode;
00490
00491   //Find the specified index
00492   while(iIndex--)
00493     pNode = pNode->m_pNextNode;
00494
00495   return (LISTPOS)pNode;
00496 }
00497
00498 #endif //_LIST_H_
00499
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSDKSampleStorageSystem Member List

This is the complete list of members for CSDKSampleStorageSystem, including all inherited members.
CreateDataSourceDirectory(IWMSCommandContext *pCommandContext, LPWSTR pszContainerName, DWORD dwFlags, IWMSDataSourcePluginCallback *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
CSDKSampleStorageSystem() | CSDKSampleStorageSystem |
DeleteDataContainer(LPWSTR pszContainerName, DWORD dwFlags, IWMSDataSourcePluginCallback __RPC_FAR *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
DeleteDirectory(LPWSTR pszContainerName, DWORD dwFlags, IWMSDataSourcePluginCallback *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
DisablePlugin() | CSDKSampleStorageSystem |
EnablePlugin(long *pdwFlags, long *pdwHeartbeatPeriod) | CSDKSampleStorageSystem |
GetCustomAdminInterface(IDispatch **ppValue) | CSDKSampleStorageSystem | [virtual]
GetDataContainerVersion(IWMSCommandContext __RPC_FAR *pCommandContext, IWMSContext __RPC_FAR *pUserContext, IWMSContext __RPC_FAR *pPresContext, LPWSTR pszContainerName, DWORD dwFlags, IWMSDataSourcePluginCallback __RPC_FAR *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
GetDataSourceAttributes(DWORD __RPC_FAR *pdwFlags) | CSDKSampleStorageSystem | [virtual]
GetRootDirectories(LPWSTR __RPC_FAR *pstrRootDirectoryList, DWORD dwMaxRoots, IWMSDataSourcePluginCallback __RPC_FAR *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
InitializePlugin(IWMSContext __RPC_FAR *pServerContext, IWMSNamedValues *pNamedValues, IWMSClassObject __RPC_FAR *pClassFactory) | CSDKSampleStorageSystem | [virtual]
m_dwPageSize | CSDKSampleStorageSystem | [protected]
m_pClassFactory | CSDKSampleStorageSystem | [protected]
m_pNamedValues | CSDKSampleStorageSystem | [protected]
m_pServerContext | CSDKSampleStorageSystem | [protected]
OnHeartbeat() | CSDKSampleStorageSystem | [virtual]
OpenDataContainer(IWMSCommandContext *pCommandContext, IWMSContext *pUserContext, IWMSContext *pPresentationContext, LPWSTR pszContainerName, DWORD dwFlags, IWMSBufferAllocator __RPC_FAR *pBufferAllocator, IWMSDataSourcePluginCallback __RPC_FAR *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
OpenDirectory(IWMSCommandContext *pCommandContext, IWMSContext *pUserContext, IWMSContext *pPresentationContext, LPWSTR pszContainerName, DWORD dwFlags, IWMSBufferAllocator *pBufferAllocator, IWMSDataSourcePluginCallback *pCallback, QWORD qwContext) | CSDKSampleStorageSystem | [virtual]
ShutdownPlugin() | CSDKSampleStorageSystem | [virtual]
~CSDKSampleStorageSystem() | CSDKSampleStorageSystem | [virtual]
Generated on Wed Nov 13 2024 16:57:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/DsBrowse/bitmaps/winres.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • DsBrowse
  • bitmaps

winres.h

Go to the documentation of this file.
00001 // Microsoft Foundation Classes C++ library.
00002 // Copyright (C) 1992 - 2000 Microsoft Corporation,
00003 // All rights reserved.
00004
00005 // This source code is only intended as a supplement to the
00006 // Microsoft Foundation Classes Reference and Microsoft
00007 // QuickHelp and/or WinHelp documentation provided with the library.
00008 // See these sources for detailed information regarding the
00009 // Microsoft Foundation Classes product.
00010
00011 // winres.h - Windows resource definitions
00012 //  extracted from WINDOWS.H
00013 //          Version 3.10
00014 //          Copyright (c) 1985 - 2000 Microsoft Corp. All rights reserved.
00015 //
00016
00017 #ifdef APSTUDIO_INVOKED
00018 #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols
00019 #endif
00020
00021 #define OBM_CLOSE       32754
00022 #define OBM_UPARROW     32753
00023 #define OBM_DNARROW     32752
00024 #define OBM_RGARROW     32751
00025 #define OBM_LFARROW     32750
00026 #define OBM_REDUCE      32749
00027 #define OBM_ZOOM        32748
00028 #define OBM_RESTORE     32747
00029 #define OBM_REDUCED     32746
00030 #define OBM_ZOOMD       32745
00031 #define OBM_RESTORED    32744
00032 #define OBM_UPARROWD    32743
00033 #define OBM_DNARROWD    32742
00034 #define OBM_RGARROWD    32741
00035 #define OBM_LFARROWD    32740
00036 #define OBM_MNARROW     32739
00037 #define OBM_COMBO       32738
00038 #define OBM_UPARROWI    32737
00039 #define OBM_DNARROWI    32736
00040 #define OBM_RGARROWI    32735
00041 #define OBM_LFARROWI    32734
00042 #define OBM_OLD_CLOSE   32767
00043 #define OBM_SIZE        32766
00044 #define OBM_OLD_UPARROW 32765
00045 #define OBM_OLD_DNARROW 32764
00046 #define OBM_OLD_RGARROW 32763
00047 #define OBM_OLD_LFARROW 32762
00048 #define OBM_BTSIZE      32761
00049 #define OBM_CHECK       32760
00050 #define OBM_CHECKBOXES  32759
00051 #define OBM_BTNCORNERS  32758
00052 #define OBM_OLD_REDUCE  32757
00053 #define OBM_OLD_ZOOM    32756
00054 #define OBM_OLD_RESTORE 32755
00055 #define OCR_NORMAL      32512
00056 #define OCR_IBEAM       32513
00057 #define OCR_WAIT        32514
00058 #define OCR_CROSS       32515
00059 #define OCR_UP          32516
00060 #define OCR_SIZE        32640
00061 #define OCR_ICON        32641
00062 #define OCR_SIZENWSE    32642
00063 #define OCR_SIZENESW    32643
00064 #define OCR_SIZEWE      32644
00065 #define OCR_SIZENS      32645
00066 #define OCR_SIZEALL     32646
00067 #define OCR_ICOCUR      32647
00068 #define OIC_SAMPLE      32512
00069 #define OIC_HAND        32513
00070 #define OIC_QUES        32514
00071 #define OIC_BANG        32515
00072 #define OIC_NOTE        32516
00073
00074 #define WS_OVERLAPPED   0x00000000L
00075 #define WS_POPUP        0x80000000L
00076 #define WS_CHILD        0x40000000L
00077 #define WS_CLIPSIBLINGS 0x04000000L
00078 #define WS_CLIPCHILDREN 0x02000000L
00079 #define WS_VISIBLE      0x10000000L
00080 #define WS_DISABLED     0x08000000L
00081 #define WS_MINIMIZE     0x20000000L
00082 #define WS_MAXIMIZE     0x01000000L
00083 #define WS_CAPTION      0x00C00000L
00084 #define WS_BORDER       0x00800000L
00085 #define WS_DLGFRAME     0x00400000L
00086 #define WS_VSCROLL      0x00200000L
00087 #define WS_HSCROLL      0x00100000L
00088 #define WS_SYSMENU      0x00080000L
00089 #define WS_THICKFRAME   0x00040000L
00090 #define WS_MINIMIZEBOX  0x00020000L
00091 #define WS_MAXIMIZEBOX  0x00010000L
00092 #define WS_GROUP        0x00020000L
00093 #define WS_TABSTOP      0x00010000L
00094
00095 // other aliases
00096 #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
00097 #define WS_POPUPWINDOW  (WS_POPUP | WS_BORDER | WS_SYSMENU)
00098 #define WS_CHILDWINDOW  (WS_CHILD)
00099 #define WS_TILED        WS_OVERLAPPED
00100 #define WS_ICONIC       WS_MINIMIZE
00101 #define WS_SIZEBOX      WS_THICKFRAME
00102 #define WS_TILEDWINDOW  WS_OVERLAPPEDWINDOW
00103
00104 #define VK_LBUTTON      0x01
00105 #define VK_RBUTTON      0x02
00106 #define VK_CANCEL       0x03
00107 #define VK_MBUTTON      0x04
00108 #define VK_BACK         0x08
00109 #define VK_TAB          0x09
00110 #define VK_CLEAR        0x0C
00111 #define VK_RETURN       0x0D
00112 #define VK_SHIFT        0x10
00113 #define VK_CONTROL      0x11
00114 #define VK_MENU         0x12
00115 #define VK_PAUSE        0x13
00116 #define VK_CAPITAL      0x14
00117 #define VK_ESCAPE       0x1B
00118 #define VK_SPACE        0x20
00119 #define VK_PRIOR        0x21
00120 #define VK_NEXT         0x22
00121 #define VK_END          0x23
00122 #define VK_HOME         0x24
00123 #define VK_LEFT         0x25
00124 #define VK_UP           0x26
00125 #define VK_RIGHT        0x27
00126 #define VK_DOWN         0x28
00127 #define VK_SELECT       0x29
00128 #define VK_PRINT        0x2A
00129 #define VK_EXECUTE      0x2B
00130 #define VK_SNAPSHOT     0x2C
00131 #define VK_INSERT       0x2D
00132 #define VK_DELETE       0x2E
00133 #define VK_HELP         0x2F
00134 #define VK_NUMPAD0      0x60
00135 #define VK_NUMPAD1      0x61
00136 #define VK_NUMPAD2      0x62
00137 #define VK_NUMPAD3      0x63
00138 #define VK_NUMPAD4      0x64
00139 #define VK_NUMPAD5      0x65
00140 #define VK_NUMPAD6      0x66
00141 #define VK_NUMPAD7      0x67
00142 #define VK_NUMPAD8      0x68
00143 #define VK_NUMPAD9      0x69
00144 #define VK_MULTIPLY     0x6A
00145 #define VK_ADD          0x6B
00146 #define VK_SEPARATOR    0x6C
00147 #define VK_SUBTRACT     0x6D
00148 #define VK_DECIMAL      0x6E
00149 #define VK_DIVIDE       0x6F
00150 #define VK_F1           0x70
00151 #define VK_F2           0x71
00152 #define VK_F3           0x72
00153 #define VK_F4           0x73
00154 #define VK_F5           0x74
00155 #define VK_F6           0x75
00156 #define VK_F7           0x76
00157 #define VK_F8           0x77
00158 #define VK_F9           0x78
00159 #define VK_F10          0x79
00160 #define VK_F11          0x7A
00161 #define VK_F12          0x7B
00162 #define VK_F13          0x7C
00163 #define VK_F14          0x7D
00164 #define VK_F15          0x7E
00165 #define VK_F16          0x7F
00166 #define VK_F17          0x80
00167 #define VK_F18          0x81
00168 #define VK_F19          0x82
00169 #define VK_F20          0x83
00170 #define VK_F21          0x84
00171 #define VK_F22          0x85
00172 #define VK_F23          0x86
00173 #define VK_F24          0x87
00174 #define VK_NUMLOCK      0x90
00175 #define VK_SCROLL       0x91
00176
00177 #define SC_SIZE         0xF000
00178 #define SC_MOVE         0xF010
00179 #define SC_MINIMIZE     0xF020
00180 #define SC_MAXIMIZE     0xF030
00181 #define SC_NEXTWINDOW   0xF040
00182 #define SC_PREVWINDOW   0xF050
00183 #define SC_CLOSE        0xF060
00184 #define SC_VSCROLL      0xF070
00185 #define SC_HSCROLL      0xF080
00186 #define SC_MOUSEMENU    0xF090
00187 #define SC_KEYMENU      0xF100
00188 #define SC_ARRANGE      0xF110
00189 #define SC_RESTORE      0xF120
00190 #define SC_TASKLIST     0xF130
00191 #define SC_SCREENSAVE   0xF140
00192 #define SC_HOTKEY       0xF150
00193
00194 #define DS_ABSALIGN     0x01L
00195 #define DS_SYSMODAL     0x02L
00196 #define DS_LOCALEDIT    0x20L
00197 #define DS_SETFONT      0x40L
00198 #define DS_MODALFRAME   0x80L
00199 #define DS_NOIDLEMSG    0x100L
00200
00201 #define SS_LEFT         0x00000000L
00202 #define SS_CENTER       0x00000001L
00203 #define SS_RIGHT        0x00000002L
00204 #define SS_ICON         0x00000003L
00205 #define SS_BLACKRECT    0x00000004L
00206 #define SS_GRAYRECT     0x00000005L
00207 #define SS_WHITERECT    0x00000006L
00208 #define SS_BLACKFRAME   0x00000007L
00209 #define SS_GRAYFRAME    0x00000008L
00210 #define SS_WHITEFRAME   0x00000009L
00211 #define SS_SIMPLE       0x0000000BL
00212 #define SS_LEFTNOWORDWRAP 0x0000000CL
00213 #define SS_NOPREFIX     0x00000080L
00214
00215 #define BS_PUSHBUTTON   0x00000000L
00216 #define BS_DEFPUSHBUTTON 0x00000001L
00217 #define BS_CHECKBOX     0x00000002L
00218 #define BS_AUTOCHECKBOX 0x00000003L
00219 #define BS_RADIOBUTTON  0x00000004L
00220 #define BS_3STATE       0x00000005L
00221 #define BS_AUTO3STATE   0x00000006L
00222 #define BS_GROUPBOX     0x00000007L
00223 #define BS_USERBUTTON   0x00000008L
00224 #define BS_AUTORADIOBUTTON  0x00000009L
00225 #define BS_OWNERDRAW        0x0000000BL
00226 #define BS_LEFTTEXT     0x00000020L
00227
00228 #define ES_LEFT         0x00000000L
00229 #define ES_CENTER       0x00000001L
00230 #define ES_RIGHT        0x00000002L
00231 #define ES_MULTILINE    0x00000004L
00232 #define ES_UPPERCASE    0x00000008L
00233 #define ES_LOWERCASE    0x00000010L
00234 #define ES_PASSWORD     0x00000020L
00235 #define ES_AUTOVSCROLL  0x00000040L
00236 #define ES_AUTOHSCROLL  0x00000080L
00237 #define ES_NOHIDESEL    0x00000100L
00238 #define ES_OEMCONVERT   0x00000400L
00239 #define ES_READONLY     0x00000800L
00240 #define ES_WANTRETURN   0x00001000L
00241
00242 #define SBS_HORZ        0x0000L
00243 #define SBS_VERT        0x0001L
00244 #define SBS_TOPALIGN    0x0002L
00245 #define SBS_LEFTALIGN   0x0002L
00246 #define SBS_BOTTOMALIGN 0x0004L
00247 #define SBS_RIGHTALIGN  0x0004L
00248 #define SBS_SIZEBOXTOPLEFTALIGN 0x0002L
00249 #define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L
00250 #define SBS_SIZEBOX     0x0008L
00251
00252 #define LBS_NOTIFY      0x0001L
00253 #define LBS_SORT        0x0002L
00254 #define LBS_NOREDRAW    0x0004L
00255 #define LBS_MULTIPLESEL 0x0008L
00256 #define LBS_OWNERDRAWFIXED 0x0010L
00257 #define LBS_OWNERDRAWVARIABLE 0x0020L
00258 #define LBS_HASSTRINGS  0x0040L
00259 #define LBS_USETABSTOPS 0x0080L
00260 #define LBS_NOINTEGRALHEIGHT 0x0100L
00261 #define LBS_MULTICOLUMN 0x0200L
00262 #define LBS_WANTKEYBOARDINPUT 0x0400L
00263 #define LBS_EXTENDEDSEL 0x0800L
00264 #define LBS_DISABLENOSCROLL 0x1000L
00265 #define LBS_STANDARD    (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
00266
00267 #define CBS_SIMPLE      0x0001L
00268 #define CBS_DROPDOWN    0x0002L
00269 #define CBS_DROPDOWNLIST 0x0003L
00270 #define CBS_OWNERDRAWFIXED 0x0010L
00271 #define CBS_OWNERDRAWVARIABLE 0x0020L
00272 #define CBS_AUTOHSCROLL 0x0040L
00273 #define CBS_OEMCONVERT  0x0080L
00274 #define CBS_SORT        0x0100L
00275 #define CBS_HASSTRINGS  0x0200L
00276 #define CBS_NOINTEGRALHEIGHT 0x0400L
00277 #define CBS_DISABLENOSCROLL 0x0800L
00278
00279 // operation messages sent to DLGINIT
00280 #define WM_USER         0x0400
00281 #define LB_ADDSTRING    (WM_USER+1)
00282 #define CB_ADDSTRING    (WM_USER+3)
00283
00284 #ifdef APSTUDIO_INVOKED
00285 #undef APSTUDIO_HIDDEN_SYMBOLS
00286 #endif
00287
00288 #define IDOK            1
00289 #define IDCANCEL        2
00290 #define IDABORT         3
00291 #define IDRETRY         4
00292 #define IDIGNORE        5
00293 #define IDYES           6
00294 #define IDNO            7
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/celib.cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

celib.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1995 - 1999
00006 //
00007 //  File:       celib.cpp
00008 //
00009 //  Contents:   helper functions
00010 //
00011 //--------------------------------------------------------------------------
00012
00013 #include "pch.cpp"
00014 #pragma hdrstop
00015
00016 #include "celib.h"
00017 #include <assert.h>
00018
00019 //+--------------------------------------------------------------------------
00020 // ceDecodeObject -- call CryptDecodeObject, and allocate memory for output
00021 //
00022 //+--------------------------------------------------------------------------
00023
00024 #pragma warning(push)
00025 #pragma warning(disable: 4100)  // unreferenced formal parameter
00026 BOOL
00027 ceDecodeObject(
00028     IN DWORD dwEncodingType,
00029     IN LPCSTR lpszStructType,
00030     IN BYTE const *pbEncoded,
00031     IN DWORD cbEncoded,
00032     IN BOOL fCoTaskMemAlloc,  // referenced only by assert
00033     OUT VOID **ppvStructInfo,
00034     OUT DWORD *pcbStructInfo)
00035 {
00036     BOOL b;
00037
00038     assert(!fCoTaskMemAlloc);
00039     *ppvStructInfo = NULL;
00040     *pcbStructInfo = 0;
00041     while (TRUE)
00042     {
00043   b = CryptDecodeObject(
00044         dwEncodingType,
00045         lpszStructType,
00046         pbEncoded,
00047         cbEncoded,
00048         0,                  // dwFlags
00049         *ppvStructInfo,
00050         pcbStructInfo);
00051   if (b && 0 == *pcbStructInfo)
00052   {
00053       SetLastError((DWORD) HRESULT_FROM_WIN32(ERROR_INVALID_DATA));
00054       b = FALSE;
00055   }
00056   if (!b)
00057   {
00058       if (NULL != *ppvStructInfo)
00059       {
00060     HRESULT hr = GetLastError();
00061
00062     LocalFree(*ppvStructInfo);
00063     *ppvStructInfo = NULL;
00064     SetLastError(hr);
00065       }
00066       break;
00067   }
00068   if (NULL != *ppvStructInfo)
00069   {
00070       break;
00071   }
00072   *ppvStructInfo = (BYTE *) LocalAlloc(LMEM_FIXED, *pcbStructInfo);
00073   if (NULL == *ppvStructInfo)
00074   {
00075       b = FALSE;
00076       break;
00077   }
00078     }
00079     return(b);
00080 }
00081 #pragma warning(pop)
00082
00083
00084 #pragma warning(push)
00085 #pragma warning(disable: 4100)  // unreferenced formal parameter
00086 BOOL
00087 ceEncodeObject(
00088     IN DWORD dwEncodingType,
00089     IN LPCSTR lpszStructType,
00090     IN VOID const *pvStructInfo,
00091     IN DWORD dwFlags,   // referenced only by assert
00092     IN BOOL fCoTaskMemAlloc,  // referenced only by assert
00093     OUT BYTE **ppbEncoded,
00094     OUT DWORD *pcbEncoded)
00095 {
00096     BOOL b;
00097
00098     assert(0 == dwFlags);
00099     assert(!fCoTaskMemAlloc);
00100     *ppbEncoded = NULL;
00101     *pcbEncoded = 0;
00102     while (TRUE)
00103     {
00104   b = CryptEncodeObject(
00105         dwEncodingType,
00106         lpszStructType,
00107         const_cast<VOID *>(pvStructInfo),
00108         *ppbEncoded,
00109         pcbEncoded);
00110   if (b && 0 == *pcbEncoded)
00111   {
00112       SetLastError((DWORD) HRESULT_FROM_WIN32(ERROR_INVALID_DATA));
00113       b = FALSE;
00114   }
00115   if (!b)
00116   {
00117       if (NULL != *ppbEncoded)
00118       {
00119     HRESULT hr = GetLastError();
00120
00121     LocalFree(*ppbEncoded);
00122     *ppbEncoded = NULL;
00123     SetLastError(hr);
00124       }
00125       break;
00126   }
00127   if (NULL != *ppbEncoded)
00128   {
00129       break;
00130   }
00131   *ppbEncoded = (BYTE *) LocalAlloc(LMEM_FIXED, *pcbEncoded);
00132   if (NULL == *ppbEncoded)
00133   {
00134       b = FALSE;
00135       break;
00136   }
00137     }
00138     return(b);
00139 }
00140 #pragma warning(pop)
00141
00142
00143 // The returned pszObjId is a constant that must not be freed.  CryptFindOIDInfo
00144 // has a static internal database that is valid until crypt32.dll is unloaded.
00145
00146 WCHAR const *
00147 ceGetOIDNameA(
00148     IN char const *pszObjId)
00149 {
00150     CRYPT_OID_INFO const *pInfo = NULL;
00151     WCHAR const *pwszName = L"";
00152
00153     // First try looking up the ObjectId as an Extension or Attribute, because
00154     // we get a better Display Name, especially for Subject RDNs: CN, L, etc.
00155     // If that fails, look it up withoput restricting the group.
00156
00157     pInfo = CryptFindOIDInfo(
00158       CRYPT_OID_INFO_OID_KEY,
00159       (VOID *) pszObjId,
00160       CRYPT_EXT_OR_ATTR_OID_GROUP_ID);
00161
00162     if (NULL == pInfo || NULL == pInfo->pwszName || L'\0' == pInfo->pwszName[0])
00163     {
00164   pInfo = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (VOID *) pszObjId, 0);
00165     }
00166     if (NULL != pInfo && NULL != pInfo->pwszName && L'\0' != pInfo->pwszName[0])
00167     {
00168   pwszName = pInfo->pwszName;
00169     }
00170     return(pwszName);
00171 }
00172
00173
00174 WCHAR const *
00175 ceGetOIDName(
00176     IN WCHAR const *pwszObjId)
00177 {
00178     char *pszObjId = NULL;
00179     WCHAR const *pwszName = L"";
00180
00181     if (!ceConvertWszToSz(&pszObjId, pwszObjId, -1))
00182     {
00183   _JumpError(E_OUTOFMEMORY, error, "ceConvertWszToSz");
00184     }
00185     pwszName = ceGetOIDNameA(pszObjId);
00186
00187 error:
00188     if (NULL != pszObjId)
00189     {
00190   LocalFree(pszObjId);
00191     }
00192     return(pwszName);
00193 }
00194
00195
00196 WCHAR *
00197 ceDuplicateString(
00198     IN WCHAR const *pwsz)
00199 {
00200     WCHAR *pwszOut;
00201
00202     pwszOut = (WCHAR *) LocalAlloc(
00203         LMEM_FIXED,
00204         (wcslen(pwsz) + 1) * sizeof(pwsz[0]));
00205     if (NULL != pwszOut)
00206     {
00207   wcscpy(pwszOut, pwsz);
00208     }
00209     return(pwszOut);
00210 }
00211
00212
00213 BOOL
00214 ceConvertWszToSz(
00215     OUT CHAR **ppsz,
00216     IN WCHAR const *pwc,
00217     IN LONG cwc)
00218 {
00219     BOOL fOk = FALSE;
00220     LONG cch = 0;
00221
00222     *ppsz = NULL;
00223     while (TRUE)
00224     {
00225   cch = WideCharToMultiByte(
00226       GetACP(),
00227       0,          // dwFlags
00228       pwc,
00229       cwc,        // cchWideChar, -1 => null terminated
00230       *ppsz,
00231       cch,
00232       NULL,
00233       NULL);
00234   if (0 >= cch)
00235   {
00236       DWORD err;
00237
00238       err = GetLastError();
00239       ceERRORPRINTLINE("WideCharToMultiByte", err);
00240       if (NULL != *ppsz)
00241       {
00242     LocalFree(*ppsz);
00243     *ppsz = NULL;
00244       }
00245       break;
00246   }
00247   if (NULL != *ppsz)
00248   {
00249       fOk = TRUE;
00250       break;
00251   }
00252   *ppsz = (CHAR *) LocalAlloc(LMEM_FIXED, cch + 1);
00253   if (NULL == *ppsz)
00254   {
00255       break;
00256   }
00257     }
00258     return(fOk);
00259 }
00260
00261
00262 BOOL
00263 ceConvertWszToBstr(
00264     OUT BSTR *pbstr,
00265     IN WCHAR const *pwc,
00266     IN LONG cb)
00267 {
00268     BOOL fOk = FALSE;
00269     BSTR bstr;
00270
00271     ceFreeBstr(pbstr);
00272     do
00273     {
00274   bstr = NULL;
00275   if (NULL != pwc)
00276   {
00277       if (-1 == cb)
00278       {
00279     cb = wcslen(pwc) * sizeof(WCHAR);
00280       }
00281       bstr = SysAllocStringByteLen((char const *) pwc, cb);
00282       if (NULL == bstr)
00283       {
00284     break;
00285       }
00286   }
00287   *pbstr = bstr;
00288   fOk = TRUE;
00289     } while (FALSE);
00290     return(fOk);
00291 }
00292
00293
00294 BOOL
00295 ceConvertSzToWsz(
00296     OUT WCHAR **ppwsz,
00297     IN char const *pch,
00298     IN LONG cch)
00299 {
00300     BOOL fOk = FALSE;
00301     LONG cwc = 0;
00302
00303     *ppwsz = NULL;
00304     while (TRUE)
00305     {
00306   cwc = MultiByteToWideChar(GetACP(), 0, pch, cch, *ppwsz, cwc);
00307   if (0 >= cwc)
00308   {
00309       DWORD err;
00310
00311       err = GetLastError();
00312       ceERRORPRINTLINE("MultiByteToWideChar", err);
00313       if (NULL != *ppwsz)
00314       {
00315     LocalFree(*ppwsz);
00316     *ppwsz = NULL;
00317       }
00318       break;
00319   }
00320   if (NULL != *ppwsz)
00321   {
00322       fOk = TRUE;
00323       break;
00324   }
00325   *ppwsz = (WCHAR *) LocalAlloc(LMEM_FIXED, (cwc + 1) * sizeof(WCHAR));
00326   if (NULL == *ppwsz)
00327   {
00328       break;
00329   }
00330     }
00331     return(fOk);
00332 }
00333
00334
00335 BOOL
00336 ceConvertSzToBstr(
00337     OUT BSTR *pbstr,
00338     IN CHAR const *pch,
00339     IN LONG cch)
00340 {
00341     BOOL fOk = FALSE;
00342     BSTR bstr = NULL;
00343     LONG cwc = 0;
00344
00345     ceFreeBstr(pbstr);
00346     if (-1 == cch)
00347     {
00348   cch = strlen(pch);
00349     }
00350     while (TRUE)
00351     {
00352   cwc = MultiByteToWideChar(GetACP(), 0, pch, cch, bstr, cwc);
00353   if (0 >= cwc)
00354   {
00355       //hr = ceHLastError();
00356       //printf("MultiByteToWideChar returned %d (%x)\n", hr, hr);
00357       break;
00358   }
00359   if (NULL != bstr)
00360   {
00361       bstr[cwc] = L'\0';
00362       *pbstr = bstr;
00363       fOk = TRUE;
00364       break;
00365   }
00366   bstr = SysAllocStringLen(NULL, cwc);
00367   if (NULL == bstr)
00368   {
00369       break;
00370   }
00371     }
00372     return(fOk);
00373 }
00374
00375
00376 VOID
00377 ceFreeBstr(
00378     IN OUT BSTR *pstr)
00379 {
00380     if (NULL != *pstr)
00381     {
00382   SysFreeString(*pstr);
00383   *pstr = NULL;
00384     }
00385 }
00386
00387
00388 HRESULT
00389 ceHError(
00390     IN HRESULT hr)
00391 {
00392     assert(S_FALSE != hr);
00393
00394     if (S_OK != hr && S_FALSE != hr && !FAILED(hr))
00395     {
00396         hr = HRESULT_FROM_WIN32(hr);
00397   if ((HRESULT) 0 == HRESULT_CODE(hr))
00398   {
00399       // A call failed without properly setting an error condition!
00400       hr = E_UNEXPECTED;
00401   }
00402   assert(FAILED(hr));
00403     }
00404     return(hr);
00405 }
00406
00407
00408 HRESULT
00409 ceHLastError(VOID)
00410 {
00411     return(ceHError(GetLastError()));
00412 }
00413
00414
00415 VOID
00416 ceErrorPrintLine(
00417     IN char const *pszFile,
00418     IN DWORD line,
00419     IN char const *pszMessage,
00420     IN WCHAR const *pwszData,
00421     IN HRESULT hr)
00422 {
00423     CHAR ach[4096];
00424     LONG cch;
00425
00426 #pragma prefast(disable:53, "PREfast bug 650")
00427     cch = _snprintf(
00428     ach,
00429     sizeof(ach),
00430     "CeLib: Error: %hs(%u): %hs%hs%ws%hs 0x%x (%d)\n",
00431     pszFile,
00432     line,
00433     pszMessage,
00434     NULL == pwszData? "" : szLPAREN,
00435     NULL == pwszData? L"" : pwszData,
00436     NULL == pwszData? "" : szRPAREN,
00437     hr,
00438     hr);
00439 #pragma prefast(enable:53, "re-enable")
00440     if (0 > cch || sizeof(ach) <= cch)
00441     {
00442   strcpy(&ach[sizeof(ach) - 5], "...\n");
00443     }
00444     OutputDebugStringA(ach);
00445     wprintf(L"%hs", ach);
00446 }
00447
00448
00449 HRESULT
00450 ceDateToFileTime(
00451     IN DATE const *pDate,
00452     OUT FILETIME *pft)
00453 {
00454     SYSTEMTIME st;
00455     HRESULT hr = S_OK;
00456
00457     if (*pDate == 0.0)
00458     {
00459         GetSystemTime(&st);
00460     }
00461     else
00462     {
00463   if (!VariantTimeToSystemTime(*pDate, &st))
00464   {
00465       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00466       _JumpError(hr, error, "VariantTimeToSystemTime");
00467   }
00468     }
00469
00470     if (!SystemTimeToFileTime(&st, pft))
00471     {
00472         hr = ceHLastError();
00473         _JumpError(hr, error, "SystemTimeToFileTime");
00474     }
00475
00476 error:
00477     return(hr);
00478 }
00479
00480
00481 HRESULT
00482 ceFileTimeToDate(
00483     IN FILETIME const *pft,
00484     OUT DATE *pDate)
00485 {
00486     SYSTEMTIME st;
00487     HRESULT hr = S_OK;
00488
00489     if (!FileTimeToSystemTime(pft, &st))
00490     {
00491         hr = ceHLastError();
00492         _JumpError(hr, error, "FileTimeToSystemTime");
00493     }
00494     if (!SystemTimeToVariantTime(&st, pDate))
00495     {
00496         hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00497         _JumpError(hr, error, "SystemTimeToVariantTime");
00498     }
00499
00500 error:
00501     return(hr);
00502 }
00503
00504
00505 VOID
00506 ceMakeExprDateTime(
00507     IN OUT FILETIME *pft,
00508     IN LONG lDelta,
00509     IN enum ENUM_PERIOD enumPeriod)
00510 {
00511     LLFILETIME llft;
00512     LONGLONG llDelta;
00513     BOOL fSysTimeDelta;
00514
00515     llft.ft = *pft;
00516     llDelta = lDelta;
00517     fSysTimeDelta = FALSE;
00518     switch (enumPeriod)
00519     {
00520   case ENUM_PERIOD_WEEKS:   llDelta *= CVT_WEEKS;    break;
00521   case ENUM_PERIOD_DAYS:    llDelta *= CVT_DAYS;     break;
00522   case ENUM_PERIOD_HOURS:   llDelta *= CVT_HOURS;    break;
00523   case ENUM_PERIOD_MINUTES: llDelta *= CVT_MINUTES;  break;
00524   case ENUM_PERIOD_SECONDS:          break;
00525   default:
00526       fSysTimeDelta = TRUE;
00527       break;
00528     }
00529     if (fSysTimeDelta)
00530     {
00531   SYSTEMTIME SystemTime;
00532
00533   FileTimeToSystemTime(&llft.ft, &SystemTime);
00534   switch (enumPeriod)
00535   {
00536       case ENUM_PERIOD_MONTHS:
00537     if (0 > lDelta)
00538     {
00539         DWORD dwDelta = (DWORD) -lDelta;
00540
00541         SystemTime.wYear -= (WORD) (dwDelta / 12) + 1;
00542         SystemTime.wMonth += 12 - (WORD) (dwDelta % 12);
00543     }
00544     else
00545     {
00546         SystemTime.wMonth = (WORD) lDelta + SystemTime.wMonth;
00547     }
00548     if (12 < SystemTime.wMonth)
00549     {
00550         SystemTime.wYear += (SystemTime.wMonth - 1) / 12;
00551         SystemTime.wMonth = ((SystemTime.wMonth - 1) % 12) + 1;
00552     }
00553     break;
00554
00555       case ENUM_PERIOD_YEARS:
00556     SystemTime.wYear = (WORD) lDelta + SystemTime.wYear;
00557     break;
00558
00559       default:
00560     SystemTime.wYear += 1;
00561     break;
00562   }
00563
00564 DoConvert:
00565         if (!SystemTimeToFileTime(&SystemTime, &llft.ft))
00566         {
00567             if (GetLastError() != ERROR_INVALID_PARAMETER)
00568             {
00569                 assert(!"Unable to do time conversion");
00570                 return;
00571             }
00572
00573             // In some cases we'll convert to an invalid month-end
00574
00575             // only one month changes length from year to year
00576             if (SystemTime.wMonth == 2)
00577             {
00578                 // > 29? try leap year
00579                 if (SystemTime.wDay > 29)
00580                 {
00581                     SystemTime.wDay = 29;
00582                     goto DoConvert;
00583                 }
00584                 // == 29? try non-leap year
00585                 else if (SystemTime.wDay == 29)
00586                 {
00587                     SystemTime.wDay = 28;
00588                     goto DoConvert;
00589                 }
00590             }
00591             // sept (9), apr(4), jun(6), nov(11) all have 30 days
00592             else if ((SystemTime.wMonth == 9) ||
00593                      (SystemTime.wMonth == 4) ||
00594                      (SystemTime.wMonth == 6) ||
00595                      (SystemTime.wMonth == 11))
00596             {
00597                 if (SystemTime.wDay > 30)
00598                 {
00599                     SystemTime.wDay = 30;
00600                     goto DoConvert;
00601                 }
00602             }
00603
00604             // should never get here
00605             assert(!"Month/year processing: inaccessible code");
00606             return;
00607         }
00608     }
00609     else
00610     {
00611   llft.ll += llDelta * CVT_BASE;
00612     }
00613     *pft = llft.ft;
00614 }
00615
00616
00617 HRESULT
00618 ceMakeExprDate(
00619     IN OUT DATE *pDate,
00620     IN LONG lDelta,
00621     IN enum ENUM_PERIOD enumPeriod)
00622 {
00623     HRESULT hr;
00624     FILETIME ft;
00625
00626     hr = ceDateToFileTime(pDate, &ft);
00627     _JumpIfError(hr, error, "ceDateToFileTime");
00628
00629     ceMakeExprDateTime(&ft, lDelta, enumPeriod);
00630
00631     hr = ceFileTimeToDate(&ft, pDate);
00632     _JumpIfError(hr, error, "ceFileTimeToDate");
00633
00634 error:
00635     return(hr);
00636 }
00637
00638
00639 typedef struct _UNITSTABLE
00640 {
00641     WCHAR const     *pwszString;
00642     enum ENUM_PERIOD enumPeriod;
00643 } UNITSTABLE;
00644
00645
00646 UNITSTABLE g_aut[] =
00647 {
00648     { wszPERIODSECONDS, ENUM_PERIOD_SECONDS },
00649     { wszPERIODMINUTES, ENUM_PERIOD_MINUTES },
00650     { wszPERIODHOURS,   ENUM_PERIOD_HOURS },
00651     { wszPERIODDAYS,    ENUM_PERIOD_DAYS },
00652     { wszPERIODWEEKS,   ENUM_PERIOD_WEEKS },
00653     { wszPERIODMONTHS,  ENUM_PERIOD_MONTHS },
00654     { wszPERIODYEARS,   ENUM_PERIOD_YEARS },
00655 };
00656 #define CUNITSTABLEMAX  (sizeof(g_aut)/sizeof(g_aut[0]))
00657
00658
00659 HRESULT
00660 ceTranslatePeriodUnits(
00661     IN WCHAR const *pwszPeriod,
00662     IN LONG lCount,
00663     OUT enum ENUM_PERIOD *penumPeriod,
00664     OUT LONG *plCount)
00665 {
00666     HRESULT hr;
00667     UNITSTABLE const *put;
00668
00669     for (put = g_aut; put < &g_aut[CUNITSTABLEMAX]; put++)
00670     {
00671   if (0 == celstrcmpiL(pwszPeriod, put->pwszString))
00672   {
00673       *penumPeriod = put->enumPeriod;
00674       if (0 > lCount)
00675       {
00676     lCount = MAXLONG;
00677       }
00678       *plCount = lCount;
00679       hr = S_OK;
00680       goto error;
00681   }
00682     }
00683     hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00684
00685 error:
00686     return(hr);
00687 }
00688
00689
00690 //+-------------------------------------------------------------------------
00691 // ceVerifyObjIdA - verify the passed pszObjId is valid as per X.208
00692 //
00693 // Encode and Decode the Object Id and make sure it suvives the round trip.
00694 // The first number must be 0, 1 or 2.
00695 // Enforce all characters are digits and dots.
00696 // Enforce that no dot starts or ends the Object Id, and disallow double dots.
00697 // Enforce there is at least one dot separator.
00698 // If the first number is 0 or 1, the second number must be between 0 & 39.
00699 // If the first number is 2, the second number can be any value.
00700 //--------------------------------------------------------------------------
00701
00702 HRESULT
00703 ceVerifyObjIdA(
00704     IN CHAR const *pszObjId)
00705 {
00706     HRESULT hr;
00707     BYTE *pbEncoded = NULL;
00708     DWORD cbEncoded;
00709     CRYPT_ATTRIBUTE ainfo;
00710     CRYPT_ATTRIBUTE *painfo = NULL;
00711     DWORD cbainfo;
00712     char const *psz;
00713     int i;
00714
00715     ainfo.pszObjId = const_cast<char *>(pszObjId);
00716     ainfo.cValue = 0;
00717     ainfo.rgValue = NULL;
00718
00719     if (!ceEncodeObject(
00720         X509_ASN_ENCODING,
00721         PKCS_ATTRIBUTE,
00722         &ainfo,
00723         0,
00724         FALSE,
00725         &pbEncoded,
00726         &cbEncoded))
00727     {
00728   hr = ceHLastError();
00729   _JumpError(hr, error, "ceEncodeObject");
00730     }
00731
00732     if (!ceDecodeObject(
00733         X509_ASN_ENCODING,
00734         PKCS_ATTRIBUTE,
00735         pbEncoded,
00736         cbEncoded,
00737         FALSE,
00738         (VOID **) &painfo,
00739         &cbainfo))
00740     {
00741   hr = ceHLastError();
00742   _JumpError(hr, error, "ceDecodeObject");
00743     }
00744
00745     hr = E_INVALIDARG;
00746     if (0 != strcmp(ainfo.pszObjId, painfo->pszObjId))
00747     {
00748   _JumpError(hr, error, "bad ObjId: decode mismatch");
00749     }
00750     for (psz = painfo->pszObjId; '\0' != *psz; psz++)
00751     {
00752   // must be a digit or a dot separator
00753
00754   if (!isdigit(*psz))
00755   {
00756       if ('.' != *psz)
00757       {
00758     _JumpError(hr, error, "bad ObjId: bad char");
00759       }
00760
00761       // can't have dot at start, double dots or dot at end
00762
00763       if (psz == painfo->pszObjId || '.' == psz[1] || '\0' == psz[1])
00764       {
00765     _JumpError(hr, error, "bad ObjId: dot location");
00766       }
00767   }
00768     }
00769     psz = strchr(painfo->pszObjId, '.');
00770     if (NULL == psz)
00771     {
00772   _JumpError(hr, error, "bad ObjId: must have at least one dot");
00773     }
00774     i = atoi(painfo->pszObjId);
00775     switch (i)
00776     {
00777   case 0:
00778   case 1:
00779       i = atoi(++psz);
00780       if (0 > i || 39 < i)
00781       {
00782     _JumpError(hr, error, "bad ObjId: 0. or 1. must be followed by 0..39");
00783       }
00784       break;
00785
00786   case 2:
00787       break;
00788
00789   default:
00790       _JumpError(hr, error, "bad ObjId: must start with 0, 1 or 2");
00791     }
00792     hr = S_OK;
00793
00794 error:
00795     if (NULL != pbEncoded)
00796     {
00797       LocalFree(pbEncoded);
00798     }
00799     if (NULL != painfo)
00800     {
00801       LocalFree(painfo);
00802     }
00803     return(hr);
00804 }
00805
00806
00807 HRESULT
00808 ceVerifyObjId(
00809     IN WCHAR const *pwszObjId)
00810 {
00811     HRESULT hr;
00812     CHAR *pszObjId = NULL;
00813
00814     if (!ceConvertWszToSz(&pszObjId, pwszObjId, -1))
00815     {
00816   hr = E_OUTOFMEMORY;
00817   _JumpError(hr, error, "ceConvertWszToSz");
00818     }
00819     hr = ceVerifyObjIdA(pszObjId);
00820     _JumpIfErrorStr(hr, error, "ceVerifyObjIdA", pwszObjId);
00821
00822 error:
00823     if (NULL != pszObjId)
00824     {
00825       LocalFree(pszObjId);
00826     }
00827     return(hr);
00828 }
00829
00830
00831 HRESULT
00832 ceVerifyAltNameString(
00833     IN LONG NameChoice,
00834     IN BSTR strName)
00835 {
00836     HRESULT hr = S_OK;
00837     CERT_ALT_NAME_INFO AltName;
00838     CERT_ALT_NAME_ENTRY Entry;
00839     CERT_OTHER_NAME OtherName;
00840     char *pszObjectId = NULL;
00841     DWORD cbEncoded;
00842
00843     ZeroMemory(&AltName, sizeof(AltName));
00844     AltName.cAltEntry = 1;
00845     AltName.rgAltEntry = &Entry;
00846
00847     ZeroMemory(&Entry, sizeof(Entry));
00848     Entry.dwAltNameChoice = NameChoice;
00849
00850     switch (NameChoice)
00851     {
00852   case CERT_ALT_NAME_RFC822_NAME:
00853       Entry.pwszRfc822Name = strName;
00854       break;
00855
00856   case CERT_ALT_NAME_DNS_NAME:
00857       Entry.pwszDNSName = strName;
00858       break;
00859
00860   case CERT_ALT_NAME_URL:
00861       Entry.pwszURL = strName;
00862       break;
00863
00864   case CERT_ALT_NAME_REGISTERED_ID:
00865       if (!ceConvertWszToSz(&pszObjectId, strName, -1))
00866       {
00867     hr = E_OUTOFMEMORY;
00868     ceERRORPRINTLINE("ceConvertWszToSz", hr);
00869     goto error;
00870       }
00871       Entry.pszRegisteredID = pszObjectId;
00872       break;
00873
00874   case CERT_ALT_NAME_OTHER_NAME:
00875       Entry.pOtherName = &OtherName;
00876       OtherName.pszObjId = szOID_NT_PRINCIPAL_NAME;
00877       OtherName.Value.cbData = SysStringByteLen(strName);
00878       OtherName.Value.pbData = (BYTE *) strName;
00879       break;
00880
00881   case CERT_ALT_NAME_DIRECTORY_NAME:
00882       Entry.DirectoryName.cbData = SysStringByteLen(strName);
00883       Entry.DirectoryName.pbData = (BYTE *) strName;
00884       break;
00885
00886   case CERT_ALT_NAME_IP_ADDRESS:
00887       Entry.IPAddress.cbData = SysStringByteLen(strName);
00888       Entry.IPAddress.pbData = (BYTE *) strName;
00889       break;
00890
00891   //case CERT_ALT_NAME_X400_ADDRESS:
00892   //case CERT_ALT_NAME_EDI_PARTY_NAME:
00893   default:
00894       hr = E_INVALIDARG;
00895       ceERRORPRINTLINE("NameChoice", hr);
00896       goto error;
00897
00898     }
00899
00900     // Encode CERT_ALT_NAME_INFO:
00901
00902     if (!CryptEncodeObject(
00903         X509_ASN_ENCODING,
00904         X509_ALTERNATE_NAME,
00905         &AltName,
00906         NULL,
00907         &cbEncoded))
00908     {
00909   hr = ceHLastError();
00910   ceERRORPRINTLINE("ceEncodeObject", hr);
00911   goto error;
00912     }
00913
00914 error:
00915     if (NULL != pszObjectId)
00916     {
00917   LocalFree(pszObjectId);
00918     }
00919     return(hr);
00920 }
00921
00922
00923 HRESULT
00924 ceDispatchSetErrorInfoSub(
00925     IN HRESULT hrError,
00926     OPTIONAL IN WCHAR const *pwszIDispatchMethod,
00927     OPTIONAL IN WCHAR const *pwszDescription,
00928     OPTIONAL IN WCHAR const *pwszSource,
00929     OPTIONAL IN IID const *piid,
00930     OPTIONAL IN WCHAR const *pwszHelpFile,
00931     IN DWORD dwHelpFileContext)
00932 {
00933     HRESULT hr;
00934     WCHAR const *pwszError = NULL;
00935     ICreateErrorInfo *pCreateErrorInfo = NULL;
00936     IErrorInfo *pErrorInfo = NULL;
00937
00938     if (NULL != pwszIDispatchMethod)
00939     {
00940   pwszError = ceGetErrorMessageText(hrError, TRUE);
00941     }
00942
00943     hr = CreateErrorInfo(&pCreateErrorInfo);
00944     _JumpIfError(hr, error, "CreateErrorInfo");
00945
00946     if (NULL != piid)
00947     {
00948   hr = pCreateErrorInfo->SetGUID(*piid);
00949   _PrintIfError(hr, "SetGUID");
00950     }
00951     if (NULL != pwszSource)
00952     {
00953   hr = pCreateErrorInfo->SetSource(const_cast<WCHAR *>(pwszSource));
00954   _PrintIfError(hr, "SetSource");
00955     }
00956     if (NULL != pwszDescription)
00957     {
00958   hr = pCreateErrorInfo->SetDescription(
00959           const_cast<WCHAR *>(pwszDescription));
00960   _PrintIfError(hr, "SetDescription");
00961     }
00962     if (NULL != pwszHelpFile)
00963     {
00964   hr = pCreateErrorInfo->SetHelpFile(const_cast<WCHAR *>(pwszHelpFile));
00965   _PrintIfError(hr, "SetHelpFile");
00966
00967   hr = pCreateErrorInfo->SetHelpContext(dwHelpFileContext);
00968   _PrintIfError(hr, "SetHelpContext");
00969     }
00970
00971     hr = pCreateErrorInfo->QueryInterface(
00972             IID_IErrorInfo,
00973             (VOID **) &pErrorInfo);
00974     _JumpIfError(hr, error, "QueryInterface");
00975
00976     SetErrorInfo(0, pErrorInfo);
00977     hr = S_OK;
00978
00979 error:
00980     if (NULL != pwszError)
00981     {
00982   LocalFree(const_cast<WCHAR *>(pwszError));
00983     }
00984     if (NULL != pErrorInfo)
00985     {
00986   pErrorInfo->Release();
00987     }
00988     if (NULL != pCreateErrorInfo)
00989     {
00990   pCreateErrorInfo->Release();
00991     }
00992     return(hr);
00993 }
00994
00995
00996 HRESULT
00997 ceDispatchSetErrorInfo(
00998     IN HRESULT hrError,
00999     IN WCHAR const *pwszDescription,
01000     OPTIONAL IN WCHAR const *pwszProgId,
01001     OPTIONAL IN IID const *piid)
01002 {
01003     HRESULT hr;
01004     WCHAR const *pwszError = NULL;
01005     WCHAR *pwszText = NULL;
01006
01007     if (NULL == pwszDescription)
01008     {
01009         hr = E_POINTER;
01010   _JumpError(hr, error, "NULL pointer");
01011     }
01012     assert(FAILED(hrError));
01013     pwszError = ceGetErrorMessageText(hrError, TRUE);
01014     if (NULL == pwszError)
01015     {
01016   _PrintError(E_OUTOFMEMORY, "myGetErrorMessageText");
01017     }
01018     else
01019     {
01020   pwszText = (WCHAR *) LocalAlloc(
01021       LMEM_FIXED,
01022       (wcslen(pwszDescription) + 1 + wcslen(pwszError) + 1) *
01023        sizeof(WCHAR));
01024   if (NULL == pwszText)
01025   {
01026       _PrintError(E_OUTOFMEMORY, "LocalAlloc");
01027   }
01028   else
01029   {
01030       wcscpy(pwszText, pwszDescription);
01031       wcscat(pwszText, L" ");
01032       wcscat(pwszText, pwszError);
01033   }
01034     }
01035     hr = ceDispatchSetErrorInfoSub(
01036       hrError,
01037       NULL,   // pwszIDispatchMethod
01038       NULL != pwszText?
01039           pwszText : const_cast<WCHAR *>(pwszDescription),
01040       pwszProgId,
01041       piid,
01042       NULL,   // pwszHelpFile
01043       0);   // dwHelpFileContext
01044     _PrintIfError(hr, "ceDispatchSetErrorInfoSub");
01045
01046 error:
01047     if (NULL != pwszText)
01048     {
01049   LocalFree(pwszText);
01050     }
01051     if (NULL != pwszError)
01052     {
01053   LocalFree(const_cast<WCHAR *>(pwszError));
01054     }
01055     return(hrError);  // return input error!
01056 }
01057
01058
01059 int
01060 ceWtoI(
01061     IN WCHAR const *string,
01062     OUT BOOL *pfValid)
01063 {
01064     HRESULT hr;
01065     WCHAR szBuf[16];
01066     WCHAR *szTmp = szBuf;
01067     int cTmp = ARRAYSIZE(szBuf);
01068     int i = 0;
01069     WCHAR const *pwsz;
01070     BOOL fSawDigit = FALSE;
01071
01072     if (pfValid == NULL)
01073     {
01074         hr = E_POINTER;
01075         _JumpError(hr, error, "NULLPARAM");
01076     }
01077     *pfValid = FALSE;
01078
01079     assert(NULL != pfValid);
01080     cTmp = FoldString(
01081         MAP_FOLDDIGITS,
01082         string,
01083         -1,
01084         szTmp,
01085         cTmp);
01086     if (cTmp == 0)
01087     {
01088         hr = ceHLastError();
01089         if (HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) == hr)
01090         {
01091             hr = S_OK;
01092             cTmp = FoldString(
01093                 MAP_FOLDDIGITS,
01094                 string,
01095                 -1,
01096                 NULL,
01097                 0);
01098
01099             szTmp = (WCHAR*)LocalAlloc(LMEM_FIXED, cTmp*sizeof(WCHAR));
01100       if (NULL == szTmp)
01101       {
01102     hr = E_OUTOFMEMORY;
01103     _JumpError(hr, error, "LocalAlloc");
01104       }
01105
01106             cTmp = FoldString(
01107                 MAP_FOLDDIGITS,
01108                 string,
01109                 -1,
01110                 szTmp,
01111                 cTmp);
01112
01113             if (cTmp == 0)
01114                 hr = ceHLastError();
01115         }
01116         _JumpIfError(hr, error, "FoldString");
01117     }
01118     pwsz = szTmp;
01119     while (iswspace(*pwsz))
01120     {
01121   pwsz++;
01122     }
01123     while (iswdigit(*pwsz))
01124     {
01125   fSawDigit = TRUE;
01126   pwsz++;
01127     }
01128     while (iswspace(*pwsz))
01129     {
01130   pwsz++;
01131     }
01132     if (L'\0' == *pwsz)
01133     {
01134   *pfValid = fSawDigit;
01135     }
01136     i = _wtoi(szTmp);
01137
01138 error:
01139     if (szTmp && (szTmp != szBuf))
01140        LocalFree(szTmp);
01141
01142     return i;
01143 }
01144
01145
01146 HRESULT
01147 ceGetMachineDnsName(
01148     OUT WCHAR **ppwszDnsName)
01149 {
01150     HRESULT hr;
01151     WCHAR *pwszDnsName = NULL;
01152     DWORD cwc;
01153     COMPUTER_NAME_FORMAT NameType = ComputerNameDnsFullyQualified;
01154
01155     *ppwszDnsName = NULL;
01156     while (TRUE)
01157     {
01158   cwc = 0;
01159   if (!GetComputerNameEx(NameType, NULL, &cwc))
01160   {
01161       hr = ceHLastError();
01162       if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr &&
01163     ComputerNameDnsFullyQualified == NameType)
01164       {
01165     _PrintError(hr, "GetComputerNameEx(DnsFullyQualified) -- switching to NetBIOS");
01166     NameType = ComputerNameNetBIOS;
01167     continue;
01168       }
01169       if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr)
01170       {
01171     _JumpError(hr, error, "GetComputerNameEx");
01172       }
01173       break;
01174   }
01175     }
01176     pwszDnsName = (WCHAR *) LocalAlloc(LMEM_FIXED, cwc * sizeof(WCHAR));
01177     if (NULL == pwszDnsName)
01178     {
01179   hr = E_OUTOFMEMORY;
01180   _JumpError(hr, error, "LocalAlloc");
01181     }
01182
01183     if (!GetComputerNameEx(NameType, pwszDnsName, &cwc))
01184     {
01185   hr = ceHLastError();
01186   _JumpError(hr, error, "GetComputerNameEx");
01187     }
01188
01189     *ppwszDnsName = pwszDnsName;
01190     pwszDnsName = NULL;
01191     hr = S_OK;
01192
01193 error:
01194     if (NULL != pwszDnsName)
01195     {
01196   LocalFree(pwszDnsName);
01197     }
01198     return(hr);
01199 }
01200
01201
01202 HRESULT
01203 ceGetComputerNames(
01204     OUT WCHAR **ppwszDnsName,
01205     OUT WCHAR **ppwszOldName)
01206 {
01207     HRESULT hr;
01208     DWORD cwc;
01209     WCHAR *pwszOldName = NULL;
01210
01211     *ppwszOldName = NULL;
01212     *ppwszDnsName = NULL;
01213
01214     cwc = MAX_COMPUTERNAME_LENGTH + 1;
01215     pwszOldName = (WCHAR *) LocalAlloc(LMEM_FIXED, cwc * sizeof(WCHAR));
01216     if (NULL == pwszOldName)
01217     {
01218       hr = E_OUTOFMEMORY;
01219       _JumpError(hr, error, "LocalAlloc");
01220     }
01221     if (!GetComputerName(pwszOldName, &cwc))
01222     {
01223         hr = ceHLastError();
01224         _JumpError(hr, error, "GetComputerName");
01225     }
01226
01227     hr = ceGetMachineDnsName(ppwszDnsName);
01228     _JumpIfError(hr, error, "ceGetMachineDnsName");
01229
01230     *ppwszOldName = pwszOldName;
01231     pwszOldName = NULL;
01232
01233 error:
01234     if (NULL != pwszOldName)
01235     {
01236   LocalFree(pwszOldName);
01237     }
01238     return(hr);
01239 }
01240
01241
01242 HRESULT
01243 _IsConfigLocal(
01244     IN WCHAR const *pwszConfig,
01245     IN WCHAR const *pwszDnsName,
01246     IN WCHAR const *pwszOldName,
01247     OPTIONAL OUT WCHAR **ppwszMachine,
01248     OUT BOOL *pfLocal)
01249 {
01250     HRESULT hr;
01251     WCHAR *pwszMachine = NULL;
01252     WCHAR const *pwsz;
01253     DWORD cwc;
01254
01255     *pfLocal = FALSE;
01256     if (NULL != ppwszMachine)
01257     {
01258   *ppwszMachine = NULL;
01259     }
01260
01261     while (L'\\' == *pwszConfig)
01262     {
01263   pwszConfig++;
01264     }
01265     pwsz = wcschr(pwszConfig, L'\\');
01266     if (NULL != pwsz)
01267     {
01268   cwc = SAFE_SUBTRACT_POINTERS(pwsz, pwszConfig);
01269     }
01270     else
01271     {
01272   cwc = wcslen(pwszConfig);
01273     }
01274     pwszMachine = (WCHAR *) LocalAlloc(LMEM_FIXED, (cwc + 1) * sizeof(WCHAR));
01275     if (NULL == pwszMachine)
01276     {
01277   hr = E_OUTOFMEMORY;
01278   _JumpError(hr, error, "LocalAlloc");
01279     }
01280     CopyMemory(pwszMachine, pwszConfig, cwc * sizeof(WCHAR));
01281     pwszMachine[cwc] = L'\0';
01282
01283     if (0 == celstrcmpiL(pwszMachine, pwszDnsName) ||
01284   0 == celstrcmpiL(pwszMachine, pwszOldName))
01285     {
01286   *pfLocal = TRUE;
01287     }
01288     if (NULL != ppwszMachine)
01289     {
01290   *ppwszMachine = pwszMachine;
01291   pwszMachine = NULL;
01292     }
01293     hr = S_OK;
01294
01295 error:
01296     if (NULL != pwszMachine)
01297     {
01298   LocalFree(pwszMachine);
01299     }
01300     return(hr);
01301 }
01302
01303
01304 HRESULT
01305 ceIsConfigLocal(
01306     IN WCHAR const *pwszConfig,
01307     OPTIONAL OUT WCHAR **ppwszMachine,
01308     OUT BOOL *pfLocal)
01309 {
01310     HRESULT hr;
01311     WCHAR *pwszDnsName = NULL;
01312     WCHAR *pwszOldName = NULL;
01313
01314     *pfLocal = FALSE;
01315     if (NULL != ppwszMachine)
01316     {
01317   *ppwszMachine = NULL;
01318     }
01319
01320     hr = ceGetComputerNames(&pwszDnsName, &pwszOldName);
01321     _JumpIfError(hr, error, "ceGetComputerNames");
01322
01323     hr = _IsConfigLocal(
01324         pwszConfig,
01325         pwszDnsName,
01326         pwszOldName,
01327         ppwszMachine,
01328         pfLocal);
01329     _JumpIfError(hr, error, "_IsConfigLocal");
01330
01331 error:
01332     if (NULL != pwszDnsName)
01333     {
01334   LocalFree(pwszDnsName);
01335     }
01336     if (NULL != pwszOldName)
01337     {
01338   LocalFree(pwszOldName);
01339     }
01340     return(hr);
01341 }
01342
01343
01344 HRESULT
01345 ceBuildPathAndExt(
01346     IN WCHAR const *pwszDir,
01347     IN WCHAR const *pwszFile,
01348     OPTIONAL IN WCHAR const *pwszExt,
01349     OUT WCHAR **ppwszPath)
01350 {
01351     HRESULT hr;
01352     WCHAR *pwsz;
01353     DWORD cwc;
01354
01355     *ppwszPath = NULL;
01356     cwc = wcslen(pwszDir) + 1 + wcslen(pwszFile) + 1;
01357     if (NULL != pwszExt)
01358     {
01359   cwc += wcslen(pwszExt);
01360     }
01361
01362     pwsz = (WCHAR *) LocalAlloc(LMEM_FIXED, cwc * sizeof(WCHAR));
01363     if (NULL == pwsz)
01364     {
01365   hr = E_OUTOFMEMORY;
01366   _JumpError(hr, error, "LocalAlloc");
01367     }
01368     wcscpy(pwsz, pwszDir);
01369     if (L'\\' != pwsz[wcslen(pwsz) - 1])
01370     {
01371   wcscat(pwsz, L"\\");
01372     }
01373     wcscat(pwsz, pwszFile);
01374     if (NULL != pwszExt)
01375     {
01376   wcscat(pwsz, pwszExt);
01377     }
01378     *ppwszPath = pwsz;
01379     hr = S_OK;
01380
01381 error:
01382     return(hr);
01383 }
01384
01385
01386 // Locale-independent case-ignore string compare
01387
01388 int
01389 celstrcmpiL(
01390     IN WCHAR const *pwsz1,
01391     IN WCHAR const *pwsz2)
01392 {
01393     // CSTR_LESS_THAN(1) - CSTR_EQUAL(2)    == -1 string 1 less than string 2
01394     // CSTR_EQUAL(2) - CSTR_EQUAL(2)        == 0 string 1 equal to string 2
01395     // CSTR_GREATER_THAN(3) - CSTR_EQUAL(2) == 1 string 1 greater than string 2
01396
01397     return(CompareString(
01398     LOCALE_INVARIANT,
01399     NORM_IGNORECASE,
01400     pwsz1,
01401     -1,
01402     pwsz2,
01403     -1) -
01404       CSTR_EQUAL);
01405 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/FieldAttributeEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

FieldAttributeEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: FieldAttributeEnum
00019
00020 public class FieldAttributeEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final int adFldUnspecified = -1;
00023   public static final int adFldMayDefer = 2;
00024   public static final int adFldUpdatable = 4;
00025   public static final int adFldUnknownUpdatable = 8;
00026   public static final int adFldFixed = 16;
00027   public static final int adFldIsNullable = 32;
00028   public static final int adFldMayBeNull = 64;
00029   public static final int adFldLong = 128;
00030   public static final int adFldRowID = 256;
00031   public static final int adFldRowVersion = 512;
00032   public static final int adFldCacheDeferred = 4096;
00033   public static final int adFldNegativeScale = 16384;
00034   public static final int adFldKeyColumn = 32768;
00035 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/msplog.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

msplog.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1997-1999  Microsoft Corporation
00004
00005 Module Name:
00006
00007     mspdebug.cpp
00008
00009 Abstract:
00010
00011     This module contains the debugging support for the MSPs.
00012
00013 --*/
00014
00015 #include "precomp.h"
00016 #pragma hdrstop
00017
00018 #include <stdio.h>
00019
00020
00021 //
00022 // no need to build this code if MSPLOG is not defined
00023 //
00024
00025 #ifdef MSPLOG
00026
00027
00028 #define MAXDEBUGSTRINGLENGTH 512
00029
00030 static DWORD   sg_dwTraceID = INVALID_TRACEID;
00031
00032 static char    sg_szTraceName[100];   // saves name of dll
00033 static DWORD   sg_dwTracingToDebugger = 0;
00034 static DWORD   sg_dwTracingToConsole  = 0;
00035 static DWORD   sg_dwTracingToFile     = 0;
00036 static DWORD   sg_dwDebuggerMask      = 0;
00037
00038
00039 //
00040 // this flag indicates whether any tracing needs to be done at all
00041 //
00042
00043 BOOL g_bMSPBaseTracingOn = FALSE;
00044
00045
00046 BOOL NTAPI MSPLogRegister(LPCTSTR szName)
00047 {
00048     HKEY       hTracingKey;
00049
00050     char       szTracingKey[100];
00051     const char szDebuggerTracingEnableValue[] = "EnableDebuggerTracing";
00052     const char szConsoleTracingEnableValue[] = "EnableConsoleTracing";
00053     const char szFileTracingEnableValue[] = "EnableFileTracing";
00054     const char szTracingMaskValue[]   = "ConsoleTracingMask";
00055
00056
00057     sg_dwTracingToDebugger = 0;
00058     sg_dwTracingToConsole = 0;
00059     sg_dwTracingToFile = 0;
00060
00061 #ifdef UNICODE
00062     wsprintfA(szTracingKey, "Software\\Microsoft\\Tracing\\%ls", szName);
00063 #else
00064     wsprintfA(szTracingKey, "Software\\Microsoft\\Tracing\\%s", szName);
00065 #endif
00066
00067     _ASSERTE(sg_dwTraceID == INVALID_TRACEID);
00068
00069     if ( ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE,
00070                                         szTracingKey,
00071                                         0,
00072                                         KEY_READ,
00073                                         &hTracingKey) )
00074     {
00075         DWORD      dwDataSize = sizeof (DWORD);
00076         DWORD      dwDataType;
00077
00078         RegQueryValueExA(hTracingKey,
00079                          szDebuggerTracingEnableValue,
00080                          0,
00081                          &dwDataType,
00082                          (LPBYTE) &sg_dwTracingToDebugger,
00083                          &dwDataSize);
00084
00085         RegQueryValueExA(hTracingKey,
00086                          szConsoleTracingEnableValue,
00087                          0,
00088                          &dwDataType,
00089                          (LPBYTE) &sg_dwTracingToConsole,
00090                          &dwDataSize);
00091
00092         RegQueryValueExA(hTracingKey,
00093                          szFileTracingEnableValue,
00094                          0,
00095                          &dwDataType,
00096                          (LPBYTE) &sg_dwTracingToFile,
00097                          &dwDataSize);
00098
00099         RegQueryValueExA(hTracingKey,
00100                          szTracingMaskValue,
00101                          0,
00102                          &dwDataType,
00103                          (LPBYTE) &sg_dwDebuggerMask,
00104                          &dwDataSize);
00105
00106         RegCloseKey (hTracingKey);
00107     }
00108     else
00109     {
00110
00111         //
00112         // the key could not be opened. in case the key does not exist,
00113         // register with rtutils so that the reg keys get created
00114         //
00115
00116 #ifdef UNICODE
00117         wsprintfA(sg_szTraceName, "%ls", szName);
00118 #else
00119         wsprintfA(sg_szTraceName, "%s", szName);
00120 #endif
00121
00122         //
00123         // tracing should not have been initialized
00124         //
00125
00126         sg_dwTraceID = TraceRegister(szName);
00127
00128         if (sg_dwTraceID != INVALID_TRACEID)
00129         {
00130             g_bMSPBaseTracingOn = TRUE;
00131         }
00132
00133         return TRUE;
00134     }
00135
00136
00137     //
00138     // are we asked to do any tracing at all?
00139     //
00140
00141     if ( (0 != sg_dwTracingToDebugger) ||
00142          (0 != sg_dwTracingToConsole ) ||
00143          (0 != sg_dwTracingToFile    )    )
00144     {
00145
00146         //
00147         // see if we need to register with rtutils
00148         //
00149
00150         if ( (0 != sg_dwTracingToConsole ) || (0 != sg_dwTracingToFile) )
00151         {
00152
00153             //
00154             // rtutils tracing is enabled. register with rtutils
00155             //
00156
00157
00158 #ifdef UNICODE
00159             wsprintfA(sg_szTraceName, "%ls", szName);
00160 #else
00161             wsprintfA(sg_szTraceName, "%s", szName);
00162 #endif
00163
00164             //
00165             // tracing should not have been initialized
00166             //
00167
00168             _ASSERTE(sg_dwTraceID == INVALID_TRACEID);
00169
00170
00171             //
00172             // register
00173             //
00174
00175             sg_dwTraceID = TraceRegister(szName);
00176         }
00177
00178
00179         //
00180         // if debugger tracing, or succeeded registering with rtutils, we are all set
00181         //
00182
00183         if ( (0 != sg_dwTracingToDebugger) || (sg_dwTraceID != INVALID_TRACEID) )
00184         {
00185
00186             //
00187             // some tracing is enabled. set the global flag
00188             //
00189
00190             g_bMSPBaseTracingOn = TRUE;
00191
00192             return TRUE;
00193         }
00194         else
00195         {
00196
00197
00198             //
00199             // registration did not go through and debugger logging is off
00200             //
00201
00202             return FALSE;
00203         }
00204     }
00205
00206
00207     //
00208     // logging is not enabled. nothing to do
00209     //
00210
00211     return TRUE;
00212 }
00213
00214 void NTAPI MSPLogDeRegister()
00215 {
00216     if (g_bMSPBaseTracingOn)
00217     {
00218         sg_dwTracingToDebugger = 0;
00219         sg_dwTracingToConsole = 0;
00220         sg_dwTracingToFile = 0;
00221
00222
00223         //
00224         // if we registered tracing, unregister now
00225         //
00226
00227         if ( sg_dwTraceID != INVALID_TRACEID )
00228         {
00229             TraceDeregister(sg_dwTraceID);
00230             sg_dwTraceID = INVALID_TRACEID;
00231         }
00232     }
00233 }
00234
00235
00236 void NTAPI LogPrint(IN DWORD dwDbgLevel, IN LPCSTR lpszFormat, IN ...)
00237 /*++
00238
00239 Routine Description:
00240
00241     Formats the incoming debug message & calls TraceVprintfEx to print it.
00242
00243 Arguments:
00244
00245     dwDbgLevel   - The type of the message.
00246
00247     lpszFormat - printf-style format string, followed by appropriate
00248                  list of arguments
00249
00250 Return Value:
00251
00252 --*/
00253 {
00254     static char * message[] =
00255     {
00256         "ERROR",
00257         "WARNING",
00258         "INFO",
00259         "TRACE",
00260         "EVENT",
00261         "INVALID TRACE LEVEL"
00262     };
00263
00264     char  szTraceBuf[MAXDEBUGSTRINGLENGTH + 1];
00265
00266     DWORD dwIndex;
00267
00268     if ( ( sg_dwTracingToDebugger > 0 ) &&
00269          ( 0 != ( dwDbgLevel & sg_dwDebuggerMask ) ) )
00270     {
00271         switch(dwDbgLevel)
00272         {
00273         case MSP_ERROR: dwIndex = 0; break;
00274         case MSP_WARN:  dwIndex = 1; break;
00275         case MSP_INFO:  dwIndex = 2; break;
00276         case MSP_TRACE: dwIndex = 3; break;
00277         case MSP_EVENT: dwIndex = 4; break;
00278         default:        dwIndex = 5; break;
00279         }
00280
00281         // retrieve local time
00282         SYSTEMTIME SystemTime;
00283         GetLocalTime(&SystemTime);
00284
00285         wsprintfA(szTraceBuf,
00286                   "%s:[%02u:%02u:%02u.%03u,tid=%x:]%s: ",
00287                   sg_szTraceName,
00288                   SystemTime.wHour,
00289                   SystemTime.wMinute,
00290                   SystemTime.wSecond,
00291                   SystemTime.wMilliseconds,
00292                   GetCurrentThreadId(),
00293                   message[dwIndex]);
00294
00295         va_list ap;
00296         va_start(ap, lpszFormat);
00297
00298         _vsnprintf(&szTraceBuf[lstrlenA(szTraceBuf)],
00299             MAXDEBUGSTRINGLENGTH - lstrlenA(szTraceBuf),
00300             lpszFormat,
00301             ap
00302             );
00303
00304         lstrcatA (szTraceBuf, "\n");
00305
00306         OutputDebugStringA (szTraceBuf);
00307
00308         va_end(ap);
00309     }
00310
00311     if (sg_dwTraceID != INVALID_TRACEID)
00312     {
00313         if ( ( sg_dwTracingToConsole > 0 ) || ( sg_dwTracingToFile > 0 ) )
00314         {
00315             switch(dwDbgLevel)
00316             {
00317             case MSP_ERROR: dwIndex = 0; break;
00318             case MSP_WARN:  dwIndex = 1; break;
00319             case MSP_INFO:  dwIndex = 2; break;
00320             case MSP_TRACE: dwIndex = 3; break;
00321             case MSP_EVENT: dwIndex = 4; break;
00322             default:        dwIndex = 5; break;
00323             }
00324
00325             wsprintfA(szTraceBuf, "[%s] %s", message[dwIndex], lpszFormat);
00326
00327             va_list arglist;
00328             va_start(arglist, lpszFormat);
00329             TraceVprintfExA(sg_dwTraceID, dwDbgLevel | TRACE_USE_MSEC, szTraceBuf, arglist);
00330             va_end(arglist);
00331         }
00332     }
00333 }
00334
00335 #endif // MSPLOG
00336
00337 // eof
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/ExtObj.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

ExtObj.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ExtObj.h
00007 //
00008 //  Implementation File:
00009 //      ExtObj.cpp
00010 //
00011 //  Description:
00012 //      Definition of the CExtObject class, which implements the
00013 //      extension interfaces required by a Microsoft Windows NT Cluster
00014 //      Administrator Extension DLL.
00015 //
00016 //  Author:
00017 //      <name> (<e-mail name>) Mmmm DD, 2003
00018 //
00019 //  Revision History:
00020 //
00021 //  Notes:
00022 //
00023 /////////////////////////////////////////////////////////////////////////////
00024
00025 #pragma once
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // Include Files
00029 /////////////////////////////////////////////////////////////////////////////
00030
00031 #pragma warning( push )
00032 #include <CluAdmEx.h>   // for CLUADMEX_OBJECT_TYPE and interfaces
00033 #pragma warning( pop )
00034
00035 #include "ExtObjID.h"   // for CLSID_CoFileShareSampleEx
00036 #include "ExtObjData.h"
00037
00038 /////////////////////////////////////////////////////////////////////////////
00039 // External Class Declarations
00040 /////////////////////////////////////////////////////////////////////////////
00041
00042 class CBasePropertyPage;
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // CPageList
00046 /////////////////////////////////////////////////////////////////////////////
00047
00048 typedef CList< CBasePropertyPage *, CBasePropertyPage * > CPageList;
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 // class CExtObject
00052 /////////////////////////////////////////////////////////////////////////////
00053
00054 class CExtObject
00055     : public IWEExtendPropertySheet
00056     , public IWEExtendWizard
00057     , public IWEExtendContextMenu
00058     , public IWEInvokeCommand
00059     , public ISupportErrorInfo
00060     , public CComObjectRoot
00061     , public CComCoClass< CExtObject, &CLSID_CoFileShareSampleEx >
00062 {
00063 public:
00064     CExtObject( void );
00065 BEGIN_COM_MAP( CExtObject )
00066     COM_INTERFACE_ENTRY( IWEExtendPropertySheet )
00067     COM_INTERFACE_ENTRY( IWEExtendWizard )
00068     COM_INTERFACE_ENTRY( IWEExtendContextMenu )
00069     COM_INTERFACE_ENTRY( IWEInvokeCommand )
00070     COM_INTERFACE_ENTRY( ISupportErrorInfo )
00071 END_COM_MAP()
00072
00073 //DECLARE_NOT_AGGREGATABLE( CExtObject )
00074
00075 //
00076 // Uncomment the line above if you don't want your object to support aggregation.
00077 // The default is to support it.
00078 //
00079
00080 #pragma warning( push, 3 )
00081 #pragma warning( disable : 4996 ) // warning C4996: 'ATL::CComModule::UpdateRegistryClass' was declared deprecated
00082 DECLARE_REGISTRY(
00083           CExtObject
00084         , _T("CLUADMEX.FileShareSampleEx")
00085         , _T("CLUADMEX.FileShareSampleEx")
00086         , IDS_CLUADMEX_COMOBJ_DESC
00087         , THREADFLAGS_APARTMENT
00088         );
00089 #pragma warning( pop )
00090
00091     //
00092     // ISupportsErrorInfo
00093     //
00094
00095     STDMETHOD( InterfaceSupportsErrorInfo )( REFIID riid );
00096
00097     //
00098     // IWEExtendPropertySheet
00099     //
00100
00101 public:
00102     STDMETHOD( CreatePropertySheetPages )(
00103                       IUnknown *                 piDataIn
00104                     , IWCPropertySheetCallback * piCallbackIn
00105                     );
00106
00107     //
00108     // IWEExtendWizard
00109     //
00110
00111 public:
00112     STDMETHOD( CreateWizardPages )(
00113                       IUnknown *            piDataIn
00114                     , IWCWizardCallback *   piCallbackIn
00115                     );
00116
00117     //
00118     // IWEExtendContextMenu
00119     //
00120
00121 public:
00122     STDMETHOD( AddContextMenuItems )(
00123                       IUnknown *                piDataIn
00124                     , IWCContextMenuCallback *  piCallbackIn
00125                     );
00126
00127     //
00128     // IWEInvokeCommand
00129     //
00130
00131     STDMETHOD( InvokeCommand )(
00132                       ULONG         nCommandIDIn
00133                     , IUnknown *    piDataIn
00134                     );
00135
00136     CLUADMEX_OBJECT_TYPE Cot() { return (m_podObjData != NULL) ? m_podObjData->Cot() : CLUADMEX_OT_NONE; }
00137
00138     //
00139     // IGetClusterUIInfo data
00140     //
00141
00142     LCID                        Lcid( void ) const                  { return m_lcid; }
00143     HFONT                       Hfont( void ) const                 { return m_hfont; }
00144     HICON                       Hicon( void ) const                 { return m_hicon; }
00145     IWCWizardCallback *         PiWizardCallback( void ) const      { return m_piWizardCallback; }
00146     BOOL                        BWizard( void ) const               { return m_bWizard; }
00147
00148     //
00149     // IGetClusterDataInfo data
00150     //
00151
00152     HCLUSTER                    Hcluster( void ) const              { return m_hCluster; }
00153     LONG                        Cobj( void ) const                  { return m_cobj; }
00154     CObjData *                  PodObjData( void )                  { return m_podObjData; }
00155     HRESULT                     HrGetObjectInfo( void );
00156
00157 //
00158 // Attributes
00159 //
00160
00161 protected:
00162
00163     IUnknown *                  m_piData;
00164     IWCWizardCallback *         m_piWizardCallback;
00165     BOOL                        m_bWizard;
00166
00167     //
00168     // IGetClusterUIInfo data
00169     //
00170
00171     LCID                        m_lcid;
00172     HFONT                       m_hfont;
00173     HICON                       m_hicon;
00174
00175     //
00176     // IGetClusterDataInfo data
00177     //
00178
00179     HCLUSTER                    m_hCluster;
00180     LONG                        m_cobj;
00181
00182     CObjData *                  m_podObjData;
00183
00184 //
00185 // Implementation
00186 //
00187
00188     virtual ~CExtObject(void);
00189
00190     HRESULT                     HrGetUIInfo( IUnknown * piDataIn );
00191     HRESULT                     HrSaveData( IUnknown * piDataIn );
00192
00193     CPageList                   m_lpg;
00194
00195 }; //*** class CExtObject
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step3/dlldata.c Source File

  • NetDS
  • upnp
  • StepByStep
  • Step3

dlldata.c

Go to the documentation of this file.
00001 /*********************************************************
00002    DllData file -- generated by MIDL compiler
00003
00004         DO NOT ALTER THIS FILE
00005
00006    This file is regenerated by MIDL on every IDL file compile.
00007
00008    To completely reconstruct this file, delete it and rerun MIDL
00009    on all the IDL files in this DLL, specifying this file for the
00010    /dlldata command line option
00011
00012 *********************************************************/
00013
00014
00015 #include <rpcproxy.h>
00016
00017 #ifdef __cplusplus
00018 extern "C"   {
00019 #endif
00020
00021 EXTERN_PROXY_FILE( upnphost )
00022
00023
00024 PROXYFILE_LIST_START
00025 /* Start of list */
00026   REFERENCE_PROXY_FILE( upnphost ),
00027 /* End of list */
00028 PROXYFILE_LIST_END
00029
00030
00031 DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
00032
00033 #ifdef __cplusplus
00034 }  /*extern "C" */
00035 #endif
00036
00037 /* end of generated dlldata file */
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Menubtn

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/compdata.h Source File

  • SysMgmt
  • MMC
  • Extens

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData
00028 {
00029     friend class CComponent;
00030
00031 private:
00032     ULONG       m_cref;
00033     LPCONSOLE     m_ipConsole;
00034     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00035
00036     CStaticNode     *m_pStaticNode;
00037
00038 public:
00039     CComponentData();
00040     ~CComponentData();
00041
00042     ///////////////////////////////
00043     // Interface IUnknown
00044     ///////////////////////////////
00045     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046     STDMETHODIMP_(ULONG) AddRef();
00047     STDMETHODIMP_(ULONG) Release();
00048
00049     ///////////////////////////////
00050     // Interface IComponentData
00051     ///////////////////////////////
00052     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053         /* [in] */ LPUNKNOWN pUnknown);
00054
00055         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00056         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00059         /* [in] */ LPDATAOBJECT lpDataObject,
00060         /* [in] */ MMC_NOTIFY_TYPE event,
00061         /* [in] */ LPARAM arg,
00062         /* [in] */ LPARAM param);
00063
00064         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00065
00066     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00067         /* [in] */ MMC_COOKIE cookie,
00068         /* [in] */ DATA_OBJECT_TYPES type,
00069         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00070
00071         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075         /* [in] */ LPDATAOBJECT lpDataObjectA,
00076         /* [in] */ LPDATAOBJECT lpDataObjectB);
00077 };
00078
00079 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/Mount/Mount.Cpp Source File

  • WinBase
  • IO
  • Mount

Mount.Cpp

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 mount.c
00011
00012 This file implements a command-line utility that creates mount points for
00013 drives on Windows 2000 and later.
00014
00015 Command-line syntax:
00016    mount [-o] <drive> <directory>
00017       -o   overwrite existing mount point on <directory>
00018 ----------------------------------------------------------------------------*/
00019
00020 #include <windows.h>
00021 #include <stdio.h>
00022
00023 static void PrintHelp (void);
00024 static BOOL CreateMountPoint (LPCSTR pszDriveToMount, LPCSTR pszDirToMount);
00025
00026
00027 #if defined (DEBUG)
00028    static void DebugPrint (LPCSTR pszMsg, DWORD dwErr);
00029    #define DEBUG_PRINT(pszMsg, dwErr) DebugPrint(pszMsg, dwErr)
00030 #else
00031    #define DEBUG_PRINT(pszMsg, dwErr) NULL
00032 #endif
00033
00034
00035 int main (int argc, char **argv)
00036 {
00037    bool  bOverwriteMount;
00038    char *pszMountDir;
00039    char *pszDriveToMount;
00040    char *pszOptions;
00041
00042    // Make sure user has supplied required number of command-line arguments.
00043    if (argc != 3 && argc != 4)
00044    {
00045       PrintHelp ();
00046       return (-1);
00047    }
00048
00049    /*
00050       Since we have at least 3 args, we can initialize the pointers to them.
00051       We use pointers to explicitly refer to the arguments to make the rest
00052       of the code more understandable.
00053    */
00054    pszMountDir     = argv[argc-1];
00055    pszDriveToMount = argv[argc-2];
00056    pszOptions      = argv[argc-3];
00057
00058    // See if "-o" is present in command line.  It must be the second argument.
00059    bOverwriteMount = (argc == 4 && !lstrcmpi (pszOptions, "-o"));
00060
00061    /*
00062       If bOverwriteMount != TRUE (i.e. user wants to keep an existing
00063       mount point), then need to check destination to see if it exists and
00064       if it is a mount point. If so, don't create a volume mount point on it.
00065
00066       The way to tell if a directory is a mount point is to:
00067
00068        1) Call FindFirstFile().
00069        2) If WIN32_FIND_DATA.dwFileAttributes contains
00070           FILE_ATTRIBUTE_REPARSE_POINT see if WIN32_FIND_DATA.dwReserved0
00071           is IO_REPARSE_TAG_MOUNT_POINT.
00072        3) If so, then the directory is a mount point.
00073    */
00074    if (!bOverwriteMount)
00075    {
00076       WIN32_FIND_DATA fileInfo;
00077       HANDLE          hFind;
00078
00079       hFind = FindFirstFile (pszMountDir, &fileInfo);
00080       if (INVALID_HANDLE_VALUE != hFind)
00081       {
00082          FindClose(hFind);  // Don't need the find handle anymore.
00083
00084          /*
00085             If the destination is a mount point, tell user we're not going
00086             to replace it, and then exit.
00087          */
00088          if ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
00089              (fileInfo.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
00090          {
00091             printf("%s is already a mount point; it will not be replaced\n",
00092                    pszMountDir);
00093             return (0);
00094          }
00095       }
00096       /*
00097          If hFind == INVALID_HANDLE_VALUE here, we didn't find the directory
00098          to be the mount point. We could exit here, but we won't.  We'll
00099          just keep going because CreateMountPoint will fail the creation of
00100          the mount point on the non-existant directory.
00101       */
00102    }
00103
00104    /*
00105       Create the mount point.  Report whether we succeeded or failed.
00106    */
00107    if (CreateMountPoint (pszDriveToMount, pszMountDir))
00108       printf("mounted %s to %s\n", pszDriveToMount, pszMountDir);
00109    else
00110    {
00111       printf("couldn't mount %s to %s\n", pszDriveToMount, pszMountDir);
00112       DEBUG_PRINT ("CreateMountPoint failed with error", GetLastError());
00113    }
00114
00115    return (0);
00116 }
00117
00118
00119 /*-----------------------------------------------------------------------------
00120 CreateMountPoint( pszDriveToMount, pszDirToMount )
00121
00122 Parameters
00123    pszDriveToMount
00124       The drive that will be associated with the mount point directory.
00125
00126    pszDirToMount
00127       The location that pszDriveToMount is to be mounted.  This must be an
00128       empty directory.  It can also be a current mount point; if it is, then
00129       the existing mount point will automatically be unmounted by
00130       SetVolumeMountPoint.
00131
00132 Return Value
00133    Returns TRUE if successful, or FALSE otherwwise.
00134
00135 Notes
00136    Since GetVolumeNameForVolumeMountPoint and SetVolumeMountPoint require
00137    trailing backslashes, we'll add them if necessary.
00138 -----------------------------------------------------------------------------*/
00139 BOOL CreateMountPoint (LPCSTR pszDriveToMount, LPCSTR pszDirToMount)
00140 {
00141    const int VOL_NAME_MAX = 80;
00142    BOOL fResult;
00143    char szUniqueVolumeName[VOL_NAME_MAX];
00144
00145    char szDriveName[4];
00146    char *pszDirName = NULL;
00147    int   cchDirLen;
00148
00149    __try
00150    {
00151       /*
00152          Add trailing backslashes to drive letter and mount point directory name
00153          because volume mount point APIs require them.
00154
00155          Since drive letters are of the format C:\ or C:, we know that the max
00156          drive letter string is 4 chars long.  We can thus use array addressing
00157          to do a faster equivalent of:
00158
00159             lstrcpyn (szDriveName, pszDriveToMount, 3);
00160             lstrcat (szDriveName, "\\");
00161
00162          If the directory name doesn't already have a trailing backslash, we
00163          just copy it to a new buffer and add the trailing backslash.
00164       */
00165       __try
00166       {
00167          szDriveName[0] = pszDriveToMount[0];
00168          szDriveName[1] = pszDriveToMount[1];
00169          szDriveName[2] = '\\';
00170          szDriveName[3] = '\0';
00171
00172          // now the directory name
00173          cchDirLen = lstrlen(pszDirToMount);
00174          if (pszDirToMount[cchDirLen - 1] != '\\')
00175          {
00176             pszDirName = new char[cchDirLen + 2]; // +2 for backslash and NULL
00177             lstrcpy (pszDirName, pszDirToMount);
00178             pszDirName[cchDirLen] = '\\';
00179             pszDirName[cchDirLen+1] = '\0';
00180          }
00181          else
00182             pszDirName = (char *)pszDirToMount;  // Cast away const
00183       }
00184       __except(EXCEPTION_EXECUTE_HANDLER)
00185       {
00186          fResult = FALSE;
00187          __leave;
00188       }
00189
00190       // Create the mount point...
00191       fResult = GetVolumeNameForVolumeMountPoint (szDriveName,
00192                                                   szUniqueVolumeName,
00193                                                   VOL_NAME_MAX);
00194       if (!fResult)
00195       {
00196          DEBUG_PRINT("GetVolumeNameForVolumeMountPoint failed with error",
00197                      GetLastError());
00198          __leave;
00199       }
00200
00201       fResult = SetVolumeMountPoint (pszDirName, szUniqueVolumeName);
00202       if (!fResult)
00203       {
00204          DEBUG_PRINT("SetVolumeMountPoint failed with error", GetLastError());
00205          __leave;
00206       }
00207
00208    }
00209    __finally
00210    {
00211       // Free pszDirName if it was allocated from free store
00212       if (pszDirName != pszDirToMount)
00213          delete[] pszDirName;
00214    }
00215
00216    return (fResult);
00217 }
00218
00219
00220 /*-----------------------------------------------------------------------------
00221 PrintHelp( )
00222
00223 Notes
00224    Prints usage notes for the command line syntax.  Called if the user doesn't
00225    specify the command line correctly.
00226 -----------------------------------------------------------------------------*/
00227 void PrintHelp (void)
00228 {
00229    printf ("usage: mount [-o] <drive> <directory>\n"
00230            "\t-o   overwrite existing mount point on <directory>\n");
00231 }
00232
00233
00234 /*-----------------------------------------------------------------------------
00235 DebugPrint( pszMsg, dwErr )
00236
00237 Parameters
00238    pszMsg
00239       The string to be printed to STDOUT
00240    dwErr
00241       The error code; usually obtained from GetLastError.  If dwErr is zero,
00242       then no error code is added to the error string.  If dwErr is non-zero,
00243       then the error code will be printed in the error string.
00244 -----------------------------------------------------------------------------*/
00245 void DebugPrint (LPCSTR pszMsg, DWORD dwErr)
00246 {
00247    if (dwErr)
00248       printf("%s: %lu\n", pszMsg, dwErr);
00249    else
00250       printf("%s\n", pszMsg);
00251 }
00252
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_DLGITEMS Member List

This is the complete list of members for _DLGITEMS, including all inherited members.
dwStart | _DLGITEMS
uDelayID | _DLGITEMS
uNotify | _DLGITEMS
uState1 | _DLGITEMS
uState2 | _DLGITEMS
uTip1 | _DLGITEMS
uTip2 | _DLGITEMS
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditCommands/StdAfx.cpp Source File

  • Web
  • Browser
  • EditCommands

StdAfx.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.cpp : source file that includes just the standard includes
00006 // stdafx.pch will be the pre-compiled header
00007 // stdafx.obj will contain the pre-compiled type information
00008
00009 #include "stdafx.h"
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Rnr2/rnrcs.cpp Source File

  • NetDS
  • WinSock
  • Rnr2

rnrcs.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 // PARTICULAR PURPOSE.
00006 //
00007 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00008 //
00009 // Module:
00010 //      RnrCs.cpp
00011 //
00012 // Abstract:
00013 //      In a traditional Winsock 1.1 client/server program, the server
00014 //      binds itself to a well known port of a particular protocol family.
00015 //      Then, any client can talk to the server only if it knows the server's
00016 //      addressing infomation which includes the server's address, protocol,
00017 //      and socket type.
00018 //
00019 //      The Winsock 2 Name Resolution and Registration (RnR) provides a unified
00020 //      API set for client to search for registered services without having any
00021 //      prior knowledge of addressing information. Basically, a server wants to
00022 //      register its existence within one or more name spaces through a friendly
00023 //      service instance name and associate itself to a service class GUID.
00024 //      Client application will be able to find the addressing
00025 //      information of a server by the friendly name and class GUID
00026 //      in a name space.
00027 //
00028 //      In this sample, the server program converts the user supplied Type Id
00029 //      into a service class GUID by SVCID_NETWARE() macro. (You can also
00030 //      generate your own service class GUID using uuidgen.exe or guidgen.exe
00031 //      and distribute this GUID to your client program.) It then checks the
00032 //      availability of various kind of name space providers and install this
00033 //      service class by filling out the relevant service class information
00034 //      with NS_NTDS (NT Directory Service name space provider available in Windows 2000)
00035 //      and/or NS_SAP (Service Advertising Protocol name space provider available
00036 //      both in Windows NT 4 and Windows 2000) name spaces whenever they are available.
00037 //      If NS_NTDS has been installed, it binds itself to UDP protocol addresses
00038 //      and a port number dynamically chosen by the system. If NS_SAP has been
00039 //      installed, it also binds itself to a IPX protocol address and a socket
00040 //      number chosen by the system. After filling out its bound socket addresses,
00041 //      it advertises its availability through a service name supplied by a user.
00042 //      For each bound non-blocking socket addresses, the server tries to
00043 //      receive any datagram sent by any client and print out the client's socket
00044 //      addressing information if a datagram is received.
00045 //      When a user hits CTRL-C, the server program will unregister this
00046 //      service instance, remove the service class and close all sockets.
00047 //
00048 //      The client program converts the user supplied Type Id into a service
00049 //      class GUID by SVCID_NETWARE() macro, such that it can find any SAP
00050 //      predefined services (e.g. file server Type Id is 4) or the corresponding
00051 //      advertised server program. If the user supplies a service name, it
00052 //      will just look up the service with the same service name and Type Id.
00053 //      If the user supplies a wild card "*" for the service name, it will try
00054 //      to look up all registered services with the same
00055 //      Type Id. For each service program found, it prints out the socket addressing
00056 //      information of the service program and sends a message to it.
00057 //
00058 //      NOTE:
00059 //      (1) To exploit the NS_NTDS name space (Active Directory):
00060 //          (a) client and server machines should have Windows 2000 or later installed and both
00061 //              machines should be members of a Windows 2000 domain.
00062 //          (b) If the server program is running in the security context of Domain Admins,
00063 //              you should have no problem in publishing the service.
00064 //          (c) If the server program is running in the context of a Domain Users, Domain
00065 //              Admins have to modify the access control list (ACLs) on the WinsockServices
00066 //              container:
00067 //              From the Active Directory Users and Computers MMC snap-in, access the View menu
00068 //              and select Advanced Features. Under the System container is another container
00069 //              listed as WinsockServices. Open the WinsockServices container,
00070 //              right-click Properties->Security, add your desired user/group with Full Control
00071 //              permission. Make sure this applies onto "this object and all child objects"
00072 //              by clicking the "Advanced..." button and "View/Edit..." your selected permission
00073 //              entry.
00074 //      (2) To advertise in the SAP name space, server program machine should have
00075 //          NWLink IPX/SPX Compatible Transport protocol and SAP Agent service installed.
00076 //      (3) To lookup servers in the SAP name space, client program machine should have
00077 //          NWLink IPX/SPX Compatible Transport protocol installed.
00078 //      (4) When the server is running on a mutihomed machine, the SAP name space
00079 //          provider will only make the first registered ipx address available, other
00080 //          ipx addresses are ignored.
00081 //
00082 // Usage:  RnrCs
00083 // -c (running this program as a client)
00084 // -s (running this program as a server)
00085 // -t server_type_id (default is: 200)
00086 // -n server_instance_name (default is: MyServer)
00087 // -p provider_name (default is: NS_ALL)
00088 //                  (e.g. NS_NTDS, NS_SAP, NS_ALL)
00089 // Examples:
00090 // RnrCs -s -n MyServer   ....Run as server /w server_type_id of 200, service
00091 //                             instance name of MyServer
00092 // RnrCs -c -n * .............Run as client and find all servers /w server_type_id
00093 //                             of 200 from all available name spaces
00094 // RnrCs -c -n * -p NS_SAP ...Run as client and find all servers /w server_type_id
00095 //                             of 200 from the SAP name space
00096 // RnrCs -c -t 4 -n * ........Run as client and find all SAP file servers
00097 // Hit Ctrl-C to quit the server program
00098 //
00099 // Build:
00100 //  Use the headers and libs from the April98 Platform SDK or later.
00101 //  Link with ws2_32.lib
00102 //
00103 // Author: Frank K. Li - Microsoft Developer Support
00104 //
00105 //----------------------------------------------------------------------------
00106 #ifdef _IA64_
00107     #pragma warning (disable: 4127 4267)
00108 #endif
00109
00110 #include <winsock2.h>
00111 #include <ws2tcpip.h>
00112 #include <wspiapi.h>
00113 #include <svcguid.h>
00114 #include <wsipx.h>
00115 #include <wsnwlink.h>
00116 #include <nspapi.h>
00117
00118 #include <stdio.h>
00119 #include <stdlib.h>
00120 #include <strsafe.h>
00121
00122 #define DEFAULT_STRING_LEN      256
00123
00124
00125 void GetSockAddrString(SOCKADDR_STORAGE* pSAddr, int addrlen, char * dest, int destlen);
00126 void SetIpPort(SOCKADDR_STORAGE *dest, SOCKADDR_STORAGE *src);
00127 void DumpServiceClassInfo(LPWSASERVICECLASSINFO lpSci);
00128
00129
00130 //-------Server side structures and functions-------------------
00131 // Global socket handles
00132 const int g_nMaxNumOfCSAddr = 20; // advertise at most 10 addresses
00133 const int g_nMaxNumOfSocks  = 3;  // one for udp/ipv4, one for udp/ipv6, another for ipx
00134 int       g_nNumOfUsedSocks = 0;  // number of socket created
00135
00136 SOCKET g_aSock[g_nMaxNumOfSocks] = {INVALID_SOCKET, INVALID_SOCKET, INVALID_SOCKET};
00137 CSADDR_INFO      g_aCSAddr[g_nMaxNumOfCSAddr] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
00138 SOCKADDR_STORAGE g_aSockAddr[g_nMaxNumOfCSAddr] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}; // SOCKADDR buffer
00139 GUID             g_MyGuid;   // guid for this service class
00140 WSAQUERYSET      g_QS = {0};       // QuerySet to advertise service
00141
00142 SOCKADDR_STORAGE ss_in = {0};      // socket address for AF_INET
00143 SOCKADDR_IPX    sa_ipx = {0};     // socket address for AF_IPX
00144
00145 BOOL g_fSap   = FALSE;      // available name space providers on local machine
00146 BOOL g_fNtds  = FALSE;
00147 DWORD g_dwNumNs  = 0;       // total number of name space providers
00148
00149 BOOL fEndProgram = FALSE;   // signal the end of program when user hits "Ctrl-C"
00150
00151 BOOL DoRnrServer(char * pszServerName, int  nServerType);
00152 BOOL InstallClass(int nServerType);
00153 BOOL Advertise(char* pszServerName);
00154 BOOL ServerRecv();
00155 BOOL CheckAvailableNameSpaceProviders(BOOL& fNsSap, BOOL& fNsNtds);
00156 BOOL GetBoundIpxAddr(SOCKET soc, SOCKADDR_IPX * pSaIpx, int nAdapter);
00157 BOOL WINAPI CtrlHandler (   DWORD dwEvent );
00158
00159
00160 //-------Client side functions------------------------------
00161 void DoRnrClient (int nServiceType, char * pszServerName, DWORD dwNameSpace);
00162 void ClientSend(CSADDR_INFO* lpcsaBuffer);
00163 void PrintError (char* errfunc);
00164
00165 #define OFFSET 1024  // a large buffer to hold returned WSAQUERYSET
00166
00167 //--------------------------------------------------------------
00168 void Usage(char * pszProgramName)
00169 {
00170     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00171     fprintf(stderr, " -c (running this program as a client)\n");
00172     fprintf(stderr, " -s (running this program as a server)\n");
00173     fprintf(stderr, " -t server_type_id (default is: 200)\n");
00174     fprintf(stderr, " -n server_instance_name (default is: MyServer) \n");
00175     fprintf(stderr, " -p provider name (default is: NS_ALL) \n");
00176     fprintf(stderr, "                  (e.g. NS_NTDS, NS_SAP, NS_ALL)\n");
00177     fprintf(stderr, "Examples:\n");
00178     fprintf(stderr, "RnrCs -s -n MyServer   ...Run as server /w server_type_id of 200, service\n");
00179     fprintf(stderr, "                             instance name of MyServer\n");
00180     fprintf(stderr, "RnrCs -c -n * ............Run as client and find all servers /w server_type_id\n");
00181     fprintf(stderr, "                             of 200 from all available name spaces\n");
00182     fprintf(stderr, "RnrCs -c -n * -p NS_SAP ..Run as client and find all servers /w server_type_id\n");
00183     fprintf(stderr, "                             of 200 from the SAP name space\n");
00184     fprintf(stderr, "RnrCs -c -t 4 -n * .......Run as client and find all SAP file servers\n");
00185     fprintf(stderr, "Hit Ctrl-C to quit the server program\n");
00186 }
00187
00188 void __cdecl main (int argc, char *argv[])
00189 {
00190     char * pszServerName = "MyServer";   // default server instance name
00191     int    nServerType = 200;            // default server type id
00192     char * pszNSProvider = "NS_ALL";
00193     DWORD  dwNameSpace = NS_ALL;
00194     int i = 0;
00195     BOOL fServer = TRUE;                 // by default, running this program as the server
00196
00197     // allow the user to override settings with command line switches
00198     for (i = 1; i < argc; i++)
00199     {
00200         if ((*argv[i] == '-') || (*argv[i] == '/'))
00201         {
00202             switch (tolower(*(argv[i]+1)))
00203             {
00204             case 'n':  // server instance name
00205                 pszServerName = argv[++i];
00206                 break;
00207             case 't':  // server_type, this will be used as the base for the Server class id
00208                 nServerType = atoi(argv[++i]);
00209                 break;
00210             case 'c':
00211                 fServer = FALSE;
00212                 break;
00213             case 's':
00214                 fServer = TRUE;
00215                 break;
00216             case 'p':
00217                 pszNSProvider = argv[++i];
00218                 if (_strnicmp("NS_NTDS", pszNSProvider, strlen("NS_NTDS")) == 0)
00219                     dwNameSpace = NS_NTDS;
00220                 else if (_strnicmp("NS_SAP", pszNSProvider, strlen("NS_SAP")) == 0)
00221                     dwNameSpace = NS_SAP;
00222                 // default is NS_ALL
00223                 break;
00224             case 'h':
00225             case '?':
00226             default:
00227                 Usage(argv[0]);
00228                 return;
00229             }
00230         }
00231         else
00232         {
00233             Usage(argv[0]);
00234             return;
00235         }
00236
00237     }
00238
00239     if (fServer)
00240     {
00241         // check user input
00242         if (strcmp(pszServerName, "*") == 0)
00243         {
00244             printf("You can't supply wildcard (*) server instance name to run this server\n");
00245             Usage(argv[0]);
00246             return;
00247         }
00248     }
00249
00250     __try
00251     {
00252         // init winsock
00253         WSADATA wd;
00254         int nRet;
00255         if ( (nRet = WSAStartup (MAKEWORD (2, 2), &wd)) != 0)
00256         {
00257             printf ("Unable to start Winsock 2.  Error: %d\n", nRet);
00258             __leave;
00259         }
00260
00261         if (fServer)
00262         {
00263             // running as a server program
00264             DoRnrServer(pszServerName, nServerType);
00265         }
00266         else
00267         {
00268             // running as a client program
00269             DoRnrClient(nServerType, pszServerName, dwNameSpace);
00270         }
00271
00272     }
00273     __finally
00274     {
00275         if (fServer)
00276         {
00277             SetConsoleCtrlHandler(CtrlHandler, FALSE);
00278         }
00279
00280         WSACleanup();
00281
00282     }
00283 }
00284
00285
00286 //---------------------------------------------
00287 // server side routines
00288 //---------------------------------------------
00289
00290
00291 //---------------------------------------------------------------------------
00292 //  FUNCTION: BOOL DoRnrServer(char * pszServerName, int  nServerType)
00293 //
00294 //  PURPOSE:  The driver for the server side code. It forms the global
00295 //            class id "g_MyGuid" for this service class, installs this
00296 //            service class, advertises the service name "pszServerName" with
00297 //            the associated bound SOCKADDR addresses and then loop through
00298 //            for data sent by client. This routine returns if user hits "Ctrl-C"
00299 //            or any error encountered.
00300 //
00301 //  RETURNS:
00302 //    TRUE if user hits "Ctrl-C" to end the server program.
00303 //    FALSE if there is any error encountered.
00304 //
00305 //---------------------------------------------------------------------------
00306 BOOL DoRnrServer(char * pszServerName, int  nServerType)
00307 {
00308     // I am using SVCID_NETWARE macro to form a common class id for the
00309     // client and server program such that the client program can also query
00310     // some known SAP services on the network without running this program
00311     // as a server.
00312     // You can also generate your own class id by uuidgen.exe or guidgen.exe and
00313     // distribute the class id to client program.
00314     //
00315     // Please check svcguid.h for details about the macro.
00316     GUID guidNW = SVCID_NETWARE(nServerType);
00317
00318     memcpy(&g_MyGuid, &guidNW, sizeof(GUID));
00319
00320     if (!SetConsoleCtrlHandler(CtrlHandler, TRUE))
00321     {
00322         printf ("SetConsoleCtrlHandler failed to install console handler: %d\n",
00323                 GetLastError());
00324         return FALSE;
00325     }
00326     // Install the server class
00327     if (!InstallClass(nServerType))
00328     {
00329         return FALSE;
00330     }
00331     // advertise the server instance
00332     if (!Advertise(pszServerName))
00333     {
00334         return FALSE;
00335     }
00336
00337     // Make our bound sockets non-blocking such that
00338     // we can loop and test for data sent by client
00339     // without blocking.
00340     u_long arg = 1L;
00341     for (int i = 0; i < g_nNumOfUsedSocks; i++)
00342     {
00343         // make the socket as non-blocking socket
00344         if (ioctlsocket(g_aSock[i], FIONBIO, &arg) == SOCKET_ERROR)
00345         {
00346             printf("ioctlsocket[%d] error %d\n", i, WSAGetLastError());
00347             return FALSE;
00348         }
00349     }
00350
00351     // receive data from client who find our address thru Winsock 2 RnR
00352     for (;;)
00353     {
00354         if (ServerRecv() == FALSE)
00355         {
00356             return FALSE;
00357         }
00358         if (fEndProgram)
00359             return TRUE;
00360         Sleep(100);
00361     }
00362 }
00363
00364 //---------------------------------------------------------------------------
00365 //  FUNCTION: InstallClass(int nServerType)
00366 //
00367 //  PURPOSE:  Install a service class in NTDS and SAP name spaces if they are
00368 //            available on this machine. "nServerType" is a numerical number used
00369 //            to generate a service class id by using SVCID_NETWARE macro as shown in
00370 //            the main program.
00371 //            The name of this service class is obtained by composing "nServerType"
00372 //            with the string "TypeId.
00373 //
00374 //  RETURNS:
00375 //    TRUE if succeed otherwise FALSE
00376 //
00377 //---------------------------------------------------------------------------
00378 BOOL InstallClass(int nServerType)
00379 {
00380     WSASERVICECLASSINFO sci;
00381     WSANSCLASSINFO  aNameSpaceClassInfo[4] = {{0},{0},{0},{0}};
00382     DWORD           dwSapId = nServerType;
00383     DWORD           dwZero = 0;
00384     TCHAR           szServiceClassName[DEFAULT_STRING_LEN] = {'\0'};
00385     int             nRet = 0;
00386     DWORD           dwUdpPort = 0; // we use dynamic generated port number
00387     HRESULT hRet;
00388
00389     if (FAILED(hRet = StringCchPrintf(szServiceClassName,
00390                                       sizeof(szServiceClassName)/sizeof(szServiceClassName[0]),
00391                                       "TypeId %d",
00392                                       nServerType
00393                                      )))
00394     {
00395         printf("StringCchPrintf failed: 0x%x\n",hRet);
00396         return FALSE;
00397     }
00398
00399     printf("Installing ServiceClassName: %s\n", szServiceClassName);
00400
00401
00402     BOOL fSap  = FALSE;
00403     BOOL fNtds = FALSE;
00404
00405     // see what name space providers are available
00406     if (!CheckAvailableNameSpaceProviders(fSap, fNtds))
00407         return FALSE;
00408
00409     // save a copy
00410     g_fSap = fSap;
00411     g_fNtds = fNtds;
00412
00413     // our total number of interested name space providers
00414     if (fSap)
00415         g_dwNumNs++;
00416     if (fNtds)
00417         g_dwNumNs++;
00418
00419     // setup Service Class info
00420     SecureZeroMemory(&sci,sizeof(sci));
00421
00422     sci.lpServiceClassId = (LPGUID) &g_MyGuid;
00423     sci.lpszServiceClassName = (LPSTR) szServiceClassName;
00424     sci.dwCount = g_dwNumNs * 2; // each name space has 2 NameSpaceClassInfo
00425     sci.lpClassInfos = aNameSpaceClassInfo;
00426
00427     SecureZeroMemory(aNameSpaceClassInfo,sizeof(WSANSCLASSINFO)*4);
00428
00429     DWORD i =0; // index to array of WSANSCLASSINFO
00430
00431     // common service class registration in NTDS and SAP name spaces
00432     if (fNtds)
00433     {
00434         // NTDS setup
00435         printf("NTDS name space class installation\n");
00436
00437         aNameSpaceClassInfo[i].lpszName = SERVICE_TYPE_VALUE_CONN;
00438         aNameSpaceClassInfo[i].dwNameSpace = NS_NTDS;
00439         aNameSpaceClassInfo[i].dwValueType = REG_DWORD;
00440         aNameSpaceClassInfo[i].dwValueSize = sizeof(DWORD);
00441         aNameSpaceClassInfo[i].lpValue = &dwZero;
00442         i++; // increment of the index
00443
00444         aNameSpaceClassInfo[i].lpszName = SERVICE_TYPE_VALUE_UDPPORT;
00445         aNameSpaceClassInfo[i].dwNameSpace = NS_NTDS;
00446         aNameSpaceClassInfo[i].dwValueType = REG_DWORD;
00447         aNameSpaceClassInfo[i].dwValueSize = sizeof(DWORD);
00448         aNameSpaceClassInfo[i].lpValue = &dwUdpPort;
00449         i++; // increment of the index
00450     }
00451
00452     if (fSap)
00453     {
00454         // SAP setup
00455         printf("SAP name space class installation\n");
00456
00457         aNameSpaceClassInfo[i].lpszName = SERVICE_TYPE_VALUE_CONN;
00458         aNameSpaceClassInfo[i].dwNameSpace = NS_SAP;
00459         aNameSpaceClassInfo[i].dwValueType = REG_DWORD;
00460         aNameSpaceClassInfo[i].dwValueSize = sizeof(DWORD);
00461         aNameSpaceClassInfo[i].lpValue = &dwZero;
00462         i++; // increment of the index
00463
00464         aNameSpaceClassInfo[i].lpszName = SERVICE_TYPE_VALUE_SAPID;
00465         aNameSpaceClassInfo[i].dwNameSpace = NS_SAP;
00466         aNameSpaceClassInfo[i].dwValueType = REG_DWORD;
00467         aNameSpaceClassInfo[i].dwValueSize = sizeof(DWORD);
00468         aNameSpaceClassInfo[i].lpValue = &dwSapId;
00469     }
00470
00471     // Install the service class information
00472     DumpServiceClassInfo(&sci);
00473     nRet = WSAInstallServiceClass(&sci);
00474     if (nRet == SOCKET_ERROR)
00475     {
00476         printf("WSAInstallServiceClass error %d\n", WSAGetLastError());
00477         return FALSE;
00478     }
00479     return TRUE;
00480 }
00481
00482 //---------------------------------------------------------------------------
00483 //  FUNCTION: Advertise(char* pszServerName)
00484 //
00485 //  PURPOSE:  Given the name of this service instance "pszServerName",
00486 //            advertise this instance to the available name spaces.
00487 //
00488 //  RETURNS:
00489 //    TRUE if succeed otherwise FALSE
00490 //
00491 //---------------------------------------------------------------------------
00492 BOOL Advertise(char* pszServerName)
00493 {
00494     int nRet = 0;
00495     int i=0;              // number of socket created
00496     int nNumOfCSAddr = 0; // number of bound socket addresses
00497
00498     // Advertizing
00499
00500     // Set up the WSAQuery data
00501     SecureZeroMemory(&g_QS,sizeof(WSAQUERYSET));
00502     g_QS.dwSize = sizeof(WSAQUERYSET);
00503     g_QS.lpszServiceInstanceName = (LPSTR)pszServerName; // service instance name
00504     g_QS.lpServiceClassId = &g_MyGuid; // associated service class id
00505     g_QS.dwNameSpace = NS_ALL;         // advertise to all name spaces
00506     g_QS.lpNSProviderId = NULL;
00507     g_QS.lpcsaBuffer = g_aCSAddr;      // our bound socket addresses
00508     g_QS.lpBlob = NULL;
00509
00510
00511     // Set up the g_aCSAddr data
00512     if (g_fNtds)
00513     {
00514         SOCKET_ADDRESS_LIST *slist=NULL;
00515         struct addrinfo *res=NULL,
00516         *resptr=NULL,
00517         hints;
00518         char            *addrbuf=NULL;
00519         DWORD            dwBytes=0;
00520
00521         SecureZeroMemory(&hints,sizeof(hints));
00522
00523         hints.ai_flags = AI_PASSIVE;
00524         hints.ai_socktype = SOCK_DGRAM;
00525         hints.ai_protocol = IPPROTO_UDP;
00526
00527         nRet = getaddrinfo(NULL, "0", &hints, &res);
00528         if ((nRet != 0) || (res == NULL))
00529         {
00530             return FALSE;
00531         }
00532
00533         resptr = res;
00534         while (resptr)
00535         {
00536             g_aSock[i] = socket(resptr->ai_family, resptr->ai_socktype, resptr->ai_protocol);
00537             if (g_aSock[i] == INVALID_SOCKET)
00538             {
00539                 printf("socket error %d\n", WSAGetLastError());
00540                 freeaddrinfo(res);
00541                 return FALSE;
00542             }
00543
00544             // bind to local host ip addresses and let system to assign a port number
00545             nRet = bind ( g_aSock[i], resptr->ai_addr, (int)resptr->ai_addrlen);
00546             if ( SOCKET_ERROR == nRet )
00547             {
00548                 printf("bind error %d\n", WSAGetLastError());
00549                 freeaddrinfo(res);
00550                 return FALSE;
00551             }
00552             int cb = sizeof(ss_in);
00553             if (getsockname(g_aSock[i], (SOCKADDR *) &ss_in, &cb) == SOCKET_ERROR)
00554             {
00555                 printf("getsockname error %d\n", WSAGetLastError());
00556                 freeaddrinfo(res);
00557                 return FALSE;
00558             }
00559
00560             nRet = WSAIoctl(g_aSock[i], SIO_ADDRESS_LIST_QUERY, NULL, 0, NULL, 0, &dwBytes, NULL, NULL);
00561             if (nRet == SOCKET_ERROR)
00562             {
00563                 addrbuf = (char *)HeapAlloc(GetProcessHeap(), 0, dwBytes);
00564                 if (addrbuf == NULL)
00565                 {
00566                     freeaddrinfo(res);
00567                     return FALSE;
00568                 }
00569                 nRet = WSAIoctl(g_aSock[i], SIO_ADDRESS_LIST_QUERY, NULL, 0, addrbuf, dwBytes, &dwBytes, NULL, NULL);
00570                 if (nRet == SOCKET_ERROR)
00571                 {
00572                     printf("WSAIoctl failed: %d\n", WSAGetLastError());
00573                     HeapFree(GetProcessHeap(), 0, addrbuf);
00574                     freeaddrinfo(res);
00575                     return FALSE;
00576                 }
00577             }
00578             else
00579             {
00580                 printf("WSAIoctl should have failed!\n");
00581                 freeaddrinfo(res);
00582                 return FALSE;
00583             }
00584
00585             slist = (SOCKET_ADDRESS_LIST *)addrbuf;
00586
00587             if (resptr->ai_family == AF_INET)
00588                 printf("IPv4 addresses bound...\n");
00589             else if (resptr->ai_family == AF_INET6)
00590                 printf("IPv6 addresses bound...\n");
00591             else
00592                 printf("Unknown address family addresses bound...\n");
00593
00594             for (int j = 0; j < slist->iAddressCount ; j++)
00595             {
00596                 if (j >= g_nMaxNumOfCSAddr)
00597                 {
00598                     printf("Max. number of socket address (%d) reached. We will not advertise extra ones\n", g_nMaxNumOfCSAddr);
00599                     break;
00600                 }
00601
00602                 // Copy the address over
00603                 memcpy(&g_aSockAddr[j], slist->Address[j].lpSockaddr, slist->Address[j].iSockaddrLength);
00604
00605                 // Set the port number our socket is actually bound to
00606                 SetIpPort(&g_aSockAddr[j],&ss_in);
00607
00608                 char temp[128] = {'\0'};
00609                 GetSockAddrString (&g_aSockAddr[j], slist->Address[j].iSockaddrLength, temp, 128);
00610                 printf("Address %40s\n", temp);
00611
00612                 g_aCSAddr[j].iSocketType = SOCK_DGRAM;
00613                 g_aCSAddr[j].iProtocol = IPPROTO_UDP;
00614                 g_aCSAddr[j].LocalAddr.lpSockaddr = (struct sockaddr *)&g_aSockAddr[j];
00615                 g_aCSAddr[j].LocalAddr.iSockaddrLength = slist->Address[j].iSockaddrLength;
00616                 g_aCSAddr[j].RemoteAddr.lpSockaddr = (struct sockaddr *)&g_aSockAddr[j];
00617                 g_aCSAddr[j].RemoteAddr.iSockaddrLength = slist->Address[j].iSockaddrLength;
00618
00619                 nNumOfCSAddr++; // increase the number SOCKADDR buffer used
00620             }
00621             i++; // increase the number of socket created
00622
00623             // Go to the next address
00624             resptr = resptr->ai_next;
00625
00626             // Free the address buffer
00627             HeapFree(GetProcessHeap(), 0, addrbuf);
00628             addrbuf = NULL;
00629         }
00630         freeaddrinfo(res);
00631     }
00632
00633     if (g_fSap && (nNumOfCSAddr < g_nMaxNumOfCSAddr))
00634     {
00635         // advertise into the NS_SAP name space if we still have enough
00636         // socket address buffer
00637         SecureZeroMemory(sa_ipx.sa_netnum,sizeof(sa_ipx.sa_netnum));
00638         SecureZeroMemory(sa_ipx.sa_nodenum,sizeof(sa_ipx.sa_nodenum));
00639         sa_ipx.sa_family = AF_IPX;
00640         sa_ipx.sa_socket = 0;
00641
00642         g_aSock[i] = socket ( AF_IPX, SOCK_DGRAM, NSPROTO_IPX );
00643         if ( INVALID_SOCKET == g_aSock[i] )
00644         {
00645             printf("socket error %d\n", WSAGetLastError());
00646             return FALSE;
00647         }
00648
00649         nRet = bind ( g_aSock[i], (SOCKADDR *) &sa_ipx, sizeof (sa_ipx) );
00650         if ( SOCKET_ERROR == nRet )
00651         {
00652             printf("bind error %d\n", WSAGetLastError());
00653             return FALSE;
00654         }
00655
00656         //--------------Find out our bound ipx addresses------------
00657         int cb = 0;        // size variable
00658         int nAdapters = 0; // number of adapters bound with IPX
00659
00660         // get the number of adapters
00661         cb = sizeof(nAdapters);
00662         nRet = getsockopt(g_aSock[i], NSPROTO_IPX, IPX_MAX_ADAPTER_NUM, (char *) &nAdapters, &cb);
00663         if (nRet == SOCKET_ERROR)
00664         {
00665             printf("getsockopt error %d\n", WSAGetLastError());
00666             return FALSE;
00667         }
00668
00669
00670         SOCKADDR_IPX* pSaIpx = NULL;           // a pointer to our current SOCKADDR buffer
00671         printf("IPX addresses bound...\n");
00672
00673         for (int nIdx = 0; nIdx < nAdapters; nIdx++)
00674         {
00675             if (nNumOfCSAddr >= g_nMaxNumOfCSAddr)
00676             {
00677                 printf("Max. number of socket address (%d) reached. We will not advertise extra ones\n", g_nMaxNumOfCSAddr);
00678                 break;
00679             }
00680             // get the buffer for this SOCKADDR
00681             pSaIpx = (SOCKADDR_IPX *) &g_aSockAddr[nNumOfCSAddr];
00682
00683             if (GetBoundIpxAddr(g_aSock[i],  pSaIpx, nIdx) == FALSE)
00684             {
00685                 printf("No valid bound IPX address at adapter index %d\n", nIdx);
00686                 // since this link is not available, nNumOfCSAddr will reuse the current SOCKADDR buffer
00687                 continue;
00688             }
00689
00690             char temp[DEFAULT_STRING_LEN] = {'\0'};
00691             GetSockAddrString (&g_aSockAddr[nNumOfCSAddr], sizeof(SOCKADDR_IPX), temp, DEFAULT_STRING_LEN);
00692             printf("%40s\n", temp);
00693
00694             g_aCSAddr[nNumOfCSAddr].iSocketType = SOCK_DGRAM;
00695             g_aCSAddr[nNumOfCSAddr].iProtocol = NSPROTO_IPX;
00696             g_aCSAddr[nNumOfCSAddr].LocalAddr.lpSockaddr = (struct sockaddr *)&g_aSockAddr[nNumOfCSAddr];
00697             g_aCSAddr[nNumOfCSAddr].LocalAddr.iSockaddrLength = sizeof(sa_ipx);
00698             g_aCSAddr[nNumOfCSAddr].RemoteAddr.lpSockaddr = (struct sockaddr *)&g_aSockAddr[nNumOfCSAddr];
00699             g_aCSAddr[nNumOfCSAddr].RemoteAddr.iSockaddrLength = sizeof(sa_ipx);
00700
00701             nNumOfCSAddr++;
00702         }
00703         i++; // increase the number of socket created
00704
00705         // Note: If g_fNtds is TRUE, this ipx address will be
00706         //       available from the NTDS name space too.
00707
00708     }
00709
00710     // update counters
00711     g_QS.dwNumberOfCsAddrs = nNumOfCSAddr;
00712     g_nNumOfUsedSocks = i;
00713
00714     // Call WSASetService
00715     printf("Advertise server of instance name: %s ...\n", pszServerName);
00716     nRet = WSASetService(&g_QS, RNRSERVICE_REGISTER, 0L);
00717     if (nRet == SOCKET_ERROR)
00718     {
00719         printf("WSASetService error %d\n", WSAGetLastError());
00720         return FALSE;
00721     }
00722     printf("Wait for client talking to me, hit Ctrl-C to terminate...\n");
00723     return TRUE;
00724
00725 }
00726
00727 //---------------------------------------------------------------------------
00728 //  FUNCTION: GetBoundIpxAddr(SOCKET soc, SOCKADDR_IPX * pSaIpx, int nAdapter)
00729 //
00730 //  PURPOSE:  Given a bound socket "soc", fill up "pSaIpx" with a valid
00731 //            ipx address corresponding to the 0-based adapter index "nAdapter".
00732 //
00733 //  RETURNS:
00734 //    TRUE if succeed otherwise FALSE
00735 //
00736 //---------------------------------------------------------------------------
00737 BOOL GetBoundIpxAddr(SOCKET soc, SOCKADDR_IPX * pSaIpx, int nAdapter)
00738 {
00739     IPX_ADDRESS_DATA ipx_data = {0}; // see wsnwlink.h for details
00740     int cb = 0; // size variable
00741     int nRet = 0;
00742
00743
00744     cb = sizeof ( IPX_ADDRESS_DATA );
00745     SecureZeroMemory(&ipx_data,sizeof(IPX_ADDRESS_DATA));
00746     ipx_data.adapternum = nAdapter;
00747
00748     nRet = getsockopt ( soc, NSPROTO_IPX, IPX_ADDRESS, (char *) &ipx_data, &cb );
00749     if ( SOCKET_ERROR == nRet)
00750     {
00751         printf("getsockopt error %d\n", WSAGetLastError());
00752         return FALSE;
00753     }
00754
00755     cb = sizeof(SOCKADDR_IPX);
00756     if (getsockname(soc, (SOCKADDR *) pSaIpx, &cb) == SOCKET_ERROR)
00757     {
00758         printf("getsockname error %d\n", WSAGetLastError());
00759         return FALSE;
00760     }
00761     else
00762     {
00763         if (ipx_data.status == TRUE)
00764         {
00765             // this link is UP
00766             memcpy(pSaIpx->sa_netnum, ipx_data.netnum, sizeof(pSaIpx->sa_netnum));
00767             memcpy(pSaIpx->sa_nodenum, ipx_data.nodenum, sizeof(pSaIpx->sa_nodenum));
00768             return TRUE;
00769         }
00770         else
00771             return FALSE; // this link is DOWN
00772     }
00773 }
00774
00775 //---------------------------------------------------------------------------
00776 //  FUNCTION: CheckAvailableNameSpaceProviders(BOOL& fNsSap, BOOL& fNsNtds)
00777 //
00778 //  PURPOSE:  Check the avaliable name space providers, set fNsSap to TRUE if
00779 //            SAP is available, and fNsNtds to TRUE if NT Directory Service
00780 //            is avaialble.
00781 //
00782 //  RETURNS:
00783 //    TRUE if succeed otherwise FALSE
00784 //
00785 //  NOTE: In this sample, we are only interested to know if NS_NTDS or NS_SAP
00786 //        name space provoder is available.
00787 //---------------------------------------------------------------------------
00788 BOOL CheckAvailableNameSpaceProviders(BOOL& fNsSap, BOOL& fNsNtds)
00789 {
00790     LPWSANAMESPACE_INFO pInfo = NULL;
00791     DWORD dwBufLen = 0;
00792     PBYTE pBuf = NULL;
00793     int nCount = 0;
00794     int nRet = 0;
00795
00796     dwBufLen = 0;
00797
00798     fNsSap = fNsNtds = FALSE;
00799
00800     nRet = WSAEnumNameSpaceProviders(&dwBufLen, NULL);
00801     if (nRet == SOCKET_ERROR)
00802     {
00803         if (WSAGetLastError() != WSAEFAULT)
00804         {
00805             printf("Error %d\n", WSAGetLastError());
00806             return FALSE;
00807         }
00808     }
00809
00810     // dwBufLen contains the needed buffer size
00811     pBuf = (PBYTE) HeapAlloc(GetProcessHeap(), 0, dwBufLen);
00812     if (pBuf == NULL)
00813     {
00814         printf("\nCould not allocate buffer\n");
00815         return FALSE;
00816     }
00817
00818     nRet = WSAEnumNameSpaceProviders(&dwBufLen, (LPWSANAMESPACE_INFO)pBuf);
00819     if (nRet == SOCKET_ERROR)
00820     {
00821         printf("Error: %d\n", WSAGetLastError());
00822         HeapFree(GetProcessHeap(), 0, pBuf);
00823         return FALSE;
00824     }
00825
00826     //Loop thru the returned info
00827     pInfo = (LPWSANAMESPACE_INFO)pBuf;
00828     for (nCount = 0; nCount < nRet; nCount++)
00829     {
00830         switch (pInfo->dwNameSpace)
00831         {
00832         case NS_SAP:
00833             fNsSap = TRUE;
00834             break;
00835         case NS_NTDS:
00836             fNsNtds = TRUE;
00837             break;
00838         default:
00839             break;
00840         }
00841         pInfo++;
00842     }
00843     HeapFree(GetProcessHeap(), 0, pBuf);
00844     return TRUE;
00845 }
00846
00847 //---------------------------------------------------------------------------
00848 //  FUNCTION: BOOL ServerRecv()
00849 //
00850 //  PURPOSE: For each bound socket in g_aSock[], try to do a non-blocking
00851 //           receive and print out the peer's address information.
00852 //
00853 //  RETURNS:
00854 //    TRUE if succeed otherwise FALSE
00855 //---------------------------------------------------------------------------
00856 BOOL ServerRecv()
00857 {
00858
00859     int      nBytesReceived = 0;
00860     char     szBuf[1024] = {'\0'};
00861     SOCKADDR_STORAGE sa_peer = {0};
00862     int      nPeerAddrLen = 0;
00863
00864     for (int i = 0; i < g_nNumOfUsedSocks; i++)
00865     {
00866         nPeerAddrLen = sizeof(SOCKADDR_STORAGE);
00867         // You can use "nBytesReceived = recv(g_aSock[i], szBuf, sizeof(szBuf), 0 );", if
00868         // you don't want your peer's address information.
00869         nBytesReceived = recvfrom(g_aSock[i], szBuf, sizeof(szBuf), 0, (SOCKADDR*)&sa_peer, &nPeerAddrLen);
00870
00871         if (nBytesReceived == SOCKET_ERROR)
00872         {
00873             int nRet = WSAGetLastError();
00874             if (nRet == WSAEWOULDBLOCK || nRet == WSAEMSGSIZE)
00875                 continue;
00876             else
00877             {
00878                 printf("recv error: %d\n", nRet);
00879                 return FALSE;
00880             }
00881         }
00882         else
00883         {
00884             printf("received: [%s ", szBuf);
00885
00886             char temp[DEFAULT_STRING_LEN] = {'\0'};
00887             GetSockAddrString (&sa_peer, nPeerAddrLen, temp, DEFAULT_STRING_LEN);
00888             printf(": %s]\n", temp);
00889         }
00890     }
00891     return TRUE;
00892 }
00893
00894 //---------------------------------------------------------------------------
00895 //  FUNCTION: BOOL WINAPI CtrlHandler ( DWORD dwEvent )
00896 //  Intercept CTRL-C or CTRL-BRK events and cause the server to
00897 //  initiate shutdown and cleanup.
00898 //---------------------------------------------------------------------------
00899 BOOL WINAPI CtrlHandler (   DWORD dwEvent )
00900 {
00901     int nRet = 0;
00902     int i = 0;
00903     WCHAR szGuid[MAX_PATH] = {'\0'};
00904     HRESULT hRet;
00905
00906     switch (dwEvent)
00907     {
00908     case CTRL_C_EVENT:
00909     case CTRL_BREAK_EVENT:
00910     case CTRL_LOGOFF_EVENT:
00911     case CTRL_SHUTDOWN_EVENT:
00912     case CTRL_CLOSE_EVENT:
00913         fEndProgram = TRUE;
00914         printf("CtrlHandler: cleaning up...\n");
00915
00916         printf("delete service instance...\n");
00917         nRet = WSASetService(&g_QS, RNRSERVICE_DELETE, 0L);
00918         if (nRet == SOCKET_ERROR)
00919         {
00920             printf("WSASetService DELETE error %d\n", WSAGetLastError());
00921         } else
00922             printf(" Deleted.\n");
00923
00924         printf("Removing Service class ");
00925
00926         if (SUCCEEDED(hRet = StringCchPrintfW(szGuid,
00927                                               sizeof(szGuid)/sizeof(szGuid[0]),
00928                                               L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
00929                                               g_MyGuid.Data1,
00930                                               g_MyGuid.Data2,
00931                                               g_MyGuid.Data3,
00932                                               g_MyGuid.Data4[0],
00933                                               g_MyGuid.Data4[1],
00934                                               g_MyGuid.Data4[2],
00935                                               g_MyGuid.Data4[3],
00936                                               g_MyGuid.Data4[4],
00937                                               g_MyGuid.Data4[5],
00938                                               g_MyGuid.Data4[6],
00939                                               g_MyGuid.Data4[7]
00940                                              )))
00941         {
00942             wprintf(L"%s",szGuid);
00943
00944         }
00945
00946         printf("... \n");
00947
00948         nRet = WSARemoveServiceClass(&g_MyGuid);
00949         if (nRet == SOCKET_ERROR)
00950         {
00951             printf("WSARemoveServiceClass error %d\n", WSAGetLastError());
00952         } else
00953             printf(" Removed.\n");
00954
00955         for (i = 0; i < g_nMaxNumOfSocks; i++)
00956         {
00957             if ( g_aSock[i] != INVALID_SOCKET )
00958             {
00959                 closesocket ( g_aSock[i] );
00960                 g_aSock[i] = INVALID_SOCKET;
00961             }
00962         }
00963         break;
00964
00965     default:
00966         // unknown type--better pass it on.
00967         return FALSE;
00968     }
00969     return TRUE;
00970 }
00971
00972
00973 //-------------------------------------
00974 // Client side routines
00975 //-------------------------------------
00976
00977 //---------------------------------------------------------------------------
00978 //  FUNCTION: void DoRnrClient (int nServiceType, char * pszServerName, DWORD dwNameSpace)
00979 //
00980 //  PURPOSE: Given the service type id "nServiceType", the server instance name
00981 //           "pszServerName" and the name space to query "dwNameSpace",
00982 //           perform name resolution to the server and send a message to it.
00983 //           If "nServiceType" is some known SAP Id such as Print Queue (3),
00984 //           File Server (4), Job Server (5), Print Server (7), Archive
00985 //           Server (9), Remote Bridge Server (36) or Advertising Print Server
00986 //           (71), it will not send a message to the server.
00987 //---------------------------------------------------------------------------
00988 void DoRnrClient (int nServiceType, char * pszServerName, DWORD dwNameSpace)
00989 {
00990     static GUID guid = SVCID_NETWARE ( nServiceType );  //use this as the class id
00991     WSAQUERYSET qs = {0};
00992     AFPROTOCOLS afp[g_nMaxNumOfSocks] = {{AF_IPX,  NSPROTO_IPX}, {AF_INET, IPPROTO_UDP}, {AF_INET6, IPPROTO_UDP}};
00993     HANDLE hLookup = NULL;
00994     DWORD dwResult = 0;
00995     static char szName[100] = {'\0'};
00996     BOOL fKnownSapId = FALSE;
00997     DWORD dwLength = 0;
00998     BYTE abyBuf[sizeof(WSAQUERYSET) + OFFSET] = {0}; // provide a sufficient large
00999     // buffer for returned query set
01000     WSAQUERYSET * pQS = (WSAQUERYSETA*) abyBuf;
01001     HRESULT hRet;
01002
01003     if(FAILED(hRet = StringCchCopy(szName,
01004                                    sizeof(szName)/sizeof(szName[0]),
01005                                    pszServerName
01006                                    )))
01007     {
01008         printf("StringCchCopy failed: 0x%x\n",hRet);
01009         return;
01010     }
01011
01012     SecureZeroMemory (&qs, sizeof (WSAQUERYSET));
01013     qs.dwSize = sizeof (WSAQUERYSET);
01014     qs.lpszServiceInstanceName = szName;
01015     qs.lpServiceClassId = &guid;
01016     qs.dwNameSpace = dwNameSpace;
01017     qs.dwNumberOfProtocols = g_nMaxNumOfSocks;
01018     qs.lpafpProtocols = afp;
01019
01020     SecureZeroMemory (abyBuf, sizeof (WSAQUERYSET) + OFFSET);
01021     dwLength = sizeof(WSAQUERYSET) + OFFSET;
01022
01023     // some well known SAP name space services
01024     if (nServiceType == 3 || nServiceType == 4 || nServiceType == 5 ||
01025         nServiceType == 7 || nServiceType == 9 || nServiceType == 36 || nServiceType == 71)
01026         fKnownSapId = TRUE;
01027
01028     if (WSALookupServiceBegin ( &qs,
01029                                 LUP_RETURN_ADDR | LUP_RETURN_NAME,
01030                                 &hLookup) == SOCKET_ERROR)
01031     {
01032         PrintError("WSALookupServiceBegin");
01033         return;
01034     }
01035
01036     printf ("Performing Query for service (type, name) = (%d, %s) . . .\n\n", nServiceType, pszServerName);
01037
01038     if (strcmp(pszServerName, "*") == 0)
01039     {   // enumerate all service instances
01040         for (;;)
01041         {
01042             dwResult = WSALookupServiceNext(hLookup,
01043                                             0,
01044                                             &dwLength,
01045                                             pQS);
01046             if (dwResult == SOCKET_ERROR)
01047             {
01048                 if (WSAGetLastError() == WSAEFAULT)
01049                 {
01050                     printf("WSALookupServiceNext Error: Oops, we need a larger buffer size of : %d Bytes\n", dwLength);
01051                 }
01052                 else
01053                 {
01054                     PrintError("WSALookupServiceNext");
01055                 }
01056                 WSALookupServiceEnd (hLookup);
01057                 return;
01058             }
01059
01060             if (!dwResult)
01061             {
01062                 for (DWORD i = 0; i < pQS->dwNumberOfCsAddrs; i++)
01063                 {
01064                     SOCKADDR_STORAGE *mypt = (SOCKADDR_STORAGE *) pQS->lpcsaBuffer[i].RemoteAddr.lpSockaddr;
01065                     if (mypt)
01066                     {
01067                         // we have valid remote sockaddr
01068                         char temp[DEFAULT_STRING_LEN] = {'\0'};
01069
01070                         printf ("Name[%d]: %30s", i, pQS->lpszServiceInstanceName);
01071                         GetSockAddrString (mypt, pQS->lpcsaBuffer[i].RemoteAddr.iSockaddrLength, temp, DEFAULT_STRING_LEN);
01072                         printf("%40s\n", temp);
01073
01074                         if (! fKnownSapId)
01075                             ClientSend(&(pQS->lpcsaBuffer[i]));
01076                     }
01077                 }
01078
01079             }
01080         }
01081     }
01082     else
01083     {
01084         dwResult = WSALookupServiceNext(hLookup,
01085                                         0,
01086                                         &dwLength,
01087                                         pQS);
01088
01089         if (dwResult == SOCKET_ERROR)
01090         {
01091             if (WSAGetLastError() == WSAEFAULT)
01092             {
01093                 printf("WSALookupServiceNext Error: Oops, we need a larger buffer size of : %d Bytes\n", dwLength);
01094             }
01095             else
01096             {
01097                 PrintError("WSALookupServiceNext");
01098             }
01099             WSALookupServiceEnd (hLookup);
01100             return;
01101         }
01102
01103         if (!dwResult)
01104         {
01105             for (DWORD i = 0; i < pQS->dwNumberOfCsAddrs; i++)
01106             {
01107                 SOCKADDR_STORAGE *mypt = (SOCKADDR_STORAGE *) pQS->lpcsaBuffer[i].RemoteAddr.lpSockaddr;
01108                 if (mypt)
01109                 {
01110                     // we have valid remote sockaddr
01111                     char temp[DEFAULT_STRING_LEN] = {'\0'};
01112                     printf ("Name[%d]: %30s", i, pQS->lpszServiceInstanceName);
01113                     GetSockAddrString (mypt, pQS->lpcsaBuffer[i].RemoteAddr.iSockaddrLength, temp, DEFAULT_STRING_LEN);
01114                     printf("%40s\n", temp);
01115
01116                     if (! fKnownSapId)
01117                         ClientSend(&(pQS->lpcsaBuffer[i]));
01118                 }
01119             }
01120         }
01121         WSALookupServiceEnd (hLookup);
01122     }
01123 }
01124
01125 //---------------------------------------------------------------------------
01126 //  FUNCTION: void ClientSend(CSADDR_INFO* lpcsaBuffer)
01127 //
01128 //  PURPOSE: Given the server socket address info "lpcsaBuffer",
01129 //           send a message to the peer.
01130 //---------------------------------------------------------------------------
01131 void ClientSend(CSADDR_INFO* lpcsaBuffer)
01132 {
01133
01134     SOCKADDR_STORAGE *mypt = (SOCKADDR_STORAGE *) lpcsaBuffer->RemoteAddr.lpSockaddr;
01135
01136     SOCKET s = INVALID_SOCKET;
01137     static char szMessage[DEFAULT_STRING_LEN] = "A message from the client: ";
01138     static BOOL fHostname = FALSE;
01139     char szName[DEFAULT_STRING_LEN] = {'\0'};
01140     unsigned long ulSize = sizeof(szName);
01141     HRESULT hRet;
01142
01143     if (fHostname == FALSE)
01144     {
01145         GetComputerName(szName, &ulSize);
01146
01147         if (FAILED(hRet = StringCchCat(szMessage,
01148                                        sizeof(szMessage)/sizeof(szMessage[0]),
01149                                        szName
01150                                        )))
01151         {
01152             printf("StringCchCat failed: 0x%x\n",hRet);
01153             return;
01154         }
01155
01156         fHostname = TRUE;
01157     }
01158
01159     // The client doesn't need to know the detail of the addressing
01160     // information, it can just do the common sequence of
01161     // socket, connect, send/recv and closesocket by using the
01162     // discovered RemoteAddr.
01163     s = socket(lpcsaBuffer->RemoteAddr.lpSockaddr->sa_family,
01164                lpcsaBuffer->iSocketType,
01165                lpcsaBuffer->iProtocol);
01166
01167     if (s != INVALID_SOCKET)
01168     {
01169         if (connect(s, (SOCKADDR*)mypt, lpcsaBuffer->RemoteAddr.iSockaddrLength) != SOCKET_ERROR)
01170         {
01171             // NOTE on send on 64bit.  strlen returns a 64bit INT and send takes a 32bit int.
01172             // verify that your data is NOT larger that your data is not larger than SO_MAX_MSG_SIZE
01173             // returned by getsockopt
01174
01175             if (send(s, szMessage, (INT)strlen(szMessage)+1, 0) != SOCKET_ERROR )
01176             {
01177                 printf("send a message to the peer...\n");
01178             }
01179             else
01180             {
01181                 printf("send failed %d\n", WSAGetLastError());
01182             }
01183         }
01184         else
01185         {
01186             printf("connect failed %d\n", WSAGetLastError());
01187         }
01188
01189         if (INVALID_SOCKET != s)
01190         {
01191             closesocket(s);
01192             s = INVALID_SOCKET;
01193         }
01194     }
01195     else
01196         printf("Failed socket call %d\n", WSAGetLastError());
01197 }
01198
01199 //---------------------------------------------------------------------------
01200 // FUNCTION: void PrintError (char* errfunc)
01201 // PURPOSE:  Print error message.
01202 //---------------------------------------------------------------------------
01203 void PrintError (char* errfunc)
01204 {
01205     fflush (stdout);
01206     if (WSASERVICE_NOT_FOUND == WSAGetLastError())
01207         fprintf (stderr, "No matches found.\n");
01208     else
01209         if (WSA_E_NO_MORE == WSAGetLastError() || WSAENOMORE == WSAGetLastError())
01210         fprintf (stderr, "No more matches. \n");
01211     else
01212         fprintf (stderr, "Function %s failed with error %d\n", errfunc, WSAGetLastError());
01213 }
01214
01215
01216 //---------------------------------------------------------------------------
01217 //  FUNCTION: void GetSockAddrString(SOCKADDR* pSAddr, int addrlen, char * dest, int destlen)
01218 //
01219 //  PURPOSE:  Converts INET or IPX address in "pSAddr" into ascii string in "dest"
01220 //
01221 //
01222 //  COMMENTS:
01223 //
01224 //    INET address in decimal dotted notation:
01225 //       107.50.104.97:4790
01226 //    IPX address format in hex:
01227 //      <8 char network address>.<12 char node address>.<4 char sock address>
01228 //
01229 //  NOTE: Since Winsock 2 WSAAddressToString API is now only working for
01230 //        IP (AF_INET) and ATM (AF_ATM) address family, I would rather implement
01231 //        my version as GetSockAddrString()
01232 //---------------------------------------------------------------------------
01233 void GetSockAddrString(SOCKADDR_STORAGE* pSAddr, int addrlen, char * dest, int destlen)
01234 {
01235     HRESULT hRet;
01236
01237     if (pSAddr == NULL || dest == NULL)
01238         return;
01239
01240
01241     switch (pSAddr->ss_family)
01242     {
01243     case AF_INET:
01244     case AF_INET6:
01245         {
01246             char host[NI_MAXHOST],
01247             serv[NI_MAXSERV];
01248             int  hostlen = NI_MAXHOST,
01249             servlen = NI_MAXSERV,
01250             rc;
01251
01252             rc = getnameinfo((SOCKADDR*)pSAddr, addrlen, host, hostlen, serv, servlen,
01253                              NI_NUMERICHOST | NI_NUMERICSERV);
01254             if (rc != 0)
01255             {
01256                 if (FAILED(hRet = StringCchPrintf(dest,destlen-1,"getnameinfo failed: %d",rc)))
01257                 {
01258                     printf("StringCchPrintf failed: 0x%x\n",hRet);
01259                     return;
01260                 }
01261
01262                 return;
01263             }
01264
01265             if (FAILED(hRet = StringCchPrintf(dest,destlen-1,"%s:%s",host,serv)))
01266             {
01267                 printf("StringCchPrintf failed: 0x%x\n",hRet);
01268                 return;
01269             }
01270
01271
01272
01273         }
01274         break;
01275     case AF_IPX:
01276         {
01277             PSOCKADDR_IPX pIpxAddr = (PSOCKADDR_IPX) pSAddr;
01278
01279             if (FAILED(hRet = StringCchPrintf(dest, destlen-1,
01280                                               "%02X%02X%02X%02X.%02X%02X%02X%02X%02X%02X:%04X",
01281                                               (unsigned char)pIpxAddr->sa_netnum[0],
01282                                               (unsigned char)pIpxAddr->sa_netnum[1],
01283                                               (unsigned char)pIpxAddr->sa_netnum[2],
01284                                               (unsigned char)pIpxAddr->sa_netnum[3],
01285                                               (unsigned char)pIpxAddr->sa_nodenum[0],
01286                                               (unsigned char)pIpxAddr->sa_nodenum[1],
01287                                               (unsigned char)pIpxAddr->sa_nodenum[2],
01288                                               (unsigned char)pIpxAddr->sa_nodenum[3],
01289                                               (unsigned char)pIpxAddr->sa_nodenum[4],
01290                                               (unsigned char)pIpxAddr->sa_nodenum[5],
01291                                               ntohs(pIpxAddr->sa_socket)
01292                                               )))
01293             {
01294                 printf("StringCchPrintf failed: 0x%x\n",hRet);
01295                 return;
01296             }
01297         }
01298         break;
01299     default:
01300         if(FAILED(hRet = StringCchCopy(dest,destlen-1,"Unknown socket address family")))
01301         {
01302             printf("StringCchCopy failed: 0x%x\n",hRet);
01303         }
01304         break;
01305     }
01306 }
01307
01308 void SetIpPort(SOCKADDR_STORAGE *dest, SOCKADDR_STORAGE *src)
01309 {
01310     if (dest->ss_family == AF_INET)
01311         ((SOCKADDR_IN *)dest)->sin_port = ((SOCKADDR_IN *)src)->sin_port;
01312     else if (dest->ss_family == AF_INET6)
01313         ((SOCKADDR_IN6 *)dest)->sin6_port = ((SOCKADDR_IN6 *)src)->sin6_port;
01314 }
01315
01316 void DumpServiceClassInfo(LPWSASERVICECLASSINFO lpSci)
01317 {
01318     WCHAR szGuid[MAX_PATH] = {'\0'};
01319     GUID TempGuid = {0};
01320     DWORD i = 0;
01321     HRESULT hRet;
01322
01323     if (NULL == lpSci)
01324         return;
01325
01326     CopyMemory(&TempGuid,lpSci->lpServiceClassId,sizeof(GUID));
01327
01328     if (FAILED(hRet = StringCchPrintfW(szGuid,
01329                                        sizeof(szGuid)/sizeof(szGuid[0]),
01330                                        L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
01331                                        TempGuid.Data1,
01332                                        TempGuid.Data2,
01333                                        TempGuid.Data3,
01334                                        TempGuid.Data4[0],
01335                                        TempGuid.Data4[1],
01336                                        TempGuid.Data4[2],
01337                                        TempGuid.Data4[3],
01338                                        TempGuid.Data4[4],
01339                                        TempGuid.Data4[5],
01340                                        TempGuid.Data4[6],
01341                                        TempGuid.Data4[7]
01342                                       )))
01343     {
01344         printf("StringCchPrintfW failed: 0x%x\n",hRet);
01345         return;
01346
01347     }
01348
01349
01350
01351     printf("\nWSASERVICECLASSINFO %p:\n",lpSci);
01352     wprintf(L"lpServiceClassId:\t%s\n",szGuid);
01353     printf("lpszServiceClassName:\t%s\n",lpSci->lpszServiceClassName);
01354     printf("dwCount:\t\t%d\n",lpSci->dwCount);
01355
01356     for (i = 0; i < lpSci->dwCount; i++)
01357     {
01358         printf("lpClassInfos (WSANSCLASSINFOW %p):\n",&lpSci->lpClassInfos[i]);
01359         printf("\t\tdwNameSpace:\t%d\n",lpSci->lpClassInfos[i].dwNameSpace);
01360         printf("\t\tdwValueSize:\t%d\n",lpSci->lpClassInfos[i].dwValueSize);
01361         printf("\t\tdwValueType:\t%d\n",lpSci->lpClassInfos[i].dwValueType);
01362         printf("\t\tlpszName:\t%s\n",lpSci->lpClassInfos[i].lpszName);
01363         printf("\t\tlpValue:\t%p\n",lpSci->lpClassInfos[i].lpValue);
01364
01365     }
01366     printf("\n");
01367
01368     return;
01369
01370 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/NewsEvent/Helper/sampleConstants.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • NewsEvent
  • Helper

sampleConstants.java

Go to the documentation of this file.
00001 package helper;
00002 public interface sampleConstants
00003 {
00004   public static final boolean PARALLEL_FLAG   = true;
00005   public static final boolean UNINSTALL_FLAG    = false;
00006   public static final boolean INSTALL_FLAG    = true;
00007   public static final boolean SUBSCRIBE_FLAG    = true;
00008   public static final boolean UNSUBSCRIBE_FLAG    = false;
00009
00010   public static final String  EVENT_CLSID     = "{997FF9C0-0F01-11D3-9257-0080C7C30D72}";
00011   public static final String  CASCADE_EVENT_CLSID   = "{8CE4A9E0-0FC1-11D3-925A-0080C7C30D72}";
00012
00013   public static final String  EVENT_NAME      = "NEWSEVENTCLASSLib.NewsEvent";
00014   public static final String  CASCADE_EVENT_NAME  = "CASCADEECLib.CascadeEC";
00015   public static final String  PERSIS_EVENT_NAME = "PERSISTATLLib.NewsEvent";
00016
00017   public static final String  SUBSCRIBER_NAME   = "NewsSubscriber";
00018   public static final String  CASCADE_NAME    = "CascadeSubscription" ;
00019   public static final String  PUBLISHER_NAME    = "NewsPublisher";
00020   public static final String  PERSIS_NAME     = "PersistentNewsSubscription";
00021   public static final String  TRANSIENT_NAME    = "TransientSubscription";
00022
00023   public static final String  PERSIST_EVENT_DLL = "D:\\mssdk\\Samples\\COM\\Services\\Events\\EventNewsJAVA\\PersistSubs\\PersistSubs.dll";
00024   public static final String  CASCADE_EVENT_DLL = "D:\\mssdk\\Samples\\COM\\Services\\Events\\EventNewsJAVA\\CascadeEvent\\CascadeEvent.dll";
00025   public static final String  NEW_EVENT_DLL   = "D:\\mssdk\\Samples\\COM\\Services\\Events\\EventNewsJAVA\\NewsEvent\\NewsEvent.dll";
00026
00027 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampclnt/dump.cpp Source File

  • Dataaccess
  • oledb
  • sampclnt

dump.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Consumer
00003 // (C) Copyright 1991 - 2000 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // File name: DUMP.CPP
00006 //
00007 //      Dump\output routines for the SAMPCLNT sample OLE DB consumer.
00008 //
00009 //      See README.TXT for more information on the SAMPCLNT sample.
00010 //
00011 // Functions:
00012 //
00013 //      See SAMPCLNT.H for function prototypes
00014 //
00015
00016
00017
00018 #include "sampclnt.h"
00019
00020
00021
00022
00023 void DumpErrorMsg
00024   (
00025     const char* format,
00026     ...
00027   )
00028 {
00029   va_list argptr;
00030
00031   assert(format != NULL);
00032
00033   // log this message to stderr and to our log file
00034   va_start( argptr, format );
00035   tvfprintf( stderr, format, argptr);
00036     tvfprintf( g_fpLogFile, format, argptr);
00037   va_end( argptr );
00038 }
00039
00040
00041
00042 void DumpStatusMsg
00043   (
00044     const char* format,
00045     ...
00046   )
00047 {
00048   va_list argptr;
00049
00050   assert(format != NULL);
00051
00052   // log this message to stdout and to our log file
00053   va_start( argptr, format );
00054   tvfprintf( stdout, format, argptr );
00055     tvfprintf( g_fpLogFile, format, argptr );
00056   va_end( argptr );
00057 }
00058
00059
00060
00061
00062 HRESULT DumpErrorHResult
00063   (
00064   HRESULT      hr_return,
00065   const char  *format,      // can be NULL
00066   ...
00067   )
00068 {
00069   char     buff[100];
00070   int      cBytesWritten;
00071   va_list  argptr;
00072
00073   //
00074   // Dump an error message.
00075   // Print the text of the HRESULT,
00076   // Return the HRESULT we were passed.
00077
00078     // these result codes were generated from the oledberr.h
00079   static Note ResultCodes[] = {
00080     // oledberr.h error codes
00081     NOTE(DB_E_BADACCESSORHANDLE),
00082     NOTE(DB_E_BADACCESSORHANDLE),
00083     NOTE(DB_E_ROWLIMITEXCEEDED),
00084     NOTE(DB_E_READONLYACCESSOR),
00085     NOTE(DB_E_SCHEMAVIOLATION),
00086     NOTE(DB_E_BADROWHANDLE),
00087     NOTE(DB_E_OBJECTOPEN),
00088     NOTE(DB_E_BADBINDINFO),
00089     NOTE(DB_SEC_E_PERMISSIONDENIED),
00090     NOTE(DB_E_NOTAREFERENCECOLUMN),
00091     NOTE(DB_E_NOCOMMAND),
00092     NOTE(DB_E_BADBOOKMARK),
00093     NOTE(DB_E_BADLOCKMODE),
00094     NOTE(DB_E_PARAMNOTOPTIONAL),
00095     NOTE(DB_E_BADRATIO),
00096     NOTE(DB_E_ERRORSINCOMMAND),
00097     NOTE(DB_E_BADSTARTPOSITION),
00098     NOTE(DB_E_NOTREENTRANT),
00099     NOTE(DB_E_NOAGGREGATION),
00100     NOTE(DB_E_DELETEDROW),
00101     NOTE(DB_E_CANTFETCHBACKWARDS),
00102     NOTE(DB_E_ROWSNOTRELEASED),
00103     NOTE(DB_E_BADSTORAGEFLAG),
00104     NOTE(DB_E_BADSTATUSVALUE),
00105     NOTE(DB_E_CANTSCROLLBACKWARDS),
00106     NOTE(DB_E_INTEGRITYVIOLATION),
00107     NOTE(DB_E_ABORTLIMITREACHED),
00108     NOTE(DB_E_DUPLICATEINDEXID),
00109     NOTE(DB_E_NOINDEX),
00110     NOTE(DB_E_INDEXINUSE),
00111     NOTE(DB_E_NOTABLE),
00112     NOTE(DB_E_CONCURRENCYVIOLATION),
00113     NOTE(DB_E_BADCOPY),
00114     NOTE(DB_E_BADPRECISION),
00115     NOTE(DB_E_BADSCALE),
00116     NOTE(DB_E_BADID),
00117     NOTE(DB_E_BADTYPE),
00118     NOTE(DB_E_DUPLICATECOLUMNID),
00119     NOTE(DB_E_DUPLICATETABLEID),
00120     NOTE(DB_E_TABLEINUSE),
00121     NOTE(DB_E_NOLOCALE),
00122     NOTE(DB_E_BADRECORDNUM),
00123     NOTE(DB_E_BOOKMARKSKIPPED),
00124     NOTE(DB_E_BADPROPERTYVALUE),
00125     NOTE(DB_E_INVALID),
00126     NOTE(DB_E_BADACCESSORFLAGS),
00127     NOTE(DB_E_BADSTORAGEFLAGS),
00128     NOTE(DB_E_BYREFACCESSORNOTSUPPORTED),
00129     NOTE(DB_E_NULLACCESSORNOTSUPPORTED),
00130     NOTE(DB_E_NOTPREPARED),
00131     NOTE(DB_E_BADACCESSORTYPE),
00132     NOTE(DB_E_WRITEONLYACCESSOR),
00133     NOTE(DB_SEC_E_AUTH_FAILED),
00134     NOTE(DB_E_CANCELED),
00135     NOTE(DB_E_BADSOURCEHANDLE),
00136     NOTE(DB_S_ROWLIMITEXCEEDED),
00137     NOTE(DB_S_COLUMNTYPEMISMATCH),
00138     NOTE(DB_S_TYPEINFOOVERRIDDEN),
00139     NOTE(DB_S_BOOKMARKSKIPPED),
00140     NOTE(DB_S_ENDOFROWSET),
00141     NOTE(DB_S_BUFFERFULL),
00142     NOTE(DB_S_CANTRELEASE),
00143     NOTE(DB_S_DIALECTIGNORED),
00144     NOTE(DB_S_UNWANTEDPHASE),
00145     NOTE(DB_S_COLUMNSCHANGED),
00146     NOTE(DB_S_ERRORSRETURNED),
00147     NOTE(DB_S_BADROWHANDLE),
00148     NOTE(DB_S_DELETEDROW),
00149     NOTE(DB_S_STOPLIMITREACHED),
00150     NOTE(DB_S_LOCKUPGRADED),
00151     NOTE(DB_S_PROPERTIESCHANGED),
00152     NOTE(DB_S_ERRORSOCCURRED),
00153     NOTE(DB_S_PARAMUNAVAILABLE),
00154     NOTE(DB_S_MULTIPLECHANGES),
00155
00156     // winerr.h
00157     NOTE(E_UNEXPECTED),
00158     NOTE(E_NOTIMPL),
00159     NOTE(E_OUTOFMEMORY),
00160     NOTE(E_INVALIDARG),
00161     NOTE(E_NOINTERFACE),
00162     NOTE(E_POINTER),
00163     NOTE(E_HANDLE),
00164     NOTE(E_ABORT),
00165     NOTE(E_FAIL),
00166     NOTE(E_ACCESSDENIED),
00167     NOTE(S_OK),
00168     NOTE(S_FALSE),
00169     NOTE(E_UNEXPECTED),
00170     NOTE(E_NOTIMPL),
00171     NOTE(E_OUTOFMEMORY),
00172     NOTE(E_INVALIDARG),
00173     NOTE(E_NOINTERFACE),
00174     NOTE(E_POINTER),
00175     NOTE(E_HANDLE),
00176     NOTE(E_ABORT),
00177     NOTE(E_FAIL),
00178     NOTE(E_ACCESSDENIED),
00179     // BindMoniker Errors
00180     NOTE(MK_E_NOOBJECT),
00181     NOTE(MK_E_EXCEEDEDDEADLINE),
00182     NOTE(MK_E_CONNECTMANUALLY),
00183     NOTE(MK_E_INTERMEDIATEINTERFACENOTSUPPORTED),
00184     NOTE(STG_E_ACCESSDENIED),
00185     NOTE(MK_E_SYNTAX),
00186     NOTE(MK_E_CANTOPENFILE),
00187   };
00188
00189
00190   // Format the message.
00191   // Print name of hresult code.
00192
00193   if (format)
00194     {
00195     va_start( argptr, format );
00196     cBytesWritten = _vsnprintf( buff, sizeof(buff), format, argptr );
00197     va_end( argptr );
00198     }
00199   else
00200     strcpy( buff, "" );
00201
00202   // log to stderr and also to our log file
00203   tfprintf( stderr, "%.*s: Returned %.30s\n",
00204     sizeof(buff), buff,
00205     GetNoteString( ResultCodes, NUMELEM(ResultCodes), GetScode(hr_return)) );
00206
00207     tfprintf( g_fpLogFile, "%.*s: Returned %.30s\n",
00208     sizeof(buff), buff,
00209     GetNoteString( ResultCodes, NUMELEM(ResultCodes), GetScode(hr_return)) );
00210
00211   return ResultFromScode( hr_return );
00212 }
00213
00214
00215
00216
00217 void DumpColumnsInfo
00218   (
00219     DBCOLUMNINFO* pColInfo,
00220     ULONG       cCol
00221     )
00222 {
00223   ULONG j;
00224
00225   assert(pColInfo != NULL);
00226
00227   tfprintf( g_fpLogFile, "\nColumn Information:\n\n");
00228
00229   for (j=0; j < cCol; j++)
00230     {
00231     WriteColumnInfo( g_fpLogFile, &pColInfo[j] );
00232     }
00233 }
00234
00235
00236
00237 void WriteColumnInfo
00238   (
00239   FILE*     fp,
00240   DBCOLUMNINFO* p
00241   )
00242 {
00243   DBID      *pCol;
00244     DBKIND      eKind;
00245   wchar_t   wszGuidBuff[MAX_GUID_STRING];
00246     wchar_t     wszNameBuff[MAX_GUID_STRING];
00247
00248   static char *szDbcolkind[] = { "Guid+Name", "Guid+PropID", "Name",
00249       "Guid+Name", "Guid+PropID", "PropID", "Guid" };
00250
00251   assert(p != NULL);
00252
00253   // For DBTYPEENUM.  Doesn't need to be in order.
00254   // Below we mask off the high bits.
00255   static Note typenotes[] =
00256       {
00257     NOTE(DBTYPE_EMPTY),
00258     NOTE(DBTYPE_NULL),
00259     NOTE(DBTYPE_I2),
00260     NOTE(DBTYPE_I4),
00261     NOTE(DBTYPE_R4),
00262     NOTE(DBTYPE_R8),
00263     NOTE(DBTYPE_CY),
00264     NOTE(DBTYPE_DATE),
00265     NOTE(DBTYPE_BSTR),
00266     NOTE(DBTYPE_IDISPATCH),
00267     NOTE(DBTYPE_ERROR),
00268     NOTE(DBTYPE_BOOL),
00269     NOTE(DBTYPE_VARIANT),
00270     NOTE(DBTYPE_IUNKNOWN),
00271     NOTE(DBTYPE_DECIMAL),
00272     NOTE(DBTYPE_UI1),
00273     NOTE(DBTYPE_ARRAY),
00274     NOTE(DBTYPE_BYREF),
00275     NOTE(DBTYPE_I1),
00276     NOTE(DBTYPE_UI2),
00277     NOTE(DBTYPE_UI4),
00278     NOTE(DBTYPE_I8),
00279     NOTE(DBTYPE_UI8),
00280     NOTE(DBTYPE_GUID),
00281     NOTE(DBTYPE_VECTOR),
00282     NOTE(DBTYPE_RESERVED),
00283     NOTE(DBTYPE_BYTES),
00284     NOTE(DBTYPE_STR),
00285     NOTE(DBTYPE_WSTR),
00286     NOTE(DBTYPE_NUMERIC),
00287     NOTE(DBTYPE_UDT),
00288     NOTE(DBTYPE_DBDATE),
00289     NOTE(DBTYPE_DBTIME),
00290     NOTE(DBTYPE_DBTIMESTAMP),
00291       };
00292
00293   static Note flagnotes[] =
00294       {
00295     NOTE(DBCOLUMNFLAGS_ISBOOKMARK),
00296     NOTE(DBCOLUMNFLAGS_MAYDEFER),
00297     NOTE(DBCOLUMNFLAGS_WRITE),
00298     NOTE(DBCOLUMNFLAGS_WRITEUNKNOWN),
00299     NOTE(DBCOLUMNFLAGS_ISFIXEDLENGTH),
00300     NOTE(DBCOLUMNFLAGS_ISNULLABLE),
00301     NOTE(DBCOLUMNFLAGS_MAYBENULL),
00302     NOTE(DBCOLUMNFLAGS_ISLONG),
00303     NOTE(DBCOLUMNFLAGS_ISROWID),
00304     NOTE(DBCOLUMNFLAGS_ISROWVER),
00305     NOTE(DBCOLUMNFLAGS_CACHEDEFERRED),
00306     };
00307
00308   pCol = & p->columnid;
00309     eKind = pCol->eKind;
00310
00311     // stringize GUID for pretty printing
00312     switch (eKind)
00313         {
00314         case DBKIND_GUID_NAME:
00315         case DBKIND_GUID_PROPID:
00316         case DBKIND_GUID:
00317           StringFromGUID2( pCol->uGuid.guid, wszGuidBuff, sizeof(wszGuidBuff) );
00318             break;
00319         case DBKIND_PGUID_NAME:
00320         case DBKIND_PGUID_PROPID:
00321           StringFromGUID2( *(pCol->uGuid.pguid), wszGuidBuff, sizeof(wszGuidBuff) );
00322             break;
00323         default:
00324             wcscpy( wszGuidBuff, L"<none>" );
00325             break;
00326         }
00327
00328     // stringize name or propID for pretty printing
00329     switch (eKind)
00330         {
00331         case DBKIND_GUID_NAME:
00332         case DBKIND_NAME:
00333         case DBKIND_PGUID_NAME:
00334             swprintf( wszNameBuff, L"[name=%.50S]", pCol->uName.pwszName ? pCol->uName.pwszName : L"(unknown)" );
00335             break;
00336         case DBKIND_GUID_PROPID:
00337         case DBKIND_PGUID_PROPID:
00338         case DBKIND_PROPID:
00339             swprintf( wszNameBuff, L"[propid=%lu]", pCol->uName.ulPropid );
00340             break;
00341         default:
00342             wcscpy( wszNameBuff, L"" );
00343             break;
00344         }
00345
00346     // pretty print column info
00347     tfprintf( fp, "ColumnId [kind=%.40s] [guid=%.40S] %.60S\n",
00348         szDbcolkind[eKind], wszGuidBuff, wszNameBuff );
00349
00350
00351   // Now move on to other stuff...
00352   // Name in DBCOLUMNINFO different than name in DBCOLUMNID (maybe).
00353   tfprintf(fp, "  Name          = '%.50S'\n", p->pwszName );
00354   tfprintf(fp, "  iOrdinal      = %d\n", p->iOrdinal);
00355   tfprintf(fp, "  wType         = %.100s\n",
00356     GetNoteString( typenotes, NUMELEM(typenotes),
00357         p->wType & (~DBTYPE_BYREF) & (~DBTYPE_ARRAY) & (~DBTYPE_VECTOR) ) );
00358   if (p->wType & DBTYPE_BYREF)
00359     tfprintf(fp, "      (BYREF)\n");
00360   if (p->wType & DBTYPE_ARRAY)
00361     tfprintf(fp, "      (ARRAY)\n");
00362   if (p->wType & DBTYPE_VECTOR)
00363     tfprintf(fp, "      (VECTOR)\n");
00364   tfprintf(fp, "  ulColumnSize  = %ld\n", p->ulColumnSize );
00365   tfprintf(fp, "  bPrecision    = %d\n",  p->bPrecision );
00366   tfprintf(fp, "  bScale        = %d\n",  p->bScale );
00367   tfprintf(fp, "  dwFlags       = %s\n\n",
00368     GetNoteStringBitvals( flagnotes, NUMELEM(flagnotes), p->dwFlags ) );
00369
00370
00371 }
00372
00373
00374 char* GetNoteString
00375     (
00376   Note * rgNote,
00377   int    cNote,
00378   DWORD  dwValue
00379   )
00380 {
00381   int j;
00382
00383   assert(rgNote != NULL);
00384
00385   // Scan a table of value/string,
00386   // return ptr to string found.
00387
00388   for (j=0; j < cNote; j++) {
00389     if (rgNote[j].dwFlag == dwValue)
00390       return rgNote[j].szText;
00391   }
00392   return "<unknown>";
00393 }
00394
00395
00396
00397
00398
00399
00400
00401 char* GetNoteStringBitvals
00402   (
00403   Note*   rgNote,
00404   int     cNote,
00405   DWORD   dwValue
00406   )
00407 {
00408   static char buff[400];
00409   int j;
00410
00411   assert(rgNote != NULL);
00412
00413   // Make a string that combines all the bits ORed together.
00414
00415   strcpy(buff, "");
00416   for (j=0; j < cNote; j++) {
00417     if (rgNote[j].dwFlag & dwValue) {
00418       if (buff[0])
00419         strcat( buff, " | " );
00420       strcat( buff, rgNote[j].szText );
00421     }
00422   }
00423   assert(strlen(buff) < sizeof(buff));
00424   return buff;
00425 }
00426
00427
00428
00429
00430 ULONG CalcPrettyPrintMaxColWidth
00431     (
00432     DBBINDING*  rgBind,
00433     ULONG       cBind
00434     )
00435 {
00436   ULONG cMaxWidth;
00437     ULONG   cTotalWidth;
00438     ULONG iBind;
00439
00440   assert(rgBind != NULL);
00441
00442   cMaxWidth = DEFAULT_CBMAXLENGTH;
00443   while (1)
00444     {
00445     cTotalWidth = 0;
00446
00447     for (iBind=0; iBind < cBind; iBind++)
00448       cTotalWidth += min( cMaxWidth, rgBind[iBind].cbMaxLen ) + 1;
00449
00450     if (cTotalWidth < PRETTYPRINT_MAXTOTALWIDTH || cMaxWidth < PRETTYPRINT_MINCOLWIDTH)
00451       break;
00452
00453     cMaxWidth--;
00454     }
00455
00456   return cMaxWidth;
00457 }
00458
00459
00460
00461 void DumpColumnHeadings
00462   (
00463   DBBINDING*    rgBind,
00464   ULONG     cBind,
00465   DBCOLUMNINFO*   pColInfo,
00466   ULONG     cCol,
00467     ULONG     cMaxColWidth
00468   )
00469 {
00470   ULONG iBind;
00471
00472   assert(rgBind != NULL);
00473     assert(pColInfo != NULL);
00474
00475   for (iBind=0; iBind < cBind; iBind++)
00476     tfprintf( g_fpLogFile, "%-*.*S ",
00477       min( cMaxColWidth, rgBind[iBind].cbMaxLen ),
00478       min( cMaxColWidth, rgBind[iBind].cbMaxLen ),
00479       LookupColumnName( pColInfo, cCol, rgBind[iBind].iOrdinal ) );
00480   tfprintf( g_fpLogFile, "\n" );
00481   for (iBind=0; iBind < cBind; iBind++)
00482     tfprintf( g_fpLogFile, "%-*.*s ",
00483       min( cMaxColWidth, rgBind[iBind].cbMaxLen ),
00484       min( cMaxColWidth, rgBind[iBind].cbMaxLen ),
00485       "------------------------------" );
00486   tfprintf( g_fpLogFile, "\n" );
00487 }
00488
00489
00490
00491 WCHAR* LookupColumnName
00492   (
00493   DBCOLUMNINFO* rgColInfo,
00494   ULONG       cCol,
00495   ULONG       iCol
00496   )
00497 {
00498   ULONG j;
00499
00500   assert(rgColInfo != NULL);
00501
00502   // A really slow way to get the column name, given the ordinal.
00503   // The problem is that result-set ordinals do not necessarily match
00504   // the index into the ColumnInfo array.
00505   // (May have bookmark, which is always column 0.)
00506
00507   for (j=0; j < cCol; j++)
00508     if (rgColInfo[j].iOrdinal == iCol)
00509       return rgColInfo[j].pwszName;
00510
00511   return L"Error";
00512 }
00513
00514
00515
00516
00517 void DumpRow
00518   (
00519     DBBINDING*  rgBind,
00520     ULONG   cBind,
00521     ULONG   cMaxColWidth,
00522     BYTE*     pData
00523     )
00524 {
00525   ULONG     iBind;
00526     COLUMNDATA* pColumn;
00527
00528   assert(rgBind);
00529   assert( offsetof(COLUMNDATA, dwLength) == 0);
00530
00531   // Print each column we're bound to.
00532   for (iBind=0; iBind < cBind; iBind++)
00533     {
00534     // Columns are bound differently; not so easy.
00535     // Print out to at least DEFAULT_CBMAXLENGTH width (pretty),
00536     // Limit to first dwLength characters.
00537
00538     pColumn = (COLUMNDATA *) (pData + rgBind[iBind].obLength);
00539     PrintColumn( pColumn, rgBind, iBind, cMaxColWidth );
00540     }
00541   tfprintf( g_fpLogFile, "\n" );
00542 }
00543
00544
00545
00546
00547
00548 void PrintColumn
00549   (
00550   COLUMNDATA    *pColumn,
00551   DBBINDING     *rgBind,
00552   ULONG          iBind,
00553   ULONG          cMaxColWidth
00554   )
00555 {
00556   void* p;
00557   ULONG   ulPrintWidth;
00558   ULONG   ulPrintPrecision;
00559   DWORD   dwStatus;
00560   DWORD   dwLength;
00561   BOOL    fDidVariant;
00562   BOOL    fIsUnicode;
00563   char* sFormat;
00564   HRESULT hr;
00565
00566     assert(pColumn != NULL);
00567     assert(rgBind != NULL);
00568
00569   // Pretty print a column.
00570   // May have different type of binding.
00571
00572   fDidVariant = FALSE;
00573   fIsUnicode  = FALSE;
00574   dwStatus = pColumn->dwStatus;
00575   dwLength = pColumn->dwLength;
00576
00577   if (dwStatus == DBSTATUS_S_ISNULL)
00578     {
00579     p = "<null>";
00580     dwLength = strlen( (char *) p);
00581     }
00582     else if (dwStatus == DBBINDSTATUS_UNSUPPORTEDCONVERSION)
00583         {
00584         p = "<unsupportedconversion>";
00585     dwLength = strlen( (char *) p);
00586         }
00587   else
00588     {
00589     switch (rgBind[iBind].wType)
00590       {
00591     case DBTYPE_STR:
00592       // We have a string in our buffer, so use it.
00593       p = (void *) &pColumn->bData;
00594       break;
00595     case DBTYPE_VARIANT:
00596       // We have a variant in our buffer, so convert to string.
00597       p = (void *) &pColumn->bData;
00598       hr = VariantChangeTypeEx(
00599           (VARIANT *) p,      // Destination (convert in place)
00600           (VARIANT *) p,      // Source
00601           LOCALE_SYSTEM_DEFAULT,  // LCID
00602           0,            // dwFlags
00603           VT_BSTR );
00604       if (FAILED(hr))
00605               {
00606         DumpErrorHResult( hr, "VariantChangeTypeEx, field %d", iBind );
00607                 return;
00608                 }
00609       p = (wchar_t *) (((VARIANT *)p)->bstrVal) ;
00610       dwLength = ((DWORD *)p)[-1] / sizeof(wchar_t);
00611       fDidVariant = TRUE;
00612       fIsUnicode  = TRUE;
00613       break;
00614     default:
00615       p = "??? unknown type ???";
00616       break;
00617       }
00618     }
00619
00620   // Print the column.
00621   // If it has been truncated or rounded, print a '#' in
00622   // the far right-hand column.
00623   ulPrintWidth     = min( cMaxColWidth, rgBind[iBind].cbMaxLen );
00624   ulPrintPrecision = min( cMaxColWidth, dwLength );
00625   if (dwStatus == DBSTATUS_S_TRUNCATED ||  cMaxColWidth < dwLength)
00626   {
00627     ulPrintWidth--;
00628     ulPrintPrecision--;
00629   }
00630
00631   sFormat = fIsUnicode ? "%-*.*S" : "%-*.*s";
00632
00633   tfprintf( g_fpLogFile, sFormat, ulPrintWidth, ulPrintPrecision, p );
00634
00635   if (dwStatus == DBSTATUS_S_TRUNCATED ||  cMaxColWidth < dwLength)
00636     tfprintf( g_fpLogFile, "#" );
00637   tfprintf( g_fpLogFile, " " );
00638
00639   // Free memory used by the variant.
00640   if (fDidVariant)
00641     VariantClear( (VARIANT *) &pColumn->bData );
00642
00643   return;
00644 }
00645
00646
00647
00648
00649 void tfprintf
00650   (
00651   FILE*   fp,
00652   const char* format,
00653   ...
00654   )
00655 {
00656   int   cBytesWritten;
00657   char  buff[400];
00658   va_list argptr;
00659
00660   assert(format != NULL);
00661
00662   // Dump a formatted string.
00663     // _vsnprintf prevents overflowing our buffer.
00664   va_start( argptr, format );
00665   cBytesWritten = _vsnprintf( buff, sizeof(buff), format, argptr );
00666   va_end( argptr );
00667   buff[sizeof(buff)-1] = '\0';
00668
00669   // Can't use fprintf, because string could contain '%'.
00670   if (fp)
00671     fputs( buff, fp );
00672 }
00673
00674
00675
00676 void tvfprintf
00677   (
00678   FILE*   fp,
00679   const char* format,
00680   va_list   argptr
00681   )
00682 {
00683   int   cBytesWritten;
00684   char  buff[400];
00685
00686
00687   assert(format != NULL);
00688
00689   // Dump a formatted string.
00690     // _vsnprintf prevents overflowing our buffer.
00691   cBytesWritten = _vsnprintf( buff, sizeof(buff), format, argptr );
00692   buff[sizeof(buff)-1] = '\0';
00693
00694   // Can't use fprintf, because string could contain '%'.
00695   if (fp)
00696     fputs( buff, fp );
00697 }
00698
00699
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/app.Cpp Source File

  • Com
  • Fundamentals
  • SimpCntr

app.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: app.cpp
00003 //
00004 //    Implementation file for the CSimpleApp Class
00005 //
00006 // Functions:
00007 //
00008 //    See app.h for a list of member functions.
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "ioipf.h"
00017 #include "ioips.h"
00018 #include "app.h"
00019 #include "site.h"
00020 #include "doc.h"
00021 #include "stdpal.h"
00022
00023 #define cpeAppPal 256  // number of colors in our apps palette
00024 typedef struct
00025    {
00026    WORD wVersion;
00027    WORD cpe;
00028    PALETTEENTRY rgpe[cpeAppPal];
00029    } LOGPAL;
00030
00031
00032 //**********************************************************************
00033 //
00034 // CreateStandardPalette
00035 //
00036 // Purpose:
00037 //
00038 //      Creates a standard Apps palette.
00039 //
00040 // Parameters:
00041 //
00042 //      None
00043 //
00044 // Return Value:
00045 //
00046 //      None
00047 //
00048 //********************************************************************
00049 HPALETTE CreateStandardPalette(void)
00050    {
00051    HDC hdc;
00052    HPALETTE hpal;
00053
00054    hpal = (HPALETTE) NULL;
00055    hdc = GetDC(NULL);
00056    if (hdc != NULL && GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
00057       {
00058       int cpeSysPal;
00059       int cpeReserved;
00060
00061       cpeSysPal = GetDeviceCaps(hdc, SIZEPALETTE);
00062       cpeReserved = GetDeviceCaps(hdc, NUMRESERVED);
00063       if (cpeSysPal > cpeReserved)
00064          {
00065          int cpeReserved2;
00066          unsigned char FAR* lpb;
00067          PALETTEENTRY FAR* ppe;
00068          PALETTEENTRY FAR* ppeMac;
00069          LOGPAL logpal;
00070
00071          cpeReserved2 = cpeReserved/2;
00072
00073          // Get the system palette entries at the beginning and end.
00074          GetSystemPaletteEntries(hdc, 0, cpeReserved2, logpal.rgpe);
00075          GetSystemPaletteEntries(hdc, cpeSysPal - cpeReserved2, cpeReserved2,
00076             &logpal.rgpe[cpeAppPal-cpeReserved2]);
00077
00078          logpal.cpe = cpeAppPal;
00079          logpal.wVersion = 0x300;
00080
00081          lpb = (BYTE FAR *) &palSVGA[10];
00082          ppe = (PALETTEENTRY FAR*)&logpal.rgpe[cpeReserved2];
00083          ppeMac = (PALETTEENTRY FAR*)&logpal.rgpe[cpeAppPal-cpeReserved2];
00084          while (ppe < ppeMac)
00085             {
00086             ppe->peFlags = PC_NOCOLLAPSE;
00087             ppe->peRed   = *lpb++;
00088             ppe->peGreen = *lpb++;
00089             ppe->peBlue  = *lpb++;
00090             ppe++;
00091             }
00092          hpal = CreatePalette((LOGPALETTE FAR *)&logpal);
00093          }
00094       }
00095    ReleaseDC(NULL, hdc);
00096    return hpal;
00097    }
00098
00099 //**********************************************************************
00100 //
00101 // CSimpleApp::CSimpleApp()
00102 //
00103 // Purpose:
00104 //
00105 //      Constructor for CSimpleApp
00106 //
00107 // Parameters:
00108 //
00109 //      None
00110 //
00111 // Return Value:
00112 //
00113 //      None
00114 //
00115 // Function Calls:
00116 //      Function                    Location
00117 //
00118 //      OutputDebugString           Windows API
00119 //      SetRectEmpty                Windows API
00120 //
00121 // Comments:
00122 //
00123 //      CSimpleApp has a contained COleInPlaceFrame.  On construction
00124 //      of CSimpleApp, we explicitly call the constructor of this
00125 //      contained class and pass a copy of the this pointer, so that
00126 //      COleInPlaceFrame can refer back to this class
00127 //
00128 //********************************************************************
00129 #pragma warning(disable : 4355)  // turn off this warning.  This warning
00130                                                                 // tells us that we are passing this in
00131                                                                 // an initializer, before "this" is through
00132                                                                 // initializing.  This is ok, because
00133                                                                 // we just store the ptr in the other
00134                                                                 // constructor
00135
00136 CSimpleApp::CSimpleApp() : m_OleInPlaceFrame(this)
00137 #pragma warning (default : 4355)  // Turn the warning back on
00138 {
00139         OutputDebugString("In CSimpleApp's Constructor \r\n");
00140
00141         // clear members
00142         m_hAppWnd = NULL;
00143         m_hInst = NULL;
00144         m_lpDoc = NULL;
00145     m_hwndUIActiveObj = NULL;
00146
00147         // clear flags
00148         m_fInitialized = FALSE;
00149         m_fCSHMode = FALSE;
00150         m_fMenuMode = FALSE;
00151
00152         // used for inplace
00153         SetRectEmpty(&nullRect);
00154 }
00155
00156 //**********************************************************************
00157 //
00158 // CSimpleApp::~CSimpleApp()
00159 //
00160 // Purpose:
00161 //
00162 //      Destructor for CSimpleApp Class.
00163 //
00164 // Parameters:
00165 //
00166 //      None
00167 //
00168 // Return Value:
00169 //
00170 //      None
00171 //
00172 // Function Calls:
00173 //      Function                    Location
00174 //
00175 //      OutputDebugString           Windows API
00176 //      OleUninitialize             OLE API
00177 //
00178 // Comments:
00179 //
00180 //********************************************************************
00181
00182 CSimpleApp::~CSimpleApp()
00183 {
00184         OutputDebugString("In CSimpleApp's Destructor\r\n");
00185
00186         if (m_hStdPal)
00187                 DeleteObject(m_hStdPal);
00188
00189         // need to uninit the library...
00190         if (m_fInitialized)
00191                 OleUninitialize();
00192 }
00193
00194 //**********************************************************************
00195 //
00196 // CSimpleApp::DestroyDocs()
00197 //
00198 // Purpose:
00199 //
00200 //      Destroys all of the open documents in the application (Only one
00201 //      since this is an SDI app, but could easily be modified to
00202 //      support MDI).
00203 //
00204 // Parameters:
00205 //
00206 //      None
00207 //
00208 // Return Value:
00209 //
00210 //      None
00211 //
00212 // Function Calls:
00213 //      Function                    Location
00214 //
00215 // Comments:
00216 //
00217 //********************************************************************
00218
00219 void CSimpleApp::DestroyDocs()
00220 {
00221         CStabilize stabilize(this);
00222         m_lpDoc->Close();   // we have only 1 document
00223 }
00224
00225 //**********************************************************************
00226 //
00227 // CSimpleApp::QueryInterface
00228 //
00229 // Purpose:
00230 //
00231 //      Used for interface negotiation at the Frame level.
00232 //
00233 // Parameters:
00234 //
00235 //      REFIID riid         -   A reference to the interface that is
00236 //                              being queried.
00237 //
00238 //      LPVOID FAR* ppvObj  -   An out parameter to return a pointer to
00239 //                              the interface.
00240 //
00241 // Return Value:
00242 //
00243 //      S_OK    -   The interface is supported.
00244 //      S_FALSE -   The interface is not supported
00245 //
00246 // Function Calls:
00247 //      Function                    Location
00248 //
00249 //      OutputDebugString           Windows API
00250 //      IsEqualIID                  OLE API
00251 //                   OLE API
00252 //      COleInPlaceFrame::AddRef    IOIPF.CPP
00253 //
00254 // Comments:
00255 //
00256 //      Note that this QueryInterface is associated with the frame.
00257 //      Since the application could potentially have multiple documents
00258 //      and multiple objects, a lot of the interfaces are ambiguous.
00259 //      (ie. which IOleObject is returned?).  For this reason, only
00260 //      pointers to interfaces associated with the frame are returned.
00261 //      In this implementation, Only IOleInPlaceFrame (or one of the
00262 //      interfaces it is derived from) can be returned.
00263 //
00264 //********************************************************************
00265
00266 STDMETHODIMP CSimpleApp::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00267 {
00268         OutputDebugString("In CSimpleApp::QueryInterface\r\n");
00269
00270         *ppvObj = NULL;     // must set out pointer parameters to NULL
00271
00272         // looking for IUnknown
00273         if ( riid == IID_IUnknown)
00274                 {
00275                 AddRef();
00276                 *ppvObj = this;
00277                 return S_OK;
00278                 }
00279
00280         // looking for IOleWindow
00281         if ( riid == IID_IOleWindow)
00282                 {
00283                 m_OleInPlaceFrame.AddRef();
00284                 *ppvObj=&m_OleInPlaceFrame;
00285                 return S_OK;
00286                 }
00287
00288         // looking for IOleInPlaceUIWindow
00289         if ( riid == IID_IOleInPlaceUIWindow)
00290                 {
00291                 m_OleInPlaceFrame.AddRef();
00292                 *ppvObj=&m_OleInPlaceFrame;
00293                 return S_OK;
00294                 }
00295
00296         // looking for IOleInPlaceFrame
00297         if ( riid == IID_IOleInPlaceFrame)
00298                 {
00299                 m_OleInPlaceFrame.AddRef();
00300                 *ppvObj=&m_OleInPlaceFrame;
00301                 return S_OK;
00302                 }
00303
00304         // Not a supported interface
00305         return E_NOINTERFACE;
00306 }
00307
00308 //**********************************************************************
00309 //
00310 // CSimpleApp::AddRef
00311 //
00312 // Purpose:
00313 //
00314 //      Adds to the reference count at the Application level.
00315 //
00316 // Parameters:
00317 //
00318 //      None
00319 //
00320 // Return Value:
00321 //
00322 //      ULONG   -   The new reference count of the application.
00323 //
00324 // Function Calls:
00325 //      Function                    Location
00326 //
00327 //      OutputDebugString           Windows API
00328 //
00329 // Comments:
00330 //
00331 //      Due to the reference counting model that is used in this
00332 //      implementation, this reference count is the sum of the
00333 //      reference counts on all interfaces of all objects open
00334 //      in the application.
00335 //
00336 //********************************************************************
00337
00338 STDMETHODIMP_(ULONG) CSimpleApp::AddRef()
00339 {
00340         OutputDebugString("In CSimpleApp::AddRef\r\n");
00341         return SafeAddRef();
00342 }
00343
00344 //**********************************************************************
00345 //
00346 // CSimpleApp::Release
00347 //
00348 // Purpose:
00349 //
00350 //      Decrements the reference count at this level
00351 //
00352 // Parameters:
00353 //
00354 //      None
00355 //
00356 // Return Value:
00357 //
00358 //      ULONG   -   The new reference count of the application.
00359 //
00360 // Function Calls:
00361 //      Function                    Location
00362 //
00363 //      OutputDebugString           Windows API
00364 //
00365 // Comments:
00366 //
00367 //********************************************************************
00368
00369 STDMETHODIMP_(ULONG) CSimpleApp::Release()
00370 {
00371         OutputDebugString("In CSimpleApp::Release\r\n");
00372
00373         return SafeRelease();
00374 }
00375
00376 //**********************************************************************
00377 //
00378 // CSimpleApp::fInitApplication
00379 //
00380 // Purpose:
00381 //
00382 //      Initializes the application
00383 //
00384 // Parameters:
00385 //
00386 //      HANDLE hInstance    -   Instance handle of the application.
00387 //
00388 // Return Value:
00389 //
00390 //      TRUE    -   Application was successfully initialized.
00391 //      FALSE   -   Application could not be initialized
00392 //
00393 // Function Calls:
00394 //      Function                    Location
00395 //
00396 //      LoadIcon                    Windows API
00397 //      LoadCursor                  Windows API
00398 //      GetStockObject              Windows API
00399 //      RegisterClass               Windows API
00400 //
00401 // Comments:
00402 //
00403 //********************************************************************
00404
00405 BOOL CSimpleApp::fInitApplication(HANDLE hInstance)
00406 {
00407         WNDCLASS  wc;
00408
00409         // Fill in window class structure with parameters that describe the
00410         // main window.
00411
00412         wc.style = NULL;                    // Class style(s).
00413         wc.lpfnWndProc = MainWndProc;       // Function to retrieve messages for
00414                                                                                 // windows of this class.
00415         wc.cbClsExtra = 0;                  // No per-class extra data.
00416         wc.cbWndExtra = 0;                  // No per-window extra data.
00417         wc.hInstance = (HINSTANCE) hInstance; // Application that owns the class.
00418         wc.hIcon = LoadIcon((HINSTANCE) hInstance, "SimpCntr");
00419         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00420         wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00421         wc.lpszMenuName =  "SIMPLEMENU";    // Name of menu resource in .RC file.
00422         wc.lpszClassName = "SimpCntrAppWClass";  // Name used in CreateWindow call
00423
00424         if (!RegisterClass(&wc))
00425                 return FALSE;
00426
00427         wc.style = CS_DBLCLKS;              // Class style(s). allow DBLCLK's
00428         wc.lpfnWndProc = DocWndProc;        // Function to retrieve messages for
00429                                                                                 // windows of this class.
00430         wc.cbClsExtra = 0;                  // No per-class extra data.
00431         wc.cbWndExtra = 0;                  // No per-window extra data.
00432         wc.hInstance = (HINSTANCE) hInstance;           // Application that owns the class.
00433         wc.hIcon = NULL;
00434         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00435         wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00436         wc.lpszMenuName =  NULL;
00437         wc.lpszClassName = "SimpCntrDocWClass"; // Name used in CreateWindow call.
00438
00439         // Register the window class and return success/failure code.
00440
00441         return (RegisterClass(&wc));
00442 }
00443
00444 //**********************************************************************
00445 //
00446 // CSimpleApp::fInitInstance
00447 //
00448 // Purpose:
00449 //
00450 //      Instance initialization.
00451 //
00452 // Parameters:
00453 //
00454 //      HANDLE hInstance    -   App. Instance Handle.
00455 //
00456 //      int nCmdShow        -   Show parameter from WinMain
00457 //
00458 // Return Value:
00459 //
00460 //      TRUE    -   Initialization Successful
00461 //      FALSE   -   Initialization Failed.
00462 //
00463 //
00464 // Function Calls:
00465 //      Function                    Location
00466 //
00467 //      CreateWindow                Windows API
00468 //      ShowWindow                  Windows API
00469 //      UpdateWindow                Windows API
00470 //      OleBuildVersion             OLE API
00471 //      OleInitialize               OLE API
00472 //
00473 // Comments:
00474 //
00475 //      Note that successful Initalization of the OLE libraries
00476 //      is remembered so the UnInit is only called if needed.
00477 //
00478 //********************************************************************
00479
00480 BOOL CSimpleApp::fInitInstance (HANDLE hInstance, int nCmdShow)
00481 {
00482         DWORD dwVer = OleBuildVersion();
00483         LPMALLOC lpMalloc = NULL;
00484
00485         // check to see if we are compatible with this version of the libraries
00486         if (HIWORD(dwVer) != rmm || LOWORD(dwVer) < rup) {
00487 #ifdef _DEBUG
00488                 OutputDebugString("WARNING: Incompatible OLE library version\r\n");
00489 #else
00490                 return FALSE;
00491 #endif
00492         }
00493
00494         if (SUCCEEDED(OleInitialize(lpMalloc)))
00495         {
00496                 m_fInitialized = TRUE;
00497         }
00498         else
00499         {
00500             // Replacing the standard allocator may not be legal.
00501             // Try again using the default allocator.
00502             if (SUCCEEDED(OleInitialize(NULL)))
00503             {
00504                 m_fInitialized = TRUE;
00505             }
00506         }
00507
00508         m_hInst = (HINSTANCE) hInstance;
00509
00510         // Create the "application" windows
00511         m_hAppWnd = CreateWindow ("SimpCntrAppWClass",
00512                                                           "Simple OLE 2.0 In-Place Container",
00513                                                           WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
00514                                                           CW_USEDEFAULT,
00515                                                           CW_USEDEFAULT,
00516                                                           CW_USEDEFAULT,
00517                                                           CW_USEDEFAULT,
00518                                                           NULL,
00519                                                           NULL,
00520                                                           (HINSTANCE) hInstance,
00521                                                           NULL);
00522
00523         if (!m_hAppWnd)
00524                 return FALSE;
00525
00526         m_hStdPal = CreateStandardPalette();
00527
00528         ShowWindow (m_hAppWnd, nCmdShow);
00529         UpdateWindow (m_hAppWnd);
00530
00531         return m_fInitialized;
00532 }
00533
00534 //**********************************************************************
00535 //
00536 // CSimpleApp::lCommandHandler
00537 //
00538 // Purpose:
00539 //
00540 //      Handles the processing of WM_COMMAND.
00541 //
00542 // Parameters:
00543 //
00544 //      HWND hWnd       -   Handle to the application Window
00545 //
00546 //      UINT message    -   message (always WM_COMMAND)
00547 //
00548 //      WPARAM wParam   -   Same as passed to the WndProc
00549 //
00550 //      LPARAM lParam   -   Same as passed to the WndProc
00551 //
00552 // Return Value:
00553 //
00554 //      NULL
00555 //
00556 // Function Calls:
00557 //      Function                                    Location
00558 //
00559 //      IOleInPlaceActiveObject::QueryInterface     Object
00560 //      IOleInPlaceObject::ContextSensitiveHelp     Object
00561 //      IOleInPlaceObject::Release                  Object
00562 //      IOleObject::DoVerb                          Object
00563 //      GetClientRect                               Windows API
00564 //      MessageBox                                  Windows API
00565 //      DialogBox                                   Windows API
00566 //      MakeProcInstance                            Windows API
00567 //      FreeProcInstance                            Windows API
00568 //      SendMessage                                 Windows API
00569 //      DefWindowProc                               Windows API
00570 //      CSimpleDoc::InsertObject                    DOC.CPP
00571 //
00572 // Comments:
00573 //
00574 //********************************************************************
00575
00576 long CSimpleApp::lCommandHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00577 {
00578         CStabilize stabilize(this);
00579         RECT rect;
00580
00581         // context sensitive help...
00582         if (m_fMenuMode || m_fCSHMode)
00583                 {
00584                 if (m_fCSHMode)
00585                         {
00586                         // clear context sensitive help flag
00587                         m_fCSHMode = FALSE;
00588
00589                         // if there is an InPlace active object, call its context sensitive help
00590                         // method with the FALSE parameter to bring the object out of the
00591                         // csh state.  See the technotes for details.
00592                         if (m_lpDoc->m_lpActiveObject)
00593                                 {
00594                                 LPOLEINPLACEOBJECT lpInPlaceObject;
00595                                 m_lpDoc->m_lpActiveObject->QueryInterface(IID_IOleInPlaceObject, (LPVOID FAR *)&lpInPlaceObject);
00596                                 lpInPlaceObject->ContextSensitiveHelp(FALSE);
00597                                 lpInPlaceObject->Release();
00598                                 }
00599                         }
00600
00601                 // see the technotes for details on implementing context sensitive
00602                 // help
00603                 if (m_fMenuMode)
00604                         {
00605                         m_fMenuMode = FALSE;
00606
00607                         if (m_lpDoc->m_lpActiveObject)
00608                                 m_lpDoc->m_lpActiveObject->ContextSensitiveHelp(FALSE);
00609                         }
00610                 // if we provided help, we would do it here...
00611                 MessageBox (hWnd, "Help", "Help", MB_OK);
00612
00613                 return NULL;
00614                 }
00615
00616         // see if the command is a verb selections
00617         //@@WTK WIN32, UNICODE
00618         //if (wParam >= IDM_VERB0)
00619         if (LOWORD(wParam) >= IDM_VERB0)
00620                 {
00621                 // get the rectangle of the object
00622                 m_lpDoc->m_lpSite->GetObjRect(&rect);
00623
00624                 //@@WTK WIN32, UNICODE
00625                 //m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(wParam - IDM_VERB0, NULL, &m_lpDoc->m_lpSite->m_OleClientSite, -1, m_lpDoc->m_hDocWnd, &rect);
00626                 m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(LOWORD(wParam) - IDM_VERB0, NULL,
00627                                 &m_lpDoc->m_lpSite->m_OleClientSite, -1, m_lpDoc->m_hDocWnd, &rect);
00628                 }
00629         else
00630                 {
00631                 //@@WTK WIN32, UNICODE
00632                 //switch (wParam) {
00633                 switch (LOWORD(wParam)) {
00634                         // bring up the About box
00635                         case IDM_ABOUT:
00636                                 {
00637
00638                                 DialogBox(m_hInst,               // current instance
00639                                         "AboutBox",                  // resource to use
00640                                         m_hAppWnd,                   // parent handle
00641                                         (DLGPROC) About);                // About() instance address
00642
00643                                 break;
00644                                 }
00645
00646                         // bring up the InsertObject Dialog
00647                         case IDM_INSERTOBJECT:
00648                                 m_lpDoc->InsertObject();
00649                                 break;
00650
00651                         // exit the application
00652                         case IDM_EXIT:
00653                                 SendMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
00654                                 break;
00655
00656                         case IDM_NEW:
00657                                 m_lpDoc->Close();
00658                                 m_lpDoc = NULL;
00659                                 lCreateDoc(hWnd, 0, 0, 0);
00660                                 break;
00661
00662                         default:
00663                                 return (DefWindowProc(hWnd, message, wParam, lParam));
00664                         }   // end of switch
00665                 }  // end of else
00666         return NULL;
00667 }
00668
00669 //**********************************************************************
00670 //
00671 // CSimpleApp::lSizeHandler
00672 //
00673 // Purpose:
00674 //
00675 //      Handles the WM_SIZE message
00676 //
00677 // Parameters:
00678 //
00679 //      HWND hWnd       -   Handle to the application Window
00680 //
00681 //      UINT message    -   message (always WM_SIZE)
00682 //
00683 //      WPARAM wParam   -   Same as passed to the WndProc
00684 //
00685 //      LPARAM lParam   -   Same as passed to the WndProc
00686 //
00687 // Return Value:
00688 //
00689 //      LONG    -   returned from the "document" resizing
00690 //
00691 // Function Calls:
00692 //      Function                    Location
00693 //
00694 //      GetClientRect               Windows API
00695 //      CSimpleDoc::lResizeDoc      DOC.CPP
00696 //
00697 // Comments:
00698 //
00699 //********************************************************************
00700
00701 long CSimpleApp::lSizeHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00702 {
00703         CStabilize stabilize(this);
00704         RECT rect;
00705
00706         GetClientRect(m_hAppWnd, &rect);
00707         return m_lpDoc->lResizeDoc(&rect);
00708 }
00709
00710 //**********************************************************************
00711 //
00712 // CSimpleApp::lCreateDoc
00713 //
00714 // Purpose:
00715 //
00716 //      Handles the creation of a document.
00717 //
00718 // Parameters:
00719 //
00720 //      HWND hWnd       -   Handle to the application Window
00721 //
00722 //      UINT message    -   message (always WM_CREATE)
00723 //
00724 //      WPARAM wParam   -   Same as passed to the WndProc
00725 //
00726 //      LPARAM lParam   -   Same as passed to the WndProc
00727 //
00728 // Return Value:
00729 //
00730 //      NULL
00731 //
00732 // Function Calls:
00733 //      Function                    Location
00734 //
00735 //      GetClientRect               Windows API
00736 //      CSimpleDoc::CSimpleDoc      DOC.CPP
00737 //
00738 // Comments:
00739 //
00740 //********************************************************************
00741
00742 long CSimpleApp::lCreateDoc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00743 {
00744         CStabilize stabilize(this);
00745         RECT rect;
00746
00747         GetClientRect(hWnd, &rect);
00748
00749         m_lpDoc = CSimpleDoc::Create(this, &rect, hWnd);
00750
00751         return NULL;
00752 }
00753
00754 //**********************************************************************
00755 //
00756 // CSimpleApp::AddFrameLevelUI
00757 //
00758 // Purpose:
00759 //
00760 //      Used during InPlace negotiation.
00761 //
00762 // Parameters:
00763 //
00764 //      None
00765 //
00766 // Return Value:
00767 //
00768 //      None
00769 //
00770 // Function Calls:
00771 //      Function                            Location
00772 //
00773 //      COleInPlaceFrame::SetMenu           IOIPF.CPP
00774 //      CSimpleApp::AddFrameLevelTools      APP.CPP
00775 //
00776 // Comments:
00777 //
00778 //      Be sure to read the Technotes included in the OLE 2.0 toolkit
00779 //
00780 //********************************************************************
00781
00782 void CSimpleApp::AddFrameLevelUI()
00783 {
00784         CStabilize stabilize(this);
00785         m_OleInPlaceFrame.SetMenu(NULL, NULL, NULL);
00786         AddFrameLevelTools();
00787 }
00788
00789 //**********************************************************************
00790 //
00791 // CSimpleApp::AddFrameLevelTools
00792 //
00793 // Purpose:
00794 //
00795 //      Used during InPlace negotiation.
00796 //
00797 // Parameters:
00798 //
00799 //      None
00800 //
00801 // Return Value:
00802 //
00803 //      None
00804 //
00805 // Function Calls:
00806 //      Function                              Location
00807 //
00808 //      COleInPlaceFrame::SetBorderSpace      IOIPF.CPP
00809 //      InvalidateRect                        Windows API
00810 //
00811 // Comments:
00812 //
00813 //      Be sure to read the Technotes included in the OLE 2.0 toolkit
00814 //
00815 //********************************************************************
00816
00817 void CSimpleApp::AddFrameLevelTools()
00818 {
00819         CStabilize stabilize(this);
00820         m_OleInPlaceFrame.SetBorderSpace(&nullRect);
00821         InvalidateRect(m_hAppWnd, NULL, TRUE);
00822 }
00823
00824 //**********************************************************************
00825 //
00826 // CSimpleApp::HandleAccelerators
00827 //
00828 // Purpose:
00829 //
00830 //      To properly handle accelerators in the Message Loop
00831 //
00832 // Parameters:
00833 //
00834 //      LPMSG lpMsg -   A pointer to the message structure.
00835 //
00836 // Return Value:
00837 //
00838 //      TRUE    -   The accelerator was handled
00839 //      FALSE   -   The accelerator was not handled
00840 //
00841 // Function Calls:
00842 //      Function                                        Location
00843 //
00844 //      IOleInPlaceActiveObject::TranslateAccelerator   Object
00845 //
00846 // Comments:
00847 //
00848 //      If an object is InPlace active, it gets the first shot at
00849 //      handling the accelerators.
00850 //
00851 //********************************************************************
00852
00853 BOOL CSimpleApp::HandleAccelerators(LPMSG lpMsg)
00854 {
00855         CStabilize stabilize(this);
00856         HRESULT hResult;
00857         BOOL retval = FALSE;
00858
00859         // if we have an InPlace Active Object
00860         if (m_lpDoc->m_lpActiveObject)
00861                 {
00862                 // Pass the accelerator on...
00863                 hResult = m_lpDoc->m_lpActiveObject->TranslateAccelerator(lpMsg);
00864                 if (hResult == NOERROR)
00865                         retval = TRUE;
00866                 }
00867
00868         return retval;
00869 }
00870
00871 //**********************************************************************
00872 //
00873 // CSimpleApp::PaintApp
00874 //
00875 // Purpose:
00876 //
00877 //      Handles the painting of the doc window.
00878 //
00879 //
00880 // Parameters:
00881 //
00882 //      HDC hDC -   hDC to the Doc Window.
00883 //
00884 // Return Value:
00885 //
00886 //      None
00887 //
00888 // Function Calls:
00889 //      Function                    Location
00890 //
00891 //      CSimpleDoc::PaintDoc        DOC.CPP
00892 //
00893 // Comments:
00894 //
00895 //      This is an app level function in case we want to do palette
00896 //      management.
00897 //
00898 //********************************************************************
00899
00900 void CSimpleApp::PaintApp (HDC hDC)
00901 {
00902         CStabilize stabilize(this);
00903         // at this level, we could enumerate through all of the
00904         // visible objects in the application, so that a palette
00905         // that best fits all of the objects can be built.
00906
00907         // This app is designed to take on the same palette
00908         // functionality that was provided in OLE 1.0, the palette
00909         // of the last object drawn is realized.  Since we only
00910         // support one object at a time, it shouldn't be a big
00911         // deal.
00912
00913         // if we supported multiple documents, we would enumerate
00914         // through each of the open documents and call paint.
00915
00916         if (m_lpDoc)
00917                 m_lpDoc->PaintDoc(hDC);
00918
00919 }
00920
00921 //**********************************************************************
00922 //
00923 // CSimpleApp::ContextSensitiveHelp
00924 //
00925 // Purpose:
00926 //      Used in supporting context sensitive haelp at the app level.
00927 //
00928 //
00929 // Parameters:
00930 //
00931 //      BOOL fEnterMode    -   Entering/Exiting Context Sensitive
00932 //                             help mode.
00933 //
00934 // Return Value:
00935 //
00936 //      None
00937 //
00938 // Function Calls:
00939 //      Function                                    Location
00940 //
00941 //      IOleInPlaceActiveObject::QueryInterface     Object
00942 //      IOleInPlaceObject::ContextSensitiveHelp     Object
00943 //      IOleInPlaceObject::Release                  Object
00944 //
00945 // Comments:
00946 //
00947 //      This function isn't used because we don't support Shift+F1
00948 //      context sensitive help.  Be sure to look at the technotes
00949 //      in the OLE 2.0 toolkit.
00950 //
00951 //********************************************************************
00952
00953 void CSimpleApp::ContextSensitiveHelp (BOOL fEnterMode)
00954 {
00955         CStabilize stabilize(this);
00956         if (m_fCSHMode != fEnterMode)
00957                 {
00958                 m_fCSHMode = fEnterMode;
00959
00960                 // this code "trickles" the context sensitive help via shift+f1
00961                 // to the inplace active object.  See the technotes for implementation
00962                 // details.
00963                 if (m_lpDoc->m_lpActiveObject)
00964                         {
00965                         LPOLEINPLACEOBJECT lpInPlaceObject;
00966                         m_lpDoc->m_lpActiveObject->QueryInterface(IID_IOleInPlaceObject, (LPVOID FAR *)&lpInPlaceObject);
00967                         lpInPlaceObject->ContextSensitiveHelp(fEnterMode);
00968                         lpInPlaceObject->Release();
00969                         }
00970                 }
00971 }
00972
00973
00974 /* OLE2NOTE: forward the WM_QUERYNEWPALETTE message (via
00975 **    SendMessage) to UIActive in-place object if there is one.
00976 **    this gives the UIActive object the opportunity to select
00977 **    and realize its color palette as the FOREGROUND palette.
00978 **    this is optional for in-place containers. if a container
00979 **    prefers to force its color palette as the foreground
00980 **    palette then it should NOT forward the this message. or
00981 **    the container can give the UIActive object priority; if
00982 **    the UIActive object returns 0 from the WM_QUERYNEWPALETTE
00983 **    message (ie. it did not realize its own palette), then
00984 **    the container can realize its palette.
00985 **    (see ContainerDoc_ForwardPaletteChangedMsg for more info)
00986 **
00987 **    (It is a good idea for containers to use the standard
00988 **    palette even if they do not use colors themselves. this
00989 **    will allow embedded object to get a good distribution of
00990 **    colors when they are being drawn by the container)
00991 **
00992 */
00993
00994 LRESULT CSimpleApp::QueryNewPalette(void)
00995 {
00996         if (m_hwndUIActiveObj) {
00997                 if (SendMessage(m_hwndUIActiveObj, WM_QUERYNEWPALETTE,
00998                                 (WPARAM)0, (LPARAM)0)) {
00999                         /* Object selected its palette as foreground palette */
01000                         return (LRESULT)1;
01001                 }
01002         }
01003
01004         return wSelectPalette(m_hAppWnd, m_hStdPal, FALSE/*fBackground*/);
01005 }
01006
01007
01008 /* This is just a helper routine */
01009
01010 LRESULT wSelectPalette(HWND hWnd, HPALETTE hPal, BOOL fBackground)
01011 {
01012         HDC hdc;
01013         HPALETTE hOldPal;
01014         UINT iPalChg = 0;
01015
01016         if (hPal == 0)
01017                 return (LRESULT)0;
01018
01019         hdc = GetDC(hWnd);
01020         hOldPal = SelectPalette(hdc, hPal, fBackground);
01021         iPalChg = RealizePalette(hdc);
01022         SelectPalette(hdc, hOldPal, TRUE /*fBackground*/);
01023         ReleaseDC(hWnd, hdc);
01024
01025         if (iPalChg > 0)
01026                 InvalidateRect(hWnd, NULL, TRUE);
01027
01028         return (LRESULT)1;
01029 }
01030
01031
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/about.h Source File

  • SysMgmt
  • MMC
  • Extens

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/registry.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

registry.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include <ObjBase.h>
00016 #include "Registry.h"
00017 #include "Globals.h"
00018
00019
00020 /////////////////////////////////////////////////////////////////////////////
00021 // Internal helper functions prototypes
00022
00023
00024 // Set the given key and its value.
00025 HRESULT SetKeyAndValue( const TCHAR* pszPath, const TCHAR* szSubkey, const TCHAR* szValue);
00026
00027 // Set the given key and its value in the MMC Snapin location
00028 HRESULT SetSnapInKeyAndValue( const TCHAR* szKey, const TCHAR* szSubkey, const TCHAR* szName, const TCHAR* szValue );
00029
00030 // Set the given valuename under the key to value
00031 HRESULT SetValue( const TCHAR* szKey, const TCHAR* szValueName, const TCHAR* szValue);
00032
00033 // Delete szKeyChild and all of its descendents.
00034 HRESULT RecursiveDeleteKey( HKEY hKeyParent, const TCHAR* szKeyChild );
00035
00036
00037 /////////////////////////////////////////////////////////////////////////////
00038 // Public function implementation
00039
00040
00041 //---------------------------------------------------------------------------
00042 // Register the component in the registry.
00043 //
00044 HRESULT RegisterServer
00045 (
00046   HMODULE        hModule,          //[in] DLL module handle
00047   const CLSID&   clsid,            //[in] Class ID
00048   const TCHAR*   szFriendlyName    //[in] Name string
00049 )
00050 {
00051   // Get server location.
00052   TCHAR szModule[512] ;
00053   DWORD dwResult = ::GetModuleFileName( hModule,
00054                                         szModule,
00055                                         sizeof(szModule)/sizeof(TCHAR)
00056                                       );
00057   if( 0 == dwResult ) return HRESULT_FROM_WIN32( dwResult );
00058
00059   // Get CLSID string in wide char
00060   LPOLESTR wszCLSID = NULL ;
00061   HRESULT hResult = StringFromCLSID( clsid, &wszCLSID ) ;
00062   if( S_OK != hResult )
00063   {
00064     CoTaskMemFree( wszCLSID );
00065     return hResult;
00066   }
00067
00068   TCHAR* pszCLSID = NULL;
00069   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00070   CoTaskMemFree( wszCLSID );           // Through with wide version
00071
00072   TCHAR szKey[64];                     // Build the CLSID key string CLSID\\{...}
00073   _tcscpy( szKey, _T("CLSID\\") );
00074   _tcscat( szKey, pszCLSID );
00075   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00076
00077   // Add the CLSID to the registry.
00078   SetKeyAndValue( szKey, NULL, szFriendlyName );
00079
00080   // Add the server filename subkey under the CLSID key.
00081   SetKeyAndValue( szKey, _T("InprocServer32"), szModule );
00082
00083   // Set the threading model
00084   _tcscat( szKey, _T("\\InprocServer32") );
00085   SetValue( szKey, _T("ThreadingModel"), _T("Apartment") );
00086
00087   return S_OK ;
00088 }
00089
00090
00091 //---------------------------------------------------------------------------
00092 // Remove the component from the registry.
00093 //
00094 LONG UnregisterServer
00095 (
00096   const CLSID& clsid         //[in] Class ID of component to remove
00097 )
00098 {
00099   HRESULT hResult = S_OK;
00100
00101   // Allocate the CLSID string
00102   LPOLESTR wszCLSID = NULL ;
00103   hResult = StringFromCLSID( clsid, &wszCLSID );
00104   if( S_OK != hResult )
00105   {
00106     CoTaskMemFree( wszCLSID );
00107     return hResult;
00108   }
00109
00110   // Build the key CLSID\\{...}
00111   TCHAR szKey[64];
00112   _tcscpy( szKey, _T("CLSID\\") );
00113
00114   TCHAR* pszCLSID = NULL;
00115   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00116   CoTaskMemFree( wszCLSID );           // Through with wide version
00117
00118   _tcscat( szKey, pszCLSID );
00119   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00120
00121   // Delete the CLSID Key - CLSID\{...}
00122   LONG lResult = RecursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );
00123   if( ERROR_SUCCESS != lResult )
00124     hResult = HRESULT_FROM_WIN32( lResult );
00125
00126   return hResult;
00127 }
00128
00129 //---------------------------------------------------------------------------
00130 // Register the snap-in in the registry.
00131 //
00132 HRESULT RegisterSnapin
00133 (
00134   const  CLSID&  clsid,              //[in] Class ID
00135   const  TCHAR*  szNameString,       //[in] NameString
00136   const  CLSID&  clsidAbout,         //[in] Class Id for About Class
00137   const  BOOL    bSupportExtensions  //[in] TRUE if we support extensions
00138 )
00139 {
00140   HRESULT hResult = S_FALSE;
00141   TCHAR*  pszSnapCLSID = NULL;         // Needed for TCHAR version of the ClassID
00142
00143   // If any part of this process fails, jump out of the loop and return
00144   // the error code
00145   do
00146   {
00147     // Allocate the CLSID string
00148     LPOLESTR wszSnapCLSID  = NULL ;
00149     hResult = StringFromCLSID( clsid, &wszSnapCLSID ) ;
00150     if( S_OK != hResult )
00151     {
00152        CoTaskMemFree( wszSnapCLSID );
00153        continue;
00154     }
00155
00156     W2T( &pszSnapCLSID, wszSnapCLSID );  // W2T is defined in Globals.h
00157     CoTaskMemFree( wszSnapCLSID );       // Through with wide version
00158
00159     // Add the Snap-in's CLSID to the registry
00160     hResult = SetSnapInKeyAndValue( pszSnapCLSID, NULL, _T("NameString"), szNameString );
00161     BREAK_ON_ERROR( hResult );
00162
00163     hResult = SetSnapInKeyAndValue( pszSnapCLSID, _T("StandAlone"), NULL, NULL );
00164     BREAK_ON_ERROR( hResult );
00165
00166     // Add registry information for ISnapinAbout if we support it
00167     LPOLESTR wszAboutCLSID = NULL;
00168     TCHAR*   pszAboutCLSID = NULL;
00169     if( IID_NULL != clsidAbout )
00170     {
00171       hResult = StringFromCLSID( clsidAbout, &wszAboutCLSID );
00172       if( S_OK != hResult )
00173       {
00174         CoTaskMemFree( wszAboutCLSID ); // Free this memory before exiting
00175         continue;
00176       }
00177
00178       W2T( &pszAboutCLSID, wszAboutCLSID );
00179       hResult = SetSnapInKeyAndValue( pszAboutCLSID, NULL, _T("About"), pszAboutCLSID );
00180       CoTaskMemFree( wszAboutCLSID );
00181       CoTaskMemFree( pszAboutCLSID );
00182       BREAK_ON_ERROR( hResult );
00183    }
00184
00185     if( TRUE == bSupportExtensions )     // Build the NodeTypesKey
00186     {
00187       hResult = SetSnapInKeyAndValue( pszSnapCLSID, _T("NodeTypes"), NULL, NULL );
00188       BREAK_ON_ERROR( hResult );
00189       TCHAR szKey[64];
00190       _tcscpy( szKey, pszSnapCLSID );
00191       _tcscat(szKey, _T("\\NodeTypes"));
00192       hResult = SetSnapInKeyAndValue( szKey, pszSnapCLSID, NULL, NULL );
00193       BREAK_ON_ERROR( hResult );
00194     }
00195   }while( 0 );
00196
00197   CoTaskMemFree( pszSnapCLSID);
00198   return hResult;
00199 }
00200
00201
00202 //---------------------------------------------------------------------------
00203 // Unregister the snap-in in the registry.
00204 //
00205 HRESULT UnregisterSnapin
00206 (
00207   const CLSID& clsid         //[in] Class ID of object to unregister
00208 )
00209 {
00210   HRESULT hResult = S_OK;
00211
00212   TCHAR    szKeyBuf[1024];
00213   LPOLESTR wszCLSID = NULL;
00214   TCHAR*   pszCLSID = NULL;        // Needed for TCHAR version of the ClassID
00215
00216   // Get CLSID as a wide string
00217   hResult = StringFromCLSID( clsid, &wszCLSID );
00218   if( S_OK != hResult )
00219   {
00220     CoTaskMemFree( wszCLSID );
00221     return hResult;
00222   }
00223
00224   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00225   CoTaskMemFree( wszCLSID );           // Through with wide version
00226
00227   // Load the buffer with the Snap-In Location
00228   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00229
00230   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00231   _tcscat( szKeyBuf, pszCLSID );
00232
00233   // Delete the CLSID Key - CLSID\{...}
00234   LONG lResult = RecursiveDeleteKey( HKEY_LOCAL_MACHINE, szKeyBuf );
00235   if( ERROR_SUCCESS != lResult )
00236     hResult = HRESULT_FROM_WIN32( lResult );
00237
00238   CoTaskMemFree( pszCLSID );
00239   return hResult;
00240 }
00241
00242 //---------------------------------------------------------------------------
00243 // Delete a key and all of its descendents.
00244 //
00245 HRESULT RecursiveDeleteKey
00246 (
00247   HKEY          hKeyParent,    //[in] Parent of key to delete
00248   const TCHAR*  lpszKeyChild   //[in] Key to delete
00249 )
00250 {
00251   // Open the child.
00252   HKEY hKeyChild = NULL;
00253   LONG lResult   = ERROR_SUCCESS;
00254
00255   do                     // We go to all this trouble to prevent any
00256   {                      // possibility of exiting while leaving a key open
00257
00258     lResult = RegOpenKeyEx( hKeyParent,
00259                             lpszKeyChild,
00260                             0,
00261                             KEY_ALL_ACCESS,
00262                             &hKeyChild
00263                           );
00264     if( ERROR_SUCCESS != lResult )
00265       continue;
00266
00267     // Enumerate all of the decendents of this child.
00268     FILETIME time;
00269     _TCHAR szBuffer[256];
00270     DWORD dwSize = 256;
00271     while( S_OK == RegEnumKeyEx(hKeyChild,0,szBuffer,&dwSize,NULL,NULL,NULL,&time) )
00272     {
00273       // Delete the decendents of this child.
00274       lResult = RecursiveDeleteKey( hKeyChild, szBuffer );
00275       if( ERROR_SUCCESS != lResult )
00276       {
00277         continue;
00278       }
00279       dwSize = 256 ;
00280     }
00281   }while( 0 );
00282
00283   RegCloseKey( hKeyChild );            // Always try to close the child
00284                                        // then delete this child.
00285   return RegDeleteKey( hKeyParent, lpszKeyChild );
00286 }
00287
00288 //---------------------------------------------------------------------------
00289 // Create a Registry Key and set its value.
00290 //   - This helper function was borrowed and modifed from
00291 //     Kraig Brockschmidt's book Inside OLE.
00292 //
00293 HRESULT SetKeyAndValue
00294 (
00295   const TCHAR*  szKey,       //[in] Parent key
00296   const TCHAR*  szSubkey,    //[in] Child key
00297   const TCHAR*  szValue      //[in] Value to set
00298 )
00299 {
00300   HKEY hKey = NULL;
00301   HRESULT hResult = S_FALSE;
00302   TCHAR szKeyBuf[1024];
00303
00304   // Copy keyname into buffer.
00305   _tcscpy( szKeyBuf, szKey );
00306
00307   // Add subkey name to buffer.
00308   if( NULL != szSubkey )
00309   {
00310     _tcscat( szKeyBuf, _T("\\") );
00311     _tcscat( szKeyBuf, szSubkey );
00312   }
00313
00314   do                     // We go to all this trouble to prevent any
00315   {                      // possibility of exiting while leaving a key open
00316
00317     // Create and open key and subkey.
00318     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT,
00319                                    szKeyBuf,
00320                                    0,
00321                                    NULL,
00322                                    REG_OPTION_NON_VOLATILE,
00323                                    KEY_ALL_ACCESS,
00324                                    NULL,
00325                                    &hKey,
00326                                    NULL
00327                                  );
00328     if( ERROR_SUCCESS != lResult )
00329     {
00330       hResult = HRESULT_FROM_WIN32( lResult );
00331       continue;
00332     }
00333
00334     if( NULL != szValue )    // Now set the value
00335     {
00336       hResult = RegSetValueEx( hKey,
00337                                NULL,
00338                                0,
00339                                REG_SZ,
00340                                (BYTE*)szValue,
00341                                BYTE_SIZE( szValue )    // BYTE_SIZE is in Globals.h
00342                              );
00343       BREAK_ON_ERROR( hResult );
00344     }
00345   }while( 0 );
00346
00347   RegCloseKey( hKey );       // Always try to close the key
00348   return hResult;
00349 }
00350
00351
00352 //---------------------------------------------------------------------------
00353 // Open a key value and set it
00354 //
00355 HRESULT SetValue
00356 (
00357   const TCHAR*  szKey,         //[in] Parent key
00358   const TCHAR*  szValueName,   //[in] Name of value
00359   const TCHAR*  szValue        //[in] Value in string format
00360 )
00361 {
00362   HKEY    hKey = NULL;
00363   HRESULT hResult = S_FALSE;
00364   TCHAR szKeyBuf[1024];
00365
00366   // Copy keyname into buffer.
00367   _tcscpy( szKeyBuf, szKey );
00368
00369   do                     // We go to all this trouble to prevent any
00370   {                      // possibility of exiting while leaving a key open
00371
00372     // Create and open key and subkey.
00373     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT ,
00374                                    szKeyBuf,
00375                                    0,
00376                                    NULL,
00377                                    REG_OPTION_NON_VOLATILE,
00378                                    KEY_ALL_ACCESS,
00379                                    NULL,
00380                                    &hKey,
00381                                    NULL
00382                                  );
00383     if( ERROR_SUCCESS != lResult )
00384     {
00385       hResult = HRESULT_FROM_WIN32( lResult );
00386       continue;
00387     }
00388
00389     if( NULL != szValue )    // Now set the value
00390     {
00391       hResult = RegSetValueEx( hKey,
00392                                szValueName,
00393                                0,
00394                                REG_SZ,
00395                                (BYTE*)szValue,
00396                                BYTE_SIZE( szValue )
00397                              );
00398       BREAK_ON_ERROR( hResult );
00399     }
00400   }while( 0 );
00401
00402   RegCloseKey( hKey );       //Always attempt to close the key
00403   return hResult;
00404 }
00405
00406
00407 //---------------------------------------------------------------------------
00408 // Create a key and set its value.
00409 //   - This helper function was borrowed and modifed from
00410 //     Kraig Brockschmidt's book Inside OLE.
00411 //
00412 HRESULT SetSnapInKeyAndValue
00413 (
00414   const TCHAR*  szKey,       //[in] Parent key
00415   const TCHAR*  szSubkey,    //[in] Child key
00416   const TCHAR*  szName,      //[in] Value name
00417   const TCHAR*  szValue      //[in] Value in string format
00418 )
00419 {
00420   HKEY    hKey = NULL;
00421   HRESULT hResult = S_FALSE;
00422   TCHAR  szKeyBuf[1024];
00423
00424   // Load the buffer with the Snap-In Location
00425   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00426
00427   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00428   _tcscat( szKeyBuf, szKey );
00429
00430   if( NULL != szSubkey )               // Add subkey name to buffer.
00431   {
00432     _tcscat( szKeyBuf, _T("\\") );
00433     _tcscat( szKeyBuf, szSubkey );
00434   }
00435
00436   do                     // We go to all this trouble to prevent any
00437   {                      // possibility of exiting while leaving a key open
00438
00439     // Create and open key and subkey.
00440     long lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00441                                    szKeyBuf,
00442                                    0,
00443                                    NULL,
00444                                    REG_OPTION_NON_VOLATILE,
00445                                    KEY_ALL_ACCESS,
00446                                    NULL,
00447                                    &hKey,
00448                                    NULL
00449                                  );
00450     if( ERROR_SUCCESS != lResult )     // Will return S_FALSE
00451       continue;
00452
00453     // Set the Value.
00454     if( szValue != NULL )
00455     {
00456       hResult = RegSetValueEx( hKey,
00457                                szName,
00458                                0,
00459                                REG_SZ,
00460                                (BYTE*)szValue,
00461                                BYTE_SIZE(szValue)
00462                              );
00463       BREAK_ON_ERROR( hResult );
00464     }
00465     else
00466     {                        // If we got this far then everthing
00467       hResult = S_OK;        // must be OK
00468     }
00469   }while( 0 );
00470
00471   RegCloseKey( hKey );       //Always attempt to close the key
00472   return hResult;
00473 }
00474
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/basedialog.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

basedialog.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  BaseDialog.h:  Interface for the CBaseDialog class.  This is the base
00014 //                 class for modeless dialogs.
00015 //
00016
00017
00018 #ifndef _CLASS_BASEDIALOG_
00019 #define _CLASS_BASEDIALOG_
00020
00021 #include <Windows.h>
00022
00023
00024 #if _MSC_VER > 1000
00025 #pragma once
00026 #endif // _MSC_VER > 1000
00027
00028
00029 //---------------------------------------------------------------------------
00030 class CBaseDialog
00031 {
00032   private:
00033     HWND     m_hWnd;         // Handle from CreateDialogParam
00034     ULONG    m_nTemplate;    // Dialog template ID
00035     DLGPROC  m_DlgProc;      // Points to Dialog Proc
00036     DWORD    m_dwFlags;      // Create flags
00037
00038   public:
00039     CBaseDialog( ULONG nTemplate = 0 );
00040     virtual ~CBaseDialog();
00041
00042     virtual HWND Create( HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags = 0 );
00043
00044   protected:
00045     static BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00046
00047     virtual LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00048     virtual LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00049     virtual LRESULT OnCancel( HWND hDlg, WPARAM wParam, LPARAM lParam );
00050     virtual LRESULT OnNcDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam );
00051     virtual LRESULT OnDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam );
00052     virtual LRESULT OnClose( HWND hDlg, WPARAM wParam, LPARAM lParam );
00053
00054   public:
00055     virtual BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) = 0;
00056
00057 };
00058
00059
00060 #endif //_CLASS_BASEDIALOG_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RURASREGROOT Member List

This is the complete list of members for _RURASREGROOT, including all inherited members.
hkRegRoot | _RURASREGROOT
pszName | _RURASREGROOT
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/profile.h Source File

  • Begin
  • sdkdiff

profile.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * utility functions to read and write values to the profile,
00013  * using win.ini for Win16 or HKEY_CURRENT_USER\software\microsoft\sdkdiff\...
00014  * in the registry for Win32
00015  */
00016
00017 #ifndef _PROFILE_REG_H
00018 #define _PROFILE_REG_H
00019
00020 #define MMPROFILECACHE 0  // Set to 1 to cache keys, 0 otherwise
00021 #define USESTRINGSALSO 1
00022
00023 #ifndef _WIN32
00024
00025 #define mmGetProfileIntA(app, value, default) \
00026           GetProfileInt(app, value, default)
00027
00028 #define mmWriteProfileString(appname, valuename, pData) \
00029           WriteProfileString(appname, valuename, pData)
00030
00031 #define mmGetProfileString(appname, valuename, pDefault, pResult, cbResult) \
00032           GetProfileString(appname, valuename, pDefault, pResult, cbResult)
00033
00034 #define CloseKeys()
00035
00036 #else
00037
00038
00039 /*
00040  * read a UINT from the profile, or return default if
00041  * not found.
00042  */
00043 UINT mmGetProfileIntA(LPCSTR appname, LPCSTR valuename, INT uDefault);
00044
00045 /*
00046  * read a string from the profile into pResult.
00047  * result is number of characters written into pResult
00048  */
00049 DWORD mmGetProfileString(LPCTSTR appname, LPCTSTR valuename, LPCTSTR pDefault,
00050                     LPTSTR pResult, int cbResult
00051 );
00052
00053 /*
00054  * write a string/integer to the profile
00055  */
00056 BOOL mmWriteProfileString(LPCTSTR appname, LPCTSTR valuename, LPCTSTR pData);
00057
00058 BOOL mmWriteProfileInt(LPCTSTR appname, LPCTSTR valuename, INT value);
00059
00060 UINT mmGetProfileInt(LPCTSTR appname, LPCTSTR valuename, INT value);
00061
00062 #undef WriteProfileString
00063 #undef GetProfileString
00064 #undef GetProfileInt
00065
00066 #define WriteProfileString  mmWriteProfileString
00067 #define WriteProfileInt     mmWriteProfileInt
00068 #define GetProfileString    mmGetProfileString
00069 #define GetProfileInt       mmGetProfileInt
00070
00071
00072 #if MMPROFILECACHE
00073 VOID CloseKeys(VOID);
00074 #else
00075 #define CloseKeys()
00076 #endif
00077
00078 /*
00079  * convert an Ansi string to Wide characters
00080  */
00081 LPWSTR mmAnsiToWide (
00082    LPWSTR lpwsz,   // out: wide char buffer to convert into
00083    LPCSTR  lpsz,   // in: ansi string to convert from
00084    UINT   nChars); // in: count of characters in each buffer
00085
00086 /*
00087  * convert a Wide char string to Ansi
00088  */
00089 LPSTR mmWideToAnsi (
00090    LPSTR  lpsz,    // out: ansi buffer to convert into
00091    LPCWSTR lpwsz,  // in: wide char buffer to convert from
00092    UINT   nChars); // in: count of characters (not bytes!)
00093
00094 #if !defined NUMELMS
00095  #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
00096 #endif
00097
00098 #endif
00099 #endif // _PROFILE_REG_H
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/MqApiTst.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

MqApiTst.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // MqApitest.h : main header file for the TEST application
00013 //
00014
00015
00016 #ifndef __AFXWIN_H__
00017   #error include 'stdafx.h' before including this file for PCH
00018 #endif
00019
00020 #include "resource.h"       // main symbols
00021
00022 #include "mq.h"
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CTestApp:
00026 // See test.cpp for the implementation of this class
00027 //
00028
00029 class CTestApp : public CWinApp
00030 {
00031 public:
00032   CTestApp();
00033
00034 // Overrides
00035   // ClassWizard generated virtual function overrides
00036   //{{AFX_VIRTUAL(CTestApp)
00037   public:
00038   virtual BOOL InitInstance();
00039   //}}AFX_VIRTUAL
00040
00041 // Implementation
00042
00043   //{{AFX_MSG(CTestApp)
00044   afx_msg void OnAppAbout();
00045     // NOTE - the ClassWizard will add and remove member functions here.
00046     //    DO NOT EDIT what you see in these blocks of generated code !
00047   //}}AFX_MSG
00048   DECLARE_MESSAGE_MAP()
00049 protected:
00050   BOOL IsDsEnabledLocaly();
00051 };
00052
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055
00056 #define MAX_Q_PATHNAME_LEN 4000
00057 #define MAX_Q_FORMATNAME_LEN 4000
00058 #define BUFFERSIZE MAX_Q_FORMATNAME_LEN
00059 //#define BUFFERSIZE 256
00060
00061 #define DEFAULT_M_TIMETOREACHQUEUE -1
00062 #define DEFAULT_M_TIMETOBERECEIVED -1
00063 #define MAX_VAR    20
00064 #define ACCESSBUFFERSIZE 50
00065
00066 //
00067 // A structure for the array of queues that the application handles.
00068 //
00069 class ARRAYQ{
00070 public:
00071   TCHAR szPathName[MAX_Q_PATHNAME_LEN];     // holds the Queue path name.
00072   TCHAR szFormatName[MAX_Q_FORMATNAME_LEN]; // holds the Queue format name.
00073   QUEUEHANDLE hHandle;                         // a handle for an open Queue.
00074   DWORD dwAccess;                              // access for the queue.
00075   BOOL  bFormatNameOnly;            //Is there path name as well, or ARRAYQ instance has only
00076                         //Format Name.
00077   ARRAYQ
00078     (
00079     ):
00080     dwAccess(0),
00081     bFormatNameOnly(0),
00082     hHandle(0)
00083     {
00084       szPathName[0]=0;
00085       szFormatName[0]=0;
00086     }
00087 };
00088
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/EnumMount/EnumMountPoints.c Source File

  • WinBase
  • IO
  • EnumMount

EnumMountPoints.c

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1998 - 2000  Microsoft Corporation.  All rights reserved.
00008
00009
00010 EnumMountPoints.c
00011
00012 This file implements a command line utility that enumerates volumes and
00013 mount points (if any) on each volume.
00014
00015 ----------------------------------------------------------------------------*/
00016
00017 #include <windows.h>
00018 #include <stdio.h>
00019 #include <tchar.h>
00020
00021 static void EnumVolumes();
00022 static void EnumMountPoints(LPTSTR szVolume);
00023 static void PrintMountPoint(LPTSTR szVolume, LPTSTR szMountPoint);
00024 static void PrintDosDeviceNames(LPTSTR szVolume);
00025
00026 void main()
00027 {
00028     EnumVolumes();
00029 }
00030
00031 /*-----------------------------------------------------------------------------
00032 EnumVolumes()
00033
00034 Parameters
00035     None
00036
00037 Return Value
00038     None
00039
00040 Notes
00041     FindFirstVolume/FindNextVolume returns the unique volume name for each.
00042     Since unique volume names aren't very user friendly, PrintDosDeviceNames
00043     prints out the Dos device name(s) that refer to the volume.
00044 -----------------------------------------------------------------------------*/
00045 void EnumVolumes()
00046 {
00047     HANDLE hFindVolume;
00048     TCHAR  szVolumeName[MAX_PATH];
00049
00050     // Find the first unique volume & enumerate it's mount points
00051     hFindVolume = FindFirstVolume(szVolumeName, MAX_PATH);
00052
00053     // If we can't even find one volume, just print an error and return.
00054     if (hFindVolume == INVALID_HANDLE_VALUE)
00055     {
00056         _tprintf(_T("FindFirstVolume failed.  Error = %d\n"), GetLastError());
00057         return;
00058     }
00059
00060     _tprintf(_T("\nUnique vol name: "));
00061     _tprintf(_T("%s\n"), szVolumeName);
00062     PrintDosDeviceNames(szVolumeName);
00063     EnumMountPoints(szVolumeName);
00064
00065     // Find the rest of the unique volumes and enumerate each of their
00066     // mount points.
00067     while (FindNextVolume(hFindVolume, szVolumeName, MAX_PATH))
00068     {
00069         _tprintf(_T("\nUnique vol name: "));
00070         _tprintf(_T("%s\n"), szVolumeName);
00071         PrintDosDeviceNames(szVolumeName);
00072         EnumMountPoints(szVolumeName);
00073     }
00074
00075     FindVolumeClose(hFindVolume);
00076 }
00077
00078 /*-----------------------------------------------------------------------------
00079 EnumMountPoints(LPTSTR szVolume)
00080
00081 Parameters
00082     szVolume
00083         Unique volume name of the volume to enumerate mount points for.
00084
00085 Return Value
00086     None
00087
00088 Notes
00089     Enumerates and prints the volume mount points (if any) for the unique
00090     volume name passed in.
00091 -----------------------------------------------------------------------------*/
00092 void EnumMountPoints(LPTSTR szVolume)
00093 {
00094     HANDLE hFindMountPoint;
00095     TCHAR  szMountPoint[MAX_PATH];
00096
00097
00098     // Find and print the first mount point.
00099     hFindMountPoint = FindFirstVolumeMountPoint(szVolume, szMountPoint, MAX_PATH);
00100
00101     // If a mount point was found, print it out, if there is not even
00102     // one mount point, just print "None" and return.
00103     if (hFindMountPoint != INVALID_HANDLE_VALUE)
00104     {
00105         PrintMountPoint(szVolume, szMountPoint);
00106     }
00107     else
00108     {
00109         _tprintf(_T("No mount points.\n"));
00110         return;
00111     }
00112
00113     // Find and print the rest of the mount points
00114     while (FindNextVolumeMountPoint(hFindMountPoint, szMountPoint, MAX_PATH))
00115     {
00116         PrintMountPoint(szVolume, szMountPoint);
00117     }
00118
00119     FindVolumeMountPointClose(hFindMountPoint);
00120 }
00121
00122 /*-----------------------------------------------------------------------------
00123 PrintMountPoint(LPTSTR szVolume, LPTSTR szMountPoint)
00124
00125 Parameters
00126     szVolume
00127         Unique volume name the mount point is located on
00128
00129     szMountPoint
00130         Name of the mount point to print
00131
00132 Return Value
00133     None
00134
00135 Notes
00136     Prints out both the mount point and the unique volume name of the volume
00137     mounted at the mount point.
00138 -----------------------------------------------------------------------------*/
00139 void PrintMountPoint(LPTSTR szVolume, LPTSTR szMountPoint)
00140 {
00141     TCHAR szMountPointPath[MAX_PATH];
00142     TCHAR szVolumeName[MAX_PATH];
00143
00144     _tprintf(_T("  * Mount point: "));
00145
00146     // Print out the mount point
00147     _tprintf(_T("%s\n"), szMountPoint);
00148     _tprintf(_T("                     ...is a mount point for...\n"));
00149
00150     // Append the mount point name to the unique volume name to get the
00151     // complete path name for the mount point
00152     _tcscpy(szMountPointPath, szVolume);
00153     _tcscat(szMountPointPath, szMountPoint);
00154
00155     // Get and print the unique volume name for the volume mounted at the
00156     // mount point
00157     if (!GetVolumeNameForVolumeMountPoint(szMountPointPath, szVolumeName, MAX_PATH))
00158     {
00159         _tprintf(_T("GetVolumeNameForVolumeMountPoint failed.  Error = %d\n"), GetLastError());
00160     }
00161     else
00162     {
00163         _tprintf(_T("                 %s\n"), szVolumeName);
00164     }
00165 }
00166
00167 /*-----------------------------------------------------------------------------
00168 PrintDosDeviceNames(LPTSTR szVolume)
00169
00170 Parameters
00171     szVolume
00172         Unique volume name to get the Dos device names for
00173
00174 Return Value
00175     None
00176
00177 Notes
00178     Prints out the Dos device name(s) for the unique volume name
00179 -----------------------------------------------------------------------------*/
00180 void PrintDosDeviceNames(LPTSTR szVolume)
00181 {
00182     int    nStrLen;
00183     DWORD  dwBuffLen;
00184     LPTSTR szDrive;
00185     LPTSTR szBuffer = NULL;
00186     TCHAR  szVolumeName[MAX_PATH];
00187
00188     // Get all logical drive strings
00189     dwBuffLen = GetLogicalDriveStrings(0, szBuffer);
00190     szBuffer = (LPTSTR)malloc(dwBuffLen*sizeof(TCHAR));
00191     GetLogicalDriveStrings(dwBuffLen, szBuffer);
00192     szDrive = szBuffer;
00193
00194     _tprintf(_T("Dos drive names: "));
00195
00196     nStrLen = (int)_tcslen(szDrive);
00197
00198     // Get the unique volume name for each logical drive string.  If the volume
00199     // drive string matches the passed in volume, print out the Dos drive name
00200     while(nStrLen)
00201     {
00202         if (GetVolumeNameForVolumeMountPoint(szDrive, szVolumeName, MAX_PATH))
00203         {
00204             if (_tcsicmp(szVolume, szVolumeName) == 0)
00205             {
00206                 _tprintf(_T("%s "), szDrive);
00207             }
00208         }
00209         szDrive += nStrLen+1;
00210         nStrLen = (int)_tcslen(szDrive);
00211     }
00212
00213     _tprintf(_T("\n"));
00214     if (szBuffer) free(szBuffer);
00215 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFrame Member List

This is the complete list of members for CFrame, including all inherited members.
Accelerators(void) | CFrame | [inline]
CFrame(HINSTANCE, HINSTANCE, LPSTR, int) | CFrame |
ClientWndProc(HWND, UINT, WPARAM, LPARAM) | CFrame | [friend]
Close() | CFrame |
ContextSensitiveHelp(BOOL) | CFrame |
CreateObject(LPTSTR) | CFrame | [protected]
EnableModeless(BOOL) | CFrame |
Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvaIn, VARIANTARG *pvaOut) | CFrame |
FrameWndProc(HWND, UINT, WPARAM, LPARAM) | CFrame | [friend]
GetBorder(LPRECT) | CFrame |
GetWindow(HWND *) | CFrame |
Init(UINT, int, int, int, int) | CFrame |
InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS) | CFrame |
Instance(void) | CFrame | [inline]
m_bwIP | CFrame | [protected]
m_cRef | CFrame | [protected]
m_dwIDCounter | CFrame | [protected]
m_fHaveObject | CFrame | [protected]
m_fInContextHelp | CFrame | [protected]
m_fInitialized | CFrame | [protected]
m_fInObjectHelp | CFrame | [protected]
m_fOurMenuShowing | CFrame | [protected]
m_fUsingOurHelp | CFrame | [protected]
m_hAccel | CFrame | [protected]
m_hInst | CFrame | [protected]
m_hInstPrev | CFrame | [protected]
m_hMenuHelp | CFrame | [protected]
m_hMenuOrg | CFrame | [protected]
m_hMenuTop | CFrame | [protected]
m_hWnd | CFrame | [protected]
m_hWndClient | CFrame | [protected]
m_hWndObj | CFrame | [protected]
m_nCmdShow | CFrame | [protected]
m_phMenu | CFrame | [protected]
m_pIOleIPActiveObject | CFrame | [protected]
m_pIStorage | CFrame | [protected]
m_pSite | CFrame | [protected]
m_pszCmdLine | CFrame | [protected]
MessageLoop(void) | CFrame |
OnCommand(HWND, WPARAM, LPARAM) | CFrame | [protected]
OpenDialog(LPTSTR, UINT) | CFrame | [protected]
QueryInterface(REFIID, void **) | CFrame |
QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText) | CFrame |
RegisterAllClasses(void) | CFrame | [protected]
RemoveMenus(HMENU) | CFrame |
RequestBorderSpace(LPCBORDERWIDTHS) | CFrame |
ResizeClientWindow(UINT, UINT, UINT, UINT) | CFrame | [protected]
SetActiveObject(LPOLEINPLACEACTIVEOBJECT, LPCOLESTR) | CFrame |
SetBorderSpace(LPCBORDERWIDTHS) | CFrame |
SetMenu(HMENU, HOLEMENU, HWND) | CFrame |
SetStatusText(LPCOLESTR) | CFrame |
STDMETHODIMP_(ULONG) AddRef(void) | CFrame |
STDMETHODIMP_(ULONG) Release(void) | CFrame |
TranslateAccelerator(LPMSG, WORD) | CFrame |
Window(void) | CFrame | [inline]
~CFrame(void) | CFrame |
Generated on Wed Nov 13 2024 16:56:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Snmp/WSnmp/Helper.Cpp Source File

  • NetDS
  • Snmp
  • WSnmp

Helper.Cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005 Module Name: helper.cpp
00006
00007 Abstract:
00008
00009     helper functions used by wsnmputil.cpp.
00010
00011 --*/
00012
00013
00014 #include  <stdio.h>
00015 #include  <string.h>
00016 #include  <stdlib.h>
00017 #include  <winsock2.h>
00018 #include  <winsnmp.h>
00019 #include  <snmp.h>
00020 #include  <mgmtapi.h>
00021
00022 #include  "wsnmputil.h"
00023
00024
00025
00026 //
00027 // abstract: print the usage for wsnmputil
00028 // input  :  none
00029 // output :  none
00030 //
00031 void    Usage( )
00032 {
00033     printf("\nusage:  wsnmputil [-v1|-v2] [get|getnext|walk|getbulk|subtree] agent community [non_repeaters max_repetitions] oid [oid ...]\n");
00034     printf("Examples:\n");
00035     printf("  wsnmputil trap\n");
00036     printf("  wsnmputil -v1 get localhost public 1.3.6.1.2.1.1.1.0\n");
00037     printf("  wsnmputil -v1 getnext localhost public 1.3.6.1.2.1.1.1.0\n");
00038     printf("  wsnmputil -v1 subtree localhost public 1.3.6.1.2.1.1\n");
00039     printf("  wsnmputil -v1 set toaster public 1.3.6.1.4.1.12.2.5.0   2\n");
00040     printf("  wsnmputil -v2 walk localhost public 1\n");
00041     printf("  wsnmputil -v2 getbulk toaster public 1  2   1.3.6.1.2.1.1.2.0  1.3.6.1.2.1.4.22.1.2  1.3.6.1.2.1.4.22.1.4\n");
00042 }  // end of Usage
00043
00044
00045
00046 //
00047 // abstract: Print the debug message.
00048 // input:    variable
00049 // output:   none
00050 //
00051 void    PrintDbgMessage( LPSTR szFormat, ... )
00052 {
00053     va_list argList;
00054     char    szBuf[ 1024 ];
00055
00056     va_start ( argList, szFormat );
00057     vsprintf     ( szBuf, szFormat, argList );
00058     va_end     ( argList );
00059
00060     printf     ( szBuf );
00061 }  //end of PrintDbgMessage
00062
00063
00064
00065 //
00066 // abstract: convert agentAddress ( "a.b.c.d" format or "text.xyz.com" format )
00067 // input  : text string from the command line
00068 // output : TRUE if name is resolved to IP address, FALSE otherwise.
00069 //
00070 BOOL ConvertTexttoIp( char *agentAddress )
00071 {
00072
00073     DWORD           ipAddr;
00074     struct hostent *phost = NULL;
00075
00076
00077     if ( agentAddress == NULL )
00078         return ( FALSE );
00079
00080     gVars.agentSockAddr.sin_family = AF_INET;
00081
00082     if ( (ipAddr = inet_addr( agentAddress )) == INADDR_NONE )
00083     {
00084         if ( (phost = gethostbyname( agentAddress )) == NULL )
00085         {
00086             return ( FALSE );
00087         }
00088         else
00089             memcpy( (char *)&gVars.agentSockAddr.sin_addr, (char *)phost->h_addr, sizeof(unsigned long) );
00090     }
00091     else
00092         memcpy( (char *)&gVars.agentSockAddr.sin_addr, (char *)&ipAddr, sizeof(unsigned long) );
00093
00094     return (TRUE);
00095
00096 } // end of ConvertTexttoIp
00097
00098
00099
00100 //
00101 // abstract: Parse the command line parameters and fill up the pSession structure.
00102 // input parameters:
00103 // argc   number of command line parameters
00104 // argv   list of all the command line parameters.
00105 //
00106 // output parameters:
00107 // TRUE   Command line parsing is successful.
00108 // FALSE  Command line parsing failed, print the usage.
00109 //
00110 BOOL    ParseCommandLine( int argc, char **argv )
00111 {
00112
00113     char        localOid[] = "1.3.6.1.2.1";
00114
00115     // should we wait for traps?
00116     if ( (argc < 5) && (argc != 2) )
00117     {
00118         Usage( );
00119         return ( FALSE );
00120     }
00121     else if ( (_stricmp( argv[1], "trap")) && (argc < 5) )
00122     {
00123         Usage( );
00124         return ( FALSE );
00125     }
00126
00127     // init the class
00128     gVars.oidCount = 0;
00129
00130     // update the pointers.
00131     ++argv;
00132     --argc;
00133
00134     if ( !_stricmp( *argv, "trap" ) )
00135     {
00136         gVars.operation = TRAP;        // wait for traps.
00137         return ( TRUE );
00138     }
00139     else if ( !_stricmp(*argv, "-v2") )
00140     {
00141         gVars.version = TRUE;   // use v2c mode.
00142     }
00143     else if ( !_stricmp(*argv, "-v1") )
00144     {
00145         gVars.version = FALSE;   // use v1 mode.
00146     }
00147
00148     // update the pointers.
00149     ++argv;
00150     --argc;
00151
00152     // check the operation specified.
00153     if ( !_stricmp( *argv, "get" ) )
00154     {
00155         gVars.operation = GET;        // do a get.
00156     }
00157     else if ( !_stricmp( *argv, "getnext" ) )
00158     {
00159         gVars.operation = GET_NEXT;    // do get next.
00160     }
00161     else if ( !_stricmp( *argv, "walk" ) )
00162     {
00163         gVars.operation = WALK;        // do a walk.
00164     }
00165     else if ( !_stricmp( *argv, "set" ) )
00166     {
00167         gVars.operation = SET;        // do a set.
00168     }
00169     else if ( !_stricmp( *argv, "getbulk" ) )
00170     {
00171         gVars.operation = GET_BULK;    // do get bulk operation.
00172     }
00173     else if ( !_stricmp( *argv, "subtree" ) )
00174     {
00175         gVars.operation = SUB_TREE;    // go through the sub tree.
00176     }
00177     else
00178     {
00179         Usage( );
00180         return ( FALSE );
00181     }
00182
00183     // Get agent address...
00184     argv++;
00185     argc--;
00186
00187     gVars.pAgentStrAddr = (LPSTR)SnmpUtilMemAlloc( (int) (strlen(*argv) + 1) );
00188     if ( gVars.pAgentStrAddr == NULL )
00189     {
00190         PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00191         return ( FALSE );
00192     }
00193
00194     strcpy( gVars.pAgentStrAddr, *argv );
00195
00196     // convert the string to IP address.
00197     if ( ConvertTexttoIp(*argv) == FALSE )
00198     {
00199         PrintDbgMessage( "Invalid SNMP agent ..\n" );
00200         return ( FALSE );
00201     }
00202
00203     // Get agent community...
00204     argv++;
00205     argc--;
00206
00207     gVars.pAgentCommunity = (LPSTR)SnmpUtilMemAlloc( (int) (strlen( *argv ) + 1 ));
00208     if ( gVars.pAgentCommunity == NULL )
00209     {
00210         PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00211         return ( FALSE );
00212     }
00213
00214     strcpy( gVars.pAgentCommunity, *argv );
00215
00216     //   If it is a GetBulkRequest
00217     //   Get non_repeaters field and max_repetitions field for
00218     //   SNMP_PDU_GETBULK PDU.
00219
00220     if (gVars.operation == GET_BULK)
00221     {
00222         argv++;
00223         argc--;
00224         if (argc)
00225             gVars.non_repeaters = atol(*argv);
00226         else
00227             return FALSE;
00228         argv++;
00229         argc--;
00230         if (argc)
00231             gVars.max_repetitions = atol(*argv);
00232         else
00233             return FALSE;
00234     }
00235
00236     // ensure that the command line arguments are less than CMD_LINE_ARGS
00237     while( ( --argc ) && ( gVars.oidCount < CMD_LINE_ARGS ) )
00238     {
00239         argv++;
00240
00241         if ( ( ( gVars.operation == WALK  ) || ( gVars.operation == SUB_TREE ) )
00242              && ( strlen( *argv ) <= 3 ) )
00243         {
00244
00245             if ( ( *argv[0] ) == '.' )
00246             {
00247                 // trying to preserve old snmputil behavior.
00248                 // if the user wants to browse a tree starting from .1
00249                 // or if the user wants to browse the tree from .2
00250
00251                 gVars.pszOid[ gVars.oidCount ] = (LPSTR)SnmpUtilMemAlloc( (int)(strlen( localOid )) + (int) (strlen( *argv ) + 1 ));
00252                 if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00253                 {
00254                     PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00255                     return ( FALSE );
00256                 }
00257                 strcpy( gVars.pszOid[ gVars.oidCount ], localOid );
00258                 strcat( gVars.pszOid[ gVars.oidCount ], *argv );
00259             }
00260             else if ( isdigit( *argv[0] ) != 0 )
00261             {
00262                 // if the user wants to browse the tree from 1 or 2
00263
00264                 gVars.pszOid[ gVars.oidCount ] = (LPSTR)SnmpUtilMemAlloc( (int)(strlen( localOid )) + (int) (strlen( *argv ) + 2 ));
00265                 if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00266                 {
00267                     PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00268                     return ( FALSE );
00269                 }
00270                 strcpy( gVars.pszOid[ gVars.oidCount ], localOid );
00271                 strcat( gVars.pszOid[ gVars.oidCount ], "." );
00272                 strcat( gVars.pszOid[ gVars.oidCount ], *argv );
00273             }
00274             else
00275             {
00276                 gVars.pszOid[ gVars.oidCount ] = (LPSTR)SnmpUtilMemAlloc( (int)(strlen( *argv ) + 1 ));
00277                 if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00278                 {
00279                     PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00280                     return ( FALSE );
00281                 }
00282                 strcpy( gVars.pszOid[ gVars.oidCount ], *argv );
00283             }
00284
00285             ++gVars.oidCount;
00286             // do a walk or SUB_TREE on one oid.
00287             break;
00288         }
00289         else if ( gVars.operation == SET )
00290         {
00291             if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00292             {
00293                 gVars.pszOid[ gVars.oidCount ] = ( LPSTR )SnmpUtilMemAlloc( (int) (strlen( ( *argv ) ) + 1 ));
00294                 if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00295                 {
00296                     PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00297                     return ( FALSE );
00298                 }
00299                 strcpy( gVars.pszOid[ gVars.oidCount ], *argv );
00300             }
00301             else
00302             {
00303                 gVars.pSetValue = ( LPSTR )SnmpUtilMemAlloc( (int)(strlen( *argv ) + 1 ));
00304                 if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00305                 {
00306                     PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00307                     return ( FALSE );
00308                 }
00309                 strcpy( gVars.pSetValue, *argv );
00310                 break; // we only do a SET for 1 pair of (name, value) varbinding
00311             }
00312
00313         }
00314         else
00315         {
00316             gVars.pszOid[ gVars.oidCount ] = (LPSTR)SnmpUtilMemAlloc( (int)(strlen( *argv ) + 1 ));
00317             if ( gVars.pszOid[ gVars.oidCount ] == NULL )
00318             {
00319                 PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00320                 return ( FALSE );
00321             }
00322             strcpy( gVars.pszOid[ gVars.oidCount ], *argv );
00323             ++gVars.oidCount;
00324         }
00325
00326     }
00327
00328     if (gVars.operation == GET_BULK)
00329     {
00330         //check if user has entered valid arguments for GET_BULK operation
00331         if (gVars.non_repeaters < 0 || gVars.max_repetitions < 0 )
00332             return (FALSE);
00333         if (gVars.oidCount < gVars.non_repeaters)
00334             return (FALSE);
00335     }
00336
00337     return ( TRUE );
00338 }  // end of ParseCommandLine
00339
00340
00341
00342 //
00343 // abstract: convert the passes string to smiVALUE
00344 // input  :  a pointer to smiValue
00345 // output :  none
00346 //
00347 void ConvertStringToSmiValue( smiVALUE *pValue )
00348 {
00349
00350     int     i;
00351     DWORD   ipAddr;
00352     BYTE    *pBytePtr;
00353
00354     switch( pValue->syntax )
00355     {
00356
00357         case SNMP_SYNTAX_INT:
00358             pValue->value.sNumber = atol( gVars.pSetValue );
00359             break;
00360
00361         case SNMP_SYNTAX_UINT32:
00362         case SNMP_SYNTAX_CNTR32:
00363         case SNMP_SYNTAX_GAUGE32:
00364         case SNMP_SYNTAX_TIMETICKS:
00365             pValue->value.uNumber = atol( gVars.pSetValue );
00366             break;
00367
00368         case SNMP_SYNTAX_CNTR64:
00369             pValue->value.hNumber.hipart = ( smiUINT32 )( _atoi64( gVars.pSetValue ) >> 32);
00370             pValue->value.hNumber.lopart = (smiUINT32)( _atoi64( gVars.pSetValue ) & 0xFFFFFFFF);
00371             break;
00372
00373         case SNMP_SYNTAX_OCTETS:
00374         case SNMP_SYNTAX_BITS:
00375         case SNMP_SYNTAX_OPAQUE:
00376             pValue->value.string.len = (int) strlen( gVars.pSetValue );
00377             pValue->value.string.ptr = ( smiBYTE * )SnmpUtilMemAlloc( pValue->value.string.len * sizeof( smiBYTE ) );
00378
00379             if ( pValue->value.string.ptr )
00380             {
00381
00382                 memcpy( pValue->value.string.ptr,
00383                         gVars.pSetValue,
00384                         pValue->value.string.len * sizeof( smiBYTE )
00385                       );
00386             }
00387             break;
00388         case SNMP_SYNTAX_NSAPADDR:
00389             break;
00390         case SNMP_SYNTAX_IPADDR:
00391
00392             pValue->value.string.len = 4;        // len of IPAddress field.
00393             pValue->value.string.ptr = ( smiBYTE * )SnmpUtilMemAlloc( pValue->value.string.len * sizeof( smiBYTE ) );
00394
00395             ipAddr = inet_addr( gVars.pSetValue );
00396
00397             pBytePtr = ( BYTE * )&ipAddr;
00398
00399             for( i = 0; i < 4; i++ )
00400             {
00401                 pValue->value.string.ptr[ i ] = *pBytePtr++;
00402             }
00403
00404             break;
00405         case SNMP_SYNTAX_NULL:
00406         case SNMP_SYNTAX_NOSUCHOBJECT:
00407         case SNMP_SYNTAX_NOSUCHINSTANCE:
00408         case SNMP_SYNTAX_ENDOFMIBVIEW:
00409             pValue->value.empty = 0;
00410             break;
00411
00412         default:
00413             break;
00414     }
00415
00416 }  //end of ConvertStringToSmiValue
00417
00418
00419
00420 //
00421 // abstract: print a smiValue
00422 // input  :  a pointer to smiValue
00423 // output :  none
00424 //
00425 void PrintOidValue( smiVALUE *pValue )
00426 {
00427
00428     if ( pValue == NULL )
00429         return;
00430
00431
00432     switch( pValue->syntax )
00433     {
00434         case SNMP_SYNTAX_INT32:
00435             printf( "INTEGER: %ld \n", pValue->value.sNumber );
00436             break;
00437         case SNMP_SYNTAX_UINT32:
00438             printf( "UNSIGNED INTEGER: %ld \n", pValue->value.uNumber );
00439             break;
00440         case SNMP_SYNTAX_CNTR32:
00441             printf( "COUNTER: %ld \n", pValue->value.uNumber );
00442             break;
00443         case SNMP_SYNTAX_GAUGE32:
00444             printf( "GAUGE: %ld \n", pValue->value.uNumber );
00445             break;
00446         case SNMP_SYNTAX_TIMETICKS:
00447             printf( "TIMETICKS: %ld \n", pValue->value.uNumber );
00448             break;
00449         case SNMP_SYNTAX_CNTR64:
00450             printf( "COUNTER64: %ld%ld \n", pValue->value.hNumber.hipart,
00451                                         pValue->value.hNumber.lopart );
00452             break;
00453         case SNMP_SYNTAX_OCTETS:
00454         {
00455             UINT  J;
00456             BOOL  IsDisplayString = TRUE;
00457             LPSTR StringFormat;
00458             for ( J=0; J < pValue->value.string.len && IsDisplayString; J++ )
00459             {
00460                 IsDisplayString = isprint( pValue->value.string.ptr[J] );
00461             }
00462             StringFormat = IsDisplayString ? "%c" : "<0x%02x>" ;
00463
00464             printf( "OCTET STRING - " );
00465             for ( J=0; J < pValue->value.string.len; J++ )
00466             {
00467                 printf( StringFormat, pValue->value.string.ptr[J] );
00468             }
00469             putchar( '\n' );
00470         }
00471             break;
00472
00473         case SNMP_SYNTAX_BITS:
00474         {
00475             UINT J;
00476             printf( "Bits - " );
00477             for ( J=0; J < pValue->value.string.len; J++ )
00478             {
00479                 printf( "0x%x ", pValue->value.string.ptr[J] );
00480             }
00481             putchar( '\n' );
00482         }
00483             break;
00484
00485         case SNMP_SYNTAX_OPAQUE:
00486         {
00487             UINT J;
00488             printf( "Opaque - " );
00489             for ( J=0; J < pValue->value.string.len; J++ )
00490             {
00491                 printf( "0x%x ", pValue->value.string.ptr[J] );
00492             }
00493             putchar( '\n' );
00494         }
00495             break;
00496
00497         case SNMP_SYNTAX_IPADDR:
00498         {
00499             printf( "IpAddress - " );
00500             printf( "%d.%d.%d.%d ",
00501                   pValue->value.string.ptr[0] ,
00502                   pValue->value.string.ptr[1] ,
00503                   pValue->value.string.ptr[2] ,
00504                   pValue->value.string.ptr[3] );
00505             putchar( '\n' );
00506         }
00507             break;
00508
00509         case SNMP_SYNTAX_NSAPADDR:
00510             break;
00511
00512         case SNMP_SYNTAX_OID:
00513         {
00514             UINT J;
00515             printf( "OBJECT IDENTIFIER - " );
00516             for ( J=0; J < pValue->value.oid.len; J++ )
00517             {
00518                 printf( ".%d", pValue->value.oid.ptr[J] );
00519             }
00520             putchar( '\n' );
00521         }
00522             break;
00523
00524         case SNMP_SYNTAX_NULL:
00525             printf( "NULL - NULL \n" );
00526             break;
00527
00528         case SNMP_SYNTAX_NOSUCHOBJECT:
00529             printf( "No such object ..\n" );
00530             break;
00531
00532         case SNMP_SYNTAX_NOSUCHINSTANCE:
00533             printf( "No such instance ..\n" );
00534             break;
00535
00536         case SNMP_SYNTAX_ENDOFMIBVIEW:
00537             printf( " End of MibView ..\n " );
00538             break;
00539
00540         default:
00541             printf( "Invalid Type ..\n" );
00542             break;
00543     }
00544
00545 }  //end of PrintOidValue
00546
00547
00548
00549 //
00550 // abstarct: print the varBinds in pSession->hVbl
00551 // input:    a pointer to manager session
00552 // output:   none
00553 //
00554 BOOL    PrintVarBind( PSNMP_MGR_SESSION pSession )
00555 {
00556     char                 szBuf[ MAX_BUFFER_LEN ];
00557     char                 szSecString[ MAX_BUFFER_LEN ];
00558     int                     oidCount;
00559     int                     i;
00560     smiINT               result;
00561     AsnObjectIdentifier  Oid;      //unfortunate that there is no better way
00562     LPSTR                string = NULL;
00563
00564
00565     oidCount = SnmpCountVbl( pSession->hVbl );
00566
00567
00568     // using gVars.oid for walk operation.
00569     // doesnt hurt when using get, get next operations as well.
00570
00571     for( i = 1; i <= oidCount; i++ )
00572     {
00573
00574         if (i > 1) //free the last gVars.oid before getting a new one
00575         {
00576             SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&gVars.oid);
00577             if  ( gVars.value.syntax == SNMP_SYNTAX_OCTETS )
00578             {
00579                 SnmpFreeDescriptor ( SNMP_SYNTAX_OCTETS, (smiLPOPAQUE)&gVars.value.value.string);
00580             }
00581             if  ( gVars.value.syntax == SNMP_SYNTAX_OID )
00582             {
00583                 SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&gVars.value.value.oid);
00584             }
00585         }
00586
00587         SnmpGetVb( pSession->hVbl, i, &gVars.oid, &gVars.value );
00588
00589         // a special case for SUB_TREE walk.
00590         if ( gVars.operation == SUB_TREE )
00591         {
00592             SnmpOidCompare( &gVars.startOid, &gVars.oid, ( gVars.startOid.len ), &result );
00593             if ( result != 0 )
00594                     return FALSE;
00595         }
00596         // a special case for WALK operation.
00597         if (gVars.operation == WALK && gVars.value.syntax == SNMP_SYNTAX_ENDOFMIBVIEW)
00598         {
00599             return FALSE;
00600         }
00601
00602
00603         if ( gVars.doSet == FALSE )
00604         {
00605             printf( "OID :" );
00606             memset( szBuf, 0, MAX_BUFFER_LEN );
00607             SnmpOidToStr( &gVars.oid, MAX_BUFFER_LEN, szBuf );
00608             printf( szBuf );
00609             printf ( "\n\r" );
00610
00611             // The old mgmtapi requires a leading dot....
00612             strcpy( szSecString, "." );
00613             strcat( szSecString, szBuf );
00614
00615
00616             if ( SnmpMgrStrToOid( szSecString, &Oid ) )
00617             {
00618                 SnmpMgrOidToStr( &Oid, &string );
00619             }
00620
00621             if ( string )
00622             {
00623                 printf( "%s \n", string );
00624                 SnmpUtilMemFree( string );
00625                 SnmpUtilOidFree ( &Oid);
00626             }
00627
00628             PrintOidValue( &gVars.value );
00629             printf( "\n\r\n\r" );
00630         }
00631
00632     }
00633
00634     return TRUE;
00635
00636 }  //PrintVarBind
00637
00638
00639
00640
00641 //
00642 // abstract : parse and print v2 trap in v1 form.
00643 //            assuming that the trap is sent by a v1 agent
00644 //
00645 // input:     PSNMP_MGR_SESSION pointer to the session
00646 // output:    none
00647 //
00648 void    ParseAndPrintv2Trap( PSNMP_MGR_SESSION pSession )
00649 {
00650     smiOID      sysUpTime,
00651                 snmpTrapOid,
00652                 snmpTrapEnterprise,
00653                 snmpTraps,
00654                 snmpTrapEnterpriseOID,
00655                 tmpOid;
00656
00657     smiINT      result;
00658     smiVALUE    value;
00659
00660     DWORD       oidCount;
00661     DWORD       index;
00662     int         genTrap;
00663     char        szBuf[ MAX_BUFFER_LEN ];
00664     char        szSecString[ MAX_BUFFER_LEN ];
00665     AsnObjectIdentifier  Oid;      //unfortunate that there is no better way
00666     LPSTR       string = NULL;
00667     BOOL        entOid = FALSE;
00668
00669
00670     if ( pSession == NULL )
00671         return;
00672
00673     // convert to oids.
00674
00675     if ( SNMP_FAILURE( SnmpStrToOid( "1.3.6.1.2.1.1.3", &sysUpTime ) ) )
00676         return;
00677     if ( SNMP_FAILURE( SnmpStrToOid( "1.3.6.1.6.3.1.1.4", &snmpTrapOid ) ) )
00678         return;
00679     if ( SNMP_FAILURE( SnmpStrToOid( "1.3.6.1.6.3.1.1.4", &snmpTrapEnterprise ) ) )
00680         return;
00681     if ( SNMP_FAILURE( SnmpStrToOid( "1.3.6.1.6.3.1.1.5", &snmpTraps ) ) )
00682         return;
00683     if ( SNMP_FAILURE( SnmpStrToOid( "1.3.6.1.6.3.1.1.4.3.0", &snmpTrapEnterpriseOID ) ) )
00684         return;
00685
00686     oidCount = SnmpCountVbl ( pSession->hVbl );
00687
00688     for( index = 1; index <= oidCount; index++ )
00689     {
00690         // print out varbind (name, value) pair in format of:
00691         // Name in numerical form
00692         // Name in string form
00693         // value
00694         // generic trap name (if this varbind is a generic trap)
00695         SnmpGetVb( pSession->hVbl, index, &tmpOid, &value );
00696         printf( "OID :" );
00697         memset( szBuf, 0, MAX_BUFFER_LEN );
00698         SnmpOidToStr( &tmpOid, MAX_BUFFER_LEN, szBuf );
00699         printf( szBuf );
00700         printf ( "\n\r" );
00701
00702         if (index == oidCount)
00703         {
00704             // Check if the last variable binding equals to "snmpTrapEnterpriseOID.0"
00705             SnmpOidCompare( &snmpTrapEnterpriseOID, &tmpOid, snmpTrapEnterpriseOID.len, &result );
00706             entOid = (result == 0);
00707         }
00708
00709         // The old mgmtapi requires a leading dot....
00710         strcpy( szSecString, "." );
00711         strcat( szSecString, szBuf );
00712
00713
00714         if ( SnmpMgrStrToOid( szSecString, &Oid ) )
00715         {
00716             SnmpMgrOidToStr( &Oid, &string );
00717         }
00718
00719         if ( string )
00720         {
00721             printf( "OID string: %s \n", string );
00722             SnmpUtilMemFree( string );
00723             SnmpUtilOidFree ( &Oid);
00724         }
00725         else
00726         {
00727             printf( "OID string: <Can't convert oid to string form>\n");
00728         }
00729         SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&tmpOid);
00730
00731         PrintOidValue( &value );
00732
00733         // process generic traps only ..
00734         if ( value.syntax == SNMP_SYNTAX_OID )
00735         {
00736             tmpOid = value.value.oid; // structure copy ..
00737
00738             SnmpOidCompare( &snmpTraps, &tmpOid, snmpTraps.len, &result );
00739
00740             if ( !result )
00741             {
00742                 if ( tmpOid.len == ( snmpTraps.len + 1 ) )
00743                 {
00744                     genTrap = tmpOid.ptr[ snmpTraps.len ];
00745
00746                     switch( genTrap )
00747                         {
00748                         case 1:
00749                             PrintDbgMessage( "ColdStart \n" );
00750                             break;
00751                         case 2:
00752                             PrintDbgMessage( "WarmStart \n" );
00753                             break;
00754                         case 3:
00755                             PrintDbgMessage( "LinkDown \n" );
00756                             break;
00757                         case 4:
00758                             PrintDbgMessage( "LinkUp \n" );
00759                             break;
00760                         case 5:
00761                             PrintDbgMessage( "Authentication Failure \n" );
00762                             break;
00763                         case 6:
00764                             PrintDbgMessage( "EGP Neighbor Loss \n" );
00765                             break;
00766                         case 7:
00767                             PrintDbgMessage( "enterprise specific \n" );
00768                             break;
00769                         default:
00770                             break;
00771                         }
00772                 }
00773             }
00774         }
00775
00776         printf( "\n\r\n\r" );
00777
00778         if ( entOid )
00779         {
00780             PrintDbgMessage( "Enterprise specific oid from v1 trap \n" );
00781             PrintDbgMessage( "\n\r\n\r" );
00782         }
00783
00784         if  ( value.syntax == SNMP_SYNTAX_OCTETS )
00785         {
00786             SnmpFreeDescriptor ( SNMP_SYNTAX_OCTETS, (smiLPOPAQUE)&value.value.string);
00787         }
00788         if  ( value.syntax == SNMP_SYNTAX_OID )
00789         {
00790             SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&value.value.oid);
00791         }
00792     }
00793
00794
00795         SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&sysUpTime);
00796         SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&snmpTrapOid);
00797         SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&snmpTrapEnterprise);
00798         SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&snmpTraps);
00799         SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&snmpTrapEnterpriseOID);
00800
00801 }  // end of ParseAndPrintv2Trap
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/localres.h Source File

  • SysMgmt
  • MMC
  • ActiveX

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/iocs.h Source File

  • Com
  • Fundamentals
  • SimpCntr

iocs.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOCS.H
00003 //
00004 //      Definition of COleClientSite
00005 //
00006 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IOCS_H_ )
00009 #define _IOCS_H_
00010
00011 #include <assert.h>
00012
00013 class CSimpleSite;
00014
00015 interface COleClientSite : public IOleClientSite
00016 {
00017   int m_nCount;
00018   CSimpleSite FAR * m_pSite;
00019
00020   COleClientSite(CSimpleSite FAR * pSite) {
00021     OutputDebugString("In IOCS's constructor\r\n");
00022     m_pSite = pSite;
00023     m_nCount = 0;
00024     }
00025
00026   ~COleClientSite() {
00027     OutputDebugString("In IOCS's destructor\r\n");
00028     assert(m_nCount == 0);
00029     }
00030
00031   STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
00032   STDMETHODIMP_(ULONG) AddRef();
00033   STDMETHODIMP_(ULONG) Release();
00034
00035   // *** IOleClientSite methods ***
00036   STDMETHODIMP SaveObject();
00037   STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER FAR* ppmk);
00038   STDMETHODIMP GetContainer(LPOLECONTAINER FAR* ppContainer);
00039   STDMETHODIMP ShowObject();
00040   STDMETHODIMP OnShowWindow(BOOL fShow);
00041   STDMETHODIMP RequestNewObjectLayout();
00042 };
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/osp/vc/mydatasource.h Source File

  • Dataaccess
  • osp
  • vc

mydatasource.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample OLEDB Simple Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation.  All Rights Reserved.
00004 //
00005 // module MyDataSource.h | MyDataSource object implementation
00006 //
00007 //
00008 #ifndef _MyDataSource_H_
00009 #define _MyDataSource_H_
00010
00011
00012 ////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 ////////////////////////////////////////////////////////
00016 #include "msdaosp.h"
00017 #include "MyOSPObject.h"
00018 #include "CExList.h"
00019
00020 ////////////////////////////////////////////////////////
00021 // MyDataSource
00022 //
00023 ////////////////////////////////////////////////////////
00024 class MyDataSource  : public IDataSource
00025 {
00026 public:
00027   //constructors
00028   MyDataSource();
00029   virtual ~MyDataSource();
00030
00031   virtual HRESULT Init();
00032
00033   //IUnknown
00034   virtual inline STDMETHODIMP_(ULONG) AddRef()
00035   {
00036     InterlockedIncrement((LONG*)&m_cRef);
00037     return m_cRef;
00038   }
00039   virtual inline STDMETHODIMP_(ULONG) Release()
00040   {
00041     if(InterlockedDecrement((LONG*)&m_cRef))
00042       return m_cRef;
00043
00044     delete this;
00045     return 0;
00046   }
00047   virtual STDMETHODIMP  QueryInterface(REFIID riid, void** ppv);
00048
00049   //IDataSource methods
00050   virtual STDMETHODIMP  getDataMember(BSTR bstrDM, REFIID riid, IUnknown** ppUnk);
00051     virtual STDMETHODIMP  getDataMemberName(LONG lIndex, BSTR* pbstrDM);
00052     virtual STDMETHODIMP  getDataMemberCount(LONG* plCount);
00053
00054   virtual STDMETHODIMP  addDataSourceListener(IDataSourceListener* pDSL);
00055     virtual STDMETHODIMP  removeDataSourceListener(IDataSourceListener* pDSL);
00056
00057 protected:
00058   //data
00059   MyOSPObject*          m_pMyOSPObject;
00060   CExList<IDataSourceListener*> m_listListeners;
00061
00062   //tables
00063   ULONG m_cTables;
00064   WCHAR*  m_rgpwszTableName[1];
00065
00066   //IUnknown
00067   ULONG m_cRef;
00068 };
00069
00070 #endif //_MyDataSource_H_
00071
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

APMFILEHEADER Member List

This is the complete list of members for APMFILEHEADER, including all inherited members.
bbox | APMFILEHEADER
checksum | APMFILEHEADER
hmf | APMFILEHEADER
inch | APMFILEHEADER
key | APMFILEHEADER
reserved | APMFILEHEADER
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/mibmgr.h Source File

  • NetDS
  • RRas
  • ip

mibmgr.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\mibmanager.h
00008
00009 Abstract:
00010
00011     The file contains the header for mib.c
00012
00013 Revision History:
00014
00015     MohitT      June-15-1999    Created
00016
00017 --*/
00018
00019 #ifndef _MIBMANAGER_H_
00020 #define _MIBMANAGER_H_
00021
00022 DWORD
00023 WINAPI
00024 MM_MibSet (
00025     IN      PIPSAMPLE_MIB_SET_INPUT_DATA    pimsid);
00026
00027 DWORD
00028 WINAPI
00029 MM_MibGet (
00030     IN      PIPSAMPLE_MIB_GET_INPUT_DATA    pimgid,
00031     OUT     PIPSAMPLE_MIB_GET_OUTPUT_DATA   pimgod,
00032     IN OUT  PULONG                          pulOutputSize,
00033     IN      MODE                            mMode);
00034
00035 #endif // _MIB_H_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/io/ASyncTrans/openf.c Source File

  • Web
  • iis
  • extensions
  • io
  • ASyncTrans

openf.c

Go to the documentation of this file.
00001 /* Copyright (c) 1995-2002 Microsoft Corporation
00002
00003   Module Name:
00004
00005     openf.c
00006
00007   Abstract:
00008
00009     This module implements a simple open file handle cache
00010 */
00011
00012 #include "openf.h"
00013
00014 /* internal data structure for maintaining the list of open file handles. */
00015
00016 typedef struct _OPEN_FILE {
00017
00018   HANDLE  hFile;
00019   struct _OPEN_FILE * pNext;
00020   LONG    nHits;
00021   LONG    nRefs;
00022   CHAR    rgchFile[MAX_PATH + 1];
00023
00024 } OPEN_FILE, *LPOPEN_FILE;
00025
00026 LPOPEN_FILE g_pOpenFiles = NULL;
00027 CRITICAL_SECTION g_csOpenFiles;
00028
00029 /* Set up global variables containing the flags for CreateFile. The flags can be masked for Windows 95 system */
00030
00031 DWORD  g_dwCreateFileShareMode = (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE);
00032 DWORD  g_dwCreateFileFlags = (FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED);
00033
00034 VOID InitFileHandleCache(VOID)
00035 {
00036   InitializeCriticalSection(&g_csOpenFiles);
00037 }
00038
00039 DWORD CleanupFileHandleCache(VOID)
00040 {
00041   LPOPEN_FILE  pFileScan;
00042
00043   while (g_pOpenFiles != NULL) {
00044
00045     pFileScan = g_pOpenFiles;
00046
00047     g_pOpenFiles = g_pOpenFiles->pNext;
00048
00049     if (pFileScan->hFile != INVALID_HANDLE_VALUE)
00050       CloseHandle( pFileScan->hFile);
00051
00052     LocalFree(pFileScan);
00053   }
00054
00055   DeleteCriticalSection(&g_csOpenFiles);
00056
00057   return NO_ERROR;
00058 }
00059
00060 /*
00061   Description:
00062
00063     This function opens the file specified in the 'pszFile'.
00064     If the file name starts with a '/' we use the ECB to map
00065     the given path into a physical file path.
00066
00067   Arguments:
00068
00069     pecb - pointer to the ECB block
00070     pszFile - pointer to file name
00071
00072   Returns:
00073
00074     valid File handle on success
00075 */
00076
00077 HANDLE FcOpenFile(IN EXTENSION_CONTROL_BLOCK *pecb, IN LPCSTR pszFile)
00078 {
00079   LPOPEN_FILE pFileScan;
00080   HANDLE hFile = INVALID_HANDLE_VALUE;
00081
00082   EnterCriticalSection(&g_csOpenFiles);
00083
00084   for (pFileScan =  g_pOpenFiles; NULL != pFileScan; pFileScan = pFileScan->pNext) {
00085
00086     if (0 == lstrcmpi(pFileScan->rgchFile, pszFile)) {
00087
00088       /* there is a file match. */
00089
00090       break;
00091     }
00092   }
00093
00094   if (NULL == pFileScan) {
00095
00096     /* File was not found. Create a new file handle */
00097
00098     CHAR rgchFileName[ MAX_PATH]; /* local copy */
00099     LPCSTR pszInputPath = pszFile;
00100
00101     lstrcpyn(rgchFileName, pszFile, MAX_PATH);
00102
00103     if (*pszFile == '/') {
00104
00105       DWORD cbSize = sizeof(rgchFileName);
00106       BOOL fRet;
00107
00108       /* reset the file pointer, so subsequent use will fail */
00109
00110       pszFile = NULL;
00111
00112       /* Using the ECB map the Virtual path to the Physical path */
00113
00114       fRet = pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_MAP_URL_TO_PATH, rgchFileName, &cbSize, NULL);
00115
00116       if (fRet) {
00117
00118           /* we got the mapping. Use it. */
00119
00120           pszFile = rgchFileName;
00121       }
00122     }
00123
00124     if (NULL != pszFile) {
00125
00126       pFileScan = LocalAlloc(LPTR, sizeof(*pFileScan));
00127
00128       if (NULL != pFileScan) {
00129
00130         SECURITY_ATTRIBUTES sa;
00131
00132         sa.nLength = sizeof(sa);
00133         sa.lpSecurityDescriptor = NULL;
00134         sa.bInheritHandle = FALSE;
00135
00136         pFileScan->hFile = CreateFile(pszFile, GENERIC_READ, g_dwCreateFileShareMode, &sa, OPEN_EXISTING, g_dwCreateFileFlags, NULL);
00137
00138         if (INVALID_HANDLE_VALUE == pFileScan->hFile) {
00139
00140           LocalFree(pFileScan);
00141
00142           pFileScan = NULL;
00143
00144         } else {
00145
00146           /* insert this into the list at the top */
00147
00148           lstrcpyn(pFileScan->rgchFile, pszInputPath, MAX_PATH);
00149
00150           pFileScan->pNext = g_pOpenFiles;
00151
00152           g_pOpenFiles = pFileScan;
00153
00154           pFileScan->nRefs = 1;
00155           pFileScan->nHits = 0;
00156         }
00157       }
00158     }
00159   }
00160
00161   if (NULL != pFileScan) {
00162
00163     hFile = pFileScan->hFile;
00164
00165     pFileScan->nHits++;
00166     pFileScan->nRefs++;
00167   }
00168
00169   LeaveCriticalSection(&g_csOpenFiles);
00170
00171   return hFile;
00172 }
00173
00174 DWORD FcCloseFile(IN HANDLE hFile)
00175 {
00176   LPOPEN_FILE pFileScan;
00177   DWORD dwError = NO_ERROR;
00178
00179   EnterCriticalSection(&g_csOpenFiles);
00180
00181   /* Look for the handle and decrement the ref count. */
00182
00183   for (pFileScan = g_pOpenFiles; NULL != pFileScan; pFileScan = pFileScan->pNext) {
00184
00185     if ( hFile == pFileScan->hFile) {
00186
00187       /*  there is a file match. */
00188
00189       pFileScan->nRefs--;
00190
00191       /*
00192         Note: This is example code. Do not use for production, as there
00193         is no freeing of the file when Ref hits 0
00194       */
00195
00196       break;
00197     }
00198   }
00199
00200   if (NULL == pFileScan) {
00201
00202     /* file handle not found */
00203
00204     dwError = (ERROR_INVALID_HANDLE);
00205   }
00206
00207   LeaveCriticalSection(&g_csOpenFiles);
00208
00209   return dwError;
00210 }
00211
00212 /*
00213   Description:
00214
00215     Reads contents of file [hFile] from the specified offset in the overlapped
00216     structure. The contents are read into the buffer supplied.
00217
00218   Arguments:
00219
00220     hFile        - handle for the File from which to read data
00221     pchBuffer    - pointer to the buffer into which the data is to be read
00222     dwBufferSize - DWORD containing the max size of the buffer supplied
00223     pcbRead      - number of bytes read from the file
00224     pov          - pointer to an overlapped structure that contains the
00225                     offset from where to read the contents. The
00226                     overlapped structure also is used for Overlapped
00227                     IO in NT.
00228
00229   Notes:
00230
00231     This function automatically handles both Windows 95 and NT
00232
00233   Returns:
00234
00235     TRUE on success and FALSE if there is a failure.
00236     Use GetLastError() to get the last error code on failure.
00237 */
00238
00239 BOOL FcReadFromFile(IN HANDLE hFile, OUT CHAR *pchBuffer, IN DWORD dwBufferSize, OUT LPDWORD pcbRead, IN OUT LPOVERLAPPED pov)
00240 {
00241   BOOL fRet = TRUE;
00242
00243   *pcbRead = 0;
00244
00245   ResetEvent(pov->hEvent);
00246
00247   /* read data from file */
00248
00249   if (!ReadFile(hFile, pchBuffer, dwBufferSize, pcbRead, pov)) {
00250
00251     DWORD err = GetLastError();
00252
00253     if ((err != ERROR_IO_PENDING) || !GetOverlappedResult(hFile, pov, pcbRead, TRUE))
00254       fRet = FALSE;
00255   }
00256
00257   if (fRet)
00258     pov->Offset += *pcbRead;
00259
00260   return fRet;
00261 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/Serialization/Serialization.cs Source File

  • TabletPC
  • Serialization

Serialization.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: Serialization.cs
00013 //  Ink Serialization Application
00014 //
00015 //  This program demonstrates how one can serialize and deserialize
00016 //  ink in various formats.
00017 //
00018 //  The application represents a form with fields for inputting first
00019 //  name, last name and signature. It allows the user to save this
00020 //  data as pure ISF (Ink Serialized Format) XML using base64 encoded
00021 //  ISF or HTML which references GIF images "fortified" with ink.  It
00022 //  is also possible to Load from the XML and ISF formats.  The ISF
00023 //  save/load uses extended properties to store the first name and last
00024 //  name, whereas the XML and HTML save/load stores this information in
00025 //  custom attributes.
00026 //
00027 //  This sample does not support loading from the HTML format, because
00028 //  HTML is not a format suitable for storing structured data, such as
00029 //  forms. Because the data is separated into multiple streams (name,
00030 //  signature, etc.,) a format which preserves this separation such as
00031 //  XML or another kind of database format is required.
00032 //
00033 //  HTML is very useful in a flow editing environment, such as a word
00034 //  processing document. The HTML that is saved by this sample uses
00035 //  fortified GIFs. These GIFs have ISF embedded within them, which
00036 //  preserves the full fidelity of the ink. A word processing
00037 //  application could save a document containing multiple types of
00038 //  data, such as images, tables, formatted text and ink persisted
00039 //  in an HTML format. This HTML would render without a hitch in
00040 //  browsers which have no special abilities to understand ink.
00041 //  However, when loaded into an application that is ink-aware, such
00042 //  as another word processing application, the full fidelity of the
00043 //  original ink is available and can be rendered at very high quality,
00044 //  edited or used for recognition.
00045 //
00046 //  See the "Ink Interoperability" whitepaper, in this SDK, for more
00047 //  information about persistence formats for ink.
00048 //
00049 //  The features used are: Load method, Save method, and extended properties
00050 //
00051 //--------------------------------------------------------------------------
00052
00053 using System;
00054 using System.Drawing.Drawing2D;
00055 using System.Windows.Forms;
00056 using System.Text;
00057 using System.IO;
00058 using System.Xml;
00059
00060 // The Ink namespace, which contains the Tablet PC Platform API
00061 using Microsoft.Ink;
00062
00063 namespace Serialization
00064 {
00065   public class SerializationForm : System.Windows.Forms.Form
00066   {
00067
00068         #region Standard Template Code
00069     /// Required designer variable.
00070     private System.ComponentModel.Container components = null;
00071
00072     private System.Windows.Forms.MainMenu MenuBar;
00073     private System.Windows.Forms.MenuItem FileMenu;
00074     private System.Windows.Forms.MenuItem NewMenu;
00075     private System.Windows.Forms.MenuItem OpenMenu;
00076     private System.Windows.Forms.MenuItem SaveAsMenu;
00077     private System.Windows.Forms.MenuItem SeperatorMenu;
00078     private System.Windows.Forms.MenuItem ExitMenu;
00079
00080     private System.Windows.Forms.GroupBox Signature;
00081     private System.Windows.Forms.TextBox FirstNameBox;
00082     private System.Windows.Forms.TextBox LastNameBox;
00083
00084     private System.Windows.Forms.Label FirstNameLabel;
00085     private System.Windows.Forms.Label LastNameLabel;
00086         #endregion
00087
00088     // The one and only ink collector
00089     private InkCollector ic;
00090
00091     // These strings identify the GUIDs for custom attributes
00092     private Guid FirstName = new Guid ("{29B2E996-57B6-4fda-BFFD-F54DBA4C35F9}");
00093     private Guid LastName = new Guid ("{8A448E7C-0F39-4cd9-BB52-71FDA3221674}");
00094
00095     // Constructor
00096     public SerializationForm()
00097     {
00098             #region Standard Template Code
00099       //
00100       // Required for Windows Form Designer support
00101       //
00102       InitializeComponent();
00103
00104             #endregion
00105
00106             // Create the InkCollector and attach it to the signature GroupBox
00107             ic = new InkCollector(Signature.Handle);
00108             ic.Enabled = true;
00109     }
00110
00111         #region Standard Template Code
00112     /// Clean up any resources being used.
00113     /// Windows Forms Designer template code
00114     protected override void Dispose( bool disposing )
00115     {
00116       if( disposing )
00117       {
00118         if (components != null)
00119         {
00120           components.Dispose();
00121         }
00122       }
00123       base.Dispose( disposing );
00124     }
00125         #endregion
00126
00127     #region Windows Form Designer generated code
00128     /// <summary>
00129     /// Required method for Designer support - do not modify
00130     /// the contents of this method with the code editor.
00131     /// </summary>
00132     private void InitializeComponent()
00133     {
00134             this.MenuBar = new System.Windows.Forms.MainMenu();
00135             this.FileMenu = new System.Windows.Forms.MenuItem();
00136             this.NewMenu = new System.Windows.Forms.MenuItem();
00137             this.OpenMenu = new System.Windows.Forms.MenuItem();
00138             this.SaveAsMenu = new System.Windows.Forms.MenuItem();
00139             this.SeperatorMenu = new System.Windows.Forms.MenuItem();
00140             this.ExitMenu = new System.Windows.Forms.MenuItem();
00141             this.Signature = new System.Windows.Forms.GroupBox();
00142             this.FirstNameBox = new System.Windows.Forms.TextBox();
00143             this.LastNameBox = new System.Windows.Forms.TextBox();
00144             this.FirstNameLabel = new System.Windows.Forms.Label();
00145             this.LastNameLabel = new System.Windows.Forms.Label();
00146             this.SuspendLayout();
00147             //
00148             // MenuBar
00149             //
00150             this.MenuBar.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00151                                                                                     this.FileMenu});
00152             //
00153             // FileMenu
00154             //
00155             this.FileMenu.Index = 0;
00156             this.FileMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00157                                                                                      this.NewMenu,
00158                                                                                      this.OpenMenu,
00159                                                                                      this.SaveAsMenu,
00160                                                                                      this.SeperatorMenu,
00161                                                                                      this.ExitMenu});
00162             this.FileMenu.Text = "&File";
00163             //
00164             // NewMenu
00165             //
00166             this.NewMenu.Index = 0;
00167             this.NewMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
00168             this.NewMenu.Text = "&New";
00169             this.NewMenu.Click += new System.EventHandler(this.NewMenu_Click);
00170             //
00171             // OpenMenu
00172             //
00173             this.OpenMenu.Index = 1;
00174             this.OpenMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
00175             this.OpenMenu.Text = "&Open...";
00176             this.OpenMenu.Click += new System.EventHandler(this.OpenMenu_Click);
00177             //
00178             // SaveAsMenu
00179             //
00180             this.SaveAsMenu.Index = 2;
00181             this.SaveAsMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
00182             this.SaveAsMenu.Text = "Save &As...";
00183             this.SaveAsMenu.Click += new System.EventHandler(this.SaveAsMenu_Click);
00184             //
00185             // SeperatorMenu
00186             //
00187             this.SeperatorMenu.Index = 3;
00188             this.SeperatorMenu.Text = "-";
00189             //
00190             // ExitMenu
00191             //
00192             this.ExitMenu.Index = 4;
00193             this.ExitMenu.Text = "E&xit";
00194             this.ExitMenu.Click += new System.EventHandler(this.ExitMenu_Click);
00195             //
00196             // Signature
00197             //
00198             this.Signature.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
00199                 | System.Windows.Forms.AnchorStyles.Left)
00200                 | System.Windows.Forms.AnchorStyles.Right);
00201             this.Signature.Location = new System.Drawing.Point(8, 48);
00202             this.Signature.Name = "Signature";
00203             this.Signature.Size = new System.Drawing.Size(456, 67);
00204             this.Signature.TabIndex = 1;
00205             this.Signature.TabStop = false;
00206             this.Signature.Text = "Signature";
00207             //
00208             // FirstNameBox
00209             //
00210             this.FirstNameBox.Location = new System.Drawing.Point(8, 24);
00211             this.FirstNameBox.Name = "FirstNameBox";
00212             this.FirstNameBox.Size = new System.Drawing.Size(200, 20);
00213             this.FirstNameBox.TabIndex = 2;
00214             this.FirstNameBox.Text = "";
00215             //
00216             // LastNameBox
00217             //
00218             this.LastNameBox.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
00219                 | System.Windows.Forms.AnchorStyles.Right);
00220             this.LastNameBox.Location = new System.Drawing.Point(216, 24);
00221             this.LastNameBox.Name = "LastNameBox";
00222             this.LastNameBox.Size = new System.Drawing.Size(248, 20);
00223             this.LastNameBox.TabIndex = 3;
00224             this.LastNameBox.Text = "";
00225             //
00226             // FirstNameLabel
00227             //
00228             this.FirstNameLabel.Location = new System.Drawing.Point(8, 8);
00229             this.FirstNameLabel.Name = "FirstNameLabel";
00230             this.FirstNameLabel.Size = new System.Drawing.Size(100, 16);
00231             this.FirstNameLabel.TabIndex = 4;
00232             this.FirstNameLabel.Text = "First Name";
00233             //
00234             // LastNameLabel
00235             //
00236             this.LastNameLabel.Location = new System.Drawing.Point(216, 8);
00237             this.LastNameLabel.Name = "LastNameLabel";
00238             this.LastNameLabel.Size = new System.Drawing.Size(100, 16);
00239             this.LastNameLabel.TabIndex = 5;
00240             this.LastNameLabel.Text = "Last Name";
00241             //
00242             // SerializationForm
00243             //
00244             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00245             this.ClientSize = new System.Drawing.Size(472, 121);
00246             this.Controls.AddRange(new System.Windows.Forms.Control[] {
00247                                                                           this.LastNameLabel,
00248                                                                           this.FirstNameLabel,
00249                                                                           this.LastNameBox,
00250                                                                           this.FirstNameBox,
00251                                                                           this.Signature});
00252             this.Menu = this.MenuBar;
00253             this.Name = "SerializationForm";
00254             this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
00255             this.Text = "Ink Serialization Sample Application";
00256             this.ResumeLayout(false);
00257
00258         }
00259     #endregion
00260
00261         #region Standard Template Code
00262     /// The main entry point for the application.
00263     [STAThread]
00264     static void Main()
00265     {
00266       Application.Run(new SerializationForm());
00267     }
00268         #endregion
00269
00270     // If the user hits the new menu, clear the document
00271     private void NewMenu_Click(object sender, System.EventArgs e)
00272     {
00273       // Erase the ink
00274       ic.Ink.DeleteStrokes();
00275       Signature.Invalidate();
00276
00277       // Clear the text boxes
00278       FirstNameBox.Text = "";
00279       LastNameBox.Text = "";
00280     }
00281
00282     // If the user hits the exit menu, exit the application
00283     private void ExitMenu_Click(object sender, System.EventArgs e)
00284     {
00285             ic.Enabled = false;
00286             this.Dispose();
00287     }
00288
00289     // This function handles the Save As.. command. It allows the user
00290     // to specify a filename and location, as well as the type of format
00291     // to save in. It then calls the appropriate helper function.
00292     // The try...catch section in this function will handle all of the error
00293     // handling for the helper methods it calls.
00294     private void SaveAsMenu_Click(object sender, System.EventArgs e)
00295     {
00296       /// Create a stream which will be used to save data to the output file
00297       Stream myStream = null;
00298
00299       /// Create the SaveFileDialog, which presents a standard Windows
00300       /// Save dialog to the user.
00301       SaveFileDialog saveDialog = new SaveFileDialog();
00302
00303       /// Set the filter to suggest our recommended extensions
00304       saveDialog.Filter =
00305         "Ink Serialized Format files (*.isf)|*.isf|XML files (*.xml)|*.xml|" +
00306         "HTML files (*.htm)|*.htm";
00307
00308       /// If the dialog exits and the user didn't choose Cancel
00309       if(saveDialog.ShowDialog() == DialogResult.OK)
00310       {
00311                 try
00312                 {
00313                     /// Attempt to Open the file with read/write permission
00314                     myStream = saveDialog.OpenFile();
00315                     if(myStream != null)
00316                     {
00317                         // Put the filename in a more canonical format
00318                         String filename = saveDialog.FileName.ToLower();
00319
00320                         // Get a version of the filename without an extension
00321                         // This will be used for saving the associated image
00322                         String extensionlessFilename = Path.GetFileNameWithoutExtension(filename);
00323
00324                         // Get the extension of the file
00325                         String extension = Path.GetExtension(filename);
00326
00327                         // Use the extension to determine what form to save the data in
00328                         switch (extension)
00329                         {
00330                             case ".xml":
00331                                 SaveXML(myStream);
00332                                 break;
00333
00334                                 /// The two HTML cases require a filename for saving associated images
00335                             case ".htm": case ".html":
00336                                 SaveHTML(myStream, extensionlessFilename);
00337                                 break;
00338
00339                                 /// If unfamiliar with the extension, use ISF, the most "native format"
00340                             case ".isf": default:
00341                                 SaveISF(myStream);
00342                                 break;
00343                         }
00344                     }
00345                     else
00346                     {
00347                         // Throw an exception if a null pointer is returned for the stream
00348                         throw new IOException();
00349                     }
00350                 }
00351                 catch (IOException /*ioe*/)
00352                 {
00353                     MessageBox.Show ("File error");
00354                 }
00355                 finally
00356                 {
00357                     // Close the stream in the finally clause so it
00358                     // is always reached, regardless of whether an
00359                     // exception occurs.  SaveXML, SaveHTML, and
00360                     // SaveISF can throw, so this precaution is necessary.
00361                     if (null != myStream)
00362                     {
00363                         myStream.Close();
00364                     }
00365                 }
00366       } // End if user chose OK from dialog
00367     }
00368
00369     // This function saves the form in ISF format.
00370     // It uses ExtendedProperties to preserve the first and last names.
00371     // ExtendedProperties are an easy way to store non-ink data within an
00372     // ink object. In this case, there is no outer format which contains the
00373     // ink, so the only place to store the names is within the ink object itself.
00374     private void SaveISF(Stream s)
00375     {
00376       byte[] isf;
00377
00378       // This is the ink object which will be serialized
00379       ExtendedProperties inkProperties = ic.Ink.ExtendedProperties;
00380
00381       // Store the name fields in the ink object
00382       // These fields will roundtrip through the ISF format
00383             // Ignore empty fields since strictly empty strings
00384             //       cannot be stored in ExtendedProperties.
00385             if (FirstNameBox.Text.Length > 0)
00386             {
00387                 inkProperties.Add(FirstName, FirstNameBox.Text);
00388             }
00389             if (LastNameBox.Text.Length > 0)
00390             {
00391                 inkProperties.Add(LastName, LastNameBox.Text);
00392             }
00393
00394       // Perform the serialization
00395       isf = ic.Ink.Save(PersistenceFormat.InkSerializedFormat);
00396
00397             // If the first and last names were added as extended
00398             // properties to the ink, remove them - these properties
00399             // are only used for the save and there is no need to
00400             // keep them around on the ink object.
00401             if (inkProperties.DoesPropertyExist(FirstName))
00402             {
00403                 inkProperties.Remove(FirstName);
00404             }
00405             if (inkProperties.DoesPropertyExist(LastName))
00406             {
00407                 inkProperties.Remove(LastName);
00408             }
00409
00410       // Write the ISF to the stream
00411       s.Write(isf,0,isf.Length);
00412     }
00413
00414     // This function saves the form in XML format.
00415     // It uses the base64 encoded version of the ink, which is most suitable
00416     // for representation in XML. The names are stored as XML fields, rather
00417     // than custom properties, so that these properties can be most easily
00418     // accessible if the XML is saved in a database.
00419     private void SaveXML(Stream s)
00420     {
00421       // This object will encode our byte data to a UTF8 string
00422       UTF8Encoding utf8 = new UTF8Encoding();
00423
00424       byte[] base64ISF_bytes;
00425       string base64ISF_string;
00426
00427       // Create a new XmlTextWriter.
00428       XmlTextWriter xwriter = new XmlTextWriter(s, System.Text.Encoding.UTF8);
00429
00430       // Write the beginning of the document including the
00431       // document declaration.
00432       xwriter.WriteStartDocument();
00433
00434       // Write the beginning of the "data" element. This is
00435       // the opening tag to our data
00436       xwriter.WriteStartElement("SerializationSampleData");
00437
00438       // Get the base64 encoded ISF
00439       base64ISF_bytes = ic.Ink.Save(PersistenceFormat.Base64InkSerializedFormat);
00440
00441       // Convert it to a String
00442       base64ISF_string = utf8.GetString(base64ISF_bytes);
00443
00444       // Write the ISF containing node to the XML
00445       xwriter.WriteElementString("Ink", base64ISF_string);
00446
00447       // Write the text date from the form
00448             // Note that the names are stored as XML fields, rather
00449             // than custom properties, so that these properties can
00450             // be most easily accessible if the XML is saved in a database.
00451       xwriter.WriteElementString("FirstName",FirstNameBox.Text);
00452       xwriter.WriteElementString("LastName",LastNameBox.Text);
00453
00454       //End the "data" element.
00455       xwriter.WriteEndElement();
00456
00457       //End the document
00458       xwriter.WriteEndDocument();
00459
00460       //Close the xml document.
00461             xwriter.Close();
00462     }
00463
00464     // This function saves the form in HTML format.
00465     // It also creates an ink fortified GIF which is referenced by the HTML.
00466     // A fortified GIF is an image file that has ISF embedded inside it. To an
00467     // ink-unaware application, it is simply an image, but to an ink-aware
00468     // application, all of the original ink data is available.
00469     //
00470     // Please refer to the "Ink Interoperability" whitepaper for more information
00471     // on fortified GIFs.
00472     private void SaveHTML(Stream s, String nameBase)
00473     {
00474
00475             // It is not possible to save an empty .gif, so it
00476             // is first necessary to ensure that the ink has a bounding
00477             // box (i.e. the ink is not empty).  The bounding box is
00478             // used for this check instead of checking whether the stroke
00479             // count is zero, since the ink could still be empty if the
00480             // strokes don't contain any points.
00481             if (ic.Ink.Strokes.GetBoundingBox().IsEmpty)
00482             {
00483                 MessageBox.Show("Unable to save empty ink in HTML persistence format.");
00484             }
00485             else
00486             {
00487
00488                 FileStream gifFile;
00489                 byte[] fortifiedGif = null;
00490                 String html;
00491                 byte[] htmlBytes;
00492
00493                 // This object will encode our byte data to a UTF8 string
00494                 UTF8Encoding utf8 = new UTF8Encoding();
00495
00496                 // Create a directory to store the fortified GIF which also contains ISF
00497                 // and open the file for writing
00498                 Directory.CreateDirectory(nameBase + "_files");
00499                 gifFile = File.OpenWrite(nameBase + "_files\\signature.gif");
00500
00501                 // Generate the fortified GIF represenation of the ink
00502                 fortifiedGif = ic.Ink.Save(PersistenceFormat.Gif);
00503
00504                 // Write and close the gif file
00505                 gifFile.Write(fortifiedGif, 0, fortifiedGif.Length);
00506                 gifFile.Close();
00507
00508                 // Create the HTML output
00509                 // Note that the names are stored in HTML tags, rather
00510                 // than custom properties, so that these properties can
00511                 // be easily retrieved from the HTML.
00512                 html =
00513                     "<HTML><HEAD></HEAD><BODY>" +
00514
00515                     "<P>First Name: " +
00516                     FirstNameBox.Text +
00517                     " &nbsp;&nbsp;&nbsp;Last Name: " +
00518                     LastNameBox.Text +
00519                     "</P>" +
00520
00521                     "<P><IMG src='" +
00522                     nameBase + "_files\\signature.gif" +
00523                     "' /></P>" +
00524
00525                     "</BODY></HTML>";
00526
00527                 // Convert the HTML to a byte array for writing to the stream
00528                 htmlBytes = utf8.GetBytes(html);
00529
00530                 // Write the HTML to the stream
00531                 s.Write(htmlBytes, 0, htmlBytes.Length);
00532             }
00533     }
00534
00535     // This function handles the Open... command. It will determine the type of ink which is being
00536     // opened and call the appropriate helper routine.
00537     // The try...catch section in this function will handle all of the error
00538     // handling for the functions it calls.
00539     private void OpenMenu_Click(object sender, System.EventArgs e)
00540     {
00541       /// Create a stream which will be used to load data from the output file
00542       Stream myStream = null;
00543
00544       /// Create the OpenFileDialog, which presents a standard Windows
00545       /// dialog to the user.
00546       OpenFileDialog openDialog = new OpenFileDialog();
00547
00548       /// Set the filter to suggest our recommended extensions
00549       openDialog.Filter =
00550         "All Known Files (*.isf; *.xml)|*.isf; *.xml|Ink Serialized Format files (*.isf)|*.isf|" +
00551         "XML files (*.xml)|*.xml|All Files (*.*)|*.*";
00552
00553       /// If the dialog exits and the user didn't choose Cancel
00554       if(openDialog.ShowDialog() == DialogResult.OK)
00555       {
00556                 try
00557                 {
00558                     /// Attempt to Open the file with read only permission
00559                     myStream = openDialog.OpenFile();
00560                     if(myStream != null)
00561                     {
00562                         // Put the filename in a more canonical format
00563                         String filename = openDialog.FileName.ToLower();
00564
00565                         // Get the extension of the file
00566                         String extension = filename.Substring(filename.LastIndexOf('.'));
00567
00568                         // Use the extension to determine what form to save the data in
00569                         switch (extension)
00570                         {
00571                             case ".isf":
00572                                 LoadISF(myStream);
00573                                 break;
00574
00575                             case ".xml":
00576                                 LoadXML(myStream);
00577                                 break;
00578
00579                                 // If unfamiliar with the extension, assume ISF, the most "native format"
00580                             default:
00581                                 LoadISF(myStream);
00582                                 break;
00583                         }
00584                     }
00585                     else
00586                     {
00587                         // Throw an exception if a null pointer is returned for the stream
00588                         throw new IOException();
00589                     }
00590                 }
00591                 catch (IOException /*ioe*/)
00592                 {
00593                     MessageBox.Show ("File error");
00594                 }
00595                 catch
00596                 {
00597                     // If the xml or the scanned form image file are not available,
00598                     // display an error and exit
00599                     MessageBox.Show("An error occured while loading ink from the specified file.\n"+
00600                         "Please verify that the file contains valid serialized ink and try again.",
00601                         "Serialization",
00602                         MessageBoxButtons.OK);
00603                 }
00604                 finally
00605                 {
00606                     // Close the stream in the finally clause so it
00607                     // is always reached, regardless of whether an
00608                     // exception occurs.  LoadXML, LoadHTML, and
00609                     // LoadISF can throw, so this precaution is necessary.
00610                     if (null != myStream)
00611                     {
00612                         myStream.Close();
00613                     }
00614                 }
00615       }
00616     }
00617
00618     // This function will load ISF into the ink object.
00619     // It will also pull the data stored in the object's extended properties and
00620     // repopulate the text boxes.
00621     private void LoadISF(Stream s)
00622     {
00623       Ink loadedInk = new Ink();
00624       byte[] isfBytes = new byte[s.Length];
00625
00626       // read in the ISF
00627       s.Read(isfBytes, 0, (int) s.Length);
00628
00629       // load the ink into a new ink object
00630       // once an ink object has been "dirtied" it can never load ink again
00631             loadedInk.Load(isfBytes);
00632
00633       // temporarily disable the ink collector and swap ink objects
00634       ic.Enabled = false;
00635       ic.Ink = loadedInk;
00636       ic.Enabled = true;
00637
00638       // Repaint the inkable region
00639       Signature.Invalidate();
00640
00641             ExtendedProperties inkProperties = ic.Ink.ExtendedProperties;
00642
00643       // Get the raw data out of this stroke's extended
00644       // properties list, using our previously defined
00645       // Guid as a key to the extended property we want.
00646             // Since the save method stored the first and last
00647             // name information as extended propertied, we can
00648             // remove this information now that the load is complete.
00649             if (inkProperties.DoesPropertyExist(FirstName))
00650             {
00651                 FirstNameBox.Text = (String) inkProperties[FirstName].Data;
00652                 inkProperties.Remove(FirstName);
00653             }
00654             else
00655             {
00656                 FirstNameBox.Text = String.Empty;
00657             }
00658
00659       if (inkProperties.DoesPropertyExist(LastName))
00660       {
00661         LastNameBox.Text = (String) inkProperties[LastName].Data;
00662                 inkProperties.Remove(LastName);
00663       }
00664             else
00665             {
00666                 LastNameBox.Text = String.Empty;
00667             }
00668     }
00669
00670     // This function will load XML into the ink object.
00671     // It will repopulate the text boxes using the data stored in the XML.
00672     private void LoadXML(Stream s)
00673     {
00674       // This object will encode our byte data to a UTF8 string
00675       UTF8Encoding utf8 = new UTF8Encoding();
00676
00677       XmlDocument xd = new XmlDocument();
00678       XmlNodeList nodes;
00679       Ink loadedInk = new Ink();
00680
00681       // Load the XML data into an XMLDocument object
00682       xd.Load(s);
00683
00684       // Get the data in the ink node
00685       nodes = xd.GetElementsByTagName("Ink");
00686
00687       // load the ink into a new ink object
00688       // once an ink object has been "dirtied" it can never load ink again
00689             if (0 != nodes.Count)
00690             {
00691                 loadedInk.Load(utf8.GetBytes(nodes[0].InnerXml));
00692             }
00693
00694       // temporarily disable the ink collector and swap ink objects
00695       ic.Enabled = false;
00696       ic.Ink = loadedInk;
00697       ic.Enabled = true;
00698
00699             // Repaint the inkable region
00700             Signature.Invalidate();
00701
00702       // Get the data in the FirstName node
00703       nodes = xd.GetElementsByTagName("FirstName");
00704             if (0 != nodes.Count)
00705             {
00706                 FirstNameBox.Text = nodes[0].InnerXml;
00707             }
00708             else
00709             {
00710                 FirstNameBox.Text = String.Empty;
00711             }
00712
00713       // Get the data in the LastName node
00714       nodes = xd.GetElementsByTagName("LastName");
00715             if (0 != nodes.Count)
00716             {
00717                 LastNameBox.Text = nodes[0].InnerXml;
00718             }
00719             else
00720             {
00721                 LastNameBox.Text = String.Empty;
00722             }
00723     }
00724   }
00725 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCreateQueueDialog Member List

This is the complete list of members for CCreateQueueDialog, including all inherited members.
CCreateQueueDialog(CWnd *pParent=NULL) | CCreateQueueDialog |
DoDataExchange(CDataExchange *pDX) | CCreateQueueDialog | [protected, virtual]
GetLabel(TCHAR szLabelBuffer[BUFFERSIZE]) | CCreateQueueDialog | [inline]
GetPathName(TCHAR szPathNameBuffer[BUFFERSIZE]) | CCreateQueueDialog | [inline]
IDD enum value | CCreateQueueDialog |
m_strLabel | CCreateQueueDialog |
m_strPathName | CCreateQueueDialog |
Generated on Wed Nov 13 2024 16:55:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProxyPlugin::COpState Member List

This is the complete list of members for CProxyPlugin::COpState, including all inherited members.
COpState() | CProxyPlugin::COpState | [inline]
m_bstrHost | CProxyPlugin::COpState |
m_bstrOriginUrl | CProxyPlugin::COpState |
m_bstrPath | CProxyPlugin::COpState |
m_bstrProtocol | CProxyPlugin::COpState |
m_cRef | CProxyPlugin::COpState | [private]
m_dwProtocolIndex | CProxyPlugin::COpState |
m_Op | CProxyPlugin::COpState |
m_pCacheProxyCallback | CProxyPlugin::COpState |
m_pPresentationContext | CProxyPlugin::COpState |
m_varContext | CProxyPlugin::COpState |
m_wPort | CProxyPlugin::COpState |
OP_QUERY_CACHE enum value | CProxyPlugin::COpState |
OP_QUERY_CACHE_MISS_POLICY enum value | CProxyPlugin::COpState |
OpTypes enum name | CProxyPlugin::COpState |
QueryInterface(REFIID riid, void **ppvObject) | CProxyPlugin::COpState | [inline]
STDMETHOD_(ULONG, AddRef)() | CProxyPlugin::COpState | [inline]
STDMETHOD_(ULONG, Release)() | CProxyPlugin::COpState | [inline]
~COpState() | CProxyPlugin::COpState | [inline]
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/HtmlProp/FiltReg.Hxx Source File

  • WinBase
  • Indexing
  • HtmlProp

FiltReg.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (c) Microsoft Corporation. All rights reserved.
00005 //
00006 // File:        RegSrv.hxx
00007 //
00008 // Contents:    Macros for Self-registration of Filters
00009 //
00010 // Functions:   Macros to create DllRegisterServer, DllUnregisterServer
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #pragma once
00015
00016 #include <olectl.h>
00017
00018 //
00019 // Structure to define classes (.doc, .xls, etc.)
00020 //
00021
00022 struct SClassEntry
00023 {
00024     WCHAR const * pwszExt;                  // (ex: .doc)  May be null
00025     WCHAR const * pwszShortName;            // (ex: Word.Document.8)
00026     WCHAR const * pwszDescription;          // (ex: Microsoft Word Document)
00027     WCHAR const * pwszClassId;              // (ex: {00020906-0000-0000-C000-000000000046})
00028     WCHAR const * pwszClassIdDescription;   // (ex: Microsoft Word Document)
00029 };
00030
00031 //
00032 // Structure to define persistent handler entry.
00033 //
00034
00035 struct SHandlerEntry
00036 {
00037     WCHAR const * pwszClassId;
00038     WCHAR const * pwszClassIdDescription;
00039     WCHAR const * pwszClassIdFilter;
00040 };
00041
00042 //
00043 // Structure to define filter class
00044 //
00045
00046 struct SFilterEntry
00047 {
00048     WCHAR const * pwszClassId;
00049     WCHAR const * pwszClassIdDescription;
00050     WCHAR const * pwszDLL;
00051     WCHAR const * pwszThreadingModel;
00052 };
00053
00054 //
00055 // Sample use of the three structures
00056 //
00057 //
00058 // SClassEntry const aClasses[] = { { L".doc", L"Word.Document.8",
00059 //                                    L"Microsoft Word Document",
00060 //                                    L"{00020906-0000-0000-C000-000000000046}",
00061 //                                    L"Microsoft Word Document" },
00062 //
00063 //                                  { 0, L"Word.Document.6",
00064 //                                    L"Microsoft Word 6.0 - 7.0 Document",
00065 //                                    L"{00020900-0000-0000-C000-000000000046}",
00066 //                                    L"Microsoft Word 6.0 - 7.0 Document" }
00067 //                                };
00068 //
00069 // SHandlerEntry const OfficeHandler = { L"{98de59a0-d175-11cd-a7bd-00006b827d94}",
00070 //                                       L"Microsoft Office Persistent Handler",
00071 //                                       L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}" };
00072 //
00073 // SFilterEntry const OfficeFilter = { L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}",
00074 //                                     L"Microsoft Office Filter",
00075 //                                     L"OffFilt.dll",
00076 //                                     0 };
00077 //
00078
00079 //
00080 // Function prototypes
00081 //
00082
00083 inline long RegisterACLSID( SClassEntry const & Class,
00084                             WCHAR const * pwszPHandler,
00085                             WCHAR const * pwszClassId = 0,
00086                             BOOL fAppendOnly = FALSE,
00087                             BOOL fAppendDesc = TRUE );
00088
00089 inline long RegisterAClass( SClassEntry const & Class,
00090                             WCHAR const * pwszPHandler,
00091                             WCHAR const * pwszShortName = 0,
00092                             BOOL fAppendOnly = FALSE );
00093
00094 inline long RegisterAClassAndExt( SClassEntry const & Class,
00095                                   WCHAR const * pwszPHandler,
00096                                   BOOL fAppendOnly = FALSE,
00097                                   BOOL fBlastExistingPersistentHandler = TRUE );
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 //  Function:   BuildKeyValues, private
00102 //
00103 //  Effects:    Given array of key, value, key, value, ... adds the entries
00104 //              under CLSID as:
00105 //
00106 //                  Key1 : <NO NAME> Value1
00107 //                    Key2 : <NO NAME> Value2
00108 //                      :
00109 //                      :
00110 //
00111 //  Arguments:  [awszKeyValues] -- Keys and values
00112 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00113 //
00114 //  Returns:    ERROR_SUCCESS on success
00115 //
00116 //  Notes:      The *value* entries can be null, signifying no value at a
00117 //              given level.
00118 //
00119 //----------------------------------------------------------------------------
00120
00121 inline long BuildKeyValues( WCHAR const * const * awszKeyValues, unsigned cKeyValues )
00122 {
00123     WCHAR wcTemp[MAX_PATH];
00124     wcscpy( wcTemp, L"CLSID" );
00125
00126     long dwError;
00127     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00128     unsigned i = 0;
00129
00130     do
00131     {
00132         if ( INVALID_HANDLE_VALUE != hKey )
00133         {
00134             RegCloseKey( hKey );
00135             hKey = (HKEY)INVALID_HANDLE_VALUE;
00136         }
00137
00138         wcscat( wcTemp, L"\\" );
00139         wcscat( wcTemp, awszKeyValues[i] );
00140
00141         DWORD  dwDisposition;
00142
00143         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00144                                    wcTemp,               // Sub key
00145                                    0,                    // Reserved
00146                                    0,                    // Class
00147                                    0,                    // Flags
00148                                    KEY_ALL_ACCESS,       // Access
00149                                    0,                    // Security
00150                                    &hKey,                // Handle
00151                                    &dwDisposition );     // Disposition
00152
00153         if ( ERROR_SUCCESS != dwError )
00154             break;
00155
00156         i++;
00157
00158         if ( 0 != awszKeyValues[i] )
00159             dwError = RegSetValueExW( hKey,                     // Key
00160                                       0,                        // Name
00161                                       0,                        // Reserved
00162                                       REG_SZ,                   // Type
00163                                       (BYTE *)awszKeyValues[i], // Value
00164                                       (DWORD) ( (1 + wcslen(awszKeyValues[i]) ) * sizeof(WCHAR) ) );
00165
00166         if ( ERROR_SUCCESS != dwError )
00167             break;
00168
00169         i++;
00170     }
00171     while ( i < cKeyValues );
00172
00173     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00174         RegCloseKey( hKey );
00175
00176     return dwError;
00177 }
00178
00179 //+---------------------------------------------------------------------------
00180 //
00181 //  Function:   AddThreadingModel
00182 //
00183 //  Synopsis:   Adds the threading model value to the CLSID\\GUID\\InProcServer32
00184 //              key
00185 //
00186 //  Arguments:  [wszClsId] - ClassId of the inproc server.
00187 //              [wszThreadingModel] -- 0 (for single threaded) or one of
00188 //                                     Apartment, Free, or Both
00189 //
00190 //  History:    3-07-97   srikants   Created
00191 //
00192 //----------------------------------------------------------------------------
00193
00194 inline long AddThreadingModel( WCHAR const * wszClsId,
00195                                WCHAR const * wszThreadingModel )
00196 {
00197     WCHAR wcTemp[MAX_PATH];
00198     wcscpy( wcTemp, L"CLSID" );
00199     wcscat( wcTemp, L"\\" );
00200     wcscat( wcTemp, wszClsId );
00201     wcscat( wcTemp, L"\\" );
00202     wcscat( wcTemp, L"InprocServer32" );
00203
00204     long dwError;
00205     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00206     unsigned i = 0;
00207
00208     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00209                              wcTemp,               // Sub key
00210                              0,                    // Reserved
00211                              KEY_ALL_ACCESS,       // Access
00212                              &hKey );              // Handle
00213
00214     if ( ERROR_SUCCESS != dwError )
00215         return dwError;
00216
00217     if ( 0 != wszThreadingModel )
00218         dwError = RegSetValueExW( hKey,                   // Key
00219                                   L"ThreadingModel",      // Name
00220                                   0,                      // Reserved
00221                                   REG_SZ,                 // Type
00222                                   (BYTE *) wszThreadingModel,  // Value
00223                                   (DWORD) ( (wcslen(wszThreadingModel) + 1) * sizeof WCHAR ) );
00224     else
00225         RegDeleteValueW( hKey,                   // Key
00226                          L"ThreadingModel" );    // Name
00227
00228     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00229         RegCloseKey( hKey );
00230
00231     return dwError;
00232 }
00233
00234 //+---------------------------------------------------------------------------
00235 //
00236 //  Function:   DestroyKeyValues, private
00237 //
00238 //  Effects:    Given array of key, value, key, value from AddKeyValues,
00239 //              removes the keys.
00240 //
00241 //  Arguments:  [awszKeyValues] -- Keys and values
00242 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00243 //
00244 //  Returns:    ERROR_SUCCESS on success
00245 //
00246 //----------------------------------------------------------------------------
00247
00248 inline long DestroyKeyValues( WCHAR const * const * awszKeyValues, int cKeyValues )
00249 {
00250     WCHAR wcTemp[MAX_PATH];
00251
00252     //
00253     // Build path to deepest component
00254     //
00255
00256     wcscpy( wcTemp, L"CLSID" );
00257     int i = 0;
00258
00259     do
00260     {
00261         wcscat( wcTemp, L"\\" );
00262         wcscat( wcTemp, awszKeyValues[i] );
00263
00264         i += 2;
00265     }
00266     while ( i < cKeyValues );
00267
00268     //
00269     // Remove components in reverse order
00270     //
00271
00272     long dwError = ERROR_SUCCESS;
00273     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00274
00275     unsigned cc = (unsigned) wcslen( wcTemp );
00276
00277     for ( i -= 2; i >= 0; i -= 2 )
00278     {
00279         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00280                                  wcTemp,               // Sub key
00281                                  0,                    // Reserved
00282                                  KEY_ALL_ACCESS,       // Access
00283                                  &hKey );              // Handle
00284
00285         if ( ERROR_SUCCESS != dwError )
00286             break;
00287
00288         #if 0  // Values deleted by RegDeleteKeyW
00289         //
00290         // Delete value, if there is one.
00291         //
00292
00293         if ( 0 != awszKeyValues[i+1] )
00294             dwError = RegDeleteValueW( hKey, 0 );
00295
00296         if ( ERROR_SUCCESS != dwError )
00297             break;
00298         #endif // 0
00299
00300         //
00301         // Delete subkey, if there is one.
00302         //
00303
00304         if ( i+2 < cKeyValues )
00305             dwError = RegDeleteKeyW( hKey, awszKeyValues[i+2] );
00306
00307         if ( ERROR_SUCCESS != dwError )
00308             break;
00309
00310         //
00311         // Close key and truncate string to next component.
00312         //
00313
00314         if ( INVALID_HANDLE_VALUE != hKey )
00315         {
00316             RegCloseKey( hKey );
00317             hKey = (HKEY)INVALID_HANDLE_VALUE;
00318         }
00319
00320         cc -= (unsigned) wcslen( awszKeyValues[i] );
00321         cc--;
00322
00323         wcTemp[cc] = 0;
00324     }
00325
00326     //
00327     // Remove the final top key
00328     //
00329
00330     if ( ERROR_SUCCESS == dwError )
00331     {
00332         do
00333         {
00334             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00335                                      wcTemp,               // Sub key -- "CLSID"
00336                                      0,                    // Reserved
00337                                      KEY_ALL_ACCESS,       // Access
00338                                      &hKey );              // Handle
00339
00340             if ( ERROR_SUCCESS != dwError )
00341                 break;
00342
00343             //
00344             // Delete subkey
00345             //
00346
00347             dwError = RegDeleteKeyW( hKey, awszKeyValues[0] );
00348
00349         } while ( FALSE );
00350     }
00351
00352     return dwError;
00353 }
00354
00355 //+---------------------------------------------------------------------------
00356 //
00357 //  Function:   RegisterAClassAndExt, private
00358 //
00359 //  Synopsis:   Registers a class, extensions (optional) and a persistent handler.
00360 //
00361 //  Arguments:  [Class]        -- Class description
00362 //              [pwszPHandler] -- Persistent handler for class
00363 //
00364 //  Returns:    ERROR_SUCCESS on success
00365 //
00366 //  Notes:      Class is only registered if similar class does not already
00367 //              exist.  Persistent handler is always registered for class.
00368 //
00369 //----------------------------------------------------------------------------
00370
00371 inline long RegisterAClassAndExt( SClassEntry const & Class,
00372                                   WCHAR const * pwszPHandler,
00373                                   BOOL fAppendOnly,
00374                                   BOOL fBlastExistingPersistentHandler )
00375 {
00376     WCHAR wcTemp[MAX_PATH];
00377
00378     long dwError = NO_ERROR;
00379     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00380
00381     do
00382     {
00383         //
00384         // First, the optional extension entry
00385         //
00386
00387         DWORD dwDisposition;
00388         DWORD dwType;
00389         DWORD dwSize;
00390
00391         if ( 0 == Class.pwszExt )
00392         {
00393             //
00394             // Build up named entry
00395             //
00396
00397             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00398                 return ERROR_INSUFFICIENT_BUFFER;
00399
00400             wcscpy( wcTemp, Class.pwszShortName );
00401         }
00402         else
00403         {
00404             if ( wcslen( Class.pwszExt ) >= MAX_PATH )
00405                 return ERROR_INSUFFICIENT_BUFFER;
00406
00407             wcscpy( wcTemp, Class.pwszExt );
00408
00409             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00410                                        wcTemp,               // Sub key
00411                                        0,                    // Reserved
00412                                        0,                    // Class
00413                                        0,                    // Flags
00414                                        KEY_ALL_ACCESS,       // Access
00415                                        0,                    // Security
00416                                        &hKey,                // Handle
00417                                        &dwDisposition );     // Disposition
00418             if ( ERROR_SUCCESS != dwError )
00419                 break;
00420
00421             //
00422             // Write or read class association
00423             //
00424
00425             BOOL fSetValue = TRUE;
00426
00427             if ( REG_OPENED_EXISTING_KEY == dwDisposition )
00428             {
00429                 dwSize = sizeof(wcTemp);
00430
00431                 dwError = RegQueryValueExW( hKey,            // Key handle
00432                                             0,               // Name
00433                                             0,               // Reserved
00434                                             &dwType,         // Datatype
00435                                             (BYTE *)wcTemp,  // Data returned here
00436                                             &dwSize );       // Size of data
00437
00438                 if ( ERROR_SUCCESS == dwError )
00439                 {
00440                     fSetValue = FALSE;
00441
00442                     if ( REG_SZ != dwType )
00443                         dwError = E_FAIL;
00444                 }
00445                 else if ( ERROR_FILE_NOT_FOUND == dwError )
00446                 {
00447                     //
00448                     // This is ok, but we need to remember that the
00449                     // combination of wcTemp[0] == 0 && fAppendOnly means
00450                     // don't try to register the class.
00451                     //
00452
00453                     wcTemp[0] = 0;
00454                     dwError = ERROR_SUCCESS;
00455                 }
00456             }
00457
00458             if ( fSetValue && !fAppendOnly )
00459             {
00460                 dwError = RegSetValueExW( hKey,                        // Key
00461                                           0,                           // Name
00462                                           0,                           // Reserved
00463                                           REG_SZ,                      // Type
00464                                           (BYTE *)Class.pwszShortName, // Value
00465                                           (DWORD) ( (1 + wcslen(Class.pwszShortName) ) * sizeof(WCHAR) ) );
00466
00467                 wcTemp[0] = 0;
00468             }
00469
00470             if ( ERROR_SUCCESS != dwError )
00471                 break;
00472
00473             //
00474             // Write the persistent handler key
00475             //
00476
00477             HKEY hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00478
00479             dwError = RegCreateKeyExW( hKey,                 // Root
00480                                        L"PersistentHandler", // Sub key
00481                                        0,                    // Reserved
00482                                        0,                    // Class
00483                                        0,                    // Flags
00484                                        KEY_ALL_ACCESS,       // Access
00485                                        0,                    // Security
00486                                        &hKey2,               // Handle
00487                                        &dwDisposition );     // Disposition
00488
00489             if ( ERROR_SUCCESS != dwError )
00490                 break;
00491
00492             if ( fBlastExistingPersistentHandler ||
00493                  ( REG_OPENED_EXISTING_KEY != dwDisposition ) )
00494                 dwError = RegSetValueExW( hKey2,                 // Key
00495                                           0,                     // Name
00496                                           0,                     // Reserved
00497                                           REG_SZ,                // Type
00498                                           (BYTE *)pwszPHandler,  // Value
00499                                           (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00500
00501             if ( (HKEY)INVALID_HANDLE_VALUE != hKey2 )
00502             {
00503                 RegCloseKey( hKey2 );
00504                 hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00505             }
00506         }
00507
00508         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00509         {
00510             RegCloseKey( hKey );
00511             hKey = (HKEY)INVALID_HANDLE_VALUE;
00512         }
00513
00514         if ( ERROR_SUCCESS != dwError )
00515             break;
00516
00517         //
00518         // Here, wcTemp may contain the key name for the named entry (ex: Word.Document.8)
00519         //
00520
00521         if ( wcTemp[0] != 0 || !fAppendOnly )
00522             dwError = RegisterAClass( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00523
00524     } while( FALSE );
00525
00526     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00527     {
00528         RegCloseKey( hKey );
00529         hKey = (HKEY)INVALID_HANDLE_VALUE;
00530     }
00531
00532     return dwError;
00533 }
00534
00535 //+---------------------------------------------------------------------------
00536 //
00537 //  Function:   RegisterAClass, private
00538 //
00539 //  Synopsis:   Registers a class and a persistent handler.
00540 //
00541 //  Arguments:  [Class]        -- Class description
00542 //              [pwszPHandler] -- Persistent handler for class
00543 //              [pwszClass]    -- If non 0, used instead of class from [Class]
00544 //
00545 //  Returns:    ERROR_SUCCESS on success
00546 //
00547 //  Notes:      Class is only registered if similar class does not already
00548 //              exist.  Persistent handler is always registered for class.
00549 //
00550 //----------------------------------------------------------------------------
00551
00552 inline long RegisterAClass( SClassEntry const & Class,
00553                             WCHAR const * pwszPHandler,
00554                             WCHAR const * pwszShortName,
00555                             BOOL fAppendOnly )
00556 {
00557     WCHAR wcTemp[MAX_PATH];
00558
00559     long dwError;
00560     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00561
00562     if ( 0 == pwszShortName )
00563     {
00564         if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00565             return ERROR_INSUFFICIENT_BUFFER;
00566
00567         wcscpy( wcTemp, Class.pwszShortName );
00568     }
00569     else
00570     {
00571         if ( wcslen( pwszShortName ) >= MAX_PATH )
00572             return ERROR_INSUFFICIENT_BUFFER;
00573
00574         wcscpy( wcTemp, pwszShortName );
00575     }
00576
00577     do
00578     {
00579         DWORD dwDisposition;
00580         DWORD dwType;
00581         DWORD dwSize;
00582
00583         //
00584         // Here, wcTemp contains the key name for the named entry (ex: Word.Document.8)
00585         //
00586
00587         if ( fAppendOnly )
00588         {
00589             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00590                                      wcTemp,               // Sub key
00591                                      0,                    // Reserved
00592                                      KEY_ALL_ACCESS,       // Access
00593                                      &hKey );              // Handle
00594
00595             if ( ERROR_SUCCESS != dwError)
00596             {
00597                 //
00598                 // Not opening the key at all is legit.
00599                 //
00600
00601                 if ( ERROR_FILE_NOT_FOUND == dwError )
00602                     dwError = ERROR_SUCCESS;
00603
00604                 break;
00605             }
00606
00607             dwDisposition = REG_OPENED_EXISTING_KEY;
00608         }
00609         else
00610         {
00611             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00612                                        wcTemp,               // Sub key
00613                                        0,                    // Reserved
00614                                        0,                    // Class
00615                                        0,                    // Flags
00616                                        KEY_ALL_ACCESS,       // Access
00617                                        0,                    // Security
00618                                        &hKey,                // Handle
00619                                        &dwDisposition );     // Disposition
00620
00621             if ( ERROR_SUCCESS != dwError )
00622                 break;
00623         }
00624
00625         //
00626         // If needed, write the description, but only for non-overrides.
00627         //
00628
00629         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszShortName )
00630         {
00631             dwError = RegSetValueExW( hKey,                          // Key
00632                                       0,                             // Name
00633                                       0,                             // Reserved
00634                                       REG_SZ,                        // Type
00635                                       (BYTE *)Class.pwszDescription, // Value
00636                                       (DWORD) ( (1 + wcslen(Class.pwszDescription) ) * sizeof(WCHAR) ) );
00637
00638             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00639                 return ERROR_INSUFFICIENT_BUFFER;
00640
00641             wcscpy( wcTemp, Class.pwszShortName );
00642
00643             if ( ERROR_SUCCESS != dwError )
00644                 break;
00645         }
00646
00647         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00648         {
00649             RegCloseKey( hKey );
00650             hKey = (HKEY)INVALID_HANDLE_VALUE;
00651         }
00652
00653         //
00654         // Write or read ClassId
00655         //
00656
00657         wcscat( wcTemp, L"\\CLSID" );
00658
00659         if ( fAppendOnly )
00660         {
00661             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00662                                      wcTemp,               // Sub key
00663                                      0,                    // Reserved
00664                                      KEY_ALL_ACCESS,       // Access
00665                                      &hKey );              // Handle
00666
00667             if ( ERROR_SUCCESS != dwError)
00668             {
00669                 //
00670                 // Not opening the key at all is legit.
00671                 //
00672
00673                 if ( ERROR_FILE_NOT_FOUND == dwError )
00674                     dwError = ERROR_SUCCESS;
00675
00676                 break;
00677             }
00678
00679             dwDisposition = REG_OPENED_EXISTING_KEY;
00680         }
00681         else
00682         {
00683             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00684                                        wcTemp,               // Sub key
00685                                        0,                    // Reserved
00686                                        0,                    // Class
00687                                        0,                    // Flags
00688                                        KEY_ALL_ACCESS,       // Access
00689                                        0,                    // Security
00690                                        &hKey,                // Handle
00691                                        &dwDisposition );     // Disposition
00692
00693             if ( ERROR_SUCCESS != dwError )
00694                 break;
00695         }
00696
00697         dwSize = sizeof(wcTemp);
00698
00699         dwError = RegQueryValueExW( hKey,                // Key handle
00700                                     0,                   // Name
00701                                     0,                   // Reserved
00702                                     &dwType,             // Datatype
00703                                     (BYTE *)(wcTemp),    // Data returned here
00704                                     &dwSize );           // Size of data
00705
00706         if ( ERROR_SUCCESS != dwError )
00707         {
00708             if ( ERROR_FILE_NOT_FOUND == dwError )
00709             {
00710                 //
00711                 // Don't set a class id in append mode.
00712                 //
00713
00714                 if ( fAppendOnly )
00715                 {
00716                     dwError = ERROR_SUCCESS;
00717                     break;
00718                 }
00719
00720                 dwError = RegSetValueExW( hKey,                          // Key
00721                                           0,                             // Name
00722                                           0,                             // Reserved
00723                                           REG_SZ,                        // Type
00724                                           (BYTE *)Class.pwszClassId,     // Value
00725                                           (DWORD) ( (1 + wcslen(Class.pwszClassId) ) * sizeof(WCHAR) ) );
00726
00727                 wcTemp[0] = 0; // Default to class from Class structure
00728
00729                 if ( ERROR_SUCCESS != dwError )
00730                     break;
00731             }
00732             else
00733                 break;
00734         }
00735         else
00736         {
00737             if ( REG_SZ != dwType )
00738                 dwError = E_FAIL;
00739         }
00740
00741         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00742         {
00743             RegCloseKey( hKey );
00744             hKey = (HKEY)INVALID_HANDLE_VALUE;
00745         }
00746
00747         if ( ERROR_SUCCESS != dwError )
00748             break;
00749
00750         //
00751         // Here, wcTemp contains the {class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00752         //
00753
00754         dwError = RegisterACLSID( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00755
00756     } while( FALSE );
00757
00758     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00759     {
00760         RegCloseKey( hKey );
00761         hKey = (HKEY)INVALID_HANDLE_VALUE;
00762     }
00763
00764     return dwError;
00765 }
00766
00767 //+---------------------------------------------------------------------------
00768 //
00769 //  Function:   RegisterACLSID, private
00770 //
00771 //  Synopsis:   Registers a CLSID / persistent handler.
00772 //
00773 //  Arguments:  [Class]        -- Class description
00774 //              [pwszPHandler] -- Persistent handler for class
00775 //              [pwszClassId]  -- If non 0, used instead of class id from [Class]
00776 //              [fAppendOnly]  -- TRUE --> CLSID should not be created
00777 //              [fAppendDesc]  -- TRUE --> Class description should be added.
00778 //                                         Only applies if [fAppendOnly] is FALSE
00779 //
00780 //  Returns:    ERROR_SUCCESS on success
00781 //
00782 //  Notes:      Class id is only registered if similar class does not already
00783 //              exist.  Persistent handler is always registered for class.
00784 //
00785 //----------------------------------------------------------------------------
00786
00787 inline long RegisterACLSID( SClassEntry const & Class,
00788                             WCHAR const * pwszPHandler,
00789                             WCHAR const * pwszClassId,
00790                             BOOL fAppendOnly,
00791                             BOOL fAppendDesc )
00792 {
00793     WCHAR wcTemp[MAX_PATH];
00794
00795     long dwError;
00796     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00797
00798     wcscpy( wcTemp, L"CLSID\\" );
00799
00800     if ( 0 == pwszClassId )
00801         wcscat( wcTemp, Class.pwszClassId );
00802     else
00803         wcscat( wcTemp, pwszClassId );
00804
00805     do
00806     {
00807         DWORD dwDisposition;
00808
00809         //
00810         // Here, wcTemp contains the CLSID\{class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00811         //
00812
00813         if ( fAppendOnly )
00814         {
00815             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00816                                      wcTemp,               // Sub key
00817                                      0,                    // Reserved
00818                                      KEY_ALL_ACCESS,       // Access
00819                                      &hKey );              // Handle
00820
00821             if ( ERROR_SUCCESS != dwError)
00822             {
00823                 //
00824                 // Not opening the key at all is legit.
00825                 //
00826
00827                 if ( ERROR_FILE_NOT_FOUND == dwError )
00828                     dwError = ERROR_SUCCESS;
00829
00830                 break;
00831             }
00832
00833             dwDisposition = REG_OPENED_EXISTING_KEY;
00834         }
00835         else
00836         {
00837             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00838                                        wcTemp,               // Sub key
00839                                        0,                    // Reserved
00840                                        0,                    // Class
00841                                        0,                    // Flags
00842                                        KEY_ALL_ACCESS,       // Access
00843                                        0,                    // Security
00844                                        &hKey,                // Handle
00845                                        &dwDisposition );     // Disposition
00846         }
00847
00848         if ( ERROR_SUCCESS != dwError )
00849             break;
00850
00851         //
00852         // If needed, write the description, but not for override class.
00853         //
00854
00855         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszClassId && fAppendDesc )
00856         {
00857             dwError = RegSetValueExW( hKey,                                 // Key
00858                                       0,                                    // Name
00859                                       0,                                    // Reserved
00860                                       REG_SZ,                               // Type
00861                                       (BYTE *)Class.pwszClassIdDescription, // Value
00862                                       (DWORD) ( (1 + wcslen(Class.pwszClassIdDescription) ) * sizeof(WCHAR) ) );
00863
00864             if ( ERROR_SUCCESS != dwError )
00865                 break;
00866         }
00867
00868         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00869         {
00870             RegCloseKey( hKey );
00871             hKey = (HKEY)INVALID_HANDLE_VALUE;
00872         }
00873
00874         //
00875         // Always write persistent handler.
00876         //
00877
00878         wcscat( wcTemp, L"\\PersistentHandler" );
00879
00880         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00881                                    wcTemp,               // Sub key
00882                                    0,                    // Reserved
00883                                    0,                    // Class
00884                                    0,                    // Flags
00885                                    KEY_ALL_ACCESS,       // Access
00886                                    0,                    // Security
00887                                    &hKey,                // Handle
00888                                    &dwDisposition );     // Disposition
00889
00890         if ( ERROR_SUCCESS != dwError )
00891             break;
00892
00893         dwError = RegSetValueExW( hKey,                  // Key
00894                                   0,                     // Name
00895                                   0,                     // Reserved
00896                                   REG_SZ,                // Type
00897                                   (BYTE *)pwszPHandler,  // Value
00898                                   (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00899
00900     } while( FALSE );
00901
00902     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00903     {
00904         RegCloseKey( hKey );
00905         hKey = (HKEY)INVALID_HANDLE_VALUE;
00906     }
00907
00908     return dwError;
00909 }
00910
00911 //+---------------------------------------------------------------------------
00912 //
00913 //  Function:   RemoveAClassName, private
00914 //
00915 //  Synopsis:   Removes all references to class name (ex: Word.Document.8)
00916 //
00917 //  Arguments:  [pwszClass] -- Class Name
00918 //
00919 //  Returns:    ERROR_SUCCESS on success
00920 //
00921 //----------------------------------------------------------------------------
00922
00923 inline long RemoveAClassName( WCHAR * pwszClass )
00924 {
00925     //
00926     // First, delete class name entry.
00927     //
00928
00929     long dwEnum = ERROR_SUCCESS;    // The enumerator
00930     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
00931
00932     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
00933
00934     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00935                                   0,                    // Sub key
00936                                   0,                    // Reserved
00937                                   KEY_ALL_ACCESS,       // Access
00938                                   &hKeyEnum );          // Handle
00939
00940
00941     if ( ERROR_SUCCESS == dwError )
00942     {
00943         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClass );
00944
00945         //
00946         // Now enumerate all classes entries, looking for the clsid
00947         //
00948
00949         DWORD dwIndex = 0;
00950
00951         while ( ERROR_SUCCESS == dwEnum )
00952         {
00953             WCHAR wcTemp[MAX_PATH];
00954             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
00955             FILETIME ftUnused;
00956
00957             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
00958                                     dwIndex,                // Index of registry subkey
00959                                     wcTemp,                 // Buffer for name
00960                                     &dwSize,                // Size of buffer / key
00961                                     0,                      // Reserved
00962                                     0,                      // Class (unused)
00963                                     0,                      // Class size (unused)
00964                                     &ftUnused );            // Filetime (unused)
00965
00966             dwIndex++;
00967
00968             if ( ERROR_SUCCESS == dwEnum )
00969             {
00970                 HKEY hKey;
00971
00972                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00973                                          wcTemp,               // Sub key
00974                                          0,                    // Reserved
00975                                          KEY_ALL_ACCESS,       // Access
00976                                          &hKey );              // Handle
00977
00978                 if ( ERROR_SUCCESS == dwError )
00979                 {
00980                     WCHAR wcTemp2[MAX_PATH];
00981                     DWORD dwType;
00982
00983                     dwSize = sizeof(wcTemp2);
00984
00985                     dwError = RegQueryValueExW( hKey,                // Key handle
00986                                                 0,                   // Name
00987                                                 0,                   // Reserved
00988                                                 &dwType,             // Datatype
00989                                                 (BYTE *)wcTemp2,     // Data returned here
00990                                                 &dwSize );           // Size of data
00991
00992                     RegCloseKey( hKey );
00993
00994                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClass ) )
00995                     {
00996                         //
00997                         // Always delete the value
00998                         //
00999
01000                         if ( ERROR_SUCCESS == dwIgnore )
01001                             dwIgnore = RegDeleteValueW( hKey, 0 );
01002                         else
01003                             RegDeleteValueW( hKey, 0 );
01004
01005                         //
01006                         // Any other key(s)?
01007                         //
01008
01009                         dwSize = sizeof(wcTemp) / sizeof wcTemp[0];
01010
01011                         DWORD dw2 = RegEnumKeyExW( hKey,                   // Handle of key
01012                                                    0,                      // Index of registry subkey
01013                                                    wcTemp,                 // Buffer for name
01014                                                    &dwSize,                // Size of buffer / key
01015                                                    0,                      // Reserved
01016                                                    0,                      // Class (unused)
01017                                                    0,                      // Class size (unused)
01018                                                    &ftUnused );            // Filetime (unused)
01019
01020                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01021                         {
01022                             if ( ERROR_SUCCESS == dwIgnore )
01023                                 dwIgnore = RegDeleteKeyW( hKeyEnum, wcTemp );
01024                             else
01025                                 RegDeleteKeyW( hKeyEnum, wcTemp );
01026
01027                             dwIndex = 0;
01028                         }
01029
01030                     }
01031                     else
01032                         dwError = ERROR_SUCCESS;  // Just didn't have a null key (or no match)
01033                 }
01034             }
01035         }
01036     }
01037
01038     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01039         dwError = dwEnum;
01040
01041     if ( ERROR_SUCCESS != dwError )
01042         return dwError;
01043     else
01044         return dwIgnore;
01045 }
01046
01047 //+---------------------------------------------------------------------------
01048 //
01049 //  Function:   RemoveAClass, private
01050 //
01051 //  Synopsis:   Removes all references to class
01052 //
01053 //  Arguments:  [pwszClass] -- Class
01054 //
01055 //  Returns:    ERROR_SUCCESS on success
01056 //
01057 //----------------------------------------------------------------------------
01058
01059 inline long RemoveAClass( WCHAR * pwszClassId )
01060 {
01061     //
01062     // First, delete class entry.
01063     //
01064
01065     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
01066     long dwEnum = ERROR_SUCCESS;    // For enumerator
01067
01068     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01069
01070     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01071                                   L"CLSID",             // Sub key
01072                                   0,                    // Reserved
01073                                   KEY_ALL_ACCESS,       // Access
01074                                   &hKeyEnum );          // Handle
01075
01076     if ( ERROR_SUCCESS == dwError )
01077     {
01078         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClassId );
01079
01080         RegCloseKey( hKeyEnum );
01081
01082         long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01083                                       0,                    // Sub key
01084                                       0,                    // Reserved
01085                                       KEY_ALL_ACCESS,       // Access
01086                                       &hKeyEnum );          // Handle
01087     }
01088
01089     if ( ERROR_SUCCESS == dwError )
01090     {
01091         //
01092         // Now enumerate all classes entries, looking for the clsid
01093         //
01094
01095         DWORD dwIndex = 0;
01096
01097         while ( ERROR_SUCCESS == dwEnum )
01098         {
01099             WCHAR wcTemp[MAX_PATH];
01100             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01101             FILETIME ftUnused;
01102
01103             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01104                                     dwIndex,                // Index of registry subkey
01105                                     wcTemp,                 // Buffer for name
01106                                     &dwSize,                // Size of buffer / key
01107                                     0,                      // Reserved
01108                                     0,                      // Class (unused)
01109                                     0,                      // Class size (unused)
01110                                     &ftUnused );            // Filetime (unused)
01111
01112             dwIndex++;
01113
01114             if ( ERROR_SUCCESS == dwEnum )
01115             {
01116                 wcscat( wcTemp, L"\\CLSID" );
01117
01118                 HKEY hKey;
01119
01120                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01121                                          wcTemp,               // Sub key
01122                                          0,                    // Reserved
01123                                          KEY_ALL_ACCESS,       // Access
01124                                          &hKey );              // Handle
01125
01126                 if ( ERROR_SUCCESS == dwError )
01127                 {
01128                     WCHAR wcTemp2[MAX_PATH];
01129                     DWORD dwType;
01130
01131                     dwSize = sizeof(wcTemp2);
01132
01133                     dwError = RegQueryValueExW( hKey,                // Key handle
01134                                                 0,                   // Name
01135                                                 0,                   // Reserved
01136                                                 &dwType,             // Datatype
01137                                                 (BYTE *)wcTemp2,     // Data returned here
01138                                                 &dwSize );           // Size of data
01139
01140                     RegCloseKey( hKey );
01141
01142                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClassId ) )
01143                     {
01144                         wcTemp[ wcslen(wcTemp) - wcslen( L"\\CLSID" ) ] = 0;
01145
01146                         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01147                                                  wcTemp,               // Sub key
01148                                                  0,                    // Reserved
01149                                                  KEY_ALL_ACCESS,       // Access
01150                                                  &hKey );              // Handle
01151
01152                         if ( ERROR_SUCCESS == dwError )
01153                         {
01154                             if ( ERROR_SUCCESS == dwIgnore )
01155                                 dwIgnore = RegDeleteKeyW( hKey, L"CLSID" );
01156                             else
01157                                 RegDeleteKeyW( hKey, L"CLSID" );
01158
01159                             dwIndex = 0;
01160                         }
01161
01162                         //
01163                         // If there are no more entries, then the class name can be deleted
01164                         //
01165
01166                         dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01167
01168                         long dw2 = RegEnumKeyExW( hKey,               // Handle of key
01169                                                   0,                  // Index of registry subkey
01170                                                   wcTemp,             // Buffer for name
01171                                                   &dwSize,            // Size of buffer / key
01172                                                   0,                  // Reserved
01173                                                   0,                  // Class (unused)
01174                                                   0,                  // Class size (unused)
01175                                                   &ftUnused );        // Filetime (unused)
01176
01177                         RegCloseKey( hKey );
01178
01179                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01180                             RemoveAClassName( wcTemp );
01181                     }
01182                 }
01183                 else
01184                     dwError = ERROR_SUCCESS;  // Just didn't have CLSID
01185             }
01186         }
01187     }
01188
01189     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01190         dwError = dwEnum;
01191
01192     if ( ERROR_SUCCESS != dwError )
01193         return dwError;
01194     else
01195         return dwIgnore;
01196 }
01197
01198 //+---------------------------------------------------------------------------
01199 //
01200 //  Function:   RegisterAHandler, private
01201 //
01202 //  Synopsis:   Registers a persistent handler in registry
01203 //
01204 //  Arguments:  [Handler] -- Persistent handler
01205 //
01206 //  Returns:    ERROR_SUCCESS on success
01207 //
01208 //----------------------------------------------------------------------------
01209
01210 inline long RegisterAHandler( SHandlerEntry const & Handler )
01211 {
01212     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01213                                     Handler.pwszClassIdDescription,
01214                                     L"PersistentAddinsRegistered",
01215                                     0,
01216                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01217                                     Handler.pwszClassIdFilter };
01218
01219     return BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01220 }
01221
01222 //+---------------------------------------------------------------------------
01223 //
01224 //  Function:   RegisterAFilter, private
01225 //
01226 //  Synopsis:   Registers a filter in registry
01227 //
01228 //  Arguments:  [Filter] -- IFilter implementation
01229 //
01230 //  Returns:    ERROR_SUCCESS on success
01231 //
01232 //----------------------------------------------------------------------------
01233
01234 inline long RegisterAFilter( SFilterEntry const & Filter )
01235 {
01236     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01237                                     Filter.pwszClassIdDescription,
01238                                     L"InprocServer32",
01239                                     Filter.pwszDLL };
01240
01241     long retVal = BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01242     if ( ERROR_SUCCESS == retVal )
01243         retVal = AddThreadingModel( Filter.pwszClassId, Filter.pwszThreadingModel );
01244
01245     return retVal;
01246 }
01247
01248 //+---------------------------------------------------------------------------
01249 //
01250 //  Function:   UnRegisterAHandler, private
01251 //
01252 //  Synopsis:   Unregisters a persistent handler, including class entries.
01253 //
01254 //  Arguments:  [Handler] -- Persistent handler
01255 //
01256 //  Returns:    ERROR_SUCCESS on success
01257 //
01258 //----------------------------------------------------------------------------
01259
01260 inline long UnRegisterAHandler( SHandlerEntry const & Handler )
01261 {
01262     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01263                                     Handler.pwszClassIdDescription,
01264                                     L"PersistentAddinsRegistered",
01265                                     0,
01266                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01267                                     Handler.pwszClassIdFilter };
01268
01269     //
01270     // dwIgnore is used to record non-fatal errors
01271     //
01272
01273     long dwIgnore = DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01274     long dwError = ERROR_SUCCESS;
01275
01276     //
01277     // Now, enumerate all classes and delete any persistent handler entries.
01278     //
01279
01280     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01281
01282     long dwEnum = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01283                                  L"CLSID",              // Sub key
01284                                  0,                    // Reserved
01285                                  KEY_ALL_ACCESS,       // Access
01286                                  &hKeyEnum );          // Handle
01287
01288     DWORD dwIndex = 0;
01289
01290     while ( ERROR_SUCCESS == dwEnum )
01291     {
01292         WCHAR wcTemp[MAX_PATH];
01293
01294         wcscpy( wcTemp, L"CLSID\\" );
01295         unsigned cc = (unsigned) wcslen( wcTemp );
01296
01297         DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]) - cc;
01298         FILETIME ftUnused;
01299
01300         dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01301                                 dwIndex,                // Index of registry subkey
01302                                 wcTemp + cc,            // Buffer for name
01303                                 &dwSize,                // Size of buffer / key
01304                                 0,                      // Reserved
01305                                 0,                      // Class (unused)
01306                                 0,                      // Class size (unused)
01307                                 &ftUnused );            // Filetime (unused)
01308
01309         dwIndex++;
01310
01311         //
01312         // Does the key have a persistent handler?
01313         //
01314
01315         if ( ERROR_SUCCESS == dwEnum )
01316         {
01317             wcscat( wcTemp, L"\\PersistentHandler" );
01318
01319             HKEY hKey;
01320
01321             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01322                                      wcTemp,               // Sub key
01323                                      0,                    // Reserved
01324                                      KEY_ALL_ACCESS,       // Access
01325                                      &hKey );              // Handle
01326
01327             if ( ERROR_SUCCESS == dwError )
01328             {
01329                 //
01330                 // Is this the persistent handler we're looking for?
01331                 //
01332
01333                 WCHAR wcTemp2[MAX_PATH];
01334                 DWORD dwType;
01335
01336                 dwSize = sizeof(wcTemp2);
01337
01338                 dwError = RegQueryValueExW( hKey,                // Key handle
01339                                             0,                   // Name
01340                                             0,                   // Reserved
01341                                             &dwType,             // Datatype
01342                                             (BYTE *)wcTemp2,     // Data returned here
01343                                             &dwSize );           // Size of data
01344
01345                 RegCloseKey( hKey );
01346
01347                 if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, Handler.pwszClassId ) )
01348                 {
01349                     wcTemp[ wcslen(wcTemp) - wcslen( L"\\PersistentHandler" ) ] = 0;
01350
01351                     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01352                                              wcTemp,               // Sub key
01353                                              0,                    // Reserved
01354                                              KEY_ALL_ACCESS,       // Access
01355                                              &hKey );              // Handle
01356
01357                     if ( ERROR_SUCCESS == dwError )
01358                     {
01359                         if ( ERROR_SUCCESS == dwIgnore )
01360                             dwIgnore = RegDeleteKeyW( hKey, L"PersistentHandler" );
01361                         else
01362                             RegDeleteKeyW( hKey, L"PersistentHandler" );
01363
01364                         dwIndex = 0; // Start over again
01365                     }
01366
01367                     //
01368                     // If that was the *only* entry under the clsid, then the class can be
01369                     // removed.
01370                     //
01371
01372                     dwSize = sizeof(wcTemp2)/sizeof(wcTemp2[0]);
01373
01374                     long dw2 = RegEnumKeyExW( hKey,             // Handle of key
01375                                               0,                // Index of registry subkey
01376                                               wcTemp2,          // Buffer for name
01377                                               &dwSize,          // Size of buffer / key
01378                                               0,                // Reserved
01379                                               0,                // Class (unused)
01380                                               0,                // Class size (unused)
01381                                               &ftUnused );      // Filetime (unused)
01382
01383                     RegCloseKey( hKey );
01384
01385                     if ( ERROR_NO_MORE_ITEMS == dw2 )
01386                         RemoveAClass( wcTemp + wcslen( L"CLSID\\" ) );
01387                 }
01388                 else
01389                 {
01390                     //
01391                     // Didn't have persistent handler null key.  Odd but not fatal.
01392                     // Or, key didn't match target.
01393                     //
01394
01395                     dwIgnore = dwError;
01396                     dwError = ERROR_SUCCESS;
01397                 }
01398
01399             }
01400             else
01401                 dwError = ERROR_SUCCESS;  // Just didn't have persistent handler
01402         }
01403     }
01404
01405     if ( (HKEY)INVALID_HANDLE_VALUE != hKeyEnum )
01406         RegCloseKey( hKeyEnum );
01407
01408     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01409         dwError = dwEnum;
01410
01411     if ( ERROR_SUCCESS != dwError )
01412         return dwError;
01413     else
01414         return dwIgnore;
01415 }
01416
01417 //+---------------------------------------------------------------------------
01418 //
01419 //  Function:   UnRegisterAnExt, private
01420 //
01421 //  Synopsis:   Unregisters a filter extension
01422 //
01423 //  Arguments:  [Class] -- Class description to unregister
01424 //
01425 //  Returns:    ERROR_SUCCESS on success
01426 //
01427 //----------------------------------------------------------------------------
01428
01429 inline long UnRegisterAnExt( SClassEntry const & Class )
01430 {
01431     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
01432     DWORD dwError;
01433
01434     do
01435     {
01436         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01437                                  Class.pwszExt,        // Sub key -- "CLSID"
01438                                  0,                    // Reserved
01439                                  KEY_ALL_ACCESS,       // Access
01440                                  &hKey );              // Handle
01441
01442         if ( ERROR_SUCCESS != dwError )
01443             break;
01444
01445         dwError = RegDeleteKeyW( hKey, L"PersistentHandler" );
01446
01447     } while ( FALSE );
01448
01449     if ( INVALID_HANDLE_VALUE != hKey )
01450     {
01451         RegCloseKey( hKey );
01452         hKey = (HKEY)INVALID_HANDLE_VALUE;
01453     }
01454
01455     return dwError;
01456 }
01457
01458 //+---------------------------------------------------------------------------
01459 //
01460 //  Function:   UnRegisterAFilter, private
01461 //
01462 //  Synopsis:   Unregisters a filter
01463 //
01464 //  Arguments:  [Filter] -- IFilter implementation
01465 //
01466 //  Returns:    ERROR_SUCCESS on success
01467 //
01468 //----------------------------------------------------------------------------
01469
01470 inline long UnRegisterAFilter( SFilterEntry const & Filter )
01471 {
01472     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01473                                     Filter.pwszClassIdDescription,
01474                                     L"InprocServer32",
01475                                     Filter.pwszDLL };
01476
01477     return DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01478 }
01479
01480 //+---------------------------------------------------------------------------
01481 //
01482 //  Function:   DllUnregisterServer
01483 //
01484 //  Synopsis:   Self-unregistration
01485 //
01486 //----------------------------------------------------------------------------
01487
01488 //+---------------------------------------------------------------------------
01489 //
01490 //  Function:   DllRegisterServer
01491 //
01492 //  Synopsis:   Self-registration
01493 //
01494 //  Notes:      There are two versions here.  Version 1 registers only
01495 //              extensions.  Version 2 registers extensions and
01496 //              [nameless] Class IDs.
01497 //
01498 //----------------------------------------------------------------------------
01499
01500 #define DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, fBlastExistingPersistentHandler )  \
01501                                                                \
01502 STDAPI Name##UnregisterServer()                                \
01503 {                                                              \
01504     /*                                                         \
01505      * Always remove Persistent Handler and Filter entries     \
01506      */                                                        \
01507                                                                \
01508     long dwError = UnRegisterAHandler( Handler );              \
01509                                                                \
01510     if ( ERROR_SUCCESS == dwError )                            \
01511         dwError = UnRegisterAFilter( Filter );                 \
01512     else                                                       \
01513         UnRegisterAFilter( Filter );                           \
01514                                                                \
01515     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01516     {                                                          \
01517         if ( ERROR_SUCCESS == dwError )                        \
01518             dwError = UnRegisterAnExt( aClasses[i] );          \
01519         else                                                   \
01520              UnRegisterAnExt( aClasses[i] );                   \
01521     }                                                          \
01522                                                                \
01523     if ( ERROR_SUCCESS == dwError )                            \
01524         return S_OK;                                           \
01525     else                                                       \
01526         return S_FALSE;                                        \
01527 }                                                              \
01528                                                                \
01529 STDAPI Name##RegisterServer()                                  \
01530 {                                                              \
01531     /*                                                         \
01532      * Always create Persistent Handler and Filter entries     \
01533      */                                                        \
01534                                                                \
01535     long dwError = RegisterAHandler( Handler );                \
01536                                                                \
01537     /*                                                         \
01538      * First, register the CLSID and persistent handler,       \
01539      * then work back to the class description and the         \
01540      * extension. This ensures we cover all possible           \
01541      * mappings.                                               \
01542      *                                                         \
01543      */                                                        \
01544                                                                \
01545     OSVERSIONINFO Version;                                     \
01546     Version.dwOSVersionInfoSize = sizeof(Version);             \
01547                                                                \
01548     BOOL fAppendOnly = FALSE;                                  \
01549                                                                \
01550     if ( GetVersionEx( &Version ) &&                           \
01551          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01552          Version.dwMajorVersion >= 5 )                         \
01553     {                                                          \
01554         fAppendOnly = TRUE;                                    \
01555     }                                                          \
01556                                                                \
01557     if ( ERROR_SUCCESS == dwError )                            \
01558         dwError = RegisterAFilter( Filter );                   \
01559                                                                \
01560     if ( ERROR_SUCCESS == dwError )                            \
01561         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01562             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01563                                                                \
01564     if ( ERROR_SUCCESS == dwError )                            \
01565         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01566             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01567                                                                \
01568     if ( ERROR_SUCCESS == dwError )                            \
01569         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01570             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly, fBlastExistingPersistentHandler );                     \
01571                                                                \
01572     if ( ERROR_SUCCESS == dwError )                            \
01573         return S_OK;                                           \
01574     else                                                       \
01575         return SELFREG_E_CLASS;                                \
01576 }
01577
01578
01579 #define DEFINE_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01580     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, TRUE )  \
01581
01582
01583 #define DEFINE_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01584     DEFINE_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01585
01586 #define DEFINE_SOFT_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01587     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, FALSE )  \
01588
01589 #define DEFINE_SOFT_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01590     DEFINE_SOFT_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01591
01592
01593 //
01594 // Version 2 (for NT 4 support where all the extra registry goo is required).
01595 //
01596
01597 #define DEFINE_REGISTERFILTER2( Name, Handler, Filter, aClasses )  \
01598                                                                \
01599 STDAPI Name##UnregisterServer()                                \
01600 {                                                              \
01601     /*                                                         \
01602      * Always remove Persistent Handler and Filter entries     \
01603      */                                                        \
01604                                                                \
01605     long dwError = UnRegisterAHandler( Handler );              \
01606                                                                \
01607     if ( ERROR_SUCCESS == dwError )                            \
01608         dwError = UnRegisterAFilter( Filter );                 \
01609     else                                                       \
01610         UnRegisterAFilter( Filter );                           \
01611                                                                \
01612     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01613     {                                                          \
01614         if ( ERROR_SUCCESS == dwError )                        \
01615             dwError = UnRegisterAnExt( aClasses[i] );          \
01616         else                                                   \
01617             UnRegisterAnExt( aClasses[i] );                    \
01618     }                                                          \
01619                                                                \
01620     if ( ERROR_SUCCESS == dwError )                            \
01621         return S_OK;                                           \
01622     else                                                       \
01623         return S_FALSE;                                        \
01624 }                                                              \
01625                                                                \
01626 STDAPI Name##RegisterServer()                                  \
01627 {                                                              \
01628     /*                                                         \
01629      * Always create Persistent Handler and Filter entries     \
01630      */                                                        \
01631                                                                \
01632     long dwError = RegisterAHandler( Handler );                \
01633                                                                \
01634     /*                                                         \
01635      * First, register the CLSID and persistent handler,       \
01636      * then work back to the class description and the         \
01637      * extension. This ensures we cover all possible           \
01638      * mappings.                                               \
01639      *                                                         \
01640      */                                                        \
01641                                                                \
01642     OSVERSIONINFO Version;                                     \
01643     Version.dwOSVersionInfoSize = sizeof(Version);             \
01644                                                                \
01645     BOOL fAppendOnly = FALSE;                                  \
01646                                                                \
01647     if ( GetVersionEx( &Version ) &&                           \
01648          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01649          Version.dwMajorVersion >= 5 )                         \
01650     {                                                          \
01651         fAppendOnly = TRUE;                                    \
01652     }                                                          \
01653                                                                \
01654     if ( ERROR_SUCCESS == dwError )                            \
01655         dwError = RegisterAFilter( Filter );                   \
01656                                                                \
01657     if ( ERROR_SUCCESS == dwError )                            \
01658         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01659             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, FALSE, FALSE );                \
01660                                                                \
01661     if ( ERROR_SUCCESS == dwError )                            \
01662         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01663             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01664                                                                \
01665     if ( ERROR_SUCCESS == dwError )                            \
01666         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01667             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly );                     \
01668                                                                \
01669     if ( ERROR_SUCCESS == dwError )                            \
01670         return S_OK;                                           \
01671     else                                                       \
01672         return SELFREG_E_CLASS;                                \
01673 }
01674
01675
01676
01677
01678 #define DEFINE_DLLREGISTERFILTER2( Handler, Filter, aClasses )  \
01679     DEFINE_REGISTERFILTER2( Dll, Handler, Filter, aClasses )
01680
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/basesnap.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

basesnap.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  This file contains implementations for IClassFactory
00014 //             and the Snap-in's DLL exported functions
00015
00016
00017 #include <ObjBase.h>
00018 #include <InitGuid.h>
00019 #include "Globals.h"
00020 #include "Guids.h"
00021 #include "BaseSnap.h"
00022 #include "Comp.h"
00023 #include "CompData.h"
00024 #include "About.h"
00025 #include "Registry.h"
00026
00027
00028 #include "TraceMacro.h"
00029 #undef  MODULESTRING
00030 #define MODULESTRING  _T("BaseSnap")
00031
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 //  Implementation of IClassFactory for CComponentData
00035
00036 //---------------------------------------------------------------------------
00037 CClassFactory::CClassFactory( FACTORY_TYPE eFactoryType )
00038 {
00039   m_cRef = 0;
00040   m_FactoryType = eFactoryType;
00041
00042   InterlockedIncrement((long*)&g_uObjectCount);
00043 }
00044
00045
00046 //---------------------------------------------------------------------------
00047 CClassFactory::~CClassFactory()
00048 {
00049   InterlockedDecrement((long*)&g_uObjectCount);
00050 }
00051
00052
00053 //---------------------------------------------------------------------------
00054 STDMETHODIMP CClassFactory::QueryInterface
00055 (
00056   REFIID   riid,             //[in] Identifier of the requested interface
00057   LPVOID*  ppv               //[out] Address of requested interface
00058 )
00059 {
00060   if( NULL == ppv )
00061     return E_FAIL;
00062
00063   HRESULT hResult = E_NOINTERFACE;
00064   *ppv = NULL;
00065
00066   if( IsEqualIID(riid, IID_IUnknown) )
00067   {
00068     *ppv = static_cast<IClassFactory*>(this);
00069   }
00070   else if( IsEqualIID(riid, IID_IClassFactory) )
00071   {
00072     *ppv = static_cast<IClassFactory*>(this);
00073   }
00074
00075   if( *ppv )
00076   {
00077     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00078     hResult = S_OK;
00079   }
00080
00081   return hResult;
00082 }
00083
00084
00085 //---------------------------------------------------------------------------
00086 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00087 {
00088   return InterlockedIncrement( (long*)&m_cRef );
00089 }
00090
00091
00092 //---------------------------------------------------------------------------
00093 STDMETHODIMP_(ULONG) CClassFactory::Release()
00094 {
00095   if( 0 == InterlockedDecrement( (long*)&m_cRef) )
00096   {
00097     delete this;
00098     return 0;
00099   }
00100   return m_cRef;
00101 }
00102
00103 //---------------------------------------------------------------------------
00104 //  Creates an instance of the object type which was passed in the
00105 //  class constructor
00106 //
00107 STDMETHODIMP CClassFactory::CreateInstance
00108 (
00109   LPUNKNOWN  pUnkOuter,      //[in] NULL unless object is part of aggregate
00110   REFIID     riid,           //[in] Reference to interface indentifier
00111   LPVOID*    ppvObj          //[out] Address of requested interface pointer
00112 )
00113 {
00114   HRESULT  hResult = E_FAIL;
00115   void*    pObject = NULL;
00116
00117   if( NULL == ppvObj )
00118     return hResult;
00119
00120   *ppvObj = NULL;
00121
00122   // Our object does does not support aggregation, so we need to
00123   // fail if they ask us to do aggregation.
00124   if( pUnkOuter )
00125     return CLASS_E_NOAGGREGATION;
00126
00127   // NEW:  Support for providing CSnapinAbout objects
00128   switch( m_FactoryType )
00129   {
00130     case COMPONENTDATA:
00131       pObject = new CComponentData();
00132       break;
00133
00134     case ABOUT:
00135       pObject = new CSnapinAbout();
00136       break;
00137
00138     default:
00139       pObject = NULL;
00140   }
00141
00142   if( NULL == pObject )                // Failed to create an object
00143     return E_INVALIDARG;               // due to bad argument
00144
00145   // QueryInterface will do the AddRef() for us, don't do it here
00146   hResult = ( (LPUNKNOWN)pObject)->QueryInterface( riid, ppvObj );
00147
00148   if( S_OK != hResult )
00149     delete pObject;
00150
00151   return hResult;
00152 }
00153
00154
00155 //---------------------------------------------------------------------------
00156 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00157 {
00158   if( TRUE == fLock )
00159     InterlockedIncrement((long*)&g_uServerLocks);
00160   else
00161     InterlockedDecrement((long*)&g_uServerLocks);
00162
00163   return S_OK;
00164 }
00165
00166
00167 /////////////////////////////////////////////////////////////////////////////
00168 //  Our Snap-in's exported functions
00169 //
00170
00171 //---------------------------------------------------------------------------
00172 //  Entry point into our Snap-in DLL
00173 //
00174 BOOL WINAPI DllMain
00175 (
00176   HINSTANCE  hInstDLL,         //[in] Handle to DLL module
00177   DWORD      fdwReason,        //[in] Reason for calling function
00178   void*      lpvReserved       //[in] Reserved
00179 )
00180 {
00181   if( DLL_PROCESS_ATTACH == fdwReason )
00182   {
00183      g_hInst = hInstDLL;
00184   }
00185
00186   return TRUE;
00187 }
00188
00189
00190 //---------------------------------------------------------------------------
00191 STDAPI DllGetClassObject
00192 (
00193   REFCLSID   rclsid,         //[in] CLSID for the class object
00194   REFIID     riid,           //[in] Reference to interface identifier
00195   LPVOID     *ppvObj         //[out] Object which recieves interface pointer
00196 )
00197 {
00198   // NEW: Must test for CSnapinAbout now
00199   if( (rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout) )
00200     return CLASS_E_CLASSNOTAVAILABLE;
00201
00202   if( !ppvObj )
00203     return E_FAIL;
00204
00205   *ppvObj = NULL;
00206
00207   // We can only hand out IUnknown and IClassFactory pointers.  Fail
00208   // if caller asks for anything else.
00209   if( !IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory) )
00210     return E_NOINTERFACE;
00211
00212   CClassFactory *pFactory = NULL;
00213
00214   // NEW:  Create the new class factory.  Pass in the type of object to create
00215   if( rclsid == CLSID_CComponentData )
00216     pFactory = new CClassFactory(CClassFactory::COMPONENTDATA);
00217   else if( rclsid == CLSID_CSnapinAbout )
00218     pFactory = new CClassFactory(CClassFactory::ABOUT);
00219
00220
00221   HRESULT hResult = pFactory->QueryInterface( riid, ppvObj );
00222
00223   return hResult;
00224 }
00225
00226
00227 //---------------------------------------------------------------------------
00228 STDAPI DllCanUnloadNow(void)
00229 {
00230   if( 0 == g_uObjectCount && 0 == g_uServerLocks )
00231     return S_OK;
00232   else
00233     return S_FALSE;
00234 }
00235
00236
00237 //---------------------------------------------------------------------------
00238 STDAPI DllRegisterServer()
00239 {
00240   HRESULT hResult = S_FALSE;
00241
00242   do
00243   { // NEW: Support ISnapinAbout
00244     hResult = RegisterServer( g_hInst, CLSID_CSnapinAbout, gtszABOUT_NAME );
00245     BREAK_ON_ERROR( hResult );
00246
00247     hResult = RegisterServer( g_hInst, CLSID_CComponentData, gtszSNAPIN_NAME );
00248     BREAK_ON_ERROR( hResult );
00249
00250     hResult = RegisterSnapin( CLSID_CComponentData, gtszSNAPIN_NAME, CLSID_CSnapinAbout, FALSE );
00251     BREAK_ON_ERROR( hResult );
00252
00253   }while( 0 );
00254
00255   return hResult;
00256 }
00257
00258
00259 //---------------------------------------------------------------------------
00260 STDAPI DllUnregisterServer()
00261 {
00262   if( S_OK == UnregisterServer(CLSID_CComponentData) )
00263     return UnregisterSnapin(CLSID_CComponentData);
00264   else
00265     return E_FAIL;
00266 }
00267
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Custom/SpinCube/Paint.c Source File

  • WinUI
  • Controls
  • Custom
  • SpinCube

Paint.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *
00003 *  MODULE:      PAINT.C
00004 *
00005 *  PURPOSE:     This is the module responsible for painting the SPINCUBE
00006 *               custom control. When Paint() is called we retrieve a
00007 *               pointer to a SPINCUBEINFO structure, and then use it's
00008 *               current rotation & translation values to transform the
00009 *               polyhedron described by gNormalizedVertices & gaiFacets.
00010 *               Once we've transformed the vertices, we draw the
00011 *               background, which consists of a grey rectangle and a few
00012 *               black lines (a crass attempt to render a perspective
00013 *               view into a "room"), on the offscreen bitmap associated
00014 *               with the control (i.e. pSCI->hbmCompat). Then we walk the
00015 *               facet list of the transformed polyhedron (gXformedVertices
00016 *               & gaiFacets), drawing only those facets whose outward
00017 *               normal faces us (again, drawing on pSCI->hbmCompat).
00018 *               Finally, we BitBlt the appropriate rectangle from our
00019 *               offscreen bitmap to the screen itself.
00020 *
00021 *               Drawing to the offscreen bitmap has two advantages over
00022 *               drawing straight to the screen:
00023 *
00024 *                 1. The actual drawing the user sees consists of only
00025 *                    a single BitBlt. Otherwise, the user would see us
00026 *                    both erase the polyhedron in it's old position and
00027 *                    draw it in it's new position (alot of flashing- not
00028 *                    very smooth animation).
00029 *
00030 *                 2. When a spincube control with the SS_ERASE style
00031 *                    is brought to the foreground, all it's contents
00032 *                    i.e. the cube trails) are saved & can be re-Blted
00033 *                    to the screen. Otherwise, all this info would be
00034 *                    lost & there'd be a big blank spot in the middle
00035 *                    of the control!
00036 *
00037 *               Interested persons should consult a text on 3 dimensional
00038 *               graphics for more information (i.e. "Computer Graphics:
00039 *               Principles and Practice", by Foley & van Dam).
00040 *
00041 *               Notes:
00042 *
00043 *               - A 3x2 tranformation matrix  is used instead of a  3x3
00044 *                 matrix, since the transformed z-values aren't needed.
00045 *                 (Normally these would be required for use in depth
00046 *                 sorting  [for hidden surface removal], but  since we
00047 *                 draw  only  a single convex polyhedron this  is not
00048 *                 necessary.)
00049 *
00050 *               - A simplified perspective viewing transformation
00051 *                 (which also  precludes the need for the transformed z
00052 *                 coordinates). In a nutshell, the perspective  scale
00053 *                 is as follows:
00054 *
00055 *                                    p' = S    x  p
00056 *                                          per
00057 *
00058 *                 where:
00059 *                        S    = WindowDepth /
00060 *                         per      (WindowDepth + fCurrentZTranslation)
00061 *
00062 *                 (WindowDepth is  the greater of the  control's window
00063 *                 height or window width.)
00064 *
00065 *
00066 *  FUNCTIONS:   Paint()                         - the paint routine
00067 *               TransformVertices()             - transforms vertices
00068 *               ComputeRotationTransformation() - computes xformation
00069 *                                                 based on current x, y
00070 *                                                 and z rotation angles
00071 *
00072 *
00073 *                           Microsoft Developer Support
00074 *                  Copyright 1992 - 2000 Microsoft Corporation
00075 *
00076 \******************************************************************************/
00077
00078 #include <windows.h>
00079 #include <math.h>
00080 #include <stdlib.h>
00081 #include "spincube.h"
00082 #include "paint.h"
00083
00084
00085
00086 /******************************************************************************\
00087 *
00088 *  FUNCTION:     Paint
00089 *
00090 *  INPUTS:       hwnd - Handle of the window to draw into.
00091 *
00092 *  COMMENTS:     Draws window background & a polyhedron in the window.
00093 *
00094 \******************************************************************************/
00095
00096 void Paint (HWND hwnd)
00097 {
00098   PSPINCUBEINFO  pSCI;
00099   RECT           rect;
00100   int            i;
00101   LONG           lScaleFactor;
00102   PAINTSTRUCT    ps;
00103   HRGN           hrgnClip;
00104   HBRUSH         hBrush, hBrushSave;
00105   int            iX, iY, iCX, iCY;
00106   int            facetIndex, numPoints;
00107   POINT          polygn[MAX_POINTS_PER_FACET];
00108   POINT          vector1, vector2;
00109   COLORREF       acrColor[6] = { 0x0000ff, 0x00ff00, 0xff0000,
00110                                  0x00ffff, 0xff00ff, 0xffff00 };
00111
00112   pSCI = (PSPINCUBEINFO) GetWindowLongPtr (hwnd, GWL_SPINCUBEDATA);
00113
00114   BeginPaint (hwnd, &ps);
00115
00116   if (memcmp((void *)&ps.rcPaint, (void *)&pSCI->rcCubeBoundary, sizeof(RECT))
00117       & !REPAINT_BKGND(pSCI))
00118
00119   {
00120     //
00121     // We're not here because it's time to animate (i.e. this paint isn't
00122     //   the result of a WM_TIMER), so just do the Blt & blow out of here...
00123     //
00124
00125     BitBlt (ps.hdc,
00126             ps.rcPaint.left,
00127             ps.rcPaint.top,
00128             ps.rcPaint.right - ps.rcPaint.left,
00129             ps.rcPaint.bottom - ps.rcPaint.top,
00130             pSCI->hdcCompat, ps.rcPaint.left,
00131             ps.rcPaint.top, SRCCOPY);
00132
00133     EndPaint (hwnd, &ps);
00134     return;
00135   }
00136
00137
00138   //
00139   // The rectangle we get back is in Desktop coordinates, so we need to
00140   //   modify it to reflect coordinates relative to this window.
00141   //
00142
00143   GetWindowRect (hwnd, &rect);
00144
00145   rect.right  -= rect.left;
00146   rect.bottom -= rect.top;
00147   rect.left = rect.top = 0;
00148
00149
00150   //
00151   // Determine a "best fit" scale factor for our polyhedron
00152   //
00153
00154   if (!(lScaleFactor = rect.right > rect.bottom ?
00155                        rect.bottom/12 : rect.right/12))
00156
00157     lScaleFactor = 1;
00158
00159
00160   TransformVertices (hwnd, &rect, pSCI, lScaleFactor);
00161
00162
00163   //
00164   // Draw the window frame & background
00165   //
00166   // Note: The chances are that we are coming through here because we
00167   //   got a WM_TIMER message & it's time to redraw the cube to simulate
00168   //   animation. In that case all we want to erase/redraw is that small
00169   //   rectangle which bounded the polyhedron the last time. The less
00170   //   drawing that actually gets done the better, since we wnat to
00171   //   minimize the flicker on the screen. __BeginPaint__ is perfect for
00172   //   this because it causes all drawing outside of the invalid region
00173   //   to be "clipped" (no drawing is performed outside of the invalid
00174   //   region), and it also validates the invalid region.
00175   //
00176
00177   if (DO_ERASE(hwnd) || REPAINT_BKGND(pSCI))
00178   {
00179     hrgnClip = CreateRectRgnIndirect (&ps.rcPaint);
00180     SelectClipRgn (pSCI->hdcCompat, hrgnClip);
00181     DeleteObject (hrgnClip);
00182
00183     SelectObject (pSCI->hdcCompat, GetStockObject (GRAY_BRUSH));
00184     Rectangle    (pSCI->hdcCompat, (int)rect.left, (int)rect.top,
00185                   (int)rect.right, (int)rect.bottom);
00186
00187     iX = (rect.right  - rect.left) / 4;
00188     iY = (rect.bottom - rect.top ) / 4;
00189
00190     MoveToEx (pSCI->hdcCompat, (int)rect.left, (int)rect.top, NULL);
00191     LineTo   (pSCI->hdcCompat, (int)rect.left + iX, (int)rect.top + iY);
00192     LineTo   (pSCI->hdcCompat, (int)rect.left + iX, (int)rect.bottom - iY);
00193     LineTo   (pSCI->hdcCompat, (int)rect.left,      (int)rect.bottom);
00194
00195     MoveToEx (pSCI->hdcCompat, (int)rect.right, (int)rect.top, NULL);
00196     LineTo   (pSCI->hdcCompat, (int)rect.right - iX, (int)rect.top + iY);
00197     LineTo   (pSCI->hdcCompat, (int)rect.right - iX, (int)rect.bottom- iY);
00198     LineTo   (pSCI->hdcCompat, (int)rect.right,      (int)rect.bottom);
00199
00200     MoveToEx (pSCI->hdcCompat, (int)rect.left + iX,  (int)rect.top + iY, NULL);
00201     LineTo   (pSCI->hdcCompat, (int)rect.right - iX, (int)rect.top + iY);
00202
00203     MoveToEx (pSCI->hdcCompat, (int)rect.left + iX,  (int)rect.bottom - iY, NULL);
00204     LineTo   (pSCI->hdcCompat, (int)rect.right - iX, (int)rect.bottom - iY);
00205
00206     SelectClipRgn (pSCI->hdcCompat, NULL);
00207
00208     pSCI->iOptions &= ~SPINCUBE_REPAINT_BKGND;
00209   }
00210
00211
00212   //
00213   // Draw the polyhedron. We'll walk through the facets list and compute
00214   //   the normal for each facet- if the normal has z > 0, then the facet
00215   //   faces us and we'll draw it. Note that this algorithim is ONLY valid
00216   //   for scenes with a single, convex polyhedron.
00217   //
00218   // Note: Use GetDC here because the above call to BeginPaint will
00219   //   probably not give us a DC with access to as much real estate as
00220   //   we'd like (we wouldn't be able to draw outside of the invalid
00221   //   region). We can party on the entire control window with the DC
00222   //   returned by GetDC.
00223   //
00224
00225   for (i = 0, facetIndex = 0; i < NUMFACETS; i++)
00226   {
00227     vector1.x = gXformedVertices[gaiFacets[facetIndex + 1]].x -
00228                 gXformedVertices[gaiFacets[facetIndex]].x;
00229     vector1.y = gXformedVertices[gaiFacets[facetIndex + 1]].y -
00230                 gXformedVertices[gaiFacets[facetIndex]].y;
00231     vector2.x = gXformedVertices[gaiFacets[facetIndex + 2]].x -
00232                 gXformedVertices[gaiFacets[facetIndex + 1]].x;
00233     vector2.y = gXformedVertices[gaiFacets[facetIndex + 2]].y -
00234                 gXformedVertices[gaiFacets[facetIndex + 1]].y;
00235
00236     for (numPoints = 0; gaiFacets[facetIndex] != -1; numPoints++, facetIndex++)
00237     {
00238       polygn[numPoints].x = gXformedVertices[gaiFacets[facetIndex]].x;
00239       polygn[numPoints].y = gXformedVertices[gaiFacets[facetIndex]].y;
00240     }
00241
00242     facetIndex++; /* skip over the -1's in the facets list */
00243     if ((vector1.x*vector2.y - vector1.y*vector2.x) > 0)
00244     {
00245       hBrush     = CreateSolidBrush (acrColor[i]);
00246       hBrushSave = (HBRUSH) SelectObject (pSCI->hdcCompat, hBrush);
00247
00248       Polygon (pSCI->hdcCompat, &polygn[0], numPoints);
00249
00250       SelectObject (pSCI->hdcCompat, hBrushSave);
00251       DeleteObject (hBrush);
00252     }
00253   }
00254
00255   iX  = pSCI->rcCubeBoundary.left < ps.rcPaint.left ?
00256         pSCI->rcCubeBoundary.left : ps.rcPaint.left;
00257   iY  = pSCI->rcCubeBoundary.top  < ps.rcPaint.top  ?
00258         pSCI->rcCubeBoundary.top  : ps.rcPaint.top;
00259
00260   iCX = (pSCI->rcCubeBoundary.right > ps.rcPaint.right ?
00261          pSCI->rcCubeBoundary.right : ps.rcPaint.right) - iX;
00262
00263   iCY = (pSCI->rcCubeBoundary.bottom > ps.rcPaint.bottom ?
00264          pSCI->rcCubeBoundary.bottom : ps.rcPaint.bottom) - iY;
00265
00266   EndPaint (hwnd, &ps);
00267
00268   ps.hdc = GetDC (hwnd);
00269
00270   BitBlt (ps.hdc, iX, iY, iCX, iCY, pSCI->hdcCompat, iX, iY, SRCCOPY);
00271
00272   ReleaseDC (hwnd, ps.hdc);
00273
00274 }
00275
00276
00277
00278 /******************************************************************************\
00279 *
00280 *  FUNCTION:     TransformVertices
00281 *
00282 *  INPUTS:       hwnd         - control window handle
00283 *                pWindowRect  - pointer to RECT describing control's dimensions
00284 *                pSCI         - pointer to control's SPINCUBEINFO structure
00285 *                fScaleFactor - scale factor for use in this window
00286 *
00287 \******************************************************************************/
00288
00289 void TransformVertices (HWND hwnd,          RECT  *pWindowRect,
00290                         PSPINCUBEINFO pSCI, LONG  lScaleFactor)
00291 {
00292   int    i;
00293   int    iWindowDepth = pWindowRect->right > pWindowRect->bottom ?
00294                         pWindowRect->right : pWindowRect->bottom;
00295   RECT   WindowRect;
00296   float  fDepthScale;
00297   int    iNewTranslationInc = (rand() % 10) + 2;
00298   float  fNewRotationInc    = (float) 0.01 * ((rand() % 30) + 2);
00299
00300   WindowRect.left = - (WindowRect.right  = pWindowRect->right  >> 1);
00301   WindowRect.top  = - (WindowRect.bottom = pWindowRect->bottom >> 1);
00302
00303   //
00304   // Initiailize the bounding rectangle with max/min vals
00305   //
00306
00307   pSCI->rcCubeBoundary.left   =
00308   pSCI->rcCubeBoundary.top    = 100000; // big positive value
00309   pSCI->rcCubeBoundary.right  =
00310   pSCI->rcCubeBoundary.bottom = -100000; // small negative value
00311
00312
00313   //
00314   // First scale, then rotate, then translate each vertex.
00315   //   Keep track of the maximum & minimum values bounding the
00316   //   vertices in the x,y plane for use later in bounds checking.
00317   //
00318   // Note: we don't bother computing z values after the scale,
00319   //   as they are only really necessary for the rotation. If we
00320   //   were doing real bounds checking we'd need it, but this code
00321   //   simply uses the pSCI->iCurrentZTranslation to determine
00322   //   the z-boundaries.
00323   //
00324
00325   for (i = 0; i < NUMVERTICES; i++)
00326   {
00327     LONG tempX;
00328
00329     //
00330     // Copy the static vertices into a temp array
00331     //
00332
00333     gXformedVertices[i] = gNormalizedVertices[i];
00334
00335     //
00336     // The scale...
00337     //
00338
00339     gXformedVertices[i].x *= lScaleFactor;
00340     gXformedVertices[i].y *= lScaleFactor;
00341     gXformedVertices[i].z *= lScaleFactor;
00342
00343     //
00344     // The rotation...
00345     //
00346
00347     ComputeRotationTransformation (pSCI->fCurrentXRotation,
00348                                    pSCI->fCurrentYRotation,
00349                                    pSCI->fCurrentZRotation);
00350
00351     tempX   =               (LONG) (gM[0][0] * gXformedVertices[i].x +
00352                                     gM[0][1] * gXformedVertices[i].y +
00353                                     gM[0][2] * gXformedVertices[i].z);
00354
00355     gXformedVertices[i].y = (LONG) (gM[1][0] * gXformedVertices[i].x +
00356                                     gM[1][1] * gXformedVertices[i].y +
00357                                     gM[1][2] * gXformedVertices[i].z);
00358     gXformedVertices[i].x = tempX;
00359
00360     //
00361     // The translation...
00362     //
00363
00364     gXformedVertices[i].x += pSCI->iCurrentXTranslation;
00365     gXformedVertices[i].y += pSCI->iCurrentYTranslation;
00366
00367     //
00368     // Check if we have new max or min vals
00369     //
00370
00371     if (pSCI->rcCubeBoundary.left > gXformedVertices[i].x)
00372
00373       pSCI->rcCubeBoundary.left = gXformedVertices[i].x;
00374
00375     if (pSCI->rcCubeBoundary.right < gXformedVertices[i].x)
00376
00377       pSCI->rcCubeBoundary.right = gXformedVertices[i].x;
00378
00379     if (pSCI->rcCubeBoundary.top > gXformedVertices[i].y)
00380
00381       pSCI->rcCubeBoundary.top = gXformedVertices[i].y;
00382
00383     if (pSCI->rcCubeBoundary.bottom < gXformedVertices[i].y)
00384
00385       pSCI->rcCubeBoundary.bottom = gXformedVertices[i].y;
00386   }
00387
00388
00389   //
00390   // Now for some bounds checking, change translation & rotation increments
00391   //   if we hit a "wall". Also so the gbHitBoundary flag so we remember
00392   //   to flash the cube when we draw it.
00393   //
00394
00395   if (pSCI->rcCubeBoundary.left < WindowRect.left)
00396   {
00397     pSCI->iCurrentXTranslationInc = iNewTranslationInc;
00398     pSCI->fCurrentZRotationInc    = fNewRotationInc;
00399   }
00400
00401   else if (pSCI->rcCubeBoundary.right > WindowRect.right)
00402   {
00403     pSCI->iCurrentXTranslationInc = -iNewTranslationInc;
00404     pSCI->fCurrentZRotationInc    = -fNewRotationInc;
00405   }
00406
00407   if (pSCI->rcCubeBoundary.top < WindowRect.top)
00408    {
00409     pSCI->iCurrentYTranslationInc = iNewTranslationInc;
00410     pSCI->fCurrentXRotationInc    = fNewRotationInc;
00411   }
00412
00413   else if (pSCI->rcCubeBoundary.bottom > WindowRect.bottom)
00414   {
00415     pSCI->iCurrentYTranslationInc = -iNewTranslationInc;
00416     pSCI->fCurrentXRotationInc    = -fNewRotationInc;
00417   }
00418
00419   if (pSCI->iCurrentZTranslation < (int) lScaleFactor<<1)
00420   {
00421     pSCI->iCurrentZTranslationInc = iNewTranslationInc;
00422     pSCI->fCurrentYRotationInc    = fNewRotationInc;
00423   }
00424
00425   else if (pSCI->iCurrentZTranslation > (iWindowDepth - (int) lScaleFactor))
00426   {
00427     pSCI->iCurrentZTranslationInc = -iNewTranslationInc;
00428     pSCI->fCurrentYRotationInc    = -fNewRotationInc;
00429   }
00430
00431
00432   //
00433   // Now a kludgy scale based on depth (iCurrentZTranslation) of the center
00434   //   point of the polyhedron
00435   //
00436
00437   fDepthScale =  ((float) iWindowDepth) /
00438                  ((float) (iWindowDepth + pSCI->iCurrentZTranslation));
00439
00440   pSCI->rcCubeBoundary.left  = (LONG)(fDepthScale* pSCI->rcCubeBoundary.left  );
00441   pSCI->rcCubeBoundary.right = (LONG)(fDepthScale* pSCI->rcCubeBoundary.right );
00442   pSCI->rcCubeBoundary.top   = (LONG)(fDepthScale* pSCI->rcCubeBoundary.top   );
00443   pSCI->rcCubeBoundary.bottom= (LONG)(fDepthScale* pSCI->rcCubeBoundary.bottom);
00444
00445   for (i = 0; i < NUMVERTICES; i++)
00446   {
00447     gXformedVertices[i].x = (LONG) (fDepthScale * gXformedVertices[i].x);
00448     gXformedVertices[i].y = (LONG) (fDepthScale * gXformedVertices[i].y);
00449   }
00450
00451
00452   //
00453   // If currently in motion then increment the current rotation & tranlation
00454   //
00455
00456   if (IN_MOTION(hwnd))
00457   {
00458     pSCI->fCurrentXRotation += pSCI->fCurrentXRotationInc;
00459     pSCI->fCurrentYRotation += pSCI->fCurrentYRotationInc;
00460     pSCI->fCurrentZRotation += pSCI->fCurrentZRotationInc;
00461
00462     pSCI->iCurrentXTranslation += pSCI->iCurrentXTranslationInc;
00463     pSCI->iCurrentYTranslation += pSCI->iCurrentYTranslationInc;
00464     pSCI->iCurrentZTranslation += pSCI->iCurrentZTranslationInc;
00465   }
00466
00467
00468   //
00469   // Up to this point all coordinates are relative to a window whose
00470   //   center is at (0,0). Now we'll translate appropriately...
00471   //
00472
00473   pSCI->rcCubeBoundary.left   += pWindowRect->right  >> 1;
00474   pSCI->rcCubeBoundary.right  += pWindowRect->right  >> 1;
00475   pSCI->rcCubeBoundary.top    += pWindowRect->bottom >> 1;
00476   pSCI->rcCubeBoundary.bottom += pWindowRect->bottom >> 1;
00477
00478   for (i = 0; i < NUMVERTICES; i++)
00479   {
00480     gXformedVertices[i].x += pWindowRect->right  >> 1;
00481     gXformedVertices[i].y += pWindowRect->bottom >> 1;
00482   }
00483
00484
00485   //
00486   // Since FillRect's are inclusive-exclusive (there'll be leftovers
00487   //   from the last cube we drew otherwise)...
00488   //
00489
00490   pSCI->rcCubeBoundary.right++;
00491   pSCI->rcCubeBoundary.bottom++;
00492
00493
00494   //
00495   // Finally, adjust the rcCubeBoundary such that it fits entirely within
00496   //   the acutal control window. The reason for this is that when calling
00497   //   InvalidateRect from SpincubeWndProc\case_WM_TIMER we may get
00498   //   a different PAINSTRUCT.rcPaint (since InvalidateRect clips the passed
00499   //   in rect to the window bounds) and our abouve test to memcmp() will
00500   //   fail.
00501   //
00502
00503   if (pSCI->rcCubeBoundary.left < 0)
00504
00505     pSCI->rcCubeBoundary.left = 0;
00506
00507   if (pSCI->rcCubeBoundary.top < 0)
00508
00509     pSCI->rcCubeBoundary.top = 0;
00510
00511   if (pSCI->rcCubeBoundary.right > pWindowRect->right)
00512
00513     pSCI->rcCubeBoundary.right = pWindowRect->right;
00514
00515   if (pSCI->rcCubeBoundary.bottom > pWindowRect->bottom)
00516
00517     pSCI->rcCubeBoundary.bottom = pWindowRect->bottom;
00518 }
00519
00520
00521 /******************************************************************************\
00522 *
00523 *  FUNCTION:    ComputeRotationTransformation
00524 *
00525 *  INPUTS:      fRotationX - Angle to rotate about X axis.
00526 *               fRotationY - Angle to rotate about Y axis.
00527 *               fRotationZ - Angle to rotate about Z axis.
00528 *
00529 *  COMMENTS:    Computes a 3x2 tranformation matrix which rotates about
00530 *               the Z axis, the Y axis, and the X axis, respectively.
00531 *
00532 \******************************************************************************/
00533
00534 void ComputeRotationTransformation (float fRotationX,
00535                                     float fRotationY,
00536                                     float fRotationZ)
00537 {
00538   float sinX, cosX, sinY, cosY, sinZ, cosZ;
00539
00540   sinX = (float) sin ((double) fRotationX);
00541   cosX = (float) cos ((double) fRotationX);
00542   sinY = (float) sin ((double) fRotationY);
00543   cosY = (float) cos ((double) fRotationY);
00544   sinZ = (float) sin ((double) fRotationZ);
00545   cosZ = (float) cos ((double) fRotationZ);
00546
00547   gM[0][0] =  cosY*cosZ;
00548   gM[0][1] = -cosY*sinZ;
00549   gM[0][2] =  sinY;
00550   gM[1][0] =  sinX*sinY*cosZ + cosX*sinZ;
00551   gM[1][1] = -sinX*sinY*sinZ + cosX*cosZ;
00552   gM[1][2] = -sinX*cosY;
00553 }
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook Server/CMgdResType.h Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook Server

CMgdResType.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      CMgdResType.h
00007 //
00008 //  Description:
00009 //      Header file for the CMgdResType class.
00010 //
00011 //  Author:
00012 //      <name> (<e-mail name>) Mmmm DD, 2003
00013 //
00014 //  Revision History:
00015 //
00016 //  Notes:
00017 //
00018 /////////////////////////////////////////////////////////////////////////////
00019
00020 #pragma once
00021
00022 //////////////////////////////////////////////////////////////////////////////
00023 // Include Files
00024 //////////////////////////////////////////////////////////////////////////////
00025
00026 #include "clres.h"
00027 #include "CMgdClusCfgInit.h"
00028
00029 //////////////////////////////////////////////////////////////////////////////
00030 //++
00031 //
00032 //  class CMgdResType
00033 //
00034 //  Description:
00035 //      The CMgdResType class is an implementation of the
00036 //      IClusCfgResourceTypeInfo interface.
00037 //
00038 //--
00039 //////////////////////////////////////////////////////////////////////////////
00040 class CMgdResType
00041     : public IClusCfgResourceTypeInfo
00042     , public IClusCfgStartupListener
00043     , public CMgdClusCfgInit
00044     , public CComCoClass<CMgdResType,&CLSID_ClipBookServer>
00045 {
00046 public:
00047     CMgdResType( void ) {}
00048     virtual ~CMgdResType( void ) {}
00049
00050 BEGIN_COM_MAP( CMgdResType )
00051     COM_INTERFACE_ENTRY( IClusCfgResourceTypeInfo )
00052     COM_INTERFACE_ENTRY( IClusCfgStartupListener )
00053     COM_INTERFACE_ENTRY( IClusCfgInitialize )
00054 END_COM_MAP()
00055 DECLARE_NOT_AGGREGATABLE( CMgdResType )
00056
00057 BEGIN_CATEGORY_MAP( CMgdResType )
00058     IMPLEMENTED_CATEGORY( CATID_ClusCfgResourceTypes )
00059     IMPLEMENTED_CATEGORY( CATID_ClusCfgStartupListeners )
00060 END_CATEGORY_MAP()
00061
00062 DECLARE_NOT_AGGREGATABLE( CMgdResType )
00063
00064 #pragma warning( push, 3 )
00065 #pragma warning( disable : 4995 ) // warning C4995: '<x>': name was marked as #pragma deprecated
00066 DECLARE_REGISTRY_RESOURCEID(IDR_CMgdResType)
00067 #pragma warning( pop )
00068
00069     //
00070     //  IClusCfgResourceTypeInfo interface
00071     //
00072
00073     STDMETHOD( CommitChanges )( IUnknown * punkClusterInfoIn, IUnknown * punkResTypeServicesIn );
00074     STDMETHOD( GetTypeGUID )( GUID * pguidGUIDOut );
00075     STDMETHOD( GetTypeName )( BSTR * pbstrTypeNameOut );
00076
00077     //
00078     //  IClusCfgStartupListener methods
00079     //
00080
00081     STDMETHOD( Notify )( IUnknown * punkIn );
00082
00083 private:
00084
00085     //
00086     //  Private copy constructor to avoid copying.
00087     //
00088
00089     CMgdResType( const CMgdResType & rSrcIn );
00090
00091     //
00092     //  Private assignment operator to avoid copying.
00093     //
00094
00095     const CMgdResType & operator = ( const CMgdResType & rSrcIn );
00096
00097 }; //*** class CMgdResType
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/GINA/GinaHook/GinaHook.c Source File

  • Security
  • GINA
  • GinaHook

GinaHook.c

Go to the documentation of this file.
00001 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002
00003  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00004  EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00005  WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00006
00007  Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009  Module:   Ginahook.c
00010
00011  Abstract: See ReadMe.txt for more detail information about this sample.
00012
00013  Revision: August 6, 1999.
00014
00015 -------------------------------------------------------------------------------*/
00016
00017 #define _WIN32_WINNT 0x0400
00018
00019 #include <windows.h>
00020 #include <winwlx.h>
00021
00022 #include "Ginahook.h"
00023 #include "GinaDlg.h"
00024
00025 //
00026 // Location of the real MSGINA.
00027 //
00028
00029 #define REALGINA_PATH      TEXT("MSGINA.DLL")
00030 #define GINASTUB_VERSION   (WLX_VERSION_1_3) // Highest version supported at
00031                                              // this point. Remember to modify
00032                                              // this as support for newer version
00033                                              // is added to this program.
00034 //
00035 // Winlogon function dispatch table.
00036 //
00037 static PVOID g_pWinlogon = NULL;
00038 static DWORD g_dwVersion = WLX_VERSION_1_3;
00039
00040 //
00041 // Pointers to the real MSGINA functions.
00042 //
00043
00044 static PFWLXNEGOTIATE            pfWlxNegotiate;
00045 static PFWLXINITIALIZE           pfWlxInitialize;
00046 static PFWLXDISPLAYSASNOTICE     pfWlxDisplaySASNotice;
00047 static PFWLXLOGGEDOUTSAS         pfWlxLoggedOutSAS;
00048 static PFWLXACTIVATEUSERSHELL    pfWlxActivateUserShell;
00049 static PFWLXLOGGEDONSAS          pfWlxLoggedOnSAS;
00050 static PFWLXDISPLAYLOCKEDNOTICE  pfWlxDisplayLockedNotice;
00051 static PFWLXWKSTALOCKEDSAS       pfWlxWkstaLockedSAS;
00052 static PFWLXISLOCKOK             pfWlxIsLockOk;
00053 static PFWLXISLOGOFFOK           pfWlxIsLogoffOk;
00054 static PFWLXLOGOFF               pfWlxLogoff;
00055 static PFWLXSHUTDOWN             pfWlxShutdown;
00056
00057 //
00058 // New for version 1.1
00059 //
00060
00061 static PFWLXSTARTAPPLICATION     pfWlxStartApplication  = NULL;
00062 static PFWLXSCREENSAVERNOTIFY    pfWlxScreenSaverNotify = NULL;
00063
00064 //
00065 // New for version 1.2 - No new GINA interface was added, except
00066 //                       a new function in the dispatch table.
00067 //
00068
00069 //
00070 // New for version 1.3
00071 //
00072
00073 static PFWLXNETWORKPROVIDERLOAD   pfWlxNetworkProviderLoad  = NULL;
00074 static PFWLXDISPLAYSTATUSMESSAGE  pfWlxDisplayStatusMessage = NULL;
00075 static PFWLXGETSTATUSMESSAGE      pfWlxGetStatusMessage     = NULL;
00076 static PFWLXREMOVESTATUSMESSAGE   pfWlxRemoveStatusMessage  = NULL;
00077
00078
00079 //
00080 // Hook into the real MSGINA.
00081 //
00082
00083 BOOL MyInitialize (HINSTANCE hDll, DWORD dwWlxVersion)
00084 {
00085    //
00086    // Get pointers to all of the WLX functions in the real MSGINA.
00087    //
00088    pfWlxInitialize =
00089       (PFWLXINITIALIZE) GetProcAddress(hDll, "WlxInitialize");
00090    if (!pfWlxInitialize)
00091    {
00092       return FALSE;
00093    }
00094
00095    pfWlxDisplaySASNotice =
00096       (PFWLXDISPLAYSASNOTICE) GetProcAddress(hDll, "WlxDisplaySASNotice");
00097    if (!pfWlxDisplaySASNotice)
00098    {
00099       return FALSE;
00100    }
00101
00102    pfWlxLoggedOutSAS =
00103       (PFWLXLOGGEDOUTSAS) GetProcAddress(hDll, "WlxLoggedOutSAS");
00104    if (!pfWlxLoggedOutSAS)
00105    {
00106       return FALSE;
00107    }
00108
00109    pfWlxActivateUserShell =
00110       (PFWLXACTIVATEUSERSHELL) GetProcAddress(hDll, "WlxActivateUserShell");
00111    if (!pfWlxActivateUserShell)
00112    {
00113       return FALSE;
00114    }
00115
00116    pfWlxLoggedOnSAS =
00117       (PFWLXLOGGEDONSAS) GetProcAddress(hDll, "WlxLoggedOnSAS");
00118    if (!pfWlxLoggedOnSAS)
00119    {
00120       return FALSE;
00121    }
00122
00123    pfWlxDisplayLockedNotice =
00124       (PFWLXDISPLAYLOCKEDNOTICE) GetProcAddress(hDll, "WlxDisplayLockedNotice");
00125    if (!pfWlxDisplayLockedNotice)
00126    {
00127       return FALSE;
00128    }
00129
00130    pfWlxIsLockOk =
00131       (PFWLXISLOCKOK) GetProcAddress(hDll, "WlxIsLockOk");
00132    if (!pfWlxIsLockOk)
00133    {
00134       return FALSE;
00135    }
00136
00137    pfWlxWkstaLockedSAS =
00138        (PFWLXWKSTALOCKEDSAS) GetProcAddress(hDll, "WlxWkstaLockedSAS");
00139    if (!pfWlxWkstaLockedSAS)
00140    {
00141       return FALSE;
00142    }
00143
00144    pfWlxIsLogoffOk =
00145       (PFWLXISLOGOFFOK) GetProcAddress(hDll, "WlxIsLogoffOk");
00146    if (!pfWlxIsLogoffOk)
00147    {
00148       return FALSE;
00149    }
00150
00151    pfWlxLogoff =
00152       (PFWLXLOGOFF) GetProcAddress(hDll, "WlxLogoff");
00153    if (!pfWlxLogoff)
00154    {
00155       return FALSE;
00156    }
00157
00158    pfWlxShutdown =
00159       (PFWLXSHUTDOWN) GetProcAddress(hDll, "WlxShutdown");
00160    if (!pfWlxShutdown)
00161    {
00162       return FALSE;
00163    }
00164
00165    //
00166    // Load functions for version 1.1 as necessary.
00167    //
00168    if (dwWlxVersion > WLX_VERSION_1_0)
00169    {
00170       pfWlxStartApplication =
00171          (PFWLXSTARTAPPLICATION) GetProcAddress(hDll, "WlxStartApplication");
00172       if (!pfWlxStartApplication)
00173       {
00174          return FALSE;
00175       }
00176
00177       pfWlxScreenSaverNotify =
00178          (PFWLXSCREENSAVERNOTIFY) GetProcAddress(hDll, "WlxScreenSaverNotify");
00179       if (!pfWlxScreenSaverNotify)
00180       {
00181          return FALSE;
00182       }
00183    }
00184
00185    //
00186    // Load functions for version 1.3 as necessary.
00187    //
00188    if (dwWlxVersion > WLX_VERSION_1_2)
00189    {
00190       pfWlxNetworkProviderLoad =
00191          (PFWLXNETWORKPROVIDERLOAD)
00192             GetProcAddress(hDll, "WlxNetworkProviderLoad");
00193       if (!pfWlxNetworkProviderLoad)
00194       {
00195          return FALSE;
00196       }
00197
00198       pfWlxDisplayStatusMessage =
00199          (PFWLXDISPLAYSTATUSMESSAGE)
00200             GetProcAddress(hDll, "WlxDisplayStatusMessage");
00201       if (!pfWlxDisplayStatusMessage)
00202       {
00203          return FALSE;
00204       }
00205
00206       pfWlxGetStatusMessage =
00207          (PFWLXGETSTATUSMESSAGE)
00208             GetProcAddress(hDll, "WlxGetStatusMessage");
00209       if (!pfWlxGetStatusMessage)
00210       {
00211          return FALSE;
00212       }
00213
00214       pfWlxRemoveStatusMessage =
00215          (PFWLXREMOVESTATUSMESSAGE)
00216             GetProcAddress(hDll, "WlxRemoveStatusMessage");
00217       if (!pfWlxRemoveStatusMessage)
00218       {
00219          return FALSE;
00220       }
00221    }
00222
00223    //
00224    // Load functions for newer version here...
00225    //
00226
00227    //
00228    // Everything loaded OK.
00229    //
00230    return TRUE;
00231 }
00232
00233
00234 BOOL
00235 WINAPI
00236 WlxNegotiate (DWORD   dwWinlogonVersion,
00237               DWORD * pdwDllVersion)
00238 {
00239    HINSTANCE hDll;
00240    DWORD dwWlxVersion = GINASTUB_VERSION;
00241
00242    //
00243    // Load MSGINA.DLL.
00244    //
00245    if (!(hDll = LoadLibrary(REALGINA_PATH)))
00246    {
00247       return FALSE;
00248    }
00249
00250    //
00251    // Get pointers to WlxNegotiate function in the real MSGINA.
00252    //
00253    pfWlxNegotiate = (PFWLXNEGOTIATE) GetProcAddress(hDll, "WlxNegotiate");
00254    if (!pfWlxNegotiate)
00255    {
00256       return FALSE;
00257    }
00258
00259    //
00260    // Handle older version of Winlogon.
00261    //
00262    if (dwWinlogonVersion < dwWlxVersion)
00263    {
00264       dwWlxVersion = dwWinlogonVersion;
00265    }
00266
00267    //
00268    // Negotiate with MSGINA for version that we can support.
00269    //
00270    if (!pfWlxNegotiate(dwWlxVersion, &dwWlxVersion))
00271    {
00272       return FALSE;
00273    }
00274
00275    //
00276    // Load the rest of the WLX functions from the real MSGINA.
00277    //
00278    if (!MyInitialize(hDll, dwWlxVersion))
00279    {
00280       return FALSE;
00281    }
00282
00283    //
00284    // Inform Winlogon which version to use.
00285    //
00286    *pdwDllVersion = g_dwVersion = dwWlxVersion;
00287
00288    return TRUE;
00289 }
00290
00291
00292 BOOL
00293 WINAPI
00294 WlxInitialize (LPWSTR  lpWinsta,
00295                HANDLE  hWlx,
00296                PVOID   pvReserved,
00297                PVOID   pWinlogonFunctions,
00298                PVOID * pWlxContext)
00299 {
00300
00301    //
00302    // Save pointer to dispatch table.
00303    //
00304    // Note that g_pWinlogon will need to be properly casted to the
00305    // appropriate version when used to call function in the dispatch
00306    // table.
00307    //
00308    // For example, assuming we are at WLX_VERSION_1_3, we would call
00309    // WlxSasNotify() as follows:
00310    //
00311    // ((PWLX_DISPATCH_VERSION_1_3) g_pWinlogon)->WlxSasNotify(hWlx, MY_SAS);
00312    //
00313    g_pWinlogon = pWinlogonFunctions;
00314
00315    //
00316    // Now hook the WlxDialogBoxParam() dispatch function.
00317    //
00318    HookWlxDialogBoxParam(g_pWinlogon, g_dwVersion);
00319
00320    return pfWlxInitialize(lpWinsta,
00321                           hWlx,
00322                           pvReserved,
00323                           pWinlogonFunctions,
00324                           pWlxContext);
00325 }
00326
00327
00328 VOID
00329 WINAPI
00330 WlxDisplaySASNotice (PVOID pWlxContext)
00331 {
00332    pfWlxDisplaySASNotice(pWlxContext);
00333 }
00334
00335
00336 int
00337 WINAPI
00338 WlxLoggedOutSAS (PVOID                pWlxContext,
00339                  DWORD                dwSasType,
00340                  PLUID                pAuthenticationId,
00341                  PSID                 pLogonSid,
00342                  PDWORD               pdwOptions,
00343                  PHANDLE              phToken,
00344                  PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
00345                  PVOID *              pProfile)
00346 {
00347    int iRet;
00348
00349    iRet = pfWlxLoggedOutSAS(pWlxContext,
00350                             dwSasType,
00351                             pAuthenticationId,
00352                             pLogonSid,
00353                             pdwOptions,
00354                             phToken,
00355                             pMprNotifyInfo,
00356                             pProfile);
00357
00358    if(iRet == WLX_SAS_ACTION_LOGON)
00359    {
00360       //
00361       // Copy pMprNotifyInfo and pLogonSid for later use.
00362       //
00363
00364       // pMprNotifyInfo->pszUserName
00365       // pMprNotifyInfo->pszDomain
00366       // pMprNotifyInfo->pszPassword
00367       // pMprNotifyInfo->pszOldPassword
00368    }
00369
00370    return iRet;
00371 }
00372
00373
00374 BOOL
00375 WINAPI
00376 WlxActivateUserShell (PVOID pWlxContext,
00377                       PWSTR pszDesktopName,
00378                       PWSTR pszMprLogonScript,
00379                       PVOID pEnvironment)
00380 {
00381    return pfWlxActivateUserShell(pWlxContext,
00382                                  pszDesktopName,
00383                                  pszMprLogonScript,
00384                                  pEnvironment);
00385 }
00386
00387
00388 int
00389 WINAPI
00390 WlxLoggedOnSAS (PVOID pWlxContext,
00391                 DWORD dwSasType,
00392                 PVOID pReserved)
00393 {
00394    return pfWlxLoggedOnSAS(pWlxContext,
00395                            dwSasType,
00396                            pReserved);
00397 }
00398
00399
00400 VOID
00401 WINAPI
00402 WlxDisplayLockedNotice (PVOID pWlxContext)
00403 {
00404    pfWlxDisplayLockedNotice(pWlxContext);
00405 }
00406
00407
00408 BOOL
00409 WINAPI
00410 WlxIsLockOk (PVOID pWlxContext)
00411 {
00412    return pfWlxIsLockOk(pWlxContext);
00413 }
00414
00415
00416 int
00417 WINAPI
00418 WlxWkstaLockedSAS (PVOID pWlxContext,
00419                    DWORD dwSasType)
00420 {
00421    return pfWlxWkstaLockedSAS(pWlxContext, dwSasType);
00422 }
00423
00424
00425 BOOL
00426 WINAPI
00427 WlxIsLogoffOk (PVOID pWlxContext)
00428 {
00429    BOOL bSuccess;
00430
00431    bSuccess = pfWlxIsLogoffOk(pWlxContext);
00432
00433    if(bSuccess)
00434    {
00435       //
00436       // If it's OK to logoff, make sure stored credentials are cleaned up.
00437       //
00438    }
00439
00440    return bSuccess;
00441 }
00442
00443
00444 VOID
00445 WINAPI
00446 WlxLogoff (PVOID pWlxContext)
00447 {
00448    pfWlxLogoff(pWlxContext);
00449 }
00450
00451
00452 VOID
00453 WINAPI
00454 WlxShutdown(PVOID pWlxContext,
00455             DWORD ShutdownType)
00456 {
00457    pfWlxShutdown(pWlxContext, ShutdownType);
00458 }
00459
00460
00461 //
00462 // New for version 1.1
00463 //
00464
00465 BOOL
00466 WINAPI
00467 WlxScreenSaverNotify (PVOID  pWlxContext,
00468                       BOOL * pSecure)
00469 {
00470    return pfWlxScreenSaverNotify(pWlxContext, pSecure);
00471 }
00472
00473 BOOL
00474 WINAPI
00475 WlxStartApplication (PVOID pWlxContext,
00476                      PWSTR pszDesktopName,
00477                      PVOID pEnvironment,
00478                      PWSTR pszCmdLine)
00479 {
00480    return pfWlxStartApplication(pWlxContext,
00481                                 pszDesktopName,
00482                                 pEnvironment,
00483                                 pszCmdLine);
00484 }
00485
00486
00487 //
00488 // New for version 1.3
00489 //
00490
00491 BOOL
00492 WINAPI
00493 WlxNetworkProviderLoad (PVOID                pWlxContext,
00494                         PWLX_MPR_NOTIFY_INFO pNprNotifyInfo)
00495 {
00496    return pfWlxNetworkProviderLoad(pWlxContext, pNprNotifyInfo);
00497 }
00498
00499
00500 BOOL
00501 WINAPI
00502 WlxDisplayStatusMessage (PVOID pWlxContext,
00503                          HDESK hDesktop,
00504                          DWORD dwOptions,
00505                          PWSTR pTitle,
00506                          PWSTR pMessage)
00507 {
00508    return pfWlxDisplayStatusMessage(pWlxContext,
00509                                     hDesktop,
00510                                     dwOptions,
00511                                     pTitle,
00512                                     pMessage);
00513 }
00514
00515
00516 BOOL
00517 WINAPI
00518 WlxGetStatusMessage (PVOID   pWlxContext,
00519                      DWORD * pdwOptions,
00520                      PWSTR   pMessage,
00521                      DWORD   dwBufferSize)
00522 {
00523    return pfWlxGetStatusMessage(pWlxContext,
00524                                 pdwOptions,
00525                                 pMessage,
00526                                 dwBufferSize);
00527 }
00528
00529
00530 BOOL
00531 WINAPI
00532 WlxRemoveStatusMessage (PVOID pWlxContext)
00533 {
00534    return pfWlxRemoveStatusMessage(pWlxContext);
00535 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/AdvReco/AdvReco.h Source File

  • TabletPC
  • AdvReco

AdvReco.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      AdvRecoApp.h
00013 //
00014 // Description:
00015 //      The header file for the CAdvRecoApp class - the application window
00016 //      class of the AdvReco sample.
00017 //    The methods of the class are defined in the AdvReco.cpp file.
00018 //
00019 //--------------------------------------------------------------------------
00020
00021 #pragma once
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // CAdvRecoApp
00025
00026 class CAdvRecoApp :
00027     public CWindowImpl<CAdvRecoApp>,
00028     public IInkCollectorEventsImpl<CAdvRecoApp>,
00029     public IInkRecognitionEventsImpl<CAdvRecoApp>
00030 {
00031 public:
00032     // Constants
00033
00034     enum {
00035         // submenus indices
00036         mc_iSubmenuRecognizers = 1,
00037         mc_iSubmenuInputScopes = 2,
00038         mc_iSubmenuGuides = 3,
00039         mc_iSubmenuModes = 4,
00040         // child windows IDs
00041         mc_iInputWndId = 1,
00042         mc_iOutputWndId = 2,
00043         mc_iStatusWndId = 3,
00044         mc_iSSGestLVId = 4,
00045         mc_iMSGestLVId = 5,
00046         // recognition guide box data
00047         mc_iNumRowsCols = 100,
00048         mc_iGuideColWidth = 100,
00049         mc_iGuideRowHeight = 100,
00050         mc_cxBoxMargin = 4,
00051         mc_cyBoxMargin = 4,
00052         // the width of the gesture list views
00053         mc_cxGestLVWidth = 160,
00054         // the number of the gesture names in the string table
00055         mc_cNumSSGestures = 36,     // single stroke gestures
00056         mc_cNumMSGestures =  6,     // multi-stroke gestures
00057         // pen width
00058         mc_iPenWidth = 5
00059     };
00060
00061     // Automation API interface pointers
00062     CComPtr<IInkCollector>          m_spIInkCollector;
00063     CComPtr<IInkRenderer>           m_spIInkRenderer;
00064     CComPtr<IInkDisp>               m_spIInkDisp;
00065     CComPtr<IInkStrokes>            m_spIInkStrokes;
00066     CComPtr<IInkRecognizerContext>  m_spIInkRecoContext;
00067     CComPtr<IInkRecognizers>        m_spIInkRecognizers;
00068     CComPtr<IInkRecognizerGuide>    m_spIInkRecoGuide;
00069
00070     // Child windows
00071     CInkInputWnd    m_wndInput;
00072     CRecoOutputWnd  m_wndResults;
00073     HWND            m_hwndStatusBar;
00074     HWND            m_hwndSSGestLV;     // single stroke gestures list view
00075     HWND            m_hwndMSGestLV;     // multiple stroke gestures list view
00076
00077     // Helper data members
00078     UINT            m_nCmdRecognizer;
00079     UINT            m_nCmdInputScope;
00080     UINT            m_nCmdGuide;
00081     UINT            m_nCmdMode;
00082     CComBSTR        m_bstrCurRecoName;
00083     bool            m_bCoerceInputScope;
00084     SIZE            m_szGuideBox;
00085     bool            m_bAllSSGestures;
00086     bool            m_bAllMSGestures;
00087
00088     // Static method that creates an object of the class
00089     static int Run(int nCmdShow);
00090
00091     // Constructor
00092     CAdvRecoApp() :
00093         m_hwndStatusBar(NULL), m_hwndSSGestLV(NULL), m_hwndMSGestLV(NULL),
00094         m_bCoerceInputScope(false),
00095         m_nCmdGuide(0), m_nCmdInputScope(0), m_nCmdRecognizer(0), m_nCmdMode(0),
00096         m_bAllSSGestures(true), m_bAllMSGestures(true)
00097     {
00098         m_szGuideBox.cx = m_szGuideBox.cy = 0;
00099     }
00100
00101     // Helper methods
00102     HMENU   LoadMenu();
00103     bool    CreateChildWindows();
00104     void    UpdateLayout();
00105     void    UpdateMenuRadioItems(UINT iSubMenu, UINT idCheck, UINT idUncheck);
00106     void    UpdateInputScopeMenu();
00107     void    UpdateStatusBar();
00108     bool    UseRecognizer(IInkRecognizer* pIInkRecognizer);
00109     bool    GetGestureName(InkApplicationGesture idGesture, UINT& idGestureName);
00110     void    PresetGestures();
00111
00112
00113 // Declare the class objects' window class with NULL background.
00114 // There's no need to paint CAdvRecoApp window background because
00115 // the entire client area is covered by the child windows.
00116 DECLARE_WND_CLASS_EX(NULL, 0, -1)
00117
00118 // ATL macro's to declare which commands/messages the class is interested in.
00119 BEGIN_MSG_MAP(CAdvRecoApp)
00120     MESSAGE_HANDLER(WM_CREATE, OnCreate)
00121     MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
00122     MESSAGE_HANDLER(WM_SIZE, OnSize)
00123     COMMAND_ID_HANDLER(ID_RECOGNIZER_DEFAULT, OnRecognizer)
00124     COMMAND_RANGE_HANDLER(ID_RECOGNIZER_FIRST, ID_RECOGNIZER_LAST, OnRecognizer)
00125     COMMAND_ID_HANDLER(ID_INPUTSCOPE_COERCE, OnInputScopeCoerce)
00126     COMMAND_RANGE_HANDLER(ID_INPUTSCOPE_FIRST, ID_INPUTSCOPE_LAST, OnInputScope)
00127     COMMAND_ID_HANDLER(ID_GUIDE_NONE, OnGuide)
00128     COMMAND_ID_HANDLER(ID_GUIDE_LINES, OnGuide)
00129     COMMAND_ID_HANDLER(ID_GUIDE_BOXES, OnGuide)
00130     COMMAND_ID_HANDLER(ID_MODE_INK, OnMode)
00131     COMMAND_ID_HANDLER(ID_MODE_INK_AND_GESTURES, OnMode)
00132     COMMAND_ID_HANDLER(ID_MODE_GESTURES, OnMode)
00133     COMMAND_ID_HANDLER(ID_RECOGNIZE, OnRecognize)
00134     COMMAND_ID_HANDLER(ID_CLEAR, OnClear)
00135     COMMAND_ID_HANDLER(ID_EXIT, OnExit)
00136     NOTIFY_HANDLER(mc_iSSGestLVId, LVN_COLUMNCLICK, OnLVColumnClick)
00137     NOTIFY_HANDLER(mc_iMSGestLVId, LVN_COLUMNCLICK, OnLVColumnClick)
00138     NOTIFY_HANDLER(mc_iSSGestLVId, LVN_ITEMCHANGING, OnLVItemChanging)
00139     NOTIFY_HANDLER(mc_iMSGestLVId, LVN_ITEMCHANGING, OnLVItemChanging)
00140 END_MSG_MAP()
00141
00142 public:
00143
00144     // Window message handlers
00145     LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00146     LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00147     LRESULT OnSetFocus(UINT, WPARAM, LPARAM, BOOL& bHandled);
00148     LRESULT OnSize(UINT, WPARAM, LPARAM, BOOL& bHandled);
00149     LRESULT OnLVColumnClick(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
00150     LRESULT OnLVItemChanging(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
00151
00152     // Command handlers
00153     LRESULT OnRecognizer(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00154     LRESULT OnInputScopeCoerce(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00155     LRESULT OnInputScope(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00156     LRESULT OnGuide(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00157     LRESULT OnMode(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00158     LRESULT OnRecognize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00159     LRESULT OnClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00160     LRESULT OnExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00161
00162     // Ink collector event handler
00163     HRESULT OnStroke(IInkCursor* pIInkCursor, IInkStrokeDisp* pIInkStroke,
00164                      VARIANT_BOOL* pbCancel);
00165     HRESULT OnGesture(IInkCursor* pIInkCursor, IInkStrokes* pIInkStrokes,
00166                       VARIANT vGestures, VARIANT_BOOL* pbCancel);
00167
00168     // Recognition event handler
00169     HRESULT OnRecognitionWithAlternates(IInkRecognitionResult* pIInkRecoResult,
00170                                         VARIANT vCustomParam,
00171                                         InkRecognitionStatus RecognitionStatus);
00172 };
00173
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/compdata.Cpp Source File

  • SysMgmt
  • MMC
  • CutCopy

compdata.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "CompData.h"
00021 #include "DataObj.h"
00022 #include "Space.h"
00023 #include "resource.h"
00024 #include <crtdbg.h>
00025
00026 CComponentData::CComponentData()
00027 : m_cref(0), m_ipConsoleNameSpace(NULL), m_ipConsole(NULL)
00028 {
00029     OBJECT_CREATED
00030
00031         m_pStaticNode = new CStaticNode;
00032 }
00033
00034 CComponentData::~CComponentData()
00035 {
00036     if (m_pStaticNode) {
00037         delete m_pStaticNode;
00038     }
00039
00040     OBJECT_DESTROYED
00041 }
00042
00043 ///////////////////////
00044 // IUnknown implementation
00045 ///////////////////////
00046
00047 STDMETHODIMP CComponentData::QueryInterface(REFIID riid, LPVOID *ppv)
00048 {
00049     if (!ppv)
00050         return E_FAIL;
00051
00052     *ppv = NULL;
00053
00054     if (IsEqualIID(riid, IID_IUnknown))
00055         *ppv = static_cast<IComponentData *>(this);
00056     else if (IsEqualIID(riid, IID_IComponentData))
00057         *ppv = static_cast<IComponentData *>(this);
00058
00059     if (*ppv)
00060     {
00061         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00062         return S_OK;
00063     }
00064
00065     return E_NOINTERFACE;
00066 }
00067
00068 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00069 {
00070     return InterlockedIncrement((LONG *)&m_cref);
00071 }
00072
00073 STDMETHODIMP_(ULONG) CComponentData::Release()
00074 {
00075     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00076     {
00077         // we need to decrement our object count in the DLL
00078         delete this;
00079         return 0;
00080     }
00081
00082     return m_cref;
00083 }
00084
00085 ///////////////////////////////
00086 // Interface IComponentData
00087 ///////////////////////////////
00088 HRESULT CComponentData::Initialize(
00089                                    /* [in] */ LPUNKNOWN pUnknown)
00090 {
00091     HRESULT      hr;
00092
00093     //
00094     // Get pointer to name space interface
00095     //
00096     hr = pUnknown->QueryInterface(IID_IConsoleNameSpace, (void **)&m_ipConsoleNameSpace);
00097     _ASSERT( S_OK == hr );
00098
00099     //
00100     // Get pointer to console interface
00101     //
00102     hr = pUnknown->QueryInterface(IID_IConsole, (void **)&m_ipConsole);
00103     _ASSERT( S_OK == hr );
00104
00105     IImageList *pImageList;
00106     m_ipConsole->QueryScopeImageList(&pImageList);
00107     _ASSERT( S_OK == hr );
00108
00109     hr = pImageList->ImageListSetStrip( (long *)m_pStaticNode->m_pBMapSm, // pointer to a handle
00110         (long *)m_pStaticNode->m_pBMapLg, // pointer to a handle
00111         0, // index of the first image in the strip
00112         RGB(0, 128, 128)  // color of the icon mask
00113         );
00114
00115     pImageList->Release();
00116
00117     return S_OK;
00118 }
00119
00120 HRESULT CComponentData::CreateComponent(
00121                                         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent)
00122 {
00123     *ppComponent = NULL;
00124
00125     CComponent *pComponent = new CComponent(this);
00126
00127     if (NULL == pComponent)
00128         return E_OUTOFMEMORY;
00129
00130     return pComponent->QueryInterface(IID_IComponent, (void **)ppComponent);
00131 }
00132
00133 HRESULT CComponentData::Notify(
00134                                /* [in] */ LPDATAOBJECT lpDataObject,
00135                                /* [in] */ MMC_NOTIFY_TYPE event,
00136                                /* [in] */ LPARAM arg,
00137                                /* [in] */ LPARAM param)
00138 {
00139     MMCN_Crack(TRUE, lpDataObject, this, NULL, event, arg, param);
00140
00141     HRESULT hr = S_FALSE;
00142
00143   //Get our data object. If it is NULL, we return with S_FALSE.
00144   //See implementation of GetOurDataObject() to see how to
00145   //handle special data objects.
00146   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00147   if (NULL == pDataObject)
00148     return S_FALSE;
00149
00150   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00151
00152     switch (event)
00153     {
00154     case MMCN_EXPAND:
00155         hr = base->OnExpand(m_ipConsoleNameSpace, m_ipConsole, (HSCOPEITEM)param);
00156         break;
00157
00158     case MMCN_ADD_IMAGES:
00159         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00160         break;
00161
00162     case MMCN_DELETE:
00163     CSpaceStation* pSpaceStn = dynamic_cast<CSpaceStation*>(base);
00164     if (NULL != pSpaceStn)
00165     {
00166       hr = pSpaceStn->OnDeleteScopeItem(m_ipConsoleNameSpace);
00167     }
00168
00169     break;
00170
00171   }
00172     return hr;
00173 }
00174
00175 HRESULT CComponentData::Destroy( void)
00176 {
00177     // Free interfaces
00178     if (m_ipConsoleNameSpace) {
00179         m_ipConsoleNameSpace->Release();
00180         m_ipConsoleNameSpace = NULL;
00181     }
00182
00183     if (m_ipConsole) {
00184         m_ipConsole->Release();
00185         m_ipConsole = NULL;
00186     }
00187
00188     return S_OK;
00189 }
00190
00191 HRESULT CComponentData::QueryDataObject(
00192                                         /* [in] */ MMC_COOKIE cookie,
00193                                         /* [in] */ DATA_OBJECT_TYPES type,
00194                                         /* [out] */ LPDATAOBJECT *ppDataObject)
00195 {
00196     CDataObject *pObj = NULL;
00197
00198     if (cookie == 0)
00199         pObj = new CDataObject((MMC_COOKIE)m_pStaticNode, type);
00200     else
00201         pObj = new CDataObject(cookie, type);
00202
00203     if (!pObj)
00204         return E_OUTOFMEMORY;
00205
00206     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00207
00208     return S_OK;
00209 }
00210
00211 HRESULT CComponentData::GetDisplayInfo(
00212                                        /* [out][in] */ SCOPEDATAITEM *pScopeDataItem)
00213 {
00214     HRESULT hr = S_FALSE;
00215
00216     // if they are asking for the SDI_STR we have one of those to give
00217     if (pScopeDataItem->lParam) {
00218         CDelegationBase *base = (CDelegationBase *)pScopeDataItem->lParam;
00219         if (pScopeDataItem->mask & SDI_STR) {
00220                         LPCTSTR pszT = base->GetDisplayName();
00221                         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00222             pScopeDataItem->displayname = pszW;
00223         }
00224
00225         if (pScopeDataItem->mask & SDI_IMAGE) {
00226             pScopeDataItem->nImage = base->GetBitmapIndex();
00227         }
00228     }
00229
00230     return hr;
00231 }
00232
00233 HRESULT CComponentData::CompareObjects(
00234                                        /* [in] */ LPDATAOBJECT lpDataObjectA,
00235                                        /* [in] */ LPDATAOBJECT lpDataObjectB)
00236 {
00237     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00238     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00239
00240     // compare the object pointers
00241     if (baseA->GetCookie() == baseB->GetCookie())
00242         return S_OK;
00243
00244     return S_FALSE;
00245 }
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/EdHost.idl Source File

  • Web
  • Browser
  • EditHost

EdHost.idl

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // EdHost.idl : IDL source for EdHost.dll
00006 //
00007
00008 // This file will be processed by the MIDL tool to
00009 // produce the type library (EdHost.tlb) and marshalling code.
00010 #define DISPID_GETHWND   500
00011
00012 import "oaidl.idl";
00013 import "ocidl.idl";
00014
00015   [
00016     object,
00017     uuid(5FD6158A-71F6-4F20-B8A9-6EAF5D032D15),
00018     dual,
00019     helpstring("IBrowserHost Interface"),
00020     pointer_default(unique)
00021   ]
00022   interface IBrowserHost : IDispatch
00023   {
00024     HRESULT Run();
00025     HRESULT Stop();
00026     [id(DISPID_GETHWND), helpstring("method GetHWND")] HRESULT GetHwnd(long* phwnd);
00027   };
00028   [
00029     object,
00030     uuid(213DA9A8-B856-4049-BBA3-11758E902390),
00031     helpstring("IGrid Interface"),
00032     pointer_default(unique)
00033   ]
00034   interface IGrid : IUnknown
00035   {
00036     [propget, helpstring("property GridSize")] HRESULT GridSize([out, retval] long *pVal);
00037     [propput, helpstring("property GridSize")] HRESULT GridSize([in] long newVal);
00038   };
00039   [
00040     object,
00041     uuid(CCBFDE40-FE5D-4A3C-880B-47839715E3AC),
00042     dual,
00043     helpstring("ISnap Interface"),
00044     pointer_default(unique)
00045   ]
00046   interface ISnap : IDispatch
00047   {
00048     [propget, id(1), helpstring("property SnapIncrement")] HRESULT SnapIncrement([out, retval] long *pVal);
00049     [propput, id(1), helpstring("property SnapIncrement")] HRESULT SnapIncrement([in] long newVal);
00050     [propget, id(2), helpstring("property SnapOn")] HRESULT SnapOn([out, retval] BOOL *pVal);
00051     [propput, id(2), helpstring("property SnapOn")] HRESULT SnapOn([in] BOOL newVal);
00052   };
00053
00054 [
00055   uuid(77562D86-6956-4863-AA6D-2646344624EE),
00056   version(1.0),
00057   helpstring("EdHost 1.0 Type Library")
00058 ]
00059 library EDHOSTLib
00060 {
00061   importlib("stdole32.tlb");
00062   importlib("stdole2.tlb");
00063
00064   [
00065     uuid(2A2B21D5-F43B-4EA0-9DFA-1EFE9F9E211A),
00066     helpstring("BrowserHost Class")
00067   ]
00068   coclass BrowserHost
00069   {
00070     [default] interface IBrowserHost;
00071   };
00072
00073   [
00074     uuid(1429392E-A3DF-45AD-A1A3-B02836417AB1),
00075     helpstring("Grid Class")
00076   ]
00077   coclass Grid
00078   {
00079     [default] interface IGrid;
00080   };
00081   [
00082     uuid(1C33EB2D-823E-4897-858B-E06D6BD3CC07),
00083     helpstring("Snap Class")
00084   ]
00085   coclass Snap
00086   {
00087     [default] interface ISnap;
00088   };
00089
00090 };
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDelegationBase Member List

This is the complete list of members for CDelegationBase, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetBitmapIndex()=0 | CDelegationBase | [pure virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetDisplayName(int nCol=0)=0 | CDelegationBase | [pure virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
getNodeType() | CDelegationBase | [inline, virtual]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_handle | CDelegationBase | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CDelegationBase | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
Generated on Wed Nov 13 2024 16:56:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/PerfDllS/LeakyBin/Resource.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • PerfDllS
  • LeakyBin

Resource.h

Go to the documentation of this file.
00001 /* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00003 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 PARTICULAR PURPOSE.
00005
00006 Copyright (C) 1995 - 2000.  Microsoft Corporation.  All rights reserved.
00007 */
00008
00009
00010 // Next default values for new objects
00011 //
00012 #ifdef APSTUDIO_INVOKED
00013 #ifndef APSTUDIO_READONLY_SYMBOLS
00014 #define _APS_NO_MFC                     1
00015 #define _APS_NEXT_RESOURCE_VALUE        101
00016 #define _APS_NEXT_COMMAND_VALUE         40001
00017 #define _APS_NEXT_CONTROL_VALUE         1000
00018 #define _APS_NEXT_SYMED_VALUE           101
00019 #endif
00020 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/Iconpro/Icons.C Source File

  • WinUI
  • Resource
  • Iconpro

Icons.C

Go to the documentation of this file.
00001   /****************************************************************************\
00002 *
00003 *     FILE:     ICONS.C
00004 *
00005 *     PURPOSE:  IconPro Project Icon handing Code C file
00006 *
00007 *     COMMENTS: This file contains the icon handling code
00008 *
00009 *     FUNCTIONS:
00010 *      EXPORTS:
00011 *               ReadIconFromICOFile        - Reads Icon from ICO file
00012 *               WriteIconToICOFile         - Writes Icon to ICO file
00013 *               MakeIconFromResource       - Makes HICON from a resource
00014 *               ReadIconFromEXEFile        - Reads Icon from a EXE or DLL file
00015 *               IconImageToClipBoard       - Puts icon image on clipboard
00016 *               IconImageFromClipBoard     - Gets icon image from clipboard
00017 *               CreateBlankNewFormatIcon   - Makes a new, blank icon image
00018 *               DrawXORMask                - Draws XOR mask using DIBs
00019 *               DrawANDMask                - Draws AND mask using DIBs
00020 *               GetXORImageRect            - Calculates XOR image position
00021 *               MakeNewANDMaskBasedOnPoint - Calculates new AND mask
00022 *               ConvertBMPFileToIcon       - Converts BMP to Icon
00023 *               IconImageToBMPFile         - Writes an icon image to BMP file
00024 *      LOCALS:
00025 *               ReadICOHeader              - Reads ICO file header
00026 *               AdjustIconImagePointers    - Adjusts internal pointers
00027 *               ExtractDlgProc             - Dlg Proc for extract dialog
00028 *               MyEnumProcedure            - For EnumResourceNames()
00029 *               GetIconFromInstance        - Extracts Icon from Instance
00030 *               ChooseIconFromEXEFile      - Gets a user's choice icon from file
00031 *               WriteICOHeader             - Writes ICO file header
00032 *               CalculateImageOffset       - Calcs offset in file of image
00033 *               DIBToIconImage             - Converts DIB to icon image
00034 *
00035 *     Copyright 1995 - 2000 Microsoft Corp.
00036 *
00037 *
00038 * History:
00039 *                July '95 - Created
00040 *
00041 \****************************************************************************/
00042 #include <Windows.h>
00043 #include <commdlg.h>
00044 #include <malloc.h>
00045 #include <tchar.h>
00046 #include "Resource.h"
00047 #include "IconPro.h"
00048 #include "Icons.H"
00049 #include "Dib.H"
00050
00051
00052 /****************************************************************************/
00053 // Structs used locally (file scope)
00054 // Resource Position info - size and offset of a resource in a file
00055 typedef struct
00056 {
00057     DWORD dwBytes;
00058     DWORD dwOffset;
00059 } RESOURCEPOSINFO, *PRESOURCEPOSINFO;
00060
00061 // EXE/DLL icon information - filename, instance handle and ID
00062 typedef struct
00063 {
00064     PCTSTR      szFileName;
00065     HINSTANCE hInstance;
00066     PTSTR     pID;
00067 } EXEDLLICONINFO, *PEXEDLLICONINFO;
00068 /****************************************************************************/
00069
00070
00071 /****************************************************************************/
00072 // External Globals
00073 extern HINSTANCE    hInst;
00074 extern HWND         hWndMain;
00075 /****************************************************************************/
00076
00077 /****************************************************************************/
00078 // Prototypes for local functions
00079 UINT ReadICOHeader( HANDLE hFile );
00080 BOOL AdjustIconImagePointers( ICONIMAGE* pImage );
00081 BOOL CALLBACK ExtractDlgProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
00082 BOOL CALLBACK MyEnumProcedure( HANDLE  hModule, PCTSTR  pszType, PTSTR  pszName, LPARAM  lParam );
00083 HICON GetIconFromInstance( HINSTANCE hInstance, PTSTR nIndex );
00084 PTSTR ChooseIconFromEXEFile( PEXEDLLICONINFO pEDII );
00085 BOOL WriteICOHeader( HANDLE hFile, UINT nNumEntries );
00086 DWORD CalculateImageOffset( ICONRESOURCE* pIR, UINT nIndex );
00087 BOOL DIBToIconImage( ICONIMAGE* pii, PBYTE pDIB, BOOL bStretch );
00088 /****************************************************************************/
00089
00090
00091
00092 /****************************************************************************
00093 *
00094 *     FUNCTION: MakeIconFromResource
00095 *
00096 *     PURPOSE:  Makes an HICON from an icon resource
00097 *
00098 *     PARAMS:   ICONIMAGE* pIcon - pointer to the icon resource
00099 *
00100 *     RETURNS:  HICON - handle to the new icon, NULL for failure
00101 *
00102 * History:
00103 *                July '95 - Created
00104 *
00105 \****************************************************************************/
00106 HICON MakeIconFromResource (
00107     ICONIMAGE* pIcon )
00108 {
00109     HICON  hIcon = NULL;
00110
00111     // Sanity Check
00112     if( pIcon == NULL )
00113     {
00114         return NULL;
00115     }
00116
00117     if( pIcon->pBits == NULL )
00118     {
00119         return NULL;
00120     }
00121
00122     // Let the OS do the real work :)
00123     hIcon = CreateIconFromResourceEx( pIcon->pBits, pIcon->dwNumBytes, TRUE, 0x00030000,
00124             (*(PBITMAPINFOHEADER)(pIcon->pBits)).biWidth, (*(PBITMAPINFOHEADER)(pIcon->pBits)).biHeight/2, 0 );
00125
00126     // It failed, odds are good we're on NT so try the non-Ex way
00127     if( hIcon == NULL )
00128     {
00129         // We would break on NT if we try with a 16bpp image
00130         if(pIcon->pbi->bmiHeader.biBitCount != 16)
00131         {
00132             hIcon = CreateIconFromResource( pIcon->pBits, pIcon->dwNumBytes, TRUE, 0x00030000 );
00133         }
00134     }
00135     return hIcon;
00136 }
00137 /* End MakeIconFromResource() **********************************************/
00138
00139
00140
00141
00142
00143 /****************************************************************************
00144 *
00145 *     FUNCTION: ReadIconFromICOFile
00146 *
00147 *     PURPOSE:  Reads an Icon Resource from an ICO file
00148 *
00149 *     PARAMS:   PCTSTR szFileName - Name of the ICO file
00150 *
00151 *     RETURNS:  PICONRESOURCE - pointer to the resource, NULL for failure
00152 *
00153 * History:
00154 *                July '95 - Created
00155 *
00156 \****************************************************************************/
00157 ICONRESOURCE* ReadIconFromICOFile (
00158     PCTSTR szFileName )
00159 {
00160     ICONRESOURCE*       pIR = NULL;
00161     ICONRESOURCE*       pNew = NULL;
00162     HANDLE              hFile = NULL;
00163     PRESOURCEPOSINFO    pRPI = NULL;
00164     UINT                i;
00165     DWORD             dwBytesRead;
00166     ICONDIRENTRY*       pIDE = NULL;
00167
00168
00169     // Open the file
00170     if( (hFile = CreateFile( szFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL )) == INVALID_HANDLE_VALUE )
00171     {
00172         MessageBox( hWndMain, TEXT("Error Opening File for Reading"), szFileName, MB_OK );
00173         return NULL;
00174     }
00175     // Allocate memory for the resource structure
00176     if( (pIR = malloc( sizeof(ICONRESOURCE) )) == NULL )
00177     {
00178         MessageBox( hWndMain, TEXT("Error Allocating Memory"), szFileName, MB_OK );
00179         CloseHandle( hFile );
00180         return NULL;
00181     }
00182     // Read in the header
00183     if( (pIR->nNumImages = ReadICOHeader( hFile )) == (UINT)-1 )
00184     {
00185         MessageBox( hWndMain, TEXT("Error Reading File Header"), szFileName, MB_OK );
00186         CloseHandle( hFile );
00187         free( pIR );
00188         return NULL;
00189     }
00190     // Adjust the size of the struct to account for the images
00191     if( (pNew = realloc( pIR, sizeof(ICONRESOURCE) + ((pIR->nNumImages-1) * sizeof(ICONIMAGE)) )) == NULL )
00192     {
00193         MessageBox( hWndMain, TEXT("Error Allocating Memory"), szFileName, MB_OK );
00194         CloseHandle( hFile );
00195         free( pIR );
00196         return NULL;
00197     }
00198     pIR = pNew;
00199     // Store the original name
00200     lstrcpyn( pIR->szOriginalICOFileName, szFileName, MAX_PATH - 1);
00201     lstrcpyn( pIR->szOriginalDLLFileName, TEXT(""), MAX_PATH - 1 );
00202     // Allocate enough memory for the icon directory entries
00203     if( (pIDE = malloc( pIR->nNumImages * sizeof( ICONDIRENTRY ) ) ) == NULL )
00204     {
00205         MessageBox( hWndMain, TEXT("Error Allocating Memory"), szFileName, MB_OK );
00206         CloseHandle( hFile );
00207         free( pIR );
00208         return NULL;
00209     }
00210     // Read in the icon directory entries
00211     if( ! ReadFile( hFile, pIDE, pIR->nNumImages * sizeof( ICONDIRENTRY ), &dwBytesRead, NULL ) )
00212     {
00213         MessageBox( hWndMain, TEXT("Error Reading File"), szFileName, MB_OK );
00214         CloseHandle( hFile );
00215         free( pIR );
00216         return NULL;
00217     }
00218     if( dwBytesRead != pIR->nNumImages * sizeof( ICONDIRENTRY ) )
00219     {
00220         MessageBox( hWndMain, TEXT("Error Reading File"), szFileName, MB_OK );
00221         CloseHandle( hFile );
00222         free( pIR );
00223         return NULL;
00224     }
00225     // Loop through and read in each image
00226     for( i = 0; i < pIR->nNumImages; i++ )
00227     {
00228         // Allocate memory for the resource
00229         if( (pIR->IconImages[i].pBits = malloc(pIDE[i].dwBytesInRes)) == NULL )
00230         {
00231             MessageBox( hWndMain, TEXT("Error Allocating Memory"), szFileName, MB_OK );
00232             CloseHandle( hFile );
00233             free( pIR );
00234             free( pIDE );
00235             return NULL;
00236         }
00237         pIR->IconImages[i].dwNumBytes = pIDE[i].dwBytesInRes;
00238         // Seek to beginning of this image
00239         if( SetFilePointer( hFile, pIDE[i].dwImageOffset, NULL, FILE_BEGIN ) == INVALID_SET_FILE_POINTER )
00240         {
00241             MessageBox( hWndMain, TEXT("Error Seeking in File"), szFileName, MB_OK );
00242             CloseHandle( hFile );
00243             free( pIR );
00244             free( pIDE );
00245             return NULL;
00246         }
00247         // Read it in
00248         if( ! ReadFile( hFile, pIR->IconImages[i].pBits, pIDE[i].dwBytesInRes, &dwBytesRead, NULL ) )
00249         {
00250             MessageBox( hWndMain, TEXT("Error Reading File"), szFileName, MB_OK );
00251             CloseHandle( hFile );
00252             free( pIR );
00253             free( pIDE );
00254             return NULL;
00255         }
00256         if( dwBytesRead != pIDE[i].dwBytesInRes )
00257         {
00258             MessageBox( hWndMain, TEXT("Error Reading File"), szFileName, MB_OK );
00259             CloseHandle( hFile );
00260             free( pIDE );
00261             free( pIR );
00262             return NULL;
00263         }
00264         // Set the internal pointers appropriately
00265         if( ! AdjustIconImagePointers( &(pIR->IconImages[i]) ) )
00266         {
00267             MessageBox( hWndMain, TEXT("Error Converting to Internal Format"), szFileName, MB_OK );
00268             CloseHandle( hFile );
00269             free( pIDE );
00270             free( pIR );
00271             return NULL;
00272         }
00273     }
00274     // Clean up
00275     free( pIDE );
00276     free( pRPI );
00277     CloseHandle( hFile );
00278     return pIR;
00279 }
00280 /* End ReadIconFromICOFile() **********************************************/
00281
00282
00283
00284
00285 /****************************************************************************
00286 *
00287 *     FUNCTION: AdjustIconImagePointers
00288 *
00289 *     PURPOSE:  Adjusts internal pointers in icon resource struct
00290 *
00291 *     PARAMS:   ICONIMAGE* pImage - the resource to handle
00292 *
00293 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
00294 *
00295 * History:
00296 *                July '95 - Created
00297 *
00298 \****************************************************************************/
00299 BOOL AdjustIconImagePointers (
00300     ICONIMAGE* pImage )
00301 {
00302     // Sanity check
00303     if( pImage==NULL )
00304     {
00305         return FALSE;
00306     }
00307
00308     // BITMAPINFO is at beginning of bits
00309     pImage->pbi = (PBITMAPINFO)pImage->pBits;
00310     // Width - simple enough
00311     pImage->Width = pImage->pbi->bmiHeader.biWidth;
00312     // Icons are stored in funky format where height is doubled - account for it
00313     pImage->Height = (pImage->pbi->bmiHeader.biHeight)/2;
00314     // How many colors?
00315     pImage->Colors = pImage->pbi->bmiHeader.biPlanes * pImage->pbi->bmiHeader.biBitCount;
00316     // XOR bits follow the header and color table
00317     pImage->pXOR = (PBYTE)FindDIBBits((PSTR)pImage->pbi);
00318     // AND bits follow the XOR bits
00319     pImage->pAND = pImage->pXOR + (pImage->Height*BytesPerLine((PBITMAPINFOHEADER)(pImage->pbi)));
00320     return TRUE;
00321 }
00322 /* End AdjustIconImagePointers() *******************************************/
00323
00324
00325
00326
00327 /****************************************************************************
00328 *
00329 *     FUNCTION: ReadICOHeader
00330 *
00331 *     PURPOSE:  Reads the header from an ICO file
00332 *
00333 *     PARAMS:   HANDLE hFile - handle to the file
00334 *
00335 *     RETURNS:  UINT - Number of images in file, -1 for failure
00336 *
00337 * History:
00338 *                July '95 - Created
00339 *
00340 \****************************************************************************/
00341 UINT ReadICOHeader (
00342     HANDLE hFile )
00343 {
00344     WORD    Input;
00345     DWORD dwBytesRead;
00346
00347     // Read the 'reserved' WORD
00348     if( ! ReadFile( hFile, &Input, sizeof( WORD ), &dwBytesRead, NULL ) )
00349         return (UINT)-1;
00350     // Did we get a WORD?
00351     if( dwBytesRead != sizeof( WORD ) )
00352         return (UINT)-1;
00353     // Was it 'reserved' ?   (ie 0)
00354     if( Input != 0 )
00355         return (UINT)-1;
00356     // Read the type WORD
00357     if( ! ReadFile( hFile, &Input, sizeof( WORD ), &dwBytesRead, NULL ) )
00358         return (UINT)-1;
00359     // Did we get a WORD?
00360     if( dwBytesRead != sizeof( WORD ) )
00361         return (UINT)-1;
00362     // Was it type 1?
00363     if( Input != 1 )
00364         return (UINT)-1;
00365     // Get the count of images
00366     if( ! ReadFile( hFile, &Input, sizeof( WORD ), &dwBytesRead, NULL ) )
00367         return (UINT)-1;
00368     // Did we get a WORD?
00369     if( dwBytesRead != sizeof( WORD ) )
00370         return (UINT)-1;
00371     // Return the count
00372     return Input;
00373 }
00374 /* End ReadICOHeader() ****************************************************/
00375
00376
00377
00378
00379 /****************************************************************************
00380 *
00381 *     FUNCTION: MyEnumProcedure
00382 *
00383 *     PURPOSE:  Callback for enumerating resources in a DLL/EXE
00384 *
00385 *     PARAMS:   HANDLE  hModule  - Handle of the module
00386 *               PCTSTR pszType   - Resource Type
00387 *               PTSTR  pszName   - Resource Name
00388 *               LONG    lParam   - Handle of ListBox to add name to
00389 *
00390 *     RETURNS:  BOOL - TRUE to continue, FALSE to stop
00391 *
00392 * History:
00393 *                July '95 - Created
00394 *
00395 \****************************************************************************/
00396 BOOL CALLBACK MyEnumProcedure (
00397     HANDLE  hModule,
00398     PCTSTR  pszType,
00399     PTSTR  pszName,
00400     LPARAM  lParam )
00401 {
00402     TCHAR szBuffer[256] = {0};
00403     LONG    nIndex        = LB_ERR;
00404     PTSTR pID           = NULL;
00405
00406     // Name is from MAKEINTRESOURCE()
00407     if( HIWORD(pszName) == 0 )
00408     {
00409         wsprintf( szBuffer, TEXT("Icon [%d]"), (DWORD_PTR)pszName );
00410         pID = pszName;
00411     }
00412     else
00413     {
00414         // Name is string
00415         pID = _tcsdup( pszName );
00416         wsprintf( szBuffer, TEXT("Icon [%s]"), pID );
00417     }
00418     // Add it to the listbox
00419     nIndex = (LONG)SendDlgItemMessage( (HWND)lParam, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)(szBuffer) );
00420     // Set the item data to be the name of the resource so we can get it later
00421     SendDlgItemMessage( (HWND)lParam, IDC_LIST1, LB_SETITEMDATA, (WPARAM)nIndex, (LPARAM)pID );
00422     return TRUE;
00423 }
00424 /* End MyEnumProcedure() ***************************************************/
00425
00426
00427
00428 /****************************************************************************
00429 *
00430 *     FUNCTION: GetIconFromInstance
00431 *
00432 *     PURPOSE:  Callback for enumerating resources in a DLL/EXE
00433 *
00434 *     PARAMS:   HINSTANCE hInstance - Instance handle for this module
00435 *               PTSTR    nIndex    - Resource index
00436 *
00437 *     RETURNS:  HICON - Handle to the icon, NULL for failure
00438 *
00439 * History:
00440 *                July '95 - Created
00441 *
00442 \****************************************************************************/
00443 HICON GetIconFromInstance (
00444     HINSTANCE hInstance,
00445     PTSTR nIndex )
00446 {
00447     HICON hIcon   = NULL;
00448     HRSRC hRsrc   = NULL;
00449     HGLOBAL hGlobal = NULL;
00450     PVOID pRes    = NULL;
00451     int     nID;
00452
00453     // Find the group icon
00454     if( (hRsrc = FindResource( hInstance, nIndex, RT_GROUP_ICON )) == NULL )
00455         return NULL;
00456     if( (hGlobal = LoadResource( hInstance, hRsrc )) == NULL )
00457         return NULL;
00458     if( (pRes = LockResource(hGlobal)) == NULL )
00459         return NULL;
00460
00461     // Find this particular image
00462     nID = LookupIconIdFromDirectory( pRes, TRUE );
00463     if( (hRsrc = FindResource( hInstance, MAKEINTRESOURCE(nID), RT_ICON )) == NULL )
00464         return NULL;
00465     if( (hGlobal = LoadResource( hInstance, hRsrc )) == NULL )
00466         return NULL;
00467     if( (pRes = LockResource(hGlobal)) == NULL )
00468         return NULL;
00469     // Let the OS make us an icon
00470     hIcon = CreateIconFromResource( pRes, SizeofResource(hInstance,hRsrc), TRUE, 0x00030000 );
00471     return hIcon;
00472 }
00473 /* End GetIconFromInstance() ***********************************************/
00474
00475
00476
00477 /****************************************************************************
00478 *
00479 *     FUNCTION: ExtractDlgProc
00480 *
00481 *     PURPOSE:  Window Procedure for the Extract Dialog
00482 *
00483 *     PARAMS:   HWND hWnd     - This window handle
00484 *               UINT Msg      - Which Message?
00485 *               WPARAM wParam - message parameter
00486 *               LPARAM lParam - message parameter
00487 *
00488 *     RETURNS:  BOOL - FALSE for cancel, TRUE for ok
00489 *
00490 * History:
00491 *                July '95 - Created
00492 *
00493 \****************************************************************************/
00494 BOOL CALLBACK ExtractDlgProc (
00495     HWND hWnd,
00496     UINT Msg,
00497     WPARAM wParam,
00498     LPARAM lParam )
00499 {
00500     // Variable that holds info on this EXE/DLL
00501     static PEXEDLLICONINFO pEDII;
00502
00503     switch( Msg )
00504     {
00505         // During Paint, we will draw the currently selected icon
00506         case WM_PAINT:
00507             {
00508                 HDC         hDC      = NULL;
00509                 PAINTSTRUCT ps       = {0};
00510                 DWORD       nIndex;
00511                 PTSTR       pIconID  = NULL;
00512
00513                 hDC = BeginPaint( hWnd, &ps );
00514                 // Get the current selection
00515                 if( (nIndex = (DWORD)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETCURSEL, 0, 0 )) != CB_ERR )
00516                 {
00517                     // Get the data associated with the current selection - its the icon name
00518                     if( (pIconID = (PTSTR)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETITEMDATA, nIndex, 0 )) != (PTSTR)CB_ERR )
00519                     {
00520                         RECT        Rect       = {0};
00521                         RECT        ButtonRect = {0};
00522                         RECT        DlgRect    = {0};
00523                         HWND        hWndButton = NULL;
00524                         HICON     hIcon      = NULL;
00525                         ICONINFO    IconInfo   = {0};
00526                         BITMAP      bm         = {0};
00527                         POINT     UpperLeft  = {0};
00528                         POINT       LowerRight = {0};
00529
00530                         // Make an Icon
00531                         hIcon = GetIconFromInstance( pEDII->hInstance, pIconID );
00532                         // Locate the icon
00533                         GetIconInfo( hIcon, &IconInfo );
00534                         GetObject( IconInfo.hbmColor, sizeof(BITMAP), &bm );
00535                         hWndButton = GetDlgItem( hWnd, IDCANCEL );
00536                         GetWindowRect( hWndButton, &ButtonRect );
00537                         GetWindowRect( hWnd, &DlgRect );
00538                         UpperLeft.x = ButtonRect.left;
00539                         UpperLeft.y = ButtonRect.bottom;
00540                         LowerRight.x = ButtonRect.right;
00541                         LowerRight.y = DlgRect.bottom;
00542                         ScreenToClient( hWnd, &UpperLeft );
00543                         ScreenToClient( hWnd, &LowerRight );
00544                         SetRect( &Rect, UpperLeft.x, UpperLeft.y, LowerRight.x, LowerRight.y );
00545                         // Draw it
00546                         DrawIcon( hDC, Rect.left + ((Rect.right - Rect.left - bm.bmWidth)/2),
00547                                 Rect.top + ((Rect.bottom - Rect.top - bm.bmHeight)/2), hIcon );
00548                         // Kill it
00549                         DestroyIcon( hIcon );
00550                     }
00551                 }
00552                 EndPaint( hWnd, &ps );
00553             }
00554             break; // End WM_PAINT
00555
00556         // Dialog is being initialized
00557         case WM_INITDIALOG:
00558             {
00559                 UINT    nCount;
00560                 TCHAR szBuffer[MAX_PATH]    = {0};
00561                 TCHAR   szFileTitle[MAX_PATH] = {0};
00562
00563                 // Are we being sent data about an EXE/DLL?
00564                 if( (pEDII = (PEXEDLLICONINFO)lParam) != NULL )
00565                 {
00566                     // Set the title of the dialog to reflect the EXE/DLL filename
00567                     GetFileTitle( pEDII->szFileName, szFileTitle, MAX_PATH );
00568                     wsprintf( szBuffer, TEXT("Extract Icon [%s]"), szFileTitle );
00569                     SetWindowText( hWnd, szBuffer );
00570                     // Fill in the listbox with the icons available
00571                     if( ! EnumResourceNames( pEDII->hInstance, RT_GROUP_ICON, MyEnumProcedure, (LPARAM)hWnd ) )
00572                     {
00573                         MessageBox( hWnd, TEXT("Error Enumerating Icons"), TEXT("Error"), MB_OK );
00574                         PostMessage( hWnd, WM_CLOSE, 0, 0 );
00575                     }
00576                     SendDlgItemMessage( hWnd, IDC_LIST1, LB_SETCURSEL, 0, 0 );
00577                     // If we have <= 1, post an OK message
00578                     if( (nCount = (UINT)SendDlgItemMessage(hWnd, IDC_LIST1, LB_GETCOUNT, 0, 0)) == 1 )
00579                     {
00580                         PostMessage( hWnd, WM_COMMAND, IDOK, 0 );
00581                     }
00582                     // If there were no icons, let the user know
00583                     if( nCount == 0 )
00584                     {
00585                         MessageBox( hWnd, TEXT("No Icons in this File"), TEXT("Error"), MB_OK );
00586                         PostMessage( hWnd, WM_CLOSE, 0, 0 );
00587                     }
00588                 }
00589                 return FALSE;
00590             }
00591             break; // End WM_INITDIALOG
00592
00593         // Shut 'er down
00594         case WM_CLOSE:
00595             PostMessage( hWnd, WM_COMMAND, IDCANCEL, 0l );
00596             break; // End WM_CLOSE
00597
00598         // Children are sending messages
00599         case WM_COMMAND:
00600             switch( LOWORD(wParam) )
00601             {
00602                 // Its the listbox, just redraw the icon
00603                 case IDC_LIST1:
00604                     switch( HIWORD(wParam) )
00605                     {
00606                         case CBN_SELCHANGE: /* fall-through */
00607                         case CBN_SELENDOK:
00608                             InvalidateRect( hWnd, NULL, TRUE );
00609                         break;
00610                     }
00611                     break; // End IDC_LIST1
00612
00613                 // User has chosen an icon, shut it down
00614                 case IDOK:
00615                     {
00616                         LONG nIndex;
00617
00618                         pEDII->pID = NULL;
00619                         if( (nIndex = (LONG)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETCURSEL, 0, 0 )) != LB_ERR )
00620                             pEDII->pID = (PTSTR)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETITEMDATA, nIndex, 0 );
00621                         EndDialog( hWnd, TRUE );
00622                     }
00623                     break; // End IDOK
00624
00625                 // BAIL!
00626                 case IDCANCEL:
00627                     EndDialog( hWnd, FALSE );
00628                     break; // End IDCANCEL
00629             }
00630             break;
00631
00632         default:
00633             return FALSE;
00634             break;
00635     }
00636     return TRUE;
00637 }
00638 /* End ExtractDlgProc() ****************************************************/
00639
00640
00641
00642
00643 /****************************************************************************
00644 *
00645 *     FUNCTION: ChooseIconFromEXEFile
00646 *
00647 *     PURPOSE:  Ask the user which icon he/she wants from the DLL/EXE
00648 *
00649 *     PARAMS:   PEXEDLLICONINFO pEDII - info on this DLL/EXE
00650 *
00651 *     RETURNS:  PTSTR - pointer to the resource name
00652 *
00653 * History:
00654 *                July '95 - Created
00655 *
00656 \****************************************************************************/
00657 PTSTR ChooseIconFromEXEFile(
00658     PEXEDLLICONINFO pEDII )
00659 {
00660     // Just launch the dialog box and let it handle it
00661     if( DialogBoxParam( hInst, MAKEINTRESOURCE(IDD_EXTRACTDLG),
00662                         hWndMain, (DLGPROC)ExtractDlgProc, (LPARAM)(pEDII) ) )
00663     {
00664         // User chose 'Ok'
00665         return pEDII->pID;
00666     }
00667     // User chose 'Cancel', or an error occurred, fail the call
00668     return NULL;
00669 }
00670 /* End ChooseIconFromEXEFile() **********************************************/
00671
00672
00673
00674
00675 /****************************************************************************
00676 *
00677 *     FUNCTION: ReadIconFromEXEFile
00678 *
00679 *     PURPOSE:  Load an Icon Resource from a DLL/EXE file
00680 *
00681 *     PARAMS:   PCTSTR szFileName - name of DLL/EXE file
00682 *
00683 *     RETURNS:  PICONRESOURCE - pointer to icon resource
00684 *
00685 * History:
00686 *                July '95 - Created
00687 *
00688 \****************************************************************************/
00689 ICONRESOURCE* ReadIconFromEXEFile(
00690     PCTSTR szFileName )
00691 {
00692     ICONRESOURCE*  pIR      = NULL;
00693     HINSTANCE      hLibrary = NULL;
00694     PTSTR          pID      = NULL;
00695     EXEDLLICONINFO EDII     = {0};
00696
00697     // Load the DLL/EXE - NOTE: must be a 32bit EXE/DLL for this to work
00698     if( (hLibrary = LoadLibraryEx( szFileName, NULL, LOAD_LIBRARY_AS_DATAFILE )) == NULL )
00699     {
00700         // Failed to load - abort
00701         MessageBox( hWndMain, TEXT("Error Loading File - Choose a 32bit DLL or EXE"), szFileName, MB_OK );
00702         return NULL;
00703     }
00704     // Store the info
00705     EDII.szFileName = szFileName;
00706     EDII.hInstance = hLibrary;
00707     // Ask the user, "Which Icon?"
00708     if( (pID = ChooseIconFromEXEFile( &EDII )) != NULL )
00709     {
00710         HRSRC       hRsrc   = NULL;
00711         HGLOBAL     hGlobal = NULL;
00712         MEMICONDIR* pIcon   = NULL;
00713         UINT        i;
00714
00715         // Find the group icon resource
00716         if( (hRsrc = FindResource( hLibrary, pID, RT_GROUP_ICON )) == NULL )
00717         {
00718             FreeLibrary( hLibrary );
00719             return NULL;
00720         }
00721         if( (hGlobal = LoadResource( hLibrary, hRsrc )) == NULL )
00722         {
00723             FreeLibrary( hLibrary );
00724             return NULL;
00725         }
00726         if( (pIcon = LockResource(hGlobal)) == NULL )
00727         {
00728             FreeLibrary( hLibrary );
00729             return NULL;
00730         }
00731         // Allocate enough memory for the images
00732         if( (pIR = malloc( sizeof(ICONRESOURCE) + ((pIcon->idCount-1) * sizeof(ICONIMAGE)) )) == NULL )
00733         {
00734             MessageBox( hWndMain, TEXT("Error Allocating Memory"), szFileName, MB_OK );
00735             FreeLibrary( hLibrary );
00736             return NULL;
00737         }
00738         // Fill in local struct members
00739         pIR->nNumImages = pIcon->idCount;
00740         lstrcpyn( pIR->szOriginalDLLFileName, szFileName, MAX_PATH - 1 );
00741         lstrcpyn( pIR->szOriginalICOFileName, TEXT(""), MAX_PATH - 1 );
00742         // Loop through the images
00743         for( i = 0; i < pIR->nNumImages; i++ )
00744         {
00745             // Get the individual image
00746             if( (hRsrc = FindResource( hLibrary, MAKEINTRESOURCE(pIcon->idEntries[i].nID), RT_ICON )) == NULL )
00747             {
00748                 free( pIR );
00749                 FreeLibrary( hLibrary );
00750                 return NULL;
00751             }
00752             if( (hGlobal = LoadResource( hLibrary, hRsrc )) == NULL )
00753             {
00754                 free( pIR );
00755                 FreeLibrary( hLibrary );
00756                 return NULL;
00757             }
00758             // Store a copy of the resource locally
00759             pIR->IconImages[i].dwNumBytes = SizeofResource( hLibrary, hRsrc );
00760             pIR->IconImages[i].pBits = malloc( pIR->IconImages[i].dwNumBytes );
00761             memcpy( pIR->IconImages[i].pBits, LockResource( hGlobal ), pIR->IconImages[i].dwNumBytes );
00762             // Adjust internal pointers
00763             if( ! AdjustIconImagePointers( &(pIR->IconImages[i]) ) )
00764             {
00765                 MessageBox( hWndMain, TEXT("Error Converting to Internal Format"), szFileName, MB_OK );
00766                 free( pIR );
00767                 FreeLibrary( hLibrary );
00768                 return NULL;
00769             }
00770         }
00771     }
00772     FreeLibrary( hLibrary );
00773     return pIR;
00774 }
00775 /* End ReadIconFromEXEFile() ************************************************/
00776
00777
00778
00779 /****************************************************************************
00780 *
00781 *     FUNCTION: WriteICOHeader
00782 *
00783 *     PURPOSE:  Writes the header to an ICO file
00784 *
00785 *     PARAMS:   HANDLE hFile       - handle to the file
00786 *               UINT   nNumEntries - Number of images in file
00787 *
00788 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
00789 *
00790 * History:
00791 *                July '95 - Created
00792 *
00793 \****************************************************************************/
00794 BOOL WriteICOHeader(
00795     HANDLE hFile,
00796     UINT nNumEntries )
00797 {
00798     WORD    Output;
00799     DWORD dwBytesWritten;
00800     BOOL    bRet = TRUE;
00801
00802     // Write 'reserved' WORD
00803     Output = 0;
00804     if( ! WriteFile( hFile, &Output, sizeof( WORD ), &dwBytesWritten, NULL ) )
00805     {
00806         bRet = FALSE;
00807         goto exit_func;
00808     }
00809
00810     // Did we write a WORD?
00811     if( dwBytesWritten != sizeof( WORD ) )
00812     {
00813         bRet = FALSE;
00814         goto exit_func;
00815     }
00816
00817     // Write 'type' WORD (1)
00818     Output = 1;
00819     if( ! WriteFile( hFile, &Output, sizeof( WORD ), &dwBytesWritten, NULL ) )
00820     {
00821         bRet = FALSE;
00822         goto exit_func;
00823     }
00824
00825     // Did we write a WORD?
00826     if( dwBytesWritten != sizeof( WORD ) )
00827     {
00828         bRet = FALSE;
00829         goto exit_func;
00830     }
00831
00832     // Write Number of Entries
00833     Output = (WORD)nNumEntries;
00834     if( ! WriteFile( hFile, &Output, sizeof( WORD ), &dwBytesWritten, NULL ) )
00835     {
00836         bRet = FALSE;
00837         goto exit_func;
00838     }
00839
00840     // Did we write a WORD?
00841     if( dwBytesWritten != sizeof( WORD ) )
00842     {
00843         bRet = FALSE;
00844         goto exit_func;
00845     }
00846
00847 exit_func:
00848     return bRet;
00849 }
00850 /* End WriteICOHeader() ****************************************************/
00851
00852
00853
00854 /****************************************************************************
00855 *
00856 *     FUNCTION: CalculateImageOffset
00857 *
00858 *     PURPOSE:  Calculates the file offset for an icon image
00859 *
00860 *     PARAMS:   PICONRESOURCE pIR   - pointer to icon resource
00861 *               UINT           nIndex - which image?
00862 *
00863 *     RETURNS:  DWORD - the file offset for that image
00864 *
00865 * History:
00866 *                July '95 - Created
00867 *
00868 \****************************************************************************/
00869 DWORD CalculateImageOffset(
00870     ICONRESOURCE* pIR,
00871     UINT nIndex )
00872 {
00873     DWORD dwSize;
00874     UINT  i;
00875
00876     // Calculate the ICO header size
00877     dwSize = 3 * sizeof(WORD);
00878     // Add the ICONDIRENTRY's
00879     dwSize += pIR->nNumImages * sizeof(ICONDIRENTRY);
00880     // Add the sizes of the previous images
00881     for(i=0;i<nIndex;i++)
00882     {
00883         dwSize += pIR->IconImages[i].dwNumBytes;
00884     }
00885     // we're there - return the number
00886     return dwSize;
00887 }
00888 /* End CalculateImageOffset() ***********************************************/
00889
00890
00891
00892
00893 /****************************************************************************
00894 *
00895 *     FUNCTION: WriteIconToICOFile
00896 *
00897 *     PURPOSE:  Writes the icon resource data to an ICO file
00898 *
00899 *     PARAMS:   PICONRESOURCE pIR       - pointer to icon resource
00900 *               PCTSTR        szFileName - name for the ICO file
00901 *
00902 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
00903 *
00904 * History:
00905 *                July '95 - Created
00906 *
00907 \****************************************************************************/
00908 BOOL WriteIconToICOFile(
00909     ICONRESOURCE* pIR,
00910     PCTSTR szFileName )
00911 {
00912     HANDLE hFile = NULL;
00913     UINT   i;
00914     DWORD  dwBytesWritten;
00915     BOOL   bSuccess = TRUE;
00916
00917     // open the file
00918     if( (hFile = CreateFile( szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL )) == INVALID_HANDLE_VALUE )
00919     {
00920         MessageBox( hWndMain, TEXT("Error Opening File for Writing"), szFileName, MB_OK );
00921         bSuccess = FALSE;
00922         goto exit_func;
00923     }
00924
00925     // Write the header
00926     if( ! WriteICOHeader( hFile, pIR->nNumImages ) )
00927     {
00928         MessageBox( hWndMain, TEXT("Error Writing ICO File"), szFileName, MB_OK );
00929         CloseHandle( hFile );
00930         bSuccess = FALSE;
00931         goto exit_func;
00932     }
00933
00934     // Write the ICONDIRENTRY's
00935     for( i=0; i<pIR->nNumImages; i++ )
00936     {
00937         ICONDIRENTRY ide = {0};
00938
00939         // Convert internal format to ICONDIRENTRY
00940         ide.bWidth = (BYTE)pIR->IconImages[i].Width;
00941         ide.bHeight = (BYTE)pIR->IconImages[i].Height;
00942         ide.wPlanes = pIR->IconImages[i].pbi->bmiHeader.biPlanes;
00943         ide.wBitCount = pIR->IconImages[i].pbi->bmiHeader.biBitCount;
00944         if( (ide.wPlanes * ide.wBitCount) >= 8 )
00945         {
00946             ide.bColorCount = 0;
00947         }
00948         else
00949         {
00950             ide.bColorCount = (BYTE)(1 << (ide.wPlanes * ide.wBitCount));
00951         }
00952         ide.dwBytesInRes = pIR->IconImages[i].dwNumBytes;
00953         ide.dwImageOffset = CalculateImageOffset( pIR, i );
00954         // Write the ICONDIRENTRY out to disk
00955         if( ! WriteFile( hFile, &ide, sizeof( ICONDIRENTRY ), &dwBytesWritten, NULL ) )
00956         {
00957             bSuccess = FALSE;
00958             goto exit_func;
00959         }
00960         // Did we write a full ICONDIRENTRY ?
00961         if( dwBytesWritten != sizeof( ICONDIRENTRY ) )
00962         {
00963             bSuccess = FALSE;
00964             goto exit_func;
00965         }
00966     }
00967     // Write the image bits for each image
00968     for( i=0; i<pIR->nNumImages; i++ )
00969     {
00970         DWORD dwTemp = pIR->IconImages[i].pbi->bmiHeader.biSizeImage;
00971
00972         // Set the sizeimage member to zero
00973         pIR->IconImages[i].pbi->bmiHeader.biSizeImage = 0;
00974         // Write the image bits to file
00975         if( ! WriteFile( hFile, pIR->IconImages[i].pBits, pIR->IconImages[i].dwNumBytes, &dwBytesWritten, NULL ) )
00976         {
00977             bSuccess = FALSE;
00978             goto exit_func;
00979         }
00980
00981         if( dwBytesWritten != pIR->IconImages[i].dwNumBytes )
00982         {
00983             bSuccess = FALSE;
00984             goto exit_func;
00985         }
00986         // set it back
00987         pIR->IconImages[i].pbi->bmiHeader.biSizeImage = dwTemp;
00988     }
00989     CloseHandle( hFile );
00990
00991 exit_func:
00992     return bSuccess;
00993 }
00994 /* End WriteIconToICOFile() **************************************************/
00995
00996
00997 /****************************************************************************
00998 *
00999 *     FUNCTION: IconImageToClipBoard
01000 *
01001 *     PURPOSE:  Copies an icon image to the clipboard in CF_DIB format
01002 *
01003 *     PARAMS:   ICONIMAGE* pii - pointer to icon image data
01004 *
01005 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01006 *
01007 * History:
01008 *                July '95 - Created
01009 *
01010 \****************************************************************************/
01011 BOOL IconImageToClipBoard(
01012     ICONIMAGE* pii )
01013 {
01014     HANDLE hGlobal = NULL;
01015     PSTR   pBits   = NULL;
01016
01017     // Open the clipboard
01018     if( OpenClipboard( hWndMain ) )
01019     {
01020         // empty it
01021         if( EmptyClipboard() )
01022         {
01023             // Make a buffer to send to clipboard
01024             hGlobal = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE, pii->dwNumBytes );
01025             pBits = GlobalLock( hGlobal );
01026             // Copy the bits to the buffer
01027             memcpy( pBits, pii->pBits, pii->dwNumBytes );
01028             // Adjust for funky height*2 thing
01029             ((PBITMAPINFOHEADER)pBits)->biHeight /= 2;
01030             GlobalUnlock( hGlobal );
01031             // Send it to the clipboard
01032             SetClipboardData( CF_DIB, hGlobal );
01033             CloseClipboard();
01034             return TRUE;
01035         }
01036     }
01037     return FALSE;
01038 }
01039 /* End IconImageToClipBoard() ***********************************************/
01040
01041
01042
01043 /****************************************************************************
01044 *
01045 *     FUNCTION: IconImageFromClipBoard
01046 *
01047 *     PURPOSE:  Creates an icon image from the CF_DIB clipboard entry
01048 *
01049 *     PARAMS:   ICONIMAGE*  pii           - pointer to icon image data
01050 *               BOOL        bStretchToFit - TRUE to stretch, FALSE to take
01051 *                                           the upper left corner of the DIB
01052 *
01053 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01054 *
01055 * History:
01056 *                July '95 - Created
01057 *
01058 \****************************************************************************/
01059 BOOL IconImageFromClipBoard(
01060     ICONIMAGE* pii,
01061     BOOL bStretchToFit )
01062 {
01063     PBITMAPINFO pbi         = NULL;
01064     HANDLE      hClipGlobal = NULL;
01065     BOOL        bRet        = FALSE;
01066
01067     // Open the clipboard
01068     if( OpenClipboard( hWndMain ) )
01069     {
01070         // Get the CF_DIB data from it
01071         if( (hClipGlobal = GetClipboardData( CF_DIB )) != NULL )
01072         {
01073             // Lock it down
01074             if( (pbi=GlobalLock(hClipGlobal)) != NULL )
01075             {
01076                 // Convert it to an icon image
01077                 bRet = DIBToIconImage( pii, (PBYTE)pbi, bStretchToFit );
01078                 GlobalUnlock( hClipGlobal );
01079             }
01080         }
01081         CloseClipboard();
01082     }
01083     return bRet;
01084 }
01085 /* End IconImageFromClipBoard() ********************************************/
01086
01087
01088
01089 /****************************************************************************
01090 *
01091 *     FUNCTION: DIBToIconImage
01092 *
01093 *     PURPOSE:  Converts a CF_DIB memory block to an icon image
01094 *
01095 *     PARAMS:   ICONIMAGE* pii           - pointer to icon image data
01096 *               PBYTE      pDIB          - a pointer to the CF_DIB block
01097 *               BOOL       bStretchToFit - TRUE to stretch, FALSE to take
01098 *                                          the upper left corner of the DIB
01099 *
01100 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01101 *
01102 * History:
01103 *                July '95 - Created
01104 *
01105 \****************************************************************************/
01106 BOOL DIBToIconImage(
01107     ICONIMAGE* pii,
01108     PBYTE pDIB,
01109     BOOL bStretch )
01110 {
01111     PBYTE pNewDIB = NULL;
01112
01113     // Sanity check
01114     if( pDIB == NULL )
01115     {
01116         return FALSE;
01117     }
01118
01119     // Let the DIB engine convert color depths if need be
01120     pNewDIB = ConvertDIBFormat( (PBITMAPINFO)pDIB, pii->Width, pii->Height, pii->Colors, bStretch );
01121
01122     // Now we have a cool new DIB of the proper size/color depth
01123     // Lets poke it into our data structures and be done with it
01124
01125     // How big is it?
01126     pii->dwNumBytes = sizeof( BITMAPINFOHEADER )                        // Header
01127                     + PaletteSize( (PSTR)pNewDIB )                      // Palette
01128                     + pii->Height * BytesPerLine( (PBITMAPINFOHEADER)pNewDIB )  // XOR mask
01129                     + pii->Height * WIDTHBYTES( pii->Width );           // AND mask
01130
01131     // If there was already an image here, free it
01132     if( pii->pBits != NULL )
01133     {
01134         free( pii->pBits );
01135     }
01136
01137     // Allocate enough room for the new image
01138     if( (pii->pBits = malloc( pii->dwNumBytes )) == NULL )
01139     {
01140         free( pii );
01141         return FALSE;
01142     }
01143     // Copy the bits
01144     memcpy( pii->pBits, pNewDIB, sizeof( BITMAPINFOHEADER ) + PaletteSize( (PSTR)pNewDIB ) );
01145     // Adjust internal pointers/variables for new image
01146     pii->pbi = (PBITMAPINFO)(pii->pBits);
01147     pii->pbi->bmiHeader.biHeight *= 2;
01148     pii->pXOR = (PBYTE)FindDIBBits( (PSTR)(pii->pBits) );
01149     memcpy( pii->pXOR, FindDIBBits((PSTR)pNewDIB), pii->Height * BytesPerLine( (PBITMAPINFOHEADER)pNewDIB ) );
01150     pii->pAND = pii->pXOR + pii->Height * BytesPerLine( (PBITMAPINFOHEADER)pNewDIB );
01151     memset( pii->pAND, 0, pii->Height * WIDTHBYTES( pii->Width ) );
01152     // Free the source
01153     free( pNewDIB );
01154     return TRUE;
01155 }
01156 /* End DIBToIconImage() ***************************************************/
01157
01158
01159
01160
01161 /****************************************************************************
01162 *
01163 *     FUNCTION: CreateBlankNewFormatIcon
01164 *
01165 *     PURPOSE:  Creates a blank icon image for a new format
01166 *
01167 *     PARAMS:   ICONIMAGE* pii  - pointer to icon image data
01168 *
01169 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01170 *
01171 * History:
01172 *                July '95 - Created
01173 *
01174 \****************************************************************************/
01175 BOOL CreateBlankNewFormatIcon(
01176     ICONIMAGE* pii )
01177 {
01178     DWORD            dwFinalSize = 0;
01179     BITMAPINFOHEADER bmih        = {0};
01180
01181     // Fill in the bitmap header
01182     ZeroMemory( &bmih, sizeof( BITMAPINFOHEADER ) );
01183     bmih.biSize = sizeof( BITMAPINFOHEADER );
01184     bmih.biBitCount = (WORD)pii->Colors;
01185     bmih.biClrUsed = 0;
01186
01187     // How big will the final thing be?
01188     // Well, it'll have a header
01189     dwFinalSize = sizeof( BITMAPINFOHEADER );
01190     // and a color table (even if it's zero length)
01191     dwFinalSize += PaletteSize( (PSTR)&bmih );
01192     // and XOR bits
01193     dwFinalSize += pii->Height * WIDTHBYTES( pii->Width * pii->Colors );
01194     // and AND bits. That's about it :)
01195     dwFinalSize += pii->Height * WIDTHBYTES( pii->Width );
01196
01197     // Allocate some memory for it
01198     pii->pBits = malloc( dwFinalSize );
01199     ZeroMemory( pii->pBits, dwFinalSize );
01200     pii->dwNumBytes = dwFinalSize;
01201     pii->pbi = (PBITMAPINFO)(pii->pBits);
01202     pii->pXOR = (PBYTE)(pii->pbi) + sizeof(BITMAPINFOHEADER) + PaletteSize( (PSTR)&bmih );
01203     pii->pAND = pii->pXOR + (pii->Height * WIDTHBYTES( pii->Width * pii->Colors ));
01204
01205     // The bitmap header is zeros, fill it out
01206     pii->pbi->bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
01207     pii->pbi->bmiHeader.biWidth = pii->Width;
01208     // Don't forget the funky height*2 icon resource thing
01209     pii->pbi->bmiHeader.biHeight = pii->Height * 2;
01210     pii->pbi->bmiHeader.biPlanes = 1;
01211     pii->pbi->bmiHeader.biBitCount = (WORD)pii->Colors;
01212     pii->pbi->bmiHeader.biCompression = BI_RGB;
01213
01214     return TRUE;
01215 }
01216 /* End CreateBlankNewFormatIcon() ******************************************/
01217
01218
01219
01220 /****************************************************************************
01221 *
01222 *     FUNCTION: GetXORImageRect
01223 *
01224 *     PURPOSE:  Given a bounding Rect, calculates the XOR mask display Rect
01225 *
01226 *     PARAMS:   RECT        Rect  - Bounding rect for drawing area
01227 *               ICONIMAGE*  pIcon - pointer to icon image data
01228 *
01229 *     RETURNS:  RECT - the rect where the XOR image will be drawn
01230 *
01231 * History:
01232 *                July '95 - Created
01233 *
01234 \****************************************************************************/
01235 RECT GetXORImageRect(
01236     RECT Rect,
01237     ICONIMAGE* pIcon )
01238 {
01239     RECT NewRect = {0};
01240
01241     // Just center the thing in the bounding display rect
01242     NewRect.left = Rect.left + ((RectWidth(Rect)-pIcon->pbi->bmiHeader.biWidth)/2);
01243     NewRect.top = Rect.top + ((RectHeight(Rect)-(pIcon->pbi->bmiHeader.biHeight/2))/2);
01244     NewRect.bottom = NewRect.top + (pIcon->pbi->bmiHeader.biHeight/2);
01245     NewRect.right = NewRect.left + pIcon->pbi->bmiHeader.biWidth;
01246     return NewRect;
01247 }
01248 /* End GetXORImageRect() ***************************************************/
01249
01250
01251
01252
01253 /****************************************************************************
01254 *
01255 *     FUNCTION: DrawXORMask
01256 *
01257 *     PURPOSE:  Using DIB functions, draw XOR mask on hDC in Rect
01258 *
01259 *     PARAMS:   HDC         hDC    - The DC on which to draw
01260 *               RECT        Rect   - Bounding rect for drawing area
01261 *               ICONIMAGE*  pIcon  - pointer to icon image data
01262 *
01263 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01264 *
01265 *     COMMENTS: Does not use any palette information since the
01266 *               OS won't when it draws the icon anyway.
01267 *
01268 * History:
01269 *                July '95 - Created
01270 *
01271 \****************************************************************************/
01272 BOOL DrawXORMask(
01273     HDC hDC,
01274     RECT Rect,
01275     ICONIMAGE* pIcon )
01276 {
01277     int x, y;
01278
01279     // Sanity checks
01280     if( pIcon == NULL )
01281     {
01282         return FALSE;
01283     }
01284
01285     if( pIcon->pBits == NULL )
01286     {
01287         return FALSE;
01288     }
01289
01290     // Account for height*2 thing
01291     pIcon->pbi->bmiHeader.biHeight /= 2;
01292
01293     // Locate it
01294     x = Rect.left + ((RectWidth(Rect)-pIcon->pbi->bmiHeader.biWidth)/2);
01295     y = Rect.top + ((RectHeight(Rect)-pIcon->pbi->bmiHeader.biHeight)/2);
01296
01297     // Blast it to the screen
01298     SetDIBitsToDevice( hDC, x, y, pIcon->pbi->bmiHeader.biWidth, pIcon->pbi->bmiHeader.biHeight, 0, 0, 0, pIcon->pbi->bmiHeader.biHeight, pIcon->pXOR, pIcon->pbi, DIB_RGB_COLORS );
01299
01300     // UnAccount for height*2 thing
01301     pIcon->pbi->bmiHeader.biHeight *= 2;
01302
01303     return TRUE;
01304 }
01305 /* End DrawXORMask() *******************************************************/
01306
01307
01308
01309
01310 /****************************************************************************
01311 *
01312 *     FUNCTION: DrawANDMask
01313 *
01314 *     PURPOSE:  Using DIB functions, draw AND mask on hDC in Rect
01315 *
01316 *     PARAMS:   HDC         hDC    - The DC on which to draw
01317 *               RECT        Rect   - Bounding rect for drawing area
01318 *               ICONIMAGE*  pIcon  - pointer to icon image data
01319 *
01320 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01321 *
01322 * History:
01323 *                July '95 - Created
01324 *
01325 \****************************************************************************/
01326 BOOL DrawANDMask(
01327     HDC hDC,
01328     RECT Rect,
01329     ICONIMAGE* pIcon )
01330 {
01331     PBITMAPINFO pbi = NULL;
01332     int         x, y;
01333     BOOL        bSuccess = TRUE;
01334
01335     // Sanity checks
01336     if( pIcon == NULL )
01337     {
01338         bSuccess = FALSE;
01339         goto exit_func;
01340     }
01341
01342     if( pIcon->pBits == NULL )
01343     {
01344         bSuccess = FALSE;
01345         goto exit_func;
01346     }
01347
01348     // Need a bitmap header for the mono mask
01349     pbi = malloc( sizeof(BITMAPINFO) + (2 * sizeof( RGBQUAD )) );
01350     pbi->bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
01351     pbi->bmiHeader.biWidth = pIcon->pbi->bmiHeader.biWidth;
01352     pbi->bmiHeader.biHeight = pIcon->pbi->bmiHeader.biHeight/2;
01353     pbi->bmiHeader.biPlanes = 1;
01354     pbi->bmiHeader.biBitCount = 1;
01355     pbi->bmiHeader.biCompression = BI_RGB;
01356     pbi->bmiHeader.biSizeImage = 0;
01357     pbi->bmiHeader.biXPelsPerMeter = 0;
01358     pbi->bmiHeader.biYPelsPerMeter = 0;
01359     pbi->bmiHeader.biClrUsed = 0;
01360     pbi->bmiHeader.biClrImportant = 0;
01361     pbi->bmiColors[0].rgbRed = 0;
01362     pbi->bmiColors[0].rgbGreen = 0;
01363     pbi->bmiColors[0].rgbBlue = 0;
01364     pbi->bmiColors[0].rgbReserved = 0;
01365     pbi->bmiColors[1].rgbRed = 255;
01366     pbi->bmiColors[1].rgbGreen = 255;
01367     pbi->bmiColors[1].rgbBlue = 255;
01368     pbi->bmiColors[1].rgbReserved = 0;
01369
01370     // Locate it
01371     x = Rect.left + ((RectWidth(Rect)-pbi->bmiHeader.biWidth)/2);
01372     y = Rect.top + ((RectHeight(Rect)-pbi->bmiHeader.biHeight)/2);
01373
01374     // Blast it to the screen
01375     SetDIBitsToDevice( hDC, x, y, pbi->bmiHeader.biWidth, pbi->bmiHeader.biHeight, 0, 0, 0, pbi->bmiHeader.biHeight, pIcon->pAND, pbi, DIB_RGB_COLORS );
01376
01377     // clean up
01378     free( pbi );
01379
01380 exit_func:
01381     return bSuccess;
01382 }
01383 /* End DrawANDMask() *******************************************************/
01384
01385
01386
01387
01388 /****************************************************************************
01389 *
01390 *     FUNCTION: MakeNewANDMaskBasedOnPoint
01391 *
01392 *     PURPOSE:  Creates a new AND mask for the icon image
01393 *
01394 *     PARAMS:   ICONIMAGE* pIcon  - pointer to icon image data
01395 *               POINT      pt     - coords of transparent pixel
01396 *
01397 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01398 *
01399 *     COMMENTS: Creates the AND mask using the color of the pixel at pt
01400 *               as a transparent color. The XOR mask is changed as well.
01401 *               This is because the OS expects the XOR mask to have the
01402 *               AND mask already applied (ie black in transparent areas)
01403 *
01404 * History:
01405 *                July '95 - Created
01406 *
01407 \****************************************************************************/
01408 BOOL MakeNewANDMaskBasedOnPoint(
01409     ICONIMAGE* pIcon,
01410     POINT pt )
01411 {
01412     HBITMAP     hXORBitmap          = NULL;
01413     HBITMAP     hOldXORBitmap       = NULL;
01414     HDC         hDC                 = NULL;
01415     HDC         hMemDC1             = NULL;
01416     PBYTE       pXORBits            = NULL;
01417     COLORREF    crTransparentColor  = {0};
01418     LONG        i,j;
01419
01420
01421     // Account for height*2 thing
01422     pIcon->pbi->bmiHeader.biHeight /= 2;
01423
01424     // Need a DC
01425     hDC = GetDC( NULL );
01426
01427     // Use DIBSection for source
01428     hXORBitmap = CreateDIBSection( hDC, pIcon->pbi, DIB_RGB_COLORS, &pXORBits, NULL, 0  );
01429     memcpy( pXORBits, pIcon->pXOR, (pIcon->pbi->bmiHeader.biHeight) * BytesPerLine((PBITMAPINFOHEADER)(pIcon->pbi)) );
01430     hMemDC1 = CreateCompatibleDC( hDC );
01431     hOldXORBitmap = SelectObject( hMemDC1, hXORBitmap );
01432
01433     // Set the color table if need be
01434     if( pIcon->pbi->bmiHeader.biBitCount <= 8 )
01435     {
01436         SetDIBColorTable( hMemDC1, 0, DIBNumColors((PSTR)(pIcon->pbi)), pIcon->pbi->bmiColors);
01437     }
01438
01439     // What's the transparent color?
01440     crTransparentColor = GetPixel( hMemDC1, pt.x, pt.y );
01441
01442     // Loop through the pixels
01443     for(i=0;i<pIcon->pbi->bmiHeader.biWidth;i++)
01444     {
01445         for(j=0;j<pIcon->pbi->bmiHeader.biHeight;j++)
01446         {
01447             // Is the source transparent at this point?
01448             if( GetPixel( hMemDC1, i, j ) == crTransparentColor )
01449             {
01450                 // Yes, so set the pixel in AND mask, and clear it in XOR mask
01451                 SetMonoDIBPixel( pIcon->pAND, pIcon->pbi->bmiHeader.biWidth,
01452                                  pIcon->pbi->bmiHeader.biHeight, i, j, TRUE );
01453                 if( pIcon->pbi->bmiHeader.biBitCount == 1 )
01454                 {
01455                     SetMonoDIBPixel( pXORBits, pIcon->pbi->bmiHeader.biWidth,
01456                                      pIcon->pbi->bmiHeader.biHeight, i, j, FALSE );
01457                 }
01458                 else
01459                 {
01460                     SetPixelV( hMemDC1, i, j, RGB(0,0,0) );
01461                 }
01462             }
01463             else
01464             {
01465                 // No, so clear pixel in AND mask
01466                 SetMonoDIBPixel( pIcon->pAND, pIcon->pbi->bmiHeader.biWidth, pIcon->pbi->bmiHeader.biHeight, i, j, FALSE );
01467             }
01468         }
01469     }
01470     // Flush the SetPixelV() calls
01471     GdiFlush();
01472
01473     SelectObject( hMemDC1, hOldXORBitmap );
01474
01475     // Copy the new XOR bits back to our storage
01476     memcpy( pIcon->pXOR, pXORBits, (pIcon->pbi->bmiHeader.biHeight) * BytesPerLine((PBITMAPINFOHEADER)(pIcon->pbi)) );
01477
01478     // Clean up
01479     DeleteObject( hXORBitmap );
01480     DeleteDC( hMemDC1 );
01481     ReleaseDC( NULL, hDC );
01482
01483
01484     // UnAccount for height*2 thing
01485     pIcon->pbi->bmiHeader.biHeight *= 2;
01486     return TRUE;
01487 }
01488 /* End MakeNewANDMaskBasedOnPoint() *****************************************/
01489
01490
01491 /****************************************************************************
01492 *
01493 *     FUNCTION: IconImageFromBMPFile
01494 *
01495 *     PURPOSE:  Creates an icon image from a BMP file
01496 *
01497 *     PARAMS:   PCTSTR     szFileName     - Filename for BMP file
01498 *               ICONIMAGE* pii            - pointer to icon image data
01499 *               BOOL       bStretchToFit  - TRUE to stretch, FALSE to take
01500 *                                           the upper left corner of the DIB
01501 *
01502 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01503 *
01504 * History:
01505 *                July '95 - Created
01506 *
01507 \****************************************************************************/
01508 BOOL IconImageFromBMPFile(
01509     PCTSTR szFileName,
01510     ICONIMAGE* pii,
01511     BOOL bStretchToFit )
01512 {
01513     PBYTE   pDIB = NULL;
01514     BOOL    bRet = FALSE;
01515
01516     if( (pDIB=ReadBMPFile(szFileName)) == NULL )
01517     {
01518         return FALSE;
01519     }
01520
01521     // Convert it to an icon image
01522     bRet = DIBToIconImage( pii, pDIB, bStretchToFit );
01523     free( pDIB );
01524     return bRet;
01525 }
01526 /* End IconImageFromBMPFile() ********************************************/
01527
01528
01529
01530
01531 /****************************************************************************
01532 *
01533 *     FUNCTION: IconImageToBMPFile
01534 *
01535 *     PURPOSE:  Creates BMP file from an icon image
01536 *
01537 *     PARAMS:   PCTSTR     szFileName   - Filename for BMP file
01538 *               ICONIMAGE* pii          - pointer to icon image data
01539 *
01540 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
01541 *
01542 * History:
01543 *                July '95 - Created
01544 *
01545 \****************************************************************************/
01546 BOOL IconImageToBMPFile(
01547     PCTSTR szFileName,
01548     ICONIMAGE* pii )
01549 {
01550     return WriteBMPFile( szFileName, (PBYTE)pii->pbi );
01551 }
01552
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBackgroundFolder Member List

This is the complete list of members for CBackgroundFolder, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
AddItem(int id) | CBackgroundFolder | [private]
AddItem(int id) | CBackgroundFolder | [private]
AddItem(int id) | CBackgroundFolder | [private]
bExpanded | CDelegationBase | [protected]
CBackgroundFolder() | CBackgroundFolder |
CBackgroundFolder() | CBackgroundFolder |
CBackgroundFolder() | CBackgroundFolder |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CBackgroundFolder | [inline, virtual]
GetBitmapIndex() | CBackgroundFolder | [inline, virtual]
GetBitmapIndex() | CBackgroundFolder | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CBackgroundFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CBackgroundFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CBackgroundFolder | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CBackgroundFolder | [inline, virtual]
getNodeType() | CBackgroundFolder | [inline, virtual]
getNodeType() | CBackgroundFolder | [inline, virtual]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_backgroundHwnd | CBackgroundFolder | [private]
m_bSelected | CBackgroundFolder | [private]
m_bViewUpdated | CBackgroundFolder | [private]
m_children | CBackgroundFolder | [private]
m_critSect | CBackgroundFolder | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
m_pConsoleNameSpace | CBackgroundFolder | [private]
m_running | CBackgroundFolder | [private]
m_scopeitem | CBackgroundFolder | [private]
m_thread | CBackgroundFolder | [private]
m_threadId | CBackgroundFolder | [private]
MAX_CHILDREN enum value | CBackgroundFolder | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CBackgroundFolder | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CBackgroundFolder | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CBackgroundFolder | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CBackgroundFolder | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CBackgroundFolder | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CBackgroundFolder | [virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh() | CBackgroundFolder | [virtual]
OnRefresh() | CBackgroundFolder | [virtual]
OnRefresh() | CBackgroundFolder | [virtual]
CDelegationBase::OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CBackgroundFolder | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CBackgroundFolder | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CBackgroundFolder | [virtual]
CDelegationBase::OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
CDelegationBase::OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
StartThread() | CBackgroundFolder | [private]
StartThread() | CBackgroundFolder | [private]
StartThread() | CBackgroundFolder | [private]
StopThread() | CBackgroundFolder | [private]
StopThread() | CBackgroundFolder | [private]
StopThread() | CBackgroundFolder | [private]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CBackgroundFolder | [private, static]
ThreadProc(LPVOID lpParameter) | CBackgroundFolder | [private, static]
ThreadProc(LPVOID lpParameter) | CBackgroundFolder | [private, static]
ThreadProc(LPVOID lpParameter) | CBackgroundFolder | [private, static]
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBackgroundFolder | [private, static]
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBackgroundFolder | [private, static]
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBackgroundFolder | [private, static]
~CBackgroundFolder() | CBackgroundFolder | [virtual]
~CBackgroundFolder() | CBackgroundFolder | [virtual]
~CBackgroundFolder() | CBackgroundFolder | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
Generated on Wed Nov 13 2024 16:55:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagDIAGINFO Member List

This is the complete list of members for tagDIAGINFO, including all inherited members.
irecRecNumber | tagDIAGINFO
szDescFieldName | tagDIAGINFO
uwDescField | tagDIAGINFO
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/dxtrans/dxsurfmod/resource.h Source File

  • Web
  • dxtrans
  • dxsurfmod

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by surfmod.rc
00004 //
00005 #define IDR_MENU1                       101
00006 #define IDD_PROP                        104
00007 #define IDI_ICON1                       105
00008 #define IDCE_BGSURFACE                  1001
00009 #define IDCE_BGR                        1004
00010 #define IDCE_BGG                        1005
00011 #define IDCE_BGB                        1006
00012 #define IDCE_BGA                        1007
00013 #define IDCE_FGSURFACE                  1008
00014 #define IDCE_FGTILEX                    1009
00015 #define IDCR_FGTILE                     1010
00016 #define IDCR_FGPLACE                    1011
00017 #define IDCE_FGTILEY                    1012
00018 #define IDCE_BGBOUNDSX                  1015
00019 #define IDCE_BGBOUNDSY                  1016
00020 #define IDCB_LOADBG                     1017
00021 #define IDCB_LOADFG                     1018
00022 #define IDCC_FILLCOLOR                  1025
00023 #define ICCR_BACKGROUND                 1026
00024 #define IDCR_BOUNDS                     1027
00025 #define IDCC_FOREGROUND                 1028
00026 #define IDCE_OPACITY                    1030
00027 #define IDM_CLOSE                       40003
00028 #define IDM_EXIT                        40004
00029 #define IDM_PROPERTIES                  40005
00030 #define IDM_OVER                        40006
00031 #define IDM_ALPHA                       40007
00032 #define IDM_HUE                         40008
00033 #define IDM_BRIGHTNESS                  40009
00034
00035 // Next default values for new objects
00036 //
00037 #ifdef APSTUDIO_INVOKED
00038 #ifndef APSTUDIO_READONLY_SYMBOLS
00039 #define _APS_NEXT_RESOURCE_VALUE        106
00040 #define _APS_NEXT_COMMAND_VALUE         40010
00041 #define _APS_NEXT_CONTROL_VALUE         1031
00042 #define _APS_NEXT_SYMED_VALUE           101
00043 #endif
00044 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/ObjectPoolingJAVA/ObjectPoolingComponent/Account/util/DatabaseSettings.java Source File

  • Com
  • Services
  • Object_Pooling
  • ObjectPoolingJAVA
  • ObjectPoolingComponent
  • Account
  • util

DatabaseSettings.java

Go to the documentation of this file.
00001 package  util;
00002 public interface DatabaseSettings
00003 {
00004   public static final String DSN  = "Account";
00005   public static final String User = "sa";
00006   public static final String pass = "";
00007 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFixedAlloc Member List

This is the complete list of members for CFixedAlloc, including all inherited members.
Alloc() | CFixedAlloc | [inline]
CFixedAlloc(UINT nAllocSize, UINT nBlockSize=64) | CFixedAlloc |
Free(void *p) | CFixedAlloc | [inline]
FreeAll() | CFixedAlloc |
GetAllocSize() | CFixedAlloc | [inline]
m_nAllocSize | CFixedAlloc | [protected]
m_nBlockSize | CFixedAlloc | [protected]
m_pBlocks | CFixedAlloc | [protected]
m_pNodeFree | CFixedAlloc | [protected]
m_protect | CFixedAlloc | [protected]
~CFixedAlloc() | CFixedAlloc |
Generated on Wed Nov 13 2024 16:56:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/wn_dos.h Source File

  • Com
  • Fundamentals
  • OleStd

wn_dos.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2.0 Property Set Utilities
00004 **
00005 **    wn_dos.h
00006 **
00007 **    This file contains file contains data structure defintions,
00008 **    function prototypes, constants, etc. for Windows 3.x form of
00009 **    DOS calls. This is used by the SUMINFO OLE 2.0 Property Set
00010 **    utilities used to manage the Summary Info property set.
00011 **
00012 **    (c) Copyright Microsoft Corp. 1990 - 2000 All Rights Reserved
00013 **
00014 *************************************************************************/
00015
00016 #ifndef WN_DOS_H
00017 #define WN_DOS_H
00018
00019 #include <dos.h>
00020
00021 #define WIN 1
00022
00023 #define cbMaxFile 146 //from inc\path.h
00024 #define SEEK_FROM_BEGINNING 0
00025 #define SEEK_FROM_END 2
00026 #define chDOSPath ('\\')        // FUTURE: not used all places it could be
00027 #define chDOSWildAll    '*'     /* DOS File name wild card. */
00028 #define chDOSWildSingle '?'
00029
00030
00031
00032 // Close, seek, delete, rename, flush, get attributes, read, write
00033 /* RPC TEMP
00034 int  FCloseOsfnWin(WORD);
00035 #define FCloseOsfn(osfn)    FCloseOsfnWin(osfn)
00036 long DwSeekDwWin(WORD,LONG,WORD);
00037 #define DwSeekDw(osfn, dwSeek, bSeekFrom)   DwSeekDwWin(osfn, dwSeek, bSeekFrom)
00038 EC  EcDeleteSzFfnameWin(char *);
00039 #define EcDeleteSzFfname(szFile) EcDeleteSzFfnameWin(szFile)
00040 EC  EcRenameSzFfnameWin(char *,char *);
00041 #define EcRenameSzFfname(szFileCur,szFileNew) EcRenameSzFfnameWin(szFileCur,szFileNew)
00042 int FFlushOsfnWin(int);
00043 #define FFlushOsfn(osfn)    FFlushOsfnWin(osfn)
00044 WORD DaGetFileModeSzWin(char *);
00045 #define DaGetFileModeSz(szFile) DaGetFileModeSzWin(szFile)
00046 int  CbReadOsfnWin(int, void far *, UINT);
00047 int  CbWriteOsfnWin(int, void far *, UINT);
00048 #define CbWriteOsfn(osfn,lpch,cbWrite)  CbWriteOsfnWin(osfn,lpch,cbWrite)
00049 */
00050 #define WinOpenFile(sz,ofs,n)   OpenFile(sz,ofs,n)
00051 #define SeekHfile(f,off,kind) _llseek(f,off,kind)
00052 #define CbReadOsfn(osfn,lpch,cbRead)    CbReadOsfnWin(osfn,lpch,cbRead)
00053 #define CbReadHfile(f,buf,n) _lread(f,buf,n)
00054 #define CbReadOsfnWin(f,buf,n) CbReadHfile(f,buf,n)
00055 #define EcFindFirst4dm(a,b,c) _dos_findfirst((const char *)(b),c,(struct find_t*)a)
00056 #define EcFindNext4dm(a) _dos_findnext((struct find_t*)a)
00057 #define FHfileToSffsDate(handle,date,time) _dos_getftime(handle, (unsigned *)(date), (unsigned *)(time))
00058 #define SeekHfile(f, off, kind) _llseek(f,off,kind)
00059
00060 /* buffer structure to be used with EcFindFirst() and EcFindNext() */
00061 typedef struct _SFFS
00062   { /* Search Find File Structure */
00063   uchar buff[21]; // dos search info
00064   uchar wAttr;
00065   union
00066     {
00067     unsigned short timeVariable;    /*RPC47*/
00068     BF time:16;
00069     struct
00070       {
00071       BF sec : 5;
00072       BF mint: 6;
00073       BF hr  : 5;
00074       };
00075     };
00076   union
00077     {
00078     unsigned short dateVariable;
00079     BF date:16;
00080     struct
00081       {
00082       BF dom : 5;
00083       BF mon : 4;
00084       BF yr  : 7;
00085       };
00086     };
00087   ulong cbFile;
00088   uchar szFileName[13];
00089   } SFFS;
00090
00091 // find first file/find next file
00092 #define PszFromPsffs(psffs)     ((psffs)->szFileName)
00093 #define CopySzFilePsffs(psffs,sz)   OemToAnsi((char HUGE *)&((psffs)->szFileName[0]),(char HUGE *)(sz))
00094 #define CbSzFilePsffs(psffs)    CbSz((psffs)->szFileName)
00095 #define CbFileSizePsffs(psffs)  (psffs)->cbFile
00096 #define AttribPsffs(psffs)      (psffs)->wAttr
00097 #define EcFindFirstCore(psffs, sz, wAttr) EcFindFirst(psffs, sz, wAttr)   /*RPC22*/
00098 #define FDotPsffs(psffs) ((psffs)->szFileName[0]=='.')   /*RPC23*/
00099 #define AppendSzWild(sz) {int i=_fstrlen((char FAR *)(sz)); sz[i]='*'; sz[i+1]='.'; sz[i+2]='*'; sz[i+3]='\0';}
00100 // disk free space
00101
00102 unsigned long LcbDiskFreeSpaceWin(int);
00103 #define LcbDiskFreeSpace(chDrive) LcbDiskFreeSpaceWin(chDrive)
00104
00105 // date and time    /*RPC39*/
00106 /*
00107 typedef struct _TIM {                    // Time structure returned by OsTime
00108   CHAR minutes, hour, hsec, sec;
00109   } TIM;
00110
00111 typedef struct _DAT {                    // Date structure returned by OsDate
00112   int  year;
00113   CHAR month, day, dayOfWeek;
00114   } DAT;
00115 */
00116 #define TIM dostime_t    /*RPC39*/
00117 #define DAT dosdate_t
00118 #define OsTimeWin(TIM) _dos_gettime(TIM)
00119 #define OsDateWin(DAT) _dos_getdate(DAT)
00120
00121
00122 /* DOS File Attributes */
00123 #define DA_NORMAL       0x00
00124 #define DA_READONLY     0x01
00125 #define DA_HIDDEN       0x02
00126 #define DA_SYSTEM       0x04
00127 #define DA_VOLUME       0x08
00128 #define DA_SUBDIR       0x10
00129 #define DA_ARCHIVE      0x20
00130 #define DA_NIL          0xFFFF  /* Error DA */
00131 #define dosxSharing     32      /* Extended error code for sharing viol. */
00132 #define nErrNoAcc       5       /* OpenFile error code for Access Denied */
00133 #define nErrFnf         2       /* OpenFile error code for File Not Found */
00134
00135 /* Components of the Open mode for OpenSzFfname (DOS FUNC 3DH) */
00136 #define MASK_fINH       0x80
00137 #define MASK_bSHARE     0x70
00138 #define MASK_bACCESS    0x07
00139
00140 #define bSHARE_DENYRDWR 0x10
00141 #define bSHARE_DENYWR   0x20
00142 #define bSHARE_DENYNONE 0x40
00143
00144 /* Seek-from type codes passed to DOS function 42H */
00145
00146 #define SF_BEGINNING    0       /* Seek from beginning of file */
00147 #define SF_CURRENT      1       /* Seek from current file pointer */
00148 #define SF_END          2       /* Seek from end of file */
00149
00150
00151 typedef struct _DOSDTTM /* DOS DaTe TiMe */
00152     {
00153     union
00154       {
00155       long lDOSDttm;
00156       struct
00157         {
00158         BF day: 5;
00159         BF month:   4;
00160         BF year:    7;
00161         BF sec: 5;
00162         BF mint:    6;
00163         BF hours:   5;
00164         } S1;
00165       } U1;
00166     } DOSDTTM;
00167
00168 int  FOsfnIsFile(int);
00169
00170 void DateStamp(int, LONG *,  int);
00171 int  DosxError(void);
00172 int  ShellExec(int, int);
00173
00174 #endif //WN_DOS_H
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/statnode.h Source File

  • SysMgmt
  • MMC
  • CutCopy

statnode.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SNAPINBASE_H
00021 #define _SNAPINBASE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CStaticNode : public CDelegationBase {
00026 public:
00027     CStaticNode();
00028
00029     virtual ~CStaticNode();
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) {
00032         static _TCHAR szDisplayName[256];
00033         LoadString(g_hinst, IDS_SNAPINNAME, szDisplayName, (sizeof szDisplayName)/(sizeof szDisplayName[0]));
00034         return szDisplayName;
00035     }
00036     virtual const GUID & getNodeType() { return thisGuid; }
00037     virtual const int GetBitmapIndex() { return INDEX_NONE; }
00038
00039 public:
00040     // virtual functions go here (for MMCN_*)
00041     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00042
00043 private:
00044     enum { NUMBER_OF_CHILDREN = 5 };
00045     CDelegationBase *children[NUMBER_OF_CHILDREN];
00046
00047     // {2974380C-4C4B-11d2-89D8-000021473128}
00048     static const GUID thisGuid;
00049 };
00050
00051
00052
00053 #endif // _SNAPINBASE_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/comp.h Source File

  • SysMgmt
  • MMC
  • Nameext

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent, IExtendContextMenu
00025 {
00026 private:
00027     ULONG       m_cref;
00028
00029     IConsole*   m_ipConsole;
00030     IDisplayHelp* m_ipDisplayHelp;
00031
00032     class CComponentData *m_pComponentData;
00033
00034     public:
00035         CComponent(CComponentData *parent);
00036         ~CComponent();
00037
00038         ///////////////////////////////
00039         // Interface IUnknown
00040         ///////////////////////////////
00041         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042         STDMETHODIMP_(ULONG) AddRef();
00043         STDMETHODIMP_(ULONG) Release();
00044
00045         ///////////////////////////////
00046         // Interface IComponent
00047         ///////////////////////////////
00048         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00049             /* [in] */ LPCONSOLE lpConsole);
00050
00051             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00052             /* [in] */ LPDATAOBJECT lpDataObject,
00053             /* [in] */ MMC_NOTIFY_TYPE event,
00054             /* [in] */ LPARAM arg,
00055             /* [in] */ LPARAM param);
00056
00057             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00058             /* [in] */ MMC_COOKIE cookie);
00059
00060             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00061             /* [in] */ MMC_COOKIE cookie,
00062             /* [in] */ DATA_OBJECT_TYPES type,
00063             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00064
00065             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00066             /* [in] */ MMC_COOKIE cookie,
00067             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00068             /* [out] */ long __RPC_FAR *pViewOptions);
00069
00070             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00071             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00072
00073             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00074             /* [in] */ LPDATAOBJECT lpDataObjectA,
00075             /* [in] */ LPDATAOBJECT lpDataObjectB);
00076
00077             ///////////////////////////////
00078             // Interface IExtendContextMenu
00079             ///////////////////////////////
00080             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddMenuItems(
00081             /* [in] */ LPDATAOBJECT piDataObject,
00082             /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
00083             /* [out][in] */ long __RPC_FAR *pInsertionAllowed);
00084
00085             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Command(
00086             /* [in] */ long lCommandID,
00087             /* [in] */ LPDATAOBJECT piDataObject);
00088
00089 };
00090
00091 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPooledData Member List

This is the complete list of members for CPooledData, including all inherited members.
ActivateData(IObjectContext *pObjectContext) | CPooledData | [inline, protected]
CanConnectionBePooled(void) | CPooledData | [inline, protected, virtual]
ConstructData(IDispatch *pUnk) | CPooledData | [inline, protected]
CPooledData() | CPooledData | [inline, protected]
DeactivateData(void)=0 | CPooledData | [protected, pure virtual]
Enlist(IObjectContext *pObjectContext, const CLSID &clsid, const IID &iid)=0 | CPooledData | [protected, pure virtual]
m_bConstructed | CPooledData | [protected]
m_bObjectPooled | CPooledData | [protected]
m_bShouldEnlist | CPooledData | [protected]
m_spObjectContext | CPooledData | [protected]
m_txuow | CPooledData | [protected]
ManualConstruct(BSTR ConstructString)=0 | CPooledData | [protected, pure virtual]
QueryEnlist(const CLSID &clsid, const IID &iid) | CPooledData | [inline, protected, virtual]
~CPooledData() | CPooledData | [inline, protected]
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ITest Member List

This is the complete list of members for ITest, including all inherited members.
LPTEST typedef | ITest
Test1([in, out] BSTR lpbstr) | ITest
Test2([in] BSTR bstrIn,[out] BSTR *lpbstrOut) | ITest
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/GQos/QosEvent/QosEvent.Cpp Source File

  • NetDS
  • GQos
  • QosEvent

QosEvent.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      qosevent.cpp
00010 //
00011 // Abstract:
00012 //      This application demonstrates how to GQOS-enable a simple Winsock
00013 //      application.  This application makes no attempt to do anything useful
00014 //      per se, but concentrates on illustrating key techniques to use when
00015 //      developing your GQOS-enabled application.  Additionally, this
00016 //      application demonstrates several Winsock2-specific APIs and techniques
00017 //      that are useful whether or not your main interest is GQOS-enabling your
00018 //      application.
00019 //
00020 //      Commandline parameters determine whether this application functions as
00021 //      either a sender (-n) or a receiver (default).  Use the -? commandline
00022 //      switch to determine available options.
00023 //
00024 //      This application simply sends a buffer of data when acting as the
00025 //      sender, to an instance of itself acting as a receiver.  Any number of
00026 //      senders (up to MAXCLIENTS) can be started to interact with one instance
00027 //      of a receiver.The size of the data buffer (-b), its contents (-d), and
00028 //      the number of times to send (-l) this buffer are controllable via
00029 //      commandline switches. A repeat value of 0 implies continuous sending.
00030 //      The (-c) commandline switch allows enabling/disabling QOS on the socket
00031 //      every 5 sends and will cause any repeat count entered to be overridden
00032 //      and set to continuous mode. A delay commandline switch (-s:#), measured
00033 //      in milliseconds can be specified for the sender to insure the total
00034 //      transfer spans a measured unit of time (this would be interesting for
00035 //      observing RSVP PATH/RESV message refresh).
00036 //
00037 //      The sender and receiver can choose to use either UDP or TCP (default)
00038 //      for data transfers by using the -p commandline option.  The port number
00039 //      (endpoint) used by TCP and UDP is also controllable via commandline
00040 //      switch (-e).
00041 //
00042 //      The application is also multicast capable. A multicast receiver must
00043 //      specify the multicast option (-m) and the multicast IP address to join
00044 //      or allow a default to be used.  If the multicast option is not specified
00045 //      but the sender attempts to send data directly to that multicast address,
00046 //      the -m is implicitly set by the program. When both -n and -m values are
00047 //      used (by a multicast sender) any address specified in -n is overriden by
00048 //      the value used in -m.
00049 //
00050 //      This application can be enabled to support GQOS by specifying a specific
00051 //      GQOS template to use (-q) for transfers.  Additionally, when to enable
00052 //      GQOS (i.e. when to inform the GQOS Service Provider) can be controlled
00053 //      via a commandline switch (-i).  The priority to use for sending data is
00054 //      also controllable via a commandline switch (-tc-priority).
00055 //
00056 // Entry Points:
00057 //      main - this is where it all starts
00058 //
00059 // Usage:
00060 //      Act as a TCP receiver and enable QOS using g711 codec
00061 //          qosevent -q:g711
00062 //      Act as a TCP sender and enable QOS using g711 and send buffer 10 times
00063 //          qosevent -n:receiver_host -q:g711 -l:10
00064 //      Act as a UDP sender and enable QOS using g711, set QOS during connect,
00065 //      send buffer 30 times with a 2 second delay between sends
00066 //          qosevent -p:udp -n:receiver_host -q:g711 -i:d -l:30 -s:2000
00067 //      Act as a TCP sender, no QOS, and send buffer once
00068 //          qosevent -n:receiver_host
00069 //      Act as a UDP sender, no QOS, and send buffer once
00070 //          qosevent -n:receiver_host
00071 //      Act as a multicast receiver and enable QOS using g711
00072 //          qosevent -q:g711 -m:234.5.6.7
00073 //
00074 // Build:
00075 //      Use the headers and libs from the June98 Platform SDK or later.
00076 //      Link with ws2_32.lib
00077 //
00078 // Author:
00079 //      Barry R. Butterklee
00080 //
00081 // Changes:
00082 //      8/99 - Correct handling of SIO_GET_QOS for Windows 2000 (and workaround
00083 //             for Windows 98) added to GetQos().
00084 //      8/99 - Fix handling of RSVP_RESERVE_INFO in PrintQos() and SetQos()
00085 //      8/99 - Remove obsolete QOS_OBJECT_PRIORITY
00086 //      8/99 - Update comments in CreateSendingSocket
00087
00088
00089 #include "qosevent.h"
00090
00091 OPTIONS default_options =
00092     {
00093     "localhost",
00094     MY_DEFPORT,
00095     1,
00096     'c',
00097     4096,
00098     NULL,
00099     0,
00100     0,
00101     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, INVALID_SEND_PRIORITY,
00102         TRUE, TRUE, TRUE, TRUE, FALSE, QOS_IOCTL_SET_BEFORE, QOS_DEFAULTNAME},
00103     {IPPROTO_TCP, FALSE, FALSE}
00104     };
00105
00106 FLOWSPEC default_notraffic =
00107     {
00108     QOS_NOT_SPECIFIED,
00109     QOS_NOT_SPECIFIED,
00110     QOS_NOT_SPECIFIED,
00111     QOS_NOT_SPECIFIED,
00112     QOS_NOT_SPECIFIED,
00113     SERVICETYPE_NOTRAFFIC,
00114     QOS_NOT_SPECIFIED,
00115     QOS_NOT_SPECIFIED
00116     };
00117
00118
00119 FLOWSPEC default_g711 =
00120     {
00121     8500,
00122     680,
00123     17000,
00124     QOS_NOT_SPECIFIED,
00125     QOS_NOT_SPECIFIED,
00126     SERVICETYPE_GUARANTEED,
00127     340,
00128     340
00129     };
00130
00131
00132 SOCKADDR_IN g_destaddr;
00133
00134 static BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions);
00135 static VOID PrintOptions(OPTIONS *pOptions);
00136 static VOID Usage(CHAR *szProgramname);
00137
00138
00139
00140
00141 int _cdecl main(int argc, char *argv[])
00142 {
00143     int ret, err;
00144     OPTIONS options;
00145     WSADATA WSAData;
00146     WSAPROTOCOL_INFO protocol_info;
00147
00148     ret = NO_ERROR;
00149     options.buf = NULL;
00150
00151     // Process the Command Line Options
00152     if (!ValidOptions(argv, argc, &options))
00153         exit(1);
00154
00155     // Startup Winsock
00156     err = WSAStartup(MAKEWORD(2,2), &WSAData);
00157     if (err)
00158     {
00159         printf("WSAStartup Failed (%d) Exiting\n", err);
00160         goto cleanup;
00161     }
00162
00163     // Look for a Service Provider to handle what
00164     // we need from the options
00165     if (!FindServiceProvider(
00166                     options.spOptions.iProtocol,
00167                     options.spOptions.bQos,
00168                     options.spOptions.bMulticast,
00169                     &protocol_info))
00170     {
00171         printf("No matching service provider found. Exiting\n");
00172         goto cleanup;
00173     }
00174
00175     // Show the user what they have selected
00176     PrintOptions(&options);
00177
00178     // Become a Sender or a Reciever
00179     if (options.qosOptions.bReceiver)
00180         Receiver(&options, &protocol_info);
00181     else
00182         Sender(&options, &protocol_info);
00183
00184 cleanup:
00185
00186     if (options.buf)
00187         free(options.buf);
00188
00189     WSACleanup();
00190     return(0);
00191 }
00192
00193
00194
00195
00196 // Abstract:
00197 //      Verify options passed in and set options structure accordingly.
00198 //
00199 BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
00200 {
00201   OSVERSIONINFO   verInfo;
00202   char *errReason = NULL;
00203   int i;
00204
00205   // Initialize the options to default values
00206   *pOptions = default_options;
00207
00208   for (i=1; i<argc; i++)
00209   {
00210     if ((argv[i][0] != '-') && (argv[i][0] != '/') )
00211       goto err;
00212
00213     switch(tolower(argv[i][1]))
00214     {
00215     case 'b' :
00216       if (strlen(argv[i]) <= 3)
00217         goto err;
00218       pOptions->nBufSize = 1024*atoi(&argv[i][3]);
00219       break;
00220
00221     case 'c' :
00222       pOptions->qosOptions.bAlternateQos = TRUE;
00223       break;
00224
00225     case 'd' :
00226       if (strlen(argv[i]) <= 3)
00227         goto err;
00228       pOptions->fillchar = argv[i][3];
00229       break;
00230
00231     case 'e' :
00232       if (strlen(argv[i]) <= 3)
00233         goto err;
00234       pOptions->port = (USHORT) atoi(&argv[i][3]);
00235       break;
00236
00237     case 'i' :
00238       if (strlen(argv[i]) <= 3)
00239         goto err;
00240
00241             switch(tolower(argv[i][3]))
00242             {
00243                 case 'a':
00244                     pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_AFTER;
00245                     break;
00246                 case 'b':
00247                     pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_BEFORE;
00248                     break;
00249                 case 'd':
00250           pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_DURING;
00251           break;
00252             case 'q':
00253           pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_QOS;
00254           break;
00255             default:
00256           goto err;
00257             }
00258       break;
00259
00260     case 'l' :
00261       if (strlen(argv[i]) <= 3)
00262         goto err;
00263       pOptions->nRepeat = atoi(&argv[i][3]);
00264       break;
00265
00266     case 'm' :
00267       pOptions->spOptions.bMulticast = TRUE;
00268       if (strlen(argv[i]) <= 3)
00269         break;
00270
00271       // we are getting passed a hostname, Is it too big?
00272       if (strlen(&argv[i][3]) >= sizeof(pOptions->szHostname))
00273       {
00274         errReason = "specified hostname too long, max 64 characters";
00275         goto err;
00276       }
00277
00278       strcpy(pOptions->szHostname, &argv[i][3]);
00279       break;
00280
00281     case 'n' :
00282       pOptions->qosOptions.bReceiver = FALSE;
00283       if (strlen(argv[i]) <= 3)
00284         break;
00285
00286       // we are trying to specify a hostname
00287       // but multicast group overrides hostname on -n
00288       if (pOptions->spOptions.bMulticast)
00289       {
00290         printf("Warning: Hostname specified in -n is ignored when multicast is set\n");
00291         break;
00292       }
00293
00294       // Is it too big?
00295       if (strlen(&argv[i][3]) >= sizeof(pOptions->szHostname))
00296       {
00297         errReason = "specified hostname too long, max 64 characters";
00298         goto err;
00299       }
00300
00301       strcpy(pOptions->szHostname, &argv[i][3]);
00302       break;
00303
00304     case 'p' :
00305       if (strlen(argv[i]) <= 3)
00306         goto err;
00307
00308             switch(tolower(argv[i][3]))
00309             {
00310                 case 'u':
00311           pOptions->spOptions.iProtocol = IPPROTO_UDP;
00312                     break;
00313                 case 't':
00314           pOptions->spOptions.iProtocol = IPPROTO_TCP;
00315           break;
00316             default:
00317           goto err;
00318             }
00319       break;
00320
00321     case 'q' :
00322       pOptions->spOptions.bQos = TRUE;
00323       if (strlen(argv[i]) <= 3)
00324         break;
00325
00326       // We are being given the template name, Is it too long?
00327       if (strlen(&argv[i][3]) >= sizeof(pOptions->qosOptions.szTemplate))
00328       {
00329         errReason = "specified template name too long, max 64 characters";
00330         goto err;
00331       }
00332
00333       strcpy(pOptions->qosOptions.szTemplate, &argv[i][3]);
00334       break;
00335
00336     case 'r' :
00337       if (strlen(argv[i]) <= 3)
00338         goto err;
00339
00340       if ((_stricmp(argv[i], "-rsvp-confirm") == 0) ||
00341         (_stricmp(argv[i], "-rsvp_confirm") == 0))
00342       {
00343         pOptions->qosOptions.bConfirmResv = TRUE;
00344         pOptions->qosOptions.bProviderSpecific = TRUE;
00345       }
00346       else if ((_stricmp(argv[i], "-rsvp-wait") == 0) ||
00347           (_stricmp(argv[i], "-rsvp_wait") == 0))
00348       {
00349         pOptions->qosOptions.bWaitToSend = TRUE;
00350         pOptions->qosOptions.bProviderSpecific = TRUE;
00351       }
00352       else
00353         goto err;
00354
00355       break;
00356
00357     case 's' :
00358       if (strlen(argv[i]) <= 3)
00359         goto err;
00360
00361       pOptions->dwSleep = atoi(&argv[i][3]);
00362       break;
00363
00364         case '?':
00365             i=0; //reset i to not print a specific location error
00366
00367     default:
00368       goto err;
00369     }
00370   }
00371
00372
00373   if (pOptions->qosOptions.bReceiver)
00374     pOptions->fillchar = 0;
00375
00376   if (pOptions->spOptions.bMulticast)
00377   {
00378     pOptions->spOptions.iProtocol = IPPROTO_UDP;
00379     pOptions->qosOptions.bSetDestaddr = FALSE;
00380   }
00381
00382   if (IPPROTO_TCP == pOptions->spOptions.iProtocol)
00383   {
00384     pOptions->spOptions.bMulticast = FALSE;
00385     pOptions->qosOptions.bSetDestaddr = FALSE;
00386   }
00387   else if (!pOptions->spOptions.bMulticast)
00388     pOptions->qosOptions.bSetDestaddr = TRUE;
00389
00390   if (pOptions->spOptions.bQos)
00391   {
00392     if (pOptions->qosOptions.bReceiver)
00393       {
00394         if (pOptions->qosOptions.bWaitToSend)
00395                 // not a valid sender option
00396           pOptions->qosOptions.bWaitToSend = FALSE;
00397
00398         }
00399         else
00400         {
00401             if (pOptions->qosOptions.bConfirmResv)
00402                 // not a valid sender option
00403           pOptions->qosOptions.bConfirmResv = FALSE;
00404         }
00405
00406     if (pOptions->qosOptions.bAlternateQos)
00407       pOptions->nRepeat = 0;  // override repeat count to continuous mode
00408
00409     if (    (IPPROTO_UDP == pOptions->spOptions.iProtocol)
00410         &&  (!pOptions->spOptions.bMulticast))
00411       // using UDP, there WSAAccept will not be called, therefore do
00412       // not wait to set qos
00413       pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_BEFORE;
00414
00415     verInfo.dwOSVersionInfoSize = sizeof(verInfo);
00416     GetVersionEx(&verInfo);
00417     switch (verInfo.dwPlatformId)
00418     {
00419     case VER_PLATFORM_WIN32_NT:
00420       pOptions->qosOptions.bQueryBufferSize = TRUE;
00421       pOptions->qosOptions.bMustSetQosInAccept = FALSE;
00422       pOptions->qosOptions.bFineGrainErrorAvail = TRUE;
00423       pOptions->qosOptions.bQosabilityIoctls = TRUE;
00424       printf("running on NT\n");
00425       break;
00426
00427     case VER_PLATFORM_WIN32_WINDOWS:
00428       pOptions->qosOptions.bQueryBufferSize = FALSE;
00429       pOptions->qosOptions.bMustSetQosInAccept = TRUE;
00430       pOptions->qosOptions.bFineGrainErrorAvail = FALSE;
00431       pOptions->qosOptions.bQosabilityIoctls = FALSE;
00432       printf("running on 9x\n");
00433       break;
00434
00435     default:
00436       printf ("requires Windows NT or Windows 98\n");
00437       pOptions->qosOptions.bQueryBufferSize = FALSE;
00438       pOptions->qosOptions.bMustSetQosInAccept = TRUE;
00439       pOptions->qosOptions.bFineGrainErrorAvail = FALSE;
00440       pOptions->qosOptions.bQosabilityIoctls = FALSE;
00441       break;
00442     }
00443   }
00444
00445   pOptions->buf = (char *)malloc(pOptions->nBufSize);
00446   if (!pOptions->buf) {
00447     printf("Unable to allocate buffer for sends of size (%d). Exiting.\n",
00448                 pOptions->nBufSize);
00449     return(FALSE);
00450   }
00451
00452   FillMemory(pOptions->buf, pOptions->nBufSize, pOptions->fillchar);
00453   return(TRUE);
00454
00455 err:
00456   if (i>0)
00457   {
00458     if (errReason)
00459       printf("  invalid option syntax (%s): %s\n", argv[i], errReason);
00460     else
00461       printf("  invalid option syntax (%s)\n", argv[i]);
00462   }
00463   Usage(argv[0]);
00464   return(FALSE);
00465 }
00466
00467
00468
00469
00470 // Abstract:
00471 //      Just print the options to be used for this run.
00472 //
00473 static VOID PrintOptions(OPTIONS *pOptions)
00474 {
00475   printf("Options\n");
00476   printf("  Protocol %d\n", pOptions->spOptions.iProtocol);
00477   printf("  Port %d\n", pOptions->port);
00478
00479   if (pOptions->qosOptions.bReceiver)
00480     printf("  Act as Receiver\n");
00481   else
00482   {
00483     printf("  Act as sender and send to %s\n", pOptions->szHostname);
00484     printf("  Sleep %d milliseconds between sends\n", pOptions->dwSleep);
00485     printf("  Fill buffer with <%c>\n", pOptions->fillchar);
00486     if (pOptions->nRepeat)
00487       printf("  Repeat sending the buffer %d times\n", pOptions->nRepeat);
00488     else
00489       printf("  Repeat sending the buffer continually\n");
00490   }
00491
00492   printf("  Bufsize %d (1K increments)\n", pOptions->nBufSize);
00493   printf("  Multicast is %s\n",
00494           (pOptions->spOptions.bMulticast ? "Enabled" : "Disabled"));
00495
00496   if (pOptions->spOptions.bQos)
00497   {
00498     printf("  Qos template %s\n", pOptions->qosOptions.szTemplate);
00499     printf("  Qos to be set ");
00500
00501     switch (pOptions->qosOptions.qosIoctlSet)
00502     {
00503     case QOS_IOCTL_SET_BEFORE:
00504       printf("Before accept/connect/joinleaf\n");
00505       break;
00506
00507     case QOS_IOCTL_SET_AFTER:
00508       printf("After accept/connect/joinleaf\n");
00509       break;
00510
00511     case QOS_IOCTL_SET_DURING:
00512       printf("During accept/connect/joinleaf\n");
00513       break;
00514
00515     case QOS_IOCTL_SET_QOS:
00516       if (pOptions->qosOptions.bReceiver)
00517         printf("During FD_QOS, implies QOS with no signaling set before accept/connect (eventually)\n");
00518       else
00519       {
00520         pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_BEFORE;
00521         printf("Before connect\n");
00522       }
00523       break;
00524       default:
00525           _assume(0);
00526     }
00527
00528     if (pOptions->qosOptions.bConfirmResv )
00529       printf("  RESV confirmation to be requested\n");
00530
00531     if (INVALID_SEND_PRIORITY != pOptions->qosOptions.SendPriority)
00532       printf("  Qos TC SendPriority to be set to %d\n",
00533           pOptions->qosOptions.SendPriority);
00534
00535     if (!pOptions->qosOptions.bReceiver)
00536     {
00537       if (pOptions->qosOptions.bWaitToSend)
00538         printf("  Wait for RESV before sending data\n");
00539       else
00540         printf("  Do not wait for RESV to start sending data\n");
00541     } else
00542       printf("  Qos must be set during Accept = %s\n",
00543         (pOptions->qosOptions.bMustSetQosInAccept?"TRUE":"FALSE"));
00544
00545     printf("  Query for QOS buffer size: %s\n",
00546         (pOptions->qosOptions.bQueryBufferSize?"TRUE":"FALSE"));
00547   }
00548
00549   printf("\n");
00550   return;
00551 }
00552
00553
00554
00555
00556 // Abstract:
00557 //      Print out usage table for the program
00558 //
00559 VOID Usage(CHAR *szProgramname)
00560 {
00561     printf("usage:\n  %s -?\n\n", szProgramname);
00562     printf("  %s [-b:#] [-d:c] [-e:#] [-l:#] [-m:group] [-n:host] [-s:#] [-u]\n\t[-q:template [-i:[a|b|d|q]] [-c] [-rsvp-confirm] [-rsvp-wait]]\n\n",
00563             szProgramname);
00564     printf("  -?\t\tDisplay this help\n");
00565     printf("\n");
00566     printf("  -b:bufsize\tSize of send/recv buffer; in 1K increments (Def:%d)\n",
00567             default_options.nBufSize);
00568     printf("  -d:c\t\tCharacter used to fill buffer (Def:%c)\n",
00569             default_options.fillchar);
00570     printf("  -e:port\tEndpoint number (port) to use (Def:%d)\n",
00571             default_options.port);
00572     printf("  -l:loop\tLoop count for sending buffer (0==>continuous) (Def:%d)\n",
00573             default_options.nRepeat);
00574     printf("  -m:group\tMulticast group (IP) to join (Def:%s)\n",
00575             DEFAULT_MULTICASTGROUP);
00576     printf("  -n:host\tAct as the client and connect to 'host' (Def:%s)\n",
00577             default_options.szHostname);
00578     printf("  -p:protocol\tTCP or UDP (def:TCP)\n");
00579     printf("  -s:#\t\tSleep # milliseconds between sends (def: 0)\n");
00580     printf("\n");
00581     printf("  -q:template\tEnable QoS and use 'template' to specify the name (Def:%s)\n",
00582             default_options.qosOptions.szTemplate);
00583     printf("  -c\t\tCycle enabling/disabling QOS on sending socket (Def: no cycling)\n");
00584     printf("  -i:[a|b|d|q]\tSet Qos After, Before, During accept/connect, or during FD_QOS\n\t\t\t(def: Before)\n");
00585     printf("  -rsvp-confirm\t\tRequest RESV confirmation be sent (Def: no confirmation) (not for Windows XP and later)\n");
00586     printf("  -rsvp-wait\t\tWait for RESV from receiver before sending data (not for Windows XP and later)\n");
00587     return;
00588 }
00589
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Util::line Member List

This is the complete list of members for Util::line, including all inherited members.
XFrom | Util::line
XTo | Util::line
YFrom | Util::line
YTo | Util::line
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/APP.Cxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

APP.Cxx

Go to the documentation of this file.
00001 //+--------------------------------------------------------
00002 // File:        App.cxx
00003 //
00004 // Classes:     CController
00005 //
00006 // Functions:   WinMain
00007 //              WndProc
00008 //              MakeWindowClass
00009 //              AboutDlgProc
00010 //        PropDlgProc
00011 //
00012 // History:     22-Jan-1993     asmusf  created
00013 //----------------------------------------------------------
00014
00015 #include <windows.h>
00016 #include <windowsx.h>
00017 #include "app.hxx"
00018
00019 // global for use by PropDlgProc
00020 CCTypeSet * pCSet = NULL;
00021
00022
00023 //+--------------------------------------------------------
00024 // Class:       CController
00025 //
00026 // Purpose:     Controlling the application, UI handler
00027 //
00028 // History:     22-Jan-1993     asmusf  created
00029 //----------------------------------------------------------
00030
00031 void CController::Create(HWND hwnd, LPARAM lParam )
00032 {
00033     HANDLE handle = ((LPCREATESTRUCT) lParam)->hInstance;
00034     _hInst = (HINSTANCE)handle;
00035     _funAbout = (DLGPROC) MakeProcInstance((FARPROC)AboutDlgProc, _hInst);
00036     _funProp = (DLGPROC) MakeProcInstance((FARPROC) PropDlgProc, _hInst );
00037
00038     // Set up the Main View
00039     _pView = new CScrollableView(((LPCREATESTRUCT) lParam)->cx,
00040                                 ((LPCREATESTRUCT) lParam)->cy);
00041     _pView->SetScale(100);
00042
00043     SetScrollRange(hwnd, SB_VERT, 0, PAGEHEIGHT, FALSE);
00044     SetScrollRange(hwnd, SB_HORZ, 0, PAGEWIDTH, FALSE);
00045
00046     SetScrollPos(hwnd, SB_HORZ, 0, TRUE );
00047     SetScrollPos(hwnd, SB_VERT, 0, TRUE );
00048
00049     // Set up the Model
00050     _pModel= new CModel(_hInst, hwnd, HEXADECIMAL, USEDONLY);
00051
00052     // Set up the initial state of the Menu
00053     Page(hwnd, IDM_FIRSTPAGE);
00054
00055     // initially no pop-up character box
00056     _pBox = 0;
00057 }
00058
00059 void CController::Destroy()
00060 {
00061
00062     FreeProcInstance((FARPROC)AboutDlgProc);
00063
00064     delete _pView;
00065     delete _pModel;
00066     PostQuitMessage(0);
00067 }
00068
00069 void CController::Size ( LPARAM lParam )
00070 {
00071    _pView->SetSize ( LOWORD(lParam), HIWORD(lParam) );
00072 }
00073
00074 // Message Box with text from resource file
00075 void CController::AlertBox( HWND hwnd, UINT idsText, UINT fuStyle)
00076 {
00077     TCHAR szText[100];
00078     TCHAR szCaption[100];
00079
00080     LoadString(_hInst, idsText, (LPTSTR)szText, 100);
00081     LoadString(_hInst, IDS_MSGCAPTION, (LPTSTR)szCaption, 100);
00082
00083     ::MessageBox (hwnd, (LPTSTR)szText, (LPTSTR)szCaption, fuStyle) ;
00084 };
00085
00086 // Menu commands processing
00087
00088 void CController::Command ( HWND hwnd, WPARAM wID )
00089 {
00090     switch ( wID )
00091     {
00092       // File Menu
00093       case IDM_PRINT:
00094            {
00095                 CPrintRequest job(hwnd, 1, _pModel->GetMaxPage());
00096
00097                 if(!job.Cancelled() && !job.Error())
00098                 {
00099                     CPrintCanvas canvas (job);
00100                     job.Print (_hInst, canvas, _pModel);
00101
00102                     if(job.Error())
00103                     {
00104                         AlertBox (hwnd, IDS_PRINTERR, MB_OK | MB_ICONEXCLAMATION) ;
00105                     }
00106                 }
00107            }
00108            break;
00109
00110       case IDM_EXIT:
00111            SendMessage ( hwnd, WM_CLOSE, 0L, 0L );
00112            break;
00113
00114       // View Menu
00115       case IDM_NEXTPAGE:
00116            Page(hwnd, IDM_NEXTPAGE);
00117            break;
00118
00119       case IDM_PREVPAGE:
00120            Page(hwnd, IDM_PREVPAGE);
00121            break;
00122
00123       case IDM_NEXTSECTION:
00124            Page(hwnd, IDM_NEXTSECTION);
00125            break;
00126
00127       case IDM_PREVSECTION:
00128            Page(hwnd, IDM_PREVSECTION);
00129            break;
00130
00131       case IDM_ZOOMIN:
00132            {
00133                UINT iScale;
00134                _pView->GetScale(iScale);
00135                iScale -= (iScale > 50 ? 25 : 0);
00136                _pView->SetScale(iScale);
00137                _pView->Invalidate(hwnd);
00138            }
00139            break;
00140
00141       case IDM_ZOOMOUT:
00142            {
00143                UINT iScale;
00144                _pView->GetScale(iScale);
00145                iScale += (iScale < 200 ? 25 : 0);
00146                _pView->SetScale(iScale);
00147                _pView->Invalidate(hwnd);
00148            }
00149            break;
00150
00151       // Options Menu
00152       case IDM_FONT:
00153            _pModel->ChooseFont(hwnd);
00154            _pView->Invalidate(hwnd);
00155            break;
00156
00157      case IDM_DECIMAL:
00158            {
00159                UINT fuFormat;
00160                _pModel->GetFormat(fuFormat);
00161                fuFormat ^= DECIMAL;
00162                CheckMenuItem (GetMenu(hwnd), IDM_DECIMAL,
00163                         fuFormat & DECIMAL ? MF_CHECKED : MF_UNCHECKED ) ;
00164               _pModel->SetFormat(fuFormat);
00165            }
00166            _pView->Invalidate(hwnd);
00167            break;
00168
00169       case IDM_ALLPAGES:
00170            {
00171                UINT fPageMode;
00172                _pModel->GetPageMode(fPageMode);
00173                fPageMode ^= ALLPAGES;
00174                CheckMenuItem (GetMenu(hwnd), IDM_ALLPAGES,
00175                         fPageMode & ALLPAGES ? MF_CHECKED : MF_UNCHECKED ) ;
00176                _pModel->SetPageMode(fPageMode);
00177            }
00178            _pView->Invalidate(hwnd);
00179            break;
00180
00181        case IDM_SHOWPROP:
00182             {
00183                 DialogBox( _hInst, TEXT("PROPERTIES"),hwnd, _funProp );
00184                     _pModel->SetCSet(pCSet);
00185             }
00186             _pView->Invalidate(hwnd);
00187             break;
00188
00189       // Help Menu
00190       case IDM_HELP:
00191            AlertBox ( hwnd, IDS_NOTIMPLEM, MB_ICONINFORMATION | MB_OK);
00192            break;
00193
00194       case IDM_ABOUT:
00195            DialogBox ( _hInst, TEXT("AboutBox"), hwnd, _funAbout );
00196            break;
00197      }
00198 }
00199
00200 void CController::Page(HWND hwnd, WPARAM wParam)
00201 {
00202     UINT iPage = _pModel->GetPage();
00203     switch (wParam)
00204     {
00205     case IDM_PREVPAGE:
00206         _pModel->PrevPage();
00207         break;
00208     case IDM_NEXTPAGE:
00209         _pModel->NextPage();
00210         break;
00211     case IDM_NEXTSECTION:
00212         _pModel->NextSection();
00213         break;
00214     case IDM_PREVSECTION:
00215         _pModel->PrevSection();
00216         break;
00217     case IDM_FIRSTPAGE:
00218         _pModel->SetPage( 0 );
00219         break;
00220     case IDM_LASTPAGE:
00221         _pModel->SetPage( _pModel->GetMaxPage() -1 );
00222         break;
00223     }
00224     if (iPage != _pModel->GetPage())
00225     {
00226         _pView->Invalidate(hwnd);
00227     }
00228     HMENU hmenu = GetMenu(hwnd);
00229
00230     EnableMenuItem (hmenu, IDM_PREVPAGE, _pModel->CanPrevPage()  ?
00231                       MF_ENABLED : MF_DISABLED | MF_GRAYED ) ;
00232     EnableMenuItem (hmenu, IDM_NEXTPAGE, _pModel->CanNextPage() ?
00233                       MF_ENABLED : MF_DISABLED | MF_GRAYED ) ;
00234     EnableMenuItem (hmenu, IDM_NEXTSECTION, _pModel->CanNextSection() ?
00235                       MF_ENABLED : MF_DISABLED | MF_GRAYED ) ;
00236     EnableMenuItem (hmenu, IDM_PREVSECTION,_pModel->CanPrevSection() ?
00237                       MF_ENABLED : MF_DISABLED | MF_GRAYED ) ;
00238 }
00239
00240 void CController::ButtonDown(HWND hwnd, LPARAM lParam )
00241 {
00242     static RECT rc;
00243     SetCapture (hwnd);
00244
00245   // second mouse click removes pop-up box
00246     if( _pBox )
00247     {
00248         delete _pBox;
00249         _pBox = 0;
00250     _pView->Invalidate(hwnd, &rc);
00251         return;
00252     }
00253
00254   // locate character selected
00255     CScreenCanvas canvas(hwnd);
00256
00257     POINT pt = {LOWORD(lParam), HIWORD(lParam)};
00258
00259     UINT iChar = _pView->Hittest(canvas, pt, _pModel);
00260
00261     if( iChar == 0xFFFF )
00262     {
00263         return;   // no char selected
00264     }
00265
00266   // create the pop-up box
00267     SIZE size = { 4*(INCH1-INCH8)/5, INCH1};
00268     CBoxFormat bxf(size);
00269
00270     HFONT hfont = _pModel->GetFont();
00271     _pBox = new CBox(bxf, iChar, hfont);
00272
00273
00274   // match current format
00275     UINT fuFormat;
00276   _pModel->GetFormat(fuFormat);
00277   _pBox->SetFormat(fuFormat & DECIMAL);
00278
00279
00280     canvas.DPtoLP(&pt);
00281     pt.x -= size.cx/2;
00282     pt.y -= size.cy/2;
00283 #ifdef UNICODE
00284     pt.x -= size.cx; // accommodate wider popup
00285 #endif
00286
00287     GetClientRect(hwnd, &rc);
00288
00289   // show it
00290     _pBox->Paint(canvas, pt, rc);
00291
00292   //--- dead code....
00293     size = _pBox->GetSize();
00294
00295   POINT ptSize;
00296   ptSize.x = size.cx;
00297   ptSize.y = size.cy;
00298   canvas.LPtoDP(&ptSize);
00299   pt.x+=ptSize.x;
00300   pt.y+=ptSize.y;
00301 }
00302
00303 void CController::ButtonUp(HWND hwnd, LPARAM lParam )
00304 {
00305     ReleaseCapture();
00306 }
00307
00308 void CController::KeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
00309 {
00310     switch( wParam )
00311     {
00312     case VK_PRIOR:
00313          Page(hwnd, IDM_PREVPAGE);
00314          break;
00315     case VK_NEXT:
00316          Page(hwnd, IDM_NEXTPAGE);
00317          break;
00318     case VK_HOME:
00319          Page(hwnd, IDM_FIRSTPAGE);
00320          break;
00321     case VK_END:
00322          Page(hwnd, IDM_LASTPAGE);
00323          break;
00324     case VK_UP:
00325          _pView->SetVScrollPos(hwnd, SB_LINEUP, lParam, _pModel);
00326          break;
00327     case VK_DOWN:
00328          _pView->SetVScrollPos(hwnd, SB_LINEDOWN, lParam, _pModel);
00329          break;
00330     case VK_LEFT:
00331          _pView->SetHScrollPos(hwnd, SB_LINEUP, lParam, _pModel);
00332          break;
00333     case VK_RIGHT:
00334          _pView->SetHScrollPos(hwnd, SB_LINEDOWN, lParam, _pModel);
00335          break;
00336     }
00337 }
00338
00339 void CController::KeyUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
00340 {
00341 }
00342
00343 void CController::HScroll(HWND hwnd, WPARAM wParam, LPARAM lParam)
00344 {
00345   if (_pBox)
00346   {
00347     // Remove box by simulating second mouse click
00348     ButtonDown(hwnd, 0);
00349     UpdateWindow(hwnd);
00350   }
00351     _pView->SetHScrollPos(hwnd, wParam, lParam, _pModel);
00352 }
00353
00354 void CController::VScroll(HWND hwnd, WPARAM wParam, LPARAM lParam)
00355 {
00356   if (_pBox)
00357   {
00358     // Remove box by simulating second mouse click
00359     ButtonDown(hwnd, 0);
00360     UpdateWindow(hwnd);
00361   }
00362     _pView->SetVScrollPos(hwnd, wParam, lParam, _pModel);
00363 }
00364
00365 // Main application
00366
00367 // WinMain - Main window funtion
00368 //
00369 int WINAPI WinMain
00370    ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow )
00371 {
00372     TCHAR  szAppName [] = TEXT("Grid") ;
00373     TCHAR  szCaption [] = TEXT("Character Grid") ;
00374
00375     // Create Window Class
00376
00377     if ( hPrevInst == 0 )
00378     {
00379         MakeWindowClass ( WndProc, szAppName, hInst );
00380     }
00381
00382     // Create Window
00383
00384     CWindow win ( szCaption, szAppName, hInst );
00385
00386     win.Show ( cmdShow );
00387
00388     MSG  msg;
00389
00390     while ( GetMessage (&msg, NULL, 0, 0 ) )
00391     {
00392         TranslateMessage ( &msg );
00393         DispatchMessage ( &msg );
00394     }
00395
00396     return (int)msg.wParam;
00397 }
00398
00399 // Make Window Class
00400 //
00401 void MakeWindowClass ( WNDPROC WndProc, LPTSTR szAppName, HINSTANCE hInst )
00402 {
00403     WNDCLASS cl;
00404
00405     cl.style = CS_HREDRAW | CS_VREDRAW;
00406     cl.lpfnWndProc = WndProc;
00407     cl.cbClsExtra = 0;
00408     cl.cbWndExtra = 0;
00409     cl.hInstance = hInst;
00410     cl.hIcon = LoadIcon ( hInst, szAppName );
00411     cl.hCursor = LoadCursor ( NULL, IDC_ARROW );
00412     cl.hbrBackground = GetStockBrush ( WHITE_BRUSH );
00413     cl.lpszMenuName = szAppName;
00414     cl.lpszClassName = szAppName;
00415
00416     RegisterClass (&cl);
00417 }
00418
00419 // Window Proc
00420 //
00421
00422 LRESULT CALLBACK WndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
00423 {
00424     static CController ctrl;
00425
00426     switch (message)
00427     {
00428         case WM_CREATE:
00429             ctrl.Create(hwnd, lParam);
00430             return 0;
00431         case WM_SIZE:
00432             ctrl.Size(lParam);
00433             return 0;
00434         case WM_PAINT:
00435             ctrl.Paint(hwnd);
00436             return 0;
00437         case WM_COMMAND:
00438             ctrl.Command(hwnd, wParam);
00439             return 0;
00440         case WM_LBUTTONUP:
00441             ctrl.ButtonUp(hwnd, lParam);
00442             return 0;
00443         case WM_LBUTTONDOWN:
00444             ctrl.ButtonDown(hwnd, lParam);
00445             return 0;
00446         case WM_KEYUP:
00447             ctrl.KeyUp(hwnd, wParam, lParam);
00448             return 0;
00449         case WM_KEYDOWN:
00450             ctrl.KeyDown(hwnd, wParam, lParam);
00451             return 0;
00452         case WM_VSCROLL:
00453             ctrl.VScroll(hwnd, wParam, lParam );
00454             return 0;
00455         case WM_HSCROLL:
00456             ctrl.HScroll(hwnd, wParam, lParam );
00457             return 0;
00458         case WM_DESTROY:
00459             ctrl.Destroy();
00460             return 0;
00461
00462     }
00463     return DefWindowProc (hwnd, message, wParam, lParam );
00464 }
00465
00466 // "About" dialog box procedure
00467 // Process messages from dialog box
00468 //
00469
00470 BOOL CALLBACK AboutDlgProc
00471    ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
00472 {
00473
00474     switch(message)
00475     {
00476        case WM_INITDIALOG:
00477             return TRUE;
00478        case WM_COMMAND:
00479             switch (wParam) //Command ID
00480             {
00481                case IDOK:
00482                case IDCANCEL:
00483                     EndDialog(hwnd, 0);
00484                     return TRUE;
00485             }
00486             break;
00487     }
00488     return FALSE;
00489 }
00490
00491 extern CPrintAux PrGlobal;
00492
00493 //======== PrintDlgProc ===========================================
00494
00495 BOOL CALLBACK PrintDlgProc
00496    ( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam )
00497 {
00498     switch (message)
00499     {
00500         case WM_INITDIALOG:
00501              SetWindowText (hwndDlg, (TCHAR *)lParam) ;
00502              EnableMenuItem (GetSystemMenu (hwndDlg, FALSE), SC_CLOSE, MF_GRAYED) ;
00503              return TRUE ;
00504
00505         case WM_COMMAND:
00506              PrGlobal._bUserAbort = TRUE ;
00507              EnableWindow (GetParent (hwndDlg), TRUE) ;
00508              DestroyWindow (hwndDlg) ;
00509              PrGlobal._hDlgPrint = 0 ;
00510              return TRUE ;
00511     }
00512     return FALSE ;
00513 }
00514
00515 //======== AbortProc ===========================================
00516
00517 BOOL CALLBACK AbortProc(HDC hdcPrn, short nCode)
00518 {
00519     MSG   msg ;
00520
00521     while (!PrGlobal._bUserAbort && PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
00522     {
00523         if (!PrGlobal._hDlgPrint
00524                 ||
00525             !IsDialogMessage (PrGlobal._hDlgPrint, &msg))
00526         {
00527             TranslateMessage (&msg) ;
00528             DispatchMessage (&msg) ;
00529         }
00530     }
00531     return !PrGlobal._bUserAbort ;
00532 }
00533
00534
00535 //======== PropDlgProc ===========================================
00536 struct t_Ctype
00537 {
00538   WORD  fVal[3];
00539   LPTSTR  pszName;
00540 } vCtype [] =  {
00541          0x0001,0,0, TEXT("UPPER "),  // A
00542          0x0002,0,0, TEXT("LOWER "),  //a
00543          0x0004,0,0, TEXT("DIGIT "),  //1
00544          0x0008,0,0, TEXT("SPACE "),  //_
00545          0x0010,0,0, TEXT("PUNCT "),  //!
00546          0x0020,0,0, TEXT("CNTRL "),
00547          0x0040,0,0, TEXT("BLANK "),
00548          0x0080,0,0, TEXT("XDIGIT "), //x
00549          0x0100,0,0, TEXT("ALPHA "),  //alpha
00550
00551          0, 0x0001,0, TEXT("LEFTTORIGHT "), //>
00552          0, 0x0002,0, TEXT("RIGHTTOLEFT "), //<
00553          0, 0x0003,0, TEXT("EUROPENUMBER "),
00554          0, 0x0004,0, TEXT("EUROPESEPARATOR "),
00555          0, 0x0005,0, TEXT("EUROPETERMINATOR "),
00556          0, 0x0006,0, TEXT("ARABICNUMBER "),
00557          0, 0x0007,0, TEXT("COMMONSEPARATOR "),
00558          0, 0x0008,0, TEXT("BLOCKSEPARATOR "),
00559          0, 0x0009,0, TEXT("SEGMENTSEPARATOR "),
00560          0, 0x000a,0, TEXT("WHITESPACE "),  // _
00561          0, 0x000b,0, TEXT("OTHERNEUTRAL "),  //<>
00562
00563          0,0,0x0001, TEXT("NONSPACING "),
00564          0,0,0x0002, TEXT("DIACRITIC "),  //  "
00565          0,0,0x0004, TEXT("VOWELMARK "),
00566          0,0,0x0008, TEXT("SYMBOL "),  //   =
00567          0,0,0x0010, TEXT("KATAKANA "),  //   katakana a
00568          0,0,0x0020, TEXT("HIRAGANA "),  //   hiragana a
00569          0,0,0x0040, TEXT("HALFWIDTH "),  //  han
00570          0,0,0x0080, TEXT("FULLWIDTH "),  //  zen
00571          0,0,0x0100, TEXT("IDEOGRAPH "),  //  kan
00572          0,0,0x0200, TEXT("KASHIDA "),
00573          0,0,0x0400, TEXT("LEXICAL "),
00574          0,0,0x8000, TEXT("C3ALPHA ") //  alpha
00575 };
00576
00577
00578 BOOL CALLBACK PropDlgProc
00579    ( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam )
00580 {
00581   INT_PTR i;
00582     switch (message)
00583     {
00584        case WM_INITDIALOG:
00585         for( i=0; i<sizeof vCtype/sizeof t_Ctype; i++)
00586       {
00587           SendDlgItemMessage(hwndDlg, IDC_PROPLIST, LB_ADDSTRING, i, (LPARAM) vCtype[i].pszName);
00588       }
00589             return TRUE;
00590        case WM_COMMAND:
00591             switch (wParam) //Command ID
00592             {
00593                case IDOK:
00594             if( pCSet )
00595             {
00596             delete pCSet;
00597           }
00598             i = SendDlgItemMessage(hwndDlg, IDC_PROPLIST, LB_GETCARETINDEX, 0, 0);
00599             pCSet = new CCTypeSet(vCtype[i].fVal[0],vCtype[i].fVal[1], vCtype[i].fVal[2]);
00600                     EndDialog(hwndDlg, 0);
00601           return TRUE;
00602                case IDCANCEL:
00603             if( pCSet )
00604           {
00605             delete pCSet;
00606           }
00607                     EndDialog(hwndDlg, 0);
00608                     return TRUE;
00609             }
00610             break;
00611     }
00612     return FALSE ;
00613 }
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/guids.h Source File

  • SysMgmt
  • MMC
  • Simple

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {1BA53C00-232F-11d2-9007-00C04F98BC0B}
00020 DEFINE_GUID(CLSID_CComponentData,
00021             0x1ba53c00, 0x232f, 0x11d2, 0x90, 0x7, 0x0, 0xc0, 0x4f, 0x98, 0xbc, 0xb);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Dialogs.h Source File

  • Multimedia
  • Gdi
  • WinCap32

Dialogs.h

Go to the documentation of this file.
00001 #define IDC_SELECTTEXT              101
00002 #define IDC_ENTIRESCREEN            311
00003 #define IDC_PARTIALSCREEN           312
00004 #define IDC_CLIENTAREAONLY          302
00005 #define IDC_ENTIREWINDOW            301
00006 #define IDC_CAPTIONBARONLY          303
00007 #define IDC_MENUBARONLY             304
00008 #define IDC_SINGLEWINDOW            310
00009 #define IDC_STATUSBAR               103
00010 #define IDC_OPTIONSBUTTON           110
00011 #define IDC_ICONAREA                102
00012 #define IDC_VERSION                 111
00013 #define IDC_COPYRIGHT               114
00014 #define IDC_PRINTER                 115
00015 #define IDC_FILE                    116
00016 #define IDC_BESTFIT                 119
00017 #define IDC_STRETCHTOPAGE           120
00018 #define IDC_SCALE                   121
00019 #define IDC_XAXIS                   122
00020 #define IDC_YAXIS                   201
00021 #define IDC_DIRECTORIES             204
00022 #define IDC_EDITFILE                502
00023 #define IDC_GROUPBOX1               117
00024 #define IDC_BOX2                    118
00025 #define IDC_BOX1                    123
00026 #define IDC_BOX3                    124
00027 #define IDC_FILETEXT                104
00028 #define IDC_SELECTPRINTER           105
00029 #define IDC_BOX4                    109
00030 #define IDC_DIVIDINGLINE            106
00031 #define IDC_PRINTTEXT1              401
00032 #define IDC_PRINTTEXT2              402
00033 #define IDC_PERCENTAGE              403
00034 #define IDC_TITLE                   125
00035 #define IDC_TITLE2                  128
00036 #define IDC_TITLE1                  129
00037 #define IDC_ABOUT                   107
00038 #define IDC_YTEXT                   202
00039 #define IDC_XTEXT                   200
00040 #define IDC_FOLD                    108
00041 #define DLGOPEN_EDIT                610
00042 #define DLGOPEN_FILE_LISTBOX        620
00043 #define DLGOPEN_DIR_LISTBOX         630
00044 #define DLGOPEN_PATH                640
00045 #define DLGOPEN_TEXT                650
00046 #define DLGOPEN_FOLDOUT             660
00047 #define DLGOPEN_BIG                 670
00048 #define DLGOPEN_SMALL               680
00049
00050 #define IDC_BITMAP1                 126
00051 #define IDC_BITMAP2                 131
00052 #define IDC_TEXT1                   525
00053 #define OPENING                     100
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/compdata.Cpp Source File

  • SysMgmt
  • MMC
  • CMenu

compdata.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "CompData.h"
00021 #include "DataObj.h"
00022 #include "resource.h"
00023 #include <crtdbg.h>
00024
00025 CComponentData::CComponentData()
00026 : m_cref(0), m_ipConsoleNameSpace(NULL), m_ipConsole(NULL)
00027 {
00028     OBJECT_CREATED
00029
00030     m_pStaticNode = new CStaticNode;
00031
00032     TCHAR tmpHelpFile[MAX_PATH];
00033
00034     GetWindowsDirectory(tmpHelpFile, (sizeof tmpHelpFile)/(sizeof tmpHelpFile[0]));
00035     _tcscat(tmpHelpFile, _T("\\HELP\\"));
00036     LoadString(g_hinst, IDS_HELPFILE, &tmpHelpFile[_tcslen(tmpHelpFile)], MAX_PATH - _tcslen(tmpHelpFile));
00037
00038     MAKE_WIDEPTR_FROMTSTR(wszHelpFile, tmpHelpFile);
00039     wcscpy(m_HelpFile, wszHelpFile);
00040 }
00041
00042 CComponentData::~CComponentData()
00043 {
00044     if (m_pStaticNode) {
00045         delete m_pStaticNode;
00046     }
00047
00048     OBJECT_DESTROYED
00049 }
00050
00051 ///////////////////////
00052 // IUnknown implementation
00053 ///////////////////////
00054
00055 STDMETHODIMP CComponentData::QueryInterface(REFIID riid, LPVOID *ppv)
00056 {
00057     if (!ppv)
00058         return E_FAIL;
00059
00060     *ppv = NULL;
00061
00062     if (IsEqualIID(riid, IID_IUnknown))
00063         *ppv = static_cast<IComponentData *>(this);
00064     else if (IsEqualIID(riid, IID_IComponentData))
00065         *ppv = static_cast<IComponentData *>(this);
00066     else if (IsEqualIID(riid, IID_IExtendContextMenu))
00067         *ppv = static_cast<IExtendContextMenu *>(this);
00068     else if (IsEqualIID(riid, IID_ISnapinHelp))
00069         *ppv = static_cast<ISnapinHelp*>(this);
00070
00071     if (*ppv)
00072     {
00073         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00074         return S_OK;
00075     }
00076
00077     return E_NOINTERFACE;
00078 }
00079
00080 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00081 {
00082     return InterlockedIncrement((LONG *)&m_cref);
00083 }
00084
00085 STDMETHODIMP_(ULONG) CComponentData::Release()
00086 {
00087     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00088     {
00089         // we need to decrement our object count in the DLL
00090         delete this;
00091         return 0;
00092     }
00093
00094     return m_cref;
00095 }
00096
00097 ///////////////////////////////
00098 // Interface IComponentData
00099 ///////////////////////////////
00100 HRESULT CComponentData::Initialize(
00101                                    /* [in] */ LPUNKNOWN pUnknown)
00102 {
00103     HRESULT      hr;
00104
00105     //
00106     // Get pointer to name space interface
00107     //
00108     hr = pUnknown->QueryInterface(IID_IConsoleNameSpace, (void **)&m_ipConsoleNameSpace);
00109     _ASSERT( S_OK == hr );
00110
00111     //
00112     // Get pointer to console interface
00113     //
00114     hr = pUnknown->QueryInterface(IID_IConsole, (void **)&m_ipConsole);
00115     _ASSERT( S_OK == hr );
00116
00117     IImageList *pImageList;
00118     m_ipConsole->QueryScopeImageList(&pImageList);
00119     _ASSERT( S_OK == hr );
00120
00121     hr = pImageList->ImageListSetStrip( (long *)m_pStaticNode->m_pBMapSm, // pointer to a handle
00122         (long *)m_pStaticNode->m_pBMapLg, // pointer to a handle
00123         0, // index of the first image in the strip
00124         RGB(0, 128, 128)  // color of the icon mask
00125         );
00126
00127     pImageList->Release();
00128
00129
00130     return S_OK;
00131 }
00132
00133 HRESULT CComponentData::CreateComponent(
00134                                         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent)
00135 {
00136     *ppComponent = NULL;
00137
00138     CComponent *pComponent = new CComponent(this);
00139
00140     if (NULL == pComponent)
00141         return E_OUTOFMEMORY;
00142
00143     return pComponent->QueryInterface(IID_IComponent, (void **)ppComponent);
00144 }
00145
00146 HRESULT CComponentData::Notify(
00147                                /* [in] */ LPDATAOBJECT lpDataObject,
00148                                /* [in] */ MMC_NOTIFY_TYPE event,
00149                                /* [in] */ LPARAM arg,
00150                                /* [in] */ LPARAM param)
00151 {
00152     MMCN_Crack(TRUE, lpDataObject, this, NULL, event, arg, param);
00153
00154     HRESULT hr = S_FALSE;
00155
00156   //Get our data object. If it is NULL, we return with S_FALSE.
00157   //See implementation of GetOurDataObject() to see how to
00158   //handle special data objects.
00159   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00160   if (NULL == pDataObject)
00161     return S_FALSE;
00162
00163   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00164
00165     switch (event)
00166     {
00167     case MMCN_EXPAND:
00168         hr = base->OnExpand(m_ipConsoleNameSpace, m_ipConsole, (HSCOPEITEM)param);
00169         break;
00170     }
00171
00172     return hr;
00173 }
00174
00175 HRESULT CComponentData::Destroy( void)
00176 {
00177     // Free interfaces
00178     if (m_ipConsoleNameSpace) {
00179         m_ipConsoleNameSpace->Release();
00180         m_ipConsoleNameSpace = NULL;
00181     }
00182
00183     if (m_ipConsole) {
00184         m_ipConsole->Release();
00185         m_ipConsole = NULL;
00186     }
00187
00188     return S_OK;
00189 }
00190
00191 HRESULT CComponentData::QueryDataObject(
00192                                         /* [in] */ MMC_COOKIE cookie,
00193                                         /* [in] */ DATA_OBJECT_TYPES type,
00194                                         /* [out] */ LPDATAOBJECT *ppDataObject)
00195 {
00196     CDataObject *pObj = NULL;
00197
00198     if (cookie == 0)
00199         pObj = new CDataObject((MMC_COOKIE)m_pStaticNode, type);
00200     else
00201         pObj = new CDataObject(cookie, type);
00202
00203     if (!pObj)
00204         return E_OUTOFMEMORY;
00205
00206     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00207
00208     return S_OK;
00209 }
00210
00211 HRESULT CComponentData::GetDisplayInfo(
00212                                        /* [out][in] */ SCOPEDATAITEM *pScopeDataItem)
00213 {
00214     HRESULT hr = S_FALSE;
00215
00216     // if they are asking for the SDI_STR we have one of those to give
00217     if (pScopeDataItem->lParam) {
00218         CDelegationBase *base = (CDelegationBase *)pScopeDataItem->lParam;
00219         if (pScopeDataItem->mask & SDI_STR) {
00220             LPCTSTR pszT = base->GetDisplayName();
00221             MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00222             pScopeDataItem->displayname = pszW;
00223         }
00224
00225         if (pScopeDataItem->mask & SDI_IMAGE) {
00226             pScopeDataItem->nImage = base->GetBitmapIndex();
00227         }
00228     }
00229
00230     return hr;
00231 }
00232
00233 HRESULT CComponentData::CompareObjects(
00234                                        /* [in] */ LPDATAOBJECT lpDataObjectA,
00235                                        /* [in] */ LPDATAOBJECT lpDataObjectB)
00236 {
00237     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00238     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00239
00240     // compare the object pointers
00241     if (baseA->GetCookie() == baseB->GetCookie())
00242         return S_OK;
00243
00244     return S_FALSE;
00245 }
00246
00247 ///////////////////////////////
00248 // Interface ISnapinHelp
00249 ///////////////////////////////
00250 HRESULT CComponentData::GetHelpTopic(
00251                                      /* [out] */ LPOLESTR *lpCompiledHelpFile)
00252 {
00253     *lpCompiledHelpFile = static_cast<LPOLESTR>(CoTaskMemAlloc((wcslen(m_HelpFile) + 1) * sizeof(WCHAR)));
00254
00255     wcscpy(*lpCompiledHelpFile, m_HelpFile);
00256
00257     return S_OK;
00258 }
00259
00260 ///////////////////////////////
00261 // Interface IExtendContextMenu
00262 ///////////////////////////////
00263 HRESULT CComponentData::AddMenuItems(
00264                                      /* [in] */ LPDATAOBJECT piDataObject,
00265                                      /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
00266                                      /* [out][in] */ long __RPC_FAR *pInsertionAllowed)
00267 {
00268     CDelegationBase *base = GetOurDataObject(piDataObject)->GetBaseNodeObject();
00269
00270     return base->OnAddMenuItems(piCallback, pInsertionAllowed);
00271 }
00272
00273 HRESULT CComponentData::Command(
00274                                 /* [in] */ long lCommandID,
00275                                 /* [in] */ LPDATAOBJECT piDataObject)
00276 {
00277     CDelegationBase *base = GetOurDataObject(piDataObject)->GetBaseNodeObject();
00278
00279     return base->OnMenuCommand(m_ipConsole, lCommandID);
00280 }
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Hello2J Member List

This is the complete list of members for Hello2J, including all inherited members.
destroy() | Hello2J | [inline]
FALSE | Hello2J | [private]
getAppletInfo() | Hello2J | [inline]
Hello2J() | Hello2J | [inline]
init() | Hello2J | [inline]
m_AgentEx | Hello2J | [private]
m_bUsingDefaultCharacter | Hello2J | [private]
m_Character | Hello2J | [private]
m_CharacterID | Hello2J | [private]
m_CharacterPathOld | Hello2J | [private]
m_CommandID | Hello2J | [private]
m_Commands | Hello2J | [private]
m_RequestID | Hello2J | [private]
m_Sink | Hello2J | [private]
m_SinkID | Hello2J | [private]
paint(Graphics g) | Hello2J | [inline]
start() | Hello2J | [inline]
stop() | Hello2J | [inline]
TRUE | Hello2J | [private]
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagArFonts Member List

This is the complete list of members for tagArFonts, including all inherited members.
cySpace | tagArFonts
hdc | tagArFonts
lf | tagArFonts
nFonts | tagArFonts
tm | tagArFonts
Type | tagArFonts
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/globals.h Source File

  • SysMgmt
  • MMC
  • About

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025   #define IDM_BUTTON1    0x100
00026   #define IDM_BUTTON2    0x101
00027
00028   extern HINSTANCE g_hinst;
00029   extern ULONG g_uObjects;
00030
00031   #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032   #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034   // uncomment the following #define to enable message cracking
00035   // #define MMC_CRACK_MESSAGES
00036   void MMCN_Crack(BOOL bComponentData,
00037           IDataObject *pDataObject,
00038           IComponentData *pCompData,
00039           IComponent *pComp,
00040           MMC_NOTIFY_TYPE event,
00041           LPARAM arg,
00042           LPARAM param);
00043 #endif
00044
00045 //=--------------------------------------------------------------------------=
00046 // allocates a temporary buffer that will disappear when it goes out of scope
00047 // NOTE: be careful of that -- make sure you use the string in the same or
00048 // nested scope in which you created this buffer. people should not use this
00049 // class directly.  use the macro(s) below.
00050 //
00051 class TempBuffer {
00052   public:
00053     TempBuffer(ULONG cBytes) {
00054         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00055         m_fHeapAlloc = (cBytes > 120);
00056     }
00057     ~TempBuffer() {
00058         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00059     }
00060     void *GetBuffer() {
00061         return m_pBuf;
00062     }
00063
00064   private:
00065     void *m_pBuf;
00066     // we'll use this temp buffer for small cases.
00067     //
00068     char  m_szTmpBuf[120];
00069     unsigned m_fHeapAlloc:1;
00070 };
00071
00072 //=--------------------------------------------------------------------------=
00073 // string helpers.
00074 //
00075 // given a _TCHAR, copy it into a wide buffer.
00076 // be careful about scoping when using this macro!
00077 //
00078 // how to use the below two macros:
00079 //
00080 //  ...
00081 //  LPTSTR pszT;
00082 //  pszT = MyGetTStringRoutine();
00083 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00084 //  MyUseWideStringRoutine(pwsz);
00085 //  ...
00086 #ifdef UNICODE
00087 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00088     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00089     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00090     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00091     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00092 #else // ANSI
00093 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00094     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00095     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00096     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00097     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00098     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00099 #endif
00100
00101 #ifdef UNICODE
00102 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00103     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00104     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00105     lstrcpyW((LPWSTR)ptrname, tstr)
00106 #else // ANSI
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00109     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00110     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00111     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00112 #endif
00113
00114 //
00115 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00116 // have to be declared, and no clean up must be done.
00117 //
00118 // * 2 for DBCS handling in below length computation
00119 //
00120 #ifdef UNICODE
00121 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00122     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00123     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00124     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00125     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00126 #else // ANSI
00127 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00128     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00129     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00130     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00131     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00132 #endif
00133
00134 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAlterColumnDlg Member List

This is the complete list of members for CAlterColumnDlg, including all inherited members.
AlterColumn(HWND hWndParent) | CAlterColumnDlg |
CAlterColumnDlg(CMDIChild *pCMDIChild) | CAlterColumnDlg |
CDialogLite(UINT uIDD=0) | CDialogLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CRowsetViewerDlg(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRowsetViewerDlg |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetOptions() | CRowsetViewerDlg | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_ColDesc | CAlterColumnDlg |
m_comboDBType | CAlterColumnDlg | [private]
m_comboTypeName | CAlterColumnDlg | [private]
m_CPropSets | CAlterColumnDlg |
m_dwColFlags | CAlterColumnDlg |
m_editColumnName | CAlterColumnDlg | [private]
m_editNewColumnName | CAlterColumnDlg | [private]
m_editPrecision | CAlterColumnDlg | [private]
m_editScale | CAlterColumnDlg | [private]
m_editSize | CAlterColumnDlg | [private]
m_editTableName | CAlterColumnDlg | [private]
m_fModal | CDialogLite |
m_fUseColProps | CAlterColumnDlg |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_listColumnDescFlags | CAlterColumnDlg | [private]
m_nID | CWndLite |
m_pCMainWindow | CRowsetViewerDlg |
m_pCMDIChild | CRowsetViewerDlg |
m_pColumnID | CAlterColumnDlg |
m_pSubClassProc | CWndLite |
m_pTableID | CAlterColumnDlg |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnCancel() | CDialogLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CAlterColumnDlg | [virtual]
CDialogLite::OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CAlterColumnDlg | [virtual]
CDialogLite::OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CAlterColumnDlg | [virtual]
CDialogLite::OnInitDialog() | CDialogLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CAlterColumnDlg | [virtual]
CDialogLite::OnOK() | CDialogLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSelChange(INT iID, HWND hWndCtrl) | CAlterColumnDlg | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CAlterColumnDlg() | CAlterColumnDlg | [virtual]
~CDialogLite() | CDialogLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:55:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/DoServer.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

DoServer.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          DOServer.cpp
00021
00022   Description:   General function implementation.
00023
00024 **************************************************************************/
00025
00026 /**************************************************************************
00027 #include statements
00028 **************************************************************************/
00029
00030 #include "DOServer.h"
00031 #include "ClsFact.h"
00032 #include <windowsx.h>
00033 #include <CommDlg.h>
00034
00035 #include <initguid.h>
00036
00037 // {F0FD0C00-65BA-11d0-B66F-00A0C90348D6}
00038 DEFINE_GUID(   CLSID_SimpleDocObject,
00039       0xf0fd0c00,
00040       0x65ba,
00041       0x11d0,
00042       0xb6,
00043       0x6f,
00044       0x0,
00045       0xa0,
00046       0xc9,
00047       0x3,
00048       0x48,
00049       0xd6);
00050
00051       /**************************************************************************
00052       private function prototypes
00053 **************************************************************************/
00054
00055 BOOL InitApp(BOOL, int);
00056 void CenterWindow(HWND);
00057
00058 /**************************************************************************
00059 global variables
00060 **************************************************************************/
00061
00062 HINSTANCE      g_hInst;
00063 DWORD          g_DllRefCount;
00064 DWORD          g_dwRegister;
00065
00066 /**************************************************************************
00067
00068   WinMain
00069
00070 **************************************************************************/
00071
00072 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
00073 {
00074   UNREFERENCED_PARAMETER(hPrevInstance);
00075   BOOL  fEmbedding;
00076   MSG   msg;
00077
00078   g_hInst = hInstance;
00079
00080   //check for the embedding switch
00081   ParseCommandLine(lpCmdLine, &fEmbedding, NULL);
00082
00083   if(!fEmbedding)
00084   {
00085     DialogBox(g_hInst, MAKEINTRESOURCE(IDD_MAIN_DIALOG), NULL, (DLGPROC)MainDlgProc);
00086     return 0;
00087   }
00088
00089   if(!InitApp(fEmbedding, nCmdShow))
00090     return 0;
00091
00092   //DebugBreak();
00093
00094   //The message loop will only exit when the main object gets destroyed.
00095   while(GetMessage(&msg, NULL, 0, 0))
00096   {
00097     TranslateMessage(&msg);
00098     DispatchMessage(&msg);
00099   }
00100
00101   OutputDebugString(TEXT("Exiting WinMain\n"));
00102
00103   if(g_dwRegister)
00104     CoRevokeClassObject(g_dwRegister);
00105
00106   CoUninitialize();
00107
00108   return (INT)msg.wParam;
00109 }
00110
00111 /**************************************************************************
00112
00113   InitApp()
00114
00115 **************************************************************************/
00116
00117 BOOL InitApp(BOOL fEmbedding, int nCmdShow)
00118 {
00119   UNREFERENCED_PARAMETER(fEmbedding);
00120   UNREFERENCED_PARAMETER(nCmdShow);
00121   //initialize OLE
00122   if(FAILED(CoInitialize(NULL)))
00123     return FALSE;
00124
00125   CClassFactory  *pClassFactory = new CClassFactory();
00126
00127   if(NULL == pClassFactory)
00128   {
00129     CoUninitialize();
00130     return FALSE;
00131   }
00132
00133   LPUNKNOWN   pUnknown;
00134   HRESULT     hr;
00135
00136   hr = pClassFactory->QueryInterface(IID_IUnknown, (LPVOID*)&pUnknown);
00137   if(FAILED(hr))
00138   {
00139     pClassFactory->Release();
00140     return FALSE;
00141   }
00142
00143   //register the class object
00144   hr = CoRegisterClassObject(   CLSID_SimpleDocObject,
00145     pUnknown,
00146     CLSCTX_LOCAL_SERVER,
00147     REGCLS_MULTIPLEUSE,
00148     &g_dwRegister);
00149
00150   if(FAILED(hr))
00151   {
00152     pClassFactory->Release();
00153     return FALSE;
00154   }
00155
00156   return TRUE;
00157 }
00158
00159 /**************************************************************************
00160
00161   MainDlgProc()
00162
00163 **************************************************************************/
00164
00165 BOOL CALLBACK MainDlgProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
00166 {
00167   UNREFERENCED_PARAMETER(lParam);
00168   static COleDocument  *pOleDoc;
00169
00170   switch(uMessage)
00171   {
00172   case WM_INITDIALOG:
00173     CenterWindow(hWnd);
00174
00175     pOleDoc = new COleDocument();
00176
00177     if(pOleDoc)
00178     {
00179       EnableWindow(GetDlgItem(hWnd, IDC_REGISTER), TRUE);
00180       EnableWindow(GetDlgItem(hWnd, IDC_CREATE_FILE), TRUE);
00181     }
00182
00183     break;
00184
00185   case WM_DESTROY:
00186     if(pOleDoc)
00187     {
00188       delete pOleDoc;
00189     }
00190
00191     break;
00192
00193   case WM_COMMAND:
00194     switch(GET_WM_COMMAND_ID(wParam, lParam))
00195     {
00196     case IDOK:
00197     case IDCANCEL:
00198             EndDialog(hWnd, 0);
00199             break;
00200
00201     case IDC_REGISTER:
00202             if(pOleDoc)
00203       {
00204         pOleDoc->RegisterServer();
00205       }
00206             break;
00207
00208     case IDC_CREATE_FILE:
00209             if(pOleDoc)
00210       {
00211         pOleDoc->CreateFile(hWnd);
00212       }
00213             break;
00214     }
00215     return FALSE;
00216   }
00217
00218   return FALSE;
00219 }
00220
00221
00222 /**************************************************************************
00223
00224   ColorHookProc()
00225
00226 **************************************************************************/
00227
00228 BOOL CALLBACK ColorHookProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
00229 {
00230   UNREFERENCED_PARAMETER(lParam);
00231   UNREFERENCED_PARAMETER(wParam);
00232   static COleDocument  *pOleDoc;
00233   static UINT          uSaveOK;
00234
00235   switch(uMessage)
00236   {
00237   case WM_INITDIALOG:
00238     {
00239       UINT  uSelect;
00240
00241       pOleDoc = (COleDocument*)((LPOPENFILENAME)(lParam))->lCustData;
00242
00243       uSaveOK = RegisterWindowMessage(FILEOKSTRING);
00244
00245       switch(pOleDoc->m_Color)
00246       {
00247       default:
00248       case RED_COLOR:
00249         uSelect = IDC_RED;
00250         break;
00251
00252       case GREEN_COLOR:
00253         uSelect = IDC_GREEN;
00254         break;
00255
00256       case BLUE_COLOR:
00257         uSelect = IDC_BLUE;
00258         break;
00259       }
00260
00261       CheckRadioButton(hWnd, IDC_RED, IDC_BLUE, uSelect);
00262     }
00263     break;
00264
00265   case WM_DESTROY:
00266     break;
00267
00268   default:
00269     if(uMessage == uSaveOK)
00270     {
00271       //Save button pressed
00272       if(IsDlgButtonChecked(hWnd, IDC_GREEN))
00273             {
00274         pOleDoc->m_Color = GREEN_COLOR;
00275             }
00276       else if(IsDlgButtonChecked(hWnd, IDC_BLUE))
00277             {
00278         pOleDoc->m_Color = BLUE_COLOR;
00279             }
00280       else
00281             {
00282         pOleDoc->m_Color = RED_COLOR;
00283             }
00284     }
00285
00286     break;
00287   }
00288
00289   return FALSE;
00290 }
00291
00292 /*****************************************************************************
00293
00294   CenterWindow
00295
00296 *****************************************************************************/
00297
00298 void CenterWindow(HWND hWnd)
00299 {
00300   RECT  rc;
00301   int   x,
00302     y;
00303
00304   GetWindowRect(hWnd, &rc);
00305
00306   x = GetSystemMetrics(SM_CXSCREEN)/2 - ((rc.right - rc.left)/2);
00307   y = GetSystemMetrics(SM_CYSCREEN)/2 - ((rc.bottom - rc.top)/2);
00308
00309   //don't move the window if it's already in the right position
00310   if((x != rc.left) || (y != rc.top))
00311     MoveWindow(hWnd, x, y, rc.right - rc.left, rc.bottom - rc.top, TRUE);
00312 }
00313
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/GUIText.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

GUIText.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUITEXT.CPP
00003
00004   Summary:   Implementation file for the CGuiText C++ class. A GuiText is
00005              a C++ object that encapsulates the human interface for
00006              editing the text of a persistent text object.
00007
00008              CGuiText is anchored to the Windows GUI (Graphical User
00009              Interface) environment--it retains knowledge of window
00010              handles and device contexts on the local machine. This
00011              GuiText object relies on a persistent Text object for storage
00012              of the text data. This text object (a COTextPage object) is
00013              instantiated as a COM object in a separate thread-safe
00014              In-process server, PERTEXT.
00015
00016              For a comprehensive tutorial code tour of GUITEXT's contents
00017              and offerings see the tutorial PERCLIEN.HTM file. For more
00018              specific technical details on the internal workings see the
00019              comments dispersed throughout the GUITEXT source code.
00020
00021   Classes:   CGuiText.
00022
00023   Origin:    5-20-97: atrent - Editor inheritance from GUIPAPER.CPP in the
00024              STOCLIEN source.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 /*--------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will be calling the COM/OLE Libraries.
00044   We include OLECTL.H because it has definitions for connectable objects.
00045   We include APPUTIL.H because we will be building this application using
00046     the convenient Virtual Window and Dialog classes and other
00047     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00048   We include IPAGES.H and PAGEGUID.H for the common page-related Interface
00049     class, GUID, and CLSID specifications.
00050   We include RESDEF.H because it has the resource definitions specific
00051     to this application.
00052   We include TEXTWIN.H because CGuiText creates and uses a CTextWin to
00053     encapsulate a multiline edit control/window.
00054   We include GUITEXT.H because it has the C++ class used for GUI display
00055     of the edited text.
00056   We include TEXTSINK.H because it has the C++ class used for the sink that
00057     receives event notifications from the COTextPage object in the server.
00058 ---------------------------------------------------------------------------*/
00059 #include <windows.h>
00060 #include <ole2.h>
00061 #include <olectl.h>
00062 #include <apputil.h>
00063 #include <ipages.h>
00064 #include <pageguid.h>
00065 #include "resdef.h"
00066 #include "textwin.h"
00067 #include "guitext.h"
00068 #include "textsink.h"
00069
00070
00071 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00072   Method:   CGuiText::CGuiText
00073
00074   Summary:  Constructor.
00075
00076   Args:     void
00077
00078   Returns:  void
00079 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00080 CGuiText::CGuiText(HINSTANCE hInst, HWND hWndApp, INT iPage)
00081 {
00082   m_hInst           = hInst;
00083   m_hWndApp         = hWndApp;
00084   m_hWnd            = NULL;
00085   m_iPage           = iPage;
00086   m_wszDataName[0]  = 0;
00087   m_pTextWin        = NULL;
00088   m_pIStorage_Root  = NULL;
00089   m_pITextPage      = NULL;
00090   m_pCOTextPageSink = NULL;
00091   m_dwTextPageSink  = 0;
00092   m_bChanged        = FALSE;
00093
00094   // Save the ClassID of TextPages using overloaded '=' operator.
00095   m_CidTextPage = CLSID_TextPage;
00096 }
00097
00098
00099 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00100   Method:   CGuiText::~CGuiText
00101
00102   Summary:  Destructor.
00103
00104   Args:     void
00105
00106   Returns:  void
00107 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00108 CGuiText::~CGuiText(void)
00109 {
00110   // CGuiText is derived from CVirWindow which traps the WM_DESTROY
00111   // message and causes a delete of CGuiText which in turn causes this
00112   // destructor to run. The WM_DESTROY results when the window is destoyed
00113   // after a close of the window.
00114
00115   // Disconnect the Sink in the client from the connection points in
00116   // the server.
00117   DisconnectSink();
00118
00119   // Release the interface held on the TextPageSink object.
00120   RELEASE_INTERFACE(m_pCOTextPageSink);
00121
00122   // Destroy the existing COTextPage by releasing the ITextPage interface.
00123   RELEASE_INTERFACE(m_pITextPage);
00124
00125   // Release the interface held on the root storage.
00126   RELEASE_INTERFACE(m_pIStorage_Root);
00127
00128   // Delete the CTextWin object (edit control window).
00129   DELETE_POINTER(m_pTextWin);
00130
00131   // Tell main app that this text page is gone.
00132   PostMessage(m_hWndApp, WM_USER_PAGECLOSED, 0, m_iPage);
00133 }
00134
00135
00136 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00137   Method:   CGuiText::Clear
00138
00139   Summary:  Internal private method to clear (erase) the text content of
00140             both the current text edit window as well as the COTextPage
00141             server.
00142
00143   Args:     void.
00144
00145   Returns:  HRESULT
00146               Standard result code. NOERROR for success.
00147 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00148 HRESULT CGuiText::Clear(
00149           void)
00150 {
00151   HRESULT hr = E_FAIL;
00152
00153   if (NULL != m_pTextWin && NULL != m_pITextPage)
00154   {
00155     m_pTextWin->Clear();
00156     m_pITextPage->Clear(TRUE);
00157     m_bChanged = TRUE;
00158     // Tell main app if this page was changed.
00159     PostMessage(m_hWndApp, WM_USER_PAGECHANGED, 0, m_iPage);
00160     hr = NOERROR;
00161   }
00162
00163   return hr;
00164 }
00165
00166
00167 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00168   Method:   CGuiText::Load
00169
00170   Summary:  Load TextPage data from the current storage Stream.
00171
00172   Args:     void.
00173
00174   Returns:  HRESULT
00175               Standard result code. NOERROR for success.
00176 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00177 HRESULT CGuiText::Load(void)
00178 {
00179   HRESULT hr = E_FAIL;
00180   IStream* pIStream;
00181   IPersistStreamInit* pIPersistStreamInit;
00182
00183   // Can't do anything without a root storage.
00184   if (NULL != m_pIStorage_Root)
00185   {
00186     // Use the root IStorage to open the existing stream for
00187     // this particular Text Page. Load the data for the text page from
00188     // the stream. This load internally uses the IPersistStreamInit
00189     // features in a COTextPage object that is created and reconstituted
00190     // from persistent storage.
00191
00192     // Open the single stream named by m_wszDataName. It is under
00193     // the root storage.
00194     hr = m_pIStorage_Root->OpenStream(
00195            m_wszDataName,
00196            0,
00197            STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00198            0,
00199            &pIStream);
00200     if (SUCCEEDED(hr))
00201     {
00202       // Read the ClassID for the class of Component Objects that can deal
00203       // with Text Page data.
00204       hr = ReadClassStm(pIStream, &m_CidTextPage);
00205       if (SUCCEEDED(hr))
00206       {
00207         // Now use the obtained Class ID to create a COTextPage
00208         // object. Initially ask for the ITextPage interface.
00209         hr = CoCreateInstance(
00210                m_CidTextPage,
00211                NULL,
00212                CLSCTX_INPROC_SERVER,
00213                IID_ITextPage,
00214                (PPVOID)&m_pITextPage);
00215         if (SUCCEEDED(hr))
00216         {
00217           // We have a new COTextPage object. Now obtain the
00218           // IPersistStreamInit interface on it. At this point in the
00219           // client we are assuming that COTextPage uses only the
00220           // IPersistStreamInit interface for its persistence.
00221           hr = m_pITextPage->QueryInterface(
00222                  IID_IPersistStreamInit,
00223                  (PPVOID)&pIPersistStreamInit);
00224           if (SUCCEEDED(hr))
00225           {
00226             // And as expected by this client, COTextPage exposes
00227             // the IPersistStreamInit interface. Now use this interface
00228             // to ask the COTextPage object to load the Text Page data.
00229             hr = pIPersistStreamInit->Load(pIStream);
00230
00231             // Done with IPersistStreamInit for now so release it.
00232             pIPersistStreamInit->Release();
00233           }
00234         }
00235       }
00236       // Done with the interface held on the stream.
00237       pIStream->Release();
00238     }
00239     else
00240     {
00241       // If there was no existing Stream then create a new one.
00242       hr = m_pIStorage_Root->CreateStream(
00243              m_wszDataName,
00244              STGM_CREATE | STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00245              0,
00246              0,
00247              &pIStream);
00248       if (SUCCEEDED(hr))
00249       {
00250         // Write the ClassID of the COTextPage component object class.
00251         hr = WriteClassStm(pIStream, m_CidTextPage);
00252         if (SUCCEEDED(hr))
00253         {
00254           // Now use the Class ID to create a COTextPage
00255           // object. Initially ask for the ITextPage interface.
00256           hr = CoCreateInstance(
00257                  m_CidTextPage,
00258                  NULL,
00259                  CLSCTX_INPROC_SERVER,
00260                  IID_ITextPage,
00261                  (PPVOID)&m_pITextPage);
00262           if (SUCCEEDED(hr))
00263           {
00264             // We have a new COTextPage object. Now obtain the
00265             // IPersistStreamInit interface on it. At this point in the
00266             // client we are assuming that COTextPage uses only the
00267             // IPersistStreamInit interface for its persistence.
00268             hr = m_pITextPage->QueryInterface(
00269                    IID_IPersistStreamInit,
00270                    (PPVOID)&pIPersistStreamInit);
00271             if (SUCCEEDED(hr))
00272             {
00273               // And as expected by this client, COTextPage supports
00274               // the IPersistStreamInit interface. Now use this interface
00275               // to ask the COTextPage object to initialize a new empty
00276               // text page. Then save it into the stream.
00277               hr = pIPersistStreamInit->InitNew();
00278               if (SUCCEEDED(hr))
00279                 hr = pIPersistStreamInit->Save(pIStream, TRUE);
00280
00281               // Done with IPersistStreamInit for now so release it.
00282               pIPersistStreamInit->Release();
00283             }
00284           }
00285         }
00286
00287         // Done with the interface held on the stream.
00288         pIStream->Release();
00289
00290         if (FAILED(hr))
00291           m_pIStorage_Root->DestroyElement(m_wszDataName);
00292       }
00293     }
00294   }
00295
00296   return hr;
00297 }
00298
00299
00300 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00301   Method:   CGuiText::OpenWin
00302
00303   Summary:  Get CGuiText started. Make any subordinate objects, like
00304             COTextPage and CTextWin and get them started. Create the
00305             window. Read the page's text data from the specified stream
00306             and put it in the edit control.
00307
00308   Args:     IStorage* pIStorage_Root,
00309               Root storage of the compound file containing the text page.
00310             WCHAR* pwszPageTitle,
00311               The user-displayable title for the text page. Generally
00312               used in the window's title bar.
00313             WCHAR* pwszDataName)
00314               The internal storage name of the stream holding the
00315               text page.
00316
00317   Returns:  HRESULT
00318               Standard result code. NOERROR for success.
00319 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00320 HRESULT CGuiText::OpenWin(
00321           IStorage* pIStorage_Root,
00322           WCHAR* pwszPageTitle,
00323           WCHAR* pwszDataName)
00324 {
00325   HRESULT hr = E_FAIL;
00326   HWND hWnd = NULL;
00327   COTextPageSink* pCobSink = NULL;
00328   HCURSOR hCurPrev;
00329   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00330   TCHAR szTitle[32+PAGE_TITLE_SIZE];
00331   INT iTextLength;
00332   WCHAR* pwszText;
00333
00334   if (m_hInst && m_hWndApp && pwszDataName)
00335   {
00336     // Change cursor to the hour glass. This open could take awhile.
00337     hCurPrev = SetCursor(hCurWait);
00338
00339     // Set title string empty to start.
00340     szTitle[0] = 0;
00341
00342     lstrcpy(szTitle, TEXT(TEXT_WINDOW_NAME_STR));
00343 #if defined(UNICODE)
00344     if (NULL != pwszPageTitle)
00345       lstrncat(szTitle, pwszPageTitle, sizeof(szTitle)/sizeof(TCHAR) -
00346         lstrlen(szTitle));
00347     lstrcpyn(m_wszDataName, pwszDataName, sizeof(m_wszDataName)/
00348       sizeof(TCHAR));
00349 #else
00350     {
00351       CHAR szAnsi[PAGE_TITLE_SIZE];
00352
00353       // Convert PageTitle from Unicode to Ansi.
00354       if (NULL != pwszPageTitle)
00355       {
00356         UcToAnsi(pwszPageTitle, szAnsi, PAGE_TITLE_SIZE);
00357         lstrncat(szTitle, szAnsi, sizeof(szTitle)/sizeof(TCHAR) -
00358           lstrlen(szTitle));
00359       }
00360       // Copy/save DataName.
00361       memcpy(m_wszDataName, pwszDataName, PAGE_NAME_SIZE*sizeof(WCHAR));
00362     }
00363 #endif
00364     // Create the main GuiText Window. Size the window reasonably. The
00365     // Create method sets both m_hInst and m_hWnd.
00366     hWnd = Create(
00367              TEXT(TEXT_WINDOW_CLASS_NAME_STR),
00368              szTitle,
00369              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00370                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00371              CW_USEDEFAULT,
00372              CW_USEDEFAULT,
00373              ::GetSystemMetrics(SM_CXSCREEN)*1/3,
00374              ::GetSystemMetrics(SM_CYSCREEN)*1/3,
00375              m_hWndApp,
00376              NULL,
00377              m_hInst);
00378     if (NULL != hWnd)
00379     {
00380       // Create the CTextWin object so we can edit/show text data
00381       // in the text window using a standard text edit control.
00382       m_pTextWin = new CTextWin;
00383       if (NULL != m_pTextWin)
00384       {
00385         // Init the CTextWin. This creates the subordinate edit control
00386         // window and fits it into the client area of the main edit window.
00387         hr = m_pTextWin->Init(m_hInst, m_hWnd, &m_hWndEdit);
00388         if (SUCCEEDED(hr))
00389         {
00390           // Save an interface pointer to the root IStorage
00391           // and AddRef it.
00392           m_pIStorage_Root = pIStorage_Root;
00393           pIStorage_Root->AddRef();
00394
00395           // Now load the text edit control from the named stream in the
00396           // root storage. This either opens and loads the existing
00397           // stream or creates a new one.
00398           hr = Load();
00399           if (SUCCEEDED(hr))
00400           {
00401             // We loaded or created the Text Page stream and have a
00402             // COTextPage component to manage the text data.
00403
00404             // Create the COTextPageSink object to receive TextPage events.
00405             pCobSink = new COTextPageSink(NULL, this);
00406             if (NULL != pCobSink)
00407             {
00408               // Save a pointer to the COTextPageSink IUnknown interface.
00409               // AddRef because of this saved copy. Released in destructor.
00410               m_pCOTextPageSink = pCobSink;
00411               m_pCOTextPageSink->AddRef();
00412
00413               // Ask the COTextPage for the text data and pass it on to
00414               // the Edit control managed by CTextWin.
00415
00416               // First ask for the size (in WCHARs) of the text data.
00417               hr = m_pITextPage->GetLength(&iTextLength);
00418               if (SUCCEEDED(hr))
00419               {
00420                 // Allocate some temporary space for the text.
00421                 pwszText = new WCHAR[iTextLength+4];
00422                 if (NULL != pwszText)
00423                 {
00424                   // Zero the text string.
00425                   memset(pwszText, 0, (iTextLength+2) * sizeof(WCHAR));
00426
00427                   // Get the text from the COTextPage object.
00428                   hr = m_pITextPage->GetText(pwszText);
00429                   if (SUCCEEDED(hr))
00430                   {
00431                     // Put the text into the edit control.
00432                     hr = m_pTextWin->PutText(pwszText, iTextLength);
00433                     if (SUCCEEDED(hr))
00434                     {
00435                       // Ensure the new window is shown on screen.
00436                       ::ShowWindow(m_hWnd, SW_SHOWNORMAL);
00437                       ::UpdateWindow(m_hWnd);
00438                     }
00439                   }
00440                   // Delete the temporary string buffer.
00441                   delete [] pwszText;
00442                 }
00443                 else
00444                   hr = E_OUTOFMEMORY;
00445               }
00446             }
00447             else
00448               hr = E_OUTOFMEMORY;
00449           }
00450         }
00451       }
00452       else
00453         hr = E_OUTOFMEMORY;
00454
00455       if (SUCCEEDED(hr))
00456       {
00457         // If we created and reconstituted a COTextPage object from
00458         // persistent stream storage then connect the sinks in the client
00459         // to the connection sources in the server.
00460         hr = ConnectSink();
00461       }
00462       else
00463       {
00464         HrMsgId(m_hInst, m_hWnd, IDS_OPENTEXTPAGE, hr);
00465         PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00466       }
00467     }
00468
00469     // Set Cursor from hourglass back to what it was.
00470     SetCursor(hCurPrev);
00471   }
00472
00473   return (hr);
00474 }
00475
00476
00477 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00478   Method:   CGuiText::TopWin
00479
00480   Summary:  Brings the CGuiText window to the top of the z-order of the
00481             the windows.
00482
00483   Args:     void.
00484
00485   Returns:  HRESULT
00486               Standard result code. NOERROR for success.
00487 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00488 HRESULT CGuiText::TopWin(
00489           void)
00490 {
00491   HRESULT hr = E_FAIL;
00492
00493   if (IsWindow(m_hWnd))
00494   {
00495     BringWindowToTop(m_hWnd);
00496     hr = NOERROR;
00497   }
00498
00499   return hr;
00500 }
00501
00502
00503 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00504   Method:   CGuiText::ResizeWin
00505
00506   Summary:  Resize the current CGuiText window. Pass this resize on to the
00507             text edit control child window.
00508
00509   Args:     WORD wWidth,
00510               New window width in pixels.
00511             WORD wHeight)
00512               New window height in pixels.
00513
00514   Returns:  HRESULT
00515               Standard result code. NOERROR for success.
00516 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00517 HRESULT CGuiText::ResizeWin(
00518           WORD wWidth,
00519           WORD wHeight)
00520 {
00521   HRESULT hr;
00522
00523   // Tell Text Edit window  about new size.
00524   hr = m_pTextWin->Resize(wWidth, wHeight);
00525
00526   return hr;
00527 }
00528
00529
00530 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00531   Method:   CGuiText::Renumber
00532
00533   Summary:  Re-assign the current dynamic page number for this page.
00534
00535   Args:     INT iPage
00536               New page number.
00537
00538   Returns:  HRESULT
00539               Standard result code. NOERROR for success.
00540 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00541 HRESULT CGuiText::Renumber(
00542           INT iPage)
00543 {
00544   HRESULT hr = NOERROR;
00545
00546   m_iPage = iPage;
00547
00548   return hr;
00549 }
00550
00551
00552 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00553   Method:   CGuiText::ReleasePage
00554
00555   Summary:  Release the root storage held by the Text page.
00556
00557   Args:     none.
00558
00559   Returns:  HRESULT
00560               Standard result code. NOERROR for success.
00561 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00562 HRESULT CGuiText::ReleasePage(
00563           void)
00564 {
00565   HRESULT hr = E_FAIL;
00566
00567   // Release the interface held on the root storage by CGuiText.
00568   RELEASE_INTERFACE(m_pIStorage_Root);
00569
00570   return hr;
00571 }
00572
00573
00574 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00575   Method:   CGuiText::RestorePage
00576
00577   Summary:  Restores the root storage interface for a new file.
00578
00579   Args:     IStorage* pIStorage_Root
00580               New storage for the Text page.
00581
00582   Returns:  HRESULT
00583               Standard result code. NOERROR for success.
00584 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00585 HRESULT CGuiText::RestorePage(
00586           IStorage* pIStorage_Root)
00587 {
00588   HRESULT hr = E_POINTER;
00589
00590   if (NULL != pIStorage_Root)
00591   {
00592     // Save the new interface pointer to the root IStorage
00593     // and AddRef it.
00594     m_pIStorage_Root = pIStorage_Root;
00595     m_pIStorage_Root->AddRef();
00596     hr = NOERROR;
00597   }
00598
00599   return hr;
00600 }
00601
00602
00603 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00604   Method:   CGuiText::Save
00605
00606   Summary:  Uses COTextPage's IPersistStreamInit interface to save the
00607             text data in the text page's stream.
00608
00609   Args:     void.
00610
00611   Returns:  HRESULT
00612               Standard result code. NOERROR for success.
00613 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00614 HRESULT CGuiText::Save(void)
00615 {
00616   HRESULT hr = E_FAIL;
00617   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00618   HCURSOR hCurPrev;
00619   INT iTextLength;
00620   WCHAR* pwszText;
00621   LARGE_INTEGER liSeek;
00622   IStream* pIStream;
00623   IPersistStreamInit* pIPersistStreamInit;
00624
00625   if (NULL != m_pIStorage_Root && NULL != m_pITextPage)
00626   {
00627     // Change cursor to the hour glass.
00628     hCurPrev = SetCursor(hCurWait);
00629
00630     // Open the single stream named by m_wszDataName. It is under
00631     // the root storage.
00632     hr = m_pIStorage_Root->OpenStream(
00633            m_wszDataName,
00634            0,
00635            STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00636            0,
00637            &pIStream);
00638     if (SUCCEEDED(hr))
00639     {
00640       // First ask the edit control how long its text data is.
00641       hr = m_pTextWin->GetLength(&iTextLength);
00642       if (SUCCEEDED(hr))
00643       {
00644         // Allocate some temporary space for the text.
00645         pwszText = new WCHAR[iTextLength+4];
00646         if (NULL != pwszText)
00647         {
00648           // Zero the text string.
00649           memset(pwszText, 0, (iTextLength+2) * sizeof(WCHAR));
00650
00651           // Get the text from the the edit control.
00652           hr = m_pTextWin->GetText(pwszText);
00653           if (SUCCEEDED(hr))
00654           {
00655             // Put the text into the COTextPage object.
00656             hr = m_pITextPage->PutText(pwszText, iTextLength);
00657             if (SUCCEEDED(hr))
00658             {
00659               // Clear the TextWin changed flag.
00660               m_bChanged = FALSE;
00661
00662               // Tell the COTextPage object to save itself
00663               // (via its IPersistStreamInit interface).
00664               hr = m_pITextPage->QueryInterface(
00665                      IID_IPersistStreamInit,
00666                      (PPVOID)&pIPersistStreamInit);
00667               if (SUCCEEDED(hr))
00668               {
00669                 // Recue Stream to start of page text data.
00670                 LISet32(liSeek, sizeof(CLSID));
00671                 hr = pIStream->Seek(liSeek, STREAM_SEEK_SET, NULL);
00672                 if (SUCCEEDED(hr))
00673                   hr = pIPersistStreamInit->Save(pIStream, TRUE);
00674
00675                 // Done with IPersistStreamInit for now so release it.
00676                 pIPersistStreamInit->Release();
00677               }
00678             }
00679           }
00680           // Delete the temporary text buffer.
00681           delete [] pwszText;
00682         }
00683         else
00684           hr = E_OUTOFMEMORY;
00685       }
00686       // Done with the interface held on the stream.
00687       pIStream->Release();
00688     }
00689
00690     // Set Cursor back to what it was.
00691     SetCursor(hCurPrev);
00692   }
00693
00694   return hr;
00695 }
00696
00697
00698 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00699   Method:   CGuiText::AskSave
00700
00701   Summary:  Check if user edited any changes in the edit window. Also
00702             checks dirty flag (ie, if current TextPage data was modified
00703             and is out of sync with the TextPage data stored in the
00704             compound file). If changed or dirty, then ask user in simple
00705             dialog if he wants to save new data. If he says yes, then save
00706             the current TextPage data into the current compound file.
00707
00708   Args:     void.
00709
00710   Returns:  HRESULT
00711               Standard result code. NOERROR for success.
00712 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00713 int CGuiText::AskSave(void)
00714 {
00715   int iAns = IDNO;
00716   HRESULT hr;
00717   TCHAR szTitle[MAX_STRING_LENGTH];
00718   TCHAR szAsk[MAX_STRING_LENGTH];
00719   TCHAR szMsg[MAX_PATH + MAX_STRING_LENGTH];
00720   IPersistStreamInit* pIPersistStreamInit;
00721
00722   hr = m_pITextPage->QueryInterface(
00723            IID_IPersistStreamInit,
00724            (PPVOID)&pIPersistStreamInit);
00725   if (SUCCEEDED(hr))
00726   {
00727     // If changed or if the TextPage object is dirty.
00728     if (m_bChanged || S_FALSE != pIPersistStreamInit->IsDirty())
00729     {
00730       // The current data was changed; ask user if he wants to save it.
00731       if (LoadString(m_hInst, IDS_TEXT_PAGE, szTitle, MAX_STRING_LENGTH)
00732           && LoadString(m_hInst, IDS_ASK_SAVE, szAsk, MAX_STRING_LENGTH))
00733       {
00734         lstrcpyn(szMsg, szTitle, sizeof(szMsg)/sizeof(TCHAR));
00735         lstrncat(szMsg, szAsk, sizeof(szMsg)/sizeof(TCHAR) - lstrlen(szMsg));
00736         // Display AskSaveDlg to user. Ask if he wants to save.
00737         iAns = MessageBox(
00738                  m_hWnd,
00739                  szMsg,
00740                  szTitle,
00741                  MB_YESNOCANCEL | MB_ICONEXCLAMATION);
00742         switch (iAns)
00743         {
00744           case IDYES:
00745             // Tell CGuiText to save itself to the current text page stream.
00746             Save();
00747             break;
00748           case IDNO:
00749             // User clicked No. So don't save; abandon changes.
00750             break;
00751           case IDCANCEL:
00752           default:
00753             break;
00754         }
00755       }
00756     }
00757
00758     // Done with IPersistStreamInit for now so release it.
00759     pIPersistStreamInit->Release();
00760   }
00761
00762   return iAns;
00763 }
00764
00765
00766 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00767   Method:   CGuiText::Close
00768
00769   Summary:  Close this page.
00770
00771   Args:     void.
00772
00773   Returns:  HRESULT
00774               Standard result code. NOERROR for success.
00775 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00776 HRESULT CGuiText::Close(
00777           void)
00778 {
00779   HRESULT hr = NOERROR;
00780
00781   // Close the GuiText window. This will cause a delete of this CGuiText.
00782   ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00783
00784   return hr;
00785 }
00786
00787
00788 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00789   Method:   CGuiText::Delete
00790
00791   Summary:  Delete the stored Text Page. Shuts down the text page and edit
00792             windows. Disconnects the Sink and does final release of the
00793             COTextPage object.
00794
00795   Args:     void.
00796
00797   Returns:  HRESULT
00798               Standard result code. NOERROR for success.
00799 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00800 HRESULT CGuiText::Delete(void)
00801 {
00802   HRESULT hr = E_FAIL;
00803   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00804   HCURSOR hCurPrev;
00805
00806   // Change cursor to the hour glass.
00807   hCurPrev = SetCursor(hCurWait);
00808
00809   // Clear the text page.
00810   if (NULL != m_pTextWin && NULL != m_pITextPage)
00811   {
00812     m_pTextWin->Clear();
00813     m_pITextPage->Clear(FALSE);
00814     m_bChanged = FALSE;
00815   }
00816
00817   // Destroy the entire text page's stream.
00818   hr = m_pIStorage_Root->DestroyElement(m_wszDataName);
00819
00820   // Set Cursor back to what it was.
00821   SetCursor(hCurPrev);
00822
00823   return hr;
00824 }
00825
00826
00827 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00828   Method:   CGuiText::GetConnectionPoint
00829
00830   Summary:  Internal private method to obtain a connection point interface.
00831
00832   Args:     REFIID riid
00833               IID of the requested connection point Interface.
00834
00835   Returns:  IConnectionPoint*
00836               Requested IConnectionPoint interface pointer. NULL if none.
00837 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00838 IConnectionPoint* CGuiText::GetConnectionPoint(
00839                     REFIID riid)
00840 {
00841   IConnectionPoint* pConnPoint = NULL;
00842   IConnectionPointContainer* pConnPointContainer = NULL;
00843   IConnectionPoint* pConnPt;
00844   HRESULT hr;
00845
00846   // First query the object for its Connection Point Container. This
00847   // essentially asks the object in the server if it is connectable.
00848   hr = m_pITextPage->QueryInterface(
00849          IID_IConnectionPointContainer,
00850          (PPVOID)&pConnPointContainer);
00851   if SUCCEEDED(hr)
00852   {
00853     // Find the requested Connection Point. This AddRef's the
00854     // returned pointer.
00855     hr = pConnPointContainer->FindConnectionPoint(riid, &pConnPt);
00856     if (SUCCEEDED(hr))
00857       pConnPoint = pConnPt;
00858
00859     RELEASE_INTERFACE(pConnPointContainer);
00860   }
00861
00862   return pConnPoint;
00863 }
00864
00865
00866 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00867   Method:   CGuiText::ConnectSink
00868
00869   Summary:  Connect the TextPageSink to the server COTextPage event
00870             source.
00871
00872   Args:     void
00873
00874   Returns:  HRESULT
00875               Standard result code. NOERROR for success.
00876 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00877 HRESULT CGuiText::ConnectSink(void)
00878 {
00879   HRESULT hr = E_FAIL;
00880   DWORD dwKey;
00881   IConnectionPoint* pConnPoint;
00882
00883   if (!m_dwTextPageSink)
00884   {
00885     // Get the Text Page Sink connection point in the server.
00886     pConnPoint = GetConnectionPoint(IID_ITextPageSink);
00887     if (NULL != pConnPoint)
00888     {
00889       // Connect the server's object to the Text Page Sink in this client.
00890       hr = pConnPoint->Advise(m_pCOTextPageSink, &dwKey);
00891       if (SUCCEEDED(hr))
00892         m_dwTextPageSink = dwKey;
00893
00894       RELEASE_INTERFACE(pConnPoint);
00895     }
00896   }
00897
00898   return hr;
00899 }
00900
00901
00902 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00903   Method:   CGuiText::DisconnectSink
00904
00905   Summary:  Disconnect the Text Page from the server COTextPage event
00906             source.
00907
00908   Args:     void.
00909
00910   Returns:  HRESULT
00911               Standard result code. NOERROR for success.
00912 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00913 HRESULT CGuiText::DisconnectSink(void)
00914 {
00915   HRESULT hr = E_FAIL;
00916   IConnectionPoint* pConnPoint;
00917
00918   if (m_dwTextPageSink)
00919   {
00920     // Get the TextPage Sink connection point.
00921     pConnPoint = GetConnectionPoint(IID_ITextPageSink);
00922     if (NULL != pConnPoint)
00923     {
00924       // Disconnect the object in the server from the Text Page Sink in
00925       // this client.
00926       hr = pConnPoint->Unadvise(m_dwTextPageSink);
00927       if (SUCCEEDED(hr))
00928         m_dwTextPageSink = 0;
00929
00930       RELEASE_INTERFACE(pConnPoint);
00931     }
00932   }
00933
00934   return hr;
00935 }
00936
00937
00938 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00939   Method:   CGuiText::InitEditMenu
00940
00941   Summary:  Init the Parent Window's Edit menu for edit operations.
00942
00943   Args:     HMENU hEditMenu)
00944               Handle of the Edit Menu of the parent window.
00945
00946   Returns:  HRESULT
00947               Standard result code. NOERROR for success.
00948 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00949 HRESULT CGuiText::InitEditMenu(
00950           HMENU hEditMenu)
00951 {
00952   HRESULT hr = E_FAIL;
00953   INT iSelect, iEnable;
00954
00955   if (IsWindow(m_hWnd))
00956   {
00957     // Enable/Disable the Undo choice.
00958     EnableMenuItem(
00959       hEditMenu,
00960       IDM_EDIT_UNDO,
00961       SendMessage(m_hWndEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
00962
00963     // Enable/Disable the Paste choice.
00964     EnableMenuItem(
00965       hEditMenu,
00966       IDM_EDIT_PASTE,
00967       IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED);
00968
00969     // Enable/Disable the Cut, Copy, Delete choices.
00970     iSelect = SendMessage(m_hWndEdit, EM_GETSEL, 0, 0);
00971     iEnable = (HIWORD(iSelect) == LOWORD(iSelect)) ? MF_GRAYED : MF_ENABLED;
00972     EnableMenuItem(hEditMenu, IDM_EDIT_CUT, iEnable);
00973     EnableMenuItem(hEditMenu, IDM_EDIT_COPY, iEnable);
00974     EnableMenuItem(hEditMenu, IDM_EDIT_DELETE, iEnable);
00975
00976     hr = NOERROR;
00977   }
00978
00979   return hr;
00980 }
00981
00982
00983 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00984   Method:   CGuiText::DoCommand
00985
00986   Summary:  Dispatch and handle the main menu and other commands.
00987
00988   Args:     WPARAM wParam,
00989               First message parameter.
00990             LPARAM lParam)
00991               Second message parameter.
00992
00993   Returns:  LRESULT
00994               Standard Windows WindowProc return value.
00995 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00996 LRESULT CGuiText::DoCommand(
00997           WPARAM wParam,
00998           LPARAM lParam)
00999 {
01000   LRESULT lResult = FALSE;
01001   HMENU hMenu  = ::GetMenu(m_hWnd);
01002
01003   switch (LOWORD(wParam))
01004   {
01005     //----------------------------------------------------------------------
01006     // Handle Text Menu Commands.
01007     //----------------------------------------------------------------------
01008     case IDM_TEXT_SAVE:
01009       Save();
01010       break;
01011     case IDM_TEXT_CLEAR:
01012       Clear();
01013       break;
01014     case IDM_TEXT_EXIT:
01015       // The user commands us to exit this page so we tell the
01016       // window to close itself.
01017       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
01018       break;
01019
01020     //----------------------------------------------------------------------
01021     // Handle Edit Menu Commands.
01022     //----------------------------------------------------------------------
01023     case IDM_EDIT_UNDO:
01024       m_pTextWin->EditUndo();
01025       break;
01026     case IDM_EDIT_SELECTALL:
01027       m_pTextWin->EditSelectAll();
01028       break;
01029     case IDM_EDIT_CUT:
01030       m_pTextWin->EditCut();
01031       break;
01032     case IDM_EDIT_COPY:
01033       m_pTextWin->EditCopy();
01034       break;
01035     case IDM_EDIT_PASTE:
01036       m_pTextWin->EditPaste();
01037       break;
01038     case IDM_EDIT_DELETE:
01039       m_pTextWin->EditDelete();
01040       break;
01041
01042     //----------------------------------------------------------------------
01043     // Handle Help Menu Commands. Pass these commands on to main app.
01044     //----------------------------------------------------------------------
01045     case IDM_THELP_CONTENTS:
01046       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_CONTENTS, 0);
01047       break;
01048     case IDM_THELP_TUTORIAL:
01049       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_TUTORIAL, 0);
01050       break;
01051     case IDM_THELP_TUTSERVER:
01052       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_PERTEXT, 0);
01053       break;
01054     case IDM_THELP_READSOURCE:
01055       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_READSOURCE, 0);
01056       break;
01057     case IDM_THELP_ABOUT:
01058       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_ABOUT, 0);
01059       break;
01060
01061     //----------------------------------------------------------------------
01062     // Handle TextWin Commands (ie, from the child edit control).
01063     //----------------------------------------------------------------------
01064     case IDC_TEXTWIN:
01065       switch (HIWORD(wParam))
01066       {
01067         case EN_CHANGE:
01068           if (!m_bChanged)
01069           {
01070             m_bChanged = TRUE;
01071             // Tell main app if this page was changed.
01072             PostMessage(m_hWndApp, WM_USER_PAGECHANGED, 0, m_iPage);
01073           }
01074           break;
01075         case EN_MAXTEXT:
01076         case EN_ERRSPACE:
01077           ErrorBox(m_hInst, m_hWnd, IDS_PAGEFULL);
01078           break;
01079         default:
01080           break;
01081       }
01082       break;
01083
01084     default:
01085       // Defer all messages NOT handled here to the Default Window Proc.
01086       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
01087       break;
01088   }
01089
01090   return(lResult);
01091 }
01092
01093
01094 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01095   Method:   CGuiText::WindowProc
01096
01097   Summary:  Main window procedure for this window object.  See CVirWindow
01098             in the APPUTIL library (APPUTIL.CPP) for details on how this
01099             method gets called by the global WindowProc.
01100
01101   Args:     UINT uMsg,
01102               Windows message that is "sent" to this window.
01103             WPARAM wParam,
01104               First message parameter.
01105             LPARAM lParam)
01106               Second message parameter.
01107
01108   Returns:  LRESULT
01109               Standard Windows WindowProc return value.
01110 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01111 LRESULT CGuiText::WindowProc(
01112           UINT uMsg,
01113           WPARAM wParam,
01114           LPARAM lParam)
01115 {
01116   LRESULT lResult = FALSE;
01117
01118   switch (uMsg)
01119   {
01120     case WM_CREATE:
01121       break;
01122
01123     case WM_SIZE:
01124       // Handle a resize of this window.
01125       // Inform CGuiText and CTextWin of the change.
01126       ResizeWin(LOWORD(lParam), HIWORD(lParam));
01127       break;
01128
01129     case WM_INITMENUPOPUP:
01130       // Enable Edit Menu items.
01131       if (LOWORD(lParam) == 1)
01132         InitEditMenu((HMENU) wParam);
01133       break;
01134
01135     case WM_COMMAND:
01136       // Dispatch and handle any Menu and command messages received.
01137       lResult = DoCommand(wParam, lParam);
01138       break;
01139
01140     case WM_CHAR:
01141       if (wParam == 0x1b)
01142       {
01143         // Exit this app if user hits ESC key.
01144         ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
01145       }
01146       break;
01147
01148     case WM_CLOSE:
01149       // The user selected Close on the main window's System menu
01150       // or Exit on the File menu.
01151       // If there is data that has not been saved then ask user
01152       // if it should be saved. If user cancels then cancel the exit.
01153       if (IDCANCEL == AskSave())
01154         break;
01155     case WM_QUIT:
01156       BringWindowToTop(m_hWndApp);
01157       // If the app is being quit then close any associated help windows.
01158       // For later evolution...
01159     default:
01160       // Defer all messages NOT handled above to the Default Window Proc.
01161       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
01162       break;
01163   }
01164
01165   return(lResult);
01166 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Global.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

Global.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       global.hxx
00006 //
00007 //  Contents:   Global defines
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #if !defined( __GLOBAL_HXX__ )
00012 #define __GLOBAL_HXX__
00013
00014 #include <debug.hxx>
00015 #include <except.hxx>
00016
00017 DECLARE_DEBUG(html);
00018
00019 #if DBG == 1
00020
00021 #define htmlDebugOut( x ) htmlInlineDebugOut x
00022
00023 #else  // DBG == 0
00024
00025 #define htmlDebugOut( x )
00026
00027 #endif // DBG
00028
00029 //
00030 // Memory allocator that calls the default allocator and then throws on
00031 // allocation failure
00032 //
00033
00034 enum HtmlNew {
00035     onDefault = 0x1e,   // Just to force a different operator new signature
00036 };
00037
00038 #define newk(Tag, pCounter)     new
00039
00040 #if 0
00041 inline void * __cdecl operator new ( size_t size )
00042 {
00043     void *pMemory = ciNew(size);
00044
00045     if ( pMemory == 0 )
00046         throw( CException( E_OUTOFMEMORY ) );
00047
00048     return pMemory;
00049 }
00050 #endif // 0
00051
00052 #endif   // __GLOBAL_HXX__
00053
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/llistimpl.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

llistimpl.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.h:  Definition and implementation of CLListImpl.  This is a
00013 //                 generic linked list class which emulates CList from MFC.
00014 //
00015
00016
00017 #ifndef __CLASS_CLLISTIMPL__
00018 #define __CLASS_CLLISTIMPL__
00019
00020 #if _MSC_VER > 1000
00021 #pragma once
00022 #endif // _MSC_VER > 1000
00023
00024 #include <CrtDbg.h>
00025 #include <Windows.h>
00026 #include <new.h>
00027
00028
00029 // Abstract iteration position
00030 struct  __POSITION { };
00031 typedef __POSITION*  POSITION;
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 //  CPlex stuff for allocating nodes
00035 //
00036
00037 //---------------------------------------------------------------------------
00038 struct CPlex     // warning variable length structure
00039 {
00040   CPlex* pNext;
00041 //#if (_AFX_PACKING >= 8)
00042   DWORD dwReserved[1];    // align on 8 byte boundary
00043 //#endif
00044
00045   // BYTE data[maxNum*elementSize];
00046
00047   void* data() { return this+1; }
00048
00049   static CPlex* PASCAL Create(CPlex*& head, UINT nMax, UINT cbElement);
00050       // like 'calloc' but no zero fill
00051       // may throw memory exceptions
00052
00053   void FreeDataChain();       // free this one and links
00054 };
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 //  Helpers
00059 //
00060
00061 BOOL IsValidAddress( const void*  lp, UINT nBytes, BOOL bReadWrite = TRUE );
00062
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // CLListImpl<TYPE, ARG_TYPE>
00066
00067 template<class TYPE, class ARG_TYPE>
00068 class CLListImpl
00069 {
00070   public:
00071     CLListImpl( int nBlockSize = 10 );
00072     ~CLListImpl();
00073
00074   protected:
00075     struct CNode
00076     {
00077       CNode* pNext;
00078       CNode* pPrev;
00079       TYPE   data;
00080     };
00081
00082   public:
00083                                          // Attributes (head and tail)
00084    int       GetCount() const;
00085    BOOL      IsEmpty() const;
00086
00087    TYPE&     GetHead();                  // Peek at head and tail
00088    TYPE      GetHead() const;
00089    TYPE&     GetTail();
00090    TYPE      GetTail() const;
00091                                          // Operations
00092    TYPE      RemoveHead();
00093    TYPE      RemoveTail();
00094                                          // Add before head or after tail
00095    POSITION  AddHead( ARG_TYPE NewElement );
00096    POSITION  AddTail( ARG_TYPE NewElement );
00097
00098    void      AddHead(CLListImpl* pNewList);  // Add another list
00099    void      AddTail(CLListImpl* pNewList);
00100
00101    void      RemoveAll();                // Remove all elements
00102
00103    POSITION  GetHeadPosition() const;
00104    POSITION  GetTailPosition() const;
00105    TYPE&     GetNext(POSITION& rPosition);       // return *Position++
00106    TYPE      GetNext(POSITION& rPosition) const; // return *Position++
00107    TYPE&     GetPrev(POSITION& rPosition);       // return *Position--
00108    TYPE      GetPrev(POSITION& rPosition) const; // return *Position--
00109
00110    // Getting/modifying an element at a given position
00111    TYPE&     GetAt(POSITION Position);
00112    TYPE      GetAt(POSITION Position) const;
00113    void      SetAt(POSITION Pos, ARG_TYPE NewElement);
00114    void      RemoveAt(POSITION Position);
00115
00116    // inserting before or after a given position
00117    POSITION InsertBefore(POSITION position, ARG_TYPE newElement);
00118    POSITION InsertAfter(POSITION position, ARG_TYPE newElement);
00119
00120    // Helper functions (note: O(n) speed)
00121
00122    // Defaults to starting at the HEAD, return NULL if not found
00123    POSITION Find(ARG_TYPE SearchValue, POSITION StartAfter = NULL) const;
00124
00125    // Get the 'nIndex'th element (may return NULL)
00126    POSITION FindIndex(int nIndex) const;
00127
00128   // Implementation
00129   protected:
00130     CNode*   m_pNodeHead;
00131     CNode*   m_pNodeTail;
00132     int      m_nCount;
00133     CNode*   m_pNodeFree;
00134     struct   CPlex* m_pBlocks;
00135     int m_nBlockSize;
00136
00137     CNode*   NewNode(CNode*, CNode*);
00138     void     FreeNode(CNode*);
00139
00140 #ifdef _DEBUG
00141
00142   void AssertValid() const;
00143
00144 #endif //_DEBUG
00145
00146 }; //end class CLListImpl
00147
00148 /////////////////////////////////////////////////////////////////////////////
00149 // CLListImpl<TYPE, ARG_TYPE> inline functions
00150
00151 template<class TYPE, class ARG_TYPE>
00152 inline int CLListImpl<TYPE, ARG_TYPE>::GetCount() const
00153   { return m_nCount; }
00154
00155 template<class TYPE, class ARG_TYPE>
00156 inline BOOL CLListImpl<TYPE, ARG_TYPE>::IsEmpty() const
00157   { return m_nCount == 0; }
00158
00159 template<class TYPE, class ARG_TYPE>
00160 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetHead()
00161   {
00162     _ASSERT( NULL != m_pNodeHead );
00163     return m_pNodeHead->data;
00164   }
00165
00166 template<class TYPE, class ARG_TYPE>
00167 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetHead() const
00168   {
00169     _ASSERT( NULL != m_pNodeHead );
00170     return m_pNodeHead->data;
00171   }
00172
00173 template<class TYPE, class ARG_TYPE>
00174 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetTail()
00175   {
00176     _ASSERT( NULL != m_pNodeTail );
00177     return m_pNodeTail->data;
00178   }
00179
00180 template<class TYPE, class ARG_TYPE>
00181 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetTail() const
00182   {
00183     _ASSERT( NULL != m_pNodeTail );
00184     return m_pNodeTail->data;
00185   }
00186
00187 template<class TYPE, class ARG_TYPE>
00188 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetHeadPosition() const
00189   { return (POSITION)m_pNodeHead; }
00190
00191 template<class TYPE, class ARG_TYPE>
00192 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetTailPosition() const
00193   { return (POSITION)m_pNodeTail; }
00194
00195 template<class TYPE, class ARG_TYPE>
00196 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) // return *Position++
00197   {
00198     CNode* pNode = (CNode*) rPosition;
00199     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00200     rPosition = (POSITION) pNode->pNext;
00201     return pNode->data;
00202   }
00203
00204 template<class TYPE, class ARG_TYPE>
00205 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) const // return *Position++
00206   {
00207     CNode* pNode = (CNode*) rPosition;
00208     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00209     rPosition = (POSITION) pNode->pNext;
00210     return pNode->data;
00211   }
00212
00213 template<class TYPE, class ARG_TYPE>
00214 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) // return *Position--
00215   {
00216     CNode* pNode = (CNode*) rPosition;
00217     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00218     rPosition = (POSITION) pNode->pPrev;
00219     return pNode->data;
00220   }
00221
00222 template<class TYPE, class ARG_TYPE>
00223 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) const // return *Position--
00224   {
00225     CNode* pNode = (CNode*) rPosition;
00226     ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00227     rPosition = (POSITION) pNode->pPrev;
00228     return pNode->data;
00229   }
00230
00231 template<class TYPE, class ARG_TYPE>
00232 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position)
00233   {
00234     CNode* pNode = (CNode*)Position;
00235     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00236     return pNode->data;
00237   }
00238
00239 template<class TYPE, class ARG_TYPE>
00240 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position) const
00241   {
00242     CNode* pNode = (CNode*) Position;
00243     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00244     return pNode->data;
00245   }
00246
00247 template<class TYPE, class ARG_TYPE>
00248 inline void CLListImpl<TYPE, ARG_TYPE>::SetAt(POSITION Pos, ARG_TYPE NewElement)
00249   {
00250     CNode* pNode = (CNode*)Pos;
00251     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00252     pNode->data = newElement;
00253   }
00254
00255
00256 template<class TYPE, class ARG_TYPE>
00257 CLListImpl<TYPE, ARG_TYPE>::CLListImpl( int nBlockSize )
00258 {
00259   _ASSERT( nBlockSize > 0 );
00260
00261   m_nCount     = 0;
00262   m_pNodeHead  = m_pNodeTail = m_pNodeFree = NULL;
00263   m_pBlocks    = NULL;
00264   m_nBlockSize = nBlockSize;
00265 }
00266
00267 template<class TYPE, class ARG_TYPE>
00268 void CLListImpl<TYPE, ARG_TYPE>::RemoveAll()
00269 {
00270   // destroy elements
00271   CNode* pNode;
00272   for( pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext )
00273     (pNode->data).~TYPE();
00274
00275   m_nCount = 0;
00276   m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL;
00277   m_pBlocks->FreeDataChain();
00278   m_pBlocks = NULL;
00279 }
00280
00281 template<class TYPE, class ARG_TYPE>
00282 CLListImpl<TYPE, ARG_TYPE>::~CLListImpl()
00283 {
00284   RemoveAll();
00285   _ASSERT(m_nCount == 0);
00286 }
00287
00288
00289 /////////////////////////////////////////////////////////////////////////////
00290 // Node helpers
00291 //
00292 //  Implementation note: CNode's are stored in CPlex blocks and
00293 //  chained together. Free blocks are maintained in a singly linked list
00294 //  using the 'pNext' member of CNode with 'm_pNodeFree' as the head.
00295 //  Used blocks are maintained in a doubly linked list using both 'pNext'
00296 //  and 'pPrev' as links and 'm_pNodeHead' and 'm_pNodeTail'
00297 //  as the head/tail.
00298 //
00299 //  We never free a CPlex block unless the List is destroyed or RemoveAll()
00300 //  is used - so the total number of CPlex blocks may grow large depending
00301 //  on the maximum past size of the list.
00302 //
00303
00304
00305 template<class TYPE, class ARG_TYPE>
00306 CLListImpl<TYPE, ARG_TYPE>::CNode*
00307 CLListImpl<TYPE, ARG_TYPE>::NewNode(CLListImpl::CNode* pPrev, CLListImpl::CNode* pNext)
00308 {
00309   if( NULL == m_pNodeFree )
00310   {
00311     // add another block
00312     CPlex* pNewBlock = CPlex::Create( m_pBlocks, m_nBlockSize, sizeof(CNode) );
00313
00314     // chain them into free list
00315     CNode* pNode = (CNode*) pNewBlock->data();
00316     // free in reverse order to make it easier to debug
00317     pNode += m_nBlockSize - 1;
00318     for( int i = m_nBlockSize-1; i >= 0; i--, pNode-- )
00319     {
00320       pNode->pNext = m_pNodeFree;
00321       m_pNodeFree = pNode;
00322     }
00323   }
00324   _ASSERT( NULL != m_pNodeFree );  // we must have something
00325
00326   CLListImpl::CNode* pNode = m_pNodeFree;
00327   m_pNodeFree = m_pNodeFree->pNext;
00328   pNode->pPrev = pPrev;
00329   pNode->pNext = pNext;
00330   m_nCount++;
00331   _ASSERT(m_nCount > 0);  // make sure we don't overflow
00332
00333   new (&pNode->data) TYPE; // Placement new
00334
00335   return pNode;
00336 }
00337
00338
00339 template<class TYPE, class ARG_TYPE>
00340 void CLListImpl<TYPE, ARG_TYPE>::FreeNode(CLListImpl::CNode* pNode)
00341 {
00342   (pNode->data).~TYPE();
00343   pNode->pNext = m_pNodeFree;
00344   m_pNodeFree = pNode;
00345   m_nCount--;
00346   _ASSERT(m_nCount >= 0);  // make sure we don't underflow
00347
00348   // if no more elements, cleanup completely
00349   if( 0 == m_nCount )
00350     RemoveAll();
00351 }
00352
00353 template<class TYPE, class ARG_TYPE>
00354 POSITION CLListImpl<TYPE, ARG_TYPE>::AddHead( ARG_TYPE NewElement )
00355 {
00356   _ASSERT( NULL != NewElement );
00357
00358   CNode* pNewNode = NewNode( NULL, m_pNodeHead );
00359   pNewNode->data = NewElement;
00360   if( NULL != m_pNodeHead )
00361     m_pNodeHead->pPrev = pNewNode;
00362   else
00363     m_pNodeTail = pNewNode;
00364
00365   m_pNodeHead = pNewNode;
00366   return (POSITION)pNewNode;
00367 }
00368
00369
00370 template<class TYPE, class ARG_TYPE>
00371 POSITION CLListImpl<TYPE, ARG_TYPE>::AddTail(ARG_TYPE NewElement)
00372 {
00373   _ASSERT( NULL != NewElement );
00374
00375   CNode* pNewNode = NewNode( m_pNodeTail, NULL );
00376   pNewNode->data = NewElement;
00377   if( NULL != m_pNodeTail )
00378     m_pNodeTail->pNext = pNewNode;
00379   else
00380     m_pNodeHead = pNewNode;
00381
00382   m_pNodeTail = pNewNode;
00383   return (POSITION)pNewNode;
00384 }
00385
00386
00387 template<class TYPE, class ARG_TYPE>
00388 void CLListImpl<TYPE, ARG_TYPE>::AddHead( CLListImpl* pNewList )
00389 {
00390   _ASSERT( NULL != pNewList );
00391
00392   // Add a list of same elements to head (maintain order)
00393   POSITION Pos = pNewList->GetTailPosition();
00394   while( NULL != Pos )
00395     AddHead(pNewList->GetPrev( Pos ));
00396 }
00397
00398
00399 template<class TYPE, class ARG_TYPE>
00400 void CLListImpl<TYPE, ARG_TYPE>::AddTail(CLListImpl* pNewList)
00401 {
00402   _ASSERT( NULL != pNewList );
00403
00404   // Add a list of same elements
00405   POSITION Pos = pNewList->GetHeadPosition();
00406   while( NULL != Pos )
00407     AddTail(pNewList->GetNext( Pos ));
00408 }
00409
00410
00411 template<class TYPE, class ARG_TYPE>
00412 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveHead()
00413 {
00414   _ASSERT( NULL != m_pNodeHead );  // don't call on empty list !!!
00415   _ASSERT( IsValidAddress( m_pNodeHead, sizeof(CNode)) );
00416
00417   CNode* pOldNode = m_pNodeHead;
00418   TYPE returnValue = pOldNode->data;
00419
00420   m_pNodeHead = pOldNode->pNext;
00421   if( NULL != m_pNodeHead )
00422     m_pNodeHead->pPrev = NULL;
00423   else
00424     m_pNodeTail = NULL;
00425
00426   FreeNode(pOldNode);
00427   return returnValue;
00428 }
00429
00430
00431 template<class TYPE, class ARG_TYPE>
00432 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveTail()
00433 {
00434   _ASSERT( NULL != m_pNodeTail );  // don't call on empty list !!!
00435   _ASSERT( IsValidAddress( m_pNodeTail, sizeof(CNode)) );
00436
00437   CNode* pOldNode = m_pNodeTail;
00438   TYPE returnValue = pOldNode->data;
00439
00440   m_pNodeTail = pOldNode->pPrev;
00441   if( NULL != m_pNodeTail )
00442     m_pNodeTail->pNext = NULL;
00443   else
00444     m_pNodeHead = NULL;
00445
00446   FreeNode(pOldNode);
00447   return returnValue;
00448 }
00449
00450
00451 template<class TYPE, class ARG_TYPE>
00452 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertBefore(POSITION Position, ARG_TYPE NewElement)
00453 {
00454   _ASSERT( NULL != NewElement );
00455
00456   if( NULL == Position )
00457     return AddHead( NewElement ); // insert before nothing -> head of the list
00458
00459   // Insert it before position
00460   CNode* pOldNode = (CNode*)Position;
00461   CNode* pNewNode = NewNode( pOldNode->pPrev, pOldNode );
00462   pNewNode->data  = NewElement;
00463
00464   if( NULL != pOldNode->pPrev )
00465   {
00466     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00467     pOldNode->pPrev->pNext = pNewNode;
00468   }
00469   else
00470   {
00471     _ASSERT( pOldNode == m_pNodeHead );
00472     m_pNodeHead = pNewNode;
00473   }
00474   pOldNode->pPrev = pNewNode;
00475   return (POSITION)pNewNode;
00476 }
00477
00478
00479 template<class TYPE, class ARG_TYPE>
00480 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertAfter(POSITION Position, ARG_TYPE NewElement)
00481 {
00482   ASSERT( NULL != NewElement );
00483
00484   if( NULL == Position )
00485     return AddTail( NewElement ); // insert after nothing -> tail of the list
00486
00487   // Insert it before position
00488   CNode* pOldNode = (CNode*)Position;
00489   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode) ) );
00490   CNode* pNewNode = NewNode( pOldNode, pOldNode->pNext );
00491   pNewNode->data = NewElement;
00492
00493   if( NULL != pOldNode->pNext )
00494   {
00495     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00496     pOldNode->pNext->pPrev = pNewNode;
00497   }
00498   else
00499   {
00500     _ASSERT( pOldNode == m_pNodeTail );
00501     m_pNodeTail = pNewNode;
00502   }
00503   pOldNode->pNext = pNewNode;
00504   return (POSITION)pNewNode;
00505 }
00506
00507
00508 template<class TYPE, class ARG_TYPE>
00509 void CLListImpl<TYPE, ARG_TYPE>::RemoveAt( POSITION Position )
00510 {
00511   _ASSERT( NULL != Position );
00512
00513   CNode* pOldNode = (CNode*)Position;
00514   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode)) );
00515
00516   // Remove pOldNode from list
00517   if( pOldNode == m_pNodeHead )
00518   {
00519     m_pNodeHead = pOldNode->pNext;
00520   }
00521   else
00522   {
00523     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00524     pOldNode->pPrev->pNext = pOldNode->pNext;
00525   }
00526   if( pOldNode == m_pNodeTail )
00527   {
00528     m_pNodeTail = pOldNode->pPrev;
00529   }
00530   else
00531   {
00532     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00533     pOldNode->pNext->pPrev = pOldNode->pPrev;
00534   }
00535   FreeNode( pOldNode );
00536 }
00537
00538
00539 template<class TYPE, class ARG_TYPE>
00540 POSITION CLListImpl<TYPE, ARG_TYPE>::FindIndex(int nIndex) const
00541 {
00542   if( nIndex >= m_nCount || nIndex < 0 )
00543     return NULL;  // went too far
00544
00545   CNode* pNode = m_pNodeHead;
00546   while (nIndex--)
00547   {
00548     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00549     pNode = pNode->pNext;
00550   }
00551   return (POSITION)pNode;
00552 }
00553
00554
00555 template<class TYPE, class ARG_TYPE>
00556 POSITION CLListImpl<TYPE, ARG_TYPE>::Find(ARG_TYPE SearchValue, POSITION StartAfter) const
00557 {
00558   _ASSERT( NULL != SearchValue );
00559
00560   CNode* pNode = (CNode*)StartAfter;
00561   if( NULL == pNode )
00562   {
00563     pNode = m_pNodeHead;  // start at head
00564   }
00565   else
00566   {
00567     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00568     pNode = pNode->pNext;  // start after the one specified
00569   }
00570
00571   for (; pNode != NULL; pNode = pNode->pNext)
00572     if (CompareElements<TYPE>(&pNode->data, &searchValue))
00573       return (POSITION)pNode;
00574
00575   return NULL;
00576 }
00577
00578 #ifdef _DEBUG
00579
00580 template<class TYPE, class ARG_TYPE>
00581 void CLListImpl<TYPE, ARG_TYPE>::AssertValid() const
00582 {
00583   if( 0 == m_nCount )
00584   {
00585     // empty list
00586     _ASSERT( NULL == m_pNodeHead );
00587     _ASSERT( NULL == m_pNodeTail );
00588   }
00589   else
00590   {
00591     // non-empty list
00592     _ASSERT( IsValidAddress(m_pNodeHead, sizeof(CNode)) );
00593     _ASSERT( IsValidAddress(m_pNodeTail, sizeof(CNode)) );
00594   }
00595 }
00596 #endif //_DEBUG
00597
00598 #endif //__CLASS_CLLISTIMPL__
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_STANDARDSECINMEM Member List

This is the complete list of members for _STANDARDSECINMEM, including all inherited members.
cBytes | _STANDARDSECINMEM
cProperties | _STANDARDSECINMEM
rgInts | _STANDARDSECINMEM
rglpsz | _STANDARDSECINMEM
rgPropId | _STANDARDSECINMEM
rgTime | _STANDARDSECINMEM
thumb | _STANDARDSECINMEM
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAsyncTest::threadParam Member List

This is the complete list of members for CAsyncTest::threadParam, including all inherited members.
data | CAsyncTest::threadParam |
func | CAsyncTest::threadParam |
id | CAsyncTest::threadParam |
pA | CAsyncTest::threadParam |
threadParam(DWORD w, CAsyncTest *p, DWORD method, BSTR s) | CAsyncTest::threadParam | [inline]
wait | CAsyncTest::threadParam |
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

STYLE Member List

This is the complete list of members for STYLE, including all inherited members.
hf | STYLE
sc | STYLE
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

XWindow Member List

This is the complete list of members for XWindow, including all inherited members.
_h | XWindow | [private]
Free() | XWindow | [inline]
Get() | XWindow | [inline]
Set(HWND h) | XWindow | [inline]
XWindow(HWND h=0) | XWindow | [inline]
~XWindow() | XWindow | [inline]
Generated on Wed Nov 13 2024 16:58:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM Member List

This is the complete list of members for msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM, including all inherited members.
adPriorityAboveNormal | msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM | [static]
adPriorityBelowNormal | msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM | [static]
adPriorityHighest | msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM | [static]
adPriorityLowest | msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM | [static]
adPriorityNormal | msado15::ADCPROP_ASYNCTHREADPRIORITY_ENUM | [static]
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CONST_GUID_REP Member List

This is the complete list of members for CONST_GUID_REP, including all inherited members.
pguidConstant | CONST_GUID_REP
pstrRep | CONST_GUID_REP
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

t_Ctype Member List

This is the complete list of members for t_Ctype, including all inherited members.
fVal | t_Ctype
pszName | t_Ctype
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/tapirecv/tapirecv.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • tapirecv

tapirecv.cpp

Go to the documentation of this file.
00001
00002 /*
00003
00004 Copyright (c) 1999 - 2000  Microsoft Corporation
00005
00006 Module Name:
00007
00008     TAPIRecv.cpp
00009
00010 Abstract:
00011
00012     This sample illustrates the use of Media Streaming Terminal for receiving
00013     audio.
00014
00015     The application listens on addresses that support audio, accepts an
00016     incoming call and uses Media Streaming Terminal to get the incoming
00017     data, which is written into a wav file.
00018
00019 */
00020
00021
00022 #include "common.h"
00023
00024 #include "Processing.h"
00025
00026
00027 //
00028 // main thread will wait on this event before exiting
00029 //
00030
00031 HANDLE g_hExitEvent = NULL;
00032
00033
00034 //
00035 // the tapi object
00036 //
00037
00038 ITTAPI *g_pTapi = NULL;
00039
00040
00041 //
00042 // the current call
00043 //
00044
00045 ITBasicCallControl *g_pCurrentCall = NULL;
00046
00047
00048 //
00049 // critical section for protecting the global current call
00050 //
00051
00052 CRITICAL_SECTION g_CurrentCallCritSection;
00053
00054 //
00055 // the cookie from registering tapi event notification
00056 //
00057
00058 ULONG g_nTAPINotificationCookie = 0;
00059
00060
00061 ///////////////////////////////////////////////////////////////////////////////
00062 //
00063 // LogMessage
00064 //
00065 //
00066 // logs a message using printf
00067 //
00068 ///////////////////////////////////////////////////////////////////////////////
00069
00070 void LogMessage(CHAR *pszFormat, ... )
00071 {
00072
00073     //
00074     // output buffer -- note: hardcoded limit
00075     //
00076
00077     static const BUFFER_SIZE = 1280;
00078
00079     char szBuffer[BUFFER_SIZE];
00080
00081
00082     //
00083     // get current time
00084     //
00085
00086     SYSTEMTIME SystemTime;
00087
00088     GetLocalTime(&SystemTime);
00089
00090
00091     //
00092     // format thread id and time
00093     //
00094
00095     StringCbPrintf( szBuffer, BUFFER_SIZE, "[%lx]:[%02u:%02u:%02u.%03u]::",
00096              GetCurrentThreadId(),
00097              SystemTime.wHour,
00098              SystemTime.wMinute,
00099              SystemTime.wSecond,
00100              SystemTime.wMilliseconds);
00101
00102
00103     size_t iStringLength = 0;
00104
00105     HRESULT hr = StringCbLength(szBuffer, BUFFER_SIZE, &iStringLength);
00106
00107     if (FAILED(hr))
00108     {
00109         // either this code is wrong, or someone else in the process corrupted
00110         // our memory.
00111         return;
00112     }
00113
00114
00115     //
00116     // get the actual message
00117     //
00118
00119     va_list vaArguments;
00120
00121     va_start(vaArguments, pszFormat);
00122
00123
00124     size_t iBytesLeft = BUFFER_SIZE - iStringLength;
00125
00126
00127     //
00128     // not checking the return code of this function. even if it fails, we will
00129     // have a null-terminated string that we will be able to log.
00130     //
00131
00132     StringCbVPrintf( &(szBuffer[iStringLength]), iBytesLeft, pszFormat, vaArguments);
00133
00134     va_end(vaArguments);
00135
00136
00137     //
00138     // how big is the string now, and how many bytes do we have left?
00139     //
00140
00141     hr = StringCbLength(szBuffer, BUFFER_SIZE, &iStringLength);
00142
00143     if (FAILED(hr))
00144     {
00145         // either this code is wrong, or someone else in the process corrupted
00146         // our memory.
00147         return;
00148     }
00149
00150     iBytesLeft = BUFFER_SIZE - iStringLength;
00151
00152     //
00153     // append a carriage return to the string. ignore the result code, the
00154     // result string will be null-terminated no matter what.
00155     //
00156
00157     StringCbCat(szBuffer, iBytesLeft, "\n");
00158
00159
00160     //
00161     // log the buffer
00162     //
00163
00164     printf(szBuffer);
00165 }
00166
00167
00168 ///////////////////////////////////////////////////////////////////////////////
00169 //
00170 // LogFormat
00171 //
00172 // use LogMessage to log wave format
00173 //
00174 ///////////////////////////////////////////////////////////////////////////////
00175
00176 void LogFormat(const WAVEFORMATEX *pWaveFormat)
00177 {
00178     LogMessage("    Format: ");
00179     LogMessage("        tag: %u", pWaveFormat->wFormatTag);
00180     LogMessage("        channels: %u", pWaveFormat->nChannels);
00181     LogMessage("        samples/sec: %lu", pWaveFormat->nSamplesPerSec);
00182     LogMessage("        align: %u", pWaveFormat->nBlockAlign);
00183     LogMessage("        bits/sample: %u", pWaveFormat->wBitsPerSample);
00184
00185 }
00186
00187
00188
00189 ///////////////////////////////////////////////////////////////////////////////
00190 //
00191 // AllocateMemory
00192 //
00193 // use win32 heap api to allocate memory on the application's heap
00194 // and zero the allocated memory
00195 //
00196 ///////////////////////////////////////////////////////////////////////////////
00197
00198 void *AllocateMemory(SIZE_T nMemorySize)
00199 {
00200
00201
00202     //
00203     // use HeapAlloc to allocate and clear memory
00204     //
00205
00206     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nMemorySize);
00207 }
00208
00209
00210 ///////////////////////////////////////////////////////////////////////////////
00211 //
00212 // FreeMemory
00213 //
00214 // use win32 heap api to free memory previously allocated on the application's
00215 // heap
00216 //
00217 ///////////////////////////////////////////////////////////////////////////////
00218
00219
00220 void FreeMemory(void *pMemory)
00221 {
00222
00223     //
00224     // get size of the allocated memory
00225     //
00226
00227     SIZE_T nMemorySize = HeapSize(GetProcessHeap(), 0, pMemory);
00228
00229     if (-1 == nMemorySize)
00230     {
00231         LogError("FreeMemory: failed to get size of the memory block %p",
00232                  pMemory);
00233
00234         //
00235         // don't exit -- try freeing anyway
00236         //
00237
00238     }
00239     else
00240     {
00241         //
00242         // fill memory with 0xdd's before freeing, so it is easier to debug
00243         // failures caused by using pointer to deallocated memory
00244         //
00245
00246         if (NULL != pMemory)
00247         {
00248             FillMemory(pMemory, nMemorySize, 0xdd);
00249         }
00250
00251     }
00252
00253
00254     //
00255     // use HeapFree to free memory. use return code to log the result, but
00256     // do not return it to the caller
00257     //
00258
00259     BOOL bFreeSuccess = HeapFree(GetProcessHeap(), 0, pMemory);
00260
00261     if (FALSE == bFreeSuccess)
00262     {
00263         LogError("FreeMemory: HeapFree failed");
00264
00265         //
00266         // if this assertion fires, it is likely there is a problem with the
00267         // memory we are trying to deallocate. Was it allocated using heapalloc
00268         // and on the same heap? Is this a valid pointer?
00269         //
00270
00271         _ASSERTE(FALSE);
00272     }
00273
00274 }
00275
00276
00277 ///////////////////////////////////////////////////////////////////////////////
00278 //
00279 // RegisterCallBack
00280 //
00281 //
00282 // instantiate the callback object and register it with TAPI
00283 //
00284 ///////////////////////////////////////////////////////////////////////////////
00285
00286 HRESULT RegisterCallback()
00287 {
00288     LogMessage("RegisterCallback: started");
00289
00290     HRESULT hr = S_OK;
00291
00292
00293     //
00294     // get connection point container on the tapi object
00295     //
00296
00297     IConnectionPointContainer *pCPContainer = NULL;
00298
00299     hr = g_pTapi->QueryInterface(
00300                                 IID_IConnectionPointContainer,
00301                                 (void **)&pCPContainer
00302                                );
00303
00304     if (FAILED(hr))
00305     {
00306         LogError("RegisterCallback: "
00307                  "Failed to get IConnectionPointContainer on TAPI");
00308
00309         return hr;
00310     }
00311
00312
00313     //
00314     // find connection point for our interface
00315     //
00316
00317     IConnectionPoint *pCP = NULL;
00318
00319     hr = pCPContainer->FindConnectionPoint(IID_ITTAPIEventNotification, &pCP);
00320
00321     pCPContainer->Release();
00322     pCPContainer = NULL;
00323
00324     if (FAILED(hr))
00325     {
00326         LogError("RegisterCallback: "
00327                  "Failed to get a connecion point for ITTAPIEventNotification");
00328
00329         return hr;
00330     }
00331
00332
00333     //
00334     // create the callback object and register it with TAPI.
00335     // for simplicity, the callback in this sample is not a
00336     // full-fledged COM object. So create is with new.
00337     //
00338
00339     ITTAPIEventNotification *pTAPIEventNotification =
00340                                                 new CTAPIEventNotification;
00341
00342     if (NULL == pTAPIEventNotification)
00343     {
00344
00345         LogError("RegisterCallback: Failed to create a tapi event notification object.");
00346
00347         pCP->Release();
00348         pCP = NULL;
00349
00350         return E_OUTOFMEMORY;
00351     }
00352
00353
00354     //
00355     // will use the cookie later to register for events from addresses
00356     // and to unregister the callback when we no longer needs the events
00357     //
00358
00359     hr = pCP->Advise(pTAPIEventNotification,
00360                      &g_nTAPINotificationCookie);
00361
00362     pCP->Release();
00363     pCP = NULL;
00364
00365
00366     //
00367     // whether Advise failed or succeeded, we no longer need a reference to
00368     // the callback
00369     //
00370
00371     pTAPIEventNotification->Release();
00372     pTAPIEventNotification = NULL;
00373
00374     if (FAILED(hr))
00375     {
00376         g_nTAPINotificationCookie = 0;
00377
00378         LogError("RegisterCallback: Failed to Advise");
00379     }
00380
00381
00382     LogMessage("RegisterCallback: completed");
00383
00384     return hr;
00385 }
00386
00387
00388 ///////////////////////////////////////////////////////////////////////////////
00389 //
00390 // UnRegisterCallBack
00391 //
00392 //
00393 // unregister call notification object
00394 //
00395 ///////////////////////////////////////////////////////////////////////////////
00396
00397 HRESULT UnRegisterCallBack()
00398 {
00399     LogMessage("UnRegisterCallBack: started");
00400
00401     HRESULT hr = S_OK;
00402
00403
00404     //
00405     // get connection point container on the tapi object
00406     //
00407
00408     IConnectionPointContainer *pCPContainer = NULL;
00409
00410     hr = g_pTapi->QueryInterface(IID_IConnectionPointContainer,
00411                                 (void **)&pCPContainer);
00412
00413     if (FAILED(hr))
00414     {
00415         LogError("UnRegisterCallBack: "
00416                  "Failed to get IConnectionPointContainer on TAPI");
00417
00418         return hr;
00419     }
00420
00421
00422     //
00423     // find connection point for our interface
00424     //
00425
00426     IConnectionPoint *pConnectionPoint = NULL;
00427
00428     hr = pCPContainer->FindConnectionPoint(IID_ITTAPIEventNotification,
00429                                            &pConnectionPoint);
00430
00431     pCPContainer->Release();
00432     pCPContainer = NULL;
00433
00434     if (FAILED(hr))
00435     {
00436         LogError("RegisterCallback: Failed to get a connection point for "
00437                  "ITTAPIEventNotification");
00438
00439         return hr;
00440     }
00441
00442
00443     //
00444     // unregister the callback
00445     //
00446
00447     hr = pConnectionPoint->Unadvise(g_nTAPINotificationCookie);
00448
00449     pConnectionPoint->Release();
00450     pConnectionPoint = NULL;
00451
00452     g_nTAPINotificationCookie = 0;
00453
00454     if (FAILED(hr))
00455     {
00456         LogError("UnRegisterCallBack: Unadvise failed");
00457     }
00458     else
00459     {
00460         LogMessage("UnRegisterCallBack: succeeded");
00461     }
00462
00463
00464     return hr;
00465 }
00466
00467
00468 ///////////////////////////////////////////////////////////////////////////////
00469 //
00470 // AddressSupportsAudio
00471 //
00472 // return TRUE if the address supports audio
00473 //
00474 ///////////////////////////////////////////////////////////////////////////////
00475
00476 BOOL AddressSupportsAudio(IN ITAddress *pAddress)
00477 {
00478
00479     //
00480     // get the address's ITMediaSupport so we can check
00481     // the media type it supports
00482     //
00483
00484     ITMediaSupport *pMediaSupport = NULL;
00485
00486     HRESULT hr = pAddress->QueryInterface(IID_ITMediaSupport,
00487                                           (void**)&pMediaSupport);
00488
00489     if (FAILED(hr))
00490     {
00491         LogError("AddressSupportsAudio: "
00492                  "Failed to QI address for ITMediaSupport");
00493
00494         return FALSE;
00495     }
00496
00497
00498     //
00499     // does the address support audio?
00500     //
00501
00502     VARIANT_BOOL bAudioSupported = VARIANT_FALSE;
00503
00504     hr = pMediaSupport->QueryMediaType(TAPIMEDIATYPE_AUDIO, &bAudioSupported);
00505
00506     pMediaSupport->Release();
00507     pMediaSupport = NULL;
00508
00509     if (FAILED(hr))
00510     {
00511         LogError("AddressSupportsAudio: Failed to QueryMediaType");
00512
00513         return FALSE;
00514     }
00515
00516
00517
00518     if (VARIANT_TRUE == bAudioSupported)
00519     {
00520         LogMessage("AddressSupportsAudio: audio supported on this address");
00521
00522         return TRUE;
00523
00524     }
00525     else
00526     {
00527         LogMessage("AddressSupportsAudio: "
00528                    "audio NOT supported on this address");
00529
00530         return FALSE;
00531
00532     }
00533 }
00534
00535
00536 ///////////////////////////////////////////////////////////////////////////////
00537 //
00538 // AddressSupportsMST
00539 //
00540 // return TRUE if the address supports media streaming terminal
00541 //
00542 ///////////////////////////////////////////////////////////////////////////////
00543
00544 BOOL AddressSupportsMST(IN ITAddress *pAddress)
00545 {
00546
00547     //
00548     // get the address's ITTerminalSupport so we can check
00549     // the terminals it supports
00550     //
00551
00552     ITTerminalSupport *pTerminalSupport = NULL;
00553
00554     HRESULT hr = pAddress->QueryInterface( IID_ITTerminalSupport,
00555                                            (void **)&pTerminalSupport );
00556
00557     if (FAILED(hr))
00558     {
00559         LogError("AddressSupportsMST: Failed to QI address for ITTerminalSupport");
00560
00561         return FALSE;
00562     }
00563
00564
00565     //
00566     // get enumeration of dynamic terminal classes this address supports
00567     //
00568
00569     IEnumTerminalClass *pTerminalClassEnumerator = NULL;
00570
00571     hr = pTerminalSupport->EnumerateDynamicTerminalClasses(&pTerminalClassEnumerator);
00572
00573     pTerminalSupport->Release();
00574     pTerminalSupport = NULL;
00575
00576     if (FAILED(hr))
00577     {
00578
00579         LogError("AddressSupportsMST: Failed to get dynamic terminal classes");
00580
00581         return FALSE;
00582
00583     }
00584
00585
00586     //
00587     // walk through terminal class enumeration and see if the
00588     // media streaming terminal is in it
00589     //
00590
00591     while (TRUE)
00592     {
00593
00594         GUID guid;
00595
00596         hr = pTerminalClassEnumerator->Next(1, &guid, NULL);
00597
00598         if (S_OK != hr)
00599         {
00600             LogMessage("AddressSupportsMST: no more terminal classes. "
00601                        "MST not supported on this address");
00602
00603             break;
00604         }
00605
00606         if ( IsEqualGUID(guid, CLSID_MediaStreamTerminal))
00607         {
00608             LogMessage("AddressSupportsMST: media streaming terminal supported");
00609
00610             break;
00611         }
00612     }
00613
00614
00615     //
00616     // no longer need the enumeration
00617     //
00618
00619     pTerminalClassEnumerator->Release();
00620     pTerminalClassEnumerator = NULL;
00621
00622
00623     //
00624     // if we did not break out of the loop because the enumeration ended,
00625     // media streaming terminal was not in the list of supported terminals
00626     //
00627
00628     if (S_OK == hr)
00629     {
00630         return TRUE;
00631     }
00632     else
00633     {
00634         return FALSE;
00635     }
00636
00637 }
00638
00639
00640 ///////////////////////////////////////////////////////////////////////////////
00641 //
00642 // ListenOnAddress
00643 //
00644 // register to receieve notifications of calls on this addres.
00645 // calls on this address will trigger events on the callback object
00646 // we have registered with TAPI earlier.
00647 //
00648 ///////////////////////////////////////////////////////////////////////////////
00649
00650 HRESULT ListenOnAddress(ITAddress *pAddress)
00651 {
00652
00653     long ulCallNotificationCookie = 0;
00654
00655
00656     //
00657     // we want to be notified of the status of this address
00658     //
00659     // the app can keep the cookies to later unregister from events
00660     // from specific addresses (by calling ITTAPI::UnregisterNotifications)
00661     // when it no longer wants to receive events for this specific address.
00662     // this sample does not do this for simplicity.
00663     //
00664
00665     HRESULT  hr= g_pTapi->RegisterCallNotifications(pAddress,
00666                                                    VARIANT_TRUE,
00667                                                    VARIANT_TRUE,
00668                                                    TAPIMEDIATYPE_AUDIO,
00669                                                    g_nTAPINotificationCookie,
00670                                                    &ulCallNotificationCookie
00671                                                    );
00672
00673     return hr;
00674 }
00675
00676
00677 ///////////////////////////////////////////////////////////////////////////////
00678 //
00679 // StartListening
00680 //
00681 // find all addresses that support audio and start listening on them
00682 //
00683 ///////////////////////////////////////////////////////////////////////////////
00684
00685 HRESULT StartListening()
00686 {
00687
00688     HRESULT hr = S_OK;
00689
00690     LogMessage("StartListening: started");
00691
00692
00693     //
00694     // enumerate available addresses
00695     //
00696
00697     IEnumAddress *pEnumAddress = NULL;
00698
00699     hr = g_pTapi->EnumerateAddresses( &pEnumAddress );
00700
00701     if (FAILED(hr))
00702     {
00703         LogError("StartListening: Failed to enumerate addresses");
00704
00705         return hr;
00706     }
00707
00708
00709     //
00710     // this flag remains false until we succeded starting listening on at
00711     // least one address
00712     //
00713
00714     BOOL bListenStarted = FALSE;
00715
00716
00717     //
00718     // walk through all the addresses and start listening on the ones that
00719     // support audio
00720     //
00721
00722     while (TRUE)
00723     {
00724         //
00725         // check the next address
00726         //
00727
00728         ITAddress *pAddress = NULL;
00729
00730         hr = pEnumAddress->Next(1, &pAddress, NULL);
00731
00732         if (S_OK != hr)
00733         {
00734
00735             //
00736             // no more addresses or error
00737             //
00738
00739             break;
00740         }
00741
00742
00743         //
00744         // log the name of the address
00745         //
00746
00747         BSTR bstrAddressName;
00748         hr = pAddress->get_AddressName(&bstrAddressName);
00749
00750         if (SUCCEEDED(hr))
00751         {
00752
00753             LogMessage("StartListening: -> found address [%S]",
00754                         bstrAddressName);
00755
00756             SysFreeString(bstrAddressName);
00757         }
00758         else
00759         {
00760             LogError("StartListening: failed to get address name");
00761         }
00762
00763
00764         //
00765         // if the address supports audio and media streaming terminal,
00766         // start listening
00767         //
00768
00769         if ( AddressSupportsAudio(pAddress) && AddressSupportsMST(pAddress) )
00770         {
00771
00772             //
00773             // start listening on this address
00774             //
00775
00776             LogMessage("StartListening: Starting listening.");
00777
00778             hr = ListenOnAddress(pAddress);
00779
00780             if (SUCCEEDED(hr))
00781             {
00782
00783                 //
00784                 // we are listening on at least one address
00785                 //
00786
00787                 bListenStarted = TRUE;
00788
00789                 LogMessage("StartListening: "
00790                            "-> started listening on this address");
00791
00792             }
00793             else
00794             {
00795                 //
00796                 // log an error and continue
00797                 //
00798
00799                 LogError("StartListening: -> failed starting listening on this address, "
00800                          "hr = 0x%lx", hr);
00801             }
00802         }
00803         else
00804         {
00805             LogMessage("StartListening: -> no audio or MST support on this address.");
00806         }
00807
00808
00809         pAddress->Release();
00810         pAddress = NULL;
00811
00812     }
00813
00814
00815     pEnumAddress->Release();
00816     pEnumAddress = NULL;
00817
00818
00819     //
00820     // depending on whether we started listening or not, log a message and
00821     // return the appropriate error code.
00822     //
00823
00824     if (bListenStarted)
00825     {
00826         LogMessage("StartListening: completed. "
00827                    "Listening on one or more addresses");
00828
00829         return S_OK;
00830     }
00831     else
00832     {
00833         LogMessage("StartListening: completed. Not listening on any address.");
00834
00835         return E_FAIL;
00836     }
00837 }
00838
00839
00840 ///////////////////////////////////////////////////////////////////////////////
00841 //
00842 // InitializeTAPI
00843 //
00844 // create and initialize the tapi object
00845 //
00846 ///////////////////////////////////////////////////////////////////////////////
00847
00848 HRESULT InitializeTAPI()
00849 {
00850
00851     LogMessage("InitializeTAPI: started");
00852
00853     HRESULT hr = E_FAIL;
00854
00855
00856     //
00857     // cocreate the TAPI object
00858     //
00859
00860     hr = CoCreateInstance(
00861                           CLSID_TAPI,
00862                           NULL,
00863                           CLSCTX_INPROC_SERVER,
00864                           IID_ITTAPI,
00865                           (LPVOID *)&g_pTapi
00866                          );
00867
00868     if (FAILED(hr))
00869     {
00870         LogError("InitializeTAPI: failed to CoCreateInstance TAPI");
00871
00872         return hr;
00873     }
00874
00875
00876     //
00877     // cannot use tapi until it's initialized
00878     //
00879
00880     hr = g_pTapi->Initialize();
00881
00882     if (FAILED(hr))
00883     {
00884         LogError("InitializeTAPI: TAPI failed to initialize");
00885
00886         g_pTapi->Release();
00887         g_pTapi = NULL;
00888
00889         return hr;
00890     }
00891
00892
00893     //
00894     // register the callback object that will receive tapi notifications
00895     //
00896
00897     hr = RegisterCallback();
00898
00899     if (FAILED(hr))
00900     {
00901         LogError("InitializeTAPI: failed to register callback");
00902
00903         g_pTapi->Shutdown();
00904         g_pTapi->Release();
00905         g_pTapi = NULL;
00906
00907         return hr;
00908     }
00909
00910
00911     //
00912     // we want to be notified of these events:
00913     //
00914
00915     hr = g_pTapi->put_EventFilter(TE_CALLNOTIFICATION |
00916                                   TE_CALLSTATE |
00917                                   TE_CALLMEDIA);
00918
00919     if (FAILED(hr))
00920     {
00921         LogError("InitializeTAPI: Failed to put_EventFilter");
00922
00923         //
00924         // unregister callback
00925         //
00926
00927         UnRegisterCallBack();
00928
00929         //
00930         // shutdown and release TAPI
00931         //
00932
00933         g_pTapi->Shutdown();
00934         g_pTapi->Release();
00935         g_pTapi = NULL;
00936
00937         return hr;
00938     }
00939
00940
00941     //
00942     // start listening on the addresses that support audio
00943     //
00944
00945     hr = StartListening();
00946
00947     if (S_OK != hr)
00948     {
00949         LogError("InitializeTAPI: Failed to start listening");
00950
00951         //
00952         // unregister callback
00953         //
00954
00955         UnRegisterCallBack();
00956
00957         //
00958         // shutdown and release TAPI
00959         //
00960
00961         g_pTapi->Shutdown();
00962         g_pTapi->Release();
00963         g_pTapi = NULL;
00964
00965         return hr;
00966     }
00967
00968     LogMessage("InitializeTAPI: succeeded");
00969
00970     return S_OK;
00971 }
00972
00973
00974
00975 ///////////////////////////////////////////////////////////////////////////////
00976 //
00977 // DisconnectAndReleaseCall
00978 //
00979 // disconnect and release the current call, if we have one
00980 //
00981 ///////////////////////////////////////////////////////////////////////////////
00982
00983 void DisconnectAndReleaseCall()
00984 {
00985
00986     //
00987     // g_pCurrentCall can be accessed from event-processing thread and
00988     // needs to be protected
00989     //
00990
00991     EnterCriticalSection(&g_CurrentCallCritSection);
00992
00993     if (NULL != g_pCurrentCall)
00994     {
00995
00996         //
00997         // if the call exists, attempt to disconnect it
00998         //
00999
01000         LogMessage("DisconnectAndReleaseCall: disconnecting the call");
01001
01002         g_pCurrentCall->Disconnect(DC_NORMAL);
01003
01004
01005         //
01006         // succeded or failed, release the call
01007         //
01008
01009         g_pCurrentCall->Release();
01010         g_pCurrentCall = NULL;
01011     }
01012
01013
01014     LeaveCriticalSection(&g_CurrentCallCritSection);
01015 }
01016
01017
01018 ///////////////////////////////////////////////////////////////////////////////
01019 //
01020 // ShutdownTapi
01021 //
01022 // - unregister callback object
01023 // - shutdown and release TAPI object
01024 //
01025 ///////////////////////////////////////////////////////////////////////////////
01026
01027 void ShutdownTapi()
01028 {
01029
01030     LogMessage("ShutdownTapi: started");
01031
01032
01033     //
01034     // if there is still a call, disconnect it
01035     //
01036
01037     HRESULT hr = E_FAIL;
01038
01039
01040     //
01041     // by now, the call is released and disconnected.
01042     // shutdown tapi
01043     //
01044
01045     if (NULL != g_pTapi)
01046     {
01047         //
01048         // unregister callback
01049         //
01050
01051         UnRegisterCallBack();
01052
01053
01054         //
01055         // shutdown and release the TAPI object
01056         //
01057
01058         g_pTapi->Shutdown();
01059         g_pTapi->Release();
01060         g_pTapi = NULL;
01061
01062     }
01063
01064
01065     //
01066     // in the unlikely case another call was received after we released the
01067     // call that we had, release the new call.
01068     //
01069
01070     EnterCriticalSection(&g_CurrentCallCritSection);
01071
01072     if (NULL != g_pCurrentCall)
01073     {
01074
01075         g_pCurrentCall->Release();
01076         g_pCurrentCall = NULL;
01077
01078     }
01079
01080     LeaveCriticalSection(&g_CurrentCallCritSection);
01081
01082     LogMessage("ShutdownTapi: succeeded");
01083 }
01084
01085
01086 ///////////////////////////////////////////////////////////////////////////////
01087 //
01088 // CtrlHandler
01089 //
01090 // set shutdown flag when the user requests exit by pressing
01091 // ctrl+break, attempting to log off, close the window, or
01092 // shutdown windows. this will give use a chance to exit gracefully.
01093 //
01094 ///////////////////////////////////////////////////////////////////////////////
01095
01096 BOOL CtrlHandler(DWORD nEventType)
01097 {
01098
01099     static BOOL bShutdownInProgress = FALSE;
01100
01101
01102     //
01103     // are we in the middle of shutting down?
01104     //
01105
01106     if (TRUE == bShutdownInProgress)
01107     {
01108         LogMessage("CtrlHandler: Shutdown already in progress");
01109
01110         return TRUE;
01111     }
01112
01113
01114     //
01115     // any exit event (close, ctrl+break/C, logoff, shutdown)
01116     // is a signal for the application to exit.
01117     //
01118
01119     switch (nEventType)
01120     {
01121
01122         case CTRL_C_EVENT:
01123         case CTRL_CLOSE_EVENT:
01124         case CTRL_BREAK_EVENT:
01125         case CTRL_LOGOFF_EVENT:
01126         case CTRL_SHUTDOWN_EVENT:
01127
01128             LogMessage("CtrlHandler: Initiating shutdown.");
01129
01130             //
01131             // ignore subsequent shutdown requests...
01132             //
01133
01134             bShutdownInProgress = TRUE;
01135
01136             //
01137             // signal shutdown
01138             //
01139
01140             SetEvent(g_hExitEvent);
01141             break;
01142
01143         default:
01144             break;
01145
01146     }
01147
01148     return TRUE;
01149 }
01150
01151
01152 ///////////////////////////////////////////////////////////////////////////////
01153 //
01154 // main
01155 //
01156 ///////////////////////////////////////////////////////////////////////////////
01157
01158 int __cdecl main(int argc, char* argv[])
01159 {
01160
01161     LogMessage("main: started");
01162
01163
01164     //
01165     // this event be signalled when it's time to exit
01166     //
01167
01168     g_hExitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
01169
01170     if (NULL == g_hExitEvent)
01171     {
01172         LogError("main: Failed to create exit event");
01173
01174         return 1;
01175     }
01176
01177
01178
01179     //
01180     // we want to handle ctrl+c and ctrl+break events so we can cleanup on exit
01181     // proceed even in case of failure
01182     //
01183
01184     SetConsoleCtrlHandler( (PHANDLER_ROUTINE)CtrlHandler, TRUE);
01185
01186
01187     //
01188     // initialize COM
01189     //
01190
01191     HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
01192
01193     if ( FAILED(hr))
01194     {
01195         LogError("main: Failed to CoInitialize");
01196
01197         CloseHandle(g_hExitEvent);
01198         g_hExitEvent = NULL;
01199
01200         return 1;
01201     }
01202
01203
01204     //
01205     // start worker thread for tapi message processing
01206     //
01207
01208     hr = g_WorkerThread.Initialize();
01209
01210     if (FAILED(hr))
01211     {
01212         LogError("main: Failed to initialize worker thread");
01213
01214         CoUninitialize();
01215
01216         CloseHandle(g_hExitEvent);
01217         g_hExitEvent = NULL;
01218
01219         return 1;
01220     }
01221
01222
01223     //
01224     // initialize critical section used to serialize access to global
01225     // current call
01226     //
01227     // note: InitializeCriticalSection can raise STATUS_NO_MEMORY exception
01228     //
01229
01230     InitializeCriticalSection(&g_CurrentCallCritSection);
01231
01232     //
01233     // create and initialize tapi object, register the callback object
01234     // and start listening
01235     //
01236
01237     hr = InitializeTAPI();
01238
01239     if (FAILED(hr))
01240     {
01241
01242         g_WorkerThread.Shutdown();
01243
01244
01245         CloseHandle(g_hExitEvent);
01246         g_hExitEvent = NULL;
01247
01248         DeleteCriticalSection(&g_CurrentCallCritSection);
01249
01250         CoUninitialize();
01251         return 1;
01252     }
01253
01254
01255     //
01256     // wait until ctrl+break handler or CS_DISCONNECT handler signal exit event
01257     //
01258
01259     LogMessage("main: waiting for exit event");
01260
01261     DWORD nWaitResult = WaitForSingleObject(g_hExitEvent, INFINITE);
01262
01263     LogMessage("main: exit event signaled");
01264
01265
01266     //
01267     // disconnect and release call, if it exists
01268     //
01269
01270     DisconnectAndReleaseCall();
01271
01272
01273     //
01274     // cleanup tapi
01275     //
01276
01277     ShutdownTapi();
01278
01279
01280     //
01281     // stop the worker thread
01282     //
01283
01284     g_WorkerThread.Shutdown();
01285
01286
01287     //
01288     // no longer need the critical section
01289     //
01290
01291     DeleteCriticalSection(&g_CurrentCallCritSection);
01292
01293
01294     //
01295     // release com
01296     //
01297
01298     CoUninitialize();
01299
01300
01301     //
01302     // no longer need the event
01303     //
01304
01305     CloseHandle(g_hExitEvent);
01306     g_hExitEvent = NULL;
01307
01308
01309     //
01310     // exiting... we no longer want to handle ctrl+c and ctrl+break
01311     //
01312
01313     SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, FALSE);
01314
01315
01316     //
01317     // was the event signaled, or wait failed?
01318     //
01319
01320     if (WAIT_OBJECT_0 != nWaitResult)
01321     {
01322         LogError("main: Failed to wait for exit event");
01323         return 1;
01324     }
01325
01326
01327     LogMessage("main: exiting");
01328
01329   return 0;
01330 }
01331
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/policy.cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

policy.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        policy.cpp
00007 //
00008 // Contents:    Cert Server Policy Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013 #pragma hdrstop
00014
00015 #include <assert.h>
00016 #include "celib.h"
00017 #include "policy.h"
00018 #include "module.h"
00019
00020 BOOL fDebug = DBG_CERTSRV;
00021
00022 #ifndef DBG_CERTSRV
00023 #error -- DBG_CERTSRV not defined!
00024 #endif
00025
00026 // worker
00027 HRESULT
00028 polGetServerCallbackInterface(
00029     OUT ICertServerPolicy **ppServer,
00030     IN LONG Context)
00031 {
00032     HRESULT hr;
00033
00034     if (NULL == ppServer)
00035     {
00036         hr = E_POINTER;
00037   _JumpError(hr, error, "Policy:polGetServerCallbackInterface");
00038     }
00039
00040     hr = CoCreateInstance(
00041                     CLSID_CCertServerPolicy,
00042                     NULL,               // pUnkOuter
00043                     CLSCTX_INPROC_SERVER,
00044                     IID_ICertServerPolicy,
00045                     (VOID **) ppServer);
00046     _JumpIfError(hr, error, "Policy:CoCreateInstance");
00047
00048     if (NULL == *ppServer)
00049     {
00050         hr = E_UNEXPECTED;
00051   _JumpError(hr, error, "Policy:CoCreateInstance");
00052     }
00053
00054     // only set context if nonzero
00055     if (0 != Context)
00056     {
00057         hr = (*ppServer)->SetContext(Context);
00058         _JumpIfError(hr, error, "Policy:SetContext");
00059     }
00060
00061 error:
00062     return hr;
00063 }
00064
00065
00066 HRESULT
00067 polGetProperty(
00068     IN ICertServerPolicy *pServer,
00069     IN BOOL fRequest,
00070     IN WCHAR const *pwszPropertyName,
00071     IN DWORD PropType,
00072     OUT VARIANT *pvarOut)
00073 {
00074     HRESULT hr;
00075     BSTR strName = NULL;
00076
00077     VariantInit(pvarOut);
00078     strName = SysAllocString(pwszPropertyName);
00079     if (NULL == strName)
00080     {
00081   hr = E_OUTOFMEMORY;
00082   _JumpError(hr, error, "Policy:SysAllocString");
00083     }
00084     if (fRequest)
00085     {
00086   hr = pServer->GetRequestProperty(strName, PropType, pvarOut);
00087   _JumpIfErrorStr2(
00088         hr,
00089         error,
00090         "Policy:GetRequestProperty",
00091         pwszPropertyName,
00092         CERTSRV_E_PROPERTY_EMPTY);
00093     }
00094     else
00095     {
00096   hr = pServer->GetCertificateProperty(strName, PropType, pvarOut);
00097   _JumpIfErrorStr2(
00098         hr,
00099         error,
00100         "Policy:GetCertificateProperty",
00101         pwszPropertyName,
00102         CERTSRV_E_PROPERTY_EMPTY);
00103     }
00104
00105 error:
00106     if (NULL != strName)
00107     {
00108   SysFreeString(strName);
00109     }
00110     return(hr);
00111 }
00112
00113
00114 HRESULT
00115 polGetStringProperty(
00116     IN ICertServerPolicy *pServer,
00117     IN BOOL fRequest,
00118     IN WCHAR const *pwszPropertyName,
00119     OUT BSTR *pstrOut)
00120 {
00121     HRESULT hr;
00122     VARIANT var;
00123
00124     VariantInit(&var);
00125     if (NULL != *pstrOut)
00126     {
00127   SysFreeString(*pstrOut);
00128   *pstrOut = NULL;
00129     }
00130     hr = polGetProperty(
00131         pServer,
00132         fRequest,
00133         pwszPropertyName,
00134         PROPTYPE_STRING,
00135         &var);
00136     _JumpIfError2(
00137       hr,
00138       error,
00139       "Policy:polGetProperty",
00140       CERTSRV_E_PROPERTY_EMPTY);
00141
00142     if (VT_BSTR != var.vt || NULL == var.bstrVal || L'\0' == var.bstrVal)
00143     {
00144   hr = CERTSRV_E_PROPERTY_EMPTY;
00145   _JumpError(hr, error, "Policy:polGetProperty");
00146     }
00147     *pstrOut = var.bstrVal;
00148     var.vt = VT_EMPTY;
00149     hr = S_OK;
00150
00151 error:
00152     VariantClear(&var);
00153     return(hr);
00154 }
00155
00156
00157 HRESULT
00158 polGetLongProperty(
00159     IN ICertServerPolicy *pServer,
00160     IN BOOL fRequest,
00161     IN WCHAR const *pwszPropertyName,
00162     OUT LONG *plOut)
00163 {
00164     HRESULT hr;
00165     VARIANT var;
00166
00167     VariantInit(&var);
00168     hr = polGetProperty(
00169         pServer,
00170         fRequest,
00171         pwszPropertyName,
00172         PROPTYPE_LONG,
00173         &var);
00174     _JumpIfError2(hr, error, "Policy:polGetProperty", CERTSRV_E_PROPERTY_EMPTY);
00175
00176     if (VT_I4 != var.vt)
00177     {
00178   hr = CERTSRV_E_PROPERTY_EMPTY;
00179   _JumpError(hr, error, "Policy:polGetProperty");
00180     }
00181     *plOut = var.lVal;
00182     hr = S_OK;
00183
00184 error:
00185     VariantClear(&var);
00186     return(hr);
00187 }
00188
00189
00190 HRESULT
00191 polGetRequestStringProperty(
00192     IN ICertServerPolicy *pServer,
00193     IN WCHAR const *pwszPropertyName,
00194     OUT BSTR *pstrOut)
00195 {
00196     HRESULT hr;
00197
00198     hr = polGetStringProperty(pServer, TRUE, pwszPropertyName, pstrOut);
00199     _JumpIfError2(hr, error, "polGetStringProperty", CERTSRV_E_PROPERTY_EMPTY);
00200
00201 error:
00202     return(hr);
00203 }
00204
00205
00206 HRESULT
00207 polGetCertificateStringProperty(
00208     IN ICertServerPolicy *pServer,
00209     IN WCHAR const *pwszPropertyName,
00210     OUT BSTR *pstrOut)
00211 {
00212     HRESULT hr;
00213
00214     hr = polGetStringProperty(pServer, FALSE, pwszPropertyName, pstrOut);
00215     _JumpIfError2(hr, error, "polGetStringProperty", CERTSRV_E_PROPERTY_EMPTY);
00216
00217 error:
00218     return(hr);
00219 }
00220
00221
00222 HRESULT
00223 polGetRequestLongProperty(
00224     IN ICertServerPolicy *pServer,
00225     IN WCHAR const *pwszPropertyName,
00226     OUT LONG *plOut)
00227 {
00228     HRESULT hr;
00229
00230     hr = polGetLongProperty(pServer, TRUE, pwszPropertyName, plOut);
00231     _JumpIfError2(hr, error, "polGetLongProperty", CERTSRV_E_PROPERTY_EMPTY);
00232
00233 error:
00234     return(hr);
00235 }
00236
00237
00238 HRESULT
00239 polGetCertificateLongProperty(
00240     IN ICertServerPolicy *pServer,
00241     IN WCHAR const *pwszPropertyName,
00242     OUT LONG *plOut)
00243 {
00244     HRESULT hr;
00245
00246     hr = polGetLongProperty(pServer, FALSE, pwszPropertyName, plOut);
00247     _JumpIfError2(hr, error, "polGetLongProperty", CERTSRV_E_PROPERTY_EMPTY);
00248
00249 error:
00250     return(hr);
00251 }
00252
00253
00254 HRESULT
00255 polGetRequestAttribute(
00256     IN ICertServerPolicy *pServer,
00257     IN WCHAR const *pwszAttributeName,
00258     OUT BSTR *pstrOut)
00259 {
00260     HRESULT hr;
00261     BSTR strName = NULL;
00262
00263     strName = SysAllocString(pwszAttributeName);
00264     if (NULL == strName)
00265     {
00266   hr = E_OUTOFMEMORY;
00267   _JumpError(hr, error, "Policy:SysAllocString");
00268     }
00269     hr = pServer->GetRequestAttribute(strName, pstrOut);
00270     _JumpIfErrorStr2(
00271     hr,
00272     error,
00273     "Policy:GetRequestAttribute",
00274     pwszAttributeName,
00275     CERTSRV_E_PROPERTY_EMPTY);
00276
00277 error:
00278     if (NULL != strName)
00279     {
00280   SysFreeString(strName);
00281     }
00282     return(hr);
00283 }
00284
00285
00286 HRESULT
00287 polGetCertificateExtension(
00288     IN ICertServerPolicy *pServer,
00289     IN WCHAR const *pwszExtensionName,
00290     IN DWORD dwPropType,
00291     IN OUT VARIANT *pvarOut)
00292 {
00293     HRESULT hr;
00294     BSTR strName = NULL;
00295
00296     strName = SysAllocString(pwszExtensionName);
00297     if (NULL == strName)
00298     {
00299   hr = E_OUTOFMEMORY;
00300   _JumpError(hr, error, "Policy:SysAllocString");
00301     }
00302     hr = pServer->GetCertificateExtension(strName, dwPropType, pvarOut);
00303     _JumpIfErrorStr2(
00304     hr,
00305     error,
00306     "Policy:GetCertificateExtension",
00307     pwszExtensionName,
00308     CERTSRV_E_PROPERTY_EMPTY);
00309
00310 error:
00311     if (NULL != strName)
00312     {
00313   SysFreeString(strName);
00314     }
00315     return(hr);
00316 }
00317
00318
00319 HRESULT
00320 polSetCertificateExtension(
00321     IN ICertServerPolicy *pServer,
00322     IN WCHAR const *pwszExtensionName,
00323     IN DWORD dwPropType,
00324     IN DWORD dwExtFlags,
00325     IN VARIANT const *pvarIn)
00326 {
00327     HRESULT hr;
00328     BSTR strName = NULL;
00329
00330     strName = SysAllocString(pwszExtensionName);
00331     if (NULL == strName)
00332     {
00333   hr = E_OUTOFMEMORY;
00334   _JumpError(hr, error, "Policy:SysAllocString");
00335     }
00336     hr = pServer->SetCertificateExtension(
00337             strName,
00338             dwPropType,
00339             dwExtFlags,
00340             pvarIn);
00341     _JumpIfErrorStr(
00342     hr,
00343     error,
00344     "Policy:SetCertificateExtension",
00345     pwszExtensionName);
00346
00347 error:
00348     if (NULL != strName)
00349     {
00350   SysFreeString(strName);
00351     }
00352     return(hr);
00353 }
00354
00355
00356 //+--------------------------------------------------------------------------
00357 // CCertPolicySample::~CCertPolicySample -- destructor
00358 //
00359 // free memory associated with this instance
00360 //+--------------------------------------------------------------------------
00361
00362 CCertPolicySample::~CCertPolicySample()
00363 {
00364     _Cleanup();
00365
00366 }
00367
00368
00369 VOID
00370 CCertPolicySample::_FreeStringArray(
00371     IN OUT DWORD *pcString,
00372     IN OUT LPWSTR **papwsz)
00373 {
00374     LPWSTR *apwsz = *papwsz;
00375     DWORD i;
00376
00377     if (NULL != apwsz)
00378     {
00379         for (i = *pcString; i-- > 0; )
00380         {
00381             if (NULL != apwsz[i])
00382             {
00383                 DBGPRINT((fDebug, "_FreeStringArray[%u]: '%ws'\n", i, apwsz[i]));
00384                 LocalFree(apwsz[i]);
00385             }
00386         }
00387         LocalFree(apwsz);
00388         *papwsz = NULL;
00389     }
00390     *pcString = 0;
00391 }
00392
00393
00394
00395
00396 //+--------------------------------------------------------------------------
00397 // CCertPolicySample::_Cleanup -- free memory associated with this instance
00398 //
00399 // free memory associated with this instance
00400 //+--------------------------------------------------------------------------
00401
00402 VOID
00403 CCertPolicySample::_Cleanup()
00404 {
00405     if (m_strDescription)
00406     {
00407         SysFreeString(m_strDescription);
00408         m_strDescription = NULL;
00409     }
00410
00411     // RevocationExtension variables:
00412
00413     if (NULL != m_wszASPRevocationURL)
00414     {
00415         LocalFree(m_wszASPRevocationURL);
00416       m_wszASPRevocationURL = NULL;
00417     }
00418
00419
00420     _FreeStringArray(&m_cEnableRequestExtensions, &m_apwszEnableRequestExtensions);
00421     _FreeStringArray(&m_cEnableEnrolleeRequestExtensions, &m_apwszEnableEnrolleeRequestExtensions);
00422     _FreeStringArray(&m_cDisableExtensions, &m_apwszDisableExtensions);
00423
00424     if (NULL != m_strCAName)
00425     {
00426         SysFreeString(m_strCAName);
00427         m_strCAName = NULL;
00428     }
00429     if (NULL != m_strCASanitizedName)
00430     {
00431         SysFreeString(m_strCASanitizedName);
00432         m_strCASanitizedName = NULL;
00433     }
00434     if (NULL != m_strCASanitizedDSName)
00435     {
00436         SysFreeString(m_strCASanitizedDSName);
00437         m_strCASanitizedDSName = NULL;
00438     }
00439     if (NULL != m_strRegStorageLoc)
00440     {
00441         SysFreeString(m_strRegStorageLoc);
00442         m_strRegStorageLoc = NULL;
00443     }
00444     if (NULL != m_pCert)
00445     {
00446         CertFreeCertificateContext(m_pCert);
00447         m_pCert = NULL;
00448     }
00449     if (m_strMachineDNSName)
00450     {
00451         SysFreeString(m_strMachineDNSName);
00452         m_strMachineDNSName=NULL;
00453     }
00454
00455 }
00456
00457
00458 HRESULT
00459 CCertPolicySample::_ReadRegistryString(
00460     IN HKEY hkey,
00461     IN BOOL fURL,
00462     IN WCHAR const *pwszRegName,
00463     IN WCHAR const *pwszSuffix,
00464     OUT LPWSTR *ppwszOut)
00465 {
00466     HRESULT hr;
00467     WCHAR *pwszRegValue = NULL;
00468     DWORD cbValue;
00469     DWORD dwType;
00470
00471     *ppwszOut = NULL;
00472     hr = RegQueryValueEx(
00473         hkey,
00474         pwszRegName,
00475         NULL,           // lpdwReserved
00476         &dwType,
00477         NULL,
00478         &cbValue);
00479     _JumpIfErrorStr2(
00480     hr,
00481     error,
00482     "Policy:RegQueryValueEx",
00483     pwszRegName,
00484     ERROR_FILE_NOT_FOUND);
00485
00486     if (REG_SZ != dwType && REG_MULTI_SZ != dwType)
00487     {
00488         hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00489         _JumpErrorStr(hr, error, "Policy:RegQueryValueEx TYPE", pwszRegName);
00490     }
00491     if (NULL != pwszSuffix)
00492     {
00493   cbValue += wcslen(pwszSuffix) * sizeof(WCHAR);
00494     }
00495     pwszRegValue = (WCHAR *) LocalAlloc(LMEM_FIXED, cbValue + sizeof(WCHAR));
00496     if (NULL == pwszRegValue)
00497     {
00498         hr = E_OUTOFMEMORY;
00499         _JumpErrorStr(hr, error, "Policy:LocalAlloc", pwszRegName);
00500     }
00501     hr = RegQueryValueEx(
00502         hkey,
00503         pwszRegName,
00504         NULL,           // lpdwReserved
00505         &dwType,
00506         (BYTE *) pwszRegValue,
00507         &cbValue);
00508     _JumpIfErrorStr(hr, error, "Policy:RegQueryValueEx", pwszRegName);
00509
00510     // Handle malformed registry values cleanly:
00511
00512     pwszRegValue[cbValue / sizeof(WCHAR)] = L'\0';
00513     if (NULL != pwszSuffix)
00514     {
00515   wcscat(pwszRegValue, pwszSuffix);
00516     }
00517
00518     hr = ceFormatCertsrvStringArray(
00519       fURL,     // fURL
00520       m_strMachineDNSName,  // pwszServerName_p1_2
00521       m_strCASanitizedName, // pwszSanitizedName_p3_7
00522       m_iCert,    // iCert_p4
00523       MAXDWORD,   // iCertTarget_p4
00524       L"",    // pwszDomainDN_p5
00525       L"",    // pwszConfigDN_p6
00526       m_iCRL,     // iCRL_p8
00527       FALSE,      // fDeltaCRL_p9
00528       TRUE,     // fDSAttrib_p10_11
00529       1,      // cStrings
00530       (LPCWSTR *) &pwszRegValue, // apwszStringsIn
00531       ppwszOut);    // apwszStringsOut
00532     _JumpIfError(hr, error, "Policy:ceFormatCertsrvStringArray");
00533
00534 error:
00535     if (NULL != pwszRegValue)
00536     {
00537         LocalFree(pwszRegValue);
00538     }
00539     return(ceHError(hr)); // Reg routines return Win32 error codes
00540 }
00541
00542
00543 #if DBG_CERTSRV
00544
00545 VOID
00546 CCertPolicySample::_DumpStringArray(
00547     IN char const *pszType,
00548     IN DWORD count,
00549     IN LPWSTR const *apwsz)
00550 {
00551     DWORD i;
00552     WCHAR const *pwszName;
00553
00554     for (i = 0; i < count; i++)
00555     {
00556   pwszName = L"";
00557   if (iswdigit(apwsz[i][0]))
00558   {
00559       pwszName = ceGetOIDName(apwsz[i]);  // Static: do not free!
00560   }
00561   DBGPRINT((
00562     fDebug,
00563     "%hs[%u]: %ws%hs%ws\n",
00564     pszType,
00565     i,
00566     apwsz[i],
00567     L'\0' != *pwszName? " -- " : "",
00568     pwszName));
00569     }
00570 }
00571 #endif // DBG_CERTSRV
00572
00573
00574 HRESULT
00575 CCertPolicySample::_SetSystemStringProp(
00576     IN ICertServerPolicy *pServer,
00577     IN WCHAR const *pwszName,
00578     OPTIONAL IN WCHAR const *pwszValue)
00579 {
00580     HRESULT hr;
00581     BSTR strName = NULL;
00582     VARIANT varValue;
00583
00584     varValue.vt = VT_NULL;
00585     varValue.bstrVal = NULL;
00586
00587     if (!ceConvertWszToBstr(&strName, pwszName, -1))
00588     {
00589   hr = E_OUTOFMEMORY;
00590   _JumpError(hr, error, "Policy:ceConvertWszToBstr");
00591     }
00592
00593     if (NULL != pwszValue)
00594     {
00595         if (!ceConvertWszToBstr(&varValue.bstrVal, pwszValue, -1))
00596   {
00597       hr = E_OUTOFMEMORY;
00598       _JumpError(hr, error, "Policy:ceConvertWszToBstr");
00599   }
00600   varValue.vt = VT_BSTR;
00601     }
00602
00603     hr = pServer->SetCertificateProperty(strName, PROPTYPE_STRING, &varValue);
00604     _JumpIfError(hr, error, "Policy:SetCertificateProperty");
00605
00606 error:
00607     VariantClear(&varValue);
00608     if (NULL != strName)
00609     {
00610   SysFreeString(strName);
00611     }
00612     return(hr);
00613 }
00614
00615
00616 HRESULT
00617 CCertPolicySample::_AddStringArray(
00618     IN WCHAR const *pwszzValue,
00619     IN BOOL fURL,
00620     IN OUT DWORD *pcStrings,
00621     IN OUT LPWSTR **papwszRegValues)
00622 {
00623     HRESULT hr;
00624     DWORD cString = 0;
00625     WCHAR const *pwsz;
00626     LPCWSTR *awszFormatStrings = NULL;
00627     LPWSTR *awszOutputStrings = NULL;
00628
00629     // Count the number of strings we're adding
00630     for (pwsz = pwszzValue; L'\0' != *pwsz; pwsz += wcslen(pwsz) + 1)
00631     {
00632         cString++;
00633     }
00634     if (0 == cString)   // no strings
00635     {
00636   hr = S_OK;
00637         goto error;
00638     }
00639     awszFormatStrings = (LPCWSTR *) LocalAlloc(
00640           LMEM_FIXED | LMEM_ZEROINIT,
00641           cString * sizeof(LPWSTR));
00642     if (NULL == awszFormatStrings)
00643     {
00644         hr = E_OUTOFMEMORY;
00645         _JumpError(hr, error, "Policy:LocalAlloc");
00646     }
00647
00648     cString = 0;
00649     for (pwsz = pwszzValue; L'\0' != *pwsz; pwsz += wcslen(pwsz) + 1)
00650     {
00651         // Skip strings that start with a an unescaped minus sign.
00652         // Strings with an escaped minus sign (2 minus signs) are not skipped.
00653
00654         if (L'-' == *pwsz)
00655         {
00656       pwsz++;
00657       if (L'-' != *pwsz)
00658       {
00659                 continue;
00660       }
00661         }
00662         awszFormatStrings[cString++] = pwsz;
00663     }
00664
00665     // if no strings to add, don't modify
00666     if (cString > 0)
00667     {
00668         awszOutputStrings = (LPWSTR *) LocalAlloc(
00669               LMEM_FIXED | LMEM_ZEROINIT,
00670               (cString + *pcStrings) * sizeof(LPWSTR));
00671         if (NULL == awszOutputStrings)
00672         {
00673             hr = E_OUTOFMEMORY;
00674             _JumpError(hr, error, "Policy:LocalAlloc");
00675         }
00676
00677         if (0 != *pcStrings)
00678         {
00679             assert(NULL != *papwszRegValues);
00680             CopyMemory(
00681     awszOutputStrings,
00682     *papwszRegValues,
00683     *pcStrings * sizeof(LPWSTR));
00684         }
00685
00686         hr = ceFormatCertsrvStringArray(
00687     fURL,       // fURL
00688     m_strMachineDNSName,    // pwszServerName_p1_2
00689     m_strCASanitizedName,   // pwszSanitizedName_p3_7
00690     m_iCert,      // iCert_p4
00691     MAXDWORD,     // iCertTarget_p4
00692     L"",      // pwszDomainDN_p5
00693     L"",      // pwszConfigDN_p6
00694     m_iCRL,       // iCRL_p8
00695     FALSE,        // fDeltaCRL_p9
00696     TRUE,       // fDSAttrib_p10_11
00697     cString,      // cStrings
00698     awszFormatStrings,    // apwszStringsIn
00699     awszOutputStrings + (*pcStrings)); // apwszStringsOut
00700   _JumpIfError(hr, error, "Policy:ceFormatCertsrvStringArray");
00701
00702         *pcStrings = (*pcStrings) + cString;
00703         if (*papwszRegValues)
00704         {
00705             LocalFree(*papwszRegValues);
00706         }
00707         *papwszRegValues = awszOutputStrings;
00708         awszOutputStrings = NULL;
00709     }
00710     hr = S_OK;
00711
00712 error:
00713     if (NULL != awszOutputStrings)
00714     {
00715         LocalFree(awszOutputStrings);
00716     }
00717     if (NULL != awszFormatStrings)
00718     {
00719         LocalFree(awszFormatStrings);
00720     }
00721     return(hr);
00722 }
00723
00724
00725 HRESULT
00726 CCertPolicySample::_ReadRegistryStringArray(
00727     IN HKEY hkey,
00728     IN BOOL fURL,
00729     IN DWORD dwFlags,
00730     IN DWORD cRegNames,
00731     IN DWORD *aFlags,
00732     IN WCHAR const * const *apwszRegNames,
00733     IN OUT DWORD *pcStrings,
00734     IN OUT LPWSTR **papwszRegValues)
00735 {
00736     HRESULT hr;
00737     DWORD i;
00738     WCHAR *pwszzValue = NULL;
00739     DWORD cbValue;
00740     DWORD dwType;
00741
00742     for (i = 0; i < cRegNames; i++)
00743     {
00744         if (0 == (dwFlags & aFlags[i]))
00745         {
00746       continue;
00747         }
00748         if (NULL != pwszzValue)
00749         {
00750       LocalFree(pwszzValue);
00751       pwszzValue = NULL;
00752         }
00753         hr = RegQueryValueEx(
00754             hkey,
00755             apwszRegNames[i],
00756             NULL,           // lpdwReserved
00757             &dwType,
00758             NULL,
00759             &cbValue);
00760         if (S_OK != hr)
00761         {
00762       _PrintErrorStr2(
00763       hr,
00764       "Policy:RegQueryValueEx",
00765       apwszRegNames[i],
00766       ERROR_FILE_NOT_FOUND);
00767       continue;
00768         }
00769         if (REG_SZ != dwType && REG_MULTI_SZ != dwType)
00770         {
00771       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00772       _PrintErrorStr(hr, "Policy:RegQueryValueEx TYPE", apwszRegNames[i]);
00773       continue;
00774         }
00775
00776         // Handle malformed registry values cleanly by adding two WCHAR L'\0's
00777   // allocate space for 3 WCHARs to allow for unaligned (odd) cbValue;
00778
00779         pwszzValue = (WCHAR *) LocalAlloc(
00780                 LMEM_FIXED,
00781                 cbValue + 3 * sizeof(WCHAR));
00782         if (NULL == pwszzValue)
00783         {
00784       hr = E_OUTOFMEMORY;
00785       _JumpErrorStr(hr, error, "Policy:LocalAlloc", apwszRegNames[i]);
00786         }
00787         hr = RegQueryValueEx(
00788             hkey,
00789             apwszRegNames[i],
00790             NULL,           // lpdwReserved
00791             &dwType,
00792             (BYTE *) pwszzValue,
00793             &cbValue);
00794         if (S_OK != hr)
00795         {
00796       _PrintErrorStr(hr, "Policy:RegQueryValueEx", apwszRegNames[i]);
00797       continue;
00798         }
00799
00800         // Handle malformed registry values cleanly:
00801
00802         pwszzValue[cbValue / sizeof(WCHAR)] = L'\0';
00803         pwszzValue[cbValue / sizeof(WCHAR) + 1] = L'\0';
00804
00805         hr = _AddStringArray(
00806       pwszzValue,
00807       fURL,
00808       pcStrings,
00809       papwszRegValues);
00810         _JumpIfErrorStr(hr, error, "_AddStringArray", apwszRegNames[i]);
00811     }
00812     hr = S_OK;
00813
00814 error:
00815     if (NULL != pwszzValue)
00816     {
00817         LocalFree(pwszzValue);
00818     }
00819     return(hr);
00820 }
00821
00822
00823 //+--------------------------------------------------------------------------
00824 // CCertPolicySample::_InitRevocationExtension
00825 //
00826 //+--------------------------------------------------------------------------
00827
00828 VOID
00829 CCertPolicySample::_InitRevocationExtension(
00830     IN HKEY hkey)
00831 {
00832     HRESULT hr;
00833     DWORD dwType;
00834     DWORD cb;
00835
00836     cb = sizeof(m_dwRevocationFlags);
00837     hr = RegQueryValueEx(
00838                 hkey,
00839                 wszREGREVOCATIONTYPE,
00840                 NULL,           // lpdwReserved
00841                 &dwType,
00842                 (BYTE *) &m_dwRevocationFlags,
00843                 &cb);
00844     if (S_OK != hr ||
00845   REG_DWORD != dwType ||
00846   sizeof(m_dwRevocationFlags) != cb)
00847     {
00848   m_dwRevocationFlags = 0;
00849         goto error;
00850     }
00851     DBGPRINT((fDebug, "Revocation Flags = %x\n", m_dwRevocationFlags));
00852
00853     // clean up from previous call
00854
00855     if (NULL != m_wszASPRevocationURL)
00856     {
00857   LocalFree(m_wszASPRevocationURL);
00858   m_wszASPRevocationURL = NULL;
00859     }
00860
00861     if (REVEXT_ASPENABLE & m_dwRevocationFlags)
00862     {
00863         hr = _ReadRegistryString(
00864           hkey,
00865           TRUE,     // fURL
00866           wszREGREVOCATIONURL,  // pwszRegName
00867           L"?",     // pwszSuffix
00868           &m_wszASPRevocationURL);  // pstrRegValue
00869         _JumpIfErrorStr(hr, error, "_ReadRegistryString", wszREGREVOCATIONURL);
00870         _DumpStringArray("ASP", 1, &m_wszASPRevocationURL);
00871     }
00872
00873 error:
00874     ;
00875 }
00876
00877
00878 //+--------------------------------------------------------------------------
00879 // CCertPolicySample::_InitRequestExtensionList
00880 //
00881 //+--------------------------------------------------------------------------
00882
00883 VOID
00884 CCertPolicySample::_InitRequestExtensionList(
00885     IN HKEY hkey)
00886 {
00887     HRESULT hr;
00888     DWORD adwFlags[] = {
00889   EDITF_REQUESTEXTENSIONLIST,
00890     };
00891     WCHAR *apwszRegNames[] = {
00892   wszREGENABLEREQUESTEXTENSIONLIST,
00893     };
00894     WCHAR *apwszRegNamesEnrollee[] = {
00895   wszREGENABLEENROLLEEREQUESTEXTENSIONLIST,
00896     };
00897
00898     assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNames));
00899     assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNamesEnrollee));
00900
00901     // clean up from previous call
00902
00903     if (NULL != m_apwszEnableRequestExtensions)
00904     {
00905         _FreeStringArray(
00906         &m_cEnableRequestExtensions,
00907         &m_apwszEnableRequestExtensions);
00908     }
00909     if (NULL != m_apwszEnableEnrolleeRequestExtensions)
00910     {
00911         _FreeStringArray(
00912         &m_cEnableEnrolleeRequestExtensions,
00913         &m_apwszEnableEnrolleeRequestExtensions);
00914     }
00915
00916     hr = _ReadRegistryStringArray(
00917       hkey,
00918       FALSE,      // fURL
00919       m_dwEditFlags,
00920       ARRAYSIZE(adwFlags),
00921       adwFlags,
00922       apwszRegNames,
00923       &m_cEnableRequestExtensions,
00924       &m_apwszEnableRequestExtensions);
00925     _JumpIfError(hr, error, "_ReadRegistryStringArray");
00926
00927     _DumpStringArray(
00928     "Request",
00929     m_cEnableRequestExtensions,
00930     m_apwszEnableRequestExtensions);
00931
00932     hr = _ReadRegistryStringArray(
00933       hkey,
00934       FALSE,      // fURL
00935       m_dwEditFlags,
00936       ARRAYSIZE(adwFlags),
00937       adwFlags,
00938       apwszRegNamesEnrollee,
00939       &m_cEnableEnrolleeRequestExtensions,
00940       &m_apwszEnableEnrolleeRequestExtensions);
00941     _JumpIfError(hr, error, "_ReadRegistryStringArray");
00942
00943     _DumpStringArray(
00944     "EnrolleeRequest",
00945     m_cEnableEnrolleeRequestExtensions,
00946     m_apwszEnableEnrolleeRequestExtensions);
00947
00948 error:
00949     ;
00950 }
00951
00952
00953 //+--------------------------------------------------------------------------
00954 // CCertPolicySample::_InitDisableExtensionList
00955 //
00956 //+--------------------------------------------------------------------------
00957
00958 VOID
00959 CCertPolicySample::_InitDisableExtensionList(
00960     IN HKEY hkey)
00961 {
00962     HRESULT hr;
00963     DWORD adwFlags[] = {
00964   EDITF_DISABLEEXTENSIONLIST,
00965     };
00966     WCHAR *apwszRegNames[] = {
00967   wszREGDISABLEEXTENSIONLIST,
00968     };
00969
00970     assert(ARRAYSIZE(adwFlags) == ARRAYSIZE(apwszRegNames));
00971
00972     // clean up from previous call
00973
00974     if (NULL != m_apwszDisableExtensions)
00975     {
00976         _FreeStringArray(&m_cDisableExtensions, &m_apwszDisableExtensions);
00977     }
00978
00979
00980     hr = _ReadRegistryStringArray(
00981       hkey,
00982       FALSE,      // fURL
00983       m_dwEditFlags,
00984       ARRAYSIZE(adwFlags),
00985       adwFlags,
00986       apwszRegNames,
00987       &m_cDisableExtensions,
00988       &m_apwszDisableExtensions);
00989     _JumpIfError(hr, error, "_ReadRegistryStringArray");
00990
00991     _DumpStringArray(
00992     "Disable",
00993     m_cDisableExtensions,
00994     m_apwszDisableExtensions);
00995
00996 error:
00997     ;
00998 }
00999
01000
01001
01002
01003 //+--------------------------------------------------------------------------
01004 // CCertPolicySample::Initialize
01005 //
01006 // Returns S_OK on success.
01007 //+--------------------------------------------------------------------------
01008
01009 STDMETHODIMP
01010 CCertPolicySample::Initialize(
01011     /* [in] */ BSTR const strConfig)
01012 {
01013     HRESULT hr;
01014     HKEY hkey = NULL;
01015     DWORD dwType;
01016     DWORD dwSize;
01017     ICertServerPolicy *pServer = NULL;
01018     BOOL fUpgraded;
01019     BSTR bstrDescription = NULL;
01020
01021     CERT_RDN_ATTR rdnAttr = { szOID_COMMON_NAME, CERT_RDN_ANY_TYPE, };
01022
01023     rdnAttr.Value.pbData = NULL;
01024
01025     DBGPRINT((fDebug, "Policy:Initialize:\n"));
01026
01027
01028     __try
01029     {
01030   _Cleanup();
01031
01032   m_strCAName = SysAllocString(strConfig);
01033   if (NULL == m_strCAName)
01034   {
01035       hr = E_OUTOFMEMORY;
01036       _LeaveError(hr, "CCertPolicySample::SysAllocString");
01037   }
01038
01039   // force loading the description from resources
01040
01041   hr = GetDescription(&bstrDescription);
01042   _LeaveIfError(hr, "CCertPolicySample::GetDescription");
01043
01044   // get server callbacks
01045
01046   hr = polGetServerCallbackInterface(&pServer, 0);
01047   _LeaveIfError(hr, "Policy:polGetServerCallbackInterface");
01048
01049   hr = ReqInitialize(pServer);
01050   _JumpIfError(hr, error, "ReqInitialize");
01051
01052
01053   // get storage location
01054   hr = polGetCertificateStringProperty(
01055             pServer,
01056             wszPROPMODULEREGLOC,
01057             &m_strRegStorageLoc);
01058   _LeaveIfErrorStr(
01059         hr,
01060         "Policy:polGetCertificateStringProperty",
01061         wszPROPMODULEREGLOC);
01062
01063
01064   // get CA type
01065
01066   hr = polGetCertificateLongProperty(
01067             pServer,
01068             wszPROPCATYPE,
01069             (LONG *) &m_CAType);
01070   _LeaveIfErrorStr(
01071         hr,
01072         "Policy:polGetCertificateLongProperty",
01073         wszPROPCATYPE);
01074
01075
01076   // get sanitized name
01077
01078   hr = polGetCertificateStringProperty(
01079             pServer,
01080             wszPROPSANITIZEDCANAME,
01081             &m_strCASanitizedName);
01082   _LeaveIfErrorStr(
01083         hr,
01084         "Policy:polGetCertificateStringProperty",
01085         wszPROPSANITIZEDCANAME);
01086
01087   // get sanitized name
01088
01089   hr = polGetCertificateStringProperty(
01090             pServer,
01091             wszPROPSANITIZEDSHORTNAME,
01092             &m_strCASanitizedDSName);
01093   _LeaveIfErrorStr(
01094         hr,
01095         "Policy:polGetCertificateStringProperty",
01096         wszPROPSANITIZEDSHORTNAME);
01097
01098   hr = polGetCertificateLongProperty(
01099             pServer,
01100             wszPROPSERVERUPGRADED,
01101             (LONG *) &fUpgraded);
01102   if (S_OK != hr)
01103   {
01104       fUpgraded = FALSE;
01105       _PrintErrorStr(
01106         hr,
01107         "Policy:polGetCertificateLongProperty",
01108         wszPROPSERVERUPGRADED);
01109   }
01110
01111   hr = RegOpenKeyEx(
01112     HKEY_LOCAL_MACHINE,
01113     m_strRegStorageLoc,
01114     0,              // dwReserved
01115     fUpgraded?
01116         KEY_ALL_ACCESS :
01117         (KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE),
01118     &hkey);
01119   _LeaveIfErrorStr(
01120         hr,
01121         "Policy:Initialize:RegOpenKeyEx",
01122         m_strRegStorageLoc);
01123
01124   // Ignore error codes.
01125
01126   dwSize = sizeof(m_dwDispositionFlags);
01127   hr = RegQueryValueEx(
01128       hkey,
01129       wszREGREQUESTDISPOSITION,
01130       0,
01131       &dwType,
01132       (BYTE *) &m_dwDispositionFlags,
01133       &dwSize);
01134   if (S_OK != hr || REG_DWORD != dwType)
01135   {
01136       m_dwDispositionFlags = REQDISP_PENDINGFIRST | REQDISP_ISSUE;
01137   }
01138   DBGPRINT((
01139       fDebug,
01140       "Disposition Flags = %x\n",
01141       m_dwDispositionFlags));
01142
01143   dwSize = sizeof(m_dwEditFlags);
01144   hr = RegQueryValueEx(
01145       hkey,
01146       wszREGEDITFLAGS,
01147       0,
01148       &dwType,
01149       (BYTE *) &m_dwEditFlags,
01150       &dwSize);
01151   if (S_OK != hr || REG_DWORD != dwType)
01152   {
01153       m_dwEditFlags =
01154         EDITF_DEFAULT_STANDALONE;
01155   }
01156   if (fUpgraded)
01157   {
01158       DBGPRINT((
01159     fDebug,
01160     "Initialize: setting EDITF_SERVERUPGRADED\n"));
01161
01162       m_dwEditFlags |= EDITF_SERVERUPGRADED;
01163       dwSize = sizeof(m_dwEditFlags);
01164       hr = RegSetValueEx(
01165           hkey,
01166           wszREGEDITFLAGS,
01167           0,
01168           REG_DWORD,
01169           (BYTE *) &m_dwEditFlags,
01170           dwSize);
01171       _PrintIfError(hr, "Policy:RegSetValueEx");
01172   }
01173   DBGPRINT((fDebug, "Edit Flags = %x\n", m_dwEditFlags));
01174
01175   dwSize = sizeof(m_CAPathLength);
01176   hr = RegQueryValueEx(
01177       hkey,
01178       wszREGCAPATHLENGTH,
01179       0,
01180       &dwType,
01181       (BYTE *) &m_CAPathLength,
01182       &dwSize);
01183   if (S_OK != hr || REG_DWORD != dwType)
01184   {
01185       m_CAPathLength = CAPATHLENGTH_INFINITE;
01186   }
01187   DBGPRINT((fDebug, "CAPathLength = %x\n", m_CAPathLength));
01188
01189
01190   // Initialize the insertion string array.
01191   // Machine DNS name (%1)
01192
01193   hr = polGetCertificateStringProperty(
01194           pServer,
01195           wszPROPMACHINEDNSNAME,
01196           &m_strMachineDNSName);
01197   _LeaveIfErrorStr(
01198         hr,
01199         "Policy:polGetCertificateStringProperty",
01200         wszPROPMACHINEDNSNAME);
01201
01202   hr = polGetCertificateLongProperty(
01203             pServer,
01204             wszPROPCERTCOUNT,
01205             (LONG *) &m_iCert);
01206   _LeaveIfErrorStr(
01207         hr,
01208         "Policy:polGetCertificateLongProperty",
01209         wszPROPCERTCOUNT);
01210
01211   if (0 == m_iCert) // no CA certs?
01212   {
01213       hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
01214       _LeaveIfErrorStr(
01215       hr,
01216       "Policy:polGetCertificateLongProperty",
01217       wszPROPCERTCOUNT);
01218   }
01219   m_iCert--;
01220
01221   hr = polGetCertificateLongProperty(
01222             pServer,
01223             wszPROPCRLINDEX,
01224             (LONG *) &m_iCRL);
01225   _LeaveIfErrorStr(
01226         hr,
01227         "Policy:polGetCertificateLongProperty",
01228         wszPROPCRLINDEX);
01229
01230   _InitRevocationExtension(hkey);
01231   _InitRequestExtensionList(hkey);
01232   _InitDisableExtensionList(hkey);
01233
01234   hr = S_OK;
01235     }
01236     __except(hr = ceHError(GetExceptionCode()), EXCEPTION_EXECUTE_HANDLER)
01237     {
01238   _PrintError(hr, "Exception");
01239     }
01240
01241 error:
01242     if (NULL != bstrDescription)
01243     {
01244         SysFreeString(bstrDescription);
01245     }
01246     if (NULL != hkey)
01247     {
01248   RegCloseKey(hkey);
01249     }
01250     if (NULL != pServer)
01251     {
01252   pServer->Release();
01253     }
01254     return(ceHError(hr)); // Reg routines return Win32 error codes
01255 }
01256
01257
01258 DWORD
01259 polFindObjIdInList(
01260     IN WCHAR const *pwsz,
01261     IN DWORD count,
01262     IN WCHAR const * const *ppwsz)
01263 {
01264     DWORD i;
01265
01266     for (i = 0; i < count; i++)
01267     {
01268   if (NULL == pwsz || NULL == ppwsz[i])
01269   {
01270       i = count;
01271       break;
01272   }
01273   if (0 == wcscmp(pwsz, ppwsz[i]))
01274   {
01275       break;
01276   }
01277     }
01278     return(i < count? i : MAXDWORD);
01279 }
01280
01281
01282 HRESULT
01283 CCertPolicySample::_EnumerateExtensions(
01284     IN ICertServerPolicy *pServer,
01285     IN LONG bNewRequest,
01286     IN BOOL fFirstPass,
01287     IN BOOL fEnableEnrolleeExtensions,
01288     IN DWORD cCriticalExtensions,
01289     OPTIONAL IN WCHAR const * const *apwszCriticalExtensions)
01290 {
01291     HRESULT hr;
01292     HRESULT hr2;
01293     BSTR strName = NULL;
01294     LONG ExtFlags;
01295     VARIANT varValue;
01296     BOOL fClose = FALSE;
01297     BOOL fEnable;
01298     BOOL fDisable;
01299     BOOL fCritical;
01300
01301     VariantInit(&varValue);
01302
01303     hr = pServer->EnumerateExtensionsSetup(0);
01304     _JumpIfError(hr, error, "Policy:EnumerateExtensionsSetup");
01305
01306     fClose = TRUE;
01307     while (TRUE)
01308     {
01309         hr = pServer->EnumerateExtensions(&strName);
01310         if (S_FALSE == hr)
01311         {
01312             hr = S_OK;
01313             break;
01314         }
01315         _JumpIfError(hr, error, "Policy:EnumerateExtensions");
01316
01317         hr = pServer->GetCertificateExtension(
01318                                         strName,
01319                                         PROPTYPE_BINARY,
01320                                         &varValue);
01321         _JumpIfError(hr, error, "Policy:GetCertificateExtension");
01322
01323         hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
01324   _JumpIfError(hr, error, "Policy:GetCertificateExtensionFlags");
01325
01326   fEnable = FALSE;
01327   fDisable = FALSE;
01328   fCritical = FALSE;
01329
01330         if (fFirstPass)
01331         {
01332             if (bNewRequest && (EXTENSION_DISABLE_FLAG & ExtFlags))
01333             {
01334                 switch (EXTENSION_ORIGIN_MASK & ExtFlags)
01335                 {
01336                     case EXTENSION_ORIGIN_REQUEST:
01337                     case EXTENSION_ORIGIN_RENEWALCERT:
01338                     case EXTENSION_ORIGIN_PKCS7:
01339                     case EXTENSION_ORIGIN_CMC:
01340                     if ((EDITF_ENABLEREQUESTEXTENSIONS & m_dwEditFlags) ||
01341       MAXDWORD != polFindObjIdInList(
01342             strName,
01343             m_cEnableRequestExtensions,
01344             m_apwszEnableRequestExtensions) ||
01345       (fEnableEnrolleeExtensions &&
01346        MAXDWORD != polFindObjIdInList(
01347             strName,
01348             m_cEnableEnrolleeRequestExtensions,
01349             m_apwszEnableEnrolleeRequestExtensions)))
01350                     {
01351       ExtFlags &= ~EXTENSION_DISABLE_FLAG;
01352       fEnable = TRUE;
01353                     }
01354                     break;
01355                 }
01356             }
01357         }
01358         else
01359         {
01360             if (0 == (EXTENSION_DISABLE_FLAG & ExtFlags) &&
01361     MAXDWORD != polFindObjIdInList(
01362             strName,
01363             m_cDisableExtensions,
01364             m_apwszDisableExtensions))
01365             {
01366                 ExtFlags |= EXTENSION_DISABLE_FLAG;
01367                 fDisable = TRUE;
01368             }
01369             if (0 == (EXTENSION_CRITICAL_FLAG & ExtFlags) &&
01370     MAXDWORD != polFindObjIdInList(
01371             strName,
01372             cCriticalExtensions,
01373             apwszCriticalExtensions))
01374             {
01375                 ExtFlags |= EXTENSION_CRITICAL_FLAG;
01376                 fCritical = TRUE;
01377             }
01378         }
01379
01380         if (fDisable || fEnable)
01381         {
01382             hr = pServer->SetCertificateExtension(
01383                   strName,
01384                   PROPTYPE_BINARY,
01385                   ExtFlags,
01386                   &varValue);
01387             _JumpIfError(hr, error, "Policy:SetCertificateExtension");
01388         }
01389
01390         if (fFirstPass || fDisable || fEnable)
01391         {
01392       DBGPRINT((
01393     fDebug,
01394                 "Policy:EnumerateExtensions(%ws, Flags=%x, %x bytes)%hs%hs\n",
01395                 strName,
01396                 ExtFlags,
01397                 SysStringByteLen(varValue.bstrVal),
01398     fDisable? " DISABLING" : (fEnable? " ENABLING" : ""),
01399     fCritical? " +CRITICAL" : ""));
01400         }
01401   if (NULL != strName)
01402   {
01403       SysFreeString(strName);
01404       strName = NULL;
01405   }
01406         VariantClear(&varValue);
01407     }
01408
01409 error:
01410     if (fClose)
01411     {
01412         hr2 = pServer->EnumerateExtensionsClose();
01413         if (S_OK != hr2)
01414         {
01415             if (S_OK == hr)
01416             {
01417                 hr = hr2;
01418             }
01419       _PrintError(hr2, "Policy:EnumerateExtensionsClose");
01420         }
01421     }
01422     if (NULL != strName)
01423     {
01424         SysFreeString(strName);
01425     }
01426     VariantClear(&varValue);
01427     return(hr);
01428 }
01429
01430
01431 HRESULT
01432 EnumerateAttributes(
01433     IN ICertServerPolicy *pServer)
01434 {
01435     HRESULT hr;
01436     HRESULT hr2;
01437     BSTR strName = NULL;
01438     BOOL fClose = FALSE;
01439     BSTR strValue = NULL;
01440
01441     hr = pServer->EnumerateAttributesSetup(0);
01442     _JumpIfError(hr, error, "Policy:EnumerateAttributesSetup");
01443
01444     fClose = TRUE;
01445     while (TRUE)
01446     {
01447         hr = pServer->EnumerateAttributes(&strName);
01448   if (S_FALSE == hr)
01449   {
01450       hr = S_OK;
01451       break;
01452   }
01453   _JumpIfError(hr, error, "Policy:EnumerateAttributes");
01454
01455         hr = pServer->GetRequestAttribute(strName, &strValue);
01456   _JumpIfError(hr, error, "Policy:GetRequestAttribute");
01457
01458   DBGPRINT((
01459     fDebug,
01460                 "Policy:EnumerateAttributes(%ws = %ws)\n",
01461                 strName,
01462                 strValue));
01463         if (NULL != strName)
01464         {
01465             SysFreeString(strName);
01466             strName = NULL;
01467         }
01468         if (NULL != strValue)
01469         {
01470             SysFreeString(strValue);
01471             strValue = NULL;
01472         }
01473     }
01474
01475 error:
01476     if (fClose)
01477     {
01478         hr2 = pServer->EnumerateAttributesClose();
01479         if (S_OK != hr2)
01480         {
01481       _PrintError(hr2, "Policy:EnumerateAttributesClose");
01482             if (S_OK == hr)
01483             {
01484                 hr = hr2;
01485             }
01486         }
01487     }
01488     if (NULL != strName)
01489     {
01490         SysFreeString(strName);
01491     }
01492     if (NULL != strValue)
01493     {
01494         SysFreeString(strValue);
01495     }
01496     return(hr);
01497 }
01498
01499
01500 HRESULT
01501 GetRequestId(
01502     IN ICertServerPolicy *pServer,
01503     OUT LONG *plRequestId)
01504 {
01505     HRESULT hr;
01506
01507     hr = polGetRequestLongProperty(pServer, wszPROPREQUESTREQUESTID, plRequestId);
01508     _JumpIfError(hr, error, "Policy:polGetRequestLongProperty");
01509
01510     DBGPRINT((
01511   fDebug,
01512   "Policy:GetRequestId(%ws = %u)\n",
01513   wszPROPREQUESTREQUESTID,
01514   *plRequestId));
01515
01516 error:
01517     return(hr);
01518 }
01519
01520
01521 //+--------------------------------------------------------------------------
01522 // CCertPolicySample::_AddRevocationExtension
01523 //
01524 // Returns S_OK on success.
01525 //+--------------------------------------------------------------------------
01526
01527 HRESULT
01528 CCertPolicySample::_AddRevocationExtension(
01529     IN ICertServerPolicy *pServer)
01530 {
01531     HRESULT hr = S_OK;
01532     BSTR strASPExtension = NULL;
01533     VARIANT varExtension;
01534
01535     if (NULL != m_wszASPRevocationURL)
01536     {
01537   strASPExtension = SysAllocString(m_wszASPRevocationURL);
01538   if (NULL == strASPExtension)
01539   {
01540       hr = E_OUTOFMEMORY;
01541       _JumpError(hr, error, "Policy:SysAllocString");
01542   }
01543
01544   varExtension.vt = VT_BSTR;
01545   varExtension.bstrVal = strASPExtension;
01546   hr = polSetCertificateExtension(
01547         pServer,
01548         TEXT(szOID_NETSCAPE_REVOCATION_URL),
01549         PROPTYPE_STRING,
01550         0,
01551         &varExtension);
01552   _JumpIfErrorStr(hr, error, "Policy:polSetCertificateExtension", L"ASP");
01553     }
01554
01555 error:
01556     if (NULL != strASPExtension)
01557     {
01558         SysFreeString(strASPExtension);
01559     }
01560     return(hr);
01561 }
01562
01563
01564 #define HIGHBIT(bitno)  (1 << (7 - (bitno)))  // bit counted from high end
01565
01566 #define SSLBIT_CLIENT ((BYTE) HIGHBIT(0)) // certified for client auth
01567 #define SSLBIT_SERVER ((BYTE) HIGHBIT(1)) // certified for server auth
01568 #define SSLBIT_SMIME  ((BYTE) HIGHBIT(2)) // certified for S/MIME
01569 #define SSLBIT_SIGN ((BYTE) HIGHBIT(3)) // certified for signing
01570
01571 #define SSLBIT_RESERVED ((BYTE) HIGHBIT(4)) // reserved for future use
01572
01573 #define SSLBIT_CASSL  ((BYTE) HIGHBIT(5)) // CA for SSL auth certs
01574 #define SSLBIT_CASMIME  ((BYTE) HIGHBIT(6)) // CA for S/MIME certs
01575 #define SSLBIT_CASIGN ((BYTE) HIGHBIT(7)) // CA for signing certs
01576
01577 #define NSCERTTYPE_CLIENT  ((BYTE) SSLBIT_CLIENT)
01578 #define NSCERTTYPE_SERVER  ((BYTE) (SSLBIT_SERVER | SSLBIT_CLIENT))
01579 #define NSCERTTYPE_SMIME   ((BYTE) SSLBIT_SMIME)
01580 #define NSCERTTYPE_CA    ((BYTE) (SSLBIT_CASSL | SSLBIT_CASMIME | SSLBIT_CASIGN))
01581
01582 //+--------------------------------------------------------------------------
01583 // CCertPolicySample::_AddOldCertTypeExtension
01584 //
01585 // Returns S_OK on success.
01586 //+--------------------------------------------------------------------------
01587
01588 HRESULT
01589 CCertPolicySample::_AddOldCertTypeExtension(
01590     IN ICertServerPolicy *pServer,
01591     IN BOOL fCA)
01592 {
01593     HRESULT hr = S_OK;
01594     ICertEncodeBitString *pBitString = NULL;
01595     BSTR strExtension = NULL;
01596     VARIANT varExtension;
01597     BSTR strBitString = NULL;
01598     BSTR strCertType = NULL;
01599     CERT_BASIC_CONSTRAINTS2_INFO Constraints;
01600     VARIANT varConstraints;
01601     DWORD cb;
01602
01603     VariantInit(&varConstraints);
01604
01605     if (EDITF_ADDOLDCERTTYPE & m_dwEditFlags)
01606     {
01607   BYTE CertType;
01608
01609   if (!fCA)
01610   {
01611       hr = polGetCertificateExtension(
01612             pServer,
01613             TEXT(szOID_BASIC_CONSTRAINTS2),
01614             PROPTYPE_BINARY,
01615             &varConstraints);
01616       if (S_OK == hr)
01617       {
01618     cb = sizeof(Constraints);
01619     if (!CryptDecodeObject(
01620             X509_ASN_ENCODING,
01621             X509_BASIC_CONSTRAINTS2,
01622             (BYTE const *) varConstraints.bstrVal,
01623             SysStringByteLen(varConstraints.bstrVal),
01624             0,
01625             &Constraints,
01626             &cb))
01627     {
01628         hr = ceHLastError();
01629         _JumpError(hr, error, "Policy:CryptDecodeObject");
01630     }
01631     fCA = Constraints.fCA;
01632       }
01633   }
01634
01635   hr = CoCreateInstance(
01636       CLSID_CCertEncodeBitString,
01637       NULL,               // pUnkOuter
01638       CLSCTX_INPROC_SERVER,
01639       IID_ICertEncodeBitString,
01640       (VOID **) &pBitString);
01641   _JumpIfError(hr, error, "Policy:CoCreateInstance");
01642
01643   CertType = NSCERTTYPE_CLIENT; // Default to client auth. cert
01644   if (fCA)
01645   {
01646       CertType = NSCERTTYPE_CA;
01647   }
01648   else
01649   {
01650       hr = polGetRequestAttribute(pServer, wszPROPCERTTYPE, &strCertType);
01651       if (S_OK == hr)
01652       {
01653     if (0 == celstrcmpiL(strCertType, L"server"))
01654     {
01655         CertType = NSCERTTYPE_SERVER;
01656     }
01657       }
01658   }
01659
01660         if (!ceConvertWszToBstr(
01661         &strBitString,
01662         (WCHAR const *) &CertType,
01663         sizeof(CertType)))
01664   {
01665       hr = E_OUTOFMEMORY;
01666       _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01667   }
01668
01669   hr = pBitString->Encode(
01670           sizeof(CertType) * 8,
01671           strBitString,
01672           &strExtension);
01673   _JumpIfError(hr, error, "Policy:BitString:Encode");
01674
01675         varExtension.vt = VT_BSTR;
01676   varExtension.bstrVal = strExtension;
01677   hr = polSetCertificateExtension(
01678         pServer,
01679         TEXT(szOID_NETSCAPE_CERT_TYPE),
01680         PROPTYPE_BINARY,
01681         0,
01682         &varExtension);
01683   _JumpIfError(hr, error, "Policy:polSetCertificateExtension");
01684     }
01685
01686 error:
01687     VariantClear(&varConstraints);
01688     if (NULL != strExtension)
01689     {
01690         SysFreeString(strExtension);
01691     }
01692     if (NULL != strBitString)
01693     {
01694         SysFreeString(strBitString);
01695     }
01696     if (NULL != strCertType)
01697     {
01698         SysFreeString(strCertType);
01699     }
01700     if (NULL != pBitString)
01701     {
01702         pBitString->Release();
01703     }
01704     return(hr);
01705 }
01706
01707
01708 //+--------------------------------------------------------------------------
01709 // CCertPolicySample::_AddAuthorityKeyId
01710 //
01711 // Returns S_OK on success.
01712 //+--------------------------------------------------------------------------
01713
01714 HRESULT
01715 CCertPolicySample::_AddAuthorityKeyId(
01716     IN ICertServerPolicy *pServer)
01717 {
01718     HRESULT hr = S_OK;
01719     BYTE *pbEncoded = NULL;
01720     DWORD cbEncoded;
01721     BSTR strExtension = NULL;
01722     VARIANT varExtension;
01723     VARIANT varExtensionT;
01724     PCERT_AUTHORITY_KEY_ID2_INFO pInfo = NULL;
01725     DWORD cbInfo = 0;
01726     LONG ExtFlags = 0;
01727
01728     VariantInit(&varExtension);
01729
01730     // Optimization
01731
01732     if ((EDITF_ENABLEAKIKEYID |
01733    EDITF_ENABLEAKIISSUERNAME |
01734    EDITF_ENABLEAKIISSUERSERIAL) ==
01735   ((EDITF_ENABLEAKIKEYID |
01736     EDITF_ENABLEAKIISSUERNAME |
01737     EDITF_ENABLEAKIISSUERSERIAL |
01738     EDITF_ENABLEAKICRITICAL) & m_dwEditFlags))
01739     {
01740         goto error;
01741     }
01742
01743     hr = polGetCertificateExtension(
01744           pServer,
01745           TEXT(szOID_AUTHORITY_KEY_IDENTIFIER2),
01746           PROPTYPE_BINARY,
01747           &varExtension);
01748     _JumpIfError(hr, error, "Policy:polGetCertificateExtension");
01749
01750     hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
01751     _JumpIfError(hr, error, "Policy:GetCertificateExtensionFlags");
01752
01753     if (VT_BSTR != varExtension.vt)
01754     {
01755   hr = E_INVALIDARG;
01756   _JumpError(hr, error, "Policy:GetCertificateExtension");
01757     }
01758
01759     cbInfo = 0;
01760     if (!ceDecodeObject(
01761         X509_ASN_ENCODING,
01762                     X509_AUTHORITY_KEY_ID2,
01763                     (BYTE *) varExtension.bstrVal,
01764                     SysStringByteLen(varExtension.bstrVal),
01765         FALSE,
01766                     (VOID **) &pInfo,
01767                     &cbInfo))
01768     {
01769   hr = ceHLastError();
01770   _JumpIfError(hr, error, "Policy:ceDecodeObject");
01771     }
01772
01773     // Make Any Modifications Here
01774
01775     if (0 == (EDITF_ENABLEAKIKEYID & m_dwEditFlags))
01776     {
01777         pInfo->KeyId.cbData = 0;
01778         pInfo->KeyId.pbData = NULL;
01779     }
01780     if (0 == (EDITF_ENABLEAKIISSUERNAME & m_dwEditFlags))
01781     {
01782         pInfo->AuthorityCertIssuer.cAltEntry = 0;
01783         pInfo->AuthorityCertIssuer.rgAltEntry = NULL;
01784     }
01785     if (0 == (EDITF_ENABLEAKIISSUERSERIAL & m_dwEditFlags))
01786     {
01787         pInfo->AuthorityCertSerialNumber.cbData = 0;
01788         pInfo->AuthorityCertSerialNumber.pbData = NULL;
01789     }
01790     if (EDITF_ENABLEAKICRITICAL & m_dwEditFlags)
01791     {
01792   ExtFlags |= EXTENSION_CRITICAL_FLAG;
01793     }
01794     if (0 ==
01795   ((EDITF_ENABLEAKIKEYID |
01796     EDITF_ENABLEAKIISSUERNAME |
01797     EDITF_ENABLEAKIISSUERSERIAL) & m_dwEditFlags))
01798     {
01799   ExtFlags |= EXTENSION_DISABLE_FLAG;
01800     }
01801
01802     if (!ceEncodeObject(
01803         X509_ASN_ENCODING,
01804         X509_AUTHORITY_KEY_ID2,
01805         pInfo,
01806         0,
01807         FALSE,
01808         &pbEncoded,
01809         &cbEncoded))
01810     {
01811   hr = ceHLastError();
01812   _JumpError(hr, error, "Policy:ceEncodeObject");
01813     }
01814     if (!ceConvertWszToBstr(
01815       &strExtension,
01816       (WCHAR const *) pbEncoded,
01817       cbEncoded))
01818     {
01819   hr = E_OUTOFMEMORY;
01820   _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01821     }
01822
01823     varExtensionT.vt = VT_BSTR;
01824     varExtensionT.bstrVal = strExtension;
01825     hr = polSetCertificateExtension(
01826           pServer,
01827           TEXT(szOID_AUTHORITY_KEY_IDENTIFIER2),
01828           PROPTYPE_BINARY,
01829           ExtFlags,
01830           &varExtensionT);
01831     _JumpIfError(hr, error, "Policy:polSetCertificateExtension(AuthorityKeyId2)");
01832
01833 error:
01834     VariantClear(&varExtension);
01835     if (NULL != pInfo)
01836     {
01837   LocalFree(pInfo);
01838     }
01839     if (NULL != pbEncoded)
01840     {
01841   LocalFree(pbEncoded);
01842     }
01843     if (NULL != strExtension)
01844     {
01845         SysFreeString(strExtension);
01846     }
01847     return(hr);
01848 }
01849
01850
01851 //+--------------------------------------------------------------------------
01852 // CCertPolicy::_AddDefaultKeyUsageExtension
01853 //
01854 // Returns S_OK on success.
01855 //+--------------------------------------------------------------------------
01856
01857 HRESULT
01858 CCertPolicySample::_AddDefaultKeyUsageExtension(
01859     IN ICertServerPolicy *pServer,
01860     IN BOOL fCA)
01861 {
01862     HRESULT hr;
01863     BSTR strName = NULL;
01864     ICertEncodeBitString *pBitString = NULL;
01865     BSTR strExtension = NULL;
01866     VARIANT varExtension;
01867     BSTR strBitString = NULL;
01868     CERT_BASIC_CONSTRAINTS2_INFO Constraints;
01869     VARIANT varConstraints;
01870     VARIANT varKeyUsage;
01871     CRYPT_BIT_BLOB *pKeyUsage = NULL;
01872     DWORD cb;
01873     BYTE abKeyUsage[1];
01874     BYTE *pbKeyUsage;
01875     DWORD cbKeyUsage;
01876
01877     VariantInit(&varConstraints);
01878     VariantInit(&varKeyUsage);
01879
01880     if (EDITF_ADDOLDKEYUSAGE & m_dwEditFlags)
01881     {
01882   BOOL fModified = FALSE;
01883
01884   if (!fCA)
01885   {
01886       hr = polGetCertificateExtension(
01887             pServer,
01888             TEXT(szOID_BASIC_CONSTRAINTS2),
01889             PROPTYPE_BINARY,
01890             &varConstraints);
01891       if (S_OK == hr)
01892       {
01893     cb = sizeof(Constraints);
01894     if (!CryptDecodeObject(
01895             X509_ASN_ENCODING,
01896             X509_BASIC_CONSTRAINTS2,
01897             (BYTE const *) varConstraints.bstrVal,
01898             SysStringByteLen(varConstraints.bstrVal),
01899             0,
01900             &Constraints,
01901             &cb))
01902     {
01903         hr = ceHLastError();
01904         _JumpError(hr, error, "Policy:CryptDecodeObject");
01905     }
01906     fCA = Constraints.fCA;
01907       }
01908   }
01909
01910   ZeroMemory(abKeyUsage, sizeof(abKeyUsage));
01911   pbKeyUsage = abKeyUsage;
01912   cbKeyUsage = sizeof(abKeyUsage);
01913
01914   hr = polGetCertificateExtension(
01915         pServer,
01916         TEXT(szOID_KEY_USAGE),
01917         PROPTYPE_BINARY,
01918         &varKeyUsage);
01919   if (S_OK == hr)
01920   {
01921       if (!ceDecodeObject(
01922           X509_ASN_ENCODING,
01923           X509_KEY_USAGE,
01924           (BYTE const *) varKeyUsage.bstrVal,
01925           SysStringByteLen(varKeyUsage.bstrVal),
01926           FALSE,
01927           (VOID **) &pKeyUsage,
01928           &cb))
01929       {
01930     hr = GetLastError();
01931     _PrintError(hr, "Policy:ceDecodeObject");
01932       }
01933       else if (0 != cb && NULL != pKeyUsage && 0 != pKeyUsage->cbData)
01934       {
01935     pbKeyUsage = pKeyUsage->pbData;
01936     cbKeyUsage = pKeyUsage->cbData;
01937       }
01938   }
01939
01940   if ((CERT_KEY_ENCIPHERMENT_KEY_USAGE & pbKeyUsage[0]) &&
01941       (CERT_KEY_AGREEMENT_KEY_USAGE & pbKeyUsage[0]))
01942   {
01943       pbKeyUsage[0] &= ~CERT_KEY_AGREEMENT_KEY_USAGE;
01944       pbKeyUsage[0] |= CERT_DIGITAL_SIGNATURE_KEY_USAGE;
01945       fModified = TRUE;
01946   }
01947   if (fCA)
01948   {
01949       pbKeyUsage[0] |= ceCASIGN_KEY_USAGE;
01950       fModified = TRUE;
01951   }
01952   if (fModified)
01953   {
01954       hr = CoCreateInstance(
01955           CLSID_CCertEncodeBitString,
01956           NULL,               // pUnkOuter
01957           CLSCTX_INPROC_SERVER,
01958           IID_ICertEncodeBitString,
01959           (VOID **) &pBitString);
01960       _JumpIfError(hr, error, "Policy:CoCreateInstance");
01961
01962       if (!ceConvertWszToBstr(
01963       &strBitString,
01964       (WCHAR const *) pbKeyUsage,
01965       cbKeyUsage))
01966       {
01967     hr = E_OUTOFMEMORY;
01968     _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01969       }
01970
01971       hr = pBitString->Encode(cbKeyUsage * 8, strBitString, &strExtension);
01972       _JumpIfError(hr, error, "Policy:Encode");
01973
01974       if (!ceConvertWszToBstr(&strName, TEXT(szOID_KEY_USAGE), -1))
01975       {
01976     hr = E_OUTOFMEMORY;
01977     _JumpError(hr, error, "Policy:ceConvertWszToBstr");
01978       }
01979       varExtension.vt = VT_BSTR;
01980       varExtension.bstrVal = strExtension;
01981       hr = pServer->SetCertificateExtension(
01982             strName,
01983             PROPTYPE_BINARY,
01984             0,
01985             &varExtension);
01986       _JumpIfError(hr, error, "Policy:SetCertificateExtension");
01987   }
01988     }
01989     hr = S_OK;
01990
01991 error:
01992     VariantClear(&varConstraints);
01993     VariantClear(&varKeyUsage);
01994     if (NULL != pKeyUsage)
01995     {
01996         LocalFree(pKeyUsage);
01997     }
01998     if (NULL != strName)
01999     {
02000         SysFreeString(strName);
02001     }
02002     if (NULL != strExtension)
02003     {
02004         SysFreeString(strExtension);
02005     }
02006     if (NULL != strBitString)
02007     {
02008         SysFreeString(strBitString);
02009     }
02010     if (NULL != pBitString)
02011     {
02012         pBitString->Release();
02013     }
02014     return(hr);
02015 }
02016
02017
02018 HRESULT
02019 CCertPolicySample::_AddEnhancedKeyUsageExtension(
02020     IN ICertServerPolicy *pServer)
02021 {
02022     HRESULT hr;
02023     BSTR strUsage = NULL;
02024     char *pszUsage = NULL;
02025     char *psz;
02026     char *pszNext;
02027     CERT_ENHKEY_USAGE ceu;
02028     CERT_POLICIES_INFO cpi;
02029     BYTE *pbKeyUsage = NULL;
02030     DWORD cbKeyUsage;
02031     BYTE *pbPolicies = NULL;
02032     DWORD cbPolicies;
02033     CERT_POLICY_INFO *pcpi = NULL;
02034     DWORD i;
02035     VARIANT varExtension;
02036
02037     ZeroMemory(&ceu, sizeof(ceu));
02038     ZeroMemory(&cpi, sizeof(cpi));
02039     VariantInit(&varExtension);
02040
02041     if (0 == (EDITF_ATTRIBUTEEKU & m_dwEditFlags))
02042     {
02043   hr = S_OK;
02044   goto error;
02045     }
02046     hr = polGetRequestAttribute(pServer, wszPROPCERTUSAGE, &strUsage);
02047     if (S_OK != hr)
02048     {
02049   hr = S_OK;
02050   goto error;
02051     }
02052     if (!ceConvertWszToSz(&pszUsage, strUsage, -1))
02053     {
02054   hr = E_OUTOFMEMORY;
02055   _JumpError(hr, error, "Policy:ceConvertWszToSz");
02056     }
02057     for (psz = pszUsage; '\0' != *psz; psz = pszNext)
02058     {
02059   pszNext = &psz[strcspn(psz, ",")];
02060   if ('\0' != *pszNext)
02061   {
02062       pszNext++;
02063   }
02064   ceu.cUsageIdentifier++;
02065     }
02066     if (0 == ceu.cUsageIdentifier)
02067     {
02068   hr = S_OK;
02069   goto error;
02070     }
02071
02072     ceu.rgpszUsageIdentifier = (char **) LocalAlloc(
02073     LMEM_FIXED,
02074     ceu.cUsageIdentifier * sizeof(ceu.rgpszUsageIdentifier[0]));
02075     if (NULL == ceu.rgpszUsageIdentifier)
02076     {
02077   hr = E_OUTOFMEMORY;
02078   _JumpError(hr, error, "Policy:myLocalAlloc");
02079     }
02080
02081     // Destructively parse comma separated ObjIds into individual strings
02082
02083     i = 0;
02084     for (psz = pszUsage; '\0' != *psz; psz = pszNext)
02085     {
02086   char *pszEnd;
02087
02088   assert(i < ceu.cUsageIdentifier);
02089   pszNext = &psz[strcspn(psz, ",")];
02090   pszEnd = pszNext;
02091   if ('\0' != *pszNext)
02092   {
02093       *pszNext++ = '\0';
02094   }
02095   while (' ' == *psz)
02096   {
02097       psz++;
02098   }
02099   while (pszEnd > psz && ' ' == *--pszEnd)
02100   {
02101       *pszEnd = '\0';
02102   }
02103   if ('\0' != *psz)
02104   {
02105       hr = ceVerifyObjIdA(psz);
02106       _JumpIfError(hr, error, "Policy:ceVerifyObjIdA");
02107
02108       ceu.rgpszUsageIdentifier[i++] = psz;
02109   }
02110     }
02111     ceu.cUsageIdentifier = i;
02112     if (0 == ceu.cUsageIdentifier)
02113     {
02114   hr = S_OK;
02115   goto error;
02116     }
02117
02118     if (!ceEncodeObject(
02119         X509_ASN_ENCODING,
02120         X509_ENHANCED_KEY_USAGE,
02121         &ceu,
02122         0,
02123         FALSE,
02124         &pbKeyUsage,
02125         &cbKeyUsage))
02126     {
02127   hr = ceHLastError();
02128   _JumpError(hr, error, "Policy:ceEncodeObject");
02129     }
02130
02131     varExtension.bstrVal = NULL;
02132     if (!ceConvertWszToBstr(
02133       &varExtension.bstrVal,
02134       (WCHAR const *) pbKeyUsage,
02135       cbKeyUsage))
02136     {
02137         hr = E_OUTOFMEMORY;
02138         _JumpError(hr, error, "Policy:ceConvertWszToBstr");
02139     }
02140     varExtension.vt = VT_BSTR;
02141     hr = polSetCertificateExtension(
02142           pServer,
02143           TEXT(szOID_ENHANCED_KEY_USAGE),
02144           PROPTYPE_BINARY,
02145           0,
02146           &varExtension);
02147     _JumpIfError(hr, error, "Policy:polSetCertificateExtension");
02148
02149     cpi.cPolicyInfo = ceu.cUsageIdentifier;
02150     cpi.rgPolicyInfo = (CERT_POLICY_INFO *) LocalAlloc(
02151           LMEM_FIXED | LMEM_ZEROINIT,
02152           cpi.cPolicyInfo * sizeof(cpi.rgPolicyInfo[0]));
02153     if (NULL == cpi.rgPolicyInfo)
02154     {
02155         hr = E_OUTOFMEMORY;
02156         _JumpError(hr, error, "Policy:LocalAlloc");
02157     }
02158     for (i = 0; i < cpi.cPolicyInfo; i++)
02159     {
02160   cpi.rgPolicyInfo[i].pszPolicyIdentifier = ceu.rgpszUsageIdentifier[i];
02161     }
02162     if (!ceEncodeObject(
02163         X509_ASN_ENCODING,
02164         X509_CERT_POLICIES,
02165         &cpi,
02166         0,
02167         FALSE,
02168         &pbPolicies,
02169         &cbPolicies))
02170     {
02171   hr = ceHLastError();
02172   _JumpError(hr, error, "Policy:ceEncodeObject");
02173     }
02174
02175     if (!ceConvertWszToBstr(
02176       &varExtension.bstrVal,
02177       (WCHAR const *) pbPolicies,
02178       cbPolicies))
02179     {
02180         hr = E_OUTOFMEMORY;
02181         _JumpError(hr, error, "Policy:ceConvertWszToBstr");
02182     }
02183     hr = polSetCertificateExtension(
02184           pServer,
02185           TEXT(szOID_APPLICATION_CERT_POLICIES),
02186           PROPTYPE_BINARY,
02187           0,
02188           &varExtension);
02189     _JumpIfError(hr, error, "Policy:polSetCertificateExtension");
02190
02191 error:
02192     if (NULL != pcpi)
02193     {
02194   LocalFree(pcpi);
02195     }
02196     VariantClear(&varExtension);
02197     if (NULL != ceu.rgpszUsageIdentifier)
02198     {
02199   LocalFree(ceu.rgpszUsageIdentifier);
02200     }
02201     if (NULL != pbPolicies)
02202     {
02203   LocalFree(pbPolicies);
02204     }
02205     if (NULL != pbKeyUsage)
02206     {
02207   LocalFree(pbKeyUsage);
02208     }
02209     if (NULL != pszUsage)
02210     {
02211   LocalFree(pszUsage);
02212     }
02213     if (NULL != strUsage)
02214     {
02215   SysFreeString(strUsage);
02216     }
02217     return(hr);
02218 }
02219
02220
02221 //+--------------------------------------------------------------------------
02222 // CCertPolicy::_AddDefaultBasicConstraintsExtension
02223 //
02224 // Returns S_OK on success.
02225 //+--------------------------------------------------------------------------
02226
02227 HRESULT
02228 CCertPolicySample::_AddDefaultBasicConstraintsExtension(
02229     IN ICertServerPolicy *pServer,
02230     IN BOOL               fCA)
02231 {
02232     HRESULT hr;
02233     VARIANT varExtension;
02234     LONG ExtFlags;
02235     CERT_EXTENSION Ext;
02236     CERT_EXTENSION *pExtension = NULL;
02237     BSTR strCertType = NULL;
02238
02239     VariantInit(&varExtension);
02240
02241     if (EDITF_BASICCONSTRAINTSCA & m_dwEditFlags)
02242     {
02243         hr = polGetCertificateExtension(
02244         pServer,
02245         TEXT(szOID_BASIC_CONSTRAINTS2),
02246         PROPTYPE_BINARY,
02247         &varExtension);
02248         if (S_OK == hr)
02249         {
02250       CERT_BASIC_CONSTRAINTS2_INFO Constraints;
02251       DWORD cb;
02252
02253       hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
02254       if (S_OK == hr)
02255       {
02256                 Ext.pszObjId = szOID_BASIC_CONSTRAINTS2;
02257                 Ext.fCritical = FALSE;
02258                 if (EXTENSION_CRITICAL_FLAG & ExtFlags)
02259                 {
02260                     Ext.fCritical = TRUE;
02261                 }
02262                 Ext.Value.pbData = (BYTE *) varExtension.bstrVal;
02263                 Ext.Value.cbData = SysStringByteLen(varExtension.bstrVal);
02264     pExtension = &Ext;
02265
02266     cb = sizeof(Constraints);
02267     if (!fCA && CryptDecodeObject(
02268               X509_ASN_ENCODING,
02269               X509_BASIC_CONSTRAINTS2,
02270               Ext.Value.pbData,
02271               Ext.Value.cbData,
02272               0,
02273               &Constraints,
02274               &cb))
02275     {
02276         fCA = Constraints.fCA;
02277     }
02278       }
02279   }
02280     }
02281
02282     if (EDITF_ATTRIBUTECA & m_dwEditFlags)
02283     {
02284         if (!fCA)
02285         {
02286       hr = polGetRequestAttribute(pServer, wszPROPCERTTYPE, &strCertType);
02287             if (S_OK == hr)
02288             {
02289                 if (0 == celstrcmpiL(strCertType, L"ca"))
02290                 {
02291                     fCA = TRUE;
02292                 }
02293             }
02294         }
02295         if (!fCA)
02296         {
02297       hr = polGetRequestAttribute(pServer, wszPROPCERTTEMPLATE, &strCertType);
02298             if (S_OK == hr)
02299             {
02300                 if (0 == celstrcmpiL(strCertType, wszCERTTYPE_SUBORDINATE_CA) ||
02301         0 == celstrcmpiL(strCertType, wszCERTTYPE_CROSS_CA))
02302                 {
02303                     fCA = TRUE;
02304                 }
02305             }
02306   }
02307     }
02308
02309     // For standalone, the extension is only enabled if it's a CA
02310
02311     hr = AddBasicConstraintsCommon(pServer, pExtension, fCA, fCA);
02312     _JumpIfError(hr, error, "Policy:AddBasicConstraintsCommon");
02313
02314 error:
02315     VariantClear(&varExtension);
02316     if (NULL != strCertType)
02317     {
02318         SysFreeString(strCertType);
02319     }
02320     return(hr);
02321 }
02322
02323
02324 HRESULT
02325 CCertPolicySample::AddBasicConstraintsCommon(
02326     IN ICertServerPolicy *pServer,
02327     IN CERT_EXTENSION const *pExtension,
02328     IN BOOL fCA,
02329     IN BOOL fEnableExtension)
02330 {
02331     HRESULT hr;
02332     BSTR strExtension = NULL;
02333     VARIANT varExtension;
02334     CERT_CONTEXT const *pIssuerCert;
02335     CERT_EXTENSION *pIssuerExtension;
02336     LONG ExtFlags = 0;
02337     BYTE *pbConstraints = NULL;
02338     CERT_BASIC_CONSTRAINTS2_INFO Constraints;
02339     CERT_BASIC_CONSTRAINTS2_INFO IssuerConstraints;
02340     ZeroMemory(&IssuerConstraints, sizeof(IssuerConstraints));
02341
02342     DWORD cb;
02343
02344     pIssuerCert = _GetIssuer(pServer);
02345     if (NULL == pIssuerCert)
02346     {
02347         hr = E_POINTER;
02348         _JumpError(hr, error, "_GetIssuer");
02349     }
02350
02351     if (NULL != pExtension)
02352     {
02353         cb = sizeof(Constraints);
02354         if (!CryptDecodeObject(
02355       X509_ASN_ENCODING,
02356       X509_BASIC_CONSTRAINTS2,
02357       pExtension->Value.pbData,
02358       pExtension->Value.cbData,
02359       0,
02360       &Constraints,
02361       &cb))
02362         {
02363       hr = ceHLastError();
02364       _JumpError(hr, error, "Policy:CryptDecodeObject");
02365         }
02366
02367         // Cert templates use CAPATHLENGTH_INFINITE to indicate
02368         // fPathLenConstraint should be FALSE.
02369
02370         if (CAPATHLENGTH_INFINITE == Constraints.dwPathLenConstraint)
02371         {
02372
02373             // NOTE: This is ok as certcli already sets fPathLenConstraint to FALSE
02374             // for templates in this case.
02375       Constraints.fPathLenConstraint = FALSE;
02376
02377             // NOTE: This is ok as autoenrollment ignores dwPathLenConstraint
02378             // if fPathLenConstraint is FALSE;
02379       Constraints.dwPathLenConstraint = 0;
02380         }
02381         if (pExtension->fCritical)
02382         {
02383       ExtFlags = EXTENSION_CRITICAL_FLAG;
02384         }
02385     }
02386     else
02387     {
02388   Constraints.fCA = fCA;
02389   Constraints.fPathLenConstraint = FALSE;
02390   Constraints.dwPathLenConstraint = 0;
02391     }
02392     if (EDITF_BASICCONSTRAINTSCRITICAL & m_dwEditFlags)
02393     {
02394         ExtFlags = EXTENSION_CRITICAL_FLAG;
02395     }
02396
02397     // Check basic constraints against the issuer's cert.
02398
02399     pIssuerExtension = CertFindExtension(
02400         szOID_BASIC_CONSTRAINTS2,
02401         pIssuerCert->pCertInfo->cExtension,
02402         pIssuerCert->pCertInfo->rgExtension);
02403     if (NULL != pIssuerExtension)
02404     {
02405         cb = sizeof(IssuerConstraints);
02406         if (!CryptDecodeObject(
02407               X509_ASN_ENCODING,
02408               X509_BASIC_CONSTRAINTS2,
02409               pIssuerExtension->Value.pbData,
02410               pIssuerExtension->Value.cbData,
02411               0,
02412               &IssuerConstraints,
02413               &cb))
02414         {
02415             hr = ceHLastError();
02416             _JumpError(hr, error, "Policy:CryptDecodeObject");
02417         }
02418         if (!IssuerConstraints.fCA)
02419         {
02420             hr = CERTSRV_E_INVALID_CA_CERTIFICATE;
02421             _JumpError(hr, error, "Policy:CA cert not a CA cert");
02422         }
02423     }
02424
02425     if (Constraints.fCA)
02426     {
02427         if (IssuerConstraints.fPathLenConstraint)
02428         {
02429             if (0 == IssuerConstraints.dwPathLenConstraint)
02430             {
02431                 hr = CERTSRV_E_INVALID_CA_CERTIFICATE;
02432                 _JumpError(hr, error, "Policy:CA cert is a leaf CA cert");
02433             }
02434             if (!Constraints.fPathLenConstraint ||
02435                 Constraints.dwPathLenConstraint >
02436               IssuerConstraints.dwPathLenConstraint - 1)
02437             {
02438                 Constraints.fPathLenConstraint = TRUE;
02439                 Constraints.dwPathLenConstraint =
02440                 IssuerConstraints.dwPathLenConstraint - 1;
02441             }
02442         }
02443         if (CAPATHLENGTH_INFINITE != m_CAPathLength)
02444         {
02445             if (0 == m_CAPathLength)
02446             {
02447                 hr = CERTSRV_E_INVALID_CA_CERTIFICATE;
02448                 _JumpError(hr, error, "Policy:Registry says not to issue CA certs");
02449             }
02450             if (!Constraints.fPathLenConstraint ||
02451                 Constraints.dwPathLenConstraint > m_CAPathLength - 1)
02452             {
02453                 Constraints.fPathLenConstraint = TRUE;
02454                 Constraints.dwPathLenConstraint = m_CAPathLength - 1;
02455             }
02456         }
02457     }
02458
02459     if (!fEnableExtension)
02460     {
02461         ExtFlags |= EXTENSION_DISABLE_FLAG;
02462     }
02463
02464     if (!ceEncodeObject(
02465         X509_ASN_ENCODING,
02466                     X509_BASIC_CONSTRAINTS2,
02467                     &Constraints,
02468         0,
02469         FALSE,
02470                     &pbConstraints,
02471                     &cb))
02472     {
02473         hr = ceHLastError();
02474         _JumpError(hr, error, "Policy:ceEncodeObject");
02475     }
02476
02477     if (!ceConvertWszToBstr(
02478       &strExtension,
02479       (WCHAR const *) pbConstraints,
02480       cb))
02481     {
02482         hr = E_OUTOFMEMORY;
02483         _JumpError(hr, error, "Policy:ceConvertWszToBstr");
02484     }
02485
02486     varExtension.vt = VT_BSTR;
02487     varExtension.bstrVal = strExtension;
02488     hr = polSetCertificateExtension(
02489           pServer,
02490           TEXT(szOID_BASIC_CONSTRAINTS2),
02491           PROPTYPE_BINARY,
02492           ExtFlags,
02493           &varExtension);
02494     _JumpIfError(hr, error, "Policy:polSetCertificateExtension");
02495
02496 error:
02497     if (NULL != pbConstraints)
02498     {
02499         LocalFree(pbConstraints);
02500     }
02501     if (NULL != strExtension)
02502     {
02503         SysFreeString(strExtension);
02504     }
02505     return(hr);
02506 }
02507
02508
02509 //+--------------------------------------------------------------------------
02510 // CCertPolicy::_SetValidityPeriod
02511 //
02512 // Returns S_OK on success.
02513 //+--------------------------------------------------------------------------
02514
02515 HRESULT
02516 CCertPolicySample::_SetValidityPeriod(
02517     IN ICertServerPolicy *pServer)
02518 {
02519     HRESULT hr;
02520     BSTR strPeriodString = NULL;
02521     BSTR strPeriodCount = NULL;
02522     BSTR strNameNotBefore = NULL;
02523     BSTR strNameNotAfter = NULL;
02524     VARIANT varValue;
02525     LONG lDelta;
02526     ENUM_PERIOD enumValidityPeriod;
02527     BOOL fValidDigitString;
02528
02529     VariantInit(&varValue);
02530
02531     if (!(EDITF_ATTRIBUTEENDDATE & m_dwEditFlags))
02532     {
02533   hr = S_OK;
02534   goto error;
02535     }
02536
02537     hr = polGetRequestAttribute(
02538       pServer,
02539       wszPROPVALIDITYPERIODSTRING,
02540       &strPeriodString);
02541     if (S_OK != hr)
02542     {
02543   _PrintErrorStr2(
02544     hr,
02545     "Policy:polGetRequestAttribute",
02546     wszPROPVALIDITYPERIODSTRING,
02547     CERTSRV_E_PROPERTY_EMPTY);
02548   if (CERTSRV_E_PROPERTY_EMPTY == hr)
02549   {
02550       hr = S_OK;
02551   }
02552   goto error;
02553     }
02554
02555     hr = polGetRequestAttribute(
02556       pServer,
02557       wszPROPVALIDITYPERIODCOUNT,
02558       &strPeriodCount);
02559     if (S_OK != hr)
02560     {
02561   _PrintErrorStr2(
02562     hr,
02563     "Policy:polGetRequestAttribute",
02564     wszPROPVALIDITYPERIODCOUNT,
02565     CERTSRV_E_PROPERTY_EMPTY);
02566   if (CERTSRV_E_PROPERTY_EMPTY == hr)
02567   {
02568       hr = S_OK;
02569   }
02570   goto error;
02571     }
02572
02573     // Swap Count and String BSTRs if backwards -- Windows 2000 had it wrong.
02574
02575     lDelta = ceWtoI(strPeriodCount, &fValidDigitString);
02576     if (!fValidDigitString)
02577     {
02578   BSTR str = strPeriodCount;
02579
02580   strPeriodCount = strPeriodString;
02581   strPeriodString = str;
02582
02583   lDelta = ceWtoI(strPeriodCount, &fValidDigitString);
02584   if (!fValidDigitString)
02585   {
02586       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
02587       _JumpError(hr, error, "Policy:ceWtoI");
02588   }
02589     }
02590
02591     hr = ceTranslatePeriodUnits(strPeriodString, lDelta, &enumValidityPeriod, &lDelta);
02592     _JumpIfError(hr, error, "Policy:ceTranslatePeriodUnits");
02593
02594     strNameNotBefore = SysAllocString(wszPROPCERTIFICATENOTBEFOREDATE);
02595     if (NULL == strNameNotBefore)
02596     {
02597         hr = E_OUTOFMEMORY;
02598         _JumpError(hr, error, "Policy:SysAllocString");
02599     }
02600     hr = pServer->GetCertificateProperty(
02601         strNameNotBefore,
02602         PROPTYPE_DATE,
02603         &varValue);
02604     _JumpIfError(hr, error, "Policy:GetCertificateProperty");
02605
02606     hr = ceMakeExprDate(&varValue.date, lDelta, enumValidityPeriod);
02607     _JumpIfError(hr, error, "Policy:ceMakeExprDate");
02608
02609     strNameNotAfter = SysAllocString(wszPROPCERTIFICATENOTAFTERDATE);
02610     if (NULL == strNameNotAfter)
02611     {
02612         hr = E_OUTOFMEMORY;
02613         _JumpError(hr, error, "Policy:SysAllocString");
02614     }
02615     hr = pServer->SetCertificateProperty(
02616         strNameNotAfter,
02617         PROPTYPE_DATE,
02618         &varValue);
02619     _JumpIfError(hr, error, "Policy:SetCertificateProperty");
02620
02621     hr = S_OK;
02622
02623 error:
02624     VariantClear(&varValue);
02625     if (NULL != strPeriodString)
02626     {
02627   SysFreeString(strPeriodString);
02628     }
02629     if (NULL != strPeriodCount)
02630     {
02631   SysFreeString(strPeriodCount);
02632     }
02633     if (NULL != strNameNotBefore)
02634     {
02635         SysFreeString(strNameNotBefore);
02636     }
02637     if (NULL != strNameNotAfter)
02638     {
02639         SysFreeString(strNameNotAfter);
02640     }
02641     return(hr);
02642 }
02643
02644
02645
02646 //+--------------------------------------------------------------------------
02647 // CCertPolicySample::_AddV1TemplateNameExtension
02648 //
02649 // Returns S_OK on success.
02650 //+--------------------------------------------------------------------------
02651
02652 HRESULT
02653 CCertPolicySample::AddV1TemplateNameExtension(
02654     IN ICertServerPolicy *pServer,
02655     OPTIONAL IN WCHAR const *pwszTemplateName)
02656 {
02657     HRESULT hr;
02658     BSTR strName = NULL;
02659     LONG ExtFlags = 0;
02660     VARIANT varExtension;
02661     CERT_NAME_VALUE *pName = NULL;
02662     CERT_NAME_VALUE NameValue;
02663     DWORD cbEncoded;
02664     BYTE *pbEncoded = NULL;
02665     BOOL fUpdate = TRUE;
02666
02667     VariantInit(&varExtension);
02668
02669     strName = SysAllocString(TEXT(szOID_ENROLL_CERTTYPE_EXTENSION));
02670     if (NULL == strName)
02671     {
02672   hr = E_OUTOFMEMORY;
02673   _JumpError(hr, error, "Policy:SysAllocString");
02674     }
02675
02676     hr = pServer->GetCertificateExtension(
02677             strName,
02678             PROPTYPE_BINARY,
02679             &varExtension);
02680     _PrintIfError2(hr, "Policy:GetCertificateExtension", hr);
02681     if (CERTSRV_E_PROPERTY_EMPTY == hr)
02682     {
02683   if (NULL == pwszTemplateName)
02684   {
02685       hr = S_OK;
02686       goto error;
02687   }
02688     }
02689     else
02690     {
02691   _JumpIfError(hr, error, "Policy:GetCertificateExtension");
02692
02693   hr = pServer->GetCertificateExtensionFlags(&ExtFlags);
02694   _JumpIfError(hr, error, "Policy:GetCertificateExtensionFlags");
02695
02696   if (VT_BSTR == varExtension.vt &&
02697       0 == (EXTENSION_DISABLE_FLAG & ExtFlags) &&
02698       NULL != pwszTemplateName)
02699   {
02700       if (!ceDecodeObject(
02701       X509_ASN_ENCODING,
02702       X509_UNICODE_ANY_STRING,
02703       (BYTE *) varExtension.bstrVal,
02704       SysStringByteLen(varExtension.bstrVal),
02705       FALSE,
02706       (VOID **) &pName,
02707       &cbEncoded))
02708       {
02709     hr = ceHLastError();
02710     _JumpError(hr, error, "Policy:ceDecodeObject");
02711       }
02712
02713       // case sensitive compare -- be sure to match case of template
02714
02715       if (0 == lstrcmp(
02716       (WCHAR const *) pName->Value.pbData,
02717       pwszTemplateName))
02718       {
02719     fUpdate = FALSE;
02720       }
02721   }
02722     }
02723     if (fUpdate)
02724     {
02725   if (NULL == pwszTemplateName)
02726   {
02727       ExtFlags |= EXTENSION_DISABLE_FLAG;
02728   }
02729   else
02730   {
02731       VariantClear(&varExtension);
02732       varExtension.bstrVal = NULL;
02733
02734       NameValue.dwValueType = CERT_RDN_UNICODE_STRING;
02735       NameValue.Value.pbData = (BYTE *) pwszTemplateName;
02736       NameValue.Value.cbData = 0;
02737
02738       if (!ceEncodeObject(
02739           X509_ASN_ENCODING,
02740           X509_UNICODE_ANY_STRING,
02741           &NameValue,
02742           0,
02743           FALSE,
02744           &pbEncoded,
02745           &cbEncoded))
02746       {
02747     hr = ceHLastError();
02748     _JumpError(hr, error, "Policy:ceEncodeObject");
02749       }
02750       if (!ceConvertWszToBstr(
02751         &varExtension.bstrVal,
02752         (WCHAR const *) pbEncoded,
02753         cbEncoded))
02754       {
02755     hr = E_OUTOFMEMORY;
02756     _JumpError(hr, error, "Policy:ceConvertWszToBstr");
02757       }
02758       varExtension.vt = VT_BSTR;
02759       ExtFlags &= ~EXTENSION_DISABLE_FLAG;
02760   }
02761   hr = pServer->SetCertificateExtension(
02762         strName,
02763         PROPTYPE_BINARY,
02764         ExtFlags,
02765         &varExtension);
02766   _JumpIfError(hr, error, "Policy:SetCertificateExtension");
02767     }
02768     hr = S_OK;
02769
02770 error:
02771     VariantClear(&varExtension);
02772     if (NULL != strName)
02773     {
02774   SysFreeString(strName);
02775     }
02776     if (NULL != pName)
02777     {
02778   LocalFree(pName);
02779     }
02780     if (NULL != pbEncoded)
02781     {
02782   LocalFree(pbEncoded);
02783     }
02784     return(hr);
02785 }
02786
02787
02788 STDMETHODIMP
02789 CCertPolicySample::VerifyRequest(
02790     /* [in] */ BSTR const, // strConfig
02791     /* [in] */ LONG Context,
02792     /* [in] */ LONG bNewRequest,
02793     /* [in] */ LONG, // Flags
02794     /* [out, retval] */ LONG __RPC_FAR *pDisposition)
02795 {
02796     HRESULT hr = E_FAIL;
02797     ICertServerPolicy *pServer = NULL;
02798     LONG lRequestId;
02799     CRequestInstance Request;
02800     BSTR strDisposition = NULL;
02801     BOOL fEnableEnrolleeExtensions;
02802     BOOL fReenroll = FALSE;
02803     DWORD cCriticalExtensions = 0;
02804     WCHAR const * const *apwszCriticalExtensions = NULL;
02805
02806     lRequestId = 0;
02807
02808
02809     __try
02810     {
02811   if (NULL == pDisposition)
02812   {
02813       hr = E_POINTER;
02814       _LeaveError(hr, "Policy:pDisposition");
02815   }
02816   *pDisposition = VR_INSTANT_BAD;
02817
02818   hr = polGetServerCallbackInterface(&pServer, Context);
02819   _LeaveIfError(hr, "Policy:polGetServerCallbackInterface");
02820
02821   hr = GetRequestId(pServer, &lRequestId);
02822   _JumpIfError(hr, deny, "Policy:GetRequestId");
02823
02824   // only need to check user access for original submitter:
02825   // resubmit can only be called by admins
02826
02827   if (bNewRequest && (0 == (m_dwEditFlags & EDITF_IGNOREREQUESTERGROUP)))
02828   {
02829       BOOL fRequesterAccess = FALSE;
02830
02831       // Is this user allowed to request certs?
02832       hr = polGetCertificateLongProperty(
02833             pServer,
02834             wszPROPREQUESTERCAACCESS,
02835             (LONG *) &fRequesterAccess);
02836       _PrintIfErrorStr(
02837       hr,
02838       "Policy:polGetCertificateLongProperty",
02839       wszPROPREQUESTERCAACCESS);
02840       if (hr != S_OK || !fRequesterAccess)
02841       {
02842     hr = CERTSRV_E_ENROLL_DENIED;
02843     _JumpError(hr, deny, "Policy:fRequesterAccess");
02844       }
02845   }
02846
02847
02848   hr = Request.Initialize(
02849           this,
02850           pServer,
02851           &fEnableEnrolleeExtensions);
02852   _LeaveIfError(hr, "Policy:VerifyRequest:Request.Initialize");
02853
02854
02855   hr = _EnumerateExtensions(
02856           pServer,
02857           bNewRequest,
02858           TRUE,
02859           fEnableEnrolleeExtensions,
02860           0,
02861           NULL);
02862   _LeaveIfError(hr, "_EnumerateExtensions");
02863
02864   {
02865       hr = _AddDefaultBasicConstraintsExtension(
02866             pServer,
02867             Request.IsCARequest());
02868       _LeaveIfError(hr, "_AddDefaultBasicConstraintsExtension");
02869
02870       hr = _AddDefaultKeyUsageExtension(pServer, Request.IsCARequest());
02871       _LeaveIfError(hr, "_AddDefaultKeyUsageExtension");
02872
02873       hr = _AddEnhancedKeyUsageExtension(pServer);
02874       _LeaveIfError(hr, "_AddEnhancedKeyUsageExtension");
02875   }
02876
02877   hr = _SetValidityPeriod(pServer);
02878   _LeaveIfError(hr, "_SetValidityPeriod");
02879
02880   hr = EnumerateAttributes(pServer);
02881   _LeaveIfError(hr, "Policy:EnumerateAttributes");
02882
02883   hr = _AddRevocationExtension(pServer);
02884   _LeaveIfError(hr, "_AddRevocationExtension");
02885
02886   hr = _AddOldCertTypeExtension(pServer, Request.IsCARequest());
02887   _LeaveIfError(hr, "_AddOldCertTypeExtension");
02888
02889   hr = _AddAuthorityKeyId(pServer);
02890   _LeaveIfError(hr, "_AddAuthorityKeyId");
02891
02892
02893   // pass hr as Disposition
02894
02895   if ((EDITF_DISABLEEXTENSIONLIST & m_dwEditFlags) ||
02896       NULL != apwszCriticalExtensions)
02897   {
02898       hr = _EnumerateExtensions(
02899         pServer,
02900         bNewRequest,
02901         FALSE,
02902         FALSE,
02903         cCriticalExtensions,
02904         apwszCriticalExtensions);
02905       _LeaveIfError(hr, "_EnumerateExtensions");
02906   }
02907
02908   if (bNewRequest &&
02909       (
02910        (REQDISP_PENDINGFIRST & m_dwDispositionFlags)))
02911   {
02912       *pDisposition = VR_PENDING;
02913   }
02914   else switch (REQDISP_MASK & m_dwDispositionFlags)
02915   {
02916       default:
02917       case REQDISP_PENDING:
02918     *pDisposition = VR_PENDING;
02919     break;
02920
02921       case REQDISP_ISSUE:
02922     *pDisposition = VR_INSTANT_OK;
02923     break;
02924
02925       case REQDISP_DENY:
02926     *pDisposition = VR_INSTANT_BAD;
02927     break;
02928
02929       case REQDISP_USEREQUESTATTRIBUTE:
02930     *pDisposition = VR_INSTANT_OK;
02931     hr = polGetRequestAttribute(
02932             pServer,
02933             wszPROPDISPOSITION,
02934             &strDisposition);
02935     if (S_OK == hr)
02936     {
02937         if (0 == celstrcmpiL(strDisposition, wszPROPDISPOSITIONDENY))
02938         {
02939       *pDisposition = VR_INSTANT_BAD;
02940         }
02941         if (0 == celstrcmpiL(strDisposition, wszPROPDISPOSITIONPENDING))
02942         {
02943       *pDisposition = VR_PENDING;
02944         }
02945     }
02946     hr = S_OK;
02947     break;
02948   }
02949 deny:
02950   if (FAILED(hr))
02951   {
02952       *pDisposition = hr; // pass failed HRESULT back as Disposition
02953   }
02954   else if (hr != S_OK)
02955   {
02956       *pDisposition = VR_INSTANT_BAD;
02957   }
02958   hr = S_OK;
02959     }
02960     __except(hr = ceHError(GetExceptionCode()), EXCEPTION_EXECUTE_HANDLER)
02961     {
02962   _PrintError(hr, "Exception");
02963     }
02964
02965     {
02966   HRESULT hr2 = hr;
02967 #define wszFORMATREQUESTID  L"RequestId=%u"
02968   WCHAR wszRequestId[ARRAYSIZE(wszFORMATREQUESTID) + cwcDWORDSPRINTF];
02969
02970   if (S_OK == hr2 && NULL != pDisposition && FAILED(*pDisposition))
02971   {
02972       hr2 = *pDisposition;
02973   }
02974   if (S_OK != hr2)
02975   {
02976       wsprintf(wszRequestId, wszFORMATREQUESTID, lRequestId);
02977       _PrintErrorStr(hr2, "VerifyRequest", wszRequestId);
02978   }
02979     }
02980     if (NULL != strDisposition)
02981     {
02982   SysFreeString(strDisposition);
02983     }
02984     if (NULL != pServer)
02985     {
02986         pServer->Release();
02987     }
02988     //_PrintIfError(hr, "Policy:VerifyRequest(hr)");
02989     //_PrintError(*pDisposition, "Policy:VerifyRequest(*pDisposition)");
02990     return(hr);
02991 }
02992
02993
02994 //+--------------------------------------------------------------------------
02995 // CCertPolicySample::GetDescription
02996 //
02997 // Returns S_OK on success.
02998 //+--------------------------------------------------------------------------
02999
03000 STDMETHODIMP
03001 CCertPolicySample::GetDescription(
03002     /* [out, retval] */ BSTR __RPC_FAR *pstrDescription)
03003 {
03004     HRESULT hr = S_OK;
03005     WCHAR sz[MAX_PATH];
03006
03007     if(!m_strDescription)
03008     {
03009   assert(wcslen(wsz_SAMPLE_DESCRIPTION) < ARRAYSIZE(sz));
03010   wcsncpy(sz, wsz_SAMPLE_DESCRIPTION, ARRAYSIZE(sz));
03011   sz[ARRAYSIZE(sz) - 1] = L'\0';
03012
03013   m_strDescription = SysAllocString(sz);
03014   if (NULL == m_strDescription)
03015   {
03016       hr = E_OUTOFMEMORY;
03017       return hr;
03018   }
03019     }
03020
03021     if (NULL != *pstrDescription)
03022     {
03023         SysFreeString(*pstrDescription);
03024     }
03025
03026     *pstrDescription = SysAllocString(m_strDescription);
03027     if (NULL == *pstrDescription)
03028     {
03029         hr = E_OUTOFMEMORY;
03030     }
03031     return(hr);
03032 }
03033
03034
03035 //+--------------------------------------------------------------------------
03036 // CCertPolicySample::ShutDown
03037 //
03038 // Returns S_OK on success.
03039 //+--------------------------------------------------------------------------
03040
03041 STDMETHODIMP
03042 CCertPolicySample::ShutDown(VOID)
03043 {
03044     // called once, as Server unloading policy dll
03045     _Cleanup();
03046     return(S_OK);
03047 }
03048
03049
03050 //+--------------------------------------------------------------------------
03051 // CCertPolicySample::GetManageModule
03052 //
03053 // Returns S_OK on success.
03054 //+--------------------------------------------------------------------------
03055
03056 STDMETHODIMP
03057 CCertPolicySample::GetManageModule(
03058     /* [out, retval] */ ICertManageModule **ppManageModule)
03059 {
03060     HRESULT hr;
03061
03062     *ppManageModule = NULL;
03063     hr = CoCreateInstance(
03064         CLSID_CCertManagePolicyModuleSample,
03065                     NULL,               // pUnkOuter
03066                     CLSCTX_INPROC_SERVER,
03067         IID_ICertManageModule,
03068                     (VOID **) ppManageModule);
03069     _JumpIfError(hr, error, "CoCreateInstance");
03070
03071 error:
03072     return(hr);
03073 }
03074
03075
03076 //+--------------------------------------------------------------------------
03077 // CCertPolicySample::_GetIssuer
03078 //
03079 // Returns S_OK on success.
03080 //+--------------------------------------------------------------------------
03081
03082 PCCERT_CONTEXT
03083 CCertPolicySample::_GetIssuer(
03084     IN ICertServerPolicy *pServer)
03085 {
03086     HRESULT hr;
03087     VARIANT varValue;
03088     BSTR strName = NULL;
03089
03090     VariantInit(&varValue);
03091     if (NULL != m_pCert)
03092     {
03093         hr = S_OK;
03094   goto error;
03095     }
03096     strName = SysAllocString(wszPROPRAWCACERTIFICATE);
03097     if (NULL == strName)
03098     {
03099   hr = E_OUTOFMEMORY;
03100   _JumpError(hr, error, "Policy:SysAllocString");
03101     }
03102     hr = pServer->GetCertificateProperty(strName, PROPTYPE_BINARY, &varValue);
03103     _JumpIfError(hr, error, "Policy:GetCertificateProperty");
03104
03105     m_pCert = CertCreateCertificateContext(
03106             X509_ASN_ENCODING,
03107             (BYTE *) varValue.bstrVal,
03108             SysStringByteLen(varValue.bstrVal));
03109     if (NULL == m_pCert)
03110     {
03111   hr = ceHLastError();
03112   _JumpError(hr, error, "Policy:CertCreateCertificateContext");
03113     }
03114
03115 error:
03116     VariantClear(&varValue);
03117     if (NULL != strName)
03118     {
03119   SysFreeString(strName);
03120     }
03121     return(m_pCert);
03122 }
03123
03124
03125 STDMETHODIMP
03126 CCertPolicySample::InterfaceSupportsErrorInfo(
03127     IN REFIID riid)
03128 {
03129     static const IID *arr[] =
03130     {
03131         &IID_ICertPolicy,
03132     };
03133
03134     for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
03135     {
03136         if (IsEqualGUID(*arr[i], riid))
03137         {
03138             return(S_OK);
03139         }
03140     }
03141     return(S_FALSE);
03142 }
03143
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Server/BYOTTxEnlister/EnlistTransaction.h Source File

  • Com
  • Services
  • BYOT
  • Server
  • BYOTTxEnlister

EnlistTransaction.h

Go to the documentation of this file.
00001 // EnlistTransaction.h : Declaration of the CEnlistTransaction
00002
00003 #ifndef __ENLISTTRANSACTION_H_
00004 #define __ENLISTTRANSACTION_H_
00005
00006 #include "resource.h"       // main symbols
00007
00008 /////////////////////////////////////////////////////////////////////////////
00009 // CEnlistTransaction
00010 class ATL_NO_VTABLE CEnlistTransaction :
00011   public CComObjectRootEx<CComMultiThreadModel>,
00012   public CComCoClass<CEnlistTransaction, &CLSID_EnlistTransaction>,
00013   public ISupportErrorInfo,
00014   public IDispatchImpl<IEnlistTransaction, &IID_IEnlistTransaction, &LIBID_TXENLISTERLib>
00015 {
00016 public:
00017   CEnlistTransaction()
00018   {
00019   }
00020
00021 DECLARE_REGISTRY_RESOURCEID(IDR_ENLISTTRANSACTION)
00022
00023 DECLARE_PROTECT_FINAL_CONSTRUCT()
00024
00025 BEGIN_COM_MAP(CEnlistTransaction)
00026   COM_INTERFACE_ENTRY(IEnlistTransaction)
00027   COM_INTERFACE_ENTRY(IDispatch)
00028   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00029 END_COM_MAP()
00030
00031 // ISupportsErrorInfo
00032   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00033
00034 // IEnlistTransaction
00035 public:
00036   STDMETHOD(CreateInstance)(/*[in]*/ BSTR bstrProgId, /*[out]*/ IDispatch** ppDispatch);
00037   STDMETHOD(EnlistTransaction)(/*[in]*/ BSTR bstrTipUrl);
00038
00039 protected:
00040
00041   CComBSTR m_bstrTipUrl;
00042 };
00043
00044 #endif //__ENLISTTRANSACTION_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/comp.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

comp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENT_
00016 #define _CLASS_CCOMPONENT_
00017
00018 #include "Globals.h"
00019
00020
00021 class CComponentData;                  // References
00022
00023
00024 //---------------------------------------------------------------------------
00025 class CComponent : public IComponent2,
00026                           IExtendPropertySheet2
00027 {
00028   // Construction/Destruction
00029   public:
00030     CComponent( CComponentData* pParent );
00031     ~CComponent();
00032
00033
00034   ///////////////////////////////////////////////////////////////////////////
00035   // Interface IUnknown
00036   //
00037   public:
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042   ///////////////////////////////////////////////////////////////////////////
00043   // Interface IComponent2
00044   //
00045   public:
00046     HRESULT STDMETHODCALLTYPE Initialize
00047             ( /*[in]*/ LPCONSOLE ipConsole );
00048
00049     HRESULT STDMETHODCALLTYPE Notify
00050             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00051               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00052               /*[in]*/ LONG nArg,
00053               /*[in]*/ LONG nParam
00054             );
00055
00056     HRESULT STDMETHODCALLTYPE Destroy
00057             ( /*[in]*/ MMC_COOKIE nCookie );
00058
00059     HRESULT STDMETHODCALLTYPE QueryDataObject
00060             ( /*[in]*/  MMC_COOKIE nCookie,
00061               /*[in]*/  DATA_OBJECT_TYPES nEnumType,
00062               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00063             );
00064
00065     HRESULT STDMETHODCALLTYPE GetResultViewType
00066             ( /*[in]*/  MMC_COOKIE nCookie,
00067               /*[out]*/ LPOLESTR __RPC_FAR* ppViewType,
00068               /*[out]*/ long __RPC_FAR* pViewOptions
00069             );
00070
00071     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00072             ( /*[out][in]*/ RESULTDATAITEM __RPC_FAR* pResultDataItem );
00073
00074     HRESULT STDMETHODCALLTYPE CompareObjects
00075             ( /*[in]*/ LPDATAOBJECT lpDataObjectA,
00076               /*[in]*/ LPDATAOBJECT lpDataObjectB
00077             );
00078
00079     HRESULT STDMETHODCALLTYPE QueryDispatch
00080             ( /*[in] */  MMC_COOKIE  nCookie,
00081               /*[in] */  DATA_OBJECT_TYPES eType,
00082               /*[out]*/  LPDISPATCH* pipDispatch
00083             );
00084
00085     HRESULT STDMETHODCALLTYPE GetResultViewType2
00086             ( /*[in] */    MMC_COOKIE nCookie,
00087               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pRVTinfo
00088             );
00089
00090     HRESULT STDMETHODCALLTYPE RestoreResultView
00091             ( /*[in] */    MMC_COOKIE nCookie,
00092               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pResultViewType
00093             );
00094
00095
00096   /////////////////////////////////////////////////////////////////////////
00097   // Interface IExtendPropertySheet2
00098   //
00099   public:
00100     HRESULT STDMETHODCALLTYPE CreatePropertyPages
00101             ( /*[in]*/ LPPROPERTYSHEETCALLBACK lpProvider,
00102               /*[in]*/ LONG_PTR Handle,
00103               /*[in]*/ LPDATAOBJECT ipIDataObject
00104             );
00105
00106     HRESULT STDMETHODCALLTYPE QueryPagesFor
00107             ( /*[in]*/ LPDATAOBJECT ipDataObject
00108             );
00109
00110     HRESULT STDMETHODCALLTYPE GetWatermarks
00111             ( /*[in] */ LPDATAOBJECT lpIDataObject,
00112               /*[out]*/ HBITMAP __RPC_FAR *lphWatermark,
00113               /*[out]*/ HBITMAP __RPC_FAR *lphHeader,
00114               /*[out]*/ HPALETTE __RPC_FAR *lphPalette,
00115               /*[out]*/ BOOL __RPC_FAR *bStretch
00116             );
00117
00118   // Private data
00119   private:
00120     ULONG            m_cRef;
00121     HBITMAP          m_hImageStrip16;
00122     HBITMAP          m_hImageStrip32;
00123     IConsole3*       m_ipConsole;
00124     LPCONSOLEVERB    m_ipConsoleVerb;
00125     LPRESULTDATA     m_ipResultData;
00126     LPHEADERCTRL2    m_ipHeaderCtrl;
00127     CComponentData*  m_pComponentData;
00128
00129
00130   ///////////////////////////////////////////////////////////////////////////
00131   //  Handlers for notifications which are not delegated
00132   private:
00133     HRESULT  OnAddImages( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam );
00134
00135
00136   ///////////////////////////////////////////////////////////////////////////
00137   //  Public helpers
00138   public:
00139     HRESULT  GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00140
00141 };
00142
00143 #endif //_CLASS_CCOMPONENT_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAppInfo Member List

This is the complete list of members for CAppInfo, including all inherited members.
AddSubscription(EventEnum e) | CAppInfo |
AppName() | CAppInfo | [inline]
CAppInfo() | CAppInfo | [private]
CAppInfo(LPTSTR sAppName, CComSpy *pSpy) | CAppInfo |
CAppInfo(LPTSTR sAppName, CComSpy *pSpy, long nPID) | CAppInfo |
CAppInfo(LPTSTR sAppName, CComSpy *pSpy, LPTSTR sAppID) | CAppInfo |
GetEvents() | CAppInfo | [inline]
GetFilterType() | CAppInfo | [inline]
Initialze(CComSpy *pSpy) | CAppInfo | [private]
IsReadyForDelete() | CAppInfo | [inline]
IsSubscribed(EventEnum e) | CAppInfo |
IsSubscribedToAny() | CAppInfo |
m_bReadyForDelete | CAppInfo | [private]
m_EventMap | CAppInfo | [private]
m_FilterType | CAppInfo | [private]
m_PID | CAppInfo | [private]
m_pSpy | CAppInfo | [private]
m_sAppID | CAppInfo | [private]
m_sAppName | CAppInfo | [private]
RemoveAllSubscriptions() | CAppInfo |
RemoveSubscription(EventEnum e) | CAppInfo |
SetDeleteFlag(bool bDelete) | CAppInfo | [inline]
~CAppInfo() | CAppInfo |
Generated on Wed Nov 13 2024 16:55:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/step2.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

step2.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module STEP2.CPP
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////////
00016 #include "wizard.h"
00017 #include "common.h"
00018 #include "tablecopy.h"
00019 #include "table.h"
00020
00021
00022
00023 /////////////////////////////////////////////////////////////////////
00024 // Defines
00025 //
00026 /////////////////////////////////////////////////////////////////////
00027 //Enum Index Header for the ListView controls
00028 enum COL_HEADERS
00029 {
00030   //IDL_INDEXES
00031   COL_INDEXNAME   = 0,  //IndexInfo.wszIndexName
00032   COL_INDEXCOLNAME  = 1,  //IndexInfo.wszColName
00033   COL_UNIQUE      = 2,  //IndexInfo.fUnique
00034   COL_PRIMARYKEY    = 3,  //IndexInfo.fIsPrimaryKey
00035   COL_COLLATION   = 4,  //IndexInfo.dwCollation
00036   COL_AUTOUPDATE    = 5,  //IndexInfo.fAutoUpdate
00037   COL_NULLS     = 6,  //IndexInfo.dwNulls
00038 };
00039
00040 enum INDEX_TYPE
00041 {
00042   INDEXTYPE_INDEX     = 0,
00043   INDEXTYPE_PRIMARYKEY  = 1,
00044 };
00045
00046 /////////////////////////////////////////////////////////////////////
00047 // CS2Dialog::CS2Dialog
00048 //
00049 /////////////////////////////////////////////////////////////////////
00050 CS2Dialog::CS2Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pCTableCopy)
00051   : CDialogBase(hWnd, hInst)
00052 {
00053   ASSERT(pCTableCopy);
00054   m_pCTableCopy = pCTableCopy;
00055 }
00056
00057
00058 /////////////////////////////////////////////////////////////////////
00059 // CS2Dialog::~CS2Dialog
00060 //
00061 /////////////////////////////////////////////////////////////////////
00062 CS2Dialog::~CS2Dialog()
00063 {
00064 }
00065
00066
00067 /////////////////////////////////////////////////////////////////////////////
00068 // ULONG CS2Dialog::Display
00069 //
00070 /////////////////////////////////////////////////////////////////////////////
00071 ULONG CS2Dialog::Display()
00072 {
00073   //Create a modal dialog box
00074   return DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_INDEX_INFO), NULL, DlgProc, (LPARAM)this);
00075 }
00076
00077
00078 /////////////////////////////////////////////////////////////////////
00079 // CS2Dialog::DlgProc
00080 //
00081 /////////////////////////////////////////////////////////////////////
00082 BOOL WINAPI CS2Dialog::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00083 {
00084   switch(msg)
00085   {
00086     case WM_INITDIALOG:
00087     {
00088       Busy();
00089       //Store the "this" pointer, since this is a static method
00090       CS2Dialog* pThis = (CS2Dialog*)lParam;
00091       SetWindowLong(hWnd, GWL_USERDATA, (LONG)pThis);
00092       CTableCopy* pCTableCopy = pThis->m_pCTableCopy;
00093       CWizard* pCWizard = pCTableCopy->m_pCWizard;
00094
00095       LONG iPrevStep = pCWizard->m_iPrevStep;
00096
00097       //On INIT we know we have a valid hWnd to store
00098       CenterDialog(hWnd);
00099       pThis->m_hWnd = hWnd;
00100
00101       pThis->InitControls();
00102       pThis->RefreshControls();
00103
00104       pThis->ResetIndexList(GetDlgItem(hWnd, IDL_INDEXES));
00105       pCWizard->DestroyPrevStep(WIZ_STEP2);
00106
00107       //No since in even displaying this Dialog if there
00108       //are no indexes...
00109       if(pCTableCopy->m_pCFromTable->m_cIndexes == 0)
00110         pCWizard->DisplayStep(iPrevStep==WIZ_STEP1 ? WIZ_STEP3 : WIZ_STEP1);
00111
00112       return HANDLED_MSG;
00113     }
00114
00115     case WM_COMMAND:
00116     {
00117       //Obtain the "this" pointer
00118       CS2Dialog* pThis = (CS2Dialog*)GetWindowLong(hWnd, GWL_USERDATA);
00119
00120       // All buttons are handled the same way
00121       switch(GET_WM_COMMAND_ID(wParam, lParam))
00122       {
00123         case IDOK:
00124                 case IDB_PREV:
00125           //Record all selected indexes
00126           Busy();
00127           pThis->RecordSelectedIndexes(GetDlgItem(hWnd, IDL_INDEXES));
00128           pThis->m_pCTableCopy->m_pCWizard->DisplayStep((GET_WM_COMMAND_ID(wParam, lParam) == IDOK) ? WIZ_STEP3 : WIZ_STEP1);
00129                   return HANDLED_MSG;
00130
00131         case IDCANCEL:
00132           //Record all selected indexes
00133           Busy();
00134           EndDialog(hWnd, GET_WM_COMMAND_ID(wParam, lParam));
00135                   return HANDLED_MSG;
00136       }
00137     }
00138   }
00139
00140   return UNHANDLED_MSG;
00141 }
00142
00143
00144 /////////////////////////////////////////////////////////////////////////////
00145 // BOOL CS2Dialog::InitControls
00146 //
00147 /////////////////////////////////////////////////////////////////////////////
00148 BOOL CS2Dialog::InitControls()
00149 {
00150   HWND hWndIndexes = GetDlgItem(m_hWnd, IDL_INDEXES);
00151
00152   //Create the Index ImageList
00153   HIMAGELIST hIndexImageList = ImageList_Create(16, 16, ILC_MASK, 1, 0 );
00154
00155   //IDI_INDEX - normal index icon
00156   HICON hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_INDEX));
00157   ImageList_AddIcon(hIndexImageList, hIcon);
00158   //IDI_PRIMARYKEY - primary key index icon
00159   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PRIMARYKEY));
00160   ImageList_AddIcon(hIndexImageList, hIcon);
00161
00162   //Set image list to the Table Window
00163   ListView_SetImageList(hWndIndexes, hIndexImageList, LVSIL_SMALL);
00164
00165   //ListView COLUMNS
00166   LV_InsertColumn(hWndIndexes,  COL_INDEXNAME,    "Index");
00167   LV_InsertColumn(hWndIndexes,  COL_INDEXCOLNAME, "ColName");
00168   LV_InsertColumn(hWndIndexes,  COL_UNIQUE,     "Unique");
00169   LV_InsertColumn(hWndIndexes,  COL_PRIMARYKEY,   "PrimaryKey");
00170   LV_InsertColumn(hWndIndexes,  COL_COLLATION,    "Collation");
00171   LV_InsertColumn(hWndIndexes,  COL_AUTOUPDATE,   "AutoUpdate");
00172   LV_InsertColumn(hWndIndexes,  COL_NULLS,      "Nulls");
00173
00174   //AutoSize all columns
00175   for(ULONG i=0; i<=COL_NULLS; i++)
00176     SendMessage(hWndIndexes, LVM_SETCOLUMNWIDTH, (WPARAM)i,   (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
00177
00178   //Use Extended ListView Styles!
00179   SendMessage(hWndIndexes, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
00180   return TRUE;
00181 }
00182
00183 /////////////////////////////////////////////////////////////////////////////
00184 // BOOL CS2Dialog::RefreshControls
00185 //
00186 /////////////////////////////////////////////////////////////////////////////
00187 BOOL CS2Dialog::RefreshControls()
00188 {
00189   BOOL fSchemas = m_pCTableCopy->m_pCFromTable->m_pCDataSource->m_pIDBSchemaRowset != NULL;
00190
00191   //Display IndexWindow if there are on Schemas
00192   EnableWindow(GetDlgItem(m_hWnd, IDT_INDEXMSG),  fSchemas);
00193   EnableWindow(GetDlgItem(m_hWnd, IDL_INDEXES), fSchemas);
00194   return TRUE;
00195 }
00196
00197
00198 /////////////////////////////////////////////////////////////////////////////
00199 // BOOL CS2Dialog::ResetIndexList
00200 //
00201 /////////////////////////////////////////////////////////////////////////////
00202 BOOL CS2Dialog::ResetIndexList(HWND hWnd)
00203 {
00204   HRESULT hr;
00205   CHAR  szBuffer[MAX_NAME_LEN*2];
00206
00207   HROW* rghRows = NULL;
00208   ULONG i,cRowsObtained = 0;
00209   IRowset* pIRowset = NULL;
00210
00211   IAccessor* pIAccessor = NULL;
00212   HACCESSOR hAccessor = DB_NULL_HACCESSOR;
00213
00214   //Use the passed in Session interface
00215   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00216   IOpenRowset* pIOpenRowset = pCFromTable->m_pCDataSource->m_pIOpenRowset;
00217   IDBSchemaRowset* pIDBSchemaRowset = pCFromTable->m_pCDataSource->m_pIDBSchemaRowset;
00218
00219   //Provider doesn't have to support IDBSchemaRowset
00220   if(pIDBSchemaRowset == NULL)
00221   {
00222     return TRUE;
00223   }
00224
00225   //Save the currently selected indexes
00226   ULONG cSelIndexes = pCFromTable->m_cIndexes;
00227   INDEXINFO* rgSelIndexInfo = pCFromTable->m_rgIndexInfo;
00228
00229   //Reset the current IndexInfo
00230   pCFromTable->m_cIndexes = 0;
00231   pCFromTable->m_rgIndexInfo = NULL;
00232
00233   // Now make the call
00234   SendMessage(hWnd, LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0);
00235
00236   // Bind the user and table name for the list
00237   const static ULONG cBindings = 13;
00238   const static DBBINDING rgBindings[cBindings] =
00239     {
00240       //INDEX_NAME
00241       6,
00242       offsetof(INDEXINFO, wszIndexName),
00243       0,
00244       0,
00245       NULL,
00246       NULL,
00247       NULL,
00248       DBPART_VALUE,
00249       DBMEMOWNER_CLIENTOWNED,
00250       DBPARAMIO_NOTPARAM,
00251       MAX_NAME_LEN,
00252       0,
00253       DBTYPE_WSTR,
00254       0,
00255       0,
00256
00257       //UNIQUE
00258       8,
00259       offsetof(INDEXINFO, fUnique),
00260       0,
00261       0,
00262       NULL,
00263       NULL,
00264       NULL,
00265       DBPART_VALUE,
00266       DBMEMOWNER_CLIENTOWNED,
00267       DBPARAMIO_NOTPARAM,
00268       sizeof(VARIANT_BOOL),
00269       0,
00270       DBTYPE_BOOL,
00271       0,
00272       0,
00273
00274       //CLUSTERED
00275       9,
00276       offsetof(INDEXINFO, fClustered),
00277       0,
00278       0,
00279       NULL,
00280       NULL,
00281       NULL,
00282       DBPART_VALUE,
00283       DBMEMOWNER_CLIENTOWNED,
00284       DBPARAMIO_NOTPARAM,
00285       sizeof(VARIANT_BOOL),
00286       0,
00287       DBTYPE_BOOL,
00288       0,
00289       0,
00290
00291       //TYPE
00292       10,
00293       offsetof(INDEXINFO, wType),
00294       0,
00295       0,
00296       NULL,
00297       NULL,
00298       NULL,
00299       DBPART_VALUE,
00300       DBMEMOWNER_CLIENTOWNED,
00301       DBPARAMIO_NOTPARAM,
00302       sizeof(DBTYPE),
00303       0,
00304       DBTYPE_UI2,
00305       0,
00306       0,
00307
00308       //FILL_FACTOR
00309       11,
00310       offsetof(INDEXINFO, dwFillFactor),
00311       0,
00312       0,
00313       NULL,
00314       NULL,
00315       NULL,
00316       DBPART_VALUE,
00317       DBMEMOWNER_CLIENTOWNED,
00318       DBPARAMIO_NOTPARAM,
00319       sizeof(LONG),
00320       0,
00321       DBTYPE_I4,
00322       0,
00323       0,
00324
00325       //INITIAL_SIZE
00326       12,
00327       offsetof(INDEXINFO, dwInitialSize),
00328       0,
00329       0,
00330       NULL,
00331       NULL,
00332       NULL,
00333       DBPART_VALUE,
00334       DBMEMOWNER_CLIENTOWNED,
00335       DBPARAMIO_NOTPARAM,
00336       sizeof(LONG),
00337       0,
00338       DBTYPE_I4,
00339       0,
00340       0,
00341
00342       //NULLS
00343       13,
00344       offsetof(INDEXINFO, dwNulls),
00345       0,
00346       0,
00347       NULL,
00348       NULL,
00349       NULL,
00350       DBPART_VALUE,
00351       DBMEMOWNER_CLIENTOWNED,
00352       DBPARAMIO_NOTPARAM,
00353       sizeof(LONG),
00354       0,
00355       DBTYPE_I4,
00356       0,
00357       0,
00358
00359       //SORT_BOOKMARKS
00360       14,
00361       offsetof(INDEXINFO, fSortBookmarks),
00362       0,
00363       0,
00364       NULL,
00365       NULL,
00366       NULL,
00367       DBPART_VALUE,
00368       DBMEMOWNER_CLIENTOWNED,
00369       DBPARAMIO_NOTPARAM,
00370       sizeof(VARIANT_BOOL),
00371       0,
00372       DBTYPE_BOOL,
00373       0,
00374       0,
00375
00376       //AUTO_UPDATE
00377       15,
00378       offsetof(INDEXINFO, fAutoUpdate),
00379       0,
00380       0,
00381       NULL,
00382       NULL,
00383       NULL,
00384       DBPART_VALUE,
00385       DBMEMOWNER_CLIENTOWNED,
00386       DBPARAMIO_NOTPARAM,
00387       sizeof(VARIANT_BOOL),
00388       0,
00389       DBTYPE_BOOL,
00390       0,
00391       0,
00392
00393       //NULL_COLLATION
00394       16,
00395       offsetof(INDEXINFO, dwNullCollation),
00396       0,
00397       0,
00398       NULL,
00399       NULL,
00400       NULL,
00401       DBPART_VALUE,
00402       DBMEMOWNER_CLIENTOWNED,
00403       DBPARAMIO_NOTPARAM,
00404       sizeof(LONG),
00405       0,
00406       DBTYPE_I4,
00407       0,
00408       0,
00409
00410       //ORDINAL_POSITION
00411       17,
00412       offsetof(INDEXINFO, iOrdinal),
00413       0,
00414       0,
00415       NULL,
00416       NULL,
00417       NULL,
00418       DBPART_VALUE,
00419       DBMEMOWNER_CLIENTOWNED,
00420       DBPARAMIO_NOTPARAM,
00421       sizeof(ULONG),
00422       0,
00423       DBTYPE_UI4,
00424       0,
00425       0,
00426
00427       //COLUMN_NAME
00428       18,
00429       offsetof(INDEXINFO, wszColName),
00430       0,
00431       0,
00432       NULL,
00433       NULL,
00434       NULL,
00435       DBPART_VALUE,
00436       DBMEMOWNER_CLIENTOWNED,
00437       DBPARAMIO_NOTPARAM,
00438       MAX_NAME_LEN,
00439       0,
00440       DBTYPE_WSTR,
00441       0,
00442       0,
00443
00444       //COLLATION
00445       21,
00446       offsetof(INDEXINFO, dwCollation),
00447       0,
00448       0,
00449       NULL,
00450       NULL,
00451       NULL,
00452       DBPART_VALUE,
00453       DBMEMOWNER_CLIENTOWNED,
00454       DBPARAMIO_NOTPARAM,
00455       sizeof(DWORD),
00456       0,
00457       DBTYPE_I4,
00458       0,
00459       0,
00460     };
00461
00462   //set up the restrictions
00463   const ULONG cRestrictions = 5;
00464   VARIANT  rgRestrictions[cRestrictions];
00465
00466   //set up the restrictions
00467   InitVariants(cRestrictions, rgRestrictions);
00468   SetRestriction(&rgRestrictions[0], pCFromTable->m_pCDataSource->m_pwszCatalog);
00469   SetRestriction(&rgRestrictions[1], pCFromTable->m_TableInfo.wszSchemaName);
00470   SetRestriction(&rgRestrictions[4], pCFromTable->m_TableInfo.wszTableName);
00471
00472   //GetRowset
00473   //DBSCHEMA_INDEXES may not be supported by the driver.
00474   //If an error occurs, just don't display IndexInfo
00475   QTESTC(hr = pIDBSchemaRowset->GetRowset(NULL, DBSCHEMA_INDEXES, cRestrictions, rgRestrictions,
00476                     IID_IRowset, 0, NULL, (IUnknown **)&pIRowset));
00477
00478   XTESTC(hr = pIRowset->QueryInterface(IID_IAccessor, (void **)&pIAccessor));
00479
00480   //Create Accessor for IndexInfo
00481   XTESTC(hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, 0, &hAccessor, NULL));
00482
00483   while(TRUE)
00484   {
00485     XTESTC(hr = pIRowset->GetNextRows(NULL, 0, MAX_BLOCK_SIZE, &cRowsObtained, &rghRows));
00486
00487     //ENDOFROWSET
00488     if(cRowsObtained==0)
00489       break;
00490
00491     //Realloc Table struct for Indexes
00492     SAFE_REALLOC(pCFromTable->m_rgIndexInfo, INDEXINFO, pCFromTable->m_cIndexes + cRowsObtained);
00493     memset(&pCFromTable->m_rgIndexInfo[pCFromTable->m_cIndexes], 0, cRowsObtained*sizeof(INDEXINFO));
00494
00495     //Loop over rows obtained
00496     for(ULONG i=0; i<cRowsObtained; i++)
00497     {
00498       INDEXINFO* pIndexInfo = &pCFromTable->m_rgIndexInfo[pCFromTable->m_cIndexes];
00499
00500       //Get the Data
00501       XTESTC(hr = pIRowset->GetData(rghRows[i], hAccessor, (void*)pIndexInfo));
00502
00503       //If this is an index the ordinal will be 1 based
00504       if(pIndexInfo->iOrdinal==0)
00505         continue;
00506
00507       //Only list the index if the column was selected to be copied
00508       for(ULONG iCol=0; iCol<pCFromTable->m_cColumns; iCol++)
00509       {
00510         if(wcscmp(pCFromTable->m_rgColDesc[iCol].wszColName, pIndexInfo->wszColName)==0)
00511         {
00512           //Now that we have an actual index...
00513           pCFromTable->m_cIndexes++;
00514           break;
00515         }
00516       }
00517
00518     }
00519
00520     //Release all the rows
00521     XTESTC(hr = pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL));
00522     SAFE_FREE(rghRows);
00523   }
00524
00525   //GetPrimaryKey info
00526   //Since DBSCHEMA_INDEXES doesn't have to return PrimaryKey info correctly (NULL)
00527   //we will call DBSCHEMA_PRIMARYKEYS before displaying IndexInfo to make sure
00528   //which columns are really PrimaryKeys.
00529   GetPrimaryKeys();
00530
00531   //Now list all indexes to the Index ListView window
00532   for(i=0; i<pCFromTable->m_cIndexes; i++)
00533   {
00534     INDEXINFO* pIndexInfo = &pCFromTable->m_rgIndexInfo[i];
00535
00536     //INDEXNAME (item)
00537     ConvertToMBCS(pIndexInfo->wszIndexName, szBuffer, MAX_NAME_LEN);
00538     LV_InsertItem(hWnd, i, COL_INDEXNAME, szBuffer, 0, pIndexInfo->fIsPrimaryKey ? INDEXTYPE_PRIMARYKEY : INDEXTYPE_INDEX);
00539
00540     //INDEXCOLNAME (subitem)
00541     ConvertToMBCS(pIndexInfo->wszColName, szBuffer, MAX_NAME_LEN);
00542     LV_InsertItem(hWnd, i, COL_INDEXCOLNAME, szBuffer);
00543
00544     //FLAGS (subitem)
00545     LV_InsertItem(hWnd, i, COL_UNIQUE, pIndexInfo->fUnique ? "TRUE" : "FALSE");
00546     LV_InsertItem(hWnd, i, COL_PRIMARYKEY, pIndexInfo->fIsPrimaryKey ? "TRUE" : "FALSE");
00547     LV_InsertItem(hWnd, i, COL_AUTOUPDATE, pIndexInfo->fAutoUpdate ? "TRUE" : "FALSE");
00548     LV_InsertItem(hWnd, i, COL_COLLATION, (pIndexInfo->dwCollation == DB_COLLATION_ASC) ? "ASC" : (pIndexInfo->dwCollation == DB_COLLATION_DESC) ? "DESC" : "NULL");
00549     LV_InsertItem(hWnd, i, COL_NULLS, (pIndexInfo->dwNulls == DBPROPVAL_IN_DISALLOWNULL) ? "DISALLOWNULL" : (pIndexInfo->dwNulls == DBPROPVAL_IN_IGNORENULL) ? "IGNORENULL" : "IGNOREANYNULL");
00550   }
00551
00552
00553   // If there was a previous selection, select it again on Back
00554   if(rgSelIndexInfo)
00555   {
00556     LONG lFoundIndex = -1;
00557     for(i=0; i<cSelIndexes; i++)
00558     {
00559       //Find the "index" of the existing index
00560       ConvertToMBCS(rgSelIndexInfo[i].wszIndexName, szBuffer, MAX_NAME_LEN);
00561       lFoundIndex = LV_FindItem(hWnd, szBuffer, lFoundIndex);
00562
00563         //If there was a selection, select it now
00564         if(lFoundIndex != LVM_ERR)
00565       {
00566         LV_SetItemState(hWnd, lFoundIndex, COL_INDEXNAME, LVIS_SELECTED, LVIS_SELECTED);
00567
00568         //Ensure that the first item is visible
00569         if(i==0)
00570           SendMessage(hWnd, LVM_ENSUREVISIBLE, (WPARAM)lFoundIndex, (LPARAM)FALSE);
00571       }
00572     }
00573
00574   }
00575   //Otherwise select all as default
00576   else
00577   {
00578     for(i=0; i<pCFromTable->m_cIndexes; i++)
00579       LV_SetItemState(hWnd, i, COL_INDEXNAME, LVIS_SELECTED, LVIS_SELECTED);
00580   }
00581
00582   //Only enable the ListBox/Title if there are indexes
00583   EnableWindow(GetDlgItem(m_hWnd, IDT_INDEXMSG),  pCFromTable->m_cIndexes);
00584   EnableWindow(hWnd,  pCFromTable->m_cIndexes);
00585
00586     //AutoSize Index/ColName
00587   if(pCFromTable->m_cIndexes)
00588   {
00589     SendMessage(hWnd, LVM_SETCOLUMNWIDTH, (WPARAM)COL_INDEXNAME, (LPARAM)LVSCW_AUTOSIZE);
00590     SendMessage(hWnd, LVM_SETCOLUMNWIDTH, (WPARAM)COL_INDEXCOLNAME, (LPARAM)LVSCW_AUTOSIZE);
00591   }
00592
00593 CLEANUP:
00594   //Free Resriticions
00595   FreeVariants(cRestrictions, rgRestrictions);
00596
00597   if(hAccessor && pIAccessor)
00598     XTEST(pIAccessor->ReleaseAccessor(hAccessor,NULL));
00599
00600   SAFE_RELEASE(pIRowset);
00601   SAFE_RELEASE(pIAccessor);
00602   SAFE_FREE(rghRows);
00603   SAFE_FREE(rgSelIndexInfo);
00604   return hr==S_OK;
00605 }
00606
00607
00608
00609
00610 /////////////////////////////////////////////////////////////////////////////
00611 // BOOL CS2Dialog::GetPrimaryKeys
00612 //
00613 /////////////////////////////////////////////////////////////////////////////
00614 BOOL CS2Dialog::GetPrimaryKeys()
00615 {
00616   HRESULT hr;
00617
00618   HROW* rghRows = NULL;
00619   ULONG cRowsObtained = 0;
00620   IRowset* pIRowset = NULL;
00621
00622   IAccessor* pIAccessor = NULL;
00623   HACCESSOR hAccessor = DB_NULL_HACCESSOR;
00624
00625   PRIMARYKEY PrimaryKey;
00626
00627   //Use the passed in Session interface
00628   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00629   IOpenRowset* pIOpenRowset = pCFromTable->m_pCDataSource->m_pIOpenRowset;
00630   IDBSchemaRowset* pIDBSchemaRowset = pCFromTable->m_pCDataSource->m_pIDBSchemaRowset;
00631
00632   //Provider doesn't have to support IDBSchemaRowset
00633   if(pIDBSchemaRowset == NULL)
00634     return TRUE;
00635
00636   // Bind the user and table name for the list
00637   const static ULONG cBindings = 1;
00638   const static DBBINDING rgBindings[cBindings] =
00639     {
00640       4,
00641       offsetof(PRIMARYKEY, wszColName),
00642       0,
00643       0,
00644       NULL,
00645       NULL,
00646       NULL,
00647       DBPART_VALUE,
00648       DBMEMOWNER_CLIENTOWNED,
00649       DBPARAMIO_NOTPARAM,
00650       MAX_NAME_LEN,
00651       0,
00652       DBTYPE_WSTR,
00653       0,
00654       0,
00655     };
00656
00657   //set up the restrictions
00658   const ULONG cRestrictions = 3;
00659   VARIANT  rgRestrictions[cRestrictions];
00660
00661   //set up the restrictions
00662   InitVariants(cRestrictions, rgRestrictions);
00663   SetRestriction(&rgRestrictions[0], pCFromTable->m_pCDataSource->m_pwszCatalog);
00664   SetRestriction(&rgRestrictions[1], pCFromTable->m_TableInfo.wszSchemaName);
00665   SetRestriction(&rgRestrictions[2], pCFromTable->m_TableInfo.wszTableName);
00666
00667   //GetRowset
00668   //DBSCHEMA_PRIMARY_KEYS may not be supported by the driver.
00669   //If an error occurs, just don't display PrimaryKey info
00670   QTESTC(hr = pIDBSchemaRowset->GetRowset(NULL, DBSCHEMA_PRIMARY_KEYS, cRestrictions, rgRestrictions,
00671                     IID_IRowset, 0, NULL, (IUnknown **)&pIRowset));
00672
00673   XTESTC(hr = pIRowset->QueryInterface(IID_IAccessor, (void **)&pIAccessor));
00674
00675   //Create Accessor for IndexInfo
00676   XTESTC(hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, 0, &hAccessor, NULL));
00677
00678   while(TRUE)
00679   {
00680     XTESTC(hr = pIRowset->GetNextRows(NULL, 0, MAX_BLOCK_SIZE, &cRowsObtained, &rghRows));
00681
00682     //ENDOFROWSET
00683     if(cRowsObtained==0)
00684       break;
00685
00686     for(ULONG i=0; i<cRowsObtained; i++)
00687     {
00688       //Reset the PrimaryKey
00689       memset(&PrimaryKey, 0, sizeof(PRIMARYKEY));
00690
00691       //Get the Data
00692       XTESTC(hr = pIRowset->GetData(rghRows[i], hAccessor, (void*)&PrimaryKey));
00693
00694       //Need to find the corresponding column in IndexInfo and
00695       //mark it as a primary key column
00696       for(ULONG iIndex=0; iIndex<pCFromTable->m_cIndexes; iIndex++)
00697         if(wcscmp(PrimaryKey.wszColName, pCFromTable->m_rgIndexInfo[iIndex].wszColName)==0)
00698           pCFromTable->m_rgIndexInfo[iIndex].fIsPrimaryKey = TRUE;
00699
00700       //Need to find the corresponding column in m_rgColDesc and mark it as a primary key column
00701       for(i=0; i<pCFromTable->m_cColumns; i++)
00702         if(wcscmp(PrimaryKey.wszColName, pCFromTable->m_rgColDesc[i].wszColName)==0)
00703           pCFromTable->m_rgColDesc[i].fIsPrimaryKey = TRUE;
00704     }
00705
00706     //Release all the rows
00707     XTESTC(hr = pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL));
00708     SAFE_FREE(rghRows);
00709   }
00710
00711 CLEANUP:
00712   //Free Resriticions
00713   FreeVariants(cRestrictions, rgRestrictions);
00714
00715   if(hAccessor && pIAccessor)
00716     XTEST(pIAccessor->ReleaseAccessor(hAccessor,NULL));
00717
00718   SAFE_RELEASE(pIRowset);
00719   SAFE_RELEASE(pIAccessor);
00720   SAFE_FREE(rghRows);
00721   return hr==S_OK;
00722 }
00723
00724
00725
00726 /////////////////////////////////////////////////////////////////////////////
00727 // BOOL CS2Dialog::RecordSelectedIndexes
00728 //
00729 /////////////////////////////////////////////////////////////////////////////
00730 BOOL CS2Dialog::RecordSelectedIndexes(HWND hWnd)
00731 {
00732   CTable* pCTable = m_pCTableCopy->m_pCFromTable;
00733   LONG i;
00734
00735   // Get the count of selected items
00736   LONG cSelIndexes = SendMessage(hWnd, LVM_GETSELECTEDCOUNT, (WPARAM)0, (LPARAM)0);
00737   LONG iIndex = -1;
00738
00739   //Loop over all the indexes
00740   pCTable->m_cIndexes = cSelIndexes;
00741   for(i=0; i<cSelIndexes; i++)
00742   {
00743     iIndex = SendMessage(hWnd, LVM_GETNEXTITEM, (WPARAM)iIndex, (LPARAM)LVNI_SELECTED);
00744
00745     //"compact" the m_rgColDesc array to only the selected items
00746     if(iIndex != LVM_ERR)
00747       memmove(&pCTable->m_rgIndexInfo[i], &pCTable->m_rgIndexInfo[iIndex], sizeof(INDEXINFO));
00748   }
00749
00750   return TRUE;
00751 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/basesnap.h Source File

  • SysMgmt
  • MMC
  • ActiveX

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/inc/IsapiBuffer.h Source File

  • Web
  • iis
  • ISAPI_6.0
  • inc

IsapiBuffer.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiBuffer.h
00006
00007 Abstract:
00008
00009     A simple buffer class
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee), October 2002
00014
00015 --*/
00016
00017 #ifndef _isapibuffer_h
00018 #define _isapibuffer_h
00019
00020 #include <IsapiTools.h>
00021
00022 //
00023 // Set some default values for the buffer object
00024 //
00025 // DEFAULT_MAX_ALLOC_SIZE - The maximum value allowed by
00026 //                          the ISABUFFER::Resize method.
00027 //
00028 // INLINE_BUFFER_SIZE     - The size of the inline storage
00029 //                          buffer for the ISABUFFER object
00030 //
00031 //
00032
00033 #define DEFAULT_MAX_ALLOC_SIZE       16384
00034 #define INLINE_BUFFER_SIZE             256
00035
00036 class ISAPI_BUFFER
00037 {
00038 public:
00039
00040     ISAPI_BUFFER(
00041         DWORD   dwMaxAlloc = 0 // 0 defaults to DEFAULT_MAX_ALLOC_SIZE
00042         );
00043
00044     virtual
00045     ~ISAPI_BUFFER();
00046
00047     BOOL
00048     SetData(
00049         VOID *  pData,
00050         DWORD   cbData
00051         );
00052
00053     BOOL
00054     AppendData(
00055         VOID *  pData,
00056         DWORD   cbData
00057         );
00058
00059     BOOL
00060     Resize(
00061         DWORD   cbNewSize
00062         );
00063
00064     VOID
00065     Reset(
00066         BOOL    fDealloc = FALSE
00067         );
00068
00069     BOOL
00070     SetDataSize(
00071         DWORD   cbNewSize
00072         );
00073
00074     VOID
00075     SetMaxAlloc(
00076         DWORD   dwMaxAlloc
00077         );
00078
00079     DWORD
00080     QueryMaxAlloc(
00081         VOID
00082         );
00083
00084     VOID *
00085     QueryPtr(
00086         VOID
00087         );
00088
00089     DWORD
00090     QueryDataSize(
00091         VOID
00092         );
00093
00094     DWORD
00095     QueryBufferSize(
00096         VOID
00097         );
00098
00099     BOOL
00100     Base64Decode(
00101         CHAR *  szString
00102         );
00103
00104     VOID
00105     ZeroBuffer(
00106         VOID
00107         );
00108
00109 private:
00110
00111     VOID *  _pData;
00112     BYTE    _InlineData[INLINE_BUFFER_SIZE];
00113     DWORD   _cbData;
00114     DWORD   _cbBuffer;
00115     DWORD   _dwMaxAlloc;
00116 };
00117
00118 #endif  // _isapibuffer_h
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/FullSvr/stdafx.h Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • FullSvr

stdafx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: StdAfx.h
00004
00005 Summary:  Produced by VS6 ATL Wizard.
00006
00007 ----------------------------------------------------------------------------
00008
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021
00022 ==========================================================================+*/
00023
00024 // stdafx.h : include file for standard system include files,
00025 //      or project specific include files that are used frequently,
00026 //      but are changed infrequently
00027
00028 #if !defined(AFX_STDAFX_H__D1A7E4AA_6E66_443E_AE63_FF6B1E52EA9C__INCLUDED_)
00029 #define AFX_STDAFX_H__D1A7E4AA_6E66_443E_AE63_FF6B1E52EA9C__INCLUDED_
00030
00031 #if _MSC_VER > 1000
00032 #pragma once
00033 #endif // _MSC_VER > 1000
00034
00035 #define STRICT
00036 #ifndef _WIN32_WINNT
00037 #define _WIN32_WINNT 0x0500
00038 #endif
00039 #define _ATL_FREE_THREADED
00040
00041 #include <atlbase.h>
00042 //You may derive a class from CComModule and use it if you want to override
00043 //something, but do not change the name of _Module
00044 class CExeModule : public CComModule
00045 {
00046 public:
00047   LONG Unlock();
00048   DWORD dwThreadID;
00049   HANDLE hEventShutdown;
00050   void MonitorShutdown();
00051   bool StartMonitor();
00052   bool bActivity;
00053 };
00054 extern CExeModule _Module;
00055 #include <atlcom.h>
00056 //{{AFX_INSERT_LOCATION}}
00057 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00058
00059 #endif // !defined(AFX_STDAFX_H__D1A7E4AA_6E66_443E_AE63_FF6B1E52EA9C__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/Acex.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

Acex.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "acex.h"
00052
00053 // Dispatch interfaces referenced by this interface
00054 #include "ACChars.h"
00055 #include "ACProp.h"
00056 #include "ACAudio.h"
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // CAgentCtlEx
00060
00061 IMPLEMENT_DYNCREATE(CAgentCtlEx, CWnd)
00062
00063 /////////////////////////////////////////////////////////////////////////////
00064 // CAgentCtlEx properties
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // CAgentCtlEx operations
00068
00069 CAgentCtlCharacters CAgentCtlEx::GetCharacters()
00070 {
00071   LPDISPATCH pDispatch;
00072   InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
00073   return CAgentCtlCharacters(pDispatch);
00074 }
00075
00076 CAgentCtlAudioObject CAgentCtlEx::GetAudioOutput()
00077 {
00078   LPDISPATCH pDispatch;
00079   InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
00080   return CAgentCtlAudioObject(pDispatch);
00081 }
00082
00083 LPDISPATCH CAgentCtlEx::GetSpeechInput()
00084 {
00085   LPDISPATCH result;
00086   InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
00087   return result;
00088 }
00089
00090 CAgentCtlPropertySheet CAgentCtlEx::GetPropertySheet()
00091 {
00092   LPDISPATCH pDispatch;
00093   InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
00094   return CAgentCtlPropertySheet(pDispatch);
00095 }
00096
00097 LPDISPATCH CAgentCtlEx::GetCommandsWindow()
00098 {
00099   LPDISPATCH result;
00100   InvokeHelper(0xc, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
00101   return result;
00102 }
00103
00104 BOOL CAgentCtlEx::GetConnected()
00105 {
00106   BOOL result;
00107   InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00108   return result;
00109 }
00110
00111 void CAgentCtlEx::SetConnected(BOOL bNewValue)
00112 {
00113   static BYTE parms[] =
00114     VTS_BOOL;
00115   InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00116      bNewValue);
00117 }
00118
00119 BOOL CAgentCtlEx::GetSuspended()
00120 {
00121   BOOL result;
00122   InvokeHelper(0xe, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00123   return result;
00124 }
00125
00126 void CAgentCtlEx::ShowDefaultCharacterProperties(const VARIANT& x, const VARIANT& y)
00127 {
00128   static BYTE parms[] =
00129     VTS_VARIANT VTS_VARIANT;
00130   InvokeHelper(0x14, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
00131      &x, &y);
00132 }
00133
00134 BOOL CAgentCtlEx::GetRaiseRequestErrors()
00135 {
00136   BOOL result;
00137   InvokeHelper(0x15, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00138   return result;
00139 }
00140
00141 void CAgentCtlEx::SetRaiseRequestErrors(BOOL bNewValue)
00142 {
00143   static BYTE parms[] =
00144     VTS_BOOL;
00145   InvokeHelper(0x15, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00146      bNewValue);
00147 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/SampleMSP/stdafx.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • SampleMSP

stdafx.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007      stdafx.h
00008
00009 Abstract:
00010
00011         include file for standard system include files,
00012         or project specific include files that are used frequently,
00013         but are changed infrequently
00014
00015 --*/
00016
00017 #if !defined(AFX_STDAFX_H__902A4A47_56FA_11D1_8F46_00C04FB6809F__INCLUDED_)
00018 #define AFX_STDAFX_H__902A4A47_56FA_11D1_8F46_00C04FB6809F__INCLUDED_
00019
00020 #if _MSC_VER >= 1000
00021 #pragma once
00022 #endif // _MSC_VER >= 1000
00023
00024
00025 //
00026 // note: this sample includes atlbase.h to check version of ATL being used.
00027 // otherwise, the include would not be needed.
00028 //
00029
00030 #include <atlbase.h>
00031 #undef STRICT
00032
00033
00034 #include <mspbase.h>
00035 #include "common.h"
00036
00037 //{{AFX_INSERT_LOCATION}}
00038 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00039
00040 #endif // AFX_STDAFX_H__902A4A47_56FA_11D1_8F46_00C04FB6809F__INCLUDED_
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/PrintSdi.h Source File

  • NetDS
  • fax
  • PrintSdi

PrintSdi.h

Go to the documentation of this file.
00001 // PrintSDI.h : main header file for the PRINTSDI application
00002 //
00003
00004 #if !defined(AFX_PRINTSDI_H__55689543_8B6C_11D1_B7AE_000000000000__INCLUDED_)
00005 #define AFX_PRINTSDI_H__55689543_8B6C_11D1_B7AE_000000000000__INCLUDED_
00006
00007 #if _MSC_VER >= 1000
00008 #pragma once
00009 #endif // _MSC_VER >= 1000
00010
00011 #ifndef __AFXWIN_H__
00012   #error include 'stdafx.h' before including this file for PCH
00013 #endif
00014
00015 #include "resource.h"       // main symbols
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CPrintSDIApp:
00019 // See PrintSDI.cpp for the implementation of this class
00020 //
00021
00022 class CPrintSDIApp : public CWinApp
00023 {
00024 public:
00025   CPrintSDIApp();
00026
00027 // Overrides
00028   // ClassWizard generated virtual function overrides
00029   //{{AFX_VIRTUAL(CPrintSDIApp)
00030   public:
00031   virtual BOOL InitInstance();
00032   //}}AFX_VIRTUAL
00033
00034 // Implementation
00035
00036   //{{AFX_MSG(CPrintSDIApp)
00037   afx_msg void OnAppAbout();
00038     // NOTE - the ClassWizard will add and remove member functions here.
00039     //    DO NOT EDIT what you see in these blocks of generated code !
00040   //}}AFX_MSG
00041   DECLARE_MESSAGE_MAP()
00042 };
00043
00044
00045 /////////////////////////////////////////////////////////////////////////////
00046
00047 //{{AFX_INSERT_LOCATION}}
00048 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00049
00050 #endif // !defined(AFX_PRINTSDI_H__55689543_8B6C_11D1_B7AE_000000000000__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/compdata.h Source File

  • SysMgmt
  • MMC
  • WMI

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData, IExtendPropertySheet2
00028 {
00029     friend class CComponent;
00030
00031 private:
00032     ULONG       m_cref;
00033     LPCONSOLE     m_ipConsole;
00034     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00035
00036     CStaticNode     *m_pStaticNode;
00037
00038 public:
00039     CComponentData();
00040     ~CComponentData();
00041
00042     ///////////////////////////////
00043     // Interface IUnknown
00044     ///////////////////////////////
00045     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046     STDMETHODIMP_(ULONG) AddRef();
00047     STDMETHODIMP_(ULONG) Release();
00048
00049     ///////////////////////////////
00050     // Interface IComponentData
00051     ///////////////////////////////
00052     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053         /* [in] */ LPUNKNOWN pUnknown);
00054
00055         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00056         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00059         /* [in] */ LPDATAOBJECT lpDataObject,
00060         /* [in] */ MMC_NOTIFY_TYPE event,
00061         /* [in] */ LPARAM arg,
00062         /* [in] */ LPARAM param);
00063
00064         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00065
00066     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00067         /* [in] */ MMC_COOKIE cookie,
00068         /* [in] */ DATA_OBJECT_TYPES type,
00069         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00070
00071         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075         /* [in] */ LPDATAOBJECT lpDataObjectA,
00076         /* [in] */ LPDATAOBJECT lpDataObjectB);
00077
00078         //////////////////////////////////
00079         // Interface IExtendPropertySheet2
00080         //////////////////////////////////
00081         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreatePropertyPages(
00082         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00083         /* [in] */ LONG_PTR handle,
00084         /* [in] */ LPDATAOBJECT lpIDataObject);
00085
00086         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryPagesFor(
00087         /* [in] */ LPDATAOBJECT lpDataObject);
00088
00089         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetWatermarks(
00090         /* [in] */ LPDATAOBJECT lpIDataObject,
00091         /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00092         /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00093         /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00094         /* [out] */ BOOL __RPC_FAR *bStretch);
00095 };
00096
00097 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/virtualfile.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

virtualfile.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Implements our virtual file class derived from CBaseNode.  This
00014 //             class will represent our result items
00015 //
00016
00017 #include "VirtualFile.h"
00018 #include "Globals.h"
00019 #include "CompData.h"
00020 #include "Comp.h"
00021 #include "FolderNode.h"
00022                              // Tracing stuff
00023 #include "TraceMacro.h"
00024 #undef  MODULESTRING
00025 #define MODULESTRING  _T("CVirtualFile")
00026
00027
00028 // Initialize our static GUID just once
00029 GUID CVirtualFile::thisGUID = CLSID_CVirtualFile;
00030
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 // Construction/Destruction
00034
00035 CVirtualFile::CVirtualFile()
00036 {
00037   m_RDI.mask       = DEFAULT_RDI_MASK;
00038   m_RDI.str        = MMC_CALLBACK;
00039   m_RDI.nImage     = IMG_DATA_FILE;
00040   m_RDI.lParam     = reinterpret_cast<LPARAM>(this);
00041
00042   m_pParentFolder  = NULL;
00043   m_pCompData      = NULL;
00044   m_nPropPageCount = 1;      // PROPPAGE: Set the number of Property Pages
00045   m_nNotifyHandle  = 0;      // Cached notification handle.
00046 }
00047
00048 CVirtualFile::~CVirtualFile()
00049 {
00050 }
00051
00052 //---------------------------------------------------------------------------
00053 //  This node needs to know it's parent so that it can notify the parent
00054 //  that it's deleting itself in response to a MMCN_DELETE notification.
00055 //
00056 HRESULT CVirtualFile::Initialize( NODE_PROPERTIES* pNodeProps )
00057 {
00058   _ASSERT( NULL != pNodeProps );
00059
00060   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00061   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00062   wcscpy( pszTmp, pNodeProps->szNodeName );
00063   if( NULL != m_pwszNodeName )
00064     CoTaskMemFree( m_pwszNodeName );
00065
00066   m_pwszNodeName  = pszTmp;
00067   m_pParentFolder = reinterpret_cast<CFolderNode*>(pNodeProps->pParentObject);
00068   m_pCompData     = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00069   m_dwAttributes  = pNodeProps->dwAttributes;
00070
00071   return S_OK;
00072 }
00073
00074
00075 /////////////////////////////////////////////////////////////////////////////
00076 // Implementation of virtual methods
00077
00078 //---------------------------------------------------------------------------
00079 HRESULT CVirtualFile::GetDisplayInfo
00080 (
00081   RESULTDATAITEM* pRDI       //[in-out] RESULTDATAITEM struct
00082 )
00083 {
00084   HRESULT hResult = S_OK;
00085
00086   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00087   {                                  // for each column
00088     switch( pRDI->nCol )
00089     {
00090       case 0:
00091         pRDI->str = m_pwszNodeName;
00092         break;
00093
00094       case 1:                        // Return Attributes as string
00095         pRDI->str = GetAttributeString();
00096         break;
00097
00098       default:
00099         hResult = S_FALSE;
00100         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00101         break;
00102     }
00103   }
00104
00105   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00106   {
00107     pRDI->nImage = m_RDI.nImage;
00108   }
00109
00110   //TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00111   return hResult;
00112 }
00113
00114
00115 /////////////////////////////////////////////////////////////////////////////
00116 // Implementation of virtual methods
00117
00118 //---------------------------------------------------------------------------
00119 HRESULT CVirtualFile::OnSelect
00120 (
00121   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00122   LONG          nArg,          //[in] Bools for context & selection state
00123   LONG          nParam,        //[in] Not used
00124   LONG_PTR      pComponent     //[in] Points calling CComponent
00125 )
00126 {
00127   HRESULT hResult = S_FALSE;
00128
00129   BOOL    fScopePane = LOWORD(nArg);
00130   BOOL    fSelected  = HIWORD(nArg);
00131
00132   // Don't care about de-select notifications so just return
00133   if( FALSE == fSelected )
00134     return hResult;
00135
00136   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00137
00138   IConsoleVerb* ipConsoleVerb = NULL;
00139   hResult = pComp->GetInterface( REQUEST_ICONSOLEVERB, (LONG_PTR*)&ipConsoleVerb );
00140   if( S_OK != hResult )
00141    return hResult;
00142
00143   // PROPPAGE:  Adding the Properties verb and making it the default
00144   hResult = ipConsoleVerb->SetVerbState( MMC_VERB_DELETE,     ENABLED, TRUE );
00145   hResult = ipConsoleVerb->SetVerbState( MMC_VERB_PROPERTIES, ENABLED, TRUE );
00146
00147   hResult = ipConsoleVerb->SetDefaultVerb( MMC_VERB_PROPERTIES );
00148
00149   TRACE_HRESULT(_T("OnSelect"), hResult );
00150   return hResult;
00151 }
00152
00153 //---------------------------------------------------------------------------
00154 HRESULT CVirtualFile::OnShow
00155 (
00156   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00157   LONG          nArg,          //[in] TRUE if node was selcted
00158   LONG          nParam,        //[in] HSCOPEITEM of selected/deselected item
00159   LONG_PTR      pComponent     //[in] Points calling CComponent
00160 )
00161 {
00162   HRESULT  hResult = S_FALSE;
00163
00164   TRACE_HRESULT(_T("OnShow"), hResult );
00165   return hResult;
00166 }
00167
00168 //---------------------------------------------------------------------------
00169 HRESULT CVirtualFile::OnDelete
00170 (
00171   LPDATAOBJECT ipDataObject,   //[in] Points to Data Object
00172   LONG         nArg,           //[in] Not used
00173   LONG         nParam,         //[in] Not used
00174   LONG_PTR     pComponent      //[in] Points to calling IComponent
00175 )
00176 {
00177   _ASSERT( NULL != ipDataObject );
00178   _ASSERT( NULL != m_pParentFolder );
00179
00180   HRESULT hResult = S_FALSE;
00181
00182   m_pParentFolder->RemoveVirtualFile( this );
00183
00184   LPRESULTDATA ipResultData = NULL;
00185   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00186   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00187   if( S_OK != hResult )
00188     return hResult;
00189
00190   ipResultData->DeleteItem( m_RDI.itemID, 0 );
00191   delete this;
00192
00193   return hResult;
00194 }
00195
00196 /////////////////////////////////////////////////////////////////////////////
00197 //  IExtendContextMenu implementation
00198
00199 //---------------------------------------------------------------------------
00200 HRESULT CVirtualFile::AddMenuItems
00201 (
00202   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00203   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00204 )
00205 {
00206   HRESULT hResult = E_NOTIMPL;
00207   return hResult;
00208 }
00209
00210
00211 //---------------------------------------------------------------------------
00212 HRESULT CVirtualFile::Command
00213 (
00214   long lCommandID          //[in] Indentifier for menu ID
00215 )
00216 {
00217   HRESULT hResult = E_NOTIMPL;
00218   return hResult;
00219 }
00220
00221 /////////////////////////////////////////////////////////////////////////////
00222 //  IExtendPropertySheet2 implementation
00223
00224 //---------------------------------------------------------------------------
00225 //  Tell the console that this node supports property pages
00226 //
00227 HRESULT CVirtualFile::QueryForPropertyPage()
00228 {
00229   TRACE_HRESULT(_T("OnShow"), S_OK );
00230   return S_OK;
00231 }
00232
00233
00234 //---------------------------------------------------------------------------
00235 HRESULT CVirtualFile::CreatePropertyPages
00236 (
00237   LPPROPERTYSHEETCALLBACK lpCallback,  //[in] Pointer to callback interface
00238   LONG_PTR                Handle       //[in] Routing handle
00239 )
00240 {
00241   HRESULT hResult = S_FALSE;
00242
00243   m_nNotifyHandle = Handle;            // Cache the routing handle
00244
00245   // Create an array of PropertySheetPages
00246   HPROPSHEETPAGE* hPPages = new HPROPSHEETPAGE[m_nPropPageCount];
00247   if( NULL == hPPages )
00248     return E_OUTOFMEMORY;
00249
00250   PROPSHEETPAGE  psp;
00251
00252   psp.dwSize      = sizeof(PROPSHEETPAGE);
00253   psp.dwFlags     = PSP_DEFAULT | PSP_USETITLE | PSP_HASHELP;
00254   psp.hInstance   = g_hInst;
00255   psp.pszTemplate = MAKEINTRESOURCE(IDD_VFILE_PPAGE0);
00256   psp.pfnDlgProc  = PPageWndProc0;
00257   psp.lParam      = reinterpret_cast<LPARAM>(this);
00258   psp.pszTitle    = _T("General");
00259   psp.pfnCallback = NULL;
00260
00261
00262   hPPages[0] = ::CreatePropertySheetPage( &psp );
00263
00264   // Add the pages to the console's Property Sheet
00265   for( LONG nPageCount = 0; nPageCount < m_nPropPageCount; nPageCount++ )
00266   {
00267     hResult = lpCallback->AddPage( hPPages[nPageCount] );
00268     BREAK_ON_ERROR( hResult );
00269   }
00270
00271   delete [] hPPages;
00272
00273   return hResult;
00274 }
00275
00276 //---------------------------------------------------------------------------
00277 HRESULT CVirtualFile::GetWatermarks
00278 (
00279   HBITMAP __RPC_FAR*  lphWatermark,  //[out] Pointer to watermark bitmap
00280   HBITMAP __RPC_FAR*  lphHeader,     //[out] Pointer to header bitmap
00281   HPALETTE __RPC_FAR* lphPalette,    //[out] Pointer to palette
00282   BOOL __RPC_FAR*     bStretch       //[out] TRUE to stretch instead of tile
00283 )
00284 {
00285   HRESULT hResult = S_FALSE;
00286
00287
00288   return hResult;
00289 }
00290
00291 //---------------------------------------------------------------------------
00292 //
00293 //
00294 BOOL CALLBACK CVirtualFile::PPageWndProc0
00295 (
00296   HWND    hPage,     //[in] Handle to property page
00297   UINT    uMsg,      //[in] Message
00298   WPARAM  wParam,    //[in] First message parameter
00299   LPARAM  lParam     //[in] Second message parameter
00300 )
00301 {
00302   static CVirtualFile* pVFile  = NULL;
00303          BOOL          bReturn = FALSE;
00304
00305   switch( uMsg )                       // Begin message switch
00306   {
00307     case WM_INITDIALOG:
00308     {
00309       // Cache the pointer to the calling instance of CVirtualFile and
00310       // call it's OnInitPropPage method
00311       PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
00312       pVFile = reinterpret_cast<CVirtualFile*>(psp->lParam);
00313       pVFile->OnInitPropPage( hPage, wParam, lParam );
00314       break;
00315     }
00316     case WM_HELP:
00317     {
00318       // Not handling WM_HELP in this sample
00319       break;
00320     }
00321     case WM_COMMAND:
00322     {
00323       // Activate the 'Apply' button if the user clicked a button
00324       if( BN_CLICKED == HIWORD(wParam) )
00325         SendMessage(GetParent(hPage), PSM_CHANGED, (WPARAM)hPage, 0);
00326
00327       break;
00328     }
00329     case WM_DESTROY:
00330     {
00331       MMCFreeNotifyHandle( pVFile->m_nNotifyHandle );
00332       TRACE_START( _T("WM_DESTROY") );
00333       bReturn = TRUE;
00334     }
00335
00336     case WM_NOTIFY:
00337     {
00338       if( 0 == lParam )  //BUGLIST:  AV if we don't do this
00339         return 0;
00340
00341       switch( (reinterpret_cast<NMHDR*>(lParam))->code )
00342       {
00343         case PSN_APPLY:      // Really the 'OK' button
00344         {
00345           pVFile->OnApplyChanges( hPage, wParam, lParam );
00346           return PSNRET_NOERROR;
00347         }
00348         case PSN_HELP:
00349         {
00350           return PSNRET_NOERROR;
00351         }
00352         default:
00353         {
00354           break;
00355         }
00356       } //end lParam->code switch
00357     } // end WM_NOTIFY
00358
00359     default: break;
00360
00361   } // end uMsg switch
00362
00363   return bReturn;
00364
00365 }
00366
00367 //---------------------------------------------------------------------------
00368 BOOL CVirtualFile::OnInitPropPage
00369 (
00370   HWND     hPage,      //[in] Handle to Property Page
00371   WPARAM   wParam,     //[in] First message parameter
00372   LPARAM   lparam      //[in] Second message parameter
00373 )
00374 {
00375   LRESULT lResult = 0;
00376
00377   HWND hArchiveCtrl  = GetDlgItem( hPage, IDC_ARCHIVE_ATTR  );
00378   HWND hHiddenCtrl   = GetDlgItem( hPage, IDC_HIDDEN_ATTR   );
00379   HWND hLockedCtrl   = GetDlgItem( hPage, IDC_LOCKED_ATTR   );
00380   HWND hReadOnlyCtrl = GetDlgItem( hPage, IDC_READONLY_ATTR );
00381
00382
00383   if( TRUE == IsAttributeSet( ATTRIBUTE_DATA_ARCHIVE ) )
00384     lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_CHECKED, 0 );
00385
00386   if( TRUE == IsAttributeSet( ATTRIBUTE_DATA_HIDDEN ) )
00387     lResult = SendMessage( hHiddenCtrl,  BM_SETCHECK, BST_CHECKED, 0 );
00388
00389   if( TRUE == IsAttributeSet( ATTRIBUTE_DATA_LOCKED ) )
00390     lResult = SendMessage( hLockedCtrl,  BM_SETCHECK, BST_CHECKED, 0 );
00391
00392   if( TRUE == IsAttributeSet( ATTRIBUTE_DATA_READONLY ) )
00393     lResult = SendMessage( hReadOnlyCtrl,  BM_SETCHECK, BST_CHECKED, 0 );
00394
00395   return TRUE;
00396 }
00397
00398 //---------------------------------------------------------------------------
00399 BOOL CVirtualFile::OnApplyChanges
00400 (
00401   HWND     hPage,      //[in] Handle to Property Page
00402   WPARAM   wParam,     //[in] First message parameter
00403   LPARAM   lparam      //[in] Second message parameter
00404 )
00405 {
00406   LRESULT lResult = 0;
00407
00408   HWND hArchiveCtrl = GetDlgItem( hPage, IDC_ARCHIVE_ATTR  );
00409   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00410     SetAttribute( ATTRIBUTE_DATA_ARCHIVE );
00411   else
00412     RemoveAttribute( ATTRIBUTE_DATA_ARCHIVE );
00413
00414   HWND hHiddenCtrl = GetDlgItem( hPage, IDC_HIDDEN_ATTR   );
00415   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00416     SetAttribute( ATTRIBUTE_DATA_HIDDEN );
00417   else
00418     RemoveAttribute( ATTRIBUTE_DATA_HIDDEN );
00419
00420   HWND hLockedCtrl = GetDlgItem( hPage, IDC_LOCKED_ATTR   );
00421   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00422     SetAttribute( ATTRIBUTE_DATA_LOCKED );
00423   else
00424     RemoveAttribute( ATTRIBUTE_DATA_LOCKED );
00425
00426   HWND hReadOnlyCtrl = GetDlgItem( hPage, IDC_READONLY_ATTR   );
00427   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00428     SetAttribute( ATTRIBUTE_DATA_READONLY );
00429   else
00430     RemoveAttribute( ATTRIBUTE_DATA_READONLY );
00431
00432   // PROPPAGE: Now that the node's data has been updated we need to
00433   //           force a redraw to display the changed attributes.  Just
00434   //           send the HRESULTITEM to IComponent::Notify so the node
00435   //           which owns this property page can be redrawn.
00436   //
00437   _ASSERT( NULL != m_nNotifyHandle );
00438   MMCPropertyChangeNotify( m_nNotifyHandle, m_RDI.itemID );
00439
00440   return TRUE;
00441 }
00442
00443
00444 /////////////////////////////////////////////////////////////////////////////
00445 //  CVirtualFile methods
00446
00447 //---------------------------------------------------------------------------
00448 BOOL CVirtualFile::IsAttributeSet
00449 (
00450   DWORD dwAttribute           //[in] Attribute to set
00451 )
00452 {
00453   return (m_dwAttributes & dwAttribute) ? TRUE : FALSE;
00454 }
00455
00456 //---------------------------------------------------------------------------
00457 VOID CVirtualFile::SetAttribute
00458 (
00459   DWORD dwAttribute           //[in] Attribute to set
00460 )
00461 {
00462   m_dwAttributes |= dwAttribute;
00463 }
00464
00465 //---------------------------------------------------------------------------
00466 VOID CVirtualFile::RemoveAttribute
00467 (
00468   DWORD dwAttribute           //[in] Attribute to remove
00469 )
00470 {
00471   m_dwAttributes &= ~dwAttribute;
00472 }
00473
00474 //---------------------------------------------------------------------------
00475 //
00476 LPWSTR CVirtualFile::GetAttributeString()
00477 {
00478   *m_pAttributeStr = NULL;
00479
00480   if( IsAttributeSet(ATTRIBUTE_DATA_ARCHIVE) )
00481     wcscat( m_pAttributeStr, L"A " );
00482
00483   if( IsAttributeSet(ATTRIBUTE_DATA_HIDDEN) )
00484     wcscat( m_pAttributeStr, L"H " );
00485
00486   if( IsAttributeSet(ATTRIBUTE_DATA_LOCKED) )
00487     wcscat( m_pAttributeStr, L"L " );
00488
00489   if( IsAttributeSet(ATTRIBUTE_DATA_READONLY) )
00490     wcscat( m_pAttributeStr, L"R " );
00491
00492   return m_pAttributeStr;
00493 }
00494
00495
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

REGSTRUCT Member List

This is the complete list of members for REGSTRUCT, including all inherited members.
hRootKey | REGSTRUCT
lpszData | REGSTRUCT
lpszSubKey | REGSTRUCT
lpszValueName | REGSTRUCT
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/InOut/InOutp.c Source File

  • NetDS
  • RPC
  • Data
  • InOut

InOutp.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                   Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                        inout Example
00005
00006     FILE:       inoutp.c
00007
00008     PURPOSE:    Remote procedures that are linked with the server
00009                 side of RPC distributed application
00010
00011     FUNCTIONS:  InOutProc() - demonstrates in, out parameters
00012
00013     COMMENTS:
00014
00015 ****************************************************************************/
00016
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include "inout.h"    // header file generated by MIDL compiler
00020
00021 #define CONSTANT 257
00022
00023 void InOutProc(short    s1,
00024                short * ps2,
00025                float * pf3)
00026 {
00027     printf("on entry, *pf3 = %f\n", *pf3);
00028
00029     *pf3 = (float) s1 / (float) *ps2;
00030     printf("%d / %d = %0.3f\n", s1, *ps2, *pf3);
00031
00032     *ps2 = (short)CONSTANT - s1;
00033     printf("%d - %d = %d\n", CONSTANT, s1, *ps2);
00034
00035     s1++;
00036
00037     return;
00038 }
00039
00040 void Shutdown(void)
00041 {
00042     RPC_STATUS status;
00043
00044     printf("Calling RpcMgmtStopServerListening\n");
00045     status = RpcMgmtStopServerListening(NULL);
00046     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00047     if (status) {
00048         exit(status);
00049     }
00050
00051     printf("Calling RpcServerUnregisterIf\n");
00052     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00053     printf("RpcServerUnregisterIf returned 0x%x\n", status);
00054     if (status) {
00055         exit(status);
00056     }
00057 }
00058
00059 /* end file inoutp.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/capicom/cpp/isapiCertPolicy/Resource.h Source File

  • Security
  • capicom
  • cpp
  • isapiCertPolicy

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by isapiCertPolicy.rc
00004 //
00005
00006 #define IDS_FILTER        101
00007
00008 #define _APS_NEXT_RESOURCE_VALUE        103
00009 #define _APS_NEXT_CONTROL_VALUE         103
00010 #define _APS_NEXT_SYMED_VALUE           103
00011 #define _APS_NEXT_COMMAND_VALUE         32768
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cdialog.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cdialog.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CDIALOG.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////
00016 #include "Headers.h"
00017 #include "CMainWindow.h"
00018
00019
00020 /////////////////////////////////////////////////////////////////////
00021 // Defines
00022 //
00023 /////////////////////////////////////////////////////////////////////
00024 //PROPERTY
00025 enum PROP_COLUMNS
00026 {
00027   PROP_NAME,
00028   PROP_TYPE,
00029   PROP_VALUE,
00030   PROP_FLAGS,
00031   PROP_DESC,
00032   PROP_COLID
00033 };
00034
00035 #define NOTSET -2
00036
00037
00038
00039
00040 /////////////////////////////////////////////////////////////////////
00041 // Schema Constraint Mapping and Information
00042 //
00043 /////////////////////////////////////////////////////////////////////
00044 static const SCHEMAINFO g_rgSchemaInfo[] =
00045 {
00046   VALUE_PWCHAR(DBSCHEMA_ASSERTIONS),        3,
00047       {
00048         1,  L"CONSTRAINT_CATALOG",    DBTYPE_BSTR,
00049         2,  L"CONSTRAINT_SCHEMA",   DBTYPE_BSTR,
00050         3,  L"CONSTRAINT_NAME",     DBTYPE_BSTR,
00051       },
00052   VALUE_PWCHAR(DBSCHEMA_CATALOGS),        1,
00053       {
00054         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00055       },
00056   VALUE_PWCHAR(DBSCHEMA_CHARACTER_SETS),      3,
00057       {
00058         1,  L"CHARACTER_SET_CATALOG", DBTYPE_BSTR,
00059         2,  L"CHARACTER_SET_SCHEMA",  DBTYPE_BSTR,
00060         3,  L"CHARACTER_SET_NAME",    DBTYPE_BSTR,
00061       },
00062   VALUE_PWCHAR(DBSCHEMA_CHECK_CONSTRAINTS),   3,
00063       {
00064         1,  L"CONSTRAINT_CATALOG",    DBTYPE_BSTR,
00065         2,  L"CONSTRAINT_SCHEMA",   DBTYPE_BSTR,
00066         3,  L"CONSTRAINT_NAME",     DBTYPE_BSTR,
00067       },
00068   VALUE_PWCHAR(DBSCHEMA_COLLATIONS),        3,
00069       {
00070         1,  L"COLLATIONS_CATALOG",    DBTYPE_BSTR,
00071         2,  L"COLLATIONS_SCHEMA",   DBTYPE_BSTR,
00072         3,  L"COLLATIONS_NAME",     DBTYPE_BSTR,
00073       },
00074   VALUE_PWCHAR(DBSCHEMA_COLUMN_DOMAIN_USAGE),   4,
00075       {
00076         1,  L"DOMAIN_CATALOG",      DBTYPE_BSTR,
00077         2,  L"DOMAIN_SCHEMA",     DBTYPE_BSTR,
00078         3,  L"DOMAIN_NAME",       DBTYPE_BSTR,
00079         4,  L"COLUMN_NAME",       DBTYPE_BSTR,
00080       },
00081   VALUE_PWCHAR(DBSCHEMA_COLUMN_PRIVILEGES),   6,
00082       {
00083         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00084         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00085         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00086         4,  L"COLUMN_NAME",       DBTYPE_BSTR,
00087         5,  L"GRANTOR",         DBTYPE_BSTR,
00088         6,  L"GRANTEE",         DBTYPE_BSTR,
00089       },
00090   VALUE_PWCHAR(DBSCHEMA_COLUMNS),         4,
00091       {
00092         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00093         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00094         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00095         4,  L"COLUMN_NAME",       DBTYPE_BSTR,
00096       },
00097   VALUE_PWCHAR(DBSCHEMA_CONSTRAINT_COLUMN_USAGE), 4,
00098       {
00099         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00100         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00101         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00102         4,  L"COLUMN_NAME",       DBTYPE_BSTR,
00103       },
00104   VALUE_PWCHAR(DBSCHEMA_CONSTRAINT_TABLE_USAGE),  3,
00105       {
00106         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00107         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00108         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00109       },
00110   VALUE_PWCHAR(DBSCHEMA_FOREIGN_KEYS),      6,
00111       {
00112         1,  L"PK_TABLE_CATALOG",    DBTYPE_BSTR,
00113         2,  L"PK_TABLE_SCHEMA",     DBTYPE_BSTR,
00114         3,  L"PK_TABLE_NAME",     DBTYPE_BSTR,
00115         4,  L"FK_TABLE_CATALOG",    DBTYPE_BSTR,
00116         5,  L"FK_TABLE_SCHEMA",     DBTYPE_BSTR,
00117         6,  L"FK_TABLE_NAME",     DBTYPE_BSTR,
00118       },
00119   VALUE_PWCHAR(DBSCHEMA_INDEXES),         5,
00120       {
00121         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00122         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00123         3,  L"INDEX_NAME",        DBTYPE_BSTR,
00124         4,  L"TYPE",          DBTYPE_UI2,
00125         5,  L"TABLE_NAME",        DBTYPE_BSTR,
00126       },
00127   VALUE_PWCHAR(DBSCHEMA_KEY_COLUMN_USAGE),    7,
00128       {
00129         1,  L"CONSTRAINT_CATALOG",    DBTYPE_BSTR,
00130         2,  L"CONSTRAINT_SCHEMA",   DBTYPE_BSTR,
00131         3,  L"CONSTRAINT_NAME",     DBTYPE_BSTR,
00132         4,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00133         5,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00134         6,  L"TABLE_NAME",        DBTYPE_BSTR,
00135         7,  L"COLUMN_NAME",       DBTYPE_BSTR,
00136       },
00137   VALUE_PWCHAR(DBSCHEMA_PRIMARY_KEYS),      3,
00138       {
00139         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00140         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00141         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00142       },
00143   VALUE_PWCHAR(DBSCHEMA_PROCEDURE_COLUMNS),   4,
00144       {
00145         1,  L"PROCEDURE_CATALOG",   DBTYPE_BSTR,
00146         2,  L"PROCEDURE_SCHEMA",    DBTYPE_BSTR,
00147         3,  L"PROCEDURE_NAME",      DBTYPE_BSTR,
00148         4,  L"COLUMN_NAME",       DBTYPE_BSTR,
00149       },
00150   VALUE_PWCHAR(DBSCHEMA_PROCEDURE_PARAMETERS),  4,
00151       {
00152         1,  L"PROCEDURE_CATALOG",   DBTYPE_BSTR,
00153         2,  L"PROCEDURE_SCHEMA",    DBTYPE_BSTR,
00154         3,  L"PROCEDURE_NAME",      DBTYPE_BSTR,
00155         4,  L"PARAMETER_NAME",      DBTYPE_BSTR,
00156       },
00157   VALUE_PWCHAR(DBSCHEMA_PROCEDURES),        4,
00158       {
00159         1,  L"PROCEDURE_CATALOG",   DBTYPE_BSTR,
00160         2,  L"PROCEDURE_SCHEMA",    DBTYPE_BSTR,
00161         3,  L"PROCEDURE_NAME",      DBTYPE_BSTR,
00162         4,  L"PROCEDURE_TYPE",      DBTYPE_I2,
00163       },
00164   VALUE_PWCHAR(DBSCHEMA_PROVIDER_TYPES),      2,
00165       {
00166         1,  L"DATA_TYPE",       DBTYPE_UI2,
00167         2,  L"BEST_MATCH",        DBTYPE_BOOL,
00168       },
00169   VALUE_PWCHAR(DBSCHEMA_REFERENTIAL_CONSTRAINTS), 3,
00170       {
00171         1,  L"CONSTRAINT_CATALOG",    DBTYPE_BSTR,
00172         2,  L"CONSTRAINT_SCHEMA",   DBTYPE_BSTR,
00173         3,  L"CONSTRAINT_NAME",     DBTYPE_BSTR,
00174       },
00175   VALUE_PWCHAR(DBSCHEMA_SCHEMATA),        3,
00176       {
00177         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00178         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00179         3,  L"SCHEMA_OWNER",      DBTYPE_BSTR,
00180       },
00181   VALUE_PWCHAR(DBSCHEMA_SQL_LANGUAGES),     0,
00182       {
00183         1,  L"",            DBTYPE_BSTR,
00184       },
00185   VALUE_PWCHAR(DBSCHEMA_STATISTICS),        3,
00186       {
00187         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00188         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00189         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00190       },
00191   VALUE_PWCHAR(DBSCHEMA_TABLE_CONSTRAINTS),   7,
00192       {
00193         1,  L"CONSTRAINT_CATALOG",    DBTYPE_BSTR,
00194         2,  L"CONSTRAINT_SCHEMA",   DBTYPE_BSTR,
00195         3,  L"CONSTRAINT_NAME",     DBTYPE_BSTR,
00196         4,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00197         5,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00198         6,  L"TABLE_NAME",        DBTYPE_BSTR,
00199         7,  L"CONSTRAINT_TYPE",     DBTYPE_BSTR,
00200       },
00201   VALUE_PWCHAR(DBSCHEMA_TABLE_PRIVILEGES),    5,
00202       {
00203         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00204         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00205         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00206         4,  L"GRANTOR",         DBTYPE_BSTR,
00207         5,  L"GRANTEE",         DBTYPE_BSTR,
00208       },
00209   VALUE_PWCHAR(DBSCHEMA_TABLES),          4,
00210       {
00211         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00212         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00213         4,  L"TABLE_NAME",        DBTYPE_BSTR,
00214         3,  L"TABLE_TYPE",        DBTYPE_BSTR,
00215       },
00216   VALUE_PWCHAR(DBSCHEMA_TRANSLATIONS),      3,
00217       {
00218         1,  L"TRANSLATION_CATALOG",   DBTYPE_BSTR,
00219         2,  L"TRANSLATION_SCHEMA",    DBTYPE_BSTR,
00220         3,  L"TRANSLATION_NAME",    DBTYPE_BSTR,
00221       },
00222   VALUE_PWCHAR(DBSCHEMA_USAGE_PRIVILEGES),    6,
00223       {
00224         1,  L"OBJECT_CATALOG",      DBTYPE_BSTR,
00225         2,  L"OBJECT_SCHEMA",     DBTYPE_BSTR,
00226         3,  L"OBJECT_NAME",       DBTYPE_BSTR,
00227         4,  L"OBJECT_TYPE",       DBTYPE_BSTR,
00228         5,  L"GRANTOR",         DBTYPE_BSTR,
00229         6,  L"GRANTEE",         DBTYPE_BSTR,
00230       },
00231   VALUE_PWCHAR(DBSCHEMA_VIEW_COLUMN_USAGE),   3,
00232       {
00233         1,  L"VIEW_CATALOG",      DBTYPE_BSTR,
00234         2,  L"VIEW_SCHEMA",       DBTYPE_BSTR,
00235         3,  L"VIEW_NAME",       DBTYPE_BSTR,
00236       },
00237   VALUE_PWCHAR(DBSCHEMA_VIEW_TABLE_USAGE),    3,
00238       {
00239         1,  L"VIEW_CATALOG",      DBTYPE_BSTR,
00240         2,  L"VIEW_SCHEMA",       DBTYPE_BSTR,
00241         3,  L"VIEW_NAME",       DBTYPE_BSTR,
00242       },
00243   VALUE_PWCHAR(DBSCHEMA_VIEWS),         3,
00244       {
00245         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00246         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00247         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00248       },
00249
00250   //2.0
00251   VALUE_PWCHAR(DBSCHEMA_TABLES_INFO),       4,
00252       {
00253         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00254         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00255         4,  L"TABLE_NAME",        DBTYPE_BSTR,
00256         3,  L"TABLE_TYPE",        DBTYPE_BSTR,
00257       },
00258
00259
00260   //2.1
00261   VALUE_PWCHAR(DBSCHEMA_TRUSTEE),         4,
00262       {
00263         1,  L"TRUSTEE_NAME",      DBTYPE_BSTR,
00264         2,  L"TRUSTEE_GUID",      DBTYPE_BSTR,  //Variant doesn't support GUID?
00265         3,  L"TRUSTEE_PROPID",      DBTYPE_UI4,
00266         4,  L"TRUSTEE_TYPE",      DBTYPE_UI4,
00267       },
00268
00269   //2.6
00270   VALUE_PWCHAR(DBSCHEMA_TABLE_STATISTICS),    7,
00271       {
00272         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00273         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00274         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00275         4,  L"STATISTICS_CATALOG",    DBTYPE_BSTR,
00276         5,  L"STATISTICS_SCHEMA",   DBTYPE_BSTR,
00277         6,  L"STATISTICS_NAME",     DBTYPE_BSTR,
00278         7,  L"STATISTICS_TYPE",     DBTYPE_UI2,
00279       },
00280
00281   VALUE_PWCHAR(DBSCHEMA_CHECK_CONSTRAINTS_BY_TABLE),6,
00282       {
00283         1,  L"TABLE_CATALOG",     DBTYPE_BSTR,
00284         2,  L"TABLE_SCHEMA",      DBTYPE_BSTR,
00285         3,  L"TABLE_NAME",        DBTYPE_BSTR,
00286         4,  L"CONSTRAINT_CATALOG",    DBTYPE_BSTR,
00287         5,  L"CONSTRAINT_SCHEMA",   DBTYPE_BSTR,
00288         6,  L"CONSTRAINT_NAME",     DBTYPE_BSTR,
00289       },
00290
00291   //OLAP Extensions
00292   VALUE_PWCHAR(MDSCHEMA_CUBES),         3,
00293       {
00294         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00295         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00296         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00297       },
00298   VALUE_PWCHAR(MDSCHEMA_DIMENSIONS),        5,
00299       {
00300         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00301         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00302         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00303         4,  L"DIMENSION_NAME",      DBTYPE_BSTR,
00304         5,  L"DIMENSION_UNIQUE_NAME", DBTYPE_BSTR,
00305       },
00306   VALUE_PWCHAR(MDSCHEMA_HIERARCHIES),       6,
00307       {
00308         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00309         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00310         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00311         4,  L"DIMENSION_UNIQUE_NAME", DBTYPE_BSTR,
00312         5,  L"HIERARCHY_NAME",      DBTYPE_BSTR,
00313         6,  L"HIERARCHY_UNIQUE_NAME", DBTYPE_BSTR,
00314       },
00315     VALUE_PWCHAR(MDSCHEMA_LEVELS),          7,
00316       {
00317         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00318         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00319         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00320         4,  L"DIMENSION_UNIQUE_NAME", DBTYPE_BSTR,
00321         5,  L"HIERARCHY_UNIQUE_NAME", DBTYPE_BSTR,
00322         6,  L"LEVEL_NAME",        DBTYPE_BSTR,
00323         7,  L"LEVEL_UNIQUE_NAME",   DBTYPE_BSTR,
00324       },
00325   VALUE_PWCHAR(MDSCHEMA_MEASURES),        5,
00326       {
00327         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00328         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00329         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00330         4,  L"MEASURE_NAME",      DBTYPE_BSTR,
00331         5,  L"MEASURE_UNIQUE_NAME",   DBTYPE_BSTR,
00332       },
00333   VALUE_PWCHAR(MDSCHEMA_PROPERTIES),        9,
00334       {
00335         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00336         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00337         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00338         4,  L"DIMENSION_UNIQUE_NAME", DBTYPE_BSTR,
00339         5,  L"HIERARCHY_UNIQUE_NAME", DBTYPE_BSTR,
00340         6,  L"LEVEL_UNIQUE_NAME",   DBTYPE_BSTR,
00341         7,  L"MEMBER_UNIQUE_NAME",    DBTYPE_BSTR,
00342 //        8,  L"PROPERTY_NAME",     DBTYPE_BSTR,
00343 //        9,  L"PROPERTY_TYPE",     DBTYPE_BSTR,
00344       },
00345   VALUE_PWCHAR(MDSCHEMA_MEMBERS),         11,
00346       {
00347         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00348         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00349         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00350         4,  L"DIMENSION_UNIQUE_NAME", DBTYPE_BSTR,
00351         5,  L"HIERARCHY_UNIQUE_NAME", DBTYPE_BSTR,
00352         6,  L"LEVEL_UNIQUE_NAME",   DBTYPE_BSTR,
00353         7,  L"LEVEL_NUMBER",      DBTYPE_BSTR,
00354 //        8,  L"MEMBER_NAME",       DBTYPE_BSTR,
00355 //        9,  L"MEMBER_UNIQUE_NAME",    DBTYPE_BSTR,
00356 //        10, L"MEMBER_TYPE",       DBTYPE_BSTR,
00357 //        11, L"MDTREE_OPERATOR",     DBTYPE_BSTR,
00358       },
00359   VALUE_PWCHAR(MDSCHEMA_FUNCTIONS),        3,
00360       {
00361         1,  L"ORIGIN",          DBTYPE_I4,
00362         2,  L"INTERFACE_NAME",      DBTYPE_BSTR,
00363         3,  L"FUNCTION_NAME",     DBTYPE_BSTR,
00364       },
00365   VALUE_PWCHAR(MDSCHEMA_ACTIONS),          3,
00366       {
00367         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00368         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00369         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00370       },
00371   VALUE_PWCHAR(MDSCHEMA_COMMANDS),         3,
00372       {
00373         //TODO: MDSCHEMA_COMMANDS Restrictions need to be doc'd.
00374         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00375         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00376         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00377       },
00378   VALUE_PWCHAR(MDSCHEMA_SETS),           3,
00379       {
00380         1,  L"CATALOG_NAME",      DBTYPE_BSTR,
00381         2,  L"SCHEMA_NAME",       DBTYPE_BSTR,
00382         3,  L"CUBE_NAME",       DBTYPE_BSTR,
00383       },
00384
00385 };
00386
00387
00388 /////////////////////////////////////////////////////////////////////////////
00389 // CRowsetViewerDlg
00390 //
00391 /////////////////////////////////////////////////////////////////////////////
00392 CRowsetViewerDlg::CRowsetViewerDlg(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00393 {
00394   ASSERT(pCMainWindow || pCMDIChild);
00395   m_pCMDIChild  = pCMDIChild;
00396   m_pCMainWindow  = pCMDIChild ? pCMDIChild->m_pCMainWindow : pCMainWindow;
00397 }
00398
00399
00400 ////////////////////////////////////////////////////////////////
00401 // CRowsetViewerDlg::GetOptions
00402 //
00403 /////////////////////////////////////////////////////////////////
00404 COptionsSheet*  CRowsetViewerDlg::GetOptions()
00405 {
00406   return m_pCMainWindow->GetOptions();
00407 }
00408
00409
00410 /////////////////////////////////////////////////////////////////////////////
00411 // CFullConnectProvider
00412 //
00413 /////////////////////////////////////////////////////////////////////////////
00414 CFullConnectProvider::CFullConnectProvider()
00415   : CPropPageLite(IDD_FULLCONNECT_PROVIDER, "Provider")
00416 {
00417 }
00418
00419 /////////////////////////////////////////////////////////////////////////////
00420 // CFullConnectProvider::OnInitDialog
00421 //
00422 /////////////////////////////////////////////////////////////////////////////
00423 BOOL CFullConnectProvider::OnInitDialog()
00424 {
00425   CWaitCursor waitCursor;
00426
00427   //PropertySheet (BackPointer)
00428   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00429   CMainWindow* pCMainWindow = pCFullConnect->m_pCMainWindow;
00430
00431   //Controls...
00432   m_comboConfig.CreateIndirect(m_hWnd, IDC_CONFIG);
00433
00434   //CombBoxEx (allows images and indentation)
00435   m_comboProvider.CreateIndirect(m_hWnd, IDC_PROVIDER);
00436   SendMessage(m_comboProvider.m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR));
00437
00438   //Setup our "dynamic" window handle property...
00439   //NOTE: We have to do this here, since this needs to not only be a valid window handle,
00440   //must it also be the full connect dialog handle, so that if the provider displays a prompt
00441   //dialog its "modal" to this one and not the main window...
00442   m_hWndProp    = (HWND)NOTSET;
00443
00444   //Auto Save
00445   CheckDlgButton(IDB_AUTOSAVE,  BST2STATE(!(pCMainWindow->GetOptions()->m_dwCreateOpts & CREATE_NO_AUTOSAVE)));
00446
00447   //Fill in Enumerator list
00448   //NOTE: The Enumerator Combo drop down is deferred, since its quite expensive.
00449   //The drop down is populated once the drop down is selected.  Before population
00450   //it defaults to the users saved config provider, or MSDASQL if not saved...
00451
00452   //Obtain the property values for DBPROP_INIT_PROMPT
00453   ULONG cPropVals = 0;
00454   const WIDENAMEMAP* rgPropVals = NULL;
00455   if(SUCCEEDED(GetStaticPropValues(DBPROP_INIT_PROMPT, DBPROPSET_DBINIT, &cPropVals, &rgPropVals)))
00456   {
00457     //Fill in Prompt Combo
00458     pCFullConnect->InitPropCombo(GetDlgItem(IDC_PROMPT), cPropVals, rgPropVals, m_dwPromptProp == NOTSET ? 0 : m_dwPromptProp);
00459   }
00460
00461   //Load all items from the Registry
00462   //Limit it to the first 200 registry entries!
00463   //So we don't spend all day loading this combo box!
00464   WCHAR wszBuffer[MAX_NAME_LEN];
00465   for(ULONG i=0; i<200; i++)
00466   {
00467     if(S_OK != GetRegEnumKey(HKEY_ROWSETVIEWER, wszCONFIG_KEY, i, wszBuffer, MAX_NAME_LEN))
00468       break;
00469
00470     m_comboConfig.AddString(wszBuffer);
00471   }
00472
00473   //Delegate
00474   return CPropPageLite::OnInitDialog();
00475 }
00476
00477
00478 /////////////////////////////////////////////////////////////////////////////
00479 // CFullConnectProvider::OnApply
00480 //
00481 /////////////////////////////////////////////////////////////////////////////
00482 BOOL CFullConnectProvider::OnApply()
00483 {
00484   //PropertySheet (BackPointer)
00485   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00486   CMainWindow* pCMainWindow = pCFullConnect->m_pCMainWindow;
00487
00488   CWaitCursor waitCursor;
00489   GetProviderName();
00490
00491   // Make a connection using the supplied values
00492   if(FAILED(pCFullConnect->FullConnect()))
00493     return FALSE;
00494
00495   //Auto Save?
00496   BOOL bAutoSave = IsDlgButtonChecked(IDB_AUTOSAVE);
00497   if(bAutoSave)
00498     pCFullConnect->SaveDefaults();
00499
00500   //Update Options
00501   ENABLE_BIT(pCMainWindow->GetOptions()->m_dwCreateOpts, CREATE_NO_AUTOSAVE, !bAutoSave);
00502
00503   //delegate
00504   return CPropPageLite::OnApply();
00505 }
00506
00507 /////////////////////////////////////////////////////////////////////////////
00508 // CFullConnectProvider::OnSetActive
00509 //
00510 /////////////////////////////////////////////////////////////////////////////
00511 BOOL CFullConnectProvider::OnSetActive()
00512 {
00513   RefreshProvider();
00514   return TRUE;
00515 }
00516
00517 /////////////////////////////////////////////////////////////////////////////
00518 // CFullConnectProvider::OnKillActive
00519 //
00520 /////////////////////////////////////////////////////////////////////////////
00521 BOOL CFullConnectProvider::OnKillActive()
00522 {
00523   return UpdateProvider();
00524 }
00525
00526
00527 /////////////////////////////////////////////////////////////////////////////
00528 // CFullConnectProvider::OnCommand
00529 //
00530 /////////////////////////////////////////////////////////////////////////////
00531 BOOL CFullConnectProvider::OnCommand(UINT iID, HWND hWndCtrl)
00532 {
00533   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00534
00535   switch(iID)
00536   {
00537     case IDB_DEFAULTS:
00538     {
00539       pCFullConnect->ResetDefaults();
00540       return TRUE;
00541     }
00542
00543     case IDB_CONFIG_SAVE:
00544     {
00545       //Now update registry
00546       UpdateProvider();
00547       pCFullConnect->SaveDefaults();
00548       return TRUE;
00549     }
00550
00551     case IDB_CONFIG_REMOVE:
00552     {
00553       //Obtain the Selected Combo Text
00554       INDEX iSel = m_comboConfig.GetSelText(pCFullConnect->m_wszConfigName, MAX_NAME_LEN);
00555
00556       //Remove this item from the ComboBox
00557       m_comboConfig.DeleteString(iSel);
00558
00559       //Formulate the key
00560       WCHAR wszKeyName[MAX_NAME_LEN];
00561       StringFormat(wszKeyName, NUMELE(wszKeyName), L"%s\\%s", wszCONFIG_KEY, pCFullConnect->m_wszConfigName);
00562
00563       //Now Remove this Item from the registry
00564       DelRegEntry(HKEY_ROWSETVIEWER, wszKeyName, TRUE/*fSubKeys*/);
00565
00566       //We need to make sure this is not the default Config
00567       wszKeyName[0] = EOL;
00568       GetRegEntry(HKEY_ROWSETVIEWER, wszCONFIG_KEY, L"DefaultConfig", wszKeyName, MAX_NAME_LEN);
00569       if(StringCompare(wszKeyName, pCFullConnect->m_wszConfigName))
00570         SetRegEntry(HKEY_ROWSETVIEWER, wszCONFIG_KEY, L"DefaultConfig", L"(Default)");
00571
00572       //And Remove it from our Recent Config List
00573       pCFullConnect->RemoveRecentConfig(pCFullConnect->m_wszConfigName);
00574       pCFullConnect->m_wszConfigName[0] = EOL;
00575       return TRUE;
00576     }
00577
00578     case IDB_BROWSE_LOCATION:
00579     {
00580       pCFullConnect->m_idSource = IDE_LOCATION;
00581
00582       POINTS pts;
00583       GetWindowPos(GetDlgItem(IDB_BROWSE_LOCATION), &pts);
00584
00585       //Display the Context Menu
00586       DisplayContextMenu(
00587             m_hWnd,
00588             IDM_BROWSE_OPTION,
00589             pts,
00590             m_hWnd
00591             );
00592       return TRUE;
00593     }
00594
00595     case IDB_BROWSE_DATASOURCE:
00596     {
00597       pCFullConnect->m_idSource = IDE_DATASOURCE;
00598
00599       POINTS pts;
00600       GetWindowPos(GetDlgItem(IDB_BROWSE_DATASOURCE), &pts);
00601
00602       //Display the Context Menu
00603       DisplayContextMenu(
00604             m_hWnd,
00605             IDM_BROWSE_OPTION,
00606             pts,
00607             m_hWnd
00608             );
00609       return TRUE;
00610     }
00611
00612     case IDM_BROWSE_FILE:
00613     {
00614       WCHAR* pwszTitle = NULL;
00615       WCHAR* pwszBuffer = NULL;
00616
00617       switch(pCFullConnect->m_idSource)
00618       {
00619         case IDE_DATASOURCE:
00620         {
00621           pwszTitle = L"DBPROP_INIT_DATASOURCE";
00622           pwszBuffer = m_wszDataSource;
00623           break;
00624         }
00625
00626         case IDE_LOCATION:
00627         {
00628           pwszTitle = L"DBPROP_INIT_LOCATION";
00629           pwszBuffer = m_wszLocation;
00630           break;
00631         }
00632
00633         default:
00634           ASSERT(!"Unhandled Source!");
00635           break;
00636       }
00637
00638       //Display Common Dialog to obtain DataSource...
00639       //This is for providers that take a filename/path for this property
00640       if(SUCCEEDED(BrowseOpenFileName(GetAppLite()->m_hInstance, m_hWnd, pwszTitle, pwszBuffer, MAX_NAME_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0")))
00641       {
00642         CEditBoxLite editSource;
00643         editSource.CreateIndirect(m_hWnd, pCFullConnect->m_idSource);
00644
00645         //Just update value
00646         editSource.ReplaceAll(pwszBuffer);
00647       }
00648       return TRUE;
00649     }
00650
00651     case IDM_BROWSE_ENUM:
00652     {
00653       DisplayDialog(IDD_BROWSE_ENUM, m_hWnd, CFullConnect::BrowseEnumeratorProc, (LPARAM)pCFullConnect);
00654       return TRUE;
00655     }
00656   };
00657
00658   return FALSE;
00659 }
00660
00661 /////////////////////////////////////////////////////////////////////
00662 // CFullConnectProvider::OnCommandNotify
00663 //
00664 /////////////////////////////////////////////////////////////////////
00665 BOOL CFullConnectProvider::OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl)
00666 {
00667   switch(wNotifyCode)
00668   {
00669     case CBN_SELCHANGE:
00670     {
00671       if(OnSelChange(iID, hWndCtrl))
00672         return TRUE;
00673       break;
00674     }
00675
00676     case CBN_DROPDOWN:
00677     {
00678       if(OnDropDown(iID, hWndCtrl))
00679         return TRUE;
00680       break;
00681     }
00682   };
00683
00684   //Otherwise Delegate
00685   return CWndLite::OnCommandNotify(wNotifyCode, iID, hWndCtrl);
00686 }
00687
00688
00689 /////////////////////////////////////////////////////////////////////////////
00690 // CFullConnectProvider::OnDropDown
00691 //
00692 /////////////////////////////////////////////////////////////////////////////
00693 BOOL CFullConnectProvider::OnDropDown(INT iID, HWND hWndCtrl)
00694 {
00695   switch(iID)
00696   {
00697     case IDC_PROVIDER:
00698     {
00699       CWaitCursor waitCursor;
00700
00701       //NOTE: The Provider Combo box is deferred
00702       //since it requires the Root Enumerator which is quite
00703       //expensive, so only populate the provider combo
00704       //when user presses the drop down, otherwise it defaults
00705       //to their saved provider or MSDASQL...
00706       RefreshEnum();
00707       return TRUE;
00708     }
00709   };
00710
00711   return FALSE;
00712 }
00713
00714 /////////////////////////////////////////////////////////////////////////////
00715 // CFullConnectProvider::OnSelChange
00716 //
00717 /////////////////////////////////////////////////////////////////////////////
00718 BOOL CFullConnectProvider::OnSelChange(INT iID, HWND hWndCtrl)
00719 {
00720   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00721
00722   switch(iID)
00723   {
00724     case IDC_CONFIG:
00725     {
00726       //Obtain the Selected Combo Text
00727       m_comboConfig.GetSelText(pCFullConnect->m_wszConfigName, MAX_NAME_LEN);
00728
00729       //Now we need to update the FullConnect for this Config
00730       pCFullConnect->LoadDefaults();
00731       RefreshProvider();
00732       return TRUE;
00733     }
00734
00735     case IDC_PROVIDER:
00736     {
00737       //Need to remove any previously set properties.
00738       //Specifically any Advanced properties, since this is a new configuration
00739       pCFullConnect->m_CPropSets.RemoveAll();
00740
00741       //Save the newly selected provider
00742       GetProviderName();
00743       return TRUE;
00744     }
00745   };
00746
00747   return FALSE;
00748 }
00749
00750
00751 ////////////////////////////////////////////////////////////////
00752 // CFullConnectProvider::GetProviderName
00753 //
00754 /////////////////////////////////////////////////////////////////
00755 HRESULT CFullConnectProvider::GetProviderName()
00756 {
00757   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00758   ENUMINFO* pEnumInfo = &pCFullConnect->m_EnumInfo;
00759
00760   //Obtain Provider from DropDown
00761   INDEX iIndex = m_comboProvider.GetCurSel();
00762   if(iIndex != CB_ERR)
00763   {
00764     //Since we have the CBS_SORT turned on.
00765     //we store the pointer ENUMINFO object in the item data
00766     ENUMINFO* pEnumInfoData = (ENUMINFO*)m_comboProvider.GetItemParam(iIndex);
00767     if(pEnumInfoData && (LPARAM)pEnumInfoData!=CB_ERR)
00768       memcpy(pEnumInfo, pEnumInfoData, sizeof(ENUMINFO));
00769   }
00770   else
00771   {
00772     //The user must have typed in a Provider Name directly
00773     //This may not map to a provider in the list, so assume the name is a ProgID/CLSID
00774     memset(pEnumInfo, 0, sizeof(ENUMINFO));
00775     m_comboProvider.GetWindowText(pEnumInfo->wszName, MAX_NAME_LEN);
00776     m_comboProvider.GetWindowText(pEnumInfo->wszParseName, MAX_NAME_LEN);
00777   }
00778
00779   //Display Provider Info (Title of Window)
00780   wSendMessageFmt(::GetParent(m_hWnd), WM_SETTEXT, 0, L"Full Connect - %s", pEnumInfo->wszDescription[0] ? pEnumInfo->wszDescription : L"No Descripition Available");
00781   return S_OK;
00782 }
00783
00784
00785 ////////////////////////////////////////////////////////////////
00786 // CFullConnectProvider::RefreshEnum
00787 //
00788 /////////////////////////////////////////////////////////////////
00789 BOOL CFullConnectProvider::RefreshEnum(BOOL fReconnect)
00790 {
00791   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00792   CMainWindow* pCMainWindow = pCFullConnect->m_pCMainWindow;
00793   ENUMINFO* pEnumInfo = &pCFullConnect->m_EnumInfo;
00794
00795   //Remove all previous entries
00796   m_comboProvider.ResetContent();
00797
00798   //Initialize the Enumerator to establish a list of
00799   //Providers and Enumerators, if we don'thave them already
00800   if(pCFullConnect->m_pCEnumerator == NULL)
00801   {
00802     CEnumerator* pCRootEnum = pCMainWindow->m_pCRootEnumerator;
00803
00804     //No need to check the HRESULT since CEnumerator is capable of instantiating
00805     //objects, even without the RootEnum...
00806     pCRootEnum->CreateEnumInfo(CLSID_OLEDB_ENUMERATOR, fReconnect);
00807
00808     //Fill out the provider name combo box.
00809     for(ULONG i=0; i<pCRootEnum->m_cEnumInfo; i++)
00810     {
00811       ENUMINFO* pEnumInfo = &pCRootEnum->m_rgEnumInfo[i];
00812
00813       //Determine the Image to use
00814       UINT iImage = IMAGE_QUESTION;
00815       if(pEnumInfo->eType == DBSOURCETYPE_DATASOURCE)
00816         iImage = IMAGE_NORMAL;
00817       else if(pEnumInfo->eType == DBSOURCETYPE_ENUMERATOR)
00818         iImage = IMAGE_OBJECTS;
00819       else if(pEnumInfo->eType == DBSOURCETYPE_BINDER)
00820         iImage = IMAGE_CHAPTER;
00821       else if(pEnumInfo->eType == DBSOURCETYPE_DATASOURCE_MDP)
00822         iImage = IMAGE_CUBE;
00823
00824       //Add the name to the list
00825       //Since we have the CBS_SORT turned on.
00826       //we store the pointer ENUMINFO object in the item data
00827       m_comboProvider.InsertItem(-1/*iItem*/, pEnumInfo->wszName, (LPARAM)pEnumInfo, PARAM_NONE/*iIndent*/, iImage, iImage);
00828     }
00829   }
00830
00831   //Try to find Previous Selection by default
00832   m_comboProvider.SetSelText(pEnumInfo->wszName, TRUE/*fAddItem*/);
00833
00834   //Obtain Provider
00835   GetProviderName();
00836   return TRUE;
00837 }
00838
00839
00840
00841 ////////////////////////////////////////////////////////////////
00842 // CFullConnectProvider::RefreshProvider
00843 //
00844 /////////////////////////////////////////////////////////////////
00845 BOOL CFullConnectProvider::RefreshProvider()
00846 {
00847   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00848
00849   //Try to find our Saved Provider
00850   m_comboProvider.SetSelText(pCFullConnect->m_EnumInfo.wszName, TRUE/*fAddItem*/);
00851
00852   //Obtain Provider from DropDown
00853   GetProviderName();
00854
00855   //Restore Saved Values - Properties
00856   wSendMessage(GetDlgItem(IDE_LOCATION),    WM_SETTEXT, 0, m_wszLocation);
00857   wSendMessage(GetDlgItem(IDE_DATASOURCE),  WM_SETTEXT, 0, m_wszDataSource);
00858   wSendMessage(GetDlgItem(IDE_USERID),    WM_SETTEXT, 0, m_wszUserID);
00859   wSendMessage(GetDlgItem(IDE_PASSWORD),    WM_SETTEXT, 0, m_wszPassword);
00860
00861   //Set Prompt Combo
00862   CComboBoxLite comboPrompt(m_hWnd, IDC_PROMPT);
00863   comboPrompt.SetSelValue(m_dwPromptProp);
00864
00865   //Try to find our Defaut Configuration
00866   m_comboConfig.SetSelText(pCFullConnect->m_wszConfigName, TRUE/*fAddItem*/);
00867   return TRUE;
00868 }
00869
00870
00871 ////////////////////////////////////////////////////////////////
00872 // CFullConnectProvider::UpdateProvider
00873 //
00874 /////////////////////////////////////////////////////////////////
00875 BOOL CFullConnectProvider::UpdateProvider()
00876 {
00877   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00878
00879   //Obtain Provider Selection
00880   GetProviderName();
00881
00882   //Obtain Property Values
00883   wSendMessage(GetDlgItem(IDE_LOCATION),    WM_GETTEXT, MAX_NAME_LEN, m_wszLocation);
00884   wSendMessage(GetDlgItem(IDE_DATASOURCE),  WM_GETTEXT, MAX_NAME_LEN, m_wszDataSource);
00885   wSendMessage(GetDlgItem(IDE_USERID),    WM_GETTEXT, MAX_NAME_LEN, m_wszUserID);
00886   wSendMessage(GetDlgItem(IDE_PASSWORD),    WM_GETTEXT, MAX_NAME_LEN, m_wszPassword);
00887
00888   //Obtain Prompt Value
00889   INDEX iSel = (INDEX)SendMessage(GetDlgItem(IDC_PROMPT), CB_GETCURSEL, 0, 0);
00890   m_dwPromptProp = (DWORD)SendMessage(GetDlgItem(IDC_PROMPT), CB_GETITEMDATA, iSel, 0);
00891
00892   //Obtain Configuration Name
00893   m_comboConfig.GetSelText(pCFullConnect->m_wszConfigName, MAX_NAME_LEN);
00894   return TRUE;
00895 }
00896
00897
00898
00899
00900 /////////////////////////////////////////////////////////////////////////////
00901 // CFullConnectProperties
00902 //
00903 /////////////////////////////////////////////////////////////////////////////
00904 CFullConnectProperties::CFullConnectProperties()
00905   : CPropPageLite(IDD_FULLCONNECT_PROPERTIES, "Properties")
00906 {
00907 }
00908
00909 /////////////////////////////////////////////////////////////////////////////
00910 // CFullConnectProperties::OnInitDialog
00911 //
00912 /////////////////////////////////////////////////////////////////////////////
00913 BOOL CFullConnectProperties::OnInitDialog()
00914 {
00915   //PropertySheet (BackPointer)
00916   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
00917   CWaitCursor waitCursor;
00918
00919   HWND hWndAsynch   = GetDlgItem(IDC_ASYNCH);
00920   HWND hWndLocale   = GetDlgItem(IDC_LOCALE);
00921   HWND hWndMode   = GetDlgItem(IDL_MODE);
00922
00923   //DBPROP_INIT_ASYNCH
00924   const static WIDENAMEMAP rgAsynch[] =
00925   {
00926     VALUE_WCHAR(DBPROPVAL_ASYNCH_INITIALIZE),
00927   };
00928
00929   //Fill in AsynchCombo
00930   pCFullConnect->InitPropCombo(hWndAsynch, NUMELE(rgAsynch), rgAsynch, m_dwAsynchProp);
00931
00932   //Fill in LocaleCombo
00933   pCFullConnect->InitPropCombo(hWndLocale, g_cLCID, g_rgLCID, m_dwlcidProp);
00934
00935   //DBPROP_INIT_MODE
00936   const static WIDENAMEMAP rgMode[] =
00937   {
00938     VALUE_WCHAR(DB_MODE_READ),
00939     VALUE_WCHAR(DB_MODE_WRITE),
00940     VALUE_WCHAR(DB_MODE_READWRITE),
00941     VALUE_WCHAR(DB_MODE_SHARE_DENY_READ),
00942     VALUE_WCHAR(DB_MODE_SHARE_DENY_WRITE),
00943     VALUE_WCHAR(DB_MODE_SHARE_EXCLUSIVE),
00944     VALUE_WCHAR(DB_MODE_SHARE_DENY_NONE),
00945   };
00946
00947   //Fill in Mode ListBox
00948   SendMessage(hWndMode, LB_RESETCONTENT, 0, 0);
00949   for(ULONG i=0; i<NUMELE(rgMode); i++)
00950   {
00951     INDEX iSel = (INDEX)wSendMessage(hWndMode, LB_ADDSTRING, 0, rgMode[i].pwszName);
00952     SendMessage(hWndMode, LB_SETITEMDATA, iSel, (LPARAM)rgMode[i].lItem);
00953   }
00954
00955   //Restore Saved Values
00956   RefreshProperties();
00957
00958   //Delegate
00959   return CPropPageLite::OnInitDialog();
00960 }
00961
00962
00963 /////////////////////////////////////////////////////////////////////////////
00964 // CFullConnectProperties::OnSetActive
00965 //
00966 /////////////////////////////////////////////////////////////////////////////
00967 BOOL CFullConnectProperties::OnSetActive()
00968 {
00969   RefreshProperties();
00970   return TRUE;
00971 }
00972
00973
00974 /////////////////////////////////////////////////////////////////////////////
00975 // CFullConnectProperties::OnKillActive
00976 //
00977 /////////////////////////////////////////////////////////////////////////////
00978 BOOL CFullConnectProperties::OnKillActive()
00979 {
00980   return UpdateProperties();
00981 }
00982
00983
00984 ////////////////////////////////////////////////////////////////
00985 // CFullConnectProperties::RefreshProperties
00986 //
00987 /////////////////////////////////////////////////////////////////
00988 BOOL CFullConnectProperties::RefreshProperties()
00989 {
00990   HWND hWndMode   = GetDlgItem(IDL_MODE);
00991   CComboBoxLite   comboAsynch(m_hWnd, IDC_ASYNCH);
00992   CComboBoxLite   comboLocale(m_hWnd, IDC_LOCALE);
00993
00994   //Restore Saved Values - Properties
00995   wSendMessage(GetDlgItem(IDE_PROVSTRING),  WM_SETTEXT, 0, m_wszProvString);
00996   wSendMessage(GetDlgItem(IDC_CATALOG),   WM_SETTEXT, 0, m_wszCatalog);
00997
00998   //Timeout
00999   if(m_dwTimeoutProp != NOTSET)
01000     wSendMessageFmt(GetDlgItem(IDE_TIMEOUT),  WM_SETTEXT, 0, L"%d", m_dwTimeoutProp);
01001
01002   //Fill in AsynchCombo
01003   comboAsynch.SetSelValue(m_dwAsynchProp);
01004
01005   //Fill in LocaleCombo
01006   comboLocale.SetSelValue(m_dwlcidProp);
01007
01008   //Fill in Mode ListBox
01009   INDEX iCount = (INDEX)SendMessage(hWndMode, LB_GETCOUNT, 0, 0);
01010   for(LONG i=0; i<iCount; i++)
01011   {
01012     //Reselect Mode Options (turn it on or off...)
01013     LPARAM lParam = SendMessage(hWndMode, LB_GETITEMDATA, i, 0);
01014
01015     if(m_dwModeProp == NOTSET)
01016        SendMessage(hWndMode, LB_SETSEL, 0, i); //Turn off
01017     else
01018        SendMessage(hWndMode, LB_SETSEL, (lParam & m_dwModeProp) == lParam, i);
01019   }
01020
01021   return TRUE;
01022 }
01023
01024
01025 ////////////////////////////////////////////////////////////////
01026 // CFullConnectProperties::UpdateProperties
01027 //
01028 /////////////////////////////////////////////////////////////////
01029 BOOL CFullConnectProperties::UpdateProperties()
01030 {
01031   //Retrieve Values from Properties Sheet
01032   HWND hWndAsynch = GetDlgItem(IDC_ASYNCH);
01033   HWND hWndLocale = GetDlgItem(IDC_LOCALE);
01034   HWND hWndMode = GetDlgItem(IDL_MODE);
01035
01036   wSendMessage(GetDlgItem(IDE_PROVSTRING),  WM_GETTEXT, MAX_NAME_LEN, m_wszProvString);
01037   wSendMessage(GetDlgItem(IDC_CATALOG),   WM_GETTEXT, MAX_NAME_LEN, m_wszCatalog);
01038
01039   //Obtain Asynch Value
01040   INDEX iSel = (INDEX)SendMessage(hWndAsynch, CB_GETCURSEL, 0, 0);
01041   m_dwAsynchProp = (DWORD)SendMessage(hWndAsynch, CB_GETITEMDATA, iSel, 0);
01042
01043   //Obtain Locale Value
01044   iSel = (INDEX)SendMessage(hWndLocale, CB_GETCURSEL, 0, 0);
01045   m_dwlcidProp = (DWORD)SendMessage(hWndLocale, CB_GETITEMDATA, iSel, 0);
01046
01047   //Timeout
01048   m_dwTimeoutProp = NOTSET;
01049   if(!GetEditBoxValue(GetDlgItem(IDE_TIMEOUT), &m_dwTimeoutProp, 0/*Min*/, LONG_MAX/*Max*/, TRUE))
01050   {
01051     m_dwTimeoutProp = NOTSET;
01052     return FALSE;
01053   }
01054
01055   //Obtain all Mode Selected Items...
01056   INDEX iSelCount = (INDEX)SendMessage(hWndMode, LB_GETSELCOUNT, 0, 0);
01057   ASSERT(iSelCount < 20);
01058   LONG rgSelItems[20];
01059   SendMessage(hWndMode, LB_GETSELITEMS, (WPARAM)20, (LPARAM)rgSelItems);
01060
01061   m_dwModeProp = iSelCount ? 0 : NOTSET;
01062   for(LONG i=0; i<iSelCount; i++)
01063   {
01064     m_dwModeProp |= SendMessage(hWndMode, LB_GETITEMDATA, rgSelItems[i], 0);
01065   }
01066
01067   return TRUE;
01068 }
01069
01070
01071 /////////////////////////////////////////////////////////////////////////////
01072 // CFullConnectProperties::OnCommand
01073 //
01074 /////////////////////////////////////////////////////////////////////////////
01075 BOOL CFullConnectProperties::OnCommand(UINT iID, HWND hWndCtrl)
01076 {
01077   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
01078
01079   switch(iID)
01080   {
01081     case IDB_MOREPROPERTIES:
01082     {
01083       pCFullConnect->GetAdvProperties();
01084       RefreshProperties();
01085       return TRUE;
01086     }
01087
01088     case IDB_BROWSE_PROVSTRING:
01089     {
01090       pCFullConnect->m_idSource = IDE_PROVSTRING;
01091
01092       POINTS pts;
01093       GetWindowPos(GetDlgItem(IDB_BROWSE_PROVSTRING), &pts);
01094
01095       //Display the Context Menu
01096       DisplayContextMenu(
01097             m_hWnd,
01098             IDM_BROWSE_OPTION,
01099             pts,
01100             m_hWnd
01101             );
01102       return TRUE;
01103     }
01104
01105     case IDM_BROWSE_FILE:
01106     {
01107       WCHAR* pwszTitle = NULL;
01108       WCHAR* pwszBuffer = NULL;
01109
01110       switch(pCFullConnect->m_idSource)
01111       {
01112         case IDE_PROVSTRING:
01113         {
01114           pwszTitle = L"DBPROP_INIT_PROVIDERSTRING";
01115           pwszBuffer = m_wszProvString;
01116           break;
01117         }
01118
01119         default:
01120           ASSERT(!"Unhandled Source!");
01121           break;
01122       }
01123
01124       //Display Common Dialog to obtain DataSource...
01125       //This is for providers that take a filename/path for this property
01126       if(SUCCEEDED(BrowseOpenFileName(GetAppLite()->m_hInstance, m_hWnd, pwszTitle, pwszBuffer, MAX_NAME_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0")))
01127       {
01128         CEditBoxLite editSource;
01129         editSource.CreateIndirect(m_hWnd, pCFullConnect->m_idSource);
01130
01131         //Just update value
01132         editSource.ReplaceAll(pwszBuffer);
01133       }
01134       return TRUE;
01135     }
01136
01137     case IDM_BROWSE_ENUM:
01138     {
01139       DisplayDialog(IDD_BROWSE_ENUM, m_hWnd, CFullConnect::BrowseEnumeratorProc, (LPARAM)pCFullConnect);
01140       return TRUE;
01141     }
01142   };
01143
01144   return FALSE;
01145 }
01146
01147
01148
01149 /////////////////////////////////////////////////////////////////////////////
01150 // CFullConnectSecurity
01151 //
01152 /////////////////////////////////////////////////////////////////////////////
01153 CFullConnectSecurity::CFullConnectSecurity()
01154   : CPropPageLite(IDD_FULLCONNECT_SECURITY, "Security")
01155 {
01156 }
01157
01158 /////////////////////////////////////////////////////////////////////////////
01159 // CFullConnectSecurity::OnInitDialog
01160 //
01161 /////////////////////////////////////////////////////////////////////////////
01162 BOOL CFullConnectSecurity::OnInitDialog()
01163 {
01164   CWaitCursor waitCursor;
01165
01166   //PropertySheet (BackPointer)
01167   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
01168
01169   HWND hWndProtection = GetDlgItem(IDC_PROTECTION);
01170   HWND hWndImpersonation = GetDlgItem(IDC_IMPERSONATE);
01171
01172   //DBPROP_INIT_PROTECTION_LEVEL
01173   const static WIDENAMEMAP rgProtection[] =
01174   {
01175     VALUE_WCHAR(DB_PROT_LEVEL_NONE),
01176     VALUE_WCHAR(DB_PROT_LEVEL_CONNECT),
01177     VALUE_WCHAR(DB_PROT_LEVEL_CALL),
01178     VALUE_WCHAR(DB_PROT_LEVEL_PKT),
01179     VALUE_WCHAR(DB_PROT_LEVEL_PKT_INTEGRITY),
01180     VALUE_WCHAR(DB_PROT_LEVEL_PKT_PRIVACY),
01181   };
01182
01183   //Fill in ProtectionCombo
01184   pCFullConnect->InitPropCombo(hWndProtection, NUMELE(rgProtection), rgProtection, m_dwProtectionProp);
01185
01186   //DBPROP_INIT_IMPERSONATION_LEVEL
01187   const static WIDENAMEMAP rgImpersonation[] =
01188   {
01189     VALUE_WCHAR(DB_IMP_LEVEL_ANONYMOUS),
01190     VALUE_WCHAR(DB_IMP_LEVEL_IDENTIFY),
01191     VALUE_WCHAR(DB_IMP_LEVEL_IMPERSONATE),
01192     VALUE_WCHAR(DB_IMP_LEVEL_DELEGATE),
01193   };
01194
01195   //Fill in ImpersonationCombo
01196   pCFullConnect->InitPropCombo(hWndImpersonation, NUMELE(rgImpersonation), rgImpersonation, m_dwImpersonateProp);
01197
01198   //Restore Saved Values
01199   RefreshSecurity();
01200
01201   //Delegate
01202   return CPropPageLite::OnInitDialog();
01203 }
01204
01205
01206 /////////////////////////////////////////////////////////////////////////////
01207 // CFullConnectSecurity::OnSetActive
01208 //
01209 /////////////////////////////////////////////////////////////////////////////
01210 BOOL CFullConnectSecurity::OnSetActive()
01211 {
01212   RefreshSecurity();
01213   return TRUE;
01214 }
01215
01216
01217 /////////////////////////////////////////////////////////////////////////////
01218 // CFullConnectSecurity::OnKillActive
01219 //
01220 /////////////////////////////////////////////////////////////////////////////
01221 BOOL CFullConnectSecurity::OnKillActive()
01222 {
01223   return UpdateSecurity();
01224 }
01225
01226
01227 /////////////////////////////////////////////////////////////////////////////
01228 // CFullConnectSecurity::OnCommand
01229 //
01230 /////////////////////////////////////////////////////////////////////////////
01231 BOOL CFullConnectSecurity::OnCommand(UINT iID, HWND hWndCtrl)
01232 {
01233   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
01234
01235   switch(iID)
01236   {
01237     case IDB_BROWSE_INTEGRATED:
01238     {
01239       pCFullConnect->m_idSource = IDE_INTEGRATED;
01240
01241       POINTS pts;
01242       GetWindowPos(GetDlgItem(IDB_BROWSE_INTEGRATED), &pts);
01243
01244       //Display the Context Menu
01245       DisplayContextMenu(
01246             m_hWnd,
01247             IDM_BROWSE_OPTION,
01248             pts,
01249             m_hWnd
01250             );
01251       return TRUE;
01252     }
01253
01254     case IDM_BROWSE_FILE:
01255     {
01256       WCHAR* pwszTitle = NULL;
01257       WCHAR* pwszBuffer = NULL;
01258
01259       switch(pCFullConnect->m_idSource)
01260       {
01261         case IDE_INTEGRATED:
01262         {
01263           pwszTitle = L"DBPROP_AUTH_INTEGRATED";
01264           pwszBuffer = m_wszIntegrated;
01265           break;
01266         }
01267
01268         default:
01269           ASSERT(!"Unhandled Source!");
01270           break;
01271       }
01272
01273       //Display Common Dialog to obtain DataSource...
01274       //This is for providers that take a filename/path for this property
01275       if(SUCCEEDED(BrowseOpenFileName(GetAppLite()->m_hInstance, m_hWnd, pwszTitle, pwszBuffer, MAX_NAME_LEN, NULL, L"DataSource Files (.dsn;.kag;.sav)\0*.dsn;*.kag;*.sav;\0DataBase Files (.mdb;.db;.dbf)\0*.mdb;*.db;*.dbf;\0Program Files (.xls;.clb)\0*.xls;*.clb;\0Text Files (.txt;.csv)\0*.txt;*.csv\0All Files (*.*)\0*.*\0\0")))
01276       {
01277         CEditBoxLite editSource;
01278         editSource.CreateIndirect(m_hWnd, pCFullConnect->m_idSource);
01279
01280         //Just update value
01281         editSource.ReplaceAll(pwszBuffer);
01282       }
01283       return TRUE;
01284     }
01285
01286     case IDM_BROWSE_ENUM:
01287     {
01288       DisplayDialog(IDD_BROWSE_ENUM, m_hWnd, CFullConnect::BrowseEnumeratorProc, (LPARAM)pCFullConnect);
01289       return TRUE;
01290     }
01291   };
01292
01293   return FALSE;
01294 }
01295
01296
01297 ////////////////////////////////////////////////////////////////
01298 // CFullConnectSecurity::RefreshSecurity
01299 //
01300 /////////////////////////////////////////////////////////////////
01301 BOOL CFullConnectSecurity::RefreshSecurity()
01302 {
01303   CComboBoxLite     comboProtection(m_hWnd, IDC_PROTECTION);
01304   CComboBoxLite     comboImpersonation(m_hWnd, IDC_IMPERSONATE);
01305
01306   //Fill in ProtectionCombo
01307   comboProtection.SetSelValue(m_dwProtectionProp);
01308
01309   //Fill in ImpersonationCombo
01310   comboImpersonation.SetSelValue(m_dwImpersonateProp);
01311
01312   //Restore Saved Values
01313   CheckDlgButton(IDB_MASKPASSWORD,    m_dwMaskPasswordProp == VARIANT_TRUE ? BST_CHECKED : m_dwMaskPasswordProp == VARIANT_FALSE ? BST_INDETERMINATE : BST_UNCHECKED);
01314   CheckDlgButton(IDB_ENCRYPTPASSWORD,   m_dwEncryptPasswordProp == VARIANT_TRUE ? BST_CHECKED : m_dwEncryptPasswordProp == VARIANT_FALSE ? BST_INDETERMINATE : BST_UNCHECKED);
01315   CheckDlgButton(IDB_CACHEINFO,     m_dwCacheProp == VARIANT_TRUE ? BST_CHECKED : m_dwCacheProp == VARIANT_FALSE ? BST_INDETERMINATE : BST_UNCHECKED);
01316   CheckDlgButton(IDB_PERSISTINFO,     m_dwPersistProp == VARIANT_TRUE ? BST_CHECKED : m_dwPersistProp == VARIANT_FALSE ? BST_INDETERMINATE : BST_UNCHECKED);
01317   CheckDlgButton(IDB_ENCRYPTINFO,     m_dwPersistEncryptProp == VARIANT_TRUE ? BST_CHECKED : m_dwPersistEncryptProp == VARIANT_FALSE ? BST_INDETERMINATE : BST_UNCHECKED);
01318
01319   //Restore Save Values - Integrated
01320   wSendMessage(GetDlgItem(IDE_INTEGRATED),  WM_SETTEXT, 0, m_wszIntegrated);
01321   return TRUE;
01322 }
01323
01324
01325 ////////////////////////////////////////////////////////////////
01326 // CFullConnectSecurity::UpdateSecurity
01327 //
01328 /////////////////////////////////////////////////////////////////
01329 BOOL CFullConnectSecurity::UpdateSecurity()
01330 {
01331   //Retrieve Values from Security Sheet
01332   HWND hWndProtection = GetDlgItem(IDC_PROTECTION);
01333   HWND hWndImpersonate = GetDlgItem(IDC_IMPERSONATE);
01334
01335   //Obtain Protection Value
01336   INDEX iSel = (INDEX)SendMessage(hWndProtection, CB_GETCURSEL, 0, 0);
01337   m_dwProtectionProp = (DWORD)SendMessage(hWndProtection, CB_GETITEMDATA, iSel, 0);
01338
01339   //Obtain Impersonate Value
01340   iSel = (INDEX)SendMessage(hWndImpersonate, CB_GETCURSEL, 0, 0);
01341   m_dwImpersonateProp = (DWORD)SendMessage(hWndImpersonate, CB_GETITEMDATA, iSel, 0);
01342
01343   //MaskPassword
01344   m_dwMaskPasswordProp = IsDlgButtonChecked(IDB_MASKPASSWORD) == BST_CHECKED ? VARIANT_TRUE : IsDlgButtonChecked(IDB_MASKPASSWORD) == BST_INDETERMINATE ? VARIANT_FALSE : NOTSET;
01345
01346   //m_dwEncryptPasswordProp
01347   m_dwEncryptPasswordProp  = IsDlgButtonChecked(IDB_ENCRYPTPASSWORD) == BST_CHECKED ? VARIANT_TRUE : IsDlgButtonChecked(IDB_ENCRYPTPASSWORD) == BST_INDETERMINATE ? VARIANT_FALSE : NOTSET;
01348
01349   //m_dwCacheProp
01350   m_dwCacheProp = IsDlgButtonChecked(IDB_CACHEINFO) == BST_CHECKED ? VARIANT_TRUE : IsDlgButtonChecked(IDB_CACHEINFO) == BST_INDETERMINATE ? VARIANT_FALSE : NOTSET;
01351
01352   //m_dwPersistProp
01353   m_dwPersistProp = IsDlgButtonChecked(IDB_PERSISTINFO) == BST_CHECKED ? VARIANT_TRUE : IsDlgButtonChecked(IDB_PERSISTINFO) == BST_INDETERMINATE ? VARIANT_FALSE : NOTSET;
01354
01355   //m_dwPersistEncryptProp
01356   m_dwPersistEncryptProp = IsDlgButtonChecked(IDB_ENCRYPTINFO) == BST_CHECKED ? VARIANT_TRUE : IsDlgButtonChecked(IDB_ENCRYPTINFO) == BST_INDETERMINATE ? VARIANT_FALSE : NOTSET;
01357
01358   wSendMessage(GetDlgItem(IDE_INTEGRATED),  WM_GETTEXT, MAX_NAME_LEN, m_wszIntegrated);
01359   return TRUE;
01360 }
01361
01362
01363 /////////////////////////////////////////////////////////////////////////////
01364 // CFullConnectOptions
01365 //
01366 /////////////////////////////////////////////////////////////////////////////
01367 CFullConnectOptions::CFullConnectOptions()
01368   : CPropPageLite(IDD_FULLCONNECT_OPTIONS, "Options")
01369 {
01370 }
01371
01372 /////////////////////////////////////////////////////////////////////////////
01373 // CFullConnectOptions::OnInitDialog
01374 //
01375 /////////////////////////////////////////////////////////////////////////////
01376 BOOL CFullConnectOptions::OnInitDialog()
01377 {
01378   CWaitCursor waitCursor;
01379
01380   //Refresh Options
01381   RefreshOptions();
01382
01383   //Delegate
01384   return CPropPageLite::OnInitDialog();
01385 }
01386
01387
01388 /////////////////////////////////////////////////////////////////////////////
01389 // CFullConnectOptions::OnSetActive
01390 //
01391 /////////////////////////////////////////////////////////////////////////////
01392 BOOL CFullConnectOptions::OnSetActive()
01393 {
01394   RefreshOptions();
01395   return TRUE;
01396 }
01397
01398
01399 /////////////////////////////////////////////////////////////////////////////
01400 // CFullConnectOptions::OnKillActive
01401 //
01402 /////////////////////////////////////////////////////////////////////////////
01403 BOOL CFullConnectOptions::OnKillActive()
01404 {
01405   return UpdateOptions();
01406 }
01407
01408
01409 /////////////////////////////////////////////////////////////////////////////
01410 // CFullConnectOptions::OnCommand
01411 //
01412 /////////////////////////////////////////////////////////////////////////////
01413 BOOL CFullConnectOptions::OnCommand(UINT iID, HWND hWndCtrl)
01414 {
01415   switch(iID)
01416   {
01417     ON_COMMAND(IDB_REMOTE_SERVER, ::EnableWindow(::GetDlgItem(m_hWnd, IDE_REMOTESERVER), ::IsDlgButtonChecked(m_hWnd, IDB_REMOTE_SERVER)))
01418   };
01419
01420   return FALSE;
01421 }
01422
01423
01424 ////////////////////////////////////////////////////////////////
01425 // CFullConnectOptions::RefreshOptions
01426 //
01427 /////////////////////////////////////////////////////////////////
01428 BOOL CFullConnectOptions::RefreshOptions()
01429 {
01430   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
01431   CMainWindow* pCMainWindow = pCFullConnect->m_pCMainWindow;
01432
01433   //Set CLSCTX to previous saved values
01434   CheckDlgButton(IDB_INPROC_SERVER,       BST2STATE(m_dwCLSCTX & CLSCTX_INPROC_SERVER));
01435   CheckDlgButton(IDB_LOCAL_SERVER,        BST2STATE(m_dwCLSCTX & CLSCTX_LOCAL_SERVER));
01436   CheckDlgButton(IDB_REMOTE_SERVER,       BST2STATE(m_dwCLSCTX & CLSCTX_REMOTE_SERVER));
01437   CheckDlgButton(IDB_INPROC_HANDLER,        BST2STATE(m_dwCLSCTX & CLSCTX_INPROC_HANDLER));
01438   wSendMessage(GetDlgItem(IDE_REMOTESERVER),    WM_SETTEXT, 0, m_wszRemoteServer);
01439 	::EnableWindow(GetDlgItem(IDE_REMOTESERVER), m_dwCLSCTX & CLSCTX_REMOTE_SERVER);
01440
01441   //Set Connection Options to previous saved values
01442   CheckDlgButton(IDB_INIT_INITIALIZE,       BST2STATE(m_dwConnectOpts & CREATE_INITIALIZE));
01443   CheckDlgButton(IDB_INIT_SETPROPERTIES,      BST2STATE(m_dwConnectOpts & CREATE_SETPROPERTIES));
01444
01445   //NOTE: Currently these options are repeaded from the Global dialog (since we reuse it)
01446   //Just allow setting/unsetting global options here for convinence, but these are not
01447   //saved per configuration, since all other objects after this point would need to reference this
01448   //making it difficult unless we did it for just connection QI's and the rest are based upon global
01449   //settings...
01450   CheckDlgButton(IDB_QI_MANDATORY,        BST2STATE(pCMainWindow->GetOptions()->m_dwCreateOpts & CREATE_QI_MANDATORY));
01451   CheckDlgButton(IDB_QI_OPTIONAL,         BST2STATE(pCMainWindow->GetOptions()->m_dwCreateOpts & CREATE_QI_OPTIONAL));
01452
01453   //Set Other Options
01454   CheckDlgButton(IDB_USESERVICECOMP,        BST2STATE(m_dwConnectOpts & CREATE_USESERVICECOMP));
01455   return TRUE;
01456 }
01457
01458
01459 ////////////////////////////////////////////////////////////////
01460 // CFullConnectOptions::UpdateOptions
01461 //
01462 /////////////////////////////////////////////////////////////////
01463 BOOL CFullConnectOptions::UpdateOptions()
01464 {
01465   CFullConnect* pCFullConnect = (CFullConnect*)GetParent();
01466   CMainWindow* pCMainWindow = pCFullConnect->m_pCMainWindow;
01467
01468   //Obtain CLSCTX
01469   m_dwCLSCTX = 0;
01470   if(IsDlgButtonChecked(IDB_INPROC_SERVER))
01471     m_dwCLSCTX |= CLSCTX_INPROC_SERVER;
01472   if(IsDlgButtonChecked(IDB_LOCAL_SERVER))
01473     m_dwCLSCTX |= CLSCTX_LOCAL_SERVER;
01474   if(IsDlgButtonChecked(IDB_REMOTE_SERVER))
01475     m_dwCLSCTX |= CLSCTX_REMOTE_SERVER;
01476   if(IsDlgButtonChecked(IDB_INPROC_HANDLER))
01477     m_dwCLSCTX |= CLSCTX_INPROC_HANDLER;
01478
01479   //Obtain RemoteServer
01480   wSendMessage(GetDlgItem(IDE_REMOTESERVER), WM_GETTEXT, MAX_NAME_LEN, m_wszRemoteServer);
01481
01482   //Obtain Connection Options
01483   m_dwConnectOpts = 0;
01484   if(IsDlgButtonChecked(IDB_INIT_INITIALIZE))
01485     m_dwConnectOpts |= CREATE_INITIALIZE;
01486   if(IsDlgButtonChecked(IDB_INIT_SETPROPERTIES))
01487     m_dwConnectOpts |= CREATE_SETPROPERTIES;
01488
01489   //NOTE: Currently these options are repeaded from the Global dialog (since we reuse it)
01490   //Just allow setting/unsetting global options here for convinence, but these are not
01491   //saved per configuration, since all other objects after this point would need to reference this
01492   //making it difficult unless we did it for just connection QI's and the rest are based upon global
01493   //settings...
01494   ENABLE_BIT(pCMainWindow->GetOptions()->m_dwCreateOpts, CREATE_QI_MANDATORY, IsDlgButtonChecked(IDB_QI_MANDATORY));
01495   ENABLE_BIT(pCMainWindow->GetOptions()->m_dwCreateOpts, CREATE_QI_OPTIONAL,  IsDlgButtonChecked(IDB_QI_OPTIONAL));
01496
01497   //Obtain Other Options
01498   if(IsDlgButtonChecked(IDB_USESERVICECOMP))
01499     m_dwConnectOpts |= CREATE_USESERVICECOMP;
01500   return TRUE;
01501 }
01502
01503
01504
01505
01506 /////////////////////////////////////////////////////////////////////////////
01507 // CFullConnect
01508 //
01509 /////////////////////////////////////////////////////////////////////////////
01510 CFullConnect::CFullConnect(CMainWindow* pCMainWindow)
01511   : CPropSheetLite("Full Connect"), CRowsetViewerDlg(pCMainWindow)
01512 {
01513   AddPage(&m_CProvider);
01514   AddPage(&m_CProperties);
01515   AddPage(&m_CSecurity);
01516   AddPage(&m_COptions);
01517
01518   WCHAR wszBuffer[MAX_NAME_LEN+1];
01519   ULONG cBytes = 0;
01520
01521   //Enum
01522   m_pCEnumerator    = NULL;
01523   memset(&m_EnumInfo, 0, sizeof(ENUMINFO));
01524   StringCopy(m_EnumInfo.wszName,    L"MSDASQL", MAX_NAME_LEN);
01525   StringCopy(m_EnumInfo.wszParseName, L"MSDASQL", MAX_NAME_LEN);
01526
01527   //Reset all Defaults
01528   ResetDefaults();
01529
01530   //Load Configuration Name, so we know which configuration is the default
01531   GetRegEntry(HKEY_ROWSETVIEWER, wszCONFIG_KEY, L"DefaultConfig", m_wszConfigName, MAX_NAME_LEN);
01532
01533   //Load Recent Configurations
01534   for(ULONG i=0; i<MAX_RECENTCONFIGS; i++)
01535   {
01536     cBytes = sizeof(wszBuffer);
01537     if(S_OK != GetRegEnumValue(HKEY_ROWSETVIEWER, wszRECENTCONFIG_KEY, i, wszBuffer, &cBytes))
01538       break;
01539
01540     m_listConfigs.AddTail(wcsDuplicate(wszBuffer));
01541   }
01542
01543   //Load Recent File
01544   for(i=0; i<MAX_RECENTFILES; i++)
01545   {
01546     cBytes = sizeof(wszBuffer);
01547     if(S_OK != GetRegEnumValue(HKEY_ROWSETVIEWER, wszRECENTFILE_KEY, i, wszBuffer, &cBytes))
01548       break;
01549
01550     m_listFiles.AddTail(wcsDuplicate(wszBuffer));
01551   }
01552 }
01553
01554
01555 ////////////////////////////////////////////////////////////////
01556 // CFullConnect::~CFullConnect
01557 //
01558 /////////////////////////////////////////////////////////////////
01559 CFullConnect::~CFullConnect()
01560 {
01561   //Save Recent Configs
01562   DelRegEntry(HKEY_ROWSETVIEWER, wszRECENTCONFIG_KEY);
01563   while(!m_listConfigs.IsEmpty())
01564   {
01565     WCHAR* pwszConfigName = m_listConfigs.RemoveHead();
01566     if(FAILED(SetRegEntry(HKEY_ROWSETVIEWER, wszRECENTCONFIG_KEY, pwszConfigName, MAX_NAME_LEN)))
01567       break;
01568
01569     SAFE_FREE(pwszConfigName);
01570   }
01571
01572   //Save Recent Files
01573   DelRegEntry(HKEY_ROWSETVIEWER, wszRECENTFILE_KEY);
01574   while(!m_listFiles.IsEmpty())
01575   {
01576     WCHAR* pwszFileName = m_listFiles.RemoveHead();
01577     if(FAILED(SetRegEntry(HKEY_ROWSETVIEWER, wszRECENTFILE_KEY, pwszFileName, MAX_NAME_LEN)))
01578       break;
01579
01580     SAFE_FREE(pwszFileName);
01581   }
01582 }
01583
01584
01585 ////////////////////////////////////////////////////////////////
01586 // CFullConnect::ResetDefaults
01587 //
01588 /////////////////////////////////////////////////////////////////
01589 BOOL CFullConnect::ResetDefaults()
01590 {
01591   //Configuration Name
01592   StringCopy(m_wszConfigName, L"(Default)", MAX_NAME_LEN);
01593
01594   //Provider Page
01595   m_CProvider.m_wszLocation[0]    = wEOL;     //DBPROP_INIT_LOCATION
01596   m_CProvider.m_wszDataSource[0]    = wEOL;     //DBPROP_INIT_DATASOURCE
01597   m_CProvider.m_wszUserID[0]      = wEOL;     //DBPROP_AUTH_USERID
01598   m_CProvider.m_wszPassword[0]    = wEOL;     //DBPROP_AUTH_PASSWORD
01599   m_CProvider.m_dwPromptProp      = DBPROMPT_COMPLETE;
01600   m_CProvider.m_hWndProp        = (HWND)NOTSET;
01601
01602   //Properties Page
01603   m_CProperties.m_wszProvString[0]  = wEOL;     //DBPROP_INIT_PROVIDERSTRING
01604   m_CProperties.m_wszCatalog[0]   = wEOL;     //DBPROP_INIT_CATALOG
01605   m_CProperties.m_dwlcidProp      = NOTSET;
01606
01607   m_CProperties.m_dwAsynchProp    = NOTSET;
01608   m_CProperties.m_dwTimeoutProp   = NOTSET;
01609   m_CProperties.m_dwModeProp      = NOTSET;
01610
01611   //Security Page
01612   m_CSecurity.m_dwProtectionProp    = NOTSET;
01613   m_CSecurity.m_dwImpersonateProp   = NOTSET;
01614   m_CSecurity.m_dwMaskPasswordProp  = NOTSET;
01615   m_CSecurity.m_dwEncryptPasswordProp = NOTSET;
01616   m_CSecurity.m_dwCacheProp     = NOTSET;
01617   m_CSecurity.m_dwPersistProp     = NOTSET;
01618   m_CSecurity.m_dwPersistEncryptProp  = NOTSET;
01619   m_CSecurity.m_wszIntegrated[0]    = wEOL;     // DBPROP_INIT_INTEGRATED
01620
01621   //Options Page
01622   m_COptions.m_dwCLSCTX       = CLSCTX_INPROC_SERVER;
01623   m_COptions.m_wszRemoteServer[0]   = wEOL;
01624   m_COptions.m_dwConnectOpts      = CREATE_INITIALIZE | CREATE_SETPROPERTIES;
01625   return TRUE;
01626 }
01627
01628
01629 ////////////////////////////////////////////////////////////////
01630 // CFullConnect::LoadDefaults
01631 //
01632 /////////////////////////////////////////////////////////////////
01633 BOOL CFullConnect::LoadDefaults()
01634 {
01635   //Need to remove any previously set properties.
01636   //Specifically any Advanced properties, since this is a new configuration
01637   m_CPropSets.RemoveAll();
01638
01639   //Configuration Name
01640   if(m_wszConfigName[0] == wEOL)
01641     StringCopy(m_wszConfigName, L"(Default)", MAX_NAME_LEN);
01642
01643   //Formulate the key
01644   WCHAR wszKeyName[MAX_NAME_LEN];
01645   StringFormat(wszKeyName, NUMELE(wszKeyName), L"%s\\%s", wszCONFIG_KEY, m_wszConfigName);
01646
01647   //Selected Provider
01648   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Provider",       m_EnumInfo.wszName, MAX_NAME_LEN);
01649   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ParseName",      m_EnumInfo.wszParseName, MAX_NAME_LEN);
01650
01651   //Provider Page
01652   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Location",       m_CProvider.m_wszLocation, MAX_NAME_LEN);
01653   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"DataSource",     m_CProvider.m_wszDataSource, MAX_NAME_LEN);
01654   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"UserID",       m_CProvider.m_wszUserID, MAX_NAME_LEN);
01655   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Password",       m_CProvider.m_wszPassword, MAX_NAME_LEN);
01656   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"PromptProp",     (ULONG*)&m_CProvider.m_dwPromptProp);
01657   m_CProvider.m_hWndProp  = (HWND)NOTSET;
01658
01659   //Properties Page
01660   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ProvString",     m_CProperties.m_wszProvString, MAX_NAME_LEN);
01661   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Catalog",        m_CProperties.m_wszCatalog, MAX_NAME_LEN);
01662   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"lcidProp",       (ULONG*)&m_CProperties.m_dwlcidProp);
01663   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"AsynchProp",     (ULONG*)&m_CProperties.m_dwAsynchProp);
01664   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"TimeoutProp",      (ULONG*)&m_CProperties.m_dwTimeoutProp);
01665   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ModeProp",       (ULONG*)&m_CProperties.m_dwModeProp);
01666
01667   //Security Page
01668   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ProtectionProp",   (ULONG*)&m_CSecurity.m_dwProtectionProp);
01669   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ImpersonateProp",    (ULONG*)&m_CSecurity.m_dwImpersonateProp);
01670   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"MaskPasswordProp",   (ULONG*)&m_CSecurity.m_dwMaskPasswordProp);
01671   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"EncryptPasswordProp",  (ULONG*)&m_CSecurity.m_dwEncryptPasswordProp);
01672   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"CacheProp",      (ULONG*)&m_CSecurity.m_dwCacheProp);
01673   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"PersistProp",      (ULONG*)&m_CSecurity.m_dwPersistProp);
01674   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"PersistEncryptProp", (ULONG*)&m_CSecurity.m_dwPersistEncryptProp);
01675   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Integrated",     m_CSecurity.m_wszIntegrated, MAX_NAME_LEN);
01676
01677   //Options Page
01678   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"CLSCTX",       &m_COptions.m_dwCLSCTX);
01679   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"RemoteServer",     m_COptions.m_wszRemoteServer, MAX_NAME_LEN);
01680   GetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ConnectOptions",   &m_COptions.m_dwConnectOpts);
01681   return TRUE;
01682 }
01683
01684
01685 ////////////////////////////////////////////////////////////////
01686 // CFullConnect::SaveDefaults
01687 //
01688 /////////////////////////////////////////////////////////////////
01689 BOOL CFullConnect::SaveDefaults()
01690 {
01691   //Obtain the Configuration Name
01692   m_CProvider.m_comboConfig.GetSelText(m_wszConfigName, MAX_NAME_LEN);
01693   m_CProvider.m_comboConfig.SetSelText(m_wszConfigName, TRUE/*fAddItem*/);
01694
01695   //Configuration Name
01696   if(m_wszConfigName[0] == wEOL)
01697     StringCopy(m_wszConfigName, L"(Default)", MAX_NAME_LEN);
01698
01699   //Save Configuration Name, so we know which configuration is the default
01700   SetRegEntry(HKEY_ROWSETVIEWER, wszCONFIG_KEY, L"DefaultConfig", m_wszConfigName);
01701
01702   //Formulate the key
01703   WCHAR wszKeyName[MAX_NAME_LEN];
01704   StringFormat(wszKeyName, NUMELE(wszKeyName), L"%s\\%s", wszCONFIG_KEY, m_wszConfigName);
01705
01706   //Selected Provider
01707   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Provider",       m_EnumInfo.wszName);
01708   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ParseName",      m_EnumInfo.wszParseName);
01709
01710   //Provider Page
01711   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Location",       m_CProvider.m_wszLocation);
01712   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"DataSource",     m_CProvider.m_wszDataSource);
01713   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"UserID",       m_CProvider.m_wszUserID);
01714   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Password",       m_CProvider.m_wszPassword);
01715   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"PromptProp",     m_CProvider.m_dwPromptProp);
01716
01717   //NOTE: The Window handle doesn't get persisted...
01718 //  m_hWndProp
01719
01720   //Properties Page
01721   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ProvString",     m_CProperties.m_wszProvString);
01722   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Catalog",        m_CProperties.m_wszCatalog);
01723   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"lcidProp",       m_CProperties.m_dwlcidProp);
01724   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"AsynchProp",     m_CProperties.m_dwAsynchProp);
01725   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"TimeoutProp",      m_CProperties.m_dwTimeoutProp);
01726   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ModeProp",       m_CProperties.m_dwModeProp);
01727
01728   //Security Page
01729   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ProtectionProp",   m_CSecurity.m_dwProtectionProp);
01730   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ImpersonateProp",    m_CSecurity.m_dwImpersonateProp);
01731   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"MaskPasswordProp",   m_CSecurity.m_dwMaskPasswordProp);
01732   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"EncryptPasswordProp",  m_CSecurity.m_dwEncryptPasswordProp);
01733   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"CacheProp",      m_CSecurity.m_dwCacheProp);
01734   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"PersistProp",      m_CSecurity.m_dwPersistProp);
01735   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"PersistEncryptProp", m_CSecurity.m_dwPersistEncryptProp);
01736   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"Integrated",     m_CSecurity.m_wszIntegrated);
01737
01738   //Options Page
01739   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"CLSCTX",       m_COptions.m_dwCLSCTX);
01740   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"RemoteServer",     m_COptions.m_wszRemoteServer);
01741   SetRegEntry(HKEY_ROWSETVIEWER, wszKeyName, L"ConnectOptions",   m_COptions.m_dwConnectOpts);
01742
01743   //Update the Saved Configurations (now that successfuly connected)
01744   AddRecentConfig();
01745   return TRUE;
01746 }
01747
01748
01749 ////////////////////////////////////////////////////////////////
01750 // CFullConnect::LoadRecentConfig
01751 //
01752 /////////////////////////////////////////////////////////////////
01753 BOOL CFullConnect::LoadRecentConfig(ULONG iRecentConfig)
01754 {
01755   ASSERT(iRecentConfig < m_listConfigs.GetCount());
01756
01757   //Set the active config
01758   StringCopy(m_wszConfigName, m_listConfigs.GetAt(m_listConfigs.FindIndex(iRecentConfig)), MAX_NAME_LEN);
01759
01760   //Load the saved properties and Connect
01761   LoadDefaults();
01762   FullConnect();
01763   return TRUE;
01764 }
01765
01766
01767 ////////////////////////////////////////////////////////////////
01768 // CFullConnect::AddRecentConfig
01769 //
01770 /////////////////////////////////////////////////////////////////
01771 BOOL CFullConnect::AddRecentConfig(WCHAR* pwszConfigName)
01772 {
01773   //Bascially the Alogythym for updating the Recent Configurations
01774   //is similar to a FIFO stack.  Lastest items become #1 and all other items
01775   //are moved down.  The only exception is if the item already exists
01776   //then it is brought up to number one and all other items are reordered...
01777   if(pwszConfigName == NULL)
01778     pwszConfigName = m_wszConfigName;
01779
01780   //Make sure it doesn't already exist in the list
01781   RemoveRecentConfig(pwszConfigName);
01782
01783   //Now add it to the list
01784   m_listConfigs.AddHead(wcsDuplicate(pwszConfigName));
01785
01786   //Make sure the list is less than the Max
01787   if(m_listConfigs.GetCount() > MAX_RECENTCONFIGS)
01788   {
01789     pwszConfigName = m_listConfigs.RemoveTail();
01790     SAFE_FREE(pwszConfigName);
01791   }
01792   return TRUE;
01793 }
01794
01795
01796 ////////////////////////////////////////////////////////////////
01797 // CFullConnect::RemoveRecentConfig
01798 //
01799 /////////////////////////////////////////////////////////////////
01800 BOOL CFullConnect::RemoveRecentConfig(WCHAR* pwszConfigName)
01801 {
01802   ASSERT(pwszConfigName);
01803
01804   //Make sure it doesn't allready exist in the list
01805   POSITION pos = m_listConfigs.GetHeadPosition();
01806   while(pos)
01807   {
01808     POSITION posSave = pos;
01809     WCHAR* pwszName = m_listConfigs.GetNext(pos);
01810     if(StringCompare(pwszName, pwszConfigName))
01811     {
01812       //Remove this item and Add to the head
01813       pwszName = m_listConfigs.RemoveAt(posSave);
01814       SAFE_FREE(pwszName);
01815       return TRUE;
01816     }
01817   }
01818
01819   return TRUE;
01820 }
01821
01822
01823 ////////////////////////////////////////////////////////////////
01824 // CFullConnect::LoadRecentFile
01825 //
01826 /////////////////////////////////////////////////////////////////
01827 BOOL CFullConnect::LoadRecentFile(ULONG iRecentFile)
01828 {
01829   ASSERT(iRecentFile < m_listFiles.GetCount());
01830
01831   //Obtain the Selected File
01832   WCHAR* pwszFileName = m_listFiles.GetAt(m_listFiles.FindIndex(iRecentFile));
01833
01834   //Load the saved properties and Connect
01835   m_pCMainWindow->m_pCServiceComp->ConnectFromFile(pwszFileName);
01836   return TRUE;
01837 }
01838
01839
01840 ////////////////////////////////////////////////////////////////
01841 // CFullConnect::AddRecentFile
01842 //
01843 /////////////////////////////////////////////////////////////////
01844 BOOL CFullConnect::AddRecentFile(WCHAR* pwszFileName)
01845 {
01846   //Bascially the Alogythym for updating the Recent Files
01847   //is similar to a FIFO stack.  Lastest items become #1 and all other items
01848   //are moved down.  The only exception is if the item already exists
01849   //then it is brought up to number one and all other items are reordered...
01850   ASSERT(pwszFileName);
01851
01852   //Make sure it doesn't already exist in the list
01853   RemoveRecentFile(pwszFileName);
01854
01855   //Now add it to the list
01856   m_listFiles.AddHead(wcsDuplicate(pwszFileName));
01857
01858   //Make sure the list is less than the Max
01859   if(m_listFiles.GetCount() > MAX_RECENTFILES)
01860   {
01861     pwszFileName = m_listFiles.RemoveTail();
01862     SAFE_FREE(pwszFileName);
01863   }
01864   return TRUE;
01865 }
01866
01867
01868 ////////////////////////////////////////////////////////////////
01869 // CFullConnect::RemoveRecentFile
01870 //
01871 /////////////////////////////////////////////////////////////////
01872 BOOL CFullConnect::RemoveRecentFile(WCHAR* pwszFileName)
01873 {
01874   ASSERT(pwszFileName);
01875
01876   //Make sure it doesn't allready exist in the list
01877   POSITION pos = m_listFiles.GetHeadPosition();
01878   while(pos)
01879   {
01880     POSITION posSave = pos;
01881     WCHAR* pwszName = m_listFiles.GetNext(pos);
01882     if(StringCompare(pwszName, pwszFileName))
01883     {
01884       //Remove this item and Add to the head
01885       pwszName = m_listFiles.RemoveAt(posSave);
01886       SAFE_FREE(pwszName);
01887       return TRUE;
01888     }
01889   }
01890
01891   return TRUE;
01892 }
01893
01894
01895 ////////////////////////////////////////////////////////////////
01896 // CFullConnect::Display
01897 //
01898 /////////////////////////////////////////////////////////////////
01899 INT_PTR CFullConnect::Display(HWND hWndParent, CEnumerator* pCEnumerator, ENUMINFO* pEnumInfo)
01900 {
01901   //If an Enumerator is passed in, it represents the enumerator to use for instanting the object...
01902   //Otherwise if NULL - it uses the Root Enumerator Object...
01903   m_pCEnumerator = pCEnumerator;
01904   if(pEnumInfo)
01905   {
01906     ResetDefaults();
01907     memcpy(&m_EnumInfo, pEnumInfo, sizeof(ENUMINFO));
01908   }
01909   else
01910   {
01911     //Load the defaults for this configuration
01912     LoadDefaults();
01913   }
01914
01915   //Display the Property Sheet
01916     if(DoModal(hWndParent) >=0 )
01917   {
01918     //Now display focus to the new MDIChildWindow (if successful...)
01919 		::SetFocus(::GetWindow(m_pCMainWindow->m_hWndMDIClient, GW_CHILD));
01920   }
01921
01922   return TRUE;
01923 }
01924
01925
01926 ////////////////////////////////////////////////////////////////
01927 // CFullConnect::BrowseEnumeratorProc
01928 //
01929 /////////////////////////////////////////////////////////////////
01930 INT_PTR WINAPI CFullConnect::BrowseEnumeratorProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
01931 {
01932   switch (message)
01933   {
01934     case WM_INITDIALOG:
01935     {
01936       CWaitCursor waitCursor;
01937
01938       //save off the this pointer
01939       CFullConnect* pThis = (CFullConnect*)SetThis(hWnd, (void*)lParam);
01940       CEnumerator* pCRootEnum =  pThis->m_pCMainWindow->m_pCRootEnumerator;
01941
01942       //Controls
01943       CComboBoxLite comboProvider(hWnd, IDC_PROVIDER);
01944       CListViewLite listviewEnum(hWnd, IDL_LISTVIEW);
01945
01946       //We may need to connect to the RootEnumerator, if not done already
01947       pCRootEnum->CreateEnumInfo(CLSID_OLEDB_ENUMERATOR);
01948
01949       //Setup ListView
01950       SendMessage(listviewEnum.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
01951       listviewEnum.InsertColumn(0, L"SOURCES_NAME");
01952
01953       //Set image list to the ListView
01954       ListView_SetImageList(listviewEnum.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
01955
01956       //We just need to fill in a combo box with the same values
01957       //from the Root Enumerator, but only displaying Enumerators...
01958       for(ULONG i=0; i<pCRootEnum->m_cEnumInfo; i++)
01959       {
01960         if(pCRootEnum->m_rgEnumInfo[i].eType == DBSOURCETYPE_ENUMERATOR)
01961         {
01962           //Add the name to the list
01963           //Since we have the CBS_SORT turned on, the order in the Combo Box does
01964           //not match our array, so we pass the array index (lParam) as the item data
01965           comboProvider.AddString(pCRootEnum->m_rgEnumInfo[i].wszName, (LPARAM)&pCRootEnum->m_rgEnumInfo[i]);
01966         }
01967       }
01968
01969       //Try to do a smart guess on which Enumerator.
01970       //Since the spec doesn't have a actual way of prgrammatically
01971       //assoiciating providers with their enumerators, we will try and search
01972       //the enumerator name for the providers name...
01973       //So if using MSDASQL, it will find MSDASQL Enumerator
01974       INDEX iIndex = comboProvider.FindString(pThis->m_EnumInfo.wszName, -1);
01975       comboProvider.SetCurSel(iIndex!=CB_ERR ? iIndex : 0);
01976
01977       //AutoSize Header
01978       listviewEnum.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
01979
01980       //Send a selection change to the ComboBox so it updates everything
01981       SendMessage(hWnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDC_PROVIDER, hWnd, CBN_SELCHANGE));
01982       CenterDialog(hWnd);
01983       return TRUE;
01984     }
01985
01986     case WM_COMMAND:
01987     {
01988       //Filter out any Control Notification codes
01989       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
01990       {
01991         return UNHANDLED_MSG;
01992       }
01993
01994       //LBN_SELCHANGE ListBox Selection change
01995       switch(GET_WM_COMMAND_CMD(wParam, lParam))
01996       {
01997         //Selection change in a list box occurred
01998         case LBN_SELCHANGE:
01999         {
02000           //Get the "this" pointer
02001           CFullConnect* pThis = (CFullConnect*)GetThis(hWnd);
02002           CEnumerator* pCRootEnum =  pThis->m_pCMainWindow->m_pCRootEnumerator;
02003
02004           //Controls
02005           CComboBoxLite comboProvider(hWnd, IDC_PROVIDER);
02006           CListViewLite listviewEnum(hWnd, IDL_LISTVIEW);
02007
02008           //The Selection has changed...
02009           listviewEnum.DeleteAllItems();
02010           listviewEnum.EnableWindow(FALSE);
02011
02012           //Update the Window Title - with the Description
02013           INDEX iIndex = comboProvider.GetCurSel();
02014           ENUMINFO* pEnumInfo = (ENUMINFO*)comboProvider.GetItemParam(iIndex);
02015
02016           if(pEnumInfo && (LPARAM)pEnumInfo!=CB_ERR)
02017             wSendMessage(hWnd, WM_SETTEXT, 0, pEnumInfo->wszDescription);
02018           return 0;
02019         }
02020       }
02021
02022       switch (GET_WM_COMMAND_ID(wParam, lParam))
02023       {
02024         case IDB_CONNECT:
02025         {
02026           //Get the "this" pointer
02027           CFullConnect* pThis = (CFullConnect*)GetThis(hWnd);
02028
02029           //Fill in Enum Dialog
02030           pThis->DisplayBrowseEnumInfo(hWnd);
02031           return 0;
02032         }
02033
02034         case IDOK:
02035         {
02036           CWaitCursor waitCursor;
02037
02038           //Get the "this" pointer
02039           CFullConnect* pThis = (CFullConnect*)GetThis(hWnd);
02040           WCHAR wszBuffer[MAX_NAME_LEN] = {0};
02041
02042           //Controls
02043           CListViewLite listviewEnum(hWnd, IDL_LISTVIEW);
02044           INDEX iSelRow = listviewEnum.GetNextItem(-1, LVNI_SELECTED);
02045
02046           //Need to obtain Enum selection from the ListView
02047           listviewEnum.GetItemText(iSelRow, 0, wszBuffer, MAX_NAME_LEN);
02048
02049           //Now replace the entire edit box with the new selected value
02050           CEditBoxLite editSource;
02051           editSource.CreateIndirect(pThis->m_CProvider.m_hWnd, pThis->m_idSource);
02052
02053           //Just update value
02054           editSource.ReplaceAll(wszBuffer, TRUE/*bReplaceAll*/);
02055           EndDialog(hWnd, TRUE);
02056           return 0;
02057         }
02058
02059         case IDCANCEL:
02060         {
02061           EndDialog(hWnd, FALSE);
02062           return 0;
02063         }
02064       }
02065       break;
02066     }//WM_COMMAND
02067
02068
02069     case WM_NOTIFY:
02070     {
02071       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
02072
02073       switch(pDispInfo->hdr.code)
02074       {
02075         //Since we have "TwoClickActive" on this will get sent
02076         //Whenever a row is clicked on twice!
02077         //This functionality used to be done with NM_DBCLK
02078         case LVN_ITEMACTIVATE:
02079         {
02080           //Send an OK message
02081           SendMessage(hWnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDOK, hWnd, 0));
02082           return 0;
02083         }
02084       }
02085       break;
02086     }//WM_NOTIFY
02087   }
02088
02089   return FALSE;
02090 }
02091
02092
02093 ////////////////////////////////////////////////////////////////
02094 // CFullConnect::DisplayBrowseEnumInfo
02095 //
02096 /////////////////////////////////////////////////////////////////
02097 HRESULT CFullConnect::DisplayBrowseEnumInfo(HWND hWnd)
02098 {
02099   HRESULT hr = S_OK;
02100
02101   ULONG i = 0;
02102   ENUMINFO* rgEnumInfo = NULL;
02103   WCHAR wszBuffer[MAX_NAME_LEN];
02104   CComPtr<IParseDisplayName> spParseDisplayName;
02105   WCHAR* pwszParseName = NULL;
02106   CEnumerator* pCEnumerator = new CEnumerator(m_pCMainWindow);
02107   CBase* pCSource = NULL;
02108
02109   //Controls
02110   CComboBoxLite comboProvider(hWnd, IDC_PROVIDER);
02111   CListViewLite listviewEnum(hWnd, IDL_LISTVIEW);
02112
02113   //Clear Previous Items
02114   listviewEnum.DeleteAllItems();
02115   listviewEnum.EnableWindow(FALSE);
02116
02117   //Obtain the Specified ParseName
02118   INDEX iSel = comboProvider.GetCurSel();
02119   if(iSel == CB_ERR)
02120   {
02121     wszBuffer[0] = wEOL;
02122     comboProvider.GetWindowText(wszBuffer, MAX_NAME_LEN);
02123     pwszParseName = wszBuffer;
02124   }
02125   else
02126   {
02127     ENUMINFO* pEnumInfo = (ENUMINFO*)comboProvider.GetItemParam(iSel);
02128     pwszParseName = pEnumInfo->wszParseName;
02129   }
02130
02131
02132   //Connect to the specified Enumerator
02133   TESTC(hr = m_pCMainWindow->m_pCRootEnumerator->ParseDisplayName(pwszParseName, CLSCTX_ALL, IID_IParseDisplayName, (IUnknown**)&spParseDisplayName, &pCSource));
02134
02135   //Obtain the Enumerator Rowset
02136   TESTC(hr = pCEnumerator->CreateObject(pCSource, IID_IParseDisplayName, spParseDisplayName));
02137   TESTC(hr = pCEnumerator->CreateEnumInfo());
02138
02139   //Now loop through the EnumInfo and Display in the ListView
02140   //SOURCES_NAME
02141   for(i=0; i<pCEnumerator->m_cEnumInfo; i++)
02142     listviewEnum.InsertItem(i, 0, pCEnumerator->m_rgEnumInfo[i].wszName);
02143   listviewEnum.EnableWindow(TRUE);
02144
02145 CLEANUP:
02146   SAFE_FREE(rgEnumInfo);
02147   SAFE_RELEASE(pCEnumerator);
02148   return hr;
02149 }
02150
02151
02152 ////////////////////////////////////////////////////////////////
02153 // CFullConnect::InitPropCombo
02154 //
02155 /////////////////////////////////////////////////////////////////
02156 HRESULT CFullConnect::InitPropCombo(HWND hWndCombo, ULONG cItems, const WIDENAMEMAP* rgNameMap, LPARAM lParam)
02157 {
02158   //Remove any existing Data
02159   SendMessage(hWndCombo,  CB_RESETCONTENT, 0, 0);
02160   INDEX iDefSel = 0;
02161
02162   //First Item of every Property Combo is "No Set"
02163   INDEX iSel = (INDEX)SendMessage(hWndCombo, CB_ADDSTRING, 0, (LPARAM)"Not Set");
02164   SendMessage(hWndCombo,  CB_SETITEMDATA, iSel, (LPARAM)NOTSET);
02165
02166   //Fill in all Combo values...
02167   for(ULONG i=0; i<cItems; i++)
02168   {
02169     iSel = (INDEX)wSendMessage(hWndCombo, CB_ADDSTRING, 0, rgNameMap[i].pwszName);
02170     SendMessage(hWndCombo, CB_SETITEMDATA,  iSel, (LPARAM)rgNameMap[i].lItem);
02171
02172     if(rgNameMap[i].lItem == lParam)
02173       iDefSel = iSel;
02174   }
02175
02176   //Set the specified Default
02177   SendMessage(hWndCombo,  CB_SETCURSEL, iDefSel, 0);
02178   return S_OK;
02179 }
02180
02181
02182 ////////////////////////////////////////////////////////////////
02183 // CFullConnect::GetAdvProperties
02184 //
02185 /////////////////////////////////////////////////////////////////
02186 HRESULT CFullConnect::GetAdvProperties()
02187 {
02188   HRESULT hr = S_OK;
02189   CComPtr<IDBProperties> spDBProperties;
02190   ULONG iPropSet = 0;
02191   CPropertiesDlg sCPropertiesDlg(m_pCMainWindow);
02192
02193   //Obtain instance of Provider/Enum (if we haven't done so already)
02194   TESTC(hr = m_CProvider.GetProviderName());
02195   TESTC(hr = CreateProviderInstance(IID_IDBProperties, (IUnknown**)&spDBProperties));
02196
02197   //GetProperties (incase we haven't already)
02198   TESTC(hr = GetPropSets());
02199
02200   //Bring up the SetProperties Dialog
02201   TESTC(hr = sCPropertiesDlg.SetProperties(m_CProperties.m_hWnd, &DBPROPSET_DBINITALL, IID_IDBProperties, spDBProperties, spDBProperties, &m_CPropSets));
02202
02203   //Now read just our saved values...
02204   //Add update Dialogs, we only need to update values our dialogs know
02205   //about, all other properties are just saved in the set and added later...
02206   for(iPropSet=0; iPropSet<m_CPropSets.GetCount(); iPropSet++)
02207   {
02208     const DBPROPSET* pPropSet = &m_CPropSets[iPropSet];
02209     for(ULONG iProp=0; iProp<pPropSet->cProperties; iProp++)
02210     {
02211       DBPROP* pProp = &pPropSet->rgProperties[iProp];
02212       if(pPropSet->guidPropertySet == DBPROPSET_DBINIT)
02213       {
02214         switch(pProp->dwPropertyID)
02215         {
02216           //Provider Page
02217           case DBPROP_INIT_LOCATION:
02218             VariantToString(&pProp->vValue, m_CProvider.m_wszLocation, MAX_NAME_LEN, CONV_VARBOOL);
02219             break;
02220
02221           case DBPROP_INIT_DATASOURCE:
02222             VariantToString(&pProp->vValue, m_CProvider.m_wszDataSource, MAX_NAME_LEN, CONV_VARBOOL);
02223             break;
02224
02225           case DBPROP_AUTH_USERID:
02226             VariantToString(&pProp->vValue, m_CProvider.m_wszUserID, MAX_NAME_LEN, CONV_VARBOOL);
02227             break;
02228
02229           case DBPROP_AUTH_PASSWORD:
02230             VariantToString(&pProp->vValue, m_CProvider.m_wszPassword, MAX_NAME_LEN, CONV_VARBOOL);
02231             break;
02232
02233           case DBPROP_INIT_PROMPT:
02234             m_CProvider.m_dwPromptProp = V_I2(&pProp->vValue);
02235             break;
02236
02237           case DBPROP_INIT_HWND:
02238             //Note: This works for 32bit as well as 64bit values (since HWND varies).
02239             //Reason, the variant is a union, so all values are placed into the same
02240             //starting location, so we simply take the adress and cast to the type.
02241             m_CProvider.m_hWndProp    = *(HWND*)&V_I4(&pProp->vValue);
02242             break;
02243
02244           //Propeerties Page
02245           case DBPROP_INIT_PROVIDERSTRING:
02246             VariantToString(&pProp->vValue, m_CProperties.m_wszProvString, MAX_NAME_LEN, CONV_VARBOOL);
02247             break;
02248
02249           case DBPROP_INIT_CATALOG:
02250             VariantToString(&pProp->vValue, m_CProperties.m_wszCatalog, MAX_NAME_LEN, CONV_VARBOOL);
02251             break;
02252
02253           case DBPROP_INIT_LCID:
02254             m_CProperties.m_dwlcidProp = V_I4(&pProp->vValue);
02255             break;
02256
02257           case DBPROP_INIT_ASYNCH:
02258             m_CProperties.m_dwAsynchProp = V_I4(&pProp->vValue);
02259             break;
02260
02261           case DBPROP_INIT_TIMEOUT:
02262             m_CProperties.m_dwTimeoutProp = V_I4(&pProp->vValue);
02263             break;
02264
02265           case DBPROP_INIT_MODE:
02266             m_CProperties.m_dwModeProp = V_I4(&pProp->vValue);
02267             break;
02268
02269           //Security Page
02270           case DBPROP_INIT_PROTECTION_LEVEL:
02271             m_CSecurity.m_dwProtectionProp = V_I4(&pProp->vValue);
02272             break;
02273
02274           case DBPROP_INIT_IMPERSONATION_LEVEL:
02275             m_CSecurity.m_dwImpersonateProp = V_I4(&pProp->vValue);
02276             break;
02277
02278           case DBPROP_AUTH_MASK_PASSWORD:
02279             m_CSecurity.m_dwMaskPasswordProp = V_BOOL(&pProp->vValue);
02280             break;
02281
02282           case DBPROP_AUTH_ENCRYPT_PASSWORD:
02283             m_CSecurity.m_dwEncryptPasswordProp = V_BOOL(&pProp->vValue);
02284             break;
02285
02286           case DBPROP_AUTH_CACHE_AUTHINFO:
02287             m_CSecurity.m_dwCacheProp = V_BOOL(&pProp->vValue);
02288             break;
02289
02290           case DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO:
02291             m_CSecurity.m_dwPersistProp = V_BOOL(&pProp->vValue);
02292             break;
02293
02294           case DBPROP_AUTH_PERSIST_ENCRYPTED:
02295             m_CSecurity.m_dwPersistEncryptProp = V_BOOL(&pProp->vValue);
02296             break;
02297
02298           case DBPROP_AUTH_INTEGRATED:
02299             VariantToString(&pProp->vValue, m_CSecurity.m_wszIntegrated, MAX_NAME_LEN, CONV_VARBOOL);
02300             break;
02301         }
02302       }
02303     }
02304   };
02305
02306 CLEANUP:
02307   return hr;
02308 }
02309
02310
02311
02312 ////////////////////////////////////////////////////////////////
02313 // CFullConnect::CreateProviderInstance
02314 //
02315 /////////////////////////////////////////////////////////////////
02316 HRESULT CFullConnect::CreateProviderInstance(REFIID riid, IUnknown** ppIUnknown, CBase** ppCSource)
02317 {
02318   //Which Enumerator, Root Enum or passed in enumerator...
02319   CEnumerator* pCEnumerator       = m_pCEnumerator ? m_pCEnumerator : m_pCMainWindow->m_pCRootEnumerator;
02320   HRESULT hr = S_OK;
02321
02322   //Delegate out the Enumerator to instansiate this object
02323   TESTC(hr = pCEnumerator->ParseDisplayName(m_EnumInfo.wszParseName, m_COptions.m_dwCLSCTX, riid, ppIUnknown, ppCSource, m_COptions.m_dwConnectOpts, m_COptions.m_wszRemoteServer));
02324
02325 CLEANUP:
02326   return hr;
02327 }
02328
02329
02330 ////////////////////////////////////////////////////////////////
02331 // CFullConnect::GetPropSets
02332 //
02333 /////////////////////////////////////////////////////////////////
02334 HRESULT CFullConnect::GetPropSets()
02335 {
02336   HRESULT hr = S_OK;
02337
02338   //Free Previous Properties
02339   //This method gets called whenever connect gets called.
02340   //So the user may or may not have called 'More', which would have already
02341   //Obtained these properties.  Also the user may have updated the dialogs
02342   //afterwards, so bascially it boils down to the fact we need to "reget" all
02343   //Properties that are in the dialog, and save all the prev properties (More)
02344   ULONG cPropSets = 0;
02345   DBPROPSET* rgPropSets = NULL;
02346   m_CPropSets.Detach(&cPropSets, &rgPropSets);
02347
02348   //Setup Properties from Provider Page
02349   if(m_CProvider.m_wszLocation[0])
02350     m_CPropSets.SetProperty(DBPROP_INIT_LOCATION,   DBPROPSET_DBINIT, DBTYPE_BSTR, m_CProvider.m_wszLocation);
02351   if(m_CProvider.m_wszDataSource[0])
02352     m_CPropSets.SetProperty(DBPROP_INIT_DATASOURCE,   DBPROPSET_DBINIT, DBTYPE_BSTR, m_CProvider.m_wszDataSource);
02353   if(m_CProvider.m_wszUserID[0])
02354     m_CPropSets.SetProperty(DBPROP_AUTH_USERID,     DBPROPSET_DBINIT, DBTYPE_BSTR, m_CProvider.m_wszUserID);
02355   if(m_CProvider.m_wszPassword[0])
02356     m_CPropSets.SetProperty(DBPROP_AUTH_PASSWORD,   DBPROPSET_DBINIT, DBTYPE_BSTR, m_CProvider.m_wszPassword);
02357   if(m_CProvider.m_dwPromptProp != NOTSET)
02358     m_CPropSets.SetProperty(DBPROP_INIT_PROMPT,     DBPROPSET_DBINIT, DBTYPE_I2,  (void*)(LONG_PTR)m_CProvider.m_dwPromptProp);
02359
02360   //By default we will set HWND if the user has requested a prompt value (except noprompt), or
02361   //the user has explicitly set the hwnd themselves in the Advanced Properties...
02362   if(m_CProvider.m_hWndProp != (HWND)NOTSET || (m_CProvider.m_dwPromptProp != NOTSET && m_CProvider.m_dwPromptProp != DBPROMPT_NOPROMPT))
02363   {
02364     //Setup our "dynamic" window handle property...
02365     //NOTE: We have to do this here, since this needs to not only be a valid window handle,
02366     //must it also be the full connect dialog handle, so that if the provider displays a prompt
02367     //dialog its "modal" to this one and not the main window...
02368
02369     //Note: On 64bit HWND is I8 instead of I4
02370     DBTYPE wType = (sizeof(HWND)==8) ? DBTYPE_I8 : DBTYPE_I4;
02371     HWND hWnd = (m_CProvider.m_hWndProp != (HWND)NOTSET) ? m_CProvider.m_hWndProp : m_CProvider.m_hWnd;
02372     m_CPropSets.SetProperty(DBPROP_INIT_HWND,     DBPROPSET_DBINIT, wType, (void*)hWnd);
02373   }
02374
02375   //Setup Properties from Properties Page
02376   if(m_CProperties.m_wszProvString[0])
02377     m_CPropSets.SetProperty(DBPROP_INIT_PROVIDERSTRING, DBPROPSET_DBINIT, DBTYPE_BSTR, m_CProperties.m_wszProvString);
02378   if(m_CProperties.m_wszCatalog[0])
02379     m_CPropSets.SetProperty(DBPROP_INIT_CATALOG,    DBPROPSET_DBINIT, DBTYPE_BSTR, m_CProperties.m_wszCatalog);
02380   if(m_CProperties.m_dwTimeoutProp != NOTSET)
02381     m_CPropSets.SetProperty(DBPROP_INIT_TIMEOUT,    DBPROPSET_DBINIT, DBTYPE_I4,  (void*)(LONG_PTR)m_CProperties.m_dwTimeoutProp);
02382   if(m_CProperties.m_dwAsynchProp != NOTSET)
02383     m_CPropSets.SetProperty(DBPROP_INIT_ASYNCH,     DBPROPSET_DBINIT, DBTYPE_I4,  (void*)(LONG_PTR)m_CProperties.m_dwAsynchProp);
02384   if(m_CProperties.m_dwlcidProp != NOTSET)
02385     m_CPropSets.SetProperty(DBPROP_INIT_LCID,     DBPROPSET_DBINIT, DBTYPE_I4,  (void*)(LONG_PTR)m_CProperties.m_dwlcidProp);
02386   if(m_CProperties.m_dwModeProp != NOTSET)
02387     m_CPropSets.SetProperty(DBPROP_INIT_MODE,     DBPROPSET_DBINIT, DBTYPE_I4,  (void*)(LONG_PTR)m_CProperties.m_dwModeProp);
02388
02389   //Setup Properties from Security Page
02390   if(m_CSecurity.m_dwProtectionProp != NOTSET)
02391     m_CPropSets.SetProperty(DBPROP_INIT_PROTECTION_LEVEL,DBPROPSET_DBINIT, DBTYPE_I4,   (void*)(LONG_PTR)m_CSecurity.m_dwProtectionProp);
02392   if(m_CSecurity.m_dwImpersonateProp != NOTSET)
02393     m_CPropSets.SetProperty(DBPROP_INIT_IMPERSONATION_LEVEL,DBPROPSET_DBINIT, DBTYPE_I4,  (void*)(LONG_PTR)m_CSecurity.m_dwImpersonateProp);
02394   if(m_CSecurity.m_dwMaskPasswordProp != NOTSET)
02395     m_CPropSets.SetProperty(DBPROP_AUTH_MASK_PASSWORD,  DBPROPSET_DBINIT, DBTYPE_BOOL,    (void*)(LONG_PTR)m_CSecurity.m_dwMaskPasswordProp);
02396   if(m_CSecurity.m_dwEncryptPasswordProp != NOTSET)
02397     m_CPropSets.SetProperty(DBPROP_AUTH_ENCRYPT_PASSWORD,DBPROPSET_DBINIT, DBTYPE_BOOL, (void*)(LONG_PTR)m_CSecurity.m_dwEncryptPasswordProp);
02398   if(m_CSecurity.m_dwCacheProp != NOTSET)
02399     m_CPropSets.SetProperty(DBPROP_AUTH_CACHE_AUTHINFO, DBPROPSET_DBINIT, DBTYPE_BOOL,    (void*)(LONG_PTR)m_CSecurity.m_dwCacheProp);
02400   if(m_CSecurity.m_dwPersistProp != NOTSET)
02401     m_CPropSets.SetProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, DBPROPSET_DBINIT, DBTYPE_BOOL,  (void*)(LONG_PTR)m_CSecurity.m_dwPersistProp);
02402   if(m_CSecurity.m_dwPersistEncryptProp != NOTSET)
02403     m_CPropSets.SetProperty(DBPROP_AUTH_PERSIST_ENCRYPTED,  DBPROPSET_DBINIT, DBTYPE_BOOL,  (void*)(LONG_PTR)m_CSecurity.m_dwPersistEncryptProp);
02404   if(m_CSecurity.m_wszIntegrated[0])
02405     m_CPropSets.SetProperty(DBPROP_AUTH_INTEGRATED,   DBPROPSET_DBINIT, DBTYPE_BSTR,    m_CSecurity.m_wszIntegrated);
02406
02407   //Loop over all the Advanced Properties set,
02408   //And adjust any of the existing property options or type.
02409   //Always use the "latest" value specified in the dialogs, but the Advncaed
02410   //is the only way to set the type or options (REQUIRED/OPTIONAL)...
02411
02412   //If there are properties that exist out side of the ones avilable in the
02413   //dialogs, jusat set it, it may be an provider specific property,
02414   //or a newly added one to the group...
02415   for(ULONG iPropSet=0; iPropSet<cPropSets; iPropSet++)
02416   {
02417     DBPROPSET* pPropSet = &rgPropSets[iPropSet];
02418     for(ULONG iProp=0; iProp<pPropSet->cProperties; iProp++)
02419     {
02420       DBPROP* pProp = &pPropSet->rgProperties[iProp];
02421       if(pPropSet->guidPropertySet != DBPROPSET_DBINIT)
02422       {
02423         //Otherwise this is not a settable property through the
02424         //Dialogs, so just add the property, since it may be a
02425         //provider specific property or newly added to DBINIT set...
02426         m_CPropSets.SetProperty(pProp->dwPropertyID, pPropSet->guidPropertySet, DBTYPE_VARIANT, &pProp->vValue, pProp->dwOptions);
02427         break;
02428       }
02429       else
02430       {
02431         //DBPROPSET_DBINIT - Probably alread included from the dialogs
02432         switch(pProp->dwPropertyID)
02433         {
02434           //Provider Page
02435           case DBPROP_INIT_LOCATION:
02436           case DBPROP_INIT_DATASOURCE:
02437           case DBPROP_AUTH_USERID:
02438           case DBPROP_AUTH_PASSWORD:
02439           case DBPROP_INIT_PROMPT:
02440           case DBPROP_INIT_HWND:
02441
02442           //Propeerties Page
02443           case DBPROP_INIT_PROVIDERSTRING:
02444           case DBPROP_INIT_CATALOG:
02445           case DBPROP_INIT_LCID:
02446           case DBPROP_INIT_ASYNCH:
02447           case DBPROP_INIT_TIMEOUT:
02448           case DBPROP_INIT_MODE:
02449
02450           //Security Page
02451           case DBPROP_INIT_PROTECTION_LEVEL:
02452           case DBPROP_INIT_IMPERSONATION_LEVEL:
02453           case DBPROP_AUTH_MASK_PASSWORD:
02454           case DBPROP_AUTH_ENCRYPT_PASSWORD:
02455           case DBPROP_AUTH_CACHE_AUTHINFO:
02456           case DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO:
02457           case DBPROP_AUTH_PERSIST_ENCRYPTED:
02458           case DBPROP_AUTH_INTEGRATED:
02459           {
02460             //All off these properties are available through the Dialogs
02461             //But not all the options and types are.  So if this property
02462             //exists in the current set, then adjust any options and types...
02463             //Since these are only exposed in the Advnaced page...
02464
02465             //Find this property in the current set...
02466             DBPROP* pPropFound = m_CPropSets.FindProperty(pProp->dwPropertyID, pPropSet->guidPropertySet, pProp->colid);
02467             if(pPropFound)
02468             {
02469               //Override any options - from advanced
02470               pPropFound->dwOptions = pProp->dwOptions;
02471               //Override any wType - from advanced
02472               pPropFound->vValue.vt = pProp->vValue.vt;
02473               //Override any colid - from advanced
02474               //memcpy(pProp->colid, pProp->colid, sizeof(DBID));
02475             }
02476             else
02477             {
02478               //It may not have been found in the current set
02479               //since the dialog may have been Empty, ("").  Its hard
02480               //to determine what empty means in a edit box, does it mean
02481               //Empty String, NULL, not set, or VT_EMPTY.
02482               //If this property exists in the Advanced set this is where
02483               //we will obtain this information...
02484
02485               //The Advanced Page will always override the edit boxes...
02486               if(pProp->vValue.vt == VT_EMPTY || (pProp->vValue.vt == VT_BSTR && pProp->vValue.bstrVal && !pProp->vValue.bstrVal[0]))
02487                 m_CPropSets.SetProperty(pProp->dwPropertyID, pPropSet->guidPropertySet, DBTYPE_VARIANT, &pProp->vValue, pProp->dwOptions);
02488             }
02489             break;
02490           }
02491
02492           default:
02493           {
02494             //Otherwise this is not a settable property through the
02495             //Dialogs, so just add the property, since it may be a
02496             //provider specific property or newly added to DBINIT set...
02497             m_CPropSets.SetProperty(pProp->dwPropertyID, pPropSet->guidPropertySet, DBTYPE_VARIANT, &pProp->vValue, pProp->dwOptions);
02498             break;
02499           }
02500         }
02501       }
02502     }
02503   };
02504
02505   FreeProperties(&cPropSets, &rgPropSets);
02506   return hr;
02507 }
02508
02509 /////////////////////////////////////////////////////////////////
02510 // CFullConnect::FullConnect
02511 //
02512 /////////////////////////////////////////////////////////////////
02513 HRESULT CFullConnect::FullConnect()
02514 {
02515   CWaitCursor waitCursor;
02516   HRESULT hr = S_OK;
02517   CBase* pCSource = NULL;
02518   CBase* pCObject = NULL;
02519   CComPtr<IUnknown> spUnknown;
02520
02521   //Obtain instance of Provider/Enum (if haven't done so already)...
02522   TESTC(hr = CreateProviderInstance(IID_IUnknown, &spUnknown, &pCSource));
02523
02524   //Setup PropSets from all saved options
02525   TESTC(hr = GetPropSets());
02526
02527   //Connect using the specified properties
02528   //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
02529   pCObject = m_pCMainWindow->HandleObjectType(pCSource, spUnknown, IID_IUnknown, eCDataSource, m_CPropSets.GetCount(), m_CPropSets.GetPropSets(), CREATE_NEWWINDOW | CREATE_DETERMINE_TYPE | m_COptions.m_dwConnectOpts | CREATE_NODISPLAY);
02530   if(!pCObject)
02531     TESTC(hr = E_FAIL);
02532
02533   //Update the Object...
02534   pCObject->m_dwCLSCTX = m_COptions.m_dwCLSCTX;
02535   if(pCObject->m_pCMDIChild)
02536     pCObject->m_pCMDIChild->SetConfig(m_wszConfigName);
02537
02538   //Now Display the object...
02539   pCObject->DisplayObject();
02540
02541
02542 CLEANUP:
02543   return hr;
02544 }
02545
02546
02547 ////////////////////////////////////////////////////////////////
02548 // CPropertiesDlg::CPropertiesDlg
02549 //
02550 /////////////////////////////////////////////////////////////////
02551 CPropertiesDlg::CPropertiesDlg(CMainWindow* pCMainWindow)
02552   : CDialogLite(IDD_SETPROPERTIES), CRowsetViewerDlg(pCMainWindow)
02553 {
02554   m_pIUnkProperties   = NULL;
02555   m_pIDBPropertyInfo    = NULL;
02556   m_pIDBDataSourceAdmin = NULL;
02557
02558   m_pCPropSets      = NULL;
02559
02560   //Save State
02561   m_cPropInfoSets     = 0;
02562   m_rgPropInfoSets    = NULL;
02563   m_pStringBuffer     = NULL;
02564   m_bClearAll       = TRUE;
02565 }
02566
02567
02568 ////////////////////////////////////////////////////////////////
02569 // CPropertiesDlg::~CPropertiesDlg
02570 //
02571 /////////////////////////////////////////////////////////////////
02572 CPropertiesDlg::~CPropertiesDlg()
02573 {
02574 }
02575
02576
02577 ////////////////////////////////////////////////////////////////
02578 // CPropertiesDlg::SetProperties
02579 //
02580 /////////////////////////////////////////////////////////////////
02581 HRESULT CPropertiesDlg::SetProperties(HWND hWndParent, const GUID* pGuidPropertySet, REFIID riidProp, IUnknown* pIUnkProperties, IDBProperties* pIDBPropertyInfo, CPropSets* pCPropSets, IDBDataSourceAdmin* pIDBDataSourceAdmin)
02582 {
02583 //  NOTE: We can have valid causes where there is not properties interface passed in.
02584 //  When OpenRowset is called there is no method to obtain current property values, other than the
02585 //  passed in pcPropSets, which also may be empty is no properties are set...
02586 //  ASSERT(pIUnkProperties);
02587
02588   //Setup variable for StaticProcs to use...
02589   m_iidProp       = riidProp;
02590   m_pGuidPropertySet    = pGuidPropertySet;
02591
02592   m_pIUnkProperties   = pIUnkProperties;
02593   m_pIDBPropertyInfo    = pIDBPropertyInfo;
02594   m_pIDBDataSourceAdmin = pIDBDataSourceAdmin;
02595
02596   m_pCPropSets      = pCPropSets;
02597   m_eMethodType     = METHOD_SETPROPERTIES;
02598
02599   //Now Display the dialog
02600   if(DoModal(hWndParent) == IDOK)
02601     return S_OK;
02602
02603   return DB_E_CANCELED;
02604 }
02605
02606
02607 ////////////////////////////////////////////////////////////////
02608 // CPropertiesDlg::GetProperties
02609 //
02610 /////////////////////////////////////////////////////////////////
02611 HRESULT CPropertiesDlg::GetProperties(HWND hWndParent, const GUID* pGuidPropertySet, REFIID riidProp, IUnknown* pIUnkProperties, IDBProperties* pIDBPropertyInfo, CPropSets* pCPropSets, IDBDataSourceAdmin* pIDBDataSourceAdmin)
02612 {
02613   ASSERT(pIUnkProperties);
02614
02615   //Setup variable for StaticProcs to use...
02616   m_iidProp       = riidProp;
02617   m_pGuidPropertySet    = pGuidPropertySet;
02618
02619   m_pIUnkProperties   = pIUnkProperties;
02620   m_pIDBPropertyInfo    = pIDBPropertyInfo;
02621   m_pIDBDataSourceAdmin = pIDBDataSourceAdmin;
02622
02623   m_pCPropSets      = pCPropSets;
02624   m_eMethodType     = METHOD_GETPROPERTIES;
02625
02626   //Now Display the dialog
02627   if(DoModal(hWndParent) == IDOK)
02628     return S_OK;
02629
02630   return DB_E_CANCELED;
02631 }
02632
02633
02634 ////////////////////////////////////////////////////////////////
02635 // CPropertiesDlg::GetPropertyInfo
02636 //
02637 /////////////////////////////////////////////////////////////////
02638 HRESULT CPropertiesDlg::GetPropertyInfo(HWND hWndParent, const GUID* pGuidPropertySet, REFIID riidProp, IDBProperties* pIDBPropertyInfo, IDBDataSourceAdmin* pIDBDataSourceAdmin)
02639 {
02640   ASSERT(pIDBPropertyInfo || pIDBDataSourceAdmin);
02641
02642   //Setup variable for StaticProcs to use...
02643   m_iidProp       = riidProp;
02644   m_pGuidPropertySet    = pGuidPropertySet;
02645
02646   m_pIUnkProperties   = NULL;
02647   m_pIDBPropertyInfo    = pIDBPropertyInfo;
02648   m_pIDBDataSourceAdmin = pIDBDataSourceAdmin;
02649
02650   m_pCPropSets      = NULL;
02651   m_eMethodType     = METHOD_GETPROPERTYINFO;
02652
02653   //Now Display the dialog
02654   if(DoModal(hWndParent) == IDOK)
02655     return S_OK;
02656
02657   return DB_E_CANCELED;
02658 }
02659
02660
02661 /////////////////////////////////////////////////////////////////////
02662 // CPropertiesDlg::OnInitDialog
02663 //
02664 /////////////////////////////////////////////////////////////////////
02665 BOOL CPropertiesDlg::OnInitDialog()
02666 {
02667   CWaitCursor waitCursor;
02668
02669   //Setup Controls
02670   m_listviewProps.CreateIndirect(m_hWnd, IDL_PROPERTY);
02671   m_comboPropSet.CreateIndirect(m_hWnd, IDC_PROPSET);
02672
02673   //Header (change controls)
02674   m_comboOptions.CreateIndirect(m_hWnd, IDC_PROPEDIT_OPTIONS);
02675   m_comboType.CreateIndirect(m_hWnd, IDC_PROPEDIT_TYPE);
02676   m_comboValue.CreateIndirect(m_hWnd, IDC_PROPEDIT_VALUE);
02677   m_editDesc.CreateIndirect(m_hWnd, IDE_PROPEDIT_NAME);
02678
02679   //Use Extended ListView Controls...
02680   SendMessage(m_listviewProps.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES);
02681
02682   //ColumnHeaders
02683   m_listviewProps.InsertColumn(PROP_NAME,   L"Property");
02684   m_listviewProps.InsertColumn(PROP_TYPE,   L"Type");
02685   m_listviewProps.InsertColumn(PROP_VALUE,  L"Value");
02686   m_listviewProps.InsertColumn(PROP_FLAGS,  m_eMethodType == METHOD_GETPROPERTYINFO ? L"Flags" : L"Options");
02687   m_listviewProps.InsertColumn(PROP_DESC,   L"Description");
02688   if(m_eMethodType != METHOD_GETPROPERTYINFO)
02689   {
02690     m_listviewProps.InsertColumn(PROP_COLID,  L"ColID");
02691   }
02692
02693   //Set image list to the ListView
02694   ListView_SetImageList(m_listviewProps.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
02695   ListView_SetImageList(m_listviewProps.m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_STATE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_STATE);
02696
02697   //Default PropertySet
02698   IID iidProp = m_iidProp;
02699
02700   //Now adjust display and find required PropSet
02701   if(iidProp == IID_IDBProperties)
02702   {
02703     if(m_eMethodType == METHOD_SETPROPERTIES)
02704       SetWindowText(L"IDBProperties::SetProperties");
02705     else if(m_eMethodType == METHOD_GETPROPERTIES)
02706       SetWindowText(L"IDBProperties::GetProperties");
02707     else
02708       SetWindowText(L"IDBProperties::GetPropertyInfo");
02709   }
02710   else if(iidProp == IID_IDBDataSourceAdmin)
02711   {
02712     if(m_eMethodType == METHOD_SETPROPERTIES)
02713       SetWindowText(L"IDBDataSourceAdmin::ModifyDataSource");
02714     else
02715       SetWindowText(L"IDBDataSourceAdmin::GetCreationProperties");
02716   }
02717   else if(iidProp == IID_ISessionProperties)
02718   {
02719     if(m_eMethodType == METHOD_SETPROPERTIES)
02720       SetWindowText(L"ISessionProperties::SetProperties");
02721     else
02722       SetWindowText(L"ISessionProperties::GetProperties");
02723   }
02724   else if(iidProp == IID_ICommandProperties)
02725   {
02726     if(m_eMethodType == METHOD_SETPROPERTIES)
02727       SetWindowText(L"ICommandProperties::SetProperties");
02728     else
02729       SetWindowText(L"ICommandProperties::GetProperties");
02730   }
02731   else if(iidProp == IID_IRowsetInfo)
02732   {
02733     if(m_eMethodType == METHOD_SETPROPERTIES)
02734       SetWindowText(L"Set Properties for rgPropSet params");
02735     else
02736       SetWindowText(L"IRowsetInfo::GetProperties");
02737   }
02738   else
02739   {
02740     ASSERT(!"Unhandled Property Type!");
02741   }
02742
02743
02744   //Fill in the PROPSET Combo
02745   for(ULONG i=0; i<g_cPropSetMaps; i++)
02746   {
02747     INDEX iSel = m_comboPropSet.AddString(g_rgPropSetMaps[i].pwszName, i);
02748     if(m_eMethodType == METHOD_SETPROPERTIES)
02749       if(m_pGuidPropertySet && *m_pGuidPropertySet == *(g_rgPropSetMaps[i].pGuid))
02750         m_comboPropSet.SetCurSel(iSel);
02751   }
02752
02753   //Add DBPROPSET All (0, NULL)...
02754   INDEX iSel = m_comboPropSet.AddString(L"All Properties", CB_ERR);
02755
02756   //Default Selection
02757   iSel = m_comboPropSet.GetCurSel();
02758   m_comboPropSet.SetCurSel(iSel==CB_ERR || (ULONG)iSel>g_cPropSetMaps ? g_cPropSetMaps : iSel);
02759
02760   //Fill in Types Combo
02761   m_comboType.Populate(g_cVariantTypes, g_rgVariantTypes);
02762
02763   //Fill in Options Combo
02764   m_comboOptions.AddString(L"REQUIRED");  // == 0
02765   m_comboOptions.AddString(L"OPTIONAL");  // == 1
02766
02767   //Include OLE DB Defined Properties
02768   CheckDlgButton(IDB_ADDDEFINEDPROPS,   FALSE/*Default*/);
02769   m_bClearAll = TRUE;
02770
02771   //Display properties for just this set...
02772   const ULONG cPropertyIDSets = 1;
02773   DBPROPIDSET rgPropertyIDSets[cPropertyIDSets];
02774   if(m_pGuidPropertySet)
02775   {
02776     rgPropertyIDSets[0].cPropertyIDs = 0;
02777     rgPropertyIDSets[0].rgPropertyIDs = NULL;
02778     rgPropertyIDSets[0].guidPropertySet = *m_pGuidPropertySet;
02779   }
02780
02781   //Do we limit the initial property set?
02782   BOOL fInitialPropSet = m_eMethodType == METHOD_SETPROPERTIES && m_pGuidPropertySet;
02783
02784   //Display the Properties (again - this  time all of them)
02785   TESTC(DisplayProperties(fInitialPropSet ? cPropertyIDSets : 0, rgPropertyIDSets));
02786
02787 CLEANUP:
02788   //AutoSize Columns
02789   m_listviewProps.SetColumnWidth(PROP_NAME, LVSCW_AUTOSIZE_USEHEADER);
02790   m_listviewProps.SetColumnWidth(PROP_TYPE, LVSCW_AUTOSIZE_USEHEADER);
02791   m_listviewProps.SetColumnWidth(PROP_VALUE,  LVSCW_AUTOSIZE_USEHEADER);
02792   m_listviewProps.SetColumnWidth(PROP_FLAGS,  LVSCW_AUTOSIZE_USEHEADER);
02793   m_listviewProps.SetColumnWidth(PROP_DESC, LVSCW_AUTOSIZE_USEHEADER);
02794   if(m_eMethodType != METHOD_GETPROPERTYINFO)
02795   {
02796     m_listviewProps.SetColumnWidth(PROP_COLID,  LVSCW_AUTOSIZE_USEHEADER);
02797   }
02798
02799   //Disable Combos
02800   m_editDesc.EnableWindow(FALSE);
02801   m_comboOptions.EnableWindow(FALSE);
02802   m_comboType.EnableWindow(FALSE);
02803   m_comboValue.EnableWindow(FALSE);
02804
02805   //Delegate
02806   return CDialogLite::OnInitDialog();
02807 }
02808
02809
02810 /////////////////////////////////////////////////////////////////////
02811 // CPropertiesDlg::OnOK
02812 //
02813 /////////////////////////////////////////////////////////////////////
02814 BOOL CPropertiesDlg::OnOK()
02815 {
02816   CWaitCursor waitCursor;
02817   HRESULT hr = S_OK;
02818
02819   //Send a selection change message to the Value Combo
02820   if(m_eMethodType == METHOD_SETPROPERTIES)
02821     OnPropValueChange();
02822   CPropSets sCPropSets;
02823   CPropIDSets sCPropIDSets;
02824
02825   //Now that the user has selected all the properties
02826   //they wish to have set, we need to loop through all the checked
02827   //properties and add them to our list...
02828   INDEX cItems = m_listviewProps.GetItemCount();
02829   for(LONG i=0; i<cItems; i++)
02830   {
02831     //Only interested in checked items
02832     BOOL bChecked = m_listviewProps.GetItemState(i, LVIS_STATEIMAGEMASK) & INDEXTOSTATEIMAGEMASK(STATE_CHECKED);
02833     if(!bChecked)
02834       continue;
02835
02836     //Only interested in actual items, (not headers or spaces)
02837     DBPROPINFOSET* pPropInfoSet = NULL;
02838     DBPROPINFO* pPropInfo = GetSelPropInfo(i, &pPropInfoSet);
02839     if(!pPropInfo || !pPropInfoSet)
02840       continue;
02841
02842     if(m_eMethodType == METHOD_SETPROPERTIES)
02843     {
02844       //Now we have a real checked item so add it to our propset
02845       sCPropSets.SetProperty(pPropInfo->dwPropertyID, pPropInfoSet->guidPropertySet, DBTYPE_VARIANT, &pPropInfo->vValues, pPropInfo->dwFlags & DBPROPFLAGS_REQUIRED ? DBPROPOPTIONS_REQUIRED : DBPROPOPTIONS_OPTIONAL);
02846     }
02847     else
02848     {
02849       //Add the PropertyID
02850       sCPropIDSets.SetProperty(pPropInfo->dwPropertyID, pPropInfoSet->guidPropertySet);
02851     }
02852   }
02853
02854   if(m_eMethodType == METHOD_SETPROPERTIES)
02855   {
02856     //Either just save the properties back in the propset provided
02857     if(m_pCPropSets)
02858     {
02859       m_pCPropSets->Attach(sCPropSets);
02860     }
02861     //Or actually set the properties...
02862     else
02863     {
02864       //Now actually set the Properties
02865       TESTC(hr = SetProperties(sCPropSets.GetCount(), sCPropSets.GetPropSets()));
02866     }
02867   }
02868   else
02869   {
02870     //Don't end the Dialog, (if the user has selected properties)
02871     //just recall GetProperties with those selected properties.  A good way to test
02872     //a provider on a sub set of properties, rather than always calling with (0, NULL)
02873     if(sCPropIDSets.GetCount())
02874     {
02875       TESTC(hr = DisplayProperties(sCPropIDSets.GetCount(), sCPropIDSets.GetPropSets()));
02876       return FALSE;
02877     }
02878   }
02879
02880 CLEANUP:
02881   //Don't end the  Dialog on Error...
02882   if(FAILED(hr))
02883     return FALSE;
02884
02885   //Free Saved State...
02886   FreeProperties(&m_cPropInfoSets, &m_rgPropInfoSets);
02887   SAFE_FREE(m_pStringBuffer);
02888
02889   //Delegate
02890   return CDialogLite::OnOK();
02891 }
02892
02893
02894
02895 /////////////////////////////////////////////////////////////////////
02896 // CPropertiesDlg::OnCancel
02897 //
02898 /////////////////////////////////////////////////////////////////////
02899 BOOL CPropertiesDlg::OnCancel()
02900 {
02901   //Cleanup any memory allocated
02902   FreeProperties(&m_cPropInfoSets, &m_rgPropInfoSets);
02903   SAFE_FREE(m_pStringBuffer);
02904
02905   //Delegate
02906   return CDialogLite::OnCancel();
02907 }
02908
02909
02910 ////////////////////////////////////////////////////////////////
02911 // CPropertiesDlg::DisplayProperty
02912 //
02913 /////////////////////////////////////////////////////////////////
02914 HRESULT CPropertiesDlg::DisplayProperty(INDEX iItem, DBPROP* pProp, DBPROPINFO* pPropInfo, REFGUID guidPropertySet, LPARAM lParam)
02915 {
02916   //Display this property in the listview
02917   static WCHAR wszBuffer[MAX_NAME_LEN+1] = {0};
02918   ASSERT(pPropInfo);
02919
02920   //Determine which icon to display
02921   INT iImage = IMAGE_QUESTION;  //Default - unknown flags
02922
02923   //READ|WRITE
02924   if(BIT_SET(pPropInfo->dwFlags, DBPROPFLAGS_READ|DBPROPFLAGS_WRITE))
02925   {
02926     //Read-Write  - (very common)
02927     iImage = IMAGE_NORMAL;
02928   }
02929   //READ
02930   else if(BIT_SET(pPropInfo->dwFlags, DBPROPFLAGS_READ))
02931   {
02932     //Read-Only   - (very common)
02933     iImage = IMAGE_LOCK;
02934   }
02935   //WRITE
02936   else if(BIT_SET(pPropInfo->dwFlags, DBPROPFLAGS_WRITE))
02937   {
02938     //Write-Only  - (not common, able to set but not retrieve values)
02939     iImage = IMAGE_DELETE;
02940   }
02941
02942   //PROP_NAME (Indent from PropertySet)
02943   //Also store the wType as the lParam
02944   WCHAR* pwszName = GetPropertyName(pPropInfo->dwPropertyID, guidPropertySet);
02945   if(pwszName)
02946     StringFormat(wszBuffer, NUMELE(wszBuffer), L"     %s", pwszName);
02947   else
02948     StringFormat(wszBuffer, NUMELE(wszBuffer), L"     0x%x", pPropInfo->dwPropertyID);
02949   m_listviewProps.InsertItem(iItem, PROP_NAME, wszBuffer, lParam, iImage);
02950
02951   //PROP_TYPE
02952   m_listviewProps.InsertItem(iItem, PROP_TYPE, GetVariantTypeName(pPropInfo->vtType));
02953
02954   //PROP_VALUE
02955   VARIANT* pVariant = pProp ? &pProp->vValue : &pPropInfo->vValues;
02956   if(pVariant->vt == VT_EMPTY)
02957   {
02958     //Provide a default value?
02959     if(m_eMethodType == METHOD_SETPROPERTIES)
02960     {
02961       V_VT(pVariant) = pPropInfo->vtType;
02962       switch(V_VT(pVariant))
02963       {
02964         case VT_EMPTY:
02965         case VT_NULL:
02966           break;
02967
02968         case VT_BOOL:
02969           V_BOOL(pVariant) = VARIANT_TRUE;
02970           break;
02971
02972         case VT_I4:
02973           V_I4(pVariant) = 0;
02974           break;
02975
02976         case VT_I2:
02977           V_I2(pVariant) = 0;
02978           break;
02979
02980         case VT_BSTR:
02981           V_BSTR(pVariant) = NULL;
02982           break;
02983
02984         default:
02985           V_VT(pVariant) = VT_EMPTY;
02986           break;
02987       };
02988     }
02989   }
02990
02991   //PROP_VALUE
02992   VariantToString(pVariant, wszBuffer, MAX_NAME_LEN, CONV_VARBOOL);
02993   m_listviewProps.InsertItem(iItem, PROP_VALUE, wszBuffer);
02994
02995
02996   //PROP_FLAGS
02997   if(m_eMethodType == METHOD_GETPROPERTYINFO)
02998   {
02999     //PROP_FALGS
03000     StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pPropInfo->dwFlags);
03001     m_listviewProps.InsertItem(iItem, PROP_FLAGS, wszBuffer);
03002   }
03003   else
03004   {
03005     if(pProp)
03006     {
03007       if(pProp->dwOptions == DBPROPOPTIONS_OPTIONAL)
03008         m_listviewProps.InsertItem(iItem, PROP_FLAGS, L"OPTIONAL");
03009       else if(pProp->dwOptions == DBPROPOPTIONS_REQUIRED)
03010         m_listviewProps.InsertItem(iItem, PROP_FLAGS, L"REQUIRED");
03011       else
03012       {
03013         StringFormat(wszBuffer, NUMELE(wszBuffer), L"0x%08x", pProp->dwOptions);
03014         m_listviewProps.InsertItem(iItem, PROP_FLAGS, wszBuffer);
03015       }
03016     }
03017     else
03018     {
03019       m_listviewProps.InsertItem(iItem, PROP_FLAGS, pPropInfo->dwFlags & DBPROPFLAGS_REQUIRED ? L"REQUIRED" : L"OPTIONAL");
03020     }
03021   }
03022
03023   //PROP_DESC
03024   m_listviewProps.InsertItem(iItem, PROP_DESC, pPropInfo->pwszDescription);
03025
03026   if(pProp && m_eMethodType != METHOD_GETPROPERTYINFO)
03027   {
03028     //PROP_COLID
03029     DBIDToString(pProp ? &pProp->colid : NULL, wszBuffer, MAX_NAME_LEN);
03030     m_listviewProps.InsertItem(iItem, PROP_COLID, wszBuffer);
03031   }
03032
03033   return S_OK;
03034 }
03035
03036
03037 ////////////////////////////////////////////////////////////////
03038 // CPropertiesDlg::DisplayProperties
03039 //
03040 /////////////////////////////////////////////////////////////////
03041 HRESULT CPropertiesDlg::DisplayProperties(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets)
03042 {
03043   HRESULT hr = S_OK;
03044   WCHAR wszBuffer[MAX_NAME_LEN+1];
03045   ULONG iPropSet,iProp,iItems = 0;
03046
03047   //Now remove any previous items
03048   m_listviewProps.DeleteAllItems();
03049
03050   //Free Previous Properties...
03051   FreeProperties(&m_cPropInfoSets, &m_rgPropInfoSets);
03052   SAFE_FREE(m_pStringBuffer);
03053
03054   //GetPropertyInfo
03055   //Both GetProperties and SetProperites needs this info as well, not just GetPropertyInfo.
03056   //Since they need to know the description and readwrite flags...
03057   hr = GetPropertyInfo(cPropertyIDSets, rgPropertyIDSets, &m_cPropInfoSets, &m_rgPropInfoSets, &m_pStringBuffer);
03058
03059   //Do any specific post processing before displaying
03060   switch(m_eMethodType)
03061   {
03062     case METHOD_GETPROPERTYINFO:
03063     {
03064       //We just display the info returned from GetPropertyInfo...
03065       break;
03066     }
03067
03068     case METHOD_SETPROPERTIES:
03069     {
03070       ULONG cPropSets = 0;
03071       DBPROPSET* rgPropSets = NULL;
03072
03073       //For the SetProperties dialog, we want to display all the properties
03074       //obtained from GetPropertyInfo and provide the current values of the properties
03075       //obtained from GetProperties.  This allows the user access to set all available properties
03076       //and have the current value so they know what it is before setting it...
03077       hr = GetProperties(0, NULL, &cPropSets, &rgPropSets);
03078
03079       //Now combine both sets...
03080       if(SUCCEEDED(hr) && cPropSets && rgPropSets)
03081         TESTC(hr = CombineProperties(&m_cPropInfoSets, &m_rgPropInfoSets, cPropSets, rgPropSets, TRUE/*bFreeAddedPropSet*/));
03082       break;
03083     }
03084
03085     case METHOD_GETPROPERTIES:
03086     {
03087       //Save off the PropertyInfo
03088       ULONG cPropInfoSets       = m_cPropInfoSets;
03089       DBPROPINFOSET* rgPropInfoSets = m_rgPropInfoSets;
03090       m_cPropInfoSets = 0;
03091       m_rgPropInfoSets = NULL;
03092
03093       ULONG cPropSets = 0;
03094       DBPROPSET* rgPropSets = NULL;
03095
03096       //GetProperties
03097       hr = GetProperties(cPropertyIDSets, rgPropertyIDSets, &cPropSets, &rgPropSets);
03098
03099       //Now combine both sets...
03100       if(SUCCEEDED(hr) && cPropSets && rgPropSets)
03101       {
03102         //NOTE: We don't want to just combine the properties returned from GetProperties
03103         //to those returned from GetPropertyInfo, since we should only show those properties
03104         //returned from GetProperties not a combination of both.  But we do want the
03105         //flags and descriptions found in the Info so handle that seperatly...
03106
03107         //Dump our cPropSet into PropInfo sets, so we can have one routine to
03108         //dump all properties illregardless of source, and can add the propinfo flags, etc...
03109         TESTC(hr = CombineProperties(&m_cPropInfoSets, &m_rgPropInfoSets, cPropSets, rgPropSets, TRUE/*bFreeAddedPropSet*/));
03110
03111         //Add the Prop Flags and Descriptions from GetPropertyInfo
03112         for(iPropSet=0; iPropSet<m_cPropInfoSets; iPropSet++)
03113         {
03114           DBPROPINFOSET* pPropInfoSet = &m_rgPropInfoSets[iPropSet];
03115           for(iProp=0; iProp<pPropInfoSet->cPropertyInfos; iProp++)
03116           {
03117             DBPROPINFO* pPropInfo = &pPropInfoSet->rgPropertyInfos[iProp];
03118             DBPROPINFO* pFoundProp= FindProperty(pPropInfo->dwPropertyID, pPropInfoSet->guidPropertySet, cPropInfoSets, rgPropInfoSets);
03119             if(pFoundProp)
03120             {
03121               pPropInfo->pwszDescription  = pFoundProp->pwszDescription;
03122               pPropInfo->dwFlags      |=pFoundProp->dwFlags;
03123             }
03124           }
03125         }
03126       }
03127
03128       //Free the previous property info
03129       FreeProperties(&cPropInfoSets, &rgPropInfoSets);
03130       break;
03131     }
03132   };
03133
03134   //Add any defined properties (if requested)
03135   if(IsDlgButtonChecked(IDB_ADDDEFINEDPROPS))
03136   {
03137     if(cPropertyIDSets==0 || (rgPropertyIDSets && rgPropertyIDSets[0].cPropertyIDs==0))
03138     {
03139       //NOTE: We redo this first, by obtaining the static ones first, and then adding the
03140       //properties from above.  This way all defined properties are nicely ordered,
03141       //as opposed to what some providers return for an ordering...
03142       ULONG cPropInfoSets       = m_cPropInfoSets;
03143       DBPROPINFOSET* rgPropInfoSets = m_rgPropInfoSets;
03144       m_cPropInfoSets = 0;
03145       m_rgPropInfoSets = NULL;
03146
03147       //First obtain all the OLE DB Defined Properties for this set.
03148       //NOTE: We ask for FALSE - return allocated arrays instead of static arrays...
03149       TESTC(hr = GetAllocedPropInfo(cPropertyIDSets, rgPropertyIDSets, &m_cPropInfoSets, &m_rgPropInfoSets));
03150
03151       //Combine any properties returned from above
03152       TESTC(hr = CombineProperties(&m_cPropInfoSets, &m_rgPropInfoSets, cPropInfoSets, rgPropInfoSets, TRUE/*bFreeAddedPropSet*/));
03153     }
03154   }
03155
03156   //Now Display all the properties
03157   iItems = 0;
03158   for(iPropSet=0; iPropSet<m_cPropInfoSets; iPropSet++)
03159   {
03160     DBPROPINFOSET* pPropInfoSet = &m_rgPropInfoSets[iPropSet];
03161
03162     //We need to display this PropertySet
03163     WCHAR* pwszName = GetPropSetName(pPropInfoSet->guidPropertySet);
03164     if(pwszName == NULL)
03165     {
03166       StringFromGUID2(pPropInfoSet->guidPropertySet, wszBuffer, MAX_NAME_LEN);
03167       pwszName = wszBuffer;
03168     }
03169     m_listviewProps.InsertItem(iItems, PROP_NAME, pwszName, PARAM_NONE, IMAGE_NORMAL);
03170     m_listviewProps.SetItemState(iItems, 0,  INDEXTOSTATEIMAGEMASK(STATE_NORMAL),  LVIS_STATEIMAGEMASK);
03171     iItems++;
03172
03173     //Now display all properties in the set
03174     for(iProp=0; iProp<pPropInfoSet->cPropertyInfos; iProp++)
03175     {
03176       DBPROPINFO* pPropInfo = &pPropInfoSet->rgPropertyInfos[iProp];
03177
03178       //Try to find this Property in the PropSet
03179       DBPROP* pFoundProp = m_pCPropSets ? m_pCPropSets->FindProperty(pPropInfo->dwPropertyID, pPropInfoSet->guidPropertySet, DB_NULLID) : NULL;
03180
03181       //To make our lives easier we will store the [iPropSet,iProp] index into the
03182       //PropInfoSet or every property into the lParam element of the list view
03183       //This way whatever message were one we have the neccessary propinfo...
03184       LPARAM lParam = MAKELONG(iPropSet,iProp);
03185
03186       //Supply Default Type and Values if there is currently none
03187       if(pFoundProp)
03188       {
03189         pPropInfo->vtType = V_VT(&pFoundProp->vValue);
03190         XTEST(VariantCopyFast(&pPropInfo->vValues, &pFoundProp->vValue));
03191       }
03192
03193       //Delegate to Display this property
03194       TESTC(hr = DisplayProperty(iItems, pFoundProp, pPropInfo, pPropInfoSet->guidPropertySet, lParam));
03195
03196       //Set Item State to Checked/Unchecked
03197       m_listviewProps.SetItemState(iItems, 0,  INDEXTOSTATEIMAGEMASK((pFoundProp && m_pCPropSets) ? STATE_CHECKED : STATE_UNCHECKED),  LVIS_STATEIMAGEMASK);
03198       iItems++;
03199     }
03200
03201     //Now display a space between sets...
03202     m_listviewProps.InsertItem(iItems, 0, L"", PARAM_NONE, IMAGE_NORMAL);
03203     m_listviewProps.SetItemState(iItems, 0,  INDEXTOSTATEIMAGEMASK(STATE_NORMAL),  LVIS_STATEIMAGEMASK);
03204     iItems++;
03205   }
03206
03207 CLEANUP:
03208   return hr;
03209 }
03210
03211
03212 /////////////////////////////////////////////////////////////////////
03213 // CPropertiesDlg::SetProperties
03214 //
03215 /////////////////////////////////////////////////////////////////////
03216 HRESULT CPropertiesDlg::SetProperties(ULONG cPropSets, DBPROPSET* rgPropSets)
03217 {
03218   HRESULT hr = S_OK;
03219
03220   if(m_pIUnkProperties)
03221   {
03222     IID iidProp = m_iidProp;
03223
03224     //Now actually set the Properties
03225     if(iidProp == IID_IDBProperties)
03226     {
03227       XTEST_(hr = ((IDBProperties*)m_pIUnkProperties)->SetProperties(cPropSets, rgPropSets),S_OK);
03228       TRACE_METHOD(hr, L"IDBProperties::SetProperties(%d, 0x%p)", cPropSets, rgPropSets);
03229     }
03230     else if(iidProp == IID_IDBDataSourceAdmin)
03231     {
03232       XTEST_(hr = ((IDBDataSourceAdmin*)m_pIUnkProperties)->ModifyDataSource(cPropSets, rgPropSets),S_OK);
03233       TRACE_METHOD(hr, L"IDBDataSourceAdmin::ModifyDataSource(%d, 0x%p)", cPropSets, rgPropSets);
03234     }
03235     else if(iidProp == IID_ISessionProperties)
03236     {
03237       XTEST_(hr = ((ISessionProperties*)m_pIUnkProperties)->SetProperties(cPropSets, rgPropSets),S_OK);
03238       TRACE_METHOD(hr, L"ISessionProperties::SetProperties(%d, 0x%p)", cPropSets, rgPropSets);
03239     }
03240     else if(iidProp == IID_ICommandProperties)
03241     {
03242       XTEST_(hr = ((ICommandProperties*)m_pIUnkProperties)->SetProperties(cPropSets, rgPropSets),S_OK);
03243       TRACE_METHOD(hr, L"ICommandProperties::SetProperties(%d, 0x%p)", cPropSets, rgPropSets);
03244     }
03245     else
03246     {
03247       ASSERT(!"Unhandled Property Source");
03248     }
03249
03250     //Display Any Property Errors...
03251     hr = DisplayPropErrors(hr, cPropSets, rgPropSets);
03252   }
03253
03254   return hr;
03255 }
03256
03257
03258 /////////////////////////////////////////////////////////////////////
03259 // CPropertiesDlg::GetProperties
03260 //
03261 /////////////////////////////////////////////////////////////////////
03262 HRESULT CPropertiesDlg::GetProperties(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets, ULONG* pcPropSets, DBPROPSET** prgPropSets)
03263 {
03264   HRESULT hr = S_OK;
03265   ASSERT(pcPropSets);
03266   ASSERT(prgPropSets);
03267
03268   if(m_pIUnkProperties)
03269   {
03270     if(m_iidProp == IID_IDBProperties)
03271     {
03272       //IDBProperties::GetProperties
03273       XTEST(hr = ((IDBProperties*)m_pIUnkProperties)->GetProperties(cPropertyIDSets, rgPropertyIDSets, pcPropSets, prgPropSets));
03274       TRACE_METHOD(hr, L"IDBProperties::GetProperties(%d, 0x%p, &%d, &0x%p)", cPropertyIDSets, rgPropertyIDSets, *pcPropSets, *prgPropSets);
03275     }
03276     else if(m_iidProp == IID_ISessionProperties)
03277     {
03278       //ISessionProperties::GetProperties
03279       XTEST(hr = ((ISessionProperties*)m_pIUnkProperties)->GetProperties(cPropertyIDSets, rgPropertyIDSets, pcPropSets, prgPropSets));
03280       TRACE_METHOD(hr, L"ISessionProperties::GetProperties(%d, 0x%p, &%d, &0x%p)", cPropertyIDSets, rgPropertyIDSets, *pcPropSets, *prgPropSets);
03281     }
03282     else if(m_iidProp == IID_ICommandProperties)
03283     {
03284       //ICommandProperties::GetProperties
03285       XTEST(hr = ((ICommandProperties*)m_pIUnkProperties)->GetProperties(cPropertyIDSets, rgPropertyIDSets, pcPropSets, prgPropSets));
03286       TRACE_METHOD(hr, L"ICommandProperties::GetProperties(%d, 0x%p, &%d, &0x%p)", cPropertyIDSets, rgPropertyIDSets, *pcPropSets, *prgPropSets);
03287     }
03288     else if(m_iidProp == IID_IRowsetInfo)
03289     {
03290       //IRowsetInfo::GetProperties
03291       XTEST(hr = ((IRowsetInfo*)m_pIUnkProperties)->GetProperties(cPropertyIDSets, rgPropertyIDSets, pcPropSets, prgPropSets));
03292       TRACE_METHOD(hr, L"IRowsetInfo::GetProperties(%d, 0x%p, &%d, &0x%p)", cPropertyIDSets, rgPropertyIDSets, *pcPropSets, *prgPropSets);
03293     }
03294
03295     //Display Any Property Errors...
03296     hr = DisplayPropErrors(hr, *pcPropSets, *prgPropSets);
03297   }
03298
03299   return hr;
03300 }
03301
03302
03303 /////////////////////////////////////////////////////////////////////
03304 // CPropertiesDlg::GetPropertyInfo
03305 //
03306 /////////////////////////////////////////////////////////////////////
03307 HRESULT CPropertiesDlg::GetPropertyInfo(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets, ULONG* pcPropInfoSets, DBPROPINFOSET** prgPropInfoSets, WCHAR** ppStringBuffer)
03308 {
03309   HRESULT hr = S_OK;
03310   ASSERT(pcPropInfoSets);
03311   ASSERT(prgPropInfoSets);
03312   ASSERT(ppStringBuffer);
03313
03314   if(m_pIDBPropertyInfo || m_pIDBDataSourceAdmin)
03315   {
03316     //Normally GetPropertyInfo supplies all the Property Information,
03317     //But OLE DB does have a couple of other interfaces that supply prop info
03318     if(m_pIDBPropertyInfo)
03319     {
03320       //IDBProperties::GetPropertyInfo
03321       //NOTE: GetPropertyInfo may fail since the provider may not support this PropertySet.
03322       //Just continue since we allow the user to set the OLE DB Defined Properties
03323       XTEST(hr = m_pIDBPropertyInfo->GetPropertyInfo(cPropertyIDSets, rgPropertyIDSets, pcPropInfoSets, prgPropInfoSets, ppStringBuffer));
03324       TRACE_METHOD(hr, L"IDBProperties::GetPropertyInfo(%d, 0x%p, &%d, &0x%p, &0x%p)", cPropertyIDSets, rgPropertyIDSets, *pcPropInfoSets, *prgPropInfoSets, *ppStringBuffer);
03325     }
03326     else
03327     {
03328       //IDBDataSourceAdmin::GetCreationProperties
03329       //NOTE: GetCreationProperties may fail since the provider may not support this PropertySet.
03330       //Just continue since we allow the user to set the OLE DB Defined Properties
03331       XTEST(hr = m_pIDBDataSourceAdmin->GetCreationProperties(cPropertyIDSets, rgPropertyIDSets, pcPropInfoSets, prgPropInfoSets, ppStringBuffer));
03332       TRACE_METHOD(hr, L"IDBDataSourceAdmin::GetCreationProperties(%d, 0x%p, &%d, &0x%p, &0x%p)", cPropertyIDSets, rgPropertyIDSets, *pcPropInfoSets, *prgPropInfoSets, *ppStringBuffer);
03333     }
03334
03335     //Display Any Property Errors...
03336     hr = DisplayPropErrors(hr, *pcPropInfoSets, *prgPropInfoSets);
03337   }
03338
03339   return hr;
03340 }
03341
03342
03343 /////////////////////////////////////////////////////////////////////
03344 // CPropertiesDlg::GetSelPropInfo
03345 //
03346 /////////////////////////////////////////////////////////////////////
03347 DBPROPINFO* CPropertiesDlg::GetSelPropInfo(INDEX iSelRow, DBPROPINFOSET** ppPropInfoSet)
03348 {
03349   if(iSelRow == LVM_ERR)
03350     return NULL;
03351
03352   //Obtain PropInfo element
03353   //This value is stored as the lParam of the ListView row
03354   LPARAM lParam = m_listviewProps.GetItemParam(iSelRow);
03355   if(lParam == LVM_ERR || lParam == PARAM_NONE)
03356     return NULL;
03357
03358   ULONG iPropInfoSet = LOWORD(lParam);
03359   ULONG iPropInfo = HIWORD(lParam);
03360
03361   //Verify results...
03362   if(iPropInfoSet >= m_cPropInfoSets || m_rgPropInfoSets==NULL || iPropInfo >= m_rgPropInfoSets[iPropInfoSet].cPropertyInfos || m_rgPropInfoSets[iPropInfoSet].rgPropertyInfos==NULL)
03363     return NULL;
03364
03365   //Does the user want the Set as well...
03366   if(ppPropInfoSet)
03367     *ppPropInfoSet = &m_rgPropInfoSets[iPropInfoSet];
03368
03369   //Otherwise we have a valid propset and property...
03370   return &m_rgPropInfoSets[iPropInfoSet].rgPropertyInfos[iPropInfo];
03371 }
03372
03373
03374 /////////////////////////////////////////////////////////////////////
03375 // CPropertiesDlg::OnPropOptionsChange
03376 //
03377 /////////////////////////////////////////////////////////////////////
03378 BOOL CPropertiesDlg::OnPropOptionsChange()
03379 {
03380   //Obtain the selected propery
03381   INDEX iSelRow = m_comboOptions.GetItemParam(0);
03382   DBPROPINFO* pPropInfo = GetSelPropInfo(iSelRow);
03383   if(pPropInfo)
03384   {
03385     //Get the new selection
03386     //TODO64: DBPROPFLAGS is not extended for 64bit?
03387     ENABLE_BIT(pPropInfo->dwFlags, DBPROPFLAGS_REQUIRED, m_comboOptions.GetCurSel()==DBPROPOPTIONS_REQUIRED);
03388
03389     //Display the new selection
03390     m_listviewProps.SetItemText(iSelRow, PROP_FLAGS, pPropInfo->dwFlags & DBPROPFLAGS_REQUIRED ? L"REQUIRED" : L"OPTIONAL");
03391
03392     //Automatically check this property, since the user
03393     //changed the Options they probably want to set it...
03394     m_listviewProps.SetItemState(iSelRow, 0,  INDEXTOSTATEIMAGEMASK(STATE_CHECKED),  LVIS_STATEIMAGEMASK);
03395   }
03396
03397   return TRUE;
03398 }
03399
03400
03401 /////////////////////////////////////////////////////////////////////
03402 // CPropertiesDlg::OnPropTypeChange
03403 //
03404 /////////////////////////////////////////////////////////////////////
03405 BOOL CPropertiesDlg::OnPropTypeChange()
03406 {
03407   //Obtain the selected propery
03408   INDEX iSelRow = m_comboOptions.GetItemParam(0);
03409   DBPROPINFO* pPropInfo = GetSelPropInfo(iSelRow);
03410   if(pPropInfo)
03411   {
03412
03413     //Get new selection
03414     INDEX iSel = m_comboType.GetCurSel();
03415     pPropInfo->vtType = (DBTYPE)m_comboType.GetItemParam(iSel);
03416     m_listviewProps.SetItemText(iSelRow, PROP_TYPE, GetVariantTypeName(pPropInfo->vtType));
03417
03418     switch(pPropInfo->vtType)
03419     {
03420       case VT_BOOL:
03421         m_comboValue.SetSelText(L"VARIANT_FALSE", TRUE/*fAddItem*/);
03422         m_comboValue.SetSelText(L"VARIANT_TRUE", TRUE/*fAddItem*/);
03423         break;
03424
03425       case VT_EMPTY:
03426       case VT_NULL:
03427         m_comboValue.ResetContent();
03428         m_comboValue.SetSelText(L"", TRUE/*fAddItem*/);
03429         break;
03430     };
03431
03432     //Send a selection change message to the Value Combo
03433     OnPropValueChange();
03434
03435     //Automatically check this property, since the user
03436     //changed the Type they probably want to set it...
03437     m_listviewProps.SetItemState(iSelRow, 0,  INDEXTOSTATEIMAGEMASK(STATE_CHECKED),  LVIS_STATEIMAGEMASK);
03438   }
03439
03440   return TRUE;
03441 }
03442
03443
03444 /////////////////////////////////////////////////////////////////////
03445 // CPropertiesDlg::OnPropValueChange
03446 //
03447 /////////////////////////////////////////////////////////////////////
03448 BOOL CPropertiesDlg::OnPropValueChange()
03449 {
03450   //Obtain the selected propery
03451   INDEX iSelRow = m_comboOptions.GetItemParam(0);
03452   DBPROPINFO* pPropInfo = GetSelPropInfo(iSelRow);
03453   if(pPropInfo)
03454   {
03455     WCHAR wszBuffer[MAX_NAME_LEN+1] = {0};
03456     WCHAR wszPrevValue[MAX_NAME_LEN+1] = {0};
03457
03458     //Get new selection
03459     m_comboValue.GetSelText(wszBuffer, MAX_NAME_LEN);
03460
03461     //Verify Value
03462     XTEST(VariantClearFast(&pPropInfo->vValues));
03463     if(FAILED(StringToVariant(wszBuffer, (DBTYPE)pPropInfo->vtType, &pPropInfo->vValues)))
03464     {
03465       wMessageBox(GetFocus(), MB_TASKMODAL | MB_ICONERROR | MB_OK | MB_DEFBUTTON1,
03466         wsz_ERROR, L"Unable to create Variant for type=%s, value=\"%s\"", GetVariantTypeName(pPropInfo->vtType), wszBuffer);
03467       m_comboValue.SetFocus();
03468       return TRUE; //Don't Allow the Change
03469     }
03470
03471     //NOTE: We convert again here, in case the user entered
03472     //some "alias" name for the value.  IE: True and we actually allow this
03473     //but display in the view as VARIANT_TRUE...
03474     VariantToString(&pPropInfo->vValues, wszBuffer, MAX_NAME_LEN, CONV_VARBOOL);
03475
03476     //Automatically check this property, since the user
03477     //changed the Value they probably want to set it...
03478     //NOTE: We only do it if the value has changed...
03479     m_listviewProps.GetItemText(iSelRow, PROP_VALUE, wszPrevValue, MAX_NAME_LEN);
03480     if(!StringCompare(wszBuffer, wszPrevValue))
03481     {
03482       m_listviewProps.SetItemState(iSelRow, 0,  INDEXTOSTATEIMAGEMASK(STATE_CHECKED),  LVIS_STATEIMAGEMASK);
03483       m_listviewProps.SetItemText(iSelRow, PROP_VALUE, wszBuffer);
03484     }
03485   }
03486
03487   return TRUE;
03488 }
03489
03490 /////////////////////////////////////////////////////////////////////
03491 // CPropertiesDlg::OnCommandNotify
03492 //
03493 /////////////////////////////////////////////////////////////////////
03494 BOOL CPropertiesDlg::OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl)
03495 {
03496   switch(wNotifyCode)
03497   {
03498     case CBN_SELCHANGE:
03499     {
03500       if(OnSelChange(iID, hWndCtrl))
03501         return TRUE;
03502       break;
03503     }
03504   };
03505
03506   //Otherwise Delegate
03507   return CDialogLite::OnCommandNotify(wNotifyCode, iID, hWndCtrl);
03508 }
03509
03510
03511 /////////////////////////////////////////////////////////////////////////////
03512 // CPropertiesDlg::OnSelChange
03513 //
03514 /////////////////////////////////////////////////////////////////////////////
03515 BOOL CPropertiesDlg::OnSelChange(INT iID, HWND hWndCtrl)
03516 {
03517   switch(iID)
03518   {
03519     case IDC_PROPEDIT_VALUE:
03520       return OnPropValueChange();
03521
03522     case IDC_PROPEDIT_TYPE:
03523       return OnPropTypeChange();
03524
03525     case IDC_PROPEDIT_OPTIONS:
03526       return OnPropOptionsChange();
03527
03528     case IDC_PROPSET:
03529       return OnPropSetChange();
03530   };
03531
03532   return FALSE;
03533 }
03534
03535
03536 /////////////////////////////////////////////////////////////////////
03537 // CPropertiesDlg::OnClearAll
03538 //
03539 /////////////////////////////////////////////////////////////////////
03540 void CPropertiesDlg::OnClearAll()
03541 {
03542   CWaitCursor waitCursor;
03543
03544   //Send a selection change message to the Value Combo
03545   OnPropValueChange();
03546
03547   //Now that the user has selected to clear all properties
03548   //We need to loop through all the checked
03549   //properties and just uncheck them...
03550   INDEX cItems = m_listviewProps.GetItemCount();
03551   for(LONG i=0; i<cItems; i++)
03552   {
03553     //Get the Image and Param
03554     //Only interested in actual items, (not headers or spaces)
03555     LPARAM lParam = m_listviewProps.GetItemParam(i);
03556     if(lParam == PARAM_NONE)
03557       continue;
03558
03559     //Set the state
03560     m_listviewProps.SetItemState(i, 0,  INDEXTOSTATEIMAGEMASK(m_bClearAll ? STATE_UNCHECKED : STATE_CHECKED),  LVIS_STATEIMAGEMASK);
03561   }
03562
03563   //Clear All is a toggle...
03564   if(m_bClearAll)
03565   {
03566     m_bClearAll = FALSE;
03567 		::SetWindowText(GetDlgItem(IDB_CLEARALL), "SelectAll");
03568   }
03569   else
03570   {
03571     m_bClearAll = TRUE;
03572 		::SetWindowText(GetDlgItem(IDB_CLEARALL), "ClearAll");
03573   }
03574 }
03575
03576
03577
03578 /////////////////////////////////////////////////////////////////////
03579 // CPropertiesDlg::OnCommand
03580 //
03581 /////////////////////////////////////////////////////////////////////
03582 BOOL CPropertiesDlg::OnCommand(UINT iID, HWND hWndCtrl)
03583 {
03584   switch(iID)
03585   {
03586     ON_COMMAND(IDB_ADDDEFINEDPROPS,     OnAddDefinedProperties())
03587     ON_COMMAND(IDB_CLEARALL,        OnClearAll())
03588   };
03589
03590   return FALSE;
03591 }
03592
03593 /////////////////////////////////////////////////////////////////////
03594 // CPropertiesDlg::OnNotify
03595 //
03596 /////////////////////////////////////////////////////////////////////
03597 BOOL CPropertiesDlg::OnNotify(INT idCtrl, NMHDR* pNMHDR)
03598 {
03599   NM_LISTVIEW* pListView = (NM_LISTVIEW*)pNMHDR;
03600
03601   //ListView
03602   switch(pListView->hdr.code)
03603   {
03604     case LVN_ITEMCHANGED:
03605     {
03606       //Check boxes
03607       if(pListView->uNewState & LVIS_STATEIMAGEMASK)
03608       {
03609         //Get the Current Param
03610         LPARAM lParam = m_listviewProps.GetItemParam(pListView->iItem);
03611
03612         //All lParam are PARAM_NONE for headers and non properties...
03613         //We don't want to change icons for those...
03614         if(lParam == PARAM_NONE &&
03615           (pListView->uNewState & INDEXTOSTATEIMAGEMASK(STATE_CHECKED) || pListView->uNewState & INDEXTOSTATEIMAGEMASK(STATE_UNCHECKED)))
03616         {
03617           m_listviewProps.SetItemState(pListView->iItem, pListView->iSubItem,  INDEXTOSTATEIMAGEMASK(STATE_NORMAL),  LVIS_STATEIMAGEMASK);
03618           return TRUE;
03619         }
03620       }
03621       return FALSE;
03622     }
03623
03624     case LVN_ITEMACTIVATE:
03625     {
03626       //We only allow changes for SetProperties
03627       if(m_eMethodType != METHOD_SETPROPERTIES)
03628         return FALSE;
03629
03630       //Obtain PropInfo element
03631       INDEX iSelRow = pListView->iItem;
03632       DBPROPINFO* pPropInfo = GetSelPropInfo(iSelRow);
03633       if(pPropInfo)
03634       {
03635         //TODO: Item and sub item appear to be correct.
03636         //Should use inplace editing in the listview, rather than seperate headers...
03637
03638         //Which column was selected?
03639         switch(pListView->iSubItem)
03640         {
03641           case PROP_NAME:
03642           case PROP_DESC:
03643             //These items are not settable...
03644             break;
03645
03646           case PROP_TYPE:
03647           {
03648 /*            //Obtain the rect of the selected item.
03649             RECT rect = { LVIR_BOUNDS, pListView->iSubItem, 0, 0};
03650             SendMessage(m_listviewProps.m_hWnd, LVM_GETSUBITEMRECT, pListView->iItem, (LPARAM)&rect);
03651
03652             //Bring up a ComboBox
03653             //NOTE: The "Height" of the combo indicates the "dropdown" height of the combo...
03654             static CComboBoxLite comboTypes;
03655             comboTypes.Create(m_listviewProps.m_hWnd, L"COMBOBOX", NULL, IDC_TYPE,
03656               CBS_DROPDOWNLIST | CBS_AUTOHSCROLL |
03657                 WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL,
03658               0,
03659               rect.left, rect.top, rect.right-rect.left, (rect.bottom-rect.top)*15);
03660             comboTypes.SetFont(m_pCMainWindow->m_pCMDIObjects->m_pCObjTree->GetFont());
03661
03662             //Fill in the Type Combo
03663             comboTypes.Populate(g_cVariantTypes, g_rgVariantTypes);
03664             comboTypes.OnCreate(NULL);
03665 */            break;
03666           }
03667
03668           case PROP_VALUE:
03669             break;
03670           case PROP_FLAGS:
03671             break;
03672
03673           case PROP_COLID:
03674             //TODO:
03675             break;
03676
03677           default:
03678         //    ASSERT(L"Unhandled Column?");
03679             break;
03680         };
03681       }
03682
03683       return TRUE;
03684     }
03685
03686     case LVN_ITEMCHANGING:
03687     {
03688       //We Selected a "new" item
03689       if(pListView->uNewState & LVNI_FOCUSED &&
03690         pListView->uNewState & LVNI_SELECTED)
03691       {
03692         //Send a selection change message to the Value Combo
03693         if(m_eMethodType == METHOD_SETPROPERTIES)
03694           OnPropValueChange();
03695
03696         //Clear Previous info
03697         m_editDesc.SetWindowText(L"");
03698         m_comboValue.ResetContent();
03699
03700         //Obtain PropInfo element
03701         INDEX iSelRow = pListView->iItem;
03702         DBPROPINFO* pPropInfo = GetSelPropInfo(iSelRow);
03703         if(pPropInfo)
03704         {
03705           //Insert Name (Description)
03706           WCHAR wszBuffer[MAX_NAME_LEN+1] = {0};
03707           m_listviewProps.GetItemText(iSelRow, PROP_DESC, wszBuffer, MAX_NAME_LEN);
03708           m_editDesc.SetWindowText(wszBuffer);
03709
03710           //Set Current Type Selection
03711           m_comboType.SetSelValue(pPropInfo->vtType);
03712
03713           //InsertValue
03714           if(pPropInfo->vtType == DBTYPE_BOOL)
03715           {
03716             m_comboValue.AddString(L"VARIANT_TRUE");
03717             m_comboValue.AddString(L"VARIANT_FALSE");
03718           }
03719
03720           wszBuffer[0] = EOL;
03721           m_listviewProps.GetItemText(iSelRow, PROP_VALUE, wszBuffer, MAX_NAME_LEN);
03722           INDEX iIndex = m_comboValue.SetSelText(wszBuffer, TRUE/*fAddItem*/);
03723
03724           //Now select the item
03725           m_comboValue.SetCurSel(iIndex);
03726
03727           //InsertOptions
03728 //          m_comboOptions.SetItemParam(0, iSelRow);
03729           m_comboOptions.SetSelText(pPropInfo->dwFlags & DBPROPFLAGS_REQUIRED ? L"REQUIRED" : L"OPTIONAL");
03730         }
03731
03732         //Keep track of which row the data belongs to...
03733         m_comboOptions.SetItemParam(0, iSelRow);
03734
03735         //Enable Combos
03736         m_editDesc.EnableWindow(pPropInfo && m_eMethodType == METHOD_SETPROPERTIES);
03737         m_comboType.EnableWindow(pPropInfo && m_eMethodType == METHOD_SETPROPERTIES);
03738         m_comboValue.EnableWindow(pPropInfo && m_eMethodType == METHOD_SETPROPERTIES);
03739         m_comboOptions.EnableWindow(pPropInfo && m_eMethodType == METHOD_SETPROPERTIES);
03740         return FALSE; //Allow the change
03741       }
03742     }
03743   }
03744
03745   return FALSE;
03746 }
03747
03748
03749 ////////////////////////////////////////////////////////////////
03750 // CPropertiesDlg::OnAddDefinedProperties
03751 //
03752 /////////////////////////////////////////////////////////////////
03753 void CPropertiesDlg::OnAddDefinedProperties()
03754 {
03755   OnPropSetChange();
03756 }
03757
03758
03759 ////////////////////////////////////////////////////////////////
03760 // CPropertiesDlg::OnPropSetChange
03761 //
03762 /////////////////////////////////////////////////////////////////
03763 BOOL CPropertiesDlg::OnPropSetChange()
03764 {
03765   CWaitCursor waitCursor;
03766
03767   //Get new selection
03768   INDEX iIndex = m_comboPropSet.GetItemParam(m_comboPropSet.GetCurSel());
03769
03770   GUID guidPropertySet = IID_NULL;
03771   if(iIndex != CB_ERR && iIndex<(INDEX)g_cPropSetMaps)
03772     guidPropertySet = *(g_rgPropSetMaps[iIndex].pGuid);
03773
03774   //Display properties for just this set...
03775   const ULONG cPropertyIDSets = 1;
03776   DBPROPIDSET rgPropertyIDSets[cPropertyIDSets];
03777   rgPropertyIDSets[0].cPropertyIDs = 0;
03778   rgPropertyIDSets[0].rgPropertyIDs = NULL;
03779   rgPropertyIDSets[0].guidPropertySet = guidPropertySet;
03780
03781   //Display the SetProperties (again - this  time all of them)
03782   DisplayProperties(iIndex==CB_ERR ? 0 : cPropertyIDSets, rgPropertyIDSets);
03783
03784   //Disable Combos
03785   m_editDesc.EnableWindow(FALSE);
03786   m_comboOptions.EnableWindow(FALSE);
03787   m_comboType.EnableWindow(FALSE);
03788   m_comboValue.EnableWindow(FALSE);
03789   return TRUE;
03790 }
03791
03792
03793
03794
03795
03796 static const ULONG RES_NAME[MAX_RESTRICTIONS] = { IDT_RESTRICTION1, IDT_RESTRICTION2, IDT_RESTRICTION3, IDT_RESTRICTION4, IDT_RESTRICTION5, IDT_RESTRICTION6, IDT_RESTRICTION7, /*IDT_RESTRICTION8, IDT_RESTRICTION9, IDT_RESTRICTION10, IDT_RESTRICTION11, IDT_RESTRICTION12*/ };
03797 static const ULONG RES_TYPE[MAX_RESTRICTIONS] = { IDC_RESTRICTION1, IDC_RESTRICTION2, IDC_RESTRICTION3, IDC_RESTRICTION4, IDC_RESTRICTION5, IDC_RESTRICTION6, IDC_RESTRICTION7, /*IDC_RESTRICTION8, IDC_RESTRICTION9, IDC_RESTRICTION10, IDC_RESTRICTION11, IDC_RESTRICTION12*/ };
03798 static const ULONG RES_VALUE[MAX_RESTRICTIONS]  = { IDE_RESTRICTION1, IDE_RESTRICTION2, IDE_RESTRICTION3, IDE_RESTRICTION4, IDE_RESTRICTION5, IDE_RESTRICTION6, IDE_RESTRICTION7, /*IDE_RESTRICTION8, IDE_RESTRICTION9, IDE_RESTRICTION10, IDE_RESTRICTION11, IDE_RESTRICTION12*/ };
03799 //////////////////////////////////////////////////////////////////////////////
03800 // GetSchemaName
03801 //
03802 //////////////////////////////////////////////////////////////////////////////
03803 WCHAR* GetSchemaName(REFGUID guidSchema)
03804 {
03805   for(ULONG i=0; i<NUMELE(g_rgSchemaInfo); i++)
03806   {
03807     if(guidSchema == *(g_rgSchemaInfo[i].pguidSchema))
03808       return g_rgSchemaInfo[i].pwszSchemaName;
03809   }
03810
03811   return NULL;
03812 }
03813
03814
03815
03816 ////////////////////////////////////////////////////////////////
03817 // CSchemaDlg::CSchemaDlg
03818 //
03819 /////////////////////////////////////////////////////////////////
03820 CSchemaDlg::CSchemaDlg(CMDIChild* pCMDIChild)
03821   : CRowsetViewerDlg(NULL, pCMDIChild)
03822 {
03823   //Data
03824   m_hWndSchemas = NULL;
03825   m_hWndTreeWnd = NULL;
03826   m_hWndTreeView = NULL;
03827
03828   //Saved Dialog Values
03829   m_fEditing = FALSE;
03830   m_fActive = TRUE;
03831
03832   m_cSchemas = 0;
03833   m_rgSchemas = NULL;
03834   m_rgRestrictionSupport = NULL;
03835
03836   //Rowset - This is for the SchemaTree sheet, it uses its own rowset
03837   //so it doesn't mess up the users rowset, just to display a tree...
03838   m_pCTreeRowset    = NULL;
03839
03840   m_iSchemaIndex    = LVM_ERR;
03841   m_iOldSchemaIndex = LVM_ERR;
03842
03843   m_cRestrictions   = 0;
03844   m_fUseRestrictions  = TRUE;
03845   m_fUseProperties  = TRUE; //Default
03846   m_fShowSupported  = TRUE;
03847
03848   //Only set these "Default" properties, if requested by the user
03849   if(GetOptions()->m_dwRowsetOpts & ROWSET_SETDEFAULTPROPS)
03850   {
03851     //DBPROP_CANHOLDROWS is required by the OLE DB Spec - Level-0 Conformance
03852     //Since it is also legal to set a ReadOnly property, just blindy set it...
03853     m_CPropSets.SetProperty(DBPROP_CANHOLDROWS, DBPROPSET_ROWSET, DBTYPE_BOOL, (void*)VARIANT_TRUE, DBPROPOPTIONS_REQUIRED);
03854   }
03855 }
03856
03857
03858 ////////////////////////////////////////////////////////////////
03859 // CSchemaDlg::~CSchemaDlg
03860 //
03861 /////////////////////////////////////////////////////////////////
03862 CSchemaDlg::~CSchemaDlg()
03863 {
03864   m_hWnd = NULL;
03865   SAFE_RELEASE(m_pCTreeRowset);
03866
03867   SAFE_FREE(m_rgSchemas);
03868   SAFE_FREE(m_rgRestrictionSupport);
03869
03870   //Free Restrictions
03871   FreeData(DBTYPE_VARIANT, m_cRestrictions, m_rgRestrictions);
03872 }
03873
03874
03875
03876 ////////////////////////////////////////////////////////////////
03877 // CSchemaDlg::Display
03878 //
03879 /////////////////////////////////////////////////////////////////
03880 INT_PTR CSchemaDlg::Display()
03881 {
03882   //Now Display the dialog
03883   PROPSHEETPAGE psp[2];
03884   PROPSHEETHEADER psh;
03885
03886   //Header
03887   psh.dwSize      = sizeof(PROPSHEETHEADER);
03888   psh.dwFlags     = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
03889   psh.hwndParent    = m_pCMDIChild->m_hWnd;
03890   psh.hInstance   = GetAppLite()->m_hInstance;
03891   psh.pszIcon     = NULL;
03892   psh.pszCaption    = "IDBSchemaRowset";
03893   psh.nPages      = NUMELE(psp);
03894   psh.nStartPage    = 0;
03895   psh.ppsp      = (LPCPROPSHEETPAGE) &psp;
03896
03897   //Provider
03898   psp[0].dwSize   = sizeof(PROPSHEETPAGE);
03899   psp[0].dwFlags    = PSP_USETITLE;
03900   psp[0].hInstance  = GetAppLite()->m_hInstance;
03901   psp[0].pszTemplate  = MAKEINTRESOURCE(IDD_SCHEMAROWSET);
03902   psp[0].pszIcon    = NULL;
03903   psp[0].pfnDlgProc = SchemaRowsetProc;
03904   psp[0].pszTitle   = "Schemas";
03905   psp[0].lParam   = (LPARAM)this;
03906
03907   //Properties
03908   psp[1].dwSize   = sizeof(PROPSHEETPAGE);
03909   psp[1].dwFlags    = PSP_USETITLE;
03910   psp[1].hInstance  = GetAppLite()->m_hInstance;
03911   psp[1].pszTemplate  = MAKEINTRESOURCE(IDD_SCHEMATREEVIEW);
03912   psp[1].pszIcon    = NULL;
03913   psp[1].pfnDlgProc = SchemaTreeProc;
03914   psp[1].pszTitle   = "TreeView";
03915   psp[1].lParam   = (LPARAM)this;
03916
03917   //Display the Property Sheets
03918   return PropertySheet(&psh);
03919 }
03920
03921
03922 ////////////////////////////////////////////////////////////////
03923 // HRESULT CSchemaDlg::InitSchemas
03924 //
03925 /////////////////////////////////////////////////////////////////
03926 HRESULT CSchemaDlg::InitSchemas(HWND hWnd)
03927 {
03928   HRESULT hr = S_OK;
03929   m_hWndSchemas = hWnd;
03930   INDEX i,iSel = 0;
03931
03932   //Default Check UseRestrictions and UseProperties
03933 	::CheckDlgButton(hWnd, IDB_USEPROPERTIES,    BST2STATE(m_fUseProperties));
03934 	::CheckDlgButton(hWnd, IDB_USERESTRICTIONS,    BST2STATE(m_fUseRestrictions));
03935 	::CheckDlgButton(hWnd, IDB_SHOWSUPPORTED,    BST2STATE(m_fShowSupported));
03936
03937   //Obtain Supported Schemas
03938   CSession* pCSession = (CSession*)m_pCMDIChild->GetObject(eCSession);
03939
03940   //Free any previously obtain schemainfo
03941   SAFE_FREE(m_rgSchemas);
03942   SAFE_FREE(m_rgRestrictionSupport);
03943
03944   //Obtain Supported Schemas
03945   ASSERT(pCSession && pCSession->m_pIDBSchemaRowset);
03946   XTEST(hr = pCSession->m_pIDBSchemaRowset->GetSchemas(&m_cSchemas, &m_rgSchemas, &m_rgRestrictionSupport));
03947   TESTC(TRACE_METHOD(hr, L"IDBSchemaRowset::GetSchemas(&%d, &0x%p, &0x%p)", m_cSchemas, m_rgSchemas, m_rgRestrictionSupport));
03948
03949   //Fill in Schema Combo
03950   m_comboSchema.CreateIndirect(m_hWndSchemas, IDC_SCHEMAS);
03951   InitSchemaCombo(m_fShowSupported);
03952
03953   //Fill in Controls
03954   for(i=0; i<MAX_RESTRICTIONS; i++)
03955   {
03956     //Name
03957     m_rgResName[i].CreateIndirect(m_hWndSchemas, RES_NAME[i]);
03958
03959     //Type
03960     m_rgResType[i].CreateIndirect(m_hWndSchemas, RES_TYPE[i]);
03961     m_rgResType[i].Populate(g_cVariantTypes, g_rgVariantTypes);
03962
03963     //Value
03964     m_rgResValue[i].CreateIndirect(m_hWndSchemas, RES_VALUE[i]);
03965   }
03966
03967   //Try to find DBSCHEMA_TABLES by default (or our saved index)
03968   if(m_iSchemaIndex == LVM_ERR)
03969     m_iSchemaIndex = m_comboSchema.FindStringExact(L"DBSCHEMA_TABLES");
03970   m_iSchemaIndex = m_comboSchema.SetCurSel(m_iSchemaIndex==CB_ERR ? 0 : m_iSchemaIndex);
03971
03972 CLEANUP:
03973   return hr;
03974 }
03975
03976
03977 ////////////////////////////////////////////////////////////////
03978 // HRESULT CSchemaDlg::InitSchemaCombo
03979 //
03980 /////////////////////////////////////////////////////////////////
03981 HRESULT CSchemaDlg::InitSchemaCombo(BOOL fShowSupported)
03982 {
03983   WCHAR wszBuffer[MAX_NAME_LEN+1];
03984   const SCHEMAINFO* pSchemaInfo = NULL;
03985
03986   //Delete all the current items...
03987   m_comboSchema.ResetContent();
03988
03989   //Display the complete list of Schemas (if requested)
03990   if(!fShowSupported)
03991   {
03992     for(ULONG i=0; i<NUMELE(g_rgSchemaInfo); i++)
03993     {
03994       pSchemaInfo = &g_rgSchemaInfo[i];
03995
03996       //Now Add it to the ComboBox dialog...
03997       m_comboSchema.AddString(pSchemaInfo->pwszSchemaName, (LPARAM)pSchemaInfo);
03998     }
03999   }
04000
04001   //Loop over returned Schemas
04002   for(ULONG i=0; i<m_cSchemas; i++)
04003   {
04004     //Find this Schema in our List so we know the "text" name of it...
04005     pSchemaInfo = NULL;
04006     for(ULONG j=0; j<NUMELE(g_rgSchemaInfo); j++)
04007     {
04008       if(m_rgSchemas[i] == *g_rgSchemaInfo[j].pguidSchema)
04009       {
04010         pSchemaInfo = &g_rgSchemaInfo[j];
04011         break;
04012       }
04013     }
04014
04015     //There may be a provider specific SchemaGuid,
04016     //so just display the Guid value and not a name
04017     if(pSchemaInfo == NULL)
04018       StringFromGUID2(m_rgSchemas[i], wszBuffer, MAX_NAME_LEN);
04019
04020     //Now Add it to the ComboBox dialog...
04021     //Only add if were only showing supported, or its not in the known list...
04022     if(fShowSupported || pSchemaInfo==NULL)
04023       m_comboSchema.AddString(pSchemaInfo ? pSchemaInfo->pwszSchemaName : wszBuffer, pSchemaInfo ? (LPARAM)pSchemaInfo : (LPARAM)i);
04024   }
04025
04026   return S_OK;
04027 }
04028
04029
04030 ////////////////////////////////////////////////////////////////
04031 // HRESULT CSchemaDlg::GetSelectedSchema
04032 //
04033 /////////////////////////////////////////////////////////////////
04034 HRESULT CSchemaDlg::GetSelectedSchema(SCHEMAINFO** ppSchemaInfo, ULONG* pdwRestrictions)
04035 {
04036   ASSERT(ppSchemaInfo);
04037   SCHEMAINFO* pSchemaInfo = NULL;
04038
04039   if(pdwRestrictions)
04040     *pdwRestrictions = 0;
04041
04042   //User has selected a different Schema
04043   //We need to update our restriction list...
04044
04045   //Get Selected Schema
04046   m_iSchemaIndex = m_comboSchema.GetCurSel();
04047   if(m_iSchemaIndex != CB_ERR)
04048     pSchemaInfo = (SCHEMAINFO*)m_comboSchema.GetItemParam(m_iSchemaIndex);
04049
04050   //Provider Specific Schemas have the Item Data as the index rather than a pointer
04051   if(pSchemaInfo>=0 && pSchemaInfo<(SCHEMAINFO*)(ULONG_PTR)m_cSchemas)
04052   {
04053     m_iSchemaIndex = (INDEX)pSchemaInfo;
04054     pSchemaInfo = NULL;
04055   }
04056
04057   if(pSchemaInfo)
04058   {
04059     //Need to find the corresponding restrictions...
04060     if(pdwRestrictions)
04061     {
04062       m_iSchemaIndex = CB_ERR;
04063       for(ULONG i=0; i<m_cSchemas; i++)
04064       {
04065         if(*pSchemaInfo->pguidSchema == m_rgSchemas[i])
04066         {
04067           m_iSchemaIndex = i;
04068           *pdwRestrictions = m_rgRestrictionSupport[m_iSchemaIndex];
04069           break;
04070         }
04071       }
04072     }
04073   }
04074   //This is a little more difficult, since there must be a provider
04075   //specific schema, so we need to build up the info...
04076   else
04077   {
04078     //Clear our old SchemaInfo temp storage
04079     memset(&m_SchemaInfo, 0, sizeof(SCHEMAINFO));
04080
04081     if(m_iSchemaIndex>=0 && (ULONG)m_iSchemaIndex<m_cSchemas)
04082     {
04083       //Figure our how many restrictions are supported
04084       //This is required since E_INVALIDARG will be produced if
04085       //cRestrictions > than the number of max restricitons defined for this Guid
04086       for(ULONG i=0; i<MAX_RESTRICTIONS; i++)
04087       {
04088         if(m_rgRestrictionSupport[m_iSchemaIndex] & (0x00000001 << i))
04089           m_SchemaInfo.cRestrictions = i+1;
04090         m_SchemaInfo.rgResInfo[i].iNode = i+1;
04091         m_SchemaInfo.rgResInfo[i].wType = DBTYPE_BSTR;  //Default
04092       }
04093
04094       //dwRestrictions
04095       if(pdwRestrictions)
04096         *pdwRestrictions = m_rgRestrictionSupport[m_iSchemaIndex];
04097
04098       //pGuid
04099       m_SchemaInfo.pguidSchema = &m_rgSchemas[m_iSchemaIndex];
04100     }
04101
04102     //Return a pointer to our class temp SchemaInfo
04103     pSchemaInfo = &m_SchemaInfo;
04104   }
04105
04106   *ppSchemaInfo = pSchemaInfo;
04107   return S_OK;
04108 }
04109
04110
04111
04112 ////////////////////////////////////////////////////////////////
04113 // HRESULT CSchemaDlg::ChangeRestrictions
04114 //
04115 /////////////////////////////////////////////////////////////////
04116 HRESULT CSchemaDlg::ChangeRestrictions()
04117 {
04118   ULONG i=0;
04119   HRESULT hr = S_OK;
04120   SCHEMAINFO* pSchemaInfo = NULL;
04121   DWORD dwRestrictions = 0;
04122
04123   //Get the Selected Schema
04124   TESTC(hr = GetSelectedSchema(&pSchemaInfo, &dwRestrictions));
04125
04126   //Display RESTRICTION Info
04127   for(i=0; i<MAX_RESTRICTIONS; i++)
04128   {
04129     //Display Restriction Name
04130     if(i < pSchemaInfo->cRestrictions)
04131     {
04132       m_rgResName[i].SetWindowText(pSchemaInfo->rgResInfo[i].pwszName ? pSchemaInfo->rgResInfo[i].pwszName : L"Unknown");
04133       m_rgResType[i].SetSelValue(pSchemaInfo->rgResInfo[i].wType);
04134     }
04135     else
04136     {
04137       m_rgResName[i].SetWindowText(L"");
04138       m_rgResType[i].SetSelValue(DBTYPE_BSTR);
04139     }
04140
04141     //Default Value
04142     m_rgResName[i].EnableWindow(dwRestrictions & (0x00000001 << i));
04143     m_rgResValue[i].SetWindowText(L"");
04144   }
04145
04146 CLEANUP:
04147   return hr;
04148 }
04149
04150
04151 ////////////////////////////////////////////////////////////////
04152 // HRESULT CSchemaDlg::GetSelectedRestrictions
04153 //
04154 /////////////////////////////////////////////////////////////////
04155 HRESULT CSchemaDlg::GetSelectedRestrictions()
04156 {
04157   HRESULT hr = S_OK;
04158   SCHEMAINFO* pSchemaInfo = NULL;
04159   WCHAR* pwszValue = NULL;
04160
04161   //Obtain the Currently selected Schema
04162   TESTC(hr = GetSelectedSchema(&pSchemaInfo));
04163
04164   //Properties
04165   m_fUseProperties  = ::IsDlgButtonChecked(m_hWndSchemas, IDB_USEPROPERTIES);
04166   m_fShowSupported  = ::IsDlgButtonChecked(m_hWndSchemas, IDB_SHOWSUPPORTED);
04167
04168   //Free Previous Restrictions
04169   FreeData(DBTYPE_VARIANT, m_cRestrictions, m_rgRestrictions);
04170   m_cRestrictions = 0;
04171
04172   //Obtain Selected Restrictions
04173   m_fUseRestrictions = ::IsDlgButtonChecked(m_hWndSchemas, IDB_USERESTRICTIONS);
04174   if(m_fUseRestrictions)
04175   {
04176     m_cRestrictions = 0;
04177
04178     //Initialize Restrictions
04179     for(ULONG i=0; i<MAX_RESTRICTIONS; i++)
04180       VariantInitFast(&m_rgRestrictions[i]);
04181
04182     //Get the Restriction info
04183     for(i=0; i<MAX_RESTRICTIONS; i++)
04184     {
04185       DBTYPE wType = (DBTYPE)m_rgResType[i].GetItemParam(m_rgResType[i].GetCurSel());
04186
04187       //If Not VT_EMPTY we need to setup the restriction Variant
04188       if(wType != VT_EMPTY)
04189       {
04190         //If user specified, or a "special" selection in the drop down
04191         //NOTE: Since all the types are defaulted to the actual type of the restriction
04192         //to make it easier for consumers to not have to remember the correct type.
04193         //We have to come up with a different way for the user to indicate to use this
04194         //resctriction.  Currently if the edit box is left blank, we assume the user
04195         //is not interesed in the restriction and its not bound.  If the user truely
04196         //wants NULL or Empty String, those options are available in the combo drop down...
04197
04198         pwszValue = m_rgResValue[i].GetSelText();
04199         if(pwszValue || m_rgResValue[i].GetCurSel()!=CB_ERR)
04200         {
04201           XTESTC(hr = StringToVariant(pwszValue, wType, &m_rgRestrictions[i]));
04202
04203           //Record we are using this restrictions
04204           m_cRestrictions = i+1;
04205           SAFE_FREE(pwszValue);
04206         }
04207       }
04208     }
04209   }
04210
04211 CLEANUP:
04212   SAFE_FREE(pwszValue);
04213   return hr;
04214 }
04215
04216
04217 ////////////////////////////////////////////////////////////////
04218 // CSchemaDlg::SchemaRowsetProc
04219 //
04220 /////////////////////////////////////////////////////////////////
04221 INT_PTR WINAPI CSchemaDlg::SchemaRowsetProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04222 {
04223   static PROPSHEETPAGE* ps = NULL;
04224   static BOOL fAggregation  = FALSE;    //Default
04225   static BOOL fOutput     = TRUE;     //Default
04226
04227   switch(message)
04228   {
04229     case WM_INITDIALOG:
04230     {
04231       //Save the "this" pointer
04232       CWaitCursor waitCursor;
04233       ps = (PROPSHEETPAGE*)lParam;
04234       CSchemaDlg* pThis = (CSchemaDlg*)SetThis(hWnd, (void*)ps->lParam);
04235
04236       //Aggregation
04237 			::CheckDlgButton(hWnd, IDB_AGGREGATION,    BST2STATE(fAggregation));
04238
04239       //Output (ppIUnknown)
04240 			::CheckDlgButton(hWnd, IDB_OUTPUT,     BST2STATE(fOutput));
04241
04242       //Schemas
04243       pThis->InitSchemas(hWnd);
04244       pThis->ChangeRestrictions();
04245       return TRUE;
04246     }
04247
04248     case WM_COMMAND:
04249     {
04250       //CBN_SELCHANGE ListBox Selection change
04251       switch(GET_WM_COMMAND_CMD(wParam, lParam))
04252       {
04253         //Selection change in a list box occurred
04254         case CBN_SELCHANGE:
04255         {
04256           //See which combo box has changed
04257           switch(GET_WM_COMMAND_ID(wParam, lParam))
04258           {
04259             case IDC_SCHEMAS:
04260             {
04261               //Get the "this" pointer
04262               CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04263
04264               //Get Selected Schema
04265               pThis->ChangeRestrictions();
04266               return 0;
04267             }
04268           }
04269           break;
04270         }
04271
04272         //Selection change in a list box occurred
04273         case CBN_DROPDOWN:
04274         {
04275           //See which combo box has changed
04276           switch(GET_WM_COMMAND_ID(wParam, lParam))
04277           {
04278             case IDC_SCHEMAS:
04279             {
04280               //Get the "this" pointer
04281               CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04282
04283               //Update button state
04284               BOOL fShowSupported = ::IsDlgButtonChecked(hWnd, IDB_SHOWSUPPORTED);
04285
04286               //Get Selected Schema
04287               //Only need to do this if (ShowSupported) has changed...
04288               if(fShowSupported != pThis->m_fShowSupported)
04289               {
04290                 pThis->m_fShowSupported = fShowSupported;
04291                 pThis->InitSchemaCombo(fShowSupported);
04292               }
04293               return 0;
04294             }
04295           }
04296           break;
04297         }
04298
04299         return FALSE;
04300       }
04301
04302       switch (GET_WM_COMMAND_ID(wParam, lParam))
04303       {
04304         case IDB_SETPROPERTIES:
04305         {
04306           //Get the "this" pointer
04307           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04308           CMDIChild* pCMDIChild = pThis->m_pCMDIChild;
04309           CMainWindow* pCMainWindow = pCMDIChild->m_pCMainWindow;
04310
04311           CSession* pCSession     = (CSession*)pCMDIChild->GetObject(eCSession);
04312           CDataSource* pCDataSource = SOURCE_GETPARENT(pCSession, CDataSource);
04313
04314           //SetProperties
04315           CPropertiesDlg sCPropertiesDlg(pCMainWindow);
04316           sCPropertiesDlg.SetProperties(hWnd, &DBPROPSET_ROWSETALL, IID_IRowsetInfo, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &pThis->m_CPropSets);
04317           return 0;
04318         }
04319       }
04320       break;
04321
04322     }//WM_COMMAND
04323
04324     case WM_NOTIFY:
04325     {
04326       switch (((NMHDR*)lParam)->code)
04327         {
04328         case PSN_SETACTIVE:
04329         {
04330           //Get the "this" pointer
04331           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04332           pThis->m_fActive = TRUE;
04333           return 0;
04334         }
04335
04336         case PSN_KILLACTIVE://Switch
04337         {
04338           //Get the "this" pointer
04339           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04340           if(FAILED(pThis->GetSelectedRestrictions()))
04341           {
04342             SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
04343             return TRUE;
04344           }
04345           return 0;
04346         }
04347
04348         case PSN_APPLY:
04349         {
04350           CWaitCursor waitCursor;
04351
04352           //Get the "this" pointer
04353           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04354           CMDIChild* pCMDIChild = pThis->m_pCMDIChild;
04355
04356           CSession* pCSession     = (CSession*)pCMDIChild->GetObject(eCSession);
04357           CAggregate* pCAggregate   = NULL;
04358           CComPtr<IUnknown> spUnknown;
04359           HRESULT hr = S_OK;
04360
04361           if(pThis->m_fEditing)
04362           {
04363             //There is a bug in the TreeView control for editing here is KB article
04364             //Article ID: Q130691 BUG: ESC/ENTER Keys Don't Work When Editing Labels in TreeView
04365             //So one way to work around this is to just have a flag (m_fEditing)
04366             //to indicate we were in editing mode.
04367             SendMessage(pThis->m_hWndTreeView, TVM_ENDEDITLABELNOW, (WPARAM) (wParam==IDCANCEL ? TRUE : FALSE), (LPARAM)0);
04368             SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
04369             return TRUE;
04370           }
04371
04372           if(pThis->m_fActive)
04373           {
04374             //Setup Properties
04375             ULONG cPropSets = 0;
04376             DBPROPSET* rgPropSets = NULL;
04377
04378             if(pThis->m_fUseProperties)
04379             {
04380               cPropSets = pThis->m_CPropSets.GetCount();
04381               rgPropSets = pThis->m_CPropSets.GetPropSets();
04382             }
04383
04384             //Obtain the Aggregation argument
04385             fAggregation = ::IsDlgButtonChecked(hWnd, IDB_AGGREGATION);
04386             if(fAggregation)
04387               pCAggregate = new CAggregate();
04388
04389             //Obtain the Output (ppIUnknown) argument
04390             fOutput = ::IsDlgButtonChecked(hWnd, IDB_OUTPUT);
04391
04392             //Get the selected Schema...
04393             SCHEMAINFO* pSchemaInfo = NULL;
04394             TESTC(hr = pThis->GetSelectedSchema(&pSchemaInfo));
04395
04396             //Create the Schema Rowset
04397             TESTC(hr = pCSession->GetSchemaRowset(pCAggregate, *pSchemaInfo->pguidSchema, pThis->m_cRestrictions, pThis->m_rgRestrictions, IID_IUnknown, cPropSets, rgPropSets, fOutput ? &spUnknown : NULL));
04398
04399             //Process the Rowset
04400             TESTC(hr = pCMDIChild->HandleRowset(pCSession, spUnknown, IID_IUnknown, CREATE_NEWWINDOW_IFEXISTS, *pSchemaInfo->pguidSchema, NULL, TRUE/*bSchemaRowset*/));
04401           }
04402
04403         CLEANUP:
04404           SAFE_RELEASE(pCAggregate);
04405           if(FAILED(hr))
04406           {
04407             SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
04408             return TRUE;
04409           }
04410           return 0;
04411         }
04412
04413         case PSN_RESET:   //CANCEL
04414           return 0;
04415
04416       }
04417       }//WM_NOTIFY
04418
04419   }//switch(message);
04420
04421   return FALSE;
04422 }
04423
04424
04425 ////////////////////////////////////////////////////////////////
04426 // HRESULT CSchemaDlg::InitTreeView
04427 //
04428 /////////////////////////////////////////////////////////////////
04429 HRESULT CSchemaDlg::InitTreeView(HWND hWnd)
04430 {
04431   HRESULT hr = S_OK;
04432   m_hWndTreeWnd = hWnd;
04433
04434   //Saved Defaults
04435   m_fEditing = FALSE;
04436   m_iOldSchemaIndex = LVM_ERR;
04437   m_hWndTreeView = ::GetDlgItem(hWnd, IDC_TREEVIEW);
04438
04439   //Set image list to the Table Window
04440   HIMAGELIST hTableImageList = ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR);
04441   TreeView_SetImageList(m_hWndTreeView, hTableImageList, TVSIL_NORMAL);
04442   return hr;
04443 }
04444
04445
04446 ////////////////////////////////////////////////////////////////
04447 // CSchemaDlg::SchemaTreeProc
04448 //
04449 /////////////////////////////////////////////////////////////////
04450 INT_PTR WINAPI CSchemaDlg::SchemaTreeProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
04451 {
04452   static PROPSHEETPAGE* ps = NULL;
04453
04454   switch(message)
04455   {
04456     case WM_INITDIALOG:
04457     {
04458       CWaitCursor waitCursor;
04459
04460       //Save the "this" pointer
04461       ps = (PROPSHEETPAGE*)lParam;
04462       CSchemaDlg* pThis = (CSchemaDlg*)SetThis(hWnd, (void*)ps->lParam);
04463
04464       //Initialize the TreeView Page
04465       pThis->InitTreeView(hWnd);
04466       return TRUE;
04467     }
04468
04469
04470     case WM_COMMAND:
04471     {
04472       //Filter out any Control Notification codes
04473       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
04474       {
04475         return UNHANDLED_MSG;
04476       }
04477
04478       //Regular command messages
04479       switch(GET_WM_COMMAND_ID(wParam, lParam))
04480       {
04481         case IDM_OPENROWSET:
04482         {
04483           //Get the "this" pointer
04484           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04485
04486           //Send a IDM_COPYTEXT to copy the text to the edit box
04487           SendMessage(hWnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_COPYTEXT, hWnd, 0));
04488
04489           //Delete to our OpenRowset dialog box...
04490           pThis->m_pCMDIChild->m_pCSource = pThis->m_pCMDIChild->GetObject(eCSession);
04491           pThis->m_pCMDIChild->m_idSource = IDM_OPENROWSET;
04492           DisplayDialog(IDD_OPENROWSET, hWnd, pThis->m_pCMDIChild->OpenRowsetProc, (LPARAM)pThis->m_pCMDIChild);
04493           return 0;
04494         }
04495
04496         case IDM_COPYTEXT:
04497         {
04498           //Get the "this" pointer
04499           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04500           WCHAR wszBuffer[MAX_NAME_LEN+1];
04501
04502           //Get the Selected Item
04503           HTREEITEM hItem = (HTREEITEM)SendMessage(pThis->m_hWndTreeView, TVM_GETNEXTITEM, (WPARAM)TVGN_CARET, (LPARAM)TVI_ROOT);
04504
04505           if(TV_GetItemText(pThis->m_hWndTreeView, hItem, wszBuffer, MAX_NAME_LEN))
04506           {
04507             //Now just need to place this name in the EditBox
04508             //Inserted after the current "caret"
04509             pThis->m_pCMDIChild->m_pCQueryBox->ReplaceAll(wszBuffer, FALSE/*bReplaceAll*/, TRUE/*fHighlight*/);
04510           }
04511           return 0;
04512         }
04513
04514         case IDB_DISPLAYTREE:
04515         {
04516           //Get the "this" pointer
04517           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04518
04519           //Make sure we do a regeneration of the tree
04520           pThis->DisplayTree();
04521           return 0;
04522         }
04523       }
04524
04525       return FALSE;
04526     }
04527
04528     // Update status bar to reflect menu selection
04529     case WM_MENUSELECT:
04530     {
04531       //Get the "this" pointer
04532       CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04533       pThis->m_pCMDIChild->m_pCMainWindow->OnMenuSelect(LOWORD(wParam));
04534       return 0;
04535     }
04536
04537     case WM_CONTEXTMENU:
04538     {
04539       CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04540
04541       //Only display the Context menu, if there is a selected item
04542       HTREEITEM hItem = (HTREEITEM)SendMessage(pThis->m_hWndTreeView, TVM_GETNEXTITEM, (WPARAM)TVGN_CARET, (LPARAM)TVI_ROOT);
04543
04544       if(hItem)
04545       {
04546         DisplayContextMenu(
04547                 hWnd,
04548                 IDM_TREESCHEMA,
04549                 MAKEPOINTS(lParam),
04550                 hWnd
04551                 );
04552       }
04553       return FALSE;
04554     }
04555
04556     case WM_NOTIFY:
04557     {
04558       switch (((NMHDR*)lParam)->code)
04559         {
04560         case TVN_BEGINLABELEDIT:
04561         {
04562           //Get the "this" pointer
04563           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04564
04565           //Idicate we have started to edit
04566           pThis->m_fEditing = TRUE;
04567           return FALSE; //Allow the edited change
04568         }
04569
04570         case TVN_ENDLABELEDIT:
04571         {
04572           //Get the "this" pointer
04573           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04574           pThis->m_fEditing = FALSE;
04575           return TRUE; //Allow the edited change
04576         }
04577
04578         case TVN_SELCHANGED:
04579         {
04580           //There is a problem with the SELCHANGED notification
04581           //It can be sent when either a item is selected or
04582           //DELETED, since when an item deleted the selection moves
04583           //to a different selection.
04584           NM_TREEVIEW* pTreeView = (NM_TREEVIEW*)lParam;
04585           if(pTreeView->itemNew.state & TVIS_SELECTED && pTreeView->action)
04586           {
04587             //Get the "this" pointer
04588             CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04589             pThis->RefreshTreeControls();
04590           }
04591           return 0;
04592         }
04593
04594         case TTN_GETDISPINFO:
04595         {
04596           //Get the "this" pointer
04597           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04598           return 0;
04599         }
04600
04601         case PSN_SETACTIVE:
04602         {
04603           //Get the "this" pointer
04604           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04605
04606           //Need to display the specified SchemaRowset
04607           pThis->RefreshTreeControls();
04608           pThis->m_fActive = FALSE;
04609           return 0;
04610         }
04611
04612         case PSN_KILLACTIVE://Switch
04613           return 0;
04614
04615         case PSN_APPLY:
04616         {
04617           CWaitCursor waitCursor;
04618
04619           //Get the "this" pointer
04620           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04621           if(pThis->m_fEditing)
04622           {
04623             //There is a bug in the TreeView control for editing here is KB article
04624             //Article ID: Q130691 BUG: ESC/ENTER Keys Don't Work When Editing Labels in TreeView
04625             //So one way to work around this is to just have a flag (m_fEditing)
04626             //to indicate we were in editing mode.
04627             SendMessage(pThis->m_hWndTreeView, TVM_ENDEDITLABELNOW, (WPARAM) (wParam==IDCANCEL ? TRUE : FALSE), (LPARAM)0);
04628             SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
04629             return TRUE;
04630           }
04631
04632           SAFE_RELEASE(pThis->m_pCTreeRowset);
04633           return 0;
04634         }
04635
04636         case PSN_RESET:   //CANCEL
04637         {
04638           //Get the "this" pointer
04639           CSchemaDlg* pThis = (CSchemaDlg*)GetThis(hWnd);
04640           SAFE_RELEASE(pThis->m_pCTreeRowset);
04641           return 0;
04642         }
04643
04644       }
04645       }//WM_NOTIFY
04646
04647   }//switch(message);
04648
04649   return FALSE;
04650 }
04651
04652
04653 ////////////////////////////////////////////////////////////////
04654 // HRESULT CSchemaDlg::RefreshTreeControls
04655 //
04656 /////////////////////////////////////////////////////////////////
04657 HRESULT CSchemaDlg::RefreshTreeControls()
04658 {
04659   HWND hWndColName = ::GetDlgItem(m_hWndTreeWnd, IDT_COLUMNNAME);
04660
04661   if(m_iSchemaIndex != m_iOldSchemaIndex)
04662   {
04663 		::EnableWindow(m_hWndTreeView, FALSE);
04664 		::EnableWindow(hWndColName, FALSE);
04665 		::EnableWindow(::GetDlgItem(m_hWndTreeWnd, IDM_COPYTEXT), FALSE);
04666 		::EnableWindow(::GetDlgItem(m_hWndTreeWnd, IDM_OPENROWSET), FALSE);
04667   }
04668   else
04669   {
04670 		::EnableWindow(m_hWndTreeView, TRUE);
04671 		::EnableWindow(hWndColName, TRUE);
04672
04673     //Get the Selected TreeItem
04674     HTREEITEM hItem = (HTREEITEM)SendMessage(m_hWndTreeView, TVM_GETNEXTITEM, (WPARAM)TVGN_CARET, (LPARAM)TVI_ROOT);
04675
04676     //Update the ColName header...
04677     ASSERT(m_pCTreeRowset);
04678
04679     DBORDINAL iOrdinal = TV_GetItemParam(m_hWndTreeView, hItem);
04680     if(hItem && iOrdinal != LVM_ERR && iOrdinal<m_pCTreeRowset->m_ColumnInfo.GetCount())
04681     {
04682       wSendMessage(hWndColName, WM_SETTEXT, 0, GetColName(m_pCTreeRowset->m_ColumnInfo.GetOrdinal(iOrdinal)));
04683 			::EnableWindow(::GetDlgItem(m_hWndTreeWnd, IDM_COPYTEXT), TRUE);
04684 			::EnableWindow(::GetDlgItem(m_hWndTreeWnd, IDM_OPENROWSET), TRUE);
04685     }
04686     else
04687     {
04688       SendMessage(hWndColName, WM_SETTEXT, 0, (LPARAM)"");
04689 			::EnableWindow(::GetDlgItem(m_hWndTreeWnd, IDM_COPYTEXT), FALSE);
04690 			::EnableWindow(::GetDlgItem(m_hWndTreeWnd, IDM_OPENROWSET), FALSE);
04691     }
04692   }
04693
04694   return S_OK;
04695 }
04696
04697
04698 ////////////////////////////////////////////////////////////////
04699 // CSchemaDlg::DisplayTree
04700 //
04701 /////////////////////////////////////////////////////////////////
04702 HRESULT CSchemaDlg::DisplayTree()
04703 {
04704   CWaitCursor waitCursor;
04705   HRESULT hr = E_FAIL;
04706   WCHAR wszBuffer[MAX_COL_SIZE];
04707
04708   DBCOUNTITEM iCol,cRowsObtained = 0;
04709   HROW  rghRows[MAX_BLOCK_SIZE];
04710   HROW*  phRow = rghRows;
04711
04712   DBORDINAL cColOrds = 0;
04713   DBORDINAL* rgColOrds = NULL;
04714
04715   DBORDINAL iOrdinal, iColumn;
04716   HTREEITEM hFoundItem, hParent;
04717
04718   //Setup Properties
04719   ULONG cPropSets = 0;
04720   DBPROPSET* rgPropSets = NULL;
04721   SCHEMAINFO* pSchemaInfo = NULL;
04722   CComPtr<IRowset> spRowset;
04723   CSession* pCSession = (CSession*)m_pCMDIChild->GetObject(eCSession);
04724
04725   if(m_fUseProperties)
04726   {
04727     cPropSets = m_CPropSets.GetCount();
04728     rgPropSets = m_CPropSets.GetPropSets();
04729   }
04730
04731   //Get the Selected Schema
04732   TESTC(hr = GetSelectedSchema(&pSchemaInfo));
04733
04734   //Create the SchemaRowset
04735   TESTC(hr = pCSession->GetSchemaRowset(NULL, *pSchemaInfo->pguidSchema, m_cRestrictions, m_rgRestrictions, IID_IRowset, cPropSets, rgPropSets, (IUnknown**)&spRowset));
04736
04737   //(either from Command, IOpenRowset, or Schema's
04738   if(m_pCTreeRowset == NULL)
04739     m_pCTreeRowset = new CRowset(NULL, m_pCMDIChild);
04740   TESTC(hr = m_pCTreeRowset->CreateObject(pCSession, IID_IRowset, spRowset));
04741
04742   //Record that the source is a SchemaRowset...
04743   if(pSchemaInfo->pguidSchema)
04744   {
04745     m_pCTreeRowset->m_guidSource  = *pSchemaInfo->pguidSchema;
04746     m_pCTreeRowset->m_bSchemaRowset = TRUE;
04747   }
04748
04749   //Clear TreeView object
04750   SendMessage(m_hWndTreeView, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);
04751
04752   //Create ColumnInfo
04753   TESTC(hr = m_pCTreeRowset->GetColInfo());
04754
04755   ///Create Accessors and Setup bindings, (don't bind bookmark)
04756   TESTC(hr = m_pCTreeRowset->CreateAccessors(BIND_ALLCOLSEXPECTBOOKMARK));
04757
04758   //All columns that are restrictions are done first, this creates the tree
04759   //nodes.  Then all remaining columns are just elements under the last node.
04760   //We need to setup this array of ordinals to use to indicate the ordering...
04761   SAFE_ALLOC(rgColOrds, DBORDINAL, m_pCTreeRowset->m_ColumnInfo.GetCount());
04762
04763   //Add all restriction columns first
04764   cColOrds = pSchemaInfo->cRestrictions;
04765   for(iCol=0; iCol<cColOrds; iCol++)
04766   {
04767     ASSERT(pSchemaInfo->rgResInfo[iCol].iNode < m_pCTreeRowset->m_ColumnInfo.GetCount());
04768     rgColOrds[iCol] = pSchemaInfo->rgResInfo[iCol].iNode;
04769   }
04770
04771   //Add all remaining columns, (that are not already in the list...)
04772   iColumn = cColOrds;
04773   for(iCol=0; iCol<m_pCTreeRowset->m_Bindings.GetCount(); iCol++)
04774   {
04775     BOOL bFound = FALSE;
04776     iOrdinal = m_pCTreeRowset->m_Bindings[iCol].iOrdinal;
04777     for(DBCOUNTITEM j=0; j<cColOrds && !bFound; j++)
04778     {
04779       if(iOrdinal == rgColOrds[j])
04780         bFound = TRUE;
04781     }
04782
04783     //Add it to the list, if it doesn't already exist...
04784     if(!bFound)
04785     {
04786       rgColOrds[iColumn] = iOrdinal;
04787       iColumn++;
04788     }
04789   }
04790
04791   //Grab all the rows
04792   while(TRUE)
04793   {
04794     //Obtain the rows in blocks...
04795     //NOTE: We are using a "static" array passed in for GetNextRows.  This is a major performance
04796     //gain that is allowed by the spec, so the provider doesn't have to allocate the array
04797     //or guess how large, and since we are reusing it it in a loop it has signicant gains...
04798     TESTC(hr = m_pCTreeRowset->GetNextRows(0, MAX_BLOCK_SIZE, &cRowsObtained, &phRow));
04799
04800     //NOTE: We cant just use (HROW**)&rghRows, since the compiler always "assumes" &array = array!
04801     //Which is not what we want, you actually have to use a temp for the currect address.  This
04802     //assert is to make sure the provider doesn't allocate an array when the user is
04803     //passing in a user allocated array for performance...
04804     ASSERT(phRow == rghRows);
04805
04806     //ENDOFROWSET
04807     if(cRowsObtained==0)
04808       break;
04809
04810     //Loop through all rows obtained...
04811     for(ULONG iRow=0; iRow<cRowsObtained; iRow++)
04812     {
04813       //Get the Data
04814       TESTC(hr = m_pCTreeRowset->GetData(rghRows[iRow]));
04815
04816       //Loop through all the restrictions first
04817       //We will create nodes based upon the sort order of the restrictions.
04818       //Any column that is not in the sort oder will just be an item under a node
04819       hParent = NULL;
04820       for(ULONG i=0; i<cColOrds; i++)
04821       {
04822         //Get the Data for this Column
04823         const DBBINDING* pBinding = m_pCTreeRowset->m_Bindings.GetOrdinal(rgColOrds[i]);
04824         const DBCOLUMNINFO* pColInfo = m_pCTreeRowset->m_ColumnInfo.GetOrdinal(rgColOrds[i]);
04825         m_pCTreeRowset->GetColumnData(pBinding, m_pCTreeRowset->m_pData, NULL, NULL, NULL, wszBuffer, MAX_COL_SIZE, GetOptions()->m_dwConvFlags | CONV_TYPENAME, pColInfo->wType);
04826
04827         //Insert it into the TreeView
04828         if(wszBuffer[0])
04829         {
04830           //Make sure it doesn't already exist...
04831           hFoundItem = TV_FindItem(m_hWndTreeView, hParent, wszBuffer);
04832           if(hFoundItem)
04833           {
04834             hParent = hFoundItem;
04835           }
04836           else
04837           {
04838             //Insert the Item (using node Icon - 0)
04839             hParent = TV_InsertItem(m_hWndTreeView, hParent, TVI_LAST, wszBuffer, rgColOrds[i], IMAGE_FORM, IMAGE_FORM);
04840           }
04841         }
04842       }
04843
04844       //Now go through the regular non-node items and just
04845       //add the the latest parent
04846       for(iCol=cColOrds; iCol<m_pCTreeRowset->m_Bindings.GetCount(); iCol++)
04847       {
04848         const DBBINDING* pBinding = m_pCTreeRowset->m_Bindings.GetOrdinal(rgColOrds[iCol]);
04849         const DBCOLUMNINFO* pColInfo = m_pCTreeRowset->m_ColumnInfo.GetOrdinal(rgColOrds[iCol]);
04850
04851         //Get the Data for this Column
04852         m_pCTreeRowset->GetColumnData(pBinding, m_pCTreeRowset->m_pData, NULL, NULL, NULL, wszBuffer, MAX_COL_SIZE, GetOptions()->m_dwConvFlags | CONV_TYPENAME, pColInfo->wType);
04853
04854         //Insert it into the TreeView
04855         if(wszBuffer[0])
04856         {
04857           //Display the Item (using item icon - 1)
04858           TV_InsertItem(m_hWndTreeView, hParent, TVI_LAST, wszBuffer, rgColOrds[iCol], IMAGE_NORMAL, IMAGE_NORMAL);
04859         }
04860       }
04861
04862       //Free the out-of-line data
04863       m_pCTreeRowset->m_Bindings.FreeData(m_pCTreeRowset->m_pData);
04864     }
04865
04866     //Release the rows obtained
04867     TESTC(hr = m_pCTreeRowset->ReleaseRows(cRowsObtained, rghRows));
04868   }
04869
04870   //We now have displayed this tree
04871   m_iOldSchemaIndex = m_iSchemaIndex;
04872
04873 CLEANUP:
04874   SAFE_FREE(rgColOrds);
04875   RefreshTreeControls();
04876   return hr;
04877 }
04878
04879
04880
04881
04882 /////////////////////////////////////////////////////////////////////////////
04883 // CComboBoxGuid
04884 //
04885 /////////////////////////////////////////////////////////////////////////////
04886 CComboBoxGuid::CComboBoxGuid()
04887 {
04888   m_cGuidMaps   = 0;
04889   m_rgGuidMaps  = NULL;
04890 }
04891
04892
04893 /////////////////////////////////////////////////////////////////////////////
04894 // ~CComboBoxGuid
04895 //
04896 /////////////////////////////////////////////////////////////////////////////
04897 CComboBoxGuid::~CComboBoxGuid()
04898 {
04899 }
04900
04901
04902 /////////////////////////////////////////////////////////////////////////////
04903 // CComboBoxGuid::Populate
04904 //
04905 /////////////////////////////////////////////////////////////////////////////
04906 BOOL CComboBoxGuid::Populate(ULONG cGuidMaps, const WIDEGUIDMAP* rgGuidMaps)
04907 {
04908   m_cGuidMaps   = cGuidMaps;
04909   m_rgGuidMaps  = rgGuidMaps;
04910
04911   //Remove any existing Data
04912   ResetContent();
04913
04914   //Fill in the Combo Box...
04915   for(ULONG i=0; i<cGuidMaps; i++)
04916   {
04917     AddString(rgGuidMaps[i].pwszName, (ULONG_PTR)&rgGuidMaps[i]);
04918   }
04919
04920   //Restore the Default Selection...
04921   RestoreSelection();
04922   return TRUE;
04923 }
04924
04925
04926 /////////////////////////////////////////////////////////////////////////////
04927 // CComboBoxGuid::SetGuid
04928 //
04929 /////////////////////////////////////////////////////////////////////////////
04930 INDEX CComboBoxGuid::SetGuid(REFIID riid)
04931 {
04932   //Find the specified guid...
04933   for(ULONG i=0; i<m_cGuidMaps; i++)
04934   {
04935     WIDEGUIDMAP* pGuidMap = (WIDEGUIDMAP*)GetItemParam(i);
04936
04937     //Is this a match
04938     if(pGuidMap && *pGuidMap->pGuid == riid)
04939     {
04940       return SetCurSel(i);
04941     }
04942   }
04943
04944   return CB_ERR;
04945 }
04946
04947
04948 /////////////////////////////////////////////////////////////////////////////
04949 // REFIID CComboBoxGuid::GetGuid
04950 //
04951 /////////////////////////////////////////////////////////////////////////////
04952 REFIID CComboBoxGuid::GetGuid()
04953 {
04954   INDEX iSel = GetCurSel();
04955   WIDEGUIDMAP* pGuidMap = (WIDEGUIDMAP*)GetItemParam(iSel);
04956
04957   if(iSel != CB_ERR && pGuidMap)
04958   {
04959     SaveSelection();
04960     return *pGuidMap->pGuid;
04961   }
04962
04963   return GUID_NULL;
04964 }
04965
04966
04967
04968
04969
04970 /////////////////////////////////////////////////////////////////////////////
04971 // CComboBoxString
04972 //
04973 /////////////////////////////////////////////////////////////////////////////
04974 CComboBoxString::CComboBoxString()
04975 {
04976 }
04977
04978
04979 /////////////////////////////////////////////////////////////////////////////
04980 // ~CComboBoxString
04981 //
04982 /////////////////////////////////////////////////////////////////////////////
04983 CComboBoxString::~CComboBoxString()
04984 {
04985 }
04986
04987
04988 /////////////////////////////////////////////////////////////////////////////
04989 // CComboBoxString::OnInitialUpdate
04990 //
04991 /////////////////////////////////////////////////////////////////////////////
04992 BOOL CComboBoxString::OnInitialUpdate()
04993 {
04994   //Populate the <NULL> option
04995   AddString(L"<NULL>",      VT_NULL /*NULL pointer*/);
04996   AddString(L"<Empty String>",  VT_EMPTY/*Empty String*/);
04997
04998   //Delegate
04999   return CComboBoxLite::OnInitialUpdate();
05000 }
05001
05002
05003 /////////////////////////////////////////////////////////////////////////////
05004 // CComboBoxString::GetSelText
05005 //
05006 /////////////////////////////////////////////////////////////////////////////
05007 WCHAR* CComboBoxString::GetSelText()
05008 {
05009   INDEX iSel = GetCurSel();
05010   if(iSel == CB_ERR)
05011   {
05012     //Delegate
05013     return CComboBoxLite::GetWindowText();
05014   }
05015
05016   DBTYPE wType = (DBTYPE)GetItemParam(iSel);
05017   switch(wType)
05018   {
05019     case VT_NULL:
05020       //Null pointer
05021       return NULL;
05022
05023     case VT_EMPTY:
05024       //Empty string
05025       return wcsDuplicate(L"");
05026
05027     default:
05028       ASSERT(!"Unhandled Drop Down!");
05029       break;
05030   };
05031
05032   return NULL;
05033 }
05034
05035
05036
05037 /////////////////////////////////////////////////////////////////////////////
05038 // CInterfaceDlg
05039 //
05040 /////////////////////////////////////////////////////////////////////////////
05041 CInterfaceDlg::CInterfaceDlg(UINT nID, WCHAR* pwszTitle, REFIID riid)
05042   : CDialogLite(nID)
05043 {
05044   //Title
05045   m_pwszTitle   = pwszTitle;
05046
05047   //Aggregation
05048   m_fAggregation  = FALSE;  //Default
05049   m_pCAggregate = NULL;
05050
05051   //riid
05052   m_iid     = riid;
05053
05054   //Output
05055   m_fOutput   = TRUE;   //Default
05056   m_pIUnknown   = NULL;
05057   m_ppIUnknown  = NULL;
05058 }
05059
05060
05061 /////////////////////////////////////////////////////////////////////////////
05062 // ~CInterfaceDlg
05063 //
05064 /////////////////////////////////////////////////////////////////////////////
05065 CInterfaceDlg::~CInterfaceDlg()
05066 {
05067   //Aggregation
05068   SAFE_RELEASE(m_pCAggregate);
05069
05070   //Output
05071   SAFE_RELEASE(m_pIUnknown);
05072 }
05073
05074
05075 /////////////////////////////////////////////////////////////////////////////
05076 // CInterfaceDlg::OnInitDialog
05077 //
05078 /////////////////////////////////////////////////////////////////////////////
05079 BOOL CInterfaceDlg::OnInitDialog()
05080 {
05081   CWaitCursor waitCursor;
05082
05083   //Update Title and Window
05084   if(m_pwszTitle)
05085     wSendMessage(m_hWnd, WM_SETTEXT, 0, m_pwszTitle);
05086
05087   //Setup the Aggregation Button
05088   SAFE_RELEASE(m_pCAggregate);
05089   CheckDlgButton(IDB_AGGREGATION, BST2STATE(m_fAggregation));   //Default
05090
05091   //Setup the Interface Combo
05092   m_CComboInterface.CreateIndirect(m_hWnd, IDC_INTERFACE);
05093   m_CComboInterface.Populate(g_cInterfaceMaps, g_rgInterfaceMaps);
05094   m_CComboInterface.SetGuid(m_iid);
05095
05096   //Setup the ppIUnknown Button
05097   SAFE_RELEASE(m_pIUnknown);
05098   CheckDlgButton(IDB_OUTPUT, BST2STATE(m_fOutput));     //Default
05099
05100   CenterDialog(m_hWnd);
05101   return CDialogLite::OnInitDialog();
05102 }
05103
05104
05105 /////////////////////////////////////////////////////////////////////////////
05106 // CInterfaceDlg::OnOK
05107 //
05108 /////////////////////////////////////////////////////////////////////////////
05109 BOOL CInterfaceDlg::OnOK()
05110 {
05111   CWaitCursor waitCursor;
05112
05113   //Update all our items...
05114   OnUpdate();
05115
05116   //Delegate
05117   return CDialogLite::OnOK();
05118 }
05119
05120
05121 /////////////////////////////////////////////////////////////////////////////
05122 // CInterfaceDlg::OnUpdate
05123 //
05124 /////////////////////////////////////////////////////////////////////////////
05125 BOOL CInterfaceDlg::OnUpdate()
05126 {
05127   //Obtain the Aggregation argument
05128   if(IsDlgButtonChecked(IDB_AGGREGATION))
05129     m_pCAggregate = new CAggregate();
05130
05131   //Obtain the riid argument
05132   m_iid = m_CComboInterface.GetGuid();
05133
05134   //Obtain the Output (ppIUnknown) argument
05135   if(IsDlgButtonChecked(IDB_OUTPUT))
05136     m_ppIUnknown = &m_pIUnknown;
05137
05138   return TRUE;
05139 }
05140
05141
05142 /////////////////////////////////////////////////////////////////////////////
05143 // CInterfaceDlg::OnCommand
05144 //
05145 /////////////////////////////////////////////////////////////////////////////
05146 BOOL CInterfaceDlg::OnCommand(UINT iID, HWND hWndCtrl)
05147 {
05148   switch(iID)
05149   {
05150     //File Menu
05151     ON_COMMAND(IDB_AGGREGATION,   OnAggregation())
05152   }
05153
05154   return CDialogLite::OnCommand(iID, hWndCtrl);
05155 }
05156
05157 /////////////////////////////////////////////////////////////////////////////
05158 // CInterfaceDlg::OnAggregation
05159 //
05160 /////////////////////////////////////////////////////////////////////////////
05161 BOOL CInterfaceDlg::OnAggregation()
05162 {
05163   //Aggregation Combo Selection has changed...
05164   //If we are now using Aggregation, automatically change the requested
05165   //riid to IID_IUnknown, since its an error otherwise...
05166   if(IsDlgButtonChecked(IDB_AGGREGATION))
05167   {
05168     m_CComboInterface.SetGuid(IID_IUnknown);
05169   }
05170
05171   return TRUE;
05172 }
05173
05174
05175
05176
05177 /////////////////////////////////////////////////////////////////////////////
05178 // CEditValueDlg
05179 //
05180 /////////////////////////////////////////////////////////////////////////////
05181 CEditValueDlg::CEditValueDlg(UINT nID, WCHAR* pwszTitle)
05182   : CDialogLite(nID)
05183 {
05184   ASSERT(pwszTitle);
05185
05186   //Title
05187   m_pwszTitle   = pwszTitle;
05188
05189   //String
05190   m_pwszValue   = NULL;
05191   m_wReqType    = DBTYPE_WSTR;
05192 }
05193
05194
05195 /////////////////////////////////////////////////////////////////////////////
05196 // ~CEditValueDlg
05197 //
05198 /////////////////////////////////////////////////////////////////////////////
05199 CEditValueDlg::~CEditValueDlg()
05200 {
05201   //Value
05202   SAFE_FREE(m_pwszValue);
05203 }
05204
05205
05206 /////////////////////////////////////////////////////////////////////////////
05207 // CEditValueDlg::OnInitDialog
05208 //
05209 /////////////////////////////////////////////////////////////////////////////
05210 BOOL CEditValueDlg::OnInitDialog()
05211 {
05212   CWaitCursor waitCursor;
05213
05214   //Update Title and Window
05215   SetWindowText(m_pwszTitle);
05216
05217   //Setup the Value
05218   m_editValue.CreateIndirect(m_hWnd, IDE_VALUE);
05219   if(m_pwszValue)
05220     m_editValue.SetWindowText(m_pwszValue);
05221
05222   //Delegate
05223   CenterDialog(m_hWnd);
05224   return CDialogLite::OnInitDialog();
05225 }
05226
05227
05228 /////////////////////////////////////////////////////////////////////////////
05229 // CEditValueDlg::OnOK
05230 //
05231 /////////////////////////////////////////////////////////////////////////////
05232 BOOL CEditValueDlg::OnOK()
05233 {
05234   CWaitCursor waitCursor;
05235
05236   if(m_wReqType)
05237   {
05238     //Obtain the value argument
05239     SAFE_FREE(m_pwszValue);
05240     m_pwszValue = m_editValue.GetWindowText();
05241
05242     //Need to validate (and obtain) the value, so we know it can be converted to the requested type.
05243     //If not then do not continue (return FALSE), so the user gets another chance
05244     //to correct the value...
05245     if(m_wReqType != DBTYPE_WSTR)
05246     {
05247       CVariant cVariant;
05248       if(FAILED(StringToVariant(m_pwszValue, m_wReqType, &cVariant)))
05249       {
05250         wMessageBox(m_editValue.m_hWnd, MB_TASKMODAL | MB_ICONERROR | MB_OK,  wsz_ERROR,
05251           L"Unable to convert specified string \"%s\", to %s", m_pwszValue, GetDBTypeName(m_wReqType));
05252         m_editValue.SetFocus();
05253         return FALSE;
05254       }
05255     }
05256   }
05257
05258   //Delegate
05259   return CDialogLite::OnOK();
05260 }
05261
05262
05263 /////////////////////////////////////////////////////////////////////////////
05264 // CEditValueDlg::SetVariant
05265 //
05266 /////////////////////////////////////////////////////////////////////////////
05267 HRESULT CEditValueDlg::SetVariant(VARIANT* pVariant)
05268 {
05269   HRESULT hr = S_OK;
05270   ASSERT(pVariant);
05271   CVariant cVariant;
05272
05273   //Make sure we can convert to a string value
05274   hr = cVariant.ChangeType(DBTYPE_BSTR, pVariant);
05275   if(SUCCEEDED(hr))
05276   {
05277     ASSERT(cVariant.vt == VT_BSTR);
05278     SetValue(V_BSTR(&cVariant));
05279   }
05280   return hr;
05281 }
05282
05283
05284 /////////////////////////////////////////////////////////////////////////////
05285 // CEditValueDlg::GetVariant
05286 //
05287 /////////////////////////////////////////////////////////////////////////////
05288 HRESULT CEditValueDlg::GetVariant(DBTYPE wType, VARIANT* pVariant)
05289 {
05290   ASSERT(pVariant);
05291   ASSERT(m_wReqType);
05292
05293   return StringToVariant(m_pwszValue, wType, pVariant);
05294 }
05295
05296
05297
05298
05299
05300
05301 /////////////////////////////////////////////////////////////////////////////
05302 // CMultipleResultsDlg
05303 //
05304 /////////////////////////////////////////////////////////////////////////////
05305 CMultipleResultsDlg::CMultipleResultsDlg(CMDIChild* pCMDIChild)
05306   : CInterfaceDlg(IDD_MULTIPLERESULTS, NULL, IID_IRowset), CRowsetViewerDlg(NULL, pCMDIChild)
05307 {
05308   //Data
05309 }
05310
05311
05312 /////////////////////////////////////////////////////////////////////////////
05313 // ~CMultipleResultsDlg
05314 //
05315 /////////////////////////////////////////////////////////////////////////////
05316 CMultipleResultsDlg::~CMultipleResultsDlg()
05317 {
05318 }
05319
05320
05321 /////////////////////////////////////////////////////////////////////////////
05322 // CMultipleResultsDlg::OnInitDialog
05323 //
05324 /////////////////////////////////////////////////////////////////////////////
05325 BOOL CMultipleResultsDlg::OnInitDialog()
05326 {
05327   CWaitCursor waitCursor;
05328
05329   //Populate the lResultFlag Flag
05330   m_CComboReserved.CreateIndirect(m_hWnd, IDC_RESERVED);
05331   m_CComboReserved.Populate(g_cResultFlagMaps, g_rgResultFlagMaps);
05332   m_CComboReserved.SetSelValue(DBRESULTFLAG_DEFAULT);
05333
05334   //Delegate
05335   return CInterfaceDlg::OnInitDialog();
05336 }
05337
05338
05339 /////////////////////////////////////////////////////////////////////////////
05340 // CMultipleResultsDlg::OnOK
05341 //
05342 /////////////////////////////////////////////////////////////////////////////
05343 BOOL CMultipleResultsDlg::OnOK()
05344 {
05345   CWaitCursor waitCursor;
05346   HRESULT hr = S_OK;
05347
05348   //Obtain the MultipleResults object
05349   CMultipleResults* pCMultipleResults = SOURCE_GETOBJECT(m_pCMDIChild->m_pCSource, CMultipleResults);
05350   if(pCMultipleResults)
05351   {
05352     DBROWCOUNT  cRowsAffected = 0;
05353
05354     //Obtain inherited items...
05355     CInterfaceDlg::OnUpdate();
05356
05357     //lResultFlag Flag
05358     //Used to determine which object to obtain when riid is ambigous
05359     DB_LRESERVE lResultFlag = m_CComboReserved.GetSelValue();
05360     if(lResultFlag == CB_ERR)
05361       lResultFlag = DBRESULTFLAG_DEFAULT;
05362
05363     //IMultipleResults::GetResult...
05364     //NOTE: Can pontentially return other object types: (ie: CREATE_DETERMINE_TYPE)
05365     if(SUCCEEDED(hr = pCMultipleResults->GetResult(GetAggregate(), lResultFlag, GetSelInterface(), &cRowsAffected, ppUnknown())))
05366       m_pCMainWindow->HandleObjectType(pCMultipleResults, pUnknown(), GetSelInterface(), eCRowset, 0, NULL, CREATE_NEWWINDOW_IFEXISTS | CREATE_DETERMINE_TYPE);
05367   }
05368
05369 //CLEANUP:
05370   if(SUCCEEDED(hr))
05371     CDialogLite::OnOK();
05372   return TRUE;
05373 }
05374
05375
05376
05377 ////////////////////////////////////////////////////////////////
05378 // CConstraintDlg::CConstraintDlg
05379 //
05380 /////////////////////////////////////////////////////////////////
05381 CConstraintDlg::CConstraintDlg(CMainWindow* pCMainWindow)
05382   : CDialogLite(IDD_ADDCONSTRAINTDESC), CRowsetViewerDlg(pCMainWindow)
05383 {
05384   m_pConsDesc   = NULL;
05385   m_ppwszTableName  = NULL;
05386 } //CConstraintDlg::CConstraintDlg
05387
05388
05389 ////////////////////////////////////////////////////////////////
05390 // CConstraintDlg::~CConstraintDlg
05391 //
05392 /////////////////////////////////////////////////////////////////
05393 CConstraintDlg::~CConstraintDlg()
05394 {
05395 } //CConstraintDlg::~CConstraintDlg
05396
05397
05398 ////////////////////////////////////////////////////////////////
05399 // CConstraintDlg::SetConstraintAndTable
05400 //
05401 /////////////////////////////////////////////////////////////////
05402 HRESULT CConstraintDlg::SetConstraintAndTable(
05403   HWND        hWndParent,
05404   DBCONSTRAINTDESC  *pConsDesc,
05405   WCHAR       **ppwszTableName
05406 )
05407 {
05408   m_pConsDesc     = pConsDesc;
05409   m_ppwszTableName  = ppwszTableName;
05410
05411   //Now Display the dialog
05412   if(DoModal(hWndParent) == IDOK)
05413     return S_OK;
05414
05415   return DB_E_CANCELED;
05416 } //CConstraintDlg::SetConstraintAndTable
05417
05418
05419 /////////////////////////////////////////////////////////////////////
05420 // CConstraintDlg::OnInitDialog
05421 //
05422 /////////////////////////////////////////////////////////////////////
05423 BOOL CConstraintDlg::OnInitDialog()
05424 {
05425   CWaitCursor waitCursor;
05426   INDEX   iSel;
05427   ULONG   index;
05428
05429   //Setup Controls
05430   m_comboConstraintType.CreateIndirect(m_hWnd, IDC_CONSTYPE);
05431   m_listDeferrability.CreateIndirect(m_hWnd, IDC_DEFERRABILITY);
05432   m_listColumnList.CreateIndirect(m_hWnd, IDC_COLLIST);
05433   m_listFKColumnList.CreateIndirect(m_hWnd, IDC_FKCOLLIST);
05434   m_comboMatchType.CreateIndirect(m_hWnd, IDC_MATCHTYPE);
05435   m_comboUpdateRule.CreateIndirect(m_hWnd, IDC_UPDATERULE);
05436   m_comboDeleteRule.CreateIndirect(m_hWnd, IDC_DELETERULE);
05437
05438   m_editConstraintName.CreateIndirect(m_hWnd, IDE_CONSNAME);
05439   m_editBaseTableName.CreateIndirect(m_hWnd, IDE_TABLEID);
05440   m_editReferencedTableName.CreateIndirect(m_hWnd, IDE_REFERENCEDTABLE);
05441   m_editConstraintText.CreateIndirect(m_hWnd, IDE_CONSTEXT);
05442   m_editColumnName.CreateIndirect(m_hWnd, IDE_COLNAME);
05443   m_editFKColumnName.CreateIndirect(m_hWnd, IDE_FKCOLNAME);
05444
05445   //Now adjust display
05446   if(NULL != m_ppwszTableName)
05447   {
05448     SetWindowText(L"ITableDefinitionWithConstraints::AddConstraint");
05449     m_editBaseTableName.EnableWindow(TRUE);
05450   }
05451   else
05452   {
05453     SetWindowText(L"ITableDefinitionWithConstraints::CreateTableWithConstraints");
05454     m_editBaseTableName.EnableWindow(FALSE);
05455   }
05456
05457   //Fill in the constraint type list
05458   for (index = 0; index < g_cConsTypeMaps; index++)
05459   {
05460     iSel = m_comboConstraintType.AddString(g_rgConsTypeMaps[index].pwszName);
05461     m_comboConstraintType.SetItemParam(iSel, g_rgConsTypeMaps[index].lItem);
05462   }
05463   m_comboConstraintType.SetCurSel(1);
05464
05465   //Fill in the deferrability list
05466   for (index = 0; index < g_cDeferrabilityMaps; index++)
05467   {
05468     iSel = m_listDeferrability.AddString(g_rgDeferrabilityMaps[index].pwszName);
05469     m_listDeferrability.SetItemParam(iSel, g_rgDeferrabilityMaps[index].lItem);
05470   }
05471
05472   //Fill in the match type list
05473   for (index = 0; index < g_cMatchTypeMaps; index++)
05474   {
05475     iSel = m_comboMatchType.AddString(g_rgMatchTypeMaps[index].pwszName);
05476     m_comboMatchType.SetItemParam(iSel, g_rgMatchTypeMaps[index].lItem);
05477   }
05478
05479   //Fill in the update and delete list
05480   for (index = 0; index < g_cUpDelRuleMaps; index++)
05481   {
05482     // update list
05483     iSel = m_comboUpdateRule.AddString(g_rgUpDelRuleMaps[index].pwszName);
05484     m_comboUpdateRule.SetItemParam(iSel, g_rgUpDelRuleMaps[index].lItem);
05485
05486     // delete list
05487     iSel = m_comboDeleteRule.AddString(g_rgUpDelRuleMaps[index].pwszName);
05488     m_comboDeleteRule.SetItemParam(iSel, g_rgUpDelRuleMaps[index].lItem);
05489   }
05490
05491   //Delegate
05492   return CDialogLite::OnInitDialog();
05493 } // CConstraintDlg::OnInitDialog
05494
05495
05496
05497
05498 /////////////////////////////////////////////////////////////////////////////
05499 // CConstraintDlg::OnCommand
05500 //
05501 /////////////////////////////////////////////////////////////////////////////
05502 BOOL CConstraintDlg::OnCommand(UINT iID, HWND hWndCtrl)
05503 {
05504   WCHAR *pwszColName = NULL;
05505
05506   switch(iID)
05507   {
05508     case IDB_ADDCOL:
05509     {
05510       // add column to the list of columns
05511       pwszColName = m_editColumnName.GetWindowText();
05512       if (pwszColName)
05513         m_listColumnList.AddString(pwszColName);
05514       SAFE_FREE(pwszColName);
05515       return TRUE;
05516     }
05517
05518     case IDB_ADDFKCOL:
05519     {
05520       // add column to the list of columns
05521       pwszColName = m_editFKColumnName.GetWindowText();
05522       if (pwszColName)
05523         m_listFKColumnList.AddString(pwszColName);
05524       SAFE_FREE(pwszColName);
05525       return TRUE;
05526     }
05527
05528     case IDB_DELCOL:
05529     {
05530       m_listColumnList.DeleteString(m_listColumnList.GetCurSel());
05531       return TRUE;
05532     }
05533
05534     case IDB_DELFKCOL:
05535     {
05536       m_listFKColumnList.DeleteString(m_listFKColumnList.GetCurSel());
05537       return TRUE;
05538     }
05539   };
05540
05541   return FALSE;
05542 } //CConstraintDlg::OnCommand
05543
05544
05545 /////////////////////////////////////////////////////////////////////////////
05546 // CConstraintDlg::OnOK
05547 //
05548 /////////////////////////////////////////////////////////////////////////////
05549 BOOL CConstraintDlg::OnOK()
05550 {
05551   CWaitCursor waitCursor;
05552   HWND    hWndDeferrability = GetDlgItem(IDC_DEFERRABILITY);
05553   const ULONG cMaxSel = 2;
05554   INDEX   cSel;
05555   INT     rgSel[cMaxSel];
05556   DBORDINAL index;
05557   HRESULT   hr;
05558   WCHAR   *pwszText = NULL;
05559
05560   // fill in table name
05561   if (m_ppwszTableName)
05562   {
05563     *m_ppwszTableName = this->m_editBaseTableName.GetWindowText();
05564   }
05565
05566   // fill in pConsDesc structure
05567   if (m_pConsDesc)
05568   {
05569     WCHAR *pwszConsName = m_editConstraintName.GetWindowText();
05570
05571     // get constraint name
05572     if (pwszConsName)
05573     {
05574       SAFE_ALLOC(m_pConsDesc->pConstraintID, DBID, 1);
05575       m_pConsDesc->pConstraintID->eKind     = DBKIND_NAME;
05576       m_pConsDesc->pConstraintID->uName.pwszName  = pwszConsName ;
05577     }
05578
05579     // get the type
05580     m_pConsDesc->ConstraintType = (DBCONSTRAINTTYPE)m_comboConstraintType.GetItemParam(m_comboConstraintType.GetCurSel());
05581
05582     // get deferrability
05583     m_pConsDesc->Deferrability = 0;
05584     cSel = SendMessage(hWndDeferrability, LB_GETSELITEMS, (WPARAM)cMaxSel, (LPARAM)rgSel);
05585
05586     if (1 == cSel)
05587       m_pConsDesc->Deferrability |= m_listDeferrability.GetItemParam(rgSel[0]);
05588     else if (2 == cSel)
05589       m_pConsDesc->Deferrability = DBDEFERRABILITY_DEFERRED | DBDEFERRABILITY_DEFERRABLE;
05590
05591     // get text of constraint
05592     m_pConsDesc->pwszConstraintText = m_editConstraintText.GetWindowText();
05593
05594     // get list of column names
05595     m_pConsDesc->cColumns = m_listColumnList.GetCount();
05596     if (m_pConsDesc->cColumns)
05597     {
05598       SAFE_ALLOC(m_pConsDesc->rgColumnList, DBID, m_pConsDesc->cColumns);
05599       for (index = 0; index < m_pConsDesc->cColumns; index++)
05600       {
05601         m_pConsDesc->rgColumnList[index].eKind = DBKIND_NAME;
05602         SAFE_ALLOC(m_pConsDesc->rgColumnList[index].uName.pwszName, WCHAR,
05603           m_listColumnList.GetTextLen(index)+1);
05604         m_listColumnList.GetText(index, m_pConsDesc->rgColumnList[index].uName.pwszName);
05605       }
05606     }
05607
05608     // get referenced table name
05609     pwszText = m_editReferencedTableName.GetWindowText();
05610     if (pwszText)
05611     {
05612       SAFE_ALLOC(m_pConsDesc->pReferencedTableID, DBID, 1);
05613       m_pConsDesc->pReferencedTableID->eKind      = DBKIND_NAME;
05614       m_pConsDesc->pReferencedTableID->uName.pwszName = pwszText;
05615     }
05616
05617     // get list of foreign key column names
05618     m_pConsDesc->cForeignKeyColumns = m_listFKColumnList.GetCount();
05619     if (m_pConsDesc->cForeignKeyColumns)
05620     {
05621       SAFE_ALLOC(m_pConsDesc->rgForeignKeyColumnList, DBID, m_pConsDesc->cForeignKeyColumns);
05622       for (index = 0; index < m_pConsDesc->cForeignKeyColumns; index++)
05623       {
05624         m_pConsDesc->rgForeignKeyColumnList[index].eKind = DBKIND_NAME;
05625         SAFE_ALLOC(m_pConsDesc->rgForeignKeyColumnList[index].uName.pwszName, WCHAR,
05626           m_listFKColumnList.GetTextLen(index)+1);
05627         m_listFKColumnList.GetText(index, m_pConsDesc->rgForeignKeyColumnList[index].uName.pwszName);
05628       }
05629     }
05630
05631     // get match type
05632     m_pConsDesc->MatchType = (DBMATCHTYPE)m_comboMatchType.GetItemParam(m_comboMatchType.GetCurSel());
05633
05634     // get update rule
05635     m_pConsDesc->UpdateRule = (DBUPDELRULE)m_comboUpdateRule.GetItemParam(m_comboUpdateRule.GetCurSel());
05636
05637     // get delete rule
05638     m_pConsDesc->DeleteRule = (DBUPDELRULE)m_comboDeleteRule.GetItemParam(m_comboDeleteRule.GetCurSel());
05639   }
05640
05641 CLEANUP:
05642   //Delegate
05643   return CDialogLite::OnOK();
05644 } //CConstraintDlg::OnOK
05645
05646
05647
05648
05649 ////////////////////////////////////////////////////////////////
05650 // CAlterIndexDlg::CAlterIndexDlg
05651 //
05652 /////////////////////////////////////////////////////////////////
05653 CAlterIndexDlg::CAlterIndexDlg(CMDIChild *pCMDIChild)
05654   : CDialogLite(IDD_ALTERINDEX), CRowsetViewerDlg(NULL, pCMDIChild)
05655 {
05656   m_ppTableID     = NULL;
05657   m_ppIndexID     = NULL;
05658   m_ppNewIndexID    = NULL;
05659   m_pfUseIndexProps = NULL;
05660 } //CAlterIndexDlg::CAlterIndexDlg
05661
05662
05663 ////////////////////////////////////////////////////////////////
05664 // CAlterIndexDlg::~CAlterIndexDlg
05665 //
05666 /////////////////////////////////////////////////////////////////
05667 CAlterIndexDlg::~CAlterIndexDlg()
05668 {
05669 } //CAlterIndexDlg::~CAlterIndexDlg
05670
05671
05672 ////////////////////////////////////////////////////////////////
05673 // CAlterIndexDlg::AlterIndex
05674 //
05675 /////////////////////////////////////////////////////////////////
05676 HRESULT CAlterIndexDlg::AlterIndex(
05677   HWND        hWndParent,
05678   DBID        **ppTableID,
05679   DBID        **ppIndexID,
05680   DBID        **ppNewIndexID,
05681   BOOL        *pfUseIndexProps
05682 )
05683 {
05684   ASSERT(ppTableID);
05685   ASSERT(ppIndexID);
05686   ASSERT(ppNewIndexID);
05687   ASSERT(pfUseIndexProps);
05688
05689   m_ppTableID     = ppTableID;
05690   m_ppIndexID     = ppIndexID;
05691   m_ppNewIndexID    = ppNewIndexID;
05692   m_pfUseIndexProps = pfUseIndexProps;
05693
05694   *m_ppTableID = NULL;
05695   *m_ppIndexID = NULL;
05696   *m_ppNewIndexID = NULL;
05697
05698   *pfUseIndexProps = FALSE;
05699
05700   //Now Display the dialog
05701   if(DoModal(hWndParent) == IDOK)
05702     return S_OK;
05703
05704   return DB_E_CANCELED;
05705 } //CAlterIndexDlg::AlterIndex
05706
05707
05708 /////////////////////////////////////////////////////////////////////
05709 // CAlterIndexDlg::OnInitDialog
05710 //
05711 /////////////////////////////////////////////////////////////////////
05712 BOOL CAlterIndexDlg::OnInitDialog()
05713 {
05714   CWaitCursor waitCursor;
05715
05716   //Setup Controls
05717   m_editTableName.CreateIndirect(m_hWnd, IDE_TABLEID);
05718   m_editIndexName.CreateIndirect(m_hWnd, IDE_INDEXID);
05719   m_editNewIndexName.CreateIndirect(m_hWnd, IDE_NewIndexID);
05720
05721   //Auto Save buttons for change IndexID and use index properties
05722   CheckDlgButton(IDB_USEPROPERTIES, BST_UNCHECKED);
05723   CheckDlgButton(IDC_ChangeIndexID, (*m_pfUseIndexProps)? BST_CHECKED: BST_UNCHECKED);
05724
05725   m_editNewIndexName.EnableWindow(FALSE);
05726
05727   //Delegate
05728   return CDialogLite::OnInitDialog();
05729 } // CAlterIndexDlg::OnInitDialog
05730
05731
05732
05733
05734 /////////////////////////////////////////////////////////////////////////////
05735 // CAlterIndexDlg::OnCommand
05736 //
05737 /////////////////////////////////////////////////////////////////////////////
05738 BOOL CAlterIndexDlg::OnCommand(UINT iID, HWND hWndCtrl)
05739 {
05740   switch (iID)
05741   {
05742     case IDB_INDEXPROPERTIES:
05743     {
05744       // get the new index properties
05745       //Get the "this" pointer
05746 //      CAlterIndexDlg  *pThis      = (CAlterIndexDlg*)GetThis(hWndCtrl);
05747       CMDIChild   *pCMDIChild   = this->m_pCMDIChild;
05748       CMainWindow   *pCMainWindow = pCMDIChild->m_pCMainWindow;
05749
05750       CSession    *pCSession    = (CSession*)pCMDIChild->GetObject(eCSession);
05751       CDataSource   *pCDataSource = SOURCE_GETPARENT(pCSession, CDataSource);
05752       CPropertiesDlg  sCPropertiesDlg(pCMainWindow);
05753
05754       //SetProperties
05755       sCPropertiesDlg.SetProperties(hWndCtrl, &DBPROPSET_INDEXALL, IID_IDBProperties, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &this->m_CPropSets);
05756       return TRUE;
05757     }
05758     case IDC_ChangeIndexID:
05759     {
05760       m_editNewIndexName.EnableWindow(IsDlgButtonChecked(IDC_ChangeIndexID));
05761       return TRUE;
05762     }
05763   }
05764
05765   return FALSE;
05766 } //CAlterIndexDlg::OnCommand
05767
05768
05769 /////////////////////////////////////////////////////////////////////////////
05770 // CAlterIndexDlg::OnOK
05771 //
05772 /////////////////////////////////////////////////////////////////////////////
05773 BOOL CAlterIndexDlg::OnOK()
05774 {
05775   CWaitCursor waitCursor;
05776   WCHAR   *pwszTableName = NULL;
05777   WCHAR   *pwszIndexName = NULL;
05778   WCHAR   *pwszNewIndexName = NULL;
05779   HRESULT   hr;
05780
05781   pwszTableName = m_editTableName.GetWindowText();
05782   if (pwszTableName)
05783   {
05784     SAFE_ALLOC(*m_ppTableID, DBID, 1);
05785     (*m_ppTableID)->eKind     = DBKIND_NAME;
05786     (*m_ppTableID)->uName.pwszName  = pwszTableName;
05787   }
05788
05789   pwszIndexName = m_editIndexName.GetWindowText();
05790   if (pwszIndexName)
05791   {
05792     SAFE_ALLOC(*m_ppIndexID, DBID, 1);
05793     (*m_ppIndexID)->eKind     = DBKIND_NAME;
05794     (*m_ppIndexID)->uName.pwszName  = pwszIndexName;
05795   }
05796
05797   pwszNewIndexName = m_editNewIndexName.GetWindowText();
05798   if (pwszNewIndexName)
05799   {
05800     SAFE_ALLOC(*m_ppNewIndexID, DBID, 1);
05801     (*m_ppNewIndexID)->eKind      = DBKIND_NAME;
05802     (*m_ppNewIndexID)->uName.pwszName = pwszNewIndexName;
05803   }
05804
05805   *m_pfUseIndexProps = IsDlgButtonChecked(IDB_USEPROPERTIES);
05806
05807 CLEANUP:
05808   //Delegate
05809   return CDialogLite::OnOK();
05810 } //CAlterIndexDlg::OnOK
05811
05812
05813 ////////////////////////////////////////////////////////////////
05814 // CAlterTableDlg::CAlterTableDlg
05815 //
05816 /////////////////////////////////////////////////////////////////
05817 CAlterTableDlg::CAlterTableDlg(CMDIChild *pCMDIChild)
05818   : CDialogLite(IDD_ALTERTABLE), CRowsetViewerDlg(NULL, pCMDIChild)
05819 {
05820   m_pTableID      = NULL;
05821   m_pNewTableID   = NULL;
05822   m_fUseTableProps  = FALSE;
05823 } //CAlterTableDlg::CAlterTableDlg
05824
05825
05826
05827 ////////////////////////////////////////////////////////////////
05828 // CAlterTableDlg::CAlterTableDlg
05829 //
05830 /////////////////////////////////////////////////////////////////
05831 HRESULT CAlterTableDlg::AlterTable(HWND hWndParent)
05832 {
05833   //Now Display the dialog
05834   if(DoModal(hWndParent) == IDOK)
05835     return S_OK;
05836
05837   return DB_E_CANCELED;
05838 } //CAlterTableDlg::AlterTable
05839
05840
05841 ////////////////////////////////////////////////////////////////
05842 // CAlterTableDlg::~CAlterTableDlg
05843 //
05844 /////////////////////////////////////////////////////////////////
05845 CAlterTableDlg::~CAlterTableDlg()
05846 {
05847   DBIDFree(m_pTableID);
05848   SAFE_FREE(m_pTableID);
05849   DBIDFree(m_pNewTableID);
05850   SAFE_FREE(m_pNewTableID);
05851 } //CAlterTableDlg::~CAlterTableDlg
05852
05853
05854 /////////////////////////////////////////////////////////////////////
05855 // CAlterTableDlg::OnInitDialog
05856 //
05857 /////////////////////////////////////////////////////////////////////
05858 BOOL CAlterTableDlg::OnInitDialog()
05859 {
05860   CWaitCursor waitCursor;
05861
05862   //Setup Controls
05863   m_editTableName.CreateIndirect(m_hWnd, IDE_TABLEID);
05864   m_editNewTableName.CreateIndirect(m_hWnd, IDE_NewTableID);
05865
05866   //Auto Save buttons for change IndexID and use index properties
05867   CheckDlgButton(IDB_USEPROPERTIES, BST_UNCHECKED);
05868
05869   //Delegate
05870   return CDialogLite::OnInitDialog();
05871 } // CAlterTableDlg::OnInitDialog
05872
05873
05874
05875
05876 /////////////////////////////////////////////////////////////////////////////
05877 // CAlterTableDlg::OnCommand
05878 //
05879 /////////////////////////////////////////////////////////////////////////////
05880 BOOL CAlterTableDlg::OnCommand(UINT iID, HWND hWndCtrl)
05881 {
05882   switch (iID)
05883   {
05884     case IDB_TABLEPROPERTIES:
05885     {
05886       // get the new index properties
05887       //Get the "this" pointer
05888       CMDIChild   *pCMDIChild   = m_pCMDIChild;
05889       CMainWindow   *pCMainWindow = pCMDIChild->m_pCMainWindow;
05890
05891       CSession    *pCSession    = (CSession*)pCMDIChild->GetObject(eCSession);
05892       CDataSource   *pCDataSource = SOURCE_GETPARENT(pCSession, CDataSource);
05893       CPropertiesDlg  sCPropertiesDlg(pCMainWindow);
05894
05895       //SetProperties
05896       sCPropertiesDlg.SetProperties(hWndCtrl, &DBPROPSET_TABLEALL, IID_IDBProperties, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &m_CPropSets);
05897       return TRUE;
05898     }
05899   }
05900
05901   return FALSE;
05902 } //CAlterTableDlg::OnCommand
05903
05904
05905 /////////////////////////////////////////////////////////////////////////////
05906 // CAlterTableDlg::OnOK
05907 //
05908 /////////////////////////////////////////////////////////////////////////////
05909 BOOL CAlterTableDlg::OnOK()
05910 {
05911   CWaitCursor waitCursor;
05912   WCHAR   *pwszTableName = NULL;
05913   WCHAR   *pwszNewTableName = NULL;
05914   HRESULT   hr;
05915
05916   pwszTableName = m_editTableName.GetWindowText();
05917   if (pwszTableName)
05918   {
05919     SAFE_ALLOC(m_pTableID, DBID, 1);
05920     m_pTableID->eKind     = DBKIND_NAME;
05921     m_pTableID->uName.pwszName  = pwszTableName;
05922   }
05923
05924   pwszNewTableName = m_editNewTableName.GetWindowText();
05925   if (pwszNewTableName)
05926   {
05927     SAFE_ALLOC(m_pNewTableID, DBID, 1);
05928     m_pNewTableID->eKind      = DBKIND_NAME;
05929     m_pNewTableID->uName.pwszName = pwszNewTableName;
05930   }
05931
05932   m_fUseTableProps = IsDlgButtonChecked(IDB_USEPROPERTIES);
05933
05934 CLEANUP:
05935   //Delegate
05936   return CDialogLite::OnOK();
05937 } //CAlterTableDlg::OnOK
05938
05939
05940
05941
05942 ////////////////////////////////////////////////////////////////
05943 // CAlterColumnDlg::CAlterColumnDlg
05944 //
05945 /////////////////////////////////////////////////////////////////
05946 CAlterColumnDlg::CAlterColumnDlg(CMDIChild *pCMDIChild)
05947   : CDialogLite(IDD_ALTERCOLUMN), CRowsetViewerDlg(NULL, pCMDIChild)
05948 {
05949   m_pTableID      = NULL;
05950   m_pColumnID     = NULL;
05951   m_fUseColProps    = FALSE;
05952   m_dwColFlags    = 0;
05953   memset(&m_ColDesc, 0, sizeof(DBCOLUMNDESC));
05954 } //CAlterColumnDlg::CAlterColumnDlg
05955
05956
05957
05958 ////////////////////////////////////////////////////////////////
05959 // CAlterColumnDlg::AlterColumn
05960 //
05961 /////////////////////////////////////////////////////////////////
05962 HRESULT CAlterColumnDlg::AlterColumn(HWND hWndParent)
05963 {
05964   //Now Display the dialog
05965   if(DoModal(hWndParent) == IDOK)
05966     return S_OK;
05967
05968   return DB_E_CANCELED;
05969 } //CAlterColumnDlg::AlterColumn
05970
05971
05972 ////////////////////////////////////////////////////////////////
05973 // CAlterColumnDlg::~CAlterColumnDlg
05974 //
05975 /////////////////////////////////////////////////////////////////
05976 CAlterColumnDlg::~CAlterColumnDlg()
05977 {
05978   DBIDFree(m_pTableID);
05979   SAFE_FREE(m_pTableID);
05980   DBIDFree(m_pColumnID);
05981   SAFE_FREE(m_pColumnID);
05982
05983   DBIDFree(&m_ColDesc.dbcid);
05984   SAFE_FREE(m_ColDesc.pwszTypeName);
05985 } //CAlterColumnDlg::~CAlterColumnDlg
05986
05987
05988 /////////////////////////////////////////////////////////////////////
05989 // CAlterColumnDlg::OnInitDialog
05990 //
05991 /////////////////////////////////////////////////////////////////////
05992 BOOL CAlterColumnDlg::OnInitDialog()
05993 {
05994   CWaitCursor waitCursor;
05995   INDEX   iSel;
05996   DBORDINAL index;
05997   CMDIChild *pCMDIChild   = m_pCMDIChild;
05998   WCHAR   wszBuffer[MAX_NAME_LEN+1];
05999
06000   CSession    *pCSession    = (CSession*)pCMDIChild->GetObject(eCSession);
06001
06002   // make sure we have provider type info in the session
06003   if (0 == pCSession->m_cProvTypes)
06004     pCSession->GetProviderTypes();
06005
06006   //Setup Controls
06007   m_editTableName.CreateIndirect(m_hWnd, IDE_TABLEID);
06008   m_editColumnName.CreateIndirect(m_hWnd, IDE_COLUMN);
06009   m_editNewColumnName.CreateIndirect(m_hWnd, IDE_COLUMNID);
06010
06011   m_editSize.CreateIndirect(m_hWnd, IDE_SIZE);
06012   m_editPrecision.CreateIndirect(m_hWnd, IDE_PRECISION);
06013   m_editScale.CreateIndirect(m_hWnd, IDE_SCALE);
06014
06015   m_listColumnDescFlags.CreateIndirect(m_hWnd, IDL_CDFLAGS);
06016
06017   m_comboDBType.CreateIndirect(m_hWnd, IDC_TYPE);
06018   m_comboTypeName.CreateIndirect(m_hWnd, IDC_TYPENAME);
06019
06020   //Auto Save buttons for change IndexID and use index properties
06021   CheckDlgButton(IDB_USEPROPERTIES, BST_UNCHECKED);
06022
06023   //Fill in the column desc flag list
06024   for (index = 0; index < g_cCDFlagsMaps; index++)
06025   {
06026     iSel = m_listColumnDescFlags.AddString(g_rgCDFlagsMaps[index].pwszName);
06027     m_listColumnDescFlags.SetItemParam(iSel, g_rgCDFlagsMaps[index].lItem);
06028   }
06029
06030   //Fill in the type name list
06031   for (index = 0; index < pCSession->m_cProvTypes; index++)
06032   {
06033     iSel = m_comboTypeName.AddString(pCSession->m_rgProvTypes[index].wszTypeName);
06034     m_comboTypeName.SetItemParam(iSel, (LPARAM)(&pCSession->m_rgProvTypes[index]));
06035   }
06036   m_comboTypeName.SetCurSel(0);
06037
06038   //Fill in the DBTYPE list
06039   for (index = 0; index < g_cDBTypes; index++)
06040   {
06041     iSel = m_comboDBType.AddString(g_rgDBTypes[index].pwszName);
06042     m_comboDBType.SetItemParam(iSel, g_rgDBTypes[index].lItem);
06043   }
06044
06045   // select the corresponding DBTYPE
06046   wSendMessage(m_comboDBType.GetWnd(), CB_SELECTSTRING, -1, GetDBTypeName(pCSession->m_rgProvTypes[0].wType));
06047
06048   StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[0].ulColumnSize);
06049   m_editSize.SetWindowText(wszBuffer);
06050
06051   if (IsNumericType(pCSession->m_rgProvTypes[0].wType))
06052   {
06053     StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pCSession->m_rgProvTypes[0].ulColumnSize);
06054     m_editPrecision.SetWindowText(wszBuffer);
06055   }
06056   else
06057   {
06058     m_editPrecision.SetWindowText(L"0");
06059   }
06060
06061   m_editScale.SetWindowText(L"0");
06062
06063   //Delegate
06064   return CDialogLite::OnInitDialog();
06065 } // CAlterColumnDlg::OnInitDialog
06066
06067
06068
06069
06070 /////////////////////////////////////////////////////////////////////////////
06071 // CAlterColumnDlg::OnCommand
06072 //
06073 /////////////////////////////////////////////////////////////////////////////
06074 BOOL CAlterColumnDlg::OnCommand(UINT iID, HWND hWndCtrl)
06075 {
06076   switch (iID)
06077   {
06078     case IDB_SETPROPERTIES:
06079     {
06080       // get the new index properties
06081       //Get the "this" pointer
06082       CSession    *pCSession    = (CSession*)m_pCMDIChild->GetObject(eCSession);
06083       CDataSource   *pCDataSource = SOURCE_GETPARENT(pCSession, CDataSource);
06084       CPropertiesDlg  sCPropertiesDlg(m_pCMainWindow);
06085
06086       //SetProperties
06087       sCPropertiesDlg.SetProperties(hWndCtrl, &DBPROPSET_COLUMNALL, IID_IDBProperties, NULL, pCDataSource ? pCDataSource->m_pIDBProperties : NULL, &m_CPropSets);
06088       return TRUE;
06089     }
06090   }
06091
06092   return FALSE;
06093 } //CAlterColumnDlg::OnCommand
06094
06095
06096 /////////////////////////////////////////////////////////////////////
06097 // CAlterColumnDlg::OnCommandNotify
06098 //
06099 /////////////////////////////////////////////////////////////////////
06100 BOOL CAlterColumnDlg::OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl)
06101 {
06102   switch(wNotifyCode)
06103   {
06104     case CBN_SELCHANGE:
06105     {
06106       if(OnSelChange(iID, hWndCtrl))
06107         return TRUE;
06108       break;
06109     }
06110   };
06111
06112   //Otherwise Delegate
06113   return CDialogLite::OnCommandNotify(wNotifyCode, iID, hWndCtrl);
06114 } // CAlterColumnDlg::OnCommandNotify
06115
06116
06117 /////////////////////////////////////////////////////////////////////////////
06118 // CAlterColumnDlg::OnSelChange
06119 //
06120 /////////////////////////////////////////////////////////////////////////////
06121 BOOL CAlterColumnDlg::OnSelChange(INT iID, HWND hWndCtrl)
06122 {
06123   static WCHAR      wszBuffer[MAX_NAME_LEN+1];
06124
06125   switch(iID)
06126   {
06127     case IDC_TYPENAME:
06128     {
06129       CMDIChild *pCMDIChild   = m_pCMDIChild;
06130       CSession  *pCSession    = (CSession*)pCMDIChild->GetObject(eCSession);
06131
06132       PROVTYPEINFO  *pTypeInfo  = NULL;
06133       pTypeInfo = (PROVTYPEINFO*)m_comboTypeName.GetItemParam(m_comboTypeName.GetCurSel());
06134
06135       if (pTypeInfo)
06136       {
06137         // select the corresponding DBTYPE
06138         wSendMessage(m_comboDBType.GetWnd(), CB_SELECTSTRING, -1, GetDBTypeName(pTypeInfo->wType));
06139
06140         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pTypeInfo->ulColumnSize);
06141         m_editSize.SetWindowText(wszBuffer);
06142
06143         if (IsNumericType(pTypeInfo->wType))
06144         {
06145           StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", pTypeInfo->ulColumnSize);
06146           m_editPrecision.SetWindowText(wszBuffer);
06147         }
06148         else
06149         {
06150           m_editPrecision.SetWindowText(L"0");
06151         }
06152       }
06153
06154       return TRUE;
06155     }
06156
06157     case IDC_TYPE:
06158     {
06159       CMDIChild *pCMDIChild   = m_pCMDIChild;
06160       CSession  *pCSession    = (CSession*)pCMDIChild->GetObject(eCSession);
06161       DBTYPE    wType;
06162       DBLENGTH ulMaxSize = 0;
06163       BYTE  bPrecision, bScale;
06164
06165       wType = (DBTYPE)m_comboDBType.GetItemParam(m_comboDBType.GetCurSel());
06166
06167
06168       //Get Default Size,Prec,Scale for this type...
06169       GetDBTypeMaxSize(wType, &ulMaxSize, &bPrecision, &bScale);
06170
06171       //Set Size
06172       wSendMessageFmt(m_editSize.GetWnd(), WM_SETTEXT, 0, L"%lu", ulMaxSize!=0 ? ulMaxSize : 255);
06173
06174       //Set Precision
06175       wSendMessageFmt(m_editPrecision.GetWnd(), WM_SETTEXT, 0, L"%d", bPrecision);
06176
06177       //Set Scale
06178       wSendMessageFmt(m_editScale.GetWnd(), WM_SETTEXT, 0, L"%d", bScale);
06179
06180       // no type name
06181       m_comboTypeName.SetWindowText(L"");
06182       m_comboTypeName.SetCurSel(-1);
06183
06184       return TRUE;
06185     }
06186   };
06187
06188   return FALSE;
06189 } //CAlterColumnDlg::OnSelChange
06190
06191
06192
06193 /////////////////////////////////////////////////////////////////////////////
06194 // CAlterColumnDlg::OnOK
06195 //
06196 /////////////////////////////////////////////////////////////////////////////
06197 BOOL CAlterColumnDlg::OnOK()
06198 {
06199   CWaitCursor waitCursor;
06200   WCHAR   *pwszTableName  = NULL;
06201   WCHAR   *pwszColumnName = NULL;
06202   HRESULT   hr;
06203   const ULONG cMaxSel = 2;
06204   INDEX   cSel;
06205   INT     rgSel[cMaxSel];
06206   HWND    hWndCDFlags   = GetDlgItem(IDL_CDFLAGS);
06207   LONG    lValue;
06208   DBORDINAL index;
06209
06210   CMDIChild *pCMDIChild   = m_pCMDIChild;
06211   CSession  *pCSession    = (CSession*)pCMDIChild->GetObject(eCSession);
06212
06213   PROVTYPEINFO  *pTypeInfo  = NULL;
06214
06215   pwszTableName = m_editTableName.GetWindowText();
06216   if (pwszTableName)
06217   {
06218     SAFE_ALLOC(m_pTableID, DBID, 1);
06219     m_pTableID->eKind     = DBKIND_NAME;
06220     m_pTableID->uName.pwszName  = pwszTableName;
06221   }
06222
06223   pwszColumnName = m_editColumnName.GetWindowText();
06224   if (pwszColumnName)
06225   {
06226     SAFE_ALLOC(m_pColumnID, DBID, 1);
06227     m_pColumnID->eKind      = DBKIND_NAME;
06228     m_pColumnID->uName.pwszName = pwszColumnName;
06229   }
06230
06231   // fill in the flags
06232   cSel = SendMessage(hWndCDFlags, LB_GETSELITEMS, (WPARAM)cMaxSel, (LPARAM)rgSel);
06233
06234   m_dwColFlags = 0;
06235   for (index = 0; index < (ULONG)cSel; index++)
06236   {
06237     m_dwColFlags |= this->m_listColumnDescFlags.GetItemParam(rgSel[index]);
06238   }
06239
06240   // fill in the DBCOLUMNDESC structure
06241   memset(&m_ColDesc, 0, sizeof(DBCOLUMNDESC));
06242
06243   // set column name
06244   pwszColumnName = m_editNewColumnName.GetWindowText();
06245   if (pwszColumnName)
06246   {
06247     m_ColDesc.dbcid.eKind     = DBKIND_NAME;
06248     m_ColDesc.dbcid.uName.pwszName  = pwszColumnName;
06249   }
06250
06251   // get type name
06252   if (LB_ERR != m_comboTypeName.GetCurSel())
06253   {
06254     pTypeInfo = (PROVTYPEINFO*)m_comboTypeName.GetItemParam(m_comboTypeName.GetCurSel());
06255     m_ColDesc.pwszTypeName = wcsDuplicate(pTypeInfo->wszTypeName);
06256   }
06257   else
06258   {
06259     // it might be another value
06260     m_ColDesc.pwszTypeName = m_comboTypeName.GetWindowText();
06261   }
06262
06263   // get wType
06264   m_ColDesc.wType = (DBTYPE)m_comboDBType.GetItemParam(m_comboDBType.GetCurSel());
06265
06266   // get column size
06267   lValue = 0;
06268   GetEditBoxValue(m_editSize.GetWnd(), &lValue, 0/*Min*/, LONG_MAX/*Max*/, TRUE);
06269   m_ColDesc.ulColumnSize = lValue;
06270
06271   // get precision
06272   GetEditBoxValue(m_editPrecision.GetWnd(), &lValue, 0/*Min*/, 255/*Max*/, TRUE);
06273   m_ColDesc.bPrecision = (BYTE)lValue;
06274
06275   // get size
06276   GetEditBoxValue(m_editScale.GetWnd(), &lValue, 0/*Min*/, 255/*Max*/, TRUE);
06277   m_ColDesc.bScale = (BYTE)lValue;
06278
06279   // get properties
06280   m_fUseColProps = IsDlgButtonChecked(IDB_USEPROPERTIES);
06281   if (m_fUseColProps)
06282   {
06283     m_ColDesc.cPropertySets = m_CPropSets.GetCount();
06284     m_ColDesc.rgPropertySets= m_CPropSets.GetPropSets();
06285   }
06286
06287 CLEANUP:
06288   //Delegate
06289   return CDialogLite::OnOK();
06290 } //CAlterColumnDlg::OnOK
06291
06292
06293
06294 ////////////////////////////////////////////////////////////////
06295 // CExecuteParamDlg
06296 //
06297 /////////////////////////////////////////////////////////////////
06298 CExecuteParamDlg::CExecuteParamDlg(CMDIChild* pCMDIChild)
06299   : CDialogLite(IDD_PARAMEXECUTE), CRowsetViewerDlg(NULL, pCMDIChild)
06300 {
06301 }
06302
06303
06304 ////////////////////////////////////////////////////////////////
06305 // CExecuteParamDlg::OnInitDialog
06306 //
06307 /////////////////////////////////////////////////////////////////
06308 BOOL CExecuteParamDlg::OnInitDialog()
06309 {
06310   CWaitCursor waitCursor;
06311   WCHAR   wszBuffer[MAX_COL_SIZE];
06312
06313   //Command
06314   CCommand* pCCommand = SOURCE_GETOBJECT(m_pCMDIChild->m_pCSource, CCommand);
06315   CParameters& rParameters  = pCCommand->m_Parameters;
06316   CBindings&  rBindings   = rParameters.GetBindings();
06317   DB_UPARAMS cParamSets   = max(rParameters.GetParams().cParamSets, 1);
06318   DWORD dwConvFlags     = GetOptions()->m_dwConvFlags;
06319
06320   //Tab Control
06321   m_tabParamSets.CreateIndirect(m_hWnd, IDP_TABS);
06322
06323   //Add all the Tabs
06324   ASSERT(m_vecParams.GetCount() == 0);
06325   ASSERT(m_vecValues.GetCount() == 0);
06326   for(ULONG iParamSet=0; iParamSet<cParamSets; iParamSet++)
06327   {
06328     //Add the tab
06329     OnAddSet(iParamSet, rBindings.GetCount()==0/*fUseDefaults*/);
06330     CListViewLite* plistParams = m_vecParams[iParamSet];
06331     CListViewLite* plistValues = m_vecValues[iParamSet];
06332
06333     //Now add the previously setup data (if any)
06334     DBLENGTH  dbLength = 0;
06335     DBSTATUS  dbStatus = DBSTATUS_S_OK;
06336
06337     //Display the data for this paramset...
06338     for(ULONG i=0; i<rBindings.GetCount(); i++)
06339     {
06340       const DBBINDING* pBinding = &rBindings[i];
06341
06342       //Value
06343       //Get the Length, Status, Data for this Column
06344       pCCommand->GetColumnData(pBinding, rParameters.GetData(iParamSet), &dbStatus, &dbLength, NULL, wszBuffer, MAX_COL_SIZE, dwConvFlags, pBinding->wType);
06345
06346       //Insert the Data into the list (make an "easy" edit)
06347       plistValues->InsertItem(i, 0, wszBuffer, (LPARAM)pBinding->wType, 0);
06348
06349       //Insert Parameter Name
06350       StringFormat(wszBuffer, NUMELE(wszBuffer), L"Parameter %lu", i+1);
06351       plistParams->InsertItem(i, 0, wszBuffer);
06352
06353       //Insert the Length into the List
06354       if(LENGTH_IS_BOUND(*pBinding))
06355         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%lu", dbLength);
06356       else
06357         StringCopy(wszBuffer, L"Not Bound", MAX_COL_SIZE);
06358       plistParams->InsertItem(i, 1, wszBuffer);
06359
06360       //Insert the Status into the List
06361       plistParams->InsertItem(i, 2, STATUS_IS_BOUND(*pBinding) ? GetStatusName(dbStatus) : L"Not Bound");
06362
06363       //Set Item State to Checked/Unchecked
06364       plistParams->SetItemState(i, 0,  INDEXTOSTATEIMAGEMASK(STATE_CHECKED),  LVIS_STATEIMAGEMASK);
06365     }
06366
06367     //AutoSize column (now that the data is inserted)
06368     plistParams->SetColumnWidth(0,  LVSCW_AUTOSIZE_USEHEADER);
06369     plistParams->SetColumnWidth(1,  LVSCW_AUTOSIZE_USEHEADER);
06370     plistParams->SetColumnWidth(2,  LVSCW_AUTOSIZE_USEHEADER);
06371     plistValues->SetColumnWidth(0,  LVSCW_AUTOSIZE_USEHEADER);
06372   }
06373
06374   //Now activate the default Parameter Set
06375   m_tabParamSets.SetCurSel(0, TRUE/*fSendNotification*/);
06376   CenterDialog(m_hWnd);
06377   return CDialogLite::OnInitDialog();
06378 }
06379
06380
06381 ////////////////////////////////////////////////////////////////
06382 // CExecuteParamDlg::OnOK
06383 //
06384 /////////////////////////////////////////////////////////////////
06385 BOOL CExecuteParamDlg::OnOK()
06386 {
06387   CWaitCursor waitCursor;
06388
06389   //Get the "this" pointer
06390   CCommand* pCCommand = SOURCE_GETOBJECT(m_pCMDIChild->m_pCSource, CCommand);
06391   CParameters& rParameters = pCCommand->m_Parameters;
06392   HRESULT hr = S_OK;
06393
06394   //Setup ParamInfo
06395   DBPARAMINFO* rgParamInfo = NULL;
06396   DB_UPARAMS cParamsProv = 0;
06397   DBPARAMINFO* rgParamInfoProv = NULL;
06398   WCHAR* pwszNamesBuffer = NULL;
06399   WCHAR* pwszCommandText = NULL;
06400
06401   ULONG iParam,iParamSet = 0;
06402   DB_UPARAMS cParams = 0;
06403   DB_UPARAMS cParamSets = m_tabParamSets.GetItemCount();
06404
06405   //SetCommandText
06406   BOOL fSetCommandText = ::IsDlgButtonChecked(m_hWndParent, IDB_SETCOMMANDTEXT);
06407   BOOL fSetCommandStream = ::IsDlgButtonChecked(m_hWndParent, IDB_SETCOMMANDSTREAM);
06408
06409   //Obtain the number of parameters (Items) in the list
06410   //NOTE: Since all the sets have the same number of parameters, and we are
06411   //guareenteed at least one set, we only need to check the first set...
06412   cParams = m_vecParams[0]->GetItemCount();
06413   cParams = cParams == LVM_ERR ? 0 : cParams;
06414
06415   //Default ParameterInfo
06416   //NOTE: Some providers cannot derive parameter information
06417   //or the user may have only setup param info for some parameters, so by default
06418   //create parameter info for all params bound as INPUT and WSTR (or binding type).
06419   SAFE_ALLOC(rgParamInfo, DBPARAMINFO, cParams);
06420   for(iParam=0; iParam<cParams; iParam++)
06421   {
06422     //Setup the ParamInfo
06423     rgParamInfo[iParam].iOrdinal  = iParam+1;
06424     rgParamInfo[iParam].dwFlags   = DBPARAMFLAGS_ISINPUT;
06425     rgParamInfo[iParam].pwszName  = NULL;
06426     rgParamInfo[iParam].ulParamSize = MAX_COL_SIZE;
06427     rgParamInfo[iParam].pTypeInfo = NULL;
06428     rgParamInfo[iParam].wType   = GetOptions()->GetBindingType(DBTYPE_WSTR);
06429     rgParamInfo[iParam].bPrecision  = 0;
06430     rgParamInfo[iParam].bScale    = 0;
06431   }
06432
06433   //Did the user indicate they wanted to set the command text...
06434   if(fSetCommandText || fSetCommandStream)
06435   {
06436     //SetCommandText
06437     pwszCommandText = m_pCMDIChild->m_pCQueryBox->GetSelectedText();
06438     if(fSetCommandText)
06439       hr = pCCommand->SetCommandText(pwszCommandText);
06440     else
06441       hr = pCCommand->SetCommandStream(pwszCommandText);
06442
06443     //Prepare - we have to prepare for GetParameterInfo
06444     hr = pCCommand->Prepare(0);
06445   }
06446
06447   //Try to obtain more info about the params (native type for bindings)
06448   if(SUCCEEDED(hr = pCCommand->GetParameterInfo(&cParamsProv, &rgParamInfoProv, &pwszNamesBuffer)))
06449   {
06450     //Loop over the info returned from the provider
06451     for(ULONG iParam=0; iParam<cParamsProv; iParam++)
06452     {
06453       DBPARAMINFO* pParamInfo = &rgParamInfoProv[iParam];
06454
06455       //Update our default ParamInfo...
06456       if(pParamInfo->iOrdinal && pParamInfo->iOrdinal <= cParams)
06457       {
06458         //NOTE: Some providers seem not to be able to determine
06459         //if the parameter is input or output, and do not return any flags.
06460         //This will fail accessor creation, unless some flag is set, so turn
06461         //on INPUT if none of the directional flags are on...
06462         if(!BIT_SET(pParamInfo->dwFlags, DBPARAMFLAGS_ISINPUT) && !BIT_SET(pParamInfo->dwFlags, DBPARAMFLAGS_ISOUTPUT))
06463           pParamInfo->dwFlags |= DBPARAMFLAGS_ISINPUT;
06464
06465         ASSERT(rgParamInfo[pParamInfo->iOrdinal-1].iOrdinal == pParamInfo->iOrdinal);
06466         memcpy(&rgParamInfo[pParamInfo->iOrdinal-1], pParamInfo, sizeof(DBPARAMINFO));
06467       }
06468     }
06469   }
06470
06471   //Create Parameter Accessor
06472   TESTC(hr = pCCommand->CreateParamAccessor(cParams, rgParamInfo, cParamSets));
06473
06474   //Setup Data Buffer
06475   //Loop through all the parameter sets
06476   for(iParamSet=0; iParamSet<cParamSets; iParamSet++)
06477     TESTC(hr = m_pCMDIChild->GetListViewValues(m_vecParams[iParamSet]->m_hWnd, m_vecValues[iParamSet]->m_hWnd, pCCommand, rParameters.GetBindings(), rParameters.GetData(iParamSet)));
06478
06479 CLEANUP:
06480   SAFE_FREE(rgParamInfo);
06481   SAFE_FREE(rgParamInfoProv);
06482   SAFE_FREE(pwszNamesBuffer);
06483   SAFE_FREE(pwszCommandText);
06484
06485   //Don't exit if we can't successfully create a parameter from the data entered...
06486   if(FAILED(hr))
06487     return FALSE;
06488
06489   //Remove all the sets...
06490   //NOTE: Since were actually removing the tab, the indexes compact, so
06491   //we only need to keep removing the first tab...
06492   for(iParamSet=0; iParamSet<cParamSets; iParamSet++)
06493     OnDelSet(0);
06494   return CDialogLite::OnOK();
06495 }
06496
06497
06498 ////////////////////////////////////////////////////////////////
06499 // CExecuteParamDlg::OnCancel
06500 //
06501 /////////////////////////////////////////////////////////////////
06502 BOOL CExecuteParamDlg::OnCancel()
06503 {
06504   //Remove all the sets...
06505   //NOTE: Since were actually removing the tab, the indexes compact, so
06506   //we only need to keep removing the first tab...
06507   INDEX cParamSets = m_tabParamSets.GetItemCount();
06508   for(INDEX i=0; i<cParamSets; i++)
06509     OnDelSet(0);
06510
06511   //Delegate
06512   return CDialogLite::OnCancel();
06513 }
06514
06515
06516 ////////////////////////////////////////////////////////////////
06517 // CExecuteParamDlg::OnAddParameter
06518 //
06519 /////////////////////////////////////////////////////////////////
06520 BOOL CExecuteParamDlg::OnAddParameter()
06521 {
06522   WCHAR wszBuffer[MAX_NAME_LEN];
06523
06524   //Loop over all paramsets...
06525   for(INDEX iParamSet=0; iParamSet<m_tabParamSets.GetItemCount(); iParamSet++)
06526   {
06527     //Make our lives easier
06528     CListViewLite* plistParams = m_vecParams[iParamSet];
06529     CListViewLite* plistValues = m_vecValues[iParamSet];
06530
06531     //Get the Total Number of ListView Items
06532     INDEX cItems = plistParams->GetItemCount();
06533     if(cItems != LVM_ERR)
06534     {
06535       //Insert a new Parameter
06536       StringFormat(wszBuffer, NUMELE(wszBuffer), L"Parameter %lu", cItems+1);
06537       plistParams->InsertItem(cItems, 0,  wszBuffer);
06538       plistParams->InsertItem(cItems, 1,  L"0");
06539       plistParams->InsertItem(cItems, 2,  L"DBSTATUS_S_OK");
06540       plistValues->InsertItem(cItems, 0,  L"Enter Parameter Value...");
06541
06542       //Set Item State to Checked/Unchecked
06543       plistParams->SetItemState(cItems, 0,  INDEXTOSTATEIMAGEMASK(STATE_CHECKED),  LVIS_STATEIMAGEMASK);
06544     }
06545   }
06546
06547   return TRUE;
06548 }
06549
06550
06551 ////////////////////////////////////////////////////////////////
06552 // CExecuteParamDlg::OnDelParameter
06553 //
06554 /////////////////////////////////////////////////////////////////
06555 BOOL CExecuteParamDlg::OnDelParameter()
06556 {
06557   //Loop over all paramsets...
06558   for(INDEX iParamSet=0; iParamSet<m_tabParamSets.GetItemCount(); iParamSet++)
06559   {
06560     //Make our lives easier
06561     CListViewLite* plistParams = m_vecParams[iParamSet];
06562     CListViewLite* plistValues = m_vecValues[iParamSet];
06563
06564     //Get the Total Number of ListView Items
06565     INDEX cItems = plistParams->GetItemCount();
06566     if(cItems != LVM_ERR)
06567     {
06568       //Delete the Last Item
06569       plistParams->DeleteItem(cItems-1);
06570       plistValues->DeleteItem(cItems-1);
06571     }
06572   }
06573   return TRUE;
06574 }
06575
06576
06577 /////////////////////////////////////////////////////////////////
06578 // CExecuteParamDlg::OnAddSet
06579 //
06580 /////////////////////////////////////////////////////////////////
06581 BOOL CExecuteParamDlg::OnAddSet(INDEX iParamSet, BOOL fUseDefaults)
06582 {
06583   //Add the new Tab
06584   WCHAR wszBuffer[MAX_NAME_LEN];
06585   StringFormat(wszBuffer, NUMELE(wszBuffer), L"ParamSet %lu", iParamSet+1);
06586   m_tabParamSets.InsertItem(iParamSet, wszBuffer);
06587
06588   //Obtain the bounding rectangle
06589   //NOTE: We have to do this AFTER we insert the tab so that it includes
06590   //the vertical size of the tab, otherwise we will end up using the space
06591   //needed by the later inserted tab...
06592   RECT rect;
06593   GetClientRect(m_tabParamSets.m_hWnd, &rect);
06594   m_tabParamSets.AdjustRect(&rect);
06595   int  cxInside   = rect.right - rect.left;
06596   int  cyInside   = rect.bottom - rect.top;
06597
06598   //Create the Params ListView (dynamically...)
06599   CListViewLite* plistParams = new CListViewLite;
06600   plistParams->Create(m_tabParamSets.m_hWnd, WC_LISTVIEWW, NULL, IDL_PARAMNAMES,
06601                 WS_TABSTOP | WS_CHILD | /*WS_VISIBLE |*/ WS_BORDER | WS_VSCROLL | /*LVS_SINGLESEL |*/ LVS_AUTOARRANGE | LVS_REPORT | LVS_EDITLABELS | LVS_SHOWSELALWAYS, WS_EX_CLIENTEDGE,
06602                 rect.left, rect.top, cxInside/2, cyInside);
06603   m_vecParams.AddElement(plistParams);
06604
06605   //Create the Values ListView (dynamically...)
06606   CListViewLite* plistValues = new CListViewLite;
06607   plistValues->Create(m_tabParamSets.m_hWnd, WC_LISTVIEWW, NULL, IDL_PARAMVALUES,
06608                 WS_TABSTOP | WS_CHILD | /*WS_VISIBLE |*/ WS_BORDER | WS_VSCROLL | /*LVS_SINGLESEL |*/ LVS_AUTOARRANGE | LVS_REPORT | LVS_EDITLABELS | LVS_SHOWSELALWAYS, WS_EX_CLIENTEDGE,
06609                 rect.left + cxInside/2, rect.top, cxInside - cxInside/2, cyInside);
06610   m_vecValues.AddElement(plistValues);
06611
06612   //Use Extended ListView Styles!
06613   SendMessage(plistParams->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_CHECKBOXES);
06614   SendMessage(plistValues->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
06615
06616   //Set image list to the Window
06617   ListView_SetImageList(plistParams->m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_STATE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_STATE);
06618   ListView_SetImageList(plistValues->m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), LVSIL_SMALL);
06619
06620   //We need to the ListView
06621   //Headers/Columns contain ColInfo information
06622   //Rows are per columns
06623   plistParams->InsertColumn(0,  L"Parameter");
06624   plistParams->InsertColumn(1,  L"Length");
06625   plistParams->InsertColumn(2,  L"Status");
06626   plistValues->InsertColumn(0,  L"Value");
06627
06628   //This new set needs to have the same number of parameters as the first set...
06629   if(fUseDefaults)
06630   {
06631     INDEX cParams = max(m_vecParams[0]->GetItemCount(), 1);
06632     for(INDEX iParam=0; iParam<cParams; iParam++)
06633     {
06634       //Parameters
06635       StringFormat(wszBuffer, NUMELE(wszBuffer), L"Parameter %lu", iParam+1);
06636       plistParams->InsertItem(iParam, 0,  wszBuffer);
06637       plistParams->InsertItem(iParam, 1,  L"0");
06638       plistParams->InsertItem(iParam, 2,  L"DBSTATUS_S_OK");
06639       plistValues->InsertItem(iParam, 0,  L"Enter Parameter Value...");
06640     }
06641   }
06642
06643   //AutoSize column
06644   plistParams->SetColumnWidth(0,  LVSCW_AUTOSIZE_USEHEADER);
06645   plistParams->SetColumnWidth(1,  LVSCW_AUTOSIZE_USEHEADER);
06646   plistParams->SetColumnWidth(2,  LVSCW_AUTOSIZE_USEHEADER);
06647   plistValues->SetColumnWidth(0,  LVSCW_AUTOSIZE_USEHEADER);
06648
06649   //Now select this new tab
06650   m_tabParamSets.SetCurSel(iParamSet, TRUE/*fSendNotification*/);
06651   return TRUE;
06652 }
06653
06654
06655 ////////////////////////////////////////////////////////////////
06656 // CExecuteParamDlg::OnDelSet
06657 //
06658 /////////////////////////////////////////////////////////////////
06659 BOOL CExecuteParamDlg::OnDelSet(INDEX iParamSet)
06660 {
06661   INDEX cTabs = m_tabParamSets.GetItemCount();
06662   INDEX iNextTab = iParamSet<(cTabs-1) ? iParamSet+1 : max(0, iParamSet-1);
06663
06664   //Display the next tab (before deleting the previous selection)
06665   //ie: SelChanging needs to inform its going away...
06666   m_tabParamSets.SetCurSel(iNextTab, TRUE/*fSendNotification*/);
06667
06668   //Delete the Tab
06669   m_tabParamSets.DeleteItem(iParamSet);
06670
06671   //Now delete the dynamic listviews
06672   CListViewLite* plistParams = m_vecParams[iParamSet];
06673   plistParams->OnDestroy();
06674   SAFE_DELETE(plistParams);
06675
06676   //Now delete the dynamic listviews
06677   CListViewLite* plistValues = m_vecValues[iParamSet];
06678   plistValues->OnDestroy();
06679   SAFE_DELETE(plistValues);
06680
06681   //Now remove the listview from the vectors
06682   m_vecParams.RemoveAt(iParamSet);
06683   m_vecValues.RemoveAt(iParamSet);
06684
06685   //Refresh the tabs...
06686   m_tabParamSets.SetCurSel(m_tabParamSets.GetCurSel(), TRUE/*fSendNotification*/);
06687   return TRUE;
06688 }
06689
06690
06691 ////////////////////////////////////////////////////////////////
06692 // CExecuteParamDlg::OnStatusChange
06693 //
06694 /////////////////////////////////////////////////////////////////
06695 BOOL CExecuteParamDlg::OnStatusChange(DBSTATUS dbStatus)
06696 {
06697   CListViewLite* plistParams = GetActiveParam();
06698   if(plistParams)
06699   {
06700     //Insert the Status into the List
06701     INDEX iSelRow = plistParams->GetNextItem(-1, LVNI_SELECTED);
06702     if(iSelRow == LVM_ERR)
06703       return FALSE;
06704
06705     plistParams->InsertItem(iSelRow, 2, GetStatusName(dbStatus));
06706   }
06707   return TRUE;
06708 }
06709
06710
06711 ////////////////////////////////////////////////////////////////
06712 // CExecuteParamDlg::GetActiveParam
06713 //
06714 /////////////////////////////////////////////////////////////////
06715 CListViewLite*  CExecuteParamDlg::GetActiveParam()
06716 {
06717   //Obtain the active tab
06718   INDEX iParamSet = m_tabParamSets.GetCurSel();
06719   if(iParamSet == LVM_ERR)
06720     return NULL;
06721
06722   //Return the active listview
06723   return m_vecParams[iParamSet];
06724 }
06725
06726
06727 ////////////////////////////////////////////////////////////////
06728 // CExecuteParamDlg::GetActiveValue
06729 //
06730 /////////////////////////////////////////////////////////////////
06731 CListViewLite*  CExecuteParamDlg::GetActiveValue()
06732 {
06733   //Obtain the active tab
06734   INDEX iParamSet = m_tabParamSets.GetCurSel();
06735   if(iParamSet == LVM_ERR)
06736     return NULL;
06737
06738   //Return the active listview
06739   return m_vecValues[iParamSet];
06740 }
06741
06742
06743 ////////////////////////////////////////////////////////////////
06744 // CExecuteParamDlg::OnContextMenu
06745 //
06746 /////////////////////////////////////////////////////////////////
06747 BOOL CExecuteParamDlg::OnContextMenu(HWND hWnd, REFPOINTS pts)
06748 {
06749   //Obtain the active ListView
06750   CListViewLite* plistParams = GetActiveParam();
06751   if(plistParams)
06752   {
06753     //Must have selected a row to change status
06754     INDEX iSel = plistParams->GetNextItem(-1, LVNI_SELECTED);
06755     if(iSel == LVM_ERR)
06756       return FALSE;
06757
06758     //Make sure the Param listview is being selected.
06759     //NOTE: the hWnd of the control is the tab window, so we have to use
06760     //the hittest to correctly determine which child...
06761     //NOTE: ContextMenu is in Screen Coordinates
06762     if(plistParams->HitTest(pts, NULL, FALSE/*fClientCoords*/) != LVM_ERR)
06763     {
06764       //Display Menu
06765       DisplayContextMenu(
06766                 m_hWnd,
06767                 IDM_CHANGESTATUS,
06768                 pts,
06769                 m_hWnd
06770                 );
06771     }
06772   }
06773   return TRUE;
06774 }
06775
06776
06777 /////////////////////////////////////////////////////////////////////////////
06778 // CExecuteParamDlg::OnCommand
06779 //
06780 /////////////////////////////////////////////////////////////////////////////
06781 BOOL CExecuteParamDlg::OnCommand(UINT iID, HWND hWndCtrl)
06782 {
06783   switch(iID)
06784   {
06785     ON_COMMAND(IDB_ADD,         OnAddParameter())
06786     ON_COMMAND(IDB_DELETE,        OnDelParameter())
06787
06788     //WThe user always adds at the end..
06789     ON_COMMAND(IDB_ADDSET,        OnAddSet(m_tabParamSets.GetItemCount()))
06790
06791     //NOTE: We don't allow the user to delete the first (default) set...
06792     ON_COMMAND(IDB_DELETESET,     m_tabParamSets.GetItemCount()>1 ? OnDelSet(m_tabParamSets.GetItemCount()-1) : FALSE)
06793
06794     ON_COMMAND(IDM_DBSTATUS_S_OK,   OnStatusChange(DBSTATUS_S_OK))
06795     ON_COMMAND(IDM_DBSTATUS_S_ISNULL, OnStatusChange(DBSTATUS_S_ISNULL))
06796     ON_COMMAND(IDM_DBSTATUS_S_DEFAULT,  OnStatusChange(DBSTATUS_S_DEFAULT))
06797     ON_COMMAND(IDM_DBSTATUS_S_IGNORE, OnStatusChange(DBSTATUS_S_IGNORE))
06798   };
06799
06800   return FALSE;
06801 }
06802
06803
06804 /////////////////////////////////////////////////////////////////////
06805 // CExecuteParamDlg::OnNotify
06806 //
06807 /////////////////////////////////////////////////////////////////////
06808 BOOL CExecuteParamDlg::OnNotify(INT idCtrl, NMHDR* pNMHDR)
06809 {
06810   switch(pNMHDR->code)
06811   {
06812     case TCN_SELCHANGE:
06813     {
06814       if(pNMHDR->idFrom == IDP_TABS)
06815       {
06816         //Obtain the active listview
06817         CListViewLite* plistParams = GetActiveParam();
06818         CListViewLite* plistValues = GetActiveValue();
06819
06820         //Show the new active listviews
06821         if(plistParams && plistValues)
06822         {
06823           plistParams->ShowWindow(SW_SHOW);
06824           plistParams->UpdateWindow();
06825           plistValues->ShowWindow(SW_SHOW);
06826           plistValues->UpdateWindow();
06827         }
06828         return TRUE;
06829       }
06830
06831       return FALSE;
06832     }
06833
06834     case TCN_SELCHANGING:
06835     {
06836       if(pNMHDR->idFrom == IDP_TABS)
06837       {
06838         //Obtain the active listview
06839         CListViewLite* plistParams = GetActiveParam();
06840         CListViewLite* plistValues = GetActiveValue();
06841
06842         //Hide the old listviews
06843         if(plistParams && plistValues)
06844         {
06845           plistParams->ShowWindow(SW_HIDE);
06846           plistValues->ShowWindow(SW_HIDE);
06847         }
06848         return TRUE;
06849       }
06850
06851       return FALSE;
06852     }
06853
06854     //Since we have "TwoClickActive" on this will get sent
06855     //Whenever a row is clicked on twice!
06856     //This functionality used to be done with NM_DBCLK
06857     case LVN_ITEMACTIVATE:
06858     {
06859       //Obtain the active listview
06860       CListViewLite* plistValues = GetActiveValue();
06861       if(plistValues)
06862       {
06863         //Obtain the SelectedRow
06864         INDEX iSel = plistValues->GetNextItem(-1, LVNI_SELECTED);
06865         if(iSel == LVM_ERR)
06866           return FALSE;
06867
06868         //Now edit this label
06869         plistValues->EditLabel(iSel);
06870       }
06871       return TRUE;
06872     }
06873
06874     case LVN_BEGINLABELEDIT:
06875       return FALSE;//allow the user to change the value of the item.
06876
06877     case LVN_ENDLABELEDIT:
06878     {
06879       LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
06880
06881       //Obtain the active listview
06882       CListViewLite* plistValues = GetActiveValue();
06883       if(plistValues)
06884       {
06885         //Now update the ListView with the new value
06886         if(pDispInfo->item.pszText)
06887         {
06888
06889           WCHAR wszBuffer[MAX_NAME_LEN]={0};
06890           ConvertToWCHAR(pDispInfo->item.pszText, wszBuffer, MAX_NAME_LEN);
06891           plistValues->SetItemText(pDispInfo->item.iItem, 0, wszBuffer);
06892         }
06893       }
06894       return TRUE; //Allow the edited change
06895     }
06896
06897     case LVN_ITEMCHANGED:
06898     {
06899       NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
06900
06901       if(pNMListView->uNewState & LVNI_FOCUSED &&
06902         pNMListView->uNewState & LVNI_SELECTED)
06903       {
06904         //Obtain the active listview
06905         CListViewLite* plistParams = GetActiveParam();
06906         CListViewLite* plistValues = GetActiveValue();
06907         if(plistParams && plistValues)
06908         {
06909           if(idCtrl == IDL_PARAMVALUES)
06910           {
06911             SyncSibling(plistParams->m_hWnd, plistValues->m_hWnd);
06912                   return TRUE;
06913           }
06914
06915           if(idCtrl == IDL_PARAMNAMES)
06916           {
06917             SyncSibling(plistValues->m_hWnd, plistParams->m_hWnd);
06918             return TRUE;
06919           }
06920         }
06921         return FALSE;
06922       }
06923     }
06924   }
06925
06926   return FALSE;
06927 }
06928
06929
Generated on Wed Nov 13 2024 16:52:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIRow Member List

This is the complete list of members for CImpIRow, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRow, CImpIRow) | CImpIRow
GetColumns(DBORDINAL cColumns, DBCOLUMNACCESS rgColumns[]) | CImpIRow
GetSourceRowset(REFIID riid, IUnknown **ppRowset, HROW *phRow) | CImpIRow
Open(IUnknown *pIUnkOuter, DBID *pColumnID, REFGUID rguidColumnType, DWORD dwBindFlags, REFIID riid, IUnknown **ppUnk) | CImpIRow
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MidiPlyr/SMFREAD.c Source File

  • Multimedia
  • Audio
  • MidiPlyr

SMFREAD.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *
00003 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
00006 *  A PARTICULAR PURPOSE.
00007 *
00008 *  Copyright 1993 - 2000 Microsoft Corporation. All Rights Reserved.
00009 *
00010 ******************************************************************************
00011 *
00012 * SMFRead.C
00013 *
00014 * MIDI File access routines.
00015 *
00016 *****************************************************************************/
00017 #include <windows.h>
00018 #include <windowsx.h>
00019 #include <mmsystem.h>
00020 #include <memory.h>
00021 #include "muldiv32.h"
00022 #include "smf.h"
00023 #include "smfi.h"
00024 #include "debug.h"
00025
00026 PRIVATE UINT grbChanMsgLen[] =
00027 {
00028     0,                      /* 0x   not a status byte   */
00029     0,                      /* 1x   not a status byte   */
00030     0,                      /* 2x   not a status byte   */
00031     0,                      /* 3x   not a status byte   */
00032     0,                      /* 4x   not a status byte   */
00033     0,                      /* 5x   not a status byte   */
00034     0,                      /* 6x   not a status byte   */
00035     0,                      /* 7x   not a status byte   */
00036     3,                      /* 8x   Note off            */
00037     3,                      /* 9x   Note on             */
00038     3,                      /* Ax   Poly pressure       */
00039     3,                      /* Bx   Control change      */
00040     2,                      /* Cx   Program change      */
00041     2,                      /* Dx   Chan pressure       */
00042     3,                      /* Ex   Pitch bend change   */
00043     0,                      /* Fx   SysEx (see below)   */
00044 } ;
00045
00046 /******************************************************************************
00047 *
00048 * smfBuildFileIndex
00049 *
00050 * Preliminary parsing of a MIDI file.
00051 *
00052 * ppSmf                     - Pointer to a returned SMF structure if the
00053 *                             file is successfully parsed.
00054 *
00055 * Returns
00056 *   SMF_SUCCESS The events were successfully read.
00057 *   SMF_NO_MEMORY Out of memory to build key frames.
00058 *   SMF_INVALID_FILE A disk or parse error occured on the file.
00059 *
00060 * This function validates the format of and existing MIDI or RMI file
00061 * and builds the handle structure which will refer to it for the
00062 * lifetime of the instance.
00063 *
00064 * The file header information will be read and verified, and
00065 * smfBuildTrackIndices will be called on every existing track
00066 * to build keyframes and validate the track format.
00067 *
00068 *****************************************************************************/
00069 SMFRESULT FNLOCAL smfBuildFileIndex(
00070     PSMF BSTACK *           ppSmf)
00071 {
00072     SMFRESULT               smfrc;
00073     UNALIGNED CHUNKHDR *    pCh;
00074     FILEHDR FAR *           pFh;
00075     DWORD                   idx;
00076     PSMF                    pSmf,
00077                             pSmfTemp;
00078     PTRACK                  pTrk;
00079     WORD                    wMemory;
00080     DWORD                   dwLeft;
00081     HPBYTE                  hpbImage;
00082
00083     DWORD                   idxTrack;
00084     EVENT                   event;
00085     BOOL                    fFirst;
00086     DWORD                   dwLength;
00087     HLOCAL                  hLocal;
00088     PTEMPOMAPENTRY          pTempo;
00089
00090     assert(ppSmf != NULL);
00091
00092     pSmf = *ppSmf;
00093
00094     assert(pSmf != NULL);
00095
00096     /* MIDI data image is already in hpbImage (already extracted from
00097     ** RIFF header if necessary).
00098     */
00099
00100     /* Validate MIDI header
00101     */
00102     dwLeft   = pSmf->cbImage;
00103     hpbImage = pSmf->hpbImage;
00104
00105     if (dwLeft < sizeof(CHUNKHDR))
00106         return SMF_INVALID_FILE;
00107
00108     pCh = (CHUNKHDR FAR *)hpbImage;
00109
00110     dwLeft   -= sizeof(CHUNKHDR);
00111     hpbImage += sizeof(CHUNKHDR);
00112
00113     if (pCh->fourccType != FOURCC_MThd)
00114         return SMF_INVALID_FILE;
00115
00116     dwLength = DWORDSWAP(pCh->dwLength);
00117     if (dwLength < sizeof(FILEHDR) || dwLength > dwLeft)
00118         return SMF_INVALID_FILE;
00119
00120     pFh = (FILEHDR FAR *)hpbImage;
00121
00122     dwLeft   -= dwLength;
00123     hpbImage += dwLength;
00124
00125     pSmf->dwFormat       = (DWORD)(WORDSWAP(pFh->wFormat));
00126     pSmf->dwTracks       = (DWORD)(WORDSWAP(pFh->wTracks));
00127     pSmf->dwTimeDivision = (DWORD)(WORDSWAP(pFh->wDivision));
00128
00129     /*
00130     ** We've successfully parsed the header. Now try to build the track
00131     ** index.
00132     **
00133     ** We only check out the track header chunk here; the track will be
00134     ** preparsed after we do a quick integretiy check.
00135     */
00136     wMemory = sizeof(SMF) + (WORD)(pSmf->dwTracks*sizeof(TRACK));
00137     pSmfTemp = (PSMF)LocalReAlloc((HLOCAL)pSmf, wMemory, LMEM_MOVEABLE|LMEM_ZEROINIT);
00138
00139     if (NULL == pSmfTemp)
00140     {
00141         DPF(1, "No memory for extended pSmf");
00142         return SMF_NO_MEMORY;
00143     }
00144
00145     pSmf = *ppSmf = pSmfTemp;
00146     pTrk = pSmf->rTracks;
00147
00148     for (idx=0; idx<pSmf->dwTracks; idx++)
00149     {
00150         if (dwLeft < sizeof(CHUNKHDR))
00151             return SMF_INVALID_FILE;
00152
00153         pCh = (CHUNKHDR FAR *)hpbImage;
00154
00155         dwLeft   -= sizeof(CHUNKHDR);
00156         hpbImage += sizeof(CHUNKHDR);
00157
00158         if (pCh->fourccType != FOURCC_MTrk)
00159             return SMF_INVALID_FILE;
00160
00161         pTrk->idxTrack      = (DWORD)(hpbImage - pSmf->hpbImage);
00162         pTrk->smti.cbLength = DWORDSWAP(pCh->dwLength);
00163
00164         if (pTrk->smti.cbLength > dwLeft)
00165         {
00166             DPF(1, "Track longer than file!");
00167             return SMF_INVALID_FILE;
00168         }
00169
00170         dwLeft   -= pTrk->smti.cbLength;
00171         hpbImage += pTrk->smti.cbLength;
00172
00173         pTrk++;
00174     }
00175
00176     /* File looks OK. Now preparse, doing the following:
00177     ** (1) Build tempo map so we can convert to/from ticks quickly
00178     ** (2) Determine actual tick length of file
00179     ** (3) Validate all events in all tracks
00180     */
00181     pSmf->tkPosition = 0;
00182     pSmf->fdwSMF &= ~SMF_F_EOF;
00183
00184     for (pTrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; pTrk++)
00185     {
00186         pTrk->pSmf              = pSmf;
00187         pTrk->tkPosition        = 0;
00188         pTrk->cbLeft            = pTrk->smti.cbLength;
00189         pTrk->hpbImage          = pSmf->hpbImage + pTrk->idxTrack;
00190         pTrk->bRunningStatus    = 0;
00191         pTrk->fdwTrack          = 0;
00192     }
00193
00194     while (SMF_SUCCESS == (smfrc = smfGetNextEvent(pSmf, (EVENT BSTACK *)&event, MAX_TICKS)))
00195     {
00196         if (MIDI_META == event.abEvent[0] &&
00197             MIDI_META_TEMPO == event.abEvent[1])
00198         {
00199             if (3 != event.cbParm)
00200             {
00201                 return SMF_INVALID_FILE;
00202             }
00203
00204             if (pSmf->cTempoMap == pSmf->cTempoMapAlloc)
00205             {
00206                 if (NULL != pSmf->hTempoMap)
00207                 {
00208                     LocalUnlock(pSmf->hTempoMap);
00209                 }
00210
00211                 pSmf->cTempoMapAlloc += C_TEMPO_MAP_CHK;
00212                 fFirst = FALSE;
00213                 if (0 == pSmf->cTempoMap)
00214                 {
00215                     hLocal = LocalAlloc(LHND, (UINT)(pSmf->cTempoMapAlloc*sizeof(TEMPOMAPENTRY)));
00216                     fFirst = TRUE;
00217                 }
00218                 else
00219                 {
00220                     hLocal = LocalReAlloc(pSmf->hTempoMap, (UINT)(pSmf->cTempoMapAlloc*sizeof(TEMPOMAPENTRY)), LHND);
00221                 }
00222
00223                 if (NULL == hLocal)
00224                 {
00225                     return SMF_NO_MEMORY;
00226                 }
00227
00228                 pSmf->pTempoMap = (PTEMPOMAPENTRY)LocalLock(pSmf->hTempoMap = hLocal);
00229             }
00230
00231             if (fFirst && pSmf->tkPosition != 0)
00232             {
00233                 /* Inserting first event and the absolute time is zero.
00234                 ** Use defaults of 500,000 uSec/qn from MIDI spec
00235                 */
00236
00237                 pTempo = &pSmf->pTempoMap[pSmf->cTempoMap++];
00238
00239                 pTempo->tkTempo = 0;
00240                 pTempo->msBase  = 0;
00241                 pTempo->dwTempo = MIDI_DEFAULT_TEMPO;
00242
00243                 fFirst = FALSE;
00244             }
00245
00246             pTempo = &pSmf->pTempoMap[pSmf->cTempoMap++];
00247
00248             pTempo->tkTempo = pSmf->tkPosition;
00249             if (fFirst)
00250                 pTempo->msBase = 0;
00251             else
00252             {
00253                 /* NOTE: Better not be here unless we're q/n format!
00254                 */
00255                 pTempo->msBase = (pTempo-1)->msBase +
00256                                  muldiv32(pTempo->tkTempo-((pTempo-1)->tkTempo),
00257                                           (pTempo-1)->dwTempo,
00258                                           1000L*pSmf->dwTimeDivision);
00259             }
00260             pTempo->dwTempo = (((DWORD)event.hpbParm[0])<<16)|
00261                               (((DWORD)event.hpbParm[1])<<8)|
00262                               ((DWORD)event.hpbParm[2]);
00263         }
00264     }
00265
00266   if (0 == pSmf->cTempoMap)
00267   {
00268     DPF(1, "File contains no tempo map! Insert default tempo.");
00269
00270     hLocal = LocalAlloc(LHND, sizeof(TEMPOMAPENTRY));
00271     if (!hLocal)
00272       return SMF_NO_MEMORY;
00273
00274         pSmf->pTempoMap = (PTEMPOMAPENTRY)LocalLock(pSmf->hTempoMap = hLocal);
00275     pSmf->cTempoMap = 1;
00276     pSmf->cTempoMapAlloc = 1;
00277
00278     pSmf->pTempoMap->tkTempo = 0;
00279         pSmf->pTempoMap->msBase  = 0;
00280         pSmf->pTempoMap->dwTempo = MIDI_DEFAULT_TEMPO;
00281   }
00282
00283     if (SMF_END_OF_FILE == smfrc || SMF_SUCCESS == smfrc)
00284     {
00285         pSmf->tkLength = pSmf->tkPosition;
00286         smfrc = SMF_SUCCESS;
00287     }
00288
00289     return smfrc;
00290 }
00291
00292 /******************************************************************************
00293 *
00294 * smfGetNextEvent
00295 *
00296 * Read the next event from the given file.
00297 *
00298 * pSmf                      - File to read the event from.
00299 *
00300 * pEvent                    - Pointer to an event structure which will receive
00301 *                             basic information about the event.
00302 *
00303 * tkMax                     - Tick destination. An attempt to read past this
00304 *                             position in the file will fail.
00305 *
00306 * Returns
00307 *   SMF_SUCCESS The events were successfully read.
00308 *   SMF_END_OF_FILE There are no more events to read in this track.
00309 *   SMF_REACHED_TKMAX No event was read because <p tkMax> was reached.
00310 *   SMF_INVALID_FILE A disk or parse error occured on the file.
00311 *
00312 * This is the lowest level of parsing for a raw MIDI stream. The basic
00313 * information about one event in the file will be returned in pEvent.
00314 *
00315 * Merging data from all tracks into one stream is performed here.
00316 *
00317 * pEvent->tkDelta will contain the tick delta for the event.
00318 *
00319 * pEvent->abEvent will contain a description of the event.
00320 *  pevent->abEvent[0] will contain
00321 *    F0 or F7 for a System Exclusive message.
00322 *    FF for a MIDI file meta event.
00323 *    The status byte of any other MIDI message. (Running status will
00324 *    be tracked and expanded).
00325 *
00326 * pEvent->cbParm will contain the number of bytes of paramter data
00327 *   which is still in the file behind the event header already read.
00328 *   This data may be read with <f smfGetTrackEventData>. Any unread
00329 *   data will be skipped on the next call to <f smfGetNextTrackEvent>.
00330 *
00331 * Channel messages (0x8? - 0xE?) will always be returned fully in
00332 *   pevent->abEvent.
00333 *
00334 *  Meta events will contain the meta type in pevent->abEvent[1].
00335 *
00336 *  System exclusive events will contain only an 0xF0 or 0xF7 in
00337 *    pevent->abEvent[0].
00338 *
00339 *  The following fields in pTrk are used to maintain state and must
00340 *  be updated if a seek-in-track is performed:
00341 *
00342 *  bRunningStatus contains the last running status message or 0 if
00343 *   there is no valid running status.
00344 *
00345 *  hpbImage is a pointer into the file image of the first byte of
00346 *   the event to follow the event just read.
00347 *
00348 *  dwLeft contains the number of bytes from hpbImage to the end
00349 *   of the track.
00350 *
00351 *
00352 * Get the next due event from all (in-use?) tracks
00353 *
00354 * For all tracks
00355 *  If not end-of-track
00356 *   decode event delta time without advancing through buffer
00357 *   event_absolute_time = track_tick_time + track_event_delta_time
00358 *   relative_time = event_absolute_time - last_stream_time
00359 *   if relative_time is lowest so far
00360 *    save this track as the next to pull from, along with times
00361 *
00362 * If we found a track with a due event
00363 *  Advance track pointer past event, saving ptr to parm data if needed
00364 *  track_tick_time += track_event_delta_time
00365 *  last_stream_time = track_tick_time
00366 * Else
00367 *  Mark and return end_of_file
00368 *
00369 *****************************************************************************/
00370 SMFRESULT FNLOCAL smfGetNextEvent(
00371     PSMF                    pSmf,
00372     EVENT BSTACK *          pEvent,
00373     TICKS                   tkMax)
00374 {
00375     PTRACK                  pTrk;
00376     PTRACK                  pTrkFound;
00377     DWORD                   idxTrack;
00378     TICKS                   tkEventDelta;
00379     TICKS                   tkRelTime;
00380     TICKS                   tkMinRelTime;
00381     BYTE                    bEvent;
00382     DWORD                   dwGotTotal;
00383     DWORD                   dwGot;
00384     DWORD                   cbEvent;
00385
00386     assert(pSmf != NULL);
00387     assert(pEvent != NULL);
00388
00389     if (pSmf->fdwSMF & SMF_F_EOF)
00390     {
00391         return SMF_END_OF_FILE;
00392     }
00393
00394     pTrkFound       = NULL;
00395     tkMinRelTime    = MAX_TICKS;
00396
00397     for (pTrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; pTrk++)
00398     {
00399         if (pTrk->fdwTrack & SMF_TF_EOT)
00400             continue;
00401
00402
00403         if (!smfGetVDword(pTrk->hpbImage, pTrk->cbLeft, (DWORD BSTACK *)&tkEventDelta))
00404         {
00405             DPF(1, "Hit end of track w/o end marker!");
00406             return SMF_INVALID_FILE;
00407         }
00408
00409         tkRelTime = pTrk->tkPosition + tkEventDelta - pSmf->tkPosition;
00410
00411         if (tkRelTime < tkMinRelTime)
00412         {
00413             tkMinRelTime = tkRelTime;
00414             pTrkFound = pTrk;
00415         }
00416     }
00417
00418     if (!pTrkFound)
00419     {
00420         pSmf->fdwSMF |= SMF_F_EOF;
00421         return SMF_END_OF_FILE;
00422     }
00423
00424     pTrk = pTrkFound;
00425
00426     if (pSmf->tkPosition + tkMinRelTime >= tkMax)
00427     {
00428         return SMF_REACHED_TKMAX;
00429     }
00430
00431
00432     pTrk->hpbImage += (dwGot = smfGetVDword(pTrk->hpbImage, pTrk->cbLeft, (DWORD BSTACK *)&tkEventDelta));
00433     pTrk->cbLeft   -= dwGot;
00434
00435     /* We MUST have at least three bytes here (cause we haven't hit
00436     ** the end-of-track meta yet, which is three bytes long). Checking
00437     ** against three means we don't have to check how much is left
00438     ** in the track again for any short event, which is most cases.
00439     */
00440     if (pTrk->cbLeft < 3)
00441     {
00442         return SMF_INVALID_FILE;
00443     }
00444
00445     pTrk->tkPosition += tkEventDelta;
00446     pEvent->tkDelta = pTrk->tkPosition - pSmf->tkPosition;
00447     pSmf->tkPosition = pTrk->tkPosition;
00448
00449     bEvent = *pTrk->hpbImage++;
00450
00451     if (MIDI_MSG > bEvent)
00452     {
00453         if (0 == pTrk->bRunningStatus)
00454         {
00455             return SMF_INVALID_FILE;
00456         }
00457
00458         dwGotTotal = 1;
00459         pEvent->abEvent[0] = pTrk->bRunningStatus;
00460         pEvent->abEvent[1] = bEvent;
00461         if (3 == grbChanMsgLen[(pTrk->bRunningStatus >> 4) & 0x0F])
00462         {
00463             pEvent->abEvent[2] = *pTrk->hpbImage++;
00464             dwGotTotal++;
00465         }
00466     }
00467     else if (MIDI_SYSEX > bEvent)
00468     {
00469         pTrk->bRunningStatus = bEvent;
00470
00471         dwGotTotal = 2;
00472         pEvent->abEvent[0] = bEvent;
00473         pEvent->abEvent[1] = *pTrk->hpbImage++;
00474         if (3 == grbChanMsgLen[(bEvent >> 4) & 0x0F])
00475         {
00476             pEvent->abEvent[2] = *pTrk->hpbImage++;
00477             dwGotTotal++;
00478         }
00479     }
00480     else
00481     {
00482         pTrk->bRunningStatus = 0;
00483         if (MIDI_META == bEvent)
00484         {
00485             pEvent->abEvent[0] = MIDI_META;
00486             if (MIDI_META_EOT == (pEvent->abEvent[1] = *pTrk->hpbImage++))
00487             {
00488                 pTrk->fdwTrack |= SMF_TF_EOT;
00489             }
00490
00491             dwGotTotal = 2;
00492         }
00493         else if (MIDI_SYSEX == bEvent || MIDI_SYSEXEND == bEvent)
00494         {
00495             pEvent->abEvent[0] = bEvent;
00496             dwGotTotal = 1;
00497         }
00498         else
00499         {
00500             return SMF_INVALID_FILE;
00501         }
00502
00503         if (0 == (dwGot = smfGetVDword(pTrk->hpbImage, pTrk->cbLeft - 2, (DWORD BSTACK *)&cbEvent)))
00504         {
00505             return SMF_INVALID_FILE;
00506         }
00507
00508         pTrk->hpbImage  += dwGot;
00509         dwGotTotal      += dwGot;
00510
00511         if (dwGotTotal + cbEvent > pTrk->cbLeft)
00512         {
00513             return SMF_INVALID_FILE;
00514         }
00515
00516         pEvent->cbParm  = cbEvent;
00517         pEvent->hpbParm = pTrk->hpbImage;
00518
00519         pTrk->hpbImage += cbEvent;
00520         dwGotTotal     += cbEvent;
00521     }
00522
00523     assert(pTrk->cbLeft >= dwGotTotal);
00524
00525     pTrk->cbLeft -= dwGotTotal;
00526
00527     return SMF_SUCCESS;
00528 }
00529
00530 /******************************************************************************
00531 *
00532 * smfGetVDword
00533 *
00534 * Reads a variable length DWORD from the given file.
00535 *
00536 * hpbImage                  - Pointer to the first byte of the VDWORD.
00537 *
00538 * dwLeft                    - Bytes left in image
00539 *
00540 * pDw                       - Pointer to a DWORD to store the result in.
00541 *                             track.
00542 *
00543 * Returns the number of bytes consumed from the stream.
00544 *
00545 * A variable length DWORD stored in a MIDI file contains one or more
00546 * bytes. Each byte except the last has the high bit set; only the
00547 * low 7 bits are significant.
00548 *
00549 *****************************************************************************/
00550 DWORD FNLOCAL smfGetVDword(
00551     HPBYTE                  hpbImage,
00552     DWORD                   dwLeft,
00553     DWORD BSTACK *          pDw)
00554 {
00555     BYTE                    b;
00556     DWORD                   dwUsed  = 0;
00557
00558     assert(hpbImage != NULL);
00559     assert(pDw != NULL);
00560
00561     *pDw = 0;
00562
00563     do
00564     {
00565         if (!dwLeft)
00566         {
00567             return 0;
00568         }
00569
00570         b = *hpbImage++;
00571         dwLeft--;
00572         dwUsed++;
00573
00574         *pDw = (*pDw << 7) | (b & 0x7F);
00575     } while (b&0x80);
00576
00577     return dwUsed;
00578 }
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/ContMenu.Cpp Source File

  • WinUI
  • Shell
  • SampView

ContMenu.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ContMenu.cpp
00013
00014    Description:   CContextMenu implementation.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ContMenu.h"
00023 #include "Commands.h"
00024 #include "ShlView.h"
00025 #include <ShellApi.h>
00026
00027 /**************************************************************************
00028    global variables
00029 **************************************************************************/
00030
00031 #define MAX_VERB  64
00032
00033 typedef struct {
00034    TCHAR szVerb[MAX_VERB];
00035    DWORD dwCommand;
00036    }VERBMAPPING, FAR *LPVERBMAPPING;
00037
00038 VERBMAPPING g_VerbMap[] = {   TEXT("explore"),     IDM_EXPLORE,
00039                               TEXT("open"),        IDM_OPEN,
00040                               TEXT("delete"),      IDM_DELETE,
00041                               TEXT("rename"),      IDM_RENAME,
00042                               TEXT("copy"),        IDM_COPY,
00043                               TEXT("cut"),         IDM_CUT,
00044                               TEXT("paste"),       IDM_PASTE,
00045                               TEXT("NewFolder"),   IDM_NEW_FOLDER,
00046                               TEXT("NewItem"),     IDM_NEW_ITEM,
00047                               TEXT("ModifyData"),  IDM_MODIFY_DATA,
00048                               TEXT(""),            (DWORD)-1
00049                               };
00050
00051 /**************************************************************************
00052
00053    CContextMenu::CContextMenu()
00054
00055 **************************************************************************/
00056
00057 CContextMenu::CContextMenu(CShellFolder *psfParent, LPCITEMIDLIST *aPidls, UINT uItemCount)
00058 {
00059 g_DllRefCount++;
00060
00061 m_ObjRefCount = 1;
00062 m_aPidls = NULL;
00063 m_uItemCount = 0;
00064 m_fBackground = FALSE;
00065
00066 m_psfParent = psfParent;
00067 if(m_psfParent)
00068    m_psfParent->AddRef();
00069
00070 SHGetMalloc(&m_pMalloc);
00071 if(!m_pMalloc)
00072    {
00073    delete this;
00074    return;
00075    }
00076
00077 m_pPidlMgr = new CPidlMgr();
00078
00079 m_uItemCount = uItemCount;
00080
00081 if(m_uItemCount)
00082    {
00083    m_aPidls = AllocPidlTable(uItemCount);
00084    if(m_aPidls)
00085       {
00086       FillPidlTable(aPidls, uItemCount);
00087       }
00088    }
00089 else
00090    {
00091    m_fBackground = TRUE;
00092    }
00093
00094 m_cfPrivateData = RegisterClipboardFormat(CFSTR_SAMPVIEWDATA);
00095
00096 }
00097
00098 /**************************************************************************
00099
00100    CContextMenu::~CContextMenu()
00101
00102 **************************************************************************/
00103
00104 CContextMenu::~CContextMenu()
00105 {
00106 if(m_psfParent)
00107    m_psfParent->Release();
00108
00109 g_DllRefCount--;
00110
00111 //make sure the pidls are freed
00112 if(m_aPidls && m_pMalloc)
00113    {
00114    FreePidlTable(m_aPidls);
00115    }
00116
00117 if(m_pPidlMgr)
00118    delete m_pPidlMgr;
00119
00120 if(m_pMalloc)
00121    m_pMalloc->Release();
00122 }
00123
00124 ///////////////////////////////////////////////////////////////////////////
00125 //
00126 // IUnknown Implementation
00127 //
00128
00129 /**************************************************************************
00130
00131    CContextMenu::QueryInterface
00132
00133 **************************************************************************/
00134
00135 STDMETHODIMP CContextMenu::QueryInterface(   REFIID riid,
00136                                              LPVOID FAR * ppReturn)
00137 {
00138 *ppReturn = NULL;
00139
00140 if(IsEqualIID(riid, IID_IUnknown))
00141    {
00142    *ppReturn = (LPUNKNOWN)(LPCONTEXTMENU)this;
00143    }
00144
00145 if(IsEqualIID(riid, IID_IContextMenu))
00146    {
00147    *ppReturn = (LPCONTEXTMENU)this;
00148    }
00149
00150 if(IsEqualIID(riid, IID_IShellExtInit))
00151    {
00152    *ppReturn = (LPSHELLEXTINIT)this;
00153    }
00154
00155 if(*ppReturn)
00156    {
00157    (*(LPUNKNOWN*)ppReturn)->AddRef();
00158    return S_OK;
00159    }
00160
00161 return E_NOINTERFACE;
00162 }
00163
00164 /**************************************************************************
00165
00166    CContextMenu::AddRef
00167
00168 **************************************************************************/
00169
00170 STDMETHODIMP_(DWORD) CContextMenu::AddRef()
00171 {
00172 return ++m_ObjRefCount;
00173 }
00174
00175
00176 /**************************************************************************
00177
00178    CContextMenu::Release
00179
00180 **************************************************************************/
00181
00182 STDMETHODIMP_(DWORD) CContextMenu::Release()
00183 {
00184   if(--m_ObjRefCount == 0)
00185   {
00186       delete this;
00187       return 0;
00188   }
00189   return m_ObjRefCount;
00190 }
00191
00192 ///////////////////////////////////////////////////////////////////////////
00193 //
00194 // IContextMenu Implementation
00195 //
00196
00197 /**************************************************************************
00198
00199    CContextMenu::QueryContextMenu()
00200
00201 **************************************************************************/
00202
00203 STDMETHODIMP CContextMenu::QueryContextMenu( HMENU hMenu,
00204                                              UINT indexMenu,
00205                                              UINT idCmdFirst,
00206                                              UINT idCmdLast,
00207                                              UINT uFlags)
00208 {
00209 if(!(CMF_DEFAULTONLY & uFlags))
00210    {
00211    if(m_fBackground)
00212       {
00213       //add the menu items that apply to the background of the view
00214       InsertBackgroundItems(hMenu, indexMenu, idCmdFirst);
00215       }
00216    else
00217       {
00218       InsertItems(hMenu, indexMenu, idCmdFirst, uFlags);
00219       }
00220
00221    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_LAST + 1));
00222    }
00223 else
00224    {
00225    /*
00226    Just insert the default item.
00227    */
00228    MENUITEMINFO   mii;
00229    TCHAR          szText[MAX_PATH];
00230
00231    ZeroMemory(&mii, sizeof(mii));
00232    mii.cbSize = sizeof(mii);
00233
00234    if(CMF_EXPLORE & uFlags)
00235       {
00236       LoadString(g_hInst, IDS_EXPLORE, szText, sizeof(szText));
00237       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00238       mii.wID = idCmdFirst + IDM_EXPLORE;
00239       mii.fType = MFT_STRING;
00240       mii.dwTypeData = szText;
00241       mii.fState = MFS_ENABLED | MFS_DEFAULT;
00242       InsertMenuItem(   hMenu,
00243                         indexMenu++,
00244                         TRUE,
00245                         &mii);
00246       }
00247    else
00248       {
00249       LoadString(g_hInst, IDS_OPEN, szText, sizeof(szText));
00250       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00251       mii.wID = idCmdFirst + IDM_OPEN;
00252       mii.fType = MFT_STRING;
00253       mii.dwTypeData = szText;
00254       mii.fState = MFS_ENABLED | MFS_DEFAULT;
00255       InsertMenuItem(   hMenu,
00256                         indexMenu++,
00257                         TRUE,
00258                         &mii);
00259       }
00260
00261    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_LAST + 1));
00262    }
00263
00264 // Unreachable code
00265 //return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
00266 }
00267
00268 /**************************************************************************
00269
00270    CContextMenu::InvokeCommand()
00271
00272 **************************************************************************/
00273
00274 STDMETHODIMP CContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici)
00275 {
00276 LPCMINVOKECOMMANDINFOEX piciex;
00277
00278 if(pici->cbSize < sizeof(CMINVOKECOMMANDINFO))
00279    return E_INVALIDARG;
00280
00281 if(pici->cbSize >= sizeof(CMINVOKECOMMANDINFOEX) - sizeof(POINT))
00282    piciex = (LPCMINVOKECOMMANDINFOEX)pici;
00283 else
00284    piciex = NULL;
00285
00286 if(HIWORD(pici->lpVerb))
00287    {
00288    //the command is being sent via a verb
00289    LPCTSTR  pVerb;
00290
00291 #ifdef UNICODE
00292    BOOL  fUnicode = FALSE;
00293    WCHAR szVerb[MAX_PATH];
00294
00295    if(piciex && ((pici->fMask & CMIC_MASK_UNICODE) == CMIC_MASK_UNICODE))
00296       {
00297       fUnicode = TRUE;
00298       }
00299
00300    if(!fUnicode || piciex->lpVerbW == NULL)
00301       {
00302       MultiByteToWideChar( CP_ACP,
00303                            0,
00304                            pici->lpVerb,
00305                            -1,
00306                            szVerb,
00307                            ARRAYSIZE(szVerb));
00308       pVerb = szVerb;
00309       }
00310    else
00311       {
00312       pVerb = piciex->lpVerbW;
00313       }
00314 #else
00315    pVerb = pici->lpVerb;
00316 #endif   //UNICODE
00317
00318    //run through our list of verbs and get the command ID of the verb, if any
00319    int   i;
00320    for(i = 0; -1 != g_VerbMap[i].dwCommand; i++)
00321       {
00322       if(0 == lstrcmpi(pVerb, g_VerbMap[i].szVerb))
00323          {
00324          pici->lpVerb = (LPCSTR)MAKEINTRESOURCE(g_VerbMap[i].dwCommand);
00325          break;
00326          }
00327       }
00328    }
00329
00330 //this will also catch if an unsupported verb was specified
00331 if((DWORD_PTR)pici->lpVerb > IDM_LAST)
00332    return E_INVALIDARG;
00333
00334 switch(LOWORD(pici->lpVerb))
00335    {
00336    case IDM_EXPLORE:
00337       DoExplore(GetParent(pici->hwnd));
00338       break;
00339
00340    case IDM_OPEN:
00341       DoOpen(GetParent(pici->hwnd));
00342       break;
00343
00344    case IDM_NEW_FOLDER:
00345       DoNewFolder(pici->hwnd);
00346       break;
00347
00348    case IDM_NEW_ITEM:
00349       DoNewItem(pici->hwnd);
00350       break;
00351
00352    case IDM_MODIFY_DATA:
00353       DoModifyData(pici->hwnd);
00354       break;
00355
00356    case IDM_RENAME:
00357       DoRename(pici->hwnd);
00358       break;
00359
00360    case IDM_PASTE:
00361       DoPaste();
00362       break;
00363
00364    case IDM_CUT:
00365       DoCopyOrCut(pici->hwnd, TRUE);
00366       break;
00367
00368    case IDM_COPY:
00369       DoCopyOrCut(pici->hwnd, FALSE);
00370       break;
00371
00372    case IDM_DELETE:
00373       DoDelete();
00374       break;
00375
00376    }
00377
00378 return NOERROR;
00379 }
00380
00381 /**************************************************************************
00382
00383    CContextMenu::GetCommandString()
00384
00385 **************************************************************************/
00386
00387 STDMETHODIMP CContextMenu::GetCommandString( UINT_PTR idCommand,
00388                                              UINT uFlags,
00389                                              LPUINT lpReserved,
00390                                              LPSTR lpszName,
00391                                              UINT uMaxNameLen)
00392 {
00393 HRESULT  hr = E_INVALIDARG;
00394
00395 switch(uFlags)
00396    {
00397    case GCS_HELPTEXT:
00398       switch(idCommand)
00399          {
00400          case 0:
00401             hr = NOERROR;
00402             break;
00403          }
00404       break;
00405
00406    case GCS_VERBA:
00407       {
00408       int   i;
00409       for(i = 0; -1 != g_VerbMap[i].dwCommand; i++)
00410          {
00411          if(g_VerbMap[i].dwCommand == idCommand)
00412             {
00413             LocalToAnsi(lpszName, g_VerbMap[i].szVerb, uMaxNameLen);
00414             hr = NOERROR;
00415             break;
00416             }
00417          }
00418       }
00419       break;
00420
00421    /*
00422    NT 4.0 with IE 3.0x or no IE will always call this with GCS_VERBW. In this
00423    case, you need to do the lstrcpyW to the pointer passed.
00424    */
00425    case GCS_VERBW:
00426       {
00427       int   i;
00428       for(i = 0; -1 != g_VerbMap[i].dwCommand; i++)
00429          {
00430          if(g_VerbMap[i].dwCommand == idCommand)
00431             {
00432             LocalToWideChar((LPWSTR)lpszName, g_VerbMap[i].szVerb, uMaxNameLen);
00433             hr = NOERROR;
00434             break;
00435             }
00436          }
00437       }
00438       break;
00439
00440    case GCS_VALIDATE:
00441       hr = NOERROR;
00442       break;
00443    }
00444
00445 return hr;
00446 }
00447
00448 ///////////////////////////////////////////////////////////////////////////
00449 //
00450 // private and utility methods
00451 //
00452
00453 /**************************************************************************
00454
00455    CContextMenu::AllocPidlTable()
00456
00457 **************************************************************************/
00458
00459 LPITEMIDLIST* CContextMenu::AllocPidlTable(DWORD dwEntries)
00460 {
00461 LPITEMIDLIST   *aPidls;
00462
00463 dwEntries++;
00464
00465 aPidls = (LPITEMIDLIST*)m_pMalloc->Alloc(dwEntries * sizeof(LPITEMIDLIST));
00466
00467 if(aPidls)
00468    {
00469    //set all of the entries to NULL
00470    ZeroMemory(aPidls, dwEntries * sizeof(LPITEMIDLIST));
00471    }
00472
00473 return aPidls;
00474 }
00475
00476 /**************************************************************************
00477
00478    CContextMenu::FreePidlTable()
00479
00480 **************************************************************************/
00481
00482 VOID CContextMenu::FreePidlTable(LPITEMIDLIST *aPidls)
00483 {
00484 if(aPidls && m_pPidlMgr)
00485    {
00486    UINT  i;
00487    for(i = 0; aPidls[i]; i++)
00488       m_pPidlMgr->Delete(aPidls[i]);
00489
00490    m_pMalloc->Free(aPidls);
00491    }
00492 }
00493
00494 /**************************************************************************
00495
00496    CContextMenu::FillPidlTable()
00497
00498 **************************************************************************/
00499
00500 BOOL CContextMenu::FillPidlTable(LPCITEMIDLIST *aPidls, UINT uItemCount)
00501 {
00502 if(m_aPidls)
00503    {
00504    if(m_pPidlMgr)
00505       {
00506       UINT  i;
00507       for(i = 0; i < uItemCount; i++)
00508          {
00509          m_aPidls[i] = m_pPidlMgr->Copy(aPidls[i]);
00510          }
00511       return TRUE;
00512       }
00513    }
00514
00515 return FALSE;
00516 }
00517
00518 /**************************************************************************
00519
00520    CContextMenu::DoCopyOrCut()
00521
00522 **************************************************************************/
00523
00524 BOOL CContextMenu::DoCopyOrCut(HWND hWnd, BOOL fCut)
00525 {
00526 /*
00527 Copy the data to the clipboard. If this is a cut operation, mark the
00528 item as cut in the list. We will do this in the same way that the shell
00529 does it for the file system where the source data actually gets deleted
00530 when the paste operation occurs.
00531 */
00532 BOOL  fSuccess = FALSE;
00533
00534 if(OpenClipboard(NULL))
00535    {
00536    if(EmptyClipboard())
00537       {
00538       HGLOBAL        hMem;
00539       LPITEMIDLIST   pidlParent;
00540
00541       pidlParent = m_psfParent->CreateFQPidl(NULL);
00542
00543       if(pidlParent)
00544          {
00545          hMem = CreatePrivateClipboardData(pidlParent, m_aPidls, m_uItemCount, fCut);
00546
00547          if(SetClipboardData(m_cfPrivateData, hMem))
00548             {
00549             fSuccess = TRUE;
00550
00551             if(fCut)
00552                {
00553                CShellView  *pView = (CShellView*)GetViewInterface(hWnd);
00554
00555                if(pView)
00556                   {
00557                   pView->MarkItemsAsCut((LPCITEMIDLIST*)m_aPidls, m_uItemCount);
00558                   pView->Release();
00559                   }
00560                }
00561             }
00562          m_pPidlMgr->Delete(pidlParent);
00563          }
00564       }
00565
00566    CloseClipboard();
00567    }
00568
00569 return fSuccess;
00570 }
00571
00572 /**************************************************************************
00573
00574    CContextMenu::DoPaste()
00575
00576 **************************************************************************/
00577
00578 BOOL CContextMenu::DoPaste(VOID)
00579 {
00580 BOOL     fSuccess = FALSE;
00581 HGLOBAL  hMem;
00582
00583 OpenClipboard(NULL);
00584
00585 hMem = GetClipboardData(m_cfPrivateData);
00586
00587 if(hMem)
00588    {
00589    LPPRIVCLIPDATA pData = (LPPRIVCLIPDATA)GlobalLock(hMem);
00590
00591    if(pData)
00592       {
00593       BOOL           fCut = pData->fCut;
00594       CShellFolder   *psfFrom = NULL;
00595       IShellFolder   *psfDesktop;
00596       LPITEMIDLIST   pidl;
00597
00598       pidl = (LPITEMIDLIST)((LPBYTE)(pData) + pData->aoffset[0]);
00599       /*
00600       This is a fully qualified PIDL, so use the desktop folder to get the
00601       IShellFolder for this folder.
00602       */
00603       SHGetDesktopFolder(&psfDesktop);
00604       if(psfDesktop)
00605          {
00606          psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID*)&psfFrom);
00607          psfDesktop->Release();
00608          }
00609
00610       if(psfFrom)
00611          {
00612          LPITEMIDLIST   *aPidls;
00613
00614          //allocate an array of PIDLS
00615          aPidls = AllocPidlTable(pData->cidl - 1);
00616
00617          if(aPidls)
00618             {
00619             UINT  i;
00620
00621             //fill in the PIDL array
00622             for(i = 0; i < pData->cidl - 1; i++)
00623                {
00624                aPidls[i] = m_pPidlMgr->Copy((LPITEMIDLIST)((LPBYTE)(pData) + pData->aoffset[i + 1]));
00625                }
00626
00627             if(SUCCEEDED(m_psfParent->CopyItems(psfFrom, aPidls, pData->cidl - 1)))
00628                {
00629                fSuccess = TRUE;
00630
00631                if(fCut)
00632                   {
00633                   psfFrom->DeleteItems(aPidls, pData->cidl - 1);
00634                   }
00635                }
00636
00637             FreePidlTable(aPidls);
00638             }
00639
00640          psfFrom->Release();
00641          }
00642
00643       GlobalUnlock(hMem);
00644
00645       if(fSuccess && fCut)
00646          {
00647          //a successful cut and paste operation will remove the data from the clipboard
00648          EmptyClipboard();
00649          }
00650       }
00651    }
00652
00653 CloseClipboard();
00654
00655 return fSuccess;
00656 }
00657
00658 /**************************************************************************
00659
00660    CContextMenu::DoExplore()
00661
00662 **************************************************************************/
00663
00664 BOOL CContextMenu::DoExplore(HWND hWnd)
00665 {
00666 LPITEMIDLIST      pidlFQ;
00667 SHELLEXECUTEINFO  sei;
00668
00669 pidlFQ = m_psfParent->CreateFQPidl(m_aPidls[0]);
00670
00671 ZeroMemory(&sei, sizeof(sei));
00672 sei.cbSize = sizeof(sei);
00673 sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
00674 sei.lpIDList = pidlFQ;
00675 sei.lpClass = TEXT("folder");
00676 sei.hwnd = hWnd;
00677 sei.nShow = SW_SHOWNORMAL;
00678 sei.lpVerb = TEXT("explore");
00679
00680 BOOL fReturn = ShellExecuteEx(&sei);
00681
00682 m_pPidlMgr->Delete(pidlFQ);
00683
00684 return fReturn;
00685 }
00686
00687 /**************************************************************************
00688
00689    CContextMenu::DoOpen()
00690
00691 **************************************************************************/
00692
00693 BOOL CContextMenu::DoOpen(HWND hWnd)
00694 {
00695 LPITEMIDLIST      pidlFQ;
00696 SHELLEXECUTEINFO  sei;
00697
00698 pidlFQ = m_psfParent->CreateFQPidl(m_aPidls[0]);
00699
00700 ZeroMemory(&sei, sizeof(sei));
00701 sei.cbSize = sizeof(sei);
00702 sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
00703 sei.lpIDList = pidlFQ;
00704 sei.lpClass = TEXT("folder");
00705 sei.hwnd = hWnd;
00706 sei.nShow = SW_SHOWNORMAL;
00707 sei.lpVerb = TEXT("open");
00708
00709 BOOL fReturn = ShellExecuteEx(&sei);
00710
00711 m_pPidlMgr->Delete(pidlFQ);
00712
00713 return fReturn;
00714 }
00715
00716 /**************************************************************************
00717
00718    CContextMenu::DoDelete()
00719
00720 **************************************************************************/
00721
00722 STDMETHODIMP CContextMenu::DoDelete(VOID)
00723 {
00724 return m_psfParent->DeleteItems(m_aPidls, m_uItemCount);
00725 }
00726
00727 /**************************************************************************
00728
00729    CContextMenu::DoNewFolder()
00730
00731    Add the folder with the new folder name and then put the ListView into
00732    rename mode.
00733
00734 **************************************************************************/
00735
00736 STDMETHODIMP CContextMenu::DoNewFolder(HWND hWnd)
00737 {
00738 HRESULT        hr = E_FAIL;
00739 TCHAR          szName[MAX_PATH];
00740 LPITEMIDLIST   pidl;
00741
00742 m_psfParent->GetUniqueName(TRUE, szName, MAX_PATH);
00743 hr = m_psfParent->AddFolder(szName, &pidl);
00744 if(SUCCEEDED(hr))
00745    {
00746    /*
00747    CShellFolder::AddFolder should have added the new item. Tell the view to
00748    put the item into edit mode.
00749    */
00750    CShellView  *pView = (CShellView*)GetViewInterface(hWnd);
00751    if(pView)
00752       {
00753       pView->EditItem(pidl);
00754       pView->Release();
00755       }
00756
00757    m_pPidlMgr->Delete(pidl);
00758    }
00759
00760 return hr;
00761 }
00762
00763 /**************************************************************************
00764
00765    CContextMenu::DoNewItem()
00766
00767    Add the item with the new item name and then put the ListView into
00768    rename mode.
00769
00770 **************************************************************************/
00771
00772 STDMETHODIMP CContextMenu::DoNewItem(HWND hWnd)
00773 {
00774 HRESULT        hr;
00775 TCHAR          szName[MAX_PATH];
00776 LPITEMIDLIST   pidl;
00777
00778 m_psfParent->GetUniqueName(FALSE, szName, MAX_PATH);
00779 hr = m_psfParent->AddItem(szName, NULL, &pidl);
00780 if(SUCCEEDED(hr))
00781    {
00782    /*
00783    CShellFolder::AddItem should have added the new item. Tell the view to
00784    put the item into edit mode.
00785    */
00786    CShellView  *pView = (CShellView*)GetViewInterface(hWnd);
00787    if(pView)
00788       {
00789       pView->EditItem(pidl);
00790       pView->Release();
00791       }
00792
00793    m_pPidlMgr->Delete(pidl);
00794    }
00795
00796 return hr;
00797 }
00798
00799 /**************************************************************************
00800
00801    CContextMenu::DoRename()
00802
00803 **************************************************************************/
00804
00805 VOID CContextMenu::DoRename(HWND hWnd)
00806 {
00807 CShellView  *pView = (CShellView*)GetViewInterface(hWnd);
00808 if(pView)
00809    {
00810    pView->EditItem(m_aPidls[0]);
00811    pView->Release();
00812    }
00813 }
00814
00815 /**************************************************************************
00816
00817    CContextMenu::DoModifyData()
00818
00819 **************************************************************************/
00820
00821 BOOL CContextMenu::DoModifyData(HWND hwndList)
00822 {
00823 TCHAR    szData[MAX_DATA];
00824 INT_PTR  nRet;
00825
00826 //get the item's current data
00827 m_pPidlMgr->GetData(m_aPidls[0], szData, MAX_DATA);
00828
00829 nRet = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ITEMDATADLG), hwndList, (DLGPROC)ItemDataDlgProc, (LPARAM)szData);
00830
00831 if(IDOK == nRet)
00832    {
00833    m_psfParent->SetItemData(m_aPidls[0], szData);
00834
00835    return TRUE;
00836    }
00837
00838 return FALSE;
00839 }
00840
00841 /**************************************************************************
00842
00843    CContextMenu::InsertBackgroundItems()
00844
00845 **************************************************************************/
00846
00847 UINT CContextMenu::InsertBackgroundItems( HMENU hMenu,
00848                                           UINT indexMenu,
00849                                           UINT idCmdFirst)
00850 {
00851 HMENU          hPopup;
00852 TCHAR          szText[MAX_PATH];
00853 MENUITEMINFO   mii;
00854
00855 ZeroMemory(&mii, sizeof(mii));
00856 mii.cbSize = sizeof(mii);
00857
00858 //add the View submenu
00859 hPopup = CreatePopupMenu();
00860
00861 if(hPopup)
00862    {
00863    AddViewMenuItems(hPopup, idCmdFirst, (UINT)-1, TRUE);
00864
00865    LoadString(g_hInst, IDS_VIEW, szText, sizeof(szText));
00866    mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_SUBMENU;
00867    mii.wID = idCmdFirst + IDM_VIEW;
00868    mii.fType = MFT_STRING;
00869    mii.dwTypeData = szText;
00870    mii.fState = MFS_ENABLED;
00871    mii.hSubMenu = hPopup;
00872    InsertMenuItem(   hMenu,
00873                      indexMenu++,
00874                      TRUE,
00875                      &mii);
00876
00877    //only add a separator if needed
00878    mii.fMask = MIIM_TYPE;
00879    GetMenuItemInfo(hMenu, indexMenu, TRUE, &mii);
00880    if(!(mii.fType & MFT_SEPARATOR))
00881       {
00882       ZeroMemory(&mii, sizeof(mii));
00883       mii.cbSize = sizeof(mii);
00884       mii.fMask = MIIM_ID | MIIM_TYPE;
00885       mii.wID = 0;
00886       mii.fType = MFT_SEPARATOR;
00887       InsertMenuItem(   hMenu,
00888                         indexMenu++,
00889                         TRUE,
00890                         &mii);
00891       }
00892    }
00893
00894 indexMenu += AddFileMenuItems(hMenu, idCmdFirst, indexMenu, TRUE);
00895
00896 //only add a separator if needed
00897 mii.fMask = MIIM_TYPE;
00898 GetMenuItemInfo(hMenu, indexMenu, TRUE, &mii);
00899 if(!(mii.fType & MFT_SEPARATOR))
00900    {
00901    ZeroMemory(&mii, sizeof(mii));
00902    mii.cbSize = sizeof(mii);
00903    mii.fMask = MIIM_ID | MIIM_TYPE;
00904    mii.wID = 0;
00905    mii.fType = MFT_SEPARATOR;
00906    InsertMenuItem(   hMenu,
00907                      indexMenu++,
00908                      TRUE,
00909                      &mii);
00910    }
00911
00912 OpenClipboard(NULL);
00913 HGLOBAL  hClip = GetClipboardData(m_cfPrivateData);
00914 CloseClipboard();
00915
00916 LoadString(g_hInst, IDS_PASTE, szText, sizeof(szText));
00917 mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00918 mii.wID = idCmdFirst + IDM_PASTE;
00919 mii.fType = MFT_STRING;
00920 mii.dwTypeData = szText;
00921 mii.fState = (hClip ? MFS_ENABLED : MFS_DISABLED);
00922 InsertMenuItem(   hMenu,
00923                   indexMenu++,
00924                   TRUE,
00925                   &mii);
00926
00927 return indexMenu;
00928 }
00929
00930 /**************************************************************************
00931
00932    CContextMenu::InsertItems()
00933
00934 **************************************************************************/
00935
00936 UINT CContextMenu::InsertItems(  HMENU hMenu,
00937                                  UINT indexMenu,
00938                                  UINT idCmdFirst,
00939                                  UINT uFlags)
00940 {
00941 MENUITEMINFO   mii;
00942 TCHAR          szText[MAX_PATH];
00943 BOOL           fExplore = uFlags & CMF_EXPLORE;
00944 DWORD          dwAttr = SFGAO_CANRENAME |
00945                            SFGAO_CANDELETE |
00946                            SFGAO_CANCOPY |
00947                            SFGAO_CANMOVE |
00948                            SFGAO_FOLDER;
00949
00950 ZeroMemory(&mii, sizeof(mii));
00951 mii.cbSize = sizeof(mii);
00952
00953 m_psfParent->GetAttributesOf(m_uItemCount, (LPCITEMIDLIST*)m_aPidls, &dwAttr);
00954
00955 //only add the Open and Explore items if all items are folders.
00956 if(dwAttr & SFGAO_FOLDER)
00957    {
00958    if(fExplore)
00959       {
00960       LoadString(g_hInst, IDS_EXPLORE, szText, sizeof(szText));
00961       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00962       mii.wID = idCmdFirst + IDM_EXPLORE;
00963       mii.fType = MFT_STRING;
00964       mii.dwTypeData = szText;
00965       mii.fState = MFS_ENABLED | MFS_DEFAULT;
00966       InsertMenuItem(   hMenu,
00967                         indexMenu++,
00968                         TRUE,
00969                         &mii);
00970
00971       LoadString(g_hInst, IDS_OPEN, szText, sizeof(szText));
00972       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00973       mii.wID = idCmdFirst + IDM_OPEN;
00974       mii.fType = MFT_STRING;
00975       mii.dwTypeData = szText;
00976       mii.fState = MFS_ENABLED;
00977       InsertMenuItem(   hMenu,
00978                         indexMenu++,
00979                         TRUE,
00980                         &mii);
00981       }
00982    else
00983       {
00984       LoadString(g_hInst, IDS_OPEN, szText, sizeof(szText));
00985       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00986       mii.wID = idCmdFirst + IDM_OPEN;
00987       mii.fType = MFT_STRING;
00988       mii.dwTypeData = szText;
00989       mii.fState = MFS_ENABLED | MFS_DEFAULT;
00990       InsertMenuItem(   hMenu,
00991                         indexMenu++,
00992                         TRUE,
00993                         &mii);
00994
00995       LoadString(g_hInst, IDS_EXPLORE, szText, sizeof(szText));
00996       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
00997       mii.wID = idCmdFirst + IDM_EXPLORE;
00998       mii.fType = MFT_STRING;
00999       mii.dwTypeData = szText;
01000       mii.fState = MFS_ENABLED;
01001       InsertMenuItem(   hMenu,
01002                         indexMenu++,
01003                         TRUE,
01004                         &mii);
01005       }
01006    }
01007
01008 if(dwAttr & SFGAO_CANRENAME)
01009    {
01010    //only add a separator if needed
01011    if(GetMenuItemCount(hMenu))
01012       {
01013       mii.fMask = MIIM_TYPE;
01014       GetMenuItemInfo(hMenu, indexMenu, TRUE, &mii);
01015       if(!(mii.fType & MFT_SEPARATOR))
01016          {
01017          ZeroMemory(&mii, sizeof(mii));
01018          mii.cbSize = sizeof(mii);
01019          mii.fMask = MIIM_ID | MIIM_TYPE;
01020          mii.wID = 0;
01021          mii.fType = MFT_SEPARATOR;
01022          InsertMenuItem(   hMenu,
01023                            indexMenu++,
01024                            TRUE,
01025                            &mii);
01026          }
01027       }
01028
01029    LoadString(g_hInst, IDS_RENAME, szText, sizeof(szText));
01030    mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
01031    mii.wID = idCmdFirst + IDM_RENAME;
01032    mii.fType = MFT_STRING;
01033    mii.dwTypeData = szText;
01034    mii.fState = ((uFlags & MYCMF_MULTISELECT) ? MFS_DISABLED : MFS_ENABLED);
01035    InsertMenuItem(   hMenu,
01036                      indexMenu++,
01037                      TRUE,
01038                      &mii);
01039    }
01040
01041 //only add a separator if needed
01042 if(GetMenuItemCount(hMenu))
01043    {
01044    mii.fMask = MIIM_TYPE;
01045    GetMenuItemInfo(hMenu, indexMenu, TRUE, &mii);
01046    if(!(mii.fType & MFT_SEPARATOR))
01047       {
01048       mii.fMask = MIIM_ID | MIIM_TYPE;
01049       mii.wID = 0;
01050       mii.fType = MFT_SEPARATOR;
01051       InsertMenuItem(   hMenu,
01052                         indexMenu++,
01053                         TRUE,
01054                         &mii);
01055       }
01056    }
01057
01058 LoadString(g_hInst, IDS_CUT, szText, sizeof(szText));
01059 mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
01060 mii.wID = idCmdFirst + IDM_CUT;
01061 mii.fType = MFT_STRING;
01062 mii.dwTypeData = szText;
01063 mii.fState = ((dwAttr & SFGAO_CANMOVE) ? MFS_ENABLED : MFS_DISABLED);
01064 InsertMenuItem(   hMenu,
01065                   indexMenu++,
01066                   TRUE,
01067                   &mii);
01068
01069 LoadString(g_hInst, IDS_COPY, szText, sizeof(szText));
01070 mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
01071 mii.wID = idCmdFirst + IDM_COPY;
01072 mii.fType = MFT_STRING;
01073 mii.dwTypeData = szText;
01074 mii.fState = ((dwAttr & SFGAO_CANCOPY) ? MFS_ENABLED : MFS_DISABLED);
01075 InsertMenuItem(   hMenu,
01076                   indexMenu++,
01077                   TRUE,
01078                   &mii);
01079
01080 if(dwAttr & SFGAO_CANDELETE)
01081    {
01082    //only add a separator if needed
01083    if(GetMenuItemCount(hMenu))
01084       {
01085       mii.fMask = MIIM_TYPE;
01086       GetMenuItemInfo(hMenu, indexMenu, TRUE, &mii);
01087       if(!(mii.fType & MFT_SEPARATOR))
01088          {
01089          ZeroMemory(&mii, sizeof(mii));
01090          mii.cbSize = sizeof(mii);
01091          mii.fMask = MIIM_ID | MIIM_TYPE;
01092          mii.wID = 0;
01093          mii.fType = MFT_SEPARATOR;
01094          InsertMenuItem(   hMenu,
01095                            indexMenu++,
01096                            TRUE,
01097                            &mii);
01098          }
01099       }
01100
01101    LoadString(g_hInst, IDS_DELETE, szText, sizeof(szText));
01102    mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
01103    mii.wID = idCmdFirst + IDM_DELETE;
01104    mii.fType = MFT_STRING;
01105    mii.dwTypeData = szText;
01106    mii.fState = MFS_ENABLED;
01107    InsertMenuItem(   hMenu,
01108                      indexMenu++,
01109                      TRUE,
01110                      &mii);
01111    }
01112
01113 if(!(dwAttr & SFGAO_FOLDER) && !(m_fBackground))
01114    {
01115    //only add a separator if needed
01116    if(GetMenuItemCount(hMenu))
01117       {
01118       mii.fMask = MIIM_TYPE;
01119       GetMenuItemInfo(hMenu, indexMenu, TRUE, &mii);
01120       if(!(mii.fType & MFT_SEPARATOR))
01121          {
01122          ZeroMemory(&mii, sizeof(mii));
01123          mii.cbSize = sizeof(mii);
01124          mii.fMask = MIIM_ID | MIIM_TYPE;
01125          mii.wID = 0;
01126          mii.fType = MFT_SEPARATOR;
01127          InsertMenuItem(   hMenu,
01128                            indexMenu++,
01129                            TRUE,
01130                            &mii);
01131          }
01132       }
01133
01134    LoadString(g_hInst, IDS_MODIFY_DATA, szText, sizeof(szText));
01135    mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
01136    mii.wID = idCmdFirst + IDM_MODIFY_DATA;
01137    mii.fType = MFT_STRING;
01138    mii.dwTypeData = szText;
01139    mii.fState = ((uFlags & MYCMF_MULTISELECT) ? MFS_DISABLED : MFS_ENABLED);
01140    InsertMenuItem(   hMenu,
01141                      indexMenu++,
01142                      TRUE,
01143                      &mii);
01144    }
01145
01146 return indexMenu;
01147 }
01148
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/space.h Source File

  • SysMgmt
  • MMC
  • Toolbar

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "DeleBase.h"
00024 #include "CompData.h"
00025
00026 class CRocket : public CDelegationBase {
00027 public:
00028     CRocket(CComponentData *pComponentData = NULL);
00029
00030     virtual ~CRocket();
00031
00032     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00033     virtual const GUID & getNodeType() { return thisGuid; }
00034     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00035
00036     void Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload);
00037
00038 public:
00039     // virtual functions go here (for MMCN_*)
00040     virtual HRESULT OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect);
00041     virtual HRESULT OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb);
00042     virtual HRESULT OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect);
00043     virtual HRESULT OnButtonClicked(CComponent *pComponent);
00044
00045 private:
00046     // {29743810-4C4B-11d2-89D8-000021473128}
00047     static const GUID thisGuid;
00048
00049     _TCHAR *szName;
00050     LONG   lWeight;
00051     LONG   lHeight;
00052     LONG   lPayload;
00053     enum {RUNNING, PAUSED, STOPPED} iStatus;
00054 };
00055
00056 class CSpaceVehicle : public CDelegationBase {
00057 public:
00058     CSpaceVehicle(CComponentData *pComponentData = NULL);
00059
00060     virtual ~CSpaceVehicle();
00061
00062     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00063     virtual const GUID & getNodeType() { return thisGuid; }
00064     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00065
00066 public:
00067     // virtual functions go here (for MMCN_*)
00068     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00069
00070 private:
00071     enum { IDM_NEW_SPACE = 4 };
00072
00073     // {29743810-4C4B-11d2-89D8-000021473128}
00074     static const GUID thisGuid;
00075
00076 private:
00077     enum { NUMBER_OF_CHILDREN = 4 };
00078     CRocket *children[NUMBER_OF_CHILDREN];
00079 };
00080
00081 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/FreServe/BALL.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • FreServe

BALL.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      BALL.H
00003
00004   Summary:   Include file for the aggregatable COBall COM object class.
00005
00006              COBall offers a main standard IUnknown interface (basic COM
00007              object features) and the custom IBall interface (moving
00008              ball-related features).  This multiple interface COM Object
00009              Class is achieved via the technique of nested classes.  The
00010              implementation of the IBall interface is nested inside of the
00011              COBall Class.
00012
00013              This file also declares some internal C++ classes (CXForm and
00014              CBallThread) that provide internal support for the custom
00015              IBall interface.
00016
00017              For a comprehensive tutorial code tour of this module's
00018              contents and offerings see the tutorial FRESERVE.HTM file.
00019              For more specific technical details on the internal workings
00020              see the comments dispersed throughout the module's source code.
00021
00022   Functions:
00023
00024   Classes:   CXForm, CBallThread, COBall.
00025
00026   Origin:    4-5-96: atrent - Editor-inheritance from CAR.H in
00027              the DLLSERVE Tutorial Code Sample. Also borrows from
00028              the GDIDEMO sample in the Win32 samples of the Win32 SDK.
00029
00030 ----------------------------------------------------------------------------
00031   This file is part of the Microsoft COM Tutorial Code Samples.
00032
00033   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00034
00035   This source code is intended only as a supplement to Microsoft
00036   Development Tools and/or on-line documentation.  See these other
00037   materials for detailed information regarding Microsoft code samples.
00038
00039   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00040   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00041   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00042   PARTICULAR PURPOSE.
00043 ==========================================================================+*/
00044
00045 #if !defined(BALL_H)
00046 #define BALL_H
00047
00048 #ifdef __cplusplus
00049
00050 enum { MAX_BALLTHREADS = 64, BALL_MOVE_SKEW = 5 };
00051
00052
00053 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00054   Class:    CXForm
00055
00056   Summary:  A utility class with methods for performing point
00057             transformations on points that represent space/location in two
00058             dimensions.
00059
00060   Methods:  Clear
00061               Clears the transformation matrix.
00062             Scale
00063               Set transformation to multiply by a scale factor.
00064             Trans
00065               Perform transformation.
00066             Point
00067               Get point.
00068             CXForm
00069               Constructor.
00070             ~CXForm
00071               Destructor.
00072 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00073 class CXForm
00074 {
00075   private:
00076     int XForm[3][3];
00077
00078   public:
00079     CXForm(void) {};
00080     ~CXForm(void) {};
00081     void Clear(void);
00082     void Scale(int xScale, int yScale);
00083     void Trans(int xTrans, int yTrans);
00084     void Point(POINT* pPoint);
00085 };
00086
00087
00088 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00089   Class:    CBallThread
00090
00091   Summary:  A class for simple objects used to store properties of threads.
00092             An array of these is used to remember the threads that came
00093             visiting the CBall object.
00094
00095   Methods:  CBallThread
00096               Constructor.
00097             ~CBallThread
00098               Destructor.
00099 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00100 class CBallThread
00101 {
00102   public:
00103     DWORD Id;
00104     COLORREF Color;
00105
00106     CBallThread(void) {};
00107     ~CBallThread(void) {};
00108 };
00109
00110
00111 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00112   ObjectClass: COBall
00113
00114   Summary:     COM object class for COBall COM objects.  COM objects of
00115                this class offer IBall interface features, Reset, Move, and
00116                GetBall. The mulitple interfaces on this COM object are
00117                constructed via the nested interface classes technique.
00118
00119   Interfaces:  IUnknown
00120                  Standard interface providing COM object features.
00121                IBall
00122                  Basic Ball operation features.
00123
00124   Aggregation: Yes, COBall COM Objects are aggregatable by passing
00125                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00126 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00127 class COBall : public IUnknown, public CThreaded
00128 {
00129   public:
00130     // Main Object Constructor & Destructor.
00131     COBall(IUnknown* pUnkOuter, CServer* pServer);
00132     ~COBall(void);
00133
00134     // IUnknown methods. Main object, non-delegating.
00135     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00136     STDMETHODIMP_(ULONG) AddRef(void);
00137     STDMETHODIMP_(ULONG) Release(void);
00138
00139   private:
00140     // We declare nested class interface implementations here.
00141
00142     class CImpIBall : public IBall, public CThreaded
00143     {
00144       public:
00145         // Interface Implementation Constructor & Destructor.
00146         CImpIBall(COBall* pBackObj, IUnknown* pUnkOuter);
00147         ~CImpIBall(void);
00148
00149         // IUnknown methods.
00150         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00151         STDMETHODIMP_(ULONG) AddRef(void);
00152         STDMETHODIMP_(ULONG) Release(void);
00153
00154         // IBall methods.
00155         STDMETHODIMP Reset(RECT* pNewRect, short nBallSize);
00156         STDMETHODIMP GetBall(POINT* pOrg, POINT* pExt, COLORREF* pcrColor);
00157         STDMETHODIMP Move(BOOL bAlive);
00158
00159       private:
00160         // Data private to this COBall interface implementation of IBall.
00161         COBall*      m_pBackObj;     // Parent Object back pointer.
00162         IUnknown*    m_pUnkOuter;    // Outer unknown for Delegation.
00163
00164         // The following private data and methods constitute the working
00165         // heart of COBall as an actual application object.
00166         BOOL         m_bAlive;
00167         RECT         m_WinRect;
00168         int          m_nWidth;
00169         int          m_nHeight;
00170         int          m_xDirection;
00171         int          m_yDirection;
00172         BOOL         m_bNewPosition;
00173         int          m_xPosition;
00174         int          m_yPosition;
00175         short        m_xSkew;
00176         short        m_ySkew;
00177         COLORREF     m_crColor;
00178         CXForm       m_XForm;
00179         CBallThread  m_aBallThreads[MAX_BALLTHREADS];
00180
00181         // Private methods for internal use.
00182         void GetDimensions(POINT*);
00183         void SetDimensions(int,int);
00184         void GetDirection(POINT*);
00185         void SetDirection(int,int);
00186         void GetPosition(POINT*);
00187         void SetPosition(int,int);
00188         void CheckBounce(void);
00189         void FindThread(void);
00190     };
00191
00192     // Make the otherwise private and nested IBall interface implementation
00193     // a friend to COM object instantiations of this selfsame COBall
00194     // COM object class.
00195     friend CImpIBall;
00196
00197     // Private data of COBall COM objects.
00198
00199     // Nested IBall implementation instantiation.  This IBall interface
00200     // is instantiated inside this COBall object as a native interface.
00201     CImpIBall        m_ImpIBall;
00202
00203     // Main Object reference count.
00204     ULONG            m_cRefs;
00205
00206     // Outer unknown (aggregation & delegation).
00207     IUnknown*        m_pUnkOuter;
00208
00209     // Pointer to this component server's control object.
00210     CServer*         m_pServer;
00211 };
00212
00213 typedef COBall* PCOBall;
00214
00215 #endif // __cplusplus
00216
00217
00218 #endif // BALL_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/about.h Source File

  • SysMgmt
  • MMC
  • Taskpads

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CQuickStringWrap Member List

This is the complete list of members for CQuickStringWrap, including all inherited members.
_szAlloc | CQuickStringWrap | [private]
CQuickStringWrap() | CQuickStringWrap | [inline]
operator LPCWSTR() const | CQuickStringWrap | [inline]
Set(LPCWSTR szIn, DWORD dwLen) | CQuickStringWrap | [inline]
~CQuickStringWrap() | CQuickStringWrap | [inline]
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CVCSecuritySampleClass Member List

This is the complete list of members for CVCSecuritySampleClass, including all inherited members.
AmIAnAdministrator(short *) | CVCSecuritySampleClass |
CVCSecuritySampleClass() | CVCSecuritySampleClass | [inline]
WhoAmI(BSTR *) | CVCSecuritySampleClass |
Generated on Wed Nov 13 2024 16:57:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/Box.Hxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

Box.Hxx

Go to the documentation of this file.
00001 #ifndef _BOX_HXX_
00002 #define _BOX_HXX_
00003
00004 #include "font.hxx"
00005 #include "grid.hxx"
00006
00007 //====== CTextField =============================
00008 class CTextField
00009 {
00010 public:
00011         CTextField(TCHAR *sz);
00012         void Paint(CCanvas &canvas, int x, int y);
00013         void GetExtent(CCanvas& canvas, SIZE *psize);
00014         void SetFont(HFONT hfont);
00015         UINT Hittest(CCanvas& canvas, POINT pt);
00016 protected:
00017         HFONT _font;
00018         TCHAR *_sz;
00019 };
00020
00021 //====== CBoxFormat =============================
00022 class CBoxFormat : public CBlockFormat
00023 {
00024 public:
00025         CFont _fontAlias;
00026         CFont _fontCtype;
00027         CBoxFormat(SIZE sizeChar);
00028 };
00029
00030
00031 //====== CBox ===================================
00032 class CBox
00033 {
00034 public:
00035         CBox( CBoxFormat &bxf, UINT iChar, HFONT hfont ) ;
00036         // CBox(CBoxFormat &bxf, UINT iChar);
00037         //~CBox();
00038         void Paint(CCanvas &canvas, POINT pt, RECT rc);
00039         UINT Hittest(CCanvas &canvas, POINT pt);
00040         SIZE& GetSize() { return _sizeBox; };
00041     void SetFormat(UINT fuFormat) {_fuFormat = fuFormat; return; };
00042 protected:
00043         CCharBlock _Block;
00044         SIZE  _sizeBox;
00045
00046         CFont _fontBlock;
00047         CTextField _Alias;
00048         UINT _iChar;
00049         CBoxFormat &_bxf;
00050         UINT _fuFormat;
00051 };
00052
00053 #endif
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFileShareSampleApp Member List

This is the complete list of members for CFileShareSampleApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CWinApp() | CWinApp |
ExitInstance() | CFileShareSampleApp | [virtual]
InitInstance() | CFileShareSampleApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:56:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Metafile/MfEdit/MfEdit.c Source File

  • Multimedia
  • Gdi
  • Metafile
  • MfEdit

MfEdit.c

Go to the documentation of this file.
00001 /******************************Module*Header*******************************\
00002 * Module Name: mfedit.c
00003 *
00004 * Main module for the Enhanced Metafile Editor
00005 *       contains everything
00006 *
00007 * Copyright 1992 - 2000 Microsoft Corporation
00008 *
00009 * The Enhanced Metafile Editor serves to demonstrate the enhanced metafile
00010 * APIs in Windows NT.
00011 *
00012 * The Editor provides the following functions:
00013 *       1.  Playback and recording of GDI calls
00014 *       2.  Embedding bitmap and enhanced metafile into another enhanced
00015 *           metafile with transformation
00016 *       3.  Hit-testing against enhanced metafile records
00017 *       4.  Random access playback
00018 *       5.  Playback metafile records one-by-one
00019 *       6.  Selective recording of existing enhanced metafile records into
00020 *           a new enhanced metafile
00021 *       7.  drawing with pen, text, bezier, line, ellipse, rectangle and
00022 *           embedding bitmap and enhanced metafile tools
00023 *
00024 *
00025 \**************************************************************************/
00026 #include "precomp.h"
00027
00028
00029 // Conversion tables for n bits to eight bits
00030
00031 #if GAMMA_CORRECTION == 10
00032 // These tables are corrected for a gamma of 1.0
00033 static unsigned char abThreeToEight[8] =
00034 {
00035     0, 0111 >> 1, 0222 >> 1, 0333 >> 1, 0444 >> 1, 0555 >> 1, 0666 >> 1, 0377
00036 };
00037 static unsigned char abTwoToEight[4] =
00038 {
00039     0, 0x55, 0xaa, 0xff
00040 };
00041 static unsigned char abOneToEight[2] =
00042 {
00043     0, 255
00044 };
00045 #else
00046 // These tables are corrected for a gamma of 1.4
00047 static unsigned char abThreeToEight[8] =
00048 {
00049     0, 63, 104, 139, 171, 200, 229, 255
00050 };
00051 static unsigned char abTwoToEight[4] =
00052 {
00053     0, 116, 191, 255
00054 };
00055 static unsigned char abOneToEight[2] =
00056 {
00057     0, 255
00058 };
00059 #endif
00060
00061 // Table which indicates which colors in a 3-3-2 palette should be
00062 // replaced with the system default colors
00063 #if GAMMA_CORRECTION == 10
00064 static int aiDefaultOverride[STATIC_COLORS] =
00065 {
00066     0, 4, 32, 36, 128, 132, 160, 173, 181, 245,
00067     247, 164, 156, 7, 56, 63, 192, 199, 248, 255
00068 };
00069 #else
00070 static int aiDefaultOverride[STATIC_COLORS] =
00071 {
00072     0, 3, 24, 27, 64, 67, 88, 173, 181, 236,
00073     247, 164, 91, 7, 56, 63, 192, 199, 248, 255
00074 };
00075 #endif
00076
00077 static unsigned char
00078 ComponentFromIndex(int i, int nbits, int shift)
00079 {
00080     unsigned char val;
00081
00082 //    TKASSERT(nbits >= 1 && nbits <= 3);
00083
00084     val = i >> shift;
00085     switch (nbits)
00086     {
00087     case 1:
00088         return abOneToEight[val & 1];
00089
00090     case 2:
00091         return abTwoToEight[val & 3];
00092
00093     case 3:
00094         return abThreeToEight[val & 7];
00095     }
00096     return 0;
00097 }
00098
00099 // System default colors
00100 static PALETTEENTRY apeDefaultPalEntry[STATIC_COLORS] =
00101 {
00102     { 0,   0,   0,    0 },
00103     { 0x80,0,   0,    0 },
00104     { 0,   0x80,0,    0 },
00105     { 0x80,0x80,0,    0 },
00106     { 0,   0,   0x80, 0 },
00107     { 0x80,0,   0x80, 0 },
00108     { 0,   0x80,0x80, 0 },
00109     { 0xC0,0xC0,0xC0, 0 },
00110
00111     { 192, 220, 192,  0 },
00112     { 166, 202, 240,  0 },
00113     { 255, 251, 240,  0 },
00114     { 160, 160, 164,  0 },
00115
00116     { 0x80,0x80,0x80, 0 },
00117     { 0xFF,0,   0,    0 },
00118     { 0,   0xFF,0,    0 },
00119     { 0xFF,0xFF,0,    0 },
00120     { 0,   0,   0xFF, 0 },
00121     { 0xFF,0,   0xFF, 0 },
00122     { 0,   0xFF,0xFF, 0 },
00123     { 0xFF,0xFF,0xFF, 0 }
00124 };
00125
00126
00127 /******************************Public*Routine******************************\
00128 *
00129 * FUNCTION:  PolyDraw95(HDC, LPPOINT, LPBYTE, int)
00130 *
00131 * PURPOSE:   Draws the points returned from a call to GetPath()
00132 *            to an HDC
00133 *
00134 * NOTES:     This function is similar to the Windows NT PolyDraw
00135 *            function, which draws a set of line segments and Bezier
00136 *            curves. Because PolyDraw is not supported in Windows 95
00137 *            this PolyDraw95 function is used instead.
00138 *
00139 \**************************************************************************/
00140
00141 BOOL PolyDraw95(HDC  hdc,               // handle of a device context
00142                 CONST LPPOINT lppt,     // array of points
00143                 CONST LPBYTE lpbTypes,  // line and curve identifiers
00144                 int  cCount)            // count of points
00145 {
00146   int i;
00147
00148   for (i=0; i<cCount; i++)
00149     switch (lpbTypes[i]) {
00150       case PT_MOVETO :
00151          MoveToEx(hdc, lppt[i].x, lppt[i].y, NULL);
00152          break;
00153
00154       case PT_LINETO | PT_CLOSEFIGURE:
00155       case PT_LINETO :
00156          LineTo(hdc, lppt[i].x, lppt[i].y);
00157          break;
00158
00159       case PT_BEZIERTO | PT_CLOSEFIGURE:
00160       case PT_BEZIERTO :
00161         PolyBezierTo(hdc, &lppt[i], 3);
00162        i+=2;
00163          break;
00164     }
00165
00166    return TRUE;
00167 }
00168
00169
00170 /**************************************************************************\
00171 *
00172 * vErrOut
00173 *
00174 * Effects:  Put up a message box with the error string and error code
00175 *           returned.
00176 *
00177 \**************************************************************************/
00178
00179 void vErrOut(char errstring[MAX_ERR_STRING])
00180 {
00181     DWORD   dwError, dwThrdId;
00182     char    str[MAX_ERR_STRING];
00183
00184
00185     if (gbDebug) {
00186         dwError = GetLastError();
00187         dwThrdId = GetCurrentThreadId();
00188         _sntprintf((LPSTR) str, MAX_ERR_STRING - 1, "%s, tid = %lx, Error code = %d\n",
00189                  errstring, dwThrdId, dwError);
00190     str [MAX_ERR_STRING - 1] = '\0';
00191         OutputDebugString((LPCTSTR)str);
00192         //MessageBox(GetFocus(), (LPSTR)str, "MfEdit Error", MB_OK);
00193     }
00194 }
00195
00196
00197 /**************************************************************************\
00198 *
00199 * FlushPalette
00200 *
00201 \**************************************************************************/
00202
00203 static void
00204 FlushPalette(HDC hdc, WORD nColors)
00205 {
00206     LOGPALETTE *pPal;
00207     HPALETTE hpal, hpalOld;
00208     int i;
00209
00210     if (nColors == 256)
00211     {
00212         pPal = (LOGPALETTE *) LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT,
00213                                          sizeof(LOGPALETTE) + (nColors-1) * sizeof(PALETTEENTRY));
00214
00215         if (pPal)
00216         {
00217         pPal->palVersion = 0x300;
00218         pPal->palNumEntries = nColors;
00219
00220         // Mark everything PC_NOCOLLAPSE and PC_RESERVED to force every thing
00221         // into the palette.  Colors are already black because we zero initialized
00222         // during memory allocation.
00223
00224             for (i = 0; i < nColors; i++)
00225             {
00226                 pPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE | PC_RESERVED;
00227             }
00228
00229             hpal = CreatePalette(pPal);
00230             LocalFree(pPal);
00231
00232             hpalOld = SelectPalette(hdc, hpal, FALSE);
00233             RealizePalette(hdc);
00234
00235             SelectPalette(hdc, hpalOld, FALSE);
00236             DeleteObject(hpal);
00237         }
00238     }
00239 }
00240
00241
00242 /**************************************************************************\
00243 *
00244 * UpdateStaticMapping
00245 *
00246 \**************************************************************************/
00247
00248 static void
00249 UpdateStaticMapping(PALETTEENTRY *pe332Palette)
00250 {
00251     HPALETTE hpalStock;
00252     int iStatic, i332;
00253     int iMinDist, iDist;
00254     int iDelta;
00255     int iMinEntry;
00256     PALETTEENTRY *peStatic, *pe332;
00257
00258     hpalStock = GetStockObject(DEFAULT_PALETTE);
00259
00260     // The system should always have one of these
00261     //TKASSERT(hpalStock != NULL);
00262     // Make sure there's the correct number of entries
00263     //TKASSERT(GetPaletteEntries(hpalStock, 0, 0, NULL) == STATIC_COLORS);
00264
00265     // Get the current static colors
00266     GetPaletteEntries(hpalStock, 0, STATIC_COLORS, apeDefaultPalEntry);
00267
00268     // Zero the flags in the static colors because they are used later
00269     peStatic = apeDefaultPalEntry;
00270     for (iStatic = 0; iStatic < STATIC_COLORS; iStatic++)
00271     {
00272         peStatic->peFlags = 0;
00273         peStatic++;
00274     }
00275
00276     // Zero the flags in the incoming palette because they are used later
00277     pe332 = pe332Palette;
00278     for (i332 = 0; i332 < 256; i332++)
00279     {
00280         pe332->peFlags = 0;
00281         pe332++;
00282     }
00283
00284     // Try to match each static color exactly
00285     // This saves time by avoiding the least-squares match for each
00286     // exact match
00287     peStatic = apeDefaultPalEntry;
00288     for (iStatic = 0; iStatic < STATIC_COLORS; iStatic++)
00289     {
00290         pe332 = pe332Palette;
00291         for (i332 = 0; i332 < 256; i332++)
00292         {
00293             if (peStatic->peRed == pe332->peRed &&
00294                 peStatic->peGreen == pe332->peGreen &&
00295                 peStatic->peBlue == pe332->peBlue)
00296             {
00297                 //TKASSERT(pe332->peFlags != COLOR_USED);
00298
00299                 peStatic->peFlags = EXACT_MATCH;
00300                 pe332->peFlags = COLOR_USED;
00301                 aiDefaultOverride[iStatic] = i332;
00302
00303                 break;
00304             }
00305
00306             pe332++;
00307         }
00308
00309         peStatic++;
00310     }
00311
00312     // Match each static color as closely as possible to an entry
00313     // in the 332 palette by minimized the square of the distance
00314     peStatic = apeDefaultPalEntry;
00315     for (iStatic = 0; iStatic < STATIC_COLORS; iStatic++)
00316     {
00317         // Skip colors already matched exactly
00318         if (peStatic->peFlags == EXACT_MATCH)
00319         {
00320             peStatic++;
00321             continue;
00322         }
00323
00324         iMinDist = MAX_COL_DIST+1;
00325 #if DBG
00326         iMinEntry = -1;
00327 #endif
00328
00329         pe332 = pe332Palette;
00330         for (i332 = 0; i332 < 256; i332++)
00331         {
00332             // Skip colors already used
00333             if (pe332->peFlags == COLOR_USED)
00334             {
00335                 pe332++;
00336                 continue;
00337             }
00338
00339             // Compute Euclidean distance squared
00340             iDelta = pe332->peRed-peStatic->peRed;
00341             iDist = iDelta*iDelta;
00342             iDelta = pe332->peGreen-peStatic->peGreen;
00343             iDist += iDelta*iDelta;
00344             iDelta = pe332->peBlue-peStatic->peBlue;
00345             iDist += iDelta*iDelta;
00346
00347             if (iDist < iMinDist)
00348             {
00349                 iMinDist = iDist;
00350                 iMinEntry = i332;
00351             }
00352
00353             pe332++;
00354         }
00355
00356         //TKASSERT(iMinEntry != -1);
00357
00358         // Remember the best match
00359         aiDefaultOverride[iStatic] = iMinEntry;
00360         pe332Palette[iMinEntry].peFlags = COLOR_USED;
00361
00362         peStatic++;
00363     }
00364
00365     // Zero the flags in the static colors because they may have been
00366     // set.  We want them to be zero so the colors can be remapped
00367     peStatic = apeDefaultPalEntry;
00368     for (iStatic = 0; iStatic < STATIC_COLORS; iStatic++)
00369     {
00370         peStatic->peFlags = 0;
00371         peStatic++;
00372     }
00373
00374     // Reset the 332 flags because we may have set them
00375     pe332 = pe332Palette;
00376     for (i332 = 0; i332 < 256; i332++)
00377     {
00378         pe332->peFlags = PC_NOCOLLAPSE;
00379         pe332++;
00380     }
00381
00382 #if 0
00383     for (iStatic = 0; iStatic < STATIC_COLORS; iStatic++)
00384     {
00385         PrintMessage("Static color %2d maps to %d\n",
00386                      iStatic, aiDefaultOverride[iStatic]);
00387     }
00388 #endif
00389 }
00390
00391 #define SwapPalE(i,j) { \
00392     PALETTEENTRY palE; \
00393     palE = pPal->palPalEntry[i]; \
00394     pPal->palPalEntry[i] = pPal->palPalEntry[j]; \
00395     pPal->palPalEntry[j] = palE; }
00396
00397
00398 /**************************************************************************\
00399 *
00400 * SaveStaticEntries
00401 *
00402 \**************************************************************************/
00403
00404 VOID SaveStaticEntries(HDC hDC)
00405 {
00406     int i;
00407
00408     if (gbSystemColorsInUse) {
00409         for (i = COLOR_SCROLLBAR; i <= COLOR_BTNHIGHLIGHT; i++)
00410             gacrSave[i - COLOR_SCROLLBAR] = GetSysColor(i);
00411
00412         gbStaticSaved = TRUE;
00413     }
00414 }
00415
00416 /**************************************************************************\
00417 *
00418 * UseStaticEntries
00419 *
00420 \**************************************************************************/
00421
00422 static VOID UseStaticEntries(HDC hdc)
00423 {
00424     SetSysColors(NUM_STATIC_COLORS, gaiStaticIndex, gacrBlackAndWhite);
00425     gbSystemColorsInUse = TRUE;
00426
00427     PostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
00428 }
00429
00430 /**************************************************************************\
00431 *
00432 * hCreateRGBPalette
00433 *
00434 \**************************************************************************/
00435
00436 HPALETTE hCreateRGBPalette(HDC hDC, int index)
00437 {
00438     PIXELFORMATDESCRIPTOR   pfd;
00439     PLOGPALETTE             pLogPal, pPal;
00440     WORD                    nClr, i, n;
00441     HPALETTE                hPal;
00442     BOOL                    bUseStaticClr;
00443
00444
00445     if (DescribePixelFormat(hDC, index, sizeof(PIXELFORMATDESCRIPTOR), &pfd) == 0) {
00446         return (HPALETTE)NULL;
00447     }
00448
00449     bUseStaticClr = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE;
00450
00451     if (pfd.dwFlags & PFD_NEED_PALETTE) {
00452         nClr = 1 << pfd.cColorBits;
00453
00454         if ((pLogPal = (PLOGPALETTE) LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
00455                         (nClr-1) * sizeof(PALETTEENTRY))) != NULL) {
00456
00457             pLogPal->palVersion = 0x300;
00458             pLogPal->palNumEntries = nClr;
00459
00460             for (i = 0; i < nClr; i++) {
00461                 pLogPal->palPalEntry[i].peRed   =
00462             ComponentFromIndex(i, pfd.cRedBits, pfd.cRedShift);
00463                 pLogPal->palPalEntry[i].peGreen =
00464             ComponentFromIndex(i, pfd.cGreenBits, pfd.cGreenShift);
00465                 pLogPal->palPalEntry[i].peBlue  =
00466             ComponentFromIndex(i, pfd.cBlueBits, pfd.cBlueShift);
00467                 pLogPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
00468             }
00469
00470             if ( nClr == 256) {
00471                 if (bUseStaticClr) {
00472                     pLogPal->palPalEntry[0].peFlags = 0;
00473                     pLogPal->palPalEntry[255].peFlags = 0;
00474
00475                     SaveStaticEntries(hDC);
00476                     SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC);
00477                 } else {
00478                     if ((pfd.cRedBits   == 3) && (pfd.cRedShift   == 0) &&
00479                         (pfd.cGreenBits == 3) && (pfd.cGreenShift == 3) &&
00480                         (pfd.cBlueBits  == 2) && (pfd.cBlueShift  == 6)) {
00481                         UpdateStaticMapping(pLogPal->palPalEntry);
00482
00483                         for (i = 0; i < 20; i++) {
00484                             pLogPal->palPalEntry[aiDefaultOverride[i]] =
00485                                 apeDefaultPalEntry[i];
00486                         }
00487
00488                     }
00489                 }
00490             }
00491
00492             FlushPalette(hDC, nClr);
00493
00494             hPal = CreatePalette(pLogPal);
00495             LocalFree(pLogPal);
00496             SelectPalette(hDC, hPal, FALSE);
00497             RealizePalette(hDC);
00498
00499
00500             if (bUseStaticClr)
00501                 UseStaticEntries(hDC);
00502
00503         }
00504     }
00505     // set up logical indices for CI mode
00506     else if( pfd.iPixelType == PFD_TYPE_COLORINDEX ) {
00507         if (pfd.cColorBits == 4) {
00508
00509             // for 4-bit, create a logical palette with 16 entries
00510
00511             n = 16;
00512             if ( (pPal = (PLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
00513         (n-1) * sizeof(PALETTEENTRY))) != NULL ){
00514         pPal->palVersion = 0x300;
00515         pPal->palNumEntries = n;
00516
00517         for( i = 0; i < 8; i ++) {
00518           pPal->palPalEntry[i] = apeDefaultPalEntry[i];
00519         }
00520         for (i = 8; i < 16; i++) {
00521           pPal->palPalEntry[i] = apeDefaultPalEntry[i+4];
00522         }
00523
00524         // conform expects indices 0..3 to be BLACK,RED,GREEN,BLUE, so
00525         //  we rearrange the table for now.
00526
00527         SwapPalE(1,9)
00528         SwapPalE(2,10)
00529         SwapPalE(3,12)
00530       }
00531
00532     }
00533     else if (pfd.cColorBits == 8) {
00534
00535             // for 8-bit, create a logical palette with 256 entries, making
00536             // sure that the 20 system colors exist in the palette
00537
00538             n = 256;
00539             if ((pPal = (PLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
00540         (n-1) * sizeof(PALETTEENTRY))) != NULL){
00541         pPal->palVersion = 0x300;
00542         pPal->palNumEntries = n;
00543
00544         hPal = GetStockObject (DEFAULT_PALETTE);
00545
00546         // start by copying default palette into new one
00547
00548         GetPaletteEntries( hPal, 0, 20, pPal->palPalEntry);
00549
00550         // conform expects indices 0..3 to be BLACK,RED,GREEN,BLUE, so
00551         // we rearrange the table for now.
00552
00553         SwapPalE(1,13)
00554         SwapPalE(2,14)
00555         SwapPalE(3,16)
00556
00557         for( i = 20; i < n; i ++) {
00558           pPal->palPalEntry[i].peRed   = (BYTE) (i - 1);
00559           pPal->palPalEntry[i].peGreen = (BYTE) (i - 2);
00560           pPal->palPalEntry[i].peBlue  = (BYTE) (i - 3);
00561           pPal->palPalEntry[i].peFlags = (BYTE) 0;
00562         }
00563
00564
00565         // If we are taking possession of the system colors,
00566         // must guarantee that 0 and 255 are black and white
00567         // (respectively), so that they can remap to the
00568         // remaining two static colors.  All other entries must
00569         // be marked as PC_NOCOLLAPSE.
00570
00571         if ( gbUseStaticColors )
00572         {
00573           pPal->palPalEntry[0].peRed =
00574           pPal->palPalEntry[0].peGreen =
00575           pPal->palPalEntry[0].peBlue = 0x00;
00576
00577           pPal->palPalEntry[255].peRed =
00578           pPal->palPalEntry[255].peGreen =
00579           pPal->palPalEntry[255].peBlue = 0xFF;
00580
00581                   pPal->palPalEntry[0].peFlags =
00582                 pPal->palPalEntry[255].peFlags = 0;
00583
00584               for ( i = 1 ; i < 255 ; i++ )
00585             {
00586               pPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
00587
00588                 // This is a workaround for a GDI palette "feature".  If
00589               // any of the static colors are repeated in the palette,
00590             // those colors will map to the first occurance.  So, for
00591           // our case where there are only two static colors (black
00592                   // and white), if a white color appears anywhere in the
00593                 // palette other than in the last  entry, the static white
00594               // will remap to the first white.  This destroys the nice
00595             // one-to-one mapping we are trying to achieve.
00596           //
00597                   // There are two ways to workaround this.  The first is to
00598               // simply not allow a pure white anywhere but in the last
00599                 // entry.  Such requests are replaced with an attenuated
00600             // white of (0xFE, 0xFE, 0xFE).
00601                   //
00602                 // The other way is to mark these extra whites with
00603               // PC_RESERVED which will cause GDI to skip these entries
00604             // when mapping colors.  This way the app gets the actual
00605           // colors requested, but can have side effects on other
00606           // apps.
00607
00608             if ( pPal->palPalEntry[i].peRed   == 0xFF &&
00609               pPal->palPalEntry[i].peGreen == 0xFF &&
00610               pPal->palPalEntry[i].peBlue  == 0xFF )
00611             {
00612               pPal->palPalEntry[i].peFlags |= PC_RESERVED;
00613             }
00614           }
00615
00616           SaveStaticEntries(hDC);
00617           SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC);
00618         }
00619       } // not null
00620
00621         } else {
00622             // for pixel formats > 8 bits deep, create a logical palette with
00623             // 4096 entries
00624
00625             n = 4096;
00626             if ((pPal = (PLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
00627         (n-1) * sizeof(PALETTEENTRY))) != NULL ){
00628               pPal->palVersion = 0x300;
00629             pPal->palNumEntries = n;
00630
00631             for( i = 0; i < n; i ++) {
00632               pPal->palPalEntry[i].peRed   = (BYTE) ((i & 0x000f) << 4);
00633             pPal->palPalEntry[i].peGreen = (BYTE) (i & 0x00f0);
00634           pPal->palPalEntry[i].peBlue  = (BYTE) ((i & 0x0f00) >> 4);
00635           pPal->palPalEntry[i].peFlags = (BYTE) 0;
00636         }
00637
00638               // conform expects indices 0..3 to be BLACK,RED,GREEN,BLUE, so
00639             //  we rearrange the table for now.
00640       }
00641
00642       SwapPalE(1,0xf)
00643       SwapPalE(2,0xf0)
00644       SwapPalE(3,0xf00)
00645     }
00646     if (pPal){
00647       hPal = CreatePalette(pPal);
00648       LocalFree(pPal);
00649
00650
00651       FlushPalette(hDC, n);
00652
00653       SelectPalette(hDC, hPal, FALSE);
00654       RealizePalette(hDC);
00655
00656       if ( gbUseStaticColors )
00657         UseStaticEntries(hDC);
00658     }
00659   }
00660
00661     return hPal;
00662 }
00663
00664 /******************************Public*Routine******************************\
00665 *
00666 * bSetupRC
00667 *
00668 * Effects: Sets up the OpenGL rendering context
00669 *
00670 * Warnings:
00671 *
00672 \**************************************************************************/
00673
00674 #ifdef OPENGL_EMF
00675 BOOL bSetupRC(HDC hDC, PIXELFORMATDESCRIPTOR *ppfdIn)
00676 {
00677     PIXELFORMATDESCRIPTOR   pfd, *ppfd;
00678     INT                     iPfmt;
00679     BOOL                    bRet=FALSE;
00680     HPALETTE                hPal=(HPALETTE)NULL;
00681     HGLRC                   hRC;
00682     char                    text[128];
00683
00684     if ((ppfdIn != (PIXELFORMATDESCRIPTOR*)NULL) && gbUseMfPFD) {
00685         ppfd = ppfdIn;
00686     } else {
00687         ppfd = &pfd;
00688         pfd.nSize   = sizeof(PIXELFORMATDESCRIPTOR);
00689         pfd.nVersion= 1;
00690         pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
00691         pfd.iPixelType  = PFD_TYPE_RGBA;
00692         pfd.cColorBits  = 24;
00693         pfd.cRedBits    =
00694         pfd.cRedShift   =
00695         pfd.cGreenBits  =
00696         pfd.cGreenShift =
00697         pfd.cBlueBits   =
00698         pfd.cBlueShift  =
00699         pfd.cAlphaBits  =
00700         pfd.cAlphaShift = 0;
00701         pfd.cAccumBits  = 24;
00702         pfd.cAccumRedBits   =
00703         pfd.cAccumGreenBits =
00704         pfd.cAccumBlueBits  =
00705         pfd.cAccumAlphaBits = 0;
00706         pfd.cDepthBits  = 24;
00707         pfd.cStencilBits = 24;
00708         pfd.cAuxBuffers =
00709         pfd.iLayerType  =
00710         pfd.bReserved   = 0;
00711         pfd.dwLayerMask = PFD_MAIN_PLANE;
00712         pfd.dwVisibleMask = 0;
00713         pfd.dwDamageMask = 0;
00714     }
00715
00716     if ((iPfmt = ChoosePixelFormat(hDC, ppfd)) != 0) {
00717         bRet = SetPixelFormat(hDC, iPfmt, ppfd);
00718
00719         gbDB = (ppfd->dwFlags & PFD_DOUBLEBUFFER) ? TRUE : FALSE;
00720
00721         if ((hPal = hCreateRGBPalette(hDC, iPfmt)) != (HPALETTE)NULL) {
00722             SelectPalette(hDC, hPal, FALSE);
00723             RealizePalette(hDC);
00724             bRet = bRet && TRUE;
00725         } else {
00726             bRet = FALSE;
00727         }
00728
00729         hRC = wglCreateContext(hDC);
00730         wglMakeCurrent(hDC, hRC);
00731
00732         _stprintf(text, 127,"bSetupRC: hDC=%lx, hRC=%lx", hDC, hRC);
00733     text [127] = '\0';
00734         vErrOut(text);
00735
00736     }
00737     return bRet;
00738 }
00739
00740 /**************************************************************************\
00741 *
00742 * bSetRC2MatchEmfRC
00743 *
00744 * Effects:  If the bOpenGL flag is not set in the metafile header,
00745 *           return FALSE.
00746 *
00747 *           If the bOpenGL flag is set, retrieve the pfd from the enhanced
00748 *           metafile, if exists.  Set the pixel format with the retrieved
00749 *           pfd on the hDC.  If the pfd is not recorded, let bSetupRC pick
00750 *           the pfd.
00751 *
00752 *           If ppfd is not null, copy the pfd in the metafile record,
00753 *           to the ppfd.  If ppfd->nSize == 0, that means the pfd is not
00754 *           found in the metafile record.
00755 *
00756 * Warnings:
00757 *
00758 * History:
00759 *  05-May-1996
00760 * Wrote it.
00761 \**************************************************************************/
00762
00763 BOOL bSetRC2MatchEmfRC(HDC                      hDC,
00764                        ENHMETAHEADER            EnhMetaHdr,
00765                        HENHMETAFILE             hEnhMf,
00766                        PIXELFORMATDESCRIPTOR    *ppfdIn)
00767 {
00768     BOOL                    bHasPFD = FALSE, bRCSet = FALSE;
00769     char                    text[128];
00770     PIXELFORMATDESCRIPTOR   pfd;
00771
00772     if (EnhMetaHdr.bOpenGL) {
00773
00774         if (gpfnGetEnhMetaFilePixelFormat != (PROC)NULL) {
00775
00776             bHasPFD = ((gpfnGetEnhMetaFilePixelFormat)(hEnhMf,
00777                                       sizeof(PIXELFORMATDESCRIPTOR),
00778                                       &pfd) == 0) ? FALSE : TRUE;
00779
00780             bRCSet = bSetupRC(hDC, (bHasPFD ? &pfd : NULL));
00781
00782             _stprintf(text,
00783                      127, "bSetRC2MatchEmfRC: bRCSet=%ld, bHasPFD=%ld",
00784                      bRCSet, bHasPFD);
00785       text [127] = '\0';
00786             vErrOut(text);
00787
00788         } else {
00789             vErrOut("bSetRC2MatchEmfRC: gpfnGetEnhMetaFilePixelFormat is NULL");
00790         }
00791
00792     } else {
00793         vErrOut("bSetRC2MatchEmfRC: EnhMetaHdr.bOpenGL is FALSE");
00794     }
00795
00796     if (ppfdIn != (PIXELFORMATDESCRIPTOR*)NULL) {
00797         if (bHasPFD) {
00798             if (sizeof (*ppfdIn) >= sizeof(PIXELFORMATDESCRIPTOR))
00799             {
00800                 memcpy(ppfdIn, &pfd, sizeof(PIXELFORMATDESCRIPTOR));
00801             }
00802             else
00803                 return FALSE;
00804         } else {
00805             ppfdIn->nSize = 0;
00806         }
00807     }
00808
00809     return bRCSet;
00810 }
00811
00812
00813 /******************************Public*Routine******************************\
00814 *
00815 * bCleanUpRC
00816 *
00817 * Effects:  Cleans up the OpenGL rendering context
00818 *
00819 * Warnings:
00820 *
00821 \**************************************************************************/
00822
00823 BOOL bCleanUpRC(VOID)
00824 {
00825     HGLRC       hRC;
00826     HDC         hDC;
00827     char        text[128];
00828
00829     hRC = wglGetCurrentContext();
00830     hDC = wglGetCurrentDC();
00831
00832     _stprintf(text, 127,"bCleanUpRC: hDC=%lx, hRC=%lx", hDC, hRC);
00833   text [127] = '\0';
00834     vErrOut(text);
00835
00836     wglMakeCurrent(hDC, NULL);
00837     wglDeleteContext(hRC);
00838     return TRUE;
00839
00840 }
00841
00842 #else
00843 BOOL bSetupRC(HDC hDC, PIXELFORMATDESCRIPTOR *ppfdIn)
00844 {
00845     return TRUE;
00846 }
00847
00848 BOOL bSetRC2MatchEmfRC(HDC                      hDC,
00849                        ENHMETAHEADER            EnhMetaHdr,
00850                        HENHMETAFILE             hEnhMf,
00851                        PIXELFORMATDESCRIPTOR    *ppfd)
00852 {
00853     return TRUE;
00854 }
00855
00856 BOOL bCleanUpRC(VOID)
00857 {
00858     return TRUE;
00859 }
00860 #endif
00861
00862 /**************************************************************************\
00863 *
00864 * WinMain
00865 *
00866 * Effects:
00867 *
00868 * Warnings:
00869 *
00870 * History:
00871 *  06-May-1996  Retrieve the proc addr for GetEnhMetaFilePixelFormat.
00872 * Wrote it.
00873 \**************************************************************************/
00874
00875 int WINAPI WinMain(
00876            HINSTANCE hInstance,
00877            HINSTANCE hPrevInstance,
00878            LPSTR lpCmdLine,
00879            int nShowCmd)
00880 {
00881     MSG      msg;
00882     HANDLE   hAccel;
00883     HMODULE  hMod;
00884     TCHAR    libPath [MAX_ARRAYSIZE];
00885     UINT     pathSize;
00886
00887     ghModule = GetModuleHandle(NULL);
00888
00889 //
00890 // GDI32 may not support the OpenGL enhanced metafile (Win95 doesn't), in
00891 // which case, the entry point doesn't exist, so we will do a GetProcAddress
00892 // instead.
00893 //
00894
00895 //  GDI32.dll should be picked up from the System directory.
00896     pathSize = GetSystemDirectory ( libPath, MAX_ARRAYSIZE - 1);
00897     if (!pathSize || (pathSize > MAX_ARRAYSIZE))
00898     {
00899         vErrOut("Main: GetSystemDirectory failed");
00900         return 0;
00901     }
00902     libPath [MAX_ARRAYSIZE - 1] = '\0';
00903     strncat ( libPath, "GDI32.DLL", MAX_ARRAYSIZE - strlen ( libPath ));
00904     hMod = LoadLibrary( libPath );
00905     if (hMod != (HMODULE)NULL) {
00906
00907         gpfnGetEnhMetaFilePixelFormat =
00908                 GetProcAddress(hMod, "GetEnhMetaFilePixelFormat");
00909
00910         if (gpfnGetEnhMetaFilePixelFormat == (PROC)NULL)
00911             vErrOut("Main: GetProcAddress(GetEnhMetaFilePixelFormat) failed");
00912
00913     } else {
00914         vErrOut("Main: LoadLibrary(GDI32) failed");
00915     }
00916
00917     if (!InitializeApp()) {
00918         MessageBox(ghwndMain,
00919             GetStringRes(IDS_INITAPPFAIL), GetStringRes(IDS_ERROR), MB_OK);
00920         return 0;
00921     }
00922
00923     if (!(hAccel = LoadAccelerators (ghModule, MAKEINTRESOURCE(ACCEL_ID))))
00924         MessageBox(ghwndMain,
00925             GetStringRes(IDS_LOADACCFAIL), GetStringRes(IDS_ERROR), MB_OK);
00926
00927
00928     while (GetMessage(&msg, NULL, 0, 0)) {
00929         if (!TranslateAccelerator( ghwndMain, hAccel, &msg) ) {
00930             TranslateMessage(&msg);
00931             DispatchMessage(&msg);
00932         }
00933     }
00934
00935     return 1;
00936
00937     UNREFERENCED_PARAMETER(lpCmdLine);
00938     UNREFERENCED_PARAMETER(nShowCmd);
00939     UNREFERENCED_PARAMETER(hInstance);
00940     UNREFERENCED_PARAMETER(hPrevInstance);
00941 }
00942
00943
00944 /***************************************************************************\
00945 * InitializeApp
00946 *
00947 \***************************************************************************/
00948
00949 BOOL InitializeApp(void)
00950 {
00951     WNDCLASS wc;
00952     int index;
00953     HDC hDC;
00954
00955     wc.style            = CS_DBLCLKS;
00956     wc.lpfnWndProc      = (WNDPROC)MainWndProc;
00957     wc.cbClsExtra       = 0;
00958     wc.cbWndExtra   = sizeof(DWORD_PTR);
00959     wc.hInstance        = ghModule;
00960     wc.hIcon            = LoadIcon(ghModule, MAKEINTRESOURCE(APP_ICON));
00961     wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
00962     wc.hbrBackground    = (HBRUSH)(COLOR_APPWORKSPACE + 1);
00963     wc.lpszMenuName     = "MainMenu";
00964     wc.lpszClassName    = "MetafDemoClass";
00965
00966     if (!RegisterClass(&wc))
00967     return FALSE;
00968
00969     wc.style            = CS_OWNDC | CS_SAVEBITS;
00970     wc.lpfnWndProc      = (WNDPROC)DrawSurfWndProc;
00971     wc.hIcon            = NULL;
00972     wc.hCursor          = NULL;
00973     wc.hbrBackground    = (HBRUSH)(COLOR_WINDOW + 1);
00974     wc.lpszMenuName     = NULL;
00975     wc.lpszClassName    = "DrawSurfClass";
00976
00977     if (!RegisterClass(&wc))
00978     return FALSE;
00979
00980     wc.style        = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
00981     wc.lpfnWndProc  = (WNDPROC)TextWndProc;
00982     wc.hIcon        = NULL;
00983     wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
00984     wc.hbrBackground    = (HBRUSH)(COLOR_BTNFACE + 1);
00985     wc.lpszMenuName = NULL;
00986     wc.lpszClassName    = "Text";
00987
00988     if (!RegisterClass(&wc))
00989             return FALSE;
00990
00991
00992
00993     hMenu   = LoadMenu(ghModule, "MainMenu");
00994
00995     for (index = 0; index < OD_BTN_CNT; index++) {
00996         ghBmpDn[index] = (PVOID)LoadBitmap(ghModule, (LPCSTR)MAKEINTRESOURCE(BMID_BASED+index));
00997         ghBmpUp[index] = (PVOID)LoadBitmap(ghModule, (LPCSTR)MAKEINTRESOURCE(BMID_BASEU+index));
00998     }
00999     for (index = 0; index < OD_TOOL_CNT; index++) {
01000         ghToolBmpDn[index] = (PVOID)LoadBitmap(ghModule, (LPCSTR)MAKEINTRESOURCE(BMID_TOOLBASED+index));
01001         ghToolBmpUp[index] = (PVOID)LoadBitmap(ghModule, (LPCSTR)MAKEINTRESOURCE(BMID_TOOLBASEU+index));
01002
01003     }
01004
01005     ghwndMain = CreateWindowEx(0L,
01006             GetStringRes(IDS_MFDEMOCL), GetStringRes2(IDS_EMF),
01007         WS_OVERLAPPED   | WS_CAPTION     | WS_BORDER       |
01008         WS_THICKFRAME   | WS_MAXIMIZEBOX | WS_MINIMIZEBOX  |
01009         WS_CLIPCHILDREN | WS_VISIBLE     | WS_SYSMENU,
01010             80, 70, 600, 300,
01011         NULL, hMenu, ghModule, NULL);
01012
01013     if (ghwndMain == NULL)
01014     return FALSE;
01015
01016     SetWindowLongPtr(ghwndMain, GWLP_USERDATA, 0L);
01017     ghwndNext = SetClipboardViewer(ghwndMain);
01018
01019     if (gbFit2Wnd)
01020         CheckMenuItem(hMenu, MM_FIT2WND, MF_CHECKED);
01021     else
01022         CheckMenuItem(hMenu, MM_FIT2WND, MF_UNCHECKED);
01023
01024     if (gbImport3X)
01025         CheckMenuItem(hMenu, MM_IMPORT_3X, MF_CHECKED);
01026     else
01027         CheckMenuItem(hMenu, MM_IMPORT_3X, MF_UNCHECKED);
01028
01029     if (gbExport3X)
01030         CheckMenuItem(hMenu, MM_EXPORT_3X, MF_CHECKED);
01031     else
01032         CheckMenuItem(hMenu, MM_EXPORT_3X, MF_UNCHECKED);
01033
01034     SetFocus(ghwndMain);    /* set initial focus */
01035
01036     gDib.ulFiles = gDib.ulFrames = 0;
01037     hDC = GetDC(NULL);
01038     ghHT = CreateHalftonePalette(hDC);
01039     ReleaseDC(NULL, hDC);
01040
01041     return TRUE;
01042 }
01043
01044 /******************************Public*Routine******************************\
01045 *
01046 * lProcessWmCreate
01047 *
01048 * Effects:  process WM_CREATE message
01049 *
01050 * Warnings:
01051 *
01052 \**************************************************************************/
01053
01054 LONG lProcessWmCreate(HWND hWnd)
01055 {
01056     SetWindowLongPtr(hWnd, 0, (LONG_PTR)NULL);
01057     ghDCMem = CreateCompatibleDC(NULL);
01058
01059     ghwndCtrlPanel = CreateDialog(ghModule,
01060                                     (LPCSTR)MAKEINTRESOURCE(DID_CTRLPANEL),
01061                                     hWnd,
01062                                     (DLGPROC) CtrlPanelDlgProc);
01063
01064     ghwndDrawSurf = CreateWindow("DrawSurfClass",
01065                                     NULL,
01066                                     WS_BORDER | WS_CHILD | WS_VISIBLE,
01067                                     0, 0, 0, 0,
01068                                     hWnd,
01069                                     NULL,
01070                                     ghModule,
01071                                     NULL);
01072
01073     ghTextWnd = CreateWindow("Text",
01074                                 NULL,
01075                                 WS_BORDER | SS_LEFT | WS_CHILD | WS_VISIBLE,
01076                                 0, 0, 0, 0,
01077                                 hWnd,
01078                                 NULL,               //(HMENU) 2,
01079                                 ghModule,
01080                                 NULL);
01081
01082     ghbrRed     = CreateSolidBrush(RGB(255, 0, 0));
01083     ghbrAppBkgd = CreateSolidBrush(GetSysColor(COLOR_BACKGROUND));
01084     ghpnWide    = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
01085     return 0L;
01086 }
01087
01088
01089 /******************************Public*Routine******************************\
01090 *
01091 * lProcessWmDrawClip
01092 *
01093 * Effects:  process the WM_DRAWCLIPBOARD message
01094 *
01095 * Warnings:
01096 *
01097 \**************************************************************************/
01098
01099 LONG_PTR lProcessWmDrawClip(UINT message, WPARAM wParam, LPARAM lParam)
01100 {
01101     if ((IsClipboardFormatAvailable(CF_METAFILEPICT)) ||
01102         (IsClipboardFormatAvailable(CF_ENHMETAFILE)) )
01103         EnableMenuItem(hMenu, MM_PASTE, MF_ENABLED);
01104     else
01105         EnableMenuItem(hMenu, MM_PASTE,  MF_GRAYED);
01106
01107     if (ghwndNext)
01108         SendMessage(ghwndNext, message, wParam, lParam);
01109     return 0L;
01110 }
01111
01112 /******************************Public*Routine******************************\
01113 *
01114 * lProcessWmSize
01115 *
01116 * Effects:  process the WM_SIZE message
01117 *
01118 * Warnings:
01119 *
01120 \**************************************************************************/
01121
01122 LRESULT lProcessWmSize(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
01123 {
01124     RECT        rc;
01125     LONG        lcyCtrlPanel, lcyDrawSurf;
01126
01127     GetWindowRect(ghwndCtrlPanel, &rc);
01128     lcyCtrlPanel = rc.bottom-rc.top;
01129     lcyDrawSurf = HIWORD(lParam) - lcyCtrlPanel - glcyStatus;
01130
01131     //
01132     // CR!! Alternatively, this window can be created with cy
01133     //      equals to cy of the screen and saving this call
01134     //      altogether.
01135     //
01136     MoveWindow(ghwndCtrlPanel,
01137                0, 0, LOWORD(lParam), lcyCtrlPanel, TRUE);
01138
01139     //
01140     // This ordering guarantees the text window paints correctly
01141     //
01142     MoveWindow(ghTextWnd,
01143                0, lcyCtrlPanel + lcyDrawSurf,
01144                LOWORD(lParam),                    // cx of hwnd
01145                glcyStatus, TRUE);
01146
01147     MoveWindow(ghwndDrawSurf,
01148                0, lcyCtrlPanel,
01149                LOWORD(lParam),                    // cx of hwnd
01150                lcyDrawSurf, TRUE);
01151
01152     return DefWindowProc(hWnd, message, wParam, lParam);
01153 }
01154
01155 /******************************Public*Routine******************************\
01156 *
01157 * lProcessWmDestroy
01158 *
01159 * Effects:  process the WM_DESTROY message
01160 *
01161 * Warnings:
01162 *
01163 \**************************************************************************/
01164
01165 LONG lProcessWmDestroy(VOID)
01166 {
01167     if (ghDCMem != (HDC)NULL)
01168         DeleteDC(ghDCMem);
01169     if (ghMetaf != (HENHMETAFILE)NULL)
01170         DeleteEnhMetaFile(ghMetaf);
01171     DestroyWindow(ghwndCtrlPanel);
01172     DeleteObject(ghbrRed);
01173     DeleteObject(ghbrCur);
01174     DeleteObject(ghpnCur);
01175     DeleteObject(ghbrAppBkgd);
01176     DeleteObject(ghpnWide);
01177     if (ghHT)
01178         DeleteObject(ghHT);
01179     ChangeClipboardChain(ghwndMain, ghwndNext);
01180     bFreeDibFile(&gDib);
01181     PostQuitMessage(0);
01182     return 0L;
01183 }
01184
01185 /******************************Public*Routine******************************\
01186 *
01187 * lProcessDIDPlayStep
01188 *
01189 * Effects:  process the WM_COMMAND DID_X messages
01190 *
01191 * Warnings:
01192 *
01193 \**************************************************************************/
01194
01195 LONG lProcessDIDPlayStep(WPARAM wParam, INT *piPlus)
01196 {
01197     HDC           hDCDrawSurf;
01198     ENHMETAHEADER EnhMetaHdr;
01199     RECT          rcClientDS;
01200     int           iRecord;
01201     PLAYINFO      PlayInfo;
01202     BOOL          bRCSet = FALSE;
01203
01204     if (ghMetaf == 0)
01205         return 0L;
01206
01207     GetEnhMetaFileHeader(ghMetaf, sizeof(EnhMetaHdr), &EnhMetaHdr);
01208     iRecord = LOWORD(wParam) - DID_ZERO + *piPlus;
01209     SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, iRecord, FALSE);
01210     PlayInfo.iRecord = iRecord;
01211     PlayInfo.bPlayContinuous = FALSE;
01212     *piPlus = 0;
01213
01214     if ((EnhMetaHdr.nRecords > 1) && (iRecord > 0) &&
01215         (iRecord <= (INT) EnhMetaHdr.nRecords)) {
01216         hDCDrawSurf = GetDC(ghwndDrawSurf);
01217
01218         bRCSet = bSetRC2MatchEmfRC(hDCDrawSurf, EnhMetaHdr, ghMetaf, NULL);
01219         if (!bRCSet) {
01220             vErrOut("lProcessDIDPlayStep failed");
01221         }
01222
01223         if (gbFit2Wnd) {
01224             GetClientRect(ghwndDrawSurf, &rcClientDS);
01225             EnumEnhMetaFile(hDCDrawSurf, ghMetaf, (ENHMFENUMPROC)bPlayRecord, (LPVOID) &PlayInfo, &rcClientDS);
01226         } else {
01227             EnumEnhMetaFile(hDCDrawSurf, ghMetaf, (ENHMFENUMPROC)bPlayRecord, (LPVOID) &PlayInfo, (LPRECT)&EnhMetaHdr.rclBounds);
01228         }
01229         //
01230         // Enabling the user to record a metafile record selectively
01231         //
01232
01233         if ((gbRecording) && (ghDCMetaf != NULL)) {
01234             EnumEnhMetaFile(ghDCMetaf, ghMetaf, (ENHMFENUMPROC)bPlayRecord, (LPVOID) &PlayInfo, (LPRECT)&EnhMetaHdr.rclBounds);
01235         }
01236
01237         if (bRCSet) {
01238             bCleanUpRC();
01239         }
01240
01241         ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
01242     }
01243     return 0L;
01244 }
01245
01246 /******************************Public*Routine******************************\
01247 *
01248 * lProcessDIDPlayTenPlus
01249 *
01250 * Effects:  process the WM_COMMAND DID_TEN_PLUS message
01251 *
01252 * Warnings:
01253 *
01254 \**************************************************************************/
01255
01256 LONG lProcessDIDPlayTenPlus(INT *piPlus)
01257 {
01258     if (ghMetaf == 0)
01259         return 0L;
01260
01261     *piPlus += 10;
01262     SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, *piPlus, FALSE);
01263     return 0L;
01264 }
01265
01266 /******************************Public*Routine******************************\
01267 *
01268 * lProcessMMCopy
01269 *
01270 * Effects:  process the WM_COMMAND MM_COPY message
01271 *
01272 * Warnings:
01273 *
01274 \**************************************************************************/
01275
01276 LONG lProcessMMCopy(VOID)
01277 {
01278     if ((ghMetaf == 0) && (ghmf == 0)) {
01279         SetWindowText(ghTextWnd, GetStringRes(IDS_NOMFFORCPY));
01280         return 0L;
01281     }
01282
01283     OpenClipboard(ghwndMain);
01284     EmptyClipboard();
01285
01286     if (gbExport3X)
01287     {
01288         HGLOBAL         hmem;
01289         LPMETAFILEPICT  lpmfp;
01290         RECT            rcClientDS;
01291         DWORD           x, y, mm;
01292         HDC             hDCDrawSurf;
01293         LPBYTE          pjData;
01294         UINT            uiSize;
01295
01296         hDCDrawSurf = GetDC(ghwndDrawSurf);
01297
01298         if (ghmf == 0) {
01299             SetWindowText(ghTextWnd, GetStringRes(IDS_CNVEMFTO3X));
01300
01301             if (!(uiSize = GetWinMetaFileBits(ghMetaf, 0, NULL, MM_ANISOTROPIC, hDCDrawSurf))) {
01302                 MessageBox(ghwndMain, GetStringRes(IDS_GETWMFBTSFAIL),
01303                     GetStringRes(IDS_ERROR), MB_OK);
01304                 goto COPY_3X_EXIT;
01305             }
01306
01307             if ((pjData = (LPBYTE) LocalAlloc(LMEM_FIXED, uiSize)) == NULL) {
01308                 MessageBox(ghwndMain, GetStringRes(IDS_MALLOCFAIL),
01309                     GetStringRes(IDS_ERROR), MB_OK);
01310                 goto COPY_3X_EXIT;
01311             }
01312
01313             if (!(uiSize = GetWinMetaFileBits(ghMetaf, uiSize, pjData, MM_ANISOTROPIC, hDCDrawSurf))) {
01314                 MessageBox(ghwndMain, GetStringRes(IDS_GETWMFBTSFAIL2),
01315                     GetStringRes(IDS_ERROR), MB_OK);
01316                 LocalFree(pjData);
01317                 goto COPY_3X_EXIT;
01318             }
01319
01320             ghmf = SetMetaFileBitsEx(uiSize, (LPBYTE) pjData);
01321             LocalFree(pjData);
01322         }
01323
01324         if ((hmem = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE,
01325                             sizeof(METAFILEPICT))) == NULL) {
01326
01327             SetWindowText(ghTextWnd, GetStringRes(IDS_MALLOCFAIL2));
01328             goto COPY_3X_EXIT;
01329
01330         }
01331
01332         lpmfp = (LPMETAFILEPICT)GlobalLock(hmem);
01333         lpmfp->mm = mm = MM_ANISOTROPIC;
01334
01335         GetClientRect(ghwndDrawSurf, &rcClientDS);
01336         x = rcClientDS.right - rcClientDS.left;
01337         x *= 2540;
01338         x /= GetDeviceCaps(hDCDrawSurf, LOGPIXELSX);
01339         lpmfp->xExt = x;                                // ie. in 0.01mm
01340
01341         y = rcClientDS.bottom - rcClientDS.top;
01342         y *= 2540;
01343         y /= GetDeviceCaps(hDCDrawSurf, LOGPIXELSY);
01344         lpmfp->yExt = y;                                // ie. in 0.01mm
01345
01346         lpmfp->hMF = CopyMetaFile(ghmf, NULL);
01347
01348         GlobalUnlock(hmem);
01349         SetWindowText(ghTextWnd, GetStringRes(IDS_CPY3XMFTOCLP));
01350         SetClipboardData(CF_METAFILEPICT, hmem);
01351
01352 COPY_3X_EXIT:
01353         ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
01354         goto COPY_EXIT;
01355
01356     }
01357
01358     //
01359     // gbExport3X == FALSE
01360     //
01361     if (ghMetaf == 0)           // requires conversion
01362     {
01363         UINT            uiSize;
01364         LPVOID          pvData;
01365         HDC             hDCDrawSurf;
01366
01367         SetWindowText(ghTextWnd, "Converting 3X Metafile to Enhanced Metafile format");
01368         if (!(uiSize = GetMetaFileBitsEx(ghmf, 0, NULL))) {
01369             MessageBox(ghwndMain, GetStringRes(IDS_GETMFBTSXFAIL),
01370                 GetStringRes(IDS_ERROR), MB_OK);
01371             SetWindowText(ghTextWnd, GetStringRes(IDS_CNVFAIL));
01372             goto COPY_EXIT;
01373         }
01374
01375         if ((pvData = (LPVOID) LocalAlloc(LMEM_FIXED, uiSize)) == NULL) {
01376             MessageBox(ghwndMain, GetStringRes(IDS_MALLOCFAIL),
01377                 GetStringRes(IDS_ERROR), MB_OK);
01378             SetWindowText(ghTextWnd, GetStringRes(IDS_CNVFAIL));
01379             goto COPY_EXIT;
01380         }
01381
01382         if (!(uiSize = GetMetaFileBitsEx(ghmf, uiSize, pvData))) {
01383             MessageBox(ghwndMain, GetStringRes(IDS_GETWMFBTSFAIL2X),
01384                 GetStringRes(IDS_ERROR), MB_OK);
01385             goto COPY_ENH_EXIT;
01386         }
01387
01388         hDCDrawSurf = GetDC(ghwndDrawSurf);
01389
01390         // !!! provide the correct picture extents in the METAFILEPICT structure
01391         // where possible
01392         ghMetaf = SetWinMetaFileBits(uiSize, (LPBYTE)pvData, hDCDrawSurf, NULL);
01393
01394 COPY_ENH_EXIT:
01395         LocalFree(pvData);
01396         ReleaseDC(ghwndDrawSurf ,hDCDrawSurf);
01397
01398         if (ghMetaf == 0) {
01399             SetWindowText(ghTextWnd, GetStringRes(IDS_CNVFAIL));
01400             goto COPY_EXIT;
01401         }
01402
01403     }
01404
01405     //
01406     // No Conversion required
01407     //
01408     {
01409
01410         HENHMETAFILE hEmfTmp;
01411
01412         hEmfTmp = CopyEnhMetaFile(ghMetaf, NULL);
01413
01414         if (hEmfTmp) {
01415             SetWindowText(ghTextWnd, GetStringRes(IDS_CPYEMFTOCLP));
01416             SetClipboardData(CF_ENHMETAFILE, hEmfTmp);
01417             DeleteEnhMetaFile(hEmfTmp);
01418         }
01419
01420     }
01421
01422 COPY_EXIT:
01423
01424     CloseClipboard();
01425     return 0L;
01426 }
01427
01428 /******************************Public*Routine******************************\
01429 *
01430 * lProcessMMPaste
01431 *
01432 * Effects:  process the WM_COMMAND MM_PASTE message
01433 *
01434 * Warnings:
01435 *
01436 \**************************************************************************/
01437
01438 LONG lProcessMMPaste(HWND hwnd, BOOL *pbReset)
01439 {
01440
01441     OpenClipboard(ghwndMain);
01442
01443     if (gbImport3X)
01444     {
01445         HANDLE      hmem;
01446         DWORD       dwXSugExt, dwYSugExt, dwMM;
01447         HDC         hDCDrawSurf;
01448         RECT        rc;
01449         INT         iSavedDC;
01450
01451
01452         hmem = GetClipboardData(CF_METAFILEPICT);
01453
01454         if (hmem)
01455         {
01456             LPMETAFILEPICT lpmfp;
01457
01458             SetWindowText(ghTextWnd, GetStringRes(IDS_PST3XMF));
01459             lpmfp = (LPMETAFILEPICT)GlobalLock(hmem);
01460             ghmf  = lpmfp->hMF;
01461             dwMM  = lpmfp->mm;
01462             dwXSugExt = lpmfp->xExt;        // in 0.01 mm
01463             dwYSugExt = lpmfp->yExt;
01464             GlobalUnlock(hmem);
01465
01466             hDCDrawSurf = GetDC(ghwndDrawSurf);
01467
01468             iSavedDC = SaveDC(hDCDrawSurf);
01469
01470             GetClientRect(ghwndDrawSurf, &rc);
01471
01472             SetMapMode(hDCDrawSurf, dwMM);
01473             if ((dwXSugExt > 0 )&& (dwYSugExt > 0))
01474             {                               // suggested width & height of image
01475                 DWORD x;
01476                 DWORD y;
01477
01478                 // no. of pixels in x and y
01479                 x = dwXSugExt;
01480                 x *= GetDeviceCaps(hDCDrawSurf,LOGPIXELSX);
01481                 x /= 2540;
01482
01483                 y = dwYSugExt;
01484                 y *= GetDeviceCaps(hDCDrawSurf,LOGPIXELSY);
01485                 y /= 2540;
01486
01487                 SetWindowExtEx(hDCDrawSurf, x, y, NULL);
01488
01489                 if (gbFit2Wnd)
01490                     SetViewportExtEx(hDCDrawSurf, rc.right, rc.bottom, NULL);
01491                 else
01492                     SetViewportExtEx(hDCDrawSurf, x, y, NULL);
01493
01494             } else {
01495                 SetWindowText(ghTextWnd, GetStringRes(IDS_NOINFO3XMFX));
01496                 SetWindowExtEx(hDCDrawSurf, rc.right, rc.bottom, NULL);
01497                 SetViewportExtEx(hDCDrawSurf, rc.right, rc.bottom, NULL);
01498             }
01499
01500             SetViewportOrgEx(hDCDrawSurf, 0, 0, NULL);
01501             SetWindowOrgEx(hDCDrawSurf, 0, 0, NULL);
01502
01503             SetBoundsRect(hDCDrawSurf, NULL, DCB_ENABLE | DCB_SET);
01504             PlayMetaFile(hDCDrawSurf, ghmf);
01505             {
01506             UINT    uiRC;
01507             char    text[128];
01508
01509             _sntprintf(text, 127,"dwMM = %d\n", dwMM);
01510       text [127] = '\0';
01511             OutputDebugString(text);
01512             _sntprintf(text, 127,"dwXSugExt = %d\n", dwXSugExt);
01513       text [127] = '\0';
01514             OutputDebugString(text);
01515             _sntprintf(text, 127,"dwYSugExt = %d\n", dwYSugExt);
01516       text [127] = '\0';
01517             OutputDebugString(text);
01518             uiRC = GetBoundsRect(hDCDrawSurf, &rc, DCB_RESET); // in logical coordinates
01519             _sntprintf(text, 127,"GetBoundsRect = %d\n", uiRC);
01520       text [127] = '\0';
01521             OutputDebugString(text);
01522             _sntprintf(text, 127,"left     = %d\n", rc.left);
01523       text [127] = '\0';
01524             OutputDebugString(text);
01525             _sntprintf(text, 127, "right    = %d\n", rc.right);
01526       text [127] = '\0';
01527             OutputDebugString(text);
01528             _sntprintf(text, 127, "top      = %d\n", rc.top);
01529             text [127] = '\0';
01530       OutputDebugString(text);
01531             _sntprintf(text, 127,"bottom   = %d\n", rc.bottom);
01532             text [127] = '\0';
01533       OutputDebugString(text);
01534             }
01535
01536 // !!!
01537 // saving the wmf as an Aldus mf
01538 //
01539 {
01540 OPENFILENAME    ofn;
01541 char            szFile[MAX_ARRAYSIZE], szFileTitle[MAX_ARRAYSIZE];
01542 static char     *szFilter;
01543 UINT            uiSize;
01544 HANDLE          hFile, hMapFile;
01545 LPVOID          pMapFile;
01546 DWORD           dwHigh, dwLow;
01547
01548 BuildFilterStrs(-1);
01549 szFilter = BuildFilterStrs(IDS_FT_WMF);
01550 strncpy ( szFile, "*.wmf\0", MAX_ARRAYSIZE - 1);
01551 szFile [MAX_ARRAYSIZE - 1] = '\0';
01552 ofn.lStructSize = sizeof(OPENFILENAME);
01553 ofn.hwndOwner = hwnd;
01554 ofn.lpstrFilter = szFilter;
01555 ofn.lpstrCustomFilter = (LPSTR) NULL;
01556 ofn.nMaxCustFilter = 0L;
01557 ofn.nFilterIndex = 1;
01558 ofn.lpstrFile = szFile;
01559 ofn.nMaxFile = sizeof(szFile);
01560 ofn.lpstrFileTitle = szFileTitle;
01561 ofn.nMaxFileTitle = sizeof(szFileTitle);
01562 ofn.lpstrInitialDir = NULL;
01563 ofn.lpstrTitle = GetStringRes(IDS_SAVEMF);
01564 ofn.Flags = 0L;
01565 ofn.nFileOffset = 0;
01566 ofn.nFileExtension = 0;
01567 ofn.lpstrDefExt = "WMF";
01568
01569 if (!GetOpenFileName(&ofn))
01570     return 0L;
01571
01572 uiSize = GetMetaFileBitsEx(ghmf, 0, NULL);
01573 dwHigh = 0;
01574 dwLow  = uiSize;
01575
01576 if ((hFile = CreateFile(szFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL,
01577         CREATE_ALWAYS, SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS, NULL)) == INVALID_HANDLE_VALUE) {
01578     MessageBox(ghwndMain, GetStringRes(IDS_FILEOPNFAIL),
01579         GetStringRes(IDS_ERROR), MB_OK);
01580     return 0L;
01581 }
01582 if ( GetFileType(hFile) != FILE_TYPE_DISK )
01583 {
01584         CloseHandle(hFile);
01585         return 0L;
01586 }
01587
01588
01589 //
01590 // Create a map file of the opened file
01591 //
01592 if ((hMapFile = CreateFileMapping(hFile, NULL,
01593                          PAGE_READWRITE, dwHigh, dwLow, "MapF")) == NULL) {
01594     MessageBox(ghwndMain, GetStringRes(IDS_MAPFCREFAIL),
01595         GetStringRes(IDS_ERROR), MB_OK);
01596     goto ErrorExit1;
01597 }
01598
01599 //
01600 // Map a view of the whole file
01601 //
01602 if ((pMapFile = MapViewOfFile(hMapFile, FILE_MAP_WRITE, 0, 0, uiSize)) == NULL) {
01603     MessageBox(ghwndMain, GetStringRes(IDS_MAPVWMAPFOFAIL),
01604         GetStringRes(IDS_ERROR), MB_OK);
01605     goto ErrorExit2;
01606 }
01607
01608 if (uiSize) {
01609     APMFILEHEADER   AldHdr;
01610     PAPMFILEHEADER  pAldHdr;
01611     PBYTE           pjTmp;
01612     INT             iSize;
01613     char            text[128];
01614
01615     AldHdr.key = ALDUS_ID;
01616     AldHdr.hmf = 0;                                 // Unused; must be zero
01617     AldHdr.bbox.Left   = 0;                         // in metafile units
01618     AldHdr.bbox.Top    = 0;
01619     //AldHdr.bbox.Right  = rc.right - rc.left;        // in logical coordinates
01620     //AldHdr.bbox.Bottom = rc.bottom - rc.top;
01621
01622     switch (dwMM) {
01623         case MM_HIENGLISH:
01624             AldHdr.inch = 1000;
01625             AldHdr.bbox.Right  = (SHORT)dwXSugExt;
01626             AldHdr.bbox.Bottom = (SHORT)dwYSugExt;
01627             break;
01628         case MM_HIMETRIC:
01629             AldHdr.inch = 1440;
01630             AldHdr.bbox.Right  = (SHORT)(dwXSugExt / 2540 * 1440);
01631             AldHdr.bbox.Bottom = (SHORT)(dwYSugExt / 2540 * 1440);
01632             break;
01633         case MM_LOENGLISH:
01634             AldHdr.inch = 100;
01635             AldHdr.bbox.Right  = (SHORT)dwXSugExt;
01636             AldHdr.bbox.Bottom = (SHORT)dwYSugExt;
01637             break;
01638         case MM_LOMETRIC:
01639             AldHdr.inch = 254;
01640             AldHdr.bbox.Right  = (SHORT)dwXSugExt;
01641             AldHdr.bbox.Bottom = (SHORT)dwYSugExt;
01642             break;
01643         case MM_TEXT:
01644             AldHdr.inch = (WORD) (GetDeviceCaps(hDCDrawSurf, HORZRES) * 25.4 /
01645                           GetDeviceCaps(hDCDrawSurf, HORZSIZE));
01646             AldHdr.bbox.Right  = (SHORT)dwXSugExt;
01647             AldHdr.bbox.Bottom = (SHORT)dwYSugExt;
01648             break;
01649         case MM_TWIPS:
01650             AldHdr.inch = 1440;
01651             AldHdr.bbox.Right  = (SHORT)dwXSugExt;
01652             AldHdr.bbox.Bottom = (SHORT)dwYSugExt;
01653             break;
01654         default:
01655             AldHdr.inch = 1440;
01656             AldHdr.bbox.Right  = (SHORT)(dwXSugExt / 2540 * 1440);
01657             AldHdr.bbox.Bottom = (SHORT)(dwYSugExt / 2540 * 1440);
01658             break;
01659     }
01660
01661     _sntprintf(text,127, "MM           = %d\n", dwMM);
01662   text [127] = '\0';
01663     OutputDebugString(text);
01664     _sntprintf(text, 127, "AldHdr.inch  = %d\n", AldHdr.inch);
01665   text [127] = '\0';
01666     OutputDebugString(text);
01667
01668     AldHdr.reserved = 0;
01669     AldHdr.checksum = 0;
01670     {
01671     WORD    *p;
01672
01673     for (p = (WORD *)&AldHdr, AldHdr.checksum = 0;
01674             p < (WORD *)&(AldHdr.checksum); ++p)
01675         AldHdr.checksum ^= *p;
01676     }
01677
01678     pAldHdr = &AldHdr;
01679     pjTmp = (PBYTE)pMapFile;
01680
01681     iSize = 22;
01682
01683     //!!! use memcpy...
01684     while (iSize--) {
01685         *(((PBYTE)pjTmp)++) = *(((PBYTE)pAldHdr)++);
01686     }
01687
01688     pMapFile = (PBYTE)pMapFile + 22;
01689     GetMetaFileBitsEx(ghmf, uiSize, pMapFile);
01690 }
01691
01692
01693 UnmapViewOfFile(pMapFile);
01694
01695 ErrorExit2:
01696   CloseHandle(hMapFile);
01697 ErrorExit1:
01698   CloseHandle(hFile);
01699 }
01700
01701             RestoreDC(hDCDrawSurf, iSavedDC);
01702             ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
01703
01704         } else {
01705             SetWindowText(ghTextWnd, GetStringRes(IDS_GET3XFRMCLPFAIL));
01706         }
01707
01708         goto PASTE_EXIT;
01709
01710     }
01711
01712     //
01713     // gbImport3X == FALSE
01714     //
01715     {
01716         HENHMETAFILE hEmfTmp;
01717         ENHMETAHEADER EnhMetaHdr;
01718
01719         hEmfTmp = GetClipboardData(CF_ENHMETAFILE);
01720         if (hEmfTmp) {
01721             SetWindowText(ghTextWnd, GetStringRes(IDS_PSTEMF));
01722             if (ghMetaf != (HENHMETAFILE)NULL)
01723                 DeleteEnhMetaFile(ghMetaf);
01724             ghMetaf = CopyEnhMetaFile(hEmfTmp, NULL);
01725             DeleteEnhMetaFile(hEmfTmp);
01726             GetEnhMetaFileHeader(ghMetaf, sizeof(EnhMetaHdr), &EnhMetaHdr);
01727             SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, EnhMetaHdr.nRecords, FALSE);
01728             *pbReset = TRUE;
01729         } else {
01730             SetWindowText(ghTextWnd, GetStringRes(IDS_GETEMFFROMCLPFAIL));
01731         }
01732     }
01733 PASTE_EXIT:
01734
01735     CloseClipboard();
01736     EnableMenuItem(hMenu, MM_COPY,  MF_ENABLED);
01737     return 0L;
01738 }
01739
01740 /******************************Public*Routine******************************\
01741 *
01742 * lProcessMMDel
01743 *
01744 * Effects:  process the WM_COMMAND MM_DEL message
01745 *
01746 * Warnings:
01747 *
01748 \**************************************************************************/
01749
01750 LONG lProcessMMDel(VOID)
01751 {
01752     OpenClipboard(ghwndMain);
01753     EmptyClipboard();
01754     CloseClipboard();
01755     return 0L;
01756 }
01757
01758 /******************************Public*Routine******************************\
01759 *
01760 * lProcessMMPen
01761 *
01762 * Effects:  process the WM_COMMAND MM_PEN message
01763 *
01764 * Warnings:
01765 *
01766 \**************************************************************************/
01767
01768 LONG lProcessMMPen(HWND hwnd)
01769 {
01770     HDC     hDC;
01771     DWORD   dwRGB;
01772
01773     if (bChooseNewColor(hwnd, &dwRGB)) {
01774         hDC = GetDC(ghwndDrawSurf);
01775         if (ghpnCur != NULL)
01776             DeleteObject(ghpnCur);
01777         ghpnCur = CreatePen(PS_SOLID, 1, dwRGB);
01778         SelectObject(hDC, ghpnCur);
01779         if (ghDCMetaf != NULL)
01780             SelectObject(ghDCMetaf, ghpnCur);
01781         ReleaseDC(ghwndDrawSurf, hDC);
01782     }
01783     return 0L;
01784 }
01785
01786 /******************************Public*Routine******************************\
01787 *
01788 * lProcessMMBrush
01789 *
01790 * Effects:  process the WM_COMMAND MM_BRUSH message
01791 *
01792 * Warnings:
01793 *
01794 \**************************************************************************/
01795
01796 LONG lProcessMMBrush(HWND hwnd)
01797 {
01798     HDC     hDC;
01799     static DWORD   dwRGB=RGB(255, 255, 255);
01800
01801     if (bChooseNewColor(hwnd, &dwRGB)) {
01802         hDC = GetDC(ghwndDrawSurf);
01803         if (ghbrCur != NULL)
01804             DeleteObject(ghbrCur);
01805         ghbrCur = hBrCreateBrush(hDC, dwRGB);
01806         SelectObject(hDC, ghbrCur);
01807         if (ghDCMetaf != NULL)
01808             SelectObject(ghDCMetaf, ghbrCur);
01809         ReleaseDC(ghwndDrawSurf, hDC);
01810     }
01811     return 0L;
01812 }
01813
01814 /******************************Public*Routine******************************\
01815 *
01816 * lProcessMMFont
01817 *
01818 * Effects:  process the WM_COMMAND MM_FONT message
01819 *
01820 * Warnings:
01821 *
01822 \**************************************************************************/
01823
01824 LONG lProcessMMFont(VOID)
01825 {
01826     HDC     hDC;
01827     char    text[128];
01828
01829     if (bChooseNewFont(ghwndMain, &glf, &gCrText)) {
01830         ghCurFont = CreateFontIndirect(&glf);
01831
01832         hDC = GetDC(ghwndDrawSurf);
01833         EnumFonts(hDC, glf.lfFaceName, (FONTENUMPROC)iTT, (LPARAM)&gbTT);
01834         _sntprintf(text, 127, "gbTT = %d\n", gbTT);
01835     text [127] = '\0';
01836         //OutputDebugString(text);
01837         ReleaseDC(ghwndDrawSurf, hDC);
01838
01839         if (ghDCMetaf != NULL)
01840             SelectObject(ghDCMetaf, ghCurFont);
01841     }
01842     return 0L;
01843 }
01844
01845 /******************************Public*Routine******************************\
01846 *
01847 * lProcessMMStrokeFill
01848 *
01849 * Effects:  process the WM_COMMAND MM_TTOUTLN_STROKEFILL message
01850 *
01851 * Warnings:
01852 *
01853 * History:
01854 *  03-Jan-1996 -by- Petrus Wong [PetrusW]
01855 * Wrote it.
01856 \**************************************************************************/
01857
01858 LONG lProcessMMStrokeFill(VOID)
01859 {
01860     gbSFOutln = (gbSFOutln ? FALSE : TRUE);
01861     if (gbSFOutln) {
01862         CheckMenuItem(hMenu, MM_TTOUTLN_STROKEFILL, MF_CHECKED);
01863         CheckMenuItem(hMenu, MM_TTOUTLN_POLYDRAW, MF_UNCHECKED);
01864         gbPDOutln = FALSE;
01865     }
01866     return 0L;
01867 }
01868
01869 /******************************Public*Routine******************************\
01870 *
01871 * lProcessMMPolyDraw
01872 *
01873 * Effects:  process the WM_COMMAND MM_TTOUTLN_POLYDRAW message
01874 *
01875 * Warnings:
01876 *
01877 \**************************************************************************/
01878
01879 LONG lProcessMMPolyDraw(VOID)
01880 {
01881     gbPDOutln = (gbPDOutln ? FALSE : TRUE);
01882     if (gbPDOutln) {
01883         CheckMenuItem(hMenu, MM_TTOUTLN_STROKEFILL, MF_UNCHECKED);
01884         CheckMenuItem(hMenu, MM_TTOUTLN_POLYDRAW, MF_CHECKED);
01885         gbSFOutln = FALSE;
01886     }
01887     return 0L;
01888 }
01889
01890 /******************************Public*Routine******************************\
01891 *
01892 * lProcessMMMltfmts
01893 *
01894 * Effects:  process the WM_COMMAND MM_C_MLTFMTS message
01895 *
01896 * Warnings:
01897 *
01898 \**************************************************************************/
01899
01900 LONG lProcessMMMltfmts(VOID)
01901 {
01902     CMTMLTFMT *pMfmt;
01903
01904     if ((gbRecording) && (ghDCMetaf != NULL)) {
01905     if ((pMfmt = pLoadMltFmtFile()) != NULL) {
01906         GdiComment(ghDCMetaf,
01907                sizeof(CMTMLTFMT)+pMfmt->aemrformat[0].cbData,
01908                (CONST BYTE *) pMfmt);
01909         Free(pMfmt);
01910     }
01911     else
01912         MessageBox(ghwndMain,
01913                        GetStringRes(IDS_LDMFMTFILEFAIL),
01914                GetStringRes(IDS_ERROR),
01915                MB_OK);
01916     }
01917
01918     return 0L;
01919 }
01920
01921 /******************************Public*Routine******************************\
01922 *
01923 * lProcessMMHittest
01924 *
01925 * Effects:  process the WM_COMMAND MM_HITTEST message
01926 *
01927 * Warnings:
01928 *
01929 \**************************************************************************/
01930
01931 LONG lProcessMMHittest(VOID)
01932 {
01933     static BOOL bHitTest=FALSE;
01934     HWND    hwndRecBtn;
01935
01936     bHitTest = (bHitTest ? FALSE : TRUE);
01937     hwndRecBtn = GetDlgItem(ghwndCtrlPanel, DID_RECORD);
01938     if (bHitTest) {
01939     CheckMenuItem(hMenu, MM_HITTEST, MF_CHECKED);
01940     EnableMenuItem(hMenu, MM_RECORD, MF_GRAYED);
01941     EnableWindow(hwndRecBtn, FALSE);
01942     gbHitTest = TRUE;
01943     } else {
01944     CheckMenuItem(hMenu, MM_HITTEST, MF_UNCHECKED);
01945     EnableMenuItem(hMenu, MM_RECORD, MF_ENABLED);
01946     EnableWindow(hwndRecBtn, TRUE);
01947     gbHitTest = FALSE;
01948     return 0L;
01949     }
01950
01951     if (ghMetaf == 0) {
01952     SetWindowText(ghTextWnd, GetStringRes(IDS_NOMFLDFORHTST));
01953     return 0L;
01954     }
01955     return 0L;
01956 }
01957
01958 /******************************Public*Routine******************************\
01959 *
01960 * lProcessMMLEAbout
01961 *
01962 * Effects:
01963 *
01964 * Warnings:
01965 *
01966 \**************************************************************************/
01967
01968 LONG lProcessMMLEAbout(VOID)
01969 {
01970     if (DialogBox(ghModule, (LPCSTR)"AboutBox", ghwndMain, (DLGPROC)About) == -1)
01971     MessageBox(ghwndMain, GetStringRes(IDS_DLGABOUTCREFAIL),
01972             GetStringRes(IDS_ERROR), MB_OK);
01973     return 0L;
01974 }
01975
01976 /******************************Public*Routine******************************\
01977 *
01978 * lProcessMMAbout
01979 *
01980 * Effects:
01981 *
01982 * Warnings:
01983 *
01984 \**************************************************************************/
01985
01986 LONG lProcessMMAbout(VOID)
01987 {
01988     if (DialogBox(ghModule, "AboutBox", ghwndMain, (DLGPROC)About) == -1)
01989        MessageBox(ghwndMain, GetStringRes(IDS_DLGABOUTCREFAIL),
01990             GetStringRes(IDS_ERROR), MB_OK);
01991     return 0L;
01992 }
01993
01994 /******************************Public*Routine******************************\
01995 *
01996 * lProcessMMLoadMaskBmp
01997 *
01998 * Effects:
01999 *
02000 * Warnings:
02001 *
02002 \**************************************************************************/
02003
02004 LONG lProcessMMLoadMaskBmp(HWND hwnd)
02005 {
02006     SetWindowText(ghTextWnd, GetStringRes(IDS_LDMSKBM));
02007     bGetBMP(hwnd, TRUE);
02008     return 0L;
02009 }
02010
02011 /******************************Public*Routine******************************\
02012 *
02013 * lProcessMMLoadBmp
02014 *
02015 * Effects:
02016 *
02017 * Warnings:
02018 *
02019 \**************************************************************************/
02020
02021 LONG lProcessMMLoadBmp(HWND hwnd)
02022 {
02023     SetWindowText(ghTextWnd, GetStringRes(IDS_LDBM));
02024     bGetBMP(hwnd, FALSE);
02025     return 0L;
02026 }
02027
02028 /******************************Public*Routine******************************\
02029 *
02030 * lProcessMMSaveBmp
02031 *
02032 * Effects:
02033 *
02034 * Warnings:
02035 *
02036 \**************************************************************************/
02037
02038 LONG lProcessMMSaveBmp(VOID)
02039 {
02040     SetWindowText(ghTextWnd, GetStringRes(IDS_SVDRAWSFASBM));
02041     return 0L;
02042 }
02043
02044 /******************************Public*Routine******************************\
02045 *
02046 * lProcessDIDOpen
02047 *
02048 * Effects:
02049 *
02050 * Warnings:
02051 *
02052 \**************************************************************************/
02053
02054 LONG lProcessDIDOpen(HWND hwnd, CHAR *szLoadedMetaf, BOOL *pbReset)
02055 {
02056     ENHMETAHEADER EnhMetaHdr;
02057     HENHMETAFILE  hEmfTmp;
02058
02059     SetWindowText(ghTextWnd, GetStringRes(IDS_LDMF));
02060     //
02061     // If user hit cancel, we still have the original metafile
02062     //
02063     //DeleteEnhMetaFile(ghMetaf);
02064     //ghMetaf = hemfLoadMetafile(hwnd);
02065     hEmfTmp = hemfLoadMetafile(hwnd);
02066     if (hEmfTmp != 0) {
02067     char     szDesc[MAX_ARRAYSIZE];
02068
02069     if (ghMetaf != (HENHMETAFILE)NULL)
02070             DeleteEnhMetaFile(ghMetaf);
02071     ghMetaf = CopyEnhMetaFile(hEmfTmp, NULL);
02072     GetEnhMetaFileHeader(ghMetaf, sizeof(EnhMetaHdr), &EnhMetaHdr);
02073     SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, EnhMetaHdr.nRecords, FALSE);
02074     DeleteEnhMetaFile(hEmfTmp);
02075     EnableMenuItem(hMenu, MM_COPY,  MF_ENABLED);
02076     if (GetEnhMetaFileDescription(ghMetaf, 256, szDesc) != 0) {
02077         char    szText[MAX_ARRAYSIZE];
02078         char    *szTmp, szSource[MAX_ARRAYSIZE];
02079
02080         szTmp = (char *)strtok(szDesc, "\\0");
02081         strncpy(szSource, szTmp, MAX_ARRAYSIZE - 1);
02082     szSource [MAX_ARRAYSIZE - 1] = '\0';
02083         szTmp = (char *)strtok(NULL, "\\0\\0");
02084         _sntprintf(szText, MAX_ARRAYSIZE - 1, "Source: %s  Title: %s", szSource, szTmp);
02085     szText [MAX_ARRAYSIZE - 1] = '\0';
02086         SetWindowText(ghTextWnd, szText);
02087         strncpy ( szLoadedMetaf, szTmp, MAX_ARRAYSIZE - 1);
02088     szLoadedMetaf [MAX_ARRAYSIZE - 1] = '\0';
02089     } else {
02090         strncpy (szLoadedMetaf, "", MAX_ARRAYSIZE - 1 );
02091     szLoadedMetaf [MAX_ARRAYSIZE - 1] = '\0';
02092     }
02093     //} else {
02094     //    SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, 0, FALSE);
02095     }
02096     *pbReset = TRUE;
02097     return 0L;
02098 }
02099
02100 /******************************Public*Routine******************************\
02101 *
02102 * lProcessMMRec
02103 *
02104 * Effects:
02105 *
02106 * Warnings:
02107 *
02108 \**************************************************************************/
02109
02110 LONG lProcessMMRec(HWND hwnd, CHAR *szFilename)
02111 {
02112     if (gbHitTest) {
02113     SetWindowText(ghTextWnd, GetStringRes(IDS_MUSTESCHTSTMD));
02114     return 0L;
02115     }
02116
02117     SetWindowText(ghTextWnd, GetStringRes(IDS_REC));
02118     if (!gbRecording) {
02119     ghDCMetaf = hDCRecordMetafileAs(hwnd, szFilename);
02120     }
02121
02122     if (ghDCMetaf == NULL) {
02123        SetWindowText(ghTextWnd, GetStringRes(IDS_CREMFDCFAIL));
02124        return 0L;
02125     }
02126
02127     // Parse the szFilename for the title and GdiComment the metafile with it.
02128     {
02129     char    szComment[MAX_ARRAYSIZE];
02130     char    *szTmp, szTmp2[MAX_ARRAYSIZE];
02131
02132     szTmp = (char *)strtok(szFilename, "\\");
02133     strncpy( szTmp2, szTmp, MAX_ARRAYSIZE -1 );
02134   szTmp2 [MAX_ARRAYSIZE - 1] = '\0';
02135     while (szTmp != NULL) {
02136         szTmp = (char *)strtok(NULL, "\\");
02137         if (szTmp != NULL) {
02138         strncpy( szTmp2, szTmp, MAX_ARRAYSIZE -1 );
02139     szTmp2 [MAX_ARRAYSIZE - 1] = '\0';
02140         }
02141     }
02142     szTmp = (char *)strtok(szTmp2, ".");
02143     _sntprintf((LPSTR) szComment,MAX_ARRAYSIZE - 1, "MfEdit:\\0%s\\0\\0", szTmp);
02144   szComment [MAX_ARRAYSIZE - 1] = '\0';
02145 #if 0
02146     if (!GdiComment(ghDCMetaf, 256, szComment)) {
02147         MessageBox(ghwndMain, GetStringRes(IDS_ADDCMNTFAIL),
02148                 GetStringRes(IDS_ERROR), MB_OK);
02149     }
02150 #endif
02151     }
02152
02153     gbRecording = TRUE;
02154
02155     if (ghpnCur != NULL)
02156     SelectObject(ghDCMetaf, ghpnCur);
02157
02158     if (ghbrCur != NULL)
02159     SelectObject(ghDCMetaf, ghbrCur);
02160
02161     if (ghCurFont != NULL)
02162     SelectObject(ghDCMetaf, ghCurFont);
02163     return 0L;
02164 }
02165
02166 /******************************Public*Routine******************************\
02167 *
02168 * lProcessDIDRec
02169 *
02170 * Effects:
02171 *
02172 * Warnings:
02173 *
02174 \**************************************************************************/
02175
02176 LONG lProcessDIDRec(HWND hwnd, INT *piMetafCnt, char *szFilename)
02177 {
02178     int  iWidthMM, iHeightMM, iWidthPels, iHeightPels, iMMPerPelX, iMMPerPelY;
02179     char szComment[MAX_ARRAYSIZE];
02180     char szTitle[MAX_ARRAYSIZE];
02181     RECT rc;
02182     HDC  hDC;
02183
02184
02185     if (gbHitTest) {
02186     SetWindowText(ghTextWnd, GetStringRes(IDS_MUSTESCHTSTMD));
02187     return 0L;
02188     }
02189
02190     SetWindowText(ghTextWnd, GetStringRes(IDS_REC));
02191     if (!gbRecording) {
02192
02193     hDC = GetDC(hwnd);
02194     iWidthMM    = GetDeviceCaps(hDC, HORZSIZE);
02195     iHeightMM   = GetDeviceCaps(hDC, VERTSIZE);
02196     iWidthPels  = GetDeviceCaps(hDC, HORZRES);
02197     iHeightPels = GetDeviceCaps(hDC, VERTRES);
02198     ReleaseDC(hwnd, hDC);
02199     iMMPerPelX  = (iWidthMM * 100)/iWidthPels;
02200     iMMPerPelY  = (iHeightMM * 100)/iHeightPels;
02201     GetClientRect(ghwndDrawSurf, &rc);
02202     rc.left   = rc.left * iMMPerPelX;
02203     rc.top    = rc.top * iMMPerPelY;
02204     rc.right  = rc.right * iMMPerPelX;
02205     rc.bottom = rc.bottom * iMMPerPelY;
02206
02207     {
02208        char szFilenameWithExt[MAX_ARRAYSIZE];
02209        char suffix[20];
02210        char szDesc[MAX_ARRAYSIZE];
02211        char *szTmp, szTmp2[MAX_ARRAYSIZE];
02212
02213        //
02214        // assemble a new metafile name with the emf extension from
02215        // the generic szFilename
02216        //
02217        _sntprintf((LPSTR) suffix, 19, "%d.emf", *piMetafCnt);
02218      suffix [19] = '\0';
02219        (*piMetafCnt)++;
02220        strncpy(szFilenameWithExt, szFilename, MAX_ARRAYSIZE - 1);
02221        szFilenameWithExt [MAX_ARRAYSIZE - 1] = '\0'; // make sure its null terminated for strlen
02222        suffix [19] = '\0'; // make sure its null terminated for strlen
02223        if ((strlen(szFilenameWithExt)+strlen(suffix))/sizeof(char) >= MAX_ARRAYSIZE) // safe: both strings are null terminated
02224            return 0L;
02225        else
02226            strncat(szFilenameWithExt, suffix, sizeof (szFilenameWithExt) - strlen (szFilenameWithExt));
02227        //
02228        // parse szFilename for the title for description
02229        //
02230        szTmp = (char *)strtok(szFilename, "\\");
02231        strncpy( szTmp2, szTmp, MAX_ARRAYSIZE - 1);
02232      szTmp2 [MAX_ARRAYSIZE - 1] = '\0';
02233        while (szTmp != NULL) {
02234            szTmp = (char *)strtok(NULL, "\\");
02235            if (szTmp != NULL) {
02236             strncpy( szTmp2, szTmp, MAX_ARRAYSIZE - 1);
02237       szTmp2 [MAX_ARRAYSIZE - 1] = '\0';
02238            }
02239        }
02240        szTmp = (char *)strtok(szTmp2, ".");
02241        strncpy(szTitle, szTmp, MAX_ARRAYSIZE - 1);
02242      szTitle [MAX_ARRAYSIZE - 1] = '\0';
02243        _sntprintf(szDesc, MAX_ARRAYSIZE - 1, "SDK Enhanced Metafile Editor\\0%s\\0\\0", szTitle);
02244        szDesc [MAX_ARRAYSIZE - 1] = '\0';
02245      ghDCMetaf = CreateEnhMetaFile((HDC)NULL, szFilenameWithExt, (LPRECT)&rc, (LPSTR)szDesc);
02246            if (gb3D)
02247                 bSetupRC(ghDCMetaf, NULL);
02248     }
02249
02250         bSetAdvancedGraphics(ghDCMetaf);
02251     }
02252
02253     if (ghDCMetaf == NULL) {
02254        SetWindowText(ghTextWnd, GetStringRes(IDS_CREMFDCFAIL));
02255        return 0L;
02256     }
02257     _sntprintf((LPSTR) szComment, MAX_ARRAYSIZE - 1,"MfEdit:\\0%s\\0\\0", szTitle);
02258   szComment [MAX_ARRAYSIZE - 1] = '\0';
02259 #if 0
02260     if (!GdiComment(ghDCMetaf, 256, szComment)) {
02261     MessageBox(ghwndMain, GetStringRes(IDS_ADDCMNTFAIL),
02262             GetStringRes(IDS_ERROR), MB_OK);
02263     }
02264 #endif
02265     gbRecording = TRUE;
02266
02267     if (ghpnCur != NULL)
02268     SelectObject(ghDCMetaf, ghpnCur);
02269
02270     if (ghbrCur != NULL)
02271     SelectObject(ghDCMetaf, ghbrCur);
02272
02273     if (ghCurFont != NULL)
02274     SelectObject(ghDCMetaf, ghCurFont);
02275
02276     return 0L;
02277 }
02278
02279
02280 /******************************Public*Routine******************************\
02281 *
02282 * lProcessDIDStop
02283 *
02284 * Effects:
02285 *
02286 * Warnings:
02287 *
02288 \**************************************************************************/
02289
02290 LONG lProcessDIDStop(VOID)
02291 {
02292     SetWindowText(ghTextWnd, GetStringRes(IDS_STOP));
02293     if (gbRecording) {
02294         if (gb3D && gbRCSet)
02295             bCleanUpRC();
02296     ghMetaf = CloseEnhMetaFile(ghDCMetaf);
02297     gbRecording = FALSE;
02298     }
02299     return 0L;
02300 }
02301
02302 /******************************Public*Routine******************************\
02303 *
02304 * lProcessDIDPlay
02305 *
02306 * Effects:
02307 *
02308 * Warnings:
02309 *
02310 \**************************************************************************/
02311
02312 LONG lProcessDIDPlay(char *szLoadedMetaf)
02313 {
02314     HDC                     hDCDrawSurf;
02315     ENHMETAHEADER           EnhMetaHdr;
02316     RECT                    rcClientDS;
02317     int                     iEntries;
02318     PLOGPALETTE             plogPal;
02319     PBYTE                   pjTmp;
02320     HPALETTE                hPal=NULL;
02321     char                    szTmp[MAX_ARRAYSIZE];
02322     BOOL            bRCSet = FALSE;
02323 #ifdef OPENGL_EMF
02324     PIXELFORMATDESCRIPTOR   pfd;
02325 #endif
02326     BOOL                    bHasPFD = TRUE;
02327
02328
02329     _sntprintf(szTmp, MAX_ARRAYSIZE - 1, GetStringRes(IDS_FMT_PLAYMF), szLoadedMetaf);
02330   szTmp [MAX_ARRAYSIZE - 1] = '\0';
02331     SetWindowText(ghTextWnd, szTmp);
02332     if (ghMetaf != NULL) {
02333     hDCDrawSurf = GetDC(ghwndDrawSurf);
02334     GetEnhMetaFileHeader(ghMetaf, sizeof(ENHMETAHEADER), &EnhMetaHdr);
02335
02336     iEntries = GetEnhMetaFilePaletteEntries(ghMetaf, 0, NULL);
02337
02338     if (iEntries) {
02339         if ((plogPal = (PLOGPALETTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
02340             sizeof(DWORD) + sizeof(PALETTEENTRY)*iEntries )) == NULL) {
02341         MessageBox(ghwndMain, GetStringRes(IDS_CREPALFAIL),
02342                     GetStringRes(IDS_ERROR), MB_OK);
02343         }
02344             else {
02345         plogPal->palVersion = 0x300;
02346         plogPal->palNumEntries = (WORD) iEntries;
02347         pjTmp = (PBYTE) plogPal;
02348         pjTmp += 4;
02349
02350         GetEnhMetaFilePaletteEntries(ghMetaf, iEntries, (PPALETTEENTRY)pjTmp);
02351         hPal = CreatePalette(plogPal);
02352         GlobalFree(plogPal);
02353
02354         SelectPalette(hDCDrawSurf, hPal, FALSE);
02355         RealizePalette(hDCDrawSurf);
02356             }
02357     }
02358
02359 #ifdef OPENGL_EMF
02360         bRCSet = bSetRC2MatchEmfRC(hDCDrawSurf, EnhMetaHdr, ghMetaf, &pfd);
02361         bHasPFD = (pfd.nSize != 0) ? TRUE : FALSE;
02362         if (!bRCSet) {
02363             vErrOut("lProcessDIDPlay (DspDC) failed");
02364         }
02365 #endif
02366     if (gbFit2Wnd) {
02367         GetClientRect(ghwndDrawSurf, &rcClientDS);
02368         if (!PlayEnhMetaFile( hDCDrawSurf, ghMetaf, (LPRECT) &rcClientDS)) {
02369         char    text[128];
02370
02371         _sntprintf(text, 127, GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
02372     text [127] = '\0';
02373         OutputDebugString(text);
02374         } else {
02375                 if (gbDB)
02376                    SwapBuffers(hDCDrawSurf);
02377             }
02378     } else {
02379         RECT rc;
02380
02381         rc.top = rc.left = 0;
02382         rc.right = EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left;
02383         rc.bottom = EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top;
02384         if (!PlayEnhMetaFile( hDCDrawSurf, ghMetaf, (LPRECT) &rc)) {
02385         char    text[128];
02386
02387         _sntprintf(text, 127, GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
02388     text [127] = '\0';
02389         OutputDebugString(text);
02390         } else {
02391                 if (gbDB)
02392                    SwapBuffers(hDCDrawSurf);
02393             }
02394     }
02395
02396         if (bRCSet) {
02397             bCleanUpRC();
02398             bRCSet = FALSE;
02399         }
02400
02401     //
02402     // Enabling the user to embed another metafile
02403     //
02404     if ((gbRecording) && (ghDCMetaf != NULL)) {
02405         if (hPal != (HPALETTE)NULL) {
02406         SelectPalette(ghDCMetaf, hPal, FALSE);
02407         RealizePalette(ghDCMetaf);
02408         }
02409
02410 #ifdef OPENGL_EMF
02411             if (EnhMetaHdr.bOpenGL && !gbRCSet) {
02412                 char        text[128];
02413
02414                 bRCSet = bSetupRC(ghDCMetaf, (bHasPFD ? &pfd : NULL));
02415                 _sntprintf(text,127,
02416                          "lProcessDIDPlay: (MetaDC) bRCSet=%ld, bHasPFD=%ld",
02417                          bRCSet, bHasPFD);
02418         text [127] = '\0';
02419                 vErrOut(text);
02420             }
02421 #endif
02422         {
02423         RECT rc;
02424
02425         rc.top = rc.left = 0;
02426         rc.right = EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left;
02427         rc.bottom = EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top;
02428         if (!PlayEnhMetaFile( ghDCMetaf, ghMetaf, (LPRECT) &rc)) {
02429         char    text[128];
02430
02431         _sntprintf(text, 127, GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
02432     text [127] = '\0';
02433         OutputDebugString(text);
02434         } else {
02435                 if (gbDB)
02436                    SwapBuffers(ghDCMetaf);
02437             }
02438
02439
02440             if (bRCSet) {
02441                 bCleanUpRC();
02442             }
02443
02444         }
02445     }
02446
02447     ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
02448     } else {
02449     SetWindowText(ghTextWnd, GetStringRes(IDS_NOMFFORPLAY));
02450     }
02451
02452     return 0L;
02453 }
02454
02455 /******************************Public*Routine******************************\
02456 *
02457 * lProcessDIDFf
02458 *
02459 * Effects:
02460 *
02461 * Warnings:
02462 *
02463 \**************************************************************************/
02464
02465 LONG lProcessDIDFf(BOOL *pbReset)
02466 {
02467     HDC         hDCDrawSurf;
02468     ENHMETAHEADER   EnhMetaHdr;
02469     RECT        rcClientDS;
02470     static int      iRecord = 0;
02471     PLAYINFO        PlayInfo;
02472     int         iEntries;
02473     PLOGPALETTE     plogPal;
02474     PBYTE       pjTmp;
02475     HPALETTE        hPal=NULL;
02476     static BOOL     bInitRC = FALSE;
02477     static BOOL     bRCSet = FALSE;
02478     BOOL        bHasPFD = FALSE;
02479
02480     if (ghMetaf == 0)
02481     return 0L;
02482
02483     PlayInfo.iRecord = ++iRecord;
02484     PlayInfo.bPlayContinuous = TRUE;
02485
02486     GetEnhMetaFileHeader(ghMetaf, sizeof(EnhMetaHdr), &EnhMetaHdr);
02487     SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, iRecord, FALSE);
02488     if ((EnhMetaHdr.nRecords > 1) && (iRecord <= (INT)EnhMetaHdr.nRecords)) {
02489     hDCDrawSurf = GetDC(ghwndDrawSurf);
02490
02491     iEntries = GetEnhMetaFilePaletteEntries(ghMetaf, 0, NULL);
02492
02493     if (iEntries) {
02494         if ((plogPal = (PLOGPALETTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
02495             sizeof(DWORD) + sizeof(PALETTEENTRY)*iEntries )) == NULL) {
02496         MessageBox(ghwndMain, GetStringRes(IDS_CREPALFAIL),
02497                     GetStringRes(IDS_ERROR), MB_OK);
02498         }
02499             else {
02500         plogPal->palVersion = 0x300;
02501         plogPal->palNumEntries = (WORD) iEntries;
02502         pjTmp = (PBYTE) plogPal;
02503         pjTmp += 4;
02504
02505         GetEnhMetaFilePaletteEntries(ghMetaf, iEntries, (PPALETTEENTRY)pjTmp);
02506         hPal = CreatePalette(plogPal);
02507         GlobalFree(plogPal);
02508
02509         SelectPalette(hDCDrawSurf, hPal, FALSE);
02510         RealizePalette(hDCDrawSurf);
02511         }
02512     }
02513
02514         if (!bInitRC) {
02515             bRCSet = bSetRC2MatchEmfRC(hDCDrawSurf, EnhMetaHdr, ghMetaf, NULL);
02516             bInitRC = TRUE;
02517             if (!bRCSet) {
02518                 vErrOut("lProcessDIDFf failed");
02519             }
02520         }
02521
02522     if (gbFit2Wnd) {
02523         GetClientRect(ghwndDrawSurf, &rcClientDS);
02524         EnumEnhMetaFile(hDCDrawSurf, ghMetaf, (ENHMFENUMPROC)bPlayRecord, (LPVOID) &PlayInfo, (LPRECT) &rcClientDS);
02525     } else {
02526         EnumEnhMetaFile(hDCDrawSurf, ghMetaf, (ENHMFENUMPROC)bPlayRecord, (LPVOID) &PlayInfo, (LPRECT) &EnhMetaHdr.rclBounds);
02527     }
02528     //
02529     // Enabling the user to record a metafile records selectively
02530     //
02531     if ((gbRecording) && (ghDCMetaf != NULL) && (hPal != NULL)) {
02532         SelectPalette(ghDCMetaf, hPal, FALSE);
02533         RealizePalette(ghDCMetaf);
02534         EnumEnhMetaFile(ghDCMetaf, ghMetaf, (ENHMFENUMPROC)bPlayRecord, (LPVOID) &PlayInfo, (LPRECT)&EnhMetaHdr.rclBounds);
02535     }
02536
02537     ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
02538     }
02539
02540     if ((iRecord == (INT) EnhMetaHdr.nRecords) || *pbReset) {
02541     iRecord = 0;
02542     if (*pbReset)
02543         SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, 0, FALSE);
02544     *pbReset = FALSE;
02545
02546         if (bRCSet) {
02547             bCleanUpRC();
02548             bRCSet = FALSE;
02549         }
02550
02551         bInitRC = FALSE;
02552     }
02553     return 0L;
02554 }
02555
02556 /******************************Public*Routine******************************\
02557 *
02558 * lProcessDIDClear
02559 *
02560 * Effects:
02561 *
02562 * Warnings:
02563 *
02564 \**************************************************************************/
02565
02566 LONG lProcessDIDClear(VOID)
02567 {
02568     HDC     hDCDrawSurf;
02569     HGDIOBJ hObjOld;
02570     RECT    rcDrawSurf;
02571
02572     SetWindowText(ghTextWnd, GetStringRes(IDS_DRAWSFCLR));
02573     hDCDrawSurf = GetDC(ghwndDrawSurf);
02574     ghbrAppBkgd = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
02575     hObjOld = SelectObject(hDCDrawSurf, ghbrAppBkgd);
02576     GetClientRect(ghwndDrawSurf, &rcDrawSurf);
02577     PatBlt(hDCDrawSurf, 0, 0, rcDrawSurf.right, rcDrawSurf.bottom, PATCOPY);
02578     ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
02579     SelectObject(hDCDrawSurf, hObjOld);
02580     return 0L;
02581 }
02582
02583 /******************************Public*Routine******************************\
02584 *
02585 * lProcessMMImport3X
02586 *
02587 * Effects:
02588 *
02589 * Warnings:
02590 *
02591 \**************************************************************************/
02592
02593 LONG lProcessMMImport3X(VOID)
02594 {
02595     gbImport3X = (gbImport3X ? FALSE : TRUE);
02596
02597     if (gbImport3X)
02598     CheckMenuItem(hMenu, MM_IMPORT_3X, MF_CHECKED);
02599     else
02600     CheckMenuItem(hMenu, MM_IMPORT_3X, MF_UNCHECKED);
02601     return 0L;
02602 }
02603
02604 /******************************Public*Routine******************************\
02605 *
02606 * lProcessMMExport3X
02607 *
02608 * Effects:
02609 *
02610 * Warnings:
02611 *
02612 \**************************************************************************/
02613
02614 LONG lProcessMMExport3X(VOID)
02615 {
02616     gbExport3X = (gbExport3X ? FALSE : TRUE);
02617
02618     if (gbExport3X)
02619     CheckMenuItem(hMenu, MM_EXPORT_3X, MF_CHECKED);
02620     else
02621     CheckMenuItem(hMenu, MM_EXPORT_3X, MF_UNCHECKED);
02622     return 0L;
02623 }
02624
02625 /******************************Public*Routine******************************\
02626 *
02627 * lProcessMMFit2Wnd
02628 *
02629 * Effects:
02630 *
02631 * Warnings:
02632 *
02633 \**************************************************************************/
02634
02635 LONG lProcessMMFit2Wnd(VOID)
02636 {
02637     gbFit2Wnd = (gbFit2Wnd ? FALSE : TRUE);
02638
02639     if (gbFit2Wnd)
02640     CheckMenuItem(hMenu, MM_FIT2WND, MF_CHECKED);
02641     else
02642     CheckMenuItem(hMenu, MM_FIT2WND, MF_UNCHECKED);
02643     return 0L;
02644 }
02645
02646 /******************************Public*Routine******************************\
02647 *
02648 * lProcessMMPrint
02649 *
02650 * Effects:
02651 *
02652 * Warnings:
02653 *
02654 \**************************************************************************/
02655
02656 LONG lProcessMMPrint(VOID)
02657 {
02658     DWORD   dwThrdID;
02659     HANDLE  hThrd;
02660     PPRTDATA pPrtData;
02661
02662     if (ghMetaf == 0) {
02663     SetWindowText(ghTextWnd, GetStringRes(IDS_NOMFFORPRT));
02664     return 0L;
02665     }
02666
02667     //
02668     // bPrintMf is supposed to free up the memory when done.
02669     //
02670     if ((pPrtData = (PPRTDATA) GlobalAlloc(GPTR, sizeof(PRTDATA))) == NULL) {
02671     SetWindowText(ghTextWnd, GetStringRes(IDS_MALLOCFAIL2));
02672     return 0L;
02673     }
02674
02675     pPrtData->hMetaf = ghMetaf;
02676     pPrtData->bFit2Wnd = gbFit2Wnd;
02677
02678     hThrd = CreateThread(NULL, 0,
02679          (LPTHREAD_START_ROUTINE)bPrintMf,
02680          pPrtData, STANDARD_RIGHTS_REQUIRED,
02681          &dwThrdID);
02682
02683     //
02684     // Free the memory if CreateThread fails...
02685     //
02686     if (hThrd == NULL) {
02687     SetWindowText(ghTextWnd, GetStringRes(IDS_CREPRTTHRDFAIL));
02688     GlobalFree(pPrtData);
02689     }
02690
02691     return 0L;
02692 }
02693
02694 /******************************Public*Routine******************************\
02695 *
02696 * lProcessWmCommand
02697 *
02698 * Effects:
02699 *
02700 * Warnings:
02701 *
02702 \**************************************************************************/
02703
02704 LONG_PTR lProcessWmCommand(HWND     hwnd,
02705                        UINT     message,
02706                        WPARAM    wParam,
02707                        LPARAM    lParam,
02708                        INT      *piMetafCnt,
02709                        BOOL     *pbReset,
02710                        char     *szFilename,
02711                        char     *szLoadedMetaf)
02712 {
02713     static int     iPlus=0;
02714
02715     switch (LOWORD(wParam)) {
02716         case DID_ZERO:
02717         case DID_ONE:
02718         case DID_TWO:
02719         case DID_THREE:
02720         case DID_FOUR:
02721         case DID_FIVE:
02722         case DID_SIX:
02723         case DID_SEVEN:
02724         case DID_EIGHT:
02725         case DID_NINE:
02726             return lProcessDIDPlayStep(wParam, &iPlus);
02727
02728         case DID_TEN_PLUS:
02729             return lProcessDIDPlayTenPlus(&iPlus);
02730
02731         case MM_PAGESETUP:
02732         case MM_CUT:
02733             return 0L;
02734
02735         case MM_COPY:
02736             return lProcessMMCopy();
02737
02738         case MM_PASTE:
02739             return lProcessMMPaste(hwnd, pbReset);
02740
02741         case MM_DEL:
02742             return lProcessMMDel();
02743
02744         case MM_PEN:
02745             return lProcessMMPen(hwnd);
02746
02747         case MM_BRUSH:
02748             return lProcessMMBrush(hwnd);
02749
02750         case MM_FONT:
02751             return lProcessMMFont();
02752
02753         case MM_TTOUTLN_STROKEFILL:
02754             return lProcessMMStrokeFill();
02755
02756         case MM_TTOUTLN_POLYDRAW:
02757             return lProcessMMPolyDraw();
02758
02759         case MM_C_WND_MF:
02760         return 0L;
02761
02762         case MM_C_BEGIN_GP:
02763         case MM_C_END_GP:
02764         return 0L;
02765
02766     case MM_C_MLTFMTS:
02767         return lProcessMMMltfmts();
02768
02769     case MM_HITTEST:
02770         return lProcessMMHittest();
02771
02772     case MM_LEABOUT:
02773         return lProcessMMLEAbout();
02774
02775     case MM_ABOUT:
02776         return lProcessMMAbout();
02777
02778     case MM_LOAD_MASKBMP:
02779         return lProcessMMLoadMaskBmp(hwnd);
02780
02781     case MM_LOAD_BMP:
02782         return lProcessMMLoadBmp(hwnd);
02783
02784     case MM_SAVE_BMP:
02785         return lProcessMMSaveBmp();
02786
02787         case MM_LOAD:
02788     case DID_OPEN:
02789         return lProcessDIDOpen(hwnd, szLoadedMetaf, pbReset);
02790
02791     case MM_RECORD:
02792         return lProcessMMRec(hwnd, szFilename);
02793
02794     case DID_RECORD:
02795         return lProcessDIDRec(hwnd, piMetafCnt, szFilename);
02796
02797     case DID_STOP:
02798         return lProcessDIDStop();
02799
02800     case DID_PLAY:
02801         return lProcessDIDPlay(szLoadedMetaf);
02802
02803     case DID_FF:
02804         return lProcessDIDFf(pbReset);
02805
02806     case DID_CLEAR:
02807         return lProcessDIDClear();
02808
02809         case DID_PEN:
02810             SetWindowText(ghTextWnd, "Pen");
02811             return 0L;
02812         case DID_TEXT:
02813             SetWindowText(ghTextWnd, "Text");
02814             return 0L;
02815         case DID_RECT:
02816             SetWindowText(ghTextWnd, "Rectangle");
02817             return 0L;
02818         case DID_FILLRECT:
02819             SetWindowText(ghTextWnd, "Filled Rectangle");
02820             return 0L;
02821         case DID_ELLIPSE:
02822             SetWindowText(ghTextWnd, "Ellipse");
02823             return 0L;
02824         case DID_FILLELLIPSE:
02825             SetWindowText(ghTextWnd, "Filled Ellipse");
02826             return 0L;
02827         case DID_LINE:
02828             SetWindowText(ghTextWnd, "Line");
02829             return 0L;
02830         case DID_BEZIER:
02831             SetWindowText(ghTextWnd,
02832                 "Bezier: Click with Left button for placing control points");
02833             return 0L;
02834         case DID_BMPOBJ:
02835             SetWindowText(ghTextWnd,
02836                 "Bitmap: Click three points for the destination of the bitmap");
02837             return 0L;
02838         case DID_METAF:
02839             SetWindowText(ghTextWnd,
02840                 "External Metafile: Click three points for the destination of the Metafile");
02841             return 0L;
02842     case MM_IMPORT_3X:
02843         return lProcessMMImport3X();
02844
02845     case MM_EXPORT_3X:
02846         return lProcessMMExport3X();
02847
02848     case MM_FIT2WND:
02849         return lProcessMMFit2Wnd();
02850
02851     case MM_PRINT:
02852         return lProcessMMPrint();
02853
02854     default:
02855             return DefWindowProc(hwnd, message, wParam, lParam);
02856     }
02857 }
02858
02859 /***************************************************************************\
02860 * MainWndProc
02861 *
02862 \***************************************************************************/
02863
02864 LONG_PTR APIENTRY MainWndProc(
02865     HWND hwnd,
02866     UINT message,
02867     WPARAM wParam,
02868     LPARAM lParam)
02869 {
02870     static int         iMetafCnt=0;
02871     static char        szFilename[MAX_ARRAYSIZE] = "c:\\metaf";
02872     static BOOL        bReset=FALSE;
02873     static char        szLoadedMetaf[MAX_ARRAYSIZE] = " ";
02874
02875     switch (message) {
02876
02877       case WM_CREATE: {
02878         return lProcessWmCreate(hwnd);
02879       }
02880       case WM_DRAWCLIPBOARD: {
02881         return lProcessWmDrawClip(message, wParam, lParam);
02882       }
02883       case WM_SIZE: {
02884         return lProcessWmSize(hwnd, message, wParam, lParam);
02885       }
02886
02887       case WM_DESTROY: {
02888         return lProcessWmDestroy();
02889       }
02890       case WM_COMMAND: {
02891         return lProcessWmCommand(hwnd,
02892                                  message,
02893                                  wParam,
02894                                  lParam,
02895                                  &iMetafCnt,
02896                                  &bReset,
02897                                  szFilename,
02898                                  szLoadedMetaf);
02899       }
02900       default:
02901         return DefWindowProc(hwnd, message, wParam, lParam);
02902     }
02903 }
02904
02905 /******************************Public*Routine******************************\
02906 *
02907 * DrawSurfWndProc
02908 *       Drawing surface window procedure
02909 *
02910 * Effects:  Trapping all mouse messages and call the DrawStuff appropriately
02911 *           for drawing to the drawing surface DC and metafile DC as needed.
02912 *
02913 * Warnings:
02914 *
02915 \**************************************************************************/
02916
02917 LONG_PTR APIENTRY DrawSurfWndProc(
02918     HWND hwnd,
02919     UINT message,
02920     WPARAM wParam,
02921     LPARAM lParam)
02922 {
02923     static BOOL    bTrack = FALSE;
02924     static int     OrgX, OrgY;
02925     static int     PrevX, PrevY;
02926     static HDC     hDC;
02927     static HCURSOR hCurArrow, hCurHT;
02928     static BOOL    b3DSetup = FALSE;
02929
02930     switch (message) {
02931     case WM_CREATE: {
02932         RECT                    rect;
02933
02934         hDC = GetDC(hwnd);
02935
02936             {
02937             char text[128];
02938
02939             _sntprintf(text, 127, "DrawSurfWndProc: hDC=%p", hDC);
02940             text [127] = '\0';
02941       vErrOut(text);
02942             }
02943
02944             bSetAdvancedGraphics(hDC);
02945
02946             if (gb3D)
02947                 b3DSetup = bSetupRC(hDC, NULL);
02948
02949         ReleaseDC(hwnd, hDC);
02950
02951         GetClientRect(GetParent(hwnd), &rect);
02952
02953         SetWindowPos(hwnd, NULL,
02954             0,
02955             30,
02956             rect.right-rect.left,
02957             rect.bottom-rect.top-30,
02958             SWP_NOZORDER | SWP_NOMOVE);
02959             CreateCaret(hwnd, NULL, 1, CARET_HEIGHT);
02960 #if 0
02961         //CreateCaret(hwnd, NULL, 1, 12);
02962         //hbmp = LoadBitmap(ghModule, (LPCSTR)MAKEINTRESOURCE(BMID_TOOLBASED));
02963
02964         hPal = CreatePalette((LOGPALETTE *)&LogPal);
02965         hDC = GetDC(hwnd);
02966         hOldPal = SelectPalette(hDC, hPal, FALSE);
02967         RealizePalette(hDC);
02968
02969         hbmp = CreateDIBitmap(hDC, (LPBITMAPINFOHEADER)&DIBHdr, CBM_CREATEDIB, &dib, (LPBITMAPINFO)&DIBHdr, DIB_PAL_COLORS);
02970         CreateCaret(hwnd, hbmp, 1, 12);
02971
02972         ReleaseDC(hwnd, hDC);
02973 #endif
02974
02975         ghCurFont = GetStockObject(SYSTEM_FONT);
02976         GetObject(ghCurFont, sizeof(LOGFONT), &glf);
02977         hCurArrow = LoadCursor(NULL, IDC_ARROW);
02978         hCurHT = LoadCursor(NULL, IDC_CROSS);
02979         break;
02980     }
02981
02982     case WM_LBUTTONDOWN: {
02983         int    x, y;
02984
02985         x = (int) LOWORD(lParam);
02986         y = (int) HIWORD(lParam);
02987
02988         if (gbHitTest) {
02989         hDC = GetDC(hwnd);
02990         bHitTest(hDC, x, y);
02991         ReleaseDC(hwnd, hDC);
02992         break;
02993         }
02994
02995         bTrack = TRUE;
02996         OrgX = PrevX = x;
02997         OrgY = PrevY = y;
02998
02999         hDC = GetDC(hwnd);
03000         SetCapture(hwnd);
03001         break;
03002     }
03003
03004     case WM_MOUSEMOVE: {
03005         RECT rectClient;
03006         int NextX;
03007         int NextY;
03008
03009         if (gbHitTest) {
03010         SetCursor(hCurHT);
03011         } else {
03012         SetCursor(hCurArrow);
03013         }
03014
03015         // Update the selection region
03016         if (bTrack) {
03017         NextX = (SHORT) LOWORD(lParam);
03018         NextY = (SHORT) HIWORD(lParam);
03019
03020         // Do not draw outside the window's client area
03021
03022         GetClientRect (hwnd, &rectClient);
03023         if (NextX < rectClient.left) {
03024             NextX = rectClient.left;
03025         } else if (NextX >= rectClient.right) {
03026             NextX = rectClient.right - 1;
03027         }
03028         if (NextY < rectClient.top) {
03029             NextY = rectClient.top;
03030         } else if (NextY >= rectClient.bottom) {
03031             NextY = rectClient.bottom - 1;
03032         }
03033         if ((NextX != PrevX) || (NextY != PrevY)) {
03034            SetROP2(hDC, R2_NOT);       // Erases the previous box
03035            bDrawStuff(hDC, OrgX, OrgY, PrevX, PrevY, TRUE, TRUE, FALSE, NULL);
03036
03037            //
03038            // Optimization.  Do not record in metafile DC if it is going
03039            // to be erased.  So only call bDrawStuff with the PEN tool.
03040            //
03041            if (gbRecording && (ghDCMetaf != NULL) && (gdwCurTool == DID_PEN)) {
03042                bDrawStuff(ghDCMetaf, OrgX, OrgY, PrevX, PrevY, TRUE, TRUE, FALSE, NULL);
03043            }
03044
03045
03046         // Get the current mouse position
03047            PrevX = NextX;
03048            PrevY = NextY;
03049
03050            //
03051            // SetROP2(hDC, R2_COPYPEN);
03052            //   This is commented out because we don't want to erase
03053            //   the background as it sweeps.
03054            //
03055            bDrawStuff(hDC, OrgX, OrgY, PrevX, PrevY, FALSE, TRUE, FALSE, NULL);
03056
03057            if (gbRecording && (ghDCMetaf != NULL) && (gdwCurTool == DID_PEN)) {
03058                bDrawStuff(ghDCMetaf, OrgX, OrgY, PrevX, PrevY, FALSE, TRUE, FALSE, NULL);
03059            }
03060
03061         }
03062         }
03063         break;
03064
03065     }
03066
03067       case WM_LBUTTONUP: {
03068         int NextX;
03069         int NextY;
03070
03071         if (!bTrack)
03072            break;
03073
03074         // End the selection
03075            ReleaseCapture();
03076            bTrack = FALSE;
03077
03078         // Erases the box
03079            //
03080            // SetROP2(hDC, R2_NOT);
03081            //   This is assumed to be R2_NOT, thus unnecessary
03082            //
03083            bDrawStuff(hDC, OrgX, OrgY, PrevX, PrevY, TRUE, FALSE, FALSE, NULL);
03084
03085            if (gbRecording && (ghDCMetaf != NULL) && (gdwCurTool == DID_PEN)) {
03086                bDrawStuff(ghDCMetaf, OrgX, OrgY, PrevX, PrevY, TRUE, FALSE, FALSE, NULL);
03087            }
03088
03089            //
03090            // Apparently, at buttonup time, the mouse location is not clamped to
03091            // the client area.  So, the final ellipse or rectangle will be extended
03092            // outside the client area.
03093            //
03094            // NextX = (SHORT) LOWORD(lParam);
03095            // NextY = (SHORT) HIWORD(lParam);
03096            NextX = PrevX;
03097            NextY = PrevY;
03098
03099         // Draws the new box
03100            SetROP2(hDC, R2_COPYPEN);
03101            bDrawStuff(hDC, OrgX, OrgY, NextX, NextY, FALSE, FALSE, TRUE, NULL);
03102
03103            ReleaseDC(hwnd, hDC);
03104
03105            if (gbRecording && (ghDCMetaf != NULL)) {
03106                 bDrawStuff(ghDCMetaf, OrgX, OrgY, NextX, NextY, FALSE, FALSE, FALSE, NULL);
03107            }
03108
03109         break;
03110       } // case WM_LBUTTONUP
03111
03112 #ifdef JAPAN
03113       case WM_IME_REPORT:
03114         if (IR_STRING == wParam) {
03115             LPSTR   lpsz, lpszMeta;
03116
03117             if (!(lpsz = lpszMeta = GlobalLock((HANDLE)lParam))) {
03118                 return FALSE;
03119             }
03120             hDC = GetDC(hwnd);
03121         while(*lpsz) { // Draw all characters in the string
03122         bDrawStuff(hDC, 0, 0, 0, 0, TRUE, FALSE, FALSE, lpsz);
03123         IsDBCSLeadByte((BYTE)*lpsz) ? lpsz += 2 : ++lpsz;
03124         }
03125             ReleaseDC(hwnd, hDC);
03126             if (gbRecording && (ghDCMetaf != NULL)) {
03127         while(*lpszMeta) { // Draw all characters in the string
03128             bDrawStuff(ghDCMetaf, 0, 0, 0, 0, TRUE, FALSE, FALSE, lpszMeta);
03129             IsDBCSLeadByte((BYTE)*lpszMeta) ? lpszMeta += 2 : ++lpszMeta;
03130         }
03131             }
03132             GlobalUnlock((HANDLE)lParam);
03133             return TRUE;
03134         }
03135     return DefWindowProc(hwnd, message, wParam, lParam);
03136         break;
03137 #endif
03138
03139       case WM_CHAR: {
03140
03141         if (gdwCurTool != DID_TEXT)
03142             break;
03143
03144         hDC = GetDC(hwnd);
03145         bDrawStuff(hDC, 0, 0, 0, 0, TRUE, FALSE, FALSE, (LPSTR)&wParam);
03146         ReleaseDC(hwnd, hDC);
03147
03148         if (gbRecording && (ghDCMetaf != NULL)) {
03149             bDrawStuff(ghDCMetaf, 0, 0, 0, 0, TRUE, FALSE, FALSE, (LPSTR)&wParam);
03150         }
03151
03152         break;
03153       }
03154
03155       case WM_DESTROY: {
03156         HDC         hDCt;
03157         HPALETTE    hPal;
03158
03159         DestroyCaret();
03160         DeleteObject(ghCurFont);
03161
03162         if (gb3D && b3DSetup) {
03163             bCleanUpRC();
03164         }
03165
03166         hDCt = GetDC(hwnd);
03167         hPal = SelectObject(hDCt, GetStockObject(DEFAULT_PALETTE));
03168         DeleteObject(hPal);
03169         ReleaseDC(hwnd, hDCt);
03170
03171     PostQuitMessage(0);
03172     return 0L;
03173       }
03174
03175       default:
03176     return DefWindowProc(hwnd, message, wParam, lParam);
03177     }
03178
03179     return 0;
03180
03181 }
03182
03183
03184 /***************************************************************************\
03185 * About
03186 *
03187 * About dialog proc.
03188 *
03189 \***************************************************************************/
03190
03191 BOOL CALLBACK About (
03192     HWND hDlg,
03193     UINT message,
03194     WPARAM wParam,
03195     LPARAM lParam)
03196 {
03197     switch (message) {
03198     case WM_INITDIALOG:
03199         return TRUE;
03200
03201     case WM_COMMAND:
03202         if (wParam == IDOK)
03203             EndDialog(hDlg, wParam);
03204         break;
03205     }
03206
03207     return FALSE;
03208
03209     UNREFERENCED_PARAMETER(lParam);
03210     UNREFERENCED_PARAMETER(hDlg);
03211 }
03212
03213 /***************************************************************************\
03214 *
03215 * TextWndProc
03216 *
03217 * Text Window procedure for displaying miscellaneous messages to user.
03218 *
03219 \***************************************************************************/
03220
03221 LONG_PTR APIENTRY TextWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
03222 {
03223     static HFONT hFont = (HFONT) NULL;
03224
03225     switch (message)
03226     {
03227     case WM_CREATE:
03228         {
03229         LOGFONT    lf;
03230         HDC        hDC;
03231         HFONT      hOldFont;
03232             TEXTMETRIC tm;
03233         //RECT       rect;
03234
03235             SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), (PVOID) &lf, (UINT)FALSE);
03236
03237         hDC = GetDC(hwnd);
03238         // this is the height for 8 point size font in pixels
03239         lf.lfHeight = 8 * GetDeviceCaps(hDC, LOGPIXELSY) / 72;
03240
03241         hFont = CreateFontIndirect(&lf);
03242         hOldFont = SelectObject(hDC, hFont);
03243         GetTextMetrics(hDC, &tm);
03244
03245         // base the height of the window on size of text
03246         glcyStatus = tm.tmHeight+6*GetSystemMetrics(SM_CYBORDER)+2;
03247             ReleaseDC(hwnd, hDC);
03248             break;
03249         }
03250
03251     case WM_DESTROY:
03252         if (hFont)
03253         DeleteObject(hFont);
03254         break;
03255
03256     case WM_SETTEXT:
03257             DefWindowProc(hwnd, message, wParam, lParam);
03258             InvalidateRect(hwnd,NULL,FALSE);
03259             UpdateWindow(hwnd);
03260             return 0L;
03261
03262     case WM_PAINT:
03263         {
03264             PAINTSTRUCT ps;
03265             RECT   rc;
03266             char   ach[128];
03267             int    len, nxBorder, nyBorder;
03268             HFONT  hOldFont = NULL;
03269
03270             BeginPaint(hwnd, &ps);
03271
03272             GetClientRect(hwnd,&rc);
03273
03274             nxBorder = GetSystemMetrics(SM_CXBORDER);
03275         rc.left  += 9*nxBorder;
03276             rc.right -= 9*nxBorder;
03277
03278             nyBorder = GetSystemMetrics(SM_CYBORDER);
03279         rc.top    += 3*nyBorder;
03280         rc.bottom -= 3*nyBorder;
03281
03282         // 3D Text
03283             len = GetWindowText(hwnd, ach, sizeof(ach));
03284         SetBkColor(ps.hdc, GetSysColor(COLOR_BTNFACE));
03285
03286         SetBkMode(ps.hdc, TRANSPARENT);
03287         SetTextColor(ps.hdc, RGB(64,96,96));
03288         if (hFont)
03289         hOldFont = SelectObject(ps.hdc, hFont);
03290         ExtTextOut(ps.hdc, rc.left+2*nxBorder+2, rc.top+2, ETO_OPAQUE | ETO_CLIPPED,
03291                     &rc, ach, len, NULL);
03292
03293         SetTextColor(ps.hdc, RGB(128,128,128));
03294         if (hFont)
03295         hOldFont = SelectObject(ps.hdc, hFont);
03296         ExtTextOut(ps.hdc, rc.left+2*nxBorder+1, rc.top+1, ETO_CLIPPED,
03297             &rc, ach, len, NULL);
03298
03299         SetTextColor(ps.hdc, RGB(255,255,255));
03300         if (hFont)
03301         hOldFont = SelectObject(ps.hdc, hFont);
03302         ExtTextOut(ps.hdc, rc.left+2*nxBorder, rc.top, ETO_CLIPPED,
03303             &rc, ach, len, NULL);
03304
03305         SetBkMode(ps.hdc, OPAQUE);
03306
03307         if (hOldFont)
03308         SelectObject(ps.hdc, hOldFont);
03309
03310             EndPaint(hwnd, &ps);
03311             return 0L;
03312         }
03313     }
03314     return DefWindowProc(hwnd, message, wParam, lParam);
03315 }
03316
03317 /******************************Public*Routine******************************\
03318 *
03319 * CtrlPanelDlgProc
03320 *       The Control Panel dialog procedure
03321 *
03322 * Effects:  Responsible for drawing the owner draw buttons.  Notifying
03323 *           parent of user's action.
03324 *
03325 * Warnings:
03326 *
03327 \**************************************************************************/
03328
03329 LONG_PTR APIENTRY CtrlPanelDlgProc(HWND hwnd, UINT msg, WPARAM dwParam, LPARAM lParam)
03330 {
03331     switch (msg) {
03332         case WM_INITDIALOG: {
03333             int index;
03334
03335             for (index = 0; index < OD_BTN_CNT; index++) {
03336                 grHwndCtrlBtn[index] = (PVOID)GetDlgItem(hwnd, (INT)(ID_OD_BTN_BASE+index));
03337             }
03338             for (index = 0; index < OD_TOOL_CNT; index++) {
03339                 grHwndToolBtn[index] = (PVOID)GetDlgItem(hwnd, (INT)(ID_OD_TOOL_BASE+index));
03340             }
03341             return TRUE;
03342         }
03343
03344         case WM_DRAWITEM: {
03345             PDRAWITEMSTRUCT pDIS = (PDRAWITEMSTRUCT) lParam;
03346             HBITMAP hBmpOld;
03347             BITMAP  bm;
03348             HANDLE  hCtl;
03349             HDC     hDCCtl;
03350
03351             if (pDIS->CtlID == gdwCurCtrl) {
03352                 GetObject((HBITMAP) ghBmpDn[pDIS->CtlID - ID_OD_BTN_BASE], sizeof(BITMAP), (LPSTR)&bm);
03353                 hBmpOld = SelectObject(ghDCMem, (HBITMAP) ghBmpDn[pDIS->CtlID - ID_OD_BTN_BASE]);
03354             }
03355
03356             if (pDIS->CtlID == gdwCurTool) {
03357                 GetObject((HBITMAP)ghToolBmpDn[pDIS->CtlID - ID_OD_TOOL_BASE], sizeof(BITMAP), (LPSTR)&bm);
03358                 hBmpOld = SelectObject(ghDCMem, (HBITMAP)ghToolBmpDn[pDIS->CtlID - ID_OD_TOOL_BASE]);
03359             }
03360
03361             if ((pDIS->CtlID < ID_OD_TOOL_BASE) && (pDIS->CtlID != gdwCurCtrl)) {
03362                 GetObject((HBITMAP)ghBmpUp[pDIS->CtlID - ID_OD_BTN_BASE], sizeof(BITMAP), (LPSTR)&bm);
03363                 hBmpOld = SelectObject(ghDCMem, (HBITMAP)ghBmpUp[pDIS->CtlID - ID_OD_BTN_BASE]);
03364             }
03365
03366             if ((pDIS->CtlID >= ID_OD_TOOL_BASE) && (pDIS->CtlID != gdwCurTool)) {
03367                 GetObject((HBITMAP)ghToolBmpUp[pDIS->CtlID - ID_OD_TOOL_BASE], sizeof(BITMAP), (LPSTR)&bm);
03368                 hBmpOld = SelectObject(ghDCMem, (HBITMAP)ghToolBmpUp[pDIS->CtlID - ID_OD_TOOL_BASE]);
03369             }
03370
03371             //
03372             // pDIS->hDC is clipped to the update region but unfortunately
03373             // that doesn't work well with StretchBlt.  StretchBlt is used
03374             // because I don't have to make sure that the bitmap size is
03375             // exactly the same as the size of the button.
03376             //
03377             hCtl   = GetDlgItem(hwnd, pDIS->CtlID);
03378             hDCCtl = GetDC(hCtl);
03379             StretchBlt(hDCCtl,                                //pDIS->hDC,
03380                    pDIS->rcItem.left, pDIS->rcItem.top,
03381                    pDIS->rcItem.right - pDIS->rcItem.left,
03382                    pDIS->rcItem.bottom - pDIS->rcItem.top,
03383                    ghDCMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
03384             ReleaseDC(hCtl, hDCCtl);
03385             SelectObject(ghDCMem, hBmpOld);
03386             break;
03387         }
03388
03389         case WM_COMMAND: {
03390             DWORD_PTR dwOldCtrl = gdwCurCtrl;
03391             DWORD_PTR dwOldTool = gdwCurTool;
03392
03393             switch (dwParam) {
03394                 case DID_ONE:
03395                 case DID_TWO:
03396                 case DID_THREE:
03397                 case DID_FOUR:
03398                 case DID_FIVE:
03399                 case DID_SIX:
03400                 case DID_SEVEN:
03401                 case DID_EIGHT:
03402                 case DID_NINE:
03403                 case DID_ZERO:
03404                 case DID_TEN_PLUS:
03405                     //SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, dwParam - DID_ZERO, FALSE);
03406                     SendMessage(ghwndMain, WM_COMMAND, dwParam, lParam);
03407                     break;
03408                 case DID_OPEN:
03409                 case DID_RECORD:
03410                 case DID_STOP:
03411                 case DID_PLAY:
03412                 case DID_FF:
03413                     SendMessage(ghwndMain, WM_COMMAND, dwParam, lParam);
03414                     gdwCurCtrl = dwParam;
03415                     InvalidateRect((HWND)grHwndCtrlBtn[dwOldCtrl - ID_OD_BTN_BASE], NULL, FALSE);
03416                     InvalidateRect((HWND)grHwndCtrlBtn[gdwCurCtrl - ID_OD_BTN_BASE], NULL, FALSE);
03417                     break;
03418                 case DID_CLEAR:
03419                     SendMessage(ghwndMain, WM_COMMAND, dwParam, lParam);
03420                     break;
03421                 case DID_TEXT:
03422                 case DID_PEN:
03423                 case DID_RECT:
03424                 case DID_FILLRECT:
03425                 case DID_ELLIPSE:
03426                 case DID_FILLELLIPSE:
03427                 case DID_LINE:
03428                 case DID_BEZIER:
03429                 case DID_BMPOBJ:
03430                 case DID_METAF:
03431                     SendMessage(ghwndMain, WM_COMMAND, dwParam, lParam);
03432                     gdwCurTool = dwParam;
03433                     InvalidateRect((HWND)grHwndToolBtn[dwOldTool - ID_OD_TOOL_BASE], NULL, FALSE);
03434                     InvalidateRect((HWND)grHwndToolBtn[gdwCurTool - ID_OD_TOOL_BASE], NULL, FALSE);
03435                     break;
03436             }
03437             break;
03438         }
03439
03440
03441         case WM_PAINT:
03442             {
03443                 HDC hdc;
03444                 RECT rc, rcDlg;
03445                 PAINTSTRUCT ps;
03446                 HPEN hpenWindowFrame, hpenDarkGray;
03447                 int  icyDlg;
03448                 int  icyBorder;
03449
03450                 icyBorder = GetSystemMetrics(SM_CYBORDER);
03451
03452                 GetWindowRect(hwnd, &rcDlg);
03453                 icyDlg = rcDlg.right - rcDlg.left;
03454
03455                 /*
03456                  * Draw our border lines.
03457                  */
03458                 GetClientRect(hwnd, &rc);
03459                 hdc = BeginPaint(hwnd, &ps);
03460
03461                 SelectObject(hdc, GetStockObject(WHITE_PEN));
03462                 MoveToEx(hdc, rc.left, rc.top, NULL);
03463                 LineTo(hdc, rc.right, rc.top);
03464
03465                 hpenDarkGray = CreatePen(PS_SOLID, 1, DARKGRAY);
03466                 SelectObject(hdc, hpenDarkGray);
03467                 MoveToEx(hdc, rc.left, (rc.top + icyDlg) - icyBorder - 1, NULL);
03468                 LineTo(hdc, rc.right, (rc.top + icyDlg) - icyBorder - 1);
03469
03470                 hpenWindowFrame = CreatePen(PS_SOLID, icyBorder,
03471                         GetSysColor(COLOR_WINDOWFRAME));
03472                 SelectObject(hdc, hpenWindowFrame);
03473                 MoveToEx(hdc, rc.left, (rc.top + icyDlg) - icyBorder, NULL);
03474                 LineTo(hdc, rc.right, (rc.top + icyDlg) - icyBorder);
03475
03476                 EndPaint(hwnd, &ps);
03477                 DeleteObject(hpenWindowFrame);
03478                 DeleteObject(hpenDarkGray);
03479             }
03480
03481             break;
03482
03483
03484         //case WM_CTLCOLOR:
03485         case WM_CTLCOLORDLG:
03486         //case WM_CTLCOLORLISTBOX:
03487         case WM_CTLCOLORSTATIC:
03488             switch (GET_WM_CTLCOLOR_TYPE(dwParam, lParam, msg)) {
03489                 case CTLCOLOR_DLG:
03490                 //case CTLCOLOR_LISTBOX:
03491                     return (BOOL)(INT_PTR)GetStockObject(LTGRAY_BRUSH);
03492
03493                 case CTLCOLOR_STATIC:
03494                     SetBkMode(GET_WM_CTLCOLOR_HDC(dwParam, lParam, msg),
03495                               TRANSPARENT);
03496                 //    SetTextColor(GET_WM_CTLCOLOR_HDC(dwParam, lParam, msg),
03497                 //              RGB(255,0,0));
03498                 //    SetBkColor(GET_WM_CTLCOLOR_HDC(dwParam, lParam, msg),
03499                 //            LIGHTGRAY);
03500                 //              RGB(255, 255,0));
03501                     return (BOOL)(INT_PTR)GetStockObject(DKGRAY_BRUSH);
03502             }
03503             //return (BOOL)NULL;
03504             return (BOOL)(INT_PTR)GetStockObject(LTGRAY_BRUSH);
03505
03506         default:
03507             return FALSE;
03508     }
03509
03510     return FALSE;
03511 }
03512
03513
03514
03515 /******************************Public*Routine******************************\
03516 *
03517 * bDrawStuff
03518 *
03519 * Effects:  The drawing routines are localized here.
03520 *           bErase is TRUE if this fcn is called for erasing previous object.
03521 *           (as in tracking objects.)  It is FALSE, otherwise.
03522 *
03523 *           bMove is TRUE if this fcn is called inside the WM_MOUSEMOVE (as
03524 *           in tracking objects.)  It is FALSE, otherwise.
03525 *
03526 *           bCntPt is TRUE if this fcn is to increment either the iCnt or
03527 *           iCntMF counter (used only in processing metafile or bezier.)
03528 *           It is FALSE, otherwise.
03529 *
03530 *           lpstr contains the character to be drawn by TextOut when it is
03531 *           not NULL.
03532 *
03533 * Warnings: Metafile and Bezier assume that the caller is calling this fcn
03534 *           to draw in the screen DC first. Then draw it to the metafile DC.
03535 *           Thus, when it is called to draw on the metafile DC, the points
03536 *           would have been set already.
03537 *
03538 \**************************************************************************/
03539
03540 BOOL bDrawStuff(HDC hDC, INT OrgX, INT OrgY,
03541                          INT NextX, INT NextY,
03542                          BOOL bErase,
03543                          BOOL bMove,
03544                          BOOL bCntPt,
03545                          LPSTR lpstr) {
03546     BOOL bSuccess;
03547     HGDIOBJ hObjOld;
03548     static POINT rgPts[MAX_POINTS], rgPtsMF[MAX_POINTS_MF], rgPtsBMP[MAX_POINTS_BMP];
03549     static int   iCnt=0, iCntMF=0, iCntBMP=0;
03550     static BOOL  bCaretShown=FALSE;
03551
03552     bSuccess = TRUE;
03553     if (bCaretShown) {
03554         HideCaret(ghwndDrawSurf);
03555         bCaretShown = FALSE;
03556     }
03557
03558     switch (gdwCurTool) {
03559         case DID_PEN:
03560             if (bErase) {
03561                 MoveToEx(hDC, NextX, NextY, NULL);
03562             } else {
03563                 //
03564                 // Override the ROP2 st. the pen won't erase its track
03565                 //
03566                 SetROP2(hDC, R2_COPYPEN);
03567                 LineTo(hDC, NextX, NextY);
03568             }
03569             break;
03570         case DID_TEXT: {
03571             POINT   Pt;
03572 #if 0
03573         HDC hDCMem;
03574 #endif
03575
03576             if (lpstr == NULL) {
03577                 ShowCaret(ghwndDrawSurf);
03578                 bCaretShown = TRUE;
03579                 SetCaretPos(NextX, NextY-CARET_HEIGHT);
03580                 MoveToEx(hDC, NextX, NextY, NULL);
03581
03582 #if 0
03583         StretchDIBits(hDC, 20, 20+120, 64, 64, 0, 64, 64, -64, &dib,
03584                             (LPBITMAPINFO)&DIBHdr, DIB_PAL_COLORS, SRCCOPY);
03585
03586         hDCMem = CreateCompatibleDC(hDC);
03587         SelectPalette(hDCMem, hPal, FALSE);
03588         RealizePalette(hDCMem);
03589         SelectObject(hDCMem, hbmp);
03590         BitBlt(hDC, 0,0,64,64,hDCMem, 0,0,SRCCOPY);
03591         DeleteDC(hDCMem);
03592 #endif
03593
03594             SetFocus(ghwndDrawSurf);
03595             break;
03596             }
03597
03598             SetTextAlign(hDC, TA_BASELINE | TA_LEFT | TA_UPDATECP);
03599             hObjOld = SelectObject(hDC, ghCurFont);
03600             SetTextColor(hDC, gCrText);
03601
03602             if ((gbSFOutln || gbPDOutln) && gbTT) {
03603                 // get rid of the char box
03604                 SetBkMode(hDC, TRANSPARENT);
03605                 BeginPath(hDC);
03606                 TextOut(hDC, NextX, NextY, lpstr, IsDBCSLeadByte((BYTE)*lpstr) ? 2 : 1);
03607                 EndPath(hDC);
03608
03609                 if (gbSFOutln) {
03610                     StrokeAndFillPath(hDC);
03611                     goto DT_UPDATE;
03612                 }
03613
03614                 //
03615                 // Get path and polydraw
03616                 //
03617                 {
03618                 int     iNumPt;
03619                 PBYTE   pjTypes;
03620                 PPOINT  pPts;
03621
03622                 if (iNumPt = GetPath(hDC, NULL, NULL, 0)) {
03623                     if ((pPts = (PPOINT)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
03624                                                 sizeof(POINT)*iNumPt )) == NULL) {
03625                         MessageBox(ghwndMain, GetStringRes(IDS_CREPNTFAIL),
03626                             GetStringRes(IDS_ERROR), MB_OK);
03627                         break;
03628                     }
03629
03630                     if ((pjTypes = (PBYTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
03631                                                 sizeof(BYTE)*iNumPt )) == NULL) {
03632                         MessageBox(ghwndMain, GetStringRes(IDS_CREPBYTEFAIL),
03633                             GetStringRes(IDS_ERROR), MB_OK);
03634                         goto GP_EXIT1;
03635                     }
03636
03637                     GetPath(hDC, pPts, pjTypes, iNumPt);
03638                 }
03639                 PolyDraw95(hDC, pPts, pjTypes, iNumPt);
03640                 GlobalFree(pjTypes);
03641
03642 GP_EXIT1:
03643                 GlobalFree(pPts);
03644
03645                 }
03646
03647             } else {
03648                 TextOut(hDC, NextX, NextY, lpstr, IsDBCSLeadByte((BYTE)*lpstr) ? 2 : 1);
03649             }
03650 DT_UPDATE:
03651             //
03652             // Updating current position
03653             //
03654             {
03655             LONG    lHeight;
03656             LONG    lWidth;
03657             TEXTMETRIC     tm;
03658
03659                 if (GetTextMetrics(hDC, &tm)) {
03660                     lHeight = tm.tmHeight;
03661                     lWidth  = tm.tmMaxCharWidth;
03662                 }
03663
03664                 GetCurrentPositionEx(hDC, (LPPOINT) &Pt);
03665                 SetCaretPos(Pt.x, Pt.y-CARET_HEIGHT);
03666
03667             }
03668             ShowCaret(ghwndDrawSurf);
03669             bCaretShown = TRUE;
03670
03671             break;
03672
03673 #if 0
03674
03675 #define PT_LINECLOSE     (PT_LINETO | PT_CLOSEFIGURE)
03676 #define PT_BEZIERCLOSE (PT_BEZIERTO | PT_CLOSEFIGURE)
03677
03678             hpnRed = CreatePen(PS_SOLID, 0, RGB(255,0,0));
03679             SelectObject(hDC, hpnRed);
03680
03681             while (iNumPt--) {
03682                 static POINT pPnt[3];
03683                 static int   iCnt=0;
03684
03685                 switch (*pjTypes++) {
03686                     case PT_MOVETO: {
03687                         MoveToEx(hDC, pPts->x, pPts->y, NULL);
03688                         pPts++;
03689                         break;
03690                     }
03691                     case PT_LINETO: {
03692                         LineTo(hDC, pPts->x, pPts->y);
03693                         pPts++;
03694                         break;
03695
03696                     }
03697                     case PT_LINECLOSE: {
03698                         LineTo(hDC, pPts->x, pPts->y);
03699                         pPts++;
03700                         goto GP_EXIT2;
03701                     }
03702                     case PT_BEZIERTO: {
03703                         pPnt[iCnt].x = pPts->x;
03704                         pPnt[iCnt].y = pPts->y;
03705                         pPts++;
03706
03707                         if (iCnt < 2) {
03708                             iCnt++;
03709                         } else {
03710                             PolyBezierTo(hDC, pPnt, 3);
03711                             iCnt = 0;
03712                         }
03713                         break;
03714                     }
03715                     case PT_BEZIERCLOSE: {
03716                         pPnt[iCnt].x = pPts->x;
03717                         pPnt[iCnt].y = pPts->y;
03718                         pPts++;
03719
03720                         if (iCnt < 2) {
03721                             iCnt++;
03722                         } else {
03723                             PolyBezierTo(hDC, pPnt, 3);
03724                             iCnt = 0;
03725                         }
03726                         goto GP_EXIT2;
03727                     }
03728
03729                     default:
03730                         break;
03731                 }
03732
03733             }
03734
03735 #endif
03736         }
03737         case DID_RECT:
03738             hObjOld = SelectObject(hDC, GetStockObject(NULL_BRUSH));
03739             Rectangle(hDC, OrgX, OrgY, NextX, NextY);
03740             SelectObject(hDC, hObjOld);
03741             break;
03742         case DID_FILLRECT:
03743             Rectangle(hDC, OrgX, OrgY, NextX, NextY);
03744             break;
03745         case DID_ELLIPSE:
03746             hObjOld = SelectObject(hDC, GetStockObject(NULL_BRUSH));
03747             Ellipse(hDC, OrgX, OrgY, NextX, NextY);
03748             SelectObject(hDC, hObjOld);
03749             break;
03750         case DID_FILLELLIPSE:
03751             Ellipse(hDC, OrgX, OrgY, NextX, NextY);
03752             break;
03753         case DID_LINE:
03754             MoveToEx(hDC, OrgX, OrgY, NULL);
03755             LineTo(hDC, NextX, NextY);
03756             break;
03757         case DID_BEZIER:
03758             if (bErase || bMove)
03759                 return bSuccess;
03760
03761             if (bCntPt) {
03762                 rgPts[iCnt].x = NextX;
03763                 rgPts[iCnt].y = NextY;
03764                 iCnt++;
03765
03766                 if (iCnt == MAX_POINTS - 1)
03767                     iCnt = 0;
03768             }
03769
03770             if ((iCnt % 3) == 1) {              // (iCnt + 1) % 3 == 1
03771                 //
03772                 // Override the ROP2 st. the pen won't erase its track
03773                 //
03774                 SetROP2(hDC, R2_COPYPEN);
03775                 PolyBezier(hDC, (LPPOINT)&rgPts, (DWORD) iCnt);
03776             }
03777             return bSuccess;
03778
03779         case DID_BMPOBJ: {
03780             static BOOL          bBltReady = FALSE;
03781
03782             if (bErase || bMove)
03783                 return bSuccess;
03784
03785             if (ghBmp == NULL) {
03786                 SetWindowText(ghTextWnd, GetStringRes(IDS_NOBMFOREMBED));
03787                 return bSuccess;
03788             }
03789
03790             if (bCntPt) {
03791                 bBltReady = FALSE;
03792                 rgPtsBMP[iCntBMP].x = NextX;
03793                 rgPtsBMP[iCntBMP].y = NextY;
03794                 iCntBMP++;
03795
03796                 if (iCntBMP < MAX_POINTS_BMP) {
03797                     return bSuccess;
03798                 }
03799             } else {
03800                 //
03801                 // Caller don't want to increment counter, so must be doing
03802                 // recording, so we just Blt again...
03803                 //
03804                 // But, if the Blt data is no good, bail out...
03805                 //
03806                 if (!bBltReady) {
03807                     return bSuccess;
03808                 }
03809                 bPlgBlt(hDC, rgPtsBMP);
03810                 return bSuccess;
03811             }
03812             bBltReady = TRUE;
03813
03814             bPlgBlt(hDC, rgPtsBMP);
03815             iCntBMP = 0;                         // reset
03816             return bSuccess;
03817         }
03818
03819         case DID_METAF: {
03820             ENHMETAHEADER EnhMetaHdr;
03821             RECT          rcClientDS;
03822             static XFORM         xform;
03823             static BOOL          bXformReady = FALSE;
03824             int           iEntries;
03825             PLOGPALETTE     plogPal;
03826             PBYTE           pjTmp;
03827             HPALETTE        hPal;
03828             static BOOL     bRCSet = FALSE;
03829
03830
03831             if (bErase || bMove)
03832                 return bSuccess;
03833
03834             if (ghMetaf == NULL) {
03835                 SetWindowText(ghTextWnd, GetStringRes(IDS_NOMFFOREMBED));
03836                 return bSuccess;
03837             }
03838
03839             if (bCntPt) {
03840                 bXformReady = FALSE;
03841                 rgPtsMF[iCntMF].x = NextX;
03842                 rgPtsMF[iCntMF].y = NextY;
03843                 iCntMF++;
03844
03845                 if (iCntMF < MAX_POINTS_MF) {
03846                     return bSuccess;
03847                 }
03848             } else {
03849                 //
03850                 // Caller don't want to increment counter, so must be doing
03851                 // recording, so we just set xform and play it again...
03852                 //
03853                 // But, if the xform data is no good, bail out...
03854                 //
03855                 if (!bXformReady) {
03856                     return bSuccess;
03857                 }
03858
03859                 GetEnhMetaFileHeader(ghMetaf, sizeof(ENHMETAHEADER), &EnhMetaHdr);
03860                 SetWorldTransform(hDC, &xform);
03861                 GetClientRect(ghwndDrawSurf, &rcClientDS);
03862
03863                 iEntries = GetEnhMetaFilePaletteEntries(ghMetaf, 0, NULL);
03864
03865                 if (iEntries) {
03866                     if ((plogPal = (PLOGPALETTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
03867                             sizeof(DWORD) + sizeof(PALETTEENTRY)*iEntries )) == NULL) {
03868                         MessageBox(ghwndMain, GetStringRes(IDS_CREPALFAIL),
03869                             GetStringRes(IDS_ERROR), MB_OK);
03870                     }
03871
03872                     plogPal->palVersion = 0x300;
03873                     plogPal->palNumEntries = (WORD) iEntries;
03874                     pjTmp = (PBYTE) plogPal;
03875                     pjTmp += 4;
03876
03877                     GetEnhMetaFilePaletteEntries(ghMetaf, iEntries, (PPALETTEENTRY)pjTmp);
03878                     hPal = CreatePalette(plogPal);
03879                     GlobalFree(plogPal);
03880
03881                     SelectPalette(hDC, hPal, FALSE);
03882                     RealizePalette(hDC);
03883                 }
03884
03885                 bRCSet = bSetRC2MatchEmfRC(hDC, EnhMetaHdr, ghMetaf, NULL);
03886                 if (!bRCSet) {
03887                     vErrOut("DID_METAF failed");
03888                 }
03889
03890                 //PlayEnhMetaFile(hDC, ghMetaf, (LPRECT) &rcClientDS);
03891                 {
03892                 RECT rc;
03893
03894                 rc.top = rc.left = 0;
03895                 rc.right = EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left;
03896                 rc.bottom = EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top;
03897                 if (!PlayEnhMetaFile(hDC, ghMetaf, (LPRECT) &rc)) {
03898                     char    text[128];
03899
03900                     _sntprintf(text, 127, GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
03901                     text [127] = '\0';
03902           OutputDebugString(text);
03903                 } else {
03904                     if (gbDB)
03905                        SwapBuffers(hDC);
03906                 }
03907
03908                 }
03909                 ModifyWorldTransform(hDC, NULL, MWT_IDENTITY);
03910
03911                 if (bRCSet) {
03912                     bCleanUpRC();
03913                     bRCSet = FALSE;
03914                 }
03915
03916                 return bSuccess;
03917             }
03918
03919             GetEnhMetaFileHeader(ghMetaf, sizeof(ENHMETAHEADER), &EnhMetaHdr);
03920             //
03921             // Based on the three points, top-left, top-right and bottom-left
03922             // (in this order), of the destination, solve equations for the
03923             // elements of the transformation matrix.
03924             //
03925             xform.eDx = (float) rgPtsMF[0].x;
03926             xform.eDy = (float) rgPtsMF[0].y;
03927             xform.eM11 = (rgPtsMF[1].x - xform.eDx)/(EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left);
03928             xform.eM12 = (rgPtsMF[1].y - xform.eDy)/(EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left);
03929             xform.eM21 = (rgPtsMF[2].x - xform.eDx)/(EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top);
03930             xform.eM22 = (rgPtsMF[2].y - xform.eDy)/(EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top);
03931
03932             bXformReady = TRUE;
03933             SetWorldTransform(hDC, &xform);
03934             GetClientRect(ghwndDrawSurf, &rcClientDS);
03935
03936             iEntries = GetEnhMetaFilePaletteEntries(ghMetaf, 0, NULL);
03937
03938             if (iEntries) {
03939                 if ((plogPal = (PLOGPALETTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
03940                         sizeof(DWORD) + sizeof(PALETTEENTRY)*iEntries )) == NULL) {
03941                     MessageBox(ghwndMain, GetStringRes(IDS_CREPALFAIL),
03942                         GetStringRes(IDS_ERROR), MB_OK);
03943                 }
03944
03945                 plogPal->palVersion = 0x300;
03946                 plogPal->palNumEntries = (WORD) iEntries;
03947                 pjTmp = (PBYTE) plogPal;
03948                 pjTmp += 4;
03949
03950                 GetEnhMetaFilePaletteEntries(ghMetaf, iEntries, (PPALETTEENTRY)pjTmp);
03951                 hPal = CreatePalette(plogPal);
03952                 GlobalFree(plogPal);
03953
03954                 SelectPalette(hDC, hPal, FALSE);
03955                 RealizePalette(hDC);
03956             }
03957
03958             if (!bRCSet) {
03959                 bRCSet = bSetRC2MatchEmfRC(hDC, EnhMetaHdr, ghMetaf, NULL);
03960                 if (!bRCSet) {
03961                     vErrOut("DID_METAF failed");
03962                 }
03963             }
03964
03965             //PlayEnhMetaFile(hDC, ghMetaf, (LPRECT) &rcClientDS);
03966             {
03967             RECT rc;
03968
03969             rc.top = rc.left = 0;
03970             rc.right = EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left;
03971             rc.bottom = EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top;
03972             if (!PlayEnhMetaFile(hDC, ghMetaf, (LPRECT) &rc)) {
03973                  char    text[128];
03974
03975                  _sntprintf(text, 127,GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
03976                  text [127] = '\0';
03977          OutputDebugString(text);
03978             } else {
03979                 if (gbDB)
03980                    SwapBuffers(hDC);
03981             }
03982
03983             }
03984             ModifyWorldTransform(hDC, NULL, MWT_IDENTITY);
03985             iCntMF = 0;                         // reset
03986             if (bRCSet) {
03987                 bCleanUpRC();
03988                 bRCSet = FALSE;
03989             }
03990             return bSuccess;
03991         }
03992         default:
03993             break;
03994     }
03995     //
03996     // Reset counter, user has selected other tools.
03997     //
03998     iCnt = 0;
03999     iCntMF = 0;
04000     iCntBMP = 0;
04001     return bSuccess;
04002 }
04003
04004 /******************************Public*Routine******************************\
04005 *
04006 * hemfLoadMetafile
04007 *
04008 * Effects:   Brings up the Open file common dialog
04009 *            Get the enhanced metafile spec'd by user
04010 *            returns the handle to the enhanced metafile if successfull
04011 *               otherwise, returns 0.
04012 *
04013 * Warnings:
04014 *
04015 \**************************************************************************/
04016
04017 HENHMETAFILE hemfLoadMetafile(HWND hwnd) {
04018     OPENFILENAME    ofn;
04019     char            szFile[MAX_ARRAYSIZE], szFileTitle[MAX_ARRAYSIZE];
04020     static char     *szFilter;
04021
04022     HMETAFILE       hmf;
04023     UINT            uiSize;
04024     LPVOID          pvData;
04025     HDC             hDCDrawSurf;
04026     HENHMETAFILE    hemf;
04027
04028     HANDLE                  hFile, hMapFile;
04029     LPVOID                  pMapFile;
04030     LPENHMETAHEADER         pemh;
04031
04032     BOOL        bSuccess;
04033     char            text[128];
04034
04035
04036     bSuccess = TRUE;
04037
04038     BuildFilterStrs(-1);
04039     BuildFilterStrs(IDS_FT_EMF);
04040     szFilter = BuildFilterStrs(IDS_FT_WMF);
04041
04042     strncpy( szFile, "*.emf\0", MAX_ARRAYSIZE - 1);
04043   szFile [MAX_ARRAYSIZE - 1] = '\0';
04044     ofn.lStructSize = sizeof(OPENFILENAME);
04045     ofn.hwndOwner = hwnd;
04046     ofn.lpstrFilter = szFilter;
04047     ofn.lpstrCustomFilter = (LPSTR) NULL;
04048     ofn.nMaxCustFilter = 0L;
04049     ofn.nFilterIndex = 1;
04050     ofn.lpstrFile = szFile;
04051     ofn.nMaxFile = sizeof(szFile);
04052     ofn.lpstrFileTitle = szFileTitle;
04053     ofn.nMaxFileTitle = sizeof(szFileTitle);
04054     ofn.lpstrInitialDir = NULL;
04055     ofn.lpstrTitle = GetStringRes(IDS_LDMF);
04056     ofn.Flags = 0L;
04057     ofn.nFileOffset = 0;
04058     ofn.nFileExtension = 0;
04059     ofn.lpstrDefExt = "EMF";
04060
04061     if (!GetOpenFileName(&ofn))
04062         return 0L;
04063
04064     if ((hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL,
04065             OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS,
04066             NULL)) == INVALID_HANDLE_VALUE) {
04067         _sntprintf(text, 127, GetStringRes(IDS_FMT_FILEOPNFAIL), GetLastError());
04068     text [127] = '\0';
04069         MessageBox(ghwndMain, text, GetStringRes(IDS_ERROR), MB_OK);
04070         return 0L;
04071     }
04072     if ( GetFileType(hFile) != FILE_TYPE_DISK )
04073     {
04074         CloseHandle(hFile);
04075         return 0L;
04076     }
04077
04078     //
04079     // Create a map file of the opened file
04080     //
04081     if ((hMapFile = CreateFileMapping(hFile, NULL,
04082                              PAGE_READONLY, 0, 0, "MapF")) == NULL) {
04083         _sntprintf(text, 127, GetStringRes(IDS_FMT_CREMAPFILEFAIL), GetLastError());
04084     text [127] = '\0';
04085         MessageBox(ghwndMain, text, GetStringRes(IDS_ERROR), MB_OK);
04086         bSuccess = FALSE;
04087         goto ErrorExit1;
04088     }
04089
04090     //
04091     // Map a view of the whole file
04092     //
04093     if ((pMapFile = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0)) == NULL) {
04094         _sntprintf(text, 127, GetStringRes(IDS_FMT_MAPVWMAPFOFAIL), GetLastError());
04095     text [127] = '\0';
04096         MessageBox(ghwndMain, text, GetStringRes(IDS_ERROR), MB_OK);
04097         bSuccess = FALSE;
04098         goto ErrorExit2;
04099     }
04100
04101     //
04102     // First check that if it is an enhanced metafile
04103     //
04104     pemh = (LPENHMETAHEADER) pMapFile;
04105     if (pemh->dSignature == META32_SIGNATURE) {
04106         hemf = GetEnhMetaFile(szFile);
04107         goto HLM_EXIT;
04108     }
04109
04110     //
04111     // If it has an ALDUS header skip it
04112     // Notice: APMSIZE is used because the HANDLE and RECT of the structure
04113     //         depends on the environment
04114     //
04115     if (*((LPDWORD)pemh) == ALDUS_ID) {
04116         //METAFILEPICT    mfp;
04117
04118         MessageBox(ghwndMain, GetStringRes(IDS_ALDUSMF), "Hey!", MB_OK);
04119         uiSize = *((LPDWORD) ((PBYTE)pMapFile + APMSIZE + 6));
04120         hDCDrawSurf = GetDC(ghwndDrawSurf);
04121
04122         // Notice: mtSize is size of the file in word.
04123         // if LPMETAFILEPICT is NULL
04124         //    MM_ANISOTROPIC mode and default device size will be used.
04125         hemf = SetWinMetaFileBits(uiSize*2L, (PBYTE)pMapFile + APMSIZE, hDCDrawSurf, NULL);
04126 #if 0
04127         switch ( ((PAPMFILEHEADER) pMapFile)->inch ) {
04128             // !!! End up in an upside down image
04129             //
04130             case 1440:
04131                 mfp.mm = MM_TWIPS;
04132                 OutputDebugString("MM_TWIPS\n");
04133                 break;
04134             case 2540:
04135                 OutputDebugString("MM_HIMETRIC\n");
04136                 mfp.mm = MM_HIMETRIC;
04137                 break;
04138             case 254:
04139                 OutputDebugString("MM_LOMETRIC\n");
04140                 mfp.mm = MM_LOMETRIC;
04141                 break;
04142             case 1000:
04143                 OutputDebugString("MM_HIENGLISH\n");
04144                 mfp.mm = MM_HIENGLISH;
04145                 break;
04146             case 100:
04147                 OutputDebugString("MM_LOENGLISH\n");
04148                 mfp.mm = MM_LOENGLISH;
04149                 break;
04150             default:
04151                 // !!! In addition, text is too small
04152                 //
04153                 OutputDebugString("MM_ANISOTROPIC\n");
04154                 mfp.mm = MM_ANISOTROPIC;
04155                 mfp.xExt = (((PAPMFILEHEADER) pMapFile)->bbox.Right - ((PAPMFILEHEADER) pMapFile)->bbox.Left)
04156                            * ((PAPMFILEHEADER) pMapFile)->inch * 2560;
04157                 mfp.yExt = (((PAPMFILEHEADER) pMapFile)->bbox.Bottom - ((PAPMFILEHEADER) pMapFile)->bbox.Top)
04158                            * ((PAPMFILEHEADER) pMapFile)->inch * 2560;
04159                 break;
04160         }
04161         mfp.hMF = 0;
04162         hemf = SetWinMetaFileBits(uiSize*2L, (PBYTE)pMapFile + APMSIZE, hDCDrawSurf, &mfp);
04163 #endif
04164
04165         if (!hemf) {
04166             char textbuf[MAX_ARRAYSIZE];
04167
04168             _sntprintf(textbuf, MAX_ARRAYSIZE - 1,GetStringRes(IDS_FMT_SETWMFBTSFAIL), GetLastError());
04169       textbuf [MAX_ARRAYSIZE - 1] = '\0';
04170             MessageBox(ghwndMain, textbuf, GetStringRes(IDS_ERROR), MB_OK);
04171         }
04172
04173         ghmf = SetMetaFileBitsEx(uiSize*2L, (PBYTE)pMapFile + APMSIZE);
04174         if (!ghmf) {
04175             char textbuf[MAX_ARRAYSIZE];
04176
04177             _sntprintf(textbuf,MAX_ARRAYSIZE - 1, GetStringRes(IDS_FMT_SETWMFBTSXFAIL), GetLastError());
04178       textbuf [MAX_ARRAYSIZE - 1] = '\0';
04179             MessageBox(ghwndMain, textbuf, GetStringRes(IDS_ERROR), MB_OK);
04180         }
04181
04182 // !!! Displaying the Windows format metafile
04183 //if (!PlayMetaFile(hDCDrawSurf, ghmf)) {
04184 //    wsprintf(text, GetStringRes(IDS_FMT_PLAYMFFAIL), GetLastError());
04185 //    MessageBox(ghwndMain, text, GetStringRes(IDS_ERROR), MB_OK);
04186 //}
04187         ReleaseDC(ghwndDrawSurf, hDCDrawSurf);
04188         goto HLM_EXIT;
04189     }
04190
04191
04192     //
04193     // It is a Windows 3x format metafile (hopefully)
04194     //
04195     if (!(hmf = GetMetaFile((LPCSTR)szFile))) {
04196         char textbuf[MAX_ARRAYSIZE];
04197
04198         _sntprintf(textbuf, MAX_ARRAYSIZE -1, GetStringRes(IDS_FMT_GETMFFAIL), GetLastError());
04199     textbuf [MAX_ARRAYSIZE - 1] = '\0';
04200         MessageBox(ghwndMain, textbuf, GetStringRes(IDS_ERROR), MB_OK);
04201         bSuccess = FALSE;
04202         goto ErrorExit3;
04203     }
04204
04205     if (!(uiSize = GetMetaFileBitsEx(hmf, 0, NULL))) {
04206         MessageBox(ghwndMain, GetStringRes(IDS_GETMFBTSXFAIL),
04207             GetStringRes(IDS_ERROR), MB_OK);
04208         return NULL;
04209     }
04210
04211     if ((pvData = (LPVOID) LocalAlloc(LMEM_FIXED, uiSize)) == NULL) {
04212         MessageBox(ghwndMain, GetStringRes(IDS_MALLOCFAIL),
04213             GetStringRes(IDS_ERROR), MB_OK);
04214         bSuccess = FALSE;
04215         goto ErrorExit3;
04216     }
04217
04218     if (!(uiSize = GetMetaFileBitsEx(hmf, uiSize, pvData))) {
04219         MessageBox(ghwndMain, GetStringRes(IDS_GETMFBTSXFAIL2),
04220             GetStringRes(IDS_ERROR), MB_OK);
04221         bSuccess = FALSE;
04222         goto ErrorExit3;
04223     }
04224
04225     DeleteMetaFile(hmf);
04226
04227     hDCDrawSurf = GetDC(ghwndDrawSurf);
04228     hemf = SetWinMetaFileBits(uiSize, (LPBYTE)pvData, hDCDrawSurf, NULL);
04229     ghmf = SetMetaFileBitsEx(uiSize, (LPBYTE) pvData);
04230
04231     LocalFree(pvData);
04232
04233     ReleaseDC(ghwndDrawSurf ,hDCDrawSurf);
04234
04235 HLM_EXIT:
04236 ErrorExit3:
04237     UnmapViewOfFile(pMapFile);
04238
04239 ErrorExit2:
04240     CloseHandle(hMapFile);
04241 ErrorExit1:
04242     CloseHandle(hFile);
04243
04244     if (bSuccess)
04245         return hemf;
04246     else
04247         return 0L;
04248 }
04249
04250 /******************************Public*Routine******************************\
04251 *
04252 * hDCRecordMetafileAs
04253 *
04254 * Effects:   Brings up the SaveAs common dialog
04255 *            Creates the enhanced metafile with the filename spec'd by user
04256 *            Modifies the second arg to reflect the new default filename
04257 *            less extension
04258 *            returns the created metafile DC if successful, otherwise, 0
04259 *
04260 * Warnings:
04261 *
04262 \**************************************************************************/
04263
04264 HDC hDCRecordMetafileAs(HWND hwnd, LPSTR szFilename) {
04265     OPENFILENAME ofn;
04266     char szFile[MAX_ARRAYSIZE], szFileTitle[MAX_ARRAYSIZE];
04267     static char *szFilter;
04268     char *szTmp, szTmp2[MAX_ARRAYSIZE];
04269     HDC  hDCMeta;
04270
04271     int iWidthMM, iHeightMM, iWidthPels, iHeightPels, iMMPerPelX, iMMPerPelY;
04272     RECT rc;
04273     HDC hDC;
04274
04275     BuildFilterStrs(-1);
04276     szFilter = BuildFilterStrs(IDS_FT_EMF);
04277     strncpy( szFile, "*.emf\0", MAX_ARRAYSIZE -1);
04278   szFile [MAX_ARRAYSIZE - 1] = '\0';
04279     ofn.lStructSize = sizeof(OPENFILENAME);
04280     ofn.hwndOwner = hwnd;
04281     ofn.lpstrFilter = szFilter;
04282     ofn.lpstrCustomFilter = (LPSTR) NULL;
04283     ofn.nMaxCustFilter = 0L;
04284     ofn.nFilterIndex = 0L;
04285     ofn.lpstrFile = szFile;
04286     ofn.nMaxFile = sizeof(szFile);
04287     ofn.lpstrFileTitle = szFileTitle;
04288     ofn.nMaxFileTitle = sizeof(szFileTitle);
04289     ofn.lpstrInitialDir = NULL;
04290     ofn.lpstrTitle = GetStringRes(IDS_SAVEMFAS);
04291     ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
04292     ofn.nFileOffset = 0;
04293     ofn.nFileExtension = 0;
04294     ofn.lpstrDefExt = (LPSTR)NULL;
04295
04296     if (!GetSaveFileName(&ofn)) {
04297         return 0L;
04298     }
04299
04300
04301     hDC = GetDC(hwnd);
04302     iWidthMM = GetDeviceCaps(hDC, HORZSIZE);
04303     iHeightMM = GetDeviceCaps(hDC, VERTSIZE);
04304     iWidthPels = GetDeviceCaps(hDC, HORZRES);
04305     iHeightPels = GetDeviceCaps(hDC, VERTRES);
04306     ReleaseDC(hwnd, hDC);
04307     iMMPerPelX = (iWidthMM * 100)/iWidthPels;
04308     iMMPerPelY = (iHeightMM * 100)/iHeightPels;
04309     GetClientRect(ghwndDrawSurf, &rc);
04310     rc.left = rc.left * iMMPerPelX;
04311     rc.top = rc.top * iMMPerPelY;
04312     rc.right = rc.right * iMMPerPelX;
04313     rc.bottom = rc.bottom * iMMPerPelY;
04314
04315
04316     //hDCMeta = CreateEnhMetaFile((HDC)NULL, szFile, (LPRECT)NULL, (LPSTR)NULL);
04317     {
04318         CHAR    szDesc[MAX_ARRAYSIZE];
04319
04320         _sntprintf(szDesc, MAX_ARRAYSIZE - 1, "SDK Enhanced Metafile Editor\\0%s\\0\\0", szFileTitle);
04321     szDesc [MAX_ARRAYSIZE - 1] = '\0';
04322         hDCMeta = CreateEnhMetaFile((HDC)NULL, szFile, (LPRECT)&rc, (LPSTR)szDesc);
04323
04324         if (gb3D)
04325             gbRCSet = bSetupRC(hDCMeta, NULL);
04326
04327         bSetAdvancedGraphics(hDCMeta);
04328     }
04329
04330     //
04331     // parses the new filename, removes the extension and copy it into
04332     // szFilename
04333     //
04334     strncpy( szFilename, "", MAX_ARRAYSIZE - 1);
04335   szFilename [MAX_ARRAYSIZE - 1] = '\0';
04336     szTmp = (char *)My_mbstok(szFile, "\\");
04337     strncpy( szTmp2, szTmp, MAX_ARRAYSIZE - 1 );
04338   szTmp2 [MAX_ARRAYSIZE - 1] = '\0';
04339     while (szTmp != NULL) {
04340         szTmp = (char *)My_mbstok(NULL, "\\");
04341         if (szTmp != NULL) {
04342             szFilename [MAX_ARRAYSIZE - 1] = '\0'; // make sure null terminated for strlen
04343             szTmp2 [sizeof (szTmp2) - 1] = '\0';   // make sure null terminated for strlen
04344             if ((strlen(szFilename)+strlen(szTmp2))/sizeof(char) >= MAX_ARRAYSIZE - 1) // check for this and next strcat
04345                 return 0L;
04346             else
04347                 strncat(szFilename, szTmp2, MAX_ARRAYSIZE - strlen (szFilename));
04348             strncpy( szTmp2, szTmp, MAX_ARRAYSIZE - 1);
04349       szTmp2 [MAX_ARRAYSIZE - 1] = '\0';
04350             strncat(szFilename, "\\", MAX_ARRAYSIZE - strlen (szFilename));
04351         }
04352     }
04353     szTmp = (char *)My_mbstok(szTmp2, ".");
04354     szTmp [sizeof (szTmp) - 1] = '\0';
04355     szFilename [MAX_ARRAYSIZE - 1] = '\0';
04356     if ((strlen(szFilename)+strlen(szTmp))/sizeof(char) >= MAX_ARRAYSIZE)
04357         return 0L;
04358     else
04359         strncat(szFilename, szTmp, MAX_ARRAYSIZE - strlen (szFilename));
04360
04361     return hDCMeta;
04362 }
04363
04364
04365 /******************************Public*Routine******************************\
04366 *
04367 * bPlayRecord
04368 *
04369 * Effects:  Play metafile
04370 *           if PlayInfo.bPlayContinuous is TRUE
04371 *               play metafile from 1st record up to the PlayInfo.iRecord th
04372 *                   record
04373 *           else only play the PlayInfo.iRecord th record and those preceding
04374 *               records that are relevant like MoveTo, etc.
04375 *           Terminates enumeration after playing up to the
04376 *               PlayInfo.iRecord th record
04377 *
04378 * Warnings:
04379 *
04380 \**************************************************************************/
04381
04382 BOOL APIENTRY bPlayRecord(HDC hDC, LPHANDLETABLE lpHandleTable,
04383                                    LPENHMETARECORD lpEnhMetaRecord,
04384                                    UINT nHandles,
04385                                    LPVOID lpData) {
04386     BOOL bSuccess;
04387     static int  iCnt=0;
04388     int         i;
04389     char        ach[128];
04390     char        achTmp[128];
04391     LONG        lNumDword;
04392
04393     bSuccess = TRUE;
04394
04395     lNumDword = (lpEnhMetaRecord->nSize-8) / 4;
04396
04397     iCnt++;
04398     if (((PLAYINFO *) lpData)->bPlayContinuous) {
04399         bSuccess = PlayEnhMetaFileRecord(hDC, lpHandleTable,
04400                                              lpEnhMetaRecord, nHandles);
04401         if (iCnt == ((PLAYINFO *) lpData)->iRecord) {
04402             strncpy( (LPSTR) ach, rgMetaName[lpEnhMetaRecord->iType].szGDIName, 127 );
04403       ach [127] = '\0';
04404             for (i=0; i < lNumDword; i++) {
04405                 _sntprintf((LPSTR) achTmp,127, "%ld ", lpEnhMetaRecord->dParm[i]);
04406                 ach [127] = '\0'; // make sure null terminated for strlen
04407                 achTmp [127] = '\0';
04408                 if ((strlen(ach)+strlen(achTmp))/sizeof(char) >= 128)
04409                     break;
04410                 strncat(ach, achTmp, sizeof (ach) - strlen (ach));
04411             }
04412         SetWindowText(ghTextWnd, ach);
04413         }
04414     } else {
04415
04416         switch (lpEnhMetaRecord->iType) {
04417             case EMR_SETWINDOWEXTEX:
04418             case EMR_SETWINDOWORGEX:
04419             case EMR_SETVIEWPORTEXTEX:
04420             case EMR_SETVIEWPORTORGEX:
04421             case EMR_SETBRUSHORGEX:
04422             case EMR_SETMAPMODE:
04423             case EMR_SETBKMODE:
04424             case EMR_SETPOLYFILLMODE:
04425             case EMR_SETROP2:
04426             case EMR_SETSTRETCHBLTMODE:
04427             case EMR_SETTEXTALIGN:
04428             case EMR_SETTEXTCOLOR:
04429             case EMR_SETBKCOLOR:
04430             case EMR_OFFSETCLIPRGN:
04431             case EMR_MOVETOEX:
04432             case EMR_SETMETARGN:
04433             case EMR_EXCLUDECLIPRECT:
04434             case EMR_INTERSECTCLIPRECT:
04435             case EMR_SCALEVIEWPORTEXTEX:
04436             case EMR_SCALEWINDOWEXTEX:
04437             case EMR_SAVEDC:
04438             case EMR_RESTOREDC:
04439             case EMR_SETWORLDTRANSFORM:
04440             case EMR_MODIFYWORLDTRANSFORM:
04441             case EMR_SELECTOBJECT:
04442             case EMR_CREATEPEN:
04443             case EMR_CREATEBRUSHINDIRECT:
04444             case EMR_DELETEOBJECT:
04445             case EMR_SELECTPALETTE:
04446             case EMR_CREATEPALETTE:
04447             case EMR_SETPALETTEENTRIES:
04448             case EMR_RESIZEPALETTE:
04449             case EMR_REALIZEPALETTE:
04450             case EMR_SETARCDIRECTION:
04451             case EMR_SETMITERLIMIT:
04452             case EMR_BEGINPATH:
04453             case EMR_ENDPATH:
04454             case EMR_CLOSEFIGURE:
04455             case EMR_SELECTCLIPPATH:
04456             case EMR_ABORTPATH:
04457             case EMR_EXTCREATEFONTINDIRECTW:
04458             case EMR_CREATEMONOBRUSH:
04459             case EMR_CREATEDIBPATTERNBRUSHPT:
04460             case EMR_EXTCREATEPEN:
04461                 goto PlayRec;
04462             default:
04463                 break;
04464         } //switch
04465
04466         if (iCnt == ((PLAYINFO *) lpData)->iRecord) {
04467 PlayRec:
04468             bSuccess = PlayEnhMetaFileRecord(hDC, lpHandleTable,
04469                                              lpEnhMetaRecord, nHandles);
04470             strncpy((LPSTR) ach, rgMetaName[lpEnhMetaRecord->iType].szGDIName, 127);
04471       ach [127] = '\0';
04472             for (i=0; i < lNumDword; i++) {
04473                 _sntprintf((LPSTR) achTmp, 127, "%ld ", lpEnhMetaRecord->dParm[i]);
04474                 ach [127] = '\0'; // make sure null terminated for strlen
04475                 achTmp [127] = '\0';
04476                 if ((strlen(ach)+strlen(achTmp))/sizeof(char) >= 128)
04477                     break;
04478                 strncat(ach, achTmp, sizeof (ach) - strlen (ach));
04479             }
04480             SetWindowText(ghTextWnd, ach);
04481         }
04482     }
04483
04484     if (iCnt == ((PLAYINFO *) lpData)->iRecord) {
04485         iCnt = 0;
04486
04487         if (gbDB)
04488             SwapBuffers(hDC);
04489
04490         return FALSE;
04491     }
04492     return bSuccess;
04493 }
04494
04495 /******************************Public*Routine******************************\
04496 *
04497 * LoadBitmapFile
04498 *
04499 * Effects:  Loads the bitmap from file and return the bitmap
04500 *
04501 * Warnings: pszFileName contains the full path
04502 *
04503 \**************************************************************************/
04504
04505 HBITMAP hBmpLoadBitmapFile(HDC hDC, PSTR pszFileName)
04506 {
04507     HANDLE              hFile, hMapFile;
04508     LPVOID              pMapFile, pMapFileTmp;
04509     LPBITMAPINFOHEADER  pbmh;
04510     LPBITMAPINFO        pbmi;
04511     PBYTE               pjTmp;
04512     ULONG               sizBMI;
04513     HBITMAP             hBitmap;
04514     INT                 iNumClr;
04515     BOOL                bCoreHdr;
04516     WORD                wBitCount;
04517     PFILEINFO           pFileInfo;
04518
04519     hBitmap = NULL;
04520
04521     if ((hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
04522             OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS,
04523             NULL)) == INVALID_HANDLE_VALUE) {
04524         SetWindowText(ghTextWnd, GetStringRes(IDS_FILEOPNFAIL));
04525         goto ErrExit1;
04526     }
04527     if ( GetFileType(hFile) != FILE_TYPE_DISK )
04528     {
04529         goto ErrExit2;
04530     }
04531
04532
04533     //
04534     // Create a map file of the opened file
04535     //
04536     if ((hMapFile = CreateFileMapping(hFile, NULL,
04537                              PAGE_READONLY, 0, 0, NULL)) == INVALID_HANDLE_VALUE) {
04538         SetWindowText(ghTextWnd, GetStringRes(IDS_CREMAPFILEFAIL));
04539         goto ErrExit2;
04540
04541     }
04542
04543     //
04544     // Map a view of the whole file
04545     //
04546     if ((pMapFile = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0)) == NULL) {
04547         SetWindowText(ghTextWnd, GetStringRes(IDS_MAPVWOFMAPFOFAIL));
04548         goto ErrExit3;
04549     }
04550
04551     pMapFileTmp = pMapFile;
04552
04553     //
04554     // First check that it is a bitmap file
04555     //
04556     if (*((PWORD)pMapFile) != 0x4d42) {              // 'BM'
04557         MessageBox(ghwndMain, GetStringRes(IDS_NOTDIBBMFILE),
04558             GetStringRes(IDS_ERROR), MB_OK);
04559         goto ErrExit3;
04560     }
04561
04562     //
04563     // The file header doesn't end on DWORD boundary...
04564     //
04565     pbmh = (LPBITMAPINFOHEADER)((PBYTE)pMapFile + sizeof(BITMAPFILEHEADER));
04566
04567     {
04568         BITMAPCOREHEADER bmch, *pbmch;
04569         BITMAPINFOHEADER bmih, *pbmih;
04570         PBYTE            pjTmp1;
04571         ULONG            ulSiz;
04572
04573         pbmch = &bmch;
04574         pbmih = &bmih;
04575
04576         pjTmp1 = (PBYTE)pbmh;
04577         ulSiz  = sizeof(BITMAPCOREHEADER);
04578         while (ulSiz--) {
04579             *(((PBYTE)pbmch)++) = *(((PBYTE)pjTmp1)++);
04580         }
04581
04582         pjTmp1 = (PBYTE)pbmh;
04583         ulSiz = sizeof(BITMAPINFOHEADER);
04584         while (ulSiz--) {
04585             *(((PBYTE)pbmih)++) = *(((PBYTE)pjTmp1)++);
04586         }
04587
04588         //
04589         // Use the size to determine if it is a BitmapCoreHeader or
04590         // BitmapInfoHeader
04591         //
04592         // Does PM supports 16 and 32 bpp? How?
04593         //
04594         if (bmch.bcSize == sizeof(BITMAPCOREHEADER))
04595         {
04596             wBitCount = bmch.bcBitCount;
04597             iNumClr = ((wBitCount == 24) ? 0 : (1 << wBitCount));
04598             sizBMI = sizeof(BITMAPCOREHEADER)+sizeof(RGBTRIPLE)*iNumClr;
04599             bCoreHdr = TRUE;
04600         }
04601         else            // BITMAPINFOHEADER
04602         {
04603             wBitCount = bmih.biBitCount;
04604             switch (wBitCount) {
04605                 case 16:
04606                 case 32:
04607                     sizBMI = sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3;
04608                     break;
04609                 case 24:
04610                     sizBMI = sizeof(BITMAPINFOHEADER);
04611                     break;
04612                 default:
04613                     iNumClr = (1 << wBitCount);
04614                     sizBMI = sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*iNumClr;
04615                     break;
04616             }
04617             bCoreHdr = FALSE;
04618         }
04619     }
04620
04621     if ((pbmi = (LPBITMAPINFO) LocalAlloc(LMEM_FIXED,sizBMI)) == NULL) {
04622         MessageBox(ghwndMain, GetStringRes(IDS_MALLOCFAIL),
04623             GetStringRes(IDS_ERROR), MB_OK);
04624         goto ErrExit3;
04625     }
04626
04627     //
04628     // Make sure we pass in a DWORD aligned BitmapInfo to CreateDIBitmap
04629     // Otherwise, exception on the MIPS platform
04630     // CR!!!  Equivalent to memcpy
04631     //
04632     pjTmp = (PBYTE)pbmi;
04633
04634     while(sizBMI--)
04635     {
04636         *(((PBYTE)pjTmp)++) = *(((PBYTE)pbmh)++);
04637     }
04638
04639     pMapFile = (PBYTE)pMapFile + ((BITMAPFILEHEADER *)pMapFile)->bfOffBits;
04640
04641 // !!! Use CreateBitmap for monochrome bitmap?
04642
04643     //
04644     // Select the palette into the DC first before CreateDIBitmap()
04645     //
04646     bSelectDIBPal(hDC, pbmi, bCoreHdr);
04647
04648 // !!! We always pass a screen DC to this routine.
04649 // !!! Maybe we should pass a metafile DC to this routine too.
04650 // !!! The bitmap handle created for the screen DC won't give correct
04651 // !!! color for the metafile DC.  So now, we always use the original
04652 // !!! DIB info.
04653     if ((hBitmap = CreateDIBitmap(hDC, (LPBITMAPINFOHEADER)pbmi,
04654                         CBM_INIT, pMapFile, pbmi, DIB_RGB_COLORS)) == NULL) {
04655         SetWindowText(ghTextWnd, "Fail in creating DIB bitmap from file!");
04656         goto ErrExit4;
04657     }
04658
04659     // reset gbUseDIB flag, now that we have opened up a new DIB
04660     gbUseDIB = FALSE;
04661
04662 // !!! Always use the DIB info o.w. metafile DC don't get the right color.
04663 #if 0
04664     if (GetDeviceCaps(hDC, BITSPIXEL) < wBitCount) {
04665 #endif
04666         gbUseDIB = TRUE;
04667         bFreeDibFile(&gDib);
04668         pFileInfo = &(gDib.rgFileInfo[0]);
04669         pFileInfo->hFile        = hFile;
04670         pFileInfo->hMapFile     = hMapFile;
04671         pFileInfo->lpvMapView   = pMapFileTmp;
04672
04673         gDib.rgpjFrame[0]       = pMapFile;
04674         gDib.rgpbmi[0]          = pbmi;
04675         gDib.rgbCoreHdr[0]      = bCoreHdr;
04676         gDib.ulFrames           =
04677         gDib.ulFiles            = 1;
04678         return (hBitmap);
04679 #if 0
04680     }
04681 #endif
04682
04683 ErrExit4:
04684     LocalFree(pbmi);
04685 ErrExit3:
04686     CloseHandle(hMapFile);
04687 ErrExit2:
04688     CloseHandle(hFile);
04689 ErrExit1:
04690
04691     return (hBitmap);
04692
04693 }
04694
04695
04696 /******************************Public*Routine******************************\
04697 *
04698 * bFreeDibFile
04699 *
04700 * Effects:
04701 *
04702 * Warnings:
04703 *
04704 \**************************************************************************/
04705
04706 BOOL bFreeDibFile(PDIBDATA pDibData)
04707 {
04708     ULONG               ulFiles;
04709     ULONG               ulFrames;
04710     ULONG               i;
04711     PFILEINFO           pFileInfo;
04712
04713     ulFiles = pDibData->ulFiles;
04714     ulFrames = pDibData->ulFrames;
04715
04716     for (i = 0; i < ulFrames; i++) {
04717         LocalFree(pDibData->rgpjFrame[i]);
04718         LocalFree(pDibData->rgpbmi[i]);
04719     }
04720
04721     for (i = 0; i < ulFiles; i++) {
04722         pFileInfo = &(pDibData->rgFileInfo[i]);
04723         CloseHandle(pFileInfo->hFile);
04724         CloseHandle(pFileInfo->hMapFile);
04725         UnmapViewOfFile(pFileInfo->lpvMapView);
04726     }
04727
04728     pDibData->ulFiles = 0;
04729     pDibData->ulFrames = 0;
04730     return TRUE;
04731 }
04732
04733
04734
04735
04736 /******************************Public*Routine******************************\
04737 *
04738 * bGetBMP
04739 *
04740 * Effects: call common dialog and pass the filename to hBmpLoadBitmapFile
04741 *          return TRUE if successful, FALSE otherwise
04742 *
04743 * Warnings:
04744 *
04745 \**************************************************************************/
04746
04747 BOOL bGetBMP(HWND hwnd, BOOL bMask) {
04748     OPENFILENAME    ofn;
04749     char            szFile[MAX_ARRAYSIZE], szFileTitle[MAX_ARRAYSIZE];
04750     static char     *szFilter;
04751     BOOL            bSuccess;
04752     HDC             hDC;
04753
04754     bSuccess = FALSE;
04755
04756     BuildFilterStrs(-1);
04757     BuildFilterStrs(IDS_FT_DIB);
04758     szFilter = BuildFilterStrs(IDS_FT_RLE);
04759
04760     strncpy( szFile, "*.bmp\0", MAX_ARRAYSIZE - 1);
04761   szFile [MAX_ARRAYSIZE - 1] = '\0';
04762     ofn.lStructSize = sizeof(OPENFILENAME);
04763     ofn.hwndOwner = hwnd;
04764     ofn.lpstrFilter = szFilter;
04765     ofn.lpstrCustomFilter = (LPSTR) NULL;
04766     ofn.nMaxCustFilter = 0L;
04767     ofn.nFilterIndex = 1;
04768     ofn.lpstrFile = szFile;
04769     ofn.nMaxFile = sizeof(szFile);
04770     ofn.lpstrFileTitle = szFileTitle;
04771     ofn.nMaxFileTitle = sizeof(szFileTitle);
04772     ofn.lpstrInitialDir = NULL;
04773     ofn.lpstrTitle = (bMask ? GetStringRes(IDS_LDMSK) : "Load Bitmap");
04774     ofn.Flags = 0L;
04775     ofn.nFileOffset = 0;
04776     ofn.nFileExtension = 0;
04777     ofn.lpstrDefExt = "BMP";
04778
04779     if (!GetOpenFileName(&ofn))
04780         return 0L;
04781
04782     hDC = GetDC(ghwndDrawSurf);
04783     if (bMask) {
04784         ghBmpMask = hBmpLoadBitmapFile(hDC, szFile);
04785         if (ghBmpMask != NULL)
04786             bSuccess = TRUE;
04787     } else {
04788         ghBmp = hBmpLoadBitmapFile(hDC, szFile);
04789         if (ghBmp != NULL)
04790             bSuccess = TRUE;
04791     }
04792     ReleaseDC(ghwndDrawSurf, hDC);
04793
04794     return bSuccess;
04795 }
04796
04797 /******************************Public*Routine******************************\
04798 *
04799 * bHitTest
04800 *
04801 * Effects:  Enumerates metafile records
04802 *           Calling bDoHitTest to process each record found.
04803 *               The mouse position is passed to the bDoHitTest
04804 *
04805 * Warnings:
04806 *
04807 \**************************************************************************/
04808
04809 BOOL bHitTest(HDC hDC, INT x, INT y) {
04810     BOOL          bSuccess;
04811     ENHMETAHEADER EnhMetaHdr;
04812     RECT          rcClientDS;
04813     HTDATA        htData;
04814     static        HCURSOR hCurHT, hCurWait;
04815
04816     bSuccess = TRUE;
04817
04818     if (ghMetaf == 0)
04819         return 0L;
04820
04821     hCurHT = LoadCursor(NULL, IDC_CROSS);
04822     hCurWait = LoadCursor(NULL, IDC_WAIT);
04823
04824     GetEnhMetaFileHeader(ghMetaf, sizeof(EnhMetaHdr), &EnhMetaHdr);
04825
04826     htData.point.x = x;
04827     htData.point.y = y;
04828     htData.iRecord = EnhMetaHdr.nRecords;
04829
04830     SetCursor(hCurWait);
04831     if (gbFit2Wnd) {
04832         GetClientRect(ghwndDrawSurf, &rcClientDS);
04833         EnumEnhMetaFile(hDC, ghMetaf, (ENHMFENUMPROC)bDoHitTest, (LPVOID) &htData, (LPRECT)&rcClientDS);
04834     } else {
04835         RECT rc;
04836
04837         rc.top = rc.left = 0;
04838         rc.right = EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left;
04839         rc.bottom = EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top;
04840         EnumEnhMetaFile(hDC, ghMetaf, (ENHMFENUMPROC)bDoHitTest, (LPVOID) &htData, (LPRECT)&rc);
04841     }
04842     SetCursor(hCurHT);
04843
04844     return bSuccess;
04845 }
04846
04847 /******************************Public*Routine******************************\
04848 *
04849 * bDoHitTest
04850 *
04851 * Effects:      Play all records related to transformation
04852 *               Remember new mouse position if the record is a MoveTo
04853 *               Convert rectangle, ellipse, lineto and bezier to path
04854 *               Widen the path and convert it to region.
04855 *               Test if the mouse position is inside the region.
04856 *
04857 * Warnings:     Only handle rectangle, ellipse, line and polybezier
04858 *
04859 \**************************************************************************/
04860
04861 BOOL APIENTRY bDoHitTest(HDC hDC, LPHANDLETABLE lpHandleTable,
04862                                   LPENHMETARECORD lpEnhMetaRecord,
04863                                   UINT nHandles,
04864                                   LPVOID lpData) {
04865     BOOL            bSuccess;
04866     char            ach[128];
04867     char            achTmp[128];
04868     POINT           PtOrg;
04869     LONG            lNumDword;
04870     XFORM           xfSave;
04871     SIZE            SizeWndEx, SizeViewEx;
04872     POINT           ptWndOrgin, ptViewOrgin;
04873     int             i, iMode;
04874     HRGN            hRgn;
04875     PPOINT          pPt, pPtTmp;
04876     static HGDIOBJ  hObjOld=NULL;
04877     static LONG     lCurX=0;
04878     static LONG     lCurY=0;
04879     static BOOL     bXform=FALSE;
04880     static int      iCnt=0;
04881
04882     iCnt++;
04883
04884     //
04885     // select a wide pen for widen path later on
04886     //
04887     hObjOld = SelectObject(hDC, ghpnWide);
04888
04889     //
04890     // save the mouse hit position, this was passed in as a POINT structure
04891     //
04892     PtOrg.x = (((HTDATA *)lpData)->point).x;
04893     PtOrg.y = (((HTDATA *)lpData)->point).y;
04894
04895     //
04896     // save the number of parameters for the GDI fcn concerned in DWORD.
04897     // This is the total size of metafile record in question less the
04898     // size of the GDI function
04899     //
04900     lNumDword = (lpEnhMetaRecord->nSize-8) / 4;
04901
04902     switch (lpEnhMetaRecord->iType) {
04903     case EMR_SETWINDOWEXTEX:
04904     case EMR_SETWINDOWORGEX:
04905     case EMR_SETVIEWPORTEXTEX:
04906     case EMR_SETVIEWPORTORGEX:
04907     case EMR_SETMAPMODE:
04908     case EMR_SCALEVIEWPORTEXTEX:
04909     case EMR_SCALEWINDOWEXTEX:
04910     case EMR_SETMETARGN:
04911     case EMR_SAVEDC:
04912     case EMR_RESTOREDC:
04913     case EMR_SETWORLDTRANSFORM:
04914     case EMR_MODIFYWORLDTRANSFORM: {
04915         //
04916         // play all records related to transformation & font
04917         //
04918         PlayEnhMetaFileRecord(hDC, lpHandleTable,
04919                                    lpEnhMetaRecord, nHandles);
04920         bXform = TRUE;
04921         return TRUE;
04922     }
04923     //
04924     // convert the following GDI calls to path for hit testing
04925     //
04926     case EMR_RECTANGLE: {
04927         BeginPath(hDC);
04928         Rectangle(hDC, lpEnhMetaRecord->dParm[0], lpEnhMetaRecord->dParm[1],
04929                        lpEnhMetaRecord->dParm[2], lpEnhMetaRecord->dParm[3]);
04930         EndPath(hDC);
04931         break;
04932     }
04933     case EMR_ELLIPSE: {
04934         BeginPath(hDC);
04935         Ellipse(hDC, lpEnhMetaRecord->dParm[0], lpEnhMetaRecord->dParm[1],
04936                      lpEnhMetaRecord->dParm[2], lpEnhMetaRecord->dParm[3]);
04937         EndPath(hDC);
04938         break;
04939     }
04940     case EMR_MOVETOEX: {
04941         //
04942         // Remember our current position
04943         //
04944         lCurX = lpEnhMetaRecord->dParm[0];
04945         lCurY = lpEnhMetaRecord->dParm[1];
04946         return TRUE;
04947     }
04948     case EMR_LINETO: {
04949         BeginPath(hDC);
04950         MoveToEx(hDC, lCurX, lCurY, NULL);
04951         LineTo(hDC, lpEnhMetaRecord->dParm[0], lpEnhMetaRecord->dParm[1]);
04952         EndPath(hDC);
04953         break;
04954     }
04955     case EMR_POLYBEZIER16: {
04956         int         j;
04957         LONG        lSize;
04958         LONG        lPtCnt;
04959
04960         lPtCnt = lpEnhMetaRecord->dParm[4];
04961         lSize = lPtCnt * sizeof(POINTL);
04962
04963         if ((pPt = (PPOINT) LocalAlloc(LMEM_FIXED, lSize)) == NULL) {
04964             SetWindowText(ghTextWnd, GetStringRes(IDS_MALLOCFAILNOHIT));
04965             return TRUE;
04966         }
04967
04968         pPtTmp = pPt;
04969
04970         for (j=0; j < (INT) lPtCnt; j++, pPtTmp++) {
04971             pPtTmp->x = (LONG)(LOWORD(lpEnhMetaRecord->dParm[j+5]));
04972             pPtTmp->y = (LONG)(HIWORD(lpEnhMetaRecord->dParm[j+5]));
04973         }
04974
04975         BeginPath(hDC);
04976         PolyBezier(hDC, (LPPOINT)pPt, (DWORD) lPtCnt);
04977         EndPath(hDC);
04978         LocalFree(pPt);
04979         break;
04980     }
04981     default:
04982         _sntprintf((LPSTR) ach, 127, GetStringRes(IDS_FMT_NOHTST), rgMetaName[lpEnhMetaRecord->iType]);
04983     ach [127] = '\0';
04984         SetWindowText(ghTextWnd, ach);
04985         return TRUE;
04986     }   //switch
04987
04988     if (bXform) {
04989         //
04990         // Set World transform to identity temporarily so that pen width
04991         // is not affected by world to page transformation
04992         //
04993         GetWorldTransform(hDC, &xfSave);
04994         ModifyWorldTransform(hDC, NULL, MWT_IDENTITY);
04995
04996         //
04997         // Set Page transform to identity temporarily so that pen width
04998         // is not affected by page to device transformation
04999         //
05000         iMode = GetMapMode(hDC);
05001
05002         if ((iMode == MM_ISOTROPIC) || (iMode == MM_ANISOTROPIC)) {
05003             GetWindowOrgEx(hDC, &ptWndOrgin);
05004             GetWindowExtEx(hDC, &SizeWndEx);
05005             GetViewportExtEx(hDC, &SizeViewEx);
05006             GetViewportOrgEx(hDC, &ptViewOrgin);
05007         }
05008
05009         SetMapMode(hDC, MM_TEXT);
05010     }
05011
05012     WidenPath(hDC);
05013
05014     hRgn = PathToRegion(hDC);
05015
05016     if (hRgn == 0) {
05017         SetWindowText(ghTextWnd, GetStringRes(IDS_NULLRGNHTSTFAIL));
05018         DeleteObject(hRgn);
05019         return TRUE;
05020     }
05021     //DPtoLP(hDC, &PtOrg, 1);
05022     //SetPixel(hDC, PtOrg.x, PtOrg.y, RGB(0, 255, 0));
05023     //
05024     // test if mouse hit position is in region
05025     //
05026     bSuccess = PtInRegion(hRgn, PtOrg.x, PtOrg.y);
05027     //Temporily comment this out
05028     FillRgn(hDC, hRgn, ghbrRed);
05029     DeleteObject(hRgn);
05030     //
05031     // Set transform back.
05032     //
05033     if (bXform) {
05034         SetWorldTransform(hDC, &xfSave);
05035         SetMapMode(hDC, iMode);
05036
05037         if ((iMode == MM_ISOTROPIC) || (iMode == MM_ANISOTROPIC)) {
05038             SetWindowOrgEx(hDC, ptWndOrgin.x, ptWndOrgin.y, NULL);
05039             SetWindowExtEx(hDC, SizeWndEx.cx, SizeWndEx.cy, NULL);
05040             SetViewportExtEx(hDC, SizeViewEx.cx, SizeViewEx.cy, NULL);
05041             SetViewportOrgEx(hDC, ptViewOrgin.x, ptViewOrgin.y, NULL);
05042         }
05043     }
05044
05045     if (bSuccess) {
05046         Beep(440, 500);
05047         //
05048         // Reporting the metafile record number.  Then reset counter.
05049         //
05050         SetDlgItemInt(ghwndCtrlPanel, DID_COUNTER, iCnt, FALSE);
05051         iCnt=0;
05052         _sntprintf((LPSTR) ach, 127,GetStringRes(IDS_FMT_HIT), rgMetaName[lpEnhMetaRecord->iType]);
05053     ach [127] = '\0';
05054         for (i=0; i < lNumDword; i++) {
05055             _sntprintf((LPSTR) achTmp, 127,"%ld ", lpEnhMetaRecord->dParm[i]);
05056             ach [127] = '\0'; // make sure null terminated for strlen
05057             achTmp [127] = '\0';
05058             if ((strlen(ach)+strlen(achTmp))/sizeof(char) >= 128)
05059                 break;
05060             strncat(ach, achTmp, sizeof (ach) - strlen (ach));
05061         }
05062
05063         SetWindowText(ghTextWnd, ach);
05064         SelectObject(hDC, hObjOld);
05065         bXform = FALSE;
05066         return FALSE;
05067     }
05068     SetWindowText(ghTextWnd, GetStringRes(IDS_NOHIT));
05069     if (iCnt >= ((HTDATA *)lpData)->iRecord)
05070         iCnt = 0;
05071     return TRUE;
05072
05073     UNREFERENCED_PARAMETER(lpHandleTable);
05074     UNREFERENCED_PARAMETER(nHandles);
05075
05076 }
05077
05078 /******************************Public*Routine******************************\
05079 *
05080 * bChooseNewFont
05081 *
05082 * Effects:
05083 *
05084 * Warnings:
05085 *
05086 \**************************************************************************/
05087
05088 BOOL bChooseNewFont(HWND hwnd, PLOGFONT plf, COLORREF *pClrRef) {
05089    HDC                  hDC=NULL;
05090    static CHOOSEFONT    chf;
05091    static BOOL          bInit=TRUE;
05092
05093
05094    if (bInit) {
05095         bInit = FALSE;
05096
05097         hDC = GetDC( hwnd );
05098         chf.hDC = CreateCompatibleDC( hDC );
05099         ReleaseDC( hwnd, hDC );
05100
05101         chf.lStructSize = sizeof(CHOOSEFONT);
05102         chf.hwndOwner = hwnd;
05103         chf.lpLogFont = plf;
05104         chf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_INITTOLOGFONTSTRUCT;
05105         chf.rgbColors = *pClrRef;
05106         chf.lCustData = 0;
05107         chf.hInstance = (HANDLE)NULL;
05108         chf.lpszStyle = (LPSTR)NULL;
05109         chf.nFontType = SCREEN_FONTTYPE;
05110         chf.nSizeMin = 0;
05111         chf.nSizeMax = 0;
05112         chf.lpfnHook = (LPCFHOOKPROC)NULL;
05113         chf.lpTemplateName = (LPSTR)NULL;
05114    }
05115
05116    if (ChooseFont( &chf ) == FALSE ) {
05117         if (hDC)
05118             DeleteDC( hDC );
05119     return FALSE;
05120    }
05121
05122    *pClrRef = chf.rgbColors;
05123
05124    if (hDC)
05125        DeleteDC( hDC );
05126    return (TRUE);
05127 }
05128
05129 /******************************Public*Routine******************************\
05130 *
05131 * bChooseNewColor
05132 *
05133 * Effects:  Returns TRUE if successful; lpdwRGB points the color selected.
05134 *           Otherwise, FALSE.
05135 *
05136 * Warnings:
05137 *
05138 \**************************************************************************/
05139
05140 BOOL bChooseNewColor(HWND hwnd, LPDWORD lpdwRGB) {
05141     static DWORD argbCust[16] = {
05142         RGB(255, 255, 255), RGB(255, 255, 255),
05143         RGB(255, 255, 255), RGB(255, 255, 255),
05144         RGB(255, 255, 255), RGB(255, 255, 255),
05145         RGB(255, 255, 255), RGB(255, 255, 255),
05146         RGB(255, 255, 255), RGB(255, 255, 255),
05147         RGB(255, 255, 255), RGB(255, 255, 255),
05148         RGB(255, 255, 255), RGB(255, 255, 255),
05149         RGB(255, 255, 255), RGB(255, 255, 255)
05150     };
05151     CHOOSECOLOR cc;
05152     BOOL bResult;
05153
05154     cc.lStructSize = sizeof(CHOOSECOLOR);
05155     cc.hwndOwner = hwnd;
05156     cc.hInstance = ghModule;
05157     cc.rgbResult = *lpdwRGB;
05158     cc.lpCustColors = argbCust;
05159     cc.Flags = CC_RGBINIT | CC_SHOWHELP;
05160     cc.lCustData = 0;
05161     cc.lpfnHook = NULL;
05162     cc.lpTemplateName = NULL;
05163
05164     bResult = ChooseColor(&cc);
05165
05166     if (bResult) {
05167         *lpdwRGB = cc.rgbResult;
05168         return TRUE;
05169     }
05170
05171     return FALSE;
05172 }
05173
05174
05175 /******************************Public*Routine******************************\
05176 *
05177 * hBrCreateBrush
05178 *
05179 * Effects: Creates a brush with the specified RGB
05180 *
05181 * Warnings:
05182 *
05183 \**************************************************************************/
05184
05185 HBRUSH hBrCreateBrush(HDC hDC, DWORD dwRGB)
05186 {
05187     HDC hdcMem;
05188     HBRUSH hbr;
05189     HBRUSH hbrOld;
05190     HBITMAP hbmPat;
05191     HBITMAP hbmOld;
05192
05193     hbr = CreateSolidBrush(dwRGB);
05194     hdcMem = CreateCompatibleDC(hDC);
05195
05196     //
05197     // Minimum size for a bitmap to be used in a fill pattern is 8x8
05198     //
05199     hbmPat = CreateCompatibleBitmap(hDC, 8, 8);
05200
05201     hbmOld = SelectObject(hdcMem, hbmPat);
05202     hbrOld = SelectObject(hdcMem, hbr);
05203     PatBlt(hdcMem, 0, 0, 8, 8, PATCOPY);
05204
05205     //
05206     // Deselect hbmPat and hbr
05207     //
05208     SelectObject(hdcMem, hbmOld);
05209     SelectObject(hdcMem, hbrOld);
05210
05211     DeleteDC(hdcMem);
05212     DeleteObject(hbr);
05213
05214     hbr = CreatePatternBrush(hbmPat);
05215
05216     DeleteObject(hbmPat);
05217
05218     return hbr;
05219 }
05220
05221
05222 /******************************Public*Routine******************************\
05223 *
05224 * bPrintMf  Brings up the print dialog for printer setup and then
05225 *           starts printing the enhanced metafile.
05226 *
05227 *           pPD     Points to a PRTDATA structure that contains the
05228 *                   the handle for the Enh. Metafile for printing.
05229 *
05230 * Effects:  Returns TRUE if sucessful.  Otherwise, it is FALSE.
05231 *           GlobalFree pPD when exits.
05232 *
05233 * Warnings:
05234 *
05235 \**************************************************************************/
05236
05237 BOOL bPrintMf(PPRTDATA pPD) {
05238     DOCINFO         DocInfo;
05239     HDC             hDCPrinter;
05240     ENHMETAHEADER   EnhMetaHdr;
05241     HENHMETAFILE    hEnhMf;
05242     TCHAR           buf[128];
05243     PRINTDLG        pd;
05244     BOOL            bSuccess;
05245     int             iEntries;
05246     PLOGPALETTE     plogPal;
05247     PBYTE           pjTmp;
05248     HPALETTE        hPal;
05249     BOOL            bRCSet = FALSE;
05250
05251
05252     bSuccess = TRUE;
05253
05254     if (pPD->hMetaf == 0) {
05255         SetWindowText(ghTextWnd, GetStringRes(IDS_NOMFTOPRT));
05256         goto PMF_EXIT;
05257         bSuccess = FALSE;
05258     }
05259
05260     hEnhMf = CopyEnhMetaFile(pPD->hMetaf, NULL);
05261     memset(&pd, 0, sizeof(PRINTDLG));
05262     pd.lStructSize = sizeof(PRINTDLG);
05263     pd.hwndOwner   = ghwndMain;
05264     pd.Flags       = PD_RETURNDC;
05265     pd.hInstance   = ghModule;
05266
05267     if (!PrintDlg(&pd)) {
05268         SetWindowText(ghTextWnd, GetStringRes(IDS_ESCPRT));
05269         goto PMF_EXIT;
05270         bSuccess = FALSE;
05271     }
05272
05273     if (pd.hDC == NULL) {
05274         SetWindowText(ghTextWnd, GetStringRes(IDS_CREPRTDCFAIL));
05275         goto PMF_EXIT;
05276         bSuccess = FALSE;
05277     }
05278
05279     hDCPrinter = pd.hDC;
05280     if (GetEnhMetaFileDescription(hEnhMf, 128, (LPTSTR)buf) == 0) {
05281         strncpy(buf, "No Title", 127);
05282     buf [127] = '\0';
05283     }
05284
05285     memset(&DocInfo, 0, sizeof(DOCINFO));
05286     DocInfo.cbSize      = sizeof(DOCINFO);
05287     DocInfo.lpszDocName = (LPTSTR) buf;
05288     DocInfo.lpszOutput  = NULL;
05289     StartDoc(hDCPrinter, &DocInfo);
05290     StartPage(hDCPrinter);
05291
05292     SetWindowText(ghTextWnd, GetStringRes(IDS_PRT));
05293
05294     iEntries = GetEnhMetaFilePaletteEntries(hEnhMf, 0, NULL);
05295
05296     if (iEntries) {
05297         if ((plogPal = (PLOGPALETTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
05298                 sizeof(DWORD) + sizeof(PALETTEENTRY)*iEntries )) == NULL) {
05299             MessageBox(ghwndMain, GetStringRes(IDS_CREPALFAIL),
05300                 GetStringRes(IDS_ERROR), MB_OK);
05301         }
05302
05303         plogPal->palVersion = 0x300;
05304         plogPal->palNumEntries = (WORD) iEntries;
05305         pjTmp = (PBYTE) plogPal;
05306         pjTmp += 4;
05307
05308         GetEnhMetaFilePaletteEntries(hEnhMf, iEntries, (PPALETTEENTRY)pjTmp);
05309         hPal = CreatePalette(plogPal);
05310         GlobalFree(plogPal);
05311
05312         SelectPalette(hDCPrinter, hPal, FALSE);
05313         RealizePalette(hDCPrinter);
05314     }
05315
05316     GetEnhMetaFileHeader(hEnhMf, sizeof(ENHMETAHEADER), &EnhMetaHdr);
05317
05318
05319     bRCSet = bSetRC2MatchEmfRC(hDCPrinter, EnhMetaHdr, hEnhMf, NULL);
05320     if (!bRCSet) {
05321         vErrOut("bPrintMF: failed");
05322     }
05323
05324     if (pPD->bFit2Wnd) {
05325         int     iWidth, iHeight;
05326         RECT    rc;
05327
05328         iWidth = GetDeviceCaps(hDCPrinter, HORZRES);
05329         iHeight = GetDeviceCaps(hDCPrinter, VERTRES);
05330         rc.left = rc.top = 0;
05331         rc.right = iWidth;
05332         rc.bottom = iHeight;
05333         bSuccess = PlayEnhMetaFile(hDCPrinter, hEnhMf, (LPRECT) &rc);
05334         if (!bSuccess) {
05335             char    text[128];
05336
05337             _sntprintf(text, 127,GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
05338       text [127] = '\0';
05339             OutputDebugString(text);
05340         }
05341
05342
05343     } else {
05344         RECT rc;
05345
05346         rc.top = rc.left = 0;
05347         rc.right = EnhMetaHdr.rclBounds.right - EnhMetaHdr.rclBounds.left;
05348         rc.bottom = EnhMetaHdr.rclBounds.bottom - EnhMetaHdr.rclBounds.top;
05349         bSuccess = PlayEnhMetaFile(hDCPrinter, hEnhMf, (LPRECT) &rc);
05350         if (!bSuccess) {
05351             char    text[128];
05352
05353             _sntprintf(text, 127, GetStringRes(IDS_FMT_PLAYEMFFAIL), GetLastError());
05354             text [127] = '\0';
05355       OutputDebugString(text);
05356         }
05357     }
05358
05359 //    if (gbDB && bSuccess)
05360 //       SwapBuffers(hDCPrinter);
05361
05362     EndPage(hDCPrinter);
05363     EndDoc(hDCPrinter);
05364     SetWindowText(ghTextWnd, GetStringRes(IDS_PRTTHRDDONE));
05365
05366     if (bRCSet) {
05367         bCleanUpRC();
05368     }
05369
05370
05371 PMF_EXIT:
05372
05373     ExitThread(0);
05374     return bSuccess;
05375
05376 }
05377
05378 /******************************Public*Routine******************************\
05379 *
05380 * bSelectDIBPal
05381 *
05382 * Effects: Creates a logical palette from the DIB and select it into the DC
05383 *          and realize the palette. Saving the hPal in the ghPal
05384 *
05385 * Warnings: Based on Windows NT DIB support.  If PM support 16,24,32 bpp
05386 *           we need to modify this routine.
05387 *           Global alert! ghPal is changed here...
05388 *
05389 \**************************************************************************/
05390
05391 BOOL bSelectDIBPal(HDC hDC, LPBITMAPINFO pbmi, BOOL bCoreHdr)
05392 {
05393   LOGPALETTE    *plogPal;
05394   UINT          uiSizPal;
05395   INT           i, iNumClr;
05396   WORD          wBitCount;
05397
05398   if (bCoreHdr) {
05399     wBitCount = ((LPBITMAPCOREINFO)pbmi)->bmciHeader.bcBitCount;
05400   } else {
05401     wBitCount = pbmi->bmiHeader.biBitCount;
05402   }
05403
05404   switch (wBitCount) {
05405     case 16:
05406     case 24:
05407     case 32:                            // Does PM supports these?
05408         return FALSE;
05409     default:
05410         iNumClr = (1 << wBitCount);
05411         break;
05412   }
05413
05414   uiSizPal = sizeof(WORD)*2 + sizeof(PALETTEENTRY)*iNumClr;
05415   if ((plogPal = (LOGPALETTE *) LocalAlloc(LMEM_FIXED,uiSizPal)) == NULL) {
05416       MessageBox(ghwndMain, GetStringRes(IDS_ALLOCPALFAIL),
05417             GetStringRes(IDS_ERROR), MB_OK);
05418       ghPal = NULL;
05419       return FALSE;
05420   }
05421
05422   plogPal->palVersion = 0x300;
05423   plogPal->palNumEntries = (WORD) iNumClr;
05424
05425   if (bCoreHdr) {
05426     for (i=0; i<iNumClr; i++) {
05427         plogPal->palPalEntry[i].peRed   = ((LPBITMAPCOREINFO)pbmi)->bmciColors[i].rgbtRed;
05428         plogPal->palPalEntry[i].peGreen = ((LPBITMAPCOREINFO)pbmi)->bmciColors[i].rgbtGreen;
05429         plogPal->palPalEntry[i].peBlue  = ((LPBITMAPCOREINFO)pbmi)->bmciColors[i].rgbtBlue;
05430         plogPal->palPalEntry[i].peFlags = PC_RESERVED;
05431     }
05432   } else {
05433     for (i=0; i<iNumClr; i++) {
05434         plogPal->palPalEntry[i].peRed   = pbmi->bmiColors[i].rgbRed;
05435         plogPal->palPalEntry[i].peGreen = pbmi->bmiColors[i].rgbGreen;
05436         plogPal->palPalEntry[i].peBlue  = pbmi->bmiColors[i].rgbBlue;
05437         plogPal->palPalEntry[i].peFlags = PC_RESERVED;
05438     }
05439   }
05440
05441   DeleteObject(ghPal);
05442   ghPal = CreatePalette((LPLOGPALETTE)plogPal);
05443   if ((ghPal) == NULL) {
05444       MessageBox(ghwndMain, GetStringRes(IDS_CREPALFAIL),
05445             GetStringRes(IDS_ERROR), MB_OK);
05446       return FALSE;
05447   }
05448
05449   if ((GetDeviceCaps(hDC, RASTERCAPS)) & RC_PALETTE) {
05450     SelectPalette(hDC, ghPal, FALSE);
05451     RealizePalette(hDC);
05452   }
05453
05454   LocalFree(plogPal);
05455
05456   return TRUE;
05457 }
05458
05459
05460 /******************************Public*Routine******************************\
05461 *
05462 * bPlgBlt
05463 *
05464 * Effects:  If Source DIB bpp > Destination DC's
05465 *           use Halftone for PlgBlt.
05466 *
05467 * Warnings: Global Alert!
05468 *           gbUseDIB is always TRUE now.
05469 *
05470 \**************************************************************************/
05471
05472 BOOL bPlgBlt(HDC hDC, LPPOINT rgPtsBMP)
05473 {
05474     HDC                  hDCRef;
05475     HDC                  hDCSrn;                // hDC can be metaf DC
05476     HGDIOBJ              hObjOld, hBmpMem=NULL;
05477     BITMAP               bm;
05478     INT                  iBpp;
05479     WORD                 wBitCnt;
05480
05481
05482     hDCSrn = GetDC(ghwndDrawSurf);
05483     hDCRef = CreateCompatibleDC(hDC);
05484
05485     if (gbUseDIB) {
05486         int         cx, cy, dx, dy;
05487         PBITMAPINFO pbmi;
05488
05489         pbmi = (gDib.rgpbmi[0]);
05490         dx = rgPtsBMP[0].x - rgPtsBMP[1].x;
05491         dy = rgPtsBMP[0].y - rgPtsBMP[1].y;
05492         cx = (INT) sqrt( dx * dx + dy * dy );
05493
05494         dx = rgPtsBMP[0].x - rgPtsBMP[2].x;
05495         dy = rgPtsBMP[0].y - rgPtsBMP[2].y;
05496         cy = (INT) sqrt( dx * dx + dy * dy );
05497
05498         iBpp = GetDeviceCaps(hDC, BITSPIXEL);
05499
05500         if (gDib.rgbCoreHdr[0]) {
05501             wBitCnt = ((LPBITMAPCOREINFO)pbmi)->bmciHeader.bcBitCount;
05502         } else {
05503             wBitCnt = pbmi->bmiHeader.biBitCount;
05504         }
05505
05506         if (iBpp < wBitCnt) {   // Do Halftone
05507             SetStretchBltMode(hDCRef, HALFTONE);
05508             if (ghHT) {
05509                 SelectPalette(hDCRef, ghHT, FALSE);
05510                 SelectPalette(hDC, ghHT, FALSE);
05511                 SelectPalette(hDCSrn, ghHT, FALSE); // hDC can be metaf DC
05512                 RealizePalette(hDCSrn);             // always realize the srn DC
05513
05514                 // Don't have to realize the palette in hDCRef
05515                 // RealizePalette(hDCRef);
05516
05517                 // has to be compatible with screen DC, cannot be hDCRef
05518                 // memory DC has no bitmap by default?
05519                 // hDC may be a metafile DC, so use hDCSrn
05520                 hBmpMem = CreateCompatibleBitmap(hDCSrn, cx, cy);
05521                 SelectObject(hDCRef, hBmpMem);
05522             } else {
05523                 MessageBox(ghwndMain, GetStringRes(IDS_HFTONEPALNULL),
05524                     GetStringRes(IDS_ERROR), MB_OK);
05525             }
05526         } else {
05527             SetStretchBltMode(hDCRef, COLORONCOLOR);
05528             if (ghPal) {
05529                 if (ghDCMetaf == hDC)
05530                     CopyPalette(ghPal);
05531                 SelectPalette(hDCRef, ghPal, FALSE);
05532                 SelectPalette(hDC, ghPal, FALSE);
05533                 SelectPalette(hDCSrn, ghPal, FALSE); // hDC can be metaf DC
05534                 RealizePalette(hDCSrn);             // always realize the srn DC
05535
05536                 // Don't have to realize the palette in hDCRef
05537                 // RealizePalette(hDCRef);
05538
05539                 // has to be compatible with screen DC, cannot be hDCRef
05540                 // memory DC has no bitmap by default?
05541                 // hDC may be a metafile DC, so use hDCSrn
05542                 hBmpMem = CreateCompatibleBitmap(hDCSrn, cx, cy);
05543                 SelectObject(hDCRef, hBmpMem);
05544             } else {
05545                 MessageBox(ghwndMain, GetStringRes(IDS_PALNULL),
05546                     GetStringRes(IDS_ERROR), MB_OK);
05547             }
05548         }
05549
05550         if (gDib.rgbCoreHdr[0]) {
05551             StretchDIBits(hDCRef, 0,0, cx, cy,
05552                           0,0, ((LPBITMAPCOREINFO)pbmi)->bmciHeader.bcWidth, ((LPBITMAPCOREINFO)pbmi)->bmciHeader.bcHeight,
05553                           gDib.rgpjFrame[0], pbmi, DIB_RGB_COLORS, SRCCOPY);
05554         } else {
05555             StretchDIBits(hDCRef, 0,0, cx, cy,
05556                           0,0, pbmi->bmiHeader.biWidth, pbmi->bmiHeader.biHeight,
05557                           gDib.rgpjFrame[0], pbmi, DIB_RGB_COLORS, SRCCOPY);
05558         }
05559
05560         PlgBlt(hDC, rgPtsBMP, hDCRef, 0, 0, cx, cy,
05561                ghBmpMask, 0, 0);
05562
05563         if (hBmpMem)
05564             DeleteObject(hBmpMem);
05565
05566     } else {
05567         hObjOld = SelectObject(hDCRef, ghBmp);
05568
05569         GetObject(ghBmpMask, sizeof(BITMAP), (LPSTR)&bm);
05570         if (bm.bmBitsPixel != 1) {
05571             SetWindowText(ghTextWnd, GetStringRes(IDS_MUSTMSKMCHROMEBM));
05572             ghBmpMask = NULL;
05573         }
05574
05575         GetObject(ghBmp, sizeof(BITMAP), (LPSTR)&bm);
05576
05577         if (ghPal) {
05578             SelectPalette(hDC, ghPal, FALSE);
05579             RealizePalette(hDC);
05580             SetStretchBltMode(hDC, COLORONCOLOR);
05581         }
05582         PlgBlt(hDC, rgPtsBMP, hDCRef, 0, 0, bm.bmWidth, bm.bmHeight,
05583                ghBmpMask, 0, 0);
05584
05585         SelectObject(hDCRef, hObjOld);
05586     }
05587
05588     DeleteDC(hDCRef);
05589     ReleaseDC(ghwndDrawSurf, hDCSrn);
05590     return TRUE;
05591
05592 }
05593
05594
05595
05596 /******************************Public*Routine******************************\
05597 *
05598 * HPALETTE CopyPalette
05599 *
05600 * Effects:
05601 *
05602 * Warnings:
05603 *
05604 \**************************************************************************/
05605
05606 HPALETTE CopyPalette(HPALETTE hPalSrc)
05607 {
05608     PLOGPALETTE     plogPal;
05609     PBYTE           pjTmp;
05610     int             iNumEntries=0;
05611     HPALETTE        hPal;
05612
05613     if ((iNumEntries = GetPaletteEntries(hPalSrc, 0, iNumEntries, NULL)) == 0) {
05614         MessageBox(ghwndMain, GetStringRes(IDS_NOPALENTRYFORCPY),
05615             GetStringRes(IDS_ERROR), MB_OK);
05616         return (HPALETTE) NULL;
05617     }
05618
05619     if ((plogPal = (PLOGPALETTE)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,
05620             sizeof(DWORD) + sizeof(PALETTEENTRY)*iNumEntries )) == NULL) {
05621         MessageBox(ghwndMain, GetStringRes(IDS_CPYPALFAIL),
05622             GetStringRes(IDS_ERROR), MB_OK);
05623         return (HPALETTE) NULL;
05624     }
05625
05626     plogPal->palVersion = 0x300;
05627     plogPal->palNumEntries = (WORD) iNumEntries;
05628     pjTmp = (PBYTE) plogPal;
05629     pjTmp += 4;
05630     GetPaletteEntries(hPalSrc, 0, iNumEntries, (PPALETTEENTRY)pjTmp);
05631     hPal = CreatePalette(plogPal);
05632
05633     GlobalFree(plogPal);
05634
05635     return hPal;
05636 }
05637
05638
05639
05640
05641 /******************************Public*Routine******************************\
05642 *
05643 * iTT
05644 *
05645 * Effects: set the global variable gbTT if the family is true type
05646 *
05647 * Warnings:
05648 *
05649 \**************************************************************************/
05650
05651 int CALLBACK iTT(
05652     LPLOGFONT    lpLF,
05653     LPTEXTMETRIC lpTM,
05654     DWORD        dwFontType,
05655     LPARAM       lpData)
05656 {
05657
05658     if (lpTM->tmPitchAndFamily & TMPF_TRUETYPE) {
05659         //OutputDebugString("TRUETYPE\n");
05660         *((BOOL *)lpData) = TRUE;
05661     } else {
05662         //OutputDebugString("NON-TRUETYPE\n");
05663         *((BOOL *)lpData) = FALSE;
05664     }
05665
05666 #if 0
05667     //
05668     // that's equivalent
05669     //
05670     if (dwFontType & TRUETYPE_FONTTYPE) {
05671         //OutputDebugString("TRUETYPE\n");
05672         *((BOOL *)lpData) = TRUE;
05673     } else {
05674         //OutputDebugString("NON-TRUETYPE\n");
05675         *((BOOL *)lpData) = FALSE;
05676     }
05677 #endif
05678     return 0;
05679
05680     UNREFERENCED_PARAMETER (lpLF);
05681     //UNREFERENCED_PARAMETER (lpTM);
05682     UNREFERENCED_PARAMETER (dwFontType);
05683
05684 }
05685
05686
05687
05688 /******************************Public*Routine******************************\
05689 *
05690 * CMTMLTFMT *pLoadMltFmtFile(VOID)
05691 *
05692 * Effects:  Load either EPS or enh mf
05693 *
05694 * Warnings: CR! change this to load multiple def of picture
05695 *
05696 \**************************************************************************/
05697
05698 CMTMLTFMT *pLoadMltFmtFile(VOID)
05699 {
05700     OPENFILENAME    ofn;
05701     char            szDirName[MAX_ARRAYSIZE];
05702     char            szFile[MAX_ARRAYSIZE], szFileTitle[MAX_ARRAYSIZE];
05703     static char     *szFilter;
05704     HANDLE          hFile, hMapFile;
05705     LPVOID          pMapFile;
05706     DWORD           dwFileSizeLow, dwFileSizeHigh;
05707     CMTMLTFMT       *pMfmt;
05708
05709     pMfmt = (CMTMLTFMT*)NULL;
05710
05711     BuildFilterStrs(-1);
05712     BuildFilterStrs(IDS_FT_EPS);
05713     szFilter = BuildFilterStrs(IDS_FT_EMF);
05714
05715     GetSystemDirectory((LPSTR) szDirName, 256);
05716     strncpy( szFile, "*.eps\0", MAX_ARRAYSIZE - 1);
05717   szFile [MAX_ARRAYSIZE - 1] = '\0';
05718     ofn.lStructSize = sizeof(OPENFILENAME);
05719     ofn.hwndOwner = GetFocus();
05720     ofn.lpstrFilter = szFilter;
05721     ofn.lpstrCustomFilter = (LPSTR) NULL;
05722     ofn.nMaxCustFilter = 0L;
05723     ofn.nFilterIndex = 1;
05724     ofn.lpstrFile = szFile;
05725     ofn.nMaxFile = sizeof(szFile);
05726     ofn.lpstrFileTitle = szFileTitle;
05727     ofn.nMaxFileTitle = sizeof(szFileTitle);
05728     ofn.lpstrInitialDir = szDirName;
05729     ofn.lpstrTitle = (LPSTR) NULL;
05730     ofn.Flags = 0L;
05731     ofn.nFileOffset = 0;
05732     ofn.nFileExtension = 0;
05733     ofn.lpstrDefExt = "EPS";
05734
05735     if (!GetOpenFileName(&ofn)) {
05736         goto EXIT;
05737     }
05738
05739     if ((hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL,
05740             OPEN_EXISTING, FILE_ATTRIBUTE_READONLY| SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS,
05741             NULL)) == INVALID_HANDLE_VALUE) {
05742         goto EXIT;
05743     }
05744     if ( GetFileType(hFile) != FILE_TYPE_DISK )
05745     {
05746         goto EXIT2;
05747     }
05748
05749     dwFileSizeLow = GetFileSize(hFile, &dwFileSizeHigh);
05750     if ((dwFileSizeLow == 0xFFFFFFFF) && (GetLastError() != NO_ERROR)) {
05751         goto EXIT;
05752     }
05753
05754     //
05755     // Create a map file of the opened file
05756     //
05757     if ((hMapFile = CreateFileMapping(hFile, NULL,
05758                              PAGE_READONLY, 0, 0, NULL)) == INVALID_HANDLE_VALUE) {
05759         goto EXIT2;
05760     }
05761
05762     //
05763     // Map a view of the whole file
05764     //
05765     if ((pMapFile = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0)) == NULL) {
05766         goto EXIT3;
05767     }
05768
05769 //
05770 // CR!! In future, change this to load different def of the picture...
05771 //
05772   {
05773     ULONG       ulSize;
05774     PBYTE       pjTmp;
05775     RECTL       rectl;
05776
05777     ulSize = dwFileSizeLow+sizeof(CMTMLTFMT);
05778     if ((pMfmt = (CMTMLTFMT *) LocalAlloc(LMEM_FIXED, ulSize)) == NULL) {
05779         MessageBox(GetFocus(), GetStringRes(IDS_MALLOCFAIL),
05780             GetStringRes(IDS_ERROR), MB_OK);
05781         goto EXIT3;
05782     }
05783
05784     pMfmt->ident = GDICOMMENT_IDENTIFIER;
05785     pMfmt->iComment = GDICOMMENT_MULTIFORMATS;
05786     pMfmt->nFormats = 1;
05787     pMfmt->aemrformat[0].cbData = dwFileSizeLow;
05788     pMfmt->aemrformat[0].offData = 11*sizeof(DWORD);
05789
05790     // parse for %!PS-Adobe-3.0 EPSF keyword
05791     //           Enhanced Metafile signature
05792     // set EMRFORMAT.dSignature appropiately
05793
05794     if (((ENHMETAHEADER *) pMapFile)->dSignature == ENHMETA_SIGNATURE) {
05795
05796         pMfmt->aemrformat[0].dSignature = ENHMETA_SIGNATURE;
05797         pMfmt->aemrformat[0].nVersion = 0;                    // not for emf
05798         pMfmt->rclOutput.left   = ((ENHMETAHEADER *) pMapFile)->rclBounds.left;
05799         pMfmt->rclOutput.top    = ((ENHMETAHEADER *) pMapFile)->rclBounds.top;
05800         pMfmt->rclOutput.right  = ((ENHMETAHEADER *) pMapFile)->rclBounds.right;
05801         pMfmt->rclOutput.bottom = ((ENHMETAHEADER *) pMapFile)->rclBounds.bottom;
05802     }
05803     else    //assume it is Adobe EPS
05804     if (bGetEPSBounds(pMapFile, &rectl)) {
05805
05806         char text[128];
05807
05808
05809         pMfmt->aemrformat[0].dSignature = 0x46535045;
05810         pMfmt->aemrformat[0].nVersion = 1;
05811         pMfmt->rclOutput.left   = rectl.left;
05812         pMfmt->rclOutput.top    = rectl.top;
05813         pMfmt->rclOutput.right  = rectl.right;
05814         pMfmt->rclOutput.bottom = rectl.bottom;
05815
05816         _sntprintf(text, 127, "Bounds = %d %d %d %d",
05817                  rectl.left, rectl.top, rectl.right, rectl.bottom);
05818     text [127] = '\0';
05819         MessageBox(GetFocus(), text, "Bounds", MB_OK);
05820
05821     }
05822     else {
05823         // unknown file type
05824         Free(pMfmt);
05825         pMfmt = NULL;
05826         goto EXIT3;
05827     }
05828
05829     pjTmp = (PBYTE)(((DWORD *)pMfmt->aemrformat)+4);
05830     while (dwFileSizeLow--) {
05831         *(((PBYTE)pjTmp)++) = *(((PBYTE)pMapFile)++);
05832     }
05833
05834   }
05835
05836
05837 EXIT3:
05838     CloseHandle(hMapFile);
05839 EXIT2:
05840     CloseHandle(hFile);
05841 EXIT:
05842
05843     return pMfmt;
05844 }
05845
05846
05847 HLOCAL Free(CMTMLTFMT *pMfmt) {
05848     return LocalFree(pMfmt);
05849 }
05850
05851 #define MYDBG 0
05852
05853 BOOL bIsAdobe(char *szStr)
05854 {
05855     if (strcmp(szStr, "%!PS-Adobe-3.0") == 0)
05856         return TRUE;
05857     else
05858         return FALSE;
05859 }
05860
05861 BOOL bIsEPS(char *szStr)
05862 {
05863     if ((strcmp(szStr, "EPSF-3.0") == 0) ||
05864         (strcmp(szStr, "EPSF-2.0") == 0))
05865         return TRUE;
05866     else
05867         return FALSE;
05868 }
05869
05870 BOOL bIsBndBox(char *szStr)
05871 {
05872     if (strcmp(szStr, "%%BoundingBox:") == 0)
05873         return TRUE;
05874     else
05875         return FALSE;
05876 }
05877
05878 BOOL bIsEOF(char *szStr)
05879 {
05880     if (strcmp(szStr, "%%EOF") == 0)
05881         return TRUE;
05882     else
05883         return FALSE;
05884 }
05885
05886
05887 BOOL bGetEPSBounds(LPVOID lpData, RECTL *prctl)
05888 {
05889     char szKeyWord[128], szValue[128];
05890     int  index;
05891
05892
05893     if (lpData == NULL) {
05894 #if MYDBG
05895         MessageBox(GetFocus(), GetStringRes(IDS_NULLPTR),
05896             GetStringRes(IDS_ERROR), MB_OK);
05897 #endif
05898         return FALSE;
05899     }
05900
05901     index = 0;
05902
05903     if (!bGetWord(lpData, szKeyWord, &index))
05904         return FALSE;
05905
05906     if (!bIsAdobe(szKeyWord)) {
05907         MessageBox(GetFocus(), GetStringRes(IDS_NOTADOBE),
05908             GetStringRes(IDS_ERROR), MB_OK);
05909         return FALSE;
05910     }
05911
05912     if (!bGetWord(lpData, szValue, &index))
05913         return FALSE;
05914
05915     if (!bIsEPS(szValue)) {
05916         MessageBox(GetFocus(), "Not EPS!",
05917             GetStringRes(IDS_ERROR), MB_OK);
05918         return FALSE;
05919     }
05920
05921     if (!bGoNextLine(lpData, &index))
05922         return FALSE;
05923
05924     while ((bGetWord(lpData, szKeyWord, &index)) &&
05925            (!bIsBndBox(szKeyWord))) {
05926 #if MYDBG
05927         MessageBox(GetFocus(), GetStringRes(IDS_SKPTOEOL),
05928             GetStringRes(IDS_ERROR), MB_OK);
05929 #endif
05930         if (!bGoNextLine(lpData, &index)) {
05931             MessageBox(GetFocus(), GetStringRes(IDS_MUSTNOTEOF),
05932                 GetStringRes(IDS_ERROR), MB_OK);
05933             return FALSE;
05934         }
05935     }
05936
05937     if (bIsBndBox(szKeyWord)) {
05938         if (bGetWord(lpData, szValue, &index))
05939             prctl->left    = atol(szValue);
05940         else {
05941             MessageBox(GetFocus(), GetStringRes(IDS_GETBNDLFTFAIL),
05942                 GetStringRes(IDS_ERROR), MB_OK);
05943             return FALSE;
05944         }
05945
05946         if (bGetWord(lpData, szValue, &index))
05947             prctl->top     = atol(szValue);
05948         else {
05949             MessageBox(GetFocus(), GetStringRes(IDS_GETBNDTOPFAIL),
05950                 GetStringRes(IDS_ERROR), MB_OK);
05951             return FALSE;
05952         }
05953
05954         if (bGetWord(lpData, szValue, &index))
05955             prctl->right   = atol(szValue);
05956         else {
05957             MessageBox(GetFocus(), GetStringRes(IDS_GETBNDRGTFAIL),
05958                 GetStringRes(IDS_ERROR), MB_OK);
05959             return FALSE;
05960         }
05961
05962         if (bGetWord(lpData, szValue, &index))
05963             prctl->bottom  = atol(szValue);
05964         else {
05965             MessageBox(GetFocus(), GetStringRes(IDS_GETBNDBOTFAIL),
05966                 GetStringRes(IDS_ERROR), MB_OK);
05967             return FALSE;
05968         }
05969     }
05970
05971     return TRUE;
05972
05973 }
05974
05975
05976 BOOL bGetWord(LPVOID lpData, char *str, int* pi)
05977 {
05978     char *pstr;
05979
05980     pstr = str;
05981
05982     while (((char *)lpData)[*pi] == ' ')
05983         (*pi)++;
05984
05985     while ((((char *)lpData)[*pi] != ' ') &&
05986            (((char *)lpData)[*pi] != '\n') &&
05987            (((char *)lpData)[*pi] != '\r')) {
05988         *str++ = ((char *)lpData)[(*pi)++];
05989     }
05990     *str++ = '\0';
05991
05992 #if MYDBG
05993     {
05994     char text[128];
05995
05996     _sntprintf(text,127, "bGetWord gets %s", pstr);
05997     text [127] = '\0';
05998   MessageBox(GetFocus(), text, "Info", MB_OK);
05999     }
06000 #endif
06001
06002     return TRUE;
06003 }
06004
06005
06006 BOOL bGoNextLine(LPVOID lpData, int* pi)
06007 {
06008     char tmp[128];
06009     int  q;
06010
06011     while ((((char *)lpData)[*pi] != '\n') &&
06012            (((char *)lpData)[*pi] != '\r'))
06013         (*pi)++;
06014
06015     //
06016     // skip them
06017     //
06018     *pi += 2;
06019
06020     q = *pi;
06021
06022     if ((bGetWord(lpData, tmp, &q)) && (bIsEOF(tmp)) )
06023         return FALSE;
06024
06025     return TRUE;
06026 }
06027
06028
06029 /***************************************************************************\
06030 * bSetAdvancedGraphics
06031 *
06032 * Set the HDC to advanced graphics mode to get world transforms, and other
06033 *  features...  However, only do this if we are running on Windows NT, as
06034 *  the other platforms don't support GM_ADVANCED.
06035 *
06036 \***************************************************************************/
06037 BOOL bSetAdvancedGraphics(HDC hdc)
06038 {
06039     OSVERSIONINFO osvi;
06040     osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
06041
06042     GetVersionEx (&osvi);
06043     if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
06044
06045       if ((SetGraphicsMode(hdc, GM_ADVANCED)) == 0) {
06046      MessageBox(ghwndMain, GetStringRes(IDS_SETADVGRPHMDFAIL), NULL, MB_OK);
06047       }
06048     return TRUE;
06049 }
06050
06051 /******************************************************************************\
06052 *
06053 *  FUNCTION:    GetStringRes (int id INPUT ONLY)
06054 *
06055 *  COMMENTS:    Load the resource string with the ID given, and return a
06056 *               pointer to it.  Notice that the buffer is common memory so
06057 *               the string must be used before this call is made a second time.
06058 *
06059 \******************************************************************************/
06060
06061 LPTSTR   GetStringRes (int id)
06062 {
06063   static TCHAR buffer[MAX_PATH];
06064
06065   buffer[0]=0;
06066   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
06067   return buffer;
06068 }
06069
06070 LPTSTR   GetStringRes2 (int id)
06071 {
06072   static TCHAR buffer[MAX_PATH];
06073
06074   buffer[0]=0;
06075   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
06076   return buffer;
06077 }
06078
06079 /******************************************************************************\
06080 *
06081 *  FUNCTION:    BuildFilterStrs (int id INPUT ONLY)
06082 *
06083 *  COMMENTS:    Construct a filter string by a series of LoadString calls. The
06084 *       resulting string is as follows: "%OldStr%\0%IDStr%\0%(ID+1)Str%\0\0".
06085 *       Note that each consecutive function call appends the new filter
06086 *       string on to the end of a static buffer. Call the function with
06087 *       id = -1 to reinitialize the buffer.
06088 *
06089 \******************************************************************************/
06090
06091 LPTSTR  BuildFilterStrs(int id)
06092 {
06093   static TCHAR buffer[1024];
06094   static TCHAR *pBuf;
06095   int delimIndex;
06096
06097   if ((id == -1) || (!pBuf)) // to make sure the first time its called, pBuf is not used without initialization
06098   {
06099     pBuf = buffer;
06100   }
06101   else
06102   {
06103     delimIndex = LoadString(GetModuleHandle (NULL), id, pBuf, 1024 - (int)(pBuf-buffer));
06104     if (!delimIndex)
06105         return buffer;
06106     if (1024 - (int)(pBuf - buffer) > delimIndex)
06107         pBuf += delimIndex + 1;
06108
06109     delimIndex = LoadString(GetModuleHandle (NULL), id + 1, pBuf, 1024 - (int)(pBuf-buffer));
06110     if (!delimIndex)
06111         return buffer;
06112     if (1024 - (int)(pBuf - buffer) > delimIndex)
06113         pBuf += delimIndex + 1;
06114   }
06115
06116   *pBuf = 0;
06117   *(pBuf+1) = 0;
06118   return buffer;
06119 }
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/Iconpro/MDIChild.h Source File

  • WinUI
  • Resource
  • Iconpro

MDIChild.h

Go to the documentation of this file.
00001 /****************************************************************************\
00002 *
00003 *     FILE:     MDIChild.H
00004 *
00005 *     PURPOSE:  IconPro Project MDI Child Window handling header file
00006 *
00007 *     COMMENTS: One CHILDWINDOWDATA struct defined below is attached
00008 *               to each MDI child window. It stores information about
00009 *               the listbox, the locations of drawing objects, and the
00010 *               icon resource associated with each window.
00011 *
00012 *     Copyright 1995 - 2000 Microsoft Corp.
00013 *
00014 *
00015 * History:
00016 *                July '95 - Created
00017 *
00018 \****************************************************************************/
00019
00020 #include <windows.h>
00021
00022 /****************************************************************************/
00023 // local #defines
00024
00025 // The ID for the listbox child window
00026 #define ID_FORMAT_BOX   102
00027 /****************************************************************************/
00028
00029
00030 /****************************************************************************/
00031 // Local structs
00032
00033 // This struct is used to hold the data associated with an MDI window
00034 typedef struct
00035 {
00036     HWND            hWndFormatListBox;        // Window Handle for listbox
00037     PICONRESOURCE   pIR;                      // pointer to icon resource
00038     RECT            BoxRect;                  // ListBox Window Rect
00039     RECT            DrawingRect;              // Overall rect to draw in
00040     RECT            BlackRect, BlackTextRect; // for black bkgrnd & text
00041     RECT            WhiteRect, WhiteTextRect; // for white bkgrnd & text
00042     RECT            XORRect, XORTextRect;     // for XOR mask & text
00043     RECT            ANDRect, ANDTextRect;     // for AND mask & text
00044     RECT            XORImageRect;             // in which to draw OR mask
00045 } CHILDWINDOWDATA, *PCHILDWINDOWDATA;
00046 /****************************************************************************/
00047
00048
00049
00050 /****************************************************************************/
00051 // Exported function prototypes
00052 LRESULT CALLBACK IconChildWndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
00053 /****************************************************************************/
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/cfactory.h Source File

  • Com
  • async
  • server

cfactory.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __CFactory_h__
00018 #define __CFactory_h__
00019
00020 #include "CUnknown.h"
00021 ///////////////////////////////////////////////////////////
00022 //
00023 //  Component creation function
00024 //
00025 class CUnknown;
00026
00027 typedef HRESULT (_stdcall *FPCREATEINSTANCE)(IUnknown*, CUnknown**);
00028
00029 typedef enum {INPROC, CONTROL, LOCAL, REMOTE} SERVERTYPE;
00030
00031 #define MAKEVERSION(M, m) ((DWORD)(WORD)(m) | (DWORD)(WORD)(M) << 16) // M=Major, m=minor
00032
00033 ///////////////////////////////////////////////////////////
00034 //
00035 // CFactoryData
00036 //   - Information CFactory needs to create a component
00037 //     supported by the DLL
00038 //
00039 struct CFactoryData
00040 {
00041
00042   DWORD version;
00043
00044   // InProc, Local, Control
00045   SERVERTYPE server;
00046
00047   // Threading model
00048   LPCSTR threadingModel;
00049
00050   // The class ID for the component
00051   const CLSID* m_pCLSID;
00052
00053   // Pointer to the function that creates it
00054   FPCREATEINSTANCE CreateInstance;
00055
00056   // Name of the component to register in the registry
00057   LPCSTR m_RegistryName;
00058
00059   // ProgID
00060   LPOLESTR m_szProgID;
00061
00062   // Version-independent ProgID
00063   LPOLESTR m_szVerIndProgID;
00064
00065   // Short User type
00066   LPCSTR m_szname;
00067
00068   // Appliction name
00069   LPCSTR m_szAppName;
00070
00071   // Helper function for finding the class ID
00072   BOOL IsClassID(const CLSID& clsid) const
00073     { return (*m_pCLSID == clsid) ;}
00074
00075   // GUID of the typelib
00076   const GUID* m_pLIBID;
00077
00078   // Locale ID for typelib
00079   LCID  m_lcid;
00080
00081   // Version of typelib
00082   DWORD m_LibVersion;
00083
00084   // Flag set to TRUE if the server has a custom proxy
00085   bool m_fProxy;
00086
00087   // Verbs recognized by IOleObject::DoVerb
00088   LPCSTR m_oleVerbs;
00089
00090   // OLEMISC flags specific to this object
00091   DWORD m_oleMisc;
00092 };
00093
00094
00095 ///////////////////////////////////////////////////////////
00096 //
00097 // Class Factory
00098 //
00099 class CFactory : public IClassFactory
00100 {
00101 private:
00102   // IUnknown
00103   virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv);
00104   virtual ULONG   __stdcall AddRef();
00105   virtual ULONG   __stdcall Release();
00106
00107   // IClassFactory
00108   virtual HRESULT __stdcall CreateInstance(IUnknown* pUnknownOuter,
00109                                            const IID& iid,
00110                                            void** ppv);
00111   virtual HRESULT __stdcall LockServer(BOOL bLock);
00112
00113   CFactory() {};
00114
00115 #if defined(_DLL_SERVER_)
00116   // Function to determine if component can be unloaded
00117   friend HRESULT __stdcall DllCanUnloadNow();
00118   friend HRESULT __stdcall DllGetClassObject(const CLSID& clsid,
00119                       const IID& iid,
00120                       void** ppv);
00121
00122   static HRESULT CanUnloadNow();
00123
00124   // Helper function to DllGetClassObject();
00125   static HRESULT GetClassObject(const CLSID& clsid,
00126                                 const IID& iid,
00127                                 void** ppv);
00128 #endif
00129
00130 public:
00131   // Constructor - Pass pointer to data of component to create.
00132   CFactory(const CFactoryData* pFactoryData);
00133
00134   // Destructor
00135   ~CFactory();
00136
00137   // Functions to [un]register all components
00138   static HRESULT RegisterAll();
00139
00140   static HRESULT UnregisterAll();
00141
00142 private:
00143   // state variables
00144
00145   // Reference Count
00146   long m_cRef;
00147
00148   friend HRESULT _stdcall CUnknown::Quit();
00149
00150   static long s_cServerLocks;
00151
00152 public:
00153   //
00154   // Static FactoryData support functions
00155   //
00156   static BOOL IsLocked()
00157   { return (CFactory::s_cServerLocks > 0);}
00158
00159
00160   static DWORD lockCount()
00161   { return CFactory::s_cServerLocks;}
00162
00163 protected:
00164   // Pointer to information about class this factory creates
00165   const CFactoryData* m_pFactoryData;
00166 };
00167 #endif // __CFactory_h__
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/debug.c Source File

  • Com
  • async
  • server

debug.c

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #define ANSI
00019 #include <windows.h>
00020 #include <stdarg.h>
00021 #include <stdio.h>
00022 #include "debug.h"
00023
00024
00025 void AddToMessageLog(LPWSTR lpszSourceName, LPWSTR lpszMsg, WORD ErrorLogType);
00026 void ReportError(LPTSTR lpstrMessage, DWORD errno);
00027
00028 //#define _WRITE_TO_EVENT_LOG_
00029
00030 #if defined(_WRITE_TO_EVENT_LOG_)
00031 extern LPWSTR appSource;
00032 #endif
00033
00034
00035 LPSTR WINAPI UniCode2Ansi(LPSTR lpa, LPCWSTR lpw, int nChars)
00036 {
00037   _ASSERT(lpw != NULL);
00038   _ASSERT(lpa != NULL);
00039   // verify that no illegal character present
00040   // since lpa was allocated based on the size of lpw
00041   // don't worry about the number of chars
00042   lpa[0] = '\0';
00043   WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpa, nChars, NULL, NULL);
00044   return lpa;
00045 }
00046
00047 LPWSTR WINAPI Ansi2Unicode(LPWSTR lpw, LPCSTR lpa, int nChars)
00048 {
00049   _ASSERT(lpa != NULL);
00050   _ASSERT(lpw != NULL);
00051   // verify that no illegal character present
00052   // since lpw was allocated based on the size of lpa
00053   // don't worry about the number of chars
00054   lpw[0] = L'\0';
00055   MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars);
00056   return lpw;
00057 }
00058
00059 #if defined(_DEBUG)
00060 void _cdecl DebugTrace(LPCTSTR lpszFormat, ...)
00061 {
00062   va_list args;
00063   TCHAR szBuffer[512];
00064   int cb;
00065
00066   va_start(args, lpszFormat);
00067
00068   cb = _vstprintf(szBuffer, lpszFormat, args);
00069 #if defined(_WRITE_TO_EVENT_LOG_)
00070 #if !defined(_UNICODE)
00071   {
00072   CHAR_CONVERSION;
00073   AddToMessageLog(appSource, A2W(szBuffer), EVENTLOG_INFORMATION_TYPE);
00074   }
00075 #else
00076   AddToMessageLog(appSource, szBuffer, EVENTLOG_INFORMATION_TYPE);
00077 #endif // _UNICODE
00078 #else  // _WRITE_TO_EVENT_LOG_
00079   OutputDebugString(szBuffer);
00080   OutputDebugString(_T("\r\n"));
00081 #endif // _WRITE_TO_EVENT_LOG_
00082   return;
00083 }
00084 #endif // _DEBUG
00085
00086 void ReportError(LPTSTR lpstrMessage, DWORD errno)
00087 {
00088   LPTSTR lpstrError, ErrorMessage;
00089   DWORD cbLen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
00090                 FORMAT_MESSAGE_FROM_SYSTEM,
00091                 NULL,
00092                 errno,
00093                 LANG_USER_DEFAULT,
00094                 (LPSTR)&lpstrError,
00095                 0,
00096                 NULL);
00097   ErrorMessage = LocalAlloc(LPTR, cbLen+lstrlen(lpstrMessage)+3);
00098   wsprintf(ErrorMessage, "%s: %s", lpstrMessage, lpstrError);
00099 #if defined(_WRITE_TO_EVENT_LOG_)
00100 #if !defined(_UNICODE)
00101   {
00102   CHAR_CONVERSION;
00103   AddToMessageLog(appSource, A2W(ErrorMessage),EVENTLOG_ERROR_TYPE);
00104   }
00105 #else // _UNICODE
00106   AddToMessageLog(appSource, ErrorMessage,EVENTLOG_ERROR_TYPE);
00107 #endif // _UNICODE
00108 #else  // _WRITE_TO_EVENT_LOG_
00109   OutputDebugString(ErrorMessage);
00110   OutputDebugString(_T("\r\n"));
00111 #endif // _WRITE_TO_EVENT_LOG_
00112   LocalFree(lpstrError);
00113   LocalFree(ErrorMessage);
00114 }
00115
00116
00117 static BOOL g_fKey = FALSE;
00118 static TCHAR g_KeyName[] =
00119   _T("System\\CurrentControlSet\\Services\\EventLog\\Application\\COM");
00120
00121 void AddToMessageLog(LPWSTR lpszSourceName, LPWSTR lpszMsg, WORD ErrorLogType)
00122 {
00123   HKEY hkey;
00124     HANDLE  hEventSource;
00125     HANDLE hToken;
00126   TOKEN_USER *puser;
00127   PSID psid = NULL;
00128   DWORD cb = 0;
00129
00130     // Use event logging to log the error.
00131     //
00132
00133   if (!g_fKey)
00134   {
00135     RegCreateKey(HKEY_LOCAL_MACHINE, g_KeyName, &hkey);
00136     RegFlushKey(hkey);
00137     RegCloseKey(hkey);
00138     g_fKey = TRUE;
00139   }
00140
00141   if (OpenThreadToken(GetCurrentThread(), TOKEN_READ, TRUE, &hToken)
00142     || OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken))
00143   {
00144     GetTokenInformation(hToken, TokenUser, NULL, cb, &cb);
00145     puser = LocalAlloc(LPTR, cb);
00146     if (puser && GetTokenInformation(hToken, TokenUser, puser, cb, &cb))
00147       psid = puser->User.Sid;
00148   }
00149
00150   hEventSource = RegisterEventSource(NULL, _T("COM"));
00151
00152     if (hEventSource != NULL)
00153   {
00154     ReportEventW(hEventSource, // handle of event source
00155       ErrorLogType,     // event type
00156             0,                    // event category
00157             0,                    // event ID
00158             psid,                 // current user's SID
00159             1,                    // strings in lpszStrings
00160             0,                    // no bytes of raw data
00161             (LPCWSTR*)&lpszMsg,    // array of error strings
00162             NULL);                // no raw data
00163
00164         DeregisterEventSource(hEventSource);
00165     }
00166   if (puser)
00167     LocalFree(puser);
00168
00169   return;
00170 }
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/repas/Repas.Idl Source File

  • NetDS
  • RPC
  • Data
  • repas

Repas.Idl

Go to the documentation of this file.
00001 [ uuid(56BF67C0-6503-1068-BF67-00DD010FBF25),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface repas
00006 {
00007
00008 const short STRING_SIZE = 100;
00009
00010 typedef char       CHAR_STRING[STRING_SIZE];
00011 typedef wchar_t    WCHAR_STRING[STRING_SIZE];
00012
00013 // note that the client and server side need different header files,
00014 // since the represent_as ACF attribute changes the application's
00015 // signatures for the next two functions
00016
00017 // client side functions defined with ASCII for both functions
00018 // server side functions defined with UNICODE for both functions
00019
00020 // this function uses UNICODE on the wire (converted by client stub)
00021 void ModifyMyWString([in, out] WCHAR_STRING *pStr);
00022
00023 // this function uses ASCII on the wire (converted by server stub)
00024 void ModifyMyString([in, out] CHAR_STRING * pStr );
00025
00026 void Shutdown(void);
00027
00028 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

MyDataSource Member List

This is the complete list of members for MyDataSource, including all inherited members.
addDataSourceListener(IDataSourceListener *pDSL) | MyDataSource | [virtual]
addDataSourceListener(DataSourceListener rDataSourceListener) | MyDataSource | [inline]
getDataMember(BSTR bstrDM, REFIID riid, IUnknown **ppUnk) | MyDataSource | [virtual]
getDataMember(String sDataMember, _Guid riid) | MyDataSource | [inline]
getDataMemberCount(LONG *plCount) | MyDataSource | [virtual]
getDataMemberCount() | MyDataSource | [inline]
getDataMemberName(LONG lIndex, BSTR *pbstrDM) | MyDataSource | [virtual]
getDataMemberName(int lIndex) | MyDataSource | [inline]
Init() | MyDataSource | [virtual]
m_cRef | MyDataSource | [protected]
m_cTables | MyDataSource | [protected]
m_listListeners | MyDataSource | [protected]
m_pMyOSPObject | MyDataSource | [protected]
m_rgpwszTableName | MyDataSource | [protected]
m_rOSPObject | MyDataSource | [package]
m_sDataMember | MyDataSource | [package]
m_vListeners | MyDataSource | [package]
main(String args[]) | MyDataSource | [inline, static]
MyDataSource() | MyDataSource |
MyDataSource() | MyDataSource | [inline]
QueryInterface(REFIID riid, void **ppv) | MyDataSource | [virtual]
removeDataSourceListener(IDataSourceListener *pDSL) | MyDataSource | [virtual]
removeDataSourceListener(DataSourceListener rDataSourceListener) | MyDataSource | [inline]
STDMETHODIMP_(ULONG) AddRef() | MyDataSource | [inline, virtual]
STDMETHODIMP_(ULONG) Release() | MyDataSource | [inline, virtual]
~MyDataSource() | MyDataSource | [virtual]
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_ADO Member List

This is the complete list of members for msado15::_ADO, including all inherited members.
getProperties() | msado15::_ADO |
iid | msado15::_ADO | [static]
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/Callout/AdminDll.c Source File

  • NetDS
  • RRas
  • Callout

AdminDll.c

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright (C) 1992 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       MprAdmin API usage and  is meant to help users with
00007 *       MprAdmin API calling conventions. Use this code at your own risk.
00008 *       Microsoft disclaims any implied warranty. This sample code can
00009 *       be copied and distributed.
00010 *
00011 ******************************************************************************/
00012
00013 /********************************************************************
00014 *  admindll.c -- Sample program demonstrating the use of MprAdmin
00015 *                     CallOut API's
00016 *
00017 *****************************************************************************/
00018 /***************************************************************************
00019 *  Functions:
00020 *        Init(void);
00021 *        Init2(void);
00022 *        Debug_Print_RasConnection(
00023 *                       IN RAS_CONNECTION_0 *   pRasConnection0,
00024 *                       IN RAS_CONNECTION_1 *   pRasConnection1)
00025 *
00026 *        File_Print_RasConnection(
00027 *                       IN RAS_CONNECTION_0 *   pRasConnection0,
00028 *                       IN RAS_CONNECTION_1 *   pRasConnection1)
00029 *
00030 *        Debug_Print_RasPort(
00031 *                       IN RAS_PORT_0 *   pRasPort0,
00032 *                       IN RAS_PORT_1 *   pRasPort1)
00033 *
00034 *        File_Print_RasPort(
00035 *                       IN RAS_PORT_0 *   pRasPort0,
00036 *                       IN RAS_PORT_1 *   pRasPort1)
00037 *****************************************************************************/
00038
00039 #include <windows.h>
00040 #include <stdlib.h>
00041 #include <string.h>
00042 #include <stdlib.h>
00043 #include <lm.h>
00044 #include <stdio.h>
00045 #include <time.h>
00046 #include <mprapi.h>
00047 #include <memory.h>
00048 #include "Shlwapi.h" // Platform SDK wasn't including this .h file so it's part of this project
00049
00050 // Macro for counting maximum characters that will fit into a buffer
00051 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00052
00053 //Functions
00054 VOID
00055 Debug_Print_RasConnection(
00056    IN RAS_CONNECTION_0 *   pRasConnection0,
00057    IN RAS_CONNECTION_1 *   pRasConnection1
00058    );
00059
00060 VOID
00061 File_Print_RasConnection(IN RAS_CONNECTION_0 *   pRasConnection0,
00062    IN RAS_CONNECTION_1 *   pRasConnection1
00063    );
00064
00065 VOID
00066 Debug_Print_RasPort(
00067    IN RAS_PORT_0 *   pRasPort0,
00068    IN RAS_PORT_1 *   pRasPort1
00069    );
00070
00071 VOID
00072 File_Print_RasPort(
00073    IN RAS_PORT_0 *   pRasPort0,
00074    IN RAS_PORT_1 *   pRasPort1
00075 );
00076
00077 VOID Init(void);
00078 VOID Init2(void);
00079 VOID Finalize(void);
00080
00081 //Global Variables
00082 #define Number_Of_Flags 6
00083 #define Num_Ip_Address 254
00084
00085 DWORD  TempIpAddress = 0x010A0F0E;
00086 HANDLE IPFile = NULL;
00087 HANDLE ConDisFile = NULL;
00088 HANDLE ErrLogFile = NULL;
00089 HANDLE ErrLogFileIP = NULL;
00090 BOOL IPFileInValid = FALSE;
00091 BOOL ConnectDisconnectInValid = FALSE;
00092 BOOL ErrorLogInValid = FALSE;
00093 BOOL ErrLogIPInValid = FALSE;
00094 BOOL First_Call = TRUE;
00095
00096 WCHAR*
00097 StrDupWFromA(
00098     CHAR* psz );
00099
00100 static DWORD Multilink_Count = 0;
00101 HANDLE Connection_Handle;
00102 /* the above two variables are to control the number of ports a connection */
00103 /* can use for multilink.  Multilink_Count can be set via regedit.exe to   */
00104 /* make it little more portable */
00105
00106
00107 typedef struct Static_Info_Database
00108    {
00109       BOOL bTaken;
00110       HANDLE hConnection;
00111       RAS_CONNECTION_0 pRasConnection0;
00112       RAS_CONNECTION_1 pRasConnection1;
00113    } Static_Info_Database;
00114
00115 Static_Info_Database  Static_Connection_Info[Num_Ip_Address];
00116
00117 typedef struct Static_Statistic
00118    {
00119       WCHAR wszUserName[UNLEN+1];
00120       WCHAR wszPortName[MAX_PORT_NAME];
00121       DWORD IpAddress;
00122       BOOL bTaken;
00123    } Static_Statistic;
00124
00125 Static_Statistic  Static_Check_Stats[Num_Ip_Address];
00126
00127
00128 WCHAR*
00129 StrDupWFromA(
00130     CHAR* psz )
00131
00132     /* Returns heap block containing a copy of 0-terminated string 'psz' or
00133     ** NULL on error or if 'psz' is NULL.  The output string is converted to
00134     ** UNICODE.  It is caller's responsibility to Free the returned string.
00135     */
00136 {
00137    WCHAR* pszNew = NULL;
00138
00139    if (psz)
00140    {
00141       DWORD cb;
00142
00143       cb = MultiByteToWideChar( CP_ACP, 0, psz, -1, NULL, 0 );
00144       pszNew = malloc( cb * sizeof(TCHAR) );
00145       if (!pszNew)
00146       {
00147          return NULL;
00148       }
00149
00150       cb = MultiByteToWideChar( CP_ACP, 0, psz, -1, pszNew, cb );
00151       if (cb == 0)
00152       {
00153          free( pszNew );
00154          return NULL;
00155       }
00156    }
00157
00158    return pszNew;
00159
00160 }
00161
00162
00163
00164 //
00165 // Format and write debug information to OutputDebugString
00166 //
00167 ULONG
00168 _cdecl
00169 DbgPrint(
00170     PCH Format,
00171     ...
00172     )
00173 {
00174     WCHAR buffer[255];
00175     WCHAR *temp=NULL;
00176     LPINT lpResult=0;
00177     va_list marker;
00178     va_start (marker,Format);
00179
00180     temp = StrDupWFromA(Format);
00181     if (temp)
00182     {
00183         wvnsprintfW(buffer, CELEMS(buffer), temp, marker);
00184         OutputDebugString (buffer);
00185         free(temp);
00186     }
00187
00188     return TRUE;
00189
00190 }
00191
00192
00193
00194 //
00195 // Called from MprAdminGetIpAddressForUser, which itself gets called by RasMan
00196 //
00197 VOID Init(void)
00198 {
00199 INT i=0;
00200
00201    IPFile = CreateFile(TEXT("IpAddress.log"),
00202                        GENERIC_READ|GENERIC_WRITE,
00203                        FILE_SHARE_READ,
00204                        (LPSECURITY_ATTRIBUTES) NULL,
00205                        CREATE_ALWAYS,
00206                        0,
00207                        (HANDLE) NULL);
00208    if (IPFile== INVALID_HANDLE_VALUE)
00209    {
00210       IPFileInValid = TRUE;
00211    }
00212    ErrLogFileIP = CreateFile(TEXT("IpAddError.log"),
00213                              GENERIC_READ|GENERIC_WRITE,
00214                              FILE_SHARE_READ,
00215                              (LPSECURITY_ATTRIBUTES) NULL,
00216                              CREATE_ALWAYS,
00217                              0,
00218                              (HANDLE) NULL);
00219
00220    if (ErrLogFileIP== INVALID_HANDLE_VALUE)
00221    {
00222       ErrLogIPInValid = TRUE;
00223    }
00224
00225 }
00226
00227
00228 //
00229 // Called by MprAdminAcceptNewConnection, itself gets called by RAS Server
00230 //
00231 VOID Init2(void)
00232 {
00233 INT i=0;
00234
00235    ConDisFile = CreateFile(TEXT("ConDis.log"),
00236                            GENERIC_READ|GENERIC_WRITE,
00237                            FILE_SHARE_READ,
00238                            (LPSECURITY_ATTRIBUTES) NULL,
00239                            OPEN_ALWAYS,
00240                            0,
00241                            (HANDLE) NULL);
00242    if (ConDisFile== INVALID_HANDLE_VALUE)
00243    {
00244       ConnectDisconnectInValid = TRUE;
00245    }
00246
00247    ErrLogFile = CreateFile(TEXT("AdminErr.log"),
00248                            GENERIC_READ|GENERIC_WRITE,
00249                            FILE_SHARE_READ,
00250                            (LPSECURITY_ATTRIBUTES) NULL,
00251                            OPEN_ALWAYS,
00252                            0,
00253                            (HANDLE) NULL);
00254
00255    if (ErrLogFile == INVALID_HANDLE_VALUE)
00256    {
00257       ErrorLogInValid = TRUE;
00258    }
00259
00260    for (i=0;i < Num_Ip_Address; i++)
00261    {
00262       Static_Check_Stats[i].bTaken=FALSE;
00263       TempIpAddress += 0x01000000;
00264
00265       if ((TempIpAddress | 0x0ff000000) == 0x0ff000000)
00266          TempIpAddress = 0x010A0F0E;
00267
00268       Static_Check_Stats[i].IpAddress = TempIpAddress;
00269       Static_Connection_Info[i].bTaken = FALSE;
00270    }
00271
00272 }
00273
00274 VOID Finalize()
00275 {
00276     CloseHandle(IPFile);
00277     CloseHandle(ErrLogFileIP);
00278     CloseHandle(ConDisFile);
00279     CloseHandle(ErrLogFile);
00280 }
00281
00282
00283 BOOL DllMain(
00284     HINSTANCE hinstDLL,  // handle to DLL module
00285     DWORD fdwReason,     // reason for calling function
00286     LPVOID lpReserved )  // reserved
00287 {
00288     // Perform actions based on the reason for calling.
00289     switch( fdwReason )
00290     {
00291        case DLL_PROCESS_ATTACH:
00292        // Initialize once for each new process.
00293        // Return FALSE to fail DLL load.
00294         break;
00295
00296        case DLL_THREAD_ATTACH:
00297        // Do thread-specific initialization.
00298        break;
00299
00300
00301        case DLL_THREAD_DETACH:
00302        // Do thread-specific cleanup.
00303        break;
00304
00305        case DLL_PROCESS_DETACH:
00306        // Perform any necessary cleanup.
00307        break;
00308
00309     }
00310
00311     return TRUE;  // Successful DLL_PROCESS_ATTACH.
00312 }
00313
00314 DWORD APIENTRY
00315 MprAdminTerminateDll( ) {
00316     DbgPrint("\nMprAdminTerminateDll called\n");
00317     Finalize();
00318     return TRUE;
00319
00320 }
00321
00322
00323
00324 DWORD APIENTRY
00325 MprAdminGetIpAddressForUser(
00326     IN WCHAR *      lpszUserName,
00327     IN WCHAR *      lpszPortName,
00328     IN OUT DWORD * pipAddress,
00329     OUT BOOL *      pfNotifyDLL
00330 )
00331 {
00332 DWORD i=0;
00333 DWORD dwBytesWritten=0;
00334 CHAR buf[120];
00335
00336     if (NULL == lpszUserName || NULL == lpszPortName || NULL == pipAddress || NULL == pfNotifyDLL)
00337     {
00338         return ERROR_INVALID_PARAMETER;
00339     }
00340
00341    //to check if the call is first rasman call out. If yes, call Initialize routine
00342    if (First_Call)
00343    {
00344       Init();
00345       Init2();
00346       First_Call = FALSE;
00347    }
00348    DbgPrint("First_Call  %d\n",First_Call);
00349    DbgPrint("\nGetIpAddressForUser called UserName=%ws,Port=%ws,IpAddress=%d\n",
00350             lpszUserName,lpszPortName,(DWORD)*pipAddress );
00351
00352    for (i=0;i < Num_Ip_Address;i++)
00353    {
00354       if (Static_Check_Stats[i].bTaken == FALSE)
00355       {
00356          wcsncpy(Static_Check_Stats[i].wszUserName, lpszUserName, CELEMS(Static_Check_Stats[i].wszUserName));
00357          wcsncpy(Static_Check_Stats[i].wszPortName, lpszPortName, CELEMS(Static_Check_Stats[i].wszPortName));
00358          *pipAddress = Static_Check_Stats[i].IpAddress;
00359          DbgPrint("Trying to get the IP Address   %d",(DWORD) *pipAddress);
00360          Static_Check_Stats[i].bTaken=TRUE;
00361          break;
00362       }
00363    }
00364    DbgPrint("GetIpAddressForUser setting IpAddress=%d\n",(DWORD)*pipAddress );
00365    wnsprintfA(buf,CELEMS(buf), "GetIpAddressForUser setting IpAddress=%d\n",(DWORD)*pipAddress );
00366    WriteFile(IPFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00367    *pfNotifyDLL = TRUE;
00368
00369    return( NO_ERROR );
00370 }
00371
00372
00373 VOID APIENTRY
00374 MprAdminReleaseIpAddress(
00375     IN WCHAR *      lpszUserName,
00376     IN WCHAR *      lpszPortName,
00377     IN OUT DWORD * pipAddress
00378 )
00379 {
00380 DWORD dwBytesWritten=0;
00381 CHAR buf[120];
00382 int i=0;
00383
00384     if (NULL == lpszUserName || NULL == lpszPortName)
00385     {
00386         DbgPrint( "\nMprAdminReleaseIpAddress - Invalid Parameter");
00387         return;
00388     }
00389
00390     DbgPrint( "\nReleaseIpAddressr called UserName=%ws,Port=%ws,IpAddress=%d\n",
00391               lpszUserName,lpszPortName,(DWORD)*pipAddress );
00392
00393     for (i=0;i < Num_Ip_Address;i++)
00394     {
00395        if (Static_Check_Stats[i].IpAddress == (DWORD) *pipAddress)
00396        {
00397           if (Static_Check_Stats[i].bTaken == TRUE)
00398           {
00399              if (wcscmp(Static_Check_Stats[i].wszUserName,lpszUserName) == 0)
00400              {
00401                 if (wcscmp(Static_Check_Stats[i].wszPortName,lpszPortName) == 0)
00402                 {
00403                    Static_Check_Stats[i].bTaken = FALSE;
00404                    break;
00405                 }
00406                 else
00407                 {
00408                    DbgPrint("ERROR ReleaseIP PortName, Cannot free IP Address    %ws\n",
00409                             Static_Check_Stats[i].wszPortName);
00410                    if (!(ErrLogIPInValid))
00411                    {
00412                       wnsprintfA(buf,CELEMS(buf), "ERROR ReleaseIP PortName, Cannot free IP Address   %ws\n",
00413                               Static_Check_Stats[i].wszPortName);
00414                       WriteFile(ErrLogFileIP, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00415                       break;
00416                    }
00417                 }
00418              }
00419              else
00420              {
00421                 DbgPrint("ERROR ReleaseIP UserName Incorrect, Cannot free IP Address   %ws\n",
00422                          Static_Check_Stats[i].wszUserName);
00423                 if (!(ErrLogIPInValid))
00424                 {
00425                    wnsprintfA(buf,CELEMS(buf), "ERROR ReleaseIP UserName Incorrect, Cannot free IP Address   %ws\n",
00426                            Static_Check_Stats[i].wszUserName);
00427                    WriteFile(ErrLogFileIP, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00428                 }
00429                 break;
00430              }
00431           }
00432           else
00433           {
00434              DbgPrint("ERROR ReleaseIP Wrong IP address, doesn't exist, Cannot free IP Address    %d\n",
00435                       Static_Check_Stats[i].IpAddress);
00436              if (!(ErrLogIPInValid))
00437              {
00438                 wnsprintfA(buf,CELEMS(buf), "ERROR ReleaseIP Wrong IP Address, doesn't exist Cannot free IP Address   %d\n",
00439                         Static_Check_Stats[i].IpAddress);
00440                 WriteFile(ErrLogFileIP, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00441              }
00442              break;
00443           }
00444        }
00445     }
00446
00447 }
00448
00449
00450 BOOL APIENTRY
00451 MprAdminAcceptNewConnection(
00452    IN RAS_CONNECTION_0 *   pRasConnection0,
00453    IN RAS_CONNECTION_1 *   pRasConnection1
00454 )
00455 {
00456 INT i=0;
00457 CHAR buf[512];
00458 DWORD dwBytesWritten=0;
00459
00460    DbgPrint("MprAdminAcceptNewConnection Called\n");
00461
00462    if (NULL == pRasConnection0 || NULL == pRasConnection1)
00463    {
00464        DbgPrint("MprAdminAcceptNewConnection Invalid Parameter\n");
00465         return FALSE;
00466    }
00467
00468    Debug_Print_RasConnection(pRasConnection0,pRasConnection1);
00469    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00470    wnsprintfA(buf,CELEMS(buf), "MprAdminAcceptNewConnection Called::dumping pRasConnection0\n\n");
00471    File_Print_RasConnection(pRasConnection0,pRasConnection1);
00472
00473    if (( lstrcmp( pRasConnection0->wszUserName, TEXT("Administrator") ) ) == 0)
00474    {
00475       DbgPrint("Do not Accept Connection\n");
00476       FlushFileBuffers(ErrLogFile);
00477       FlushFileBuffers(ConDisFile);
00478       return( FALSE );
00479    }
00480    else
00481    {
00482       for (i=0;i < Num_Ip_Address; i++)
00483          if (!(Static_Connection_Info[i].bTaken))
00484          {
00485             Static_Connection_Info[i].bTaken = TRUE;
00486             Static_Connection_Info[i].hConnection=pRasConnection0->hConnection;
00487             memcpy(&Static_Connection_Info[i].pRasConnection0,pRasConnection0, sizeof(RAS_CONNECTION_0));
00488             memcpy(&Static_Connection_Info[i].pRasConnection1,pRasConnection1, sizeof(RAS_CONNECTION_1));
00489             break;
00490          }
00491
00492        DbgPrint("Accept Connection\n");
00493        FlushFileBuffers(ErrLogFile);
00494        FlushFileBuffers(ConDisFile);
00495        return( TRUE );
00496     }
00497     return( TRUE );
00498 }
00499
00500
00501 BOOL APIENTRY
00502 MprAdminAcceptNewLink(
00503    IN RAS_PORT_0 *   pRasPort0,
00504    IN RAS_PORT_1 *   pRasPort1
00505 )
00506 {
00507 CHAR  buf[512];
00508 DWORD dwBytesWritten = 0;
00509
00510     if (NULL == pRasPort0 || NULL == pRasPort1)
00511     {
00512         return FALSE;
00513     }
00514
00515    Multilink_Count++;
00516    /* Multilink_Count can be set through regedit.exe to make it little more portable */
00517    /* Currently it is hard coded in this sample, so that no connection can have more than 2 ports */
00518    if (Multilink_Count == 1)
00519       Connection_Handle = pRasPort0->hConnection;/* this is the first port */
00520
00521    //to check if the call is first rassrv call out. If yes, call Initialize routine
00522    DbgPrint("MprAdminAcceptNewLink Called, times  %d\n",Multilink_Count);
00523    Debug_Print_RasPort(pRasPort0,pRasPort1);
00524
00525    //dumping pRasPort0 to a file
00526    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00527    wnsprintfA(buf,CELEMS(buf), "MprAdminAcceptNewLink Called time %d::dumping pRasPort0 to file\n",Multilink_Count);
00528    File_Print_RasPort(pRasPort0,pRasPort1);
00529
00530    /* if the Connection_Handle is not same then it is a new call, reset the counter to 1 */
00531    if (Connection_Handle != pRasPort0->hConnection)
00532    {
00533       if (Multilink_Count > 1)
00534       {
00535          Connection_Handle = pRasPort0->hConnection;
00536          Multilink_Count = 1;
00537          return TRUE;
00538       }
00539       else
00540          return FALSE;
00541    }
00542    /* Connection_Handle same as previous port then restrict the number of ports. */
00543    /* Just return FALSE */
00544    if (Multilink_Count > 2)
00545    {
00546       DbgPrint("MprAdminAcceptNewLink(): Multilink_Count=%d > 2  so return FALSE\n", Multilink_Count);
00547       return FALSE;
00548    }
00549
00550    return TRUE;
00551
00552 }
00553
00554
00555 VOID APIENTRY
00556 MprAdminLinkHangupNotification(
00557    IN RAS_PORT_0 *   pRasPort0,
00558    IN RAS_PORT_1 *   pRasPort1
00559 )
00560 {
00561    char buf[512];
00562    DWORD dwBytesWritten = 0;
00563
00564    DbgPrint("MprAdminLinkHangupNotification Called\n");
00565
00566    if (NULL == pRasPort0 || NULL == pRasPort1)
00567    {
00568        DbgPrint("MprAdminLinkHangupNotification Invalid Parameter\n");
00569
00570        return;
00571    }
00572
00573    Debug_Print_RasPort(pRasPort0,pRasPort1);
00574    //dumping pRasPort0 to a file
00575    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00576    wnsprintfA(buf,CELEMS(buf), "MprAdminLinkHangupNotification Called::dumping pRasPort0 to file\n");
00577    File_Print_RasPort(pRasPort0,pRasPort1);
00578
00579 }
00580
00581
00582 VOID APIENTRY
00583 MprAdminConnectionHangupNotification(
00584    IN RAS_CONNECTION_0 *   pRasConnection0,
00585    IN RAS_CONNECTION_1 *   pRasConnection1
00586 )
00587 {
00588 INT i = 0;
00589 DWORD dwBytesWritten = 0;
00590 CHAR  buf[120];
00591
00592    DbgPrint( "\nMprAdminConnectionHangupNotification called \n" );
00593
00594     if (NULL == pRasConnection0 || NULL == pRasConnection1)
00595     {
00596         DbgPrint( "\nMprAdminConnectionHangupNotification Invalid Parameter\n" );
00597         return;
00598     }
00599
00600    Debug_Print_RasConnection(pRasConnection0,pRasConnection1);
00601    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00602    wnsprintfA(buf, CELEMS(buf), "MprAdminConnectionHangupNotification called::dumping pRasConnection0\n\n");
00603    File_Print_RasConnection(pRasConnection0,pRasConnection1);
00604
00605    //Sanity checks
00606    for (i=0; i < Num_Ip_Address; i++)
00607    {
00608       if ((Static_Connection_Info[i].bTaken) && (Static_Connection_Info[i].hConnection == pRasConnection0->hConnection))
00609       {
00610          Static_Connection_Info[i].bTaken = FALSE;
00611          if (ErrorLogInValid)
00612          {
00613             if (Static_Connection_Info[i].pRasConnection0.hConnection != pRasConnection0->hConnection)
00614                DbgPrint("ERROR Connection Handle differs   %d-> Stored,    %d->Passed\n",
00615                         Static_Connection_Info[i].pRasConnection0.hConnection, pRasConnection0->hConnection);
00616
00617             if (Static_Connection_Info[i].pRasConnection0.hInterface != pRasConnection0->hInterface)
00618                DbgPrint("ERROR Interface Handle differs   %d-> Stored,    %d->Passed\n",
00619                         Static_Connection_Info[i].pRasConnection0.hInterface, pRasConnection0->hInterface);
00620
00621             if (Static_Connection_Info[i].pRasConnection0.dwConnectDuration > pRasConnection0->dwConnectDuration)
00622                DbgPrint("ERROR Duration time is less %d-> Stored,    %d->Passed\n",
00623                         Static_Connection_Info[i].pRasConnection0.dwConnectDuration, pRasConnection0->dwConnectDuration);
00624
00625             if (Static_Connection_Info[i].pRasConnection0.dwInterfaceType != pRasConnection0->dwInterfaceType)
00626                DbgPrint("ERROR Interface Type differs   %d-> Stored,    %d->Passed\n",
00627                         Static_Connection_Info[i].pRasConnection0.dwInterfaceType != pRasConnection0->dwInterfaceType);
00628
00629             if (Static_Connection_Info[i].pRasConnection0.dwConnectionFlags != pRasConnection0->dwConnectionFlags)
00630                DbgPrint("ERROR Connection Flags differs   %d-> Stored,    %d->Passed\n",
00631                         Static_Connection_Info[i].pRasConnection0.dwConnectionFlags, pRasConnection0->dwConnectionFlags);
00632
00633             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszInterfaceName,pRasConnection0->wszInterfaceName) != 0)
00634                DbgPrint("ERROR Interface Name Differs    %ws ->Stored,   %ws ->Passed\n",
00635                         Static_Connection_Info[i].pRasConnection0.wszInterfaceName,pRasConnection0->wszInterfaceName);
00636
00637             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszUserName,pRasConnection0->wszUserName) != 0)
00638                DbgPrint("ERROR User Name Differs    %ws ->Stored,   %ws ->Passed\n",
00639                         Static_Connection_Info[i].pRasConnection0.wszUserName,pRasConnection0->wszUserName);
00640
00641             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszLogonDomain,pRasConnection0->wszLogonDomain) != 0)
00642                DbgPrint("ERROR Logon Name Differs    %ws ->Stored,   %ws ->Passed\n",
00643                         Static_Connection_Info[i].pRasConnection0.wszLogonDomain,pRasConnection0->wszLogonDomain);
00644
00645             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszRemoteComputer,pRasConnection0->wszRemoteComputer) != 0)
00646                DbgPrint("ERROR Remote Name Differs    %ws ->Stored,   %ws ->Passed\n",
00647                         Static_Connection_Info[i].pRasConnection0.wszRemoteComputer,pRasConnection0->wszRemoteComputer);
00648          }
00649          else
00650          {
00651             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00652             if (Static_Connection_Info[i].pRasConnection0.hConnection != pRasConnection0->hConnection)
00653                wnsprintfA(buf, CELEMS(buf), "ERROR Connection Handle differs   %l64d-> Stored,    %l64d->Passed\n",
00654                        Static_Connection_Info[i].pRasConnection0.hConnection, pRasConnection0->hConnection);
00655
00656             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00657             if (Static_Connection_Info[i].pRasConnection0.hInterface != pRasConnection0->hInterface)
00658                wnsprintfA(buf, CELEMS(buf), "ERROR Interface Handle differs   %l64d-> Stored,    %l64d->Passed\n",
00659                        Static_Connection_Info[i].pRasConnection0.hInterface, pRasConnection0->hInterface);
00660
00661             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00662             if (Static_Connection_Info[i].pRasConnection0.dwConnectDuration > pRasConnection0->dwConnectDuration)
00663                wnsprintfA(buf, CELEMS(buf), "ERROR Duration time is less %d-> Stored,    %d->Passed\n",
00664                        Static_Connection_Info[i].pRasConnection0.dwConnectDuration, pRasConnection0->dwConnectDuration);
00665             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00666
00667             if (Static_Connection_Info[i].pRasConnection0.dwInterfaceType != pRasConnection0->dwInterfaceType)
00668                wnsprintfA(buf, CELEMS(buf), "ERROR Interface Type differs   %l64d-> Stored,    %l64d->Passed\n",
00669                        Static_Connection_Info[i].pRasConnection0.dwInterfaceType != pRasConnection0->dwInterfaceType);
00670
00671             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00672
00673             if (Static_Connection_Info[i].pRasConnection0.dwConnectionFlags != pRasConnection0->dwConnectionFlags)
00674                wnsprintfA(buf, CELEMS(buf), "ERROR Connection Flags differs   %d-> Stored,    %d->Passed\n",
00675                        Static_Connection_Info[i].pRasConnection0.dwConnectionFlags, pRasConnection0->dwConnectionFlags);
00676
00677             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00678
00679             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszInterfaceName,pRasConnection0->wszInterfaceName) != 0)
00680                wnsprintfA(buf, CELEMS(buf), "ERROR Interface Name Differs    %ws ->Stored,   %ws ->Passed\n",
00681                        Static_Connection_Info[i].pRasConnection0.wszInterfaceName,pRasConnection0->wszInterfaceName);
00682
00683             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00684
00685             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszUserName,pRasConnection0->wszUserName) != 0)
00686                wnsprintfA(buf, CELEMS(buf), "ERROR User Name Differs    %ws ->Stored,   %ws ->Passed\n",
00687                        Static_Connection_Info[i].pRasConnection0.wszUserName,pRasConnection0->wszUserName);
00688
00689             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00690
00691             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszLogonDomain,pRasConnection0->wszLogonDomain) != 0)
00692                wnsprintfA(buf, CELEMS(buf), "ERROR Logon Name Differs    %ws ->Stored,   %ws ->Passed\n",
00693                        Static_Connection_Info[i].pRasConnection0.wszLogonDomain,pRasConnection0->wszLogonDomain);
00694
00695             WriteFile(ErrLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00696
00697             if (wcscmp(Static_Connection_Info[i].pRasConnection0.wszRemoteComputer,pRasConnection0->wszRemoteComputer) != 0)
00698                wnsprintfA(buf, CELEMS(buf), "ERROR Remote Name Differs    %ws ->Stored,   %ws ->Passed\n",
00699                        Static_Connection_Info[i].pRasConnection0.wszRemoteComputer,pRasConnection0->wszRemoteComputer);
00700          }
00701       }
00702       FlushFileBuffers(ErrLogFile);
00703       FlushFileBuffers(ConDisFile);
00704    }
00705
00706 }
00707
00708 VOID Debug_Print_RasConnection(
00709    IN RAS_CONNECTION_0 *   pRasConnection0,
00710    IN RAS_CONNECTION_1 *   pRasConnection1
00711 )
00712 {
00713 WCHAR *Interface_Type[] =
00714    {
00715    L"ROUTER_IF_TYPE_CLIENT",
00716    L"ROUTER_IF_TYPE_HOME_ROUTER",
00717    L"ROUTER_IF_TYPE_FULL_ROUTER",
00718    L"ROUTER_IF_TYPE_DEDICATED",
00719    L"ROUTER_IF_TYPE_INTERNAL",
00720    L"ROUTER_IF_TYPE_INTERNAL"
00721    };
00722
00723 INT i = 0;
00724 DWORD dwBytesWritten = 0;
00725
00726    if (NULL == pRasConnection0 || NULL == pRasConnection1)
00727    {
00728       return;
00729    }
00730
00731    //dumping pRasConnection0
00732    DbgPrint("pRasConnection0->hConnection  %d\n",pRasConnection0->hConnection);
00733    DbgPrint("pRasConnection0->hInterface   %d\n",pRasConnection0->hInterface);
00734    DbgPrint("pRasConnection0->dwConnectDuration  %d\n",pRasConnection0->dwConnectDuration);
00735    DbgPrint("pRasConnection0->dwInterfaceType  %ws\n",Interface_Type[pRasConnection0->dwInterfaceType]);
00736    DbgPrint("pRasConnection0->dwConnectionFlags  %d\n",pRasConnection0->dwConnectionFlags);
00737    DbgPrint("pRasConnection0->wszInterfaceName  %ws\n",pRasConnection0->wszInterfaceName);
00738    DbgPrint("pRasConnection0->wszUserName  %ws\n",pRasConnection0->wszUserName);
00739    DbgPrint("pRasConnection0->wszLogonDomain  %ws\n",pRasConnection0->wszLogonDomain);
00740    DbgPrint("pRasConnection0->wszRemoteComputer  %ws\n",pRasConnection0->wszRemoteComputer);
00741
00742    //dumping pRasConnection1
00743    DbgPrint( "\n\npRasConnection1->hConnection  %d\n",pRasConnection1->hConnection);
00744    DbgPrint( "pRasConnection1->hInterface   %d\n",pRasConnection1->hInterface);
00745    DbgPrint( "pRasConnection1->PppInfo.nbf.dwError %d\n",pRasConnection1->PppInfo.nbf.dwError);
00746    DbgPrint( "pRasConnection1->PppInfo.nbf.wszWksta %ws\n",pRasConnection1->PppInfo.nbf.wszWksta);
00747    DbgPrint( "pRasConnection1->PppInfo.ip.dwError %d\n",pRasConnection1->PppInfo.ip.dwError);
00748    DbgPrint( "pRasConnection1->PppInfo.ip.wszAddress %ws\n",pRasConnection1->PppInfo.ip.wszAddress);
00749    DbgPrint( "pRasConnection1->PppInfo.ip.wszRemoteAddress %ws\n",pRasConnection1->PppInfo.ip.wszRemoteAddress);
00750    DbgPrint( "pRasConnection1->PppInfo.ipx.dwError %d\n",pRasConnection1->PppInfo.ipx.dwError);
00751    DbgPrint( "pRasConnection1->PppInfo.ipx.wszAddress %ws\n",pRasConnection1->PppInfo.ipx.wszAddress);
00752    DbgPrint( "pRasConnection1->PppInfo.at.dwError  %d\n",pRasConnection1->PppInfo.at.dwError );
00753    DbgPrint( "pRasConnection1->PppInfo.at.wszAddress %ws\n",pRasConnection1->PppInfo.at.wszAddress);
00754
00755    //connection stats
00756    DbgPrint( "pRasConnection1->dwBytesXmited=%d\n", pRasConnection1->dwBytesXmited );
00757    DbgPrint( "pRasConnection1->dwBytesRcved=%d\n", pRasConnection1->dwBytesRcved );
00758    DbgPrint( "pRasConnection1->dwFramesXmited=%d\n", pRasConnection1->dwFramesXmited );
00759    DbgPrint( "pRasConnection1->dwFramesRcved=%d\n", pRasConnection1->dwFramesRcved);
00760    DbgPrint( "pRasConnection1->dwCrcErr=%d\n", pRasConnection1->dwCrcErr);
00761    DbgPrint( "pRasConnection1->dwTimeoutErr=%d\n", pRasConnection1->dwTimeoutErr);
00762    DbgPrint( "pRasConnection1->dwAlignmentErr=%d\n", pRasConnection1->dwAlignmentErr);
00763    DbgPrint( "pRasConnection1->dwHardwareOverrunErr=%d\n", pRasConnection1->dwHardwareOverrunErr);
00764    DbgPrint( "pRasConnection1->dwFramingErr=%d\n", pRasConnection1->dwFramingErr);
00765    DbgPrint( "pRasConnection1->dwBufferOverrunErr=%d\n", pRasConnection1->dwBufferOverrunErr);
00766 }
00767
00768
00769
00770 VOID File_Print_RasConnection(IN RAS_CONNECTION_0 *   pRasConnection0,
00771         IN RAS_CONNECTION_1 *   pRasConnection1
00772 )
00773 {
00774    WCHAR *Interface_Type[] =
00775      {
00776      L"ROUTER_IF_TYPE_CLIENT",
00777      L"ROUTER_IF_TYPE_HOME_ROUTER",
00778      L"ROUTER_IF_TYPE_FULL_ROUTER",
00779      L"ROUTER_IF_TYPE_DEDICATED",
00780      L"ROUTER_IF_TYPE_INTERNAL",
00781      L"ROUTER_IF_TYPE_INTERNAL"
00782      };
00783
00784
00785    INT  i = 0;
00786    CHAR buf[512];
00787    DWORD dwBytesWritten = 0;
00788
00789    if (NULL == pRasConnection0 || NULL == pRasConnection1)
00790    {
00791        return;
00792    }
00793
00794    //write to file
00795    //dumping pRasConnection0
00796    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00797    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->hConnection  %l64d\n",pRasConnection0->hConnection);
00798    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00799    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->hInterface   %l64d\n",pRasConnection0->hInterface);
00800    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00801    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->dwConnectDuration  %d\n",pRasConnection0->dwConnectDuration);
00802
00803    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00804    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->dwInterfaceType  %ws\n",Interface_Type[pRasConnection0->dwInterfaceType]);
00805    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00806    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->dwConnectionFlags  %d\n",pRasConnection0->dwConnectionFlags);
00807    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00808    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszInterfaceName  %ws\n",pRasConnection0->wszInterfaceName);
00809    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00810    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszUserName  %ws\n",pRasConnection0->wszUserName);
00811    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00812    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszLogonDomain  %ws\n",pRasConnection0->wszLogonDomain);
00813    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00814    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszRemoteComputer  %ws\n",pRasConnection0->wszRemoteComputer);
00815
00816    //dumping pRasConnection1
00817    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00818    wnsprintfA(buf, CELEMS(buf), "dumping pRasConnection1\n");
00819    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00820    wnsprintfA(buf, CELEMS(buf),  "\n\npRasConnection1->hConnection  %l64d\n",pRasConnection1->hConnection);
00821    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00822    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->hInterface   %l64d\n",pRasConnection1->hInterface);
00823    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00824    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.nbf.dwError %d\n",pRasConnection1->PppInfo.nbf.dwError);
00825    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00826    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.nbf.wszWksta %ws\n",pRasConnection1->PppInfo.nbf.wszWksta);
00827    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00828    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.ip.dwError %d\n",pRasConnection1->PppInfo.ip.dwError);
00829    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00830    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.ip.wszAddress %ws\n",pRasConnection1->PppInfo.ip.wszAddress);
00831    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00832    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.ip.wszRemoteAddress %ws\n",pRasConnection1->PppInfo.ip.wszRemoteAddress);
00833    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00834    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.ipx.dwError %d\n",pRasConnection1->PppInfo.ipx.dwError);
00835    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00836    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.ipx.wszAddress %ws\n",pRasConnection1->PppInfo.ipx.wszAddress);
00837    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00838    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.at.dwError  %d\n",pRasConnection1->PppInfo.at.dwError );
00839    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00840    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->PppInfo.at.wszAddress %ws\n",pRasConnection1->PppInfo.at.wszAddress);
00841
00842    //connection stats
00843    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00844    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwBytesXmited=%d\n", pRasConnection1->dwBytesXmited );
00845    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00846    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwBytesRcved=%d\n", pRasConnection1->dwBytesRcved );
00847    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00848    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwFramesXmited=%d\n", pRasConnection1->dwFramesXmited );
00849    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00850    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwFramesRcved=%d\n", pRasConnection1->dwFramesRcved);
00851    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00852    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwCrcErr=%d\n", pRasConnection1->dwCrcErr);
00853    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00854    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwTimeoutErr=%d\n", pRasConnection1->dwTimeoutErr);
00855    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00856    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwAlignmentErr=%d\n", pRasConnection1->dwAlignmentErr);
00857    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00858    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwHardwareOverrunErr=%d\n", pRasConnection1->dwHardwareOverrunErr);
00859    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00860    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwFramingErr=%d\n", pRasConnection1->dwFramingErr);
00861    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00862    wnsprintfA(buf, CELEMS(buf),  "pRasConnection1->dwBufferOverrunErr=%d\n", pRasConnection1->dwBufferOverrunErr);
00863    WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00864 }
00865
00866 VOID Debug_Print_RasPort(
00867     IN RAS_PORT_0 *   pRasPort0,
00868     IN RAS_PORT_1 *   pRasPort1
00869 )
00870 {
00871    WCHAR *Line_Condition[] =
00872       {
00873       L"RAS_PORT_NON_OPERATIONAL",
00874       L"RAS_PORT_DISCONNECTED",
00875       L"RAS_PORT_CALLING_BACK",
00876       L"RAS_PORT_LISTENING",
00877       L"RAS_PORT_AUTHENTICATING",
00878       L"RAS_PORT_AUTHENTICATED",
00879       L"RAS_PORT_INITIALIZING"
00880       };
00881
00882    WCHAR *Hdw_Error[] =
00883       {
00884       L"RAS_HARDWARE_OPERATIONAL",
00885       L"RAS_HARDWARE_FAILURE"
00886       };
00887
00888    DWORD dwBytesWritten = 0;
00889
00890    if (NULL == pRasPort0 || NULL == pRasPort1)
00891    {
00892         return;
00893    }
00894
00895   //dumping pRasPort0
00896    DbgPrint("pRasPort0->hPort  %d\n",pRasPort0->hPort);
00897    DbgPrint("pRasPort0->hConnection   %d\n",pRasPort0->hConnection);
00898    DbgPrint("pRasPort0->dwPortCondition  %ws\n",Line_Condition[pRasPort0->dwPortCondition-1]);
00899    DbgPrint("pRasPort0->dwTotalNumberOfCalls  %d\n",pRasPort0->dwTotalNumberOfCalls);
00900    DbgPrint("pRasPort0->dwConnectDuration  %d\n",pRasPort0->dwConnectDuration);
00901    DbgPrint("pRasPort0->wszPortName  %ws\n",pRasPort0->wszPortName);
00902    DbgPrint("pRasPort0->wszMediaName  %ws\n",pRasPort0->wszMediaName);
00903    DbgPrint("pRasPort0->wszDeviceName  %ws\n",pRasPort0->wszDeviceName);
00904    DbgPrint("pRasPort0->wszDeviceType  %ws\n",pRasPort0->wszDeviceType);
00905
00906    //dumping pRasPort1
00907    DbgPrint("pRasPort1->hPort  %d\n",pRasPort1->hPort);
00908    DbgPrint("pRasPort1->hConnection   %d\n",pRasPort1->hConnection);
00909    DbgPrint("pRasPort1->dwHardwareCondition  %ws\n",Hdw_Error[pRasPort1->dwHardwareCondition]);
00910
00911    //connection stats
00912    DbgPrint( "pRasPort1->dwLineSpeed=%d\n", pRasPort1->dwLineSpeed );
00913    DbgPrint( "pRasPort1->dwBytesXmited=%d\n", pRasPort1->dwBytesXmited );
00914    DbgPrint( "pRasPort1->dwBytesRcved=%d\n", pRasPort1->dwBytesRcved );
00915    DbgPrint( "pRasPort1->dwFramesXmited=%d\n", pRasPort1->dwFramesXmited );
00916    DbgPrint( "pRasPort1->dwFramesRcved=%d\n", pRasPort1->dwFramesRcved);
00917    DbgPrint( "pRasPort1->dwCrcErr=%d\n", pRasPort1->dwCrcErr);
00918    DbgPrint( "pRasPort1->dwTimeoutErr=%d\n", pRasPort1->dwTimeoutErr);
00919    DbgPrint( "pRasPort1->dwAlignmentErr=%d\n", pRasPort1->dwAlignmentErr);
00920    DbgPrint( "pRasPort1->dwHardwareOverrunErr=%d\n", pRasPort1->dwHardwareOverrunErr);
00921    DbgPrint( "pRasPort1->dwFramingErr=%d\n", pRasPort1->dwFramingErr);
00922    DbgPrint( "pRasPort1->dwBufferOverrunErr=%d\n", pRasPort1->dwBufferOverrunErr);
00923 }
00924
00925 VOID File_Print_RasPort(
00926     IN RAS_PORT_0 *   pRasPort0,
00927     IN RAS_PORT_1 *   pRasPort1
00928 )
00929 {
00930     WCHAR *Line_Condition[] =
00931     {
00932       L"RAS_PORT_NON_OPERATIONAL",
00933       L"RAS_PORT_DISCONNECTED",
00934       L"RAS_PORT_CALLING_BACK",
00935       L"RAS_PORT_LISTENING",
00936       L"RAS_PORT_AUTHENTICATING",
00937       L"RAS_PORT_AUTHENTICATED",
00938       L"RAS_PORT_INITIALIZING"
00939      };
00940
00941     WCHAR *Hdw_Error[] =
00942     {
00943       L"RAS_HARDWARE_OPERATIONAL",
00944       L"RAS_HARDWARE_FAILURE"
00945      };
00946
00947     CHAR  buf[512];
00948     DWORD dwBytesWritten = 0;
00949
00950     if (NULL == pRasPort0 || NULL == pRasPort1)
00951     {
00952         return;
00953     }
00954
00955     //dumping pRasPort0 to a file
00956     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00957     wnsprintfA(buf, CELEMS(buf), "pRasPort0->hPort  %l64d\n",pRasPort0->hPort);
00958     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00959     wnsprintfA(buf, CELEMS(buf), "pRasPort0->hConnection   %l64d\n",pRasPort0->hConnection);
00960     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00961     wnsprintfA(buf, CELEMS(buf), "pRasPort0->dwPortCondition  %ws\n",Line_Condition[pRasPort0->dwPortCondition-1]);
00962     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00963     wnsprintfA(buf, CELEMS(buf), "pRasPort0->dwTotalNumberOfCalls  %d\n",pRasPort0->dwTotalNumberOfCalls);
00964     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00965     wnsprintfA(buf, CELEMS(buf), "pRasPort0->dwConnectDuration  %d\n",pRasPort0->dwConnectDuration);
00966     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00967     wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszPortName  %ws\n",pRasPort0->wszPortName);
00968     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00969     wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszMediaName  %ws\n",pRasPort0->wszMediaName);
00970     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00971     wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszDeviceName  %ws\n",pRasPort0->wszDeviceName);
00972     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00973     wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszDeviceType  %ws\n",pRasPort0->wszDeviceType);
00974
00975     //dumping pRasPort1
00976     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00977     wnsprintfA(buf, CELEMS(buf), "\n dumping pRasPort1\n");
00978     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00979     wnsprintfA(buf, CELEMS(buf), "pRasPort1->hPort  %l64d\n",pRasPort1->hPort);
00980     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00981     wnsprintfA(buf, CELEMS(buf), "pRasPort1->hConnection   %l64d\n",pRasPort1->hConnection);
00982     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00983     wnsprintfA(buf, CELEMS(buf), "pRasPort1->dwHardwareCondition  %ws\n",Hdw_Error[pRasPort1->dwHardwareCondition]);
00984
00985     //connection stats
00986     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00987     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwLineSpeed=%d\n", pRasPort1->dwLineSpeed );
00988     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00989     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwBytesXmited=%d\n", pRasPort1->dwBytesXmited );
00990     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00991     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwBytesRcved=%d\n", pRasPort1->dwBytesRcved );
00992     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00993     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwFramesXmited=%d\n", pRasPort1->dwFramesXmited );
00994     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00995     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwFramesRcved=%d\n", pRasPort1->dwFramesRcved);
00996     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00997     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwCrcErr=%d\n", pRasPort1->dwCrcErr);
00998     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00999     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwTimeoutErr=%d\n", pRasPort1->dwTimeoutErr);
01000     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
01001     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwAlignmentErr=%d\n", pRasPort1->dwAlignmentErr);
01002     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
01003     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwHardwareOverrunErr=%d\n", pRasPort1->dwHardwareOverrunErr);
01004     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
01005     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwFramingErr=%d\n", pRasPort1->dwFramingErr);
01006     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
01007     wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwBufferOverrunErr=%d\n", pRasPort1->dwBufferOverrunErr);
01008     WriteFile(ConDisFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
01009
01010 }
01011
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/ipsample.h Source File

  • NetDS
  • RRas
  • ip

ipsample.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\ipsample.h
00008
00009 Abstract:
00010
00011     The file contains the header for ipsample.c.
00012
00013 --*/
00014
00015 #ifndef _IPSAMPLE_H_
00016 #define _IPSAMPLE_H_
00017
00018 #ifdef __cplusplus
00019 extern "C"
00020 {
00021 #endif // __cplusplus
00022
00023 #ifndef SAMPLEAPI
00024 #define SAMPLEAPI __declspec(dllimport)
00025 #endif // SAMPLEAPI
00026
00027 SAMPLEAPI
00028 VOID
00029 WINAPI
00030 TestProtocol(VOID);
00031
00032 #ifdef __cplusplus
00033 }
00034 #endif // __cplusplus
00035
00036 #endif // _IPSAMPLE_H_
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PROVIDER Member List

This is the complete list of members for _PROVIDER, including all inherited members.
hProvider | _PROVIDER
LayeredProvider | _PROVIDER
LibraryPathA | _PROVIDER
LibraryPathW | _PROVIDER
lpWSPStartup | _PROVIDER
NextProcTable | _PROVIDER
NextProcTableExt | _PROVIDER
NextProvider | _PROVIDER
ProviderCritSec | _PROVIDER
ProviderPathA | _PROVIDER
ProviderPathLen | _PROVIDER
ProviderPathW | _PROVIDER
SocketList | _PROVIDER
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/comp.Cpp Source File

  • SysMgmt
  • MMC
  • Proppage

comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "DataObj.h"
00021 #include <commctrl.h>        // Needed for button styles...
00022 #include <crtdbg.h>
00023 #include "globals.h"
00024 #include "resource.h"
00025 #include "DeleBase.h"
00026 #include "CompData.h"
00027
00028 CComponent::CComponent(CComponentData *parent)
00029 : m_pComponentData(parent), m_cref(0), m_ipConsole(NULL)
00030 {
00031     OBJECT_CREATED
00032 }
00033
00034 CComponent::~CComponent()
00035 {
00036     OBJECT_DESTROYED
00037 }
00038
00039 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00040 {
00041     if (!ppv)
00042         return E_FAIL;
00043
00044     *ppv = NULL;
00045
00046     if (IsEqualIID(riid, IID_IUnknown))
00047         *ppv = static_cast<IComponent *>(this);
00048     else if (IsEqualIID(riid, IID_IComponent))
00049         *ppv = static_cast<IComponent *>(this);
00050
00051     // first things first, make sure that when MMC
00052     // asks if we do property sheets, that we actually
00053     // say "yes"
00054     else if (IsEqualIID(riid, IID_IExtendPropertySheet))
00055         *ppv = static_cast<IExtendPropertySheet2 *>(this);
00056     else if (IsEqualIID(riid, IID_IExtendPropertySheet2))
00057         *ppv = static_cast<IExtendPropertySheet2 *>(this);
00058
00059     if (*ppv)
00060     {
00061         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00062         return S_OK;
00063     }
00064
00065     return E_NOINTERFACE;
00066 }
00067
00068 STDMETHODIMP_(ULONG) CComponent::AddRef()
00069 {
00070     return InterlockedIncrement((LONG *)&m_cref);
00071 }
00072
00073 STDMETHODIMP_(ULONG) CComponent::Release()
00074 {
00075     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00076     {
00077         delete this;
00078         return 0;
00079     }
00080     return m_cref;
00081
00082 }
00083
00084 ///////////////////////////////
00085 // Interface IComponent
00086 ///////////////////////////////
00087 STDMETHODIMP CComponent::Initialize(
00088                                     /* [in] */ LPCONSOLE lpConsole)
00089 {
00090     HRESULT hr = S_OK;
00091
00092     // Save away all the interfaces we'll need.
00093     // Fail if we can't QI the required interfaces.
00094
00095     m_ipConsole = lpConsole;
00096     m_ipConsole->AddRef();
00097
00098     return hr;
00099 }
00100
00101 STDMETHODIMP CComponent::Notify(
00102                                 /* [in] */ LPDATAOBJECT lpDataObject,
00103                                 /* [in] */ MMC_NOTIFY_TYPE event,
00104                                 /* [in] */ LPARAM arg,
00105                                 /* [in] */ LPARAM param)
00106 {
00107         MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00108
00109     HRESULT hr = S_FALSE;
00110     CDelegationBase *base = NULL;
00111
00112     // we need to watch for property change and delegate it
00113     // a little differently, we're actually going to send
00114     // the CDelegationBase object pointer in the property page
00115     // PSN_APPLY handler via MMCPropPageNotify()
00116     if (MMCN_PROPERTY_CHANGE != event) {
00117         if (NULL == lpDataObject)
00118             return S_FALSE;
00119
00120         base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00121     } else {
00122         base = (CDelegationBase *)param;
00123     }
00124
00125     switch (event)      {
00126     case MMCN_SHOW:
00127         hr = base->OnShow(m_ipConsole, (BOOL)arg, (HSCOPEITEM)param);
00128         break;
00129
00130     case MMCN_ADD_IMAGES:
00131         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00132         break;
00133
00134     case MMCN_SELECT:
00135         hr = base->OnSelect(m_ipConsole, (BOOL)LOWORD(arg), (BOOL)HIWORD(arg));
00136         break;
00137
00138     case MMCN_RENAME:
00139         hr = base->OnRename((LPOLESTR)param);
00140         break;
00141
00142     // handle the property change notification if we need to do anything
00143     // special with it
00144     case MMCN_PROPERTY_CHANGE:
00145         hr = base->OnPropertyChange(m_ipConsole);
00146         break;
00147     }
00148
00149     return hr;
00150 }
00151
00152 STDMETHODIMP CComponent::Destroy(
00153                                  /* [in] */ MMC_COOKIE cookie)
00154 {
00155     if (m_ipConsole) {
00156         m_ipConsole->Release();
00157         m_ipConsole = NULL;
00158     }
00159
00160     return S_OK;
00161 }
00162
00163
00164 STDMETHODIMP CComponent::QueryDataObject(
00165                                          /* [in] */ MMC_COOKIE cookie,
00166                                          /* [in] */ DATA_OBJECT_TYPES type,
00167                                          /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00168 {
00169     CDataObject *pObj = NULL;
00170
00171     if (cookie == 0)
00172         pObj = new CDataObject((MMC_COOKIE)m_pComponentData->m_pStaticNode, type);
00173     else
00174         pObj = new CDataObject(cookie, type);
00175
00176     if (!pObj)
00177         return E_OUTOFMEMORY;
00178
00179     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00180
00181     return S_OK;
00182 }
00183
00184 STDMETHODIMP CComponent::GetResultViewType(
00185                                            /* [in] */ MMC_COOKIE cookie,
00186                                            /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00187                                            /* [out] */ long __RPC_FAR *pViewOptions)
00188 {
00189     CDelegationBase *base = (CDelegationBase *)cookie;
00190
00191     //
00192     // Ask for default listview.
00193     //
00194     if (base == NULL)
00195     {
00196         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00197         *ppViewType = NULL;
00198     }
00199     else
00200         return base->GetResultViewType(ppViewType, pViewOptions);
00201
00202     return S_OK;
00203 }
00204
00205 STDMETHODIMP CComponent::GetDisplayInfo(
00206                                         /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00207 {
00208     HRESULT hr = S_OK;
00209     CDelegationBase *base = NULL;
00210
00211     // if they are asking for the RDI_STR we have one of those to give
00212
00213     if (pResultDataItem->lParam) {
00214         base = (CDelegationBase *)pResultDataItem->lParam;
00215         if (pResultDataItem->mask & RDI_STR) {
00216                         LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00217                         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00218             pResultDataItem->str = pszW;
00219         }
00220
00221         if (pResultDataItem->mask & RDI_IMAGE) {
00222             pResultDataItem->nImage = base->GetBitmapIndex();
00223         }
00224     }
00225
00226     return hr;
00227 }
00228
00229
00230 STDMETHODIMP CComponent::CompareObjects(
00231                                         /* [in] */ LPDATAOBJECT lpDataObjectA,
00232                                         /* [in] */ LPDATAOBJECT lpDataObjectB)
00233 {
00234     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00235     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00236
00237     // compare the object pointers
00238     if (baseA->GetCookie() == baseB->GetCookie())
00239         return S_OK;
00240
00241     return S_FALSE;
00242 }
00243
00244 ///////////////////////////////////
00245 // Interface IExtendPropertySheet2
00246 ///////////////////////////////////
00247 HRESULT CComponent::CreatePropertyPages(
00248                                         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00249                                         /* [in] */ LONG_PTR handle,
00250                                         /* [in] */ LPDATAOBJECT lpIDataObject)
00251 {
00252     CDelegationBase *base = GetOurDataObject(lpIDataObject)->GetBaseNodeObject();
00253
00254     return base->CreatePropertyPages(lpProvider, handle);
00255 }
00256
00257 HRESULT CComponent::QueryPagesFor(
00258                                   /* [in] */ LPDATAOBJECT lpDataObject)
00259 {
00260     CDelegationBase *base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00261
00262     return base->HasPropertySheets();
00263 }
00264
00265 HRESULT CComponent::GetWatermarks(
00266                                   /* [in] */ LPDATAOBJECT lpIDataObject,
00267                                   /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00268                                   /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00269                                   /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00270                                   /* [out] */ BOOL __RPC_FAR *bStretch)
00271 {
00272     CDelegationBase *base = GetOurDataObject(lpIDataObject)->GetBaseNodeObject();
00273
00274     return base->GetWatermarks(lphWatermark, lphHeader, lphPalette, bStretch);
00275 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/DropSrc.Cpp Source File

  • WinUI
  • Shell
  • SampView

DropSrc.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          DropSrc.cpp
00013
00014    Description:   CDropSource implementation.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "DropSrc.h"
00023
00024 /**************************************************************************
00025
00026    CDropSource::CDropSource()
00027
00028 **************************************************************************/
00029
00030 CDropSource::CDropSource(void)
00031 {
00032 g_DllRefCount++;
00033
00034 m_ObjRefCount = 1;
00035 }
00036
00037 /**************************************************************************
00038
00039    CDropSource::~CDropSource()
00040
00041 **************************************************************************/
00042
00043 CDropSource::~CDropSource(void)
00044 {
00045 g_DllRefCount--;
00046 }
00047
00048 ///////////////////////////////////////////////////////////////////////////
00049 //
00050 // IUnknown Implementation
00051 //
00052
00053 /**************************************************************************
00054
00055    CDropSource::QueryInterface()
00056
00057 **************************************************************************/
00058
00059 STDMETHODIMP CDropSource::QueryInterface(REFIID riid, LPVOID *ppReturn)
00060 {
00061 *ppReturn = NULL;
00062
00063 //IUnknown
00064 if(IsEqualIID(riid, IID_IUnknown))
00065    {
00066    *ppReturn = this;
00067    }
00068
00069 //IDropTarget
00070 else if(IsEqualIID(riid, IID_IDropSource))
00071    {
00072    *ppReturn = (IDropSource*)this;
00073    }
00074
00075 if(*ppReturn)
00076    {
00077    (*(LPUNKNOWN*)ppReturn)->AddRef();
00078    return S_OK;
00079    }
00080
00081 return E_NOINTERFACE;
00082 }
00083
00084 /**************************************************************************
00085
00086    CDropSource::AddRef()
00087
00088 **************************************************************************/
00089
00090 STDMETHODIMP_(DWORD) CDropSource::AddRef(VOID)
00091 {
00092 return ++m_ObjRefCount;
00093 }
00094
00095 /**************************************************************************
00096
00097    CDropSource::Release()
00098
00099 **************************************************************************/
00100
00101 STDMETHODIMP_(DWORD) CDropSource::Release(VOID)
00102 {
00103 if(--m_ObjRefCount == 0)
00104    {
00105    delete this;
00106    return 0;
00107    }
00108
00109 return m_ObjRefCount;
00110 }
00111
00112 ///////////////////////////////////////////////////////////////////////////
00113 //
00114 // IDropSource Implementation
00115 //
00116
00117 /**************************************************************************
00118
00119    CDropSource::QueryContinueDrag()
00120
00121 **************************************************************************/
00122
00123 STDMETHODIMP CDropSource::QueryContinueDrag(BOOL fEsc, DWORD dwKeyState)
00124 {
00125 if(fEsc)
00126    return DRAGDROP_S_CANCEL;
00127
00128 // Make sure the left mouse button is still down
00129 if(!(dwKeyState & MK_LBUTTON))
00130    return DRAGDROP_S_DROP;
00131
00132 return S_OK;
00133 }
00134
00135 /**************************************************************************
00136
00137    CDropSource::GiveFeedback()
00138
00139 **************************************************************************/
00140
00141 STDMETHODIMP CDropSource::GiveFeedback(DWORD dwEffect)
00142 {
00143 return DRAGDROP_S_USEDEFAULTCURSORS;
00144 }
00145
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMultichanApp Member List

This is the complete list of members for CMultichanApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CMultichanApp() | CMultichanApp |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CMultichanApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
OnAppAbout() | CMultichanApp |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CMultichanApp() | CMultichanApp |
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/CommandTypeEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

CommandTypeEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: CommandTypeEnum
00019
00020 public class CommandTypeEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adCmdUnspecified = -1;
00023   public static final short adCmdUnknown = 8;
00024   public static final short adCmdText = 1;
00025   public static final short adCmdTable = 2;
00026   public static final short adCmdStoredProc = 4;
00027   public static final short adCmdFile = 256;
00028   public static final short adCmdTableDirect = 512;
00029   public static final short adCmdURLBind = 1024;
00030 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/basesnap.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

basesnap.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  Abstract: This module provides the basic COM and DLL methods to create
00015 //            and load the Snap-in.  IClassFactory::CreateInstance creates
00016 //            an instance of a class whose type is passed in the constructor
00017 //
00018
00019
00020 #ifndef _BASESNAP_H_
00021 #define _BASESNAP_H_
00022
00023 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppvObj);
00024 STDAPI DllCanUnloadNow(void);
00025
00026 //---------------------------------------------------------------------------
00027 class CClassFactory : public IClassFactory
00028 {
00029   public:
00030     enum FACTORY_TYPE {COMPONENTDATA = 0, ABOUT = 1};
00031
00032   public:
00033     CClassFactory(FACTORY_TYPE eFactoryType);
00034     ~CClassFactory();
00035
00036     STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv);
00037     STDMETHODIMP_(ULONG) AddRef();
00038     STDMETHODIMP_(ULONG) Release();
00039
00040     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
00041     STDMETHODIMP LockServer(BOOL);
00042
00043   private:
00044     ULONG         m_cRef;
00045     FACTORY_TYPE  m_FactoryType;
00046
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Save.h Source File

  • WinUI
  • CommDlg
  • CDTest

Save.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 void DoSaveDialog(HWND) ;
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImp_DrawDlg::Line Member List

This is the complete list of members for CImp_DrawDlg::Line, including all inherited members.
X1 | CImp_DrawDlg::Line
X2 | CImp_DrawDlg::Line
Y1 | CImp_DrawDlg::Line
Y2 | CImp_DrawDlg::Line
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

persistatl::INewsEventDefault Member List

This is the complete list of members for persistatl::INewsEventDefault, including all inherited members.
iid | persistatl::INewsEventDefault | [static]
LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate) | persistatl::INewsEventDefault |
NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL) | persistatl::INewsEventDefault |
ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow) | persistatl::INewsEventDefault |
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCIncoming/StdAfx.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCIncoming

StdAfx.cpp

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: Stdafx.cpp
00006  * ---------- [ Source Definition File]
00007  *
00008  *
00009  ******************************************************/
00010
00011 #include "stdafx.h"
00012
00013
00014
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ActiveDirectory/PropSheetHost/DataObj.cpp Source File

  • NetDS
  • ActiveDirectory
  • PropSheetHost

DataObj.cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002 //    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003 //    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 //    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 //    PARTICULAR PURPOSE.
00006 //
00007 //    Copyright 2003 Microsoft Corporation. All Rights Reserved.
00008 //***************************************************************************
00009
00010 //***************************************************************************
00011 //
00012 //    File:          DataObj.cpp
00013 //
00014 //    Description:   CPropSheetHost implementation.
00015 //
00016 //***************************************************************************
00017
00018 //***************************************************************************
00019 //    #include statements
00020 //***************************************************************************
00021
00022 #include "stdafx.h"
00023
00024 ///////////////////////////////////////////////////////////////////////////
00025 //
00026 // IUnknown Implementation
00027 //
00028
00029 /**************************************************************************
00030
00031    CPropSheetHost::QueryInterface
00032
00033 **************************************************************************/
00034
00035 STDMETHODIMP CPropSheetHost::QueryInterface(REFIID riid,
00036                                             LPVOID *ppReturn)
00037 {
00038     if(!ppReturn)
00039     {
00040         return E_INVALIDARG;
00041     }
00042
00043     *ppReturn = NULL;
00044
00045     if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IDataObject))
00046     {
00047         *ppReturn = (IDataObject*)this;
00048     }
00049
00050     if(*ppReturn)
00051     {
00052         AddRef();
00053         return S_OK;
00054     }
00055
00056     return E_NOINTERFACE;
00057 }
00058
00059 /**************************************************************************
00060
00061    CPropSheetHost::AddRef
00062
00063 **************************************************************************/
00064
00065 STDMETHODIMP_(DWORD) CPropSheetHost::AddRef()
00066 {
00067     return ++m_ObjRefCount;
00068 }
00069
00070 /**************************************************************************
00071
00072    CPropSheetHost::Release
00073
00074 **************************************************************************/
00075
00076 STDMETHODIMP_(DWORD) CPropSheetHost::Release()
00077 {
00078     if(--m_ObjRefCount == 0)
00079     {
00080         delete this;
00081         return 0;
00082     }
00083
00084     return m_ObjRefCount;
00085 }
00086
00087 ///////////////////////////////////////////////////////////////////////////
00088 //
00089 // IDataObject Implementation
00090 //
00091
00092 /**************************************************************************
00093
00094    CPropSheetHost::GetData()
00095
00096     Retrieves the data and places it in memory that the implementation
00097     allocates.
00098
00099 **************************************************************************/
00100
00101 STDMETHODIMP CPropSheetHost::GetData(FORMATETC *pFormatEtc,
00102                                     STGMEDIUM *pStgMedium)
00103 {
00104     if(!pFormatEtc || ! pStgMedium)
00105     {
00106         return E_INVALIDARG;
00107     }
00108
00109     HRESULT hr = DV_E_FORMATETC;
00110
00111     if(m_cfDSDispSpecOptions == pFormatEtc->cfFormat)
00112     {
00113         hr = _GetDSDispSpecOption(pFormatEtc, pStgMedium);
00114     }
00115     else if(m_cfDSObjectNames == pFormatEtc->cfFormat)
00116     {
00117         hr = _GetDSObjectNames(pFormatEtc, pStgMedium);
00118     }
00119     else if(m_cfDSPropSheetConfig == pFormatEtc->cfFormat)
00120     {
00121         hr = _GetDSPropSheetConfig(pFormatEtc, pStgMedium);
00122     }
00123
00124     return hr;
00125 }
00126
00127 /**************************************************************************
00128
00129    CPropSheetHost::GetDataHere()
00130
00131     Retrieves the data and places it in memory that the caller
00132     allocates.
00133
00134 **************************************************************************/
00135
00136 STDMETHODIMP CPropSheetHost::GetDataHere(FORMATETC *pFormatEtc,
00137                                         STGMEDIUM *pStgMedium)
00138 {
00139     return E_NOTIMPL;
00140 }
00141
00142 /**************************************************************************
00143
00144     CPropSheetHost::QueryGetData()
00145
00146     Determines if the data object can supply the data in the specified
00147     format. Returns S_OK if it can or one of the DV_E_ values if not. It is
00148     not necessary to call this before GetData() or GetDataHere().
00149
00150 **************************************************************************/
00151
00152 STDMETHODIMP CPropSheetHost::QueryGetData(FORMATETC *pFormatEtc)
00153 {
00154     if(this->m_cfDSDispSpecOptions == pFormatEtc->cfFormat)
00155     {
00156         return S_OK;
00157     }
00158     else if(this->m_cfDSObjectNames == pFormatEtc->cfFormat)
00159     {
00160         return S_OK;
00161     }
00162     else if(this->m_cfDSPropSheetConfig == pFormatEtc->cfFormat)
00163     {
00164         return S_OK;
00165     }
00166
00167     return DV_E_FORMATETC;
00168 }
00169
00170 /**************************************************************************
00171
00172    CPropSheetHost::GetCanonicalFormatEtc()
00173
00174 **************************************************************************/
00175
00176 STDMETHODIMP CPropSheetHost::GetCanonicalFormatEtc(LPFORMATETC pFEIn,
00177                                                   LPFORMATETC pFEOut)
00178 {
00179     return E_NOTIMPL;
00180 }
00181
00182 /**************************************************************************
00183
00184    CPropSheetHost::EnumFormatEtc()
00185
00186 **************************************************************************/
00187
00188 STDMETHODIMP CPropSheetHost::EnumFormatEtc(DWORD dwDirection,
00189                                           IEnumFORMATETC** ppEFE)
00190 {
00191     return E_NOTIMPL;
00192 }
00193
00194 /**************************************************************************
00195
00196    CPropSheetHost::SetData()
00197
00198 **************************************************************************/
00199
00200 STDMETHODIMP CPropSheetHost::SetData(LPFORMATETC pFormatEtc,
00201                                     LPSTGMEDIUM pStgMedium,
00202                                     BOOL fRelease)
00203 {
00204     return E_NOTIMPL;
00205 }
00206
00207 /**************************************************************************
00208
00209    CPropSheetHost::DAdvise()
00210
00211 **************************************************************************/
00212
00213 STDMETHODIMP CPropSheetHost::DAdvise(  LPFORMATETC pFE,
00214                                     DWORD advf,
00215                                     IAdviseSink *ppAdviseSink,
00216                                     LPDWORD pdwConnection)
00217 {
00218     return E_NOTIMPL;
00219 }
00220
00221 /**************************************************************************
00222
00223    CPropSheetHost::DUnadvise()
00224
00225 **************************************************************************/
00226
00227 STDMETHODIMP CPropSheetHost::DUnadvise(DWORD dwConnection)
00228 {
00229     return E_NOTIMPL;
00230 }
00231
00232 /**************************************************************************
00233
00234    CPropSheetHost::EnumDAdvise()
00235
00236 **************************************************************************/
00237
00238 STDMETHODIMP CPropSheetHost::EnumDAdvise(IEnumSTATDATA** ppEnumAdvise)
00239 {
00240     return E_NOTIMPL;
00241 }
00242
00243 /***************************************************************************
00244
00245     CPropSheetHost::_GetDSDispSpecOption()
00246
00247     Get the CFSTR_DSDISPLAYSPECOPTIONS data.
00248
00249 ***************************************************************************/
00250
00251 HRESULT CPropSheetHost::_GetDSDispSpecOption(FORMATETC *pFormatEtc,
00252                                              STGMEDIUM *pStgMedium)
00253 {
00254     if((m_cfDSDispSpecOptions != pFormatEtc->cfFormat) ||
00255         !(pFormatEtc->tymed & TYMED_HGLOBAL))
00256     {
00257         return DV_E_FORMATETC;
00258     }
00259
00260     HRESULT hr = E_OUTOFMEMORY;
00261     LPWSTR pwszPrefix = m_pwszPrefix;
00262     DWORD dwPrefixOffset;
00263
00264     // Size of the DSDISPLAYSPECOPTIONS structure.
00265     DWORD dwBytes = sizeof(DSDISPLAYSPECOPTIONS);
00266
00267     // Store the offset to the prefix.
00268     dwPrefixOffset = dwBytes;
00269
00270     // Length of the prefix Unicode string, including the null terminator.
00271     dwBytes += (lstrlenW(pwszPrefix) + 1) * sizeof(WCHAR);
00272
00273     pStgMedium->pUnkForRelease = NULL;
00274     pStgMedium->tymed = TYMED_HGLOBAL;
00275     pStgMedium->hGlobal = GlobalAlloc(GPTR, dwBytes);
00276     if(pStgMedium->hGlobal)
00277     {
00278         DSDISPLAYSPECOPTIONS *pDispSpecOptions = (DSDISPLAYSPECOPTIONS*)GlobalLock(pStgMedium->hGlobal);
00279         if(pDispSpecOptions)
00280         {
00281             LPWSTR pwszTemp;
00282
00283             pDispSpecOptions->dwSize = sizeof(DSDISPLAYSPECOPTIONS);
00284             pDispSpecOptions->dwFlags = 0;
00285             pDispSpecOptions->offsetAttribPrefix = dwPrefixOffset;
00286             pDispSpecOptions->offsetUserName = 0;
00287             pDispSpecOptions->offsetPassword = 0;
00288             pDispSpecOptions->offsetServer = 0;
00289             pDispSpecOptions->offsetServerConfigPath = 0;
00290
00291             // Copy the prefix string.
00292             pwszTemp = (LPWSTR)((LPBYTE)pDispSpecOptions + dwPrefixOffset);
00293             lstrcpyW(pwszTemp, pwszPrefix);
00294
00295             GlobalUnlock(pStgMedium->hGlobal);
00296
00297             hr = S_OK;
00298         }
00299     }
00300
00301     return hr;
00302 }
00303
00304 /***************************************************************************
00305
00306     CPropSheetHost::_GetDSObjectNames()
00307
00308     Get the CFSTR_DSOBJECTNAMES data.
00309
00310 ***************************************************************************/
00311
00312 HRESULT CPropSheetHost::_GetDSObjectNames(FORMATETC *pFormatEtc,
00313                                           STGMEDIUM *pStgMedium)
00314 {
00315     if((m_cfDSObjectNames != pFormatEtc->cfFormat) ||
00316         !(pFormatEtc->tymed & TYMED_HGLOBAL))
00317     {
00318         return DV_E_FORMATETC;
00319     }
00320
00321     HRESULT hr;
00322     CComBSTR sbstrADsPath;
00323
00324     hr = m_spADObject->get_ADsPath(&sbstrADsPath);
00325     if(FAILED(hr))
00326     {
00327         return hr;
00328     }
00329
00330     CComBSTR sbstrClass;
00331     hr = m_spADObject->get_Class(&sbstrClass);
00332     if(FAILED(hr))
00333     {
00334         return hr;
00335     }
00336
00337     hr = E_OUTOFMEMORY;
00338
00339     // Size of the DSOBJECTNAMES structure.
00340     DWORD dwBytes = sizeof(DSOBJECTNAMES);
00341
00342     // Store the offset to the name.
00343     DWORD dwNameOffset = dwBytes;
00344
00345     // Length of the ADsPath Unicode string, including the null terminator.
00346     dwBytes += (sbstrADsPath.Length() + 1) * sizeof(WCHAR);
00347
00348     // Store the offset to the class.
00349     DWORD dwClassOffset = dwBytes;
00350
00351     // Length of the class Unicode string, including the null terminator.
00352     dwBytes += (sbstrClass.Length() + 1) * sizeof(WCHAR);
00353
00354     pStgMedium->pUnkForRelease = NULL;
00355     pStgMedium->tymed = TYMED_HGLOBAL;
00356     pStgMedium->hGlobal = GlobalAlloc(GPTR, dwBytes);
00357     if(pStgMedium->hGlobal)
00358     {
00359         DSOBJECTNAMES *pObjectNames = (DSOBJECTNAMES*)GlobalLock(pStgMedium->hGlobal);
00360         if(pObjectNames)
00361         {
00362             LPWSTR pwszTemp;
00363
00364             pObjectNames->clsidNamespace = GUID_NULL;
00365             pObjectNames->cItems = 1;
00366             pObjectNames->aObjects[0].dwFlags = 0;
00367             pObjectNames->aObjects[0].dwProviderFlags = DSPROVIDER_ADVANCED;
00368             pObjectNames->aObjects[0].offsetName = dwNameOffset;
00369             pObjectNames->aObjects[0].offsetClass = dwClassOffset;
00370
00371             // Copy the ADsPath string.
00372             pwszTemp = (LPWSTR)((LPBYTE)pObjectNames + dwNameOffset);
00373             lstrcpyW(pwszTemp, sbstrADsPath);
00374
00375             // Copy the class string.
00376             pwszTemp = (LPWSTR)((LPBYTE)pObjectNames + dwClassOffset);
00377             lstrcpyW(pwszTemp, sbstrClass);
00378
00379             GlobalUnlock(pStgMedium->hGlobal);
00380
00381             hr = S_OK;
00382         }
00383     }
00384
00385     return hr;
00386 }
00387
00388 /***************************************************************************
00389
00390     CPropSheetHost::_GetDSPropSheetConfig()
00391
00392     Get the CFSTR_DS_PROPSHEETCONFIG data.
00393
00394 ***************************************************************************/
00395
00396 HRESULT CPropSheetHost::_GetDSPropSheetConfig(FORMATETC *pFormatEtc,
00397                                               STGMEDIUM *pStgMedium)
00398 {
00399     if((m_cfDSPropSheetConfig != pFormatEtc->cfFormat) ||
00400         !(pFormatEtc->tymed & TYMED_HGLOBAL))
00401     {
00402         return DV_E_FORMATETC;
00403     }
00404
00405     HRESULT hr = E_OUTOFMEMORY;
00406
00407     pStgMedium->pUnkForRelease = NULL;
00408     pStgMedium->tymed = TYMED_HGLOBAL;
00409     pStgMedium->hGlobal = GlobalAlloc(GPTR, sizeof(PROPSHEETCFG));
00410     if(pStgMedium->hGlobal)
00411     {
00412         PROPSHEETCFG *pPropSheetCfg = (PROPSHEETCFG*)GlobalLock(pStgMedium->hGlobal);
00413         if(pPropSheetCfg)
00414         {
00415             // hwndParentSheet recevies the handle of the window to receive WM_ADSPROP_NOTIFY_CHANGE messages.
00416             pPropSheetCfg->hwndParentSheet = m_hwndHidden;
00417
00418             // hwndParentSheet receives the handle of the window that will receive WM_DSA_SHEET_CREATE_NOTIFY and WM_DSA_SHEET_CLOSE_NOTIFY messages.
00419             pPropSheetCfg->hwndHidden = m_hwndHidden;
00420
00421             // lNotifyHandle is not used.
00422             pPropSheetCfg->lNotifyHandle = 0;
00423
00424             /*
00425             wParamSheetClose is an identifier that is passed as the wparam in
00426             the WM_DSA_SHEET_CLOSE_NOTIFY message. If this member is zero, the
00427             WM_DSA_SHEET_CLOSE_NOTIFY is not posted.
00428             */
00429             pPropSheetCfg->wParamSheetClose = PROP_SHEET_HOST_ID;
00430
00431             GlobalUnlock(pStgMedium->hGlobal);
00432
00433             hr = S_OK;
00434         }
00435     }
00436
00437     return hr;
00438 }
00439
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFilesTest/CrmFilesTestObj.Cpp Source File

  • Com
  • Services
  • Crm
  • CrmFilesTest

CrmFilesTestObj.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmFilesTestObj.cpp
00004
00005
00006
00007 Summary:
00008
00009   Test driver component for CrmFiles CRM, VC, VB and VJ versions.
00010
00011   Should be installed in a COM+ application and requires a transaction.
00012
00013   This file is part of the Microsoft COM Technology Samples.
00014
00015 Classes:
00016
00017
00018     CCrmFilesTest
00019
00020
00021 Functions: (optional)
00022
00023 ----------------------------------------------------------------------------
00024
00025 This file is part of the Microsoft COM+ Samples.
00026
00027
00028
00029 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00030
00031
00032
00033 This source code is intended only as a supplement to Microsoft
00034
00035 Development Tools and/or on-line documentation. See these other
00036
00037 materials for detailed information regarding Microsoft code samples.
00038
00039
00040
00041 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00042
00043 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00044
00045 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00046
00047 PARTICULAR PURPOSE.
00048
00049 ==========================================================================+*/
00050 // CrmFilesTestObj.cpp : Implementation of CCrmFilesTest
00051
00052 #include "stdafx.h"
00053 #include "CrmFilesTest.h"
00054 #include "CrmFilesTestObj.h"
00055
00056 /////////////////////////////////////////////////////////////////////////////
00057 // CCrmFilesTest
00058
00059 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00060
00061 Method: CCrmFilesTest::Activate()
00062
00063 Summary: IObjectControl Method. Allows an object to perform context-specific
00064      initialization whenever it's activated. This method is called by
00065      COM+ before any other methods are called on the object.
00066
00067 Returns: HRESULT
00068
00069 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00070
00071
00072 HRESULT CCrmFilesTest::Activate()
00073 {
00074   ATLTRACE(_T("CCrmFilesTest::Activate\r\n"));
00075
00076   m_lLanguage = 0;  // VC is default
00077
00078   m_pICrmFilesWorkerCurrent = NULL;
00079
00080   for (int i = 0; i < crm_Total; i++)
00081   {
00082     m_pICrmFilesWorker[i] = NULL;
00083   }
00084
00085   HRESULT hr = CoGetObjectContext(IID_IObjectContext, (void**)&m_spObjectContext);
00086   if (SUCCEEDED(hr))
00087     return S_OK;
00088   return hr;
00089
00090 } // CCrmFilesTest::Activate
00091
00092
00093 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00094
00095 Method: CCrmFilesTest::CanBePooled()
00096
00097 Summary: IObjectControl Method. Allows an object to notify COM+ of whether it
00098      can be pooled for reuse.
00099
00100 Returns: BOOL
00101
00102 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00103
00104
00105 BOOL CCrmFilesTest::CanBePooled()
00106 {
00107   ATLTRACE(_T("CCrmFilesTest::CanBePooled\r\n"));
00108
00109   return TRUE;
00110
00111 } // CCrmFilesTest::CanBePooled
00112
00113
00114 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00115
00116 Method: CCrmFilesTest::Deactivate()
00117
00118 Summary: IObjectControl Method. Allows an object to perform whatever cleanup
00119      is necessary before it's recycled or destroyed. This method is
00120      called by COM+ whenever an object is deactivated.
00121
00122 Returns: void
00123
00124 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00125
00126
00127 void CCrmFilesTest::Deactivate()
00128 {
00129   ATLTRACE(_T("CCrmFilesTest::Deactivate\r\n"));
00130
00131   // release any CRMs we might have
00132
00133   for (int i = 0; i < crm_Total; i++)
00134   {
00135     if (NULL == m_pICrmFilesWorker[i]) continue;
00136
00137     m_pICrmFilesWorker[i]->Release();
00138
00139     m_pICrmFilesWorker[i] = NULL;
00140   }
00141
00142   m_spObjectContext.Release();
00143
00144 } // CCrmFilesTest::Deactivate
00145
00146
00147 ///// ICrmFilesTest
00148
00149 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00150
00151 Method: CCrmFilesTest::put_FileName(BSTR newVal)
00152
00153 Summary: ICrmFilesTest Method. Puts the FileName property.
00154
00155 Returns: HRESULT
00156
00157 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00158
00159
00160
00161 STDMETHODIMP CCrmFilesTest::put_FileName(BSTR newVal)
00162 {
00163   ATLTRACE(_T("CCrmFilesTest::put_FileName\r\n"));
00164
00165   m_bstrFileName = newVal;
00166
00167   return S_OK;
00168
00169 } // CCrmFilesTest::put_FileName
00170
00171
00172 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00173
00174 Method: CCrmFilesTest::CreateFile()
00175
00176 Summary: ICrmFilesTest Method. Tells the Crm Worker to create the file
00177
00178 Returns: HRESULT
00179
00180 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00181
00182
00183
00184 STDMETHODIMP CCrmFilesTest::CreateFile()
00185 {
00186   ATLTRACE(_T("CCrmFilesTest::CreateFile\r\n"));
00187
00188   HRESULT hr = S_OK;
00189
00190   hr = GetCorrectCRM();
00191
00192   if (hr != S_OK) return hr;
00193
00194   hr = m_pICrmFilesWorkerCurrent->CreateFile(m_bstrFileName);
00195
00196   return hr;
00197
00198 } // CCrmFilesTest::CreateFile
00199
00200
00201
00202 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00203
00204 Method: CCrmFilesTest::DeleteFile()
00205
00206 Summary: ICrmFilesTest Method. Tells the Crm Worker to delete the file
00207
00208 Returns: HRESULT
00209
00210 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00211
00212
00213 STDMETHODIMP CCrmFilesTest::DeleteFile()
00214 {
00215   ATLTRACE(_T("CCrmFilesTest::DeleteFile\r\n"));
00216
00217   HRESULT hr = S_OK;
00218
00219   hr = GetCorrectCRM();
00220
00221   if (hr != S_OK) return hr;
00222
00223   hr = m_pICrmFilesWorkerCurrent->DeleteFile(m_bstrFileName);
00224
00225   return hr;
00226
00227 } // CCrmFilesTest::DeleteFile
00228
00229
00230 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00231
00232 Method: CCrmFilesTest::Commit()
00233
00234 Summary: ICrmFilesTest Method. Commits the transaction.
00235
00236 Returns: HRESULT
00237
00238 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00239
00240
00241
00242 STDMETHODIMP CCrmFilesTest::Commit()
00243 {
00244   ATLTRACE(_T("CCrmFilesTest::Commit\r\n"));
00245
00246   IObjectContext * pContext = m_spObjectContext;
00247
00248   HRESULT hr = pContext->SetComplete();
00249
00250   _ASSERTE((S_OK == hr) || (CONTEXT_E_ABORTED == hr));
00251
00252   return S_OK;
00253
00254 } // CCrmFilesTest::Commit
00255
00256
00257
00258 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00259
00260 Method: CCrmFilesTest::Abort()
00261
00262 Summary: ICrmFilesTest Method. Aborts the transaction.
00263
00264 Returns: HRESULT
00265
00266 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00267
00268
00269 STDMETHODIMP CCrmFilesTest::Abort()
00270 {
00271   ATLTRACE(_T("CCrmFilesTest::Abort\r\n"));
00272
00273   IObjectContext * pContext = m_spObjectContext;
00274
00275   HRESULT hr = pContext->SetAbort();
00276
00277   _ASSERTE((S_OK == hr) || (CONTEXT_E_ABORTED == hr));
00278
00279   return S_OK;
00280
00281 } // CCrmFilesTest::Abort
00282
00283
00284 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00285
00286 Method: CCrmFilesTest::put_Language(long newVal)
00287
00288 Summary: ICrmFilesTest Method. Sets the language property.
00289
00290 Returns: HRESULT
00291
00292 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00293
00294
00295 STDMETHODIMP CCrmFilesTest::put_Language(long newVal)
00296 {
00297   ATLTRACE(_T("CCrmFilesTest::put_Language\r\n"));
00298
00299   m_lLanguage = newVal;
00300
00301   return S_OK;
00302
00303 } // CCrmFilesTest::put_Language
00304
00305
00306 ///// private functions
00307
00308
00309 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00310
00311 Method: CCrmFilesTest::put_Language(long newVal)
00312
00313 Summary: Creates the correct CRM depending on the language we are using.
00314
00315 Returns: HRESULT
00316
00317 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00318
00319
00320 HRESULT CCrmFilesTest::GetCorrectCRM(void)
00321 {
00322   ATLTRACE(_T("CCrmFilesTest::GetCorrectCRM\r\n"));
00323
00324   // if we already have the required CRM, select it
00325
00326   if (m_pICrmFilesWorker[m_lLanguage])
00327   {
00328     m_pICrmFilesWorkerCurrent = m_pICrmFilesWorker[m_lLanguage];
00329
00330     return S_OK;
00331   }
00332
00333   // need to create a new CRM Worker
00334
00335   HRESULT hr = S_OK;
00336
00337   const wchar_t* pszProgID = NULL;
00338     CLSID clsid;
00339
00340   switch (m_lLanguage)
00341   {
00342     case 0: // VC
00343
00344       pszProgID = L"CrmFilesWorker.CrmFilesWorker.1";
00345       hr = CLSIDFromProgID(pszProgID, &clsid);
00346
00347       break;
00348
00349     case 1: // VB
00350
00351       pszProgID = L"CrmFilesVB.CrmFilesWorkerVB";
00352       hr = CLSIDFromProgID(pszProgID, &clsid);
00353
00354       break;
00355
00356     case 2: // VJ
00357
00358       pszProgID = L"crmfilesvj.Worker";
00359       hr = CLSIDFromProgID(pszProgID, &clsid);
00360
00361       break;
00362
00363     default:
00364
00365       _ASSERTE("ERROR: unknown language type");
00366
00367       break;
00368
00369   }; // switch
00370
00371     _ASSERTE(S_OK == hr);
00372
00373     // get the CrmFiles CRM Worker
00374
00375   #if 0
00376     // don't use smart pointer so we don't have to catch com errors
00377     IObjectContext * pContext = m_spObjectContext;
00378   #endif
00379
00380     hr = CoCreateInstance(
00381                         clsid,
00382              NULL, CLSCTX_ALL,
00383                         __uuidof(ICrmFilesWorker),
00384                         (void **)&m_pICrmFilesWorker[m_lLanguage]);
00385
00386     _ASSERTE(S_OK == hr);
00387     _ASSERTE(m_pICrmFilesWorker[m_lLanguage]);
00388
00389   m_pICrmFilesWorkerCurrent = m_pICrmFilesWorker[m_lLanguage];
00390
00391   return S_OK;
00392
00393 } // CCrmFilesTest::GetCorrectCRM
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/PersistATL/newsevent.Cpp Source File

  • Com
  • Services
  • Events
  • EventNews
  • PersistATL

newsevent.Cpp

Go to the documentation of this file.
00001 // NewsEvent.cpp : Implementation of CNewsEvent
00002 #include "stdafx.h"
00003 #include "PersistATL.h"
00004 #include "NewsEvent.h"
00005
00006 /////////////////////////////////////////////////////////////////////////////
00007 // CNewsEvent
00008
00009 STDMETHODIMP CNewsEvent::InterfaceSupportsErrorInfo(REFIID riid)
00010 {
00011   static const IID* arr[] =
00012   {
00013     &__uuidof(INewsEvent)
00014   };
00015   for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
00016   {
00017     if (::InlineIsEqualGUID(*arr[i],riid))
00018       return S_OK;
00019   }
00020   return S_FALSE;
00021 }
00022
00023 STDMETHODIMP CNewsEvent::NewsFlash(DATE dtTimeStamp, BSTR Symbol, BSTR Headline, BSTR URL)
00024 {
00025   TCHAR* tzText=0;
00026   USES_CONVERSION;
00027
00028   tzText = W2T(Headline);
00029   MessageBox(NULL,tzText,_T("Inside the Subscriber"),MB_OK);
00030   return S_OK;
00031 }
00032
00033 STDMETHODIMP CNewsEvent::ShortQuote(BSTR Symbol, double BidPrice, double AskPrice, DATE LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow)
00034 {
00035   // TODO: Add your implementation code here
00036
00037   return S_OK;
00038 }
00039
00040 STDMETHODIMP CNewsEvent::LongQuote(BSTR Symbol, double BidPrice, double AskPrice, BSTR LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, long AskSize, long BidSize, double OpenPrice, double ClosePrice, BSTR CloseDate)
00041 {
00042   // TODO: Add your implementation code here
00043
00044   return S_OK;
00045 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/MethProv/MainDll.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • MethProv

MainDll.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  MAINDLL.CPP
00006
00007 //
00008
00009 //  Module: WMI Method provider sample code
00010
00011 //
00012
00013 //  Purpose: Contains DLL entry points.  Also has code that controls
00014
00015 //           when the DLL can be unloaded by tracking the number of
00016
00017 //           objects and locks as well as routines that support
00018
00019 //           self registration.
00020
00021 //
00022
00023 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00024 //
00025 //***************************************************************************
00026
00027 #include <objbase.h>
00028 #include <initguid.h>
00029 #include <strsafe.h>
00030
00031 #include "methprov.h"
00032
00033 HMODULE ghModule;
00034
00035 // TODO, GuidGen should be used to generate a unique number for any
00036 // providers that are going to be used for anything more extensive
00037 // than just testing.
00038
00039 DEFINE_GUID(CLSID_methodprovider,0xe30ec6a0, 0x23cf, 0x11d1, 0x8f, 0xde, 0x0, 0x0, 0xf8, 0x4, 0xaa, 0x5c);
00040 //{E30EC6A0-23CF-11d1-8FDE-0000F804AA5C}
00041
00042 //Count number of objects and number of locks.
00043
00044 long       g_cObj=0;
00045 long       g_cLock=0;
00046
00047 //***************************************************************************
00048 //
00049 // LibMain32
00050 //
00051 // Purpose: Entry point for DLL.
00052 //
00053 // Return: TRUE if OK.
00054 //
00055 //***************************************************************************
00056
00057
00058 BOOL WINAPI LibMain32(HINSTANCE hInstance, ULONG ulReason
00059     , LPVOID pvReserved)
00060 {
00061     if (DLL_PROCESS_DETACH==ulReason)
00062     {
00063         return TRUE;
00064     }
00065     else
00066     {
00067         if (DLL_PROCESS_ATTACH!=ulReason)
00068             return TRUE;
00069     }
00070
00071     ghModule = hInstance;
00072     return TRUE;
00073 }
00074
00075 //***************************************************************************
00076 //
00077 //  DllGetClassObject
00078 //
00079 //  Purpose: Called by Ole when some client wants a class factory.  Return
00080 //           one only if it is the sort of class this DLL supports.
00081 //
00082 //***************************************************************************
00083
00084
00085 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, PPVOID ppv)
00086 {
00087     HRESULT hr;
00088     CProvFactory *pObj;
00089
00090     if (CLSID_methodprovider!=rclsid)
00091         return E_FAIL;
00092
00093     pObj=new CProvFactory();
00094
00095     if (NULL==pObj)
00096         return E_OUTOFMEMORY;
00097
00098     hr=pObj->QueryInterface(riid, ppv);
00099
00100     if (FAILED(hr))
00101         delete pObj;
00102
00103     return hr;
00104 }
00105
00106 //***************************************************************************
00107 //
00108 // DllCanUnloadNow
00109 //
00110 // Purpose: Called periodically by Ole in order to determine if the
00111 //          DLL can be freed.
00112 //
00113 // Return:  S_OK if there are no objects in use and the class factory
00114 //          isn't locked.
00115 //
00116 //***************************************************************************
00117
00118 STDAPI DllCanUnloadNow(void)
00119 {
00120     SCODE   sc;
00121
00122     //It is OK to unload if there are no objects or locks on the
00123     // class factory.
00124
00125     sc=(0L==g_cObj && 0L==g_cLock) ? S_OK : S_FALSE;
00126     return sc;
00127 }
00128
00129 //***************************************************************************
00130 //
00131 //  Is4OrMore
00132 //
00133 //  Returns true if win95 or any version of NT > 3.51
00134 //
00135 //***************************************************************************
00136
00137 BOOL Is4OrMore(void)
00138 {
00139     OSVERSIONINFO os;
00140     os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00141     if(!GetVersionEx(&os))
00142         return FALSE;           // should never happen
00143     return os.dwMajorVersion >= 4;
00144 }
00145
00146 //***************************************************************************
00147 //
00148 // DllRegisterServer
00149 //
00150 // Purpose: Called during setup or by regsvr32.
00151 //
00152 // Return:  NOERROR if registration successful, error otherwise.
00153 //***************************************************************************
00154
00155 STDAPI DllRegisterServer(void)
00156 {
00157     char       szID[128];
00158     WCHAR      wcID[128];
00159     char       szCLSID[128];
00160     TCHAR      szModule[MAX_PATH + 1];
00161     char * pName = "WMI Method Provider Test";
00162     char * pModel;
00163     HKEY hKey1, hKey2;
00164
00165     // Normally we want to use "Both" as the threading model since
00166     // the DLL is free threaded, but NT 3.51 Ole doesnt work unless
00167     // the model is "Aparment"
00168
00169     if(Is4OrMore())
00170         pModel = "Both";
00171     else
00172         pModel = "Apartment";
00173
00174   // Create the path.
00175
00176   memset(wcID, NULL, sizeof(wcID));
00177   memset(szID, NULL, sizeof(szID));
00178
00179     StringFromGUID2(CLSID_methodprovider, wcID, sizeof(wcID)/sizeof(WCHAR) - 1);
00180     wcstombs(szID, wcID,  sizeof(szID));
00181   StringCbCopy(szCLSID, sizeof(szCLSID), "Software\\classes\\CLSID\\");
00182   StringCbCat(szCLSID, sizeof(szCLSID), (LPCTSTR)szID);
00183
00184
00185     // Create entries under CLSID
00186
00187   LONG lRet = RegCreateKeyEx( HKEY_LOCAL_MACHINE, szCLSID, 0, NULL,
00188                     REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
00189                     &hKey1, NULL );
00190   if (lRet != ERROR_SUCCESS)
00191   {
00192     return E_FAIL;
00193   }
00194
00195     lRet = RegSetValueEx(hKey1, NULL, 0, REG_SZ, (BYTE *)pName, strlen(pName)+1);
00196   if (lRet != ERROR_SUCCESS)
00197   {
00198     RegCloseKey(hKey1);
00199     return E_FAIL;
00200   }
00201
00202   lRet = RegCreateKeyEx( hKey1, "InprocServer32", 0, NULL,
00203                     REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
00204                     &hKey2, NULL );
00205   if (lRet != ERROR_SUCCESS)
00206   {
00207     RegCloseKey(hKey1);
00208     return E_FAIL;
00209   }
00210
00211   memset(&szModule, NULL, sizeof(szModule));
00212     GetModuleFileName(ghModule, szModule,  sizeof(szModule)/sizeof(TCHAR) - 1);
00213     lRet = RegSetValueEx(hKey2, NULL, 0, REG_SZ, (BYTE *)szModule,
00214                                         strlen(szModule)+1);
00215   if (lRet != ERROR_SUCCESS)
00216   {
00217       RegCloseKey(hKey2);
00218     RegCloseKey(hKey1);
00219     return E_FAIL;
00220   }
00221     lRet = RegSetValueEx(hKey2, "ThreadingModel", 0, REG_SZ,
00222                                         (BYTE *)pModel, strlen(pModel)+1);
00223   if (lRet != ERROR_SUCCESS)
00224   {
00225       RegCloseKey(hKey2);
00226     RegCloseKey(hKey1);
00227     return E_FAIL;
00228   }
00229     RegCloseKey(hKey1);
00230     RegCloseKey(hKey2);
00231
00232     return NOERROR;
00233
00234 }
00235
00236 //***************************************************************************
00237 //
00238 // DllUnregisterServer
00239 //
00240 // Purpose: Called when it is time to remove the registry entries.
00241 //
00242 // Return:  NOERROR if registration successful, error otherwise.
00243 //***************************************************************************
00244
00245 STDAPI DllUnregisterServer(void)
00246 {
00247   char       szID[128];
00248     WCHAR      wcID[128];
00249     char  szCLSID[128];
00250     HKEY hKey;
00251
00252     // Create the path using the CLSID
00253   memset(wcID, NULL, sizeof(wcID));
00254   memset(szID, NULL, sizeof(szID));
00255     StringFromGUID2(CLSID_methodprovider, wcID, sizeof(wcID)/sizeof(WCHAR));
00256
00257     wcstombs(szID, wcID, sizeof(szID));
00258
00259   StringCbCopy(szCLSID, sizeof(szCLSID), "Software\\classes\\CLSID\\");
00260   StringCbCat(szCLSID, sizeof(szCLSID), (LPCTSTR)szID);
00261
00262      // First delete the InProcServer subkey.
00263
00264     DWORD dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szCLSID, 0, KEY_WRITE, &hKey);
00265     if(dwRet == NO_ERROR)
00266     {
00267         RegDeleteKey(hKey, "InProcServer32");
00268         RegCloseKey(hKey);
00269     }
00270
00271     dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\CLASSES\\CLSID\\"), 0, KEY_WRITE, &hKey);
00272     if(dwRet == NO_ERROR)
00273     {
00274         RegDeleteKey(hKey,szID);
00275         RegCloseKey(hKey);
00276     }
00277
00278     return NOERROR;
00279
00280 }
00281
00282
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ipv6_hdr Member List

This is the complete list of members for ipv6_hdr, including all inherited members.
ipv6_destaddr | ipv6_hdr
ipv6_hoplimit | ipv6_hdr
ipv6_nexthdr | ipv6_hdr
ipv6_payloadlen | ipv6_hdr
ipv6_srcaddr | ipv6_hdr
ipv6_vertcflow | ipv6_hdr
Generated on Wed Nov 13 2024 16:57:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptServe/Server.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptServe

Server.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.CPP
00003
00004   Summary:   Implementation file for the CServer server control utility
00005              C++ object.  This object encapsulates the server's internal
00006              control of global server object and lock counts to govern
00007              server lifetime.
00008
00009              For a comprehensive tutorial code tour of this module's
00010              contents and offerings see the tutorial APTSERVE.HTM file.
00011              For more specific technical details on the internal workings
00012              see the comments dispersed throughout the module's source code.
00013
00014   Classes:   CServer.
00015
00016   Functions: .
00017
00018   Origin:    1-17-97: atrent - Editor-inheritance from SERVER.CPP in
00019                the LOCSERVE Tutorial Code Sample. [Revised]
00020
00021 ----------------------------------------------------------------------------
00022   This file is part of the Microsoft COM Tutorial Code Samples.
00023
00024   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00025
00026   This source code is intended only as a supplement to Microsoft
00027   Development Tools and/or on-line documentation.  See these other
00028   materials for detailed information regarding Microsoft code samples.
00029
00030   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00031   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00032   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00033   PARTICULAR PURPOSE.
00034 ==========================================================================+*/
00035
00036 /*---------------------------------------------------------------------------
00037   We include WINDOWS.H for all Win32 applications.
00038   We include OLE2.H because we will make calls to the COM/OLE Libraries.
00039   We include PROCESS.H because we will be using the C-Runtime's
00040     _beginthreadex function.
00041   We include APPUTIL.H because we will be building this DLL using
00042     the convenient Virtual Window and Dialog classes and other
00043     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00044   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00045     class, GUID, and CLSID specifications.
00046   We include SERVER.H for the object class declarations for the
00047     C++ CServer server control object.
00048   We include FACTORY.H because it has the necessary internal class factory
00049     declarations for this component server.
00050 ---------------------------------------------------------------------------*/
00051 #include <windows.h>
00052 #include <ole2.h>
00053 #include <process.h>
00054 #include <apputil.h>
00055 #include <micars.h>
00056 #include <carguids.h>
00057 #include "server.h"
00058 #include "factory.h"
00059
00060
00061 /*---------------------------------------------------------------------------
00062   Implementation the internal CServer C++ object.  Used to encapsulate
00063   global server data and the methods for Lock and Object count incrementing
00064   and decrementing.
00065 ---------------------------------------------------------------------------*/
00066
00067 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00068   Method:   CServer::CServer
00069
00070   Summary:  CServer Constructor.
00071
00072   Args:     void
00073
00074   Modifies: lots-o-stuff.
00075
00076   Returns:  void
00077 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00078 CServer::CServer(void)
00079 {
00080   // Zero the Object and Lock counts for this server.
00081   m_cObjects = 0;
00082   m_cLocks = 0;
00083
00084   // Zero the cached handles.
00085   m_hInstServer = NULL;
00086   m_hWndServer = NULL;
00087
00088   // Zero the Factory and Apartment thread references.
00089   m_pCFCar = NULL;
00090   m_pCFUtilityCar = NULL;
00091   m_pCFCruiseCar = NULL;
00092   m_paiAptCar = NULL;
00093   m_paiAptUtilityCar = NULL;
00094   m_paiAptCruiseCar = NULL;
00095   m_dwAptCar = 0;
00096   m_dwAptUtilityCar = 0;
00097   m_dwAptCruiseCar = 0;
00098
00099   // NULL the apartment handle array
00100   for (UINT i = 0; i<NUM_APARTMENTS; i++)
00101     m_hApts[i] = NULL;
00102
00103   return;
00104 }
00105
00106
00107 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00108   Method:   CServer::~CServer
00109
00110   Summary:  CServer Destructor.
00111
00112   Args:     void
00113
00114   Modifies: .
00115
00116   Returns:  void
00117 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00118 CServer::~CServer(void)
00119 {
00120
00121   return;
00122 }
00123
00124
00125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00126   Method:   CServer::OwnThis
00127
00128   Summary:  Wait for multithread exclusive ownership of this CServer object.
00129             This definition overrides the virtual function defined in the
00130             CThreaded base class to permit convenient trace logging here.
00131
00132   Args:     void
00133
00134   Modifies: m_bOwned.
00135
00136   Returns:  BOOL
00137               TRUE if success; FALSE if not.
00138 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00139 BOOL CServer::OwnThis(void)
00140 {
00141   BOOL bOwned = FALSE;
00142
00143   LOGF1("L: CServer::OwnThis. Thread <%X> waiting to own CServer.",TID);
00144
00145   if (WAIT_OBJECT_0 == WaitForSingleObject(m_hOwnerMutex, INFINITE))
00146   {
00147     m_bOwned = bOwned = TRUE;
00148     LOGF1("L: CServer::OwnThis. CServer now owned by Thread <%X>.",TID);
00149   }
00150
00151   return bOwned;
00152 }
00153
00154
00155 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00156   Method:   CServer::UnOwnThis
00157
00158   Summary:  Relinquish ownership of this CServer object.
00159             This definition overrides the virtual function defined in the
00160             CThreaded base class to permit convenient trace logging here.
00161
00162   Args:     void
00163
00164   Modifies: m_bOwned.
00165
00166   Returns:  void
00167 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00168 void CServer::UnOwnThis(void)
00169 {
00170   if (m_bOwned)
00171   {
00172     LOGF1("L: CServer::UnOwnThis. Ownership relinquished by <%X>.",TID);
00173     m_bOwned = FALSE;
00174     ReleaseMutex(m_hOwnerMutex);
00175   }
00176
00177   return;
00178 }
00179
00180
00181 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00182   Method:   CServer::ObjectsUp
00183
00184   Summary:  Increment the Server's living Object count.
00185
00186   Args:     void
00187
00188   Modifies: m_cObjects.
00189
00190   Returns:  void
00191 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00192 void CServer::ObjectsUp(void)
00193 {
00194   if (OwnThis())
00195   {
00196     m_cObjects += 1;
00197     LOGF2("L<%X>: CServer::ObjectsUp. New cObjects=%i.",TID,m_cObjects);
00198
00199     UnOwnThis();
00200   }
00201
00202   return;
00203 }
00204
00205
00206 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00207   Method:   CServer::ObjectsDown
00208
00209   Summary:  Decrement the Server's living object count. Trigger an unload
00210             of this entire server if no more living components.
00211
00212   Args:     void
00213
00214   Modifies: m_cObjects.
00215
00216   Returns:  void
00217 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00218 void CServer::ObjectsDown(void)
00219 {
00220   if (OwnThis())
00221   {
00222     if (m_cObjects > 0)
00223       m_cObjects -= 1;
00224
00225     LOGF2("L<%X>: CServer::ObjectsDown. New cObjects=%i.",TID,m_cObjects);
00226
00227     // If no more living objects and no locks then shut down the server.
00228     if (0L == m_cObjects && 0L == m_cLocks && IsWindow(m_hWndServer))
00229     {
00230       LOGF1("L<%X>: CServer::ObjectsDown. Closing down APTSERVE server.",TID);
00231
00232       // Relinquish current thread ownership of CServer before signaling
00233       // the main server thread to close down the entire server. During
00234       // shutdown other threads may need to access CServer.
00235       UnOwnThis();
00236
00237       // Post a message to this local server's message queue requesting
00238       // a close of the entire server application. This will force a
00239       // termination of all apartment threads (including the one that
00240       // may be executing this ObjectsDown)
00241       PostMessage(m_hWndServer, WM_CLOSE, 0, 0L);
00242     }
00243     else
00244       UnOwnThis();
00245   }
00246
00247   return;
00248 }
00249
00250
00251 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00252   Method:   CServer::Lock
00253
00254   Summary:  Increment the Server's Lock count.
00255
00256   Args:     void
00257
00258   Modifies: m_cLocks.
00259
00260   Returns:  void
00261 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00262 void CServer::Lock(void)
00263 {
00264   if (OwnThis())
00265   {
00266     m_cLocks += 1;
00267
00268     LOGF2("L<%X>: CServer::Lock. New cLocks=%i.",TID,m_cLocks);
00269
00270     UnOwnThis();
00271   }
00272
00273   return;
00274 }
00275
00276
00277 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00278   Method:   CServer::Unlock
00279
00280   Summary:  Decrement the Server's Lock count.
00281
00282   Args:     void
00283
00284   Modifies: m_cLocks.
00285
00286   Returns:  void
00287 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00288 void CServer::Unlock(void)
00289 {
00290   if (OwnThis())
00291   {
00292     m_cLocks -= 1;
00293     if (m_cLocks < 0)
00294       m_cLocks = 0;
00295
00296     LOGF2("L<%X>: CServer::Unlock. New cLocks=%i.",TID,m_cLocks);
00297
00298     // If no more living objects and no locks then shut down the server.
00299     if (0L == m_cObjects && 0L == m_cLocks && IsWindow(m_hWndServer))
00300     {
00301       LOGF1("L<%X>: CServer::Unlock. Closing down APTSERVE server.",TID);
00302
00303       // Relinquish current thread ownership of CServer before signaling
00304       // the main server thread to close down the entire server. During
00305       // shutdown other threads may need to access CServer.
00306       UnOwnThis();
00307
00308       // Post a message to this local server's message queue requesting
00309       // a close of the entire server application. This will force a
00310       // termination of all apartment threads (including the one that
00311       // may be executing this ObjectsDown)
00312       PostMessage(m_hWndServer, WM_CLOSE, 0, 0L);
00313     }
00314     else
00315       UnOwnThis();
00316   }
00317
00318   return;
00319 }
00320
00321
00322 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00323   Function: StartThread
00324
00325   Summary:  This local function starts a new execution thread using the
00326             C-RunTime's _beginthreadex function which takes care of
00327             necessary business (that the Win32 CreateThread does not) if
00328             the thread will make calls to C-Runtime functions--a likely
00329             possibility.
00330
00331   Args:     PCRTTHREADPROC pThreadProc,
00332               Address of the Thread Procedure to start executing.
00333             LPVOID pInitData,
00334               Address of a structure of initialization data. Instead of
00335               containing an address, this parameter can also contain a
00336               single DWORD of data.
00337             DWORD* pdwThreadId);
00338               Address of a DWORD variable that will receive the
00339               thread ID of the new thread.
00340
00341   Returns:  void.
00342 ------------------------------------------------------------------------F-F*/
00343 HANDLE StartThread(
00344          PCRTTHREADPROC pThreadProc,
00345          LPVOID pInitData,
00346          DWORD* pdwThreadId)
00347 {
00348   HANDLE hThrd;
00349
00350   hThrd = (HANDLE) _beginthreadex(
00351                      0,                       // Default security specified.
00352                      0,                       // Default stack size.
00353                      pThreadProc,             // Thread Procedure address.
00354                      (LPVOID) pInitData,      // Address of Init data.
00355                      0,                       // Default state (running).
00356                      (unsigned*)pdwThreadId); // Address of ThreadID Var.
00357
00358   return hThrd;
00359 }
00360
00361
00362 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00363   Function: AptThreadProc
00364
00365   Summary:  The common apartment model thread procedure for this server.
00366
00367   Args:     LPARAM lparam
00368               Standard Window Proc parameter.
00369
00370   Modifies: .
00371
00372   Returns:  unsigned
00373               Thread procedure return (usually msg.wParam).
00374 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00375 unsigned WINAPI AptThreadProc(
00376                   LPARAM lparam)
00377 {
00378   HRESULT hr;
00379   MSG msg;
00380   DWORD dwCFRegId;
00381   APT_INIT_DATA* paid = (APT_INIT_DATA*) lparam;
00382
00383   LOGF1("L: AptThreadProc. Starting Apartment Thread <%X>.",TID);
00384
00385   // Initialize COM for this apartment thread. Specify new STA.
00386   hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
00387
00388   // Now register the class factory with COM.
00389   LOGF1("L: AptThreadProc. Registering class factory of apartment <%X>.",TID);
00390   hr = CoRegisterClassObject(
00391          paid->rclsid,
00392          paid->pcf,
00393          CLSCTX_LOCAL_SERVER,
00394          REGCLS_MULTIPLEUSE,
00395          &dwCFRegId);
00396   LOGERROR("L:CoRegisterClassObject",hr);
00397   if (SUCCEEDED(hr))
00398   {
00399     // Provide a message pump for this thread.
00400     while (GetMessage(&msg, 0, 0, 0))
00401       DispatchMessage(&msg);
00402
00403     LOGF1("L: AptThreadProc. Revoking class factory of apartment <%X>.",TID);
00404     // Unregister the class factory with COM when the thread dies.
00405     CoRevokeClassObject(dwCFRegId);
00406   }
00407   else
00408   {
00409     LOGF2("L<%X>: AptThreadProc. RegisterClass failed. hr=0x%X.",TID,hr);
00410   }
00411
00412   // Uninitialize COM in the context of this apartment thread.
00413   CoUninitialize();
00414
00415   LOGF1("L: AptThreadProc. Apartment Thread <%X> Terminated.",TID);
00416
00417   return (int) msg.wParam;
00418 }
00419
00420
00421 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00422   Method:   CServer::OpenFactories
00423
00424   Summary:  Create and register all of this server's class factories.
00425
00426   Args:     void
00427
00428   Modifies: See below.
00429
00430   Returns:  BOOL
00431               TRUE if success; FALSE if not
00432 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00433 BOOL CServer::OpenFactories(void)
00434 {
00435   BOOL bOk = FALSE;
00436   HRESULT hr;
00437
00438   LOGF1("L<%X>: CServer::OpenFactories. Begin.",TID);
00439
00440   if (OwnThis())
00441   {
00442     // Create the ClassFactory C++ objects.
00443     m_pCFCar = new CFCar(NULL, this);
00444     m_pCFUtilityCar = new CFUtilityCar(NULL, this);
00445     m_pCFCruiseCar = new CFCruiseCar(NULL, this);
00446
00447     // Create Structures for Apartment initialization.
00448     m_paiAptCar = new APT_INIT_DATA(CLSID_AptCar);
00449     m_paiAptUtilityCar = new APT_INIT_DATA(CLSID_AptUtilityCar);
00450     m_paiAptCruiseCar = new APT_INIT_DATA(CLSID_AptCruiseCar);
00451
00452     // Create the Appartment for AptCar.
00453     LOGF1("L<%X>: CServer::OpenFactories. AptCar.",TID);
00454     if (NULL != m_pCFCar && NULL != m_paiAptCar)
00455     {
00456       // AddRef this cached pointer to the Class Factory.
00457       m_pCFCar->AddRef();
00458
00459       // Assign the ClassFactory in the apartment init data and AddRef.
00460       m_paiAptCar->pcf = m_pCFCar;
00461       m_paiAptCar->pcf->AddRef();
00462
00463       // Start the Apartment Thread using a local utility function.
00464       m_hApts[APTCAR] = StartThread(
00465                           (PCRTTHREADPROC) AptThreadProc,
00466                           (LPVOID) m_paiAptCar,
00467                           &m_dwAptCar);
00468
00469       bOk = (NULL != m_hApts[APTCAR]);
00470       if (!bOk)
00471       {
00472         hr = GetLastError();
00473         LOGF2("L<%X>: CServer::OpenFactories. AptCar failed. hr=0x%X.",TID,hr);
00474         // If can't register factory then clean up for server exit.
00475         m_pCFCar->Release();
00476         m_paiAptCar->pcf->Release();
00477         DELETE_POINTER(m_pCFCar);
00478         DELETE_POINTER(m_paiAptCar);
00479       }
00480     }
00481     else
00482       bOk = FALSE;
00483
00484     // Create the Appartment for AptUtiliytCar.
00485     LOGF1("L<%X>: CServer::OpenFactories. AptUtilityCar.",TID);
00486     if (bOk)
00487     {
00488       if (NULL != m_pCFUtilityCar && NULL != m_paiAptUtilityCar)
00489       {
00490         // AddRef this cached pointer to the Class Factory.
00491         m_pCFUtilityCar->AddRef();
00492
00493         // Assign the ClassFactory in the apartment init data and AddRef again.
00494         m_paiAptUtilityCar->pcf = m_pCFUtilityCar;
00495         m_paiAptUtilityCar->pcf->AddRef();
00496
00497         // Start the Apartment Thread using a local utility function.
00498         m_hApts[APTUTILITYCAR] = StartThread(
00499                                    (PCRTTHREADPROC) AptThreadProc,
00500                                    (LPVOID) m_paiAptUtilityCar,
00501                                    &m_dwAptUtilityCar);
00502
00503         bOk = (NULL != m_hApts[APTUTILITYCAR]);
00504         if (!bOk)
00505         {
00506           hr = GetLastError();
00507           LOGF2("L<%X>: CServer::OpenFactories. AptUtilityCar failed. hr=0x%X.",TID,hr);
00508           // If can't register factory then clean up for server exit.
00509           m_pCFUtilityCar->Release();
00510           m_paiAptUtilityCar->pcf->Release();
00511           DELETE_POINTER(m_pCFUtilityCar);
00512           DELETE_POINTER(m_paiAptUtilityCar);
00513         }
00514       }
00515       else
00516         bOk = FALSE;
00517     }
00518
00519     // Create the Appartment for AptCruiseCar.
00520     LOGF1("L<%X>: CServer::OpenFactories. AptCruiseCar.",TID);
00521     if (bOk)
00522     {
00523       if (NULL != m_pCFCruiseCar && NULL != m_paiAptCruiseCar)
00524       {
00525         // AddRef this cached pointer to the Class Factory.
00526         m_pCFCruiseCar->AddRef();
00527
00528         // Assign the ClassFactory in the apartment init data and AddRef again.
00529         m_paiAptCruiseCar->pcf = m_pCFCruiseCar;
00530         m_paiAptCruiseCar->pcf->AddRef();
00531
00532         // Start the Apartment Thread using a local utility function.
00533         m_hApts[APTCRUISECAR] = StartThread(
00534                                   (PCRTTHREADPROC) AptThreadProc,
00535                                   (LPVOID) m_paiAptCruiseCar,
00536                                   &m_dwAptCruiseCar);
00537
00538         bOk = (NULL != m_hApts[APTCRUISECAR]);
00539         if (!bOk)
00540         {
00541           hr = GetLastError();
00542           LOGF2("L<%X>: CServer::OpenFactories. AptCruiseCar failed. hr=0x%X.",TID,hr);
00543           // If can't register factory then clean up for server exit.
00544           m_pCFCruiseCar->Release();
00545           m_paiAptCruiseCar->pcf->Release();
00546           DELETE_POINTER(m_pCFCruiseCar);
00547           DELETE_POINTER(m_paiAptCruiseCar);
00548         }
00549       }
00550       else
00551         bOk = FALSE;
00552     }
00553
00554     UnOwnThis();
00555   }
00556
00557   if (bOk)
00558   {
00559     // Tell COM to AddRef the internal lock count for this process so
00560     // the count can later be used to prevent any object requests
00561     // during shutdown in CloseFactories.
00562     hr = CoAddRefServerProcess();
00563     bOk = SUCCEEDED(hr);
00564   }
00565
00566   LOGF1("L<%X>: CServer::OpenFactories. End.",TID);
00567
00568   return bOk;
00569 }
00570
00571
00572 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00573   Method:   CServer::CloseFactories
00574
00575   Summary:  Shutdown the class factory apartments. Revoke (ie, unregister)
00576             and delete all the server's class factories too.
00577
00578   Args:     void
00579
00580   Returns:  BOOL
00581               TRUE if success; FALSE if not
00582 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00583 BOOL CServer::CloseFactories(void)
00584 {
00585   BOOL bOk = TRUE;
00586   HRESULT hr;
00587
00588   LOGF1("L<%X>: CServer::CloseFactories. Begin.",TID);
00589
00590   // Tell COM to release the last lock on the server process.
00591   // This essentially prevents COM from honoring any new requests for
00592   // objects during this inevitable shutdown.
00593   CoReleaseServerProcess();
00594
00595   if (OwnThis())
00596   {
00597     // Shutdown the AptCar Apartment Thread.
00598     if (0 != m_dwAptCar)
00599     {
00600       LOGF1("L<%X>: CServer::CloseFactories. Terminate AptCar Apartment.",TID);
00601       bOk = PostThreadMessage(m_dwAptCar, WM_QUIT, 0, 0);
00602       if (!bOk)
00603       {
00604         hr = GetLastError();
00605         LOGF2("L<%X>: CServer::CloseFactories. AptCar failed. hr=0x%X.",TID,hr);
00606       }
00607     }
00608
00609     // Shutdown the AptUtilityCar Apartment Thread.
00610     if (0 != m_dwAptUtilityCar)
00611     {
00612       LOGF1("L<%X>: CServer::CloseFactories. Terminate AptUtilityCar Apartment.",TID);
00613       bOk = PostThreadMessage(m_dwAptUtilityCar, WM_QUIT, 0, 0);
00614       if (!bOk)
00615       {
00616         hr = GetLastError();
00617         LOGF2("L<%X>: CServer::CloseFactories. AptUtilityCar failed. hr=0x%X.",TID,hr);
00618       }
00619     }
00620
00621     // Shutdown the AptCruiseCar Apartment Thread.
00622     if (0 != m_dwAptCruiseCar)
00623     {
00624       LOGF1("L<%X>: CServer::CloseFactories. Terminate AptCruiseCar Apartment.",TID);
00625       bOk = PostThreadMessage(m_dwAptCruiseCar, WM_QUIT, 0, 0);
00626       if (!bOk)
00627       {
00628         hr = GetLastError();
00629         LOGF2("L<%X>: CServer::CloseFactories. AptCruiseCar failed. hr=0x%X.",TID,hr);
00630       }
00631     }
00632
00633     if (m_pCFCar && m_pCFUtilityCar && m_pCFCruiseCar)
00634     {
00635       // Release any and all of the Class Factory interface pointers.
00636       LOGF1("L<%X>: CServer::CloseFactories. Releasing all Classfactory interfaces.",TID);
00637       RELEASE_INTERFACE(m_pCFCar);
00638       RELEASE_INTERFACE(m_paiAptCar->pcf);
00639       RELEASE_INTERFACE(m_pCFUtilityCar);
00640       RELEASE_INTERFACE(m_paiAptUtilityCar->pcf);
00641       RELEASE_INTERFACE(m_pCFCruiseCar);
00642       RELEASE_INTERFACE(m_paiAptCruiseCar->pcf);
00643       DELETE_POINTER(m_paiAptCar);
00644       DELETE_POINTER(m_paiAptUtilityCar);
00645       DELETE_POINTER(m_paiAptCruiseCar);
00646
00647       // Give CServer back before waiting on threads to die.
00648       UnOwnThis();
00649
00650       // Wait a very long time (in CPU terms) for the apartment threads
00651       // to exit/terminate before closing their thread handles.
00652       WaitForMultipleObjects(NUM_APARTMENTS, m_hApts, TRUE, LONG_WAIT);
00653       for (UINT i = 0; i<NUM_APARTMENTS; i++)
00654         if (NULL != m_hApts[i])
00655           CloseHandle(m_hApts[i]);
00656     }
00657     else
00658       UnOwnThis();
00659   }
00660
00661   LOGF1("L<%X>: CServer::CloseFactories. End.",TID);
00662
00663   return bOk;
00664 }
00665
00666 // =============================== END ======================================
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/Resource.h Source File

  • Com
  • Services
  • Crm
  • CrmFiles

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by CrmFiles.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_CRMFILESWORKER              101
00007 #define IDR_CRMFILESCOMPENSATOR         102
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           103
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/DoServer.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

DoServer.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          DOServer.h
00021
00022   Description:   General defintions for the DOServer project
00023
00024 **************************************************************************/
00025
00026 /**************************************************************************
00027 #include statements
00028 **************************************************************************/
00029
00030 #include <windows.h>
00031 #include <ole2.h>
00032 #include <docobj.h>
00033 #include "OleDoc.h"
00034 #include "OleDocVw.h"
00035 #include "OleObj.h"
00036 #include "DataObj.h"
00037 #include "OIPObj.h"
00038 #include "OIPAObj.h"
00039 #include "PerStor.h"
00040 #include "PerFile.h"
00041 #include "Utils.h"
00042 #include "Resource.h"
00043
00044 /**************************************************************************
00045 function prototypes
00046 **************************************************************************/
00047
00048 BOOL CALLBACK MainDlgProc(HWND, UINT, WPARAM, LPARAM);
00049
00050 /**************************************************************************
00051 global variables
00052 **************************************************************************/
00053
00054 extern HINSTANCE  g_hInst;
00055
00056 #define ARRAYSIZE(a)    (sizeof(a)/sizeof(a[0]))
00057
00058 #define DEFAULT_COLOR   (RGB(128, 0, 0))
00059 #define DEFAULT_X       100
00060 #define DEFAULT_Y       100
00061
00062 #define DEFAULT_PROMPT  (L"*.sdo")
00063 #define FILE_EXT        (TEXT(".sdo"))
00064 #define PROG_ID         (TEXT("Simple.DocObject"))
00065 #define DOC_NAME        (TEXT("Simple Doc Object"))
00066
00067 #define RED_COLOR (RGB(128, 0, 0))
00068 #define GREEN_COLOR (RGB(0, 128, 0))
00069 #define BLUE_COLOR (RGB(0, 0, 128))
00070
00071 #if defined(_UNICODE)
00072 #define lstrncat(strDest,strSource,count) wcsncat(strDest,strSource,count)
00073 #else
00074 #define lstrncat(strDest,strSource,count) strncat(strDest,strSource,count)
00075 #endif // _UNICODE
00076
00077
00078 // {F0FD0C00-65BA-11d0-B66F-00A0C90348D6}
00079 DEFINE_GUID(   CLSID_SimpleDocObject,
00080       0xf0fd0c00,
00081       0x65ba,
00082       0x11d0,
00083       0xb6,
00084       0x6f,
00085       0x0,
00086       0xa0,
00087       0xc9,
00088       0x3,
00089       0x48,
00090       0xd6);
00091
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/SmpFilt/SmpFilt.Cxx Source File

  • WinBase
  • Indexing
  • SmpFilt

SmpFilt.Cxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (c) Microsoft Corporation. All rights reserved.
00009 //
00010 //  File:       smpfilt.cxx
00011 //
00012 //  Contents:   Sample filter Implementation for Indexing Service
00013 //
00014 //  Summary:    The sample filter reads unformated text files (with the
00015 //              extension .smp) using the current thread's ANSI code page
00016 //              and outputs UNICODE text for the current locale.
00017 //
00018 //              It accepts as input only single-byte-character text files,
00019 //              and not multibyte-character or UNICODE text files.
00020 //
00021 //  Platform:   Windows 2000
00022 //
00023 //--------------------------------------------------------------------------
00024
00025 //+-------------------------------------------------------------------------
00026 //
00027 //  Include file    Purpose
00028 //
00029 //  windows.h       Win32 declarations
00030 //  filter.h        IFilter interface declarations
00031 //  filterr.h       FACILITY_ITF error definitions for IFilter
00032 //  ntquery.h       Indexing Service declarations
00033 //  filtreg.hxx     DLL registration and unregistration macros
00034 //  smpfilt.hxx     Sample filter declarations
00035 //
00036 //--------------------------------------------------------------------------
00037
00038 #include <windows.h>
00039 #include <filter.h>
00040 #include <filterr.h>
00041 #include <ntquery.h>
00042 #include "filtreg.hxx"
00043 #include "smpfilt.hxx"
00044
00045 //F-------------------------------------------------------------------------
00046 //
00047 //  Function:   GetDefaultCodepage
00048 //
00049 //  Summary:    Returns the codepage associated with the current default
00050 //              locale, or CP_ACP if one can't be found.
00051 //
00052 //  Returns:    Codepage
00053 //
00054 //--------------------------------------------------------------------------
00055
00056 ULONG GetDefaultCodepage()
00057 {
00058     ULONG codepage;
00059
00060     int cwc = GetLocaleInfo( GetSystemDefaultLCID(),
00061                              LOCALE_RETURN_NUMBER |
00062                                  LOCALE_IDEFAULTANSICODEPAGE,
00063                              (LPWSTR) &codepage,
00064                              sizeof ULONG / sizeof WCHAR );
00065
00066     // If an error occurred, return the Ansi code page
00067
00068     if ( 0 == cwc )
00069          return CP_ACP;
00070
00071     return codepage;
00072 }
00073
00074 //C-------------------------------------------------------------------------
00075 //
00076 //  Class:      CSmpFilter
00077 //
00078 //  Summary:    Implements sample filter class
00079 //
00080 //--------------------------------------------------------------------------
00081
00082 //M-------------------------------------------------------------------------
00083 //
00084 //  Method:     CSmpFilter::CSmpFilter
00085 //
00086 //  Summary:    Class constructor
00087 //
00088 //  Arguments:  void
00089 //
00090 //  Purpose:    Manages global instance count
00091 //
00092 //--------------------------------------------------------------------------
00093
00094 CSmpFilter::CSmpFilter() :
00095     m_hFile(INVALID_HANDLE_VALUE),
00096     m_lRefs(1),
00097     m_pwszFileName(0),
00098     m_ulBufferLen(0),
00099     m_ulCharsRead(0),
00100     m_ulChunkID(1),
00101     m_fContents(FALSE),
00102     m_fEof(FALSE),
00103     m_ulCodePage( GetDefaultCodepage() )
00104 {
00105     InterlockedIncrement( &g_lInstances );
00106 }
00107
00108 //M-------------------------------------------------------------------------
00109 //
00110 //  Method:     CSmpFilter::~CSmpFilter
00111 //
00112 //  Summary:    Class destructor
00113 //
00114 //  Arguments:  void
00115 //
00116 //  Purpose:    Manages global instance count and file handle
00117 //
00118 //--------------------------------------------------------------------------
00119
00120 CSmpFilter::~CSmpFilter()
00121 {
00122     delete [] m_pwszFileName;
00123     if ( INVALID_HANDLE_VALUE != m_hFile )
00124         CloseHandle( m_hFile );
00125
00126     InterlockedDecrement( &g_lInstances );
00127 }
00128
00129 //M-------------------------------------------------------------------------
00130 //
00131 //  Method:     CSmpFilter::QueryInterface      (IUnknown::QueryInterface)
00132 //
00133 //  Summary:    Queries for requested interface
00134 //
00135 //  Arguments:  riid
00136 //                  [in] Reference IID of requested interface
00137 //              ppvObject
00138 //                  [out] Address that receives requested interface pointer
00139 //
00140 //  Returns:    S_OK
00141 //                  Interface is supported
00142 //              E_NOINTERFACE
00143 //                  Interface is not supported
00144 //
00145 //--------------------------------------------------------------------------
00146
00147 SCODE STDMETHODCALLTYPE CSmpFilter::QueryInterface(
00148     REFIID riid,
00149     void  ** ppvObject
00150 )
00151 {
00152     IUnknown *pUnkTemp = 0;
00153
00154     if ( IID_IFilter == riid )
00155         pUnkTemp = (IUnknown *)(IFilter *)this;
00156     else if ( IID_IPersistFile == riid )
00157         pUnkTemp = (IUnknown *)(IPersistFile *)this;
00158     else if ( IID_IPersist == riid )
00159         pUnkTemp = (IUnknown *)(IPersist *)(IPersistFile *)this;
00160     else if ( IID_IUnknown == riid )
00161         pUnkTemp = (IUnknown *)(IPersist *)(IPersistFile *)this;
00162     else
00163     {
00164         *ppvObject = NULL;
00165         return E_NOINTERFACE;
00166     }
00167
00168     *ppvObject = (void  *)pUnkTemp;
00169     pUnkTemp->AddRef();
00170
00171     return S_OK;
00172 }
00173
00174 //M-------------------------------------------------------------------------
00175 //
00176 //  Method:     CSmpFilter::AddRef              (IUnknown::AddRef)
00177 //
00178 //  Summary:    Increments interface refcount
00179 //
00180 //  Arguments:  void
00181 //
00182 //  Returns:    Value of incremented interface refcount
00183 //
00184 //--------------------------------------------------------------------------
00185
00186 ULONG STDMETHODCALLTYPE CSmpFilter::AddRef()
00187 {
00188     return InterlockedIncrement( &m_lRefs );
00189 }
00190
00191 //M-------------------------------------------------------------------------
00192 //
00193 //  Method:     CSmpFilter::Release             (IUnknown::Release)
00194 //
00195 //  Summary:    Decrements interface refcount, deleting if unreferenced
00196 //
00197 //  Arguments:  void
00198 //
00199 //  Returns:    Value of decremented interface refcount
00200 //
00201 //--------------------------------------------------------------------------
00202
00203 ULONG STDMETHODCALLTYPE CSmpFilter::Release()
00204 {
00205     ULONG ulTmp = InterlockedDecrement( &m_lRefs );
00206
00207     if ( 0 == ulTmp )
00208         delete this;
00209
00210     return ulTmp;
00211 }
00212
00213 //M-------------------------------------------------------------------------
00214 //
00215 //  Method:     CSmpFilter::Init                (IFilter::Init)
00216 //
00217 //  Summary:    Initializes sample filter instance
00218 //
00219 //  Arguments:  grfFlags
00220 //                  [in] Flags for filter behavior
00221 //              cAttributes
00222 //                  [in] Number attributes in array aAttributes
00223 //              aAttributes
00224 //                  [in] Array of requested attribute strings
00225 //              pFlags
00226 //                  [out] Pointer to return flags for additional properties
00227 //
00228 //  Returns:    S_OK
00229 //                  Initialization succeeded
00230 //              E_FAIL
00231 //                  File not previously loaded
00232 //              E_INVALIDARG
00233 //                  Count and contents of attributes do not agree
00234 //              FILTER_E_ACCESS
00235 //                  Unable to access file to be filtered
00236 //              FILTER_E_PASSWORD
00237 //                  (not implemented)
00238 //
00239 //--------------------------------------------------------------------------
00240
00241 SCODE STDMETHODCALLTYPE CSmpFilter::Init(
00242     ULONG grfFlags,
00243     ULONG cAttributes,
00244     FULLPROPSPEC const * aAttributes,
00245     ULONG * pFlags
00246 )
00247 {
00248     // Ignore flags for text canonicalization (text is unformatted)
00249     // Check for proper attributes request and recognize only "contents"
00250
00251     if( 0 < cAttributes )
00252     {
00253         ULONG ulNumAttr;
00254
00255         if ( 0 == aAttributes )
00256             return E_INVALIDARG;
00257
00258         for ( ulNumAttr = 0 ; ulNumAttr < cAttributes; ulNumAttr++ )
00259         {
00260             if ( guidStorage == aAttributes[ulNumAttr].guidPropSet &&
00261                 PID_STG_CONTENTS == aAttributes[ulNumAttr].psProperty.propid )
00262                 break;
00263         }
00264
00265         if ( ulNumAttr < cAttributes )
00266             m_fContents = TRUE;
00267         else
00268             m_fContents = FALSE;
00269     }
00270     else if ( 0 == grfFlags ||
00271               (grfFlags & IFILTER_INIT_APPLY_INDEX_ATTRIBUTES) )
00272         m_fContents = TRUE;
00273     else
00274         m_fContents = FALSE;
00275
00276     m_fEof = FALSE;
00277
00278     // Open the file previously specified in call to IPersistFile::Load
00279
00280     if ( 0 != m_pwszFileName )
00281     {
00282         if ( INVALID_HANDLE_VALUE != m_hFile )
00283         {
00284             CloseHandle( m_hFile );
00285             m_hFile = INVALID_HANDLE_VALUE;
00286         }
00287
00288         m_hFile = CreateFile(
00289                       (LPCWSTR)m_pwszFileName,
00290                       GENERIC_READ,
00291                       FILE_SHARE_READ | FILE_SHARE_DELETE,
00292                       0,
00293                       OPEN_EXISTING,
00294                       FILE_ATTRIBUTE_NORMAL,
00295                       0
00296                   );
00297
00298         if ( INVALID_HANDLE_VALUE == m_hFile )
00299             return FILTER_E_ACCESS;
00300     }
00301     else
00302         return E_FAIL;
00303
00304     // Enumerate OLE properties, since any NTFS file can have them
00305
00306     *pFlags = IFILTER_FLAGS_OLE_PROPERTIES;
00307
00308     // Re-initialize
00309
00310     m_ulChunkID = 1;
00311     m_ulCharsRead = 0;
00312
00313     return S_OK;
00314 }
00315
00316 //M-------------------------------------------------------------------------
00317 //
00318 //  Method:     CSmpFilter::GetChunk            (IFilter::GetChunk)
00319 //
00320 //  Summary:    Gets the next chunk (text only)
00321 //
00322 //  Note:       GetChunk accepts as input only single-byte-character text
00323 //              files, and not multibyte-character or UNICODE text files.
00324 //
00325 //  Arguments:  ppStat
00326 //                  [out] Pointer to description of current chunk
00327 //  Returns:    S_OK
00328 //                  Chunk was successfully retrieved
00329 //              E_FAIL
00330 //                  Character conversion failed
00331 //              FILTER_E_ACCESS
00332 //                  General access failure occurred
00333 //              FILTER_E_END_OF_CHUNKS
00334 //                  Previous chunk was the last chunk
00335 //              FILTER_E_EMBEDDING_UNAVAILABLE
00336 //                  (not implemented)
00337 //              FILTER_E_LINK_UNAVAILABLE
00338 //                  (not implemented)
00339 //              FILTER_E_PASSWORD
00340 //                  (not implemented)
00341 //
00342 //--------------------------------------------------------------------------
00343
00344 SCODE STDMETHODCALLTYPE CSmpFilter::GetChunk(
00345     STAT_CHUNK * pStat
00346 )
00347 {
00348     if ( INVALID_HANDLE_VALUE == m_hFile )
00349         return FILTER_E_ACCESS;
00350
00351     // Read characters from single-byte file
00352
00353     char cszBuffer[TEXT_FILTER_CHUNK_SIZE];
00354
00355     if ( !ReadFile(
00356               m_hFile,
00357               cszBuffer,
00358               TEXT_FILTER_CHUNK_SIZE,
00359               &m_ulBufferLen,
00360               NULL
00361           ) )
00362         return FILTER_E_ACCESS;
00363     else if( 0 == m_ulBufferLen )
00364         m_fEof = TRUE;
00365
00366     if ( !m_fContents || m_fEof )
00367         return FILTER_E_END_OF_CHUNKS;
00368
00369     // Convert single-byte characters to UNICODE
00370     //
00371     // This conversion assumes a one-to-one conversion:
00372     //     one input single-byte character to
00373     //     one output multibyte (UNICODE) character
00374     //
00375     // This is typically not the general case with multibyte
00376     // characters, and a general case needs to handle the possible
00377     // difference of pre- and post-conversion buffer lengths
00378
00379     if ( !MultiByteToWideChar(
00380               m_ulCodePage,
00381               MB_COMPOSITE,
00382               cszBuffer,
00383               m_ulBufferLen,
00384               m_wcsBuffer,
00385               TEXT_FILTER_CHUNK_SIZE
00386           ) )
00387         return E_FAIL;
00388
00389     // Set chunk description
00390
00391     pStat->idChunk   = m_ulChunkID;
00392     pStat->breakType = CHUNK_NO_BREAK;
00393     pStat->flags     = CHUNK_TEXT;
00394     pStat->locale    = GetSystemDefaultLCID();
00395     pStat->attribute.guidPropSet       = guidStorage;
00396     pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00397     pStat->attribute.psProperty.propid = PID_STG_CONTENTS;
00398     pStat->idChunkSource  = m_ulChunkID;
00399     pStat->cwcStartSource = 0;
00400     pStat->cwcLenSource   = 0;
00401
00402     m_ulCharsRead = 0;
00403     m_ulChunkID++;
00404
00405     return S_OK;
00406 }
00407
00408 //M-------------------------------------------------------------------------
00409 //
00410 //  Method:     CSmpFilter::GetText             (IFilter::GetText)
00411 //
00412 //  Summary:    Retrieves UNICODE text for index
00413 //
00414 //  Arguments:  pcwcBuffer
00415 //                  [in] Pointer to size of UNICODE buffer
00416 //                  [out] Pointer to count of UNICODE characters returned
00417 //              awcBuffer
00418 //                  [out] Pointer to buffer to receive UNICODE text
00419 //
00420 //  Returns:    S_OK
00421 //                  Text successfully retrieved, but text remains in chunk
00422 //              FILTER_E_NO_MORE_TEXT
00423 //                  All of the text in the current chunk has been returned
00424 //              FILTER_S_LAST_TEXT
00425 //                  Next call to GetText will return FILTER_E_NO_MORE_TEXT
00426 //
00427 //--------------------------------------------------------------------------
00428
00429 SCODE STDMETHODCALLTYPE CSmpFilter::GetText(
00430     ULONG * pcwcBuffer,
00431     WCHAR * awcBuffer
00432 )
00433 {
00434     if ( !m_fContents || 0 == m_ulBufferLen )
00435     {
00436         *pcwcBuffer = 0;
00437         return FILTER_E_NO_MORE_TEXT;
00438     }
00439
00440     // Copy characters in chunk buffer to output UNICODE buffer
00441     //
00442     // This copy assumes a one-to-one conversion in GetChunk
00443     // of input single-byte characters (each 1 byte long)
00444     // to output UNICODE characters (each 2 bytes long)
00445
00446     ULONG ulToCopy = min( *pcwcBuffer, m_ulBufferLen - m_ulCharsRead );
00447
00448     memcpy( awcBuffer, m_wcsBuffer + m_ulCharsRead, 2*ulToCopy );
00449     m_ulCharsRead += ulToCopy;
00450     *pcwcBuffer = ulToCopy;
00451
00452     if ( m_ulBufferLen == m_ulCharsRead )
00453     {
00454         m_ulCharsRead = 0;
00455         m_ulBufferLen = 0;
00456         return FILTER_S_LAST_TEXT;
00457     }
00458
00459     return S_OK;
00460 }
00461
00462 //M-------------------------------------------------------------------------
00463 //
00464 //  Method:     CSmpFilter::GetValue            (IFilter::GetValue)
00465 //
00466 //  Summary:    Retrieves properites for index
00467 //
00468 //  Arguments:  ppPropValue
00469 //                  [out] Address that receives pointer to property value
00470 //
00471 //  Returns:    FILTER_E_NO_VALUES
00472 //                  Always
00473 //              FILTER_E_NO_MORE_VALUES
00474 //                  (not implemented)
00475 //
00476 //--------------------------------------------------------------------------
00477
00478 SCODE STDMETHODCALLTYPE CSmpFilter::GetValue(
00479     PROPVARIANT ** ppPropValue
00480 )
00481 {
00482     // Sample filter does not retieve any properties
00483
00484     return FILTER_E_NO_VALUES;
00485 }
00486
00487 //M-------------------------------------------------------------------------
00488 //
00489 //  Method:     CSmpFilter::BindRegion          (IFilter::BindRegion)
00490 //
00491 //  Summary:    Creates moniker or other interface for indicated text
00492 //
00493 //  Arguments:  origPos
00494 //                  [in] Description of text location and extent
00495 //              riid
00496 //                  [in] Reference IID of specified interface
00497 //              ppunk
00498 //                  [out] Address that receives requested interface pointer
00499 //
00500 //  Returns:    E_NOTIMPL
00501 //                  Always
00502 //              FILTER_W_REGION_CLIPPED
00503 //                  (not implemented)
00504 //
00505 //--------------------------------------------------------------------------
00506
00507 SCODE STDMETHODCALLTYPE CSmpFilter::BindRegion(
00508     FILTERREGION origPos,
00509     REFIID riid,
00510     void ** ppunk
00511 )
00512 {
00513     // BindRegion is currently reserved for future use
00514
00515     return E_NOTIMPL;
00516 }
00517
00518 //M-------------------------------------------------------------------------
00519 //
00520 //  Method:     CSmpFilter::GetClassID          (IPersist::GetClassID)
00521 //
00522 //  Summary:    Retrieves the class id of the filter class
00523 //
00524 //  Arguments:  pClassID
00525 //                  [out] Pointer to the class ID of the filter
00526 //
00527 //  Returns:    S_OK
00528 //                  Always
00529 //              E_FAIL
00530 //                  (not implemented)
00531 //
00532 //--------------------------------------------------------------------------
00533
00534 SCODE STDMETHODCALLTYPE CSmpFilter::GetClassID(
00535     CLSID * pClassID
00536 )
00537 {
00538     *pClassID = CLSID_CSmpFilter;
00539     return S_OK;
00540 }
00541
00542 //M-------------------------------------------------------------------------
00543 //
00544 //  Method:     CSmpFilter::IsDirty             (IPersistFile::IsDirty)
00545 //
00546 //  Summary:    Checks whether file has changed since last save
00547 //
00548 //  Arguments:  void
00549 //
00550 //  Returns:    S_FALSE
00551 //                  Always
00552 //              S_OK
00553 //                  (not implemented)
00554 //
00555 //--------------------------------------------------------------------------
00556
00557 SCODE STDMETHODCALLTYPE CSmpFilter::IsDirty()
00558 {
00559     // File is opened read-only and never changes
00560
00561     return S_FALSE;
00562 }
00563
00564 //M-------------------------------------------------------------------------
00565 //
00566 //  Method:     CSmpFilter::Load                (IPersistFile::Load)
00567 //
00568 //  Summary:    Opens and initializes the specified file
00569 //
00570 //  Arguments:  pszFileName
00571 //                  [in] Pointer to zero-terminated string
00572 //                       of absolute path of file to open
00573 //              dwMode
00574 //                  [in] Access mode to open the file
00575 //
00576 //  Returns:    S_OK
00577 //                  File was successfully loaded
00578 //              E_OUTOFMEMORY
00579 //                  File could not be loaded due to insufficient memory
00580 //              E_FAIL
00581 //                  (not implemented)
00582 //
00583 //--------------------------------------------------------------------------
00584
00585 SCODE STDMETHODCALLTYPE CSmpFilter::Load(
00586     LPCWSTR pszFileName,
00587     DWORD dwMode
00588 )
00589 {
00590     // Load just sets the filename for GetChunk to read and ignores the mode
00591
00592     ULONG ulChars = (ULONG)wcslen( pszFileName ) + 1;
00593     delete [] m_pwszFileName;
00594
00595     m_pwszFileName = new WCHAR [ulChars];
00596
00597     if ( 0 != m_pwszFileName )
00598         wcscpy( m_pwszFileName, pszFileName );
00599     else
00600         return E_OUTOFMEMORY;
00601
00602     return S_OK;
00603 }
00604
00605 //M-------------------------------------------------------------------------
00606 //
00607 //  Method:     CSmpFilter::Save                (IPersistFile::Save)
00608 //
00609 //  Summary:    Saves a copy of the current file being filtered
00610 //
00611 //  Arguments:  pszFileName
00612 //                  [in] Pointer to zero-terminated string of
00613 //                       absolute path of where to save file
00614 //              fRemember
00615 //                  [in] Whether the saved copy is made the current file
00616 //
00617 //  Returns:    E_FAIL
00618 //                  Always
00619 //              S_OK
00620 //                  (not implemented)
00621 //
00622 //--------------------------------------------------------------------------
00623
00624 SCODE STDMETHODCALLTYPE CSmpFilter::Save(
00625     LPCWSTR pszFileName,
00626     BOOL fRemember
00627 )
00628 {
00629     // File is opened read-only; saving it is an error
00630
00631     return E_FAIL;
00632 }
00633
00634 //M-------------------------------------------------------------------------
00635 //
00636 //  Method:     CSmpFilter::SaveCompleted      (IPersistFile::SaveCompleted)
00637 //
00638 //  Summary:    Determines whether a file save is completed
00639 //
00640 //  Arguments:  pszFileName
00641 //                  [in] Pointer to zero-terminated string of
00642 //                       absolute path where file was previously saved
00643 //
00644 //  Returns:    S_OK
00645 //                  Always
00646 //
00647 //--------------------------------------------------------------------------
00648
00649 SCODE STDMETHODCALLTYPE CSmpFilter::SaveCompleted(
00650     LPCWSTR pszFileName
00651 )
00652 {
00653     // File is opened read-only, so "save" is always finished
00654
00655     return S_OK;
00656 }
00657
00658 //M-------------------------------------------------------------------------
00659 //
00660 //  Method:     CSmpFilter::GetCurFile          (IPersistFile::GetCurFile)
00661 //
00662 //  Summary:    Returns a copy of the current file name
00663 //
00664 //  Arguments:  ppszFileName
00665 //                  [out] Address to receive pointer to zero-terminated
00666 //                        string for absolute path to current file
00667 //
00668 //  Returns:    S_OK
00669 //                  A valid absolute path was successfully returned
00670 //              S_FALSE
00671 //                  (not implemented)
00672 //              E_OUTOFMEMORY
00673 //                  Operation failed due to insufficient memory
00674 //              E_FAIL
00675 //                  Operation failed due to some reason
00676 //                  other than insufficient memory
00677 //
00678 //--------------------------------------------------------------------------
00679
00680 SCODE STDMETHODCALLTYPE CSmpFilter::GetCurFile(
00681     LPWSTR * ppszFileName
00682 )
00683 {
00684     if ( 0 == m_pwszFileName )
00685         return E_FAIL;
00686
00687     ULONG ulChars = (ULONG)wcslen( m_pwszFileName ) + 1;
00688     *ppszFileName = (WCHAR *)CoTaskMemAlloc( ulChars * sizeof WCHAR );
00689
00690     if ( 0 != *ppszFileName )
00691         wcscpy( *ppszFileName, m_pwszFileName );
00692     else
00693         return E_OUTOFMEMORY;
00694
00695     return S_OK;
00696 }
00697
00698 //C-------------------------------------------------------------------------
00699 //
00700 //  Class:      CSmpFilterCF
00701 //
00702 //  Summary:    Implements class factory for sample filter
00703 //
00704 //--------------------------------------------------------------------------
00705
00706 //M-------------------------------------------------------------------------
00707 //
00708 //  Method:     CSmpFilterCF::CSmpFilterCF
00709 //
00710 //  Summary:    Class factory constructor
00711 //
00712 //  Arguments:  void
00713 //
00714 //  Purpose:    Manages global instance count
00715 //
00716 //--------------------------------------------------------------------------
00717
00718 CSmpFilterCF::CSmpFilterCF() :
00719     m_lRefs(1)
00720 {
00721     InterlockedIncrement( &g_lInstances );
00722 }
00723
00724 //M-------------------------------------------------------------------------
00725 //
00726 //  Method:     CSmpFilterCF::~CSmpFilterCF
00727 //
00728 //  Summary:    Class factory destructor
00729 //
00730 //  Arguments:  void
00731 //
00732 //  Purpose:    Manages global instance count
00733 //
00734 //--------------------------------------------------------------------------
00735
00736 CSmpFilterCF::~CSmpFilterCF()
00737 {
00738    InterlockedDecrement( &g_lInstances );
00739 }
00740
00741 //M-------------------------------------------------------------------------
00742 //
00743 //  Method:     CSmpFilterCF::QueryInterface    (IUnknown::QueryInterface)
00744 //
00745 //  Summary:    Queries for requested interface
00746 //
00747 //  Arguments:  riid
00748 //                  [in] Reference IID of requested interface
00749 //              ppvObject
00750 //                  [out] Address that receives requested interface pointer
00751 //
00752 //  Returns:    S_OK
00753 //                  Interface is supported
00754 //              E_NOINTERFACE
00755 //                  Interface is not supported
00756 //
00757 //--------------------------------------------------------------------------
00758
00759 SCODE STDMETHODCALLTYPE CSmpFilterCF::QueryInterface(
00760     REFIID riid,
00761     void  ** ppvObject
00762 )
00763 {
00764     IUnknown *pUnkTemp;
00765
00766     if ( IID_IClassFactory == riid )
00767         pUnkTemp = (IUnknown *)(IClassFactory *)this;
00768     else if ( IID_IUnknown == riid )
00769         pUnkTemp = (IUnknown *)this;
00770     else
00771     {
00772         *ppvObject = NULL;
00773         return E_NOINTERFACE;
00774     }
00775
00776     *ppvObject = (void  *)pUnkTemp;
00777     pUnkTemp->AddRef();
00778
00779     return S_OK;
00780 }
00781
00782 //M-------------------------------------------------------------------------
00783 //
00784 //  Method:     CSmpFilterCF::AddRef            (IUknown::AddRef)
00785 //
00786 //  Summary:    Increments interface refcount
00787 //
00788 //  Arguments:  void
00789 //
00790 //  Returns:    Value of incremented interface refcount
00791 //
00792 //--------------------------------------------------------------------------
00793
00794 ULONG STDMETHODCALLTYPE CSmpFilterCF::AddRef()
00795 {
00796    return InterlockedIncrement( &m_lRefs );
00797 }
00798
00799 //M-------------------------------------------------------------------------
00800 //
00801 //  Method:     CSmpFilterCF::Release           (IUnknown::Release)
00802 //
00803 //  Summary:    Decrements interface refcount, deleting if unreferenced
00804 //
00805 //  Arguments:  void
00806 //
00807 //  Returns:    Value of decremented refcount
00808 //
00809 //--------------------------------------------------------------------------
00810
00811 ULONG STDMETHODCALLTYPE CSmpFilterCF::Release()
00812 {
00813     ULONG ulTmp = InterlockedDecrement( &m_lRefs );
00814
00815     if ( 0 == ulTmp )
00816         delete this;
00817
00818     return ulTmp;
00819 }
00820
00821 //M-------------------------------------------------------------------------
00822 //
00823 //  Method:     CSmpFilterCF::CreateInstance (IClassFactory::CreateInstance)
00824 //
00825 //  Summary:    Creates new sample filter object
00826 //
00827 //  Arguments:  pUnkOuter
00828 //                  [in] Pointer to IUnknown interface of aggregating object
00829 //              riid
00830 //                  [in] Reference IID of requested interface
00831 //              ppvObject
00832 //                  [out] Address that receives requested interface pointer
00833 //
00834 //  Returns:    S_OK
00835 //                  Sample filter object was successfully created
00836 //              CLASS_E_NOAGGREGATION
00837 //                  pUnkOuter parameter was non-NULL
00838 //              E_NOINTERFACE
00839 //                  (not implemented)
00840 //              E_OUTOFMEMORY
00841 //                  Sample filter object could not be created
00842 //                  due to insufficient memory
00843 //              E_UNEXPECTED
00844 //                  Unsuccessful due to an unexpected condition
00845 //
00846 //--------------------------------------------------------------------------
00847
00848 SCODE STDMETHODCALLTYPE CSmpFilterCF::CreateInstance(
00849     IUnknown * pUnkOuter,
00850     REFIID riid,
00851     void  * * ppvObject
00852 )
00853 {
00854     CSmpFilter *pIUnk = 0;
00855
00856     if ( 0 != pUnkOuter )
00857         return CLASS_E_NOAGGREGATION;
00858
00859     pIUnk = new CSmpFilter();
00860
00861     if ( 0 != pIUnk )
00862     {
00863         if ( SUCCEEDED( pIUnk->QueryInterface( riid , ppvObject ) ) )
00864         {
00865             // Release extra refcount from QueryInterface
00866
00867             pIUnk->Release();
00868         }
00869         else
00870         {
00871             delete pIUnk;
00872             return E_UNEXPECTED;
00873         }
00874     }
00875     else
00876         return E_OUTOFMEMORY;
00877
00878     return S_OK;
00879 }
00880
00881 //M-------------------------------------------------------------------------
00882 //
00883 //  Method:     CSmpFilterCF::LockServer        (IClassFactory::LockServer)
00884 //
00885 //  Summary:    Forces/allows filter class to remain loaded/be unloaded
00886 //
00887 //  Arguments:  fLock
00888 //                  [in] TRUE to lock, FALSE to unlock
00889 //
00890 //  Returns:    S_OK
00891 //                  Always
00892 //              E_FAIL
00893 //                  (not implemented)
00894 //              E_OUTOFMEMORY
00895 //                  (not implemented)
00896 //              E_UNEXPECTED
00897 //                  (not implemented)
00898 //
00899 //--------------------------------------------------------------------------
00900
00901 SCODE STDMETHODCALLTYPE CSmpFilterCF::LockServer(
00902     BOOL fLock
00903 )
00904 {
00905     if( fLock )
00906         InterlockedIncrement( &g_lInstances );
00907     else
00908         InterlockedDecrement( &g_lInstances );
00909
00910     return S_OK;
00911 }
00912
00913 //+-------------------------------------------------------------------------
00914 //
00915 //  DLL:        SmpFilt.dll
00916 //
00917 //  Summary:    Implements Dynamic Link Library functions for sample filter
00918 //
00919 //--------------------------------------------------------------------------
00920
00921 //F-------------------------------------------------------------------------
00922 //
00923 //  Function:   DllMain
00924 //
00925 //  Summary:    Called from C-Runtime on process/thread attach/detach
00926 //
00927 //  Arguments:  hInstance
00928 //                  [in] Handle to the DLL
00929 //              fdwReason
00930 //                  [in] Reason for calling DLL entry point
00931 //              lpReserved
00932 //                  [in] Details of DLL initialization and cleanup
00933 //
00934 //  Returns:    TRUE
00935 //                  Always
00936 //
00937 //--------------------------------------------------------------------------
00938
00939 extern "C" BOOL WINAPI DllMain(
00940     HINSTANCE hInstance,
00941     DWORD     fdwReason,
00942     LPVOID    lpvReserved
00943 )
00944 {
00945    if ( DLL_PROCESS_ATTACH == fdwReason )
00946         DisableThreadLibraryCalls( hInstance );
00947
00948     return TRUE;
00949 }
00950
00951 //F-------------------------------------------------------------------------
00952 //
00953 //  Function:   DllGetClassObject
00954 //
00955 //  Summary:    Create sample filter class factory object
00956 //
00957 //  Arguments:  cid
00958 //                  [in] Class ID of class that class factory creates
00959 //              iid
00960 //                  [in] Reference IID of requested class factory interface
00961 //              ppvObj
00962 //                  [out] Address that receives requested interface pointer
00963 //
00964 //  Returns:    S_OK
00965 //                  Class factory object was created successfully
00966 //              CLASS_E_CLASSNOTAVAILABLE
00967 //                  DLL does not support the requested class
00968 //              E_INVALIDARG
00969 //                  (not implemented)
00970 //              E_OUTOFMEMORY
00971 //                  Insufficient memory to create the class factory object
00972 //              E_UNEXPECTED
00973 //                  Unsuccessful due to an unexpected condition
00974 //
00975 //--------------------------------------------------------------------------
00976
00977 extern "C" SCODE STDMETHODCALLTYPE DllGetClassObject(
00978     REFCLSID   cid,
00979     REFIID     iid,
00980     void **    ppvObj
00981 )
00982 {
00983     IUnknown *pResult = 0;
00984
00985     if ( CLSID_CSmpFilter == cid )
00986         pResult = (IUnknown *) new CSmpFilterCF;
00987     else
00988         return CLASS_E_CLASSNOTAVAILABLE;
00989
00990     if ( 0 != pResult )
00991     {
00992         if( SUCCEEDED( pResult->QueryInterface( iid, ppvObj ) ) )
00993             // Release extra refcount from QueryInterface
00994             pResult->Release();
00995         else
00996         {
00997             delete pResult;
00998             return E_UNEXPECTED;
00999         }
01000     }
01001     else
01002         return E_OUTOFMEMORY;
01003
01004     return S_OK;
01005 }
01006
01007 //F-------------------------------------------------------------------------
01008 //
01009 //  Function:   DllCanUnloadNow
01010 //
01011 //  Summary:    Indicates whether it is possible to unload DLL
01012 //
01013 //  Arguments:  void
01014 //
01015 //  Returns:    S_OK
01016 //                  DLL can be unloaded now
01017 //              S_FALSE
01018 //                  DLL must remain loaded
01019 //
01020 //--------------------------------------------------------------------------
01021
01022 extern "C" SCODE STDMETHODCALLTYPE DllCanUnloadNow(
01023     void
01024 )
01025 {
01026     if ( 0 >= g_lInstances )
01027         return S_OK;
01028     else
01029         return S_FALSE;
01030 }
01031
01032 //F-------------------------------------------------------------------------
01033 //
01034 //  Function:   DllRegisterServer
01035 //              DllUnregisterServer
01036 //
01037 //  Summary:    Registers and unregisters DLL server
01038 //
01039 //              The registration procedure uses a set of macros
01040 //              developed for use within the Indexing Service code.
01041 //              The macros are in the included filtreg.hxx.
01042 //
01043 //  Returns:    DllRegisterServer
01044 //                  S_OK
01045 //                      Registration was successful
01046 //                  SELFREG_E_CLASS
01047 //                      Registration was unsuccessful
01048 //                  SELFREG_E_TYPELIB
01049 //                      (not implemented)
01050 //                  E_OUTOFMEMORY
01051 //                      (not implemented)
01052 //                  E_UNEXPECTED
01053 //                      (not implemented)
01054 //              DllUnregisterServer
01055 //                  S_OK
01056 //                      Unregistration was successful
01057 //                  S_FALSE
01058 //                      Unregistration was successful, but other
01059 //                      entries still exist for the DLL's classes
01060 //                  SELFREG_E_CLASS
01061 //                      (not implemented)
01062 //                  SELFREG_E_TYPELIB
01063 //                      (not implemented)
01064 //                  E_OUTOFMEMORY
01065 //                      (not implemented)
01066 //                  E_UNEXPECTED
01067 //                      (not implemented)
01068 //
01069 //--------------------------------------------------------------------------
01070
01071 //+-------------------------------------------------------------------------
01072 //
01073 //  These structures define the registry keys for the registration process.
01074 //
01075 //--------------------------------------------------------------------------
01076
01077 SClassEntry const asmpClasses[] =
01078 {
01079     { L".smp",
01080       L"SmpFilt.Document",
01081       L"Sample Filter Document",
01082       L"{8B0E5E72-3C30-11d1-8C0D-00AA00C26CD4}",
01083       L"Sample Filter Document"
01084     }
01085 };
01086
01087 SHandlerEntry const smpHandler =
01088 {
01089     L"{8B0E5E73-3C30-11d1-8C0D-00AA00C26CD4}",
01090     L"SmpFilt Persistent Handler",
01091     L"{8B0E5E70-3C30-11d1-8C0D-00AA00C26CD4}"
01092 };
01093
01094 SFilterEntry const smpFilter =
01095 {
01096     L"{8B0E5E70-3C30-11d1-8C0D-00AA00C26CD4}",
01097     L"Sample Filter",
01098     L"smpfilt.dll",
01099     L"Both"
01100 };
01101
01102 //+-------------------------------------------------------------------------
01103 //
01104 //  This macro defines the registration/unregistration routines for the DLL.
01105 //
01106 //--------------------------------------------------------------------------
01107
01108 DEFINE_DLLREGISTERFILTER( smpHandler, smpFilter, asmpClasses )
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

FieldInfo Member List

This is the complete list of members for FieldInfo, including all inherited members.
autoinc | FieldInfo
fAutoUpdate | FieldInfo
fSearchable | FieldInfo
fUnsigned | FieldInfo
iField | FieldInfo
length | FieldInfo
nullable | FieldInfo
precision | FieldInfo
scale | FieldInfo
szFieldName | FieldInfo
szLength | FieldInfo
szParams | FieldInfo
szPrefix | FieldInfo
szSuffix | FieldInfo
szType | FieldInfo
wSQLType | FieldInfo
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/ADOVBS.inc Source File

  • Dataaccess
  • rds

ADOVBS.inc

Go to the documentation of this file.
00001 <%
00002 '--------------------------------------------------------------------
00003 ' Microsoft ADO
00004 '
00005 ' Copyright (c) 1996-1998 Microsoft Corporation.
00006 '
00007 '
00008 '
00009 ' ADO constants include file for VBScript
00010 '
00011 '--------------------------------------------------------------------
00012
00013 '---- CursorTypeEnum Values ----
00014 Const adOpenForwardOnly = 0
00015 Const adOpenKeyset = 1
00016 Const adOpenDynamic = 2
00017 Const adOpenStatic = 3
00018
00019 '---- CursorOptionEnum Values ----
00020 Const adHoldRecords = &H00000100
00021 Const adMovePrevious = &H00000200
00022 Const adAddNew = &H01000400
00023 Const adDelete = &H01000800
00024 Const adUpdate = &H01008000
00025 Const adBookmark = &H00002000
00026 Const adApproxPosition = &H00004000
00027 Const adUpdateBatch = &H00010000
00028 Const adResync = &H00020000
00029 Const adNotify = &H00040000
00030 Const adFind = &H00080000
00031 Const adSeek = &H00400000
00032 Const adIndex = &H00800000
00033
00034 '---- LockTypeEnum Values ----
00035 Const adLockReadOnly = 1
00036 Const adLockPessimistic = 2
00037 Const adLockOptimistic = 3
00038 Const adLockBatchOptimistic = 4
00039
00040 '---- ExecuteOptionEnum Values ----
00041 Const adAsyncExecute = &H00000010
00042 Const adAsyncFetch = &H00000020
00043 Const adAsyncFetchNonBlocking = &H00000040
00044 Const adExecuteNoRecords = &H00000080
00045 Const adExecuteStream = &H00000400
00046
00047 '---- ConnectOptionEnum Values ----
00048 Const adAsyncConnect = &H00000010
00049
00050 '---- ObjectStateEnum Values ----
00051 Const adStateClosed = &H00000000
00052 Const adStateOpen = &H00000001
00053 Const adStateConnecting = &H00000002
00054 Const adStateExecuting = &H00000004
00055 Const adStateFetching = &H00000008
00056
00057 '---- CursorLocationEnum Values ----
00058 Const adUseServer = 2
00059 Const adUseClient = 3
00060
00061 '---- DataTypeEnum Values ----
00062 Const adEmpty = 0
00063 Const adTinyInt = 16
00064 Const adSmallInt = 2
00065 Const adInteger = 3
00066 Const adBigInt = 20
00067 Const adUnsignedTinyInt = 17
00068 Const adUnsignedSmallInt = 18
00069 Const adUnsignedInt = 19
00070 Const adUnsignedBigInt = 21
00071 Const adSingle = 4
00072 Const adDouble = 5
00073 Const adCurrency = 6
00074 Const adDecimal = 14
00075 Const adNumeric = 131
00076 Const adBoolean = 11
00077 Const adError = 10
00078 Const adUserDefined = 132
00079 Const adVariant = 12
00080 Const adIDispatch = 9
00081 Const adIUnknown = 13
00082 Const adGUID = 72
00083 Const adDate = 7
00084 Const adDBDate = 133
00085 Const adDBTime = 134
00086 Const adDBTimeStamp = 135
00087 Const adBSTR = 8
00088 Const adChar = 129
00089 Const adVarChar = 200
00090 Const adLongVarChar = 201
00091 Const adWChar = 130
00092 Const adVarWChar = 202
00093 Const adLongVarWChar = 203
00094 Const adBinary = 128
00095 Const adVarBinary = 204
00096 Const adLongVarBinary = 205
00097 Const adChapter = 136
00098 Const adFileTime = 64
00099 Const adPropVariant = 138
00100 Const adVarNumeric = 139
00101 Const adArray = &H2000
00102
00103 '---- FieldAttributeEnum Values ----
00104 Const adFldMayDefer = &H00000002
00105 Const adFldUpdatable = &H00000004
00106 Const adFldUnknownUpdatable = &H00000008
00107 Const adFldFixed = &H00000010
00108 Const adFldIsNullable = &H00000020
00109 Const adFldMayBeNull = &H00000040
00110 Const adFldLong = &H00000080
00111 Const adFldRowID = &H00000100
00112 Const adFldRowVersion = &H00000200
00113 Const adFldCacheDeferred = &H00001000
00114 Const adFldIsChapter = &H00002000
00115 Const adFldNegativeScale = &H00004000
00116 Const adFldKeyColumn = &H00008000
00117 Const adFldIsRowURL = &H00010000
00118 Const adFldIsDefaultStream = &H00020000
00119 Const adFldIsCollection = &H00040000
00120
00121 '---- EditModeEnum Values ----
00122 Const adEditNone = &H0000
00123 Const adEditInProgress = &H0001
00124 Const adEditAdd = &H0002
00125 Const adEditDelete = &H0004
00126
00127 '---- RecordStatusEnum Values ----
00128 Const adRecOK = &H0000000
00129 Const adRecNew = &H0000001
00130 Const adRecModified = &H0000002
00131 Const adRecDeleted = &H0000004
00132 Const adRecUnmodified = &H0000008
00133 Const adRecInvalid = &H0000010
00134 Const adRecMultipleChanges = &H0000040
00135 Const adRecPendingChanges = &H0000080
00136 Const adRecCanceled = &H0000100
00137 Const adRecCantRelease = &H0000400
00138 Const adRecConcurrencyViolation = &H0000800
00139 Const adRecIntegrityViolation = &H0001000
00140 Const adRecMaxChangesExceeded = &H0002000
00141 Const adRecObjectOpen = &H0004000
00142 Const adRecOutOfMemory = &H0008000
00143 Const adRecPermissionDenied = &H0010000
00144 Const adRecSchemaViolation = &H0020000
00145 Const adRecDBDeleted = &H0040000
00146
00147 '---- GetRowsOptionEnum Values ----
00148 Const adGetRowsRest = -1
00149
00150 '---- PositionEnum Values ----
00151 Const adPosUnknown = -1
00152 Const adPosBOF = -2
00153 Const adPosEOF = -3
00154
00155 '---- BookmarkEnum Values ----
00156 Const adBookmarkCurrent = 0
00157 Const adBookmarkFirst = 1
00158 Const adBookmarkLast = 2
00159
00160 '---- MarshalOptionsEnum Values ----
00161 Const adMarshalAll = 0
00162 Const adMarshalModifiedOnly = 1
00163
00164 '---- AffectEnum Values ----
00165 Const adAffectCurrent = 1
00166 Const adAffectGroup = 2
00167 Const adAffectAllChapters = 4
00168
00169 '---- ResyncEnum Values ----
00170 Const adResyncUnderlyingValues = 1
00171 Const adResyncAllValues = 2
00172
00173 '---- CompareEnum Values ----
00174 Const adCompareLessThan = 0
00175 Const adCompareEqual = 1
00176 Const adCompareGreaterThan = 2
00177 Const adCompareNotEqual = 3
00178 Const adCompareNotComparable = 4
00179
00180 '---- FilterGroupEnum Values ----
00181 Const adFilterNone = 0
00182 Const adFilterPendingRecords = 1
00183 Const adFilterAffectedRecords = 2
00184 Const adFilterFetchedRecords = 3
00185 Const adFilterConflictingRecords = 5
00186
00187 '---- SearchDirectionEnum Values ----
00188 Const adSearchForward = 1
00189 Const adSearchBackward = -1
00190
00191 '---- PersistFormatEnum Values ----
00192 Const adPersistADTG = 0
00193 Const adPersistXML = 1
00194
00195 '---- StringFormatEnum Values ----
00196 Const adClipString = 2
00197
00198 '---- ConnectPromptEnum Values ----
00199 Const adPromptAlways = 1
00200 Const adPromptComplete = 2
00201 Const adPromptCompleteRequired = 3
00202 Const adPromptNever = 4
00203
00204 '---- ConnectModeEnum Values ----
00205 Const adModeUnknown = 0
00206 Const adModeRead = 1
00207 Const adModeWrite = 2
00208 Const adModeReadWrite = 3
00209 Const adModeShareDenyRead = 4
00210 Const adModeShareDenyWrite = 8
00211 Const adModeShareExclusive = &Hc
00212 Const adModeShareDenyNone = &H10
00213 Const adModeRecursive = &H400000
00214
00215 '---- RecordCreateOptionsEnum Values ----
00216 Const adCreateCollection = &H00002000
00217 Const adCreateStructDoc = &H80000000
00218 Const adCreateNonCollection = &H00000000
00219 Const adOpenIfExists = &H02000000
00220 Const adCreateOverwrite = &H04000000
00221 Const adFailIfNotExists = -1
00222
00223 '---- RecordOpenOptionsEnum Values ----
00224 Const adOpenRecordUnspecified = -1
00225 Const adOpenSource = &H00800000
00226 Const adOpenAsync = &H00001000
00227 Const adDelayFetchStream = &H00004000
00228 Const adDelayFetchFields = &H00008000
00229 Const adOpenExecuteCommand = &H00010000
00230
00231 '---- IsolationLevelEnum Values ----
00232 Const adXactUnspecified = &Hffffffff
00233 Const adXactChaos = &H00000010
00234 Const adXactReadUncommitted = &H00000100
00235 Const adXactBrowse = &H00000100
00236 Const adXactCursorStability = &H00001000
00237 Const adXactReadCommitted = &H00001000
00238 Const adXactRepeatableRead = &H00010000
00239 Const adXactSerializable = &H00100000
00240 Const adXactIsolated = &H00100000
00241
00242 '---- XactAttributeEnum Values ----
00243 Const adXactCommitRetaining = &H00020000
00244 Const adXactAbortRetaining = &H00040000
00245
00246 '---- PropertyAttributesEnum Values ----
00247 Const adPropNotSupported = &H0000
00248 Const adPropRequired = &H0001
00249 Const adPropOptional = &H0002
00250 Const adPropRead = &H0200
00251 Const adPropWrite = &H0400
00252
00253 '---- ErrorValueEnum Values ----
00254 Const adErrProviderFailed = &Hbb8
00255 Const adErrInvalidArgument = &Hbb9
00256 Const adErrOpeningFile = &Hbba
00257 Const adErrReadFile = &Hbbb
00258 Const adErrWriteFile = &Hbbc
00259 Const adErrNoCurrentRecord = &Hbcd
00260 Const adErrIllegalOperation = &Hc93
00261 Const adErrCantChangeProvider = &Hc94
00262 Const adErrInTransaction = &Hcae
00263 Const adErrFeatureNotAvailable = &Hcb3
00264 Const adErrItemNotFound = &Hcc1
00265 Const adErrObjectInCollection = &Hd27
00266 Const adErrObjectNotSet = &Hd5c
00267 Const adErrDataConversion = &Hd5d
00268 Const adErrObjectClosed = &He78
00269 Const adErrObjectOpen = &He79
00270 Const adErrProviderNotFound = &He7a
00271 Const adErrBoundToCommand = &He7b
00272 Const adErrInvalidParamInfo = &He7c
00273 Const adErrInvalidConnection = &He7d
00274 Const adErrNotReentrant = &He7e
00275 Const adErrStillExecuting = &He7f
00276 Const adErrOperationCancelled = &He80
00277 Const adErrStillConnecting = &He81
00278 Const adErrInvalidTransaction = &He82
00279 Const adErrUnsafeOperation = &He84
00280 Const adwrnSecurityDialog = &He85
00281 Const adwrnSecurityDialogHeader = &He86
00282 Const adErrIntegrityViolation = &He87
00283 Const adErrPermissionDenied = &He88
00284 Const adErrDataOverflow = &He89
00285 Const adErrSchemaViolation = &He8a
00286 Const adErrSignMismatch = &He8b
00287 Const adErrCantConvertvalue = &He8c
00288 Const adErrCantCreate = &He8d
00289 Const adErrColumnNotOnThisRow = &He8e
00290 Const adErrURLIntegrViolSetColumns = &He8f
00291 Const adErrURLDoesNotExist = &He8f
00292 Const adErrTreePermissionDenied = &He90
00293 Const adErrInvalidURL = &He91
00294 Const adErrResourceLocked = &He92
00295 Const adErrResourceExists = &He93
00296 Const adErrCannotComplete = &He94
00297 Const adErrVolumeNotFound = &He95
00298 Const adErrOutOfSpace = &He96
00299 Const adErrResourceOutOfScope = &He97
00300 Const adErrUnavailable = &He98
00301 Const adErrURLNamedRowDoesNotExist = &He99
00302 Const adErrDelResOutOfScope = &He9a
00303 Const adErrPropInvalidColumn = &He9b
00304 Const adErrPropInvalidOption = &He9c
00305 Const adErrPropInvalidValue = &He9d
00306 Const adErrPropConflicting = &He9e
00307 Const adErrPropNotAllSettable = &He9f
00308 Const adErrPropNotSet = &Hea0
00309 Const adErrPropNotSettable = &Hea1
00310 Const adErrPropNotSupported = &Hea2
00311 Const adErrCatalogNotSet = &Hea3
00312 Const adErrCantChangeConnection = &Hea4
00313 Const adErrFieldsUpdateFailed = &Hea5
00314 Const adErrDenyNotSupported = &Hea6
00315 Const adErrDenyTypeNotSupported = &Hea7
00316
00317 '---- ParameterAttributesEnum Values ----
00318 Const adParamSigned = &H0010
00319 Const adParamNullable = &H0040
00320 Const adParamLong = &H0080
00321
00322 '---- ParameterDirectionEnum Values ----
00323 Const adParamUnknown = &H0000
00324 Const adParamInput = &H0001
00325 Const adParamOutput = &H0002
00326 Const adParamInputOutput = &H0003
00327 Const adParamReturnValue = &H0004
00328
00329 '---- CommandTypeEnum Values ----
00330 Const adCmdUnknown = &H0008
00331 Const adCmdText = &H0001
00332 Const adCmdTable = &H0002
00333 Const adCmdStoredProc = &H0004
00334 Const adCmdFile = &H0100
00335 Const adCmdTableDirect = &H0200
00336
00337 '---- EventStatusEnum Values ----
00338 Const adStatusOK = &H0000001
00339 Const adStatusErrorsOccurred = &H0000002
00340 Const adStatusCantDeny = &H0000003
00341 Const adStatusCancel = &H0000004
00342 Const adStatusUnwantedEvent = &H0000005
00343
00344 '---- EventReasonEnum Values ----
00345 Const adRsnAddNew = 1
00346 Const adRsnDelete = 2
00347 Const adRsnUpdate = 3
00348 Const adRsnUndoUpdate = 4
00349 Const adRsnUndoAddNew = 5
00350 Const adRsnUndoDelete = 6
00351 Const adRsnRequery = 7
00352 Const adRsnResynch = 8
00353 Const adRsnClose = 9
00354 Const adRsnMove = 10
00355 Const adRsnFirstChange = 11
00356 Const adRsnMoveFirst = 12
00357 Const adRsnMoveNext = 13
00358 Const adRsnMovePrevious = 14
00359 Const adRsnMoveLast = 15
00360
00361 '---- SchemaEnum Values ----
00362 Const adSchemaProviderSpecific = -1
00363 Const adSchemaAsserts = 0
00364 Const adSchemaCatalogs = 1
00365 Const adSchemaCharacterSets = 2
00366 Const adSchemaCollations = 3
00367 Const adSchemaColumns = 4
00368 Const adSchemaCheckConstraints = 5
00369 Const adSchemaConstraintColumnUsage = 6
00370 Const adSchemaConstraintTableUsage = 7
00371 Const adSchemaKeyColumnUsage = 8
00372 Const adSchemaReferentialConstraints = 9
00373 Const adSchemaTableConstraints = 10
00374 Const adSchemaColumnsDomainUsage = 11
00375 Const adSchemaIndexes = 12
00376 Const adSchemaColumnPrivileges = 13
00377 Const adSchemaTablePrivileges = 14
00378 Const adSchemaUsagePrivileges = 15
00379 Const adSchemaProcedures = 16
00380 Const adSchemaSchemata = 17
00381 Const adSchemaSQLLanguages = 18
00382 Const adSchemaStatistics = 19
00383 Const adSchemaTables = 20
00384 Const adSchemaTranslations = 21
00385 Const adSchemaProviderTypes = 22
00386 Const adSchemaViews = 23
00387 Const adSchemaViewColumnUsage = 24
00388 Const adSchemaViewTableUsage = 25
00389 Const adSchemaProcedureParameters = 26
00390 Const adSchemaForeignKeys = 27
00391 Const adSchemaPrimaryKeys = 28
00392 Const adSchemaProcedureColumns = 29
00393 Const adSchemaDBInfoKeywords = 30
00394 Const adSchemaDBInfoLiterals = 31
00395 Const adSchemaCubes = 32
00396 Const adSchemaDimensions = 33
00397 Const adSchemaHierarchies = 34
00398 Const adSchemaLevels = 35
00399 Const adSchemaMeasures = 36
00400 Const adSchemaProperties = 37
00401 Const adSchemaMembers = 38
00402 Const adSchemaTrustees = 39
00403
00404 '---- FieldStatusEnum Values ----
00405 Const adFieldOK = 0
00406 Const adFieldCantConvertValue = 2
00407 Const adFieldIsNull = 3
00408 Const adFieldTruncated = 4
00409 Const adFieldSignMismatch = 5
00410 Const adFieldDataOverflow = 6
00411 Const adFieldCantCreate = 7
00412 Const adFieldUnavailable = 8
00413 Const adFieldPermissionDenied = 9
00414 Const adFieldIntegrityViolation = 10
00415 Const adFieldSchemaViolation = 11
00416 Const adFieldBadStatus = 12
00417 Const adFieldDefault = 13
00418 Const adFieldIgnore = 15
00419 Const adFieldDoesNotExist = 16
00420 Const adFieldInvalidURL = 17
00421 Const adFieldResourceLocked = 18
00422 Const adFieldResourceExists = 19
00423 Const adFieldCannotComplete = 20
00424 Const adFieldVolumeNotFound = 21
00425 Const adFieldOutOfSpace = 22
00426 Const adFieldCannotDeleteSource = 23
00427 Const adFieldReadOnly = 24
00428 Const adFieldResourceOutOfScope = 25
00429 Const adFieldAlreadyExists = 26
00430 Const adFieldPendingInsert = &H10000
00431 Const adFieldPendingDelete = &H20000
00432 Const adFieldPendingChange = &H40000
00433 Const adFieldPendingUnknown = &H80000
00434 Const adFieldPendingUnknownDelete = &H100000
00435
00436 '---- SeekEnum Values ----
00437 Const adSeekFirstEQ = &H1
00438 Const adSeekLastEQ = &H2
00439 Const adSeekAfterEQ = &H4
00440 Const adSeekAfter = &H8
00441 Const adSeekBeforeEQ = &H10
00442 Const adSeekBefore = &H20
00443
00444 '---- ADCPROP_UPDATECRITERIA_ENUM Values ----
00445 Const adCriteriaKey = 0
00446 Const adCriteriaAllCols = 1
00447 Const adCriteriaUpdCols = 2
00448 Const adCriteriaTimeStamp = 3
00449
00450 '---- ADCPROP_ASYNCTHREADPRIORITY_ENUM Values ----
00451 Const adPriorityLowest = 1
00452 Const adPriorityBelowNormal = 2
00453 Const adPriorityNormal = 3
00454 Const adPriorityAboveNormal = 4
00455 Const adPriorityHighest = 5
00456
00457 '---- ADCPROP_AUTORECALC_ENUM Values ----
00458 Const adRecalcUpFront = 0
00459 Const adRecalcAlways = 1
00460
00461 '---- ADCPROP_UPDATERESYNC_ENUM Values ----
00462
00463 '---- ADCPROP_UPDATERESYNC_ENUM Values ----
00464
00465 '---- MoveRecordOptionsEnum Values ----
00466 Const adMoveUnspecified = -1
00467 Const adMoveOverWrite = 1
00468 Const adMoveDontUpdateLinks = 2
00469 Const adMoveAllowEmulation = 4
00470
00471 '---- CopyRecordOptionsEnum Values ----
00472 Const adCopyUnspecified = -1
00473 Const adCopyOverWrite = 1
00474 Const adCopyAllowEmulation = 4
00475 Const adCopyNonRecursive = 2
00476
00477 '---- StreamTypeEnum Values ----
00478 Const adTypeBinary = 1
00479 Const adTypeText = 2
00480
00481 '---- LineSeparatorEnum Values ----
00482 Const adLF = 10
00483 Const adCR = 13
00484 Const adCRLF = -1
00485
00486 '---- StreamOpenOptionsEnum Values ----
00487 Const adOpenStreamUnspecified = -1
00488 Const adOpenStreamAsync = 1
00489 Const adOpenStreamFromRecord = 4
00490
00491 '---- StreamWriteEnum Values ----
00492 Const adWriteChar = 0
00493 Const adWriteLine = 1
00494
00495 '---- SaveOptionsEnum Values ----
00496 Const adSaveCreateNotExist = 1
00497 Const adSaveCreateOverWrite = 2
00498
00499 '---- FieldEnum Values ----
00500 Const adDefaultStream = -1
00501 Const adRecordURL = -2
00502
00503 '---- StreamReadEnum Values ----
00504 Const adReadAll = -1
00505 Const adReadLine = -2
00506
00507 '---- RecordTypeEnum Values ----
00508 Const adSimpleRecord = 0
00509 Const adCollectionRecord = 1
00510 Const adStructDoc = 2
00511 %>
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

qcorder::Order Member List

This is the complete list of members for qcorder::Order, including all inherited members.
customerID | qcorder::Order | [private]
iid | qcorder::IOrderDefault | [static]
InvokeShip() | qcorder::Order | [inline, private]
itemVect | qcorder::Order | [private]
LineItem(int itemID, int quantity) | qcorder::Order | [inline]
Order() | qcorder::Order | [inline]
orderID | qcorder::Order | [private]
Process(int lFlags) | qcorder::Order | [inline]
quantityVect | qcorder::Order | [private]
setCustomerId(int customerID) | qcorder::Order | [inline]
setOrderId(int orderID) | qcorder::Order | [inline]
WriteOrderDB() | qcorder::Order | [inline, private]
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenuex/tracemacro.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenuex

tracemacro.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "TraceMacro.h"
00017 #include <StdIo.h>             // Needed for sprintf on Win98
00018
00019
00020 //---------------------------------------------------------------------------
00021 //  Function implementations
00022 //
00023
00024 //---------------------------------------------------------------------------
00025 //  Provides trace output for HRESULTs in hex.
00026 //
00027 VOID Trace_HR
00028 (
00029   LPCTSTR pszClass,        //[in] Class name for message
00030   LPCTSTR pszFunction,     //[in] Function name for message
00031   HRESULT hr               //[in] HRESULT to display as a value
00032 )
00033 {
00034 #ifdef _DEBUG
00035
00036   TCHAR  szBuffer[512];
00037   TCHAR  szFormat[] = _T("%s::%s-> Returned 0x%X\n");
00038   INT    nChars     = 0;
00039
00040   nChars = _stprintf( szBuffer, szFormat, pszClass, pszFunction, hr );
00041   _ASSERTE( nChars < sizeof(szBuffer) );
00042
00043   OutputDebugString( szBuffer );
00044
00045 #endif
00046 } //end Trace_HR()
00047
00048
00049 //---------------------------------------------------------------------------
00050 //  Provides trace output for user defined numeric values in the form:
00051 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00052 //
00053 VOID Trace_Value
00054 (
00055   LPCTSTR pszClass,        //[in] Class name for message
00056   LPCTSTR pszFunction,     //[in] Function name for message
00057   LPCTSTR pszValueName,    //[in] Value name for message
00058   LONG    nValue           //[in] Numeric value for message
00059 )
00060 {
00061 #ifdef _DEBUG
00062
00063   TCHAR  szBuffer[512];
00064   TCHAR  szFormat[] = _T("%s::%s-> %s = %u\n");
00065   INT    nChars     = 0;
00066
00067   nChars = _stprintf( szBuffer,
00068                       szFormat,
00069                       pszClass,
00070                       pszFunction,
00071                       pszValueName,
00072                       nValue
00073                     );
00074   _ASSERTE( nChars < sizeof(szBuffer) );
00075
00076   OutputDebugString( szBuffer );
00077
00078 #endif
00079 } //end Trace_Value()
00080
00081
00082 //---------------------------------------------------------------------------
00083 //  Provides trace output which shows the class name, function name, and
00084 //  a string which maps to an MMC notification.
00085 //
00086 VOID Trace_Event
00087 (
00088   LPCTSTR pszClass,        //[in] Class name for message
00089   LPCTSTR pszFunction,     //[in] Event name for message
00090   LONG    nEvent           //[in] Event code to map to string
00091 )
00092 {
00093 #ifdef _DEBUG
00094
00095   TCHAR  szEventStr[22];
00096   TCHAR  szBuffer[512];
00097   TCHAR  szFormat[] = _T("%s::%s-> Event = %s\n");
00098   INT    nChars     = 0;
00099
00100   MapEvent( nEvent, szEventStr );
00101
00102   nChars = _stprintf( szBuffer,
00103                       szFormat,
00104                       pszClass,
00105                       pszFunction,
00106                       szEventStr
00107                     );
00108   _ASSERTE( nChars < sizeof(szBuffer) );
00109
00110   OutputDebugString( szBuffer );
00111
00112 #endif
00113 } //end Trace_Event()
00114
00115 //---------------------------------------------------------------------------
00116 //  Provides trace output which shows the class name and function name
00117 //
00118 VOID Trace_Start
00119 (
00120   LPCTSTR pszClass,        //[in] Class name for message
00121   LPCTSTR pszFunction      //[in] Event name for message
00122 )
00123 {
00124 #ifdef _DEBUG
00125
00126   TCHAR  szBuffer[512];
00127   TCHAR  szFormat[] = _T("%s::%s-> Started \n");
00128   INT    nChars     = 0;
00129
00130   nChars = _stprintf( szBuffer,
00131                       szFormat,
00132                       pszClass,
00133                       pszFunction
00134                     );
00135   _ASSERTE( nChars < sizeof(szBuffer) );
00136
00137   OutputDebugString( szBuffer );
00138
00139 #endif
00140 } //end Trace_Start()
00141
00142
00143
00144 //---------------------------------------------------------------------------
00145 // Provides human readable output for notifications
00146 //
00147 VOID MapEvent( LONG Event, LPTSTR szEventStr )
00148 {
00149 #ifdef _DEBUG
00150
00151   switch( Event )
00152   {
00153     case 0x8001:
00154       _tcscpy( szEventStr, _T("MMCN_ACTIVATE       ") );
00155       break;
00156
00157     case 0x8002:
00158       _tcscpy( szEventStr, _T("MMCN_ADD_IMAGES     ") );
00159       break;
00160
00161     case 0x8003:
00162       _tcscpy( szEventStr, _T("MMCN_BTN_CLICK      ") );
00163       break;
00164
00165     case 0x8004:
00166       _tcscpy( szEventStr, _T("MMCN_CLICK          ") );
00167       break;
00168
00169     case 0x8005:
00170       _tcscpy( szEventStr, _T("MMCN_COLUMN_CLICK   ") );
00171       break;
00172
00173     case 0x8006:
00174       _tcscpy( szEventStr, _T("MMCN_CONTEXTMENU    ") );
00175       break;
00176
00177     case 0x8007:
00178       _tcscpy( szEventStr, _T("MMCN_CUTORMOVE      ") );
00179       break;
00180
00181     case 0x8008:
00182       _tcscpy( szEventStr, _T("MMCN_DBLCLICK       ") );
00183       break;
00184
00185     case 0x8009:
00186       _tcscpy( szEventStr, _T("MMCN_DELETE         ") );
00187       break;
00188
00189     case 0x800A:
00190       _tcscpy( szEventStr, _T("MMCN_DESELECT_ALL   ") );
00191       break;
00192
00193     case 0x800B:
00194       _tcscpy( szEventStr, _T("MMCN_EXPAND         ") );
00195       break;
00196
00197     case 0x800C:
00198       _tcscpy( szEventStr, _T("MMCN_HELP           ") );
00199       break;
00200
00201     case 0x800D:
00202       _tcscpy( szEventStr, _T("MMCN_MENU_BTNCLICK  ") );
00203       break;
00204
00205     case 0x800E:
00206       _tcscpy( szEventStr, _T("MMCN_MINIMIZED      ") );
00207       break;
00208
00209     case 0x800F:
00210       _tcscpy( szEventStr, _T("MMCN_PASTE          ") );
00211       break;
00212
00213     case 0x8010:
00214       _tcscpy( szEventStr, _T("MMCN_PROPERTY_CHANGE") );
00215       break;
00216
00217     case 0x8011:
00218       _tcscpy( szEventStr, _T("MMCN_QUERY_PASTE    ") );
00219       break;
00220
00221     case 0x8012:
00222       _tcscpy( szEventStr, _T("MMCN_REFRESH        ") );
00223       break;
00224
00225     case 0x8013:
00226       _tcscpy( szEventStr, _T("MMCN_REMOVE_CHILDREN") );
00227       break;
00228
00229     case 0x8014:
00230       _tcscpy( szEventStr, _T("MMCN_RENAME         ") );
00231       break;
00232
00233     case 0x8015:
00234       _tcscpy( szEventStr, _T("MMCN_SELECT         ") );
00235       break;
00236
00237     case 0x8016:
00238       _tcscpy( szEventStr, _T("MMCN_SHOW           ") );
00239       break;
00240
00241     case 0x8017:
00242       _tcscpy( szEventStr, _T("MMCN_VIEW_CHANGE    ") );
00243       break;
00244
00245     case 0x8018:
00246       _tcscpy( szEventStr, _T("MMCN_SNAPINHELP     ") );
00247       break;
00248
00249     case 0x8019:
00250       _tcscpy( szEventStr, _T("MMCN_CONTEXTHELP    ") );
00251       break;
00252
00253     case 0x801A:
00254       _tcscpy( szEventStr, _T("MMCN_INITOCX        ") );
00255       break;
00256
00257     case 0x8021:
00258       _tcscpy( szEventStr, _T("MMCN_EXPANDSYNC     ") );
00259       break;
00260
00261     default:
00262       _stprintf( szEventStr, _T("0x%X"), Event );
00263       break;
00264   }
00265
00266 #endif
00267 } //end MapEvent()
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSCPWizApp Member List

This is the complete list of members for CSCPWizApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CWinApp() | CWinApp |
ExitInstance() | CSCPWizApp | [virtual]
InitInstance() | CSCPWizApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:57:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/LocatDlg.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

LocatDlg.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // LocatDlg.cpp : implementation file
00013 //
00014
00015
00016
00017 #include "stdafx.h"
00018 #include "MQApitst.h"
00019 #include "LocatDlg.h"
00020
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // CLocateDialog dialog
00029
00030
00031 CLocateDialog::CLocateDialog(CWnd* pParent /*=NULL*/)
00032   : CDialog(CLocateDialog::IDD, pParent)
00033 {
00034   //{{AFX_DATA_INIT(CLocateDialog)
00035   m_szLabel = TEXT("MQ API test");
00036   //}}AFX_DATA_INIT
00037 }
00038
00039
00040 void CLocateDialog::DoDataExchange(CDataExchange* pDX)
00041 {
00042   CDialog::DoDataExchange(pDX);
00043   //{{AFX_DATA_MAP(CLocateDialog)
00044   DDX_Text(pDX, IDC_LOCATE_LABEL, m_szLabel);
00045   DDV_MaxChars(pDX, m_szLabel, 128);
00046   //}}AFX_DATA_MAP
00047 }
00048
00049
00050 BEGIN_MESSAGE_MAP(CLocateDialog, CDialog)
00051   //{{AFX_MSG_MAP(CLocateDialog)
00052     // NOTE: the ClassWizard will add message map macros here
00053   //}}AFX_MSG_MAP
00054 END_MESSAGE_MAP()
00055
00056 /////////////////////////////////////////////////////////////////////////////
00057 // CLocateDialog message handlers
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/DLEdit/DLEdit.Cpp Source File

  • WinBase
  • IO
  • DLEdit

DLEdit.Cpp

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2001 Microsoft Corporation.  All rights reserved.
00008
00009 DLEDIT  -- Drive Letter Assignment Editor
00010
00011 This program demonstrates how to add or remove persistent drive letter
00012 assignments in Windows 2000, Windows XP, and Windows Server 2003.  These
00013 drive letter assignments persist through machine reboots.
00014
00015 Platforms:
00016    This program requires Windows 2000 or later.
00017
00018 Command-line syntax:
00019    DLEDIT <drive letter> <NT device name>      -- Adds persistent drive letter
00020    DLEDIT -t <drive letter> <NT device name>   -- Adds temporary drive letter
00021    DLEDIT -r <drive letter>                    -- Removes a drive letter
00022    DLEDIT <drive letter>                       -- Shows drive letter mapping
00023    DLEDIT -a                                   -- Shows all drive letter mappings
00024
00025 Command-line examples:
00026
00027    Say that E: refers to CD-ROM drive, and you want to make F: point to that
00028    CD-ROM drive instead.  Use the following two commands:
00029
00030       DLEDIT -r E:\
00031       DLEDIT F:\ \Device\CdRom0
00032
00033    To display what device a drive letter is mapped to, use the following
00034    command:
00035
00036       DLEDIT f:
00037
00038
00039 *******************************************************************************
00040 WARNING: WARNING: WARNING: WARNING: WARNING: WARNING: WARNING: WARNING:
00041
00042    This program really will change drive letter assignments, and the changes
00043    persist through reboots.  Do not remove drive letters of your hard disks if
00044    you don't have this program on a floppy disk or you might not be able to
00045    access your hard disks again!
00046 *******************************************************************************
00047
00048 -----------------------------------------------------------------------------*/
00049
00050 #define UNICODE
00051 #define _UNICODE
00052
00053 /* reduce number of headers pulled in by windows.h to improve build time */
00054 #define WIN32_LEAN_AND_MEAN
00055
00056 #include <windows.h>
00057 #include <winioctl.h>
00058 #include <TCHAR.H>
00059 #include <stdio.h>
00060
00061
00062 /*-----------------------------------------------------------------------------*/
00063 #define GPT_BASIC_DATA_ATTRIBUTE_HIDDEN  (0x4000000000000000) // from DDK's NTDDDISK.H
00064
00065 #define IOCTL_VOLUME_GET_GPT_ATTRIBUTES CTL_CODE(IOCTL_VOLUME_BASE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
00066
00067 typedef struct _VOLUME_GET_GPT_ATTRIBUTES_INFORMATION {
00068     ULONGLONG   GptAttributes;
00069 } VOLUME_GET_GPT_ATTRIBUTES_INFORMATION, *PVOLUME_GET_GPT_ATTRIBUTES_INFORMATION;
00070
00071 /*-----------------------------------------------------------------------------*/
00072
00073
00074 #define HIDDEN_PARTITION_FLAG 0x10
00075
00076
00077 /* Private error codes.  Follows guidelines in winerror.h */
00078 const DWORD PRIV_ERROR_DRIVE_LETTER_IN_USE      = 0xE0000001;
00079 //const DWORD PRIV_ERROR_DRIVE_LETTER_NOT_USED    = 0xE0000002;
00080 const DWORD PRIV_ERROR_PARTITION_HIDDEN         = 0x60000001;
00081 const DWORD PRIV_ERROR_PARTITION_NOT_RECOGNIZED = 0x60000002;
00082 //const DWORD PRIV_ERROR_NOT_PARTITIONABLE_DEVICE = 0x60000003;
00083
00084
00085
00086 BOOL WINAPI AssignPersistentDriveLetter (LPCTSTR pszDriveLetter, LPCTSTR pszDeviceName);
00087 BOOL WINAPI RemovePersistentDriveLetter (LPCTSTR pszDriveLetter);
00088 BOOL WINAPI AssignTemporaryDriveLetter (LPCTSTR pszDriveLetter, LPCTSTR pszDeviceName);
00089 BOOL WINAPI RemoveTemporaryDriveLetter (LPCTSTR pszDriveLetter);
00090
00091 BOOL WINAPI IsPartitionHidden (BYTE partitionType, ULONGLONG partitionAttribs);
00092 BOOL WINAPI IsDriveLetter (LPCTSTR pszDriveLetter);
00093 BOOL WINAPI IsWindowsXP_orLater (void);
00094
00095
00096 static void PrintHelp (LPCTSTR pszAppName);
00097
00098
00099 /*-----------------------------------------------------------------------------
00100 main( IN argc, IN argv )
00101
00102 Parameters
00103    argc
00104       Count of the command-line arguments
00105    argv
00106       Array of pointers to the individual command-line arguments
00107
00108 This function is the main program.  It parses the command-line arguments and
00109 performs the work of either removing a drive letter or adding a new one.
00110 -----------------------------------------------------------------------------*/
00111 extern "C"
00112 void _tmain (int argc, TCHAR **argv)
00113 {
00114    TCHAR * pszDriveLetter,
00115         * pszNTDevice,
00116         * pszOptions;
00117
00118    /*
00119       Command-line parsing.
00120          1) Validate arguments
00121          2) Determine what user wants to do
00122    */
00123    if (3 == argc && !lstrcmpi (argv[1], _T("-r")) && IsDriveLetter (argv[2]))
00124    {
00125       /*
00126             User wants to remove the drive letter.  Command line should be:
00127                dledit -r <drive letter>
00128       */
00129       pszOptions       = argv[1];
00130       pszDriveLetter   = argv[2];
00131       pszNTDevice      = NULL;
00132
00133       if (!RemovePersistentDriveLetter (pszDriveLetter))
00134       {
00135          if (!RemoveTemporaryDriveLetter (pszDriveLetter))
00136          {
00137             switch (GetLastError())
00138             {
00139             case ERROR_FILE_NOT_FOUND:
00140                _tprintf(_T("%s is not in use\n"), pszDriveLetter);
00141                break;
00142
00143             default:
00144                _tprintf(_T("error %lu: couldn't remove %s\n"),
00145                      GetLastError(), pszDriveLetter);
00146             }
00147          }
00148       }
00149
00150    } /* End if remove drive letter mapping */
00151
00152    else if (3 == argc && IsDriveLetter (argv[1]))
00153    {
00154       /*
00155          User wants to add a persistent drive letter.  Command line should be:
00156             dledit <drive letter> <NT device name>
00157       */
00158       pszOptions       = NULL;
00159       pszDriveLetter   = argv[1];
00160       pszNTDevice      = argv[2];
00161
00162       /*
00163          Try a persistent drive letter; if partition is hidden, the persistent
00164          mapping will fail--try a temporary mapping and tell user about it.
00165
00166          Note: Hidden partitions can be assigned temporary drive letters.
00167          These are nothing more than symbolic links created with
00168          DefineDosDevice.  Temporary drive letters will be removed when the
00169          system is rebooted.
00170       */
00171       if (!AssignPersistentDriveLetter (pszDriveLetter, pszNTDevice))
00172       {
00173          switch (GetLastError())
00174          {
00175          case PRIV_ERROR_PARTITION_HIDDEN:
00176             if (AssignTemporaryDriveLetter (pszDriveLetter, pszNTDevice))
00177                _tprintf(_T("%s is hidden; mapped %s temporarily\n"),
00178                         pszNTDevice, pszDriveLetter);
00179             else
00180                _tprintf(_T("%s is hidden; couldn't map %s to it\n"),
00181                         pszNTDevice, pszDriveLetter);
00182             break;
00183
00184          case PRIV_ERROR_DRIVE_LETTER_IN_USE:
00185             _tprintf(_T("%s is in use, can't map it to %s\n"),
00186                      pszDriveLetter, pszNTDevice);
00187             break;
00188
00189          case ERROR_FILE_NOT_FOUND:
00190             _tprintf(_T("%s doesn't exist or can't be opened\n"),
00191                      pszNTDevice);
00192             break;
00193
00194          case ERROR_INVALID_PARAMETER:
00195             _tprintf(_T("%s already has a drive letter; can't map %s to it\n"),
00196                      pszNTDevice, pszDriveLetter);
00197             break;
00198
00199          default:
00200             _tprintf(_T("error %lu: couldn't map %s to %s\n"),
00201                   GetLastError(), pszDriveLetter, pszNTDevice);
00202          }
00203       }
00204    } /* End if add persistent drive letter mapping */
00205
00206    else if (4 == argc && !lstrcmpi (argv[1], _T("-t")) && IsDriveLetter (argv[2]))
00207    {
00208       /*
00209          User wants to add a temporary drive letter.  Command line should be:
00210             dledit -t <drive letter> <NT device name>
00211       */
00212       pszOptions       = argv[1];
00213       pszDriveLetter   = argv[2];
00214       pszNTDevice      = argv[3];
00215
00216       if (!AssignTemporaryDriveLetter (pszDriveLetter, pszNTDevice))
00217       {
00218          switch (GetLastError())
00219          {
00220           case ERROR_FILE_NOT_FOUND:
00221             _tprintf(_T("%s doesn't exist or can't be opened\n"),
00222                      pszNTDevice);
00223             break;
00224
00225           case PRIV_ERROR_DRIVE_LETTER_IN_USE:
00226             _tprintf(_T("%s is in use, can't map it to %s\n"),
00227                      pszDriveLetter, pszNTDevice);
00228             break;
00229
00230          default:
00231             _tprintf(_T("error %lu: couldn't map %s to %s\n"),
00232                      GetLastError(), pszDriveLetter, pszNTDevice);
00233          }
00234       }
00235    } /* End if add temporary drive letter mapping */
00236
00237    else if (2 == argc && IsDriveLetter (argv[1]))
00238    {
00239       /*
00240          User wants to show what device is connected to the drive letter.
00241          Command line should be:
00242             dledit <drive letter>
00243       */
00244       pszOptions       = NULL;
00245       pszDriveLetter   = argv[1];
00246       pszNTDevice      = NULL;
00247
00248       TCHAR szNtDeviceName[MAX_PATH];
00249       TCHAR szDriveLetter[3];
00250
00251       /*
00252          Command-line argument for the drive letter could be in one of two
00253          formats:  C:\ or C:.  We normalize this to C: for QueryDosDevice.
00254       */
00255       szDriveLetter[0] = pszDriveLetter[0];
00256       szDriveLetter[1] = _T(':');
00257       szDriveLetter[2] = _T('\0');
00258
00259       if (QueryDosDevice (szDriveLetter, szNtDeviceName, MAX_PATH))
00260       {
00261          _tprintf(_T("%s is mapped to %s\n"), szDriveLetter, szNtDeviceName);
00262       }
00263       else
00264       {
00265          switch (GetLastError())
00266          {
00267          case ERROR_FILE_NOT_FOUND:
00268             _tprintf(_T("%s is not in use\n"), pszDriveLetter);
00269             break;
00270
00271          default:
00272             _tprintf(_T("error %lu: couldn't get mapping for %s\n"),
00273                      GetLastError(), pszDriveLetter);
00274          }
00275       }
00276
00277    } /* End if show drive letter mapping */
00278
00279    else if (2 == argc && !lstrcmpi (argv[1], _T("-a")))
00280    {
00281       /*
00282          User wants to show all mappings of drive letters to their respective
00283          devices.  Command line should be:
00284             dledit -a
00285       */
00286       pszOptions       = argv[1];
00287       pszDriveLetter   = NULL;
00288       pszNTDevice      = NULL;
00289
00290       /*
00291          Largest possible array of drive strings is 26 drive letters
00292          times 4 chars per drive letter plus 1 for the terminating NULL
00293        */
00294       const DWORD MAX_DRIVE_STRING_LENGTH = 26 * 4 + 1;
00295
00296       TCHAR szDriveStrings[MAX_DRIVE_STRING_LENGTH];
00297       DWORD cchDriveStrings;
00298
00299
00300       /*
00301          Get a list of all current drive letters, then for each, print the
00302          mapping.  Drive letters are returned in the form
00303          A:<NULL>B:<NULL>C:<NULL>...<NULL>.
00304       */
00305       cchDriveStrings = GetLogicalDriveStrings (MAX_DRIVE_STRING_LENGTH, szDriveStrings);
00306       if ( (0 != cchDriveStrings) && (cchDriveStrings <= MAX_DRIVE_STRING_LENGTH) )
00307       {
00308          TCHAR * pszCurrentDriveLetter;
00309          TCHAR szNtDeviceName[MAX_PATH];
00310          TCHAR szDriveLetter[3];
00311
00312
00313          _tprintf(_T("Drive     Device\n")
00314                   _T("-----     ------\n"));
00315
00316          pszCurrentDriveLetter = szDriveStrings;
00317          while (_T('\0') != *pszCurrentDriveLetter)
00318          {
00319             /* QueryDosDevice requires drive letters in the format X: */
00320             szDriveLetter[0] = pszCurrentDriveLetter[0];
00321             szDriveLetter[1] = _T(':');
00322             szDriveLetter[2] = _T('\0');
00323
00324             if (QueryDosDevice (szDriveLetter, szNtDeviceName, MAX_PATH))
00325                _tprintf(_T("%-10s%s\n"), szDriveLetter, szNtDeviceName);
00326
00327             pszCurrentDriveLetter += 4; /* size of X:<NULL> */
00328          }
00329       }
00330       else
00331       {
00332          _tprintf(_T("couldn't list drive letters and their devices\n"));
00333       }
00334    }  /* End if show all drive letter mappings */
00335
00336    else
00337    {
00338       /* User has selected an invalid operation--display help. */
00339       PrintHelp (argv[0]);
00340    }
00341 }
00342
00343
00344 /*-----------------------------------------------------------------------------
00345 PrintHelp( IN pszAppName )
00346
00347 Parameters
00348    pszAppName
00349       The name of the executable.  Used in displaying the help for this app.
00350
00351 Prints the command-line usage help.
00352 -----------------------------------------------------------------------------*/
00353 static void PrintHelp (LPCTSTR pszAppName)
00354 {
00355    _tprintf(_T("Adds, removes, queries drive letter assignments\n\n"));
00356    _tprintf(_T("usage: %s <Drive Letter> <NT device name>     add a drive letter\n"),
00357           pszAppName);
00358    _tprintf(_T("       %s -t <Drive Letter> <NT device name>  add a temporary drive letter\n"),
00359        pszAppName);
00360
00361    _tprintf(_T("       %s -r <Drive Letter>                   remove a drive letter\n"),
00362           pszAppName);
00363    _tprintf(_T("       %s <Drive Letter>                      show mapping for drive letter\n"),
00364        pszAppName);
00365    _tprintf(_T("       %s -a                                  show all mappings\n\n"),
00366        pszAppName);
00367
00368
00369    _tprintf(_T("example: %s e:\\ \\Device\\CdRom0\n"), pszAppName);
00370    _tprintf(_T("         %s -r e:\\\n"), pszAppName);
00371 }
00372
00373
00374 /*-----------------------------------------------------------------------------
00375 AssignPersistentDriveLetter (IN pszDriveLetter, IN pszDeviceName)
00376
00377 Description:
00378    Creates a persistent drive letter that refers to a specified device. This
00379    drive letter will remain even when the system is restarted.
00380
00381 Parameters:
00382    pszDriveLetter
00383       The new drive letter to create.  Must be in the form X: or X:\
00384
00385    pszDeviceName
00386       The NT device name to which the drive letter will be assigned.
00387
00388 Return Value:
00389    Returns TRUE if the drive letter was added, or FALSE if it wasn't.
00390 -----------------------------------------------------------------------------*/
00391 BOOL WINAPI AssignPersistentDriveLetter (
00392    LPCTSTR pszDriveLetter,
00393    LPCTSTR pszDeviceName)
00394 {
00395    BOOL fResult;
00396    TCHAR szUniqueVolumeName[MAX_PATH];
00397    TCHAR szDriveLetterAndSlash[4];
00398    TCHAR szDriveLetter[3];
00399
00400    /*
00401       Make sure we are passed a drive letter and a device name.  lstrlen
00402       is useful because it will return zero if the pointer points to memory
00403       that can't be read or a string that causes an invalid page fault before
00404       the terminating NULL.
00405    */
00406    if (0 == lstrlen(pszDriveLetter) ||
00407        0 == lstrlen(pszDeviceName)  ||
00408        !IsDriveLetter (pszDriveLetter))
00409    {
00410       SetLastError (ERROR_INVALID_PARAMETER);
00411       return FALSE;
00412    }
00413
00414    /*
00415       GetVolumeNameForVolumeMountPoint, SetVolumeMountPoint, and
00416       DeleteVolumeMountPoint require drive letters to have a trailing backslash.
00417       However, DefineDosDevice and QueryDosDevice require that the trailing
00418       backslash be absent.  So, we'll set up the following variables:
00419
00420        szDriveLetterAndSlash     for the mount point APIs
00421        szDriveLetter             for DefineDosDevice
00422    */
00423    szDriveLetterAndSlash[0] = pszDriveLetter[0];
00424    szDriveLetterAndSlash[1] = _T(':');
00425    szDriveLetterAndSlash[2] = _T('\\');
00426    szDriveLetterAndSlash[3] = _T('\0');
00427
00428    szDriveLetter[0] = szDriveLetterAndSlash[0];
00429    szDriveLetter[1] = _T(':');
00430    szDriveLetter[2] = _T('\0');
00431
00432    /*
00433       Determine if the drive letter is currently in use.  If so, return the
00434       error to the caller.  NOTE:  we temporarily reuse szUniqueVolumeName
00435       instead of allocating a large array for this one call.
00436    */
00437    fResult = QueryDosDevice (szDriveLetter, szUniqueVolumeName, MAX_PATH);
00438    if (fResult)
00439    {
00440       SetLastError (PRIV_ERROR_DRIVE_LETTER_IN_USE);
00441       return FALSE;
00442    }
00443
00444
00445    /*
00446       To map a persistent drive letter, we must make sure that the target
00447       device is one of the following:
00448
00449          A recognized partition and is not hidden
00450          A dynamic volume
00451          A non-partitionable device such as CD-ROM
00452
00453       Start by using the drive letter as a symbolic link to the device.  Then,
00454       open the device to gather the information necessary to determine if the
00455       drive can have a persistent drive letter.
00456    */
00457    fResult = DefineDosDevice (DDD_RAW_TARGET_PATH, szDriveLetter, pszDeviceName);
00458    if (fResult)
00459    {
00460       HANDLE       hDevice;
00461       DWORD        dwBytesReturned;
00462       BOOL         fResult;
00463       TCHAR        szDriveName[7]; // holds \\.\X: plus NULL.
00464
00465       VOLUME_GET_GPT_ATTRIBUTES_INFORMATION volinfo;
00466       PARTITION_INFORMATION                 partinfo;
00467
00468
00469       lstrcpyn (szDriveName, _T("\\\\.\\"), 5);
00470       lstrcpyn (szDriveName + 4, szDriveLetter, 3);
00471
00472       hDevice = CreateFile (szDriveName, GENERIC_READ,
00473                             FILE_SHARE_READ|FILE_SHARE_WRITE,
00474                             NULL, OPEN_EXISTING, 0, NULL);
00475
00476       if (INVALID_HANDLE_VALUE != hDevice)
00477       {
00478          /*
00479             See if drive is partitionable and retrieve the partition type.
00480             If the device doesn't have a partition, note it by setting the
00481             partition type to unused.
00482          */
00483          fResult = DeviceIoControl (hDevice, IOCTL_DISK_GET_PARTITION_INFO,
00484                                     NULL, 0,
00485                                     &partinfo, sizeof(partinfo),
00486                                     &dwBytesReturned, NULL);
00487          if (!fResult)
00488          {
00489             partinfo.PartitionType = PARTITION_ENTRY_UNUSED;
00490          }
00491
00492          /*
00493             On Windows XP, partition entries on GUID Partition Table drives
00494             have an attribute that determines whether partitions are hidden.
00495             Therefore, we must check this bit on the target partition.
00496
00497             If we're running on Windows 2000, there are no GPT drives, so
00498             set flags to none.  This is important for the check for hidden
00499             partitions later.
00500          */
00501          if (IsWindowsXP_orLater())
00502          {
00503             fResult = DeviceIoControl (hDevice, IOCTL_VOLUME_GET_GPT_ATTRIBUTES,
00504                                        NULL, 0,
00505                                        &volinfo, sizeof(volinfo),
00506                                        &dwBytesReturned, NULL);
00507             if (!fResult)
00508                volinfo.GptAttributes = 0;
00509          }
00510          else
00511          {
00512             volinfo.GptAttributes = 0;
00513          }
00514          CloseHandle (hDevice);
00515       }
00516       else
00517       {
00518          /*
00519             Remove the drive letter symbolic link we created, let caller know
00520             we couldn't open the drive.
00521          */
00522          DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|
00523                           DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter,
00524                           pszDeviceName);
00525          return (FALSE);
00526       }
00527
00528       /*
00529          Now, make sure drive meets requirements for receiving a persistent
00530          drive letter.
00531
00532          Note: on Windows XP, partitions that were hidden when the system
00533          booted are not assigned a unique volume name.  They will not be given
00534          one until they are marked as not hidden and the system rebooted.
00535          Therefore, we cannot create a mount point hidden partitions.
00536
00537          On Windows 2000, hidden partitions are assigned unique volume names
00538          and so can have persistent drive letters.  However, we will not allow
00539          that behavior in this tool as hidden partitions should not be assigned
00540          drive letters.
00541       */
00542       if (IsPartitionHidden (partinfo.PartitionType, volinfo.GptAttributes))
00543       {
00544          // remove the drive letter we created, let caller know what happened.
00545          DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|
00546                            DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter,
00547                            pszDeviceName);
00548
00549          SetLastError (PRIV_ERROR_PARTITION_HIDDEN);
00550          return (FALSE);
00551       }
00552
00553       /*
00554          Verify that the drive letter must refer to a recognized partition,
00555          a dynamic volume, or a non-partitionable device such as CD-ROM.
00556       */
00557       if (IsRecognizedPartition(partinfo.PartitionType) ||
00558           PARTITION_LDM == partinfo.PartitionType ||
00559           PARTITION_ENTRY_UNUSED == partinfo.PartitionType)
00560       {
00561          /*
00562             Now add the drive letter by calling on the volume mount manager.
00563             Once we have the unique volume name that the new drive letter
00564             will point to, delete the symbolic link because the Mount Manager
00565             allows only one reference to a device at a time (the new one to
00566             be added).
00567          */
00568          fResult = GetVolumeNameForVolumeMountPoint (szDriveLetterAndSlash,
00569                                                      szUniqueVolumeName,
00570                                                      MAX_PATH);
00571
00572          DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|
00573                           DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter,
00574                           pszDeviceName);
00575
00576          if (fResult)
00577             fResult = SetVolumeMountPoint (szDriveLetterAndSlash,
00578                                            szUniqueVolumeName);
00579
00580          return (fResult);
00581       }
00582       else
00583       {
00584          /*
00585             Device doesn't meet the criteria for persistent drive letter.
00586             Remove the drive letter symbolic link we created.
00587          */
00588          DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|
00589                           DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter,
00590                           pszDeviceName);
00591
00592          SetLastError (PRIV_ERROR_PARTITION_NOT_RECOGNIZED);
00593          return (FALSE);
00594       }
00595
00596    }  /* end if DeviceIoControl to map symbolic link*/
00597    else
00598       return (FALSE);
00599 }
00600
00601
00602 /*-----------------------------------------------------------------------------
00603 RemovePersistentDriveLetter( IN pszDriveLetter)
00604
00605 Description:
00606    Removes a drive letter that was created by AssignPersistentDriveLetter().
00607
00608 Parameters:
00609    pszDriveLetter
00610       The drive letter to remove.  Must be in the format X: or X:\
00611
00612 Return Value:
00613    Returns TRUE if the drive letter was removed, or FALSE if it wasn't.
00614 -----------------------------------------------------------------------------*/
00615 BOOL WINAPI RemovePersistentDriveLetter (LPCTSTR pszDriveLetter)
00616 {
00617    BOOL fResult;
00618    TCHAR szDriveLetterAndSlash[4];
00619
00620    /* Make sure we have a drive letter.   */
00621    if (0 == lstrlen(pszDriveLetter) || !IsDriveLetter (pszDriveLetter))
00622    {
00623       SetLastError (ERROR_INVALID_PARAMETER);
00624       fResult = FALSE;
00625    }
00626
00627    /*
00628       pszDriveLetter could be in the format X: or X:\.  DeleteVolumeMountPoint
00629       requires X:\, so add a trailing backslash.
00630    */
00631    szDriveLetterAndSlash[0] = pszDriveLetter[0];
00632    szDriveLetterAndSlash[1] = _T(':');
00633    szDriveLetterAndSlash[2] = _T('\\');
00634    szDriveLetterAndSlash[3] = _T('\0');
00635
00636    fResult = DeleteVolumeMountPoint (szDriveLetterAndSlash);
00637    return (fResult);
00638 }
00639
00640
00641 /*-----------------------------------------------------------------------------
00642 AssignTemporaryDriveLetter( IN pszDriveLetter, IN pszDeviceName)
00643
00644 Description:
00645    Creates a temporary drive letter that refers to a specified device.  This
00646    drive letter will exist only until the system is shut down or restarted.
00647
00648 Parameters:
00649    pszDriveLetter
00650       The new drive letter to create.  Must be in the form X: or X:\
00651
00652    pszDeviceName
00653       The NT device name to which the drive letter will be assigned.
00654
00655 Return Value:
00656    Returns TRUE if the temporary drive letter was assigned, or FALSE if it
00657    could not be.
00658
00659 Notes:
00660    A temporary drive letter is just a symbolic link.  It can be removed at any
00661    time by deleting the symbolic link. If it exists when the system is shut
00662    down or restarted, it will be removed automatically.
00663
00664    AssignTemporaryDriveLetter requires device to be present.
00665 -----------------------------------------------------------------------------*/
00666 BOOL WINAPI AssignTemporaryDriveLetter (LPCTSTR pszDriveLetter, LPCTSTR pszDeviceName)
00667 {
00668    TCHAR szDevice[MAX_PATH];
00669    TCHAR szDriveLetter[3];
00670    BOOL  fResult;
00671
00672    /* Verify that caller passed a drive letter and device name. */
00673    if (0 == lstrlen(pszDriveLetter) ||
00674        0 == lstrlen(pszDeviceName)  ||
00675        !IsDriveLetter (pszDriveLetter))
00676    {
00677       SetLastError (ERROR_INVALID_PARAMETER);
00678       return (FALSE);
00679    }
00680
00681    /*
00682       Make sure the drive letter isn't already in use.  If not in use,
00683       create the symbolic link to establish the temporary drive letter.
00684
00685       pszDriveLetter could be in the format X: or X:\; QueryDosDevice and
00686       DefineDosDevice need X:
00687    */
00688    szDriveLetter[0] = pszDriveLetter[0];
00689    szDriveLetter[1] = _T(':');
00690    szDriveLetter[2] = _T('\0');
00691
00692    if (!QueryDosDevice (szDriveLetter, szDevice, MAX_PATH))
00693    {
00694       /*
00695          If we can create the symbolic link, verify that it points to a real
00696          device.  If not, remove the link and return an error.  CreateFile sets
00697          the last error code to ERROR_FILE_NOT_FOUND.
00698       */
00699       fResult = DefineDosDevice (DDD_RAW_TARGET_PATH, szDriveLetter, pszDeviceName);
00700       if (fResult)
00701       {
00702          HANDLE hDevice;
00703          TCHAR  szDriveName[7]; // holds \\.\X: plus NULL.
00704
00705          lstrcpyn (szDriveName, _T("\\\\.\\"), 5);
00706          lstrcpyn (szDriveName + 4, szDriveLetter, 3);
00707
00708          hDevice = CreateFile (szDriveName, GENERIC_READ,
00709                                FILE_SHARE_READ|FILE_SHARE_WRITE,
00710                                NULL, OPEN_EXISTING, 0, NULL);
00711
00712          if (INVALID_HANDLE_VALUE != hDevice)
00713          {
00714             fResult = TRUE;
00715             CloseHandle (hDevice);
00716          }
00717          else
00718          {
00719             DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|
00720                              DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter,
00721                              pszDeviceName);
00722             fResult = FALSE;
00723          }
00724       }
00725    }
00726    else
00727    {
00728       SetLastError (PRIV_ERROR_DRIVE_LETTER_IN_USE);
00729       fResult = FALSE;
00730    }
00731
00732    return (fResult);
00733 }
00734
00735
00736 /*-----------------------------------------------------------------------------
00737 RemoveTemporaryDriveLetter( IN pszDriveLetter)
00738
00739 Description:
00740    Removes a drive letter that was created by AssignTemporaryDriveLetter().
00741
00742 Parameters:
00743    pszDriveLetter
00744       The drive letter to remove.  Must be in the format X: or X:\
00745
00746 Return Value:
00747    Returns TRUE if the drive letter was removed, or FALSE if it wasn't.
00748 -----------------------------------------------------------------------------*/
00749 BOOL WINAPI RemoveTemporaryDriveLetter (LPCTSTR pszDriveLetter)
00750 {
00751    BOOL fResult;
00752    TCHAR szDriveLetter[3];
00753    TCHAR szDeviceName[MAX_PATH];
00754
00755    /* Verify that caller passed a drive letter and device name. */
00756
00757    if (0 == lstrlen(pszDriveLetter) || !IsDriveLetter (pszDriveLetter))
00758    {
00759       SetLastError (ERROR_INVALID_PARAMETER);
00760       fResult = FALSE;
00761
00762    }
00763
00764    /*
00765       pszDriveLetter could be in the format X: or X:\; DefineDosDevice
00766       needs X:
00767    */
00768    szDriveLetter[0] = pszDriveLetter[0];
00769    szDriveLetter[1] = _T(':');
00770    szDriveLetter[2] = _T('\0');
00771
00772    fResult = QueryDosDevice (szDriveLetter, szDeviceName, MAX_PATH);
00773    if (fResult)
00774    {
00775       fResult = DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|
00776                                  DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter,
00777                                  szDeviceName);
00778    }
00779
00780    return (fResult);
00781 }
00782
00783
00784 /*-----------------------------------------------------------------------------
00785 IsPartitionHidden( IN partitionType, IN partitionAttribs)
00786
00787 Description:
00788    Determines if the partition hosting a volume is hidden or not.
00789
00790 Parameters:
00791    partitionType
00792       Specifies the partitition type; this value is obtained from
00793       IOCTL_DISK_GET_PARTITION_INFO or IOCTL_DISK_GET_DRIVE_GEOMETRY.
00794       A partition type that has bit 0x10 set is hidden.
00795
00796    partitionAttribs
00797       Specifies the attributes of a GUID Partition Type (GPT)-style partition
00798       entry.  This value is obtained from IOCTL_VOLUME_GET_GPT_ATTRIBUTES
00799       or IOCTL_DISK_GET_DRIVE_GEOMETRY_EX.  A GPT partition that has
00800       GPT_BASIC_DATA_ATTRIBUTE_HIDDEN set is hidden.
00801
00802 Return Value:
00803    Returns TRUE if the partition is hidden or FALSE if it is not.
00804
00805 Notes:
00806    On Windows XP and Windows Server 2003, partitions that were hidden when
00807    the system booted are not assigned a unique volume name.  They will not
00808    be given one until they are marked as not hidden and the system rebooted.
00809    Therefore, we cannot create a mount point hidden partitions.
00810
00811    On Windows 2000, hidden partitions are assigned unique volume names
00812    and so can have persistent drive letters.  However, we will not allow
00813    that behavior in this tool as hidden partitions should not be assigned
00814    drive letters.
00815 -----------------------------------------------------------------------------*/
00816 BOOL WINAPI IsPartitionHidden (BYTE partitionType, ULONGLONG partitionAttribs)
00817 {
00818    if ((partitionAttribs & GPT_BASIC_DATA_ATTRIBUTE_HIDDEN) ||
00819        ((partitionType & HIDDEN_PARTITION_FLAG) &&
00820         IsRecognizedPartition (partitionType & ~HIDDEN_PARTITION_FLAG)))
00821    {
00822       return TRUE;
00823    }
00824    else
00825    {
00826       return FALSE;
00827    }
00828 }
00829
00830
00831 /*-----------------------------------------------------------------------------
00832 IsDriveLetter( IN pszDriveLetter)
00833
00834 Description:
00835    Verifies string passed in is of the form X: or X:\ where X is a letter.
00836
00837 Parameters:
00838    pszDriveLetter
00839       A null terminated string.
00840
00841 Return Value:
00842    TRUE if the string is of the form X: or X:\ where X is a letter.  X
00843    may be upper-case or lower-case.  If the string isn't of this from,
00844    returns FALSE.
00845 -----------------------------------------------------------------------------*/
00846 BOOL WINAPI IsDriveLetter (LPCTSTR pszDriveLetter)
00847 {
00848     /*
00849        format must be: X:<null> or X:<NULL> where X is a letter.  lstrlen will
00850        return 0 if inaccessible pointer is supplied, or if reading bytes of
00851        string causes an access violation before reaching a terminating NULL.
00852     */
00853     if ( (0 < lstrlen (pszDriveLetter))      &&
00854          (IsCharAlpha (pszDriveLetter[0]))   &&
00855          (_T(':')   == pszDriveLetter[1])    &&
00856          ((_T('\0') == pszDriveLetter[2]) ||
00857           ((_T('\\') == pszDriveLetter[2]) && (_T('\0') == pszDriveLetter[3])))
00858        )
00859     {
00860         return TRUE;
00861     }
00862     else
00863     {
00864         return FALSE;
00865     }
00866 }
00867
00868
00869 /*-----------------------------------------------------------------------------
00870 IsWindowsXP_orLater()
00871
00872 Description:
00873    Determines if the currently-running version of Windows is Windows XP or
00874    Windows Server 2003 or later.
00875
00876 Return Value:
00877    Returns TRUE if the currently-running system is Windows XP or Windows 2003
00878    Server or later systems. Returns FALSE otherwise.
00879 -----------------------------------------------------------------------------*/
00880 BOOL WINAPI IsWindowsXP_orLater (void)
00881 {
00882    OSVERSIONINFOEX osvi;
00883    ULONGLONG       comparisonMask;
00884
00885    ZeroMemory (&osvi, sizeof(osvi));
00886    osvi.dwOSVersionInfoSize = sizeof(osvi);
00887    osvi.dwMajorVersion = 5;
00888    osvi.dwMinorVersion = 1;
00889
00890    comparisonMask = 0;
00891    comparisonMask = VerSetConditionMask (comparisonMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
00892    comparisonMask = VerSetConditionMask (comparisonMask, VER_MINORVERSION, VER_GREATER_EQUAL);
00893
00894    return (VerifyVersionInfo (&osvi, VER_MAJORVERSION|VER_MINORVERSION, comparisonMask));
00895 }
00896
00897
00898
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CExtendPropertySheet Member List

This is the complete list of members for CExtendPropertySheet, including all inherited members.
CExtendPropertySheet() | CExtendPropertySheet |
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR Handle, LPDATAOBJECT ipIDataObject) | CExtendPropertySheet |
IsAttributeSet(DWORD dwAttribute) | CExtendPropertySheet | [private]
m_cRef | CExtendPropertySheet | [private]
m_dwXAttribs | CExtendPropertySheet | [private]
m_nPageCount | CExtendPropertySheet | [private]
m_pNodeAttribs | CExtendPropertySheet | [private]
OnApplyChanges(HWND hPage, WPARAM wParam, LPARAM lParam) | CExtendPropertySheet | [private]
OnInitPropPage(HWND hPage, WPARAM wParam, LPARAM lParam) | CExtendPropertySheet | [private]
PPageWndProcX(HWND hPage, UINT uMsg, WPARAM wParam, LPARAM lParam) | CExtendPropertySheet | [private, static]
QueryInterface(REFIID riid, LPVOID *ppv) | CExtendPropertySheet |
QueryPagesFor(LPDATAOBJECT ipDataObject) | CExtendPropertySheet |
STDMETHODIMP_(ULONG) AddRef() | CExtendPropertySheet |
STDMETHODIMP_(ULONG) Release() | CExtendPropertySheet |
~CExtendPropertySheet() | CExtendPropertySheet |
Generated on Wed Nov 13 2024 16:56:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/BrochureMachine/resource.h Source File

  • Web
  • Browser
  • BrochureMachine

resource.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 //{{NO_DEPENDENCIES}}
00006 // Microsoft Developer Studio generated include file.
00007 // Used by BrochureMachine.rc
00008 //
00009 #define IDS_PROJNAME                    100
00010 #define IDR_PTLAUNCHER                  101
00011
00012 // Next default values for new objects
00013 //
00014 #ifdef APSTUDIO_INVOKED
00015 #ifndef APSTUDIO_READONLY_SYMBOLS
00016 #define _APS_NEXT_RESOURCE_VALUE        202
00017 #define _APS_NEXT_COMMAND_VALUE         32768
00018 #define _APS_NEXT_CONTROL_VALUE         201
00019 #define _APS_NEXT_SYMED_VALUE           102
00020 #endif
00021 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicClien/LicClien.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicClien

LicClien.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      LICCLIEN.CPP
00003
00004   Summary:   Based largely on the DLLCLIEN.EXE application code, this
00005              module is meant to use COM to load and access some COM
00006              components in two separate DLL COM Servers (DLLSERVE built in
00007              the sibling DLLSERVE directory and LICSERVE built in the
00008              sibline LICSERVE directory).  Thus to run LICCLIEN you must
00009              build both DLLSERVE and LICSERVE first.  The main idea in
00010              this code sample is to showcase licensing of components in
00011              servers. To this end the LICSERVE server provides the
00012              LicCruiseCar component as a licensed component and this
00013              LICCLIEN module must access it through the IClassFactory2
00014              licensing facilities.
00015
00016              LICCLIEN composes its own native composite COM object,
00017              COUtilityCruiseCar, by aggregating an existing licensed
00018              COLicCruiseCar COM component (provided by the LICSERVE.DLL
00019              server) with a native implementation of the IUtility
00020              interface.  Thus, this app showcases nested aggregation using
00021              COM's client/server protocol and involving a licensed
00022              component.
00023
00024              LICCLIEN also instantiates the car-related components
00025              provided by the two servers and exercises them (ie, Car,
00026              UtilityCar, LicCruiseCar, and UtilityCruiseCar).  LICCLIEN
00027              provides a set of menus for these Car related objects with
00028              selections for the respective methods of the Interfaces
00029              exposed by those COM Objects.  LICCLIEN also exploits
00030              LICSERVE's LicCarSample component to setup operation of that
00031              server as a code sample that supports the Client's trace
00032              LOGging macros.  After this is set up the server logs to the
00033              Client's logging facility.  Similar logging is set up for the
00034              DLLSERVE server.
00035
00036              For a comprehensive tutorial code tour of LICCLIEN's
00037              contents and offerings see the tutorial LICCLIEN.HTM file.
00038              For more specific technical details on the internal workings
00039              see the comments dispersed throughout the LICCLIEN source code.
00040              For more details on the LICSERVE.DLL that LICCLIEN works with
00041              see the LICSERVE.HTM file in the main tutorial directory.
00042              For more details on the DLLSERVE.DLL that LICCLIEN works with
00043              see the DLLSERVE.HTM file in the main tutorial directory.
00044
00045   Classes:   CMainWindow
00046
00047   Functions: InitApplication, WinMain
00048
00049   Origin:    10-5-95: atrent - Editor-inheritance from the DLLCLIEN source.
00050
00051 ----------------------------------------------------------------------------
00052   This file is part of the Microsoft COM Tutorial Code Samples.
00053
00054   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00055
00056   This source code is intended only as a supplement to Microsoft
00057   Development Tools and/or on-line documentation.  See these other
00058   materials for detailed information regarding Microsoft code samples.
00059
00060   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00061   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00062   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00063   PARTICULAR PURPOSE.
00064 ==========================================================================+*/
00065
00066 /*--------------------------------------------------------------------------
00067   We include WINDOWS.H for all Win32 applications.
00068   We include OLE2.H because we will be calling the COM/OLE Libraries.
00069   We include INITGUID.H only once (here) in the entire app because we
00070     will be defining GUIDs and want them as constants in the data segment.
00071   We include OLECTL.H because we will using IClassFactory2.
00072   We include COMMDLG.H because we will be using the Open File and
00073     potentially other Common dialogs.
00074   We include APPUTIL.H because we will be building this application using
00075     the convenient Virtual Window and Dialog classes and other
00076     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00077   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00078     class, GUID, and CLSID specifications.
00079   We include LICCLIEN.H because it has class and resource definitions
00080     specific to this LICCLIEN application.
00081   We include UTCRUCAR.H because it has COUtilityCar object class.
00082 ---------------------------------------------------------------------------*/
00083 #include <windows.h>
00084 #include <ole2.h>
00085 #include <initguid.h>
00086 #include <olectl.h>
00087 #include <commdlg.h>
00088 #include <apputil.h>
00089 #include <icars.h>
00090 #include <carguids.h>
00091 #include "licclien.h"
00092 #include "utcrucar.h"
00093
00094
00095 // Here is a pointer for use by the global Trace Message logging macros.
00096 CMsgLog* g_pMsgLog = NULL;
00097
00098
00099 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00100   Method:   CMainWindow::CMainWindow
00101
00102   Summary:  CMainWindow Constructor.
00103
00104   Args:     .
00105
00106   Modifies: .
00107
00108   Returns:  .
00109 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00110 CMainWindow::CMainWindow()
00111 {
00112   // Ensure these member variable strings are null strings.
00113   m_szFileName[0] = 0;
00114   m_szFileTitle[0] = 0;
00115
00116   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00117   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00118   m_ofnFile.hwndOwner = m_hWnd;
00119   m_ofnFile.hInstance = m_hInst;
00120   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00121   m_ofnFile.lpstrCustomFilter = NULL;
00122   m_ofnFile.nMaxCustFilter = 0;
00123   m_ofnFile.nFilterIndex = 1;
00124   m_ofnFile.lpstrFile = m_szFileName;
00125   m_ofnFile.nMaxFile = MAX_PATH;
00126   m_ofnFile.lpstrInitialDir = TEXT(".");
00127   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00128   m_ofnFile.nMaxFileTitle = MAX_PATH;
00129   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00130   m_ofnFile.lpstrDefExt = NULL;
00131   m_ofnFile.Flags = OFN_HIDEREADONLY;
00132
00133   // NULL the license key string pointer.
00134   m_bstrLicKey = NULL;
00135
00136   // NULL all the main interface pointers.
00137   m_pCar = NULL;
00138   m_pUtilityCar = NULL;
00139   m_pLicCruiseCar = NULL;
00140   m_pUtilityCruiseCar = NULL;
00141   m_pLicCarSample = NULL;
00142   m_pDllCarSample = NULL;
00143
00144   // Null the Message object pointers.
00145   m_pMsgBox = NULL;
00146   m_pMsgLog = NULL;
00147 }
00148
00149
00150 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00151   Method:   CMainWindow::~CMainWindow
00152
00153   Summary:  CMainWindow Destructor.  Destruction of the main window
00154             indicates that the application should quit and thus the
00155             PostQuitMessage API is called.
00156
00157   Args:     .
00158
00159   Modifies: .
00160
00161   Returns:  .
00162 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00163 CMainWindow::~CMainWindow()
00164 {
00165   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00166   // message and causes a delete of CMainWindow which in turn causes this
00167   // destructor to run. The WM_DESTROY results when the window is destoyed
00168   // after a close of the window. Prior to exiting the main message loop:
00169
00170   // We free any dynamically allocated data.
00171   SysFreeString(m_bstrLicKey);
00172
00173   // We release any and all of the pointers to instantiated COM objects.
00174   RELEASE_INTERFACE(m_pCar);
00175   RELEASE_INTERFACE(m_pUtilityCar);
00176   RELEASE_INTERFACE(m_pLicCruiseCar);
00177   RELEASE_INTERFACE(m_pUtilityCruiseCar);
00178   RELEASE_INTERFACE(m_pLicCarSample);
00179   RELEASE_INTERFACE(m_pDllCarSample);
00180
00181   // We delete the CMsgBox and CMsgLog objects that were made in
00182   // Initinstance.
00183   DELETE_POINTER(m_pMsgBox);
00184   DELETE_POINTER(m_pMsgLog);
00185
00186   // We then post a WM_QUIT message to cause an exit of the main thread's
00187   // message loop and an exit of this instance of the application.
00188   PostQuitMessage(0);
00189 }
00190
00191
00192 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00193   Method:   CMainWindow::InitInstance
00194
00195   Summary:  Instantiates an instance of the main application window.
00196             This method must be called only once, immediately after
00197             window class construction.  We take care to delete 'this'
00198             CMainWindow if we must return the error condition FALSE.
00199
00200   Args:     HINSTANCE hInstance,
00201               Handle of the application instance.
00202             int nCmdShow)
00203               Command to pass to ShowWindow.
00204
00205   Modifies: m_szHelpFile, m_pMsgBox, m_pMsgLog.
00206
00207   Returns:  BOOL.
00208               TRUE if succeeded.
00209               FALSE if failed.
00210 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00211 BOOL CMainWindow::InitInstance(
00212        HINSTANCE hInstance,
00213        int nCmdShow)
00214 {
00215   BOOL bOk = FALSE;
00216   HWND hWnd;
00217
00218   // Create the Message Box and Message Log objects.
00219   m_pMsgBox = new CMsgBox;
00220   m_pMsgLog = new CMsgLog;
00221
00222   if (NULL != m_pMsgBox && NULL != m_pMsgLog)
00223   {
00224     // Note, the Create method sets the m_hWnd member so we don't
00225     // need to set it explicitly here first.
00226
00227     // Here is the create of this window.  Size the window reasonably.
00228     // Create sets both m_hInst and m_hWnd.
00229     hWnd = Create(
00230              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00231              TEXT(MAIN_WINDOW_TITLE_STR),
00232              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00233                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00234              CW_USEDEFAULT,
00235              CW_USEDEFAULT,
00236              ::GetSystemMetrics(SM_CXSCREEN)*3/5,
00237              ::GetSystemMetrics(SM_CYSCREEN)*3/5,
00238              NULL,
00239              NULL,
00240              hInstance);
00241     if (hWnd)
00242     {
00243       // Ensure the new window is shown on screen and its content is
00244       // painted.
00245       ::ShowWindow(m_hWnd, nCmdShow);
00246       ::UpdateWindow(m_hWnd);
00247
00248       // Build a path to where the help file should be (it should be in
00249       // the same directory as the .EXE but with the .HTM extension.
00250       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00251
00252       // Init the Message Box object.
00253       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00254       {
00255         // Create the Trace Message Log ListBox as a child window that
00256         //   fits the client area of the Main Window (the TRUE 3rd argument
00257         //   specifies such an inside child).
00258         // If you want the Trace Message Log in a separate (but owned)
00259         //   window, then pass a FALSE instead for the 3rd argument.
00260         if (m_pMsgLog->Create(m_hInst, m_hWnd, TRUE))
00261         {
00262           HRESULT hr;
00263
00264           // Assign the global MsgLog pointer.
00265           g_pMsgLog = m_pMsgLog;
00266           // Use macro to log an initial start messsage.
00267           LOGID(IDS_START_MESSAGE_LOG);
00268
00269           LOG("C: Start LICSERVE Server Trace Logging.");
00270           // Now ask COM for the ISample interface to the server's
00271           // LicCarSample component.  This effectively loads the
00272           // LICSERVE DLL.
00273           hr = CoCreateInstance(
00274                  CLSID_LicCarSample,
00275                  NULL,
00276                  CLSCTX_INPROC_SERVER,
00277                  IID_ISample,
00278                  (PPVOID)&m_pLicCarSample);
00279           if (SUCCEEDED(hr))
00280           {
00281             hr = m_pLicCarSample->Init(m_hWnd, g_pMsgLog);
00282             if (SUCCEEDED(hr))
00283             {
00284               HMENU hMenu  = ::GetMenu(m_hWnd);
00285
00286               ::CheckMenuItem(
00287                   hMenu,
00288                   IDM_LOG_LICSERVER,
00289                   MF_BYCOMMAND | MF_CHECKED);
00290
00291               LOG("C: Start DLLSERVE Server Trace Logging.");
00292               // Also set up logging from the subordinate DLLSERVE server
00293               // to the this client as well.
00294               hr = CoCreateInstance(
00295                      CLSID_DllCarSample,
00296                      NULL,
00297                      CLSCTX_INPROC_SERVER,
00298                      IID_ISample,
00299                      (PPVOID)&m_pDllCarSample);
00300               if (SUCCEEDED(hr))
00301               {
00302                 hr = m_pDllCarSample->Init(m_hWnd, g_pMsgLog);
00303                 bOk = SUCCEEDED(hr);
00304                 if (bOk)
00305                 {
00306                   ::CheckMenuItem(
00307                       hMenu,
00308                       IDM_LOG_DLLSERVER,
00309                       MF_BYCOMMAND | MF_CHECKED);
00310                 }
00311                 else
00312                 {
00313                    RELEASE_INTERFACE(m_pDllCarSample);
00314                    // We ask COM to unload any unused COM Servers.
00315                    CoFreeUnusedLibraries();
00316                 }
00317               }
00318               else
00319                 m_pMsgBox->ErrorID(IDS_NODLLSERVER);
00320             }
00321             else
00322             {
00323               RELEASE_INTERFACE(m_pLicCarSample);
00324               // We ask COM to unload any unused COM Servers.
00325               CoFreeUnusedLibraries();
00326             }
00327           }
00328           else
00329             m_pMsgBox->ErrorID(IDS_NOLICSERVER);
00330         }
00331       }
00332     }
00333   }
00334
00335   if (!bOk)
00336   {
00337     DELETE_POINTER(m_pMsgBox);
00338     DELETE_POINTER(m_pMsgLog);
00339   }
00340
00341   return (bOk);
00342 }
00343
00344
00345 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00346   Method:   CMainWindow::GetInterface
00347
00348   Summary:  Convenience method that wraps the QueryInterface call
00349             and accepts a main COM object IUnknown pointer as an argument.
00350
00351   Args:     IUnknown* pObj,
00352               Pointer to the COM Object we are getting an interface on.
00353             REFIID riid,
00354               The GUID for the interface that we are seeking.
00355             PPVOID ppv);
00356               Address of the caller's pointer variable that will
00357               receive the requested interface pointer.
00358
00359   Modifies: .
00360
00361   Returns:  BOOL.
00362               TRUE if succeeded.
00363               FALSE if failed.
00364 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00365 BOOL CMainWindow::GetInterface(
00366        IUnknown* pObj,
00367        REFIID riid,
00368        PPVOID ppv)
00369 {
00370   BOOL bResult = FALSE;
00371   HRESULT hr;
00372
00373   *ppv=NULL;
00374
00375   if (NULL != pObj)
00376   {
00377     LOG("C: --Obtaining Interface Pointer.");
00378     hr=pObj->QueryInterface(riid, ppv);
00379
00380     if (FAILED(hr))
00381     {
00382       LOGERROR("C: ???? QueryInterface", hr);
00383     }
00384     else
00385     {
00386       LOGF1("C: Interface obtained. *ppv=0x%X", *ppv);
00387       bResult = TRUE;
00388     }
00389   }
00390   else
00391   {
00392     LOG("C: ???? Create an object first.");
00393   }
00394
00395   return (bResult);
00396 }
00397
00398
00399 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00400   Method:   CMainWindow::DoMenu
00401
00402   Summary:  Dispatch and handle the main menu commands.
00403
00404   Args:     WPARAM wParam,
00405               First message parameter (word sized).
00406             LPARAM lParam)
00407               Second message parameter (long sized).
00408
00409   Modifies: m_ofnFile, ...
00410
00411   Returns:  LRESULT
00412               Standard Windows WindowProc return value.
00413 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00414 LRESULT CMainWindow::DoMenu(
00415           WPARAM wParam,
00416           LPARAM lParam)
00417 {
00418   LRESULT lResult = FALSE;
00419   HRESULT hr;
00420   HMENU hMenu  = ::GetMenu(m_hWnd);
00421   IClassFactory2* pICF2LicCruiseCar;
00422   // Here are some interface pointers used to call methods on our COCar,
00423   // COUtilityCar, COLicCruiseCar, and COUtilityCruiseCar COM objects.
00424   ICar* pICar;
00425   IUtility* pIUtility;
00426   ICruise* pICruise;
00427
00428   switch (LOWORD(wParam))
00429   {
00430     //----------------------------------------------------------------------
00431     // Handle File Menu Commands.
00432     //----------------------------------------------------------------------
00433     case IDM_FILE_EXIT:
00434       // The user commands us to exit this application so we tell the
00435       // Main window to close itself.
00436       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00437       break;
00438
00439     //----------------------------------------------------------------------
00440     // Handle Car Menu Commands.
00441     //----------------------------------------------------------------------
00442     case IDM_CAR_CREATE:
00443       LOG("C: === Car Menu: Create.");
00444       if (NULL == m_pCar)
00445       {
00446         // Call COM service to create an instance.
00447         hr = CoCreateInstance(
00448                CLSID_DllCar,
00449                NULL,
00450                CLSCTX_INPROC_SERVER,
00451                IID_IUnknown,
00452                (PPVOID)&m_pCar);
00453         if (SUCCEEDED(hr))
00454         {
00455           ::CheckMenuItem(
00456               hMenu,
00457               IDM_CAR_CREATE,
00458               MF_BYCOMMAND | MF_CHECKED);
00459         }
00460         else
00461         {
00462           LOGERROR("C: ???? CoCreateInstance",hr);
00463         }
00464       }
00465       else
00466         LOG("C: ???? Car already exists.");
00467       break;
00468     case IDM_CAR_RELEASE:
00469       LOG("C: === Car Menu: Release.");
00470       if (NULL != m_pCar)
00471       {
00472         RELEASE_INTERFACE(m_pCar);
00473         // We ask COM to unload any unused COM Servers.
00474         CoFreeUnusedLibraries();
00475         ::CheckMenuItem(
00476             hMenu,
00477             IDM_CAR_CREATE,
00478             MF_BYCOMMAND | MF_UNCHECKED);
00479       }
00480       else
00481         LOG("C: ???? No Car to Release.");
00482       break;
00483     case IDM_CAR_SHIFT:
00484       LOG("C: === Car Menu: ICar::Shift");
00485       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00486       {
00487         LOG("C: --Calling pICar->Shift");
00488         pICar->Shift(1);
00489         LOG("C: --Releasing pICar");
00490         pICar->Release();
00491       }
00492       break;
00493     case IDM_CAR_CLUTCH:
00494       LOG("C: === Car Menu: ICar::Clutch");
00495       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00496       {
00497         LOG("C: --Calling pICar->Clutch");
00498         pICar->Clutch(100);
00499         LOG("C: --Releasing pICar");
00500         pICar->Release();
00501       }
00502       break;
00503     case IDM_CAR_SPEED:
00504       LOG("C: === Car Menu: ICar::Speed");
00505       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00506       {
00507         LOG("C: --Calling pICar->Speed");
00508         pICar->Speed(20);
00509         LOG("C: --Releasing pICar");
00510         pICar->Release();
00511       }
00512       break;
00513     case IDM_CAR_STEER:
00514       LOG("C: === Car Menu: ICar::Steer");
00515       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00516       {
00517         LOG("C: --Calling pICar->Steer");
00518         pICar->Steer(0);
00519         LOG("C: --Releasing pICar");
00520         pICar->Release();
00521       }
00522       break;
00523
00524     //----------------------------------------------------------------------
00525     // Handle UtilityCar Menu Commands.
00526     //----------------------------------------------------------------------
00527     case IDM_UCAR_CREATE:
00528       LOG("C: === UtilityCar Menu: Create.");
00529       if (NULL == m_pUtilityCar)
00530       {
00531         // Call COM service to create an instance.
00532         hr = CoCreateInstance(
00533                CLSID_DllUtilityCar,
00534                NULL,
00535                CLSCTX_INPROC_SERVER,
00536                IID_IUnknown,
00537                (PPVOID)&m_pUtilityCar);
00538         if (SUCCEEDED(hr))
00539         {
00540           ::CheckMenuItem(
00541               hMenu,
00542               IDM_UCAR_CREATE,
00543               MF_BYCOMMAND | MF_CHECKED);
00544         }
00545         else
00546         {
00547           LOGERROR("C: ???? CoCreateInstance",hr);
00548         }
00549       }
00550       else
00551         LOG("C: ???? UtilityCar already exists.");
00552       break;
00553     case IDM_UCAR_RELEASE:
00554       LOG("C: === UtilityCar Menu: Release.");
00555       if (NULL != m_pUtilityCar)
00556       {
00557         RELEASE_INTERFACE(m_pUtilityCar);
00558         // We ask COM to unload any unused COM Servers.
00559         CoFreeUnusedLibraries();
00560         ::CheckMenuItem(
00561             hMenu,
00562             IDM_UCAR_CREATE,
00563             MF_BYCOMMAND | MF_UNCHECKED);
00564       }
00565       else
00566         LOG("C: ???? No UtilityCar to Release.");
00567       break;
00568     case IDM_UCAR_SHIFT:
00569       LOG("C: === UtilityCar Menu: ICar::Shift");
00570       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00571       {
00572         LOG("C: --Calling pICar->Shift");
00573         pICar->Shift(2);
00574         LOG("C: --Releasing pICar");
00575         pICar->Release();
00576       }
00577       break;
00578     case IDM_UCAR_CLUTCH:
00579       LOG("C: === UtilityCar Menu: ICar::Clutch");
00580       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00581       {
00582         LOG("C: --Calling pICar->Clutch");
00583         pICar->Clutch(100);
00584         LOG("C: --Releasing pICar");
00585         pICar->Release();
00586       }
00587       break;
00588     case IDM_UCAR_SPEED:
00589       LOG("C: === UtilityCar Menu: ICar::Speed");
00590       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00591       {
00592         LOG("C: --Calling pICar->Speed");
00593         pICar->Speed(30);
00594         LOG("C: --Releasing pICar");
00595         pICar->Release();
00596       }
00597       break;
00598     case IDM_UCAR_STEER:
00599       LOG("C: === UtilityCar Menu: ICar::Steer");
00600       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00601       {
00602         LOG("C: --Calling pICar->Steer");
00603         pICar->Steer(10);
00604         LOG("C: --Releasing pICar");
00605         pICar->Release();
00606       }
00607       break;
00608     case IDM_UCAR_OFFROAD:
00609       LOG("C: === UtilityCar Menu: IUtility::Offroad");
00610       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00611       {
00612         LOG("C: --Calling pIUtility->Offroad");
00613         pIUtility->Offroad(1);
00614         LOG("C: --Releasing pIUtility");
00615         pIUtility->Release();
00616       }
00617       break;
00618     case IDM_UCAR_WINCH:
00619       LOG("C: === UtilityCar Menu: IUtility::Winch");
00620       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00621       {
00622         LOG("C: --Calling pIUtility->Winch");
00623         pIUtility->Winch(0);
00624         LOG("C: --Releasing pIUtility");
00625         pIUtility->Release();
00626       }
00627       break;
00628
00629     //----------------------------------------------------------------------
00630     // Handle LicCruiseCar Menu Commands.
00631     //----------------------------------------------------------------------
00632     case IDM_CCAR_CREATE:
00633       LOG("C: === LicCruiseCar Menu: Create.");
00634       if (NULL == m_pLicCruiseCar)
00635       {
00636         // Call COM service to create an instance.
00637         hr = CoCreateInstance(
00638                CLSID_LicCruiseCar,
00639                NULL,
00640                CLSCTX_INPROC_SERVER,
00641                IID_IUnknown,
00642                (PPVOID)&m_pLicCruiseCar);
00643         if (SUCCEEDED(hr))
00644         {
00645           ::CheckMenuItem(
00646               hMenu,
00647               IDM_CCAR_CREATE,
00648               MF_BYCOMMAND | MF_CHECKED);
00649         }
00650         else
00651         {
00652           LOGERROR("C: ???? CoCreateInstance",hr);
00653           if (CLASS_E_NOTLICENSED == hr)
00654             m_pMsgBox->ErrorID(IDS_NOLICENSE);
00655         }
00656       }
00657       else
00658         LOG("C: ???? LicCruiseCar already exists.");
00659       break;
00660     case IDM_CCAR_RELEASE:
00661       LOG("C: === LicCruiseCar Menu: Release.");
00662       if (NULL != m_pLicCruiseCar)
00663       {
00664         RELEASE_INTERFACE(m_pLicCruiseCar);
00665         // We ask COM to unload any unused COM Servers.
00666         CoFreeUnusedLibraries();
00667         ::CheckMenuItem(
00668             hMenu,
00669             IDM_CCAR_CREATE,
00670             MF_BYCOMMAND | MF_UNCHECKED);
00671       }
00672       else
00673         LOG("C: ???? No LicCruiseCar to Release.");
00674       break;
00675     case IDM_CCAR_SHIFT:
00676       LOG("C: === LicCruiseCar Menu: ICar::Shift");
00677       if (GetInterface(m_pLicCruiseCar, IID_ICar, (PPVOID)&pICar))
00678       {
00679         LOG("C: --Calling pICar->Shift");
00680         pICar->Shift(4);
00681         LOG("C: --Releasing pICar");
00682         pICar->Release();
00683       }
00684       break;
00685     case IDM_CCAR_CLUTCH:
00686       LOG("C: === LicCruiseCar Menu: ICar::Clutch");
00687       if (GetInterface(m_pLicCruiseCar, IID_ICar, (PPVOID)&pICar))
00688       {
00689         LOG("C: --Calling pICar->Clutch");
00690         pICar->Clutch(100);
00691         LOG("C: --Releasing pICar");
00692         pICar->Release();
00693       }
00694       break;
00695     case IDM_CCAR_SPEED:
00696       LOG("C: === LicCruiseCar Menu: ICar::Speed");
00697       if (GetInterface(m_pLicCruiseCar, IID_ICar, (PPVOID)&pICar))
00698       {
00699         LOG("C: --Calling pICar->Speed");
00700         pICar->Speed(60);
00701         LOG("C: --Releasing pICar");
00702         pICar->Release();
00703       }
00704       break;
00705     case IDM_CCAR_STEER:
00706       LOG("C: === LicCruiseCar Menu: ICar::Steer");
00707       if (GetInterface(m_pLicCruiseCar, IID_ICar, (PPVOID)&pICar))
00708       {
00709         LOG("C: --Calling pICar->Steer");
00710         pICar->Steer(0);
00711         LOG("C: --Releasing pICar");
00712         pICar->Release();
00713       }
00714       break;
00715     case IDM_CCAR_ENGAGE:
00716       LOG("C: === LicCruiseCar Menu: ICruise::Engage");
00717       if (GetInterface(m_pLicCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00718       {
00719         LOG("C: --Calling pICruise->Engage");
00720         pICruise->Engage(TRUE);
00721         LOG("C: --Releasing pICruise");
00722         pICruise->Release();
00723       }
00724       break;
00725     case IDM_CCAR_ADJUST:
00726       LOG("C: === LicCruiseCar Menu: ICruise::Adjust");
00727       if (GetInterface(m_pLicCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00728       {
00729         LOG("C: --Calling pICruise->Adjust");
00730         pICruise->Adjust(FALSE);
00731         LOG("C: --Releasing pICruise");
00732         pICruise->Release();
00733       }
00734       break;
00735
00736     //----------------------------------------------------------------------
00737     // Handle UtilityCruiseCar Menu Commands.
00738     //----------------------------------------------------------------------
00739     case IDM_UCRU_GETLICKEY:
00740       LOG("C: === UtilityCruiseCar Menu: Get License Key.");
00741       // Get a class factory for LicCruiseCar and issue IClassFactory's
00742       // CreateInstance method to manufacture a COLicCruiseCar COM object.
00743       hr = CoGetClassObject(
00744              CLSID_LicCruiseCar,
00745              CLSCTX_INPROC_SERVER,
00746              NULL,
00747              IID_IClassFactory2,
00748              (PPVOID)&pICF2LicCruiseCar);
00749       if (SUCCEEDED(hr))
00750       {
00751         LOG("C: LicCruiseCar's IClassFactory2 obtained.");
00752         hr = pICF2LicCruiseCar->RequestLicKey(0, &m_bstrLicKey);
00753         pICF2LicCruiseCar->Release();
00754       }
00755
00756       if (SUCCEEDED(hr))
00757       {
00758         LOG("C: Obtained LicCruiseCar's Runtime License Key.");
00759         ::CheckMenuItem(
00760             hMenu,
00761             IDM_UCRU_GETLICKEY,
00762             MF_BYCOMMAND | MF_CHECKED);
00763       }
00764       else
00765       {
00766         LOGERROR("C: ???? CoGetClassObject",hr);
00767         LOG("C: Failed to Obtain LicCruiseCar's Runtime License Key.");
00768       }
00769       break;
00770     case IDM_UCRU_CLEARLICKEY:
00771       LOG("C: === UtilityCruiseCar Menu: Clear License Key.");
00772       SysFreeString(m_bstrLicKey);
00773       m_bstrLicKey = NULL;
00774       ::CheckMenuItem(
00775           hMenu,
00776           IDM_UCRU_GETLICKEY,
00777           MF_BYCOMMAND | MF_UNCHECKED);
00778       break;
00779     case IDM_UCRU_CREATE:
00780       LOG("C: === UtilityCruiseCar Menu: Create with Key.");
00781       if (NULL == m_pUtilityCruiseCar)
00782       {
00783         // Call a create function to create an instance.
00784         hr = CreateUtilityCruiseCar(
00785                NULL,
00786                IID_IUnknown,
00787                m_bstrLicKey,
00788                (PPVOID)&m_pUtilityCruiseCar);
00789         if (SUCCEEDED(hr))
00790         {
00791           ::CheckMenuItem(
00792               hMenu,
00793               IDM_UCRU_CREATE,
00794               MF_BYCOMMAND | MF_CHECKED);
00795         }
00796         else
00797         {
00798           LOGERROR("C: ???? UtilityCruiseCar creation",hr);
00799           if (CLASS_E_NOTLICENSED == hr)
00800             m_pMsgBox->ErrorID(IDS_NORUNLICENSE);
00801         }
00802       }
00803       else
00804         LOG("C: ???? UtilityCruiseCar already exists.");
00805       break;
00806     case IDM_UCRU_RELEASE:
00807       LOG("C: === UtilityCruiseCar Menu: Release.");
00808       if (NULL != m_pUtilityCruiseCar)
00809       {
00810         RELEASE_INTERFACE(m_pUtilityCruiseCar);
00811         // We ask COM to unload any unused COM Servers.
00812         CoFreeUnusedLibraries();
00813         ::CheckMenuItem(
00814             hMenu,
00815             IDM_UCRU_CREATE,
00816             MF_BYCOMMAND | MF_UNCHECKED);
00817       }
00818       else
00819         LOG("C: ???? No UtilityCruiseCar to Release.");
00820       break;
00821     case IDM_UCRU_SHIFT:
00822       LOG("C: === UtilityCruiseCar Menu: ICar::Shift");
00823       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00824       {
00825         LOG("C: --Calling pICar->Shift");
00826         pICar->Shift(1);
00827         LOG("C: --Releasing pICar");
00828         pICar->Release();
00829       }
00830       break;
00831     case IDM_UCRU_CLUTCH:
00832       LOG("C: === UtilityCruiseCar Menu: ICar::Clutch");
00833       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00834       {
00835         LOG("C: --Calling pICar->Clutch");
00836         pICar->Clutch(80);
00837         LOG("C: --Releasing pICar");
00838         pICar->Release();
00839       }
00840       break;
00841     case IDM_UCRU_SPEED:
00842       LOG("C: === UtilityCruiseCar Menu: ICar::Speed");
00843       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00844       {
00845         LOG("C: --Calling pICar->Speed");
00846         pICar->Speed(10);
00847         LOG("C: --Releasing pICar");
00848         pICar->Release();
00849       }
00850       break;
00851     case IDM_UCRU_STEER:
00852       LOG("C: === UtilityCruiseCar Menu: ICar::Steer");
00853       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00854       {
00855         LOG("C: --Calling pICar->Steer");
00856         pICar->Steer(10);
00857         LOG("C: --Releasing pICar");
00858         pICar->Release();
00859       }
00860       break;
00861     case IDM_UCRU_ENGAGE:
00862       LOG("C: === UtilityCruiseCar Menu: ICruise::Engage");
00863       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00864       {
00865         LOG("C: --Calling pICruise->Engage");
00866         pICruise->Engage(FALSE);
00867         LOG("C: --Releasing pICruise");
00868         pICruise->Release();
00869       }
00870       break;
00871     case IDM_UCRU_ADJUST:
00872       LOG("C: === UtilityCruiseCar Menu: ICruise::Adjust");
00873       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00874       {
00875         LOG("C: --Calling pICruise->Adjust");
00876         pICruise->Adjust(FALSE);
00877         LOG("C: --Releasing pICruise");
00878         pICruise->Release();
00879       }
00880       break;
00881     case IDM_UCRU_OFFROAD:
00882       LOG("C: === UtilityCruiseCar Menu: IUtility::Offroad");
00883       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00884       {
00885         LOG("C: --Calling pIUtility->Offroad");
00886         pIUtility->Offroad(3);
00887         LOG("C: --Releasing pIUtility");
00888         pIUtility->Release();
00889       }
00890       break;
00891     case IDM_UCRU_WINCH:
00892       LOG("C: === UtilityCruiseCar Menu: IUtility::Winch");
00893       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00894       {
00895         LOG("C: --Calling pIUtility->Winch");
00896         pIUtility->Winch(0);
00897         LOG("C: --Releasing pIUtility");
00898         pIUtility->Release();
00899       }
00900       break;
00901
00902     //----------------------------------------------------------------------
00903     // Handle Log Menu Commands.
00904     //----------------------------------------------------------------------
00905     case IDM_LOG_LOGCLEAR:
00906       // Clear the message log.
00907       m_pMsgLog->Clear();
00908       // Use macro to log messages.
00909       LOGID(IDS_START_MESSAGE_LOG);
00910       break;
00911     case IDM_LOG_LICSERVER:
00912       // Toggle the state of the Message Logging from LICSERVE.
00913       // Toggle the checkmark indicator on the menu selection as well.
00914       {
00915         BOOL bLogServer = ::GetMenuState(
00916                             hMenu,
00917                             IDM_LOG_LICSERVER,
00918                             MF_BYCOMMAND) & MF_CHECKED;
00919         if (bLogServer)
00920         {
00921           LOG("C: Stop LICSERVE Server Trace Logging.");
00922           RELEASE_INTERFACE(m_pLicCarSample);
00923           // We ask COM to unload any unused COM Servers.
00924           CoFreeUnusedLibraries();
00925           ::CheckMenuItem(
00926               hMenu,
00927               IDM_LOG_LICSERVER,
00928               MF_BYCOMMAND | MF_UNCHECKED);
00929         }
00930         else
00931         {
00932           LOG("C: Start LICSERVE Server Trace Logging.");
00933           hr = CoCreateInstance(
00934                  CLSID_LicCarSample,
00935                  NULL,
00936                  CLSCTX_INPROC_SERVER,
00937                  IID_ISample,
00938                  (PPVOID)&m_pLicCarSample);
00939           if (SUCCEEDED(hr))
00940             hr = m_pLicCarSample->Init(m_hWnd, (PVOID)g_pMsgLog);
00941
00942           if (SUCCEEDED(hr))
00943           {
00944             ::CheckMenuItem(
00945                 hMenu,
00946                 IDM_LOG_LICSERVER,
00947                 MF_BYCOMMAND | MF_CHECKED);
00948           }
00949           else
00950           {
00951             RELEASE_INTERFACE(m_pLicCarSample);
00952             // We ask COM to unload any unused COM Servers.
00953             CoFreeUnusedLibraries();
00954             m_pMsgBox->ErrorID(IDS_NOLICSERVER);
00955           }
00956         }
00957       }
00958       break;
00959     case IDM_LOG_DLLSERVER:
00960       // Toggle the state of the Message Logging from DLLSERVE.
00961       // Toggle the checkmark indicator on the menu selection as well.
00962       {
00963         BOOL bLogServer = ::GetMenuState(
00964                             hMenu,
00965                             IDM_LOG_DLLSERVER,
00966                             MF_BYCOMMAND) & MF_CHECKED;
00967         if (bLogServer)
00968         {
00969           LOG("C: Stop DLLSERVE Server Trace Logging.");
00970           RELEASE_INTERFACE(m_pDllCarSample);
00971           // We ask COM to unload any unused COM Servers.
00972           CoFreeUnusedLibraries();
00973           ::CheckMenuItem(
00974               hMenu,
00975               IDM_LOG_DLLSERVER,
00976               MF_BYCOMMAND | MF_UNCHECKED);
00977         }
00978         else
00979         {
00980           LOG("C: Start DLLSERVE Server Trace Logging.");
00981           hr = CoCreateInstance(
00982                  CLSID_DllCarSample,
00983                  NULL,
00984                  CLSCTX_INPROC_SERVER,
00985                  IID_ISample,
00986                  (PPVOID)&m_pDllCarSample);
00987           if (SUCCEEDED(hr))
00988             hr = m_pDllCarSample->Init(m_hWnd, (PVOID)g_pMsgLog);
00989
00990           if (SUCCEEDED(hr))
00991           {
00992             ::CheckMenuItem(
00993                 hMenu,
00994                 IDM_LOG_DLLSERVER,
00995                 MF_BYCOMMAND | MF_CHECKED);
00996           }
00997           else
00998           {
00999             RELEASE_INTERFACE(m_pDllCarSample);
01000             // We ask COM to unload any unused COM Servers.
01001             CoFreeUnusedLibraries();
01002             m_pMsgBox->ErrorID(IDS_NODLLSERVER);
01003           }
01004         }
01005       }
01006       break;
01007     case IDM_LOG_LOGGING:
01008       // Toggle the state of all Message Logging.
01009       // Toggle the checkmark indicator on the menu selection as well.
01010       {
01011         BOOL bLogging = ::GetMenuState(
01012                             hMenu,
01013                             IDM_LOG_LOGGING,
01014                             MF_BYCOMMAND) & MF_CHECKED;
01015         if (bLogging)
01016         {
01017           m_pMsgLog->Logging(FALSE);
01018           ::CheckMenuItem(
01019               hMenu,
01020               IDM_LOG_LOGGING,
01021               MF_BYCOMMAND | MF_UNCHECKED);
01022         }
01023         else
01024         {
01025           m_pMsgLog->Logging(TRUE);
01026           ::CheckMenuItem(
01027               hMenu,
01028               IDM_LOG_LOGGING,
01029               MF_BYCOMMAND | MF_CHECKED);
01030         }
01031       }
01032       break;
01033     case IDM_LOG_COPYCLIP:
01034       // Copy trace message log to clipboard.
01035       m_pMsgLog->Copy();
01036       break;
01037
01038     //----------------------------------------------------------------------
01039     // Handle Help Menu Commands.
01040     //----------------------------------------------------------------------
01041     case IDM_HELP_CONTENTS:
01042       // We have some stubbed support here for bringing up the online
01043       // Help for this application.
01044       ReadHelp(m_hWnd, m_szHelpFile);
01045       break;
01046     case IDM_HELP_TUTORIAL:
01047       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
01048       // tutorial narrative file associated with this tutorial code sample.
01049       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
01050       break;
01051     case IDM_HELP_TUTLICSERVER:
01052       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
01053       // tutorial narrative file associated with the LICSERVE server.
01054       ReadTutorial(m_hInst, m_hWnd, TEXT(LICSERVE_TUTFILE_STR));
01055       break;
01056     case IDM_HELP_TUTDLLSERVER:
01057       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
01058       // tutorial narrative file associated with the DLLSERVE server.
01059       ReadTutorial(m_hInst, m_hWnd, TEXT(DLLSERVE_TUTFILE_STR));
01060       break;
01061     case IDM_HELP_READSOURCE:
01062       // Call the APPUTIL utility function ReadSource to allow the
01063       // user to open and read any of the source files of LICCLIEN.
01064       ReadSource(m_hWnd, &m_ofnFile);
01065       break;
01066     case IDM_HELP_ABOUT:
01067       {
01068         CAboutBox dlgAboutBox;
01069
01070         LOG("C: === Help Menu: About LICCLIEN.");
01071         // Show the standard About Box dialog for this EXE by telling the
01072         // dialog C++ object to show itself by invoking its ShowDialog
01073         // method.  Pass it this EXE instance and the parent window handle.
01074         // Use a dialog resource ID for the dialog template stored in
01075         // this EXE module's resources.
01076         dlgAboutBox.ShowDialog(
01077           m_hInst,
01078           MAKEINTRESOURCE(IDM_HELP_ABOUT),
01079           m_hWnd);
01080       }
01081       break;
01082     case IDM_HELP_ABOUTLICSERVER:
01083       // Call the LicCarSample in LICSERVE to show its AboutBox dialog.
01084       LOG("C: === Help Menu: About LICSERVE.");
01085       if (NULL != m_pLicCarSample)
01086         m_pLicCarSample->AboutBox(m_hWnd);
01087       break;
01088     case IDM_HELP_ABOUTDLLSERVER:
01089       // Call the DllCarSample in DLLSERVE to show its AboutBox dialog.
01090       LOG("C: === Help Menu: About DLLSERVE.");
01091       if (NULL != m_pDllCarSample)
01092         m_pDllCarSample->AboutBox(m_hWnd);
01093       break;
01094
01095     default:
01096       // Defer all messages NOT handled here to the Default Window Proc.
01097       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
01098       break;
01099   }
01100
01101   return(lResult);
01102 }
01103
01104
01105 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01106   Method:   CMainWindow::WindowProc
01107
01108   Summary:  Main window procedure for this window object.  See CVirWindow
01109             in the APPUTIL library (APPUTIL.CPP) for details on how this
01110             method gets called by the global WindowProc.
01111
01112   Args:     UINT uMsg,
01113               Windows message that is "sent" to this window.
01114             WPARAM wParam,
01115               First message parameter (word sized).
01116             LPARAM lParam)
01117               Second message parameter (long sized).
01118
01119   Modifies: ...
01120
01121   Returns:  LRESULT
01122               Standard Windows WindowProc return value.
01123 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01124 LRESULT CMainWindow::WindowProc(
01125           UINT uMsg,
01126           WPARAM wParam,
01127           LPARAM lParam)
01128 {
01129   LRESULT lResult = FALSE;
01130
01131   switch (uMsg)
01132   {
01133     case WM_CREATE:
01134       {
01135         // Setup for painting text in this window.
01136         HDC hdc = GetDC(m_hWnd);
01137         ::GetTextMetrics(hdc, &m_tm);
01138         ::ReleaseDC(m_hWnd, hdc);
01139       }
01140       break;
01141
01142     case WM_MEASUREITEM:
01143       // Get setup for painting text in this window.
01144       {
01145         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
01146         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
01147         lpmis->itemWidth = m_wWidth;
01148         lResult = TRUE;
01149       }
01150
01151     case WM_SIZE:
01152       // Handle a resize of this window.
01153       m_wWidth = LOWORD(lParam);
01154       m_wHeight = HIWORD(lParam);
01155       // Resize the Message Log ListBox
01156       m_pMsgLog->Resize(m_wWidth, m_wHeight);
01157       break;
01158
01159     case WM_COMMAND:
01160       // Dispatch and handle any Menu command messages received.
01161       lResult = DoMenu(wParam, lParam);
01162       break;
01163
01164     case WM_CLOSE:
01165       // The user selected Close on the main window's System menu
01166       // or Exit on the File menu.
01167     case WM_QUIT:
01168       // If the app is being quit then close any associated help windows.
01169     default:
01170       // Defer all messages NOT handled here to the Default Window Proc.
01171       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
01172       break;
01173   }
01174
01175   return(lResult);
01176 }
01177
01178
01179 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01180   Function: UnicodeOk
01181
01182   Summary:  Checks if the platform will handle unicode versions of
01183             Win32 string API calls.
01184
01185   Args:     void
01186
01187   Returns:  BOOL
01188               TRUE if unicode support; FALSE if not.
01189 ------------------------------------------------------------------------F-F*/
01190 BOOL UnicodeOk(void)
01191 {
01192   BOOL bOk = TRUE;
01193   TCHAR szUserName[MAX_STRING_LENGTH];
01194   DWORD dwSize = MAX_STRING_LENGTH;
01195
01196   if (!GetUserName(szUserName, &dwSize))
01197     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
01198
01199   return bOk;
01200 }
01201
01202
01203 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01204   Function: InitApplication
01205
01206   Summary:  Initializes the application and registers its main window
01207             class. InitApplication is called only once (in WinMain).
01208
01209   Args:     HINSTANCE hInstance)
01210               Handle to the first instance of the application.
01211
01212   Returns:  BOOL.
01213               TRUE if success.
01214               FALSE if fail.
01215 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01216 BOOL InitApplication(
01217        HINSTANCE hInstance)
01218 {
01219   BOOL bOk;
01220   // The window class for all instances of the main frame window.
01221   WNDCLASSEX wcf;
01222
01223   // Assign the appropriate values for this main frame window class.
01224   wcf.cbSize        = sizeof(WNDCLASSEX);
01225   wcf.cbClsExtra    = 0;            // No per-class extra data.
01226   wcf.cbWndExtra    = 0;            // No per-window extra data.
01227   wcf.hInstance     = hInstance;    // Application module instance.
01228   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
01229                                     // APPUTIL for all CVirWindows).
01230   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
01231   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
01232                                 hInstance,
01233                                 TEXT("AppIcon"));
01234   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
01235                                 hInstance,
01236                                 TEXT("AppIcon"),
01237                                 IMAGE_ICON,
01238                                 16, 16,
01239                                 0);
01240   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
01241   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
01242   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
01243   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
01244
01245   // Register the window class and return FALSE if unsuccesful.
01246   bOk = RegisterClassEx(&wcf);
01247
01248   return (bOk);
01249 }
01250
01251
01252 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01253   Function: WinMain
01254
01255   Summary:  The Windows main entry point function for this application.
01256             Initializes the application, the COM Libraries, and starts
01257             the main application message loop.
01258
01259   Args:     HINSTANCE hInstance,
01260               Instance handle; a new one for each invocation of this app.
01261             HINSTANCE hPrevInstance,
01262               Instance handle of the previous instance. NULL in Win32.
01263             LPSTR lpCmdLine,
01264               Windows passes a pointer to the application's
01265               invocation command line.
01266             int nCmdShow)
01267               Bits telling the show state of the application.
01268
01269   Returns:  int
01270               msg.wParam (upon exit of message loop).
01271               FALSE if this instance couldn't initialize and run.
01272 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01273 extern "C" int PASCAL WinMain(
01274                         HINSTANCE hInstance,
01275                         HINSTANCE hPrevInstance,
01276                         LPSTR lpCmdLine,
01277                         int nCmdShow)
01278 {
01279   CMainWindow* pWin = NULL;
01280   MSG msg;
01281   HACCEL hAccel;
01282   int iRun = FALSE;
01283
01284   // If we were compiled for UNICODE and the platform seems OK with this
01285   // then proceed.  Else we error and exit the app.
01286   if (UnicodeOk())
01287   {
01288     // Call to initialize the COM Library.  Use the SUCCEEDED macro
01289     // to detect success.  If fail then exit app with error message.
01290     if (SUCCEEDED(CoInitialize(NULL)))
01291     {
01292       // If we succeeded in initializing the COM Library we proceed to
01293       // initialize the application.  If we can't init the application
01294       // then we signal shut down with an error message exit.
01295       iRun = InitApplication(hInstance);
01296       if (iRun)
01297       {
01298         // Assume we'll set iRun to TRUE when initialization is done.
01299         iRun = FALSE;
01300         // We are still go for running so we try to create a nifty new
01301         // CMainWindow object for this app instance.
01302         pWin = new CMainWindow;
01303         if (NULL != pWin)
01304         {
01305           // Now we initialize an instance of the new CMainWindow.
01306           // This includes creating the main window.
01307           if (pWin->InitInstance(hInstance, nCmdShow))
01308           {
01309             // Load the keyboard accelerators from the resources.
01310             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
01311             if (NULL != hAccel)
01312             {
01313               // Signal App Initialization is successfully done.
01314               iRun = TRUE;
01315             }
01316           }
01317         }
01318       }
01319
01320       if (iRun)
01321       {
01322         // If we initialized the app instance properly then we are still
01323         // go for running.  We then start up the main message pump for
01324         // the application.
01325         while (GetMessage(&msg, NULL, 0, 0))
01326         {
01327           if (!TranslateAccelerator(
01328                  pWin->GetHwnd(),
01329                  hAccel,
01330                  &msg))
01331           {
01332             TranslateMessage(&msg);
01333             DispatchMessage(&msg);
01334           }
01335         }
01336
01337         // We ask COM to unload any unused COM Servers.
01338         CoFreeUnusedLibraries();
01339
01340         // We'll pass to Windows the reason why we exited the message loop.
01341         iRun = (int) msg.wParam;
01342       }
01343       else
01344       {
01345         // We failed to initialize the application. Put up error message
01346         // box saying that application couldn't be initialized.  Parent
01347         // window is desktop (ie, NULL). Exit the failed application
01348         // (ie, by returning FALSE to WinMain).
01349         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
01350
01351         // Delete the CMainWindow object.
01352         DELETE_POINTER(pWin);
01353       }
01354
01355       // We're exiting this app (either normally or by init failure) so
01356       // shut down the COM Library.
01357       CoUninitialize();
01358     }
01359     else
01360     {
01361       // We failed to Initialize the COM Library. Put up error message box
01362       // saying that COM Library couldn't be initialized.  Parent window
01363       // is desktop (ie, NULL). Exit the failed application (ie, by
01364       // returning FALSE to WinMain).
01365       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
01366     }
01367   }
01368   else
01369   {
01370     // If we were compiled for UNICODE but the platform has problems with
01371     // this then indicate an error and exit the app immediately.
01372     CHAR szMsg[MAX_STRING_LENGTH];
01373
01374     if (LoadStringA(
01375           hInstance,
01376           IDS_NOUNICODE,
01377           szMsg,
01378           MAX_STRING_LENGTH))
01379     {
01380       MessageBoxA(
01381         NULL,
01382         szMsg,
01383         ERROR_TITLE_STR,
01384         MB_OK | MB_ICONEXCLAMATION);
01385     }
01386   }
01387
01388   return iRun;
01389 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/NewsEventClass/newseventclass.Idl Source File

  • Com
  • Services
  • Events
  • EventNews
  • NewsEventClass

newseventclass.Idl

Go to the documentation of this file.
00001 // NewsEventClass.idl : IDL source for NewsEventClass.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (NewsEventClass.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009 import "..\include\News.idl";
00010
00011 [
00012   uuid(94007C90-0F00-11D3-9257-0080C7C30D72),
00013   version(1.0),
00014   helpstring("NewsEventClass 1.0 Type Library")
00015 ]
00016 library NEWSEVENTCLASSLib
00017 {
00018   importlib("stdole32.tlb");
00019   importlib("stdole2.tlb");
00020
00021   [
00022     uuid(997FF9C0-0F01-11D3-9257-0080C7C30D72),
00023     helpstring("NewsEvent Class")
00024   ]
00025   coclass NewsEvent
00026   {
00027     [default] interface INewsEvent;
00028   };
00029 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Cfact.h Source File

  • NetDS
  • SyncMgr
  • SyncDir

Cfact.h

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #ifndef _SYNCHNDLR_H
00013 #define _SYNCHNDLR_H
00014
00015 class CClassFactory : public IClassFactory
00016 {
00017 protected:
00018     ULONG   m_cRef;
00019
00020 public:
00021     CClassFactory();
00022     ~CClassFactory();
00023
00024     //IUnknown members
00025     STDMETHODIMP        QueryInterface(REFIID, LPVOID FAR *);
00026     STDMETHODIMP_(ULONG)    AddRef();
00027     STDMETHODIMP_(ULONG)    Release();
00028
00029     //IClassFactory members
00030     STDMETHODIMP        CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
00031     STDMETHODIMP        LockServer(BOOL);
00032
00033 };
00034 typedef CClassFactory *LPCClassFactory;
00035
00036
00037 #endif // _SYNCHNDLR_H
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/RecordsetEvents.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

RecordsetEvents.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dispatch-only interface RecordsetEvents
00019 /** @com.interface(iid=00000266-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DISPATCH) */
00020 public interface RecordsetEvents extends IUnknown
00021 {
00022   /** @com.method(dispid=9, type=METHOD, name="WillChangeField")
00023       @com.parameters([in,type=I4] cFields, [in,type=VARIANT] Fields, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00024   public void WillChangeField(int cFields, Variant Fields, int[] adStatus, msado15._Recordset pRecordset);
00025
00026   /** @com.method(dispid=10, type=METHOD, name="FieldChangeComplete")
00027       @com.parameters([in,type=I4] cFields, [in,type=VARIANT] Fields, [in,type=DISPATCH] pError, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00028   public void FieldChangeComplete(int cFields, Variant Fields, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset);
00029
00030   /** @com.method(dispid=11, type=METHOD, name="WillChangeRecord")
00031       @com.parameters([in,type=I4] adReason, [in,type=I4] cRecords, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00032   public void WillChangeRecord(int adReason, int cRecords, int[] adStatus, msado15._Recordset pRecordset);
00033
00034   /** @com.method(dispid=12, type=METHOD, name="RecordChangeComplete")
00035       @com.parameters([in,type=I4] adReason, [in,type=I4] cRecords, [in,type=DISPATCH] pError, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00036   public void RecordChangeComplete(int adReason, int cRecords, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset);
00037
00038   /** @com.method(dispid=13, type=METHOD, name="WillChangeRecordset")
00039       @com.parameters([in,type=I4] adReason, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00040   public void WillChangeRecordset(int adReason, int[] adStatus, msado15._Recordset pRecordset);
00041
00042   /** @com.method(dispid=14, type=METHOD, name="RecordsetChangeComplete")
00043       @com.parameters([in,type=I4] adReason, [in,type=DISPATCH] pError, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00044   public void RecordsetChangeComplete(int adReason, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset);
00045
00046   /** @com.method(dispid=15, type=METHOD, name="WillMove")
00047       @com.parameters([in,type=I4] adReason, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00048   public void WillMove(int adReason, int[] adStatus, msado15._Recordset pRecordset);
00049
00050   /** @com.method(dispid=16, type=METHOD, name="MoveComplete")
00051       @com.parameters([in,type=I4] adReason, [in,type=DISPATCH] pError, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00052   public void MoveComplete(int adReason, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset);
00053
00054   /** @com.method(dispid=17, type=METHOD, name="EndOfRecordset")
00055       @com.parameters([in,out,elementType=BOOLEAN,type=ARRAY] fMoreData, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00056   public void EndOfRecordset(boolean[] fMoreData, int[] adStatus, msado15._Recordset pRecordset);
00057
00058   /** @com.method(dispid=18, type=METHOD, name="FetchProgress")
00059       @com.parameters([in,type=I4] Progress, [in,type=I4] MaxProgress, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00060   public void FetchProgress(int Progress, int MaxProgress, int[] adStatus, msado15._Recordset pRecordset);
00061
00062   /** @com.method(dispid=19, type=METHOD, name="FetchComplete")
00063       @com.parameters([in,type=DISPATCH] pError, [in,out,elementType=I4,type=PTR] adStatus, [in,type=DISPATCH] pRecordset) */
00064   public void FetchComplete(msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset);
00065
00066
00067   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x266, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00068 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/LogWriter/DllDatax.h Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest
  • LogWriter

DllDatax.h

Go to the documentation of this file.
00001 #if !defined(AFX_DLLDATAX_H__4C3F9EC9_088C_11D3_A115_0080C71F306F__INCLUDED_)
00002 #define AFX_DLLDATAX_H__4C3F9EC9_088C_11D3_A115_0080C71F306F__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007
00008 #ifdef _MERGE_PROXYSTUB
00009
00010 extern "C"
00011 {
00012 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
00013   LPVOID lpReserved);
00014 STDAPI PrxDllCanUnloadNow(void);
00015 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
00016 STDAPI PrxDllRegisterServer(void);
00017 STDAPI PrxDllUnregisterServer(void);
00018 }
00019
00020 #endif
00021
00022 //{{AFX_INSERT_LOCATION}}
00023 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00024
00025 #endif // !defined(AFX_DLLDATAX_H__4C3F9EC9_088C_11D3_A115_0080C71F306F__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/comp.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

comp.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "Comp.h"
00017 #include "CompData.h"
00018 #include "DataObj.h"
00019 #include "Resource.h"
00020 #include "StaticNode.h"
00021
00022                              // Tracing stuff
00023 #include "TraceMacro.h"
00024 #undef  MODULESTRING
00025 #define MODULESTRING  _T("CComponent")
00026
00027
00028 //---------------------------------------------------------------------------
00029 //  Our default constuctor provides a pointer to the parent CComponentData
00030 //  class which we cache for use in later samples.
00031 //
00032 CComponent::CComponent
00033 (
00034   CComponentData*  pParent   //[in] Points to parent object
00035 )
00036 {
00037   _ASSERT( NULL != pParent );
00038
00039   m_cRef           = 0;
00040   m_ipConsole      = NULL;
00041   m_ipConsoleVerb  = NULL;
00042   m_ipResultData   = NULL;
00043   m_ipHeaderCtrl   = NULL;
00044   m_pScopeCookie   = NULL;
00045   m_pComponentData = pParent;
00046 }
00047
00048 //---------------------------------------------------------------------------
00049 CComponent::~CComponent()
00050 {
00051 }
00052
00053 /////////////////////////////////////////////////////////////////////////////
00054 //  Implementation of IUnknown
00055
00056 //---------------------------------------------------------------------------
00057 STDMETHODIMP CComponent::QueryInterface
00058 (
00059   REFIID   riid,       //[in] Identifier of the requested interface
00060   LPVOID   *ppv        //[out] Address of requested interface
00061 )
00062 {
00063   if( !ppv )
00064     return E_FAIL;
00065
00066   *ppv = NULL;
00067
00068   if( IsEqualIID(riid, IID_IUnknown) )
00069     *ppv = static_cast<IComponent*>(this);
00070   else if( IsEqualIID(riid, IID_IComponent) )
00071     *ppv = static_cast<IComponent*>(this);
00072   else if( IsEqualIID(riid, IID_IComponent2) )
00073     *ppv = static_cast<IComponent2*>(this);
00074
00075
00076   if( *ppv )
00077   {
00078     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00079     return S_OK;
00080   }
00081
00082   return E_NOINTERFACE;
00083 }
00084
00085 //---------------------------------------------------------------------------
00086 STDMETHODIMP_(ULONG) CComponent::AddRef()
00087 {
00088   return InterlockedIncrement((LONG*)&m_cRef);
00089 }
00090
00091 //---------------------------------------------------------------------------
00092 STDMETHODIMP_(ULONG) CComponent::Release()
00093 {
00094   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00095   {
00096     delete this;
00097     return 0;
00098   }
00099   return m_cRef;
00100 }
00101
00102 /////////////////////////////////////////////////////////////////////////////
00103 // Implementation of IComponent
00104
00105 //---------------------------------------------------------------------------
00106 STDMETHODIMP CComponent::Initialize
00107 (
00108   LPCONSOLE ipConsole    //[in] Points to the console's IUnknown
00109 )
00110 {
00111   HRESULT hResult = S_FALSE;
00112
00113   // MMC20:  Do a version check here.  The check is done here rather than
00114   //         in IComponentData::Initialize since this is where the
00115   //         "Snap-in failed to initialize" error dialog is generated.
00116   if( g_CV.nMajor < 2 )
00117     return S_FALSE;
00118
00119   do
00120   {
00121     hResult = ipConsole->QueryInterface( IID_IConsole3,(VOID**)&m_ipConsole );
00122     BREAK_ON_ERROR( hResult );
00123
00124     hResult = m_ipConsole->QueryConsoleVerb( &m_ipConsoleVerb );
00125     BREAK_ON_ERROR( hResult );
00126
00127     hResult = m_ipConsole->QueryInterface( IID_IResultData,(VOID**)&m_ipResultData );
00128     BREAK_ON_ERROR( hResult );
00129
00130     hResult = m_ipConsole->QueryInterface( IID_IHeaderCtrl2,(VOID**)&m_ipHeaderCtrl );
00131     BREAK_ON_ERROR( hResult );
00132
00133   }while( 0 );
00134
00135   TRACE_HRESULT(_T("Initialize"), hResult );
00136   return hResult;
00137 }
00138
00139
00140 //---------------------------------------------------------------------------
00141 STDMETHODIMP CComponent::Notify
00142 (
00143   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00144   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00145   LONG             nArg,           //[in] Depends on the notification type
00146   LONG             nParam          //[in] Depends on the notification type
00147 )
00148 {
00149   HRESULT hResult = S_FALSE;         // Return this for unhandled notifications
00150   TRACE_EVENT( _T("Notify"), MmcEvent );
00151
00152   if( NULL == ipDataObject )         // Special case handling of notifications
00153   {                                  // which have NULL data objects
00154     switch( MmcEvent )
00155     {
00156       case MMCN_CUTORMOVE:           // DRAGDROP: New notification handler
00157       {
00158         LPBASENODE pNode = ExtractBaseNodePtr( reinterpret_cast<LPDATAOBJECT>(nArg) );
00159         hResult = pNode->OnCutOrMove( ipDataObject, nArg, nParam, (LONG_PTR)this );
00160         break;
00161       }
00162       case MMCN_CANPASTE_OUTOFPROC:  // DRAGDROP: New notification for MMC 2.0
00163       {                              // Since this has a NULL Data Object we can
00164         hResult = S_OK;              // only handle this on a global basis.  Specific
00165         if( NULL != nParam )         // target nodes will get MMCN_QUERY_PASTE
00166           *(BOOL*)nParam = TRUE;
00167
00168         break;
00169       }
00170       default:
00171         break;
00172     }
00173     return hResult;
00174   }
00175
00176   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00177   if( NULL == pNode )
00178     return E_FAIL;
00179
00180   switch( MmcEvent )
00181   {
00182     case MMCN_ADD_IMAGES:
00183       hResult = OnAddImages( ipDataObject, nArg, nParam );
00184       break;
00185
00186     case MMCN_SELECT:
00187       hResult = pNode->OnSelect( ipDataObject, nArg, nParam, (LONG_PTR)this );
00188       break;
00189
00190     // Need to cache the current scope node cookie so result nodes can
00191     // enumerate thier items in the correct window when multiple windows
00192     // are used.
00193     case MMCN_SHOW:
00194       hResult = pNode->OnShow( ipDataObject, nArg, nParam, (LONG_PTR)this );
00195       if( TRUE == nArg )
00196         m_pScopeCookie = (LONG_PTR)ExtractBaseNodePtr(ipDataObject);
00197       else
00198         m_pScopeCookie = NULL;
00199
00200       break;
00201
00202     case MMCN_VIEW_CHANGE:
00203       hResult = pNode->OnViewChange( ipDataObject, nArg, nParam, (LONG_PTR)this );
00204       break;
00205
00206     case MMCN_QUERY_PASTE:
00207       hResult = pNode->OnQueryPaste( ipDataObject, nArg, nParam, (LONG_PTR)this );
00208       break;
00209
00210     case MMCN_PASTE:
00211       hResult = pNode->OnPaste( ipDataObject, nArg, nParam, (LONG_PTR)this );
00212       break;
00213
00214     case MMCN_RENAME:
00215       hResult = pNode->OnRename( ipDataObject, nArg, nParam, (LONG_PTR)this );
00216       break;
00217
00218     default:
00219       break;
00220   }
00221   return hResult;
00222 }
00223
00224 //---------------------------------------------------------------------------
00225 //  The console doesn't care what you are returning here, the hResult
00226 //  is just a debugging aid.
00227 //
00228 STDMETHODIMP CComponent::Destroy
00229 (
00230   MMC_COOKIE nCookie   //[in] Not used
00231 )
00232 {
00233   HRESULT hResult = S_OK;
00234
00235   SAFE_RELEASE( m_ipConsole     );
00236   SAFE_RELEASE( m_ipHeaderCtrl  );
00237   SAFE_RELEASE( m_ipResultData  );
00238   SAFE_RELEASE( m_ipConsoleVerb );
00239
00240 //  SAFE_FREE_BITMAP( m_hImageStrip16 );
00241 //  SAFE_FREE_BITMAP( m_hImageStrip32 );
00242
00243   return hResult;
00244 }
00245
00246 //---------------------------------------------------------------------------
00247 STDMETHODIMP CComponent::QueryDataObject
00248 (
00249   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00250   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00251   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00252 )
00253 {
00254   _ASSERT( NULL != nCookie );
00255   HRESULT hResult = S_FALSE;
00256
00257   CDataObject* pNewObject = new CDataObject();
00258   if( NULL == pNewObject )
00259     hResult = E_OUTOFMEMORY;
00260
00261   pNewObject->SetPrivateData( nCookie, (ULONG)nEnumType );
00262
00263   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00264
00265   return hResult;
00266 }
00267
00268 //---------------------------------------------------------------------------
00269 //  This method not used when the Console's QI for IComponent2 is successful
00270 //
00271 STDMETHODIMP CComponent::GetResultViewType
00272 (
00273   MMC_COOKIE          nCookie,     //[in]  Indentifier of selected node
00274   LPOLESTR __RPC_FAR* ppViewType,  //[out] Points to view type string
00275   long __RPC_FAR*     pViewOptions //[out] Points to MMC_VIEW_OPTIONS enumeration
00276 )
00277 {
00278   return E_NOTIMPL;
00279 }
00280
00281
00282 //---------------------------------------------------------------------------
00283 STDMETHODIMP CComponent::GetDisplayInfo
00284 (
00285   RESULTDATAITEM __RPC_FAR* pResultDataItem  //[in-out] Result item struct
00286 )
00287 {
00288   _ASSERT( NULL != pResultDataItem );
00289   _ASSERT( NULL != pResultDataItem->lParam );
00290
00291   HRESULT  hResult = S_FALSE;
00292
00293   LPBASENODE pNode = reinterpret_cast<LPBASENODE>(pResultDataItem->lParam);
00294   hResult = pNode->GetDisplayInfo( pResultDataItem );
00295
00296   //TRACE_HRESULT( _T("GetDisplayInfo"), hResult );
00297   return hResult;
00298 }
00299
00300 //---------------------------------------------------------------------------
00301 STDMETHODIMP CComponent::CompareObjects
00302 (
00303   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00304   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00305 )
00306 {
00307   return E_NOTIMPL;
00308 }
00309
00310 //---------------------------------------------------------------------------
00311 HRESULT CComponent::QueryDispatch
00312 (
00313   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00314   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00315   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00316 )
00317 {
00318   return E_NOTIMPL;
00319 }
00320
00321 //---------------------------------------------------------------------------
00322 //  This method is called to retrieve Result View information when the
00323 //  Snap-in supports IComponent2.  Incomplete implementation could
00324 //  result in the error:  "Snap-in failed to initialize"
00325 //
00326 HRESULT CComponent::GetResultViewType2
00327 (
00328   MMC_COOKIE             nCookie,  //[in] Identifier of object
00329   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00330 )
00331 {
00332   HRESULT hResult  = S_FALSE;
00333   LPBASENODE pNode = NULL;
00334
00335   if( NULL == nCookie )
00336     pNode = m_pComponentData->GetStaticNode();
00337   else
00338     pNode = reinterpret_cast<LPBASENODE>(nCookie);
00339
00340   hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00341
00342   TRACE_HRESULT(_T("GetResultViewType2"), hResult );
00343   return hResult;
00344 }
00345
00346
00347 //---------------------------------------------------------------------------
00348 HRESULT CComponent::RestoreResultView
00349 (
00350   MMC_COOKIE             nCookie,  //[in] Identifier of object
00351   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00352 )
00353 {
00354   return E_NOTIMPL;
00355 }
00356
00357
00358 /////////////////////////////////////////////////////////////////////////////
00359 //  Notification handlers
00360
00361
00362 //---------------------------------------------------------------------------
00363 HRESULT CComponent::OnAddImages
00364 (
00365   LPDATAOBJECT   ipDataObject, //[in] Points to the selected data object
00366   LPARAM         nArg,         //[in] Pointer to IImageList
00367   LPARAM         nParam        //[in] HSCOPEITEM of selected/deselected item
00368
00369 )
00370 {
00371   HRESULT hResult = S_FALSE;
00372
00373   HBITMAP hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16));
00374   HBITMAP hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32));
00375
00376   if( NULL != nArg )           // May get this when shutting down
00377   {
00378     IImageList* ipImageList = reinterpret_cast<IImageList*>(nArg);
00379     hResult = ipImageList->ImageListSetStrip( (LONG_PTR*)hImageStrip16,
00380                                               (LONG_PTR*)hImageStrip32,
00381                                               0,
00382                                               RGB(0,255,0)
00383                                             );
00384
00385     SAFE_FREE_BITMAP( hImageStrip16 );
00386     SAFE_FREE_BITMAP( hImageStrip32 );
00387   }
00388
00389   TRACE_HRESULT(_T("OnAddImages"), hResult );
00390   return hResult;
00391
00392 }
00393
00394 /////////////////////////////////////////////////////////////////////////////
00395 //  Public helper methods
00396
00397 //---------------------------------------------------------------------------
00398 //  Supplies interfaces to node objects.
00399 //
00400 HRESULT CComponent::GetInterface
00401 (
00402   DWORD dwRequestedInterface,  //[in] Request flag
00403   LONG_PTR* ppInterface        //[in-out] Interface pointer to return
00404 )
00405 {
00406   _ASSERT( NULL != ppInterface );
00407   HRESULT hResult = S_OK;
00408
00409   switch( dwRequestedInterface )
00410   {
00411     case REQUEST_ICONSOLE:
00412       _ASSERT( NULL != m_ipConsole );
00413       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00414       break;
00415
00416     case REQUEST_ICONSOLEVERB:
00417       _ASSERT( NULL != m_ipConsoleVerb );
00418       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleVerb);
00419       break;
00420
00421     case REQUEST_IRESULTDATA:
00422       _ASSERT( NULL != m_ipResultData );
00423       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipResultData);
00424       break;
00425
00426     case REQUEST_IHEADERCTRL:
00427       _ASSERT( NULL != m_ipHeaderCtrl );
00428       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipHeaderCtrl);
00429       break;
00430
00431     default:
00432       hResult = S_FALSE;
00433       *ppInterface = NULL;
00434       break;
00435   }
00436   return hResult;
00437 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ADSTYPE_TO_STRING_ENTRY Member List

This is the complete list of members for ADSTYPE_TO_STRING_ENTRY, including all inherited members.
AdsType | ADSTYPE_TO_STRING_ENTRY
pwszTypeName | ADSTYPE_TO_STRING_ENTRY
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/dbgUtil.c Source File

  • Com
  • Fundamentals
  • OleStd

dbgUtil.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2.0 Common Utilities
00004 **
00005 **    dbgutil.h
00006 **
00007 **    This file contains file contains functions to support debug output.
00008 **
00009 **    (c) Copyright Microsoft Corp. 1990 - 2000 All Rights Reserved
00010 **
00011 *************************************************************************/
00012
00013 #define STRICT  1
00014 #include "olestd.h"
00015
00016 static int s_nDbgIndent = 0;        // indent level for debug message
00017 #if defined( _DEBUG )
00018 static int s_nDbgLevel = 0;   // default dbg level printed
00019 #else
00020 static int s_nDbgLevel = 0;   // default dbg level printed
00021 #endif
00022
00023 STDAPI_(void) OleDbgPrint(
00024                 int     nDbgLvl,
00025                 LPSTR   lpszPrefix,
00026                 LPSTR   lpszMsg,
00027                 int     nIndent
00028 )
00029 {
00030         if (nDbgLvl <= s_nDbgLevel)
00031                 OleDbgPrintAlways(lpszPrefix, lpszMsg, nIndent);
00032 }
00033
00034
00035 STDAPI_(void) OleDbgPrintAlways(LPSTR lpszPrefix, LPSTR lpszMsg, int nIndent)
00036 {
00037         int i;
00038
00039         if (nIndent < 0)
00040                 OleDbgIndent(nIndent);
00041
00042         if (lpszPrefix && *lpszPrefix != '\0') {
00043                 OutputDebugString("| ");
00044                 for (i = 0; i < s_nDbgIndent; i++)
00045                         OutputDebugString("----");
00046
00047                 OutputDebugString(lpszPrefix);
00048                 OutputDebugString(": ");
00049         }
00050
00051         OutputDebugString(lpszMsg);
00052         if (nIndent > 0)
00053                 OleDbgIndent(nIndent);
00054 }
00055
00056 STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl)
00057 {
00058         s_nDbgLevel = nDbgLvl;
00059 }
00060
00061 STDAPI_(int) OleDbgGetDbgLevel( void )
00062 {
00063         return s_nDbgLevel;
00064 }
00065
00066 STDAPI_(void) OleDbgIndent(int n)
00067 {
00068         switch (n) {
00069                 case -1:
00070                         s_nDbgIndent--;
00071                         break;
00072                 case 1:
00073                         s_nDbgIndent++;
00074                         break;
00075                 case -2:
00076                         s_nDbgIndent = 0;
00077                         break;
00078         }
00079 }
00080
00081
00082 STDAPI_(void) OleDbgPrintRefCnt(
00083                 int         nDbgLvl,
00084                 LPSTR       lpszPrefix,
00085                 LPSTR       lpszMsg,
00086                 LPVOID      lpObj,
00087                 ULONG       refcnt
00088 )
00089 {
00090         if (nDbgLvl <= s_nDbgLevel)
00091                 OleDbgPrintRefCntAlways(lpszPrefix, lpszMsg, lpObj, refcnt);
00092 }
00093
00094
00095 STDAPI_(void) OleDbgPrintRefCntAlways(
00096                 LPSTR       lpszPrefix,
00097                 LPSTR       lpszMsg,
00098                 LPVOID      lpObj,
00099                 ULONG       refcnt
00100 )
00101 {
00102 #if defined( _DEBUG )
00103         char szBuf[256];
00104
00105         wsprintf(szBuf, "[obj=(0x%lx) cnt=%ld] %s", lpObj, refcnt, lpszMsg);
00106         OleDbgPrintAlways(lpszPrefix, szBuf, 0);
00107 #endif
00108 }
00109
00110
00111 STDAPI_(void) OleDbgPrintRect(
00112                 int         nDbgLvl,
00113                 LPSTR       lpszPrefix,
00114                 LPSTR       lpszMsg,
00115                 LPRECT      lpRect
00116 )
00117 {
00118         if (nDbgLvl <= s_nDbgLevel)
00119                 OleDbgPrintRectAlways(lpszPrefix, lpszMsg, lpRect);
00120 }
00121
00122
00123 STDAPI_(void) OleDbgPrintRectAlways(
00124                 LPSTR       lpszPrefix,
00125                 LPSTR       lpszMsg,
00126                 LPRECT      lpRect
00127 )
00128 {
00129 #if defined( _DEBUG )
00130         char szBuf[256];
00131
00132         wsprintf(
00133                         szBuf,
00134                         "%s: (%d,%d)-(%d,%d) %dx%d\r\n",
00135                         lpszMsg,
00136                         lpRect->left,
00137                         lpRect->top,
00138                         lpRect->right,
00139                         lpRect->bottom,
00140                         (lpRect->right-lpRect->left),
00141                         (lpRect->bottom-lpRect->top)
00142         );
00143         OleDbgPrintAlways(lpszPrefix, szBuf, 0);
00144 #endif
00145 }
00146
00147
00148 #define CASE_SCODE(sc)  \
00149                 case sc: \
00150                         lstrcpy(/*(LPSTR)*/szErrName, /*(LPSTR)*/#sc); \
00151                         break;
00152
00153 STDAPI_(void) OleDbgPrintScodeAlways(LPSTR lpszPrefix, LPSTR lpszMsg, SCODE sc)
00154 {
00155 #if defined( _DEBUG )
00156         char szBuf[256];
00157         char szErrName[40];
00158
00159         switch (sc) {
00160
00161                 /* SCODE's defined in SCODE.H */
00162
00163                 CASE_SCODE(S_OK)
00164                 CASE_SCODE(S_FALSE)
00165                 CASE_SCODE(E_UNEXPECTED)
00166                 CASE_SCODE(E_OUTOFMEMORY)
00167                 CASE_SCODE(E_INVALIDARG)
00168                 CASE_SCODE(E_NOINTERFACE)
00169                 CASE_SCODE(E_POINTER)
00170                 CASE_SCODE(E_HANDLE)
00171                 CASE_SCODE(E_ABORT)
00172                 CASE_SCODE(E_FAIL)
00173                 CASE_SCODE(E_ACCESSDENIED)
00174
00175                 /* SCODE's defined in OLE2.H */
00176
00177                 CASE_SCODE(OLE_E_OLEVERB)
00178                 CASE_SCODE(OLE_E_ADVF)
00179                 CASE_SCODE(OLE_E_ENUM_NOMORE)
00180                 CASE_SCODE(OLE_E_ADVISENOTSUPPORTED)
00181                 CASE_SCODE(OLE_E_NOCONNECTION)
00182                 CASE_SCODE(OLE_E_NOTRUNNING)
00183                 CASE_SCODE(OLE_E_NOCACHE)
00184                 CASE_SCODE(OLE_E_BLANK)
00185                 CASE_SCODE(OLE_E_CLASSDIFF)
00186                 CASE_SCODE(OLE_E_CANT_GETMONIKER)
00187                 CASE_SCODE(OLE_E_CANT_BINDTOSOURCE)
00188                 CASE_SCODE(OLE_E_STATIC)
00189                 CASE_SCODE(OLE_E_PROMPTSAVECANCELLED)
00190                 CASE_SCODE(OLE_E_INVALIDRECT)
00191                 CASE_SCODE(OLE_E_WRONGCOMPOBJ)
00192                 CASE_SCODE(OLE_E_INVALIDHWND)
00193                 CASE_SCODE(OLE_E_NOT_INPLACEACTIVE)
00194                 CASE_SCODE(OLE_E_CANTCONVERT)
00195                 CASE_SCODE(OLE_E_NOSTORAGE)
00196
00197                 CASE_SCODE(DV_E_FORMATETC)
00198                 CASE_SCODE(DV_E_DVTARGETDEVICE)
00199                 CASE_SCODE(DV_E_STGMEDIUM)
00200                 CASE_SCODE(DV_E_STATDATA)
00201                 CASE_SCODE(DV_E_LINDEX)
00202                 CASE_SCODE(DV_E_TYMED)
00203                 CASE_SCODE(DV_E_CLIPFORMAT)
00204                 CASE_SCODE(DV_E_DVASPECT)
00205                 CASE_SCODE(DV_E_DVTARGETDEVICE_SIZE)
00206                 CASE_SCODE(DV_E_NOIVIEWOBJECT)
00207
00208                 CASE_SCODE(OLE_S_USEREG)
00209                 CASE_SCODE(OLE_S_STATIC)
00210                 CASE_SCODE(OLE_S_MAC_CLIPFORMAT)
00211
00212                 CASE_SCODE(CONVERT10_E_OLESTREAM_GET)
00213                 CASE_SCODE(CONVERT10_E_OLESTREAM_PUT)
00214                 CASE_SCODE(CONVERT10_E_OLESTREAM_FMT)
00215                 CASE_SCODE(CONVERT10_E_OLESTREAM_BITMAP_TO_DIB)
00216                 CASE_SCODE(CONVERT10_E_STG_FMT)
00217                 CASE_SCODE(CONVERT10_E_STG_NO_STD_STREAM)
00218                 CASE_SCODE(CONVERT10_E_STG_DIB_TO_BITMAP)
00219                 CASE_SCODE(CONVERT10_S_NO_PRESENTATION)
00220
00221                 CASE_SCODE(CLIPBRD_E_CANT_OPEN)
00222                 CASE_SCODE(CLIPBRD_E_CANT_EMPTY)
00223                 CASE_SCODE(CLIPBRD_E_CANT_SET)
00224                 CASE_SCODE(CLIPBRD_E_BAD_DATA)
00225                 CASE_SCODE(CLIPBRD_E_CANT_CLOSE)
00226
00227                 CASE_SCODE(DRAGDROP_E_NOTREGISTERED)
00228                 CASE_SCODE(DRAGDROP_E_ALREADYREGISTERED)
00229                 CASE_SCODE(DRAGDROP_E_INVALIDHWND)
00230                 CASE_SCODE(DRAGDROP_S_DROP)
00231                 CASE_SCODE(DRAGDROP_S_CANCEL)
00232                 CASE_SCODE(DRAGDROP_S_USEDEFAULTCURSORS)
00233
00234                 CASE_SCODE(OLEOBJ_E_NOVERBS)
00235                 CASE_SCODE(OLEOBJ_E_INVALIDVERB)
00236                 CASE_SCODE(OLEOBJ_S_INVALIDVERB)
00237                 CASE_SCODE(OLEOBJ_S_CANNOT_DOVERB_NOW)
00238                 CASE_SCODE(OLEOBJ_S_INVALIDHWND)
00239                 CASE_SCODE(INPLACE_E_NOTUNDOABLE)
00240                 CASE_SCODE(INPLACE_E_NOTOOLSPACE)
00241                 CASE_SCODE(INPLACE_S_TRUNCATED)
00242
00243                 /* SCODE's defined in COMPOBJ.H */
00244
00245                 CASE_SCODE(CO_E_NOTINITIALIZED)
00246                 CASE_SCODE(CO_E_ALREADYINITIALIZED)
00247                 CASE_SCODE(CO_E_CANTDETERMINECLASS)
00248                 CASE_SCODE(CO_E_CLASSSTRING)
00249                 CASE_SCODE(CO_E_IIDSTRING)
00250                 CASE_SCODE(CO_E_APPNOTFOUND)
00251                 CASE_SCODE(CO_E_APPSINGLEUSE)
00252                 CASE_SCODE(CO_E_ERRORINAPP)
00253                 CASE_SCODE(CO_E_DLLNOTFOUND)
00254                 CASE_SCODE(CO_E_ERRORINDLL)
00255                 CASE_SCODE(CO_E_WRONGOSFORAPP)
00256                 CASE_SCODE(CO_E_OBJNOTREG)
00257                 CASE_SCODE(CO_E_OBJISREG)
00258                 CASE_SCODE(CO_E_OBJNOTCONNECTED)
00259                 CASE_SCODE(CO_E_APPDIDNTREG)
00260                 CASE_SCODE(CLASS_E_NOAGGREGATION)
00261                 CASE_SCODE(CLASS_E_CLASSNOTAVAILABLE)
00262                 CASE_SCODE(REGDB_E_READREGDB)
00263                 CASE_SCODE(REGDB_E_WRITEREGDB)
00264                 CASE_SCODE(REGDB_E_KEYMISSING)
00265                 CASE_SCODE(REGDB_E_INVALIDVALUE)
00266                 CASE_SCODE(REGDB_E_CLASSNOTREG)
00267                 CASE_SCODE(REGDB_E_IIDNOTREG)
00268                 CASE_SCODE(RPC_E_CALL_REJECTED)
00269                 CASE_SCODE(RPC_E_CALL_CANCELED)
00270                 CASE_SCODE(RPC_E_CANTPOST_INSENDCALL)
00271                 CASE_SCODE(RPC_E_CANTCALLOUT_INASYNCCALL)
00272                 CASE_SCODE(RPC_E_CANTCALLOUT_INEXTERNALCALL)
00273                 CASE_SCODE(RPC_E_CONNECTION_TERMINATED)
00274                 CASE_SCODE(RPC_E_SERVER_DIED)
00275                 CASE_SCODE(RPC_E_CLIENT_DIED)
00276                 CASE_SCODE(RPC_E_INVALID_DATAPACKET)
00277                 CASE_SCODE(RPC_E_CANTTRANSMIT_CALL)
00278                 CASE_SCODE(RPC_E_CLIENT_CANTMARSHAL_DATA)
00279                 CASE_SCODE(RPC_E_CLIENT_CANTUNMARSHAL_DATA)
00280                 CASE_SCODE(RPC_E_SERVER_CANTMARSHAL_DATA)
00281                 CASE_SCODE(RPC_E_SERVER_CANTUNMARSHAL_DATA)
00282                 CASE_SCODE(RPC_E_INVALID_DATA)
00283                 CASE_SCODE(RPC_E_INVALID_PARAMETER)
00284                 CASE_SCODE(RPC_E_UNEXPECTED)
00285
00286                 /* SCODE's defined in DVOBJ.H */
00287
00288                 CASE_SCODE(DATA_S_SAMEFORMATETC)
00289                 CASE_SCODE(VIEW_E_DRAW)
00290                 CASE_SCODE(VIEW_S_ALREADY_FROZEN)
00291                 CASE_SCODE(CACHE_E_NOCACHE_UPDATED)
00292                 CASE_SCODE(CACHE_S_FORMATETC_NOTSUPPORTED)
00293                 CASE_SCODE(CACHE_S_SAMECACHE)
00294                 CASE_SCODE(CACHE_S_SOMECACHES_NOTUPDATED)
00295
00296                 /* SCODE's defined in STORAGE.H */
00297
00298                 CASE_SCODE(STG_E_INVALIDFUNCTION)
00299                 CASE_SCODE(STG_E_FILENOTFOUND)
00300                 CASE_SCODE(STG_E_PATHNOTFOUND)
00301                 CASE_SCODE(STG_E_TOOMANYOPENFILES)
00302                 CASE_SCODE(STG_E_ACCESSDENIED)
00303                 CASE_SCODE(STG_E_INVALIDHANDLE)
00304                 CASE_SCODE(STG_E_INSUFFICIENTMEMORY)
00305                 CASE_SCODE(STG_E_INVALIDPOINTER)
00306                 CASE_SCODE(STG_E_NOMOREFILES)
00307                 CASE_SCODE(STG_E_DISKISWRITEPROTECTED)
00308                 CASE_SCODE(STG_E_SEEKERROR)
00309                 CASE_SCODE(STG_E_WRITEFAULT)
00310                 CASE_SCODE(STG_E_READFAULT)
00311                 CASE_SCODE(STG_E_SHAREVIOLATION)
00312                 CASE_SCODE(STG_E_LOCKVIOLATION)
00313                 CASE_SCODE(STG_E_FILEALREADYEXISTS)
00314                 CASE_SCODE(STG_E_INVALIDPARAMETER)
00315                 CASE_SCODE(STG_E_MEDIUMFULL)
00316                 CASE_SCODE(STG_E_ABNORMALAPIEXIT)
00317                 CASE_SCODE(STG_E_INVALIDHEADER)
00318                 CASE_SCODE(STG_E_INVALIDNAME)
00319                 CASE_SCODE(STG_E_UNKNOWN)
00320                 CASE_SCODE(STG_E_UNIMPLEMENTEDFUNCTION)
00321                 CASE_SCODE(STG_E_INVALIDFLAG)
00322                 CASE_SCODE(STG_E_INUSE)
00323                 CASE_SCODE(STG_E_NOTCURRENT)
00324                 CASE_SCODE(STG_E_REVERTED)
00325                 CASE_SCODE(STG_E_CANTSAVE)
00326                 CASE_SCODE(STG_E_OLDFORMAT)
00327                 CASE_SCODE(STG_E_OLDDLL)
00328                 CASE_SCODE(STG_E_SHAREREQUIRED)
00329                 CASE_SCODE(STG_E_NOTFILEBASEDSTORAGE)
00330                 CASE_SCODE(STG_E_EXTANTMARSHALLINGS)
00331                 CASE_SCODE(STG_S_CONVERTED)
00332
00333                 /* SCODE's defined in MONIKER.H */
00334
00335                 CASE_SCODE(MK_E_CONNECTMANUALLY)
00336                 CASE_SCODE(MK_E_EXCEEDEDDEADLINE)
00337                 CASE_SCODE(MK_E_NEEDGENERIC)
00338                 CASE_SCODE(MK_E_UNAVAILABLE)
00339                 CASE_SCODE(MK_E_SYNTAX)
00340                 CASE_SCODE(MK_E_NOOBJECT)
00341                 CASE_SCODE(MK_E_INVALIDEXTENSION)
00342                 CASE_SCODE(MK_E_INTERMEDIATEINTERFACENOTSUPPORTED)
00343                 CASE_SCODE(MK_E_NOTBINDABLE)
00344                 CASE_SCODE(MK_E_NOTBOUND)
00345                 CASE_SCODE(MK_E_CANTOPENFILE)
00346                 CASE_SCODE(MK_E_MUSTBOTHERUSER)
00347                 CASE_SCODE(MK_E_NOINVERSE)
00348                 CASE_SCODE(MK_E_NOSTORAGE)
00349                 CASE_SCODE(MK_E_NOPREFIX)
00350                 CASE_SCODE(MK_S_REDUCED_TO_SELF)
00351                 CASE_SCODE(MK_S_ME)
00352                 CASE_SCODE(MK_S_HIM)
00353                 CASE_SCODE(MK_S_US)
00354                 CASE_SCODE(MK_S_MONIKERALREADYREGISTERED)
00355
00356                 default:
00357                         lstrcpy(szErrName, "UNKNOWN SCODE");
00358         }
00359
00360         wsprintf(szBuf, "%s %s (0x%lx)\n", lpszMsg, /*(LPSTR)*/szErrName, sc);
00361         OleDbgPrintAlways(lpszPrefix, szBuf, 0);
00362 #endif  // _DEBUG
00363 }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/Driver/Driver.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • Driver

Driver.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Driver.cpp
00003   Summary:   Test client for Queued Components sample order entry application
00004   Classes:   None
00005   Functions: main
00006   Origin:
00007 ----------------------------------------------------------------------------
00008   Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00009
00010     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00011     ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00012     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00013     PARTICULAR PURPOSE
00014 ==========================================================================+*/
00015
00016 #include "stdafx.h"
00017 #include "..\DataSourceNames.h" // Data source names, userid, password
00018 #include <iostream>
00019 #include <initguid.h>
00020 #include <adoid.h>        // ADO
00021 #include <adoint.h>       // ADO
00022 #include "..\QCOrder\processFlags.h"
00023 #include "..\QCOrder\QCOrder.h"
00024
00025 // constants
00026
00027 const int nLineItemsPerOrder  = 5;
00028 const int nOrdersPerDriver    = 100;
00029 const int nSleepMilliseconds  = 250;    // database keys based on integral seconds
00030
00031 // Forward function declarations
00032
00033 HRESULT CreateOrder(long lOrderId, long lFlags);
00034
00035 HRESULT CheckHR(HRESULT hr, LPCSTR pszVerb);
00036
00037 HRESULT ExecSQLStmt(LPCWSTR pszDSN, LPCWSTR pszSQLStmt);
00038
00039 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00040   Function: main    main entry point
00041   Args:     none
00042   Returns:  int     HRESULT from any error or 0
00043 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00044
00045 int __cdecl main()
00046 {
00047   long lFlags = 0;  // no database, vtable binding, not queued calls
00048 //  lFlags |= processFlagLateBound;     // Invoke components via Automation (IDispatch)
00049 //  lFlags |= processFlagWriteDB;     // Write to Order & Shipping tables
00050   lFlags |= processFlagQueuedComponents;  // Queued calls to Ship and Notify
00051
00052   HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); // init COM library
00053   CheckHR(hr, "CoInitializeEx");
00054
00055   if (SUCCEEDED(hr))
00056   {
00057     if (lFlags & processFlagWriteDB)
00058     {
00059       ExecSQLStmt(pszOrderDSN,    // Create Order table
00060             L"create table QCSampleOrder "
00061             L"  (order_id  int, "
00062             L"   cust_id   int, "
00063             L"   line_no   int, "
00064             L"   item_id   int, "
00065             L"   quantity  int, "
00066             L"   ship_status varchar(25) )" );
00067       // Accept error - table may already exist
00068
00069       ExecSQLStmt(pszShipDSN,     // Create ship table
00070             L"create table QCSampleShip "
00071             L"  (order_id int, "
00072             L"   cust_id  int, "
00073             L"   line_no  int, "
00074             L"   item_id  int, "
00075             L"   quantity int, "
00076             L"   ship_status_enum int )" );
00077       // Accept error - table may already exist
00078     }
00079
00080     for (int ix = 0; ix < nOrdersPerDriver && SUCCEEDED(hr); ix++)
00081     {
00082       long lOrderId = time(NULL);
00083       hr = CreateOrder(lOrderId, lFlags);
00084       Sleep(nSleepMilliseconds);      // Wait between orders
00085     }
00086
00087     CoUninitialize();
00088   }
00089   return hr;
00090 }
00091
00092 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00093   Function: CreateOrder Create a single order
00094   Args:     long    lOrderId - a unique order identifier
00095   Returns:  int     HRESULT from any error or S_OK
00096 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00097
00098 HRESULT CreateOrder(long lOrderId, long lFlags)
00099 {
00100   _COM_SMARTPTR_TYPEDEF(IOrder, _uuidof(IOrder));
00101
00102   IOrderPtr pOrder;
00103
00104   HRESULT hr = pOrder.CreateInstance(_uuidof(Order));
00105   CheckHR(hr, "CoCreateInstance CLSID_Order");
00106
00107   if (SUCCEEDED(hr))
00108   {
00109     hr = pOrder->put_OrderId(lOrderId);
00110     CheckHR(hr, "put_OrderId");
00111   }
00112
00113   if (SUCCEEDED(hr))
00114   {
00115     hr = pOrder->put_CustomerId( (lOrderId % 1000) * (rand() % 1000) );
00116     CheckHR(hr, "put_CustomerId");
00117   }
00118
00119   for (int ix = 1; ix <= nLineItemsPerOrder && SUCCEEDED(hr); ix++)
00120   {
00121     // Derive ItemId and quantity from time of day
00122     hr = pOrder->LineItem(lOrderId % 100 + ix, lOrderId % 10 + 2 * ix);
00123     CheckHR(hr, "LineItem");
00124   }
00125
00126   if (SUCCEEDED(hr))
00127   {
00128     _RPT1(_CRT_WARN, "QCSamp2 %d Driver\n", lOrderId);
00129     hr = pOrder->Process(lFlags); // process the complete order
00130     CheckHR(hr, "Process");
00131   }
00132   return hr;
00133 }
00134
00135 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00136   Function: CheckHR   Tests HRESULT for an exceptional condition
00137   Args:     HRESULT   hr - the HRESULT to test
00138       LPCSTR    pszVerb - string describing function that failed
00139   Returns:  HRESULT   returns value of input HRESULT
00140 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00141
00142 HRESULT CheckHR(HRESULT hr, LPCSTR pszVerb)
00143 {
00144   if (hr != S_OK)
00145   {
00146     std::cerr << pszVerb << " hr 0x" << std::hex << hr << '\n';
00147     _RPTF2(FAILED(hr) ? _CRT_ERROR : _CRT_WARN, "%s hr 0x%x\n", pszVerb, hr);
00148   }
00149   return hr;
00150 }
00151
00152 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00153   Function: ExecSQLStmt Execute a single SQL statement using ADO
00154   Args:     LPCWSTR   pszDSN Data Source Name
00155       LPCWSTR   pszSQLStmt SQL statement to be executed
00156   Returns:  HRESULT   results from underlying functions
00157 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00158
00159 HRESULT ExecSQLStmt(LPCWSTR pszDSN, LPCWSTR pszSQLStmt)
00160 {
00161   CComPtr<ADOConnection> pADOConnection;
00162
00163   HRESULT hr = CoCreateInstance(  CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,
00164                   IID_IADOConnection, (void **) &pADOConnection);
00165   CheckHR(hr, "CoCreateInstance CLSID_CADOConnection");
00166
00167   if (SUCCEEDED(hr))
00168   {
00169     hr = pADOConnection->Open(  _bstr_t(pszDSN), _bstr_t(pszUserId),
00170                   _bstr_t(pszPassword), adOpenUnspecified);
00171     CheckHR(hr, "pADOConnection->Open");
00172   }
00173
00174   if (SUCCEEDED(hr))
00175     hr = pADOConnection->Execute(_bstr_t(pszSQLStmt), NULL, adCmdText, NULL);
00176
00177   return hr;
00178 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/compdata.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

compdata.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENTDATA_
00016 #define _CLASS_CCOMPONENTDATA_
00017
00018
00019 #include "Globals.h"
00020 #include "BaseNode.h"
00021
00022 class  CStaticNode;           // References
00023
00024 //---------------------------------------------------------------------------
00025 class CComponentData : public IComponentData2,
00026                               IExtendContextMenu   //CONTEXTMENU: New interface
00027 {
00028   private:
00029     ULONG                m_cRef;
00030     LPCONSOLE3           m_ipConsole;
00031     LPCONSOLENAMESPACE2  m_ipConsoleNameSpace2;
00032     LPIMAGELIST          m_ipScopeImage;         // Caching the image list
00033     CStaticNode*         m_pStaticNode;
00034     HSCOPEITEM           m_hStaticNode;
00035     HBITMAP              m_hImageStrip16;
00036     HBITMAP              m_hImageStrip32;
00037
00038
00039   public:
00040     CComponentData();
00041     ~CComponentData();
00042
00043     /////////////////////////////////////////////////////////////////////////
00044     // Interface IUnknown
00045     //
00046     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00047     STDMETHODIMP_(ULONG) AddRef();
00048     STDMETHODIMP_(ULONG) Release();
00049
00050     /////////////////////////////////////////////////////////////////////////
00051     // Interface IComponentData2
00052     //
00053     HRESULT STDMETHODCALLTYPE Initialize
00054             ( /*[in]*/ LPUNKNOWN pUnknown );
00055
00056     HRESULT STDMETHODCALLTYPE CreateComponent
00057             ( /*[out]*/ LPCOMPONENT __RPC_FAR* ppComponent);
00058
00059     HRESULT STDMETHODCALLTYPE Notify
00060             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00061               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00062               /*[in]*/ LONG nArg,
00063               /*[in]*/ LONG nParam
00064             );
00065
00066     HRESULT STDMETHODCALLTYPE Destroy( void);
00067
00068     HRESULT STDMETHODCALLTYPE QueryDataObject
00069             ( /*[in]*/  MMC_COOKIE uCookie,
00070               /*[in]*/  DATA_OBJECT_TYPES nEnumType,
00071               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00072             );
00073
00074     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00075             ( /*[out][in]*/ SCOPEDATAITEM __RPC_FAR* pScopeDataItem );
00076
00077     HRESULT STDMETHODCALLTYPE CompareObjects
00078             ( /*[in]*/ LPDATAOBJECT ipDataObjectA,
00079               /*[in]*/ LPDATAOBJECT ipDataObjectB
00080             );
00081
00082     HRESULT STDMETHODCALLTYPE QueryDispatch
00083             ( /*[in] */  MMC_COOKIE  nCookie,
00084               /*[in] */  DATA_OBJECT_TYPES eType,
00085               /*[out]*/  LPDISPATCH* pipDispatch
00086             );
00087
00088     /////////////////////////////////////////////////////////////////////////
00089     // Interface IExtendContextMenu
00090     //
00091     HRESULT STDMETHODCALLTYPE AddMenuItems
00092             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00093               /*[in]*/ LPCONTEXTMENUCALLBACK ipCallback,
00094               /*[out,in]*/ long __RPC_FAR* pInsertionAllowed
00095             );
00096
00097     HRESULT STDMETHODCALLTYPE Command
00098             ( /*[in]*/ long lCommandID,
00099               /*[in]*/ LPDATAOBJECT piDataObject
00100             );
00101
00102   // Pulic helper methods
00103   public:
00104     CStaticNode* GetStaticNode() { return m_pStaticNode; }
00105     HRESULT      GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00106
00107 };
00108
00109 #endif //_CLASS_CCOMPONENTDATA_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/devicenode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

devicenode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CDeviceNode class.
00014 //
00015
00016
00017 #include "DeviceNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CDeviceNode")
00024
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CDeviceNode::thisGUID = CLSID_DeviceNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 CDeviceNode::CDeviceNode()
00035 {
00036   m_SDI.mask        = DEFAULT_SDI_MASK;
00037   m_SDI.displayname = MMC_CALLBACK;
00038   m_SDI.cChildren   = 1;              // Determines if the '+' is displayed
00039   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00040
00041   m_dwAttributes    = 0;
00042   m_wzStatus        = NULL;
00043   m_hParentNode     = NULL;
00044   m_pCompData       = NULL;
00045 }
00046
00047
00048 CDeviceNode::~CDeviceNode()
00049 {
00050 }
00051
00052 //---------------------------------------------------------------------------
00053 //  This class does not make calls back to it's parent object so
00054 //  NodeProps->pParentObject is not used.
00055 //
00056 HRESULT CDeviceNode::Initialize( NODE_PROPERTIES* pNodeProps )
00057 {
00058   _ASSERT( NULL != pNodeProps );
00059
00060   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00061   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00062   wcscpy( pszTmp, pNodeProps->szNodeName );
00063   if( NULL != m_pwszNodeName )
00064     CoTaskMemFree( m_pwszNodeName );
00065
00066   m_pwszNodeName = pszTmp;
00067   m_pCompData    = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00068
00069   RefreshNodeList();                   // Add child nodes
00070                                        // and set images
00071
00072   if( pNodeProps->dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00073   {
00074     m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00075     m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00076     m_dwAttributes   |= ATTRIBUTE_BACKUP_DEVICE;
00077   }
00078   else
00079   {
00080     m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00081     m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00082     m_dwAttributes   |= ~ATTRIBUTE_BACKUP_DEVICE;
00083   }
00084
00085   m_wzStatus      = L"Online";    // Node successfully initialized
00086   m_bOnlineStatus = STATUS_ONLINE;
00087
00088   return S_OK;
00089 }
00090
00091
00092 /////////////////////////////////////////////////////////////////////////////
00093 // Implementation of virtual methods
00094
00095
00096 //---------------------------------------------------------------------------
00097 HRESULT CDeviceNode::GetResultViewType2
00098 (
00099   MMC_COOKIE             nCookie,  //[in] Identifier of object
00100   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00101 )
00102 {
00103   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00104   if( NULL == pszDescStr )
00105     return E_OUTOFMEMORY;
00106
00107   wcscpy( pszDescStr, L"DefaultListView" );
00108   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00109
00110   return S_OK;
00111 }
00112
00113
00114 //---------------------------------------------------------------------------
00115 HRESULT CDeviceNode::GetDisplayInfo
00116 (
00117   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00118 )
00119 {
00120   _ASSERT( NULL != pSDI );
00121   pSDI->displayname = m_pwszNodeName;
00122
00123   return S_OK;
00124 }
00125
00126 //---------------------------------------------------------------------------
00127 HRESULT CDeviceNode::GetDisplayInfo
00128 (
00129   RESULTDATAITEM* pRDI
00130 )
00131 {
00132   _ASSERT( NULL != pRDI );
00133
00134   HRESULT hResult = S_OK;
00135
00136   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00137   {                                  // for each column
00138     switch( pRDI->nCol )
00139     {
00140       case 0:
00141         pRDI->str = m_pwszNodeName;
00142         break;
00143
00144       case 1:                        // Attributes not supported yet
00145         pRDI->str = m_wzStatus;
00146         break;
00147
00148       default:
00149         hResult = S_FALSE;
00150         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00151         break;
00152     }
00153   }
00154   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00155   {
00156     pRDI->nImage = m_SDI.nImage;
00157   }
00158
00159   TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00160   return hResult;
00161
00162 }
00163
00164 /////////////////////////////////////////////////////////////////////////////
00165 // Implementation of notification handlers
00166
00167
00168 //---------------------------------------------------------------------------
00169 HRESULT CDeviceNode::OnSelect
00170 (
00171   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00172   LONG          nArg,          //[in] Bools for context & selection state
00173   LONG          nParam,        //[in] Not used
00174   LONG_PTR      pComponent     //[in] Points calling CComponent
00175 )
00176 {
00177   HRESULT hResult = S_FALSE;
00178
00179   // Not setting verbs for this node
00180
00181   TRACE_HRESULT(_T("OnSelect"), hResult );
00182   return hResult;
00183 }
00184
00185
00186 //---------------------------------------------------------------------------
00187 HRESULT CDeviceNode::OnShow
00188 (
00189   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00190   LONG          nArg,          //[in] TRUE if node was selcted
00191   LONG          nParam,        //[in] HSCOPEITEM of selected/deselected item
00192   LONG_PTR      pComponent     //[in] Points to calling IComponent
00193 )
00194 {
00195   HRESULT  hResult = S_FALSE;
00196
00197   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00198
00199   LPHEADERCTRL2  ipHeaderCtrl2 = NULL;
00200   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL2, (LONG_PTR*)&ipHeaderCtrl2 );
00201   if( S_OK != hResult )
00202    return hResult;
00203
00204   LPRESULTDATA  ipResultData = NULL;
00205   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00206   if( S_OK != hResult )
00207    return hResult;
00208
00209   ipHeaderCtrl2->AddRef();
00210   ipResultData->AddRef();
00211
00212   if( TRUE == nArg )  // Selecting a scope node
00213   {
00214     do
00215     {
00216       hResult = ipHeaderCtrl2->InsertColumn( 0, L"Folder Name", 0, 150 );
00217       BREAK_ON_ERROR( hResult );
00218
00219       hResult = ipHeaderCtrl2->InsertColumn( 1, L"Attributes", 0, 150 );
00220       BREAK_ON_ERROR( hResult );
00221
00222       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00223       BREAK_ON_ERROR( hResult );
00224
00225     }while(0);
00226   }
00227   else // not handling deselect notifications
00228   {
00229   }
00230
00231   ipHeaderCtrl2->Release();
00232   ipResultData->Release();
00233
00234   TRACE_HRESULT(_T("OnShow"), hResult );
00235   return hResult;
00236 }
00237
00238 //---------------------------------------------------------------------------
00239 HRESULT CDeviceNode::OnExpand
00240 (
00241   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00242   LONG           nArg,         //[in] TRUE if node was selcted
00243   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00244   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00245 )
00246 {
00247   HRESULT hResult = S_FALSE;
00248
00249   if( NULL == m_pCompData )
00250     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00251
00252   // Request an IConsoleNameSpace2 pointer from CComponentData
00253   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00254   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00255   if( S_OK != hResult )
00256     return hResult;
00257
00258   ipCNS2->AddRef();
00259   m_hParentNode = (HSCOPEITEM)nParam;  // Cache HSCOPEITEM of Parent
00260
00261   hResult = DeleteChildItems( ipCNS2 );
00262   hResult = InsertChildItems( ipCNS2 );
00263
00264   ipCNS2->Release();
00265
00266   TRACE_HRESULT( _T("OnExpand"), hResult );
00267   return hResult;
00268 }
00269
00270
00271 //---------------------------------------------------------------------------
00272 HRESULT CDeviceNode::OnRemoveChildren
00273 (
00274   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00275   LONG           nArg,         //[in] TRUE if node was selcted
00276   LONG           nParam,       //[in] HSCOPEITEM of selected/deselected item
00277   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00278 )
00279 {
00280   HRESULT hResult = S_FALSE;
00281
00282   if( NULL == m_pCompData )
00283     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00284
00285   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00286   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG_PTR*)&ipCNS2 );
00287   if( S_OK != hResult )
00288     return hResult;
00289
00290   ipCNS2->AddRef();
00291                                        // Deletes HSCOPEITEMS only...
00292   hResult = DeleteChildItems( ipCNS2 );
00293
00294   POSITION   Pos   = m_NodeList.GetHeadPosition();
00295   LPBASENODE pNode = NULL;
00296   while( Pos )                         // Delete everything...
00297   {
00298     pNode = m_NodeList.GetNext( Pos );
00299     pNode->OnRemoveChildren( ipDataObject, nArg, nParam, pCompData );
00300     delete pNode;
00301   }
00302
00303   m_NodeList.RemoveAll();            // Cleans up the list
00304
00305   ipCNS2->Release();
00306
00307   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00308   return hResult;
00309
00310 }
00311
00312
00313 /////////////////////////////////////////////////////////////////////////////
00314 //  Private Helpers
00315
00316 //---------------------------------------------------------------------------
00317 HRESULT CDeviceNode::DeleteChildItems
00318 (
00319   LPCONSOLENAMESPACE2 ipCNS2
00320 )
00321 {
00322   _ASSERT( NULL != ipCNS2 );
00323
00324   POSITION    Pos     = m_NodeList.GetHeadPosition();
00325   HSCOPEITEM  hItem   = NULL;
00326   LPBASENODE  pNode   = NULL;
00327   HRESULT     hResult = S_FALSE;
00328
00329   while( Pos )                         // Delete everything...
00330   {
00331     pNode = m_NodeList.GetNext( Pos );
00332     hItem = (HSCOPEITEM)pNode->m_SDI.ID;
00333     if( 0 != hItem )
00334       hResult = ipCNS2->DeleteItem( hItem, TRUE );
00335   }
00336
00337   return hResult;
00338 }
00339
00340
00341 //---------------------------------------------------------------------------
00342 HRESULT CDeviceNode::InsertChildItems
00343 (
00344   LPCONSOLENAMESPACE2 ipCNS2
00345 )
00346 {
00347   _ASSERT( NULL != ipCNS2 );
00348   _ASSERT( NULL != m_hParentNode );
00349
00350   HRESULT    hResult = S_FALSE;
00351   POSITION   Pos     = m_NodeList.GetHeadPosition();
00352   LPBASENODE pNode   = NULL;
00353
00354   while( Pos )
00355   {
00356     pNode   = m_NodeList.GetNext( Pos );
00357     pNode->m_SDI.relativeID = m_hParentNode;
00358     hResult = ipCNS2->InsertItem( &pNode->m_SDI );
00359   }
00360
00361   return hResult;
00362 }
00363
00364
00365 //---------------------------------------------------------------------------
00366 //  Only add one child node in this sample
00367 //
00368 HRESULT CDeviceNode::RefreshNodeList()
00369 {
00370   NODE_PROPERTIES NodeProps;
00371   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00372   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00373
00374   WCHAR  szNames[1][32];
00375   wcscpy( szNames[0], L"Root Folder" );
00376
00377   RemoveNodes();             // Clean the node list
00378
00379   LPBASENODE pNode = NULL;
00380   for( DWORD i = 0; i < 1; i++ )
00381   {
00382     wcscpy( NodeProps.szNodeName, szNames[i] );
00383     pNode = new CFolderNode;
00384     pNode->Initialize( &NodeProps );
00385     m_NodeList.AddTail( pNode );
00386   }
00387
00388   return S_OK;
00389 }
00390
00391 //---------------------------------------------------------------------------
00392 //  We do this instead of just calling RemoveAll() because our list contains
00393 //  CBaseNode pointers and so RemoveAll() does not call the destructor for
00394 //  the derived class object.
00395 //
00396 VOID CDeviceNode::RemoveNodes()
00397 {
00398   LPBASENODE pNode = NULL;
00399   POSITION   Pos   = m_NodeList.GetHeadPosition();
00400   while( Pos )
00401   {
00402     pNode = m_NodeList.GetNext( Pos );
00403     delete pNode;
00404   }
00405   m_NodeList.RemoveAll();              // Clean the list
00406 }
00407
00408 /////////////////////////////////////////////////////////////////////////////
00409 //  Public helpers
00410
00411 //---------------------------------------------------------------------------
00412 VOID CDeviceNode::ToggleStatus()
00413 {
00414   // First we have to set the image indexes according to the Online Status
00415   // and the device type
00416   //
00417   if( STATUS_ONLINE == m_bOnlineStatus )
00418   {
00419     m_bOnlineStatus = STATUS_OFFLINE;
00420     m_wzStatus      = L"Offline";
00421     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00422     {
00423       m_SDI.nImage      = IMG_DEVICE_OFFLINE;
00424       m_SDI.nOpenImage  = IMG_DEVICE_OFFLINE;
00425     }
00426     else
00427     {
00428       m_SDI.nImage      = IMG_DRIVE_OFFLINE;
00429       m_SDI.nOpenImage  = IMG_DRIVE_OFFLINE;
00430     }
00431   }
00432   else
00433   {
00434     m_bOnlineStatus = STATUS_ONLINE;
00435     m_wzStatus      = L"Online";
00436     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00437     {
00438       m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00439       m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00440     }
00441     else
00442     {
00443       m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00444       m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00445     }
00446   }
00447   // This is a scope node, so GetDisplayInfo will only ask for images for
00448   // this node when it is in the Result Pane.  To change the image for the
00449   // the Scope Pane we need to call IConsoleNameSpace2::SetItem().  This
00450   // call forces the scope node to be redrawn.
00451   //
00452   SCOPEDATAITEM  sdi;
00453   ZeroMemory( &sdi, sizeof(SCOPEDATAITEM) );
00454   sdi.mask        = SDI_IMAGE | SDI_OPENIMAGE ;
00455   sdi.ID          = m_SDI.ID;
00456   sdi.nImage      = m_SDI.nImage;
00457   sdi.nOpenImage  = m_SDI.nOpenImage;
00458
00459   // Request an IConsoleNameSpace2 pointer from CComponentData
00460   HRESULT  hResult = S_FALSE;
00461   LPCONSOLENAMESPACE2 ipCNS2 = NULL;
00462   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE2, (LONG*)&ipCNS2 );
00463   if( S_OK == hResult )
00464     hResult = ipCNS2->SetItem( &sdi );
00465
00466 }
00467
00468
00469 /////////////////////////////////////////////////////////////////////////////
00470 //  Support for Context Menus
00471
00472 //---------------------------------------------------------------------------
00473 //  Devices can only add a folder
00474 //
00475 HRESULT CDeviceNode::AddMenuItems
00476 (
00477   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00478   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00479 )
00480 {
00481   _ASSERT( NULL != ipCallback );
00482   HRESULT hResult = S_FALSE;
00483
00484   static CONTEXTMENUITEM ctxMenu[2];
00485     ctxMenu[0].lCommandID        = IDM_NEW_FOLDER;
00486     ctxMenu[0].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00487     ctxMenu[0].fFlags            = 0;
00488     ctxMenu[0].fSpecialFlags     = 0;
00489     ctxMenu[0].strName           = L"New Folder...";
00490     ctxMenu[0].strStatusBarText  = L"Add a new folder";
00491
00492     ctxMenu[1].lCommandID        = IDM_TOGGLE_STATUS;
00493     ctxMenu[1].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
00494     ctxMenu[1].fFlags            = 0;
00495     ctxMenu[1].fSpecialFlags     = 0;
00496     ctxMenu[1].strName           = L"Toggle Online Status";
00497     ctxMenu[1].strStatusBarText  = L"Toggles the device status";
00498
00499
00500   // Add the Add new folder command
00501   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00502   {
00503     hResult = ipCallback->AddItem( &ctxMenu[0] );
00504   }
00505
00506   // Add the Toggle item to the Task menu if allowed...
00507   if( CCM_INSERTIONALLOWED_TASK & *pInsertionAllowed )
00508   {
00509     hResult = ipCallback->AddItem( &ctxMenu[1] );
00510   }
00511
00512   return hResult;
00513 }
00514
00515 //---------------------------------------------------------------------------
00516 HRESULT CDeviceNode::Command
00517 (
00518   long lCommandID          //[in] Indentifier for menu ID
00519 )
00520 {
00521   HRESULT hResult = S_OK;
00522
00523   switch( lCommandID )
00524   {
00525     case IDM_TOGGLE_STATUS:
00526     {
00527       ToggleStatus();
00528       break;
00529     }
00530     case IDM_NEW_FOLDER:
00531     {
00532       MsgBox( _T("New Folders not supported"), _T("Test") );
00533       break;
00534     }
00535     default:
00536       hResult = S_FALSE;
00537       break;
00538
00539   }
00540   return hResult;
00541 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_STDZ Member List

This is the complete list of members for _STDZ, including all inherited members.
fill | _STDZ
rgchars | _STDZ
vtByteCount | _STDZ
vtType | _STDZ
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMShare/clUtil.Cpp Source File

  • Web
  • NetMeeting
  • NMShare

clUtil.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMSHARE.EXE
00003 //  File:       CLUTIL.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #include "precomp.h"
00017
00018
00019 //****************************************************************************
00020 //
00021 // CLASS RefCount
00022 //
00023 //****************************************************************************
00024
00025
00026 //****************************************************************************
00027 //
00028 // Constructor
00029 //
00030 //****************************************************************************
00031
00032 RefCount::RefCount(void)
00033 {
00034   m_cRef = 1;
00035 }
00036
00037
00038 //****************************************************************************
00039 //
00040 // Destructor
00041 //
00042 //****************************************************************************
00043
00044 RefCount::~RefCount(void)
00045 {
00046 }
00047
00048
00049 //****************************************************************************
00050 //
00051 // Methods from IUnknown
00052 //
00053 //****************************************************************************
00054
00055 ULONG STDMETHODCALLTYPE RefCount::AddRef(void)
00056 {
00057    ASSERT(m_cRef >= 0);
00058
00059    InterlockedIncrement(&m_cRef);
00060
00061    return (ULONG) m_cRef;
00062 }
00063
00064
00065 ULONG STDMETHODCALLTYPE RefCount::Release(void)
00066 {
00067   if (0 == InterlockedDecrement(&m_cRef))
00068   {
00069     delete this;
00070     return 0;
00071   }
00072
00073   ASSERT(m_cRef > 0);
00074   return (ULONG) m_cRef;
00075 }
00076
00077
00078 //****************************************************************************
00079 //
00080 // CLASS CNotify
00081 //
00082 //****************************************************************************
00083
00084
00085 //****************************************************************************
00086 //
00087 // Constructor
00088 //
00089 //****************************************************************************
00090
00091 CNotify::CNotify() :
00092   m_pcnpcnt(NULL),
00093     m_pcnp(NULL),
00094     m_dwCookie(0),
00095     m_pUnk(NULL)
00096 {
00097 }
00098
00099
00100 //****************************************************************************
00101 //
00102 // Destructor
00103 //
00104 //****************************************************************************
00105
00106 CNotify::~CNotify()
00107 {
00108   Disconnect(); // Make sure we're disconnected
00109 }
00110
00111
00112 //****************************************************************************
00113 //
00114 // HRESULT CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN)
00115 //
00116 //****************************************************************************
00117
00118 HRESULT CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN)
00119 {
00120   if (NULL == pUnk || NULL == pUnkN)
00121   {
00122     return E_POINTER;
00123   }
00124
00125   HRESULT hr = S_OK;
00126
00127   ASSERT(0 == m_dwCookie);
00128
00129   // Get the connection container
00130   hr = pUnk->QueryInterface(IID_IConnectionPointContainer, (void **)&m_pcnpcnt);
00131   if (SUCCEEDED(hr))
00132   {
00133     // Find an appropriate connection point
00134     hr = m_pcnpcnt->FindConnectionPoint(riid, &m_pcnp);
00135     if (SUCCEEDED(hr))
00136     {
00137       ASSERT(NULL != m_pcnp);
00138       // Connect the sink object
00139       hr = m_pcnp->Advise((IUnknown *)pUnkN, &m_dwCookie);
00140     }
00141   }
00142
00143   if (FAILED(hr))
00144   {
00145     m_dwCookie = 0;
00146   }
00147   else
00148   {
00149       m_pUnk = pUnk; // keep around for caller
00150     }
00151
00152   return hr;
00153 }
00154
00155
00156 //****************************************************************************
00157 //
00158 // HRESULT CNotify::Disconnect (void)
00159 //
00160 //****************************************************************************
00161
00162 HRESULT CNotify::Disconnect (void)
00163 {
00164     if (0 != m_dwCookie)
00165     {
00166         // Disconnect the sink object
00167         m_pcnp->Unadvise(m_dwCookie);
00168         m_dwCookie = 0;
00169
00170         m_pcnp->Release();
00171         m_pcnp = NULL;
00172
00173         m_pcnpcnt->Release();
00174         m_pcnpcnt = NULL;
00175
00176         m_pUnk = NULL;
00177     }
00178
00179     return S_OK;
00180 }
00181
00182
00183 //****************************************************************************
00184 //
00185 // CLASS COBLIST
00186 //
00187 //****************************************************************************
00188
00189
00190 //****************************************************************************
00191 //
00192 // Destructor
00193 //
00194 //****************************************************************************
00195
00196 COBLIST::~COBLIST()
00197 {
00198     ASSERT(IsEmpty());
00199 }
00200
00201
00202 #ifdef DEBUG
00203 VOID* COBLIST::GetHead()
00204 {
00205   ASSERT(m_pHead);
00206
00207   return m_pHead->pItem;
00208 }
00209
00210 VOID* COBLIST::GetTail()
00211 {
00212   ASSERT(m_pTail);
00213
00214   return m_pTail->pItem;
00215 }
00216 #endif /* DEBUG */
00217
00218
00219 //****************************************************************************
00220 //
00221 // VOID* COBLIST::GetNext(POSITION& rPos)
00222 //
00223 //****************************************************************************
00224
00225 VOID* COBLIST::GetNext(POSITION& rPos)
00226 {
00227   ASSERT(rPos);
00228
00229   VOID* pReturn = rPos->pItem;
00230   rPos = rPos->pNext;
00231
00232   return pReturn;
00233 }
00234
00235
00236 //****************************************************************************
00237 //
00238 // VOID* COBLIST::RemoveAt(POSITION Pos)
00239 //
00240 //****************************************************************************
00241
00242 VOID* COBLIST::RemoveAt(POSITION Pos)
00243 {
00244   VOID* pReturn = NULL;
00245
00246   if (m_pHead)
00247   {
00248     if (m_pHead == Pos)
00249     {
00250       // Removing the first element in the list
00251
00252       m_pHead = Pos->pNext;
00253       pReturn = Pos->pItem;
00254       delete Pos;
00255       m_cItem--;
00256       ASSERT(0 <= m_cItem);
00257
00258       if (NULL == m_pHead)
00259       {
00260         // Removing the only element!
00261         m_pTail = NULL;
00262       }
00263     }
00264     else
00265     {
00266       POSITION pCur = m_pHead;
00267
00268       while (pCur && pCur->pNext)
00269       {
00270         if (pCur->pNext == Pos)
00271         {
00272           // Removing
00273
00274           pCur->pNext = Pos->pNext;
00275           if (m_pTail == Pos)
00276           {
00277             m_pTail = pCur;
00278           }
00279           pReturn = Pos->pItem;
00280           delete Pos;
00281
00282           m_cItem--;
00283           ASSERT(0 <= m_cItem);
00284         }
00285
00286         pCur = pCur->pNext;
00287       }
00288     }
00289   }
00290
00291   return pReturn;
00292 }
00293
00294
00295 //****************************************************************************
00296 //
00297 // POSITION COBLIST::AddTail(VOID* pItem)
00298 //
00299 //****************************************************************************
00300
00301 POSITION COBLIST::AddTail(VOID* pItem)
00302 {
00303   POSITION posRet = NULL;
00304
00305   if (m_pTail)
00306   {
00307     if (m_pTail->pNext = new COBNODE)
00308     {
00309       m_pTail = m_pTail->pNext;
00310       m_pTail->pItem = pItem;
00311       m_pTail->pNext = NULL;
00312       m_cItem++;
00313     }
00314   }
00315   else
00316   {
00317     ASSERT(!m_pHead);
00318     if (m_pHead = new COBNODE)
00319     {
00320       m_pTail = m_pHead;
00321       m_pTail->pItem = pItem;
00322       m_pTail->pNext = NULL;
00323       m_cItem++;
00324     }
00325   }
00326
00327   return m_pTail;
00328 }
00329
00330
00331 //****************************************************************************
00332 //
00333 // void COBLIST::EmptyList()
00334 //
00335 //****************************************************************************
00336
00337 void COBLIST::EmptyList()
00338 {
00339     while (!IsEmpty()) {
00340         RemoveAt(GetHeadPosition());
00341     }
00342 }
00343
00344
00345 #ifdef DEBUG
00346 VOID* COBLIST::RemoveTail()
00347 {
00348   ASSERT(m_pHead);
00349   ASSERT(m_pTail);
00350
00351   return RemoveAt(m_pTail);
00352 }
00353
00354 VOID* COBLIST::RemoveHead()
00355 {
00356   ASSERT(m_pHead);
00357   ASSERT(m_pTail);
00358
00359   return RemoveAt(m_pHead);
00360 }
00361
00362 void * COBLIST::GetFromPosition(POSITION Pos)
00363 {
00364     void * Result = SafeGetFromPosition(Pos);
00365   ASSERT(Result);
00366   return Result;
00367 }
00368 #endif /* DEBUG */
00369
00370
00371 //****************************************************************************
00372 //
00373 // POSITION COBLIST::GetPosition(void* _pItem)
00374 //
00375 //****************************************************************************
00376
00377 POSITION COBLIST::GetPosition(void* _pItem)
00378 {
00379     POSITION    Position = m_pHead;
00380
00381     while (Position) {
00382         if (Position->pItem == _pItem) {
00383             break;
00384         }
00385     GetNext(Position);
00386     }
00387     return Position;
00388 }
00389
00390
00391 //****************************************************************************
00392 //
00393 // POSITION COBLIST::Lookup(void* pComparator)
00394 //
00395 //****************************************************************************
00396
00397 POSITION COBLIST::Lookup(void* pComparator)
00398 {
00399     POSITION    Position = m_pHead;
00400
00401     while (Position) {
00402         if (Compare(Position->pItem, pComparator)) {
00403             break;
00404         }
00405     GetNext(Position);
00406     }
00407     return Position;
00408 }
00409
00410
00411 //****************************************************************************
00412 //
00413 // void * COBLIST::SafeGetFromPosition(POSITION Pos)
00414 //
00415 //****************************************************************************
00416
00417 void * COBLIST::SafeGetFromPosition(POSITION Pos)
00418 {
00419   // Safe way to validate that an entry is still in the list,
00420   // which ensures bugs that would reference deleted memory,
00421   // reference a NULL pointer instead
00422   // (e.g. an event handler fires late/twice).
00423   // Note that versioning on entries would provide an additional
00424   // safeguard against re-use of a position.
00425   // Walk list to find entry.
00426
00427   POSITION PosWork = m_pHead;
00428
00429   while (PosWork) {
00430     if (PosWork == Pos) {
00431       return Pos->pItem;
00432     }
00433     GetNext(PosWork);
00434   }
00435   return NULL;
00436 }
00437
00438 //****************************************************************************
00439 //
00440 // COBLIST Utility routines
00441 //
00442 //****************************************************************************
00443
00444
00445 //****************************************************************************
00446 //
00447 // POSITION AddNode(PVOID pv, COBLIST ** ppList)
00448 //
00449 // Add a node to a list.
00450 // Initializes the ObList, if necessary.
00451 // Returns the position in the list or NULL if there was a problem.
00452 //
00453 //****************************************************************************
00454
00455 POSITION AddNode(PVOID pv, COBLIST ** ppList)
00456 {
00457   ASSERT(NULL != ppList);
00458   if (NULL == *ppList)
00459   {
00460     *ppList = new COBLIST();
00461     if (NULL == *ppList)
00462       return NULL;
00463   }
00464
00465   return (*ppList)->AddTail(pv);
00466 }
00467
00468
00469 //****************************************************************************
00470 //
00471 // PVOID RemoveNode(POSITION * pPos, COBLIST *pList)
00472 //
00473 // Remove a node from a list.
00474 // Sets pPos to NULL
00475 //
00476 //****************************************************************************
00477
00478 PVOID RemoveNode(POSITION * pPos, COBLIST *pList)
00479 {
00480   if ((NULL == pList) || (NULL == pPos))
00481     return NULL;
00482
00483   PVOID pv = pList->RemoveAt(*pPos);
00484   *pPos = NULL;
00485   return pv;
00486 }
00487
00488
00489 //****************************************************************************
00490 //
00491 // CLASS BSTRING
00492 //
00493 //****************************************************************************
00494
00495
00496 //****************************************************************************
00497 //
00498 // Constructor
00499 //
00500 // We don't support construction from an ANSI string in the Unicode build.
00501 //
00502 //****************************************************************************
00503
00504 #if !defined(UNICODE)
00505
00506 BSTRING::BSTRING(LPCSTR lpcString)
00507 {
00508   if (NULL != lpcString)
00509   {
00510     m_bstr = NULL;
00511
00512     // Compute the length of the required BSTR, including the null
00513     int cWC =  MultiByteToWideChar(CP_ACP, 0, lpcString, -1, NULL, 0);
00514     if (cWC <= 0)
00515       return;
00516
00517     // Allocate the BSTR, including the null
00518     m_bstr = SysAllocStringLen(NULL, cWC - 1); // SysAllocStringLen adds another 1
00519
00520     ASSERT(NULL != m_bstr);
00521     if (NULL == m_bstr)
00522     {
00523       return;
00524     }
00525
00526     // Copy the string
00527     MultiByteToWideChar(CP_ACP, 0, lpcString, -1, (LPWSTR) m_bstr, cWC);
00528
00529     // Verify that the string is null terminated
00530     ASSERT(0 == m_bstr[cWC - 1]);
00531   }
00532   else
00533   {
00534     return;
00535   }
00536 }
00537
00538 #endif // !defined(UNICODE)
00539
00540
00541 //****************************************************************************
00542 //
00543 // CLASS BTSTR
00544 //
00545 //****************************************************************************
00546
00547 //****************************************************************************
00548 //
00549 // Constructor
00550 //
00551 //****************************************************************************
00552
00553 BTSTR::BTSTR(BSTR bstr)
00554 {
00555   m_psz = PszFromBstr(bstr);
00556 }
00557
00558
00559 //****************************************************************************
00560 //
00561 // Destructor
00562 //
00563 //****************************************************************************
00564
00565 BTSTR::~BTSTR()
00566 {
00567   if (NULL != m_psz)
00568     LocalFree(m_psz);
00569 }
00570
00571
00572 //****************************************************************************
00573 //
00574 // LPTSTR PszFromBstr(BSTR bstr)
00575 //
00576 // Converts a BSTR to a LPSTR
00577 //
00578 //****************************************************************************
00579
00580 LPTSTR PszFromBstr(BSTR bstr)
00581 {
00582   if (NULL == bstr)
00583     return NULL;
00584   int cch =  WideCharToMultiByte(CP_ACP, 0, (LPWSTR)bstr, -1, NULL, 0, NULL, NULL);
00585   if (cch <= 0)
00586     return NULL;
00587
00588   LPTSTR psz = PszAlloc(cch);
00589   if (NULL == psz)
00590     return NULL;
00591
00592   WideCharToMultiByte(CP_ACP, 0, (LPWSTR)bstr, -1, psz, cch+1, NULL, NULL);
00593   return psz;
00594 }
00595
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

LIST_STRUCT Member List

This is the complete list of members for LIST_STRUCT, including all inherited members.
ListError | LIST_STRUCT
OrderFunction | LIST_STRUCT
pCurrentNode | LIST_STRUCT
pFirstNode | LIST_STRUCT
pLastNode | LIST_STRUCT
pListData | LIST_STRUCT
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminAuthenticationCapabilitiesOptions Member List

This is the complete list of members for comadmin::COMAdminAuthenticationCapabilitiesOptions, including all inherited members.
COMAdminAuthenticationCapabilitiesDynamicCloaking | comadmin::COMAdminAuthenticationCapabilitiesOptions | [static]
COMAdminAuthenticationCapabilitiesNone | comadmin::COMAdminAuthenticationCapabilitiesOptions | [static]
COMAdminAuthenticationCapabilitiesSecureReference | comadmin::COMAdminAuthenticationCapabilitiesOptions | [static]
COMAdminAuthenticationCapabilitiesStaticCloaking | comadmin::COMAdminAuthenticationCapabilitiesOptions | [static]
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/comp.Cpp Source File

  • SysMgmt
  • MMC
  • Nameext

comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "DataObj.h"
00021 #include <crtdbg.h>
00022 #include "globals.h"
00023 #include "resource.h"
00024 #include "DeleBase.h"
00025 #include "NameExt.h"
00026
00027 CComponent::CComponent(CComponentData *parent)
00028 : m_pComponentData(parent), m_cref(0), m_ipConsole(NULL), m_ipDisplayHelp(NULL)
00029 {
00030     OBJECT_CREATED
00031 }
00032
00033 CComponent::~CComponent()
00034 {
00035     OBJECT_DESTROYED
00036 }
00037
00038 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00039 {
00040     if (!ppv)
00041         return E_FAIL;
00042
00043     *ppv = NULL;
00044
00045     if (IsEqualIID(riid, IID_IUnknown))
00046         *ppv = static_cast<IComponent *>(this);
00047     else if (IsEqualIID(riid, IID_IComponent))
00048         *ppv = static_cast<IComponent *>(this);
00049     else if (IsEqualIID(riid, IID_IExtendContextMenu))
00050         *ppv = static_cast<IExtendContextMenu *>(this);
00051
00052     if (*ppv)
00053     {
00054         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00055         return S_OK;
00056     }
00057
00058     return E_NOINTERFACE;
00059 }
00060
00061 STDMETHODIMP_(ULONG) CComponent::AddRef()
00062 {
00063     return InterlockedIncrement((LONG *)&m_cref);
00064 }
00065
00066 STDMETHODIMP_(ULONG) CComponent::Release()
00067 {
00068     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00069     {
00070         delete this;
00071         return 0;
00072     }
00073     return m_cref;
00074
00075 }
00076
00077 ///////////////////////////////
00078 // Interface IComponent
00079 ///////////////////////////////
00080 STDMETHODIMP CComponent::Initialize(
00081                                     /* [in] */ LPCONSOLE lpConsole)
00082 {
00083     HRESULT hr = S_OK;
00084
00085     // Save away all the interfaces we'll need.
00086     // Fail if we can't QI the required interfaces.
00087
00088     m_ipConsole = lpConsole;
00089     m_ipConsole->AddRef();
00090
00091     hr = m_ipConsole->QueryInterface(IID_IDisplayHelp, (void **)&m_ipDisplayHelp);
00092
00093     return hr;
00094 }
00095
00096 STDMETHODIMP CComponent::Notify(
00097                                 /* [in] */ LPDATAOBJECT lpDataObject,
00098                                 /* [in] */ MMC_NOTIFY_TYPE event,
00099                                 /* [in] */ LPARAM arg,
00100                                 /* [in] */ LPARAM param)
00101 {
00102     MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00103
00104     HRESULT hr = S_FALSE;
00105
00106   //Get our data object. If it is NULL, we return with S_FALSE.
00107   //See implementation of GetOurDataObject() to see how to
00108   //handle special data objects.
00109   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00110   if (NULL == pDataObject)
00111     return S_FALSE;
00112
00113   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00114
00115     switch (event)      {
00116     case MMCN_ADD_IMAGES:
00117         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00118         break;
00119
00120     case MMCN_SHOW:
00121         hr = base->OnShow(m_ipConsole, (BOOL)arg, (HSCOPEITEM)param);
00122         break;
00123
00124     }
00125
00126     return hr;
00127 }
00128
00129 STDMETHODIMP CComponent::Destroy(
00130                                  /* [in] */ MMC_COOKIE cookie)
00131 {
00132     if (m_ipConsole) {
00133         m_ipConsole->Release();
00134         m_ipConsole = NULL;
00135     }
00136
00137     if (m_ipDisplayHelp) {
00138         m_ipDisplayHelp->Release();
00139         m_ipDisplayHelp = NULL;
00140     }
00141
00142     return S_OK;
00143 }
00144
00145
00146 STDMETHODIMP CComponent::QueryDataObject(
00147                                          /* [in] */ MMC_COOKIE cookie,
00148                                          /* [in] */ DATA_OBJECT_TYPES type,
00149                                          /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00150 {
00151     CDataObject *pObj = NULL;
00152
00153   //cookie == 0 not possible in a namespace extension
00154 //    if (cookie == 0)
00155 //        pObj = new CDataObject((MMC_COOKIE)m_pComponentData->m_pStaticNode, type);
00156 //    else
00157         pObj = new CDataObject(cookie, type);
00158
00159     if (!pObj)
00160         return E_OUTOFMEMORY;
00161
00162     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00163
00164     return S_OK;
00165 }
00166
00167 STDMETHODIMP CComponent::GetResultViewType(
00168                                            /* [in] */ MMC_COOKIE cookie,
00169                                            /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00170                                            /* [out] */ long __RPC_FAR *pViewOptions)
00171 {
00172     CDelegationBase *base = (CDelegationBase *)cookie;
00173
00174     //
00175     // Ask for default listview.
00176     //
00177     if (base == NULL)
00178     {
00179         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00180         *ppViewType = NULL;
00181     }
00182     else
00183         return base->GetResultViewType(ppViewType, pViewOptions);
00184
00185     return S_OK;
00186 }
00187
00188 STDMETHODIMP CComponent::GetDisplayInfo(
00189                                         /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00190 {
00191     HRESULT hr = S_OK;
00192     CDelegationBase *base = NULL;
00193
00194     // if they are asking for the RDI_STR we have one of those to give
00195
00196     if (pResultDataItem->lParam) {
00197         base = (CDelegationBase *)pResultDataItem->lParam;
00198         if (pResultDataItem->mask & RDI_STR) {
00199             LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00200             MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00201             pResultDataItem->str = pszW;
00202         }
00203
00204         if (pResultDataItem->mask & RDI_IMAGE) {
00205             pResultDataItem->nImage = base->GetBitmapIndex();
00206         }
00207     }
00208
00209     return hr;
00210 }
00211
00212
00213 STDMETHODIMP CComponent::CompareObjects(
00214                                         /* [in] */ LPDATAOBJECT lpDataObjectA,
00215                                         /* [in] */ LPDATAOBJECT lpDataObjectB)
00216 {
00217     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00218     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00219
00220     // compare the object pointers
00221     if (baseA->GetCookie() == baseB->GetCookie())
00222         return S_OK;
00223
00224     return S_FALSE;
00225 }
00226
00227 ///////////////////////////////
00228 // Interface IExtendContextMenu
00229 ///////////////////////////////
00230 HRESULT CComponent::AddMenuItems(
00231                                  /* [in] */ LPDATAOBJECT piDataObject,
00232                                  /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
00233                                  /* [out][in] */ long __RPC_FAR *pInsertionAllowed)
00234 {
00235     CDelegationBase *base = GetOurDataObject(piDataObject)->GetBaseNodeObject();
00236
00237     return base->OnAddMenuItems(piCallback, pInsertionAllowed);
00238 }
00239
00240 HRESULT CComponent::Command(
00241                             /* [in] */ long lCommandID,
00242                             /* [in] */ LPDATAOBJECT piDataObject)
00243 {
00244     CDelegationBase *base = GetOurDataObject(piDataObject)->GetBaseNodeObject();
00245
00246     return base->OnMenuCommand(m_ipConsole, lCommandID);
00247 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_BLRPLATE Member List

This is the complete list of members for _BLRPLATE, including all inherited members.
Flags | _BLRPLATE
Opcode | _BLRPLATE
Signature | _BLRPLATE
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/FreeObject/FreeObject.Idl Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • FreeObject

FreeObject.Idl

Go to the documentation of this file.
00001 // FreeObject.idl : IDL source for FreeObject.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (FreeObject.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009   [
00010     object,
00011     uuid(BAEA7BB0-F391-11D2-A10A-0080C71F306F),
00012     dual,
00013     helpstring("ISyncTest Interface"),
00014     pointer_default(unique)
00015   ]
00016   interface ISyncTest : IDispatch
00017   {
00018     HRESULT Exercise(void);
00019   };
00020
00021 [
00022   uuid(795BF0E0-F430-11D2-A10A-0080C71F306F),
00023   version(1.0),
00024   helpstring("FreeObject 1.0 Type Library")
00025 ]
00026 library FREEOBJECTLib
00027 {
00028   importlib("stdole32.tlb");
00029   importlib("stdole2.tlb");
00030
00031   [
00032     uuid(8EAE3AA1-F430-11D2-A10A-0080C71F306F),
00033     helpstring("FreeTest Class")
00034   ]
00035   coclass FreeTest
00036   {
00037     [default] interface ISyncTest;
00038   };
00039 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditCommands/EdCommands.cpp Source File

  • Web
  • Browser
  • EditCommands

EdCommands.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // EdCommands.cpp : Implementation of WinMain
00006
00007
00008 // Note: Proxy/Stub Information
00009 //    To build a separate proxy/stub DLL,
00010 //    run nmake -f EdCommandsps.mk in the project directory.
00011
00012 #include "stdafx.h"
00013 #include "resource.h"
00014 #include <initguid.h>
00015 #include "EdCommands.h"
00016
00017 #include "EdCommands_i.c"
00018 #include "BrowserHost.h"
00019
00020
00021 const DWORD dwTimeOut = 5000; // time for EXE to be idle before shutting down
00022 const DWORD dwPause = 1000; // time to wait for threads to finish up
00023
00024 // Passed to CreateThread to monitor the shutdown event
00025 static DWORD WINAPI MonitorProc(void* pv)
00026 {
00027   CExeModule* p = (CExeModule*)pv;
00028   p->MonitorShutdown();
00029   return 0;
00030 }
00031
00032 LONG CExeModule::Unlock()
00033 {
00034   LONG l = CComModule::Unlock();
00035   if (l == 0)
00036   {
00037     bActivity = true;
00038     SetEvent(hEventShutdown); // tell monitor that we transitioned to zero
00039   }
00040   return l;
00041 }
00042
00043 //Monitors the shutdown event
00044 void CExeModule::MonitorShutdown()
00045 {
00046   while (1)
00047   {
00048     WaitForSingleObject(hEventShutdown, INFINITE);
00049     DWORD dwWait=0;
00050     do
00051     {
00052       bActivity = false;
00053       dwWait = WaitForSingleObject(hEventShutdown, dwTimeOut);
00054     } while (dwWait == WAIT_OBJECT_0);
00055     // timed out
00056     if (!bActivity && m_nLockCnt == 0) // if no activity let's really bail
00057     {
00058 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00059       CoSuspendClassObjects();
00060       if (!bActivity && m_nLockCnt == 0)
00061 #endif
00062         break;
00063     }
00064   }
00065   CloseHandle(hEventShutdown);
00066   PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00067 }
00068
00069 bool CExeModule::StartMonitor()
00070 {
00071   // CODE REVIEW: Add following security comment.
00072   /* The following use of CreateEvent is simplified for illustrative
00073   purposes. This simplified use in production code can expose a
00074   security risk in some situations. The first parameter might require
00075   specific security attributes. */
00076   hEventShutdown = CreateEvent(NULL, false, false, NULL);
00077   if (hEventShutdown == NULL)
00078     return false;
00079   DWORD dwThreadID;
00080   HANDLE h = CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
00081   return (h != NULL);
00082 }
00083
00084 CExeModule _Module;
00085
00086 BEGIN_OBJECT_MAP(ObjectMap)
00087 OBJECT_ENTRY(CLSID_BrowserHost, CBrowserHost)
00088 END_OBJECT_MAP()
00089
00090
00091 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
00092 {
00093   while (p1 != NULL && *p1 != NULL)
00094   {
00095     LPCTSTR p = p2;
00096     while (p != NULL && *p != NULL)
00097     {
00098       if (*p1 == *p)
00099         return CharNext(p1);
00100       p = CharNext(p);
00101     }
00102     p1 = CharNext(p1);
00103   }
00104   return NULL;
00105 }
00106
00107 /////////////////////////////////////////////////////////////////////////////
00108 //
00109 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00110   HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
00111 {
00112   lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
00113
00114 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00115   HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00116 #else
00117   HRESULT hRes = CoInitialize(NULL);
00118 #endif
00119   _ASSERTE(SUCCEEDED(hRes));
00120   _Module.Init(ObjectMap, hInstance, &LIBID_EDCOMMANDSLib);
00121   _Module.dwThreadID = GetCurrentThreadId();
00122   TCHAR szTokens[] = _T("-/");
00123
00124   int nRet = 0;
00125   BOOL bRun = TRUE;
00126   LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
00127   while (lpszToken != NULL)
00128   {
00129     if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
00130     {
00131       _Module.UpdateRegistryFromResource(IDR_EdCommands, FALSE);
00132       nRet = _Module.UnregisterServer(TRUE);
00133       bRun = FALSE;
00134       break;
00135     }
00136     if (lstrcmpi(lpszToken, _T("RegServer"))==0)
00137     {
00138       _Module.UpdateRegistryFromResource(IDR_EdCommands, TRUE);
00139       nRet = _Module.RegisterServer(TRUE);
00140       bRun = FALSE;
00141       break;
00142     }
00143     lpszToken = FindOneOf(lpszToken, szTokens);
00144   }
00145
00146   if (bRun)
00147   {
00148     _Module.StartMonitor();
00149 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00150     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00151       REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
00152     _ASSERTE(SUCCEEDED(hRes));
00153     hRes = CoResumeClassObjects();
00154 #else
00155     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00156       REGCLS_MULTIPLEUSE);
00157 #endif
00158     _ASSERTE(SUCCEEDED(hRes));
00159
00160     // Create the Browser Window
00161     CComPtr<IBrowserHost> pApp;
00162     CoCreateInstance(CLSID_BrowserHost,
00163              NULL,
00164              CLSCTX_INPROC_SERVER,
00165              IID_IBrowserHost,
00166              (void**)&pApp);
00167     if (pApp)
00168     {
00169       pApp->Run();
00170
00171
00172
00173       //long hwnd;
00174       HWND hwndApp;
00175
00176       IOleWindow* pOWin;
00177       pApp->QueryInterface(IID_IOleWindow, (void**)&pOWin);
00178       pOWin->GetWindow(&hwndApp);
00179       pOWin->Release();
00180       //pApp->GetHwnd(&hwnd);
00181       //hwndApp = (HWND)hwnd;
00182
00183       MSG msg;
00184       while (GetMessage(&msg, 0, 0, 0))
00185       {
00186         TranslateMessage(&msg);
00187
00188         // Pass message to app on keydown so that it can pass the
00189         // message on to the WebBrowser control as necessary
00190         if (msg.message == WM_KEYDOWN)
00191           SendMessage(hwndApp, msg.message, msg.wParam, msg.lParam);
00192
00193         DispatchMessage(&msg);
00194       }
00195
00196       _Module.RevokeClassObjects();
00197       Sleep(dwPause); //wait for any threads to finish
00198     }
00199   }
00200
00201   _Module.Term();
00202   CoUninitialize();
00203   return nRet;
00204 }
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CONST_WORD_REP Member List

This is the complete list of members for CONST_WORD_REP, including all inherited members.
szRep | CONST_WORD_REP
wTag | CONST_WORD_REP
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/ClassProv/ClassProv.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • ClassProv

ClassProv.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  CLASSPRO.CPP
00006
00007 //
00008
00009 //  Module: WINMGMT class provider sample code
00010
00011 //
00012
00013 //  Purpose: Defines the CClassPro class.  An object of this class is
00014
00015 //           created by the class factory for each connection.
00016
00017 //
00018
00019 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00020 //
00021 //***************************************************************************
00022
00023 #include <objbase.h>
00024 #include "sample.h"
00025 #include <process.h>
00026 #include <strsafe.h>
00027
00028
00029 InstDef MyDefs[] = {{L"a", 1}, {L"b", 2}, {L"c", 3}};
00030
00031 long glNumInst = sizeof(MyDefs)/sizeof(InstDef);
00032
00033 #define SAMPLE_CLASS_NAME L"ClassProvSamp"
00034
00035 //***************************************************************************
00036 //
00037 // CClassPro::CClassPro
00038 // CClassPro::~CClassPro
00039 //
00040 //***************************************************************************
00041
00042 CClassPro::CClassPro(BSTR ObjectPath, BSTR User, BSTR Password, IWbemContext * pCtx)
00043 {
00044     m_pNamespace = NULL;
00045     m_cRef=0;
00046     InterlockedIncrement(&g_cObj);
00047     return;
00048 }
00049
00050 CClassPro::~CClassPro(void)
00051 {
00052     if(m_pNamespace)
00053         m_pNamespace->Release();
00054     InterlockedDecrement(&g_cObj);
00055     return;
00056 }
00057
00058 //***************************************************************************
00059 //
00060 // CClassPro::QueryInterface
00061 // CClassPro::AddRef
00062 // CClassPro::Release
00063 //
00064 // Purpose: IUnknown members for CClassPro object.
00065 //***************************************************************************
00066
00067
00068 STDMETHODIMP CClassPro::QueryInterface(REFIID riid, PPVOID ppv)
00069 {
00070     *ppv=NULL;
00071
00072     // Since we have dual inheritance, it is necessary to cast the return type
00073
00074     if(riid== IID_IWbemServices)
00075        *ppv=(IWbemServices*)this;
00076
00077     if(IID_IUnknown==riid || riid== IID_IWbemProviderInit)
00078        *ppv=(IWbemProviderInit*)this;
00079
00080
00081     if (NULL!=*ppv) {
00082         AddRef();
00083         return NOERROR;
00084         }
00085     else
00086         return E_NOINTERFACE;
00087
00088 }
00089
00090
00091 STDMETHODIMP_(ULONG) CClassPro::AddRef(void)
00092 {
00093     return ++m_cRef;
00094 }
00095
00096 STDMETHODIMP_(ULONG) CClassPro::Release(void)
00097 {
00098     ULONG nNewCount = InterlockedDecrement((long *)&m_cRef);
00099     if (0L == nNewCount)
00100         delete this;
00101
00102     return nNewCount;
00103 }
00104
00105 /***********************************************************************
00106 *                                                                      *
00107 *   CClassPro::Initialize                                                *
00108 *                                                                      *
00109 *   Purpose: This is the implementation of IWbemProviderInit. The method  *
00110 *   is need to initialize with CIMOM.                                    *
00111 *                                                                      *
00112 ***********************************************************************/
00113
00114 STDMETHODIMP CClassPro::Initialize(LPWSTR pszUser, LONG lFlags,
00115                                     LPWSTR pszNamespace, LPWSTR pszLocale,
00116                                     IWbemServices *pNamespace,
00117                                     IWbemContext *pCtx,
00118                                     IWbemProviderInitSink *pInitSink)
00119 {
00120    if(! pNamespace)
00121   {
00122       pInitSink->SetStatus(WBEM_E_FAILED , 0);
00123   }
00124   else
00125   {
00126     m_pNamespace = pNamespace;
00127       m_pNamespace->AddRef();
00128     pInitSink->SetStatus(WBEM_S_INITIALIZED, 0);
00129   }
00130
00131
00132     return WBEM_S_NO_ERROR;
00133 }
00134
00135 //***************************************************************************
00136 //
00137 // CClassPro::CreateClassEnumAsync
00138 //
00139 // Purpose: Asynchronously enumerates the classes this provider supports.
00140 // Note that this sample only supports one.
00141 //
00142 //***************************************************************************
00143
00144 SCODE CClassPro::CreateClassEnumAsync(const BSTR Superclass, long lFlags,
00145                     IWbemContext  *pCtx, IWbemObjectSink *pHandler)
00146 {
00147     if(pHandler == NULL || m_pNamespace == NULL)
00148         return WBEM_E_INVALID_PARAMETER;
00149
00150   SCODE sc = S_OK;
00151
00152   if(SysStringLen(Superclass) == 0)
00153   {
00154     IWbemClassObject * pNewClass = NULL;
00155     sc = CreateClass(m_pNamespace, &pNewClass, SAMPLE_CLASS_NAME, pCtx);
00156
00157     if(sc == S_OK)
00158     {
00159       // Send the object to the caller
00160
00161       pHandler->Indicate(1,&pNewClass);
00162       pNewClass->Release();
00163     }
00164   }
00165     // Set status
00166
00167     pHandler->SetStatus(0,sc,NULL, NULL);
00168   return S_OK;
00169 }
00170
00171 //***************************************************************************
00172 //
00173 // CClassPro::CreateInstanceEnumAsync
00174 //
00175 // Purpose: Asynchronously enumerates the instances.
00176 //
00177 //***************************************************************************
00178
00179 SCODE CClassPro::CreateInstanceEnumAsync( const BSTR RefStr, long lFlags, IWbemContext *pCtx,
00180        IWbemObjectSink FAR* pHandler)
00181 {
00182     SCODE sc;
00183     int iCnt;
00184     IWbemClassObject FAR* pNewInst;
00185
00186     // Do a check of arguments and make sure we have pointer to Namespace
00187
00188     if(pHandler == NULL || m_pNamespace == NULL)
00189         return WBEM_E_INVALID_PARAMETER;
00190
00191     for(iCnt=0; iCnt < glNumInst; iCnt++)
00192     {
00193         sc = CreateInst(m_pNamespace,MyDefs[iCnt].pwcKey,
00194                     MyDefs[iCnt].lValue, &pNewInst, RefStr, pCtx);
00195
00196         if(sc != S_OK)
00197             break;
00198
00199         // Send the object to the caller
00200
00201         pHandler->Indicate(1,&pNewInst);
00202         pNewInst->Release();
00203     }
00204
00205     // Set status
00206
00207     pHandler->SetStatus(0,sc,NULL, NULL);
00208
00209     return sc;
00210 }
00211
00212
00213 //***************************************************************************
00214 //
00215 // CClassPro::GetObjectByPathAsync
00216 //
00217 // Purpose: Returns either an instance or a class.
00218 //
00219 //***************************************************************************
00220
00221
00222
00223 SCODE CClassPro::GetObjectAsync(const BSTR ObjectPath, long lFlags,IWbemContext  *pCtx,
00224                     IWbemObjectSink FAR* pHandler)
00225 {
00226
00227     SCODE sc;
00228     IWbemClassObject FAR* pObj;
00229     BOOL bOK = FALSE;
00230
00231     // Do a check of arguments and make sure we have pointer to Namespace
00232
00233     if(ObjectPath == NULL || pHandler == NULL || m_pNamespace == NULL)
00234         return WBEM_E_INVALID_PARAMETER;
00235
00236   // If we are being asked for our class, get that
00237   size_t i1 = SysStringLen(ObjectPath);
00238   size_t i2 = wcslen(SAMPLE_CLASS_NAME);
00239   if(i1 >= i2 && !_wcsicmp(&ObjectPath[i1-i2], SAMPLE_CLASS_NAME) )
00240   {
00241     IWbemClassObject * pNewClass = NULL;
00242     sc = CreateClass(m_pNamespace, &pNewClass, SAMPLE_CLASS_NAME, pCtx);
00243
00244     if(sc == S_OK)
00245     {
00246       // Send the object to the caller
00247
00248       pHandler->Indicate(1,&pNewClass);
00249       pNewClass->Release();
00250     }
00251   }
00252   else if(S_OK ==GetByPath(ObjectPath,&pObj, pCtx))
00253     {
00254         pHandler->Indicate(1,&pObj);
00255         pObj->Release();
00256         bOK = TRUE;
00257     sc = S_OK;
00258     }
00259   else
00260     sc = WBEM_E_NOT_FOUND;
00261
00262     // Set Status
00263
00264     pHandler->SetStatus(0,sc, NULL, NULL);
00265
00266     return sc;
00267 }
00268
00269 //***************************************************************************
00270 //
00271 // CClassPro::GetByPath
00272 //
00273 // Purpose: Creates an instance given a particular Path value.
00274 //
00275 //***************************************************************************
00276
00277 SCODE CClassPro::GetByPath(BSTR ObjectPath, IWbemClassObject FAR* FAR* ppObj, IWbemContext  *pCtx)
00278 {
00279     SCODE sc = S_OK;
00280
00281     int iCnt;
00282
00283     // do a simple path parse.  The path will look something like
00284     // ClassProvSamp.MyKey="a"
00285     // Create a test string with just the part between quotes.
00286
00287     WCHAR wcTest[MAX_PATH+1];
00288   StringCbCopyW(wcTest, sizeof(wcTest), ObjectPath);
00289     WCHAR * pwcTest, * pwcCompare = NULL;
00290
00291     int iNumQuotes = 0;
00292     for(pwcTest = wcTest; *pwcTest; pwcTest++)
00293         if(*pwcTest == L'\"')
00294         {
00295             iNumQuotes++;
00296             if(iNumQuotes == 1)
00297             {
00298                 pwcCompare = pwcTest+1;
00299             }
00300             else if(iNumQuotes == 2)
00301             {
00302                 *pwcTest = NULL;
00303                 break;
00304             }
00305         }
00306         else if(*pwcTest == L'.')
00307             *pwcTest = NULL;    // issolate the class name.
00308     if(iNumQuotes != 2)
00309         return WBEM_E_FAILED;
00310
00311     // check the instance list for a match.
00312
00313     for(iCnt = 0; iCnt < glNumInst; iCnt++)
00314     {
00315         if(!_wcsicmp(MyDefs[iCnt].pwcKey, pwcCompare))
00316         {
00317             sc = CreateInst(m_pNamespace,MyDefs[iCnt].pwcKey,
00318                     MyDefs[iCnt].lValue, ppObj, wcTest, pCtx);
00319             return sc;
00320         }
00321     }
00322
00323     return WBEM_E_NOT_FOUND;
00324 }
00325
00326 SCODE CClassPro::PutClassAsync(
00327             /* [in] */ IWbemClassObject __RPC_FAR *pObject,
00328             /* [in] */ long lFlags,
00329             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00330             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
00331 {
00332
00333   VARIANT var;
00334   VariantInit(&var);
00335   pObject->Get(L"__Class", 0, &var, NULL, NULL);
00336   if(!_wcsicmp(SAMPLE_CLASS_NAME, var.bstrVal))
00337     pResponseHandler->SetStatus(0,S_OK,NULL, NULL);
00338   else
00339     pResponseHandler->SetStatus(0,WBEM_E_NOT_FOUND,NULL, NULL);
00340   return S_OK;
00341 }
00342
00343 SCODE CClassPro::DeleteClassAsync(
00344             /* [in] */ const BSTR Class,
00345             /* [in] */ long lFlags,
00346             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00347             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
00348 {
00349   if(!_wcsicmp(SAMPLE_CLASS_NAME, Class))
00350     pResponseHandler->SetStatus(0,S_OK,NULL, NULL);
00351   else
00352     pResponseHandler->SetStatus(0,WBEM_E_NOT_FOUND,NULL, NULL);
00353
00354   return S_OK;
00355 }
00356 SCODE CClassPro::PutInstanceAsync(
00357             /* [in] */ IWbemClassObject __RPC_FAR *pInst,
00358             /* [in] */ long lFlags,
00359             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00360             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
00361 {
00362     pResponseHandler->SetStatus(0,S_OK,NULL, NULL);
00363   return S_OK;
00364 }
00365 SCODE CClassPro::DeleteInstanceAsync(
00366             /* [in] */ const BSTR ObjectPath,
00367             /* [in] */ long lFlags,
00368             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00369             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
00370 {
00371     pResponseHandler->SetStatus(0,S_OK,NULL, NULL);
00372   return S_OK;
00373 }
00374
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DiskCleanupHandler/ClassFactory.h Source File

  • WinUI
  • Shell
  • DiskCleanupHandler

ClassFactory.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  ClassFactory.h
00011 //
00012 //      Interface for the CClassFactory class.
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #ifndef _CLASSFACTORY_H_INCLUDED
00017 #define _CLASSFACTORY_H_INCLUDED
00018
00019 #if _MSC_VER > 1000
00020 #pragma once
00021 #endif // _MSC_VER > 1000
00022
00023 class CClassFactory : public IClassFactory
00024 {
00025 public:
00026     CClassFactory();
00027     virtual ~CClassFactory();
00028
00029     // IUnknown methods
00030     STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObject);
00031     STDMETHODIMP_(ULONG) AddRef();
00032     STDMETHODIMP_(ULONG) Release();
00033
00034     // IClassFactory methods
00035     STDMETHODIMP CreateInstance (LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
00036     STDMETHODIMP LockServer (BOOL bLock);
00037 private:
00038     ULONG m_nRefCount;
00039 };
00040
00041 #endif // _CLASSFACTORY_H_INCLUDED
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SENDTOARGS Member List

This is the complete list of members for _SENDTOARGS, including all inherited members.
dwBufferCount | _SENDTOARGS
dwFlags | _SENDTOARGS
dwNumberOfBytesSent | _SENDTOARGS
iToLen | _SENDTOARGS
lpBuffers | _SENDTOARGS
To | _SENDTOARGS
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/OPBank/linkable.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • OPBank

linkable.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Linkable.cpp
00003   Summary:   CLinkable linked list helper class implementation used by
00004        bank client
00005   Classes:   CLinkable
00006 -----------------------------------------------------------------------------
00007
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020
00021 ==========================================================================+*/
00022
00023 //
00024 // Includes
00025 //
00026 #include <stdafx.h>
00027 #include "linkable.h"
00028
00029
00030 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00031   Function: CLinkable::InsertAfter
00032   Summary:  Insert 'that' onto the list after 'this'. Remove 'other' from
00033       its current list, if necessary.
00034   Args:     CLinkable* that   element to insert
00035   Returns:  void
00036 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00037 void CLinkable::InsertAfter( CLinkable* that )
00038 {
00039   CLinkable* prev = that->m_pPrev;
00040   CLinkable* next = that->m_pNext;
00041
00042   prev->m_pNext = next;
00043   next->m_pPrev = prev;
00044
00045   next = this->m_pNext;
00046
00047   this->m_pNext = that;
00048   that->m_pPrev = this;
00049   that->m_pNext = next;
00050   next->m_pPrev = that;
00051 }
00052
00053
00054 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00055   Function: CLinkable::InsertBefore
00056   Summary:  Insert 'that' onto the list before 'this'. Remove 'other' from
00057       its current list, if necessary.
00058   Args:     CLinkable* that   item to insert
00059   Returns:  void
00060 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00061 void CLinkable::InsertBefore( CLinkable* that )
00062 {
00063   CLinkable* prev = that->m_pPrev;
00064   CLinkable* next = that->m_pNext;
00065
00066   prev->m_pNext = next;
00067   next->m_pPrev = prev;
00068
00069   prev = this->m_pPrev;
00070
00071   prev->m_pNext = that;
00072   that->m_pPrev = prev;
00073   that->m_pNext = this;
00074   this->m_pPrev = that;
00075 }
00076
00077
00078 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00079   Function: CLinkable::Remove
00080   Summary:  Remove element from its current list, if any.
00081       its current list, if necessary.
00082   Args:     None
00083   Returns:  void
00084 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00085 void CLinkable::Remove()
00086 {
00087   CLinkable* prev = m_pPrev;
00088   CLinkable* next = m_pNext;
00089
00090   prev->m_pNext = next;
00091   next->m_pPrev = prev;
00092
00093   m_pPrev = m_pNext = this;
00094 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Overlap/Overlap.c Source File

  • NetDS
  • WinSock
  • Overlap

Overlap.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 * Sample demonstrating use of Events in Overlapped (Asynchronous) I/O
00003 *
00004 * This code uses AcceptEx()
00005 * YOU MUST HAVE SERVICE PACK 3 on NT 3.51 to use it !!!
00006 *
00007 *       This is a part of the Microsoft Source Code Samples.
00008 *       Copyright 1996 - 2000 Microsoft Corporation.
00009 *       All rights reserved.
00010 *       This source code is only intended as a supplement to
00011 *       Microsoft Development Tools and/or WinHelp documentation.
00012 *       See these sources for detailed information regarding the
00013 *       Microsoft samples programs.
00014 \******************************************************************************/
00015 #ifdef _IA64_
00016     #pragma warning (disable: 4267)
00017 #endif
00018
00019 #ifndef WIN32_LEAN_AND_MEAN
00020 #define WIN32_LEAN_AND_MEAN
00021 #endif
00022
00023 #include <winsock2.h>
00024 #include <ws2tcpip.h>
00025 #include <mswsock.h>
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <string.h>
00029 #include <strsafe.h>
00030
00031 #define WS_VER 0x0202
00032 #define DEFAULT_PORT "5001"
00033 #define DEFAULT_BACKLOG 5
00034 #define MAX_IO_PEND 10    // maximum pending I/O requests
00035
00036 #define OP_READ 0x10
00037 #define OP_WRITE 0x20
00038
00039 #define XMALLOC(x) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,x)
00040 #define XFREE(x)   if(x != NULL) {HeapFree(GetProcessHeap(),0,x); x = NULL;}
00041
00042 #define ERR(e) fprintf(stderr,"\n%s failed with error: %d\n",e,WSAGetLastError())
00043 #define CLOSESOCK(s) if(INVALID_SOCKET != s) {closesocket(s); s = INVALID_SOCKET;}
00044 #define CLOSEEVENT(h) if(WSA_INVALID_EVENT != h) {WSACloseEvent(h); h = WSA_INVALID_EVENT;}
00045
00046 //
00047 // This structure keeps some useful information
00048 //
00049 typedef struct _socklist
00050 {
00051     SOCKET sock;
00052     WSAOVERLAPPED *overlap;
00053     char Buffer[128];
00054     WSABUF DataBuf;
00055 }Socklist;
00056
00057 int curr_size = 0; // current number of handles we are intersted in
00058
00059 int DoWait(WSAEVENT *, Socklist *) ;
00060 void HandleEvent(int , WSAEVENT *, Socklist *) ;
00061
00062 void Usage(char *progname)
00063 {
00064     fprintf(stderr,"Usage\n%s -e [endpoint] -i [interface]\n",
00065             progname);
00066     fprintf(stderr,"Where:\n");
00067     fprintf(stderr,"\tendpoint is the port to listen on\n");
00068     fprintf(stderr,"\tinterface is the ipaddr (in dotted decimal notation for IPv4 or hex quad notation for IPv6)");
00069     fprintf(stderr," to bind to\n");
00070     fprintf(stderr,"Defaults are 5001 and INADDR_ANY|IN6ADDR_ANY\n");
00071
00072 }
00073
00074 int __cdecl main(int argc, char **argv)
00075 {
00076
00077     char *interface = NULL;
00078     char *Buffer = NULL;
00079     char *port = DEFAULT_PORT;
00080     char host[NI_MAXHOST];
00081     char serv[NI_MAXSERV];
00082     int hostlen = NI_MAXHOST;
00083     int servlen = NI_MAXSERV;
00084     int ai_family = AF_UNSPEC;
00085     int i = 0;
00086     int nStartup = 0;
00087     struct addrinfo hints = {0};
00088     struct addrinfo *local = NULL;
00089     WSADATA wsaData;
00090     SOCKET listen_socket = INVALID_SOCKET;
00091     SOCKET accept_socket = INVALID_SOCKET;
00092     WSAOVERLAPPED *Overlap = NULL;
00093     DWORD bytes = 0;
00094     DWORD bytes_read = 0;
00095     DWORD lasterror = 0;
00096
00097     //
00098     // Handles is the array that stores the Event Handles
00099     //
00100     WSAEVENT Handles[MAX_IO_PEND] ;
00101
00102     //
00103     // socklist is a parallel array that keeps state information for
00104     // each Handle.
00105     //
00106     Socklist socklist[MAX_IO_PEND];
00107
00108     //
00109     // Pointers to Microsoft specific extensions
00110     //
00111     LPFN_ACCEPTEX pfnAcceptEx;
00112     GUID acceptex_guid = WSAID_ACCEPTEX;
00113
00114     __try
00115     {
00116
00117
00118         if (NULL == (Buffer = (char*)XMALLOC(((2*sizeof(SOCKADDR_STORAGE))+32)*sizeof(char))))
00119         {
00120             ERR("HeapAlloc()");
00121             __leave;
00122
00123         }
00124
00125         //
00126         // Parse arguments
00127         //
00128         if ( argc > 1 )
00129         {
00130             for ( i = 1;i < argc; i++ )
00131             {
00132                 if ( (argv[i][0] == '-') || (argv[i][0] == '/') )
00133                 {
00134                     switch ( tolower(argv[i][1]) )
00135                     {
00136
00137                     case 'i':
00138                         if ( i+1 < argc )
00139                             interface = argv[++i];
00140                         break;
00141                     case 'e':
00142                         if ( i+1 < argc )
00143                             port = argv[++i];
00144                         break;
00145                     default:
00146                         {
00147                             Usage(argv[0]);
00148                             __leave;
00149                         }
00150                         break;
00151                     }
00152                 }
00153                 else
00154                 {
00155                     Usage(argv[0]);
00156                     __leave;
00157                 }
00158             }
00159         }
00160
00161         //
00162         // Since port 0 would be any available port.
00163         // Resetting port back to DEFAULT_PORT to avoid confusion.
00164         //
00165         if ( 0 == strncmp(port, "0", 1) )
00166         {
00167             port = DEFAULT_PORT;
00168         }
00169
00170         if ( 0 != (nStartup = WSAStartup(WS_VER, &wsaData)) )
00171         {
00172             WSASetLastError(nStartup); //WSAStartup does not set last error on failure
00173             ERR("WSAStartup()");
00174             __leave;
00175
00176         }
00177         else
00178             nStartup++;
00179
00180         //
00181         // Resolve the interface
00182         //
00183         SecureZeroMemory(&hints,sizeof(hints));
00184         hints.ai_flags  = ((interface) ? 0 : AI_PASSIVE);
00185         hints.ai_family = ai_family;
00186         hints.ai_socktype = SOCK_STREAM;
00187         hints.ai_protocol = IPPROTO_TCP;
00188
00189         if ( 0 != getaddrinfo(interface, port, &hints, &local))
00190         {
00191             ERR("getaddrinfo()");
00192             __leave;
00193         }
00194
00195         ai_family = local->ai_family;
00196
00197         if (NULL == local)
00198         {
00199             fprintf(stderr, "getaddrinfo() failed to resolve/convert the interface\n");
00200             __leave;
00201         }
00202
00203         if (INVALID_SOCKET == (listen_socket = WSASocket(local->ai_family,
00204                                                          local->ai_socktype,
00205                                                          local->ai_protocol,
00206                                                          NULL,
00207                                                          0,
00208                                                          WSA_FLAG_OVERLAPPED
00209                                                         )))
00210         {
00211             ERR("WSASocket()");
00212             __leave;
00213         }
00214
00215
00216         if ( SOCKET_ERROR == bind(listen_socket,
00217                                   local->ai_addr,
00218                                   (int)local->ai_addrlen
00219                                  ))
00220         {
00221             ERR("bind()");
00222             __leave;
00223         }
00224
00225
00226         if ( SOCKET_ERROR == listen(listen_socket, DEFAULT_BACKLOG))
00227         {
00228             ERR("listen()");
00229             __leave;
00230         }
00231
00232         //
00233         // Resolve numeric host name
00234         //
00235         if ( 0 != getnameinfo(local->ai_addr,
00236                               (int)local->ai_addrlen,
00237                               host,
00238                               hostlen,
00239                               serv,
00240                               servlen,
00241                               NI_NUMERICHOST | NI_NUMERICSERV
00242                              ))
00243         {
00244             ERR("getnameinfo()");
00245             __leave;
00246         }
00247
00248         // Don't need the local interface anymore
00249         if (NULL != local)
00250             freeaddrinfo(local);
00251
00252         printf("Listening on %s:%s\n", host, serv);
00253
00254         //
00255         // Add the listening socket to our state information for the handle.
00256         //
00257         socklist[0].sock = listen_socket;
00258
00259         curr_size =1;
00260
00261         for ( i = 0;i < MAX_IO_PEND;i++ )
00262             Handles[i] = WSA_INVALID_EVENT;
00263
00264         //
00265         // Load the extension functions
00266         //
00267
00268         if ( SOCKET_ERROR == WSAIoctl(listen_socket,
00269                                       SIO_GET_EXTENSION_FUNCTION_POINTER,
00270                                       &acceptex_guid,
00271                                       sizeof(acceptex_guid),
00272                                       &pfnAcceptEx,
00273                                       sizeof(pfnAcceptEx),
00274                                       &bytes,
00275                                       NULL,
00276                                       NULL
00277                                      ))
00278         {
00279             fprintf(stderr,"Failed to obtain AcceptEx() pointer: ");
00280             ERR("WSAIoctl()");
00281             __leave;
00282         }
00283
00284         //
00285         // The structure of the following loop is very similar to a situation
00286         // where select() might be used.
00287         // We use WSAGetOverlappedResult() to multiplex between incoming/outgoing
00288         // data on existing connections.
00289         //
00290         // We don't queue an AcceptEx() until someone actually connects to
00291         // the previous socket. This is to keep the code simple, not a limitation
00292         // of the API itself.
00293         //
00294         for ( ;; )
00295         {
00296
00297             // create a socket for AcceptEx()
00298
00299             if (INVALID_SOCKET == (accept_socket = WSASocket(ai_family,
00300                                                              SOCK_STREAM,
00301                                                              0,
00302                                                              NULL,
00303                                                              0,
00304                                                              WSA_FLAG_OVERLAPPED
00305                                                             )))
00306             {
00307                 ERR("WSASocket()");
00308                 __leave;
00309             }
00310
00311             //
00312             // Allocate an overlapped structure.
00313             // We use the Offset field to keep track of the socket handle
00314             // we have accepted a connection on, since there is no other
00315             // way to pass information to GetOverlappedResult()
00316             //
00317             Overlap = (WSAOVERLAPPED*)XMALLOC(sizeof(WSAOVERLAPPED));
00318
00319             //
00320             // Did the HeapAllocation FAIL??
00321             //
00322             if ( Overlap == NULL )
00323             {
00324                 ERR("HeapAlloc()");
00325                 __leave;
00326             }
00327
00328             SecureZeroMemory(Overlap, sizeof(WSAOVERLAPPED));
00329
00330             Overlap->Offset = (DWORD) accept_socket;
00331
00332             if ( WSA_INVALID_EVENT == (Overlap->hEvent = WSACreateEvent() ))
00333             {
00334                 ERR("WSACreateEvent()");
00335                 __leave;
00336             }
00337
00338             //
00339             // Set the appropriate array members
00340             //
00341             Handles[0] = Overlap->hEvent;
00342             socklist[0].overlap = Overlap;
00343
00344             //
00345             // AcceptEx()
00346             //
00347             if ( !pfnAcceptEx(listen_socket,
00348                               accept_socket,
00349                               Buffer,
00350                               0, // read nothing from the socket
00351                               sizeof(SOCKADDR_STORAGE)+16,
00352                               sizeof(SOCKADDR_STORAGE)+16,
00353                               &bytes_read,
00354                               Overlap
00355                              ))
00356             {
00357
00358                 lasterror = WSAGetLastError();
00359                 if ( WSA_IO_PENDING != lasterror)
00360                 {
00361                     ERR("AcceptEx()");
00362                     for ( i = 0; i < curr_size; i++ )
00363                     {
00364                         shutdown(socklist[i].sock, SD_BOTH);
00365                         CLOSESOCK(socklist[i].sock);
00366                         XFREE(socklist[i].overlap);
00367                         CLOSEEVENT(Handles[i]);
00368                     }
00369                     __leave;
00370                 }
00371             }
00372
00373             //
00374             // This loop simple checks the handles to see which one is
00375             // signalled.
00376             // If error, exit.
00377             // If there is a new incoming connection, we break to the outer loop
00378             // queue another AcceptEx()
00379             //
00380             for ( ;; )
00381             {
00382                 i = DoWait(Handles, socklist);
00383                 if ( i < 0 )
00384                     break;
00385                 HandleEvent(i, Handles, socklist);
00386                 if ( i == 0 )
00387                     break;
00388             };
00389             if ( i < 0 )
00390             {
00391                 for ( i = 0; i < curr_size; i++ )
00392                 {
00393                     shutdown(socklist[i].sock, SD_BOTH);
00394                     CLOSESOCK(socklist[i].sock);
00395                     XFREE(socklist[i].overlap);
00396                     CLOSEEVENT(Handles[i]);
00397                 }
00398                 __leave;
00399             }
00400         }
00401     }
00402     __finally
00403     {
00404         XFREE(Buffer);
00405         if (NULL != local) freeaddrinfo(local);
00406         CLOSESOCK(listen_socket);
00407         CLOSESOCK(accept_socket);
00408         CLOSEEVENT(Overlap->hEvent);
00409         XFREE(Overlap);
00410
00411     }
00412 }
00413
00414 /*
00415  * This is the main function that handles all the events occuring on the
00416  * different handles we are watching.
00417  *
00418  * Parameters:
00419  *          index: Index into the Handles[] array. Returned by DoWait()
00420  *          Handles: Array of Event Handles we are watching
00421  *          socklist: Helper parallel array of state information
00422  *
00423  */
00424 void HandleEvent(int index, WSAEVENT *Handles, Socklist *socklist)
00425 {
00426
00427     WSAOVERLAPPED *Overlap;
00428     SOCKET newsock = INVALID_SOCKET;
00429     DWORD bytes = 0;
00430     DWORD    flags    =    0;
00431     DWORD lasterr = 0;
00432     int i = 0;
00433
00434     Overlap = socklist[index].overlap;
00435
00436
00437
00438
00439     if (!WSAResetEvent(Handles[index]))
00440     {
00441         ERR("WSAResetEvent()");
00442     }
00443
00444     //
00445     // Check the specified handle
00446     //
00447     // If a socket is closed by the other side, the error returned is
00448     // WSAECONNRESET
00449     //
00450     if ( !WSAGetOverlappedResult(socklist[index].sock,
00451                                  Overlap,
00452                                  &bytes,
00453                                  FALSE,
00454                                  &flags))
00455     {
00456         ERR("WSAGetOverlappedResult()");
00457     }
00458
00459     newsock = Overlap->Offset;
00460
00461     //
00462     // If the other side closed the connection, close our socket and
00463     // move the next element of the Handles[] array into our
00464     // index.
00465     //
00466     // The array compaction is done so that we only pass valid handles
00467     // in the first "curr_size" elements of the array to
00468     // WSAWaitForMultipleEvents(). The function will fail otherwise.
00469     //
00470
00471     //
00472     // We should NEVER get this for our listening socket
00473     //
00474     if ( (index != 0) && (bytes == 0 ) )
00475     {
00476         CLOSESOCK(newsock);
00477         XFREE(Overlap);
00478         CLOSEEVENT(Handles[index]);
00479         for ( i = index; i < curr_size; i++ )
00480         {
00481             Handles[i] = Handles[i+1];
00482             socklist[i] = socklist[i+1];
00483         }
00484         curr_size--;
00485         return;
00486     }
00487
00488     if ( (index == 0) )
00489     {    // listening socket
00490         if ( curr_size >= MAX_IO_PEND )
00491         {
00492             shutdown(newsock, SD_BOTH);
00493             CLOSESOCK(newsock);
00494             fprintf(stderr,"Too many pending requests\n");
00495             return;
00496         }
00497
00498         //
00499         // Get the event handle used to queue the AcceptEx(),
00500         // and re-use it to queue a WSARecv() on the socket.
00501         //
00502         Handles[curr_size] = Overlap->hEvent;
00503
00504         //
00505         // Fill in the details of our accepted socket
00506         //
00507         socklist[curr_size].sock = newsock;
00508         SecureZeroMemory(socklist[curr_size].Buffer,
00509                          sizeof(socklist[curr_size].Buffer)/sizeof(socklist[curr_size].Buffer[0]
00510                          ));
00511
00512         socklist[curr_size].overlap = Overlap;
00513         socklist[curr_size].DataBuf.len = sizeof(socklist[curr_size].Buffer);
00514         socklist[curr_size].DataBuf.buf = socklist[curr_size].Buffer;
00515
00516         //
00517         // The OffsetHigh field is used to keep track of what we are doing.
00518         // This enables us to alternate WSARecv() and WSASend() on a
00519         // connection
00520         //
00521         Overlap->OffsetHigh = OP_READ;
00522
00523         flags = 0;
00524         if ( SOCKET_ERROR == WSARecv(socklist[curr_size].sock,
00525                                      &(socklist[curr_size].DataBuf),
00526                                      1,
00527                                      &bytes,
00528                                      &flags,
00529                                      socklist[curr_size].overlap,
00530                                      NULL
00531                                      ))
00532         {
00533
00534             lasterr = WSAGetLastError();
00535
00536             if ( WSA_IO_PENDING != lasterr)
00537             {
00538                 ERR("WSARecv()");
00539                 if ( WSAECONNRESET == lasterr)
00540                 {
00541
00542                     //
00543                     // Handle WSAECONNRESET specially
00544                     // Other errors are not good
00545                     //
00546                     shutdown(newsock, SD_BOTH);
00547                     CLOSESOCK(newsock);
00548                     XFREE(Overlap);
00549                     CLOSEEVENT(Handles[index]);
00550                     for ( i = index; i < curr_size; i++ )
00551                     {
00552                         Handles[i] = Handles[i+1];
00553                         socklist[i] = socklist[i+1];
00554                     }
00555                     curr_size--;
00556                 }
00557                 return;
00558             }
00559         }
00560
00561         //
00562         // Increment the last valid handle location in the Handles
00563         // array.
00564         //
00565         curr_size++;
00566         return;
00567     }
00568
00569     //
00570     //  If the previous operation was an OP_READ, queue WSASend() on the
00571     //  socket
00572     //
00573     if ( Overlap->OffsetHigh == OP_READ )
00574     { // WSARecv() was queued
00575
00576         printf("Read buffer [%s]\n", socklist[index].Buffer);
00577         printf("Echoing back to client\n");
00578
00579         if ( SOCKET_ERROR == WSASend(socklist[index].sock,
00580                                      &(socklist[index].DataBuf),
00581                                      1,
00582                                      &bytes,
00583                                      0,
00584                                      socklist[index].overlap,
00585                                      NULL))
00586         {
00587
00588             lasterr = WSAGetLastError();
00589             if(WSA_IO_PENDING != lasterr)
00590             {
00591                 ERR("WSASend()");
00592                 if ( WSAECONNRESET == lasterr)
00593                 {
00594                     shutdown(newsock, SD_BOTH);
00595                     CLOSESOCK(newsock);
00596                     XFREE(Overlap);
00597                     CLOSEEVENT(Handles[index]);
00598                     for ( i = index; i < curr_size; i++ )
00599                     {
00600                         Handles[i] = Handles[i+1];
00601                         socklist[i] = socklist[i+1];
00602                     }
00603                     curr_size--;
00604                 }
00605                 return;
00606             }
00607         }
00608
00609         Overlap->OffsetHigh = OP_WRITE;
00610         return;
00611     }
00612
00613     //
00614     // If we had a WSASend() queued, now do a WSARecv()
00615     //
00616     else if ( Overlap->OffsetHigh == OP_WRITE )
00617     { // WSASend() was queued
00618
00619         printf("Wrote %d bytes\n",bytes);
00620         printf("Queueing read\n");
00621
00622         flags = 0;
00623         if ( SOCKET_ERROR == WSARecv(socklist[index].sock,
00624                                      &(socklist[index].DataBuf),
00625                                      1,
00626                                      &bytes,
00627                                      &flags,
00628                                      socklist[index].overlap,
00629                                      NULL
00630                                      ))
00631         {
00632
00633             lasterr = WSAGetLastError();
00634             if(WSA_IO_PENDING != lasterr)
00635             {
00636                 ERR("WSARecv()");
00637                 if ( WSAECONNRESET == lasterr)
00638                 {
00639                     shutdown(newsock, SD_BOTH);
00640                     CLOSESOCK(newsock);
00641                     XFREE(Overlap);
00642                     CLOSEEVENT(Handles[index]);
00643                     for ( i = index; i < curr_size; i++ )
00644                     {
00645                         Handles[i] = Handles[i+1];
00646                         socklist[i] = socklist[i+1];
00647                     }
00648                     curr_size--;
00649                 }
00650                 return;
00651             }
00652         }
00653
00654         Overlap->OffsetHigh = OP_READ;
00655         return;
00656     }
00657     else
00658     {
00659         fprintf(stderr,"Unknown operation queued\n");
00660     }
00661
00662
00663
00664 }
00665
00666 //
00667 // This is the wait function used to keep track of events
00668 //
00669 int DoWait(WSAEVENT *Handles, Socklist *socklist)
00670 {
00671
00672     DWORD wait_rc = 0;
00673     WSAEVENT hTemp = WSA_INVALID_EVENT;
00674     Socklist socklTemp;
00675
00676     int i = 0;
00677
00678     //
00679     // Rotate the array, beginning at index 1, by one element.
00680     // This ensures that all handles get a fair chance to be serviced.
00681     //
00682     // There is no way to detect how many handles were signalled when
00683     // WSAWaitForMultipleObjects() returns. We simply pick the first one and
00684     // come back to this function later
00685     // Without the rotation below, this has the potential for starving
00686     // connections accepted later.
00687     //
00688     // Index 0 is avoided, since it is our listening socket.
00689     //
00690     for ( i = 1; i < curr_size-1; i++ )
00691     {
00692         hTemp = Handles[i+1];
00693         Handles[i+1] = Handles[i];
00694         Handles[i] = hTemp;
00695
00696         socklTemp = socklist[i+1];
00697         socklist[i+1] = socklist[i];
00698         socklist[i] = socklTemp;
00699     }
00700
00701     if(WSA_WAIT_FAILED == (wait_rc = WSAWaitForMultipleEvents(curr_size,
00702                                                               Handles,
00703                                                               FALSE,
00704                                                               WSA_INFINITE,
00705                                                               FALSE
00706                                                               )))
00707     {
00708         ERR("WSAWaitForMultipleEvents()");
00709         return -1;
00710     }
00711
00712     return(wait_rc - WSA_WAIT_EVENT_0);
00713 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/compdata.h Source File

  • SysMgmt
  • MMC
  • Taskpads

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData
00028 {
00029     friend class CComponent;
00030
00031 private:
00032     ULONG       m_cref;
00033     LPCONSOLE     m_ipConsole;
00034     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00035
00036     CStaticNode     *m_pStaticNode;
00037
00038 public:
00039     CComponentData();
00040     ~CComponentData();
00041
00042     ///////////////////////////////
00043     // Interface IUnknown
00044     ///////////////////////////////
00045     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046     STDMETHODIMP_(ULONG) AddRef();
00047     STDMETHODIMP_(ULONG) Release();
00048
00049     ///////////////////////////////
00050     // Interface IComponentData
00051     ///////////////////////////////
00052     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053         /* [in] */ LPUNKNOWN pUnknown);
00054
00055         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00056         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00059         /* [in] */ LPDATAOBJECT lpDataObject,
00060         /* [in] */ MMC_NOTIFY_TYPE event,
00061         /* [in] */ LPARAM arg,
00062         /* [in] */ LPARAM param);
00063
00064         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00065
00066     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00067         /* [in] */ MMC_COOKIE cookie,
00068         /* [in] */ DATA_OBJECT_TYPES type,
00069         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00070
00071         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075         /* [in] */ LPDATAOBJECT lpDataObjectA,
00076         /* [in] */ LPDATAOBJECT lpDataObjectB);
00077 };
00078
00079 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::FieldEnum Member List

This is the complete list of members for msado15::FieldEnum, including all inherited members.
adDefaultStream | msado15::FieldEnum | [static]
adRecordURL | msado15::FieldEnum | [static]
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/Client/Client.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • Client

Client.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: client.cpp
00004
00005 Summary:  Produced by VS6 MFC Wizard. Implements the Client.Exe Application.
00006
00007 Look in this module to see how Non-Blocking Method Calls and Call Cancellation
00008 are used to implement DCOM Timeouts.
00009
00010 ----------------------------------------------------------------------------
00011
00012 This file is part of the Microsoft COM+ Samples.
00013
00014 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00015
00016 This source code is intended only as a supplement to Microsoft
00017 Development Tools and/or on-line documentation. See these other
00018 materials for detailed information regarding Microsoft code samples.
00019
00020 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00021 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00022 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00023 PARTICULAR PURPOSE.
00024
00025 ==========================================================================+*/
00026 // client.cpp : Defines the class behaviors for the application.
00027 //
00028
00029 #include "stdafx.h"
00030 #include "client.h"
00031 #include "clientDlg.h"
00032
00033
00034 #include "..\server\server_i.c"
00035 #include "..\PingResp\PingResp_i.c"
00036
00037 #ifdef _DEBUG
00038 #define new DEBUG_NEW
00039 #undef THIS_FILE
00040 static char THIS_FILE[] = __FILE__;
00041 #endif
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // CClientApp
00045
00046 BEGIN_MESSAGE_MAP(CClientApp, CWinApp)
00047   //{{AFX_MSG_MAP(CClientApp)
00048     // NOTE - the ClassWizard will add and remove mapping macros here.
00049     //    DO NOT EDIT what you see in these blocks of generated code!
00050   //}}AFX_MSG
00051   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00052 END_MESSAGE_MAP()
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // CClientApp construction
00056
00057 CClientApp::CClientApp()
00058 {
00059   pDlg = NULL;
00060   pMonitor = NULL;
00061   pMonitorCallFactory = NULL;
00062   pMonitorResponder = NULL;
00063   nFail = 0;
00064   // Place all significant initialization in InitInstance
00065 }
00066
00067 CClientApp::~CClientApp(){
00068 //    if (pMonitorCallFactory) pMonitorCallFactory->Release();
00069 //    if (pMonitor) pMonitor->Release();
00070         if (pDlg) delete pDlg;
00071 }
00072 /////////////////////////////////////////////////////////////////////////////
00073 // The one and only CClientApp object
00074
00075 CClientApp theApp;
00076
00077 /////////////////////////////////////////////////////////////////////////////
00078 // CClientApp initialization
00079
00080 BOOL CClientApp::InitInstance()
00081 {
00082   // Standard initialization
00083   // If you are not using these features and wish to reduce the size
00084   //  of your final executable, you should remove from the following
00085   //  the specific initialization routines you do not need.
00086
00087 #ifdef _AFXDLL
00088   Enable3dControls();     // Call this when using MFC in a shared DLL
00089 #else
00090   Enable3dControlsStatic(); // Call this when linking to MFC statically
00091 #endif
00092
00093   AfxOleInit();
00094
00095   pDlg = new CClientDlg;
00096   m_pMainWnd = pDlg;
00097   if (!pDlg->Create(IDD_CLIENT_DIALOG,NULL)){
00098     AfxMessageBox(_T("Can't Create Dialog!"));
00099     return FALSE;
00100   }
00101
00102
00103   return TRUE;
00104 }
00105
00106
00107 HRESULT CClientApp::DoAPing(IPingResponder *pResp, DWORD dwTimeout){
00108   AsyncIPingResponder *pAsyncResp = NULL;
00109   ISynchronize* pAsyncSync = NULL;
00110   ICallFactory* pResponderCallFactory = NULL;
00111   ICancelMethodCalls* pCancel = NULL;
00112
00113   HRESULT hr = E_FAIL;
00114   __try {
00115     hr = pResp->QueryInterface(IID_ICallFactory, (void**)&pResponderCallFactory);
00116     if (FAILED(hr)) return hr;
00117
00118     hr = pResponderCallFactory->CreateCall(IID_AsyncIPingResponder,NULL,IID_AsyncIPingResponder,(IUnknown**)&pAsyncResp);
00119     if (FAILED(hr)) return hr;
00120
00121     hr = pAsyncResp->Begin_Ping();
00122     if (FAILED(hr)) return hr;
00123     pDlg->m_lPings++;
00124
00125     // Timeout the Ping...
00126     hr = pAsyncResp->QueryInterface(IID_ISynchronize,(void**)&pAsyncSync);
00127     if (FAILED(hr)) return hr;
00128
00129     // The HRESULT from this wait is what determines whether DoAPing fails!
00130     hr = pAsyncSync->Wait(0, dwTimeout);
00131
00132     if (hr != S_OK){
00133       // Ping didn't complete in time. Cancel the call to cleanup
00134       // any resources consumed by the call.
00135       HRESULT hr2 = S_OK;
00136       hr2 = pAsyncResp->QueryInterface(IID_ICancelMethodCalls, (void**)&pCancel);
00137         ASSERT(SUCCEEDED(hr2));
00138         hr2 = pCancel->Cancel(0);
00139         ASSERT(SUCCEEDED(hr2));
00140         pCancel->Release();
00141         pCancel = NULL;
00142       pDlg->m_lPingFailures++;
00143     }
00144
00145     // Complete the Ping Call ignoring its results
00146     pAsyncResp->Finish_Ping();
00147
00148   }
00149   __finally{
00150     // All these releases will cleanup any debris left from the ping
00151     if (pCancel) pCancel->Release();
00152     if (pAsyncResp) pAsyncResp->Release();
00153     if (pAsyncSync) pAsyncSync->Release();
00154     if (pResponderCallFactory) pResponderCallFactory->Release();
00155   }
00156   return hr;
00157 }
00158
00159 BOOL CClientApp::OnIdle(LONG lCount)
00160 {
00161   AsyncIMonitorServer *pAsyncMonitor = NULL;
00162   ISynchronize* pAsyncSync = NULL;
00163   ICancelMethodCalls* pCancel = NULL;
00164   HRESULT hr = E_FAIL;
00165
00166   CWinApp::OnIdle(lCount);
00167
00168   __try {
00169   if ((lCount == 0) && pMonitorCallFactory){
00170
00171     // Time to make Non-Blocking Call to get data
00172     hr = pMonitorCallFactory->CreateCall(IID_AsyncIMonitorServer,NULL,IID_AsyncIMonitorServer,(IUnknown**)&pAsyncMonitor);
00173     if (FAILED(hr)){
00174       AfxMessageBox(_T("OOPS! Creating of Call Instance Object Failed"));
00175       return FALSE;
00176     }
00177
00178     // Start Call
00179     pDlg->m_lTries++;
00180
00181     hr = pAsyncMonitor->Begin_GetData();
00182     if (SUCCEEDED(hr)) {
00183
00184       hr = pAsyncMonitor->QueryInterface(IID_ISynchronize,(void**)&pAsyncSync);
00185       ASSERT(SUCCEEDED(hr));
00186       //
00187       // There are two different mechanisms shown here:
00188       //  A) As long as the server system responsds to a ping
00189       //       let the call complete in as long as it likes.
00190       //
00191       //  B) Enforce a strict timeout. The call must complete within
00192       //     the CALLTIMEOUT interval.
00193       //
00194
00195       if (pDlg->m_bUsePing){
00196         // Use the pinging technique...
00197         HRESULT hr2 = S_OK;
00198
00199         // Keep call going as long as pinging succeeds
00200         while (hr2 == S_OK) {
00201         hr = pAsyncSync->Wait(0, CALLTIMEOUTWHENPINGING);
00202         if (hr != S_OK){
00203           hr2 = DoAPing(pMonitorResponder, PINGTIMEOUT);
00204
00205         } else {
00206           hr2 = (HRESULT)-1; //Call Completed
00207         }
00208         }
00209
00210         // Evaluate the results of pinging or call
00211         if (hr != S_OK){
00212           // Call didn't complete and we got here because DoAPing failed
00213           // Just cancel call
00214           pDlg->m_lTimeouts++;
00215           hr = pAsyncMonitor->QueryInterface(IID_ICancelMethodCalls, (void**)&pCancel);
00216           ASSERT(SUCCEEDED(hr));
00217           hr = pCancel->Cancel(0);
00218           ASSERT(SUCCEEDED(hr));
00219           pCancel->Release();
00220           pCancel = NULL;
00221         }
00222
00223       } else {
00224         // Apply Strict Timeouts
00225         hr = pAsyncSync->Wait(0,CALLTIMEOUT);
00226         if (hr != S_OK){
00227           // Timeout happened before Call Completed
00228           // Cancel call which will cause Finish_GetData
00229           //   to return RPC_E_CALLCANCELED
00230           pDlg->m_lTimeouts++;
00231           hr = pAsyncMonitor->QueryInterface(IID_ICancelMethodCalls, (void**)&pCancel);
00232           ASSERT(SUCCEEDED(hr));
00233           hr = pCancel->Cancel(0);
00234           ASSERT(SUCCEEDED(hr));
00235           pCancel->Release();
00236           pCancel = NULL;
00237         }
00238       }
00239
00240       pAsyncSync->Release();
00241       pAsyncSync = NULL;
00242     } else {
00243       pDlg->m_lFails++;
00244     }
00245     // Complete Call
00246         long iNewData;
00247     hr = pAsyncMonitor->Finish_GetData(&iNewData);
00248     if (SUCCEEDED(hr)) {
00249             pDlg->m_iData = iNewData;       // Believe new data
00250       nFail = 0;            // State data Ok...
00251         } else {
00252       nFail++;
00253         }
00254     if (nFail > 3) nFail=3;   // To keep the UI happy
00255
00256
00257
00258     pAsyncMonitor->Release();
00259     pAsyncMonitor = NULL;
00260
00261     // Update Status Text on Dialog based upon nFail
00262     if (nFail == 0){
00263       pDlg->m_cGood.ModifyStyle(0,WS_VISIBLE,0);
00264       pDlg->m_cWarning.ModifyStyle(WS_VISIBLE,0,0);
00265       pDlg->m_cBad.ModifyStyle(WS_VISIBLE,0,0);
00266     } else if (nFail <= 2){
00267       pDlg->m_cGood.ModifyStyle(WS_VISIBLE,0,0);
00268       pDlg->m_cWarning.ModifyStyle(0,WS_VISIBLE,0);
00269       pDlg->m_cBad.ModifyStyle(WS_VISIBLE,0,0);
00270     } else {
00271       pDlg->m_cGood.ModifyStyle(WS_VISIBLE,0,0);
00272       pDlg->m_cWarning.ModifyStyle(WS_VISIBLE,0,0);
00273       pDlg->m_cBad.ModifyStyle(0,WS_VISIBLE,0);
00274     }
00275
00276     pDlg->Invalidate(TRUE);
00277     pDlg->UpdateData(FALSE);
00278     pDlg->UpdateWindow();
00279
00280     pDlg->SetTimer(47,MONITORPOLLDELAY,NULL);
00281
00282
00283   }
00284   }
00285   __finally {
00286     if (pCancel) pCancel->Release();
00287     if (pAsyncSync) pAsyncSync->Release();
00288     if (pAsyncMonitor) pAsyncMonitor->Release();
00289     }
00290
00291   return FALSE;
00292 }
00293
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/CRUCAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

CRUCAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CRUCAR.CPP
00003
00004   Summary:   Implementation file for the aggregatable COLicCruiseCar COM
00005              object class.
00006
00007              CRUCAR showcases the construction of the COLicCruiseCar COM
00008              object class with the IUnknown, ICar, and ICruise interfaces.
00009              This is done through Aggregation reuse of COCar's ICar
00010              interface features.  COCar is provided by a separate COM
00011              server (DLLSERVE).
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial DLLSERVE.HTM file.
00015              For more specific technical details on the internal workings
00016              see the comments dispersed throughout the module's source code.
00017
00018   Classes:   COLicCruiseCar.
00019
00020   Functions: none.
00021
00022   Origin:    10-5-95: atrent - Editor-inheritance from CRUCAR.CPP in
00023                the DLLSERVE Tutorial Code Sample.
00024
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040 /*---------------------------------------------------------------------------
00041   We include WINDOWS.H for all Win32 applications.
00042   We include OLE2.H because we will be calling the COM/OLE Libraries.
00043   We include APPUTIL.H because we will be building this application using
00044     the convenient Virtual Window and Dialog classes and other
00045     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00046   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00047     class, GUID, and CLSID specifications.
00048   We include SERVER.H because it has the necessary internal class and
00049     resource definitions for this DLL.
00050   We include CRUCAR.H because it has the class COLicCruiseCar declarations.
00051 ---------------------------------------------------------------------------*/
00052 #include <windows.h>
00053 #include <ole2.h>
00054 #include <apputil.h>
00055 #include <icars.h>
00056 #include <carguids.h>
00057 #include "server.h"
00058 #include "crucar.h"
00059
00060
00061 /*---------------------------------------------------------------------------
00062   COLicCruiseCar's implementation of its main COM object class including
00063   Constructor, Destructor, QueryInterface, AddRef, and Release.
00064 ---------------------------------------------------------------------------*/
00065
00066 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00067   Method:   COLicCruiseCar::COLicCruiseCar
00068
00069   Summary:  COLicCruiseCar Constructor. Note the member initializer:
00070             "m_ImpICruise(this, pUnkOuter)" which is used to pass the
00071             'this' and pUnkOuter pointers of this constructor function
00072             to the constructor in the instantiation of the implementation
00073             of the CImpICruise interface (which is nested inside this
00074             present COLicCruiseCar Object Class).
00075
00076   Args:     IUnknown* pUnkOuter,
00077               Pointer to the the outer Unknown.  NULL means this COM Object
00078               is not being Aggregated.  Non NULL means it is being created
00079               on behalf of an outside COM object that is reusing it via
00080               aggregation.
00081             CServer* pServer)
00082               Pointer to the server's control object.
00083
00084   Modifies: m_cRefs, m_pUnkOuter.
00085
00086   Returns:  void
00087 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00088 COLicCruiseCar::COLicCruiseCar(
00089   IUnknown* pUnkOuter,
00090   CServer* pServer) :
00091   m_ImpICruise(this, pUnkOuter)
00092 {
00093   // Zero the COM object's reference count.
00094   m_cRefs = 0;
00095
00096   // No AddRef necessary if non-NULL, as this present COM object's lifetime
00097   // is totally coupled with the controlling Outer object's lifetime.
00098   m_pUnkOuter = pUnkOuter;
00099
00100   // Zero the pointer to the aggregated COCar object's IUnknown
00101   // interface (for delegation of IUnknown calls to it).
00102   m_pUnkCar = NULL;
00103
00104   // Assign the pointer to the server's control object.
00105   m_pServer = pServer;
00106
00107   LOGF1("P: COLicCruiseCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00108
00109   return;
00110 }
00111
00112
00113 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00114   Method:   COLicCruiseCar::~COLicCruiseCar
00115
00116   Summary:  COLicCruiseCar Destructor.
00117
00118   Args:     void
00119
00120   Modifies: .
00121
00122   Returns:  void
00123 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00124 COLicCruiseCar::~COLicCruiseCar(void)
00125 {
00126   LOG("P: COLicCruiseCar::Destructor.");
00127
00128   RELEASE_INTERFACE(m_pUnkCar);
00129
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   COLicCruiseCar::Init
00136
00137   Summary:  COLicCruiseCar Initialization method.
00138
00139   Args:     void
00140
00141   Modifies: m_pUnkCar, m_pICar, m_cRefs.
00142
00143   Returns:  HRESULT
00144               Standard result code. NOERROR for success.
00145 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00146 HRESULT COLicCruiseCar::Init(void)
00147 {
00148   HRESULT hr;
00149
00150   LOG("P: COLicCruiseCar::Init.");
00151
00152   // Set up the right pIUnknown for delegation.  If we are being
00153   // aggregated then we pass the pUnkOuter in turn to any COM objects
00154   // that we are aggregating.  m_pUnkOuter was set in the Constructor.
00155   IUnknown* pUnkOuter = (NULL == m_pUnkOuter) ? this : m_pUnkOuter;
00156
00157   // We create an instance of the COCar object and do this via the
00158   // Aggregation reuse technique.  Note we pass pUnkOuter as the
00159   // Aggregation pointer.  It is the 'this' pointer to this present
00160   // LicCruiseCar object if we are not being aggregated; otherwise it is
00161   // the pointer to the outermost object's controlling IUnknown.  Following
00162   // the rules of Aggregation we must ask for an IID_IUnknown interface.
00163   // We cache the requested  pointer to the IUnknown of the new COCar COM
00164   // object for later use in delegating IUnknown calls.
00165   hr = CoCreateInstance(
00166          CLSID_DllCar,
00167          pUnkOuter,
00168          CLSCTX_INPROC_SERVER,
00169          IID_IUnknown,
00170          (PPVOID)&m_pUnkCar);
00171
00172   if (SUCCEEDED(hr))
00173   {
00174     LOG("P: COLicCruiseCar::Init (New Aggregation of COCar) Succeeded.");
00175   }
00176   else
00177   {
00178     LOG("P: COLicCruiseCar::Init (New Aggregation of COCar) Failed.");
00179   }
00180
00181   return (hr);
00182 }
00183
00184
00185 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00186   Method:   COLicCruiseCar::QueryInterface
00187
00188   Summary:  QueryInterface of the COLicCruiseCar non-delegating
00189             IUnknown implementation.
00190
00191   Args:     REFIID riid,
00192               [in] GUID of the Interface being requested.
00193             PPVOID ppv)
00194               [out] Address of the caller's pointer variable that will
00195               receive the requested interface pointer.
00196
00197   Modifies: .
00198
00199   Returns:  HRESULT
00200 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00201 STDMETHODIMP COLicCruiseCar::QueryInterface(
00202                REFIID riid,
00203                PPVOID ppv)
00204 {
00205   HRESULT hr = E_NOINTERFACE;
00206   *ppv = NULL;
00207
00208   if (IID_IUnknown == riid)
00209   {
00210     *ppv = this;
00211     LOG("P: COLicCruiseCar::QueryInterface. 'this' pIUnknown returned.");
00212   }
00213   else if (IID_ICruise == riid)
00214   {
00215     // This ICruise interface is implemented in this COLicCruiseCar object
00216     // and might be called a native interface of COLicCruiseCar.
00217     *ppv = &m_ImpICruise;
00218     LOG("P: COLicCruiseCar::QueryInterface. pICruise returned.");
00219   }
00220
00221   if (NULL != *ppv)
00222   {
00223     // We've handed out a pointer to an interface so obey the COM rules
00224     //   and AddRef its reference count.
00225     ((LPUNKNOWN)*ppv)->AddRef();
00226     hr = NOERROR;
00227   }
00228   else if (IID_ICar == riid)
00229   {
00230     LOG("P: COLicCruiseCar::QueryInterface. ICar delegating.");
00231     // We didn't implement the ICar interface in this COLicCruiseCar object.
00232     // The aggregated inner COCar object is contributing the ICar interface
00233     // to this present composite or aggregating LicCruiseCar object. So, to
00234     // satisfy a QI request for the ICar interface, we delegate the
00235     // QueryInterface to the inner object's principal IUnknown.
00236     hr = m_pUnkCar->QueryInterface(riid, ppv);
00237   }
00238
00239   return (hr);
00240 }
00241
00242
00243 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00244   Method:   COLicCruiseCar::AddRef
00245
00246   Summary:  AddRef of the COLicCruiseCar non-delegating IUnknown
00247             implementation.
00248
00249   Args:     void
00250
00251   Modifies: m_cRefs.
00252
00253   Returns:  ULONG
00254               New value of m_cRefs (COM object's reference count).
00255 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00256 STDMETHODIMP_(ULONG) COLicCruiseCar::AddRef(void)
00257 {
00258   m_cRefs++;
00259
00260   LOGF1("P: COLicCruiseCar::AddRef. New cRefs=%i.", m_cRefs);
00261
00262   return m_cRefs;
00263 }
00264
00265
00266 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00267   Method:   COLicCruiseCar::Release
00268
00269   Summary:  Release of the COLicCruiseCar non-delegating IUnknown
00270             implementation.
00271
00272   Args:     void
00273
00274   Modifies: m_cRefs.
00275
00276   Returns:  ULONG
00277               New value of m_cRefs (COM object's reference count).
00278 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00279 STDMETHODIMP_(ULONG) COLicCruiseCar::Release(void)
00280 {
00281   ULONG ulCount = --m_cRefs;
00282
00283   LOGF1("P: COLicCruiseCar::Release. New cRefs=%i.", m_cRefs);
00284
00285   if (0 == m_cRefs)
00286   {
00287     // We've reached a zero reference count for this COM object.
00288     // So we tell the server housing to decrement its global object
00289     // count so that the server will be unloaded if appropriate.
00290     if (NULL != m_pServer)
00291       m_pServer->ObjectsDown();
00292
00293     // We artificially bump the main ref count.  This fulfills one of
00294     // the rules of aggregated objects and ensures that an indirect
00295     // recursive call to this release won't occur because of other
00296     // delegating releases that might happen in our own destructor.
00297     m_cRefs++;
00298     delete this;
00299   }
00300
00301   return ulCount;
00302 }
00303
00304
00305 /*---------------------------------------------------------------------------
00306   COLicCruiseCar's nested implementation of the ICruise interface including
00307   Constructor, Destructor, QueryInterface, AddRef, Release,
00308   Engage, and Adjust.
00309 ---------------------------------------------------------------------------*/
00310
00311 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00312   Method:   COLicCruiseCar::CImpICruise::CImpICruise
00313
00314   Summary:  Constructor for the CImpICruise interface instantiation.
00315
00316   Args:     COLicCruiseCar* pBackObj,
00317               Back pointer to the parent outer object.
00318             IUnknown* pUnkOuter)
00319               Pointer to the outer Unknown.  For delegation.
00320
00321   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00322
00323   Returns:  void
00324 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00325 COLicCruiseCar::CImpICruise::CImpICruise(
00326   COLicCruiseCar* pBackObj,
00327   IUnknown* pUnkOuter)
00328 {
00329   // Init the Interface Ref Count (used for debugging only).
00330   m_cRefI = 0;
00331
00332   // Init the Back Object Pointer to point to the outer object.
00333   m_pBackObj = pBackObj;
00334
00335   // Init the CImpICruise interface's delegating Unknown pointer.  We use
00336   // the Back Object pointer for IUnknown delegation here if we are not
00337   // being aggregated.  If we are being aggregated we use the supplied
00338   // pUnkOuter for IUnknown delegation.  In either case the pointer
00339   // assignment requires no AddRef because the CImpICruise lifetime is
00340   // quaranteed by the lifetime of the parent object in which
00341   // CImpICruise is nested.
00342   if (NULL == pUnkOuter)
00343   {
00344     m_pUnkOuter = pBackObj;
00345     LOG("P: COLicCruiseCar::CImpICruise Constructor. Non-Aggregating.");
00346   }
00347   else
00348   {
00349     m_pUnkOuter = pUnkOuter;
00350     LOG("P: COLicCruiseCar::CImpICruise Constructor. Aggregating.");
00351   }
00352
00353   return;
00354 }
00355
00356
00357 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00358   Method:   COLicCruiseCar::CImpICruise::~CImpICruise
00359
00360   Summary:  Destructor for the CImpICruise interface instantiation.
00361
00362   Args:     void
00363
00364   Modifies: .
00365
00366   Returns:  void
00367 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00368 COLicCruiseCar::CImpICruise::~CImpICruise(void)
00369 {
00370   LOG("P: COLicCruiseCar::CImpICruise Destructor.");
00371
00372   return;
00373 }
00374
00375
00376 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00377   Method:   COLicCruiseCar::CImpICruise::QueryInterface
00378
00379   Summary:  The QueryInterface IUnknown member of this ICruise interface
00380             implementation that delegates to m_pUnkOuter, whatever it is.
00381
00382   Args:     REFIID riid,
00383               [in] GUID of the Interface being requested.
00384             PPVOID ppv)
00385               [out] Address of the caller's pointer variable that will
00386               receive the requested interface pointer.
00387
00388   Modifies: .
00389
00390   Returns:  HRESULT
00391               Returned by the delegated outer QueryInterface call.
00392 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00393 STDMETHODIMP COLicCruiseCar::CImpICruise::QueryInterface(
00394                REFIID riid,
00395                PPVOID ppv)
00396 {
00397   LOG("P: COLicCruiseCar::CImpICruise::QueryInterface. Delegating.");
00398
00399   // Delegate this call to the outer object's QueryInterface.
00400   return m_pUnkOuter->QueryInterface(riid, ppv);
00401 }
00402
00403
00404 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00405   Method:   COLicCruiseCar::CImpICruise::AddRef
00406
00407   Summary:  The AddRef IUnknown member of this ICruise interface
00408             implementation that delegates to m_pUnkOuter, whatever it is.
00409
00410   Args:     void
00411
00412   Modifies: m_cRefI.
00413
00414   Returns:  ULONG
00415               Returned by the delegated outer AddRef call.
00416 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00417 STDMETHODIMP_(ULONG) COLicCruiseCar::CImpICruise::AddRef(void)
00418 {
00419   // Increment the Interface Reference Count.
00420   ++m_cRefI;
00421
00422   LOGF1("P: COLicCruiseCar::CImpICruise::Addref. Delegating. New cI=%i.", m_cRefI);
00423
00424   // Delegate this call to the outer object's AddRef.
00425   return m_pUnkOuter->AddRef();
00426 }
00427
00428
00429 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00430   Method:   COLicCruiseCar::CImpICruise::Release
00431
00432   Summary:  The Release IUnknown member of this ICruise interface
00433             implementation that delegates to m_pUnkOuter, whatever it is.
00434
00435   Args:     void
00436
00437   Modifies: .
00438
00439   Returns:  ULONG
00440               Returned by the delegated outer Release call.
00441 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00442 STDMETHODIMP_(ULONG) COLicCruiseCar::CImpICruise::Release(void)
00443 {
00444   // Decrement the Interface Reference Count.
00445   --m_cRefI;
00446
00447   LOGF1("P: COLicCruiseCar::CImpICruise::Release. Delegating. New cI=%i.",m_cRefI);
00448
00449   // Delegate this call to the outer object's Release.
00450   return m_pUnkOuter->Release();
00451 }
00452
00453
00454 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00455   Method:   COLicCruiseCar::CImpICruise::Engage
00456
00457   Summary:  The Engage member method of this ICruise interface
00458             implementation.  A simple empty method on a COLicCruiseCar COM
00459             object for tutorial purposes.  Presumably if this Car object
00460             were modeling a real Car then the Engage method would turn
00461             the Cruise control system on or off.
00462
00463   Args:     BOOL bOnOff)
00464               TRUE for On; FALSE for Off.
00465
00466   Modifies: .
00467
00468   Returns:  HRESULT
00469               NOERROR
00470 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00471 STDMETHODIMP COLicCruiseCar::CImpICruise::Engage(
00472                BOOL bOnOff)
00473 {
00474   LOGF1("P: COLicCruiseCar::CImpICruise::Engage. Called. bOnOff=%i.",bOnOff);
00475
00476   return NOERROR;
00477 }
00478
00479
00480 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00481   Method:   COLicCruiseCar::CImpICruise::Adjust
00482
00483   Summary:  The Adjust member method of this ICruise interface
00484             implementation.  A simple empty method on a COLicCruiseCar COM
00485             object for tutorial purposes.  Presumably if this Car object
00486             were modeling a real Car then the Adjust method would allow
00487             notching the cruise set speed up or down by increments of 3 mph.
00488
00489   Args:     BOOL bUpDown)
00490               TRUE for Up; FALSE for Down.
00491
00492   Modifies: .
00493
00494   Returns:  HRESULT
00495               NOERROR
00496 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00497 STDMETHODIMP COLicCruiseCar::CImpICruise::Adjust(
00498                BOOL bUpDown)
00499 {
00500   LOGF1("P: COLicCruiseCar::CImpICruise::Adjust. Called. bUpDown=%i.",bUpDown);
00501
00502   return NOERROR;
00503 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Pickle/Picklp/Picklp.Idl Source File

  • NetDS
  • RPC
  • Pickle
  • Picklp

Picklp.Idl

Go to the documentation of this file.
00001 [ uuid (B75AF600-9CF4-11CD-A076-08002B2BD711),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface proc_pickle
00006 {
00007
00008 const short ARR_SIZE =  4;
00009 const short BUFSIZE = 1024;
00010
00011 typedef struct _OBJECT1 {
00012     long    al[ARR_SIZE];
00013     short   s;
00014     } OBJECT1;
00015
00016 typedef struct _OBJECT2 {
00017     short                   sSize;
00018     [size_is(sSize)] short  as[];
00019     } OBJECT2;
00020
00021 void
00022 ProcPickle(
00023     [in,out, string] char * pTextId,
00024     [in,out]  OBJECT1 *     pObject1,
00025     [in,out]  OBJECT2 *     pObject2
00026     );
00027
00028 }
00029 
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_INTERFACEMAP Member List

This is the complete list of members for _INTERFACEMAP, including all inherited members.
pIID | _INTERFACEMAP
pwszInterface | _INTERFACEMAP
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/ias.h Source File

  • Com
  • Fundamentals
  • SimpDnd

ias.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IAS.H
00003 //
00004 //      Definition of CAdviseSink
00005 //
00006 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IAS_H_ )
00009 #define _IAS_H_
00010
00011 #include <assert.h>
00012
00013 class CSimpleSite;
00014
00015 interface CAdviseSink : public IAdviseSink
00016 {
00017   int m_nCount;
00018   CSimpleSite FAR * m_pSite;
00019
00020   CAdviseSink(CSimpleSite FAR * pSite) {
00021     OutputDebugString("In IAS's constructor\r\n");
00022     m_pSite = pSite;
00023     m_nCount = 0;
00024     };
00025
00026   ~CAdviseSink() {
00027     OutputDebugString("In IAS's destructor\r\n");
00028     assert(m_nCount == 0);
00029     } ;
00030
00031   STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
00032   STDMETHODIMP_(ULONG) AddRef ();
00033   STDMETHODIMP_(ULONG) Release ();
00034
00035   // *** IAdviseSink methods ***
00036   STDMETHODIMP_(void) OnDataChange (FORMATETC FAR* pFormatetc, STGMEDIUM FAR* pStgmed);
00037   STDMETHODIMP_(void) OnViewChange (DWORD dwAspect, LONG lindex);
00038   STDMETHODIMP_(void) OnRename (LPMONIKER pmk);
00039   STDMETHODIMP_(void) OnSave ();
00040   STDMETHODIMP_(void) OnClose ();
00041 };
00042
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/nmsession.cpp Source File

  • Web
  • NetMeeting
  • PlugTransport

nmsession.cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     PLUGTRANSPORT.EXE
00003 //  File:       NMSESSION.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #include "precomp.h"
00017
00018
00019 //***********************
00020 //FUNCTION DECLARATIONS
00021 //***********************
00022
00023 BSTR LPSTR2BSTR(LPSTR pszString);
00024 BOOL BSTR2LPSTR(BSTR bstrConnID, LPSTR pszConnID);
00025
00026
00027 //**********************************
00028 //
00029 // CLASS Conf
00030 //
00031 //**********************************
00032
00033 //****************************************************************************
00034 //
00035 //    FUNCTION:   Conf::Conf(HWND hWnd)
00036 //
00037 //    PURPOSE:    Construction
00038
00039 //    COMMENTS:
00040 //
00041 //
00042 //
00043 //****************************************************************************
00044
00045 Conf::Conf(HWND hWnd)
00046 {
00047     m_pMgrNotify    = NULL;
00048     m_pCallNotify   = NULL;
00049     m_pConfNotify   = NULL;
00050
00051     m_pINmMgr       = NULL;
00052     m_pINmConf      = NULL;
00053     m_pINmCall      = NULL;
00054     m_bInCall       = FALSE;
00055
00056     // Get the handler to the application window
00057     m_hWnd = hWnd;
00058 }
00059
00060
00061 //****************************************************************************
00062 //
00063 //    FUNCTION:   Conf::~Conf()
00064 //
00065 //    PURPOSE:    Destruction
00066
00067 //    COMMENTS:
00068 //
00069 //
00070 //
00071 //****************************************************************************
00072
00073 Conf::~Conf()
00074 {
00075     // Assert that everything has been tidied up - i.e. Uninitialize was called
00076     //
00077     ASSERT(m_pMgrNotify == NULL);
00078     ASSERT(m_pCallNotify == NULL);
00079     ASSERT(m_pConfNotify == NULL);
00080     ASSERT(m_pINmMgr == NULL);
00081     ASSERT(m_pINmConf == NULL);
00082     ASSERT(m_pINmCall == NULL);
00083
00084 }
00085
00086
00087 //****************************************************************************
00088 //
00089 //    FUNCTION:   HRESULT Conf::Initialize()
00090 //
00091 //    PURPOSE:    Initiate NetMeeting, obtain a pointer to INmManager,
00092 //                connect the MgrNotify sink object and initialize INmManager.
00093 //
00094 //    COMMENTS:
00095 //
00096 //
00097 //****************************************************************************
00098
00099 HRESULT Conf::Initialize()
00100 {
00101     HRESULT hr          = S_OK;
00102     ULONG   uOptions    = NM_INIT_CONTROL;                  // Don't display the NetMeeting UI
00103     ULONG   uCaps       = NMCH_DATA | NMCH_FT | NMCH_SHARE; // data only conference
00104
00105     // Create Sink Objects.
00106     // During construction, AddRef occurs
00107     m_pMgrNotify = new CMgrNotify(this);
00108     if (m_pMgrNotify == NULL)
00109     {
00110         return E_OUTOFMEMORY;
00111     }
00112
00113     m_pCallNotify = new CCallNotify(this);
00114     if (m_pCallNotify == NULL)
00115     {
00116         return E_OUTOFMEMORY;
00117     }
00118
00119     m_pConfNotify = new CConfNotify(this);
00120     if (m_pConfNotify == NULL)
00121     {
00122         return E_OUTOFMEMORY;
00123     }
00124
00125     hr = CoCreateInstance(CLSID_NmManager,NULL,CLSCTX_INPROC_SERVER,IID_INmManager,(VOID **)&m_pINmMgr);
00126     if (FAILED(hr))
00127     {
00128         return hr;
00129     }
00130
00131     hr = m_pMgrNotify->Connect(m_pINmMgr);
00132     if (FAILED(hr))
00133     {
00134         return hr;
00135     }
00136
00137     hr = m_pINmMgr->Initialize(&uOptions,&uCaps);
00138     if (FAILED(hr))
00139     {
00140         return hr;
00141     }
00142
00143     return hr;
00144 }
00145
00146
00147 //****************************************************************************
00148 //
00149 //    FUNCTION:   HRESULT Conf::Uninitialize()
00150 //
00151 //    PURPOSE:    Disconnect MgrNotify sink object and release the interface INmManager
00152 //
00153 //    COMMENTS:
00154 //
00155 //
00156 //
00157 //
00158 //
00159 //****************************************************************************
00160
00161 HRESULT Conf::Uninitialize()
00162 {
00163     if (NULL != m_pMgrNotify)
00164         m_pMgrNotify->Disconnect();
00165
00166     if (NULL != m_pINmMgr)
00167     {
00168         m_pINmMgr->Release();
00169         m_pINmMgr = NULL;
00170     }
00171
00172     if (m_pMgrNotify != NULL)
00173     {
00174         m_pMgrNotify->Release();
00175         m_pMgrNotify = NULL;
00176     }
00177
00178     if (m_pCallNotify != NULL)
00179     {
00180         m_pCallNotify->Release();
00181         m_pCallNotify = NULL;
00182     }
00183
00184     if (m_pConfNotify != NULL)
00185     {
00186         m_pConfNotify->Release();
00187         m_pConfNotify = NULL;
00188     }
00189
00190     return S_OK;
00191 }
00192
00193
00194 //****************************************************************************
00195 //
00196 //    FUNCTION:   HRESULT Conf::Call(CPluggableTransport *pPlugTrans)
00197 //
00198 //    PURPOSE:    Make the call using the already created transport connection
00199 //
00200 //    COMMENTS:
00201 //
00202 //
00203 //****************************************************************************
00204
00205 HRESULT Conf::Call(CPluggableTransport *pPlugTrans)
00206 {
00207     HRESULT hr          = S_OK;
00208     BSTR    bstrName    = NULL;
00209
00210     if (NULL == pPlugTrans)
00211         return E_FAIL;
00212
00213     if (NULL == m_pINmMgr)
00214         return E_FAIL;
00215
00216     if (FALSE == pPlugTrans->InConnection())
00217         return E_FAIL;
00218
00219     // get the BSTR form of the connection ID
00220     bstrName = LPSTR2BSTR(pPlugTrans->GetConnectionID());
00221     if (NULL == bstrName)
00222         return E_OUTOFMEMORY;
00223
00224     // make the call
00225     hr = m_pINmMgr->CreateCall(&m_pINmCall, NM_CALL_DEFAULT, NM_ADDR_T120_TRANSPORT, bstrName, NULL);
00226     if (FAILED(hr))
00227     {
00228         // Call object sometimes needs to be released.
00229         if (NULL != m_pINmCall)
00230         {
00231             m_pCallNotify->Disconnect();
00232             m_pINmCall->Release();
00233             m_pINmCall = NULL;
00234         }
00235     }
00236
00237     SysFreeString(bstrName);
00238     return S_OK;
00239 }
00240
00241
00242 //****************************************************************************
00243 //
00244 //    FUNCTION:   HRESULT Conf::HangUp()
00245 //
00246 //    PURPOSE:   Leave the conference
00247
00248 //    COMMENTS:
00249 //
00250 //
00251 //****************************************************************************
00252
00253 HRESULT Conf::HangUp()
00254 {
00255     HRESULT hr = S_OK;
00256
00257     // if call hungup before Call accepted or rejected, release INmCall and
00258     // disconnect CallNotify sink
00259     if (NULL != m_pINmCall)
00260     {
00261         hr = m_pINmCall->Cancel();
00262         if (FAILED(hr))
00263         {
00264             MessageBox(NULL,TEXT("m_pINmCall->Cancel failed."),TEXT("Error"),MB_OK);
00265         }
00266
00267         if (NULL != m_pCallNotify)
00268         {
00269             hr = m_pCallNotify->Disconnect();
00270             if (FAILED(hr))
00271             {
00272                 MessageBox(NULL,TEXT("m_pCallNotify->Disconnect failed."),TEXT("Error"),MB_OK);
00273             }
00274         }
00275
00276         m_pINmCall->Release();
00277         m_pINmCall=NULL;
00278     }
00279     else
00280     {
00281         if (NULL != m_pINmConf)
00282         {
00283             hr = m_pINmConf->Leave();
00284             if (FAILED(hr))
00285             {
00286                 MessageBox(NULL,TEXT("m_pINmConf->Leave failed."),TEXT("Error"),MB_OK);
00287             }
00288         }
00289     }
00290
00291
00292     // Release INmConf and disconnect the ConfNotify sink
00293     if (NULL != m_pINmConf)
00294     {
00295         if (NULL != m_pConfNotify)
00296         {
00297             hr = m_pConfNotify->Disconnect();
00298             if (FAILED(hr))
00299             {
00300                 MessageBox(NULL,TEXT("m_pConfNotify->Disconnect failed."),TEXT("Error"),MB_OK);
00301             }
00302         }
00303
00304         m_pINmConf->Release();
00305         m_pINmConf=NULL;
00306     }
00307
00308     m_bInCall = false;
00309
00310     // update the UI
00311     if (m_hWnd)
00312     {
00313         SendMessage(m_hWnd,WM_DISCONNECTED,0,0);
00314     }
00315
00316     return hr;
00317 }
00318
00319
00320 //****************************************************************************
00321 //
00322 //    FUNCTION:   HRESULT Conf::CallCreated(INmCall * pCall)
00323 //
00324 //    PURPOSE:    Callback from the MgrNotify sink object
00325
00326 //    COMMENTS:
00327 //
00328 //
00329 //****************************************************************************
00330
00331 HRESULT Conf::CallCreated(INmCall * pCall)
00332 {
00333     HRESULT hr  = S_OK;
00334
00335     if (NULL == pCall)
00336     {
00337         return E_POINTER;
00338     }
00339
00340     ASSERT(m_pINmCall == NULL);
00341     if (m_pINmCall != NULL)
00342     {
00343         MessageBox(NULL,TEXT("m_pINmCall is not NULL, and we have a new call!"),TEXT("Error"),MB_OK);
00344         m_pINmCall->Release();
00345     }
00346
00347     m_pINmCall = pCall;
00348     m_pINmCall->AddRef();
00349
00350     if (NULL != m_pCallNotify)
00351     {
00352         hr = m_pCallNotify->Connect(pCall);
00353         if (FAILED(hr))
00354         {
00355             MessageBox(NULL,TEXT("m_pCallNotify->Connect failed."),TEXT("Error"),MB_OK);
00356             return hr;
00357         }
00358     }
00359
00360     m_bInCall = true;
00361
00362     // update the UI
00363     if (m_hWnd)
00364         SendMessage(m_hWnd,WM_CONNECTING,0,0);
00365
00366     return S_OK;
00367 }
00368
00369
00370 //****************************************************************************
00371 //
00372 //    FUNCTION:   HRESULT Conf::AcceptCall()
00373 //
00374 //    PURPOSE:    Accept the incoming call
00375
00376 //    COMMENTS:
00377 //
00378 //
00379 //****************************************************************************
00380
00381 HRESULT Conf::AcceptCall()
00382 {
00383     if (m_pINmCall == NULL)
00384     {
00385         return HRESULT_FROM_WIN32(ERROR_NOT_READY);
00386     }
00387
00388     return m_pINmCall->Accept();
00389 }
00390
00391
00392 //****************************************************************************
00393 //
00394 //    FUNCTION:   HRESULT Conf::RejectCall()
00395 //
00396 //    PURPOSE:    Reject the incoming call
00397
00398 //    COMMENTS:
00399 //
00400 //
00401 //****************************************************************************
00402
00403 HRESULT Conf::RejectCall()
00404 {
00405     if (m_pINmCall == NULL)
00406     {
00407         return HRESULT_FROM_WIN32(ERROR_NOT_READY);
00408     }
00409
00410     return m_pINmCall->Reject();
00411 }
00412
00413
00414 //****************************************************************************
00415 //
00416 //    FUNCTION:   HRESULT Conf::ConferenceCreated(INmConference *pINmConf)
00417 //
00418 //    PURPOSE:    Callback from the MgrNotify sink object that
00419 //                a new conference has been created
00420 //
00421 //    COMMENTS:
00422 //
00423 //
00424 //****************************************************************************
00425
00426 HRESULT Conf::ConferenceCreated(INmConference *pINmConf)
00427 {
00428     HRESULT hr = S_OK;
00429
00430     if (pINmConf == NULL)
00431     {
00432         return E_POINTER;
00433     }
00434
00435     ASSERT(m_pINmConf == NULL);
00436     if (m_pINmConf != NULL)
00437     {
00438         MessageBox(NULL,TEXT("m_pINmConf is not NULL, and we have a new conf!"),TEXT("Error"),MB_OK);
00439         m_pINmConf->Release();
00440     }
00441
00442     //Add Conference notification sink to handle channels.
00443     m_pINmConf = pINmConf;
00444     m_pINmConf->AddRef();
00445
00446     if (m_pConfNotify != NULL)
00447     {
00448         hr = m_pConfNotify->Connect(pINmConf);
00449         if (FAILED(hr))
00450         {
00451             MessageBox(NULL,TEXT("m_pConfNotify->Connect failed."),TEXT("Error"),MB_OK);
00452             return hr;
00453         }
00454     }
00455
00456     m_bInCall = true;
00457
00458     if (m_hWnd)
00459     {
00460         SendMessage(m_hWnd,WM_CONNECTED,0,0);
00461     }
00462
00463     return S_OK;
00464 }
00465
00466
00467 //****************************************************************************
00468 //
00469 //    FUNCTION:   HRESULT Conf::CallAccepted()
00470 //
00471 //    PURPOSE:    Callback from the CallNotify sink object that
00472 //                the new call has been accepted
00473
00474 //    COMMENTS:
00475 //
00476 //
00477 //****************************************************************************
00478
00479 HRESULT Conf::CallAccepted()
00480 {
00481     HRESULT hr = S_OK;
00482
00483     // Release INmCall, and let send window message that a user has connected
00484     if (NULL != m_pINmCall)
00485     {
00486         m_pINmCall->Release();
00487         m_pINmCall=NULL;
00488     }
00489
00490     if (m_pCallNotify != NULL)
00491     {
00492         hr = m_pCallNotify->Disconnect();
00493         if (FAILED(hr))
00494         {
00495             MessageBox(NULL,TEXT("m_pCallNotify->Disconnect failed."),TEXT("Error"),MB_OK);
00496         }
00497     }
00498
00499     m_bInCall = true;
00500
00501     return S_OK;
00502 }
00503
00504
00505 //****************************************************************************
00506 //
00507 //    FUNCTION:   HRESULT Conf::CallRejected()
00508 //
00509 //    PURPOSE:    Callback from the CallNotify sink object that
00510 //                the new call has been rejected
00511
00512 //    COMMENTS:
00513 //
00514 //
00515 //****************************************************************************
00516
00517 HRESULT Conf::CallRejected()
00518 {
00519     HRESULT hr = S_OK;
00520     // Release INmCall, INmConf, disconnect CallNotify and ConfNotify
00521     // sink objects, and send message to main window that the user has
00522     // disconnected.
00523     if (NULL != m_pINmCall)
00524     {
00525         if (NULL != m_pCallNotify)
00526         {
00527             hr = m_pCallNotify->Disconnect();
00528             if (FAILED(hr))
00529             {
00530                 MessageBox(NULL,TEXT("m_pCallNotify->Disconnect failed."),TEXT("Error"),MB_OK);
00531             }
00532         }
00533
00534         m_pINmCall->Release();
00535         m_pINmCall=NULL;
00536     }
00537
00538     if (NULL != m_pINmConf)
00539     {
00540         m_pINmConf->Release();
00541         m_pINmConf=NULL;
00542     }
00543
00544     if (NULL != m_pConfNotify)
00545     {
00546         hr = m_pConfNotify->Disconnect();
00547         if (FAILED(hr))
00548         {
00549             MessageBox(NULL,TEXT("m_pConfNotify->Disconnect failed."),TEXT("Error"),MB_OK);
00550         }
00551     }
00552
00553     m_bInCall = false;
00554
00555     if (m_hWnd)
00556         SendMessage(m_hWnd,WM_DISCONNECTED,0,0);
00557
00558     return S_OK;
00559 }
00560
00561
00562 //****************************************************************************
00563 //
00564 //    FUNCTION:   HRESULT Conf::RemoteHungup()
00565 //
00566 //    PURPOSE:    Callback from the ConfNotify sink object
00567 //                that a member has left the conference
00568
00569 //    COMMENTS:
00570 //
00571 //
00572 //
00573 //****************************************************************************
00574
00575 HRESULT Conf::RemoteHungup()
00576 {
00577     HRESULT hr = S_OK;
00578
00579     // Release INmConf, disconnect ConfNotify sink object, and send message to
00580     // main window that the remote node has disconnected.
00581     if (NULL != m_pINmConf)
00582     {
00583         m_pINmConf->Release();
00584         m_pINmConf = NULL;
00585     }
00586
00587     if (NULL != m_pConfNotify)
00588     {
00589         hr = m_pConfNotify->Disconnect();
00590         if (FAILED(hr))
00591         {
00592             MessageBox(NULL,TEXT("m_pConfNotify->Disconnect failed."),TEXT("Error"),MB_OK);
00593         }
00594     }
00595
00596     m_bInCall = false;
00597
00598     if (m_hWnd)
00599     {
00600         SendMessage(m_hWnd,WM_DISCONNECTED,0,0);
00601     }
00602
00603     return S_OK;
00604 }
00605
00606
00607 //****************************************************************************
00608 //
00609 //    FUNCTION:   BOOL Conf::InCall()
00610 //
00611 //    PURPOSE:
00612 //
00613 //    COMMENTS:
00614 //
00615 //
00616 //****************************************************************************
00617
00618 BOOL Conf::InCall()
00619 {
00620     return m_bInCall;
00621 }
00622
00623
00624 //****************************************************************************
00625 //
00626 //    FUNCTION:   INmManager * Conf::GetNmManager()
00627 //
00628 //    PURPOSE:
00629 //
00630 //    COMMENTS:
00631 //
00632 //
00633 //
00634 //****************************************************************************
00635
00636 INmManager * Conf::GetNmManager()
00637 {
00638     return m_pINmMgr;
00639 }
00640
00641
00642
00643 //****************************************************************************
00644 //
00645 // CLASS CCallNotify
00646 //
00647 //****************************************************************************
00648
00649 //****************************************************************************
00650 //
00651 //    FUNCTION:   CCallNotify::CCallNotify()
00652 //
00653 //    PURPOSE:    Construction
00654
00655 //    COMMENTS:
00656 //
00657 //****************************************************************************
00658
00659 CCallNotify::CCallNotify()
00660 {
00661     m_pConf = NULL;
00662 }
00663
00664
00665 //****************************************************************************
00666 //
00667 //    FUNCTION:   CCallNotify::CCallNotify(Conf *pConf)
00668 //
00669 //    PURPOSE:    Construction
00670
00671 //    COMMENTS:
00672 //
00673 //****************************************************************************
00674
00675 CCallNotify::CCallNotify(Conf *pConf)
00676 {
00677     m_pConf = pConf;
00678 }
00679
00680 //****************************************************************************
00681 //
00682 //    FUNCTION:   CCallNotify::~CCallNotify()
00683 //
00684 //    PURPOSE:    Destruction
00685
00686 //    COMMENTS:
00687 //
00688 //
00689 //****************************************************************************
00690
00691 CCallNotify::~CCallNotify()
00692 {}
00693
00694
00695 //****************************************************************************
00696 //
00697 //    FUNCTION:   ULONG STDMETHODCALLTYPE CCallNotify::AddRef()
00698 //
00699 //    PURPOSE:    method from IUnknown
00700 //
00701 //    COMMENTS:
00702 //
00703 //
00704 //****************************************************************************
00705
00706 ULONG STDMETHODCALLTYPE CCallNotify::AddRef()
00707 {
00708     return RefCount::AddRef();
00709 }
00710
00711
00712 //****************************************************************************
00713 //
00714 //    FUNCTION:   ULONG STDMETHODCALLTYPE CCallNotify::Release()
00715 //
00716 //    PURPOSE:    Method from IUnknown
00717 //
00718 //    COMMENTS:
00719 //
00720 //
00721 //****************************************************************************
00722
00723 ULONG STDMETHODCALLTYPE CCallNotify::Release()
00724 {
00725     return RefCount::Release();
00726 }
00727
00728
00729 //****************************************************************************
00730 //
00731 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CCallNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
00732 //
00733 //    PURPOSE:    Method from IUnknown
00734
00735 //    COMMENTS:
00736 //
00737 //
00738 //****************************************************************************
00739
00740 HRESULT STDMETHODCALLTYPE CCallNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
00741 {
00742     if (ppvObject == NULL)
00743     {
00744         return E_POINTER;
00745     }
00746
00747     *ppvObject = NULL;
00748
00749     if (riid == IID_IUnknown)
00750         *ppvObject = (PVOID *)this;
00751     else if (riid == IID_INmCallNotify)
00752         *ppvObject = (PVOID *)this;
00753     else
00754         return E_NOINTERFACE;
00755
00756     AddRef();
00757     return S_OK;
00758 }
00759
00760 //****************************************************************************
00761 //
00762 //    FUNCTION:   HRESULT CCallNotify::Connect(IUnknown * pUnkOuter)
00763 //
00764 //    PURPOSE:    Sink connect method
00765 //
00766 //    COMMENTS:
00767 //
00768 //
00769 //****************************************************************************
00770
00771 HRESULT CCallNotify::Connect(IUnknown * pUnkOuter)
00772 {
00773     return CNotify::Connect(pUnkOuter, IID_INmCallNotify, (IUnknown *)this);
00774 }
00775
00776
00777 //****************************************************************************
00778 //
00779 //    FUNCTION:   HRESULT CCallNotify::Disconnect()
00780 //
00781 //    PURPOSE:    Sink disconnect method
00782 //
00783 //    COMMENTS:
00784 //
00785 //
00786 //****************************************************************************
00787
00788 HRESULT CCallNotify::Disconnect()
00789 {
00790     return CNotify::Disconnect();
00791 }
00792
00793
00794 //****************************************************************************
00795 //
00796 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CCallNotify::Failed(ULONG uError)
00797 //
00798 //    PURPOSE:    Sink notification method
00799
00800 //    COMMENTS:
00801 //
00802 //
00803 //
00804 //****************************************************************************
00805
00806 HRESULT STDMETHODCALLTYPE CCallNotify::Failed(ULONG uError)
00807 {
00808     return S_OK;
00809 }
00810
00811
00812 //****************************************************************************
00813 //
00814 //    FUNCTION:  HRESULT STDMETHODCALLTYPE CCallNotify::Accepted(INmConference *pConference)
00815 //
00816 //    PURPOSE:   Sink notification method
00817 //
00818 //    COMMENTS:
00819 //
00820 //
00821 //****************************************************************************
00822
00823 HRESULT STDMETHODCALLTYPE CCallNotify::Accepted(INmConference *pConference)
00824 {
00825     return S_OK;
00826 }
00827
00828 //****************************************************************************
00829 //
00830 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CCallNotify::NmUI(CONFN uNotify)
00831 //
00832 //    PURPOSE:    Sink notification method
00833
00834 //    COMMENTS:
00835 //
00836 //****************************************************************************
00837
00838 HRESULT STDMETHODCALLTYPE CCallNotify::NmUI(CONFN uNotify)
00839 {
00840     return S_OK;
00841 }
00842
00843
00844 //****************************************************************************
00845 //
00846 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CCallNotify::StateChanged(NM_CALL_STATE uState)
00847 //
00848 //    PURPOSE:    Sink notification method
00849
00850 //    COMMENTS:
00851 //
00852 //
00853 //****************************************************************************
00854
00855 HRESULT STDMETHODCALLTYPE CCallNotify::StateChanged(NM_CALL_STATE uState)
00856 {
00857     HRESULT hr = S_OK;
00858
00859     if (NULL == m_pConf)
00860     {
00861         return E_FAIL;
00862     }
00863
00864     switch (uState)
00865     {
00866     case NM_CALL_RING:
00867
00868         // Query whether to accept the call and notify my Conf object the result.
00869         if (MessageBox(NULL,TEXT("Accept incoming call?"),TEXT("Call"),MB_YESNO|MB_TASKMODAL)== IDYES)
00870         {
00871             hr = m_pConf->AcceptCall();
00872             if (FAILED(hr))
00873             {
00874                 MessageBox(NULL,TEXT("m_pConf->AcceptCall failed."),TEXT("Error"),MB_OK);
00875             }
00876         }
00877
00878         else
00879         {
00880             hr = m_pConf->RejectCall();
00881             if (FAILED(hr))
00882             {
00883                 MessageBox(NULL,TEXT("m_pConf->RejectCall failed."),TEXT("Error"),MB_OK);
00884             }
00885         }
00886         break;
00887
00888     case NM_CALL_REJECTED:
00889
00890         // Notify my Conf object that the call was rejected.
00891         hr = m_pConf->CallRejected();
00892         if (FAILED(hr))
00893         {
00894             MessageBox(NULL,TEXT("m_pConf->CallRejected failed."),TEXT("Error"),MB_OK);
00895         }
00896
00897         break;
00898
00899     case NM_CALL_ACCEPTED:
00900
00901         // Notify my Conf object that the call was accepted
00902         hr = m_pConf->CallAccepted();
00903         if (FAILED(hr))
00904         {
00905             MessageBox(NULL,TEXT("m_pConf->CallAccepted failed."),TEXT("Error"),MB_OK);
00906         }
00907         break;
00908     }
00909     return S_OK;
00910 }
00911
00912
00913
00914 //****************************************************************************
00915 //
00916 // CLASS CConfNotify
00917 //
00918 //****************************************************************************
00919
00920 //****************************************************************************
00921 //
00922 //    FUNCTION:   CConfNotify::CConfNotify()
00923 //
00924 //    PURPOSE:    Construction
00925 //
00926 //    COMMENTS:
00927 //
00928 //
00929 //****************************************************************************
00930
00931 CConfNotify::CConfNotify()
00932 {
00933     m_pConf = NULL;
00934 }
00935
00936
00937 //****************************************************************************
00938 //
00939 //    FUNCTION:   CConfNotify::CConfNotify(Conf *pConf)
00940 //
00941 //    PURPOSE:    Construction
00942
00943 //    COMMENTS:
00944 //
00945 //
00946 //****************************************************************************
00947
00948 CConfNotify::CConfNotify(Conf *pConf)
00949 {
00950     m_pConf = pConf;
00951 }
00952
00953
00954 //****************************************************************************
00955 //
00956 //    FUNCTION:   CConfNotify::~CConfNotify()
00957 //
00958 //    PURPOSE:    Destruction
00959
00960 //    COMMENTS:
00961 //
00962 //
00963 //
00964 //
00965 //
00966 //****************************************************************************
00967
00968 CConfNotify::~CConfNotify()
00969 {}
00970
00971
00972 //****************************************************************************
00973 //
00974 //    FUNCTION:   ULONG STDMETHODCALLTYPE CConfNotify::AddRef()
00975 //
00976 //    PURPOSE:    Method from IUnknown
00977
00978 //    COMMENTS:
00979 //
00980 //****************************************************************************
00981
00982 ULONG STDMETHODCALLTYPE CConfNotify::AddRef()
00983 {
00984     return RefCount::AddRef();
00985 }
00986
00987
00988 //****************************************************************************
00989 //
00990 //    FUNCTION:   ULONG STDMETHODCALLTYPE CConfNotify::Release()
00991 //
00992 //    PURPOSE:    Method from IUnknown
00993
00994 //    COMMENTS:
00995 //
00996 //****************************************************************************
00997
00998 ULONG STDMETHODCALLTYPE CConfNotify::Release()
00999 {
01000     return RefCount::Release();
01001 }
01002
01003
01004 //****************************************************************************
01005 //
01006 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CConfNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
01007 //
01008 //    PURPOSE:    Method from IUnknown
01009
01010 //    COMMENTS:
01011 //
01012 //
01013 //****************************************************************************
01014
01015 HRESULT STDMETHODCALLTYPE CConfNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
01016 {
01017     if (ppvObject == NULL)
01018     {
01019         return E_POINTER;
01020     }
01021
01022     *ppvObject = NULL;
01023
01024     if (riid == IID_IUnknown)
01025         *ppvObject = (PVOID *)this;
01026     else if (riid == IID_INmConferenceNotify)
01027         *ppvObject = (PVOID *)this;
01028     else
01029         return E_NOINTERFACE;
01030
01031     AddRef();
01032
01033     return S_OK;
01034 }
01035
01036
01037 //****************************************************************************
01038 //
01039 //    FUNCTION:   HRESULT CConfNotify::Connect(IUnknown * pUnkOuter)
01040 //
01041 //    PURPOSE:    Sink connect method
01042
01043 //    COMMENTS:
01044 //
01045 //****************************************************************************
01046
01047 HRESULT CConfNotify::Connect(IUnknown * pUnkOuter)
01048 {
01049     return CNotify::Connect(pUnkOuter, IID_INmConferenceNotify, (IUnknown *)this);
01050 }
01051
01052
01053 //****************************************************************************
01054 //
01055 //    FUNCTION:   HRESULT CConfNotify::Disconnect()
01056 //
01057 //    PURPOSE:    Sink disconnect method
01058
01059 //    COMMENTS:
01060 //
01061 //
01062 //****************************************************************************
01063
01064 HRESULT CConfNotify::Disconnect()
01065 {
01066     return CNotify::Disconnect();
01067 }
01068
01069
01070 //****************************************************************************
01071 //
01072 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CConfNotify::ChannelChanged(NM_CHANNEL_NOTIFY uNotify, INmChannel * pChannel)
01073 //
01074 //    PURPOSE:    Sink notification method
01075 //
01076 //    COMMENTS:
01077 //
01078 //
01079 //****************************************************************************
01080
01081 HRESULT STDMETHODCALLTYPE CConfNotify::ChannelChanged(NM_CHANNEL_NOTIFY uNotify, INmChannel * pChannel)
01082 {
01083     HRESULT hr  = S_OK;
01084     ULONG   uCh = 0;
01085
01086     if (pChannel == NULL)
01087     {
01088         return E_POINTER;
01089     }
01090
01091     // When notified that a channel has been added add code to handle it.
01092     // We don't need the code below for this app. I keep it to make it easier
01093     // if somebody needs to handle a channel
01094     if (uNotify == NM_CHANNEL_ADDED)
01095     {
01096         hr = pChannel->GetNmch(&uCh);
01097         if (FAILED(hr))
01098         {
01099             MessageBox(NULL,TEXT("pChannel->GetNmch failed."),TEXT("Error"),MB_OK);
01100         }
01101     }
01102
01103     return S_OK;
01104 }
01105
01106
01107 //****************************************************************************
01108 //
01109 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CConfNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember * pMember)
01110 //
01111 //    PURPOSE:    Sink notification method
01112 //
01113 //    COMMENTS:
01114 //
01115 //
01116 //****************************************************************************
01117
01118 HRESULT STDMETHODCALLTYPE CConfNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember * pMember)
01119 {
01120     return S_OK;
01121 }
01122
01123
01124 //****************************************************************************
01125 //
01126 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CConfNotify::NmUI(CONFN uNotify)
01127 //
01128 //    PURPOSE:    Sink notification method
01129
01130 //    COMMENTS:
01131 //
01132 //
01133 //****************************************************************************
01134
01135 HRESULT STDMETHODCALLTYPE CConfNotify::NmUI(CONFN uNotify)
01136 {
01137     return S_OK;
01138 }
01139
01140
01141 //****************************************************************************
01142 //
01143 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CConfNotify::StateChanged(NM_CONFERENCE_STATE uState)
01144 //
01145 //    PURPOSE:    Sink notification method
01146 //
01147 //    COMMENTS:
01148 //
01149 //
01150 //****************************************************************************
01151
01152 HRESULT STDMETHODCALLTYPE CConfNotify::StateChanged(NM_CONFERENCE_STATE uState)
01153 {
01154     HRESULT hr = S_OK;
01155
01156     // Notify my Conf object that the remote hungup.
01157     if ((uState == NM_CONFERENCE_IDLE) && (m_pConf != NULL))
01158     {
01159         hr = m_pConf->RemoteHungup();
01160         if (FAILED(hr))
01161         {
01162             MessageBox(NULL,TEXT("m_pConf->RemoteHungup failed."),TEXT("Error"),MB_OK);
01163         }
01164     }
01165
01166     return S_OK;
01167 }
01168
01169
01170
01171 //****************************************************************************
01172 //
01173 // CLASS CMgrNotify
01174 //
01175 //****************************************************************************
01176
01177 //****************************************************************************
01178 //
01179 //    FUNCTION:   CMgrNotify::CMgrNotify()
01180 //
01181 //    PURPOSE:    Construction
01182
01183 //    COMMENTS:
01184 //
01185 //
01186 //****************************************************************************
01187
01188 CMgrNotify::CMgrNotify()
01189 {
01190     m_pConf = NULL;
01191 }
01192
01193
01194 //****************************************************************************
01195 //
01196 //    FUNCTION:   CMgrNotify::CMgrNotify(Conf * pConf)
01197 //
01198 //    PURPOSE:    Construction
01199
01200 //    COMMENTS:
01201 //
01202 //
01203 //****************************************************************************
01204
01205 CMgrNotify::CMgrNotify(Conf * pConf)
01206 {
01207     m_pConf = pConf;
01208 }
01209
01210
01211 //****************************************************************************
01212 //
01213 //    FUNCTION:   CMgrNotify::~CMgrNotify()
01214 //
01215 //    PURPOSE:    Destruction
01216
01217 //    COMMENTS:
01218 //
01219 //
01220 //****************************************************************************
01221
01222 CMgrNotify::~CMgrNotify()
01223 {}
01224
01225
01226 //****************************************************************************
01227 //
01228 //    FUNCTION:   ULONG STDMETHODCALLTYPE CMgrNotify::AddRef()
01229 //
01230 //    PURPOSE:    Method from IUnknown
01231
01232 //    COMMENTS:
01233 //
01234 //
01235 //****************************************************************************
01236
01237 ULONG STDMETHODCALLTYPE CMgrNotify::AddRef()
01238 {
01239     return RefCount::AddRef();
01240 }
01241
01242
01243 //****************************************************************************
01244 //
01245 //    FUNCTION:   ULONG STDMETHODCALLTYPE CMgrNotify::Release()
01246 //
01247 //    PURPOSE:    Method from IUnknown
01248
01249 //    COMMENTS:
01250 //
01251 //
01252 //****************************************************************************
01253
01254 ULONG STDMETHODCALLTYPE CMgrNotify::Release()
01255 {
01256     return RefCount::Release();
01257 }
01258
01259
01260 //****************************************************************************
01261 //
01262 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CMgrNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
01263 //
01264 //    PURPOSE:    Method from IUnknown
01265
01266 //    COMMENTS:
01267 //
01268 //
01269 //****************************************************************************
01270
01271 HRESULT STDMETHODCALLTYPE CMgrNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
01272 {
01273     if (ppvObject == NULL)
01274     {
01275         return E_POINTER;
01276     }
01277
01278     *ppvObject = NULL;
01279
01280     if (riid == IID_IUnknown)
01281         *ppvObject = (PVOID *)this;
01282     else if (riid == IID_INmManagerNotify)
01283         *ppvObject = (PVOID *)this;
01284     else
01285         return E_NOINTERFACE;
01286
01287     AddRef();
01288     return S_OK;
01289 }
01290
01291
01292 //****************************************************************************
01293 //
01294 //    FUNCTION:   HRESULT CMgrNotify::Connect(IUnknown * pUnkOuter)
01295 //
01296 //    PURPOSE:    Sink connect method
01297
01298 //    COMMENTS:
01299 //
01300 //
01301 //****************************************************************************
01302
01303 HRESULT CMgrNotify::Connect(IUnknown * pUnkOuter)
01304 {
01305     return CNotify::Connect(pUnkOuter, IID_INmManagerNotify, (IUnknown *)this);
01306 }
01307
01308
01309 //****************************************************************************
01310 //
01311 //    FUNCTION:   HRESULT CMgrNotify::Disconnect()
01312 //
01313 //    PURPOSE:    Sink disconnect method
01314
01315 //    COMMENTS:
01316 //
01317 //
01318 //****************************************************************************
01319
01320 HRESULT CMgrNotify::Disconnect()
01321 {
01322     return CNotify::Disconnect();
01323 }
01324
01325
01326 //****************************************************************************
01327 //
01328 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CMgrNotify::CallCreated(INmCall * pCall)
01329 //
01330 //    PURPOSE:    Sink notification method
01331
01332 //    COMMENTS:
01333 //
01334 //
01335 //****************************************************************************
01336
01337 HRESULT STDMETHODCALLTYPE CMgrNotify::CallCreated(INmCall * pCall)
01338 {
01339     HRESULT hr = S_OK;
01340     // Notify my Conf object that a Call object was created
01341     if (m_pConf != NULL)
01342     {
01343         hr = m_pConf->CallCreated(pCall);
01344         if (FAILED(hr))
01345         {
01346             MessageBox(NULL,TEXT("m_pConf->CallCreated failed."),TEXT("Error"),MB_OK);
01347         }
01348     }
01349
01350     return S_OK;
01351 }
01352
01353
01354 //****************************************************************************
01355 //
01356 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CMgrNotify::ConferenceCreated(INmConference * pConference)
01357 //
01358 //    PURPOSE:    Sink notification method
01359
01360 //    COMMENTS:
01361 //
01362 //
01363 //****************************************************************************
01364
01365 HRESULT STDMETHODCALLTYPE CMgrNotify::ConferenceCreated(INmConference * pConference)
01366 {
01367     HRESULT hr = S_OK;
01368     // Notify my Conf object that a Conference object was created
01369     if (m_pConf != NULL)
01370     {
01371         hr = m_pConf->ConferenceCreated(pConference);
01372         if (FAILED(hr))
01373         {
01374             MessageBox(NULL,TEXT("m_pConf->ConferenceCreated failed."),TEXT("Error"),MB_OK);
01375         }
01376     }
01377
01378     return S_OK;
01379 }
01380
01381
01382 //****************************************************************************
01383 //
01384 //    FUNCTION:   HRESULT STDMETHODCALLTYPE CMgrNotify::NmUI(CONFN uNotify)
01385 //
01386 //    PURPOSE:    Sink notification method
01387
01388 //    COMMENTS:
01389 //
01390 //
01391 //****************************************************************************
01392
01393 HRESULT STDMETHODCALLTYPE CMgrNotify::NmUI(CONFN uNotify)
01394 {
01395     return S_OK;
01396 }
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/ConnectionManager/cmsample.cpp Source File

  • NetDS
  • Ras
  • ConnectionManager

cmsample.cpp

Go to the documentation of this file.
00001 //+----------------------------------------------------------------------------
00002 //
00003 // File:     cmsample.cpp
00004 //
00005 // Module:   CMSAMPLE.DLL
00006 //
00007 // Synopsis: Main source for changing proxy file setting using a Tunnel Address
00008 //           with Connection Manager
00009 //
00010 // Copyright (c) 2001 - 2002 Microsoft Corporation. All rights reserved.
00011 //
00012 //+----------------------------------------------------------------------------
00013 #include <windows.h>
00014
00015 // Function prototypes
00016
00017 // Main Entry point
00018 HRESULT WINAPI SetProxyUsingTunnelAddress(HWND hWnd, HINSTANCE hInst,
00019                                           LPSTR pszArgs, DWORD nShow);
00020 LPSTR *GetArgV(LPSTR pszCmdLine);
00021 BOOL WriteProxyServerSettingToFile(LPCSTR pszSourceFile, LPSTR pszProxyServer);
00022 BOOL ReadProxyServerByTunnelAddressFromFile(LPCSTR pszSourceFile,
00023                                             LPSTR pszTunnelAddress,
00024                       LPSTR *ppszProxyServer);
00025
00026 #define CMSAMPLE_STARTING_BUF_SIZE  256 // Starting size of the string buffer
00027 #define MAX_CMD_ARGS                15  // Maximum number of arguments expected
00028
00029 // Enumerations to keep pointer state for parsing command line arguments
00030 typedef enum _CMDLN_STATE
00031 {
00032     CS_END_SPACE,   // handling end space
00033     CS_BEGIN_QUOTE, // we've encountered a begin quote
00034     CS_END_QUOTE,   // we've encountered an end quote
00035     CS_CHAR,        // we're scanning chars
00036     CS_DONE
00037 } CMDLN_STATE;
00038
00039
00040
00041
00042 extern "C" BOOL WINAPI DllMain(
00043     HINSTANCE   hinstDLL,     // handle to DLL module
00044     DWORD       fdwReason,    // reason for calling function
00045     LPVOID      lpvReserved   // reserved
00046 )
00047 {
00048     return TRUE;
00049 }
00050
00051
00052 //+----------------------------------------------------------------------------
00053 //
00054 // Function:  SetProxyUsingTunnelAddress
00055 //
00056 // Synopsis:  Entry point for changing the proxy file settings using a tunnel
00057 //            address. The parameters to the dll are passed via a string which
00058 //        contains parameters.
00059 //
00060 // Arguments: HWND hWnd         - Window handle of caller
00061 //            HINSTANCE hInst   - Instance handle of caller
00062 //            LPSTR pszArgs     - Argument string
00063 //            DWORD nShow       - Reserved for future use
00064 //
00065 // Returns:   HRESULT           - S_OK or S_FALSE
00066 //
00067 //+----------------------------------------------------------------------------
00068 HRESULT WINAPI SetProxyUsingTunnelAddress(HWND hWnd, HINSTANCE hInst,
00069                                           LPSTR pszArgs, DWORD nShow)
00070 {
00071     // If we wanted to fail the connection we would return E_FAIL, since we
00072     // still want to connect even if this custom action fails, we just return S_FALSE (by default)
00073     // or S_OK in a successful case
00074     HRESULT hr = S_FALSE;
00075     LPSTR* ArgV = NULL;
00076     LPSTR pszServiceDir = NULL;
00077     LPSTR pszTunnelAddress = NULL;
00078     LPSTR pszProxyFile = NULL;
00079     LPSTR pszTunnelFile = NULL;
00080     LPSTR pszTunnelSettingFilePath = NULL;
00081     LPSTR pszProxyFilePath = NULL;
00082     LPSTR pszProxyServer = NULL;
00083     DWORD dwTunnelPathLen = 0;
00084     DWORD dwProxyPathLen = 0;
00085     HANDLE hCurrentHeap = GetProcessHeap();
00086     int i = 0;
00087     DWORD lcid = 0;
00088
00089   //  Parse out the command line parameters
00090   //  command line is of the form:
00091     //      /ServiceDir %SERVICEDIR% /TunnelAddress %TUNNELADDRESS% /ProxyFile
00092     //          <PROXYFILE> /TunnelFile <TUNNELFILE>
00093
00094   // Check if we have any arguments
00095     if (!pszArgs)
00096     {
00097     goto exit;
00098     }
00099
00100   // Separate each argument in the string by '\0' and return a list of
00101     // pointers to each argument
00102     ArgV = GetArgV(pszArgs);
00103
00104   // Check if we have any valid parsed arguments
00105     if (!ArgV)
00106     {
00107         goto exit;
00108     }
00109
00110   // Search the command line arguments for the following switches and their
00111   // corresponding values. Since actual paramter value is at i+1, make sure i
00112     // is less than the maximum allowed parameters - 1.
00113
00114
00115     lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
00116
00117     while (ArgV[i] && ((MAX_CMD_ARGS-1) > i))
00118     {
00119         if ((CSTR_EQUAL == CompareString(lcid, NORM_IGNORECASE,  ArgV[i], -1, "/ServiceDir", -1)) && ArgV[i+1])
00120         {
00121       pszServiceDir = (ArgV[i+1]);
00122       i = i+2;
00123         }
00124     else if ((CSTR_EQUAL == CompareString(lcid, NORM_IGNORECASE,  ArgV[i], -1, "/TunnelAddress", -1)) && ArgV[i+1])
00125         {
00126       pszTunnelAddress = ArgV[i+1];
00127       i = i+2;
00128         }
00129     else if ((CSTR_EQUAL == CompareString(lcid, NORM_IGNORECASE,  ArgV[i], -1, "/ProxyFile", -1)) && ArgV[i+1])
00130         {
00131       pszProxyFile = ArgV[i+1];
00132       i = i+2;
00133         }
00134     else if ((CSTR_EQUAL == CompareString(lcid, NORM_IGNORECASE,  ArgV[i], -1, "/TunnelFile", -1)) && ArgV[i+1])
00135         {
00136       pszTunnelFile = ArgV[i+1];
00137       i = i+2;
00138         }
00139         else
00140         {
00141             //  Unknown option.
00142             i++;
00143         }
00144     }
00145
00146   // Make sure we have values for the arguments
00147   if (!pszServiceDir || !pszTunnelAddress || !pszProxyFile || !pszTunnelFile)
00148   {
00149         goto exit;
00150   }
00151
00152   // Check to see if we got zero length string values from the command line
00153     // arguments. Exit if that is the case.
00154   if (!(*pszServiceDir) || !(*pszTunnelAddress) ||
00155     !(*pszProxyFile) || !(*pszTunnelFile))
00156   {
00157         goto exit;
00158   }
00159
00160   // Calculate the string size for the two paths that need to be created
00161   // Add 2 for the NULL and backslash
00162     dwTunnelPathLen = lstrlen(pszServiceDir) +  lstrlen(pszTunnelFile) + 2;
00163   dwProxyPathLen = lstrlen(pszServiceDir) +  lstrlen(pszProxyFile) + 2;
00164
00165   // Allocate the memory
00166   pszTunnelSettingFilePath = (LPSTR)HeapAlloc(hCurrentHeap, HEAP_ZERO_MEMORY,
00167                                 dwTunnelPathLen); // ANSI - char == byte
00168   if (!pszTunnelSettingFilePath)
00169   {
00170         goto exit;
00171   }
00172
00173   pszProxyFilePath = (LPSTR)HeapAlloc(hCurrentHeap, HEAP_ZERO_MEMORY,
00174                                 dwProxyPathLen);  // ANSI - char == byte
00175   if (!pszProxyFilePath)
00176   {
00177         goto exit;
00178   }
00179
00180   // Since we allocated pszTunnelSettingFilePath, we know that it has enough
00181     // room to fit the path. Otherwise we would have to use _snprintf or wnsprintf.
00182     // Copy the Service directory to create the full path.
00183   wsprintf(pszTunnelSettingFilePath, "%s\\%s", pszServiceDir, pszTunnelFile);
00184
00185     // Since we allocated pszTunnelSettingFilePath, we know that it has enough
00186     // room to fit the path. Otherwise we would have to use _snprintf or wnsprintf.
00187     //Create the full path to the Proxy file.
00188   wsprintf(pszProxyFilePath, "%s\\%s", pszServiceDir, pszProxyFile);
00189
00190   if (ReadProxyServerByTunnelAddressFromFile(pszTunnelSettingFilePath,
00191                                                pszTunnelAddress,
00192                                                &pszProxyServer))
00193   {
00194     // Call WriteProxyServerSettingToFile - the function checks for empty
00195         // strings
00196     if(WriteProxyServerSettingToFile(pszProxyFilePath, pszProxyServer))
00197     {
00198       hr = S_OK;
00199     }
00200   }
00201
00202 exit:
00203   // Clean up allocated memory
00204   // Delete the argument pointers, Tunnel Server path, Proxy file path and
00205     // ProxyServer name pointers
00206     if (ArgV)
00207       HeapFree(hCurrentHeap, 0, (LPVOID)ArgV);
00208
00209     if (pszTunnelSettingFilePath)
00210       HeapFree(hCurrentHeap, 0, (LPVOID)pszTunnelSettingFilePath);
00211
00212     if (pszProxyFilePath)
00213         HeapFree(hCurrentHeap, 0, (LPVOID)pszProxyFilePath);
00214
00215     if (pszProxyServer)
00216         HeapFree(hCurrentHeap, 0, (LPVOID)pszProxyServer);
00217
00218   return hr;
00219 }
00220
00221
00222
00223 //+----------------------------------------------------------------------------
00224 //
00225 // Function:  ReadProxyServerByTunnelAddressFromFile
00226 //
00227 // Synopsis:  Reads the proxy settings from the given proxy file and stores
00228 //            them in the provided pointer.  Please note that the buffers
00229 //            allocated here and stored in ppszProxyServer must be freed by
00230 //        the caller. If the TunnelAddress doesn't exist in the
00231 //        pszSourceFile this function still allocates memory and returns
00232 //            an empty string.
00233 //
00234 // Arguments: LPCSTR pszSourceFile    - file from which to read the proxy
00235 //                                      settings
00236 //            LPSTR  pszTunnelAddress - string containing the TunnelAddress
00237 //                    used to look up the ProxyServer value
00238 //            OUT LPSTR  *ppszProxyServer - string pointer that will have the Proxy
00239 //                                      server value (in server:port format)
00240 //
00241 // Returns:   BOOL - TRUE if the settings were successfully read
00242 //
00243 //+----------------------------------------------------------------------------
00244 BOOL ReadProxyServerByTunnelAddressFromFile(LPCSTR pszSourceFile,
00245                                             LPSTR pszTunnelAddress,
00246                       LPSTR *ppszProxyServer)
00247 {
00248   BOOL bReturn = FALSE;
00249   BOOL bExit = FALSE;
00250   DWORD dwReturnedSize = 0;
00251   DWORD dwSize = CMSAMPLE_STARTING_BUF_SIZE;
00252     HANDLE hCurrentHeap = GetProcessHeap();
00253
00254     // Section in Tunnel to read
00255     const CHAR* const c_pszTunnelAddressSection = "Tunnel Address";
00256
00257     //  Check parameters
00258   if ((NULL == ppszProxyServer) || (NULL == pszSourceFile) ||
00259         (NULL == pszTunnelAddress))
00260   {
00261     return FALSE;
00262   }
00263
00264   // Check for empty strings
00265   if (!(*pszSourceFile) || !(*pszTunnelAddress))
00266   {
00267     return FALSE;
00268   }
00269
00270   // Set the incoming pointer to NULL
00271   *ppszProxyServer = NULL;
00272
00273
00274   // In case the original buffer size is too small, the loop will try to
00275     // allocate more buffer space and try to read the value until. The
00276   // loop will exist if the value properly fits into the buffer or the size
00277   // exceeds 2048.
00278     do
00279     {
00280         if (*ppszProxyServer)
00281         {
00282         // Free allocated memory
00283         HeapFree(hCurrentHeap, 0, (LPVOID)*ppszProxyServer);
00284         *ppszProxyServer = NULL;
00285         }
00286
00287     // Allocate space for the ProxyServer name
00288         *ppszProxyServer = (LPSTR)HeapAlloc(hCurrentHeap, HEAP_ZERO_MEMORY,
00289                                             dwSize);  //ANSI - char == byte
00290
00291         if (*ppszProxyServer)
00292         {
00293       // Since memory allocation succeeded, read the value from the
00294             // settings file
00295             dwReturnedSize = GetPrivateProfileString(c_pszTunnelAddressSection,
00296                                             pszTunnelAddress,  "",
00297                                             *ppszProxyServer, dwSize,
00298                                             pszSourceFile);
00299
00300       // Check if the value fits into the buffer
00301             if ((dwReturnedSize == (dwSize - 2))  ||
00302                 (dwReturnedSize == (dwSize - 1)))
00303             {
00304                 //  The buffer is too small, lets allocate a bigger one
00305                 dwSize = 2*dwSize;
00306                 if (dwSize > 2048)
00307                 {
00308                     // Allocation above 2K, need to exit
00309           HeapFree(hCurrentHeap, 0, (LPVOID)*ppszProxyServer);
00310           *ppszProxyServer = NULL;
00311           goto exit;
00312                 }
00313             }
00314             else if (0 == dwReturnedSize)
00315             {
00316                 //  Either we got an error, or more likely there was no data
00317                 //  to get
00318         HeapFree(hCurrentHeap, 0, (LPVOID)*ppszProxyServer);
00319                 *ppszProxyServer = NULL;
00320                 goto exit;
00321             }
00322             else
00323             {
00324         // The function read in the data correctly. Just return.
00325                 return TRUE;
00326             }
00327         }
00328         else
00329         {
00330             bExit = TRUE;
00331         }
00332
00333     } while (!bExit);
00334
00335 exit:
00336   return bReturn;
00337 }
00338
00339
00340 //+----------------------------------------------------------------------------
00341 //
00342 // Function:  WriteProxyServerSettingToFile
00343 //
00344 // Synopsis:  Writes the specified settings to the given backup proxy filename.
00345 //            Please see the above format guide for specifics.
00346 //
00347 // Arguments: LPCSTR pszSourceFile - file to write the current settings to
00348 //            LPSTR pszProxyServer - proxy server string in server:port format
00349 //
00350 // Returns:   BOOL - TRUE if the values were written successfully
00351 //
00352 //+----------------------------------------------------------------------------
00353 BOOL WriteProxyServerSettingToFile(LPCSTR pszSourceFile, LPSTR pszProxyServer)
00354 {
00355   BOOL bReturn = FALSE;
00356
00357     // Section in Proxy file to update
00358     const CHAR* const c_pszManualProxySection = "Manual Proxy";
00359
00360     // Key in Proxy file to update
00361     const CHAR* const c_pszProxyServer = "ProxyServer";
00362
00363     //  Check input params
00364   if ( (NULL == pszSourceFile) || (NULL == pszProxyServer))
00365   {
00366     return bReturn;
00367   }
00368
00369   // Check for empty strings
00370   if (!(*pszSourceFile) || !(*pszProxyServer))
00371   {
00372     return bReturn;
00373   }
00374
00375     //  Save the Proxy Server name to the Proxy setting file
00376     if (WritePrivateProfileString(c_pszManualProxySection, c_pszProxyServer,
00377                                   pszProxyServer, pszSourceFile))
00378     {
00379         bReturn = TRUE;
00380     }
00381
00382   return bReturn;
00383 }
00384
00385
00386
00387 //+----------------------------------------------------------------------------
00388 //
00389 // Function:  GetArgV
00390 //
00391 // Synopsis:  Simulates ArgV using GetCommandLine to parse the parameters
00392 //
00393 // Arguments: LPSTR pszCmdLine - Ptr to a copy of the command line to be
00394 //                               processed
00395 //
00396 // Returns:   LPSTR * - Ptr to a ptr array containing the arguments. Caller is
00397 //                       responsible for releasing memory.
00398 //
00399 //
00400 //+----------------------------------------------------------------------------
00401 LPSTR *GetArgV(LPSTR pszCmdLine)
00402 {
00403     HANDLE hCurrentHeap = GetProcessHeap();
00404
00405     if (NULL == pszCmdLine || NULL == pszCmdLine[0])
00406     {
00407         return NULL;
00408     }
00409
00410     // Allocate Ptr array, up to MAX_CMD_ARGS ptrs
00411   LPSTR *ppArgV = (LPSTR *) HeapAlloc(hCurrentHeap, HEAP_ZERO_MEMORY,
00412                                         sizeof(LPSTR) * MAX_CMD_ARGS);
00413
00414     if (NULL == ppArgV)
00415     {
00416         return NULL;
00417     }
00418
00419     // Declare locals
00420     LPSTR pszCurr = NULL;
00421     LPSTR pszNext = NULL;
00422     LPSTR pszToken = NULL;
00423     CMDLN_STATE state;
00424     state = CS_CHAR;
00425     int ndx = 0;
00426
00427     // Parse out pszCmdLine and store pointers in ppArgV
00428     pszCurr = pszToken = pszCmdLine;
00429
00430     do
00431     {
00432         switch (*pszCurr)
00433         {
00434             case ' ':
00435                 if (state == CS_CHAR)
00436                 {
00437                     // We found a token
00438                     pszNext = CharNext(pszCurr);
00439                     *pszCurr = '\0';
00440
00441                     ppArgV[ndx] = pszToken;
00442                     ndx++;
00443
00444                     pszCurr = pszToken = pszNext;
00445                     state = CS_END_SPACE;
00446                     continue;
00447                 }
00448         else
00449                 {
00450                     if (state == CS_END_SPACE || state == CS_END_QUOTE)
00451             {
00452               pszToken = CharNext(pszToken);
00453             }
00454                 }
00455
00456                 break;
00457
00458             case '\"':
00459                 if (state == CS_BEGIN_QUOTE)
00460                 {
00461                     // We found a token
00462                     pszNext = CharNext(pszCurr);
00463                     *pszCurr = '\0';
00464
00465                     // skip the opening quote
00466                     pszToken = CharNext(pszToken);
00467
00468                     ppArgV[ndx] = pszToken;
00469                     ndx++;
00470
00471                     pszCurr = pszToken = pszNext;
00472
00473                     state = CS_END_QUOTE;
00474                     continue;
00475                 }
00476                 else
00477                 {
00478                     state = CS_BEGIN_QUOTE;
00479                 }
00480                 break;
00481
00482             case '\0':
00483                 if (state != CS_END_QUOTE)
00484                 {
00485                     // End of the line, set last token
00486                     ppArgV[ndx] = pszToken;
00487                 }
00488                 state = CS_DONE;
00489                 break;
00490
00491             default:
00492                 if (state == CS_END_SPACE || state == CS_END_QUOTE)
00493                 {
00494                     state = CS_CHAR;
00495                 }
00496                 break;
00497         }
00498
00499         pszCurr = CharNext(pszCurr);
00500     } while ((state != CS_DONE) && (MAX_CMD_ARGS > ndx));
00501
00502     return ppArgV;
00503 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/basesnap.h Source File

  • SysMgmt
  • MMC
  • Extens

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/comp.h Source File

  • SysMgmt
  • MMC
  • CMenu

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent,
00025 IExtendContextMenu
00026 {
00027 private:
00028     ULONG       m_cref;
00029
00030     IConsole*   m_ipConsole;
00031     IDisplayHelp* m_ipDisplayHelp;
00032
00033     class CComponentData *m_pComponentData;
00034
00035     public:
00036         CComponent(CComponentData *parent);
00037         ~CComponent();
00038
00039         ///////////////////////////////
00040         // Interface IUnknown
00041         ///////////////////////////////
00042         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00043         STDMETHODIMP_(ULONG) AddRef();
00044         STDMETHODIMP_(ULONG) Release();
00045
00046         ///////////////////////////////
00047         // Interface IComponent
00048         ///////////////////////////////
00049         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00050             /* [in] */ LPCONSOLE lpConsole);
00051
00052             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00053             /* [in] */ LPDATAOBJECT lpDataObject,
00054             /* [in] */ MMC_NOTIFY_TYPE event,
00055             /* [in] */ LPARAM arg,
00056             /* [in] */ LPARAM param);
00057
00058             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00059             /* [in] */ MMC_COOKIE cookie);
00060
00061             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00062             /* [in] */ MMC_COOKIE cookie,
00063             /* [in] */ DATA_OBJECT_TYPES type,
00064             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00065
00066             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00067             /* [in] */ MMC_COOKIE cookie,
00068             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00069             /* [out] */ long __RPC_FAR *pViewOptions);
00070
00071             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00073
00074             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075             /* [in] */ LPDATAOBJECT lpDataObjectA,
00076             /* [in] */ LPDATAOBJECT lpDataObjectB);
00077
00078             ///////////////////////////////
00079             // Interface IExtendContextMenu
00080             ///////////////////////////////
00081             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddMenuItems(
00082             /* [in] */ LPDATAOBJECT piDataObject,
00083             /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
00084             /* [out][in] */ long __RPC_FAR *pInsertionAllowed);
00085
00086             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Command(
00087             /* [in] */ long lCommandID,
00088             /* [in] */ LPDATAOBJECT piDataObject);
00089 };
00090
00091 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CObjTree Member List

This is the complete list of members for CObjTree, including all inherited members.
AddObject(CBase *pCSource, CBase *pCBase) | CObjTree | [virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CObjTree(CMainWindow *pCMainWindow) | CObjTree |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CSplitterLite(HWND hWndParent=NULL, UINT nID=0) | CSplitterLite |
CTreeViewLite(HWND hWndParent=NULL, UINT nID=0) | CTreeViewLite |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeleteAllItems() | CTreeViewLite | [inline]
DeleteItem(HTREEITEM hItem) | CTreeViewLite | [inline]
DestroyWindow() | CWndLite | [virtual]
DrawSplitter(HDC hDC, BOOL fVertical, REFRECT rectLeft, REFRECT rectRight, REFPOINTS ptsClient) | CSplitterLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EnsureVisible(HTREEITEM hItem) | CTreeViewLite | [inline]
Expand(HTREEITEM hItem, UINT flag=TVE_EXPAND) | CTreeViewLite | [inline]
GarbageCollectNode(HTREEITEM hTreeItem) | CObjTree | [virtual]
GetChildItem(HTREEITEM hItem) | CTreeViewLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetItemParam(HTREEITEM hItem) | CTreeViewLite |
GetNextItem(HTREEITEM hItem, UINT nCode=TVGN_NEXT) | CTreeViewLite | [inline]
GetParentItem(HTREEITEM hItem) | CTreeViewLite | [inline]
GetSelectedItem() | CTreeViewLite | [inline]
GetSelectedObject() | CObjTree | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
HitTest(REFPOINTS pts, UINT *pFlags=NULL, BOOL fClientCoords=TRUE) | CTreeViewLite |
InsertItem(HTREEITEM hParent, HTREEITEM hInsAfter, WCHAR *wszName, LPARAM lParam=PARAM_NONE, INT iImage=IMAGE_NONE, INT iSelectedImage=IMAGE_NONE, UINT iState=IMAGE_NONE, UINT iStateMask=IMAGE_NONE) | CTreeViewLite |
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hCursorOld | CSplitterLite |
m_hCursorRight | CSplitterLite |
m_hCursorTop | CSplitterLite |
m_hDraggingItem | CTreeViewLite | [protected]
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iBorderCX | CSplitterLite |
m_iBorderCY | CSplitterLite |
m_nID | CWndLite |
m_pCMainWindow | CObjTree |
m_pCWndBottom | CSplitterLite |
m_pCWndLeft | CSplitterLite |
m_pCWndRight | CSplitterLite |
m_pCWndTop | CSplitterLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnBeginDrag(INT idCtrl, NMTREEVIEW *pNMTreeView) | CTreeViewLite | [virtual]
OnBeginLabelEdit(INT idCtrl, NMTVDISPINFO *ptvdi) | CTreeViewLite | [virtual]
OnBorder(REFPOINTS pts, INT iBorder) | CSplitterLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CObjTree | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CObjTree | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CTreeViewLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CObjTree | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnEndLabelEdit(INT idCtrl, NMTVDISPINFO *ptvdi) | CTreeViewLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CObjTree | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CTreeViewLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CTreeViewLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CTreeViewLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CObjTree | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSelChanged(INT idCtrl, NMTREEVIEW *pNMTreeView) | CTreeViewLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CObjTree | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
RemoveNode(HTREEITEM hTreeItem) | CObjTree | [virtual]
RemoveObject(CBase *pCBase) | CObjTree | [virtual]
SelectItem(HTREEITEM hItem) | CTreeViewLite | [inline]
SelectObject(CBase *pCBase) | CObjTree | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetItemImage(HTREEITEM hItem, INT iImage, INT iSelectedImage) | CTreeViewLite |
SetItemParam(HTREEITEM hItem, LPARAM lParam) | CTreeViewLite |
SetItemState(HTREEITEM hItem, UINT iState, UINT iStateMask) | CTreeViewLite |
SetItemText(HTREEITEM hItem, WCHAR *pwszText) | CTreeViewLite |
SetSplitter(CSplitterLite *pCWndTop, CSplitterLite *pCWndBottom=NULL, CSplitterLite *pCWndLeft=NULL, CSplitterLite *pCWndRight=NULL) | CSplitterLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
StartTracking(REFPOINTS ptsScreen, REFRECT rectLeft, REFRECT rectRight, BOOL fVertical, POINT *pPoint) | CSplitterLite | [virtual]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CObjTree() | CObjTree | [virtual]
~CTreeViewLite() | CTreeViewLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSTATest Member List

This is the complete list of members for CSTATest, including all inherited members.
CSTATest() | CSTATest | [inline]
Exercise(void) | CSTATest |
Generated on Wed Nov 13 2024 16:57:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/_Record.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

_Record.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface _Record
00019 /** @com.interface(iid=00000562-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface _Record extends msado15._ADO
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=1, type=PROPGET, name="ActiveConnection", name2="getActiveConnection", addFlagsVtable=4)
00027       @com.parameters([type=VARIANT] return) */
00028   public Variant getActiveConnection();
00029
00030   /** @com.method(vtoffset=6, dispid=1, type=PROPPUT, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00031       @com.parameters([in,type=STRING] pvar) */
00032   public void setActiveConnection(String pvar);
00033
00034   /** @com.method(vtoffset=7, dispid=1, type=PROPPUTREF, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00035       @com.parameters([in,iid=00000550-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] pvar) */
00036   public void setActiveConnection(msado15._Connection pvar);
00037
00038   /** @com.method(vtoffset=8, dispid=2, type=PROPGET, name="State", name2="getState", addFlagsVtable=4)
00039       @com.parameters([type=I4] return) */
00040   public int getState();
00041
00042   /** @com.method(vtoffset=9, dispid=3, type=PROPGET, name="Source", name2="getSource", addFlagsVtable=4)
00043       @com.parameters([type=VARIANT] return) */
00044   public Variant getSource();
00045
00046   /** @com.method(vtoffset=10, dispid=3, type=PROPPUT, name="Source", name2="putSource", addFlagsVtable=4)
00047       @com.parameters([in,type=STRING] pvar) */
00048   public void setSource(String pvar);
00049
00050   /** @com.method(vtoffset=11, dispid=3, type=PROPPUTREF, name="Source", name2="putSource", addFlagsVtable=4)
00051       @com.parameters([in,iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] pvar) */
00052   public void setSource(Object pvar);
00053
00054   /** @com.method(vtoffset=12, dispid=4, type=PROPGET, name="Mode", name2="getMode", addFlagsVtable=4)
00055       @com.parameters([type=I4] return) */
00056   public int getMode();
00057
00058   /** @com.method(vtoffset=13, dispid=4, type=PROPPUT, name="Mode", name2="putMode", addFlagsVtable=4)
00059       @com.parameters([in,type=I4] pMode) */
00060   public void setMode(int pMode);
00061
00062   /** @com.method(vtoffset=14, dispid=5, type=PROPGET, name="ParentURL", name2="getParentURL", addFlagsVtable=4)
00063       @com.parameters([type=STRING] return) */
00064   public String getParentURL();
00065
00066   /** @com.method(vtoffset=15, dispid=6, type=METHOD, name="MoveRecord", addFlagsVtable=4)
00067       @com.parameters([in,type=STRING] Source, [in,type=STRING] Destination, [in,type=STRING] UserName, [in,type=STRING] Password, [in,type=I4] Options, [in,type=BOOLEAN] Async, [type=STRING] return) */
00068   public String MoveRecord(String Source, String Destination, String UserName, String Password, int Options, boolean Async);
00069
00070   /** @com.method(vtoffset=16, dispid=7, type=METHOD, name="CopyRecord", addFlagsVtable=4)
00071       @com.parameters([in,type=STRING] Source, [in,type=STRING] Destination, [in,type=STRING] UserName, [in,type=STRING] Password, [in,type=I4] Options, [in,type=BOOLEAN] Async, [type=STRING] return) */
00072   public String CopyRecord(String Source, String Destination, String UserName, String Password, int Options, boolean Async);
00073
00074   /** @com.method(vtoffset=17, dispid=8, type=METHOD, name="DeleteRecord", addFlagsVtable=4)
00075       @com.parameters([in,type=STRING] Source, [in,type=BOOLEAN] Async) */
00076   public void DeleteRecord(String Source, boolean Async);
00077
00078   /** @com.method(vtoffset=18, dispid=9, type=METHOD, name="Open", addFlagsVtable=4)
00079       @com.parameters([in,type=VARIANT] Source, [in,type=VARIANT] ActiveConnection, [in,type=I4] Mode, [in,type=I4] CreateOptions, [in,type=I4] Options, [in,type=STRING] UserName, [in,type=STRING] Password) */
00080   public void Open(Variant Source, Variant ActiveConnection, int Mode, int CreateOptions, int Options, String UserName, String Password);
00081
00082   /** @com.method(vtoffset=19, dispid=10, type=METHOD, name="Close", addFlagsVtable=4)
00083       @com.parameters() */
00084   public void Close();
00085
00086   /** @com.method(vtoffset=20, dispid=0, type=PROPGET, name="Fields", name2="getFields", addFlagsVtable=4)
00087       @com.parameters([iid=00000564-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00088   public msado15.Fields getFields();
00089
00090   /** @com.method(vtoffset=21, dispid=11, type=PROPGET, name="RecordType", name2="getRecordType", addFlagsVtable=4)
00091       @com.parameters([type=I4] return) */
00092   public int getRecordType();
00093
00094   /** @com.method(vtoffset=22, dispid=12, type=METHOD, name="GetChildren", addFlagsVtable=4)
00095       @com.parameters([iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00096   public msado15._Recordset GetChildren();
00097
00098   /** @com.method(vtoffset=23, dispid=13, type=METHOD, name="Cancel", addFlagsVtable=4)
00099       @com.parameters() */
00100   public void Cancel();
00101
00102
00103   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x562, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00104 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/Prof.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

Prof.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Profiling Routines
00005
00006     FILE: Prof.cpp
00007
00008     PURPOSE: Routines for profiling server system services.
00009
00010     FUNCTIONS:
00011         ProfOpenLog - Opens the profile log file and prepares to
00012     take timings.
00013         ProfRecordTime - Records the time of an event.
00014         ProfCloseLog - Writes the profiling data to the file
00015     and closes it.
00016
00017     COMMENTS: See the header file for function info.
00018         These routines depend on the existence of a high-resolution
00019     performance counter.
00020
00021 */
00022
00023 #include "common.h"
00024
00025 #include <process.h>
00026
00027 #include "Prof.h"
00028 #include "Service.h"
00029
00030 // Handle to the profile log file.
00031 HANDLE hProfLog = NULL;
00032
00033 // Counters for the timings.
00034 LARGE_INTEGER lpStartTime, lpCurrentTime, lpFrequency;
00035
00036 // The profile log text data.
00037 // Profile log gets acumulated in this string first, and then
00038 // gets written out when the log gets closed.
00039 TCHAR PROF_LOG[PROF_LOG_MAX_SIZE];
00040
00041 // Current size of the profile log.
00042 UINT nProfLogSize = 0;
00043
00044 // This is the maximum size of the log entry without the
00045 // user-specified message.  It is basically the size of a string
00046 // with an integer and a float.
00047 #define MAX_ENTRY_SIZE_NOMSG (32)
00048
00049 CRITICAL_SECTION ProfCriticalSection;
00050
00051 VOID ProfOpenLog(LPTSTR LogFileName) {
00052
00053     // Init the critsec.
00054     if (InitializeCriticalSectionAndSpinCount(&ProfCriticalSection, 0) == 0) {
00055         AddToMessageLogProcFailure(TEXT("ProfOpenLog: InitializeCriticalSectionAndSpinCount"), GetLastError());
00056         return;
00057     }
00058
00059     // Open the profiling log.
00060     if ((hProfLog = CreateFile(LogFileName,
00061                                GENERIC_WRITE,
00062                                0,
00063                                NULL,
00064                                CREATE_ALWAYS,
00065                                FILE_ATTRIBUTE_NORMAL,
00066                                NULL)) == INVALID_HANDLE_VALUE) {
00067         AddToMessageLogProcFailure(TEXT("ProfOpenLog: CreateFile"), GetLastError());
00068         return;
00069     }
00070
00071     // Get the current time.
00072     if (QueryPerformanceCounter(&lpStartTime) == FALSE) {
00073         AddToMessageLogProcFailure(TEXT("ProfOpenLog: QueryPerformanceCounter"), GetLastError());
00074         return;
00075     }
00076
00077     // Get the frequency.
00078     if (QueryPerformanceFrequency(&lpFrequency) == FALSE) {
00079         AddToMessageLogProcFailure(TEXT("ProfOpenLog: QueryPerformanceCounter"), GetLastError());
00080         return;
00081     }
00082 }
00083
00084 VOID ProfRecordTime(UINT id, LPTSTR msg) {
00085     FLOAT dt;
00086
00087     EnterCriticalSection(&ProfCriticalSection);
00088
00089     // Write the entry only if there is enough space left in
00090     // the log.
00091     if (nProfLogSize < PROF_LOG_MAX_SIZE - (MAX_ENTRY_SIZE_NOMSG + _tcslen(msg))) {
00092         if (QueryPerformanceCounter(&lpCurrentTime) == FALSE) {
00093             AddToMessageLogProcFailure(TEXT("ProfRecordTime: QueryPerformanceCounter"), GetLastError());
00094             LeaveCriticalSection(&ProfCriticalSection);
00095             return;
00096         }
00097
00098         // Get the time stamp for the event.
00099         dt = (FLOAT)(lpCurrentTime.QuadPart - lpStartTime.QuadPart)/(FLOAT)(lpFrequency.QuadPart);
00100
00101         // Append the entry to the log.
00102         nProfLogSize+=_stprintf(&PROF_LOG[nProfLogSize], TEXT("%d %s %f\n"), id, msg, dt);
00103     }
00104
00105     LeaveCriticalSection(&ProfCriticalSection);
00106 }
00107
00108 VOID ProfCloseLog(VOID) {
00109     ULONG cbWritten;
00110     DWORD status;
00111
00112     // Delete the critsec.
00113     // Here we make the assumption that no outside functions will use
00114     // the critsec anymore.  This should be valid, since all the profiling data
00115     // has been written.
00116     // Also we make an assumption that only one thread will attempt
00117     // to close the profile log.  This should be valid as well, or the
00118     // user can inmplement a semaphore to take care of that.
00119     DeleteCriticalSection(&ProfCriticalSection);
00120
00121     // Write out the profile log.
00122     if(!WriteFile(hProfLog,
00123                   (LPVOID)PROF_LOG,
00124                   nProfLogSize*sizeof(TCHAR),
00125                   &cbWritten,
00126                   NULL)) {
00127
00128         AddToMessageLogProcFailure(TEXT("ProfCloseLog: WriteFile"), GetLastError());
00129         return;
00130     }
00131
00132     // Close the profile log.
00133     if (hProfLog != NULL && hProfLog != INVALID_HANDLE_VALUE) {
00134         status = CloseHandle(hProfLog);
00135         ASSERT(status);
00136     }
00137 }
00138
00139 // end Prof.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/EnumAlgs/EnumAlgs.c Source File

  • Security
  • CryptoApi
  • EnumAlgs

EnumAlgs.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008 \******************************************************************************/
00009
00010 #include <stdlib.h>
00011 #include <stdio.h>
00012 #include <ctype.h>
00013 #include <windows.h>
00014 #include <wincrypt.h>
00015
00016 /*****************************************************************************/
00017 void _cdecl main(int argc, char *argv[])
00018 {
00019    INT iReturn = 0;
00020    HCRYPTPROV hProv = 0;
00021    PROV_ENUMALGS EnumAlgs;
00022    DWORD dwDataLen;
00023    DWORD dwFlags;
00024    CHAR *pszAlgType;
00025
00026    // Get handle to the default provider.
00027    if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0))
00028    {
00029       printf("Error %x during CryptAcquireContext!\n", GetLastError());
00030       goto Error;
00031    }
00032
00033    // Set the CRYPT_FIRST flag the first time through the loop.
00034    dwFlags = CRYPT_FIRST;
00035
00036    // Set size of data expected
00037    dwDataLen = sizeof(PROV_ENUMALGS);
00038
00039    // Enumerate the supported algorithms.
00040    while (TRUE)
00041    {
00042       // Retrieve information about an algorithm.
00043       if (!CryptGetProvParam(hProv, PP_ENUMALGS, (LPBYTE)&EnumAlgs, &dwDataLen, dwFlags))
00044       {
00045          if (GetLastError() == ERROR_NO_MORE_ITEMS)
00046          {
00047             // Exit the loop.
00048             break;
00049          }
00050
00051          printf("Error %x reading algorithm!\n", GetLastError());
00052          goto Error;
00053       }
00054
00055       // Determine algorithm type.
00056       switch (GET_ALG_CLASS(EnumAlgs.aiAlgid))
00057       {
00058       case ALG_CLASS_DATA_ENCRYPT: pszAlgType = "Encrypt";
00059          break;
00060       case ALG_CLASS_HASH:         pszAlgType = "Hash";
00061          break;
00062       case ALG_CLASS_KEY_EXCHANGE: pszAlgType = "Exchange";
00063          break;
00064       case ALG_CLASS_SIGNATURE:    pszAlgType = "Signature";
00065          break;
00066       default:                     pszAlgType = "Unknown";
00067       }
00068
00069       // Print information about algorithm.
00070       printf("Name:%-19s  Type:%-9s  Bits:%-4d  Algid:%8.8xh\n",
00071          EnumAlgs.szName, pszAlgType, EnumAlgs.dwBitLen, EnumAlgs.aiAlgid);
00072
00073       // Clear the flags for the remaining interations of the loop.
00074       dwFlags = 0;
00075    }
00076
00077 Exit:
00078
00079    // Release CSP handle (if open)
00080    if (hProv)
00081    {
00082       CryptReleaseContext(hProv, 0);
00083    }
00084
00085    exit(iReturn);
00086
00087 Error:
00088
00089    iReturn = 1;
00090    goto Exit;
00091 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/mspcall.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

mspcall.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1998-1999  Microsoft Corporation
00004
00005 Module Name:
00006
00007     MSPCall.cpp
00008
00009 Abstract:
00010
00011     This module contains implementation of CMSPCall.
00012
00013 --*/
00014
00015 #include "precomp.h"
00016 #pragma hdrstop
00017
00018 /////////////////////////////////////////////////////////////////////////////
00019 // CMSPCallBase
00020 /////////////////////////////////////////////////////////////////////////////
00021
00022 CMSPCallBase::CMSPCallBase()
00023     : m_pMSPAddress(NULL),
00024       m_htCall(NULL),
00025       m_dwMediaType(0)
00026 {
00027     LOG((MSP_TRACE, "CMSPCallBase::CMSPCallBase[%p] entered.", this));
00028
00029     LOG((MSP_TRACE, "CMSPCallBase::CMSPCallBase exited."));
00030 }
00031
00032
00033 CMSPCallBase::~CMSPCallBase()
00034 {
00035     LOG((MSP_TRACE, "CMSPCallBase::~CMSPCallBase[%p] entered.", this));
00036
00037
00038     // We wait until destructor to release the address because
00039     // they might be used by calls from the stream. If the last stream
00040     // has released its reference, this pointer will not be used again.
00041
00042     // If the MSPAddress had a refcount on the call, it should have been
00043     // released in the ShutdownMSPCall() method.
00044
00045     // release the address
00046     if (m_pMSPAddress != NULL)
00047     {
00048         LOG((MSP_TRACE, "CMSPCallBase::~CMSPCallBase releasing address [%p].", m_pMSPAddress));
00049
00050         m_pMSPAddress->MSPAddressRelease();
00051     }
00052
00053     LOG((MSP_TRACE, "CMSPCallBase::~CMSPCallBase exited."));
00054 }
00055
00056 // ITStreamControl methods, called by the app.
00057 STDMETHODIMP CMSPCallBase::EnumerateStreams(
00058     OUT     IEnumStream **      ppEnumStream
00059     )
00060 {
00061     LOG((MSP_TRACE,
00062         "EnumerateStreams entered. ppEnumStream:%x", ppEnumStream));
00063
00064     //
00065     // Check parameters.
00066     //
00067
00068     if (MSPB_IsBadWritePtr(ppEnumStream, sizeof(VOID *)))
00069     {
00070         LOG((MSP_ERROR, "CMSPCallBase::EnumerateStreams - "
00071             "bad pointer argument - exit E_POINTER"));
00072
00073         return E_POINTER;
00074     }
00075
00076     //
00077     // First see if this call has been shut down.
00078     // acquire the lock before accessing the stream object list.
00079     //
00080
00081     CLock lock(m_lock);
00082
00083     if (m_Streams.GetData() == NULL)
00084     {
00085         LOG((MSP_ERROR, "CMSPCallBase::EnumerateStreams - "
00086             "call appears to have been shut down - exit E_UNEXPECTED"));
00087
00088         // This call has been shut down.
00089         return E_UNEXPECTED;
00090     }
00091
00092     //
00093     // Create an enumerator object.
00094     //
00095
00096     typedef _CopyInterface<ITStream> CCopy;
00097     typedef CSafeComEnum<IEnumStream, &IID_IEnumStream,
00098                 ITStream *, CCopy> CEnumerator;
00099
00100     HRESULT hr;
00101
00102     CComObject<CEnumerator> *pEnum = NULL;
00103
00104     hr = CComObject<CEnumerator>::CreateInstance(&pEnum);
00105     if (pEnum == NULL)
00106     {
00107         LOG((MSP_ERROR, "CMSPCallBase::EnumerateStreams - "
00108             "Could not create enumerator object, %x", hr));
00109
00110         return hr;
00111     }
00112
00113     //
00114     // query for the IID_IEnumStream i/f
00115     //
00116
00117     hr = pEnum->_InternalQueryInterface(IID_IEnumStream, (void**)ppEnumStream);
00118
00119     if (FAILED(hr))
00120     {
00121         LOG((MSP_ERROR, "CMSPCallBase::EnumerateStreams - "
00122             "query enum interface failed, %x", hr));
00123
00124         delete pEnum;
00125         return hr;
00126     }
00127
00128     //
00129     // Init the enumerator object. The CSafeComEnum can handle zero-sized
00130     // array.
00131     //
00132
00133     hr = pEnum->Init(
00134         m_Streams.GetData(),                        // the begin itor
00135         m_Streams.GetData() + m_Streams.GetSize(),  // the end itor,
00136         NULL,                                       // IUnknown
00137         AtlFlagCopy                                 // copy the data.
00138         );
00139
00140     if (FAILED(hr))
00141     {
00142         LOG((MSP_ERROR, "CMSPCallBase::EnumerateStreams - "
00143             "init enumerator object failed, %x", hr));
00144
00145         (*ppEnumStream)->Release();
00146         return hr;
00147     }
00148
00149     LOG((MSP_TRACE, "CMSPCallBase::EnumerateStreams - exit S_OK"));
00150
00151     return hr;
00152 }
00153
00154 ///////////////////////////////////////////////////////////////////////////////
00155 ///////////////////////////////////////////////////////////////////////////////
00156 //
00157 // return a VB collection of streams
00158 //
00159
00160 STDMETHODIMP CMSPCallBase::get_Streams(
00161     OUT     VARIANT *           pVariant
00162     )
00163 {
00164     LOG((MSP_TRACE, "CMSPCallBase::get_Streams - enter"));
00165
00166     //
00167     // Check parameters.
00168     //
00169
00170     if ( MSPB_IsBadWritePtr(pVariant, sizeof(VARIANT) ) )
00171     {
00172         LOG((MSP_ERROR, "CMSPCallBase::get_Streams - "
00173             "bad pointer argument - exit E_POINTER"));
00174
00175         return E_POINTER;
00176     }
00177
00178     //
00179     // See if this call has been shut down. Acquire the lock before accessing
00180     // the stream object list.
00181     //
00182
00183     CLock lock(m_lock);
00184
00185     if (m_Streams.GetData() == NULL)
00186     {
00187         LOG((MSP_ERROR, "CMSPCallBase::get_Streams - "
00188             "call appears to have been shut down - exit E_UNEXPECTED"));
00189
00190         // This call has been shut down.
00191         return E_UNEXPECTED;
00192     }
00193
00194     //
00195     // create the collection object - see mspcoll.h
00196     //
00197
00198     typedef CTapiIfCollection< ITStream * > StreamCollection;
00199     CComObject<StreamCollection> * pCollection;
00200     HRESULT hr = CComObject<StreamCollection>::CreateInstance( &pCollection );
00201
00202     if ( FAILED(hr) )
00203     {
00204         LOG((MSP_ERROR, "CMSPCallBase::get_Streams - "
00205             "can't create collection - exit 0x%08x", hr));
00206
00207         return hr;
00208     }
00209
00210     //
00211     // get the Collection's IDispatch interface
00212     //
00213
00214     IDispatch * pDispatch;
00215
00216     hr = pCollection->_InternalQueryInterface(IID_IDispatch,
00217                                               (void **) &pDispatch );
00218
00219     if ( FAILED(hr) )
00220     {
00221         LOG((MSP_ERROR, "CMSPCallBase::get_Streams - "
00222             "QI for IDispatch on collection failed - exit 0x%08x", hr));
00223
00224         delete pCollection;
00225
00226         return hr;
00227     }
00228
00229     //
00230     // Init the collection using an iterator -- pointers to the beginning and
00231     // the ending element plus one.
00232     //
00233
00234     hr = pCollection->Initialize( m_Streams.GetSize(),
00235                                   m_Streams.GetData(),
00236                                   m_Streams.GetData() + m_Streams.GetSize() );
00237
00238     if (FAILED(hr))
00239     {
00240         LOG((MSP_ERROR, "CMSPCallBase::get_Streams - "
00241             "Initialize on collection failed - exit 0x%08x", hr));
00242
00243         pDispatch->Release();
00244         return hr;
00245     }
00246
00247     //
00248     // put the IDispatch interface pointer into the variant
00249     //
00250
00251     LOG((MSP_INFO, "CMSPCallBase::get_Streams - "
00252         "placing IDispatch value %08x in variant", pDispatch));
00253
00254     VariantInit(pVariant);
00255     pVariant->vt = VT_DISPATCH;
00256     pVariant->pdispVal = pDispatch;
00257
00258     LOG((MSP_TRACE, "CMSPCallBase::get_Streams - exit S_OK"));
00259
00260     return S_OK;
00261 }
00262
00263 // methods called by the MSPstream object.
00264 HRESULT CMSPCallBase::HandleStreamEvent(
00265     IN      MSPEVENTITEM *     pEventItem
00266     ) const
00267 {
00268     _ASSERTE(!MSPB_IsBadWritePtr(pEventItem, sizeof(MSPEVENTITEM)));
00269
00270     pEventItem->MSPEventInfo.hCall = m_htCall;
00271     return m_pMSPAddress->PostEvent(pEventItem);
00272 }
00273
00274 STDMETHODIMP CMSPCallBase::CreateStream(
00275     IN      long                lMediaType,
00276     IN      TERMINAL_DIRECTION  Direction,
00277     IN OUT  ITStream **         ppStream
00278     )
00279 /*++
00280
00281 Routine Description:
00282
00283
00284 Arguments:
00285
00286
00287 Return Value:
00288
00289 S_OK
00290
00291 E_POINTER
00292 E_OUTOFMEMORY
00293 TAPI_E_INVALIDMEDIATYPE
00294 TAPI_E_INVALIDTERMINALDIRECTION
00295 TAPI_E_INVALIDTERMINALCLASS
00296
00297 --*/
00298 {
00299     LOG((MSP_TRACE,
00300         "CreateStream--dwMediaType:%x, Direction:%x, ppStream %x",
00301         lMediaType, Direction, ppStream
00302         ));
00303
00304     if ( ! IsValidSingleMediaType( (DWORD) lMediaType, m_dwMediaType) )
00305     {
00306         LOG((MSP_ERROR,
00307             "wrong media type:%x, call media type:%x",
00308             lMediaType, m_dwMediaType
00309             ));
00310
00311         return TAPI_E_INVALIDMEDIATYPE;
00312     }
00313
00314     if (MSPB_IsBadWritePtr(ppStream, sizeof (VOID *)))
00315     {
00316         LOG((MSP_ERROR, "Bad pointer, ppStream:%x",ppStream));
00317
00318         return E_POINTER;
00319     }
00320
00321     return InternalCreateStream( (DWORD) lMediaType, Direction, ppStream);
00322 }
00323
00324 HRESULT CMSPCallBase::ReceiveTSPCallData(
00325         IN      PBYTE               pBuffer,
00326         IN      DWORD               dwSize
00327         )
00328 /*++
00329
00330 Routine Description:
00331
00332   Base class receive TSP call data method... does nothing in base class.
00333   Implemented so that MSP's that only communicate per-address don't have
00334   to override it.
00335
00336 Arguments:
00337
00338
00339 Return Value:
00340
00341 S_OK
00342
00343 --*/
00344
00345 {
00346     LOG((MSP_TRACE, "CMSPCallBase::ReceiveTSPCallData - enter"));
00347     LOG((MSP_TRACE, "CMSPCallBase::ReceiveTSPCallData - exit S_OK"));
00348
00349     return S_OK;
00350 }
00351
00352
00353 /////////////////////////////////////////////////////////////////////////////
00354 // Debugging utilities
00355 /////////////////////////////////////////////////////////////////////////////
00356
00357 #ifdef DBGGRAPH
00358
00359 HRESULT
00360 SetGraphLogFile(
00361     IN IGraphBuilder *pIGraphBuilder
00362     )
00363 /*++
00364
00365 Routine Description:
00366
00367     Set the log file for the filter graph.
00368
00369 Arguments:
00370
00371     pIGraphBuilder - The filter graph.
00372
00373 Return Value:
00374
00375     HRESULT.
00376
00377 --*/
00378 {
00379     const TCHAR GRAPHLOGPATH[] = _T("c:\\temp\\graph.log");
00380
00381     HANDLE hFile = CreateFile(
00382         GRAPHLOGPATH,
00383         GENERIC_WRITE,
00384         FILE_SHARE_READ, // sharing
00385         NULL, // no security
00386         OPEN_ALWAYS,
00387         0,    // no attributes, no flags
00388         NULL  // no template
00389         );
00390
00391     if (hFile == INVALID_HANDLE_VALUE)
00392     {
00393         LOG((MSP_ERROR,
00394             "Can not open graph log file: %s, %x",
00395             GRAPHLOGPATH,
00396             GetLastError()
00397             ));
00398         return S_FALSE;
00399     }
00400
00401     SetFilePointer(hFile, 0, NULL, FILE_END);
00402     HRESULT hr = pIGraphBuilder->SetLogFile(hFile);
00403
00404     return hr;
00405 }
00406 #endif
00407
00408 /////////////////////////////////////////////////////////////////////////////
00409 // CMSPCallMultiGraph
00410 /////////////////////////////////////////////////////////////////////////////
00411
00412 CMSPCallMultiGraph::CMSPCallMultiGraph()
00413     : CMSPCallBase()
00414 {
00415     LOG((MSP_TRACE, "CMSPCallMultiGraph::CMSPCallMultiGraph entered."));
00416     LOG((MSP_TRACE, "CMSPCallMultiGraph::CMSPCallMultiGraph exited."));
00417 }
00418
00419 CMSPCallMultiGraph::~CMSPCallMultiGraph()
00420 {
00421     LOG((MSP_TRACE, "CMSPCallMultiGraph::~CMSPCallMultiGraph entered."));
00422
00423     LOG((MSP_TRACE, "CMSPCallMultiGraph::~CMSPCallMultiGraph exited."));
00424 }
00425
00426 // methods called by the MSPAddress object.
00427 HRESULT CMSPCallMultiGraph::Init(
00428     IN      CMSPAddress *       pMSPAddress,
00429     IN      MSP_HANDLE          htCall,
00430     IN      DWORD               dwReserved,
00431     IN      DWORD               dwMediaType
00432     )
00433 /*++
00434
00435 Routine Description:
00436
00437 This method is called by CMSPAddress when the call is first created.
00438 It creates a filter graph for the streams. It gets the event handle from
00439 the graph and posts it to the thread pool. The derived method is supposed
00440 to create its own streams based one the mediatypes.
00441
00442 Arguments:
00443
00444
00445 Return Value:
00446
00447     HRESULT.
00448
00449 --*/
00450 {
00451     LOG((MSP_TRACE,
00452         "MSP call %x initialize entered, pMSPAddress:%x",
00453         this, pMSPAddress));
00454
00455     // No need to acquire locks on this call because it is called only
00456     // once when the object is created. No other calls can be made on
00457     // this object at this point.
00458     _ASSERTE(m_pMSPAddress == NULL);
00459
00460     // initialize the stream array so that the array is not NULL.
00461     if (!m_Streams.Grow())
00462     {
00463         return E_OUTOFMEMORY;
00464     }
00465
00466     pMSPAddress->MSPAddressAddRef();
00467     m_pMSPAddress   = pMSPAddress;
00468     m_htCall        = htCall;
00469     m_dwMediaType   = dwMediaType;
00470
00471     return S_OK;
00472 }
00473
00474
00475 HRESULT CMSPCallMultiGraph::ShutDown()
00476 /*++
00477
00478 Routine Description:
00479
00480 Cancel the event waiting and then call the base impelmentaion. Call the
00481 shutdown on the stream objects. Release the references on all the stream
00482 objects. Acquires the lock in the function.
00483
00484 Arguments:
00485
00486     pIGraphBuilder - The filter graph.
00487
00488 Return Value:
00489
00490     HRESULT.
00491
00492 --*/
00493
00494 {
00495     LOG((MSP_TRACE, "MSP call %x is shutting down", this));
00496
00497     // acquire the lock on the terminal data because we are writing to it.
00498     m_lock.Lock();
00499
00500     // release all the streams
00501     for (int i = m_Streams.GetSize() - 1; i >= 0; i --)
00502     {
00503         UnregisterWaitEvent(i);
00504
00505         ((CMSPStream*)m_Streams[i])->ShutDown();
00506         m_Streams[i]->Release();
00507     }
00508     m_Streams.RemoveAll();
00509     m_ThreadPoolWaitBlocks.RemoveAll();
00510
00511     m_lock.Unlock();
00512
00513     return S_OK;
00514 }
00515
00516 HRESULT CMSPCallMultiGraph::InternalCreateStream(
00517     IN      DWORD               dwMediaType,
00518     IN      TERMINAL_DIRECTION  Direction,
00519     IN OUT  ITStream **         ppStream
00520     )
00521 /*++
00522
00523 Routine Description:
00524
00525
00526 Arguments:
00527
00528
00529 Return Value:
00530
00531 S_OK
00532
00533 E_POINTER
00534 E_OUTOFMEMORY
00535 TAPI_E_INVALIDMEDIATYPE
00536 TAPI_E_INVALIDTERMINALDIRECTION
00537 TAPI_E_INVALIDTERMINALCLASS
00538
00539 --*/
00540 {
00541     // Create a filter graph and get the media event interface.
00542     CComPtr <IMediaEvent> pIMediaEvent;
00543     HRESULT hr = CoCreateInstance(
00544             CLSID_FilterGraph,
00545             NULL,
00546             CLSCTX_INPROC_SERVER,
00547             IID_IMediaEvent,
00548             (void **) &pIMediaEvent
00549             );
00550
00551     if (FAILED(hr))
00552     {
00553         LOG((MSP_ERROR, "create filter graph %x", hr));
00554         return hr;
00555     }
00556
00557     ITStream * pITStream;
00558     hr = CreateStreamObject(
00559         dwMediaType,
00560         Direction,
00561         pIMediaEvent,
00562         &pITStream
00563         );
00564
00565     if (FAILED(hr))
00566     {
00567         LOG((MSP_ERROR, "CreateStreamObject returned:%x",hr));
00568         return hr;
00569     }
00570
00571     // Add the stream into our list of streams.
00572     m_lock.Lock();
00573     if (!m_Streams.Add(pITStream))
00574     {
00575         ((CMSPStream*)pITStream)->ShutDown();
00576         pITStream->Release();
00577
00578         m_lock.Unlock();
00579
00580         LOG((MSP_ERROR, "out of memory is adding a stream."));
00581         return E_OUTOFMEMORY;
00582     }
00583
00584     // register the new graph and stream to the thread pool for graph events.
00585     hr = RegisterWaitEvent(pIMediaEvent, pITStream);
00586
00587     if (FAILED(hr))
00588     {
00589         ((CMSPStream*)pITStream)->ShutDown();
00590         pITStream->Release();
00591
00592         m_Streams.Remove(pITStream);
00593
00594         m_lock.Unlock();
00595
00596         LOG((MSP_ERROR, "Register wait returned %x.", hr));
00597         return hr;
00598     }
00599     m_lock.Unlock();
00600
00601     // AddRef the interface pointer and return it.
00602     pITStream->AddRef();
00603     *ppStream = pITStream;
00604
00605     return S_OK;
00606 }
00607
00608 HRESULT CMSPCallMultiGraph::RegisterWaitEvent(
00609     IN  IMediaEvent *   pIMediaEvent,
00610     IN  ITStream *      pITStream
00611     )
00612 {
00613     // This function should only be called within a critical section
00614     // on the object.
00615
00616     HANDLE hEvent;
00617     HRESULT hr = pIMediaEvent->GetEventHandle((OAEVENT*)&hEvent);
00618     if (FAILED(hr))
00619     {
00620         LOG((MSP_ERROR, "Can not get the event handle. %x", hr));
00621         return hr;
00622     }
00623
00624     THREADPOOLWAITBLOCK WaitBlock;
00625     ZeroMemory(&WaitBlock, sizeof WaitBlock);
00626
00627     WaitBlock.pContext = (MSPSTREAMCONTEXT *)malloc(sizeof(MSPSTREAMCONTEXT));
00628     if (WaitBlock.pContext == NULL)
00629     {
00630         LOG((MSP_ERROR, "out of memory for the context."));
00631         return E_OUTOFMEMORY;
00632     }
00633
00634     if (!m_ThreadPoolWaitBlocks.Add(WaitBlock))
00635     {
00636         free(WaitBlock.pContext);
00637
00638         LOG((MSP_ERROR, "out of memory adding the waitblock."));
00639         return E_OUTOFMEMORY;
00640     }
00641
00642     // increment the ref count before posting the callback to the thread pool.
00643     // but for the call, use our special inner object addref.
00644
00645     this->MSPCallAddRef();
00646     pITStream->AddRef();
00647     pIMediaEvent->AddRef();
00648
00649     WaitBlock.pContext->pMSPCall        = this;
00650     WaitBlock.pContext->pITStream       = pITStream;
00651     WaitBlock.pContext->pIMediaEvent    = pIMediaEvent;
00652
00653     //
00654     // post the event to the thread pool to wait on.
00655     //
00656
00657     HANDLE hWaitHandle = NULL;
00658
00659     BOOL fSuccess = RegisterWaitForSingleObject(
00660         & hWaitHandle,          // pointer to the returned handle
00661         hEvent,                 // the event handle to wait for.
00662         DispatchGraphEvent,     // the callback function.
00663         WaitBlock.pContext,     // the context for the callback.
00664         INFINITE,               // wait forever.
00665         WT_EXECUTEINWAITTHREAD  // use the wait thread to call the callback.
00666         );
00667
00668     if ( ( ! fSuccess ) || (hWaitHandle == NULL) )
00669     {
00670         LOG((MSP_ERROR,
00671             "Register wait call back failed. %x", GetLastError()));
00672
00673         // decrement the ref count if the posting failed.
00674         this->MSPCallRelease();
00675         pITStream->Release();
00676         pIMediaEvent->Release();
00677
00678         // Free the context block;
00679         free(WaitBlock.pContext);
00680         m_ThreadPoolWaitBlocks.Remove(WaitBlock);
00681
00682         return E_FAIL;
00683     }
00684
00685     // If register succeeded, save the wait handle. We know it is the last one.
00686     m_ThreadPoolWaitBlocks[m_ThreadPoolWaitBlocks.GetSize() - 1].hWaitHandle
00687         = hWaitHandle;
00688
00689     return S_OK;
00690 }
00691
00692 STDMETHODIMP CMSPCallMultiGraph::RemoveStream(
00693     IN      ITStream *         pStream
00694     )
00695 /*++
00696
00697 Routine Description:
00698
00699
00700 Arguments:
00701
00702
00703 Return Value:
00704
00705 S_OK
00706
00707 E_INVALIDARG
00708
00709 --*/
00710 {
00711     LOG((MSP_TRACE, "CMSPCallMultiGraph::RemoveStream - pStream %x", pStream));
00712
00713     // acquire the lock before accessing the stream object list.
00714     CLock lock(m_lock);
00715
00716     int index = m_Streams.Find(pStream);
00717     if (index < 0)
00718     {
00719         LOG((MSP_ERROR, "CMSPCallMultiGraph::RemoveStream - Stream %x is not found.", pStream));
00720         return E_INVALIDARG;
00721     }
00722
00723     UnregisterWaitEvent(index);
00724
00725     ((CMSPStream*)m_Streams[index])->ShutDown();
00726     m_Streams[index]->Release();
00727
00728     m_Streams.RemoveAt(index);
00729
00730     LOG((MSP_TRACE, "CMSPCallMultiGraph::RemoveStream - exit S_OK"));
00731
00732     return S_OK;
00733 }
00734
00735 HRESULT CMSPCallMultiGraph::UnregisterWaitEvent(
00736     IN  int     index
00737     )
00738 {
00739     if (index >= m_ThreadPoolWaitBlocks.GetSize())
00740     {
00741         // the call must have been disconnected.
00742         return E_UNEXPECTED;
00743     }
00744
00745     THREADPOOLWAITBLOCK &WaitBlock = m_ThreadPoolWaitBlocks[index];
00746
00747     // These pointers should never be NULL.
00748     _ASSERTE(WaitBlock.hWaitHandle != NULL);
00749     _ASSERTE(WaitBlock.pContext != NULL);
00750
00751     // Cancel the wait posted to the thread pool.
00752     BOOL fRes = ::UnregisterWaitEx(WaitBlock.hWaitHandle, (HANDLE)-1);
00753     if (!fRes)
00754     {
00755         // we should never get here, UnregisterWaitEx will block until success
00756
00757         LOG((MSP_ERROR,
00758             "UnregisterWait failed. %x", GetLastError()));
00759
00760         // just remove it from the list. keep the data so that it won't AV.
00761         m_ThreadPoolWaitBlocks.RemoveAt(index);
00762         return E_FAIL;
00763     }
00764
00765     // We need to decrement the refcount because it was incremented
00766     // before we post the wait.
00767     (WaitBlock.pContext->pMSPCall)->MSPCallRelease();
00768     (WaitBlock.pContext->pITStream)->Release();
00769     (WaitBlock.pContext->pIMediaEvent)->Release();
00770
00771     // Free the context block;
00772     free(WaitBlock.pContext);
00773
00774     m_ThreadPoolWaitBlocks.RemoveAt(index);
00775
00776     return S_OK;
00777 }
00778
00779 // methods called by the thread pool
00780 VOID NTAPI CMSPCallMultiGraph::DispatchGraphEvent(
00781     IN      VOID *              pContext,
00782     IN      BOOLEAN             bFlag
00783     )
00784 {
00785     LOG((MSP_EVENT,
00786         "DispatchGraphEvent:pContext:%x, bFlag:%u",
00787         pContext, bFlag));
00788
00789     // the pContext is a pointer to a call, since it carries a ref count,
00790     // the call should still be alive.
00791     _ASSERTE( ! IsBadReadPtr(pContext, sizeof(VOID *) ) );
00792
00793     MSPSTREAMCONTEXT * pEventContext = (MSPSTREAMCONTEXT *)pContext;
00794     pEventContext->pMSPCall->HandleGraphEvent(pEventContext);
00795 }
00796
00797 VOID CMSPCallMultiGraph::HandleGraphEvent(
00798     IN  MSPSTREAMCONTEXT * pContext
00799     )
00800 {
00801     long     lEventCode;
00802     LONG_PTR lParam1, lParam2; // win64 fix
00803
00804     HRESULT hr = pContext->pIMediaEvent->GetEvent(&lEventCode, &lParam1, &lParam2, 0);
00805     if (FAILED(hr))
00806     {
00807         LOG((MSP_ERROR, "Can not get the actual event. %x", hr));
00808         return;
00809     }
00810
00811     LOG((MSP_EVENT, "ProcessGraphEvent, code:%d param1:%x param2:%x",
00812         lEventCode, lParam1, lParam2));
00813
00814     //
00815     // Create an event data structure that we will pass to the worker thread.
00816     //
00817
00818     MULTI_GRAPH_EVENT_DATA * pData;
00819     pData = new MULTI_GRAPH_EVENT_DATA;
00820
00821     if (pData == NULL)
00822     {
00823         pContext->pIMediaEvent->FreeEventParams(lEventCode, lParam1, lParam2);
00824
00825         LOG((MSP_ERROR, "Out of memory for event data."));
00826         return;
00827     }
00828
00829     pData->pCall      = this;
00830     pData->pITStream  = pContext->pITStream;
00831     pData->lEventCode = lEventCode;
00832     pData->lParam1    = lParam1;
00833     pData->lParam2    = lParam2;
00834
00835
00836     //
00837     // also pass an addref'ed pointer to IMediaEvent, so that whoever processes
00838     // the message has the opportunity to free event parameters
00839     //
00840
00841     pData->pIMediaEvent = pContext->pIMediaEvent;
00842     pData->pIMediaEvent->AddRef();
00843
00844
00845     //
00846     // Make sure the call and stream don't go away while we handle the event.
00847     // but use our special inner object addref for the call
00848     //
00849
00850     pData->pCall->MSPCallAddRef();
00851     pData->pITStream->AddRef();
00852
00853     //
00854     // Queue an async work item to call ProcessGraphEvent.
00855     //
00856
00857     hr = g_Thread.QueueWorkItem(AsyncMultiGraphEvent,
00858                                 (void *) pData,
00859                                 FALSE);  // asynchronous
00860
00861     if (FAILED(hr))
00862     {
00863         LOG((MSP_ERROR, "QueueWorkItem failed, return code:%x", hr));
00864
00865         pData->pCall->MSPCallRelease();
00866         pData->pITStream->Release();
00867
00868
00869         //
00870         // no one is going to free event params and release the IMediaEvent
00871         // pointer, so do it here
00872         //
00873
00874         pContext->pIMediaEvent->FreeEventParams(lEventCode, lParam1, lParam2);
00875         pData->pIMediaEvent->Release();
00876
00877         delete pData;
00878     }
00879 }
00880
00881 DWORD WINAPI AsyncMultiGraphEvent(LPVOID pVoid)
00882 {
00883     MULTI_GRAPH_EVENT_DATA * pData = ( MULTI_GRAPH_EVENT_DATA * ) pVoid;
00884
00885     //
00886     // Handle the event.
00887     //
00888
00889     (pData->pCall)->ProcessGraphEvent(pData->pITStream,
00890                                       pData->lEventCode,
00891                                       pData->lParam1,
00892                                       pData->lParam2);
00893
00894     //
00895     // These were addrefed when the event was queued.
00896     // but we used our special inner object addref for the call
00897     //
00898
00899     pData->pCall->MSPCallRelease();
00900     pData->pITStream->Release();
00901
00902
00903     //
00904     // if we have IMediaEvent pointer, free event params and release the media
00905     // event interface pointer
00906     //
00907
00908     if (NULL != pData->pIMediaEvent)
00909     {
00910         pData->pIMediaEvent->FreeEventParams(pData->lEventCode,
00911                                              pData->lParam1,
00912                                              pData->lParam2);
00913         pData->pIMediaEvent->Release();
00914         pData->pIMediaEvent = NULL;
00915     }
00916
00917     //
00918     // Free the event data structure.
00919     //
00920
00921     delete pData;
00922
00923     return 0;
00924 }
00925
00926 HRESULT CMSPCallMultiGraph::ProcessGraphEvent(
00927     IN      ITStream *      pITStream,
00928     IN      long            lEventCode,
00929     IN      LONG_PTR        lParam1,
00930     IN      LONG_PTR        lParam2
00931     )
00932 {
00933     CLock lock(m_lock);
00934
00935     if (m_Streams.Find(pITStream) < 0)
00936     {
00937         LOG((MSP_WARN,
00938             "stream %x is already removed.",
00939             pITStream));
00940         return TAPI_E_NOITEMS;
00941     }
00942
00943     //
00944     // No dynamic cast because this is our own pointer.
00945     //
00946
00947     return ((CMSPStream*)pITStream)->
00948         ProcessGraphEvent(lEventCode, lParam1, lParam2);
00949 }
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/sBar.Cpp Source File

  • Web
  • NetMeeting
  • NMUI

sBar.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       SBAR.CPP
00004 //  Content:    Status Bar Routines
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 TBBUTTON _rgtbb[] =
00018 {
00019     {0,   0,                      TBSTATE_ENABLED, TBSTYLE_SEP,    0, 0,  0, 0},
00020     {28,  IDM_MONITOR,            TBSTATE_ENABLED, TBSTYLE_CHECK,  0, 0,  1, 0},
00021     {10,  IDM_CONF_START,         TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  2, 0},
00022     {6,   IDM_CONF_STOP,          TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  3, 0},
00023     {4,   IDM_VIEW_CLEAR,         TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  4, 0},
00024     {5,   IDM_CALL,               TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  5, 0},
00025     {1,   IDM_VIEW_MSG,           TBSTATE_ENABLED, TBSTYLE_CHECK,  0, 0,  6, 0},
00026     {0,   IDM_VIEW_CLEAR,         TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  7, 0},
00027     {6,   IDM_VIEW_FONT,          TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  8, 0},
00028     {10,  IDM_CHANNEL_DATA,       TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0,  9, 0},
00029     {11,  IDM_CHANNEL_AUDIO,      TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 10, 0},
00030     {26,  IDM_CHANNEL_FT,         TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 12, 0},
00031     {14,  IDM_CHANNEL_SHARE,      TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 13, 0},
00032     {3,   IDM_FT_CANCEL,          TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 14, 0},
00033
00034 };
00035
00036 // default ordering of toolbar buttons
00037 static TCHAR _szBtnDefault[] = TEXT("0100020304000500060007");
00038
00039 static TCHAR _szToolbar[] = TEXT("Toolbar");
00040
00041
00042 //****************************************************************************
00043 //
00044 // LPTBBUTTON _GetDefaultTbb(DWORD * pcTbb, BOOL fReset)
00045 //
00046 //****************************************************************************
00047
00048 LPTBBUTTON _GetDefaultTbb(DWORD * pcTbb, BOOL fReset)
00049 {
00050   if  (NULL == pcTbb)
00051   {
00052     ERROR_MSG(TEXT("_GetDefaultTbb: NULL == pcTbb"));
00053     return 0;
00054   }
00055
00056   DWORD iBtn  = 0;
00057   DWORD cBtn  = 0;
00058   LPTSTR  lpsz  = 0;
00059   LPTSTR  lpch  = 0;
00060   LPTBBUTTON pttb = 0;
00061
00062   if (fReset)
00063     lpsz = _szBtnDefault;
00064   else
00065     lpsz = GetIniStr(_szToolbar, _szBtnDefault);
00066
00067   if  (NULL == lpsz)
00068     return NULL;
00069
00070   lpch = lpsz;
00071   cBtn = lstrlen(lpsz) / 2;
00072
00073   pttb = (LPTBBUTTON) LpvAlloc(sizeof(TBBUTTON) * cBtn);
00074   if (NULL == pttb)
00075     return NULL;
00076   for (iBtn = 0; iBtn < cBtn; iBtn++)
00077   {
00078     CopyMemory(pttb + iBtn, &_rgtbb[ChFromHex(lpch)], sizeof(TBBUTTON));
00079     lpch += 2;
00080   }
00081
00082   if (!fReset)
00083     FreePlpv(&lpsz);
00084
00085   *pcTbb = cBtn;
00086   return pttb;
00087 }
00088
00089 //****************************************************************************
00090 //
00091 // VOID ResetToolbar(void)
00092 //
00093 // Reset the toolbar to the initial defaults
00094 //
00095 //****************************************************************************
00096
00097 VOID ResetToolbar(void)
00098 {
00099   DWORD cBtn  = 0;
00100   DWORD iBtn  = 0;
00101
00102   LPTBBUTTON ptbb = NULL;
00103
00104   ptbb = _GetDefaultTbb(&cBtn, TRUE /* fReset */);
00105   if (NULL == ptbb)
00106     return;
00107
00108   iBtn = SendMessage(ghwndTbar, TB_BUTTONCOUNT, 0, 0);
00109   while (iBtn != 0)
00110   {
00111     SendMessage(ghwndTbar, TB_DELETEBUTTON, (WPARAM) --iBtn, 0);
00112   }
00113
00114   SendMessage(ghwndTbar, TB_ADDBUTTONS, (WPARAM) cBtn, (LPARAM) ptbb);
00115
00116   FreePlpv(&ptbb);
00117 }
00118
00119 //****************************************************************************
00120 //
00121 // BOOL FCreateTbar(void)
00122 //
00123 // Create the toolbar
00124 //
00125 //****************************************************************************
00126
00127 BOOL FCreateTbar(void)
00128 {
00129   DWORD   cBtn  = 0;
00130   LPTBBUTTON  ptbb  = 0;
00131
00132   ptbb = _GetDefaultTbb(&cBtn, FALSE /* fReset */);
00133   if (NULL == ptbb)
00134     return FALSE;
00135
00136   ghwndTbar = CreateToolbarEx(ghwndMain,
00137     WS_CHILD | CCS_ADJUSTABLE |
00138       TBSTYLE_TOOLTIPS | TBSTYLE_ALTDRAG, // | TBSTYLE_WRAPABLE
00139     IDW_TBAR,
00140     NUMIMAGES,
00141     ghInst,
00142     IDC_TOOLBAR,
00143     ptbb,
00144     cBtn,
00145     BUTTONWIDTH,
00146     BUTTONHEIGHT,
00147     IMAGEWIDTH,
00148     IMAGEHEIGHT,
00149     sizeof(TBBUTTON));
00150
00151   FreePlpv(&ptbb);
00152
00153   return (ghwndTbar != NULL);
00154 }
00155
00156 //****************************************************************************
00157 //
00158 // LRESULT MsgNotifyTbar(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00159 //
00160 //****************************************************************************
00161
00162 LRESULT MsgNotifyTbar(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00163 {
00164   LPTOOLTIPTEXT lpToolTipText =(LPTOOLTIPTEXT) lparam;
00165   static TCHAR szBuffer[MAX_PATH + 1];
00166
00167   if  (NULL == lparam)
00168   {
00169     ERROR_MSG(TEXT("MsgNotifyTbar: NULL == lparam"));
00170     return 0;
00171   }
00172
00173   switch (lpToolTipText->hdr.code)
00174     {
00175   case TTN_NEEDTEXT:
00176   {
00177     ZeroMemory(szBuffer, sizeof(TCHAR) * (MAX_PATH + 1));
00178     int cb  = 0;
00179
00180     cb = LoadString(ghInst, lpToolTipText->hdr.idFrom,   // string ID == command ID
00181       szBuffer, MAX_PATH);
00182     if (cb == 0)
00183     {
00184       szBuffer[0] = '\0';
00185     }
00186
00187     lpToolTipText->lpszText = szBuffer;
00188     return 1;
00189   }
00190   case TBN_QUERYINSERT:
00191     return 1; // allow insert
00192   case TBN_QUERYDELETE:
00193     return 1; // allow delete
00194   case TBN_RESET:
00195     ResetToolbar();
00196     return 1;
00197   case TBN_GETBUTTONINFO:
00198   {
00199     LPTBNOTIFY ptbn = (LPTBNOTIFY) lparam;
00200     int iBtn = ptbn->iItem+1;
00201
00202     if (iBtn >= (ARRAY_ELEMENTS(_rgtbb)))
00203       return 0; // all button data has been passed to the control
00204
00205     LoadString(ghInst, _rgtbb[iBtn].idCommand, ptbn->pszText, ptbn->cchText);
00206 //?   ptbn->tbButton = _rgtbb[iBtn];
00207     return 1;
00208
00209   }
00210   case TBN_CUSTHELP:
00211     break;
00212   case TBN_TOOLBARCHANGE:
00213     break; // changes handled when exiting
00214   default:
00215     break;
00216     }
00217
00218   return 0;
00219 }
00220
00221 //****************************************************************************
00222 //
00223 // VOID SetToolbarCheck(int idm, BOOL fCheck)
00224 //
00225 // Change the status of a toolbar command to be checked
00226 //
00227 //****************************************************************************
00228
00229 VOID SetToolbarCheck(int idm, BOOL fCheck)
00230 {
00231   SendMessage(ghwndTbar, TB_CHECKBUTTON,
00232     (WPARAM) idm, (LPARAM) MAKELONG(fCheck, 0));
00233 }
00234
00235 //****************************************************************************
00236 //
00237 // VOID CmdToolbar(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
00238 //
00239 //****************************************************************************
00240
00241 VOID CmdToolbar(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
00242 {
00243   SendMessage(ghwndTbar, TB_CUSTOMIZE, 0, 0);
00244 }
00245
00246
00247 //****************************************************************************
00248 //
00249 // VOID WriteIniTbar(void)
00250 //
00251 //****************************************************************************
00252
00253 VOID WriteIniTbar(void)
00254 {
00255   int     iBtn  = 0;
00256   int     cBtn  = 0;
00257   LPTSTR    lpsz  = 0;
00258   LPTSTR    lpch  = 0;
00259   TBBUTTON  tbb;
00260
00261   if (NULL == ghwndTbar)
00262     return; // no toolbar?
00263
00264   cBtn = SendMessage(ghwndTbar, TB_BUTTONCOUNT, 0, 0);
00265   if (0 == cBtn)
00266     return;
00267
00268   lpsz = (LPTSTR) LpvAlloc((cBtn*2 + 1) * sizeof(TCHAR));
00269   if (NULL == lpsz)
00270     return;
00271   ZeroMemory(lpsz, (cBtn*2 + 1) * sizeof(TCHAR));
00272
00273   lpch = lpsz;
00274   for (iBtn = 0; iBtn < cBtn; iBtn++)
00275   {
00276     SendMessage(ghwndTbar, TB_GETBUTTON, (WPARAM) iBtn, (LPARAM) (LPTBBUTTON) &tbb);
00277     _sntprintf(lpch, 2, TEXT("%02X"), LOBYTE(tbb.dwData));
00278     lpch += 2;
00279   }
00280   WriteIniStr(_szToolbar, lpsz);
00281   FreePlpv(&lpsz);
00282 }
00283
00284
00285 //****************************************************************************
00286 //
00287 // BOOL FCreateSbar(void)
00288 //
00289 // Create the status bar.
00290 //
00291 //****************************************************************************
00292
00293 BOOL FCreateSbar(void)
00294 {
00295   ghwndSbar = CreateWindow(STATUSCLASSNAME, NULL,
00296     WS_CHILD | SBARS_SIZEGRIP,
00297     0, 0, 0, 0,
00298     ghwndMain, (HMENU) IDW_SBAR, ghInst, NULL);
00299
00300   return (ghwndSbar != NULL);
00301 }
00302
00303
00304 //****************************************************************************
00305 //
00306 // VOID UpdateStatusBar(LPTSTR lpsz, WORD wPart, WORD wFlags)
00307 //
00308 // Update the text for part of the status bar
00309 //
00310 //****************************************************************************
00311
00312 VOID UpdateStatusBar(LPTSTR lpsz, WORD wPart, WORD wFlags)
00313 {
00314     SendMessage(ghwndSbar, SB_SETTEXT, wPart | wFlags, (LPARAM) lpsz);
00315 }
00316
00317
00318 //****************************************************************************
00319 //
00320 // VOID StatusMsg(LPTSTR sz)
00321 //
00322 //****************************************************************************
00323
00324 VOID StatusMsg(LPTSTR sz)
00325 {
00326   UpdateStatusBar(sz, IDSBP_MSG, 0);
00327 }
00328
00329
00330 //****************************************************************************
00331 //
00332 // VOID UpdateStatusIcon(DWORD dwId)
00333 //
00334 //****************************************************************************
00335
00336 VOID UpdateStatusIcon(DWORD dwId)
00337 {
00338   static DWORD m_idIconStatus = 0;
00339   static HICON m_hIconStatus = 0;
00340
00341   if (dwId == m_idIconStatus)
00342     return;
00343
00344   HICON hIcon = (HICON) LoadImage(ghInst,
00345         MAKEINTRESOURCE(dwId), IMAGE_ICON,
00346         STATUSICONSIZE, STATUSICONSIZE,
00347         LR_DEFAULTCOLOR | LR_SHARED);
00348   if (NULL == hIcon)
00349   {
00350     return;
00351   }
00352
00353   m_idIconStatus = dwId;
00354   m_hIconStatus = hIcon;
00355   SendMessage(ghwndSbar, SB_SETTEXT,
00356       IDSBP_ICON | SBT_OWNERDRAW, (LPARAM) m_hIconStatus);
00357 }
00358
00359
00360 //****************************************************************************
00361 //
00362 // LRESULT MsgMenuSelect(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00363 //
00364 // Change the status bar text to display the menu help.
00365 //
00366 //****************************************************************************
00367
00368 LRESULT MsgMenuSelect(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00369 {
00370   TCHAR  szBuffer[MAX_PATH + 1];
00371   UINT   nStringID = 0;
00372   UINT   fuFlags = GET_WM_MENUSELECT_FLAGS(wparam, lparam) & 0xffff;
00373   UINT   uCmd    = GET_WM_MENUSELECT_CMD(wparam, lparam);
00374   HMENU  hMenu   = GET_WM_MENUSELECT_HMENU(wparam, lparam);
00375
00376   ZeroMemory(szBuffer, sizeof(TCHAR)*(MAX_PATH + 1));
00377
00378   if (fuFlags == 0xffff && hMenu == NULL)     // Menu has been closed
00379   {
00380     return 0;
00381 //    nStringID = IDS_DESCRIPTION;
00382   }
00383   else if (fuFlags & MFT_SEPARATOR)           // Ignore separators
00384   {
00385     nStringID = 0;
00386   }
00387   else if (fuFlags & MF_POPUP)                // Popup menu
00388   {
00389     if (fuFlags & MF_SYSMENU)               // System menu
00390       nStringID = IDS_SYSMENU;
00391   }
00392   else                                        // Must be a command item
00393   {
00394     nStringID = uCmd;               // String ID == Command ID
00395   }
00396
00397   // Load the string if we have an ID
00398   if (nStringID != 0)
00399   {
00400     LoadString(ghInst, nStringID, szBuffer, MAX_PATH);
00401   }
00402
00403   // Finally... send the string to the status bar
00404   UpdateStatusBar(szBuffer, IDSBP_MSG, 0);
00405
00406   return 0;
00407 }
00408
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIOleInPlaceSite Member List

This is the complete list of members for CImpIOleInPlaceSite, including all inherited members.
CanInPlaceActivate(void) | CImpIOleInPlaceSite |
CImpIOleInPlaceSite(class CSite *, IUnknown *) | CImpIOleInPlaceSite |
ContextSensitiveHelp(BOOL) | CImpIOleInPlaceSite |
DeactivateAndUndo(void) | CImpIOleInPlaceSite |
DiscardUndoState(void) | CImpIOleInPlaceSite |
GetWindow(HWND *) | CImpIOleInPlaceSite |
GetWindowContext(LPOLEINPLACEFRAME *, LPOLEINPLACEUIWINDOW *, LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO) | CImpIOleInPlaceSite |
m_cRef | CImpIOleInPlaceSite | [protected]
m_pSite | CImpIOleInPlaceSite | [protected]
m_pUnkOuter | CImpIOleInPlaceSite | [protected]
OnInPlaceActivate(void) | CImpIOleInPlaceSite |
OnInPlaceDeactivate(void) | CImpIOleInPlaceSite |
OnPosRectChange(LPCRECT) | CImpIOleInPlaceSite |
OnUIActivate(void) | CImpIOleInPlaceSite |
OnUIDeactivate(BOOL) | CImpIOleInPlaceSite |
QueryInterface(REFIID, void **) | CImpIOleInPlaceSite |
Scroll(SIZE) | CImpIOleInPlaceSite |
STDMETHODIMP_(ULONG) AddRef(void) | CImpIOleInPlaceSite |
STDMETHODIMP_(ULONG) Release(void) | CImpIOleInPlaceSite |
~CImpIOleInPlaceSite(void) | CImpIOleInPlaceSite |
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/server/rqsengine.cpp Source File

  • NetDS
  • RRas
  • rqs
  • server

rqsengine.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       RqsEngine.cpp
00004 //
00005 //      Synopsis:   Engine that drives the server-side ras quarantine removal
00006 //                  utility.
00007 //
00008 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00009 //
00010 //+--------------------------------------------------------------------------
00011
00012 #include <rqs.h>
00013
00014 //+--------------------------------------------------------------------------
00015 //
00016 // Synopsis: Structure to be passed to the callback functions
00017 //
00018 //+--------------------------------------------------------------------------
00019 typedef struct _RqsEngineCbInfo
00020 {
00021     RqsEngine* pEngine;
00022     RqsClient* pClient;
00023 } RqsEngineCbInfo;
00024
00025 //+--------------------------------------------------------------------------
00026 //
00027 // Synopsis: Instantiates a quarantine engine object
00028 //
00029 //+--------------------------------------------------------------------------
00030 RqsEngine::RqsEngine() : m_ulClientCount(0), m_hService(NULL), m_dwCheckPoint(0),
00031                          m_hServer(NULL), m_hInstMprApi(NULL),
00032                          m_fConsoleTrace(FALSE), m_dwTraceId(INVALID_TRACEID),
00033                          m_fDebugTrace(FALSE), m_fRtTrace(FALSE),
00034                          m_hkTrace(NULL), m_hkConfig(NULL), m_hLog(NULL),
00035                          m_Config(), m_sServer(), m_eSocketAccept(),
00036                          m_eSocketRead(), m_eQuit(), m_eTrace(),
00037                          m_rwlConfig(), m_csClientsLock(), m_bRegisteredForConnectionNotification(FALSE)
00038 {
00039     m_szInternalAddress[0] = '\0';
00040 }
00041
00042 //+--------------------------------------------------------------------------
00043 //
00044 // Synopsis: Cleans up a quarantine engine object
00045 //
00046 //+--------------------------------------------------------------------------
00047 RqsEngine::~RqsEngine()
00048 {
00049     Clear();
00050
00051     if (m_bRegisteredForConnectionNotification)
00052     {
00053         DeregisterForConnectionNotification();
00054     }
00055     if (m_hkConfig)
00056     {
00057         RegCloseKey(m_hkConfig);
00058     }
00059     if (m_hkTrace)
00060     {
00061         RegCloseKey(m_hkTrace);
00062     }
00063     if (m_hServer)
00064     {
00065         MprAdminServerDisconnect(m_hServer);
00066     }
00067     if (m_hInstMprApi)
00068     {
00069         FreeLibrary(m_hInstMprApi);
00070     }
00071     if (m_dwTraceId != INVALID_TRACEID)
00072     {
00073         TraceDeregisterExA( m_dwTraceId, 0 );
00074     }
00075     if (m_hLog)
00076     {
00077         DeregisterEventSource(m_hLog);
00078     }
00079
00080 }
00081
00082 //+--------------------------------------------------------------------------
00083 //
00084 // Synopsis: Clears a quarantine engine object
00085 //
00086 //+--------------------------------------------------------------------------
00087 VOID
00088 RqsEngine::Clear()
00089 {
00090     m_Config.Clear();
00091     m_sServer.Close();
00092     m_ulClientCount = 0;
00093 }
00094
00095 //+--------------------------------------------------------------------------
00096 //
00097 // Synopsis: Helper method initializes all of the events
00098 //
00099 //+--------------------------------------------------------------------------
00100 HRESULT
00101 RqsEngine::InitializeEvents()
00102 {
00103     HRESULT hr = S_OK;
00104
00105     __try
00106     {
00107         hr = m_eQuit.Initialize(NONSIGNALED, FALSE);
00108         RU_LEAVE_IF_NOT_OK(hr);
00109         m_dwCheckPoint++;
00110
00111         hr = m_eConfig.Initialize(NONSIGNALED, FALSE);
00112         RU_LEAVE_IF_NOT_OK(hr);
00113         m_dwCheckPoint++;
00114
00115         hr = m_eTrace.Initialize(NONSIGNALED, FALSE);
00116         RU_LEAVE_IF_NOT_OK(hr);
00117         m_dwCheckPoint++;
00118
00119         hr = m_eInterfaceAdded.Initialize(NONSIGNALED, FALSE);
00120         RU_LEAVE_IF_NOT_OK(hr);
00121         m_dwCheckPoint++;
00122
00123         // Cause the registry functions to signal us when change occurs
00124         //
00125         if (m_hkConfig)
00126         {
00127             hr = RegNotifyChangeKeyValue(
00128                     m_hkConfig,
00129                     FALSE,
00130                     REG_NOTIFY_CHANGE_LAST_SET,
00131                     m_eConfig.GetHandle(),
00132                     TRUE);
00133             if (hr != ERROR_SUCCESS)
00134             {
00135                 Trace("Warning: unable to set up config event %x", hr);
00136                 hr = S_OK;
00137             }
00138         }
00139         m_dwCheckPoint++;
00140
00141         if (m_hkTrace)
00142         {
00143             hr = RegNotifyChangeKeyValue(
00144                     m_hkTrace,
00145                     FALSE,
00146                     REG_NOTIFY_CHANGE_LAST_SET,
00147                     m_eTrace.GetHandle(),
00148                     TRUE);
00149             if (hr != ERROR_SUCCESS)
00150             {
00151                 Trace("Warning: unable to set up trace event %x", hr);
00152                 hr = S_OK;
00153             }
00154         }
00155         m_dwCheckPoint++;
00156
00157     }
00158
00159     __finally
00160     {
00161     }
00162
00163     return hr;
00164 }
00165
00166
00167 //+--------------------------------------------------------------------------
00168 //
00169 // Synopsis: Initializes a quarantine server object
00170 //
00171 //+--------------------------------------------------------------------------
00172 HRESULT
00173 RqsEngine::Initialize()
00174 {
00175     HRESULT hr = S_OK;
00176
00177     __try
00178     {
00179         // Register event log handle.
00180         //
00181         m_hLog = RegisterEventSource(NULL, L"Rqs");
00182         if (m_hLog == NULL)
00183         {
00184             hr = HRESULT_FROM_WIN32( GetLastError() );
00185             __leave;
00186         }
00187
00188         // Initialize all of the members of the class
00189         //
00190         hr = m_eSocketAccept.Initialize(NONSIGNALED, FALSE);
00191         RU_LEAVE_IF_NOT_OK(hr);
00192         m_dwCheckPoint++;
00193
00194         hr = m_eSocketRead.Initialize(NONSIGNALED, FALSE);
00195         RU_LEAVE_IF_NOT_OK(hr);
00196         m_dwCheckPoint++;
00197
00198         hr = m_rwlConfig.Initialize();
00199         RU_LEAVE_IF_NOT_OK(hr);
00200         m_dwCheckPoint++;
00201
00202         hr = m_Config.Load();
00203         RU_LEAVE_IF_NOT_OK(hr);
00204         m_dwCheckPoint++;
00205         m_fRtTrace = m_Config.GetTraceEnabled();
00206         m_fDebugTrace = m_Config.GetDebugTrace();
00207
00208         hr = m_csClientsLock.Initialize();
00209         RU_LEAVE_IF_NOT_OK(hr);
00210
00211         // Establish tracing ability if possible
00212         //
00213         m_dwTraceId = TraceRegisterExA( "Rqs", 0 );
00214
00215         // Load the quarantine removal function
00216         //
00217         m_hInstMprApi = LoadLibrary(m_Config.GetLibrary());
00218         if (m_hInstMprApi)
00219         {
00220             m_qFunc = (RqsRemoveQuarantineFunc)
00221                 GetProcAddress(
00222                     m_hInstMprApi,
00223                     "MprAdminConnectionRemoveQuarantine");
00224         }
00225
00226         // Get references to the registry keys
00227         //
00228         hr = RuRegOpenKey(RqsConfig::GetConfigPath(), FALSE, &m_hkConfig);
00229         if (S_OK != hr)
00230         {
00231             Trace("Warning, unable to listen for configuration changes %x", hr);
00232         }
00233
00234         hr = RuRegOpenKey(RqsConfig::GetTracePath(), FALSE, &m_hkTrace);
00235         if (S_OK != hr)
00236         {
00237             Trace("Warning, unable to listen for trace changes %x", hr);
00238         }
00239
00240         hr = InitializeEvents();
00241         RU_LEAVE_IF_NOT_OK(hr);
00242
00243         hr = ConnectRRAS();
00244         if (SUCCEEDED(hr))
00245         {
00246             //  Init the Server socket to listen for incoming requests.
00247             //
00248             hr = InitializeServerSocket();
00249
00250             if (ERROR_NO_SUCH_INTERFACE == HRESULT_CODE(hr))
00251             {
00252                 hr = RegisterForConnectionNotification();
00253                 RU_LEAVE_IF_NOT_OK(hr);
00254
00255                 hr = S_OK;
00256                 Trace("Internal interface not found.");
00257                 Trace("Waiting for first connection so that RRAS will create the internal interface.");
00258             }
00259
00260             RU_LEAVE_IF_NOT_OK(hr);
00261             m_dwCheckPoint++;
00262
00263         }
00264         else if ((HRESULT_CODE(hr) == RPC_S_UNKNOWN_IF) || (HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE))
00265         {
00266             // RRAS isn't available yet.  Schedule a workitem to wait for RRAS and then init the
00267             // server socket.
00268             //
00269             hr = ScheduleWork(InitializeServerSocketCb);
00270         }
00271         RU_LEAVE_IF_NOT_OK(hr);
00272     }
00273
00274     __finally
00275     {
00276         if (S_OK != hr)
00277         {
00278             Clear();
00279         }
00280     }
00281
00282     TraceSelf();
00283
00284     return hr;
00285 }
00286
00287 //+--------------------------------------------------------------------------
00288 //
00289 // Synopsis: Establishes an RPC connection to the RRAS service.
00290 //
00291 //+--------------------------------------------------------------------------
00292 HRESULT
00293 RqsEngine::ConnectRRAS(IN OPTIONAL DWORD dwRetries)
00294 {
00295     DWORD dwRet;
00296     BOOL bWrittenWaitingMessage = FALSE;
00297
00298     if (m_hServer)
00299     {
00300         return S_OK;
00301     }
00302
00303     do
00304     {
00305         // Connect to the remote access server
00306         //
00307         dwRet = MprAdminServerConnect(NULL, &m_hServer);
00308
00309         if (dwRet == ERROR_SUCCESS)
00310         {
00311             Trace("Connected to RRAS.");
00312             break;
00313         }
00314         else if (((dwRet == RPC_S_UNKNOWN_IF) || (dwRet == RPC_S_SERVER_UNAVAILABLE)) && (dwRetries > 0))
00315         {
00316             //  We weren't able to connect to RRAS because it isn't fully initialized yet, so lets
00317             //  sleep for a second and try again
00318             //
00319             if (!bWrittenWaitingMessage)
00320             {
00321                 Trace("Unable to connect to RRAS.  RRAS has not finished initializing yet, waiting...");
00322                 bWrittenWaitingMessage = TRUE;
00323             }
00324             Sleep(1000);
00325             dwRetries--;
00326         }
00327         else
00328         {
00329             //
00330             //  Unexpected error.
00331             //
00332             m_hServer = NULL;
00333             break;
00334         }
00335
00336     } while(dwRetries > 0);
00337
00338
00339     return HRESULT_FROM_WIN32(dwRet);
00340 }
00341
00342 //+--------------------------------------------------------------------------
00343 //
00344 // Synopsis: Causes the quarantine engine to execute.
00345 //
00346 //+--------------------------------------------------------------------------
00347 HRESULT
00348 RqsEngine::Execute()
00349 {
00350     HRESULT hr = S_FALSE;
00351     RqsEvent Action;
00352     BOOL fDone = FALSE;
00353
00354     while (!fDone)
00355     {
00356         // Wait for something to happen
00357         //
00358         hr = Wait(&Action);
00359         RU_BREAK_IF_NOT_OK(hr);
00360
00361         // Do your thing
00362         //
00363         switch (Action)
00364         {
00365             case Connect:
00366                 hr = ScheduleWork(ClientConnectCb);
00367                 break;
00368
00369             case Read:
00370                 hr = ScheduleWork(ClientReadCb);
00371                 break;
00372
00373             case UpdateConfig:
00374                 hr = ReloadConfig();
00375                 break;
00376
00377             case UpdateTrace:
00378                 hr = ReloadTrace();
00379                 break;
00380
00381             case ConfigServerSocket:
00382                 DeregisterForConnectionNotification();
00383                 hr = InitializeServerSocket();
00384
00385                 if (SUCCEEDED(hr))
00386                 {
00387                     TraceSelf();
00388                 }
00389                 else
00390                 {
00391                     fDone = TRUE;
00392                 }
00393                 break;
00394
00395             case Quit:
00396                 fDone = TRUE;
00397                 break;
00398         }
00399
00400         if (S_OK != hr)
00401         {
00402             Trace("Execution error %d 0x%x", Action, hr);
00403             hr = S_OK;
00404         }
00405
00406     }
00407
00408     // Wait for the pending clients to complete
00409     //
00410     while (m_ulClientCount)
00411     {
00412         Trace("Waiting for %d pending clients...", m_ulClientCount);
00413         Sleep(0);
00414     }
00415
00416     return hr;
00417
00418 }
00419
00420 //+--------------------------------------------------------------------------
00421 //
00422 // Synopsis: Private helper function causes the engine to wait for events
00423 //           to occur including the "stop working" event.
00424 //
00425 //+--------------------------------------------------------------------------
00426 HRESULT
00427 RqsEngine::Wait(
00428     OUT RqsEvent* pAction)
00429 {
00430     DWORD dwRet;
00431     HANDLE hEvents[6];
00432     UINT uiCount = sizeof(hEvents) / sizeof(HANDLE);
00433     HRESULT hr = S_OK;
00434
00435     hEvents[0] = m_eQuit.GetHandle();
00436     hEvents[1] = m_eSocketAccept.GetHandle();
00437     hEvents[2] = m_eConfig.GetHandle();
00438     hEvents[3] = m_eTrace.GetHandle();
00439     hEvents[4] = m_eSocketRead.GetHandle();
00440     hEvents[5] = m_eInterfaceAdded.GetHandle();
00441
00442     dwRet = WaitForMultipleObjectsEx(
00443                 uiCount,
00444                 hEvents,
00445                 FALSE,
00446                 INFINITE,
00447                 FALSE);
00448     switch (dwRet)
00449     {
00450         case WAIT_OBJECT_0:
00451             *pAction = Quit;
00452             break;
00453
00454         case WAIT_OBJECT_0 + 1:
00455             *pAction = Connect;
00456             break;
00457
00458         case WAIT_OBJECT_0 + 2:
00459             *pAction = UpdateConfig;
00460             break;
00461
00462         case WAIT_OBJECT_0 + 3:
00463             *pAction = UpdateTrace;
00464             break;
00465
00466         case WAIT_OBJECT_0 + 4:
00467             *pAction = Read;
00468             break;
00469
00470         case WAIT_OBJECT_0 + 5:
00471             *pAction = ConfigServerSocket;
00472             break;
00473
00474         default:
00475             *pAction = Error;
00476             hr = HRESULT_FROM_WIN32( GetLastError() );
00477             break;
00478     }
00479
00480     return hr;
00481 }
00482
00483 //+--------------------------------------------------------------------------
00484 //
00485 // Synopsis: Schedules a given type of work to occur.
00486 //
00487 //+--------------------------------------------------------------------------
00488 HRESULT
00489 RqsEngine::ScheduleWork(
00490     IN LPTHREAD_START_ROUTINE pFunc,
00491     IN RqsClient* pClient)
00492 {
00493     HRESULT hr;
00494     RqsEngineCbInfo* pInfo = NULL;
00495
00496     pInfo = new RqsEngineCbInfo;
00497     if (NULL == pInfo)
00498     {
00499         return E_OUTOFMEMORY;
00500     }
00501
00502     ZeroMemory(pInfo, sizeof(RqsEngineCbInfo));
00503     pInfo->pEngine = this;
00504     pInfo->pClient = pClient;
00505
00506     if (0 == QueueUserWorkItem(
00507                     pFunc,
00508                     reinterpret_cast<PVOID>(pInfo),
00509                     WT_EXECUTEINIOTHREAD))
00510     {
00511        hr = HRESULT_FROM_WIN32(GetLastError());
00512        delete pInfo; // note normally pInfo is deleted by the callback functions
00513     }
00514     else
00515     {
00516        hr = S_OK;
00517     }
00518
00519
00520     return hr;
00521 }
00522
00523 //+--------------------------------------------------------------------------
00524 //
00525 // Synopsis: Adds a client to the list that this engine is servicing
00526 //
00527 //+--------------------------------------------------------------------------
00528 HRESULT
00529 RqsEngine::ClientAdd(
00530     IN RqsClient* pClient)
00531 {
00532     HRESULT hr;
00533
00534     m_csClientsLock.Enter();
00535     hr = m_lClients.InsertBack(pClient);
00536     m_csClientsLock.Leave();
00537
00538     if (hr == S_OK)
00539     {
00540         Trace("Added client %s", pClient->GetAddressPsz());
00541         InterlockedIncrement(&m_ulClientCount);
00542     }
00543
00544     return hr;
00545 }
00546 //+--------------------------------------------------------------------------
00547 //
00548 // Synopsis: Informs the engine of a client that is leaving
00549 //
00550 //+--------------------------------------------------------------------------
00551 VOID
00552 RqsEngine::ClientRemove()
00553 {
00554     InterlockedDecrement(&m_ulClientCount);
00555 }
00556
00557 //+--------------------------------------------------------------------------
00558 //
00559 // Synopsis: Processes a client connection
00560 //
00561 //+--------------------------------------------------------------------------
00562 HRESULT
00563 RqsEngine::ClientConnect()
00564 {
00565     RuSocket* pSocket = NULL;
00566     RqsClient* pClient = NULL;
00567     HRESULT hr = S_FALSE;
00568
00569     __try
00570     {
00571         // Create a new client socket
00572         //
00573         pSocket = new RuSocket();
00574         if (NULL == pSocket)
00575         {
00576             hr = E_OUTOFMEMORY;
00577             __leave;
00578         }
00579
00580         // Create the new client control block
00581         //
00582         pClient = new RqsClient();
00583         if (pClient == NULL)
00584         {
00585             hr = E_OUTOFMEMORY;
00586             __leave;
00587         }
00588
00589         // Accept the next client socket
00590         //
00591         hr = m_sServer.Listen(pSocket);
00592         RU_LEAVE_IF_NOT_OK(hr);
00593
00594         // Assign the open client socket to the new client control block
00595         //
00596         pClient->SetEngine(this);
00597         pClient->AssignSocket(pSocket);
00598
00599         // Add this client to the engine
00600         //
00601         hr = ClientAdd(pClient);
00602         RU_LEAVE_IF_NOT_OK(hr);
00603
00604         // Cause the read event to signal when data is ready for this client
00605         //
00606         hr = pSocket->SetEvent(m_eSocketRead.GetHandle(), FD_READ);
00607         if (S_OK != hr)
00608         {
00609             Trace(
00610                 "Unable to set read event for socket %s, hr = %d",
00611                 pClient->GetAddressPsz(),
00612                 hr);
00613             hr = S_OK;
00614             __leave;
00615         }
00616
00617     }
00618
00619     __finally
00620     {
00621         if (hr != S_OK)
00622         {
00623             if (pSocket)
00624             {
00625                 delete pSocket;
00626             }
00627             if (pClient)
00628             {
00629                 delete pClient;
00630             }
00631         }
00632     }
00633
00634     return hr;
00635 }
00636
00637 //+--------------------------------------------------------------------------
00638 //
00639 // Synopsis: Reponds to the event that signals that some client has data
00640 //           ready to be read.
00641 //
00642 //+--------------------------------------------------------------------------
00643 HRESULT
00644 RqsEngine::ClientReadMessages()
00645 {
00646     HRESULT hr = S_OK;
00647     ClientList::Iterator Iter;
00648     RqsClient* pClient;
00649     RqsClientState cState;
00650
00651     m_csClientsLock.Enter();
00652
00653     for (m_lClients.GetIterator(Iter); !Iter.AtEnd(); )
00654     {
00655         pClient = Iter.GetItem();
00656         pClient->ReceiveMessage();
00657         cState = pClient->GetState();
00658
00659         if ((cState == ClientError) || (cState == ReceiveComplete))
00660         {
00661             Trace(
00662                 "Client receive %s %s (%s)",
00663                 ((cState == ReceiveComplete) ? "completed successfully for" : "failed for"),
00664                 pClient->GetAddressPsz(),
00665                 pClient->GetUsername());
00666
00667             // Remove the client from the list
00668             //
00669             Iter.Next();
00670             hr = m_lClients.RemoveItem(pClient);
00671             if (hr != S_OK)
00672             {
00673                 Trace("Unable to remove client from list %x", hr);
00674                 break;
00675             }
00676
00677             // If this client is ready to complete, schedule it to happen
00678             //
00679             if (cState == ReceiveComplete)
00680             {
00681                 // Note the client complete callback will free
00682                 // pClient and call ClientRemove when it is finished.
00683                 //
00684                 hr = ScheduleWork(ClientCompleteCb, pClient);
00685                 if (S_OK != hr)
00686                 {
00687                     Trace(
00688                         "Unable to complete client 0x%x, %s (%s)",
00689                         hr,
00690                         pClient->GetAddressPsz(),
00691                         pClient->GetUsername());
00692                     delete pClient;
00693                     ClientRemove();
00694                 }
00695             }
00696             else // ClientError state
00697             {
00698                 delete pClient;
00699                 ClientRemove();
00700             }
00701
00702             // The iterator has already been incremented at this point
00703             //
00704         }
00705         else
00706         {
00707             Iter.Next(); // client isn't done receiving, skip it
00708         }
00709
00710     }
00711
00712     m_csClientsLock.Leave();
00713
00714     return hr;
00715 }
00716
00717 //+--------------------------------------------------------------------------
00718 //
00719 // Synopsis: Thread pool callback to process the event that says a client has
00720 //           data ready to read.
00721 //
00722 //+--------------------------------------------------------------------------
00723 DWORD WINAPI
00724 RqsEngine::ClientReadCb(
00725     IN LPVOID pvContext)
00726 {
00727     HRESULT hr;
00728
00729     RqsEngineCbInfo* pInfo =
00730         reinterpret_cast<RqsEngineCbInfo*>(pvContext);
00731
00732     RqsEngine* pEngine = pInfo->pEngine;
00733
00734     hr = pEngine->ClientReadMessages();
00735
00736     if (S_OK != hr)
00737     {
00738         pEngine->Trace("Error received from ClientReadMessages %x", hr);
00739     }
00740
00741     delete pInfo;
00742
00743     return HRESULT_CODE(hr);
00744 }
00745
00746 //+--------------------------------------------------------------------------
00747 //
00748 // Synopsis: Thread pool callback to process a client connect event
00749 //
00750 //+--------------------------------------------------------------------------
00751 DWORD WINAPI
00752 RqsEngine::ClientConnectCb(IN LPVOID pvContext)
00753 {
00754     HRESULT hr;
00755
00756     RqsEngineCbInfo* pInfo =
00757         reinterpret_cast<RqsEngineCbInfo*>(pvContext);
00758
00759     RqsEngine* pEngine = pInfo->pEngine;
00760
00761     hr = pEngine->ClientConnect();
00762
00763     if (S_OK != hr)
00764     {
00765         pEngine->Trace("Error returned from ClientConnect %x", hr);
00766     }
00767
00768     delete pInfo;
00769
00770     return HRESULT_CODE(hr);
00771 }
00772
00773 //+--------------------------------------------------------------------------
00774 //
00775 // Synopsis: Thread pool callback to Connect to RRAS and Init the Server socket
00776 //
00777 //+--------------------------------------------------------------------------
00778 DWORD WINAPI
00779 RqsEngine::InitializeServerSocketCb(IN LPVOID pvContext)
00780 {
00781     HRESULT hr;
00782
00783     RqsEngineCbInfo* pInfo =
00784         reinterpret_cast<RqsEngineCbInfo*>(pvContext);
00785
00786     if (NULL == pInfo)
00787     {
00788         return ERROR_INVALID_PARAMETER;
00789     }
00790
00791     RqsEngine* pEngine = pInfo->pEngine;
00792
00793     //
00794     //  Try to connect to RRAS for up to 5 minutes
00795     //
00796     hr = pEngine->ConnectRRAS(300);
00797
00798     if (SUCCEEDED(hr))
00799     {
00800         hr = pEngine->InitializeServerSocket();
00801         if (ERROR_NO_SUCH_INTERFACE == HRESULT_CODE(hr))
00802         {
00803             hr = pEngine->RegisterForConnectionNotification();
00804             pEngine->Trace("Internal interface not found.");
00805             pEngine->Trace("Waiting for first connection so that RRAS will create the internal interface.");
00806         }
00807     }
00808
00809     delete pInfo;
00810
00811     if (S_OK != hr)
00812     {
00813         pEngine->Trace("InitializeServerSocketCb, error 0x%x, exiting.", hr);
00814         pEngine->Stop();
00815     }
00816
00817     return HRESULT_CODE(hr);
00818 }
00819
00820 //+--------------------------------------------------------------------------
00821 //
00822 // Synopsis: Thread pool callback to process a client after it has received
00823 //           its entire message.
00824 //
00825 //+--------------------------------------------------------------------------
00826 DWORD WINAPI
00827 RqsEngine::ClientCompleteCb(
00828     IN LPVOID pvContext)
00829 {
00830     HRESULT hr;
00831     RqsEngineCbInfo* pInfo =
00832         reinterpret_cast<RqsEngineCbInfo*>(pvContext);
00833
00834     if (NULL == pInfo)
00835     {
00836         return ERROR_INVALID_PARAMETER;
00837     }
00838
00839     RqsEngine* pEngine = pInfo->pEngine;
00840     RqsClient* pClient = pInfo->pClient;
00841     BOOL fAccept;
00842
00843     __try
00844     {
00845         // Make sure we're connected to the RRAS service
00846         //
00847         hr = pEngine->ConnectRRAS();
00848         if (S_OK != hr)
00849         {
00850             pEngine->Trace(
00851                 "Can't connect to RRAS service 0x%x.  Dropping client %s (%s).",
00852                 hr,
00853                 pClient->GetAddressPsz(),
00854                 pClient->GetUsername());
00855             __leave;
00856         }
00857
00858         // Figure out whether to accept the client
00859         //
00860         fAccept = pEngine->ClientAuthenticate(pClient->GetString());
00861
00862         pEngine->Trace(
00863             "[%s] %s (%s) %s",
00864             (fAccept) ? "Accept" : "Reject",
00865             pClient->GetAddressPsz(),
00866             pClient->GetUsername(),
00867             pClient->GetString()
00868             );
00869
00870         // Try to remove the quarantine
00871         //
00872         if (fAccept)
00873         {
00874             hr = pEngine->ClientClearQuarantine(pClient->GetAddressN(),
00875                      pClient->GetAddressPsz(),
00876                      pClient->GetUsername());
00877
00878             if (S_OK == hr)
00879             {
00880                 pEngine->ClientLogInfo(
00881                     RQS_LOG_SUCCESS,
00882                     pClient->GetAddressPsz(),
00883                     pClient->GetUsername(),
00884                     pClient->GetString());
00885             }
00886             else if (HRESULT_FROM_WIN32(ERROR_NOT_FOUND) == hr)
00887             {
00888                 pEngine->ClientLogInfo(
00889                     RQS_LOG_SUCCESS_BUT_NO_QUARANTINE,
00890                     pClient->GetAddressPsz(),
00891                     pClient->GetUsername(),
00892                     pClient->GetString());
00893                 hr = S_OK;
00894             }
00895             else
00896             {
00897                 pEngine->ClientLogInfo(
00898                     RQS_LOG_SUCCESS_BUT_PROBLEM_ENCOUNTERED,
00899                     pClient->GetAddressPsz(),
00900                     pClient->GetUsername(),
00901                     pClient->GetString());
00902                 pEngine->Trace("Unable to remove client quarantine. 0x%x", hr);
00903                 fAccept = FALSE;
00904             }
00905         }
00906         else
00907         {
00908             pEngine->ClientLogInfo(
00909                 RQS_LOG_REJECT,
00910                 pClient->GetAddressPsz(),
00911                 pClient->GetUsername(),
00912                 pClient->GetString());
00913         }
00914
00915         hr = pClient->SendResponse(fAccept);
00916         RU_LEAVE_IF_NOT_OK(hr);
00917
00918     }
00919
00920     __finally
00921     {
00922         delete pInfo;
00923         delete pClient;
00924         pEngine->ClientRemove();
00925     }
00926
00927     return HRESULT_CODE(hr);
00928 }
00929
00930 //+--------------------------------------------------------------------------
00931 //
00932 // Synopsis: Authenticates a client
00933 //
00934 //+--------------------------------------------------------------------------
00935 BOOL
00936 RqsEngine::ClientAuthenticate(
00937     IN CHAR* pszString)
00938 {
00939     HRESULT hr;
00940     BOOL fOk;
00941
00942     hr = m_rwlConfig.Lock(READER);
00943     if (S_OK != hr)
00944     {
00945         Trace("Unable to lock configuration object.");
00946         return FALSE;
00947     }
00948
00949     fOk = m_Config.Find(pszString);
00950
00951     hr = m_rwlConfig.Unlock(READER);
00952     if (hr != S_OK)
00953     {
00954         Trace("Unable to unlock configuration object.");
00955         return FALSE;
00956     }
00957
00958     return fOk;
00959 }
00960
00961 //+--------------------------------------------------------------------------
00962 //
00963 // Synopsis: Removes a client's quarantine
00964 //
00965 //+--------------------------------------------------------------------------
00966 HRESULT
00967 RqsEngine::ClientClearQuarantine(
00968     IN DWORD dwAddress,
00969     CONST CHAR* pszAddress,
00970     CONST CHAR* pszUsername)
00971 {
00972     HRESULT hr = S_FALSE;
00973
00974     if (m_qFunc != NULL)
00975     {
00976         Trace("Removing Quarantine on IP address %s (%s)", pszAddress, pszUsername);
00977
00978         //  Here is where we call MprAdminConnectionRemoveQuarantine to
00979         //  remove the client's quarantine IP Filters or its quarantine
00980         //  disconnect timer.  Note that we use the client's IP address
00981         //  to uniquely identify it to the RRAS server.  We also could
00982         //  have used a handle to the RAS connection.
00983         //
00984         DWORD dwError = m_qFunc(m_hServer, UlongToPtr(dwAddress), TRUE);
00985
00986         if (dwError == ERROR_NOT_FOUND)
00987         {
00988             Trace("Quarantine removal failed, user was either never quarantined or was already removed from quarantine.");
00989         }
00990         else if (dwError != ERROR_SUCCESS)
00991         {
00992             Trace("Quarantine removal failed, error %d.", dwError);
00993         }
00994
00995         hr = HRESULT_FROM_WIN32(dwError);
00996     }
00997     else
00998     {
00999         Trace("Quarantine support not available.");
01000     }
01001
01002     return hr;
01003 }
01004
01005 //+--------------------------------------------------------------------------
01006 //
01007 // Synopsis: Reloads configuration
01008 //
01009 //+--------------------------------------------------------------------------
01010 HRESULT
01011 RqsEngine::ReloadTrace()
01012 {
01013     HRESULT hr, hr2;
01014
01015     hr = m_rwlConfig.Lock(WRITER);
01016     if (S_OK != hr)
01017     {
01018         Trace("Unable to lock configuration object.");
01019         return hr;
01020     }
01021
01022     __try
01023     {
01024         hr = m_Config.LoadTrace();
01025         if (S_OK != hr)
01026         {
01027             Trace("Unable to reload configuration trace.");
01028         }
01029
01030         hr2 = m_rwlConfig.Unlock(WRITER);
01031         if (hr2 != S_OK)
01032         {
01033             Trace("Unable to unlock configuration object.");
01034         }
01035         RU_LEAVE_IF_NOT_OK(hr);
01036
01037         // Assign the new trace values.
01038         //
01039         m_fRtTrace = m_Config.GetTraceEnabled();
01040         TraceSelf();
01041
01042         // Re-register the configuration event
01043         //
01044         hr = RegNotifyChangeKeyValue(
01045                 m_hkTrace,
01046                 FALSE,
01047                 REG_NOTIFY_CHANGE_LAST_SET,
01048                 m_eTrace.GetHandle(),
01049                 TRUE);
01050         if (hr != ERROR_SUCCESS)
01051         {
01052             Trace("Warning: unable to re-setup trace event %x", hr);
01053             hr = S_OK;
01054         }
01055
01056     }
01057
01058     __finally
01059     {
01060     }
01061
01062     return hr;
01063 }
01064
01065 //+--------------------------------------------------------------------------
01066 //
01067 // Synopsis: Reloads configuration
01068 //
01069 //+--------------------------------------------------------------------------
01070 HRESULT
01071 RqsEngine::ReloadConfig()
01072 {
01073     HRESULT hr, hr2;
01074
01075     hr = m_rwlConfig.Lock(WRITER);
01076     if (S_OK != hr)
01077     {
01078         Trace("Unable to lock configuration object.");
01079         return hr;
01080     }
01081
01082     __try
01083     {
01084         m_Config.Clear();
01085         hr = m_Config.LoadConfig();
01086         if (S_OK != hr)
01087         {
01088             Trace("Unable to reload configuration object.");
01089         }
01090
01091         hr2 = m_rwlConfig.Unlock(WRITER);
01092         if (hr2 != S_OK)
01093         {
01094             Trace("Unable to unlock configuration object.");
01095         }
01096         RU_LEAVE_IF_NOT_OK(hr);
01097
01098         // Assign the new configuration values.  Note that the accepted
01099         // value set has been updated at this point.
01100         //
01101         m_fDebugTrace = m_Config.GetDebugTrace();
01102         TraceSelf();
01103
01104         // Re-register the configuration event
01105         //
01106         hr = RegNotifyChangeKeyValue(
01107                 m_hkConfig,
01108                 FALSE,
01109                 REG_NOTIFY_CHANGE_LAST_SET,
01110                 m_eConfig.GetHandle(),
01111                 TRUE);
01112         if (hr != ERROR_SUCCESS)
01113         {
01114             Trace("Warning: unable to re-setup config event %x", hr);
01115             hr = S_OK;
01116         }
01117
01118     }
01119
01120     __finally
01121     {
01122     }
01123
01124     return hr;
01125 }
01126
01127 //+--------------------------------------------------------------------------
01128 //
01129 // Synopsis: Common tracing api.
01130 //
01131 //+--------------------------------------------------------------------------
01132 VOID
01133 RqsEngine::Trace(
01134     IN LPSTR pszTrace,
01135     IN ...) const
01136 {
01137     va_list arglist;
01138     CHAR szTemp[2048];
01139     HANDLE hFileOut;
01140     INT iCount;
01141     DWORD dwTemp;
01142
01143     szTemp[0] = 0;
01144
01145     if ((!m_fConsoleTrace) && (!m_fDebugTrace) && (!m_fRtTrace))
01146     {
01147         return;
01148     }
01149
01150     va_start(arglist, pszTrace);
01151     iCount = _vsnprintf(szTemp, sizeof(szTemp)/sizeof(szTemp[0]) - 1, pszTrace, arglist);
01152     va_end(arglist);
01153
01154     szTemp[sizeof(szTemp)/sizeof(szTemp[0]) - 1] = 0; // make sure to NULL terminate as _vsnprintf doesn't guarantee that
01155
01156     // If we're running in stand-alone mode, output to the console
01157     //
01158     if ((m_fConsoleTrace))
01159     {
01160         hFileOut = GetStdHandle(STD_OUTPUT_HANDLE);
01161         WriteFile(hFileOut, szTemp, iCount, &dwTemp, NULL);
01162         WriteFile(hFileOut, "\n", 2, &dwTemp, NULL);
01163     }
01164
01165     // If we're running as a service, then output to the trace logs
01166     //
01167     else if (m_fRtTrace)
01168     {
01169         if (m_dwTraceId != INVALID_TRACEID)
01170         {
01171             TracePrintfA(m_dwTraceId, szTemp);
01172         }
01173     }
01174
01175     // If the m_fDebugTrace variable has been set in the debugger, then
01176     // output to the debugger
01177     //
01178     if (m_fDebugTrace)
01179     {
01180         OutputDebugStringA(szTemp);
01181         OutputDebugStringA("\n");
01182     }
01183
01184 }
01185
01186 //+--------------------------------------------------------------------------
01187 //
01188 // Synopsis: Traces out this engine instance.
01189 //
01190 //+--------------------------------------------------------------------------
01191 VOID
01192 RqsEngine::TraceSelf()
01193 {
01194     Trace("Engine object:");
01195     Trace("==============");
01196     Trace("Client count:   %d", m_ulClientCount);
01197     Trace("Service:        %x", m_hService);
01198     Trace("Checkpoint:     %d", m_dwCheckPoint);
01199     Trace("Mpr handle:     %x", m_hInstMprApi);
01200     Trace("Mprs handle:    %x", m_hServer);
01201     Trace("Console trace:  %d", m_fConsoleTrace);
01202     Trace("Debug Trace:    %d", m_fDebugTrace);
01203     Trace("RtUtils Trace:  %d", m_fRtTrace);
01204     Trace("Trace Id:       %d", m_dwTraceId);
01205     Trace("Trace key:      %x", m_hkTrace);
01206     Trace("Config key:     %x", m_hkConfig);
01207     Trace("Internal IP:    %s", (m_szInternalAddress[0] ? m_szInternalAddress : "<Unable to connect to RRAS>"));
01208
01209     Trace("Configuration object:");
01210     Trace("=====================");
01211     m_Config.TraceSelf(*this);
01212 }
01213
01214 //+--------------------------------------------------------------------------
01215 //
01216 // Synopsis: Figures out what type of event log message we are logging.
01217 //
01218 //+--------------------------------------------------------------------------
01219 WORD RqsEngine::GetEventType(DWORD dwEventId)
01220 {
01221     WORD wEventType;
01222
01223     DWORD dwSeverity = (dwEventId >> 30) & 0x3;
01224
01225     switch(dwSeverity)
01226     {
01227         case 0:
01228             wEventType = EVENTLOG_SUCCESS;
01229             break;
01230         case 1:
01231             wEventType = EVENTLOG_INFORMATION_TYPE;
01232             break;
01233         case 2:
01234             wEventType = EVENTLOG_WARNING_TYPE;
01235             break;
01236         case 3:
01237         default:
01238             wEventType = EVENTLOG_ERROR_TYPE;
01239             break;
01240     }
01241
01242     return wEventType;
01243 }
01244
01245 //+--------------------------------------------------------------------------
01246 //
01247 // Synopsis: Records success or failure to the event log.
01248 //
01249 //+--------------------------------------------------------------------------
01250 VOID
01251 RqsEngine::ClientLogInfo(
01252     IN DWORD dwEventId,
01253     IN CONST CHAR* pszIp,
01254     IN CONST CHAR* pszUsername,
01255     IN CONST CHAR* pszString)
01256 {
01257     WCHAR *pszAddressW = NULL, *pszStringW = NULL, *pszUsernameW = NULL, *pszArgs[3];
01258     BOOL fOk;
01259
01260     pszAddressW = RuStringDupAtoW(const_cast<PSTR>(pszIp));
01261     pszStringW = RuStringDupAtoW(const_cast<PSTR>(pszString));
01262     pszUsernameW = RuStringDupAtoW(const_cast<PSTR>(pszUsername));
01263
01264     pszArgs[0] = (pszAddressW) ? pszAddressW : L"";
01265     pszArgs[1] = (pszUsernameW) ? pszUsernameW : L"";
01266     pszArgs[2] = (pszStringW) ? pszStringW : L"";
01267
01268     fOk = ReportEvent(
01269                 m_hLog,
01270                 GetEventType(dwEventId),
01271                 0,
01272                 dwEventId,
01273                 NULL,
01274                 3,
01275                 0,
01276                 (LPCWSTR *)pszArgs,
01277                 NULL);
01278     if (! fOk)
01279     {
01280         Trace("ReportEvent error %x", GetLastError());
01281     }
01282
01283     if (pszStringW)
01284     {
01285         RuFree( pszStringW );
01286     }
01287
01288     if (pszAddressW)
01289     {
01290         RuFree( pszAddressW );
01291     }
01292
01293     if (pszUsernameW)
01294     {
01295         RuFree( pszUsernameW );
01296     }
01297
01298 }
01299
01300 //+--------------------------------------------------------------------------
01301 //
01302 // Synopsis: Gets the IP address for the given interface identifier
01303 //
01304 //+--------------------------------------------------------------------------
01305 DWORD
01306 RqsEngine::GetIpAddressFromInterfaceIndex(
01307     IN DWORD dwInterfaceId,
01308     OUT CHAR* pszIpAddress,
01309     IN DWORD dwCount)
01310 {
01311     if ((NULL == pszIpAddress) || (0 == dwCount))
01312     {
01313         return ERROR_INVALID_PARAMETER;
01314     }
01315
01316     PMIB_IPADDRTABLE pIpAddrTable = NULL;
01317     DWORD dwSize = 0;
01318     DWORD dwRet;
01319
01320     __try
01321     {
01322         // Figure out how much memory we need
01323         //
01324         dwRet = GetIpAddrTable (NULL, &dwSize, TRUE);
01325
01326         if (ERROR_INSUFFICIENT_BUFFER != dwRet)
01327         {
01328             __leave;
01329         }
01330
01331         pIpAddrTable = (PMIB_IPADDRTABLE)RuAlloc(dwSize, TRUE);
01332
01333         if (!pIpAddrTable)
01334         {
01335             dwRet = ERROR_NOT_ENOUGH_MEMORY;
01336             __leave;
01337         }
01338
01339         // Actually get the IP address table.
01340         //
01341         dwRet = GetIpAddrTable (pIpAddrTable, &dwSize, TRUE);
01342
01343         if (ERROR_SUCCESS != dwRet)
01344         {
01345             __leave;
01346         }
01347
01348         //  Init the Ip Address string to the empty string
01349         //
01350         pszIpAddress[0] = '\0';
01351
01352         // Find the required index.
01353         //
01354         for (DWORD dwLoopIndex = 0; dwLoopIndex < pIpAddrTable->dwNumEntries; dwLoopIndex++)
01355         {
01356             if (pIpAddrTable->table[dwLoopIndex].dwIndex == dwInterfaceId)
01357             {
01358                 //  Print the IP address into the string
01359                 //
01360                 DWORD dwAddr = pIpAddrTable->table[dwLoopIndex].dwAddr;
01361                 _snprintf(pszIpAddress, dwCount, "%d.%d.%d.%d", IP4(dwAddr), IP3(dwAddr), IP2(dwAddr), IP1(dwAddr));
01362
01363                 //
01364                 //  Ensure NULL termination
01365                 //
01366                 pszIpAddress[dwCount - 1] = '\0';
01367
01368                 break;
01369             }
01370         }
01371
01372         // Make sure we found something.
01373         //
01374         if (pszIpAddress[0] == '\0')
01375         {
01376             dwRet = ERROR_NOT_FOUND;
01377         }
01378     }
01379
01380     __finally
01381     {
01382         if (pIpAddrTable)
01383         {
01384             RuFree(pIpAddrTable);
01385         }
01386     }
01387
01388     return dwRet;
01389 }
01390
01391
01392 //+--------------------------------------------------------------------------
01393 //
01394 // Synopsis: Gets the IP address for the given interface name
01395 //
01396 //+--------------------------------------------------------------------------
01397 DWORD
01398 RqsEngine::GetIpAddressFromInterfaceName(
01399     IN CONST WCHAR* pwszInterfaceName,
01400     OUT CHAR* pszIpAddress,
01401     IN DWORD dwCount)
01402 {
01403     if ((NULL == pwszInterfaceName) || (NULL == pszIpAddress) || (0 == dwCount))
01404     {
01405         return ERROR_INVALID_PARAMETER;
01406     }
01407
01408     //  First we need to call GetIfTable to get the list of interfaces to match
01409     //  against the one passed in.  Once we have found our interface in the
01410     //  interface table, then we will have the associated interface index that we
01411     //  can use with the the IP address table to get the associated IP address for our interface.
01412     //
01413     DWORD dwRet;
01414     DWORD dwSize = 0;
01415     PMIB_IFTABLE pInterfaceTable = NULL;
01416     PMIB_IFROW pInterface = NULL;
01417
01418     __try
01419     {
01420         // Figure out how much memory we need.
01421         //
01422         dwRet = GetIfTable(NULL, &dwSize, TRUE);
01423
01424         if (ERROR_INSUFFICIENT_BUFFER != dwRet)
01425         {
01426             __leave;
01427         }
01428
01429         pInterfaceTable = (PMIB_IFTABLE)RuAlloc(dwSize, TRUE);
01430
01431         if (!pInterfaceTable)
01432         {
01433             dwRet = ERROR_NOT_ENOUGH_MEMORY;
01434             __leave;
01435         }
01436
01437         // Actually get the interface table.
01438         //
01439         dwRet = GetIfTable(pInterfaceTable, &dwSize, TRUE);
01440
01441         if (ERROR_SUCCESS != dwRet)
01442         {
01443             __leave;
01444         }
01445
01446         // Find the interface index.  If we cannot find the requested
01447         // interface name, return ERROR_NO_SUCH_INTERFACE.  This is a
01448         // signal to the caller that RRAS may not have created the
01449         // reqested interface yet.
01450         //
01451         dwRet = ERROR_NO_SUCH_INTERFACE;
01452         for (DWORD dwIndex = 0; dwIndex < pInterfaceTable->dwNumEntries; dwIndex++)
01453         {
01454             pInterface = &(pInterfaceTable->table[dwIndex]);
01455             if (0 == lstrcmpiW(pInterface->wszName, pwszInterfaceName))
01456             {
01457                 // Use the interface index to get the IP address
01458                 //
01459                 dwRet = GetIpAddressFromInterfaceIndex (pInterface->dwIndex, pszIpAddress, dwCount);
01460                 break;
01461             }
01462         }
01463     }
01464
01465     __finally
01466     {
01467         if (pInterfaceTable)
01468         {
01469             RuFree(pInterfaceTable);
01470         }
01471     }
01472
01473     return dwRet;
01474 }
01475
01476 //+--------------------------------------------------------------------------
01477 //
01478 // Synopsis: Returns the IP Address of the internal interface of RRAS
01479 //
01480 //+--------------------------------------------------------------------------
01481 HRESULT
01482 RqsEngine::GetInternalIpAddress(
01483     OUT CHAR* pszIpAddress,
01484     IN DWORD dwCount)
01485  {
01486     // Check inputs
01487     //
01488     if ((NULL == pszIpAddress) || (0 == dwCount))
01489     {
01490         return E_INVALIDARG;
01491     }
01492
01493     DWORD dwRet;
01494     HANDLE hMprConfig = NULL;
01495     MPR_INTERFACE_0* pMprInterface = NULL;
01496     DWORD dwNumEntries = 0;
01497     DWORD dwTotalEntries = 0;
01498
01499     //  First call MprConfigServerConnect so we can get a config handle
01500     //
01501     __try
01502     {
01503         dwRet = MprConfigServerConnect(NULL, &hMprConfig);
01504
01505         if (NO_ERROR != dwRet)
01506         {
01507             __leave;
01508         }
01509
01510         //  Get the interfaces that RRAS knows about.
01511         //
01512         dwRet = MprConfigInterfaceEnum(hMprConfig, 0, (LPBYTE*)&pMprInterface, -1, &dwNumEntries, &dwTotalEntries, NULL);
01513
01514         if ((NO_ERROR != dwRet) || (dwNumEntries != dwTotalEntries))
01515         {
01516             __leave;
01517         }
01518
01519         //  Find the internal interface
01520         //
01521         dwRet = ERROR_NOT_FOUND;
01522         for (DWORD dwIndex = 0; dwIndex < dwNumEntries; dwIndex++)
01523         {
01524             if (ROUTER_IF_TYPE_INTERNAL == pMprInterface[dwIndex].dwIfType)
01525             {
01526                 //  Now all we need to do is find the IP address of the internal interface.
01527                 //
01528                 dwRet = GetIpAddressFromInterfaceName (pMprInterface[dwIndex].wszInterfaceName, pszIpAddress, dwCount);
01529
01530                 if (ERROR_SUCCESS == dwRet)
01531                 {
01532                     Trace("Internal interface found, %s", pszIpAddress);
01533                 }
01534                 __leave;
01535             }
01536         }
01537     }
01538
01539     __finally
01540     {
01541         if (pMprInterface)
01542         {
01543             MprConfigBufferFree(pMprInterface);
01544         }
01545
01546         if (hMprConfig)
01547         {
01548             MprConfigServerDisconnect(hMprConfig);
01549         }
01550     }
01551
01552     return HRESULT_FROM_WIN32(dwRet);
01553 }
01554
01555 //+--------------------------------------------------------------------------
01556 //
01557 // Synopsis: Initializes the socket that RQS uses to listen for requests.
01558 //
01559 //+--------------------------------------------------------------------------
01560 HRESULT
01561 RqsEngine::InitializeServerSocket()
01562 {
01563     HRESULT hr;
01564
01565     // Attempt to connect to the RRAS service.  We need to connect to
01566     // the RRAS service so we can figure out the correct interface to
01567     // listen on ... ie. the internal interface.
01568     //
01569     __try
01570     {
01571         hr = ConnectRRAS();
01572         RU_LEAVE_IF_NOT_OK(hr);
01573
01574         hr = GetInternalIpAddress(m_szInternalAddress, sizeof(m_szInternalAddress));
01575         RU_LEAVE_IF_NOT_OK(hr);
01576
01577         hr = m_sServer.Create(m_Config.GetPort(), m_szInternalAddress);
01578
01579         if (HRESULT_CODE(hr) == WSAEADDRINUSE)
01580         {
01581             Trace("\n\tUnable to acquire port %d.  Make sure that RQS is not already", m_Config.GetPort());
01582             Trace("\trunning or that another application is not already using this port.\n");
01583         }
01584         else if (SUCCEEDED(hr))
01585         {
01586             HANDLE hEvent = m_eSocketAccept.GetHandle();
01587
01588             if (NULL == hEvent)
01589             {
01590                 __leave;
01591             }
01592
01593             // Signal whenever a new connection arrives
01594             //
01595             hr = m_sServer.SetEvent(hEvent);
01596             RU_LEAVE_IF_NOT_OK(hr);
01597         }
01598     }
01599
01600     __finally
01601     {
01602     }
01603
01604
01605     return hr;
01606 }
01607
01608 //+--------------------------------------------------------------------------
01609 //
01610 // Synopsis: Registers for connection notifications from RRAS
01611 //
01612 //+--------------------------------------------------------------------------
01613 HRESULT
01614 RqsEngine::RegisterForConnectionNotification()
01615 {
01616     DWORD dwRet;
01617
01618     __try
01619     {
01620         HANDLE hEvent = m_eInterfaceAdded.GetHandle();
01621
01622         if (NULL == hEvent)
01623         {
01624             // m_eInterfaceAdded isn't initialized yet.
01625             //
01626             dwRet = ERROR_INVALID_HANDLE;
01627             __leave;
01628         }
01629
01630         HRESULT hr = ConnectRRAS();
01631         if (FAILED(hr))
01632         {
01633             dwRet = HRESULT_CODE(hr);
01634             __leave;
01635         }
01636
01637         dwRet = MprAdminRegisterConnectionNotification(m_hServer, hEvent);
01638
01639         if (ERROR_SUCCESS == dwRet)
01640         {
01641             m_bRegisteredForConnectionNotification = TRUE;
01642         }
01643     }
01644
01645     __finally
01646     {
01647     }
01648
01649     return HRESULT_FROM_WIN32(dwRet);
01650 }
01651
01652 //+--------------------------------------------------------------------------
01653 //
01654 // Synopsis: Deregisters for connection notifications from RRAS
01655 //
01656 //+--------------------------------------------------------------------------
01657 HRESULT
01658 RqsEngine::DeregisterForConnectionNotification()
01659 {
01660     DWORD dwRet;
01661
01662     __try
01663     {
01664         HANDLE hEvent = m_eInterfaceAdded.GetHandle();
01665
01666         if (NULL == hEvent)
01667         {
01668             // m_eInterfaceAdded isn't initialized yet.
01669             //
01670             dwRet = ERROR_INVALID_HANDLE;
01671             __leave;
01672         }
01673
01674         HRESULT hr = ConnectRRAS();
01675         if (FAILED(hr))
01676         {
01677             dwRet = HRESULT_CODE(hr);
01678             __leave;
01679         }
01680
01681         dwRet = MprAdminDeregisterConnectionNotification(m_hServer, hEvent);
01682
01683         if (ERROR_SUCCESS == dwRet)
01684         {
01685             m_bRegisteredForConnectionNotification = FALSE;
01686         }
01687     }
01688
01689     __finally
01690     {
01691     }
01692
01693     return HRESULT_FROM_WIN32(dwRet);
01694 }
01695
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/sky.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

sky.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Sky.h"
00021
00022 const GUID CSkyBasedVehicle::thisGuid = { 0x2974380f, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CSkyBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBackground Member List

This is the complete list of members for CBackground, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CBackground(int id) | CBackground | [inline]
CBackground(int id) | CBackground | [inline]
CBackground(int id) | CBackground | [inline]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CBackground | [inline, virtual]
GetBitmapIndex() | CBackground | [inline, virtual]
GetBitmapIndex() | CBackground | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CBackground | [virtual]
GetDisplayName(int nCol=0) | CBackground | [virtual]
GetDisplayName(int nCol=0) | CBackground | [virtual]
GetHandle() | CBackground | [inline]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CBackground | [inline, virtual]
getNodeType() | CBackground | [inline, virtual]
getNodeType() | CBackground | [inline, virtual]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
IDM_NEW_BACKGROUND enum value | CBackground | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_id | CBackground | [private]
m_itemId | CBackground | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HSCOPEITEM itemId) | CBackground | [inline]
CDelegationBase::SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CBackground | [private, static]
~CBackground() | CBackground | [inline, virtual]
~CBackground() | CBackground | [inline, virtual]
~CBackground() | CBackground | [inline, virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Fields Member List

This is the complete list of members for msado15::Fields, including all inherited members.
_Append(String Name, int Type, int DefinedSize, int Attrib) | msado15::Fields |
_NewEnum() | msado15::Fields |
Append(String Name, int Type, int DefinedSize, int Attrib, Variant FieldValue) | msado15::Fields |
Delete(Variant Index) | msado15::Fields |
getCount() | msado15::Fields |
getItem(Variant Index) | msado15::Fields |
iid | msado15::Fields | [static]
Refresh() | msado15::Fields |
Update() | msado15::Fields |
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/globals.h Source File

  • SysMgmt
  • MMC
  • CMenu

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025   #define IDM_BUTTON1    0x100
00026   #define IDM_BUTTON2    0x101
00027
00028   extern HINSTANCE g_hinst;
00029   extern ULONG g_uObjects;
00030
00031   #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032   #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034   // uncomment the following #define to enable message cracking
00035   // #define MMC_CRACK_MESSAGES
00036   void MMCN_Crack(BOOL bComponentData,
00037           IDataObject *pDataObject,
00038           IComponentData *pCompData,
00039           IComponent *pComp,
00040           MMC_NOTIFY_TYPE event,
00041           LPARAM arg,
00042           LPARAM param);
00043 #endif
00044
00045 //=--------------------------------------------------------------------------=
00046 // allocates a temporary buffer that will disappear when it goes out of scope
00047 // NOTE: be careful of that -- make sure you use the string in the same or
00048 // nested scope in which you created this buffer. people should not use this
00049 // class directly.  use the macro(s) below.
00050 //
00051 class TempBuffer {
00052   public:
00053     TempBuffer(ULONG cBytes) {
00054         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00055         m_fHeapAlloc = (cBytes > 120);
00056     }
00057     ~TempBuffer() {
00058         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00059     }
00060     void *GetBuffer() {
00061         return m_pBuf;
00062     }
00063
00064   private:
00065     void *m_pBuf;
00066     // we'll use this temp buffer for small cases.
00067     //
00068     char  m_szTmpBuf[120];
00069     unsigned m_fHeapAlloc:1;
00070 };
00071
00072 //=--------------------------------------------------------------------------=
00073 // string helpers.
00074 //
00075 // given a _TCHAR, copy it into a wide buffer.
00076 // be careful about scoping when using this macro!
00077 //
00078 // how to use the below two macros:
00079 //
00080 //  ...
00081 //  LPTSTR pszT;
00082 //  pszT = MyGetTStringRoutine();
00083 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00084 //  MyUseWideStringRoutine(pwsz);
00085 //  ...
00086 #ifdef UNICODE
00087 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00088     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00089     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00090     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00091     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00092 #else // ANSI
00093 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00094     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00095     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00096     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00097     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00098     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00099 #endif
00100
00101 #ifdef UNICODE
00102 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00103     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00104     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00105     lstrcpyW((LPWSTR)ptrname, tstr)
00106 #else // ANSI
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00109     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00110     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00111     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00112 #endif
00113
00114 //
00115 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00116 // have to be declared, and no clean up must be done.
00117 //
00118 // * 2 for DBCS handling in below length computation
00119 //
00120 #ifdef UNICODE
00121 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00122     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00123     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00124     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00125     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00126 #else // ANSI
00127 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00128     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00129     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00130     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00131     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00132 #endif
00133
00134 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/virtualfile.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

virtualfile.h

Go to the documentation of this file.
00001  /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Defines a virtual file class derived from CBaseNode.  This
00014 //             class will represent our result items
00015 //
00016
00017
00018 #ifndef _CLASS_VIRTUALFILE_
00019 #define _CLASS_VIRTUALFILE_
00020
00021 #include "Globals.h"
00022 #include "BaseNode.h"
00023
00024
00025 class CFolderNode;           // References
00026 class CComponentData;
00027
00028 //---------------------------------------------------------------------------
00029 class CVirtualFile : public CBaseNode
00030 {
00031   public:
00032     CVirtualFile();
00033     virtual ~CVirtualFile();
00034
00035     HRESULT Initialize( NODE_PROPERTIES* pNodeProps );
00036
00037   ///////////////////////////////////////////////////////////////////////////
00038   // Virtual methods
00039   public:
00040     ULONG   GetNodeType() { return NODETYPE_VFILE; }
00041     GUID&   GetNodeGUID() { return thisGUID; }
00042     HRESULT GetProperty( BSTR bstrPropertyName, PBSTR pbstrProperty );
00043
00044     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo )
00045             { return E_NOTIMPL; }
00046
00047     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI )
00048             { return E_NOTIMPL; }
00049
00050     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00051
00052   ///////////////////////////////////////////////////////////////////////////
00053   //  Notification handlers
00054   //
00055   public:
00056     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00057     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00058     HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00059     HRESULT OnDelete( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00060     HRESULT OnViewChange( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00061             { return E_NOTIMPL; }
00062
00063     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData )
00064             { return E_NOTIMPL; }
00065
00066     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData )
00067             { return E_NOTIMPL; }
00068
00069   ///////////////////////////////////////////////////////////////////////////
00070   //  Context Menu methods
00071   //
00072   public:
00073     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00074     HRESULT Command( long lCommandID );
00075
00076   private:
00077     static GUID      thisGUID;
00078     CFolderNode*     m_pParentFolder;
00079     CComponentData*  m_pCompData;
00080     DWORD            m_dwAttributes;       // Attribute flags
00081     WCHAR            m_pAttribStr[16];     // Attribute string
00082     WCHAR            m_pDescripStr[64];     // Description string
00083     SYSTEMTIME       m_InitTime;
00084
00085
00086   public:
00087     BOOL    IsAttributeSet( DWORD dwAttribute );
00088     VOID    SetAttribute( DWORD dwAttribute );
00089     VOID    RemoveAttribute( DWORD dwAttribute );
00090     LPWSTR  GetAttributeString();
00091     LPWSTR  GetDescriptionString() { return m_pDescripStr; }
00092     DWORD   GetAttributes()  { return m_dwAttributes; }
00093
00094 };
00095
00096 #endif //_CLASS_VIRTUALFILE_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/Sample.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

Sample.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SAMPLE.CPP
00003
00004   Summary:   Implementation file for the COLicCarSample sample utility COM
00005              object.  This object exposes the ISample interface that is
00006              used to allow better integration of server with client as a
00007              code sample (eg, set up trace logging from server to client's
00008              log display).
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial LICSERVE.HTM file.
00012              For more specific technical details on the internal workings
00013              see the comments dispersed throughout the module's source code.
00014
00015   Classes:   COLicCarSample.
00016
00017   Functions:
00018
00019   Origin:    10-5-95: atrent - Editor-inheritance from SAMPLE.CPP in
00020                the DLLSERVE Tutorial Code Sample.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 /*---------------------------------------------------------------------------
00038   We include WINDOWS.H for all Win32 applications.
00039   We include OLE2.H because we will be calling the COM/OLE Libraries.
00040   We include APPUTIL.H because we will be building this DLL using
00041     the convenient Virtual Window and Dialog classes and other
00042     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00043   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00044     class, GUID, and CLSID specifications.
00045   We include SERVER.H for the object class declarations for the
00046     CServer server control object.
00047   We include SAMPLE.H for the object class declarations for the
00048     COLicCarSample COM object.
00049 ---------------------------------------------------------------------------*/
00050 #include <windows.h>
00051 #include <ole2.h>
00052 #include <apputil.h>
00053 #include <icars.h>
00054 #include <carguids.h>
00055 #include "server.h"
00056 #include "sample.h"
00057
00058 /*---------------------------------------------------------------------------
00059   Implementation the COLicCarSample COM object.  Used to expose a utility
00060   server interface for the server as a code sample.  COLicCarSample exposes
00061   the ISample interface.
00062 ---------------------------------------------------------------------------*/
00063
00064 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00065   Method:   COLicCarSample::COLicCarSample
00066
00067   Summary:  COLicCarSample Constructor. Note the member initializer:
00068             "m_ImpISample(this, pUnkOuter, pServer)" which is used to pass
00069             the 'this', pUnkOuter, and pServer pointers of this
00070             constructor function to the constructor in the instantiation
00071             of the implementation of the CImpISample interface (which is
00072             nested inside this present COLicCarSample Object Class).
00073
00074   Args:     IUnknown* pUnkOuter,
00075               Pointer to the the outer Unknown.  NULL means this COM Object
00076               is not being Aggregated.  Non NULL means it is being created
00077               on behalf of an outside COM object that is reusing it via
00078               aggregation.
00079             CServer* pServer
00080               Pointer to the server's control object.
00081
00082   Modifies: m_cRefs, m_pUnkOuter.
00083
00084   Returns:  void
00085 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00086 COLicCarSample::COLicCarSample(
00087   IUnknown* pUnkOuter,
00088   CServer* pServer) :
00089   m_ImpISample(this, pUnkOuter, pServer)
00090 {
00091   // Zero the COM object's reference count.
00092   m_cRefs = 0;
00093
00094   // No AddRef necessary if non-NULL, as we're nested.
00095   m_pUnkOuter = pUnkOuter;
00096
00097   // Init the pointer to the server's control object.
00098   m_pServer = pServer;
00099
00100   LOGF1("P: COLicCarSample Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00101
00102   return;
00103 }
00104
00105
00106 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00107   Method:   COLicCarSample::~COLicCarSample
00108
00109   Summary:  COLicCarSample Destructor.
00110
00111   Args:     void
00112
00113   Modifies: .
00114
00115   Returns:  void
00116 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00117 COLicCarSample::~COLicCarSample(void)
00118 {
00119   LOG("P: COLicCarSample::Destructor.");
00120
00121   return;
00122 }
00123
00124
00125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00126   Method:   COLicCarSample::QueryInterface
00127
00128   Summary:  QueryInterface of the COLicCarSample non-delegating
00129             IUnknown implementation.
00130
00131   Args:     REFIID riid,
00132               [in] GUID of the Interface being requested.
00133             PPVOID ppv)
00134               [out] Address of the caller's pointer variable that will
00135               receive the requested interface pointer.
00136
00137   Modifies: .
00138
00139   Returns:  HRESULT
00140 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00141 STDMETHODIMP COLicCarSample::QueryInterface(
00142                REFIID riid,
00143                PPVOID ppv)
00144 {
00145   HRESULT hr = E_NOINTERFACE;
00146   *ppv = NULL;
00147
00148   if (IID_IUnknown == riid)
00149   {
00150     *ppv = this;
00151     LOG("P: COLicCarSample::QueryInterface. 'this' pIUnknown returned.");
00152   }
00153   else if (IID_ISample == riid)
00154   {
00155     *ppv = &m_ImpISample;
00156     LOG("P: COLicCarSample::QueryInterface. pISample returned.");
00157   }
00158
00159   if (NULL != *ppv)
00160   {
00161     // We've handed out a pointer to the interface so obey the COM rules
00162     // and AddRef the reference count.
00163     ((LPUNKNOWN)*ppv)->AddRef();
00164     hr = NOERROR;
00165   }
00166
00167   return (hr);
00168 }
00169
00170
00171 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00172   Method:   COLicCarSample::AddRef
00173
00174   Summary:  AddRef of the COLicCarSample non-delegating IUnknown
00175             implementation.
00176
00177   Args:     void
00178
00179   Modifies: m_cRefs.
00180
00181   Returns:  ULONG
00182               New value of m_cRefs (COM object's reference count).
00183 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00184 STDMETHODIMP_(ULONG) COLicCarSample::AddRef(void)
00185 {
00186   m_cRefs++;
00187
00188   LOGF1("P: COLicCarSample::AddRef. New cRefs=%i.", m_cRefs);
00189
00190   return m_cRefs;
00191 }
00192
00193
00194 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00195   Method:   COLicCarSample::Release
00196
00197   Summary:  Release of the COLicCarSample non-delegating IUnknown
00198             implementation.
00199
00200   Args:     void
00201
00202   Modifies: m_cRefs.
00203
00204   Returns:  ULONG
00205               New value of m_cRefs (COM object's reference count).
00206 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00207 STDMETHODIMP_(ULONG) COLicCarSample::Release(void)
00208 {
00209   m_cRefs--;
00210
00211   LOGF1("P: COLicCarSample::Release. New cRefs=%i.", m_cRefs);
00212
00213   if (0 == m_cRefs)
00214   {
00215     // We've reached a zero reference count for this COM object.
00216     // So we tell the server housing to decrement its global object
00217     // count so that the server will be unloaded if appropriate.
00218     if (NULL != m_pServer)
00219       m_pServer->ObjectsDown();
00220
00221     // We artificially bump the main ref count to prevent reentrancy
00222     // via the main object destructor.  Not really needed in this
00223     // COLicCarSample but a good practice because we are aggregatable and
00224     // may at some point in the future add something entertaining like
00225     // some Releases to the COLicCarSample destructor.
00226     m_cRefs++;
00227     delete this;
00228   }
00229
00230   return m_cRefs;
00231 }
00232
00233
00234 /*---------------------------------------------------------------------------
00235   COLicCarSample's nested implementation of the ISample interface
00236   including Constructor, Destructor, QueryInterface, AddRef, Release,
00237   Init, and AboutBox methods.
00238 ---------------------------------------------------------------------------*/
00239
00240 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00241   Method:   COLicCarSample::CImpISample::CImpISample
00242
00243   Summary:  Constructor for the CImpISample interface instantiation.
00244
00245   Args:     COLicCarSample* pBackObj,
00246               Back pointer to the parent outer object.
00247             IUnknown* pUnkOuter,
00248               Pointer to the outer Unknown.  For delegation.
00249             CServer* pServer)
00250               Pointer to the server's control object.
00251
00252   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
00253
00254   Returns:  void
00255 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00256 COLicCarSample::CImpISample::CImpISample(
00257   COLicCarSample* pBackObj,
00258   IUnknown* pUnkOuter,
00259   CServer* pServer)
00260 {
00261   // Init the Interface Ref Count (used for debugging only).
00262   m_cRefI = 0;
00263
00264   // Init the Back Object Pointer to point to the outer object.
00265   m_pBackObj = pBackObj;
00266
00267   // Init the pointer to the server control object.
00268   m_pServer = pServer;
00269
00270   // Init the CImpISample interface's delegating Unknown pointer.  We use
00271   // the Back Object pointer for IUnknown delegation here if we are not
00272   // being aggregated.  If we are being aggregated we use the supplied
00273   // pUnkOuter for IUnknown delegation.  In either case the pointer
00274   // assignment requires no AddRef because the CImpISample lifetime is
00275   // quaranteed by the lifetime of the parent object in which
00276   // CImpISample is nested.
00277   if (NULL == pUnkOuter)
00278   {
00279     m_pUnkOuter = pBackObj;
00280     LOG("P: COLicCarSample::CImpISample Constructor. Non-Aggregating.");
00281   }
00282   else
00283   {
00284     m_pUnkOuter = pUnkOuter;
00285     LOG("P: COLicCarSample::CImpISample Constructor. Aggregating.");
00286   }
00287
00288   return;
00289 }
00290
00291
00292 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00293   Method:   COLicCarSample::CImpISample::~CImpISample
00294
00295   Summary:  Destructor for the CImpISample interface instantiation.
00296
00297   Args:     void
00298
00299   Modifies: .
00300
00301   Returns:  void
00302 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00303 COLicCarSample::CImpISample::~CImpISample(void)
00304 {
00305   LOG("P: COLicCarSample::CImpISample Destructor.");
00306
00307   return;
00308 }
00309
00310
00311 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00312   Method:   COLicCarSample::CImpISample::QueryInterface
00313
00314   Summary:  The QueryInterface IUnknown member of this ISample interface
00315             implementation that delegates to m_pUnkOuter, whatever it is.
00316
00317   Args:     REFIID riid,
00318               [in] GUID of the Interface being requested.
00319             PPVOID ppv)
00320               [out] Address of the caller's pointer variable that will
00321               receive the requested interface pointer.
00322
00323   Modifies: .
00324
00325   Returns:  HRESULT
00326               Returned by the delegated outer QueryInterface call.
00327 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00328 STDMETHODIMP COLicCarSample::CImpISample::QueryInterface(
00329                REFIID riid,
00330                PPVOID ppv)
00331 {
00332   LOG("P: COLicCarSample::CImpISample::QueryInterface. Delegating.");
00333
00334   // Delegate this call to the outer object's QueryInterface.
00335   return m_pUnkOuter->QueryInterface(riid, ppv);
00336 }
00337
00338
00339 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00340   Method:   COLicCarSample::CImpISample::AddRef
00341
00342   Summary:  The AddRef IUnknown member of this ISample interface
00343             implementation that delegates to m_pUnkOuter, whatever it is.
00344
00345   Args:     void
00346
00347   Modifies: m_cRefI.
00348
00349   Returns:  ULONG
00350               Returned by the delegated outer AddRef call.
00351 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00352 STDMETHODIMP_(ULONG) COLicCarSample::CImpISample::AddRef(void)
00353 {
00354   // Increment the Interface Reference Count.
00355   ++m_cRefI;
00356
00357   LOGF1("P: COLicCarSample::CImpISample::Addref. Delegating. New cI=%i.", m_cRefI);
00358
00359   // Delegate this call to the outer object's AddRef.
00360   return m_pUnkOuter->AddRef();
00361 }
00362
00363
00364 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00365   Method:   COLicCarSample::CImpISample::Release
00366
00367   Summary:  The Release IUnknown member of this ISample interface
00368             implementation that delegates to m_pUnkOuter, whatever it is.
00369
00370   Args:     void
00371
00372   Modifies: .
00373
00374   Returns:  ULONG
00375               Returned by the delegated outer Release call.
00376 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00377 STDMETHODIMP_(ULONG) COLicCarSample::CImpISample::Release(void)
00378 {
00379   // Decrement the Interface Reference Count.
00380   --m_cRefI;
00381
00382   LOGF1("P: COLicCarSample::CImpISample::Release. Delegating. New cI=%i.", m_cRefI);
00383
00384   // Delegate this call to the outer object's Release.
00385   return m_pUnkOuter->Release();
00386 }
00387
00388
00389 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00390   Method:   COLicCarSample::CImpISample::Init
00391
00392   Summary:  Initialize the COLicCarSample object to enable trace logging
00393             from server to client.  This includes passing in a pointer
00394             that points the Client EXE's MsgLog facility so that the
00395             LOG* trace logging macros in the server will be logged in
00396             the Client's message log window.  This Init function also
00397             rigs up the same kind of trace logging for the subordinate
00398             DLLSERVE server.
00399
00400   Args:     HWND hWndParent
00401               [in] Handle of a client's parent owning window.
00402             PVOID pvMsgLog
00403               [in] Pointer to the Client's MsgLog object.  If NULL
00404               then setup independent logging window for this DLL.
00405
00406   Modifies: .
00407
00408   Returns:  HRESULT
00409               Standard result code. NOERROR for success.
00410 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00411 STDMETHODIMP COLicCarSample::CImpISample::Init(
00412                HWND hWndParent,
00413                PVOID pvMsgLog)
00414 {
00415   HRESULT hr = NOERROR;
00416
00417   // Init this DLL's MsgBox facility.
00418   g_pServer->m_pMsgBox->Init(g_pServer->m_hDllInst, hWndParent);
00419
00420   if (NULL != pvMsgLog)
00421   {
00422     // Set up a pointer to the client EXE's Message Log facility so
00423     // that any LOG macros used in this DLL will log to the host EXE's
00424     // log window.
00425     g_pMsgLog = (CMsgLog *)pvMsgLog;
00426     LOG("P: --- LICSERVE.DLL now logging to Client ---");
00427   }
00428   else
00429   {
00430     // But if pvMsgLog is passed in as NULL then Create an independent
00431     // logging facility for this DLL (use the client EXE's main window
00432     // as the parent window).
00433     CMsgLog* pMsgLog = new CMsgLog;
00434
00435     if (NULL != pMsgLog)
00436     {
00437       if (pMsgLog->Create(g_pServer->m_hDllInst, hWndParent, FALSE))
00438       {
00439         g_pMsgLog = pMsgLog;
00440         LOG("P: --- LICSERVE.DLL now logging ---");
00441       }
00442       else
00443         delete pMsgLog;
00444     }
00445   }
00446
00447   return hr;
00448 }
00449
00450
00451 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00452   Method:   COLicCarSample::CImpISample::AboutBox
00453
00454   Summary:  The AboutBox method commands the Server to display its own
00455             About dialog box (using resources stored in this DLL itself.
00456
00457   Args:     HWND hWnd
00458               [in] Handle of window (ie of client) that is to be parent of
00459               the About dialog window.
00460
00461   Modifies: .
00462
00463   Returns:  HRESULT
00464               Standard result code.
00465 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00466 HRESULT COLicCarSample::CImpISample::AboutBox(
00467           HWND hWnd)
00468 {
00469   HRESULT hr = NOERROR;
00470
00471   LOG("P: COLicCarSample::CImpISample::AboutBox.");
00472
00473   // Define one of those nifty APPUTIL CAboutBox modal dialog objects.
00474   CAboutBox dlgAboutBox;
00475
00476   // Show the standard About Box dialog for this DLL by telling the dialog
00477   // C++ object to show itself by invoking its ShowDialog method.
00478   // Pass it this DLL instance and the parent window handle.  Use a dialog
00479   // resource ID for the dialog stored in this DLL module's resources.
00480   dlgAboutBox.ShowDialog(
00481     m_pServer->m_hDllInst,
00482     MAKEINTRESOURCE(IDD_ABOUTBOX),
00483     hWnd);
00484
00485   return hr;
00486 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/clUtil.h Source File

  • Web
  • NetMeeting
  • NMUI

clUtil.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       CLUTIL.H
00004 //  Content:    Utility Classes
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #ifndef _CL_UTIL_H_
00016 #define _CL_UTIL_H_
00017
00018
00019 //****************************************************************************
00020 //
00021 // CLASS RefCount
00022 //
00023 //****************************************************************************
00024
00025 class RefCount
00026 {
00027 private:
00028    LONG m_cRef;
00029
00030 public:
00031    RefCount();
00032    // Virtual destructor defers to destructor of derived class.
00033    virtual ~RefCount();
00034
00035    // IUnknown methods
00036
00037    ULONG STDMETHODCALLTYPE AddRef(void);
00038    ULONG STDMETHODCALLTYPE Release(void);
00039 };
00040
00041
00042 //****************************************************************************
00043 //
00044 // CLASS CNotify
00045 //
00046 // Notification sink
00047 //
00048 //****************************************************************************
00049
00050 class CNotify
00051 {
00052 private:
00053     DWORD  m_dwCookie;
00054   IUnknown * m_pUnk;
00055     IConnectionPoint           * m_pcnp;
00056     IConnectionPointContainer  * m_pcnpcnt;
00057 public:
00058     CNotify(void);
00059     ~CNotify();
00060
00061     HRESULT Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN);
00062     HRESULT Disconnect(void);
00063
00064     IUnknown * GetPunk() {return m_pUnk;}
00065 };
00066
00067
00068 //****************************************************************************
00069 //
00070 // CLASS COBLIST
00071 //
00072 //****************************************************************************
00073
00074 #define POSITION COBNODE*
00075
00076 struct COBNODE
00077 {
00078   POSITION  pNext;
00079   void*   pItem;
00080 };
00081
00082 class COBLIST
00083 {
00084 protected:
00085   POSITION m_pHead;
00086   POSITION m_pTail;
00087     virtual BOOL Compare(void* pItemToCompare, void* pComparator)
00088                        { return(pItemToCompare == pComparator); };
00089 public:
00090   COBLIST() : m_pHead(NULL), m_pTail(NULL) { };
00091     virtual         ~COBLIST();
00092
00093   virtual void *  RemoveAt(POSITION rPos);
00094     void            EmptyList();
00095   POSITION      AddTail(void* pItem);
00096   void *        GetTail();
00097   void *        GetNext(POSITION& rPos);
00098     void *          SafeGetFromPosition(POSITION rPos);
00099     POSITION        GetPosition(void* pItem);
00100     POSITION        Lookup(void* pComparator);
00101   POSITION      GetHeadPosition()  { return (m_pHead); };
00102   POSITION      GetTailPosition()  { return (m_pTail); };
00103   BOOL        IsEmpty()          { return (!m_pHead); };
00104 #ifdef DEBUG
00105   void *        GetHead();
00106   void *        RemoveHead();
00107   void *          RemoveTail();
00108   void *        GetFromPosition(POSITION rPos);
00109 #else
00110   void *        GetHead()          { return GetFromPosition(GetHeadPosition());};
00111   void *        RemoveHead()       { return RemoveAt(m_pHead); };
00112   void *          RemoveTail()       { return RemoveAt(m_pTail); };
00113   void *        GetFromPosition(POSITION rPos){return (NULL == rPos) ? NULL : (rPos->pItem);};
00114 #endif
00115 };
00116
00117 //****************************************************************************
00118 //
00119 // Utility Functions
00120 //
00121 //****************************************************************************
00122
00123 POSITION AddNode(PVOID pv, COBLIST ** ppList);
00124 PVOID RemoveNode(POSITION * pPos, COBLIST *pList);
00125
00126
00127 //****************************************************************************
00128 //
00129 // CLASS BSTRING
00130 //
00131 //****************************************************************************
00132
00133 class BSTRING
00134 {
00135 private:
00136   BSTR   m_bstr;
00137
00138 public:
00139   // Constructors
00140   BSTRING() {m_bstr = NULL;}
00141
00142   inline BSTRING(LPCWSTR lpcwString);
00143
00144 #if !defined(UNICODE)
00145   // We don't support construction from an ANSI string in the Unicode build.
00146   BSTRING(LPCSTR lpcString);
00147 #endif // !defined(UNICODE)
00148
00149   // Destructor
00150   inline ~BSTRING();
00151
00152   // Cast to BSTR
00153   operator BSTR() {return m_bstr;}
00154   inline LPBSTR GetLPBSTR(void);
00155 };
00156
00157
00158 BSTRING::BSTRING(LPCWSTR lpcwString)
00159 {
00160   if (NULL != lpcwString)
00161   {
00162     m_bstr = SysAllocString(lpcwString);
00163     ASSERT(NULL != m_bstr);
00164   }
00165   else
00166   {
00167     m_bstr = NULL;
00168   }
00169 }
00170
00171 BSTRING::~BSTRING()
00172 {
00173   if (NULL != m_bstr)
00174   {
00175     SysFreeString(m_bstr);
00176     m_bstr = NULL;
00177   }
00178 }
00179
00180 inline LPBSTR BSTRING::GetLPBSTR(void)
00181 {
00182   ASSERT(NULL != m_bstr);
00183   if  (NULL == m_bstr)
00184     return NULL;
00185
00186   return &m_bstr;
00187 }
00188
00189
00190 //****************************************************************************
00191 //
00192 // CLASS BTSTR
00193 //
00194 //****************************************************************************
00195
00196 class BTSTR
00197 {
00198 private:
00199   LPTSTR m_psz;
00200
00201 public:
00202   BTSTR(BSTR bstr);
00203   ~BTSTR();
00204
00205   // Cast to BSTR
00206   operator LPTSTR() {return (NULL == m_psz) ? TEXT("<null>") : m_psz;}
00207 };
00208
00209 LPTSTR PszFromBstr(BSTR bst);
00210 DWORD GetRegDWORD(HKEY hkRoot, LPCTSTR szSubKey, LPCTSTR szValName, DWORD dwDefault);
00211
00212
00213 #endif  // _CL_UTIL_H_
00214
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/StdAfx.Cpp Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/DynOut/DynOutc.c Source File

  • NetDS
  • RPC
  • DynOut

DynOutc.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1995 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011 //
00012 // Sample code to show server-side
00013 // memory allocation for an [out] parameter
00014 //
00015 //
00016 #include <stdio.h>
00017 #include <conio.h>
00018 #include <stdlib.h>
00019 #include <assert.h>
00020 #include <malloc.h>
00021 #include "dynout.h"
00022
00023 void main(int argc,char **argv)
00024 {
00025   unsigned char *pr = NULL;
00026   long lSize;
00027   int i;
00028   int bOK;
00029
00030   RpcTryExcept
00031   {
00032     for(;;)
00033     {
00034       pr = NULL;  // This is *REALLY* important!
00035
00036       GrabChunk(&lSize,&pr);
00037
00038       // quick sanity check
00039       for (i=0, bOK=TRUE; (i < lSize) && bOK; i++)
00040       {
00041         if (*pr != pr[i])
00042         {
00043           puts("***Error***");
00044           bOK=FALSE;
00045           break;
00046         }
00047       }
00048
00049       printf("Returned %d bytes of '%c'\n",lSize,*pr);
00050
00051       midl_user_free(pr);
00052     }
00053   }
00054   RpcExcept(1)
00055   {
00056     printf("Err: %u\n",RpcExceptionCode());
00057   }
00058   RpcEndExcept
00059 }
00060
00061 void  __RPC_FAR * __RPC_API midl_user_allocate(size_t len)
00062 {
00063     return malloc(len);
00064 }
00065
00066 void __RPC_API midl_user_free(void __RPC_FAR * ptr)
00067 {
00068
00069     free(ptr);
00070 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/HtmlElem.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

HtmlElem.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       htmlelem.cxx
00006 //
00007 //  Contents:   Base class for Html element
00008 //
00009 //  Classes:    CHtmlElement
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <htmlelem.hxx>
00017
00018
00019 //+-------------------------------------------------------------------------
00020 //
00021 //  Method:     CHtmlElement::CHtmlElement
00022 //
00023 //  Synopsis:   Constructor
00024 //
00025 //  Arguments:  [htmlIFilter]     -- Reference to IFilter
00026 //              [mmSerialStream]  -- Reference to input stream
00027 //
00028 //--------------------------------------------------------------------------
00029
00030 CHtmlElement::CHtmlElement( CHtmlIFilter& htmlIFilter,
00031                             CSerialStream& serialStream )
00032     : _htmlIFilter(htmlIFilter),
00033       _serialStream(serialStream),
00034       _scanner(htmlIFilter, serialStream)
00035 {
00036 }
00037
00038
00039 //+-------------------------------------------------------------------------
00040 //
00041 //  Method:     CHtmlElement::GetValue
00042 //
00043 //  Synopsis:   Default implementation for returning value in current chunk
00044 //
00045 //  Arguments:  [ppPropValue]  -- Value returned here
00046 //
00047 //--------------------------------------------------------------------------
00048 SCODE CHtmlElement::GetValue( PROPVARIANT ** ppPropValue )
00049 {
00050     return FILTER_E_NO_VALUES;
00051 }
00052
00053 //+-------------------------------------------------------------------------
00054 //
00055 //  Method:     CHtmlElement::InitFilterRegion
00056 //
00057 //  Synopsis:   Initializes the filter region of a chunk to default value
00058 //
00059 //  Arguments:  [idChunkSource]  -- Id of source chunk
00060 //              [cwcStartSource] -- Offset of source text in chunk
00061 //              [cwcLenSource]   -- Length of source text in chunk
00062 //
00063 //--------------------------------------------------------------------------
00064
00065 void CHtmlElement::InitFilterRegion( ULONG& idChunkSource,
00066                                      ULONG& cwcStartSource,
00067                                      ULONG& cwcLenSource )
00068 {
00069     idChunkSource = 0;
00070     cwcStartSource = 0;
00071     cwcLenSource = 0;
00072 }
00073
00074
00075
00076 //+-------------------------------------------------------------------------
00077 //
00078 //  Method:     CHtmlElement::SwitchToNextHtmlElement
00079 //
00080 //  Synopsis:   Find the next Html element and switch to it's parsing algorithm
00081 //
00082 //  Arguments:  [pStat] -- chunk information returned here
00083 //
00084 //--------------------------------------------------------------------------
00085
00086 SCODE CHtmlElement::SwitchToNextHtmlElement( STAT_CHUNK *pStat )
00087 {
00088     CToken token;
00089
00090     _scanner.SkipCharsUntilNextRelevantToken( token );
00091     HtmlTokenType eTokType = token.GetTokenType();
00092     if ( eTokType == EofToken )
00093         return FILTER_E_END_OF_CHUNKS;
00094
00095     CHtmlElement *pHtmlElemNext = _htmlIFilter.QueryHtmlElement( eTokType );
00096     Win4Assert( pHtmlElemNext );
00097     pHtmlElemNext->InitStatChunk( pStat );
00098     _htmlIFilter.ChangeState( pHtmlElemNext );
00099
00100     return S_OK;
00101 }
00102
00103
00104
00105 //+-------------------------------------------------------------------------
00106 //
00107 //  Method:     CHtmlElement::SkipRemainingTextAndGotoNextChunk
00108 //
00109 //  Synopsis:   Move to the next chunk
00110 //
00111 //  Arguments:  [pStat] -- chunk information returned here
00112 //
00113 //--------------------------------------------------------------------------
00114
00115 SCODE CHtmlElement::SkipRemainingTextAndGotoNextChunk( STAT_CHUNK *pStat )
00116 {
00117     ULONG ulBufSize  = TEMP_BUFFER_SIZE;
00118
00119     //
00120     // Loop until text in current chunk has been exhausted
00121     //
00122     SCODE sc = GetText( &ulBufSize, _aTempBuffer );
00123     while ( SUCCEEDED(sc) )
00124     {
00125         sc = GetText( &ulBufSize, _aTempBuffer );
00126     }
00127
00128     sc = GetChunk( pStat );
00129
00130     return sc;
00131 }
00132
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_FFSTREAM Member List

This is the complete list of members for _FFSTREAM, including all inherited members.
dwFFStreamMagic | _FFSTREAM
hFile | _FFSTREAM
lpContext | _FFSTREAM
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAppInstallDlg Member List

This is the complete list of members for CAppInstallDlg, including all inherited members.
CAppInstallDlg(CWnd *pParent=NULL) | CAppInstallDlg |
DoDataExchange(CDataExchange *pDX) | CAppInstallDlg | [protected, virtual]
IDD enum value | CAppInstallDlg |
m_bOverwriteFiles | CAppInstallDlg | [private]
m_bRemoteInstall | CAppInstallDlg | [private]
m_edtAppFile | CAppInstallDlg |
m_edtInstallDir | CAppInstallDlg |
m_edtPWD | CAppInstallDlg |
m_edtRemoteServerName | CAppInstallDlg |
m_edtUID | CAppInstallDlg |
m_hIcon | CAppInstallDlg | [protected]
m_nInstallType | CAppInstallDlg | [private]
m_pCatalog | CAppInstallDlg | [private]
OnAppFileSearch() | CAppInstallDlg | [protected]
OnClose() | CAppInstallDlg | [protected]
OnInitDialog() | CAppInstallDlg | [protected, virtual]
OnInstallDirSearch() | CAppInstallDlg | [protected]
OnInstallWithoutUsers() | CAppInstallDlg | [protected]
OnInstallWithUsers() | CAppInstallDlg | [protected]
OnOK() | CAppInstallDlg | [protected, virtual]
OnOverwriteFiles() | CAppInstallDlg | [protected]
OnRemoteServerInstall() | CAppInstallDlg | [protected]
ReleaseCatalog() | CAppInstallDlg | [private]
set_Catalog(ICOMAdminCatalog *pCatalog) | CAppInstallDlg |
ToggleRemoteServerState(bool Flag) | CAppInstallDlg | [private]
Generated on Wed Nov 13 2024 16:55:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  ADQI.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030   static TCHAR error[64];
00031
00032   switch (verb) {
00033     case MMC_VERB_NONE:
00034     return _T("NONE");
00035     case MMC_VERB_OPEN:
00036     return _T("OPEN");
00037     case MMC_VERB_COPY:
00038     return _T("COPY");
00039     case MMC_VERB_PASTE:
00040     return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042     return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044     return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046     return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048     return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050     return _T("PRINT");
00051     case MMC_VERB_CUT:
00052     return _T("CUT");
00053   default:
00054     wsprintf(error, _T("Unknown verb id %d"), verb);
00055     return error;
00056   }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061         IComponentData *pCompData,
00062         IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064         LPARAM arg,
00065         LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069   TCHAR message[cchMessage] = {0};
00070
00071   if (bComponentData == TRUE)
00072     OutputDebugString(_T("IComponentData::Notify( "));
00073   else
00074     OutputDebugString(_T("IComponent::Notify( "));
00075
00076   wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077   OutputDebugString(message);
00078
00079     switch (event)  {
00080     case MMCN_ACTIVATE:
00081       wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082       break;
00083
00084     case MMCN_ADD_IMAGES:
00085       wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086       break;
00087
00088     case MMCN_BTN_CLICK:
00089       wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090       break;
00091
00092     case MMCN_COLUMN_CLICK:
00093       wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,   param);
00094       break;
00095
00096     case MMCN_COLUMNS_CHANGED:
00097       wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098       break;
00099
00100     case MMCN_CONTEXTHELP:
00101       wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102       break;
00103
00104     case MMCN_CONTEXTMENU:
00105       wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106       break;
00107
00108     case MMCN_CUTORMOVE:
00109       wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110       break;
00111
00112     case MMCN_DBLCLICK:
00113       wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114       break;
00115
00116     case MMCN_DELETE:
00117       wsprintf(message, _T("MMCN_DELETE\n"));
00118       break;
00119
00120     case MMCN_DESELECT_ALL:
00121       wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122       break;
00123
00124     case MMCN_EXPAND:
00125       wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126       break;
00127
00128     case MMCN_EXPANDSYNC:
00129       wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130       break;
00131
00132     case MMCN_FILTERBTN_CLICK:
00133       wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134       break;
00135
00136     case MMCN_FILTER_CHANGE:
00137       wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138       break;
00139
00140     case MMCN_HELP:
00141       wsprintf(message, _T("MMCN_HELP\n"));
00142       break;
00143
00144     case MMCN_INITOCX:
00145       wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146       break;
00147
00148     case MMCN_LISTPAD:
00149       wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150       break;
00151
00152     case MMCN_MENU_BTNCLICK:
00153       wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154       break;
00155
00156     case MMCN_MINIMIZED:
00157       wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158       break;
00159
00160     case MMCN_PASTE:
00161       wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162       break;
00163
00164     case MMCN_PRELOAD:
00165       wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166       break;
00167
00168     case MMCN_PRINT:
00169       wsprintf(message, _T("MMCN_PRINT\n"));
00170       break;
00171
00172     case MMCN_PROPERTY_CHANGE:
00173       wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174       break;
00175
00176     case MMCN_QUERY_PASTE:
00177       wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178       break;
00179
00180     case MMCN_REFRESH:
00181       wsprintf(message, _T("MMCN_REFRESH\n"));
00182       break;
00183
00184     case MMCN_REMOVE_CHILDREN:
00185       wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186       break;
00187
00188     case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192       StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193       break;
00194
00195     case MMCN_RESTORE_VIEW:
00196       wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197       break;
00198
00199     case MMCN_SELECT:
00200       wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201       break;
00202
00203     case MMCN_SHOW:
00204       wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205       break;
00206
00207     case MMCN_SNAPINHELP:
00208       wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209       break;
00210
00211     case MMCN_VIEW_CHANGE:
00212       wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213       break;
00214   }
00215
00216   if (message[0] != 0)
00217     OutputDebugString(message);
00218   else
00219     OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222   return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventConsumer/PermEventsdlg.h Source File

  • SysMgmt
  • WMI
  • VC
  • EventConsumer

PermEventsdlg.h

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  PermEventsDlg.h
00006 //
00007 // Description:
00008 //    header file for event consumer sample dialog box
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #if !defined(AFX_PermEventsDLG_H__E868569A_0774_11D1_AD85_00AA00B8E05A__INCLUDED_)
00015 #define AFX_PermEventsDLG_H__E868569A_0774_11D1_AD85_00AA00B8E05A__INCLUDED_
00016
00017 #if _MSC_VER >= 1000
00018 #pragma once
00019 #endif // _MSC_VER >= 1000
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // CPermEventsDlg dialog
00023
00024 class CPermEventsDlg : public CDialog
00025 {
00026 // Construction
00027 public:
00028   CPermEventsDlg(CWnd* pParent = NULL); // standard constructor
00029
00030 // Dialog Data
00031   //{{AFX_DATA(CPermEventsDlg)
00032   enum { IDD = IDD_PERMEVENTS_DIALOG };
00033   CListBox  m_outputList;
00034   //}}AFX_DATA
00035
00036   // ClassWizard generated virtual function overrides
00037   //{{AFX_VIRTUAL(CPermEventsDlg)
00038   protected:
00039   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00040   //}}AFX_VIRTUAL
00041
00042 // Implementation
00043 protected:
00044   HICON m_hIcon;
00045
00046   // Generated message map functions
00047   //{{AFX_MSG(CPermEventsDlg)
00048   virtual BOOL OnInitDialog();
00049   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00050   afx_msg void OnPaint();
00051   afx_msg HCURSOR OnQueryDragIcon();
00052   //}}AFX_MSG
00053   DECLARE_MESSAGE_MAP()
00054 };
00055
00056 //{{AFX_INSERT_LOCATION}}
00057 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00058
00059 #endif // !defined(AFX_PermEventsDLG_H__E868569A_0774_11D1_AD85_00AA00B8E05A__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

RqsEngine Member List

This is the complete list of members for RqsEngine, including all inherited members.
Clear() | RqsEngine | [private]
ClientAdd(IN RqsClient *pClient) | RqsEngine |
ClientAuthenticate(IN CHAR *pszString) | RqsEngine |
ClientClearQuarantine(IN DWORD dwAddress, IN CONST CHAR *pszAddress, IN CONST CHAR *pszUsername) | RqsEngine |
ClientCompleteCb(IN LPVOID pvContext) | RqsEngine | [private, static]
ClientConnect() | RqsEngine | [private]
ClientConnectCb(IN LPVOID pvContext) | RqsEngine | [private, static]
ClientLogInfo(IN DWORD dwEvent, IN CONST CHAR *pszIp, IN CONST CHAR *pszUsername, IN CONST CHAR *pszString) | RqsEngine |
ClientReadCb(IN LPVOID pvContext) | RqsEngine | [private, static]
ClientReadMessages() | RqsEngine |
ClientRemove() | RqsEngine |
ConnectRRAS(IN OPTIONAL DWORD dwRetries=0) | RqsEngine |
DeregisterForConnectionNotification() | RqsEngine | [private]
Execute() | RqsEngine |
GetCheckpoint() | RqsEngine | [inline]
GetEventType(DWORD dwEventId) | RqsEngine | [private]
GetInternalIpAddress(OUT CHAR *pszIpAddress, IN DWORD dwCount) | RqsEngine | [private]
GetIpAddressFromInterfaceIndex(IN DWORD dwInterfaceId, OUT CHAR *pszIpAddress, IN DWORD dwCount) | RqsEngine | [private]
GetIpAddressFromInterfaceName(IN CONST WCHAR *pwszInterfaceName, OUT CHAR *pszIpAddress, IN DWORD dwCount) | RqsEngine | [private]
GetServiceHandle() | RqsEngine | [inline]
Initialize() | RqsEngine |
InitializeEvents() | RqsEngine | [private]
InitializeServerSocket() | RqsEngine | [private]
InitializeServerSocketCb(IN LPVOID pvContext) | RqsEngine | [private, static]
m_bRegisteredForConnectionNotification | RqsEngine | [private]
m_Config | RqsEngine | [private]
m_csClientsLock | RqsEngine | [private]
m_dwCheckPoint | RqsEngine | [private]
m_dwTraceId | RqsEngine | [private]
m_eConfig | RqsEngine | [private]
m_eInterfaceAdded | RqsEngine | [private]
m_eQuit | RqsEngine | [private]
m_eSocketAccept | RqsEngine | [private]
m_eSocketRead | RqsEngine | [private]
m_eTrace | RqsEngine | [private]
m_fConsoleTrace | RqsEngine | [private]
m_fDebugTrace | RqsEngine | [private]
m_fRtTrace | RqsEngine | [private]
m_hInstMprApi | RqsEngine | [private]
m_hkConfig | RqsEngine | [private]
m_hkTrace | RqsEngine | [private]
m_hLog | RqsEngine | [private]
m_hServer | RqsEngine | [private]
m_hService | RqsEngine | [private]
m_lClients | RqsEngine | [private]
m_qFunc | RqsEngine | [private]
m_rwlConfig | RqsEngine | [private]
m_sServer | RqsEngine | [private]
m_szInternalAddress | RqsEngine | [private]
m_ulClientCount | RqsEngine | [private]
RegisterForConnectionNotification() | RqsEngine | [private]
ReloadConfig() | RqsEngine | [private]
ReloadTrace() | RqsEngine | [private]
RqsEngine() | RqsEngine |
ScheduleWork(LPTHREAD_START_ROUTINE pFunc, RqsClient *pClient=NULL) | RqsEngine | [private]
SetConsoleTracing(IN BOOL fConsole) | RqsEngine | [inline]
SetServiceHandle(SERVICE_STATUS_HANDLE hService) | RqsEngine | [inline]
Stop() | RqsEngine | [inline]
Trace(IN LPSTR pszTrace, IN...) const | RqsEngine |
TraceCurrentServerConnections() | RqsEngine | [private]
TraceSelf() | RqsEngine |
Wait(OUT RqsEvent *pAction) | RqsEngine | [private]
~RqsEngine() | RqsEngine |
Generated on Wed Nov 13 2024 16:57:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCOrder/QCOrder.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCOrder

QCOrder.Cpp

Go to the documentation of this file.
00001 // QCOrder.cpp : Implementation of DLL Exports.
00002
00003 #include "stdafx.h"
00004 #include "resource.h"
00005 #include "initguid.h"
00006 #include <adoid.h>    // ADO
00007 #include "../QCShip2/QCShip2.h"
00008 #include "../QCShip2/QCShip2_i.c"
00009 #include "QCOrder.h"
00010 #include "QCOrder_i.c"
00011 #include "Order.h"
00012
00013 CComModule _Module;
00014
00015 BEGIN_OBJECT_MAP(ObjectMap)
00016   OBJECT_ENTRY(CLSID_Order, COrder)
00017 END_OBJECT_MAP()
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // DLL Entry Point
00021
00022 extern "C"
00023 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00024 {
00025   if (dwReason == DLL_PROCESS_ATTACH)
00026   {
00027     _Module.Init(ObjectMap, hInstance);
00028     DisableThreadLibraryCalls(hInstance);
00029   }
00030   else if (dwReason == DLL_PROCESS_DETACH)
00031     _Module.Term();
00032   return TRUE;    // ok
00033 }
00034
00035 /////////////////////////////////////////////////////////////////////////////
00036 // Used to determine whether the DLL can be unloaded by OLE
00037
00038 STDAPI DllCanUnloadNow(void)
00039 {
00040   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00041 }
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // Returns a class factory to create an object of the requested type
00045
00046 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00047 {
00048   return _Module.GetClassObject(rclsid, riid, ppv);
00049 }
00050
00051 /////////////////////////////////////////////////////////////////////////////
00052 // DllRegisterServer - Adds entries to the system registry
00053
00054 STDAPI DllRegisterServer(void)
00055 {
00056   // registers object, typelib and all interfaces in typelib
00057   return _Module.RegisterServer(TRUE);
00058 }
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // DllUnregisterServer - Removes entries from the system registry
00062
00063 STDAPI DllUnregisterServer(void)
00064 {
00065   _Module.UnregisterServer();
00066   return S_OK;
00067 }
00068
00069
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Instance_Provider/Globals.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Instance_Provider

Globals.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Globals.cpp
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #include <PreComp.h>
00017 #include <wbemprov.h>
00018
00019 #include <initguid.h>
00020 #ifndef INITGUID
00021 #define INITGUID
00022 #endif
00023
00024 #include "Globals.h"
00025
00026 /******************************************************************************
00027  *
00028  *  Name:
00029  *
00030  *    s_LocksInProgress
00031  *    s_ObjectsInProgress
00032  *
00033  *  Description:
00034  *
00035  *    Keep a count of outstanding global objects. Used for debugging purposes.
00036  *
00037  *****************************************************************************/
00038
00039 LONG Provider_Globals :: s_LocksInProgress ;
00040 LONG Provider_Globals :: s_ObjectsInProgress ;
00041
00042 /******************************************************************************
00043  *
00044  *  Name: Global_Startup ()
00045  *
00046  *
00047  *  Description:
00048  *
00049  *    Global function to handle initialization.
00050  *    Place user code here.
00051  *
00052  *****************************************************************************/
00053
00054 HRESULT Provider_Globals :: Global_Startup ()
00055 {
00056   HRESULT t_Result = S_OK ;
00057   return t_Result ;
00058 }
00059
00060 /******************************************************************************
00061  *
00062  *  Name: Global_Shutdown ()
00063  *
00064  *
00065  *  Description:
00066  *
00067  *    Global function to handle uninitialization.
00068  *    Place user code here.
00069  *
00070  *****************************************************************************/
00071
00072 HRESULT Provider_Globals :: Global_Shutdown ()
00073 {
00074   HRESULT t_Result = S_OK ;
00075   return t_Result ;
00076 }
00077
00078 /******************************************************************************
00079  *
00080  *  Name: CreateInstance
00081  *
00082  *
00083  *  Description:
00084  *
00085  *      Wrapper function for CoCreateInstance/CoGetClassObject.
00086  *      Useful for specific security context and debugging purposes.
00087  *
00088  *****************************************************************************/
00089
00090 HRESULT Provider_Globals :: CreateInstance (
00091
00092   const CLSID &a_ReferenceClsid ,
00093   LPUNKNOWN a_OuterUnknown ,
00094   const DWORD &a_ClassContext ,
00095   const UUID &a_ReferenceInterfaceId ,
00096   void **a_ObjectInterface
00097 )
00098 {
00099   HRESULT t_Result = S_OK ;
00100
00101 #if 1
00102
00103 /*
00104  *  Use standard implementation
00105  */
00106
00107    t_Result = CoCreateInstance (
00108
00109     a_ReferenceClsid ,
00110     a_OuterUnknown ,
00111     a_ClassContext ,
00112     a_ReferenceInterfaceId ,
00113     ( void ** )  a_ObjectInterface
00114   );
00115
00116 #else
00117
00118 /*
00119  *  Tweak configuration settings for call.
00120  */
00121
00122   COAUTHIDENTITY t_AuthenticationIdentity ;
00123   ZeroMemory ( & t_AuthenticationIdentity , sizeof ( t_AuthenticationIdentity ) ) ;
00124
00125   t_AuthenticationIdentity.User = NULL ;
00126   t_AuthenticationIdentity.UserLength = 0 ;
00127   t_AuthenticationIdentity.Domain = NULL ;
00128   t_AuthenticationIdentity.DomainLength = 0 ;
00129   t_AuthenticationIdentity.Password = NULL ;
00130   t_AuthenticationIdentity.PasswordLength = 0 ;
00131   t_AuthenticationIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE ;
00132
00133   COAUTHINFO t_AuthenticationInfo ;
00134   ZeroMemory ( & t_AuthenticationInfo , sizeof ( t_AuthenticationInfo ) ) ;
00135
00136     t_AuthenticationInfo.dwAuthnSvc = RPC_C_AUTHN_DEFAULT ;
00137     t_AuthenticationInfo.dwAuthzSvc = RPC_C_AUTHZ_DEFAULT ;
00138     t_AuthenticationInfo.pwszServerPrincName = NULL ;
00139     t_AuthenticationInfo.dwAuthnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; //RPC_C_AUTHN_LEVEL_CONNECT ;
00140     t_AuthenticationInfo.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE  ;
00141     t_AuthenticationInfo.dwCapabilities = EOAC_NONE ;
00142     t_AuthenticationInfo.pAuthIdentityData = NULL ;
00143
00144   COSERVERINFO t_ServerInfo ;
00145   ZeroMemory ( & t_ServerInfo , sizeof ( t_ServerInfo ) ) ;
00146
00147   t_ServerInfo.pwszName = NULL ;
00148     t_ServerInfo.dwReserved2 = 0 ;
00149     t_ServerInfo.pAuthInfo = & t_AuthenticationInfo ;
00150
00151   IClassFactory *t_ClassFactory = NULL ;
00152
00153   t_Result = CoGetClassObject (
00154
00155     a_ReferenceClsid ,
00156     a_ClassContext ,
00157     & t_ServerInfo ,
00158     IID_IClassFactory ,
00159     ( void ** )  & t_ClassFactory
00160   ) ;
00161
00162   if ( SUCCEEDED ( t_Result ) )
00163   {
00164     t_Result = t_ClassFactory->CreateInstance (
00165
00166       a_OuterUnknown ,
00167       a_ReferenceInterfaceId ,
00168       a_ObjectInterface
00169     );
00170
00171     t_ClassFactory->Release () ;
00172   }
00173
00174 #endif
00175
00176   return t_Result ;
00177 }
00178
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

DBG_THREAD_INFO Member List

This is the complete list of members for DBG_THREAD_INFO, including all inherited members.
dwThreadID | DBG_THREAD_INFO
hThread | DBG_THREAD_INFO
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/Java/Hello3/Notify.java Source File

  • Web
  • MSAgent
  • Java
  • Hello3

Notify.java

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright (C) 1997-1998 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //==========================================================================
00011
00012 // Standard java imports
00013
00014 import java.applet.*;
00015 import java.awt.*;
00016 import agentsvr.IAgentNotifySinkEx;
00017
00018 // This class is an implementation of an IAgentNotifySinkEx.
00019 // All methods are stubs except RequestComplete.
00020
00021 public class Notify implements IAgentNotifySinkEx
00022 {
00023   public  int       m_DoneID[] = {-1};
00024   private Hello3J     m_Applet;
00025
00026   public Notify(Hello3J applet)
00027   {
00028     m_Applet = applet;
00029   }
00030
00031   public void Click(int characterID, short keys, int x, int y)
00032   {
00033   }
00034
00035   public void DblClick(int characterID, short keys, int x, int y)
00036   {
00037   }
00038
00039   public void Restart()
00040   {
00041   }
00042
00043   public void BookMark(int bookmarkID)
00044   {
00045   }
00046
00047   public void Shutdown()
00048   {
00049   }
00050
00051   public void DragStart(int characterID, short keys, int x, int y)
00052   {
00053   }
00054
00055   public void DragComplete(int characterID, short keys, int x, int y)
00056   {
00057   }
00058
00059   public void ActivateInputState(int characterID, int activated)
00060   {
00061   }
00062
00063   public void Command(int commandID, com.ms.com.IUnknown userInput)
00064   {
00065   }
00066
00067   public void RequestStart(int requestID)
00068   {
00069   }
00070
00071   public void RequestComplete(int requestID, int status)
00072   {
00073     if (requestID == m_DoneID[0])
00074     {
00075       m_Applet.HideCharacters();
00076     }
00077   }
00078
00079   public void VisibleState(int characterID, int visible, int cause)
00080   {
00081   }
00082
00083   public void Idle(int characterID, int start)
00084   {
00085   }
00086
00087   public void Move(int characterID, int x, int y, int cause)
00088   {
00089   }
00090
00091   public void Size(int characterID, int width, int height)
00092   {
00093   }
00094
00095   public void BalloonVisibleState(int characterID, int visible)
00096   {
00097   }
00098
00099   public void HelpComplete(int characterID, int commandID, int cause)
00100   {
00101   }
00102
00103   public void ListeningState(int characterID, int state, int cause)
00104   {
00105   }
00106
00107   public void DefaultCharacterChange(String guid)
00108   {
00109   }
00110
00111   public void AgentPropertyChange()
00112   {
00113   }
00114
00115   public void ActiveClientChange(int characterID, int status)
00116   {
00117   }
00118 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Handles/cxhndl/Cxhndlc.c Source File

  • NetDS
  • RPC
  • Handles
  • cxhndl

Cxhndlc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                       cxhndl Example
00005
00006     FILE:       cxhndlc.c
00007
00008     USAGE:      cxhndlc  -n network_address
00009                          -p protocol_sequence
00010                          -e endpoint
00011                          -o options
00012                          -f filename
00013
00014     PURPOSE:    Client side of RPC distributed application
00015
00016     FUNCTIONS:  main() - binds to server and calls remote procedure
00017
00018     COMMENTS:   This distributed application uses a context handle.
00019
00020 ****************************************************************************/
00021
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024 #include "cxhndl.h"    // header file generated by MIDL compiler
00025
00026
00027 #define PURPOSE \
00028 "This Microsoft RPC Version 2.0 sample program demonstrates\n\
00029 the use of the [context_handle] attribute. For more information\n\
00030 about attributes and RPC API functions, see the RPC programming\n\
00031 guide and reference.\n\n"
00032
00033
00034 void Usage(char * pszProgramName)
00035 {
00036     fprintf(stderr, "%s", PURPOSE);
00037     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00038     fprintf(stderr, " -p protocol_sequence\n");
00039     fprintf(stderr, " -n network_address\n");
00040     fprintf(stderr, " -e endpoint\n");
00041     fprintf(stderr, " -o options\n");
00042     fprintf(stderr, " -f filename\n");
00043     exit(1);
00044 }
00045
00046 void __cdecl main(int argc, char **argv)
00047 {
00048     RPC_STATUS status;
00049     PCONTEXT_HANDLE_TYPE phContext = NULL;
00050
00051     unsigned char * pbBuf = NULL;
00052     short cbRead;    // count of bytes read
00053
00054     unsigned char * pszUuid             = NULL;
00055     unsigned char * pszProtocolSequence = "ncacn_np";
00056     unsigned char * pszNetworkAddress   = NULL;
00057     unsigned char * pszEndpoint         = "\\pipe\\cxhndl";
00058     unsigned char * pszOptions          = NULL;
00059     unsigned char * pszStringBinding    = NULL;
00060     unsigned char * pszFileName         = "readme.txt";
00061     int i;
00062
00063     /* allow the user to override settings with command line switches */
00064     for (i = 1; i < argc; i++) {
00065         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00066             switch (tolower(*(argv[i]+1))) {
00067             case 'p':  // protocol sequence
00068                 pszProtocolSequence = argv[++i];
00069                 break;
00070             case 'n':  // network address
00071                 pszNetworkAddress = argv[++i];
00072                 break;
00073             case 'e':
00074                 pszEndpoint = argv[++i];
00075                 break;
00076             case 'o':
00077                 pszOptions = argv[++i];
00078                 break;
00079             case 'f':
00080                 pszFileName = argv[++i];
00081                 break;
00082             case 'h':
00083             case '?':
00084             default:
00085                 Usage(argv[0]);
00086             }
00087         }
00088         else
00089             Usage(argv[0]);
00090     }
00091
00092     pbBuf = (unsigned char *)
00093             midl_user_allocate(BUFSIZE * sizeof(unsigned char));
00094
00095     /* Use a convenience function to concatenate the elements of  */
00096     /* the string binding into the proper sequence.               */
00097     status = RpcStringBindingCompose(pszUuid,
00098                                      pszProtocolSequence,
00099                                      pszNetworkAddress,
00100                                      pszEndpoint,
00101                                      pszOptions,
00102                                      &pszStringBinding);
00103     printf("RpcStringBindingCompose returned 0x%x\n", status);
00104     printf("pszStringBinding = %s\n", pszStringBinding);
00105     if (status) {
00106         exit(status);
00107     }
00108
00109     /* Set the binding handle that will be used to bind to the server. */
00110     status = RpcBindingFromStringBinding(pszStringBinding,
00111                                          &hStarter);
00112     printf("RpcBindingFromStringBinding returned 0x%x\n", status);
00113     if (status) {
00114         exit(status);
00115     }
00116
00117     printf("Calling the remote procedure RemoteOpen\n");
00118     if (RemoteOpen(&phContext, pszFileName) < 0) {
00119         printf("Unable to open %s\n", pszFileName);
00120         Shutdown();
00121         exit(2);
00122     }
00123
00124     /* Now the context handle also manages the binding. */
00125     status = RpcBindingFree(&hStarter);
00126     printf("RpcBindingFree returned 0x%x\n", status);
00127     if (status) {
00128         exit(status);
00129     }
00130
00131     /*  Free the string binding */
00132     status = RpcStringFree(&pszStringBinding);
00133     printf("RpcStringFree returned 0x%x\n", status);
00134     if (status) {
00135         exit(status);
00136     }
00137
00138     printf("Calling the remote procedure RemoteRead\n");
00139     while (RemoteRead(phContext, pbBuf, &cbRead) > 0) {
00140         for (i = 0; i < cbRead; i++)
00141             putchar(*(pbBuf+i));
00142     }
00143
00144     printf("Calling the remote procedure RemoteClose\n");
00145     if (RemoteClose(&phContext) < 0 ) {
00146         printf("Close failed on %s\n", pszFileName);
00147         exit(2);
00148     }
00149
00150     exit(0);
00151
00152 }  // end main()
00153
00154
00155 /*********************************************************************/
00156 /*                 MIDL allocate and free                            */
00157 /*********************************************************************/
00158
00159 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00160 {
00161     return(malloc(len));
00162 }
00163
00164 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00165 {
00166     free(ptr);
00167 }
00168
00169 /* end cxhndlc.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/Formdump/html.cpp Source File

  • Web
  • iis
  • extensions
  • Formdump

html.cpp

Go to the documentation of this file.
00001 //  Copyright (c) 1997-2002 Microsoft Corporation
00002 //
00003 //  Module Name:
00004 //
00005 //    html.cpp
00006 //
00007 //  Abstract:
00008 //
00009 //    This module contains simple HTML authoring functions.
00010
00011 #define WIN32_LEAN_AND_MEAN
00012 #include <windows.h>
00013 #include <httpext.h>
00014 #include <stdio.h>
00015 #include <stdarg.h>
00016
00017 #include "html.h"
00018
00019 void WriteString(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpsz)
00020 {
00021   DWORD dwBytesWritten;
00022
00023   dwBytesWritten = lstrlen(lpsz);
00024   pECB->WriteClient(pECB->ConnID, (PVOID) lpsz, &dwBytesWritten, 0);
00025 }
00026
00027 void HtmlCreatePage(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszTitle)
00028 {
00029   WriteString(pECB, "<HTML>\r\n\r\n");
00030
00031   if (lpszTitle) {
00032     WriteString(pECB, "<HEAD><TITLE>");
00033     HtmlWriteText(pECB, lpszTitle);
00034     WriteString(pECB, "</TITLE></HEAD>\r\n\r\n");
00035   }
00036   WriteString(pECB, "<BODY>\r\n\r\n");
00037 }
00038
00039 void HtmlEndPage(IN EXTENSION_CONTROL_BLOCK *pECB)
00040 {
00041   WriteString(pECB, "</BODY>\r\n\r\n");
00042   WriteString(pECB, "</HTML>\r\n");
00043 }
00044
00045
00046 void HtmlHeading(IN EXTENSION_CONTROL_BLOCK *pECB, IN int nHeading, IN LPCSTR lpszText)
00047 {
00048   HtmlBeginHeading(pECB, nHeading);
00049   HtmlWriteText(pECB, lpszText);
00050   HtmlEndHeading(pECB, nHeading);
00051 }
00052
00053
00054 void HtmlBeginHeading(IN EXTENSION_CONTROL_BLOCK *pECB, IN int nHeading)
00055 {
00056   char szCode[16];
00057
00058   wsprintf(szCode, "<H%i>", nHeading);
00059   WriteString(pECB, szCode);
00060 }
00061
00062
00063 void HtmlEndHeading(IN EXTENSION_CONTROL_BLOCK *pECB, IN int nHeading)
00064 {
00065   char szCode[16];
00066
00067   wsprintf(szCode, "</H%i>", nHeading);
00068   WriteString(pECB, szCode);
00069 }
00070
00071
00072 void HtmlWriteTextLine(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpsz)
00073 {
00074   HtmlWriteText(pECB, lpsz);
00075   WriteString(pECB, "\r\n");
00076 }
00077
00078
00079 void HtmlWriteText(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpsz)
00080 {
00081   char szBuf[1028];
00082
00083   // Build up enough data to make call to WriteString
00084   // worthwhile; convert special chars too.
00085
00086   int nLen = 0;
00087
00088   for (int i = 0; lpsz[i]; i++) {
00089
00090     if (lpsz[i] == '<')
00091       lstrcpy(&szBuf[nLen], "&lt;");
00092     else if (lpsz[i] == '>')
00093       lstrcpy(&szBuf[nLen], "&gt;");
00094     else if (lpsz[i] == '&')
00095       lstrcpy(&szBuf[nLen], "&amp;");
00096     else if (lpsz[i] == '\"')
00097       lstrcpy(&szBuf[nLen], "&quot;");
00098     else {
00099       szBuf[nLen] = lpsz[i];
00100       szBuf[nLen + 1] = 0;
00101     }
00102
00103     nLen += lstrlen(&szBuf[nLen]);
00104
00105     if (nLen >= 1024) {
00106       WriteString(pECB, szBuf);
00107       nLen = 0;
00108     }
00109   }
00110
00111   if (nLen)
00112     WriteString(pECB, szBuf);
00113 }
00114
00115
00116 void HtmlEndParagraph(IN EXTENSION_CONTROL_BLOCK *pECB)
00117 {
00118   WriteString(pECB, "<P>\r\n");
00119 }
00120
00121 // HtmlHyperLink adds a hyptertext link.  lpszDoc is the destination
00122 // document, and lpszText is the display text.
00123 //
00124 // HtmlHyperLinkAndBookmark adds a hyperlink with a bookmark link.
00125 // HtmlBookmarkLink adds only a bookmark link.
00126
00127 void HtmlHyperLink(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszDoc, IN LPCSTR lpszText)
00128 {
00129   WriteString(pECB, "<A HREF=\"");
00130   HtmlWriteText(pECB, lpszDoc);
00131   WriteString(pECB, "\">");
00132   HtmlWriteText(pECB, lpszText);
00133   WriteString(pECB, "</A>\r\n");
00134 }
00135
00136 void HtmlHyperLinkAndBookmark(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszDoc, IN LPCSTR lpszBookmark, IN LPCSTR lpszText)
00137 {
00138   WriteString(pECB, "<A HREF=\"");
00139
00140   if (lpszDoc)
00141     HtmlWriteText(pECB, lpszDoc);
00142
00143   WriteString(pECB, "#");
00144   HtmlWriteText(pECB, lpszBookmark);
00145   WriteString(pECB, "\">");
00146   HtmlWriteText(pECB, lpszText);
00147   WriteString(pECB, "</A>\r\n");
00148 }
00149
00150 void HtmlBookmarkLink(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszBookmark, IN LPCSTR lpszText)
00151 {
00152   HtmlHyperLinkAndBookmark(pECB, NULL, lpszBookmark, lpszText);
00153 }
00154
00155 // The following support list formatting.
00156
00157 void HtmlBeginUnnumberedList(IN EXTENSION_CONTROL_BLOCK *pECB)
00158 {
00159   WriteString(pECB, "<UL>\r\n");
00160 }
00161
00162
00163 void HtmlBeginListItem(IN EXTENSION_CONTROL_BLOCK *pECB)
00164 {
00165   WriteString(pECB, "<LI>");
00166 }
00167
00168
00169 void HtmlEndUnnumberedList(
00170                            IN EXTENSION_CONTROL_BLOCK *pECB
00171                            )
00172 {
00173   WriteString(pECB, "</UL>");
00174 }
00175
00176
00177 void HtmlBeginNumberedList(
00178                            IN EXTENSION_CONTROL_BLOCK *pECB
00179                            )
00180 {
00181   WriteString(pECB, "<OL>");
00182 }
00183
00184
00185 void HtmlEndNumberedList(
00186                          IN EXTENSION_CONTROL_BLOCK *pECB
00187                          )
00188 {
00189   WriteString(pECB, "</OL>");
00190 }
00191
00192
00193 void HtmlBeginDefinitionList(
00194                              IN EXTENSION_CONTROL_BLOCK *pECB
00195                              )
00196 {
00197   WriteString(pECB, "<DL>");
00198 }
00199
00200
00201 void HtmlEndDefinitionList(
00202                            IN EXTENSION_CONTROL_BLOCK *pECB
00203                            )
00204 {
00205   WriteString(pECB, "</DL>");
00206 }
00207
00208
00209 void HtmlDefinition(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszTerm, IN LPSTR lpszDef)
00210 {
00211   WriteString(pECB, "<DT> ");
00212   HtmlWriteText(pECB, lpszTerm);
00213   WriteString(pECB, "\r\n");
00214   WriteString(pECB, "<DD> ");
00215
00216   int nStart = 0;
00217   int nLen = lstrlen(lpszDef);
00218
00219   do {
00220
00221     int nEnd = nStart + 70;
00222
00223     if (nEnd >= nLen) {
00224
00225       HtmlWriteText(pECB, &lpszDef[nStart]);
00226       WriteString(pECB, "\r\n");
00227
00228       break;
00229     }
00230
00231     while (nEnd > nStart)
00232       if (lpszDef[nEnd] == ' ')
00233         break;
00234
00235     if (nEnd == nStart)
00236
00237       // too long!
00238
00239       nEnd = nStart + 70;
00240
00241     // write defintion segment
00242
00243     char tcHolder = lpszDef[nEnd];
00244
00245     lpszDef[nEnd] = 0;
00246
00247     HtmlWriteText(pECB, &lpszDef[nStart]);
00248
00249     WriteString(pECB, "\r\n");
00250
00251     lpszDef[nEnd] = tcHolder;
00252
00253     nStart = nEnd;
00254
00255     // skip excess whitespace
00256
00257     while (lpszDef[nStart] == ' ')
00258       nStart++;
00259
00260     // pretty formatting
00261
00262     if (nStart < nLen)
00263       WriteString(pECB, "     ");
00264
00265   } while (nStart < nLen);
00266 }
00267
00268 // For complex defintions
00269
00270 void HtmlBeginDefinitionTerm(IN EXTENSION_CONTROL_BLOCK *pECB)
00271 {
00272   WriteString(pECB, "<DT>");
00273 }
00274
00275 void HtmlBeginDefinition(IN EXTENSION_CONTROL_BLOCK *pECB)
00276 {
00277   WriteString(pECB, "<DD>");
00278 }
00279
00280 // Text formatting
00281
00282 void HtmlBeginPreformattedText(
00283                                IN EXTENSION_CONTROL_BLOCK *pECB
00284                                )
00285 {
00286   WriteString(pECB, "<PRE>");
00287 }
00288
00289
00290 void HtmlEndPreformattedText(
00291                              IN EXTENSION_CONTROL_BLOCK *pECB
00292                              )
00293 {
00294   WriteString(pECB, "</PRE>");
00295 }
00296
00297
00298 void HtmlBeginBlockQuote(
00299                          IN EXTENSION_CONTROL_BLOCK *pECB
00300                          )
00301 {
00302   WriteString(pECB, "<BLOCKQUOTE>");
00303 }
00304
00305
00306 void HtmlEndBlockQuote(
00307                        IN EXTENSION_CONTROL_BLOCK *pECB
00308                        )
00309 {
00310   WriteString(pECB, "</BLOCKQUOTE>");
00311 }
00312
00313
00314 void HtmlBeginAddress(
00315                       IN EXTENSION_CONTROL_BLOCK *pECB
00316                       )
00317 {
00318   WriteString(pECB, "<ADDRESS>");
00319 }
00320
00321
00322 void HtmlEndAddress(
00323                     IN EXTENSION_CONTROL_BLOCK *pECB
00324                     )
00325 {
00326   WriteString(pECB, "</ADDRESS>");
00327 }
00328
00329
00330 void HtmlBeginDefine(
00331                      IN EXTENSION_CONTROL_BLOCK *pECB
00332                      )
00333 {
00334   WriteString(pECB, "<DFN>");
00335 }
00336
00337
00338 void HtmlEndDefine(
00339                    IN EXTENSION_CONTROL_BLOCK *pECB
00340                    )
00341 {
00342   WriteString(pECB, "</DFN>");
00343 }
00344
00345
00346 void HtmlBeginEmphasis(
00347                        IN EXTENSION_CONTROL_BLOCK *pECB
00348                        )
00349 {
00350   WriteString(pECB, "<EM>");
00351 }
00352
00353
00354 void HtmlEndEmphasis(
00355                      IN EXTENSION_CONTROL_BLOCK *pECB
00356                      )
00357 {
00358   WriteString(pECB, "</EM>");
00359 }
00360
00361
00362 void HtmlBeginCitation(
00363                        IN EXTENSION_CONTROL_BLOCK *pECB
00364                        )
00365 {
00366   WriteString(pECB, "<CITE>");
00367 }
00368
00369
00370 void HtmlEndCitation(
00371                      IN EXTENSION_CONTROL_BLOCK *pECB
00372                      )
00373 {
00374   WriteString(pECB, "</CITE>");
00375 }
00376
00377
00378 void HtmlBeginCode(
00379                    IN EXTENSION_CONTROL_BLOCK *pECB
00380                    )
00381 {
00382   WriteString(pECB, "<CODE>");
00383 }
00384
00385
00386 void HtmlEndCode(
00387                  IN EXTENSION_CONTROL_BLOCK *pECB
00388                  )
00389 {
00390   WriteString(pECB, "</CODE>");
00391 }
00392
00393
00394 void HtmlBeginKeyboard(
00395                        IN EXTENSION_CONTROL_BLOCK *pECB
00396                        )
00397 {
00398   WriteString(pECB, "<KBD>");
00399 }
00400
00401
00402 void HtmlEndKeyboard(
00403                      IN EXTENSION_CONTROL_BLOCK *pECB
00404                      )
00405 {
00406   WriteString(pECB, "</KBD>");
00407 }
00408
00409
00410 void HtmlBeginStatus(
00411                      IN EXTENSION_CONTROL_BLOCK *pECB
00412                      )
00413 {
00414   WriteString(pECB, "<SAMP>");
00415 }
00416
00417
00418 void HtmlEndStatus(
00419                    IN EXTENSION_CONTROL_BLOCK *pECB
00420                    )
00421 {
00422   WriteString(pECB, "</SAMP>");
00423 }
00424
00425
00426 void HtmlBeginStrong(
00427                      IN EXTENSION_CONTROL_BLOCK *pECB
00428                      )
00429 {
00430   WriteString(pECB, "<STRONG>");
00431 }
00432
00433
00434 void HtmlEndStrong(IN EXTENSION_CONTROL_BLOCK *pECB)
00435 {
00436   WriteString(pECB, "</STRONG>");
00437 }
00438
00439
00440 void HtmlBeginVariable(IN EXTENSION_CONTROL_BLOCK *pECB)
00441 {
00442   WriteString(pECB, "<VAR>");
00443 }
00444
00445
00446 void HtmlEndVariable(
00447                      IN EXTENSION_CONTROL_BLOCK *pECB
00448                      )
00449 {
00450   WriteString(pECB, "</VAR>");
00451 }
00452
00453
00454 void HtmlBold(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszText)
00455 {
00456   HtmlBeginBold(pECB);
00457   HtmlWriteText(pECB, lpszText);
00458   HtmlEndBold(pECB);
00459 }
00460
00461
00462 void HtmlBeginBold(IN EXTENSION_CONTROL_BLOCK *pECB)
00463 {
00464   WriteString(pECB, "<B>");
00465 }
00466
00467
00468 void HtmlEndBold(IN EXTENSION_CONTROL_BLOCK *pECB)
00469 {
00470   WriteString(pECB, "</B>");
00471 }
00472
00473
00474 void HtmlItalic(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszText)
00475 {
00476   HtmlBeginItalic(pECB);
00477   HtmlWriteText(pECB, lpszText);
00478   HtmlEndItalic(pECB);
00479 }
00480
00481
00482 void HtmlBeginItalic(IN EXTENSION_CONTROL_BLOCK *pECB)
00483 {
00484   WriteString(pECB, "<I>");
00485 }
00486
00487
00488 void HtmlEndItalic(IN EXTENSION_CONTROL_BLOCK *pECB)
00489 {
00490   WriteString(pECB, "</I>");
00491 }
00492
00493
00494 void HtmlFixed(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszText)
00495 {
00496   HtmlBeginFixed(pECB);
00497   HtmlWriteText(pECB, lpszText);
00498   HtmlEndFixed(pECB);
00499 }
00500
00501
00502 void HtmlBeginFixed(IN EXTENSION_CONTROL_BLOCK *pECB)
00503 {
00504   WriteString(pECB, "<TT>");
00505 }
00506
00507
00508 void HtmlEndFixed(IN EXTENSION_CONTROL_BLOCK *pECB)
00509 {
00510   WriteString(pECB, "</TT>");
00511 }
00512
00513
00514 void HtmlLineBreak(IN EXTENSION_CONTROL_BLOCK *pECB)
00515 {
00516   WriteString(pECB, "<BR>\r\n");
00517 }
00518
00519
00520 void HtmlHorizontalRule(IN EXTENSION_CONTROL_BLOCK *pECB)
00521 {
00522   WriteString(pECB, "\r\n<HR>\r\n");
00523 }
00524
00525
00526 void HtmlImage(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszPicFile, IN LPCSTR lpszAltText)
00527 {
00528   WriteString(pECB, "<IMG SRC = \"");
00529   HtmlWriteText(pECB, lpszPicFile);
00530   WriteString(pECB, "\"");
00531   if (lpszAltText) {
00532     WriteString(pECB, " ALT = \"");
00533     HtmlWriteText(pECB, lpszAltText);
00534     WriteString(pECB, "\"");
00535   }
00536   WriteString(pECB, ">\r\n");
00537 }
00538
00539
00540 void HtmlPrintf(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszFormat, ...)
00541 {
00542   char szBuf[8192];
00543
00544   va_list list;
00545
00546   va_start(list, lpszFormat);
00547
00548   vsprintf(szBuf, lpszFormat, list);
00549   WriteString(pECB, szBuf);
00550
00551   va_end(list);
00552 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/GetImage/MainWnd.h Source File

  • Multimedia
  • wia
  • GetImage

MainWnd.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 --*/
00006
00007 #ifndef __MAINWND__
00008 #define __MAINWND__
00009
00010 #include "EventCallback.h"
00011
00012 //////////////////////////////////////////////////////////////////////////
00013 //
00014 // CMainWindow
00015 //
00016
00017 /*++
00018
00019     CMainWindow is the main MDI frame window. It is descended from IUnknown
00020     for reference counting.
00021
00022 Methods
00023
00024     Register
00025         Registers the window class
00026
00027     DoModal
00028         Invokes the window and returns when the main window is closed.
00029
00030     WindowProc
00031         Processes window messages.
00032
00033     OnFromScannerOrCamera
00034         Displays the WIA device selection, image selection and image tranfer
00035         dialogs to transfer one or multiple images from a WIA device when the
00036         user selects "From Scanner Or Camera..." menu item.
00037
00038 --*/
00039
00040 class CMainWindow : public IUnknown
00041 {
00042 public:
00043     CMainWindow();
00044
00045     // IUnknown interface
00046
00047     STDMETHOD(QueryInterface)(REFIID iid, LPVOID *ppvObj);
00048     STDMETHOD_(ULONG, AddRef)();
00049     STDMETHOD_(ULONG, Release)();
00050
00051     // CMainWindow methods
00052
00053     static ATOM Register();
00054
00055     int DoModal();
00056
00057 private:
00058     static
00059     LRESULT
00060     CALLBACK
00061     WindowProc(
00062         HWND   hWnd,
00063         UINT   uMsg,
00064         WPARAM wParam,
00065         LPARAM lParam
00066     );
00067
00068     LRESULT OnFromScannerOrCamera();
00069
00070 private:
00071     LONG  m_cRef;
00072     HWND  m_hMDIClient;
00073     LONG  m_nNumImages;
00074     BOOL  m_bDisplayWaitCursor;
00075
00076     CComPtr<WiaWrap::CEventCallback>  m_pEventCallback;
00077 };
00078
00079 #endif //__MAINWND__
00080
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Surrog/Common.h Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Surrog

Common.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #ifndef _WIN32_WINNT
00019 #define _WIN32_WINNT  0x0402
00020 #endif
00021
00022 #include <windows.h>
00023 #include <assert.h>
00024
00025 #define MAX_GUIDSTR_LEN 40
00026
00027 const CHAR szClsidKeyName[] = "CLSID";
00028 const CHAR szAppidValueName[] = "AppID";
00029
00030 #ifndef __ISurrogate_INTERFACE_DEFINED__
00031 #error "You need SP2-Compliant SDK headers to compile this file."
00032 #endif
00033
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/ADOVCGEN/advcgendlg.cpp Source File

  • Dataaccess
  • ADO
  • ADOVCGEN

advcgendlg.cpp

Go to the documentation of this file.
00001 // ADVCGENDlg.cpp : implementation file
00002 //
00003
00004 #include "stdafx.h"
00005 #include "ADVCGEN.h"
00006 #include "ADVCGENDlg.h"
00007
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // CAboutDlg dialog used for App About
00016
00017 class CAboutDlg : public CDialog
00018 {
00019 public:
00020   CAboutDlg();
00021
00022 // Dialog Data
00023   //{{AFX_DATA(CAboutDlg)
00024   enum { IDD = IDD_ABOUTBOX };
00025   //}}AFX_DATA
00026
00027   // ClassWizard generated virtual function overrides
00028   //{{AFX_VIRTUAL(CAboutDlg)
00029   protected:
00030   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00031   //}}AFX_VIRTUAL
00032
00033 // Implementation
00034 protected:
00035   //{{AFX_MSG(CAboutDlg)
00036   //}}AFX_MSG
00037   DECLARE_MESSAGE_MAP()
00038 };
00039
00040 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00041 {
00042   //{{AFX_DATA_INIT(CAboutDlg)
00043   //}}AFX_DATA_INIT
00044 }
00045
00046 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00047 {
00048   CDialog::DoDataExchange(pDX);
00049   //{{AFX_DATA_MAP(CAboutDlg)
00050   //}}AFX_DATA_MAP
00051 }
00052
00053 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00054   //{{AFX_MSG_MAP(CAboutDlg)
00055     // No message handlers
00056   //}}AFX_MSG_MAP
00057 END_MESSAGE_MAP()
00058
00059 /////////////////////////////////////////////////////////////////////////////
00060 // CADVCGENDlg dialog
00061
00062 CADVCGENDlg::CADVCGENDlg(CWnd* pParent /*=NULL*/)
00063   : CDialog(CADVCGENDlg::IDD, pParent)
00064 {
00065   //{{AFX_DATA_INIT(CADVCGENDlg)
00066   //}}AFX_DATA_INIT
00067   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
00068   schemaRs = NULL; // Schema Recordset Object
00069     dataRs = NULL;  // Data Recordset Object
00070   conn = NULL;
00071   m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00072 }
00073
00074
00075 CADVCGENDlg::~CADVCGENDlg()
00076 {
00077   //{{AFX_DATA_INIT(CADVCGENDlg)
00078   //}}AFX_DATA_INIT
00079   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
00080   if (schemaRs != NULL) // Schema Recordset Object
00081   {
00082     if(schemaRs->State != ado20::adStateOpen)
00083       schemaRs->Close();
00084     schemaRs.Release();
00085     schemaRs=NULL;
00086   }
00087     if (dataRs != NULL)  // Data Recordset Object
00088   {
00089     if(dataRs->State != ado20::adStateOpen)
00090       dataRs->Close();
00091     dataRs.Release();
00092     dataRs = NULL;
00093   }
00094   if(conn != NULL)
00095   {
00096     if(conn->State != ado20::adStateOpen)
00097       conn->Close();
00098     conn.Release();
00099     conn = NULL;
00100   }
00101 }
00102
00103
00104 void CADVCGENDlg::DoDataExchange(CDataExchange* pDX)
00105 {
00106   CDialog::DoDataExchange(pDX);
00107   //{{AFX_DATA_MAP(CADVCGENDlg)
00108   DDX_Control(pDX, IDC_DATAGRID1, m_DataGridDisplay);
00109   DDX_Control(pDX, IDC_TABLELIST, m_TableListBox);
00110   DDX_Control(pDX, IDC_CHECK1, m_SchemaInfo);
00111   DDX_Control(pDX, IDC_EDIT1, m_SQLEditBox);
00112   //}}AFX_DATA_MAP
00113 }
00114
00115 BEGIN_MESSAGE_MAP(CADVCGENDlg, CDialog)
00116   //{{AFX_MSG_MAP(CADVCGENDlg)
00117   ON_WM_SYSCOMMAND()
00118   ON_WM_PAINT()
00119   ON_WM_QUERYDRAGICON()
00120   ON_BN_CLICKED(IDC_BUTTON2, OnXecute)
00121   ON_BN_CLICKED(IDC_BUTTON1, OnBuild)
00122   ON_BN_CLICKED(IDCANCEL, OnExit)
00123   ON_LBN_SELCHANGE(IDC_TABLELIST, OnChangeTableList)
00124   //}}AFX_MSG_MAP
00125 END_MESSAGE_MAP()
00126
00127 /////////////////////////////////////////////////////////////////////////////
00128 // CADVCGENDlg message handlers
00129
00130 BOOL CADVCGENDlg::OnInitDialog()
00131 {
00132   CDialog::OnInitDialog();
00133
00134   // Add "About..." menu item to system menu.
00135
00136   // IDM_ABOUTBOX must be in the system command range.
00137   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00138   ASSERT(IDM_ABOUTBOX < 0xF000);
00139
00140   CMenu* pSysMenu = GetSystemMenu(FALSE);
00141   if (pSysMenu != NULL)
00142   {
00143     CString strAboutMenu;
00144     strAboutMenu.LoadString(IDS_ABOUTBOX);
00145     if (!strAboutMenu.IsEmpty())
00146     {
00147       pSysMenu->AppendMenu(MF_SEPARATOR);
00148       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
00149     }
00150   }
00151
00152   // Set the icon for this dialog.  The framework does this automatically
00153   //  when the application's main window is not a dialog
00154   SetIcon(m_hIcon, TRUE);     // Set big icon
00155   SetIcon(m_hIcon, FALSE);    // Set small icon
00156
00157   // TODO: Add extra initialization here
00158
00159   return TRUE;  // return TRUE  unless you set the focus to a control
00160 }
00161
00162 void CADVCGENDlg::OnSysCommand(UINT nID, LPARAM lParam)
00163 {
00164   if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00165   {
00166     CAboutDlg dlgAbout;
00167     dlgAbout.DoModal();
00168   }
00169   else
00170   {
00171     CDialog::OnSysCommand(nID, lParam);
00172   }
00173 }
00174
00175 // If you add a minimize button to your dialog, you will need the code below
00176 //  to draw the icon.  For MFC applications using the document/view model,
00177 //  this is automatically done for you by the framework.
00178
00179 void CADVCGENDlg::OnPaint()
00180 {
00181   if (IsIconic())
00182   {
00183     CPaintDC dc(this); // device context for painting
00184
00185     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
00186
00187     // Center icon in client rectangle
00188     int cxIcon = GetSystemMetrics(SM_CXICON);
00189     int cyIcon = GetSystemMetrics(SM_CYICON);
00190     CRect rect;
00191     GetClientRect(&rect);
00192     int x = (rect.Width() - cxIcon + 1) / 2;
00193     int y = (rect.Height() - cyIcon + 1) / 2;
00194
00195     // Draw the icon
00196     dc.DrawIcon(x, y, m_hIcon);
00197   }
00198   else
00199   {
00200     CDialog::OnPaint();
00201   }
00202 }
00203
00204 // The system calls this to obtain the cursor to display while the user drags
00205 //  the minimized window.
00206 HCURSOR CADVCGENDlg::OnQueryDragIcon()
00207 {
00208   return (HCURSOR) m_hIcon;
00209 }
00210
00211 void CADVCGENDlg::OnXecute()
00212 {
00213   char buffer[MAX_COUNT];
00214   CString buff1;
00215   // Get the SQL Statement
00216   TRYDB
00217   m_SQLEditBox.GetWindowText(buffer,MAX_COUNT);
00218   if(strlen(buffer) > 0)
00219     OutputIntoDataGrid(buffer);
00220   CATCHDB
00221 }
00222
00223 void CADVCGENDlg::OnBuild()
00224 {
00225
00226   TRYDB;
00227   try
00228   {
00229     // The the Smart Pointer
00230     msdasc::IDataSourceLocatorPtr pOledb;  // Interface to show
00231     //Get the m_pInterface pointer to the DataLinks COM Object
00232     pOledb.CreateInstance(__uuidof(msdasc::DataLinks));  // coclass of IDataSourceLocatorPtr
00233     // Get the Connection
00234 //    if (conn != NULL)  // It contains data release it first
00235 //      conn->Close();
00236     conn = (ado20::_ConnectionPtr) pOledb->PromptNew();
00237
00238     connStr = (char*) conn->ConnectionString;
00239     TRACE("ADO Connection string is %s\n",(char*) conn->ConnectionString);
00240     TRACE("ADO Version is %s\n",(char*) conn->Version);
00241     SetDlgItemText(IDC_CONNECTSTRING,(LPCTSTR) conn->ConnectionString);
00242     UpdateData();
00243     // Set The cursor before the Open !!!
00244     //conn->CursorLocation = ado20::adUseClient;
00245     if(conn->State != ado20::adStateOpen)
00246       conn->Open(L"",L"",L"",-1);
00247
00248 //////////////////////////////////////////////////////////////////////////////
00249     // How to create restrictions
00250     // Pass it the right info
00251     // rs now contains all the data...
00252     // To selectively get Table data only...
00253     ///////////////////////////////////////////////////////////////
00254     _variant_t restrictions;
00255     // For adSchemaTable
00256     int lenCtr=4;
00257     _variant_t criteriaValues[4];
00258     criteriaValues[0].vt = VT_EMPTY;
00259     criteriaValues[1].vt = VT_EMPTY;
00260     criteriaValues[2].vt = VT_EMPTY;
00261     criteriaValues[3].vt = VT_BSTR;
00262     criteriaValues[3].bstrVal = (BSTR)_bstr_t("TABLE");
00263     RestrictionsOnOpenSchema(restrictions,lenCtr, criteriaValues);
00264     // If it contained previous data
00265     if (schemaRs != NULL)
00266     {
00267       schemaRs->putref_ActiveConnection(NULL);
00268       schemaRs->Close();
00269     }
00270
00271     schemaRs = conn->OpenSchema(ado20::adSchemaTables,&restrictions);
00272     if(schemaRs->State == ado20::adStateOpen)
00273     {
00274       schemaRs->MoveFirst();
00275       m_TableListBox.ResetContent();
00276       while(!schemaRs->EOF)
00277       {
00278       if(m_SchemaInfo.GetCheck() == TRUE)
00279         {
00280           m_TableListBox.AddString(VarToBstr(schemaRs->Fields->Item[1L]->Value)+  // The Schema Name
00281             _bstr_t(".")+                       // "."
00282             VarToBstr(schemaRs->Fields->Item[2L]->Value));          // The Table Name
00283         }
00284         else
00285           m_TableListBox.AddString(VarToBstr(schemaRs->Fields->Item[2L]->Value));
00286         hr = schemaRs->MoveNext();
00287       }
00288       TRACE( "Found %lu records.\n", schemaRs->RecordCount );
00289       m_DataGridDisplay.SetRefDataSource( NULL);
00290       m_DataGridDisplay.ClearFields();
00291       m_DataGridDisplay.Refresh();
00292       ////////////////////////////////////////////////////
00293       // Enable Disabled Controls...
00294       SetDlgItemText(IDC_CONNECTSTRING,(LPCTSTR) conn->ConnectionString);
00295       DataRefresh(TRUE);
00296     }
00297     else
00298       MessageBox("Could not open the Schema Information", "Error",MB_OK);
00299   }
00300   catch (_com_error &ce)
00301   {
00302     CString adoStr,msgStr,tempStr;
00303     //
00304     // Trace COM error information.
00305     //
00306     adoStr=_T("");
00307     TRACE( "\nCom Exception Information\n-----------------------------------------------\n" );
00308     TRACE( "Description : %s\n",   (char*) ce.Description()  );
00309     TRACE( "Message     : %s\n",   (char*) ce.ErrorMessage() );
00310     TRACE( "HResult     : 0x%08x\n", ce.Error() );
00311     //
00312     // Trace ADO exception information only if connection is not null.
00313     //
00314     if ( NULL != conn )
00315     {
00316       TRACE( "\nADO Exception Information\n-----------------------------------------------\n" );
00317       ado20::ErrorPtr err;
00318       for ( long i=0; i<conn->Errors->Count; i++ )
00319       {
00320         tempStr=_T("");
00321         err = conn->Errors->Item[i];
00322         TRACE( "Number      : 0x%08x\n", err->Number );
00323         TRACE( "Description : %s\n",    (char*) err->Description );
00324         TRACE( "SQLState    : %s\n",     (char*) err->SQLState );
00325         TRACE( "Source      : %s\n\n",   (char*) err->Source );
00326         tempStr.Format("Ado Exception :\n===============\nDescription : %s\nSource : %s\n",(char*) err->Description,(char*) err->Source);
00327         adoStr += tempStr;
00328       }
00329     }
00330     msgStr.Format("\tCom Exception :\n===============\nDescription : %s\nMessage     : %s\n\t%s",(char*) ce.Description(),(char*) ce.ErrorMessage(), (LPCTSTR) adoStr);
00331     this->MessageBox(msgStr,"Error Message", MB_OK);
00332   }
00333   CATCHDB;
00334 }
00335
00336 _bstr_t CADVCGENDlg::VarToBstr(_variant_t varT)
00337 {
00338   TRYDB
00339   switch(varT.vt)
00340   {
00341   case VT_EMPTY: return _bstr_t("Empty");
00342   case VT_NULL: return _bstr_t("<NULL>");
00343   case VT_ERROR: return _bstr_t("Error");
00344   case VT_BSTR: return _bstr_t(varT.bstrVal);
00345   default: return _bstr_t("Unknown");
00346   }
00347   CATCHDB
00348   return _bstr_t("Wrong Data Type");
00349 }
00350
00351 void CADVCGENDlg::RestrictionsOnOpenSchema(_variant_t &restrictions, int lenCtr, _variant_t *criteriaValues)
00352 {
00353    HRESULT hr = 0;
00354    SAFEARRAY FAR* psa;
00355    SAFEARRAYBOUND rgsabound[1];
00356    rgsabound[0].lLbound = 0;
00357    rgsabound[0].cElements = lenCtr;
00358
00359    TRYDB
00360    psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
00361    // Fill the safe array.
00362    for( long lIndex = 0 ; lIndex < lenCtr ;lIndex++)
00363    {
00364      hr  = SafeArrayPutElement(psa, &lIndex,&criteriaValues[lIndex]);
00365    }
00366    // Initialize the safearray.
00367    restrictions.vt = VT_VARIANT | VT_ARRAY;
00368    V_ARRAY(&restrictions) = psa;
00369    CATCHDB
00370 }
00371
00372 void CADVCGENDlg::OnExit()
00373 {
00374   TRYDB
00375   if (MessageBox("Thanx for using ADVCGEN...","Exit",MB_OK) == IDOK)
00376     DestroyWindow();
00377   CATCHDB
00378 }
00379
00380 void CADVCGENDlg::OnChangeTableList()
00381 {
00382   CString buff1,buffer;
00383   // Get the table name
00384   TRYDB
00385   m_TableListBox.GetText(m_TableListBox.GetCurSel(), buffer);
00386   // Create connection object.
00387   if (buffer.Find(" ") == -1)
00388     buff1.Format("SELECT * FROM %s",buffer,buffer);
00389   else
00390     buff1.Format("SELECT * FROM [%s]",buffer,buffer);
00391   OutputIntoDataGrid((char *) _bstr_t(buff1));
00392   m_SQLEditBox.SetWindowText(buff1);
00393   CATCHDB
00394 }
00395
00396 void CADVCGENDlg::OutputIntoDataGrid(char *buffer)
00397 {
00398   _variant_t vra; // Dummy Rows affected variant
00399
00400   TRYDB
00401   try
00402   {
00403     TRACE( "Instantiating ado connection object...\n" );
00404     // Remember INSERT, Update, Delete commands do not return recordsets
00405     if(dataRs == NULL) // Create it only for the 1st time
00406       hr = dataRs.CreateInstance(__uuidof(ado20::Recordset));
00407     else
00408     {
00409       dataRs->putref_ActiveConnection(NULL);
00410       if(dataRs->State == ado20::adStateOpen)
00411         dataRs->Close();
00412       m_DataGridDisplay.ClearFields();
00413       m_DataGridDisplay.SetRefDataSource(NULL);
00414     }
00415     dataRs->putref_ActiveConnection(conn);
00416     hr = dataRs->Open(_bstr_t(buffer),_variant_t((IDispatch*) conn), ado20::adOpenStatic,ado20::adLockOptimistic,ado20::adCmdText);
00417     if (SUCCEEDED(hr))
00418     {
00419       // Only for select statements do the following
00420       if(dataRs->State == ado20::adStateOpen)
00421       {
00422         TRACE( "Found %lu records.\n", dataRs->RecordCount );
00423         if(dataRs->RecordCount > 0 )
00424         {
00425           m_DataGridDisplay.ClearFields();
00426           m_DataGridDisplay.SetRefDataSource( (IUnknownPtr) dataRs);
00427         }
00428         else
00429           MessageBox("No Records found !!", "Error", MB_OK);
00430         UpdateData();
00431       }
00432     }
00433     else
00434       MessageBox("Could not Open the Query !!", "Error", MB_OK);
00435   }
00436   catch (_com_error &ce)
00437   {
00438     CString adoStr,msgStr,tempStr;
00439     //
00440     // Trace COM error information.
00441     //
00442     adoStr=_T("");
00443     TRACE( "\nCom Exception Information\n-----------------------------------------------\n" );
00444     TRACE( "Description : %s\n",   (char*) ce.Description()  );
00445     TRACE( "Message     : %s\n",   (char*) ce.ErrorMessage() );
00446     TRACE( "HResult     : 0x%08x\n", ce.Error() );
00447     //
00448     // Trace ADO exception information only if connection is not null.
00449     //
00450     if ( NULL != conn )
00451     {
00452       TRACE( "\nADO Exception Information\n-----------------------------------------------\n" );
00453       ado20::ErrorPtr err;
00454       for ( long i=0; i<conn->Errors->Count; i++ )
00455       {
00456         tempStr=_T("");
00457         err = conn->Errors->Item[i];
00458         TRACE( "Number      : 0x%08x\n", err->Number );
00459         TRACE( "Description : %s\n",    (char*) err->Description );
00460         TRACE( "SQLState    : %s\n",     (char*) err->SQLState );
00461         TRACE( "Source      : %s\n\n",   (char*) err->Source );
00462         tempStr.Format("Ado Exception :\n===============\nDescription : %s\nSource : %s\n",(char*) err->Description,(char*) err->Source);
00463         adoStr += tempStr;
00464       }
00465     }
00466     msgStr.Format("Com Exception :\n===============\nDescription : %s\nMessage     : %s\n%s",(char*) ce.Description(),(char*) ce.ErrorMessage(), (LPCTSTR) adoStr);
00467     MessageBox(msgStr,"Error Message", MB_OK);
00468   }
00469   CATCHDB
00470
00471 }
00472
00473 void CADVCGENDlg::DataRefresh(BOOL bflag)
00474 {
00475   m_SQLEditBox.EnableWindow(bflag); // enable the SQL statement Edit Box
00476   m_TableListBox.EnableWindow(bflag); // The Select Table ListBox...
00477   (GetDlgItem(IDC_DATAGRID1))->EnableWindow(bflag); // The Datagrid
00478   (GetDlgItem(IDC_BUTTON2))->EnableWindow(bflag); // The Xeceute Button
00479   (GetDlgItem(ID_REFRESH))->EnableWindow(bflag); // The Refresh Button
00480   UpdateData();
00481 }
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/ui.cpp Source File

  • Web
  • NetMeeting
  • PlugTransport

ui.cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     PLUGTRANSPORT.EXE
00003 //  File:       UI.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #include "precomp.h"
00017
00018
00019 //*******************
00020 // DEFINITIONS
00021 //*******************
00022
00023 #define MAX_SZ          200
00024 #define DEFAULTCOMPORT  TEXT("Com1")
00025
00026
00027 //*******************
00028 // GLOBALS
00029 //*******************
00030
00031 HINSTANCE ghInst;
00032
00033
00034 //**********************
00035 //FUNCTION DECLARATIONS
00036 //**********************
00037
00038 BOOL CALLBACK MainDlgProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
00039
00040
00041 //****************************************************************************
00042 //
00043 //    FUNCTION:   int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst, LPSTR szCmdLine, INT nCmdShow)
00044 //
00045 //    PURPOSE:    calls initialization function
00046
00047 //    COMMENTS:   Windows recognizes this function by name as the initial entry point
00048 //                for the program.  This function calls the application initialization
00049 //                routine.
00050 //
00051 //****************************************************************************
00052
00053 int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst, LPSTR szCmdLine, INT nCmdShow)
00054 {
00055     HRESULT hr = S_OK;
00056     int     iRes = 0;
00057     WSADATA wsa_data;
00058     WORD    version_requested = MAKEWORD (1,1);
00059
00060     // Initialize COM
00061     hr = CoInitialize(NULL);
00062     if (FAILED(hr))
00063     {
00064         MessageBox(NULL, TEXT("CoInitialize"), TEXT("Error"), MB_OK);
00065         return -1;
00066     }
00067
00068     ghInst = hInst;
00069
00070     // Initialize windows sockets
00071     iRes = ::WSAStartup(version_requested, &wsa_data);
00072     if (iRes)
00073     {
00074         MessageBox(NULL, TEXT("WSAStartup failed"), TEXT("Error"), MB_OK);
00075         return -1;
00076     }
00077
00078     // Load UI
00079     iRes = DialogBox(hInst,MAKEINTRESOURCE(IDD_PLUGTRANSPORT),NULL,(DLGPROC)MainDlgProc);
00080
00081     // Terminate use of Windows sockets
00082     iRes = ::WSACleanup();
00083     if (SOCKET_ERROR == iRes)
00084     {
00085         MessageBox(NULL, TEXT("WSACleanup failed"), TEXT("Error"), MB_OK);
00086         return -1;
00087     }
00088
00089     // Uninitialize COM
00090     CoUninitialize();
00091
00092     return iRes;
00093 }
00094
00095
00096 //****************************************************************************
00097 //
00098 //    FUNCTION:   BOOL CALLBACK MainDlgProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam)
00099 //
00100 //    PURPOSE:    This function is called when the Main Dialog initializes.
00101 //                It sets up the initial interface pointers and updates
00102 //                the dialog accordingly
00103 //    COMMENTS:
00104 //
00105 //
00106
00107 //****************************************************************************
00108
00109 BOOL CALLBACK MainDlgProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam)
00110 {
00111
00112     static Conf *pConf = NULL;
00113     static CPluggableTransport *pPlugTrans = NULL;
00114     HRESULT hr = S_OK;
00115
00116     switch (uMsg)
00117     {
00118     case WM_INITDIALOG:
00119     {
00120         pConf = new Conf(hWnd);
00121         if (NULL == pConf)
00122         {
00123             MessageBox(NULL,TEXT("Not enough memory"),TEXT("Error"),MB_OK);
00124             EndDialog(hWnd,0);
00125             return false;
00126         }
00127
00128         pPlugTrans = new CPluggableTransport();
00129         if (NULL == pPlugTrans)
00130         {
00131             MessageBox(NULL,TEXT("Not enough memory"),TEXT("Error"),MB_OK);
00132             EndDialog(hWnd,0);
00133             return false;
00134         }
00135
00136         // Initialize the NM part of the Conf object
00137         hr = pConf->Initialize();
00138         if (FAILED(hr))
00139         {
00140             MessageBox(NULL,TEXT("NetMeeting cannot start"),TEXT("Error"),MB_OK);
00141             EndDialog(hWnd,0);
00142             return false;
00143         }
00144
00145         // Initialize the PluggableTransport part of the Conf object
00146         hr = pPlugTrans->Initialize(pConf->GetNmManager());
00147         if (FAILED(hr))
00148         {
00149             MessageBox(NULL,TEXT("Plug cannot be initialized"),TEXT("Error"),MB_OK);
00150             EndDialog(hWnd,0);
00151             return false;
00152         }
00153
00154         // update UI
00155         SetDlgItemText(hWnd, ID_CALL, TEXT("&Call"));
00156         SetDlgItemText(hWnd, ID_CONNECT, TEXT("Co&nnect"));
00157         EnableWindow(GetDlgItem(hWnd, ID_CALL), false);
00158         EnableWindow(GetDlgItem(hWnd, ID_CONNECT), true);
00159         EnableWindow(GetDlgItem(hWnd, IDC_LISTEN), false);
00160         EnableWindow(GetDlgItem(hWnd, IDC_CONNECT), false);
00161         return true;
00162     }
00163
00164     case WM_CLOSE:
00165     {
00166         if (NULL != pPlugTrans)
00167         {
00168             // Close any connections of any kind that are still there
00169             if (pPlugTrans->InConnection())
00170             {
00171                 hr = pPlugTrans->CloseConnection(FRAMING_LEGACY_PSTN);
00172                 if (FAILED(hr))
00173                 {
00174                     // Ignore the failure for now
00175                 }
00176
00177                 hr = pPlugTrans->CloseConnection(FRAMING_X224);
00178                 if (FAILED(hr))
00179                 {
00180                     // Ignore the failure for now
00181                 }
00182             }
00183
00184             hr = pPlugTrans->Uninitialize();
00185             if (FAILED(hr))
00186             {
00187                 MessageBox(NULL,TEXT("pPlugTrans->Uninitialize failed"),TEXT("Error"),MB_OK);
00188             }
00189
00190             delete pPlugTrans;
00191             pPlugTrans = NULL;
00192         }
00193
00194         if (NULL != pConf)
00195         {
00196             // Hangup if in a call
00197             if (pConf->InCall())
00198             {
00199                 hr = pConf->HangUp();
00200                 if (FAILED(hr))
00201                 {
00202                     MessageBox(NULL,TEXT("pConf->HangUp failed"),TEXT("Error"),MB_OK);
00203                 }
00204             }
00205
00206             // Clear and delete Conf object
00207             hr = pConf->Uninitialize();
00208             if (FAILED(hr))
00209             {
00210                 MessageBox(NULL,TEXT("pConf->Uninitialize failed"),TEXT("Error"),MB_OK);
00211             }
00212
00213             delete pConf;
00214             pConf = NULL;
00215         }
00216
00217         EndDialog(hWnd, 0);
00218         return true;
00219     }
00220
00221     case WM_CONNECTING:
00222     case WM_CONNECTED:
00223     {
00224         // Message from Conf object that a user is connected
00225         SetDlgItemText(hWnd,ID_CALL,TEXT("Han&gup"));
00226         return true;
00227     }
00228
00229     case WM_DISCONNECTED:
00230     {
00231         // Message from Conf object that a user disconnected or rejected call
00232         SetDlgItemText(hWnd,ID_CALL,TEXT("C&all"));
00233         EnableWindow(GetDlgItem(hWnd, ID_CALL), false);
00234         EnableWindow(GetDlgItem(hWnd, IDC_LISTEN), false);
00235         EnableWindow(GetDlgItem(hWnd, IDC_CONNECT), false);
00236
00237         // Close the connection
00238         SendMessage(hWnd, WM_COMMAND, ID_CONNECT, 0);
00239         return true;
00240     }
00241
00242     case WM_PLUGABLE_SOCKET:
00243     {
00244         ULONG event = WSAGETSELECTEVENT(lParam);
00245
00246         if (NULL == pPlugTrans)
00247         {
00248             MessageBox(NULL, TEXT("pPlugTrans is NULL"), TEXT("Error"), MB_OK);
00249             return false;
00250         }
00251
00252         // We get FD_CLOSE when the socket is closed by the remote site
00253         if (event & FD_CLOSE)
00254         {
00255             SetEvent(pPlugTrans->GetCloseEventHandle());
00256         }
00257
00258         //We get FD_READ when there is data available for us to read
00259         if (event & FD_READ)
00260         {
00261             SetEvent(pPlugTrans->GetReadEventHandle());
00262         }
00263
00264         // We get FD_WRITE when there is space available to write data to WinSock
00265         if (event & FD_WRITE)
00266         {
00267             SetEvent(pPlugTrans->GetWriteEventHandle());
00268         }
00269
00270         // We get FD_CONNECT when connecting to a remote site
00271         if (event & FD_CONNECT)
00272         {
00273             // No FD_CONNECT code is needed for this sample
00274         }
00275
00276         // We get FD_ACCEPT when a remote site is connecting with us
00277         if (event & FD_ACCEPT)
00278         {
00279             hr = pPlugTrans->AcceptConnection(hWnd);
00280             if (FAILED(hr))
00281             {
00282                 MessageBox(NULL, TEXT("Accept connection failed"), TEXT("Error"), MB_OK);
00283                 return false;
00284             }
00285
00286             // update UI
00287             SetDlgItemText(hWnd,ID_CONNECT,TEXT("&Disconnect"));
00288             EnableWindow(GetDlgItem(hWnd, ID_CALL), true);
00289         }
00290         return true;
00291     }
00292
00293     case WM_COMMAND:
00294     {
00295         switch (LOWORD(wParam))
00296         {
00297         case IDC_PSTN:
00298         {
00299             EnableWindow(GetDlgItem(hWnd, IDC_LISTEN), true);
00300             EnableWindow(GetDlgItem(hWnd, IDC_CONNECT), true);
00301             return true;
00302         }
00303         case IDC_X224:
00304         {
00305             EnableWindow(GetDlgItem(hWnd, IDC_LISTEN), true);
00306             EnableWindow(GetDlgItem(hWnd, IDC_CONNECT), true);
00307             // It seems that user wants to use X224. Let's create the listen socket
00308             // in order to be ready to accept new connections
00309             if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_LISTEN))
00310             {
00311                 if (FAILED(pPlugTrans->m_pX224->CreateListenSocket(hWnd)))
00312                 {
00313                     MessageBox(hWnd, TEXT("Create listen socket failed"), TEXT("Error"), MB_OK);
00314                     return false;
00315                 }
00316             }
00317             return true;
00318         }
00319
00320         case ID_CALL:
00321         {
00322             // If not in a call, then make a call, otherwise hang up.
00323             if (NULL == pConf)
00324             {
00325                 return false;
00326             }
00327
00328             if (FALSE == pConf->InCall())
00329             {
00330                 hr = pConf->Call(pPlugTrans);
00331                 if (FAILED(hr))
00332                 {
00333                 }
00334                 return true;
00335             }
00336             else
00337             {
00338                 hr = pConf->HangUp();
00339                 if (FAILED(hr))
00340                 {
00341                 }
00342                 return true;
00343             }
00344         }
00345         case ID_CONNECT:
00346         {
00347             // If not in a connection, then make a connection. otherwise close the connections
00348             if (NULL == pPlugTrans)
00349             {
00350                 return false;
00351             }
00352
00353             if (!pPlugTrans->InConnection())
00354             {
00355                 // get the machine name or the com port you are gonna use
00356                 // It must always be something there
00357                 TCHAR szName[MAX_SZ];
00358
00359                 GetDlgItemText(hWnd,IDC_NAME,szName,MAX_SZ);
00360                 if (szName[0] == TEXT('\0'))
00361                 {
00362                     MessageBox(hWnd, TEXT("Enter a machine name to connect to or a com port to use"), TEXT("Error"), MB_OK);
00363                     return false;
00364                 }
00365
00366                 if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_PSTN))
00367                 {
00368                     if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_LISTEN))
00369                     {
00370                         // This is the case in which we use PSTN stack
00371                         //and we are going to accept a connection
00372                         if (SUCCEEDED(pPlugTrans->AcceptConnection(szName)))
00373                         {
00374                             SetDlgItemText(hWnd,ID_CONNECT,TEXT("&Disconnect"));
00375                             EnableWindow(GetDlgItem(hWnd, ID_CALL), true);
00376                             return true;
00377                         }
00378                         return false;
00379                     }
00380
00381                     if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CONNECT))
00382                     {
00383                         // This is the case in which we use PSTN stack
00384                         //and we are going to make a connection
00385                         if (SUCCEEDED(pPlugTrans->CreateConnection(szName)))
00386                         {
00387                             SetDlgItemText(hWnd,ID_CONNECT,TEXT("&Disconnect"));
00388                             EnableWindow(GetDlgItem(hWnd, ID_CALL), true);
00389                             return true;
00390                         }
00391                         return false;
00392                     }
00393                 }
00394
00395                 if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_X224))
00396                 {
00397                     if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CONNECT))
00398                     {
00399                         // This is the case in which we use X224 stack
00400                         //and we are going to create a connection
00401
00402                         // Create the connect socket
00403                         if (FAILED(pPlugTrans->m_pX224->CreateConnectSocket(hWnd, szName)))
00404                         {
00405                             MessageBox(hWnd, TEXT("Create connect socket failed"), TEXT("Error"), MB_OK);
00406                             return false;
00407                         }
00408
00409                         // Create the connection
00410                         if (SUCCEEDED(pPlugTrans->CreateConnection()))
00411                         {
00412                             SetDlgItemText(hWnd,ID_CONNECT,TEXT("&Disconnect"));
00413                             EnableWindow(GetDlgItem(hWnd, ID_CALL), true);
00414                             return true;
00415                         }
00416                         return false;
00417                     }
00418                 }
00419             }
00420             else
00421             {
00422                 // close any connections of any kind
00423                 pPlugTrans->CloseConnection(FRAMING_LEGACY_PSTN);
00424                 pPlugTrans->CloseConnection(FRAMING_X224);
00425                 SetDlgItemText(hWnd,ID_CONNECT,TEXT("&Connect"));
00426                 EnableWindow(GetDlgItem(hWnd, ID_CALL), false);
00427                 EnableWindow(GetDlgItem(hWnd, IDC_LISTEN), false);
00428                 EnableWindow(GetDlgItem(hWnd, IDC_CONNECT), false);
00429                 return true;
00430             }
00431
00432         return false;
00433         }
00434
00435         case IDC_LISTEN:
00436         {
00437             if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_X224))
00438             {
00439                 // It seems that the user wants to use X224. Let's create the listen socket
00440                 // in order to be ready to accept new connections
00441                 SendDlgItemMessage (hWnd, IDC_NAME, WM_SETTEXT, 0, (LPARAM)(LPSTR) pPlugTrans->m_pX224->SetAndGetHostName());
00442                 if (FAILED(pPlugTrans->m_pX224->CreateListenSocket(hWnd)))
00443                 {
00444                     MessageBox(hWnd, TEXT("Create listen socket failed"), TEXT("Error"), MB_OK);
00445                     return false;
00446                 }
00447             }
00448
00449             if (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_PSTN))
00450             {
00451                 // It seems that the user wants to use PSTN. Let's show him the default
00452                 // com port
00453                 SendDlgItemMessage(hWnd, IDC_NAME, WM_SETTEXT, 0, (LPARAM)(LPSTR) DEFAULTCOMPORT);
00454             }
00455
00456             return true;
00457         }
00458         }
00459      }
00460     default:
00461         return false;
00462     }
00463 }
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

XInterface< T > Member List

This is the complete list of members for XInterface< T >, including all inherited members.
_p | XInterface< T > | [private]
Acquire() | XInterface< T > | [inline]
Acquire() | XInterface< T > | [inline]
Acquire() | XInterface< T > | [inline]
Free() | XInterface< T > | [inline]
GetIUPointer() | XInterface< T > | [inline]
GetIUPointer() | XInterface< T > | [inline]
GetIUPointer() | XInterface< T > | [inline]
GetPointer() const | XInterface< T > | [inline]
GetPointer() const | XInterface< T > | [inline]
GetPointer() const | XInterface< T > | [inline]
GetPPointer() | XInterface< T > | [inline]
GetPPointer() | XInterface< T > | [inline]
GetPPointer() | XInterface< T > | [inline]
GetQIPointer() | XInterface< T > | [inline]
GetQIPointer() | XInterface< T > | [inline]
GetQIPointer() | XInterface< T > | [inline]
GetReference() | XInterface< T > | [inline]
IsNull() | XInterface< T > | [inline]
IsNull() | XInterface< T > | [inline]
operator->() | XInterface< T > | [inline]
operator->() | XInterface< T > | [inline]
operator->() | XInterface< T > | [inline]
Set(T *p) | XInterface< T > | [inline]
XInterface(T *p=0) | XInterface< T > | [inline]
XInterface(T *p=0) | XInterface< T > | [inline]
XInterface(T *p=0) | XInterface< T > | [inline]
~XInterface() | XInterface< T > | [inline]
~XInterface() | XInterface< T > | [inline]
~XInterface() | XInterface< T > | [inline]
Generated on Wed Nov 13 2024 16:58:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/Objfdbk.c Source File

  • Com
  • Fundamentals
  • OleStd

Objfdbk.c

Go to the documentation of this file.
00001 /*
00002  * OBJFDBK.C
00003  *
00004  * Miscellaneous API's to generate UI feedback effects for OLE objects. This
00005  * is part of the OLE 2.0 User Interface Support Library.
00006  * The following feedback effects are supported:
00007  *      1. Object selection handles (OleUIDrawHandles)
00008  *      2. Open Object window shading (OleUIDrawShading)
00009  *
00010  * Copyright (c)1992 - 2000 Microsoft Corporation, All Right Reserved
00011  */
00012
00013 #define STRICT  1
00014 #include "olestd.h"
00015
00016 static void DrawHandle(HDC hdc, int x, int y, UINT cSize, BOOL bInvert, BOOL fDraw);
00017
00018 /*
00019  * OleUIDrawHandles
00020  *
00021  * Purpose:
00022  *  Draw handles or/and boundary around Container Object when selected
00023  *
00024  * Parameters:
00025  *  lpRect      Dimensions of Container Object
00026  *  hdc         HDC of Container Object (MM_TEXT mapping mode)
00027  *  dwFlags-
00028  *      Exclusive flags
00029  *          OLEUI_HANDLES_INSIDE    Draw handles on inside of rect
00030  *          OLEUI_HANDLES_OUTSIDE   Draw handles on outside of rect
00031  *      Optional flags
00032  *          OLEUI_HANDLES_NOBORDER  Draw handles only, no rect
00033  *          OLEUI_HANDLES_USEINVERSE
00034  *              use invert for handles and rect, o.t. use COLOR_WINDOWTEXT
00035  *  cSize       size of handle box
00036  *  fDraw       Draw if TRUE, erase if FALSE
00037  *
00038  * Return Value: null
00039  *
00040  */
00041 STDAPI_(void) OleUIDrawHandles(
00042         LPRECT  lpRect,
00043         HDC     hdc,
00044         DWORD   dwFlags,
00045         UINT    cSize,
00046         BOOL    fDraw
00047 )
00048 {
00049         HBRUSH  hbr;
00050         RECT    rc;
00051         int     bkmodeOld;
00052         BOOL    bInvert = (BOOL) (dwFlags & OLEUI_HANDLES_USEINVERSE);
00053
00054         CopyRect((LPRECT)&rc, lpRect);
00055
00056         bkmodeOld = SetBkMode(hdc, TRANSPARENT);
00057
00058         if (dwFlags & OLEUI_HANDLES_OUTSIDE)
00059                 InflateRect((LPRECT)&rc, cSize - 1, cSize - 1);
00060
00061         // Draw the handles inside the rectangle boundary
00062         DrawHandle(hdc, rc.left, rc.top, cSize, bInvert, fDraw);
00063         DrawHandle(hdc, rc.left, rc.top+(rc.bottom-rc.top-cSize)/2, cSize, bInvert, fDraw);
00064         DrawHandle(hdc, rc.left, rc.bottom-cSize, cSize, bInvert, fDraw);
00065         DrawHandle(hdc, rc.left+(rc.right-rc.left-cSize)/2, rc.top, cSize, bInvert, fDraw);
00066         DrawHandle(hdc, rc.left+(rc.right-rc.left-cSize)/2, rc.bottom-cSize, cSize, bInvert, fDraw);
00067         DrawHandle(hdc, rc.right-cSize, rc.top, cSize, bInvert, fDraw);
00068         DrawHandle(hdc, rc.right-cSize, rc.top+(rc.bottom-rc.top-cSize)/2, cSize, bInvert, fDraw);
00069         DrawHandle(hdc, rc.right-cSize, rc.bottom-cSize, cSize, bInvert, fDraw);
00070
00071         if (!(dwFlags & OLEUI_HANDLES_NOBORDER)) {
00072                 if (fDraw)
00073                         hbr = GetStockObject(BLACK_BRUSH);
00074                 else
00075                         hbr = GetStockObject(WHITE_BRUSH);
00076
00077                 FrameRect(hdc, lpRect, hbr);
00078         }
00079
00080         SetBkMode(hdc, bkmodeOld);
00081 }
00082
00083
00084
00085 /*
00086  * DrawHandle
00087  *
00088  * Purpose:
00089  *  Draw a handle box at the specified coordinate
00090  *
00091  * Parameters:
00092  *  hdc         HDC to be drawn into
00093  *  x, y        upper left corner coordinate of the handle box
00094  *  cSize       size of handle box
00095  *  bInvert     use InvertRect() if TRUE, otherwise use Rectangle()
00096  *  fDraw       Draw if TRUE, erase if FALSE, ignored if bInvert is TRUE
00097  *
00098  * Return Value: null
00099  *
00100  */
00101 static void DrawHandle(HDC hdc, int x, int y, UINT cSize, BOOL bInvert, BOOL fDraw)
00102 {
00103         HBRUSH  hbr;
00104         HBRUSH  hbrOld;
00105         HPEN    hpen;
00106         HPEN    hpenOld;
00107         RECT    rc;
00108
00109
00110         if (!bInvert) {
00111                 if (fDraw) {
00112                         hpen = GetStockObject(BLACK_PEN);
00113                         hbr = GetStockObject(BLACK_BRUSH);
00114                 } else {
00115                         hpen = GetStockObject(WHITE_PEN);
00116                         hbr = GetStockObject(WHITE_PEN);
00117                 }
00118
00119                 hpenOld = SelectObject(hdc, hpen);
00120                 hbrOld = SelectObject(hdc, hbr);
00121                 Rectangle(hdc, x, y, x+cSize, y+cSize);
00122                 SelectObject(hdc, hpenOld);
00123                 SelectObject(hdc, hbrOld);
00124         }
00125         else {
00126                 rc.left = x;
00127                 rc.top = y;
00128                 rc.right = x + cSize;
00129                 rc.bottom = y + cSize;
00130                 InvertRect(hdc, (LPRECT)&rc);
00131         }
00132 }
00133
00134
00135 /*
00136  * OleUIDrawShading
00137  *
00138  * Purpose:
00139  *  Shade the object when it is in in-place editing. Borders are drawn
00140  *  on the Object rectangle. The right and bottom edge of the rectangle
00141  *  are excluded in the drawing.
00142  *
00143  * Parameters:
00144  *  lpRect      Dimensions of Container Object
00145  *  hdc         HDC for drawing
00146  *  dwFlags-
00147  *      Exclusive flags
00148  *          OLEUI_SHADE_FULLRECT    Shade the whole rectangle
00149  *          OLEUI_SHADE_BORDERIN    Shade cWidth pixels inside rect
00150  *          OLEUI_SHADE_BORDEROUT   Shade cWidth pixels outside rect
00151  *      Optional flags
00152  *          OLEUI_SHADE_USEINVERSE
00153  *              use PATINVERT instead of the hex value
00154  *  cWidth      width of border in pixel
00155  *
00156  * Return Value: null
00157  *
00158  */
00159 STDAPI_(void) OleUIDrawShading(LPRECT lpRect, HDC hdc, DWORD dwFlags, UINT cWidth)
00160 {
00161         HBRUSH  hbr;
00162         HBRUSH  hbrOld;
00163         HBITMAP hbm;
00164         RECT    rc;
00165         WORD    wHatchBmp[] = {0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88};
00166         COLORREF cvText;
00167         COLORREF cvBk;
00168
00169         hbm = CreateBitmap(8, 8, 1, 1, wHatchBmp);
00170         hbr = CreatePatternBrush(hbm);
00171         hbrOld = SelectObject(hdc, hbr);
00172
00173         rc = *lpRect;
00174
00175         if (dwFlags == OLEUI_SHADE_FULLRECT) {
00176                 cvText = SetTextColor(hdc, RGB(255, 255, 255));
00177                 cvBk = SetBkColor(hdc, RGB(0, 0, 0));
00178                 PatBlt(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
00179                         0x00A000C9L /* DPa */ );
00180
00181         } else {    // either inside or outside rect
00182
00183                 if (dwFlags == OLEUI_SHADE_BORDEROUT)
00184                         InflateRect((LPRECT)&rc, cWidth - 1, cWidth - 1);
00185
00186                 cvText = SetTextColor(hdc, RGB(255, 255, 255));
00187                 cvBk = SetBkColor(hdc, RGB(0, 0, 0));
00188                 PatBlt(hdc, rc.left, rc.top, rc.right - rc.left,
00189                         cWidth, 0x00A000C9L /* DPa */);
00190                 PatBlt(hdc, rc.left, rc.top, cWidth, rc.bottom - rc.top,
00191                         0x00A000C9L /* DPa */);
00192                 PatBlt(hdc, rc.right - cWidth, rc.top, cWidth,
00193                         rc.bottom - rc.top, 0x00A000C9L /* DPa */);
00194                 PatBlt(hdc, rc.left, rc.bottom - cWidth, rc.right-rc.left,
00195                         cWidth, 0x00A000C9L /* DPa */);
00196         }
00197
00198         SetTextColor(hdc, cvText);
00199         SetBkColor(hdc, cvBk);
00200         SelectObject(hdc, hbrOld);
00201         DeleteObject(hbr);
00202         DeleteObject(hbm);
00203 }
00204
00205
00206 /*
00207  * OleUIShowObject
00208  *
00209  * Purpose:
00210  *  Draw the ShowObject effect around the object
00211  *
00212  * Parameters:
00213  *  lprc        rectangle for drawing
00214  *  hdc         HDC for drawing
00215  *  fIsLink     linked object (TRUE) or embedding object (FALSE)
00216  *
00217  * Return Value: null
00218  *
00219  */
00220 STDAPI_(void) OleUIShowObject(LPCRECT lprc, HDC hdc, BOOL fIsLink)
00221 {
00222         HPEN    hpen;
00223         HPEN    hpenOld;
00224         HBRUSH  hbrOld;
00225
00226         if (!lprc || !hdc)
00227                 return;
00228
00229         hpen = fIsLink ? CreatePen(PS_DASH, 1, RGB(0,0,0)) :
00230                                          GetStockObject(BLACK_PEN);
00231
00232         if (!hpen)
00233                 return;
00234
00235         hpenOld = SelectObject(hdc, hpen);
00236         hbrOld = SelectObject(hdc, GetStockObject(NULL_BRUSH));
00237
00238         Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom);
00239
00240         SelectObject(hdc, hpenOld);
00241         SelectObject(hdc, hbrOld);
00242
00243         if (fIsLink)
00244                 DeleteObject(hpen);
00245
00246 }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/ResProp.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

ResProp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ResProp.h
00007 //
00008 //  Implementation File:
00009 //      ResProp.cpp
00010 //
00011 //  Description:
00012 //      Definition of the resource extension property page classes.
00013 //
00014 //  Author:
00015 //      <name> (<e-mail name>) Mmmm DD, 2003
00016 //
00017 //  Revision History:
00018 //
00019 //  Notes:
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 #pragma once
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Include Files
00027 /////////////////////////////////////////////////////////////////////////////
00028
00029 #ifndef _BASEPAGE_H_
00030 #include "BasePage.h"   // for CBasePropertyPage
00031 #endif
00032
00033 #ifndef _PROPLIST_H_
00034 #include "PropList.h"   // for CObjectPropert
00035 #endif
00036
00037 /////////////////////////////////////////////////////////////////////////////
00038 // Forward Class Declarations
00039 /////////////////////////////////////////////////////////////////////////////
00040
00041 class CFileShareSampleParamsPage;
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // External Class Declarations
00045 /////////////////////////////////////////////////////////////////////////////
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 //
00049 //  CFileShareSampleParamsPage
00050 //
00051 //  Purpose:
00052 //      Parameters page for resources.
00053 //
00054 /////////////////////////////////////////////////////////////////////////////
00055
00056 class CFileShareSampleParamsPage
00057     : public CBasePropertyPage
00058 {
00059     DECLARE_DYNCREATE( CFileShareSampleParamsPage )
00060
00061 //
00062 //  Construction
00063 //
00064
00065 public:
00066     CFileShareSampleParamsPage( void );
00067
00068 //
00069 //  Dialog Data
00070 //
00071
00072     //{{AFX_DATA(CFileShareSampleParamsPage)
00073     enum { IDD = IDD_PP_FILESHARESAMPLE_PARAMETERS };
00074     CEdit   m_editShareName;
00075     CEdit   m_editPath;
00076     CString m_strShareName;
00077     CString m_strPath;
00078     CString m_strRemark;
00079     DWORD   m_nMaxUsers;
00080     //}}AFX_DATA
00081     CString m_strPrevShareName;
00082     CString m_strPrevPath;
00083     CString m_strPrevRemark;
00084     DWORD   m_nPrevMaxUsers;
00085
00086 protected:
00087     enum
00088     {
00089         epropShareName,
00090         epropPath,
00091         epropRemark,
00092         epropMaxUsers,
00093         epropMAX
00094     };
00095     CObjectProperty     m_rgProps[ epropMAX ];
00096
00097 // Overrides
00098     // ClassWizard generate virtual function overrides
00099     //{{AFX_VIRTUAL(CFileShareSampleParamsPage)
00100     public:
00101     virtual BOOL OnSetActive();
00102     protected:
00103     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00104     //}}AFX_VIRTUAL
00105
00106 protected:
00107     virtual const CObjectProperty * Pprops( void ) const    { return m_rgProps; }
00108     virtual DWORD                   Cprops( void ) const    { return sizeof( m_rgProps ) / sizeof( CObjectProperty ); }
00109
00110 //
00111 //  Implementation
00112 //
00113
00114 protected:
00115     BOOL    BAllRequiredFieldsPresent( void ) const;
00116
00117     // Generated message map functions
00118     //{{AFX_MSG(CFileShareSampleParamsPage)
00119     virtual BOOL OnInitDialog();
00120     afx_msg void OnChangeRequiredField();
00121     //}}AFX_MSG
00122     DECLARE_MESSAGE_MAP()
00123
00124 };  //*** class CFileShareSampleParamsPage
00125
00126 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/Iconpro/MDIChild.C Source File

  • WinUI
  • Resource
  • Iconpro

MDIChild.C

Go to the documentation of this file.
00001 /****************************************************************************\
00002 *
00003 *     FILE:     MDIChild.C
00004 *
00005 *     PURPOSE:  IconPro Project MDI Child Window handling c file
00006 *
00007 *     COMMENTS: This file contains the MDI Child Window handling code
00008 *
00009 *     FUNCTIONS:
00010 *      EXPORTS:
00011 *               IconChildWndProc   - Window Procedure for the MDI children
00012 *      LOCALS:
00013 *               Draw3DRect         - Draws a rectangle using 3D colors
00014 *               EraseBackground    - Draws the MDI child's background
00015 *               CreateChildren     - Creates MDI child's child windows
00016 *               CreateChildListBox - Creates and shows a list box
00017 *               AddFormatDlgProc   - Dialog Proc for AddFormat dialog
00018 *
00019 *     Copyright 1995 - 2000 Microsoft Corp.
00020 *
00021 *
00022 * History:
00023 *                July '95 - Created
00024 *
00025 \****************************************************************************/
00026 #include <windows.h>
00027 #include <commctrl.h>
00028 #include <commdlg.h>
00029 #include <malloc.h>
00030 #include "Icons.h"
00031 #include "IconPro.h"
00032 #include "Resource.h"
00033 #include "MDIChild.H"
00034
00035
00036 /****************************************************************************/
00037 // External Globals
00038 extern HINSTANCE    hInst;
00039 extern HWND         hWndMain, hMDIClientWnd;
00040 /****************************************************************************/
00041
00042
00043 /****************************************************************************/
00044 // Prototypes for local functions
00045 BOOL Draw3DRect( HDC hDC, RECT Rect, BOOL bSunken );
00046 void EraseBackground( HWND hWnd, HDC hDC );
00047 BOOL CreateChildren( HWND hWnd );
00048 HWND CreateChildListBox( HWND hWndParent, UINT ID, PRECT pRect );
00049 BOOL CALLBACK AddFormatDlgProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
00050 /****************************************************************************/
00051
00052
00053
00054 /****************************************************************************
00055 *
00056 *     FUNCTION: IconChildWndProc
00057 *
00058 *     PURPOSE:  Window Procedure for MDI child window
00059 *
00060 *     PARAMS:   HWND hWnd     - This window handle
00061 *               UINT Msg      - Which Message?
00062 *               WPARAM wParam - message parameter
00063 *               LPARAM lParam - message parameter
00064 *
00065 *     RETURNS:  LRESULT - depends on message
00066 *
00067 * History:
00068 *                July '95 - Created
00069 *
00070 \****************************************************************************/
00071 LRESULT CALLBACK IconChildWndProc(
00072     HWND hWnd,
00073     UINT Msg,
00074     WPARAM wParam,
00075     LPARAM lParam )
00076 {
00077     // Which message is it?
00078     switch( Msg )
00079     {
00080         // User pressed left mouse button
00081         // Should be re-generate the AND mask?
00082         case WM_LBUTTONDOWN:
00083             {
00084                 PCHILDWINDOWDATA pcwd = NULL;
00085
00086                 // Get the icon resource data aassociated with this window
00087                 if( (pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA )) == NULL )
00088                 {
00089                     break;
00090                 }
00091
00092                 // Do something only if the CNTRL key is pressed too
00093                 if( MK_CONTROL & wParam )
00094                 {
00095                     POINTS  pts       = MAKEPOINTS(lParam);
00096                     POINT pt        = {0};
00097                     RECT    ImageRect = {0};
00098                     DWORD nIndex;
00099
00100                     pt.x = pts.x; pt.y = pts.y;
00101                     // Do we have some icon resource data?
00102                     if( pcwd->pIR != NULL )
00103                     {
00104                         // Which image is selected right now?
00105                         if( (nIndex = (DWORD)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00106                         {
00107                             // Where is it drawn
00108                             ImageRect = GetXORImageRect( pcwd->XORRect, &(pcwd->pIR->IconImages[nIndex]) );
00109                             // Is the mouse click in the image?
00110                             if( PtInRect( &ImageRect, pt ) )
00111                             {
00112                                 HCURSOR hOldCursor = NULL;
00113
00114                                 // This might take a while :(
00115                                 hOldCursor = SetCursor( LoadCursor(NULL,IDC_WAIT) );
00116                                 pt.x -= ImageRect.left;
00117                                 pt.y -= ImageRect.top;
00118                                 // generate the new AND mask
00119                                 MakeNewANDMaskBasedOnPoint( &(pcwd->pIR->IconImages[nIndex]), pt );
00120                                 // force a redraw
00121                                 InvalidateRect( hWnd, NULL, TRUE );
00122                                 //  Set changed flag
00123                                 pcwd->pIR->bHasChanged = TRUE;
00124                                 // finally, its over, put the cursor back
00125                                 SetCursor( hOldCursor );
00126                             }
00127                         }
00128                     }
00129                 }
00130             }
00131             break; // End WM_LBUTTONDOWN
00132
00133         // Time to say "Goodbye"
00134         case WM_CLOSE:
00135             {
00136                 PCHILDWINDOWDATA    pcwd        = NULL;
00137                 TCHAR   szWindowTitle[MAX_PATH] = {0};
00138
00139                 // Get the data associated with this window
00140                 pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00141                 // Is there data associated with this window?
00142                 if( pcwd != NULL )
00143                 {
00144                     // Does the data include an icon resource
00145                     if( pcwd->pIR != NULL )
00146                     {
00147                         // Has the resource changed?
00148                         if( pcwd->pIR->bHasChanged )
00149                         {
00150                             // Get the title for the message box
00151                             GetWindowText( hWnd, szWindowTitle, MAX_PATH );
00152                             if( lstrlen( szWindowTitle ) < 1 )
00153                             {
00154                                 lstrcpyn( szWindowTitle, TEXT("UnKnown"),
00155                                           sizeof(szWindowTitle)/sizeof(szWindowTitle[0]) - 1  );
00156                             }
00157                             // User want to save changes?
00158                             switch( MessageBox( hWnd, TEXT("Icon has Changed, Save Changes?"), szWindowTitle, MB_ICONSTOP | MB_YESNOCANCEL ) )
00159                             {
00160                                 case IDYES:
00161                                     SendMessage( hWnd, WM_COMMAND, ID_FILE_SAVE, 0 );
00162                                     // Fall through to IDNO and kill window
00163                                 case IDNO:
00164                                     DefMDIChildProc( hWnd, Msg, wParam, lParam );
00165                                     return 0;
00166                                     break;
00167                                 case IDCANCEL:
00168                                     return 1;
00169                                     break;
00170                             }
00171                         }
00172                     }
00173                 }
00174                 DefMDIChildProc( hWnd, Msg, wParam, lParam );
00175                 return 0;
00176             }
00177             break; // End WM_CLOSE
00178
00179         // We are being created
00180         case WM_CREATE:
00181             {
00182                 PCHILDWINDOWDATA pcwd = NULL;
00183
00184                 // Need new data for this new window
00185                 pcwd = malloc( sizeof( CHILDWINDOWDATA ) );
00186                 SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)pcwd );
00187                 pcwd->pIR = NULL;
00188                 // If a resource was passed in, use it
00189                 if( (PVOID)lParam != NULL )
00190                 {
00191                     pcwd->pIR = (PICONRESOURCE)(((MDICREATESTRUCT *)(((CREATESTRUCT *)lParam)->lpCreateParams))->lParam);
00192                 }
00193
00194                 // If no resource was passed in, do minimal initialization
00195                 if( pcwd->pIR == NULL )
00196                 {
00197                     pcwd->pIR = malloc(sizeof(ICONRESOURCE));
00198                     lstrcpyn( pcwd->pIR->szOriginalICOFileName, TEXT("Untitled"), MAX_PATH - 1 );
00199                     lstrcpyn( pcwd->pIR->szOriginalDLLFileName, TEXT(""), MAX_PATH - 1 );
00200                     pcwd->pIR->nNumImages = 0;
00201                 }
00202                 // Nothing has changed
00203                 pcwd->pIR->bHasChanged = FALSE;
00204                 // Create the list box, etc
00205                 CreateChildren( hWnd );
00206                 return DefMDIChildProc( hWnd, Msg, wParam, lParam );
00207             }
00208             break; // End WM_CREATE
00209
00210         // Won't let window get too small to show our main area
00211         case WM_GETMINMAXINFO:
00212             {
00213                 PMINMAXINFO pmmi = (PMINMAXINFO)lParam;
00214
00215                 pmmi->ptMinTrackSize.x = WINDOW_WIDTH;
00216                 pmmi->ptMinTrackSize.y = WINDOW_HEIGHT;
00217                 return 0;
00218             }
00219             break; // End WM_GETMINMAXINFO
00220
00221         // Yikes! We're being destroyed!
00222         case WM_DESTROY:
00223             {
00224                 PCHILDWINDOWDATA pcwd = NULL;
00225
00226                 // Get the data associated with this window
00227                 pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00228                 // Is there some?
00229                 if( pcwd != NULL )
00230                 {
00231                     // Is there a resource?
00232                     if( pcwd->pIR != NULL )
00233                     {
00234                         UINT i;
00235
00236                         // Free all the bits
00237                         for( i=0; i< pcwd->pIR->nNumImages; i++ )
00238                         {
00239                             if( pcwd->pIR->IconImages[i].pBits != NULL )
00240                             {
00241                                 free( pcwd->pIR->IconImages[i].pBits );
00242                             }
00243                         }
00244                         free( pcwd->pIR );
00245                     }
00246                     free( pcwd );
00247                 }
00248                 SetWindowLongPtr( hWnd, GWLP_USERDATA, 0 );
00249             }
00250             break; // End WM_DESTROY
00251
00252         // Draw our background (white and black squares, etc)
00253         case WM_ERASEBKGND:
00254             EraseBackground( hWnd, (HDC)wParam );
00255             return 1;
00256             break; // End WM_ERASEBKGND
00257
00258         // Ok, time to paint
00259         case WM_PAINT:
00260             {
00261                 PCHILDWINDOWDATA    pcwd  = NULL;
00262                 HDC                 hDC   = NULL;
00263                 PAINTSTRUCT         ps    = {0};
00264                 DWORD               nIndex;
00265                 HICON               hIcon = NULL;
00266
00267                 // Obligatory BeginPaint()
00268                 hDC = BeginPaint( hWnd, &ps );
00269                 // Get the data associated with this window
00270                 pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00271                 // Is there some?
00272                 if( pcwd != NULL )
00273                 {
00274                     // Is there a resource?
00275                     if( pcwd->pIR != NULL )
00276                     {
00277                         // Which image is selected?
00278                         if( (nIndex = (DWORD)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00279                         {
00280                             int         Width, Height;
00281
00282                             // Get an HICON for the currently selected image
00283                             hIcon = MakeIconFromResource( &(pcwd->pIR->IconImages[nIndex]) );
00284                             // How big is the icon?
00285                             Width = pcwd->pIR->IconImages[nIndex].Width;
00286                             Height = pcwd->pIR->IconImages[nIndex].Height;
00287                             // Check to see if the icon is NULL
00288                             // If it is, consider it "unsupported"
00289                             // In the future, maybe we should look into MakeIconFromResource() and
00290                             // see why it is null - it may be for another reason than "unsupported"
00291                             if( hIcon == NULL )
00292                             {
00293                                 SIZE    Size, Position;
00294
00295                                 // Draw some text in the black rect
00296                                 SetTextColor( hDC, RGB(255,255,255) );
00297                                 GetTextExtentPoint32( hDC, TEXT("Unsupported"), 11, &Size );
00298                                 Position.cx = pcwd->BlackRect.left + ((RectWidth(pcwd->BlackRect)-Size.cx)/2);
00299                                 Position.cy = pcwd->BlackRect.top + (RectHeight(pcwd->BlackRect)/2) - Size.cy;
00300                                 TextOut( hDC, Position.cx, Position.cy, TEXT("Unsupported"), 11 );
00301                                 GetTextExtentPoint32( hDC, TEXT("Format"), 6, &Size );
00302                                 Position.cx = pcwd->BlackRect.left + ((RectWidth(pcwd->BlackRect)-Size.cx)/2);
00303                                 Position.cy = pcwd->BlackRect.top + (RectHeight(pcwd->BlackRect)/2) + 1;
00304                                 TextOut( hDC, Position.cx, Position.cy, TEXT("Format"), 6 );
00305
00306                                 // Draw some text in the white rect
00307                                 SetTextColor( hDC, RGB(0,0,0) );
00308                                 GetTextExtentPoint32( hDC, TEXT("Unsupported"), 11, &Size );
00309                                 Position.cx = pcwd->WhiteRect.left + ((RectWidth(pcwd->WhiteRect)-Size.cx)/2);
00310                                 Position.cy = pcwd->WhiteRect.top + (RectHeight(pcwd->WhiteRect)/2) - Size.cy;
00311                                 TextOut( hDC, Position.cx, Position.cy, TEXT("Unsupported"), 11 );
00312                                 GetTextExtentPoint32( hDC, TEXT("Format"), 6, &Size );
00313                                 Position.cx = pcwd->WhiteRect.left + ((RectWidth(pcwd->WhiteRect)-Size.cx)/2);
00314                                 Position.cy = pcwd->WhiteRect.top + (RectHeight(pcwd->WhiteRect)/2) + 1;
00315                                 TextOut( hDC, Position.cx, Position.cy, TEXT("Format"), 6 );
00316                             }
00317                             else
00318                             {
00319                                 // Draw it on the black background
00320                                 DrawIconEx( hDC, pcwd->BlackRect.left + ((RectWidth(pcwd->BlackRect)-Width)/2),
00321                                                 pcwd->BlackRect.top + ((RectHeight(pcwd->BlackRect)-Height)/2),
00322                                                 hIcon, Width, Height, 0, NULL, DI_NORMAL );
00323                                 // Draw it on the white background
00324                                 DrawIconEx( hDC, pcwd->WhiteRect.left + ((RectWidth(pcwd->WhiteRect)-Width)/2),
00325                                                 pcwd->WhiteRect.top + ((RectHeight(pcwd->WhiteRect)-Height)/2),
00326                                                 hIcon, Width, Height, 0, NULL, DI_NORMAL );
00327                             }
00328                             // Draw just the XOR mask
00329                             DrawXORMask( hDC, pcwd->XORRect, &(pcwd->pIR->IconImages[nIndex]) );
00330                             // Draw just the AND mask
00331                             DrawANDMask( hDC, pcwd->ANDRect, &(pcwd->pIR->IconImages[nIndex]) );
00332                             // Kill the icon, we're one with it
00333                             if( hIcon != NULL )
00334                                 DestroyIcon( hIcon );
00335                         }
00336                     }
00337                 }
00338                 // Obligtory EndPaint()
00339                 EndPaint( hWnd, &ps );
00340             }
00341             break; // End WM_PAINT
00342
00343         // WM_COMMAND - menu options, etc
00344         case WM_COMMAND:
00345             // which one is it?
00346             switch( LOWORD(wParam) )
00347             {
00348                 // Edit->Export BMP - write icon image as BMP file
00349                 case ID_EDIT_EXPORTBMP:
00350                     {
00351                     PCHILDWINDOWDATA pcwd                 = NULL;
00352                     DWORD            nIndex;
00353                     TCHAR            szFileName[MAX_PATH] = {0};
00354
00355                     // Get the data associated this window
00356                     pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00357                     // If we have some data, including an icon resource
00358                     if( (pcwd != NULL ) && (pcwd->pIR != NULL) && (pcwd->hWndFormatListBox!= NULL) )
00359                     {
00360                         // Which image is currently selected?
00361                         if( (nIndex = (DWORD)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00362                         {
00363                             // Get the name of the file from which to import the image
00364                             if( GetSaveIconFileName( szFileName, IDS_BMPFILTERSTRING, TEXT("Export to BMP File") ) )
00365                             {
00366                                 HCURSOR hOldCursor;
00367
00368                                 // This might take a while :(
00369                                 hOldCursor = SetCursor( LoadCursor(NULL,IDC_WAIT) );
00370                                 IconImageToBMPFile( szFileName, &(pcwd->pIR->IconImages[nIndex]) );
00371                                 SetCursor( hOldCursor );
00372                             }
00373                         }
00374                     }
00375                     }
00376                     break; // End ID_EDIT_EXPORTBMP
00377
00378                 // Edit->Import BMP and Edit->Stretch-Import BMP - convert BMP file to icon
00379                 case ID_EDIT_IMPORTBMP:  /* fall-through */
00380                 case ID_EDIT_STRETCHIMPORTBMP:
00381                     {
00382                         PCHILDWINDOWDATA    pcwd                 = NULL;
00383                         DWORD               nIndex;
00384                         TCHAR               szFileName[MAX_PATH] = {0};
00385
00386                         // Get the data associated this window
00387                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00388                         // If we have some data, including an icon resource
00389                         if( (pcwd != NULL ) && (pcwd->pIR != NULL) && (pcwd->hWndFormatListBox!= NULL) )
00390                         {
00391                             // Which image is currently selected?
00392                             if( (nIndex = (DWORD)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00393                             {
00394                                 // Get the name of the file from which to import the image
00395                                 if( GetOpenIconFileName( szFileName, IDS_BMPFILTERSTRING, TEXT("Import from BMP File") ) )
00396                                 {
00397                                     HCURSOR hOldCursor;
00398
00399                                     // This might take a while :(
00400                                     hOldCursor = SetCursor( LoadCursor(NULL,IDC_WAIT) );
00401                                     // Import the BMP image data
00402                                     if( IconImageFromBMPFile( szFileName, &(pcwd->pIR->IconImages[nIndex]), (LOWORD(wParam)==ID_EDIT_STRETCHIMPORTBMP)?TRUE:FALSE ) )
00403                                     {
00404                                         // which, of course, changes things
00405                                         pcwd->pIR->bHasChanged = TRUE;
00406                                         // Force a repaint
00407                                         InvalidateRect( hWnd, NULL, TRUE );
00408                                     }
00409                                     SetCursor( hOldCursor );
00410                                 }
00411                             }
00412                         }
00413                     }
00414                     break; // End ID_EDIT_IMPORTBMP/ID_EDIT_STRETCHIMPORTBMP
00415
00416                 // User wants to add an image format
00417                 case ID_EDIT_ADDFORMAT:
00418                     {
00419                         PICONIMAGE  pii           = NULL;
00420                         TCHAR       szBuffer[256] = {0};
00421
00422                         // Launch the dialog to ask which size and color depth
00423                         if( DialogBoxParam( hInst, MAKEINTRESOURCE(IDD_ADDFORMATDLG), hWndMain, (DLGPROC)AddFormatDlgProc, (LPARAM)(&pii) ) )
00424                         {
00425                             PCHILDWINDOWDATA    pcwd    = NULL;
00426                             PICONRESOURCE       pNewIR  = NULL;
00427                             DWORD               nIndex, i;
00428
00429                             // Get the data associated this window
00430                             pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00431                             // If we have some data, including an icon resource
00432                             if( (pcwd != NULL ) && (pcwd->pIR != NULL) && (pcwd->hWndFormatListBox!= NULL) )
00433                             {
00434                                 // Need to see if the new format already exists in the resource
00435                                 // We don't want dupes, so check each image for dupe
00436                                 for(i=0;i<pcwd->pIR->nNumImages;i++)
00437                                 {
00438                                     // Is it the same as the new one?
00439                                     if( (pcwd->pIR->IconImages[i].Width==pii->Width) &&
00440                                         (pcwd->pIR->IconImages[i].Height==pii->Height) &&
00441                                         (pcwd->pIR->IconImages[i].Colors==pii->Colors) )
00442                                     {
00443                                         // Yikes! It is - bail and select the old one
00444                                         MessageBox( hWnd, TEXT("That format already exists - format not added"), TEXT("Error"), MB_OK );
00445                                         SendMessage( pcwd->hWndFormatListBox,   CB_SETCURSEL, (WPARAM)i, (LPARAM)0 );
00446                                         break;
00447                                     }
00448                                 }
00449                                 // Need bigger block of memory to hold an extra image format
00450                                 pNewIR = malloc( sizeof( ICONRESOURCE ) + ( ( pcwd->pIR->nNumImages + 1) * sizeof(ICONIMAGE) ) );
00451                                 // Of course this changes things
00452                                 pNewIR->bHasChanged = TRUE;
00453                                 // Copy old to new
00454                                 lstrcpyn( pNewIR->szOriginalICOFileName, pcwd->pIR->szOriginalICOFileName,
00455                                           MAX_PATH - 1);
00456                                 lstrcpyn( pNewIR->szOriginalDLLFileName, pcwd->pIR->szOriginalDLLFileName,
00457                                           MAX_PATH - 1);
00458                                 pNewIR->nNumImages = pcwd->pIR->nNumImages + 1;
00459                                 for(i=0;i<pcwd->pIR->nNumImages;i++)
00460                                 {
00461                                     memcpy( &(pNewIR->IconImages[i]), &(pcwd->pIR->IconImages[i]), sizeof( ICONIMAGE ) );
00462                                 }
00463                                 // Add in the new one
00464                                 memcpy( &(pNewIR->IconImages[i]), pii, sizeof( ICONIMAGE ) );
00465                                 // Add this new one to the list box
00466                                 wsprintf( szBuffer, TEXT("%dx%d, %d Bit Color"), pii->Width, pii->Height, pii->Colors );
00467                                 nIndex = (ULONG)SendMessage( pcwd->hWndFormatListBox, CB_ADDSTRING, 0, (LPARAM)szBuffer );
00468                                 // Select the new one
00469                                 SendMessage( pcwd->hWndFormatListBox,   CB_SETCURSEL, (WPARAM)i, (LPARAM)0 );
00470                                 // clean up
00471                                 free( pii );
00472                                 free( pcwd->pIR );
00473                                 pcwd->pIR = pNewIR;
00474                                 // Create a nice new blank image for this format
00475                                 CreateBlankNewFormatIcon( &(pcwd->pIR->IconImages[i]) );
00476                                 // force a repaint
00477                                 InvalidateRect( hWnd, NULL, TRUE );
00478                             }
00479                         }
00480                     }
00481                     break; // End WM_COMMAND -> ID_EDIT_ADDFORMAT
00482
00483                 // User wants to remove an image format
00484                 case ID_EDIT_REMOVEFORMAT:
00485                     {
00486                         PCHILDWINDOWDATA    pcwd        = NULL;
00487                         DWORD               nIndex, i;
00488                         PICONRESOURCE       pNewIR      = NULL;
00489
00490                         // Get the data associated this window
00491                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00492                         // If we have some data, including an icon resource
00493                         if( (pcwd != NULL ) && (pcwd->pIR != NULL) && (pcwd->hWndFormatListBox!= NULL) )
00494                         {
00495                             // Which image is currently selected?
00496                             if( (nIndex = (ULONG)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00497                             {
00498                                 // Remove the entry from the list box
00499                                 SendMessage( pcwd->hWndFormatListBox, CB_DELETESTRING, nIndex, 0 );
00500                                 // Need less memory now
00501                                 pNewIR = malloc( sizeof( ICONRESOURCE ) + ( ( pcwd->pIR->nNumImages - 1) * sizeof(ICONIMAGE) ) );
00502                                 // Of course this changes things
00503                                 pNewIR->bHasChanged = TRUE;
00504                                 // Copy old to new
00505                                 lstrcpyn( pNewIR->szOriginalICOFileName, pcwd->pIR->szOriginalICOFileName,
00506                                           MAX_PATH - 1);
00507                                 lstrcpyn( pNewIR->szOriginalDLLFileName, pcwd->pIR->szOriginalDLLFileName,
00508                                           MAX_PATH - 1);
00509                                 pNewIR->nNumImages = pcwd->pIR->nNumImages - 1;
00510                                 // Copy the rest of the images from old to new
00511                                 for(i=0;i<nIndex;i++)
00512                                 {
00513                                     memcpy( &(pNewIR->IconImages[i]), &(pcwd->pIR->IconImages[i]), sizeof( ICONIMAGE ) );
00514                                 }
00515                                 for(;i<pcwd->pIR->nNumImages-1;i++)
00516                                 {
00517                                     memcpy( &(pNewIR->IconImages[i]), &(pcwd->pIR->IconImages[i+1]), sizeof( ICONIMAGE ) );
00518                                 }
00519                                 // Clean up
00520                                 free( pcwd->pIR );
00521                                 pcwd->pIR = pNewIR;
00522                                 // Select a different image
00523                                 if( (int) --nIndex < 0 )
00524                                 {
00525                                     nIndex = 0;
00526                                 }
00527                                 SendMessage( pcwd->hWndFormatListBox, CB_SETCURSEL, (WPARAM)nIndex, 0 );
00528                                 // Force a repaint
00529                                 InvalidateRect( hWnd, NULL, TRUE );
00530                             }
00531                         }
00532                     }
00533                     break; // End WM_COMMAND -> ID_EDIT_REMOVEFORMAT
00534
00535                 // User wants to paste CF_DIB from clipboard into current image
00536                 case ID_EDIT_STRETCHPASTE: /* fall-through */
00537                 case ID_EDIT_PASTE:
00538                     {
00539                         PCHILDWINDOWDATA    pcwd    = NULL;
00540                         DWORD               nIndex;
00541
00542                         // Get the data associated this window
00543                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00544                         // If we have some data, including an icon resource
00545                         if( (pcwd != NULL ) && (pcwd->pIR != NULL) && (pcwd->hWndFormatListBox!= NULL) )
00546                         {
00547                             // Which image is currently selected?
00548                             if( (nIndex = (ULONG)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00549                             {
00550                                 HCURSOR hOldCursor;
00551
00552                                 // This might take a while :(
00553                                 hOldCursor = SetCursor( LoadCursor(NULL,IDC_WAIT) );
00554
00555                                 // Paste over it from the clipboard
00556                                 if( IconImageFromClipBoard( &(pcwd->pIR->IconImages[nIndex]),
00557                                                             LOWORD(wParam)!=ID_EDIT_PASTE ) )
00558                                 {
00559                                     // which, of course, changes things
00560                                     pcwd->pIR->bHasChanged = TRUE;
00561                                 }
00562                                 // Force a repaint
00563                                 InvalidateRect( hWnd, NULL, TRUE );
00564                                 SetCursor( hOldCursor );
00565                             }
00566                         }
00567                     }
00568                     break; // End WM_COMMAND -> ID_EDIT_STRETCHPASTE/ID_EDIT_PASTE
00569
00570                 // Put current image on the clipboard in CF_DIB format
00571                 case ID_EDIT_COPY:
00572                     {
00573                         PCHILDWINDOWDATA    pcwd  = NULL;
00574                         DWORD               nIndex;
00575
00576                         // Get the data associated this window
00577                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00578                         // If we have some data, including an icon resource
00579                         if( (pcwd != NULL ) && (pcwd->pIR != NULL) && (pcwd->hWndFormatListBox!= NULL) )
00580                         {
00581                             // Which image is currently selected?
00582                             if( (nIndex = (ULONG)SendMessage( pcwd->hWndFormatListBox, CB_GETCURSEL, 0, 0 )) != CB_ERR )
00583                             {
00584                                 // Send this image to the clipboard
00585                                 IconImageToClipBoard( &(pcwd->pIR->IconImages[nIndex]) );
00586                             }
00587                         }
00588                     }
00589                     break; // End WM_COMMAND -> ID_EDIT_COPY
00590
00591                 // The filename has changed, update the window title
00592                 case ID_UPDATETITLE:
00593                     {
00594                         TCHAR            szFileTitle[MAX_PATH] = {0};
00595                         PCHILDWINDOWDATA pcwd                  = NULL;
00596
00597                         // Get the data associated this window
00598                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00599                         // If we have some data
00600                         if( pcwd != NULL )
00601                         {
00602                             // including an icon resource
00603                             if( pcwd->pIR != NULL )
00604                             {
00605                                 // The calculate and set the new title
00606                                 if( GetFileTitle( pcwd->pIR->szOriginalICOFileName, szFileTitle, MAX_PATH ) == 0 )
00607                                 {
00608                                     SetWindowText( hWnd, szFileTitle );
00609                                 }
00610                             }
00611                         }
00612                     }
00613                     break; // End WM_COMMAND -> ID_UPDATETITLE
00614
00615                 // How many image formats in the icon resource? (return that number)
00616                 case ID_GETNUMFORMATS:
00617                     {
00618                         PCHILDWINDOWDATA pcwd = NULL;
00619                         UINT             nNum = 0;
00620
00621                         // Get the data associated this window
00622                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00623                         // If we have some data
00624                         if( pcwd != NULL )
00625                         {
00626                             // If we have a listbox, get its count, else 0
00627                             if( pcwd->hWndFormatListBox != NULL )
00628                             {
00629                                 nNum = (UINT)SendMessage( pcwd->hWndFormatListBox, CB_GETCOUNT, 0, 0 );
00630                             }
00631                             else
00632                             {
00633                                 nNum = 0;
00634                             }
00635
00636                             // If an error occurred, default to 0
00637                             if( nNum == (UINT)CB_ERR )
00638                             {
00639                                 nNum = 0;
00640                             }
00641                         }
00642                         // Send it back
00643                         return nNum;
00644                     }
00645                     break; // End WM_COMMAND -> ID_GETNUMFORMATS
00646
00647                 // Has this icon resource changed? return TRUE=yes, FALSE=no
00648                 case ID_HASFILECHANGED:
00649                     {
00650                         PCHILDWINDOWDATA pcwd = NULL;
00651                         UINT             nRet = 0;
00652
00653                         // Get the data associated this window
00654                         pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA );
00655                         // If we have some data
00656                         if( pcwd != NULL )
00657                         {
00658                             // And it includes an icon resource
00659                             if( pcwd->pIR != NULL )
00660                             {
00661                                 // then check whether it has changed
00662                                 return pcwd->pIR->bHasChanged == TRUE;
00663                             }
00664                         }
00665                         // Otherwise, return FALSE
00666                         return nRet;
00667                     }
00668                     break; // End WM_COMMAND -> ID_HASFILECHANGED
00669
00670                 // Handle selection changes, etc from listbox
00671                 case ID_FORMAT_BOX:
00672                     switch( HIWORD(wParam) )
00673                     {
00674                         // If a selection is made, or changes, repaint
00675                         case CBN_SELCHANGE: /* fall-through */
00676                         case CBN_SELENDOK:
00677                             InvalidateRect( hWnd, NULL, TRUE );
00678                             break;
00679                     }
00680                     break; // End WM_COMMAND -> ID_FORMAT_BOX
00681
00682                 // User wants to save the ICO file
00683                 case ID_FILE_SAVEAS: /* fall-through */
00684                 case ID_FILE_SAVE:
00685                 {
00686                     TCHAR          szFileName[MAX_PATH] = {0};
00687                     PCHILDWINDOWDATA pcwd                 = NULL;
00688
00689                     // Get the data associated this window
00690                     if( ( pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA ) ) != NULL )
00691                     {
00692                         // See if it includes an icon resource
00693                         if( pcwd->pIR != NULL )
00694                         {
00695                             HCURSOR hOldCursor = NULL;
00696
00697                             // This might take a while :(
00698                             hOldCursor = SetCursor( LoadCursor(NULL,IDC_WAIT) );
00699
00700                             // If we have an original filename, and user did *NOT* 'Save As'
00701                             if( ( lstrlen(pcwd->pIR->szOriginalICOFileName) > 0 ) && (LOWORD(wParam)!=ID_FILE_SAVEAS) )
00702                             {
00703                                 // The just write it out
00704                                 WriteIconToICOFile( pcwd->pIR, pcwd->pIR->szOriginalICOFileName );
00705                                 // which, of course, brings it up to date
00706                                 pcwd->pIR->bHasChanged = FALSE;
00707                             }
00708                             else
00709                             {
00710                                 // Either we have no name, or user hit 'Save As'
00711                                 if( GetSaveIconFileName( szFileName, IDS_FILTERSTRING, LOWORD(wParam)==ID_FILE_SAVE?TEXT("Save Icon File"):TEXT("Save Icon File As") ) )
00712                                 {
00713                                     // So, write it out
00714                                     WriteIconToICOFile( pcwd->pIR, szFileName );
00715                                     // Update the name associated with the resource
00716                                     lstrcpyn( pcwd->pIR->szOriginalICOFileName, szFileName, MAX_PATH - 1 );
00717                                     // Inform window to update title
00718                                     SendMessage( hWnd, WM_COMMAND, ID_UPDATETITLE, 0 );
00719                                     // and, of course, it is now up to date
00720                                     pcwd->pIR->bHasChanged = FALSE;
00721                                 }
00722                             }
00723                             SetCursor( hOldCursor );
00724                         }
00725                         else
00726                         {
00727                             MessageBox( hWnd, TEXT("Error Getting Icon Info - File Not Saved"), TEXT("Error"), MB_OK );
00728                         }
00729                     }
00730                 }
00731                 break; // End WM_COMMAND -> ID_FILE_SAVE/ID_FILE_SAVEAS
00732             }
00733             break; // End WM_COMMAND
00734     }
00735     return DefMDIChildProc( hWnd, Msg, wParam, lParam );
00736 }
00737 /* End IconChildWndProc() **************************************************/
00738
00739
00740
00741
00742 /****************************************************************************
00743 *
00744 *     FUNCTION: Draw3DRect
00745 *
00746 *     PURPOSE:  draws a rectangle in 3d colors
00747 *
00748 *     PARAMS:   HDC hDC      - The DC on which to draw
00749 *               RECT Rect    - The rectangle itself
00750 *               BOOL bSunken - TRUE  = rect should look sunken
00751 *                              FALSE = rect should look raised
00752 *
00753 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
00754 *
00755 * History:
00756 *                July '95 - Created
00757 *
00758 \****************************************************************************/
00759 BOOL Draw3DRect(
00760     HDC hDC,
00761     RECT Rect,
00762     BOOL bSunken )
00763 {
00764     HBRUSH  hBrush  = NULL;
00765     HPEN    hPen    = NULL;
00766     HPEN    hOldPen = NULL;
00767
00768     // Get the color for the main foreground
00769     hBrush = CreateSolidBrush( GetSysColor(COLOR_3DFACE) );
00770     // paint it
00771     FillRect( hDC, &Rect, hBrush );
00772     DeleteObject( hBrush );
00773     // Get the pen for the top and left sides
00774     if( bSunken )
00775     {
00776         hPen = CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW) );
00777     }
00778     else
00779     {
00780         hPen = CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT) );
00781     }
00782     hOldPen = SelectObject( hDC, hPen);
00783     // Draw the top and left sides
00784     MoveToEx( hDC, Rect.right, Rect.top, NULL );
00785     LineTo( hDC, Rect.left, Rect.top );
00786     LineTo( hDC, Rect.left, Rect.bottom );
00787     SelectObject( hDC, hOldPen);
00788     DeleteObject( hPen );
00789     // Get the pen for the bottom and right sides
00790     if( bSunken )
00791     {
00792         hPen = CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT) );
00793     }
00794     else
00795     {
00796         hPen = CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW) );
00797     }
00798     hOldPen = SelectObject( hDC, hPen);
00799     // Draw the bottom and right sides
00800     LineTo( hDC, Rect.right, Rect.bottom );
00801     LineTo( hDC, Rect.right, Rect.top );
00802     SelectObject( hDC, hOldPen);
00803     DeleteObject( hPen );
00804     return TRUE;
00805 }
00806 /* End Draw3DRect() *******************************************************/
00807
00808
00809
00810
00811 /****************************************************************************
00812 *
00813 *     FUNCTION: EraseBackground
00814 *
00815 *     PURPOSE:  Draws the background for the MDI child
00816 *
00817 *     PARAMS:   HWND hWnd - The MDI window of interest
00818 *               HDC  hDC  - The DC on which to draw
00819 *
00820 *     RETURNS:  void
00821 *
00822 * History:
00823 *                July '95 - Created
00824 *
00825 \****************************************************************************/
00826 void EraseBackground(
00827     HWND hWnd,
00828     HDC hDC )
00829 {
00830     RECT                Rect     = {0};
00831     PCHILDWINDOWDATA  pcwd     = NULL;
00832     HBRUSH              hBrush   = NULL;
00833     SIZE                TextSize = {0};
00834
00835     // Just how big is this window?
00836     GetClientRect( hWnd, &Rect );
00837     // Paint the background
00838     Draw3DRect( hDC, Rect, FALSE );
00839
00840     // If there is no icon resource yet, bail out
00841     if( ( pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA ) ) == NULL )
00842     {
00843         return;
00844     }
00845     // Draw 3d rectangles around areas of interest
00846     Draw3DRect( hDC, pcwd->WhiteRect, TRUE );
00847     Draw3DRect( hDC, pcwd->WhiteTextRect, TRUE );
00848     Draw3DRect( hDC, pcwd->BlackRect, TRUE );
00849     Draw3DRect( hDC, pcwd->BlackTextRect, TRUE );
00850     Draw3DRect( hDC, pcwd->XORRect, TRUE );
00851     Draw3DRect( hDC, pcwd->XORTextRect, TRUE );
00852     Draw3DRect( hDC, pcwd->ANDRect, TRUE );
00853     Draw3DRect( hDC, pcwd->ANDTextRect, TRUE );
00854     // Fill in the white area
00855     hBrush = GetStockObject( WHITE_BRUSH );
00856     SelectObject( hDC, hBrush );
00857     Rectangle( hDC, pcwd->WhiteRect.left, pcwd->WhiteRect.top, pcwd->WhiteRect.right, pcwd->WhiteRect.bottom );
00858     // Fill in the black area
00859     hBrush = GetStockObject( BLACK_BRUSH );
00860     SelectObject( hDC, hBrush );
00861     Rectangle( hDC, pcwd->BlackRect.left, pcwd->BlackRect.top, pcwd->BlackRect.right, pcwd->BlackRect.bottom );
00862
00863     // Set texts for the various sections
00864     SetBkMode( hDC, TRANSPARENT );
00865     GetTextExtentPoint32( hDC, TEXT("Icon On Black"), 13, &TextSize );
00866     TextOut( hDC, pcwd->BlackTextRect.left + ((RectWidth(pcwd->BlackTextRect)-TextSize.cx)/2),
00867              pcwd->BlackTextRect.top + ((RectHeight(pcwd->BlackTextRect)-TextSize.cy)/2),
00868              TEXT("Icon On Black"), 13 );
00869     GetTextExtentPoint32( hDC, TEXT("Icon On White"), 13, &TextSize );
00870     TextOut( hDC, pcwd->WhiteTextRect.left + ((RectWidth(pcwd->WhiteTextRect)-TextSize.cx)/2),
00871              pcwd->WhiteTextRect.top + ((RectHeight(pcwd->WhiteTextRect)-TextSize.cy)/2),
00872              TEXT("Icon On White"), 13 );
00873     GetTextExtentPoint32( hDC, TEXT("XOR Mask"), 8, &TextSize );
00874     TextOut( hDC, pcwd->XORTextRect.left + ((RectWidth(pcwd->XORTextRect)-TextSize.cx)/2),
00875              pcwd->XORTextRect.top + ((RectHeight(pcwd->XORTextRect)-TextSize.cy)/2),
00876              TEXT("XOR Mask"), 8 );
00877     GetTextExtentPoint32( hDC, TEXT("AND Mask"), 8, &TextSize );
00878     TextOut( hDC, pcwd->ANDTextRect.left + ((RectWidth(pcwd->ANDTextRect)-TextSize.cx)/2),
00879              pcwd->ANDTextRect.top + ((RectHeight(pcwd->ANDTextRect)-TextSize.cy)/2),
00880              TEXT("AND Mask"), 8 );
00881 }
00882 /* End EraseBackground() ***************************************************/
00883
00884
00885
00886
00887 /****************************************************************************
00888 *
00889 *     FUNCTION: CreateChildren
00890 *
00891 *     PURPOSE:  Create the listbox, fills it with entries
00892 *
00893 *     PARAMS:   HWND hWnd - The MDI window of interest
00894 *
00895 *     RETURNS:  BOOL - TRUE for success, FALSE for failure
00896 *
00897 * History:
00898 *                July '95 - Created
00899 *
00900 \****************************************************************************/
00901 BOOL CreateChildren(
00902     HWND hWnd )
00903 {
00904     RECT             ClientRect = {0};
00905     RECT             TempRect   = {0};
00906     PCHILDWINDOWDATA pcwd       = NULL;
00907     HDC              hDC        = NULL;
00908     SIZE             size       = {0};
00909     BOOL             bSuccess   = TRUE;
00910
00911     // Get the data associated with this window
00912     if( (pcwd = (PCHILDWINDOWDATA)GetWindowLongPtr( hWnd, GWLP_USERDATA )) == NULL )
00913     {
00914         bSuccess = FALSE;
00915         goto exit_func;
00916     }
00917
00918     // Just how big is this window?
00919     GetClientRect( hWnd, &ClientRect );
00920     // Calculate listbox size and position
00921     SetRect( &(pcwd->BoxRect), 10, ClientRect.bottom-30, (MAX_ICON_WIDTH*2)+14, ClientRect.bottom+50 );
00922     // Create the listbox
00923     if((pcwd->hWndFormatListBox=CreateChildListBox( hWnd, ID_FORMAT_BOX, &(pcwd->BoxRect) )) == NULL )
00924     {
00925         bSuccess = FALSE;
00926         goto exit_func;
00927     }
00928
00929     // If we have an icon resource
00930     if( pcwd->pIR != NULL )
00931     {
00932         UINT  i, nIndex;
00933         TCHAR szBuffer[256] = {0};
00934
00935         // For each image in the resoure
00936         for(i=0;i<pcwd->pIR->nNumImages;i++)
00937         {
00938             // Add the type of the image to the listbox
00939             wsprintf( szBuffer, TEXT("%dx%d, %d Bit Color"), pcwd->pIR->IconImages[i].Width,
00940                         pcwd->pIR->IconImages[i].Height, pcwd->pIR->IconImages[i].Colors );
00941             nIndex = (ULONG)SendMessage( pcwd->hWndFormatListBox, CB_ADDSTRING, 0, (LPARAM)szBuffer );
00942         }
00943         // Select the first entry
00944         SendMessage( pcwd->hWndFormatListBox,   CB_SETCURSEL, (WPARAM)0, (LPARAM)0 );
00945     }
00946     // Adjust the box size based on the listbox's real size
00947     GetClientRect( pcwd->hWndFormatListBox, &TempRect );
00948     pcwd->BoxRect.bottom = pcwd->BoxRect.top + TempRect.bottom;
00949
00950     // How big is text these days?
00951     hDC = GetDC( hWnd );
00952     GetTextExtentPoint32( hDC, TEXT("Icon on Black"), 13, &size );
00953     ReleaseDC( hWnd, hDC );
00954
00955     // Set the rectangles for the various squares to be drawn later
00956 #define DIVIDER 5
00957     SetRect( &(pcwd->DrawingRect), 10, 10, (MAX_ICON_WIDTH*2)+14, 20 + (MAX_ICON_HEIGHT*2) + (TempRect.bottom*2) );
00958     SetRect( &(pcwd->BlackRect), pcwd->DrawingRect.left, pcwd->DrawingRect.top, pcwd->DrawingRect.left + MAX_ICON_WIDTH + 1, pcwd->DrawingRect.top + MAX_ICON_HEIGHT + 1 );
00959     SetRect( &(pcwd->BlackTextRect), pcwd->BlackRect.left, pcwd->BlackRect.bottom+1, pcwd->BlackRect.right, pcwd->BlackRect.bottom + TempRect.bottom + 1 );
00960     SetRect( &(pcwd->WhiteRect), pcwd->BlackRect.right+1, pcwd->BlackRect.top, pcwd->DrawingRect.right, pcwd->BlackRect.bottom );
00961     SetRect( &(pcwd->WhiteTextRect), pcwd->WhiteRect.left, pcwd->WhiteRect.bottom+1, pcwd->WhiteRect.right, pcwd->WhiteRect.bottom + TempRect.bottom + 1 );
00962     SetRect( &(pcwd->XORRect),  pcwd->BlackTextRect.left, pcwd->BlackTextRect.bottom + 1 + DIVIDER, pcwd->BlackRect.right, pcwd->BlackTextRect.bottom + 2 + DIVIDER + MAX_ICON_HEIGHT );
00963     SetRect( &(pcwd->XORTextRect),  pcwd->XORRect.left, pcwd->XORRect.bottom + 1, pcwd->XORRect.right, pcwd->DrawingRect.bottom );
00964     SetRect( &(pcwd->ANDRect),  pcwd->WhiteTextRect.left, pcwd->WhiteTextRect.bottom + 1 + DIVIDER, pcwd->WhiteRect.right, pcwd->WhiteTextRect.bottom + 2 + DIVIDER + MAX_ICON_HEIGHT );
00965     SetRect( &(pcwd->ANDTextRect),  pcwd->ANDRect.left, pcwd->ANDRect.bottom + 1, pcwd->ANDRect.right, pcwd->DrawingRect.bottom );
00966 #undef DIVIDER
00967
00968 exit_func:
00969     return bSuccess;
00970 }
00971 /* End CreateChildren() ****************************************************/
00972
00973
00974
00975
00976 /****************************************************************************
00977 *
00978 *     FUNCTION: CreateChildListBox
00979 *
00980 *     PURPOSE:  Creates a listbox and shows it
00981 *
00982 *     PARAMS:   HWND   hWndParent - The MDI window to be a parent
00983 *               UINT   ID         - the ID of the new listbox
00984 *               PRECT  pRect      - the RECT for the listbox
00985 *
00986 *     RETURNS:  HWND - handle to listbox window, NULL for failure
00987 *
00988 * History:
00989 *                July '95 - Created
00990 *
00991 \****************************************************************************/
00992 HWND CreateChildListBox(
00993     HWND hWndParent,
00994     UINT ID,
00995     PRECT pRect )
00996 {
00997     HWND hWnd;
00998
00999     hWnd = CreateWindow( TEXT("COMBOBOX"), TEXT(""), CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL | WS_CHILD | WS_VSCROLL,
01000                         pRect->left, pRect->top,
01001                         pRect->right - pRect->left + 1, pRect->bottom - pRect->top + 1,
01002                         hWndParent, (HMENU)(LONG_PTR)ID, hInst, 0 );
01003     if( hWnd != NULL )
01004     {
01005         ShowWindow( hWnd, SW_SHOW );
01006     }
01007     return hWnd;
01008 }
01009 /* End CreateChildListBox() ************************************************/
01010
01011
01012
01013
01014 /****************************************************************************
01015 *
01016 *     FUNCTION: AddFormatDlgProc
01017 *
01018 *     PURPOSE:  Dialog Procedure for "Add Format" dialog
01019 *
01020 *     PARAMS:   HWND hWnd     - This dialog's window handle
01021 *               UINT Msg      - Which Message?
01022 *               WPARAM wParam - message parameter
01023 *               LPARAM lParam - message parameter
01024 *
01025 *     RETURNS:  BOOL - TRUE for OK, FALSE for Cancel
01026 *
01027 * History:
01028 *                July '95 - Created
01029 *
01030 \****************************************************************************/
01031 BOOL CALLBACK AddFormatDlgProc(
01032     HWND hWnd,
01033     UINT Msg,
01034     WPARAM wParam,
01035     LPARAM lParam )
01036 {
01037     // Support all DIB color formats known at this time
01038     #define MAX_COLOR_FORMAT    5
01039     TCHAR ColorFormats[MAX_COLOR_FORMAT+1][20] = { TEXT("Monochrome (1bpp)"), TEXT("16 Color (4bpp)"), TEXT("256 Color (8bpp)"),
01040                                     TEXT("16 Bit Color"), TEXT("24 Bit Color"), TEXT("32 Bit Color") };
01041     UINT    Bits[MAX_COLOR_FORMAT+1] = { 1, 4, 8, 16, 24, 32 };
01042     static  bSquareOnly = TRUE;
01043     static  LPARAM lInitParam;
01044
01045
01046     switch( Msg )
01047     {
01048         // Dialog is being initialized
01049         case WM_INITDIALOG:
01050             {
01051                 TCHAR szBuffer[100] = {0};
01052
01053                 // We are passed a pointer to a LPICONIMAGE in lParam, save it
01054                 lInitParam = lParam;
01055                 // Set the range and position of the sliders
01056                 SendDlgItemMessage( hWnd, ID_WIDTHSLIDER, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(MIN_ICON_WIDTH,MAX_ICON_WIDTH) );
01057                 SendDlgItemMessage( hWnd, ID_WIDTHSLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)MIN_ICON_WIDTH );
01058                 wsprintf( szBuffer, TEXT("%d Width"), MIN_ICON_WIDTH );
01059                 SetDlgItemText( hWnd, ID_WIDTHTEXT, szBuffer );
01060                 SendDlgItemMessage( hWnd, ID_HEIGHTSLIDER, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(MIN_ICON_HEIGHT,MAX_ICON_HEIGHT) );
01061                 SendDlgItemMessage( hWnd, ID_HEIGHTSLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)MIN_ICON_HEIGHT );
01062                 wsprintf( szBuffer, TEXT("%d Height"), MIN_ICON_HEIGHT );
01063                 SetDlgItemText( hWnd, ID_HEIGHTTEXT, szBuffer );
01064                 SendDlgItemMessage( hWnd, ID_COLORSLIDER, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0,MAX_COLOR_FORMAT) );
01065                 SendDlgItemMessage( hWnd, ID_COLORSLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)2);
01066                 SetDlgItemText( hWnd, ID_COLORTEXT, ColorFormats[2] );
01067                 CheckDlgButton( hWnd, IDC_SQUAREONLY, bSquareOnly );
01068             }
01069             break; // End WM_INITDIALOG
01070
01071         // Scroll message from the sliders
01072         case WM_HSCROLL:
01073             {
01074                 int nPos;
01075                 TCHAR szBuffer[100] = {0};
01076
01077                 // Get the current position
01078                 if( ( LOWORD(wParam) == TB_THUMBPOSITION ) || ( LOWORD(wParam) == TB_THUMBTRACK ) )
01079                     nPos = HIWORD( wParam );
01080                 else
01081                     nPos = (int)SendMessage( (HWND)lParam, TBM_GETPOS, 0, 0 );
01082                 // Was it the width slider?
01083                 if( (HWND)lParam == GetDlgItem( hWnd, ID_WIDTHSLIDER) )
01084                 {
01085                     // Update the text
01086                     wsprintf( szBuffer, TEXT("%d Width"), nPos );
01087                     SetDlgItemText( hWnd, ID_WIDTHTEXT, szBuffer );
01088                     // If dealing with width=height, adjust height too
01089                     if( bSquareOnly )
01090                     {
01091                         SendDlgItemMessage( hWnd, ID_HEIGHTSLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)nPos );
01092                         wsprintf( szBuffer, TEXT("%d Height"), nPos );
01093                         SetDlgItemText( hWnd, ID_HEIGHTTEXT, szBuffer );
01094                     }
01095                 }
01096                 else
01097                 {
01098                     // Was it the height slider?
01099                     if( (HWND)lParam == GetDlgItem( hWnd, ID_HEIGHTSLIDER) )
01100                     {
01101                         // Update the text
01102                         wsprintf( szBuffer, TEXT("%d Height"), nPos );
01103                         SetDlgItemText( hWnd, ID_HEIGHTTEXT, szBuffer );
01104                         // If dealing with width=height, adjust width too
01105                         if( bSquareOnly )
01106                         {
01107                             SendDlgItemMessage( hWnd, ID_WIDTHSLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)nPos );
01108                             wsprintf( szBuffer, TEXT("%d Width"), nPos );
01109                             SetDlgItemText( hWnd, ID_WIDTHTEXT, szBuffer );
01110                         }
01111                     }
01112                     else
01113                     {
01114                         // Was it the color slider?
01115                         if( (HWND)lParam == GetDlgItem( hWnd, ID_COLORSLIDER) )
01116                         {
01117                             // Update the text
01118                             SetDlgItemText( hWnd, ID_COLORTEXT, ColorFormats[nPos] );
01119                         }
01120                     }
01121                 }
01122             }
01123             break; // End WM_HSCROLL
01124
01125         // Time to say 'goodbye'
01126         case WM_CLOSE:
01127             PostMessage( hWnd, WM_COMMAND, IDCANCEL, 0l );
01128             break; // End WM_CLOSE
01129
01130
01131         // Messages from user items - checkboxes etc
01132         case WM_COMMAND:
01133             switch( LOWORD(wParam) )
01134             {
01135                 // Checkbox for width=height restriction
01136                 case IDC_SQUAREONLY:
01137                     // Is it checked now?
01138                     bSquareOnly = IsDlgButtonChecked( hWnd, IDC_SQUAREONLY );
01139                     // If it is, set height equal to width
01140                     if( bSquareOnly )
01141                     {
01142                         int nPos;
01143                         TCHAR szBuffer[100] = {0};
01144
01145                         nPos = (int)SendDlgItemMessage( hWnd, ID_WIDTHSLIDER, TBM_GETPOS, 0, 0 );
01146                         SendDlgItemMessage( hWnd, ID_HEIGHTSLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)nPos );
01147                         wsprintf( szBuffer, TEXT("%d Height"), nPos );
01148                         SetDlgItemText( hWnd, ID_HEIGHTTEXT, szBuffer );
01149                     }
01150                     break; // End IDC_SQUAREONLY
01151
01152                 // Add Format button has been pressed
01153                 case IDOK:
01154                     {
01155                         PICONIMAGE pii = NULL;
01156
01157                         // Were we passed a valid PICONIMAGE pointer?
01158                         if( ((PICONIMAGE)lInitParam) != NULL )
01159                         {
01160                             // allocate the new ICONIMAGE
01161                             if( (pii = malloc( sizeof( ICONIMAGE ) )) == FALSE )
01162                             {
01163                                 EndDialog( hWnd, FALSE );
01164                             }
01165                             else
01166                             {
01167                                 // initialize it
01168                                 ZeroMemory( pii, sizeof( ICONIMAGE ) );
01169                                 pii->Width = (UINT)SendDlgItemMessage( hWnd, ID_WIDTHSLIDER, TBM_GETPOS, 0, 0 );
01170                                 pii->Height = (UINT)SendDlgItemMessage( hWnd, ID_HEIGHTSLIDER, TBM_GETPOS, 0, 0 );
01171                                 pii->Colors = Bits[SendDlgItemMessage( hWnd, ID_COLORSLIDER, TBM_GETPOS, 0, 0 )];
01172                                 // update the pointer that we were passed
01173                                 *(PICONIMAGE *)lInitParam = pii;
01174                                 // bail
01175                                 EndDialog( hWnd, TRUE );
01176                             }
01177                         }
01178                         else
01179                         {
01180                             // bail
01181                             EndDialog( hWnd, FALSE );
01182                         }
01183                     }
01184                     break; // End IDOK
01185
01186                 // Time to cancel
01187                 case IDCANCEL:
01188                     EndDialog( hWnd, FALSE );
01189                     break; // End IDCANCEL
01190             }
01191             break;
01192
01193         default:
01194             return FALSE;
01195             break;
01196     }
01197
01198     return TRUE;
01199     #undef MAX_COLOR_FORMAT
01200 }
01201 /* End AddFormatDlgProc() ************************************************/
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ASYNC_REQUESTER Member List

This is the complete list of members for ASYNC_REQUESTER, including all inherited members.
_List | ASYNC_REQUESTER | [private]
ASYNC_REQUESTER(UINT nRequesterID, SIMPLE_BROWSER *pBrowser) | ASYNC_REQUESTER |
Close() | ASYNC_REQUESTER | [private]
CLOSED enum value | ASYNC_REQUESTER | [private]
CLOSING enum value | ASYNC_REQUESTER | [private]
DATA_AVAILABLE enum value | ASYNC_REQUESTER | [private]
DATA_EXHAUSTED enum value | ASYNC_REQUESTER | [private]
ERROR enum value | ASYNC_REQUESTER | [private]
HEADERS_AVAILABLE enum value | ASYNC_REQUESTER | [private]
INIT enum value | ASYNC_REQUESTER | [private]
m_ContentLength | ASYNC_REQUESTER | [private]
m_dwBytesReadSoFar | ASYNC_REQUESTER | [private]
m_dwErrorAPI | ASYNC_REQUESTER | [private]
m_dwLastError | ASYNC_REQUESTER | [private]
m_dwStartingTime | ASYNC_REQUESTER | [private]
m_dwTimeLimit | ASYNC_REQUESTER | [private]
m_fClosing | ASYNC_REQUESTER | [private]
m_fProxyAutoDiscovery | ASYNC_REQUESTER | [private]
m_fProxyFailover | ASYNC_REQUESTER | [private]
m_hConnect | ASYNC_REQUESTER | [private]
m_hRequest | ASYNC_REQUESTER | [private]
m_nFailureRetries | ASYNC_REQUESTER | [private]
m_nID | ASYNC_REQUESTER | [private]
m_nNumAttempts | ASYNC_REQUESTER | [private]
m_pBrowser | ASYNC_REQUESTER | [private]
m_ProxyInfo | ASYNC_REQUESTER | [private]
m_pwszNextProxies | ASYNC_REQUESTER | [private]
m_pwszUrl | ASYNC_REQUESTER | [private]
m_ReadBuffer | ASYNC_REQUESTER | [private]
m_State | ASYNC_REQUESTER | [private]
m_TimeRemaining | ASYNC_REQUESTER | [private]
OnHandleClosing(HINTERNET) | ASYNC_REQUESTER | [private]
OnHeadersAvailable() | ASYNC_REQUESTER | [private]
OnReadComplete(DWORD dwBytesRead) | ASYNC_REQUESTER | [private]
OnRequestError(LPWINHTTP_ASYNC_RESULT) | ASYNC_REQUESTER | [private]
OnSendRequestComplete() | ASYNC_REQUESTER | [private]
Open(PWSTR pwszUrl, BOOL fProxyAutoDiscovery, BOOL fProxyFailover, UINT nFailureRetries, UINT nTimeLimit) | ASYNC_REQUESTER |
OPENED enum value | ASYNC_REQUESTER | [private]
READ_BUFFER_SIZE enum value | ASYNC_REQUESTER | [private]
RECEIVING enum value | ASYNC_REQUESTER | [private]
RequesterStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) | ASYNC_REQUESTER | [friend]
RequestToShutdown() | ASYNC_REQUESTER |
SENDING enum value | ASYNC_REQUESTER | [private]
SIMPLE_BROWSER class | ASYNC_REQUESTER | [friend]
Start() | ASYNC_REQUESTER |
STATE enum name | ASYNC_REQUESTER | [private]
WAITING_FOR_DATA enum value | ASYNC_REQUESTER | [private]
~ASYNC_REQUESTER() | ASYNC_REQUESTER |
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWinApp Member List

This is the complete list of members for CWinApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CWinApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:57:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/deleBase.Cpp Source File

  • SysMgmt
  • MMC
  • Help

deleBase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021
00022 const GUID CDelegationBase::thisGuid = { 0x2974380b, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CDelegationBase implementation
00027 //
00028 //
00029 CDelegationBase::CDelegationBase()
00030 {
00031
00032 }
00033
00034 CDelegationBase::~CDelegationBase()
00035 {
00036 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tag_smfopenstruct Member List

This is the complete list of members for tag_smfopenstruct, including all inherited members.
dwTimeDivision | tag_smfopenstruct
hSmf | tag_smfopenstruct
pstrName | tag_smfopenstruct
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/ScannedPaperForm/C#/AssemblyInfo.cs Source File

  • TabletPC
  • ScannedPaperForm
  • C#

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("Scanned Paper Form Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2003 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 //[assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 //[assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CComSpy Member List

This is the complete list of members for CComSpy, including all inherited members.
About() | CComSpy |
AddEventToList(LONGLONG perfCount, LPCOLESTR sEvent, LPCOLESTR sApplication) | CComSpy |
AddParamValueToList(LPCOLESTR sParamName, LPCOLESTR sValue) | CComSpy |
AddRunningAspsToDebugMenu(HMENU hMenu) | CComSpy |
Audit() | CComSpy | [inline]
CComSpy() | CComSpy |
ChooseFont() | CComSpy |
ChooseLogFile(BSTR *sLogFileName, BOOL *bCanceled) | CComSpy |
ClearAllEvents() | CComSpy |
Close(DWORD dwSaveOption) | CComSpy |
CreateHFontFromIFont(IFont *pFont) | CComSpy |
EnableAudit(BOOL bEnable) | CComSpy | [private]
FinalRelease() | CComSpy | [inline]
get_Audit(BOOL *pVal) | CComSpy |
get_ColWidth(short nColumn, long *pVal) | CComSpy |
get_LogFile(BSTR *pVal) | CComSpy |
get_LogToFile(BOOL *pVal) | CComSpy |
get_ShowGridLines(BOOL *pVal) | CComSpy |
get_ShowOnScreen(BOOL *pVal) | CComSpy |
GetAuditObj() | CComSpy | [inline]
GetViewStatus(DWORD *pdwStatus) | CComSpy | [inline]
IPersistStreamInit_Load(LPSTREAM pStm, ATL_PROPMAP_ENTRY *pMap) | CComSpy |
IPersistStreamInit_Save(LPSTREAM pStm, BOOL, ATL_PROPMAP_ENTRY *pMap) | CComSpy |
m_bAudit | CComSpy | [private]
m_bCSV | CComSpy | [private]
m_bLogToFile | CComSpy | [private]
m_bShowGridLines | CComSpy | [private]
m_bShowOnScreen | CComSpy | [private]
m_cEvents | CComSpy | [private]
m_ctlSysListView32 | CComSpy |
m_hFile | CComSpy | [private]
m_hFont | CComSpy | [private]
m_hMenuDebug | CComSpy | [private]
m_hWndList | CComSpy | [private]
m_map | CComSpy | [private]
m_nWidth | CComSpy | [private]
m_pFont | CComSpy |
m_pSqlAudit | CComSpy | [private]
m_pSysAppInfo | CComSpy | [private]
m_sLogFile | CComSpy | [private]
OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnChooseFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnChooseLogFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CComSpy |
OnDebugApplication(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CComSpy |
OnDrawAdvanced(ATL_DRAWINFO &di) | CComSpy |
OnInitMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CComSpy |
OnLogToFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnRButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CComSpy |
OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnSelectApplications(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnToggleAudit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnToggleGridLines(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
OnToggleShowOnScreen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CComSpy |
put_Audit(BOOL newVal) | CComSpy |
put_ColWidth(short nColumn, long newVal) | CComSpy |
put_LogFile(BSTR newVal) | CComSpy |
put_LogToFile(BOOL newVal) | CComSpy |
put_ShowGridLines(BOOL newVal) | CComSpy |
put_ShowOnScreen(BOOL newVal) | CComSpy |
putref_Font(IFontDisp *pFont) | CComSpy | [inline]
Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog) | CComSpy | [inline]
SaveToFile() | CComSpy |
SelectApplications() | CComSpy |
SetObjectRects(LPCRECT prcPos, LPCRECT prcClip) | CComSpy | [inline]
ShouldScroll(int nIndex) | CComSpy |
ShutdownApplication(LPCOLESTR sApplicationName) | CComSpy |
Write(LPCOLESTR pszPropName, VARIANT *pVar) | CComSpy | [inline]
~CComSpy() | CComSpy | [inline]
Generated on Wed Nov 13 2024 16:55:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSCPPageKeywords Member List

This is the complete list of members for CSCPPageKeywords, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
CSCPPageKeywords(CSCPWiz *pWizExt) | CSCPPageKeywords |
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
GetSummaryInfo(CString &szSummary) | CSCPPageKeywords |
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [virtual]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
IDD enum value | CSCPPageKeywords |
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hWnd | CPropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_pAttributeEditor | CSCPPageKeywords | [private]
m_pIPropertyPageSite | CPropertyPage | [protected]
m_pWizExt | CSCPPageKeywords | [private]
m_szValueList | CSCPPageKeywords | [private]
Move(LPCRECT pRect) | CPropertyPage |
OnInitDialog() | CSCPPageKeywords | [virtual]
OnKillActive() | CSCPPageKeywords | [virtual]
OnSetActive() | CSCPPageKeywords | [virtual]
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
SetWizardButtons() | CSCPPageKeywords |
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
~CPropertyPage() | CPropertyPage | [virtual]
~CSCPPageKeywords() | CSCPPageKeywords | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/SetDisp/SetDisp.h Source File

  • Multimedia
  • Gdi
  • SetDisp

SetDisp.h

Go to the documentation of this file.
00001 /**************************************************************\
00002 *                                                              *
00003 *   Header file for SetDisp.c                                 *
00004 *                                                              *
00005 \**************************************************************/
00006 #define STRICT
00007
00008 #define _INC_OLE
00009 #include <windows.h>
00010 #undef  _INC_OLE
00011
00012
00013 /**************************************************************\
00014 *                                                              *
00015 *   Misc contants to control app behaviour                     *
00016 *                                                              *
00017 \**************************************************************/
00018 #define MYWM_NOTIFYICON   (WM_APP+100)
00019 #define VERIFY_RESCHANGE  1
00020
00021 //Milliseconds  -- set to 10 seconds
00022 #define VERIFY_TIMEOUT         10000
00023
00024 #define MAX_MODES              40
00025 #define MIN_FREQUENCY          60
00026 #define MIN_WIDTH              400
00027
00028 /**************************************************************\
00029 *                                                              *
00030 *   Global to everybody...                                     *
00031 *                                                              *
00032 \**************************************************************/
00033 HINSTANCE g_hinst       = NULL;
00034
00035 PDEVMODE  gpDevModes    = NULL;
00036 PDEVMODE  gpCurrentMode = NULL;
00037
00038 HANDLE    ghVerifyDlg   = NULL;
00039
00040 INT       gnModes       = -1;
00041 UINT      gnCurrentMode =  0;  //Default to the first until
00042                                //we determine which it really is
00043
00044
00045 /**************************************************************\
00046 *                                                              *
00047 *  Function Prototypes                                         *
00048 *                                                              *
00049 \**************************************************************/
00050 INT_PTR CALLBACK SetDispDlgProc (HWND hDlg, UINT uMsg,
00051                                WPARAM wParam, LPARAM lParam);
00052
00053 VOID CALLBACK VerifyTimerProc(HWND hwnd, UINT uMsg,
00054                               UINT_PTR idEvent,DWORD dwTime);
00055
00056 INT_PTR CALLBACK VerifyDlgProc (HWND hDlg, UINT uMsg,
00057                              WPARAM wParam, LPARAM lParam);
00058
00059 BOOL APIENTRY About (HWND hDlg, UINT message,
00060                      WPARAM wParam, LPARAM lParam);
00061
00062 VOID APIENTRY HandlePopupMenu (HWND   hwnd, POINT point);
00063
00064
00065 BOOL SetResolutionMenu (HWND hwnd);
00066 BOOL ChangeResolution (UINT nNewMode, HWND hwnd);
00067
00068 BOOL GetDevModes (HWND hWnd);
00069
00070 int CompareDevModes (DEVMODE *leftDM, DEVMODE *rightDM);
00071
00072
00073 BOOL TrayMessage (HWND hDlg, DWORD dwMessage, UINT uID,
00074                   HICON hIcon, PSTR pszTip );
00075
00076 void NotifyAdd (HWND hDlg, UINT uIndex);
00077 void NotifyDelete (HWND hDlg, UINT uIndex);
00078
00079 BOOL IsNT(void);
00080
00081
00082
00083
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventConsumer/Factory.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • EventConsumer

Factory.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00006 //
00007 //  File:  factory.cpp
00008 //
00009 //  Description :
00010 //      Event consumer provider class factory implementation
00011 //
00012 //  Part of : WMI Tutorial.
00013 //
00014 //  History:
00015 //
00016 //***************************************************************************
00017
00018 #include "stdafx.h"
00019 #include "factory.h"
00020 #include "Provider.h"
00021
00022 CProviderFactory::CProviderFactory(CListBox *pOutputList)
00023 {
00024   m_cRef = 0L;
00025   m_pOutputList = pOutputList;
00026 }
00027
00028 CProviderFactory::~CProviderFactory()
00029 {
00030 }
00031
00032 //IUnknown methods
00033
00034 STDMETHODIMP CProviderFactory::QueryInterface(REFIID riid, LPVOID FAR *ppv)
00035 {
00036     *ppv=NULL;
00037
00038     if (riid == IID_IUnknown || riid == IID_IClassFactory)
00039         *ppv=this;
00040
00041     if (*ppv != NULL)
00042     {
00043         ((LPUNKNOWN)*ppv)->AddRef();
00044         return NOERROR;
00045     }
00046
00047     return E_NOINTERFACE;
00048 }
00049
00050
00051 STDMETHODIMP_(ULONG) CProviderFactory::AddRef(void)
00052 {
00053     return InterlockedIncrement(&m_cRef);
00054 }
00055
00056
00057 STDMETHODIMP_(ULONG) CProviderFactory::Release(void)
00058 {
00059     int lNewRef = InterlockedDecrement(&m_cRef);
00060     if(lNewRef == 0)
00061     {
00062         delete this;
00063     }
00064
00065     return lNewRef;
00066 }
00067
00068 //+---------------------------------------------------------------------------
00069 //
00070 //  Function:   CProviderFactory::CreateInstance
00071 //
00072 //  Synopsis:
00073 //
00074 //  Arguments:  [pUnkOuter]
00075 //              [iid]
00076 //              [ppv]
00077 //
00078 //  Returns:    HRESULT
00079 //
00080 //  Modifies:
00081 //
00082 //----------------------------------------------------------------------------
00083 STDMETHODIMP
00084 CProviderFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
00085 {
00086   HRESULT hr;
00087     CProvider *pProvider = NULL;
00088
00089     if (pUnkOuter)
00090         return E_FAIL;
00091
00092     pProvider = new CProvider(m_pOutputList);
00093
00094     if (pProvider)
00095     {
00096         hr = pProvider->QueryInterface(riid, ppv);
00097     }
00098     else
00099     {
00100         *ppv = NULL;
00101         return E_OUTOFMEMORY;
00102     }
00103
00104     return NOERROR;
00105 }
00106
00107 //+---------------------------------------------------------------------------
00108 //
00109 //  Function:   CProviderFactory::LockServer
00110 //
00111 //  Synopsis:
00112 //
00113 //  Arguments:  [fLock]
00114 //
00115 //  Returns:    HRESULT
00116 //
00117 //  Modifies:
00118 //
00119 //----------------------------------------------------------------------------
00120 STDMETHODIMP CProviderFactory::LockServer(BOOL fLock)
00121 {
00122     if (fLock)
00123         m_cRef++;
00124     else
00125         m_cRef--;
00126
00127     return NOERROR;
00128 }
00129
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Nameext

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "globals.h"
00023 #include "resource.h"
00024 #include "guids.h"
00025 #include "basesnap.h"
00026 #include "nameext.h"
00027 #include "About.h"
00028 #include "Registry.h"
00029 #include "Extend.h"
00030
00031 // our globals
00032 HINSTANCE g_hinst;
00033
00034
00035 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00036                     DWORD fdwReason,
00037                     void* lpvReserved)
00038 {
00039
00040     if (fdwReason == DLL_PROCESS_ATTACH) {
00041         g_hinst = hinstDLL;
00042     }
00043
00044     return TRUE;
00045 }
00046
00047
00048 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00049 {
00050     if ((rclsid != CLSID_CNamespaceExtension) && (rclsid != CLSID_CSnapinAbout))
00051         return CLASS_E_CLASSNOTAVAILABLE;
00052
00053
00054     if (!ppvObj)
00055         return E_FAIL;
00056
00057     *ppvObj = NULL;
00058
00059     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00060     // if they ask for anything else.
00061     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00062         return E_NOINTERFACE;
00063
00064     CClassFactory *pFactory = NULL;
00065
00066     // make the factory passing in the creation function for the type of object they want
00067     if (rclsid == CLSID_CNamespaceExtension)
00068         pFactory = new CClassFactory(CClassFactory::NAMESPACEEXTENSION);
00069     else if (rclsid == CLSID_CSnapinAbout)
00070         pFactory = new CClassFactory(CClassFactory::ABOUT);
00071
00072     if (NULL == pFactory)
00073         return E_OUTOFMEMORY;
00074
00075     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00076
00077     return hr;
00078 }
00079
00080 STDAPI DllCanUnloadNow(void)
00081 {
00082     if (g_uObjects == 0 && g_uSrvLock == 0)
00083         return S_OK;
00084     else
00085         return S_FALSE;
00086 }
00087
00088
00089 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00090 : m_cref(0), m_factoryType(factoryType)
00091 {
00092     OBJECT_CREATED
00093 }
00094
00095 CClassFactory::~CClassFactory()
00096 {
00097     OBJECT_DESTROYED
00098 }
00099
00100 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00101 {
00102     if (!ppv)
00103         return E_FAIL;
00104
00105     *ppv = NULL;
00106
00107     if (IsEqualIID(riid, IID_IUnknown))
00108         *ppv = static_cast<IClassFactory *>(this);
00109     else
00110         if (IsEqualIID(riid, IID_IClassFactory))
00111             *ppv = static_cast<IClassFactory *>(this);
00112
00113         if (*ppv)
00114         {
00115             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00116             return S_OK;
00117         }
00118
00119         return E_NOINTERFACE;
00120 }
00121
00122 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00123 {
00124     return InterlockedIncrement((LONG *)&m_cref);
00125 }
00126
00127 STDMETHODIMP_(ULONG) CClassFactory::Release()
00128 {
00129     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00130     {
00131         delete this;
00132         return 0;
00133     }
00134     return m_cref;
00135 }
00136
00137 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00138 {
00139     HRESULT  hr;
00140     void* pObj;
00141
00142     if (!ppvObj)
00143         return E_FAIL;
00144
00145     *ppvObj = NULL;
00146
00147     // Our object does does not support aggregation, so we need to
00148     // fail if they ask us to do aggregation.
00149     if (pUnkOuter)
00150         return CLASS_E_NOAGGREGATION;
00151
00152     if (NAMESPACEEXTENSION == m_factoryType) {
00153         pObj = new CComponentData();
00154     } else {
00155         pObj = new CSnapinAbout();
00156     }
00157
00158     if (!pObj)
00159         return E_OUTOFMEMORY;
00160
00161     // QueryInterface will do the AddRef() for us, so we do not
00162     // do it in this function
00163     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00164
00165     if (FAILED(hr))
00166         delete pObj;
00167
00168     return hr;
00169 }
00170
00171 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00172 {
00173     if (fLock)
00174         InterlockedIncrement((LONG *)&g_uSrvLock);
00175     else
00176         InterlockedDecrement((LONG *)&g_uSrvLock);
00177
00178     return S_OK;
00179 }
00180
00181 //////////////////////////////////////////////////////////
00182 //
00183 // Exported functions
00184 //
00185
00186
00187 //
00188 // Server registration
00189 //
00190 STDAPI DllRegisterServer()
00191 {
00192     HRESULT hr = SELFREG_E_CLASS;
00193
00194     _TCHAR szName[256];
00195     _TCHAR szSnapInName[256];
00196
00197     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00198     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00199
00200     _TCHAR szAboutName[256];
00201
00202     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00203
00204
00205     // register our CoClasses
00206     hr = RegisterServer(g_hinst,
00207         CLSID_CNamespaceExtension,
00208         szName);
00209
00210     if SUCCEEDED(hr)
00211         hr = RegisterServer(g_hinst,
00212         CLSID_CSnapinAbout,
00213         szAboutName);
00214
00215     // place the registry information for SnapIns
00216     if SUCCEEDED(hr)
00217         hr = RegisterSnapin(CLSID_CNamespaceExtension, szSnapInName, CLSID_CSnapinAbout);
00218
00219     return hr;
00220 }
00221
00222
00223 STDAPI DllUnregisterServer()
00224 {
00225     if (UnregisterServer(CLSID_CNamespaceExtension) == S_OK)
00226         return UnregisterSnapin(CLSID_CNamespaceExtension);
00227     else
00228         return E_FAIL;
00229 }
00230
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditFeatures/resource.h Source File

  • Web
  • Browser
  • EditFeatures

resource.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 //{{NO_DEPENDENCIES}}
00006 // Microsoft Developer Studio generated include file.
00007 // Used by EdCommands.rc
00008 //
00009 #define IDS_PROJNAME                    100
00010 #define IDR_EdCommands                  100
00011 #define IDR_BROWSERHOST                   101
00012 #define IDR_TOOLBAR1                    201
00013 #define ID_BUTTON1                      32768
00014 #define ID_BUTTON2                      32769
00015 #define ID_BUTTON3                      32770
00016 #define ID_BUTTON4                      32772
00017 #define ID_BUTTON5                      32774
00018 #define ID_BUTTON6                      32776
00019 #define ID_BUTTON8                      32777
00020 #define ID_BUTTON7                      32778
00021 #define ID_BUTTON9                      32779
00022 #define ID_TOOLBARWND                   32780
00023 #define ID_BUTTON10                     32782
00024 #define ID_URLBOX                       32784
00025
00026 // Next default values for new objects
00027 //
00028 #ifdef APSTUDIO_INVOKED
00029 #ifndef APSTUDIO_READONLY_SYMBOLS
00030 #define _APS_NEXT_RESOURCE_VALUE        249
00031 #define _APS_NEXT_COMMAND_VALUE         32781
00032 #define _APS_NEXT_CONTROL_VALUE         201
00033 #define _APS_NEXT_SYMED_VALUE           104
00034 #endif
00035 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/dataobj.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

dataobj.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "DataObj.h"
00016 #include "StaticNode.h"
00017
00018                              // Tracing stuff
00019 #include "TraceMacro.h"
00020 #undef  MODULESTRING
00021 #define MODULESTRING  _T("CDataObject")
00022
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // Construction/Destruction
00026
00027
00028 //---------------------------------------------------------------------------
00029 CDataObject::CDataObject()
00030 {
00031   m_cRef     = 0;
00032   m_nCookie  = 0;
00033   m_uContext = 0;
00034
00035 }
00036
00037 //---------------------------------------------------------------------------
00038 //
00039 //
00040 CDataObject::~CDataObject()
00041 {
00042   if( MMC_MULTI_SELECT_COOKIE == m_nCookie )
00043   {
00044     // The object list contains pointers to IDataObjects which store info
00045     // on multiselect nodes.  MMC doesn't know about these so we need to
00046     // clean them up
00047     //
00048     //LPDATAOBJECT pDO = NULL;
00049     //POSITION     Pos = m_ObjectList.GetHeadPosition();
00050     //while( Pos )
00051     //{
00052     //  pDO = m_ObjectList.GetNext( Pos );
00053     //  pDO->Release();
00054     //}
00055
00056     // The Cookie list just has pointers to nodes, just delete the list
00057     m_CookieList.RemoveAll();
00058
00059     // The Guid list just has pointers to GUIDs, just delete the list.
00060     m_GuidList.RemoveAll();
00061   }
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // IUnknown implementation
00066
00067 //---------------------------------------------------------------------------
00068 STDMETHODIMP CDataObject::QueryInterface
00069 (
00070   REFIID   riid,
00071   LPVOID*  ppv
00072 )
00073 {
00074   if( !ppv )
00075     return E_FAIL;
00076
00077   HRESULT hResult = E_NOINTERFACE;
00078   *ppv = NULL;
00079
00080   if( IsEqualIID(riid, IID_IUnknown) )
00081     *ppv = static_cast<IDataObject*>(this);
00082   else if( IsEqualIID(riid, IID_IDataObject) )
00083     *ppv = static_cast<IDataObject*>(this);
00084
00085   if( *ppv )
00086   {
00087     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00088     hResult = S_OK;
00089   }
00090
00091   return hResult;
00092 }
00093
00094 //---------------------------------------------------------------------------
00095 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00096 {
00097     return InterlockedIncrement((LONG*)&m_cRef);
00098 }
00099
00100 //---------------------------------------------------------------------------
00101 STDMETHODIMP_(ULONG) CDataObject::Release()
00102 {
00103   if (InterlockedDecrement((LONG*)&m_cRef) == 0)
00104   {
00105     delete this;
00106     return 0;
00107   }
00108   return m_cRef;
00109 }
00110
00111 /////////////////////////////////////////////////////////////////////////////
00112 // IDataObject implementation
00113 //
00114
00115 //---------------------------------------------------------------------------
00116 //  MMC will call GetDataHere() for it's required clipboard formats
00117 //
00118 HRESULT CDataObject::GetDataHere
00119 (
00120   FORMATETC *pFormatEtc,     //[in]  Pointer to the FORMATETC structure
00121   STGMEDIUM *pMedium         //[out] Pointer to the STGMEDIUM structure
00122 )
00123 {
00124   const CLIPFORMAT cf = pFormatEtc->cfFormat;
00125   IStream* ipStream = NULL;
00126
00127   HRESULT hResult = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &ipStream );
00128   if( S_OK != hResult )
00129     return hResult;                        // Minimal error checking
00130
00131   hResult = DV_E_FORMATETC;                // Unknown format
00132
00133   if( cf == g_cfDisplayName )
00134   {
00135     hResult = RetrieveDisplayString( ipStream );
00136   }
00137   else if( cf == g_cfSnapinClsid )
00138   {
00139     hResult = RetrieveSnapInClassID( ipStream );
00140   }
00141   else if( cf == g_cfNodeType )
00142   {
00143     hResult = RetrieveNodeTypeGuid( ipStream );
00144   }
00145   else if( cf == g_cfszNodeType )
00146   {
00147     hResult = RetrieveGuidString( ipStream );
00148   }
00149   else if( cf == g_cfBaseNodePtr )
00150   {
00151     hResult = RetrieveBaseNodePtr( ipStream );
00152   }
00153   else if( cf == g_cfDataObjPtr )
00154   {
00155     hResult = RetrieveDataObjPtr( ipStream );
00156   }
00157
00158   ipStream->Release();
00159
00160   return hResult;
00161 }
00162
00163 //---------------------------------------------------------------------------
00164 //  MULTISELECT: MMC will call here for multiselect clipboard formats
00165 //
00166 HRESULT CDataObject::GetData
00167 (
00168   FORMATETC* pFormatEtc,     //[in]  Pointer to the FORMATETC structure
00169   STGMEDIUM* pStgMedium      //[out] Pointer to the STGMEDIUM structure
00170 )
00171 {
00172   HRESULT hResult = DV_E_FORMATETC;
00173
00174   do
00175   {
00176     if( g_cfMS_Cookies == pFormatEtc->cfFormat )
00177     {
00178       hResult = RetrieveMultiSelectCookies( pStgMedium );
00179       continue;
00180     }
00181     if( g_cfMS_Objects == pFormatEtc->cfFormat )
00182     {
00183       hResult = RetrieveMultiSelectTypes( pStgMedium );
00184       continue;
00185     }
00186     if( g_cfMS_IsMsObj == pFormatEtc->cfFormat )
00187     {
00188       hResult = S_FALSE;
00189       continue;
00190     }
00191   }while( 0 );
00192
00193   return hResult;
00194 }
00195
00196 //---------------------------------------------------------------------------
00197 VOID CDataObject::SetPrivateData
00198 (
00199   INT_PTR  nCookie,      //[in] Pointer to node this object represents
00200   ULONG    uContext      //[in] Context of the node
00201 )
00202 {
00203   m_nCookie  = nCookie;
00204   m_uContext = uContext;
00205 }
00206
00207 /////////////////////////////////////////////////////////////////////////////
00208 //  Handlers for MMC's required clipboard formats
00209
00210
00211 //---------------------------------------------------------------------------
00212 // CCF_DISPLAY_NAME is one of the required clipformats.
00213 // MMC askes for this string to display the name of the SnapIn's StaticNode
00214 // in the ScopePane
00215 //
00216 HRESULT CDataObject::RetrieveDisplayString
00217 (
00218   IStream* ipStream        //[in-out] Stream to return our data in.
00219 )
00220 {
00221   CBaseNode* pNode = reinterpret_cast<CBaseNode*>(m_nCookie);
00222   LPWSTR pNodeName = pNode->GetNodeName();
00223
00224   ULONG ulSizeofName = (wcslen(pNodeName) + 1) * sizeof(WCHAR);
00225   return ipStream->Write(pNodeName, ulSizeofName, NULL);
00226
00227 }
00228
00229 //---------------------------------------------------------------------------
00230 //  CCF_SNAPIN_CLASSID is one of the required clipformats.
00231 //  MMC will ask for this data.  This ClassID which we return represents
00232 //  the COM object which is the entry point for our SnapIn
00233 //
00234 HRESULT CDataObject::RetrieveSnapInClassID
00235 (
00236   IStream* ipStream        //[in-out] Stream to return our data in.
00237 )
00238 {
00239   return ipStream->Write( &CLSID_CComponentData, sizeof(GUID), NULL );
00240 }
00241
00242
00243 //---------------------------------------------------------------------------
00244 //  CCF_NODETYPE is one of the required clipformats.
00245 //  MMC needs the NodeType GUID to determine what extensions to activate
00246 //  for a node.  It looks under the MMC/NodeTypes registry key for the GUID
00247 //  and enumerates the extensions found beneath it.  MMC uses this GUID
00248 //  strictly as a uniquie identifier.  It does not expect it to correspond
00249 //  to the ClaseID of a com object.
00250 //
00251 HRESULT CDataObject::RetrieveNodeTypeGuid
00252 (
00253   IStream* ipStream        //[in-out] Stream to return our data in.
00254 )
00255 {
00256   CBaseNode* pNode = reinterpret_cast<CBaseNode*>(m_nCookie);
00257   GUID* pGuid = (GUID*)&pNode->GetNodeGUID();
00258
00259   return ipStream->Write( (void*)pGuid, sizeof(GUID), NULL );
00260 }
00261
00262
00263 //---------------------------------------------------------------------------
00264 //  CCF_SZNODETYPE is a required clipboard format.
00265 //  We return the node's GUID as a wide string.
00266 //
00267 HRESULT CDataObject::RetrieveGuidString
00268 (
00269   IStream* ipStream        //[in-out] Stream to return our data in.
00270 )
00271 {
00272   LPOLESTR pszGUID;
00273   CBaseNode* pNode = reinterpret_cast<CBaseNode*>(m_nCookie);
00274
00275   HRESULT  hResult = StringFromCLSID( pNode->GetNodeGUID(), &pszGUID );
00276   if( S_OK == hResult )
00277   {
00278     hResult = ipStream->Write( pszGUID, (wcslen(pszGUID) + 1) * sizeof(WCHAR), NULL );
00279     CoTaskMemFree( pszGUID );
00280   }
00281
00282   return hResult;
00283 }
00284
00285 //---------------------------------------------------------------------------
00286 HRESULT CDataObject::RetrieveBaseNodePtr
00287 (
00288   IStream* ipStream        //[in-out] Stream to return our data in.
00289 )
00290 {
00291   LPBASENODE pNode = reinterpret_cast<LPBASENODE>(m_nCookie);
00292   return ipStream->Write( &pNode, sizeof(LPBASENODE), NULL );
00293 }
00294
00295 //---------------------------------------------------------------------------
00296 HRESULT CDataObject::RetrieveDataObjPtr
00297 (
00298   IStream* ipStream        //[in-out] Stream to return our data in.
00299 )
00300 {
00301   CDataObject* pThis = this;
00302   return ipStream->Write( &pThis, sizeof(CDataObject*), NULL );
00303 }
00304
00305 /////////////////////////////////////////////////////////////////////////////
00306 //  MULTISELECT:  Support for multiselect clipformats and helper methods
00307
00308
00309 //---------------------------------------------------------------------------
00310 //
00311 //
00312
00313 HRESULT CDataObject::RetrieveMultiSelectCookies
00314 (
00315   STGMEDIUM* pStgMedium      //[out] Pointer to the STGMEDIUM structure
00316 )
00317 {
00318   HRESULT hResult = S_OK;
00319   DWORD dwMemSize = (m_CookieList.GetCount() * sizeof(LONG_PTR)) + sizeof(DWORD);
00320
00321   HGLOBAL hMem =  GlobalAlloc( GMEM_SHARE | GMEM_MOVEABLE, dwMemSize);
00322   if( NULL == hMem )
00323     hResult = E_OUTOFMEMORY;
00324   else
00325   {
00326     MULTISELECT_COOKIES* pMSCookies = (MULTISELECT_COOKIES*)GlobalLock( hMem );
00327     pMSCookies->count = m_CookieList.GetCount();
00328
00329     LONG nIndex  = 0;
00330     POSITION Pos = m_CookieList.GetHeadPosition();
00331     while( Pos )
00332     {
00333       pMSCookies->Cookies[nIndex] = m_CookieList.GetNext( Pos );
00334       nIndex++;
00335     }
00336
00337     GlobalUnlock( hMem );
00338     pStgMedium->hGlobal        = hMem;
00339     pStgMedium->tymed          = TYMED_HGLOBAL;
00340     pStgMedium->pUnkForRelease = NULL;
00341   }
00342   return hResult;
00343 }
00344
00345 //---------------------------------------------------------------------------
00346 //  MULTISELECT:  Support for CCF_OBJECT_TYPES_IN_MULTI_SELECT
00347 //
00348 HRESULT CDataObject::RetrieveMultiSelectTypes
00349 (
00350   STGMEDIUM* pStgMedium      //[out] Pointer to the STGMEDIUM structure
00351 )
00352 {
00353   HRESULT hResult = S_OK;
00354   DWORD dwMemSize = (m_GuidList.GetCount() * sizeof(GUID)) + sizeof(DWORD);
00355
00356   DATA_OBJECT_TYPES type = (DATA_OBJECT_TYPES)m_uContext;
00357
00358   HGLOBAL hMem =  GlobalAlloc( GMEM_SHARE | GMEM_MOVEABLE, dwMemSize );
00359   if( NULL == hMem )
00360     hResult = E_OUTOFMEMORY;
00361   else
00362   {
00363     SMMCObjectTypes* pMSObjTypes = (SMMCObjectTypes*)GlobalLock( hMem );
00364     pMSObjTypes->count = m_GuidList.GetCount();
00365
00366     LONG nIndex  = 0;
00367     POSITION Pos = m_GuidList.GetHeadPosition();
00368     while( Pos )
00369     {
00370       CopyMemory( (void*)&pMSObjTypes->guid[nIndex], (void*)m_GuidList.GetNext( Pos ), sizeof(GUID) );
00371       nIndex++;
00372     }
00373
00374     GlobalUnlock( hMem );
00375     pStgMedium->hGlobal        = hMem;
00376     pStgMedium->tymed          = TYMED_HGLOBAL;
00377     pStgMedium->pUnkForRelease = NULL;
00378   }
00379
00380   return hResult;
00381 }
00382
00383 //---------------------------------------------------------------------------
00384 HRESULT CDataObject::AddMultiSelectCookie
00385 (
00386   LONG_PTR   nCookie         //[in] Cookie to add to multiselect list
00387 )
00388 {
00389   _ASSERT( nCookie > 0 );
00390   m_CookieList.AddTail( nCookie );     // Add the data object to our list
00391
00392   return S_OK;
00393 }
00394
00395 //---------------------------------------------------------------------------
00396 //  MULTISELECT:  Add a new GUID pointer to the list.  This method places
00397 //  the onus of determining the uniqueness of GUIDs on the caller.  All
00398 //  GUIDs in this list must be unique.
00399 //
00400 HRESULT CDataObject::AddMultiSelectGuid
00401 (
00402   GUID*  pGuid         //[in] GUID to add to multiselect list
00403 )
00404 {
00405   _ASSERT( NULL != pGuid );
00406   m_GuidList.AddTail( pGuid );     // Add the GUID to our list
00407
00408   return S_OK;
00409 }
00410
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminOS.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminOS.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminOS
00019
00020 public interface COMAdminOS
00021 {
00022   public static final int COMAdminOSWindows3_1 = 1;
00023   public static final int COMAdminOSWindows9x = 2;
00024   public static final int COMAdminOSWindowsNT = 3;
00025   public static final int COMAdminOSWindowsNTEnterprise = 4;
00026 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/error.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

error.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module ERROR.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _ERROR_H_
00012 #define _ERROR_H_
00013
00014
00015 ///////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 ///////////////////////////////////////////////////////////////
00019
00020
00021 ///////////////////////////////////////////////////////////////
00022 // Defines
00023 //
00024 ///////////////////////////////////////////////////////////////
00025 typedef struct _NAMEMAP
00026 {
00027   CHAR*   pszName;  // Name
00028   LONG    lItem;    // Item
00029 } NAMEMAP;
00030
00031 typedef struct _WIDENAMEMAP
00032 {
00033   WCHAR*    pwszName; // Name
00034   LONG    lItem;    // Item
00035 } WIDENAMEMAP;
00036
00037 typedef struct _WIDEGUIDMAP
00038 {
00039   WCHAR*      pwszName; // Name
00040   const GUID*   pGuid;    // Guid
00041 } WIDEGUIDMAP;
00042
00043 typedef struct _WIDEDBIDMAP
00044 {
00045   WCHAR*      pwszName; // Name
00046   const DBID*   pDBID;    // DBID
00047 } WIDEDBIDMAP;
00048
00049
00050 ////////////////////////////////////////////////////////////////////////////
00051 // Extened Error Info
00052 //
00053 ////////////////////////////////////////////////////////////////////////////
00054 enum ERRORPOST
00055 {
00056   EP_ERRORINFO_ALWAYS   = 0x00000002,
00057   EP_ERRORINFO_FAILURE  = 0x00000004,
00058   EP_ERRORINFO_NEVER    = 0x00000008,
00059
00060   EP_HRESULT_ALWAYS   = 0x00000010,
00061   EP_HRESULT_NOERRORINFO  = 0x00000020,
00062   EP_HRESULT_NEVER    = 0x00000040,
00063   EP_HRESULT_FAILURE    = 0x00000080,
00064
00065   EP_REFCOUNT_FAILURE   = 0x00000100,
00066   EP_IMALLOC_SPY      = 0x00001000,
00067   EP_IMALLOC_ALLOCS   = 0x00002000
00068 };
00069
00070 extern DWORD g_dwErrorPost;
00071 extern DWORD g_dwBreakID;
00072 BOOL SetErrorPosting(ERRORPOST eErrorPost, BOOL fSet = TRUE);
00073 BOOL GetErrorPosting(ERRORPOST eErrorPost);
00074
00075
00076 WCHAR*    GetMapName(REFGUID guid, ULONG cGuidMap, const WIDEGUIDMAP* rgGuidMap);
00077 WCHAR*    GetMapName(const DBID* pDBID, ULONG cDBIDMap, const WIDEDBIDMAP* rgDBIDMap);
00078 CHAR*   GetMapName(LONG lItem, ULONG cNameMap, const NAMEMAP* rgNameMap);
00079 WCHAR*    GetMapName(LONG lItem, ULONG cNameMap, const WIDENAMEMAP* rgNameMap, DWORD dwConvFlags = CONV_NONE);
00080 LONG    GetMapName(CHAR* psz, ULONG cNameMap, const NAMEMAP* rgNameMap);
00081 LONG    GetMapName(WCHAR* pwsz, ULONG cNameMap, const WIDENAMEMAP* rgNameMap);
00082 WCHAR*    GetBitMapName(DWORD dwItem, ULONG cNameMap, const WIDENAMEMAP* rgNameMap, DWORD dwBitStart = 0);
00083
00084 CHAR*   GetErrorName(HRESULT hr);
00085 WCHAR*    GetStatusName(DBSTATUS dbStatus, DWORD dwConvFlags = CONV_DECIMAL);
00086 DBSTATUS  GetStatusValue(WCHAR* pszName);
00087 WCHAR*    GetInterfaceName(REFIID riid);
00088 WCHAR*    GetObjectTypeName(REFGUID rguidObjectType);
00089 WCHAR*    GetDialectName(REFGUID rguid);
00090 WCHAR*    GetRowColName(const DBID* pColumnid);
00091
00092 //Generic Errors
00093 HRESULT   DisplayHRESULT(HRESULT hrActual, WCHAR* pwszFile = L"Unknown", ULONG ulLine = 0, INT* piResult = 0);
00094 HRESULT   DisplayWinError(DWORD dwError, WCHAR* pwszFile, LONG lLine, WCHAR* pwszText = L"Windows");
00095
00096 //IErrorInfo
00097 HRESULT   DisplayAllErrors(HRESULT hrActual, WCHAR* pwszFile = L"Unknown", ULONG ulLine = 0, INT* piResult = 0);
00098 HRESULT   DisplayAllErrors(HRESULT hrActual, HRESULT hrExpected, WCHAR* pwszFile = L"Unknown", ULONG ulLine = 0, INT* piResult = 0);
00099 HRESULT   DisplayErrorInfo(HRESULT hrActual, WCHAR* pwszFile = L"Unknown", ULONG ulLine = 0, INT* piResult = 0);
00100
00101 //ISQLErrorInfo
00102 HRESULT   GetSqlErrorInfo(ULONG iRecord, IErrorRecords* pIErrorRecords, BSTR* pBstr, LONG* plNativeError = NULL);
00103
00104 //Binding Errors
00105 HRESULT   DisplayBindingErrors(HRESULT hrReturned, DBCOUNTITEM cBindings, const DBBINDING* rgBindings, void* pData);
00106 HRESULT   DisplayColumnErrors(HRESULT hrReturned, DBORDINAL cColumns, DBID* rgColumns, DBSTATUS* rgStatus);
00107 HRESULT   DisplayColAccessErrors(HRESULT hrReturned, DBORDINAL cColAccess, DBCOLUMNACCESS* rgColAccess);
00108 HRESULT   DisplayRowErrors(HRESULT hrReturned, DBROWCOUNT cRows, HROW* rghRows, DBROWSTATUS* rgRowStatus);
00109 HRESULT   DisplayAccessorErrors(HRESULT hrReturned, DBCOUNTITEM cBindings, const DBBINDING* rgBindings, DBBINDSTATUS* rgStatus);
00110
00111 //Properties
00112 WCHAR*    GetPropSetName(REFGUID guidPropertySet);
00113 WCHAR*    GetPropertyName(DBPROPID dwPropertyID, REFGUID guidPropertySet);
00114 WCHAR*    GetPropStatusName(DBPROPSTATUS dbPropStatus);
00115 HRESULT   GetStaticPropValues(DBPROPID dwPropertyID, REFGUID guidPropertySet, ULONG* pcPropValMap, const WIDENAMEMAP** prgPropValMap);
00116 HRESULT   GetStaticPropInfo(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets, ULONG* pcStaticInfoSets, const DBPROPINFOSET** prgStaticInfoSets);
00117 HRESULT   GetAllocedPropInfo(ULONG cPropertyIDSets, DBPROPIDSET* rgPropertyIDSets, ULONG* pcPropInfoSets, DBPROPINFOSET** prgPropInfoSets);
00118 BOOL    IsSpecialPropSet(REFGUID guidSpecialPropertySet, GUID* pGuidPropertySet);
00119
00120 //Property Errors
00121 HRESULT   DisplayPropErrors(HRESULT hrReturned, REFIID riid, IUnknown* pIUnknown);
00122 HRESULT   DisplayPropErrors(HRESULT hrReturned, ULONG cPropSets, DBPROPSET* rgPropSets);
00123 HRESULT   DisplayPropErrors(HRESULT hrReturned, ULONG cPropInfoSets, DBPROPINFOSET* rgPropInfoSets);
00124
00125 //RefCount Errors
00126 HRESULT   DisplayRefCountErrors(WCHAR* pwszName, ULONG ulActRefCount, ULONG ulExpRefCount = 0);
00127
00128 //Notifications
00129 WCHAR*    GetPhaseName(DBEVENTPHASE ePhase);
00130 WCHAR*    GetReasonName(DBREASON eReason);
00131 WCHAR*    GetAsynchReason(ULONG ulOperation);
00132 WCHAR*    GetAsynchPhase(ULONG ulAsynchPhase);
00133
00134
00135 /////////////////////////////////////////////////////////////////////////////
00136 //  Name MAPS
00137 //
00138 /////////////////////////////////////////////////////////////////////////////
00139 extern const ULONG      g_cInterfaceMaps;
00140 extern const WIDEGUIDMAP  g_rgInterfaceMaps[];
00141
00142 extern const ULONG      g_cDBTypes;
00143 extern const WIDENAMEMAP  g_rgDBTypes[];
00144
00145 extern const ULONG      g_cPropSetMaps;
00146 extern const WIDEGUIDMAP  g_rgPropSetMaps[];
00147
00148 extern const ULONG      g_cVariantTypes;
00149 extern const WIDENAMEMAP  g_rgVariantTypes[];
00150
00151 extern const WIDENAMEMAP  g_rgIsoLevels[];
00152 extern const ULONG      g_cIsoLevels;
00153
00154 extern const WIDENAMEMAP  g_rgXACTTC[];
00155 extern const ULONG      g_cXACTTC;
00156
00157 extern const ULONG      g_cColFlagsMaps;
00158 extern const WIDENAMEMAP  g_rgColFlagsMaps[];
00159
00160 extern const ULONG      g_cObjectTypeMaps;
00161 extern const WIDEGUIDMAP  g_rgObjectTypeMaps[];
00162
00163 extern const ULONG      g_cDialectMaps;
00164 extern const WIDEGUIDMAP  g_rgDialectMaps[];
00165
00166 extern const ULONG      g_cPromptOptions;
00167 extern const WIDENAMEMAP  g_rgPromptOptions[];
00168
00169 extern const ULONG      g_cSourceType;
00170 extern const WIDENAMEMAP  g_rgSourceType[];
00171
00172 extern const ULONG      g_cBindURLMaps;
00173 extern const WIDENAMEMAP  g_rgBindURLMaps[];
00174
00175 extern const ULONG      g_cRowColMaps;
00176 extern const WIDEDBIDMAP  g_rgRowColMaps[];
00177
00178 extern const ULONG      g_cLCID;
00179 extern const WIDENAMEMAP  g_rgLCID[];
00180
00181 extern const ULONG      g_cConsTypeMaps;
00182 extern const WIDENAMEMAP  g_rgConsTypeMaps[];
00183
00184 extern const ULONG      g_cDeferrabilityMaps;
00185 extern const WIDENAMEMAP  g_rgDeferrabilityMaps[];
00186
00187 extern const ULONG      g_cMatchTypeMaps;
00188 extern const WIDENAMEMAP  g_rgMatchTypeMaps[];
00189
00190 extern const ULONG      g_cUpDelRuleMaps;
00191 extern const WIDENAMEMAP  g_rgUpDelRuleMaps[];
00192
00193 extern const ULONG      g_cCDFlagsMaps;
00194 extern const WIDENAMEMAP  g_rgCDFlagsMaps[];
00195
00196 extern const ULONG      g_cResultFlagMaps;
00197 extern const WIDENAMEMAP  g_rgResultFlagMaps[];
00198
00199 #endif  //_ERROR_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSimpleClass Member List

This is the complete list of members for CSimpleClass, including all inherited members.
CSimpleClass() | CSimpleClass |
InInOutPipesSample(IPipeLong *pInPipe1, IPipeLong *pInPipe2, IPipeLong **ppOutPipe) | CSimpleClass |
InOutPipeSample(IPipeLong **ppInOutPipe) | CSimpleClass |
InPipeSample(IPipeLong *pInPipe) | CSimpleClass |
m_cRef | CSimpleClass | [private]
OutPipeSample(IPipeLong **pOutPipe) | CSimpleClass |
QueryInterface(REFIID riid, void **ppv) | CSimpleClass |
STDMETHODIMP_(ULONG) AddRef(void) | CSimpleClass |
STDMETHODIMP_(ULONG) Release(void) | CSimpleClass |
~CSimpleClass() | CSimpleClass |
Generated on Wed Nov 13 2024 16:57:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCIncoming/Utils.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCIncoming

Utils.h

Go to the documentation of this file.
00001
00002 /******************************************************>
00003  * Copyright (c) 2001 Microsoft Corporation.
00004  * All rights reserved.
00005  *
00006  *
00007  * @Abstract: Utils.h
00008  * ---------- [ Header Definition File]
00009  *
00010  *
00011  * @Description:
00012  * -------------
00013  * Utilities for logging Error Messages in the debugger
00014  * or in a Popup message box
00015  *
00016  *
00017  ******************************************************/
00018
00019 #ifndef __RTCINCOMINGUTILS__H__
00020 #define __RTCINCOMINGUTILS__H__
00021
00022
00023 #define FREE_BSTR_IF(bstrVal) \
00024   { if (NULL != bstrVal) { SysFreeString(bstrVal); bstrVal = NULL ;}  else bstrVal = NULL; }
00025
00026
00027 #ifdef __cplusplus
00028 //
00029 // for C Var length parameters
00030 //
00031 extern "C" {
00032 #endif
00033
00034 int  DBLOGGER(TCHAR *str, ...) ;
00035 void LOGMSGERROR(TCHAR *str, ...);
00036
00037 #ifdef __cplusplus
00038 }
00039 #endif
00040
00041
00042
00043 #endif
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IPC/NamePipe/NPServer/Server32.c Source File

  • WinBase
  • IPC
  • NamePipe
  • NPServer

Server32.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 *       This source code is only intended as a supplement to
00010 *       Microsoft Development Tools and/or WinHelp documentation.
00011 *       See these sources for detailed information regarding the
00012 *       Microsoft samples programs.
00013 \******************************************************************************/
00014
00015 /*************************************************************************\
00016 *  PROGRAM: server32.c
00017 *
00018 *  PURPOSE:
00019 *
00020 *     To demonstrate the use of named pipes and the overlapped structure.
00021 *     This code serves as the server side of the named pipe instances.
00022 *     For more details on an overview of this codes designs or use, see
00023 *     the README file.  For details on the implementation, see the comments
00024 *     in this code.
00025 *
00026 *
00027 \*************************************************************************/
00028
00029 #define  STRICT
00030 #include <windows.h>
00031 #include <sddl.h>
00032 #include "server32.h"
00033
00034 #include <string.h>
00035 #include <stdio.h>
00036 #include <stdlib.h>
00037
00038                                        // clients[] is a global array of
00039                                        // structures used to keep track
00040                                        // of the multiple instances of
00041                                        // the server side of the named
00042                                        // pipe.  As a client connects
00043                                        // to a given instance, a new
00044                                        // server thread is created and
00045                                        // added to the array.
00046 WRTHANDLE clients[MAX_PIPE_INSTANCES];
00047 DWORD     clientCount = 0;             // Global count of connected clients.
00048
00049 HWND   hWnd;
00050 HANDLE hInst;
00051 CHAR   lpBuffer[255];
00052
00053 // CreateMyDACL
00054 // Creates a security descriptor containing the
00055 // desired DACL. This function uses SDDL to make Deny and Allow ACEs.
00056 //
00057 // Parameter:
00058 //     SECURITY_ATTRIBUTES * pSA
00059 // Address to a SECURITY_ATTRIBUTES structure. It is the caller's
00060 // responsibility to properly initialize the structure, and to free
00061 // the structure's lpSecurityDescriptor member when done (by calling
00062 // the LocalFree function).
00063 //
00064 // Return value:
00065 //    FALSE if the address to the structure is NULL.
00066 //    Otherwise, this function returns the value from the
00067 //    ConvertStringSecurityDescriptorToSecurityDescriptor function.
00068 BOOL CreateMyDACL(SECURITY_ATTRIBUTES * pSA)
00069 {
00070     // Define the SDDL for the DACL. This example sets
00071     // the following access:
00072     //     Built-in guests are denied all access.
00073     //     Anonymous Logon is denied all access.
00074     //     Authenticated Users are allowed read/write/execute access.
00075     //     Administrators are allowed full control.
00076     // Modify these values as needed to generate the proper
00077     // DACL for your application.
00078     TCHAR * szSD = "D:"                   // Discretionary ACL
00079                    "(D;OICI;GA;;;BG)"     // Deny access to Built-in Guests
00080                    "(D;OICI;GA;;;AN)"     // Deny access to Anonymous Logon
00081                    "(A;OICI;GRGWGX;;;AU)" // Allow read/write/execute to Authenticated Users
00082                    "(A;OICI;GA;;;BA)";    // Allow full control to Administrators
00083
00084     if (NULL == pSA)
00085         return FALSE;
00086
00087     return ConvertStringSecurityDescriptorToSecurityDescriptor(
00088                                                               szSD,
00089                                                               SDDL_REVISION_1,
00090                                                               &(pSA->lpSecurityDescriptor),
00091                                                               NULL);
00092 }
00093
00094 /*************************************************************************\
00095 *
00096 *  FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
00097 *
00098 *  PURPOSE: calls initialization function, processes message loop
00099 *
00100 *  COMMENTS:
00101 *
00102 \*************************************************************************/
00103
00104 int APIENTRY WinMain (HINSTANCE hInstance,
00105                       HINSTANCE hPrevInstance,
00106                       LPSTR  lpCmdLine,
00107                       int    nCmdShow)
00108
00109
00110 {
00111
00112   MSG  msg;
00113   WNDCLASS wc;
00114
00115
00116   UNREFERENCED_PARAMETER( lpCmdLine );
00117   UNREFERENCED_PARAMETER( hPrevInstance );
00118
00119   //
00120   // Detect platform and exit gracefully if not Windows NT.
00121   //
00122
00123   {
00124     OSVERSIONINFO osvi;
00125     osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
00126
00127     GetVersionEx (&osvi);
00128     if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) {
00129           LoadString(hInst, IDS_WRONGOS, lpBuffer, sizeof(lpBuffer));
00130       MessageBox (NULL, lpBuffer, "SERVER32", MB_OK | MB_ICONSTOP);
00131       return 0;
00132     }
00133   }
00134
00135
00136
00137   hInst = hInstance;
00138
00139   wc.style = 0;
00140   wc.lpfnWndProc = (WNDPROC)MainWndProc;
00141   wc.cbClsExtra = 0;
00142   wc.cbWndExtra = 0;
00143   wc.hInstance = hInstance;
00144   wc.hIcon = LoadIcon (hInstance, "npserver");
00145   wc.hCursor = LoadCursor (NULL, IDC_ARROW);
00146   wc.hbrBackground = GetStockObject (WHITE_BRUSH);
00147   wc.lpszMenuName = "PipeMenu";
00148   wc.lpszClassName = "PipeWClass";
00149
00150   RegisterClass(&wc);
00151
00152   LoadString(hInst, IDS_WINDOWTITLE, lpBuffer, sizeof(lpBuffer));
00153   hWnd = CreateWindow ("PipeWClass",
00154                        lpBuffer,
00155                        WS_OVERLAPPEDWINDOW,
00156                        CW_USEDEFAULT,
00157                        CW_USEDEFAULT,
00158                        CW_USEDEFAULT,
00159                        CW_USEDEFAULT,
00160                        NULL,
00161                        NULL,
00162                        hInstance,
00163                        NULL);
00164
00165
00166   ShowWindow (hWnd, nCmdShow);
00167
00168   while (GetMessage (&msg, NULL, 0, 0))
00169     DispatchMessage (&msg);
00170
00171   return (int)(msg.wParam);
00172
00173 }
00174
00175 /*************************************************************************\
00176 *
00177 *  FUNCTION:  MainWndProc (HWND, UINT, WPARAM, LPARAM)
00178 *
00179 *  PURPOSE:   To process messages.  To launch client and server threads
00180 *
00181 \*************************************************************************/
00182
00183 LRESULT CALLBACK MainWndProc (HWND   hwnd,
00184                            UINT   message,
00185                            WPARAM wParam,
00186                            LPARAM lParam)
00187 {
00188
00189   LONG        lpServerThreadID;
00190   PAINTSTRUCT paintStruct;
00191   HDC         hDC;
00192
00193   switch (message)
00194       {
00195         case WM_PAINT:
00196            // DrawBranch is used to paint the spools and text to the window.
00197            hDC = BeginPaint (hwnd, &paintStruct);
00198            DrawBranch (hDC);
00199            EndPaint (hwnd, &paintStruct);
00200            return(0);
00201
00202         case WM_CREATE :
00203            // Create the first instance of a server side of the pipe.
00204            CreateThread ((LPSECURITY_ATTRIBUTES)NULL,       // No security.
00205                          (DWORD)0,                          // Same stack size.
00206                          (LPTHREAD_START_ROUTINE)ServerProc,// Thread procedure.
00207                          (LPVOID)&hwnd,                     // Parameter.
00208                          (DWORD)0,                          // Start immediatly.
00209                          (LPDWORD)&lpServerThreadID);       // Thread ID.
00210            return (0);
00211
00212         case WM_DESTROY :
00213            PostQuitMessage (0);
00214            return (0);
00215        }
00216     return DefWindowProc (hwnd, message, wParam, lParam);
00217 }
00218
00219
00220
00221 /*************************************************************************\
00222 *
00223 *  PROCEDURE: ServerProc (HWND *hWnd)
00224 *
00225 *  PURPOSE:
00226 *
00227 *    A thread procedure, which creates an instance of the server side of
00228 *    the named pipe, and then blocks waiting for a client to connect.
00229 *    Once the client connects, a global array is updated with the specific
00230 *    clients information, and this procedure is called again
00231 *    to launch another waiting server thread.  After launching the new
00232 *    thread, this thread begins to loop, reading the named pipe.  When
00233 *    a message comes from it's client, it uses TellAll() to broadcast
00234 *    the message to the other clients in the array.
00235 *
00236 *  CALLED BY:
00237 *
00238 *    ServerProc();
00239 *    WinMain();
00240 *
00241 *  CALLS TO:
00242 *
00243 *    TellAll();
00244 *    ServerProc().
00245 *
00246 *  COMMENTS:
00247 *
00248 *    Clients is a global array which hold information on each client
00249 *    connected to the named pipe.  This procedure recieves a buffer.
00250 *    It then steps through this global array, and for each client it
00251 *    writes the buffer.
00252 *
00253 \*************************************************************************/
00254
00255 VOID ServerProc(HWND *hWnd)
00256  {
00257    HANDLE hThread;                       // Pipe handle.
00258    HANDLE hPipe;                       // Pipe handle.
00259    CHAR   inBuf[IN_BUF_SIZE] = "";     // Input buffer for pipe.
00260    DWORD  ServerThreadID;              // Used for CreateThread().
00261
00262    CHAR   errorBuf[LINE_LEN] = "";     // Used for error messages.
00263    DWORD  bytesRead;                   // Used in ReadFile().
00264    DWORD  retCode;                     // Used to trap return codes.
00265    DWORD  clientIndex;                 // Index into global array, for this
00266                                        // instances client.
00267    DWORD  lastError;                   // Traps returns from GetLastError().
00268    BOOL   ExitLoop = FALSE;            // Boolean Flag to exit loop.
00269
00270    OVERLAPPED OverLapWrt;              // Overlapped structure for writing.
00271    HANDLE     hEventWrt;               // Event handle for overlapped write.
00272
00273    OVERLAPPED OverLapRd;               // Overlapped structure for reading.
00274    HANDLE     hEventRd;                // Event handle for overlapped reads.
00275    DWORD        bytesTransRd;          // Bytes transferred by overlapped.
00276    //PSECURITY_DESCRIPTOR    pSD;
00277    SECURITY_ATTRIBUTES     sa;
00278
00279
00280    if (!CreateMyDACL(&sa))
00281      {
00282      MessageBox (*hWnd, "CreateMyDACL Failed", "Debug: ServerProc()", MB_OK);
00283      return;
00284      }
00285
00286    sa.nLength = sizeof(sa);
00287    sa.bInheritHandle = TRUE;
00288
00289                                        // Create a local named pipe with
00290                                        // the name '\\.\PIPE\test'.  The
00291                                        // '.' signifies local pipe.
00292    hPipe = CreateNamedPipe ("\\\\.\\PIPE\\test", // Pipe name = 'test'.
00293                PIPE_ACCESS_DUPLEX                // 2 way pipe.
00294                | FILE_FLAG_OVERLAPPED,           // Use overlapped structure.
00295                PIPE_WAIT                         // Wait on messages.
00296                | PIPE_READMODE_MESSAGE           // Specify message mode pipe.
00297                | PIPE_TYPE_MESSAGE,
00298                MAX_PIPE_INSTANCES,               // Maximum instance limit.
00299                OUT_BUF_SIZE,                     // Buffer sizes.
00300                IN_BUF_SIZE,
00301                TIME_OUT,                         // Specify time out.
00302                &sa);                             // Security attributes.
00303
00304                                        // Check Errors.
00305     if ((DWORD)(DWORD_PTR)hPipe == 0xFFFFFFFF)
00306      {
00307
00308      retCode = GetLastError();         // Report any error, it should always succeed.
00309      LoadString(hInst, IDS_ERRORCODE, lpBuffer, sizeof(lpBuffer));
00310      wsprintf (errorBuf, lpBuffer, retCode);
00311      LoadString(hInst, IDS_DEBUGTITLE, lpBuffer, sizeof(lpBuffer));
00312      MessageBox (*hWnd, errorBuf, lpBuffer,
00313                  MB_ICONINFORMATION | MB_OK | MB_APPLMODAL);
00314      };
00315
00316                                        // Block until a client connects.
00317    ConnectNamedPipe(hPipe, NULL);
00318
00319                                        // Create and init overlap for writing.
00320    hEventWrt = CreateEvent (NULL, TRUE, FALSE, NULL);
00321    memset (&OverLapWrt, 0, sizeof(OVERLAPPED));
00322    OverLapWrt.hEvent = hEventWrt;
00323
00324                                        // Set the clientIndex, then increment
00325                                        // the count.  Fill in the structure
00326                                        // for this client in the array.
00327    clientIndex = clientCount++;
00328    clients[clientIndex].hPipe   = hPipe;
00329    clients[clientIndex].live    = TRUE;
00330    clients[clientIndex].overLap = OverLapWrt;
00331    clients[clientIndex].hEvent  = hEventWrt;
00332
00333                                        // Create and init overlap for reading.
00334    hEventRd = CreateEvent(NULL,TRUE,FALSE,NULL);
00335    memset (&OverLapRd, 0, sizeof(OVERLAPPED));
00336    OverLapRd.hEvent = hEventRd;
00337
00338                                        // Read from the client, the first
00339                                        // first message should always be
00340                                        // the clients user name.
00341    retCode = ReadFile (hPipe, inBuf, PLEASE_READ, &bytesRead, &OverLapRd);
00342
00343    if (!retCode)
00344     lastError = GetLastError();
00345
00346    if (lastError == ERROR_IO_PENDING)  // Wait on read if need be.
00347      WaitForSingleObject (hEventRd, (DWORD)-1);
00348
00349                                        // Put client's name in the array.
00350    strcpy (clients[clientIndex].Name, inBuf);
00351
00352                                        // Create a thread which will make
00353                                        // another server instance of the
00354                                        // named pipe.
00355    hThread = CreateThread ((LPSECURITY_ATTRIBUTES)NULL,        // No security attributes.
00356                  (DWORD)0,                           // Use same stack size.
00357                  (LPTHREAD_START_ROUTINE)ServerProc, // Thread procedure.
00358                  (LPVOID)hWnd,                       // Parameter to pass.
00359                  (DWORD)0,                           // Run immediately.
00360                  (LPDWORD)&ServerThreadID);          // Thread identifier.
00361
00362    clients[clientIndex].hThread   = hThread;
00363
00364    TellAll("");                        // Forces a paint, draws a red spool
00365                                        // and name for this client.
00366
00367                                        // Do loop which basically reads from
00368                                        // this specific client, and then
00369                                        // uses TellAll() to broadcast the
00370                                        // message to all the connected
00371                                        // clients.
00372    do{
00373                                        // Read the pipe.
00374       retCode = ReadFile (hPipe, inBuf, PLEASE_READ, &bytesRead, &OverLapRd);
00375
00376                                        // Check for three kinds of errors:
00377                                        // If Error = IO_PENDING, wait til
00378                                        // the event handle signals success,
00379                                        // If BROKEN_PIPE, exit the do loop.
00380                                        // Any other error, flag it to the
00381                                        // user and exit the do loop.
00382       if (!retCode)
00383         {
00384         lastError = GetLastError();
00385
00386         switch (lastError)
00387           {
00388                                        // IO_PENDING, wait on the event.
00389            case ERROR_IO_PENDING:
00390              WaitForSingleObject (hEventRd, (DWORD)-1);
00391              break;
00392                                        // Pipe is broken, exit the loop.
00393            case ERROR_BROKEN_PIPE:
00394              ExitLoop = TRUE;
00395              break;
00396                                        // Something else is wrong, exit the
00397                                        // the loop after telling the user.
00398            default:
00399              LoadString(hInst, IDS_READERROR, lpBuffer, sizeof(lpBuffer));
00400              wsprintf (errorBuf, lpBuffer, lastError);
00401              LoadString(hInst, IDS_DEBUGINFO, lpBuffer, sizeof(lpBuffer));
00402              MessageBox (*hWnd, errorBuf, lpBuffer, MB_OK);
00403              ExitLoop = TRUE;
00404              break;
00405           }
00406         }
00407
00408       if (!ExitLoop)
00409         {
00410         GetOverlappedResult (hPipe, &OverLapRd, &bytesTransRd, FALSE);
00411
00412                                        // Use TellAll to broadcast the message.
00413         if (bytesTransRd)
00414           TellAll(inBuf);
00415         else
00416           TellAll("");
00417         }
00418
00419    }while(!ExitLoop);
00420
00421    clients[clientIndex].live = FALSE;  // Turns spool gray.
00422    CloseHandle (hPipe);                // Close handles.
00423    CloseHandle (hEventRd);
00424    CloseHandle (hEventWrt);
00425    DisconnectNamedPipe (hPipe);        // Close pipe instance.
00426    ExitThread(0);                      // Clean up and die.
00427   }
00428
00429
00430 /*************************************************************************\
00431 *
00432 *  PROCEDURE: TellAll (CHAR *buffer)
00433 *
00434 *  PURPOSE:
00435 *
00436 *    To write the buffer (input parameter) to all of the clients listed
00437 *    in the global array "clients".
00438 *
00439 *  CALLED BY:
00440 *
00441 *    ServerProc();
00442 *
00443 *  COMMENTS:
00444 *
00445 *    Clients is a global array which hold information on each client
00446 *    connected to the named pipe.  This procedure recieves a buffer.
00447 *    It then steps through this global array, and for each client it
00448 *    writes the buffer.
00449 *
00450 \*************************************************************************/
00451
00452 VOID TellAll( CHAR *buffer )
00453   {
00454     DWORD i;                           // Index through array.
00455     DWORD bytesWritten;                // Used in WriteFile().
00456     DWORD retCode;                     // Traps return codes.
00457     CHAR  Buf[LINE_LEN];               // Message Buffer.
00458     DWORD lastError;                   // Traps returns from GetLastError().
00459
00460     for(i=0; i < clientCount; i++)     // For all clients in the array.
00461       {
00462                                        // If client isn't alive, don't waste
00463                                        // time writing to it.
00464       if (clients[i].live)
00465         {
00466         retCode = WriteFile (clients[i].hPipe, buffer, (DWORD)strlen(buffer),
00467                              &bytesWritten, &clients[i].overLap);
00468
00469                                        // Check 3 kinds of errors: IO_PENDING,
00470                                        // NO_DATA, or other.  Wait on event
00471                                        // handle if IO_PENDING, else, if it's
00472                                        // anything other than NO_DATA (pipe
00473                                        // client disconnected), flag the user.
00474                                        // In any case, if it's not IO_PENDING,
00475                                        // clients[i].live = FALSE, spool turns
00476                                        // gray.
00477         if (!retCode)
00478           {
00479           lastError = GetLastError();
00480
00481                                        // IO_PENDING, wait on event handle.
00482           if (lastError == ERROR_IO_PENDING)
00483             {
00484             WaitForSingleObject (clients[i].hEvent, (DWORD)-1);
00485             }
00486           else
00487             {
00488                                        // If not NO_DATA, flag user.
00489             if (lastError != ERROR_NO_DATA)
00490               {
00491               LoadString(hInst, IDS_DEBUGLAST, lpBuffer, sizeof(lpBuffer));
00492               wsprintf (Buf, "%s = %d", buffer, GetLastError());
00493               MessageBox(hWnd, Buf, lpBuffer, MB_OK);
00494               }
00495             clients[i].live = FALSE;
00496             }
00497           }
00498         } //if client.live
00499
00500
00501         // Unused thread handles have to be cleaned up.
00502         // Otherwise, handle leakage will occur.
00503         if ((clients[i].hThread != NULL) && (clients[i].live == FALSE))
00504         {
00505           CloseHandle(clients[i].hThread);
00506           clients[i].hThread = NULL;
00507         }
00508       } // for loop
00509                                        // Paint window with new information.
00510     InvalidateRect(hWnd, NULL, TRUE);
00511   }
00512
00513
00514
00515 /*************************************************************************\
00516 *
00517 *  PROCEDURE: DrawBranch (HDC hDC)
00518 *
00519 *  PURPOSE:
00520 *
00521 *    To draw one of four bitmaps for each client, depending upon the clients
00522 *    status (alive = red spool, dead or disconnected = gray), and location in
00523 *    the array.  It also draws the clients user name beside the spool.
00524 *    This procedure is executed when the WM_PAINT message is trapped.
00525 *
00526 *  CALLED BY:
00527 *
00528 *    WinMain();
00529 *
00530 *  COMMENTS:
00531 *
00532 \*************************************************************************/
00533 VOID DrawBranch(HDC hDC)
00534 {
00535                                        // Spool bitmaps.
00536   HBITMAP hEndLive, hEndDead, hMidLive, hMidDead, hBitMap;
00537
00538   HDC hDCMem;
00539   int X, Y;
00540   BITMAP bm;
00541   POINT ptSize, ptOrg;
00542   DWORD index;
00543
00544                                        // Load bitmaps: two red (live),
00545                                        // two dead (gray).  End = end
00546                                        // of tree (last client to connect),
00547                                        // mid means in the middle somewhere.
00548        hEndLive = LoadBitmap (hInst, "EndLive");
00549        hEndDead = LoadBitmap (hInst, "EndDead");
00550
00551        hMidLive = LoadBitmap (hInst, "MidLive");
00552        hMidDead = LoadBitmap (hInst, "MidDead");
00553
00554                                        // For each client, determine if
00555                                        // if alive or not, and position;
00556                                        // then blt appropriate map and
00557                                        // clients name.
00558     for (index = 0; index < clientCount; index++)
00559       {
00560
00561       if (index < clientCount - 1)     // ClientCount - 1 = last (end) client.
00562        {
00563         if(clients[index].live)        // If live = red, else = gray.
00564          hBitMap = hMidLive;
00565         else
00566          hBitMap = hMidDead;
00567        }
00568       else
00569        {
00570         if(clients[index].live)        // If live = red, else = gray.
00571          hBitMap = hEndLive;
00572         else
00573          hBitMap = hEndDead;
00574        }
00575                                        // Calculate coordinates:
00576       X = BITMAP_X;                    // X position is constant.
00577       Y = index * BITMAP_Y;            // Y is based on index in the array.
00578
00579                                        // Blt the chosen map.
00580       hDCMem = CreateCompatibleDC(hDC);
00581       SelectObject(hDCMem, hBitMap);
00582       SetMapMode(hDCMem, GetMapMode(hDC));
00583
00584       GetObject(hBitMap, sizeof(BITMAP), &bm);
00585
00586       ptSize.x = bm.bmWidth;
00587       ptSize.y = bm.bmHeight;
00588       DPtoLP (hDC, &ptSize, 1);
00589
00590       ptOrg.x = 0;
00591       ptOrg.y = 0;
00592       DPtoLP (hDCMem, &ptOrg, 1);
00593
00594       BitBlt(hDC, X, Y, ptSize.x, ptSize.y,
00595              hDCMem, ptOrg.x, ptOrg.y, SRCCOPY);
00596
00597
00598       X =  NAME_X;                     // Relocate X,Y for clients name.
00599       Y += NAME_Y;
00600                                        // Write name next to spool.
00601       TextOut (hDC, X, Y, clients[index].Name, (int)strlen(clients[index].Name));
00602       DeleteDC(hDCMem);
00603       }
00604
00605
00606 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/DComPerm/SDMgmt.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • DComPerm

SDMgmt.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <stdio.h>
00020 #include <conio.h>
00021 #include <tchar.h>
00022 #include "ntsecapi.h"
00023 #include "dcomperm.h"
00024
00025 /*---------------------------------------------------------------------------*\
00026  * NAME: CreateNewSD
00027  * --------------------------------------------------------------------------*
00028  * DESCRIPTION: Creates a new security descriptor.
00029 \*---------------------------------------------------------------------------*/
00030 DWORD CreateNewSD (
00031     SECURITY_DESCRIPTOR **ppSecurityDesc
00032     )
00033 {
00034     PACL    pAcl          = NULL;
00035     DWORD   cbSid         = 0;
00036     PSID    pSid          = NULL;
00037     PSID    psidGroup     = NULL;
00038     PSID    psidOwner     = NULL;
00039     DWORD   dwReturnValue = ERROR_SUCCESS;
00040
00041     if(!ppSecurityDesc) return ERROR_BAD_ARGUMENTS;
00042
00043     *ppSecurityDesc = NULL;
00044
00045     dwReturnValue = GetCurrentUserSID (&pSid);
00046
00047     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00048
00049     cbSid = GetLengthSid (pSid);
00050
00051     *ppSecurityDesc = (SECURITY_DESCRIPTOR *) malloc (
00052          sizeof (ACL) +  (2 * cbSid) + sizeof (SECURITY_DESCRIPTOR));
00053
00054     if(!*ppSecurityDesc)
00055     {
00056         dwReturnValue = ERROR_OUTOFMEMORY;
00057         goto CLEANUP;
00058     }
00059
00060     psidGroup = (SID *) (*ppSecurityDesc + 1);
00061     psidOwner = (SID *) (((BYTE *) psidGroup) + cbSid);
00062     pAcl = (ACL *) (((BYTE *) psidOwner) + cbSid);
00063
00064     if (!InitializeSecurityDescriptor (*ppSecurityDesc, SECURITY_DESCRIPTOR_REVISION))
00065     {
00066         dwReturnValue = GetLastError();
00067         goto CLEANUP;
00068     }
00069
00070     if (!InitializeAcl (pAcl,
00071                         sizeof (ACL)+sizeof (ACCESS_ALLOWED_ACE)+cbSid,
00072                         ACL_REVISION2))
00073     {
00074         dwReturnValue = GetLastError();
00075         goto CLEANUP;
00076     }
00077
00078     if (!SetSecurityDescriptorDacl (*ppSecurityDesc, TRUE, pAcl, FALSE))
00079     {
00080         dwReturnValue = GetLastError();
00081         goto CLEANUP;
00082     }
00083
00084     memcpy (psidGroup, pSid, cbSid);
00085     if (!SetSecurityDescriptorGroup (*ppSecurityDesc, psidGroup, FALSE))
00086     {
00087         dwReturnValue = GetLastError();
00088         goto CLEANUP;
00089     }
00090
00091     memcpy (psidOwner, pSid, cbSid);
00092     if (!SetSecurityDescriptorOwner (*ppSecurityDesc, psidOwner, FALSE))
00093     {
00094         dwReturnValue = GetLastError();
00095         goto CLEANUP;
00096     }
00097
00098 CLEANUP:
00099
00100     if(dwReturnValue != ERROR_SUCCESS)
00101     {
00102         if(*ppSecurityDesc) free (*ppSecurityDesc);
00103     }
00104
00105     if(pSid) free (pSid);
00106
00107     return dwReturnValue;
00108 }
00109
00110 /*---------------------------------------------------------------------------*\
00111  * NAME: SetLegacyAclDefaults
00112  * --------------------------------------------------------------------------*
00113  * DESCRIPTION: Adds the default ACEs to the supplied ACL as confgured in
00114  * the legacy COM security model.
00115 \*---------------------------------------------------------------------------*/
00116 DWORD SetLegacyAclDefaults(
00117     PACL pDacl,
00118     DWORD dwSDType
00119     )
00120 {
00121     DWORD dwReturnValue = ERROR_BAD_ARGUMENTS;
00122
00123     switch (dwSDType)
00124     {
00125
00126         case SDTYPE_DEFAULT_LAUNCH:
00127         case SDTYPE_APPLICATION_LAUNCH:
00128
00129         dwReturnValue = AddAccessAllowedACEToACL (&pDacl,
00130                                                   COM_RIGHTS_EXECUTE,
00131                                                   _T("SYSTEM"));
00132
00133         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00134
00135         dwReturnValue = AddAccessAllowedACEToACL (&pDacl,
00136                                                   COM_RIGHTS_EXECUTE,
00137                                                   _T("Administrators"));
00138
00139         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00140
00141         dwReturnValue = AddAccessAllowedACEToACL (&pDacl,
00142                                                   COM_RIGHTS_EXECUTE,
00143                                                   _T("Interactive"));
00144         break;
00145
00146         case SDTYPE_DEFAULT_ACCESS:
00147         case SDTYPE_APPLICATION_ACCESS:
00148
00149         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00150
00151         dwReturnValue = AddAccessAllowedACEToACL (&pDacl,
00152                                                   COM_RIGHTS_EXECUTE,
00153                                                   _T("SYSTEM"));
00154
00155         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00156
00157         dwReturnValue = AddAccessAllowedACEToACL (&pDacl,
00158                                                   COM_RIGHTS_EXECUTE,
00159                                                   _T("SELF"));
00160         break;
00161
00162         default:
00163
00164             _tprintf(_T("WARNING: SetLegacyAclDefaults- Invalid security descriptor type.\n"));
00165
00166         break;
00167
00168     }
00169
00170 CLEANUP:
00171
00172     return dwReturnValue;
00173 }
00174
00175
00176 /*---------------------------------------------------------------------------*\
00177  * NAME: SetAclDefaults
00178  * --------------------------------------------------------------------------*
00179  * DESCRIPTION: Sets the default ACEs in a ACL for the enhanced COM
00180  * security model.
00181 \*---------------------------------------------------------------------------*/
00182 DWORD SetAclDefaults(
00183     PACL *ppDacl,
00184     DWORD dwSDType
00185     )
00186 {
00187     DWORD dwReturnValue = ERROR_BAD_ARGUMENTS;
00188
00189     switch (dwSDType)
00190     {
00191
00192         case SDTYPE_MACHINE_LAUNCH:
00193
00194         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00195                                                   COM_RIGHTS_ACTIVATE_REMOTE |
00196                                                   COM_RIGHTS_EXECUTE_REMOTE |
00197                                                   COM_RIGHTS_ACTIVATE_LOCAL |
00198                                                   COM_RIGHTS_EXECUTE_LOCAL |
00199                                                   COM_RIGHTS_EXECUTE,
00200                                                   _T("Administrators"));
00201
00202         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00203
00204         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00205                                                   COM_RIGHTS_ACTIVATE_REMOTE |
00206                                                   COM_RIGHTS_EXECUTE_REMOTE |
00207                                                   COM_RIGHTS_ACTIVATE_LOCAL |
00208                                                   COM_RIGHTS_EXECUTE_LOCAL |
00209                                                   COM_RIGHTS_EXECUTE,
00210                                                   _T("Offer Remote Assistance Helpers"));
00211
00212         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00213
00214         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00215                                                   COM_RIGHTS_ACTIVATE_LOCAL |
00216                                                   COM_RIGHTS_EXECUTE_LOCAL |
00217                                                   COM_RIGHTS_EXECUTE,
00218                                                   _T("Everyone"));
00219
00220         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00221
00222         break;
00223
00224         case SDTYPE_MACHINE_ACCESS:
00225
00226         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00227                                                   COM_RIGHTS_EXECUTE_REMOTE |
00228                                                   COM_RIGHTS_EXECUTE_LOCAL |
00229                                                   COM_RIGHTS_EXECUTE,
00230                                                   _T("Everyone"));
00231
00232         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00233
00234         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00235                                                   COM_RIGHTS_EXECUTE_LOCAL |
00236                                                   COM_RIGHTS_EXECUTE,
00237                                                   _T("Everyone"));
00238
00239
00240         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00241
00242         break;
00243
00244         case SDTYPE_DEFAULT_LAUNCH:
00245         case SDTYPE_APPLICATION_LAUNCH:
00246
00247         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00248                                                   COM_RIGHTS_ACTIVATE_REMOTE |
00249                                                   COM_RIGHTS_EXECUTE_REMOTE |
00250                                                   COM_RIGHTS_ACTIVATE_LOCAL |
00251                                                   COM_RIGHTS_EXECUTE_LOCAL |
00252                                                   COM_RIGHTS_EXECUTE,
00253                                                   _T("SYSTEM"));
00254
00255         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00256
00257         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00258                                                   COM_RIGHTS_ACTIVATE_REMOTE |
00259                                                   COM_RIGHTS_EXECUTE_REMOTE |
00260                                                   COM_RIGHTS_ACTIVATE_LOCAL |
00261                                                   COM_RIGHTS_EXECUTE_LOCAL |
00262                                                   COM_RIGHTS_EXECUTE,
00263                                                   _T("Administrators"));
00264
00265         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00266
00267         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00268                                                   COM_RIGHTS_ACTIVATE_REMOTE |
00269                                                   COM_RIGHTS_EXECUTE_REMOTE |
00270                                                   COM_RIGHTS_ACTIVATE_LOCAL |
00271                                                   COM_RIGHTS_EXECUTE_LOCAL |
00272                                                   COM_RIGHTS_EXECUTE,
00273                                                   _T("Interactive"));
00274
00275         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00276
00277         break;
00278
00279         case SDTYPE_DEFAULT_ACCESS:
00280         case SDTYPE_APPLICATION_ACCESS:
00281
00282
00283         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00284                                                   COM_RIGHTS_EXECUTE_LOCAL |
00285                                                   COM_RIGHTS_EXECUTE,
00286                                                   _T("SYSTEM"));
00287
00288         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00289
00290         dwReturnValue = AddAccessAllowedACEToACL (ppDacl,
00291                                                   COM_RIGHTS_EXECUTE_REMOTE |
00292                                                   COM_RIGHTS_EXECUTE_LOCAL |
00293                                                   COM_RIGHTS_EXECUTE,
00294                                                   _T("SELF"));
00295
00296         if(dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00297
00298         break;
00299
00300         default:
00301
00302             _tprintf(_T("WARNING: SetAclDefaults- Invalid security descriptor type.\n"));
00303
00304         break;
00305
00306     }
00307
00308 CLEANUP:
00309
00310     return dwReturnValue;
00311 }
00312
00313
00314 /*---------------------------------------------------------------------------*\
00315  * NAME: MakeSDAbsolute
00316  * --------------------------------------------------------------------------*
00317  * DESCRIPTION: Takes a self-relative security descriptor and returns a
00318  * newly created absolute security descriptor.
00319 \*---------------------------------------------------------------------------*/
00320 DWORD MakeSDAbsolute (
00321     PSECURITY_DESCRIPTOR psidOld,
00322     PSECURITY_DESCRIPTOR *psidNew
00323     )
00324 {
00325     PSECURITY_DESCRIPTOR  pSid           = NULL;
00326     DWORD                 cbDescriptor   = 0;
00327     DWORD                 cbDacl         = 0;
00328     DWORD                 cbSacl         = 0;
00329     DWORD                 cbOwnerSID     = 0;
00330     DWORD                 cbGroupSID     = 0;
00331     PACL                  pDacl          = NULL;
00332     PACL                  pSacl          = NULL;
00333     PSID                  psidOwner      = NULL;
00334     PSID                  psidGroup      = NULL;
00335     BOOL                  fPresent       = FALSE;
00336     BOOL                  fSystemDefault = FALSE;
00337     DWORD                 dwReturnValue  = ERROR_SUCCESS;
00338
00339     // Get SACL
00340     if (!GetSecurityDescriptorSacl (psidOld, &fPresent, &pSacl, &fSystemDefault))
00341     {
00342         dwReturnValue = GetLastError();
00343         goto CLEANUP;
00344     }
00345
00346     if (pSacl && fPresent)
00347     {
00348         cbSacl = pSacl->AclSize;
00349     }
00350
00351     // Get DACL
00352     if (!GetSecurityDescriptorDacl (psidOld, &fPresent, &pDacl, &fSystemDefault))
00353     {
00354         dwReturnValue = GetLastError();
00355         goto CLEANUP;
00356     }
00357
00358     if (pDacl && fPresent)
00359     {
00360         cbDacl = pDacl->AclSize;
00361     }
00362
00363     // Get Owner
00364     if (!GetSecurityDescriptorOwner (psidOld, &psidOwner, &fSystemDefault))
00365     {
00366         dwReturnValue = GetLastError();
00367         goto CLEANUP;
00368     }
00369
00370     cbOwnerSID = GetLengthSid (psidOwner);
00371
00372     // Get Group
00373     if (!GetSecurityDescriptorGroup (psidOld, &psidGroup, &fSystemDefault))
00374     {
00375         dwReturnValue = GetLastError();
00376         goto CLEANUP;
00377     }
00378
00379     cbGroupSID = GetLengthSid (psidGroup);
00380
00381     // Do the conversion
00382     cbDescriptor = 0;
00383
00384     MakeAbsoluteSD (psidOld, pSid, &cbDescriptor, pDacl, &cbDacl, pSacl,
00385                     &cbSacl, psidOwner, &cbOwnerSID, psidGroup,
00386                     &cbGroupSID);
00387
00388     pSid = (PSECURITY_DESCRIPTOR) malloc(cbDescriptor);
00389     if(!pSid)
00390     {
00391         dwReturnValue = ERROR_OUTOFMEMORY;
00392         goto CLEANUP;
00393     }
00394
00395     ZeroMemory(pSid, cbDescriptor);
00396
00397     if (!InitializeSecurityDescriptor (pSid, SECURITY_DESCRIPTOR_REVISION))
00398     {
00399         dwReturnValue = GetLastError();
00400         goto CLEANUP;
00401     }
00402
00403     if (!MakeAbsoluteSD (psidOld, pSid, &cbDescriptor, pDacl, &cbDacl, pSacl,
00404                          &cbSacl, psidOwner, &cbOwnerSID, psidGroup,
00405                          &cbGroupSID))
00406     {
00407         dwReturnValue = GetLastError();
00408         goto CLEANUP;
00409     }
00410
00411 CLEANUP:
00412
00413     if(dwReturnValue != ERROR_SUCCESS && pSid)
00414     {
00415         free(pSid);
00416         pSid = NULL;
00417     }
00418
00419     *psidNew = pSid;
00420
00421     return dwReturnValue;
00422 }
00423
00424 /*---------------------------------------------------------------------------*\
00425  * NAME: SetNamedValueSD
00426  * --------------------------------------------------------------------------*
00427  * DESCRIPTION: Copies the supplied security descriptor to the registry.
00428 \*---------------------------------------------------------------------------*/
00429 DWORD SetNamedValueSD (
00430     HKEY hkeyRoot,
00431     LPTSTR tszKeyName,
00432     LPTSTR tszValueName,
00433     SECURITY_DESCRIPTOR *pSecurityDesc
00434     )
00435 {
00436     DWORD   dwReturnValue = ERROR_SUCCESS;
00437     DWORD   dwDisposition = 0;
00438     HKEY    hkeyReg       = NULL;
00439
00440     // Create new key or open existing key
00441     dwReturnValue = RegCreateKeyEx (hkeyRoot, tszKeyName, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hkeyReg, &dwDisposition);
00442     if (dwReturnValue != ERROR_SUCCESS)
00443     {
00444         goto CLEANUP;
00445     }
00446
00447     // Write the security descriptor
00448     dwReturnValue = RegSetValueEx (hkeyReg, tszValueName, 0, REG_BINARY, (LPBYTE) pSecurityDesc, GetSecurityDescriptorLength (pSecurityDesc));
00449     if (dwReturnValue != ERROR_SUCCESS)
00450     {
00451         goto CLEANUP;
00452     }
00453
00454 CLEANUP:
00455
00456     if(hkeyReg) RegCloseKey (hkeyReg);
00457
00458     return dwReturnValue;
00459 }
00460
00461 /*---------------------------------------------------------------------------*\
00462  * NAME: GetNamedValueSD
00463  * --------------------------------------------------------------------------*
00464  * DESCRIPTION: Retrieves a designated security descriptor from the
00465  * registry.
00466 \*---------------------------------------------------------------------------*/
00467 DWORD GetNamedValueSD (
00468     HKEY hkeyRoot,
00469     LPTSTR tszKeyName,
00470     LPTSTR tszValueName,
00471     SECURITY_DESCRIPTOR **ppSecurityDesc,
00472     BOOL *psdNew
00473     )
00474 {
00475     DWORD  dwReturnValue = ERROR_SUCCESS;
00476     HKEY   hkeyReg       = NULL;
00477     DWORD  dwType        = 0;
00478     DWORD  cbSize        = 0;
00479
00480     if(!ppSecurityDesc) return ERROR_BAD_ARGUMENTS;
00481
00482     if(psdNew) *psdNew = FALSE;
00483     *ppSecurityDesc = NULL;
00484
00485     // Get the security descriptor from the named value. If it doesn't
00486     // exist, create a fresh one.
00487     dwReturnValue = RegOpenKeyEx (hkeyRoot, tszKeyName, 0, KEY_ALL_ACCESS, &hkeyReg);
00488
00489     if (dwReturnValue != ERROR_SUCCESS)
00490     {
00491         if(dwReturnValue == ERROR_FILE_NOT_FOUND)
00492         {
00493             goto CLEANUP;
00494         }
00495
00496         return dwReturnValue;
00497     }
00498
00499     dwReturnValue = RegQueryValueEx (hkeyReg, tszValueName, NULL, &dwType, NULL, &cbSize);
00500
00501     if (dwReturnValue != ERROR_SUCCESS && dwReturnValue != ERROR_INSUFFICIENT_BUFFER)
00502     {
00503         goto CLEANUP;
00504     }
00505
00506     *ppSecurityDesc = (SECURITY_DESCRIPTOR *) malloc (cbSize);
00507
00508     dwReturnValue = RegQueryValueEx (hkeyReg, tszValueName, NULL, &dwType, (LPBYTE) *ppSecurityDesc, &cbSize);
00509
00510
00511 CLEANUP:
00512
00513     if(dwReturnValue != ERROR_SUCCESS)
00514     {
00515         if(*ppSecurityDesc) free(*ppSecurityDesc);
00516
00517         *ppSecurityDesc = NULL;
00518
00519         if(psdNew)
00520         {
00521             dwReturnValue = CreateNewSD (ppSecurityDesc);
00522             if (dwReturnValue == ERROR_SUCCESS)
00523             {
00524                 *psdNew = TRUE;
00525             }
00526         }
00527     }
00528
00529     if(hkeyReg) RegCloseKey (hkeyReg);
00530
00531     return dwReturnValue;
00532 }
00533
00534 /*---------------------------------------------------------------------------*\
00535  * NAME: ListNamedValueSD
00536  * --------------------------------------------------------------------------*
00537  * DESCRIPTION: Displays the designated security descriptor.
00538 \*---------------------------------------------------------------------------*/
00539 DWORD ListNamedValueSD (
00540     HKEY hkeyRoot,
00541     LPTSTR tszKeyName,
00542     LPTSTR tszValueName,
00543     DWORD dwSDType
00544     )
00545 {
00546     DWORD               dwReturnValue = ERROR_SUCCESS;
00547     SECURITY_DESCRIPTOR *pSD          = NULL;
00548     BOOL                fPresent      = FALSE;
00549     BOOL                fDefaultDACL  = FALSE;
00550     PACL                dacl          = NULL;
00551
00552     dwReturnValue = GetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, &pSD, NULL);
00553
00554     if (dwReturnValue != ERROR_SUCCESS)
00555     {
00556         _tprintf (_T("<Using Default Permissions>\n"));
00557         goto CLEANUP;
00558     }
00559
00560     if (!GetSecurityDescriptorDacl (pSD, &fPresent, &dacl, &fDefaultDACL))
00561     {
00562         dwReturnValue = GetLastError();
00563         goto CLEANUP;
00564     }
00565
00566     if (!fPresent)
00567     {
00568         _tprintf (_T("<Access is denied to everyone>\n"));
00569         goto CLEANUP;
00570     }
00571
00572     ListACL (dacl, dwSDType);
00573
00574 CLEANUP:
00575
00576     if(pSD) free (pSD);
00577
00578     return dwReturnValue;
00579 }
00580
00581 /*---------------------------------------------------------------------------*\
00582  * NAME: AddPrincipalToNamedValueSD
00583  * --------------------------------------------------------------------------*
00584  * DESCRIPTION: Retrieves the designated security descriptor from the
00585  * registry and adds an ACE for the designated principal.
00586 \*---------------------------------------------------------------------------*/
00587 DWORD AddPrincipalToNamedValueSD (
00588     HKEY hkeyRoot,
00589     LPTSTR tszKeyName,
00590     LPTSTR tszValueName,
00591     LPTSTR tszPrincipal,
00592     BOOL fPermit,
00593     DWORD dwAccessMask,
00594     DWORD dwSDType
00595     )
00596 {
00597     DWORD               dwReturnValue    = ERROR_SUCCESS;
00598     SECURITY_DESCRIPTOR *pSD             = NULL;
00599     SECURITY_DESCRIPTOR *psdSelfRelative = NULL;
00600     SECURITY_DESCRIPTOR *psdAbsolute     = NULL;
00601     DWORD               cbSecurityDesc   = 0;
00602     BOOL                fPresent         = FALSE;
00603     BOOL                fDefaultDACL     = FALSE;
00604     PACL                pDacl            = NULL;
00605     BOOL                fNewSD           = FALSE;
00606
00607     dwReturnValue = GetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, &pSD, &fNewSD);
00608
00609     // Get security descriptor from registry or create a new one
00610     if (dwReturnValue != ERROR_SUCCESS)  goto CLEANUP;
00611
00612     if (!GetSecurityDescriptorDacl (pSD, &fPresent, &pDacl, &fDefaultDACL))
00613     {
00614         dwReturnValue = GetLastError();
00615         goto CLEANUP;
00616     }
00617
00618     if (fNewSD)
00619     {
00620         dwReturnValue = SetAclDefaults(&pDacl, dwSDType);
00621         if (dwReturnValue != ERROR_SUCCESS)  goto CLEANUP;
00622     }
00623
00624     // Add the tszPrincipal that the caller wants added
00625     if (fPermit)
00626     {
00627         dwReturnValue = AddAccessAllowedACEToACL (&pDacl, dwAccessMask, tszPrincipal);
00628     }
00629     else
00630     {
00631         dwReturnValue = AddAccessDeniedACEToACL (&pDacl, dwAccessMask, tszPrincipal);
00632     }
00633
00634     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00635
00636     // Make the security descriptor absolute if it isn't new
00637     if (!fNewSD)
00638     {
00639         dwReturnValue = MakeSDAbsolute ((PSECURITY_DESCRIPTOR) pSD, (PSECURITY_DESCRIPTOR *) &psdAbsolute);
00640         if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00641     }
00642     else
00643     {
00644         psdAbsolute = pSD;
00645     }
00646
00647     // Set the discretionary ACL on the security descriptor
00648     if (!SetSecurityDescriptorDacl (psdAbsolute, TRUE, pDacl, FALSE))
00649     {
00650         dwReturnValue = GetLastError();
00651         goto CLEANUP;
00652      }
00653
00654     // Make the security descriptor self-relative so that we can
00655     // store it in the registry
00656     cbSecurityDesc = 0;
00657
00658     MakeSelfRelativeSD (psdAbsolute, psdSelfRelative, &cbSecurityDesc);
00659
00660     psdSelfRelative = (SECURITY_DESCRIPTOR *) malloc (cbSecurityDesc);
00661
00662     if(!psdSelfRelative)
00663     {
00664         dwReturnValue = ERROR_OUTOFMEMORY;
00665         goto CLEANUP;
00666     }
00667
00668     if (!MakeSelfRelativeSD (psdAbsolute, psdSelfRelative, &cbSecurityDesc))
00669     {
00670         dwReturnValue = GetLastError();
00671         goto CLEANUP;
00672     }
00673
00674     // Store the security descriptor in the registry
00675     SetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, psdSelfRelative);
00676
00677 CLEANUP:
00678
00679     if(pSD) free (pSD);
00680     if(psdSelfRelative) free (psdSelfRelative);
00681     if(psdAbsolute && pSD != psdAbsolute) free (psdAbsolute);
00682
00683     return dwReturnValue;
00684 }
00685
00686
00687 /*---------------------------------------------------------------------------*\
00688  * NAME: UpdatePrincipalInNamedValueSD
00689  * --------------------------------------------------------------------------*
00690  * DESCRIPTION: Retrieves the designated security descriptor from the
00691  * registry and updates all ACLs that belong to the named principal.
00692 \*---------------------------------------------------------------------------*/
00693 DWORD UpdatePrincipalInNamedValueSD (
00694     HKEY hkeyRoot,
00695     LPTSTR tszKeyName,
00696     LPTSTR tszValueName,
00697     LPTSTR tszPrincipal,
00698     DWORD dwAccessMask,
00699     BOOL fRemove,
00700     DWORD fAceType
00701     )
00702 {
00703     DWORD               dwReturnValue    = ERROR_SUCCESS;
00704     SECURITY_DESCRIPTOR *pSD             = NULL;
00705     SECURITY_DESCRIPTOR *psdSelfRelative = NULL;
00706     SECURITY_DESCRIPTOR *psdAbsolute     = NULL;
00707     DWORD               cbSecurityDesc   = 0;
00708     BOOL                fPresent         = FALSE;
00709     BOOL                fDefaultDACL     = FALSE;
00710     PACL                pDacl            = NULL;
00711
00712
00713     // Get security descriptor from registry
00714     dwReturnValue = GetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, &pSD, NULL);
00715
00716
00717     if (dwReturnValue != ERROR_SUCCESS)
00718     {
00719         if(dwReturnValue == ERROR_FILE_NOT_FOUND && fRemove)
00720         {
00721             dwReturnValue = ERROR_SUCCESS;
00722         }
00723         goto CLEANUP;
00724     }
00725
00726     if (!GetSecurityDescriptorDacl (pSD, &fPresent, &pDacl, &fDefaultDACL))
00727     {
00728         dwReturnValue = GetLastError();
00729         goto CLEANUP;
00730     }
00731
00732     // Update the tszPrincipal that the caller wants to change
00733     dwReturnValue = UpdatePrincipalInACL (pDacl, tszPrincipal, dwAccessMask, fRemove, fAceType);
00734     if(dwReturnValue == ERROR_FILE_NOT_FOUND)
00735     {
00736         dwReturnValue = ERROR_SUCCESS;
00737         goto CLEANUP;
00738     }
00739     else if (dwReturnValue != ERROR_SUCCESS)
00740     {
00741         dwReturnValue = GetLastError();
00742         goto CLEANUP;
00743     }
00744
00745     // Make the security descriptor absolute
00746     dwReturnValue = MakeSDAbsolute ((PSECURITY_DESCRIPTOR) pSD, (PSECURITY_DESCRIPTOR *) &psdAbsolute);
00747     if (dwReturnValue != ERROR_SUCCESS)  goto CLEANUP;
00748
00749
00750     // Set the discretionary ACL on the security descriptor
00751     if (!SetSecurityDescriptorDacl (psdAbsolute, TRUE, pDacl, FALSE))
00752     {
00753         dwReturnValue = GetLastError();
00754         goto CLEANUP;
00755     }
00756
00757     // Make the security descriptor self-relative so that we can
00758     // store it in the registry
00759     cbSecurityDesc = 0;
00760     MakeSelfRelativeSD (psdAbsolute, psdSelfRelative, &cbSecurityDesc);
00761
00762     psdSelfRelative = (SECURITY_DESCRIPTOR *) malloc (cbSecurityDesc);
00763
00764
00765     if (!MakeSelfRelativeSD (psdAbsolute, psdSelfRelative, &cbSecurityDesc))
00766     {
00767         dwReturnValue = GetLastError();
00768         goto CLEANUP;
00769     }
00770
00771     // Store the security descriptor in the registry
00772     dwReturnValue = SetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, psdSelfRelative);
00773
00774 CLEANUP:
00775
00776     if(pSD) free (pSD);
00777     if(psdSelfRelative) free (psdSelfRelative);
00778     if(psdAbsolute) free (psdAbsolute);
00779
00780     return dwReturnValue;
00781 }
00782
00783 /*---------------------------------------------------------------------------*\
00784  * NAME: RemovePrincipalFromNamedValueSD
00785  * --------------------------------------------------------------------------*
00786  * DESCRIPTION: Retrieves the designated security descriptor from the
00787  * registry and removes all ACLs that belong to the named principal.
00788 \*---------------------------------------------------------------------------*/
00789 DWORD RemovePrincipalFromNamedValueSD (
00790     HKEY hkeyRoot,
00791     LPTSTR tszKeyName,
00792     LPTSTR tszValueName,
00793     LPTSTR tszPrincipal,
00794     DWORD fAceType
00795     )
00796 {
00797     DWORD               dwReturnValue    = ERROR_SUCCESS;
00798     SECURITY_DESCRIPTOR *pSD             = NULL;
00799     SECURITY_DESCRIPTOR *psdSelfRelative = NULL;
00800     SECURITY_DESCRIPTOR *psdAbsolute     = NULL;
00801     DWORD               cbSecurityDesc   = 0;
00802     BOOL                fPresent         = FALSE;
00803     BOOL                fDefaultDACL     = FALSE;
00804     PACL                pDacl            = NULL;
00805
00806     dwReturnValue = GetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, &pSD, NULL);
00807
00808     // Get security descriptor from registry or create a new one
00809     if (dwReturnValue != ERROR_SUCCESS)
00810     {
00811         if(dwReturnValue == ERROR_FILE_NOT_FOUND)
00812         {
00813             dwReturnValue = ERROR_SUCCESS;
00814         }
00815         goto CLEANUP;
00816     }
00817
00818     if (!GetSecurityDescriptorDacl (pSD, &fPresent, &pDacl, &fDefaultDACL))
00819     {
00820         dwReturnValue = GetLastError();
00821         goto CLEANUP;
00822     }
00823
00824     // Remove the tszPrincipal that the caller wants removed
00825     dwReturnValue = RemovePrincipalFromACL (pDacl, tszPrincipal, fAceType);
00826     if(dwReturnValue == ERROR_FILE_NOT_FOUND)
00827     {
00828         dwReturnValue = ERROR_SUCCESS;
00829         goto CLEANUP;
00830     }
00831     else if (dwReturnValue != ERROR_SUCCESS)
00832     {
00833         dwReturnValue = GetLastError();
00834         goto CLEANUP;
00835     }
00836
00837     // Make the security descriptor absolute if it isn't new
00838     dwReturnValue = MakeSDAbsolute ((PSECURITY_DESCRIPTOR) pSD, (PSECURITY_DESCRIPTOR *) &psdAbsolute);
00839     if (dwReturnValue != ERROR_SUCCESS)  goto CLEANUP;
00840
00841     // Set the discretionary ACL on the security descriptor
00842     if (!SetSecurityDescriptorDacl (psdAbsolute, TRUE, pDacl, FALSE))
00843     {
00844         dwReturnValue = GetLastError();
00845         goto CLEANUP;
00846     }
00847
00848     // Make the security descriptor self-relative so that we can
00849     // store it in the registry
00850     cbSecurityDesc = 0;
00851     MakeSelfRelativeSD (psdAbsolute, psdSelfRelative, &cbSecurityDesc);
00852
00853     psdSelfRelative = (SECURITY_DESCRIPTOR *) malloc (cbSecurityDesc);
00854
00855
00856     if (!MakeSelfRelativeSD (psdAbsolute, psdSelfRelative, &cbSecurityDesc))
00857     {
00858         dwReturnValue = GetLastError();
00859         goto CLEANUP;
00860     }
00861
00862     // Store the security descriptor in the registry
00863     dwReturnValue = SetNamedValueSD (hkeyRoot, tszKeyName, tszValueName, psdSelfRelative);
00864
00865 CLEANUP:
00866
00867     if(pSD) free (pSD);
00868     if(psdSelfRelative) free (psdSelfRelative);
00869     if(psdAbsolute) free (psdAbsolute);
00870
00871     return dwReturnValue;
00872 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/BrowserHost.cpp Source File

  • Web
  • Browser
  • EditHost

BrowserHost.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // BrowserHost.cpp : Implementation of CBrowserHost
00006 #include "stdafx.h"
00007 #include "EdHost.h"
00008 #include "BrowserHost.h"
00009 #include "exdispid.h"
00010 #include "mshtmdid.h"
00011 #include "mshtmhst.h"
00012 #include "mshtmcid.h"
00013 #include "Snap.h"
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // BrowserHost
00017
00018 CBrowserHost::CBrowserHost() :
00019   m_bEnableCtxMenus(TRUE),
00020   m_dwDLControl(DLCTL_DLIMAGES|DLCTL_VIDEOS|DLCTL_BGSOUNDS),
00021   m_dwCookie((DWORD)0),
00022   m_dwDocHostUIFlags((DWORD)0),
00023   m_dwDocHostUIDblClk((DWORD)0),
00024   m_bInPlaceActive(FALSE),
00025   m_bAtlBrowserHelp(TRUE),
00026   m_wndUrlCombo(_T("ComboBox"), this, 1),
00027   m_wndIncrementCombo(_T("ComboBox"), this, 1),
00028   m_bButton2Down(FALSE),
00029   m_bButton3Down(FALSE),
00030   m_bButton4Down(FALSE),
00031   m_bButton5Down(FALSE),
00032   m_lGridCookie(NULL),
00033   m_lSnapIncrement(50)
00034 {
00035 }
00036
00037 LRESULT CBrowserHost::OnCreate(UINT, WPARAM, LPARAM, BOOL&) {return 0;}
00038
00039 LRESULT CBrowserHost::OnNCDestroy(UINT, WPARAM, LPARAM, BOOL&)
00040 {
00041   Stop();
00042   return 0;
00043 }
00044
00045 LRESULT CBrowserHost::OnKeydown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00046 {
00047   USES_CONVERSION;
00048
00049   // Deal with return key events
00050   if (wParam == VK_RETURN)
00051   {
00052     // Stop any previous navigations
00053     m_spWebBrowser->Stop();
00054
00055     CComBSTR bstrURL, bstrOldURL, bstrIncrement;
00056     CComVariant vtEmpty;
00057
00058     // CODE REVIEW: Add following security comment.
00059     /* The following use of GetWindowText is simplified for illustrative
00060     purposes. This simplified use in production code can expose a
00061     security risk in some situations. In production code you might want
00062     to ensure that the receiving buffer size isn't exceeded by the size
00063     of the source string. */
00064     // Get text in Url address box and the
00065     // URL of current page for comparison
00066     m_wndUrlCombo.GetWindowText(bstrURL.m_str);
00067     m_spWebBrowser->get_LocationURL(&bstrOldURL);
00068
00069     // Convert to char string for comparison
00070     LPSTR tURL = OLE2A(bstrURL);
00071     LPSTR tOldURL = OLE2A(bstrOldURL);
00072
00073     if (strcmp(tURL,tOldURL)) // strcmp returns 0 if they're the same
00074     {
00075       // string in URL box is new, so navigate to new page and return
00076
00077       // First remove grid behavior if there is one
00078       if (m_lGridCookie)
00079       {
00080         IHTMLElement* pBody = NULL;
00081         IHTMLElement2* pBody2;
00082         VARIANT_BOOL dummy;
00083
00084         // Get IHTMLElement and IHTMLElement2 interfaces for the body
00085         m_spDoc->get_body(&pBody);
00086         pBody->QueryInterface(IID_IHTMLElement2, (void**)&pBody2);
00087         pBody2->removeBehavior(m_lGridCookie, &dummy);
00088         m_lGridCookie = NULL;
00089         m_spGrid = (IGrid*)NULL;
00090
00091         pBody->Release();
00092         pBody2->Release();
00093       }
00094
00095       m_spWebBrowser->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);
00096
00097       // Turn off snap and grid buttons because IHTMLEditHost and the
00098       // rendering behavior are re-initialized when a navigation happens
00099       m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON2, MAKELONG(FALSE, 0));
00100       m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON3, MAKELONG(FALSE, 0));
00101       m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON4, MAKELONG(FALSE, 0));
00102       m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON5, MAKELONG(FALSE, 0));
00103       m_bButton2Down = FALSE;
00104       m_bButton4Down = FALSE;
00105       m_bButton5Down = FALSE;
00106
00107       bHandled = TRUE;
00108       return 0;
00109     }
00110
00111     // CODE REVIEW: Add following security comment.
00112     /* The following use of GetWindowText is simplified for illustrative
00113     purposes. This simplified use in production code can expose a
00114     security risk in some situations. In production code you might want
00115     to ensure that the receiving buffer size isn't exceeded by the size
00116     of the source string. */
00117     // Get text in increment box and convert to char string
00118     m_wndIncrementCombo.GetWindowText((BSTR&)bstrIncrement);
00119     LPSTR tIncrement = OLE2A(bstrIncrement);
00120
00121     // convert new increment to number and
00122     // compare to current increment
00123     long lNewInc = _wtol(bstrIncrement);
00124     if (lNewInc != m_lSnapIncrement && lNewInc > 0)
00125     {
00126       // increment is new, so change to it and return
00127       m_lSnapIncrement = lNewInc;
00128
00129       if (m_spGrid)
00130         m_spGrid->put_GridSize(m_lSnapIncrement);
00131
00132       if (m_spSnap)
00133         m_spSnap->put_SnapIncrement(m_lSnapIncrement);
00134
00135       bHandled = TRUE;
00136       return S_OK;
00137     }
00138     else
00139     {
00140       // increment is either the same as old one or invalid,
00141       // so change increment box value back to old one
00142       TCHAR oldInc;
00143       // convert number to string
00144       _ltot(m_lSnapIncrement, &oldInc, 10);
00145       m_wndIncrementCombo.SetWindowText(&oldInc);
00146     }
00147   }
00148
00149   // Deal with tab and delete key events
00150   // Check for doc first
00151   if (m_spDoc)
00152   {
00153     // Determine current designMode
00154     CComBSTR bstrMode;
00155     m_spDoc->get_designMode(&bstrMode);
00156     char* cMode = OLE2A(bstrMode);
00157
00158     // Handle tab when design mode is off
00159     if ((strcmp(cMode, "On") && wParam == VK_TAB) || wParam == VK_RETURN)
00160     {
00161       // Pass user interface control to the WebBrowser when
00162       // the tab key is pressed (that is, UIActivate it)
00163       // This lets the WebBrowser change focus between the
00164       // various controls on the page when the tab key is pressed
00165       CComQIPtr<IOleObject, &IID_IOleObject> spOleObject(m_spWebBrowser);
00166
00167       RECT rect;
00168       GetClientRect(&rect);
00169       spOleObject->DoVerb(OLEIVERB_UIACTIVATE, NULL, this, 0, m_hWnd, &rect);
00170     }
00171
00172     // When designMode is on, disable tab and handle delete
00173     // (it requires special handling to work correctly)
00174     if ((!strcmp(cMode, "On") && wParam == VK_DELETE) ||
00175       (strcmp(cMode, "On") && wParam == VK_TAB) ||
00176       (wParam == VK_RETURN))
00177     {
00178       // Call TranslateAccelerator on the in-place active
00179       // object for the delete key so that the accelerator will be passed to the
00180       // hosted WebBrowser control.  This forces the delete key to
00181       // work correctly in design mode.
00182       CComQIPtr<IOleInPlaceActiveObject,
00183           &IID_IOleInPlaceActiveObject> spInPlaceActiveObject(m_spWebBrowser);
00184
00185       MSG msg;
00186       msg.message = uMsg;
00187       msg.wParam = wParam;
00188       msg.lParam = lParam;
00189
00190       spInPlaceActiveObject->TranslateAccelerator(&msg);
00191     }
00192
00193   }
00194
00195   bHandled = FALSE;
00196
00197   return 0;
00198 }
00199
00200
00201 LRESULT CBrowserHost::OnButton1(WORD, WORD, HWND, BOOL&)
00202 {
00203   _ASSERT(m_spWebBrowser);
00204
00205   if (!m_spDoc)
00206   {
00207      MessageBox(_T("Document object no available."));
00208      return 0;
00209   }
00210
00211   USES_CONVERSION; // Needed for the OLE2A conversion macro
00212   BSTR bstrMode;
00213
00214   m_spDoc->get_designMode(&bstrMode);
00215   char* cMode = OLE2A(bstrMode);
00216
00217   if (strcmp(cMode, "On"))
00218   {
00219     m_spDoc->put_designMode(L"On");
00220     m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON1, MAKELONG(TRUE, 0));
00221     m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON2, MAKELONG(TRUE, 0));
00222     m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON4, MAKELONG(TRUE, 0));
00223     m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON5, MAKELONG(TRUE, 0));
00224
00225   }
00226   else
00227   {
00228     m_spDoc->put_designMode(L"Off");
00229     m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON1, MAKELONG(FALSE, 0));
00230     m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON2, MAKELONG(FALSE, 0));
00231     m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON4, MAKELONG(FALSE, 0));
00232     m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON5, MAKELONG(FALSE, 0));
00233     m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON2, MAKELONG(FALSE, 0));
00234     m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON4, MAKELONG(FALSE, 0));
00235     m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON5, MAKELONG(FALSE, 0));
00236     m_bButton2Down = FALSE;
00237     m_bButton4Down = FALSE;
00238     m_bButton5Down = FALSE;
00239
00240   }
00241
00242   return 1;
00243 }
00244
00245 LRESULT CBrowserHost::OnButton2(WORD, WORD, HWND, BOOL&)
00246 {
00247   if (!m_spSnap) return 0;
00248
00249   m_bButton2Down = !m_bButton2Down;
00250
00251   m_spSnap->put_SnapOn(m_bButton2Down);
00252   m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON2, MAKELONG(m_bButton2Down, 0));
00253
00254   return 0;
00255 }
00256
00257 LRESULT CBrowserHost::OnButton3(WORD, WORD, HWND, BOOL&)
00258 {
00259   HRESULT hr;
00260
00261   IHTMLElement* pBody = NULL;
00262   IHTMLElement2* pBody2;
00263   IElementBehaviorFactory* pGridFactory;
00264     VARIANT vFactory;
00265
00266   // Get IHTMLElement and IHTMLElement2 interfaces for the body
00267   hr = m_spDoc->get_body(&pBody);
00268   hr = pBody->QueryInterface(IID_IHTMLElement2, (void**)&pBody2);
00269
00270   if (m_lGridCookie)
00271   {
00272     VARIANT_BOOL dummy;
00273     hr = pBody2->removeBehavior(m_lGridCookie, &dummy);
00274     m_lGridCookie = NULL;
00275     m_spGrid = (IGrid*)NULL;
00276     LRESULT lr = m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON3, MAKELONG(FALSE, 0));
00277
00278     return 1;
00279   }
00280
00281   // Get the behavior factory interface for
00282   // the grid rendering behavior
00283   hr = CoCreateInstance(CLSID_Grid, NULL, CLSCTX_INPROC_SERVER, IID_IElementBehaviorFactory, (void**)&pGridFactory);
00284
00285   // Convert pGridFactory to the proper VARIANT data type
00286   // for IHTMLElement2::AddBehavior
00287   V_VT(&vFactory) = VT_UNKNOWN;
00288     V_UNKNOWN(&vFactory) = pGridFactory;
00289
00290   // AddRef because we've copied the pGridFactory pointer
00291     V_UNKNOWN(&vFactory)->AddRef();
00292
00293   // Add Grid behavior
00294   hr = pBody2->addBehavior(NULL, &vFactory, &m_lGridCookie);
00295   m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON3, MAKELONG(TRUE, 0));
00296
00297   // cache a pointer the the IGrid interface and set the gridsize
00298   hr = pGridFactory->QueryInterface(IID_IGrid, (void**)&m_spGrid);
00299   hr = m_spGrid->put_GridSize(m_lSnapIncrement);
00300
00301   // Release resources
00302   hr = pBody->Release();
00303   hr = pBody2->Release();
00304   hr = pGridFactory->Release();
00305
00306   return 0;
00307 }
00308
00309 LRESULT CBrowserHost::OnButton4(WORD, WORD, HWND, BOOL&)
00310 {
00311   m_bButton4Down = !m_bButton4Down;
00312
00313   VARIANT var;
00314   V_VT(&var) = VT_BOOL;
00315
00316   if (m_bButton4Down)
00317       V_BOOL(&var) = VARIANT_TRUE;
00318   else
00319     V_BOOL(&var) = VARIANT_FALSE;
00320
00321   // Turn on 2D positioning
00322   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00323              IDM_2D_POSITION,
00324              MSOCMDEXECOPT_DODEFAULT,
00325              &var,
00326              NULL);
00327
00328   m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON4, MAKELONG(m_bButton4Down, 0));
00329
00330   return 0;
00331 }
00332
00333 LRESULT CBrowserHost::OnButton5(WORD, WORD, HWND, BOOL&)
00334 {
00335   m_bButton5Down = !m_bButton5Down;
00336
00337   VARIANT var;
00338   V_VT(&var) = VT_BOOL;
00339
00340   if (m_bButton5Down)
00341       V_BOOL(&var) = VARIANT_TRUE;
00342   else
00343     V_BOOL(&var) = VARIANT_FALSE;
00344
00345   // Turn on LiveResizing
00346   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00347              IDM_LIVERESIZE,
00348              MSOCMDEXECOPT_DODEFAULT,
00349              &var,
00350              NULL);
00351
00352   m_wndToolBar.SendMessage(TB_PRESSBUTTON, ID_BUTTON5, MAKELONG(m_bButton5Down, 0));
00353
00354   return 0;
00355 }
00356
00357 STDMETHODIMP CBrowserHost::Run()
00358 {
00359   // Create and show the window
00360   RECT rcClient = { CW_USEDEFAULT, 0, 0, 0 };
00361
00362   Create(GetDesktopWindow(), rcClient, _T("IHTMLEditHost Sample App"), WS_VISIBLE | WS_OVERLAPPEDWINDOW,
00363        0, NULL);
00364   ShowWindow(SW_SHOWNORMAL);
00365
00366   // Create the toolbar
00367   CreateToolbar();
00368
00369   // Create the status bar
00370   m_wndStatusBar.Attach(CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CCS_BOTTOM,
00371                               _T("Ready"), m_hWnd, 2));
00372   _ASSERT(m_wndStatusBar);
00373
00374   // Create the WebBrowser control
00375   CComPtr<IOleObject> spOleObject;
00376   HRESULT hr = CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IOleObject,
00377                       (void**)&spOleObject);
00378   if (hr != S_OK)
00379   {
00380     MessageBox(_T("CoCreateInstance failed"));
00381     return E_FAIL;
00382   }
00383
00384   if (spOleObject->SetClientSite(this) != S_OK)
00385   {
00386     MessageBox(_T("SetClientSite failed"));
00387     return E_FAIL;
00388   }
00389
00390   // In-place activate the WebBrower control
00391   MSG msg;
00392   GetClientRect(&rcClient);
00393
00394   hr = spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, m_hWnd, &rcClient);
00395   if (hr != S_OK)
00396   {
00397     MessageBox(_T("DoVerb failed"));
00398     return E_FAIL;
00399   }
00400
00401   // Get the pointer to the WebBrowser control.  Note that setting a CComQIPtr
00402   // equal to a pointer of another type causes CComQIPtr to call QueryInterface.
00403   m_spWebBrowser = spOleObject;
00404   _ASSERT(m_spWebBrowser);
00405
00406   if (!m_spWebBrowser)
00407     return E_FAIL;
00408
00409   // Set up the connection to the WebBrowser control to receive events
00410   hr = AtlAdvise(m_spWebBrowser, GetUnknown(), DIID_DWebBrowserEvents2, &m_dwCookie);
00411   if (FAILED(hr))
00412     ATLTRACE(_T("Failed to Advise\n"));
00413
00414   // Get the size of the status bar
00415   RECT rcWindow;
00416   m_wndStatusBar.GetWindowRect(&rcWindow);
00417
00418   // Resize the control to accomodate the status bar and toolbar
00419   rcClient.bottom -= (rcWindow.bottom - rcWindow.top);
00420
00421   m_wndToolBar.GetWindowRect(&rcWindow);
00422   rcClient.top += (rcWindow.bottom - rcWindow.top);
00423
00424   // QI for the in-place object to set the size
00425   m_spInPlaceObject = m_spWebBrowser;
00426   _ASSERT(m_spInPlaceObject);
00427
00428   if (m_spInPlaceObject)
00429     m_spInPlaceObject->SetObjectRects(&rcClient, &rcClient);
00430
00431   // QI for the IOleCommandTarget interface that will be used later
00432   m_spOleCmdTarg = m_spWebBrowser;
00433   _ASSERT(m_spOleCmdTarg);
00434
00435   // Load Test Page
00436   m_spWebBrowser->Navigate(L"res://edhost.exe/test.html", NULL, NULL, NULL, NULL);
00437
00438   return S_OK;
00439 }
00440
00441 STDMETHODIMP CBrowserHost::Stop()
00442 {
00443   _ASSERT(m_spWebBrowser);
00444
00445   HRESULT hr = AtlUnadvise(m_spWebBrowser, DIID_DWebBrowserEvents2, m_dwCookie);
00446
00447   if (FAILED(hr))
00448     ATLTRACE("Failed to Unadvise\n");
00449
00450   PostQuitMessage(0);
00451
00452   return S_OK;
00453 }
00454
00455 LRESULT CBrowserHost::OnSize(UINT, WPARAM, LPARAM lParam, BOOL&)
00456 {
00457   RECT rcWindow;
00458
00459   // Resize the status bar
00460   if (m_wndStatusBar)
00461   {
00462     int cxParent = LOWORD(lParam);
00463     int cyParent = HIWORD(lParam);
00464     int x = 0, y, cx, cy;
00465
00466     // Keep the status bar height the same.
00467     m_wndStatusBar.GetWindowRect(&rcWindow);
00468     cy = rcWindow.bottom - rcWindow.top;
00469
00470     y = cyParent - cy;
00471     cx = cxParent;
00472     m_wndStatusBar.MoveWindow(x, y, cx, cy, TRUE);
00473   }
00474
00475   // Tell the toolbar to resize itself
00476   if (m_wndToolBar)
00477     m_wndToolBar.SendMessage(TB_AUTOSIZE, 0, 0L);
00478
00479   // Resize the control
00480   if (m_spWebBrowser && m_bInPlaceActive)
00481   {
00482     RECT rcClient;
00483     GetClientRect(&rcClient);
00484
00485     // Resize the control to accomodate the status bar and toolbar
00486     rcClient.bottom -= (rcWindow.bottom - rcWindow.top);
00487
00488     m_wndToolBar.GetWindowRect(&rcWindow);
00489     rcClient.top += (rcWindow.bottom - rcWindow.top);
00490
00491     if (m_spInPlaceObject)
00492       m_spInPlaceObject->SetObjectRects(&rcClient, &rcClient);
00493   }
00494
00495   return 0;
00496 }
00497
00498 // IDispatch Methods
00499 STDMETHODIMP CBrowserHost::Invoke(DISPID dispidMember, REFIID riid,
00500                      LCID lcid, WORD wFlags,
00501                      DISPPARAMS* pDispParams,
00502                      VARIANT* pvarResult, EXCEPINFO*  pExcepInfo,
00503                      UINT* puArgErr)
00504 {
00505   USES_CONVERSION;
00506
00507   switch (dispidMember)
00508   {
00509     case DISPID_DOCUMENTCOMPLETE:
00510       {
00511       IDispatch* pDisp;
00512       m_spDoc = (IHTMLDocument2*)NULL;
00513       m_spWebBrowser->get_Document(&pDisp);
00514       pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&m_spDoc);
00515
00516       pDisp->Release();
00517       break;
00518       }
00519
00520     case DISPID_DOWNLOADCOMPLETE:
00521       // Set the text of the combobox to the current URL
00522       BSTR bstrURL;
00523
00524       m_spWebBrowser->get_LocationURL(&bstrURL);
00525       m_wndUrlCombo.SetWindowText(OLE2T(bstrURL));
00526
00527       break;
00528
00529     case DISPID_STATUSTEXTCHANGE:
00530       m_wndStatusBar.SetWindowText(OLE2T(pDispParams->rgvarg[0].bstrVal));
00531       break;
00532
00533     default:
00534       return DISP_E_MEMBERNOTFOUND;
00535   }
00536
00537   return S_OK;
00538 }
00539
00540 void CBrowserHost::CreateToolbar()
00541 {
00542   TBBUTTON tbb[] =
00543   {
00544     // Add separators to make room for the combo box.
00545     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00546     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00547     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00548     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00549     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00550     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00551     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00552     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00553     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00554     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00555     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00556     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00557     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00558     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00559     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00560     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00561     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00562     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00563     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00564     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00565     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00566     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00567     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00568     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00569     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00570     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00571     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00572     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00573     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00574     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00575     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00576     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00577     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00578     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00579     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00580     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00581     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00582     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00583     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00584     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00585
00586     0, ID_BUTTON1, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0,
00587     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00588     1, ID_BUTTON2, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0,
00589     2, ID_BUTTON3, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0,
00590
00591     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00592     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00593     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00594     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00595     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00596     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00597     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00598     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00599     0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0,
00600
00601     3, ID_BUTTON4, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0,
00602     4, ID_BUTTON5, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0,
00603   };
00604
00605   HWND toolbar = CreateToolbarEx(m_hWnd,
00606                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CCS_TOP | TBSTYLE_TOOLTIPS,
00607                    ID_TOOLBARWND,
00608                    4,
00609                    _Module.GetResourceInstance(),
00610                    IDR_TOOLBAR1,
00611                    tbb, 55,
00612                    0, 0,
00613                    55, 30,
00614                    sizeof(TBBUTTON));
00615
00616   m_wndToolBar.Attach(toolbar);
00617   _ASSERT(m_wndToolBar);
00618
00619   // Tell the toolbar to resize itself
00620   m_wndToolBar.SendMessage(TB_AUTOSIZE, 0, 0L);
00621
00622   m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON2, MAKELONG(FALSE, 0));
00623   //m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON3, MAKELONG(TRUE, 0));
00624   m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON4, MAKELONG(FALSE, 0));
00625   m_wndToolBar.SendMessage(TB_ENABLEBUTTON, ID_BUTTON5, MAKELONG(FALSE, 0));
00626
00627   // Create the combo box on the toolbar
00628   RECT rc, rc2, rc3, rc4;
00629
00630   // Calculate the coordinates for the combo box.
00631   m_wndToolBar.SendMessage(TB_GETITEMRECT, (WPARAM)0, (LPARAM)(LPRECT)&rc);
00632   m_wndToolBar.SendMessage(TB_GETITEMRECT, (WPARAM)38, (LPARAM)(LPRECT)&rc2);
00633   m_wndToolBar.SendMessage(TB_GETITEMRECT, (WPARAM)45, (LPARAM)(LPRECT)&rc3);
00634   m_wndToolBar.SendMessage(TB_GETITEMRECT, (WPARAM)48, (LPARAM)(LPRECT)&rc4);
00635
00636   rc.right = rc2.right;
00637   rc3.right = rc4.right;
00638   rc.top = rc.top + 5;
00639   rc3.top = rc3.top + 5;
00640   rc.bottom = rc.top + 20;
00641   rc3.bottom = rc3.top + 20;
00642
00643   m_wndUrlCombo.Create(m_wndToolBar, rc, NULL, WS_CHILD|WS_VISIBLE,
00644                 0, ID_URLBOX);
00645   m_wndIncrementCombo.Create(m_wndToolBar, rc3, NULL, WS_CHILD|WS_VISIBLE,
00646                 0, ID_SNAPINCBOX);
00647
00648   TCHAR tcharInc;
00649   _ltot(m_lSnapIncrement, &tcharInc, 10);
00650   m_wndIncrementCombo.SetWindowText(&tcharInc);
00651
00652
00653
00654 }
00655
00656
00657 STDMETHODIMP CBrowserHost::GetHwnd(long* phwnd)
00658 {
00659   *phwnd = (long)m_hWnd;
00660    return S_OK;
00661 }
00662
00663 // IServiceProvider
00664 STDMETHODIMP CBrowserHost::QueryService(REFGUID guidService,
00665                     REFIID riid,
00666                     void **ppv)
00667 {
00668     HRESULT hr = E_NOINTERFACE;
00669
00670     if (guidService == SID_SHTMLEditHost && riid == IID_IHTMLEditHost)
00671     {
00672     // Create new CSnap object
00673         CComObject<CSnap>* pSnap;
00674         hr = CComObject<CSnap>::CreateInstance(&pSnap);
00675
00676     // Query the new CSnap object for IHTMLEditHost interface
00677         hr = pSnap->QueryInterface(IID_IHTMLEditHost, ppv);
00678
00679         // Cache a pointer to ISnap so we can tell the Snap behavior
00680         // when to snap
00681         m_spSnap = (ISnap*)NULL; // Clear any previous pointers
00682         hr = pSnap->QueryInterface(IID_ISnap, (void**)&m_spSnap);
00683
00684     // Set the snap increment
00685         hr = pSnap->put_SnapIncrement(m_lSnapIncrement);
00686     }
00687
00688     return hr;
00689 }
00690
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/HtmlIFlt.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

HtmlIFlt.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       htmliflt.hxx
00006 //
00007 //  Contents:   Html IFilter
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #if !defined( __HTMLIFLT_HXX__ )
00012 #define __HTMLIFLT_HXX__
00013
00014 extern "C" GUID CLSID_HtmlIFilter;
00015
00016 //
00017 // Standard Ole exports
00018 //
00019
00020 extern "C" SCODE STDMETHODCALLTYPE DllGetClassObject( REFCLSID   cid,
00021                                                       REFIID     iid,
00022                                                       void **    ppvObj );
00023
00024 extern "C" SCODE STDMETHODCALLTYPE DllCanUnloadNow( void );
00025
00026 //+-------------------------------------------------------------------------
00027 //
00028 //  Class:      CHtmlIFilterBase
00029 //
00030 //  Purpose:    Manage aggregation, refcounting for CHtmlIFilter
00031 //
00032 //--------------------------------------------------------------------------
00033
00034 class CHtmlIFilterBase : public IFilter, public IPersistFile
00035 {
00036 public:
00037
00038     //
00039     // From IUnknown
00040     //
00041
00042     virtual  SCODE STDMETHODCALLTYPE  QueryInterface(REFIID riid, void  * * ppvObject);
00043
00044     virtual  ULONG STDMETHODCALLTYPE  AddRef();
00045
00046     virtual  ULONG STDMETHODCALLTYPE  Release();
00047
00048     //
00049     // From IFilter
00050     //
00051
00052     virtual  SCODE STDMETHODCALLTYPE  Init( ULONG grfFlags,
00053                                             ULONG cAttributes,
00054                                             FULLPROPSPEC const * aAttributes,
00055                                             ULONG * pFlags ) = 0;
00056
00057     virtual  SCODE STDMETHODCALLTYPE  GetChunk( STAT_CHUNK * pStat) = 0;
00058
00059     virtual  SCODE STDMETHODCALLTYPE  GetText( ULONG * pcwcBuffer,
00060                                                WCHAR * awcBuffer ) = 0;
00061
00062     virtual  SCODE STDMETHODCALLTYPE  GetValue( PROPVARIANT * * ppPropValue ) = 0;
00063
00064     virtual  SCODE STDMETHODCALLTYPE  BindRegion( FILTERREGION origPos,
00065                                                   REFIID riid,
00066                                                   void ** ppunk) = 0;
00067
00068     //
00069     // From IPersistFile
00070     //
00071
00072     virtual  SCODE STDMETHODCALLTYPE  GetClassID( CLSID * pClassID ) = 0;
00073
00074     virtual  SCODE STDMETHODCALLTYPE  IsDirty() = 0;
00075
00076     virtual  SCODE STDMETHODCALLTYPE  Load( LPCWSTR pszFileName,
00077                                             DWORD dwMode) = 0;
00078
00079     virtual  SCODE STDMETHODCALLTYPE  Save( LPCWSTR pszFileName,
00080                                             BOOL fRemember ) = 0;
00081
00082     virtual  SCODE STDMETHODCALLTYPE  SaveCompleted( LPCWSTR pszFileName ) = 0;
00083
00084     virtual  SCODE STDMETHODCALLTYPE  GetCurFile( LPWSTR  * ppszFileName ) = 0;
00085
00086 protected:
00087
00088             CHtmlIFilterBase();
00089     virtual ~CHtmlIFilterBase();
00090
00091     long _uRefs;
00092 };
00093
00094 //+-------------------------------------------------------------------------
00095 //
00096 //  Class:      CHtmlIFilterCF
00097 //
00098 //  Purpose:    Class factory for Html filter class
00099 //
00100 //--------------------------------------------------------------------------
00101
00102 class CHtmlIFilterCF : public IClassFactory
00103 {
00104 public:
00105
00106     CHtmlIFilterCF();
00107
00108     virtual  SCODE STDMETHODCALLTYPE  QueryInterface( REFIID riid,
00109                                                       void  ** ppvObject);
00110
00111     virtual  ULONG STDMETHODCALLTYPE  AddRef();
00112
00113     virtual  ULONG STDMETHODCALLTYPE  Release();
00114
00115     virtual  SCODE STDMETHODCALLTYPE  CreateInstance( IUnknown * pUnkOuter,
00116                                                       REFIID riid, void  * * ppvObject );
00117
00118     virtual  SCODE STDMETHODCALLTYPE  LockServer( BOOL fLock );
00119
00120 protected:
00121
00122     friend SCODE STDMETHODCALLTYPE DllGetClassObject( REFCLSID cid,
00123                                                       REFIID iid, void** ppvObj );
00124     virtual ~CHtmlIFilterCF();
00125
00126     long _uRefs;
00127 };
00128
00129
00130 #endif // __HTMLIFLT_HXX__
00131
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_Parameter Member List

This is the complete list of members for msado15::_Parameter, including all inherited members.
AppendChunk(Variant Val) | msado15::_Parameter |
getAttributes() | msado15::_Parameter |
getDirection() | msado15::_Parameter |
getName() | msado15::_Parameter |
getNumericScale() | msado15::_Parameter |
getPrecision() | msado15::_Parameter |
getProperties() | msado15::_Parameter |
getSize() | msado15::_Parameter |
getType() | msado15::_Parameter |
getValue() | msado15::_Parameter |
iid | msado15::_Parameter | [static]
setAttributes(int plParmAttribs) | msado15::_Parameter |
setDirection(int plParmDirection) | msado15::_Parameter |
setName(String pbstr) | msado15::_Parameter |
setNumericScale(byte pbScale) | msado15::_Parameter |
setPrecision(byte pbPrecision) | msado15::_Parameter |
setSize(int pl) | msado15::_Parameter |
setType(int psDataType) | msado15::_Parameter |
setValue(Variant pvar) | msado15::_Parameter |
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ADOConnectionConstruction Member List

This is the complete list of members for msado15::ADOConnectionConstruction, including all inherited members.
getDSO() | msado15::ADOConnectionConstruction |
getSession() | msado15::ADOConnectionConstruction |
iid | msado15::ADOConnectionConstruction | [static]
WrapDSOandSession(IUnknown pDSO, IUnknown pSession) | msado15::ADOConnectionConstruction |
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/CallBackClient/stdafx.h Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • CallBackClient

stdafx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: StdAfx.h
00004 ----------------------------------------------------------------------------
00005
00006 This file is part of the Microsoft COM+ Samples.
00007
00008 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00009
00010 This source code is intended only as a supplement to Microsoft
00011 Development Tools and/or on-line documentation. See these other
00012 materials for detailed information regarding Microsoft code samples.
00013
00014 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 PARTICULAR PURPOSE.
00018
00019 ==========================================================================+*/
00020 // stdafx.h : include file for standard system include files,
00021 //  or project specific include files that are used frequently, but
00022 //      are changed infrequently
00023 //
00024
00025 #if !defined(AFX_STDAFX_H__9B43635A_18ED_470D_9F2F_DF666428E129__INCLUDED_)
00026 #define AFX_STDAFX_H__9B43635A_18ED_470D_9F2F_DF666428E129__INCLUDED_
00027
00028 #if _MSC_VER > 1000
00029 #pragma once
00030 #endif // _MSC_VER > 1000
00031
00032 #define STRICT
00033 #ifndef _WIN32_WINNT
00034 #define _WIN32_WINNT 0x0500
00035 #endif
00036 #define _ATL_APARTMENT_THREADED
00037
00038 #include <atlbase.h>
00039 class CExeModule : public CComModule
00040 {
00041 public:
00042   LONG Unlock();
00043   DWORD dwThreadID;
00044   HANDLE hEventShutdown;
00045   void MonitorShutdown();
00046   bool StartMonitor();
00047   bool bActivity;
00048 };
00049 extern CExeModule _Module;
00050 #include <atlcom.h>
00051
00052 #include <stdio.h>
00053
00054 // TODO: reference additional headers your program requires here
00055
00056 //{{AFX_INSERT_LOCATION}}
00057 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00058
00059 #endif // !defined(AFX_STDAFX_H__9B43635A_18ED_470D_9F2F_DF666428E129__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTxSub Member List

This is the complete list of members for CTxSub, including all inherited members.
CSysLCESub() | CSysLCESub | [inline]
CTxSub(CComSpy *pSpy) | CTxSub | [inline]
CTxSub() | CTxSub | [inline]
GetEventClass(LPGUID guid) | CTxSub | [inline, virtual]
GetEventType(EventEnum *e) | CTxSub | [inline, virtual]
GetInterface(IID *iid) | CTxSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnTransactionAbort(COMSVCSEVENTINFO *pInfo, REFGUID guidTx) | CTxSub |
OnTransactionCommit(COMSVCSEVENTINFO *pInfo, REFGUID guidTx) | CTxSub |
OnTransactionPrepare(COMSVCSEVENTINFO *pInfo, REFGUID guidTx, BOOL bVoteYes) | CTxSub |
OnTransactionStart(COMSVCSEVENTINFO *pInfo, REFGUID guidTx, REFGUID tsid, BOOL bRoot) | CTxSub |
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:57:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/version.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

version.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module version include file
00008 //
00009 //
00010
00011 // Constants -----------------------------------------------------------------
00012 #ifndef _AXVER_H_
00013 #define _AXVER_H_
00014
00015 // Constants ------------------------------------------------------------------
00016
00017 #define VER_FILEVERSION 2,70,7531.0
00018 #define VER_FILEVERSION_STR "2.70.7531.0\0"
00019 #define VER_PRODUCTVERSION 2,70,7531.0
00020 #define VER_PRODUCTVERSION_STR "2.70.7531.0\0"
00021
00022 #define VER_FILEFLAGSMASK   (VS_FF_DEBUG | VS_FF_PRERELEASE)
00023 #ifdef DEBUG
00024 #define VER_FILEFLAGS     (VS_FF_DEBUG)
00025 #else
00026 #define VER_FILEFLAGS     (0)
00027 #endif //DEBUG
00028
00029 #define VER_FILEOS        VOS_NT_WINDOWS32
00030
00031 #define VER_COMPANYNAME_STR   "Microsoft Corporation\0"
00032 #define VER_PRODUCTNAME_STR   "Microsoft OLE DB\0"
00033 #define VER_LEGALCOPYRIGHT_STR  "Copyright \251 Microsoft Corporation 1994-1999\0"
00034
00035 // Resource DLL Version Resource ID
00036 #define IDS_RESDLL_VER      1
00037
00038 #endif //_AXVER_H_
00039 //--------------------
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/guidbind/vc/ADSIhelpers.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • guidbind
  • vc

ADSIhelpers.cpp

Go to the documentation of this file.
00001 /*
00002
00003     ADSIHelpers.CPP
00004
00005     General helper rountines for Debugging ADSI applications
00006
00007
00008 */
00009
00010 #define INC_OLE2
00011 #define UNICODE 1
00012 #define _WIN32_DCOM
00013
00014 // If defined, will throw a WCHAR * on an error
00015 // in AdsMsagBox()
00016 //#define THROW_CHARPTR_ONERROR
00017
00018 #include "ADSIhelpers.h"
00019
00020
00021
00022 #include <windows.h>
00023 #include <OBJIDL.H>
00024 #include <OAIDL.H>
00025 #include <COMCAT.H>
00026 #include <DOCOBJ.H>
00027 #include <HLINK.H>
00028 #include <MTX.H>
00029 #include <MTXSPM.H>
00030 #include <stdio.h>
00031 #include <string.h>
00032 #include <stdio.h>
00033 #include <string.h>
00034 #include <assert.h>
00035
00036 //////////////////////////////////////////////
00037 //  Debugging Functions
00038
00039
00040
00041 // Will display a message box for a BAD Hresult.
00042 // Will do nothing for a S_OK HRESULT
00043 // Pass in the HRESULT to be tested and a char * describing the
00044 // area in the code
00045 void CheckHRESULT(HRESULT hr, const char *pszCause)
00046 {
00047     if (FAILED(hr))
00048     {
00049         char sz[1024];
00050         char szCaption[1024];
00051         strcpy(szCaption, pszCause);
00052         strcat(szCaption, " failed!");
00053         if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, sz, 1024, 0))
00054             strcpy(sz, "Unknown error");
00055         MessageBoxA(0, sz, szCaption, MB_SETFOREGROUND);
00056        // DebugBreak();
00057     }
00058 }
00059
00060
00061 // When passed a VARIANT vt member, will return a string describing
00062 // all the bitmask settings...
00063 const char * GetVariantStyle(VARTYPE vt)
00064 {
00065   static char pRet[200];
00066
00067   pRet[0] = NULL;
00068
00069   if (vt == VT_EMPTY) strcat(pRet,"VT_EMPTY ");
00070
00071   if (HAS_BIT_STYLE(vt, VT_BYREF)) strcat(pRet,"VT_BYREF ");
00072   if (HAS_BIT_STYLE(vt, VT_UI1)) strcat(pRet,"VT_UI1 ");
00073   if (HAS_BIT_STYLE(vt, VT_I2)) strcat(pRet,"VT_I2 ");
00074   if (HAS_BIT_STYLE(vt, VT_I4)) strcat(pRet,"VT_I4 ");
00075   if (HAS_BIT_STYLE(vt, VT_R4)) strcat(pRet,"VT_R4 ");
00076   if (HAS_BIT_STYLE(vt, VT_R8)) strcat(pRet,"VT_R8 ");
00077   if (HAS_BIT_STYLE(vt, VT_CY)) strcat(pRet,"VT_CY ");
00078   if (HAS_BIT_STYLE(vt, VT_BSTR)) strcat(pRet,"VT_BSTR ");
00079   if (HAS_BIT_STYLE(vt, VT_NULL)) strcat(pRet,"VT_NULL ");
00080   if (HAS_BIT_STYLE(vt, VT_ERROR)) strcat(pRet,"VT_ERROR ");
00081   if (HAS_BIT_STYLE(vt, VT_BOOL)) strcat(pRet,"VT_BOOL ");
00082   if (HAS_BIT_STYLE(vt, VT_DATE)) strcat(pRet,"VT_DATE ");
00083   if (HAS_BIT_STYLE(vt, VT_DISPATCH)) strcat(pRet,"VT_DISPATCH ");
00084   if (HAS_BIT_STYLE(vt, VT_VARIANT)) strcat(pRet,"VT_VARIANT ");
00085   if (HAS_BIT_STYLE(vt, VT_UNKNOWN)) strcat(pRet,"VT_UNKNOWN ");
00086   if (HAS_BIT_STYLE(vt, VT_ARRAY)) strcat(pRet,"VT_ARRAY ");
00087
00088   return pRet;
00089 }
00090
00091 // Pass in the interface ptr to the property value
00092 // will return a BSTR value of the data.
00093 // The IADsPropertyValue::get_ADsType()  is called to retrieve the
00094 // ADSTYPE valued enum
00095 // This enum is then used to determine which IADsPropertyValue method
00096 // to call to receive the actual data
00097
00098 // CALLER assumes responsibility for freeing returned BSTR
00099 HRESULT GetIADsPropertyValueAsBSTR(BSTR * pbsRet,IADsPropertyValue * pAdsPV)
00100 {
00101   HRESULT hr = S_OK;
00102
00103   long lAdsType;
00104   hr = pAdsPV->get_ADsType(&lAdsType);
00105
00106   if (FAILED(hr))
00107     return hr;
00108
00109   switch (lAdsType)
00110   {
00111     case ADSTYPE_INVALID :
00112     {
00113       *pbsRet = SysAllocString(L"<ADSTYPE_INVALID>");
00114     }
00115     break;
00116
00117     case ADSTYPE_DN_STRING :
00118     {
00119       hr = pAdsPV->get_DNString(pbsRet);
00120     }
00121     break;
00122     case ADSTYPE_CASE_EXACT_STRING :
00123     {
00124       hr = pAdsPV->get_CaseExactString(pbsRet);
00125     }
00126     break;
00127     case ADSTYPE_CASE_IGNORE_STRING :
00128     {
00129       hr = pAdsPV->get_CaseIgnoreString(pbsRet);
00130     }
00131     break;
00132     case ADSTYPE_PRINTABLE_STRING :
00133     {
00134       hr = pAdsPV->get_PrintableString(pbsRet);
00135     }
00136     break;
00137     case ADSTYPE_NUMERIC_STRING :
00138     {
00139       hr = pAdsPV->get_NumericString(pbsRet);
00140     }
00141     break;
00142     case ADSTYPE_BOOLEAN :
00143     {
00144       long b;
00145       hr = pAdsPV->get_Boolean(&b);
00146       if (SUCCEEDED(hr))
00147       {
00148         if (b)
00149           *pbsRet = SysAllocString(L"<TRUE>");
00150         else
00151           *pbsRet = SysAllocString(L"<FALSE>");
00152       }
00153     }
00154     break;
00155     case ADSTYPE_INTEGER :
00156     {
00157       long lInt;
00158       hr = pAdsPV->get_Integer(&lInt);
00159       if (SUCCEEDED(hr))
00160       {
00161         WCHAR wOut[100];
00162         wsprintf(wOut,L"%d",lInt);
00163         *pbsRet = SysAllocString(wOut);
00164       }
00165     }
00166     break;
00167     case ADSTYPE_OCTET_STRING :
00168     {
00169       *pbsRet = SysAllocString(L"<ADSTYPE_LARGE_INTEGER>");
00170       //  hr = pAdsPV->get_OctetString(pbsRet);
00171     }
00172     break;
00173     case ADSTYPE_UTC_TIME :
00174     {
00175       DATE daUTCTime;
00176       WCHAR wDateOut[255];
00177       hr = pAdsPV->get_UTCTime(&daUTCTime);
00178
00179       if (SUCCEEDED(hr))
00180       {
00181       /*  wsprintf(wDateout,L"%02d/%02d/%04d %02d:%02d:%02d",
00182           pValues->UTCTime.wMonth, pValues->UTCTime.wDay, pValues->UTCTime.wYear,
00183           pValues->UTCTime.wHour, pValues->UTCTime.wMinute, pValues->UTCTime.wSecond );
00184       */
00185         *pbsRet = SysAllocString(wDateOut);
00186       }
00187     }
00188     break;
00189     case ADSTYPE_LARGE_INTEGER :
00190     {
00191       *pbsRet = SysAllocString(L"<ADSTYPE_LARGE_INTEGER>");
00192     }
00193     break;
00194     case ADSTYPE_PROV_SPECIFIC :
00195     {
00196       *pbsRet = SysAllocString(L"<ADSTYPE_PROV_SPECIFIC>");
00197     }
00198     break;
00199     case ADSTYPE_OBJECT_CLASS :
00200     {
00201       *pbsRet = SysAllocString(L"<ADSTYPE_OBJECT_CLASS>");
00202     }
00203     break;
00204     case ADSTYPE_PATH :
00205     {
00206       *pbsRet = SysAllocString(L"<ADSTYPE_PATH>");
00207     }
00208     break;
00209     case ADSTYPE_NT_SECURITY_DESCRIPTOR :
00210     {
00211       *pbsRet = SysAllocString(L"<ADSTYPE_NT_SECURITY_DESCRIPTOR>");
00212     }
00213     break;
00214
00215     default:
00216       *pbsRet = SysAllocString(L"<UNRECOGNIZED>");
00217     break;
00218
00219   }
00220   return hr;
00221 }
00222
00223 // Displays a Messagebox with a BAD Hresult
00224 // Supports standard system COM errors
00225 // And Active Directory Errors
00226 void ADErrMsgBox(HRESULT passedhr)
00227 {
00228
00229     if (SUCCEEDED(passedhr))
00230         return;
00231
00232     HRESULT hr;
00233     DWORD lError;
00234     WCHAR pwErrBuff[2048];
00235     WCHAR pwADErrBuff[512];
00236
00237     WCHAR * pADErrCodeStr;
00238
00239     pwErrBuff[0] = NULL;
00240     pADErrCodeStr = CrackADError( passedhr);
00241
00242     // If an ADSI error code was returned, display it
00243     if (pADErrCodeStr[0] != NULL)
00244     {
00245         wcscat(pwErrBuff,L"\t<*> ADSI Error HRESULT Returns: <*> \n");
00246         wcscat(pwErrBuff,pADErrCodeStr);
00247         wcscat(pwErrBuff,L"\n");
00248     }
00249
00250     // Call ADsGetLastError() to retrieve the error text from ADSI
00251     wcscat(pwErrBuff,L"\t<*> ADSI Error: <*>\n");
00252
00253     hr = ADsGetLastError(
00254         &lError,
00255         pwADErrBuff,
00256         2047,
00257         L"",
00258         0
00259         );
00260
00261
00262     if (FAILED(hr))
00263         wcscat(pwErrBuff,L"<Unable to retrieve ADs Error>");
00264     else
00265         wcscat(pwErrBuff,pwADErrBuff);
00266
00267     wcscat(pwErrBuff,L"\n");
00268
00269     WCHAR sz[1024];
00270
00271     wcscat(pwErrBuff,L"\t<*> System Error: <*> \n");
00272
00273     // Check the standard system to crack the bad HRESULT into a string
00274     if (!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, passedhr, 0, sz, 1024, 0))
00275         wcscat(sz, L"Unknown HRESULT error");
00276     else
00277         wcscat(pwErrBuff, sz);
00278
00279     // Display
00280     OutputDebugStringW(pwErrBuff);
00281     OutputDebugStringW(L"\r\n");
00282     MessageBoxW(NULL,pwErrBuff,L"ADErrMsgBox():",MB_OK);
00283
00284     #ifdef _DEBUG
00285         DebugBreak();
00286     #endif
00287
00288     #ifdef THROW_CHARPTR_ONERROR
00289         throw pwErrBuff;
00290     #endif
00291
00292
00293 }
00294
00295
00296 WCHAR * CrackADError(HRESULT hResult)
00297 {
00298    static WCHAR szwText[ 128 ];
00299    szwText[0] = 0l;
00300
00301    switch( hResult )
00302    {
00303       case  E_ADS_BAD_PATHNAME:
00304          return L"E_ADS_BAD_PATHNAME";
00305          break;
00306
00307       case  E_ADS_INVALID_DOMAIN_OBJECT:
00308          return L"E_ADS_INVALID_DOMAIN_OBJECT";
00309          break;
00310
00311       case  E_ADS_INVALID_USER_OBJECT:
00312          return L"E_ADS_INVALID_USER_OBJECT";
00313          break;
00314
00315       case  E_ADS_INVALID_COMPUTER_OBJECT:
00316          return L"E_ADS_INVALID_COMPUTER_OBJECT";
00317          break;
00318
00319       case  E_ADS_UNKNOWN_OBJECT:
00320          return L"E_ADS_UNKNOWN_OBJECT";
00321          break;
00322
00323       case  E_ADS_PROPERTY_NOT_SET:
00324          return L"E_ADS_PROPERTY_NOT_SET";
00325          break;
00326
00327       case  E_ADS_PROPERTY_NOT_SUPPORTED:
00328          return L"E_ADS_PROPERTY_NOT_SUPPORTED";
00329          break;
00330
00331       case  E_ADS_PROPERTY_INVALID:
00332          return L"E_ADS_PROPERTY_INVALID";
00333          break;
00334
00335       case  E_ADS_BAD_PARAMETER:
00336          return L"E_ADS_BAD_PARAMETER";
00337          break;
00338
00339       case  E_ADS_OBJECT_UNBOUND:
00340          return L"E_ADS_OBJECT_UNBOUND";
00341          break;
00342
00343       case  E_ADS_PROPERTY_NOT_MODIFIED:
00344          return L"E_ADS_PROPERTY_NOT_MODIFIED";
00345          break;
00346
00347       case  E_ADS_PROPERTY_MODIFIED:
00348          return L"E_ADS_PROPERTY_MODIFIED";
00349          break;
00350
00351       case  E_ADS_CANT_CONVERT_DATATYPE:
00352          return L"E_ADS_CANT_CONVERT_DATATYPE";
00353          break;
00354
00355       case  E_ADS_PROPERTY_NOT_FOUND:
00356          return L"E_ADS_PROPERTY_NOTFOUND";
00357          break;
00358
00359       case  E_ADS_OBJECT_EXISTS:
00360          return L"E_ADS_OBJECT_EXISTS";
00361          break;
00362
00363       case  E_ADS_SCHEMA_VIOLATION:
00364          return L"E_ADS_SCHEMA_VIOLATION";
00365          break;
00366
00367       case  E_ADS_COLUMN_NOT_SET:
00368          return L"E_ADS_COLUMN_NOT_SET";
00369          break;
00370
00371       case  E_ADS_INVALID_FILTER:
00372          return L"E_ADS_INVALID_FILTER";
00373          break;
00374
00375       case  HRESULT_FROM_WIN32(ERROR_DS_OPERATIONS_ERROR):
00376          return L"ERROR_DS_OPERATIONS_ERROR";
00377          break;
00378
00379       case  HRESULT_FROM_WIN32(ERROR_DS_PROTOCOL_ERROR):
00380          return L"ERROR_DS_PROTOCOL_ERROR";
00381          break;
00382
00383       case  HRESULT_FROM_WIN32(ERROR_DS_TIMELIMIT_EXCEEDED):
00384          return L"ERROR_DS_TIMELIMIT_EXCEEDED";
00385          break;
00386
00387       case  HRESULT_FROM_WIN32(ERROR_DS_SIZELIMIT_EXCEEDED):
00388          return L"ERROR_DS_SIZELIMIT_EXCEEDED";
00389          break;
00390
00391       case  HRESULT_FROM_WIN32(ERROR_DS_COMPARE_FALSE):
00392          return L"ERROR_DS_COMPARE_FALSE";
00393          break;
00394
00395
00396       case  HRESULT_FROM_WIN32(ERROR_DS_COMPARE_TRUE):
00397          return L"ERROR_DS_COMPARE_TRUE";
00398          break;
00399
00400       case  HRESULT_FROM_WIN32(ERROR_DS_AUTH_METHOD_NOT_SUPPORTED):
00401          return L"ERROR_DS_AUTH_METHOD_NOT_SUPPORTED";
00402          break;
00403
00404
00405       case  HRESULT_FROM_WIN32(ERROR_DS_STRONG_AUTH_REQUIRED):
00406          return L"ERROR_DS_STRONG_AUTH_REQUIRED";
00407          break;
00408
00409
00410       case  HRESULT_FROM_WIN32(ERROR_MORE_DATA):
00411          return L"ERROR_MORE_DATA";
00412          break;
00413
00414       case  HRESULT_FROM_WIN32(ERROR_DS_REFERRAL):
00415          return L"(ERROR_DS_REFERRAL";
00416          break;
00417
00418       case  HRESULT_FROM_WIN32(ERROR_DS_ADMIN_LIMIT_EXCEEDED):
00419          return L"ERROR_DS_ADMIN_LIMIT_EXCEEDED";
00420          break;
00421
00422       case  HRESULT_FROM_WIN32(ERROR_DS_UNAVAILABLE_CRIT_EXTENSION):
00423          return L"(ERROR_DS_UNAVAILABLE_CRIT_EXTENSION";
00424          break;
00425
00426       case  HRESULT_FROM_WIN32(ERROR_DS_CONFIDENTIALITY_REQUIRED):
00427          return L"HRESULT_FROM_WIN32(ERROR_DS_CONFIDENTIALITY_REQUIRED";
00428          break;
00429
00430       case  HRESULT_FROM_WIN32(ERROR_DS_NO_ATTRIBUTE_OR_VALUE):
00431          return L"ERROR_DS_NO_ATTRIBUTE_OR_VALUE";
00432          break;
00433
00434       case  HRESULT_FROM_WIN32(ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED):
00435          return L"(ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED";
00436          break;
00437
00438       case  HRESULT_FROM_WIN32(ERROR_DS_INAPPROPRIATE_MATCHING):
00439          return L"(ERROR_DS_INAPPROPRIATE_MATCHING";
00440          break;
00441
00442       case  HRESULT_FROM_WIN32(ERROR_DS_CONSTRAINT_VIOLATION):
00443          return L"ERROR_DS_CONSTRAINT_VIOLATION";
00444          break;
00445
00446       case  HRESULT_FROM_WIN32(ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS):
00447          return L"ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS";
00448          break;
00449
00450       case  HRESULT_FROM_WIN32(ERROR_DS_INVALID_ATTRIBUTE_SYNTAX):
00451          return L"ERROR_DS_INVALID_ATTRIBUTE_SYNTAX";
00452          break;
00453
00454       case  HRESULT_FROM_WIN32(ERROR_DS_NO_SUCH_OBJECT):
00455          return L"ERROR_DS_NO_SUCH_OBJECT";
00456          break;
00457
00458       case  HRESULT_FROM_WIN32(ERROR_DS_INVALID_DN_SYNTAX):
00459          return L"ERROR_DS_INVALID_DN_SYNTAX";
00460          break;
00461
00462       case  HRESULT_FROM_WIN32(ERROR_DS_IS_LEAF):
00463          return L"ERROR_DS_IS_LEAF";
00464          break;
00465
00466       case  HRESULT_FROM_WIN32(ERROR_DS_ALIAS_DEREF_PROBLEM):
00467          return L"ERROR_DS_ALIAS_DEREF_PROBLEM";
00468          break;
00469
00470       case  HRESULT_FROM_WIN32(ERROR_DS_INAPPROPRIATE_AUTH):
00471          return L"ERROR_DS_INAPPROPRIATE_AUTH";
00472          break;
00473
00474       case  HRESULT_FROM_WIN32(ERROR_INVALID_PASSWORD):
00475          return L"ERROR_INVALID_PASSWORD";
00476          break;
00477
00478       case  HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED):
00479          return L"ERROR_ACCESS_DENIED";
00480          break;
00481
00482       case  HRESULT_FROM_WIN32(ERROR_DS_BUSY):
00483          return L"ERROR_DS_BUSY";
00484          break;
00485
00486       case  HRESULT_FROM_WIN32(ERROR_DS_UNAVAILABLE):
00487          return L"ERROR_DS_UNAVAILABLE";
00488          break;
00489
00490       case  HRESULT_FROM_WIN32(ERROR_DS_UNWILLING_TO_PERFORM):
00491          return L"ERROR_DS_UNWILLING_TO_PERFORM";
00492          break;
00493
00494       case  HRESULT_FROM_WIN32(ERROR_DS_LOOP_DETECT):
00495          return L"ERROR_DS_LOOP_DETECT";
00496          break;
00497
00498       case  HRESULT_FROM_WIN32(ERROR_DS_NAMING_VIOLATION):
00499          return L"ERROR_DS_NAMING_VIOLATION";
00500          break;
00501
00502       case  HRESULT_FROM_WIN32(ERROR_DS_OBJ_CLASS_VIOLATION):
00503          return L"ERROR_DS_OBJ_CLASS_VIOLATION";
00504          break;
00505
00506       case  HRESULT_FROM_WIN32(ERROR_DS_CANT_ON_NON_LEAF):
00507          return L"ERROR_DS_CANT_ON_NONLEAF";
00508          break;
00509
00510       case  HRESULT_FROM_WIN32(ERROR_DS_CANT_ON_RDN):
00511          return L"ERROR_DS_CANT_ON_RDN";
00512          break;
00513
00514       case  HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS):
00515          return L"ERROR_ALREADY_EXISTS";
00516          break;
00517
00518       case  HRESULT_FROM_WIN32(ERROR_DS_CANT_MOD_OBJ_CLASS):
00519          return L"ERROR_DS_CANT_MOD_OBJ_CLASS";
00520          break;
00521
00522       case  HRESULT_FROM_WIN32(ERROR_DS_OBJECT_RESULTS_TOO_LARGE):
00523          return L"ERROR_DS_OBJECT_RESULTS_TOO_LARGE";
00524          break;
00525
00526       case  HRESULT_FROM_WIN32(ERROR_DS_AFFECTS_MULTIPLE_DSAS):
00527          return L"ERROR_DS_AFFECTS_MULTIPLE_DSAS";
00528          break;
00529
00530       case  HRESULT_FROM_WIN32(ERROR_GEN_FAILURE):
00531          return L"(ERROR_GEN_FAILURE";
00532          break;
00533
00534       case  HRESULT_FROM_WIN32(ERROR_DS_SERVER_DOWN):
00535          return L"ERROR_DS_SERVER_DOWN";
00536          break;
00537
00538       case  HRESULT_FROM_WIN32(ERROR_DS_LOCAL_ERROR):
00539          return L"ERROR_DS_LOCAL_ERROR";
00540          break;
00541
00542       case  HRESULT_FROM_WIN32(ERROR_DS_ENCODING_ERROR):
00543          return L"ERROR_DS_ENCODING_ERROR";
00544          break;
00545
00546       case  HRESULT_FROM_WIN32(ERROR_DS_DECODING_ERROR):
00547          return L"(ERROR_DS_DECODING_ERROR";
00548          break;
00549
00550       case  HRESULT_FROM_WIN32(ERROR_TIMEOUT):
00551          return L"(ERROR_TIMEOUT";
00552          break;
00553
00554       case  HRESULT_FROM_WIN32(ERROR_DS_AUTH_UNKNOWN):
00555          return L"ERROR_DS_AUTH_UNKNOWN";
00556          break;
00557
00558       case  HRESULT_FROM_WIN32(ERROR_DS_FILTER_UNKNOWN):
00559          return L"(ERROR_DS_FILTER_UNKNOWN";
00560          break;
00561
00562       case  HRESULT_FROM_WIN32(ERROR_CANCELLED):
00563          return L"(ERROR_CANCELLED";
00564          break;
00565
00566       case  HRESULT_FROM_WIN32(ERROR_DS_PARAM_ERROR):
00567          return L"ERROR_DS_PARAM_ERROR";
00568          break;
00569
00570       case  HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY):
00571          return L"ERROR_NOT_ENOUGH_MEMORY";
00572          break;
00573
00574       case  HRESULT_FROM_WIN32(ERROR_CONNECTION_REFUSED):
00575          return L"ERROR_CONNECTION_REFUSED";
00576          break;
00577
00578       case  HRESULT_FROM_WIN32(ERROR_DS_NOT_SUPPORTED):
00579          return L"ERROR_DS_NOT_SUPPORTED";
00580          break;
00581
00582       case  HRESULT_FROM_WIN32(ERROR_DS_NO_RESULTS_RETURNED):
00583          return L"ERROR_DS_NO_RESULTS_RETURNED";
00584          break;
00585
00586       case  HRESULT_FROM_WIN32(ERROR_DS_CONTROL_NOT_FOUND):
00587          return L"ERROR_DS_CONTROL_NOT_FOUND";
00588          break;
00589
00590       case  HRESULT_FROM_WIN32(ERROR_DS_CLIENT_LOOP):
00591          return L"(ERROR_DS_CLIENT_LOOP";
00592          break;
00593
00594       case  HRESULT_FROM_WIN32(ERROR_DS_REFERRAL_LIMIT_EXCEEDED):
00595          return L"ERROR_DS_REFERRAL_LIMIT_EXCEEDED";
00596          break;
00597
00598       case  E_FAIL:
00599          return L"E_FAIL";
00600          break;
00601
00602       case  E_NOTIMPL:
00603          return L"E_NOIMPL";
00604          break;
00605
00606       case  S_OK:
00607          return L"OK";
00608          break;
00609
00610       case  0x800704b8:
00611       // we have an extended error
00612       {
00613          WCHAR szErrorBuff[ 1024 ];
00614          WCHAR szNameBuff[ 1024 ];
00615          DWORD dwError;
00616
00617          ADsGetLastError( &dwError,
00618                           szErrorBuff,
00619                           1023,
00620                           szNameBuff,
00621                           1023 );
00622          wcscat( szNameBuff, L" : " );
00623          wcscat( szNameBuff, szErrorBuff );
00624          wcscpy( szwText,szNameBuff);
00625
00626          return szwText;
00627       }
00628
00629    }
00630
00631     return szwText;
00632 }
00633
00634
00635
00636 // Takes an ADSTYPE and converts it to a string
00637 const char * AdsTypeToChar(long AdsType)
00638 {
00639   static char pAdsChar[200];
00640   pAdsChar[0] = NULL;
00641
00642   switch (AdsType)
00643   {
00644
00645     case ADSTYPE_INVALID :
00646       strcpy(pAdsChar,"ADSTYPE_INVALID");
00647     break;
00648     case ADSTYPE_DN_STRING :
00649       strcpy(pAdsChar,"ADSTYPE_DN_STRING");
00650     break;
00651     case ADSTYPE_CASE_EXACT_STRING :
00652       strcpy(pAdsChar,"ADSTYPE_CASE_EXACT_STRING");
00653     break;
00654     case ADSTYPE_CASE_IGNORE_STRING :
00655       strcpy(pAdsChar,"ADSTYPE_CASE_IGNORE_STRING");
00656     break;
00657     case ADSTYPE_PRINTABLE_STRING :
00658       strcpy(pAdsChar,"ADSTYPE_PRINTABLE_STRING");
00659     break;
00660     case ADSTYPE_NUMERIC_STRING :
00661       strcpy(pAdsChar,"ADSTYPE_NUMERIC_STRING");
00662     break;
00663     case ADSTYPE_BOOLEAN :
00664       strcpy(pAdsChar,"ADSTYPE_BOOLEAN");
00665     break;
00666     case ADSTYPE_INTEGER :
00667       strcpy(pAdsChar,"ADSTYPE_INTEGER");
00668     break;
00669     case ADSTYPE_OCTET_STRING :
00670       strcpy(pAdsChar,"ADSTYPE_OCTET_STRING");
00671     break;
00672     case ADSTYPE_UTC_TIME :
00673       strcpy(pAdsChar,"ADSTYPE_UTC_TIME");
00674     break;
00675     case ADSTYPE_LARGE_INTEGER :
00676       strcpy(pAdsChar,"ADSTYPE_LARGE_INTEGER");
00677     break;
00678     case ADSTYPE_PROV_SPECIFIC :
00679       strcpy(pAdsChar,"ADSTYPE_PROV_SPECIFIC");
00680     break;
00681     case ADSTYPE_OBJECT_CLASS :
00682       strcpy(pAdsChar,"ADSTYPE_OBJECT_CLASS");
00683     break;
00684     case ADSTYPE_PATH :
00685       strcpy(pAdsChar,"ADSTYPE_PATH");
00686     break;
00687     case ADSTYPE_NT_SECURITY_DESCRIPTOR :
00688       strcpy(pAdsChar,"ADSTYPE_NT_SECURITY_DESCRIPTOR");
00689     break;
00690
00691     default:
00692       strcpy(pAdsChar,"<UNRECOGNIZED>");
00693     break;
00694
00695   }
00696   return pAdsChar;
00697
00698
00699 }
00700
00701
00702
00703 struct IIDLookUp
00704 {
00705   GUID id;
00706   char * pIDName;
00707
00708   IIDLookUp(GUID iNewID,char * pNewIDName) :
00709   id(iNewID), pIDName(pNewIDName) {};
00710 };
00711
00712
00713 IIDLookUp    arIDs [] =
00714 {
00715 IIDLookUp(IID_IEnumGUID,              "IID_IEnumGUID"),
00716 IIDLookUp(IID_IEnumCATEGORYINFO,          "IID_IEnumCATEGORYINFO"),
00717 IIDLookUp(IID_ICatRegister,             "IID_ICatRegister"),
00718 IIDLookUp(IID_ICatInformation,            "IID_ICatInformation"),
00719 IIDLookUp(IID_IOleDocument,             "IID_IOleDocument"),
00720 IIDLookUp(IID_IOleDocumentSite,           "IID_IOleDocumentSite"),
00721 IIDLookUp(IID_IOleDocumentView,           "IID_IOleDocumentView"),
00722 IIDLookUp(IID_IEnumOleDocumentViews,        "IID_IEnumOleDocumentViews"),
00723 IIDLookUp(IID_IContinueCallback,          "IID_IContinueCallback"),
00724 IIDLookUp(IID_IPrint,               "IID_IPrint"),
00725 IIDLookUp(IID_IOleCommandTarget,          "IID_IOleCommandTarget"),
00726 IIDLookUp(IID_IHlink,               "IID_IHlink"),
00727 IIDLookUp(IID_IHlinkSite,             "IID_IHlinkSite"),
00728 IIDLookUp(IID_IHlinkTarget,             "IID_IHlinkTarget"),
00729 IIDLookUp(IID_IHlinkFrame,              "IID_IHlinkFrame"),
00730 IIDLookUp(IID_IEnumHLITEM,              "IID_IEnumHLITEM"),
00731 IIDLookUp(IID_IHlinkBrowseContext,          "IID_IHlinkBrowseContext"),
00732 IIDLookUp(IID_ICreateTypeInfo,            "IID_ICreateTypeInfo"),
00733 IIDLookUp(IID_ICreateTypeInfo2,           "IID_ICreateTypeInfo2"),
00734 IIDLookUp(IID_ICreateTypeLib,           "IID_ICreateTypeLib"),
00735 IIDLookUp(IID_ICreateTypeLib2,            "IID_ICreateTypeLib2"),
00736 IIDLookUp(IID_IDispatch,              "IID_IDispatch"),
00737 IIDLookUp(IID_IEnumVARIANT,             "IID_IEnumVARIANT"),
00738 IIDLookUp(IID_ITypeComp,              "IID_ITypeComp"),
00739 IIDLookUp(IID_ITypeInfo,              "IID_ITypeInfo"),
00740 IIDLookUp(IID_ITypeInfo2,             "IID_ITypeInfo2"),
00741 IIDLookUp(IID_ITypeLib,               "IID_ITypeLib"),
00742 IIDLookUp(IID_ITypeLib2,              "IID_ITypeLib2"),
00743 IIDLookUp(IID_ITypeChangeEvents,          "IID_ITypeChangeEvents"),
00744 IIDLookUp(IID_IErrorInfo,             "IID_IErrorInfo"),
00745 IIDLookUp(IID_ICreateErrorInfo,           "IID_ICreateErrorInfo"),
00746 IIDLookUp(IID_ISupportErrorInfo,          "IID_ISupportErrorInfo"),
00747 IIDLookUp(IID_IMarshal,               "IID_IMarshal"),
00748 IIDLookUp(IID_IMalloc,                "IID_IMalloc"),
00749 IIDLookUp(IID_IMallocSpy,             "IID_IMallocSpy"),
00750 IIDLookUp(IID_IStdMarshalInfo,            "IID_IStdMarshalInfo"),
00751 IIDLookUp(IID_IExternalConnection,          "IID_IExternalConnection"),
00752 IIDLookUp(IID_IMultiQI,               "IID_IMultiQI"),
00753 IIDLookUp(IID_IEnumUnknown,             "IID_IEnumUnknown"),
00754 IIDLookUp(IID_IBindCtx,               "IID_IBindCtx"),
00755 IIDLookUp(IID_IEnumMoniker,             "IID_IEnumMoniker"),
00756 IIDLookUp(IID_IRunnableObject,            "IID_IRunnableObject"),
00757 IIDLookUp(IID_IRunningObjectTable,          "IID_IRunningObjectTable"),
00758 IIDLookUp(IID_IPersist,               "IID_IPersist"),
00759 IIDLookUp(IID_IPersistStream,           "IID_IPersistStream"),
00760 IIDLookUp(IID_IMoniker,               "IID_IMoniker"),
00761 IIDLookUp(IID_IROTData,               "IID_IROTData"),
00762 IIDLookUp(IID_IEnumString,              "IID_IEnumString"),
00763 IIDLookUp(IID_ISequentialStream,          "IID_ISequentialStream"),
00764 IIDLookUp(IID_IStream,                "IID_IStream"),
00765 IIDLookUp(IID_IEnumSTATSTG,             "IID_IEnumSTATSTG"),
00766 IIDLookUp(IID_IStorage,               "IID_IStorage"),
00767 IIDLookUp(IID_IPersistFile,             "IID_IPersistFile"),
00768 IIDLookUp(IID_IPersistStorage,            "IID_IPersistStorage"),
00769 IIDLookUp(IID_ILockBytes,             "IID_ILockBytes"),
00770 IIDLookUp(IID_IEnumFORMATETC,           "IID_IEnumFORMATETC"),
00771 IIDLookUp(IID_IEnumSTATDATA,            "IID_IEnumSTATDATA"),
00772 IIDLookUp(IID_IRootStorage,             "IID_IRootStorage"),
00773 IIDLookUp(IID_IAdviseSink,              "IID_IAdviseSink"),
00774 IIDLookUp(IID_IAdviseSink2,             "IID_IAdviseSink2"),
00775 IIDLookUp(IID_IDataObject,              "IID_IDataObject"),
00776 IIDLookUp(IID_IDataAdviseHolder,          "IID_IDataAdviseHolder"),
00777 IIDLookUp(IID_IMessageFilter,           "IID_IMessageFilter"),
00778 IIDLookUp(IID_IRpcChannelBuffer,          "IID_IRpcChannelBuffer"),
00779 IIDLookUp(IID_IRpcProxyBuffer,            "IID_IRpcProxyBuffer"),
00780 IIDLookUp(IID_IRpcStubBuffer,           "IID_IRpcStubBuffer"),
00781 IIDLookUp(IID_IPSFactoryBuffer,           "IID_IPSFactoryBuffer"),
00782 IIDLookUp(IID_IPropertyStorage,           "IID_IPropertyStorage"),
00783 IIDLookUp(IID_IPropertySetStorage,          "IID_IPropertySetStorage"),
00784 IIDLookUp(IID_IEnumSTATPROPSTG,           "IID_IEnumSTATPROPSTG"),
00785 IIDLookUp(IID_IEnumSTATPROPSETSTG,          "IID_IEnumSTATPROPSETSTG"),
00786 IIDLookUp(IID_IFillLockBytes,           "IID_IFillLockBytes"),
00787 IIDLookUp(IID_IProgressNotify,            "IID_IProgressNotify"),
00788 IIDLookUp(IID_ILayoutStorage,           "IID_ILayoutStorage"),
00789 IIDLookUp(IID_IEnumConnections,           "IID_IEnumConnections"),
00790 IIDLookUp(IID_IConnectionPoint,           "IID_IConnectionPoint"),
00791 IIDLookUp(IID_IEnumConnectionPoints,        "IID_IEnumConnectionPoints"),
00792 IIDLookUp(IID_IConnectionPointContainer,      "IID_IConnectionPointContainer"),
00793 IIDLookUp(IID_IClassFactory2,           "IID_IClassFactory2"),
00794 IIDLookUp(IID_IProvideClassInfo,          "IID_IProvideClassInfo"),
00795 IIDLookUp(IID_IProvideClassInfo2,         "IID_IProvideClassInfo2"),
00796 IIDLookUp(IID_IOleControl,              "IID_IOleControl"),
00797 IIDLookUp(IID_IOleControlSite,            "IID_IOleControlSite"),
00798 IIDLookUp(IID_IPropertyPage,            "IID_IPropertyPage"),
00799 IIDLookUp(IID_IPropertyPage2,           "IID_IPropertyPage2"),
00800 IIDLookUp(IID_IPropertyPageSite,          "IID_IPropertyPageSite"),
00801 IIDLookUp(IID_IPropertyNotifySink,          "IID_IPropertyNotifySink"),
00802 IIDLookUp(IID_ISpecifyPropertyPages,        "IID_ISpecifyPropertyPages"),
00803 IIDLookUp(IID_IPersistMemory,           "IID_IPersistMemory"),
00804 IIDLookUp(IID_IPersistStreamInit,         "IID_IPersistStreamInit"),
00805 IIDLookUp(IID_IPersistPropertyBag,          "IID_IPersistPropertyBag"),
00806 IIDLookUp(IID_ISimpleFrameSite,           "IID_ISimpleFrameSite"),
00807 IIDLookUp(IID_IFont,                "IID_IFont"),
00808 IIDLookUp(IID_IPicture,               "IID_IPicture"),
00809 IIDLookUp(IID_IFontDisp,              "IID_IFontDisp"),
00810 IIDLookUp(IID_IPictureDisp,             "IID_IPictureDisp"),
00811 IIDLookUp(IID_IAdviseSinkEx,            "IID_IAdviseSinkEx"),
00812 IIDLookUp(IID_IOleInPlaceObjectWindowless,      "IID_IOleInPlaceObjectWindowless"),
00813 IIDLookUp(IID_IOleInPlaceSiteEx,          "IID_IOleInPlaceSiteEx"),
00814 IIDLookUp(IID_IOleInPlaceSiteWindowless,      "IID_IOleInPlaceSiteWindowless"),
00815 IIDLookUp(IID_IViewObjectEx,            "IID_IViewObjectEx"),
00816 IIDLookUp(IID_IOleUndoUnit,             "IID_IOleUndoUnit"),
00817 IIDLookUp(IID_IOleParentUndoUnit,         "IID_IOleParentUndoUnit"),
00818 IIDLookUp(IID_IEnumOleUndoUnits,          "IID_IEnumOleUndoUnits"),
00819 IIDLookUp(IID_IOleUndoManager,            "IID_IOleUndoManager"),
00820 IIDLookUp(IID_IQuickActivate,           "IID_IQuickActivate"),
00821 IIDLookUp(IID_IPointerInactive,           "IID_IPointerInactive"),
00822 IIDLookUp(IID_IObjectWithSite,            "IID_IObjectWithSite"),
00823 IIDLookUp(IID_IErrorLog,              "IID_IErrorLog"),
00824 IIDLookUp(IID_IPropertyBag,             "IID_IPropertyBag"),
00825 IIDLookUp(IID_IPerPropertyBrowsing,         "IID_IPerPropertyBrowsing"),
00826 IIDLookUp(IID_StdOle,               "IID_StdOle"),
00827 IIDLookUp(IID_IOleAdviseHolder,           "IID_IOleAdviseHolder"),
00828 IIDLookUp(IID_IOleCache,              "IID_IOleCache"),
00829 IIDLookUp(IID_IOleCache2,             "IID_IOleCache2"),
00830 IIDLookUp(IID_IOleCacheControl,           "IID_IOleCacheControl"),
00831 IIDLookUp(IID_IParseDisplayName,          "IID_IParseDisplayName"),
00832 IIDLookUp(IID_IOleContainer,            "IID_IOleContainer"),
00833 IIDLookUp(IID_IOleClientSite,           "IID_IOleClientSite"),
00834 IIDLookUp(IID_IOleObject,             "IID_IOleObject"),
00835 IIDLookUp(IID_IOleWindow,             "IID_IOleWindow"),
00836 IIDLookUp(IID_IOleLink,               "IID_IOleLink"),
00837 IIDLookUp(IID_IOleItemContainer,          "IID_IOleItemContainer"),
00838 IIDLookUp(IID_IOleInPlaceUIWindow,          "IID_IOleInPlaceUIWindow"),
00839 IIDLookUp(IID_IOleInPlaceActiveObject,        "IID_IOleInPlaceActiveObject"),
00840 IIDLookUp(IID_IOleInPlaceFrame,           "IID_IOleInPlaceFrame"),
00841 IIDLookUp(IID_IOleInPlaceObject,          "IID_IOleInPlaceObject"),
00842 IIDLookUp(IID_IOleInPlaceSite,            "IID_IOleInPlaceSite"),
00843 IIDLookUp(IID_IContinue,              "IID_IContinue"),
00844 IIDLookUp(IID_IViewObject,              "IID_IViewObject"),
00845 IIDLookUp(IID_IViewObject2,             "IID_IViewObject2"),
00846 IIDLookUp(IID_IDropSource,              "IID_IDropSource"),
00847 IIDLookUp(IID_IDropTarget,              "IID_IDropTarget"),
00848 IIDLookUp(IID_IEnumOLEVERB,             "IID_IEnumOLEVERB"),
00849 IIDLookUp(IID_IServiceProvider,           "IID_IServiceProvider"),
00850 IIDLookUp(IID_IUnknown,               "IID_IUnknown"),
00851 IIDLookUp(IID_IClassFactory,            "IID_IClassFactory"),
00852 IIDLookUp(IID_IAsyncMoniker,              "IID_IAsyncMoniker"),
00853 IIDLookUp(CLSID_StdURLMoniker,            "CLSID_StdURLMoniker"),
00854 IIDLookUp(CLSID_HttpProtocol,             "CLSID_HttpProtocol"),
00855 IIDLookUp(CLSID_FtpProtocol,              "CLSID_FtpProtocol"),
00856 IIDLookUp(CLSID_GopherProtocol,           "CLSID_GopherProtocol"),
00857 IIDLookUp(CLSID_HttpSProtocol,            "CLSID_HttpSProtocol"),
00858 IIDLookUp(CLSID_FileProtocol,             "CLSID_FileProtocol"),
00859 IIDLookUp(CLSID_MkProtocol,               "CLSID_MkProtocol"),
00860 IIDLookUp(IID_IPersistMoniker,            "IID_IPersistMoniker"),
00861 IIDLookUp(IID_IBindProtocol,            "IID_IBindProtocol"),
00862 IIDLookUp(IID_IBinding,               "IID_IBinding"),
00863 IIDLookUp(IID_IBindStatusCallback,          "IID_IBindStatusCallback"),
00864 IIDLookUp(IID_IAuthenticate,            "IID_IAuthenticate"),
00865 IIDLookUp(IID_IHttpNegotiate,           "IID_IHttpNegotiate"),
00866 IIDLookUp(IID_IWindowForBindingUI,          "IID_IWindowForBindingUI"),
00867 IIDLookUp(IID_ICodeInstall,             "IID_ICodeInstall"),
00868 IIDLookUp(IID_IWinInetInfo,             "IID_IWinInetInfo"),
00869 IIDLookUp(IID_IHttpSecurity,            "IID_IHttpSecurity"),
00870 IIDLookUp(IID_IWinInetHttpInfo,           "IID_IWinInetHttpInfo"),
00871 IIDLookUp(IID_IBindHost,              "IID_IBindHost"),
00872 IIDLookUp(IID_IUnknown,               "IID_IUnknown"),
00873
00874 // ADSI stuff
00875 IIDLookUp(IID_IADs,                 "IID_IADs"),
00876 IIDLookUp(IID_IADsContainer,            "IID_IADsContainer"),
00877 IIDLookUp(IID_IADsCollection,           "IID_IADsCollection"),
00878 IIDLookUp(IID_IADsMembers,              "IID_IADsMembers"),
00879 IIDLookUp(IID_IADsPropertyList,           "IID_IADsPropertyList"),
00880 IIDLookUp(IID_IADsPropertyEntry,          "IID_IADsPropertyEntry"),
00881 IIDLookUp(IID_IADsPropertyValue,          "IID_IADsPropertyValue"),
00882 //IIDLookUp(IID_IADsPropertyValueEx,          "IID_IADsPropertyValueEx"),
00883 //IIDLookUp(IID_IADsValue,              "IID_IADsValue"),
00884 IIDLookUp(IID_IPrivateDispatch,           "IID_IPrivateDispatch"),
00885 IIDLookUp(IID_IPrivateUnknown,            "IID_IPrivateUnknown"),
00886 IIDLookUp(IID_IADsExtension,            "IID_IADsExtension"),
00887 IIDLookUp(IID_IADsDeleteOps,            "IID_IADsDeleteOps"),
00888 IIDLookUp(IID_IADsNamespaces,           "IID_IADsNamespaces"),
00889 IIDLookUp(IID_IADsClass,              "IID_IADsClass"),
00890 IIDLookUp(IID_IADsProperty,             "IID_IADsProperty"),
00891 IIDLookUp(IID_IADsSyntax,             "IID_IADsSyntax"),
00892 IIDLookUp(IID_IADsLocality,             "IID_IADsLocality"),
00893 IIDLookUp(IID_IADsO,                "IID_IADsO"),
00894 IIDLookUp(IID_IADsOU,               "IID_IADsOU"),
00895 IIDLookUp(IID_IADsDomain,             "IID_IADsDomain"),
00896 IIDLookUp(IID_IADsComputer,             "IID_IADsComputer"),
00897 IIDLookUp(IID_IADsComputerOperations,       "IID_IADsComputerOperations"),
00898 IIDLookUp(IID_IADsGroup,              "IID_IADsGroup"),
00899 IIDLookUp(IID_IADsUser,               "IID_IADsUser"),
00900 IIDLookUp(IID_IADsPrintQueue,           "IID_IADsPrintQueue"),
00901 IIDLookUp(IID_IADsPrintQueueOperations,       "IID_IADsPrintQueueOperations"),
00902 IIDLookUp(IID_IADsPrintJob,             "IID_IADsPrintJob"),
00903 IIDLookUp(IID_IADsPrintJobOperations,       "IID_IADsPrintJobOperations"),
00904 IIDLookUp(IID_IADsService,              "IID_IADsService"),
00905 IIDLookUp(IID_IADsServiceOperations,        "IID_IADsServiceOperations"),
00906 IIDLookUp(IID_IADsFileService,            "IID_IADsFileService"),
00907 IIDLookUp(IID_IADsFileServiceOperations,      "IID_IADsFileServiceOperations"),
00908 IIDLookUp(IID_IADsFileShare,            "IID_IADsFileShare"),
00909 IIDLookUp(IID_IADsSession,              "IID_IADsSession"),
00910 IIDLookUp(IID_IADsResource,             "IID_IADsResource"),
00911 IIDLookUp(IID_IADsOpenDSObject,           "IID_IADsOpenDSObject"),
00912 IIDLookUp(IID_IDirectoryObject,           "IID_IDirectoryObject"),
00913 IIDLookUp(IID_IDirectorySearch,           "IID_IDirectorySearch"),
00914 //IIDLookUp(IID_IDirectoryAttrMgmt,         "IID_IDirectoryAttrMgmt"),
00915 IIDLookUp(IID_IADsAccessControlEntry,       "IID_IADsAccessControlEntry"),
00916 IIDLookUp(IID_IADsAccessControlList,        "IID_IADsAccessControlList"),
00917 IIDLookUp(IID_IADsSecurityDescriptor,       "IID_IADsSecurityDescriptor"),
00918 IIDLookUp(IID_IADsLargeInteger,           "IID_IADsLargeInteger"),
00919 IIDLookUp(IID_IADsNameTranslate,          "IID_IADsNameTranslate"),
00920 IIDLookUp(IID_IADsCaseIgnoreList,         "IID_IADsCaseIgnoreList"),
00921 IIDLookUp(IID_IADsFaxNumber,            "IID_IADsFaxNumber"),
00922 IIDLookUp(IID_IADsNetAddress,           "IID_IADsNetAddress"),
00923 IIDLookUp(IID_IADsOctetList,            "IID_IADsOctetList"),
00924 IIDLookUp(IID_IADsEmail,              "IID_IADsEmail"),
00925 IIDLookUp(IID_IADsPath,               "IID_IADsPath"),
00926 IIDLookUp(IID_IADsReplicaPointer,         "IID_IADsReplicaPointer"),
00927 IIDLookUp(IID_IADsAcl,                "IID_IADsAcl"),
00928 IIDLookUp(IID_IADsTimestamp,            "IID_IADsTimestamp"),
00929 IIDLookUp(IID_IADsPostalAddress,          "IID_IADsPostalAddress"),
00930 IIDLookUp(IID_IADsBackLink,             "IID_IADsBackLink"),
00931 IIDLookUp(IID_IADsTypedName,            "IID_IADsTypedName"),
00932 IIDLookUp(IID_IADsHold,               "IID_IADsHold"),
00933 IIDLookUp(IID_IADsObjectOptions,          "IID_IADsObjectOptions"),
00934
00935 // Last ONE
00936 IIDLookUp(IID_IUnknown,NULL)
00937 };
00938
00939
00940 inline BOOL AretheGUIDsEqual(REFGUID rguid1, REFGUID rguid2)
00941 {
00942    return (
00943     ((PLONG) &rguid1)[0] == ((PLONG) &rguid2)[0] &&
00944     ((PLONG) &rguid1)[1] == ((PLONG) &rguid2)[1] &&
00945     ((PLONG) &rguid1)[2] == ((PLONG) &rguid2)[2] &&
00946     ((PLONG) &rguid1)[3] == ((PLONG) &rguid2)[3]);
00947 }
00948
00949
00950 // Returns a string descriing the passed GUID
00951 char * GetCharFromGUID(GUID idtofind)
00952 {
00953   int x =0;
00954
00955   while(arIDs[x].pIDName && !AretheGUIDsEqual(arIDs[x].id ,idtofind))
00956     x++;
00957
00958   return arIDs[x].pIDName ;
00959 }
00960
00961 char pQueryAllInterfacesOut[5000];
00962
00963 // Queries ALL the interfaces of passed in IUNknown
00964 // returns a string with a space delimited list of the
00965 // interfaces
00966 const char * QueryAllInterfaces(IUnknown * pUnk)
00967 {
00968
00969   int x = 0;
00970   int iLen = sizeof(arIDs)/sizeof(IIDLookUp);
00971   pQueryAllInterfacesOut[0] = NULL;
00972   IUnknown * pGetUnk = NULL;
00973
00974   for (x = 0; x < iLen; x++)
00975   {
00976     if(SUCCEEDED(pUnk->QueryInterface(arIDs[x].id,(void **) &pGetUnk)))
00977     {
00978       if (arIDs[x].pIDName)
00979       {
00980         strcat (pQueryAllInterfacesOut,arIDs[x].pIDName );
00981         strcat (pQueryAllInterfacesOut,"\n ");
00982         pGetUnk->Release();
00983         pGetUnk = NULL;
00984       }
00985     }
00986   }
00987   return pQueryAllInterfacesOut;
00988 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCrmFilesWorker Member List

This is the complete list of members for CCrmFilesWorker, including all inherited members.
Activate(void) | CCrmFilesWorker |
CanBePooled(void) | CCrmFilesWorker |
CCrmFilesWorker() | CCrmFilesWorker |
CreateFile(BSTR bstrFileName) | CCrmFilesWorker |
Deactivate(void) | CCrmFilesWorker |
DeleteFile(BSTR bstrFileName) | CCrmFilesWorker |
GetCrmLogControl(void) | CCrmFilesWorker | [private]
m_id | CCrmFilesWorker | [private]
m_pICrmLogControl | CCrmFilesWorker | [private]
~CCrmFilesWorker() | CCrmFilesWorker |
Generated on Wed Nov 13 2024 16:55:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

newseventclass::INewsEventDefault Member List

This is the complete list of members for newseventclass::INewsEventDefault, including all inherited members.
iid | newseventclass::INewsEventDefault | [static]
LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate) | newseventclass::INewsEventDefault |
NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL) | newseventclass::INewsEventDefault |
ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow) | newseventclass::INewsEventDefault |
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/ScripTag.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

ScripTag.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright 1992 - 1998 Microsoft Corporation
00004 //
00005 //  File:       scriptag.hxx
00006 //
00007 //  Contents:   Parsing algorithm for script tags
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #if !defined( __SCRIPTAG_HXX__ )
00012 #define __SCRIPTAG_HXX__
00013
00014 #include <htmlelem.hxx>
00015 #include <proptag.hxx>
00016
00017
00018 //+-------------------------------------------------------------------------
00019 //
00020 //  Class:      CScriptTag
00021 //
00022 //  Purpose:    Parsing algorithm for script tag in Html
00023 //
00024 //--------------------------------------------------------------------------
00025
00026 class CScriptTag : public CHtmlElement
00027 {
00028
00029 public:
00030     CScriptTag( CHtmlIFilter& htmlIFilter,
00031                 CSerialStream& serialStream,
00032                 GUID ClsidScriptInfo );
00033
00034     virtual SCODE    GetChunk( STAT_CHUNK *pStat );
00035     virtual SCODE    GetText( ULONG *pcwcOutput, WCHAR *awcBuffer );
00036     virtual SCODE    GetValue( PROPVARIANT ** ppPropValue );
00037
00038     virtual void     InitStatChunk( STAT_CHUNK *pStat );
00039
00040 private:
00041
00042     PropTagState     _eState;                                       // Current state of tag
00043     GUID             _clsidScriptInfo;
00044     WCHAR            _awszPropSpec[MAX_PROPSPEC_STRING_LENGTH+1];   // Prop spec string in attribute
00045 };
00046
00047
00048 #endif // __SCRIPTAG_HXX__
00049
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ICOMSysLCE Member List

This is the complete list of members for ICOMSysLCE, including all inherited members.
GetEventClass([out] LPGUID guid) | ICOMSysLCE
GetEventType([out] EventEnum *e) | ICOMSysLCE
Install([in] BSTR *PropertyName,[in] VARIANT PropertyValue) | ICOMSysLCE
Uninstall() | ICOMSysLCE
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Search/vc/Search.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Search
  • vc

Search.cpp

Go to the documentation of this file.
00001 // Search.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "stdio.h"
00006 #include "activeds.h"
00007
00008
00009 int main(int argc, char* argv[])
00010 {
00011   HRESULT hr;
00012   IDirectorySearch *pSearch;
00013   CoInitialize(NULL);
00014
00015
00016   ///////////////////////////////////////////////
00017   // Bind to Object, it serves as a base search
00018   ///////////////////////////////////////////////
00019   hr = ADsGetObject(L"LDAP://DC=testDom1,DC=testDom2,DC=microsoft,DC=com",
00020                   IID_IDirectorySearch,
00021             (void**) &pSearch );
00022
00023   if ( !SUCCEEDED(hr) )
00024   {
00025     return hr;
00026   }
00027
00028
00029   ///////////////////////////////////////
00030   // We want a subtree search
00031   /////////////////////////////////////////
00032   ADS_SEARCHPREF_INFO prefInfo[1];
00033   prefInfo[0].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
00034   prefInfo[0].vValue.dwType = ADSTYPE_INTEGER;
00035   prefInfo[0].vValue.Integer = ADS_SCOPE_SUBTREE;
00036   hr = pSearch->SetSearchPreference( prefInfo, 1);
00037
00038   ////////////////////////////////////
00039   // Prepared for attributed returned
00040   ////////////////////////////////////
00041   LPWSTR pszAttr[] = { L"Name"};
00042   ADS_SEARCH_HANDLE hSearch;
00043   DWORD dwCount= sizeof(pszAttr)/sizeof(LPWSTR);
00044
00045
00046   //////////////////////////////////////////
00047   // Search for all groups in a domain
00048   /////////////////////////////////////////////
00049   hr = pSearch->ExecuteSearch(L"(objectCategory=Group)", pszAttr, dwCount, &hSearch );
00050
00051   if ( !SUCCEEDED(hr) )
00052   {
00053     pSearch->Release();
00054     return hr;
00055   }
00056
00057   //////////////////////////////////////////
00058   // Now enumerate the result
00059   /////////////////////////////////////////////
00060   ADS_SEARCH_COLUMN col;
00061     while(  pSearch->GetNextRow(hSearch)  != S_ADS_NOMORE_ROWS )
00062     {
00063     // Get 'Name' attribute
00064     hr = pSearch->GetColumn( hSearch, pszAttr[0], &col );
00065     if ( SUCCEEDED(hr) )
00066     {
00067       printf("%S\n", col.pADsValues->CaseIgnoreString);
00068       pSearch->FreeColumn( &col ); // You need to FreeColum after use.
00069     }
00070
00071
00072     }
00073
00074   ////////////////////
00075   // Clean-up
00076   ////////////////////////
00077     pSearch->CloseSearchHandle(hSearch);
00078   pSearch->Release();
00079
00080
00081
00082   CoUninitialize();
00083   return 0;
00084 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Static_Info_Database Member List

This is the complete list of members for Static_Info_Database, including all inherited members.
bTaken | Static_Info_Database
hConnection | Static_Info_Database
pRasConnection0 | Static_Info_Database
pRasConnection1 | Static_Info_Database
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditCommands/StdAfx.h Source File

  • Web
  • Browser
  • EditCommands

StdAfx.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.h : include file for standard system include files,
00006 //      or project specific include files that are used frequently,
00007 //      but are changed infrequently
00008
00009 #if !defined(AFX_STDAFX_H__282ACEFC_3C20_44F0_AF8F_BBFF0E5EE651__INCLUDED_)
00010 #define AFX_STDAFX_H__282ACEFC_3C20_44F0_AF8F_BBFF0E5EE651__INCLUDED_
00011
00012 #if _MSC_VER > 1000
00013 #pragma once
00014 #endif // _MSC_VER > 1000
00015
00016 #define STRICT
00017 #ifndef _WIN32_WINNT
00018 #define _WIN32_WINNT 0x0400
00019 #endif
00020 #define _ATL_APARTMENT_THREADED
00021
00022 #include <atlbase.h>
00023 //You may derive a class from CComModule and use it if you want to override
00024 //something, but do not change the name of _Module
00025 class CExeModule : public CComModule
00026 {
00027 public:
00028   LONG Unlock();
00029   DWORD dwThreadID;
00030   HANDLE hEventShutdown;
00031   void MonitorShutdown();
00032   bool StartMonitor();
00033   bool bActivity;
00034 };
00035 extern CExeModule _Module;
00036 #include <atlcom.h>
00037
00038 //{{AFX_INSERT_LOCATION}}
00039 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00040
00041 #endif // !defined(AFX_STDAFX_H__282ACEFC_3C20_44F0_AF8F_BBFF0E5EE651__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/Imp_Draw/Imp_Draw.h Source File

  • NetDS
  • MessageQueuing
  • Imp_Draw

Imp_Draw.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // Imp_Draw.h : main header file for the IMP_DRAW application
00013 //
00014
00015
00016
00017 #if !defined(AFX_IMP_DRAW_H__02EE0036_FC6D_11D0_A14D_00C04FB9D5DF__INCLUDED_)
00018 #define AFX_IMP_DRAW_H__02EE0036_FC6D_11D0_A14D_00C04FB9D5DF__INCLUDED_
00019
00020 #if _MSC_VER >= 1000
00021 #pragma once
00022 #endif // _MSC_VER >= 1000
00023
00024 #ifndef __AFXWIN_H__
00025   #error include 'stdafx.h' before including this file for PCH
00026 #endif
00027
00028 #include "resource.h"   // main symbols
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // CImp_DrawApp:
00032 // See Imp_Draw.cpp for the implementation of this class
00033 //
00034
00035 class CImp_DrawApp : public CWinApp
00036 {
00037 public:
00038   CImp_DrawApp();
00039
00040 // Overrides
00041   // ClassWizard generated virtual function overrides
00042   //{{AFX_VIRTUAL(CImp_DrawApp)
00043   public:
00044   virtual BOOL InitInstance();
00045   //}}AFX_VIRTUAL
00046
00047 // Implementation
00048
00049   //{{AFX_MSG(CImp_DrawApp)
00050     // NOTE - the ClassWizard will add and remove member functions here.
00051     //    DO NOT EDIT what you see in these blocks of generated code !
00052   //}}AFX_MSG
00053   DECLARE_MESSAGE_MAP()
00054 };
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058
00059 //{{AFX_INSERT_LOCATION}}
00060 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00061
00062 #endif // !defined(AFX_IMP_DRAW_H__02EE0036_FC6D_11D0_A14D_00C04FB9D5DF__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/comp.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

comp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENT_
00016 #define _CLASS_CCOMPONENT_
00017
00018 #include "Globals.h"
00019
00020
00021 class CComponentData;                  // References
00022
00023
00024 //---------------------------------------------------------------------------
00025 class CComponent : public IComponent2,
00026                           INodeProperties
00027 {
00028   // Construction/Destruction
00029   public:
00030     CComponent( CComponentData* pParent );
00031     ~CComponent();
00032
00033
00034     /////////////////////////////////////////////////////////////////////////
00035     // Interface IUnknown
00036     //
00037     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00038     STDMETHODIMP_(ULONG) AddRef();
00039     STDMETHODIMP_(ULONG) Release();
00040
00041     /////////////////////////////////////////////////////////////////////////
00042     // Interface IComponent
00043     //
00044     HRESULT STDMETHODCALLTYPE Initialize
00045             ( /*[in]*/ LPCONSOLE ipConsole );
00046
00047     HRESULT STDMETHODCALLTYPE Notify
00048             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00049               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00050               /*[in]*/ LONG nArg,
00051               /*[in]*/ LONG nParam
00052             );
00053
00054     HRESULT STDMETHODCALLTYPE Destroy
00055             ( /*[in]*/ MMC_COOKIE nCookie );
00056
00057     HRESULT STDMETHODCALLTYPE QueryDataObject
00058             ( /*[in]*/  MMC_COOKIE nCookie,
00059               /*[in]*/  DATA_OBJECT_TYPES nEnumType,
00060               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00061             );
00062
00063     HRESULT STDMETHODCALLTYPE GetResultViewType
00064             ( /*[in]*/  MMC_COOKIE nCookie,
00065               /*[out]*/ LPOLESTR __RPC_FAR* ppViewType,
00066               /*[out]*/ long __RPC_FAR* pViewOptions
00067             );
00068
00069     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00070             ( /*[out][in]*/ RESULTDATAITEM __RPC_FAR* pResultDataItem );
00071
00072     HRESULT STDMETHODCALLTYPE CompareObjects
00073             ( /*[in]*/ LPDATAOBJECT lpDataObjectA,
00074               /*[in]*/ LPDATAOBJECT lpDataObjectB
00075             );
00076
00077     HRESULT STDMETHODCALLTYPE QueryDispatch
00078             ( /*[in] */  MMC_COOKIE  nCookie,
00079               /*[in] */  DATA_OBJECT_TYPES eType,
00080               /*[out]*/  LPDISPATCH* pipDispatch
00081             );
00082
00083     HRESULT STDMETHODCALLTYPE GetResultViewType2
00084             ( /*[in] */    MMC_COOKIE nCookie,
00085               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pRVTinfo
00086             );
00087
00088     HRESULT STDMETHODCALLTYPE RestoreResultView
00089             ( /*[in] */    MMC_COOKIE nCookie,
00090               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pResultViewType
00091             );
00092
00093
00094     /////////////////////////////////////////////////////////////////////////
00095     // Interface INodeProperties
00096     //
00097     HRESULT STDMETHODCALLTYPE GetProperty
00098             ( /*[in] */  LPDATAOBJECT ipDataObject,
00099               /*[in] */  BSTR  szPropertyName,
00100               /*[out]*/  PBSTR pbstrProperty
00101             );
00102
00103   // Private data
00104   private:
00105     ULONG            m_cRef;
00106     LPCONSOLE3       m_ipConsole;
00107     LPCONSOLEVERB    m_ipConsoleVerb;
00108     LPRESULTDATA     m_ipResultData;
00109     LPHEADERCTRL2    m_ipHeaderCtrl;
00110     CComponentData*  m_pComponentData;
00111     LONG_PTR         m_pScopeCookie;
00112
00113   ///////////////////////////////////////////////////////////////////////////
00114   //  Handlers for notifications which are not delegated
00115   private:
00116     HRESULT  OnAddImages( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam );
00117
00118
00119   ///////////////////////////////////////////////////////////////////////////
00120   //  Public helpers
00121   public:
00122     HRESULT  GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00123     LONG_PTR GetScopeCookie()  { return m_pScopeCookie; }
00124
00125 };
00126
00127 #endif //_CLASS_CCOMPONENT_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/BrochureMachine/BrochureMachine_p.c Source File

  • Web
  • Browser
  • BrochureMachine

BrochureMachine_p.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 /* this ALWAYS GENERATED file contains the proxy stub code */
00006
00007
00008 /* File created by MIDL compiler version 5.01.0164 */
00009 /* at Tue Oct 03 16:16:33 2000
00010  */
00011 /* Compiler settings for C:\workshop\samples\browser\BrochureMachine\BrochureMachine.idl:
00012     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00013     error checks: allocation ref bounds_check enum stub_data
00014 */
00015 //@@MIDL_FILE_HEADING(  )
00016
00017 #define USE_STUBLESS_PROXY
00018
00019
00020 /* verify that the <rpcproxy.h> version is high enough to compile this file*/
00021 #ifndef __REDQ_RPCPROXY_H_VERSION__
00022 #define __REQUIRED_RPCPROXY_H_VERSION__ 440
00023 #endif
00024
00025
00026 #include "rpcproxy.h"
00027 #ifndef __RPCPROXY_H_VERSION__
00028 #error this stub requires an updated version of <rpcproxy.h>
00029 #endif // __RPCPROXY_H_VERSION__
00030
00031
00032 #include "BrochureMachine.h"
00033
00034 #define TYPE_FORMAT_STRING_SIZE   3
00035 #define PROC_FORMAT_STRING_SIZE   23
00036
00037 typedef struct _MIDL_TYPE_FORMAT_STRING
00038     {
00039     short          Pad;
00040     unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
00041     } MIDL_TYPE_FORMAT_STRING;
00042
00043 typedef struct _MIDL_PROC_FORMAT_STRING
00044     {
00045     short          Pad;
00046     unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
00047     } MIDL_PROC_FORMAT_STRING;
00048
00049
00050 extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
00051 extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
00052
00053
00054 /* Object interface: IUnknown, ver. 0.0,
00055    GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
00056
00057
00058 /* Object interface: IDispatch, ver. 0.0,
00059    GUID={0x00020400,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
00060
00061
00062 /* Object interface: IPTLauncher, ver. 0.0,
00063    GUID={0xA79007AB,0xEB8B,0x46DB,{0x92,0x25,0x5B,0xF4,0xBD,0xD0,0xBC,0xAF}} */
00064
00065
00066 extern const MIDL_STUB_DESC Object_StubDesc;
00067
00068
00069 extern const MIDL_SERVER_INFO IPTLauncher_ServerInfo;
00070
00071 #pragma code_seg(".orpc")
00072
00073 static const MIDL_STUB_DESC Object_StubDesc =
00074     {
00075     0,
00076     NdrOleAllocate,
00077     NdrOleFree,
00078     0,
00079     0,
00080     0,
00081     0,
00082     0,
00083     __MIDL_TypeFormatString.Format,
00084     1, /* -error bounds_check flag */
00085     0x20000, /* Ndr library version */
00086     0,
00087     0x50100a4, /* MIDL Version 5.1.164 */
00088     0,
00089     0,
00090     0,  /* notify & notify_flag routine table */
00091     1,  /* Flags */
00092     0,  /* Reserved3 */
00093     0,  /* Reserved4 */
00094     0   /* Reserved5 */
00095     };
00096
00097 static const unsigned short IPTLauncher_FormatStringOffsetTable[] =
00098     {
00099     (unsigned short) -1,
00100     (unsigned short) -1,
00101     (unsigned short) -1,
00102     (unsigned short) -1,
00103     0
00104     };
00105
00106 static const MIDL_SERVER_INFO IPTLauncher_ServerInfo =
00107     {
00108     &Object_StubDesc,
00109     0,
00110     __MIDL_ProcFormatString.Format,
00111     &IPTLauncher_FormatStringOffsetTable[-3],
00112     0,
00113     0,
00114     0,
00115     0
00116     };
00117
00118 static const MIDL_STUBLESS_PROXY_INFO IPTLauncher_ProxyInfo =
00119     {
00120     &Object_StubDesc,
00121     __MIDL_ProcFormatString.Format,
00122     &IPTLauncher_FormatStringOffsetTable[-3],
00123     0,
00124     0,
00125     0
00126     };
00127
00128 CINTERFACE_PROXY_VTABLE(8) _IPTLauncherProxyVtbl =
00129 {
00130     &IPTLauncher_ProxyInfo,
00131     &IID_IPTLauncher,
00132     IUnknown_QueryInterface_Proxy,
00133     IUnknown_AddRef_Proxy,
00134     IUnknown_Release_Proxy ,
00135     0 /* (void *)-1 /* IDispatch::GetTypeInfoCount */ ,
00136     0 /* (void *)-1 /* IDispatch::GetTypeInfo */ ,
00137     0 /* (void *)-1 /* IDispatch::GetIDsOfNames */ ,
00138     0 /* IDispatch_Invoke_Proxy */ ,
00139     (void *)-1 /* IPTLauncher::LaunchPT */
00140 };
00141
00142
00143 static const PRPC_STUB_FUNCTION IPTLauncher_table[] =
00144 {
00145     STUB_FORWARDING_FUNCTION,
00146     STUB_FORWARDING_FUNCTION,
00147     STUB_FORWARDING_FUNCTION,
00148     STUB_FORWARDING_FUNCTION,
00149     NdrStubCall2
00150 };
00151
00152 CInterfaceStubVtbl _IPTLauncherStubVtbl =
00153 {
00154     &IID_IPTLauncher,
00155     &IPTLauncher_ServerInfo,
00156     8,
00157     &IPTLauncher_table[-3],
00158     CStdStubBuffer_DELEGATING_METHODS
00159 };
00160
00161 #pragma data_seg(".rdata")
00162
00163 #if !defined(__RPC_WIN32__)
00164 #error  Invalid build platform for this stub.
00165 #endif
00166
00167 #if !(TARGET_IS_NT40_OR_LATER)
00168 #error You need a Windows NT 4.0 or later to run this stub because it uses these features:
00169 #error   -Oif or -Oicf, more than 32 methods in the interface.
00170 #error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
00171 #error This app will die there with the RPC_X_WRONG_STUB_VERSION error.
00172 #endif
00173
00174
00175 static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
00176     {
00177         0,
00178         {
00179
00180   /* Procedure LaunchPT */
00181
00182       0x33,   /* FC_AUTO_HANDLE */
00183       0x6c,   /* Old Flags:  object, Oi2 */
00184 /*  2 */  NdrFcLong( 0x0 ), /* 0 */
00185 /*  6 */  NdrFcShort( 0x7 ),  /* 7 */
00186 #ifndef _ALPHA_
00187 /*  8 */  NdrFcShort( 0x8 ),  /* x86, MIPS, PPC Stack size/offset = 8 */
00188 #else
00189       NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
00190 #endif
00191 /* 10 */  NdrFcShort( 0x0 ),  /* 0 */
00192 /* 12 */  NdrFcShort( 0x8 ),  /* 8 */
00193 /* 14 */  0x4,    /* Oi2 Flags:  has return, */
00194       0x1,    /* 1 */
00195
00196   /* Return value */
00197
00198 /* 16 */  NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
00199 #ifndef _ALPHA_
00200 /* 18 */  NdrFcShort( 0x4 ),  /* x86, MIPS, PPC Stack size/offset = 4 */
00201 #else
00202       NdrFcShort( 0x8 ),  /* Alpha Stack size/offset = 8 */
00203 #endif
00204 /* 20 */  0x8,    /* FC_LONG */
00205       0x0,    /* 0 */
00206
00207       0x0
00208         }
00209     };
00210
00211 static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
00212     {
00213         0,
00214         {
00215       NdrFcShort( 0x0 ),  /* 0 */
00216
00217       0x0
00218         }
00219     };
00220
00221 const CInterfaceProxyVtbl * _BrochureMachine_ProxyVtblList[] =
00222 {
00223     ( CInterfaceProxyVtbl *) &_IPTLauncherProxyVtbl,
00224     0
00225 };
00226
00227 const CInterfaceStubVtbl * _BrochureMachine_StubVtblList[] =
00228 {
00229     ( CInterfaceStubVtbl *) &_IPTLauncherStubVtbl,
00230     0
00231 };
00232
00233 PCInterfaceName const _BrochureMachine_InterfaceNamesList[] =
00234 {
00235     "IPTLauncher",
00236     0
00237 };
00238
00239 const IID *  _BrochureMachine_BaseIIDList[] =
00240 {
00241     &IID_IDispatch,
00242     0
00243 };
00244
00245
00246 #define _BrochureMachine_CHECK_IID(n) IID_GENERIC_CHECK_IID( _BrochureMachine, pIID, n)
00247
00248 int __stdcall _BrochureMachine_IID_Lookup( const IID * pIID, int * pIndex )
00249 {
00250
00251     if(!_BrochureMachine_CHECK_IID(0))
00252         {
00253         *pIndex = 0;
00254         return 1;
00255         }
00256
00257     return 0;
00258 }
00259
00260 const ExtendedProxyFileInfo BrochureMachine_ProxyFileInfo =
00261 {
00262     (PCInterfaceProxyVtblList *) & _BrochureMachine_ProxyVtblList,
00263     (PCInterfaceStubVtblList *) & _BrochureMachine_StubVtblList,
00264     (const PCInterfaceName * ) & _BrochureMachine_InterfaceNamesList,
00265     (const IID ** ) & _BrochureMachine_BaseIIDList,
00266     & _BrochureMachine_IID_Lookup,
00267     1,
00268     2,
00269     0, /* table of [async_uuid] interfaces */
00270     0, /* Filler1 */
00271     0, /* Filler2 */
00272     0  /* Filler3 */
00273 };
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/ShlView.h Source File

  • WinUI
  • Shell
  • SampView

ShlView.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ShlView.h
00013
00014    Description:   CShellView definitions.
00015
00016 **************************************************************************/
00017
00018 #ifndef SHELLVIEW_H
00019 #define SHELLVIEW_H
00020
00021 #include <windows.h>
00022 #include <windowsx.h>
00023 #include <objbase.h>
00024 #include <shlobj.h>
00025 #include <ServProv.h>
00026 #include <DocObj.h>
00027 #include "ShlFldr.h"
00028 #include "PidlMgr.h"
00029 #include "ContMenu.h"
00030
00031 /**************************************************************************
00032    global IDs
00033 **************************************************************************/
00034
00035 //control IDs
00036 #define ID_LISTVIEW     2000
00037
00038 /**************************************************************************
00039
00040    CShellView class definition
00041
00042 **************************************************************************/
00043
00044 class CShellView : public IShellView
00045 {
00046 friend class CShellFolder;
00047 friend class CContextMenu;
00048
00049 private:
00050    DWORD          m_ObjRefCount;
00051    UINT           m_uState;
00052   LPITEMIDLIST   m_pidl;
00053   FOLDERSETTINGS m_FolderSettings;
00054   LPSHELLBROWSER m_pShellBrowser;
00055   HWND           m_hwndParent;
00056   HWND           m_hWnd;
00057   HWND           m_hwndList;
00058   HMENU          m_hMenu;
00059    CShellFolder   *m_psfParent;
00060   LPMALLOC       m_pMalloc;
00061    CPidlMgr       *m_pPidlMgr;
00062    HACCEL         m_hAccels;
00063    BOOL           m_fInEdit;
00064
00065 public:
00066    CShellView(CShellFolder*, LPCITEMIDLIST);
00067    ~CShellView();
00068
00069    //IUnknown methods
00070    STDMETHOD (QueryInterface)(REFIID, LPVOID*);
00071    STDMETHOD_ (DWORD, AddRef)();
00072    STDMETHOD_ (DWORD, Release)();
00073
00074    //IOleWindow methods
00075    STDMETHOD (GetWindow) (HWND*);
00076    STDMETHOD (ContextSensitiveHelp) (BOOL);
00077
00078    //IShellView methods
00079    STDMETHOD (TranslateAccelerator) (LPMSG);
00080    STDMETHOD (EnableModeless) (BOOL);
00081    STDMETHOD (UIActivate) (UINT);
00082    STDMETHOD (Refresh) (VOID);
00083    STDMETHOD (CreateViewWindow) (LPSHELLVIEW, LPCFOLDERSETTINGS, LPSHELLBROWSER, LPRECT, HWND*);
00084    STDMETHOD (DestroyViewWindow) (VOID);
00085    STDMETHOD (GetCurrentInfo) (LPFOLDERSETTINGS);
00086    STDMETHOD (AddPropertySheetPages) (DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
00087    STDMETHOD (SaveViewState) (VOID);
00088    STDMETHOD (SelectItem) (LPCITEMIDLIST, UINT);
00089    STDMETHOD (GetItemObject) (UINT, REFIID, LPVOID*);
00090
00091 private:
00092    static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00093   LRESULT UpdateMenu(HMENU hMenu);
00094   LRESULT UpdateToolbar(VOID);
00095   VOID MergeFileMenu(HMENU, BOOL);
00096   VOID MergeViewMenu(HMENU);
00097   VOID MergeEditMenu(HMENU, BOOL);
00098   VOID MergeToolbar(VOID);
00099   LRESULT OnCommand(DWORD, DWORD, HWND);
00100   LRESULT OnActivate(UINT);
00101   VOID OnDeactivate(VOID);
00102   LRESULT OnSetFocus(VOID);
00103   LRESULT OnKillFocus(VOID);
00104   LRESULT OnNotify(UINT, LPNMHDR);
00105   LRESULT OnSize(WORD, WORD);
00106   LRESULT OnCreate(VOID);
00107   LRESULT OnDestroy(VOID);
00108   BOOL CreateList(VOID);
00109   BOOL InitList(VOID);
00110   VOID FillList(VOID);
00111   LRESULT OnSettingChange(LPCTSTR);
00112    VOID GetShellSettings(VOID);
00113    VOID DoContextMenu(WORD, WORD, BOOL, DWORD);
00114    int FindItemPidl(LPCITEMIDLIST);
00115    LRESULT OnViewLarge(VOID);
00116    LRESULT OnViewSmall(VOID);
00117    LRESULT OnViewList(VOID);
00118    LRESULT OnViewDetails(VOID);
00119    BOOL AddItem(LPCITEMIDLIST);
00120    BOOL DeleteItem(LPCITEMIDLIST);
00121    BOOL RenameItem(LPCITEMIDLIST, LPCITEMIDLIST);
00122    LPITEMIDLIST GetPidl();
00123    LPITEMIDLIST GetFQPidl();
00124    VOID MarkItemsAsCut(LPCITEMIDLIST*, UINT);
00125    VOID EditItem(LPCITEMIDLIST);
00126    VOID UpdateData(LPCITEMIDLIST);
00127
00128 };
00129
00130 #endif   //SHELLVIEW_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COShip Member List

This is the complete list of members for COShip, including all inherited members.
COShip() | COShip | [inline]
InvokeNotifyIDispatch(IUnknown *punk, long lFlags) | COShip | [private]
InvokeNotifyVtable(IUnknown *punk, long lFlags) | COShip | [private]
LineItem(long lItemId, long lQuantity) | COShip |
m_lCustomerId | COShip | [private]
m_lOrderId | COShip | [private]
m_veclItemId | COShip | [private]
m_veclQuantity | COShip | [private]
m_vecShipStatus | COShip | [private]
NotifyRequestor(long lFlags) | COShip | [private]
Process(long lFlags) | COShip |
put_CustomerId(long lCustomerId) | COShip |
put_OrderId(long lOrderId) | COShip |
RandomShipStatus() | COShip | [private]
WriteShipDB() | COShip | [private]
Generated on Wed Nov 13 2024 16:57:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::PropertyAttributesEnum Member List

This is the complete list of members for msado15::PropertyAttributesEnum, including all inherited members.
adPropNotSupported | msado15::PropertyAttributesEnum | [static]
adPropOptional | msado15::PropertyAttributesEnum | [static]
adPropRead | msado15::PropertyAttributesEnum | [static]
adPropRequired | msado15::PropertyAttributesEnum | [static]
adPropWrite | msado15::PropertyAttributesEnum | [static]
Generated on Wed Nov 13 2024 16:58:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/ComDlg32/ComDlg32.h Source File

  • WinUI
  • CommDlg
  • ComDlg32

ComDlg32.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 //  CMNDLG32.H
00003 //---------------------------------------------------------------------------
00004
00005 #ifndef STRICT
00006 #define STRICT
00007 #endif
00008
00009 #ifdef  RC_INVOKED
00010 #include <winuser.h>
00011 #else // RC_INVOKED
00012 #include <windows.h>
00013 #endif  // RC_INVOKED
00014 #include "resource.h"
00015
00016 // window ids
00017 #define ID_EDITCHILD    500
00018
00019 // string constants
00020
00021 #define IDS_DIALOGFAILURE     1
00022 #define IDS_STRUCTSIZE        2
00023 #define IDS_INITIALIZATION    3
00024 #define IDS_NOTEMPLATE        4
00025 #define IDS_NOHINSTANCE       5
00026 #define IDS_LOADSTRFAILURE    6
00027 #define IDS_FINDRESFAILURE    7
00028 #define IDS_LOADRESFAILURE    8
00029 #define IDS_LOCKRESFAILURE    9
00030 #define IDS_MEMALLOCFAILURE  10
00031 #define IDS_MEMLOCKFAILURE   11
00032 #define IDS_NOHOOK           12
00033 #define IDS_SETUPFAILURE     13
00034 #define IDS_PARSEFAILURE     14
00035 #define IDS_RETDEFFAILURE    15
00036 #define IDS_LOADDRVFAILURE   16
00037 #define IDS_GETDEVMODEFAIL   17
00038 #define IDS_INITFAILURE      18
00039 #define IDS_NODEVICES        19
00040 #define IDS_NODEFAULTPRN     20
00041 #define IDS_DNDMMISMATCH     21
00042 #define IDS_CREATEICFAILURE  22
00043 #define IDS_PRINTERNOTFOUND  23
00044 #define IDS_NOFONTS          24
00045 #define IDS_SUBCLASSFAILURE  25
00046 #define IDS_INVALIDFILENAME  26
00047 #define IDS_BUFFERTOOSMALL   27
00048 #define IDS_FILTERSTRING     28
00049 #define IDS_UNKNOWNERROR     29
00050
00051 // constants
00052
00053 #define MAX_PATH             260
00054
00055 // Function prototypes
00056
00057 // procs
00058 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
00059 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
00060 LRESULT CALLBACK EnterNew(HWND, UINT, WPARAM, LPARAM);
00061 LRESULT CALLBACK ComDlg32DlgProc(HWND, UINT, WPARAM, LPARAM);
00062
00063 //functions
00064 BOOL InitApplication(HANDLE);
00065 BOOL InitInstance(HANDLE, int);
00066 BOOL OpenTheFile( HWND, HWND );
00067 void ProcessCDError(DWORD, HWND);
00068 BOOL NEAR PASCAL TestNotify(HWND, LPOFNOTIFY);
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/onenumdisks.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

onenumdisks.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  OnEnumDisks.cpp
00006 //
00007 // Description:
00008 //  This file implements the OnEnumDisks() routine which
00009 //    demonstrates simple instance enumeration.
00010 //
00011 // History:
00012 //
00013 // **************************************************************************
00014
00015 #include "stdafx.h"
00016 #include "AdvClientDlg.h"
00017
00018 #define TIMEOUT -1
00019 // **************************************************************************
00020 //
00021 //  CAdvClientDlg::OnEnumdisks()
00022 //
00023 // Description:
00024 //    Enumerates all the disks on a machine. Demonstrates getting
00025 //    known properties directly.
00026 //
00027 // Parameters:
00028 //    None.
00029 //
00030 // Returns:
00031 //    Nothing.
00032 //
00033 // Globals accessed:
00034 //    None.
00035 //
00036 // Globals modified:
00037 //    None.
00038 //
00039 //===========================================================================
00040 void CAdvClientDlg::OnEnumdisks()
00041 {
00042   // these are for enumerating.
00043   HRESULT  hRes;
00044   ULONG uReturned;
00045   IWbemClassObject *pStorageDev = NULL;
00046   IEnumWbemClassObject *pEnumStorageDevs = NULL;
00047
00048   // these help get properties.
00049   VARIANT pVal;
00050   BSTR propName = NULL;
00051     CString buf;
00052
00053   // here's what we're looking for.
00054   // NOTE: make sure you specify a class that has a Provider()
00055   //  specified for it in the mof file. All other classes are
00056   //  abstract and wont be found using HMM_FLAG_SHALLOW. They
00057   //  will be found using HMM_FLAG_DEEP.
00058   BSTR className = SysAllocString(L"Win32_LogicalDisk");
00059   if (!className)
00060   {
00061     TRACE(_T("SysAllocString failed: not enough memory\n"));
00062     return;
00063   }
00064
00065   // setup for the "__RELPATH" system property.
00066   propName = SysAllocString(L"__RELPATH");
00067   if (!propName)
00068   {
00069     SysFreeString(className);
00070     TRACE(_T("SysAllocString failed: not enough memory\n"));
00071     return;
00072   }
00073
00074   VariantInit(&pVal);
00075
00076   m_outputList.ResetContent();
00077   m_outputList.AddString(_T("working..."));
00078
00079   TRACE(_T("Going for class\n"));
00080
00081   //---------------------------
00082   // get the list of logical storage devices.
00083     if ((hRes = m_pIWbemServices->CreateInstanceEnum(className,
00084                         WBEM_FLAG_SHALLOW,
00085                         NULL,
00086                         &pEnumStorageDevs)) == S_OK)
00087   {
00088     TRACE(_T("good enumerator\n"));
00089
00090     m_outputList.ResetContent();
00091
00092     uReturned = 1;
00093     while(uReturned == 1)
00094     {
00095       //---------------------------
00096       // enumerate through the resultset.
00097       hRes = pEnumStorageDevs->Next(TIMEOUT,
00098                     1,
00099                     &pStorageDev,
00100                     &uReturned);
00101
00102       TRACE(_T("Next() %d:%s\n"), uReturned, ErrorString(hRes));
00103
00104       // was one found?
00105       if((hRes == S_OK) && (uReturned == 1))
00106       {
00107
00108         TRACE(_T("Got a device class\n"));
00109
00110         VariantClear(&pVal);
00111
00112
00113         // Add the path
00114         if (pStorageDev->Get(propName,
00115                     0L,
00116                     &pVal,
00117                     NULL, NULL) == S_OK)
00118         {
00119           TRACE(_T("Got a device path\n"));
00120            buf = V_BSTR(&pVal);
00121         }
00122
00123         // add to the output listbox.
00124         m_outputList.AddString(buf);
00125
00126         // cleanup for next loop
00127         VariantInit(&pVal);
00128
00129         // Done with this object.
00130         if (pStorageDev)
00131         {
00132           pStorageDev->Release();
00133
00134           // NOTE: pStorageDev MUST be set to NULL for the next all to Next().
00135           pStorageDev = NULL;
00136         }
00137
00138       } // endif (hRes == S_OK)
00139
00140         } // endwhile
00141
00142     TRACE(_T("done enumming: %s\n"), ErrorString(hRes));
00143
00144     // Done with this enumerator.
00145     if (pEnumStorageDevs)
00146     {
00147       pEnumStorageDevs->Release();
00148       pEnumStorageDevs = NULL;
00149     }
00150     }
00151   else // CreateInstanceEnum() failed.
00152   {
00153     TRACE(_T("CreateInstanceEnum() failed: %s\n"), ErrorString(hRes));
00154
00155   } // endif CreateInstanceEnum()
00156
00157   TRACE(_T("returning\n"));
00158 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/CacheProxy/cplusplus/proxypluginimpl.h Source File

  • Multimedia
  • WindowsMediaServices9
  • CacheProxy
  • cplusplus

proxypluginimpl.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName:            ProxyPluginImpl.h
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011
00012 #pragma once
00013
00014 #ifndef __PROXYPLUGINIMPL_H_
00015 #define __PROXYPLUGINIMPL_H_
00016
00017 #include "resource.h"       // main symbols
00018
00019 #include "WMSBasicPlugin.h"
00020 #include "StreamCache.h"
00021 #include "ProxyPlugin.h"
00022 #include "wmscontext.h"
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //
00026 // CProxyPlugin
00027 //
00028 /////////////////////////////////////////////////////////////////////////////
00029 class ATL_NO_VTABLE CProxyPlugin :
00030         public CComObjectRootEx<CComMultiThreadModel>,
00031         public CComCoClass<CProxyPlugin, &CLSID_ProxyPlugin>,
00032         public IWMSCacheProxy,
00033         public IWMSCacheProxyServerCallback,
00034         public IWMSBasicPlugin
00035 {
00036 public:
00037                     CProxyPlugin();
00038     virtual         ~CProxyPlugin();
00039
00040 DECLARE_REGISTRY_RESOURCEID(IDR_PROXYPLUGIN)
00041 DECLARE_NOT_AGGREGATABLE(CProxyPlugin)
00042 DECLARE_GET_CONTROLLING_UNKNOWN()
00043 DECLARE_PROTECT_FINAL_CONSTRUCT()
00044
00045 BEGIN_COM_MAP(CProxyPlugin)
00046     COM_INTERFACE_ENTRY(IWMSCacheProxy)
00047     COM_INTERFACE_ENTRY(IWMSCacheProxyServerCallback)
00048     COM_INTERFACE_ENTRY(IWMSBasicPlugin)
00049 END_COM_MAP()
00050
00051     //
00052     // IWMSCacheProxy
00053     //
00054     HRESULT STDMETHODCALLTYPE QueryCache(
00055                     BSTR bstrOriginUrl,
00056                     IWMSContext *pUserContext,
00057                     IWMSCommandContext *pCommandContext,
00058                     IWMSContext *pPresentationContext,
00059                     long QueryType,
00060                     IWMSCacheProxyCallback *pCallback,
00061                     VARIANT varContext
00062                     );
00063     HRESULT STDMETHODCALLTYPE QueryCacheMissPolicy(
00064                     BSTR bstrOriginUrl,
00065                     IWMSContext *pUserContext,
00066                     IWMSCommandContext *pCommandContext,
00067                     IWMSContext *pPresentationContext,
00068                     IUnknown *pCachePluginContext,
00069                     long QueryType,
00070                     IWMSCacheProxyCallback *pCallback,
00071                     VARIANT varContext
00072                     );
00073
00074     HRESULT STDMETHODCALLTYPE RemoveCacheItem(
00075                     BSTR bstrOriginUrl,
00076                     IWMSCacheProxyCallback *pCallback,
00077                     VARIANT varContext
00078                     )
00079     {
00080         return( E_NOTIMPL );
00081     }
00082     HRESULT STDMETHODCALLTYPE RemoveAllCacheItems(
00083                     IWMSCacheProxyCallback *pCallback,
00084                     VARIANT varContext
00085                     )
00086     {
00087         return( E_NOTIMPL );
00088     }
00089     HRESULT STDMETHODCALLTYPE AddCacheItem(
00090                     BSTR bstrOriginUrl,
00091                     BSTR bstrPrestuffUrl,
00092                     long lExpiration,
00093                     long lBandwidth,
00094                     long lRemoteEventFlags,
00095                     IWMSCacheProxyCallback *pCallback,
00096                     VARIANT varContext
00097                     )
00098     {
00099         return( E_NOTIMPL );
00100     }
00101     HRESULT STDMETHODCALLTYPE QuerySpaceForCacheItem(
00102                     long lContentSizeLow,
00103                     long lContentSizeHigh,
00104                     VARIANT_BOOL *pvarfSpaceAvail
00105                     )
00106     {
00107         return( E_NOTIMPL );
00108     }
00109     HRESULT STDMETHODCALLTYPE FindCacheItem(
00110                     BSTR pszOriginUrl,
00111                     IWMSCacheItemDescriptor **ppCacheItemDescriptor
00112                     )
00113     {
00114         return( E_NOTIMPL );
00115     }
00116     HRESULT STDMETHODCALLTYPE CreateCacheItemCollection(
00117                     IWMSCacheItemCollection **ppCacheItemCollection
00118                     )
00119     {
00120         return( E_NOTIMPL );
00121     }
00122     HRESULT STDMETHODCALLTYPE OnCacheClientClose(
00123                     HRESULT resultHr,
00124                     IWMSContext *pUserContext,
00125                     IWMSContext *pPresentationContext
00126                     );
00127
00128     //
00129     // IWMSCacheProxyServerCallback
00130     //
00131     HRESULT STDMETHODCALLTYPE OnGetContentInformation(
00132                     long lHr,
00133                     IWMSContext *pContentInfo,
00134                     VARIANT varContext
00135                     );
00136     HRESULT STDMETHODCALLTYPE OnCompareContentInformation(
00137                     long lHr,
00138                     WMS_CACHE_VERSION_COMPARE_RESPONSE CompareResponse,
00139                     IWMSContext *pNewContentInfo,
00140                     VARIANT varContext
00141                     )
00142     {
00143         return( E_NOTIMPL );
00144     }
00145     HRESULT STDMETHODCALLTYPE OnDownloadContentProgress(
00146                     long lHr,
00147                     WMS_RECORD_PROGRESS_OPCODE opCode,
00148                     IWMSContext *pArchiveContext,
00149                     VARIANT varContext
00150                     )
00151     {
00152         return( E_NOTIMPL );
00153     }
00154     HRESULT STDMETHODCALLTYPE OnDownloadContentFinished(
00155                     long lHr,
00156                     SAFEARRAY *psaArchiveContexts,
00157                     VARIANT varContext
00158                     )
00159     {
00160         return( E_NOTIMPL );
00161     }
00162     HRESULT STDMETHODCALLTYPE OnCancelDownloadContent(
00163                     long lHr,
00164                     VARIANT varContext
00165                     )
00166     {
00167         return( E_NOTIMPL );
00168     }
00169
00170     //
00171     // IWMSBasicPlugin
00172     //
00173     HRESULT STDMETHODCALLTYPE InitializePlugin(
00174                     IWMSContext *pServerContext,
00175                     IWMSNamedValues *pNamedValues,
00176                     IWMSClassObject *pClassFactory
00177                     );
00178     HRESULT STDMETHODCALLTYPE ShutdownPlugin();
00179     HRESULT STDMETHODCALLTYPE GetCustomAdminInterface(
00180                     IDispatch **ppValue
00181                     );
00182     HRESULT STDMETHODCALLTYPE OnHeartbeat();
00183     HRESULT STDMETHODCALLTYPE EnablePlugin(
00184                     long *pdwFlags,
00185                     long *pdwHeartbeatPeriod );
00186     HRESULT STDMETHODCALLTYPE DisablePlugin();
00187
00188 private:
00189     class COpState : public IUnknown
00190     {
00191     public:
00192         enum OpTypes
00193         {
00194             OP_QUERY_CACHE,
00195             OP_QUERY_CACHE_MISS_POLICY
00196         };
00197
00198         OpTypes                   m_Op;
00199         CComBSTR                  m_bstrOriginUrl;
00200         CComBSTR                  m_bstrProtocol;
00201         CComBSTR                  m_bstrHost;
00202         CComBSTR                  m_bstrPath;
00203         IWMSContext              *m_pPresentationContext;
00204         IWMSCacheProxyCallback   *m_pCacheProxyCallback;
00205         CComVariant               m_varContext;
00206         DWORD                     m_dwProtocolIndex;
00207         WORD                      m_wPort;
00208
00209         COpState()
00210         {
00211             m_cRef = 1;
00212             m_pPresentationContext = NULL;
00213             m_pCacheProxyCallback = NULL;
00214             m_wPort = 0;
00215         }
00216
00217         ~COpState()
00218         {
00219             if( NULL != m_pPresentationContext )
00220             {
00221                 m_pPresentationContext->Release();
00222             }
00223
00224             if( NULL != m_pCacheProxyCallback )
00225             {
00226                 m_pCacheProxyCallback->Release();
00227             }
00228         }
00229
00230         STDMETHOD_(ULONG, AddRef)()
00231         {
00232             ULONG cRef = InterlockedIncrement( &m_cRef );
00233
00234             return( cRef );
00235         }
00236
00237         STDMETHOD_(ULONG, Release)()
00238         {
00239             ULONG cRef = InterlockedDecrement( &m_cRef );
00240             if( 0 == cRef )
00241             {
00242                 delete this;
00243                 return( 0 );
00244             }
00245
00246             return( cRef );
00247         }
00248
00249         STDMETHOD( QueryInterface )( REFIID riid, void **ppvObject )
00250         {
00251             if( NULL == ppvObject )
00252             {
00253                 return( E_POINTER );
00254             }
00255
00256             *ppvObject = NULL;
00257
00258             if( IID_IUnknown == riid )
00259             {
00260                 AddRef();
00261                 *ppvObject = ( IUnknown *) this;
00262                 return( S_OK );
00263             }
00264
00265             return( E_NOINTERFACE );
00266         }
00267
00268     private:
00269         LONG m_cRef;
00270     };
00271
00272     BOOL ParseUrl( BSTR bstrUrl,
00273                    BSTR *pbstrProtocol,
00274                    BSTR *pbstrHost,
00275                    BSTR *pbstrPath,
00276                    WORD *pwPort
00277                    );
00278
00279     IWMSCacheProxyServer *m_pICacheProxyServer;
00280 };
00281
00282 #endif //__PROXYPLUGINIMPL_H_
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CounterInfoBlock Member List

This is the complete list of members for _CounterInfoBlock, including all inherited members.
dLastValue | _CounterInfoBlock
dwFirstIndex | _CounterInfoBlock
dwLastIndex | _CounterInfoBlock
dwNextIndex | _CounterInfoBlock
hCounter | _CounterInfoBlock
pCounterArray | _CounterInfoBlock
pdhCurrentStats | _CounterInfoBlock
pNext | _CounterInfoBlock
szCounterPath | _CounterInfoBlock
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllServe/Sample.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllServe

Sample.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SAMPLE.CPP
00003
00004   Summary:   Implementation file for the COCarSample sample utility COM
00005              object.  This object exposes the ISample interface
00006              that is used to allow better integration of server with
00007              client as a code sample (eg, set up trace logging from
00008              server to client's log display).
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial DLLSERVE.HTM file.
00012              For more specific technical details on the internal workings
00013              see the comments dispersed throughout the module's source code.
00014
00015   Classes:   COCarSample.
00016
00017   Functions:
00018
00019   Origin:    9-11-95: atrent - Editor-inheritance from COMOBJ.CPP in
00020                the COMOBJ Tutorial Code Sample.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 /*---------------------------------------------------------------------------
00038   We include WINDOWS.H for all Win32 applications.
00039   We include OLE2.H because we will be calling the COM/OLE Libraries.
00040   We include APPUTIL.H because we will be building this DLL using
00041     the convenient Virtual Window and Dialog classes and other
00042     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00043   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00044     class, GUID, and CLSID specifications.
00045   We include SERVER.H for the object class declarations for the
00046     CServer server control object.
00047   We include SAMPLE.H for the object class declarations for the
00048     COCarSample COM object.
00049 ---------------------------------------------------------------------------*/
00050 #include <windows.h>
00051 #include <ole2.h>
00052 #include <apputil.h>
00053 #include <icars.h>
00054 #include <carguids.h>
00055 #include "server.h"
00056 #include "sample.h"
00057
00058 /*---------------------------------------------------------------------------
00059   Implementation the COCarSample COM object.  Used to expose a utility
00060   server interface for the server as a code sample.  COCarSample exposes
00061   the ISample interface.
00062 ---------------------------------------------------------------------------*/
00063
00064 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00065   Method:   COCarSample::COCarSample
00066
00067   Summary:  COCarSample Constructor. Note the member initializer:
00068             "m_ImpISample(this, pUnkOuter, pServer)" which is used to pass
00069             the 'this', pUnkOuter, and pServer pointers of this
00070             constructor function to the constructor in the instantiation
00071             of the implementation of the CImpISample interface (which is
00072             nested inside this present COCarSample Object Class).
00073
00074   Args:     IUnknown* pUnkOuter,
00075               Pointer to the the outer Unknown.  NULL means this COM Object
00076               is not being Aggregated.  Non NULL means it is being created
00077               on behalf of an outside COM object that is reusing it via
00078               aggregation.
00079             CServer* pServer
00080               Pointer to the server's control object.
00081
00082   Modifies: m_cRefs, m_pUnkOuter.
00083
00084   Returns:  void
00085 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00086 COCarSample::COCarSample(
00087   IUnknown* pUnkOuter,
00088   CServer* pServer) :
00089   m_ImpISample(this, pUnkOuter, pServer)
00090 {
00091   // Zero the COM object's reference count.
00092   m_cRefs = 0;
00093
00094   // No AddRef necessary if non-NULL, as we're nested.
00095   m_pUnkOuter = pUnkOuter;
00096
00097   // Init the pointer to the server's control object.
00098   m_pServer = pServer;
00099
00100   LOGF1("S: COCarSample Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00101
00102   return;
00103 }
00104
00105
00106 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00107   Method:   COCarSample::~COCarSample
00108
00109   Summary:  COCarSample Destructor.
00110
00111   Args:     void
00112
00113   Returns:  void
00114 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00115 COCarSample::~COCarSample(void)
00116 {
00117   LOG("S: COCarSample::Destructor.");
00118
00119   return;
00120 }
00121
00122
00123 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00124   Method:   COCarSample::QueryInterface
00125
00126   Summary:  QueryInterface of the COCarSample non-delegating
00127             IUnknown implementation.
00128
00129   Args:     REFIID riid,
00130               [in] GUID of the Interface being requested.
00131             PPVOID ppv)
00132               [out] Address of the caller's pointer variable that will
00133               receive the requested interface pointer.
00134
00135   Returns:  HRESULT
00136 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00137 STDMETHODIMP COCarSample::QueryInterface(
00138                REFIID riid,
00139                PPVOID ppv)
00140 {
00141   HRESULT hr = E_NOINTERFACE;
00142   *ppv = NULL;
00143
00144   if (IID_IUnknown == riid)
00145   {
00146     *ppv = this;
00147     LOG("S: COCarSample::QueryInterface. 'this' pIUnknown returned.");
00148   }
00149   else if (IID_ISample == riid)
00150   {
00151     *ppv = &m_ImpISample;
00152     LOG("S: COCarSample::QueryInterface. pISample returned.");
00153   }
00154
00155   if (NULL != *ppv)
00156   {
00157     // We've handed out a pointer to the interface so obey the COM rules
00158     // and AddRef the reference count.
00159     ((LPUNKNOWN)*ppv)->AddRef();
00160     hr = NOERROR;
00161   }
00162
00163   return (hr);
00164 }
00165
00166
00167 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00168   Method:   COCarSample::AddRef
00169
00170   Summary:  AddRef of the COCarSample non-delegating IUnknown implementation.
00171
00172   Args:     void
00173
00174   Modifies: m_cRefs.
00175
00176   Returns:  ULONG
00177               New value of m_cRefs (COM object's reference count).
00178 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00179 STDMETHODIMP_(ULONG) COCarSample::AddRef(void)
00180 {
00181   m_cRefs++;
00182
00183   LOGF1("S: COCarSample::AddRef. New cRefs=%i.", m_cRefs);
00184
00185   return m_cRefs;
00186 }
00187
00188
00189 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00190   Method:   COCarSample::Release
00191
00192   Summary:  Release of the COCarSample non-delegating IUnknown
00193             implementation.
00194
00195   Args:     void
00196
00197   Modifies: m_cRefs.
00198
00199   Returns:  ULONG
00200               New value of m_cRefs (COM object's reference count).
00201 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00202 STDMETHODIMP_(ULONG) COCarSample::Release(void)
00203 {
00204   m_cRefs--;
00205
00206   LOGF1("S: COCarSample::Release. New cRefs=%i.", m_cRefs);
00207
00208   if (0 == m_cRefs)
00209   {
00210     // We've reached a zero reference count for this COM object.
00211     // So we tell the server housing to decrement its global object
00212     // count so that the server will be unloaded if appropriate.
00213     if (NULL != m_pServer)
00214       m_pServer->ObjectsDown();
00215
00216     // We artificially bump the main ref count to prevent reentrancy
00217     // via the main object destructor.  Not really needed in this
00218     // COCarSample but a good practice because we are aggregatable and
00219     // may at some point in the future add something entertaining like
00220     // some Releases to the COCarSample destructor.
00221     m_cRefs++;
00222     delete this;
00223   }
00224
00225   return m_cRefs;
00226 }
00227
00228
00229 /*---------------------------------------------------------------------------
00230   COCarSample's nested implementation of the ISample interface
00231   including Constructor, Destructor, QueryInterface, AddRef, Release,
00232   Init, and AboutBox methods.
00233 ---------------------------------------------------------------------------*/
00234
00235 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00236   Method:   COCarSample::CImpISample::CImpISample
00237
00238   Summary:  Constructor for the CImpISample interface instantiation.
00239
00240   Args:     COCarSample* pBackObj,
00241               Back pointer to the parent outer object.
00242             IUnknown* pUnkOuter,
00243               Pointer to the outer Unknown.  For delegation.
00244             CServer* pServer)
00245               Pointer to the server's control object.
00246
00247   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
00248
00249   Returns:  void
00250 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00251 COCarSample::CImpISample::CImpISample(
00252   COCarSample* pBackObj,
00253   IUnknown* pUnkOuter,
00254   CServer* pServer)
00255 {
00256   // Init the Interface Ref Count (used for debugging only).
00257   m_cRefI = 0;
00258
00259   // Init the Back Object Pointer to point to the outer object.
00260   m_pBackObj = pBackObj;
00261
00262   // Init the pointer to the server control object.
00263   m_pServer = pServer;
00264
00265   // Init the CImpISample interface's delegating Unknown pointer.  We use
00266   // the Back Object pointer for IUnknown delegation here if we are not
00267   // being aggregated.  If we are being aggregated we use the supplied
00268   // pUnkOuter for IUnknown delegation.  In either case the pointer
00269   // assignment requires no AddRef because the CImpISample lifetime is
00270   // quaranteed by the lifetime of the parent object in which
00271   // CImpISample is nested.
00272   if (NULL == pUnkOuter)
00273   {
00274     m_pUnkOuter = pBackObj;
00275     LOG("S: COCarSample::CImpISample Constructor. Non-Aggregating.");
00276   }
00277   else
00278   {
00279     m_pUnkOuter = pUnkOuter;
00280     LOG("S: COCarSample::CImpISample Constructor. Aggregating.");
00281   }
00282
00283   return;
00284 }
00285
00286
00287 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00288   Method:   COCarSample::CImpISample::~CImpISample
00289
00290   Summary:  Destructor for the CImpISample interface instantiation.
00291
00292   Args:     void
00293
00294   Returns:  void
00295 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00296 COCarSample::CImpISample::~CImpISample(void)
00297 {
00298   LOG("S: COCarSample::CImpISample Destructor.");
00299
00300   return;
00301 }
00302
00303
00304 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00305   Method:   COCarSample::CImpISample::QueryInterface
00306
00307   Summary:  The QueryInterface IUnknown member of this ISample interface
00308             implementation that delegates to m_pUnkOuter, whatever it is.
00309
00310   Args:     REFIID riid,
00311               [in] GUID of the Interface being requested.
00312             PPVOID ppv)
00313               [out] Address of the caller's pointer variable that will
00314               receive the requested interface pointer.
00315
00316   Returns:  HRESULT
00317               Returned by the delegated outer QueryInterface call.
00318 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00319 STDMETHODIMP COCarSample::CImpISample::QueryInterface(
00320                REFIID riid,
00321                PPVOID ppv)
00322 {
00323   LOG("S: COCarSample::CImpISample::QueryInterface. Delegating.");
00324
00325   // Delegate this call to the outer object's QueryInterface.
00326   return m_pUnkOuter->QueryInterface(riid, ppv);
00327 }
00328
00329
00330 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00331   Method:   COCarSample::CImpISample::AddRef
00332
00333   Summary:  The AddRef IUnknown member of this ISample interface
00334             implementation that delegates to m_pUnkOuter, whatever it is.
00335
00336   Args:     void
00337
00338   Modifies: m_cRefI.
00339
00340   Returns:  ULONG
00341               Returned by the delegated outer AddRef call.
00342 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00343 STDMETHODIMP_(ULONG) COCarSample::CImpISample::AddRef(void)
00344 {
00345   // Increment the Interface Reference Count.
00346   ++m_cRefI;
00347
00348   LOGF1("S: COCarSample::CImpISample::Addref. Delegating. New cI=%i.", m_cRefI);
00349
00350   // Delegate this call to the outer object's AddRef.
00351   return m_pUnkOuter->AddRef();
00352 }
00353
00354
00355 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00356   Method:   COCarSample::CImpISample::Release
00357
00358   Summary:  The Release IUnknown member of this ISample interface
00359             implementation that delegates to m_pUnkOuter, whatever it is.
00360
00361   Args:     void
00362
00363   Returns:  ULONG
00364               Returned by the delegated outer Release call.
00365 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00366 STDMETHODIMP_(ULONG) COCarSample::CImpISample::Release(void)
00367 {
00368   // Decrement the Interface Reference Count.
00369   --m_cRefI;
00370
00371   LOGF1("S: COCarSample::CImpISample::Release. Delegating. New cI=%i.", m_cRefI);
00372
00373   // Delegate this call to the outer object's Release.
00374   return m_pUnkOuter->Release();
00375 }
00376
00377
00378 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00379   Method:   COCarSample::CImpISample::Init
00380
00381   Summary:  Initialize the COCarSample object to enable trace logging
00382             from server to client.  This includes passing in a pointer
00383             that points the Client EXE's MsgLog facility so that the
00384             LOG* trace logging macros in the server will be logged in
00385             the Client's message log window.
00386
00387   Args:     HWND hWndParent
00388               [in] Handle of a client's parent owning window.
00389             PVOID pvMsgLog
00390               [in] Pointer to the Client's MsgLog object.  If NULL
00391               then setup independent logging window for this DLL.
00392
00393   Returns:  HRESULT
00394               Standard result code. NOERROR for success.
00395 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00396 STDMETHODIMP COCarSample::CImpISample::Init(
00397                HWND hWndParent,
00398                PVOID pvMsgLog)
00399 {
00400   HRESULT hr = NOERROR;
00401
00402   // Init this DLL's MsgBox facility.
00403   g_pServer->m_pMsgBox->Init(g_pServer->m_hDllInst, hWndParent);
00404
00405   if (NULL != pvMsgLog)
00406   {
00407     // Set up a pointer to the client EXE's Message Log facility so
00408     // that any LOG macros used in this DLL will log to the host EXE's
00409     // log window.
00410     g_pMsgLog = (CMsgLog *)pvMsgLog;
00411     LOG("S: --- DLLSERVE.DLL now logging to Client ---");
00412   }
00413   else
00414   {
00415     // But if pvMsgLog is passed in as NULL then Create an independent
00416     // logging facility for this DLL (use the client EXE's main window
00417     // as the parent window).
00418     CMsgLog* pMsgLog = new CMsgLog;
00419
00420     if (NULL != pMsgLog)
00421     {
00422       if (pMsgLog->Create(g_pServer->m_hDllInst, hWndParent, FALSE))
00423       {
00424         g_pMsgLog = pMsgLog;
00425         LOG("S: --- DLLSERVE.DLL now logging ---");
00426       }
00427       else
00428         delete pMsgLog;
00429     }
00430   }
00431
00432   return hr;
00433 }
00434
00435
00436 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00437   Method:   COCarSample::CImpISample::AboutBox
00438
00439   Summary:  The AboutBox method commands the Server to display its own
00440             About dialog box (using resources stored in this DLL itself.
00441
00442   Args:     HWND hWnd
00443               [in] Handle of window (ie of client) that is to be parent of
00444               the About dialog window.
00445
00446   Returns:  HRESULT
00447               Standard result code.
00448 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00449 HRESULT COCarSample::CImpISample::AboutBox(
00450           HWND hWnd)
00451 {
00452   HRESULT hr = NOERROR;
00453
00454   LOG("S: COCarSample::CImpISample::AboutBox.");
00455
00456   // Define one of those nifty APPUTIL CAboutBox modal dialog objects.
00457   CAboutBox dlgAboutBox;
00458
00459   // Show the standard About Box dialog for this DLL by telling the dialog
00460   // C++ object to show itself by invoking its ShowDialog method.
00461   // Pass it this DLL instance and the parent window handle.  Use a dialog
00462   // resource ID for the dialog stored in this DLL module's resources.
00463   dlgAboutBox.ShowDialog(
00464     m_pServer->m_hDllInst,
00465     MAKEINTRESOURCE(IDD_ABOUTBOX),
00466     hWnd);
00467
00468   return hr;
00469 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cdataset.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cdataset.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CDATASET.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 //////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 /////////////////////////////////////////////////////////////////
00019 // CDataset::CDataset
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CDataset::CDataset(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CDataAccess(eCDataset, pCMainWindow, pCMDIChild)
00024 {
00025   //Dataset
00026   m_pIMDDataset   = NULL;
00027   m_pIMDFind      = NULL;
00028   m_pIMDRangeRowset = NULL;
00029
00030   //Data
00031   m_cAxis       = 0;
00032   m_rgAxisInfo    = NULL;
00033 }
00034
00035
00036 /////////////////////////////////////////////////////////////////
00037 // CDataset::~CDataset
00038 //
00039 /////////////////////////////////////////////////////////////////
00040 CDataset::~CDataset()
00041 {
00042   ReleaseObject(0);
00043 }
00044
00045
00046 /////////////////////////////////////////////////////////////////
00047 // CDataset::AutoRelease
00048 //
00049 /////////////////////////////////////////////////////////////////
00050 HRESULT CDataset::AutoRelease()
00051 {
00052   HRESULT hr = S_OK;
00053
00054   //Free the AxisInfo
00055   FreeAxisInfo(&m_cAxis, &m_rgAxisInfo);
00056
00057   //Interface
00058   RELEASE_INTERFACE(IMDDataset);
00059   RELEASE_INTERFACE(IMDFind);
00060   RELEASE_INTERFACE(IMDRangeRowset);
00061
00062   //Delegate
00063   return CDataAccess::AutoRelease();
00064 }
00065
00066
00067 ////////////////////////////////////////////////////////////////
00068 // CDataset::AutoQI
00069 //
00070 /////////////////////////////////////////////////////////////////
00071 HRESULT CDataset::AutoQI(DWORD dwCreateOpts)
00072 {
00073   //Delegate First so we have base interfaces
00074   CDataAccess::AutoQI(dwCreateOpts);
00075
00076   //[MANDATORY]
00077   if(dwCreateOpts & CREATE_QI_MANDATORY)
00078   {
00079     OBTAIN_INTERFACE(IMDDataset);
00080   }
00081
00082   //[OPTIONAL]
00083   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00084   {
00085     OBTAIN_INTERFACE(IMDFind);
00086     OBTAIN_INTERFACE(IMDRangeRowset);
00087   }
00088
00089   return S_OK;
00090 }
00091
00092
00093 /////////////////////////////////////////////////////////////////
00094 // IUnknown** CDataset::GetInterfaceAddress
00095 //
00096 /////////////////////////////////////////////////////////////////
00097 IUnknown** CDataset::GetInterfaceAddress(REFIID riid)
00098 {
00099   HANDLE_GETINTERFACE(IMDDataset);
00100   HANDLE_GETINTERFACE(IMDFind);
00101   HANDLE_GETINTERFACE(IMDRangeRowset);
00102
00103   //Otherwise delegate
00104   return CDataAccess::GetInterfaceAddress(riid);
00105 }
00106
00107
00108 /////////////////////////////////////////////////////////////////
00109 //  GetAxisInfo
00110 //
00111 //  Get the axis info for all axis in the current dataset.
00112 //  Return count and array of axis info.
00113 //
00114 /////////////////////////////////////////////////////////////////
00115 HRESULT CDataset::GetAxisInfo(DBCOUNTITEM* pcAxis, MDAXISINFO** prgAxisInfo)
00116 {
00117   HRESULT hr = E_FAIL;
00118
00119   if(m_pIMDDataset)
00120   {
00121     //IMDDataset::GetAxisInfo
00122     XTEST(hr = m_pIMDDataset->GetAxisInfo(pcAxis, prgAxisInfo));
00123     TESTC(TRACE_METHOD(hr, L"IMDDataset::GetAxisInfo(%lu, &0x%p)", pcAxis ? *pcAxis : 0, prgAxisInfo ? *prgAxisInfo : NULL));
00124   }
00125
00126 CLEANUP:
00127   return hr;
00128 }
00129
00130
00131 /////////////////////////////////////////////////////////////////
00132 //  FreeAxisInfo
00133 //
00134 /////////////////////////////////////////////////////////////////
00135 HRESULT CDataset::FreeAxisInfo(DBCOUNTITEM* pcAxis, MDAXISINFO** prgAxisInfo)
00136 {
00137   HRESULT hr = E_FAIL;
00138   ASSERT(pcAxis && prgAxisInfo);
00139
00140   if(m_pIMDDataset)
00141   {
00142     //IMDDataset::FreeAxisInfo
00143     XTEST(hr = m_pIMDDataset->FreeAxisInfo(*pcAxis, *prgAxisInfo));
00144     TESTC(TRACE_METHOD(hr, L"IMDDataset::FreeAxisInfo(%lu, &0x%p)", *pcAxis, *prgAxisInfo));
00145   }
00146
00147   //NULL output pointers
00148   *pcAxis     = 0;
00149   *prgAxisInfo  = NULL;
00150
00151 CLEANUP:
00152   return hr;
00153 }
00154
00155
00156
00157 /////////////////////////////////////////////////////////////////
00158 // HRESULT CDataset::GetCellData
00159 //
00160 /////////////////////////////////////////////////////////////////
00161 HRESULT CDataset::GetCellData(DBORDINAL ulStartCell, DBORDINAL ulEndCell)
00162 {
00163   HRESULT hr = E_FAIL;
00164
00165   if(m_pIMDDataset)
00166   {
00167     //NOTE: Using cbRowSize of IAccessor::CreateAccessor
00168     //Because this method fetches properties for more than one cell,
00169     //the provider should know how long each row is. In this context, a "row" means the area
00170     //allocated in the consumer's buffer to hold all properties pertaining to one cell.
00171     //This information should be given in the cbRowSize parameter of IAccessor::CreateAccessor.
00172     //If the value of this parameter is zero, the consumer wants to fetch only one row of data
00173     //(one cell). In this case, it is an error to specify a ulStartCell different from the
00174     //ulEndCell.
00175
00176     //Because of the above in the OLAP spec, we need to make sure our buffer is large enough
00177     //to hold the number of requested cells...
00178     if(ulEndCell > ulStartCell && m_cbRowSize)
00179       SAFE_REALLOC(m_pData, BYTE, m_cbRowSize * (ulEndCell - ulStartCell + 1));
00180
00181     //IMDDataset::GetCellData
00182     XTEST(hr = m_pIMDDataset->GetCellData(m_hAccessor, ulStartCell, ulEndCell, m_pData));
00183     TESTC(TRACE_METHOD(hr, L"IMDDataset::GetCellData(0x%p, 0x%ld, 0x%ld, 0x%p)", m_hAccessor, ulStartCell, ulEndCell, m_pData));
00184   }
00185
00186 CLEANUP:
00187   return hr;
00188 }
00189
00190 ////////////////////////////////////////////////////////////////
00191 //  GetAxisRowset
00192 //
00193 //  Get the axis info and rowset for the first axis.
00194 //  Return IRowset interface for the axis rowset.
00195 //
00196 /////////////////////////////////////////////////////////////////
00197 HRESULT CDataset::GetAxisRowset(CAggregate* pCAggregate, DBCOUNTITEM iAxis, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown)
00198 {
00199   HRESULT hr = E_FAIL;
00200
00201   if(m_pIMDDataset)
00202   {
00203     //GetAxisInfo (if not already)
00204     if(m_cAxis == 0)
00205       TESTC(hr = GetAxisInfo(&m_cAxis, &m_rgAxisInfo));
00206
00207     //GetAxisRowset
00208     if(m_cAxis)
00209     {
00210       XTEST_(hr = m_pIMDDataset->GetAxisRowset(
00211                       pCAggregate,
00212                       iAxis,
00213                       riid,
00214                       cPropSets,
00215                       rgPropSets,
00216                       ppIUnknown),S_OK);
00217       TRACE_METHOD(hr, L"IMDDataset::GetAxisRowset(0x%p, %d, %s, %d, 0x%p, &0x%p)", pCAggregate, iAxis, GetInterfaceName(riid), cPropSets, rgPropSets, ppIUnknown ? *ppIUnknown : NULL);
00218     }
00219
00220     //Display Errors (if occurred)
00221     TESTC(hr = DisplayPropErrors(hr, cPropSets, rgPropSets));
00222
00223     //Handle Aggregation
00224     if(pCAggregate)
00225       TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00226   }
00227
00228 CLEANUP:
00229   return hr;
00230 }
00231
00232
00233 /////////////////////////////////////////////////////////////////
00234 // HRESULT CDataset::DisplayObject
00235 //
00236 /////////////////////////////////////////////////////////////////
00237 HRESULT CDataset::DisplayObject()
00238 {
00239   HRESULT hr = S_OK;
00240
00241   BINDCOLS eBindCols = (GetOptions()->m_dwAccessorOpts & ACCESSOR_BIND_BOOKMARK ? BIND_ALLCOLS : BIND_ALLCOLSEXPECTBOOKMARK);
00242   if(m_pCMDIChild)
00243   {
00244     //Reset Cursor
00245     m_pCMDIChild->m_pCDataGrid->m_fLastFetchForward = FALSE;
00246     m_pCMDIChild->m_pCDataGrid->m_lCurPos = 0;
00247
00248     //First Clear the existing Window...
00249     TESTC(hr = m_pCMDIChild->m_pCDataGrid->ClearAll());
00250   }
00251
00252   //Create ColumnInfo
00253   TESTC(hr = GetColInfo());
00254
00255   //Create Accessors and Setup bindings
00256   TESTC(hr = CreateAccessors(eBindCols));
00257
00258   if(m_pCMDIChild)
00259   {
00260     //Refresh the Columns and Rows
00261     TESTC(hr = m_pCMDIChild->m_pCDataGrid->RefreshData());
00262   }
00263
00264   //Display the object...
00265   TESTC(hr = CDataAccess::DisplayObject());
00266
00267 CLEANUP:
00268   if(m_pCMDIChild)
00269     m_pCMDIChild->UpdateControls();
00270   return hr;
00271 }
Generated on Wed Nov 13 2024 16:52:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CGetInfoExDlg Member List

This is the complete list of members for CGetInfoExDlg, including all inherited members.
CGetInfoExDlg(CWnd *pParent=NULL) | CGetInfoExDlg |
DoDataExchange(CDataExchange *pDX) | CGetInfoExDlg | [protected, virtual]
GetAttribute() | CGetInfoExDlg | [inline]
IDD enum value | CGetInfoExDlg |
m_sAttr | CGetInfoExDlg | [protected]
m_sAttrText | CGetInfoExDlg |
OnOK() | CGetInfoExDlg | [protected, virtual]
Generated on Wed Nov 13 2024 16:56:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CIntTrace Member List

This is the complete list of members for CIntTrace, including all inherited members.
Append(LPCWSTR pwszString, bool bCanUndo=TRUE, DWORD dwMask=0, DWORD dwColor=0) | CRichEditLite | [virtual]
CanPaste() | CEditBoxLite | [inline]
CConsole() | CConsole | [inline]
CEditBoxLite(HWND hWndParent=NULL, UINT nID=0) | CEditBoxLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CIntTrace(CMainWindow *pCMainWindow) | CIntTrace |
Clear() | CIntTrace | [virtual]
Copy() | CEditBoxLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CRichEditLite(HWND hWndParent=NULL, UINT nID=0) | CRichEditLite |
CSplitterLite(HWND hWndParent=NULL, UINT nID=0) | CSplitterLite |
Cut() | CEditBoxLite | [inline]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DrawSplitter(HDC hDC, BOOL fVertical, REFRECT rectLeft, REFRECT rectRight, REFPOINTS ptsClient) | CSplitterLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
FindNext(DWORD dwFindFlags, WCHAR *pwszText) | CRichEditLite | [virtual]
FindText(DWORD dwFindFlags, FINDTEXTEXW *pFINDTEXT) | CRichEditLite | [virtual]
GetConsole() | CConsole | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetLine(INDEX iLine, CHAR *pszBuffer, ULONG ulMaxSize) | CEditBoxLite |
GetLineCount() | CEditBoxLite | [inline]
GetOptions() | CIntTrace | [virtual]
GetSel(INDEX *piMin, INDEX *piMax) | CRichEditLite | [inline, virtual]
GetSel(CHARRANGE *pcr) | CRichEditLite | [inline, virtual]
CEditBoxLite::GetSel(INDEX *piMin, INDEX *piMax) | CEditBoxLite | [inline, virtual]
CEditBoxLite::GetSel(CHARRANGE *pcr) | CEditBoxLite | [inline, virtual]
GetSelectedText(BOOL fEntireLine=TRUE) | CRichEditLite |
GetTextRange(CHARRANGE &cr, WCHAR *pwszBuffer) | CEditBoxLite |
GetTextRange(CHARRANGE &cr, CHAR *pszBuffer) | CEditBoxLite |
GetTrace() | CIntTrace | [static]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
LineFromChar(INDEX nIndex) | CRichEditLite | [inline]
LineIndex(INDEX nLine) | CEditBoxLite | [inline]
LineLength(INDEX nStartChar) | CEditBoxLite | [inline]
LineScroll(INDEX nLines, INDEX nChars=0) | CEditBoxLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hCursorOld | CSplitterLite |
m_hCursorRight | CSplitterLite |
m_hCursorTop | CSplitterLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iBorderCX | CSplitterLite |
m_iBorderCY | CSplitterLite |
m_nID | CWndLite |
m_pCMainWindow | CIntTrace |
m_pCWndBottom | CSplitterLite |
m_pCWndLeft | CSplitterLite |
m_pCWndRight | CSplitterLite |
m_pCWndTop | CSplitterLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_pwszNewLine | CConsole | [protected]
m_ulNestingLevel | CIntTrace |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnBorder(REFPOINTS pts, INT iBorder) | CSplitterLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CIntTrace | [virtual]
CRichEditLite::OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CIntTrace | [virtual]
CRichEditLite::OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CRichEditLite | [virtual]
CEditBoxLite::OnCreate(CREATESTRUCT *pCREATESTRUCT) | CEditBoxLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLink(INT idCtrl, ENLINK *pEnLink) | CRichEditLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CRichEditLite | [virtual]
CEditBoxLite::OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CIntTrace | [virtual]
CRichEditLite::OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CIntTrace | [virtual]
CRichEditLite::OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnUpdateOutputSelected() | CIntTrace | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
operator<<(LPCWSTR pwsz) | CConsole | [inline, virtual]
operator<<(COLORREF refColor) | CConsole | [inline, virtual]
operator<<(COLORA attColor) | CConsole | [inline, virtual]
OutputIndent(ULONG cIndentLevel) | CIntTrace | [virtual]
OutputLineEnd() | CIntTrace | [virtual]
OutputText(DWORD dwMask, COLORREF dwColor, WCHAR *pwszText) | CIntTrace | [virtual]
OutputTextFmt(DWORD dwMask, COLORREF dwColor, WCHAR *pwszFmt,...) | CIntTrace | [virtual]
Paste() | CEditBoxLite | [inline]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
ReplaceAll(LPCWSTR pwszString, bool bReplaceAll=FALSE, bool fHighlight=FALSE) | CEditBoxLite | [virtual]
ReplaceSel(LPCWSTR pwszString, bool bCanUndo) | CRichEditLite | [inline, virtual]
ReplaceSel(LPCWSTR pwszString, bool bCanUndo, DWORD dwMask, DWORD dwColor) | CRichEditLite | [virtual]
CEditBoxLite::ReplaceSel(LPCWSTR pwszString, bool bCanUndo) | CEditBoxLite | [inline, virtual]
Save(LPCWSTR pwszFileName) | CEditBoxLite |
ScrollCaret() | CEditBoxLite | [inline]
SetCharFormat(DWORD dwMask, CHARFORMATW &charFormatW) | CRichEditLite |
SetColor(COLORREF refColor) | CRichEditLite | [inline, virtual]
SetColorAttrib(COLORA attColor, BOOL fEnable=TRUE) | CRichEditLite | [inline, virtual]
SetDefaultFont() | CRichEditLite |
SetEffects(DWORD dwMask, DWORD dwEffects, COLORREF crTextColor) | CRichEditLite |
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetOptions(UINT dwOptions, UINT fOperation=ECOOP_OR) | CEditBoxLite | [inline]
SetReadOnly(bool bReadOnly) | CEditBoxLite | [inline]
SetSel(INDEX iMin, INDEX iMax) | CRichEditLite | [inline, virtual]
CEditBoxLite::SetSel(INDEX iMin, INDEX iMax) | CEditBoxLite | [inline, virtual]
SetSplitter(CSplitterLite *pCWndTop, CSplitterLite *pCWndBottom=NULL, CSplitterLite *pCWndLeft=NULL, CSplitterLite *pCWndRight=NULL) | CSplitterLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
SetWordWrap(BOOL fWordWrap) | CRichEditLite | [virtual]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
StartTracking(REFPOINTS ptsScreen, REFRECT rectLeft, REFRECT rectRight, BOOL fVertical, POINT *pPoint) | CSplitterLite | [virtual]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
TraceAddRef(IUnknown *pIUnknown, WCHAR *pwszText) | CIntTrace | [static]
TraceMethod(HRESULT hrActual, WCHAR *pwszFmt,...) | CIntTrace | [static]
TraceNotification(DWORD dwNotifyType, HRESULT hrVeto, WCHAR *pwszInterface, WCHAR *pwszMethod, WCHAR *pwszParams,...) | CIntTrace | [static]
TraceQI(IUnknown *pIUnknown, REFIID riid, IUnknown **ppIUnknown, WCHAR *pwszFmt=L"IUnknown") | CIntTrace | [static]
TraceRelease(IUnknown **ppIUnknown, WCHAR *pwszText, ULONG ulExpectedRefCount=1) | CIntTrace | [static]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
Write(LPCWSTR pwszText) | CRichEditLite | [inline, virtual]
WriteLine(LPCWSTR pwsz=NULL) | CConsole | [inline, virtual]
~CConsole() | CConsole | [inline, virtual]
~CEditBoxLite() | CEditBoxLite | [virtual]
~CIntTrace() | CIntTrace | [virtual]
~CRichEditLite() | CRichEditLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

LOGON_DATA Member List

This is the complete list of members for LOGON_DATA, including all inherited members.
szServer | LOGON_DATA
szTransport | LOGON_DATA
szUserURI | LOGON_DATA
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Include/OleStd.h Source File

  • Com
  • Fundamentals
  • Include

OleStd.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2.0 Utilities
00004 **
00005 **    olestd.h
00006 **
00007 **    This file contains file contains data structure defintions,
00008 **    function prototypes, constants, etc. for the common OLE 2.0
00009 **    utilities.
00010 **
00011 **    These utilities include the following:
00012 **          Debuging Assert/Verify macros
00013 **          HIMETRIC conversion routines
00014 **          reference counting debug support
00015 **          OleStd API's for common compound-document app support
00016 **
00017 **    (c) Copyright Microsoft Corp. 1990 - 2000 All Rights Reserved
00018 **
00019 *************************************************************************/
00020
00021 #if !defined( _OLESTD_H_ )
00022 #define _OLESTD_H_
00023
00024 #if !defined(__cplusplus) && !defined( __TURBOC__)
00025 #define NONAMELESSUNION     // use strict ANSI standard (for DVOBJ.H)
00026 #endif
00027
00028 #include <windows.h>
00029 #include <shellapi.h>
00030 #include <ole2.h>
00031 #include <string.h>
00032 #include <dlgs.h>           //For fileopen dlg; standard include
00033 #include "ansiapi.h"
00034 #include "oledlg.h"
00035
00036 /*************************************************************************
00037 ** DEBUG ASSERTION ROUTINES
00038 *************************************************************************/
00039
00040 #if DBG
00041 #include <assert.h>
00042 #define FnAssert(lpstrExpr, lpstrMsg, lpstrFileName, iLine)     \
00043         (_assert(lpstrMsg ? lpstrMsg : lpstrExpr,               \
00044                  lpstrFileName,                                 \
00045                  iLine), NOERROR)
00046 #endif //DBG
00047
00048 // BEGINING OF OLD OLESTD.H FILE
00049 #if defined( __TURBOC__ ) || defined( WIN32 )
00050 #define _based(a)
00051 #endif
00052
00053 #ifndef RC_INVOKED
00054 #include <dos.h>        // needed for filetime
00055 #endif  /* RC_INVOKED */
00056
00057 #include <commdlg.h>    // needed for LPPRINTDLG
00058 #include <shellapi.h>   // needed for HKEY
00059 #include "ansiapi.h"
00060
00061 // String table defines...
00062 #define  IDS_OLESTDNOCREATEFILE   700
00063 #define  IDS_OLESTDNOOPENFILE     701
00064 #define  IDS_OLESTDDISKFULL       702
00065
00066
00067 /*
00068  * Some C interface declaration stuff
00069  */
00070
00071 #if ! defined(__cplusplus)
00072 typedef struct tagINTERFACEIMPL {
00073       IUnknownVtbl FAR*       lpVtbl;
00074       LPVOID                  lpBack;
00075       int                     cRef;   // interface specific ref count.
00076 } INTERFACEIMPL, FAR* LPINTERFACEIMPL;
00077
00078 #define INIT_INTERFACEIMPL(lpIFace, pVtbl, pBack)   \
00079       ((lpIFace)->lpVtbl = pVtbl, \
00080          ((LPINTERFACEIMPL)(lpIFace))->lpBack = (LPVOID)pBack,   \
00081          ((LPINTERFACEIMPL)(lpIFace))->cRef = 0  \
00082       )
00083
00084 #if defined( _DEBUG )
00085 #define OleDbgQueryInterfaceMethod(lpUnk)   \
00086       ((lpUnk) != NULL ? ((LPINTERFACEIMPL)(lpUnk))->cRef++ : 0)
00087 #define OleDbgAddRefMethod(lpThis, iface)   \
00088       ((LPINTERFACEIMPL)(lpThis))->cRef++
00089
00090 #if _DEBUGLEVEL >= 2
00091 #define OleDbgReleaseMethod(lpThis, iface) \
00092       (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
00093          OleDbgOut("\t" iface "* RELEASED (cRef == 0)\r\n"),1 : \
00094           (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
00095             ( \
00096                DebugBreak(), \
00097                OleDbgOut(  \
00098                   "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
00099             ),1 : \
00100             1)
00101
00102 #else       // if _DEBUGLEVEL < 2
00103 #define OleDbgReleaseMethod(lpThis, iface) \
00104       (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
00105          1 : \
00106           (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
00107             ( \
00108                OleDbgOut(  \
00109                   "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
00110       ),1 : \
00111             1)
00112
00113 #endif      // if _DEBUGLEVEL < 2
00114
00115 #else       // ! defined (_DEBUG)
00116
00117 #define OleDbgQueryInterfaceMethod(lpUnk)
00118 #define OleDbgAddRefMethod(lpThis, iface)
00119 #define OleDbgReleaseMethod(lpThis, iface)
00120
00121 #endif      // if defined( _DEBUG )
00122
00123 #endif      // ! defined(__cplusplus)
00124
00125 /*
00126  * Some docfiles stuff
00127  */
00128
00129 #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
00130 #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
00131 #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
00132
00133 /*
00134  * Some Concurrency stuff
00135  */
00136
00137 /* standard Delay (in msec) to wait before retrying an LRPC call.
00138 **    this value is returned from IMessageFilter::RetryRejectedCall
00139 */
00140 #define OLESTDRETRYDELAY    (DWORD)5000
00141
00142 /* Cancel the pending outgoing LRPC call.
00143 **    this value is returned from IMessageFilter::RetryRejectedCall
00144 */
00145 #define OLESTDCANCELRETRY   (DWORD)-1
00146
00147 /*
00148  * Some Icon support stuff.
00149  *
00150  * The following API's are now OBSOLETE because equivalent API's have been
00151  * added to the OLE2.DLL library
00152  *      GetIconOfFile       superceeded by OleGetIconOfFile
00153  *      GetIconOfClass      superceeded by OleGetIconOfClass
00154  *      OleUIMetafilePictFromIconAndLabel
00155  *                          superceeded by OleMetafilePictFromIconAndLabel
00156  *
00157  * The following macros are defined for backward compatibility with previous
00158  * versions of the OLE2UI library. It is recommended that the new Ole* API's
00159  * should be used instead.
00160  */
00161 #define GetIconOfFile(hInst, lpszFileName, fUseFileAsLabel) \
00162    OleGetIconOfFile(lpszFileName, fUseFileAsLabel)
00163
00164 #define GetIconOfClass(hInst, rclsid, lpszLabel, fUseTypeAsLabel) \
00165    OleGetIconOfClass(rclsid, lpszLabel, fUseTypeAsLabel)
00166
00167 #define OleUIMetafilePictFromIconAndLabel(hIcon,pszLabel,pszSourceFile,iIcon)\
00168    OleMetafilePictFromIconAndLabel(hIcon, pszLabel, pszSourceFile, iIcon)
00169
00170
00171 /*
00172  * Some Clipboard Copy/Paste & Drag/Drop support stuff
00173  */
00174
00175 //Macro to set all FormatEtc fields
00176 #define SETFORMATETC(fe, cf, asp, td, med, li)   \
00177    ((fe).cfFormat=cf, \
00178     (fe).dwAspect=asp, \
00179     (fe).ptd=td, \
00180     (fe).tymed=med, \
00181     (fe).lindex=li)
00182
00183 //Macro to set interesting FormatEtc fields defaulting the others.
00184 #define SETDEFAULTFORMATETC(fe, cf, med)  \
00185    ((fe).cfFormat=cf, \
00186     (fe).dwAspect=DVASPECT_CONTENT, \
00187     (fe).ptd=NULL, \
00188     (fe).tymed=med, \
00189     (fe).lindex=-1)
00190
00191 // Macro to test if two FormatEtc structures are an exact match
00192 #define IsEqualFORMATETC(fe1, fe2)  \
00193    (OleStdCompareFormatEtc(&(fe1), &(fe2))==0)
00194
00195 // Clipboard format strings
00196 #define CF_EMBEDSOURCE      TEXT("Embed Source")
00197 #define CF_EMBEDDEDOBJECT   TEXT("Embedded Object")
00198 #define CF_LINKSOURCE       TEXT("Link Source")
00199 #define CF_CUSTOMLINKSOURCE TEXT("Custom Link Source")
00200 #define CF_OBJECTDESCRIPTOR TEXT("Object Descriptor")
00201 #define CF_LINKSRCDESCRIPTOR TEXT("Link Source Descriptor")
00202 #define CF_OWNERLINK        TEXT("OwnerLink")
00203 #define CF_FILENAME         TEXT("FileName")
00204
00205 #define OleStdQueryOleObjectData(lpformatetc)   \
00206    (((lpformatetc)->tymed & TYMED_ISTORAGE) ?    \
00207          NOERROR : ResultFromScode(DV_E_FORMATETC))
00208
00209 #define OleStdQueryLinkSourceData(lpformatetc)   \
00210    (((lpformatetc)->tymed & TYMED_ISTREAM) ?    \
00211          NOERROR : ResultFromScode(DV_E_FORMATETC))
00212
00213 #define OleStdQueryObjectDescriptorData(lpformatetc)    \
00214    (((lpformatetc)->tymed & TYMED_HGLOBAL) ?    \
00215          NOERROR : ResultFromScode(DV_E_FORMATETC))
00216
00217 #define OleStdQueryFormatMedium(lpformatetc, tymd)  \
00218    (((lpformatetc)->tymed & tymd) ?    \
00219          NOERROR : ResultFromScode(DV_E_FORMATETC))
00220
00221 // Make an independent copy of a MetafilePict
00222 #define OleStdCopyMetafilePict(hpictin, phpictout)  \
00223    (*(phpictout) = OleDuplicateData(hpictin,CF_METAFILEPICT,GHND|GMEM_SHARE))
00224
00225
00226 // REVIEW: these need to be added to OLE2.H
00227 #if !defined( DD_DEFSCROLLINTERVAL )
00228 #define DD_DEFSCROLLINTERVAL    50
00229 #endif
00230
00231 #if !defined( DD_DEFDRAGDELAY )
00232 #define DD_DEFDRAGDELAY         200
00233 #endif
00234
00235 #if !defined( DD_DEFDRAGMINDIST )
00236 #define DD_DEFDRAGMINDIST       2
00237 #endif
00238
00239
00240 /* OleStdGetDropEffect
00241 ** -------------------
00242 **
00243 ** Convert a keyboard state into a DROPEFFECT.
00244 **
00245 ** returns the DROPEFFECT value derived from the key state.
00246 **    the following is the standard interpretation:
00247 **          no modifier -- Default Drop     (NULL is returned)
00248 **          CTRL        -- DROPEFFECT_COPY
00249 **          SHIFT       -- DROPEFFECT_MOVE
00250 **          CTRL-SHIFT  -- DROPEFFECT_LINK
00251 **
00252 **    Default Drop: this depends on the type of the target application.
00253 **    this is re-interpretable by each target application. a typical
00254 **    interpretation is if the drag is local to the same document
00255 **    (which is source of the drag) then a MOVE operation is
00256 **    performed. if the drag is not local, then a COPY operation is
00257 **    performed.
00258 */
00259 #define OleStdGetDropEffect(grfKeyState)    \
00260    ( (grfKeyState & MK_CONTROL) ?          \
00261       ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ) :  \
00262       ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : 0 ) )
00263
00264
00265 #define OLESTDDROP_NONE         0
00266 #define OLESTDDROP_DEFAULT      1
00267 #define OLESTDDROP_NONDEFAULT   2
00268
00269
00270 /*
00271  * Some misc stuff
00272  */
00273
00274 #define EMBEDDINGFLAG "Embedding"     // Cmd line switch for launching a srvr
00275
00276 #define HIMETRIC_PER_INCH   2540      // number HIMETRIC units per inch
00277 #define PTS_PER_INCH        72        // number points (font size) per inch
00278
00279 #define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
00280 #define MAP_LOGHIM_TO_PIX(x,ppli)   MulDiv((ppli), (x), HIMETRIC_PER_INCH)
00281
00282 // Returns TRUE if all fields of the two Rect's are equal, else FALSE.
00283 #define AreRectsEqual(lprc1, lprc2)     \
00284    (((lprc1->top == lprc2->top) &&     \
00285      (lprc1->left == lprc2->left) &&   \
00286      (lprc1->right == lprc2->right) && \
00287      (lprc1->bottom == lprc2->bottom)) ? TRUE : FALSE)
00288
00289 #define LSTRCPYN(lpdst, lpsrc, cch) \
00290 (\
00291    (lpdst)[(cch)-1] = '\0', \
00292    ((cch)>1 ? _fstrncpy(lpdst, lpsrc, (cch)-1) : 0)\
00293 )
00294
00295
00296
00297 /****** DEBUG Stuff *****************************************************/
00298
00299 #ifdef _DEBUG
00300
00301 #if !defined( _DBGTRACE )
00302 #define _DEBUGLEVEL 2
00303 #else
00304 #define _DEBUGLEVEL _DBGTRACE
00305 #endif
00306
00307
00308 #if defined( NOASSERT )
00309
00310 #define OLEDBGASSERTDATA
00311 #define OleDbgAssert(a)
00312 #define OleDbgAssertSz(a, b)
00313 #define OleDbgVerify(a)
00314 #define OleDbgVerifySz(a, b)
00315
00316 #else   // ! NOASSERT
00317
00318 #define OLEDBGASSERTDATA    \
00319       static char _based(_segname("_CODE")) _szAssertFile[]= __FILE__;
00320
00321 #define OleDbgAssert(a) \
00322       (!(a) ? FnAssert(#a, NULL, _szAssertFile, __LINE__) : (HRESULT)1)
00323
00324 #define OleDbgAssertSz(a, b)    \
00325       (!(a) ? FnAssert(#a, b, _szAssertFile, __LINE__) : (HRESULT)1)
00326
00327 #define OleDbgVerify(a) \
00328       OleDbgAssert(a)
00329
00330 #define OleDbgVerifySz(a, b)    \
00331       OleDbgAssertSz(a, b)
00332
00333 #endif  // ! NOASSERT
00334
00335
00336 #define OLEDBGDATA_MAIN(szPrefix)   \
00337       char near g_szDbgPrefix[] = szPrefix;    \
00338       OLEDBGASSERTDATA
00339 #define OLEDBGDATA  \
00340       extern char near g_szDbgPrefix[];    \
00341       OLEDBGASSERTDATA
00342
00343 #define OLEDBG_BEGIN(lpsz) \
00344       OleDbgPrintAlways(g_szDbgPrefix,lpsz,1);
00345
00346 #define OLEDBG_END  \
00347       OleDbgPrintAlways(g_szDbgPrefix,"End\r\n",-1);
00348
00349 #define OleDbgOut(lpsz) \
00350       OleDbgPrintAlways(g_szDbgPrefix,lpsz,0)
00351
00352 #define OleDbgOutNoPrefix(lpsz) \
00353       OleDbgPrintAlways("",lpsz,0)
00354
00355 #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)      \
00356       OleDbgPrintRefCntAlways(g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
00357
00358 #define OleDbgOutRect(lpsz,lpRect)      \
00359       OleDbgPrintRectAlways(g_szDbgPrefix,lpsz,lpRect)
00360
00361 #define OleDbgOutHResult(lpsz,hr)   \
00362       OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,GetScode(hr))
00363
00364 #define OleDbgOutScode(lpsz,sc) \
00365       OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,sc)
00366
00367 #define OleDbgOut1(lpsz)    \
00368       OleDbgPrint(1,g_szDbgPrefix,lpsz,0)
00369
00370 #define OleDbgOutNoPrefix1(lpsz)    \
00371       OleDbgPrint(1,"",lpsz,0)
00372
00373 #define OLEDBG_BEGIN1(lpsz)    \
00374       OleDbgPrint(1,g_szDbgPrefix,lpsz,1);
00375
00376 #define OLEDBG_END1 \
00377       OleDbgPrint(1,g_szDbgPrefix,"End\r\n",-1);
00378
00379 #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)     \
00380       OleDbgPrintRefCnt(1,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
00381
00382 #define OleDbgOutRect1(lpsz,lpRect)     \
00383       OleDbgPrintRect(1,g_szDbgPrefix,lpsz,lpRect)
00384
00385 #define OleDbgOut2(lpsz)    \
00386       OleDbgPrint(2,g_szDbgPrefix,lpsz,0)
00387
00388 #define OleDbgOutNoPrefix2(lpsz)    \
00389       OleDbgPrint(2,"",lpsz,0)
00390
00391 #define OLEDBG_BEGIN2(lpsz)    \
00392       OleDbgPrint(2,g_szDbgPrefix,lpsz,1);
00393
00394 #define OLEDBG_END2 \
00395       OleDbgPrint(2,g_szDbgPrefix,"End\r\n",-1);
00396
00397 #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)     \
00398       OleDbgPrintRefCnt(2,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
00399
00400 #define OleDbgOutRect2(lpsz,lpRect)     \
00401       OleDbgPrintRect(2,g_szDbgPrefix,lpsz,lpRect)
00402
00403 #define OleDbgOut3(lpsz)    \
00404       OleDbgPrint(3,g_szDbgPrefix,lpsz,0)
00405
00406 #define OleDbgOutNoPrefix3(lpsz)    \
00407       OleDbgPrint(3,"",lpsz,0)
00408
00409 #define OLEDBG_BEGIN3(lpsz)    \
00410       OleDbgPrint(3,g_szDbgPrefix,lpsz,1);
00411
00412 #define OLEDBG_END3 \
00413       OleDbgPrint(3,g_szDbgPrefix,"End\r\n",-1);
00414
00415 #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)     \
00416       OleDbgPrintRefCnt(3,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
00417
00418 #define OleDbgOutRect3(lpsz,lpRect)     \
00419       OleDbgPrintRect(3,g_szDbgPrefix,lpsz,lpRect)
00420
00421 #define OleDbgOut4(lpsz)    \
00422       OleDbgPrint(4,g_szDbgPrefix,lpsz,0)
00423
00424 #define OleDbgOutNoPrefix4(lpsz)    \
00425       OleDbgPrint(4,"",lpsz,0)
00426
00427 #define OLEDBG_BEGIN4(lpsz)    \
00428       OleDbgPrint(4,g_szDbgPrefix,lpsz,1);
00429
00430 #define OLEDBG_END4 \
00431       OleDbgPrint(4,g_szDbgPrefix,"End\r\n",-1);
00432
00433 #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)     \
00434       OleDbgPrintRefCnt(4,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
00435
00436 #define OleDbgOutRect4(lpsz,lpRect)     \
00437       OleDbgPrintRect(4,g_szDbgPrefix,lpsz,lpRect)
00438
00439 #else   //  !_DEBUG
00440
00441 #define OLEDBGDATA_MAIN(szPrefix)
00442 #define OLEDBGDATA
00443 #define OleDbgAssert(a)
00444 #define OleDbgAssertSz(a, b)
00445 #define OleDbgVerify(a)         (a)
00446 #define OleDbgVerifySz(a, b)    (a)
00447 #define OleDbgOutHResult(lpsz,hr)
00448 #define OleDbgOutScode(lpsz,sc)
00449 #define OLEDBG_BEGIN(lpsz)
00450 #define OLEDBG_END
00451 #define OleDbgOut(lpsz)
00452 #define OleDbgOut1(lpsz)
00453 #define OleDbgOut2(lpsz)
00454 #define OleDbgOut3(lpsz)
00455 #define OleDbgOut4(lpsz)
00456 #define OleDbgOutNoPrefix(lpsz)
00457 #define OleDbgOutNoPrefix1(lpsz)
00458 #define OleDbgOutNoPrefix2(lpsz)
00459 #define OleDbgOutNoPrefix3(lpsz)
00460 #define OleDbgOutNoPrefix4(lpsz)
00461 #define OLEDBG_BEGIN1(lpsz)
00462 #define OLEDBG_BEGIN2(lpsz)
00463 #define OLEDBG_BEGIN3(lpsz)
00464 #define OLEDBG_BEGIN4(lpsz)
00465 #define OLEDBG_END1
00466 #define OLEDBG_END2
00467 #define OLEDBG_END3
00468 #define OLEDBG_END4
00469 #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)
00470 #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)
00471 #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)
00472 #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)
00473 #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)
00474 #define OleDbgOutRect(lpsz,lpRect)
00475 #define OleDbgOutRect1(lpsz,lpRect)
00476 #define OleDbgOutRect2(lpsz,lpRect)
00477 #define OleDbgOutRect3(lpsz,lpRect)
00478 #define OleDbgOutRect4(lpsz,lpRect)
00479
00480 #endif  //  _DEBUG
00481
00482
00483 /*************************************************************************
00484 ** Function prototypes
00485 *************************************************************************/
00486
00487
00488 //OLESTD.C
00489 STDAPI_(int) SetDCToAnisotropic(HDC hDC, LPRECT lprcPhysical, LPRECT lprcLogical, LPRECT lprcWindowOld, LPRECT lprcViewportOld);
00490 STDAPI_(int) SetDCToDrawInHimetricRect(HDC, LPRECT, LPRECT, LPRECT, LPRECT);
00491 STDAPI_(int) ResetOrigDC(HDC, int, LPRECT, LPRECT);
00492
00493 STDAPI_(int)        XformWidthInHimetricToPixels(HDC, int);
00494 STDAPI_(int)        XformWidthInPixelsToHimetric(HDC, int);
00495 STDAPI_(int)        XformHeightInHimetricToPixels(HDC, int);
00496 STDAPI_(int)        XformHeightInPixelsToHimetric(HDC, int);
00497
00498 STDAPI_(void) XformRectInPixelsToHimetric(HDC, LPRECT, LPRECT);
00499 STDAPI_(void) XformRectInHimetricToPixels(HDC, LPRECT, LPRECT);
00500 STDAPI_(void) XformSizeInPixelsToHimetric(HDC, LPSIZEL, LPSIZEL);
00501 STDAPI_(void) XformSizeInHimetricToPixels(HDC, LPSIZEL, LPSIZEL);
00502 STDAPI_(int) XformWidthInHimetricToPixels(HDC, int);
00503 STDAPI_(int) XformWidthInPixelsToHimetric(HDC, int);
00504 STDAPI_(int) XformHeightInHimetricToPixels(HDC, int);
00505 STDAPI_(int) XformHeightInPixelsToHimetric(HDC, int);
00506
00507 STDAPI_(void) ParseCmdLine(LPSTR, BOOL FAR *, LPSTR);
00508
00509 STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk);
00510 STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid);
00511 STDAPI_(LPSTORAGE) OleStdCreateRootStorage(LPOLESTR lpszStgName, DWORD grfMode);
00512 STDAPI_(LPSTORAGE) OleStdOpenRootStorage(LPOLESTR lpszStgName, DWORD grfMode);
00513 STDAPI_(LPSTORAGE) OleStdOpenOrCreateRootStorage(LPOLESTR lpszStgName, DWORD grfMode);
00514 STDAPI_(LPSTORAGE) OleStdCreateChildStorage(LPSTORAGE lpStg, LPOLESTR lpszStgName);
00515 STDAPI_(LPSTORAGE) OleStdOpenChildStorage(LPSTORAGE lpStg, LPOLESTR lpszStgName, DWORD grfMode);
00516 STDAPI_(BOOL) OleStdCommitStorage(LPSTORAGE lpStg);
00517 STDAPI OleStdDestroyAllElements(LPSTORAGE lpStg);
00518
00519 STDAPI_(LPSTORAGE) OleStdCreateStorageOnHGlobal(
00520       HANDLE hGlobal,
00521       BOOL fDeleteOnRelease,
00522       DWORD dwgrfMode
00523 );
00524 STDAPI_(LPSTORAGE) OleStdCreateTempStorage(BOOL fUseMemory, DWORD grfMode);
00525 STDAPI OleStdDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew);
00526 STDAPI_(BOOL) OleStdGetTreatAsFmtUserType(
00527       REFCLSID        rClsidApp,
00528       LPSTORAGE       lpStg,
00529       CLSID FAR*      lpclsid,
00530       CLIPFORMAT FAR* lpcfFmt,
00531       LPOLESTR FAR*      lplpszType
00532 );
00533 STDAPI OleStdDoTreatAsClass(LPOLESTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew);
00534 STDAPI_(BOOL) OleStdSetupAdvises(LPOLEOBJECT lpOleObject, DWORD dwDrawAspect,
00535                LPOLESTR lpszContainerApp, LPOLESTR lpszContainerObj,
00536                LPADVISESINK lpAdviseSink, BOOL fCreate);
00537 STDAPI OleStdSwitchDisplayAspect(
00538       LPOLEOBJECT             lpOleObj,
00539       LPDWORD                 lpdwCurAspect,
00540       DWORD                   dwNewAspect,
00541       HGLOBAL                 hMetaPict,
00542       BOOL                    fDeleteOldAspect,
00543       BOOL                    fSetupViewAdvise,
00544       LPADVISESINK            lpAdviseSink,
00545       BOOL FAR*               lpfMustUpdate
00546 );
00547 STDAPI OleStdSetIconInCache(LPOLEOBJECT lpOleObj, HGLOBAL hMetaPict);
00548 STDAPI_(HGLOBAL) OleStdGetData(
00549       LPDATAOBJECT        lpDataObj,
00550       CLIPFORMAT          cfFormat,
00551       DVTARGETDEVICE FAR* lpTargetDevice,
00552       DWORD               dwAspect,
00553       LPSTGMEDIUM         lpMedium
00554 );
00555 STDAPI_(void) OleStdMarkPasteEntryList(
00556       LPDATAOBJECT        lpSrcDataObj,
00557       LPOLEUIPASTEENTRY   lpPriorityList,
00558       int                 cEntries
00559 );
00560 STDAPI_(int) OleStdGetPriorityClipboardFormat(
00561       LPDATAOBJECT        lpSrcDataObj,
00562       LPOLEUIPASTEENTRY   lpPriorityList,
00563       int                 cEntries
00564 );
00565 STDAPI_(BOOL) OleStdIsDuplicateFormat(
00566       LPFORMATETC         lpFmtEtc,
00567       LPFORMATETC         arrFmtEtc,
00568       int                 nFmtEtc
00569 );
00570 STDAPI_(void) OleStdRegisterAsRunning(LPUNKNOWN lpUnk, LPMONIKER lpmkFull, DWORD FAR* lpdwRegister);
00571 STDAPI_(void) OleStdRevokeAsRunning(DWORD FAR* lpdwRegister);
00572 STDAPI_(void) OleStdNoteFileChangeTime(LPOLESTR lpszFileName, DWORD dwRegister);
00573 STDAPI_(void) OleStdNoteObjectChangeTime(DWORD dwRegister);
00574 STDAPI OleStdGetOleObjectData(
00575       LPPERSISTSTORAGE    lpPStg,
00576       LPFORMATETC         lpformatetc,
00577       LPSTGMEDIUM         lpMedium,
00578       BOOL                fUseMemory
00579 );
00580 STDAPI OleStdGetLinkSourceData(
00581       LPMONIKER           lpmk,
00582       LPCLSID             lpClsID,
00583       LPFORMATETC         lpformatetc,
00584       LPSTGMEDIUM         lpMedium
00585 );
00586 STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
00587       CLSID               clsid,
00588       DWORD               dwAspect,
00589       SIZEL               sizel,
00590       POINTL              pointl,
00591       DWORD               dwStatus,
00592       LPOLESTR            lpszFullUserTypeName,
00593       LPOLESTR            lpszSrcOfCopy
00594 );
00595 STDAPI_(HGLOBAL) OleStdGetObjectDescriptorDataFromOleObject(
00596       LPOLEOBJECT         lpOleObj,
00597       LPOLESTR            lpszSrcOfCopy,
00598       DWORD               dwAspect,
00599       POINTL              pointl,
00600       LPSIZEL             lpSizelHim
00601 );
00602 STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
00603       LPDATAOBJECT       lpDataObject,
00604       LPSTGMEDIUM        lpmedium,
00605       CLIPFORMAT FAR*    lpcfFmt
00606 );
00607 STDAPI_(HANDLE) OleStdGetMetafilePictFromOleObject(
00608       LPOLEOBJECT         lpOleObj,
00609       DWORD               dwDrawAspect,
00610       LPSIZEL             lpSizelHim,
00611       DVTARGETDEVICE FAR* ptd
00612 );
00613
00614 STDAPI_(void) OleStdCreateTempFileMoniker(LPOLESTR lpszPrefixString, UINT FAR* lpuUnique, LPOLESTR lpszName, LPMONIKER FAR* lplpmk);
00615 STDAPI_(LPMONIKER) OleStdGetFirstMoniker(LPMONIKER lpmk);
00616 STDAPI_(ULONG) OleStdGetLenFilePrefixOfMoniker(LPMONIKER lpmk);
00617 STDAPI OleStdMkParseDisplayName(
00618       REFCLSID        rClsid,
00619       LPBC            lpbc,
00620       LPOLESTR        lpszUserName,
00621       ULONG FAR*      lpchEaten,
00622       LPMONIKER FAR*  lplpmk
00623 );
00624 STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize);
00625 STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize);
00626 STDAPI_(void) OleStdFree(LPVOID pmem);
00627 STDAPI_(ULONG) OleStdGetSize(LPVOID pmem);
00628 STDAPI_(void) OleStdFreeString(LPOLESTR lpsz, LPMALLOC lpMalloc);
00629 STDAPI_(LPOLESTR) OleStdCopyString(LPOLESTR lpszSrc, LPMALLOC lpMalloc);
00630 STDAPI_(ULONG) OleStdGetItemToken(LPOLESTR lpszSrc, LPOLESTR lpszDst,int nMaxChars);
00631
00632 STDAPI_(UINT)     OleStdIconLabelTextOut(HDC        hDC,
00633                                HFONT      hFont,
00634                                int        nXStart,
00635                                int        nYStart,
00636                                UINT       fuOptions,
00637                                RECT FAR * lpRect,
00638                                LPOLESTR   lpszString,
00639                                UINT       cchString,
00640                                int FAR *  lpDX);
00641
00642 // registration database query functions
00643 STDAPI_(UINT)     OleStdGetAuxUserType(REFCLSID rclsid,
00644                              WORD   wAuxUserType,
00645                              LPOLESTR  lpszAuxUserType,
00646                              int    cch,
00647                              HKEY   hKey);
00648
00649 STDAPI_(UINT)     OleStdGetUserTypeOfClass(REFCLSID rclsid,
00650                                  LPOLESTR lpszUserType,
00651                                  UINT cch,
00652                                  HKEY hKey);
00653
00654 STDAPI_(BOOL) OleStdGetMiscStatusOfClass(REFCLSID, HKEY, DWORD FAR *);
00655 STDAPI_(CLIPFORMAT) OleStdGetDefaultFileFormatOfClass(
00656       REFCLSID        rclsid,
00657       HKEY            hKey
00658 );
00659
00660 STDAPI_(void) OleStdInitVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl);
00661 STDMETHODIMP OleStdNullMethod(LPUNKNOWN lpThis);
00662 STDAPI_(BOOL) OleStdCheckVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl, LPOLESTR lpszIface);
00663 STDAPI_(ULONG) OleStdVerifyRelease(LPUNKNOWN lpUnk, LPOLESTR lpszMsg);
00664 STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk);
00665
00666 STDAPI_(HDC) OleStdCreateDC(DVTARGETDEVICE FAR* ptd);
00667 STDAPI_(HDC) OleStdCreateIC(DVTARGETDEVICE FAR* ptd);
00668 STDAPI_(DVTARGETDEVICE FAR*) OleStdCreateTargetDevice(LPPRINTDLG lpPrintDlg);
00669 STDAPI_(BOOL) OleStdDeleteTargetDevice(DVTARGETDEVICE FAR* ptd);
00670 STDAPI_(DVTARGETDEVICE FAR*) OleStdCopyTargetDevice(DVTARGETDEVICE FAR* ptdSrc);
00671 STDAPI_(BOOL) OleStdCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc);
00672 STDAPI_(int) OleStdCompareFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight);
00673 STDAPI_(BOOL) OleStdCompareTargetDevice
00674    (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight);
00675
00676
00677 STDAPI_(void) OleDbgPrint(
00678       int     nDbgLvl,
00679       LPSTR   lpszPrefix,
00680       LPSTR   lpszMsg,
00681       int     nIndent
00682 );
00683 STDAPI_(void) OleDbgPrintAlways(LPSTR lpszPrefix, LPSTR lpszMsg, int nIndent);
00684 STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl);
00685 STDAPI_(int) OleDbgGetDbgLevel( void );
00686 STDAPI_(void) OleDbgIndent(int n);
00687 STDAPI_(void) OleDbgPrintRefCnt(
00688       int         nDbgLvl,
00689       LPSTR       lpszPrefix,
00690       LPSTR       lpszMsg,
00691       LPVOID      lpObj,
00692       ULONG       refcnt
00693 );
00694 STDAPI_(void) OleDbgPrintRefCntAlways(
00695       LPSTR       lpszPrefix,
00696       LPSTR       lpszMsg,
00697       LPVOID      lpObj,
00698       ULONG       refcnt
00699 );
00700 STDAPI_(void) OleDbgPrintRect(
00701       int         nDbgLvl,
00702       LPSTR       lpszPrefix,
00703       LPSTR       lpszMsg,
00704       LPRECT      lpRect
00705 );
00706 STDAPI_(void) OleDbgPrintRectAlways(
00707       LPSTR       lpszPrefix,
00708       LPSTR       lpszMsg,
00709       LPRECT      lpRect
00710 );
00711 STDAPI_(void) OleDbgPrintScodeAlways(LPSTR lpszPrefix, LPSTR lpszMsg, SCODE sc);
00712
00713
00714 STDAPI_(LPENUMFORMATETC)
00715   OleStdEnumFmtEtc_Create(ULONG nCount, LPFORMATETC lpEtc);
00716
00717 STDAPI_(LPENUMSTATDATA)
00718   OleStdEnumStatData_Create(ULONG nCount, LPSTATDATA lpStat);
00719
00720 STDAPI_(BOOL)
00721   OleStdCopyStatData(LPSTATDATA pDest, LPSTATDATA pSrc);
00722
00723 STDAPI_(HPALETTE)
00724   OleStdCreateStandardPalette(void);
00725
00726 #if defined( OBSOLETE )
00727
00728 /*************************************************************************
00729 ** The following API's have been converted into macros:
00730 **          OleStdQueryOleObjectData
00731 **          OleStdQueryLinkSourceData
00732 **          OleStdQueryObjectDescriptorData
00733 **          OleStdQueryFormatMedium
00734 **          OleStdCopyMetafilePict
00735 **          AreRectsEqual
00736 **          OleStdGetDropEffect
00737 **
00738 **    These macros are defined above
00739 *************************************************************************/
00740 STDAPI_(BOOL) AreRectsEqual(LPRECT lprc1, LPRECT lprc2);
00741 STDAPI_(BOOL) OleStdCopyMetafilePict(HANDLE hpictin, HANDLE FAR* phpictout);
00742 STDAPI OleStdQueryOleObjectData(LPFORMATETC lpformatetc);
00743 STDAPI OleStdQueryLinkSourceData(LPFORMATETC lpformatetc);
00744 STDAPI OleStdQueryObjectDescriptorData(LPFORMATETC lpformatetc);
00745 STDAPI OleStdQueryFormatMedium(LPFORMATETC lpformatetc, TYMED tymed);
00746 STDAPI_(DWORD) OleStdGetDropEffect ( DWORD grfKeyState );
00747 #endif  // OBSOLETE
00748
00749 // END OF OLD OLESTD.H FILE
00750
00751 #define UPDATELINKS_STARTDELAY 2000 // delay before first link
00752
00753 #ifdef __TURBOC__
00754 #define _getcwd getcwd
00755 #define _itoa   itoa
00756 #define __max   max
00757 #define _find_t find_t
00758 #endif // __TURBOC__
00759
00760 #ifdef WIN32
00761 #define _fmemset memset
00762 #define _fmemcpy memcpy
00763 #define _fmemcmp memcmp
00764 #define _fstrcpy strcpy
00765 #define _fstrncpy strncpy
00766 #define _fstrlen strlen
00767 #define _fstrrchr strrchr
00768 #define _fstrtok strtok
00769 #endif  // WIN32
00770
00771 #if !defined( EXPORT )
00772 #ifdef WIN32
00773 #define EXPORT
00774 #else
00775 #define EXPORT  __export
00776 #endif  // WIN32
00777 #endif  // !EXPORT
00778
00779 /*
00780  * Initialization / Uninitialization routines.  OleStdInitialize
00781  * must be called prior to using any functions in OLESTD.LIB.
00782  */
00783
00784 STDAPI_(BOOL) OleStdInitialize(HINSTANCE hInstance);
00785 STDAPI_(void) OleStdUninitialize(void);
00786
00787 // object count, used to support DllCanUnloadNow and OleUICanUnloadNow
00788 extern DWORD g_dwObjectCount;
00789
00790 STDAPI OleUICanUnloadNow(void);
00791 STDAPI OleUILockLibrary(BOOL fLock);
00792
00793
00794 //Dialog Identifiers as passed in Help messages to identify the source.
00795 #define IDD_FILEOPEN            32253
00796
00797 // The following Dialogs are message dialogs used by OleUIPromptUser API
00798
00799 // Stringtable identifers
00800 #define IDS_OLE2UIUNKNOWN       32300
00801 #define IDS_OLE2UILINK          32301
00802 #define IDS_OLE2UIOBJECT        32302
00803 #define IDS_OLE2UIEDIT          32303
00804 #define IDS_OLE2UICONVERT       32304
00805 #define IDS_OLE2UIEDITLINKCMD_1VERB     32305
00806 #define IDS_OLE2UIEDITOBJECTCMD_1VERB   32306
00807 #define IDS_OLE2UIEDITLINKCMD_NVERB     32307
00808 #define IDS_OLE2UIEDITOBJECTCMD_NVERB   32308
00809 #define IDS_OLE2UIEDITNOOBJCMD  32309
00810 // def. icon label (usu. "Document")
00811 #define IDS_DEFICONLABEL        32310
00812 #define IDS_OLE2UIPASTELINKEDTYPE  32311
00813
00814
00815 #define IDS_FILTERS             32320
00816 #define IDS_ICONFILTERS         32321
00817 #define IDS_BROWSE              32322
00818
00819 //Resource identifiers for bitmaps
00820 #define IDB_RESULTSEGA                  32325
00821 #define IDB_RESULTSVGA                  32326
00822 #define IDB_RESULTSHIRESVGA             32327
00823
00824
00825 //Missing from windows.h
00826 #ifndef PVOID
00827 typedef VOID *PVOID;
00828 #endif
00829
00830
00831 //Hook type used in all structures.
00832 typedef UINT (CALLBACK *LPFNOLEUIHOOK)(HWND, UINT, WPARAM, LPARAM);
00833
00834
00835 //Strings for registered messages
00836 #define SZOLEUI_MSG_FILEOKSTRING        "OLEUI_MSG_FILEOKSTRING"
00837
00838
00839 //Help Button Identifier
00840 #define ID_OLEUIHELP                    99
00841
00842 // Static text control (use this instead of -1 so things work correctly for
00843 // localization
00844 #define  ID_STATIC                      98
00845
00846 //Maximum key size we read from the RegDB.
00847 #define OLEUI_CCHKEYMAX                 256  // make any changes to this in geticon.c too
00848
00849 //Maximum verb length and length of Object menu
00850 #define OLEUI_CCHVERBMAX                32
00851 #define OLEUI_OBJECTMENUMAX             256
00852
00853 //Maximum MS-DOS pathname.
00854 #define OLEUI_CCHPATHMAX                256 // make any changes to this in geticon.c too
00855 #define OLEUI_CCHFILEMAX                13
00856
00857 //Icon label length
00858 #define OLEUI_CCHLABELMAX               40  // make any changes to this in geticon.c too
00859
00860 //Length of the CLSID string
00861 #define OLEUI_CCHCLSIDSTRING            39
00862
00863
00864 //Metafile utility functions
00865 WINOLEAPI_(HGLOBAL) OleUIMetafilePictFromIconAndLabel(HICON, LPOLESTR, LPOLESTR, UINT);
00866 STDAPI_(void)    OleUIMetafilePictIconFree(HGLOBAL);
00867 STDAPI_(BOOL)    OleUIMetafilePictIconDraw(HDC, LPRECT, HGLOBAL, BOOL);
00868 STDAPI_(UINT)    OleUIMetafilePictExtractLabel(HGLOBAL, LPOLESTR, UINT, LPDWORD);
00869 STDAPI_(HICON)   OleUIMetafilePictExtractIcon(HGLOBAL);
00870 STDAPI_(BOOL)    OleUIMetafilePictExtractIconSource(HGLOBAL,LPOLESTR,UINT FAR *);
00871
00872
00873
00874
00875
00876 /*************************************************************************
00877 ** INSERT OBJECT DIALOG
00878 *************************************************************************/
00879
00880 //Insert Object Dialog identifiers
00881 #define ID_IO_CREATENEW                 2100
00882 #define ID_IO_CREATEFROMFILE            2101
00883 #define ID_IO_LINKFILE                  2102
00884 #define ID_IO_OBJECTTYPELIST            2103
00885 #define ID_IO_DISPLAYASICON             2104
00886 #define ID_IO_CHANGEICON                2105
00887 #define ID_IO_FILE                      2106
00888 #define ID_IO_FILEDISPLAY               2107
00889 #define ID_IO_RESULTIMAGE               2108
00890 #define ID_IO_RESULTTEXT                2109
00891 #define ID_IO_ICONDISPLAY               2110
00892 #define ID_IO_OBJECTTYPETEXT            2111
00893 #define ID_IO_FILETEXT                  2112
00894 #define ID_IO_FILETYPE                  2113
00895
00896 // Strings in OLE2UI resources
00897 #define IDS_IORESULTNEW                 32400
00898 #define IDS_IORESULTNEWICON             32401
00899 #define IDS_IORESULTFROMFILE1           32402
00900 #define IDS_IORESULTFROMFILE2           32403
00901 #define IDS_IORESULTFROMFILEICON2       32404
00902 #define IDS_IORESULTLINKFILE1           32405
00903 #define IDS_IORESULTLINKFILE2           32406
00904 #define IDS_IORESULTLINKFILEICON1       32407
00905 #define IDS_IORESULTLINKFILEICON2       32408
00906
00907 /*************************************************************************
00908 ** PASTE SPECIAL DIALOG
00909 *************************************************************************/
00910
00911 //Paste Special Dialog identifiers
00912 #define ID_PS_PASTE                    500
00913 #define ID_PS_PASTELINK                501
00914 #define ID_PS_SOURCETEXT               502
00915 #define ID_PS_PASTELIST                503
00916 #define ID_PS_PASTELINKLIST            504
00917 #define ID_PS_DISPLAYLIST              505
00918 #define ID_PS_DISPLAYASICON            506
00919 #define ID_PS_ICONDISPLAY              507
00920 #define ID_PS_CHANGEICON               508
00921 #define ID_PS_RESULTIMAGE              509
00922 #define ID_PS_RESULTTEXT               510
00923 #define ID_PS_RESULTGROUP              511
00924 #define ID_PS_STXSOURCE                512
00925 #define ID_PS_STXAS                    513
00926
00927 // Paste Special String IDs
00928 #define IDS_PSPASTEDATA                32410
00929 #define IDS_PSPASTEOBJECT              32411
00930 #define IDS_PSPASTEOBJECTASICON        32412
00931 #define IDS_PSPASTELINKDATA            32413
00932 #define IDS_PSPASTELINKOBJECT          32414
00933 #define IDS_PSPASTELINKOBJECTASICON    32415
00934 #define IDS_PSNONOLE                   32416
00935 #define IDS_PSUNKNOWNTYPE              32417
00936 #define IDS_PSUNKNOWNSRC               32418
00937 #define IDS_PSUNKNOWNAPP               32419
00938
00939
00940 /*************************************************************************
00941 ** EDIT LINKS DIALOG
00942 *************************************************************************/
00943
00944 // Edit Links Dialog identifiers
00945 #define ID_EL_CHANGESOURCE             201
00946 #define ID_EL_AUTOMATIC                202
00947 #define ID_EL_CLOSE                    208
00948 #define ID_EL_CANCELLINK               209
00949 #define ID_EL_UPDATENOW                210
00950 #define ID_EL_OPENSOURCE               211
00951 #define ID_EL_MANUAL                   212
00952 #define ID_EL_LINKSOURCE               216
00953 #define ID_EL_LINKTYPE                 217
00954 #define ID_EL_UPDATE                   218
00955 #define ID_EL_NULL                     -1
00956 #define ID_EL_LINKSLISTBOX             206
00957 #define ID_EL_COL1                     220
00958 #define ID_EL_COL2                     221
00959 #define ID_EL_COL3                     222
00960
00961
00962
00963 /*************************************************************************
00964 ** CHANGE ICON DIALOG
00965 *************************************************************************/
00966
00967 //Change Icon Dialog identifiers
00968 #define ID_GROUP                    120
00969 #define ID_CURRENT                  121
00970 #define ID_CURRENTICON              122
00971 #define ID_DEFAULT                  123
00972 #define ID_DEFAULTICON              124
00973 #define ID_FROMFILE                 125
00974 #define ID_FROMFILEEDIT             126
00975 #define ID_ICONLIST                 127
00976 #define ID_LABEL                    128
00977 #define ID_LABELEDIT                129
00978 #define ID_BROWSE                   130
00979 #define ID_RESULTICON               132
00980 #define ID_RESULTLABEL              133
00981
00982 // Stringtable defines for Change Icon
00983 #define IDS_CINOICONSINFILE         32430
00984 #define IDS_CIINVALIDFILE           32431
00985 #define IDS_CIFILEACCESS            32432
00986 #define IDS_CIFILESHARE             32433
00987 #define IDS_CIFILEOPENFAIL          32434
00988
00989
00990
00991 /*************************************************************************
00992 ** CONVERT DIALOG
00993 *************************************************************************/
00994
00995 //Convert Dialog identifiers
00996 #define IDCV_OBJECTTYPE             150
00997 #define IDCV_DISPLAYASICON          152
00998 #define IDCV_CHANGEICON             153
00999 #define IDCV_ACTIVATELIST           154
01000 #define IDCV_CONVERTTO              155
01001 #define IDCV_ACTIVATEAS             156
01002 #define IDCV_RESULTTEXT             157
01003 #define IDCV_CONVERTLIST            158
01004 #define IDCV_ICON                   159
01005 #define IDCV_ICONLABEL1             160
01006 #define IDCV_ICONLABEL2             161
01007 #define IDCV_STXCURTYPE             162
01008 #define IDCV_GRPRESULT              163
01009 #define IDCV_STXCONVERTTO           164
01010
01011 // String IDs for Convert dialog
01012 #define IDS_CVRESULTCONVERTLINK     32440
01013 #define IDS_CVRESULTCONVERTTO       32441
01014 #define IDS_CVRESULTNOCHANGE        32442
01015 #define IDS_CVRESULTDISPLAYASICON   32443
01016 #define IDS_CVRESULTACTIVATEAS      32444
01017 #define IDS_CVRESULTACTIVATEDIFF    32445
01018
01019
01020 /*************************************************************************
01021 ** BUSY DIALOG
01022 *************************************************************************/
01023
01024 // Busy dialog identifiers
01025 #define IDBZ_RETRY                      600
01026 #define IDBZ_ICON                       601
01027 #define IDBZ_MESSAGE1                   602
01028 #define IDBZ_SWITCHTO                   604
01029
01030 // Busy dialog stringtable defines
01031 #define IDS_BZRESULTTEXTBUSY            32447
01032 #define IDS_BZRESULTTEXTNOTRESPONDING   32448
01033
01034 // Links dialog stringtable defines
01035 #define IDS_LINK_AUTO           32450
01036 #define IDS_LINK_MANUAL         32451
01037 #define IDS_LINK_UNKNOWN        32452
01038 #define IDS_LINKS               32453
01039 #define IDS_FAILED              32454
01040 #define IDS_CHANGESOURCE        32455
01041 #define IDS_INVALIDSOURCE       32456
01042 #define IDS_ERR_GETLINKSOURCE   32457
01043 #define IDS_ERR_GETLINKUPDATEOPTIONS    32458
01044 #define IDS_ERR_ADDSTRING       32459
01045 #define IDS_CHANGEADDITIONALLINKS   32460
01046 #define IDS_CLOSE               32461
01047
01048
01049 /*************************************************************************
01050 ** PROMPT USER DIALOGS
01051 *************************************************************************/
01052 #define ID_PU_LINKS             900
01053 #define ID_PU_TEXT              901
01054 #define ID_PU_CONVERT           902
01055 #define ID_PU_BROWSE            904
01056 #define ID_PU_METER             905
01057 #define ID_PU_PERCENT           906
01058 #define ID_PU_STOP              907
01059
01060 // used for -1 ids in dialogs:
01061 #define ID_DUMMY    999
01062
01063 /* inside ole2ui.c */
01064 #ifdef __cplusplus
01065 extern "C"
01066 #endif
01067
01068 /*************************************************************************
01069 ** OLE OBJECT FEEDBACK EFFECTS
01070 *************************************************************************/
01071
01072 #define OLEUI_HANDLES_USEINVERSE    0x00000001L
01073 #define OLEUI_HANDLES_NOBORDER      0x00000002L
01074 #define OLEUI_HANDLES_INSIDE        0x00000004L
01075 #define OLEUI_HANDLES_OUTSIDE       0x00000008L
01076
01077
01078 #define OLEUI_SHADE_FULLRECT        1
01079 #define OLEUI_SHADE_BORDERIN        2
01080 #define OLEUI_SHADE_BORDEROUT       3
01081
01082 /* objfdbk.c function prototypes */
01083 STDAPI_(void) OleUIDrawHandles(LPRECT lpRect, HDC hdc, DWORD dwFlags, UINT cSize, BOOL fDraw);
01084 STDAPI_(void) OleUIDrawShading(LPRECT lpRect, HDC hdc, DWORD dwFlags, UINT cWidth);
01085 STDAPI_(void) OleUIShowObject(LPCRECT lprc, HDC hdc, BOOL fIsLink);
01086
01087
01088 /*************************************************************************
01089 ** Hatch window definitions and prototypes                              **
01090 *************************************************************************/
01091 #define DEFAULT_HATCHBORDER_WIDTH   4
01092
01093 STDAPI_(BOOL) RegisterHatchWindowClass(HINSTANCE hInst);
01094 STDAPI_(HWND) CreateHatchWindow(HWND hWndParent, HINSTANCE hInst);
01095 STDAPI_(UINT) GetHatchWidth(HWND hWndHatch);
01096 STDAPI_(void) GetHatchRect(HWND hWndHatch, LPRECT lpHatchRect);
01097 STDAPI_(void) SetHatchRect(HWND hWndHatch, LPRECT lprcHatchRect);
01098 STDAPI_(void) SetHatchWindowSize(
01099       HWND        hWndHatch,
01100       LPRECT      lprcIPObjRect,
01101       LPRECT      lprcClipRect,
01102       LPPOINT     lpptOffset
01103 );
01104
01105 #define OLEUI_VERSION_MAGIC 0x4D42
01106
01107 #endif // _OLESTD_H_
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SUMMARYINFO Member List

This is the complete list of members for _SUMMARYINFO, including all inherited members.
byteOrder | _SUMMARYINFO
classId | _SUMMARYINFO
cSections | _SUMMARYINFO
formatVersion | _SUMMARYINFO
getOSVersion | _SUMMARYINFO
osVersion | _SUMMARYINFO
rgPropSet | _SUMMARYINFO
rgSections | _SUMMARYINFO
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/inc/rureg.h Source File

  • NetDS
  • RRas
  • rqs
  • inc

rureg.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       RuReg.h
00004 //
00005 //      Synopsis:   Registry manipulating api's
00006 //
00007 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //+--------------------------------------------------------------------------
00010
00011 #ifndef _RU_REG_H
00012 #define _RU_REG_H
00013
00014 #include "RasUtil.h"
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020 //  pszName: the name of the value to Set/Get
00021 //  dwType:  the type of the data
00022 //  dwSize:  the size of pbData in bytes
00023 //  pbData:  pointer to the data
00024 //  dwErr:   on output, specifies an error on read/write of the value
00025 //
00026 //  For DWORD, BYTE, dwSize is the actual size of the data for REG_SZ,
00027 //  REG_EXPAND_SZ, or REG_MULTI_SZ, dwSize includes the terminating NULL
00028 //  character.
00029 //
00030 typedef struct _RUREGVALUE
00031 {
00032     PWSTR  pszName;
00033     DWORD  dwType;
00034     DWORD  dwSize;  // the size of the data like the registry API
00035     BYTE * pbData;
00036     HRESULT  hr;
00037 } RUREGVALUE, * PRUREGVALUE;
00038
00039 HRESULT
00040 RuRegOpenKey(
00041     IN CONST PWSTR pszKeyPath,
00042     IN BOOL fCreate,
00043     OUT HKEY* phKey);
00044
00045 HRESULT
00046 RuRegGet(
00047     IN CONST PWSTR pszKeyPath,
00048     IN OUT RUREGVALUE * pRegVal,
00049     IN DWORD dwCount
00050     );
00051
00052 VOID
00053 RuRegFreeValues(
00054     IN CONST RUREGVALUE* pValues,
00055     IN UINT uiCount);
00056
00057
00058
00059 #ifdef __cplusplus
00060 }
00061 #endif
00062
00063 #endif
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/localres.h Source File

  • SysMgmt
  • MMC
  • Proppage

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/space.Cpp Source File

  • SysMgmt
  • MMC
  • WMI

space.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include <windows.h>
00021 #include "Space.h"
00022 #include "Comp.h"
00023 #include "resource.h"
00024 #define STRSAFE_NO_DEPRECATE
00025 #include <strsafe.h>
00026
00027 const GUID CSpaceVehicle::thisGuid = { 0x29743810, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00028 const GUID CRocket::thisGuid = { 0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00029
00030 //==============================================================
00031 //
00032 // CSpaceVehicle implementation
00033 //
00034 //
00035 CSpaceVehicle::CSpaceVehicle()
00036 {
00037     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00038         children[n] = new CRocket(_T("Rocket"), n+1, 500000, 265, 75000);
00039     }
00040 }
00041
00042 CSpaceVehicle::~CSpaceVehicle()
00043 {
00044     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00045         if (children[n]) {
00046             delete children[n];
00047         }
00048 }
00049
00050 HRESULT CSpaceVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00051 {
00052     HRESULT      hr = S_OK;
00053
00054     IHeaderCtrl *pHeaderCtrl = NULL;
00055     IResultData *pResultData = NULL;
00056
00057     if (bShow) {
00058         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00059         _ASSERT( SUCCEEDED(hr) );
00060
00061         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00062         _ASSERT( SUCCEEDED(hr) );
00063
00064         // Set the column headers in the results pane
00065         hr = pHeaderCtrl->InsertColumn( 0, L"Rocket Class", 0, MMCLV_AUTO );
00066         _ASSERT( S_OK == hr );
00067         hr = pHeaderCtrl->InsertColumn( 1, L"Rocket Weight", 0, MMCLV_AUTO );
00068         _ASSERT( S_OK == hr );
00069         hr = pHeaderCtrl->InsertColumn( 2, L"Rocket Height", 0, MMCLV_AUTO );
00070         _ASSERT( S_OK == hr );
00071         hr = pHeaderCtrl->InsertColumn( 3, L"Rocket Payload", 0, MMCLV_AUTO );
00072         _ASSERT( S_OK == hr );
00073         hr = pHeaderCtrl->InsertColumn( 4, L"Status", 0, MMCLV_AUTO );
00074         _ASSERT( S_OK == hr );
00075
00076         // insert items here
00077         RESULTDATAITEM rdi;
00078
00079         hr = pResultData->DeleteAllRsltItems();
00080         _ASSERT( SUCCEEDED(hr) );
00081
00082         if (!bExpanded) {
00083             // create the child nodes, then expand them
00084             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00085                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00086                 rdi.mask       = RDI_STR       |   // Displayname is valid
00087                     RDI_IMAGE     |
00088                     RDI_PARAM;        // nImage is valid
00089
00090                 rdi.nImage      = children[n]->GetBitmapIndex();
00091                 rdi.str         = MMC_CALLBACK;
00092                 rdi.nCol        = 0;
00093                 rdi.lParam      = (LPARAM)children[n];
00094
00095                 hr = pResultData->InsertItem( &rdi );
00096
00097                 _ASSERT( SUCCEEDED(hr) );
00098             }
00099         }
00100
00101         pHeaderCtrl->Release();
00102         pResultData->Release();
00103     }
00104
00105     return hr;
00106 }
00107
00108 //==============================================================
00109 //
00110 // CRocket implementation
00111 //
00112 //
00113 CRocket::CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload)
00114 : szName(NULL), lWeight(0), lHeight(0), lPayload(0), iStatus(STOPPED)
00115 {
00116     if (szName) {
00117         this->szName = new _TCHAR[(_tcslen(szName) + 1) * sizeof(_TCHAR)];
00118         _tcscpy(this->szName, szName);
00119     }
00120
00121     this->nId = id;
00122     this->lWeight = lWeight;
00123     this->lHeight = lHeight;
00124     this->lPayload = lPayload;
00125
00126     m_ppHandle = 0;
00127 }
00128
00129 CRocket::~CRocket()
00130 {
00131     if (szName)
00132         delete [] szName;
00133 }
00134
00135 const _TCHAR *CRocket::GetDisplayName(int nCol)
00136 {
00137     const size_t cchBuffer = 128;
00138     static _TCHAR buf[cchBuffer];
00139
00140     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00141     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00142
00143     switch (nCol) {
00144     case 0:
00145         StringCchPrintf(buf, cchBuffer, _T("%s (#%d)"), szName ? szName : _T(""), nId);
00146         break;
00147
00148     case 1:
00149         StringCchPrintf(buf, cchBuffer, _T("%ld metric tons"), lWeight);
00150         break;
00151
00152     case 2:
00153         StringCchPrintf(buf, cchBuffer, _T("%ld meters"), lHeight);
00154         break;
00155
00156     case 3:
00157         StringCchPrintf(buf, cchBuffer, _T("%ld kilos"), lPayload);
00158         break;
00159
00160     case 4:
00161         StringCchPrintf(buf, cchBuffer, _T("%s"),
00162             iStatus == RUNNING ? _T("running") :
00163         iStatus == PAUSED ? _T("paused") :
00164         iStatus == STOPPED ? _T("stopped") : _T("unknown"));
00165         break;
00166
00167     }
00168
00169     return buf;
00170 }
00171
00172 HRESULT CRocket::OnRename(LPOLESTR pszNewName)
00173 {
00174     if (szName) {
00175         delete [] szName;
00176         szName = NULL;
00177     }
00178
00179     MAKE_TSTRPTR_FROMWIDE(ptrname, pszNewName);
00180     szName = new _TCHAR[(_tcslen(ptrname) + 1) * sizeof(_TCHAR)];
00181     _tcscpy(szName, ptrname);
00182
00183     return S_OK;
00184 }
00185
00186 // handle anything special when the user clicks Apply or Ok
00187 // on the property sheet.  This sample directly accesses the
00188 // operated-on object, so there's nothing special to do when the user presses Ok.
00189 // when the user presses Apply, we update the currently selected result item
00190 HRESULT CRocket::OnPropertyChange(IConsole *pConsole)
00191 {
00192
00193     //redraw the item
00194     IResultData *pResultData = NULL;
00195
00196   HRESULT hr;
00197
00198   hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00199   _ASSERT( SUCCEEDED(hr) );
00200
00201   HRESULTITEM myhresultitem;
00202
00203   //lparam == this. See CSpaceVehicle::OnShow
00204   hr = pResultData->FindItemByLParam( (LPARAM)this, &myhresultitem );
00205   _ASSERT( SUCCEEDED(hr) );
00206
00207   hr = pResultData->UpdateItem( myhresultitem );
00208   _ASSERT( SUCCEEDED(hr) );
00209
00210     pResultData->Release();
00211
00212
00213   return S_OK;
00214 }
00215
00216 HRESULT CRocket::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
00217 {
00218     IConsoleVerb *pConsoleVerb;
00219
00220     HRESULT hr = pConsole->QueryConsoleVerb(&pConsoleVerb);
00221     _ASSERT(SUCCEEDED(hr));
00222
00223     hr = pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, TRUE);
00224
00225     // can't get to properties (via the standard methods) unless
00226     // we tell MMC to display the Properties menu item and
00227     // toolbar button, this wil give the user a visual cue that
00228     // there's "something" to do
00229     hr = pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
00230
00231     pConsoleVerb->Release();
00232
00233     return S_OK;
00234 }
00235
00236 // Implement the dialog proc
00237 BOOL CALLBACK CRocket::DialogProc(
00238                                   HWND hwndDlg,  // handle to dialog box
00239                                   UINT uMsg,     // message
00240                                   WPARAM wParam, // first message parameter
00241                                   LPARAM lParam  // second message parameter
00242                                   )
00243 {
00244     static CRocket *pRocket = NULL;
00245
00246     switch (uMsg) {
00247     case WM_INITDIALOG:
00248         // catch the "this" pointer so we can actually operate on the object
00249         pRocket = reinterpret_cast<CRocket *>(reinterpret_cast<PROPSHEETPAGE *>(lParam)->lParam);
00250
00251         SetDlgItemText(hwndDlg, IDC_ROCKET_NAME, pRocket->szName);
00252         SetDlgItemInt(hwndDlg, IDC_ROCKET_HEIGHT, pRocket->lHeight, FALSE);
00253         SetDlgItemInt(hwndDlg, IDC_ROCKET_WEIGHT, pRocket->lWeight, FALSE);
00254         SetDlgItemInt(hwndDlg, IDC_ROCKET_PAYLOAD, pRocket->lPayload, FALSE);
00255
00256         _ASSERT( CB_ERR != SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_INSERTSTRING, 0, (LPARAM)_T("Running")) );
00257         _ASSERT( CB_ERR != SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_INSERTSTRING, 1, (LPARAM)_T("Paused")) );
00258         _ASSERT( CB_ERR != SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_INSERTSTRING, 2, (LPARAM)_T("Stopped")) );
00259
00260         SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_SETCURSEL, (WPARAM)pRocket->iStatus, 0);
00261
00262         break;
00263
00264     case WM_COMMAND:
00265         // turn the Apply button on
00266         if (HIWORD(wParam) == EN_CHANGE ||
00267             HIWORD(wParam) == CBN_SELCHANGE)
00268             SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
00269         break;
00270
00271     case WM_DESTROY:
00272         // tell MMC that we're done with the property sheet (we got this
00273         // handle in CreatePropertyPages
00274         MMCFreeNotifyHandle(pRocket->m_ppHandle);
00275         break;
00276
00277     case WM_NOTIFY:
00278         switch (((NMHDR *) lParam)->code) {
00279         case PSN_APPLY:
00280             // update the information
00281             if (pRocket->szName) {
00282                 delete [] pRocket->szName;
00283                 pRocket->szName = NULL;
00284             }
00285
00286             {
00287                 int n = SendDlgItemMessage(hwndDlg, IDC_ROCKET_NAME, WM_GETTEXTLENGTH, 0, 0);
00288                 if (n != 0) {
00289                     pRocket->szName = new _TCHAR[n + 1];
00290                     GetDlgItemText(hwndDlg, IDC_ROCKET_NAME, pRocket->szName, n + 1);
00291                 }
00292             }
00293             pRocket->lHeight = GetDlgItemInt(hwndDlg, IDC_ROCKET_HEIGHT, NULL, FALSE);
00294             pRocket->lWeight = GetDlgItemInt(hwndDlg, IDC_ROCKET_WEIGHT, NULL, FALSE);
00295             pRocket->lPayload = GetDlgItemInt(hwndDlg, IDC_ROCKET_PAYLOAD, NULL, FALSE);
00296
00297             pRocket->iStatus = (ROCKET_STATUS)SendDlgItemMessage(hwndDlg, IDC_ROCKET_STATUS, CB_GETCURSEL, 0, 0);
00298
00299             // ask MMC to send us a message (on the main thread) so
00300             // we know the Apply button was clicked.
00301             HRESULT hr = MMCPropertyChangeNotify(pRocket->m_ppHandle, (long)pRocket);
00302
00303             _ASSERT(SUCCEEDED(hr));
00304
00305             return PSNRET_NOERROR;
00306         }
00307         break;
00308     }
00309
00310     return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
00311 }
00312
00313
00314 HRESULT CRocket::HasPropertySheets()
00315 {
00316     // say "yes" when MMC asks if we have pages
00317     return S_OK;
00318 }
00319
00320 HRESULT CRocket::CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle)
00321 {
00322     PROPSHEETPAGE psp;
00323     HPROPSHEETPAGE hPage = NULL;
00324
00325     // cache this handle so we can call MMCPropertyChangeNotify
00326     m_ppHandle = handle;
00327
00328     // create the property page for this node.
00329     // NOTE: if your node has multiple pages, put the following
00330     // in a loop and create multiple pages calling
00331     // lpProvider->AddPage() for each page.
00332     psp.dwSize = sizeof(PROPSHEETPAGE);
00333     psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEICONID;
00334     psp.hInstance = g_hinst;
00335     psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE);
00336     psp.pfnDlgProc = DialogProc;
00337     psp.lParam = reinterpret_cast<LPARAM>(this);
00338     psp.pszTitle = MAKEINTRESOURCE(IDS_PST_ROCKET);
00339     psp.pszIcon = MAKEINTRESOURCE(IDI_PSI_ROCKET);
00340
00341
00342     hPage = CreatePropertySheetPage(&psp);
00343     _ASSERT(hPage);
00344
00345     return lpProvider->AddPage(hPage);
00346 }
00347
00348 HRESULT CRocket::GetWatermarks(HBITMAP *lphWatermark,
00349                                HBITMAP *lphHeader,
00350                                HPALETTE *lphPalette,
00351                                BOOL *bStretch)
00352 {
00353     return S_FALSE;
00354 }
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/CmdLineConsumer/CmdLineConsumerDlg.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • CmdLineConsumer

CmdLineConsumerDlg.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  CmdLineConsumerDlg.cpp
00006 //
00007 // Description:
00008 //      Implementation file for command-line event consumer dialog boxes
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #include "stdafx.h"
00015 #include "CmdLineConsumer.h"
00016 #include "CmdLineConsumerDlg.h"
00017
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CAboutDlg dialog used for App About
00026
00027 class CAboutDlg : public CDialog
00028 {
00029 public:
00030   CAboutDlg();
00031
00032 // Dialog Data
00033   //{{AFX_DATA(CAboutDlg)
00034   enum { IDD = IDD_ABOUTBOX };
00035   //}}AFX_DATA
00036
00037   // ClassWizard generated virtual function overrides
00038   //{{AFX_VIRTUAL(CAboutDlg)
00039   protected:
00040   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00041   //}}AFX_VIRTUAL
00042
00043 // Implementation
00044 protected:
00045   //{{AFX_MSG(CAboutDlg)
00046   //}}AFX_MSG
00047   DECLARE_MESSAGE_MAP()
00048 };
00049
00050 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00051 {
00052   //{{AFX_DATA_INIT(CAboutDlg)
00053   //}}AFX_DATA_INIT
00054 }
00055
00056 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00057 {
00058   CDialog::DoDataExchange(pDX);
00059   //{{AFX_DATA_MAP(CAboutDlg)
00060   //}}AFX_DATA_MAP
00061 }
00062
00063 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00064   //{{AFX_MSG_MAP(CAboutDlg)
00065     // No message handlers
00066   //}}AFX_MSG_MAP
00067 END_MESSAGE_MAP()
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 // CCmdLineConsumerDlg dialog
00071
00072 CCmdLineConsumerDlg::CCmdLineConsumerDlg(CWnd* pParent /*=NULL*/)
00073   : CDialog(CCmdLineConsumerDlg::IDD, pParent)
00074 {
00075   //{{AFX_DATA_INIT(CCmdLineConsumerDlg)
00076     // NOTE: the ClassWizard will add member initialization here
00077   //}}AFX_DATA_INIT
00078   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
00079   m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00080 }
00081
00082 void CCmdLineConsumerDlg::DoDataExchange(CDataExchange* pDX)
00083 {
00084   CDialog::DoDataExchange(pDX);
00085   //{{AFX_DATA_MAP(CCmdLineConsumerDlg)
00086   DDX_Control(pDX, IDC_LIST, m_output);
00087   //}}AFX_DATA_MAP
00088 }
00089
00090 BEGIN_MESSAGE_MAP(CCmdLineConsumerDlg, CDialog)
00091   //{{AFX_MSG_MAP(CCmdLineConsumerDlg)
00092   ON_WM_SYSCOMMAND()
00093   ON_WM_PAINT()
00094   ON_WM_QUERYDRAGICON()
00095   //}}AFX_MSG_MAP
00096 END_MESSAGE_MAP()
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // CCmdLineConsumerDlg message handlers
00100
00101 BOOL CCmdLineConsumerDlg::OnInitDialog()
00102 {
00103   CDialog::OnInitDialog();
00104
00105   // this controls the app's main dialog box.
00106   ShowWindow(SW_MINIMIZE);
00107
00108   // Add "About..." menu item to system menu.
00109
00110   // IDM_ABOUTBOX must be in the system command range.
00111   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00112   ASSERT(IDM_ABOUTBOX < 0xF000);
00113
00114   CMenu* pSysMenu = GetSystemMenu(FALSE);
00115   if (pSysMenu != NULL)
00116   {
00117     CString strAboutMenu;
00118     strAboutMenu.LoadString(IDS_ABOUTBOX);
00119     if (!strAboutMenu.IsEmpty())
00120     {
00121       pSysMenu->AppendMenu(MF_SEPARATOR);
00122       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
00123     }
00124   }
00125
00126   // Set the icon for this dialog.  The framework does this automatically
00127   //  when the application's main window is not a dialog
00128   SetIcon(m_hIcon, TRUE);     // Set big icon
00129   SetIcon(m_hIcon, FALSE);    // Set small icon
00130
00131   // TODO: Add extra initialization here
00132
00133   return TRUE;  // return TRUE  unless you set the focus to a control
00134 }
00135
00136 void CCmdLineConsumerDlg::OnSysCommand(UINT nID, LPARAM lParam)
00137 {
00138   if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00139   {
00140     CAboutDlg dlgAbout;
00141     dlgAbout.DoModal();
00142   }
00143   else
00144   {
00145     CDialog::OnSysCommand(nID, lParam);
00146   }
00147 }
00148
00149 // If you add a minimize button to your dialog, you will need the code below
00150 //  to draw the icon.  For MFC applications using the document/view model,
00151 //  this is automatically done for you by the framework.
00152
00153 void CCmdLineConsumerDlg::OnPaint()
00154 {
00155   if (IsIconic())
00156   {
00157     CPaintDC dc(this); // device context for painting
00158
00159     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
00160
00161     // Center icon in client rectangle
00162     int cxIcon = GetSystemMetrics(SM_CXICON);
00163     int cyIcon = GetSystemMetrics(SM_CYICON);
00164     CRect rect;
00165     GetClientRect(&rect);
00166     int x = (rect.Width() - cxIcon + 1) / 2;
00167     int y = (rect.Height() - cyIcon + 1) / 2;
00168
00169     // Draw the icon
00170     dc.DrawIcon(x, y, m_hIcon);
00171   }
00172   else
00173   {
00174     CDialog::OnPaint();
00175   }
00176 }
00177
00178 // The system calls this to obtain the cursor to display while the user drags
00179 //  the minimized window.
00180 HCURSOR CCmdLineConsumerDlg::OnQueryDragIcon()
00181 {
00182   return (HCURSOR) m_hIcon;
00183 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/comp.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

comp.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "Comp.h"
00017 #include "CompData.h"
00018 #include "DataObj.h"
00019 #include "Resource.h"
00020 #include "StaticNode.h"
00021
00022                              // Tracing stuff
00023 #include "TraceMacro.h"
00024 #undef  MODULESTRING
00025 #define MODULESTRING  _T("CComponent")
00026
00027
00028 //---------------------------------------------------------------------------
00029 //  Our default constuctor provides a pointer to the parent CComponentData
00030 //  class which we cache for use in later samples.
00031 //
00032 CComponent::CComponent
00033 (
00034   CComponentData*  pParent   //[in] Points to parent object
00035 )
00036 {
00037   _ASSERT( NULL != pParent );
00038
00039   m_cRef           = 0;
00040   m_hImageStrip16  = NULL;
00041   m_hImageStrip32  = NULL;
00042   m_ipConsole      = NULL;
00043   m_ipConsoleVerb  = NULL;
00044   m_ipResultData   = NULL;
00045   m_ipHeaderCtrl   = NULL;
00046   m_pComponentData = pParent;
00047
00048 }
00049
00050 //---------------------------------------------------------------------------
00051 CComponent::~CComponent()
00052 {
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 //  Implementation of IUnknown
00057
00058 //---------------------------------------------------------------------------
00059 //  PROPPAGE:  Support for IExtendPropertySheet2 added
00060 //
00061 STDMETHODIMP CComponent::QueryInterface
00062 (
00063   REFIID   riid,       //[in] Identifier of the requested interface
00064   LPVOID   *ppv        //[out] Address of requested interface
00065 )
00066 {
00067   if( !ppv )
00068     return E_FAIL;
00069
00070   *ppv = NULL;
00071
00072   if( IsEqualIID(riid, IID_IUnknown) )
00073     *ppv = static_cast<IComponent*>(this);
00074   else if( IsEqualIID(riid, IID_IComponent) )
00075     *ppv = static_cast<IComponent*>(this);
00076   else if( IsEqualIID(riid, IID_IComponent2) )
00077     *ppv = static_cast<IComponent2*>(this);
00078   else if( IsEqualIID(riid, IID_IExtendPropertySheet2) )
00079     *ppv = static_cast<IExtendPropertySheet2*>(this);
00080
00081
00082   if( *ppv )
00083   {
00084     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00085     return S_OK;
00086   }
00087
00088   return E_NOINTERFACE;
00089 }
00090
00091 //---------------------------------------------------------------------------
00092 STDMETHODIMP_(ULONG) CComponent::AddRef()
00093 {
00094   return InterlockedIncrement((LONG*)&m_cRef);
00095 }
00096
00097 //---------------------------------------------------------------------------
00098 STDMETHODIMP_(ULONG) CComponent::Release()
00099 {
00100   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00101   {
00102     delete this;
00103     return 0;
00104   }
00105   return m_cRef;
00106 }
00107
00108 /////////////////////////////////////////////////////////////////////////////
00109 // Implementation of IComponent2
00110
00111 //---------------------------------------------------------------------------
00112 STDMETHODIMP CComponent::Initialize
00113 (
00114   LPCONSOLE ipConsole    //[in] Points to the console's IUnknown
00115 )
00116 {
00117   HRESULT hResult = S_FALSE;
00118
00119   do
00120   {
00121     hResult = ipConsole->QueryInterface( IID_IConsole3,(VOID**)&m_ipConsole );
00122     BREAK_ON_ERROR( hResult );
00123
00124     hResult = m_ipConsole->QueryConsoleVerb( &m_ipConsoleVerb );
00125     BREAK_ON_ERROR( hResult );
00126
00127     hResult = m_ipConsole->QueryInterface( IID_IResultData2,(VOID**)&m_ipResultData );
00128     BREAK_ON_ERROR( hResult );
00129
00130     hResult = m_ipConsole->QueryInterface( IID_IHeaderCtrl2,(VOID**)&m_ipHeaderCtrl );
00131     BREAK_ON_ERROR( hResult );
00132
00133     // Load the bitmaps from the dll for the results pane
00134     m_hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16));
00135     if( NULL == m_hImageStrip16 )
00136     {
00137       hResult = S_FALSE;
00138       continue;
00139     }
00140
00141     m_hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32));
00142     if( NULL == m_hImageStrip32 )
00143     {
00144       hResult = S_FALSE;
00145       continue;
00146     }
00147
00148   }while( 0 );
00149
00150   TRACE_HRESULT(_T("Initialize"), hResult );
00151   return hResult;
00152 }
00153
00154
00155 //---------------------------------------------------------------------------
00156 STDMETHODIMP CComponent::Notify
00157 (
00158   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00159   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00160   LONG             nArg,           //[in] Depends on the notification type
00161   LONG             nParam          //[in] Depends on the notification type
00162 )
00163 {
00164   HRESULT hResult = S_FALSE;       // Return this for unhandled notifications
00165   TRACE_EVENT( _T("Notify"), MmcEvent );
00166
00167   // PROPPAGE: Special handling of this event since it has a NULL DataObject.
00168   //           We passed in the HRESULTITEM of the node which owns the
00169   //           property page, so all we have to do is redraw that node to
00170   //           reflect any changes made.
00171   //
00172   if( MMCN_PROPERTY_CHANGE == MmcEvent )
00173   {
00174     return m_ipResultData->UpdateItem( (HRESULTITEM)nParam );
00175   }
00176
00177   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00178   if( NULL == pNode )
00179     return E_FAIL;
00180
00181
00182   switch( MmcEvent )
00183   {
00184     case MMCN_ADD_IMAGES:
00185       hResult = OnAddImages( ipDataObject, nArg, nParam );
00186       break;
00187
00188     case MMCN_SELECT:
00189       hResult = pNode->OnSelect( ipDataObject, nArg, nParam, (LONG_PTR)this );
00190       break;
00191
00192     case MMCN_SHOW:
00193       hResult = pNode->OnShow( ipDataObject, nArg, nParam, (LONG_PTR)this );
00194       break;
00195
00196     case MMCN_VIEW_CHANGE:
00197       hResult = pNode->OnViewChange( ipDataObject, nArg, nParam, (LONG_PTR)this );
00198       break;
00199
00200     case MMCN_DELETE:
00201       hResult = pNode->OnDelete( ipDataObject, nArg, nParam, (LONG_PTR)this );
00202       break;
00203
00204     // PROPPAGE:  Returning S_FALSE from here executes the default verb.
00205     case MMCN_DBLCLICK:
00206       break;
00207
00208     default:
00209       break;
00210   }
00211   return hResult;
00212 }
00213
00214 //---------------------------------------------------------------------------
00215 STDMETHODIMP CComponent::Destroy
00216 (
00217   MMC_COOKIE nCookie   //[in] Not used
00218 )
00219 {
00220   SAFE_RELEASE( m_ipConsole     );
00221   SAFE_RELEASE( m_ipHeaderCtrl  );
00222   SAFE_RELEASE( m_ipResultData  );
00223   SAFE_RELEASE( m_ipConsoleVerb );
00224
00225   SAFE_FREE_BITMAP( m_hImageStrip16 );
00226   SAFE_FREE_BITMAP( m_hImageStrip32 );
00227
00228   return S_OK;
00229 }
00230
00231 //---------------------------------------------------------------------------
00232 STDMETHODIMP CComponent::QueryDataObject
00233 (
00234   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00235   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00236   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00237 )
00238 {
00239   _ASSERT( NULL != nCookie );
00240   HRESULT hResult = S_FALSE;
00241
00242   CDataObject* pNewObject = new CDataObject();
00243   if( NULL == pNewObject )
00244     hResult = E_OUTOFMEMORY;
00245
00246   pNewObject->SetPrivateData( nCookie, (ULONG)nEnumType );
00247
00248   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00249
00250   return hResult;
00251 }
00252
00253 //---------------------------------------------------------------------------
00254 //  This method is not called in MMC20
00255 //
00256 STDMETHODIMP CComponent::GetResultViewType
00257 (
00258   MMC_COOKIE          nCookie,     //[in]  Indentifier of selected node
00259   LPOLESTR __RPC_FAR* ppViewType,  //[out] Points to view type string
00260   long __RPC_FAR*     pViewOptions //[out] Points to MMC_VIEW_OPTIONS enumeration
00261 )
00262 {
00263   _ASSERT( FALSE );
00264   return E_NOTIMPL;
00265 }
00266
00267
00268 //---------------------------------------------------------------------------
00269 STDMETHODIMP CComponent::GetDisplayInfo
00270 (
00271   RESULTDATAITEM __RPC_FAR* pResultDataItem  //[in-out] Result item struct
00272 )
00273 {
00274   _ASSERT( NULL != pResultDataItem );
00275   _ASSERT( NULL != pResultDataItem->lParam );
00276
00277   HRESULT  hResult = S_FALSE;
00278
00279   LPBASENODE pNode = reinterpret_cast<LPBASENODE>(pResultDataItem->lParam);
00280   hResult = pNode->GetDisplayInfo( pResultDataItem );
00281
00282   //TRACE_HRESULT( _T("GetDisplayInfo"), hResult );
00283   return hResult;
00284 }
00285
00286 //---------------------------------------------------------------------------
00287 //  PROPPAGE:  This method is called by the console when a Property Page
00288 //             is already up for an object, and the user has attempted to
00289 //             bring up a second page for the same object.  The cookies,
00290 //             which are really pointers to the selected node, are compared
00291 //             and if they match we return S_OK.  In this case the console
00292 //             will not bring up the Property Page for that object, instead
00293 //             the existing page is brought to the foreground
00294 //
00295 STDMETHODIMP CComponent::CompareObjects
00296 (
00297   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00298   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00299 )
00300 {
00301   HRESULT hResult = S_FALSE;
00302
00303   CDataObject* pDO_A = ExtractDataObjPtr( ipDataObjectA );
00304   CDataObject* pDO_B = ExtractDataObjPtr( ipDataObjectB );
00305   if( NULL == pDO_A || NULL == pDO_B )
00306     return hResult;
00307
00308   (pDO_A->GetCookie() == pDO_B->GetCookie()) ? hResult = S_OK : hResult = S_FALSE;
00309
00310   return hResult;
00311 }
00312
00313 //---------------------------------------------------------------------------
00314 HRESULT CComponent::QueryDispatch
00315 (
00316   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00317   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00318   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00319 )
00320 {
00321   return E_NOTIMPL;
00322 }
00323
00324 //---------------------------------------------------------------------------
00325 //  NOTE:  Failure to correctly implement this method will result in
00326 //         the error:  "Snap-in failed to initialize"
00327 //
00328 HRESULT CComponent::GetResultViewType2
00329 (
00330   MMC_COOKIE             nCookie,  //[in] Identifier of object
00331   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00332 )
00333 {
00334   HRESULT hResult = S_FALSE;
00335
00336   if( NULL == nCookie )
00337   {
00338     CStaticNode* pNode = m_pComponentData->GetStaticNode();
00339     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00340   }
00341   else
00342   {
00343     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(nCookie);
00344     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00345   }
00346
00347   TRACE_HRESULT(_T("GetResultViewType2"), hResult );
00348   return hResult;
00349 }
00350
00351
00352 //---------------------------------------------------------------------------
00353 HRESULT CComponent::RestoreResultView
00354 (
00355   MMC_COOKIE             nCookie,  //[in] Identifier of object
00356   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00357 )
00358 {
00359   return E_NOTIMPL;
00360 }
00361
00362 /////////////////////////////////////////////////////////////////////////////
00363 //  IExtendPropertySheet2
00364
00365 //---------------------------------------------------------------------------
00366 //  PROPPAGE:  Nodes own their own property pages so we delegate creating
00367 //             the pages.
00368 //
00369 STDMETHODIMP CComponent::CreatePropertyPages
00370 (
00371   LPPROPERTYSHEETCALLBACK lpProvider,  //[in] Pointer to callback interface
00372   LONG_PTR                Handle,      //[in] Handle for routing notification
00373   LPDATAOBJECT            ipDataObject //[in] Pointer to data object
00374 )
00375 {
00376   _ASSERT( NULL != ipDataObject );
00377   HRESULT hResult = S_FALSE;
00378
00379   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00380   if( NULL == pNode )
00381     return E_FAIL;
00382
00383   return pNode->CreatePropertyPages( lpProvider, Handle );
00384
00385 }
00386
00387 //---------------------------------------------------------------------------
00388 //  PROPPAGE:  If the Property Page verb is enabled, the console will call
00389 //             this method to see if the node has a propery page to add.
00390 //
00391 STDMETHODIMP CComponent::QueryPagesFor
00392 (
00393   LPDATAOBJECT ipDataObject  //[in] Pointer to selected data object
00394 )
00395 {
00396   _ASSERT( NULL != ipDataObject );
00397   HRESULT hResult = S_FALSE;
00398
00399   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00400   if( NULL == pNode )
00401     return E_FAIL;
00402
00403   return pNode->QueryForPropertyPage();
00404
00405 }
00406
00407 //---------------------------------------------------------------------------
00408 STDMETHODIMP CComponent::GetWatermarks
00409 (
00410   LPDATAOBJECT        ipDataObject,  //[in]  Pointer to data object
00411   HBITMAP __RPC_FAR*  lphWatermark,  //[out] Pointer to watermark bitmap
00412   HBITMAP __RPC_FAR*  lphHeader,     //[out] Pointer to header bitmap
00413   HPALETTE __RPC_FAR* lphPalette,    //[out] Pointer to palette
00414   BOOL __RPC_FAR*     bStretch       //[out] TRUE to stretch instead of tile
00415 )
00416 {
00417   _ASSERT( NULL != ipDataObject );
00418   HRESULT hResult = S_FALSE;
00419
00420
00421   return hResult;
00422 }
00423
00424 /////////////////////////////////////////////////////////////////////////////
00425 //  Notification handlers
00426
00427
00428 //---------------------------------------------------------------------------
00429 HRESULT CComponent::OnAddImages
00430 (
00431   LPDATAOBJECT   ipDataObject, //[in] Points to the selected data object
00432   LONG           nArg,         //[in] Pointer to IImageList
00433   LONG           nParam        //[in] HSCOPEITEM of selected/deselected item
00434
00435 )
00436 {
00437   HRESULT hResult = S_FALSE;
00438
00439   if( NULL != nArg )           // May get this when shutting down
00440   {
00441     IImageList* ipImageList = reinterpret_cast<IImageList*>(nArg);
00442     hResult = ipImageList->ImageListSetStrip( (LONG*)m_hImageStrip16,
00443                                               (LONG*)m_hImageStrip32,
00444                                               0,
00445                                               RGB(0,255,0)
00446                                             );
00447   }
00448   TRACE_HRESULT(_T("OnAddImages"), hResult );
00449   return hResult;
00450
00451 }
00452
00453 /////////////////////////////////////////////////////////////////////////////
00454 //  Public helper methods
00455
00456 //---------------------------------------------------------------------------
00457 //  Supplies interfaces to node objects.
00458 //
00459 HRESULT CComponent::GetInterface
00460 (
00461   DWORD dwRequestedInterface,  //[in] Request flag
00462   LONG_PTR* ppInterface        //[in-out] Interface pointer to return
00463 )
00464 {
00465   _ASSERT( NULL != ppInterface );
00466   HRESULT hResult = S_OK;
00467
00468   switch( dwRequestedInterface )
00469   {
00470     case REQUEST_ICONSOLE:
00471       _ASSERT( NULL != m_ipConsole );
00472       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00473       break;
00474
00475     case REQUEST_ICONSOLEVERB:
00476       _ASSERT( NULL != m_ipConsoleVerb );
00477       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleVerb);
00478       break;
00479
00480     case REQUEST_IRESULTDATA:
00481       _ASSERT( NULL != m_ipResultData );
00482       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipResultData);
00483       break;
00484
00485     case REQUEST_IHEADERCTRL:
00486       _ASSERT( NULL != m_ipHeaderCtrl );
00487       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipHeaderCtrl);
00488       break;
00489
00490     default:
00491       hResult = S_FALSE;
00492       *ppInterface = NULL;
00493       break;
00494   }
00495   return hResult;
00496 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkCollection_RTS/C#/InkCollection.cs Source File

  • TabletPC
  • InkCollection_RTS
  • C#

InkCollection.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2004 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: InkCollection.cs
00013 //  Simple Ink Collection Sample Application
00014 //
00015 //  This sample program demonstrates how to use a real time stylus
00016 //  to collect and render pen input.
00017 //
00018 //  The features used are: RealTimeStylus, DynamicRenderer,
00019 //  and IStylusAsyncPlugin.
00020 //
00021 //--------------------------------------------------------------------------
00022
00023 using System;
00024 using System.Diagnostics;
00025 using System.Drawing;
00026 using System.Windows.Forms;
00027 using System.Collections;
00028
00029 // The Microsoft Tablet PC namespaces
00030 using Microsoft.Ink;
00031 using Microsoft.StylusInput;
00032 using Microsoft.StylusInput.PluginData;
00033
00034
00035 namespace InkCollection
00036 {
00037
00038     /// <summary>
00039     /// The InkCollection Sample Application form class
00040     /// </summary>
00041     public class InkCollection : Form, IStylusAsyncPlugin
00042     {
00043
00044         // Declare constants for the pen widths used by this application.
00045         // Note that these constants are in himetric units (1 unit = .01mm)
00046         private const float ThinInkWidth = 10;
00047         private const float MediumInkWidth = 100;
00048         private const float ThickInkWidth = 200;
00049
00050         // Declare the real time stylus
00051         private RealTimeStylus myRealTimeStylus;
00052
00053         // Declare the renderers.  The dynamic renderer is used to render the ink
00054         // stroke that is currently being collected, whereas the static renderer
00055         // is used to render strokes that have already been collected.
00056         private DynamicRenderer myDynamicRenderer;
00057         private Renderer myRenderer;
00058
00059         // Declare the hashtable used to store packet data that is being collected by one
00060         // or more cursors.  StylusId's are used as the hashtable key to uniquely
00061         // identify the packet data collected for a given cursor.
00062         private Hashtable myPackets;
00063
00064         // Declare the ink object used to store strokes collected by the real time stylus.
00065         private Ink myInk;
00066
00067         #region Standard Template Code
00068
00069         private System.Windows.Forms.MenuItem miMainFile;
00070         private System.Windows.Forms.MenuItem miExit;
00071         private System.Windows.Forms.MenuItem miMainInk;
00072         private System.Windows.Forms.MenuItem miEnabled;
00073         private System.Windows.Forms.MenuItem miColor;
00074         private System.Windows.Forms.MenuItem miRed;
00075         private System.Windows.Forms.MenuItem miGreen;
00076         private System.Windows.Forms.MenuItem miBlue;
00077         private System.Windows.Forms.MenuItem miBlack;
00078         private System.Windows.Forms.MenuItem miWidth;
00079         private System.Windows.Forms.MenuItem miThin;
00080         private System.Windows.Forms.MenuItem miMedium;
00081         private System.Windows.Forms.MenuItem miThick;
00082         private System.Windows.Forms.MainMenu miMain;
00083         private System.ComponentModel.Container components = null;
00084         #endregion
00085
00086         public InkCollection()
00087         {
00088             #region Standard Template Code
00089             // Required for Windows Form Designer support
00090             InitializeComponent();
00091             #endregion
00092         }
00093
00094         #region Standard Template Code
00095         /// <summary>
00096         /// Clean up any resources being used.
00097         /// </summary>
00098         protected override void Dispose( bool disposing )
00099         {
00100             if( disposing )
00101             {
00102                 if (components != null)
00103                 {
00104                     components.Dispose();
00105                 }
00106             }
00107             base.Dispose( disposing );
00108
00109         }
00110         #endregion
00111
00112         #region Windows Form Designer generated code
00113         /// <summary>
00114         /// ----- Standard Template Code -----
00115         /// Required method for Designer support - do not modify
00116         /// the contents of this method with the code editor.
00117         /// </summary>
00118         private void InitializeComponent()
00119         {
00120             this.miMain = new System.Windows.Forms.MainMenu();
00121             this.miMainFile = new System.Windows.Forms.MenuItem();
00122             this.miExit = new System.Windows.Forms.MenuItem();
00123             this.miMainInk = new System.Windows.Forms.MenuItem();
00124             this.miEnabled = new System.Windows.Forms.MenuItem();
00125             this.miColor = new System.Windows.Forms.MenuItem();
00126             this.miRed = new System.Windows.Forms.MenuItem();
00127             this.miGreen = new System.Windows.Forms.MenuItem();
00128             this.miBlue = new System.Windows.Forms.MenuItem();
00129             this.miBlack = new System.Windows.Forms.MenuItem();
00130             this.miWidth = new System.Windows.Forms.MenuItem();
00131             this.miThin = new System.Windows.Forms.MenuItem();
00132             this.miMedium = new System.Windows.Forms.MenuItem();
00133             this.miThick = new System.Windows.Forms.MenuItem();
00134             //
00135             // miMain
00136             //
00137             this.miMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00138                                                                                    this.miMainFile,
00139                                                                                    this.miMainInk});
00140             //
00141             // miMainFile
00142             //
00143             this.miMainFile.Index = 0;
00144             this.miMainFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00145                                                                                        this.miExit});
00146             this.miMainFile.Text = "File";
00147             //
00148             // miExit
00149             //
00150             this.miExit.Index = 0;
00151             this.miExit.Text = "Exit";
00152             this.miExit.Click += new System.EventHandler(this.miExit_Click);
00153             //
00154             // miMainInk
00155             //
00156             this.miMainInk.Index = 1;
00157             this.miMainInk.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00158                                                                                       this.miEnabled,
00159                                                                                       this.miColor,
00160                                                                                       this.miWidth});
00161             this.miMainInk.Text = "Ink";
00162             //
00163             // miEnabled
00164             //
00165             this.miEnabled.Checked = true;
00166             this.miEnabled.Index = 0;
00167             this.miEnabled.Text = "Enabled";
00168             this.miEnabled.Click += new System.EventHandler(this.miEnabled_Click);
00169             //
00170             // miColor
00171             //
00172             this.miColor.Index = 1;
00173             this.miColor.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00174                                                                                     this.miRed,
00175                                                                                     this.miGreen,
00176                                                                                     this.miBlue,
00177                                                                                     this.miBlack});
00178             this.miColor.Text = "Color";
00179             //
00180             // miRed
00181             //
00182             this.miRed.Index = 0;
00183             this.miRed.Text = "Red";
00184             this.miRed.Click += new System.EventHandler(this.miRed_Click);
00185             //
00186             // miGreen
00187             //
00188             this.miGreen.Index = 1;
00189             this.miGreen.Text = "Green";
00190             this.miGreen.Click += new System.EventHandler(this.miGreen_Click);
00191             //
00192             // miBlue
00193             //
00194             this.miBlue.Index = 2;
00195             this.miBlue.Text = "Blue";
00196             this.miBlue.Click += new System.EventHandler(this.miBlue_Click);
00197             //
00198             // miBlack
00199             //
00200             this.miBlack.Index = 3;
00201             this.miBlack.Text = "Black";
00202             this.miBlack.Click += new System.EventHandler(this.miBlack_Click);
00203             //
00204             // miWidth
00205             //
00206             this.miWidth.Index = 2;
00207             this.miWidth.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00208                                                                                     this.miThin,
00209                                                                                     this.miMedium,
00210                                                                                     this.miThick});
00211             this.miWidth.Text = "Width";
00212             //
00213             // miThin
00214             //
00215             this.miThin.Index = 0;
00216             this.miThin.Text = "Thin";
00217             this.miThin.Click += new System.EventHandler(this.miThin_Click);
00218             //
00219             // miMedium
00220             //
00221             this.miMedium.Index = 1;
00222             this.miMedium.Text = "Medium";
00223             this.miMedium.Click += new System.EventHandler(this.miMedium_Click);
00224             //
00225             // miThick
00226             //
00227             this.miThick.Index = 2;
00228             this.miThick.Text = "Thick";
00229             this.miThick.Click += new System.EventHandler(this.miThick_Click);
00230             //
00231             // InkCollection
00232             //
00233             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00234             this.ClientSize = new System.Drawing.Size(292, 245);
00235             this.Menu = this.miMain;
00236             this.Name = "InkCollection";
00237             this.Text = "RTS Ink Collection Sample";
00238             this.Load += new System.EventHandler(this.InkCollection_Load);
00239             this.Paint += new System.Windows.Forms.PaintEventHandler(this.InkCollection_Paint);
00240
00241
00242         }
00243         #endregion
00244
00245         #region Standard Template Code
00246         /// <summary>
00247         /// The main entry point for the application.
00248         /// </summary>
00249         [STAThread]
00250         static void Main()
00251         {
00252             Application.Run(new InkCollection());
00253         }
00254         #endregion
00255
00256         /// <summary>
00257         /// Event Handler from Form Load Event
00258         /// Set up the real time stylus for collection
00259         /// </summary>
00260         /// <param name="sender">The control that raised the event.</param>
00261         /// <param name="e">The event arguments.</param>
00262         private void InkCollection_Load(object sender, System.EventArgs e)
00263         {
00264
00265             // Create the renderers.  The dynamic renderer is used to render the ink
00266             // stroke that is currently being collected, whereas the static renderer
00267             // is used to render strokes that have already been collected.
00268             myDynamicRenderer = new DynamicRenderer(this);
00269             myRenderer = new Renderer();
00270
00271             //
00272             // If you do not modify the default drawing attributes, the default
00273             // drawing attributes will use the following properties and values:
00274             //
00275             //      AntiAliased     = true
00276             //      Color           = black
00277             //      FitToCurve      = false
00278             //      Height          = 1
00279             //      IgnorePressure  = false
00280             //      PenTip          = ball
00281             //      RasterOperation = copy pen
00282             //      Transparency    = 0
00283             //      Width           = 53 (2 pixels on a 96 dpi screen)
00284             //
00285             // For an example of how to modify other drawing attributes, uncomment
00286             // the following lines of code:
00287             // myDynamicRenderer.DrawingAttributes.PenTip = PenTip.Rectangle;
00288             // myDynamicRenderer.DrawingAttributes.Height = (.5F)*MediumInkWidth;
00289             // myDynamicRenderer.DrawingAttributes.Transparency = 128;
00290             //
00291
00292             // Create the real time stylus used to receive stylus notifications
00293             myRealTimeStylus = new RealTimeStylus(this, true);
00294
00295             // Add the dynamic renderer to the synchronous plugin notification chain.
00296             // Synchronous notifications occur on the pen thread.
00297             myRealTimeStylus.SyncPluginCollection.Add(myDynamicRenderer);
00298
00299             // Add the form to the asynchronous plugin notification chain.  This plugin
00300             // will be used to collect stylus data into an ink object.  Asynchronous
00301             // notifications occur on the UI thread.
00302             myRealTimeStylus.AsyncPluginCollection.Add(this);
00303
00304             // Enable the real time stylus and the dynamic renderer
00305             myRealTimeStylus.Enabled = true;
00306             myDynamicRenderer.Enabled = true;
00307
00308             // Create the ink object used to store ink collected from the real time stylus
00309             myPackets = new Hashtable();
00310             myInk = new Ink();
00311         }
00312
00313         /// <summary>
00314         /// Event Handler from the form Paint event.
00315         /// </summary>
00316         /// <param name="sender">The control that raised the event.</param>
00317         /// <param name="e">The event arguments.</param>
00318         private void InkCollection_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
00319         {
00320             // Refresh the dynamic renderer, since it's possible that a stroke is being
00321             // collected at the time Paint occurs.  In this case, the portion of the stroke
00322             // that has already been collected will need to be redrawn.
00323             myDynamicRenderer.Refresh();
00324
00325             // Use the static renderer to redraw strokes that have already been collected.
00326             myRenderer.Draw(e.Graphics, myInk.Strokes);
00327         }
00328
00329         #region Menu Event Handlers
00330         /// <summary>
00331         /// Event Handler from Ink->Color->Red Menu Item
00332         /// </summary>
00333         /// <param name="sender">The control that raised the event.</param>
00334         /// <param name="e">The event arguments.</param>
00335         private void miRed_Click(object sender, System.EventArgs e)
00336         {
00337
00338             myDynamicRenderer.DrawingAttributes.Color = Color.Red;
00339         }
00340
00341         /// <summary>
00342         /// Event Handler from Ink->Color->Green Menu Item
00343         /// </summary>
00344         /// <param name="sender">The control that raised the event.</param>
00345         /// <param name="e">The event arguments.</param>
00346         private void miGreen_Click(object sender, System.EventArgs e)
00347         {
00348             myDynamicRenderer.DrawingAttributes.Color = Color.Green;
00349         }
00350
00351         /// <summary>
00352         /// Event Handler from Ink->Color->Blue Menu Item
00353         /// </summary>
00354         /// <param name="sender">The control that raised the event.</param>
00355         /// <param name="e">The event arguments.</param>
00356         private void miBlue_Click(object sender, System.EventArgs e)
00357         {
00358             myDynamicRenderer.DrawingAttributes.Color = Color.Blue;
00359         }
00360
00361         /// <summary>
00362         /// Event Handler from Ink->Color->Black Menu Item
00363         /// </summary>
00364         /// <param name="sender">The control that raised the event.</param>
00365         /// <param name="e">The event arguments.</param>
00366         private void miBlack_Click(object sender, System.EventArgs e)
00367         {
00368             myDynamicRenderer.DrawingAttributes.Color = Color.Black;
00369         }
00370
00371         /// <summary>
00372         /// Event Handler from Ink->Width->Thin Menu Item
00373         /// </summary>
00374         /// <param name="sender">The control that raised the event.</param>
00375         /// <param name="e">The event arguments.</param>
00376         private void miThin_Click(object sender, System.EventArgs e)
00377         {
00378             myDynamicRenderer.DrawingAttributes.Width = ThinInkWidth;
00379         }
00380
00381         /// <summary>
00382         /// Event Handler from Ink->Width->Medium Menu Item
00383         /// </summary>
00384         /// <param name="sender">The control that raised the event.</param>
00385         /// <param name="e">The event arguments.</param>
00386         private void miMedium_Click(object sender, System.EventArgs e)
00387         {
00388             myDynamicRenderer.DrawingAttributes.Width = MediumInkWidth;
00389         }
00390
00391         /// <summary>
00392         /// Event Handler from Ink->Width->Thick Menu Item
00393         /// </summary>
00394         /// <param name="sender">The control that raised the event.</param>
00395         /// <param name="e">The event arguments.</param>
00396         private void miThick_Click(object sender, System.EventArgs e)
00397         {
00398             myDynamicRenderer.DrawingAttributes.Width = ThickInkWidth;
00399         }
00400
00401         /// <summary>
00402         /// Event Handler from File->Exit Menu Item
00403         /// </summary>
00404         /// <param name="sender">The control that raised the event.</param>
00405         /// <param name="e">The event arguments.</param>
00406         private void miExit_Click(object sender, System.EventArgs e)
00407         {
00408             myRealTimeStylus.Enabled = false;
00409             Application.Exit();
00410         }
00411
00412         /// <summary>
00413         /// Event Handler from Ink->Enabled Menu Item
00414         /// </summary>
00415         /// <param name="sender">The control that raised the event.</param>
00416         /// <param name="e">The event arguments.</param>
00417         private void miEnabled_Click(object sender, System.EventArgs e)
00418         {
00419             // Toggle the enabled state of the real time stylus
00420             myRealTimeStylus.Enabled = !myRealTimeStylus.Enabled;
00421             miEnabled.Checked = myRealTimeStylus.Enabled;
00422         }
00423         #endregion
00424
00425         #region IStylusAsyncPlugin interface implementation
00426
00427         /// <summary>
00428         /// Occurs when the stylus touches the digitizer surface.
00429         /// Allocate a new array to store the packet data for this stylus.
00430         /// </summary>
00431         /// <param name="sender">The real time stylus associated with the notification</param>
00432         /// <param name="data">The notification data</param>
00433         public void StylusDown(RealTimeStylus sender, StylusDownData data)
00434         {
00435             // Allocate an empty array to store the packet data that will be
00436             // collected for this stylus.
00437             ArrayList collectedPackets = new ArrayList();
00438
00439             // Add the packet data from StylusDown to the array
00440             collectedPackets.AddRange(data.GetData());
00441
00442             // Insert the array into a hashtable using the stylus id as a key.
00443             myPackets.Add(data.Stylus.Id, collectedPackets);
00444         }
00445
00446         /// <summary>
00447         /// Occurs when the stylus moves on the digitizer surface.
00448         /// Add new packet data into the packet array for this stylus.
00449         /// </summary>
00450         /// <param name="sender">The real time stylus associated with the notification</param>
00451         /// <param name="data">The notification data</param>
00452         public void Packets(RealTimeStylus sender, PacketsData data)
00453         {
00454             // Use the stylus id as a key to retrieve the packet array for the
00455             // stylus.  Insert the new packet data into this array.
00456             ((ArrayList)(myPackets[data.Stylus.Id])).AddRange(data.GetData());
00457         }
00458
00459         /// <summary>
00460         /// Occurs when the stylus leaves the digitizer surface.
00461         /// Retrieve the packet array for this stylus and use it to create
00462         /// a new stoke.
00463         /// </summary>
00464         /// <param name="sender">The real time stylus associated with the notification</param>
00465         /// <param name="data">The notification data</param>
00466         public void StylusUp(RealTimeStylus sender, StylusUpData data)
00467         {
00468             // Retrieve the packet array from the hashtable using the cursor id
00469             // as a key.  Then, clean this entry from the hash since it is no
00470             // longer needed.
00471             ArrayList collectedPackets = (ArrayList)myPackets[data.Stylus.Id];
00472             myPackets.Remove(data.Stylus.Id);
00473
00474             // Add the packet data from StylusUp to the array
00475             collectedPackets.AddRange(data.GetData());
00476
00477             // Create the stroke using the specified drawing attributes.
00478             int[] packets = (int[])(collectedPackets.ToArray(typeof(int)));
00479             TabletPropertyDescriptionCollection tabletProperties = myRealTimeStylus.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);
00480
00481             Stroke stroke = myInk.CreateStroke(packets, tabletProperties);
00482             if (stroke != null)
00483             {
00484                 stroke.DrawingAttributes.Color = myDynamicRenderer.DrawingAttributes.Color;
00485                 stroke.DrawingAttributes.Width = myDynamicRenderer.DrawingAttributes.Width;
00486             }
00487         }
00488
00489         /// <summary>
00490         /// Called when the current plugin or the ones previous in the list
00491         /// threw an exception.
00492         /// </summary>
00493         /// <param name="sender">The real time stylus</param>
00494         /// <param name="data">Error data</param>
00495         public void Error(RealTimeStylus sender, ErrorData data)
00496         {
00497             Debug.Assert(false, null, "An error occurred.  DataId=" + data.DataId + ", " + "Exception=" + data.InnerException);
00498         }
00499
00500         /// <summary>
00501         /// Defines the types of notifications the plugin is interested in.
00502         /// </summary>
00503         public DataInterestMask DataInterest
00504         {
00505             get
00506             {
00507                 return DataInterestMask.StylusDown |
00508                        DataInterestMask.Packets |
00509                        DataInterestMask.StylusUp |
00510                        DataInterestMask.Error;
00511             }
00512         }
00513
00514         // The remaining interface methods are not used in this sample application.
00515         public void RealTimeStylusDisabled(RealTimeStylus sender, RealTimeStylusDisabledData data) {}
00516         public void RealTimeStylusEnabled(RealTimeStylus sender, RealTimeStylusEnabledData data){}
00517         public void StylusOutOfRange(RealTimeStylus sender, StylusOutOfRangeData data) {}
00518         public void StylusInRange(RealTimeStylus sender, StylusInRangeData data) {}
00519         public void StylusButtonDown(RealTimeStylus sender, StylusButtonDownData data) {}
00520         public void StylusButtonUp(RealTimeStylus sender, StylusButtonUpData data) {}
00521         public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data){}
00522         public void SystemGesture(RealTimeStylus sender, SystemGestureData data){}
00523         public void InAirPackets(RealTimeStylus sender, InAirPacketsData data){}
00524         public void TabletAdded(RealTimeStylus sender, TabletAddedData data){}
00525         public void TabletRemoved(RealTimeStylus sender, TabletRemovedData data) {}
00526
00527         #endregion
00528     }
00529 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Instance_Provider/Service.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Instance_Provider

Service.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   XXXX
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #include <precomp.h>
00017 #include <objbase.h>
00018 #include <sddl.h>
00019 #include <strsafe.h>
00020
00021
00022 #include "Globals.h"
00023 #include "Service.h"
00024
00025 #define MASK_CLIENT_ACCESS_BIND 1
00026 static GENERIC_MAPPING s_ClientAccessMapping = {
00027   0,
00028   0,
00029   STANDARD_RIGHTS_REQUIRED | MASK_CLIENT_ACCESS_BIND,
00030   STANDARD_RIGHTS_REQUIRED | MASK_CLIENT_ACCESS_BIND
00031 };
00032
00033 /******************************************************************************
00034  *
00035  *  Name: g_Contact_Properties
00036  *
00037  *
00038  *  Description:
00039  *
00040  *      Static snapshot of contact data
00041  *
00042  *****************************************************************************/
00043
00044 Object_Property g_Contact_Properties [] = {
00045
00046     0 , 21 , L"ID" , L"0000000000001" ,
00047     0 , 8 , L"LastName" ,  L"Mandelshtam" ,
00048     0 , 8 , L"FirstName" , L"Osip" ,
00049     0 , 8 , L"HomePhone" , L"2069424877" ,
00050     0 , 8 , L"WorkPhone" , L"4258649459" ,
00051     1 , 0 , L"NA" , L"NA" ,
00052     0 , 21 , L"ID" , L"0000000000002" ,
00053     0 , 8 , L"LastName" ,  L"Pasternak" ,
00054     0 , 8 , L"FirstName" , L"Boris" ,
00055     0 , 8 , L"HomePhone" , L"4259434877" ,
00056     0 , 8 , L"WorkPhone" , L"4258964949" ,
00057     1 , 0 , L"NA" , L"NA" ,
00058     0 , 21 , L"ID" , L"0000000000003" ,
00059     0 , 8 , L"LastName" ,  L"Akhmatova" ,
00060     0 , 8 , L"FirstName" , L"Anna" ,
00061     0 , 8 , L"HomePhone" , L"7186724877" ,
00062     0 , 8 , L"WorkPhone" , L"2128640059" ,
00063     1 , 0 , L"NA" , L"NA" ,
00064     2 , 0 , L"NA" , L"NA"
00065
00066 } ;
00067
00068 /******************************************************************************
00069  *
00070  *  Name: g_Process_Properties
00071  *
00072  *
00073  *  Description:
00074  *
00075  *      Static snapshot of process data
00076  *
00077  *****************************************************************************/
00078
00079 Object_Property g_Process_Properties [] = {
00080
00081 0 , 8 , L"Caption" , L"System Idle Process" ,
00082 0 , 8 , L"CreationClassName" , L"Win32_Process" ,
00083 0 , 8 , L"CSCreationClassName" , L"Win32_ComputerSystem" ,
00084 0 , 8 , L"CSName" , L"STEVM_1" ,
00085 0 , 8 , L"Description" , L"System Idle Process" ,
00086 0 , 8 , L"Handle" , L"0" ,
00087 0 , 19 , L"HandleCount" , L"0" ,
00088 0 , 21 , L"KernelModeTime" , L"1484250781250" ,
00089 0 , 8 , L"Name" , L"System Idle Process" ,
00090 0 , 8 , L"OSCreationClassName" , L"Win32_OperatingSystem" ,
00091 0 , 8 , L"OSName" , L"Microsoft Windows Whistler Server|C:\\WINNT|\\Device\\Harddisk0\\Partition1" ,
00092 0 , 21 , L"OtherOperationCount" , L"0" ,
00093 0 , 21 , L"OtherTransferCount" , L"0" ,
00094 0 , 19 , L"PageFaults" , L"1" ,
00095 0 , 19 , L"PageFileUsage" , L"0" ,
00096 0 , 19 , L"ParentProcessId" , L"0" ,
00097 0 , 19 , L"PeakPageFileUsage" , L"0" ,
00098 0 , 21 , L"PeakVirtualSize" , L"0" ,
00099 0 , 19 , L"PeakWorkingSetSize" , L"20480" ,
00100 0 , 19 , L"Priority" , L"0" ,
00101 0 , 21 , L"PrivatePageCount" , L"0" ,
00102 0 , 19 , L"ProcessId" , L"0" ,
00103 0 , 19 , L"QuotaNonPagedPoolUsage" , L"0" ,
00104 0 , 19 , L"QuotaPagedPoolUsage" , L"0" ,
00105 0 , 19 , L"QuotaPeakNonPagedPoolUsage" , L"0" ,
00106 0 , 19 , L"QuotaPeakPagedPoolUsage" , L"0" ,
00107 0 , 21 , L"ReadOperationCount" , L"0" ,
00108 0 , 21 , L"ReadTransferCount" , L"0" ,
00109 0 , 19 , L"SessionId" , L"0" ,
00110 0 , 19 , L"ThreadCount" , L"2" ,
00111 0 , 21 , L"UserModeTime" , L"0" ,
00112 0 , 21 , L"VirtualSize" , L"0" ,
00113 0 , 8 , L"WindowsVersion" , L"5.1.2496" ,
00114 0 , 21 , L"WorkingSetSize" , L"20480" ,
00115 0 , 21 , L"WriteOperationCount" , L"0" ,
00116 0 , 21 , L"WriteTransferCount" , L"0" ,
00117 1 , 0 , L"NA" , L"NA" ,
00118 0 , 8 , L"Caption" , L"System" ,
00119 0 , 8 , L"CreationClassName" , L"Win32_Process" ,
00120 0 , 8 , L"CSCreationClassName" , L"Win32_ComputerSystem" ,
00121 0 , 8 , L"CSName" , L"STEVM_1" ,
00122 0 , 8 , L"Description" , L"System" ,
00123 0 , 8 , L"Handle" , L"4" ,
00124 0 , 19 , L"HandleCount" , L"1650" ,
00125 0 , 21 , L"KernelModeTime" , L"617031250" ,
00126 0 , 19 , L"MaximumWorkingSetSize" , L"1413120" ,
00127 0 , 19 , L"MinimumWorkingSetSize" , L"0" ,
00128 0 , 8 , L"Name" , L"System" ,
00129 0 , 8 , L"OSCreationClassName" , L"Win32_OperatingSystem" ,
00130 0 , 8 , L"OSName" , L"Microsoft Windows Whistler Server|C:\\WINNT|\\Device\\Harddisk0\\Partition1" ,
00131 0 , 21 , L"OtherOperationCount" , L"29386" ,
00132 0 , 21 , L"OtherTransferCount" , L"508628" ,
00133 0 , 19 , L"PageFaults" , L"7085" ,
00134 0 , 19 , L"PageFileUsage" , L"0" ,
00135 0 , 19 , L"ParentProcessId" , L"0" ,
00136 0 , 19 , L"PeakPageFileUsage" , L"0" ,
00137 0 , 21 , L"PeakVirtualSize" , L"2043904" ,
00138 0 , 19 , L"PeakWorkingSetSize" , L"831488" ,
00139 0 , 19 , L"Priority" , L"8" ,
00140 0 , 21 , L"PrivatePageCount" , L"32768" ,
00141 0 , 19 , L"ProcessId" , L"4" ,
00142 0 , 19 , L"QuotaNonPagedPoolUsage" , L"0" ,
00143 0 , 19 , L"QuotaPagedPoolUsage" , L"0" ,
00144 0 , 19 , L"QuotaPeakNonPagedPoolUsage" , L"0" ,
00145 0 , 19 , L"QuotaPeakPagedPoolUsage" , L"0" ,
00146 0 , 21 , L"ReadOperationCount" , L"92" ,
00147 0 , 21 , L"ReadTransferCount" , L"542740" ,
00148 0 , 19 , L"SessionId" , L"0" ,
00149 0 , 19 , L"ThreadCount" , L"50" ,
00150 0 , 21 , L"UserModeTime" , L"0" ,
00151 0 , 21 , L"VirtualSize" , L"1884160" ,
00152 0 , 8 , L"WindowsVersion" , L"5.1.2496" ,
00153 0 , 21 , L"WorkingSetSize" , L"221184" ,
00154 0 , 21 , L"WriteOperationCount" , L"10189" ,
00155 0 , 21 , L"WriteTransferCount" , L"54440072" ,
00156 1 , 0 , L"NA" , L"NA" ,
00157 2 , 0 , L"NA" , L"NA"
00158 } ;
00159
00160 /******************************************************************************
00161  *
00162  *  Name: Set_Uint64
00163  *
00164  *
00165  *  Description:
00166  *
00167  *    Sets a 64bit value into an instance
00168  *
00169  *****************************************************************************/
00170
00171 HRESULT Set_Uint64 (
00172
00173   IWbemClassObject *a_Instance ,
00174   wchar_t *a_Name ,
00175   const UINT64 &a_Uint64
00176 )
00177 {
00178   wchar_t t_String [ 64 ] ;
00179   StringCbPrintf(t_String, sizeof(t_String), L"%I64u" , a_Uint64 ) ;
00180
00181   VARIANT t_Variant ;
00182   VariantInit ( & t_Variant ) ;
00183   t_Variant.vt = VT_BSTR ;
00184   t_Variant.bstrVal = SysAllocString ( t_String ) ;
00185   if ( t_Variant.bstrVal )
00186   {
00187     HRESULT t_Result = a_Instance->Put ( a_Name , 0 , & t_Variant , 0 ) ;
00188
00189     VariantClear ( & t_Variant ) ;
00190
00191     return t_Result ;
00192   }
00193   else
00194   {
00195     return WBEM_E_OUT_OF_MEMORY ;
00196   }
00197 }
00198
00199 /******************************************************************************
00200  *
00201  *  Name: Set_Uint32
00202  *
00203  *
00204  *  Description:
00205  *
00206  *    Sets a 32bit value into an instance
00207  *
00208  *****************************************************************************/
00209
00210 HRESULT Set_Uint32 (
00211
00212   IWbemClassObject *a_Instance ,
00213   wchar_t *a_Name ,
00214   const DWORD &a_Uint32
00215 )
00216 {
00217   VARIANT t_Variant ;
00218   VariantInit ( & t_Variant ) ;
00219   t_Variant.vt = VT_I4 ;
00220   t_Variant.lVal = a_Uint32 ;
00221
00222   return a_Instance->Put ( a_Name , 0 , & t_Variant , 0 ) ;
00223 }
00224
00225 /******************************************************************************
00226  *
00227  *  Name: Set_String
00228  *
00229  *
00230  *  Description:
00231  *
00232  *    Sets a string value into an instance
00233  *
00234  *****************************************************************************/
00235
00236 HRESULT Set_String (
00237
00238   IWbemClassObject *a_Instance ,
00239   wchar_t *a_Name ,
00240   wchar_t *a_String
00241 )
00242 {
00243   VARIANT t_Variant ;
00244   VariantInit ( & t_Variant ) ;
00245   t_Variant.vt = VT_BSTR ;
00246   t_Variant.bstrVal = SysAllocString ( a_String ) ;
00247   if ( t_Variant.bstrVal )
00248   {
00249     HRESULT t_Result = a_Instance->Put ( a_Name , 0 , & t_Variant , 0 ) ;
00250
00251     VariantClear ( & t_Variant ) ;
00252
00253     return t_Result ;
00254   }
00255   else
00256   {
00257     return WBEM_E_OUT_OF_MEMORY ;
00258   }
00259 }
00260
00261 /******************************************************************************
00262  *
00263  *  Name: SetProperty
00264  *
00265  *
00266  *  Description:
00267  *
00268  *      Set an instance property based on it's type specified in the static
00269  *      process data definition.
00270  *
00271  *****************************************************************************/
00272
00273 HRESULT SetProperty (
00274
00275   IWbemClassObject *a_Instance ,
00276   Object_Property &a_Property
00277 )
00278 {
00279   HRESULT t_Result = S_OK ;
00280
00281   switch ( a_Property.m_Type )
00282   {
00283     case CIM_STRING:
00284     {
00285       t_Result = Set_String (
00286
00287         a_Instance ,
00288         a_Property.m_Name ,
00289         a_Property.m_Value
00290       ) ;
00291     }
00292     break ;
00293
00294     case CIM_UINT32:
00295     {
00296       ULONG t_Integer ;
00297       swscanf ( a_Property.m_Value ,  L"%lu" , & t_Integer ) ;
00298
00299       t_Result = Set_Uint32 (
00300
00301         a_Instance ,
00302         a_Property.m_Name ,
00303         t_Integer
00304       ) ;
00305     }
00306     break ;
00307
00308     case CIM_UINT64:
00309     {
00310       UINT64 t_Integer ;
00311       swscanf ( a_Property.m_Value , L"%I64u" , & t_Integer ) ;
00312
00313       t_Result = Set_Uint64 (
00314
00315         a_Instance ,
00316         a_Property.m_Name ,
00317         t_Integer
00318       ) ;
00319     }
00320     break ;
00321
00322     default:
00323     {
00324       WBEM_E_INVALID_PARAMETER ;
00325     }
00326     break ;
00327   }
00328
00329   return t_Result ;
00330 }
00331
00332
00333
00334 /******************************************************************************
00335  *
00336  *  Name: CheckAccess
00337  *
00338  *  Description:  Allow provider to evaluate permissions against a security descriptor
00339  *
00340  *  This method should be called by WMI providers in scenarios where
00341  *      they cannot or should not impersonate the client. This happens in two scenarios:
00342  *      a) when the providers access resources that are not protected by ACL's
00343  *      b) when the client connects at the impersonation level of RPC_C_IMP_LEVEL_IDENTIFY
00344  *
00345  *****************************************************************************/
00346
00347 HRESULT CheckAccess (SECURITY_DESCRIPTOR *a_SecurityDescriptor ,
00348           DWORD a_Access ,
00349           GENERIC_MAPPING *a_Mapping)
00350 {
00351   HRESULT t_Result = S_OK ;
00352
00353   HANDLE t_Token = NULL ;
00354
00355   BOOL t_Status = OpenThreadToken (
00356
00357     GetCurrentThread () ,
00358     TOKEN_QUERY ,
00359     TRUE ,
00360     & t_Token
00361   ) ;
00362
00363   DWORD t_LastError = GetLastError () ;
00364   if ( ! t_Status)
00365   {
00366     //the thread token should always be available
00367
00368     switch ( t_LastError )
00369     {
00370       case E_ACCESSDENIED:
00371       {
00372         return  WBEM_E_ACCESS_DENIED ;
00373       }
00374       break ;
00375
00376       default:
00377       {
00378         return WBEM_E_FAILED ;
00379       }
00380       break ;
00381     }
00382   }
00383
00384
00385   DWORD t_Access = 0 ;
00386   BOOL t_AccessStatus = FALSE ;
00387   PRIVILEGE_SET *t_PrivilegeSet = NULL ;
00388   DWORD t_PrivilegeSetSize = 0 ;
00389
00390   MapGenericMask (
00391
00392     & a_Access ,
00393     a_Mapping
00394   ) ;
00395
00396   t_Status = AccessCheck (
00397
00398     a_SecurityDescriptor ,
00399     t_Token,
00400     a_Access ,
00401     a_Mapping ,
00402     NULL ,
00403     & t_PrivilegeSetSize ,
00404     & t_Access ,
00405     & t_AccessStatus
00406   ) ;
00407
00408   if (!t_Status || !t_AccessStatus )
00409   {
00410     DWORD t_LastError = GetLastError () ;
00411     if ( t_LastError == ERROR_INSUFFICIENT_BUFFER )
00412     {
00413       t_PrivilegeSet = ( PRIVILEGE_SET * ) new BYTE [ t_PrivilegeSetSize ] ;
00414       if ( t_PrivilegeSet )
00415       {
00416         t_Status = AccessCheck (
00417           a_SecurityDescriptor ,
00418           t_Token,
00419           a_Access ,
00420           a_Mapping ,
00421           t_PrivilegeSet ,
00422           & t_PrivilegeSetSize ,
00423           & t_Access ,
00424           & t_AccessStatus
00425         ) ;
00426
00427         if ( !t_Status || !t_AccessStatus )
00428         {
00429           t_Result = WBEM_E_ACCESS_DENIED ;
00430         }
00431
00432         delete [] ( BYTE * ) t_PrivilegeSet ;
00433       }
00434       else
00435       {
00436         t_Result = WBEM_E_OUT_OF_MEMORY ;
00437       }
00438     }
00439     else
00440     {
00441       t_Result = WBEM_E_ACCESS_DENIED;
00442     }
00443
00444   }
00445
00446   CloseHandle ( t_Token ) ;
00447
00448
00449   return t_Result ;
00450 }
00451
00452
00453
00454 /******************************************************************************
00455  *
00456  *  Name: GetCurrentImpersonationLevel
00457  *
00458  *
00459  *  Description:
00460  *
00461  *      Get COM impersonation level of caller.
00462  *
00463  *****************************************************************************/
00464
00465 DWORD GetCurrentImpersonationLevel ()
00466 {
00467   DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00468
00469     HANDLE t_ThreadToken = NULL ;
00470
00471     BOOL t_Status = OpenThreadToken (
00472
00473     GetCurrentThread() ,
00474     TOKEN_QUERY,
00475     TRUE,
00476     &t_ThreadToken
00477   ) ;
00478
00479     if ( t_Status )
00480     {
00481     SECURITY_IMPERSONATION_LEVEL t_Level = SecurityAnonymous ;
00482     DWORD t_Returned = 0 ;
00483
00484     t_Status = GetTokenInformation (
00485
00486       t_ThreadToken ,
00487       TokenImpersonationLevel ,
00488       & t_Level ,
00489       sizeof ( SECURITY_IMPERSONATION_LEVEL ) ,
00490       & t_Returned
00491     ) ;
00492
00493     CloseHandle ( t_ThreadToken ) ;
00494
00495     if ( t_Status == FALSE )
00496     {
00497       t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00498     }
00499     else
00500     {
00501       switch ( t_Level )
00502       {
00503         case SecurityAnonymous:
00504         {
00505           t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00506         }
00507         break ;
00508
00509         case SecurityIdentification:
00510         {
00511           t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
00512         }
00513         break ;
00514
00515         case SecurityImpersonation:
00516         {
00517           t_ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE ;
00518         }
00519         break ;
00520
00521         case SecurityDelegation:
00522         {
00523           t_ImpersonationLevel = RPC_C_IMP_LEVEL_DELEGATE ;
00524         }
00525         break ;
00526
00527         default:
00528         {
00529           t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00530         }
00531         break ;
00532       }
00533     }
00534   }
00535   else
00536   {
00537         ULONG t_LastError = GetLastError () ;
00538
00539         if ( t_LastError == ERROR_NO_IMPERSONATION_TOKEN || t_LastError == ERROR_NO_TOKEN )
00540         {
00541             t_ImpersonationLevel = RPC_C_IMP_LEVEL_DELEGATE ;
00542         }
00543         else
00544     {
00545       if ( t_LastError == ERROR_CANT_OPEN_ANONYMOUS )
00546       {
00547         t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00548       }
00549       else
00550       {
00551         t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00552       }
00553     }
00554     }
00555
00556   return t_ImpersonationLevel ;
00557 }
00558
00559
00560
00561 /******************************************************************************
00562  *
00563  *  Name: CProvider_IWbemServices
00564  *
00565  *
00566  *  Description:
00567  *
00568  *    Constructor for object. Initialize variables to NULL. Increment global object count
00569  *
00570  *****************************************************************************/
00571
00572 CProvider_IWbemServices :: CProvider_IWbemServices () :
00573
00574   m_ReferenceCount ( 0 ) ,
00575   m_User ( NULL ) ,
00576   m_Locale ( NULL ) ,
00577   m_Namespace ( NULL ) ,
00578   m_CoreService ( NULL ) ,
00579   m_ComputerName  ( NULL ) ,
00580   m_OperatingSystemVersion ( NULL ) ,
00581   m_Win32_ProcessEx_Object ( NULL ),
00582   m_ContactInfo_Object (NULL)
00583 {
00584   InitializeCriticalSection ( & m_CriticalSection ) ;
00585
00586   InterlockedIncrement ( & Provider_Globals :: s_ObjectsInProgress ) ;
00587 }
00588
00589 /******************************************************************************
00590  *
00591  *  Name: ~CProvider_IWbemServices
00592  *
00593  *
00594  *  Description:
00595  *
00596  *    Constructor for object. Uninitialize variables . Decrement global object count
00597  *
00598  *****************************************************************************/
00599
00600 CProvider_IWbemServices :: ~CProvider_IWbemServices ()
00601 {
00602   DeleteCriticalSection ( & m_CriticalSection ) ;
00603
00604   if ( m_User )
00605   {
00606     SysFreeString ( m_User ) ;
00607   }
00608
00609   if ( m_Locale )
00610   {
00611     SysFreeString ( m_Locale ) ;
00612   }
00613
00614   if ( m_Namespace )
00615   {
00616     SysFreeString ( m_Namespace ) ;
00617   }
00618
00619   if ( m_CoreService )
00620   {
00621     m_CoreService->Release () ;
00622   }
00623
00624   if ( m_Win32_ProcessEx_Object )
00625   {
00626     m_Win32_ProcessEx_Object->Release () ;
00627   }
00628
00629   if ( m_ContactInfo_Object )
00630   {
00631     m_ContactInfo_Object->Release () ;
00632   }
00633
00634   if ( m_ComputerName )
00635   {
00636     SysFreeString ( m_ComputerName ) ;
00637   }
00638
00639   if ( m_OperatingSystemVersion )
00640   {
00641     SysFreeString ( m_OperatingSystemVersion ) ;
00642   }
00643
00644   InterlockedDecrement ( & Provider_Globals :: s_ObjectsInProgress ) ;
00645 }
00646
00647 /******************************************************************************
00648  *
00649  *  Name:   AddRef
00650  *
00651  *
00652  *  Description:
00653  *
00654  *    Perform Locked increment. Keep com object Alive.
00655  *
00656  *****************************************************************************/
00657
00658 STDMETHODIMP_(ULONG) CProvider_IWbemServices :: AddRef ( void )
00659 {
00660   return InterlockedIncrement ( & m_ReferenceCount ) ;
00661 }
00662
00663 /******************************************************************************
00664  *
00665  *  Name:
00666  *
00667  *    Release
00668  *
00669  *  Description:
00670  *
00671  *    Perform Locked decrement. Attempt to destroy com object.
00672  *
00673  *****************************************************************************/
00674
00675 STDMETHODIMP_(ULONG) CProvider_IWbemServices :: Release ( void )
00676 {
00677   LONG t_Reference ;
00678   if ( ( t_Reference = InterlockedDecrement ( & m_ReferenceCount ) ) == 0 )
00679   {
00680 /*
00681  *  No more outstanding references, delete the object.
00682  */
00683     delete this ;
00684   }
00685
00686   return t_Reference ;
00687 }
00688
00689 /******************************************************************************
00690  *
00691  *  Name:
00692  *
00693  *
00694  *  Description:
00695  *
00696  *
00697  *****************************************************************************/
00698
00699 STDMETHODIMP CProvider_IWbemServices :: QueryInterface (
00700
00701   REFIID a_Riid ,
00702   LPVOID FAR *a_Void
00703 )
00704 {
00705 /*
00706  *  Just clean up out parameter first.
00707  */
00708
00709   *a_Void = NULL ;
00710
00711   if ( a_Riid == IID_IUnknown )
00712   {
00713     *a_Void = ( LPVOID ) this ;
00714   }
00715   else if ( a_Riid == IID_IWbemServices )
00716   {
00717 /*
00718  *  Make sure we support event consumer interface IWbemServices
00719  */
00720
00721     *a_Void = ( LPVOID ) ( IWbemServices * ) this ;
00722   }
00723   else if ( a_Riid == IID_IWbemPropertyProvider )
00724   {
00725     *a_Void = ( LPVOID ) ( IWbemPropertyProvider * ) this ;
00726   }
00727   else if ( a_Riid == IID_IWbemProviderInit )
00728   {
00729     *a_Void = ( LPVOID ) ( IWbemProviderInit * ) this ;
00730   }
00731   else if ( a_Riid == IID_IWbemShutdown )
00732   {
00733     *a_Void = ( LPVOID ) ( IWbemShutdown * ) this ;
00734   }
00735
00736   if ( *a_Void )
00737   {
00738     ( ( LPUNKNOWN ) *a_Void )->AddRef () ;
00739
00740     return ResultFromScode ( S_OK ) ;
00741   }
00742   else
00743   {
00744     return ResultFromScode ( E_NOINTERFACE ) ;
00745   }
00746 }
00747
00748 /******************************************************************************
00749  *
00750  *  Name: CancelAsyncCall
00751  *
00752  *
00753  *  Description:
00754  *
00755  *      Allow provider to determine if call was cancelled.
00756  *
00757  *****************************************************************************/
00758
00759 HRESULT CProvider_IWbemServices :: CancelAsyncCall (
00760
00761   IWbemObjectSink *a_Sink
00762 )
00763 {
00764   HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
00765   return t_Result ;
00766 }
00767
00768 /******************************************************************************
00769  *
00770  *  Name: GetObjectAsync
00771  *
00772  *
00773  *  Description:
00774  *
00775  *      Allow provider to respond to a query for a specific object
00776  *
00777  *****************************************************************************/
00778
00779 HRESULT CProvider_IWbemServices :: GetObjectAsync (
00780
00781   const BSTR a_ObjectPath ,
00782   long a_Flags ,
00783   IWbemContext *a_Context ,
00784   IWbemObjectSink *a_Sink
00785 )
00786 {
00787   HRESULT t_Result = WBEM_E_NOT_FOUND ;
00788   return t_Result ;
00789 }
00790
00791 /******************************************************************************
00792  *
00793  *  Name: PutClassAsync
00794  *
00795  *
00796  *  Description:
00797  *
00798  *      Not required for instance providers.,
00799  *
00800  *****************************************************************************/
00801
00802 HRESULT CProvider_IWbemServices :: PutClassAsync (
00803
00804   IWbemClassObject *a_Object ,
00805   long a_Flags ,
00806   IWbemContext FAR *a_Context ,
00807   IWbemObjectSink *a_Sink
00808 )
00809 {
00810    return WBEM_E_NOT_FOUND ;
00811 }
00812
00813 /******************************************************************************
00814  *
00815  *  Name: DeleteClassAsync
00816  *
00817  *
00818  *  Description:
00819  *
00820  *      Not required for instance providers.,
00821  *
00822  *****************************************************************************/
00823
00824 HRESULT CProvider_IWbemServices :: DeleteClassAsync (
00825
00826   const BSTR a_Class ,
00827   long a_Flags,
00828   IWbemContext *a_Context ,
00829   IWbemObjectSink *a_Sink
00830 )
00831 {
00832    return WBEM_E_NOT_AVAILABLE ;
00833 }
00834
00835 /******************************************************************************
00836  *
00837  *  Name: CreateClassEnumAsync
00838  *
00839  *
00840  *  Description:
00841  *
00842  *      Not required for instance providers.,
00843  *
00844  *****************************************************************************/
00845
00846
00847 SCODE CProvider_IWbemServices :: CreateClassEnumAsync (
00848
00849   const BSTR a_SuperClass ,
00850   long a_Flags ,
00851   IWbemContext *a_Context ,
00852   IWbemObjectSink *a_Sink
00853 )
00854 {
00855   return WBEM_E_NOT_FOUND ;
00856 }
00857
00858 /******************************************************************************
00859  *
00860  *  Name: PutInstanceAsync
00861  *
00862  *
00863  *  Description:
00864  *
00865  *      Allow provider to create/update a specific object
00866  *
00867  *****************************************************************************/
00868
00869 HRESULT CProvider_IWbemServices :: PutInstanceAsync (
00870
00871   IWbemClassObject *a_Instance ,
00872   long a_Flags ,
00873     IWbemContext *a_Context ,
00874   IWbemObjectSink *a_Sink
00875 )
00876 {
00877   HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
00878   return t_Result ;
00879 }
00880
00881 /******************************************************************************
00882  *
00883  *  Name: DeleteInstanceAsync
00884  *
00885  *
00886  *  Description:
00887  *
00888  *      Allow provider to delete a specific object
00889  *
00890  *****************************************************************************/
00891
00892 HRESULT CProvider_IWbemServices :: DeleteInstanceAsync (
00893
00894   const BSTR a_ObjectPath ,
00895     long a_Flags ,
00896     IWbemContext *a_Context ,
00897     IWbemObjectSink *a_Sink
00898 )
00899 {
00900   HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
00901   return t_Result ;
00902 }
00903
00904 /******************************************************************************
00905  *
00906  *  Name: CreateInstanceEnumAsync
00907  *
00908  *
00909  *  Description:
00910  *
00911  *      This provider enumerates instances of Win32_ProcessEx and ContactInfo classes.
00912  *
00913  *      To access Win32_ProcessEx objects, this provider impersonates the client (modeling the
00914  *      scenario where protected OS objects would surfaced by a provider - even though
00915  *      in this sample the objects are in fact hard-coded and not protected).
00916  *
00917  *      ContactInfo objects surfaced by this provider that are not protected by ACL's, so
00918  *      the provider performs access checks only allowing certain groups to view ContactInfo data
00919  *      (acts as an Identity-level provider)
00920  *
00921  *****************************************************************************/
00922
00923 HRESULT CProvider_IWbemServices :: CreateInstanceEnumAsync (
00924
00925   const BSTR a_Class ,
00926   long a_Flags ,
00927   IWbemContext *a_Context ,
00928   IWbemObjectSink *a_Sink
00929 )
00930 {
00931   //Impersonate the client
00932   HRESULT hr = S_OK ;
00933
00934   if ( _wcsicmp ( a_Class , L"ContactInfo" ) == 0 )
00935   {
00936     //Grant access for built-in admins, local system, local admins, local service and network service.
00937     PSECURITY_DESCRIPTOR secDescriptor = NULL;
00938     BOOL bRes = ConvertStringSecurityDescriptorToSecurityDescriptor //this function is only available on Windows 2000 and above
00939       ( L"O:BAG:BAD:(A;;0x10000001;;;BA)(A;;0x10000001;;;SY)(A;;0x10000001;;;LA)(A;;0x10000001;;;SY)(A;;0x10000001;;;S-1-5-20)(A;;0x10000001;;;S-1-5-19)",
00940       SDDL_REVISION_1,
00941       (PSECURITY_DESCRIPTOR *) &secDescriptor,
00942       NULL);
00943
00944     if (! bRes)
00945     {
00946       hr = WBEM_E_ACCESS_DENIED;
00947       a_Sink->SetStatus ( 0 , hr , NULL , NULL ) ;
00948       return hr ;
00949     }
00950
00951     hr = CoImpersonateClient () ;
00952     if ( FAILED ( hr ) )
00953     {
00954       LocalFree(secDescriptor);
00955
00956       a_Sink->SetStatus ( 0 , hr , NULL , NULL ) ;
00957       return hr ;
00958     }
00959
00960
00961     // perform an access check.
00962
00963     hr = CheckAccess((SECURITY_DESCRIPTOR *)secDescriptor,
00964               MASK_CLIENT_ACCESS_BIND,
00965               &s_ClientAccessMapping);
00966
00967     LocalFree(secDescriptor);
00968
00969     //  Revert before we perform any operations
00970     CoRevertToSelf () ;
00971
00972     if (FAILED(hr))
00973     {
00974       hr = WBEM_E_ACCESS_DENIED;
00975       a_Sink->SetStatus ( 0 , hr , NULL , NULL ) ;
00976       return hr ;
00977     }
00978
00979
00980     //Enumerate the instances.
00981     hr = CreateInstanceEnumAsync_Contacts (
00982
00983       m_ContactInfo_Object ,
00984       a_Flags ,
00985       a_Context ,
00986       a_Sink
00987     ) ;
00988
00989   }
00990   else if ( _wcsicmp ( a_Class , L"Win32_ProcessEx" ) == 0 )
00991   {
00992     hr = CoImpersonateClient () ;
00993     if ( FAILED ( hr ) )
00994     {
00995       a_Sink->SetStatus ( 0 , hr , NULL , NULL ) ;
00996       return hr ;
00997     }
00998
00999     //  Check to see if call is at the RPC_C_IMP_LEVEL_IDENTIFY level. If that's the case,
01000     //  the provider will not be able to impersonate the client to access the protected Win32_ProcessEx resources.
01001     //  However, the provider can decide perform an access check to see if the client is sufficiently privileged.
01002     //
01003     //  Please keep in mind that if in the MOF file __Win32Provider instabce sets the HostingModel
01004     //  to Decoupled:Com (the default), the original client impersonation level will be lowered to
01005     //  RPC_C_IMP_LEVEL_IDENTIFY before calling into provider. To allow original client
01006     //  impersonation level through to provider, set the HostingModel to
01007     //  Decoupled:Com:FoldIdentity(FALSE}.
01008     //  See comments in the MOF file for more info.
01009
01010
01011     DWORD t_CurrentImpersonationLevel = GetCurrentImpersonationLevel () ;
01012     if ( t_CurrentImpersonationLevel < RPC_C_IMP_LEVEL_IMPERSONATE )
01013     {
01014       //  Revert before we perform any operations
01015       CoRevertToSelf () ;
01016
01017
01018       hr = WBEM_E_ACCESS_DENIED;
01019       a_Sink->SetStatus ( 0 , hr , NULL , NULL ) ;
01020       return hr ;
01021     }
01022
01023     //Enumerate the instances.
01024     hr = CreateInstanceEnumAsync_Process (
01025
01026       m_Win32_ProcessEx_Object ,
01027       a_Flags ,
01028       a_Context ,
01029       a_Sink
01030     ) ;
01031
01032     CoRevertToSelf () ;
01033   }
01034   else
01035   {
01036     hr = WBEM_E_INVALID_CLASS ;
01037   }
01038
01039 /*
01040  *  Inform WMI of status of call.
01041  */
01042
01043
01044   a_Sink->SetStatus ( 0 , hr , NULL , NULL ) ;
01045
01046   return hr ;
01047 }
01048
01049 /******************************************************************************
01050  *
01051  *  Name: ExecQueryAsync
01052  *
01053  *
01054  *  Description:
01055  *
01056  *      Enumerate instances based on a WQL query.
01057  *
01058  *****************************************************************************/
01059
01060 HRESULT CProvider_IWbemServices :: ExecQueryAsync (
01061
01062   const BSTR a_QueryFormat,
01063   const BSTR a_Query,
01064   long a_Flags,
01065   IWbemContext *a_Context ,
01066   IWbemObjectSink *a_Sink
01067 )
01068 {
01069
01070   return WBEM_E_NOT_AVAILABLE ;
01071
01072
01073 }
01074
01075 /******************************************************************************
01076  *
01077  *  Name: ExecMethodAsync
01078  *
01079  *
01080  *  Description:
01081  *
01082  *      Allow provider to execute a method.
01083  *
01084  *****************************************************************************/
01085
01086 HRESULT CProvider_IWbemServices :: ExecMethodAsync (
01087
01088     const BSTR a_ObjectPath ,
01089     const BSTR a_MethodName ,
01090     long a_Flags ,
01091     IWbemContext *a_Context ,
01092     IWbemClassObject *a_InParams ,
01093   IWbemObjectSink *a_Sink
01094 )
01095 {
01096   HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
01097   return t_Result ;
01098 }
01099
01100 /******************************************************************************
01101  *
01102  *  Name: GettProperty
01103  *
01104  *
01105  *  Description:
01106  *
01107  *    Place holder for property provider method. Currently not used.
01108  *
01109  *****************************************************************************/
01110
01111 HRESULT CProvider_IWbemServices :: GetProperty (
01112
01113     long a_Flags ,
01114     const BSTR a_Locale ,
01115     const BSTR a_ClassMapping ,
01116     const BSTR a_InstanceMapping ,
01117     const BSTR a_PropertyMapping ,
01118     VARIANT *a_Value
01119 )
01120 {
01121   if ( _wcsicmp ( a_PropertyMapping , L"ExtraProperty1" ) == 0 )
01122   {
01123   }
01124   else
01125   {
01126     if ( _wcsicmp ( a_PropertyMapping , L"ExtraProperty2" ) == 0 )
01127     {
01128     }
01129     else
01130     {
01131     }
01132   }
01133
01134   return S_OK ;
01135 }
01136
01137 /******************************************************************************
01138  *
01139  *  Name: PutProperty
01140  *
01141  *
01142  *  Description:
01143  *
01144  *    Place holder for property provider method. Currently not used.
01145  *
01146  *****************************************************************************/
01147
01148 HRESULT CProvider_IWbemServices :: PutProperty (
01149
01150     long a_Flags ,
01151     const BSTR a_Locale ,
01152     const BSTR a_ClassMapping ,
01153     const BSTR a_InstanceMapping ,
01154     const BSTR a_PropertyMapping ,
01155     const VARIANT *a_Value
01156 )
01157 {
01158   if ( _wcsicmp ( a_PropertyMapping , L"ExtraProperty1" ) == 0 )
01159   {
01160   }
01161   else
01162   {
01163     if ( _wcsicmp ( a_PropertyMapping , L"ExtraProperty2" ) == 0 )
01164     {
01165     }
01166     else
01167     {
01168     }
01169   }
01170
01171   return S_OK ;
01172 }
01173
01174 /******************************************************************************
01175  *
01176  *  Name:   Initialize
01177  *
01178  *
01179  *  Description:
01180  *
01181  *        Wmi calls this optional interface to inform the provider of
01182  *        configuration information associated within the client, locale
01183  *        and namespace. Provider retains this information for future use.
01184  *
01185  *****************************************************************************/
01186
01187 HRESULT CProvider_IWbemServices :: Initialize (
01188
01189   LPWSTR a_User,
01190   LONG a_Flags,
01191   LPWSTR a_Namespace,
01192   LPWSTR a_Locale,
01193   IWbemServices *a_CoreService,         // For anybody
01194   IWbemContext *a_Context,
01195   IWbemProviderInitSink *a_Sink     // For init signals
01196 )
01197 {
01198   HRESULT t_Result = S_OK ;
01199
01200       if ( m_User )
01201
01202       {
01203
01204             SysFreeString ( m_User ) ;
01205
01206             m_User = NULL ;
01207
01208       }
01209
01210
01211
01212       if ( m_Locale )
01213
01214       {
01215
01216             SysFreeString ( m_Locale ) ;
01217
01218             m_Locale = NULL ;
01219
01220       }
01221
01222
01223
01224       if ( m_Namespace )
01225
01226       {
01227
01228             SysFreeString ( m_Namespace ) ;
01229
01230             m_Namespace  = NULL ;
01231
01232       }
01233
01234
01235
01236       if ( m_CoreService )
01237
01238       {
01239
01240             m_CoreService->Release () ;
01241
01242             m_CoreService = NULL ;
01243
01244       }
01245
01246
01247
01248       if ( m_Win32_ProcessEx_Object )
01249
01250       {
01251
01252             m_Win32_ProcessEx_Object->Release () ;
01253
01254             m_Win32_ProcessEx_Object = NULL ;
01255
01256       }
01257
01258     if ( m_ContactInfo_Object )
01259
01260       {
01261
01262             m_Win32_ProcessEx_Object->Release () ;
01263
01264             m_Win32_ProcessEx_Object = NULL ;
01265
01266       }
01267
01268
01269
01270       if ( m_ComputerName )
01271
01272       {
01273
01274             SysFreeString ( m_ComputerName ) ;
01275
01276             m_ComputerName = NULL ;
01277
01278       }
01279
01280
01281
01282       if ( m_OperatingSystemVersion )
01283
01284       {
01285
01286             SysFreeString ( m_OperatingSystemVersion ) ;
01287
01288             m_OperatingSystemVersion = NULL ;
01289
01290       }
01291
01292
01293 /*
01294  *  Impersonate and check impersonation level.
01295  */
01296
01297   t_Result = CoImpersonateClient () ;
01298   if ( SUCCEEDED ( t_Result ) )
01299   {
01300     if ( GetCurrentImpersonationLevel () == RPC_C_IMP_LEVEL_IDENTIFY )
01301     {
01302       CoRevertToSelf () ;
01303     }
01304   }
01305
01306   if ( a_CoreService )
01307   {
01308     m_CoreService = a_CoreService ;
01309     m_CoreService->AddRef () ;
01310   }
01311   else
01312   {
01313     t_Result = WBEM_E_INVALID_PARAMETER ;
01314   }
01315
01316   if ( SUCCEEDED ( t_Result ) )
01317   {
01318     if ( a_User )
01319     {
01320       m_User = SysAllocString ( a_User ) ;
01321       if ( m_User == NULL )
01322       {
01323         t_Result = WBEM_E_OUT_OF_MEMORY ;
01324       }
01325     }
01326   }
01327
01328   if ( SUCCEEDED ( t_Result ) )
01329   {
01330     if ( a_Locale )
01331     {
01332       m_Locale = SysAllocString ( a_Locale ) ;
01333       if ( m_Locale == NULL )
01334       {
01335         t_Result = WBEM_E_OUT_OF_MEMORY ;
01336       }
01337     }
01338   }
01339
01340   if ( SUCCEEDED ( t_Result ) )
01341   {
01342     if ( a_Namespace )
01343     {
01344       m_Namespace = SysAllocString ( a_Namespace ) ;
01345       if ( m_Namespace == NULL )
01346       {
01347         t_Result = WBEM_E_OUT_OF_MEMORY ;
01348       }
01349     }
01350   }
01351
01352   BSTR t_Class;
01353
01354   if ( SUCCEEDED ( t_Result ) )
01355   {
01356     t_Class = SysAllocString ( L"Win32_ProcessEx" ) ;
01357     if ( !t_Class )
01358     {
01359       t_Result = WBEM_E_OUT_OF_MEMORY ;
01360     }
01361     else
01362     {
01363       t_Result = m_CoreService->GetObject (
01364
01365         t_Class ,
01366         0 ,
01367         a_Context ,
01368         & m_Win32_ProcessEx_Object ,
01369         NULL
01370       ) ;
01371
01372       SysFreeString ( t_Class ) ;
01373     }
01374   }
01375
01376   if ( SUCCEEDED ( t_Result ) )
01377   {
01378
01379     t_Class = SysAllocString( L"ContactInfo" );
01380     if ( !t_Class )
01381     {
01382       t_Result = WBEM_E_OUT_OF_MEMORY ;
01383     }
01384     else
01385     {
01386       t_Result = m_CoreService->GetObject (
01387
01388         t_Class ,
01389         0 ,
01390         a_Context ,
01391         & m_ContactInfo_Object ,
01392         NULL
01393       ) ;
01394
01395       SysFreeString ( t_Class ) ;
01396     }
01397
01398   }
01399
01400   if ( SUCCEEDED ( t_Result ) )
01401   {
01402     m_ComputerName = SysAllocStringLen ( NULL , MAX_COMPUTERNAME_LENGTH + 1 ) ;
01403     if ( m_ComputerName )
01404     {
01405       DWORD t_Length = MAX_COMPUTERNAME_LENGTH + 1 ;
01406       if (! GetComputerName ( m_ComputerName , & t_Length ))
01407       {
01408         t_Result = WBEM_E_FAILED ;
01409       }
01410
01411     }
01412     else
01413     {
01414       t_Result = WBEM_E_OUT_OF_MEMORY ;
01415     }
01416   }
01417
01418   if ( SUCCEEDED ( t_Result ) )
01419   {
01420     OSVERSIONINFO t_VersionInfo ;
01421     t_VersionInfo.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO ) ;
01422     if ( GetVersionEx ( & t_VersionInfo ) )
01423     {
01424       m_OperatingSystemVersion  = SysAllocStringLen ( NULL , _MAX_PATH ) ;
01425       if ( m_OperatingSystemVersion )
01426       {
01427         StringCbPrintfW(m_OperatingSystemVersion, SysStringByteLen(m_OperatingSystemVersion),
01428           L"%d.%d.%hu", t_VersionInfo.dwMajorVersion , t_VersionInfo.dwMinorVersion , LOWORD ( t_VersionInfo.dwBuildNumber ) ) ;
01429       }
01430       else
01431       {
01432         t_Result = WBEM_E_OUT_OF_MEMORY ;
01433       }
01434     }
01435     else
01436     {
01437       t_Result = WBEM_E_FAILED ;
01438     }
01439   }
01440
01441   CoRevertToSelf () ;
01442
01443   a_Sink->SetStatus ( t_Result , 0 ) ;
01444
01445   return t_Result ;
01446 }
01447
01448 /******************************************************************************
01449  *
01450  *  Name:   Shutdown
01451  *
01452  *
01453  *  Description:
01454  *
01455  *        Optional interface and method that informs provider of object implementation
01456  *        being released by WMI. Shutdown is not guaranteed to be called on system
01457  *        shutdown.
01458  *
01459  *****************************************************************************/
01460
01461 HRESULT CProvider_IWbemServices :: Shutdown (
01462
01463   LONG a_Flags ,
01464   ULONG a_MaxMilliSeconds ,
01465   IWbemContext *a_Context
01466 )
01467 {
01468   HRESULT t_Result = S_OK ;
01469   return t_Result ;
01470 }
01471
01472
01473 /******************************************************************************
01474  *
01475  *  Name: CreateInstanceEnumAsync_Contacts
01476  *
01477  *
01478  *  Description:
01479  *
01480  *    Enumerate all static instances of the ContactInfo class.
01481  *
01482  *****************************************************************************/
01483
01484 HRESULT CProvider_IWbemServices :: CreateInstanceEnumAsync_Contacts (
01485
01486   IWbemClassObject *a_ClassObject ,
01487   long a_Flags ,
01488   IWbemContext __RPC_FAR *a_Context,
01489   IWbemObjectSink FAR *a_Sink
01490 )
01491 {
01492   HRESULT t_Result = S_OK ;
01493
01494 /*
01495  *  Count the instances
01496  */
01497
01498   ULONG t_Count = 0 ;
01499
01500   Object_Property *t_Property = g_Contact_Properties ;
01501   while ( SUCCEEDED ( t_Result ) && t_Property )
01502   {
01503     BOOL t_Loop = TRUE ;
01504     while ( t_Loop )
01505     {
01506       switch ( t_Property->m_State )
01507       {
01508         case 0:
01509         {
01510           t_Property ++ ;
01511         }
01512         break ;
01513
01514         case 1:
01515         {
01516           t_Loop = FALSE ;
01517           t_Property ++ ;
01518           t_Count ++ ;
01519         }
01520         break ;
01521
01522         case 2:
01523         {
01524           t_Loop = FALSE ;
01525           t_Property = NULL ;
01526         } ;
01527
01528         default:
01529         {
01530         }
01531         break ;
01532       }
01533     }
01534   }
01535
01536   if ( t_Count )
01537   {
01538
01539 /*
01540  *  Create the array of instances
01541  */
01542
01543     ULONG t_Index = 0 ;
01544
01545     IWbemClassObject **t_ObjectArray = new IWbemClassObject * [ t_Count ] ;
01546     if ( t_ObjectArray )
01547     {
01548       for ( ULONG t_ObjectIndex = 0 ; t_ObjectIndex < t_Count ; t_ObjectIndex ++ )
01549       {
01550         t_ObjectArray [ t_ObjectIndex ] = NULL ;
01551       }
01552
01553       t_Result = a_ClassObject->SpawnInstance (
01554
01555         0 ,
01556         & t_ObjectArray [ t_Index ]
01557       ) ;
01558
01559       Object_Property *t_Property = g_Contact_Properties ;
01560       while ( SUCCEEDED ( t_Result ) && t_Property )
01561       {
01562         BOOL t_Loop = TRUE ;
01563         while ( t_Loop )
01564         {
01565           switch ( t_Property->m_State )
01566           {
01567             case 0:
01568             {
01569 /*
01570  *  Set property value for the current instance
01571  */
01572
01573               SetProperty ( t_ObjectArray [ t_Index ] , *t_Property ) ;
01574               t_Property ++ ;
01575             }
01576             break ;
01577
01578             case 1:
01579             {
01580 /*
01581  *  Create a new instance
01582  */
01583               t_Loop = FALSE ;
01584
01585               t_Index ++ ;
01586
01587               if ( t_Index < t_Count )
01588               {
01589                 t_Result = a_ClassObject->SpawnInstance (
01590
01591                   0 ,
01592                   & t_ObjectArray [ t_Index ]
01593                 ) ;
01594               }
01595
01596               t_Property ++ ;
01597             }
01598             break ;
01599
01600             case 2:
01601             {
01602 /*
01603  * Break from loop when we've reached the end of the data
01604  */
01605               t_Loop = FALSE ;
01606               t_Property = NULL ;
01607             } ;
01608
01609             default:
01610             {
01611             }
01612             break ;
01613           }
01614         }
01615       }
01616
01617 /*
01618  *  Send the instances to WMI.
01619  */
01620       if ( SUCCEEDED ( t_Result ) )
01621       {
01622         t_Result = a_Sink->Indicate ( t_Count , t_ObjectArray ) ;
01623       }
01624
01625 /*
01626  *  Discard
01627  */
01628
01629       for ( t_Index = 0 ; t_Index < t_Count ; t_Index ++ )
01630       {
01631         if ( t_ObjectArray [ t_Index ] )
01632         {
01633           t_ObjectArray [ t_Index ]->Release () ;
01634         }
01635       }
01636
01637       delete [] t_ObjectArray ;
01638     }
01639   }
01640
01641   return t_Result ;
01642 }
01643
01644
01645 /******************************************************************************
01646  *
01647  *  Name: CreateInstanceEnumAsync_Process
01648  *
01649  *
01650  *  Description:
01651  *
01652  *    Enumerate all static instances of the Win32_ProcessEx class.
01653  *
01654  *****************************************************************************/
01655
01656 HRESULT CProvider_IWbemServices :: CreateInstanceEnumAsync_Process (
01657
01658   IWbemClassObject *a_ClassObject ,
01659   long a_Flags ,
01660   IWbemContext __RPC_FAR *a_Context,
01661   IWbemObjectSink FAR *a_Sink
01662 )
01663 {
01664   HRESULT t_Result = S_OK ;
01665
01666 /*
01667  *  Count the instances
01668  */
01669
01670   ULONG t_Count = 0 ;
01671
01672   Object_Property *t_Property = g_Process_Properties ;
01673   while ( SUCCEEDED ( t_Result ) && t_Property )
01674   {
01675     BOOL t_Loop = TRUE ;
01676     while ( t_Loop )
01677     {
01678       switch ( t_Property->m_State )
01679       {
01680         case 0:
01681         {
01682           t_Property ++ ;
01683         }
01684         break ;
01685
01686         case 1:
01687         {
01688           t_Loop = FALSE ;
01689           t_Property ++ ;
01690           t_Count ++ ;
01691         }
01692         break ;
01693
01694         case 2:
01695         {
01696           t_Loop = FALSE ;
01697           t_Property = NULL ;
01698         } ;
01699
01700         default:
01701         {
01702         }
01703         break ;
01704       }
01705     }
01706   }
01707
01708   if ( t_Count )
01709   {
01710
01711 /*
01712  *  Create the array of instances
01713  */
01714
01715     ULONG t_Index = 0 ;
01716
01717     IWbemClassObject **t_ObjectArray = new IWbemClassObject * [ t_Count ] ;
01718     if ( t_ObjectArray )
01719     {
01720       for ( ULONG t_ObjectIndex = 0 ; t_ObjectIndex < t_Count ; t_ObjectIndex ++ )
01721       {
01722         t_ObjectArray [ t_ObjectIndex ] = NULL ;
01723       }
01724
01725       t_Result = a_ClassObject->SpawnInstance (
01726
01727         0 ,
01728         & t_ObjectArray [ t_Index ]
01729       ) ;
01730
01731       Object_Property *t_Property = g_Process_Properties ;
01732       while ( SUCCEEDED ( t_Result ) && t_Property )
01733       {
01734         BOOL t_Loop = TRUE ;
01735         while ( t_Loop )
01736         {
01737           switch ( t_Property->m_State )
01738           {
01739             case 0:
01740             {
01741 /*
01742  *  Set property value for the current instance
01743  */
01744
01745               SetProperty ( t_ObjectArray [ t_Index ] , *t_Property ) ;
01746               t_Property ++ ;
01747             }
01748             break ;
01749
01750             case 1:
01751             {
01752 /*
01753  *  Create a new instance
01754  */
01755               t_Loop = FALSE ;
01756
01757               t_Index ++ ;
01758
01759               if ( t_Index < t_Count )
01760               {
01761                 t_Result = a_ClassObject->SpawnInstance (
01762
01763                   0 ,
01764                   & t_ObjectArray [ t_Index ]
01765                 ) ;
01766               }
01767
01768               t_Property ++ ;
01769             }
01770             break ;
01771
01772             case 2:
01773             {
01774 /*
01775  * Break from loop when we've reached the end of the data
01776  */
01777               t_Loop = FALSE ;
01778               t_Property = NULL ;
01779             } ;
01780
01781             default:
01782             {
01783             }
01784             break ;
01785           }
01786         }
01787       }
01788
01789 /*
01790  *  Send the instances to WMI.
01791  */
01792
01793       if ( SUCCEEDED ( t_Result ) )
01794       {
01795         t_Result = a_Sink->Indicate ( t_Count , t_ObjectArray ) ;
01796       }
01797
01798 /*
01799  *  Discard
01800  */
01801
01802
01803       for ( t_Index = 0 ; t_Index < t_Count ; t_Index ++ )
01804       {
01805         if ( t_ObjectArray [ t_Index ] )
01806         {
01807           t_ObjectArray [ t_Index ]->Release () ;
01808         }
01809       }
01810
01811       delete [] t_ObjectArray ;
01812     }
01813   }
01814
01815   return t_Result ;
01816 }
01817
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagLABELEXTRACT Member List

This is the complete list of members for tagLABELEXTRACT, including all inherited members.
cch | tagLABELEXTRACT
fFoundIconOnly | tagLABELEXTRACT
fFoundIndex | tagLABELEXTRACT
fFoundSource | tagLABELEXTRACT
iIcon | tagLABELEXTRACT
Index | tagLABELEXTRACT
lpsz | tagLABELEXTRACT
PrevIndex | tagLABELEXTRACT
u | tagLABELEXTRACT
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/Client/StdAfx.h Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • Client

StdAfx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: StdAfx.h
00004
00005 Summary:  Produced by VS6 ATL Wizard. Used to generate pre-compiled headers
00006           for project.
00007
00008 ----------------------------------------------------------------------------
00009
00010 This file is part of the Microsoft COM+ Samples.
00011
00012 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00013
00014 This source code is intended only as a supplement to Microsoft
00015 Development Tools and/or on-line documentation. See these other
00016 materials for detailed information regarding Microsoft code samples.
00017
00018 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00019 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00021 PARTICULAR PURPOSE.
00022
00023 ==========================================================================+*/
00024 // stdafx.h : include file for standard system include files,
00025 //  or project specific include files that are used frequently, but
00026 //      are changed infrequently
00027 //
00028
00029 #if !defined(AFX_STDAFX_H__146DF857_4D72_11D2_9672_00AA00B913AC__INCLUDED_)
00030 #define AFX_STDAFX_H__146DF857_4D72_11D2_9672_00AA00B913AC__INCLUDED_
00031
00032 #if _MSC_VER >= 1000
00033 #pragma once
00034 #endif // _MSC_VER >= 1000
00035
00036 #define VC_EXTRALEAN
00037
00038 #include <afxwin.h>         // MFC core and standard components
00039 #include <afxext.h>         // MFC extensions
00040 #ifndef _AFX_NO_AFXCMN_SUPPORT
00041 #include <afxcmn.h>     // MFC support for Windows Common Controls
00042 #endif // _AFX_NO_AFXCMN_SUPPORT
00043 #include <afxole.h>
00044
00045 //{{AFX_INSERT_LOCATION}}
00046 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00047
00048 #endif // !defined(AFX_STDAFX_H__146DF857_4D72_11D2_9672_00AA00B913AC__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/ips.h Source File

  • Com
  • Fundamentals
  • SimpSvr

ips.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: ips.h
00003 //
00004 //      Definition of CPersistStorage
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008
00009 #if !defined( _IPS_H_)
00010 #define _IPS_H_
00011
00012
00013 #include <ole2.h>
00014 //@@WTK WIN32, UNICODE
00015 //#include <storage.h>
00016 #include "obj.h"
00017
00018 class CSimpSvrObj;
00019
00020 interface CPersistStorage : IPersistStorage
00021 {
00022 private:
00023   CSimpSvrObj FAR * m_lpObj;
00024   int m_nCount;
00025   BOOL m_fSameAsLoad;
00026
00027 public:
00028   CPersistStorage::CPersistStorage(CSimpSvrObj FAR * lpSimpSvrObj)
00029     {
00030     m_lpObj = lpSimpSvrObj;
00031     m_nCount = 0;
00032     };
00033   CPersistStorage::~CPersistStorage() {};
00034
00035   STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppvObj);
00036   STDMETHODIMP_(ULONG) AddRef ();
00037   STDMETHODIMP_(ULONG) Release ();
00038
00039   STDMETHODIMP InitNew (LPSTORAGE pStg);
00040   STDMETHODIMP GetClassID  ( LPCLSID lpClassID) ;
00041   STDMETHODIMP Save  ( LPSTORAGE pStgSave, BOOL fSameAsLoad) ;
00042   STDMETHODIMP SaveCompleted  ( LPSTORAGE pStgNew);
00043   STDMETHODIMP Load  ( LPSTORAGE pStg);
00044   STDMETHODIMP IsDirty  ();
00045   STDMETHODIMP HandsOffStorage  ();
00046
00047   void ReleaseStreamsAndStorage();
00048   void OpenStreams(LPSTORAGE lpStg);
00049   void CreateStreams(LPSTORAGE lpStg);
00050   void CreateStreams(LPSTORAGE lpStg, LPSTREAM FAR *lpTempColor, LPSTREAM FAR *lpTempSize);
00051
00052 };
00053
00054 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/PropertyList/vc/ADSIhelpers.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • PropertyList
  • vc

ADSIhelpers.cpp

Go to the documentation of this file.
00001
00002 #define INC_OLE2
00003 #define UNICODE 1
00004 #define _WIN32_DCOM
00005
00006
00007 #include "ADSIhelpers.h"
00008
00009
00010 #include <stdio.h>
00011 #include <assert.h>
00012 #include <iads.h>
00013 #include <adshlp.h>
00014 #include <adserr.h>
00015 #include <wchar.h>
00016 #include <objbase.h>
00017 #include <activeds.h>
00018 //Make sure you define UNICODE
00019 //Need to define version 5 for Windows 2000
00020 #define _WIN32_WINNT 0x0500
00021
00022
00023 #include <sddl.h>
00024
00025 //////////////////////////////////////////////////////////////////////
00026 //
00027 // PLEASE READ: You MUST run on Windows 2000 to run this sample
00028 //
00029 ////////////////////////////////////////////////////////////////////////
00030
00031
00032 // Calls all the methods on a IADs object
00033 // and prints them
00034 void PrintIADSObject(IADs * pIADs)
00035 {
00036   assert(pIADs);
00037
00038   BSTR bsResult;
00039
00040   pIADs->get_Name(&bsResult);
00041   wprintf(L" NAME: %s\n",(LPOLESTR) bsResult);
00042   SysFreeString(bsResult);
00043
00044   pIADs->get_Class(&bsResult);
00045   wprintf(L" CLASS: %s\n",(LPOLESTR) bsResult);
00046   SysFreeString(bsResult);
00047
00048   pIADs->get_GUID(&bsResult);
00049   wprintf(L" GUID: %s\n",(LPOLESTR) bsResult);
00050   SysFreeString(bsResult);
00051
00052   pIADs->get_ADsPath(&bsResult);
00053   wprintf(L" ADSPATH: %s\n",(LPOLESTR) bsResult);
00054   SysFreeString(bsResult);
00055
00056   pIADs->get_Parent(&bsResult);
00057   wprintf(L" PARENT: %s\n",(LPOLESTR) bsResult);
00058   SysFreeString(bsResult);
00059
00060   pIADs->get_Schema(&bsResult);
00061   wprintf(L" SCHEMA: %s\n",(LPOLESTR) bsResult);
00062   SysFreeString(bsResult);
00063
00064 }
00065
00066
00067 // Will display a message box for a BAD Hresult.
00068 // Will do nothing for a S_OK HRESULT
00069 // Pass in the HRESULT to be tested and a char * describing the
00070 // area in the code
00071 void CheckHRESULT(HRESULT hr, const char *pszCause)
00072 {
00073     if (FAILED(hr))
00074     {
00075         char sz[1024];
00076         char szCaption[1024];
00077         strcpy(szCaption, pszCause);
00078         strcat(szCaption, " failed!");
00079         if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, sz, 1024, 0))
00080             strcpy(sz, "Unknown error");
00081         MessageBoxA(0, sz, szCaption, MB_SETFOREGROUND);
00082        // DebugBreak();
00083     }
00084 }
00085
00086
00087 // When passed a VARIANT vt member, will return a string describing
00088 // all the bitmask settings...
00089 const char * GetVariantStyle(VARTYPE vt)
00090 {
00091   static char pRet[200];
00092
00093   pRet[0] = NULL;
00094
00095   if (vt == VT_EMPTY) strcat(pRet,"VT_EMPTY ");
00096
00097   if (HAS_BIT_STYLE(vt, VT_BYREF)) strcat(pRet,"VT_BYREF ");
00098   if (HAS_BIT_STYLE(vt, VT_UI1)) strcat(pRet,"VT_UI1 ");
00099   if (HAS_BIT_STYLE(vt, VT_I2)) strcat(pRet,"VT_I2 ");
00100   if (HAS_BIT_STYLE(vt, VT_I4)) strcat(pRet,"VT_I4 ");
00101   if (HAS_BIT_STYLE(vt, VT_R4)) strcat(pRet,"VT_R4 ");
00102   if (HAS_BIT_STYLE(vt, VT_R8)) strcat(pRet,"VT_R8 ");
00103   if (HAS_BIT_STYLE(vt, VT_CY)) strcat(pRet,"VT_CY ");
00104   if (HAS_BIT_STYLE(vt, VT_BSTR)) strcat(pRet,"VT_BSTR ");
00105   if (HAS_BIT_STYLE(vt, VT_NULL)) strcat(pRet,"VT_NULL ");
00106   if (HAS_BIT_STYLE(vt, VT_ERROR)) strcat(pRet,"VT_ERROR ");
00107   if (HAS_BIT_STYLE(vt, VT_BOOL)) strcat(pRet,"VT_BOOL ");
00108   if (HAS_BIT_STYLE(vt, VT_DATE)) strcat(pRet,"VT_DATE ");
00109   if (HAS_BIT_STYLE(vt, VT_DISPATCH)) strcat(pRet,"VT_DISPATCH ");
00110   if (HAS_BIT_STYLE(vt, VT_VARIANT)) strcat(pRet,"VT_VARIANT ");
00111   if (HAS_BIT_STYLE(vt, VT_UNKNOWN)) strcat(pRet,"VT_UNKNOWN ");
00112   if (HAS_BIT_STYLE(vt, VT_ARRAY)) strcat(pRet,"VT_ARRAY ");
00113
00114   return pRet;
00115 }
00116
00117
00118
00119 // Pass in the interface ptr to the property value
00120 // will return a BSTR value of the data.
00121 // The IADsPropertyValue::get_ADsType()  is called to retrieve the
00122 // ADSTYPE valued enum
00123 // This enum is then used to determine which IADsPropertyValue method
00124 // to call to receive the actual data
00125
00126 // CALLER assumes responsibility for freeing returned BSTR
00127 HRESULT GetIADsPropertyValueAsBSTR(BSTR * pbsRet,IADsPropertyEntry *pAdsEntry, IADsPropertyValue * pAdsPV)
00128 {
00129   HRESULT hr = S_OK;
00130
00131   long lAdsType;
00132   hr = pAdsPV->get_ADsType(&lAdsType);
00133
00134   if (FAILED(hr))
00135     return hr;
00136
00137   switch (lAdsType)
00138   {
00139     case ADSTYPE_INVALID :
00140     {
00141       *pbsRet = SysAllocString(L"<ADSTYPE_INVALID>");
00142     }
00143     break;
00144
00145     case ADSTYPE_DN_STRING :
00146     {
00147       hr = pAdsPV->get_DNString(pbsRet);
00148     }
00149     break;
00150     case ADSTYPE_CASE_EXACT_STRING :
00151     {
00152       hr = pAdsPV->get_CaseExactString(pbsRet);
00153     }
00154     break;
00155     case ADSTYPE_CASE_IGNORE_STRING :
00156     {
00157       hr = pAdsPV->get_CaseIgnoreString(pbsRet);
00158     }
00159     break;
00160     case ADSTYPE_PRINTABLE_STRING :
00161     {
00162       hr = pAdsPV->get_PrintableString(pbsRet);
00163     }
00164     break;
00165     case ADSTYPE_NUMERIC_STRING :
00166     {
00167       hr = pAdsPV->get_NumericString(pbsRet);
00168     }
00169     break;
00170     case ADSTYPE_BOOLEAN :
00171     {
00172       long b;
00173       hr = pAdsPV->get_Boolean(&b);
00174       if (SUCCEEDED(hr))
00175       {
00176         if (b)
00177           *pbsRet = SysAllocString(L"<TRUE>");
00178         else
00179           *pbsRet = SysAllocString(L"<FALSE>");
00180       }
00181     }
00182     break;
00183     case ADSTYPE_INTEGER :
00184     {
00185       long lInt;
00186       hr = pAdsPV->get_Integer(&lInt);
00187       if (SUCCEEDED(hr))
00188       {
00189         WCHAR wOut[100];
00190         wsprintf(wOut,L"%d",lInt);
00191         *pbsRet = SysAllocString(wOut);
00192       }
00193     }
00194     break;
00195     case ADSTYPE_OCTET_STRING :
00196     {
00197       *pbsRet = SysAllocString(L"<ADSTYPE_OCTET_STRING>");
00198             BSTR bsName= NULL;
00199             VARIANT vOctet;
00200             DWORD dwSLBound;
00201             DWORD dwSUBound;
00202             void HUGEP *pArray;
00203             VariantInit(&vOctet);
00204
00205         //Get the name of the property to handle
00206         //the properties we're interested in.
00207         pAdsEntry->get_Name(&bsName);
00208         hr = pAdsPV->get_OctetString(&vOctet);
00209
00210                 //Get a pointer to the bytes in the octet string.
00211         if (SUCCEEDED(hr))
00212         {
00213           hr = SafeArrayGetLBound( V_ARRAY(&vOctet),
00214                         1,
00215                         (long FAR *) &dwSLBound );
00216           hr = SafeArrayGetUBound( V_ARRAY(&vOctet),
00217                         1,
00218                         (long FAR *) &dwSUBound );
00219           if (SUCCEEDED(hr))
00220           {
00221             hr = SafeArrayAccessData( V_ARRAY(&vOctet),
00222                           &pArray );
00223           }
00224           /* Since an Octet String has a specific meaning
00225                        depending on the attribute name, handle two
00226                        common ones here
00227                     */
00228                     if (0==wcscmp(L"objectGUID", bsName))
00229           {
00230             LPOLESTR szDSGUID = new WCHAR [39];
00231
00232             //Cast to LPGUID
00233             LPGUID pObjectGUID = (LPGUID)pArray;
00234             //Convert GUID to string.
00235 						::StringFromGUID2(*pObjectGUID, szDSGUID, 39);
00236                         *pbsRet = SysAllocString(szDSGUID);
00237
00238           }
00239           else if (0==wcscmp(L"objectSid", bsName))
00240           {
00241             PSID pObjectSID = (PSID)pArray;
00242
00243             //Convert SID to string.
00244             LPOLESTR szSID = NULL;
00245             ConvertSidToStringSid(pObjectSID, &szSID);
00246                         *pbsRet = SysAllocString(szSID);
00247             LocalFree(szSID);
00248           }
00249           else
00250           {
00251             *pbsRet = SysAllocString(L"<Value of type Octet String. No Conversion>");
00252
00253           }
00254             SafeArrayUnaccessData( V_ARRAY(&vOctet) );
00255             VariantClear(&vOctet);
00256         }
00257
00258         SysFreeString(bsName);
00259
00260
00261     }
00262     break;
00263     case ADSTYPE_LARGE_INTEGER :
00264     {
00265       *pbsRet = SysAllocString(L"<ADSTYPE_LARGE_INTEGER>");
00266     }
00267     break;
00268     case ADSTYPE_PROV_SPECIFIC :
00269     {
00270       *pbsRet = SysAllocString(L"<ADSTYPE_PROV_SPECIFIC>");
00271     }
00272     break;
00273     case ADSTYPE_OBJECT_CLASS :
00274     {
00275       hr = pAdsPV->get_CaseIgnoreString(pbsRet);
00276     }
00277     break;
00278     case ADSTYPE_PATH :
00279     {
00280       hr = pAdsPV->get_CaseIgnoreString(pbsRet);
00281     }
00282     break;
00283     case ADSTYPE_NT_SECURITY_DESCRIPTOR :
00284     {
00285       *pbsRet = SysAllocString(L"<ADSTYPE_NT_SECURITY_DESCRIPTOR>");
00286     }
00287     break;
00288
00289     default:
00290       *pbsRet = SysAllocString(L"<UNRECOGNIZED>");
00291     break;
00292
00293   }
00294   return hr;
00295 }
00296
00297
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/resource.h Source File

  • WinUI
  • TSFcase

resource.h

Go to the documentation of this file.
00001 //
00002 // resource.h
00003 //
00004 // Resource declarations.
00005 //
00006
00007 #ifndef RESOURCE_H
00008 #define RESOURCE_H
00009
00010 //#define IDI_CASE        0
00011
00012 #endif // RESOURCE_H
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/localres.h Source File

  • SysMgmt
  • MMC
  • CutCopy

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029 #define INDEX_BACKGROUND    6
00030 #define INDEX_STATION       7
00031
00032 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/land.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x8512760b, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00023
00024 // {8512760B-6BE7-11d3-9156-00C04F65B3F9}
00025 //DEFINE_GUID(<<name>>,
00026 //0x8512760b, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00027
00028
00029 //==============================================================
00030 //
00031 // CLandBasedVehicle implementation
00032 //
00033 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Event_Provider/Main.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Event_Provider

Main.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Main.cpp
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #include <precomp.h>
00017 #include <objbase.h>
00018 #include <stdio.h>
00019 #include <tchar.h>
00020 #include <wbemcli.h>
00021 #include <wbemprov.h>
00022 #include "Globals.h"
00023
00024 /******************************************************************************
00025  *
00026  *  Name: g_ThreadTerminate
00027  *
00028  *
00029  *  Description:
00030  *
00031  *    Global event used to inform worker thread that it should terminate.
00032  *
00033  *****************************************************************************/
00034
00035 HANDLE g_ThreadTerminate = NULL ;
00036
00037 /******************************************************************************
00038  *
00039  *  Name: WindowsMainProc
00040  *
00041  *
00042  *  Description:
00043  *
00044  *      Spin processing windows messages
00045  *
00046  *****************************************************************************/
00047
00048 LRESULT CALLBACK WindowsMainProc ( HWND a_hWnd , UINT a_message , WPARAM a_wParam , LPARAM a_lParam )
00049 {
00050   LRESULT t_rc = 0 ;
00051
00052   switch ( a_message )
00053   {
00054     case WM_DESTROY:
00055     {
00056       PostMessage ( a_hWnd , WM_QUIT , 0 , 0 ) ;
00057     }
00058     break ;
00059
00060     default:
00061     {
00062       t_rc = DefWindowProc ( a_hWnd , a_message , a_wParam , a_lParam ) ;
00063     }
00064     break ;
00065   }
00066
00067   return ( t_rc ) ;
00068 }
00069
00070 /******************************************************************************
00071  *
00072  *  Name: WindowsInit
00073  *
00074  *
00075  *  Description:
00076  *
00077  *      Initialize a window so that we can close the app down.
00078  *
00079  *****************************************************************************/
00080
00081 HWND WindowsInit ( HINSTANCE a_HInstance )
00082 {
00083   static wchar_t *t_TemplateCode = L"TemplateCode" ;
00084
00085   WNDCLASS  t_wc ;
00086
00087   t_wc.style            = CS_HREDRAW | CS_VREDRAW ;
00088   t_wc.lpfnWndProc      = WindowsMainProc ;
00089   t_wc.cbClsExtra       = 0 ;
00090   t_wc.cbWndExtra       = 0 ;
00091   t_wc.hInstance        = a_HInstance ;
00092   t_wc.hIcon            = LoadIcon(NULL, IDI_HAND) ;
00093   t_wc.hCursor          = LoadCursor(NULL, IDC_ARROW) ;
00094   t_wc.hbrBackground    = (HBRUSH) (COLOR_WINDOW + 1) ;
00095   t_wc.lpszMenuName     = NULL ;
00096   t_wc.lpszClassName    = t_TemplateCode ;
00097
00098   ATOM t_winClass = RegisterClass ( &t_wc ) ;
00099
00100   HWND t_HWnd = CreateWindow (
00101
00102     t_TemplateCode ,              // see RegisterClass() call
00103     t_TemplateCode ,                      // text for window title bar
00104     WS_OVERLAPPEDWINDOW | WS_MINIMIZE ,               // window style
00105     CW_USEDEFAULT ,                     // default horizontal position
00106     CW_USEDEFAULT ,                     // default vertical position
00107     CW_USEDEFAULT ,                     // default width
00108     CW_USEDEFAULT ,                     // default height
00109     NULL ,                              // overlapped windows have no parent
00110     NULL ,                              // use the window class menu
00111     a_HInstance ,
00112     NULL                                // pointer not needed
00113   ) ;
00114
00115   ShowWindow ( t_HWnd, SW_SHOW ) ;
00116   //ShowWindow ( t_HWnd, SW_HIDE ) ;
00117
00118   return t_HWnd ;
00119 }
00120
00121 /******************************************************************************
00122  *
00123  *  Name: WindowsStop
00124  *
00125  *
00126  *  Description:
00127  *
00128  *      Cleanup window
00129  *
00130  *****************************************************************************/
00131
00132 void WindowsStop ( HWND a_HWnd )
00133 {
00134   DestroyWindow ( a_HWnd ) ;
00135 }
00136
00137 /******************************************************************************
00138  *
00139  *  Name: WindowsStart
00140  *
00141  *
00142  *  Description:
00143  *
00144  *      Initialize windows dependant resources.
00145  *
00146  *****************************************************************************/
00147
00148 HWND WindowsStart ( HINSTANCE a_Handle )
00149 {
00150   HWND t_HWnd = NULL ;
00151   if ( ! ( t_HWnd = WindowsInit ( a_Handle ) ) )
00152   {
00153     }
00154
00155   return t_HWnd ;
00156 }
00157
00158 /******************************************************************************
00159  *
00160  *  Name: WindowsDispatch
00161  *
00162  *
00163  *  Description:
00164  *
00165  *      Standard message pump.
00166  *
00167  *****************************************************************************/
00168
00169 void WindowsDispatch ()
00170 {
00171   BOOL t_GetMessage ;
00172   MSG t_lpMsg ;
00173
00174   while ( ( t_GetMessage = GetMessage ( & t_lpMsg , NULL , 0 , 0 ) ) == TRUE )
00175   {
00176     TranslateMessage ( & t_lpMsg ) ;
00177     DispatchMessage ( & t_lpMsg ) ;
00178   }
00179 }
00180
00181 /******************************************************************************
00182  *
00183  *  Name: UninitComServer
00184  *
00185  *
00186  *  Description:
00187  *
00188  *      Uninitialize COM dependant resources,
00189  *
00190  *****************************************************************************/
00191
00192 HRESULT UninitComServer ()
00193 {
00194   CoUninitialize () ;
00195
00196   return S_OK ;
00197 }
00198
00199 /******************************************************************************
00200  *
00201  *  Name: InitComServer
00202  *
00203  *
00204  *  Description:
00205  *
00206  *      Initialize COM dependant resources.
00207  *
00208  *****************************************************************************/
00209
00210 HRESULT InitComServer ( DWORD a_AuthenticationLevel , DWORD a_ImpersonationLevel )
00211 {
00212   HRESULT t_Result = S_OK ;
00213
00214     t_Result = CoInitializeEx (
00215
00216     0,
00217     COINIT_MULTITHREADED
00218   );
00219
00220 #ifndef EOAC_DYNAMIC_CLOAKING
00221 #define EOAC_DYNAMIC_CLOAKING 0x40
00222 #endif
00223
00224   if ( SUCCEEDED ( t_Result ) )
00225   {
00226
00227     DWORD dwCapabilities;
00228     if (a_AuthenticationLevel == RPC_C_AUTHN_LEVEL_NONE)
00229       dwCapabilities = EOAC_NONE;
00230     else
00231       dwCapabilities = EOAC_SECURE_REFS;
00232
00233     t_Result = CoInitializeSecurity (
00234
00235       NULL,
00236       -1,
00237       NULL,
00238       NULL,
00239       a_AuthenticationLevel,
00240       a_ImpersonationLevel,
00241       NULL,
00242       EOAC_DYNAMIC_CLOAKING | dwCapabilities,
00243       0
00244     );
00245
00246     if ( FAILED ( t_Result ) )
00247     {
00248       CoUninitialize () ;
00249       return t_Result ;
00250     }
00251   }
00252
00253   if ( FAILED ( t_Result ) )
00254   {
00255     CoUninitialize () ;
00256   }
00257
00258   return t_Result  ;
00259 }
00260
00261 /******************************************************************************
00262  *
00263  *  Name:   ThreadArg_Struct
00264  *
00265  *
00266  *  Description:
00267  *
00268  *        Structure used to pass objects between threads.
00269  *
00270  *****************************************************************************/
00271
00272 struct ThreadArg_Struct
00273 {
00274   IWbemServices *m_Service ;
00275   IWbemObjectSink *m_Sink ;
00276   IWbemEventSink *m_EventSink ;
00277   IWbemDecoupledBasicEventProvider *m_Registrar ;
00278 } ;
00279
00280 /******************************************************************************
00281  *
00282  *  Name: ThreadExecutionFunction
00283  *
00284  *
00285  *  Description:
00286  *
00287  *    Worker thread function used to obtain event class and sit in a loop
00288  *    generating instances of a particular event class.
00289  *
00290  *****************************************************************************/
00291
00292 DWORD ThreadExecutionFunction ( void *a_Context )
00293 {
00294   HRESULT t_Result = S_OK ;
00295
00296 /*
00297  *  Initialize com on thread.
00298  */
00299
00300   t_Result = CoInitializeEx (
00301
00302     0,
00303     COINIT_MULTITHREADED
00304   ) ;
00305
00306   if ( SUCCEEDED ( t_Result ) )
00307   {
00308
00309 /*
00310  *  Cast thread context to expected type.
00311  */
00312
00313     struct ThreadArg_Struct *t_ThreadStruct = ( struct ThreadArg_Struct * ) a_Context ;
00314     if ( t_ThreadStruct )
00315     {
00316       IWbemClassObject *t_Object = NULL ;
00317       BSTR t_String = SysAllocString ( L"SampleEvent" ) ;
00318       if ( t_String )
00319       {
00320 /*
00321  *  Get the event class from WMI.
00322  */
00323
00324         t_Result = t_ThreadStruct->m_Service->GetObject (
00325
00326           t_String ,
00327           0 ,
00328           NULL ,
00329           & t_Object ,
00330           NULL
00331         ) ;
00332
00333         if ( SUCCEEDED ( t_Result ) )
00334         {
00335 /*
00336  *  Create an event instance.
00337  */
00338
00339           IWbemClassObject *t_Instance = NULL ;
00340           t_Result = t_Object->SpawnInstance ( 0 , & t_Instance ) ;
00341           if ( SUCCEEDED ( t_Result ) )
00342           {
00343             VARIANT t_Variant ;
00344             VariantInit ( & t_Variant ) ;
00345
00346             t_Variant.vt = VT_BSTR ;
00347             t_Variant.bstrVal = SysAllocString ( L"Steve" ) ;
00348             if (t_Variant.bstrVal)
00349             {
00350               t_Result = t_Instance->Put (
00351
00352                   L"Name" ,
00353                   0 ,
00354                   & t_Variant ,
00355                   CIM_EMPTY
00356                 ) ;
00357             }
00358             else
00359             {
00360               t_Result = WBEM_E_OUT_OF_MEMORY;
00361             }
00362
00363
00364             if ( SUCCEEDED ( t_Result ) )
00365             {
00366               VariantClear ( & t_Variant ) ;
00367
00368 /*
00369  *  Sit in a loop until termination event has been signalled.
00370  */
00371
00372               BOOL t_Continue = TRUE ;
00373               while ( t_Continue )
00374               {
00375                 DWORD t_Status = WaitForSingleObject ( g_ThreadTerminate , 1000 ) ;
00376                 switch ( t_Status )
00377                 {
00378                   case WAIT_TIMEOUT:
00379                   {
00380 /*
00381  *  Send the event on its way.
00382  */
00383                     t_ThreadStruct->m_Sink->Indicate ( 1 , & t_Instance ) ;
00384                   }
00385                   break ;
00386
00387                   case WAIT_OBJECT_0:
00388                   {
00389 /*
00390  *  Event is signalled so break out of loop.
00391  */
00392                     t_Continue = FALSE ;
00393                   }
00394                   break ;
00395
00396                   default:
00397                   {
00398 /*
00399  *  Unknown condition, just break out of loop.
00400  */
00401                     t_Continue = FALSE ;
00402                   }
00403                   break ;
00404                 }
00405               }
00406             }
00407
00408             t_Instance->Release () ;
00409           }
00410
00411           t_Object->Release () ;
00412         }
00413
00414         SysFreeString ( t_String ) ;
00415       }
00416       else
00417       {
00418         t_Result = WBEM_E_OUT_OF_MEMORY ;
00419       }
00420
00421       t_ThreadStruct->m_Service->Release () ;
00422       t_ThreadStruct->m_Sink->Release () ;
00423       t_ThreadStruct->m_Registrar->Release () ;
00424
00425       delete t_ThreadStruct ;
00426     }
00427     else
00428     {
00429       t_Result = WBEM_E_INVALID_PARAMETER ;
00430     }
00431
00432     CoUninitialize () ;
00433   }
00434
00435   return t_Result ;
00436 }
00437
00438 /******************************************************************************
00439  *
00440  *  Name: RestrictedThreadExecutionFunction
00441  *
00442  *
00443  *  Description:
00444  *
00445  *    Worker thread function used to obtain event class and sit in a loop
00446  *    generating instances of a particular event class.
00447  *
00448  *****************************************************************************/
00449
00450 DWORD RestrictedThreadExecutionFunction ( void *a_Context )
00451 {
00452   HRESULT t_Result = S_OK ;
00453
00454 /*
00455  *  Initialize com on thread.
00456  */
00457
00458   t_Result = CoInitializeEx (
00459
00460     0,
00461     COINIT_MULTITHREADED
00462   ) ;
00463
00464   if ( SUCCEEDED ( t_Result ) )
00465   {
00466 /*
00467  *  Cast thread context to expected type.
00468  */
00469
00470     struct ThreadArg_Struct *t_ThreadStruct = ( struct ThreadArg_Struct * ) a_Context ;
00471     if ( t_ThreadStruct )
00472     {
00473       IWbemClassObject *t_Object = NULL ;
00474       BSTR t_String = SysAllocString ( L"SampleEvent" ) ;
00475       if ( t_String )
00476       {
00477 /*
00478  *  Obtain a sink that will tell us when a user has asked for an event based on the specific
00479  *  query.
00480  */
00481
00482         wchar_t *t_Query = L"Select * from SampleEvent" ;
00483
00484         IWbemEventSink *t_RestrictedSink = NULL ;
00485
00486         t_Result = t_ThreadStruct->m_EventSink->GetRestrictedSink (
00487
00488           1 ,
00489           & t_Query ,
00490           NULL ,
00491           & t_RestrictedSink
00492         ) ;
00493
00494         if ( SUCCEEDED ( t_Result ) )
00495         {
00496 /*
00497  *  Set event batching parameters to boost performance.
00498  */
00499           t_Result = t_RestrictedSink->SetBatchingParameters (
00500
00501             WBEM_FLAG_MUST_BATCH ,
00502             10000000 ,
00503             1000
00504           );
00505
00506 /*
00507  *  Get the event class from WMI.
00508  */
00509
00510           t_Result = t_ThreadStruct->m_Service->GetObject (
00511
00512             t_String ,
00513             0 ,
00514             NULL ,
00515             & t_Object ,
00516             NULL
00517           ) ;
00518
00519           if ( SUCCEEDED ( t_Result ) )
00520           {
00521 /*
00522  *  Sit in a loop until termination event has been signalled.
00523  */
00524
00525             BOOL t_Continue = TRUE ;
00526             while ( t_Continue )
00527             {
00528
00529               DWORD t_Status = WaitForSingleObject ( g_ThreadTerminate , 10000 ) ;
00530               switch ( t_Status )
00531               {
00532                 case WAIT_TIMEOUT:
00533                 {
00534 /*
00535  *  See if anyone is listening for event
00536  */
00537                   if ( t_RestrictedSink->IsActive () == S_OK )
00538                   {
00539 /*
00540  *  Create an event instance.
00541  */
00542                     IWbemClassObject *t_Instance = NULL ;
00543                     t_Result = t_Object->SpawnInstance ( 0 , & t_Instance ) ;
00544                     if ( SUCCEEDED ( t_Result ) )
00545                     {
00546                       VARIANT t_Variant ;
00547                       VariantInit ( & t_Variant ) ;
00548
00549                       t_Variant.vt = VT_BSTR ;
00550                       t_Variant.bstrVal = SysAllocString ( L"Steve" ) ;
00551
00552                       if (t_Variant.bstrVal)
00553                       {
00554                         t_Result = t_Instance->Put (
00555
00556                                   L"Name" ,
00557                                   0 ,
00558                                   & t_Variant ,
00559                                   CIM_EMPTY
00560                                 ) ;
00561                         /*
00562                         * Send the event on its way.
00563                         */
00564                         t_RestrictedSink->Indicate ( 1 , & t_Instance ) ;
00565
00566                       }
00567                       else
00568                       {
00569                         t_Result = WBEM_E_OUT_OF_MEMORY;
00570                       }
00571
00572
00573                       t_Instance->Release () ;
00574                     }
00575                   }
00576                 }
00577                 break ;
00578
00579                 case WAIT_OBJECT_0:
00580                 {
00581 /*
00582  *  Event is signalled so break out of loop.
00583  */
00584                   t_Continue = FALSE ;
00585                 }
00586                 break ;
00587
00588                 default:
00589                 {
00590 /*
00591  *  Unknown condition, just break out of loop.
00592  */
00593
00594                   t_Continue = FALSE ;
00595                 }
00596                 break ;
00597               }
00598             }
00599
00600             t_Object->Release () ;
00601           }
00602
00603           t_RestrictedSink->Release () ;
00604         }
00605
00606         SysFreeString ( t_String ) ;
00607       }
00608       else
00609       {
00610         t_Result = WBEM_E_OUT_OF_MEMORY ;
00611       }
00612
00613       t_ThreadStruct->m_Service->Release () ;
00614       t_ThreadStruct->m_Sink->Release () ;
00615       t_ThreadStruct->m_Registrar->Release () ;
00616
00617       delete t_ThreadStruct ;
00618     }
00619     else
00620     {
00621       t_Result = WBEM_E_INVALID_PARAMETER ;
00622     }
00623
00624     CoUninitialize () ;
00625   }
00626
00627   return t_Result ;
00628 }
00629
00630 /******************************************************************************
00631  *
00632  *  Name: RegisterDecoupledEvent
00633  *
00634  *
00635  *  Description:
00636  *
00637  *      Register a decoupled event provider object with WMI.
00638  *      We pass in an implementation of IWbemEventProvider so
00639  *      that WMI can inform provider of new client event registrations.
00640  *
00641  *****************************************************************************/
00642
00643 HRESULT RegisterDecoupledEvent (
00644
00645   IWbemDecoupledBasicEventProvider *&a_Registrar ,
00646   HANDLE &a_ThreadHandle
00647 )
00648 {
00649 /*
00650  *  Cleanup out arguments
00651  */
00652
00653   a_ThreadHandle = NULL ;
00654   a_Registrar = NULL ;
00655
00656   HRESULT t_Result = S_OK ;
00657
00658 /*
00659  *  Create an event to inform worker thread to terminate.
00660  */
00661
00662   g_ThreadTerminate = CreateEvent ( NULL , FALSE , FALSE , NULL ) ;
00663   if ( g_ThreadTerminate )
00664   {
00665 /*
00666  *  Create the event registrar, so that we can register with WMI.
00667  */
00668
00669     t_Result = Provider_Globals :: CreateInstance (
00670
00671       CLSID_WbemDecoupledBasicEventProvider ,
00672       NULL ,
00673       CLSCTX_INPROC_SERVER ,
00674       IID_IWbemDecoupledBasicEventProvider ,
00675       ( void ** ) & a_Registrar
00676     ) ;
00677
00678     if ( SUCCEEDED ( t_Result ) )
00679     {
00680       t_Result = a_Registrar->Register (
00681
00682         0 ,
00683         NULL ,
00684         NULL ,
00685         NULL ,
00686         L"root\\cimv2" ,
00687         L"DecoupledEventProvider" ,
00688         NULL
00689       ) ;
00690
00691       if ( SUCCEEDED ( t_Result ) )
00692       {
00693 /*
00694  *  Grab the IWbemServices pointer associated with the provider instance, use it later to
00695  *  query for class specific information when generating events.
00696  */
00697
00698         IWbemServices *t_Service = NULL ;
00699         t_Result = a_Registrar->GetService ( 0 , NULL , & t_Service ) ;
00700         if ( SUCCEEDED ( t_Result ) )
00701         {
00702
00703 /*
00704  *  Grab the event sink associated with the event provider instance, use it later to send events to WMI.
00705  */
00706
00707           IWbemObjectSink *t_Sink = NULL ;
00708           t_Result = a_Registrar->GetSink ( 0 , NULL , & t_Sink ) ;
00709           if ( SUCCEEDED ( t_Result ) )
00710           {
00711 /*
00712  *  Pass information taken from WMI and package it so that worker thread can
00713  *  proceed.
00714  */
00715
00716             struct ThreadArg_Struct *t_ThreadStruct = new ThreadArg_Struct ;
00717             if ( t_ThreadStruct )
00718             {
00719               t_ThreadStruct->m_Service = t_Service ;
00720               t_ThreadStruct->m_Sink = t_Sink ;
00721               t_ThreadStruct->m_Registrar = a_Registrar ;
00722
00723               t_ThreadStruct->m_Service->AddRef () ;
00724               t_ThreadStruct->m_Sink->AddRef () ;
00725               t_ThreadStruct->m_Registrar->AddRef () ;
00726
00727 /*
00728  *  Create worker thread.
00729  */
00730
00731               DWORD t_ThreadId = 0 ;
00732               a_ThreadHandle = CreateThread (
00733
00734                 NULL ,
00735                 0 ,
00736                 ( LPTHREAD_START_ROUTINE ) ThreadExecutionFunction ,
00737                 t_ThreadStruct ,
00738                 0 ,
00739                 & t_ThreadId
00740               ) ;
00741
00742               if ( a_ThreadHandle == NULL )
00743               {
00744 /*
00745  *  Everything failed to release resources.
00746  */
00747
00748                 t_ThreadStruct->m_Service->Release () ;
00749                 t_ThreadStruct->m_Sink->Release () ;
00750                 t_ThreadStruct->m_Registrar->Release () ;
00751
00752                 delete t_ThreadStruct ;
00753
00754                 t_Result = WBEM_E_FAILED ;
00755               }
00756             }
00757             else
00758             {
00759               t_Result = WBEM_E_OUT_OF_MEMORY ;
00760             }
00761
00762             t_Sink->Release () ;
00763           }
00764
00765           t_Service->Release () ;
00766         }
00767       }
00768     }
00769
00770     if ( FAILED ( t_Result ) )
00771     {
00772       if ( a_Registrar )
00773       {
00774         a_Registrar->Release () ;
00775         a_Registrar = NULL ;
00776       }
00777     }
00778   }
00779   else
00780   {
00781     t_Result = WBEM_E_OUT_OF_MEMORY ;
00782   }
00783
00784   return t_Result ;
00785 }
00786
00787 /******************************************************************************
00788  *
00789  *  Name: RegisterDecoupledRestrictedEvent
00790  *
00791  *
00792  *  Description:
00793  *
00794  *      Register the event provider and create a thread to perform
00795  *      generate of events. A restricted sink is an extension to
00796  *      a regular event sink, one can specify batching parameters,
00797  *      detect when atleast one client has registered for a specific query, etc.
00798  *
00799  *****************************************************************************/
00800
00801 HRESULT RegisterDecoupledRestrictedEvent (
00802
00803   IWbemDecoupledBasicEventProvider *&a_Registrar ,
00804   HANDLE &a_ThreadHandle
00805 )
00806 {
00807 /*
00808  *  Cleanup out arguments
00809  */
00810
00811   a_ThreadHandle = NULL ;
00812   a_Registrar = NULL ;
00813
00814   HRESULT t_Result = S_OK ;
00815
00816 /*
00817  *  Create an event to inform worker thread to terminate.
00818  */
00819
00820   g_ThreadTerminate = CreateEvent ( NULL , FALSE , FALSE , NULL ) ;
00821   if ( g_ThreadTerminate )
00822   {
00823 /*
00824  *  Create the event registrar, so that we can register with WMI.
00825  */
00826
00827     t_Result = Provider_Globals :: CreateInstance (
00828
00829       CLSID_WbemDecoupledBasicEventProvider ,
00830       NULL ,
00831       CLSCTX_INPROC_SERVER ,
00832       IID_IWbemDecoupledBasicEventProvider ,
00833       ( void ** ) & a_Registrar
00834     ) ;
00835
00836     if ( SUCCEEDED ( t_Result ) )
00837     {
00838 /*
00839  *  Register the provider inteface with WMI, specifying the namespace and provider instance of __Win32provider
00840  */
00841
00842       t_Result = a_Registrar->Register (
00843
00844         0 ,
00845         NULL ,
00846         NULL ,
00847         NULL ,
00848         L"root\\cimv2" ,
00849         L"DecoupledEventProvider" ,
00850         NULL
00851       ) ;
00852
00853       if ( SUCCEEDED ( t_Result ) )
00854       {
00855 /*
00856  *  Grab the IWbemServices pointer associated with the provider instance, use it later to
00857  *  query for class specific information when generating events.
00858  */
00859
00860         IWbemServices *t_Service = NULL ;
00861         t_Result = a_Registrar->GetService ( 0 , NULL , & t_Service ) ;
00862         if ( SUCCEEDED ( t_Result ) )
00863         {
00864 /*
00865  *  Grab the event sink associated with the event provider instance, use it later to send events to WMI.
00866  */
00867           IWbemObjectSink *t_Sink = NULL ;
00868           t_Result = a_Registrar->GetSink ( 0 , NULL , & t_Sink ) ;
00869           if ( SUCCEEDED ( t_Result ) )
00870           {
00871             IWbemEventSink *t_EventSink = NULL ;
00872             t_Result = t_Sink->QueryInterface ( IID_IWbemEventSink , ( void **) & t_EventSink ) ;
00873             if ( SUCCEEDED ( t_Result ) )
00874             {
00875 /*
00876  *  Pass information taken from WMI and package it so that worker thread can
00877  *  proceed.
00878  */
00879               struct ThreadArg_Struct *t_ThreadStruct = new ThreadArg_Struct ;
00880               if ( t_ThreadStruct )
00881               {
00882                 t_ThreadStruct->m_Service = t_Service ;
00883                 t_ThreadStruct->m_Sink = t_Sink ;
00884                 t_ThreadStruct->m_EventSink = t_EventSink ;
00885                 t_ThreadStruct->m_Registrar = a_Registrar ;
00886
00887                 t_ThreadStruct->m_Service->AddRef () ;
00888                 t_ThreadStruct->m_Sink->AddRef () ;
00889                 t_ThreadStruct->m_EventSink->AddRef () ;
00890                 t_ThreadStruct->m_Registrar->AddRef () ;
00891
00892 /*
00893  *  Create worker thread.
00894  */
00895                 DWORD t_ThreadId = 0 ;
00896                 a_ThreadHandle = CreateThread (
00897
00898                   NULL ,
00899                   0 ,
00900                   ( LPTHREAD_START_ROUTINE ) RestrictedThreadExecutionFunction ,
00901                   t_ThreadStruct ,
00902                   0 ,
00903                   & t_ThreadId
00904                 ) ;
00905
00906                 if ( a_ThreadHandle == NULL )
00907                 {
00908 /*
00909  *  Everything failed to release resources.
00910  */
00911
00912                   t_ThreadStruct->m_Service->Release () ;
00913                   t_ThreadStruct->m_Sink->Release () ;
00914                   t_ThreadStruct->m_EventSink->Release () ;
00915                   t_ThreadStruct->m_Registrar->Release () ;
00916
00917                   delete t_ThreadStruct ;
00918
00919                   t_Result = WBEM_E_FAILED ;
00920                 }
00921
00922                 t_EventSink->Release () ;
00923               }
00924               else
00925               {
00926                 t_Result = WBEM_E_OUT_OF_MEMORY ;
00927               }
00928             }
00929
00930             t_Sink->Release () ;
00931           }
00932
00933           t_Service->Release () ;
00934         }
00935       }
00936     }
00937
00938     if ( FAILED ( t_Result ) )
00939     {
00940       if ( a_Registrar )
00941       {
00942         a_Registrar->Release () ;
00943         a_Registrar = NULL ;
00944       }
00945     }
00946   }
00947   else
00948   {
00949     t_Result = WBEM_E_OUT_OF_MEMORY ;
00950   }
00951
00952   return t_Result ;
00953 }
00954
00955 /******************************************************************************
00956  *
00957  *  Name:   Process_DecoupledEvent
00958  *
00959  *
00960  *  Description:
00961  *
00962  *        Register the provider and just sit spinning until the
00963  *        application window is destroyed.
00964  *
00965  *****************************************************************************/
00966
00967 HRESULT Process_DecoupledEvent ()
00968 {
00969   HANDLE t_ThreadHandle = NULL ;
00970
00971   IWbemDecoupledBasicEventProvider *t_EventRegistrar = NULL ;
00972
00973   HRESULT t_Result = RegisterDecoupledEvent ( t_EventRegistrar , t_ThreadHandle ) ;
00974
00975   if ( SUCCEEDED ( t_Result ) )
00976   {
00977     WindowsDispatch () ;
00978
00979 /*
00980  *  Wait for provider thread to terminate before completing.
00981  */
00982
00983     SetEvent ( g_ThreadTerminate ) ;
00984     WaitForSingleObject ( t_ThreadHandle , INFINITE ) ;
00985     CloseHandle ( t_ThreadHandle ) ;
00986   }
00987
00988   if ( t_EventRegistrar )
00989   {
00990     t_EventRegistrar->UnRegister () ;
00991     t_EventRegistrar->Release () ;
00992   }
00993
00994   return t_Result ;
00995 }
00996
00997 /******************************************************************************
00998  *
00999  *  Name:   Process_DecoupledRestrictedEvent
01000  *
01001  *
01002  *  Description:
01003  *
01004  *        Register the provider and just sit spinning until the
01005  *        application window is destroyed.
01006  *
01007  *****************************************************************************/
01008
01009 HRESULT Process_DecoupledRestrictedEvent ()
01010 {
01011   HANDLE t_ThreadHandle = NULL ;
01012
01013   IWbemDecoupledBasicEventProvider *t_EventRegistrar = NULL ;
01014
01015   HRESULT t_Result = RegisterDecoupledRestrictedEvent ( t_EventRegistrar , t_ThreadHandle ) ;
01016   if ( SUCCEEDED ( t_Result ) )
01017   {
01018     WindowsDispatch () ;
01019
01020 /*
01021  *  Wait for provider thread to terminate before completing.
01022  */
01023
01024     SetEvent ( g_ThreadTerminate ) ;
01025     WaitForSingleObject ( t_ThreadHandle , INFINITE ) ;
01026     CloseHandle ( t_ThreadHandle ) ;
01027   }
01028
01029   if ( t_EventRegistrar )
01030   {
01031     t_EventRegistrar->UnRegister () ;
01032     t_EventRegistrar->Release () ;
01033   }
01034
01035   return t_Result ;
01036 }
01037
01038 /******************************************************************************
01039  *
01040  *  Name: Process
01041  *
01042  *
01043  *  Description:
01044  *
01045  *      Main work routine, initialize com components and performs
01046  *      event provider dispatch loop.
01047  *
01048  *****************************************************************************/
01049
01050 HRESULT Process ()
01051 {
01052   DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
01053   DWORD t_AuthenticationLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
01054
01055   HRESULT t_Result = InitComServer ( t_AuthenticationLevel , t_ImpersonationLevel ) ;
01056   if ( SUCCEEDED ( t_Result ) )
01057   {
01058     try
01059     {
01060 #if 0
01061
01062 /*
01063  *  Create a restricted sink event provider
01064  */
01065       t_Result = Process_DecoupledRestrictedEvent () ;
01066
01067 #else
01068
01069 /*
01070  *  Create a regular sink event provider
01071  */
01072
01073       t_Result = Process_DecoupledEvent () ;
01074 #endif
01075     }
01076     catch ( ... )
01077     {
01078     }
01079
01080     UninitComServer () ;
01081   }
01082
01083   return t_Result ;
01084 }
01085
01086 /******************************************************************************
01087  *
01088  *  Name: Main
01089  *
01090  *
01091  *  Description:
01092  *
01093  *    Main entry point, initialize global resources, windows components and then
01094  *    perform provider work.
01095  *
01096  *****************************************************************************/
01097
01098 int WINAPI WinMain (
01099
01100     HINSTANCE hInstance,    // handle to current instance
01101     HINSTANCE hPrevInstance,  // handle to previous instance
01102     LPSTR lpCmdLine,      // pointer to command line
01103     int nShowCmd        // show state of window
01104 )
01105 {
01106   HRESULT t_Result = Provider_Globals :: Global_Startup () ;
01107   if ( SUCCEEDED ( t_Result ) )
01108   {
01109     HWND t_Window = WindowsStart ( hInstance ) ;
01110     if ( t_Window )
01111     {
01112       t_Result = Process () ;
01113
01114       WindowsStop ( t_Window ) ;
01115     }
01116
01117     t_Result = Provider_Globals :: Global_Shutdown () ;
01118   }
01119
01120   return 0 ;
01121 }
01122
01123
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/CacheProxy/csharp/AssemblyInfo.cs Source File

  • Multimedia
  • WindowsMediaServices9
  • CacheProxy
  • csharp

AssemblyInfo.cs

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // AssemblyInfo.cs
00007 //
00008 //------------------------------------------------------------------------------
00009 using System.Reflection;
00010 using System.Runtime.CompilerServices;
00011
00012 //
00013 // General Information about an assembly is controlled through the following
00014 // set of attributes. Change these attribute values to modify the information
00015 // associated with an assembly.
00016 //
00017 [assembly: AssemblyTitle("CacheProxySamplePlugin")]
00018 [assembly: AssemblyDescription("Windows Media Services SDK Cache-Proxy Sample Plugin")]
00019 [assembly: AssemblyConfiguration("")]
00020 [assembly: AssemblyCompany("Microsoft Corporation")]
00021 [assembly: AssemblyProduct("Windows Media Services")]
00022 [assembly: AssemblyCopyright("Microsoft Corporation. All rights reserved.")]
00023 [assembly: AssemblyTrademark("")]
00024 [assembly: AssemblyCulture("")]
00025
00026 //
00027 // Version information for an assembly consists of the following four values:
00028 //
00029 //      Major Version
00030 //      Minor Version
00031 //      Build Number
00032 //      Revision
00033 //
00034 // You can specify all the values or you can default the Revision and Build Numbers
00035 // by using the '*' as shown below:
00036
00037 [assembly: AssemblyVersion("1.0")]
00038
00039 //
00040 // In order to sign your assembly you must specify a key to use. Refer to the
00041 // Microsoft .NET Framework documentation for more information on assembly signing.
00042 //
00043 // Use the attributes below to control which key is used for signing.
00044 //
00045 // Notes:
00046 //   (*) If no key is specified, the assembly is not signed.
00047 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00048 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00049 //       a key.
00050 //   (*) If the KeyFile and the KeyName values are both specified, the
00051 //       following processing occurs:
00052 //       (1) If the KeyName can be found in the CSP, that key is used.
00053 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00054 //           in the KeyFile is installed into the CSP and used.
00055 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00056 //       When specifying the KeyFile, the location of the KeyFile should be
00057 //       relative to the project output directory which is
00058 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00059 //       located in the project directory, you would specify the AssemblyKeyFile
00060 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00061 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00062 //       documentation for more information on this.
00063 //
00064 [assembly: AssemblyDelaySign(false)]
00065 [assembly: AssemblyKeyFile("")]
00066 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/NetProviders/LogonNP/Npaux.h Source File

  • Security
  • NetProviders
  • LogonNP

Npaux.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 npaux.h
00010 ---------------------------------------------------------------*/
00011
00012 #if !defined (INC_NPAUX_H)
00013 #define INC_NPAUX_H
00014
00015 //
00016 // Unicode strings are counted 16-bit character strings. If they are
00017 // NULL terminated, Length does not include trailing NULL.
00018 //
00019
00020 typedef struct _UNICODE_STRING
00021 {
00022    USHORT Length;
00023    USHORT MaximumLength;
00024    #ifdef MIDL_PASS
00025    [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
00026    #else // MIDL_PASS
00027    PWSTR  Buffer;
00028    #endif // MIDL_PASS
00029 } UNICODE_STRING;
00030 typedef UNICODE_STRING *PUNICODE_STRING;
00031    #define UNICODE_NULL ((WCHAR)0) // winnt
00032
00033
00034 typedef enum _MSV1_0_LOGON_SUBMIT_TYPE
00035 {
00036    Dummy
00037 } MSV1_0_LOGON_SUBMIT_TYPE, *PMSV1_0_LOGON_SUBMIT_TYPE;
00038
00039
00040 typedef struct _MSV1_0_INTERACTIVE_LOGON
00041 {
00042    MSV1_0_LOGON_SUBMIT_TYPE MessageType;
00043    UNICODE_STRING LogonDomainName;
00044    UNICODE_STRING UserName;
00045    UNICODE_STRING Password;
00046 } MSV1_0_INTERACTIVE_LOGON, *PMSV1_0_INTERACTIVE_LOGON;
00047
00048 #endif
00049
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStartupListener/MyStartupListener.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStartupListener

MyStartupListener.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      MyStartupListener.h
00005 //
00006 //  Description:
00007 //      Declaration of the CMyStartupListener class.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #pragma once
00012
00013 //
00014 // Categories and ClusCfg GUIDS
00015 //
00016 #include <ClusCfgGuids.h>
00017
00018 #include "resource.h"
00019
00020 //
00021 // Store the warning state.
00022 //
00023 #pragma warning( push )
00024
00025 //
00026 // Disable warning 4995. The text of the warning is below:
00027 // 'wsprintf': name was marked as #pragma deprecated
00028 //
00029 #pragma warning( disable : 4995 )
00030
00031 // {BA3DE790-AD13-432b-A1DB-4905F6C7A336}
00032 DEFINE_GUID( CLSID_MyStartupListener,
00033 0xba3de790, 0xad13, 0x432b, 0xa1, 0xdb, 0x49, 0x5, 0xf6, 0xc7, 0xa3, 0x36);
00034
00035 /////////////////////////////////////////////////////////////////////////////
00036 //++
00037 //
00038 // CMyStartupListener class definition
00039 //
00040 //--
00041 /////////////////////////////////////////////////////////////////////////////
00042 class CMyStartupListener
00043     : public CComObjectRootEx<CComMultiThreadModel>
00044     , public CComCoClass<CMyStartupListener, &CLSID_MyStartupListener>
00045     , public IClusCfgStartupListener
00046     , public IClusCfgInitialize
00047 {
00048 private:
00049     //
00050     // Locale id.
00051     //
00052     LCID                m_lcid;
00053
00054     //
00055     // Pointer to the callback interface.
00056     //
00057     IClusCfgCallback * m_piccCallback;
00058
00059 protected:
00060     //
00061     // Constructor and destructor
00062     //
00063     CMyStartupListener( void );
00064     ~CMyStartupListener( void );
00065
00066 public:
00067
00068     DECLARE_REGISTRY_RESOURCEID( IDR_MYSTARTUPLISTENER )
00069     DECLARE_NOT_AGGREGATABLE( CMyStartupListener )
00070
00071     DECLARE_PROTECT_FINAL_CONSTRUCT()
00072
00073     BEGIN_COM_MAP( CMyStartupListener )
00074         COM_INTERFACE_ENTRY( IClusCfgStartupListener )
00075         COM_INTERFACE_ENTRY( IClusCfgInitialize )
00076     END_COM_MAP()
00077
00078     BEGIN_CATEGORY_MAP( CMyStartupListener )
00079         IMPLEMENTED_CATEGORY( CATID_ClusCfgStartupListeners )
00080     END_CATEGORY_MAP()
00081
00082     //
00083     // IClusCfgStartupListener methods
00084     //
00085     STDMETHOD( Notify ) ( IUnknown * punkIn );
00086
00087     //
00088     //  IClusCfgInitialize methods
00089     //
00090     STDMETHOD( Initialize )(
00091           IUnknown *   punkCallbackIn
00092         , LCID         lcidIn
00093         );
00094
00095 }; //*** class: CMyStartupListener
00096
00097 //
00098 // Restore the warning state.
00099 //
00100 #pragma warning( pop )
00101
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkBlog/C#/AddBlog.aspx.cs Source File

  • TabletPC
  • InkBlog
  • C#

AddBlog.aspx.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2004 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: AddBlog.aspx.cs
00013 //  ASP.NET code behind page used for submitting new blog data.
00014 //
00015 //  This class receives the blog data posted by the user to the server
00016 //  and uses it to create a web page that is viewable from Default.aspx.
00017 //  If the client supports inking, this page contains text for the blog
00018 //  title and ink serialized as GIF for the blog body.  Otherwise, if the
00019 //  client does not support inking, it will consist of text for both the blog
00020 //  title and body.
00021 //
00022 //--------------------------------------------------------------------------
00023
00024 using System;
00025 using System.Collections.Specialized;
00026 using System.IO;
00027 using System.Web.UI;
00028
00029 namespace InkBlog
00030 {
00031     /// <summary>
00032     /// The AddBlog code-behind page.
00033     /// </summary>
00034     public class AddBlog : Page
00035     {
00036
00037         /// <summary>
00038         /// Handles the Load event for this Page.
00039         ///
00040         /// Retrieves the blog data posted to the server and uses it to
00041         /// create an HTML page that is viewable from Default.aspx.
00042         /// If the blog contains ink data, this page will consist of
00043         /// a GIF containing serialized ink data; otherwise, it will
00044         /// consist only of text.
00045         /// </summary>
00046         /// <param name="sender">The object that raised the event.</param>
00047         /// <param name="e">The event arguments.</param>
00048         private void Page_Load(object sender, System.EventArgs e)
00049         {
00050             NameValueCollection form = Request.Form;
00051
00052             if ( form.Keys.Count > 0 )
00053             {
00054                 // Determine the location where blog web pages and images are
00055                 // stored on the server
00056                 string blogPath = Server.MapPath("Blogs/");
00057                 string imagePath = Path.Combine(blogPath,"Images");
00058
00059                 // If this location does not yet exist, create it.
00060                 DirectoryInfo dirInfo = new DirectoryInfo(imagePath);
00061                 if (!dirInfo.Exists)
00062                 {
00063                     dirInfo.Create();
00064                 }
00065
00066                 // Specifies the name of the web page file to generate.
00067                 //    In this case, we use a timestamp to uniquely identify each blog.
00068                 string fileName = DateTime.Now.Ticks.ToString();
00069
00070                 // Extract the blog title and body data posted to the server
00071                 String blogTitle = form.GetValues("BlogTitleText")[0];
00072                 String inkBody  = form.GetValues("BlogBodyInkData")[0];
00073                 String textBody = form.GetValues("BlogBodyText")[0];
00074
00075                 // Html fragment to be inserted into the blog's web page.
00076                 string content = null;
00077
00078                 // Check if ink data is available.  If so create a corresponding GIF
00079                 // from the serialized ink data and an HTML fragment referencing it.
00080                 // Otherwise, create an HTML fragment with text from the blog.
00081                 if ( ( String.Empty != inkBody ) )
00082                 {
00083                     // Use helper method to create a GIF image file from ink data
00084                     CreateGif(imagePath, fileName, inkBody);
00085
00086                     // Create an HTML fragment to reference the image file
00087                     content = "<img src=\"Blogs/Images/" + fileName + ".gif\"></img>";
00088                 }
00089                 else
00090                 {
00091                     // If no ink data is available create an HTML fragment that contains
00092                     // the blog's text directly.
00093                     content = "<P>" + textBody + "</P>";
00094                 }
00095
00096                 // Use helper method to create the blog web page on the server
00097                 CreateHtm(blogPath, fileName, blogTitle, content);
00098
00099                 // Redirect the user to Default.aspx, which displays a list of all
00100                 // available blogs.
00101                 Response.Clear();
00102                 Response.Redirect("Default.aspx");
00103             }
00104         }
00105
00106         /// <summary>
00107         /// Helper method to create a GIF image file from the serialized ink data.
00108         /// Note:  since the ink data was serialized on the client side, the
00109         /// server does not need to have any specialized knowledge of ink.
00110         /// </summary>
00111         /// <param name="path">The location where the image should be created</param>
00112         /// <param name="fileName">The filename of the image</param>
00113         /// <param name="inkData">The serialized ink data</param>
00114         protected void CreateGif(String path, String fileName, String inkBody)
00115         {
00116             String gifFilePath = Path.Combine(path, fileName + ".gif");
00117             using (FileStream fs = File.Create(gifFilePath))
00118             {
00119                 byte[] bytes = Convert.FromBase64String(inkBody);
00120                 fs.Write(bytes,0,bytes.Length);
00121             }
00122         }
00123
00124         /// <summary>
00125         /// Helper method to create a HTM file from the blog data.
00126         /// </summary>
00127         /// <param name="fileName">The location where the HTM file should be created</param>
00128         /// <param name="blogName">The filename of the image</param>
00129         /// <param name="content">The HTML fragment that either references the ink image or text data</param>
00130         protected void CreateHtm(String path, String fileName, String blogTitle, String content)
00131         {
00132             String htmFilePath = Path.Combine(path, fileName + ".htm");
00133
00134             using (StreamWriter htmFile = File.CreateText(htmFilePath))
00135             {
00136                 htmFile.Write("<h3 align=center>" + blogTitle + " (" +DateTime.Now.ToString() + ")</h3>");
00137                 htmFile.Write(content);
00138             }
00139         }
00140
00141         #region Web Form Designer generated code
00142         override protected void OnInit(EventArgs e)
00143         {
00144             //
00145             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
00146             //
00147             InitializeComponent();
00148             base.OnInit(e);
00149         }
00150
00151         /// <summary>
00152         /// Required method for Designer support - do not modify
00153         /// the contents of this method with the code editor.
00154         /// </summary>
00155         private void InitializeComponent()
00156         {
00157             this.Load += new System.EventHandler(this.Page_Load);
00158         }
00159         #endregion
00160     }
00161 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHandler Member List

This is the complete list of members for CHandler, including all inherited members.
CHandler() | CHandler
GetRecordset(BSTR conn, BSTR args, BSTR query, _Recordset **ppRS) | CHandler
InterfaceSupportsErrorInfo(REFIID riid) | CHandler
OpenConnection(BSTR conn, BSTR args, long lFlags, BSTR *pQuery, _Connection **ppConnection) | CHandler
Reconnect(BSTR conn, BSTR args, _Recordset *pRS) | CHandler
Generated on Wed Nov 13 2024 16:56:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Methodsub.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Methodsub.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "ComSpyCtl.h"
00019 #include <comsvcs.h>
00020 #include "SysLCESub.h"
00021 #include "ComSpyAudit.h"
00022
00023 #include "CComSpy.h"
00024 #include "MethodSub.h"
00025
00026 extern LONGLONG PerformanceFrequency;
00027
00028 STDMETHODIMP  CMethodSub::OnMethodCall(COMSVCSEVENTINFO * pInfo, ULONG64 oid,REFCLSID guidCid, REFIID guidRid, ULONG iMeth)
00029 {
00030   TimeStack * pStack = m_map[oid];
00031   if (!pStack)
00032   {
00033     pStack = new TimeStack;
00034     m_map[oid] = pStack;
00035   }
00036   _ASSERTE(pStack);
00037   pStack -> push_front(pInfo->perfCount);
00038
00039   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnMethodCall"), GuidToBstr(pInfo->guidApp));
00040   WCHAR id[32];
00041   //wsprintfW(id,L"0x%08X", oid);
00042   wsprintfW(id,L"0x%016X", oid);
00043   m_pSpy -> AddParamValueToList(L"ObjectID", id);
00044
00045     CComBSTR sCid = GuidToBstr(guidCid);
00046     CComBSTR sIid = GuidToBstr(guidRid);
00047
00048   m_pSpy -> AddParamValueToList(L"CLSID", sCid);
00049   m_pSpy -> AddParamValueToList(L"riid", sIid);
00050
00051   TCHAR * pszGuidName = NULL;
00052   HRESULT hr;
00053   hr = GetMethodName(guidRid, iMeth, &pszGuidName) ;
00054     if(hr == S_OK)
00055   {
00056     m_pSpy -> AddParamValueToList(L"Method Name", pszGuidName);
00057   }
00058   else
00059   {
00060     pszGuidName = new _TCHAR[8] ;
00061     wsprintf(pszGuidName, _T("%X"), iMeth) ;
00062     m_pSpy -> AddParamValueToList(L"v-table index", pszGuidName);
00063   }
00064     IF_AUDIT_DO(OnMethodCall)(pInfo->perfCount,
00065                 GuidToBstr(pInfo->guidApp),
00066                 id,
00067                 sCid,
00068                 sIid,
00069                 pszGuidName);
00070
00071
00072
00073     delete pszGuidName ;
00074     pszGuidName = NULL ;
00075   return S_OK;
00076 }
00077
00078 STDMETHODIMP  CMethodSub::OnMethodReturn(COMSVCSEVENTINFO * pInfo,
00079                       ULONG64 oid,
00080                       REFCLSID guidCid,
00081                       REFIID guidRid,
00082                       ULONG iMeth,
00083                       HRESULT hrRet)
00084 {
00085   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnMethodReturn"), GuidToBstr(pInfo->guidApp));
00086   WCHAR id[32];
00087   wsprintfW(id,L"0x%016X", oid);
00088   m_pSpy -> AddParamValueToList(L"ObjectID", id);
00089
00090     CComBSTR sCid = GuidToBstr(guidCid);
00091     CComBSTR sIid = GuidToBstr(guidRid);
00092
00093   m_pSpy -> AddParamValueToList(L"CLSID", sCid);
00094   m_pSpy -> AddParamValueToList(L"riid", sIid);
00095
00096   TCHAR      * pszGuidName   =   NULL ;
00097   HRESULT hr;
00098   hr = GetMethodName(guidRid, iMeth, &pszGuidName) ;
00099     if(hr != S_OK)
00100   {
00101     pszGuidName = new _TCHAR[8] ;
00102     wsprintf(pszGuidName, _T("%X"), iMeth) ;
00103     m_pSpy -> AddParamValueToList(L"v-table index", pszGuidName);
00104   }
00105   else
00106   {
00107     m_pSpy -> AddParamValueToList(L"Method Name", pszGuidName);
00108   }
00109
00110   WCHAR wcRet[16];
00111   wsprintfW(wcRet, L"0x%08X", hrRet);
00112     m_pSpy -> AddParamValueToList(L"Return Value", wcRet);
00113
00114
00115   TCHAR sTime[16];
00116   TimeStack * pStack = m_map[oid];
00117   LONGLONG oldTime  = pStack -> front();
00118   pStack -> pop_front();
00119   _ASSERTE(oldTime);
00120
00121     DWORD timeDiff = (DWORD)((1000*(pInfo->perfCount-oldTime))/PerformanceFrequency);
00122   wsprintf(sTime, _T("%d"), timeDiff);
00123
00124   m_pSpy -> AddParamValueToList(L"Call time (ms)", sTime);
00125
00126
00127   IF_AUDIT_DO(OnMethodReturn)(pInfo->perfCount,
00128                 GuidToBstr(pInfo->guidApp),
00129                   id,
00130                   sCid,
00131                   sIid,
00132                   pszGuidName,
00133                   hrRet,
00134                   sTime);
00135   delete pszGuidName ;
00136     pszGuidName = NULL ;
00137
00138
00139   if (pStack -> empty())
00140   {
00141     delete pStack;
00142     m_map.erase(oid);
00143   }
00144   return S_OK;
00145 }
00146
00147 STDMETHODIMP  CMethodSub::OnMethodException(COMSVCSEVENTINFO * pInfo, ULONG64 oid,REFCLSID guidCid, REFIID guidRid, ULONG iMeth)
00148 {
00149   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnMethodException"), GuidToBstr(pInfo->guidApp));
00150
00151   WCHAR id[32];
00152   wsprintfW(id,L"0x%016X", oid);
00153   m_pSpy -> AddParamValueToList(L"ObjectID", id);
00154
00155     CComBSTR sCid = GuidToBstr(guidCid);
00156     CComBSTR sIid = GuidToBstr(guidRid);
00157
00158   m_pSpy -> AddParamValueToList(L"CLSID", sCid);
00159   m_pSpy -> AddParamValueToList(L"riid", sIid);
00160
00161   TCHAR      * pszGuidName   =   NULL ;
00162   HRESULT hr;
00163   hr = GetMethodName(guidRid, iMeth, &pszGuidName) ;
00164     if(hr != S_OK) { pszGuidName = new _TCHAR[64] ; lstrcpyn(pszGuidName, L"Unknown (no TypeLibrary)", sizeof("Unknown (no TypeLibrary)")) ; }
00165     m_pSpy -> AddParamValueToList(L"Method Name", pszGuidName);
00166
00167     IF_AUDIT_DO(OnMethodException)(pInfo->perfCount,
00168                    GuidToBstr(pInfo->guidApp),
00169                    id,
00170                    sCid,
00171                    sIid,
00172                    pszGuidName);
00173
00174
00175     delete pszGuidName ;
00176     pszGuidName = NULL ;
00177   return S_OK;
00178 }
00179
00180 HRESULT CMethodSub::GetClsidOfTypeLib2 (IID * piid, UUID * puuidClsid)
00181 {
00182   WCHAR   * pszBuffIID        = 0x0;
00183   HRESULT     hr            = S_OK;
00184   WCHAR     rgBufferIid [40];
00185   WCHAR     szBufferClsid[40];
00186   RPC_STATUS    RpcStatus;
00187   WCHAR     rgBufferKey [256];
00188   long      lRetVal;
00189   HKEY      hkey;
00190   long      lcbszClsidBuff      = 40 * sizeof(WCHAR) ;
00191
00192   //-------------------------------------------------------------------------
00193   //Convert the iid to it's string form
00194   RpcStatus = UuidToString ( piid, &pszBuffIID);
00195
00196
00197   lstrcpyn(rgBufferIid, pszBuffIID, lstrlen(pszBuffIID));
00198   RpcStringFree (&pszBuffIID);
00199
00200
00201   //-------------------------------------------------------------------------
00202   //Create the Registry key to do the lookup with
00203   lstrcpyn (rgBufferKey, L"Interface\\{", sizeof("Interface\\{"));
00204   _tcsncat (rgBufferKey, rgBufferIid, _tcslen(rgBufferIid));
00205   _tcsncat (rgBufferKey, L"}\\TypeLib", sizeof(L"}\\TypeLib"));
00206
00207   //UNDONE -- gaganc Perhaps should handle the \interface<iid1>\forward<iid2|
00208   //case also.
00209
00210   //-------------------------------------------------------------------------
00211   //Open the appropriate registry key
00212   //HKEY_CLASSES_ROOT\Interface\{<...interface iid ...>}\Typelib
00213
00214   lRetVal = RegOpenKey  (
00215                 HKEY_CLASSES_ROOT,
00216                 rgBufferKey,
00217                 &hkey
00218               );
00219
00220   if (lRetVal != ERROR_SUCCESS)
00221   {
00222     return E_FAIL;
00223   }
00224
00225
00226
00227   //-------------------------------------------------------------------------
00228   //Obain the clsid from the open key
00229   lRetVal = RegQueryValueEx (
00230                   hkey,
00231                   NULL,
00232                   NULL,
00233                   NULL,
00234                   (unsigned char *)szBufferClsid,
00235                   (unsigned long *)&lcbszClsidBuff
00236                 );
00237
00238
00239     if(lRetVal != ERROR_SUCCESS)
00240     {
00241         RegCloseKey(hkey) ;
00242         return E_FAIL ;
00243     }
00244
00245
00246   //-------------------------------------------------------------------------
00247   //Get rid of the braces in the begining and the end.
00248
00249   //Remove the trailing brace
00250   szBufferClsid[37] = '\0';
00251
00252   //convert the string form of the clsid to a binary form. Plus 1 will
00253   //remove the first brace.
00254   lRetVal = UuidFromString ((szBufferClsid + 1), puuidClsid);
00255
00256     if(lRetVal != ERROR_SUCCESS)
00257     {
00258         RegCloseKey(hkey) ;
00259         return E_UNEXPECTED ;
00260     }
00261
00262   //-------------------------------------------------------------------------
00263   //Prepare to return
00264
00265   lRetVal = RegCloseKey (hkey);
00266
00267   return hr;
00268 } //end GetClsidOfTypeLib
00269
00270
00271 //----------------------------------------------------------------------------
00272 // Function:  GetMethodName (INTERNAL FUNCTION)
00273 // Description: Takes an IID and a method index returns the corresponding
00274 //              method name.
00275 //
00276 // Exceptions:  n/a
00277 // Process:
00278 // Notes:   ppszMethodName should be freed by the client using standard
00279 //        C++ delete.  If hr != S_OK, ppszMethodName will be set to
00280 //        NULL.
00281 //----------------------------------------------------------------------------
00282 HRESULT CMethodSub::GetMethodName (REFIID riid, int iMeth, _TCHAR** ppszMethodName)
00283 {
00284   BOOL      fRet    = FALSE;
00285   HRESULT     hr;
00286   UUID      uuidClsid;
00287   LCID      lcid    = 0x0;
00288   ITypeLib  * pITypeLib = 0x0;
00289   ITypeInfo * pITypeInfo  = 0x0;
00290     FUNCDESC    *   pFuncDesc   = 0x0;
00291     _TCHAR      *   pszMethod   = 0x0;
00292     BSTR            bstrName ;
00293     UINT            lcNames     = 0 ;
00294
00295     IID * piid = (IID *) &riid;
00296
00297   //Obtain the clsid of the typelib for this interface
00298   hr = GetClsidOfTypeLib2 (piid, &uuidClsid);
00299
00300   if (hr != S_OK) goto errExit ;
00301
00302   //-------------------------------------------------------------------------
00303   //Obtain the ITypeLib interface on the typelib
00304   hr = LoadRegTypeLib (
00305               uuidClsid,    //CLSID
00306               1,        //Major version number
00307               0,        //Minor version number
00308               0,      //the locale id
00309               &pITypeLib
00310             );
00311
00312   // if the default system lcid (0) doesn't work, we try
00313   // LCID 9 (standard english) and if that doesn't work, we failfast
00314   if(FAILED(hr))
00315   {
00316     hr = LoadRegTypeLib (uuidClsid, 1,0,9,&pITypeLib);
00317   }
00318
00319
00320     if(FAILED(hr)) goto errExit ;
00321
00322   hr = pITypeLib->GetTypeInfoOfGuid (*piid, &pITypeInfo);
00323
00324     if(FAILED(hr)) goto errExit ;
00325
00326   hr = pITypeInfo->GetFuncDesc(iMeth, &pFuncDesc) ;
00327
00328     if(FAILED(hr)) goto errExit ;
00329
00330     hr = pITypeInfo->GetNames(pFuncDesc->memid, &bstrName, 1, &lcNames) ;
00331
00332     if(FAILED(hr)) goto errExit ;
00333
00334     pszMethod = new _TCHAR[lstrlen(bstrName)+1] ;
00335
00336     if(! pszMethod)
00337     {
00338         hr = E_OUTOFMEMORY ;
00339         goto errExit ;
00340     }
00341
00342     lstrcpyn(pszMethod, bstrName, lstrlen(bstrName)) ;
00343
00344     SysFreeString(bstrName) ;
00345
00346 errExit:
00347
00348     if (pFuncDesc)
00349   {
00350     pITypeInfo->ReleaseFuncDesc(pFuncDesc) ;
00351   }
00352
00353
00354   if (pITypeInfo)
00355   {
00356     pITypeInfo->Release();
00357   }
00358
00359     if (pITypeLib)
00360     {
00361         pITypeLib->Release() ;
00362     }
00363
00364     *ppszMethodName = pszMethod ;
00365
00366     return hr ;
00367 }
00368
00369
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/RenderBehave/renderproject/Render.idl Source File

  • Web
  • Browser
  • RenderBehave
  • renderproject

Render.idl

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // Render.idl : IDL source for Render.dll
00006 //
00007
00008 // This file will be processed by the MIDL tool to
00009 // produce the type library (Render.tlb) and marshalling code.
00010
00011 import "oaidl.idl";
00012 import "ocidl.idl";
00013
00014   [
00015
00016     uuid(CFDD0BC0-9906-11d3-953D-0000F804E031),
00017
00018     helpstring("IFactory Interface"),
00019     pointer_default(unique)
00020   ]
00021   interface IFactory : IUnknown
00022   {
00023   };
00024   [
00025
00026     uuid(CFDD0BC1-9906-11d3-953D-0000F804E031),
00027
00028     helpstring("IBehavior Interface"),
00029     pointer_default(unique)
00030   ]
00031   interface IBehavior : IDispatch
00032   {
00033   };
00034   [
00035     object,
00036     uuid(CFDD0BC2-9906-11d3-953D-0000F804E031),
00037     dual,
00038     helpstring("IEventSink Interface"),
00039     pointer_default(unique)
00040   ]
00041   interface IEventSink : IDispatch
00042   {
00043   };
00044 [
00045   uuid(CFDD0BC3-9906-11d3-953D-0000F804E031),
00046   version(1.0),
00047   helpstring("Render 1.0 Type Library")
00048 ]
00049
00050
00051 library RENDERLib
00052 {
00053   importlib("stdole32.tlb");
00054   importlib("stdole2.tlb");
00055
00056   [
00057     uuid(CFDD0BBD-9906-11d3-953D-0000F804E031),
00058     helpstring("Factory Class")
00059   ]
00060   coclass Factory
00061   {
00062     [default] interface IFactory;
00063   };
00064   [
00065     uuid(CFDD0BBE-9906-11d3-953D-0000F804E031),
00066     helpstring("Behavior Class")
00067   ]
00068   coclass Behavior
00069   {
00070     [default] interface IBehavior;
00071   };
00072   [
00073     uuid(CFDD0BBF-9906-11d3-953D-0000F804E031),
00074     helpstring("EventSink Class")
00075   ]
00076   coclass EventSink
00077   {
00078     [default] interface IEventSink;
00079   };
00080 };
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDlgIADs Member List

This is the complete list of members for CDlgIADs, including all inherited members.
CDlgIADs(LPUNKNOWN, CWnd *pParent=NULL) | CDlgIADs |
DoDataExchange(CDataExchange *pDX) | CDlgIADs | [protected, virtual]
IDD enum value | CDlgIADs |
m_cAttrList | CDlgIADs |
m_cValueList | CDlgIADs |
m_pADs | CDlgIADs |
m_sADsPath | CDlgIADs |
m_sClass | CDlgIADs |
m_sGUID | CDlgIADs |
m_sName | CDlgIADs |
m_sParent | CDlgIADs |
m_sSchema | CDlgIADs |
OnBindGuid() | CDlgIADs | [protected]
OnCopy() | CDlgIADs | [protected]
OnDblClkAttrValue() | CDlgIADs | [protected]
OnGet() | CDlgIADs | [protected]
OnGetEx() | CDlgIADs | [protected]
OnGetInfo() | CDlgIADs | [protected]
OnGetInfoex() | CDlgIADs | [protected]
OnInitDialog() | CDlgIADs | [protected, virtual]
OnParentPath() | CDlgIADs | [protected]
OnPut() | CDlgIADs | [protected]
OnPutEx() | CDlgIADs | [protected]
OnSchemaPath() | CDlgIADs | [protected]
OnSelChangeAttrList() | CDlgIADs | [protected]
OnSetInfo() | CDlgIADs | [protected]
~CDlgIADs() | CDlgIADs |
Generated on Wed Nov 13 2024 16:56:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/Subs.c Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

Subs.c

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      SUBS.C                                                        */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #include <windows.h>
00010 #include <commctrl.h>
00011 #include <imm.h>
00012 #include "resource.h"
00013 #include "imeapps.h"
00014
00015 void MoveCompCandWindow(HWND hWnd)
00016 {
00017     RECT rc = {0};
00018     RECT rcClient = {0};
00019     int cx;
00020
00021     GetClientRect(hWnd, &rcClient);
00022
00023     GetWindowRect(hWndToolBar,&rc);
00024     ScreenToClient(hWnd,(LPPOINT)&rc.right);
00025     rcClient.top = rc.bottom;
00026
00027     GetWindowRect(hWndStatus,&rc);
00028     ScreenToClient(hWnd,(LPPOINT)&rc.left);
00029     rcClient.bottom = rc.top;
00030
00031     if (fShowCand)
00032     {
00033         if (rcClient.right >= CAND_CX * 3)
00034         {
00035             cx = rcClient.right-rcClient.left - CAND_CX;
00036         }
00037         else
00038         {
00039             cx = (rcClient.right-rcClient.left) * 2 / 3;
00040         }
00041
00042         MoveWindow(hWndCompStr,
00043                    rcClient.left,
00044                    rcClient.top,
00045                    cx,
00046                    rcClient.bottom-rcClient.top,
00047                    TRUE);
00048         MoveWindow(hWndCandList,
00049                    cx,
00050                    rcClient.top,
00051                    rcClient.right-rcClient.left - cx,
00052                    rcClient.bottom-rcClient.top,
00053                    TRUE);
00054     }
00055     else
00056     {
00057         MoveWindow(hWndCompStr,
00058                    rcClient.left,
00059                    rcClient.top,
00060                    rcClient.right-rcClient.left,
00061                    rcClient.bottom-rcClient.top,
00062                    TRUE);
00063         MoveWindow(hWndCandList, 0, 0, 0, 0, TRUE);
00064     }
00065
00066 }
00067
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

gss_buffer_desc_struct Member List

This is the complete list of members for gss_buffer_desc_struct, including all inherited members.
length | gss_buffer_desc_struct
value | gss_buffer_desc_struct
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/DUnion/DUnionc.c Source File

  • NetDS
  • RPC
  • Data
  • DUnion

DUnionc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                     Discriminated Union Example
00005
00006     FILE:       dunionc.c
00007
00008     USAGE:      dunionc  -n network_address
00009                          -p protocol_sequence
00010                          -e endpoint
00011                          -o options
00012                          -d discriminant
00013                          -v union_value
00014
00015     PURPOSE:    Client side of RPC distributed application
00016
00017     FUNCTIONS:  main() - binds to server and calls remote procedure
00018
00019     COMMENTS:   This distributed application illustrates discriminated
00020                 union.
00021
00022 ****************************************************************************/
00023
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <ctype.h>
00027 #include "dunion.h"    // header file generated by MIDL compiler
00028
00029
00030 void Usage(char * pszProgramName)
00031 {
00032     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00033     fprintf(stderr, " -p protocol_sequence\n");
00034     fprintf(stderr, " -n network_address\n");
00035     fprintf(stderr, " -e endpoint\n");
00036     fprintf(stderr, " -o options\n");
00037     fprintf(stderr, " -d discriminant\n");
00038     fprintf(stderr, " -v union_value\n");
00039     exit(1);
00040 }
00041
00042 void DisplayUnionValue(DISCRIM_UNION_PARAM_TYPE *up,
00043                        short                    sDiscrim)
00044 {
00045     printf("sDiscrim = %d, data = ", sDiscrim);
00046     switch(sDiscrim) {
00047     case 0:
00048         printf("short: %d\n", up->sVal);
00049         break;
00050     case 1:
00051         printf("float: %f\n", up->fVal);
00052         break;
00053     case 2:
00054         printf("char: %c\n", up->chVal);
00055         break;
00056     default:
00057         printf("invalid\n");
00058         break;
00059     }
00060 }
00061
00062 void __cdecl main(int argc, char **argv)
00063 {
00064     RPC_STATUS status;
00065     unsigned char * pszUuid             = NULL;
00066     unsigned char * pszProtocolSequence = "ncacn_np";
00067     unsigned char * pszNetworkAddress   = NULL;
00068     unsigned char * pszEndpoint         = "\\pipe\\dunion";
00069     unsigned char * pszOptions          = NULL;
00070     unsigned char * pszStringBinding    = NULL;
00071     int i;
00072
00073     short sDiscrim = 0;
00074     DISCRIM_UNION_PARAM_TYPE  up = {1};
00075     DISCRIM_UNION_STRUCT_TYPE us = {0, 1};
00076
00077     /* allow the user to override settings with command line switches */
00078     for (i = 1; i < argc; i++) {
00079         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00080             switch (tolower(*(argv[i]+1))) {
00081             case 'p':  // protocol sequence
00082                 pszProtocolSequence = argv[++i];
00083                 break;
00084             case 'n':  // network address
00085                 pszNetworkAddress = argv[++i];
00086                 break;
00087             case 'e':
00088                 pszEndpoint = argv[++i];
00089                 break;
00090             case 'o':
00091                 pszOptions = argv[++i];
00092                 break;
00093             case 'd':
00094                 sDiscrim = (short) atoi(argv[++i]);
00095                 if ((sDiscrim > 3) || (sDiscrim < 0))
00096                     sDiscrim = 0;
00097                 us.sDiscrim = sDiscrim;
00098                 break;
00099             case 'v':
00100                 switch(sDiscrim) {
00101                 case 0:
00102                     up.sVal =  (short) atoi(argv[++i]);
00103                     us.u.sVal = up.sVal;
00104                     break;
00105                 case 1:
00106                     up.fVal =  (float) atof(argv[++i]);
00107                     us.u.fVal = up.fVal;
00108                     break;
00109                 case 2:
00110                     up.chVal = *(argv[++i]);
00111                     us.u.chVal = up.chVal;
00112                     break;
00113                 default:
00114                     break;
00115                 }
00116                 break;
00117             case 'h':
00118             case '?':
00119             default:
00120                 Usage(argv[0]);
00121             }
00122         }
00123         else
00124             Usage(argv[0]);
00125     }
00126
00127     /* Use a convenience function to concatenate the elements of  */
00128     /* the string binding into the proper sequence.               */
00129     status = RpcStringBindingCompose(pszUuid,
00130                                      pszProtocolSequence,
00131                                      pszNetworkAddress,
00132                                      pszEndpoint,
00133                                      pszOptions,
00134                                      &pszStringBinding);
00135     printf("RpcStringBindingCompose returned 0x%x\n", status);
00136     printf("pszStringBinding = %s\n", pszStringBinding);
00137     if (status) {
00138         exit(status);
00139     }
00140
00141     /* Set the binding handle that will be used to bind to the server. */
00142     status = RpcBindingFromStringBinding(pszStringBinding,
00143                                          &hDiscrim);
00144     printf("RpcBindingFromStringBinding returned 0x%x\n", status);
00145     if (status) {
00146         exit(status);
00147     }
00148
00149     printf("Calling the remote procedure 'UnionParamProc'\n");
00150
00151     RpcTryExcept {
00152         DisplayUnionValue(&up, sDiscrim);  // display value before call
00153         UnionParamProc(&up, sDiscrim);     // call the remote procedure
00154
00155         UnionStructProc(&us);              // call the remote procedure
00156         DisplayUnionValue(&up, sDiscrim);  // display value after call
00157
00158         Shutdown();                    // Shut down the server
00159     }
00160     RpcExcept(1) {
00161         printf("Runtime reported exception %ld\n", RpcExceptionCode() );
00162     }
00163     RpcEndExcept
00164
00165     /*  The remote procedure call is complete.  Free the binding handle */
00166     status = RpcBindingFree(&hDiscrim);
00167     printf("RpcBindingFree returned 0x%x\n", status);
00168     if (status) {
00169         exit(status);
00170     }
00171
00172     exit(0);
00173
00174 }  // end main()
00175
00176
00177 /*********************************************************************/
00178 /*                 MIDL allocate and free                            */
00179 /*********************************************************************/
00180
00181 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00182 {
00183     return(malloc(len));
00184 }
00185
00186 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00187 {
00188     free(ptr);
00189 }
00190
00191 /* end file dunionc.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/StdAfx.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

StdAfx.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      StdAfx.cpp
00005 //
00006 //  Description:
00007 //
00008 //  Header File:
00009 //      StdAfx.h
00010 //
00011 //////////////////////////////////////////////////////////////////////////////
00012
00013 //////////////////////////////////////////////////////////////////////////////
00014 // Include Files
00015 /////////////////////////////////////////////////////////////////////////////
00016
00017 #include "stdafx.h"
00018
00019 #pragma warning( push, 3 )
00020
00021 #ifdef _ATL_STATIC_REGISTRY
00022 #include <statreg.h>
00023 #endif
00024
00025 #include "MyStorageResource_i.c"
00026 #pragma warning( pop )
00027
00028
00029 //////////////////////////////////////////////////////////////////////////////
00030 //++
00031 //
00032 //  HrSetInitialize
00033 //
00034 //  Description:
00035 //      Initialize the passed in object.
00036 //
00037 //  Arguments:
00038 //      punkIn
00039 //          Interface to object to initialize.
00040 //
00041 //      picccIn
00042 //          Callback interface.
00043 //
00044 //      lcidIn
00045 //          Locale ID.
00046 //
00047 //  Return Value:
00048 //      S_OK
00049 //          Success.
00050 //
00051 //      Other
00052 //          An error occurred.
00053 //
00054 //  Remarks:
00055 //      None.
00056 //
00057 //--
00058 //////////////////////////////////////////////////////////////////////////////
00059 HRESULT
00060 HrSetInitialize(
00061       IUnknown *            punkIn
00062     , IClusCfgCallback *    picccIn
00063     , LCID                  lcidIn
00064     )
00065 {
00066     assert( punkIn != NULL );
00067
00068     HRESULT                 hr;
00069     IClusCfgInitialize *    pcci = NULL;
00070     IUnknown *              punkCallback = NULL;
00071
00072     //
00073     // Make sure required arguments were specified.
00074     //
00075
00076     if ( punkIn == NULL )
00077     {
00078         hr = E_INVALIDARG;
00079         goto Cleanup;
00080     } // if:
00081
00082     //
00083     // If a callback interface was specified, get an IUnknown pointer
00084     // to pass to the specified object.
00085     //
00086
00087     if ( picccIn != NULL )
00088     {
00089         hr = picccIn->TypeSafeQI( IUnknown, &punkCallback );
00090         if ( FAILED( hr ) )
00091         {
00092             goto Cleanup;
00093         } // if:
00094     } // if: callback interface was specified
00095
00096     //
00097     // Query the object for the IClusCfgInitialize interface and call
00098     // the Initialize method if successful.
00099     //
00100
00101     hr = punkIn->TypeSafeQI( IClusCfgInitialize, &pcci );
00102     if ( SUCCEEDED( hr ) )
00103     {
00104         hr = pcci->Initialize( punkCallback, lcidIn );
00105         pcci->Release();
00106     } // if:
00107     else if ( hr == E_NOINTERFACE )
00108     {
00109         hr = S_OK;
00110     } // else if:
00111
00112 Cleanup:
00113
00114     if ( punkCallback != NULL )
00115     {
00116         punkCallback->Release();
00117     } // if:
00118
00119     return hr;
00120
00121 } //*** HrSetInitialize
00122
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CMallSpy/Test.Cxx Source File

  • Com
  • Fundamentals
  • CMallSpy

Test.Cxx

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <ole2.h>
00020 #include "cmallspy.hxx"
00021
00022 extern "C" void printf(CHAR*, ...);
00023
00024 const UINT NALLOCATIONS = 573;
00025
00026
00027 int __cdecl main(int argc, char **argv)
00028 {
00029     HRESULT     hr;
00030     LPMALLOCSPY pMallocSpy = new CMallocSpy();
00031
00032     // Initialize
00033     CoInitialize(NULL);
00034     hr = CoRegisterMallocSpy(pMallocSpy);
00035     if (hr != S_OK)
00036     {
00037         printf("CoRegisterMallocSpy failed with %x\n", hr);
00038         CoUninitialize();
00039         return 0;
00040     }
00041     printf("CoRegisterMallocSpy succeeded.\n");
00042
00043     // Allocate enoungh to force an expansion
00044     LPMALLOC pMalloc;
00045     void    *allocs[NALLOCATIONS];
00046     ULONG j;
00047
00048     if ((hr = CoGetMalloc(MEMCTX_TASK, &pMalloc)) != S_OK)
00049     {
00050         printf("CoGetMalloc failed with %x\n", hr);
00051         CoUninitialize();
00052         return 0;
00053     }
00054     printf("CoGetMalloc succeeded.\n");
00055     printf("Allocating %u memory blocks.\n", NALLOCATIONS);
00056     for (j = 0; j < NALLOCATIONS; j++)
00057     {
00058         allocs[j] = pMalloc->Alloc(173);
00059     }
00060
00061     // Now release everything
00062     printf("Releasing %u memory blocks.\n", NALLOCATIONS);
00063     for (j = 0; j < NALLOCATIONS; j++)
00064     {
00065         pMalloc->Free(allocs[j]);
00066         allocs[j] = NULL;
00067     }
00068
00069     printf("Test complete.\n");
00070     // All done
00071     CoRevokeMallocSpy();
00072     CoUninitialize();
00073     return 0;
00074 }
00075
00076
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRocket Member List

This is the complete list of members for CRocket, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CRocket | [virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CRocket | [virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CRocket | [virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CRocket | [virtual]
CRocket(CComponentData *pComponentData=NULL) | CRocket |
CRocket() | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload, CSpaceVehicle *pParent) | CRocket |
CRocket(CSpaceStation *pSpaceStation, _TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket() | CRocket |
CRocket(CSpaceStation *pSpaceStation, _TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CRocket(CComponentData *pComponentData=NULL) | CRocket |
CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
CSpaceStation | CRocket | [private]
DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CRocket | [private, static]
DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CRocket | [private, static]
DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CRocket | [private, static]
DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CRocket | [private, static]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetBitmapIndex() | CRocket | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
getDeletedStatus() | CRocket | [inline]
getDeletedStatus() | CRocket | [inline]
getDeletedStatus() | CRocket | [inline]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetDisplayName(int nCol=0) | CRocket | [virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetId() | CRocket | [inline]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
GetMenu(int nMenuId) | CRocket | [virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
getNodeType() | CRocket | [inline, virtual]
GetParent() | CRocket | [inline]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CRocket | [virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CRocket | [virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CRocket | [virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CRocket | [virtual]
HasPropertySheets() | CRocket | [virtual]
HasPropertySheets() | CRocket | [virtual]
HasPropertySheets() | CRocket | [virtual]
HasPropertySheets() | CRocket | [virtual]
IDM_PAUSE_SPACE enum value | CRocket | [private]
IDM_START_SPACE enum value | CRocket | [private]
IDM_STOP_SPACE enum value | CRocket | [private]
Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload) | CRocket |
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
isDeleted | CRocket | [private]
iStatus | CRocket | [private]
iStatus | CRocket | [private]
iStatus | CRocket | [private]
iStatus | CRocket | [private]
iStatus | CRocket | [private]
iStatus | CRocket | [private]
iStatus | CRocket | [private]
lHeight | CRocket | [private]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
lPayload | CRocket | [private]
lWeight | CRocket | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
m_pParent | CRocket | [private]
m_ppHandle | CRocket | [private]
m_pSpaceStation | CRocket | [private]
nId | CRocket | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CRocket | [virtual]
OnButtonClicked(CComponent *pComponent) | CRocket | [virtual]
OnDelete(IConsole *pConsoleComp) | CRocket | [virtual]
OnDelete(IConsole *pConsole) | CRocket | [virtual]
OnDelete(IConsole *pConsole) | CRocket | [virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CRocket | [virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CRocket | [virtual]
CDelegationBase::OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CRocket | [virtual]
OnPropertyChange(IConsole *pConsole) | CRocket | [virtual]
OnPropertyChange(IConsole *pConsole) | CRocket | [virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CRocket | [virtual]
OnRefresh(IConsole *pConsole) | CRocket | [virtual]
OnRefresh(IConsole *pConsole) | CRocket | [virtual]
CDelegationBase::OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnRename(LPOLESTR pszNewName) | CRocket | [virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CRocket | [virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CRocket | [virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CRocket | [virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CRocket | [virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CRocket | [virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CRocket | [virtual]
PAUSED enum value | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
ROCKET_STATUS enum name | CRocket | [private]
RUNNING enum value | CRocket | [private]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
setDeletedStatus(BOOL status) | CRocket | [inline]
setDeletedStatus(BOOL status) | CRocket | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CRocket | [virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
STOPPED enum value | CRocket | [private]
szName | CRocket | [private]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CRocket | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
~CRocket() | CRocket | [virtual]
Generated on Wed Nov 13 2024 16:57:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/localres.h Source File

  • SysMgmt
  • MMC
  • Nameext

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030 #define INDEX_SUN 6
00031 #define INDEX_SNOW 7
00032 #define INDEX_RAIN 8
00033 #define INDEX_CLOUD 9
00034 #define INDEX_WORLD 10
00035 #define INDEX_THUNDER 11
00036
00037
00038 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/TServer.Cpp Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

TServer.Cpp

Go to the documentation of this file.
00001 // Filename: tServer.cpp
00002 //
00003 // Description:  Implementation of DLL Exports
00004 //
00005 // This file is provided as part of the Microsoft Transaction Server Samples
00006 //
00007 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00008 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00009 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00010 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00011 // PURPOSE.
00012 //
00013 // Copyright (C) 1997 - 2000 Microsoft Corporation, All rights reserved
00014 //
00015 // Note: Proxy/Stub Information
00016 //    To merge the proxy/stub code into the object DLL, add the file
00017 //    dlldatax.c to the project.  Make sure precompiled headers
00018 //    are turned off for this file, and add _MERGE_PROXYSTUB to the
00019 //    defines for the project.
00020 //
00021 //    If you are not running WinNT4.0 or Win95 with DCOM, then you
00022 //    need to remove the following define from dlldatax.c
00023 //    #define _WIN32_WINNT 0x0500
00024 //
00025 //    Further, if you are running MIDL without /Oicf switch, you also
00026 //    need to remove the following define from dlldatax.c.
00027 //    #define USE_STUBLESS_PROXY
00028 //
00029 //    Modify the custom build rule for tServer.idl by adding the following
00030 //    files to the Outputs.
00031 //      tServer_p.c
00032 //      dlldata.c
00033 //    To build a separate proxy/stub DLL,
00034 //    run nmake -f tServerps.mk in the project directory.
00035
00036 #include "stdafx.h"
00037 #include "resource.h"
00038 #include "initguid.h"
00039 #include "tServer.h"
00040 // #include "dlldatax.h"
00041
00042 #include "tServer_i.c"
00043 #include "Computer.h"
00044 #include "Human.h"
00045
00046 #ifdef _MERGE_PROXYSTUB
00047 extern "C" HINSTANCE hProxyDll;
00048 #endif
00049
00050 CComModule _Module;
00051
00052 BEGIN_OBJECT_MAP(ObjectMap)
00053   OBJECT_ENTRY(CLSID_Human, CHuman)
00054   OBJECT_ENTRY(CLSID_Computer, CComputer)
00055 END_OBJECT_MAP()
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // DLL Entry Point
00059
00060 extern "C"
00061 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00062 {
00063   lpReserved;
00064 #ifdef _MERGE_PROXYSTUB
00065   if (!PrxDllMain(hInstance, dwReason, lpReserved))
00066     return FALSE;
00067 #endif
00068   if (dwReason == DLL_PROCESS_ATTACH)
00069   {
00070     _Module.Init(ObjectMap, hInstance);
00071     DisableThreadLibraryCalls(hInstance);
00072   }
00073   else if (dwReason == DLL_PROCESS_DETACH)
00074     _Module.Term();
00075   return TRUE;    // ok
00076 }
00077
00078 /////////////////////////////////////////////////////////////////////////////
00079 // Used to determine whether the DLL can be unloaded by OLE
00080
00081 STDAPI DllCanUnloadNow(void)
00082 {
00083 #ifdef _MERGE_PROXYSTUB
00084   if (PrxDllCanUnloadNow() != S_OK)
00085     return S_FALSE;
00086 #endif
00087   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00088 }
00089
00090 /////////////////////////////////////////////////////////////////////////////
00091 // Returns a class factory to create an object of the requested type
00092
00093 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00094 {
00095 #ifdef _MERGE_PROXYSTUB
00096   if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00097     return S_OK;
00098 #endif
00099   return _Module.GetClassObject(rclsid, riid, ppv);
00100 }
00101
00102 /////////////////////////////////////////////////////////////////////////////
00103 // DllRegisterServer - Adds entries to the system registry
00104
00105 STDAPI DllRegisterServer(void)
00106 {
00107 #ifdef _MERGE_PROXYSTUB
00108   HRESULT hRes = PrxDllRegisterServer();
00109   if (FAILED(hRes))
00110     return hRes;
00111 #endif
00112   // registers object, typelib and all interfaces in typelib
00113   return _Module.RegisterServer(TRUE);
00114 }
00115
00116 /////////////////////////////////////////////////////////////////////////////
00117 // DllUnregisterServer - Removes entries from the system registry
00118
00119 STDAPI DllUnregisterServer(void)
00120 {
00121 #ifdef _MERGE_PROXYSTUB
00122   PrxDllUnregisterServer();
00123 #endif
00124   _Module.UnregisterServer();
00125   return S_OK;
00126 }
00127
00128
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcChars.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcChars.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "ACChars.h"
00052
00053 // Dispatch interfaces referenced by this interface
00054 #include "ACChar.h"
00055 #include "ACReq.h"
00056
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // CAgentCtlCharacters properties
00060
00061 /////////////////////////////////////////////////////////////////////////////
00062 // CAgentCtlCharacters operations
00063
00064 CAgentCtlCharacterEx CAgentCtlCharacters::GetItem(LPCTSTR CharacterID)
00065 {
00066   LPDISPATCH pDispatch;
00067   static BYTE parms[] =
00068     VTS_BSTR;
00069   InvokeHelper(0x0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, parms,
00070     CharacterID);
00071   return CAgentCtlCharacterEx(pDispatch);
00072 }
00073
00074 CAgentCtlCharacterEx CAgentCtlCharacters::Character(LPCTSTR CharacterID)
00075 {
00076   LPDISPATCH pDispatch;
00077   static BYTE parms[] =
00078     VTS_BSTR;
00079   InvokeHelper(0x3, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00080     CharacterID);
00081   return CAgentCtlCharacterEx(pDispatch);
00082 }
00083
00084 void CAgentCtlCharacters::Unload(LPCTSTR CharacterID)
00085 {
00086   static BYTE parms[] =
00087     VTS_BSTR;
00088   InvokeHelper(0x2, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
00089      CharacterID);
00090 }
00091
00092 CAgentCtlRequest CAgentCtlCharacters::Load(LPCTSTR CharacterID, const VARIANT& LoadKey)
00093 {
00094   LPDISPATCH pDispatch;
00095   static BYTE parms[] =
00096     VTS_BSTR VTS_VARIANT;
00097   InvokeHelper(0x1, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00098     CharacterID, &LoadKey);
00099   return CAgentCtlRequest(pDispatch);
00100 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Sample::MySignedXml Member List

This is the complete list of members for Sample::MySignedXml, including all inherited members.
ConvertIntToByteArray(uint dwInput) | Sample::MySignedXml | [inline, private, static]
GetPublicKey() | Sample::MySignedXml | [inline, protected]
ImportPublicKeyBlob(byte[] rgbPubKeyBlob, int cbPubKeyBlob, out uint pExponent, out IntPtrppbModulus, out uint pModulusSize) | Sample::MySignedXml | [private]
m_keyInfoEnum | Sample::MySignedXml | [private]
MySignedXml() | Sample::MySignedXml | [inline]
MySignedXml(XmlDocument document) | Sample::MySignedXml | [inline]
PublicKeyBlobFromCertificateRawData(byte[] rgbRawData, int cbRawData, out IntPtrppbKeyBlob, out uint pKeyBlobSize) | Sample::MySignedXml | [private]
UnmanagedArrayFree(IntPtr ppbKeyBlob) | Sample::MySignedXml | [private]
Generated on Wed Nov 13 2024 16:58:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/CMgdClusCfgInit.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

CMgdClusCfgInit.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      CMgdClusCfgInit.cpp
00005 //
00006 //  Description:
00007 //      Implementation of the CMgdClusCfgInit class.
00008 //
00009 //  Header File:
00010 //      CMgdClusCfgInit.h
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 //////////////////////////////////////////////////////////////////////////////
00015 // Include Files
00016 //////////////////////////////////////////////////////////////////////////////
00017
00018 #include "stdafx.h"
00019 #include "CMgdClusCfgInit.h"
00020
00021
00022 //////////////////////////////////////////////////////////////////////////////
00023 // CMgdClusCfgInit class
00024 //////////////////////////////////////////////////////////////////////////////
00025
00026
00027 //////////////////////////////////////////////////////////////////////////////
00028 //++
00029 //
00030 //  CMgdClusCfgInit::CMgdClusCfgInit
00031 //
00032 //  Description:
00033 //      Constructor. Sets all member variables to default values.
00034 //
00035 //  Arguments:
00036 //      None.
00037 //
00038 //  Return Value:
00039 //      None.
00040 //
00041 //--
00042 //////////////////////////////////////////////////////////////////////////////
00043 CMgdClusCfgInit::CMgdClusCfgInit( void )
00044 {
00045     m_picccCallback = NULL;
00046     m_lcid = GetUserDefaultLCID();
00047
00048     m_bstrNodeName = NULL;
00049     m_bstrDllName = NULL;
00050     m_bstrResTypeName = NULL;
00051     m_bstrDisplayName = NULL;
00052
00053 } //*** CMgdClusCfgInit::CMgdClusCfgInit
00054
00055
00056 //////////////////////////////////////////////////////////////////////////////
00057 //++
00058 //
00059 //  CMgdClusCfgInit::~CMgdClusCfgInit
00060 //
00061 //  Description:
00062 //      Destructor. Frees all previously allocated memory and releases all
00063 //      interface pointers.
00064 //
00065 //  Arguments:
00066 //      None.
00067 //
00068 //  Return Value:
00069 //      None.
00070 //
00071 //--
00072 //////////////////////////////////////////////////////////////////////////////
00073 CMgdClusCfgInit::~CMgdClusCfgInit( void )
00074 {
00075     if ( m_picccCallback != NULL )
00076     {
00077         m_picccCallback->Release();
00078         m_picccCallback = NULL;
00079     } // if: m_picccCallback was used
00080
00081     SysFreeString( m_bstrNodeName );
00082     SysFreeString( m_bstrDllName );
00083     SysFreeString( m_bstrResTypeName );
00084     SysFreeString( m_bstrDisplayName );
00085
00086 } //*** CMgdClusCfgInit::~CMgdClusCfgInit
00087
00088
00089 //////////////////////////////////////////////////////////////////////////////
00090 //++
00091 //
00092 //  CMgdClusCfgInit::Initialize
00093 //
00094 //  Description:
00095 //      Initialize this component.
00096 //
00097 //  Arguments:
00098 //      punkCallbackIn
00099 //          Interface on which to query for the IClusCfgCallback interface.
00100 //
00101 //      lcidIn
00102 //          Locale ID.
00103 //
00104 //  Return Value:
00105 //      S_OK
00106 //          Success.
00107 //
00108 //      E_POINTER
00109 //          Expected pointer argument specified as NULL.
00110 //
00111 //      E_OUTOFMEMORY
00112 //          Out of memory.
00113 //
00114 //      Other HRESULTs
00115 //          Failure.
00116 //
00117 //--
00118 //////////////////////////////////////////////////////////////////////////////
00119 STDMETHODIMP
00120 CMgdClusCfgInit::Initialize(
00121       IUnknown *    punkCallbackIn
00122     , LCID          lcidIn
00123     )
00124 {
00125     HRESULT hr = S_OK;
00126     WCHAR   szComputerName[ MAX_PATH ];
00127     DWORD   cchComputerName = MAX_PATH;
00128     DWORD   dwError = ERROR_SUCCESS;
00129
00130     m_lcid = lcidIn;
00131
00132     if ( punkCallbackIn == NULL )
00133     {
00134         hr = E_POINTER;
00135         goto Cleanup;
00136     } // if: Callback pointer is invalid (NULL)
00137
00138     //
00139     // Save the callback interface pointer.
00140     //
00141
00142     hr = punkCallbackIn->TypeSafeQI( IClusCfgCallback, &m_picccCallback );
00143     if ( FAILED( hr ) )
00144     {
00145         goto Cleanup;
00146     } // if: TypeSafeQI failed
00147
00148     //
00149     // Save the computer name for use by SendStatusReport.
00150     //
00151
00152     if ( GetComputerNameEx( ComputerNamePhysicalDnsHostname, szComputerName, &cchComputerName ) == 0 )
00153     {
00154         dwError = GetLastError();
00155         hr = HRESULT_FROM_WIN32( dwError );
00156
00157         HrSendStatusReport(
00158               TASKID_Major_Find_Devices
00159             , TASKID_Minor_StorageResourceInitialize
00160             , 1
00161             , 1
00162             , 1
00163             , hr
00164             , IDS_ERROR_GETCOMPUTERNAME_FAILED
00165             , 0
00166             );
00167         goto Cleanup;
00168     } // if: GetComputerName failed
00169
00170     m_bstrNodeName = SysAllocString( szComputerName );
00171     if ( m_bstrNodeName == NULL )
00172     {
00173         hr = E_OUTOFMEMORY;
00174         goto Cleanup;
00175     } // if:
00176
00177     //
00178     // Get the dll name.
00179     //
00180
00181     m_bstrDllName = SysAllocString( RESTYPE_DLL_NAME );
00182     if ( m_bstrDllName == NULL )
00183     {
00184         hr = E_OUTOFMEMORY;
00185         goto Cleanup;
00186     } // if:
00187
00188     //
00189     // Get the resource type name.
00190     //
00191
00192     m_bstrResTypeName = SysAllocString( RESTYPE_NAME );
00193     if ( m_bstrResTypeName == NULL )
00194     {
00195         hr = E_OUTOFMEMORY;
00196         goto Cleanup;
00197     } // if:
00198
00199     //
00200     // Load the resource type display name.
00201     //
00202
00203     //
00204     // NOTE:    The resource type display name should be localized, but the resource type
00205     //          name should always remain the same.
00206     //
00207
00208     hr = HrLoadStringIntoBSTR( _Module.m_hInstResource, IDS_RESTYPE_DISPLAYNAME, &m_bstrDisplayName );
00209     if ( FAILED( hr ) )
00210     {
00211         goto Cleanup;
00212     } // if:
00213
00214 Cleanup:
00215
00216     return hr;
00217
00218 } //*** CMgdClusCfgInit::Initialize
00219
00220
00221 //////////////////////////////////////////////////////////////////////////////
00222 //++
00223 //
00224 //  CMgdClusCfgInit::HrSendStatusReport
00225 //
00226 //  Description:
00227 //      Wraps IClusCfgCallback::SendStatusReport.
00228 //
00229 //  Arguments:
00230 //       clsidTaskMajorIn
00231 //       clsidTaskMinorIn
00232 //       ulMinIn
00233 //       ulMaxIn
00234 //       ulCurrentIn
00235 //       hrStatusIn
00236 //       idsDescriptionIn
00237 //       idsReferenceIn
00238 //
00239 //  Return Value:
00240 //      S_OK
00241 //          Success.
00242 //
00243 //      Other HRESULTs
00244 //          Failure.
00245 //
00246 //--
00247 //////////////////////////////////////////////////////////////////////////////
00248 STDMETHODIMP
00249 CMgdClusCfgInit::HrSendStatusReport(
00250       CLSID     clsidTaskMajorIn
00251     , CLSID     clsidTaskMinorIn
00252     , ULONG     ulMinIn
00253     , ULONG     ulMaxIn
00254     , ULONG     ulCurrentIn
00255     , HRESULT   hrStatusIn
00256     , UINT      idsDescriptionIn
00257     , UINT      idsReferenceIn
00258     ...
00259     )
00260 {
00261     HRESULT     hr = S_OK;
00262     BSTR        bstrDescription = NULL;
00263     BSTR        bstrReference = NULL;
00264     va_list     valist = NULL;
00265
00266     va_start( valist, idsReferenceIn );
00267     hr = HrFormatStringWithVAListIntoBSTR( _Module.m_hInstResource, idsDescriptionIn, &bstrDescription, valist );
00268     va_end( valist );
00269     if ( FAILED( hr ) )
00270     {
00271         goto Cleanup;
00272     } // if:
00273
00274     if ( idsReferenceIn != 0 )
00275     {
00276         hr = HrLoadStringIntoBSTR( _Module.m_hInstResource, idsReferenceIn, &bstrReference );
00277         if ( FAILED( hr ) )
00278         {
00279             goto Cleanup;
00280         } // if:
00281     } // if: valid reference string
00282
00283     hr = SendStatusReport(
00284               clsidTaskMajorIn
00285             , clsidTaskMinorIn
00286             , ulMinIn
00287             , ulMaxIn
00288             , ulCurrentIn
00289             , hrStatusIn
00290             , bstrDescription
00291             , bstrReference
00292             );
00293     if ( FAILED( hr ) )
00294     {
00295         goto Cleanup;
00296     } // if:
00297
00298 Cleanup:
00299
00300     SysFreeString( bstrDescription );
00301     SysFreeString( bstrReference );
00302
00303     return hr;
00304
00305 } //*** CMgdClusCfgInit::HrSendStatusReport
00306
00307
00308 //////////////////////////////////////////////////////////////////////////////
00309 //++
00310 //
00311 //  CMgdClusCfgInit::HrSendStatusReport
00312 //
00313 //  Description:
00314 //      Wraps IClusCfgCallback::SendStatusReport.
00315 //
00316 //  Arguments:
00317 //       clsidTaskMajorIn
00318 //       clsidTaskMinorIn
00319 //       ulMinIn
00320 //       ulMaxIn
00321 //       ulCurrentIn
00322 //       hrStatusIn
00323 //       pcszDescriptionIn
00324 //       idsReferenceIn
00325 //       ...        optional parameters for pcszDescriptionIn
00326 //
00327 //  Return Value:
00328 //      S_OK
00329 //          Success.
00330 //
00331 //      Other HRESULTs
00332 //          Failure.
00333 //
00334 //--
00335 //////////////////////////////////////////////////////////////////////////////
00336 STDMETHODIMP
00337 CMgdClusCfgInit::HrSendStatusReport(
00338       CLSID     clsidTaskMajorIn
00339     , CLSID     clsidTaskMinorIn
00340     , ULONG     ulMinIn
00341     , ULONG     ulMaxIn
00342     , ULONG     ulCurrentIn
00343     , HRESULT   hrStatusIn
00344     , LPCWSTR   pcszDescriptionIn
00345     , UINT      idsReferenceIn
00346     ...
00347     )
00348 {
00349     HRESULT     hr = S_OK;
00350     BSTR        bstrDescription = NULL;
00351     BSTR        bstrReference = NULL;
00352     va_list     valist = NULL;
00353
00354     va_start( valist, idsReferenceIn );
00355     hr = HrFormatStringWithVAListIntoBSTR( pcszDescriptionIn, &bstrDescription, valist );
00356     va_end( valist );
00357     if ( FAILED( hr ) )
00358     {
00359         goto Cleanup;
00360     } // if:
00361
00362     if ( idsReferenceIn != 0 )
00363     {
00364         hr = HrLoadStringIntoBSTR( _Module.m_hInstResource, idsReferenceIn, &bstrReference );
00365         if ( FAILED( hr ) )
00366         {
00367             goto Cleanup;
00368         } // if:
00369     } // if: valid reference string
00370
00371     hr = SendStatusReport(
00372               clsidTaskMajorIn
00373             , clsidTaskMinorIn
00374             , ulMinIn
00375             , ulMaxIn
00376             , ulCurrentIn
00377             , hrStatusIn
00378             , bstrDescription
00379             , bstrReference
00380             );
00381     if ( FAILED( hr ) )
00382     {
00383         goto Cleanup;
00384     } // if:
00385
00386 Cleanup:
00387
00388     SysFreeString( bstrDescription );
00389     SysFreeString( bstrReference );
00390
00391     return hr;
00392
00393 } //*** CMgdClusCfgInit::HrSendStatusReport
00394
00395
00396 //////////////////////////////////////////////////////////////////////////////
00397 //++
00398 //
00399 //  CMgdClusCfgInit::HrSendStatusReport
00400 //
00401 //  Description:
00402 //      Wraps IClusCfgCallback::SendStatusReport.
00403 //
00404 //  Arguments:
00405 //       clsidTaskMajorIn
00406 //       clsidTaskMinorIn
00407 //       ulMinIn
00408 //       ulMaxIn
00409 //       ulCurrentIn
00410 //       hrStatusIn
00411 //       pcszDescriptionIn
00412 //       pcszReferenceIn
00413 //
00414 //  Return Value:
00415 //      S_OK
00416 //          Success.
00417 //
00418 //      Other HRESULTs
00419 //          Failure.
00420 //
00421 //--
00422 //////////////////////////////////////////////////////////////////////////////
00423 STDMETHODIMP
00424 CMgdClusCfgInit::HrSendStatusReport(
00425       CLSID      clsidTaskMajorIn
00426     , CLSID      clsidTaskMinorIn
00427     , ULONG      ulMinIn
00428     , ULONG      ulMaxIn
00429     , ULONG      ulCurrentIn
00430     , HRESULT    hrStatusIn
00431     , LPCWSTR    pcszDescriptionIn
00432     , LPCWSTR    pcszReferenceIn
00433     ...
00434     )
00435 {
00436     HRESULT     hr = S_OK;
00437     BSTR        bstrDescription = NULL;
00438     va_list     valist = NULL;
00439
00440     va_start( valist, pcszReferenceIn );
00441     hr = HrFormatStringWithVAListIntoBSTR( pcszDescriptionIn, &bstrDescription, valist );
00442     va_end( valist );
00443     if ( FAILED( hr ) )
00444     {
00445         goto Cleanup;
00446     } // if:
00447
00448     hr = SendStatusReport(
00449               clsidTaskMajorIn
00450             , clsidTaskMinorIn
00451             , ulMinIn
00452             , ulMaxIn
00453             , ulCurrentIn
00454             , hrStatusIn
00455             , bstrDescription
00456             , pcszReferenceIn
00457             );
00458     if ( FAILED( hr ) )
00459     {
00460         goto Cleanup;
00461     } // if:
00462
00463 Cleanup:
00464
00465     SysFreeString( bstrDescription );
00466
00467     return hr;
00468
00469 } //*** CMgdClusCfgInit::HrSendStatusReport
00470
00471
00472 //////////////////////////////////////////////////////////////////////////////
00473 //++
00474 //
00475 //  CMgdClusCfgInit::SendStatusReport
00476 //
00477 //  Description:
00478 //      Wraps IClusCfgCallback::SendStatusReport.
00479 //
00480 //  Arguments:
00481 //       clsidTaskMajorIn
00482 //       clsidTaskMinorIn
00483 //       ulMinIn
00484 //       ulMaxIn
00485 //       ulCurrentIn
00486 //       hrStatusIn
00487 //       pcszDescriptionIn
00488 //       pcszReferenceIn
00489 //
00490 //  Return Value:
00491 //      S_OK
00492 //          Success.
00493 //
00494 //      Other HRESULTs
00495 //          Failure.
00496 //
00497 //--
00498 //////////////////////////////////////////////////////////////////////////////
00499 STDMETHODIMP
00500 CMgdClusCfgInit::SendStatusReport(
00501       CLSID     clsidTaskMajorIn
00502     , CLSID     clsidTaskMinorIn
00503     , ULONG     ulMinIn
00504     , ULONG     ulMaxIn
00505     , ULONG     ulCurrentIn
00506     , HRESULT   hrStatusIn
00507     , LPCWSTR   pcszDescriptionIn
00508     , LPCWSTR   pcszReferenceIn
00509     )
00510 {
00511     HRESULT     hr = S_OK;
00512     FILETIME    ftTime;
00513
00514     assert( m_picccCallback != NULL );
00515     assert( m_bstrNodeName != NULL );
00516
00517     GetSystemTimeAsFileTime( &ftTime );
00518
00519     if ( m_picccCallback != NULL )
00520     {
00521         hr = m_picccCallback->SendStatusReport(
00522                   m_bstrNodeName
00523                 , clsidTaskMajorIn
00524                 , clsidTaskMinorIn
00525                 , ulMinIn
00526                 , ulMaxIn
00527                 , ulCurrentIn
00528                 , hrStatusIn
00529                 , pcszDescriptionIn
00530                 , &ftTime
00531                 , pcszReferenceIn
00532                 );
00533         if ( FAILED( hr ) )
00534         {
00535             goto Cleanup;
00536         } // if:
00537     } // if: m_picccCallback != NULL
00538
00539 Cleanup:
00540
00541     return hr;
00542
00543 } //*** CMgdClusCfgInit::SendStatusReport
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/ioips.Cpp Source File

  • Com
  • Fundamentals
  • SimpCntr

ioips.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOIPS.CPP
00003 //
00004 //      Implementation file for COleInPlaceSite
00005 //
00006 // Functions:
00007 //
00008 //      See IOIPS.H for class Definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "ioipf.h"
00017 #include "ioips.h"
00018 #include "app.h"
00019 #include "site.h"
00020 #include "doc.h"
00021
00022 //**********************************************************************
00023 //
00024 // CSimpleSite::COleInPlaceSite::QueryInterface
00025 //
00026 // Purpose:
00027 //
00028 //      Used for interface negotiation at the interface level.
00029 //
00030 // Parameters:
00031 //
00032 //      REFIID riid         -   A reference to the interface that is
00033 //                              being queried.
00034 //
00035 //      LPVOID FAR* ppvObj  -   An out parameter to return a pointer to
00036 //                              the interface.
00037 //
00038 // Return Value:
00039 //
00040 //      S_OK    -   The interface is supported.
00041 //      S_FALSE -   The interface is not supported
00042 //
00043 // Function Calls:
00044 //      Function                    Location
00045 //
00046 //      OutputDebugString           Windows API
00047 //      CSimpleSite::QueryInterface SITE.CPP
00048 //
00049 // Comments:
00050 //
00051 //********************************************************************
00052
00053 STDMETHODIMP COleInPlaceSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00054 {
00055         OutputDebugString("In IOIPS::QueryInterface\r\n");
00056         CStabilize stabilize(m_pSite);
00057
00058         // delegate to the container Site
00059         return m_pSite->QueryInterface(riid, ppvObj);
00060 }
00061
00062 //**********************************************************************
00063 //
00064 // CSimpleSite::COleInPlaceSite::AddRef
00065 //
00066 // Purpose:
00067 //
00068 //      Adds to the reference count at the interface level.
00069 //
00070 // Parameters:
00071 //
00072 //      None
00073 //
00074 // Return Value:
00075 //
00076 //      ULONG   -   The new reference count of the interface.
00077 //
00078 // Function Calls:
00079 //      Function                    Location
00080 //
00081 //      OutputDebugString           Windows API
00082 //
00083 // Comments:
00084 //
00085 //********************************************************************
00086
00087 STDMETHODIMP_(ULONG) COleInPlaceSite::AddRef()
00088 {
00089         OutputDebugString("In IOIPS::AddRef\r\n");
00090
00091         // increment the interface reference count (for debugging only)
00092         ++m_nCount;
00093
00094         // delegate to the container Site
00095         return m_pSite->AddRef();
00096 }
00097
00098 //**********************************************************************
00099 //
00100 // CSimpleSite::COleInPlaceSite::Release
00101 //
00102 // Purpose:
00103 //
00104 //      Decrements the reference count at this level
00105 //
00106 // Parameters:
00107 //
00108 //      None
00109 //
00110 // Return Value:
00111 //
00112 //      ULONG   -   The new reference count of the interface.
00113 //
00114 // Function Calls:
00115 //      Function                    Location
00116 //
00117 //      OutputDebugString           Windows API
00118 //      CSimpleSite::Release        SITE.CPP
00119 //
00120 // Comments:
00121 //
00122 //********************************************************************
00123
00124 STDMETHODIMP_(ULONG) COleInPlaceSite::Release()
00125 {
00126         OutputDebugString("In IOIPS::Release\r\n");
00127         // decrement the interface reference count (for debugging only)
00128         m_nCount--;
00129
00130         // delegate to the container Site
00131         return m_pSite->Release();
00132 }
00133
00134 //**********************************************************************
00135 //
00136 // COleInPlaceSite::GetWindow
00137 //
00138 // Purpose:
00139 //
00140 //      Returns the Window Handle of the client site
00141 //
00142 // Parameters:
00143 //
00144 //      HWND FAR* lphwnd    - place to return the handle
00145 //
00146 // Return Value:
00147 //
00148 //      S_OK
00149 //
00150 // Function Calls:
00151 //      Function                    Location
00152 //
00153 //      OutputDebugString           Windows API
00154 //                   OLE API
00155 //
00156 // Comments:
00157 //
00158 //********************************************************************
00159
00160 STDMETHODIMP COleInPlaceSite::GetWindow (HWND FAR* lphwnd)
00161 {
00162         OutputDebugString("In IOIPS::GetWindow\r\n");
00163         CStabilize stabilize(m_pSite);
00164
00165         // return the handle to our editing window.
00166         *lphwnd = m_pSite->m_lpDoc->m_hDocWnd;
00167
00168         return S_OK;
00169 }
00170
00171 //**********************************************************************
00172 //
00173 // COleInPlaceSite::ContextSensitiveHelp
00174 //
00175 // Purpose:
00176 //
00177 //
00178 // Parameters:
00179 //
00180 //      BOOL fEnterMode - TRUE for entering Context Sensitive help mode
00181 //
00182 // Return Value:
00183 //
00184 //      S_OK
00185 //
00186 // Function Calls:
00187 //      Function                    Location
00188 //
00189 //      OutputDebugString           Windows API
00190 //                   OLE API
00191 //
00192 // Comments:
00193 //
00194 //      Be sure to read the technotes included with the OLE toolkit.
00195 //
00196 //********************************************************************
00197
00198 STDMETHODIMP COleInPlaceSite::ContextSensitiveHelp (BOOL fEnterMode)
00199 {
00200         OutputDebugString("In IOIPS::ContextSensitiveHelp\r\n");
00201
00202         if (m_pSite->m_lpDoc->m_lpApp->m_fCSHMode != fEnterMode)
00203                 m_pSite->m_lpDoc->m_lpApp->m_fCSHMode = fEnterMode;
00204
00205         return S_OK;
00206 }
00207
00208 //**********************************************************************
00209 //
00210 // COleInPlaceSite::CanInPlaceActivate
00211 //
00212 // Purpose:
00213 //
00214 //      Object calls to find out if the container can InPlace activate
00215 //
00216 // Parameters:
00217 //
00218 //      None
00219 //
00220 // Return Value:
00221 //
00222 //      S_OK
00223 //
00224 // Function Calls:
00225 //      Function                    Location
00226 //
00227 //      OutputDebugString           Windows API
00228 //                   OLE API
00229 //
00230 // Comments:
00231 //
00232 //********************************************************************
00233
00234 STDMETHODIMP COleInPlaceSite::CanInPlaceActivate ()
00235 {
00236         OutputDebugString("In IOIPS::CanInPlaceActivate\r\n");
00237
00238         // return S_OK to indicate we can in-place activate
00239         return S_OK;
00240 }
00241
00242 //**********************************************************************
00243 //
00244 // COleInPlaceSite::OnInPlaceActivate
00245 //
00246 // Purpose:
00247 //
00248 //      Called by the object on InPlace Activation
00249 //
00250 // Parameters:
00251 //
00252 //      None
00253 //
00254 // Return Value:
00255 //
00256 //      S_OK
00257 //
00258 // Function Calls:
00259 //      Function                    Location
00260 //
00261 //      OutputDebugString           Windows API
00262 //                   OLE API
00263 //
00264 // Comments:
00265 //
00266 //********************************************************************
00267
00268 STDMETHODIMP COleInPlaceSite::OnInPlaceActivate ()
00269 {
00270         HRESULT hrErr;
00271         OutputDebugString("In IOIPS::OnInPlaceActivate\r\n");
00272         CStabilize stabilize(m_pSite);
00273
00274         hrErr = m_pSite->m_lpOleObject->QueryInterface(
00275                         IID_IOleInPlaceObject, (LPVOID FAR *)&m_pSite->m_lpInPlaceObject);
00276         if (hrErr != NOERROR)
00277                 return E_FAIL;
00278
00279         // return S_OK to indicate we can in-place activate.
00280         return S_OK;
00281 }
00282
00283 //**********************************************************************
00284 //
00285 // COleInPlaceSite::OnUIActivate
00286 //
00287 // Purpose:
00288 //
00289 //      Object calls this method when it displays it's UI.
00290 //
00291 // Parameters:
00292 //
00293 //      None.
00294 //
00295 // Return Value:
00296 //
00297 //      S_OK
00298 //
00299 // Function Calls:
00300 //      Function                    Location
00301 //
00302 //      OutputDebugString           Windows API
00303 //                   OLE API
00304 //
00305 // Comments:
00306 //
00307 //********************************************************************
00308
00309 STDMETHODIMP COleInPlaceSite::OnUIActivate ()
00310 {
00311         OutputDebugString("In IOIPS::OnUIActivate\r\n");
00312
00313         m_pSite->m_lpDoc->m_fAddMyUI=FALSE;
00314         m_pSite->m_lpDoc->m_fInPlaceActive = TRUE;
00315         m_pSite->m_fInPlaceActive = TRUE;
00316
00317         m_pSite->m_lpInPlaceObject->GetWindow((HWND FAR*)&m_pSite->m_hwndIPObj);
00318
00319         // return S_OK to continue in-place activation
00320         return S_OK;
00321 }
00322
00323 //**********************************************************************
00324 //
00325 // COleInPlaceSite::GetWindowContext
00326 //
00327 // Purpose:
00328 //
00329 //      Called by the object to get information for InPlace Negotiation.
00330 //
00331 // Parameters:
00332 //
00333 //      LPOLEINPLACEFRAME FAR* lplpFrame    - Location to return a pointer
00334 //                                            to IOleInPlaceFrame.
00335 //
00336 //      LPOLEINPLACEUIWINDOW FAR* lplpDoc   - Location to return a pointer
00337 //                                            to IOleInPlaceUIWindow.
00338 //
00339 //      LPRECT lprcPosRect                  - The rect that the object
00340 //                                            occupies
00341 //
00342 //      LPRECT lprcClipRect                 - The clipping rect
00343 //
00344 //      LPOLEINPLACEFRAMEINFO lpFrameInfo   - Pointer to FRAMEINFO
00345 //
00346 //
00347 // Return Value:
00348 //
00349 //      S_OK
00350 //
00351 // Function Calls:
00352 //      Function                    Location
00353 //
00354 //      COleInPlaceFrame::AddRef    IOIPF.CPP
00355 //      CSimpleSite::GetObjRect     SITE.CPP
00356 //      OutputDebugString           Windows API
00357 //      SetMapMode                  Windows API
00358 //      GetDC                       Windows API
00359 //      ReleaseDC                   Windows API
00360 //      CopyRect                    Windows API
00361 //      GetClientRect               Windows API
00362 //                   OLE API
00363 //
00364 // Comments:
00365 //
00366 //********************************************************************
00367
00368 STDMETHODIMP COleInPlaceSite::GetWindowContext (LPOLEINPLACEFRAME FAR* lplpFrame,
00369                                                            LPOLEINPLACEUIWINDOW FAR* lplpDoc,
00370                                                            LPRECT lprcPosRect,
00371                                                            LPRECT lprcClipRect,
00372                                                            LPOLEINPLACEFRAMEINFO lpFrameInfo)
00373 {
00374         RECT rect;
00375         CStabilize stabilize(m_pSite);
00376
00377         OutputDebugString("In IOIPS::GetWindowContext\r\n");
00378
00379         // the frame is associated with the application object.
00380         // need to AddRef() it...
00381         m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame.AddRef();
00382         *lplpFrame = &m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame;
00383         *lplpDoc = NULL;  // must be NULL, cause we're SDI.
00384
00385         // get the size of the object in pixels
00386         m_pSite->GetObjRect(&rect);
00387
00388         // Copy this to the passed buffer
00389         CopyRect(lprcPosRect, &rect);
00390
00391         // fill the clipping region
00392         GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
00393         CopyRect(lprcClipRect, &rect);
00394
00395         // fill the FRAMEINFO
00396         lpFrameInfo->fMDIApp = FALSE;
00397         lpFrameInfo->hwndFrame = m_pSite->m_lpDoc->m_lpApp->m_hAppWnd;
00398         lpFrameInfo->haccel = NULL;
00399         lpFrameInfo->cAccelEntries = 0;
00400
00401         return S_OK;
00402 }
00403
00404 //**********************************************************************
00405 //
00406 // COleInPlaceSite::Scroll
00407 //
00408 // Purpose:
00409 //
00410 //      Not Implemented
00411 //
00412 // Parameters:
00413 //
00414 //      Not Implemented
00415 //
00416 // Return Value:
00417 //
00418 //      Not Implemented
00419 //
00420 // Function Calls:
00421 //      Function                    Location
00422 //
00423 //      OutputDebugString           Windows API
00424 //
00425 // Comments:
00426 //
00427 //      Not Implemented
00428 //
00429 //********************************************************************
00430
00431 STDMETHODIMP COleInPlaceSite::Scroll (SIZE scrollExtent)
00432 {
00433         OutputDebugString("In IOIPS::Scroll\r\n");
00434         return E_FAIL;
00435 }
00436
00437 //**********************************************************************
00438 //
00439 // COleInPlaceSite::OnUIDeactivate
00440 //
00441 // Purpose:
00442 //
00443 //      Called by the object when its UI goes away
00444 //
00445 // Parameters:
00446 //
00447 //       BOOL fUndoable
00448 //
00449 // Return Value:
00450 //
00451 //      S_OK
00452 //
00453 // Function Calls:
00454 //      Function                    Location
00455 //
00456 //      OutputDebugString           Windows API
00457 //      CSimpleAPP::AddFrameLevelUI APP.CPP
00458 //                   OLE API
00459 //
00460 // Comments:
00461 //
00462 //********************************************************************
00463
00464 STDMETHODIMP COleInPlaceSite::OnUIDeactivate (BOOL fUndoable)
00465 {
00466         OutputDebugString("In IOIPS::OnUIDeactivate\r\n");
00467         CStabilize stabilize(m_pSite);
00468
00469         // need to clear this flag first
00470         m_pSite->m_lpDoc->m_fInPlaceActive = FALSE;
00471         m_pSite->m_fInPlaceActive = FALSE;
00472
00473         m_pSite->m_lpDoc->m_lpApp->QueryNewPalette();
00474         m_pSite->m_lpDoc->m_lpApp->AddFrameLevelUI();
00475         return S_OK;
00476 }
00477
00478 //**********************************************************************
00479 //
00480 // COleInPlaceSite::OnInPlaceDeactivate
00481 //
00482 // Purpose:
00483 //
00484 //      Called when the inplace session is over
00485 //
00486 // Parameters:
00487 //
00488 //      None
00489 //
00490 // Return Value:
00491 //
00492 //      S_OK
00493 //
00494 // Function Calls:
00495 //      Function                    Location
00496 //
00497 //      OutputDebugString           Windows API
00498 //                   OLE API
00499 //
00500 // Comments:
00501 //
00502 //********************************************************************
00503
00504 STDMETHODIMP COleInPlaceSite::OnInPlaceDeactivate ()
00505 {
00506         OutputDebugString("In IOIPS::OnInPlaceDeactivate\r\n");
00507
00508         if (m_pSite->m_lpInPlaceObject) {
00509                 m_pSite->m_lpInPlaceObject->Release();
00510                 m_pSite->m_lpInPlaceObject = NULL;
00511         }
00512         return S_OK;
00513 }
00514
00515 //**********************************************************************
00516 //
00517 // COleInPlaceSite::DiscardUndoState
00518 //
00519 // Purpose:
00520 //
00521 //      Not Implemented
00522 //
00523 // Parameters:
00524 //
00525 //      Not Implemented
00526 //
00527 // Return Value:
00528 //
00529 //      Not Implemented
00530 //
00531 // Function Calls:
00532 //      Function                    Location
00533 //
00534 //      OutputDebugString           Windows API
00535 //
00536 // Comments:
00537 //
00538 //      Not Implemented
00539 //
00540 //********************************************************************
00541
00542 STDMETHODIMP COleInPlaceSite::DiscardUndoState ()
00543 {
00544         OutputDebugString("In IOIPS::DiscardUndoState\r\n");
00545         return E_FAIL;
00546 }
00547
00548 //**********************************************************************
00549 //
00550 // COleInPlaceSite::DeactivateAndUndo
00551 //
00552 // Purpose:
00553 //
00554 //      Not Implemented
00555 //
00556 // Parameters:
00557 //
00558 //      Not Implemented
00559 //
00560 // Return Value:
00561 //
00562 //      Not Implemented
00563 //
00564 // Function Calls:
00565 //      Function                    Location
00566 //
00567 //      OutputDebugString           Windows API
00568 //
00569 // Comments:
00570 //
00571 //      Not Implemented
00572 //
00573 //********************************************************************
00574
00575 STDMETHODIMP COleInPlaceSite::DeactivateAndUndo ()
00576 {
00577         OutputDebugString("In IOIPS::DeactivateAndUndo\r\n");
00578         return E_FAIL;
00579 }
00580
00581 //**********************************************************************
00582 //
00583 // COleInPlaceSite::OnPosRectChange
00584 //
00585 // Purpose:
00586 //
00587 //      The object calls this method when it's size changes during an
00588 //      InPlace Session
00589 //
00590 // Parameters:
00591 //
00592 //      LPCRECT lprcPosRect -   The new object rect
00593 //
00594 // Return Value:
00595 //
00596 //      S_OK
00597 //
00598 // Function Calls:
00599 //      Function                            Location
00600 //
00601 //      OutputDebugString                   Windows API
00602 //      GetClientRect                       Windows API
00603 //      IOleObject::GetExtent               Object
00604 //      IOleObject::QueryInterface          Object
00605 //      IOleInPlaceObject::SetObjectRects   Object
00606 //      IOleInPlaceObject::Release          Object
00607 //                           OLE API
00608 //
00609 // Comments:
00610 //
00611 //********************************************************************
00612
00613 STDMETHODIMP COleInPlaceSite::OnPosRectChange (LPCRECT lprcPosRect)
00614 {
00615         OutputDebugString("In IOIPS::OnPosRectChange\r\n");
00616         CStabilize stabilize(m_pSite);
00617
00618         // update the size in the document object
00619         // NOTE: here we must call IOleObject::GetExtent to get actual extents
00620         //       of the running object. IViewObject2::GetExtent returns the
00621         //       last cached extents.
00622         m_pSite->m_lpOleObject->GetExtent(DVASPECT_CONTENT, &m_pSite->m_sizel);
00623         RECT rect;
00624         GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
00625
00626         // tell the object its new size
00627         m_pSite->m_lpInPlaceObject->SetObjectRects(lprcPosRect, &rect);
00628
00629         return S_OK;
00630 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IAS/MapName/radutil.h Source File

  • NetDS
  • IAS
  • MapName

radutil.h

Go to the documentation of this file.
00001 /* Copyright (c) Microsoft Corporation. All rights reserved. */
00002
00003 #ifndef RADUTIL_H
00004 #define RADUTIL_H
00005 #pragma once
00006
00007 #include "authif.h"
00008
00009 #ifdef __cplusplus
00010 extern "C" {
00011 #endif
00012
00013 LPVOID
00014 WINAPI
00015 RadiusAlloc(
00016    SIZE_T dwBytes
00017    );
00018
00019 VOID
00020 WINAPI
00021 RadiusFree(
00022    LPVOID lpMem
00023    );
00024
00025 #define RADIUS_ATTR_NOT_FOUND ((DWORD)-1)
00026
00027 /* Returns the index of the first attribute with the desired type or
00028  * RADIUS_ATTR_NOT_FOUND if no such attribute exists. */
00029 DWORD
00030 WINAPI
00031 RadiusFindFirstIndex(
00032    PRADIUS_ATTRIBUTE_ARRAY pAttrs,
00033    DWORD dwAttrType
00034    );
00035
00036 /* Returns the first attribute with the desired type or NULL if no such
00037  * attribute exists. */
00038 const RADIUS_ATTRIBUTE*
00039 WINAPI
00040 RadiusFindFirstAttribute(
00041    PRADIUS_ATTRIBUTE_ARRAY pAttrs,
00042    DWORD dwAttrType
00043    );
00044
00045 /* Replaces the first attribute of the specified type or appends the new
00046  * attribute to the end of the request if no such attribute exists. */
00047 DWORD
00048 WINAPI
00049 RadiusReplaceFirstAttribute(
00050    PRADIUS_ATTRIBUTE_ARRAY pAttrs,
00051    const RADIUS_ATTRIBUTE* pSrc
00052    );
00053
00054 /* Install an extension DLL. */
00055 HRESULT
00056 WINAPI
00057 RadiusExtensionInstall(
00058     HMODULE hModule,
00059     LPCWSTR pwszType,
00060     BOOL fInstall
00061     );
00062
00063 #ifdef __cplusplus
00064 }
00065 #endif
00066 #endif // RADUTIL_H
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Framer/Site.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Framer

Site.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*
00019  * SITE.CPP
00020  * Document Object Site Object
00021  *
00022  */
00023
00024
00025 #include "framer.h"
00026
00027
00028 /*
00029  * CSite::CSite
00030  * CSite::~CSite
00031  *
00032  *  dwID            DWORD identifer for this site.
00033  *  hWnd            HWND of the window associated with the site
00034  *  pFR             PCFrame to the parent structure.
00035  */
00036
00037 CSite::CSite(DWORD dwID, HWND hWnd, PCFrame pFR)
00038     {
00039     m_cRef=0;
00040     m_dwID=dwID;
00041     m_hWnd=hWnd;
00042     m_pFR=pFR;
00043
00044     m_fInitialized=0;
00045     m_pIStorage=NULL;
00046
00047     m_pObj=NULL;
00048
00049     m_pIOleObject=NULL;
00050     m_pIOleIPObject=NULL;
00051     m_pIOleDocView=NULL;
00052
00053     m_pImpIOleClientSite=NULL;
00054     m_pImpIAdviseSink=NULL;
00055     m_pImpIOleIPSite=NULL;
00056     m_pImpIOleDocumentSite=NULL;
00057
00058     m_fDocObj=FALSE;
00059     return;
00060     }
00061
00062
00063 CSite::~CSite(void)
00064     {
00065     //Object pointers cleaned up in Close.
00066
00067     //We delete our own interfaces since we control them
00068     DeleteInterfaceImp(m_pImpIOleDocumentSite);
00069     DeleteInterfaceImp(m_pImpIOleIPSite);
00070     DeleteInterfaceImp(m_pImpIAdviseSink);
00071     DeleteInterfaceImp(m_pImpIOleClientSite);
00072     return;
00073     }
00074
00075
00076
00077
00078 /*
00079  * CSite::QueryInterface
00080  * CSite::AddRef
00081  * CSite::Release
00082  *
00083  * Purpose:
00084  *  IUnknown members for CSite object.
00085  */
00086
00087 STDMETHODIMP CSite::QueryInterface(REFIID riid, void **ppv)
00088     {
00089     *ppv=NULL;
00090
00091     if (IID_IUnknown==riid)
00092         *ppv=this;
00093
00094     if (IID_IOleClientSite==riid)
00095         *ppv=m_pImpIOleClientSite;
00096
00097     if (IID_IAdviseSink==riid)
00098         *ppv=m_pImpIAdviseSink;
00099
00100     if (IID_IOleWindow==riid || IID_IOleInPlaceSite==riid)
00101         *ppv=m_pImpIOleIPSite;
00102
00103     if (IID_IOleDocumentSite==riid)
00104         *ppv=m_pImpIOleDocumentSite;
00105
00106     if (NULL!=*ppv)
00107         {
00108         ((LPUNKNOWN)*ppv)->AddRef();
00109         return NOERROR;
00110         }
00111
00112     return ResultFromScode(E_NOINTERFACE);
00113     }
00114
00115
00116 STDMETHODIMP_(ULONG) CSite::AddRef(void)
00117     {
00118     return ++m_cRef;
00119     }
00120
00121 STDMETHODIMP_(ULONG) CSite::Release(void)
00122     {
00123     if (0!=--m_cRef)
00124         return m_cRef;
00125
00126     delete this;
00127     return 0;
00128     }
00129
00130
00131
00132
00133
00134
00135 /*
00136  * CSite::Create
00137  *
00138  * Purpose:
00139  *  Asks the site to instantiate an object given a filename.
00140  *  This goes through OleCreateFromFile and will either create
00141  *  an embedded object or a package (embedded) object.  When
00142  *  activated, this will either launch the app and activate
00143  *  as a DocObject, launch the app and open the file, or fail
00144  *  because no app can open the file.
00145  *
00146  * Parameters:
00147  *  pszFile         LPTSTR of the file from which to create the object.
00148  *  pIStorage       IStorage * of the parent storage in which we're
00149  *                  to create an IStorage for the new object.
00150  *  dwID            DWORD identifier for this site.
00151  *
00152  * Return Value:
00153  *  BOOL            Result of the creation.
00154  */
00155
00156 BOOL CSite::Create(LPTSTR pszFile, IStorage *pIStorage)
00157     {
00158     HRESULT             hr=E_FAIL;
00159     LPUNKNOWN           pObj;
00160
00161     //Create a new storage for this object (sets m_pIStorage)
00162     if (!CreateStorage(pIStorage))
00163         return FALSE;
00164
00165     //Now create an object from the file
00166    #ifdef UNICODE
00167     hr=OleCreateFromFile(CLSID_NULL, pszFile, IID_IUnknown
00168         , OLERENDER_NONE, NULL, NULL, m_pIStorage, (void **)&pObj);
00169    #else
00170     OLECHAR     szFile[512];    //Assumption on string length
00171
00172     MultiByteToWideChar(CP_ACP, 0, pszFile, -1, szFile, 512);
00173   hr=OleCreateFromFile(CLSID_NULL, szFile, IID_IUnknown
00174         , OLERENDER_NONE, NULL, NULL, m_pIStorage, (void **)&pObj);
00175    #endif
00176
00177     //If creation didn't work, get rid of the element Open created.
00178     if (FAILED(hr))
00179         {
00180         Destroy(pIStorage);
00181         return FALSE;
00182         }
00183
00184     //We don't get the size if PatronObject data was seen already.
00185     if (!ObjectInitialize(pObj))
00186         {
00187         Destroy(pIStorage);
00188         return FALSE;
00189         }
00190
00191     m_fInitialized=TRUE;
00192     return TRUE;
00193     }
00194
00195
00196
00197
00198
00199
00200 /*
00201  * CSite::ObjectInitialize
00202  * (Protected)
00203  *
00204  * Purpose:
00205  *  Performs operations necessary after creating an object or
00206  *  reloading one from storage.
00207  *
00208  * Parameters:
00209  *  pObj            LPUNKNOWN of the object in this tenant.
00210  *  pFE             LPFORMATETC describing the graphic here.
00211  *  dwData          DWORD extra data.  If pFE->dwAspect==
00212  *                  DVASPECT_ICON then this is the iconic metafile.
00213  *
00214  * Return Value:
00215  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
00216  */
00217
00218 BOOL CSite::ObjectInitialize(LPUNKNOWN pObj)
00219     {
00220     HRESULT         hr;
00221     DWORD           dw;
00222
00223     if (NULL==pObj)
00224         return FALSE;
00225
00226     m_pObj=pObj;
00227
00228     //We need an IOleObject most of the time, so get one here.
00229     m_pIOleObject=NULL;
00230     hr=pObj->QueryInterface(IID_IOleObject, (void **)&m_pIOleObject);
00231
00232     /*
00233      * Follow up object creation with advises and so forth.  If
00234      * we cannot get IOleObject here, then we know we can't do
00235      * any IOleObject actions from here on--object is static.
00236      */
00237     if (FAILED(hr))
00238         return TRUE;
00239
00240     //SetClientSite is critical for DocObjects
00241     m_pIOleObject->SetClientSite(m_pImpIOleClientSite);
00242     m_pIOleObject->Advise(m_pImpIAdviseSink, &dw);
00243
00244   //This is to give PowerPoint a chance to initialize itself earlier
00245   OleRun(m_pIOleObject);
00246     return TRUE;
00247     }
00248
00249
00250
00251
00252 /*
00253  * CSite::CreateStorage
00254  *
00255  * Purpose:
00256  *  Creates an sub-storage within a given parent storage,
00257  *  setting m_pIStorage.
00258  *
00259  * Parameters:
00260  *  pIStorage       IStorage * of the parent storage
00261  *
00262  * Return Value:
00263  *  BOOL            TRUE if creation succeeds, FALSE otherwise.
00264  */
00265
00266 BOOL CSite::CreateStorage(IStorage *pIStorage)
00267     {
00268     HRESULT     hr;
00269     DWORD       dwMode=STGM_TRANSACTED | STGM_READWRITE
00270                     | STGM_SHARE_EXCLUSIVE;
00271     TCHAR       szName[32];
00272
00273     if (NULL==pIStorage)
00274         return FALSE;
00275
00276     /*
00277      * Attempt to open the storage under this ID.  If there is
00278      * none, then create it.  In either case we end up with an
00279      * IStorage that we either save in pPage or release.
00280      */
00281     wsprintf(szName, TEXT("Site %lu"), m_dwID);
00282
00283    #ifdef UNICODE
00284     hr=pIStorage->CreateStorage(szName, dwMode, 0, 0, &m_pIStorage);
00285    #else
00286     OLECHAR  szwName[32];
00287   MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, 32);
00288     hr=pIStorage->CreateStorage(szwName, dwMode, 0, 0, &m_pIStorage);
00289    #endif
00290
00291     if (FAILED(hr))
00292         return FALSE;
00293
00294   //Create stream for the object; name is irrelevant
00295   dwMode=STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
00296    #ifdef UNICODE
00297     hr=m_pIStorage->CreateStream(TEXT("\003DocObjInfo"), dwMode, 0, 0
00298         , &m_pIStream);
00299    #else
00300   MultiByteToWideChar(CP_ACP, 0, "\003DocObjInfo", -1, szwName, 32);
00301     hr=m_pIStorage->CreateStream(szwName, dwMode, 0, 0, &m_pIStream);
00302    #endif
00303
00304     //If we failed to create a stream in the file, do it in memory
00305   if (FAILED(hr))
00306     {
00307     if (FAILED(CreateStreamOnHGlobal(NULL, TRUE, &m_pIStream)))
00308         return FALSE;
00309     }
00310
00311     //Create interface implementations
00312     m_pImpIOleClientSite=new CImpIOleClientSite(this, this);
00313     m_pImpIAdviseSink=new CImpIAdviseSink(this, this);
00314     m_pImpIOleIPSite=new CImpIOleInPlaceSite(this, this);
00315     m_pImpIOleDocumentSite=new CImpIOleDocumentSite(this, this);
00316
00317     if (NULL==m_pImpIOleClientSite || NULL==m_pImpIAdviseSink
00318         || NULL==m_pImpIOleIPSite || NULL==m_pImpIOleDocumentSite)
00319         return FALSE;
00320
00321     return TRUE;
00322     }
00323
00324
00325
00326
00327 /*
00328  * CSite::Close
00329  *
00330  * Purpose:
00331  *  Possibly commits the storage, then releases it, afterwards
00332  *  frees alls the object pointers.
00333  *
00334  * Parameters:
00335  *  fCommit         BOOL indicating if we're to commit.
00336  *
00337  * Return Value:
00338  *  None
00339  */
00340
00341 void CSite::Close(BOOL fCommit)
00342     {
00343     //OnInPlaceDeactivate releases this pointer.
00344     if (NULL!=m_pIOleIPObject)
00345         m_pIOleIPObject->InPlaceDeactivate();
00346
00347     ReleaseInterface(m_pIOleDocView);
00348
00349     if (NULL!=m_pIOleObject)
00350         {
00351         m_pIOleObject->Close(fCommit
00352             ? OLECLOSE_SAVEIFDIRTY : OLECLOSE_NOSAVE);
00353         ReleaseInterface(m_pIOleObject);
00354         }
00355
00356     ReleaseInterface(m_pObj);
00357   ReleaseInterface(m_pIStream);
00358     ReleaseInterface(m_pIStorage);
00359
00360     return;
00361     }
00362
00363
00364
00365
00366 /*
00367  * CSite::Update
00368  *
00369  * Purpose:
00370  *  Forces a commit on the object's storage
00371  *
00372  * Parameters:
00373  *  None
00374  *
00375  * Return Value:
00376  *  None
00377  */
00378
00379 void CSite::Update(void)
00380     {
00381     LPPERSISTSTORAGE    pIPS;
00382
00383     if (NULL!=m_pIStorage)
00384         return;
00385
00386     m_pObj->QueryInterface(IID_IPersistStorage, (void **)&pIPS);
00387     OleSave(pIPS, m_pIStorage, TRUE);
00388     pIPS->SaveCompleted(NULL);
00389     pIPS->Release();
00390
00391     m_pIStorage->Commit(STGC_DEFAULT);
00392     return;
00393     }
00394
00395
00396
00397
00398
00399 /*
00400  * CSite::Destroy
00401  *
00402  * Purpose:
00403  *  Removes this storage from the parent storage.  The caller should
00404  *  eventually delete this CSite object to free the object herein.
00405  *  Nothing is committed when being destroyed.
00406  *
00407  * Parameters:
00408  *  pIStorage       IStorage * of the parent
00409  *
00410  * Return Value:
00411  *  None
00412  */
00413
00414 void CSite::Destroy(IStorage *pIStorage)
00415     {
00416     TCHAR     szName[32];
00417
00418     if (NULL==pIStorage)
00419         return;
00420
00421     if (NULL!=m_pObj)
00422         Close(FALSE);
00423
00424   wsprintf(szName, TEXT("Site %lu"), m_dwID);
00425    #ifdef UNICODE
00426     pIStorage->DestroyElement(szName);
00427    #else
00428     OLECHAR  szwName[32];
00429   MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, 32);
00430   pIStorage->DestroyElement(szwName);
00431    #endif
00432     return;
00433     }
00434
00435
00436
00437
00438
00439 /*
00440  * CSite::Activate
00441  *
00442  * Purpose:
00443  *  Activates a verb on the object living in the site.
00444  *
00445  * Parameters:
00446  *  iVerb           LONG of the verb to execute.
00447  *
00448  * Return Value:
00449  *  None
00450  */
00451
00452 void CSite::Activate(LONG iVerb)
00453     {
00454     CHourglass *pHour;
00455     RECT        rc;
00456
00457     pHour=new CHourglass;
00458
00459     GetClientRect(m_hWnd, &rc);
00460     m_pIOleObject->DoVerb(iVerb, NULL, m_pImpIOleClientSite, 0
00461         , m_hWnd, &rc);
00462
00463     delete pHour;
00464     return;
00465     }
00466
00467
00468
00469
00470 /*
00471  * CSite::UpdateObjectRects
00472  *
00473  * Purpose:
00474  *  Informs the site that the client area window was resized and
00475  *  that the site needs to also tell the DocObject of the resize.
00476  *
00477  * Parameters:
00478  *  None
00479  *
00480  * Return Value:
00481  *  None
00482  */
00483
00484 void CSite::UpdateObjectRects(void)
00485     {
00486     RECT    rc;
00487
00488     if (NULL==m_pIOleDocView)
00489         return;
00490
00491     GetClientRect(m_hWnd, &rc);
00492     m_pIOleDocView->SetRect(&rc);
00493     return;
00494     }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenuExt/localres.h Source File

  • SysMgmt
  • MMC
  • CMenuExt

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030 #define INDEX_SUN 6
00031 #define INDEX_SNOW 7
00032 #define INDEX_RAIN 8
00033 #define INDEX_CLOUD 9
00034 #define INDEX_WORLD 10
00035 #define INDEX_THUNDER 11
00036
00037
00038 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/TSSysInf/Server/SysInf_S.c Source File

  • WinBase
  • WtsApi
  • TSSysInf
  • Server

SysInf_S.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright 1998 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sysinf_s.c
00008
00009 Abstract:
00010
00011     This file contains the code for the server-side application to demonstrate
00012     Virtual Channels on Windows Terminal Services.
00013
00014     The server application first obtains system information from the client
00015     machine and then obtains memory information, which is updated every 2
00016     seconds.
00017
00018     The server app will stop obtaining memory information when the client
00019     disconnects and will resume when the client reconnects.
00020
00021     The server app ends when the user presses Ctrl-C or Ctrl-Break.  The
00022     control handler will signal an event to stop obtaining memory info and
00023     clean up any extraneous handles.
00024
00025 Author:
00026
00027     Frank Kim (franki)    18-Mar-99
00028
00029 --*/
00030
00031 #include "sysinfo.h"
00032
00033 #define TEXT1(x) x
00034
00035
00036 void DisplayError(LPTSTR pszAPI)
00037 {
00038     LPVOID lpvMessageBuffer;
00039     DWORD  lastErr;
00040
00041     lastErr = GetLastError();
00042
00043     FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00044                   NULL, lastErr,
00045                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00046                   (LPTSTR)&lpvMessageBuffer, 0, NULL);
00047
00048     //
00049     //... now display this string
00050     //
00051     _tprintf(TEXT1("SYSINF_S ERROR: API        = %s.\n"), pszAPI);
00052     _tprintf(TEXT1("                error code = %d.\n"), lastErr);
00053     _tprintf(TEXT1("                message    = %s.\n"), (LPTSTR)lpvMessageBuffer);
00054
00055     //
00056     // Free the buffer allocated by the system
00057     //
00058     LocalFree(lpvMessageBuffer);
00059
00060     ExitProcess(GetLastError());
00061 }
00062
00063
00064 BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
00065 {
00066     //
00067     // cleanup
00068     //
00069
00070     if (!SetEvent(ghEventEnd))
00071         DisplayError(TEXT("SetEvent"));
00072
00073     return TRUE;
00074 }
00075
00076
00077 void
00078 _cdecl
00079 _tmain(void)
00080 {
00081     BOOL            bContinue = TRUE;
00082     BOOL            bQuery = TRUE;
00083     DWORD           dwTimeout = QUERY_INTERVAL;
00084     DWORD           dwWait = WAIT_TIMEOUT;
00085     DWORD           dwSessionId;
00086     DWORD           dwControlCode;
00087     ULONG           ulBytesWritten;
00088     ULONG           ulBytesRead;
00089     HANDLE          hVirtChannel;
00090     HANDLE          hEventConnect[3]; // 0 reconnect, 1 disconnect, 2 stop
00091     MEMORYSTATUS    ms;
00092     TS_VERSION_INFO tsvi;
00093     TCHAR           szEventReconnect[256] = TEXT("");
00094     TCHAR           szEventDisconnect[256] = TEXT("");
00095     TCHAR           buffer[256] = TEXT("");
00096
00097     //
00098     // install console control handler
00099     //
00100     if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, TRUE))
00101         DisplayError(TEXT("SetConsoleControlHandler"));
00102
00103     //
00104     // obtain session id
00105     //
00106     if (!ProcessIdToSessionId(GetCurrentProcessId(), &dwSessionId))
00107         DisplayError(TEXT("ProcessIdToSessionId"));
00108
00109     wsprintf(szEventReconnect, TEXT("Global\\sysinf_s-%u-Reconnect"), dwSessionId);
00110     wsprintf(szEventDisconnect, TEXT("Global\\sysinf_s-%u-Disconnect"), dwSessionId);
00111
00112     //
00113     // exit if running in console session
00114     //
00115     if (dwSessionId == 0){
00116         _tprintf(TEXT1("running in console session\n"));
00117         return;
00118     }
00119
00120     //
00121     // create connection events
00122     //
00123     hEventConnect[0] = CreateEvent(NULL, FALSE, FALSE, szEventReconnect);
00124     if (hEventConnect[0] == NULL)
00125         DisplayError(TEXT("CreateEvent"));
00126
00127     hEventConnect[1] = CreateEvent(NULL, FALSE, FALSE, szEventDisconnect);
00128     if (hEventConnect[1] == NULL)
00129         DisplayError(TEXT("CreateEvent"));
00130
00131     //
00132     // create stop event
00133     //
00134     ghEventEnd = CreateEvent(NULL, FALSE, FALSE, NULL);
00135     if (ghEventEnd == NULL)
00136         DisplayError(TEXT("CreateEvent"));
00137
00138     hEventConnect[2] = ghEventEnd;
00139
00140     //
00141     // open virtual channel
00142     //
00143     hVirtChannel = WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE,
00144                                          dwSessionId,
00145                                          CHANNELNAME);
00146     if (hVirtChannel == NULL)
00147         DisplayError(TEXT("WTSVirtualChannelOpen"));
00148
00149     //
00150     // get system information
00151     //
00152     dwControlCode = TSVERSIONINFO;
00153     if (!WTSVirtualChannelWrite(hVirtChannel,
00154                                 (PCHAR)&dwControlCode,
00155                                 sizeof(dwControlCode),
00156                                 &ulBytesWritten))
00157         DisplayError(TEXT("WTSVirtualChannelWrite"));
00158
00159     //
00160     // read system info
00161     //
00162     if (!WTSVirtualChannelRead(hVirtChannel,
00163                                INFINITE,
00164                                (PCHAR)&tsvi,
00165                                sizeof(tsvi),
00166                                &ulBytesRead))
00167         DisplayError(TEXT("WTSVirtualChannelRead"));
00168
00169     //
00170     // display system info
00171     //
00172     _tprintf(TEXT1("Client machine  : %s\n"), tsvi.szComputerName);
00173     printf("TS machine      : %s\n", tsvi.szClientName);
00174     _tprintf(TEXT1("User context    : %s\n"), tsvi.szUserName);
00175     _tprintf(TEXT1("Operating System: "));
00176     if (tsvi.osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00177         _tprintf(TEXT1("Windows 9x\n"));
00178     else if (tsvi.osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
00179         _tprintf(TEXT1("Windows NT or Windows 2000\n"));
00180     else
00181         _tprintf(TEXT1("Win32s\n"));
00182
00183     _tprintf(TEXT1("OS Version      : %u.%u\n"), tsvi.osvi.dwMajorVersion, tsvi.osvi.dwMinorVersion);
00184     _tprintf(TEXT1("Build Number    : %u\n"), tsvi.osvi.dwBuildNumber);
00185     _tprintf(TEXT1("Service Pack    : %s\n"), tsvi.osvi.szCSDVersion);
00186     _tprintf(TEXT1("Page Size       : %u\n"), tsvi.si.dwPageSize);
00187     _tprintf(TEXT1("Number of procs : %u\n"), tsvi.si.dwNumberOfProcessors);
00188
00189     if (tsvi.si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL){
00190
00191         _tprintf(TEXT1("Processor type  : "), tsvi.si.dwNumberOfProcessors);
00192         switch (tsvi.si.wProcessorLevel)
00193         {
00194             case 3:
00195                 _tprintf(TEXT1("Intel 80386\n"));
00196                 break;
00197
00198             case 4:
00199                 _tprintf(TEXT1("Intel 80486\n"));
00200                 break;
00201
00202             case 5:
00203                 _tprintf(TEXT1("Intel Pentium\n"));
00204                 break;
00205
00206             case 6:
00207                 _tprintf(TEXT1("Intel Pentium Pro or Pentium II\n"));
00208                 break;
00209
00210             default:
00211                 _tprintf(TEXT1("Intel ????\n"));
00212                 break;
00213         }
00214     }
00215
00216     _tprintf(TEXT1("\nMemory Load - Avail Physical - Avail Page File - Avail Virtual\n"));
00217
00218     while(bContinue){
00219         dwWait = WaitForMultipleObjects(3, hEventConnect, FALSE, dwTimeout);
00220         switch(dwWait)
00221         {
00222             case WAIT_TIMEOUT:
00223                 if (bQuery) {
00224                     //
00225                     // initialize buffer
00226                     //
00227                     ZeroMemory(&ms, sizeof(ms));
00228                     ulBytesRead = 0;
00229                     ZeroMemory(buffer, sizeof(buffer));
00230
00231                     dwControlCode = TSMEMORYINFO;
00232                     if (!WTSVirtualChannelWrite(hVirtChannel,
00233                                                 (PCHAR)&dwControlCode,
00234                                                 sizeof(dwControlCode),
00235                                                 &ulBytesWritten))
00236                         DisplayError(TEXT("WTSVirtualChannelWrite"));
00237
00238                     //
00239                     // read data
00240                     //
00241                     if (!WTSVirtualChannelRead(hVirtChannel,
00242                                                INFINITE,
00243                                                (PCHAR)&ms,
00244                                                sizeof(ms),
00245                                                &ulBytesRead))
00246                         DisplayError(TEXT("WTSVirtualChannelRead"));
00247
00248                     //
00249                     // display data
00250                     //
00251                     wsprintf(buffer,
00252                              TEXT("%10lu%%   %14lu   %15lu   %13lu"),
00253                              ms.dwMemoryLoad,
00254                              ms.dwAvailPhys,
00255                              ms.dwAvailPageFile,
00256                              ms.dwAvailVirtual);
00257                     _tprintf(TEXT1("\r%s"), buffer);
00258                 }
00259                 break;
00260
00261             case WAIT_OBJECT_0: // reconnect
00262                 //
00263                 // allow query to occur
00264                 //
00265                 bQuery = TRUE;
00266                 dwTimeout = QUERY_INTERVAL;
00267                 _tprintf(TEXT1("-reconnected-\n"), buffer);
00268                 break;
00269
00270             case WAIT_OBJECT_0 + 1: // disconnect
00271                 //
00272                 // do not query
00273                 //
00274                 bQuery = FALSE;
00275                 dwTimeout = INFINITE;
00276                 _tprintf(TEXT1("\n-disconnected-\n"), buffer);
00277                 break;
00278
00279             case WAIT_OBJECT_0 + 2: // stop
00280                 bContinue = FALSE;
00281                 break;
00282
00283             case WAIT_FAILED:
00284                 DisplayError(TEXT("WaitForMultipleObjects"));
00285                 break;
00286
00287             default:
00288                 break;
00289         }
00290     }
00291
00292     //
00293     // close the virtual channel
00294     //
00295     WTSVirtualChannelClose(hVirtChannel);
00296
00297     //
00298     // close handles
00299     //
00300     CloseHandle(hEventConnect[0]);
00301     CloseHandle(hEventConnect[1]);
00302     CloseHandle(ghEventEnd);
00303 }
00304
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CObjPoolSub Member List

This is the complete list of members for CObjPoolSub, including all inherited members.
CObjPoolSub(CComSpy *pSpy) | CObjPoolSub | [inline]
CObjPoolSub() | CObjPoolSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetEventClass(LPGUID guid) | CObjPoolSub | [inline, virtual]
GetEventType(EventEnum *e) | CObjPoolSub | [inline, virtual]
GetInterface(IID *iid) | CObjPoolSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnObjPoolGetFromTx(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, REFGUID guidClass, REFGUID guidTx, ULONG64 ObjectID) | CObjPoolSub | [inline]
OnObjPoolGetObject(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, REFGUID guidClass, DWORD dwAvailable, ULONG64 ObjectID) | CObjPoolSub | [inline]
OnObjPoolPutObject(COMSVCSEVENTINFO *pInfo, REFGUID guidClass, int nReason, DWORD dwAvailable, ULONG64 ObjectID) | CObjPoolSub | [inline]
OnObjPoolRecycleToTx(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, REFGUID guidClass, REFGUID guidTx, ULONG64 ObjectID) | CObjPoolSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/registry.h Source File

  • SysMgmt
  • MMC
  • CMenu

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step2/MyDevice.cpp Source File

  • NetDS
  • upnp
  • StepByStep
  • Step2

MyDevice.cpp

Go to the documentation of this file.
00001 // MyDevice.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f MyDeviceps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "MyDevice.h"
00012
00013 #include "MyDevice_i.c"
00014 #include "Dimmer.h"
00015 #include "DimmerService.h"
00016
00017
00018 CComModule _Module;
00019
00020 BEGIN_OBJECT_MAP(ObjectMap)
00021 OBJECT_ENTRY(CLSID_Dimmer, CDimmer)
00022 OBJECT_ENTRY(CLSID_DimmerService, CDimmerService)
00023 END_OBJECT_MAP()
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // DLL Entry Point
00027
00028 extern "C"
00029 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00030 {
00031     if (dwReason == DLL_PROCESS_ATTACH)
00032     {
00033         _Module.Init(ObjectMap, hInstance, &LIBID_MYDEVICELib);
00034         DisableThreadLibraryCalls(hInstance);
00035     }
00036     else if (dwReason == DLL_PROCESS_DETACH)
00037         _Module.Term();
00038     return TRUE;    // ok
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 // Used to determine whether the DLL can be unloaded by OLE
00043
00044 STDAPI DllCanUnloadNow(void)
00045 {
00046     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // Returns a class factory to create an object of the requested type
00051
00052 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00053 {
00054     return _Module.GetClassObject(rclsid, riid, ppv);
00055 }
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // DllRegisterServer - Adds entries to the system registry
00059
00060 STDAPI DllRegisterServer(void)
00061 {
00062     // registers object, typelib and all interfaces in typelib
00063     return _Module.RegisterServer(TRUE);
00064 }
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // DllUnregisterServer - Removes entries from the system registry
00068
00069 STDAPI DllUnregisterServer(void)
00070 {
00071     return _Module.UnregisterServer(TRUE);
00072 }
00073
00074
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/delebase.Cpp Source File

  • SysMgmt
  • MMC
  • ActiveX

delebase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021 #include "Comp.h"
00022 #include "CompData.h"
00023
00024 const GUID CDelegationBase::thisGuid = { 0x2974380b, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00025
00026 //==============================================================
00027 //
00028 // CDelegationBase implementation
00029 //
00030 //
00031 CDelegationBase::CDelegationBase()
00032 : m_pComponentData(NULL), bExpanded(FALSE)
00033 {
00034     m_pBMapSm = NULL;
00035     m_pBMapLg = NULL;
00036
00037     LoadBitmaps();
00038 }
00039
00040 CDelegationBase::~CDelegationBase()
00041 {
00042 }
00043
00044 // CDelegationBase::AddImages sets up the collection of images to be displayed
00045 // by the IComponent in the result pane as a result of its MMCN_SHOW handler
00046 HRESULT CDelegationBase::AddImages(IImageList *pImageList, HSCOPEITEM hsi)
00047 {
00048     return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
00049         (long *)m_pBMapLg, // pointer to a handle
00050         0, // index of the first image in the strip
00051         RGB(0, 128, 128)  // color of the icon mask
00052         );
00053 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/AdvClient.h Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

AdvClient.h

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  HMMSamp.h
00006 //
00007 // Description:
00008 //  This file declares the CHMMSampleApp class. It is the main
00009 //    class for the tutorial
00010 //
00011 // Part of: WMI Tutorial #1.
00012 //
00013 // Used by: Nobody.
00014 //
00015 // History:
00016 //
00017 // **************************************************************************
00018
00019 #if !defined(AFX_HMMENUM_H__6AC7FBF7_FE04_11D0_AD84_00AA00B8E05A__INCLUDED_)
00020 #define AFX_HMMENUM_H__6AC7FBF7_FE04_11D0_AD84_00AA00B8E05A__INCLUDED_
00021
00022 #if _MSC_VER >= 1000
00023 #pragma once
00024 #endif // _MSC_VER >= 1000
00025
00026 #ifndef __AFXWIN_H__
00027   #error include 'stdafx.h' before including this file for PCH
00028 #endif
00029
00030 #include "resource.h"   // main symbols
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 // CHMMSampleApp:
00034 // See WBEMEnum.cpp for the implementation of this class
00035 //
00036
00037 class CHMMSampleApp : public CWinApp
00038 {
00039 public:
00040   CHMMSampleApp();
00041
00042 // Overrides
00043   // ClassWizard generated virtual function overrides
00044   //{{AFX_VIRTUAL(CHMMSampleApp)
00045   public:
00046   virtual BOOL InitInstance();
00047   //}}AFX_VIRTUAL
00048
00049   BOOL InitSecurity(void);
00050   virtual int ExitInstance();
00051 // Implementation
00052
00053   //{{AFX_MSG(CHMMSampleApp)
00054     // NOTE - the ClassWizard will add and remove member functions here.
00055     //    DO NOT EDIT what you see in these blocks of generated code !
00056   //}}AFX_MSG
00057   DECLARE_MESSAGE_MAP()
00058 };
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061
00062 //{{AFX_INSERT_LOCATION}}
00063 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00064
00065 #endif // !defined(AFX_HMMENUM_H__6AC7FBF7_FE04_11D0_AD84_00AA00B8E05A__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

igmp_hdr_query_v3 Member List

This is the complete list of members for igmp_hdr_query_v3, including all inherited members.
checksum | igmp_hdr_query_v3
group_addr | igmp_hdr_query_v3
max_resp_time | igmp_hdr_query_v3
num_sources | igmp_hdr_query_v3
qqi | igmp_hdr_query_v3
resv_suppr_robust | igmp_hdr_query_v3
sources | igmp_hdr_query_v3
type | igmp_hdr_query_v3
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ColumnProvider/ClassFactory.h Source File

  • WinUI
  • Shell
  • ColumnProvider

ClassFactory.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  ClassFactory.h
00011 //
00012 //      Interface for the CClassFactory class.
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #ifndef _CLASSFACTORY_H_INCLUDED
00017 #define _CLASSFACTORY_H_INCLUDED
00018
00019 #if _MSC_VER > 1000
00020 #pragma once
00021 #endif // _MSC_VER > 1000
00022
00023 class CClassFactory : public IClassFactory
00024 {
00025 public:
00026     CClassFactory();
00027     virtual ~CClassFactory();
00028
00029     // IUnknown methods
00030     STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObject);
00031     STDMETHODIMP_(ULONG) AddRef();
00032     STDMETHODIMP_(ULONG) Release();
00033
00034     // IClassFactory methods
00035     STDMETHODIMP CreateInstance (LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
00036     STDMETHODIMP LockServer (BOOL bLock);
00037
00038 private:
00039     ULONG m_nRefCount;
00040 };
00041
00042 #endif // _CLASSFACTORY_H_INCLUDED
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CStorageResource Member List

This is the complete list of members for CStorageResource, including all inherited members.
CanBeManaged(void) | CStorageResource |
IStorageProperties::CanBeManaged(void) | IStorageProperties |
Cleanup(EClusCfgCleanupReason cccrReasonIn) | CStorageResource |
Clone(IEnumClusCfgPartitions **ppEnumClusCfgPartitionsOut) | CStorageResource |
CMgdClusCfgInit(void) | CMgdClusCfgInit |
CMgdClusCfgInit(void) | CMgdClusCfgInit |
Count(DWORD *pnCountOut) | CStorageResource |
Create(IUnknown *punkServicesIn) | CStorageResource |
CStorageResource(void) | CStorageResource |
CStorageResource(const CStorageResource &rSrcIn) | CStorageResource | [private]
Evict(IUnknown *punkServicesIn) | CStorageResource |
GetCallback(void) | CMgdClusCfgInit | [inline]
GetCallback(void) | CMgdClusCfgInit | [inline]
GetDisplayName(void) | CMgdClusCfgInit | [inline]
GetDisplayName(void) | CMgdClusCfgInit | [inline]
GetDllName(void) | CMgdClusCfgInit | [inline]
GetDllName(void) | CMgdClusCfgInit | [inline]
GetDriveLetterMappings(SDriveLetterMapping *pdlmDriveLetterMappingsOut) | CStorageResource |
GetLCID(void) | CMgdClusCfgInit | [inline]
GetLCID(void) | CMgdClusCfgInit | [inline]
GetName(BSTR *pbstrNameOut) | CStorageResource |
GetNodeName(void) | CMgdClusCfgInit | [inline]
GetNodeName(void) | CMgdClusCfgInit | [inline]
GetResourcePrivateData(BYTE *pbBufferOut, DWORD *pcbBufferInout) | CStorageResource |
GetResTypeName(void) | CMgdClusCfgInit | [inline]
GetResTypeName(void) | CMgdClusCfgInit | [inline]
GetUID(BSTR *pbstrUIDOut) | CStorageResource |
HrAddPartitionToArray(IUnknown *punkIn) | CStorageResource | [private]
HrCreateFriendlyName(void) | CStorageResource | [private]
HrCreateFriendlyName(BSTR bstrNameIn) | CStorageResource | [private]
HrCreatePartitionInfo(IWbemClassObject *pPartitionIn) | CStorageResource | [private]
HrGetDeviceID(BSTR *pbstrDeviceIDOut) | CStorageResource |
IStorageProperties::HrGetDeviceID(BSTR *pbstrDeviceIDOut) | IStorageProperties |
HrGetDeviceIndex(DWORD *pidxDeviceOut) | CStorageResource |
IStorageProperties::HrGetDeviceIndex(DWORD *pidxDeviceOut) | IStorageProperties |
HrGetDiskNames(BSTR *pbstrDiskNameOut, BSTR *pbstrDeviceNameOut) | CStorageResource |
IStorageProperties::HrGetDiskNames(BSTR *pbstrDiskNameOut, BSTR *pbstrDeviceNameOut) | IStorageProperties |
HrGetPartitionInfo(IWbemClassObject *pDiskIn, BOOL *pfRetainObjectOut) | CStorageResource | [private]
HrGetSCSIBus(ULONG *pulSCSIBusOut) | CStorageResource |
IStorageProperties::HrGetSCSIBus(ULONG *pulSCSIBusOut) | IStorageProperties |
HrGetSCSIPort(ULONG *pulSCSIPortOut) | CStorageResource |
IStorageProperties::HrGetSCSIPort(ULONG *pulSCSIPortOut) | IStorageProperties |
HrGetSignature(DWORD *pdwSignatureOut) | CStorageResource |
IStorageProperties::HrGetSignature(DWORD *pdwSignatureOut) | IStorageProperties |
HrIsClusterCapable(void) | CStorageResource | [private]
HrIsDynamicDisk(void) | CStorageResource |
IStorageProperties::HrIsDynamicDisk(void) | IStorageProperties |
HrIsGPTDisk(void) | CStorageResource |
IStorageProperties::HrIsGPTDisk(void) | IStorageProperties |
HrIsPartitionGPT(IWbemClassObject *pPartitionIn) | CStorageResource | [private]
HrIsPartitionLDM(IWbemClassObject *pPartitionIn) | CStorageResource | [private]
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, LPCWSTR pcszReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, UINT idsDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, LPCWSTR pcszReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, UINT idsDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSetFriendlyName(LPCWSTR pcszFriendlyNameIn) | CStorageResource |
IStorageProperties::HrSetFriendlyName(LPCWSTR pcszFriendlyNameIn) | IStorageProperties |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMgdClusCfgInit |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMgdClusCfgInit |
IsManaged(void) | CStorageResource |
IsManagedByDefault(void) | CStorageResource |
IsMultiNodeCapable(void) | CStorageResource |
IsQuorumCapable(void) | CStorageResource |
IsQuorumResource(void) | CStorageResource |
IsThisLogicalDisk(WCHAR cLogicalDiskIn) | CStorageResource |
IStorageProperties::IsThisLogicalDisk(WCHAR cLogicalDiskIn) | IStorageProperties |
m_bstrDescription | CStorageResource | [private]
m_bstrDeviceID | CStorageResource | [private]
m_bstrFriendlyName | CStorageResource | [private]
m_bstrName | CStorageResource | [private]
m_cPartitions | CStorageResource | [private]
m_dwSignature | CStorageResource | [private]
m_fIsDynamicDisk | CStorageResource | [private]
m_fIsGPTDisk | CStorageResource | [private]
m_fIsManaged | CStorageResource | [private]
m_fIsManagedByDefault | CStorageResource | [private]
m_fIsMultiNodeCapable | CStorageResource | [private]
m_fIsQuorumCapable | CStorageResource | [private]
m_fIsQuorumResource | CStorageResource | [private]
m_idxDevice | CStorageResource | [private]
m_idxEnumPartitionNext | CStorageResource | [private]
m_idxNextPartition | CStorageResource | [private]
m_pIWbemServices | CStorageResource | [private]
m_prgPartitions | CStorageResource | [private]
m_ulSCSIBus | CStorageResource | [private]
m_ulSCSILun | CStorageResource | [private]
m_ulSCSIPort | CStorageResource | [private]
m_ulSCSITid | CStorageResource | [private]
Next(ULONG cNumberRequestedIn, IClusCfgPartitionInfo **rgpPartitionInfoOut, ULONG *pcNumberFetchedOut) | CStorageResource |
operator=(const CStorageResource &rSrcIn) | CStorageResource | [private]
PostCreate(IUnknown *punkServicesIn) | CStorageResource |
PreCreate(IUnknown *punkServicesIn) | CStorageResource |
PrepareToHostQuorumResource(void) | CStorageResource |
Reset(void) | CStorageResource |
SetDriveLetterMappings(SDriveLetterMapping dlmDriveLetterMappingsIn) | CStorageResource |
SetManaged(BOOL fIsManagedIn) | CStorageResource |
SetManagedByDefault(BOOL fIsManagedByDefaultIn) | CStorageResource |
SetMultiNodeCapable(BOOL fMultiNodeCapableIn) | CStorageResource |
SetName(LPCWSTR pwszNameIn) | CStorageResource |
SetQuorumCapable(BOOL fIsQuorumCapableIn) | CStorageResource |
SetQuorumResource(BOOL fIsQuorumDeviceIn) | CStorageResource |
SetResourcePrivateData(const BYTE *pcbBufferIn, DWORD cbBufferIn) | CStorageResource |
SetWbemObject(IWbemClassObject *pDiskIn, BOOL *pfRetainObjectOut) | CStorageResource |
IWMIObject::SetWbemObject(IWbemClassObject *pObjectIn, BOOL *pfRetainObjectOut) | IWMIObject |
SetWbemServices(IWbemServices *pIWbemServicesIn) | CStorageResource |
IWMIServices::SetWbemServices(IWbemServices *pIWbemServicesIn) | IWMIServices |
Skip(ULONG cNumberToSkipIn) | CStorageResource |
~CMgdClusCfgInit(void) | CMgdClusCfgInit | [virtual]
~CMgdClusCfgInit(void) | CMgdClusCfgInit | [virtual]
~CStorageResource(void) | CStorageResource | [virtual]
Generated on Wed Nov 13 2024 16:57:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/utils.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

utils.h

Go to the documentation of this file.
00001 #ifndef __UTILS_H_
00002 #define __UTILS_H_
00003
00004 extern WCHAR * const month[];
00005
00006 inline long WriteNamedParam(WCHAR* wszParamStart, LPCWSTR wszName, VARIANT* pVal);
00007 WCHAR* BuildExecCommand(WCHAR* wszSQL, LPCWSTR wszStoredProc, LPCWSTR wszKeyField, VARIANT* pVal);
00008
00009 // This Variant wrapper is based on the CComVariant code
00010 // from ATL, however it has been modified to support
00011 // a fixed allocator, and has been modified to use OLEAUT32.DLL
00012 // as little as possible.
00013 class CFastVariant : public tagVARIANT
00014 {
00015   DECLARE_FIXED_ALLOC(CFastVariant);
00016 // Constructors
00017 public:
00018   CFastVariant()
00019   {
00020     vt = VT_EMPTY;
00021   }
00022   ~CFastVariant()
00023   {
00024     Clear();
00025   }
00026
00027   CFastVariant(const VARIANT& varSrc)
00028   {
00029     vt = VT_EMPTY;
00030     InternalCopy(&varSrc);
00031   }
00032
00033   CFastVariant(const CFastVariant& varSrc)
00034   {
00035     vt = VT_EMPTY;
00036     InternalCopy(&varSrc);
00037   }
00038
00039   CFastVariant(BSTR bstrSrc)
00040   {
00041     vt = VT_EMPTY;
00042     *this = bstrSrc;
00043   }
00044   CFastVariant(LPCOLESTR lpszSrc)
00045   {
00046     vt = VT_EMPTY;
00047     *this = lpszSrc;
00048   }
00049
00050 #ifndef OLE2ANSI
00051   CFastVariant(LPCSTR lpszSrc)
00052   {
00053     vt = VT_EMPTY;
00054     *this = lpszSrc;
00055   }
00056 #endif
00057
00058   CFastVariant(bool bSrc)
00059   {
00060     vt = VT_BOOL;
00061 #pragma warning(disable: 4310) // cast truncates constant value
00062     boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
00063 #pragma warning(default: 4310) // cast truncates constant value
00064   }
00065
00066   CFastVariant(int nSrc)
00067   {
00068     vt = VT_I4;
00069     lVal = nSrc;
00070   }
00071   CFastVariant(BYTE nSrc)
00072   {
00073     vt = VT_UI1;
00074     bVal = nSrc;
00075   }
00076   CFastVariant(short nSrc)
00077   {
00078     vt = VT_I2;
00079     iVal = nSrc;
00080   }
00081   CFastVariant(long nSrc, VARTYPE vtSrc = VT_I4)
00082   {
00083     ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_ERROR);
00084     vt = vtSrc;
00085     lVal = nSrc;
00086   }
00087   CFastVariant(float fltSrc)
00088   {
00089     vt = VT_R4;
00090     fltVal = fltSrc;
00091   }
00092   CFastVariant(double dblSrc)
00093   {
00094     vt = VT_R8;
00095     dblVal = dblSrc;
00096   }
00097   CFastVariant(CY cySrc)
00098   {
00099     vt = VT_CY;
00100     cyVal.Hi = cySrc.Hi;
00101     cyVal.Lo = cySrc.Lo;
00102   }
00103   CFastVariant(IDispatch* pSrc)
00104   {
00105     vt = VT_DISPATCH;
00106     pdispVal = pSrc;
00107     // Need to AddRef as VariantClear will Release
00108     if (pdispVal != NULL)
00109       pdispVal->AddRef();
00110   }
00111   CFastVariant(IUnknown* pSrc)
00112   {
00113     vt = VT_UNKNOWN;
00114     punkVal = pSrc;
00115     // Need to AddRef as VariantClear will Release
00116     if (punkVal != NULL)
00117       punkVal->AddRef();
00118   }
00119
00120 // Assignment Operators
00121 public:
00122   CFastVariant& operator=(const CFastVariant& varSrc)
00123   {
00124     InternalCopy(&varSrc);
00125     return *this;
00126   }
00127   CFastVariant& operator=(const VARIANT& varSrc)
00128   {
00129     InternalCopy(&varSrc);
00130     return *this;
00131   }
00132
00133   CFastVariant& operator=(BSTR bstrSrc)
00134   {
00135     InternalClear();
00136     vt = VT_BSTR;
00137     bstrVal = ::SysAllocString(bstrSrc);
00138     if (bstrVal == NULL && bstrSrc != NULL)
00139     {
00140       vt = VT_ERROR;
00141       scode = E_OUTOFMEMORY;
00142     }
00143     return *this;
00144   }
00145
00146   CFastVariant& operator=(LPCOLESTR lpszSrc)
00147   {
00148     InternalClear();
00149     vt = VT_BSTR;
00150     bstrVal = ::SysAllocString(lpszSrc);
00151
00152     if (bstrVal == NULL && lpszSrc != NULL)
00153     {
00154       vt = VT_ERROR;
00155       scode = E_OUTOFMEMORY;
00156     }
00157     return *this;
00158   }
00159
00160   #ifndef OLE2ANSI
00161   CFastVariant& operator=(LPCSTR lpszSrc)
00162   {
00163     USES_CONVERSION;
00164     InternalClear();
00165     vt = VT_BSTR;
00166     bstrVal = ::SysAllocString(A2COLE(lpszSrc));
00167
00168     if (bstrVal == NULL && lpszSrc != NULL)
00169     {
00170       vt = VT_ERROR;
00171       scode = E_OUTOFMEMORY;
00172     }
00173     return *this;
00174   }
00175   #endif
00176
00177   CFastVariant& operator=(bool bSrc)
00178   {
00179     if (vt != VT_BOOL)
00180     {
00181       InternalClear();
00182       vt = VT_BOOL;
00183     }
00184   #pragma warning(disable: 4310) // cast truncates constant value
00185     boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
00186   #pragma warning(default: 4310) // cast truncates constant value
00187     return *this;
00188   }
00189
00190   CFastVariant& operator=(int nSrc)
00191   {
00192     if (vt != VT_I4)
00193     {
00194       InternalClear();
00195       vt = VT_I4;
00196     }
00197     lVal = nSrc;
00198
00199     return *this;
00200   }
00201
00202   CFastVariant& operator=(BYTE nSrc)
00203   {
00204     if (vt != VT_UI1)
00205     {
00206       InternalClear();
00207       vt = VT_UI1;
00208     }
00209     bVal = nSrc;
00210     return *this;
00211   }
00212
00213   CFastVariant& operator=(short nSrc)
00214   {
00215     if (vt != VT_I2)
00216     {
00217       InternalClear();
00218       vt = VT_I2;
00219     }
00220     iVal = nSrc;
00221     return *this;
00222   }
00223
00224   CFastVariant& operator=(long nSrc)
00225   {
00226     if (vt != VT_I4)
00227     {
00228       InternalClear();
00229       vt = VT_I4;
00230     }
00231     lVal = nSrc;
00232     return *this;
00233   }
00234
00235   CFastVariant& operator=(float fltSrc)
00236   {
00237     if (vt != VT_R4)
00238     {
00239       InternalClear();
00240       vt = VT_R4;
00241     }
00242     fltVal = fltSrc;
00243     return *this;
00244   }
00245
00246   CFastVariant& operator=(double dblSrc)
00247   {
00248     if (vt != VT_R8)
00249     {
00250       InternalClear();
00251       vt = VT_R8;
00252     }
00253     dblVal = dblSrc;
00254     return *this;
00255   }
00256
00257   CFastVariant& operator=(CY cySrc)
00258   {
00259     if (vt != VT_CY)
00260     {
00261       InternalClear();
00262       vt = VT_CY;
00263     }
00264     cyVal.Hi = cySrc.Hi;
00265     cyVal.Lo = cySrc.Lo;
00266     return *this;
00267   }
00268
00269   CFastVariant& operator=(IDispatch* pSrc)
00270   {
00271     InternalClear();
00272     vt = VT_DISPATCH;
00273     pdispVal = pSrc;
00274     // Need to AddRef as VariantClear will Release
00275     if (pdispVal != NULL)
00276       pdispVal->AddRef();
00277     return *this;
00278   }
00279
00280   CFastVariant& operator=(IUnknown* pSrc)
00281   {
00282     InternalClear();
00283     vt = VT_UNKNOWN;
00284     punkVal = pSrc;
00285
00286     // Need to AddRef as VariantClear will Release
00287     if (punkVal != NULL)
00288       punkVal->AddRef();
00289     return *this;
00290   }
00291
00292
00293 // Comparison Operators
00294 public:
00295   bool operator==(const VARIANT& varSrc) const
00296   {
00297     if (this == &varSrc)
00298       return true;
00299
00300     // Variants not equal if types don't match
00301     if (vt != varSrc.vt)
00302       return false;
00303
00304     // Check type specific values
00305     switch (vt)
00306     {
00307       case VT_EMPTY:
00308       case VT_NULL:
00309         return true;
00310
00311       case VT_BOOL:
00312         return boolVal == varSrc.boolVal;
00313
00314       case VT_UI1:
00315         return bVal == varSrc.bVal;
00316
00317       case VT_I2:
00318         return iVal == varSrc.iVal;
00319
00320       case VT_I4:
00321         return lVal == varSrc.lVal;
00322
00323       case VT_R4:
00324         return fltVal == varSrc.fltVal;
00325
00326       case VT_R8:
00327         return dblVal == varSrc.dblVal;
00328
00329       case VT_BSTR:
00330         return (::SysStringByteLen(bstrVal) == ::SysStringByteLen(varSrc.bstrVal)) &&
00331             (::memcmp(bstrVal, varSrc.bstrVal, ::SysStringByteLen(bstrVal)) == 0);
00332
00333       case VT_ERROR:
00334         return scode == varSrc.scode;
00335
00336       case VT_DISPATCH:
00337         return pdispVal == varSrc.pdispVal;
00338
00339       case VT_UNKNOWN:
00340         return punkVal == varSrc.punkVal;
00341
00342       default:
00343         ATLASSERT(false);
00344         // fall through
00345     }
00346
00347     return false;
00348   }
00349 //  bool operator!=(const VARIANT& varSrc) const {return !operator==(varSrc);}
00350 //  bool operator<(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT)==VARCMP_LT;}
00351 //  bool operator>(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT)==VARCMP_GT;}
00352
00353 // Interim Fix for VC6 ATL
00354   bool operator!=(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)!=VARCMP_EQ;}
00355   //bool operator==(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)==VARCMP_EQ;}
00356   bool operator<(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)==VARCMP_LT;}
00357   bool operator>(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)==VARCMP_GT;}
00358
00359
00360
00361 // Operations
00362 public:
00363   HRESULT Clear()
00364   {
00365     if (vt != VT_EMPTY)
00366       return ::VariantClear(this);
00367     else
00368       return S_OK;
00369   }
00370
00371   HRESULT Copy(const VARIANT* pSrc)
00372   {
00373     return ::VariantCopy(this, const_cast<VARIANT*>(pSrc));
00374   }
00375
00376   HRESULT Attach(VARIANT* pSrc)
00377   {
00378     // Clear out the variant
00379     HRESULT hr = Clear();
00380     if (!FAILED(hr))
00381     {
00382       // Copy the contents and give control to CFastVariant
00383       memcpy(this, pSrc, sizeof(VARIANT));
00384       pSrc->vt = VT_EMPTY;
00385       hr = S_OK;
00386     }
00387     return hr;
00388   }
00389
00390   HRESULT Detach(VARIANT* pDest)
00391   {
00392     HRESULT hr = S_OK;
00393     if (pDest->vt != VT_EMPTY)
00394       hr = ::VariantClear(pDest);
00395     // Clear out the variant
00396     if (!FAILED(hr))
00397     {
00398       // Copy the contents and remove control from CFastVariant
00399       memcpy(pDest, this, sizeof(VARIANT));
00400       vt = VT_EMPTY;
00401       hr = S_OK;
00402     }
00403     return hr;
00404   }
00405
00406   HRESULT ChangeType(VARTYPE vtNew, const VARIANT* pSrc = NULL)
00407   {
00408     VARIANT* pVar = const_cast<VARIANT*>(pSrc);
00409     // Convert in place if pSrc is NULL
00410     if (pVar == NULL)
00411       pVar = this;
00412     // Do nothing if doing in place convert and vts not different
00413     return ::VariantChangeType(this, pVar, 0, vtNew);
00414   }
00415
00416   HRESULT WriteToStream(IStream* pStream);
00417   HRESULT ReadFromStream(IStream* pStream);
00418
00419 // Implementation
00420 public:
00421   HRESULT InternalClear()
00422   {
00423     HRESULT hr = Clear();
00424     ATLASSERT(SUCCEEDED(hr));
00425     if (FAILED(hr))
00426     {
00427       vt = VT_ERROR;
00428       scode = hr;
00429     }
00430     return hr;
00431   }
00432
00433   void InternalCopy(const VARIANT* pSrc)
00434   {
00435     HRESULT hr = Copy(pSrc);
00436     if (FAILED(hr))
00437     {
00438       vt = VT_ERROR;
00439       scode = hr;
00440     }
00441   }
00442 };
00443
00444 inline HRESULT CFastVariant::WriteToStream(IStream* pStream)
00445 {
00446   HRESULT hr = pStream->Write(&vt, sizeof(VARTYPE), NULL);
00447   if (FAILED(hr))
00448     return hr;
00449
00450   int cbWrite = 0;
00451   switch (vt)
00452   {
00453   case VT_UNKNOWN:
00454   case VT_DISPATCH:
00455     {
00456       CComPtr<IPersistStream> spStream;
00457       if (punkVal != NULL)
00458       {
00459         hr = punkVal->QueryInterface(IID_IPersistStream, (void**)&spStream);
00460         if (FAILED(hr))
00461           return hr;
00462       }
00463       if (spStream != NULL)
00464         return OleSaveToStream(spStream, pStream);
00465       else
00466         return WriteClassStm(pStream, CLSID_NULL);
00467     }
00468   case VT_UI1:
00469   case VT_I1:
00470     cbWrite = sizeof(BYTE);
00471     break;
00472   case VT_I2:
00473   case VT_UI2:
00474   case VT_BOOL:
00475     cbWrite = sizeof(short);
00476     break;
00477   case VT_I4:
00478   case VT_UI4:
00479   case VT_R4:
00480   case VT_INT:
00481   case VT_UINT:
00482   case VT_ERROR:
00483   case VT_NULL:
00484     cbWrite = sizeof(long);
00485     break;
00486   case VT_R8:
00487   case VT_CY:
00488   case VT_DATE:
00489     cbWrite = sizeof(double);
00490     break;
00491   default:
00492     break;
00493   }
00494   if (cbWrite != 0)
00495     return pStream->Write((void*) &bVal, cbWrite, NULL);
00496
00497   CComBSTR bstrWrite;
00498   CFastVariant varBSTR;
00499   if (vt != VT_BSTR)
00500   {
00501     hr = VariantChangeType(&varBSTR, this, VARIANT_NOVALUEPROP, VT_BSTR);
00502     if (FAILED(hr))
00503       return hr;
00504     bstrWrite = varBSTR.bstrVal;
00505   }
00506   else
00507     bstrWrite = bstrVal;
00508
00509   return bstrWrite.WriteToStream(pStream);
00510 }
00511
00512 inline HRESULT CFastVariant::ReadFromStream(IStream* pStream)
00513 {
00514   ATLASSERT(pStream != NULL);
00515   HRESULT hr = S_OK;
00516   if (vt != VT_EMPTY)
00517     hr = VariantClear(this);
00518   if (FAILED(hr))
00519     return hr;
00520   VARTYPE vtRead;
00521   hr = pStream->Read(&vtRead, sizeof(VARTYPE), NULL);
00522   if (hr == S_FALSE)
00523     hr = E_FAIL;
00524   if (FAILED(hr))
00525     return hr;
00526
00527   vt = vtRead;
00528   int cbRead = 0;
00529   switch (vtRead)
00530   {
00531   case VT_UNKNOWN:
00532   case VT_DISPATCH:
00533     {
00534       punkVal = NULL;
00535       hr = OleLoadFromStream(pStream,
00536         (vtRead == VT_UNKNOWN) ? IID_IUnknown : IID_IDispatch,
00537         (void**)&punkVal);
00538       if (hr == REGDB_E_CLASSNOTREG)
00539         hr = S_OK;
00540       return S_OK;
00541     }
00542   case VT_UI1:
00543   case VT_I1:
00544     cbRead = sizeof(BYTE);
00545     break;
00546   case VT_I2:
00547   case VT_UI2:
00548   case VT_BOOL:
00549     cbRead = sizeof(short);
00550     break;
00551   case VT_I4:
00552   case VT_UI4:
00553   case VT_R4:
00554   case VT_INT:
00555   case VT_UINT:
00556   case VT_ERROR:
00557   case VT_NULL:
00558     cbRead = sizeof(long);
00559     break;
00560   case VT_R8:
00561   case VT_CY:
00562   case VT_DATE:
00563     cbRead = sizeof(double);
00564     break;
00565   default:
00566     break;
00567   }
00568   if (cbRead != 0)
00569   {
00570     hr = pStream->Read((void*) &bVal, cbRead, NULL);
00571     if (hr == S_FALSE)
00572       hr = E_FAIL;
00573     return hr;
00574   }
00575   CComBSTR bstrRead;
00576
00577   hr = bstrRead.ReadFromStream(pStream);
00578   if (FAILED(hr))
00579     return hr;
00580   vt = VT_BSTR;
00581   bstrVal = bstrRead.Detach();
00582   if (vtRead != VT_BSTR)
00583     hr = ChangeType(vtRead);
00584   return hr;
00585 }
00586
00587 #endif
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/caccount.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

caccount.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CAccount.cpp
00003   Summary:   Implementation of Object Pooled Account component
00004   Classes:   CAccount
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #include "stdafx.h"
00023 #include "Account.h"
00024 #include <comsvcs.h>
00025 #include "CAccount.h"
00026 #include <stdio.h>
00027 #include <transact.h>
00028
00029 HRESULT CheckAmount (IObjectContext * pObjectContext, long lAmount, BSTR * s);
00030
00031 HRESULT GetConnection(WCHAR * sDSN, HENV  * phenv, HDBC * phdbc, HSTMT * phstmt, BOOL bUseObjectPool);
00032
00033 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00034   Function: GetODBCError
00035   Summary:  Call SQLError to get the error from ODBC
00036   Args:     HENV henv   An ODBC environment handle
00037       HDBC hdbc   An ODBC database connection handle
00038       HSTMT hstmt   An ODBC statement handle
00039       BSTR* sErr    Output error string
00040   Returns:  void
00041 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00042 void GetODBCError(HENV henv, HDBC hdbc, HSTMT hstmt, BSTR * sErr)
00043 {
00044   WCHAR szSqlState[64];
00045   SDWORD NativeError;
00046   WCHAR szErr[512];
00047   SWORD cbErrorMsg;
00048   SQLError(henv, hdbc, hstmt, (SQLWCHAR *)szSqlState, &NativeError, (SQLWCHAR *)szErr, 511, &cbErrorMsg);
00049   *sErr = ::SysAllocString(szErr);
00050 }
00051
00052
00053
00054 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00055   Function: GetConnection
00056   Summary:  Get the ODBC connection to SQL Server
00057   Args:     WCHAR* sDsn     ODBC DSN to connect to
00058       HENV* phEnv     An ODBC environment handle
00059       HDBC* phdbc     An ODBC database connection handle
00060       HSTMT* phstmt   An ODBC statement handle
00061       BOOL bUseObjectPool flag whether we're using COM+ pooling or not
00062   Returns:  HRESULT
00063 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00064 HRESULT GetConnection(WCHAR * sDsn, HENV  * phenv, HDBC * phdbc, HSTMT * phstmt, BOOL bUseObjectPool)
00065 {
00066
00067
00068   RETCODE rc;
00069   HRESULT hr= S_OK;
00070
00071   rc = SQLAllocEnv(phenv);
00072   ASSERT_SQL_SUCCESS(rc);
00073   if (bUseObjectPool)
00074   {
00075     rc = SQLSetEnvAttr(*phenv, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_OFF, 0);
00076     ASSERT_SQL_SUCCESS(rc);
00077   }
00078   rc = SQLAllocConnect(*phenv, phdbc);
00079   if (SQL_FAILED(rc))
00080     return E_FAIL;
00081   WCHAR szConn[255];
00082   WORD nSize = 255;
00083   rc = SQLDriverConnect(*phdbc, NULL, (SQLWCHAR *)sDsn, SQL_NTS, (SQLWCHAR *)szConn, 255, (short *)&nSize, (UWORD)SQL_DRIVER_NOPROMPT);
00084   if (SQL_FAILED(rc))
00085   {
00086     SQLFreeEnv(*phenv);
00087     return E_FAIL;
00088   }
00089   rc = SQLAllocStmt(*phdbc, phstmt); // generic stmt
00090   if (SQL_FAILED(rc))
00091   {
00092     SQLFreeConnect(*phdbc);
00093     SQLFreeEnv(*phenv);
00094
00095     return E_FAIL;
00096   }
00097
00098   return S_OK;
00099
00100 }
00101
00102
00103 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00104   Function: CAccount::InterfaceSupportsErrorInfo
00105   Summary:  Confirms or denies that an error came from IAccount interface
00106   Args:     REFIID riid     Interface ID returned in error
00107   Returns:  HRESULT
00108 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00109 STDMETHODIMP CAccount::InterfaceSupportsErrorInfo(REFIID riid)
00110 {
00111   static const IID* arr[] =
00112   {
00113     &IID_IAccount,
00114   };
00115
00116   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00117   {
00118     // refer to guiddef.h
00119     if (::InlineIsEqualGUID(*arr[i],riid))
00120       return S_OK;
00121   }
00122   return S_FALSE;
00123 }
00124
00125
00126
00127 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00128   Function: CAccount::Construct
00129   Summary:  Called by the constructor activator
00130   Args:     IDispatch *pUnk   Used to obtain construction string
00131   Returns:  HRESULT
00132   Comments: The construct string should look like
00133       "FILEDSN=OPBankSamples;DATABASE=pubs;UID=sa;PWD=;APP=OPBank"
00134       If '/NP' is in the string, COM+ pooling will not be active
00135 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00136 STDMETHODIMP CAccount::Construct(IDispatch * pUnk)
00137 {
00138
00139   if (!pUnk)
00140     return E_UNEXPECTED;
00141   HRESULT hr;
00142   IObjectConstructString * pString = NULL;
00143   hr = pUnk -> QueryInterface(IID_IObjectConstructString, (void **)&pString);
00144   if (pString)
00145   {
00146     CComBSTR s;
00147     pString -> get_ConstructString(&s);
00148     WCHAR * p = wcsstr(s.m_str, L"/NP");
00149     if (p)
00150     {
00151       m_bObjectPooled = FALSE;
00152       *p = NULL;
00153     }
00154     else
00155       m_bObjectPooled = TRUE;
00156
00157     m_sDSN = s;
00158     pString -> Release();
00159     hr = GetConnection(m_sDSN.m_str, &m_henv, &m_hdbc, &m_hstmt, m_bObjectPooled);
00160     if (FAILED(hr))
00161     {
00162       BSTR sResult;
00163       GetODBCError(m_henv, m_hdbc, NULL, &sResult);
00164       AtlReportError( CLSID_CUpdateReceipt, sResult, IID_IAccount, hr);
00165       SysFreeString(sResult);
00166       return hr;
00167     }
00168   }
00169
00170   m_bConstructed = TRUE;
00171
00172   return hr;
00173
00174 }
00175
00176
00177 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00178   Function: CAccount::Post
00179   Summary:  Modifies an account by a certain amount
00180   Args:     long lAccount   The account to modify
00181       long lAmount    Amount to modify the account by
00182       BSTR* pbstrResult Informational string (NULL if error)
00183   Returns:  HRESULT       S_OK or E_FAIL
00184 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00185 STDMETHODIMP CAccount::Post (IN long lAccount, IN long lAmount, OUT BSTR* pbstrResult) {
00186
00187   HRESULT hr = S_OK;
00188   *pbstrResult = NULL;
00189   IObjectContext* pObjectContext = NULL;
00190
00191   if (!m_bConstructed)
00192   {
00193     m_sDSN = L"FILEDSN=OPBankSamples;DATABASE=pubs;UID=sa;PWD=;APP=OPBank";
00194     hr = GetConnection(m_sDSN.m_str, &m_henv, &m_hdbc, &m_hstmt, FALSE);
00195     if (FAILED(hr))
00196     {
00197       BSTR sResult;
00198       GetODBCError(m_henv, m_hdbc, NULL, &sResult);
00199       AtlReportError( CLSID_CAccount, sResult, IID_IAccount, hr);
00200       SysFreeString(sResult);
00201       return hr;
00202     }
00203   }
00204
00205   long lErrFlag = 0;
00206   hr = CoGetObjectContext(IID_IObjectContext, (void**)&pObjectContext);
00207   if (!pObjectContext)
00208   {
00209     AtlReportError( CLSID_CAccount, "No Object Context", IID_IAccount, hr);
00210     return hr;
00211   }
00212
00213   hr = CheckAmount(pObjectContext, lAmount, pbstrResult);
00214   if (FAILED(hr))
00215   {
00216     pObjectContext -> SetAbort();
00217     SafeRelease(pObjectContext);
00218     AtlReportError( CLSID_CAccount, *pbstrResult, IID_IAccount, hr);
00219     SysFreeString(*pbstrResult);
00220     return hr;
00221   }
00222
00223   _ASSERTE(m_henv);
00224   hr = DoWork(lAccount, lAmount, pbstrResult);
00225   if (SUCCEEDED(hr))
00226   {
00227     pObjectContext -> SetComplete();
00228   }
00229   else
00230   {
00231     pObjectContext -> SetAbort();
00232     AtlReportError( CLSID_CAccount, *pbstrResult, IID_IAccount, hr);
00233     SysFreeString(*pbstrResult);
00234   }
00235
00236
00237   // (03.22.00 mdl) Release connection if object is not pooled.
00238   if (!m_bObjectPooled)
00239   {
00240     FinalRelease();
00241   }
00242
00243   SafeRelease(pObjectContext);
00244   return hr;
00245 }
00246
00247
00248
00249 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00250   Function: CheckAmount
00251   Summary:
00252   Args:     IObjectContext* pObjectContext  Pointer to ObjectContext
00253       long lAmount          Amount to modify the account by
00254       BSTR* s             Informational string (NULL if error)
00255   Returns:  HRESULT             S_OK or E_FAIL
00256 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00257 HRESULT CheckAmount(IObjectContext * pObjectContext, long lAmount, BSTR * s)
00258 {
00259
00260   if (!pObjectContext)
00261   {
00262     *s = ::SysAllocString(L"No Context");
00263     return E_FAIL;
00264   }
00265   // Check security for large transfers
00266   if (lAmount > 500 || lAmount < -500)
00267   {
00268     BOOL bInRole;
00269     BSTR bstrRole;
00270
00271     bstrRole = ::SysAllocString(L"Managers");
00272     HRESULT hr;
00273     hr = pObjectContext->IsCallerInRole (bstrRole, &bInRole);
00274     ::SysFreeString(bstrRole);
00275
00276     if (FAILED( hr ))
00277     {
00278       *s = ::SysAllocString(L"IsCallerInRole() call failed!  Please add the 'Managers' Roll to the package.");
00279       return hr;
00280     }
00281
00282     if (!bInRole)
00283     {
00284       *s = ::SysAllocString(L"Need 'Managers' role for amounts over $500");
00285       return  E_FAIL;
00286     }
00287   }
00288   return S_OK;
00289 }
00290
00291
00292 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00293   Function: CAccount::DoWork
00294   Summary:  Get current balance, check for overdraft, and update new balance
00295   Args:     long lAccount   The account to modify
00296       long lAmount    Amount to modify the account by
00297       BSTR* pbstrResult Informational string
00298   Returns:  HRESULT       S_OK
00299                 E_UNEXPECTED (ODBC Error)
00300                 E_FAIL (other error, ie overdrawn)
00301 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00302 HRESULT CAccount::DoWork(long lAccount, long lAmount, BSTR *pbstrResult)
00303 {
00304
00305   WCHAR szBuffer[512];
00306   RETCODE rc;
00307   long lBal = 0;
00308   long len = 0;
00309   HRESULT hr = S_OK;
00310
00311   if (m_bShouldEnlist)
00312   {
00313     //
00314     // NOTE: I know I call SetComplete, so I don't have to set
00315     //       the m_bShouldEnlist flag to FALSE after I enlist
00316     //
00317     hr = Enlist();
00318     if (FAILED(hr))
00319       return hr;
00320   }
00321
00322   ZeroMemory(szBuffer, 512 * sizeof (WCHAR));
00323   wsprintf(szBuffer, L"update VcAccount set balance = balance + %ld where AccountNo = %ld", lAmount, lAccount);
00324   rc = SQLExecDirect(m_hstmt, szBuffer, SQL_NTS);
00325   if (SQL_FAILED(rc))
00326   {
00327     GetODBCError(m_henv, m_hdbc, m_hstmt, pbstrResult);
00328     return E_UNEXPECTED;
00329
00330   }
00331
00332   long nRowsAffected;
00333   rc = SQLRowCount( m_hstmt, &nRowsAffected);
00334   if (nRowsAffected == 0)
00335   {
00336     wsprintf (szBuffer, L"account %ld not on file. (VC++ ODBC)", lAccount);
00337     *pbstrResult = SysAllocString(szBuffer);
00338     return E_FAIL;
00339   }
00340
00341   wsprintf (szBuffer, L"SELECT Balance FROM VcAccount WHERE AccountNo = %ld", lAccount);
00342
00343
00344   rc = SQLExecDirect(m_hstmt, szBuffer, SQL_NTS);
00345   if (SQL_FAILED(rc))
00346   {
00347     GetODBCError(m_henv, m_hdbc, m_hstmt, pbstrResult);
00348     return E_UNEXPECTED;
00349
00350   }
00351   while (SQLFetch(m_hstmt) == SQL_SUCCESS) // only get the first one for now
00352   {
00353
00354     rc = SQLGetData(m_hstmt, 1, SQL_C_LONG, &lBal, 0, &len);
00355   }
00356
00357   // Check for overdraw, then prepare return string
00358   if (lBal < 0)
00359   {
00360
00361     wsprintf (szBuffer, L"Error. Account %ld would be overdrawn by %ld.  Balance is still %ld",
00362         lAccount, -lBal, lBal - lAmount);
00363
00364     *pbstrResult = ::SysAllocString(szBuffer);
00365     return E_FAIL;
00366   }
00367
00368   SQLFreeStmt(m_hstmt, SQL_CLOSE);
00369
00370
00371   wsprintf (szBuffer, L"%s account %ld, balance is $%ld. (VC++ ODBC)",
00372       lAmount >= 0 ? L"Credit to" : L"Debit from", lAccount, lBal);
00373
00374   *pbstrResult = SysAllocString(szBuffer);
00375
00376   return S_OK;
00377 }
00378
00379
00380 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00381   Function: CAccount::FinalRelease
00382   Summary:  Free up ODBC connection
00383   Returns:  void
00384 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00385 void CAccount::FinalRelease()
00386 {
00387   if (m_hstmt)
00388     SQLFreeStmt(m_hstmt, SQL_DROP);
00389   if (m_hdbc)
00390   {
00391     SQLDisconnect(m_hdbc);
00392     SQLFreeConnect(m_hdbc);
00393   }
00394   if (m_henv)
00395     SQLFreeEnv(m_henv);
00396
00397   m_hstmt = 0;
00398   m_henv = 0;
00399   m_hdbc = 0;
00400 }
00401
00402
00403 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00404   Function: CAccount::Activate
00405   Summary:  On activation, get the transaction (unit of work).  If the same
00406       transaction as before, no need to enlist.  Otherwise, set a flag
00407       to re-enlist in the transaction.  If configured not to use COM+
00408       pooling, immediately return.
00409   Returns:  HRESULT
00410 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00411 STDMETHODIMP CAccount::Activate()
00412 {
00413
00414   //  should only do this when we are being activated in different
00415   //  tx units of work
00416   m_bShouldEnlist = FALSE;
00417
00418   if (!m_bObjectPooled)
00419     return S_OK;
00420
00421   HRESULT hr;
00422   IObjectContext * pObjectContext = NULL;
00423   hr = CoGetObjectContext(IID_IObjectContext, (void**)&pObjectContext);
00424   _ASSERTE(pObjectContext);
00425   GUID txUOW = GUID_NULL;
00426   IObjectContextInfo  * pObjTx = NULL;
00427   pObjectContext -> QueryInterface(IID_IObjectContextInfo, (void **)&pObjTx);
00428   if (pObjTx)
00429   {
00430     pObjTx -> GetTransactionId (&txUOW);
00431     pObjTx -> Release();
00432   }
00433   pObjectContext -> Release();
00434
00435   if (txUOW != m_txuow)
00436   {
00437     m_bShouldEnlist = TRUE;
00438     m_txuow = txUOW;
00439
00440   }
00441
00442   return S_OK;
00443
00444 }
00445
00446
00447 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00448   Function: CAccount::Enlist
00449   Summary:  Enlists ODBC in the current transaction
00450   Returns:  HRESULT
00451 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00452 HRESULT CAccount::Enlist()
00453 {
00454   HRESULT hr;
00455   IObjectContext * pObjectContext = NULL;
00456   hr = CoGetObjectContext(IID_IObjectContext, (void**)&pObjectContext);
00457   _ASSERTE(pObjectContext);
00458
00459   IObjectContextInfo  * pObjTx = NULL;
00460   pObjectContext -> QueryInterface(IID_IObjectContextInfo, (void **)&pObjTx);
00461   pObjectContext -> Release();
00462   if (pObjTx)
00463   {
00464     ITransaction * pTx = NULL;
00465     pObjTx -> GetTransaction ((IUnknown **)&pTx);
00466     RETCODE rc ;
00467     if (pTx)
00468     {
00469       rc = SQLSetConnectOption(m_hdbc, SQL_ATTR_ENLIST_IN_DTC, (UDWORD)pTx);
00470       if (SQL_FAILED(rc))
00471       {
00472 #ifdef _DEBUG
00473         BSTR sErr;
00474         GetODBCError(m_henv, m_hdbc, m_hstmt, &sErr);
00475         AtlTrace(L"Warning! Failed to enlist on caller tx in VCAccount!\n");
00476         AtlTrace(L"ODBC Error: ");
00477         AtlTrace(sErr);
00478         AtlTrace(L"\n");
00479         SysFreeString(sErr);
00480 #endif
00481         hr = E_FAIL;
00482       }
00483
00484       pTx -> Release();
00485     }
00486
00487     pObjTx -> Release();
00488   }
00489
00490   return hr;
00491 }
00492
00493
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/DynDlg/DynDlg.h Source File

  • WinUI
  • Resource
  • DynDlg

DynDlg.h

Go to the documentation of this file.
00001
00002
00003 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
00004
00005 #define IDM_EXIT        101
00006 #define IDM_DIALOG1     201
00007 #define IDM_DIALOG2     202
00008 #define IDM_HELP        301
00009 #define IDM_ABOUT       302
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CUtilComPtr< T > Member List

This is the complete list of members for CUtilComPtr< T >, including all inherited members.
CUtilComPtr() | CUtilComPtr< T > | [inline]
Detach() | CUtilComPtr< T > | [inline]
m_p | CUtilComPtr< T > | [private]
operator T *() | CUtilComPtr< T > | [inline]
operator&() | CUtilComPtr< T > | [inline]
~CUtilComPtr() | CUtilComPtr< T > | [inline]
Generated on Wed Nov 13 2024 16:57:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCNotify/Notify.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCNotify

Notify.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Notify.cpp
00003   Summary:   Implementation of CONotify class
00004   Classes:   Implemented: CONotify
00005        Used: ADO  CLSID_ADOConnection
00006        Used: COM+ ObjectContext
00007   Methods:   put_CustomerId
00008        put_OrderId
00009        LineItem
00010        ProcessOrder
00011 -----------------------------------------------------------------------------
00012
00013 This file is part of the Microsoft COM+ Samples.
00014
00015 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00016
00017 This source code is intended only as a supplement to Microsoft
00018 Development Tools and/or on-line documentation. See these other
00019 materials for detailed information regarding Microsoft code samples.
00020
00021 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00022 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00023 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00024 PARTICULAR PURPOSE.
00025
00026 ==========================================================================+*/
00027
00028 #include "stdafx.h"
00029 #include "..\DataSourceNames.h" // ADO Data Source Names, userid, password
00030 #include <adoid.h>    // ADO from OLEDBSDK
00031 #include <adoint.h>   // ADO from OLEDBSDK
00032 #include "QCNotify.h" // MIDL output from QCNotify.idl
00033 #include "Notify.h"   // Class header
00034 #include "..\QCOrder\processFlags.h"  // process flag descriptions
00035
00036 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00037   Method:   CONotify::put_CustomerId
00038   Summary:  property put for CustomerId property
00039   Args:     long lCustomerId      A customer identifier.
00040   Modifies: class member variable m_lCustomerId
00041   Returns:  HRESULT - Always returns S_OK
00042 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00043
00044 STDMETHODIMP CONotify::put_CustomerId(long lCustomerId)
00045 {
00046   m_lCustomerId = lCustomerId;
00047   return S_OK;
00048 }
00049
00050 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00051   Method:   CONotify::put_OrderId
00052   Summary:  property put for OrderId property
00053   Args:     long lOrderId     An order identifier.
00054   Modifies: class member variable m_lOrderId
00055   Returns:  HRESULT - Always returns S_OK
00056 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00057
00058 STDMETHODIMP CONotify::put_OrderId(long lOrderId)
00059 {
00060   m_lOrderId = lOrderId;
00061   return S_OK;
00062 }
00063
00064 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00065   Method:   CONotify::LineItem
00066   Summary:  Adds a single item to an order
00067   Args:     long lItemId      An item identifier (e.g. stock number)
00068       long lQuantity      Quantity of the item ordered
00069       ShipStatus shipStatus Shipping Status (see QCSamp1.idl)
00070   Modifies: class members m_veclItemId, m_veclQuantity, m_vecShipStatus
00071   Returns:  HRESULT - Always returns S_OK
00072 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00073
00074 STDMETHODIMP CONotify::LineItem(long lItemId, long lQuantity, ShipStatus shipStatus)
00075 {
00076   _ASSERTE(shipStatus >= ssShipped && shipStatus <= ssUnrecognizedItem);
00077
00078   m_veclItemId.push_back(lItemId);
00079   m_veclQuantity.push_back(lQuantity);
00080   m_vecShipStatus.push_back(shipStatus);
00081   return S_OK;
00082 }
00083
00084 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00085   Method:   CONotify::Process
00086   Summary:  Updates order entry database with shipping status strings.
00087   Args:     long  lFlags - option flag bits
00088   Modifies: Rows in order entry database (DSN = QCSampOrder)
00089       Issues COM+ SetComplete or SetAbort depending on request success.
00090   Returns:  HRESULT - returns failure from embedded function requests or S_OK.
00091 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00092
00093 STDMETHODIMP CONotify::Process(long lFlags)
00094 {
00095   HRESULT hr = S_OK;
00096
00097   _RPT1(_CRT_WARN, "QCSamp1 %d Notify\n", m_lOrderId);
00098
00099   if (lFlags & processFlagWriteDB)
00100   {
00101     CComPtr<ADOConnection> pADOConnection;
00102
00103     hr = CoCreateInstance(  CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,
00104                 IID_IADOConnection, (void **) &pADOConnection);
00105     if (SUCCEEDED(hr))
00106     {
00107       // Constants for Data Source Names, userid, password are in DataSourceName.h
00108
00109       hr = pADOConnection->Open(  _bstr_t(pszOrderDSN), _bstr_t(pszUserId),
00110                     _bstr_t(pszPassword), adOpenUnspecified);
00111
00112       TCHAR szSQLStmt[512];
00113
00114       // The elements in this array correspond to the ShipStatus enumeration
00115       LPCTSTR const apszShipStatus[] =
00116       {
00117         _T("Not yet processed"),
00118         _T("Shipped"),
00119         _T("Back Ordered"),
00120         _T("Not Stocked"),
00121         _T("Unrecognized Item ID")
00122       };
00123
00124       LPCTSTR const pszPrototypeSQLStmt =
00125         _T("update QCSampleOrder set ship_status = \'%s\' ")
00126         _T(" where order_id = %ld ")
00127         _T("   and cust_id  = %ld ")
00128         _T("   and line_no  = %ld ")
00129         _T("   and item_id  = %ld ")
00130         _T("   and quantity = %ld ");
00131
00132       for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00133       {
00134         wsprintf( szSQLStmt,
00135               pszPrototypeSQLStmt,
00136               apszShipStatus[m_vecShipStatus[ix]],
00137               m_lOrderId,
00138               m_lCustomerId,
00139               ix,
00140               m_veclItemId[ix],
00141               m_veclQuantity[ix]);
00142
00143         hr = pADOConnection->Execute(_bstr_t(szSQLStmt), NULL, adCmdText, NULL);
00144       }
00145     }
00146   }
00147   // Invoke SetComplete or SetAbort depending on our success
00148
00149   CComPtr<IObjectContext> pIObjectContext;
00150
00151   if (SUCCEEDED(CoGetObjectContext(IID_IObjectContext, (void**)&pIObjectContext)))
00152   {
00153     if (SUCCEEDED(hr))  pIObjectContext->SetComplete();
00154     else        pIObjectContext->SetAbort();
00155   }
00156
00157   return hr;
00158 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Cap/Error.Cpp Source File

  • Web
  • MSAgent
  • c
  • Cap

Error.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 #include "stdafx.h"
00045 #include "Error.h"
00046
00047
00048 extern const LPTSTR kpszAppTitle;
00049
00050
00051 // Production code would expand this to report Agent errors
00052
00053 void SystemError(HWND hWndParent, HRESULT hRes, BOOL bWarning) {
00054
00055   LPVOID lpMsgBuf;
00056   DWORD dwRes;
00057   UINT uFlags = MB_OK | MB_TOPMOST;
00058
00059   if (bWarning)
00060     uFlags |= MB_ICONEXCLAMATION;
00061   else
00062     uFlags |= MB_ICONERROR;
00063
00064   dwRes = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00065               NULL,
00066               hRes,
00067               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00068               (LPTSTR)&lpMsgBuf,
00069               0,
00070               NULL);
00071
00072   if (dwRes == 0) {
00073     MessageBox(hWndParent, _T("Unknown error, code = 0x%x"), kpszAppTitle, uFlags);
00074   }
00075   else {
00076     MessageBox(hWndParent, (LPTSTR)lpMsgBuf, kpszAppTitle, uFlags);
00077     LocalFree(lpMsgBuf);
00078   }
00079 }
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ClientContext Member List

This is the complete list of members for _ClientContext, including all inherited members.
addressFamily | _ClientContext
delay | _ClientContext
loopCount | _ClientContext
nBytesRecd | _ClientContext
nBytesRemainingToBeSent | _ClientContext
pRecvBuf | _ClientContext
pSendBuf | _ClientContext
recvBufSize | _ClientContext
scenario | _ClientContext
sendBufSize | _ClientContext
sock | _ClientContext
szPort | _ClientContext
szServer | _ClientContext
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/space.h Source File

  • SysMgmt
  • MMC
  • ActiveX

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include <mmc.h>
00024 #include "DeleBase.h"
00025
00026 class CRocket : public CDelegationBase {
00027 public:
00028     CRocket(CComponentData *pComponentData = NULL);
00029
00030     virtual ~CRocket();
00031
00032     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00033     virtual const GUID & getNodeType() { return thisGuid; }
00034     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00035
00036     void Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload);
00037
00038 private:
00039     // {29743810-4C4B-11d2-89D8-000021473128}
00040     static const GUID thisGuid;
00041
00042     _TCHAR *szName;
00043     LONG   lWeight;
00044     LONG   lHeight;
00045     LONG   lPayload;
00046     enum {RUNNING, PAUSED, STOPPED} iStatus;
00047 };
00048
00049 class CSpaceVehicle : public CDelegationBase {
00050 public:
00051     CSpaceVehicle(CComponentData *pComponentData = NULL);
00052
00053     virtual ~CSpaceVehicle();
00054
00055     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00056     virtual const GUID & getNodeType() { return thisGuid; }
00057     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00058
00059     virtual HRESULT Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00060
00061 private:
00062     enum { IDM_NEW_SPACE = 4 };
00063
00064     // {29743810-4C4B-11d2-89D8-000021473128}
00065     static const GUID thisGuid;
00066
00067 private:
00068
00069     enum { NUMBER_OF_CHILDREN = 4 };
00070     CRocket *children[NUMBER_OF_CHILDREN];
00071 };
00072
00073 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMShare/cShare.Cpp Source File

  • Web
  • NetMeeting
  • NMShare

cShare.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMSHARE.EXE
00003 //  File:       CSHARE.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 INmChannelAppShare * g_pChannelAppShare = NULL;
00018 CAppShareNotify * g_pNotifyAppShare = NULL;
00019
00020
00021 //****************************************************************************
00022 //
00023 // HRESULT HookChannel(INmChannel * pChannel)
00024 //
00025 //****************************************************************************
00026
00027 HRESULT HookChannel(INmChannel * pChannel)
00028 {
00029   HRESULT hr = S_OK;
00030   CAppShareNotify * pNotify = NULL;
00031   INmChannelAppShare * pChannelAs = NULL;
00032
00033   ASSERT(NULL != pChannel);
00034
00035   if (NULL == pChannel)
00036   {
00037     hr = ERROR_INVALID_PARAMETER;
00038     return hr;
00039   }
00040
00041   hr = pChannel->QueryInterface(IID_INmChannelAppShare, (void **)&pChannelAs);
00042   if (FAILED(hr))
00043   {
00044     // Not an app sharing channel
00045     return hr;
00046   }
00047   if (NULL != g_pChannelAppShare)
00048   {
00049     g_pChannelAppShare->Release();
00050     g_pChannelAppShare = NULL;
00051   }
00052   g_pChannelAppShare = pChannelAs;
00053   // keep QI ref around
00054
00055     // Connect to the channel object
00056     pNotify = new CAppShareNotify();
00057     if (pNotify == NULL)
00058     {
00059         hr = E_OUTOFMEMORY;
00060     }
00061     else
00062     {
00063     hr = pNotify->Connect(g_pChannelAppShare);
00064     if (FAILED(hr))
00065     {
00066       pNotify->Release();
00067     }
00068     else
00069     {
00070       g_pNotifyAppShare = pNotify;
00071     }
00072   }
00073
00074   if (FAILED(hr))
00075   {
00076     g_pChannelAppShare->Release();
00077     g_pChannelAppShare = NULL;
00078   }
00079   else
00080   {
00081     DoEnumApps();
00082   }
00083
00084   return hr;
00085 }
00086
00087
00088 //****************************************************************************
00089 //
00090 // HRESULT HookChannel(INmChannel * pChannel)
00091 //
00092 //****************************************************************************
00093
00094 VOID UnHookChannel(INmChannel * pChannel)
00095 {
00096   if (NULL == pChannel)
00097     return;
00098
00099   if (NULL == g_pChannelAppShare)
00100     return;
00101
00102   if (S_OK != g_pChannelAppShare->IsSameAs(pChannel))
00103     return;
00104
00105   FreeAppShareChannel();
00106 }
00107
00108
00109 //****************************************************************************
00110 //
00111 // VOID FreeAppShareChannel(void)
00112 //
00113 //****************************************************************************
00114
00115 VOID FreeAppShareChannel(void)
00116 {
00117   // Release all notify
00118   if (NULL != g_pNotifyAppShare)
00119   {
00120     g_pNotifyAppShare->Disconnect();
00121     g_pNotifyAppShare->Release();
00122     g_pNotifyAppShare = NULL;
00123   }
00124
00125   if (NULL != g_pChannelAppShare)
00126   {
00127     g_pChannelAppShare->Release();
00128     g_pChannelAppShare = NULL;
00129   }
00130 }
00131
00132
00133 //****************************************************************************
00134 //
00135 // CLASS CAppShareNotify
00136 //
00137 //****************************************************************************
00138
00139 CAppShareNotify::CAppShareNotify() : RefCount(), CNotify()
00140 {
00141 }
00142
00143 CAppShareNotify::~CAppShareNotify()
00144 {
00145 }
00146
00147
00148 //****************************************************************************
00149 //
00150 // Methods from IUnknown
00151 //
00152 //****************************************************************************
00153
00154 ULONG STDMETHODCALLTYPE CAppShareNotify::AddRef(void)
00155 {
00156   return RefCount::AddRef();
00157 }
00158
00159
00160 ULONG STDMETHODCALLTYPE CAppShareNotify::Release(void)
00161 {
00162   return RefCount::Release();
00163 }
00164
00165 HRESULT STDMETHODCALLTYPE CAppShareNotify::QueryInterface(REFIID riid, PVOID *ppvObject)
00166 {
00167   if (NULL == ppvObject)
00168   {
00169     return E_POINTER;
00170   }
00171
00172   HRESULT hr = S_OK;
00173
00174   if (riid == IID_IUnknown)
00175   {
00176     *ppvObject = (IUnknown *)this;
00177   }
00178   else if (riid == IID_INmChannelAppShareNotify)
00179   {
00180     *ppvObject = (INmChannelAppShareNotify *)this;
00181   }
00182   else
00183   {
00184     hr = E_NOINTERFACE;
00185     *ppvObject = NULL;
00186   }
00187
00188   if (S_OK == hr)
00189   {
00190     AddRef();
00191   }
00192
00193   return hr;
00194 }
00195
00196
00197 //****************************************************************************
00198 //
00199 // Methods from ICNotify
00200 //
00201 //****************************************************************************
00202
00203 HRESULT STDMETHODCALLTYPE CAppShareNotify::Connect(IUnknown *pUnk)
00204 {
00205   return CNotify::Connect(pUnk, IID_INmChannelAppShareNotify, (IUnknown *)this);
00206 }
00207
00208 HRESULT STDMETHODCALLTYPE CAppShareNotify::Disconnect(void)
00209 {
00210   return CNotify::Disconnect();
00211 }
00212
00213
00214 //****************************************************************************
00215 //
00216 // Methods from INmChannelNotify
00217 //
00218 //****************************************************************************
00219
00220 HRESULT STDMETHODCALLTYPE CAppShareNotify::NmUI(CONFN uNotify)
00221 {
00222   LPTSTR psz;
00223
00224   switch (uNotify)
00225   {
00226     case CONFN_CLICK_CONTROL:
00227       psz = TEXT("Click: requesting control");
00228       break;
00229     case CONFN_CLICK_OBSCURE:
00230       psz = TEXT("Click: obscured area");
00231       break;
00232     case CONFN_CLICK_REMOTE_NOT_COLLABORATING:
00233       psz = TEXT("Click: Remote not collaborating");
00234       break;
00235     case CONFN_CLICK_LOCAL_NOT_COLLABORATING:
00236       psz = TEXT("Click: Local not collaborating");
00237       break;
00238     default:
00239       psz = TEXT("Unknown confn");
00240       break;
00241   }
00242
00243   DisplayMsg(psz);
00244
00245   return S_OK;
00246 }
00247
00248
00249 HRESULT STDMETHODCALLTYPE CAppShareNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
00250 {
00251   PUSER pUser = PUserFromINmMember(pMember);
00252   if (NULL != pUser)
00253   {
00254 //    UpdateUserChannel(pUser, (INmChannel *) (CNotify::GetPunk()), uNotify);
00255 #ifdef DEBUG
00256     TCHAR szMsg[MAX_PATH + 1];
00257     ZeroMemory(szMsg,(MAX_PATH + 1) * sizeof(TCHAR));
00258     _sntprintf(szMsg,MAX_PATH,TEXT("%s changed sharing status"), pUser->pszName);
00259
00260     //TCHAR szMsg[MAX_PATH];
00261     //wsprintf(szMsg, TEXT("%s changed sharing status"), pUser->pszName);
00262     DisplayMsg(szMsg);
00263 #endif
00264
00265     if (S_OK == pMember->IsSelf())
00266     {
00267       NM_SHARE_STATE uState;
00268       if (SUCCEEDED(pMember->GetShareState(&uState)))
00269       {
00270         SetMenuCheck(IDM_WORK_ALONE,  (NM_SHARE_WORKING_ALONE == uState));
00271         SetMenuCheck(IDM_COLLABORATE, (NM_SHARE_COLLABORATING == uState)
00272           || (NM_SHARE_IN_CONTROL == uState));
00273         SetMenuCheck(IDM_IN_CONTROL,  (NM_SHARE_IN_CONTROL == uState));
00274
00275 #ifdef DEBUG
00276         switch (uState)
00277         {
00278           case NM_SHARE_WORKING_ALONE: DisplayMsg(TEXT("Working Alone"));       break;
00279           case NM_SHARE_COLLABORATING: DisplayMsg(TEXT("Collaborating"));       break;
00280           case NM_SHARE_IN_CONTROL:    DisplayMsg(TEXT("In Control"));          break;
00281           default:                     DisplayMsg(TEXT("Uknown Share State?")); break;
00282         }
00283 #endif
00284       }
00285     }
00286     else
00287     {
00288 #ifdef DEBUG
00289       NM_SHARE_STATE uState;
00290       if (SUCCEEDED(pMember->GetShareState(&uState)))
00291       {
00292         LPTSTR pszState = TEXT("?");
00293         switch (uState)
00294         {
00295           case NM_SHARE_WORKING_ALONE: pszState = TEXT("Working Alone");       break;
00296           case NM_SHARE_COLLABORATING: pszState = TEXT("Collaborating");       break;
00297           case NM_SHARE_IN_CONTROL:    pszState = TEXT("In Control");          break;
00298           default:                     pszState = TEXT("Uknown Share State?"); break;
00299         }
00300
00301         BSTR  bstrName;
00302         if (SUCCEEDED(pMember->GetName(&bstrName)))
00303         {
00304           TCHAR sz[MAX_PATH + 1];
00305           ZeroMemory(sz,(MAX_PATH + 1) * sizeof(TCHAR));
00306           _sntprintf(sz,MAX_PATH,TEXT("%s is %s"), (LPTSTR) BTSTR(bstrName), pszState);
00307
00308
00309           //TCHAR sz[MAX_PATH];
00310           //wsprintf(sz, "%s is %s", (LPTSTR) BTSTR(bstrName), pszState);
00311           DisplayMsg(sz);
00312           SysFreeString(bstrName);
00313         }
00314       }
00315 #endif
00316     }
00317   }
00318
00319   return S_OK;
00320 }
00321
00322 HRESULT STDMETHODCALLTYPE CAppShareNotify::StateChanged(NM_SHAPP_STATE uState, INmSharableApp *pApp)
00323 {
00324   TCHAR szMsg[MAX_PATH + 1];
00325   ZeroMemory(szMsg,(MAX_PATH + 1) * sizeof(TCHAR));
00326   _sntprintf(szMsg,MAX_PATH,TEXT("%08X %s"), pApp,
00327     (NM_SHAPP_SHARED == uState) ? TEXT("Shared") : TEXT("not shared"));
00328
00329   DisplayMsg(szMsg);
00330   UpdateApp(pApp);
00331   return S_OK;
00332 }
00333
00334
00335 VOID DoEnumApps(void)
00336 {
00337   HRESULT hr = S_OK;
00338   ULONG cFetched = 0;
00339   IEnumNmSharableApp * pEnum = NULL;
00340   INmSharableApp * pApp = NULL;
00341
00342   if (NULL == g_pChannelAppShare)
00343     return;
00344
00345   hr = g_pChannelAppShare->EnumSharableApp(&pEnum);
00346   if (FAILED(hr))
00347   {
00348       return;
00349   }
00350
00351   for ( ; ; )
00352   {
00353     hr = pEnum->Next(1, &pApp, &cFetched);
00354     if (S_OK != hr)
00355       break;
00356
00357     UpdateApp(pApp);
00358     pApp->Release();
00359   }
00360
00361   pEnum->Release();
00362 }
00363
00364
00365 VOID DoWorkAlone(void)
00366 {
00367   if (NULL == g_pChannelAppShare)
00368     return;
00369
00370   HRESULT hr = g_pChannelAppShare->SetState(NM_SHARE_WORKING_ALONE);
00371 }
00372
00373 VOID DoCollaborate(void)
00374 {
00375   if (NULL == g_pChannelAppShare)
00376     return;
00377
00378   HRESULT hr = g_pChannelAppShare->SetState(NM_SHARE_COLLABORATING);
00379 }
00380
00381 VOID DoTakeControl(void)
00382 {
00383   if (NULL == g_pChannelAppShare)
00384     return;
00385
00386   HRESULT hr = g_pChannelAppShare->SetState(NM_SHARE_IN_CONTROL);
00387 }
00388
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/ClassProv/Utils.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • ClassProv

Utils.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  UTILS.CPP
00006
00007 //
00008
00009 //  Module: WINMGMT class provider sample code
00010
00011 //
00012
00013 //  Purpose: General purpose utilities.
00014
00015 //
00016
00017 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00018 //
00019 //***************************************************************************
00020
00021 #include <objbase.h>
00022 #include "sample.h"
00023
00024
00025 //***************************************************************************
00026 //
00027 // CreateInst
00028 //
00029 // Purpose: Creates a new instance and sets
00030 //          the inital values of the properties.
00031 //
00032 // Return:   S_OK if all is well, otherwise an error code is returned
00033 //
00034 //***************************************************************************
00035
00036 SCODE CreateInst(IWbemServices * pNamespace, LPWSTR pKey, long lVal,
00037                                         IWbemClassObject ** pNewInst,
00038                                         WCHAR * pwcClassName,
00039                     IWbemContext  *pCtx)
00040 {
00041     SCODE sc;
00042     IWbemClassObject * pClass = NULL;
00043     sc = pNamespace->GetObject(pwcClassName, 0, pCtx, &pClass, NULL);
00044     if(sc != S_OK)
00045         return WBEM_E_FAILED;
00046     sc = pClass->SpawnInstance(0, pNewInst);
00047     pClass->Release();
00048     if(FAILED(sc))
00049         return sc;
00050     VARIANT v;
00051
00052     // Set the key property value.
00053
00054     v.vt = VT_BSTR;
00055     v.bstrVal = SysAllocString(pKey);
00056   if (v.bstrVal == NULL)
00057     return WBEM_E_OUT_OF_MEMORY;
00058     sc = (*pNewInst)->Put(L"MyKey", 0, &v, 0);
00059     VariantClear(&v);
00060   if(FAILED(sc))
00061         return sc;
00062
00063     // Set the number property value.
00064
00065     v.vt = VT_I4;
00066     v.lVal = lVal;
00067     sc = (*pNewInst)->Put(L"MyValue", 0, &v, 0);
00068     return sc;
00069 }
00070
00071 SCODE CreateClass( IWbemServices * pNamespace, IWbemClassObject ** pNewClass,
00072                                              WCHAR * pwcClassName,
00073                        IWbemContext  *pCtx)
00074 {
00075
00076     SCODE sc;
00077     sc = pNamespace->GetObject(NULL, 0, pCtx, pNewClass, NULL);
00078     if(sc != S_OK)
00079         return sc;
00080
00081     VARIANT v;
00082
00083     // Set the class name.
00084
00085     v.vt = VT_BSTR;
00086     v.bstrVal = SysAllocString(pwcClassName);
00087   if (!v.bstrVal)
00088     return WBEM_E_OUT_OF_MEMORY;
00089     sc = (*pNewClass)->Put(L"__class", 0, &v, 0);
00090     VariantClear(&v);
00091
00092
00093     // Set the key property value.
00094
00095     v.vt = VT_NULL;
00096     sc = (*pNewClass)->Put(L"MyKey", 0, &v, CIM_STRING);
00097
00098     // Set the number property value.
00099
00100     sc = (*pNewClass)->Put(L"MyValue", 0, &v, CIM_SINT32);
00101
00102   // Set the key qualifier
00103
00104   IWbemQualifierSet* pQualSet = NULL;
00105
00106   sc = (*pNewClass)->GetPropertyQualifierSet(L"MyKey", &pQualSet);
00107   if(pQualSet)
00108   {
00109       v.vt = VT_BOOL;
00110     v.boolVal = VARIANT_TRUE;
00111     sc = pQualSet->Put(L"Key", &v, 0);
00112     pQualSet->Release();
00113   }
00114
00115   // Set the dynamic qualifier
00116
00117   sc = (*pNewClass)->GetQualifierSet(&pQualSet);
00118   if(pQualSet)
00119   {
00120       v.vt = VT_BOOL;
00121     v.boolVal = VARIANT_TRUE;
00122     sc = pQualSet->Put(L"Dynamic", &v, 0);
00123
00124       v.vt = VT_BSTR;
00125     v.bstrVal = SysAllocString(L"ClassProvSamp");
00126     if (v.bstrVal)
00127       sc = pQualSet->Put(L"Provider", &v, 0);
00128     else
00129       sc = WBEM_E_OUT_OF_MEMORY;
00130     VariantClear(&v);
00131
00132     pQualSet->Release();
00133   }
00134
00135     return sc;
00136
00137 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/INIT.c Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

INIT.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   init.c
00009 //
00010 //  PURPOSE:   Performs application and instance specific initialization.
00011 //
00012 //  FUNCTIONS:
00013 //    InitApplication() - Initializes window data and registers window.
00014 //
00015 //  COMMENTS:
00016 //
00017
00018 #include <windows.h>            // required for all Windows applications
00019 #include "globals.h"            // prototypes specific to this application
00020
00021 HINSTANCE hInst;                // current instance
00022
00023 char szAppName[9];              // The name of this application
00024 char szTitle[40];               // The title bar text
00025
00026
00027 //
00028 //  FUNCTION: InitApplication(HINSTANCE, int)
00029 //
00030 //  PURPOSE: Initializes window data and registers window class.
00031 //
00032 //  PARAMETERS:
00033 //    hInstance - The handle to the instance of this application that
00034 //                is currently being executed.
00035 //    nCmdShow  - Specifies how the main window is to be displayed.
00036 //
00037 //  RETURN VALUE:
00038 //    TRUE  - Success
00039 //    FALSE - Initialization failed
00040 //
00041 //  COMMENTS:
00042 //
00043 //    This function is called at application initialization time.  It
00044 //    performs initialization tasks for the current application instance.
00045 //    Unlike Win16, in Win32, each instance of an application must register
00046 //    window classes.
00047 //
00048 //    In this function, we initialize a window class by filling out a data
00049 //    structure of type WNDCLASS and calling the Windows RegisterClass()
00050 //    function.  Then we create the main window and show it.
00051 //
00052 //
00053
00054 BOOL InitApplication(HINSTANCE hInstance, int nCmdShow)
00055 {
00056     WNDCLASS  wc;
00057     HWND      hwnd; // Main window handle.
00058
00059     // Load the application name and description strings.
00060
00061     LoadString(hInstance, IDS_APPNAME, szAppName, sizeof(szAppName));
00062     LoadString(hInstance, IDS_DESCRIPTION, szTitle, sizeof(szTitle));
00063
00064     // Save the instance handle in static variable, which will be used in
00065     // many subsequence calls from this application to Windows.
00066
00067     hInst = hInstance; // Store instance handle in our global variable
00068
00069     // Fill in window class structure with parameters that describe the
00070     // main window.
00071
00072     wc.style         = CS_HREDRAW | CS_VREDRAW; // Class style(s).
00073     wc.lpfnWndProc   = (WNDPROC)WndProc;        // Window Procedure
00074     wc.cbClsExtra    = 0;                       // No per-class extra data.
00075     wc.cbWndExtra    = 0;                       // No per-window extra data.
00076     wc.hInstance     = hInstance;               // Owner of this class
00077     wc.hIcon         = LoadIcon (hInstance, szAppName); // Icon name from .RC
00078     wc.hCursor       = LoadCursor(NULL, IDC_ARROW); // Cursor
00079     wc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
00080     wc.lpszMenuName  = szAppName;               // Menu name from .RC
00081     wc.lpszClassName = szAppName;               // Name to register as
00082
00083     // Register the window class and return FALSE if unsuccesful.
00084
00085     if (!RegisterClass(&wc))
00086     {
00087         return FALSE;
00088     }
00089
00090     // Create a main window for this application instance.
00091     hwnd = CreateWindow(szAppName,           // See RegisterClass() call
00092                         szTitle,             // Text for window title bar
00093                         WS_OVERLAPPEDWINDOW, // Window style
00094                         CW_USEDEFAULT, 0,    // Use default positioning
00095                         CW_USEDEFAULT, 0,    // Use default size
00096                         NULL,                // Overlapped has no parent
00097                         NULL,                // Use the window class menu
00098                         hInstance,           // This instance owns this window
00099                         NULL                 // Don't need data in WM_CREATE
00100     );
00101
00102     // If window could not be created, return "failure"
00103     if (!hwnd)
00104         return FALSE;
00105
00106     // Make the window visible; update its client area; and return "success"
00107     ShowWindow(hwnd, nCmdShow);  // Show the window
00108     UpdateWindow(hwnd);          // Sends WM_PAINT message
00109
00110     return TRUE;                 // We succeeded...
00111 }
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Pipes/Pipe.Idl Source File

  • NetDS
  • RPC
  • Pipes

Pipe.Idl

Go to the documentation of this file.
00001 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*\
00002 |                    Copyright Microsoft Corp. 1992-1996                 |
00003 |                        Remote Machine pipe sample                      |
00004 |                                                                        |
00005 |  FILE      :   pipe.idl                                                |
00006 |                                                                        |
00007 |  PURPOSE   :   This file defines the interface for the pipe example    |
00008 |                                                                        |
00009 \*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00010 [
00011 uuid(60ceb4a0-c2f1-11cf-9556-00aa00374e69),     // UUID
00012 pointer_default(unique),                        // Pointer default
00013 version(1.0)                                    // Interface version
00014 ]
00015 interface pipe_sample
00016 {
00017 // Declare the pipe data type. This should also work for UNICODE.
00018 #ifdef _UNICODE
00019     typedef pipe wchar_t CHAR_PIPE_TYPE;
00020 #else
00021     typedef pipe unsigned char CHAR_PIPE_TYPE;
00022 #endif
00023
00024     /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00025     /* ScrambleFile - This procedure sends a file from the client to    */
00026     /*              the server, the server then "encodes" it , and the  */
00027     /*              file is sent back to the client                     */
00028     /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00029     void ScrambleFile(
00030         [in] unsigned long Action,              // Encode / Decode
00031         [in, out] CHAR_PIPE_TYPE *pipe_data);   // The file content
00032
00033
00034     /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00035     /* ShutDown - This procedure sends a message to the server that it  */
00036     /*          can stop listen for remote procedure calls              */
00037     /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00038     void ShutDown(void);            // Procedure to shut down the server
00039 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/CodePage.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

CodePage.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:   codepage.hxx
00006 //
00007 //  Contents:   Locale to codepage
00008 //
00009 //  History:    08-Jul-96     SitaramR    Created
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 #if !defined __CODEPAGE_HXX__
00014 #define __CODEPAGE_HXX__
00015
00016
00017 ULONG LocaleToCodepage( LCID lcid );
00018
00019
00020 #endif
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CNodeData Member List

This is the complete list of members for CNodeData, including all inherited members.
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CNodeData | [virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CNodeData | [virtual]
CObjData(void) | CObjData | [inline]
CObjData(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
GetHNode(void) | CNodeData | [inline]
GetHNode(void) | CNodeData | [inline]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CObjData | [inline, virtual]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CObjData | [inline, virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CObjData | [inline, virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CObjData | [inline, virtual]
HrInitialize(IUnknown *piDataIn) | CNodeData | [protected, virtual]
HrInitialize(IUnknown *piDataIn) | CNodeData | [protected, virtual]
InvokeCommand(ULONG nCommandIDIn) | CNodeData | [virtual]
InvokeCommand(ULONG nCommandIDIn) | CNodeData | [virtual]
m_cot | CObjData | [protected]
m_hNode | CNodeData | [private]
m_rgprtcPSPages | CObjData | [protected]
m_rgprtcWizPages | CObjData | [protected]
m_strName | CObjData | [protected]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
StrName(void) | CObjData | [inline, virtual]
StrName(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/Resource.h Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

Resource.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1997 - 2000
00006 //
00007 //  File:       resource.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 //{{NO_DEPENDENCIES}}
00012 // Microsoft Developer Studio generated include file.
00013 // Used by certexit.rc
00014 //
00015 #define IDS_CERTEXIT_DESC 1
00016 #define IDS_CERTMANAGEEXITMODULE_DESC 2
00017
00018
00019 // Next default values for new objects
00020 //
00021 #ifdef APSTUDIO_INVOKED
00022 #ifndef APSTUDIO_READONLY_SYMBOLS
00023 #define _APS_NEXT_RESOURCE_VALUE        201
00024 #define _APS_NEXT_COMMAND_VALUE         32768
00025 #define _APS_NEXT_CONTROL_VALUE         201
00026 #define _APS_NEXT_SYMED_VALUE           101
00027 #endif
00028 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/AppBar/Resource.h Source File

  • WinUI
  • Shell
  • AppBar

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by AppBar.rc
00004 //
00005 #define IDR_GENERIC                     101
00006 #define IDD_ABOUT                       102
00007 #define IDI_APPICON                     103
00008 #define IDD_OPTIONS                     105
00009 #define IDR_CONTEXTMENU                 106
00010 #define IDB_APPBAR                      107
00011 #define IDB_BASE                        108
00012 #define IDB_WINDOW                      109
00013 #define IDC_AUTOHIDE                    1000
00014 #define IDC_ONTOP                       1001
00015 #define IDC_PICTURE                     1002
00016 #define IDC_APPBAR                      1003
00017 #define IDC_WINDOW                      1004
00018 #define IDC_USER1                       1005
00019 #define ID_FILE_EXIT                    40001
00020 #define ID_HELP_ABOUT                   40002
00021 #define ID_APPBAR_REGISTER              40003
00022 #define ID_APPBAR_UNREGISTER            40004
00023 #define ID_APPBAR_AUTOHIDE              40005
00024 #define ID_APPBAR_NOAUTOHIDE            40006
00025 #define ID_APPBAR_TOP                   40007
00026 #define ID_APPBAR_BOTTOM                40008
00027 #define ID_APPBAR_LEFT                  40009
00028 #define ID_APPBAR_RIGHT                 40010
00029 #define ID_PROPERTIES                   40012
00030 #define IDC_STATIC                      -1
00031
00032 // Next default values for new objects
00033 //
00034 #ifdef APSTUDIO_INVOKED
00035 #ifndef APSTUDIO_READONLY_SYMBOLS
00036 #define _APS_NEXT_RESOURCE_VALUE        110
00037 #define _APS_NEXT_COMMAND_VALUE         40013
00038 #define _APS_NEXT_CONTROL_VALUE         1006
00039 #define _APS_NEXT_SYMED_VALUE           101
00040 #endif
00041 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Hello2/Notify.h Source File

  • Web
  • MSAgent
  • c
  • Hello2

Notify.h

Go to the documentation of this file.
00001 #ifndef _AgentNotifySink_h_
00002 #define _AgentNotifySink_h_
00003
00004
00005 #include "Hello2.h"
00006
00007
00008 class AgentNotifySink : public IAgentNotifySinkEx {
00009 public:
00010   AgentNotifySink() : m_cRefs(0) {}
00011    ~AgentNotifySink() {}
00012
00013     STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
00014     STDMETHODIMP_(ULONG) AddRef();
00015     STDMETHODIMP_(ULONG) Release();
00016
00017   STDMETHODIMP GetTypeInfoCount(UINT *);
00018   STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
00019   STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID, DISPID *);
00020   STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
00021
00022     STDMETHODIMP Command(long dwCommandID, IUnknown * punkUserInput);
00023     STDMETHODIMP ActivateInputState(long dwCharID, long bActivated);
00024     STDMETHODIMP Restart();
00025     STDMETHODIMP Shutdown();
00026     STDMETHODIMP VisibleState(long dwCharID, long bVisible, long lCause);
00027   STDMETHODIMP Click(long dwCharID, short fwKeys, long X, long Y);
00028   STDMETHODIMP DblClick(long dwCharID, short fwKeys, long X, long Y);
00029   STDMETHODIMP DragStart(long dwCharID, short fwKeys, long X, long Y);
00030   STDMETHODIMP DragComplete(long dwCharID, short fwKeys, long X, long Y);
00031   STDMETHODIMP RequestStart(long dwRequestID);
00032   STDMETHODIMP RequestComplete(long dwRequestID, long hrStatus);
00033   STDMETHODIMP BookMark(long dwBookMarkID);
00034     STDMETHODIMP Idle(long dwCharID, long bStart);
00035   STDMETHODIMP Move(long dwCharID, long X, long Y, long lCause);
00036   STDMETHODIMP Size(long dwCharID, long lWidth, long lHeight);
00037   STDMETHODIMP BalloonVisibleState(long dwCharID, long bVisible);
00038
00039   STDMETHODIMP HelpComplete(long dwCharID, long dwCommandID, long dwCause);
00040   STDMETHODIMP ListeningState(long dwCharacterID, long bListenState, long dwCause);
00041   STDMETHODIMP DefaultCharacterChange(BSTR bszGUID);
00042   STDMETHODIMP AgentPropertyChange();
00043   STDMETHODIMP ActiveClientChange(long dwCharID, long lStatus);
00044
00045
00046 private:
00047   ULONG m_cRefs;
00048 };
00049
00050
00051 #endif
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/addvfiledlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

addvfiledlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddVFileDlg.h:   Header for the CAddVFileDlg class.  This is a
00014 //                   modeless dialog class used to add Virtual Files.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDVFILEDLG_
00019 #define _CLASS_ADDVFILEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddVFileDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddVFileDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddVFileDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDVFILEDLG_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/DComPerm/SrvcMgmt.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • DComPerm

SrvcMgmt.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <stdio.h>
00020 #include <conio.h>
00021 #include <tchar.h>
00022 #include "ntsecapi.h"
00023 #include "dcomperm.h"
00024
00025 /*---------------------------------------------------------------------------*\
00026  * NAME: GetRunAsPassword                                                    *
00027  * --------------------------------------------------------------------------*
00028  * DESCRIPTION: Retrieves the password for the given application.            *
00029  * --------------------------------------------------------------------------*
00030  *  ARGUMENTS:                                                               *
00031  *                                                                           *
00032  *  tszAppID - The Application ID you wish to modify                         *
00033  *  (e.g. "{99999999-9999-9999-9999-00AA00BBF7C7}")                          *
00034  *                                                                           *
00035  *  tszPassword - Password of the user you have specified in the RunAs       *
00036  *  named value under the AppID registry key.                                *
00037  *                                                                           *
00038  * --------------------------------------------------------------------------*
00039  *  RETURNS: WIN32 Error Code                                                *
00040 \*---------------------------------------------------------------------------*/
00041 DWORD GetRunAsPassword (
00042     LPTSTR tszAppID,
00043     LPTSTR tszPassword
00044     )
00045 {
00046     LSA_OBJECT_ATTRIBUTES objectAttributes             = {0};
00047     HANDLE                hPolicy                      = NULL;
00048     LSA_UNICODE_STRING    lsaKeyString                 = {0};
00049     PLSA_UNICODE_STRING   lsaPasswordString            = {0};
00050     WCHAR                 wszKey [4 + GUIDSTR_MAX + 1] = {0};
00051     WCHAR                 wszAppID [GUIDSTR_MAX + 1]   = {0};
00052     DWORD                 dwReturnValue                = ERROR_SUCCESS;
00053
00054 #ifndef UNICODE
00055     STR2UNI (wszAppID, tszAppID);
00056 #else
00057     lstrcpy (wszAppID, tszAppID);
00058 #endif
00059
00060     wcsncpy (wszKey, L"SCM:", (sizeof(wszKey)/sizeof(WCHAR))-1);
00061     wcsncat (wszKey, wszAppID, (sizeof(wszKey)/sizeof(WCHAR))-5);
00062
00063     lsaKeyString.Length = (USHORT) ((wcslen (wszKey) + 1) * sizeof (WCHAR));
00064     lsaKeyString.MaximumLength = (GUIDSTR_MAX + 5) * sizeof (WCHAR);
00065     lsaKeyString.Buffer = wszKey;
00066
00067     // Open the local security policy
00068     objectAttributes.Length = sizeof (LSA_OBJECT_ATTRIBUTES);
00069
00070     dwReturnValue = LsaOpenPolicy (NULL,
00071                                  &objectAttributes,
00072                                  POLICY_GET_PRIVATE_INFORMATION,
00073                                  &hPolicy);
00074
00075     dwReturnValue = LsaNtStatusToWinError(dwReturnValue);
00076
00077     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00078
00079     // Read the user's password
00080     dwReturnValue = LsaRetrievePrivateData (hPolicy,
00081                                           &lsaKeyString,
00082                                           &lsaPasswordString);
00083
00084     dwReturnValue = LsaNtStatusToWinError(dwReturnValue);
00085
00086     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00087
00088 CLEANUP:
00089
00090     if(hPolicy) LsaClose (hPolicy);
00091
00092 #ifndef UNICODE
00093     UNI2STR (tszPassword, lsaPasswordString->Buffer);
00094 #else
00095     wcscpy (tszPassword, lsaPasswordString->Buffer);
00096 #endif
00097
00098     return dwReturnValue;
00099 }
00100
00101 /*---------------------------------------------------------------------------*\
00102  * NAME: SetRunAsPassword                                                    *
00103  * --------------------------------------------------------------------------*
00104  * DESCRIPTION: Sets the RunAs password for an AppID. Note that if you       *
00105  * have specified the RunAs named value to "Interactive User" you do not     *
00106  * need to set the RunAs password.                                           *
00107  * --------------------------------------------------------------------------*
00108  *  ARGUMENTS:                                                               *
00109  *                                                                           *
00110  *  tszAppID - The Application ID you wish to modify                         *
00111  *  (e.g. "{99999999-9999-9999-9999-00AA00BBF7C7}")                          *
00112  *                                                                           *
00113  *  tszPrincipal - Name of the principal you have specified in the RunAs     *
00114  *  named value under the AppID registry key                                 *
00115  *                                                                           *
00116  *  tszPassword - Password of the user you have specified in the RunAs       *
00117  *  named value under the AppID registry key.                                *
00118  * --------------------------------------------------------------------------*
00119  *  RETURNS: WIN32 Error Code                                                *
00120 \*---------------------------------------------------------------------------*/
00121 DWORD SetRunAsPassword (
00122     LPTSTR tszAppID,
00123     LPTSTR tszPrincipal,
00124     LPTSTR tszPassword
00125     )
00126 {
00127     LSA_OBJECT_ATTRIBUTES objectAttributes             = {0};
00128     HANDLE                hPolicy                      = NULL;
00129     LSA_UNICODE_STRING    lsaKeyString                 = {0};
00130     LSA_UNICODE_STRING    lsaPasswordString            = {0};
00131     WCHAR                 wszKey [4 + GUIDSTR_MAX + 1] = {0};
00132     WCHAR                 wszAppID [GUIDSTR_MAX + 1]   = {0};
00133     WCHAR                 wszPassword [256]            = {0};
00134     DWORD                 dwReturnValue                = ERROR_SUCCESS;
00135
00136 #ifndef UNICODE
00137     STR2UNI (wszAppID, tszAppID);
00138     STR2UNI (wszPassword, tszPassword);
00139 #else
00140     wcsncpy (wszAppID, tszAppID, (sizeof(wszAppID)/sizeof(*wszAppID))-1);
00141     wcsncpy (wszPassword, tszPassword, (sizeof(wszPassword)/sizeof(*wszPassword))-1);
00142 #endif
00143
00144     wcsncpy (wszKey, L"SCM:", (sizeof(wszKey)/sizeof(*wszKey))-1);
00145     wcsncat (wszKey, wszAppID, (sizeof(wszKey)/sizeof(*wszKey))-5);
00146
00147     lsaKeyString.Length = (USHORT) ((wcslen (wszKey) + 1) * sizeof (WCHAR));
00148     lsaKeyString.MaximumLength = (GUIDSTR_MAX + 5) * sizeof (WCHAR);
00149     lsaKeyString.Buffer = wszKey;
00150
00151     lsaPasswordString.Length = (USHORT) ((wcslen (wszPassword) + 1) * sizeof (WCHAR));
00152     lsaPasswordString.Buffer = wszPassword;
00153     lsaPasswordString.MaximumLength = lsaPasswordString.Length;
00154
00155     // Open the local security policy
00156     objectAttributes.Length = sizeof (LSA_OBJECT_ATTRIBUTES);
00157
00158     dwReturnValue = LsaOpenPolicy (NULL,
00159                                  &objectAttributes,
00160                                  POLICY_CREATE_SECRET,
00161                                  &hPolicy);
00162
00163     dwReturnValue = LsaNtStatusToWinError(dwReturnValue);
00164
00165     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00166
00167     // Store the user's password
00168     dwReturnValue = LsaStorePrivateData (hPolicy,
00169                                        &lsaKeyString,
00170                                        &lsaPasswordString);
00171
00172     dwReturnValue = LsaNtStatusToWinError(dwReturnValue);
00173
00174     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00175
00176
00177     dwReturnValue = SetAccountRights (tszPrincipal, _T("SeBatchLogonRight"));
00178     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00179
00180 CLEANUP:
00181
00182     if(hPolicy) LsaClose (hPolicy);
00183
00184     return dwReturnValue;
00185 }
00186
00187 /*---------------------------------------------------------------------------*\
00188  * NAME: SetAccountRights                                                    *
00189  * --------------------------------------------------------------------------*
00190  * DESCRIPTION: Sets the account right for a given user.                     *
00191 \*---------------------------------------------------------------------------*/
00192 DWORD SetAccountRights (
00193     LPTSTR tszUser,
00194     LPTSTR tszPrivilege
00195     )
00196 {
00197     LSA_HANDLE            hPolicy            = NULL;
00198     LSA_OBJECT_ATTRIBUTES objectAttributes   = {0};
00199     PSID                  psidPrincipal      = NULL;
00200     LSA_UNICODE_STRING    lsaPrivilegeString = {0};
00201     WCHAR                 wszPrivilege [256] = {0};
00202     DWORD                dwReturnValue       = ERROR_SUCCESS;
00203
00204 #ifdef _UNICODE
00205     lstrcpy (wszPrivilege, tszPrivilege);
00206 #else
00207     STR2UNI (wszPrivilege, tszPrivilege);
00208 #endif
00209
00210     dwReturnValue = LsaOpenPolicy (NULL,
00211                                    &objectAttributes,
00212                                    POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES,
00213                                    &hPolicy);
00214
00215     dwReturnValue = LsaNtStatusToWinError(dwReturnValue);
00216
00217     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00218
00219     dwReturnValue = GetPrincipalSID (tszUser, &psidPrincipal);
00220     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00221
00222     lsaPrivilegeString.Length = (USHORT) (wcslen (wszPrivilege) * sizeof (WCHAR));
00223     lsaPrivilegeString.MaximumLength = (USHORT) (lsaPrivilegeString.Length + sizeof (WCHAR));
00224     lsaPrivilegeString.Buffer = wszPrivilege;
00225
00226     dwReturnValue = LsaAddAccountRights (hPolicy,
00227                                          psidPrincipal,
00228                                          &lsaPrivilegeString,
00229                                          1);
00230
00231     dwReturnValue = LsaNtStatusToWinError(dwReturnValue);
00232
00233     if (dwReturnValue != ERROR_SUCCESS) goto CLEANUP;
00234
00235
00236 CLEANUP:
00237
00238     if(psidPrincipal) free (psidPrincipal);
00239     if(hPolicy) LsaClose (hPolicy);
00240
00241     return dwReturnValue;
00242 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagSTATMESSAGEMAP Member List

This is the complete list of members for tagSTATMESSAGEMAP, including all inherited members.
idsMsg | tagSTATMESSAGEMAP
uID | tagSTATMESSAGEMAP
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllClien/UTCRUCAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllClien

UTCRUCAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      UTCRUCAR.CPP
00003
00004   Summary:   Implementation file for the aggregatable COUtilityCruiseCar
00005              COM object class.
00006
00007              UTCRUCAR showcases the construction of the COUtilityCruiseCar
00008              COM object class with the IUnknown, ICar, ICruise, and
00009              IUtility interfaces.  This is done through Aggregation reuse
00010              of COCruiseCar's ICar and ICruise interface features.
00011
00012              For a comprehensive tutorial code tour of this module's
00013              contents and offerings see the tutorial DLLCLIEN.HTM
00014              file.  For more specific technical details on the internal
00015              workings see the comments dispersed throughout the
00016              module's source code.
00017
00018   Classes:   COUtilityCruiseCar
00019
00020   Functions: CreateUtilityCruiseCar.
00021
00022   Origin:    9-20-95: atrent - Editor inheritance from COMUSER source.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include APPUTIL.H because we will be building this application using
00043     the convenient Virtual Window and Dialog classes and other
00044     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00045   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00046     class, GUID, and CLSID specifications.
00047   We include UTCRUCAR.H because it has the COUtilityCruiseCar declarations.
00048 ---------------------------------------------------------------------------*/
00049 #include <windows.h>
00050 #include <ole2.h>
00051 #include <apputil.h>
00052 #include <icars.h>
00053 #include <carguids.h>
00054 #include "dllclien.h"
00055 #include "utcrucar.h"
00056
00057
00058 /*---------------------------------------------------------------------------
00059   COUtilityCruiseCar's implementation of its main COM object class including
00060   Constructor, Destructor, QueryInterface, AddRef, and Release.
00061 ---------------------------------------------------------------------------*/
00062
00063 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00064   Method:   COUtilityCruiseCar::COUtilityCruiseCar
00065
00066   Summary:  COUtilityCruiseCar Constructor. Note the member initializer:
00067             "m_ImpIUtility(this, pUnkOuter)" which is used to pass the 'this'
00068             and pUnkOuter pointers of this constructor function to the
00069             constructor in the instantiation of the implementation of
00070             the CImpIUtility interface (which is nested inside this present
00071             COUtilityCruiseCar Object Class).
00072
00073   Args:     IUnknown* pUnkOuter)
00074               Pointer to the the outer Unknown.  NULL means this COM Object
00075               is not being Aggregated.  Non NULL means it is being created
00076               on behalf of an outside COM object that is reusing it via
00077               aggregation.
00078
00079   Modifies: m_cRefs, m_pUnkOuter, m_pUnkCruiseCar.
00080
00081   Returns:  void
00082 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00083 COUtilityCruiseCar::COUtilityCruiseCar(
00084   IUnknown* pUnkOuter) :
00085   m_ImpIUtility(this, pUnkOuter)
00086 {
00087   // Zero the COM object's reference count.
00088   m_cRefs = 0;
00089
00090   // No AddRef necessary if non-NULL, as this COM object's lifetime
00091   // is totally coupled with the controlling Outer object's lifetime.
00092   m_pUnkOuter = pUnkOuter;
00093
00094   // Zero the pointer to the aggregated COCruiseCar object's IUnknown
00095   // interface (for delegation of IUnknown calls to it).
00096   m_pUnkCruiseCar = NULL;
00097
00098   LOGF1("C: COUtilityCruiseCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00099
00100   return;
00101 }
00102
00103
00104 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00105   Method:   COUtilityCruiseCar::~COUtilityCruiseCar
00106
00107   Summary:  COUtilityCruiseCar Destructor.
00108
00109   Args:     void
00110
00111   Modifies: .
00112
00113   Returns:  void
00114 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00115 COUtilityCruiseCar::~COUtilityCruiseCar(void)
00116 {
00117   LOG("C: COUtilityCruiseCar::Destructor.");
00118
00119   RELEASE_INTERFACE(m_pUnkCruiseCar);
00120
00121   return;
00122 }
00123
00124
00125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00126   Method:   COUtilityCruiseCar::Init
00127
00128   Summary:  COUtilityCruiseCar Initialization method.
00129
00130   Args:     void
00131
00132   Modifies: m_pUnkCruiseCar, m_pICar, m_pICruise, m_cRefs.
00133
00134   Returns:  HRESULT
00135               Standard result code. NOERROR for success.
00136 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00137 HRESULT COUtilityCruiseCar::Init(void)
00138 {
00139   HRESULT hr;
00140   IClassFactory* pICFCruiseCar;
00141
00142   // Set up the right pIUnknown for delegation.  If we are being
00143   // aggregated then we pass the pUnkOuter in turn to any COM objects
00144   // that we are aggregating.  m_pUnkOuter was set in the Constructor.
00145   IUnknown* pUnkOuter = (NULL == m_pUnkOuter) ? this : m_pUnkOuter;
00146
00147   LOG("C: COUtilityCruiseCar::Init.");
00148
00149   // Get a class factory for DllCruiseCar and issue IClassFactory's
00150   // CreateInstance method to manufacture a COCruiseCar COM object.
00151   hr = CoGetClassObject(
00152          CLSID_DllCruiseCar,
00153          CLSCTX_INPROC_SERVER,
00154          NULL,
00155          IID_IClassFactory,
00156          (PPVOID)&pICFCruiseCar);
00157   if (SUCCEEDED(hr))
00158   {
00159     hr = pICFCruiseCar->CreateInstance(
00160                           pUnkOuter,
00161                           IID_IUnknown,
00162                           (PPVOID)&m_pUnkCruiseCar);
00163     pICFCruiseCar->Release();
00164   }
00165
00166   if (SUCCEEDED(hr))
00167   {
00168     LOG("C: COUtilityCruiseCar::Init Succeeded.");
00169   }
00170   else
00171   {
00172     LOG("C: COUtilityCruiseCar::Init Failed.");
00173   }
00174
00175   return (hr);
00176 }
00177
00178
00179 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00180   Method:   COUtilityCruiseCar::QueryInterface
00181
00182   Summary:  QueryInterface of the COUtilityCruiseCar non-delegating
00183             IUnknown implementation.
00184
00185   Args:     REFIID riid,
00186               [in] GUID of the Interface being requested.
00187             PPVOID ppv)
00188               [out] Address of the caller's pointer variable that will
00189               receive the requested interface pointer.
00190
00191   Modifies: .
00192
00193   Returns:  HRESULT
00194 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00195 STDMETHODIMP COUtilityCruiseCar::QueryInterface(
00196                REFIID riid,
00197                PPVOID ppv)
00198 {
00199   HRESULT hr = E_NOINTERFACE;
00200   *ppv = NULL;
00201
00202   if (IID_IUnknown == riid)
00203   {
00204     *ppv = this;
00205     LOG("C: COUtilityCruiseCar::QueryInterface. 'this' pIUnknown returned.");
00206   }
00207   else if (IID_IUtility == riid)
00208   {
00209     // This IUtility interface is implemented in this COUtilityCruiseCar
00210     // object as a native interface of COUtilityCruiseCar.
00211     *ppv = &m_ImpIUtility;
00212     LOG("C: COUtilityCruiseCar::QueryInterface. pIUtility returned.");
00213   }
00214
00215   if (NULL != *ppv)
00216   {
00217     // We've handed out a pointer to an interface so obey the COM rules
00218     //   and AddRef its reference count.
00219     ((LPUNKNOWN)*ppv)->AddRef();
00220     hr = NOERROR;
00221   }
00222   else if (IID_ICar == riid)
00223   {
00224     LOG("C: COUtilityCruiseCar::QueryInterface. ICar delegating.");
00225     // We didn't implement the ICar interface in this COUtilityCruiseCar
00226     // object.  The aggregated inner object (CruiseCar) is contributing
00227     // the ICar interface to this present composite or aggregating
00228     // UtilityCruiseCar object.  So, to satisfy a QI request for the ICar
00229     // interface, we delegate the QueryInterface to the inner
00230     // object's IUnknown.
00231     hr = m_pUnkCruiseCar->QueryInterface(riid, ppv);
00232   }
00233   else if (IID_ICruise == riid)
00234   {
00235     LOG("C: COUtilityCruiseCar::QueryInterface. ICruise delegating.");
00236     // We didn't implement the ICruise interface in this COUtilityCruiseCar
00237     // object.  The aggregated inner object (CruiseCar) is contributing
00238     // the ICruise interface to this present composite or aggregating
00239     // UtilityCruiseCar object.  As above we delegate this QI to the
00240     // aggregated object's IUnknown.
00241     hr = m_pUnkCruiseCar->QueryInterface(riid, ppv);
00242   }
00243
00244   return (hr);
00245 }
00246
00247
00248 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00249   Method:   COUtilityCruiseCar::AddRef
00250
00251   Summary:  AddRef of the COUtilityCruiseCar non-delegating
00252             IUnknown implementation.
00253
00254   Args:     void
00255
00256   Modifies: m_cRefs.
00257
00258   Returns:  ULONG
00259               New value of m_cRefs (COM object's reference count).
00260 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00261 STDMETHODIMP_(ULONG) COUtilityCruiseCar::AddRef(void)
00262 {
00263   m_cRefs++;
00264
00265   LOGF1("C: COUtilityCruiseCar::AddRef. New cRefs=%i.", m_cRefs);
00266
00267   return m_cRefs;
00268 }
00269
00270
00271 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00272   Method:   COUtilityCruiseCar::Release
00273
00274   Summary:  Release of the COUtilityCruiseCar non-delegating IUnknown
00275             implementation.
00276
00277   Args:     void
00278
00279   Modifies: m_cRefs.
00280
00281   Returns:  ULONG
00282               New value of m_cRefs (COM object's reference count).
00283 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00284 STDMETHODIMP_(ULONG) COUtilityCruiseCar::Release(void)
00285 {
00286   ULONG ulCount = --m_cRefs;
00287
00288   LOGF1("C: COUtilityCruiseCar::Release. New cRefs=%i.", m_cRefs);
00289
00290   if (0 == m_cRefs)
00291   {
00292     // We artificially bump the main ref count.  Thie fulfills one of
00293     // the rules of aggregated objects and ensures that an indirect
00294     // recursive call to this release won't occur because of other
00295     // delegating releases that might happen in our own destructor.
00296     m_cRefs++;
00297     delete this;
00298   }
00299
00300   return ulCount;
00301 }
00302
00303
00304 /*---------------------------------------------------------------------------
00305   COUtilityCruiseCar's nested implementation of the IUtility interface
00306   including methods: Constructor, Destructor, QueryInterface, AddRef,
00307   Release, Offroad, and Winch.
00308 ---------------------------------------------------------------------------*/
00309
00310 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00311   Method:   COUtilityCruiseCar::CImpIUtility::CImpIUtility
00312
00313   Summary:  Constructor for the CImpIUtility interface instantiation.
00314
00315   Args:     COUtilityCruiseCar* pBackObj,
00316               Back pointer to the parent outer object.
00317             IUnknown* pUnkOuter)
00318               Pointer to the outer Unknown.  For delegation.
00319
00320   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00321
00322   Returns:  void
00323 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00324 COUtilityCruiseCar::CImpIUtility::CImpIUtility(
00325   COUtilityCruiseCar* pBackObj,
00326   IUnknown* pUnkOuter)
00327 {
00328   // Init the Interface Ref Count (used for debugging only).
00329   m_cRefI = 0;
00330
00331   // Init the Back Object Pointer to point to the outer object.
00332   m_pBackObj = pBackObj;
00333
00334   // Init the CImpIUtility interface's delegating IUnknown pointer.  We use
00335   // the Back Object pointer for IUnknown delegation here if we are not
00336   // being aggregated.  If we are being aggregated we use the supplied
00337   // pUnkOuter for IUnknown delegation.  In either case the pointer
00338   // assignment requires no AddRef because the CImpIUtility lifetime is
00339   // quaranteed by the lifetime of the parent object in which
00340   // CImpIUtility is nested.
00341   if (NULL == pUnkOuter)
00342   {
00343     m_pUnkOuter = pBackObj;
00344     LOG("C: COUtilityCruiseCar::CImpIUtility Constructor. Non-Aggregating.");
00345   }
00346   else
00347   {
00348     m_pUnkOuter = pUnkOuter;
00349     LOG("C: COUtilityCruiseCar::CImpIUtility Constructor. Aggregating.");
00350   }
00351
00352   return;
00353 }
00354
00355
00356 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00357   Method:   COUtilityCruiseCar::CImpIUtility::~CImpIUtility
00358
00359   Summary:  Destructor for the CImpIUtility interface instantiation.
00360
00361   Args:     void
00362
00363   Modifies: .
00364
00365   Returns:  void
00366 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00367 COUtilityCruiseCar::CImpIUtility::~CImpIUtility(void)
00368 {
00369   LOG("C: COUtilityCruiseCar::CImpIUtility Destructor.");
00370
00371   return;
00372 }
00373
00374
00375 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00376   Method:   COUtilityCruiseCar::CImpIUtility::QueryInterface
00377
00378   Summary:  The QueryInterface IUnknown member of this IUtility interface
00379             implementation that delegates to m_pUnkOuter, whatever it is.
00380
00381   Args:     REFIID riid,
00382               [in] GUID of the Interface being requested.
00383             PPVOID ppv)
00384               [out] Address of the caller's pointer variable that will
00385               receive the requested interface pointer.
00386
00387   Modifies: .
00388
00389   Returns:  HRESULT
00390               Returned by the delegated outer QueryInterface call.
00391 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00392 STDMETHODIMP COUtilityCruiseCar::CImpIUtility::QueryInterface(
00393                REFIID riid,
00394                PPVOID ppv)
00395 {
00396   LOG("C: COUtilityCruiseCar::CImpIUtility::QueryInterface. Delegating.");
00397
00398   // Delegate this call to the outer object's QueryInterface.
00399   return m_pUnkOuter->QueryInterface(riid, ppv);
00400 }
00401
00402
00403 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00404   Method:   COUtilityCruiseCar::CImpIUtility::AddRef
00405
00406   Summary:  The AddRef IUnknown member of this IUtility interface
00407             implementation that delegates to m_pUnkOuter, whatever it is.
00408
00409   Args:     void
00410
00411   Modifies: m_cRefI.
00412
00413   Returns:  ULONG
00414               Returned by the delegated outer AddRef call.
00415 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00416 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpIUtility::AddRef(void)
00417 {
00418   // Increment the Interface Reference Count.
00419   ++m_cRefI;
00420
00421   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Addref. Delegating. New cI=%i.", m_cRefI);
00422
00423   // Delegate this call to the outer object's AddRef.
00424   return m_pUnkOuter->AddRef();
00425 }
00426
00427
00428 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00429   Method:   COUtilityCruiseCar::CImpIUtility::Release
00430
00431   Summary:  The Release IUnknown member of this IUtility interface
00432             implementation that delegates to m_pUnkOuter, whatever it is.
00433
00434   Args:     void
00435
00436   Modifies: .
00437
00438   Returns:  ULONG
00439               Returned by the delegated outer Release call.
00440 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00441 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpIUtility::Release(void)
00442 {
00443   // Decrement the Interface Reference Count.
00444   --m_cRefI;
00445
00446   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Release. Delegating. New cI=%i.", m_cRefI);
00447
00448   // Delegate this call to the outer object's Release.
00449   return m_pUnkOuter->Release();
00450 }
00451
00452
00453 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00454   Method:   COUtilityCruiseCar::CImpIUtility::Offroad
00455
00456   Summary:  The Offroad member method of this IUtility interface
00457             implementation.  A simple empty method on a COUtilityCruiseCar
00458             COM object for tutorial purposes.  Presumably if this
00459             UtilityCruise Car object were modeling a real Car then the
00460             Offroad method would function the 4-wheel drive transfer case
00461             and shift it to the specified 4-wheel drive mode.
00462
00463   Args:     short nGear
00464               0 = 2H or regular 2-wheel drive;
00465               1 = 4H or 4-wheel drive high speed;
00466               2 = neutral; and
00467               3 = 4L or 4-wheel drive low speed).
00468
00469   Modifies: .
00470
00471   Returns:  HRESULT
00472               NOERROR
00473 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00474 STDMETHODIMP COUtilityCruiseCar::CImpIUtility::Offroad(
00475                short nGear)
00476 {
00477   HRESULT hr;
00478   ICar* pICar = NULL;
00479
00480   // In our fantasy Sport-Utility Car world we may need to stop the car
00481   // before switching to 4-Wheel drive low (nGear == 3 for 4L). Let's
00482   // assume so because it's a convenient excuse to show this aggregating
00483   // COUtilityCruiseCar outer object using one of the interfaces (ICar)
00484   // of its aggregated COCruiseCar inner object.  DLLCLIEN gracefully
00485   // cooperates in this by invoking this Offroad method from the
00486   // UtilityCruiseCar menu with nGear == 3.
00487   if (3 == nGear)
00488   {
00489     hr = m_pBackObj->m_pUnkCruiseCar->QueryInterface(
00490                                         IID_ICar,
00491                                         (PPVOID)&pICar);
00492     if (SUCCEEDED(hr))
00493     {
00494       m_pUnkOuter->Release();
00495       pICar->Speed(0);
00496       m_pUnkOuter->AddRef();
00497       pICar->Release();
00498     }
00499   }
00500
00501   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Offroad. Called. nGear=%i.",nGear);
00502
00503   return NOERROR;
00504 }
00505
00506
00507 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00508   Method:   COUtilityCruiseCar::CImpIUtility::Winch
00509
00510   Summary:  The Adjust member method of this IUtility interface
00511             implementation.  A simple empty method on a COUtilityCruiseCar
00512             COM object for tutorial purposes.  Presumably if this
00513             UtilityCruiseCar object were modeling a real Car then the
00514             Winch method would turn on/off the front-mounted Winch to the
00515             specified RPMs.
00516
00517   Args:     short nRpm
00518               0 = off; 1 - 50 RPM.
00519
00520   Modifies: .
00521
00522   Returns:  HRESULT
00523               NOERROR
00524 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00525 STDMETHODIMP COUtilityCruiseCar::CImpIUtility::Winch(
00526                short nRpm)
00527 {
00528   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Winch. Called. nRpm=%i.",nRpm);
00529
00530   return NOERROR;
00531 }
00532
00533
00534 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00535   Function: CreateUtilityCruiseCar
00536
00537   Summary:  Creates an instance of the COUtilityCruiseCar COM object class
00538             returning a requested interface pointer. COUtilityCruiseCar
00539             uses the Aggregation reuse technique to incorporate
00540             COCruiseCar features (ie, ICar and ICruise implementations)
00541             into its Interface offerings (ie, IUnknown, and IUtility).
00542             With this aggregation, the ICar and ICruise interfaces are
00543             not implemented in COUtilityCruiseCar.  They are instead
00544             solely implemented in a COCruiseCar object that
00545             CreateUtilityCruiseCar instantiates.  That COCruiseCar's ICar
00546             and ICruise implementations are used directly in this
00547             aggregation.  COCruiseCar is provided by the outside DLLSERVE.DLL.
00548
00549   Args:     IUnknown* pUnkOuter,
00550               Pointer the outer Unknown interface.  Non NULL implies
00551               that the new COM object is being created via an
00552               aggregation with an Outer object.  NULL implies that the
00553               object is not being created via aggregation.
00554             REFIID riid,
00555               The GUID of the interface requested on the new COM Object.
00556             PPVOID ppv)
00557               Address of the caller's pointer variable that will
00558               receive the requested interface pointer.
00559
00560   Returns:  HRESULT
00561               NOERROR if successful, CLASS_E_NOAGREGATION if IUnknown is
00562               not requested with non-NULL pUnkOuter, or other errors as
00563               appropriate.
00564 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00565 HRESULT CreateUtilityCruiseCar(
00566           IUnknown* pUnkOuter,
00567           REFIID riid,
00568           PPVOID ppv)
00569 {
00570   HRESULT hr;
00571   COUtilityCruiseCar* pCob;
00572
00573   LOGF1("C: CreateUtilityCruiseCar. pUnkOuter=0x%X.",pUnkOuter);
00574
00575   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00576   // the COM rules state the IUnknown interface MUST also be concomitantly
00577   // requested.  If it is not so requested ( riid != IID_IUnknown) then
00578   // an error must be returned indicating that no aggregate creation of
00579   // the COUtilityCruiseCar COM Object can be performed using anything
00580   // other than a controlling IUnknown interface.
00581   if (NULL != pUnkOuter && riid != IID_IUnknown)
00582     hr = CLASS_E_NOAGGREGATION;
00583   else
00584   {
00585     // Instantiate a COUtilityCruiseCar COM Object.
00586     pCob = new COUtilityCruiseCar(pUnkOuter);
00587     if (NULL != pCob)
00588     {
00589       // If we have succeeded in instantiating the COUtilityCruiseCar object
00590       // we initialize it to offer it's interfaces.
00591       hr = pCob->Init();
00592       if (SUCCEEDED(hr))
00593       {
00594         // We QueryInterface this new COM Object not only to deposit the
00595         // main interface pointer to the caller's pointer variable, but to
00596         // also automatically bump the Reference Count on the new COM
00597         // Object after handing out this *ppv reference to it.
00598         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00599       }
00600     }
00601     else
00602       hr = E_OUTOFMEMORY;
00603   }
00604
00605   if (SUCCEEDED(hr))
00606     LOGF1("C: CreateUtilityCruiseCar Succeeded. *ppv=0x%X.",*ppv);
00607
00608   return hr;
00609 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/SampView.Cpp Source File

  • WinUI
  • Shell
  • SampView

SampView.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          SampView.cpp
00013
00014    Description:   Contains DLLMain and standard OLE COM object creation stuff.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ShlView.h"
00023 #include "ClsFact.h"
00024 #include "ViewList.h"
00025 #include "Utility.h"
00026 #include <olectl.h>
00027
00028 /**************************************************************************
00029    GUID stuff
00030 **************************************************************************/
00031
00032 //this part is only done once
00033 //if you need to use the GUID in another file, just include Guid.h
00034 #define INITGUID
00035 #include <initguid.h>
00036 #include <shlguid.h>
00037 #include "Guid.h"
00038
00039 /**************************************************************************
00040    private function prototypes
00041 **************************************************************************/
00042
00043 extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
00044 BOOL DeleteEntireKey(HKEY, LPTSTR);
00045
00046 /**************************************************************************
00047    global variables
00048 **************************************************************************/
00049
00050 HINSTANCE   g_hInst;
00051 UINT        g_DllRefCount;
00052 HIMAGELIST  g_himlLarge = NULL;
00053 HIMAGELIST  g_himlSmall = NULL;
00054 TCHAR       g_szStoragePath[MAX_PATH];
00055 TCHAR       g_szExtTitle[TITLE_SIZE];
00056 const TCHAR c_szDataFile[] = TEXT("items.ini\0");
00057 const TCHAR c_szSection[] = TEXT("Items\0");
00058 int         g_nColumn = INITIAL_COLUMN_SIZE;
00059 CViewList   *g_pViewList;
00060
00061 /**************************************************************************
00062
00063    DllMain
00064
00065 **************************************************************************/
00066
00067 extern "C" BOOL WINAPI DllMain(  HINSTANCE hInstance,
00068                                  DWORD dwReason,
00069                                  LPVOID lpReserved)
00070 {
00071 switch(dwReason)
00072    {
00073    case DLL_PROCESS_ATTACH:
00074       g_hInst = hInstance;
00075       g_DllRefCount = 0;
00076
00077       GetGlobalSettings();
00078
00079       //create the global image lists
00080       CreateImageLists();
00081
00082       g_pViewList = new CViewList();
00083       break;
00084
00085    case DLL_PROCESS_DETACH:
00086       SaveGlobalSettings();
00087
00088       //destroy the global image lists
00089       DestroyImageLists();
00090
00091       if(g_pViewList)
00092          delete g_pViewList;
00093       break;
00094    }
00095
00096 return TRUE;
00097 }
00098
00099 /**************************************************************************
00100
00101    DllCanUnloadNow
00102
00103 **************************************************************************/
00104
00105 STDAPI DllCanUnloadNow(VOID)
00106 {
00107 return (g_DllRefCount ? S_FALSE : S_OK);
00108 }
00109
00110 /**************************************************************************
00111
00112    DllGetClassObject
00113
00114 **************************************************************************/
00115
00116 STDAPI DllGetClassObject(  REFCLSID rclsid,
00117                            REFIID riid,
00118                            LPVOID *ppReturn)
00119 {
00120 *ppReturn = NULL;
00121
00122 //if we don't support this classid, return the proper error code
00123 if(!IsEqualCLSID(rclsid, CLSID_SampleNameSpace))
00124    return CLASS_E_CLASSNOTAVAILABLE;
00125
00126 //create a CClassFactory object and check it for validity
00127 CClassFactory *pClassFactory = new CClassFactory();
00128 if(NULL == pClassFactory)
00129    return E_OUTOFMEMORY;
00130
00131 //get the QueryInterface return for our return value
00132 HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn);
00133
00134 //call Release to decrement the ref count - creating the object set it to one
00135 //and QueryInterface incremented it - since its being used externally (not by
00136 //us), we only want the ref count to be 1
00137 pClassFactory->Release();
00138
00139 //return the result from QueryInterface
00140 return hResult;
00141 }
00142
00143 /**************************************************************************
00144
00145    DllRegisterServer
00146
00147 **************************************************************************/
00148
00149 typedef struct{
00150    HKEY  hRootKey;
00151    LPTSTR lpszSubKey;
00152    LPTSTR lpszValueName;
00153    LPTSTR lpszData;
00154 }REGSTRUCT, *LPREGSTRUCT;
00155
00156 STDAPI DllRegisterServer(VOID)
00157 {
00158 int      i;
00159 HKEY     hKey;
00160 LRESULT  lResult;
00161 DWORD    dwDisp;
00162 TCHAR    szSubKey[MAX_PATH];
00163 TCHAR    szCLSID[MAX_PATH];
00164 TCHAR    szModule[MAX_PATH];
00165 LPWSTR   pwsz;
00166
00167 //get the CLSID in string form
00168 StringFromIID(CLSID_SampleNameSpace, &pwsz);
00169
00170 if(pwsz)
00171    {
00172    WideCharToLocal(szCLSID, pwsz, ARRAYSIZE(szCLSID));
00173
00174    //free the string
00175    LPMALLOC pMalloc;
00176    CoGetMalloc(1, &pMalloc);
00177    if(pMalloc)
00178       {
00179       pMalloc->Free(pwsz);
00180       pMalloc->Release();
00181       }
00182    }
00183
00184 //get this DLL's path and file name
00185 GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule));
00186
00187 //register the CLSID entries
00188 REGSTRUCT ClsidEntries[] = {  HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s"),                  NULL,                   g_szExtTitle,
00189                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),  NULL,                   TEXT("%s"),
00190                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),  TEXT("ThreadingModel"), TEXT("Apartment"),
00191                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\DefaultIcon"),     NULL,                   TEXT("%s,0"),
00192                               NULL,                NULL,                               NULL,                   NULL};
00193
00194 for(i = 0; ClsidEntries[i].hRootKey; i++)
00195    {
00196    //Create the sub key string.
00197    wsprintf(szSubKey, ClsidEntries[i].lpszSubKey, szCLSID);
00198
00199    lResult = RegCreateKeyEx(  ClsidEntries[i].hRootKey,
00200                               szSubKey,
00201                               0,
00202                               NULL,
00203                               REG_OPTION_NON_VOLATILE,
00204                               KEY_WRITE,
00205                               NULL,
00206                               &hKey,
00207                               &dwDisp);
00208
00209    if(NOERROR == lResult)
00210       {
00211       TCHAR szData[MAX_PATH];
00212
00213       //if necessary, create the value string
00214       wsprintf(szData, ClsidEntries[i].lpszData, szModule);
00215
00216       lResult = RegSetValueEx(   hKey,
00217                                  ClsidEntries[i].lpszValueName,
00218                                  0,
00219                                  REG_SZ,
00220                                  (LPBYTE)szData,
00221                                  (lstrlen(szData) + 1) * sizeof(TCHAR));
00222
00223       RegCloseKey(hKey);
00224       }
00225    else
00226       return SELFREG_E_CLASS;
00227    }
00228
00229 //Register the default flags for the folder.
00230
00231 wsprintf(   szSubKey,
00232             TEXT("CLSID\\%s\\ShellFolder"),
00233             szCLSID);
00234
00235 lResult = RegCreateKeyEx(  HKEY_CLASSES_ROOT,
00236                            szSubKey,
00237                            0,
00238                            NULL,
00239                            REG_OPTION_NON_VOLATILE,
00240                            KEY_WRITE,
00241                            NULL,
00242                            &hKey,
00243                            &dwDisp);
00244
00245 if(NOERROR == lResult)
00246    {
00247    DWORD dwData = SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_BROWSABLE | SFGAO_DROPTARGET;
00248
00249    lResult = RegSetValueEx(   hKey,
00250                               TEXT("Attributes"),
00251                               0,
00252                               REG_BINARY,
00253                               (LPBYTE)&dwData,
00254                               sizeof(dwData));
00255
00256    RegCloseKey(hKey);
00257    }
00258 else
00259    return SELFREG_E_CLASS;
00260
00261 //Register the name space extension
00262
00263 /*
00264 Create the sub key string. Change this from "...MyComputer..." to
00265 "...Desktop..." if desired.
00266 */
00267 //#define INSTALL_ON_DESKTOP
00268 wsprintf(   szSubKey,
00269 #ifdef INSTALL_ON_DESKTOP
00270             TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\%s"),
00271 #else
00272             TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\NameSpace\\%s"),
00273 #endif
00274             szCLSID);
00275
00276 lResult = RegCreateKeyEx(  HKEY_LOCAL_MACHINE,
00277                            szSubKey,
00278                            0,
00279                            NULL,
00280                            REG_OPTION_NON_VOLATILE,
00281                            KEY_WRITE,
00282                            NULL,
00283                            &hKey,
00284                            &dwDisp);
00285
00286 if(NOERROR == lResult)
00287    {
00288    TCHAR szData[MAX_PATH];
00289
00290    //Create the value string.
00291    lstrcpyn(szData, g_szExtTitle, ARRAYSIZE(szData));
00292
00293    lResult = RegSetValueEx(   hKey,
00294                               NULL,
00295                               0,
00296                               REG_SZ,
00297                               (LPBYTE)szData,
00298                               (lstrlen(szData) + 1) * sizeof(TCHAR));
00299
00300    RegCloseKey(hKey);
00301    }
00302 else
00303    return SELFREG_E_CLASS;
00304
00305 //If running on NT, register the extension as approved.
00306 OSVERSIONINFO  osvi;
00307
00308 osvi.dwOSVersionInfoSize = sizeof(osvi);
00309 GetVersionEx(&osvi);
00310
00311 if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
00312    {
00313    lstrcpyn( szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), ARRAYSIZE(szSubKey));
00314
00315    lResult = RegCreateKeyEx(  HKEY_LOCAL_MACHINE,
00316                               szSubKey,
00317                               0,
00318                               NULL,
00319                               REG_OPTION_NON_VOLATILE,
00320                               KEY_WRITE,
00321                               NULL,
00322                               &hKey,
00323                               &dwDisp);
00324
00325    if(NOERROR == lResult)
00326       {
00327       TCHAR szData[MAX_PATH];
00328
00329       //Create the value string.
00330       lstrcpyn(szData, g_szExtTitle, ARRAYSIZE(szData));
00331
00332       lResult = RegSetValueEx(   hKey,
00333                                  szCLSID,
00334                                  0,
00335                                  REG_SZ,
00336                                  (LPBYTE)szData,
00337                                  (lstrlen(szData) + 1) * sizeof(TCHAR));
00338
00339       RegCloseKey(hKey);
00340       }
00341    else
00342       return SELFREG_E_CLASS;
00343    }
00344
00345 //tell the shell that the folder has been added.
00346 LPITEMIDLIST   pidlDesktop,
00347                pidlMyComputer;
00348
00349 SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop);
00350 SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer);
00351 SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidlDesktop, 0);
00352 SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidlMyComputer, 0);
00353
00354 IMalloc  *pMalloc;
00355 if(S_OK == SHGetMalloc(&pMalloc))
00356    {
00357    pMalloc->Free(pidlDesktop);
00358    pMalloc->Free(pidlMyComputer);
00359    pMalloc->Release();
00360    }
00361
00362 return S_OK;
00363 }
00364
00365 /**************************************************************************
00366
00367    DllUnregisterServer()
00368
00369 **************************************************************************/
00370
00371 STDAPI DllUnregisterServer(VOID)
00372 {
00373 LPWSTR   pwsz;
00374 TCHAR    szCLSID[MAX_PATH];
00375 TCHAR    szSubKey[MAX_PATH];
00376
00377 //get the CLSID in string form
00378 StringFromIID(CLSID_SampleNameSpace, &pwsz);
00379
00380 if(pwsz)
00381    {
00382    WideCharToLocal(szCLSID, pwsz, ARRAYSIZE(szCLSID));
00383
00384    //free the string
00385    LPMALLOC pMalloc;
00386    CoGetMalloc(1, &pMalloc);
00387    if(pMalloc)
00388       {
00389       pMalloc->Free(pwsz);
00390       pMalloc->Release();
00391       }
00392    }
00393 else
00394    {
00395    return E_FAIL;
00396    }
00397
00398 //delete the namespace extension entries
00399 wsprintf(   szSubKey,
00400             TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\NameSpace\\%s"),
00401             szCLSID);
00402 DeleteEntireKey(HKEY_LOCAL_MACHINE, szSubKey);
00403 wsprintf(   szSubKey,
00404             TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\%s"),
00405             szCLSID);
00406 DeleteEntireKey(HKEY_LOCAL_MACHINE, szSubKey);
00407
00408 //delete the object's registry entries
00409 wsprintf(szSubKey, TEXT("CLSID\\%s"), szCLSID);
00410 DeleteEntireKey(HKEY_CLASSES_ROOT, szSubKey);
00411
00412 //delete the approved extensions on NT
00413 OSVERSIONINFO  osvi;
00414
00415 osvi.dwOSVersionInfoSize = sizeof(osvi);
00416 GetVersionEx(&osvi);
00417
00418 if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
00419    {
00420    LRESULT  lResult;
00421    HKEY     hKey;
00422
00423    lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
00424                            TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
00425                            0,
00426                            KEY_SET_VALUE,
00427                            &hKey);
00428
00429    if(NOERROR == lResult)
00430       {
00431       TCHAR szData[MAX_PATH];
00432
00433       //Create the value string.
00434       lstrcpyn(szData, g_szExtTitle, ARRAYSIZE(szData));
00435
00436       lResult = RegDeleteValue(  hKey,
00437                                  szCLSID);
00438
00439       RegCloseKey(hKey);
00440       }
00441    else
00442       return SELFREG_E_CLASS;
00443    }
00444
00445 //tell the shell that the folder has been removed.
00446 LPITEMIDLIST   pidlDesktop,
00447                pidlMyComputer;
00448
00449 SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop);
00450 SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer);
00451 SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidlDesktop, 0);
00452 SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidlMyComputer, 0);
00453
00454 IMalloc  *pMalloc;
00455 if(S_OK == SHGetMalloc(&pMalloc))
00456    {
00457    pMalloc->Free(pidlDesktop);
00458    pMalloc->Free(pidlMyComputer);
00459    pMalloc->Release();
00460    }
00461
00462 return S_OK;
00463 }
00464
00465 /**************************************************************************
00466
00467    DeleteEntireKey()
00468
00469 **************************************************************************/
00470
00471 BOOL DeleteEntireKey(HKEY hKey, LPTSTR pszSubKey)
00472 {
00473 LRESULT  lResult;
00474 HKEY     hEnumKey;
00475
00476 lResult = RegOpenKeyEx( hKey,
00477                         pszSubKey,
00478                         0,
00479                         KEY_ENUMERATE_SUB_KEYS,
00480                         &hEnumKey);
00481
00482 if(NOERROR == lResult)
00483    {
00484    TCHAR szKey[MAX_PATH];
00485    DWORD dwSize = MAX_PATH;
00486
00487    while(ERROR_SUCCESS == RegEnumKeyEx(hEnumKey, 0, szKey, &dwSize, NULL, NULL, NULL, NULL))
00488       {
00489       DeleteEntireKey(hEnumKey, szKey);
00490
00491       dwSize = MAX_PATH;
00492       }
00493
00494    RegCloseKey(hEnumKey);
00495    }
00496 else
00497    {
00498    return FALSE;
00499    }
00500
00501 RegDeleteKey(hKey, pszSubKey);
00502
00503 return TRUE;
00504 }
00505
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/ListSINK.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

ListSINK.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      LISTSINK.H
00003
00004   Summary:   Include file for the COPageListSink COM object class.
00005
00006              COPageListSink offers a main IUnknown standard interface and
00007              the custom IPageListSink interface (outgoing connection
00008              events from COPageList objects). This multiple interface COM
00009              Object Class is achieved via the technique of nested classes.
00010              The implementation of the IPageListSink interface is nested
00011              inside of the COPageListSink Class.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial PERCLIEN.HTM
00015              file. For more specific technical details on the internal
00016              workings see the comments dispersed throughout the module's
00017              source code.
00018
00019   Functions: .
00020
00021   Classes:   COPageListSink.
00022
00023   Origin:    5-25-97: atrent - Editor-inheritance from SINK.H in the
00024              STOCLIEN Tutorial Code Sample. [Revised]
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(LISTSINK_H)
00042 #define LISTSINK_H
00043
00044 #ifdef __cplusplus
00045
00046
00047 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00048   ObjectClass: COPageListSink
00049
00050   Summary:     The main Sink COM object class for COPageListSink COM
00051                objects. COM objects of this class offer the IPageListSink
00052                sink interface supporting various PageList events. The
00053                mulitple interfaces on this COM object are constructed via
00054                the nested interface classes technique.
00055
00056   Interfaces:  IUnknown
00057                  Standard interface providing COM object features.
00058                IPageListSink
00059                  Sink interface for PageList events.
00060
00061   Aggregation: Yes, COPageListSink COM Objects are aggregatable by passing
00062                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00063 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00064 class COPageListSink : public IUnknown
00065 {
00066   public:
00067     // Main Object Constructor & Destructor.
00068     COPageListSink(IUnknown* pUnkOuter, CGuiList* pGuiList);
00069     ~COPageListSink(void);
00070
00071     // IUnknown methods. Main object, non-delegating.
00072     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00073     STDMETHODIMP_(ULONG) AddRef(void);
00074     STDMETHODIMP_(ULONG) Release(void);
00075
00076   private:
00077     // We declare nested class interface implementations here.
00078
00079     class CImpIPageListSink : public IPageListSink
00080     {
00081       public:
00082         // Interface Implementation Constructor & Destructor.
00083         CImpIPageListSink(COPageListSink* pCO, IUnknown* pUnkOuter);
00084         ~CImpIPageListSink(void);
00085
00086         // IUnknown methods.
00087         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00088         STDMETHODIMP_(ULONG) AddRef(void);
00089         STDMETHODIMP_(ULONG) Release(void);
00090
00091         // IPageListSink methods.
00092         STDMETHODIMP         Loaded(void);
00093         STDMETHODIMP         Saved(void);
00094         STDMETHODIMP         Cleared(void);
00095         STDMETHODIMP         PageAdded(INT iPage);
00096         STDMETHODIMP         PageDeleted(INT iPage);
00097         STDMETHODIMP         PageSet(INT iPage);
00098
00099       private:
00100         // Data private to this interface implementation of IPageList.
00101         COPageListSink*  m_pCO;          // Parent Object back pointer.
00102         IUnknown*        m_pUnkOuter;    // Outer unknown for Delegation.
00103     };
00104
00105     // Make the otherwise private and nested IPageListSink interface
00106     // implementation a friend to COM object instantiations of this
00107     // COPageListSink COM object class.
00108     friend CImpIPageListSink;
00109
00110     // Private data of COPageListSink COM objects.
00111
00112     // Nested IPageListSink implementation instantiation.  This
00113     // IPageListSink interface is instantiated inside this COPageListSink
00114     // object as a native interface.
00115     CImpIPageListSink    m_ImpIPageListSink;
00116
00117     // Main Object reference count.
00118     ULONG                m_cRefs;
00119
00120     // Outer unknown (aggregation delegation). Used when this COM object
00121     // is being aggregated.
00122     IUnknown*            m_pUnkOuter;
00123
00124     // Pointer to the main object that can service the Sink events.
00125     CGuiList*            m_pGuiList;
00126 };
00127
00128 #endif // __cplusplus
00129
00130
00131 #endif // LISTSINK_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/globals.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

globals.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "BaseNode.h"
00016
00017 //---------------------------------------------------------------------------
00018 // MMC's requiered clipboard formats
00019
00020 UINT g_cfDisplayName = 0;      // DisplayName for our SnapIn node
00021 UINT g_cfNodeType    = 0;      // GUID of the selected node
00022 UINT g_cfszNodeType  = 0;      // String representation of namespace GUID
00023 UINT g_cfSnapinClsid = 0;      // Class ID of this SnapIn
00024
00025 //---------------------------------------------------------------------------
00026 //  Custom clipboard formats
00027
00028 UINT g_cfBaseNodePtr = 0;
00029 UINT g_cfDataObjPtr  = 0;
00030
00031
00032 // Global variables
00033
00034 HINSTANCE g_hInst = NULL;      // Our global instance handle
00035 ULONG g_uObjectCount = 0;      // Global object count
00036 ULONG g_uServerLocks = 0;      // Global lock count
00037
00038
00039 //---------------------------------------------------------------------------
00040 //  This is the fast, simple way to convert unicode to ansi.  It does NOT
00041 //  handle multibyte ansi strings and is not localized.  But it should be
00042 //  fine for registry entries
00043 //  NOTE:  The caller is responsible for freeing the memory.
00044 //
00045 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide )
00046 {
00047   LONG nLen = wcslen( szWide ) +1;
00048   *pszAnsi = (char*)CoTaskMemAlloc( nLen );
00049   char* pCounter = *pszAnsi;
00050
00051   while( *szWide )
00052   {
00053     *pCounter = LOBYTE(*szWide);
00054     pCounter++;
00055     szWide++;
00056   }
00057   *pCounter = NULL;
00058 }
00059
00060 //---------------------------------------------------------------------------
00061 //  copies a string ( like strncpy )
00062 //  in non-unicode version coverts ansi-to-unicode first.
00063 //
00064 void _fastcall CopyT2W( LPWSTR strDest, LPCTSTR strSource, size_t count)
00065 {
00066 #ifndef _UNICODE
00067
00068   MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, strSource, -1, strDest, count );
00069
00070 #else
00071
00072   wcsncpy( strDest, strSource, count );
00073
00074 #endif
00075
00076   if ( count > 0 )
00077     strDest[ count - 1 ] = 0;
00078 }
00079
00080 //---------------------------------------------------------------------------
00081 //
00082 void InitClipboardFormats()
00083 {
00084   g_cfDisplayName  = RegisterClipboardFormat( T_CCF_DISPLAY_NAME );
00085   g_cfNodeType     = RegisterClipboardFormat( T_CCF_NODETYPE );
00086   g_cfszNodeType   = RegisterClipboardFormat( T_CCF_SZNODETYPE );
00087   g_cfSnapinClsid  = RegisterClipboardFormat( T_CCF_SNAPIN_CLASSID );
00088
00089   g_cfBaseNodePtr  = RegisterClipboardFormat( T_CCF_BASENODE_PTR );
00090   g_cfDataObjPtr   = RegisterClipboardFormat( T_CCF_DATAOBJ_PTR );
00091
00092 }
00093
00094 //---------------------------------------------------------------------------
00095 //  Extracts data based on the passed-in clipboard format
00096 //
00097 HRESULT ExtractFromDataObject
00098 (
00099   LPDATAOBJECT ipDataObject,   // [in]  Points to data object
00100   UINT         cfClipFormat,   // [in]  Clipboard format to use
00101   ULONG        nByteCount,     // [in]  Number of bytes to allocate
00102   HGLOBAL      *phGlobal       // [out] Points to the data we want
00103 )
00104 {
00105   _ASSERT( NULL != ipDataObject );
00106
00107             *phGlobal = NULL;
00108   HRESULT   hResult   = S_FALSE;
00109   STGMEDIUM StgMedium = { TYMED_HGLOBAL,  NULL  };
00110   FORMATETC FormatEtc = { cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00111
00112   do
00113   {
00114     // Allocate memory for the stream
00115     StgMedium.hGlobal = ::GlobalAlloc( GMEM_SHARE, nByteCount );
00116
00117     if( NULL == StgMedium.hGlobal )
00118     {
00119       hResult = E_OUTOFMEMORY;
00120       break;
00121     }
00122
00123     // Attempt to get data from the object
00124     hResult = ipDataObject->GetDataHere( &FormatEtc, &StgMedium );
00125     if( FAILED(hResult) )
00126     {
00127       break;
00128     }
00129     // StgMedium now has the data we need
00130     *phGlobal = StgMedium.hGlobal;
00131     StgMedium.hGlobal = NULL;
00132
00133   } while (0);
00134
00135   if( FAILED(hResult) && StgMedium.hGlobal )
00136   {
00137     HGLOBAL hRetVal = ::GlobalFree(StgMedium.hGlobal);
00138     _ASSERT( NULL == hRetVal );         // Must return NULL
00139   }
00140   return hResult;
00141
00142 }
00143
00144
00145 //---------------------------------------------------------------------------
00146 //  This helper returns the current BaseNode object on the custom
00147 //  g_cfBaseNodePtr clipboard format
00148 //
00149 CBaseNode* ExtractBaseNodePtr
00150 (
00151   LPDATAOBJECT ipDataObject      // [in] IComponent pointer
00152 )
00153 {
00154   LPBASENODE  pNode   = NULL;
00155   HGLOBAL     hGlobal = NULL;
00156   HRESULT     hResult = S_FALSE;
00157
00158   hResult = ExtractFromDataObject( ipDataObject,
00159                                    g_cfBaseNodePtr,
00160                                    sizeof(LPBASENODE),
00161                                    &hGlobal
00162                                  );
00163   if( SUCCEEDED(hResult) )
00164   {
00165     pNode = *(LPBASENODE*)(hGlobal);
00166     HGLOBAL hRetVal = GlobalFree(hGlobal);
00167     _ASSERT( NULL == hRetVal );        // Must return NULL
00168   }
00169
00170   return pNode;
00171
00172 }
00173
00174 //---------------------------------------------------------------------------
00175 //  Converts an IDataObject pointer to a CDataObject pointer by
00176 //  retrieving a "this" pointer using a custom clipboard format.
00177 //
00178 CDataObject* ExtractDataObjPtr
00179 (
00180   LPDATAOBJECT ipDataObject      //[in] IDataObject pointer
00181 )
00182 {
00183   _ASSERT( 0 != g_cfDataObjPtr );
00184
00185   HGLOBAL      hGlobal = NULL;
00186   HRESULT      hResult = S_OK;
00187   CDataObject* pDO     = NULL;
00188
00189   hResult = ExtractFromDataObject( ipDataObject,
00190                                    g_cfDataObjPtr,
00191                                    sizeof(CDataObject **),
00192                                    &hGlobal
00193                                  );
00194
00195   if( SUCCEEDED(hResult) )
00196   {
00197     pDO = *(CDataObject **)(hGlobal);
00198     _ASSERT( NULL != pDO );
00199
00200     HGLOBAL hRetVal = GlobalFree(hGlobal);
00201     _ASSERT( NULL == hRetVal );       // Must return NULL
00202   }
00203
00204   return pDO;
00205
00206 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCustomPropertyStore Member List

This is the complete list of members for CCustomPropertyStore, including all inherited members.
_cRef | CCustomPropertyStore | [private]
_dwState | CCustomPropertyStore | [private]
_SetState(DWORD dwState) | CCustomPropertyStore | [inline]
CCustomPropertyStore() | CCustomPropertyStore |
Clone(ITfPropertyStore **ppClone) | CCustomPropertyStore |
Divide(ITfRange *pRangeThis, ITfRange *pRangeNew, ITfPropertyStore **ppPropertyStore) | CCustomPropertyStore |
GetData(VARIANT *pvarValue) | CCustomPropertyStore |
GetDataType(DWORD *pdwReserved) | CCustomPropertyStore |
GetPropertyRangeCreator(CLSID *pclsid) | CCustomPropertyStore |
GetType(GUID *pguidType) | CCustomPropertyStore |
OnTextUpdated(DWORD dwFlags, ITfRange *pRangeNew, BOOL *pfAccept) | CCustomPropertyStore |
QueryInterface(REFIID riid, void **ppvObj) | CCustomPropertyStore |
Serialize(IStream *pStream, ULONG *pcb) | CCustomPropertyStore |
Shrink(ITfRange *pRangeNew, BOOL *pfFree) | CCustomPropertyStore |
STDMETHODIMP_(ULONG) AddRef(void) | CCustomPropertyStore |
STDMETHODIMP_(ULONG) Release(void) | CCustomPropertyStore |
~CCustomPropertyStore() | CCustomPropertyStore |
Generated on Wed Nov 13 2024 16:55:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMFT/CConf.Cpp Source File

  • Web
  • NetMeeting
  • NMFT

CConf.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMFT.EXE
00003 //  File:       CCONF.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 // Global Varaiables
00018 INmManager    * g_pMgr  = NULL;         // The Conference Manager
00019 INmConference * g_pConference = NULL;   // The Current Conference
00020 INmChannelFt  * g_pChannelFt = NULL;    // The File Transfer Channel
00021 CFtNotify     * g_pNotifyFt = NULL;     // The File Transfer Notify Hook
00022 INmMember     * g_pMember = NULL;       // The destination
00023 INmFt         * g_pFt = NULL;           // The File Transfer Object
00024
00025
00026 // Local Application Guid : {3582DED0-9CCF-11d0-8B26-00A0C91BC90E}
00027 const GUID g_guidApp =
00028 {0x3582ded0, 0x9ccf, 0x11d0, { 0x8b, 0x26, 0x0, 0xa0, 0xc9, 0x1b, 0xc9, 0xe} };
00029
00030
00031 //****************************************************************************
00032 //
00033 // HRESULT InitConfMgr(void)
00034 //
00035 //****************************************************************************
00036
00037 HRESULT InitConfMgr(void)
00038 {
00039   HRESULT     hr  = NULL;
00040   LPCLASSFACTORY  pcf = NULL;
00041
00042   // Notify the system we want to use the conferencing services
00043   // by creating a conference manager object
00044
00045   hr = CoGetClassObject(CLSID_NmManager, CLSCTX_INPROC, NULL, IID_IClassFactory, (void**)&pcf);
00046
00047   if (SUCCEEDED(hr))
00048   {
00049     if  (NULL == pcf)
00050       return E_POINTER;
00051
00052     // Get the conference manager object
00053     hr = pcf->CreateInstance(NULL, IID_INmManager, (void**)&g_pMgr);
00054     if (SUCCEEDED(hr))
00055     {
00056       hr  = E_POINTER;
00057       if  (NULL != g_pMgr)
00058       {
00059         ULONG uchCaps = NMCH_ALL;
00060         ULONG uOptions  = 0;
00061
00062         hr = g_pMgr->Initialize(&uOptions, &uchCaps);
00063       }
00064     }
00065
00066     pcf->Release();
00067     pcf = NULL;
00068   }
00069
00070   return hr;
00071 }
00072
00073
00074 //****************************************************************************
00075 //
00076 // HRESULT GetActiveConference(void)
00077 //
00078 //****************************************************************************
00079
00080 HRESULT GetActiveConference(void)
00081 {
00082   HRESULT         hr  = NO_ERROR  ;
00083   IEnumNmConference * pEnum = NULL    ;
00084
00085   if (NULL == g_pMgr)
00086   {
00087     return E_FAIL;
00088   }
00089
00090   hr = g_pMgr->EnumConference(&pEnum);
00091   if (SUCCEEDED(hr))
00092   {
00093     if  (NULL == pEnum)
00094       return E_POINTER;
00095
00096     hr = pEnum->Next(1, &g_pConference, NULL);
00097     if SUCCEEDED(hr)
00098     {
00099       hr  = E_POINTER;
00100       if  (NULL != g_pConference)
00101       {
00102         NM_CONFERENCE_STATE confState;
00103         hr = g_pConference->GetState(&confState);
00104         if (SUCCEEDED(hr))
00105         {
00106           hr = (NM_CONFERENCE_ACTIVE == confState) ? S_OK : S_FALSE;
00107         }
00108       }
00109     }
00110
00111     pEnum->Release();
00112     pEnum = NULL;
00113   }
00114
00115   return hr;
00116 }
00117
00118
00119 //****************************************************************************
00120 //
00121 // VOID FreeFtChannel(void)
00122 //
00123 //****************************************************************************
00124
00125 VOID FreeFtChannel(void)
00126 {
00127   if (NULL != g_pFt)
00128   {
00129     g_pFt->Release();
00130     g_pFt = NULL;
00131   }
00132
00133   // Release all notify
00134   if (NULL != g_pNotifyFt)
00135   {
00136     g_pNotifyFt->Disconnect();
00137     g_pNotifyFt->Release();
00138     g_pNotifyFt = NULL;
00139   }
00140
00141   if (NULL != g_pChannelFt)
00142   {
00143     g_pChannelFt->Release();
00144     g_pChannelFt = NULL;
00145   }
00146 }
00147
00148
00149 //****************************************************************************
00150 //
00151 // HRESULT GetFtChannel(void)
00152 //
00153 //****************************************************************************
00154
00155 HRESULT GetFtChannel(void)
00156 {
00157   HRESULT       hr    = NO_ERROR  ;
00158   BOOL        fFound  = FALSE   ;
00159   ULONG       nmch    = 0     ;
00160   INmChannel    * pChannel  = NULL    ;
00161   IEnumNmChannel  * pEnum   = NULL    ;
00162
00163   if (NULL == g_pConference)
00164   {
00165     return E_FAIL;
00166   }
00167
00168   // TODO: Check if active and in data conference
00169
00170   hr = g_pConference->EnumChannel(&pEnum);
00171   if (SUCCEEDED(hr))
00172   {
00173     if  (NULL == pEnum)
00174       return E_FAIL;
00175
00176     while (SUCCEEDED(hr) && !fFound)
00177     {
00178       hr = pEnum->Next(1, &pChannel, NULL);
00179
00180       if FAILED(hr)
00181         break;
00182
00183       if  (NULL == pChannel)
00184       {
00185         hr = E_FAIL;
00186         break;
00187       }
00188
00189       hr = pChannel->GetNmch(&nmch);
00190
00191       if (SUCCEEDED(hr) && (NMCH_FT == nmch))
00192       {
00193         hr = pChannel->QueryInterface(IID_INmChannelFt, (PVOID *) &g_pChannelFt);
00194         fFound = ((S_OK == hr) && (NULL != g_pChannelFt));
00195       }
00196
00197       pChannel->Release();
00198       pChannel = NULL;
00199     }
00200
00201     pEnum->Release();
00202     pEnum = NULL;
00203   }
00204
00205   return fFound ? S_OK : hr;
00206 }
00207
00208
00209 //****************************************************************************
00210 //
00211 // HRESULT HookFtChannel(void)
00212 //
00213 //****************************************************************************
00214
00215 HRESULT HookFtChannel(void)
00216 {
00217   HRESULT     hr    = NO_ERROR  ;
00218   CFtNotify * pNotify = NULL    ;
00219
00220   ASSERT(NULL != g_pChannelFt);
00221   if  (NULL == g_pChannelFt)
00222     return E_FAIL;
00223
00224     // Connect to the channel object
00225     pNotify = new CFtNotify();
00226     if (pNotify == NULL)
00227     {
00228         hr = E_OUTOFMEMORY;
00229     }
00230     else
00231     {
00232     hr = pNotify->Connect(g_pChannelFt);
00233     if (SUCCEEDED(hr))
00234     {
00235       g_pNotifyFt = pNotify;
00236     }
00237     else
00238     {
00239       pNotify -> Release();
00240       pNotify =  NULL;
00241     }
00242   }
00243
00244   if (FAILED(hr))
00245   {
00246     FreeFtChannel();
00247   }
00248
00249   return hr;
00250 }
00251
00252
00253 //****************************************************************************
00254 //
00255 // HRESULT SendFile(void)
00256 //
00257 //****************************************************************************
00258
00259 HRESULT SendFile(void)
00260 {
00261   HRESULT hr  = NO_ERROR;
00262
00263   if (NULL == g_pChannelFt)
00264   {
00265     return E_FAIL;
00266   }
00267
00268   BSTRING bstrFile(g_szFile);
00269   hr = g_pChannelFt->SendFile(&g_pFt, g_pMember, bstrFile, 0);
00270   return hr;
00271 }
00272
00273
00274 HWND ghwndProgress = NULL;
00275
00276 VOID UpdateProgress(CONFN uNotify)
00277 {
00278   HRESULT hr  = NO_ERROR;
00279
00280   if ((NULL == g_pFt) || (NULL == ghwndMain))
00281   {
00282     return;
00283   }
00284
00285   NM_FT_STATE uState;
00286   hr = g_pFt->GetState(&uState);
00287
00288
00289   switch (uNotify)
00290     {
00291   case CONFN_FT_STARTED:
00292   {
00293     TCHAR szMsg[MAX_PATH + 1];
00294
00295     ZeroMemory(szMsg, MAX_PATH + 1);
00296
00297     // Fill out "Sending <filename>"
00298
00299     _sntprintf(szMsg, MAX_PATH, TEXT("Sending %s"), (NULL != g_szFile) ? g_szFile : TEXT("<Null>"));
00300     SetDlgItemText(ghwndMain, IDE_SEND, szMsg);
00301
00302     ULONG uBytes  = 0;
00303     if (FAILED(g_pFt->GetSize(&uBytes)))
00304       uBytes = 0;
00305
00306     // Fill out "to <user> (x bytes)"
00307
00308     SetDlgItemText(ghwndMain, IDE_DEST, szMsg);
00309
00310     ghwndProgress = GetDlgItem(ghwndMain, IDC_PROGRESS);
00311     ASSERT(NULL != ghwndProgress);
00312
00313     SendMessage(ghwndProgress, PBM_SETPOS, 0, 0);
00314     ShowWindow(ghwndMain, SW_SHOW);
00315     SetFocus(GetDlgItem(ghwndMain, IDCANCEL));
00316     break;
00317   }
00318
00319   case CONFN_FT_PROGRESS:
00320   {
00321     ULONG uPercent    = 0 ;
00322     ULONG uBytesCurr  = 0 ;
00323     ULONG uBytesTotal = 0 ;
00324
00325     if (FAILED(g_pFt->GetBytesTransferred(&uBytesCurr)) ||
00326       FAILED(g_pFt->GetSize(&uBytesTotal)))
00327     {
00328       return;
00329     }
00330
00331     if (0 == uBytesTotal)
00332       uPercent = 100;
00333     else
00334       uPercent = uBytesCurr * 100 / uBytesTotal;
00335
00336     SendMessage(ghwndProgress, PBM_SETPOS, uPercent, 0);
00337     break;
00338   }
00339
00340   case CONFN_FT_COMPLETE:
00341   case CONFN_FT_CANCELED:
00342   {
00343     SetDlgItemText(ghwndMain, IDCANCEL, TEXT("Close"));
00344     break;
00345   }
00346
00347   default:
00348     return;
00349     }
00350 }
00351
00352
00353 //****************************************************************************
00354 //
00355 // CLASS CNotify
00356 //
00357 //****************************************************************************
00358
00359
00360 //****************************************************************************
00361 //
00362 // Constructor
00363 //
00364 //****************************************************************************
00365
00366 CFtNotify::CFtNotify() : RefCount(), CNotify()
00367 {
00368 }
00369
00370
00371 //****************************************************************************
00372 //
00373 // Destructor
00374 //
00375 //****************************************************************************
00376
00377 CFtNotify::~CFtNotify()
00378 {
00379 }
00380
00381
00382 //****************************************************************************
00383 //
00384 // Methods from IUnknown
00385 //
00386 //****************************************************************************
00387
00388 ULONG STDMETHODCALLTYPE CFtNotify::AddRef(void)
00389 {
00390   return RefCount::AddRef();
00391 }
00392
00393
00394 ULONG STDMETHODCALLTYPE CFtNotify::Release(void)
00395 {
00396   return RefCount::Release();
00397 }
00398
00399 HRESULT STDMETHODCALLTYPE CFtNotify::QueryInterface(REFIID riid, PVOID *ppvObject)
00400 {
00401   if  (NULL == ppvObject)
00402     return E_POINTER;
00403
00404   HRESULT hr = NO_ERROR;
00405
00406   if (riid == IID_IUnknown)
00407   {
00408     *ppvObject = (IUnknown *)this;
00409   }
00410   else if (riid == IID_INmChannelFtNotify)
00411   {
00412     *ppvObject = (INmChannelFtNotify *)this;
00413   }
00414   else
00415   {
00416     hr = E_NOINTERFACE;
00417     *ppvObject = NULL;
00418   }
00419
00420   if SUCCEEDED(hr)
00421   {
00422     AddRef();
00423   }
00424
00425   return hr;
00426 }
00427
00428
00429 //****************************************************************************
00430 //
00431 // Methods from ICNotify
00432 //
00433 //****************************************************************************
00434
00435 HRESULT STDMETHODCALLTYPE CFtNotify::Connect(IUnknown *pUnk)
00436 {
00437   return CNotify::Connect(pUnk, IID_INmChannelFtNotify, (IUnknown *)this);
00438 }
00439
00440 HRESULT STDMETHODCALLTYPE CFtNotify::Disconnect(void)
00441 {
00442   return CNotify::Disconnect();
00443 }
00444
00445
00446 //****************************************************************************
00447 //
00448 // Methods from IConfNotify
00449 //
00450 //****************************************************************************
00451
00452 HRESULT STDMETHODCALLTYPE CFtNotify::NmUI(CONFN uNotify)
00453 {
00454   return S_OK;
00455 }
00456
00457 HRESULT STDMETHODCALLTYPE CFtNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
00458 {
00459   return S_OK;
00460 }
00461
00462 HRESULT STDMETHODCALLTYPE CFtNotify::FtUpdate(CONFN uNotify, INmFt * pFt)
00463 {
00464   if (NULL != pFt)
00465   {
00466     UpdateProgress(uNotify);
00467   }
00468
00469   if  ((CONFN_FT_COMPLETE == uNotify) || (CONFN_FT_CANCELED == uNotify))
00470   {
00471     PostMessage(ghwndMain, WM_QUIT, 0, 0);
00472   }
00473
00474   return S_OK;
00475 }
00476
00477
00478
00479 //****************************************************************************
00480 //
00481 // VOID FreeNmObjects(void)
00482 //
00483 //****************************************************************************
00484
00485 VOID FreeNmObjects(void)
00486 {
00487   FreeFtChannel();
00488
00489   // Release conference
00490   if (NULL != g_pConference)
00491   {
00492     g_pConference->Release();
00493     g_pConference = NULL;
00494   }
00495
00496   // Release conference manager
00497   if (NULL != g_pMgr)
00498   {
00499     g_pMgr->Release();
00500     g_pMgr = NULL;
00501   }
00502 }
00503
00504
00505 //****************************************************************************
00506 //
00507 // BOOL FInitNm(void)
00508 //
00509 //****************************************************************************
00510
00511 BOOL FInitNm(void)
00512 {
00513   if (S_OK != InitConfMgr())
00514     return FALSE;
00515
00516   if (S_OK != GetActiveConference())
00517     return FALSE;
00518
00519   if (S_OK != GetFtChannel())
00520     return FALSE;
00521
00522   if (S_OK != HookFtChannel())
00523     return FALSE;
00524
00525   return TRUE;
00526 }
00527
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSchemaDlg Member List

This is the complete list of members for CSchemaDlg, including all inherited members.
ChangeRestrictions() | CSchemaDlg | [virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CRowsetViewerDlg(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRowsetViewerDlg |
CSchemaDlg(CMDIChild *pCMDIChild) | CSchemaDlg |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
Display() | CSchemaDlg | [virtual]
DisplayTree() | CSchemaDlg | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetOptions() | CRowsetViewerDlg | [virtual]
GetSelectedRestrictions() | CSchemaDlg | [virtual]
GetSelectedSchema(SCHEMAINFO **ppSchemaInfo, ULONG *pdwRestrictions=NULL) | CSchemaDlg | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
InitSchemaCombo(BOOL fShowSupported) | CSchemaDlg | [virtual]
InitSchemas(HWND hWnd) | CSchemaDlg | [virtual]
InitTreeView(HWND hWnd) | CSchemaDlg | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_comboSchema | CSchemaDlg |
m_CPropSets | CSchemaDlg |
m_cRestrictions | CSchemaDlg |
m_cSchemas | CSchemaDlg |
m_fActive | CSchemaDlg |
m_fEditing | CSchemaDlg |
m_fShowSupported | CSchemaDlg |
m_fUseProperties | CSchemaDlg |
m_fUseRestrictions | CSchemaDlg |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_hWndSchemas | CSchemaDlg |
m_hWndTreeView | CSchemaDlg |
m_hWndTreeWnd | CSchemaDlg |
m_iOldSchemaIndex | CSchemaDlg |
m_iSchemaIndex | CSchemaDlg |
m_nID | CWndLite |
m_pCMainWindow | CRowsetViewerDlg |
m_pCMDIChild | CRowsetViewerDlg |
m_pCTreeRowset | CSchemaDlg |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_rgResName | CSchemaDlg |
m_rgRestrictions | CSchemaDlg |
m_rgRestrictionSupport | CSchemaDlg |
m_rgResType | CSchemaDlg |
m_rgResValue | CSchemaDlg |
m_rgSchemas | CSchemaDlg |
m_SchemaInfo | CSchemaDlg |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
RefreshTreeControls() | CSchemaDlg | [virtual]
SchemaRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CSchemaDlg | [static]
SchemaTreeProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CSchemaDlg | [static]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CSchemaDlg() | CSchemaDlg | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/CConf.h Source File

  • Web
  • NetMeeting
  • NMChat

CConf.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       CCONF.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 //****************************************************************************
00016 //
00017 // CLASS CMgrNotify
00018 //
00019 //****************************************************************************
00020
00021 class CMgrNotify : public RefCount, public CNotify, public INmManagerNotify
00022 {
00023 public:
00024   CMgrNotify();
00025   ~CMgrNotify();
00026
00027   // INmManagerNotify
00028   HRESULT STDMETHODCALLTYPE NmUI(CONFN confn);
00029   HRESULT STDMETHODCALLTYPE ConferenceCreated(INmConference *pConference);
00030   HRESULT STDMETHODCALLTYPE CallCreated(INmCall *pCall);
00031
00032   // ICNotify methods
00033   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00034   HRESULT STDMETHODCALLTYPE Disconnect(void);
00035
00036   // IUnknown methods
00037   ULONG STDMETHODCALLTYPE AddRef(void);
00038   ULONG STDMETHODCALLTYPE Release(void);
00039   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00040 };
00041
00042
00043 //****************************************************************************
00044 //
00045 // CLASS CConfNotify
00046 //
00047 //****************************************************************************
00048
00049 class CConfNotify : public RefCount, public CNotify, public INmConferenceNotify
00050 {
00051 public:
00052   CConfNotify();
00053   ~CConfNotify();
00054
00055   // INmConferenceNotify
00056   HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
00057   HRESULT STDMETHODCALLTYPE StateChanged(NM_CONFERENCE_STATE uState);
00058   HRESULT STDMETHODCALLTYPE MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pfMember);
00059   HRESULT STDMETHODCALLTYPE ChannelChanged(NM_CHANNEL_NOTIFY uNotify, INmChannel *pChannel);
00060
00061   // ICNotify methods
00062   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00063   HRESULT STDMETHODCALLTYPE Disconnect(void);
00064
00065   // IUnknown methods
00066   ULONG STDMETHODCALLTYPE AddRef(void);
00067   ULONG STDMETHODCALLTYPE Release(void);
00068   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00069 };
00070
00071
00072
00073 // Global Variables
00074 extern INmManager * g_pMgr;
00075 extern INmConference * g_pConference;
00076 extern BOOL g_fActiveConference;
00077
00078 // Global Functions
00079 HRESULT InitConfMgr(void);
00080 VOID FreeConfMgr(void);
00081 VOID FreeConference(void);
00082 HRESULT HookConference(INmConference * pConference);
00083
00084
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImportRes Member List

This is the complete list of members for CImportRes, including all inherited members.
CImportRes(const TCHAR *szDatabase, const TCHAR *szSaveDatabase, const TCHAR *szDLLFile) | CImportRes | [inline]
ImportDialog(TCHAR *szDialog) | CImportRes |
ImportDialogs() | CImportRes |
ImportDlgInit() | CImportRes | [private]
ImportStrings() | CImportRes |
Initialize() | CImportRes | [private]
IsInErrorState() | CImportRes | [inline]
LoadDialog(HINSTANCE hModule, const TCHAR *szType, TCHAR *szDialog) | CImportRes |
LoadString(HINSTANCE hModule, const TCHAR *szType, TCHAR *szString) | CImportRes |
m_fError | CImportRes | [private]
m_fFoundLang | CImportRes | [private]
m_fSetCodepage | CImportRes | [private]
m_hControl | CImportRes | [private]
m_hDatabase | CImportRes | [private]
m_hDialog | CImportRes | [private]
m_hInst | CImportRes | [private]
m_hRadioButton | CImportRes | [private]
m_szDatabase | CImportRes | [private]
m_szDLLFile | CImportRes | [private]
m_szOrigDb | CImportRes | [private]
SetCodePage(WORD wLang) | CImportRes |
SetErrorState(BOOL fState) | CImportRes | [inline]
SetFoundLang(BOOL fValue) | CImportRes | [inline]
VerifyDatabaseCodepage() | CImportRes | [private]
WasLanguagePreviouslyFound() | CImportRes | [inline]
~CImportRes() | CImportRes |
Generated on Wed Nov 13 2024 16:56:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SmartRefPointer< T > Member List

This is the complete list of members for SmartRefPointer< T >, including all inherited members.
Clear() | SmartRefPointer< T > | [inline]
Get() const | SmartRefPointer< T > | [inline]
GetRecvPointer() | SmartRefPointer< T > | [inline]
m_Interface | SmartRefPointer< T > | [private]
operator const T *() const | SmartRefPointer< T > | [inline]
operator->() const | SmartRefPointer< T > | [inline]
operator=(SmartRefPointer &Other) | SmartRefPointer< T > | [inline]
RefIt() | SmartRefPointer< T > | [inline, private]
Release() | SmartRefPointer< T > | [inline]
ReleaseIt() | SmartRefPointer< T > | [inline, private]
SmartRefPointer() | SmartRefPointer< T > | [inline]
SmartRefPointer(T *RawInterface) | SmartRefPointer< T > | [inline]
SmartRefPointer(SmartRefPointer &Other) | SmartRefPointer< T > | [inline]
~SmartRefPointer() | SmartRefPointer< T > | [inline]
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/people.h Source File

  • SysMgmt
  • MMC
  • Taskpads

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBicycle : public CDelegationBase {
00026 public:
00027     CBicycle(int i) : id(i) { }
00028     virtual ~CBicycle() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00033
00034 private:
00035     // {2974380D-4C4B-11d2-89D8-000021473128}
00036     static const GUID thisGuid;
00037
00038     int id;
00039 };
00040
00041 class CBicycleFolder : public CDelegationBase {
00042 public:
00043     CBicycleFolder();
00044     virtual ~CBicycleFolder();
00045
00046     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Bicycles (horizontal listpad)"); }
00047     virtual const GUID & getNodeType() { return thisGuid; }
00048     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00049
00050     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00051
00052 public:
00053     // virtual functions go here (for MMCN_*)
00054     virtual HRESULT OnListpad(IConsole *pConsole, BOOL bAttaching);
00055
00056   // taskpad support
00057     virtual HRESULT TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2);
00058     virtual MMC_TASK *GetTaskList(LPOLESTR szTaskGroup, LONG *nCount);
00059   virtual HRESULT GetTaskpadTitle(LPOLESTR *pszTitle);
00060   virtual HRESULT GetTaskpadDescription(LPOLESTR *pszDescription);
00061   virtual HRESULT GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO);
00062   virtual HRESULT GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo);
00063
00064 private:
00065     // {2974380D-4C4B-11d2-89D8-000021473128}
00066     static const GUID thisGuid;
00067
00068     enum { NUMBER_OF_CHILDREN = 20 };
00069     CDelegationBase *children[NUMBER_OF_CHILDREN];
00070 };
00071
00072 class CSkateboard : public CDelegationBase {
00073 public:
00074     CSkateboard(int i) : id(i) { }
00075     virtual ~CSkateboard() {}
00076
00077     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00078     virtual const GUID & getNodeType() { return thisGuid; }
00079     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00080
00081 private:
00082     // {2974380D-4C4B-11d2-89D8-000021473128}
00083     static const GUID thisGuid;
00084
00085     int id;
00086 };
00087
00088 class CSkateboardFolder : public CDelegationBase {
00089 public:
00090     CSkateboardFolder();
00091     virtual ~CSkateboardFolder();
00092
00093     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Skateboards (taskpad)"); }
00094     virtual const GUID & getNodeType() { return thisGuid; }
00095     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00096
00097     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00098
00099 public:
00100   // taskpad support
00101     virtual HRESULT TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2);
00102     virtual MMC_TASK *GetTaskList(LPOLESTR szTaskGroup, LONG *nCount);
00103   virtual HRESULT GetTaskpadTitle(LPOLESTR *pszTitle);
00104   virtual HRESULT GetTaskpadDescription(LPOLESTR *pszDescription);
00105   virtual HRESULT GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO);
00106   virtual HRESULT GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo);
00107
00108 private:
00109     // {2974380D-4C4B-11d2-89D8-000021473128}
00110     static const GUID thisGuid;
00111
00112     enum { NUMBER_OF_CHILDREN = 20 };
00113     CDelegationBase *children[NUMBER_OF_CHILDREN];
00114 };
00115
00116 class CIceSkate : public CDelegationBase {
00117 public:
00118     CIceSkate(int i) : id(i), bSelected(false) { }
00119     virtual ~CIceSkate() {}
00120
00121     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00122     virtual const GUID & getNodeType() { return thisGuid; }
00123     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00124
00125     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00126
00127 private:
00128     // {2974380D-4C4B-11d2-89D8-000021473128}
00129     static const GUID thisGuid;
00130
00131     int id;
00132     bool bSelected;
00133
00134 public:
00135     bool IsSelected() const { return bSelected; }
00136 };
00137
00138 class CIceSkateFolder : public CDelegationBase {
00139 public:
00140     CIceSkateFolder();
00141     virtual ~CIceSkateFolder();
00142
00143     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Ice Skates (listpad)"); }
00144     virtual const GUID & getNodeType() { return thisGuid; }
00145     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00146
00147     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00148
00149 public:
00150     // virtual functions go here (for MMCN_*)
00151     virtual HRESULT OnListpad(IConsole *pConsole, BOOL bAttaching);
00152     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00153
00154   // taskpad support
00155     virtual HRESULT TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2);
00156     virtual MMC_TASK *GetTaskList(LPOLESTR szTaskGroup, LONG *nCount);
00157   virtual HRESULT GetTaskpadTitle(LPOLESTR *pszTitle);
00158   virtual HRESULT GetTaskpadDescription(LPOLESTR *pszDescription);
00159   virtual HRESULT GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO);
00160   virtual HRESULT GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo);
00161
00162 private:
00163     // {2974380D-4C4B-11d2-89D8-000021473128}
00164     static const GUID thisGuid;
00165
00166     enum { NUMBER_OF_CHILDREN = 20 };
00167     CIceSkate *children[NUMBER_OF_CHILDREN];
00168 };
00169
00170 class CPeoplePoweredVehicle : public CDelegationBase {
00171 public:
00172     CPeoplePoweredVehicle();
00173     virtual ~CPeoplePoweredVehicle();
00174
00175     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00176     virtual const GUID & getNodeType() { return thisGuid; }
00177     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00178
00179     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00180
00181 private:
00182     enum { IDM_NEW_PEOPLE = 1 };
00183
00184     // {2974380D-4C4B-11d2-89D8-000021473128}
00185     static const GUID thisGuid;
00186
00187     enum { NUMBER_OF_CHILDREN = 3 };
00188     CDelegationBase *children[3];
00189 };
00190
00191 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Object/OHello/cHello.Cxx Source File

  • Com
  • Fundamentals
  • Object
  • OHello

cHello.Cxx

Go to the documentation of this file.
00001 /*+----------------------------------------------------------------------------
00002
00003 Microsoft Windows Sample Program
00004 Copyright 1994 - 2000 Microsoft Corporation.  All rights reserved.
00005
00006 FILE:       CHello.cxx
00007
00008 PURPOSE:    Implements the CHello object and class factory.
00009
00010 CLASSES:    CHello
00011             CHelloClassFactory
00012
00013 FUNCTIONS:  RegisterClassFactory
00014             RevokeClassFactory
00015
00016 -----------------------------------------------------------------------------*/
00017 #include <windows.h>
00018 #include <stdio.h>
00019 #include "ohello.h"
00020
00021 void DecrementLockCount();
00022 void IncrementLockCount();
00023 void ObjectCreated();
00024 void ObjectDestroyed();
00025
00026 extern "C" const CLSID CLSID_OHello;
00027
00028 long    g_fClassRegistered  = FALSE;
00029 DWORD   g_dwRegister        = 0;
00030
00031 //The CHello class implements the server object.
00032 class CHello : public IHello
00033 {
00034 private:
00035     unsigned long    m_cRef;
00036
00037     //destructor
00038     ~CHello()
00039     {
00040         DecrementLockCount();
00041         ObjectDestroyed();
00042     }
00043
00044 public:
00045     //constructor
00046     CHello()
00047     {
00048         m_cRef = 1;
00049         ObjectCreated();
00050         IncrementLockCount();
00051     }
00052
00053   HRESULT STDMETHODCALLTYPE QueryInterface(
00054     REFIID iid,
00055       void **ppv);
00056
00057   ULONG STDMETHODCALLTYPE AddRef();
00058
00059   ULONG STDMETHODCALLTYPE Release();
00060
00061   HRESULT STDMETHODCALLTYPE HelloProc(unsigned char *pszString);
00062 };
00063
00064 //+-------------------------------------------------------------------------
00065 //
00066 //  Method:     CHello::AddRef, public
00067 //
00068 //  Synopsis:   Increment reference count
00069 //
00070 //  See Also:   IUnknown::AddRef
00071 //
00072 //--------------------------------------------------------------------------
00073 ULONG STDMETHODCALLTYPE
00074 CHello::AddRef()
00075 {
00076     InterlockedIncrement((long *) &m_cRef);
00077     return m_cRef;
00078 }
00079
00080 //+---------------------------------------------------------------------------
00081 //
00082 //  Method:     CHello::HelloProc()
00083 //
00084 //  Synopsis:   Displays the specified string.
00085 //
00086 //  See Also:   IHello::HelloProc
00087 //
00088 //----------------------------------------------------------------------------
00089 HRESULT STDMETHODCALLTYPE
00090 CHello::HelloProc(unsigned char *pszString)
00091 {
00092     printf("HelloProc: %s \n", pszString);
00093     return S_OK;
00094 }
00095
00096 //+-------------------------------------------------------------------------
00097 //
00098 //  Method:     CHello::QueryInterface, public
00099 //
00100 //  Synopsis:   Query for an interface on the class factory.
00101 //
00102 //  See Also:   IUnknown:QueryInterface
00103 //
00104 //--------------------------------------------------------------------------
00105 HRESULT STDMETHODCALLTYPE
00106 CHello::QueryInterface (
00107     REFIID iid,
00108     void **ppv )
00109 {
00110     HRESULT hr;
00111
00112     if ( IsEqualGUID( iid, IID_IUnknown ) ||
00113          IsEqualGUID( iid, IID_IHello ) )
00114     {
00115         *ppv = (IHello *) this;
00116         AddRef();
00117       hr = S_OK;
00118     }
00119     else
00120     {
00121         *ppv = 0;
00122         hr = E_NOINTERFACE;
00123     }
00124
00125     return hr;
00126 }
00127
00128 //+-------------------------------------------------------------------------
00129 //
00130 //  Method:     CHello::Release, public
00131 //
00132 //  Synopsis:   Decrement DLL reference count
00133 //
00134 //  Notes:      After the m_cRef is decremented, the object may be
00135 //              deleted by another thread.  In order to make this code safe
00136 //              for multiple threads, we have to access the object state
00137 //              before decrementing m_cRef.
00138 //
00139 //  See Also:   IUnknown::Release.
00140 //
00141 //--------------------------------------------------------------------------
00142 ULONG STDMETHODCALLTYPE
00143 CHello::Release()
00144 {
00145     unsigned long count;
00146
00147     count = m_cRef - 1;
00148
00149     if(InterlockedDecrement((long *) &m_cRef) == 0)
00150     {
00151         count = 0;
00152         delete this;
00153     }
00154
00155     return count;
00156 }
00157
00158
00159
00160 // this is the class factory for the CHello server object.
00161 // it manufactures CHello server objects in response to a CreateInstance
00162 // call
00163
00164 class CHelloClassFactory : public IClassFactory
00165 {
00166 private:
00167     unsigned long    m_cRef;
00168
00169     //destructor
00170     ~CHelloClassFactory()
00171     {
00172         ObjectDestroyed();
00173     }
00174
00175 public:
00176     //constructor
00177     CHelloClassFactory()
00178     {
00179         m_cRef = 1;
00180         ObjectCreated();
00181     }
00182
00183   HRESULT STDMETHODCALLTYPE QueryInterface(
00184     REFIID iid,
00185       void **ppv);
00186
00187   ULONG STDMETHODCALLTYPE AddRef();
00188
00189   ULONG STDMETHODCALLTYPE Release();
00190
00191   HRESULT STDMETHODCALLTYPE CreateInstance(
00192       IUnknown *punkOuter,
00193       REFIID riid,
00194       void **ppv);
00195
00196    HRESULT STDMETHODCALLTYPE LockServer(
00197         BOOL fLock );
00198
00199 };
00200
00201 //+-------------------------------------------------------------------------
00202 //
00203 //  Method:     CHelloClassFactory::AddRef, public
00204 //
00205 //  Synopsis:   Increment DLL reference counts
00206 //
00207 //  See Also:   IUnknown::AddRef
00208 //
00209 //--------------------------------------------------------------------------
00210 ULONG STDMETHODCALLTYPE
00211 CHelloClassFactory::AddRef()
00212 {
00213     InterlockedIncrement((long *) &m_cRef);
00214     return m_cRef;
00215 }
00216
00217 //+-------------------------------------------------------------------------
00218 //
00219 //  Method:     CHelloClassFactory::CreateInstance, public
00220 //
00221 //  Synopsis:   Create an instance of CHello.
00222 //
00223 //  See Also:   IClassFactory::CreateInstance
00224 //
00225 //--------------------------------------------------------------------------
00226 HRESULT STDMETHODCALLTYPE
00227 CHelloClassFactory::CreateInstance
00228 (
00229     IUnknown *punkOuter,
00230     REFIID riid,
00231     void **ppv
00232 )
00233 {
00234     HRESULT hr;
00235     CHello *pHello;
00236
00237     if(punkOuter != 0)
00238     {
00239         //The CHello class doesn't support aggregation.
00240         return CLASS_E_NOAGGREGATION;
00241     }
00242
00243     pHello = new CHello();
00244     if(pHello != 0)
00245     {
00246         hr = pHello->QueryInterface(riid, ppv);
00247         pHello->Release();
00248     }
00249     else
00250     {
00251         hr = E_OUTOFMEMORY;
00252         *ppv = 0;
00253     }
00254
00255     return hr;
00256 }
00257
00258 //+-------------------------------------------------------------------------
00259 //
00260 //  Method:     CHelloClassFactory::LockServer, public
00261 //
00262 //  Synopsis:   Lock the server in memory (by adding an extra reference)
00263 //
00264 //  Notes:      The class factory will be revoked when the lock count
00265 //              is decremented to zero.  LockServer(TRUE) will increment the
00266 //              lock count and ensure that the class factory will
00267 //              not be revoked.
00268 //
00269 //  See Also:   IClassFactory::LockServer
00270 //
00271 //--------------------------------------------------------------------------
00272 HRESULT STDMETHODCALLTYPE
00273 CHelloClassFactory::LockServer(
00274     BOOL fLock )
00275 {
00276     if (fLock == TRUE)
00277         IncrementLockCount();
00278     else
00279         DecrementLockCount();
00280
00281     return S_OK;
00282 }
00283
00284
00285 //+-------------------------------------------------------------------------
00286 //
00287 //  Method:     CHelloClassFactory::QueryInterface, public
00288 //
00289 //  Synopsis:   Query for an interface on the class factory.
00290 //
00291 //  See Also:   IUnknown::QueryInterface
00292 //
00293 //--------------------------------------------------------------------------
00294 HRESULT STDMETHODCALLTYPE
00295 CHelloClassFactory::QueryInterface (
00296     REFIID iid,
00297     void **ppv )
00298 {
00299     HRESULT hr;
00300
00301     if ( IsEqualGUID( iid, IID_IUnknown) ||
00302          IsEqualGUID( iid, IID_IClassFactory ) )
00303     {
00304         *ppv = this;
00305         AddRef();
00306         hr = S_OK;
00307     }
00308     else
00309     {
00310         *ppv = 0;
00311         hr = E_NOINTERFACE;
00312     }
00313
00314     return hr;
00315 }
00316 //+-------------------------------------------------------------------------
00317 //
00318 //  Method:     CHelloClassFactory::Release, public
00319 //
00320 //  Synopsis:   Decrement DLL reference count
00321 //
00322 //  See Also:   IUnknown::Release
00323 //
00324 //--------------------------------------------------------------------------
00325 ULONG STDMETHODCALLTYPE
00326 CHelloClassFactory::Release()
00327 {
00328     unsigned long count;
00329
00330     count = m_cRef - 1;
00331
00332     if(InterlockedDecrement((long *) &m_cRef) == 0)
00333     {
00334         count = 0;
00335
00336         ObjectDestroyed();
00337     }
00338
00339     return count;
00340 }
00341
00342 //+-------------------------------------------------------------------------
00343 //
00344 //  Function:   RegisterClassFactory.
00345 //
00346 //  Synopsis:   Register the class factory if it is not currently registered.
00347 //
00348 //--------------------------------------------------------------------------
00349 HRESULT RegisterClassFactory()
00350 {
00351     HRESULT hr;
00352     CHelloClassFactory *pClassFactory;
00353
00354     if(InterlockedExchange(&g_fClassRegistered, TRUE) == FALSE)
00355     {
00356         pClassFactory = new CHelloClassFactory;
00357
00358         if(pClassFactory != 0)
00359         {
00360             hr = CoRegisterClassObject(CLSID_OHello,
00361                                  (IUnknown *) pClassFactory,
00362                                  CLSCTX_LOCAL_SERVER,
00363                                  REGCLS_MULTIPLEUSE,
00364                                  &g_dwRegister);
00365             pClassFactory->Release();
00366         }
00367         else
00368         {
00369            hr = E_OUTOFMEMORY;
00370         }
00371     }
00372     else
00373     {
00374         hr = S_OK;
00375     }
00376     return hr;
00377 }
00378
00379 //+-------------------------------------------------------------------------
00380 //
00381 //  Function:   RevokeClassFactory.
00382 //
00383 //  Synopsis:   Revoke the registered class factories if they have not
00384 //              already been revoked.
00385 //
00386 //--------------------------------------------------------------------------
00387 HRESULT RevokeClassFactory()
00388 {
00389     HRESULT hr;
00390
00391     if(InterlockedExchange(&g_fClassRegistered, FALSE) == TRUE)
00392     {
00393         hr = CoRevokeClassObject(g_dwRegister);
00394     }
00395     else
00396     {
00397         hr = S_OK;
00398     }
00399     return hr;
00400 }
00401
00402
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/dxtrans/dxsurf1/resource.h Source File

  • Web
  • dxtrans
  • dxsurf1

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by dxsurf1.rc
00004 //
00005 #define IDI_DXTICON                     101
00006 #define IDR_MENU1                       102
00007 #define IDM_ABOUT                       40001
00008 #define IDM_OPEN                        40002
00009 #define IDM_EXIT                        40003
00010
00011 // Next default values for new objects
00012 //
00013 #ifdef APSTUDIO_INVOKED
00014 #ifndef APSTUDIO_READONLY_SYMBOLS
00015 #define _APS_NEXT_RESOURCE_VALUE        103
00016 #define _APS_NEXT_COMMAND_VALUE         40004
00017 #define _APS_NEXT_CONTROL_VALUE         1000
00018 #define _APS_NEXT_SYMED_VALUE           101
00019 #endif
00020 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/people.h Source File

  • SysMgmt
  • MMC
  • CutCopy

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBicycle : public CDelegationBase {
00026 public:
00027     CBicycle(int i) : id(i) { }
00028     virtual ~CBicycle() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00033
00034 private:
00035     // {2974380D-4C4B-11d2-89D8-000021473128}
00036     static const GUID thisGuid;
00037
00038     int id;
00039 };
00040
00041 class CBicycleFolder : public CDelegationBase {
00042 public:
00043     CBicycleFolder();
00044     virtual ~CBicycleFolder();
00045
00046     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Bicycles"); }
00047     virtual const GUID & getNodeType() { return thisGuid; }
00048     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00049
00050 public:
00051     // virtual functions go here (for MMCN_*)
00052     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00053
00054 private:
00055     // {2974380D-4C4B-11d2-89D8-000021473128}
00056     static const GUID thisGuid;
00057
00058     enum { NUMBER_OF_CHILDREN = 20 };
00059     CDelegationBase *children[NUMBER_OF_CHILDREN];
00060 };
00061
00062 class CSkateboard : public CDelegationBase {
00063 public:
00064     CSkateboard(int i) : id(i) { }
00065     virtual ~CSkateboard() {}
00066
00067     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00068     virtual const GUID & getNodeType() { return thisGuid; }
00069     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00070
00071 private:
00072     // {2974380D-4C4B-11d2-89D8-000021473128}
00073     static const GUID thisGuid;
00074
00075     int id;
00076 };
00077
00078 class CSkateboardFolder : public CDelegationBase {
00079 public:
00080     CSkateboardFolder();
00081     virtual ~CSkateboardFolder();
00082
00083     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Skateboards"); }
00084     virtual const GUID & getNodeType() { return thisGuid; }
00085     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00086
00087 public:
00088     // virtual functions go here (for MMCN_*)
00089     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00090
00091 private:
00092     // {2974380D-4C4B-11d2-89D8-000021473128}
00093     static const GUID thisGuid;
00094
00095     enum { NUMBER_OF_CHILDREN = 20 };
00096     CDelegationBase *children[NUMBER_OF_CHILDREN];
00097 };
00098
00099 class CIceSkate : public CDelegationBase {
00100 public:
00101     CIceSkate(int i) : id(i) { }
00102     virtual ~CIceSkate() {}
00103
00104     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00105     virtual const GUID & getNodeType() { return thisGuid; }
00106     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00107
00108 private:
00109     // {2974380D-4C4B-11d2-89D8-000021473128}
00110     static const GUID thisGuid;
00111
00112     int id;
00113 };
00114
00115 class CIceSkateFolder : public CDelegationBase {
00116 public:
00117     CIceSkateFolder();
00118     virtual ~CIceSkateFolder();
00119
00120     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Ice Skates"); }
00121     virtual void GetChildColumnInfo(RESULTDATAITEM *rdi);
00122     virtual const GUID & getNodeType() { return thisGuid; }
00123     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00124
00125   virtual CDelegationBase *GetChildPtr(int index) {
00126     return (index < NUMBER_OF_CHILDREN) ? children[index] : NULL;
00127   }
00128
00129     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00130
00131 public:
00132     // virtual functions go here (for MMCN_*)
00133     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00134     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00135
00136 private:
00137     // {2974380D-4C4B-11d2-89D8-000021473128}
00138     static const GUID thisGuid;
00139
00140     enum { NUMBER_OF_CHILDREN = 5000 };
00141     CDelegationBase *children[NUMBER_OF_CHILDREN];
00142 };
00143
00144 class CPeoplePoweredVehicle : public CDelegationBase {
00145 public:
00146     CPeoplePoweredVehicle();
00147     virtual ~CPeoplePoweredVehicle();
00148
00149     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00150     virtual const GUID & getNodeType() { return thisGuid; }
00151     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00152
00153     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00154
00155 private:
00156     enum { IDM_NEW_PEOPLE = 1 };
00157
00158     // {2974380D-4C4B-11d2-89D8-000021473128}
00159     static const GUID thisGuid;
00160
00161     enum { NUMBER_OF_CHILDREN = 3 };
00162     CDelegationBase *children[3];
00163 };
00164
00165 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRTCEvents Member List

This is the complete list of members for CRTCEvents, including all inherited members.
AddRef() | CRTCEvents | [inline]
Advise(IRTCClient *pClient, HWND hWnd) | CRTCEvents | [inline]
CRTCEvents() | CRTCEvents | [inline]
Event(RTC_EVENT enEvent, IDispatch *pDisp) | CRTCEvents | [inline]
m_dwCookie | CRTCEvents | [private]
m_dwRefCount | CRTCEvents | [private]
m_hWnd | CRTCEvents | [private]
QueryInterface(REFIID iid, void **ppvObject) | CRTCEvents | [inline]
Release() | CRTCEvents | [inline]
Unadvise(IRTCClient *pClient) | CRTCEvents | [inline]
Generated on Wed Nov 13 2024 16:57:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/delebase.h Source File

  • SysMgmt
  • MMC
  • CutCopy

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CComponentData;
00030
00031 class CDelegationBase {
00032 public:
00033     CDelegationBase();
00034     virtual ~CDelegationBase();
00035
00036     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00037     virtual void GetChildColumnInfo(RESULTDATAITEM *rdi) { }
00038     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00039
00040     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00041     virtual const int GetBitmapIndex() = 0;
00042
00043   virtual CDelegationBase *GetChildPtr(int index) { return NULL; }
00044
00045     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00046
00047   virtual HRESULT SelectItem(IConsole *pConsole)
00048   {
00049     return pConsole->SelectScopeItem(HSCOPEITEM(m_handle));
00050   }
00051
00052 public:
00053     // virtual functions go here (for MMCN_*)
00054     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00055     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00056     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00057     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00058     virtual HRESULT OnRefresh(IConsole *pConsole) { return S_FALSE; }
00059   virtual HRESULT OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) { return S_FALSE; }
00060     virtual HRESULT OnRename(LPOLESTR pszNewName) { return S_FALSE; }
00061
00062   // cut / copy / paste implementation
00063   virtual HRESULT OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) { return S_FALSE; }
00064   virtual HRESULT OnQueryPaste(CDelegationBase *pPasted) { return S_FALSE; }
00065   virtual HRESULT OnDelete(IConsole *pConsole) { return S_FALSE; }
00066   virtual HRESULT OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) { _ASSERT(FALSE); return S_FALSE; }
00067
00068 public:
00069     static HBITMAP m_pBMapSm;
00070     static HBITMAP m_pBMapLg;
00071
00072   HANDLE GetHandle() { return m_handle; }
00073   void SetHandle(HANDLE handle) { m_handle = handle; }
00074
00075 protected:
00076     static void LoadBitmaps() {
00077         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00078         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00079     }
00080
00081     BOOL bExpanded;
00082
00083 private:
00084     // {2974380B-4C4B-11d2-89D8-000021473128}
00085     static const GUID thisGuid;
00086   HANDLE m_handle;
00087 };
00088
00089 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCRMSub Member List

This is the complete list of members for CCRMSub, including all inherited members.
CCRMSub(CComSpy *pSpy) | CCRMSub | [inline]
CCRMSub() | CCRMSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetEventClass(LPGUID guid) | CCRMSub | [inline, virtual]
GetEventType(EventEnum *e) | CCRMSub | [inline, virtual]
GetInterface(IID *iid) | CCRMSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnCRMAbort(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMAnalyze(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID, DWORD dwCrmRecordType, DWORD dwRecordSize) | CCRMSub |
OnCRMBegin(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID, GUID guidActivity, GUID guidTx, WCHAR szProgIdCompensator[64], WCHAR szDescription[64]) | CCRMSub |
OnCRMCheckpoint(COMSVCSEVENTINFO *pInfo, GUID guidApp) | CCRMSub |
OnCRMCommit(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMDeliver(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID, BOOL bVariants, DWORD dwRecordSize) | CCRMSub |
OnCRMDone(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMForce(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMForget(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMIndoubt(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMPrepare(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMRecoveryDone(COMSVCSEVENTINFO *pInfo, GUID guidApp) | CCRMSub |
OnCRMRecoveryStart(COMSVCSEVENTINFO *pInfo, GUID guidApp) | CCRMSub |
OnCRMRelease(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID) | CCRMSub |
OnCRMWrite(COMSVCSEVENTINFO *pInfo, GUID guidClerkCLSID, BOOL bVariants, DWORD dwRecordSize) | CCRMSub |
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:55:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPropPageLite Member List

This is the complete list of members for CPropPageLite, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | CPropPageLite | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CDialogLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CPropPageLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSetActive() | CPropPageLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

qcnotify::Notify Member List

This is the complete list of members for qcnotify::Notify, including all inherited members.
customerID | qcnotify::Notify | [private]
getShipStatusString(Integer statusVal) | qcnotify::Notify | [inline, private]
iid | qcnotify::INotifyDefault | [static]
itemVect | qcnotify::Notify | [private]
LineItem(int itemID, int quantity, int shipStatus) | qcnotify::Notify | [inline]
Notify() | qcnotify::Notify | [inline]
orderID | qcnotify::Notify | [private]
Process(int lFlags) | qcnotify::Notify | [inline]
quantityVect | qcnotify::Notify | [private]
setCustomerId(int customerID) | qcnotify::Notify | [inline]
setOrderId(int orderID) | qcnotify::Notify | [inline]
shipStatusVect | qcnotify::Notify | [private]
WriteDB() | qcnotify::Notify | [inline, private]
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/MMStrm.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

MMStrm.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       mmstrm.hxx
00006 //
00007 //  Contents:   Memory Mapped Stream
00008 //
00009 //  Classes:    CMmStream, CMmStreamBuf
00010 //
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #if !defined __MMSTRM_HXX__
00015 #define __MMSTRM_HXX__
00016
00017 #include <pmmstrm.hxx>
00018
00019 //+---------------------------------------------------------------------------
00020 //
00021 //  Class:      CMmStream
00022 //
00023 //  Purpose:    Memory Mapped Stream
00024 //
00025 //----------------------------------------------------------------------------
00026
00027 class CMmStream: public PMmStream
00028 {
00029     friend class CMmStreamBuf;
00030
00031 public:
00032     CMmStream();
00033
00034     CMmStream( WCHAR* wcsPath );
00035
00036     BOOL Ok() { return _hFile != INVALID_HANDLE_VALUE; }
00037
00038     virtual ~CMmStream();
00039
00040     void OpenRorW ( WCHAR* wcsPath );
00041
00042     void Open ( const WCHAR* wcsPath,
00043                 ULONG modeAccess,
00044                 ULONG modeShare,
00045                 ULONG modeCreate,
00046                 ULONG modeAttribute = FILE_ATTRIBUTE_NORMAL);
00047
00048     void Close();
00049
00050     void   SetSize ( PStorage& storage,
00051                      ULONG newSizeLow,
00052                      ULONG newSizeHigh=0 );
00053
00054     BOOL   isEmpty() { return _sizeHigh == 0 && _sizeLow == 0; }
00055
00056     ULONG  SizeLow() { return _sizeLow; }
00057
00058     ULONG  SizeHigh() { return _sizeHigh; }
00059
00060     LONGLONG Size() const
00061     {
00062         return llfromuls( _sizeLow, _sizeHigh );
00063     }
00064
00065     BOOL   isWritable() { return _fWrite; }
00066
00067     void   MapAll ( CMmStreamBuf& sbuf );
00068
00069     void   Map ( CMmStreamBuf& sbuf,
00070                          ULONG cb = 0,
00071                          ULONG offLow = 0,
00072                          ULONG offHigh = 0,
00073                          BOOL  fMapForWrite = FALSE );
00074
00075     void   Unmap ( CMmStreamBuf& sbuf );
00076
00077     void   Flush ( CMmStreamBuf& sbuf, ULONG cb );
00078
00079
00080 protected:
00081
00082     HANDLE _hFile;
00083     HANDLE _hMap;
00084
00085     ULONG  _sizeLow;
00086     ULONG  _sizeHigh;
00087
00088     BOOL   _fWrite;
00089 };
00090
00091 #endif
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/ProxyStub/CopyFileRm.Idl Source File

  • Com
  • Common
  • ProxyStub

CopyFileRm.Idl

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 ********************************************************************************
00004 * Filename: CopyFileRm.idl
00005 *
00006 * Description:  IDL source for CopyFileRm.dll
00007 *         This file will be processed by the MIDL tool to
00008 *       produce the type library (CopyFileRm.tlb) and marshalling code.
00009 *
00010 *
00011 * This file is provided as part of the Microsoft Transaction Server
00012 * Software Development Kit
00013 *
00014 *THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00015 *WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00016 *INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00017 *OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00018 *PURPOSE.
00019 *
00020 * Copyright (C) 1997 Microsoft Corporation, All rights reserved
00021 ********************************************************************************
00022 \******************************************************************************/
00023
00024
00025 import "oaidl.idl";
00026 import "ocidl.idl";
00027
00028   [
00029     object,
00030     uuid(BACEDF87-74AB-11D0-B162-00AA00BA3258),
00031     helpstring("IFileRm Interface"),
00032     pointer_default(unique)
00033   ]
00034   interface IFileRm : IUnknown
00035   {
00036     [helpstring("copy the list of files")]
00037     HRESULT CopyListTx([in] long lConHandle);
00038
00039     [helpstring("breaks a connection")]
00040     HRESULT Disconnect([in] long ulConnHandle);
00041
00042     [helpstring("Establishes a connection")]
00043     HRESULT Connect([in] BSTR sAppName, [out] long * ulConnHandle);
00044
00045     [helpstring("copy a file")]
00046     HRESULT FileCopyTx([in] long lConHandle, [in] BSTR sSource, [in] BSTR sDestination, [in] BOOL bFailIfExists);
00047
00048     [helpstring("rename a file")]
00049     HRESULT FileRenameTx([in] long lConHandle, [in] BSTR sSource, [in] BSTR sDestination);
00050
00051     [helpstring("add a file to copy")]
00052     HRESULT AddFile([in] long lConHandle, [in] BSTR sSource, [in] BSTR sDestination);
00053
00054     [helpstring("Move a file")]
00055     HRESULT FileMoveTxt([in] long lConHandle, [in] BSTR sSource, [in] BSTR sDestination);
00056
00057     [helpstring("delete a file")]
00058     HRESULT FileDeleteTx([in] long lConHandle, [in] BSTR sFileName);
00059
00060     [helpstring("gets the location of the TM")]
00061     HRESULT GetTmWhereabouts([in] long lConHandle,[out, size_is(, *pcbTmAddr)]BYTE **rgbTmAddr, [out] ULONG *pcbTmAddr);
00062
00063     [helpstring("Exports the Tx")]
00064     HRESULT ExportTx([in] long lConHandle, [in] ULONG cbTranCookie, [in, size_is(cbTranCookie)]BYTE *rgbTranCookie);
00065
00066     [helpstring("Resets the Worker for the given handle")]
00067     HRESULT ResetConnection([in] long lConHandle);
00068     [helpstring("method TMDown")] HRESULT TMDown();
00069
00070
00071   };
00072 [
00073   uuid(BACEDF7A-74AB-11D0-B162-00AA00BA3258),
00074   version(1.0),
00075   helpstring("CopyFileRm 1.0 Type Library")
00076 ]
00077 library COPYFILERMLib
00078 {
00079   importlib("stdole32.tlb");
00080
00081   [
00082     uuid(F67A6312-4EC4-11D0-9697-00AA00C149A6),
00083     helpstring("FileRm Class")
00084   ]
00085   coclass CoFileRm
00086   {
00087     [default] interface IFileRm;
00088   };
00089 };
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/Computer.Cpp Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

Computer.Cpp

Go to the documentation of this file.
00001 // Filename: Computer.cpp
00002 //
00003 // Description:  Implementation of CComputer
00004 // This file contains the code that handles the interaction between a human
00005 // player and a computer player.
00006 //
00007 // This file is provided as part of the Microsoft Transaction Server Samples
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00010 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00011 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00012 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00013 // PURPOSE.
00014 //
00015 // Copyright (C) 1997 - 2000 Microsoft Corporation, All rights reserved
00016
00017 #include "stdafx.h"
00018 #include "tServer.h"
00019 #include "Computer.h"
00020
00021 #include <mtx.h>
00022 //#include <mtxspm.h>
00023 #include <time.h>
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 //
00027
00028 STDMETHODIMP CComputer::InterfaceSupportsErrorInfo(REFIID riid)
00029 {
00030   static const IID* arr[] =
00031   {
00032     &IID_IComputer,
00033   };
00034
00035   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00036   {
00037     if (::InlineIsEqualGUID(*arr[i],riid))
00038       return S_OK;
00039   }
00040   return S_FALSE;
00041 }
00042
00043
00044 STDMETHODIMP CComputer::AddNewGame (IN VARIANT_BOOL bEasy, OUT VARIANT* pvGameID, OUT VARIANT* pvOrder,
00045                   OUT VARIANT* pvX, OUT VARIANT* pvY) {
00046
00047   HRESULT hr = S_OK;
00048
00049   IObjectContext* pObjectContext = NULL;
00050
00051   ISharedPropertyGroupManager* spmMgr = NULL;
00052   ISharedPropertyGroup* spmGroup = NULL;
00053
00054   ISharedProperty* spmPropCounter = NULL;
00055   ISharedProperty* spmPropState = NULL;
00056
00057   pvGameID->vt = VT_I4;
00058   pvOrder->vt = VT_I4;
00059   pvX->vt = VT_I4;
00060   pvY->vt = VT_I4;
00061
00062   long lGameID = 0;
00063   long lOrder = 0;
00064   long lNewX = 0;
00065   long lNewY = 0;
00066
00067
00068   try {
00069
00070     // Get the object context
00071     THROW_ERR ( hr = GetObjectContext(&pObjectContext) );
00072     if (pObjectContext == NULL) {
00073       THROW_ERR ( E_FAIL );
00074     }
00075
00076     // Create the SharedPropertyGroupManager
00077     THROW_ERR ( pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager, IID_ISharedPropertyGroupManager, (void**)&spmMgr) );
00078
00079     // Create the SharedPropertyGroup
00080     LONG lIsolationMode = LockMethod;
00081     LONG lReleaseMode = Process;
00082     VARIANT_BOOL bExists = VARIANT_FALSE;
00083     THROW_ERR ( spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode, &bExists, &spmGroup) );
00084
00085     // Create the counter properties
00086     THROW_ERR ( spmGroup->CreateProperty (L"Counter", &bExists, &spmPropCounter) );
00087
00088     // Obtain the current value of the counter
00089     CComVariant vCounter;
00090     THROW_ERR ( spmPropCounter->get_Value (&vCounter) );
00091
00092     // Assign gameID
00093     if (vCounter.lVal == 0)
00094       vCounter.lVal = 1;
00095
00096     lGameID = vCounter.lVal;
00097
00098     // Update the counter
00099     vCounter.lVal ++;
00100     THROW_ERR ( spmPropCounter->put_Value (vCounter) );
00101
00102     // Set the state variable
00103     TCHAR szBuf [512];
00104     BSTR bstrState;
00105
00106     wsprintf (szBuf, _T("%dState"), lGameID);
00107     bstrState = TCHAR2BSTR (szBuf);
00108     THROW_ERR ( spmGroup->CreateProperty (bstrState, &bExists, &spmPropState) );
00109
00110     CComVariant vState;
00111     vState.vt = VT_I4;
00112     vState.lVal = 4;
00113     THROW_ERR ( spmPropState->put_Value (vState) );
00114
00115     // Initialize the array
00116     InitArray();
00117     THROW_ERR ( SaveArray(lGameID) );
00118
00119     // Assign order randomly
00120     srand ((unsigned) time (NULL));
00121     lOrder = rand() % 2 + 1;
00122
00123     // Get computer's first move if player's order is 2
00124     if (lOrder == 2) {
00125       GetMove (lGameID, bEasy, lNewX, lNewY);
00126       plField [lNewX][lNewY] = 2;
00127       SaveArray(lGameID);
00128     }
00129
00130     // Prepare return values
00131     pvX->lVal = lNewX;
00132     pvY->lVal = lNewY;
00133     pvOrder->lVal = lOrder;
00134     pvGameID->lVal = lGameID;
00135
00136     // We're finished and happy
00137     pObjectContext->SetComplete();
00138
00139   } catch (HRESULT hr) {
00140
00141     // Create an ErrorInfo object
00142     ICreateErrorInfo* pCreateErrInfo = NULL;
00143     IErrorInfo* pErrInfo = NULL;
00144
00145     CreateErrorInfo (&pCreateErrInfo);
00146     pCreateErrInfo->QueryInterface (IID_IErrorInfo, (LPVOID FAR*) &pErrInfo);
00147
00148     // Fill in error information
00149     TCHAR szErr [512];
00150     wsprintf (szErr, _T("Error %d occurred in Computer::AddNewGame()"), hr);
00151     BSTR bstrDesc = TCHAR2BSTR (szErr);
00152     pCreateErrInfo->SetGUID (IID_IComputer);
00153     pCreateErrInfo->SetSource (L"Computer");
00154     pCreateErrInfo->SetDescription (bstrDesc);
00155     ::SysFreeString (bstrDesc);
00156
00157     // Confirm error information
00158     SetErrorInfo (0, pErrInfo);
00159
00160     // Clean up the error objects
00161     if (pCreateErrInfo)
00162       pCreateErrInfo->Release();
00163
00164     if (pErrInfo)
00165       pErrInfo->Release();
00166
00167     // Indicate our unhappiness
00168     if (pObjectContext)
00169       pObjectContext->SetAbort();
00170
00171     hr = E_FAIL;
00172   }
00173
00174   if (pObjectContext)
00175     pObjectContext->Release();
00176
00177   if (spmMgr)
00178     spmMgr->Release();
00179
00180   if (spmGroup)
00181     spmGroup->Release();
00182
00183   if (spmPropCounter)
00184     spmPropCounter->Release();
00185
00186   if (spmPropState)
00187     spmPropState->Release();
00188
00189   return hr;
00190 }
00191
00192
00193 STDMETHODIMP CComputer::NewMove (IN long lGameID, IN VARIANT_BOOL bEasy, IN long lX, IN long lY,
00194                  OUT VARIANT* pvMyX, OUT VARIANT* pvMyY, OUT VARIANT* pvWin) {
00195   // Win protocol
00196   // ============
00197   // 0  -> moves did not end game
00198   // 1  -> player won
00199   // -1 -> computer won
00200   // 2  -> player's move tied the game
00201   // -2 -> computer's move tied the game
00202
00203   HRESULT hr = S_OK;
00204
00205   pvMyX->vt = VT_I4;
00206   pvMyY->vt = VT_I4;
00207   pvWin->vt = VT_I4;
00208
00209   long lTurns = 0;
00210   long lWin = 0;
00211   long lNewX = 0;
00212   long lNewY = 0;
00213
00214   IObjectContext* pObjectContext = NULL;
00215
00216
00217   try {
00218
00219     // Get the object context
00220     THROW_ERR ( hr = GetObjectContext(&pObjectContext) );
00221     if (pObjectContext == NULL) {
00222       THROW_ERR ( E_FAIL );
00223     }
00224
00225     THROW_ERR ( LoadArray(lGameID) );
00226
00227     // Enter new move
00228     plField [lX][lY] = 1;
00229
00230     // Check for player's win
00231     if (IsWin (1)) {
00232
00233       // Player won
00234       lWin = 1;
00235
00236     } else {
00237
00238       // Check for fullness
00239       lTurns = HowManyTurns();
00240
00241       if (lTurns == 9) {
00242
00243         // Tie
00244         lWin = - 2;
00245
00246       } else {
00247
00248         // Get computer's move
00249         GetMove (lGameID, bEasy, lNewX, lNewY);
00250         plField[lNewX][lNewY] = 2;
00251
00252         // Check for computer win
00253         if (IsWin(2))
00254
00255           lWin = - 1;
00256
00257         else
00258
00259           // Check for fullness
00260           if (lTurns == 8)
00261             lWin = 2;
00262       }
00263     }
00264
00265     // Save array
00266     THROW_ERR ( SaveArray(lGameID) );
00267
00268     // Set return values
00269     pvMyX->lVal = lNewX;
00270     pvMyY->lVal = lNewY;
00271     pvWin->lVal = lWin;
00272
00273     // We're finished and happy
00274     pObjectContext->SetComplete();
00275
00276   } catch (HRESULT hr) {
00277
00278     // Create an ErrorInfo object
00279     ICreateErrorInfo* pCreateErrInfo = NULL;
00280     IErrorInfo* pErrInfo = NULL;
00281
00282     CreateErrorInfo (&pCreateErrInfo);
00283     pCreateErrInfo->QueryInterface (IID_IErrorInfo, (LPVOID FAR*) &pErrInfo);
00284
00285     // Fill in error information
00286     TCHAR szErr[512];
00287     wsprintf (szErr, _T("Error %d occurred in Computer::NewMove()"), hr);
00288     BSTR bstrDesc = TCHAR2BSTR (szErr);
00289     pCreateErrInfo->SetGUID (IID_IComputer);
00290     pCreateErrInfo->SetSource (L"Computer");
00291     pCreateErrInfo->SetDescription (bstrDesc);
00292     ::SysFreeString (bstrDesc);
00293
00294     // Confirm error information
00295     SetErrorInfo (0, pErrInfo);
00296
00297     // Clean up the error objects
00298     if (pCreateErrInfo)
00299       pCreateErrInfo->Release();
00300
00301     if (pErrInfo)
00302       pErrInfo->Release();
00303
00304     // Indicate our unhappiness
00305     if (pObjectContext)
00306       pObjectContext->SetAbort();
00307
00308     hr = E_FAIL;
00309   }
00310
00311   if (pObjectContext)
00312     pObjectContext->Release();
00313
00314   return hr;
00315 }
00316
00317
00318 void CComputer::GetMove (long lGameID, VARIANT_BOOL bEasy, long& lX, long& lY) {
00319
00320   long lFlag = 0;
00321   long lNewX = 0;
00322   long lNewY = 0;
00323
00324   // Perhaps there's only possible move
00325   if (HowManyTurns() == 8) {
00326
00327     // Scan for open tile
00328     long i,j;
00329     for (i = 0; i < 3; i ++) {
00330       for (j = 0; j < 3; j ++) {
00331         if (plField[i][j] == 0) {
00332           lNewX = i;
00333           lNewY = j;
00334           lFlag = 1;
00335         }
00336       }
00337     }
00338   }
00339
00340   // Check for win
00341   if (lFlag == 0)
00342     lFlag = LineScan (2, lNewX, lNewY);
00343
00344   // Check for block
00345   if (lFlag == 0)
00346     lFlag = LineScan (1, lNewX, lNewY);
00347
00348   // Else create a new move
00349   if (lFlag == 0) {
00350
00351     // Prepare random seed
00352     srand ((unsigned) time (NULL));
00353
00354     // Decide intelligence level
00355     if (!bEasy) {
00356
00357       // Place in center if it's open
00358       if (plField[1][1] == 0) {
00359         lNewX = 1;
00360         lNewY = 1;
00361         lFlag = 1;
00362
00363       } else {
00364
00365         // Place on corner, if opponent placed first move in center
00366         long lTurns = HowManyTurns();
00367         if (lTurns == 1 && plField[1][1] > 0) {
00368           lNewX = (rand() % 2 == 0) ? 0:2;
00369           lNewY = (rand() % 2 == 0) ? 0:2;
00370           lFlag = 1;
00371         } else {
00372
00373           // Place on opposite tile, if opponent's second
00374           // move was placed on diagonal
00375           if (lTurns == 2) {
00376             if (plField[0][0] == 1) {
00377               lNewX = 2;
00378               lNewY = 2;
00379               lFlag = 1;
00380             }
00381
00382             if (plField[0][2] == 1) {
00383               lNewX = 2;
00384               lNewY = 0;
00385               lFlag = 1;
00386             }
00387
00388             if (plField[2][0] == 1) {
00389               lNewX = 0;
00390               lNewY = 2;
00391               lFlag = 1;
00392             }
00393
00394             if (plField[2][2] == 1) {
00395               lNewX = 0;
00396               lNewY = 0;
00397               lFlag = 1;
00398             }
00399           }
00400         }
00401       }
00402
00403       // Else find most intelligent move
00404       if (lFlag == 0) {
00405
00406         float value = 0;
00407         float maxValue = 0;
00408
00409         for (long i = 0; i < 3; i ++) {
00410           for (long j = 0; j < 3; j ++) {
00411
00412             // Evaluate tile
00413             value = Evaluate (i, j);
00414
00415             // Randomize equal choices
00416             if (value == maxValue && rand() % 2 == 0) {
00417
00418               lNewX = i;
00419               lNewY = j;
00420
00421             } else {
00422
00423               if (value > maxValue) {
00424                 maxValue = value;
00425                 lNewX = i;
00426                 lNewY = j;
00427               }
00428             }
00429           }
00430         }
00431       }
00432
00433     } else {
00434
00435       // Choose a random slot
00436       while (lFlag == 0) {
00437
00438         lNewX = rand() % 3;
00439         lNewY = rand() % 3;
00440
00441         if (plField [lNewX][lNewY] == 0)
00442           lFlag = 1;
00443       }
00444     }
00445   }
00446
00447   // Prepare return values
00448   lX = lNewX;
00449   lY = lNewY;
00450 }
00451
00452 float CComputer::Evaluate (long lX, long lY) {
00453
00454   long lNewX, lNewY, lNewX2, lNewY2;
00455   float fEval1, fEval2, fEval3;
00456
00457   if (plField[lX][lY] != 0) {
00458
00459     lX = - 100;
00460     lY = - 100;
00461     return - 100;
00462   } else {
00463
00464     // Evaluate defensive options
00465     plField[lX][lY] = 1;
00466     fEval2 = (float) (LineScan (1, lNewX, lNewY) / 3);
00467
00468     // Evaluate offensive options
00469     plField[lX][lY] = 2;
00470     fEval1 = (float) LineScan (2, lNewX, lNewY);
00471
00472     // Evaluate opponent's follow-up
00473     if (fEval1 > 0) {
00474       plField[lNewX][lNewY] = 1;
00475       fEval3 = (float) (LineScan (1, lNewX2, lNewY2) * 0.9);
00476       plField[lNewX][lNewY] = 0;
00477     } else
00478       fEval3 = 0;
00479
00480     // Restore tiles and return final evaluation
00481     plField[lX][lY] = 0;
00482     return fEval1 + fEval2 - fEval3;
00483   }
00484 }
00485
00486
00487 bool CComputer::IsWin (long lPlayer) {
00488
00489   bool bWin = false;
00490
00491   for (int i = 0; i < 3; i ++) {
00492     if (plField [i][0] == plField [i][1] && plField [i][1] == plField [i][2] && plField [i][0] == lPlayer)
00493       bWin = true;
00494     if (plField [0][i] == plField [1][i] && plField [1][i] == plField [2][i] && plField [0][i] == lPlayer)
00495       bWin = true;
00496   }
00497
00498   if (plField [0][0] == plField [1][1] && plField [1][1] == plField [2][2] && plField [1][1] == lPlayer)
00499     bWin = true;
00500   if (plField [2][0] == plField [1][1] && plField [1][1] == plField [0][2] && plField [1][1] == lPlayer)
00501     bWin = true;
00502
00503   return bWin;
00504 }
00505
00506
00507 long CComputer::HowManyTurns () {
00508
00509   long lTurns = 0;
00510
00511   for (int i = 0; i < 3; i ++) {
00512     for (int j = 0; j < 3; j ++) {
00513       if (plField[i][j] > 0) {
00514         lTurns ++;
00515       }
00516     }
00517   }
00518
00519   return lTurns;
00520 }
00521
00522
00523 long CComputer::LineScan (long lPlayer, long& lX, long& lY) {
00524
00525   long lCounter = 0;
00526   lX = - 100;
00527   lY = - 100;
00528
00529   // Horizontal lines
00530   for (int i = 0; i < 3; i ++) {
00531
00532     if (plField [1][i] == lPlayer && plField [0][i] == lPlayer && plField[2][i] == 0) {
00533       lX = 2;
00534       lY = i;
00535       lCounter ++;
00536     }
00537
00538     if (plField [0][i] == lPlayer && plField [2][i] == lPlayer && plField[1][i] == 0) {
00539       lX = 1;
00540       lY = i;
00541       lCounter ++;
00542     }
00543
00544     if (plField [1][i] == lPlayer && plField [2][i] == lPlayer && plField[0][i] == 0) {
00545       lX = 0;
00546       lY = i;
00547       lCounter ++;
00548     }
00549   }
00550
00551   // Vertical lines
00552   for (i = 0; i < 3; i ++) {
00553
00554     if (plField [i][1] == lPlayer && plField [i][0] == lPlayer && plField[i][2] == 0) {
00555       lX = i;
00556       lY = 2;
00557       lCounter ++;
00558     }
00559
00560     if (plField [i][0] == lPlayer && plField [i][2] == lPlayer && plField[i][1] == 0) {
00561       lX = i;
00562       lY = 1;
00563       lCounter ++;
00564     }
00565
00566     if (plField [i][1] == lPlayer && plField [i][2] == lPlayer && plField[i][0] == 0) {
00567       lX = i;
00568       lY = 0;
00569       lCounter ++;
00570     }
00571   }
00572
00573   // Diagonals
00574   if (plField [1][1] == lPlayer && plField [0][0] == lPlayer && plField[2][2] == 0) {
00575     lX = 2;
00576     lY = 2;
00577     lCounter ++;
00578   }
00579
00580   if (plField [1][1] == lPlayer && plField [2][0] == lPlayer && plField[0][2] == 0) {
00581     lX = 0;
00582     lY = 2;
00583     lCounter ++;
00584   }
00585
00586   if (plField [1][1] == lPlayer && plField [0][2] == lPlayer && plField[2][0] == 0) {
00587     lX = 2;
00588     lY = 0;
00589     lCounter ++;
00590   }
00591
00592   if (plField [1][1] == lPlayer && plField [2][2] == lPlayer && plField[0][0] == 0) {
00593     lX = 0;
00594     lY = 0;
00595     lCounter ++;
00596   }
00597
00598   if (plField [0][0] == lPlayer && plField [2][2] == lPlayer && plField[1][1] == 0) {
00599     lX = 1;
00600     lY = 1;
00601     lCounter ++;
00602   }
00603   if (plField [0][2] == lPlayer && plField [2][0] == lPlayer && plField[1][1] == 0) {
00604     lX = 1;
00605     lY = 1;
00606     lCounter ++;
00607   }
00608
00609   return lCounter;
00610 }
00611
00612
00613 HRESULT CComputer::LoadArray (long lGameID) {
00614
00615   HRESULT hr = S_OK;
00616
00617   IObjectContext* pObjectContext = NULL;
00618
00619   ISharedPropertyGroupManager* spmMgr = NULL;
00620   ISharedPropertyGroup* spmGroup = NULL;
00621   ISharedProperty* spmPropField[3][3];
00622
00623   // Get context
00624   hr = GetObjectContext(&pObjectContext);
00625
00626   // Create the SharedPropertyGroupManager
00627   hr = pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager, IID_ISharedPropertyGroupManager, (void**)&spmMgr);
00628
00629   // Create the SharedPropertyGroup
00630   LONG lIsolationMode = LockMethod;
00631   LONG lReleaseMode = Process;
00632   VARIANT_BOOL bExists = VARIANT_FALSE;
00633   hr = spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode, &bExists, &spmGroup);
00634
00635   // Load the field SharedProperties
00636   TCHAR szBuf [512];
00637   BSTR bstrField;
00638   CComVariant vField;
00639
00640   for (long i = 0; i < 3; i ++ ) {
00641     for (long j = 0; j < 3; j ++) {
00642
00643       wsprintf (szBuf, _T("%dField%d%d"), lGameID, i, j);
00644       bstrField = TCHAR2BSTR (szBuf);
00645       hr = spmGroup->CreateProperty (bstrField, &bExists, &spmPropField[i][j]);
00646       ::SysFreeString (bstrField);
00647
00648       hr = spmPropField[i][j]->get_Value (&vField);
00649       plField[i][j] = vField.lVal;
00650     }
00651   }
00652
00653   if (pObjectContext)
00654     pObjectContext->Release();
00655
00656   if (spmMgr)
00657     spmMgr->Release();
00658
00659   if (spmGroup)
00660     spmGroup->Release();
00661
00662   for (i = 0; i < 3; i ++) {
00663     for (long j = 0; j < 3; j ++) {
00664       if (spmPropField[i][j]) {
00665         spmPropField[i][j]->Release();
00666       }
00667     }
00668   }
00669
00670   return hr;
00671 }
00672
00673
00674 HRESULT CComputer::SaveArray (long lGameID) {
00675
00676   HRESULT hr = S_OK;
00677
00678   IObjectContext* pObjectContext = NULL;
00679
00680   ISharedPropertyGroupManager* spmMgr = NULL;
00681   ISharedPropertyGroup* spmGroup = NULL;
00682   ISharedProperty* spmPropField[3][3];
00683
00684   // Get context
00685   hr = GetObjectContext(&pObjectContext);
00686
00687   // Create the SharedPropertyGroupManager
00688   hr = pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager, IID_ISharedPropertyGroupManager, (void**)&spmMgr);
00689
00690   // Create the SharedPropertyGroup
00691   LONG lIsolationMode = LockMethod;
00692   LONG lReleaseMode = Process;
00693   VARIANT_BOOL bExists = VARIANT_FALSE;
00694   hr = spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode, &bExists, &spmGroup);
00695
00696   // Save the field SharedProperties
00697   TCHAR szBuf [512];
00698   BSTR bstrField;
00699   CComVariant vField;
00700   vField.vt = VT_I4;
00701
00702   for (long i = 0; i < 3; i ++ ) {
00703     for (long j = 0; j < 3; j ++) {
00704
00705       wsprintf (szBuf, _T("%dField%d%d"), lGameID, i, j);
00706       bstrField = TCHAR2BSTR (szBuf);
00707       hr = spmGroup->CreateProperty (bstrField, &bExists, &spmPropField[i][j]);
00708       ::SysFreeString (bstrField);
00709
00710       vField.lVal = plField[i][j];
00711       hr = spmPropField[i][j]->put_Value (vField);
00712     }
00713   }
00714
00715   if (pObjectContext)
00716     pObjectContext->Release();
00717
00718   if (spmMgr)
00719     spmMgr->Release();
00720
00721   if (spmGroup)
00722     spmGroup->Release();
00723
00724   for (i = 0; i < 3; i ++) {
00725     for (long j = 0; j < 3; j ++) {
00726       if (spmPropField[i][j]) {
00727         spmPropField[i][j]->Release();
00728       }
00729     }
00730   }
00731
00732   return hr;
00733 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ENUMINFO Member List

This is the complete list of members for ENUMINFO, including all inherited members.
eType | ENUMINFO
fIsParent | ENUMINFO
wszDescription | ENUMINFO
wszName | ENUMINFO
wszParseName | ENUMINFO
Generated on Wed Nov 13 2024 16:57:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkDivider/C#/AssemblyInfo.cs Source File

  • TabletPC
  • InkDivider
  • C#

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("Ink Divider Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2003 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 //[assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 // [assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/CertXSam.Idl Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

CertXSam.Idl

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        certxsam.idl
00007 //
00008 // Contents:    IDL source for certsam
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 import "wtypes.idl";
00013 import "certexit.idl";
00014 import "certmod.idl";
00015
00016
00017 //+--------------------------------------------------------------------------
00018 // certexit Type library
00019 //+--------------------------------------------------------------------------
00020
00021 [
00022     uuid(d29571d0-c2c8-11d2-b313-00c04f79dc72),
00023     version(1.0),
00024     helpstring("CertExitSample 1.0 Type Library")
00025 ]
00026
00027 library CERTEXITSAMPLELib
00028 {
00029     importlib("stdole2.tlb");
00030
00031     [
00032   uuid(d2075560-c2c8-11d2-b313-00c04f79dc72),
00033   helpstring("CertExitSample Class")
00034     ]
00035     coclass CCertExitSample
00036     {
00037   [default] interface ICertExit;
00038     };
00039
00040     [
00041   uuid(d3099410-c2c8-11d2-b313-00c04f79dc72),
00042   helpstring("CertManageExitModuleSample Class")
00043     ]
00044     coclass CCertManageExitModuleSample
00045     {
00046   [default] interface ICertManageModule;
00047     };
00048 };
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/simplearray.h Source File

  • SysMgmt
  • MMC
  • WMI

simplearray.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #if (_ATL_VER < 0x0300)
00020 /////////////////////////////////////////////////////////////////////////////
00021 // Collection helpers - CSimpleArray & CSimpleMap
00022
00023 template <class T>
00024 class CSimpleArray
00025 {
00026 public:
00027   T* m_aT;
00028   int m_nSize;
00029   int m_nAllocSize;
00030
00031 // Construction/destruction
00032   CSimpleArray() : m_aT(NULL), m_nSize(0), m_nAllocSize(0)
00033   { }
00034
00035   ~CSimpleArray()
00036   {
00037     RemoveAll();
00038   }
00039
00040 // Operations
00041   int GetSize() const
00042   {
00043     return m_nSize;
00044   }
00045   BOOL Add(T& t)
00046   {
00047     if(m_nSize == m_nAllocSize)
00048     {
00049       T* aT;
00050       int nNewAllocSize = (m_nAllocSize == 0) ? 1 : (m_nSize * 2);
00051       aT = (T*)realloc(m_aT, nNewAllocSize * sizeof(T));
00052       if(aT == NULL)
00053         return FALSE;
00054       m_nAllocSize = nNewAllocSize;
00055       m_aT = aT;
00056     }
00057     m_nSize++;
00058     SetAtIndex(m_nSize - 1, t);
00059     return TRUE;
00060   }
00061   BOOL Remove(T& t)
00062   {
00063     int nIndex = Find(t);
00064     if(nIndex == -1)
00065       return FALSE;
00066     return RemoveAt(nIndex);
00067   }
00068   BOOL RemoveAt(int nIndex)
00069   {
00070     if(nIndex != (m_nSize - 1))
00071       memmove((void*)&m_aT[nIndex], (void*)&m_aT[nIndex + 1], (m_nSize - (nIndex + 1)) * sizeof(T));
00072     m_nSize--;
00073     return TRUE;
00074   }
00075   void RemoveAll()
00076   {
00077     if(m_aT != NULL)
00078     {
00079       free(m_aT);
00080       m_aT = NULL;
00081     }
00082     m_nSize = 0;
00083     m_nAllocSize = 0;
00084   }
00085   T& operator[] (int nIndex) const
00086   {
00087     _ASSERT(nIndex >= 0 && nIndex < m_nSize);
00088     return m_aT[nIndex];
00089   }
00090   T* GetData() const
00091   {
00092     return m_aT;
00093   }
00094
00095 // Implementation
00096   void SetAtIndex(int nIndex, T& t)
00097   {
00098     _ASSERT(nIndex >= 0 && nIndex < m_nSize);
00099     m_aT[nIndex] = t;
00100   }
00101   int Find(T& t) const
00102   {
00103     for(int i = 0; i < m_nSize; i++)
00104     {
00105       if(m_aT[i] == t)
00106         return i;
00107     }
00108     return -1;  // not found
00109   }
00110 };
00111 #endif
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagHANDLERITEM_SYNCSTATUS Member List

This is the complete list of members for _tagHANDLERITEM_SYNCSTATUS, including all inherited members.
dwSyncMgrResultStatus | _tagHANDLERITEM_SYNCSTATUS
fCancelled | _tagHANDLERITEM_SYNCSTATUS
fSynchronizeComplete | _tagHANDLERITEM_SYNCSTATUS
fSynchronizing | _tagHANDLERITEM_SYNCSTATUS
fUnresolvedConflicts | _tagHANDLERITEM_SYNCSTATUS
genericItem | _tagHANDLERITEM_SYNCSTATUS
ItemID | _tagHANDLERITEM_SYNCSTATUS
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/basedialog.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

basedialog.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  BaseDialog.cpp: implementation of the CBaseDialog class.
00014 //
00015
00016 #include "BaseDialog.h"
00017 #include "Globals.h"
00018
00019
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // Construction/Destruction
00023
00024 //---------------------------------------------------------------------------
00025 CBaseDialog::CBaseDialog( ULONG nTemplate )
00026 {
00027   _ASSERT( NULL != nTemplate );
00028
00029   m_nTemplate = nTemplate;
00030   m_hWnd      = NULL;          // Handle returned by CreateDialogParam
00031   m_DlgProc   = DlgProc;       // Point to default dialog proc
00032   m_dwFlags   = 0;
00033 }
00034
00035 //---------------------------------------------------------------------------
00036 CBaseDialog::~CBaseDialog()
00037 {
00038 }
00039
00040 //---------------------------------------------------------------------------
00041 //  Use CreateDialogParam rather than CreateDialog so that we can later
00042 //  retrieve the 'this' pointer which we will need to point back to the
00043 //  particular instance of this class.
00044 //
00045 HWND CBaseDialog::Create
00046 (
00047   HINSTANCE  hInstance,      //[in] Global instance handle
00048   HWND       hWndParent,     //[in] Handle to parent window
00049   DWORD      dwFlags         //[in] Create flags - not used
00050 )
00051 {
00052   _ASSERT( NULL != hInstance );
00053
00054   m_dwFlags = dwFlags;
00055   m_hWnd = CreateDialogParam( hInstance,
00056                               MAKEINTRESOURCE(m_nTemplate),
00057                               hWndParent,
00058                               m_DlgProc,
00059                               (LPARAM)this
00060                             );
00061
00062   BOOL bReturn = ShowWindow( m_hWnd, SW_SHOW );  // Should return 0
00063
00064   return m_hWnd;
00065 }
00066
00067
00068 /////////////////////////////////////////////////////////////////////////////
00069 //  Message Handlers
00070
00071 //---------------------------------------------------------------------------
00072 LRESULT CBaseDialog::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00073 {
00074   return 1;
00075 }
00076
00077 //---------------------------------------------------------------------------
00078 //  This is the first message sent by the DetroyWindow() function.
00079 //  It is sent after the window is removed from the screen, but it should
00080 //  be assumed that any child windows still exist.
00081 //
00082 LRESULT CBaseDialog::OnDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam )
00083 {
00084   return 1;
00085 }
00086
00087 //---------------------------------------------------------------------------
00088 //  This is sent after WM_DESTROY, and informs the app that the non-client
00089 //  area is being destroyed.  This is where allocated resources should be
00090 //  cleaned up.
00091 //
00092 LRESULT CBaseDialog::OnNcDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam )
00093 {
00094   m_hWnd = NULL;             // Since this is a modeless-only dialog
00095   delete this;               // class we delete ourselves here
00096
00097   return 1;
00098 }
00099
00100 //---------------------------------------------------------------------------
00101 LRESULT CBaseDialog::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00102 {
00103   return DestroyWindow( m_hWnd);
00104 }
00105
00106 //---------------------------------------------------------------------------
00107 LRESULT CBaseDialog::OnCancel( HWND hDlg, WPARAM wParam, LPARAM lParam )
00108 {
00109   return DestroyWindow( m_hWnd);
00110 }
00111
00112 //---------------------------------------------------------------------------
00113 LRESULT CBaseDialog::OnClose( HWND hDlg, WPARAM wParam, LPARAM lParam )
00114 {
00115   return DestroyWindow( m_hWnd);
00116 }
00117
00118
00119 /////////////////////////////////////////////////////////////////////////////
00120 //  Dialog Procedures
00121
00122 //---------------------------------------------------------------------------
00123 //  Since this is a static function we can't use a 'this' pointer or call
00124 //  the base class directly.  There may be multiple base classes using
00125 //  this method.  We get around this by storing the 'this' pointer in the
00126 //  lParam of CreateDialogParam.  When we get WM_INITDIALOG we get this
00127 //  pointer back in the lParam.  Now we can use SetWindowLongPtr to store
00128 //  it, and later retireve it with GetWindowLongPtr.  Once we have a
00129 //  valid 'this' pointer we can cast it back to the base class and then
00130 //  call the base class's ProcessMessage function.
00131 //
00132 BOOL CALLBACK CBaseDialog::DlgProc
00133 (
00134   HWND     hDlg,           //[in] Handle to dialog box
00135   UINT     uMsg,           //[in] Message
00136   WPARAM   wParam,         //[in] First message parameter
00137   LPARAM   lParam          //[in] Second message parameter
00138 )
00139 {
00140   BOOL bReturn = FALSE;
00141   if( WM_INITDIALOG == uMsg )
00142   {
00143     SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
00144   }
00145
00146   CBaseDialog* pThis = reinterpret_cast<CBaseDialog*>(GetWindowLongPtr(hDlg, GWL_USERDATA));
00147   if( NULL != pThis )
00148   {
00149     bReturn = pThis->ProcessMessage( hDlg, uMsg, wParam, lParam );
00150   }
00151
00152   return bReturn;
00153 }
00154
00155 //---------------------------------------------------------------------------
00156 //  This is the instance specific method used to process messages.  The
00157 //  DialogProc delegates this responsibiliy to each instance of the class.
00158 //  This is a pure virtual function.  The code below is provided to cut
00159 //  and paste into the derived class's implementation.
00160 /*
00161 BOOL CBaseDialog::ProcessMessage
00162 (
00163   HWND     hDlg,           //[in] Handle to dialog box
00164   UINT     uMsg,           //[in] Message
00165   WPARAM   wParam,         //[in] First message parameter
00166   LPARAM   lParam          //[in] Second message parameter
00167 )
00168 {
00169   LRESULT lResult = 0;
00170   switch( uMsg )
00171   {
00172     case WM_INITDIALOG:
00173       lResult = OnInitDialog( hDlg, wParam, lParam );
00174       break;
00175
00176     case WM_DESTROY:
00177       lResult = OnDestroy( hDlg, wParam, lParam );
00178       break;
00179
00180     case WM_NCDESTROY:
00181       lResult = OnNcDestroy( hDlg, wParam, lParam );
00182       break;
00183
00184     case WM_CLOSE:
00185       lResult = OnClose( hDlg, wParam, lParam );
00186
00187     case WM_COMMAND:
00188       switch( wParam )
00189       {
00190         case IDOK:
00191           lResult = OnOK( hDlg, wParam, lParam );
00192           break;
00193
00194         case IDCANCEL:
00195           lResult = OnCancel( hDlg, wParam, lParam );
00196           break;
00197
00198         default:
00199           break;
00200       }
00201     default:
00202       break;
00203   }
00204   return (BOOL)lResult;
00205 }
00206 */
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/Msg.Cpp Source File

  • Web
  • NetMeeting
  • NMUI

Msg.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       MSG.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 // from cmd.cpp
00018 VOID CmdExit(void);
00019 LRESULT MsgCmdMain(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam);
00020
00021 // from tbar.cpp
00022 LRESULT MsgNotifyTbar(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam);
00023 LRESULT MsgMenuSelect(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam);
00024
00025
00026 //****************************************************************************
00027 //
00028 // Handle a WM_DESTROY message
00029 //
00030 //****************************************************************************
00031
00032 LRESULT MsgDestroy(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lParam)
00033 {
00034   FreeAllComObjects();
00035   PostQuitMessage(0);
00036   return 0;
00037 }
00038
00039
00040 //****************************************************************************
00041 //
00042 // LRESULT MsgCreate(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lParam)
00043 //
00044 //****************************************************************************
00045
00046 LRESULT MsgCreate(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lParam)
00047 {
00048   return 0;
00049 }
00050
00051
00052 //****************************************************************************
00053 //
00054 // Handle a WM_CLOSE message
00055 //
00056 //****************************************************************************
00057
00058 LRESULT MsgClose(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
00059 {
00060   FreeAllComObjects();
00061   CmdExit();
00062   return 0;
00063 }
00064
00065
00066 //****************************************************************************
00067 //
00068 // Handle a WM_SIZE message
00069 //
00070 //****************************************************************************
00071
00072 LRESULT MsgSize(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
00073 {
00074   int dxClient = LOWORD(lparam);  // width of client area
00075   int dyClient = HIWORD(lparam);  // height of client area
00076
00077   SizeMsgWindow(dxClient, dyClient);
00078   SizeStatus(dxClient, 0);
00079   SendMessage(ghwndSbar, uMsg, wparam, lparam);
00080
00081   return 0;
00082 }
00083
00084
00085 //****************************************************************************
00086 //
00087 // Handle a WM_GETMINMAXINFO message
00088 //
00089 //****************************************************************************
00090
00091 LRESULT MsgGetMinMax(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
00092 {
00093   LPMINMAXINFO lpminmax = (LPMINMAXINFO) lparam;
00094
00095   if (gdxWndMin == 0 || gdyWndMin == 0)
00096     return 0;
00097
00098   if  (NULL == lpminmax)
00099   {
00100     ERROR_MSG(TEXT("MsgGetMinMax: NULL == lpminmax"));
00101     return 0;
00102   }
00103
00104   lpminmax->ptMinTrackSize.x = gdxWndMin;
00105   lpminmax->ptMinTrackSize.y = gdyWndMin;
00106
00107   return 0;
00108 }
00109
00110 //****************************************************************************
00111 //
00112 // LRESULT MsgDrawItem(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00113 //
00114 //****************************************************************************
00115
00116 LRESULT MsgDrawItem(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00117 {
00118   switch (wParam)
00119   {
00120   case IDW_MSG:
00121   {
00122     LPDRAWITEMSTRUCT  lpdi  = (LPDRAWITEMSTRUCT)lParam;
00123     TCHAR *       tsz   = 0;
00124
00125     if  (NULL == lpdi)
00126     {
00127       ERROR_MSG(TEXT("MsgDrawItem: NULL == lpdi"));
00128       break;
00129     }
00130
00131     COLORREF cv = SendMessage(ghwndMsg, LB_GETITEMDATA, (WPARAM)lpdi->itemID, (LPARAM)0);
00132     SetTextColor(lpdi->hDC, cv);
00133
00134     int nLen = SendMessage(ghwndMsg, LB_GETTEXTLEN, (WPARAM) lpdi->itemID, 0);
00135
00136     if  ( (0 < nLen)
00137       &&  (NULL != (tsz = new TCHAR[nLen + 1]))
00138       )
00139     {
00140       ZeroMemory(tsz, nLen + 1);
00141
00142       SendMessage(ghwndMsg, LB_GETTEXT, (WPARAM)lpdi->itemID, (LPARAM) tsz);
00143       DrawText(lpdi->hDC, tsz, -1, &lpdi->rcItem, DT_LEFT | DT_SINGLELINE);
00144
00145       delete [] tsz;
00146       tsz = 0;
00147     }
00148     break;
00149   }
00150   case IDW_SBAR:
00151   {
00152     if  (NULL == lParam)
00153     {
00154       ERROR_MSG(TEXT("MsgDrawItem: NULL == lParam"));
00155       break;
00156     }
00157
00158     if (0 != (((LPDRAWITEMSTRUCT) lParam)->itemData))
00159     {
00160       DrawIconEx( ((LPDRAWITEMSTRUCT) lParam)->hDC,
00161         ((LPDRAWITEMSTRUCT) lParam)->rcItem.left,
00162         ((LPDRAWITEMSTRUCT) lParam)->rcItem.top,
00163         (HICON) (((LPDRAWITEMSTRUCT) lParam)->itemData),
00164         STATUSICONSIZE, STATUSICONSIZE, 0, NULL, DI_NORMAL);
00165     }
00166     break;
00167   }
00168
00169   case IDL_USERS:
00170   {
00171     DrawUserItem((LPDRAWITEMSTRUCT) lParam);
00172     break;
00173   }
00174
00175   default:
00176     break;
00177   } /* switch */
00178
00179   return 0;
00180 }
00181
00182
00183 //****************************************************************************
00184 //
00185 // LRESULT MsgNotify(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00186 //
00187 //****************************************************************************
00188
00189 LRESULT MsgNotify(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00190 {
00191   if  (NULL == lParam)
00192   {
00193     ERROR_MSG(TEXT("MsgNotify: NULL == MsgNotify"));
00194     return 0;
00195   }
00196
00197     switch (((LPNMHDR) lParam)->idFrom)
00198         {
00199     case IDW_TBAR:
00200         return MsgNotifyTbar(hwnd, uMsg, wParam, lParam);
00201     default:
00202         // It might still be for the toolbar (tooltips)
00203         return MsgNotifyTbar(hwnd, uMsg, wParam, lParam);
00204         }
00205
00206     return 0;
00207 }
00208
00209
00210 ////////////////////////////////////////////////////////////////////////////
00211 // Main window message table definition.
00212 static MSD _rgmsdMain[] =
00213 {
00214   {WM_COMMAND,       MsgCmdMain},
00215   {WM_NOTIFY,        MsgNotify},
00216   {WM_CREATE,        MsgCreate},
00217   {WM_DESTROY,       MsgDestroy},
00218   {WM_CLOSE,         MsgClose},
00219   {WM_SIZE,          MsgSize},
00220   {WM_MENUSELECT,    MsgMenuSelect},
00221   {WM_GETMINMAXINFO, MsgGetMinMax},
00222   {WM_DRAWITEM,      MsgDrawItem},
00223
00224   {0, NULL}  // MUST be the last entry
00225 };
00226
00227
00228 //****************************************************************************
00229 //
00230 // Main Window proc
00231 //
00232 //****************************************************************************
00233
00234 LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00235 {
00236   if  (NULL == _rgmsdMain)
00237   {
00238     ERROR_MSG(TEXT("WndProc: NULL == _rgmsdMain"));
00239     return 0;
00240   }
00241
00242   for (LPMSD lpmsd = _rgmsdMain; 0 != lpmsd->uMsg; lpmsd++)
00243   {
00244     if (lpmsd->uMsg == uMsg)
00245     {
00246       return lpmsd->pfnmsg(hwnd, uMsg, wParam, lParam);
00247     }
00248   }
00249
00250   return DefWindowProc(hwnd, uMsg, wParam, lParam);
00251 }
00252
00253
00254
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IAS/DialIn/DialIn.c Source File

  • NetDS
  • IAS
  • DialIn

DialIn.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007    dialin.c
00008
00009 Abstract:
00010
00011    This module implements the DLL exports for a RADIUS extension DLL.
00012
00013    The sample extension processes all Access-Requests destined for the
00014    WindowsNT authentication provider and verifies that the user has been
00015    granted the dial-in privilege.
00016
00017 --*/
00018
00019 #include <windows.h>
00020 #include <malloc.h>
00021 #include <authif.h>
00022 #include <rassapi.h>
00023 #include <lmerr.h>
00024
00025 /*
00026  *  The UNC name of the localhost.
00027  */
00028 WCHAR theLocalServer[UNCLEN + 1];
00029
00030 /*
00031  *  Finds an attribute of the desired type.
00032  */
00033 CONST RADIUS_ATTRIBUTE*
00034 WINAPI
00035 FindAttribute(
00036     IN CONST RADIUS_ATTRIBUTE *pAttrs,
00037     IN DWORD dwAttrType
00038     )
00039 {
00040    for ( ; pAttrs->dwAttrType != ratMinimum; ++pAttrs)
00041    {
00042       if (pAttrs->dwAttrType == dwAttrType) { return pAttrs; }
00043    }
00044
00045    return NULL;
00046 }
00047
00048 /*
00049  *  Initialize the extension.
00050  */
00051 DWORD
00052 WINAPI
00053 RadiusExtensionInit( VOID )
00054 {
00055    DWORD cbData;
00056
00057    /* theLocalServer must be in UNC format. */
00058    wcscpy(theLocalServer, L"\\\\");
00059
00060    /* Append the computer name. */
00061    cbData = UNCLEN - 1;
00062    if (!GetComputerNameW(theLocalServer + 2, &cbData))
00063    {
00064       return GetLastError();
00065    }
00066
00067    return NO_ERROR;
00068 }
00069
00070 /*
00071  *  Process a request.
00072  */
00073 DWORD
00074 WINAPI
00075 RadiusExtensionProcess(
00076     IN CONST RADIUS_ATTRIBUTE *pAttrs,
00077     OUT OPTIONAL PRADIUS_ACTION pfAction
00078     )
00079 {
00080    CONST RADIUS_ATTRIBUTE *p;
00081    PWSTR domain, username;
00082    int nChar;
00083    DWORD error;
00084    WCHAR buffer[UNCLEN + 1], *accountServer;
00085    RAS_USER_0 ru0;
00086
00087    /* Only process Access-Requests. */
00088    p = FindAttribute(pAttrs, ratCode);
00089    if (p == NULL || p->dwValue != 1)
00090    {
00091       return NO_ERROR;
00092    }
00093
00094    /* If it's not destined for the WindowsNT provider, we're not interested. */
00095    p = FindAttribute(pAttrs, ratProvider);
00096    if (p == NULL || p->dwValue != rapWindowsNT)
00097    {
00098       return NO_ERROR;
00099    }
00100
00101    /* Find the Stripped-User-Name attribute. */
00102    p = FindAttribute(pAttrs, ratStrippedUserName);
00103
00104    /* Make sure we found an attribute and it's the right data type. */
00105    if (p == NULL || p->fDataType != rdtString)
00106    {
00107       return ERROR_INVALID_DATA;
00108    }
00109
00110    /* Allocate a buffer for the UNICODE string. */
00111    domain = (PWSTR)_alloca((p->cbDataLength + 1) * sizeof(WCHAR));
00112
00113    /* Convert to UNICODE. */
00114    nChar = MultiByteToWideChar(
00115                CP_ACP,
00116                0,
00117                p->lpValue,
00118                p->cbDataLength,
00119                domain,
00120                p->cbDataLength + 1
00121                );
00122    if (nChar == 0)
00123    {
00124       return GetLastError();
00125    }
00126    domain[nChar] = L'\0';
00127
00128    /* Look for the delimiter in "domain\username". */
00129    username = wcschr(domain, L'\\');
00130
00131    accountServer = theLocalServer;
00132
00133    if (username)
00134    {
00135       /* We found a delimiter, so null it out and advance. */
00136       *username++ = L'\0';
00137
00138       /* Is this the local computer? */
00139       if (_wcsicmp(domain, theLocalServer + 2))
00140       {
00141          /* No, so we have to find a DC. */
00142          error = RasAdminGetUserAccountServer(
00143                      domain,
00144                      NULL,
00145                      buffer
00146                      );
00147          if (error != NO_ERROR)
00148          {
00149             return error;
00150          }
00151
00152          accountServer = buffer;
00153       }
00154    }
00155    else
00156    {
00157       /* No delimiter, so the whole thing is the username. */
00158       username = domain;
00159    }
00160
00161    /* Retrieve the dial-in info for this user. */
00162    error = RasAdminUserGetInfo(
00163                accountServer,
00164                username,
00165                &ru0
00166                );
00167
00168    /* If the user doesn't exist, it's not an error, but we always reject. */
00169    if (error == NERR_UserNotFound)
00170    {
00171       *pfAction = raReject;
00172       return NO_ERROR;
00173    }
00174
00175    /* Any other error and we bail. */
00176    if (error != NO_ERROR)
00177    {
00178       return error;
00179    }
00180
00181    /* Is the dial-in bit set? */
00182    if ((ru0.bfPrivilege & RASPRIV_DialinPrivilege) == 0)
00183    {
00184       /* No, so reject. */
00185       *pfAction = raReject;
00186    }
00187
00188    return NO_ERROR;
00189 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/AsyncRPC/AsyncRPC.Idl Source File

  • NetDS
  • RPC
  • AsyncRPC

AsyncRPC.Idl

Go to the documentation of this file.
00001 [ uuid (7f6c4340-eb67-11d1-b9d7-00c04fad9a3b),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface AsyncRPC
00006 {
00007 const long DEFAULT_ASYNC_DELAY        = 20;   // in seconds
00008 const char* DEFAULT_PROTOCOL_SEQUENCE = "ncacn_ip_tcp";
00009 const char* DEFAULT_ENDPOINT          = "8765";
00010
00011 void NonAsyncFunc(handle_t hBinding,
00012                   [in, string] unsigned char * pszMessage);
00013
00014 void AsyncFunc(handle_t hBinding,
00015                [in] unsigned long nAsychDelay);
00016
00017 void Shutdown(handle_t hBinding);
00018 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagMAPMODELOOKUP Member List

This is the complete list of members for tagMAPMODELOOKUP, including all inherited members.
iMapMode | tagMAPMODELOOKUP
wMenuItem | tagMAPMODELOOKUP
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/PoolTest.h Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest

PoolTest.h

Go to the documentation of this file.
00001 /* MIDL: this ALWAYS GENERATED file contains the definitions for the interfaces */
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellExt/ShExInit.Cpp Source File

  • WinUI
  • Shell
  • ShellExt

ShExInit.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   shexinit.cpp
00009 //
00010 //  PURPOSE:   Implements the IShellExtInit member function necessary to support
00011 //             the context menu and property sheet portioins of this shell extension.
00012 //
00013
00014 #include "priv.h"
00015 #include "shellext.h"
00016
00017
00018 //
00019 //  FUNCTION: CShellExt::Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY)
00020 //
00021 //  PURPOSE: Called by the shell when initializing a context menu or property
00022 //           sheet extension.
00023 //
00024 //  PARAMETERS:
00025 //    pIDFolder - Specifies the parent folder
00026 //    pDataObj  - Spefifies the set of items selected in that folder.
00027 //    hRegKey   - Specifies the type of the focused item in the selection.
00028 //
00029 //  RETURN VALUE:
00030 //
00031 //    NOERROR in all cases.
00032 //
00033 //  COMMENTS:   Note that at the time this function is called, we don't know
00034 //              (or care) what type of shell extension is being initialized.
00035 //              It could be a context menu or a property sheet.
00036 //
00037
00038 STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
00039                                    LPDATAOBJECT pDataObj,
00040                                    HKEY hRegKey)
00041 {
00042     ODS("CShellExt::Initialize()\r\n");
00043
00044     // Initialize can be called more than once
00045
00046     if (m_pDataObj)
00047         m_pDataObj->Release();
00048
00049     // duplicate the object pointer and registry handle
00050
00051     if (pDataObj)
00052     {
00053         m_pDataObj = pDataObj;
00054         pDataObj->AddRef();
00055     }
00056
00057     return NOERROR;
00058 }
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampclnt/resource.h Source File

  • Dataaccess
  • oledb
  • sampclnt

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft OLE DB Sample Consumer
00003 // (C) Copyright 1991 - 2000 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // Microsoft Visual C++ generated include file.
00006 // Used by SAMPCLNT.RC
00007 //
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        101
00014 #define _APS_NEXT_COMMAND_VALUE         40006
00015 #define _APS_NEXT_CONTROL_VALUE         1000
00016 #define _APS_NEXT_SYMED_VALUE           101
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_socklist Member List

This is the complete list of members for _socklist, including all inherited members.
Buffer | _socklist
DataBuf | _socklist
overlap | _socklist
sock | _socklist
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CKeystrokeEditSession Member List

This is the complete list of members for CKeystrokeEditSession, including all inherited members.
_pContext | CEditSessionBase | [protected]
_pMark | CKeystrokeEditSession | [private]
_wParam | CKeystrokeEditSession | [private]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CKeystrokeEditSession(ITfContext *pContext, WPARAM wParam) | CKeystrokeEditSession | [inline]
CKeystrokeEditSession(CMarkTextService *pMark, ITfContext *pContext, WPARAM wParam) | CKeystrokeEditSession | [inline]
DoEditSession(TfEditCookie ec) | CKeystrokeEditSession | [virtual]
DoEditSession(TfEditCookie ec) | CKeystrokeEditSession | [virtual]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
~CKeystrokeEditSession() | CKeystrokeEditSession | [inline]
Generated on Wed Nov 13 2024 16:56:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMMCControl Member List

This is the complete list of members for CMMCControl, including all inherited members.
CMMCControl() | CMMCControl | [inline]
DoHelp() | CMMCControl |
IDD enum value | CMMCControl |
InterfaceSupportsErrorInfo(REFIID riid) | CMMCControl | [inline]
m_bAnimating | CMMCControl | [private]
m_timerId | CMMCControl | [private]
OnAmbientPropertyChange(DISPID dispid) | CMMCControl | [inline]
OnClickedAnimate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CMMCControl | [inline]
StartAnimation() | CMMCControl |
StopAnimation() | CMMCControl |
~CMMCControl() | CMMCControl | [inline]
Generated on Wed Nov 13 2024 16:56:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #include <initguid.h>
00008 #ifdef _ATL_STATIC_REGISTRY
00009 #include <statreg.h>
00010 #include <statreg.cpp>
00011 #endif
00012
00013 #include <atlimpl.cpp>
00014
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/GetRowsOptionEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

GetRowsOptionEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: GetRowsOptionEnum
00019
00020 public class GetRowsOptionEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adGetRowsRest = -1;
00023 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/FaxDlg.Cpp Source File

  • NetDS
  • fax
  • PrintSdi

FaxDlg.Cpp

Go to the documentation of this file.
00001 // FaxDlg.cpp : implementation file
00002 //
00003
00004 #include "stdafx.h"
00005 #include "PrintSDI.h"
00006 #include "FaxDlg.h"
00007
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // FaxDlg dialog
00016
00017
00018 FaxDlg::FaxDlg(CWnd* pParent /*=NULL*/)
00019   : CDialog(FaxDlg::IDD, pParent)
00020 {
00021   //{{AFX_DATA_INIT(FaxDlg)
00022   m_FaxNumber = _T("");
00023   m_RecipientName = _T("");
00024   //}}AFX_DATA_INIT
00025 }
00026
00027
00028 void FaxDlg::DoDataExchange(CDataExchange* pDX)
00029 {
00030   CDialog::DoDataExchange(pDX);
00031   //{{AFX_DATA_MAP(FaxDlg)
00032   DDX_Text(pDX, IDC_EDIT1, m_FaxNumber);
00033   DDV_MaxChars(pDX, m_FaxNumber, 30);
00034   DDX_Text(pDX, IDC_EDIT2, m_RecipientName);
00035   DDV_MaxChars(pDX, m_RecipientName, 64);
00036   //}}AFX_DATA_MAP
00037 }
00038
00039
00040 BEGIN_MESSAGE_MAP(FaxDlg, CDialog)
00041   //{{AFX_MSG_MAP(FaxDlg)
00042     // NOTE: the ClassWizard will add message map macros here
00043   //}}AFX_MSG_MAP
00044 END_MESSAGE_MAP()
00045
00046 /////////////////////////////////////////////////////////////////////////////
00047 // FaxDlg message handlers
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Dog/Dogcf.Cpp Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Dog

Dogcf.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include "dogcf.h"
00020 #include "cdog.h"
00021
00022 // IUnknown
00023 STDMETHODIMP CClassFactory::QueryInterface(REFIID iid, void FAR* FAR* ppv)
00024 {
00025     *ppv = NULL;
00026
00027     if (iid == IID_IUnknown || iid == IID_IClassFactory)
00028         *ppv = this;
00029     else
00030         return ResultFromScode(E_NOINTERFACE);
00031
00032     AddRef();
00033     return NOERROR;
00034 }
00035
00036
00037 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00038 {
00039     return InterlockedIncrement(&m_cRef);
00040 }
00041
00042
00043 STDMETHODIMP_(ULONG) CClassFactory::Release()
00044 {
00045     if(InterlockedDecrement(&m_cRef) == 0)
00046     {
00047         delete this;
00048         return 0;
00049     }
00050     return m_cRef;
00051 }
00052
00053 // IClassFactory
00054 STDMETHODIMP CClassFactory::CreateInstance(IUnknown FAR* punkOuter, REFIID riid,
00055                        void FAR* FAR* ppv)
00056 {
00057     extern HINSTANCE g_hInst;
00058
00059     HRESULT hr;
00060     CDog * pDog;
00061
00062     *ppv = NULL;
00063
00064     // This implementation does not allow aggregation
00065     if (punkOuter)
00066         return ResultFromScode(CLASS_E_NOAGGREGATION);
00067
00068     // Create an instance of the Dog object.
00069     pDog = new CDog;
00070
00071     hr = pDog->QueryInterface(riid, ppv);
00072     if (FAILED(hr))
00073     {
00074         delete pDog;
00075         return hr;
00076     }
00077     return NOERROR;
00078 }
00079
00080 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00081 {
00082     extern LONG g_cLocks;
00083
00084     if (fLock)
00085         InterlockedIncrement(&g_cLocks);
00086     else
00087         InterlockedDecrement(&g_cLocks);
00088
00089     return NOERROR;
00090 }
00091
00092
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat2/resource.h Source File

  • Web
  • NetMeeting
  • NMChat2

resource.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       RESOURCE.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1999-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 //{{NO_DEPENDENCIES}}
00016 // Microsoft Developer Studio generated include file.
00017 // Used by res.rc
00018 //
00019 #define IDS_APP_TITLE                   1
00020 #define IDS_VERSION                     2
00021 #define IDS_SYSMENU                     4
00022 #define ICO_MAIN                        101
00023 #define IDM_APP                         104
00024 #define ID_APPACCEL                     105
00025 #define IDM_EXIT                        40002
00026 #define IDM_VIEW_CLEAR                  40012
00027 #define IDM_EJECT                       40021
00028 #define IDM_ABOUT                       40092
00029
00030 #define IDM_REGISTER_LOCAL              40100
00031 #define IDM_INVOKE_ALL                  40101
00032
00033 // Next default values for new objects
00034 //
00035 #ifdef APSTUDIO_INVOKED
00036 #ifndef APSTUDIO_READONLY_SYMBOLS
00037 #define _APS_NEXT_RESOURCE_VALUE        124
00038 #define _APS_NEXT_COMMAND_VALUE         40145
00039 #define _APS_NEXT_CONTROL_VALUE         1028
00040 #define _APS_NEXT_SYMED_VALUE           101
00041 #endif
00042 #endif
00043
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminErrorCodes.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminErrorCodes.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminErrorCodes
00019
00020 public interface COMAdminErrorCodes
00021 {
00022   public static final int COMAdminErrObjectErrors = -2146368511;
00023   public static final int COMAdminErrObjectInvalid = -2146368510;
00024   public static final int COMAdminErrKeyMissing = -2146368509;
00025   public static final int COMAdminErrAlreadyInstalled = -2146368508;
00026   public static final int COMAdminErrAppFileWriteFail = -2146368505;
00027   public static final int COMAdminErrAppFileReadFail = -2146368504;
00028   public static final int COMAdminErrAppFileVersion = -2146368503;
00029   public static final int COMAdminErrBadPath = -2146368502;
00030   public static final int COMAdminErrApplicationExists = -2146368501;
00031   public static final int COMAdminErrRoleExists = -2146368500;
00032   public static final int COMAdminErrCantCopyFile = -2146368499;
00033   public static final int COMAdminErrNoUser = -2146368497;
00034   public static final int COMAdminErrInvalidUserids = -2146368496;
00035   public static final int COMAdminErrNoRegistryCLSID = -2146368495;
00036   public static final int COMAdminErrBadRegistryProgID = -2146368494;
00037   public static final int COMAdminErrAuthenticationLevel = -2146368493;
00038   public static final int COMAdminErrUserPasswdNotValid = -2146368492;
00039   public static final int COMAdminErrCLSIDOrIIDMismatch = -2146368488;
00040   public static final int COMAdminErrRemoteInterface = -2146368487;
00041   public static final int COMAdminErrDllRegisterServer = -2146368486;
00042   public static final int COMAdminErrNoServerShare = -2146368485;
00043   public static final int COMAdminErrDllLoadFailed = -2146368483;
00044   public static final int COMAdminErrBadRegistryLibID = -2146368482;
00045   public static final int COMAdminErrAppDirNotFound = -2146368481;
00046   public static final int COMAdminErrRegistrarFailed = -2146368477;
00047   public static final int COMAdminErrCompFileDoesNotExist = -2146368476;
00048   public static final int COMAdminErrCompFileLoadDLLFail = -2146368475;
00049   public static final int COMAdminErrCompFileGetClassObj = -2146368474;
00050   public static final int COMAdminErrCompFileClassNotAvail = -2146368473;
00051   public static final int COMAdminErrCompFileBadTLB = -2146368472;
00052   public static final int COMAdminErrCompFileNotInstallable = -2146368471;
00053   public static final int COMAdminErrNotChangeable = -2146368470;
00054   public static final int COMAdminErrNotDeletable = -2146368469;
00055   public static final int COMAdminErrSession = -2146368468;
00056   public static final int COMAdminErrCompMoveLocked = -2146368467;
00057   public static final int COMAdminErrCompMoveBadDest = -2146368466;
00058   public static final int COMAdminErrRegisterTLB = -2146368464;
00059   public static final int COMAdminErrSystemApp = -2146368461;
00060   public static final int COMAdminErrCompFileNoRegistrar = -2146368460;
00061   public static final int COMAdminErrCoReqCompInstalled = -2146368459;
00062   public static final int COMAdminErrServiceNotInstalled = -2146368458;
00063   public static final int COMAdminErrPropertySaveFailed = -2146368457;
00064   public static final int COMAdminErrObjectExists = -2146368456;
00065   public static final int COMAdminErrRegFileCorrupt = -2146368453;
00066   public static final int COMAdminErrPropertyOverflow = -2146368452;
00067   public static final int COMAdminErrNotInRegistry = -2146368450;
00068   public static final int COMAdminErrObjectNotPoolable = -2146368449;
00069   public static final int COMAdminErrApplidMatchesClsid = -2146368442;
00070   public static final int COMAdminErrRoleDoesNotExist = -2146368441;
00071   public static final int COMAdminErrStartAppNeedsComponents = -2146368440;
00072   public static final int COMAdminErrRequiresDifferentPlatform = -2146368439;
00073   public static final int COMAdminErrQueuingServiceNotAvailable = -2146367998;
00074   public static final int COMAdminErrObjectParentMissing = -2146367480;
00075   public static final int COMAdminErrObjectDoesNotExist = -2146367479;
00076   public static final int COMAdminErrCanNotExportAppProxy = -2146368438;
00077   public static final int COMAdminErrCanNotStartApp = -2146368437;
00078   public static final int COMAdminErrCanNotExportSystemApp = -2146368436;
00079   public static final int COMAdminErrCanNotSubscribeToComponent = -2146368435;
00080 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/osp/vc/cexlist.h Source File

  • Dataaccess
  • osp
  • vc

cexlist.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CEXLIST.H
00008 //
00009 //-----------------------------------------------------------------------------
00010 #ifndef _CEXLIST_H_
00011 #define _CEXLIST_H_
00012
00013 /////////////////////////////////////////////////////////////////////////////
00014 // Includes
00015 //
00016 /////////////////////////////////////////////////////////////////////////////
00017
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // Defines
00021 //
00022 /////////////////////////////////////////////////////////////////////////////
00023 typedef void* POS;
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // CNode
00028 //
00029 /////////////////////////////////////////////////////////////////////////////
00030 template <class TYPE> class CNode
00031 {
00032 public:
00033   // constructors
00034   CNode(TYPE val, CNode* pPrevNode, CNode* pNextNode);
00035
00036   // members
00037   TYPE     m_data;       // element data
00038   CNode*   m_pNextNode;  // next CNode
00039   CNode*   m_pPrevNode;  // prev CNode
00040 };
00041
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // CNode::CNode
00045 //
00046 /////////////////////////////////////////////////////////////////////////////
00047 template <class TYPE> CNode<TYPE>::CNode(TYPE data, CNode* pPrevNode, CNode* pNextNode)
00048 {
00049   //Constructor
00050   m_data = data;
00051   m_pPrevNode = pPrevNode;
00052   m_pNextNode = pNextNode;
00053 }
00054
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CExList
00059 //
00060 /////////////////////////////////////////////////////////////////////////////
00061 template <class TYPE> class CExList
00062 {
00063 public:
00064
00065   //constructors
00066   CExList();
00067   virtual ~CExList();
00068
00069   //members
00070
00071   //list modifying operations
00072   virtual POS   AddHead(TYPE element);    // Add to Head
00073   virtual POS   AddTail(TYPE element);    // Add to Tail
00074
00075   virtual POS   InsertBefore(POS position, TYPE element); // Add before position
00076   virtual POS   InsertAfter(POS position, TYPE element);  // Add after position
00077
00078   virtual TYPE  RemoveHead();       // Remove from Head
00079   virtual TYPE  RemoveTail();       // Remove from Tail
00080   virtual TYPE  RemoveAt(POS position);   // RemoveAt position
00081   virtual void  RemoveAll();        // Remove all elements
00082
00083   //Seeking methods
00084   virtual POS   Find(TYPE element);         // Find element
00085
00086   //Peek methods
00087   virtual POS   GetHeadPosition();      // Head Position
00088   virtual POS   GetTailPosition();      // Tail Position
00089
00090   virtual TYPE  GetHead();          // Head element
00091   virtual TYPE  GetTail();          // Tail element
00092   virtual TYPE  GetNext(POS& position);   // Next element
00093   virtual TYPE  GetPrev(POS& position);   // Prev element
00094
00095   //Data methods
00096   virtual TYPE  GetAt(POS position) const;      //Get element value
00097   virtual TYPE  SetAt(POS position, TYPE element);  //Set element value
00098
00099   //Array-like methods
00100   virtual POS   FindIndex(ULONG iIndex);  //Index element
00101
00102   //informational methods
00103   virtual BOOL  IsEmpty();          // IsEmpty
00104   virtual ULONG GetCount();         // Elements in the list
00105
00106 private:
00107   //data
00108   CNode<TYPE>*  m_pHeadNode;        // Head of CExList
00109   CNode<TYPE>*  m_pTailNode;        // Tail of CExList
00110   ULONG     m_ulElements;       // Elements in the list
00111 };
00112
00113
00114 /////////////////////////////////////////////////////////////////////////////
00115 // CExList::CExList
00116 //
00117 /////////////////////////////////////////////////////////////////////////////
00118 template <class TYPE> CExList<TYPE>::CExList()
00119 {
00120   //constructor
00121   m_pHeadNode = NULL;
00122   m_pTailNode = NULL;
00123   m_ulElements = 0;
00124 }
00125
00126 /////////////////////////////////////////////////////////////////////////////
00127 // CExList::~CExList
00128 //
00129 /////////////////////////////////////////////////////////////////////////////
00130 template <class TYPE> CExList<TYPE>::~CExList()
00131 {
00132   //Remove all elements
00133   RemoveAll();
00134 }
00135
00136
00137 /////////////////////////////////////////////////////////////////////////////
00138 // CExList::AddHead
00139 //
00140 /////////////////////////////////////////////////////////////////////////////
00141 template <class TYPE> POS CExList<TYPE>::AddHead(TYPE element)
00142 {
00143   //Add to the Head of the CExList, (stack)
00144   CNode<TYPE>* pHeadNode = new CNode<TYPE>(element, NULL, m_pHeadNode);
00145
00146   //If there was a list hook the head->prev to the new head
00147   if(m_pHeadNode)
00148     m_pHeadNode->m_pPrevNode = pHeadNode;
00149
00150   //If there isn't a tail element, hook it to the head
00151   if(!m_pTailNode)
00152     m_pTailNode = pHeadNode;
00153
00154   m_pHeadNode = pHeadNode;
00155   m_ulElements++;
00156   return m_pHeadNode;
00157 }
00158
00159
00160 /////////////////////////////////////////////////////////////////////////////
00161 // CExList::AddTail
00162 //
00163 /////////////////////////////////////////////////////////////////////////////
00164 template <class TYPE> POS CExList<TYPE>::AddTail(TYPE element)
00165 {
00166   //Add to the m_pTailNode of the CExList
00167   CNode<TYPE>* pTailNode = new CNode<TYPE>(element, m_pTailNode, 0);
00168
00169   //if previously empty
00170   if(!m_pHeadNode)
00171     m_pHeadNode = pTailNode;
00172   else
00173     m_pTailNode->m_pNextNode = pTailNode;
00174
00175   m_pTailNode = pTailNode;
00176   m_ulElements++;
00177   return m_pTailNode;
00178 }
00179
00180
00181
00182 /////////////////////////////////////////////////////////////////////////////
00183 // CExList::GetHeadPosition
00184 //
00185 /////////////////////////////////////////////////////////////////////////////
00186 template <class TYPE> inline POS CExList<TYPE>::GetHeadPosition()
00187 {
00188   //return Head element Position
00189   return m_pHeadNode;
00190 }
00191
00192 /////////////////////////////////////////////////////////////////////////////
00193 // CExList::GetTailPosition
00194 //
00195 /////////////////////////////////////////////////////////////////////////////
00196 template <class TYPE> inline POS CExList<TYPE>::GetTailPosition()
00197 {
00198   //return Tail element Position
00199   return m_pTailNode;
00200 }
00201
00202 /////////////////////////////////////////////////////////////////////////////
00203 // CExList::GetHead
00204 //
00205 /////////////////////////////////////////////////////////////////////////////
00206 template <class TYPE> inline TYPE CExList<TYPE>::GetHead()
00207 {
00208   //return Head element value
00209   return m_pHeadNode->m_data;
00210 }
00211
00212 /////////////////////////////////////////////////////////////////////////////
00213 // CExList::AddTail
00214 //
00215 /////////////////////////////////////////////////////////////////////////////
00216 template <class TYPE> inline TYPE CExList<TYPE>::GetTail()
00217 {
00218   // return Tail element value
00219   return m_pTailNode->m_data;
00220 }
00221
00222
00223 /////////////////////////////////////////////////////////////////////////////
00224 // CExList::GetNext
00225 //
00226 /////////////////////////////////////////////////////////////////////////////
00227 template <class TYPE> inline TYPE CExList<TYPE>::GetNext(POS& position)
00228 {
00229   //Set position to the next element
00230   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00231   position = pNode->m_pNextNode;
00232
00233   //return the current element
00234   return pNode->m_data;
00235 }
00236
00237
00238 /////////////////////////////////////////////////////////////////////////////
00239 // CExList::GetPrev
00240 //
00241 /////////////////////////////////////////////////////////////////////////////
00242 template <class TYPE> inline TYPE CExList<TYPE>::GetPrev(POS& position)
00243 {
00244   //Set position to the next element
00245   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00246   position = pNode->m_pPrevNode;
00247
00248   //return the current element
00249   return pNode->m_data;
00250 }
00251
00252
00253 /////////////////////////////////////////////////////////////////////////////
00254 // CExList::GetAt
00255 //
00256 /////////////////////////////////////////////////////////////////////////////
00257 template <class TYPE> inline TYPE CExList<TYPE>::GetAt(POS position) const
00258 {
00259   return ((CNode<TYPE>*)position)->m_data;
00260 }
00261
00262 /////////////////////////////////////////////////////////////////////////////
00263 // CExList::SetAt
00264 //
00265 /////////////////////////////////////////////////////////////////////////////
00266 template <class TYPE> inline TYPE CExList<TYPE>::SetAt(POS position, TYPE element)
00267 {
00268   //Save the old data
00269   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00270   TYPE oldData = pNode->m_data;
00271
00272   //Store new data
00273   pNode->m_data = element;
00274
00275   //return olddata
00276   return oldData;
00277 }
00278
00279
00280 /////////////////////////////////////////////////////////////////////////////
00281 // CExList::Find
00282 //
00283 /////////////////////////////////////////////////////////////////////////////
00284 template <class TYPE> POS CExList<TYPE>::Find(TYPE element)
00285 {
00286   //return pointer to found element
00287   for(CNode<TYPE>* p = m_pHeadNode; p; p = p->m_pNextNode)
00288     if(p->m_data == element)
00289     return p;   // return position to found CNode
00290
00291   return NULL;  // return NULL if not found
00292 }
00293
00294
00295 /////////////////////////////////////////////////////////////////////////////
00296 // CExList::IsEmpty
00297 //
00298 /////////////////////////////////////////////////////////////////////////////
00299 template <class TYPE> inline BOOL CExList<TYPE>::IsEmpty()
00300 {
00301   // returns TRUE if Empty
00302   return m_ulElements == 0;
00303 }
00304
00305
00306
00307 /////////////////////////////////////////////////////////////////////////////
00308 // CExList::RemoveHead
00309 //
00310 /////////////////////////////////////////////////////////////////////////////
00311 template <class TYPE> TYPE CExList<TYPE>::RemoveHead()
00312 {
00313   //Remove and return from the Head of the List
00314   CNode<TYPE>* pHeadNode = m_pHeadNode; // pointer to the Removed node
00315   TYPE element = GetHead();       //make a copy, before deleteing
00316
00317   m_pHeadNode = pHeadNode->m_pNextNode;   // reroute Head to exclude the first element
00318   if(m_pHeadNode)
00319     m_pHeadNode->m_pPrevNode = NULL;
00320   else
00321     m_pTailNode = NULL;
00322
00323   m_ulElements--;
00324   delete pHeadNode;           // delete head
00325   return element;
00326 }
00327
00328
00329 /////////////////////////////////////////////////////////////////////////////
00330 // CExList::RemoveTail
00331 //
00332 /////////////////////////////////////////////////////////////////////////////
00333 template <class TYPE> TYPE CExList<TYPE>::RemoveTail()
00334 {
00335   //Remove and return from the m_pTailNode of the CExList
00336   CNode<TYPE>* pTailNode = m_pTailNode->m_pPrevNode;
00337   TYPE element = GetTail();  //make a copy before deleteing
00338
00339   m_pTailNode = pTailNode;
00340   if(m_pTailNode)
00341     m_pTailNode->m_pNextNode = NULL;
00342   else
00343     m_pHeadNode = NULL;
00344
00345   m_ulElements--;
00346   delete m_pTailNode;
00347   return element;
00348 }
00349
00350
00351 /////////////////////////////////////////////////////////////////////////////
00352 // CExList::RemoveAt
00353 //
00354 /////////////////////////////////////////////////////////////////////////////
00355 template <class TYPE> TYPE CExList<TYPE>::RemoveAt(POS position)
00356 {
00357   //Remove CExList[position]
00358   CNode<TYPE>* pNode = (CNode<TYPE>*)position;
00359   TYPE oldData = pNode->m_data;
00360
00361   // If removing the head
00362   if (pNode == m_pHeadNode)
00363     m_pHeadNode = pNode->m_pNextNode;
00364   else
00365     pNode->m_pPrevNode->m_pNextNode = pNode->m_pNextNode;
00366
00367   //If removing the tail
00368   if (pNode == m_pTailNode)
00369     m_pTailNode = pNode->m_pPrevNode;
00370   else
00371     pNode->m_pNextNode->m_pPrevNode = pNode->m_pPrevNode;
00372
00373   m_ulElements--;
00374   delete pNode;
00375   return oldData;
00376 }
00377
00378
00379 /////////////////////////////////////////////////////////////////////////////
00380 // CExList::RemoveAll
00381 //
00382 /////////////////////////////////////////////////////////////////////////////
00383 template <class TYPE> void CExList<TYPE>::RemoveAll()
00384 {
00385   // Remove all items from the CExList
00386   CNode<TYPE>* pNode = m_pHeadNode;
00387   while(pNode)
00388   {
00389     CNode<TYPE>* pTemp = pNode;
00390     pNode = pNode->m_pNextNode;
00391     delete pTemp;
00392   }
00393
00394   m_pHeadNode   = NULL;
00395   m_pTailNode   = NULL;
00396   m_ulElements  = 0;
00397 }
00398
00399
00400 /////////////////////////////////////////////////////////////////////////////
00401 // CExList::GetCount
00402 //
00403 /////////////////////////////////////////////////////////////////////////////
00404 template <class TYPE> inline ULONG CExList<TYPE>::GetCount()
00405 {
00406   // return the Length
00407   return m_ulElements;
00408 }
00409
00410
00411 /////////////////////////////////////////////////////////////////////////////
00412 // CExList::InsertBefore
00413 //
00414 /////////////////////////////////////////////////////////////////////////////
00415 template <class TYPE> POS CExList<TYPE>::InsertBefore(POS position, TYPE element)
00416 {
00417   //insert before the position
00418   if(position == m_pHeadNode)    // Add before Head
00419     return AddHead(element);
00420
00421   CNode<TYPE>* pOldNode = (CNode<TYPE>*)position;
00422
00423   //otherwise a little more difficult
00424   CNode<TYPE>* pNewNode = new CNode<TYPE>(element, pOldNode->m_pPrevNode, pOldNode);
00425
00426   //Create the new node
00427   pNewNode->m_pNextNode = new CNode<TYPE>(element, pOldNode->m_pPrevNode, pOldNode->m_pNextNode);
00428
00429   //Hook up before after nodes to it
00430   pOldNode->m_pPrevNode->m_pNextNode = pNewNode;
00431   pOldNode->m_pPrevNode = pNewNode;
00432
00433   m_ulElements++;
00434   return pNewNode;
00435 }
00436
00437
00438
00439 /////////////////////////////////////////////////////////////////////////////
00440 // CExList::InsertAfter
00441 //
00442 /////////////////////////////////////////////////////////////////////////////
00443 template <class TYPE> POS CExList<TYPE>::InsertAfter(POS position, TYPE element)
00444 {
00445   //insert after the position
00446   if(position == m_pTailNode)     // Add after the m_pTailNode
00447     return AddTail(element);
00448
00449   CNode<TYPE>* pOldNode = (CNode<TYPE>*)position;
00450
00451   //other wise a little more difficult
00452   CNode<TYPE>* pNewNode = new CNode<TYPE>(element, pOldNode, pOldNode->m_pNextNode);
00453
00454   //Hook up before after nodes to it
00455   pOldNode->m_pNextNode->m_pPrevNode = pNewNode;
00456   pOldNode->m_pNextNode = pNewNode;
00457
00458   m_ulElements++;
00459   return pNewNode;
00460 }
00461
00462
00463 /////////////////////////////////////////////////////////////////////////////
00464 // CExList::FindIndex
00465 //
00466 /////////////////////////////////////////////////////////////////////////////
00467 template <class TYPE> POS CExList<TYPE>::FindIndex(ULONG iIndex)
00468 {
00469   CNode<TYPE>* pNode = m_pHeadNode;
00470
00471   //Find the specified index
00472   while(iIndex--)
00473     pNode = pNode->m_pNextNode;
00474
00475   return (POS)pNode;
00476 }
00477
00478 #endif //_LIST_H_
00479
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/networkmgr.h Source File

  • NetDS
  • RRas
  • ip

networkmgr.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\networkmanager.h
00008
00009 Abstract:
00010
00011     The file contains the interface to the network manager.
00012
00013 --*/
00014
00015 #ifndef _NETWORK_MANAGER_H_
00016 #define _NETWORK_MANAGER_H_
00017
00018
00019 VOID
00020 WINAPI
00021 NM_CallbackNetworkEvent (
00022     IN  PVOID                   pvContext,
00023     IN  BOOLEAN                 bTimerOrWaitFired);
00024
00025 VOID
00026 WINAPI
00027 NM_CallbackPeriodicTimer (
00028     IN  PVOID                   pvContext,
00029     IN  BOOLEAN                 bTimerOrWaitFired);
00030
00031
00032
00033 DWORD
00034 NM_AddInterface (
00035     IN  LPWSTR                  pwszInterfaceName,
00036     IN  DWORD                 dwInterfaceIndex,
00037     IN  WORD                    wAccessType,
00038     IN  PVOID                 pvInterfaceInfo);
00039
00040 DWORD
00041 NM_DeleteInterface (
00042     IN  DWORD                   dwInterfaceIndex);
00043
00044 DWORD
00045 NM_InterfaceStatus (
00046     IN DWORD                    dwInterfaceIndex,
00047     IN BOOL                     bInterfaceActive,
00048     IN DWORD                    dwStatusType,
00049     IN PVOID                    pvStatusInfo);
00050
00051 DWORD
00052 NM_GetInterfaceInfo (
00053     IN      DWORD               dwInterfaceIndex,
00054     IN      PVOID               pvInterfaceInfo,
00055     IN  OUT PULONG              pulBufferSize,
00056     OUT     PULONG              pulStructureVersion,
00057     OUT     PULONG              pulStructureSize,
00058     OUT     PULONG              pulStructureCount);
00059
00060 DWORD
00061 NM_SetInterfaceInfo (
00062     IN      DWORD               dwInterfaceIndex,
00063     IN      PVOID               pvInterfaceInfo);
00064
00065
00066
00067 DWORD
00068 NM_DoUpdateRoutes (
00069     IN      DWORD               dwInterfaceIndex
00070     );
00071
00072
00073
00074 DWORD
00075 NM_ProcessRouteChange (
00076     VOID);
00077
00078 #endif // _NETWORK_MANAGER_H_
00079
00080
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/people.h Source File

  • SysMgmt
  • MMC
  • Multisel

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBicycle : public CDelegationBase {
00026 public:
00027     CBicycle(int i) : id(i) { }
00028     virtual ~CBicycle() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00033
00034 private:
00035     // {2974380D-4C4B-11d2-89D8-000021473128}
00036     static const GUID thisGuid;
00037
00038     int id;
00039 };
00040
00041 class CBicycleFolder : public CDelegationBase {
00042 public:
00043     CBicycleFolder();
00044     virtual ~CBicycleFolder();
00045
00046     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Bicycles"); }
00047     virtual const GUID & getNodeType() { return thisGuid; }
00048     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00049
00050 public:
00051     // virtual functions go here (for MMCN_*)
00052     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00053
00054 private:
00055     // {2974380D-4C4B-11d2-89D8-000021473128}
00056     static const GUID thisGuid;
00057
00058     enum { NUMBER_OF_CHILDREN = 20 };
00059     CDelegationBase *children[NUMBER_OF_CHILDREN];
00060 };
00061
00062 class CSkateboard : public CDelegationBase {
00063 public:
00064     CSkateboard(int i) : id(i) { }
00065     virtual ~CSkateboard() {}
00066
00067     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00068     virtual const GUID & getNodeType() { return thisGuid; }
00069     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00070
00071 private:
00072     // {2974380D-4C4B-11d2-89D8-000021473128}
00073     static const GUID thisGuid;
00074
00075     int id;
00076 };
00077
00078 class CSkateboardFolder : public CDelegationBase {
00079 public:
00080     CSkateboardFolder();
00081     virtual ~CSkateboardFolder();
00082
00083     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Skateboards"); }
00084     virtual const GUID & getNodeType() { return thisGuid; }
00085     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00086
00087 public:
00088     // virtual functions go here (for MMCN_*)
00089     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00090
00091 private:
00092     // {2974380D-4C4B-11d2-89D8-000021473128}
00093     static const GUID thisGuid;
00094
00095     enum { NUMBER_OF_CHILDREN = 20 };
00096     CDelegationBase *children[NUMBER_OF_CHILDREN];
00097 };
00098
00099 class CIceSkate : public CDelegationBase {
00100 public:
00101     CIceSkate(int i) : id(i) { }
00102     virtual ~CIceSkate() {}
00103
00104     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00105     virtual const GUID & getNodeType() { return thisGuid; }
00106     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00107
00108 private:
00109     // {2974380D-4C4B-11d2-89D8-000021473128}
00110     static const GUID thisGuid;
00111
00112     int id;
00113 };
00114
00115 class CIceSkateFolder : public CDelegationBase {
00116 public:
00117     CIceSkateFolder();
00118     virtual ~CIceSkateFolder();
00119
00120     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Ice Skates"); }
00121     virtual void GetChildColumnInfo(RESULTDATAITEM *rdi);
00122     virtual const GUID & getNodeType() { return thisGuid; }
00123     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00124
00125   virtual CDelegationBase *GetChildPtr(int index) {
00126     return (index < NUMBER_OF_CHILDREN) ? children[index] : NULL;
00127   }
00128
00129     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00130
00131 public:
00132     // virtual functions go here (for MMCN_*)
00133     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00134     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00135
00136 private:
00137     // {2974380D-4C4B-11d2-89D8-000021473128}
00138     static const GUID thisGuid;
00139
00140     enum { NUMBER_OF_CHILDREN = 5000 };
00141     CDelegationBase *children[NUMBER_OF_CHILDREN];
00142 };
00143
00144 class CPeoplePoweredVehicle : public CDelegationBase {
00145 public:
00146     CPeoplePoweredVehicle();
00147     virtual ~CPeoplePoweredVehicle();
00148
00149     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00150     virtual const GUID & getNodeType() { return thisGuid; }
00151     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00152
00153     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00154
00155 private:
00156     enum { IDM_NEW_PEOPLE = 1 };
00157
00158     // {2974380D-4C4B-11d2-89D8-000021473128}
00159     static const GUID thisGuid;
00160
00161     enum { NUMBER_OF_CHILDREN = 3 };
00162     CDelegationBase *children[3];
00163 };
00164
00165 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkDivider/C#/InkDividerForm.cs Source File

  • TabletPC
  • InkDivider
  • C#

InkDividerForm.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: InkDividerForm.cs
00013 //  Simple Ink Divider Sample Application
00014 //
00015 //  This sample is based on the Ink Collection sample. An InkDivider
00016 //  is created and asked to do layout analysis. In Automatic Layout
00017 //  Analysis mode (accessible through Mode->Automatic Layout Analysis
00018 //  menu item) the Ink Divider is invoked whenever the ink is changed.
00019 //  Otherwise, the Ink Division can be invoked through File->Divide
00020 //  menu item. In either case, the default recognizer is used, if
00021 //  available. The divide method is called. The UI is then updated by
00022 //  drawing a bounding rectangle around each parsed unit. Besides using
00023 //  different colors, these rectangles are inflated by different amounts
00024 //  to ensure that none of the rectangles is obscured by others.
00025 //  The following table specifies the color and inflation for each units:
00026 //
00027 //      |-----------|-----------|-----------|
00028 //      | Unit      |  Color    | Inflation |
00029 //      |-----------|-----------|-----------|
00030 //      | Word      | Green     |    1      |
00031 //      |-----------|-----------|-----------|
00032 //      | Line      | Magenta   |    3      |
00033 //      |-----------------------|-----------|
00034 //      | Paragraph | Blue      |    5      |
00035 //      |-----------------------|-----------|
00036 //      | Drawing   | Red       |    1      |
00037 //      |-----------------------------------|
00038 //
00039 //  The application has the capability of erasing strokes. Two menu items
00040 //  Mode->Ink and Mode->Erase are provided to switch between inking and
00041 //  erasing modes. As the new ink is added or deleted to or from the Ink
00042 //  object, the ink divider is kept updated. It makes InkDivider.Divide()
00043 //  method to work fast.
00044 //  The menu item for Mode->Automatic Layout Analysis is checked by default.
00045 //  With this option checked, the InkCollector object's Stroke and StrokeDeleted
00046 //  event handlers call this method every time a stroke is made or deleted. With
00047 //  more than a few strokes present, the call to the Divider object's Divide
00048 //  method creates a noticeable delay. In practice, call the Divide method only
00049 //  when you need the division result.
00050 //
00051 //  The features used are: InkDivider, InkOverlay, Erasing Ink,
00052 //      InkCollectorStrokeEventHandler, InkOverlayStrokesDeletingEventHandler,
00053 //      InkOverlayStrokesDeletedEventHandler and InkSpaceToPixel.
00054 //
00055 //--------------------------------------------------------------------------
00056
00057 using System;
00058 using System.Drawing;
00059 using System.Windows.Forms;
00060
00061 // The Ink namespace, which contains the Tablet PC Platform API
00062 using Microsoft.Ink;
00063
00064
00065 namespace Microsoft.Samples.Ink.CS.InkDividerSample
00066 {
00067     /// <summary>
00068     /// InkDivider sample application form class.
00069     /// </summary>
00070     public class InkDividerForm : System.Windows.Forms.Form
00071     {
00072         // Declare the Ink Overlay object
00073         private InkOverlay myInkOverlay = null;
00074
00075         // Declare the ink divider object
00076         private Divider myInkDivider = null;
00077
00078         // Collection of Bounding Boxes for words, drawings, lines and paragraphs
00079         Rectangle[] myWordBoundingBoxes;
00080         Rectangle[] myDrawingBoundingBoxes;
00081         Rectangle[] myLineBoundingBoxes;
00082         Rectangle[] myParagraphBoundingBoxes;
00083
00084         #region Standard Template Code
00085         private System.Windows.Forms.MainMenu mainMenu;
00086         private System.Windows.Forms.Panel DrawArea;
00087         private System.Windows.Forms.StatusBar statusBar;
00088         private System.Windows.Forms.StatusBarPanel statusBarPanelDummy;
00089         private System.Windows.Forms.StatusBarPanel statusBarPanelDrawing;
00090         private System.Windows.Forms.StatusBarPanel statusBarPanelParagraph;
00091         private System.Windows.Forms.StatusBarPanel statusBarPanelWord;
00092         private System.Windows.Forms.StatusBarPanel statusBarPanelLine;
00093         private System.Windows.Forms.MenuItem miFile;
00094         private System.Windows.Forms.MenuItem miDivide;
00095         private System.Windows.Forms.MenuItem miExit;
00096         private System.Windows.Forms.MenuItem miMode;
00097         private System.Windows.Forms.MenuItem miInk;
00098         private System.Windows.Forms.MenuItem miErase;
00099         private System.Windows.Forms.MenuItem miAutomaticLayoutAnalysis;
00100         private System.Windows.Forms.MenuItem miSeparate;
00101         /// <summary>
00102         /// Required designer variable.
00103         /// </summary>
00104         private System.ComponentModel.Container components = null;
00105         #endregion
00106
00107         public InkDividerForm()
00108         {
00109             #region Standard Template Code
00110             //
00111             // Required for Windows Form Designer support
00112             //
00113             InitializeComponent();
00114
00115             //
00116             // Add any constructor code after InitializeComponent call to be added here
00117             //
00118             #endregion
00119
00120         }
00121
00122         #region Standard Template Code
00123         /// <summary>
00124         /// Clean up any resources being used.
00125         /// </summary>
00126         protected override void Dispose( bool disposing )
00127         {
00128             if( disposing )
00129             {
00130                 if (components != null)
00131                 {
00132                     components.Dispose();
00133                 }
00134
00135                 // dispose the ink overlay's resources
00136                 if (myInkOverlay != null)
00137                 {
00138                     myInkOverlay.Dispose();
00139                 }
00140
00141                 // dispose the divider's resources
00142                 if (myInkDivider != null)
00143                 {
00144                     // dispose the recognizer context that we associated
00145                     // with the divider
00146                     if (myInkDivider.RecognizerContext != null)
00147                     {
00148                         myInkDivider.RecognizerContext.Dispose();
00149                     }
00150
00151                     // dispose the strokes that we associated
00152                     // with the divider
00153                     if (myInkDivider.Strokes != null)
00154                     {
00155                         myInkDivider.Strokes.Dispose();
00156                     }
00157                     myInkDivider.Dispose();
00158                 }
00159             }
00160             base.Dispose( disposing );
00161         }
00162         #endregion
00163
00164         #region Windows Form Designer generated code
00165         /// <summary>
00166         /// Required method for Designer support - do not modify
00167         /// the contents of this method with the code editor.
00168         /// </summary>
00169         private void InitializeComponent()
00170         {
00171             this.mainMenu = new System.Windows.Forms.MainMenu();
00172             this.miFile = new System.Windows.Forms.MenuItem();
00173             this.miDivide = new System.Windows.Forms.MenuItem();
00174             this.miExit = new System.Windows.Forms.MenuItem();
00175             this.miMode = new System.Windows.Forms.MenuItem();
00176             this.miInk = new System.Windows.Forms.MenuItem();
00177             this.miErase = new System.Windows.Forms.MenuItem();
00178             this.miSeparate = new System.Windows.Forms.MenuItem();
00179             this.miAutomaticLayoutAnalysis = new System.Windows.Forms.MenuItem();
00180             this.DrawArea = new System.Windows.Forms.Panel();
00181             this.statusBar = new System.Windows.Forms.StatusBar();
00182             this.statusBarPanelDummy = new System.Windows.Forms.StatusBarPanel();
00183             this.statusBarPanelWord = new System.Windows.Forms.StatusBarPanel();
00184             this.statusBarPanelLine = new System.Windows.Forms.StatusBarPanel();
00185             this.statusBarPanelParagraph = new System.Windows.Forms.StatusBarPanel();
00186             this.statusBarPanelDrawing = new System.Windows.Forms.StatusBarPanel();
00187             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelDummy)).BeginInit();
00188             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelWord)).BeginInit();
00189             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelLine)).BeginInit();
00190             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelParagraph)).BeginInit();
00191             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelDrawing)).BeginInit();
00192             this.SuspendLayout();
00193             //
00194             // mainMenu
00195             //
00196             this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00197                                                                                      this.miFile,
00198                                                                                      this.miMode});
00199             //
00200             // miFile
00201             //
00202             this.miFile.Index = 0;
00203             this.miFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00204                                                                                    this.miDivide,
00205                                                                                    this.miExit});
00206             this.miFile.Text = "&File";
00207             //
00208             // miDivide
00209             //
00210             this.miDivide.Index = 0;
00211             this.miDivide.Text = "&Divide";
00212             this.miDivide.Click += new System.EventHandler(this.miDivide_Click);
00213             //
00214             // miExit
00215             //
00216             this.miExit.Index = 1;
00217             this.miExit.Text = "E&xit";
00218             this.miExit.Click += new System.EventHandler(this.miExit_Click);
00219             //
00220             // miMode
00221             //
00222             this.miMode.Index = 1;
00223             this.miMode.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00224                                                                                    this.miInk,
00225                                                                                    this.miErase,
00226                                                                                    this.miSeparate,
00227                                                                                    this.miAutomaticLayoutAnalysis});
00228             this.miMode.Text = "&Mode";
00229             //
00230             // miInk
00231             //
00232             this.miInk.Index = 0;
00233             this.miInk.Text = "&Ink";
00234             this.miInk.Click += new System.EventHandler(this.miInk_Click);
00235             //
00236             // miErase
00237             //
00238             this.miErase.Index = 1;
00239             this.miErase.Text = "&Erase";
00240             this.miErase.Click += new System.EventHandler(this.miErase_Click);
00241             //
00242             // miSeparate
00243             //
00244             this.miSeparate.Index = 2;
00245             this.miSeparate.Text = "-";
00246             //
00247             // miAutomaticLayoutAnalysis
00248             //
00249             this.miAutomaticLayoutAnalysis.Checked = true;
00250             this.miAutomaticLayoutAnalysis.Index = 3;
00251             this.miAutomaticLayoutAnalysis.Text = "&Automatic Layout Analysis";
00252             this.miAutomaticLayoutAnalysis.Click += new System.EventHandler(this.miAutomaticLayoutAnalysis_Click);
00253             //
00254             // DrawArea
00255             //
00256             this.DrawArea.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
00257                 | System.Windows.Forms.AnchorStyles.Left)
00258                 | System.Windows.Forms.AnchorStyles.Right);
00259             this.DrawArea.BackColor = System.Drawing.SystemColors.Window;
00260             this.DrawArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
00261             this.DrawArea.Name = "DrawArea";
00262             this.DrawArea.Size = new System.Drawing.Size(560, 420);
00263             this.DrawArea.TabIndex = 2;
00264             this.DrawArea.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawArea_Paint);
00265             //
00266             // statusBar
00267             //
00268             this.statusBar.Location = new System.Drawing.Point(0, 420);
00269             this.statusBar.Name = "statusBar";
00270             this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
00271                                                                                          this.statusBarPanelDummy,
00272                                                                                          this.statusBarPanelWord,
00273                                                                                          this.statusBarPanelLine,
00274                                                                                          this.statusBarPanelParagraph,
00275                                                                                          this.statusBarPanelDrawing});
00276             this.statusBar.RightToLeft = System.Windows.Forms.RightToLeft.No;
00277             this.statusBar.ShowPanels = true;
00278             this.statusBar.Size = new System.Drawing.Size(560, 21);
00279             this.statusBar.TabIndex = 3;
00280             //
00281             // statusBarPanelDummy
00282             //
00283             this.statusBarPanelDummy.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
00284             this.statusBarPanelDummy.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
00285             this.statusBarPanelDummy.Width = 200;
00286             //
00287             // statusBarPanelWord
00288             //
00289             this.statusBarPanelWord.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
00290             this.statusBarPanelWord.Text = "Green: Word";
00291             this.statusBarPanelWord.Width = 79;
00292             //
00293             // statusBarPanelLine
00294             //
00295             this.statusBarPanelLine.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
00296             this.statusBarPanelLine.Text = "Magenta: Line";
00297             this.statusBarPanelLine.Width = 86;
00298             //
00299             // statusBarPanelParagraph
00300             //
00301             this.statusBarPanelParagraph.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
00302             this.statusBarPanelParagraph.Text = "Blue: Paragraph";
00303             this.statusBarPanelParagraph.Width = 96;
00304             //
00305             // statusBarPanelDrawing
00306             //
00307             this.statusBarPanelDrawing.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
00308             this.statusBarPanelDrawing.Text = "Red: Drawing";
00309             this.statusBarPanelDrawing.Width = 83;
00310             //
00311             // InkDividerForm
00312             //
00313             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00314             this.ClientSize = new System.Drawing.Size(560, 441);
00315             this.Controls.AddRange(new System.Windows.Forms.Control[] {
00316                                                                           this.statusBar,
00317                                                                           this.DrawArea});
00318             this.Menu = this.mainMenu;
00319             this.Name = "InkDividerForm";
00320             this.Text = "Ink Divider";
00321             this.Load += new System.EventHandler(this.InkDividerForm_Load);
00322             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelDummy)).EndInit();
00323             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelWord)).EndInit();
00324             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelLine)).EndInit();
00325             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelParagraph)).EndInit();
00326             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelDrawing)).EndInit();
00327             this.ResumeLayout(false);
00328
00329         }
00330         #endregion
00331
00332         #region Standard Template Code
00333         /// <summary>
00334         /// The main entry point for the application.
00335         /// </summary>
00336         [STAThread]
00337         static void Main()
00338         {
00339             Application.Run(new InkDividerForm());
00340         }
00341         #endregion
00342
00343
00344         /// <summary>
00345         /// Paint method gets called everytime when the window is refreshed.
00346         /// </summary>
00347         /// <param name="sender"></param>
00348         /// <param name="e"></param>
00349         private void DrawArea_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
00350         {
00351             // Create the Pen used to draw bounding boxes.
00352             // First set of bounding boxes drawn here are the bounding boxes of paragraphs.
00353             // These boxes are drawn with Blue pen.
00354             Pen penBox = new Pen(Color.Blue, 2);
00355
00356             // First, draw the bounding boxes for Paragraphs
00357             if(null != myParagraphBoundingBoxes)
00358             {
00359                 // Draw bounding boxes for Paragraphs
00360                 e.Graphics.DrawRectangles(penBox, myParagraphBoundingBoxes);
00361             }
00362
00363             // Next, draw the bounding boxes for Lines
00364             if(null != myLineBoundingBoxes)
00365             {
00366                 // Color is Magenta pen
00367                 penBox.Color = Color.Magenta;
00368                 // Draw the bounding boxes for Lines
00369                 e.Graphics.DrawRectangles(penBox, myLineBoundingBoxes);
00370             }
00371
00372             // Then, draw the bounding boxes for Words
00373             if(null != myWordBoundingBoxes)
00374             {
00375                 // Color is Green
00376                 penBox.Color = Color.Green;
00377                 // Draw bounding boxes for Words
00378                 e.Graphics.DrawRectangles(penBox, myWordBoundingBoxes);
00379             }
00380
00381             // Finally, draw the boxes for Drawings
00382             if(null != myDrawingBoundingBoxes)
00383             {
00384                 // Color is Red pen
00385                 penBox.Color = Color.Red;
00386                 // Draw bounding boxes for Drawings
00387                 e.Graphics.DrawRectangles(penBox, myDrawingBoundingBoxes);
00388             }
00389         }
00390
00391         /// <summary>
00392         /// Event Handler from Form Load Event
00393         /// Setup the ink overlay for collection
00394         /// </summary>
00395         /// <param name="sender">The control that raised the event.</param>
00396         /// <param name="e">The event arguments.</param>
00397         private void InkDividerForm_Load(object sender, System.EventArgs e)
00398         {
00399             // Create the ink overlay and associate it with the form
00400             myInkOverlay = new Microsoft.Ink.InkOverlay(DrawArea.Handle);
00401
00402             // Hook event handler for the Stroke event to myInkOverlay_Stroke.
00403             // This is necessary since the application needs to pass the strokes
00404             // to the ink divider.
00405             myInkOverlay.Stroke += new InkCollectorStrokeEventHandler(myInkOverlay_Stroke);
00406
00407             // Hook the event handler for StrokeDeleting event to myInkOverlay_StrokeDeleting.
00408             // This is necessary as the application needs to remove the strokes from
00409             // ink divider object as well.
00410             myInkOverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(myInkOverlay_StrokeDeleting);
00411
00412             // Hook the event handler for StrokeDeleted event to myInkOverlay_StrokeDeleted.
00413             // This is necessary to update the layout analysis result when automatic layout analysis
00414             // option is selected.
00415             myInkOverlay.StrokesDeleted += new InkOverlayStrokesDeletedEventHandler(myInkOverlay_StrokeDeleted);
00416
00417             // Create the ink divider object
00418             myInkDivider = new Divider();
00419
00420             // Add a default recognizer context to the divider object
00421             // without adding the recognizer context, the divider would
00422             // not use a recognizer to do its word segmentation and would
00423             // have less accurate results.
00424             // Adding the recognizer context will slow down the call to
00425             // myInkDivider.Divide though.
00426             // It is possible that there is no recognizer installed on the
00427             // machine for this language. In that case the divider will
00428             // not use a recognizer to improve its accuracy.
00429             // Get the default recognizer if any
00430             try
00431             {
00432                 Recognizers recognizers = new Recognizers();
00433                 myInkDivider.RecognizerContext = recognizers.GetDefaultRecognizer().CreateRecognizerContext();
00434             }
00435             catch (InvalidOperationException)
00436             {
00437                 //We are in the case where no default recognizers can be found
00438             }
00439
00440             // The LineHeight property helps the InkDivider distinguish between
00441             // drawing and handwriting. The value should be the expected height
00442             // of the user's handwriting in ink space units (0.01mm).
00443             // Here we set the LineHeight to 840, which is about 1/3 of an inch.
00444             myInkDivider.LineHeight = 840;
00445
00446             // Assign ink overlay's strokes collection to the ink divider
00447             // This strokes collection will be updated in the event handler
00448             myInkDivider.Strokes = myInkOverlay.Ink.Strokes;
00449
00450             // Enable ink collection
00451             myInkOverlay.Enabled = true;
00452
00453             // Set check for ink menu item
00454             miInk.Checked = true;
00455         }
00456
00457         /// <summary>
00458         /// Helper function to obtain array of rectangles from the
00459         /// division result of the division type of interest. Each rectangle
00460         /// is inflated by the amount specified in the third parameter. This
00461         /// is done to ensure the visibility of all rectangles.
00462         /// </summary>
00463         /// <param name="divResult">Ink Divider division result</param>
00464         /// <param name="divType">Division type</param>
00465         /// <param name="inflate">Number of Pixels by which the rectangles are inflated</param>
00466         /// <returns> Array of rectangles containing bounding boxes of
00467         /// division type specified by divType. The rectangles are in pixel unit.</returns>
00468         private Rectangle[] GetUnitBBoxes(DivisionResult divResult, InkDivisionType divType, int inflate)
00469         {
00470             // Declare the array of rectangles to hold the result
00471             Rectangle[] divRects;
00472
00473             // Get the division units from the division result of division type
00474             DivisionUnits units = divResult.ResultByType(divType);
00475
00476             // If there is at least one unit, we construct the rectangles
00477             if((null != units) && (0 < units.Count))
00478             {
00479                 // We need to convert rectangles from ink units to
00480                 // pixel units. For that, we need Graphics object
00481                 // to pass to InkRenderer.InkSpaceToPixel method
00482                 using (Graphics g = DrawArea.CreateGraphics())
00483                 {
00484
00485                     // Construct the rectangles
00486                     divRects = new Rectangle[units.Count];
00487
00488                     // InkRenderer.InkSpaceToPixel takes Point as parameter.
00489                     // Create two Point objects to point to (Top, Left) and
00490                     // (Width, Height) properties of ractangle. (Width, Height)
00491                     // is used instead of (Right, Bottom) because (Right, Bottom)
00492                     // are read-only properties on Rectangle
00493                     Point ptLocation = new Point();
00494                     Point ptSize = new Point();
00495
00496                     // Index into the bounding boxes
00497                     int i = 0;
00498
00499                     // Iterate through the collection of division units to obtain the bounding boxes
00500                     foreach(DivisionUnit unit in units)
00501                     {
00502                         // Get the bounding box of the strokes of the division unit
00503                         divRects[i] = unit.Strokes.GetBoundingBox();
00504
00505                         // The bounding box is in ink space unit. Convert them into pixel unit.
00506                         ptLocation = divRects[i].Location;
00507                         ptSize.X = divRects[i].Width;
00508                         ptSize.Y = divRects[i].Height;
00509
00510                         // Convert the Location from Ink Space to Pixel Space
00511                         myInkOverlay.Renderer.InkSpaceToPixel(g, ref ptLocation);
00512
00513                         // Convert the Size from Ink Space to Pixel Space
00514                         myInkOverlay.Renderer.InkSpaceToPixel(g, ref ptSize);
00515
00516                         // Assign the result back to the corresponding properties
00517                         divRects[i].Location = ptLocation;
00518                         divRects[i].Width = ptSize.X;
00519                         divRects[i].Height = ptSize.Y;
00520
00521                         // Inflate the rectangle by inflate pixels in both directions
00522                         divRects[i].Inflate(inflate, inflate);
00523
00524                         // Increment the index
00525                         ++i;
00526                     }
00527
00528                 } // Relinquish the Graphics object
00529             }
00530             else
00531             {
00532                 // Otherwise we return null
00533                 divRects = null;
00534             }
00535
00536             // Return the Rectangle[] object
00537             return divRects;
00538         }
00539
00540         /// <summary>
00541         /// Helper function that calls Ink Divider to perform the ink division.
00542         /// This function is called by File->Divide menu handler and strokes
00543         /// event handler.
00544         /// </summary>
00545         private void DivideInk()
00546         {
00547             // Ink Divider produces result based on its own Strokes object
00548             // Invoke the Ink Divider
00549             DivisionResult divResult = myInkDivider.Divide();
00550
00551             // Call helper function to get the bounding boxes for Words
00552             // Rectangles are inflated by 1 pixel in all direction to
00553             // avoid overlapping with stroke
00554             myWordBoundingBoxes = GetUnitBBoxes(divResult, InkDivisionType.Segment, 1);
00555
00556             // Call helper function to get the bounding boxes for Lines
00557             // Rectangles are inflated by 3 pixels in all directions
00558             myLineBoundingBoxes = GetUnitBBoxes(divResult, InkDivisionType.Line, 3);
00559
00560             // Call helper function to get the bounding boxes for Paragraphs
00561             // Rectangles are inflated by 5 pixels in all directions
00562             myParagraphBoundingBoxes = GetUnitBBoxes(divResult, InkDivisionType.Paragraph, 5);
00563
00564             // Call helper function to get the bounding boxes for Drawings
00565             // The rectangles are inflated by 1 pixel in all directions
00566             myDrawingBoundingBoxes = GetUnitBBoxes(divResult, InkDivisionType.Drawing, 1);
00567
00568             // Update the form to reflect these changes
00569             DrawArea.Refresh();
00570         }
00571
00572         /// <summary>
00573         /// Event handler for File->Divide menu item
00574         /// </summary>
00575         /// <param name="sender">The control that raised the event.</param>
00576         /// <param name="e">The event arguments.</param>
00577         private void miDivide_Click(object sender, System.EventArgs e)
00578         {
00579             // Call DivideInk to perform the ink division
00580             DivideInk();
00581         }
00582
00583         /// <summary>
00584         /// Event Handler from Ink Overlay's Stroke event
00585         /// This event is fired when a new stroke is drawn.
00586         /// In this case, it is necessary to update the ink divider's
00587         /// strokes collection. The event is fired even when the eraser stroke is created.
00588         /// The event handler must filter out the eraser strokes.
00589         /// </summary>
00590         /// <param name="sender">The control that raised the event.</param>
00591         /// <param name="e">The event arguments.</param>
00592         private void myInkOverlay_Stroke(object sender, InkCollectorStrokeEventArgs e )
00593         {
00594             // Filter out the eraser stroke.
00595             if(InkOverlayEditingMode.Ink == myInkOverlay.EditingMode)
00596             {
00597                 // Add the new stroke to the ink divider's strokes collection
00598                 myInkDivider.Strokes.Add(e.Stroke);
00599
00600                 if(miAutomaticLayoutAnalysis.Checked)
00601                 {
00602                     // Call DivideInk
00603                     DivideInk();
00604
00605                     // Repaint the screen to reflect the change
00606                     DrawArea.Refresh();
00607                 }
00608             }
00609         }
00610
00611         /// <summary>
00612         /// Event Handler for Ink Overlay's StrokeDeleting event.
00613         /// This event is fired when a set of stroke is about to be deleted.
00614         /// The stroke should also be removed from the ink divider's
00615         /// stroke collection as well
00616         /// </summary>
00617         /// <param name="sender">The control that raised the event</param>
00618         /// <param name="e">The event arguments</param>
00619         void myInkOverlay_StrokeDeleting(object sender, InkOverlayStrokesDeletingEventArgs e)
00620         {
00621             // Remove the strokes to be deleted from the ink divider's stroke collection
00622             myInkDivider.Strokes.Remove(e.StrokesToDelete);
00623         }
00624
00625         /// <summary>
00626         /// Event handler for Ink Overlay's StrokeDeleted event.
00627         /// This event is fired when the set of strokes were actually deleted.
00628         /// DivideInk method is called to analyze the current layout.
00629         /// </summary>
00630         /// <param name="sender">The control that raised the event</param>
00631         /// <param name="e">The event argument</param>
00632         void myInkOverlay_StrokeDeleted(object sender, System.EventArgs e)
00633         {
00634             // If automatic layout analysis is turned on, call DivideInk
00635             if(miAutomaticLayoutAnalysis.Checked)
00636             {
00637                 // Call Divide Ink
00638                 DivideInk();
00639
00640                 // Repaint the screen to reflect the change
00641                 DrawArea.Refresh();
00642             }
00643         }
00644
00645         /// <summary>
00646         /// Event handler for File->Exit menu item
00647         /// </summary>
00648         /// <param name="sender">The control that raised the event.</param>
00649         /// <param name="e">The event arguments.</param>
00650         private void miExit_Click(object sender, System.EventArgs e)
00651         {
00652             this.Close();
00653         }
00654
00655         /// <summary>
00656         /// Event handler for Mode->Ink menu item
00657         /// </summary>
00658         /// <param name="sender">The control that raised the event.</param>
00659         /// <param name="e">The event arguments.</param>
00660         private void miInk_Click(object sender, System.EventArgs e)
00661         {
00662             // Turn on the inking mode
00663             myInkOverlay.EditingMode = InkOverlayEditingMode.Ink;
00664
00665             // Update the state of the Ink and Erase menu items
00666             miInk.Checked = true;
00667             miErase.Checked = false;
00668
00669             // Update the UI
00670             this.Refresh();
00671         }
00672
00673         /// <summary>
00674         /// Event handler for Mode->Erase menu item
00675         /// </summary>
00676         /// <param name="sender">The control that raised the event.</param>
00677         /// <param name="e">The event argument.</param>
00678         private void miErase_Click(object sender, System.EventArgs e)
00679         {
00680             // Turn on the ink deletion mode
00681             myInkOverlay.EditingMode = InkOverlayEditingMode.Delete;
00682
00683             // Update the state of the Ink and Erase menu items
00684             miInk.Checked = false;
00685             miErase.Checked = true;
00686
00687             // Update the UI
00688             this.Refresh();
00689         }
00690
00691         /// <summary>
00692         /// Event handler for Mode->AutomaticLayoutAnalysis menu item.
00693         /// </summary>
00694         /// <param name="sender">The control that raised the event.</param>
00695         /// <param name="e">The event argument.</param>
00696         private void miAutomaticLayoutAnalysis_Click(object sender, System.EventArgs e)
00697         {
00698             // Toggle the check on the menu item.
00699             miAutomaticLayoutAnalysis.Checked = !miAutomaticLayoutAnalysis.Checked;
00700             // Update the window.
00701             this.Refresh();
00702         }
00703     }
00704 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTSFDataObject Member List

This is the complete list of members for CTSFDataObject, including all inherited members.
_SetText(LPWSTR pwszText) | CTSFDataObject |
CTSFDataObject() | CTSFDataObject |
DAdvise(LPFORMATETC, DWORD, IAdviseSink *, LPDWORD) | CTSFDataObject |
DUnadvise(DWORD dwConnection) | CTSFDataObject |
EnumDAdvise(IEnumSTATDATA **ppEnumAdvise) | CTSFDataObject |
EnumFormatEtc(DWORD, IEnumFORMATETC **) | CTSFDataObject |
GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC) | CTSFDataObject |
GetData(LPFORMATETC, LPSTGMEDIUM) | CTSFDataObject |
GetDataHere(LPFORMATETC, LPSTGMEDIUM) | CTSFDataObject |
m_FormatEtc | CTSFDataObject | [private]
m_ObjRefCount | CTSFDataObject | [private]
m_pwszText | CTSFDataObject | [private]
QueryGetData(LPFORMATETC) | CTSFDataObject |
QueryInterface(REFIID, LPVOID FAR *) | CTSFDataObject |
SetData(LPFORMATETC, LPSTGMEDIUM, BOOL) | CTSFDataObject |
STDMETHODIMP_(DWORD) AddRef() | CTSFDataObject |
STDMETHODIMP_(DWORD) Release() | CTSFDataObject |
~CTSFDataObject() | CTSFDataObject |
Generated on Wed Nov 13 2024 16:57:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/PingResp/StdAfx.h Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • PingResp

StdAfx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: StdAfx.h
00004
00005 Summary:  Produced by VS6 ATL Wizard. Project's include file used to generate
00006           pre-compiled headers.
00007
00008 ----------------------------------------------------------------------------
00009
00010 This file is part of the Microsoft COM+ Samples.
00011
00012 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00013
00014 This source code is intended only as a supplement to Microsoft
00015 Development Tools and/or on-line documentation. See these other
00016 materials for detailed information regarding Microsoft code samples.
00017
00018 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00019 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00021 PARTICULAR PURPOSE.
00022
00023 ==========================================================================+*/
00024 // stdafx.h : include file for standard system include files,
00025 //      or project specific include files that are used frequently,
00026 //      but are changed infrequently
00027
00028 #if !defined(AFX_STDAFX_H__8C0B3D34_DB1F_11D2_8C2B_00A0C9F422B8__INCLUDED_)
00029 #define AFX_STDAFX_H__8C0B3D34_DB1F_11D2_8C2B_00A0C9F422B8__INCLUDED_
00030
00031 #if _MSC_VER > 1000
00032 #pragma once
00033 #endif // _MSC_VER > 1000
00034
00035 #define STRICT
00036 #ifndef _WIN32_WINNT
00037 #define _WIN32_WINNT 0x0500
00038 #endif
00039 #define _ATL_APARTMENT_THREADED
00040
00041 #include <atlbase.h>
00042 //You may derive a class from CComModule and use it if you want to override
00043 //something, but do not change the name of _Module
00044 extern CComModule _Module;
00045 #include <atlcom.h>
00046
00047 //{{AFX_INSERT_LOCATION}}
00048 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00049
00050 #endif // !defined(AFX_STDAFX_H__8C0B3D34_DB1F_11D2_8C2B_00A0C9F422B8__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllSkel/DllSkel.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllSkel

DllSkel.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DLLSKEL.H
00003
00004   Summary:   Include file for the DLLSKEL.DLL dynamic link library.  This
00005              include file is meant to serve double duty as providing
00006              general set of macros that (1) when included in a DLLSKEL
00007              implementation file wherein it provides a DLLENTRY
00008              designation for the definition of exported functions and (2)
00009              when included in an app that uses these function calls it
00010              provides a DLLENTRY designation for the declaration of
00011              imported functions.  The default behavior is to serve
00012              consumer apps that import the functions in the providing
00013              DLLSKEL.DLL.  Prior to the #include of this DLLSKEL.H if
00014              _DLLEXPORT_ is #defined, the bahavior is to serve the DLLSKEL
00015              itself in defining the functions as exported.
00016
00017              For a comprehensive tutorial code tour of DLLSKEL's contents
00018              and offerings see the tutorial DLLSKEL.HTM file. For more
00019              specific technical details on the internal workings see the
00020              comments dispersed throughout the DLLSKEL source code.
00021
00022   Classes:   none
00023
00024   Functions: none
00025
00026   Origin:    12-9-96: atrent - Revised.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 #if !defined(DLLSKEL_H)
00044 #define DLLSKEL_H
00045
00046 #if !defined(RC_INCLUDE)
00047
00048 #if !defined(_DLLEXPORT_)
00049
00050 // If _DLLEXPORT_ is not defined then the default is to import.
00051 #if defined(__cplusplus)
00052 #define DLLENTRY extern "C" __declspec(dllimport)
00053 #else
00054 #define DLLENTRY extern __declspec(dllimport)
00055 #endif
00056 #define STDENTRY DLLENTRY HRESULT WINAPI
00057 #define STDENTRY_(type) DLLENTRY type WINAPI
00058
00059 // Here is the list of service APIs offered by the DLL (using the
00060 // appropriate entry API declaration macros just #defined above).
00061 STDENTRY_(BOOL) DllHelloBox (HWND);
00062 STDENTRY_(BOOL) DllAboutBox (HWND);
00063
00064 #else  // _DLLEXPORT_
00065
00066 // Else if _DLLEXPORT_ is defined then we've been told to export.
00067 #if defined(__cplusplus)
00068 #define DLLENTRY extern "C" __declspec(dllexport)
00069 #else
00070 #define DLLENTRY __declspec(dllexport)
00071 #endif
00072 #define STDENTRY DLLENTRY HRESULT WINAPI
00073 #define STDENTRY_(type) DLLENTRY type WINAPI
00074
00075 #endif // _DLLEXPORT_
00076
00077 #endif // RC_INCLUDE
00078
00079 #endif // DLLSKEL_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Simple/StdAfx.h Source File

  • Web
  • iis
  • Components
  • Cpp
  • Simple

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005
00006 #include <atlbase.h>
00007 //You may derive a class from CComModule and use it if you want to override
00008 //something, but do not change the name of _Module
00009 extern CComModule _Module;
00010 #include <atlcom.h>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyAudit/Events.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyAudit

Events.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "ComSpyAudit.h"
00019 #ifndef DBNTWIN32
00020 #define DBNTWIN32
00021 #include <SQL.h>
00022 #include <SQLEXT.h>
00023 #include <ODBCINST.h>
00024 #endif // DBNTWIN32
00025 #include <ODBCINST.h>
00026 #include "ComSpySqlAudit.h"
00027
00028 #define SQL_EXEC(x)                         \
00029   {                               \
00030     RETCODE rc;                         \
00031     rc = SQLExecDirect(m_hstmt, x, lstrlen(x));         \
00032       if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO )    \
00033     {                             \
00034       CComBSTR msg;                     \
00035       GetError( m_henv, m_hdbc, m_hstmt, &msg.m_str);     \
00036       ATLTRACE(L"Warning! SQlExecDirec failed! Msg: ");   \
00037       ATLTRACE(msg.m_str);                  \
00038       ATLTRACE(L"\n");                    \
00039     }                             \
00040   }
00041
00042
00043
00044 long CComSpySqlAudit::PerfCountToTickCount(LONGLONG perfCount)
00045 {
00046   long TickCount = 0;
00047     if (m_PerformanceFrequency != 0)
00048         TickCount = (long)((1000 * perfCount) / m_PerformanceFrequency);
00049
00050   return TickCount;
00051 }
00052
00053
00054
00055
00056
00057 //////////////////////////Thread Events///////////////////////////////////
00058 STDMETHODIMP CComSpySqlAudit::OnThreadStart(
00059                 LONGLONG perfCount,
00060                 LPCOLESTR pszGuidApp,
00061         LPCOLESTR pszThreadID,
00062         LPCOLESTR pszW2KThreadID,
00063         DWORD dwThreadCnt)
00064 {
00065     long TickCount = PerfCountToTickCount(perfCount);
00066
00067   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00068   wsprintf(m_sSQL,
00069        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, W2KThreadID, ThreadCnt) values ('%s',%d,'%s','%s','%s', %d)",
00070        L"OnThreadStart",
00071        TickCount,
00072        pszGuidApp,
00073        pszThreadID,
00074        pszW2KThreadID,
00075        dwThreadCnt);
00076
00077   SQL_EXEC(m_sSQL);
00078   return S_OK;
00079 }
00080
00081
00082 STDMETHODIMP CComSpySqlAudit::OnThreadTerminate(
00083                 LONGLONG perfCount,
00084                 LPCOLESTR pszGuidApp,
00085         LPCOLESTR pszThreadID,
00086         LPCOLESTR pszW2KThreadID,
00087         DWORD dwThreadCnt
00088             )
00089 {
00090     long TickCount = PerfCountToTickCount(perfCount);
00091
00092   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00093   wsprintf(m_sSQL,
00094        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, W2KThreadID, ThreadCnt) values ('%s',%d,'%s','%s','%s', %d)",
00095        L"OnThreadTerminate",
00096        TickCount,
00097        pszGuidApp,
00098        pszThreadID,
00099        pszW2KThreadID,
00100        dwThreadCnt);
00101
00102
00103   SQL_EXEC(m_sSQL);
00104   return S_OK;
00105 }
00106
00107 STDMETHODIMP CComSpySqlAudit::OnThreadBindToApartment(
00108               LONGLONG perfCount,
00109               LPCOLESTR pszGuidApp,
00110               LPCOLESTR pszThreadID,
00111               LPCOLESTR pszAptID,
00112               DWORD dwActivityCnt)
00113 {
00114   long TickCount = PerfCountToTickCount(perfCount);
00115
00116   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00117   wsprintf(m_sSQL,
00118        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, ApartmentID, ActivityCnt) values ('%s', %d,'%s','%s','%s', %d)",
00119        L"OnThreadBindToApartment",
00120        TickCount,
00121        pszGuidApp,
00122        pszThreadID,
00123        pszAptID,
00124        dwActivityCnt);
00125
00126
00127   SQL_EXEC(m_sSQL);
00128   return S_OK;
00129 }
00130
00131
00132 STDMETHODIMP CComSpySqlAudit::OnThreadUnBind(
00133                LONGLONG perfCount,
00134                LPCOLESTR pszGuidApp,
00135                LPCOLESTR pszThreadID,
00136                LPCOLESTR pszAptID,
00137                DWORD dwActivityCnt
00138         )
00139 {
00140     long TickCount = PerfCountToTickCount(perfCount);
00141
00142   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00143   wsprintf(m_sSQL,
00144        L"insert into ThreadEvents (Event, TickCount, Application, Threadid, ApartmentID, ActivityCnt) values ('%s',%d,'%s','%s','%s', %d)",
00145        L"OnThreadUnBind",
00146        TickCount,
00147        pszGuidApp,
00148        pszThreadID,
00149        pszAptID,
00150        dwActivityCnt);
00151
00152   SQL_EXEC(m_sSQL);
00153   return S_OK;
00154 }
00155
00156
00157 STDMETHODIMP CComSpySqlAudit::OnThreadAssignApartment(
00158               LONGLONG perfCount,
00159               LPCOLESTR pszGuidApp,
00160               LPCOLESTR pszGuidActivityID,
00161               LPCOLESTR pszAptID  )
00162 {
00163   long TickCount = PerfCountToTickCount(perfCount);
00164
00165   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00166   wsprintf(m_sSQL,
00167        L"insert into ThreadEvents (Event, TickCount, Application, ActivityID, ApartmentID) values ('%s',%d,'%s','%s','%s')",
00168        L"OnThreadAssignApartment",
00169        TickCount,
00170        pszGuidApp,
00171        pszGuidActivityID,
00172        pszAptID);
00173
00174
00175   SQL_EXEC(m_sSQL);
00176   return S_OK;
00177 }
00178
00179
00180
00181 STDMETHODIMP CComSpySqlAudit::OnThreadUnassignApartment(
00182            LONGLONG perfCount,
00183            LPCOLESTR pszGuidApp,
00184            LPCOLESTR pszAptID )
00185 {
00186   long TickCount = PerfCountToTickCount(perfCount);
00187
00188   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00189   wsprintf(m_sSQL,
00190        L"insert into ThreadEvents (Event, TickCount, Application, ApartmentID) values ('%s', %d,'%s','%s')",
00191        L"OnThreadUnAssignApartment",
00192        TickCount,
00193        pszGuidApp,
00194        pszAptID);
00195
00196
00197   SQL_EXEC(m_sSQL);
00198   return S_OK;
00199 }
00200
00201
00202 STDMETHODIMP CComSpySqlAudit::OnThreadWorkEnque(
00203            LONGLONG perfCount,
00204            LPCOLESTR pszGuidApp,
00205            LPCOLESTR pszThreadID,
00206            LPCOLESTR MsgWorkID,
00207            DWORD dwQueueLen)
00208 {
00209   long TickCount = PerfCountToTickCount(perfCount);
00210
00211   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00212   wsprintf(m_sSQL,
00213        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, MsgWorkID,QueueLen) values ('%s', %d,'%s','%s','%s', %d)",
00214        L"OnThreadWorkEnque",
00215        TickCount,
00216        pszGuidApp,
00217        pszThreadID,
00218        MsgWorkID,
00219        dwQueueLen);
00220
00221
00222   SQL_EXEC(m_sSQL);
00223   return S_OK;
00224 }
00225
00226 STDMETHODIMP CComSpySqlAudit::OnThreadWorkPrivate(
00227            LONGLONG perfCount,
00228            LPCOLESTR pszGuidApp,
00229            LPCOLESTR pszThreadID,
00230            LPCOLESTR MsgWorkID)
00231 {
00232   long TickCount = PerfCountToTickCount(perfCount);
00233
00234   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00235   wsprintf(m_sSQL,
00236        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, MsgWorkID) values ('%s', %d, '%s','%s','%s')",
00237        L"OnThreadWorkPrivate",
00238        TickCount,
00239        pszGuidApp,
00240        pszThreadID,
00241        MsgWorkID);
00242
00243   SQL_EXEC(m_sSQL);
00244   return S_OK;
00245 }
00246
00247 STDMETHODIMP CComSpySqlAudit::OnThreadWorkPublic(
00248                LONGLONG perfCount,
00249                LPCOLESTR pszGuidApp,
00250                LPCOLESTR pszThreadID,
00251                LPCOLESTR MsgWorkID,
00252                DWORD dwQueueLen)
00253 {
00254   long TickCount = PerfCountToTickCount(perfCount);
00255
00256   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00257   wsprintf(m_sSQL,
00258        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, MsgWorkID,QueueLen) values ('%s', %d,'%s','%s','%s', %d)",
00259        L"OnThreadWorkPublic",
00260        TickCount,
00261        pszGuidApp,
00262        pszThreadID,
00263        MsgWorkID,
00264        dwQueueLen);
00265
00266
00267   SQL_EXEC(m_sSQL);
00268   return S_OK;
00269 }
00270
00271 STDMETHODIMP CComSpySqlAudit::OnThreadWorkRedirect(
00272               LONGLONG perfCount,
00273               LPCOLESTR pszGuidApp,
00274               LPCOLESTR pszThreadID,
00275               LPCOLESTR MsgWorkID,
00276               DWORD dwQueueLen,
00277               LPCOLESTR pszThreadNum)
00278 {
00279   long TickCount = PerfCountToTickCount(perfCount);
00280
00281   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00282   wsprintf(m_sSQL,
00283        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, MsgWorkID,QueueLen, ThreadNum) values ('%s',%d,'%s','%s','%s', %d, '%s')",
00284        L"OnThreadWorkPublic",
00285        TickCount,
00286        pszGuidApp,
00287        pszThreadID,
00288        MsgWorkID,
00289        dwQueueLen,
00290        pszThreadNum);
00291
00292
00293   SQL_EXEC(m_sSQL);
00294   return S_OK;
00295 }
00296
00297 STDMETHODIMP CComSpySqlAudit::OnThreadWorkReject(
00298                LONGLONG perfCount,
00299                LPCOLESTR pszGuidApp,
00300                LPCOLESTR pszThreadID,
00301                LPCOLESTR MsgWorkID,
00302                DWORD dwQueueLen)
00303 {
00304   long TickCount = PerfCountToTickCount(perfCount);
00305
00306   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00307   wsprintf(m_sSQL,
00308        L"insert into ThreadEvents (Event, TickCount, Application, ThreadID, MsgWorkID,QueueLen) values ('%s', %d,'%s','%s','%s', %d)",
00309        L"OnThreadWorkPublic",
00310        TickCount,
00311        pszGuidApp,
00312        pszThreadID,
00313        MsgWorkID,
00314        dwQueueLen);
00315
00316   SQL_EXEC(m_sSQL);
00317   return S_OK;
00318
00319 }
00320
00321 //////////////////////////Application Events///////////////////////////////////
00322 STDMETHODIMP CComSpySqlAudit::OnAppActivation(
00323                 LONGLONG perfCount,
00324                 LPCOLESTR pszGuidApp
00325             )
00326 {
00327    long TickCount = PerfCountToTickCount(perfCount);
00328
00329   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00330   wsprintf(m_sSQL,
00331        L"insert into AppEvents values ('%s',%d,'%s')",
00332        L"OnAppActivation",
00333        TickCount,
00334        pszGuidApp);
00335
00336   SQL_EXEC(m_sSQL);
00337   return S_OK;
00338 }
00339
00340 STDMETHODIMP CComSpySqlAudit::OnAppShutdown(
00341                 LONGLONG perfCount,
00342                 LPCOLESTR pszGuidApp
00343             )
00344 {
00345     long TickCount = PerfCountToTickCount(perfCount);
00346
00347   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00348   wsprintf(m_sSQL,
00349        L"insert into AppEvents values ('%s',%d,'%s')",
00350        L"OnAppShutdown",
00351        TickCount,
00352        pszGuidApp);
00353
00354   SQL_EXEC(m_sSQL);
00355   return S_OK;
00356 }
00357
00358 //////////////////////////Transaction Events///////////////////////////////////
00359 STDMETHODIMP CComSpySqlAudit::OnTransactionStart(
00360                 LONGLONG perfCount,
00361                 LPCOLESTR pszGuidApp,
00362                 LPCOLESTR pszGuidTxID,
00363                 LPCOLESTR pszGuidTSID,
00364         BOOL bRoot
00365             )
00366 {
00367     long TickCount = PerfCountToTickCount(perfCount);
00368
00369   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00370   wsprintf(m_sSQL,
00371        L"insert into TransactionEvents (Event,TickCount,Application, TransactionID, TSID, Root) \
00372         values ('%s',%d,'%s','%s','%s','%s' )",
00373        L"OnTransactionStart",
00374        TickCount,
00375        pszGuidApp,
00376        pszGuidTxID,
00377        pszGuidTSID,
00378        (bRoot ? L"Yes" : L"No")
00379        );
00380
00381   SQL_EXEC(m_sSQL);
00382   return S_OK;
00383 }
00384
00385 STDMETHODIMP CComSpySqlAudit::OnTransactionPrepared(
00386                 LONGLONG perfCount,
00387                 LPCOLESTR pszGuidApp,
00388                 LPCOLESTR pszGuidTxID,
00389         BOOL bVoteYes
00390             )
00391 {
00392     long TickCount = PerfCountToTickCount(perfCount);
00393
00394   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00395   wsprintf(m_sSQL,
00396        L"insert into TransactionEvents (Event,TickCount,Application, TransactionID, VoteYes) \
00397         values ('%s',%d,'%s','%s','%s' )",
00398        L"OnTransactionPrepared",
00399        TickCount,
00400        pszGuidApp,
00401        pszGuidTxID,
00402        (bVoteYes ? L"Yes" : L"No")
00403        );
00404
00405   SQL_EXEC(m_sSQL);
00406   return S_OK;
00407 }
00408
00409 STDMETHODIMP CComSpySqlAudit::OnTransactionCommit(
00410                 LONGLONG perfCount,
00411                 LPCOLESTR pszGuidApp,
00412         LPCOLESTR pszGuidTxID
00413             )
00414 {
00415     long TickCount = PerfCountToTickCount(perfCount);
00416
00417   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00418   wsprintf(m_sSQL,
00419        L"insert into TransactionEvents (Event,TickCount,Application, TransactionID) \
00420         values ('%s',%d,'%s','%s')",
00421        L"OnTransactionCommit",
00422        TickCount,
00423        pszGuidApp,
00424        pszGuidTxID
00425        );
00426
00427
00428   SQL_EXEC(m_sSQL);
00429   return S_OK;
00430 }
00431
00432
00433 STDMETHODIMP CComSpySqlAudit::OnTransactionAborted(
00434                 LONGLONG perfCount,
00435                 LPCOLESTR pszGuidApp,
00436         LPCOLESTR pszGuidTxID
00437             )
00438 {
00439     long TickCount = PerfCountToTickCount(perfCount);
00440
00441   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00442   wsprintf(m_sSQL,
00443        L"insert into TransactionEvents (Event,TickCount,Application, TransactionID) \
00444         values ('%s',%d,'%s','%s')",
00445        L"OnTransactionAborted",
00446        TickCount,
00447        pszGuidApp,
00448        pszGuidTxID
00449        );
00450
00451
00452   SQL_EXEC(m_sSQL);
00453   return S_OK;
00454 }
00455
00456
00457 //////////////////////////Method Events///////////////////////////////////
00458 STDMETHODIMP CComSpySqlAudit::OnMethodCall(
00459                 LONGLONG perfCount,
00460         LPCOLESTR pszGuidApp,
00461                 LPCOLESTR pszObjectID,
00462                 LPCOLESTR pszGuidClassID,
00463                 LPCOLESTR pszGuidInterfaceID,
00464                 LPCOLESTR pszMethod
00465             )
00466 {
00467     long TickCount = PerfCountToTickCount(perfCount);
00468
00469   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00470   wsprintf(m_sSQL,
00471        L"insert into MethodEvents (Event,TickCount, Application, ObjectID, ClassID, InterfaceID, Method) values('%s',%ld, '%s','%s', '%s', '%s', '%s')",
00472        L"OnMethodCall",
00473        TickCount,
00474        pszGuidApp,
00475        pszObjectID,
00476        pszGuidClassID,
00477        pszGuidInterfaceID,
00478        pszMethod
00479        );
00480
00481   ATLTRACE(L"OnMethodCall: m_sSQL = %s", m_sSQL);
00482   SQL_EXEC(m_sSQL);
00483   return S_OK;
00484 }
00485
00486 STDMETHODIMP CComSpySqlAudit::OnMethodReturn(
00487                 LONGLONG perfCount,
00488         LPCOLESTR pszGuidApp,
00489                 LPCOLESTR pszObjectID,
00490                 LPCOLESTR pszGuidClassID,
00491                 LPCOLESTR pszGuidInterfaceID,
00492                 LPCOLESTR pszMethod,
00493                 HRESULT hr,
00494         LPCOLESTR pszCallTime
00495             )
00496 {
00497     long TickCount = PerfCountToTickCount(perfCount);
00498
00499   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00500   wsprintf(m_sSQL,
00501        L"insert into MethodEvents  values ('%s', %d, '%s', '%s', '%s', '%s', '%s', %d, '%s')",
00502        L"OnMethodReturn",
00503        TickCount,
00504        pszGuidApp,
00505        pszObjectID,
00506        pszGuidClassID,
00507        pszGuidInterfaceID,
00508        pszMethod,
00509        hr,
00510        pszCallTime);
00511
00512   SQL_EXEC(m_sSQL);
00513   return S_OK;
00514 }
00515
00516 STDMETHODIMP CComSpySqlAudit::OnMethodException(
00517                 LONGLONG perfCount,
00518         LPCOLESTR pszGuidApp,
00519                 LPCOLESTR pszObjectID,
00520                 LPCOLESTR pszGuidClassID,
00521                 LPCOLESTR pszGuidInterfaceID,
00522                 LPCOLESTR pszMethod
00523             )
00524 {
00525     long TickCount = PerfCountToTickCount(perfCount);
00526
00527   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00528   wsprintf(m_sSQL,
00529        L"insert into MethodEvents (Event,TickCount, Application, ObjectID, ClassID, InterfaceID, Method) \
00530         values ('%s', %d, '%s', '%s', '%s', '%s', '%s')",
00531        L"OnMethodException",
00532        TickCount,
00533        pszGuidApp,
00534        pszObjectID,
00535        pszGuidClassID,
00536        pszGuidInterfaceID,
00537        pszMethod);
00538
00539   SQL_EXEC(m_sSQL);
00540   return S_OK;
00541 }
00542
00543
00544 //////////////////////////Object Construction Events///////////////////////////////////
00545 //share table with Object Events
00546 STDMETHODIMP CComSpySqlAudit::OnObjectConstruct(
00547        LONGLONG perfCount,
00548        LPCOLESTR pszGuidApp,
00549        LPCOLESTR pszClassID,
00550        LPCOLESTR pszConstructString,
00551        LPCOLESTR pszObjectID
00552     )
00553 {
00554   long TickCount = PerfCountToTickCount(perfCount);
00555
00556   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00557   wsprintf(m_sSQL,
00558        L"insert into ObjectEvents (Event,TickCount,Application, ClassID,ConstructString,ObjectID) \
00559         values ('%s', %d, '%s', '%s', '%s', '%s')",
00560        L"OnObjectConstruct",
00561        TickCount,
00562        pszGuidApp,
00563        pszClassID,
00564        pszConstructString,
00565        pszObjectID);
00566
00567   SQL_EXEC(m_sSQL);
00568
00569
00570   return S_OK;
00571 }
00572
00573 //////////////////////////Instance Events///////////////////////////////////
00574 //share table with Object Events
00575 STDMETHODIMP CComSpySqlAudit::OnObjectCreate(
00576               LONGLONG perfCount,
00577               LPCOLESTR pszGuidApp,
00578               LPCOLESTR pszGuidActivityID,
00579               LPCOLESTR pszClassID,
00580               LPCOLESTR pszTSID,
00581               LPCOLESTR pszContextID,
00582               LPCOLESTR pszObjectID)
00583 {
00584     long TickCount = PerfCountToTickCount(perfCount);
00585
00586   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00587
00588   wsprintf(m_sSQL,
00589        L"insert into ObjectEvents (Event, TickCount,Application, ActivityID, ClassID, TSID, ContextID,ObjectID) \
00590         values ('%s',%d, '%s', '%s', '%s', '%s', '%s', '%s')",
00591        L"OnObjectCreate",
00592        TickCount,
00593        pszGuidApp,
00594        pszGuidActivityID,
00595        pszClassID,
00596        pszTSID,
00597        pszContextID,
00598        pszObjectID);
00599
00600   SQL_EXEC(m_sSQL);
00601   return S_OK;
00602 }
00603
00604 STDMETHODIMP CComSpySqlAudit::OnObjectDestroy(
00605               LONGLONG perfCount,
00606               LPCOLESTR pszGuidApp,
00607               LPCOLESTR pszContextID
00608             )
00609 {
00610     long TickCount = PerfCountToTickCount(perfCount);
00611
00612   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00613
00614   wsprintf(m_sSQL,
00615        L"insert into ObjectEvents (Event,TickCount,Application,ContextID) \
00616         values ('%s',%d, '%s', '%s')",
00617        L"OnObjectDestroy",
00618        TickCount,
00619        pszGuidApp,
00620        pszContextID);
00621
00622   SQL_EXEC(m_sSQL);
00623
00624   return S_OK;
00625 }
00626
00627 //////////////////////////Object Events///////////////////////////////////
00628 STDMETHODIMP CComSpySqlAudit::OnObjectActivate(
00629         LONGLONG perfCount,
00630         LPCOLESTR pszGuidApp,
00631         LPCOLESTR pszContextID,
00632         LPCOLESTR pszObjectID
00633             )
00634 {
00635     long TickCount = PerfCountToTickCount(perfCount);
00636
00637   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00638   wsprintf(m_sSQL,
00639        L"insert into ObjectEvents (Event, TickCount,Application, ContextID,ObjectId) \
00640         values ('%s', %d,  '%s', '%s','%s')",
00641        L"OnObjectActivate",
00642        TickCount,
00643        pszGuidApp,
00644        pszContextID,
00645        pszObjectID);
00646
00647   SQL_EXEC(m_sSQL);
00648   return S_OK;
00649 }
00650
00651 STDMETHODIMP CComSpySqlAudit::OnObjectDeactivate(
00652                 LONGLONG perfCount,
00653         LPCOLESTR pszGuidApp,
00654         LPCOLESTR pszContextID,
00655         LPCOLESTR pszObjectID
00656             )
00657 {
00658     long TickCount = PerfCountToTickCount(perfCount);
00659
00660   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00661   wsprintf(m_sSQL,
00662        L"insert into ObjectEvents (Event, TickCount,Application, ContextID,ObjectId) \
00663         values ('%s', %d,  '%s', '%s','%s')",
00664        L"OnObjectDeactivate",
00665        TickCount,
00666        pszGuidApp,
00667        pszContextID,
00668        pszObjectID);
00669
00670   SQL_EXEC(m_sSQL);
00671
00672   return S_OK;
00673 }
00674
00675 STDMETHODIMP CComSpySqlAudit::OnDisableCommit(
00676                 LONGLONG perfCount,
00677         LPCOLESTR pszGuidApp,
00678         LPCOLESTR pszContextID
00679             )
00680 {
00681     long TickCount = PerfCountToTickCount(perfCount);
00682
00683   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00684   wsprintf(m_sSQL,
00685        L"insert into ObjectEvents (Event, TickCount,Application, ContextID) \
00686         values ('%s', %d,  '%s', '%s')",
00687        L"OnDisableCommit",
00688        TickCount,
00689        pszGuidApp,
00690        pszContextID);
00691
00692   SQL_EXEC(m_sSQL);
00693
00694
00695   return S_OK;
00696 }
00697
00698 STDMETHODIMP CComSpySqlAudit::OnEnableCommit(
00699                 LONGLONG perfCount,
00700         LPCOLESTR pszGuidApp,
00701         LPCOLESTR pszContextID
00702             )
00703 {
00704     long TickCount = PerfCountToTickCount(perfCount);
00705
00706   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00707   wsprintf(m_sSQL,
00708         L"insert into ObjectEvents (Event, TickCount,Application, ContextID) \
00709         values ('%s', %d,  '%s', '%s')",
00710        L"OnEnableCommit",
00711        TickCount,
00712        pszGuidApp,
00713        pszContextID);
00714
00715   SQL_EXEC(m_sSQL);
00716
00717
00718   return S_OK;
00719 }
00720
00721 STDMETHODIMP CComSpySqlAudit::OnSetComplete(
00722                 LONGLONG perfCount,
00723         LPCOLESTR pszGuidApp,
00724         LPCOLESTR pszContextID
00725             )
00726 {
00727     long TickCount = PerfCountToTickCount(perfCount);
00728
00729   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00730   wsprintf(m_sSQL,
00731        L"insert into ObjectEvents (Event, TickCount,Application, ContextID) \
00732         values ('%s', %d,  '%s', '%s')",
00733        L"OnSetComplete",
00734        TickCount,
00735        pszGuidApp,
00736        pszContextID);
00737
00738   SQL_EXEC(m_sSQL);
00739
00740
00741   return S_OK;
00742 }
00743
00744 STDMETHODIMP CComSpySqlAudit::OnSetAbort(
00745                 LONGLONG perfCount,
00746         LPCOLESTR pszGuidApp,
00747         LPCOLESTR pszContextID
00748             )
00749 {
00750     long TickCount = PerfCountToTickCount(perfCount);
00751
00752   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00753   wsprintf(m_sSQL,
00754        L"insert into ObjectEvents (Event, TickCount,Application, ContextID) \
00755         values ('%s', %d,  '%s', '%s')",
00756        L"OnSetAbort",
00757        TickCount,
00758        pszGuidApp,
00759        pszContextID);
00760
00761   SQL_EXEC(m_sSQL);
00762
00763
00764   return S_OK;
00765 }
00766
00767
00768 //////////////////////////Resource Events///////////////////////////////////
00769 STDMETHODIMP CComSpySqlAudit::OnResourceCreate(
00770           LONGLONG perfCount,
00771           LPCOLESTR pszGuidApp,
00772           LPCOLESTR pszObjectID,
00773           LPCOLESTR pszType,
00774           LPCOLESTR pszResId,
00775           BOOL bEnlisted
00776             )
00777 {
00778     long TickCount = PerfCountToTickCount(perfCount);
00779
00780   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00781   wsprintf(m_sSQL,
00782        L"insert into ResourceEvents (Event,TickCount,Application, ObjectID, Type, ResourceID, Enlisted) \
00783         values ('%s',%d, '%s', '%s', '%s', '%s', '%s')",
00784        L"OnResourceCreate",
00785        TickCount,
00786        pszGuidApp,
00787        pszObjectID,
00788        pszType,
00789        pszResId,
00790        (bEnlisted ? L"TRUE" : L"FALSE")
00791        );
00792
00793   SQL_EXEC(m_sSQL);
00794
00795   return S_OK;
00796 }
00797
00798 STDMETHODIMP CComSpySqlAudit::OnResourceAllocate(
00799                 LONGLONG perfCount,
00800         LPCOLESTR pszGuidApp,
00801                 LPCOLESTR pszObjectID,
00802                 LPCOLESTR pszType,
00803                 LPCOLESTR pszResId,
00804         BOOL bEnlisted,
00805         LPCOLESTR pszNumRated,
00806         LPCOLESTR pszRating
00807             )
00808 {
00809     long TickCount = PerfCountToTickCount(perfCount);
00810
00811   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00812   wsprintf(m_sSQL,
00813        L"insert into ResourceEvents (Event,TickCount,Application, ObjectID, Type, ResourceID, Enlisted, NumRated, Rating) \
00814         values ('%s',%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
00815        L"OnResourceAllocate",
00816        TickCount,
00817        pszGuidApp,
00818        pszObjectID,
00819        pszType,
00820        pszResId,
00821        bEnlisted ? L"TRUE" : L"FALSE",
00822        pszNumRated,
00823        pszRating
00824        );
00825
00826   SQL_EXEC(m_sSQL);
00827
00828   return S_OK;
00829 }
00830
00831 STDMETHODIMP CComSpySqlAudit::OnResourceRecycle(
00832                 LONGLONG perfCount,
00833                 LPCOLESTR pszGuidApp,
00834                 LPCOLESTR pszObjectID,
00835                 LPCOLESTR pszType,
00836         LPCOLESTR pszResId
00837             )
00838 {
00839     long TickCount = PerfCountToTickCount(perfCount);
00840
00841   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00842
00843   wsprintf(m_sSQL,
00844        L"insert into ResourceEvents (Event,TickCount,Application, ObjectID, Type, ResourceID) \
00845         values ('%s',%d, '%s', '%s', '%s', '%s')",
00846        L"OnResourceRecycle",
00847        TickCount,
00848        pszGuidApp,
00849        pszObjectID,
00850        pszType,
00851        pszResId
00852        );
00853
00854   SQL_EXEC(m_sSQL);
00855
00856   return S_OK;
00857 }
00858
00859 STDMETHODIMP CComSpySqlAudit::OnResourceDestroy(
00860                 LONGLONG perfCount,
00861                 LPCOLESTR pszGuidApp,
00862                 LPCOLESTR pszObjectID,
00863                 HRESULT hResult,
00864         LPCOLESTR pszType,
00865         LPCOLESTR pszResId
00866             )
00867 {
00868     long TickCount = PerfCountToTickCount(perfCount);
00869
00870   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00871
00872   wsprintf(m_sSQL,
00873        L"insert into ResourceEvents (Event,TickCount,Application,ObjectID, Type, ResourceID,HResult) \
00874         values ('%s',%d, '%s','%s', '%s', '%s', %d)",
00875        L"OnResourceDestroy",
00876        TickCount,
00877        pszGuidApp,
00878        pszObjectID,
00879        pszType,
00880        pszResId,
00881        hResult
00882        );
00883
00884   SQL_EXEC(m_sSQL);
00885
00886   return S_OK;
00887 }
00888
00889
00890 STDMETHODIMP CComSpySqlAudit::OnResourceTrack(
00891           LONGLONG perfCount,
00892           LPCOLESTR pszGuidApp,
00893           LPCOLESTR pszObjectID,
00894           LPCOLESTR pszType,
00895           LPCOLESTR pszResId,
00896           BOOL bEnlisted
00897             )
00898 {
00899     long TickCount = PerfCountToTickCount(perfCount);
00900
00901   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00902   wsprintf(m_sSQL,
00903        L"insert into ResourceEvents (Event,TickCount,Application, ObjectID, Type, ResourceID, Enlisted) \
00904         values ('%s',%d, '%s', '%s', '%s', '%s', '%s')",
00905        L"OnResourceTrack",
00906        TickCount,
00907        pszGuidApp,
00908        pszObjectID,
00909        pszType,
00910        pszResId,
00911        bEnlisted ? L"TRUE" : L"FALSE"
00912        );
00913
00914   SQL_EXEC(m_sSQL);
00915
00916   return S_OK;
00917 }
00918
00919 //////////////////////////Security Events///////////////////////////////////
00920 STDMETHODIMP CComSpySqlAudit::OnAuthenticate(
00921               LONGLONG perfCount,
00922           LPCOLESTR pszGuidApp,
00923           LPCOLESTR pszGuidActivity,
00924           LPCOLESTR pszObjectID,
00925           LPCOLESTR pszGuidIID,
00926           LPCOLESTR pszMethod,
00927           LPCOLESTR pszOriginalUser,
00928           LPCOLESTR pszDirectUser,
00929           BOOL bCurrentUserInpersonatingInProc
00930             )
00931 {
00932     long TickCount = PerfCountToTickCount(perfCount);
00933
00934   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00935   wsprintf(m_sSQL,
00936        L"insert into SecurityEvents (Event,TickCount,Application, ActivityID, ObjectID, InterfaceID, Method, OriginalUser, DirectUser,Impersonation) \
00937         values ('%s', %d, '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s')",
00938        L"OnAuthenticate",
00939        TickCount,
00940        pszGuidApp,
00941        pszGuidActivity,
00942        pszObjectID,
00943        pszGuidIID,
00944        pszMethod,
00945        pszOriginalUser,
00946        pszDirectUser,
00947        (bCurrentUserInpersonatingInProc ? L"Yes" : L"NO"));
00948
00949
00950   ATLTRACE(L"OnAuthenticate: m_sSQL = %s\n", m_sSQL);
00951
00952
00953   SQL_EXEC(m_sSQL);
00954   return S_OK;
00955 }
00956
00957 STDMETHODIMP CComSpySqlAudit::OnAuthenticateFail(
00958               LONGLONG perfCount,
00959           LPCOLESTR pszGuidApp,
00960           LPCOLESTR pszGuidActivity,
00961           LPCOLESTR pszObjectID,
00962           LPCOLESTR pszGuidIID,
00963           LPCOLESTR pszMethod,
00964           LPCOLESTR pszOriginalUser,
00965           LPCOLESTR pszDirectUser,
00966           BOOL bCurrentUserInpersonatingInProc
00967             )
00968 {
00969     long TickCount = PerfCountToTickCount(perfCount);
00970
00971   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
00972   wsprintf(m_sSQL,
00973        L"insert into SecurityEvents (Event,TickCount,Application, ActivityID, ObjectID, InterfaceID, Method, OriginalUser, DirectUser,Impersonation) \
00974         values ('%s', %d, '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s')",
00975        L"OnAuthenticateFail",
00976        TickCount,
00977        pszGuidApp,
00978        pszGuidActivity,
00979        pszObjectID,
00980        pszGuidIID,
00981        pszMethod,
00982        pszOriginalUser,
00983        pszDirectUser,
00984        (bCurrentUserInpersonatingInProc ? L"Yes" : L"NO"));
00985
00986   SQL_EXEC(m_sSQL);
00987   return S_OK;
00988 }
00989
00990 //////////////////////////Identity Events///////////////////////////////////
00991 //Share table security events
00992 STDMETHODIMP CComSpySqlAudit::OnIISRequestInfo(
00993        LONGLONG perfCount,
00994        LPCOLESTR pszGuidApp,
00995        LPCOLESTR pszObjectID,
00996        LPCOLESTR pszClientIP,
00997        LPCOLESTR pszServerIP,
00998        LPCOLESTR pszURL
00999     )
01000 {
01001   long TickCount = PerfCountToTickCount(perfCount);
01002
01003   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01004   wsprintf(m_sSQL,
01005        L"insert into SecurityEvents (Event,TickCount,Application, ObjectID,ClientIP, ServerIP, URL) \
01006         values ('%s',%d, '%s', '%s','%s','%s','%s')",
01007        L"OnIISRequestInfo",
01008        TickCount,
01009        pszGuidApp,
01010        pszObjectID,
01011        pszClientIP,
01012        pszServerIP,
01013        pszURL
01014        );
01015   SQL_EXEC(m_sSQL);
01016
01017   return S_OK;
01018 }
01019
01020 //////////////////////////Object Pool Events///////////////////////////////////
01021 STDMETHODIMP CComSpySqlAudit::OnObjPoolPutObject(
01022               LONGLONG perfCount,
01023               LPCOLESTR pszGuidApp,
01024               LPCOLESTR pszClassID,
01025               int nReason,
01026               DWORD dwAvailableObjs,
01027               LPCOLESTR pszObjectID)
01028 {
01029   long TickCount = PerfCountToTickCount(perfCount);
01030
01031   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01032   wsprintf(m_sSQL,
01033        L"insert into ObjectPoolEvents (Event,TickCount,Application, ClassID, Reason, AvailableObjs, ObjectID) \
01034         values ('%s',%d, '%s', '%s', %d, %d, '%s')",
01035        L"OnObjPoolPutObject",
01036        TickCount,
01037        pszGuidApp,
01038        pszClassID,
01039        nReason,
01040        dwAvailableObjs,
01041        pszObjectID
01042        );
01043
01044   SQL_EXEC(m_sSQL);
01045
01046   return S_OK;
01047
01048 }
01049
01050 STDMETHODIMP CComSpySqlAudit::OnObjPoolGetObject(
01051        LONGLONG perfCount,
01052        LPCOLESTR pszGuidApp,
01053        LPCOLESTR pszGuidActivityID,
01054        LPCOLESTR pszClassID,
01055        DWORD dwAvailableObjs,
01056        LPCOLESTR pszObjectID)
01057 {
01058   long TickCount = PerfCountToTickCount(perfCount);
01059
01060   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01061   wsprintf(m_sSQL,
01062        L"insert into ObjectPoolEvents (Event,TickCount,Application, ActivityID, ClassID, AvailableObjs, ObjectID) \
01063         values ('%s',%d, '%s', '%s', '%s', %d, '%s')",
01064        L"OnObjPoolGetObject",
01065        TickCount,
01066        pszGuidApp,
01067        pszGuidActivityID,
01068        pszClassID,
01069        dwAvailableObjs,
01070        pszObjectID
01071        );
01072
01073   SQL_EXEC(m_sSQL);
01074
01075   return S_OK;
01076
01077 }
01078
01079 STDMETHODIMP CComSpySqlAudit::OnObjPoolRecycleToTx(
01080        LONGLONG perfCount,
01081        LPCOLESTR pszGuidApp,
01082        LPCOLESTR pszGuidActivityID,
01083        LPCOLESTR pszClassID,
01084        LPCOLESTR pszGuidTx,
01085        LPCOLESTR pszObjectID)
01086 {
01087   long TickCount = PerfCountToTickCount(perfCount);
01088
01089   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01090   wsprintf(m_sSQL,
01091        L"insert into ObjectPoolEvents (Event,TickCount,Application, ActivityID, ClassID, TransactionID, ObjectID) \
01092         values ('%s',%d, '%s', '%s', '%s', '%s', '%s')",
01093        L"OnObjPoolRecycleToTx",
01094        TickCount,
01095        pszGuidApp,
01096        pszGuidActivityID,
01097        pszClassID,
01098        pszGuidTx,
01099        pszObjectID
01100        );
01101
01102   SQL_EXEC(m_sSQL);
01103
01104   return S_OK;
01105 }
01106
01107 STDMETHODIMP CComSpySqlAudit::OnObjPoolGetFromTx(
01108        LONGLONG perfCount,
01109        LPCOLESTR pszGuidApp,
01110        LPCOLESTR pszGuidActivityID,
01111        LPCOLESTR pszClassID,
01112        LPCOLESTR pszGuidTx,
01113        LPCOLESTR pszObjectID)
01114 {
01115   long TickCount = PerfCountToTickCount(perfCount);
01116
01117   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01118   wsprintf(m_sSQL,
01119        L"insert into ObjectPoolEvents (Event,TickCount,Application, ActivityID, ClassID, TransactionID, ObjectID) \
01120         values ('%s',%d, '%s', '%s', '%s', '%s', '%s')",
01121        L"OnObjPoolGetFromTx",
01122        TickCount,
01123        pszGuidApp,
01124        pszGuidActivityID,
01125        pszClassID,
01126        pszGuidTx,
01127        pszObjectID
01128        );
01129
01130   SQL_EXEC(m_sSQL);
01131
01132   return S_OK;
01133
01134 }
01135
01136 //////////////////////////Object Pool Events 2///////////////////////////////////
01137 //Share table with Object Pool
01138 STDMETHODIMP CComSpySqlAudit::OnObjPoolCreateObject(
01139        LONGLONG perfCount,
01140        LPCOLESTR pszGuidApp,
01141        LPCOLESTR pszClassID,
01142        DWORD dwAvailableObjs,
01143        LPCOLESTR pszObjectID)
01144 {
01145   long TickCount = PerfCountToTickCount(perfCount);
01146
01147   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01148   wsprintf(m_sSQL,
01149        L"insert into ObjectPoolEvents (Event,TickCount,Application, ClassID,AvailableObjs, ObjectID) \
01150         values ('%s',%d, '%s', '%s', %d, '%s')",
01151        L"OnObjPoolCreateObject",
01152        TickCount,
01153        pszGuidApp,
01154        pszClassID,
01155        dwAvailableObjs,
01156        pszObjectID
01157        );
01158
01159   SQL_EXEC(m_sSQL);
01160
01161   return S_OK;
01162
01163 }
01164
01165 STDMETHODIMP CComSpySqlAudit::OnObjPoolDestroyObject(
01166        LONGLONG perfCount,
01167        LPCOLESTR pszGuidApp,
01168        LPCOLESTR pszClassID,
01169        DWORD dwAvailableObjs,
01170        LPCOLESTR pszObjectID)
01171 {
01172   long TickCount = PerfCountToTickCount(perfCount);
01173
01174   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01175   wsprintf(m_sSQL,
01176        L"insert into ObjectPoolEvents (Event,TickCount,Application, ActivityID, ClassID, TransactionID, ObjectID) \
01177         values ('%s',%d, '%s', '%s', %d, '%s')",
01178        L"OnObjPoolDestroyObject",
01179        TickCount,
01180        pszGuidApp,
01181        pszClassID,
01182        dwAvailableObjs,
01183        pszObjectID
01184        );
01185
01186   SQL_EXEC(m_sSQL);
01187
01188   return S_OK;
01189
01190 }
01191
01192 STDMETHODIMP CComSpySqlAudit::OnObjPoolCreateDecision(
01193        LONGLONG perfCount,
01194        LPCOLESTR pszGuidApp,
01195        DWORD dwThreadsWaiting,
01196        DWORD dwAvailableObjs,
01197        DWORD dwCreatedObjs,
01198        DWORD dwMin,
01199        DWORD dwMax)
01200 {
01201   long TickCount = PerfCountToTickCount(perfCount);
01202
01203   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01204   wsprintf(m_sSQL,
01205        L"insert into ObjectPoolEvents (Event,TickCount,Application, ThreadsWaiting, AvailableObjs, CreatedObjs, Min, Max) \
01206         values ('%s',%d, '%s', %d, %d, %d, %d, %d)",
01207        L"OnObjPoolCreateDecision",
01208        TickCount,
01209        pszGuidApp,
01210        dwThreadsWaiting,
01211        dwAvailableObjs,
01212        dwCreatedObjs,
01213        dwMin,
01214        dwMax
01215        );
01216
01217   SQL_EXEC(m_sSQL);
01218
01219   return S_OK;
01220
01221 }
01222
01223 STDMETHODIMP CComSpySqlAudit::OnObjPoolTimeout(
01224        LONGLONG perfCount,
01225        LPCOLESTR pszGuidApp,
01226        LPCOLESTR pszClassID,
01227        LPCOLESTR pszGuidActivityID,
01228        DWORD dwTimeout)
01229 {
01230   long TickCount = PerfCountToTickCount(perfCount);
01231
01232   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01233   wsprintf(m_sSQL,
01234        L"insert into ObjectPoolEvents (Event,TickCount,Application, ClassID, ActivityID,Timeout) \
01235         values ('%s',%d, '%s', '%s', '%s',%d)",
01236        L"OnObjPoolTimeout",
01237        TickCount,
01238        pszGuidApp,
01239        pszClassID,
01240        pszGuidActivityID,
01241        dwTimeout
01242        );
01243
01244   SQL_EXEC(m_sSQL);
01245
01246   return S_OK;
01247
01248 }
01249
01250 STDMETHODIMP CComSpySqlAudit::OnObjPoolCreatePool(
01251        LONGLONG perfCount,
01252        LPCOLESTR pszGuidApp,
01253        LPCOLESTR pszClassID,
01254        DWORD dwMin,
01255        DWORD dwMax,
01256        DWORD dwTimeout)
01257 {
01258   long TickCount = PerfCountToTickCount(perfCount);
01259
01260   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01261   wsprintf(m_sSQL,
01262        L"insert into ObjectPoolEvents (Event,TickCount,Application, ClassID, Min, Max, Timeout) \
01263         values ('%s',%d, '%s', '%s', %d, %d, %d)",
01264        L"OnObjPoolCreatePool",
01265        TickCount,
01266        pszGuidApp,
01267        pszClassID,
01268        dwMin,
01269        dwMax,
01270        dwTimeout
01271        );
01272
01273   SQL_EXEC(m_sSQL);
01274
01275   return S_OK;
01276
01277 }
01278
01279
01280 //////////////////////////Activity Events///////////////////////////////////
01281 STDMETHODIMP CComSpySqlAudit::OnActivityCreate(
01282        LONGLONG perfCount,
01283        LPCOLESTR pszGuidApp,
01284        LPCOLESTR pszGuidActivityID
01285     )
01286 {
01287   long TickCount = PerfCountToTickCount(perfCount);
01288
01289   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01290   wsprintf(m_sSQL,
01291        L"insert into ActivityEvents (Event,TickCount,Application, ActivityID) \
01292         values ('%s',%d, '%s', '%s')",
01293        L"OnActivityCreate",
01294        TickCount,
01295        pszGuidApp,
01296        pszGuidActivityID
01297        );
01298
01299   SQL_EXEC(m_sSQL);
01300
01301   return S_OK;
01302
01303 }
01304
01305 STDMETHODIMP CComSpySqlAudit::OnActivityDestroy(
01306        LONGLONG perfCount,
01307        LPCOLESTR pszGuidApp,
01308        LPCOLESTR pszGuidActivityID
01309     )
01310 {
01311   long TickCount = PerfCountToTickCount(perfCount);
01312
01313   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01314   wsprintf(m_sSQL,
01315        L"insert into ActivityEvents (Event,TickCount,Application, ActivityID) \
01316         values ('%s',%d, '%s', '%s')",
01317        L"OnActivityDestroy",
01318        TickCount,
01319        pszGuidApp,
01320        pszGuidActivityID
01321        );
01322
01323   SQL_EXEC(m_sSQL);
01324
01325   return S_OK;
01326 }
01327
01328 STDMETHODIMP CComSpySqlAudit::OnActivityEnter(
01329        LONGLONG perfCount,
01330        LPCOLESTR pszGuidApp,
01331        LPCOLESTR pszGuidCurrentApp,
01332        LPCOLESTR pszGuidEnteredApp,
01333        LPCOLESTR pszW2KThreadID
01334     )
01335 {
01336   long TickCount = PerfCountToTickCount(perfCount);
01337
01338   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01339   wsprintf(m_sSQL,
01340        L"insert into ActivityEvents (Event,TickCount,Application, CurrentApp, EnteredApp,W2KThreadID) \
01341         values ('%s',%d, '%s', '%s','%s', '%s')",
01342        L"OnActivityEnter",
01343        TickCount,
01344        pszGuidApp,
01345        pszGuidCurrentApp,
01346        pszGuidEnteredApp,
01347        pszW2KThreadID
01348        );
01349
01350   SQL_EXEC(m_sSQL);
01351
01352   return S_OK;
01353 }
01354
01355
01356 STDMETHODIMP CComSpySqlAudit::OnActivityTimeout(
01357        LONGLONG perfCount,
01358        LPCOLESTR pszGuidApp,
01359        LPCOLESTR pszGuidCurrentApp,
01360        LPCOLESTR pszGuidEnteredApp,
01361        LPCOLESTR pszW2KThreadID,
01362        DWORD dwTimeout
01363     )
01364 {
01365   long TickCount = PerfCountToTickCount(perfCount);
01366
01367   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01368   wsprintf(m_sSQL,
01369        L"insert into ActivityEvents (Event,TickCount,Application, CurrentApp, EnteredApp,W2KThreadID,Timeout) \
01370         values ('%s',%d, '%s', '%s','%s', '%s',%d)",
01371        L"OnActivityTimeout",
01372        TickCount,
01373        pszGuidApp,
01374        pszGuidCurrentApp,
01375        pszGuidEnteredApp,
01376        pszW2KThreadID,
01377        dwTimeout
01378        );
01379
01380   SQL_EXEC(m_sSQL);
01381
01382   return S_OK;
01383 }
01384
01385 STDMETHODIMP CComSpySqlAudit::OnActivityReenter(
01386        LONGLONG perfCount,
01387        LPCOLESTR pszGuidApp,
01388        LPCOLESTR pszGuidCurrentApp,
01389        LPCOLESTR pszW2KThreadID,
01390        DWORD dwCallDepth
01391     )
01392 {
01393   long TickCount = PerfCountToTickCount(perfCount);
01394
01395   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01396   wsprintf(m_sSQL,
01397        L"insert into ActivityEvents (Event,TickCount,Application, CurrentApp, W2KThreadID,CallDepth) \
01398         values ('%s',%d, '%s', '%s','%s',%d)",
01399        L"OnActivityReenter",
01400        TickCount,
01401        pszGuidApp,
01402        pszGuidCurrentApp,
01403        pszW2KThreadID,
01404        dwCallDepth
01405        );
01406
01407   SQL_EXEC(m_sSQL);
01408
01409   return S_OK;
01410 }
01411
01412 STDMETHODIMP CComSpySqlAudit::OnActivityLeave(
01413        LONGLONG perfCount,
01414        LPCOLESTR pszGuidApp,
01415        LPCOLESTR pszGuidCurrentApp,
01416        LPCOLESTR pszGuidLeftApp
01417     )
01418 {
01419   long TickCount = PerfCountToTickCount(perfCount);
01420
01421   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01422   wsprintf(m_sSQL,
01423        L"insert into ActivityEvents (Event,TickCount,Application, CurrentApp, LeftApp) \
01424         values ('%s',%d, '%s', '%s','%s')",
01425        L"OnActivityLeave",
01426        TickCount,
01427        pszGuidApp,
01428        pszGuidCurrentApp,
01429        pszGuidLeftApp
01430        );
01431
01432   SQL_EXEC(m_sSQL);
01433
01434   return S_OK;
01435 }
01436
01437 STDMETHODIMP CComSpySqlAudit::OnActivityLeaveSame(
01438        LONGLONG perfCount,
01439        LPCOLESTR pszGuidApp,
01440        LPCOLESTR pszGuidCurrentApp,
01441        DWORD dwCallDepth
01442     )
01443 {
01444   long TickCount = PerfCountToTickCount(perfCount);
01445
01446   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01447   wsprintf(m_sSQL,
01448        L"insert into ActivityEvents (Event,TickCount,Application, CurrentApp,CallDepth) \
01449         values ('%s',%d, '%s', '%s',%d)",
01450        L"OnActivityLeaveSame",
01451        TickCount,
01452        pszGuidApp,
01453        pszGuidCurrentApp,
01454        dwCallDepth
01455        );
01456
01457   SQL_EXEC(m_sSQL);
01458
01459   return S_OK;
01460 }
01461
01462
01463
01464 //////////////////////////Queued Components Events///////////////////////////////////
01465 STDMETHODIMP CComSpySqlAudit::OnQCRecord(
01466        LONGLONG perfCount,
01467        LPCOLESTR pszGuidApp,
01468        LPCOLESTR pszObjectID,
01469        LPCOLESTR pszQueueName,
01470        LPCOLESTR pszGuidMsgID,
01471        LPCOLESTR pszGuidWorkFlowID,
01472        HRESULT hr
01473     )
01474 {
01475   long TickCount = PerfCountToTickCount(perfCount);
01476
01477   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01478   wsprintf(m_sSQL,
01479        L"insert into QCEvents (Event,TickCount,Application, ObjectID,QueueName, MsgID, WorkFlowID, HResult) \
01480         values ('%s',%d, '%s', '%s','%s','%s','%s',%d)",
01481        L"OnQCRecord",
01482        TickCount,
01483        pszGuidApp,
01484        pszObjectID,
01485        pszQueueName,
01486        pszGuidMsgID,
01487        pszGuidWorkFlowID,
01488        hr
01489        );
01490
01491   SQL_EXEC(m_sSQL);
01492
01493   return S_OK;
01494 }
01495 STDMETHODIMP CComSpySqlAudit::OnQCQueueOpen(
01496        LONGLONG perfCount,
01497        LPCOLESTR pszGuidApp,
01498        LPCOLESTR pszQueueName,
01499        LPCOLESTR pszQueueID,
01500        HRESULT hr
01501     )
01502 {
01503   long TickCount = PerfCountToTickCount(perfCount);
01504
01505   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01506   wsprintf(m_sSQL,
01507        L"insert into QCEvents (Event,TickCount,Application, QueueName, QueueID, HResult) \
01508         values ('%s',%d, '%s', '%s','%s', %d)",
01509        L"OnQCQueueOpen",
01510        TickCount,
01511        pszGuidApp,
01512        pszQueueName,
01513        pszQueueID,
01514        hr
01515        );
01516
01517   SQL_EXEC(m_sSQL);
01518
01519   return S_OK;
01520 }
01521
01522 STDMETHODIMP CComSpySqlAudit::OnQCReceive(
01523        LONGLONG perfCount,
01524        LPCOLESTR pszGuidApp,
01525        LPCOLESTR pszQueueID,
01526        LPCOLESTR pszGuidMsgID,
01527        LPCOLESTR pszGuidWorkFlowID,
01528        HRESULT hr
01529     )
01530 {
01531   long TickCount = PerfCountToTickCount(perfCount);
01532
01533   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01534   wsprintf(m_sSQL,
01535        L"insert into QCEvents (Event,TickCount,Application, QueueID, MsgID, WrokFlowID, HResult) \
01536         values ('%s',%d, '%s', '%s','%s','%s', %d)",
01537        L"OnQCReceive",
01538        TickCount,
01539        pszGuidApp,
01540        pszQueueID,
01541        pszGuidMsgID,
01542        pszGuidWorkFlowID,
01543        hr
01544        );
01545
01546   SQL_EXEC(m_sSQL);
01547
01548   return S_OK;
01549 }
01550
01551 STDMETHODIMP CComSpySqlAudit::OnQCReceiveFail(
01552        LONGLONG perfCount,
01553        LPCOLESTR pszGuidApp,
01554        LPCOLESTR pszQueueID,
01555        HRESULT hr
01556     )
01557 {
01558   long TickCount = PerfCountToTickCount(perfCount);
01559
01560   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01561   wsprintf(m_sSQL,
01562        L"insert into QCEvents (Event,TickCount,Application, QueueID, HResult) \
01563         values ('%s',%d, '%s', '%s', %d)",
01564        L"OnQCReceiveFail",
01565        TickCount,
01566        pszGuidApp,
01567        pszQueueID,
01568        hr
01569        );
01570   SQL_EXEC(m_sSQL);
01571
01572   return S_OK;
01573 }
01574
01575 STDMETHODIMP CComSpySqlAudit::OnQCMoveToReTryQueue(
01576        LONGLONG perfCount,
01577        LPCOLESTR pszGuidApp,
01578        LPCOLESTR pszGuidMsgID,
01579        LPCOLESTR pszGuidWorkFlowID,
01580        ULONG RetryIndex
01581     )
01582 {
01583
01584   long TickCount = PerfCountToTickCount(perfCount);
01585
01586   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01587   wsprintf(m_sSQL,
01588        L"insert into QCEvents (Event,TickCount,Application, MsgID, WorkFlowID, RetryIndex) \
01589         values ('%s',%d, '%s', '%s', '%s',%d)",
01590        L"OnQCMoveToReTryQueue",
01591        TickCount,
01592        pszGuidApp,
01593        pszGuidMsgID,
01594        pszGuidWorkFlowID,
01595        RetryIndex
01596        );
01597
01598   SQL_EXEC(m_sSQL);
01599
01600   return S_OK;
01601 }
01602
01603 STDMETHODIMP CComSpySqlAudit::OnQCMoveToDeadQueue(
01604        LONGLONG perfCount,
01605        LPCOLESTR pszGuidApp,
01606        LPCOLESTR pszGuidMsgID,
01607        LPCOLESTR pszGuidWorkFlowID
01608     )
01609 {
01610
01611   long TickCount = PerfCountToTickCount(perfCount);
01612
01613   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01614   wsprintf(m_sSQL,
01615        L"insert into QCEvents (Event,TickCount,Application, MsgID, WorkFlowID) \
01616         values ('%s',%d, '%s', '%s', '%s')",
01617        L"OnQCMoveToDeadQueue",
01618        TickCount,
01619        pszGuidApp,
01620        pszGuidMsgID,
01621        pszGuidWorkFlowID
01622        );
01623
01624   SQL_EXEC(m_sSQL);
01625
01626   return S_OK;
01627 }
01628
01629 STDMETHODIMP CComSpySqlAudit::OnQCPlayback(
01630        LONGLONG perfCount,
01631        LPCOLESTR pszGuidApp,
01632        LPCOLESTR pszObjectID,
01633        LPCOLESTR pszGuidMsgID,
01634        LPCOLESTR pszGuidWorkFlowID,
01635        HRESULT hr
01636     )
01637 {
01638   long TickCount = PerfCountToTickCount(perfCount);
01639
01640   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01641   wsprintf(m_sSQL,
01642        L"insert into QCEvents (Event,TickCount,Application, ObjectID, MsgID, WorkFlowID, HResult) \
01643         values ('%s',%d, '%s', '%s', '%s','%s',%d)",
01644        L"OnQCMoveToDeadQueue",
01645        TickCount,
01646        pszGuidApp,
01647        pszObjectID,
01648        pszGuidMsgID,
01649        pszGuidWorkFlowID,
01650        hr
01651        );
01652
01653   SQL_EXEC(m_sSQL);
01654
01655   return S_OK;
01656 }
01657
01658 //////////////////////////Exception Events///////////////////////////////////
01659 STDMETHODIMP CComSpySqlAudit::OnExceptionUser(
01660        LONGLONG perfCount,
01661        LPCOLESTR pszGuidApp,
01662        LPCOLESTR pszCode,
01663        LPCOLESTR pszAddress,
01664        LPCOLESTR pszStackTrace
01665     )
01666 {
01667   long TickCount = PerfCountToTickCount(perfCount);
01668
01669   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01670   wsprintf(m_sSQL,
01671        L"insert into ExceptionEvents (Event,TickCount,Application, Code,Address,StackTrace) \
01672         values ('%s',%d, '%s', '%s','%s','%s')",
01673        L"OnExceptionUser",
01674        TickCount,
01675        pszGuidApp,
01676        pszCode,
01677        pszAddress,
01678        pszStackTrace
01679        );
01680
01681   SQL_EXEC(m_sSQL);
01682
01683   return S_OK;
01684 }
01685
01686 //////////////////////////CRM Events///////////////////////////////////
01687 STDMETHODIMP CComSpySqlAudit::OnCRMRecoveryStart(
01688        LONGLONG perfCount,
01689        LPCOLESTR pszGuidApp
01690     )
01691 {
01692
01693   long TickCount = PerfCountToTickCount(perfCount);
01694
01695   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01696   wsprintf(m_sSQL,
01697        L"insert into CRMEvents (Event,TickCount,Application) \
01698         values ('%s',%d, '%s')",
01699        L"OnCRMRecoveryStart",
01700        TickCount,
01701        pszGuidApp
01702        );
01703
01704   SQL_EXEC(m_sSQL);
01705
01706   return S_OK;
01707 }
01708
01709 STDMETHODIMP CComSpySqlAudit::OnCRMRecoveryDone(
01710        LONGLONG perfCount,
01711        LPCOLESTR pszGuidApp
01712     )
01713 {
01714   long TickCount = PerfCountToTickCount(perfCount);
01715
01716   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01717   wsprintf(m_sSQL,
01718        L"insert into CRMEvents (Event,TickCount,Application) \
01719         values ('%s',%d, '%s')",
01720        L"OnCRMRecoveryDone",
01721        TickCount,
01722        pszGuidApp
01723        );
01724
01725   SQL_EXEC(m_sSQL);
01726
01727   return S_OK;
01728 }
01729
01730 STDMETHODIMP CComSpySqlAudit::OnCRMCheckpoint(
01731        LONGLONG perfCount,
01732        LPCOLESTR pszGuidApp
01733     )
01734 {
01735   long TickCount = PerfCountToTickCount(perfCount);
01736
01737   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01738   wsprintf(m_sSQL,
01739        L"insert into CRMEvents (Event,TickCount,Application) \
01740         values ('%s',%d, '%s')",
01741        L"OnCRMCheckpoint",
01742        TickCount,
01743        pszGuidApp
01744        );
01745
01746   SQL_EXEC(m_sSQL);
01747
01748   return S_OK;
01749 }
01750
01751 STDMETHODIMP CComSpySqlAudit::OnCRMBegin(
01752        LONGLONG perfCount,
01753        LPCOLESTR pszGuidApp,
01754        LPCOLESTR pszGuidClerkCLSID,
01755        LPCOLESTR pszGuidActivityID,
01756        LPCOLESTR pszGuidTxUOWID,
01757        LPCOLESTR pszProgIdCompensator,
01758        LPCOLESTR pszDescription
01759     )
01760 {
01761   long TickCount = PerfCountToTickCount(perfCount);
01762
01763   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01764   wsprintf(m_sSQL,
01765        L"insert into CRMEvents (Event,TickCount,Application, ClerkID, ActivityID,TransactionUOWID,ProgIdCompensator,Description ) \
01766         values ('%s',%d, '%s','%s','%s','%s','%s','%s')",
01767          L"OnCRMBegin",
01768          TickCount,
01769          pszGuidApp,
01770          pszGuidClerkCLSID,
01771          pszGuidActivityID,
01772          pszGuidTxUOWID,
01773          pszProgIdCompensator,
01774          pszDescription
01775            );
01776
01777   SQL_EXEC(m_sSQL);
01778
01779   return S_OK;
01780 }
01781
01782 STDMETHODIMP CComSpySqlAudit::OnCRMPrepare(
01783        LONGLONG perfCount,
01784        LPCOLESTR pszGuidApp,
01785        LPCOLESTR pszGuidClerkCLSID
01786     )
01787 {
01788
01789   long TickCount = PerfCountToTickCount(perfCount);
01790
01791   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01792   wsprintf(m_sSQL,
01793        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01794         values ('%s',%d, '%s','%s')",
01795          L"OnCRMPrepare",
01796          TickCount,
01797          pszGuidApp,
01798          pszGuidClerkCLSID
01799            );
01800
01801   SQL_EXEC(m_sSQL);
01802
01803   return S_OK;
01804 }
01805
01806 STDMETHODIMP CComSpySqlAudit::OnCRMCommit(
01807        LONGLONG perfCount,
01808        LPCOLESTR pszGuidApp,
01809        LPCOLESTR pszGuidClerkCLSID
01810     )
01811 {
01812   long TickCount = PerfCountToTickCount(perfCount);
01813
01814   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01815   wsprintf(m_sSQL,
01816        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01817         values ('%s',%d, '%s','%s')",
01818          L"OnCRMCommit",
01819          TickCount,
01820          pszGuidApp,
01821          pszGuidClerkCLSID
01822        );
01823
01824   SQL_EXEC(m_sSQL);
01825
01826   return S_OK;
01827 }
01828
01829 STDMETHODIMP CComSpySqlAudit::OnCRMAbort(
01830        LONGLONG perfCount,
01831        LPCOLESTR pszGuidApp,
01832        LPCOLESTR pszGuidClerkCLSID
01833     )
01834 {
01835   long TickCount = PerfCountToTickCount(perfCount);
01836
01837   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01838   wsprintf(m_sSQL,
01839        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01840         values ('%s',%d, '%s','%s')",
01841          L"OnCRMAbort",
01842          TickCount,
01843          pszGuidApp,
01844          pszGuidClerkCLSID
01845        );
01846
01847   SQL_EXEC(m_sSQL);
01848
01849   return S_OK;
01850 }
01851
01852 STDMETHODIMP CComSpySqlAudit::OnCRMIndoubt(
01853        LONGLONG perfCount,
01854        LPCOLESTR pszGuidApp,
01855        LPCOLESTR pszGuidClerkCLSID
01856     )
01857 {
01858   long TickCount = PerfCountToTickCount(perfCount);
01859
01860   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01861   wsprintf(m_sSQL,
01862        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01863         values ('%s',%d, '%s','%s')",
01864          L"OnCRMIndoubt",
01865          TickCount,
01866          pszGuidApp,
01867          pszGuidClerkCLSID
01868        );
01869
01870   SQL_EXEC(m_sSQL);
01871
01872   return S_OK;
01873 }
01874
01875 STDMETHODIMP CComSpySqlAudit::OnCRMDone(
01876        LONGLONG perfCount,
01877        LPCOLESTR pszGuidApp,
01878        LPCOLESTR pszGuidClerkCLSID
01879     )
01880 {
01881   long TickCount = PerfCountToTickCount(perfCount);
01882
01883   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01884   wsprintf(m_sSQL,
01885        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01886         values ('%s',%d, '%s','%s')",
01887          L"OnCRMDone",
01888          TickCount,
01889          pszGuidApp,
01890          pszGuidClerkCLSID
01891        );
01892
01893   SQL_EXEC(m_sSQL);
01894
01895   return S_OK;
01896 }
01897
01898 STDMETHODIMP CComSpySqlAudit::OnCRMRelease(
01899        LONGLONG perfCount,
01900        LPCOLESTR pszGuidApp,
01901        LPCOLESTR pszGuidClerkCLSID
01902     )
01903 {
01904   long TickCount = PerfCountToTickCount(perfCount);
01905
01906   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01907   wsprintf(m_sSQL,
01908        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01909         values ('%s',%d, '%s','%s')",
01910          L"OnCRMRelease",
01911          TickCount,
01912          pszGuidApp,
01913          pszGuidClerkCLSID
01914        );
01915
01916   SQL_EXEC(m_sSQL);
01917
01918   return S_OK;
01919 }
01920
01921 STDMETHODIMP CComSpySqlAudit::OnCRMAnalyze(
01922        LONGLONG perfCount,
01923        LPCOLESTR pszGuidApp,
01924        LPCOLESTR pszGuidClerkCLSID,
01925        LPCOLESTR pszCrmRecordType,
01926        DWORD dwRecordSize
01927     )
01928 {
01929   long TickCount = PerfCountToTickCount(perfCount);
01930
01931   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01932   wsprintf(m_sSQL,
01933        L"insert into CRMEvents (Event,TickCount,Application, ClerkID,CRMRecordType,RecordSize) \
01934         values ('%s',%d, '%s','%s','%s',%d)",
01935          L"OnCRMAnalyze",
01936          TickCount,
01937          pszGuidApp,
01938          pszGuidClerkCLSID,
01939          pszCrmRecordType,
01940          dwRecordSize
01941        );
01942
01943   SQL_EXEC(m_sSQL);
01944
01945   return S_OK;
01946 }
01947
01948 STDMETHODIMP CComSpySqlAudit::OnCRMWrite(
01949        LONGLONG perfCount,
01950        LPCOLESTR pszGuidApp,
01951        LPCOLESTR pszGuidClerkCLSID,
01952        BOOL bVariants,
01953        DWORD dwRecordSize)
01954 {
01955   long TickCount = PerfCountToTickCount(perfCount);
01956
01957   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01958   wsprintf(m_sSQL,
01959        L"insert into CRMEvents (Event,TickCount,Application, ClerkID,Variants,RecordSize) \
01960         values ('%s',%d, '%s','%s','%s',%d)",
01961          L"OnCRMWrite",
01962          TickCount,
01963          pszGuidApp,
01964          pszGuidClerkCLSID,
01965          (bVariants ? L"Yes" : L"No"),
01966          dwRecordSize
01967        );
01968   SQL_EXEC(m_sSQL);
01969
01970   return S_OK;
01971 }
01972
01973 STDMETHODIMP CComSpySqlAudit::OnCRMForget(
01974        LONGLONG perfCount,
01975        LPCOLESTR pszGuidApp,
01976        LPCOLESTR pszGuidClerkCLSID
01977     )
01978 {
01979   long TickCount = PerfCountToTickCount(perfCount);
01980
01981   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
01982   wsprintf(m_sSQL,
01983        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
01984         values ('%s',%d, '%s','%s')",
01985          L"OnCRMForget",
01986          TickCount,
01987          pszGuidApp,
01988          pszGuidClerkCLSID
01989        );
01990
01991   SQL_EXEC(m_sSQL);
01992
01993   return S_OK;
01994 }
01995
01996 STDMETHODIMP CComSpySqlAudit::OnCRMForce(
01997        LONGLONG perfCount,
01998        LPCOLESTR pszGuidApp,
01999        LPCOLESTR pszGuidClerkCLSID
02000     )
02001 {
02002   long TickCount = PerfCountToTickCount(perfCount);
02003
02004   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
02005   wsprintf(m_sSQL,
02006        L"insert into CRMEvents (Event,TickCount,Application, ClerkID) \
02007         values ('%s',%d, '%s','%s')",
02008          L"OnCRMForce",
02009          TickCount,
02010          pszGuidApp,
02011          pszGuidClerkCLSID
02012        );
02013
02014   SQL_EXEC(m_sSQL);
02015
02016   return S_OK;
02017 }
02018
02019 STDMETHODIMP CComSpySqlAudit::OnCRMDeliver(
02020        LONGLONG perfCount,
02021        LPCOLESTR pszGuidApp,
02022        LPCOLESTR pszGuidClerkCLSID,
02023        BOOL bVariants,
02024        DWORD dwRecordSize
02025     )
02026 {
02027   long TickCount = PerfCountToTickCount(perfCount);
02028
02029   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
02030   wsprintf(m_sSQL,
02031        L"insert into CRMEvents (Event,TickCount,Application, ClerkID, Variants, RecordSize) \
02032         values ('%s',%d, '%s','%s','%s',%d)",
02033          L"OnCRMDeliver",
02034          TickCount,
02035          pszGuidApp,
02036          pszGuidClerkCLSID,
02037          (bVariants ? L"Yes" : L"No"),
02038          dwRecordSize
02039        );
02040
02041   SQL_EXEC(m_sSQL);
02042
02043   return S_OK;
02044 }
02045
02046 //////////////////////////Load Balancing Events///////////////////////////////////
02047 STDMETHODIMP CComSpySqlAudit::TargetUp(
02048                LONGLONG perfCount,
02049                LPCOLESTR pszServerName,
02050                LPCOLESTR pszClsidEng)
02051 {
02052   long TickCount = PerfCountToTickCount(perfCount);
02053
02054   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
02055   wsprintf(m_sSQL,
02056        L"insert into LBEvents (Event,TickCount,Application, ServerName, ClsidEng) \
02057         values ('%s',%d, '%s','%s','%s')",
02058          L"TargetUp",
02059          TickCount,
02060          L"COM+ Load Balancing",
02061          pszServerName,
02062          pszClsidEng
02063        );
02064
02065   SQL_EXEC(m_sSQL);
02066
02067   return S_OK;
02068 }
02069
02070 STDMETHODIMP CComSpySqlAudit::TargetDown(
02071                LONGLONG perfCount,
02072                LPCOLESTR pszServerName,
02073                LPCOLESTR pszClsidEng)
02074 {
02075   long TickCount = PerfCountToTickCount(perfCount);
02076
02077   ZeroMemory(m_sSQL, SQL_BUF_SIZE * sizeof(WCHAR));
02078   wsprintf(m_sSQL,
02079        L"insert into LBEvents (Event,TickCount,Application, ServerName, ClsidEng) \
02080         values ('%s',%d, '%s','%s','%s')",
02081          L"TargetDown",
02082          TickCount,
02083          L"COM+ Load Balancing",
02084          pszServerName,
02085          pszClsidEng
02086        );
02087
02088   SQL_EXEC(m_sSQL);
02089
02090   return S_OK;
02091 }
02092
02093 STDMETHODIMP CComSpySqlAudit:: EngineDefined(
02094                LONGLONG perfCount,
02095                LPCOLESTR pszPropName,
02096                VARIANT *varPropValue,
02097                LPCOLESTR pszClsidEng)
02098 {
02099   UNREFERENCED_PARAMETER(perfCount);
02100   UNREFERENCED_PARAMETER(pszPropName);
02101   UNREFERENCED_PARAMETER(varPropValue);
02102   UNREFERENCED_PARAMETER(pszClsidEng);
02103
02104   return S_OK;
02105 }
02106
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_DRAWDATA Member List

This is the complete list of members for _DRAWDATA, including all inherited members.
nObject _DRAWDATA
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletCapability Member List

This is the complete list of members for tagAppletCapability, including all inherited members.
CapClass | tagAppletCapability
CapID | tagAppletCapability
cEntities | tagAppletCapability
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/command.h Source File

  • Dataaccess
  • oledb
  • sampprov

command.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 //--------------------------------------------------------------------
00003 // Microsoft OLE DB Sample Provider
00004 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00005 //
00006 // @doc
00007 //
00008 // @module COMMAND.H | CCommand base object and contained interface
00009 // definitions
00010 //
00011 //
00012
00013 #ifndef __COMMAND_H__
00014 #define __COMMAND_H__
00015
00016 #include "baseobj.h"
00017 #include "dbsess.h"
00018
00019 // Forward declarations ------------------------------------------------------
00020 class CImpIAccessor;
00021 class CImpICommandText;
00022 class CImpICommandProperties;
00023 class CImpIColumnsInfo;
00024 class CImpIConvertType;
00025
00026 typedef CImpICommandText*     PIMPICOMMANDTEXT;
00027 typedef CImpICommandProperties*   PIMPICOMMANDPROPERTIES;
00028 typedef CImpIColumnsInfo*     PIMPICOLUMNSINFO;
00029 typedef CImpIConvertType*     PIMPICONVERTTYPE;
00030
00031 // Constants -----------------------------------------------------------------
00032 // For CCommand::m_dwStatus
00033 // These are bit masks.
00034 enum COMMAND_STATUS_FLAG {
00035   // Command Object status flags
00036   CMD_STATUS_MASK     = 0x0000000F,
00037   CMD_INITIALIZED     = 0x00000001,
00038   CMD_TEXT_SET      = 0x00000002,
00039   CMD_EXECUTING     = 0x00000004,
00040   CMD_EXEC_CANCELED   = 0x10000000,
00041 };
00042
00043 // Classes -------------------------------------------------------------------
00044
00045
00046 //----------------------------------------------------------------------------
00047 // @class CCommand | Containing class for all interfaces on the Command CoType Object
00048 //
00049 class CCommand : public CBaseObj        //@base public | CBaseObj
00050 {
00051   //  Contained interfaces are friends
00052   friend class CImpIAccessor;
00053   friend class CImpICommandText;
00054   friend class CImpICommandProperties;
00055   friend class CImpIColumnsInfo;
00056   friend class CImpIConvertType;
00057
00058   //@access protected
00059   protected:
00060     //@cmember Reference count
00061     DBREFCOUNT          m_cRef;
00062     //@cmember Controlling IUnknown
00063     CImpIAccessor*        m_pIAccessor;
00064     //@cmember Contained ICommandText and ICommand
00065     PIMPICOMMANDTEXT      m_pICommandText;
00066     //@cmember Contained ICommandProperties
00067     PIMPICOMMANDPROPERTIES    m_pICommandProperties;
00068     //@cmember Contained IColumnsInfo
00069     PIMPICOLUMNSINFO      m_pIColumnsInfo;
00070     //@cmember Contained IConvertType
00071     PIMPICONVERTTYPE      m_pIConvertType;
00072
00073     //@cmember Execution Status Flags
00074     UDWORD            m_dwStatus;
00075     //@cmember Count of Active Rowsets on this command object
00076     ULONG           m_cRowsetsOpen;
00077
00078     //@cmember Impersonation GUID
00079     GUID            m_guidImpersonate;
00080
00081     //@cmember GUID for dialect of current text or tree
00082     GUID            m_guidCmdDialect;
00083     //@cmember current file to open, if any
00084     WCHAR *           m_strCmdText;
00085     //@member Utility object to manage properties
00086     PCUTILPROP          m_pUtilProp;
00087
00088   //@access public
00089   public:
00090
00091     //@cmember Constructor
00092      CCommand(CDBSession* pCSession, LPUNKNOWN pUnkOuter);
00093
00094      //@cmember Destructor
00095     ~CCommand(void);
00096
00097     //@cmember Parent Session Object
00098     CDBSession*         m_pCSession;
00099
00100     //@cmember Initialization Routine
00101     HRESULT FInit();
00102
00103     //  Object's base IUnknown
00104     //@cmember Request an Interface
00105     STDMETHODIMP        QueryInterface(REFIID, LPVOID *);
00106     //@cmember Increments the Reference count
00107     STDMETHODIMP_(DBREFCOUNT) AddRef(void);
00108     //@cmember Decrements the Reference count
00109     STDMETHODIMP_(DBREFCOUNT) Release(void);
00110
00111     //@cmember Used to cancel currently executing commands
00112     HRESULT CheckCanceledHelper();
00113
00114     inline void SetImpersonateIID(const GUID* pGuid) {
00115       assert(pGuid);
00116       m_guidImpersonate = *pGuid;
00117     };
00118
00119     inline WCHAR * const GetCommandText() {
00120       return m_strCmdText;
00121     };
00122
00123     inline BOOL IsCommandSet() {
00124       return !!(m_dwStatus & CMD_TEXT_SET);
00125     };
00126
00127     inline void DecrementOpenRowsets() {
00128       InterlockedDecrement( (LONG*) &m_cRowsetsOpen );
00129       ASSERT( m_cRowsetsOpen != (ULONG)-1 );
00130     };
00131
00132     inline void IncrementOpenRowsets() {
00133       InterlockedIncrement( (LONG*) &m_cRowsetsOpen );
00134     };
00135
00136     inline BOOL IsRowsetOpen() {
00137       return (m_cRowsetsOpen > 0) ? TRUE : FALSE;
00138     };
00139 };
00140
00141 typedef CCommand*     PCCOMMAND;
00142
00143
00144 //----------------------------------------------------------------------------
00145 // @class CImpICommandText | Contained ICommandText class
00146 // Object
00147 //
00148 class CImpICommandText : public ICommandText  //@base public | ICommandText
00149 {
00150   private: //@access Private Data Members
00151     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CCommand)
00152
00153   public: //@access Public Functions
00154     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CCommand, CImpICommandText);
00155     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00156
00157     //  ICommandText members
00158     //@cmember GetCommandText Method
00159       STDMETHODIMP      GetCommandText(GUID* pguidDialect, LPOLESTR* ppwszCommand);
00160     //@cmember SetCommandText Method
00161     STDMETHODIMP      SetCommandText(REFGUID rguidDialect, LPCOLESTR pwszCommand);
00162     //@cmember Cancel Method, inherited from ICommand
00163       STDMETHODIMP      Cancel();
00164     //@cmember Execute Method, inherited from ICommand
00165     STDMETHODIMP      Execute(IUnknown* pUnkOuter,
00166                 REFIID riid, DBPARAMS* pParams,
00167                 DBROWCOUNT* pcRowsAffected, IUnknown** ppRowset);
00168     //@cmember GetDBSession Method
00169     STDMETHODIMP      GetDBSession(REFIID riid, IUnknown** ppSession);
00170 };
00171
00172
00173
00174 //-----------------------------------------------------------------------------
00175 // @class CImpICommandProperties | Base class to implement ICommandProperties.
00176 //
00177 //
00178 class CImpICommandProperties : public ICommandProperties  //@base public | ICommandProperties
00179 {
00180   private: //@access Private Data Members
00181     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CCommand)
00182
00183   public: //@access Public Functions
00184     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CCommand, CImpICommandProperties);
00185     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00186
00187     //  ICommandProperties members
00188     //@cmember GetProperties Method
00189         STDMETHODIMP  GetProperties(const ULONG cPropertySets,
00190             const DBPROPIDSET rgPropertySets[], ULONG* pcProperties,
00191             DBPROPSET** prgProperties);
00192     //@cmember SetProperties Method
00193         STDMETHODIMP  SetProperties
00194           (
00195             ULONG       cPropertySets,
00196             DBPROPSET     rgPropertySets[]
00197           );
00198 };
00199
00200 #endif __COMMAND_H__
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImageTag Member List

This is the complete list of members for CImageTag, including all inherited members.
_aTempBuffer | CHtmlElement | [protected]
_cValueChars | CImageTag | [private]
_cValueCharsFiltered | CImageTag | [private]
_htmlIFilter | CHtmlElement | [protected]
_pwcValueBuf | CImageTag | [private]
_scanner | CHtmlElement | [protected]
_serialStream | CHtmlElement | [protected]
CHtmlElement(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CHtmlElement |
CImageTag(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CImageTag |
GetChunk(STAT_CHUNK *pStat) | CImageTag | [virtual]
GetText(ULONG *pcwcOutput, WCHAR *awcBuffer) | CImageTag | [virtual]
GetValue(PROPVARIANT **ppPropValue) | CHtmlElement | [virtual]
InitFilterRegion(ULONG &idChunkSource, ULONG &cwcStartSource, ULONG &cwcLenSource) | CHtmlElement | [virtual]
InitStatChunk(STAT_CHUNK *pStat) | CImageTag | [virtual]
SkipRemainingTextAndGotoNextChunk(STAT_CHUNK *pStat) | CHtmlElement | [protected]
SwitchToNextHtmlElement(STAT_CHUNK *pStat) | CHtmlElement | [protected]
~CHtmlElement() | CHtmlElement | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMDIChild Member List

This is the complete list of members for CMDIChild, including all inherited members.
AbortTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
AddColumnProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
AdminCreateDataSourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
AutoPosition(BOOL fDefaultPosition=TRUE) | CMDIChild | [virtual]
CanConvertProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
ChangeSelectedRow(CBase *pCSource, UINT idSource) | CMDIChild | [virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CMDIChild(CMainWindow *pCMainWindow) | CMDIChild |
CMDIChildLite() | CMDIChildLite |
ColumnChangeProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
CommandPersistProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
CommitTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, HICON hIcon, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CMDIChildLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateAccessorProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
CreateEnumChild() | CMDIChild | [virtual]
CreateIndexProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CreateTableProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeleteSelectedRows() | CMDIChild | [virtual]
DestroyWindow() | CWndLite | [virtual]
DisplayDialog(UINT uID, HWND hWndParent, DLGPROC lpDialogFunc, CBase *pCObject, UINT idSource=0) | CMDIChild | [virtual]
DropColumnProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
DropConstraintProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
DropIndexProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
DropTableProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
ExecuteProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
FindNextRowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetAxisInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetAxisRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetBindingsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetChapteredChild(INDEX iSelectedCol, const DBBINDING *pBinding, REFIID riid=IID_IRowset) | CMDIChild | [virtual]
GetColInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetColumnsRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetListViewValues(HWND hWndNames, HWND hWndValues, CDataAccess *pCDataAccess, CBindings &rBindings, void *pData) | CMDIChild | [virtual]
GetLiteralInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetNextRowsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetObject(SOURCE eSource=eCUnknown, BOOL fAlways=FALSE) | CMDIChild | [virtual]
GetObjectAddress(SOURCE eSource=eCUnknown) | CMDIChild | [virtual]
GetOptions() | CMDIChild | [virtual]
GetParameterInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetReferencedRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetTransactionInfo(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [virtual]
HandleRowset(CBase *pCSource, IUnknown *pIUnknown, REFIID riid, DWORD dwFlags, REFGUID guidSource, WCHAR *pwszTableName=NULL, BOOL fSchemaRowset=FALSE) | CMDIChild | [virtual]
InsertNewRow() | CMDIChild | [virtual]
ISCO_DeleteProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
ISCO_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
JoinTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
m_bUnicodeMsg | CWndLite |
m_CDefPropSets | CMDIChild |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iChildWindow | CMDIChild | [static]
m_idSource | CMDIChild |
m_lastSizedEdge | CMDIChild |
m_nID | CWndLite |
m_pCCommand | CMDIChild |
m_pCDataAccess | CMDIChild |
m_pCDataGrid | CMDIChild |
m_pCDataSource | CMDIChild |
m_pCMainWindow | CMDIChild |
m_pCMultipleResults | CMDIChild |
m_pCQueryBox | CMDIChild |
m_pCSession | CMDIChild |
m_pCSource | CMDIChild |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_pwszConfig | CMDIChild |
m_wndPlacement | CWndLite |
MDIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [static]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CMDIChild | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CMDIChild | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(LPCREATESTRUCT lpCreateStruct) | CMDIChild | [virtual]
CMDIChildLite::OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CMDIChild | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CMDIChild | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate) | CMDIChild | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CMDIChild | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CMDIChild | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CMDIChild | [virtual]
OnSizing(WPARAM nSide, REFPOINTS pts) | CMDIChild | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CMDIChild | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OpenRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
ProviderInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
ReleaseTransaction(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
RowChangeProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
RowOpenProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
SetCommandTextProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
SetConfig(WCHAR *pwszConfig, BOOL fCopy=TRUE) | CMDIChild | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParameterInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
SetTransactionOptionsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
SetupTransactionCombo(HWND hWnd) | CMDIChild | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
StartTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChild | [static]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UndoChanges() | CMDIChild | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [virtual]
UpdateChanges() | CMDIChild | [virtual]
UpdateControls() | CMDIChild | [virtual]
UpdateWindow() | CWndLite | [inline]
UpdateWndTitle() | CMDIChild | [virtual]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CMDIChild() | CMDIChild | [virtual]
~CMDIChildLite() | CMDIChildLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CREATEGIZMOW Member List

This is the complete list of members for CREATEGIZMOW, including all inherited members.
dx | CREATEGIZMOW
dy | CREATEGIZMOW
hBmp | CREATEGIZMOW
hWndParent | CREATEGIZMOW
iGizmo | CREATEGIZMOW
iImage | CREATEGIZMOW
iType | CREATEGIZMOW
pszText | CREATEGIZMOW
uID | CREATEGIZMOW
uState | CREATEGIZMOW
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/EncryptDecrypt/RSACert/RSACert.cpp Source File

  • Security
  • CryptoApi
  • EncryptDecrypt
  • RSACert

RSACert.cpp

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2002.  Microsoft Corporation.  All rights reserved.
00008 */
00009 /*
00010 #define UNICODE
00011 #define _UNICODE
00012 #define _WIN32_WINNT 0x0400
00013 */
00014 #include <windows.h>
00015 #include <tchar.h>
00016 #include <stdio.h>
00017 #include <strsafe.h> // for proper buffer handling
00018
00019 const int IN_BUFFER_SIZE    = 64 * 1024;
00020 // OUT_BUFFER_SIZE is 8 bytes larger than IN_BUFFER_SIZE
00021 // When CALG_RC2 algorithm is used, encrypted data
00022 // will be 8 bytes larger than IN_BUFFER_SIZE
00023 const int OUT_BUFFER_SIZE   = IN_BUFFER_SIZE + 8; // extra padding
00024
00025 #define MY_ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
00026
00027 void PrintUsage();
00028 PCCERT_CONTEXT GetCertificateContextFromName(
00029                         LPTSTR lpszCertificateName,
00030                         LPTSTR lpszCertificateStoreName,
00031                         DWORD  dwCertStoreOpenFlags);
00032
00033 BOOL AcquireAndGetRSAKey(PCCERT_CONTEXT pCertContext,
00034                          DWORD dwCertStoreOpenFlags,
00035                          HCRYPTPROV *phProv,
00036                          HCRYPTKEY *phRSAKey,
00037                          BOOL fEncrypt,
00038                          BOOL *fCallerFreeProv);
00039 BOOL EncryptDecryptFile(LPTSTR lpszCertificateName,
00040                         LPTSTR lpszCertificateStoreName,
00041                         DWORD  dwCertStoreOpenFlags,
00042                         LPTSTR lpszInputFileName,
00043                         LPTSTR lpszOutputFileName,
00044                         BOOL fEncrypt);
00045 void __cdecl MyPrintf(LPCTSTR lpszFormat, ...);
00046
00047 #define CheckAndLocalFree(ptr) \
00048             if (ptr != NULL) \
00049             { \
00050                LocalFree(ptr); \
00051                ptr = NULL; \
00052             }
00053
00054 void PrintUsage()
00055 {
00056    MyPrintf(_T("RSACert [</e>|</d>] <CertName> <StoreName> [</u>|</m>] <InputFile> <OutputFile>\n"));
00057    MyPrintf(_T("/e for Encryption\n"));
00058    MyPrintf(_T("/d for Decryption\n"));
00059    MyPrintf(_T("/u for current user certificate store\n"));
00060    MyPrintf(_T("/m for local machine certificate store\n"));
00061 }
00062
00063 void __cdecl MyPrintf(LPCTSTR lpszFormat, ...)
00064 {
00065    TCHAR szOutput[2048];
00066    va_list v1 = NULL;
00067    HRESULT hr = S_OK;
00068
00069    va_start(v1, lpszFormat);
00070    hr = StringCbVPrintf(szOutput, sizeof(szOutput), lpszFormat, v1);
00071    if (SUCCEEDED(hr))
00072    {
00073       OutputDebugString(szOutput);
00074       _tprintf(szOutput);
00075    }
00076    else
00077    {
00078       _tprintf(_T("StringCbVPrintf failed with %X\n"), hr);
00079    }
00080 }
00081
00082 void _tmain(int argc, TCHAR **argv)
00083 {
00084    BOOL fEncrypt = FALSE;
00085    LPTSTR lpszCertificateName = NULL;
00086    LPTSTR lpszCertificateStoreName = NULL;
00087    LPTSTR lpszInputFileName = NULL;
00088    LPTSTR lpszOutputFileName = NULL;
00089    DWORD dwCertStoreOpenFlags = CERT_SYSTEM_STORE_CURRENT_USER;
00090
00091    if (argc != 7)
00092    {
00093       PrintUsage();
00094       return;
00095    }
00096
00097    /* Check whether the action to be performed is encrypt or decrypt */
00098    if (_tcsicmp(argv[1], _T("/e")) == 0)
00099    {
00100       fEncrypt = TRUE;
00101    }
00102    else if (_tcsicmp(argv[1], _T("/d")) == 0)
00103    {
00104       fEncrypt = FALSE;
00105    }
00106    else
00107    {
00108       PrintUsage();
00109       return;
00110    }
00111
00112    lpszCertificateName = argv[2];
00113    lpszCertificateStoreName = argv[3];
00114
00115    /* Check whether the certificate store to be opened is user or machine */
00116    if (_tcsicmp(argv[4], _T("/u")) == 0)
00117    {
00118       dwCertStoreOpenFlags = CERT_SYSTEM_STORE_CURRENT_USER;
00119    }
00120    else if (_tcsicmp(argv[4], _T("/m")) == 0)
00121    {
00122       dwCertStoreOpenFlags = CERT_SYSTEM_STORE_LOCAL_MACHINE;
00123    }
00124    else
00125    {
00126       PrintUsage();
00127       return;
00128    }
00129
00130    lpszInputFileName = argv[5];
00131    lpszOutputFileName = argv[6];
00132
00133    EncryptDecryptFile(lpszCertificateName,
00134                         lpszCertificateStoreName,
00135                         dwCertStoreOpenFlags,
00136                         lpszInputFileName,
00137                         lpszOutputFileName,
00138                         fEncrypt);
00139 }
00140
00141 PCCERT_CONTEXT GetCertificateContextFromName(
00142                         LPTSTR lpszCertificateName,
00143                         LPTSTR lpszCertificateStoreName,
00144                         DWORD  dwCertStoreOpenFlags)
00145 {
00146    PCCERT_CONTEXT pCertContext = NULL;
00147    HCERTSTORE hCertStore = NULL;
00148    LPSTR szStoreProvider;
00149    DWORD dwFindType;
00150
00151 #ifdef UNICODE
00152    szStoreProvider = (LPSTR)CERT_STORE_PROV_SYSTEM_W;
00153 #else
00154    szStoreProvider = (LPSTR)CERT_STORE_PROV_SYSTEM_A;
00155 #endif
00156
00157    // Open the specified certificate store
00158    hCertStore = CertOpenStore(szStoreProvider,
00159                      0,
00160                      NULL,
00161                      CERT_STORE_READONLY_FLAG|
00162                      dwCertStoreOpenFlags,
00163                      lpszCertificateStoreName);
00164    if (hCertStore == NULL)
00165    {
00166       MyPrintf(_T("CertOpenStore failed with %X\n"), GetLastError());
00167       return pCertContext;
00168    }
00169
00170 #ifdef UNICODE
00171    dwFindType = CERT_FIND_SUBJECT_STR_W;
00172 #else
00173    dwFindType = CERT_FIND_SUBJECT_STR_A;
00174 #endif
00175
00176    // Find the certificate by CN.
00177    pCertContext = CertFindCertificateInStore(
00178                     hCertStore,
00179                     MY_ENCODING,
00180                     0,
00181                     dwFindType,
00182                     lpszCertificateName,
00183                     NULL);
00184    if (pCertContext == NULL)
00185    {
00186       MyPrintf(_T("CertFindCertificateInStore failed with %X\n"), GetLastError());
00187    }
00188
00189    CertCloseStore(hCertStore, 0);
00190
00191    return pCertContext;
00192 }
00193
00194 BOOL AcquireAndGetRSAKey(PCCERT_CONTEXT pCertContext,
00195                          HCRYPTPROV *phProv,
00196                          HCRYPTKEY *phRSAKey,
00197                          BOOL fEncrypt,
00198                          BOOL *pfCallerFreeProv)
00199 {
00200    BOOL fSuccess = FALSE;
00201    DWORD dwKeySpec = 0;
00202
00203    __try
00204    {
00205       *phProv = NULL;
00206       *phRSAKey = NULL;
00207       *pfCallerFreeProv = FALSE;
00208
00209       if (fEncrypt)
00210       {
00211          // Acquire context for RSA key
00212          fSuccess = CryptAcquireContext(phProv,
00213                         NULL,
00214                         MS_DEF_PROV,
00215                         PROV_RSA_FULL,
00216                         CRYPT_VERIFYCONTEXT);
00217          if (!fSuccess)
00218          {
00219             MyPrintf(_T("CryptAcquireContext failed with %X\n"), GetLastError());
00220             __leave;
00221          }
00222
00223          // Import the RSA public key from the certificate context
00224          fSuccess = CryptImportPublicKeyInfo(*phProv,
00225                         MY_ENCODING,
00226                         &(pCertContext->pCertInfo->SubjectPublicKeyInfo),
00227                         phRSAKey);
00228          if (!fSuccess)
00229          {
00230             MyPrintf(_T("CryptImportPublicKeyInfo failed with %X\n"), GetLastError());
00231             __leave;
00232          }
00233
00234          *pfCallerFreeProv = TRUE;
00235       }
00236       else
00237       {
00238          // Acquire the RSA private key
00239          fSuccess = CryptAcquireCertificatePrivateKey(pCertContext,
00240                CRYPT_ACQUIRE_USE_PROV_INFO_FLAG|CRYPT_ACQUIRE_COMPARE_KEY_FLAG,
00241                NULL, phProv, &dwKeySpec, pfCallerFreeProv);
00242          if (!fSuccess)
00243          {
00244             MyPrintf(_T("CryptAcquireCertificatePrivateKey failed with %X\n"), GetLastError());
00245             __leave;
00246          }
00247
00248          // Get the RSA key handle
00249          fSuccess = CryptGetUserKey(*phProv, dwKeySpec, phRSAKey);
00250          if (!fSuccess)
00251          {
00252             MyPrintf(_T("CryptGetUserKey failed with %X\n"), GetLastError());
00253             __leave;
00254          }
00255       }
00256    }
00257    __finally
00258    {
00259       if (fSuccess == FALSE)
00260       {
00261          if (phProv && *phProv != NULL)
00262          {
00263             CryptReleaseContext(*phProv, 0);
00264             *phProv = NULL;
00265          }
00266          if (phRSAKey && *phRSAKey != NULL)
00267          {
00268             CryptDestroyKey(*phRSAKey);
00269             *phRSAKey = NULL;
00270          }
00271       }
00272    }
00273
00274    return fSuccess;
00275 }
00276
00277 BOOL EncryptDecryptFile(LPTSTR lpszCertificateName,
00278                         LPTSTR lpszCertificateStoreName,
00279                         DWORD  dwCertStoreOpenFlags,
00280                         LPTSTR lpszInputFileName,
00281                         LPTSTR lpszOutputFileName,
00282                         BOOL fEncrypt)
00283 {
00284    BOOL fResult = FALSE;
00285    HCRYPTPROV hProv = NULL;
00286    HCRYPTKEY hRSAKey = NULL;
00287    HCRYPTKEY hSessionKey = NULL;
00288    HANDLE hInFile = INVALID_HANDLE_VALUE;
00289    HANDLE hOutFile = INVALID_HANDLE_VALUE;
00290    BOOL finished = FALSE;
00291    BYTE pbBuffer[OUT_BUFFER_SIZE];
00292    DWORD dwByteCount = 0;
00293    DWORD dwBytesRead = 0;
00294    DWORD dwBytesWritten = 0;
00295    LPBYTE pbSessionKeyBlob = NULL;
00296    DWORD dwSessionKeyBlob = 0;
00297    BOOL fCallerFreeProv = FALSE;
00298    PCCERT_CONTEXT pCertContext = NULL;
00299    BOOL fSuccess = FALSE;
00300
00301    __try
00302    {
00303       pCertContext = GetCertificateContextFromName(lpszCertificateName,
00304                         lpszCertificateStoreName,
00305                         dwCertStoreOpenFlags);
00306       if (pCertContext == NULL)
00307       {
00308          __leave;
00309       }
00310
00311       fResult = AcquireAndGetRSAKey(pCertContext,
00312                         &hProv,
00313                         &hRSAKey,
00314                         fEncrypt,
00315                         &fCallerFreeProv);
00316       if (fResult == FALSE)
00317       {
00318          __leave;
00319       }
00320
00321       // Open the input file to be encrypted or decrypted
00322       hInFile = CreateFile(lpszInputFileName,
00323                   GENERIC_READ,
00324                   0,
00325                   NULL,
00326                   OPEN_EXISTING,
00327                   FILE_ATTRIBUTE_NORMAL,
00328                   NULL);
00329       if (hInFile == INVALID_HANDLE_VALUE)
00330       {
00331          MyPrintf(_T("CreateFile failed with %d\n"), GetLastError());
00332          __leave;
00333       }
00334
00335       // Open the output file to write the encrypted or decrypted data
00336       hOutFile = CreateFile(lpszOutputFileName,
00337                   GENERIC_WRITE,
00338                   0,
00339                   NULL,
00340                   CREATE_ALWAYS,
00341                   FILE_ATTRIBUTE_NORMAL,
00342                   NULL);
00343       if (hOutFile == INVALID_HANDLE_VALUE)
00344       {
00345          MyPrintf(_T("CreateFile failed with %d\n"), GetLastError());
00346          __leave;
00347       }
00348
00349       if (fEncrypt)
00350       {
00351          fResult = CryptGenKey(hProv, CALG_RC4, CRYPT_EXPORTABLE, &hSessionKey);
00352          if (!fResult)
00353          {
00354             MyPrintf(_T("CryptGenKey failed with %X\n"), GetLastError());
00355             __leave;
00356          }
00357
00358          // The first call to ExportKey with NULL gets the key size.
00359          dwSessionKeyBlob = 0;
00360          fResult = CryptExportKey(hSessionKey, hRSAKey, SIMPLEBLOB, 0,
00361                      NULL, &dwSessionKeyBlob);
00362          if (!fResult)
00363          {
00364             MyPrintf(_T("CryptExportKey failed with %X\n"), GetLastError());
00365             __leave;
00366          }
00367
00368          // Allocate memory for Encrypted Session key blob
00369          pbSessionKeyBlob = (LPBYTE)LocalAlloc(LPTR, dwSessionKeyBlob);
00370          if (!pbSessionKeyBlob)
00371          {
00372             MyPrintf(_T("LocalAlloc failed with %d\n"), GetLastError());
00373             __leave;
00374          }
00375
00376          fResult = CryptExportKey(hSessionKey, hRSAKey, SIMPLEBLOB, 0,
00377                      pbSessionKeyBlob, &dwSessionKeyBlob);
00378          if (!fResult)
00379          {
00380             MyPrintf(_T("CryptExportKey failed with %X\n"), GetLastError());
00381             __leave;
00382          }
00383
00384          // Write the size of key blob, then the key blob itself, to output file.
00385          fResult = WriteFile(hOutFile, &dwSessionKeyBlob,
00386                      sizeof(dwSessionKeyBlob),
00387                      &dwBytesWritten, NULL);
00388          if (!fResult)
00389          {
00390             MyPrintf(_T("WriteFile failed with %d\n"), GetLastError());
00391             __leave;
00392          }
00393          fResult = WriteFile(hOutFile, pbSessionKeyBlob,
00394                      dwSessionKeyBlob,
00395                      &dwBytesWritten, NULL);
00396          if (!fResult)
00397          {
00398             MyPrintf(_T("WriteFile failed with %d\n"), GetLastError());
00399             __leave;
00400          }
00401       }
00402       else
00403       {
00404          // Read in key block size, then key blob itself from input file.
00405          fResult = ReadFile(hInFile, &dwByteCount, sizeof(dwByteCount),
00406                &dwBytesRead, NULL);
00407          if (!fResult)
00408          {
00409             MyPrintf(_T("ReadFile failed with %d\n"), GetLastError());
00410             __leave;
00411          }
00412
00413          fResult = ReadFile(hInFile, pbBuffer, dwByteCount, &dwBytesRead, NULL);
00414          if (!fResult)
00415          {
00416             MyPrintf(_T("ReadFile failed with %d\n"), GetLastError());
00417             __leave;
00418          }
00419
00420          // import key blob into "CSP"
00421          fResult = CryptImportKey(hProv, pbBuffer, dwByteCount, hRSAKey, 0, &hSessionKey);
00422          if (!fResult)
00423          {
00424             MyPrintf(_T("CryptImportKey failed with %X\n"), GetLastError());
00425             __leave;
00426          }
00427       }
00428
00429       do
00430       {
00431          dwByteCount = 0;
00432
00433          // Now read data from the input file 64K bytes at a time.
00434          fResult = ReadFile(hInFile, pbBuffer, IN_BUFFER_SIZE, &dwByteCount, NULL);
00435
00436          // If the file size is exact multiple of 64K, dwByteCount will be zero after
00437          // all the data has been read from the input file. In this case, simply break
00438          // from the while loop. The check to do this is below
00439          if (dwByteCount == 0)
00440             break;
00441
00442          if (!fResult)
00443          {
00444             MyPrintf(_T("ReadFile failed with %d\n"), GetLastError());
00445             __leave;
00446          }
00447
00448          finished = (dwByteCount < IN_BUFFER_SIZE);
00449
00450          // Encrypt/Decrypt depending on the required action.
00451          if (fEncrypt)
00452          {
00453             fResult = CryptEncrypt(hSessionKey, 0, finished, 0, pbBuffer, &dwByteCount,
00454                            OUT_BUFFER_SIZE);
00455             if (!fResult)
00456             {
00457                MyPrintf(_T("CryptEncrypt failed with %X\n"), GetLastError());
00458                __leave;
00459             }
00460          }
00461          else
00462          {
00463             fResult = CryptDecrypt(hSessionKey, 0, finished, 0, pbBuffer, &dwByteCount);
00464             if (!fResult)
00465             {
00466                MyPrintf(_T("CryptDecrypt failed with %X\n"), GetLastError());
00467                __leave;
00468             }
00469          }
00470
00471          // Write the encrypted/decrypted data to the output file.
00472          fResult = WriteFile(hOutFile, pbBuffer, dwByteCount,
00473             &dwBytesWritten, NULL);
00474          if (!fResult)
00475          {
00476             MyPrintf(_T("WriteFile failed with %d\n"), GetLastError());
00477             __leave;
00478          }
00479
00480       } while (!finished);
00481
00482       if (fEncrypt)
00483          MyPrintf(_T("File %s is encrypted successfully!\n"), lpszInputFileName);
00484       else
00485          MyPrintf(_T("File %s is decrypted successfully!\n"), lpszInputFileName);
00486
00487       fSuccess = TRUE;
00488    }
00489    __finally
00490    {
00491       /* Cleanup */
00492       CheckAndLocalFree(pbSessionKeyBlob);
00493       if (pCertContext != NULL) CertFreeCertificateContext(pCertContext);
00494       if (hRSAKey != NULL) CryptDestroyKey(hRSAKey);
00495       if (hSessionKey != NULL) CryptDestroyKey(hSessionKey);
00496       if (fCallerFreeProv && hProv != NULL) CryptReleaseContext(hProv, 0);
00497       if (hInFile != INVALID_HANDLE_VALUE) CloseHandle(hInFile);
00498       if (hOutFile != INVALID_HANDLE_VALUE) CloseHandle(hOutFile);
00499    }
00500
00501    return fSuccess;
00502 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyface/ComSpyAudit.Idl Source File

  • Com
  • Administration
  • Spy
  • ComSpyface

ComSpyAudit.Idl

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 import "oaidl.idl";
00018 import "ocidl.idl";
00019
00020   [
00021
00022     uuid(AFCF0622-1429-11D1-B1B8-00AA00BA3258),
00023
00024     helpstring("IComSpyAudit Interface"),
00025     pointer_default(unique)
00026   ]
00027   interface IComSpyAudit : IUnknown
00028   {
00029
00030     //IComThreadEvents
00031     HRESULT OnThreadStart(
00032           [in] LONGLONG perfCount,
00033           [in] LPCOLESTR pszGuidApp,
00034           [in] LPCOLESTR pszThreadID,
00035           [in] LPCOLESTR pszW2KThreadID,
00036           [in] DWORD dwThreadCnt
00037         );
00038
00039     HRESULT OnThreadTerminate(
00040           [in] LONGLONG perfCount,
00041           [in] LPCOLESTR pszGuidApp,
00042           [in] LPCOLESTR pszThreadID,
00043           [in] LPCOLESTR pszW2KThreadID,
00044           [in] DWORD dwThreadCnt
00045         );
00046
00047       HRESULT OnThreadBindToApartment(
00048           [in] LONGLONG perfCount,
00049           [in] LPCOLESTR pszGuidApp,
00050           [in] LPCOLESTR pszThreadID,
00051           [in] LPCOLESTR pszAptID,
00052           [in] DWORD dwActivityCnt
00053         );
00054
00055     HRESULT OnThreadUnBind(
00056           [in] LONGLONG perfCount,
00057           [in] LPCOLESTR pszGuidApp,
00058           [in] LPCOLESTR pszThreadID,
00059           [in] LPCOLESTR pszAptID,
00060           [in] DWORD dwActivityCnt
00061         );
00062
00063     HRESULT OnThreadAssignApartment(
00064           [in] LONGLONG perfCount,
00065           [in] LPCOLESTR pszGuidApp,
00066           [in] LPCOLESTR pszGuidActivityID,
00067           [in] LPCOLESTR pszAptID
00068         );
00069     HRESULT OnThreadUnassignApartment(
00070           [in] LONGLONG perfCount,
00071           [in] LPCOLESTR pszGuidApp,
00072           [in] LPCOLESTR pszAptID
00073         );
00074
00075     HRESULT OnThreadWorkEnque(
00076           [in] LONGLONG perfCount,
00077           [in] LPCOLESTR pszGuidApp,
00078           [in] LPCOLESTR pszThreadID,
00079           [in] LPCOLESTR MsgWorkID,
00080           [in] DWORD dwQueueLen
00081         );
00082     HRESULT OnThreadWorkPrivate(
00083           [in] LONGLONG perfCount,
00084           [in] LPCOLESTR pszGuidApp,
00085           [in] LPCOLESTR pszThreadID,
00086           [in] LPCOLESTR MsgWorkID
00087         );
00088     HRESULT OnThreadWorkPublic(
00089           [in] LONGLONG perfCount,
00090           [in] LPCOLESTR pszGuidApp,
00091           [in] LPCOLESTR pszThreadID,
00092           [in] LPCOLESTR MsgWorkID,
00093           [in] DWORD dwQueueLen
00094         );
00095     HRESULT OnThreadWorkRedirect(
00096           [in] LONGLONG perfCount,
00097           [in] LPCOLESTR pszGuidApp,
00098           [in] LPCOLESTR pszThreadID,
00099           [in] LPCOLESTR MsgWorkID,
00100           [in] DWORD dwQueueLen,
00101           [in] LPCOLESTR pszThreadNum
00102         );
00103     HRESULT OnThreadWorkReject(
00104           [in] LONGLONG perfCount,
00105           [in] LPCOLESTR pszGuidApp,
00106           [in] LPCOLESTR pszThreadID,
00107           [in] LPCOLESTR MsgWorkID,
00108           [in] DWORD dwQueueLen
00109         );
00110
00111
00112     //IComAppEvents
00113     HRESULT OnAppActivation(
00114           [in] LONGLONG perfCount,
00115           [in] LPCOLESTR pszGuidApp
00116         );
00117
00118     HRESULT OnAppShutdown(
00119           [in] LONGLONG perfCount,
00120           [in] LPCOLESTR pszGuidApp
00121         );
00122
00123     //IComInstanceEvents
00124     HRESULT OnObjectCreate(
00125           [in] LONGLONG perfCount,
00126           [in] LPCOLESTR pszGuidApp,
00127           [in] LPCOLESTR pszGuidActivityID,
00128           [in] LPCOLESTR pszClassID,
00129           [in] LPCOLESTR pszTSID,
00130           [in] LPCOLESTR pszContextID,
00131           [in] LPCOLESTR pszObjectID
00132         );
00133
00134     HRESULT OnObjectDestroy(
00135           [in] LONGLONG perfCount,
00136           [in] LPCOLESTR pszGuidApp,
00137           [in] LPCOLESTR pszContextID
00138         );
00139
00140     //IComTransactionEvents
00141     HRESULT OnTransactionStart(
00142           [in] LONGLONG perfCount,
00143           [in] LPCOLESTR pszGuidApp,
00144           [in] LPCOLESTR pszGuidTxID,
00145           [in] LPCOLESTR pszGuidTSID,
00146           [in] BOOL bRoot
00147         );
00148
00149     HRESULT OnTransactionPrepared(
00150           [in] LONGLONG perfCount,
00151           [in] LPCOLESTR pszGuidApp,
00152           [in] LPCOLESTR pszGuidTxID,
00153           [in] BOOL bVoteYes
00154         );
00155
00156     HRESULT OnTransactionAborted(
00157           [in] LONGLONG perfCount,
00158           [in] LPCOLESTR pszGuidApp,
00159           [in] LPCOLESTR pszGuidTxID
00160         );
00161
00162     HRESULT OnTransactionCommit(
00163           [in] LONGLONG perfCount,
00164           [in] LPCOLESTR pszGuidApp,
00165           [in] LPCOLESTR pszGuidTxID
00166         );
00167
00168     //IComMethodEvents
00169     HRESULT OnMethodCall(
00170           [in] LONGLONG perfCount,
00171           [in] LPCOLESTR pszGuidApp,
00172           [in] LPCOLESTR pszObjectID,
00173           [in] LPCOLESTR pszGuidClassID,
00174           [in] LPCOLESTR pszGuidInterfaceID,
00175           [in] LPCOLESTR pszMethod
00176         );
00177
00178     HRESULT OnMethodReturn(
00179           [in] LONGLONG perfCount,
00180           [in] LPCOLESTR pszGuidApp,
00181           [in] LPCOLESTR pszObjectID,
00182           [in] LPCOLESTR pszGuidClassID,
00183           [in] LPCOLESTR pszGuidInterfaceID,
00184           [in] LPCOLESTR pszMethod,
00185           [in] HRESULT hr,
00186           [in] LPCOLESTR pszCallTime
00187         );
00188
00189     HRESULT OnMethodException(
00190           [in] LONGLONG perfCount,
00191           [in] LPCOLESTR pszGuidApp,
00192           [in] LPCOLESTR pszObjectID,
00193           [in] LPCOLESTR pszGuidClassID,
00194           [in] LPCOLESTR pszGuidInterfaceID,
00195           [in] LPCOLESTR pszMethod
00196         );
00197
00198     //IComObjectEvents
00199     HRESULT OnObjectActivate(
00200           [in] LONGLONG perfCount,
00201           [in] LPCOLESTR pszGuidApp,
00202           [in] LPCOLESTR pszContextID,
00203           [in] LPCOLESTR pszObjectID
00204         );
00205
00206     HRESULT OnObjectDeactivate(
00207           [in] LONGLONG perfCount,
00208           [in] LPCOLESTR pszGuidApp,
00209           [in] LPCOLESTR pszContextID,
00210           [in] LPCOLESTR pszObjectID
00211         );
00212
00213     HRESULT OnDisableCommit(
00214           [in] LONGLONG perfCount,
00215           [in] LPCOLESTR pszGuidApp,
00216           [in] LPCOLESTR pszContextID
00217         );
00218
00219     HRESULT OnEnableCommit(
00220           [in] LONGLONG perfCount,
00221           [in] LPCOLESTR pszGuidApp,
00222           [in] LPCOLESTR pszContextID
00223         );
00224
00225     HRESULT OnSetComplete(
00226           [in] LONGLONG perfCount,
00227           [in] LPCOLESTR pszGuidApp,
00228           [in] LPCOLESTR pszContextID
00229         );
00230     HRESULT OnSetAbort(
00231           [in] LONGLONG perfCount,
00232           [in] LPCOLESTR pszGuidApp,
00233           [in] LPCOLESTR pszContextID
00234         );
00235
00236
00237       //IComResourceEvents
00238      HRESULT OnResourceCreate(
00239           [in] LONGLONG perfCount,
00240           [in] LPCOLESTR pszGuidApp,
00241           [in] LPCOLESTR pszObjectID,
00242           [in] LPCOLESTR pszType,
00243           [in] LPCOLESTR pszResId,
00244           [in] BOOL bEnlisted
00245         );
00246
00247     HRESULT OnResourceAllocate(
00248           [in] LONGLONG perfCount,
00249           [in] LPCOLESTR pszGuidApp,
00250           [in] LPCOLESTR pszObjectID,
00251           [in] LPCOLESTR pszType,
00252           [in] LPCOLESTR pszResId,
00253           [in] BOOL bEnlisted,
00254           [in] LPCOLESTR pszNumRated,
00255           [in] LPCOLESTR pszRating
00256         );
00257
00258     HRESULT OnResourceRecycle(
00259           [in] LONGLONG perfCount,
00260           [in] LPCOLESTR pszGuidApp,
00261           [in] LPCOLESTR pszObjectID,
00262           [in] LPCOLESTR pszType,
00263           [in] LPCOLESTR pszResId
00264         );
00265
00266     HRESULT OnResourceDestroy(
00267           [in] LONGLONG perfCount,
00268           [in] LPCOLESTR pszGuidApp,
00269           [in] LPCOLESTR pszObjectID,
00270           [in] HRESULT hResult,
00271           [in] LPCOLESTR pszType,
00272           [in] LPCOLESTR pszResId
00273         );
00274     HRESULT OnResourceTrack(
00275           [in] LONGLONG perfCount,
00276           [in] LPCOLESTR pszGuidApp,
00277           [in] LPCOLESTR pszObjectID,
00278           [in] LPCOLESTR pszType,
00279           [in] LPCOLESTR pszResId,
00280           [in] BOOL bEnlisted
00281         );
00282
00283
00284     //SecurityEvents
00285     HRESULT OnAuthenticate(
00286            [in] LONGLONG perfCount,
00287            [in] LPCOLESTR pszGuidApp,
00288            [in] LPCOLESTR pszGuidActivity,
00289            [in] LPCOLESTR pszObjectID,
00290            [in] LPCOLESTR pszGuidIID,
00291            [in] LPCOLESTR pszMethod,
00292            [in] LPCOLESTR pszOriginalUser,
00293            [in] LPCOLESTR pszDirectUser,
00294            [in] BOOL bCurrentUserInpersonatingInProc
00295         );
00296
00297     HRESULT OnAuthenticateFail(
00298            [in] LONGLONG perfCount,
00299            [in] LPCOLESTR pszGuidApp,
00300            [in] LPCOLESTR pszGuidActivity,
00301            [in] LPCOLESTR pszObjectID,
00302            [in] LPCOLESTR pszGuidIID,
00303            [in] LPCOLESTR pszMethod,
00304            [in] LPCOLESTR pszOriginalUser,
00305            [in] LPCOLESTR pszDirectUser,
00306            [in] BOOL bCurrentUserInpersonatingInProc
00307         );
00308
00309         //IComObjectPoolEvents
00310     HRESULT OnObjPoolPutObject(
00311                  [in] LONGLONG perfCount,
00312            [in] LPCOLESTR pszGuidApp,
00313              [in] LPCOLESTR pszClassID,
00314            [in] int nReason,
00315            [in] DWORD dwAvailableObjs,
00316            [in] LPCOLESTR pszObjectID
00317         );
00318
00319     HRESULT OnObjPoolGetObject(
00320           [in] LONGLONG perfCount,
00321           [in] LPCOLESTR pszGuidApp,
00322           [in] LPCOLESTR pszGuidActivityID,
00323           [in] LPCOLESTR pszClassID,
00324           [in] DWORD dwAvailableObjs,
00325           [in] LPCOLESTR pszObjectID
00326         );
00327
00328     HRESULT OnObjPoolRecycleToTx(
00329           [in] LONGLONG perfCount,
00330           [in] LPCOLESTR pszGuidApp,
00331           [in] LPCOLESTR pszGuidActivityID,
00332           [in] LPCOLESTR pszClassID,
00333           [in] LPCOLESTR pszGuidTx,
00334           [in] LPCOLESTR pszObjectID
00335         );
00336
00337     HRESULT OnObjPoolGetFromTx(
00338           [in] LONGLONG perfCount,
00339           [in] LPCOLESTR pszGuidApp,
00340           [in] LPCOLESTR pszGuidActivityID,
00341           [in] LPCOLESTR pszClassID,
00342           [in] LPCOLESTR pszGuidTx,
00343           [in] LPCOLESTR pszObjectID
00344         );
00345
00346     //IComObjectPoolEvents2
00347     HRESULT OnObjPoolCreateObject(
00348           [in] LONGLONG perfCount,
00349           [in] LPCOLESTR pszGuidApp,
00350           [in] LPCOLESTR pszClassID,
00351           [in] DWORD dwAvailableObjs,
00352           [in] LPCOLESTR pszObjectID
00353         );
00354
00355     HRESULT OnObjPoolDestroyObject(
00356           [in] LONGLONG perfCount,
00357           [in] LPCOLESTR pszGuidApp,
00358           [in] LPCOLESTR pszClassID,
00359           [in] DWORD dwAvailableObjs,
00360           [in] LPCOLESTR pszObjectID
00361         );
00362
00363     HRESULT OnObjPoolCreateDecision(
00364           [in] LONGLONG perfCount,
00365           [in] LPCOLESTR pszGuidApp,
00366           [in] DWORD dwThreadsWaiting,
00367           [in] DWORD dwAvailableObjs,
00368           [in] DWORD dwCreatedObjs,
00369           [in] DWORD dwMin,
00370           [in] DWORD dwMax
00371         );
00372
00373     HRESULT OnObjPoolTimeout(
00374           [in] LONGLONG perfCount,
00375           [in] LPCOLESTR pszGuidApp,
00376           [in] LPCOLESTR pszClassID,
00377           [in] LPCOLESTR pszGuidActivityID,
00378           [in] DWORD dwTimeout);
00379
00380     HRESULT OnObjPoolCreatePool(
00381           [in] LONGLONG perfCount,
00382           [in] LPCOLESTR pszGuidApp,
00383           [in] LPCOLESTR pszClassID,
00384           [in] DWORD dwMin,
00385           [in] DWORD dwMax,
00386           [in] DWORD dwTimeout
00387         );
00388
00389     //IComObjectConstructionEvents
00390     HRESULT OnObjectConstruct(
00391           [in] LONGLONG perfCount,
00392           [in] LPCOLESTR pszGuidApp,
00393           [in] LPCOLESTR pszClassID,
00394           [in] LPCOLESTR pszConstructString,
00395           [in] LPCOLESTR pszObjectID
00396         );
00397
00398
00399     //IComActivityEvents
00400     HRESULT OnActivityCreate(
00401           [in] LONGLONG perfCount,
00402           [in] LPCOLESTR pszGuidApp,
00403           [in] LPCOLESTR pszGuidActivityID
00404         );
00405
00406     HRESULT OnActivityDestroy(
00407           [in] LONGLONG perfCount,
00408           [in] LPCOLESTR pszGuidApp,
00409           [in] LPCOLESTR pszGuidActivityID
00410         );
00411
00412     HRESULT OnActivityEnter(
00413           [in] LONGLONG perfCount,
00414           [in] LPCOLESTR pszGuidApp,
00415           [in] LPCOLESTR pszGuidCurrentApp,
00416           [in] LPCOLESTR pszGuidEnteredApp,
00417           [in] LPCOLESTR pszW2KThreadID
00418         );
00419
00420     HRESULT OnActivityTimeout(
00421           [in] LONGLONG perfCount,
00422           [in] LPCOLESTR pszGuidApp,
00423           [in] LPCOLESTR pszGuidCurrentApp,
00424           [in] LPCOLESTR pszGuidEnteredApp,
00425           [in] LPCOLESTR pszW2KThreadID,
00426           [in] DWORD dwTimeout
00427         );
00428
00429     HRESULT OnActivityReenter(
00430           [in] LONGLONG perfCount,
00431           [in] LPCOLESTR pszGuidApp,
00432           [in] LPCOLESTR pszGuidCurrentApp,
00433           [in] LPCOLESTR pszW2KThreadID,
00434           [in] DWORD dwCallDepth
00435         );
00436
00437     HRESULT OnActivityLeave(
00438           [in] LONGLONG perfCount,
00439           [in] LPCOLESTR pszGuidApp,
00440           [in] LPCOLESTR pszGuidCurrentApp,
00441           [in] LPCOLESTR pszGuidLeftApp
00442         );
00443
00444     HRESULT OnActivityLeaveSame(
00445           [in] LONGLONG perfCount,
00446           [in] LPCOLESTR pszGuidApp,
00447           [in] LPCOLESTR pszGuidCurrentApp,
00448           [in] DWORD dwCallDepth
00449         );
00450
00451     //IComIdentityEvents
00452     HRESULT OnIISRequestInfo(
00453           [in] LONGLONG perfCount,
00454           [in] LPCOLESTR pszGuidApp,
00455           [in] LPCOLESTR pszObjectID,
00456           [in] LPCOLESTR pszClientIP,
00457           [in] LPCOLESTR pszServerIP,
00458           [in] LPCOLESTR pszURL
00459         );
00460
00461     //IComQCEvents
00462     HRESULT OnQCRecord(
00463           [in] LONGLONG perfCount,
00464           [in] LPCOLESTR pszGuidApp,
00465           [in] LPCOLESTR pszObjectID,
00466           [in] LPCOLESTR pszQueueName,
00467           [in] LPCOLESTR pszGuidMsgID,
00468           [in] LPCOLESTR pszGuidWorkFlowID,
00469           [in] HRESULT hr
00470         );
00471     HRESULT OnQCQueueOpen(
00472           [in] LONGLONG perfCount,
00473           [in] LPCOLESTR pszGuidApp,
00474           [in] LPCOLESTR pszQueueName,
00475           [in] LPCOLESTR pszQueueID,
00476           [in] HRESULT hr
00477         );
00478     HRESULT OnQCReceive(
00479           [in] LONGLONG perfCount,
00480           [in] LPCOLESTR pszGuidApp,
00481           [in] LPCOLESTR pszQueueID,
00482           [in] LPCOLESTR pszGuidMsgID,
00483           [in] LPCOLESTR pszGuidWorkFlowID,
00484           [in] HRESULT hr
00485         );
00486     HRESULT OnQCReceiveFail(
00487           [in] LONGLONG perfCount,
00488           [in] LPCOLESTR pszGuidApp,
00489           [in] LPCOLESTR pszQueueID,
00490           [in] HRESULT hr
00491         );
00492     HRESULT OnQCMoveToReTryQueue(
00493           [in] LONGLONG perfCount,
00494           [in] LPCOLESTR pszGuidApp,
00495           [in] LPCOLESTR pszGuidMsgID,
00496           [in] LPCOLESTR pszGuidWorkFlowID,
00497           [in] ULONG RetryIndex
00498         );
00499     HRESULT OnQCMoveToDeadQueue(
00500           [in] LONGLONG perfCount,
00501           [in] LPCOLESTR pszGuidApp,
00502           [in] LPCOLESTR pszGuidMsgID,
00503           [in] LPCOLESTR pszGuidWorkFlowID
00504         );
00505     HRESULT OnQCPlayback(
00506           [in] LONGLONG perfCount,
00507           [in] LPCOLESTR pszGuidApp,
00508           [in] LPCOLESTR pszObjectID,
00509           [in] LPCOLESTR pszGuidMsgID,
00510           [in] LPCOLESTR pszGuidWorkFlowID,
00511           [in] HRESULT hr
00512         );
00513
00514     //IComExceptionEvents
00515     HRESULT OnExceptionUser(
00516           [in] LONGLONG perfCount,
00517           [in] LPCOLESTR pszGuidApp,
00518           [in] LPCOLESTR pszCode,
00519           [in] LPCOLESTR pszAddress,
00520           [in] LPCOLESTR pszStackTrace
00521         );
00522
00523     //IComCRMEvents
00524     HRESULT OnCRMRecoveryStart(
00525           [in] LONGLONG perfCount,
00526           [in] LPCOLESTR pszGuidApp
00527         );
00528
00529     HRESULT OnCRMRecoveryDone(
00530           [in] LONGLONG perfCount,
00531           [in] LPCOLESTR pszGuidApp
00532         );
00533
00534     HRESULT OnCRMCheckpoint(
00535           [in] LONGLONG perfCount,
00536           [in] LPCOLESTR pszGuidApp
00537         );
00538
00539     HRESULT OnCRMBegin(
00540           [in] LONGLONG perfCount,
00541           [in] LPCOLESTR pszGuidApp,
00542           [in] LPCOLESTR pszGuidClerkCLSID,
00543           [in] LPCOLESTR pszGuidActivityID,
00544           [in] LPCOLESTR pszGuidTxUOWID,
00545           [in] LPCOLESTR pszProgIdCompensator,
00546           [in] LPCOLESTR pszDescription
00547         );
00548
00549     HRESULT OnCRMPrepare(
00550           [in] LONGLONG perfCount,
00551           [in] LPCOLESTR pszGuidApp,
00552           [in] LPCOLESTR pszGuidClerkCLSID
00553         );
00554
00555     HRESULT OnCRMCommit(
00556           [in] LONGLONG perfCount,
00557           [in] LPCOLESTR pszGuidApp,
00558           [in] LPCOLESTR pszGuidClerkCLSID
00559         );
00560
00561     HRESULT OnCRMAbort(
00562           [in] LONGLONG perfCount,
00563           [in] LPCOLESTR pszGuidApp,
00564           [in] LPCOLESTR pszGuidClerkCLSID
00565         );
00566
00567     HRESULT OnCRMIndoubt(
00568           [in] LONGLONG perfCount,
00569           [in] LPCOLESTR pszGuidApp,
00570           [in] LPCOLESTR pszGuidClerkCLSID
00571         );
00572
00573     HRESULT OnCRMDone(
00574           [in] LONGLONG perfCount,
00575           [in] LPCOLESTR pszGuidApp,
00576           [in] LPCOLESTR pszGuidClerkCLSID
00577         );
00578
00579     HRESULT OnCRMRelease(
00580           [in] LONGLONG perfCount,
00581           [in] LPCOLESTR pszGuidApp,
00582           [in] LPCOLESTR pszGuidClerkCLSID
00583         );
00584
00585     HRESULT OnCRMAnalyze(
00586           [in] LONGLONG perfCount,
00587           [in] LPCOLESTR pszGuidApp,
00588           [in] LPCOLESTR pszGuidClerkCLSID,
00589           [in] LPCOLESTR pszCrmRecordType,
00590           [in] DWORD dwRecordSize
00591         );
00592
00593     HRESULT OnCRMWrite(
00594           [in] LONGLONG perfCount,
00595           [in] LPCOLESTR pszGuidApp,
00596           [in] LPCOLESTR pszGuidClerkCLSID,
00597           [in] BOOL bVariants,
00598           [in] DWORD dwRecordSize);
00599
00600     HRESULT OnCRMForget(
00601           [in] LONGLONG perfCount,
00602           [in] LPCOLESTR pszGuidApp,
00603           [in] LPCOLESTR pszGuidClerkCLSID
00604         );
00605
00606     HRESULT OnCRMForce(
00607           [in] LONGLONG perfCount,
00608           [in] LPCOLESTR pszGuidApp,
00609           [in] LPCOLESTR pszGuidClerkCLSID
00610         );
00611
00612     HRESULT OnCRMDeliver(
00613           [in] LONGLONG perfCount,
00614           [in] LPCOLESTR pszGuidApp,
00615           [in] LPCOLESTR pszGuidClerkCLSID,
00616           [in] BOOL bVariants,
00617           [in] DWORD dwRecordSize
00618         );
00619
00620     //ILBEvents
00621         HRESULT TargetUp(
00622         [in] LONGLONG perfCount,
00623         [in] LPCOLESTR pszServerName,
00624         [in] LPCOLESTR pszClsidEng
00625       );
00626
00627     HRESULT TargetDown(
00628         [in] LONGLONG perfCount,
00629         [in] LPCOLESTR pszServerName,
00630         [in] LPCOLESTR pszClsidEng
00631       );
00632
00633         HRESULT  EngineDefined(
00634         [in] LONGLONG perfCount,
00635         [in] LPCOLESTR pszPropName,
00636         [in] VARIANT *varPropValue,
00637         [in] LPCOLESTR pszClsidEng
00638       );
00639
00640
00641       ////
00642     HRESULT Init(LPCOLESTR sDSN, LPCOLESTR sUser, LPCOLESTR sPw);
00643   };
00644 [
00645   uuid(AFCF0615-1429-11D1-B1B8-00AA00BA3258),
00646   version(1.0),
00647   helpstring("ComSpyAudit 1.0 Type Library")
00648 ]
00649 library COMSPYAUDITLib
00650 {
00651   importlib("stdole32.tlb");
00652   importlib("stdole2.tlb");
00653
00654   [
00655     uuid(AFCF0623-1429-11D1-B1B8-00AA00BA3258),
00656     helpstring("ComSpyAudit Class")
00657   ]
00658   coclass ComSpyAudit
00659   {
00660     [default] interface IComSpyAudit;
00661   };
00662 };
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/statnode.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

statnode.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "StatNode.h"
00021
00022 #include "People.h"
00023 #include "Sky.h"
00024 #include "Land.h"
00025 #include "Space.h"
00026
00027 const GUID CStaticNode::thisGuid = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00028
00029 //==============================================================
00030 //
00031 // CStaticNode implementation
00032 //
00033 //
00034 CStaticNode::CStaticNode(CComponentData *pComponentData)
00035 {
00036     m_pComponentData = pComponentData;
00037
00038     children[0] = new CPeoplePoweredVehicle(pComponentData);
00039     children[1] = new CLandBasedVehicle(pComponentData);
00040     children[2] = new CSkyBasedVehicle(pComponentData);
00041     children[3] = new CSpaceVehicle(pComponentData);
00042 }
00043
00044 CStaticNode::~CStaticNode()
00045 {
00046     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00047         if (children[n]) {
00048             delete children[n];
00049         }
00050 }
00051
00052 HRESULT CStaticNode::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00053 {
00054     SCOPEDATAITEM sdi;
00055
00056     if (!bExpanded) {
00057         // create the child nodes, then expand them
00058         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00059             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00060             sdi.mask = SDI_STR       |   // Displayname is valid
00061                 SDI_PARAM     |   // lParam is valid
00062                 SDI_IMAGE     |   // nImage is valid
00063                 SDI_OPENIMAGE |   // nOpenImage is valid
00064                 SDI_PARENT    |
00065                 SDI_CHILDREN;
00066
00067             sdi.relativeID  = (HSCOPEITEM)parent;
00068             sdi.nImage      = children[n]->GetBitmapIndex();
00069             sdi.nOpenImage  = INDEX_OPENFOLDER;
00070             sdi.displayname = MMC_CALLBACK;
00071             sdi.lParam      = (LPARAM)children[n];       // The cookie
00072             sdi.cChildren   = (n == 0); // only the first child has children
00073             // in this sample
00074
00075             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00076
00077             _ASSERT( SUCCEEDED(hr) );
00078         }
00079
00080         bExpanded = TRUE;
00081     }
00082
00083     return S_OK;
00084 }
00085
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/RenderBehave/renderproject/Stdafx.cpp Source File

  • Web
  • Browser
  • RenderBehave
  • renderproject

Stdafx.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.cpp : source file that includes just the standard includes
00006 //  stdafx.pch will be the pre-compiled header
00007 //  stdafx.obj will contain the pre-compiled type information
00008
00009 #include "stdafx.h"
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Explore.VC/VCExplore.Cpp Source File

  • Com
  • Administration
  • Explore.VC

VCExplore.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018
00019 #include "stdafx.h"
00020 #include "VCExplore.h"
00021 #include "VCExploreDlg.h"
00022
00023
00024 #ifdef _DEBUG
00025 #define new DEBUG_NEW
00026 #undef THIS_FILE
00027 static char THIS_FILE[] = __FILE__;
00028 #endif
00029
00030 extern g_pCurrCatalog;
00031 extern g_pCurrCollection;
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 // CVCExploreApp
00035
00036 BEGIN_MESSAGE_MAP(CVCExploreApp, CWinApp)
00037   //{{AFX_MSG_MAP(CVCExploreApp)
00038     // NOTE - the ClassWizard will add and remove mapping macros here.
00039     //    DO NOT EDIT what you see in these blocks of generated code!
00040   //}}AFX_MSG
00041   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00042 END_MESSAGE_MAP()
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // CVCExploreApp construction
00046
00047 CVCExploreApp::CVCExploreApp()
00048 {
00049   // TODO: add construction code here,
00050   // Place all significant initialization in InitInstance
00051 }
00052
00053 /////////////////////////////////////////////////////////////////////////////
00054 // The one and only CVCExploreApp object
00055
00056 CVCExploreApp theApp;
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // CVCExploreApp initialization
00060
00061 BOOL CVCExploreApp::InitInstance()
00062 {
00063   AfxEnableControlContainer();
00064
00065   // Standard initialization
00066   // If you are not using these features and wish to reduce the size
00067   //  of your final executable, you should remove from the following
00068   //  the specific initialization routines you do not need.
00069
00070 #ifdef _AFXDLL
00071   Enable3dControls();     // Call this when using MFC in a shared DLL
00072 #else
00073   Enable3dControlsStatic(); // Call this when linking to MFC statically
00074 #endif
00075
00076   // Attempt to get a reference to current catalog
00077   //_bstr_t bstrCollectionName = "Root";
00078   //g_pCurrCatalog = new ICatalog;
00079   //g_pCurrCollection = g_pCurrCatalog->GetCollection(bstrCollectionName);
00080
00081   CVCExploreDlg dlg;
00082   m_pMainWnd = &dlg;
00083   dlg.DoModal();
00084
00085   // Since the dialog has been closed, return FALSE so that we exit the
00086   //  application, rather than start the application's message pump.
00087   return FALSE;
00088 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/GSS/GssClient.c Source File

  • Security
  • SSPI
  • GSS

GssClient.c

Go to the documentation of this file.
00001 /*
00002  * Copyright 1994 by OpenVision Technologies, Inc.
00003  *
00004  * Permission to use, copy, modify, distribute, and sell this software
00005  * and its documentation for any purpose is hereby granted without fee,
00006  * provided that the above copyright notice appears in all copies and
00007  * that both that copyright notice and this permission notice appear in
00008  * supporting documentation, and that the name of OpenVision not be used
00009  * in advertising or publicity pertaining to distribution of the software
00010  * without specific, written prior permission. OpenVision makes no
00011  * representations about the suitability of this software for any
00012  * purpose.  It is provided "as is" without express or implied warranty.
00013  *
00014  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00015  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
00016  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00017  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
00018  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
00019  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00020  * PERFORMANCE OF THIS SOFTWARE.
00021  */
00022
00023
00024 #include "gss-misc.h"
00025
00026 int SignOnly = FALSE;
00027
00028 void usage()
00029 {
00030    fprintf(stderr,
00031     "Usage: gssclient [-port port] [-sign] [-d] host service msg\n");
00032    exit(1);
00033 }
00034
00035 /*
00036  * Function: connect_to_server
00037  *
00038  * Purpose: Opens a TCP connection to the name host and port.
00039  *
00040  * Arguments:
00041  *
00042  *      host            (r) the target host name
00043  *      port            (r) the target port, in host byte order
00044  *
00045  * Returns: the established socket file desciptor, or -1 on failure
00046  *
00047  * Effects:
00048  *
00049  * The host name is resolved with gethostbyname(), and the socket is
00050  * opened and connected.  If an error occurs, an error message is
00051  * displayed and -1 is returned.
00052  */
00053 int connect_to_server(host, port)
00054 char *host;
00055 u_short port;
00056 {
00057    struct sockaddr_in saddr;
00058    struct hostent *hp;
00059    int s;
00060    int err;
00061    WSADATA socket_data;
00062    USHORT version_required = 0x0101;
00063
00064
00065    err = WSAStartup(version_required, &socket_data);
00066    if (err)
00067    {
00068       fprintf(stderr,"Failed to initailize WSA: %d\n",err);
00069       return (-1);
00070    }
00071
00072
00073    if ((hp = gethostbyname(host)) == NULL)
00074    {
00075       fprintf(stderr, "Unknown host: %s\n", host);
00076       return -1;
00077    }
00078
00079    saddr.sin_family = hp->h_addrtype;
00080    memcpy((char *)&saddr.sin_addr, hp->h_addr, sizeof(saddr.sin_addr));
00081    saddr.sin_port = htons(port);
00082
00083    if ((s = (int)socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
00084    {
00085       fprintf(stderr, "creating socket - %x", GetLastError());
00086       return -1;
00087    }
00088
00089    if (connect(s, (struct sockaddr *)&saddr, sizeof(saddr)) == SOCKET_ERROR)
00090    {
00091       fprintf(stderr, "connecting to server - %x", GetLastError());
00092       (void) closesocket(s);
00093       return -1;
00094    }
00095    return s;
00096 }
00097
00098 /*
00099  * Function: client_establish_context
00100  *
00101  * Purpose: establishes a GSS-API context with a specified service and
00102  * returns the context handle
00103  *
00104  * Arguments:
00105  *
00106  *      s               (r) an established TCP connection to the service
00107  *      service_name    (r) the ASCII service name of the service
00108  *      context         (w) the established GSS-API context
00109  *      ret_flags       (w) the returned flags from init_sec_context
00110  *
00111  * Returns: 0 on success, -1 on failure
00112  *
00113  * Effects:
00114  *
00115  * service_name is imported as a GSS-API name and a GSS-API context is
00116  * established with the corresponding service; the service should be
00117  * listening on the TCP connection s.  The default GSS-API mechanism
00118  * is used, and mutual authentication and replay detection are
00119  * requested.
00120  *
00121  * If successful, the context handle is returned in context.  If
00122  * unsuccessful, the GSS-API error messages are displayed on stderr
00123  * and -1 is returned.
00124  */
00125 int client_establish_context(s, service_name, deleg_flag,
00126                              gss_context, ret_flags)
00127 int s;
00128 char *service_name;
00129 OM_uint32 deleg_flag;
00130 CtxtHandle *gss_context;
00131 OM_uint32 *ret_flags;
00132 {
00133    SecBuffer send_tok, recv_tok;
00134    SecBufferDesc input_desc, output_desc;
00135    OM_uint32 maj_stat;
00136    CredHandle cred_handle;
00137    TimeStamp expiry;
00138    PCtxtHandle context_handle = NULL;
00139
00140
00141    input_desc.cBuffers = 1;
00142    input_desc.pBuffers = &recv_tok;
00143    input_desc.ulVersion = SECBUFFER_VERSION;
00144
00145    recv_tok.BufferType = SECBUFFER_TOKEN;
00146    recv_tok.cbBuffer = 0;
00147    recv_tok.pvBuffer = NULL;
00148
00149    output_desc.cBuffers = 1;
00150    output_desc.pBuffers = &send_tok;
00151    output_desc.ulVersion = SECBUFFER_VERSION;
00152
00153    send_tok.BufferType = SECBUFFER_TOKEN;
00154    send_tok.cbBuffer = 0;
00155    send_tok.pvBuffer = NULL;
00156
00157    cred_handle.dwLower = 0;
00158    cred_handle.dwUpper = 0;
00159
00160    maj_stat = AcquireCredentialsHandle(
00161                                       NULL,                       // no principal name
00162                                       "Kerberos",                 // package name
00163                                       SECPKG_CRED_OUTBOUND,
00164                                       NULL,                       // no logon id
00165                                       NULL,                       // no auth data
00166                                       NULL,                       // no get key fn
00167                                       NULL,                       // noget key arg
00168                                       &cred_handle,
00169                                       &expiry
00170                                       );
00171    if (maj_stat != SEC_E_OK)
00172    {
00173       display_status("acquiring credentials",maj_stat,0);
00174       return (-1);
00175    }
00176
00177    /*
00178     * Perform the context-establishement loop.
00179     */
00180
00181    gss_context->dwLower = 0;
00182    gss_context->dwUpper = 0;
00183
00184    do
00185    {
00186       maj_stat =
00187       InitializeSecurityContext(
00188                                &cred_handle,
00189                                context_handle,
00190                                service_name,
00191                                deleg_flag,
00192                                0,          // reserved
00193                                SECURITY_NATIVE_DREP,
00194                                &input_desc,
00195                                0,          // reserved
00196                                gss_context,
00197                                &output_desc,
00198                                ret_flags,
00199                                &expiry
00200                                );
00201
00202       if (recv_tok.pvBuffer)
00203       {
00204          free(recv_tok.pvBuffer);
00205          recv_tok.pvBuffer = NULL;
00206          recv_tok.cbBuffer = 0;
00207
00208       }
00209
00210       context_handle = gss_context;
00211
00212       if (maj_stat!=SEC_E_OK && maj_stat!=SEC_I_CONTINUE_NEEDED)
00213       {
00214          display_status("initializing context", maj_stat, 0);
00215          FreeCredentialsHandle(&cred_handle);
00216          return -1;
00217       }
00218
00219       if (send_tok.cbBuffer != 0)
00220       {
00221          printf("Sending init_sec_context token (size=%d)...",
00222                 send_tok.cbBuffer);
00223          if (send_token(s, &send_tok) < 0)
00224          {
00225             FreeContextBuffer(send_tok.pvBuffer);
00226             FreeCredentialsHandle(&cred_handle);
00227             return -1;
00228          }
00229       }
00230
00231       FreeContextBuffer(send_tok.pvBuffer);
00232       send_tok.pvBuffer = NULL;
00233       send_tok.cbBuffer = 0;
00234
00235       if (maj_stat == SEC_I_CONTINUE_NEEDED)
00236       {
00237          printf("continue needed...");
00238          if (recv_token(s, &recv_tok) < 0)
00239          {
00240             FreeCredentialsHandle(&cred_handle);
00241             return -1;
00242          }
00243       }
00244       printf("\n");
00245
00246    } while (maj_stat == SEC_I_CONTINUE_NEEDED);
00247
00248    FreeCredentialsHandle(&cred_handle);
00249    return 0;
00250 }
00251
00252 void read_file(file_name, in_buf)
00253 char                *file_name;
00254 PSecBuffer          in_buf;
00255 {
00256    int fd;
00257    ULONG bytes_in, count;
00258    UCHAR buf[100];
00259
00260    //
00261    // readthrough once to get the size.
00262    //
00263
00264    if ((fd = _open(file_name, O_RDONLY, 0)) < 0)
00265    {
00266       perror("open");
00267       fprintf(stderr, "Couldn't open file %s\n", file_name);
00268       exit(1);
00269    }
00270
00271    for (bytes_in = 0; ; bytes_in += count)
00272    {
00273       count = _read(fd, buf, sizeof(buf));
00274       if (count < 0)
00275       {
00276          fprintf(stderr, "read - %x", GetLastError());
00277          exit(1);
00278       }
00279       if (count == 0)
00280          break;
00281    }
00282    _close(fd);
00283
00284    if ((fd = _open(file_name, O_RDONLY, 0)) < 0)
00285    {
00286       perror("open");
00287       fprintf(stderr, "Couldn't open file %s\n", file_name);
00288       exit(1);
00289    }
00290
00291    in_buf->cbBuffer = bytes_in;
00292    in_buf->pvBuffer = malloc(in_buf->cbBuffer);
00293
00294    if (in_buf->pvBuffer == 0)
00295    {
00296       fprintf(stderr, "Couldn't allocate %d byte buffer for reading file\n",
00297               in_buf->cbBuffer);
00298       exit(1);
00299    }
00300
00301    memset(in_buf->pvBuffer, 0, in_buf->cbBuffer);
00302
00303    for (bytes_in = 0; bytes_in < in_buf->cbBuffer; bytes_in += count)
00304    {
00305       count = _read(fd, (PUCHAR) in_buf->pvBuffer+bytes_in, in_buf->cbBuffer-bytes_in);
00306       if (count < 0)
00307       {
00308          fprintf(stderr, "read - %x", GetLastError());
00309          exit(1);
00310       }
00311       if (count == 0)
00312          break;
00313    }
00314
00315    if (bytes_in != count)
00316       fprintf(stderr, "Warning, only read in %d bytes, expected %d\n",
00317               bytes_in, count);
00318 }
00319
00320 /*
00321  * Function: call_server
00322  *
00323  * Purpose: Call the "sign" service.
00324  *
00325  * Arguments:
00326  *
00327  *      host            (r) the host providing the service
00328  *      port            (r) the port to connect to on host
00329  *      service_name    (r) the GSS-API service name to authenticate to
00330  *      msg             (r) the message to have "signed"
00331  *
00332  * Returns: 0 on success, -1 on failure
00333  *
00334  * Effects:
00335  *
00336  * call_server opens a TCP connection to <host:port> and establishes a
00337  * GSS-API context with service_name over the connection.  It then
00338  * seals msg in a GSS-API token with gss_seal, sends it to the server,
00339  * reads back a GSS-API signature block for msg from the server, and
00340  * verifies it with gss_verify.  -1 is returned if any step fails,
00341  * otherwise 0 is returned.
00342  */
00343 int call_server(host, port, service_name, deleg_flag, msg, use_file)
00344 char *host;
00345 u_short port;
00346 char *service_name;
00347 OM_uint32 deleg_flag;
00348 char *msg;
00349 int use_file;
00350 {
00351    CtxtHandle context;
00352    SecBuffer in_buf, out_buf;
00353    SecBuffer wrap_bufs[3];
00354    SecBufferDesc in_buf_desc;
00355    SecPkgContext_Sizes sizes;
00356    int s;
00357    OM_uint32 ret_flags;
00358    OM_uint32 maj_stat;
00359    gss_qop_t qop_state;
00360
00361    /* Open connection */
00362    if ((s = connect_to_server(host, port)) < 0)
00363       return -1;
00364
00365    /* Establish context */
00366    if (client_establish_context(s, service_name, deleg_flag,  &context,
00367                                 &ret_flags) < 0)
00368    {
00369       (void) closesocket(s);
00370       return -1;
00371    }
00372
00373    maj_stat = QueryContextAttributes(
00374                                     &context,
00375                                     SECPKG_ATTR_SIZES,
00376                                     &sizes
00377                                     );
00378    if (maj_stat != SEC_E_OK)
00379    {
00380       display_status("querying context attributes", maj_stat, 0);
00381       return (-1);
00382    }
00383
00384    if (use_file)
00385    {
00386       read_file(msg, &in_buf);
00387    }
00388    else
00389    {
00390       /* Seal the message */
00391       in_buf.pvBuffer = msg;
00392       in_buf.cbBuffer = (ULONG)strlen(msg) + 1;
00393    }
00394
00395    //
00396    // Prepare to encrypt the message
00397    //
00398
00399    printf("Block Size is %d, inbuffer = %d\n",
00400           sizes.cbBlockSize, in_buf.cbBuffer);
00401
00402    in_buf_desc.cBuffers = 3;
00403    in_buf_desc.pBuffers = wrap_bufs;
00404    in_buf_desc.ulVersion = SECBUFFER_VERSION;
00405
00406    wrap_bufs[0].cbBuffer = sizes.cbSecurityTrailer;
00407    wrap_bufs[0].BufferType = SECBUFFER_TOKEN;
00408    wrap_bufs[0].pvBuffer = malloc(sizes.cbSecurityTrailer);
00409
00410    if (wrap_bufs[0].pvBuffer == NULL)
00411    {
00412       fprintf(stderr,"Failed to allocate space for security trailer\n");
00413       return (-1);
00414    }
00415
00416    wrap_bufs[1].BufferType = SECBUFFER_DATA;
00417    wrap_bufs[1].cbBuffer = in_buf.cbBuffer;
00418    wrap_bufs[1].pvBuffer = malloc(wrap_bufs[1].cbBuffer);
00419
00420    if (wrap_bufs[1].pvBuffer == NULL)
00421    {
00422       fprintf(stderr,"Couldn't allocate space for wrap message\n");
00423       return (-1);
00424    }
00425
00426    memcpy(
00427          wrap_bufs[1].pvBuffer,
00428          in_buf.pvBuffer,
00429          in_buf.cbBuffer
00430          );
00431
00432    wrap_bufs[2].BufferType = SECBUFFER_PADDING;
00433    wrap_bufs[2].cbBuffer = sizes.cbBlockSize;
00434    wrap_bufs[2].pvBuffer = malloc(wrap_bufs[2].cbBuffer);
00435
00436    if (wrap_bufs[2].pvBuffer == NULL)
00437    {
00438       fprintf(stderr,"Couldn't allocate space for wrap message\n");
00439       return (-1);
00440    }
00441
00442
00443
00444    maj_stat = EncryptMessage(
00445                             &context,
00446                             SignOnly ? KERB_WRAP_NO_ENCRYPT : 0,
00447                             &in_buf_desc,
00448                             0);
00449
00450
00451    if (maj_stat != SEC_E_OK)
00452    {
00453       display_status("sealing message", maj_stat, 0);
00454       (void) closesocket(s);
00455       (void) DeleteSecurityContext(&context);
00456       return -1;
00457    }
00458
00459    //
00460    // Create the mesage to send to server
00461    //
00462
00463    out_buf.cbBuffer = wrap_bufs[0].cbBuffer + wrap_bufs[1].cbBuffer + wrap_bufs[2].cbBuffer;
00464    out_buf.pvBuffer = malloc(out_buf.cbBuffer);
00465
00466    if (out_buf.pvBuffer == NULL)
00467    {
00468       fprintf(stderr,"Failed to allocate space for wrapepd message\n");
00469       return (-1);
00470    }
00471
00472    memcpy(
00473          out_buf.pvBuffer,
00474          wrap_bufs[0].pvBuffer,
00475          wrap_bufs[0].cbBuffer
00476          );
00477    memcpy(
00478          (PUCHAR) out_buf.pvBuffer + (int) wrap_bufs[0].cbBuffer,
00479          wrap_bufs[1].pvBuffer,
00480          wrap_bufs[1].cbBuffer
00481          );
00482    memcpy(
00483          (PUCHAR) out_buf.pvBuffer + wrap_bufs[0].cbBuffer + wrap_bufs[1].cbBuffer,
00484          wrap_bufs[2].pvBuffer,
00485          wrap_bufs[2].cbBuffer
00486          );
00487
00488    /* Send to server */
00489    if (send_token(s, &out_buf) < 0)
00490    {
00491       (void) closesocket(s);
00492       (void) DeleteSecurityContext(&context);
00493       return -1;
00494    }
00495
00496    free(out_buf.pvBuffer);
00497    out_buf.pvBuffer = NULL;
00498    out_buf.cbBuffer = 0;
00499    free(wrap_bufs[0].pvBuffer);
00500    wrap_bufs[0].pvBuffer = NULL;
00501    free(wrap_bufs[1].pvBuffer);
00502    wrap_bufs[1].pvBuffer = NULL;
00503
00504    /* Read signature block into out_buf */
00505    if (recv_token(s, &out_buf) < 0)
00506    {
00507       (void) closesocket(s);
00508       (void) DeleteSecurityContext( &context);
00509       return -1;
00510    }
00511
00512    /* Verify signature block */
00513
00514    in_buf_desc.cBuffers = 2;
00515    wrap_bufs[0] = in_buf;
00516    wrap_bufs[0].BufferType = SECBUFFER_DATA;
00517    wrap_bufs[1] = out_buf;
00518    wrap_bufs[1].BufferType = SECBUFFER_TOKEN;
00519
00520    maj_stat = VerifySignature(&context, &in_buf_desc, 0, &qop_state);
00521    if (maj_stat != SEC_E_OK)
00522    {
00523       display_status("verifying signature", maj_stat, 0);
00524       (void) closesocket(s);
00525       (void) DeleteSecurityContext( &context);
00526       return -1;
00527    }
00528    free(out_buf.pvBuffer);
00529
00530    if (use_file)
00531       free(in_buf.pvBuffer);
00532
00533    printf("Signature verified.\n");
00534
00535    /* Delete context */
00536    maj_stat = DeleteSecurityContext(&context);
00537    if (maj_stat != SEC_E_OK)
00538    {
00539       display_status("deleting context", maj_stat, 0);
00540       (void) closesocket(s);
00541       return -1;
00542    }
00543
00544    (void) closesocket(s);
00545    return 0;
00546 }
00547
00548
00549 int _cdecl main(argc, argv)
00550 int argc;
00551 char **argv;
00552 {
00553    char *service_name, *server_host, *msg;
00554    char *mechanism = 0;
00555    u_short port = 4444;
00556    int use_file = 0;
00557    int  i;
00558
00559    OM_uint32 deleg_flag = ( ISC_REQ_MUTUAL_AUTH |
00560                             ISC_REQ_ALLOCATE_MEMORY |
00561                             ISC_REQ_CONFIDENTIALITY |
00562                             ISC_REQ_REPLAY_DETECT);
00563    FLAGMAPPING FlagMappings[] = {
00564 #define DUPE( x ) { "-" #x, ISC_REQ_ ## x, "ISC_REQ_"#x }
00565
00566       DUPE( CONFIDENTIALITY ),
00567       DUPE( DELEGATE ),
00568       DUPE( INTEGRITY ),
00569       DUPE( USE_SESSION_KEY ),
00570       DUPE( REPLAY_DETECT ),
00571       DUPE( SEQUENCE_DETECT ),
00572       DUPE( MUTUAL_AUTH )
00573    };
00574
00575    display_file = stdout;
00576
00577    /* Parse arguments. */
00578    argc--; argv++;
00579    while (argc)
00580    {
00581
00582       if (strcmp(*argv, "-port") == 0)
00583       {
00584          argc--; argv++;
00585          if (!argc) usage();
00586          port = (u_short)atoi(*argv);
00587       }
00588       else if (strcmp(*argv, "-sign") == 0)
00589       {
00590          SignOnly = TRUE;
00591       }
00592       else if (strcmp(*argv, "-mech") == 0)
00593       {
00594          argc--; argv++;
00595          if (!argc) usage();
00596          mechanism = *argv;
00597       }
00598       else if ( _strcmpi(*argv, "-d") == 0 )
00599       {
00600          deleg_flag |= ISC_REQ_DELEGATE;
00601
00602       }
00603       else
00604       {
00605
00606          /*
00607           * Search for flags to use along the command line.
00608           * We do this so that we can determine what, if any,
00609           * flags are busted.
00610           */
00611
00612          BOOL found = FALSE;
00613
00614          for ( i = 0 ;
00615              i < ( sizeof( FlagMappings ) /
00616                    sizeof( FLAGMAPPING ) ) ;
00617              i ++ )
00618          {
00619
00620             if ( _strcmpi( *argv, FlagMappings[ i ].name ) == 0 )
00621             {
00622
00623                found = TRUE;
00624                deleg_flag |= FlagMappings[ i ].value ;
00625                printf( "adding flag %hs (0x%x).\n",
00626                        FlagMappings[ i ].name +1,
00627                        FlagMappings[ i ].value );
00628                break;
00629
00630             }
00631          }
00632
00633          if ( !found )
00634          {
00635
00636             break;
00637
00638          }
00639       }
00640       argc--; argv++;
00641    }
00642
00643    if ( argc != 3 ) usage();
00644
00645    for (i = 0; i < (sizeof(FlagMappings)/sizeof(FLAGMAPPING)); i++)
00646    {
00647       if (deleg_flag & FlagMappings[i].value)
00648          printf("Context flag: %s\n", FlagMappings[i].realname);
00649    }
00650    if (SignOnly)
00651       printf("No encryption - sign only\n");
00652
00653    server_host = *argv++;
00654    service_name = *argv++;
00655    msg = *argv++;
00656
00657    fprintf( stderr,
00658             "calling host %hs, name %hs, msg \"%hs\".\n",
00659             server_host,
00660             service_name,
00661             msg );
00662
00663    if (call_server(server_host, port, service_name,
00664                    deleg_flag, msg, use_file) < 0)
00665       exit(1);
00666
00667
00668    return 0;
00669 }
00670
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SLangRegistry Member List

This is the complete list of members for SLangRegistry, including all inherited members.
lcid | SLangRegistry
pwszLangName | SLangRegistry
Stemmer | SLangRegistry
WordBreaker | SLangRegistry
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/klist/KList.c Source File

  • Security
  • Authorization
  • klist

KList.c

Go to the documentation of this file.
00001 /*--
00002
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009
00010 Module Name:
00011
00012     klist.c
00013
00014 Abstract:
00015
00016     Sample program that demonstrates how to:
00017        query Kerberos ticket cache
00018        purge Kerberos tickets from cache
00019        request service ticket
00020
00021 Author:
00022
00023     David Mowers (davemo)   14-October-98
00024
00025 Revision History:
00026
00027 --*/
00028
00029
00030 //
00031 // Common include files.
00032 //
00033 #define UNICODE
00034 #define _UNICODE
00035
00036 #include <windows.h>
00037 #include <stdio.h>
00038 #include <stdlib.h>
00039 #include <conio.h>
00040 #include <ntsecapi.h>
00041 #define SECURITY_WIN32
00042 #include <security.h>
00043
00044 #define INTERACTIVE_PURGE 1
00045
00046 #define SEC_SUCCESS(Status) ((Status) >= 0)
00047
00048 VOID
00049 InitUnicodeString(
00050     PUNICODE_STRING DestinationString,
00051     PCWSTR SourceString OPTIONAL
00052     );
00053
00054 VOID
00055 ShowLastError(
00056     LPSTR szAPI,
00057     DWORD dwError
00058     );
00059
00060 VOID
00061 ShowNTError(
00062     LPSTR szAPI,
00063     NTSTATUS Status
00064     );
00065
00066 BOOL
00067 PackageConnectLookup(
00068     HANDLE *pLogonHandle,
00069     ULONG *pPackageId
00070     );
00071
00072 BOOL
00073 ShowTickets(
00074     HANDLE LogonHandle,
00075     ULONG PackageId,
00076     DWORD dwMode
00077     );
00078
00079 BOOL
00080 ShowTgt(
00081     HANDLE LogonHandle,
00082     ULONG PackageId
00083     );
00084
00085 DWORD
00086 GetEncodedTicket(
00087     HANDLE LogonHandle,
00088     ULONG PackageId,
00089     wchar_t *Server
00090     );
00091
00092 int __cdecl
00093 wmain(
00094     int argc,
00095     wchar_t  *argv[]
00096     )
00097 {
00098
00099     HANDLE LogonHandle = NULL;
00100     ULONG PackageId;
00101
00102     if (argc < 2)
00103     {
00104         printf("Usage: %S <tickets | tgt | purge | get> [service principal name(for get)]\n",argv[0]);
00105         return FALSE;
00106     }
00107
00108     //
00109     // Get the logon handle and package ID from the
00110     // Kerberos package
00111     //
00112     if(!PackageConnectLookup(&LogonHandle, &PackageId))
00113         return FALSE;
00114
00115     if(!_wcsicmp(argv[1],L"tickets"))
00116     {
00117         ShowTickets(LogonHandle, PackageId, 0);
00118     }
00119     else if(!_wcsicmp(argv[1],L"tgt"))
00120     {
00121         ShowTgt(LogonHandle, PackageId);
00122     }
00123     else if(!_wcsicmp(argv[1],L"purge"))
00124     {
00125         ShowTickets(LogonHandle, PackageId, INTERACTIVE_PURGE);
00126     }
00127     else if(!_wcsicmp(argv[1],L"get"))
00128     {
00129         if(argc < 3)
00130         {
00131             printf("Provide service principal name (SPN) of encoded ticket to retrieve\n");
00132         }
00133         else
00134             GetEncodedTicket(LogonHandle, PackageId, argv[2]);
00135     }
00136     else
00137     {
00138         printf("Usage: %S <tickets | tgt | purge | get> [service principal name(for get)]\n",argv[0]);
00139     }
00140
00141     if (LogonHandle != NULL)
00142     {
00143         LsaDeregisterLogonProcess(LogonHandle);
00144     }
00145
00146     return TRUE;
00147
00148 }
00149
00150 VOID
00151 PrintKerbName(
00152     PKERB_EXTERNAL_NAME Name
00153     )
00154 {
00155     ULONG Index;
00156     for (Index = 0; Index < Name->NameCount ; Index++ )
00157     {
00158         printf("%wZ",&Name->Names[Index]);
00159     if ((Index+1) < Name->NameCount)
00160       printf("/");
00161     }
00162     printf("\n");
00163 }
00164
00165 VOID
00166 PrintTime(
00167     LPSTR Comment,
00168     TimeStamp ConvertTime
00169     )
00170 {
00171
00172     printf( "%s", Comment );
00173
00174     //
00175     // If the time is infinite,
00176     //  just say so.
00177     //
00178     if ( ConvertTime.HighPart == 0x7FFFFFFF && ConvertTime.LowPart == 0xFFFFFFFF ) {
00179         printf( "Infinite\n" );
00180
00181     //
00182     // Otherwise print it more clearly
00183     //
00184     } else {
00185
00186         SYSTEMTIME SystemTime;
00187         FILETIME LocalFileTime;
00188
00189         if( FileTimeToLocalFileTime(
00190                 (PFILETIME) &ConvertTime,
00191                 &LocalFileTime
00192                 ) &&
00193             FileTimeToSystemTime(
00194                 &LocalFileTime,
00195                 &SystemTime
00196                 ) )
00197         {
00198
00199             printf( "%ld/%ld/%ld %ld:%2.2ld:%2.2ld\n",
00200                     SystemTime.wMonth,
00201                     SystemTime.wDay,
00202                     SystemTime.wYear,
00203                     SystemTime.wHour,
00204                     SystemTime.wMinute,
00205                     SystemTime.wSecond );
00206         }
00207           else
00208       {
00209           printf( "%ld\n", (long)(ConvertTime.QuadPart/(10*1000*1000)));
00210       }
00211     }
00212
00213 }
00214
00215 VOID
00216 PrintEType(
00217     int etype
00218     )
00219 {
00220
00221 #define AddEtype(n) { n, TEXT(#n) }
00222
00223     struct _etype {
00224         int etype;
00225         LPTSTR ename;
00226     } enames[] = {
00227         AddEtype(KERB_ETYPE_NULL),
00228         AddEtype(KERB_ETYPE_DES_CBC_CRC),
00229         AddEtype(KERB_ETYPE_DES_CBC_MD4),
00230         AddEtype(KERB_ETYPE_DES_CBC_MD5),
00231         AddEtype(KERB_ETYPE_DES_PLAIN),
00232         AddEtype(KERB_ETYPE_RC4_MD4),
00233         AddEtype(KERB_ETYPE_RC4_PLAIN2),
00234         AddEtype(KERB_ETYPE_RC4_LM),
00235         AddEtype(KERB_ETYPE_RC4_SHA),
00236         AddEtype(KERB_ETYPE_DES_PLAIN),
00237         AddEtype(KERB_ETYPE_RC4_HMAC_OLD),
00238         AddEtype(KERB_ETYPE_RC4_PLAIN_OLD),
00239         AddEtype(KERB_ETYPE_RC4_HMAC_OLD_EXP),
00240         AddEtype(KERB_ETYPE_RC4_PLAIN_OLD_EXP),
00241         AddEtype(KERB_ETYPE_RC4_PLAIN),
00242         AddEtype(KERB_ETYPE_RC4_PLAIN_EXP),
00243         AddEtype(KERB_ETYPE_DSA_SIGN),
00244         AddEtype(KERB_ETYPE_RSA_PRIV),
00245         AddEtype(KERB_ETYPE_RSA_PUB),
00246         AddEtype(KERB_ETYPE_RSA_PUB_MD5),
00247         AddEtype(KERB_ETYPE_RSA_PUB_SHA1),
00248         AddEtype(KERB_ETYPE_PKCS7_PUB),
00249         AddEtype(KERB_ETYPE_DES_CBC_MD5_NT),
00250         AddEtype(KERB_ETYPE_RC4_HMAC_NT),
00251         AddEtype(KERB_ETYPE_RC4_HMAC_NT_EXP),
00252         {-1, 0}
00253     };
00254     int i;
00255
00256     for (i = 0; enames[i].ename != 0; i++) {
00257     if (etype == enames[i].etype) {
00258         printf("KerbTicket Encryption Type: (%d) %S\n",
00259            etype,
00260            enames[i].ename);
00261         return;
00262     }
00263     }
00264     printf("KerbTicket Encryption Type: %d\n", etype);
00265 }
00266
00267
00268 VOID
00269 PrintTktFlags(
00270     ULONG flags
00271     )
00272 {
00273     if (flags & KERB_TICKET_FLAGS_forwardable) {
00274         printf("forwardable ");
00275     }
00276     if (flags & KERB_TICKET_FLAGS_forwarded) {
00277         printf("forwarded ");
00278     }
00279     if (flags & KERB_TICKET_FLAGS_proxiable) {
00280         printf("proxiable ");
00281     }
00282     if (flags & KERB_TICKET_FLAGS_proxy) {
00283         printf("proxy ");
00284     }
00285     if (flags & KERB_TICKET_FLAGS_may_postdate) {
00286         printf("may_postdate ");
00287     }
00288     if (flags & KERB_TICKET_FLAGS_postdated) {
00289         printf("postdated ");
00290     }
00291     if (flags & KERB_TICKET_FLAGS_invalid) {
00292         printf("invalid ");
00293     }
00294     if (flags & KERB_TICKET_FLAGS_renewable) {
00295         printf("renewable ");
00296     }
00297     if (flags & KERB_TICKET_FLAGS_initial) {
00298         printf("initial ");
00299     }
00300     if (flags & KERB_TICKET_FLAGS_hw_authent) {
00301         printf("hw_auth ");
00302     }
00303     if (flags & KERB_TICKET_FLAGS_pre_authent) {
00304         printf("preauth ");
00305     }
00306     if (flags & KERB_TICKET_FLAGS_ok_as_delegate) {
00307         printf("delegate ");
00308     }
00309     printf("\n");
00310 }
00311
00312 BOOL
00313 PackageConnectLookup(
00314     HANDLE *pLogonHandle,
00315     ULONG *pPackageId
00316     )
00317 {
00318     LSA_STRING Name;
00319     NTSTATUS Status;
00320
00321     Status = LsaConnectUntrusted(
00322                 pLogonHandle
00323                 );
00324
00325     if (!SEC_SUCCESS(Status))
00326     {
00327         ShowNTError("LsaConnectUntrusted", Status);
00328         return FALSE;
00329     }
00330
00331     Name.Buffer = MICROSOFT_KERBEROS_NAME_A;
00332     Name.Length = strlen(Name.Buffer);
00333     Name.MaximumLength = Name.Length + 1;
00334
00335     Status = LsaLookupAuthenticationPackage(
00336                 *pLogonHandle,
00337                 &Name,
00338                 pPackageId
00339                 );
00340
00341     if (!SEC_SUCCESS(Status))
00342     {
00343         ShowNTError("LsaLookupAuthenticationPackage", Status);
00344         return FALSE;
00345     }
00346
00347     return TRUE;
00348
00349 }
00350
00351 BOOL
00352 PurgeTicket(
00353     HANDLE LogonHandle,
00354     ULONG PackageId,
00355     LPWSTR Server,
00356     DWORD  cbServer,
00357     LPWSTR Realm,
00358     DWORD  cbRealm
00359     )
00360 {
00361     NTSTATUS Status;
00362     PVOID Response;
00363     ULONG ResponseSize;
00364     NTSTATUS SubStatus=0;
00365
00366     PKERB_PURGE_TKT_CACHE_REQUEST pCacheRequest = NULL;
00367
00368     pCacheRequest = (PKERB_PURGE_TKT_CACHE_REQUEST)
00369         LocalAlloc(LMEM_ZEROINIT,
00370         cbServer + cbRealm + sizeof(KERB_PURGE_TKT_CACHE_REQUEST));
00371
00372     pCacheRequest->MessageType = KerbPurgeTicketCacheMessage;
00373     pCacheRequest->LogonId.LowPart = 0;
00374     pCacheRequest->LogonId.HighPart = 0;
00375
00376     CopyMemory((LPBYTE)pCacheRequest+sizeof(KERB_PURGE_TKT_CACHE_REQUEST),
00377         Server,cbServer);
00378     CopyMemory((LPBYTE)pCacheRequest+sizeof(KERB_PURGE_TKT_CACHE_REQUEST)+cbServer,
00379         Realm,cbRealm);
00380
00381     pCacheRequest->ServerName.Buffer =
00382         (LPWSTR)((LPBYTE)pCacheRequest+sizeof(KERB_PURGE_TKT_CACHE_REQUEST));
00383
00384     pCacheRequest->ServerName.Length =
00385         (unsigned short)cbServer;
00386
00387     pCacheRequest->ServerName.MaximumLength =
00388         (unsigned short)cbServer;
00389
00390     pCacheRequest->RealmName.Buffer =
00391         (LPWSTR)((LPBYTE)pCacheRequest+sizeof(KERB_PURGE_TKT_CACHE_REQUEST)+cbServer);
00392
00393     pCacheRequest->RealmName.Length =
00394         (unsigned short)cbRealm;
00395
00396     pCacheRequest->RealmName.MaximumLength =
00397         (unsigned short)cbRealm;
00398
00399     printf("\tDeleting ticket: \n");
00400     printf("\t   ServerName = %wZ (cb=%lu)\n",&pCacheRequest->ServerName,cbServer);
00401     printf("\t   RealmName  = %wZ (cb=%lu)\n",&pCacheRequest->RealmName,cbRealm);
00402
00403     Status = LsaCallAuthenticationPackage(
00404                 LogonHandle,
00405                 PackageId,
00406                 pCacheRequest,
00407                 sizeof(KERB_PURGE_TKT_CACHE_REQUEST)+cbServer+cbRealm,
00408                 &Response,
00409                 &ResponseSize,
00410                 &SubStatus
00411                 );
00412
00413     if (!SEC_SUCCESS(Status) || !SEC_SUCCESS(Status))
00414     {
00415         ShowNTError("LsaCallAuthenticationPackage(purge)", Status);
00416         printf("Substatus: 0x%x\n",SubStatus);
00417         ShowNTError("LsaCallAuthenticationPackage(purge SubStatus)", SubStatus);
00418         return FALSE;
00419     }
00420     else
00421     {
00422         printf("\tTicket purged!\n");
00423         return TRUE;
00424     }
00425
00426 }
00427
00428
00429 BOOL
00430 ShowTickets(
00431     HANDLE LogonHandle,
00432     ULONG PackageId,
00433     DWORD dwMode
00434     )
00435 {
00436     NTSTATUS Status;
00437     KERB_QUERY_TKT_CACHE_REQUEST CacheRequest;
00438     PKERB_QUERY_TKT_CACHE_RESPONSE CacheResponse = NULL;
00439     ULONG ResponseSize;
00440     NTSTATUS SubStatus;
00441     ULONG Index;
00442     int ch;
00443
00444     CacheRequest.MessageType = KerbQueryTicketCacheMessage;
00445     CacheRequest.LogonId.LowPart = 0;
00446     CacheRequest.LogonId.HighPart = 0;
00447
00448     Status = LsaCallAuthenticationPackage(
00449                 LogonHandle,
00450                 PackageId,
00451                 &CacheRequest,
00452                 sizeof(CacheRequest),
00453                 (PVOID *) &CacheResponse,
00454                 &ResponseSize,
00455                 &SubStatus
00456                 );
00457     if (!SEC_SUCCESS(Status) || !SEC_SUCCESS(SubStatus))
00458     {
00459         ShowNTError("LsaCallAuthenticationPackage", Status);
00460         printf("Substatus: 0x%x\n",SubStatus);
00461         return FALSE;
00462     }
00463
00464     printf("\nCached Tickets: (%lu)\n", CacheResponse->CountOfTickets);
00465     for (Index = 0; Index < CacheResponse->CountOfTickets ; Index++ )
00466     {
00467         printf("\n   Server: %wZ@%wZ\n",
00468             &CacheResponse->Tickets[Index].ServerName,
00469             &CacheResponse->Tickets[Index].RealmName);
00470         printf("      ");
00471         PrintEType(CacheResponse->Tickets[Index].EncryptionType);
00472         PrintTime("      End Time: ",CacheResponse->Tickets[Index].EndTime);
00473         PrintTime("      Renew Time: ",CacheResponse->Tickets[Index].RenewTime);
00474         printf("      TicketFlags: (0x%x) ", CacheResponse->Tickets[Index].TicketFlags);
00475         PrintTktFlags(CacheResponse->Tickets[Index].TicketFlags);
00476         printf("\n");
00477
00478         if(dwMode == INTERACTIVE_PURGE)
00479         {
00480             printf("Purge? (y/n/q) : ");
00481             ch = _getche();
00482             if(ch == 'y' || ch == 'Y')
00483             {
00484                 printf("\n");
00485                 PurgeTicket(
00486                     LogonHandle,
00487                     PackageId,
00488                     CacheResponse->Tickets[Index].ServerName.Buffer,
00489                     CacheResponse->Tickets[Index].ServerName.Length,
00490                     CacheResponse->Tickets[Index].RealmName.Buffer,
00491                     CacheResponse->Tickets[Index].RealmName.Length
00492                     );
00493             }
00494             else if(ch == 'q' || ch == 'Q')
00495                 goto cleanup;
00496             else
00497                 printf("\n\n");
00498
00499         }
00500     }
00501
00502 cleanup:
00503
00504     if (CacheResponse != NULL)
00505     {
00506         LsaFreeReturnBuffer(CacheResponse);
00507     }
00508
00509     return TRUE;
00510 }
00511
00512 BOOL
00513 ShowTgt(
00514     HANDLE LogonHandle,
00515     ULONG PackageId
00516     )
00517 {
00518     NTSTATUS Status;
00519     KERB_QUERY_TKT_CACHE_REQUEST CacheRequest;
00520   PKERB_RETRIEVE_TKT_RESPONSE TicketEntry = NULL;
00521     PKERB_EXTERNAL_TICKET Ticket;
00522     ULONG ResponseSize;
00523     NTSTATUS SubStatus;
00524     BOOLEAN Trusted = TRUE;
00525
00526     CacheRequest.MessageType = KerbRetrieveTicketMessage;
00527     CacheRequest.LogonId.LowPart = 0;
00528     CacheRequest.LogonId.HighPart = 0;
00529
00530     Status = LsaCallAuthenticationPackage(
00531                 LogonHandle,
00532                 PackageId,
00533                 &CacheRequest,
00534                 sizeof(CacheRequest),
00535                 (PVOID *) &TicketEntry,
00536                 &ResponseSize,
00537                 &SubStatus
00538                 );
00539
00540     if (!SEC_SUCCESS(Status) || !SEC_SUCCESS(SubStatus))
00541     {
00542         ShowNTError("LsaCallAuthenticationPackage", Status);
00543         printf("Substatus: 0x%x\n",SubStatus);
00544         return FALSE;
00545     }
00546
00547     Ticket = &(TicketEntry->Ticket);
00548
00549     printf("\nCached TGT:\n\n");
00550
00551     printf("ServiceName: "); PrintKerbName(Ticket->ServiceName);
00552
00553     printf("TargetName: "); PrintKerbName(Ticket->TargetName);
00554
00555     printf("FullServiceName: "); PrintKerbName(Ticket->ClientName);
00556
00557     printf("DomainName: %.*S\n",
00558         Ticket->DomainName.Length/sizeof(WCHAR),Ticket->DomainName.Buffer);
00559
00560     printf("TargetDomainName: %.*S\n",
00561         Ticket->TargetDomainName.Length/sizeof(WCHAR),Ticket->TargetDomainName.Buffer);
00562
00563     printf("AltTargetDomainName: %.*S\n",
00564         Ticket->AltTargetDomainName.Length/sizeof(WCHAR),Ticket->AltTargetDomainName.Buffer);
00565
00566     printf("TicketFlags: (0x%x) ",Ticket->TicketFlags);
00567     PrintTktFlags(Ticket->TicketFlags);
00568     PrintTime("KeyExpirationTime: ",Ticket->KeyExpirationTime);
00569     PrintTime("StartTime: ",Ticket->StartTime);
00570     PrintTime("EndTime: ",Ticket->EndTime);
00571     PrintTime("RenewUntil: ",Ticket->RenewUntil);
00572     PrintTime("TimeSkew: ",Ticket->TimeSkew);
00573     PrintEType(Ticket->SessionKey.KeyType);
00574
00575
00576     if (TicketEntry != NULL)
00577     {
00578         LsaFreeReturnBuffer(TicketEntry);
00579     }
00580
00581     return TRUE;
00582 }
00583
00584 DWORD
00585 GetEncodedTicket(
00586     HANDLE LogonHandle,
00587     ULONG PackageId,
00588     wchar_t *Server
00589     )
00590 {
00591     NTSTATUS Status;
00592     PKERB_RETRIEVE_TKT_REQUEST CacheRequest = NULL;
00593     PKERB_RETRIEVE_TKT_RESPONSE CacheResponse = NULL;
00594     PKERB_EXTERNAL_TICKET Ticket;
00595     ULONG ResponseSize;
00596     NTSTATUS SubStatus;
00597     BOOLEAN Trusted = TRUE;
00598     BOOLEAN Success = FALSE;
00599     UNICODE_STRING Target = {0};
00600     UNICODE_STRING Target2 = {0};
00601
00602     InitUnicodeString( &Target2, Server);
00603
00604     CacheRequest = (PKERB_RETRIEVE_TKT_REQUEST)
00605             LocalAlloc(LMEM_ZEROINIT, Target2.Length + sizeof(KERB_RETRIEVE_TKT_REQUEST));
00606
00607     CacheRequest->MessageType = KerbRetrieveEncodedTicketMessage ;
00608     CacheRequest->LogonId.LowPart = 0;
00609     CacheRequest->LogonId.HighPart = 0;
00610
00611
00612     Target.Buffer = (LPWSTR) (CacheRequest + 1);
00613     Target.Length = Target2.Length;
00614     Target.MaximumLength = Target2.MaximumLength;
00615
00616     CopyMemory(
00617         Target.Buffer,
00618         Target2.Buffer,
00619         Target2.Length
00620         );
00621
00622     CacheRequest->TargetName = Target;
00623
00624     Status = LsaCallAuthenticationPackage(
00625                 LogonHandle,
00626                 PackageId,
00627                 CacheRequest,
00628                 Target2.Length + sizeof(KERB_RETRIEVE_TKT_REQUEST),
00629                 (PVOID *) &CacheResponse,
00630                 &ResponseSize,
00631                 &SubStatus
00632                 );
00633
00634     if (!SEC_SUCCESS(Status) || !SEC_SUCCESS(SubStatus))
00635     {
00636         ShowNTError("LsaCallAuthenticationPackage", Status);
00637         printf("Substatus: 0x%x\n",SubStatus);
00638         ShowNTError("Substatus:", SubStatus);
00639
00640     }
00641     else
00642     {
00643         Ticket = &(CacheResponse->Ticket);
00644
00645         printf("\nEncoded Ticket:\n\n");
00646
00647         printf("ServiceName: "); PrintKerbName(Ticket->ServiceName);
00648
00649         printf("TargetName: "); PrintKerbName(Ticket->TargetName);
00650
00651         printf("ClientName: "); PrintKerbName(Ticket->ClientName);
00652
00653         printf("DomainName: %.*S\n",
00654             Ticket->DomainName.Length/sizeof(WCHAR),Ticket->DomainName.Buffer);
00655
00656         printf("TargetDomainName: %.*S\n",
00657             Ticket->TargetDomainName.Length/sizeof(WCHAR),Ticket->TargetDomainName.Buffer);
00658
00659         printf("AltTargetDomainName: %.*S\n",
00660             Ticket->AltTargetDomainName.Length/sizeof(WCHAR),Ticket->AltTargetDomainName.Buffer);
00661
00662         printf("TicketFlags: (0x%x) ",Ticket->TicketFlags);
00663         PrintTktFlags(Ticket->TicketFlags);
00664         PrintTime("KeyExpirationTime: ",Ticket->KeyExpirationTime);
00665         PrintTime("StartTime: ",Ticket->StartTime);
00666         PrintTime("EndTime: ",Ticket->EndTime);
00667         PrintTime("RenewUntil: ",Ticket->RenewUntil);
00668         PrintTime("TimeSkew: ",Ticket->TimeSkew);
00669         PrintEType(Ticket->SessionKey.KeyType);
00670
00671         Success = TRUE;
00672
00673     }
00674
00675     if (CacheResponse)
00676     {
00677         LsaFreeReturnBuffer(CacheResponse);
00678     }
00679     if (CacheRequest)
00680     {
00681         LocalFree(CacheRequest);
00682     }
00683
00684     return Success;
00685 }
00686
00687 VOID
00688 InitUnicodeString(
00689   PUNICODE_STRING DestinationString,
00690     PCWSTR SourceString OPTIONAL
00691     )
00692 {
00693     ULONG Length;
00694
00695     DestinationString->Buffer = (PWSTR)SourceString;
00696     if (SourceString != NULL) {
00697         Length = wcslen( SourceString ) * sizeof( WCHAR );
00698         DestinationString->Length = (USHORT)Length;
00699         DestinationString->MaximumLength = (USHORT)(Length + sizeof(UNICODE_NULL));
00700         }
00701     else {
00702         DestinationString->MaximumLength = 0;
00703         DestinationString->Length = 0;
00704         }
00705 }
00706
00707 VOID
00708 ShowLastError(
00709   LPSTR szAPI,
00710   DWORD dwError
00711   )
00712 {
00713    #define MAX_MSG_SIZE 256
00714
00715    static WCHAR szMsgBuf[MAX_MSG_SIZE];
00716    DWORD dwRes;
00717
00718    printf("Error calling function %s: %lu\n", szAPI, dwError);
00719
00720    dwRes = FormatMessage (
00721       FORMAT_MESSAGE_FROM_SYSTEM,
00722       NULL,
00723       dwError,
00724       MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US),
00725       szMsgBuf,
00726       MAX_MSG_SIZE,
00727       NULL);
00728    if (0 == dwRes) {
00729       printf("FormatMessage failed with %d\n", GetLastError());
00730       ExitProcess(EXIT_FAILURE);
00731    }
00732
00733    printf("%S",szMsgBuf);
00734 }
00735
00736 VOID
00737 ShowNTError(
00738   LPSTR szAPI,
00739   NTSTATUS Status
00740   )
00741 {
00742     //
00743     // Convert the NTSTATUS to Winerror. Then call ShowLastError().
00744     //
00745     ShowLastError(szAPI, LsaNtStatusToWinError(Status));
00746 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Assert.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

Assert.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       assert.cxx
00006 //
00007 //  Contents:   Debug assert function
00008 //
00009 //----------------------------------------------------------------------------
00010
00011 #include <pch.cxx>
00012 #pragma hdrstop
00013
00014 //+---------------------------------------------------------------------------
00015 //
00016 //  Function:   Win4Assert
00017 //
00018 //  Synopsis:   Display assertion information
00019 //
00020 //----------------------------------------------------------------------------
00021
00022 void Win4AssertEx( char const * szFile,
00023                    int iLine,
00024                    char const * szMessage)
00025 {
00026      char acsString[200];
00027
00028      sprintf( acsString, "%s, File: %s Line: %u\n", szMessage, szFile, iLine );
00029      OutputDebugStringA( acsString );
00030
00031      DebugBreak();
00032 }
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/pooleddata.Cpp Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

pooleddata.Cpp

Go to the documentation of this file.
00001 #include "stdafx.h"
00002 #include "pooleddata.h"
00003
00004 IMPLEMENT_FIXED_ALLOC(tagFieldMetaData, ENTITY_PER_BANK);
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/KeepAliveWithThreads/KeepAliveP.c Source File

  • Web
  • iis
  • extensions
  • KeepAliveWithThreads

KeepAliveP.c

Go to the documentation of this file.
00001 /* Copyright (c) 1997-2002 Microsoft Corporation
00002
00003   Module Name:
00004
00005     KeepAliveP.c
00006
00007   Abstract:
00008
00009     Sample ISAPI Extension demonstrating Keep-Alive with a thread pool.
00010 */
00011
00012 #define WIN32_LEAN_AND_MEAN
00013 #include <windows.h>
00014 #include <httpext.h>
00015 #include <stdio.h>
00016 #include "threadpool.h"
00017
00018 /*
00019   Purpose:
00020
00021     Initialize the thread pool when the DLL is loaded by IIS.
00022
00023   Arguments:
00024
00025     hinstDLL - DLL instance handle
00026     fdwReason - notification code
00027     lpdvContext - reserved
00028
00029   Returns:
00030
00031     TRUE if notification was successfully processed by the DLL
00032     FALSE to indicate a failure
00033 */
00034
00035 BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD fdwReason, IN LPVOID lpvContext)
00036 {
00037   BOOL fReturn = TRUE;
00038
00039   switch (fdwReason) {
00040
00041     case DLL_PROCESS_ATTACH :
00042
00043       fReturn = InitThreadPool();
00044
00045       break;
00046   }
00047
00048   return fReturn;
00049 }
00050
00051 /*
00052   Description:
00053
00054     This is required ISAPI Extension DLL entry point.
00055
00056   Arguments:
00057
00058     pVer - poins to extension version info structure
00059
00060   Returns:
00061
00062     always returns TRUE
00063 */
00064
00065 BOOL WINAPI GetExtensionVersion(OUT HSE_VERSION_INFO *pVer)
00066 {
00067   pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
00068
00069   lstrcpyn(pVer->lpszExtensionDesc, "ISAPI Keep-Alive with Thread Pool Extension Sample", HSE_MAX_EXT_DLL_NAME_LEN);
00070
00071   return TRUE;
00072 }
00073
00074 /*
00075   Description:
00076
00077     Demonstrate usage of persistent connections serviced by a thread pool.
00078
00079   Arguments:
00080
00081     pECB - points to the extension control block
00082
00083   Returns:
00084
00085     HSE_STATUS_PENDING if request was successfully queued
00086     HSE_SUCCESS_AND_KEEP_CONN if request was served immediately
00087       (presumably because the queue was full)
00088 */
00089
00090 DWORD WINAPI HttpExtensionProc(IN EXTENSION_CONTROL_BLOCK *pECB)
00091 {
00092   DWORD dwSize;
00093   HSE_SEND_HEADER_EX_INFO HeaderExInfo;
00094
00095   char szHeader[] =
00096     "Connection: Keep-Alive\r\n"
00097     "Content-Length: %lu\r\n"
00098     "Content-type: text/html\r\n\r\n";
00099
00100   char szBusyMessage[] =
00101     "<html> <form method=get action=KeepAliveP.dll> <input type=submit> "
00102     "<br>pECB->ConnID=%lu  <br>Server was too busy. </form></html>";
00103
00104   char szBuffer[4096];
00105   char szBuffer2[4096];
00106
00107   EnterCriticalSection(&csQueueLock);
00108
00109   if (!AddWorkQueueEntry(pECB)) {
00110
00111     /* if ECB could not be assigned */
00112
00113     LeaveCriticalSection(&csQueueLock);
00114
00115     sprintf(szBuffer2, szBusyMessage, pECB->ConnID);
00116
00117     /* Send outgoing header */
00118
00119     sprintf(szBuffer, szHeader, strlen(szBuffer2));
00120
00121     HeaderExInfo.pszHeader = szBuffer;
00122     HeaderExInfo.cchHeader = strlen( szBuffer );
00123     HeaderExInfo.pszStatus = "200 OK";
00124     HeaderExInfo.cchStatus = strlen( HeaderExInfo.pszStatus );
00125     HeaderExInfo.fKeepConn = TRUE;
00126
00127     pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL);
00128
00129     /* Send content */
00130
00131     dwSize = strlen(szBuffer2);
00132
00133     pECB->WriteClient(pECB->ConnID, szBuffer2, &dwSize, 0);
00134
00135     return HSE_STATUS_SUCCESS_AND_KEEP_CONN;
00136
00137   } else {
00138
00139     /* release 1 thread from the pool */
00140
00141     ReleaseSemaphore(hWorkSem, 1, NULL);
00142
00143     LeaveCriticalSection(&csQueueLock);
00144   }
00145
00146   return HSE_STATUS_PENDING;
00147 }
00148
00149 /*
00150   Description:
00151
00152     This function is called when the WWW service is shutdown
00153
00154   Arguments:
00155
00156     dwFlags - HSE_TERM_ADVISORY_UNLOAD or HSE_TERM_MUST_UNLOAD
00157
00158   Return Value:
00159
00160     TRUE if extension is ready to be unloaded,
00161     FALSE otherwise
00162 */
00163
00164 BOOL WINAPI TerminateExtension(IN DWORD dwFlags)
00165 {
00166   return TRUE;
00167 }
00168
00169 /*
00170   Description:
00171
00172     Worker thread function - simulates extended processing of the HTTP request
00173
00174   Arguments:
00175
00176     pvThreadNum - thread number
00177
00178   Returns:
00179
00180     alsways returns 0
00181 */
00182
00183 DWORD WINAPI WorkerFunction(IN LPVOID pvThreadNum)
00184 {
00185   EXTENSION_CONTROL_BLOCK *pECB;
00186   DWORD dwRet, dwState, dwSize;
00187   HSE_SEND_HEADER_EX_INFO HeaderExInfo;
00188
00189   DWORD dwThreadNum = (DWORD)pvThreadNum;
00190
00191   /* This header will be filled in with the content length */
00192
00193   char szHeader[] =
00194     "Connection: Keep-Alive\r\nContent-Length: %lu\r\n"
00195     "Content-type: text/html\r\n\r\n";
00196
00197   char szContent[] =
00198     "<html> <form method=get action=KeepAliveP.dll><input type=submit> "
00199     "<br>pECB->ConnID=%lu  <br>dwThreadNum=%lu</form></html>";
00200
00201   char szBuffer[4096];
00202   char szBuffer2[4096];
00203
00204   for (;;) {
00205
00206     dwRet = WaitForSingleObject(hWorkSem, INFINITE);
00207
00208     if (dwRet == WAIT_OBJECT_0) {
00209
00210       EnterCriticalSection(&csQueueLock);
00211
00212       if (GetWorkQueueEntry(&pECB)) {
00213
00214         /* Found work to do */
00215
00216         LeaveCriticalSection(&csQueueLock);
00217
00218         sprintf(szBuffer2, szContent, pECB->ConnID, dwThreadNum);
00219
00220         /* Send outgoing header */
00221
00222         sprintf(szBuffer, szHeader, strlen(szBuffer2));
00223
00224         HeaderExInfo.pszHeader = szBuffer;
00225         HeaderExInfo.cchHeader = strlen( szBuffer );
00226         HeaderExInfo.pszStatus = "200 OK";
00227         HeaderExInfo.cchStatus = strlen( HeaderExInfo.pszStatus );
00228         HeaderExInfo.fKeepConn = TRUE;
00229
00230         pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL);
00231
00232         /* Simulate extended processing */
00233
00234         Sleep(3000);
00235
00236         /* Send content */
00237
00238         dwSize = strlen(szBuffer2);
00239
00240         pECB->WriteClient(pECB->ConnID, szBuffer2, &dwSize, 0);
00241
00242         /* Tell IIS to keep the connection open */
00243
00244         dwState = HSE_STATUS_SUCCESS_AND_KEEP_CONN;
00245
00246         pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_DONE_WITH_SESSION, &dwState, NULL, 0);
00247
00248       } else {
00249
00250         /* No item found is unexpected condition - exit thread */
00251
00252         LeaveCriticalSection(&csQueueLock);
00253
00254         ExitThread(0);
00255       }
00256
00257     } else {
00258
00259       /* Leave the infinite loop */
00260
00261       break;
00262     }
00263   }
00264
00265   return 0;
00266 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcComms.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcComms.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "ACComms.h"
00052
00053 // Dispatch interfaces referenced by this interface
00054 #include "ACComm.h"
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CAgentCtlCommandsEx properties
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // CAgentCtlCommandsEx operations
00062
00063 CAgentCtlCommandEx CAgentCtlCommandsEx::GetItem(LPCTSTR Name)
00064 {
00065   LPDISPATCH pDispatch;
00066   static BYTE parms[] =
00067     VTS_BSTR;
00068   InvokeHelper(0x0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, parms,
00069     Name);
00070   return CAgentCtlCommandEx(pDispatch);
00071 }
00072
00073 CAgentCtlCommandEx CAgentCtlCommandsEx::Command(LPCTSTR Name)
00074 {
00075   LPDISPATCH pDispatch;
00076   static BYTE parms[] =
00077     VTS_BSTR;
00078   InvokeHelper(0xf, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00079     Name);
00080   return CAgentCtlCommandEx(pDispatch);
00081 }
00082
00083 long CAgentCtlCommandsEx::GetCount()
00084 {
00085   long result;
00086   InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00087   return result;
00088 }
00089
00090 CString CAgentCtlCommandsEx::GetCaption()
00091 {
00092   CString result;
00093   InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00094   return result;
00095 }
00096
00097 void CAgentCtlCommandsEx::SetCaption(LPCTSTR lpszNewValue)
00098 {
00099   static BYTE parms[] =
00100     VTS_BSTR;
00101   InvokeHelper(0x3, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00102      lpszNewValue);
00103 }
00104
00105 CString CAgentCtlCommandsEx::GetVoice()
00106 {
00107   CString result;
00108   InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00109   return result;
00110 }
00111
00112 void CAgentCtlCommandsEx::SetVoice(LPCTSTR lpszNewValue)
00113 {
00114   static BYTE parms[] =
00115     VTS_BSTR;
00116   InvokeHelper(0x4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00117      lpszNewValue);
00118 }
00119
00120 BOOL CAgentCtlCommandsEx::GetVisible()
00121 {
00122   BOOL result;
00123   InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00124   return result;
00125 }
00126
00127 void CAgentCtlCommandsEx::SetVisible(BOOL bNewValue)
00128 {
00129   static BYTE parms[] =
00130     VTS_BOOL;
00131   InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00132      bNewValue);
00133 }
00134
00135 LPDISPATCH CAgentCtlCommandsEx::Add(LPCTSTR Name, const VARIANT& Caption, const VARIANT& Voice, const VARIANT& Enabled, const VARIANT& Visible)
00136 {
00137   LPDISPATCH result;
00138   static BYTE parms[] =
00139     VTS_BSTR VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT;
00140   InvokeHelper(0xa, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, parms,
00141     Name, &Caption, &Voice, &Enabled, &Visible);
00142   return result;
00143 }
00144
00145 LPDISPATCH CAgentCtlCommandsEx::Insert(LPCTSTR Name, LPCTSTR RefName, const VARIANT& Before, const VARIANT& Caption, const VARIANT& Voice, const VARIANT& Enabled, const VARIANT& Visible)
00146 {
00147   LPDISPATCH result;
00148   static BYTE parms[] =
00149     VTS_BSTR VTS_BSTR VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT;
00150   InvokeHelper(0xb, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, parms,
00151     Name, RefName, &Before, &Caption, &Voice, &Enabled, &Visible);
00152   return result;
00153 }
00154
00155 void CAgentCtlCommandsEx::Remove(LPCTSTR Name)
00156 {
00157   static BYTE parms[] =
00158     VTS_BSTR;
00159   InvokeHelper(0xd, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
00160      Name);
00161 }
00162
00163 void CAgentCtlCommandsEx::RemoveAll()
00164 {
00165   InvokeHelper(0xe, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
00166 }
00167
00168 void CAgentCtlCommandsEx::SetDefaultCommand(LPCTSTR lpszNewValue)
00169 {
00170   static BYTE parms[] =
00171     VTS_BSTR;
00172   InvokeHelper(0x10, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00173      lpszNewValue);
00174 }
00175
00176 CString CAgentCtlCommandsEx::GetDefaultCommand()
00177 {
00178   CString result;
00179   InvokeHelper(0x10, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00180   return result;
00181 }
00182
00183 void CAgentCtlCommandsEx::SetHelpContextID(long nNewValue)
00184 {
00185   static BYTE parms[] =
00186     VTS_I4;
00187   InvokeHelper(0x11, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00188      nNewValue);
00189 }
00190
00191 long CAgentCtlCommandsEx::GetHelpContextID()
00192 {
00193   long result;
00194   InvokeHelper(0x11, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00195   return result;
00196 }
00197
00198 void CAgentCtlCommandsEx::SetFontName(LPCTSTR lpszNewValue)
00199 {
00200   static BYTE parms[] =
00201     VTS_BSTR;
00202   InvokeHelper(0x15, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00203      lpszNewValue);
00204 }
00205
00206 CString CAgentCtlCommandsEx::GetFontName()
00207 {
00208   CString result;
00209   InvokeHelper(0x15, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00210   return result;
00211 }
00212
00213 long CAgentCtlCommandsEx::GetFontSize()
00214 {
00215   long result;
00216   InvokeHelper(0x17, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00217   return result;
00218 }
00219
00220 void CAgentCtlCommandsEx::SetFontSize(long nNewValue)
00221 {
00222   static BYTE parms[] =
00223     VTS_I4;
00224   InvokeHelper(0x17, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00225      nNewValue);
00226 }
00227
00228 void CAgentCtlCommandsEx::SetVoiceCaption(LPCTSTR lpszNewValue)
00229 {
00230   static BYTE parms[] =
00231     VTS_BSTR;
00232   InvokeHelper(0x16, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00233      lpszNewValue);
00234 }
00235
00236 CString CAgentCtlCommandsEx::GetVoiceCaption()
00237 {
00238   CString result;
00239   InvokeHelper(0x16, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00240   return result;
00241 }
00242
00243 void CAgentCtlCommandsEx::SetGlobalVoiceCommandsEnabled(BOOL bNewValue)
00244 {
00245   static BYTE parms[] =
00246     VTS_BOOL;
00247   InvokeHelper(0x18, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00248      bNewValue);
00249 }
00250
00251 BOOL CAgentCtlCommandsEx::GetGlobalVoiceCommandsEnabled()
00252 {
00253   BOOL result;
00254   InvokeHelper(0x18, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00255   return result;
00256 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/omniprov/source/resource.h Source File

  • Dataaccess
  • oledb
  • omniprov
  • source

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by TheProvider.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_MSOMNIPROV                  101
00007 #define IDS_DBPROP_ACTIVESESSIONS       102
00008 #define IDS_DBPROP_ASYNCTXNCOMMIT       103
00009 #define IDS_DBPROP_BYREFACCESSORS       104
00010 #define IDS_DBPROP_CATALOGLOCATION      105
00011 #define IDS_DBPROP_CATALOGTERM          106
00012 #define IDS_DBPROP_CATALOGUSAGE         107
00013 #define IDS_DBPROP_COLUMNDEFINITION     108
00014 #define IDS_DBPROP_CONCATNULLBEHAVIOR   109
00015 #define IDS_DBPROP_DATASOURCENAME       110
00016 #define IDS_DBPROP_DATASOURCEREADONLY   111
00017 #define IDS_DBPROP_DBMSNAME             112
00018 #define IDS_DBPROP_DBMSVER              113
00019 #define IDS_DBPROP_PROCEDURETERM        114
00020 #define IDS_DBPROP_PROVIDEROLEDBVER     115
00021 #define IDS_DBPROP_PROVIDERNAME         116
00022 #define IDS_DBPROP_PROVIDERVER          117
00023 #define IDS_DBPROP_QUOTEDIDENTIFIERCASE 118
00024 #define IDS_DBPROP_SCHEMATERM           119
00025 #define IDS_DBPROP_SCHEMAUSAGE          120
00026 #define IDS_DBPROP_SQLSUPPORT           121
00027 #define IDS_DBPROP_STRUCTUREDSTORAGE    122
00028 #define IDS_DBPROP_SUBQUERIES           123
00029 #define IDS_DBPROP_SUPPORTEDTXNISOLEVELS 124
00030 #define IDS_DBPROP_SUPPORTEDTXNISORETAIN 125
00031 #define IDS_DBPROP_TABLETERM            126
00032 #define IDS_DBPROP_USERNAME             127
00033 #define IDS_DBPROP_SUPPORTEDTXNDDL      128
00034 #define IDS_DBPROP_ASYNCTXNABORT        129
00035 #define IDS_DBPROP_DSOTHREADMODEL       130
00036 #define IDS_DBPROP_MULTIPLEPARAMSETS    131
00037 #define IDS_DBPROP_OUTPUTPARAMETERAVAILABILITY 132
00038 #define IDS_DBPROP_PERSISTENTIDTYPE     133
00039 #define IDS_DBPROP_NOTIFYCOLUMNSET      134
00040 #define IDS_DBPROP_NOTIFYROWDELETE      135
00041 #define IDS_DBPROP_NOTIFYROWFIRSTCHANGE 136
00042 #define IDS_DBPROP_NOTIFYROWINSERT      137
00043 #define IDS_DBPROP_NOTIFYROWRESYNCH     138
00044 #define IDS_DBPROP_NOTIFYROWSETRELEASE  139
00045 #define IDS_DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE 140
00046 #define IDS_DBPROP_NOTIFYROWUNDOCHANGE  141
00047 #define IDS_DBPROP_NOTIFYROWUNDODELETE  142
00048 #define IDS_DBPROP_GROUPBY              143
00049 #define IDS_DBPROP_HETEROGENEOUSTABLES  144
00050 #define IDS_DBPROP_IDENTIFIERCASE       145
00051 #define IDS_DBPROP_LOCKMODES            146
00052 #define IDS_DBPROP_MAXINDEXSIZE         147
00053 #define IDS_DBPROP_MAXROWSIZE           148
00054 #define IDS_DBPROP_MAXROWSIZEINCLUDESBLOB 149
00055 #define IDS_DBPROP_MAXTABLESINSELECT    150
00056 #define IDS_DBPROP_MULTIPLESTORAGEOBJECTS 151
00057 #define IDS_DBPROP_MULTITABLEUPDATE     152
00058 #define IDS_DBPROP_NOTIFICATIONPHASES   153
00059 #define IDS_DBPROP_NULLCOLLATION        154
00060 #define IDS_DBPROP_OLEOBJECTS           155
00061 #define IDS_DBPROP_ORDERBYCOLUMNSINSELECT 156
00062 #define IDS_DBPROP_PREPARECOMMITBEHAVIOR 157
00063 #define IDS_DBPROP_PREPAREABORTBEHAVIOR 158
00064 #define IDS_DBPROP_NOTIFYROWUNDOINSERT  159
00065 #define IDS_DBPROP_NOTIFYROWUPDATE      160
00066 #define IDS_DBPROP_ROWSETCONVERSIONSONCOMMAND 161
00067 #define IDS_DBPROP_MULTIPLERESULTS      162
00068 #define IDS_DBPROP_ISequentialStream    163
00069 #define IDS_DBPROP_ABORTPRESERVE        164
00070 #define IDS_DBPROP_BLOCKINGSTORAGEOBJECTS 165
00071 #define IDS_DBPROP_IRowsetScroll        166
00072 #define IDS_DBPROP_IRowsetUpdate        167
00073 #define IDS_DBPROP_ISupportErrorInfo    168
00074 #define IDS_DBPROP_CHANGEINSERTEDROWS   169
00075 #define IDS_DBPROP_RETURNPENDINGINSERTS 170
00076 #define IDS_DBPROP_IConvertType         171
00077 #define IDS_DBPROP_AUTH_CACHE_AUTHINFO  172
00078 #define IDS_DBPROP_AUTH_ENCRYPT_PASSWORD 173
00079 #define IDS_DBPROP_AUTH_INTEGRATED      174
00080 #define IDS_DBPROP_AUTH_MASK_PASSWORD   175
00081 #define IDS_DBPROP_AUTH_PASSWORD        176
00082 #define IDS_DBPROP_AUTH_PERSIST_ENCRYPTED 177
00083 #define IDS_DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO 178
00084 #define IDS_DBPROP_AUTH_USERID          179
00085 #define IDS_DBPROP_INIT_DATASOURCE      180
00086 #define IDS_DBPROP_INIT_HWND            181
00087 #define IDS_DBPROP_INIT_IMPERSONATION_LEVEL 182
00088 #define IDS_DBPROP_INIT_LOCATION        183
00089 #define IDS_DBPROP_INIT_MODE            184
00090 #define IDS_DBPROP_INIT_PROMPT          185
00091 #define IDS_DBPROP_INIT_PROTECTION_LEVEL 186
00092 #define IDS_DBPROP_INIT_TIMEOUT         187
00093 #define IDS_DBPROP_INIT_LCID            188
00094 #define IDS_DBPROP_INIT_PROVIDERSTRING  189
00095 #define IDS_DBPROP_SESS_AUTOCOMMITISOLEVELS 190
00096 #define IDS_DBPROP_SERVERCURSOR         191
00097 #define IDS_DBPROP_TRANSACTEDOBJECT     192
00098 #define IDS_DBPROP_UPDATABILITY         193
00099 #define IDS_DBPROP_STRONGIDENTITY       194
00100 #define IDS_DBPROP_IAccessor            195
00101 #define IDS_DBPROP_IColumnsInfo         196
00102 #define IDS_DBPROP_IColumnsRowset       197
00103 #define IDS_DBPROP_IConnectionPointContainer 198
00104 #define IDS_DBPROP_IProvideMoniker      199
00105 #define IDS_DBPROP_IRowset              200
00106 #define IDS_DBPROP_IRowsetChange        201
00107 #define IDS_DBPROP_IRowsetIdentity      202
00108 #define IDS_DBPROP_IRowsetInfo          203
00109 #define IDS_DBPROP_IRowsetLocate        204
00110 #define IDS_DBPROP_IRowsetResynch       205
00111 #define IDS_DBPROP_BOOKMARKS            206
00112 #define IDS_DBPROP_BOOKMARKSKIPPED      207
00113 #define IDS_DBPROP_BOOKMARKTYPE         208
00114 #define IDS_DBPROP_CANFETCHBACKWARDS    209
00115 #define IDS_DBPROP_CANHOLDROWS          210
00116 #define IDS_DBPROP_APPENDONLY           211
00117 #define IDS_DBPROP_CANSCROLLBACKWARDS   212
00118 #define IDS_DBPROP_COLUMNRESTRICT       213
00119 #define IDS_DBPROP_COMMANDTIMEOUT       214
00120 #define IDS_DBPROP_COMMITPRESERVE       215
00121 #define IDS_DBPROP_DELAYSTORAGEOBJECTS  216
00122 #define IDS_DBPROP_IMMOBILEROWS         217
00123 #define IDS_DBPROP_LITERALBOOKMARKS     218
00124 #define IDS_DBPROP_LITERALIDENTITY      219
00125 #define IDS_DBPROP_MAXOPENROWS          220
00126 #define IDS_DBPROP_MAXPENDINGROWS       221
00127 #define IDS_DBPROP_MAXROWS              222
00128 #define IDS_DBPROP_OTHERINSERT          223
00129 #define IDS_DBPROP_OTHERUPDATEDELETE    224
00130 #define IDS_DBPROP_OWNINSERT            225
00131 #define IDS_DBPROP_OWNUPDATEDELETE      226
00132 #define IDS_DBPROP_QUICKRESTART         227
00133 #define IDS_DBPROP_REENTRANTEVENTS      228
00134 #define IDS_DBPROP_REMOVEDELETED        229
00135 #define IDS_DBPROP_REPORTMULTIPLECHANGES 230
00136 #define IDS_DBPROP_ROWRESTRICT          231
00137 #define IDS_DBPROP_ROWTHREADMODEL       232
00138 #define IDS_DBPROP_ORDEREDBOOKMARKS     233
00139 #define IDS_DBPROP_INIT_OLEDBSERVICES   1189
00140
00141 // Next default values for new objects
00142 //
00143 #ifdef APSTUDIO_INVOKED
00144 #ifndef APSTUDIO_READONLY_SYMBOLS
00145 #define _APS_NEXT_RESOURCE_VALUE        203
00146 #define _APS_NEXT_COMMAND_VALUE         32768
00147 #define _APS_NEXT_CONTROL_VALUE         201
00148 #define _APS_NEXT_SYMED_VALUE           234
00149 #endif
00150 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/Account.Idl Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

Account.Idl

Go to the documentation of this file.
00001 // Filename: Account.idl
00002 //
00003 // Description: IDL source for Account.dll
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (Account.tlb) and marshalling code
00006 //
00007 // This file is provided as part of the Microsoft Transaction Server Samples
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00010 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00011 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00012 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00013 // PURPOSE.
00014 //
00015 // Copyright (C) 1997 Microsoft Corporation, All rights reserved
00016
00017 #include <mtxattr.h>
00018 import "oaidl.idl";
00019
00020   [
00021     object,
00022     uuid(04CF0B72-1989-11D0-B917-0080C7394688),
00023     dual,
00024     helpstring("IAccount Interface"),
00025     pointer_default(unique)
00026
00027   ]
00028   interface IAccount : IDispatch
00029   {
00030
00031     HRESULT Post(
00032       [in] long lAccount,
00033       [in] long lAmount,
00034       [out,retval] BSTR* pbstrResult);
00035   };
00036
00037   [
00038     object,
00039     uuid(04CF0B73-1989-11D0-B917-0080C7394688),
00040     dual,
00041     helpstring("IMoveMoneyOptions Interface"),
00042     pointer_default(unique)
00043
00044   ]
00045
00046   interface IMoveMoneyOptions : IDispatch
00047   {
00048     HRESULT UseComPlus();
00049     HRESULT SetAccountClsctx([in] long clsctx);
00050   };
00051
00052   [
00053     object,
00054     uuid(04CF0B77-1989-11D0-B917-0080C7394688),
00055     dual,
00056     helpstring("IMoveMoney Interface"),
00057     pointer_default(unique)
00058
00059   ]
00060   interface IMoveMoney : IDispatch
00061   {
00062
00063     HRESULT Perform(
00064       [in] long lPrimeAccount,
00065       [in] long lSecondAccount,
00066       [in] long lAmount,
00067       [in] long lTranType,
00068       [out, retval] BSTR* pbstrResult);
00069   };
00070
00071
00072   [
00073     object,
00074     uuid(A81260B1-DDC8-11D0-B5A0-00C04FB957D8),
00075     dual,
00076     helpstring("IGetReceipt Interface"),
00077     pointer_default(unique)
00078
00079   ]
00080   interface IGetReceipt : IDispatch
00081   {
00082
00083     HRESULT GetNextReceipt (
00084       [out,retval] long* plReceiptNo);
00085   };
00086
00087   [
00088     object,
00089     uuid(A81260B7-DDC8-11D0-B5A0-00C04FB957D8),
00090     dual,
00091     helpstring("IUpdateReceipt Interface"),
00092     pointer_default(unique)
00093
00094   ]
00095   interface IUpdateReceipt : IDispatch
00096   {
00097
00098     HRESULT Update (
00099       [out,retval] long* plReceiptNo);
00100   };
00101
00102
00103
00104
00105
00106
00107
00108
00109 [
00110   uuid(04CF0B70-1989-11D0-B917-0080C7394688),
00111   version(1.0),
00112   helpstring("Sample Bank Account (VC version)")
00113 ]
00114 library ACCOUNT
00115 {
00116   importlib("stdole2.tlb");
00117
00118   [
00119     uuid(04CF0B76-1989-11D0-B917-0080C7394688),
00120     helpstring("Account Class"),
00121     TRANSACTION_REQUIRED
00122   ]
00123   coclass CAccount
00124   {
00125     [default] interface IAccount;
00126   };
00127
00128   [
00129     uuid(04CF0B7B-1989-11D0-B917-0080C7394688),
00130     helpstring("MoveMoney Class"),
00131     TRANSACTION_REQUIRED
00132   ]
00133   coclass CMoveMoney
00134   {
00135     [default] interface IMoveMoney;
00136     interface IMoveMoneyOptions;
00137   };
00138
00139   [
00140     uuid(A81260B2-DDC8-11D0-B5A0-00C04FB957D8),
00141     helpstring("GetReceipt Class"),
00142     TRANSACTION_SUPPORTED
00143   ]
00144   coclass CGetReceipt
00145   {
00146     [default] interface IGetReceipt;
00147   };
00148
00149
00150   [
00151     uuid(A81260B8-DDC8-11D0-B5A0-00C04FB957D8),
00152     helpstring("UpdateReceipt Class"),
00153     TRANSACTION_REQUIRES_NEW
00154   ]
00155   coclass CUpdateReceipt
00156   {
00157     [default] interface IUpdateReceipt;
00158   };
00159 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::RecordCreateOptionsEnum Member List

This is the complete list of members for msado15::RecordCreateOptionsEnum, including all inherited members.
adCreateCollection | msado15::RecordCreateOptionsEnum | [static]
adCreateNonCollection | msado15::RecordCreateOptionsEnum | [static]
adCreateOverwrite | msado15::RecordCreateOptionsEnum | [static]
adCreateStructDoc | msado15::RecordCreateOptionsEnum | [static]
adFailIfNotExists | msado15::RecordCreateOptionsEnum | [static]
adOpenIfExists | msado15::RecordCreateOptionsEnum | [static]
Generated on Wed Nov 13 2024 16:58:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminComponentFlags Member List

This is the complete list of members for comadmin::COMAdminComponentFlags, including all inherited members.
COMAdminCompFlagAlreadyInstalled | comadmin::COMAdminComponentFlags | [static]
COMAdminCompFlagCOMPlusPropertiesFound | comadmin::COMAdminComponentFlags | [static]
COMAdminCompFlagInterfacesFound | comadmin::COMAdminComponentFlags | [static]
COMAdminCompFlagNotInApplication | comadmin::COMAdminComponentFlags | [static]
COMAdminCompFlagProxyFound | comadmin::COMAdminComponentFlags | [static]
COMAdminCompFlagTypeInfoFound | comadmin::COMAdminComponentFlags | [static]
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step4/MyDevice.cpp Source File

  • NetDS
  • upnp
  • StepByStep
  • Step4

MyDevice.cpp

Go to the documentation of this file.
00001 // MyDevice.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f MyDeviceps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "MyDevice.h"
00012
00013 #include "MyDevice_i.c"
00014 #include "Dimmer.h"
00015 #include "DimmerService.h"
00016
00017
00018 CComModule _Module;
00019
00020 BEGIN_OBJECT_MAP(ObjectMap)
00021 OBJECT_ENTRY(CLSID_Dimmer, CDimmer)
00022 //OBJECT_ENTRY(CLSID_DimmerService, CDimmerService)
00023 END_OBJECT_MAP()
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // DLL Entry Point
00027
00028 extern "C"
00029 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00030 {
00031     if (dwReason == DLL_PROCESS_ATTACH)
00032     {
00033         _Module.Init(ObjectMap, hInstance, &LIBID_MYDEVICELib);
00034         DisableThreadLibraryCalls(hInstance);
00035     }
00036     else if (dwReason == DLL_PROCESS_DETACH)
00037         _Module.Term();
00038     return TRUE;    // ok
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 // Used to determine whether the DLL can be unloaded by OLE
00043
00044 STDAPI DllCanUnloadNow(void)
00045 {
00046     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // Returns a class factory to create an object of the requested type
00051
00052 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00053 {
00054     return _Module.GetClassObject(rclsid, riid, ppv);
00055 }
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // DllRegisterServer - Adds entries to the system registry
00059
00060 STDAPI DllRegisterServer(void)
00061 {
00062     // registers object, typelib and all interfaces in typelib
00063     return _Module.RegisterServer(TRUE);
00064 }
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // DllUnregisterServer - Removes entries from the system registry
00068
00069 STDAPI DllUnregisterServer(void)
00070 {
00071     return _Module.UnregisterServer(TRUE);
00072 }
00073
00074
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SHandlerEntry Member List

This is the complete list of members for SHandlerEntry, including all inherited members.
pwszClassId | SHandlerEntry
pwszClassIdDescription | SHandlerEntry
pwszClassIdFilter | SHandlerEntry
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/dxtrans/dxsurfmod/main.cpp Source File

  • Web
  • dxtrans
  • dxsurfmod

main.cpp

Go to the documentation of this file.
00001 ///////////////////////////////////////
00002 //
00003 //  main.cpp
00004 //
00005 //  This sample demonstrates how surface modifiers can be
00006 //  used to create a variety of images through a slide
00007 //  show presentation.
00008 //
00009 // Copyright (c) 2001 Microsoft Corporation. All rights reserved.
00010 //
00011
00012 ///////////////////////////////////////
00013 //
00014 //  Windows includes
00015 //
00016
00017 #include <objbase.h>
00018 #include <initguid.h>
00019 #include <windows.h>
00020 #include <wchar.h>
00021 #include <tchar.h>
00022
00023 ///////////////////////////////////////
00024 //
00025 //  DXTransforms includes
00026 //
00027
00028 #include <dxtguid.c>
00029 #include <dxtrans.h>
00030 #include <dxtmsft.h>
00031 #include <dxbounds.h>
00032 #include <dxterror.h>
00033 #include <strsafe.h>
00034 #include "resource.h"
00035
00036 ///////////////////////////////////////
00037 //
00038 //  Macros
00039 //
00040
00041 #define MAX_SLIDE_INDEX 11
00042
00043 ///////////////////////////////////////
00044 //
00045 //  Function Prototypes
00046 //
00047
00048 LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
00049 void HandleError(HRESULT hr, HWND hwnd, LPCSTR szErrorMsg);
00050 void ReleaseAllObjects(void);
00051 void GetImageDirectoryAndFileName(PWSTR wszImageDirAndFileName,
00052                   PCWSTR wszFileName);
00053
00054 ///////////////////////////////////////
00055 //
00056 //  Global Variables
00057 //
00058
00059 IDXTransformFactory*    g_pTransFact        = NULL;
00060 IDXSurfaceFactory*      g_pSurfFact         = NULL;
00061 IDXSurface*             g_pSurf1            = NULL;
00062 IDXSurface*             g_pSurf2            = NULL;
00063
00064 IDXSurfaceModifier*     g_pSurfMod          = NULL;
00065 IDXSurface*             g_pSurfModSurf      = NULL;
00066
00067 IDXLUTBuilder*          g_pLUTBuilder       = NULL;
00068 IDXLookupTable*         g_pLookupTable      = NULL;
00069
00070 CDXDBnds                g_bndsMod;
00071 CDXDBnds                g_bndsWnd;
00072
00073 int                     g_iFrameIndex       = -1;
00074
00075 LPCSTR                  g_szCaption         = NULL;
00076 LPCSTR                  g_szNotes           = NULL;
00077
00078
00079
00080
00081
00082 ////////////////////////////////////////////////////////////////
00083 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00084                    PSTR szCmdLine, int iCmdShow)
00085 ////////////////////////////////////////////////////////////////
00086 {
00087     static char szAppName[] = "SurfMod";
00088     HWND        hwnd;
00089     MSG         msg;
00090     WNDCLASSEX  wc;
00091
00092     CoInitialize(NULL);
00093
00094     wc.cbSize           = sizeof(wc);
00095     wc.style            = CS_HREDRAW | CS_VREDRAW;
00096     wc.lpfnWndProc      = WndProc;
00097     wc.cbClsExtra       = 0;
00098     wc.cbWndExtra       = 0;
00099     wc.hInstance        = hInstance;
00100     wc.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
00101     wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
00102     wc.hbrBackground    = (HBRUSH) GetStockObject(BLACK_BRUSH);
00103     wc.lpszMenuName     = MAKEINTRESOURCE(IDR_MENU1);
00104     wc.lpszClassName    = szAppName;
00105     wc.hIconSm          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
00106
00107     RegisterClassEx(&wc);
00108
00109     hwnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
00110                           szAppName, "SurfMod",
00111                           WS_OVERLAPPEDWINDOW,
00112                           CW_USEDEFAULT, CW_USEDEFAULT,
00113                           680, 480,
00114                           NULL,
00115                           NULL,
00116                           hInstance,
00117                           NULL);
00118
00119     if ( hwnd )
00120     {
00121         ShowWindow(hwnd, iCmdShow);
00122         UpdateWindow(hwnd);
00123
00124         while ( GetMessage(&msg, NULL, 0, 0) )
00125         {
00126             TranslateMessage(&msg);
00127             DispatchMessage(&msg);
00128         }
00129     }
00130
00131     ReleaseAllObjects();
00132     CoUninitialize();
00133
00134     return msg.wParam;
00135 }
00136
00137
00138 ////////////////////////////////////////////////////////////////////////////
00139 LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
00140 ////////////////////////////////////////////////////////////////////////////
00141 {
00142     PAINTSTRUCT ps;
00143     RECT        rc;
00144     HDC         hdc         = NULL;
00145     HRESULT     hr          = S_OK;
00146
00147     CDXDBnds    bndsCur;                    // A variable to hold the current
00148                                             // bounds of the surface modifier
00149                                             // if needed.
00150
00151     POINT       pt          = { 50, 50 };   // Used for offset.
00152
00153     IDXSurface* pSurfTemp   = NULL;         // A temporary surface used to
00154                                             // translate the surface modifier
00155                                             // to the screen's pixel format and
00156                                             // retrieve a handle to a DC.
00157
00158     IDXDCLock*  pLock       = NULL;         // Used to lock a pSurfTemp and
00159                                             // retrieve a handle to a DC.
00160
00161     OPIDDXLUTBUILDER lutOps[] =             // Operations performed by the
00162         { OPID_DXLUTBUILDER_Invert };       // lookup table.
00163
00164
00165     switch ( iMsg )
00166     {
00167     case WM_COMMAND:
00168
00169         // User selected Exit from the File menu.
00170
00171         switch ( LOWORD(wParam) )
00172         {
00173         case IDM_EXIT:
00174
00175             PostMessage(hwnd, WM_CLOSE, 0, 0L);
00176             return 0;
00177         }
00178
00179         break;
00180
00181     case WM_CREATE:
00182
00183         ///////////////////////////////////////
00184         //
00185         //  Create factories
00186         //
00187
00188         // Transform factory.
00189
00190         hr = CoCreateInstance(CLSID_DXTransformFactory, NULL, CLSCTX_INPROC,
00191                               IID_IDXTransformFactory, (void**) &g_pTransFact);
00192
00193         // Surface factory.
00194
00195         if ( SUCCEEDED(hr) )
00196         {
00197             hr = g_pTransFact->QueryService(SID_SDXSurfaceFactory,
00198                                             IID_IDXSurfaceFactory,
00199                                             (void**) &g_pSurfFact);
00200         }
00201
00202         if ( FAILED(hr) )
00203         {
00204             HandleError(hr, NULL, "Can't create factories.  The DXMedia SDK "
00205                         "must be installed for this sample to work properly.");
00206
00207             return -1;
00208         }
00209
00210         ///////////////////////////////////////
00211         //
00212         //  Load Images
00213         //
00214
00215
00216         hr = g_pSurfFact->LoadImage(L"eagle_ck.gif",
00217                                     NULL, NULL, &DDPF_PMARGB32, IID_IDXSurface,
00218                                     (void**) &g_pSurf1);
00219
00220         if ( SUCCEEDED(hr) )
00221         {
00222
00223             hr = g_pSurfFact->LoadImage(L"apple.gif",
00224                                         NULL, NULL, &DDPF_PMARGB32, IID_IDXSurface,
00225                                         (void**) &g_pSurf2);
00226         }
00227
00228         if ( FAILED(hr) )
00229         {
00230             if ( DXTERR_REQ_IE_DLLNOTFOUND == hr )
00231             {
00232                 HandleError(hr, NULL, "Error loading images, possibly because "
00233                             "IE4.0 or greater is not installed.");
00234             }
00235             else
00236             {
00237                 HandleError(hr, NULL, "LoadImage failure.");
00238             }
00239
00240             return -1;
00241         }
00242
00243
00244         ///////////////////////////////////////
00245         //
00246         //  Create lookup table
00247         //
00248
00249         // Create a lookup table builder.
00250
00251         if ( SUCCEEDED(hr) )
00252         {
00253             hr = CoCreateInstance(CLSID_DXLUTBuilder, NULL, CLSCTX_INPROC,
00254                                   IID_IDXLUTBuilder, (void**) &g_pLUTBuilder);
00255         }
00256
00257         // Setup to support color inversion operation.
00258
00259         if ( SUCCEEDED(hr) )
00260         {
00261             hr = g_pLUTBuilder->SetBuildOrder(lutOps, 1);
00262         }
00263
00264         // Modify the level of the color inversion.
00265
00266         if ( SUCCEEDED(hr) )
00267         {
00268             hr = g_pLUTBuilder->SetInvert(0.5);
00269         }
00270
00271         // Query for a lookup table to be attached to the surface modifier.
00272
00273         if ( SUCCEEDED(hr) )
00274         {
00275             hr = g_pLUTBuilder->QueryInterface(IID_IDXLookupTable,
00276                                                (void**) &g_pLookupTable);
00277         }
00278
00279         if ( FAILED(hr) )
00280         {
00281             HandleError(hr, NULL, "Error creating lookup table.");
00282
00283             return -1;
00284         }
00285
00286         // The g_iFrameIndex variable is initialized to -1.  Immediately
00287         // sending the window a keypress right arrow message will update
00288         // b_iFrameIndex to 0 and setup the first sample frame.
00289
00290         SendMessage(hwnd, WM_KEYDOWN, VK_RIGHT, 0);
00291
00292         return 0;
00293
00294     case WM_DESTROY:
00295
00296         PostQuitMessage(0);
00297
00298         return 0;
00299
00300     case WM_KEYDOWN:
00301
00302         switch ( wParam )
00303         {
00304
00305             // Only responds to the user pressing the right
00306             // or left arrow keys.
00307
00308         case VK_RIGHT:
00309         case VK_LEFT:
00310
00311             while ( TRUE )
00312             {
00313                 if ( VK_RIGHT == wParam && g_iFrameIndex < MAX_SLIDE_INDEX )
00314                 {
00315                     // Increase the frame count if the user pressed
00316                     // the right arrow key.
00317
00318                     g_iFrameIndex++;
00319                     break;
00320                 }
00321
00322                 if ( VK_LEFT == wParam && g_iFrameIndex > 0 )
00323                 {
00324                     // Decrease the frame index if the user pressed
00325                     // the left arrow key.
00326
00327                     g_iFrameIndex--;
00328                     break;
00329                 }
00330
00331                 return 0;
00332             }
00333
00334             ///////////////////////////////////////
00335             //
00336             //  Reset surface modifier
00337             //
00338
00339             // The surface modifier can be reset by calling all Set methods
00340             // with NULL parameters or the it can be released and re-created.
00341
00342             // 1. Release surface modifier and associated surface pointer.
00343
00344             if ( g_pSurfModSurf )
00345             {
00346                 g_pSurfModSurf->Release();
00347                 g_pSurfModSurf = NULL;
00348             }
00349
00350             if ( g_pSurfMod )
00351             {
00352                 g_pSurfMod->Release();
00353                 g_pSurfMod = NULL;
00354             }
00355
00356             // 2. Re-create surface modifier.
00357
00358             hr = CoCreateInstance(CLSID_DXSurfaceModifier, NULL, CLSCTX_INPROC,
00359                                   IID_IDXSurfaceModifier, (void**) &g_pSurfMod);
00360
00361             // 3. Query for surface pointer to access the image.
00362
00363             if ( SUCCEEDED(hr) )
00364             {
00365                 hr = g_pSurfMod->QueryInterface(IID_IDXSurface,
00366                                                 (void**) &g_pSurfModSurf);
00367             }
00368
00369             ///////////////////////////////////////
00370             //
00371             //  Setup new frame
00372             //
00373
00374             switch ( g_iFrameIndex )
00375             {
00376             case 0:
00377
00378                 // Blank opaque blue surface
00379
00380                 g_pSurfMod->SetFillColor(0xFF0000FF);
00381                 g_pSurfMod->SetBounds(&g_bndsMod);
00382
00383                 g_szCaption = "0    "
00384                               "Fill Color: Opaque Blue    "
00385                               "[ Use left and right arrow keys to switch frames ]";
00386
00387                 g_szNotes = "When no background is used, the surface modifier "
00388                             "can be any size and sizes with the window.";
00389
00390                 break;
00391
00392             case 1:
00393
00394                 // Blank opaque blue surface that's the
00395                 // same size as the background surface
00396
00397                 g_pSurfMod->SetFillColor(0xFF0000FF);
00398                 g_pSurfMod->SetBackground(g_pSurf1);
00399
00400                 g_szCaption = "1    "
00401                               "Background: Eagle    "
00402                               "Fill Color: Opaque Blue [ Obscures eagle ]";
00403
00404                 g_szNotes = "A surface modifier using a background always sizes "
00405                             "to the background.";
00406
00407                 break;
00408
00409             case 2:
00410
00411                 // Eagle surface with a translucent blue
00412                 // surface over the top.
00413
00414                 g_pSurfMod->SetFillColor(0x550000FF);
00415                 g_pSurfMod->SetBackground(g_pSurf1);
00416
00417                 g_szCaption = "2    "
00418                               "Background: Eagle    "
00419                               "Fill Color: Translucent Blue    "
00420                               "Composite Operation: Over [ default ]    ";
00421
00422                 g_szNotes = "Fill color is always drawn in front of the "
00423                             "background surface.";
00424
00425                 break;
00426
00427             case 3:
00428
00429                 // translucent blue eagle
00430
00431                 g_pSurfMod->SetFillColor(0x550000FF);
00432                 g_pSurfMod->SetBackground(g_pSurf1);
00433                 g_pSurfMod->SetCompositeOperation(DXSURFMOD_COMP_ALPHA_MASK);
00434
00435                 g_szCaption = "3    "
00436                               "Background: Eagle    "
00437                               "Fill Color: Translucent Blue    "
00438                               "Composite Operation: Alpha Mask    ";
00439
00440                 g_szNotes = "The background's alpha value is used to draw the "
00441                             "fill color.";
00442
00443                 break;
00444
00445             case 4:
00446
00447                 // Apple in upper left hand corner of a
00448                 // translucent blue surface
00449
00450                 g_pSurfMod->SetFillColor(0x550000FF);
00451                 g_pSurfMod->SetForeground(g_pSurf2, FALSE, NULL);
00452                 g_pSurfMod->SetBounds(&g_bndsMod);
00453
00454                 g_szCaption = "4    "
00455                               "Fill Color: Translucent Blue    "
00456                               "Foreground: Apple";
00457
00458                 g_szNotes = "Foreground surfaces are always drawn in front of "
00459                             "the fill color.";
00460
00461                 break;
00462
00463             case 5:
00464
00465                 // Apple in front of translucent blue surface
00466                 // placed 50 pixels from both top and left edges
00467
00468                 g_pSurfMod->SetFillColor(0x550000FF);
00469                 g_pSurfMod->SetForeground(g_pSurf2, FALSE, &pt);
00470                 g_pSurfMod->SetBounds(&g_bndsMod);
00471
00472                 g_szCaption = "5    "
00473                               "Fill Color: Translucent Blue    "
00474                               "Foreground: Apple, offset [ 50, 50 ]";
00475
00476
00477                 g_szNotes = "When not tiled, the foreground is offset relative "
00478                             "to the upper left corner of the surface modifier.";
00479
00480                 break;
00481
00482             case 6:
00483
00484                 // Apples tiled in front of translucent blue surface
00485                 // with first apple against top left edge.
00486
00487                 g_pSurfMod->SetFillColor(0x550000FF);
00488                 g_pSurfMod->SetForeground(g_pSurf2, TRUE, NULL);
00489                 g_pSurfMod->SetBounds(&g_bndsMod);
00490
00491                 g_szCaption = "6    "
00492                               "Fill Color: Translucent Blue    "
00493                               "Foreground: Apple, tiled";
00494
00495                 g_szNotes = "The first tiled foreground image is placed in the "
00496                             "upper left corner of the surface modifier.";
00497
00498                 break;
00499
00500             case 7:
00501
00502                 // Apples tiled in front of translucent blue surface
00503                 // with the [50, 50] coordinate of the first apple
00504                 // at the top left corner.
00505
00506                 g_pSurfMod->SetFillColor(0x550000FF);
00507                 g_pSurfMod->SetForeground(g_pSurf2, TRUE, &pt);
00508                 g_pSurfMod->SetBounds(&g_bndsMod);
00509
00510                 g_szCaption = "7    "
00511                               "Fill Color: Translucent Blue    "
00512                               "Foreground: Apple, tiled, offset [ 50, 50 ]";
00513
00514                 g_szNotes = "When tiled, the offset is relative to the upper "
00515                             "left corner of the foreground surface.";
00516
00517                 break;
00518
00519             case 8:
00520
00521                 // Apple in front of eagle.
00522
00523                 g_pSurfMod->SetBackground(g_pSurf1);
00524                 g_pSurfMod->SetForeground(g_pSurf2, FALSE, NULL);
00525
00526                 g_szCaption = "8    "
00527                               "Background: Eagle    "
00528                               "Foreground: Apple    "
00529                               "Composite Operation: Over [ default ]";
00530
00531                 g_szNotes = "The foreground surface is always drawn in front "
00532                             "of the background surface.";
00533
00534                 break;
00535
00536             case 9:
00537
00538                 // translucent apple in front of eagle.
00539
00540                 g_pSurfMod->SetBackground(g_pSurf1);
00541                 g_pSurfMod->SetForeground(g_pSurf2, FALSE, NULL);
00542                 g_pSurfMod->SetOpacity(0.5);
00543
00544                 g_szCaption = "9    "
00545                               "Background: Eagle    "
00546                               "Foreground: Apple    "
00547                               "Composite Operation: Over [ default ]    "
00548                               "Opacity: 0.5";
00549
00550                 g_szNotes = "SetOpacity only affects the opacity of the "
00551                             "foreground surface.";
00552
00553                 break;
00554
00555             case 10:
00556
00557                 // translucent tiled apples only show where eagle's
00558                 // alpha value is greater than zero.
00559
00560                 g_pSurfMod->SetBackground(g_pSurf1);
00561                 g_pSurfMod->SetForeground(g_pSurf2, TRUE, NULL);
00562                 g_pSurfMod->SetCompositeOperation(DXSURFMOD_COMP_ALPHA_MASK);
00563                 g_pSurfMod->SetOpacity(0.5);
00564
00565                 g_szCaption = "10    "
00566                               "Background: Eagle    "
00567                               "Foreground: Apple, tiled    "
00568                               "Composite Operation: Alpha Mask    "
00569                               "Opacity: 0.5";
00570
00571                 g_szNotes = "Alpha mask can be used for a cool effect with "
00572                             "a tiled foreground surface and opacity.";
00573
00574                 break;
00575
00576             case 11:
00577
00578                 // Apple modified using a lookup table in front of
00579                 // a translucent blue surface.
00580
00581                 g_pSurfMod->SetFillColor(0xFF000055);
00582                 g_pSurfMod->SetForeground(g_pSurf2, FALSE, NULL);
00583                 g_pSurfMod->SetLookup(g_pLookupTable);
00584                 g_pSurfMod->SetBounds(&g_bndsMod);
00585
00586                 g_szCaption = "11    "
00587                               "Fill Color: Solid Dark Blue    "
00588                               "Foreground: Apple    "
00589                               "Lookup Table: Color Inversion";
00590
00591                 g_szNotes = "Lookup tables only modify the foreground surface.  "
00592                             "This was created with a lookup table builder.";
00593
00594                 break;
00595             }
00596
00597             // Check for error
00598
00599             if ( FAILED(hr) )
00600             {
00601                 HandleError(hr, hwnd, "Error during frame setup.");
00602             }
00603
00604             // Force window repaint
00605
00606             InvalidateRect(hwnd, NULL, TRUE);
00607             UpdateWindow(hwnd);
00608         }
00609
00610         return 0;
00611
00612     case WM_PAINT:
00613
00614         hdc = BeginPaint(hwnd, &ps);
00615
00616         // Retrieve the bounds of the surface modifier.
00617
00618         hr = g_pSurfModSurf->GetBounds(&bndsCur);
00619
00620         //     Since you can't get a device context from a
00621         //     surface modifier, you have to:
00622
00623         // 1.  Create a new surface, same size as surface modifier.
00624         //     Sending parameter 3 as NULL means the surface will be
00625         //     created with the same pixel format as the display.
00626
00627         if ( SUCCEEDED(hr) )
00628         {
00629             hr = g_pSurfFact->CreateSurface(NULL, NULL, NULL, &bndsCur, NULL,
00630                                             NULL, IID_IDXSurface,
00631                                             (void**) &pSurfTemp);
00632         }
00633
00634         // 2.  Use surface factory's BitBlt function to copy the image
00635         //     onto the new surface (this is the most efficient method).
00636
00637         if ( SUCCEEDED(hr) )
00638         {
00639             hr = g_pSurfFact->BitBlt(pSurfTemp, NULL, g_pSurfModSurf, NULL, NULL);
00640         }
00641
00642         // 3.  Lock the surface so that changes can't be made while painting.
00643
00644         if ( SUCCEEDED(hr) )
00645         {
00646             hr = pSurfTemp->LockSurfaceDC(NULL, INFINITE, DXLOCKF_READ, &pLock);
00647         }
00648
00649         // 4.  Retrieve a device context from the lock and then use the  GDI
00650         //     BitBlt function to blit the contents of the surface to the window.
00651
00652         if ( SUCCEEDED(hr) )
00653         {
00654             hdc = pLock->GetDC();
00655
00656             if ( bndsCur == g_bndsMod )
00657             {
00658                 // If the bounds are the same as the largest possible
00659                 // size for this window size, blit to (0,0).
00660                 // [ Note:  Will run this code when the surface modifier
00661                 //          does not use a background surface. ]
00662
00663                 BitBlt(ps.hdc, 0, 0,
00664                        bndsCur.Width(), bndsCur.Height(),
00665                        hdc, 0, 0, SRCCOPY);
00666             }
00667             else
00668             {
00669                 // If the bounds are different than the largest possible
00670                 // size for this window size, center inside the window.
00671                 // [ Note:  Will run this code when the surface modifier
00672                 //          uses a background surface. ]
00673
00674                 BitBlt(ps.hdc,
00675                        (g_bndsMod.Width()  - bndsCur.Width())  / 2,
00676                        (g_bndsMod.Height() - bndsCur.Height()) / 2,
00677                        bndsCur.Width(), bndsCur.Height(),
00678                        hdc, 0, 0, SRCCOPY);
00679             }
00680
00681             // Releasing the lock will also release the handle to the device
00682             // context (hdc) so ReleaseDC isn't needed.
00683
00684             pLock->Release();
00685         }
00686
00687         // Release the temporary surface used to convert the
00688         // pixel format and retrieve an hdc.
00689
00690         if ( pSurfTemp )
00691         {
00692             pSurfTemp->Release();
00693         }
00694
00695         // Print the caption text at the bottom of the screen.
00696
00697         if ( SUCCEEDED(hr) )
00698         {
00699             SetBkMode(ps.hdc, TRANSPARENT);
00700
00701             SetTextColor(ps.hdc, RGB(255, 0, 0));
00702             size_t dwCaptionLength;
00703             if (FAILED( StringCchLength(g_szCaption, 256, &dwCaptionLength))) { return -1; }
00704               TextOut(ps.hdc, 10, g_bndsWnd.Height() - 45, g_szCaption, dwCaptionLength);
00705
00706             SetTextColor(ps.hdc, RGB(0, 200, 0));
00707             size_t dwNotesLength;
00708             if (FAILED( StringCchLength(g_szNotes, 256, &dwNotesLength))) { return -1; }
00709               TextOut(ps.hdc, 10, g_bndsWnd.Height() - 25, g_szNotes, dwNotesLength);
00710         }
00711
00712         EndPaint(hwnd, &ps);
00713
00714         // Check for error
00715
00716         if ( FAILED(hr) )
00717         {
00718             HandleError(hr, hwnd, "Error repainting frame.");
00719         }
00720
00721         return 0;
00722
00723     case WM_SIZE:
00724
00725         GetClientRect(hwnd, &rc);
00726
00727         // When the window is resized, set the sizes of
00728         // two bounds objects:
00729         //
00730         // g_bndsWnd is the size of the full client area of the
00731         //   window.
00732         //
00733         // g_bndsMod is the size of the full client area of the
00734         //   window minus a few pixels to leave room for a caption.
00735         //   These are the bounds that will be used to size surface
00736         //   modifiers that don't use a background surface.
00737
00738         g_bndsWnd.SetXYSize(rc.right - rc.left, rc.bottom - rc.top);
00739
00740         g_bndsMod.SetXYSize(rc.right - rc.left, rc.bottom - rc.top - 50);
00741
00742         // Set the "virtual size" of the surface modifier equal to
00743         // the same size as the window (leaving room at the bottom
00744         // for the frame caption.)  If the surface modifier uses
00745         // a background surface it will ignore this method and retain
00746         // bounds equal to the size of the background surface.
00747
00748         g_pSurfMod->SetBounds(&g_bndsMod);
00749
00750         return 0;
00751     }
00752
00753     return DefWindowProc(hwnd, iMsg, wParam, lParam);
00754 }
00755
00756
00757 //////////////////////////////////////////////////////////
00758 void HandleError(HRESULT hr, HWND hwnd, LPCSTR szErrorMsg)
00759 //////////////////////////////////////////////////////////
00760 {
00761     char    szMsg[256];
00762
00763     // Use the strsafe.h version of printf.
00764     StringCchPrintf(szMsg, 256, "HRESULT: 0x%08x\n%s", hr, szErrorMsg);
00765
00766     MessageBox(hwnd, szMsg, "Error", MB_OK | MB_ICONEXCLAMATION);
00767
00768     if ( hwnd )
00769         PostMessage(hwnd, WM_CLOSE, 0, 0);
00770 }
00771
00772
00773 ////////////////////////////
00774 void ReleaseAllObjects(void)
00775 ////////////////////////////
00776 {
00777     if ( g_pLookupTable )
00778         g_pLookupTable->Release();
00779
00780     if ( g_pLUTBuilder )
00781         g_pLUTBuilder->Release();
00782
00783     if ( g_pSurfModSurf )
00784         g_pSurfModSurf->Release();
00785
00786     if ( g_pSurfMod )
00787         g_pSurfMod->Release();
00788
00789     if ( g_pSurf2 )
00790         g_pSurf2->Release();
00791
00792     if ( g_pSurf1 )
00793         g_pSurf1->Release();
00794
00795     if ( g_pSurfFact )
00796         g_pSurfFact->Release();
00797
00798     if ( g_pTransFact )
00799         g_pTransFact->Release();
00800 }
00801
00802
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Event_Provider/Globals.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Event_Provider

Globals.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Globals.cpp
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #include <PreComp.h>
00017 #include <wbemprov.h>
00018
00019 #include <initguid.h>
00020 #ifndef INITGUID
00021 #define INITGUID
00022 #endif
00023
00024 #include "Globals.h"
00025
00026 /******************************************************************************
00027  *
00028  *  Name:
00029  *
00030  *    s_LocksInProgress
00031  *    s_ObjectsInProgress
00032  *
00033  *  Description:
00034  *
00035  *    Keep a count of outstanding global objects. Used for debugging purposes.
00036  *
00037  *****************************************************************************/
00038
00039 LONG Provider_Globals :: s_LocksInProgress ;
00040 LONG Provider_Globals :: s_ObjectsInProgress ;
00041
00042 /******************************************************************************
00043  *
00044  *  Name: Global_Startup ()
00045  *
00046  *
00047  *  Description:
00048  *
00049  *    Global function to handle initialization.
00050  *    Place user code here.
00051  *
00052  *****************************************************************************/
00053
00054 HRESULT Provider_Globals :: Global_Startup ()
00055 {
00056   HRESULT t_Result = S_OK ;
00057   return t_Result ;
00058 }
00059
00060 /******************************************************************************
00061  *
00062  *  Name: Global_Shutdown ()
00063  *
00064  *
00065  *  Description:
00066  *
00067  *    Global function to handle uninitialization.
00068  *    Place user code here.
00069  *
00070  *****************************************************************************/
00071
00072 HRESULT Provider_Globals :: Global_Shutdown ()
00073 {
00074   HRESULT t_Result = S_OK ;
00075   return t_Result ;
00076 }
00077
00078 /******************************************************************************
00079  *
00080  *  Name: CreateInstance
00081  *
00082  *
00083  *  Description:
00084  *
00085  *      Wrapper function for CoCreateInstance/CoGetClassObject.
00086  *      Useful for specific security context and debugging purposes.
00087  *
00088  *****************************************************************************/
00089
00090 HRESULT Provider_Globals :: CreateInstance (
00091
00092   const CLSID &a_ReferenceClsid ,
00093   LPUNKNOWN a_OuterUnknown ,
00094   const DWORD &a_ClassContext ,
00095   const UUID &a_ReferenceInterfaceId ,
00096   void **a_ObjectInterface
00097 )
00098 {
00099   HRESULT t_Result = S_OK ;
00100
00101 #if 1
00102
00103 /*
00104  *  Use standard implementation
00105  */
00106
00107    t_Result = CoCreateInstance (
00108
00109     a_ReferenceClsid ,
00110     a_OuterUnknown ,
00111     a_ClassContext ,
00112     a_ReferenceInterfaceId ,
00113     ( void ** )  a_ObjectInterface
00114   );
00115
00116 #else
00117
00118 /*
00119  *  Tweak configuration settings for call.
00120  */
00121
00122   COAUTHIDENTITY t_AuthenticationIdentity ;
00123   ZeroMemory ( & t_AuthenticationIdentity , sizeof ( t_AuthenticationIdentity ) ) ;
00124
00125   t_AuthenticationIdentity.User = NULL ;
00126   t_AuthenticationIdentity.UserLength = 0 ;
00127   t_AuthenticationIdentity.Domain = NULL ;
00128   t_AuthenticationIdentity.DomainLength = 0 ;
00129   t_AuthenticationIdentity.Password = NULL ;
00130   t_AuthenticationIdentity.PasswordLength = 0 ;
00131   t_AuthenticationIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE ;
00132
00133   COAUTHINFO t_AuthenticationInfo ;
00134   ZeroMemory ( & t_AuthenticationInfo , sizeof ( t_AuthenticationInfo ) ) ;
00135
00136     t_AuthenticationInfo.dwAuthnSvc = RPC_C_AUTHN_DEFAULT ;
00137     t_AuthenticationInfo.dwAuthzSvc = RPC_C_AUTHZ_DEFAULT ;
00138     t_AuthenticationInfo.pwszServerPrincName = NULL ;
00139     t_AuthenticationInfo.dwAuthnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; //RPC_C_AUTHN_LEVEL_CONNECT ;
00140     t_AuthenticationInfo.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE  ;
00141     t_AuthenticationInfo.dwCapabilities = EOAC_NONE ;
00142     t_AuthenticationInfo.pAuthIdentityData = NULL ;
00143
00144   COSERVERINFO t_ServerInfo ;
00145   ZeroMemory ( & t_ServerInfo , sizeof ( t_ServerInfo ) ) ;
00146
00147   t_ServerInfo.pwszName = NULL ;
00148     t_ServerInfo.dwReserved2 = 0 ;
00149     t_ServerInfo.pAuthInfo = & t_AuthenticationInfo ;
00150
00151   IClassFactory *t_ClassFactory = NULL ;
00152
00153   t_Result = CoGetClassObject (
00154
00155     a_ReferenceClsid ,
00156     a_ClassContext ,
00157     & t_ServerInfo ,
00158     IID_IClassFactory ,
00159     ( void ** )  & t_ClassFactory
00160   ) ;
00161
00162   if ( SUCCEEDED ( t_Result ) )
00163   {
00164     t_Result = t_ClassFactory->CreateInstance (
00165
00166       a_OuterUnknown ,
00167       a_ReferenceInterfaceId ,
00168       a_ObjectInterface
00169     );
00170
00171     t_ClassFactory->Release () ;
00172   }
00173
00174 #endif
00175
00176   return t_Result ;
00177 }
00178
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/land.h Source File

  • SysMgmt
  • MMC
  • Complete

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035     virtual void SetScopeItemValue(LONG scopeitem) { m_hParentHScopeItem = scopeitem; }
00036     virtual HSCOPEITEM GetParentScopeItem() { return m_hParentHScopeItem; }
00037
00038 private:
00039     enum { IDM_NEW_LAND = 2 };
00040
00041     HSCOPEITEM m_hParentHScopeItem;
00042
00043     // {8512760B-6BE7-11d3-9156-00C04F65B3F9}
00044     static const GUID thisGuid;
00045 };
00046
00047
00048 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/Client/Client.h Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • Client

Client.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: client.h
00004
00005 Summary:  Produced by VS6 MFC Wizard. Main Header file for Client.exe Application
00006
00007 Look in this module to see definitions used in client.cpp to implement DCOM
00008 timeouts.
00009
00010 ----------------------------------------------------------------------------
00011
00012 This file is part of the Microsoft COM+ Samples.
00013
00014 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00015
00016 This source code is intended only as a supplement to Microsoft
00017 Development Tools and/or on-line documentation. See these other
00018 materials for detailed information regarding Microsoft code samples.
00019
00020 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00021 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00022 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00023 PARTICULAR PURPOSE.
00024
00025 ==========================================================================+*/
00026
00027 #if !defined(AFX_CLIENT_H__146DF853_4D72_11D2_9672_00AA00B913AC__INCLUDED_)
00028 #define AFX_CLIENT_H__146DF853_4D72_11D2_9672_00AA00B913AC__INCLUDED_
00029
00030 #if _MSC_VER >= 1000
00031 #pragma once
00032 #endif // _MSC_VER >= 1000
00033
00034 #ifndef __AFXWIN_H__
00035   #error include 'stdafx.h' before including this file for PCH
00036 #endif
00037
00038 #include "resource.h"   // main symbols
00039 #include "clientDlg.h"
00040 #include "..\server\server.h"
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 // CClientApp:
00044 // See client.cpp for the implementation of this class
00045 //
00046
00047 class CClientApp : public CWinApp
00048 {
00049 public:
00050   CClientApp();
00051   ~CClientApp();
00052
00053   CClientDlg  *pDlg;
00054   IMonitorServer *pMonitor;
00055   ICallFactory* pMonitorCallFactory;
00056   IPingResponder* pMonitorResponder;
00057   int nFail;
00058
00059   HRESULT DoAPing(IPingResponder* pResp, DWORD dwTimeout);
00060
00061 // Overrides
00062   // ClassWizard generated virtual function overrides
00063   //{{AFX_VIRTUAL(CClientApp)
00064   public:
00065   virtual BOOL InitInstance();
00066   virtual BOOL OnIdle(LONG lCount);
00067   //}}AFX_VIRTUAL
00068
00069 // Implementation
00070
00071   //{{AFX_MSG(CClientApp)
00072     // NOTE - the ClassWizard will add and remove member functions here.
00073     //    DO NOT EDIT what you see in these blocks of generated code !
00074   //}}AFX_MSG
00075   DECLARE_MESSAGE_MAP()
00076 };
00077
00078 extern CClientApp theApp;
00079
00080 #define MONITORPOLLDELAY (1*1000)
00081 #define CALLTIMEOUT (4*1000)
00082 #define CALLTIMEOUTWHENPINGING (2*1000)
00083 #define PINGTIMEOUT (1*1000)
00084
00085 /////////////////////////////////////////////////////////////////////////////
00086
00087 //{{AFX_INSERT_LOCATION}}
00088 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00089
00090 #endif // !defined(AFX_CLIENT_H__146DF853_4D72_11D2_9672_00AA00B913AC__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpwizard/util.cpp Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpwizard

util.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       util.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #include "stdafx.h"
00012 #include "util.h"
00013
00014 HRESULT SetStringAttribute(IADs* pIADs, LPCWSTR lpszAttr, LPCWSTR lpszValue)
00015 {
00016   ASSERT(pIADs != NULL);
00017   ASSERT(lpszAttr != NULL);
00018
00019   // Allocate the string
00020   BSTR bstrAttr = ::SysAllocString(lpszAttr);
00021
00022   // Imbed the value in a VARIANT
00023   HRESULT hr = S_OK;
00024   CComVariant varValue;
00025   varValue.vt = VT_BSTR;
00026   varValue.bstrVal = ::SysAllocString(lpszValue);
00027
00028   // Set the value in the temporary object
00029   hr = pIADs->Put(bstrAttr, varValue);
00030
00031   // Clean up memory
00032   ::SysFreeString(bstrAttr);
00033   return hr;
00034 }
00035
00036 HRESULT SetStringListAttribute(IADs* pIADs, LPCWSTR lpszAttr, CStringList& szValueList)
00037 {
00038   CComVariant var;
00039   HRESULT hr = S_OK;
00040
00041   hr = StringListToVariant(var, szValueList);
00042   if (SUCCEEDED(hr))
00043   {
00044     BSTR bstrAttr = ::SysAllocString(lpszAttr);
00045     hr = pIADs->Put(bstrAttr, var);
00046     ::SysFreeString(bstrAttr);
00047   }
00048   return hr;
00049 }
00050
00051 HRESULT StringListToVariant( VARIANT& refvar, const CStringList& refstringlist)
00052 {
00053   HRESULT hr = S_OK;
00054   int cCount = refstringlist.GetCount();
00055
00056   SAFEARRAYBOUND rgsabound[1];
00057   rgsabound[0].lLbound = 0;
00058   rgsabound[0].cElements = cCount;
00059
00060   SAFEARRAY* psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
00061   if (NULL == psa)
00062     return E_OUTOFMEMORY;
00063
00064   VariantClear( &refvar );
00065   V_VT(&refvar) = VT_VARIANT|VT_ARRAY;
00066   V_ARRAY(&refvar) = psa;
00067
00068   VARIANT SingleResult;
00069   VariantInit( &SingleResult );
00070   V_VT(&SingleResult) = VT_BSTR;
00071   POSITION pos = refstringlist.GetHeadPosition();
00072   long i;
00073   for (i = 0; i < cCount, pos != NULL; i++)
00074   {
00075     V_BSTR(&SingleResult) = T2BSTR((LPCTSTR)refstringlist.GetNext(pos));
00076     hr = SafeArrayPutElement(psa, &i, &SingleResult);
00077     if( FAILED(hr) )
00078       return hr;
00079   }
00080   if (i != cCount || pos != NULL)
00081     return E_UNEXPECTED;
00082
00083   return hr;
00084 } // StringListToVariant()
00085
00086
00087 //////////////////////////////////////////////////////////////////////////////////////////
00088 //////////////////////////////////////////////////////////////////////////////////////////
00089
00090 BEGIN_MESSAGE_MAP(CAttributeValueEditor, CEdit)
00091   ON_CONTROL_REFLECT_EX(EN_CHANGE, OnChange)
00092 END_MESSAGE_MAP()
00093
00094 BOOL CAttributeValueEditor::OnChange()
00095 {
00096   m_pEditor->OnEditChange();
00097   return FALSE;
00098 }
00099
00100 //////////////////////////////////////////////////////////////////////////////////////////
00101
00102 BEGIN_MESSAGE_MAP(CMultiValuedListBox, CListBox)
00103   ON_CONTROL_REFLECT_EX(LBN_SELCHANGE, OnSelChange)
00104 END_MESSAGE_MAP()
00105
00106 BOOL CMultiValuedListBox::OnSelChange()
00107 {
00108   m_pEditor->OnValueSelChange();
00109   return FALSE;
00110 }
00111
00112 //////////////////////////////////////////////////////////////////////////////////////////
00113
00114 BEGIN_MESSAGE_MAP(CAttributeValueAddButton, CButton)
00115   ON_CONTROL_REFLECT_EX(BN_CLICKED, OnAdd)
00116 END_MESSAGE_MAP()
00117
00118 BOOL CAttributeValueAddButton::OnAdd()
00119 {
00120   m_pEditor->OnAddValue();
00121   return FALSE;
00122 }
00123
00124 //////////////////////////////////////////////////////////////////////////////////////////
00125
00126 BEGIN_MESSAGE_MAP(CAttributeValueDeleteButton, CButton)
00127   ON_CONTROL_REFLECT_EX(BN_CLICKED, OnDelete)
00128 END_MESSAGE_MAP()
00129
00130 BOOL CAttributeValueDeleteButton::OnDelete()
00131 {
00132   m_pEditor->OnDeleteValue();
00133   return FALSE;
00134 }
00135
00136 //////////////////////////////////////////////////////////////////////////////////////////
00137
00138 CMultiValuedAttributeEditor::CMultiValuedAttributeEditor(CStringList& strrefAttributeList) :
00139   m_ValueEditor(this),
00140   m_ValueList(this),
00141   m_AddButton(this),
00142   m_DeleteButton(this),
00143   m_strrefAttributeList(strrefAttributeList)
00144
00145 {
00146 }
00147
00148 BOOL CMultiValuedAttributeEditor::Initialize(UINT nEditBox,
00149                                               UINT nListBox,
00150                                               UINT nAddButton,
00151                                               UINT nDeleteButton,
00152                                               CWnd* pParentWnd)
00153 {
00154   BOOL bRes = TRUE;
00155
00156   //
00157   // Subclass controls
00158   //
00159   bRes = m_ValueEditor.SubclassDlgItem(nEditBox, pParentWnd);
00160   ASSERT(bRes);
00161   if (!bRes) return FALSE;
00162
00163   bRes = m_ValueList.SubclassDlgItem(nListBox, pParentWnd);
00164   ASSERT(bRes);
00165   if (!bRes) return FALSE;
00166
00167   bRes = m_AddButton.SubclassDlgItem(nAddButton, pParentWnd);
00168   ASSERT(bRes);
00169   if (!bRes) return FALSE;
00170
00171   bRes = m_DeleteButton.SubclassDlgItem(nDeleteButton, pParentWnd);
00172   ASSERT(bRes);
00173   if (!bRes) return FALSE;
00174
00175   //
00176   // Add strings to list box
00177   //
00178   POSITION pos = m_strrefAttributeList.GetHeadPosition();
00179   while (pos != NULL)
00180   {
00181     CString szAddString = m_strrefAttributeList.GetNext(pos);
00182     m_ValueList.AddString(szAddString);
00183   }
00184   return bRes;
00185 }
00186
00187 void CMultiValuedAttributeEditor::OnEditChange()
00188 {
00189   CString szNewValue;
00190   m_ValueEditor.GetWindowText(szNewValue);
00191
00192   m_AddButton.EnableWindow(!szNewValue.IsEmpty());
00193 }
00194
00195 void CMultiValuedAttributeEditor::OnValueSelChange()
00196 {
00197   int nSelection = m_ValueList.GetCurSel();
00198   m_DeleteButton.EnableWindow(nSelection != LB_ERR);
00199 }
00200
00201 void CMultiValuedAttributeEditor::OnAddValue()
00202 {
00203   CString szNewValue;
00204   m_ValueEditor.GetWindowText(szNewValue);
00205
00206   m_strrefAttributeList.AddTail(szNewValue);
00207   if (m_ValueList.AddString(szNewValue) != LB_ERR)
00208   {
00209     m_ValueEditor.SetWindowText(_T(""));
00210   }
00211 }
00212
00213 void CMultiValuedAttributeEditor::OnDeleteValue()
00214 {
00215   int nSelection = m_ValueList.GetCurSel();
00216   if (nSelection != LB_ERR)
00217   {
00218     m_ValueList.DeleteString(nSelection);
00219
00220     POSITION pos = m_strrefAttributeList.FindIndex(nSelection);
00221     if (pos != NULL)
00222     {
00223       m_strrefAttributeList.RemoveAt(pos);
00224     }
00225   }
00226 }
00227
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

fileline Member List

This is the complete list of members for fileline, including all inherited members.
flags | fileline
hash | fileline
linenr | fileline
link | fileline
pwzText | fileline
text | fileline
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/StdAfx.Cpp Source File

  • NetDS
  • fax
  • PrintSdi

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  PrintSDI.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/foldernode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

foldernode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CFolderNode class.
00014 //
00015
00016
00017 #include "FolderNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020 #include "AddVFileDlg.h"
00021                              // Tracing stuff
00022 #include "TraceMacro.h"
00023 #undef  MODULESTRING
00024 #define MODULESTRING  _T("CFolderNode")
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CFolderNode::thisGUID = CLSID_CFolderNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 CFolderNode::CFolderNode()
00035 {
00036   m_SDI.mask        = DEFAULT_SDI_MASK;
00037   m_SDI.displayname = MMC_CALLBACK;
00038   m_SDI.nImage      = IMG_FOLDER_DEFAULT;
00039   m_SDI.nOpenImage  = IMG_FOLDER_DEFAULT;
00040   m_SDI.cChildren   = 0;              // Determines if the '+' is displayed
00041   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00042
00043   m_dwAttributes    = 0;
00044   m_pCompData       = NULL;
00045   m_hAddVFileDlg    = NULL;
00046   m_hMessageWnd     = NULL;
00047
00048 }
00049
00050 CFolderNode::~CFolderNode()
00051 {
00052 }
00053
00054 //---------------------------------------------------------------------------
00055 //  This node does not need to call it's parent so we can ignore
00056 //  pNodeProps->pParentObject
00057 //
00058 HRESULT CFolderNode::Initialize( NODE_PROPERTIES* pNodeProps )
00059 {
00060   _ASSERT( NULL != pNodeProps );
00061   HRESULT hResult = S_FALSE;
00062
00063   SIZE_T  nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00064   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00065   wcscpy( pszTmp, pNodeProps->szNodeName );
00066   if( NULL != m_pwszNodeName )
00067     CoTaskMemFree( m_pwszNodeName );
00068
00069   m_pwszNodeName = pszTmp;
00070   m_pCompData = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00071
00072   RefreshNodeList();         // Create Result Item nodes
00073
00074   // We create a hidden window to allow us to communicate with modeless
00075   // dialogs and other things which run in a seperate thread.
00076
00077   WNDCLASS wc;
00078   ZeroMemory (&wc, sizeof(WNDCLASS));
00079   wc.cbWndExtra    = sizeof(this);
00080   wc.lpfnWndProc   = FolderNodeWndProc;
00081   wc.hInstance     = g_hInst;
00082   wc.lpszClassName = _T("FolderNodeMsgWnd");
00083
00084   RegisterClass( &wc );
00085   m_hMessageWnd = CreateWindow( _T("FolderNodeMsgWnd"), NULL,
00086                                 0, 0, 0, 0, 0, NULL, 0, g_hInst, this);
00087
00088   if( NULL == m_hMessageWnd )
00089     hResult = S_FALSE;
00090
00091   return hResult;
00092 }
00093
00094 //---------------------------------------------------------------------------
00095 //  This is our hidden window which is just used for handling messages.  We
00096 //  go to all this trouble so that we don't ever pass interface pointers or
00097 //  other objects across threads.
00098 //
00099 LRESULT CALLBACK CFolderNode::FolderNodeWndProc
00100 (
00101   HWND   hWnd,     //[in] Handle to window
00102   UINT   uMsg,     //[in] Message identifier
00103   WPARAM wParam,   //[in] First message parameter
00104   LPARAM lParam    //[in] Second message parameter
00105 )
00106 {
00107   switch( uMsg )
00108   {
00109     case WM_CREATE:
00110     {
00111       LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00112       SetWindowLongPtr( hWnd, 0, (LONG_PTR)lpcs->lpCreateParams );
00113       break;
00114     }
00115
00116     case WM_ADD_VIRTUALFILE:
00117     {
00118       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00119       NODE_PROPERTIES* pProps = (NODE_PROPERTIES*)wParam;
00120       pThisNode->AddVirtualFile( pProps );
00121       break;
00122     }
00123
00124     case WM_VIRTUALFILE_CLOSED:
00125     {
00126       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00127       pThisNode->m_hAddVFileDlg = NULL;
00128     }
00129     default:
00130       return DefWindowProc( hWnd, uMsg, wParam, lParam );
00131   }
00132   return 0;
00133 }
00134
00135
00136 /////////////////////////////////////////////////////////////////////////////
00137 // Implementation of virtual methods
00138
00139 //---------------------------------------------------------------------------
00140 HRESULT CFolderNode::GetResultViewType2
00141 (
00142   MMC_COOKIE             nCookie,  //[in] Identifier of object
00143   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00144 )
00145 {
00146   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00147   if( NULL == pszDescStr )
00148     return E_OUTOFMEMORY;
00149
00150   wcscpy( pszDescStr, L"DefaultListView" );
00151   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00152
00153   return S_OK;
00154 }
00155
00156 //---------------------------------------------------------------------------
00157 HRESULT CFolderNode::GetDisplayInfo
00158 (
00159   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00160 )
00161 {
00162   _ASSERT( NULL != pSDI );
00163   pSDI->displayname = m_pwszNodeName;
00164
00165   return S_OK;
00166 }
00167
00168 //---------------------------------------------------------------------------
00169 HRESULT CFolderNode::GetDisplayInfo
00170 (
00171   RESULTDATAITEM* pRDI
00172 )
00173 {
00174   _ASSERT( NULL != pRDI );
00175
00176   HRESULT hResult = S_OK;
00177
00178   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00179   {                                  // for each column
00180     switch( pRDI->nCol )
00181     {
00182       case 0:
00183         pRDI->str = m_pwszNodeName;
00184         break;
00185
00186       case 1:                        // Attributes not supported yet
00187         pRDI->str = L"No attributes";
00188         break;
00189
00190       default:
00191         hResult = S_FALSE;
00192         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00193         break;
00194     }
00195   }
00196   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00197   {
00198     pRDI->nImage = m_SDI.nImage;
00199   }
00200
00201   TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00202   return hResult;
00203
00204 }
00205
00206 /////////////////////////////////////////////////////////////////////////////
00207 // Implementation of notification handlers
00208
00209
00210 //---------------------------------------------------------------------------
00211 HRESULT CFolderNode::OnSelect
00212 (
00213   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00214   LPARAM        nArg,          //[in] Bools for context & selection state
00215   LPARAM        nParam,        //[in] Not used
00216   LONG_PTR      pComponent     //[in] Points calling CComponent
00217 )
00218 {
00219   HRESULT hResult = S_FALSE;
00220
00221   // Not setting verbs for this node
00222
00223   TRACE_HRESULT(_T("OnSelect"), hResult );
00224   return hResult;
00225 }
00226
00227
00228 //---------------------------------------------------------------------------
00229 HRESULT CFolderNode::OnShow
00230 (
00231   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00232   LPARAM        nArg,          //[in] TRUE if node was selcted
00233   LPARAM        nParam,        //[in] HSCOPEITEM of selected/deselected item
00234   LONG_PTR      pComponent     //[in] Points calling CComponent
00235 )
00236 {
00237   HRESULT  hResult = S_FALSE;
00238
00239   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00240
00241   LPHEADERCTRL2  ipHeaderCtrl2 = NULL;
00242   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL2, (LONG_PTR*)&ipHeaderCtrl2 );
00243   if( S_OK != hResult )
00244    return hResult;
00245
00246   LPRESULTDATA  ipResultData = NULL;
00247   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00248   if( S_OK != hResult )
00249    return hResult;
00250
00251
00252   if( TRUE == nArg )         // Selecting a scope node
00253   {
00254     do
00255     {
00256       hResult = ipHeaderCtrl2->InsertColumn( 0, L"File Name", 0, 150 );
00257       BREAK_ON_ERROR( hResult );
00258
00259       hResult = ipHeaderCtrl2->InsertColumn( 1, L"Attributes", 0, 150 );
00260       BREAK_ON_ERROR( hResult );
00261
00262       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00263       BREAK_ON_ERROR( hResult );
00264
00265       hResult = EnumerateResultItems( ipResultData );
00266       BREAK_ON_ERROR( hResult );
00267
00268     }while(0);
00269   }
00270   else                       // Clean up result items on deselection
00271   {
00272     hResult = ipResultData->DeleteAllRsltItems();
00273   }
00274
00275   TRACE_HRESULT(_T("OnShow"), hResult );
00276   return hResult;
00277 }
00278
00279 //---------------------------------------------------------------------------
00280 HRESULT CFolderNode::OnExpand
00281 (
00282   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00283   LPARAM         nArg,         //[in] TRUE if node was selcted
00284   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00285   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00286 )
00287 {
00288   HRESULT hResult = S_FALSE;
00289
00290   if( NULL == m_pCompData )
00291     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00292
00293
00294   TRACE_HRESULT( _T("OnExpand"), hResult );
00295   return hResult;              // Not expanding anything
00296 }
00297
00298 //---------------------------------------------------------------------------
00299 HRESULT CFolderNode::OnRemoveChildren
00300 (
00301   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00302   LPARAM         nArg,         //[in] TRUE if node was selcted
00303   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00304   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00305 )
00306 {
00307   HRESULT hResult = S_OK;      // Just delete our child nodes, the
00308                                // corresponding result items are cleaned
00309   RemoveNodes();               // up in MMCN_SHOW -> FALSE
00310
00311   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00312   return hResult;
00313 }
00314
00315 //---------------------------------------------------------------------------
00316 HRESULT CFolderNode::OnViewChange
00317 (
00318   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00319   LPARAM         nArg,         //[in] TRUE if node was selcted
00320   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00321   LONG_PTR       pComponent    //[in] Points to calling IComponent
00322 )
00323 {
00324   HRESULT hResult = S_FALSE;
00325   LPRESULTDATA ipResultData = NULL;
00326
00327   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00328   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00329   if( S_OK != hResult )
00330     return hResult;
00331
00332   hResult = EnumerateResultItems( ipResultData );
00333
00334   TRACE_HRESULT( _T("OnViewChange"), hResult );
00335   return hResult;
00336 }
00337
00338 //---------------------------------------------------------------------------
00339 //  MMC_HELP:  This gets called when a FolderNode is selected and
00340 //  the F1 key is pressed.
00341 //
00342 HRESULT CFolderNode::OnContextHelp
00343 (
00344   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00345   LPARAM        nArg,          //[in] Not used
00346   LPARAM        nParam,        //[in] Not used
00347   LONG_PTR      pComponent     //[in] Points calling CComponent
00348 )
00349 {
00350   HRESULT   hResult = S_FALSE;
00351   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00352
00353   LPOLESTR pszBaseHelpPath  = GetHelpFilePath();
00354   LPOLESTR pszTopicPath     = L"::/FolderNodes.html";
00355
00356   // Allocate space for the topic string
00357   SIZE_T nBasePathLen  = wcslen( pszBaseHelpPath );
00358   SIZE_T nTopicPathLen = wcslen( pszTopicPath );
00359   SIZE_T nBufferSize   = (nBasePathLen + nTopicPathLen + 1) * sizeof(WCHAR);
00360
00361   // Build the topic string
00362   LPOLESTR pszThisTopicPath = (LPOLESTR)CoTaskMemAlloc( nBufferSize );
00363   wcscpy( pszThisTopicPath, pszBaseHelpPath );
00364   wcscat( pszThisTopicPath, pszTopicPath );
00365
00366   // Request a pointer to IDisplayHelp
00367   IDisplayHelp* ipDisplayHelp = NULL;
00368   pComp->GetInterface( REQUEST_IDISPLAYHELP, (LONG_PTR*)&ipDisplayHelp );
00369
00370   hResult = ipDisplayHelp->ShowTopic( pszThisTopicPath );
00371
00372   TRACE_HRESULT(_T("OnContextHelp"), hResult );   // Return value is not used
00373   return hResult;
00374 }
00375
00376 /////////////////////////////////////////////////////////////////////////////
00377 //  Support for Context Menus
00378
00379 //---------------------------------------------------------------------------
00380 HRESULT CFolderNode::AddMenuItems
00381 (
00382   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00383   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00384 )
00385 {
00386   _ASSERT( NULL != ipCallback );
00387   HRESULT hResult = S_FALSE;
00388
00389   static CONTEXTMENUITEM ctxMenu;
00390     ctxMenu.lCommandID        = IDM_NEW_VIRTFILE;
00391     ctxMenu.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00392     ctxMenu.fSpecialFlags     = 0;
00393     ctxMenu.strName           = L"New Virtual File...";
00394     ctxMenu.strStatusBarText  = L"Add a new virtual file";
00395
00396
00397   if( NULL == m_hAddVFileDlg )     // If the AddVFile dialog is running
00398     ctxMenu.fFlags = 0;            // gray the menu selection
00399   else
00400     ctxMenu.fFlags = MF_GRAYED;
00401
00402
00403   // Add the 'New Device' option to the New menu if allowed...
00404   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00405   {
00406     hResult = ipCallback->AddItem( &ctxMenu );
00407   }
00408
00409   return hResult;
00410 }
00411
00412 //---------------------------------------------------------------------------
00413 HRESULT CFolderNode::Command
00414 (
00415   long lCommandID          //[in] Indentifier for menu ID
00416 )
00417 {
00418   HRESULT hResult = S_OK;
00419
00420   switch( lCommandID )
00421   {
00422     case IDM_NEW_VIRTFILE:
00423     {
00424       CAddVFileDlg* pDlg = new CAddVFileDlg( IDD_ADDVFILE_DLG, m_hMessageWnd );
00425       m_hAddVFileDlg = pDlg->Create( g_hInst, GetDesktopWindow(), 0 );
00426       break;
00427     }
00428     default:
00429     {
00430       hResult = S_FALSE;
00431       break;
00432     }
00433   }
00434   return hResult;
00435 }
00436
00437 /////////////////////////////////////////////////////////////////////////////
00438 //  Private helpers
00439
00440 //---------------------------------------------------------------------------
00441 HRESULT CFolderNode::RefreshNodeList()
00442 {
00443   NODE_PROPERTIES NodeProps;
00444   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00445   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00446   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00447   NodeProps.dwAttributes   = 0;
00448
00449   WCHAR  szNames[1][32];
00450   wcscpy( szNames[0], L"Virtual File 1" );
00451
00452   RemoveNodes();             // Clean the node list
00453
00454   CVirtualFile* pNode = NULL;
00455   for( DWORD i = 0; i < 1; i++ )
00456   {
00457     wcscpy( NodeProps.szNodeName, szNames[i] );
00458     pNode = new CVirtualFile;
00459     pNode->Initialize( &NodeProps );
00460     m_NodeList.AddTail( pNode );
00461   }
00462
00463   return S_OK;
00464 }
00465
00466 //---------------------------------------------------------------------------
00467 VOID CFolderNode::RemoveNodes()
00468 {
00469   CVirtualFile* pNode = NULL;
00470   POSITION   Pos   = m_NodeList.GetHeadPosition();
00471   while( Pos )
00472   {
00473     pNode = m_NodeList.GetNext( Pos );
00474     delete pNode;
00475   }
00476   m_NodeList.RemoveAll();              // Clean the list
00477 }
00478
00479 //---------------------------------------------------------------------------
00480 VOID CFolderNode::RemoveVirtualFile
00481 (
00482   CVirtualFile* pDeadNode    //[in] CVirtualFile to remove from list
00483 )
00484 {
00485   CVirtualFile* pNode = NULL;
00486   POSITION     NewPos = m_NodeList.GetHeadPosition();
00487   POSITION     OldPos = NULL;
00488   while( NewPos )
00489   {
00490     OldPos = NewPos;                   // Need to save this
00491     pNode = m_NodeList.GetNext( NewPos );
00492     if( pNode == pDeadNode )
00493     {
00494       m_NodeList.RemoveAt( OldPos );
00495       continue;                        // Exit, found it
00496     }
00497   }
00498 }
00499
00500 //---------------------------------------------------------------------------
00501 HRESULT CFolderNode::AddVirtualFile
00502 (
00503   NODE_PROPERTIES* pProps    //[in] Properties of new node
00504 )
00505 {
00506   _ASSERT( NULL != pProps );
00507   HRESULT hResult = S_FALSE;
00508
00509   pProps->pParentObject  = reinterpret_cast<LONG_PTR>(this);
00510   pProps->pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00511
00512   CVirtualFile* pNode = NULL;
00513   pNode = new CVirtualFile;
00514   pNode->Initialize( pProps );
00515   m_NodeList.AddTail( pNode );
00516
00517   LPCONSOLE3 ipConsole = NULL;
00518   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole );
00519   if( S_OK != hResult )
00520     return hResult;
00521
00522   LPDATAOBJECT pDO = NULL;
00523   m_pCompData->QueryDataObject( (MMC_COOKIE)this, CCT_SCOPE, &pDO );
00524
00525   ipConsole->UpdateAllViews( pDO, 0, 0 );
00526   pDO->Release();
00527
00528   return hResult;
00529 }
00530
00531
00532 //---------------------------------------------------------------------------
00533 HRESULT CFolderNode::EnumerateResultItems
00534 (
00535   LPRESULTDATA ipResultData  //[in] Points to cached IResultData
00536 )
00537 {
00538   _ASSERT( NULL != ipResultData );
00539   HRESULT hResult = S_FALSE;
00540
00541   hResult = ipResultData->DeleteAllRsltItems();
00542
00543   CVirtualFile*  pNode = NULL;
00544   POSITION       Pos   = m_NodeList.GetHeadPosition();
00545   while( Pos )
00546   {
00547     pNode = m_NodeList.GetNext( Pos );
00548     hResult = ipResultData->InsertItem( &pNode->m_RDI );
00549   }
00550
00551   return hResult;
00552 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/stream.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

stream.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module STREAM.CPP | CStream object implementation
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014
00015
00016 // Code ----------------------------------------------------------------------
00017
00018 // CStream::CStream ----------------------------------------------------------
00019 //
00020 // @mfunc Constructor for this class
00021 //
00022 // @rdesc NONE
00023 //
00024 CStream::CStream
00025     (
00026     LPUNKNOWN pUnkOuter         //@parm IN | Outer Unkown Pointer
00027     ) // invoke ctor for base class
00028   : CBaseObj( BOT_STREAM )
00029 {
00030   //  Initialize simple member vars
00031     m_cRef          = 0L;
00032   m_pUnkOuter   = pUnkOuter ? pUnkOuter : this;
00033
00034   m_pBuffer   = NULL;
00035   m_pParentObj  = NULL;
00036   m_iPos      = 0;
00037   m_cMaxSize    = 0;
00038
00039     //  Initially, NULL all contained interfaces
00040   m_pIGetSourceRow  = NULL;
00041   m_pIStream      = NULL;
00042 }
00043
00044
00045 // CStream::~CStream ---------------------------------------------------------
00046 //
00047 // @mfunc Destructor for this class
00048 //
00049 // @rdesc NONE
00050 //
00051 CStream::~CStream()
00052 {
00053     //  Free contained interfaces
00054   SAFE_DELETE( m_pIGetSourceRow );
00055   SAFE_DELETE( m_pIStream );
00056
00057   if( m_pBuffer )
00058     delete [] m_pBuffer;
00059
00060   if( m_pParentObj )
00061     m_pParentObj->GetOuterUnknown()->Release();
00062 }
00063
00064
00065 // CStream::FInit ------------------------------------------------------------
00066 //
00067 // @mfunc Initialize the stream Object
00068 //
00069 // @rdesc Did the Initialization Succeed
00070 //      @flag  TRUE  | Initialization succeeded
00071 //      @flag  FALSE | Initialization failed
00072 //
00073 BOOL CStream::FInit
00074     (
00075   CRow *    pParentRow,   //@parm IN | pointer to parent Row object
00076   ROWBUFF * pRowBuff    //@par, IN | pointer to row buffer
00077     )
00078 {
00079   // Asserts
00080   assert(pParentRow);
00081   assert(pRowBuff);
00082
00083   m_pParentObj = pParentRow;
00084   m_pParentObj->GetOuterUnknown()->AddRef();
00085
00086     // Allocate contained interface objects
00087     m_pIStream      = new CImpIStream( this, m_pUnkOuter );
00088   m_pIGetSourceRow  = new CImpIGetSourceRow( this, m_pUnkOuter );
00089
00090   m_cMaxSize = pParentRow->m_cbRowSize;
00091   m_pBuffer = new BYTE [ROUND_UP(m_cMaxSize , COLUMN_ALIGNVAL)];
00092   if( m_pBuffer )
00093   {
00094     memcpy(m_pBuffer, pRowBuff->cdData, m_cMaxSize );
00095   }
00096
00097     // if all interfaces were created, return success
00098     return (BOOL) ( m_pIStream && m_pIGetSourceRow && m_pBuffer);
00099 }
00100
00101
00102 // CStream::QueryInterface ---------------------------------------------------
00103 //
00104 // @mfunc Returns a pointer to a specified interface. Callers use
00105 // QueryInterface to determine which interfaces the called object
00106 // supports.
00107 //
00108 // @rdesc HRESULT indicating the status of the method
00109 //      @flag S_OK | Interface is supported and ppvObject is set.
00110 //      @flag E_NOINTERFACE | Interface is not supported by the object
00111 //      @flag E_INVALIDARG | One or more arguments are invalid.
00112 //
00113 STDMETHODIMP CStream::QueryInterface
00114     (
00115     REFIID riid,
00116     LPVOID * ppv
00117     )
00118 {
00119     if( NULL == ppv )
00120     return E_INVALIDARG;
00121
00122   //  Place NULL in *ppv in case of failure
00123     *ppv = NULL;
00124
00125   //IUNKNOWN
00126   if( riid == IID_IUnknown )
00127     *ppv = this;
00128   else if( riid == IID_IGetSourceRow )
00129     *ppv = m_pIGetSourceRow;
00130   else if( riid == IID_IStream )
00131     *ppv = m_pIStream;
00132   else if (riid == IID_ISequentialStream )
00133     *ppv = m_pIStream;
00134
00135     //  If we're going to return an interface, AddRef it first
00136     if (*ppv)
00137         {
00138         ((LPUNKNOWN) *ppv)->AddRef();
00139         return S_OK;
00140         }
00141     else
00142         return E_NOINTERFACE;
00143 }
00144
00145
00146 // CStream::AddRef -----------------------------------------------------------
00147 //
00148 // @mfunc Increments a persistence count for the object
00149 //
00150 // @rdesc Current reference count
00151 //
00152 STDMETHODIMP_( ULONG ) CStream::AddRef
00153      (
00154      void
00155      )
00156 {
00157     return ++m_cRef;
00158 }
00159
00160
00161 // CStream::Release ----------------------------------------------------------
00162 //
00163 // @mfunc Decrements a persistence count for the object and if
00164 // persistence count is 0, the object destroys itself.
00165 //
00166 // @rdesc Current reference count
00167 //
00168 STDMETHODIMP_( ULONG ) CStream::Release
00169      (
00170      void
00171      )
00172 {
00173     if (!--m_cRef)
00174         {
00175         delete this;
00176         return 0;
00177         }
00178
00179     return m_cRef;
00180 }
00181
00182
00183 // CImpIGetSourceRow::GetSourceRow -------------------------------------------
00184 //
00185 // @mfunc Returns the interface pointer of the row object that created this
00186 // stream
00187 //
00188 // @rdesc HRESULT
00189 //      @flag S_OK                | Method Succeeded
00190 //      @flag E_INVALIDARG        | ppRow was NULL
00191 //    @flag DB_E_NOSOURCEOBJECT | No row object context for the stream
00192 //
00193 STDMETHODIMP CImpIGetSourceRow::GetSourceRow
00194   (
00195   REFIID    riid,
00196   IUnknown ** ppRow
00197   )
00198 {
00199   assert( m_pObj );
00200   assert( m_pObj->m_pParentObj );
00201
00202   //Null output arg
00203   if( ppRow )
00204     *ppRow = NULL;
00205
00206   //Check for E_INVALIDARG condition
00207   if( NULL == ppRow )
00208     return E_INVALIDARG;
00209
00210   return m_pObj->m_pParentObj->GetOuterUnknown()->QueryInterface(riid, (LPVOID*)ppRow);
00211 }
00212
00213
00214 // CImpIStream::Read ---------------------------------------------------------
00215 //
00216 // @mfunc Reads from the stream
00217 //
00218 // @rdesc HRESULT
00219 //      @flag S_OK                | Method Succeeded
00220 //
00221 HRESULT CImpIStream::Read
00222   (
00223   void *  pv,
00224   ULONG cb,
00225   ULONG * pcbRead
00226   )
00227 {
00228   assert( m_pObj );
00229   assert( m_pObj->m_pParentObj );
00230
00231   ULONG cbRead = 0;
00232   ULONG cBytesLeft = 0;
00233   ULONG cBytesRead = 0;
00234
00235   if( !pv )
00236     return STG_E_INVALIDPOINTER;
00237
00238   if( cb == 0 )
00239     return S_OK;
00240
00241   cBytesLeft = m_pObj->m_cMaxSize > m_pObj->m_iPos ? m_pObj->m_cMaxSize - m_pObj->m_iPos : 0;
00242   cBytesRead = cb > cBytesLeft ? cBytesLeft : cb;
00243
00244   //if no more bytes to retrive return
00245   if(cBytesLeft == 0)
00246     return S_FALSE;
00247
00248   //Copy to users buffer the number of bytes requested or remaining
00249   memcpy(pv, (void*)((BYTE*)m_pObj->m_pBuffer + m_pObj->m_iPos), cBytesRead);
00250
00251   if(pcbRead)
00252     *pcbRead = cBytesRead;
00253
00254   m_pObj->m_iPos += cBytesRead;
00255
00256   if(cb != cBytesRead)
00257     return S_FALSE;
00258
00259   return S_OK;
00260 }
00261
00262
00263 ///////////////////////////////////////////////////////////////////////////////
00264 // CImpIStream::Write
00265 //
00266 ///////////////////////////////////////////////////////////////////////////////
00267 HRESULT CImpIStream::Write
00268   (
00269   const void *  pv,
00270   ULONG     cb,
00271   ULONG *     pcbWritten
00272   )
00273 {
00274   // Sample Provider's stream are strictly read only
00275   return STG_E_ACCESSDENIED;
00276 }
00277
00278
00279 ///////////////////////////////////////////////////////////////////////////////
00280 // HRESULT CImpIStream::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER * plibNewPosition)
00281 //
00282 ///////////////////////////////////////////////////////////////////////////////
00283 HRESULT CImpIStream::Seek
00284   (
00285   LARGE_INTEGER   dlibMove,
00286   DWORD       dwOrigin,
00287   ULARGE_INTEGER *  plibNewPosition
00288   )
00289 {
00290   DWORDLONG ullOffset = 0;
00291   HRESULT   hr = S_OK;
00292   CStream * pCStream = (CStream *) m_pObj;
00293
00294   //Determine with respect to what the origin is...
00295   switch(dwOrigin)
00296   {
00297     case STREAM_SEEK_SET:
00298       ullOffset = dlibMove.QuadPart;
00299       break;
00300
00301     case STREAM_SEEK_CUR:
00302       ullOffset = pCStream->m_iPos + dlibMove.QuadPart;
00303       break;
00304
00305     case STREAM_SEEK_END:
00306       ullOffset = pCStream->m_cMaxSize + dlibMove.QuadPart;
00307       break;
00308
00309     default:
00310       //The value of the dwOrigin parameter is not valid
00311       return STG_E_INVALIDFUNCTION;
00312   };
00313
00314   //Make sure the new offset is within the range, for some reason ::Seek
00315   //allows going off the end of the stream...
00316   if( ullOffset < 0 || ullOffset > pCStream->m_cMaxSize )
00317     return STG_E_INVALIDFUNCTION;
00318
00319   //Reset the current buffer position
00320   pCStream->m_iPos = (ULONG)ullOffset;
00321
00322   if(plibNewPosition)
00323     plibNewPosition->QuadPart = pCStream->m_iPos;
00324
00325   return hr;
00326 }
00327
00328
00329 ///////////////////////////////////////////////////////////////////////////////
00330 // HRESULT CImpIStream::SetSize(  ULARGE_INTEGER libNewSize)
00331 //
00332 ///////////////////////////////////////////////////////////////////////////////
00333 HRESULT CImpIStream::SetSize
00334   (
00335   ULARGE_INTEGER libNewSize   //Specifies the new size of the stream object
00336   )
00337 {
00338   return E_NOTIMPL;
00339 }
00340
00341
00342 ///////////////////////////////////////////////////////////////////////////////
00343 // HRESULT CImpIStream::CopyTo
00344 //
00345 ///////////////////////////////////////////////////////////////////////////////
00346 HRESULT CImpIStream::CopyTo
00347   (
00348   IStream *     pIStream, //Points to the destination stream
00349   ULARGE_INTEGER    cb,     //Specifies the number of bytes to copy
00350   ULARGE_INTEGER *  pcbRead,  //Pointer to the actual number of bytes read from the source
00351   ULARGE_INTEGER *  pcbWritten  //Pointer to the actual number of bytes written to the destination
00352   )
00353 {
00354   return E_NOTIMPL;
00355 }
00356
00357
00358 // CImpIStream::Commit -------------------------------------------------------
00359 //
00360 // @mfunc Commit
00361 //
00362 // @rdesc HRESULT
00363 //      @flag S_OK
00364 //
00365 HRESULT CImpIStream::Commit
00366   (
00367   DWORD grfCommitFlags      //Specifies how changes are committed
00368   )
00369 {
00370   return S_OK;
00371 }
00372
00373
00374 // CImpIStream::Revert -------------------------------------------------------
00375 //
00376 // @mfunc Revert
00377 //
00378 // @rdesc HRESULT
00379 //      @flag S_OK
00380 //
00381 HRESULT CImpIStream::Revert()
00382 {
00383   return S_OK;
00384 }
00385
00386
00387 // CImpIStream::LockRegion ---------------------------------------------------
00388 //
00389 // @mfunc Unlock
00390 //
00391 // @rdesc HRESULT
00392 //      @flag STG_E_INVALIDFUNCTION               |  Not implemented
00393 //
00394 HRESULT CImpIStream::LockRegion
00395   (
00396   ULARGE_INTEGER libOffset, //Specifies the byte offset for the beginning of the range
00397   ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
00398   DWORD dwLockType      //Specifies the restriction on accessing the specified range
00399   )
00400 {
00401   return STG_E_INVALIDFUNCTION;
00402 }
00403
00404
00405 // CImpIStream::UnlockRegion -------------------------------------------------
00406 //
00407 // @mfunc Unlock
00408 //
00409 // @rdesc HRESULT
00410 //      @flag STG_E_INVALIDFUNCTION               |  Not implemented
00411 //
00412 HRESULT CImpIStream::UnlockRegion
00413   (
00414   ULARGE_INTEGER libOffset, //Specifies the byte offset for the beginning of the range
00415   ULARGE_INTEGER cb,      //Specifies the length of the range in bytes
00416   DWORD dwLockType      //Specifies the access restriction previously placed on the range
00417   )
00418 {
00419   //Locking is optional
00420   return STG_E_INVALIDFUNCTION;
00421 }
00422
00423
00424 // CImpIStream::Stat ---------------------------------------------------------
00425 //
00426 // @mfunc Stat
00427 //
00428 // @rdesc HRESULT
00429 //      @flag S_OK                  | method succeeded
00430 //    @flag STG_E_INVALIDPOINTER  | pstatstg was null
00431 //    @flag STG_E_INVALIDFLAG   | invalid flag
00432 //
00433 HRESULT CImpIStream::Stat
00434   (
00435   STATSTG * pstatstg,       //Location for STATSTG structure
00436   DWORD   grfStatFlag       //Values taken from the STATFLAG enumeration
00437   )
00438 {
00439   if(!pstatstg)
00440     return STG_E_INVALIDPOINTER;
00441 #if 0
00442   //Initialize the struct
00443   memset(pstatstg, 0, sizeof(STATSTG));
00444
00445   //Set the string...
00446   if(grfStatFlag & STATFLAG_NONAME)
00447     pstatstg->pwcsName = NULL;
00448   else if(grfStatFlag & STATFLAG_DEFAULT)
00449     pstatstg->pwcsName = wcsDuplicate(L"Sample Provider Storage Object...");
00450   else
00451     return STG_E_INVALIDFLAG;
00452
00453   //type
00454   pstatstg->type = STGTY_STREAM;
00455   pstatstg->grfMode = STGM_READ;
00456   pstatstg->grfLocksSupported = 0;
00457
00458   ULARGE_INTEGER largeInteger = { m_pObj->m_cMaxSize };
00459   pstatstg->cbSize = largeInteger;
00460 #endif
00461
00462   return S_OK;
00463 }
00464
00465
00466 // CImpIStream::Clone --------------------------------------------------------
00467 //
00468 // @mfunc Clone the stream
00469 //
00470 // @rdesc HRESULT
00471 //      @flag E_NOTIMPL                |  Not implemented
00472 //
00473 HRESULT CImpIStream::Clone(IStream ** ppIStream)
00474 {
00475   return E_NOTIMPL;
00476 }
00477
00478
00479
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/ATMEvent/Enumerator.Cpp Source File

  • NetDS
  • WinSock
  • ATMEvent

Enumerator.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      enumerator.cpp
00010 //
00011 // Abstract:
00012 //
00013 // Entry Points:
00014 //      Enumerator - enumerate ATM interfaces on the local machine.
00015 //
00016 // Author:
00017 //      Barry R. Butterklee
00018
00019
00020 #include "atmevent.h"
00021
00022
00023 // Abstract:
00024 //      Determine the number of ATM adapters on the machine and then print out
00025 //      a list of each adaptors NSAP address.
00026 //
00027 //
00028 void Enumerator(
00029                OPTIONS          *pOptions
00030                )
00031 {
00032     SOCKET          sd = INVALID_SOCKET;
00033     SOCKADDR_ATM    atm_addr = {0};
00034     CHAR            szAddress[MAX_ATM_INTERFACE_LEN] = {'\0'};
00035     DWORD           dwNumInterfaces = 0;
00036     DWORD           dwAddrLen = 0;
00037     DWORD           dwBytes=sizeof(DWORD);
00038     int             nRet = 0;
00039
00040
00041     sd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
00042                    &pOptions->protocolInfo, 0, WSA_FLAG_OVERLAPPED);
00043     if (INVALID_SOCKET == sd)
00044     {
00045         printf("WSASocket: %d\n", WSAGetLastError());
00046         return;
00047     }
00048
00049     nRet = WSAIoctl(sd, SIO_GET_NUMBER_OF_ATM_DEVICES,
00050                     NULL, 0,
00051                     (LPVOID)&dwNumInterfaces, sizeof(dwNumInterfaces), &dwBytes,
00052                     NULL, NULL);
00053     if (SOCKET_ERROR == nRet)
00054     {
00055         printf("WSAIoctl:SIO_GET_NUMBER_OF_ATM_DEVICES: %d\n", WSAGetLastError());
00056         return;
00057     }
00058
00059     for (DWORD i=0; i < dwNumInterfaces ;i++)
00060     {
00061         ZeroMemory(&atm_addr, sizeof(SOCKADDR_ATM));
00062
00063         nRet = WSAIoctl(sd, SIO_GET_ATM_ADDRESS,
00064                         (LPVOID)&i, sizeof(DWORD),
00065                         (LPVOID)&atm_addr.satm_number, sizeof(atm_addr.satm_number), &dwBytes,
00066                         NULL, NULL);
00067         if (SOCKET_ERROR == nRet)
00068         {
00069             printf("WSAIoctl:SIO_GET_ATM_ADDRESS: %d\n", WSAGetLastError());
00070             return;
00071         }
00072
00073         // fill in remainder of ATM address structure
00074         atm_addr.satm_family                 = AF_ATM;
00075         atm_addr.satm_number.AddressType     = ATM_NSAP;
00076         atm_addr.satm_number.NumofDigits     = ATM_ADDR_SIZE;
00077         atm_addr.satm_blli.Layer2Protocol    = SAP_FIELD_ANY;
00078         atm_addr.satm_blli.Layer3Protocol    = SAP_FIELD_ABSENT;
00079         atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
00080
00081         ZeroMemory(szAddress, sizeof(szAddress));
00082         dwAddrLen = sizeof(szAddress);
00083         if (SOCKET_ERROR == WSAAddressToString((LPSOCKADDR)&atm_addr, sizeof(atm_addr),
00084                                &pOptions->protocolInfo, szAddress, &dwAddrLen))
00085         {
00086             printf("WSAAddressToString: %d\n", WSAGetLastError());
00087             break;
00088         }
00089         printf("ATM Interface [%d]: <%s>\n", i, szAddress);
00090     }
00091
00092     if (INVALID_SOCKET != sd)
00093     {
00094         closesocket(sd);
00095         sd = INVALID_SOCKET;
00096     }
00097     return;
00098 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/RealTimeStylusPlugin/C#/CustomDynamicRendererPlugin.cs Source File

  • TabletPC
  • RealTimeStylusPlugin
  • C#

CustomDynamicRendererPlugin.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2004 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: CustomDynamicRendererPlugin.cs
00013 //  Real time stylus plugin that demonstrates custom
00014 //  dynamic rendering.
00015 //
00016 //  This class implements the real time stylus plugin
00017 //  interface to receive pen input notifications.  It then
00018 //  handles the Packets notification to draw a small circle
00019 //  around each new packet point.
00020 //
00021 //  The features used are: IRealTimeStylusPlugin
00022 //
00023 //--------------------------------------------------------------------------
00024
00025 using System;
00026 using System.Drawing;
00027 using System.Diagnostics;
00028
00029 // The Microsoft Tablet PC namespaces
00030 using Microsoft.Ink;
00031 using Microsoft.StylusInput;
00032 using Microsoft.StylusInput.PluginData;
00033
00034 namespace RealTimeStylusPlugins
00035 {
00036     /// <summary>
00037     /// A real time stylus plugin that demonstrates
00038     /// custom dynamic rendering.
00039     /// </summary>
00040     public class CustomDynamicRendererPlugin:IStylusSyncPlugin
00041     {
00042         // Declare the graphics object used for dynamic rendering
00043         private Graphics myGraphics;
00044
00045         /// <summary>
00046         /// Constructor for this plugin
00047         /// </summary>
00048         /// <param name="g">The graphics object used for dynamic rendering.</param>
00049         public CustomDynamicRendererPlugin(Graphics g)
00050         {
00051             myGraphics = g;
00052         }
00053
00054
00055         /// <summary>
00056         /// Occurs when the stylus moves on the digitizer surface.
00057         /// Use this notification to draw a small circle around each
00058         /// new packet received.
00059         /// </summary>
00060         /// <param name="sender">The real time stylus associated with the notification</param>
00061         /// <param name="data">The notification data</param>
00062         public void Packets(RealTimeStylus sender,  PacketsData data)
00063         {
00064             // For each new packet received, extract the x,y data
00065             // and draw a small circle around the result.
00066             for (int i = 0; i < data.Count; i += data.PacketPropertyCount)
00067             {
00068                 // Packet data always has x followed by y followed by the rest
00069                 Point point = new Point(data[i], data[i+1]);
00070
00071                 // Since the packet data is in Ink Space coordinates, we need to convert to Pixels...
00072                 point.X = (int)Math.Round((float)point.X * (float)myGraphics.DpiX/2540.0F);
00073                 point.Y = (int)Math.Round((float)point.Y * (float)myGraphics.DpiY/2540.0F);
00074
00075                 // Draw a circle corresponding to the packet
00076                 myGraphics.DrawEllipse(Pens.Green, point.X - 2, point.Y - 2, 4, 4);
00077             }
00078         }
00079
00080         /// <summary>
00081         /// Called when the current plugin or the ones previous in the list
00082         /// threw an exception.
00083         /// </summary>
00084         /// <param name="sender">The real time stylus associated with the notification</param>
00085         /// <param name="data">The notification data</param>
00086   public void Error(RealTimeStylus sender, ErrorData data)
00087         {
00088              Debug.Assert(false, null, "An error occurred.  DataId=" + data.DataId + ", " + "Exception=" + data.InnerException);
00089         }
00090
00091         /// <summary>
00092         /// Defines the types of notifications the plugin is interested in.
00093         /// </summary>
00094         public DataInterestMask DataInterest
00095         {
00096             get
00097             {
00098                 return DataInterestMask.Packets | DataInterestMask.Error;
00099             }
00100         }
00101
00102         // The remaining interface methods are not used in this sample application.
00103         public void RealTimeStylusDisabled(RealTimeStylus sender, RealTimeStylusDisabledData data) {}
00104         public void RealTimeStylusEnabled(RealTimeStylus sender, RealTimeStylusEnabledData data){}
00105         public void StylusOutOfRange(RealTimeStylus sender, StylusOutOfRangeData data) {}
00106         public void StylusInRange(RealTimeStylus sender, StylusInRangeData data) {}
00107         public void StylusDown(RealTimeStylus sender, StylusDownData data) {}
00108         public void StylusUp(RealTimeStylus sender, StylusUpData data) {}
00109         public void StylusButtonDown(RealTimeStylus sender, StylusButtonDownData data) {}
00110         public void StylusButtonUp(RealTimeStylus sender, StylusButtonUpData data) {}
00111         public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data){}
00112         public void SystemGesture(RealTimeStylus sender, SystemGestureData data){}
00113         public void InAirPackets(RealTimeStylus sender, InAirPacketsData data){}
00114         public void TabletAdded(RealTimeStylus sender, TabletAddedData data){}
00115         public void TabletRemoved(RealTimeStylus sender, TabletRemovedData data) {}
00116     }
00117 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSendMessageDialog Member List

This is the complete list of members for CSendMessageDialog, including all inherited members.
CSendMessageDialog(CArray< ARRAYQ *, ARRAYQ * > *, CWnd *pParent=NULL) | CSendMessageDialog |
DoDataExchange(CDataExchange *pDX) | CSendMessageDialog | [protected, virtual]
GetAcknowledge() | CSendMessageDialog | [inline]
GetAdminPathName(TCHAR szAdminPathName[BUFFERSIZE]) | CSendMessageDialog | [inline]
GetAuthenticated() | CSendMessageDialog | [inline]
GetDeadLetter() | CSendMessageDialog | [inline]
GetDelivery() | CSendMessageDialog | [inline]
GetEncrypted() | CSendMessageDialog | [inline]
GetJournal() | CSendMessageDialog | [inline]
GetMessageBody(TCHAR *pszMessageBodyBuffer) | CSendMessageDialog | [inline]
GetMessageLabel(TCHAR szMessageLabelBuffer[BUFFERSIZE]) | CSendMessageDialog | [inline]
GetPathName(TCHAR szPathName[BUFFERSIZE]) | CSendMessageDialog | [inline]
GetPriority() | CSendMessageDialog | [inline]
GetTimeToBeReceived() | CSendMessageDialog | [inline]
GetTimeToReachQueue() | CSendMessageDialog | [inline]
IDD enum value | CSendMessageDialog |
m_AdminPathNameCB | CSendMessageDialog |
m_Authenticated | CSendMessageDialog |
m_bPriority | CSendMessageDialog |
m_DeadLetter | CSendMessageDialog |
m_dwTimeToBeReceived | CSendMessageDialog |
m_dwTimeToReachQueue | CSendMessageDialog |
m_Encrypted | CSendMessageDialog |
m_iAck | CSendMessageDialog |
m_iDelivery | CSendMessageDialog |
m_Journal | CSendMessageDialog |
m_PathNameCB | CSendMessageDialog |
m_pStrArray | CSendMessageDialog |
m_strBody | CSendMessageDialog |
m_strLabel | CSendMessageDialog |
m_szAdminPathName | CSendMessageDialog |
m_szPathName | CSendMessageDialog |
OnInitDialog() | CSendMessageDialog | [protected, virtual]
OnOK() | CSendMessageDialog | [protected, virtual]
OnSelchangeTargetCombo() | CSendMessageDialog | [protected]
Generated on Wed Nov 13 2024 16:57:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/FullSvr/fullsvr.Cpp Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • FullSvr

fullsvr.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: FullSvr.cpp
00004
00005 Summary:  Produced by VS6 ATL Wizard. Implements main module for server.exe.
00006           Handles class registration for implementations contained in server.exe.
00007
00008
00009 ----------------------------------------------------------------------------
00010
00011 This file is part of the Microsoft COM+ Samples.
00012
00013 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00014
00015 This source code is intended only as a supplement to Microsoft
00016 Development Tools and/or on-line documentation. See these other
00017 materials for detailed information regarding Microsoft code samples.
00018
00019 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00020 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00022 PARTICULAR PURPOSE.
00023
00024 ==========================================================================+*/
00025 // FullSvr.cpp : Implementation of WinMain
00026
00027
00028 // Note: Proxy/Stub Information
00029 //      To build a separate proxy/stub DLL,
00030 //      run nmake -f FullSvrps.mk in the project directory.
00031
00032 #include "stdafx.h"
00033 #include "resource.h"
00034 #include <initguid.h>
00035 #include <string.h>
00036 #include "FullSvr.h"
00037
00038 #include "FullSvr_i.c"
00039 #include "FullServ.h"
00040
00041
00042 const DWORD dwTimeOut = 5000; // time for EXE to be idle before shutting down
00043 const DWORD dwPause   = 1000; // time to wait for threads to finish up
00044 HANDLE hMonitorThread;
00045 // Passed to CreateThread to monitor the shutdown event
00046 static DWORD WINAPI MonitorProc(void* pv)
00047 {
00048     CExeModule* p = (CExeModule*)pv;
00049     p->MonitorShutdown();
00050     return 0;
00051 }
00052
00053 LONG CExeModule::Unlock()
00054 {
00055     LONG l = CComModule::Unlock();
00056     if (l == 0)
00057     {
00058         bActivity = true;
00059         SetEvent(hEventShutdown); // tell monitor that we transitioned to zero
00060     }
00061     return l;
00062 }
00063
00064 //Monitors the shutdown event
00065 void CExeModule::MonitorShutdown()
00066 {
00067     while (1)
00068     {
00069         WaitForSingleObject(hEventShutdown, INFINITE);
00070         DWORD dwWait=0;
00071         do
00072         {
00073             bActivity = false;
00074             dwWait = WaitForSingleObject(hEventShutdown, dwTimeOut);
00075         } while (dwWait == WAIT_OBJECT_0);
00076         // timed out
00077         if (!bActivity && m_nLockCnt == 0) // if no activity let's really bail
00078         {
00079 #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
00080             CoSuspendClassObjects();
00081             if (!bActivity && m_nLockCnt == 0)
00082 #endif
00083                 break;
00084         }
00085     }
00086     CloseHandle(hEventShutdown);
00087     PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00088 }
00089
00090 bool CExeModule::StartMonitor()
00091 {
00092     hEventShutdown = CreateEvent(NULL, false, false, NULL);
00093     if (hEventShutdown == NULL)
00094         return false;
00095     DWORD dwThreadID;
00096     hMonitorThread = CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
00097     return (hMonitorThread != NULL);
00098 }
00099
00100 CExeModule _Module;
00101
00102 BEGIN_OBJECT_MAP(ObjectMap)
00103 OBJECT_ENTRY(CLSID_FullServ, CFullServ)
00104 END_OBJECT_MAP()
00105
00106
00107 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
00108 {
00109     while (p1 != NULL && *p1 != NULL)
00110     {
00111         LPCTSTR p = p2;
00112         while (p != NULL && *p != NULL)
00113         {
00114             if (*p1 == *p)
00115                 return CharNext(p1);
00116             p = CharNext(p);
00117         }
00118         p1 = CharNext(p1);
00119     }
00120     return NULL;
00121 }
00122
00123 /////////////////////////////////////////////////////////////////////////////
00124 //
00125 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00126     HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
00127 {
00128     lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
00129
00130     HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00131     _ASSERTE(SUCCEEDED(hRes));
00132     _Module.Init(ObjectMap, hInstance, &LIBID_FULLSVRLib);
00133     _Module.dwThreadID = GetCurrentThreadId();
00134     TCHAR szTokens[] = _T("-/");
00135
00136     int nRet = 0;
00137     BOOL bRun = TRUE;
00138     LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
00139     while (lpszToken != NULL)
00140     {
00141         if (_tcsnicmp(lpszToken, _T("UnregServer"), 11)==0)
00142         {
00143             _Module.UpdateRegistryFromResource(IDR_FullSvr, FALSE);
00144             nRet = _Module.UnregisterServer(TRUE);
00145             bRun = FALSE;
00146             break;
00147         }
00148         if (_tcsnicmp(lpszToken, _T("RegServer"), 9)==0)
00149         {
00150             _Module.UpdateRegistryFromResource(IDR_FullSvr, TRUE);
00151             nRet = _Module.RegisterServer(TRUE);
00152             bRun = FALSE;
00153             break;
00154         }
00155         lpszToken = FindOneOf(lpszToken, szTokens);
00156     }
00157
00158     if (bRun)
00159     {
00160         _Module.StartMonitor();
00161         hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00162             REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
00163         _ASSERTE(SUCCEEDED(hRes));
00164         hRes = CoResumeClassObjects();
00165         _ASSERTE(SUCCEEDED(hRes));
00166
00167         MSG msg;
00168         while (GetMessage(&msg, 0, 0, 0))
00169             DispatchMessage(&msg);
00170
00171         _Module.RevokeClassObjects();
00172         Sleep(dwPause); //wait for any threads to finish
00173     }
00174
00175   CloseHandle(hMonitorThread);
00176     _Module.Term();
00177     CoUninitialize();
00178     return nRet;
00179 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

InkBlog::AddBlog Member List

This is the complete list of members for InkBlog::AddBlog, including all inherited members.
CreateGif(String path, String fileName, String inkBody) | InkBlog::AddBlog | [inline, protected]
CreateHtm(String path, String fileName, String blogTitle, String content) | InkBlog::AddBlog | [inline, protected]
InitializeComponent() | InkBlog::AddBlog | [inline, private]
OnInit(EventArgs e) | InkBlog::AddBlog | [inline, protected]
Page_Load(object sender, System.EventArgs e) | InkBlog::AddBlog | [inline, private]
Generated on Wed Nov 13 2024 16:58:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConClien/GUIBALL.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConClien

GUIBALL.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUIBALL.H
00003
00004   Summary:   Include file for the CGuiBall C++ class. A GuiBall is a C++
00005              object that moves and displays a bouncing ball in the client
00006              area of a designated window. GuiBall is anchored to the
00007              Windows GUI (Graphical User Interface) environment. This
00008              GuiBall object continuously paints a ball image based on data
00009              it obtains from a virtual ball object. This virtual ball
00010              object is instantiated as a COM object (a COBall) in a
00011              separate In-process server, CONSERVE.
00012
00013              GuiBall uses the system timer to issue WM_TIMER messages that
00014              cause a continuous moving and displaying of the ball. GuiBall
00015              provides methods to initialize the GuiBall, paint the ball
00016              image, and restart the motion.
00017
00018              For a comprehensive tutorial code tour of GUIBALL's contents
00019              and offerings see the tutorial CONCLIEN.HTM file. For more
00020              specific technical details on the internal workings see the
00021              comments dispersed throughout the GUIBALL source code.
00022
00023   Classes:   CGuiBall
00024
00025   Origin:    5-30-96: atrent - Editor inheritance from GUIBALL.H in the
00026              FRECLIEN source.
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042 #if !defined(GUIBALL_H)
00043 #define GUIBALL_H
00044
00045 #if defined(__cplusplus)
00046
00047
00048 // Here are constants for the delays in milliseconds that control
00049 // the incremental motion of the ball and how often a snapshot of
00050 // the ball image is painted. Other constants are for the ball's
00051 // bounce sound.
00052 enum
00053 {
00054   BALL_PAINT_DELAY  = 30,
00055   BALL_MOVE_DELAY = 100,
00056   BOUNCE_SOUND_DURATION = 30,
00057   BOUNCE_BOTTOM_FREQUENCY = 800,
00058   BOUNCE_SIDE_FREQUENCY = 2400,
00059   BOUNCE_TOP_FREQUENCY = 4800
00060 };
00061
00062
00063 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00064   Class:    CGuiBall
00065
00066   Summary:  Class to encapsulate the displayable Graphical User
00067             Interface GUI Ball object.
00068
00069   Methods:  CGuiBall
00070               Constructor.
00071             ~CGuiBall
00072               Destructor.
00073             BOOL Init(HWND hWnd);
00074               Initialize the GuiBall.
00075             void PaintBall(void);
00076               Paint one image of the Ball.
00077             void Restart(void);
00078               Restart the process including clear window, move ball to
00079               start position, restart motion.
00080             void PaintWin(void);
00081               Repaint the window but don't restart motion.
00082             void BounceBottom(void);
00083             void BounceSide(void);
00084             void BounceTop(void);
00085               Perform GUI acton associated with these bounce events.
00086             HRESULT ConnectBallSink(void);
00087               Connect the BallSink to the server COBall source.
00088             HRESULT DisconnectBallSink(void);
00089               Disconnect the BallSink from the server COBall source.
00090             IConnectionPoint* GetConnectionPoint(REFIID riid);
00091               Private method to obtain a connection point interface.
00092 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00093 class CGuiBall
00094 {
00095   public:
00096     CGuiBall(void);
00097     ~CGuiBall(void);
00098     BOOL Init(HWND hWnd);
00099     void PaintBall(void);
00100     void Restart(void);
00101     void PaintWin(void);
00102     void BounceBottom(void);
00103     void BounceSide(void);
00104     void BounceTop(void);
00105     HRESULT ConnectBallSink(void);
00106     HRESULT DisconnectBallSink(void);
00107
00108   private:
00109     HWND       m_hWnd;
00110     IBall*     m_pIBall;
00111     COLORREF   m_crColor;
00112     POINT      m_OldPos;
00113     POINT      m_OldExt;
00114     IUnknown*  m_pCOBallSink;
00115     DWORD      m_dwBallSink;
00116     DWORD      m_dwBounceSndDur;
00117     DWORD      m_dwBounceBotFreq;
00118     DWORD      m_dwBounceSideFreq;
00119     DWORD      m_dwBounceTopFreq;
00120
00121     IConnectionPoint* GetConnectionPoint(REFIID riid);
00122 };
00123
00124
00125 #endif // __cplusplus
00126
00127 #endif
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagWorkerThreadArgs Member List

This is the complete list of members for _tagWorkerThreadArgs, including all inherited members.
hEvent | _tagWorkerThreadArgs
hr | _tagWorkerThreadArgs
hwnd | _tagWorkerThreadArgs
pThis | _tagWorkerThreadArgs
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/RPCsvc/Client.C Source File

  • NetDS
  • RPC
  • RPCsvc

Client.C

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   client.c
00009 //
00010 //  PURPOSE:  This program is a command line oriented
00011 //            demonstration of the Simple RPC service sample.
00012 //
00013 //  FUNCTIONS:
00014 //    main(int argc, char **argv);
00015 //    StartTime()
00016 //    EndTime();
00017 //    DoTimings();
00018 //
00019 //  COMMENTS:
00020 //
00021 //  AUTHOR:
00022 //      Mario Goertzel - RPC Development
00023 //
00024 #include <windows.h>
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <rpc.h>
00028 #include "rpcsvc.h"
00029
00030 void Usage(void)
00031 {
00032     printf("Usage:\n"
00033         "\t-n <server addr>  - Defaults to local machine\n"
00034         "\t-t <protseq>      - Defaults to ncalrpc (fast, local only)\n"
00035         "\t-i <iterations>   - Defaults to 100\n"
00036         "\t-s <security lvl> - Default none, range none (1) to privacy (6)\n"
00037         );
00038     return;
00039 }
00040
00041
00042 //
00043 //  FUNCTIONS: StartTime()
00044 //             EndTime()
00045 //
00046 //  USAGE:
00047 //      StartTime();
00048 //        // Do some work.
00049 //      mseconds = EndTime();
00050 //
00051 //  RETURN VALUE:
00052 //      Milliseconds between StartTime() and EndTime() calls.
00053
00054 LARGE_INTEGER Time;
00055
00056 void StartTime(void)
00057 {
00058     QueryPerformanceCounter(&Time);
00059 }
00060
00061 ULONG EndTime()
00062 {
00063     LARGE_INTEGER liDiff;
00064     LARGE_INTEGER liFreq;
00065
00066     QueryPerformanceCounter(&liDiff);
00067
00068     liDiff.QuadPart -= Time.QuadPart;
00069     liDiff.QuadPart *= 1000; // Adjust to milliseconds, shouldn't overflow...
00070
00071     (void)QueryPerformanceFrequency(&liFreq);
00072
00073     return ((ULONG)(liDiff.QuadPart / liFreq.QuadPart));
00074 }
00075
00076 //
00077 //  FUNCTION: DoTimings
00078 //
00079 //  PURPOSE: Calls and times various RPC calls.
00080 //           (Avoid cluttering up main())
00081 //
00082 //  PARAMETERS:
00083 //    Binding     - Binding to the server.
00084 //    iIterations - Number of times to make each call.
00085 //
00086 //  RETURN VALUE:
00087 //    n/a
00088 //
00089 //
00090 void DoTimings(RPC_BINDING_HANDLE Binding,
00091                UINT iIterations)
00092 {
00093     ULONG mseconds;
00094     UINT i;
00095     RPC_STATUS status;
00096     byte bBuffer[4096];
00097     ULONG lBufferLength;
00098     ULONG lBufferSize;
00099
00100     // Time Pings() (void calls)
00101
00102     StartTime();
00103     for(i = iIterations; i; i--)
00104         {
00105         status = Ping(Binding);
00106         if (status != RPC_S_OK)
00107             goto Cleanup;
00108         }
00109     mseconds = EndTime();
00110
00111     printf("%4d calls in %8d milliseconds - void calls.\n", iIterations, mseconds);
00112
00113     // Time [in] buffer's
00114     //
00115
00116     lBufferLength = BUFFER_SIZE;
00117     lBufferSize   = BUFFER_SIZE;
00118     StartTime();
00119     for(i = iIterations; i; i--)
00120         {
00121         status = BufferIn1(Binding, bBuffer, lBufferLength, lBufferSize);
00122         if (status != RPC_S_OK)
00123             {
00124             goto Cleanup;
00125             }
00126         }
00127     mseconds = EndTime();
00128
00129     printf("%4d calls in %8d milliseconds - 100 byte buffer in (1).\n", iIterations, mseconds);
00130
00131     lBufferLength = BUFFER_SIZE;
00132
00133     StartTime();
00134     for(i = iIterations; i; i--)
00135         {
00136         status = BufferIn3(Binding, bBuffer, lBufferLength);
00137         if (status != RPC_S_OK)
00138             {
00139             goto Cleanup;
00140             }
00141         }
00142     mseconds = EndTime();
00143
00144     printf("%4d calls in %8d milliseconds - 100 byte buffer in (2).\n", iIterations, mseconds);
00145
00146     lBufferLength = BUFFER_SIZE;
00147
00148     StartTime();
00149     for(i = iIterations; i; i--)
00150         {
00151         status = BufferIn3(Binding, bBuffer, lBufferLength);
00152         if (status != RPC_S_OK)
00153             {
00154             goto Cleanup;
00155             }
00156         }
00157     mseconds = EndTime();
00158
00159     printf("%4d calls in %8d milliseconds - 100 byte buffer in (3).\n", iIterations, mseconds);
00160
00161     // Time [out] buffer's
00162
00163     lBufferLength = BUFFER_SIZE;
00164
00165     StartTime();
00166     for(i = iIterations; i; i--)
00167         {
00168         status = BufferOut1(Binding, bBuffer, &lBufferLength);
00169         if (status != RPC_S_OK)
00170             {
00171             goto Cleanup;
00172             }
00173         }
00174     mseconds = EndTime();
00175
00176     printf("%4d calls in %8d milliseconds - 100 byte buffer out (1).\n", iIterations, mseconds);
00177
00178     lBufferLength = BUFFER_SIZE;
00179     lBufferSize   = BUFFER_SIZE;
00180
00181     StartTime();
00182     for(i = iIterations; i; i--)
00183         {
00184         status = BufferOut2(Binding, bBuffer, lBufferSize, &lBufferLength);
00185         if (status != RPC_S_OK)
00186             {
00187             goto Cleanup;
00188             }
00189         }
00190     mseconds = EndTime();
00191
00192     printf("%4d calls in %8d milliseconds - 100 byte buffer out (2).\n", iIterations, mseconds);
00193
00194     StartTime();
00195     for(i = iIterations; i; i--)
00196         {
00197         BUFFER Buffer;
00198         Buffer.BufferLength = 0;
00199         Buffer.Buffer = 0;
00200
00201         status = BufferOut3(Binding, &Buffer);
00202         if (status != RPC_S_OK)
00203             {
00204             goto Cleanup;
00205             }
00206         MIDL_user_free(Buffer.Buffer);
00207         }
00208     mseconds = EndTime();
00209
00210     printf("%4d calls in %8d milliseconds - 100 byte buffer out (3).\n", iIterations, mseconds);
00211
00212     lBufferLength = BUFFER_SIZE;
00213
00214     StartTime();
00215     for(i = iIterations; i; i--)
00216         {
00217         status = BufferOut4(Binding, bBuffer, &lBufferLength);
00218         if (status != RPC_S_OK)
00219             {
00220             goto Cleanup;
00221             }
00222         }
00223     mseconds = EndTime();
00224
00225     printf("%4d calls in %8d milliseconds - 100 byte buffer out (4).\n", iIterations, mseconds);
00226
00227     // Time arrays of structures
00228
00229     {
00230     struct BAD1 abad1[50];
00231     struct BAD2 abad2[50];
00232     struct GOOD agood[50];
00233
00234     for (i = 0; i < 50; i++)
00235         {
00236         abad2[i].e = (BAD_ENUM)i % 4 + 1;
00237         agood[i].e = (GOOD_ENUM)i % 4 + 5;
00238         }
00239
00240     StartTime();
00241     for(i = iIterations; i; i--)
00242         {
00243         status = StructsIn1(Binding, &abad1[0]);
00244         if (status != RPC_S_OK)
00245             {
00246             goto Cleanup;
00247             }
00248         }
00249     mseconds = EndTime();
00250
00251     printf("%4d calls in %8d milliseconds - 2 mod 4 aligned structs.\n", iIterations, mseconds);
00252
00253     StartTime();
00254     for(i = iIterations; i; i--)
00255         {
00256         status = StructsIn2(Binding, &abad2[0]);
00257         if (status != RPC_S_OK)
00258             {
00259             goto Cleanup;
00260             }
00261         }
00262     mseconds = EndTime();
00263
00264     printf("%4d calls in %8d milliseconds - structs with an enum.\n", iIterations, mseconds);
00265
00266     StartTime();
00267     for(i = iIterations; i; i--)
00268         {
00269         status = StructsIn3(Binding, &agood[0]);
00270         if (status != RPC_S_OK)
00271             {
00272             goto Cleanup;
00273             }
00274         }
00275     mseconds = EndTime();
00276
00277     printf("%4d calls in %8d milliseconds - structs with v1_enum.\n", iIterations, mseconds);
00278     }
00279
00280     // Linked lists
00281
00282     {
00283     LIST list;
00284     PLIST plist = &list;
00285     for (i = 0; i < LIST_SIZE - 1; i++)
00286         {
00287         plist->pNext = MIDL_user_allocate(sizeof(LIST));
00288         plist->data = i;
00289         if (plist->pNext == 0)
00290             {
00291             status = RPC_S_OUT_OF_MEMORY;
00292             goto Cleanup;
00293             }
00294         plist = plist->pNext;
00295         }
00296     plist->data = i;
00297     plist->pNext = 0;
00298
00299
00300     StartTime();
00301     for(i = iIterations; i; i--)
00302         {
00303         status = ListIn(Binding, &list);
00304         if (status != RPC_S_OK)
00305             {
00306             goto Cleanup;
00307             }
00308         }
00309     mseconds = EndTime();
00310
00311     printf("%4d calls in %8d milliseconds - [in] linked list.\n", iIterations, mseconds);
00312
00313     StartTime();
00314     for(i = iIterations; i; i--)
00315         {
00316         status = ListOut1(Binding, &list);
00317         if (status != RPC_S_OK)
00318             {
00319             goto Cleanup;
00320             }
00321         // Freeing the list here would cause all the elements
00322         // to be allocated again on the next call.
00323         }
00324     mseconds = EndTime();
00325
00326     printf("%4d calls in %8d milliseconds - [out] linked list (1).\n", iIterations, mseconds);
00327
00328     StartTime();
00329     for(i = iIterations; i; i--)
00330         {
00331         status = ListOut2(Binding, &list);
00332         if (status != RPC_S_OK)
00333             {
00334             goto Cleanup;
00335             }
00336         // Freeing the list here would cause all the elements
00337         // to be allocated again on the next call.
00338         }
00339     mseconds = EndTime();
00340
00341     printf("%4d calls in %8d milliseconds - [out] linked list (2).\n", iIterations, mseconds);
00342
00343     // Free allocated elements of the list.
00344     plist = list.pNext;
00345     while(plist)
00346         {
00347         PLIST tmp = plist;
00348         plist = plist->pNext;
00349         MIDL_user_free(tmp);
00350         }
00351     }
00352
00353     // Unions
00354
00355     {
00356     BAD_UNION badunionArray[UNION_ARRAY_LEN];
00357     GOOD_UNION goodunion;
00358     ARM_ONE armone;
00359     ULONG ulArray[UNION_ARRAY_LEN];
00360
00361     goodunion.Tag = 1;
00362     goodunion.u.pOne = &armone;
00363     armone.DataLength = UNION_ARRAY_LEN;
00364     armone.Data = ulArray;
00365
00366     for(i = 0; i < UNION_ARRAY_LEN; i++)
00367         {
00368         ulArray[i] = i;
00369         badunionArray[i].Tag = 1;
00370         badunionArray[i].u.ulData = i;
00371         }
00372
00373     StartTime();
00374     for(i = iIterations; i; i--)
00375         {
00376         status = UnionCall1(Binding, UNION_ARRAY_LEN, badunionArray);
00377         if (status != RPC_S_OK)
00378             {
00379             goto Cleanup;
00380             }
00381         }
00382     mseconds = EndTime();
00383
00384     printf("%4d calls in %8d milliseconds - [in] array of unions.\n", iIterations, mseconds);
00385
00386     StartTime();
00387     for(i = iIterations; i; i--)
00388         {
00389         status = UnionCall2(Binding, &goodunion);
00390         if (status != RPC_S_OK)
00391             {
00392             goto Cleanup;
00393             }
00394         }
00395     mseconds = EndTime();
00396
00397     printf("%4d calls in %8d milliseconds - [in] union of arrays.\n", iIterations, mseconds);
00398
00399     }
00400
00401     // Time pings() (null calls) which impersonate the client.
00402
00403     StartTime();
00404     for(i = iIterations; i; i--)
00405         {
00406
00407         status = CheckSecurity(Binding);
00408
00409         if (status != RPC_S_OK)
00410             {
00411             if (status == RPC_S_ACCESS_DENIED)
00412                 {
00413                 printf("Access denied, try -s 2 or higher.\n");
00414                 return;
00415                 }
00416             goto Cleanup;
00417             }
00418
00419         }
00420     mseconds = EndTime();
00421
00422     printf("%4d calls in %8d milliseconds - void call w/ impersonation\n", iIterations, mseconds);
00423
00424 Cleanup:
00425
00426     if (status != RPC_S_OK)
00427         {
00428         printf("Call failed - %d\n", status);
00429         }
00430
00431     return;
00432 }
00433
00434 //
00435 //  FUNCTION: main
00436 //
00437 //  PURPOSE: Parses arguments and binds to the server.
00438 //
00439 //  PARAMETERS:
00440 //    argc - number of command line arguments
00441 //    argv - array of command line arguments
00442 //
00443 //  RETURN VALUE:
00444 //    Program exit code.
00445 //
00446 //
00447 int main(int argc, char *argv[])
00448 {
00449     char *serverAddress = NULL;
00450     char *protocol = "ncalrpc";
00451     UINT iIterations = 100;
00452     unsigned char *stringBinding;
00453     RPC_BINDING_HANDLE Binding;
00454     RPC_STATUS status;
00455     ULONG SecurityLevel = RPC_C_AUTHN_LEVEL_NONE;
00456
00457     argc--;
00458     argv++;
00459     while(argc)
00460         {
00461         if (   argv[0][0] != '-'
00462             && argv[0][0] != '/')
00463             {
00464             Usage();
00465             return(1);
00466             }
00467
00468         switch(argv[0][1])
00469             {
00470             case 'n':
00471                 if (argc < 2)
00472                     {
00473                     Usage();
00474                     return(1);
00475                     }
00476                 serverAddress = argv[1];
00477                 argc--;
00478                 argv++;
00479                 break;
00480             case 't':
00481                 if (argc < 2)
00482                     {
00483                     Usage();
00484                     return(1);
00485                     }
00486                 protocol = argv[1];
00487                 argc--;
00488                 argv++;
00489                 break;
00490             case 'i':
00491                 if (argc < 2)
00492                     {
00493                     Usage();
00494                     return(1);
00495                     }
00496                 iIterations = atoi(argv[1]);
00497                 argc--;
00498                 argv++;
00499                 break;
00500             case 's':
00501                 if (argc < 2)
00502                     {
00503                     Usage();
00504                     return(1);
00505                     }
00506                 SecurityLevel = atoi(argv[1]);
00507                 if (SecurityLevel > RPC_C_AUTHN_LEVEL_PKT_PRIVACY)
00508                     {
00509                     Usage();
00510                     return(1);
00511                     }
00512                 argc--;
00513                 argv++;
00514                 break;
00515             default:
00516                 Usage();
00517                 return(1);
00518                 break;
00519             }
00520
00521         argc--;
00522         argv++;
00523         }
00524
00525     status = RpcStringBindingCompose(0,
00526                                      protocol,
00527                                      serverAddress,
00528                                      0,
00529                                      0,
00530                                      &stringBinding);
00531     if (status != RPC_S_OK)
00532         {
00533         printf("RpcStringBindingCompose failed - %d\n", status);
00534         return(1);
00535         }
00536
00537     status = RpcBindingFromStringBinding(stringBinding, &Binding);
00538
00539     if (status != RPC_S_OK)
00540         {
00541         printf("RpcBindingFromStringBinding failed - %d\n", status);
00542         return(1);
00543         }
00544
00545     status =
00546     RpcBindingSetAuthInfo(Binding,
00547                           0,
00548                           SecurityLevel,
00549                           RPC_C_AUTHN_WINNT,
00550                           0,
00551                           0
00552                          );
00553
00554     if (status != RPC_S_OK)
00555         {
00556         printf("RpcBindingSetAuthInfo failed - %d\n", status);
00557         return(1);
00558         }
00559
00560     status = Ping(Binding);
00561
00562     if (status != RPC_S_OK)
00563         {
00564         printf("Ping failed - %d\n", status);
00565         }
00566
00567     printf("Connected.\n");
00568
00569     //
00570     // Call and time various RPC calls.
00571     //
00572
00573     DoTimings(Binding, iIterations);
00574
00575     // Cleanup
00576
00577     status = RpcBindingFree(&Binding);
00578
00579     // ASSERT(status == RPC_S_OK):
00580
00581     status = RpcStringFree(&stringBinding);
00582
00583     // ASSERT(status == RPC_S_OK);
00584
00585     return(0);
00586 }
00587
00588 void * __RPC_USER MIDL_user_allocate(size_t size)
00589 {
00590     return(HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, size));
00591 }
00592
00593 void __RPC_USER MIDL_user_free( void *pointer)
00594 {
00595     HeapFree(GetProcessHeap(), 0, pointer);
00596 }
00597
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CUtilitiesDlg Member List

This is the complete list of members for CUtilitiesDlg, including all inherited members.
CUtilitiesDlg(CWnd *pParent=NULL) | CUtilitiesDlg |
DoDataExchange(CDataExchange *pDX) | CUtilitiesDlg | [protected, virtual]
IDD enum value | CUtilitiesDlg |
m_hIcon | CUtilitiesDlg | [protected]
m_nUtilityOption | CUtilitiesDlg | [private]
m_nUtilityType | CUtilitiesDlg | [private]
m_pCatalog | CUtilitiesDlg | [private]
OnClose() | CUtilitiesDlg | [protected]
OnInitDialog() | CUtilitiesDlg | [protected, virtual]
OnJNEC() | CUtilitiesDlg | [protected]
OnOK() | CUtilitiesDlg | [protected, virtual]
OnRefresh() | CUtilitiesDlg | [protected]
OnRouter() | CUtilitiesDlg | [protected]
OnStart() | CUtilitiesDlg | [protected]
OnStop() | CUtilitiesDlg | [protected]
ReleaseCatalog() | CUtilitiesDlg | [private]
set_Catalog(ICOMAdminCatalog *pCatalog) | CUtilitiesDlg |
Generated on Wed Nov 13 2024 16:57:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/syslcesub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

syslcesub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __SysLCESub_H_
00018 #define __SysLCESub_H_
00019
00020 #include "resource.h"       // main symbols
00021
00022 class CComSpy;
00023 /////////////////////////////////////////////////////////////////////////////
00024 // CSysLCESub
00025 class ATL_NO_VTABLE CSysLCESub :
00026   public CComObjectRootEx<CComSingleThreadModel>,
00027   public ICOMSysLCE
00028 {
00029 private:
00030   OLECHAR*  EventName( EventEnum e );
00031
00032 protected:
00033   GUID  m_SubscriptionGuid;
00034   CComSpy * m_pSpy;
00035
00036 public:
00037   CSysLCESub()
00038   {
00039     CoCreateGuid( &m_SubscriptionGuid );
00040   }
00041
00042   void SetSpyObj(CComSpy * pSpy)
00043   {
00044     m_pSpy = pSpy;
00045   }
00046
00047 DECLARE_GET_CONTROLLING_UNKNOWN()
00048
00049 BEGIN_COM_MAP(CSysLCESub)
00050   COM_INTERFACE_ENTRY(ICOMSysLCE)
00051 END_COM_MAP()
00052
00053 // Virtual Methods
00054 public:
00055   STDMETHOD(GetEventType)(EventEnum * e) = 0;
00056   STDMETHOD(GetEventClass)(LPGUID EventClass) = 0;
00057   STDMETHOD(GetInterface)(IID* iid) = 0;
00058
00059 // ISysLCESub Methods
00060 public:
00061   STDMETHOD(Install)(BSTR* PropertyName, VARIANT PropertyValue);
00062   STDMETHOD(Uninstall)();
00063 };
00064
00065 #endif //__SysLCESub_H_
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/CustomScript/CustomEntry/customentry.c Source File

  • NetDS
  • Ras
  • CustomScript
  • CustomEntry

customentry.c

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  File Name
00004 //      customentry.c
00005 //
00006 // Written for Microsoft Developer Support
00007 // Copyright (c) 1995 - 2002 Microsoft Corporation. All rights reserved.
00008 //
00009 #ifndef _WIN32_WINNT
00010 #define _WIN32_WINNT 0x500
00011 #endif
00012
00013 #ifdef UNICODE
00014 #undef UNICODE
00015 #endif
00016
00017 #include <windows.h>
00018 #include <stdlib.h>
00019 #include <stdio.h>
00020 #include <ras.h>
00021 #include <raserror.h>
00022 #include <tchar.h>
00023
00024
00025 void Usage();
00026 void OutputTraceString(LPTSTR lpszFormatString, ...);
00027 BOOL CreateEntry(LPTSTR pszEntryName, LPTSTR pszPhoneNumber, LPTSTR pszDLLPath, BOOL fCustomScript);
00028
00029
00030 // Macro for counting maximum characters that will fit into a buffer
00031 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00032
00033
00034 #define RASCUSTOMDIAL_KEYPATH   "SYSTEM\\CurrentControlSet\\Services\\Rasman\\Parameters"
00035 #define RASCUSTOMDIAL_VALUENAME "CustomDLL"
00036
00037 // Helper function to make custom dll a trusted component.
00038 // It writes custom DLL path into registry
00039 HRESULT CreateRegistryKey(LPTSTR pszPath);
00040 TCHAR * CheckForSelf(LPCTSTR pSrc, LPBYTE pDest, DWORD dwBufLen);
00041
00042 #define RASCUSTOMDIAL_ENTRYNAME TEXT("SDKSample")
00043 #define MAX_DEBUGSTR 256      // max string for ouput
00044
00045 int __cdecl main (int argc, TCHAR * argv[])
00046 {
00047   DWORD dwErr = 0;
00048     TCHAR szEntryName[RAS_MaxEntryName + 1] = {0};
00049     TCHAR szPhoneNumber[RAS_MaxPhoneNumber + 1] = {0};
00050     TCHAR szCustomDLLPath[MAX_PATH + 1] = {0};
00051     RASENTRY rasEntry = {0};
00052   BOOL fRetVal = FALSE;
00053     BOOL fCustomScript = FALSE;
00054
00055     // 1st argument is phone number, second is custom script, third is custom dial dll path
00056     if (3 <= argc)
00057     {
00058         if (3 == argc)
00059         {
00060             lstrcpyn(szPhoneNumber, argv[1], CELEMS(szPhoneNumber));
00061             fCustomScript = (BOOL)_ttol(argv[2]);
00062         }
00063         else
00064         {
00065             if (4 == argc)
00066             {
00067                 lstrcpyn(szPhoneNumber, argv[1], CELEMS(szPhoneNumber));
00068                 fCustomScript = (BOOL)_ttol(argv[2]);
00069                 lstrcpyn(szCustomDLLPath, argv[3], CELEMS(szCustomDLLPath));
00070             }
00071             else
00072             {
00073                 Usage();
00074                 return ERROR_INVALID_PARAMETER;
00075             }
00076         }
00077     }
00078     else
00079     {
00080         Usage();
00081         return ERROR_INVALID_PARAMETER;
00082     }
00083
00084     lstrcpyn(szEntryName, RASCUSTOMDIAL_ENTRYNAME, CELEMS(szEntryName));
00085
00086     fRetVal = CreateEntry(szEntryName, szPhoneNumber, szCustomDLLPath, fCustomScript);
00087
00088     if (fRetVal)
00089     {
00090         _tprintf(_T("Successfully created the custom entry %s \n"),szEntryName);
00091     }
00092     else
00093     {
00094         _tprintf(_T("Failed to Create the entry.\n"));
00095     }
00096
00097     return (int)fRetVal;
00098 }
00099
00100 void Usage()
00101 {
00102     printf("PhoneNumber is required. CustomDLLPath is optional\n");
00103     printf("Usage : customentry <PhoneNumber> <custom_script> [<CustomDLLPath>]\n");
00104     printf("\ncustom_script:\n 0 - no custom script is being used.\n 1 - using custom script.\n");
00105
00106     return;
00107 }
00108
00109
00110 //
00111 // CreateTestEntry
00112 //
00113 // creates a ras entry. If pszDLLPath isn't 0 length, then we'll set
00114 // the szCustomDialDll member of RASENTRY structure as well for use with
00115 // custom dial DLL.
00116 //
00117 BOOL CreateEntry(LPTSTR pszEntryName, LPTSTR pszPhoneNumber, LPTSTR pszDLLPath, BOOL fCustomScript)
00118 {
00119     DWORD rc = 0;               // return code from function calls
00120     DWORD dwSize = 0;           // structure size
00121     RASENTRY *pRasEntry = NULL; // Ras Entry structure
00122     BOOL bResult = FALSE;       // return value for the function
00123     LPRASDEVINFO lpRasDevInfo = NULL;
00124     LPRASDEVINFO lpRasDevInfoTemp = NULL;
00125     DWORD dwNumEntries = 0;
00126     BOOL fSuccess = FALSE;
00127
00128     OutputTraceString("CreateEntry called.\n");
00129
00130     if (!pszEntryName || !pszPhoneNumber || !pszDLLPath)
00131     {
00132         return FALSE;
00133     }
00134
00135     dwSize = sizeof(RASENTRY);
00136     pRasEntry = (RASENTRY*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
00137     if (NULL == pRasEntry)
00138     {
00139         return FALSE;
00140     }
00141
00142     // Initialize the RASENTRY structure.
00143     pRasEntry->dwSize = dwSize;
00144
00145     // When passing in L"" as 2nd param this call populates pRasEntry with default values.
00146     rc = RasGetEntryProperties(NULL, "", pRasEntry, &dwSize, NULL, NULL);
00147     if (ERROR_BUFFER_TOO_SMALL == rc)
00148     {
00149         if (HeapFree(GetProcessHeap(), 0, (LPVOID)pRasEntry))
00150         {
00151             pRasEntry = (RASENTRY*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
00152             if (NULL == pRasEntry)
00153             {
00154                 return FALSE;
00155             }
00156         }
00157         else
00158         {
00159             return FALSE;
00160         }
00161
00162         // Initialize the RASENTRY structure.
00163         pRasEntry->dwSize = sizeof(RASENTRY);
00164         rc = RasGetEntryProperties(NULL, "", pRasEntry, &dwSize, NULL, NULL);
00165     }
00166
00167     if (ERROR_SUCCESS != rc)
00168     {
00169         goto done;
00170     }
00171
00172
00173     // Modify the entry structure
00174     lstrcpyn(pRasEntry->szLocalPhoneNumber, pszPhoneNumber, CELEMS(pRasEntry->szLocalPhoneNumber));
00175     lstrcpyn(pRasEntry->szDeviceType, RASDT_Modem, CELEMS(pRasEntry->szDeviceType));
00176     lstrcpyn(pRasEntry->szCustomDialDll, pszDLLPath, CELEMS(pRasEntry->szCustomDialDll));
00177
00178     pRasEntry->dwfOptions = 0;
00179     pRasEntry->dwfOptions = RASEO_PreviewPhoneNumber | RASEO_ShowDialingProgress | RASEO_PreviewUserPw | RASEO_PreviewDomain;
00180
00181     if (fCustomScript)
00182     {
00183         printf("Setting RASEO_CustomScript option.\n");
00184         pRasEntry->dwfOptions |= RASEO_CustomScript;
00185     }
00186
00187     pRasEntry->dwfNetProtocols = RASNP_Ip | RASNP_Ipx;
00188     pRasEntry->dwSubEntries = 1;
00189     pRasEntry->dwType =  RASET_Phone;
00190     pRasEntry->dwEncryptionType = ET_None;
00191
00192     //
00193     // enumerate to get the device name to use - we'll just pick one (a modem)
00194     //
00195     // first get the size of the buffer required
00196     // Allocate buffer with default value
00197     dwSize = sizeof(RASDEVINFO);
00198     lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
00199     if (NULL == lpRasDevInfo)
00200     {
00201         printf("HeapAlloc failed.\n");
00202         goto done;
00203     }
00204
00205     lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
00206
00207     rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries);
00208
00209     switch(rc)   // Check whether RasEnumDevices succeeded
00210     {
00211     case ERROR_BUFFER_TOO_SMALL:
00212         // If the buffer is too small, free the allocated memory and allocate a bigger buffer.
00213
00214         if (HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo))
00215         {
00216             lpRasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
00217             if (NULL == lpRasDevInfo)
00218             {
00219                 OutputTraceString(_T("--- HeapAlloc failed in CreateTestEntry (GetLastError = %d)\n"), GetLastError());
00220                 goto done;
00221             }
00222
00223             lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
00224
00225             rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries);
00226             if (ERROR_SUCCESS != rc)
00227             {
00228                 OutputTraceString(_TEXT("--- RasEnumDevices failed in CreateTestEntry: %d"), rc);
00229                 goto done;
00230             }
00231
00232             fSuccess = TRUE;
00233         }
00234         else
00235         {
00236             OutputTraceString(_T("--- HeapFree failed in CreateTestEntry (GetLastError = %d)\n"), GetLastError());
00237             goto done;
00238         }
00239         break;
00240     case ERROR_SUCCESS:
00241         fSuccess = TRUE;
00242         break;
00243
00244     default:
00245         printf("RasEnumDevices failed: Error = %d\n", rc);
00246         goto done;
00247     }
00248
00249     lpRasDevInfoTemp = lpRasDevInfo;
00250     if (fSuccess)
00251     {
00252         UINT i = 0;
00253         for (i = 0; i < dwNumEntries; i++, lpRasDevInfoTemp++)
00254         {
00255             // See if this is a modem device
00256             if (CSTR_EQUAL == CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
00257                                             NORM_IGNORECASE,
00258                                             lpRasDevInfoTemp->szDeviceType,
00259                                             -1,
00260                                             RASDT_Modem,
00261                                             -1))
00262             {
00263                 OutputTraceString(_TEXT("-- Modem device: %s\n"), lpRasDevInfoTemp->szDeviceName);
00264                 lstrcpyn(pRasEntry->szDeviceName, lpRasDevInfoTemp->szDeviceName, CELEMS(pRasEntry->szDeviceName));
00265                 break;
00266             }
00267         }
00268     }
00269
00270     // Write the phonebook entry.
00271     rc = RasSetEntryProperties(NULL, pszEntryName, pRasEntry, sizeof(RASENTRY), NULL, 0);
00272     if (ERROR_SUCCESS != rc)
00273     {
00274         OutputTraceString(_TEXT("--- RasSetEntryProperties failed in CreateTestEntry: %d\n"), rc);
00275     }
00276     else
00277     {
00278         if (lstrlen(pszDLLPath))
00279         {
00280             OutputTraceString(_TEXT("--- Calling CreateRegistryKey\n"));
00281             printf("--- Calling CreateRegistryKey\n");
00282             bResult  = (S_OK == CreateRegistryKey(pszDLLPath)? TRUE : FALSE);
00283         }
00284         else
00285         {
00286             bResult = TRUE;
00287         }
00288     }
00289
00290 done:
00291
00292     if (pRasEntry)
00293     {
00294         HeapFree(GetProcessHeap(), 0, (LPVOID)pRasEntry);
00295     }
00296
00297     if (lpRasDevInfo)
00298     {
00299         HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo);
00300     }
00301
00302     OutputTraceString(_TEXT("Exiting CreateEntry\n"));
00303
00304     return bResult;
00305 }
00306
00307 //
00308 // OutputTraceString
00309 //
00310 // multiple argument front-end to OutputDebugString
00311 //
00312 void OutputTraceString(LPTSTR lpszFormatString, ...)
00313 {
00314     TCHAR szOutputString[MAX_DEBUGSTR] = {0};  // the string to print - limited
00315     va_list arglist;                     // variable argument list
00316
00317
00318   // create the new string limited to the char count as indicated
00319   va_start(arglist, lpszFormatString);
00320   _vsnprintf(szOutputString, MAX_DEBUGSTR, lpszFormatString, arglist);
00321   va_end(arglist);
00322
00323   // send it out
00324   OutputDebugString(szOutputString);
00325 }
00326
00327
00328
00329 HRESULT CreateRegistryKey(LPTSTR pszPath)
00330 {
00331     HRESULT hr = E_UNEXPECTED;      // return code
00332     HKEY hKey;                      // handle to open registry key
00333     LONG lRet = 0;
00334
00335     OutputTraceString(_TEXT("CreateRegistryKey called.\n"));
00336
00337     // open registry for reading/writing
00338     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, RASCUSTOMDIAL_KEYPATH,
00339                0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
00340     {
00341         // read in current value
00342         DWORD dwSize = 0;           // size of buffer for reading registry
00343         DWORD dwBufSize = 0;        // size of buffer for writing to registry
00344         DWORD dwType = 0;           // type of buffer
00345         LPBYTE buffer = NULL;       // the buffer
00346         DWORD dwBufPosition = 0;    // position of new string in the buffer
00347
00348         // obtain current value size
00349         RegQueryValueEx(hKey, RASCUSTOMDIAL_VALUENAME, NULL, &dwType, NULL, &dwSize);
00350
00351         // allocate buffer to read (and write) all NULLs will be there
00352         if (dwSize > 0)
00353         {
00354             dwBufSize = dwSize + (lstrlen(pszPath) * sizeof(TCHAR)) + sizeof(TCHAR);   // should be terminated in a \0
00355         }
00356         else
00357         {
00358             dwBufSize = (lstrlen(pszPath) * sizeof(TCHAR)) + (2 * sizeof(TCHAR));   // should be terminated in a \0\0 pair
00359         }
00360
00361         buffer = (LPBYTE) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBufSize);
00362
00363         if (!buffer)
00364         {
00365             hr = E_OUTOFMEMORY;
00366             return hr;
00367         }
00368
00369         // read it if dwSize was > 0
00370         if (dwSize > 0)
00371         {
00372             lRet = RegQueryValueEx(hKey, RASCUSTOMDIAL_VALUENAME, NULL, &dwType, buffer, &dwSize);
00373             if (ERROR_SUCCESS != lRet)
00374             {
00375                 hr = HRESULT_FROM_WIN32(lRet);
00376                 goto done;
00377             }
00378         }
00379
00380         // if it isn't there add it in
00381         if (CheckForSelf(pszPath, buffer, dwSize) == NULL)
00382         {
00383             if (dwSize > 0)
00384             {
00385                 dwBufPosition = dwSize - sizeof(TCHAR); // back off original pos
00386             }
00387
00388             // add to the buffer
00389             CopyMemory(&buffer[dwBufPosition], pszPath, lstrlen(pszPath) * sizeof(TCHAR));
00390
00391             // write it
00392             dwType = REG_MULTI_SZ;
00393
00394             lRet = RegSetValueEx(hKey, RASCUSTOMDIAL_VALUENAME, 0, dwType, buffer, dwBufSize);
00395             if (ERROR_SUCCESS != lRet)
00396             {
00397                 hr = HRESULT_FROM_WIN32(lRet);
00398                 goto done;
00399             }
00400         }
00401
00402         hr = S_OK;
00403
00404 done:
00405         if (buffer)
00406         {
00407             HeapFree(GetProcessHeap(), 0, (LPVOID)buffer);
00408         }
00409
00410         RegCloseKey(hKey);
00411
00412     }
00413
00414     return hr;
00415 }
00416
00417 TCHAR * CheckForSelf(LPCTSTR pSrc, LPBYTE pDest, DWORD dwBufLen)
00418 {
00419     DWORD dwLen = 0;  // length of the buffer
00420     TCHAR * p;        // pointer into the buffer
00421
00422     if (!pSrc || !pDest)
00423     {
00424         return NULL;
00425     }
00426
00427     // loop through the buffer up to the length
00428     while (dwLen < dwBufLen)
00429     {
00430         p = (LPTSTR) &pDest[dwLen];   // get out string
00431
00432         // Compare the strings
00433         if (CSTR_EQUAL == CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
00434                                         NORM_IGNORECASE,
00435                                         pSrc,
00436                                         -1,
00437                                         p,
00438                                         -1))
00439         {
00440             return p;
00441         }
00442
00443         // go past string we just checked + the terminating '\0'
00444         dwLen = dwLen + ((lstrlen(p) + 1) * sizeof(TCHAR));
00445     }
00446
00447     return NULL;      // string was not found
00448 }
00449
00450
00451
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ErrorsVtbl Member List

This is the complete list of members for ErrorsVtbl, including all inherited members.
c | ErrorsVtbl
cNames | ErrorsVtbl
dispIdMember | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Count)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *_NewEnum)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Refresh)(ADOErrors __RPC_FAR *This) | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Item)(ADOErrors __RPC_FAR *This | ErrorsVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Clear)(ADOErrors __RPC_FAR *This) | ErrorsVtbl
Index | ErrorsVtbl
iTInfo | ErrorsVtbl
lcid | ErrorsVtbl
lcid | ErrorsVtbl
lcid | ErrorsVtbl
pctinfo | ErrorsVtbl
pDispParams | ErrorsVtbl
pExcepInfo | ErrorsVtbl
ppTInfo | ErrorsVtbl
ppvObject | ErrorsVtbl
ppvObject | ErrorsVtbl
ppvObject | ErrorsVtbl
puArgErr | ErrorsVtbl
pVarResult | ErrorsVtbl
rgDispId | ErrorsVtbl
rgszNames | ErrorsVtbl
riid | ErrorsVtbl
riid | ErrorsVtbl
riid | ErrorsVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(ADOErrors __RPC_FAR *This) | ErrorsVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(ADOErrors __RPC_FAR *This) | ErrorsVtbl
wFlags | ErrorsVtbl
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/HttpAuth/HttpAuth.h Source File

  • Security
  • SSPI
  • HttpAuth

HttpAuth.h

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 Module Name:
00011
00012     httpauth.h
00013
00014 Abstract:
00015
00016     Functions for authentication sequence ( Basic & NTLM )
00017
00018 --*/
00019
00020 BOOL AddAuthorizationHeader(PSTR pch, PSTR pchSchemes, PSTR pchAuthData, PSTR pchUserName, PSTR pchPassword, BOOL *pfNeedMoreData );
00021 BOOL InitAuthorizationHeader();
00022 void TerminateAuthorizationHeader();
00023 BOOL IsInAuthorizationSequence();
00024 BOOL ValidateAuthenticationMethods( PSTR pszMet, PSTR pszPref );
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/sky.Cpp Source File

  • SysMgmt
  • MMC
  • Openserv

sky.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Sky.h"
00021
00022 const GUID CSkyBasedVehicle::thisGuid = { 0x2974380f, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CSkyBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CClusterData Member List

This is the complete list of members for CClusterData, including all inherited members.
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CClusterData | [virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CClusterData | [virtual]
CObjData(void) | CObjData | [inline]
CObjData(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
GetHCluster(void) | CClusterData | [inline]
GetHCluster(void) | CClusterData | [inline]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CObjData | [inline, virtual]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CObjData | [inline, virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CObjData | [inline, virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CObjData | [inline, virtual]
HrInitialize(IUnknown *piDataIn) | CClusterData | [protected, virtual]
HrInitialize(IUnknown *piDataIn) | CClusterData | [protected, virtual]
InvokeCommand(ULONG nCommandIDIn) | CClusterData | [virtual]
InvokeCommand(ULONG nCommandIDIn) | CClusterData | [virtual]
m_cot | CObjData | [protected]
m_hCluster | CClusterData | [private]
m_rgprtcPSPages | CObjData | [protected]
m_rgprtcWizPages | CObjData | [protected]
m_strClusterName | CClusterData | [private]
m_strName | CObjData | [protected]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
StrName(void) | CObjData | [inline, virtual]
StrName(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
Generated on Wed Nov 13 2024 16:55:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Settings.Cpp Source File

  • NetDS
  • SyncMgr
  • SyncDir

Settings.Cpp

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 // global settings class created in DLLMain
00013 // manages user settings and keeps track of what items are synchronizing
00014 // between all instances.
00015
00016 #include "precomp.h"
00017
00018 extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
00019 extern CSettings *g_pSettings;  // ptr to global settings class.
00020
00021 //+---------------------------------------------------------------------------
00022 //
00023 //  Member:     CSettings::CSettings, public
00024 //
00025 //  Synopsis:
00026 //
00027 //  Returns:
00028 //
00029 //  Modifies:
00030 //
00031 //----------------------------------------------------------------------------
00032
00033 CSettings::CSettings()
00034 {
00035
00036     m_cRefs = 1;
00037     m_pHandlerItems = NULL;
00038 }
00039
00040 //+---------------------------------------------------------------------------
00041 //
00042 //  Member:     CSettings::~CSettings, public
00043 //
00044 //  Synopsis:   Destructor
00045 //
00046 //  Arguments:
00047 //
00048 //  Returns:
00049 //
00050 //  Modifies:
00051 //
00052 //----------------------------------------------------------------------------
00053
00054 CSettings::~CSettings()
00055 {
00056     Assert(0 == m_cRefs);
00057
00058     if (m_pHandlerItems)
00059     {
00060     LPGENERICITEMLIST pHandlerItems = m_pHandlerItems;
00061
00062         m_pHandlerItems = NULL;
00063         Release_ItemList(pHandlerItems);
00064     }
00065
00066 }
00067
00068
00069 //+---------------------------------------------------------------------------
00070 //
00071 //  Member:     CSettings::AddRef, public
00072 //
00073 //  Synopsis:
00074 //
00075 //  Arguments:
00076 //
00077 //  Returns:
00078 //
00079 //  Modifies:
00080 //
00081 //----------------------------------------------------------------------------
00082 STDMETHODIMP_(ULONG) CSettings::AddRef()
00083 {
00084 DWORD cRefs;
00085
00086     Assert(m_cRefs >= 1); // should never zero bounce.
00087     cRefs = InterlockedIncrement((LONG *)& m_cRefs);
00088     return cRefs;
00089 }
00090
00091 //+---------------------------------------------------------------------------
00092 //
00093 //  Member:     CSettings::Release, public
00094 //
00095 //  Synopsis:
00096 //
00097 //  Arguments:
00098 //
00099 //  Returns:
00100 //
00101 //  Modifies:
00102 //
00103 //----------------------------------------------------------------------------
00104
00105 STDMETHODIMP_(ULONG) CSettings::Release()
00106 {
00107 DWORD cRefs;
00108
00109     cRefs = InterlockedDecrement( (LONG *) &m_cRefs);
00110
00111     Assert(cRefs >= 0); // should never go negative.
00112     if (0 == cRefs)
00113     {
00114         delete this;
00115     }
00116
00117     return cRefs;
00118 }
00119
00120 //+---------------------------------------------------------------------------
00121 //
00122 //  Member:     CSettings::EnumSyncMgrItems, public
00123 //
00124 //  Synopsis:   Returns a SyncMgrEnum enumerator of current items
00125 //
00126 //  Arguments:
00127 //
00128 //  Returns:
00129 //
00130 //  Modifies:
00131 //
00132 //----------------------------------------------------------------------------
00133
00134 STDMETHODIMP CSettings::EnumSyncMgrItems(ISyncMgrEnumItems** ppenumOffineItems)
00135 {
00136 CLock clock(this);
00137
00138     clock.Enter();
00139
00140     ReadSettings(FALSE /* fForce */); // make sure settings have been read in
00141
00142     *ppenumOffineItems = NULL;
00143
00144     if (m_pHandlerItems)
00145     {
00146     LPGENERICITEMLIST pDupList;
00147
00148         // snapshot itemlist for enum so don't have to
00149         // worry about changes.
00150         pDupList = DuplicateItemList(m_pHandlerItems);
00151         if (pDupList)
00152         {
00153         *ppenumOffineItems = new  CEnumSyncMgrItems(pDupList,0);
00154             Release_ItemList(pDupList);
00155         }
00156
00157     }
00158
00159     clock.Leave();
00160
00161     return *ppenumOffineItems ? NOERROR: E_OUTOFMEMORY;
00162 }
00163
00164
00165 //+---------------------------------------------------------------------------
00166 //
00167 //  Member:     CSettings::ShowProperties, public
00168 //
00169 //  Synopsis:   Displays the property page for the requested item.
00170 //              it ItemID == GUID_NULL the top-level property page
00171 //              is shown.
00172 //
00173 //  Arguments:
00174 //
00175 //  Returns:
00176 //
00177 //  Modifies:
00178 //
00179 //----------------------------------------------------------------------------
00180
00181 STDMETHODIMP CSettings::ShowProperties(HWND hWndParent,REFSYNCMGRITEMID ItemID)
00182 {
00183 HRESULT hr = NOERROR;
00184 DWORD dwResult;
00185 CLock clock(this);
00186
00187     clock.Enter();
00188     ReadSettings(FALSE /* fForce */); // make sure settings are read in.a
00189     clock.Leave();
00190
00191     if (GUID_NULL == ItemID)
00192     {
00193     PROPSHEETPAGE psp [1];
00194     HPROPSHEETPAGE hpsp [1];
00195     PROPSHEETHEADER psh;
00196     CONFIGSETTINGSLPARAM configlParam;
00197
00198         configlParam.pSettings = this;
00199         configlParam.hr = NOERROR;
00200
00201         memset(psp,0,sizeof(psp));
00202         memset(&psh,0,sizeof(psh));
00203
00204         psp[0].dwSize = sizeof (psp[0]);
00205         psp[0].dwFlags = PSP_DEFAULT | PSP_USETITLE;
00206         psp[0].hInstance = g_hmodThisDll;
00207         psp[0].pszTemplate = MAKEINTRESOURCE(IDD_CONFIGDIALOG);
00208         psp[0].pszIcon = NULL;
00209         psp[0].pfnDlgProc = (DLGPROC) ConfigureDlgProc;
00210         psp[0].pszTitle = MAKEINTRESOURCE(IDS_CONFIG_TAB);
00211         psp[0].lParam = (LPARAM) &configlParam;
00212
00213         if (hpsp[0] = CreatePropertySheetPage(&(psp[0])))
00214         {
00215
00216             psh.dwSize = sizeof (psh);
00217             psh.dwFlags = PSH_DEFAULT | PSH_USEHICON;
00218             psh.hwndParent = hWndParent;
00219             psh.hInstance = g_hmodThisDll;
00220             psh.pszIcon = NULL;
00221             psh.hIcon =  LoadIcon(g_hmodThisDll, MAKEINTRESOURCE(IDI_SAMPLEHANDLERICON));
00222             psh.pszCaption = MAKEINTRESOURCE(IDS_CONFIG_TITLE);
00223             psh.nPages = 1;
00224             psh.phpage = hpsp;
00225             psh.pfnCallback = NULL;
00226             psh.nStartPage = 0;
00227
00228             dwResult = (DWORD)PropertySheet(&psh);
00229
00230             hr = configlParam.hr;
00231         }
00232
00233     }
00234     else
00235     {
00236         if (S_OK == ShowItemProperties(hWndParent,FALSE /*fNewItem */,
00237                     NULL,ItemID))
00238         {
00239             hr = S_SYNCMGR_ENUMITEMS;
00240         }
00241     }
00242
00243     return hr;
00244 }
00245
00246 //+---------------------------------------------------------------------------
00247 //
00248 //  Member:     CSettings::RequestItemLock, public
00249 //
00250 //  Synopsis:   Called by handler Requests a Lock on the Item
00251 //              once given the lock no other handler instance
00252 //              can obtain it. This ensures only one handler
00253 //              instance is synchronizing an item at a time.
00254 //
00255 //  Arguments:
00256 //
00257 //  Returns:
00258 //
00259 //  Modifies:
00260 //
00261 //----------------------------------------------------------------------------
00262
00263 BOOL CSettings::RequestItemLock(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID)
00264 {
00265 LPSAMPLEITEMSETTINGS pItemSettings;
00266 CLock clock(this);
00267
00268     clock.Enter();
00269
00270     pItemSettings = FindItemSettings(ItemID);
00271
00272     if (pItemSettings && !(pItemSettings->fSyncLock))
00273     {
00274         Assert(NULL == pItemSettings->pLockHandler);
00275
00276         pItemSettings->fSyncLock = TRUE;
00277         pItemSettings->pLockHandler = pLockHandler;
00278
00279         clock.Leave();
00280         return TRUE;
00281     }
00282
00283     clock.Leave();
00284     return FALSE;
00285 }
00286
00287
00288 //+---------------------------------------------------------------------------
00289 //
00290 //  Member:     CSettings::ReleaseItemLock, public
00291 //
00292 //  Synopsis:   Called by Handler to inform settings that it is
00293 //              done synchronizing an Item and no longer needs the lock.
00294 //              Filetime field request the last update time be upated.
00295 //
00296 //  Arguments:
00297 //
00298 //  Returns:
00299 //
00300 //  Modifies:
00301 //
00302 //----------------------------------------------------------------------------
00303
00304 BOOL CSettings::ReleaseItemLock(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID
00305                                 ,FILETIME *pftLastUpdate)
00306 {
00307     return ReleaseItemLockX(pLockHandler,ItemID,TRUE,pftLastUpdate);
00308 }
00309
00310 //+---------------------------------------------------------------------------
00311 //
00312 //  Member:     CSettings::ReleaseItemLock, public
00313 //
00314 //  Synopsis:   Called by Handler to inform settings that it is
00315 //              done synchronizing an Item and no longer needs the lock.
00316 //
00317 //  Arguments:
00318 //
00319 //  Returns:
00320 //
00321 //  Modifies:
00322 //
00323 //----------------------------------------------------------------------------
00324
00325 BOOL CSettings::ReleaseItemLock(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID)
00326 {
00327     return ReleaseItemLockX(pLockHandler,ItemID,FALSE,NULL);
00328 }
00329
00330 //+---------------------------------------------------------------------------
00331 //
00332 //  Member:     CSettings::ReleaseItemLockX, private
00333 //
00334 //  Synopsis:   private call to release synchronize call and update filetime
00335 //              if necessary.
00336 //
00337 //  Arguments:
00338 //
00339 //  Returns:
00340 //
00341 //  Modifies:
00342 //
00343 //----------------------------------------------------------------------------
00344
00345 BOOL CSettings::ReleaseItemLockX(CSyncMgrHandler *pLockHandler,REFSYNCMGRITEMID ItemID,
00346                             BOOL fUpdateft,FILETIME *pftLastUpdate)
00347 {
00348 LPSAMPLEITEMSETTINGS pItemSettings;
00349 CLock clock(this);
00350
00351     clock.Enter();
00352
00353     pItemSettings = FindItemSettings(ItemID);
00354
00355     if (pItemSettings)
00356     {
00357         Assert(TRUE == pItemSettings->fSyncLock);
00358         Assert(pLockHandler == pItemSettings->pLockHandler);
00359
00360         if (pItemSettings->pLockHandler == pLockHandler)
00361         {
00362             pItemSettings->fSyncLock = FALSE;
00363             pItemSettings->pLockHandler = NULL;
00364
00365             if (fUpdateft)
00366             {
00367                 pItemSettings->syncmgrItem.ftLastUpdate = *pftLastUpdate;
00368
00369                 // write out item to registry to update the last update time.
00370                 WriteItemSettings(pItemSettings);
00371             }
00372         }
00373
00374         clock.Leave();
00375         return TRUE;
00376     }
00377
00378     clock.Leave();
00379     return FALSE;
00380 }
00381
00382
00383 //+---------------------------------------------------------------------------
00384 //
00385 //  Member:     CSettings::CopyHandlerSyncInfo, public
00386 //
00387 //  Synopsis:   Called by handler to obtain information it
00388 //              needs on an item to perform a synchronization.
00389 //
00390 //  Arguments:
00391 //
00392 //  Returns:
00393 //
00394 //  Modifies:
00395 //
00396 //----------------------------------------------------------------------------
00397
00398 BOOL CSettings::CopyHandlerSyncInfo(REFSYNCMGRITEMID ItemID,
00399                         /* [in,out] */ LPHANDLERITEMSETTINGS pHandlerSyncItem)
00400 {
00401 LPSAMPLEITEMSETTINGS pItemSettings;
00402 BOOL fReturn = FALSE;
00403 CLock clock(this);
00404
00405     clock.Enter();
00406
00407     pItemSettings = FindItemSettings(ItemID);
00408
00409     Assert(pHandlerSyncItem);
00410
00411     if (pItemSettings && pHandlerSyncItem)
00412     {
00413
00414         pHandlerSyncItem->ItemID = ItemID;
00415         pHandlerSyncItem->ft = pItemSettings->syncmgrItem.ftLastUpdate;
00416         pHandlerSyncItem->fRecursive = pItemSettings->fRecursive;
00417
00418         lstrcpyn(pHandlerSyncItem->dir1,pItemSettings->dir1,
00419             sizeof(pHandlerSyncItem->dir1)/sizeof(TCHAR));
00420         lstrcpyn(pHandlerSyncItem->dir2,pItemSettings->dir2,
00421             sizeof(pHandlerSyncItem->dir2)/sizeof(TCHAR));
00422
00423 #ifndef _UNICODE
00424         WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
00425                             pItemSettings->syncmgrItem.wszItemName,
00426                             -1, pHandlerSyncItem->szItemName,
00427                             sizeof(pHandlerSyncItem->szItemName)/sizeof(TCHAR), NULL, NULL);
00428
00429 #else
00430         lstrcpyn(pHandlerSyncItem->szItemName,
00431             pItemSettings->syncmgrItem.wszItemName,
00432             sizeof(pHandlerSyncItem->szItemName));
00433 #endif // _UNICODE
00434
00435         fReturn = TRUE;
00436     }
00437
00438     clock.Leave();
00439     return fReturn;
00440 }
00441
00442
00443 //+---------------------------------------------------------------------------
00444 //
00445 //  Member:     CSettings::ReadSettings, private
00446 //
00447 //  Synopsis:   Called to Read in Settings from Registry
00448 //
00449 //  Arguments:
00450 //
00451 //  Returns:
00452 //
00453 //  Modifies:
00454 //
00455 //----------------------------------------------------------------------------
00456
00457 STDMETHODIMP CSettings::ReadSettings(BOOL fForce)
00458 {
00459 HKEY hkeyHandlerPerf;
00460
00461     ASSERT_LOCKHELD(this);
00462
00463     // if not forced to refresh and already have a list just re-use it.
00464     if (!fForce && m_pHandlerItems)
00465     {
00466         return NOERROR;
00467     }
00468
00469     Assert(NULL == m_pHandlerItems);
00470
00471     m_pHandlerItems = CreateItemList();
00472
00473     if (!m_pHandlerItems)
00474     {
00475         return E_OUTOFMEMORY;
00476     }
00477
00478    // loop through registered items loading them in.
00479    if (hkeyHandlerPerf =  CreateHandlerPrefKey(CLSID_SyncMgrHandler))
00480    {
00481     TCHAR lpName[256];
00482     WCHAR *pszName;
00483     DWORD cbName = 256;
00484     CLSID clsid;
00485     DWORD dwIndex = 0;
00486
00487         while ( ERROR_SUCCESS == RegEnumKey(hkeyHandlerPerf,dwIndex,
00488                 lpName,cbName) )
00489         {
00490         #ifndef _UNICODE
00491             WCHAR  pwszItemID[MAX_SYNCMGRITEMNAME];
00492
00493             MultiByteToWideChar(CP_ACP, 0,
00494                                 lpName,
00495                                 -1, pwszItemID,MAX_SYNCMGRITEMNAME);
00496
00497             pszName = pwszItemID;
00498         #else
00499             pszName = lpName;
00500         #endif // _UNICODE
00501
00502             if (NOERROR == CLSIDFromString(pszName,&clsid) )
00503             {
00504             LPSAMPLEITEMSETTINGS pSampleItem;
00505
00506                 // set up item list,
00507                 pSampleItem = (LPSAMPLEITEMSETTINGS) AddNewItemToList(m_pHandlerItems,sizeof(SAMPLEITEMSETTINGS));
00508
00509                 if (!pSampleItem)
00510                 {
00511                     continue;
00512                 }
00513
00514                 // setup values we don't get from preferences.
00515                 pSampleItem->syncmgrItem.cbSize = sizeof(SYNCMGRITEM);
00516                 pSampleItem->syncmgrItem.dwItemState = SYNCMGRITEMSTATE_CHECKED;
00517
00518                 pSampleItem->syncmgrItem.hIcon =
00519                             LoadIcon(g_hmodThisDll,MAKEINTRESOURCE(IDI_SAMPLEHANDLERICON));
00520
00521                 pSampleItem->syncmgrItem.dwFlags =
00522                                     SYNCMGRITEM_HASPROPERTIES | SYNCMGRITEM_LASTUPDATETIME;
00523
00524                  // read in items from preferences
00525                 Reg_GetItemSettingsForHandlerItem(hkeyHandlerPerf,
00526                         clsid,
00527                         pSampleItem);
00528
00529             }
00530
00531             dwIndex++;
00532         }
00533
00534
00535         RegCloseKey(hkeyHandlerPerf);
00536
00537    }
00538
00539     return NOERROR;
00540 }
00541
00542
00543 //+---------------------------------------------------------------------------
00544 //
00545 //  Member:     CSettings::WriteItemSettings, private
00546 //
00547 //  Synopsis:   Called to write out settings to the Registry
00548 //
00549 //  Arguments:
00550 //
00551 //  Returns:
00552 //
00553 //  Modifies:
00554 //
00555 //----------------------------------------------------------------------------
00556
00557 BOOL CSettings::WriteItemSettings(LPSAMPLEITEMSETTINGS pSampleItemSettings)
00558 {
00559
00560     ASSERT_LOCKHELD(this);
00561
00562     Reg_SetItemSettingsForHandlerItem(CLSID_SyncMgrHandler,
00563                         pSampleItemSettings->syncmgrItem.ItemID,
00564                         pSampleItemSettings);
00565
00566     return TRUE;
00567 }
00568
00569 // deletes item settings from the registry
00570 BOOL CSettings::DeleteItemSettings(LPSAMPLEITEMSETTINGS pSampleItemSettings)
00571 {
00572     ASSERT_LOCKHELD(this);
00573
00574     Reg_DeleteItemIdForHandlerItem(CLSID_SyncMgrHandler,
00575                         pSampleItemSettings->syncmgrItem.ItemID);
00576
00577
00578     return TRUE;
00579 }
00580
00581
00582 //+---------------------------------------------------------------------------
00583 //
00584 //  Member:     CSettings::WriteItemSettings, private
00585 //
00586 //  Synopsis:   Finds item settings in list for the specified ItemID
00587 //              caller must have put a lock on the settings list
00588 //              and not release it until it is done using the
00589 //              structure pointed to by the return value.
00590 //
00591 //  Arguments:
00592 //
00593 //  Returns:
00594 //
00595 //  Modifies:
00596 //
00597 //----------------------------------------------------------------------------
00598
00599 LPSAMPLEITEMSETTINGS  CSettings::FindItemSettings(REFSYNCMGRITEMID ItemID)
00600 {
00601 LPSAMPLEITEMSETTINGS pItemSettings = NULL;
00602
00603     ASSERT_LOCKHELD(this);
00604
00605     ReadSettings(FALSE /* fForce */); // make sure settings are read in.a
00606
00607     if (m_pHandlerItems)
00608     {
00609
00610         pItemSettings = (LPSAMPLEITEMSETTINGS) m_pHandlerItems->pFirstGenericItem;
00611
00612         while (pItemSettings)
00613         {
00614             Assert(sizeof(SAMPLEITEMSETTINGS) == pItemSettings->genericItem.cbSize);
00615
00616             if (ItemID == pItemSettings->syncmgrItem.ItemID)
00617             {
00618                 break;
00619             }
00620
00621             pItemSettings = (LPSAMPLEITEMSETTINGS) pItemSettings->genericItem.pNextGenericItem;
00622         }
00623
00624     }
00625
00626     AssertSz(pItemSettings,"Item not Found");
00627
00628     return pItemSettings;
00629 }
00630
00631
00632
00633 //+---------------------------------------------------------------------------
00634 //
00635 //  Member:     CSettings::ShowItemProperties, private
00636 //
00637 //  Synopsis:   called internally by class to show item properties
00638 //              if fNewItem is set to true then the pItemSettings
00639 //              argument is used. else need to lookup pItemSettings
00640 //              from ItemID each time it is needed.
00641 //
00642 //  Arguments:
00643 //
00644 //  Returns:
00645 //
00646 //  Modifies:
00647 //
00648 //----------------------------------------------------------------------------
00649
00650 STDMETHODIMP CSettings::ShowItemProperties(HWND hWndParent,BOOL fNewItem,
00651                                             LPSAMPLEITEMSETTINGS pItemSettings,
00652                                             SYNCMGRITEMID ItemID)
00653 {
00654 HRESULT hr = NOERROR;
00655 PROPSHEETPAGE psp [1];
00656 HPROPSHEETPAGE hpsp [1];
00657 PROPSHEETHEADER psh;
00658 ITEMCONFIGSETTINGSLPARAM ItemConfiglParam;
00659 TCHAR szLocalDisplayNameBuf[MAX_SYNCMGRITEMNAME];
00660 TCHAR *pDisplayName;
00661 WCHAR *pwszDisplayName = NULL;
00662 CLock clock(this);
00663
00664     ItemConfiglParam.pSettings = this;
00665     ItemConfiglParam.hr = NOERROR;
00666
00667     ItemConfiglParam.fNewItem = fNewItem;
00668
00669     // if new item save to use settings, else use ItemID and look up
00670     // in list when need in case item deleted by someone else.
00671
00672     clock.Enter(); // setup lock to get the display Name.
00673
00674     if (fNewItem)
00675     {
00676         Assert(pItemSettings);
00677         ItemConfiglParam.pItemSettings = pItemSettings;
00678         ItemConfiglParam.ItemID = GUID_NULL;
00679
00680         pwszDisplayName = pItemSettings->syncmgrItem.wszItemName;
00681     }
00682     else
00683     {
00684     LPSAMPLEITEMSETTINGS pTempItemSettings;
00685
00686         Assert(NULL == pItemSettings);
00687         ItemConfiglParam.pItemSettings = NULL;
00688         ItemConfiglParam.ItemID = ItemID;
00689
00690         if (pTempItemSettings = FindItemSettings(ItemID))
00691         {
00692             pwszDisplayName = pTempItemSettings->syncmgrItem.wszItemName;
00693         }
00694     }
00695
00696     // convert the display name before release lock to properly handler
00697     // existing items.
00698     pDisplayName = szLocalDisplayNameBuf;
00699     *szLocalDisplayNameBuf = NULL;
00700
00701     if (pwszDisplayName)
00702     {
00703     #if _UNICODE
00704          lstrcpy(szLocalDisplayNameBuf,pwszDisplayName);
00705     #else
00706         WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
00707                             pwszDisplayName,
00708                             -1, szLocalDisplayNameBuf,MAX_SYNCMGRITEMNAME, NULL, NULL);
00709
00710     #endif // _UNICODE
00711     }
00712
00713     clock.Leave();
00714
00715     memset(psp,0,sizeof(psp));
00716     memset(&psh,0,sizeof(psh));
00717
00718     psp[0].dwSize = sizeof (psp[0]);
00719     psp[0].dwFlags = PSP_DEFAULT | PSP_USETITLE;
00720     psp[0].hInstance = g_hmodThisDll;
00721     psp[0].pszTemplate = MAKEINTRESOURCE(IDD_ITEMCONFIGDIALOG);
00722     psp[0].pszIcon = NULL;
00723     psp[0].pfnDlgProc = (DLGPROC) ItemConfigDlgProc;
00724     psp[0].pszTitle = MAKEINTRESOURCE(IDS_ITEMCONFIG_TAB);
00725     psp[0].lParam = (LPARAM) &ItemConfiglParam;
00726
00727     if (hpsp[0] = CreatePropertySheetPage(&(psp[0])))
00728     {
00729
00730         psh.dwSize = sizeof (psh);
00731         psh.dwFlags = PSH_DEFAULT | PSH_USEHICON;
00732         psh.hwndParent = hWndParent;
00733         psh.hInstance = g_hmodThisDll;
00734         psh.pszIcon = NULL;
00735         psh.hIcon =  LoadIcon(g_hmodThisDll, MAKEINTRESOURCE(IDI_SAMPLEHANDLERITEMICON));
00736         psh.pszCaption = pDisplayName;
00737         psh.nPages = 1;
00738         psh.phpage = hpsp;
00739         psh.pfnCallback = NULL;
00740         psh.nStartPage = 0;
00741
00742         PropertySheet(&psh);
00743
00744         hr = ItemConfiglParam.hr;
00745     }
00746
00747     return hr;
00748 }
00749
00750
00751 //+---------------------------------------------------------------------------
00752 //
00753 //  Member:     CSettings::Alert, private
00754 //
00755 //  Synopsis:   Simple helper to show a message box.
00756 //
00757 //  Arguments:
00758 //
00759 //  Returns:
00760 //
00761 //  Modifies:
00762 //
00763 //----------------------------------------------------------------------------
00764
00765 int CSettings::Alert(HWND hWnd,LPCTSTR lpText)
00766 {
00767     return ::MessageBox(hWnd,lpText,TEXT("Sample Handler"),MB_OK | MB_ICONERROR);
00768 }
00769
00770
00771
00772 //+---------------------------------------------------------------------------
00773 //
00774 //  Member:     CSettings::ConfigDlgAddListViewItem, private
00775 //
00776 //  Synopsis:   Adds a ListViewItem to the Config Dialog.
00777 //
00778 //  Arguments:
00779 //
00780 //  Returns:    -1 on falure
00781 //
00782 //  Modifies:
00783 //
00784 //----------------------------------------------------------------------------
00785
00786 int CSettings::ConfigDlgAddListViewItem(HWND hWndList,SYNCMGRITEM syncMgrItem,int iItem
00787                                          ,int iIconIndex)
00788 {
00789 LV_ITEM lvItem;
00790 CONFIGITEMLISTVIEWLPARAM *pConfigItemListViewlParam;
00791 int iResult = -1;
00792
00793
00794     lvItem.mask = LVIF_TEXT | LVIF_PARAM;
00795     lvItem.iItem = iItem;
00796     lvItem.iSubItem = 0;
00797
00798     #ifdef _UNICODE
00799         lvItem.pszText = syncMgrItem.wszItemName;
00800     #else
00801         char TextBuf[MAX_PATH];
00802
00803         *TextBuf = NULL;
00804         WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, syncMgrItem.wszItemName,
00805                             -1, TextBuf,MAX_PATH, NULL, NULL);
00806
00807         lvItem.pszText = TextBuf;
00808
00809     #endif // _UNICODE
00810
00811     if (iIconIndex >= 0)
00812     {
00813         lvItem.mask |= LVIF_IMAGE;
00814         lvItem.iImage = iIconIndex;
00815     }
00816
00817     // need to store somethin in lParam so can get Item from it.
00818     pConfigItemListViewlParam = (CONFIGITEMLISTVIEWLPARAM *) ALLOC(sizeof(CONFIGITEMLISTVIEWLPARAM));
00819
00820     if (pConfigItemListViewlParam)
00821     {
00822
00823         pConfigItemListViewlParam->ItemID = syncMgrItem.ItemID;
00824     lvItem.lParam = (LPARAM) pConfigItemListViewlParam;
00825
00826     //add the item to the list
00827     iResult = ListView_InsertItem(hWndList, &lvItem);
00828
00829         if (-1 == iResult)
00830         {
00831             FREE(pConfigItemListViewlParam);
00832         }
00833
00834     }
00835
00836     return iResult;
00837 }
00838
00839 //+---------------------------------------------------------------------------
00840 //
00841 //  Member:     CSettings::OnConfigDlgInit, private
00842 //
00843 //  Synopsis:   Initializes the Config Dialog.
00844 //
00845 //  Arguments:
00846 //
00847 //  Returns:
00848 //
00849 //  Modifies:
00850 //
00851 //----------------------------------------------------------------------------
00852
00853 void CSettings::OnConfigDlgInit(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00854                                         UINT uMessage, WPARAM wParam,LPARAM lParam)
00855 {
00856 HWND hwndList = GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST);
00857
00858
00859     if (hwndList)
00860     {
00861     int iItem = 0;
00862     LV_COLUMN columnInfo;
00863     HIMAGELIST himage;
00864     int iIconIndex = -1;
00865     ISyncMgrEnumItems *pEnumItems;
00866
00867         ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT);
00868
00869     // Insert the Proper columns
00870     columnInfo.mask = LVCF_FMT  | LVCF_TEXT  | LVCF_WIDTH  | LVCF_SUBITEM;
00871     columnInfo.fmt = LVCFMT_LEFT;
00872     columnInfo.cx = CalcListViewWidth(hwndList,300);
00873     columnInfo .pszText = TEXT("Items");
00874     columnInfo.iSubItem = 0;
00875     ListView_InsertColumn(hwndList,0,&columnInfo);
00876
00877     // create an imagelist
00878         himage = ImageList_Create( GetSystemMetrics(SM_CXSMICON),
00879                          GetSystemMetrics(SM_CYSMICON),ILC_COLOR | ILC_MASK,5,20);
00880     if (himage)
00881     {
00882        ListView_SetImageList(hwndList,himage,LVSIL_SMALL);
00883     }
00884
00885     HICON hIcon = LoadIcon(g_hmodThisDll,MAKEINTRESOURCE(IDI_SAMPLEHANDLERITEMICON));
00886         if (hIcon)
00887         {
00888             iIconIndex = ImageList_AddIcon(himage,hIcon);
00889         }
00890
00891
00892         // loop though item enumerator adding the info.
00893         if (NOERROR == EnumSyncMgrItems(&pEnumItems))
00894         {
00895         SYNCMGRITEM syncMgrItem;
00896         ULONG fetched;
00897
00898             while (NOERROR == pEnumItems->Next(1,&syncMgrItem,&fetched))
00899             {
00900
00901                 if (-1 != ConfigDlgAddListViewItem(hwndList,syncMgrItem,iItem,iIconIndex))
00902                 {
00903                     iItem++;
00904                 }
00905
00906
00907             }
00908
00909             pEnumItems->Release();
00910         }
00911
00912     }
00913
00914 }
00915
00916 //+---------------------------------------------------------------------------
00917 //
00918 //  Member:     CSettings::DeleteListViewItem, private
00919 //
00920 //  Synopsis:   deletes an Item from the Config Dialog ListView
00921 //
00922 //  Arguments:
00923 //
00924 //  Returns:
00925 //
00926 //  Modifies:
00927 //
00928 //----------------------------------------------------------------------------
00929
00930 BOOL CSettings::ConfigDlgDeleteListViewItem(HWND hWndList,int iItem)
00931 {
00932 LV_ITEM lvItem;
00933 CONFIGITEMLISTVIEWLPARAM *pConfigItemListViewlParam;
00934 BOOL fResult = FALSE;
00935
00936     lvItem.mask = LVIF_PARAM;
00937     lvItem.iItem = iItem;
00938
00939     if (ListView_GetItem(hWndList, &lvItem))
00940     {
00941
00942         pConfigItemListViewlParam = (CONFIGITEMLISTVIEWLPARAM *) lvItem.lParam;
00943
00944         if (ListView_DeleteItem(hWndList,iItem))
00945         {
00946             fResult = TRUE;
00947
00948             if (pConfigItemListViewlParam)
00949             {
00950                 FREE(pConfigItemListViewlParam);
00951             }
00952         }
00953     }
00954
00955     return fResult;
00956 }
00957
00958 //+---------------------------------------------------------------------------
00959 //
00960 //  Member:     CSettings::OnConfigDlgDestroy, private
00961 //
00962 //  Synopsis:   called to cleanup the dialog
00963 //
00964 //  Arguments:
00965 //
00966 //  Returns:
00967 //
00968 //  Modifies:
00969 //
00970 //----------------------------------------------------------------------------
00971
00972 void CSettings::OnConfigDlgDestroy(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
00973                                         UINT uMessage, WPARAM wParam,LPARAM lParam)
00974 {
00975 HWND hwndListView = GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST);
00976 int iItemCount;
00977 int iItem;
00978
00979     if (!hwndListView)
00980     {
00981         return;
00982     }
00983
00984     iItemCount = ListView_GetItemCount(hwndListView);
00985
00986     for(iItem = 0; iItem < iItemCount; iItem++)
00987     {
00988         ConfigDlgDeleteListViewItem(hwndListView,0); // delete list view items to cleanup lParam
00989     }
00990 }
00991
00992
00993 //+---------------------------------------------------------------------------
00994 //
00995 //  Member:     CSettings::OnConfigDlgNotify, private
00996 //
00997 //  Synopsis:   handles WM_NOTIFY messages for the Config Dialog
00998 //
00999 //  Arguments:
01000 //
01001 //  Returns:
01002 //
01003 //  Modifies:
01004 //
01005 //----------------------------------------------------------------------------
01006
01007 void CSettings::OnConfigDlgNotify(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
01008                                         UINT uMessage, WPARAM wParam,LPARAM lParam)
01009 {
01010 LPNMHDR pnmhdr = (LPNMHDR)lParam;
01011 INT_PTR iCtrlId = wParam;
01012
01013     // enable/disable edit and remove button based on listview selection.
01014     if (IDC_CONFIGDIALOG_ITEMLIST == iCtrlId)
01015     {
01016     LPNMLISTVIEW pnmv = (LPNMLISTVIEW) pnmhdr;
01017
01018         switch (pnmhdr->code)
01019         {
01020             case LVN_ITEMCHANGED:
01021         {
01022         if (  (pnmv->uChanged == LVIF_STATE)  &&
01023               ((pnmv->uNewState ^ pnmv->uOldState) & LVIS_SELECTED))
01024         {
01025                 BOOL fEnable = FALSE;
01026
01027                     if (pnmv->uNewState & LVIS_SELECTED)
01028                     {
01029                         fEnable = TRUE;
01030                     }
01031
01032                     EnableWindow(GetDlgItem(hWnd,IDC_CONFIGDIALOG_REMOVE),fEnable);
01033                     EnableWindow(GetDlgItem(hWnd,IDC_CONFIGDIALOG_EDIT),fEnable);
01034         }
01035                 break;
01036         }
01037             case NM_DBLCLK:
01038         {
01039             LV_ITEM lvItem;
01040             CONFIGITEMLISTVIEWLPARAM *pConfigItemListViewlParam;
01041             SYNCMGRITEMID ItemID;
01042
01043                // grab itemid out of the lParam.
01044             lvItem.mask = LVIF_PARAM;
01045             lvItem.iItem = pnmv->iItem;
01046
01047             if (FALSE == ListView_GetItem(GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST),&lvItem))
01048                 {
01049                     return;
01050                 }
01051
01052             pConfigItemListViewlParam = (CONFIGITEMLISTVIEWLPARAM *) lvItem.lParam;
01053
01054                 if (NULL == pConfigItemListViewlParam)
01055                 {
01056                     return;
01057                 }
01058
01059                 ItemID = pConfigItemListViewlParam->ItemID;
01060
01061             OnConfigDlgEdit(hWnd,pConfigSettingslParam,ItemID,pnmv->iItem);
01062
01063                 break;
01064         }
01065         default:
01066                 break;
01067         }
01068     }
01069
01070 }
01071
01072 //+---------------------------------------------------------------------------
01073 //
01074 //  Member:     CSettings::OnConfigDlgAdd, private
01075 //
01076 //  Synopsis:   Implements what happens when User hits Add in the Config Dialog
01077 //
01078 //  Arguments:
01079 //
01080 //  Returns:
01081 //
01082 //  Modifies:
01083 //
01084 //----------------------------------------------------------------------------
01085
01086 void CSettings::OnConfigDlgAdd(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam)
01087 {
01088 LPSAMPLEITEMSETTINGS pSettings = (LPSAMPLEITEMSETTINGS) CreateNewListItem(sizeof(SAMPLEITEMSETTINGS));
01089
01090     if (pSettings)
01091     {
01092     HRESULT hr;
01093     SYNCMGRITEMID offType;
01094
01095         // generate an ID for the item.
01096         CoCreateGuid(&offType);
01097         pSettings->syncmgrItem.ItemID = offType;
01098         pSettings->syncmgrItem.cbSize = sizeof(SYNCMGRITEM);
01099         pSettings->syncmgrItem.dwItemState = SYNCMGRITEMSTATE_CHECKED;
01100
01101         pSettings->syncmgrItem.hIcon =
01102                     LoadIcon(g_hmodThisDll,MAKEINTRESOURCE(IDI_SAMPLEHANDLERICON));
01103
01104         pSettings->syncmgrItem.dwFlags =
01105                             SYNCMGRITEM_HASPROPERTIES | SYNCMGRITEM_LASTUPDATETIME;
01106
01107         // if wanted to setup default fields for item dialog on first create
01108         // do it here.
01109
01110         hr = ShowItemProperties(hWnd,TRUE /* fNew */, pSettings,GUID_NULL);
01111
01112         // if user hits okay/apply while in ShowItems
01113         // the item has been added to now add it to the global list
01114
01115         if ( (S_OK == hr) &&
01116             AddItemToList(m_pHandlerItems,(LPGENERICITEM) pSettings))
01117         {
01118         HWND hWndList;
01119         HICON hIcon;
01120         int iIconIndex = -1;
01121         HIMAGELIST himage;
01122
01123
01124             hWndList = GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST);
01125
01126             if (hWndList)
01127             {
01128
01129                 himage = ListView_GetImageList(hWndList,LVSIL_SMALL);
01130
01131             hIcon = LoadIcon(g_hmodThisDll,MAKEINTRESOURCE(IDI_SAMPLEHANDLERITEMICON));
01132                 if (hIcon && himage)
01133                 {
01134                     iIconIndex = ImageList_AddIcon(himage,hIcon);
01135                 }
01136
01137                 // add new item to the UI.
01138                 ConfigDlgAddListViewItem(hWndList,pSettings->syncmgrItem,0,iIconIndex);
01139             }
01140
01141             // need to reenum when return from showProperties if item was added.
01142             pConfigSettingslParam->hr = S_SYNCMGR_ENUMITEMS;
01143
01144         }
01145         else
01146         {
01147             FREE(pSettings);
01148         }
01149     }
01150 }
01151
01152 //+---------------------------------------------------------------------------
01153 //
01154 //  Member:     CSettings::OnConfigDlgAdd, private
01155 //
01156 //  Synopsis:   Implements what happens when User hits Remove in the Config Dialog
01157 //
01158 //  Arguments:
01159 //
01160 //  Returns:
01161 //
01162 //  Modifies:
01163 //
01164 //----------------------------------------------------------------------------
01165
01166 void CSettings::OnConfigDlgRemove(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
01167                                             SYNCMGRITEMID ItemID,int iItem)
01168 {
01169 LPSAMPLEITEMSETTINGS  pSettings;
01170 CLock clock(this);
01171
01172     Assert(iItem >= 0);
01173
01174     clock.Enter();
01175     pSettings =  FindItemSettings(ItemID);
01176
01177     if (pSettings && iItem >= 0)
01178     {
01179     HWND hwndListView = GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST);
01180
01181         DeleteItemSettings(pSettings); // delete item from the registry
01182
01183         DeleteItemFromList(m_pHandlerItems, (LPGENERICITEM) pSettings);// remove from enum list
01184
01185         // now remove from UI
01186         if (hwndListView)
01187         {
01188             ConfigDlgDeleteListViewItem(hwndListView,iItem);
01189         }
01190
01191         // on remove force a re-enum when return from ShowProperties.
01192         pConfigSettingslParam->hr = S_SYNCMGR_ENUMITEMS;
01193     }
01194
01195
01196     clock.Leave();
01197 }
01198
01199
01200 //+---------------------------------------------------------------------------
01201 //
01202 //  Member:     CSettings::OnConfigDlgEdit, private
01203 //
01204 //  Synopsis:   Implements what happens when User hits Edit in the Config Dialog
01205 //
01206 //  Arguments:
01207 //
01208 //  Returns:
01209 //
01210 //  Modifies:
01211 //
01212 //----------------------------------------------------------------------------
01213
01214 void CSettings::OnConfigDlgEdit(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
01215                                         SYNCMGRITEMID ItemID,int iSelection)
01216 {
01217
01218     if (S_OK == ShowItemProperties(hWnd,FALSE /* fNew */,NULL,ItemID))
01219     {
01220     HWND hwndListView =  GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST);
01221     LPSAMPLEITEMSETTINGS pSettings;
01222     CLock clock(this);
01223
01224         clock.Enter();
01225
01226         // update the listview to the new display name.
01227         // get settings again in case list changed.
01228         if (hwndListView &&
01229             (pSettings =  FindItemSettings(ItemID)))
01230         {
01231         TCHAR *pDisplayName;
01232
01233         #if _UNICODE
01234                 pDisplayName = pSettings->syncmgrItem.wszItemName;
01235         #else
01236             char TextBuf[MAX_PATH];
01237
01238             *TextBuf = NULL;
01239             WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
01240                                 pSettings->syncmgrItem.wszItemName,
01241                                 -1, TextBuf,MAX_PATH, NULL, NULL);
01242
01243             pDisplayName = TextBuf;
01244
01245         #endif // _UNICODE
01246
01247             ListView_SetItemText(hwndListView,iSelection,0,pDisplayName);
01248
01249         }
01250
01251         // if user change anything re-enum on return to ShowProperties
01252         // in case the display name was changed.
01253
01254         clock.Leave();
01255
01256         pConfigSettingslParam->hr = S_SYNCMGR_ENUMITEMS;
01257     }
01258 }
01259
01260
01261 //+---------------------------------------------------------------------------
01262 //
01263 //  Member:     CSettings::OnConfigDlgAdd, private
01264 //
01265 //  Synopsis:   Handles WM_COMMAND messages to Config Dialog
01266 //
01267 //  Arguments:
01268 //
01269 //  Returns:
01270 //
01271 //  Modifies:
01272 //
01273 //----------------------------------------------------------------------------
01274
01275 void CSettings::OnConfigDlgCommand(HWND hWnd,CONFIGSETTINGSLPARAM *pConfigSettingslParam,
01276                                         UINT uMessage, WPARAM wParam,LPARAM lParam)
01277 {
01278 WORD wNotifyCode =  HIWORD(wParam);
01279 WORD wID =  LOWORD(wParam);
01280 HWND hwndCtl =  (HWND)lParam;
01281 HWND hwndListView = GetDlgItem(hWnd,IDC_CONFIGDIALOG_ITEMLIST);
01282
01283     if (BN_CLICKED == wNotifyCode) // all just respond to clicked
01284     {
01285         switch (wID)
01286         {
01287         case IDC_CONFIGDIALOG_REMOVE:
01288         case IDC_CONFIGDIALOG_EDIT:
01289         {
01290         int iSelection;
01291         LV_ITEM lvItem;
01292         CONFIGITEMLISTVIEWLPARAM *pConfigItemListViewlParam;
01293         SYNCMGRITEMID ItemID;
01294
01295             if (!hwndListView || (-1 == (iSelection = ListView_GetSelectionMark(hwndListView))))
01296             {
01297                 return;
01298             }
01299
01300             // grab itemid out of the lParam.
01301         lvItem.mask = LVIF_PARAM;
01302         lvItem.iItem = iSelection;
01303
01304         if (FALSE == ListView_GetItem(hwndListView, &lvItem) )
01305             {
01306                 return;
01307             }
01308
01309         pConfigItemListViewlParam = (CONFIGITEMLISTVIEWLPARAM *) lvItem.lParam;
01310
01311             if (NULL == pConfigItemListViewlParam)
01312             {
01313                 return;
01314             }
01315
01316             ItemID = pConfigItemListViewlParam->ItemID;
01317
01318             switch (wID)
01319             {
01320             case IDC_CONFIGDIALOG_REMOVE:
01321                 OnConfigDlgRemove(hWnd,pConfigSettingslParam,ItemID,iSelection);
01322                 break;
01323         case  IDC_CONFIGDIALOG_EDIT:
01324                 OnConfigDlgEdit(hWnd,pConfigSettingslParam,ItemID,iSelection);
01325                 break;
01326             default:
01327                 break;
01328             }
01329
01330             break;
01331         }
01332     case  IDC_CONFIGDIALOG_ADD:
01333             OnConfigDlgAdd(hWnd,pConfigSettingslParam);
01334             break;
01335         default:
01336             break;
01337         }
01338     }
01339 }
01340
01341
01342 //+---------------------------------------------------------------------------
01343 //
01344 //  function:   ConfigureDlgProc, private
01345 //
01346 //  Synopsis:   wndProc for Configuration Dialog
01347 //
01348 //  Arguments:
01349 //
01350 //  Returns:
01351 //
01352 //  Modifies:
01353 //
01354 //----------------------------------------------------------------------------
01355
01356 BOOL CALLBACK ConfigureDlgProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
01357 {
01358 WORD wNotifyCode = HIWORD(wParam); // notification code
01359 BOOL bResult = FALSE;
01360 CONFIGSETTINGSLPARAM *pConfigSettingslParam = (CONFIGSETTINGSLPARAM *) GetWindowLongPtr(hWnd,DWLP_USER);
01361
01362     if (WM_INITDIALOG == uMessage)
01363     {
01364         pConfigSettingslParam =  (CONFIGSETTINGSLPARAM *) ((PROPSHEETPAGE *) lParam)->lParam;
01365         SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR) pConfigSettingslParam);
01366
01367         pConfigSettingslParam->pSettings->OnConfigDlgInit(hWnd,pConfigSettingslParam,uMessage,wParam,lParam);
01368     }
01369     else if (pConfigSettingslParam)
01370     {
01371         switch (uMessage)
01372         {
01373             case WM_DESTROY:
01374                 pConfigSettingslParam->pSettings->OnConfigDlgDestroy(hWnd,pConfigSettingslParam,uMessage,wParam,lParam);
01375             break;
01376             case WM_NOTIFY:
01377                 switch (((NMHDR FAR *)lParam)->code)
01378                 {
01379                     case PSN_APPLY:
01380
01381                         // if anything changed mark OK even if later cancel, can't undo
01382                         break;
01383                   default:
01384                         pConfigSettingslParam->pSettings->OnConfigDlgNotify(hWnd,pConfigSettingslParam,uMessage,wParam,lParam);
01385                      break;
01386                 }
01387                 break;
01388         case WM_COMMAND:
01389                 pConfigSettingslParam->pSettings->OnConfigDlgCommand(hWnd,pConfigSettingslParam,uMessage,wParam,lParam);
01390             break;
01391         default:
01392                 break;
01393         }
01394     }
01395
01396     return bResult;
01397 }
01398
01399 //+---------------------------------------------------------------------------
01400 //
01401 //  Member:     CSettings::ItemConfigDlgGetItemSettings, private
01402 //
01403 //  Synopsis:   Gets ptr to ItemSettings for specified Item.
01404 //
01405 //  Arguments:
01406 //
01407 //  Returns:
01408 //
01409 //  Modifies:
01410 //
01411 //----------------------------------------------------------------------------
01412
01413 LPSAMPLEITEMSETTINGS CSettings::ItemConfigDlgGetItemSettings(ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam)
01414 {
01415 LPSAMPLEITEMSETTINGS pSampleItem = NULL;
01416
01417     ASSERT_LOCKHELD(this);
01418
01419     if (pItemConfigDlglParam->fNewItem)
01420     {
01421         pSampleItem = pItemConfigDlglParam->pItemSettings;
01422     }
01423     else
01424     {
01425         pSampleItem = FindItemSettings(pItemConfigDlglParam->ItemID);
01426     }
01427
01428     return pSampleItem;
01429 }
01430
01431 //+---------------------------------------------------------------------------
01432 //
01433 //  Member:     CSettings::OnItemConfigDlgInit, private
01434 //
01435 //  Synopsis:   Handles WM_INITDIALOG message for Item Property Page
01436 //
01437 //  Arguments:
01438 //
01439 //  Returns:
01440 //
01441 //  Modifies:
01442 //
01443 //----------------------------------------------------------------------------
01444
01445 void CSettings::OnItemConfigDlgInit(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
01446                                     UINT uMessage, WPARAM wParam, LPARAM lParam)
01447 {
01448 LPSAMPLEITEMSETTINGS pSampleItem;
01449 CLock clock(this);
01450     clock.Enter();
01451
01452     pSampleItem = ItemConfigDlgGetItemSettings(pItemConfigDlglParam);
01453
01454
01455     pItemConfigDlglParam->hr = S_FALSE; // by default nothing has changed.
01456
01457     // fill in the dialog values.
01458     if (pSampleItem)
01459     {
01460     HWND hwndCtrl;
01461     #ifndef _UNICODE
01462     char TextBuf[MAX_PATH];
01463     #endif // _UNICODE
01464
01465         hwndCtrl = GetDlgItem(hWnd,IDC_ITEMCONFIGDIALOG_EDIT_DISPLAYNAME);
01466         if (hwndCtrl)
01467         {
01468         TCHAR *pDisplayName;
01469
01470         #if _UNICODE
01471                 pDisplayName = pSampleItem->syncmgrItem.wszItemName;
01472         #else
01473             *TextBuf = NULL;
01474             WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
01475                                 pSampleItem->syncmgrItem.wszItemName,
01476                                 -1, TextBuf,MAX_PATH, NULL, NULL);
01477
01478             pDisplayName = TextBuf;
01479
01480         #endif // _UNICODE
01481
01482            SendMessage(hwndCtrl,EM_SETLIMITTEXT,MAX_SYNCMGRITEMNAME,0);
01483            SetWindowText(hwndCtrl,pDisplayName);
01484         }
01485
01486         hwndCtrl = GetDlgItem(hWnd,IDC_ITEMCONFIGDIALOG_EDIT_DIR1NAME);
01487         if (hwndCtrl)
01488         {
01489             SendMessage(hwndCtrl,EM_SETLIMITTEXT,sizeof(pSampleItem->dir1),0);
01490             SendMessage(hwndCtrl,WM_SETTEXT,0,(LPARAM) pSampleItem->dir1);
01491         }
01492
01493         hwndCtrl = GetDlgItem(hWnd,IDC_ITEMCONFIGDIALOG_EDIT_DIR2NAME);
01494         if (hwndCtrl)
01495         {
01496             SendMessage(hwndCtrl,EM_SETLIMITTEXT,sizeof(pSampleItem->dir2),0);
01497             SendMessage(hwndCtrl,WM_SETTEXT,0,(LPARAM) pSampleItem->dir2);
01498         }
01499
01500         CheckDlgButton(hWnd,IDC_ITEMCONFIGDIALOG_INCLUDESUBDIRS,pSampleItem->fRecursive);
01501
01502     }
01503
01504     pItemConfigDlglParam->fDirty = FALSE;
01505
01506     clock.Leave();
01507 }
01508
01509 //+---------------------------------------------------------------------------
01510 //
01511 //  Member:     CSettings::OnItemConfigDlgDetroy, private
01512 //
01513 //  Synopsis:   Handles WM_DESTROY message for Item Property Page
01514 //
01515 //  Arguments:
01516 //
01517 //  Returns:
01518 //
01519 //  Modifies:
01520 //
01521 //----------------------------------------------------------------------------
01522
01523 void CSettings::OnItemConfigDlgDestroy(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
01524                                     UINT uMessage, WPARAM wParam,LPARAM lParam)
01525 {
01526
01527 }
01528
01529 //+---------------------------------------------------------------------------
01530 //
01531 //  Member:     CSettings::OnItemConfigDlgNotify, private
01532 //
01533 //  Synopsis:   Handles WM_NOTIFY message for Item Property Page
01534 //
01535 //  Arguments:
01536 //
01537 //  Returns:
01538 //
01539 //  Modifies:
01540 //
01541 //----------------------------------------------------------------------------
01542
01543 void CSettings::OnItemConfigDlgNotify(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
01544                                         UINT uMessage, WPARAM wParam,LPARAM lParam)
01545 {
01546
01547
01548 }
01549
01550 //+---------------------------------------------------------------------------
01551 //
01552 //  Member:     CSettings::OnItemConfigDlgCommand, private
01553 //
01554 //  Synopsis:   Handles WM_COMMAND message for Item Property Page
01555 //
01556 //  Arguments:
01557 //
01558 //  Returns:
01559 //
01560 //  Modifies:
01561 //
01562 //----------------------------------------------------------------------------
01563
01564 void CSettings::OnItemConfigDlgCommand(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
01565                                         UINT uMessage, WPARAM wParam,LPARAM lParam)
01566 {
01567 WORD wNotifyCode = HIWORD(wParam); // notification code
01568 WORD wID = LOWORD(wParam);         // item, control, or accelerator identifier
01569 HWND hwndCtl = (HWND) lParam;      // handle of control
01570
01571     if ((EN_CHANGE == wNotifyCode) || (BN_CLICKED == wNotifyCode))
01572     {
01573         pItemConfigDlglParam->fDirty = TRUE;
01574         PropSheet_Changed(GetParent(hWnd), hWnd);
01575     }
01576
01577 }
01578
01579 //+---------------------------------------------------------------------------
01580 //
01581 //  Member:     CSettings::OnItemConfigDlgApply, private
01582 //
01583 //  Synopsis:   Called when APPLY or Okay is pressed on item Properties page.
01584 //
01585 //  Arguments:
01586 //
01587 //  Returns:
01588 //
01589 //  Modifies:
01590 //
01591 //----------------------------------------------------------------------------
01592
01593 BOOL CSettings::OnItemConfigDlgApply(HWND hWnd,ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam,
01594                                     UINT uMessage, WPARAM wParam,LPARAM lParam)
01595 {
01596 BOOL fResult = TRUE;
01597 CLock clock(this);
01598
01599     if (pItemConfigDlglParam->fDirty)
01600     {
01601     LPSAMPLEITEMSETTINGS pSampleItem;
01602     HWND hwndCtrl;
01603     TCHAR dir1[MAX_PATH];
01604     TCHAR dir2[MAX_PATH];
01605     TCHAR DisplayName[MAX_SYNCMGRITEMNAME];
01606     WCHAR *pDisplayName;
01607     BOOL fRecursive = FALSE;
01608     BOOL fPersist = TRUE;
01609
01610     // get dialog values, if couldn't find don't return error so user can still cancel
01611     // dialog
01612
01613         hwndCtrl = GetDlgItem(hWnd,IDC_ITEMCONFIGDIALOG_EDIT_DISPLAYNAME);
01614         if (hwndCtrl)
01615         {
01616             if (0 >= GetWindowText(hwndCtrl,DisplayName,sizeof(DisplayName)/sizeof(TCHAR)))
01617             {
01618                 Alert(hWnd,TEXT("Display Name Is Not Valid."));
01619                 SetFocus(hwndCtrl);
01620                 return FALSE;
01621             }
01622
01623             #if _UNICODE
01624                 pDisplayName = DisplayName;
01625             #else
01626                 WCHAR wszTextBuf[MAX_SYNCMGRITEMNAME];
01627
01628                 MultiByteToWideChar(CP_ACP, 0,
01629                                     DisplayName,
01630                                     -1, wszTextBuf,MAX_SYNCMGRITEMNAME);
01631
01632                 pDisplayName = wszTextBuf;
01633
01634             #endif // _UNICODE
01635
01636         }
01637         else
01638         {
01639             fPersist = FALSE;
01640         }
01641
01642
01643         // get the new dir names.
01644         hwndCtrl = GetDlgItem(hWnd,IDC_ITEMCONFIGDIALOG_EDIT_DIR1NAME);
01645         if (hwndCtrl)
01646         {
01647             if (0 >= GetWindowText(hwndCtrl,dir1,sizeof(dir1)/sizeof(TCHAR)))
01648             {
01649                 Alert(hWnd,TEXT("Dir1 Name Is Not Valid."));
01650                return FALSE;
01651             }
01652         }
01653         else
01654         {
01655             fPersist = FALSE;
01656         }
01657
01658         hwndCtrl = GetDlgItem(hWnd,IDC_ITEMCONFIGDIALOG_EDIT_DIR2NAME);
01659         if (hwndCtrl)
01660         {
01661             if (0 >= GetWindowText(hwndCtrl,dir2,sizeof(dir2)/sizeof(TCHAR)))
01662             {
01663                 Alert(hWnd,TEXT("Dir2 Name Is Not Valid."));
01664                 return FALSE;
01665             }
01666         }
01667         else
01668         {
01669             fPersist = FALSE;
01670         }
01671
01672         // verify dir paths
01673         if (!IsValidDir(dir1))
01674         {
01675             Alert(hWnd,TEXT("Dir1 Name Is Not a Valid directory"));
01676             return FALSE;
01677         }
01678
01679         if (!IsValidDir(dir2))
01680         {
01681             Alert(hWnd,TEXT("Dir2 Name Is Not a Valid directory"));
01682             return FALSE;
01683         }
01684
01685
01686         fRecursive = IsDlgButtonChecked(hWnd,IDC_ITEMCONFIGDIALOG_INCLUDESUBDIRS);
01687
01688         // if everything validated write it out.
01689         clock.Enter();
01690         pSampleItem = ItemConfigDlgGetItemSettings(pItemConfigDlglParam);
01691         if (fPersist && pSampleItem)
01692         {
01693
01694             lstrcpyW(pSampleItem->syncmgrItem.wszItemName,pDisplayName);
01695             lstrcpy(pSampleItem->dir1,dir1);
01696             lstrcpy(pSampleItem->dir2,dir2);
01697             pSampleItem->fRecursive = fRecursive;
01698             WriteItemSettings(pSampleItem);
01699
01700             pItemConfigDlglParam->hr = S_OK; // only say items saved okay when dirty and saved properly
01701         }
01702
01703         clock.Leave();
01704     }
01705
01706     return fResult;
01707 }
01708
01709
01710 //+---------------------------------------------------------------------------
01711 //
01712 //  fucntion:   ItemConfigureDlgProc, private
01713 //
01714 //  Synopsis:   wndproc for Items Property page
01715 //
01716 //  Arguments:
01717 //
01718 //  Returns:
01719 //
01720 //  Modifies:
01721 //
01722 //----------------------------------------------------------------------------
01723
01724 BOOL CALLBACK ItemConfigDlgProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
01725 {
01726 WORD wNotifyCode = HIWORD(wParam); // notification code
01727 BOOL bResult = FALSE;
01728 ITEMCONFIGSETTINGSLPARAM *pItemConfigDlglParam = (ITEMCONFIGSETTINGSLPARAM *) GetWindowLongPtr(hWnd,DWLP_USER);
01729
01730     if (WM_INITDIALOG == uMessage)
01731     {
01732         pItemConfigDlglParam =  (ITEMCONFIGSETTINGSLPARAM *) ((PROPSHEETPAGE *) lParam)->lParam;
01733         SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR) pItemConfigDlglParam);
01734
01735         pItemConfigDlglParam->pSettings->OnItemConfigDlgInit(hWnd,pItemConfigDlglParam,uMessage,wParam,lParam);
01736
01737     }
01738     else if (pItemConfigDlglParam)
01739     {
01740         switch (uMessage)
01741         {
01742             case WM_DESTROY:
01743                 pItemConfigDlglParam->pSettings->OnItemConfigDlgDestroy(hWnd,pItemConfigDlglParam,uMessage,wParam,lParam);
01744             break;
01745             case WM_NOTIFY:
01746                 switch (((NMHDR FAR *)lParam)->code)
01747                 {
01748                     case PSN_APPLY:
01749
01750                         // after a successful apply the item has changed.
01751                         // so set return value to S_OK:
01752                         if (pItemConfigDlglParam->pSettings->OnItemConfigDlgApply(hWnd,pItemConfigDlglParam,uMessage,wParam,lParam))
01753                         {
01754                            SetWindowLongPtr(hWnd,DWLP_MSGRESULT,PSNRET_NOERROR);
01755                         }
01756                         else
01757                         {
01758                             SetWindowLongPtr(hWnd,DWLP_MSGRESULT,PSNRET_INVALID);
01759                         }
01760
01761                         return TRUE; // !!!return true so SetWindowLong DWL_MSGRESULT is applied
01762                         break;
01763                     default:
01764                         pItemConfigDlglParam->pSettings->OnItemConfigDlgNotify(hWnd,pItemConfigDlglParam,uMessage,wParam,lParam);
01765                         break;
01766                 }
01767                 break;
01768         case WM_COMMAND:
01769                 pItemConfigDlglParam->pSettings->OnItemConfigDlgCommand(hWnd,pItemConfigDlglParam,uMessage,wParam,lParam);
01770         break;
01771         default:
01772                 break;
01773         }
01774     }
01775
01776     return bResult;
01777 }
01778
01779 // implementation for item enumerator used and managed by settings.
01780
01781 //+---------------------------------------------------------------------------
01782 //
01783 //  Member:    CEnumSyncMgrItems::CEnumSyncMgrItems, public
01784 //
01785 //  Synopsis:  contructor
01786 //
01787 //  Returns:
01788 //
01789 //  Modifies:
01790 //
01791 //----------------------------------------------------------------------------
01792
01793 CEnumSyncMgrItems::CEnumSyncMgrItems(LPGENERICITEMLIST pGenericItemList,DWORD cOffset)
01794     : CGenericEnum(pGenericItemList,cOffset)
01795 {
01796 }
01797
01798
01799 //+---------------------------------------------------------------------------
01800 //
01801 //  Member:    CEnumSyncMgrItems::DeleteThisObject, public
01802 //
01803 //  Synopsis:  called by generic Enum when refcount hits zero
01804 //
01805 //  Returns:
01806 //
01807 //  Modifies:
01808 //
01809 //----------------------------------------------------------------------------
01810
01811 void CEnumSyncMgrItems::DeleteThisObject()
01812 {
01813     delete this;
01814 }
01815
01816
01817 //+---------------------------------------------------------------------------
01818 //
01819 //  Member:    CEnumSyncMgrItems::QueryInteface, public
01820 //
01821 //  Synopsis:  must override generic implementation.
01822 //
01823 //  Returns:
01824 //
01825 //  Modifies:
01826 //
01827 //----------------------------------------------------------------------------
01828
01829 STDMETHODIMP CEnumSyncMgrItems::QueryInterface(REFIID riid, LPVOID FAR *ppv)
01830 {
01831     *ppv = NULL;
01832
01833     if (IsEqualIID(riid, IID_IUnknown))
01834     {
01835         *ppv = (LPUNKNOWN) this;
01836     }
01837     else if (IsEqualIID(riid, IID_ISyncMgrEnumItems))
01838     {
01839         *ppv = (LPSYNCMGRENUMITEMS) this;
01840     }
01841     if (*ppv)
01842     {
01843         AddRef();
01844
01845         return NOERROR;
01846     }
01847
01848     return E_NOINTERFACE;
01849 }
01850
01851
01852 //+---------------------------------------------------------------------------
01853 //
01854 //  Member:    CEnumSyncMgrItems::AddRef, public
01855 //
01856 //  Synopsis:
01857 //
01858 //  Returns:
01859 //
01860 //  Modifies:
01861 //
01862 //----------------------------------------------------------------------------
01863
01864 STDMETHODIMP_(ULONG) CEnumSyncMgrItems::AddRef()
01865 {
01866     return CGenericEnum::AddRef();
01867 }
01868
01869 //+---------------------------------------------------------------------------
01870 //
01871 //  Member:    CEnumSyncMgrItems::Release, public
01872 //
01873 //  Synopsis:
01874 //
01875 //  Returns:
01876 //
01877 //  Modifies:
01878 //
01879 //----------------------------------------------------------------------------
01880
01881 STDMETHODIMP_(ULONG) CEnumSyncMgrItems::Release()
01882 {
01883     return CGenericEnum::Release();
01884 }
01885
01886
01887 //+---------------------------------------------------------------------------
01888 //
01889 //  Member:    CEnumSyncMgrItems::Next, public
01890 //
01891 //  Synopsis:  must override generic implementation.
01892 //
01893 //  Returns:
01894 //
01895 //  Modifies:
01896 //
01897 //----------------------------------------------------------------------------
01898
01899 STDMETHODIMP CEnumSyncMgrItems::Next(ULONG celt, LPSYNCMGRITEM rgelt,ULONG *pceltFetched)
01900 {
01901 HRESULT hr = NOERROR;
01902 ULONG ulFetchCount = celt;
01903 ULONG ulTransferCount = 0;
01904 LPSYNCMGRITEM pGenericItem;
01905
01906     if ( (m_cOffset + celt) > m_pGenericItemList->dwNumItems)
01907     {
01908     ulFetchCount = m_pGenericItemList->dwNumItems - m_cOffset;
01909     hr = S_FALSE;
01910     }
01911
01912     pGenericItem = rgelt;
01913
01914     while (ulFetchCount--)
01915     {
01916     LPSAMPLEITEMSETTINGS pNextSyncMgrItem;
01917
01918         Assert(m_pNextItem->cbSize == sizeof(SAMPLEITEMSETTINGS));
01919
01920         pNextSyncMgrItem = (LPSAMPLEITEMSETTINGS) m_pNextItem;
01921
01922     memcpy(pGenericItem,&(pNextSyncMgrItem->syncmgrItem),sizeof(SYNCMGRITEM));
01923     m_pNextItem = m_pNextItem->pNextGenericItem; // add error checking
01924     ++m_cOffset;
01925         ++ulTransferCount;
01926     ++pGenericItem;
01927     }
01928
01929     if (pceltFetched)
01930     {
01931         *pceltFetched = ulTransferCount;
01932     }
01933
01934     return hr;
01935 }
01936
01937 //+---------------------------------------------------------------------------
01938 //
01939 //  Member:    CEnumSyncMgrItems::Skip, public
01940 //
01941 //  Synopsis:
01942 //
01943 //  Returns:
01944 //
01945 //  Modifies:
01946 //
01947 //----------------------------------------------------------------------------
01948
01949 STDMETHODIMP CEnumSyncMgrItems::Skip(ULONG celt)
01950 {
01951     return CGenericEnum::Skip(celt);
01952 }
01953
01954
01955 //+---------------------------------------------------------------------------
01956 //
01957 //  Member:    CEnumSyncMgrItems::Reset, public
01958 //
01959 //  Synopsis:
01960 //
01961 //  Returns:
01962 //
01963 //  Modifies:
01964 //
01965 //----------------------------------------------------------------------------
01966
01967 STDMETHODIMP CEnumSyncMgrItems::Reset()
01968 {
01969     return CGenericEnum::Reset();
01970 }
01971
01972
01973 //+---------------------------------------------------------------------------
01974 //
01975 //  Member:    CEnumSyncMgrItems::Clone, public
01976 //
01977 //  Synopsis:  must override generic implementation.
01978 //
01979 //  Returns:
01980 //
01981 //  Modifies:
01982 //
01983 //----------------------------------------------------------------------------
01984
01985 STDMETHODIMP CEnumSyncMgrItems::Clone(ISyncMgrEnumItems **ppenum)
01986 {
01987 *ppenum = new  CEnumSyncMgrItems(m_pGenericItemList,m_cOffset);
01988
01989     return *ppenum ? NOERROR : E_OUTOFMEMORY;
01990 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCapMFCApp Member List

This is the complete list of members for CCapMFCApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CCapMFCApp() | CCapMFCApp |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CCapMFCApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:55:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Framer/Resource.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Framer

Resource.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*
00019  * RESOURCE.H
00020  * Document Objects Framer
00021  *
00022  * Definitions specifically pertaining to resources for the application.
00023  *
00024  */
00025
00026
00027 #ifndef _RESOURCE_H_
00028 #define _RESOURCE_H_
00029
00030 //Number of menus.
00031 #define CMENUS                              2
00032
00033 //Resource identifiers.
00034 #define IDR_MENU                            1
00035 #define IDR_MENUHELP                        2
00036 #define IDR_ACCELERATORS                    1
00037 #define IDD_ABOUT                           1
00038
00039 //Number of items on IDR_MENUHELP
00040 #define CHELPITEMS                          1
00041
00042 //Menu command identifiers.
00043 #define IDM_FILEOPEN                        101
00044 #define IDM_FILECLOSE                       102
00045 #define IDM_FILEEXIT                        105
00046
00047 #define IDM_HELPABOUT                       200
00048 #define IDM_CUSTOMHELPMIN                   201
00049
00050
00051 //Enters context help in in-place mode
00052 #define IDM_ENTERCONTEXTHELP                300
00053 #define IDM_ESCAPECONTEXTHELP               301
00054
00055 #define CACCELERATORS                       2
00056
00057 #endif //_RESOURCE_H_
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/snoop.cpp Source File

  • WinUI
  • TSFcase

snoop.cpp

Go to the documentation of this file.
00001 //
00002 // snoop.cpp
00003 //
00004 // CSnoopWnd implementation.
00005 //
00006
00007 #include "globals.h"
00008 #include "snoop.h"
00009 #include "case.h"
00010 #include "editsess.h"
00011
00012 class CUpdateTextEditSession : public CEditSessionBase
00013 {
00014 public:
00015     CUpdateTextEditSession(ITfContext *pContext, ITfRange *pRange, CSnoopWnd *pSnoopWnd) : CEditSessionBase(pContext)
00016     {
00017         _pSnoopWnd = pSnoopWnd;
00018         _pRange = pRange;
00019         if (_pRange != NULL)
00020         {
00021             _pRange->AddRef();
00022         }
00023     }
00024     ~CUpdateTextEditSession()
00025     {
00026         SafeRelease(_pRange);
00027     }
00028
00029     // ITfEditSession
00030     STDMETHODIMP DoEditSession(TfEditCookie ec);
00031
00032 private:
00033     CSnoopWnd *_pSnoopWnd;
00034     ITfRange *_pRange;
00035 };
00036
00037
00038 #define SNOOP_X_POS     0
00039 #define SNOOP_Y_POS     0
00040
00041 #define SNOOP_WIDTH     300
00042 #define SNOOP_HEIGHT    (SNOOP_WIDTH / 3)
00043
00044 ATOM CSnoopWnd::_atomWndClass = 0;
00045
00046 //+---------------------------------------------------------------------------
00047 //
00048 // ctor
00049 //
00050 //----------------------------------------------------------------------------
00051
00052 CSnoopWnd::CSnoopWnd(CCaseTextService *pCase)
00053 {
00054     _pCase = pCase; // no AddRef because CSnoopWnd is contained in the
00055                     // pCase lifetime
00056     _hWnd = NULL;
00057     _cchText = 0;
00058 }
00059
00060 //+---------------------------------------------------------------------------
00061 //
00062 // _InitClass
00063 //
00064 //----------------------------------------------------------------------------
00065
00066 /* static */
00067 BOOL CSnoopWnd::_InitClass()
00068 {
00069     WNDCLASS wc;
00070
00071     wc.style = 0;
00072     wc.lpfnWndProc = CSnoopWnd::_WndProc;
00073     wc.cbClsExtra = 0;
00074     wc.cbWndExtra = 0;
00075     wc.hInstance = g_hInst;
00076     wc.hIcon = NULL;
00077     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00078     wc.hbrBackground = NULL;
00079     wc.lpszMenuName = NULL;
00080     wc.lpszClassName = TEXT("SnoopWndClass");
00081
00082     _atomWndClass = RegisterClass(&wc);
00083
00084     return (_atomWndClass != 0);
00085 }
00086
00087 //+---------------------------------------------------------------------------
00088 //
00089 // _UninitClass
00090 //
00091 //----------------------------------------------------------------------------
00092
00093 /* static */
00094 void CSnoopWnd::_UninitClass()
00095 {
00096     if (_atomWndClass != 0)
00097     {
00098         UnregisterClass((LPCTSTR)_atomWndClass, g_hInst);
00099     }
00100 }
00101
00102
00103 //+---------------------------------------------------------------------------
00104 //
00105 // _Init
00106 //
00107 //----------------------------------------------------------------------------
00108
00109 BOOL CSnoopWnd::_Init()
00110 {
00111     // nb: on windows 2000, you can use WS_EX_NOACTIVATE to prevent windows
00112     // from taking the foreground.  We don't use that here for compatibility.
00113     // Instead, we use WS_DISABLED, which can be burdensome for more complex
00114     // ui.
00115
00116     _hWnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW,
00117                            (LPCTSTR)_atomWndClass,
00118                            TEXT("Snoop Window"),
00119                            WS_BORDER | WS_DISABLED | WS_POPUP,
00120                            SNOOP_X_POS, SNOOP_Y_POS,
00121                            SNOOP_WIDTH, SNOOP_HEIGHT,
00122                            NULL,
00123                            NULL,
00124                            g_hInst,
00125                            this);
00126
00127     return (_hWnd != NULL);
00128 }
00129
00130 //+---------------------------------------------------------------------------
00131 //
00132 // _Uninit
00133 //
00134 //----------------------------------------------------------------------------
00135
00136 void CSnoopWnd::_Uninit()
00137 {
00138     if (_hWnd != NULL)
00139     {
00140         DestroyWindow(_hWnd);
00141         _hWnd = NULL;
00142     }
00143 }
00144
00145 //+---------------------------------------------------------------------------
00146 //
00147 // _Show
00148 //
00149 //----------------------------------------------------------------------------
00150
00151 void CSnoopWnd::_Show()
00152 {
00153     ShowWindow(_hWnd, SW_SHOWNA);
00154 }
00155
00156 //+---------------------------------------------------------------------------
00157 //
00158 // _Hide
00159 //
00160 //----------------------------------------------------------------------------
00161
00162 void CSnoopWnd::_Hide()
00163 {
00164     ShowWindow(_hWnd, SW_HIDE);
00165 }
00166
00167 //+---------------------------------------------------------------------------
00168 //
00169 // _UpdateText
00170 //
00171 //----------------------------------------------------------------------------
00172
00173 void CSnoopWnd::_UpdateText(ITfRange *pRange)
00174 {
00175     ITfDocumentMgr *pdmFocus;
00176     ITfContext *pContext;
00177     CUpdateTextEditSession *pEditSession;
00178     HRESULT hr;
00179
00180     if (pRange == NULL)
00181     {
00182         // caller wants us to just use the selection in the focus doc
00183         if (_pCase->_GetThreadMgr()->GetFocus(&pdmFocus) != S_OK)
00184             return;
00185
00186         hr = pdmFocus->GetTop(&pContext);
00187
00188         pdmFocus->Release();
00189
00190         if (hr != S_OK)
00191             return;
00192     }
00193     else if (pRange->GetContext(&pContext) != S_OK)
00194         return;
00195
00196     if (pEditSession = new CUpdateTextEditSession(pContext, pRange, this))
00197     {
00198         // we need a document read lock to scan text
00199         // the CUpdateTextEditSession will do all the work when the
00200         // CUpdateTextEditSession::DoEditSession method is called by the context
00201         pContext->RequestEditSession(_pCase->_GetClientId(), pEditSession, TF_ES_READ | TF_ES_ASYNCDONTCARE, &hr);
00202
00203         pEditSession->Release();
00204     }
00205
00206     pContext->Release();
00207 }
00208
00209 //+---------------------------------------------------------------------------
00210 //
00211 // DoEditSession
00212 //
00213 //----------------------------------------------------------------------------
00214
00215 STDAPI CUpdateTextEditSession::DoEditSession(TfEditCookie ec)
00216 {
00217     _pSnoopWnd->_UpdateText(ec, _pContext, _pRange);
00218     return S_OK;
00219 }
00220
00221 //+---------------------------------------------------------------------------
00222 //
00223 // _UpdateText
00224 //
00225 //----------------------------------------------------------------------------
00226
00227 void CSnoopWnd::_UpdateText(TfEditCookie ec, ITfContext *pContext, ITfRange *pRange)
00228 {
00229     LONG cchBefore;
00230     LONG cchAfter;
00231     TF_SELECTION tfSelection;
00232     ULONG cFetched;
00233     BOOL fReleaseRange = FALSE;
00234
00235     if (pRange == NULL)
00236     {
00237         // caller wants us to use the selection
00238         if (pContext->GetSelection(ec, TS_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK ||
00239             cFetched != 1)
00240         {
00241             return;
00242         }
00243
00244         pRange = tfSelection.range; // no AddRef, take ownership of the pointer
00245         fReleaseRange = TRUE;
00246     }
00247
00248     // arbitrarily grab some text before and after the range start anchor
00249
00250     pRange->Collapse(ec, TF_ANCHOR_START);
00251
00252     pRange->ShiftStart(ec, -MAX_SNOOP_TEXT / 2, &cchBefore, NULL);
00253
00254     cchBefore = -cchBefore; // we shifted backwards, so make count a positive number
00255
00256     pRange->GetText(ec, 0, _achText, cchBefore, (ULONG *)&cchBefore);
00257
00258     pRange->Collapse(ec, TF_ANCHOR_END);
00259
00260     pRange->ShiftEnd(ec, MAX_SNOOP_TEXT - cchBefore, &cchAfter, NULL);
00261
00262     pRange->GetText(ec, 0, _achText + cchBefore, cchAfter, (ULONG *)&cchAfter);
00263
00264     _cchText = cchBefore + cchAfter;
00265
00266     // force a repaint
00267
00268     InvalidateRect(_hWnd, NULL, TRUE);
00269
00270     if (fReleaseRange)
00271     {
00272         pRange->Release();
00273     }
00274 }
00275
00276 //+---------------------------------------------------------------------------
00277 //
00278 // _WndProc
00279 //
00280 // Snoop window proc.
00281 //----------------------------------------------------------------------------
00282
00283 /* static */
00284 LRESULT CALLBACK CSnoopWnd::_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00285 {
00286     HDC hdc;
00287     PAINTSTRUCT ps;
00288
00289     switch (uMsg)
00290     {
00291         case WM_CREATE:
00292             _SetThis(hWnd, lParam);
00293             return 0;
00294
00295         case WM_PAINT:
00296             hdc = BeginPaint(hWnd, &ps);
00297             _GetThis(hWnd)->_OnPaint(hWnd, hdc);
00298             EndPaint(hWnd, &ps);
00299             return 0;
00300     }
00301
00302     return DefWindowProc(hWnd, uMsg, wParam, lParam);
00303 }
00304
00305 //+---------------------------------------------------------------------------
00306 //
00307 // _OnPaint
00308 //
00309 // WM_PAINT handler for CSnoopWnd.
00310 //----------------------------------------------------------------------------
00311
00312 void CSnoopWnd::_OnPaint(HWND hWnd, HDC hdc)
00313 {
00314     RECT rc;
00315
00316     // background
00317     GetClientRect(hWnd, &rc);
00318     FillRect(hdc, &rc, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
00319
00320     // text
00321     TextOutW(hdc, 0, 0, _achText, _cchText);
00322 }
00323
00324 //+---------------------------------------------------------------------------
00325 //
00326 // _InitSnoopWnd
00327 //
00328 // Create and init the snoop window.
00329 //----------------------------------------------------------------------------
00330
00331 BOOL CCaseTextService::_InitSnoopWnd()
00332 {
00333     BOOL fThreadfocus;
00334     ITfSource *pSource = NULL;
00335
00336     // create a snoop window
00337
00338     if ((_pSnoopWnd = new CSnoopWnd(this)) == NULL)
00339         return FALSE;
00340
00341     if (!_pSnoopWnd->_Init())
00342         goto ExitError;
00343
00344     // we also need a thread focus sink
00345
00346     if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) != S_OK)
00347     {
00348         pSource = NULL;
00349         goto ExitError;
00350     }
00351
00352     if (pSource->AdviseSink(IID_ITfThreadFocusSink, (ITfThreadFocusSink *)this, &_dwThreadFocusSinkCookie) != S_OK)
00353     {
00354         // make sure we don't try to Unadvise _dwThreadFocusSinkCookie later
00355         _dwThreadFocusSinkCookie = TF_INVALID_COOKIE;
00356         goto ExitError;
00357     }
00358
00359     pSource->Release();
00360
00361     // we may need to display the snoop window right now
00362     // our thread focus sink won't be called until something changes,
00363     // so we need to check the current state.
00364
00365     if (_pThreadMgr->IsThreadFocus(&fThreadfocus) == S_OK && fThreadfocus)
00366     {
00367         OnSetThreadFocus();
00368     }
00369
00370     return TRUE;
00371
00372 ExitError:
00373     SafeRelease(pSource);
00374     _UninitSnoopWnd();
00375     return FALSE;
00376 }
00377
00378 //+---------------------------------------------------------------------------
00379 //
00380 // _UninitSnoopWnd
00381 //
00382 // Uninit and free the snoop window, unadvise the thread focus sink.
00383 //----------------------------------------------------------------------------
00384
00385 void CCaseTextService::_UninitSnoopWnd()
00386 {
00387     ITfSource *pSource;
00388
00389     if (_pSnoopWnd != NULL)
00390     {
00391         _pSnoopWnd->_Uninit();
00392         delete _pSnoopWnd;
00393     }
00394
00395     if (_dwThreadFocusSinkCookie != TF_INVALID_COOKIE)
00396     {
00397         if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK)
00398         {
00399             pSource->UnadviseSink(_dwThreadFocusSinkCookie);
00400             pSource->Release();
00401         }
00402
00403         _dwThreadFocusSinkCookie = TF_INVALID_COOKIE;
00404     }
00405 }
00406
00407 //+---------------------------------------------------------------------------
00408 //
00409 // _Menu_ShowSnoopWnd
00410 //
00411 // Show or hide the snoop window.
00412 //----------------------------------------------------------------------------
00413
00414 void CCaseTextService::_Menu_ShowSnoopWnd(CCaseTextService *_this)
00415 {
00416     _this->_fShowSnoop = !_this->_fShowSnoop;
00417
00418     if (_this->_fShowSnoop)
00419     {
00420         _this->_pSnoopWnd->_Show();
00421     }
00422     else
00423     {
00424         _this->_pSnoopWnd->_Hide();
00425     }
00426 }
00427
00428 //+---------------------------------------------------------------------------
00429 //
00430 // OnSetThreadFocus
00431 //
00432 // Called by the system when the thread/appartment of this text service gains
00433 // the ui focus.
00434 //----------------------------------------------------------------------------
00435
00436 STDAPI CCaseTextService::OnSetThreadFocus()
00437 {
00438     if (_fShowSnoop)
00439     {
00440         _pSnoopWnd->_Show();
00441     }
00442
00443     return S_OK;
00444 }
00445
00446 //+---------------------------------------------------------------------------
00447 //
00448 // OnKillThreadFocus
00449 //
00450 // Called by the system when the thread/appartment of this text service loses
00451 // the ui focus.
00452 //----------------------------------------------------------------------------
00453
00454 STDAPI CCaseTextService::OnKillThreadFocus()
00455 {
00456     // only show our snoop window when our thread has the focus.
00457     if (_fShowSnoop)
00458     {
00459         _pSnoopWnd->_Hide();
00460     }
00461
00462     return S_OK;
00463 }
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTextElement Member List

This is the complete list of members for CTextElement, including all inherited members.
_aTempBuffer | CHtmlElement | [protected]
_cTextChars | CTextElement | [private]
_eTokTypeNext | CTextElement | [private]
_fNoMoreText | CTextElement | [private]
_htmlIFilter | CHtmlElement | [protected]
_idChunk | CTextElement | [private]
_scanner | CHtmlElement | [protected]
_serialStream | CHtmlElement | [protected]
CHtmlElement(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CHtmlElement |
CTextElement(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CTextElement |
GetChunk(STAT_CHUNK *pStat) | CTextElement | [virtual]
GetText(ULONG *pcwcBuffer, WCHAR *awcBuffer) | CTextElement | [virtual]
GetValue(PROPVARIANT **ppPropValue) | CHtmlElement | [virtual]
InitFilterRegion(ULONG &idChunkSource, ULONG &cwcStartSource, ULONG &cwcLenSource) | CTextElement | [virtual]
InitStatChunk(STAT_CHUNK *pStat) | CTextElement | [virtual]
SkipRemainingTextAndGotoNextChunk(STAT_CHUNK *pStat) | CHtmlElement | [protected]
SwitchToNextHtmlElement(STAT_CHUNK *pStat) | CHtmlElement | [protected]
~CHtmlElement() | CHtmlElement | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletRegistryEntryOwner Member List

This is the complete list of members for tagAppletRegistryEntryOwner, including all inherited members.
fEntryOwned | tagAppletRegistryEntryOwner
nOwnerEntityID | tagAppletRegistryEntryOwner
nOwnerNodeID | tagAppletRegistryEntryOwner
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/common.h Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

common.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Server System Service
00006
00007     FILE: common.h
00008
00009     PURPOSE: Provides common file replication service declarations.
00010
00011 */
00012
00013 #pragma once
00014
00015 #include <tchar.h>
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018
00019 #include <windows.h>
00020
00021 #ifdef DEBUG1
00022 #define ASSERT(cond) {if ((cond)==0){_tprintf(TEXT("Assertion \"cond\" failed.\n")); *((int *)0)=0;};}
00023 #else
00024 #define ASSERT(cond) {}
00025 #endif
00026
00027 // Macro for printing out error message and exiting the program if an
00028 // error occured during an RPC library call.
00029 #define EXIT_IF_FAIL(x, string){ \
00030         ((x) != RPC_S_OK) ? _tprintf(TEXT("%s failed with error %d\n"), \
00031         TEXT(string), (x)), exit(EXIT_FAILURE) : 0;}
00032
00033 #define RPC_EEINFO_EXIT_IF_FAIL(x, string){ \
00034         ((x) != RPC_S_OK) ? PrintProcFailureEEInfo(string, x), \
00035         exit(EXIT_FAILURE) : 0;}
00036
00037 //
00038 // Pipe Routine Pointer Types
00039 //
00040 typedef RPC_STATUS (__stdcall *WINAPI_MY_PIPE_PUSH)(
00041                                   CHAR *state,
00042                                   CHAR *buf,
00043                                   unsigned long ecount);
00044
00045 typedef RPC_STATUS (__stdcall *WINAPI_MY_PIPE_PULL)(CHAR *state,
00046               CHAR *buf,
00047               unsigned long num,
00048               unsigned long * ecount);
00049
00050 // Size for short message strings.
00051 #define MSG_SIZE (256)
00052
00053 VOID GetEEInfoText(TCHAR *Msg, UINT BuffSize, UINT *MsgSize);
00054
00055 VOID PrintProcFailureEEInfo(LPTSTR ProcName, DWORD ErrCode);
00056
00057 VOID * AutoHeapAlloc(size_t dwBytes);
00058
00059 VOID AutoHeapFree(VOID * lpMem);
00060
00061 #define CriticalSectionOwned(CriticalSection) (ULongToPtr(GetCurrentThreadId()) == (CriticalSection)->OwningThread)
00062
00063
00064 // end common.h
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/PMMStrm.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

PMMStrm.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       pmmstrm.hxx
00006 //
00007 //  Contents:   Memory Mapped Stream protocol
00008 //
00009 //  Classes:    PMmStream
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #if !defined __PMMSTRM_HXX__
00014 #define __PMMSTRM_HXX__
00015
00016 //
00017 //  64K common page size for memory mapped streams
00018 //
00019
00020 const ULONG COMMON_PAGE_SIZE = 0x10000L;
00021
00022 //+-------------------------------------------------------------------------
00023 //
00024 //  Function:   CommonPageRound, public
00025 //
00026 //  Synopsis:   Round number up to multiple of common page size
00027 //
00028 //  Arguments:  [cb] - number
00029 //
00030 //--------------------------------------------------------------------------
00031
00032 inline ULONG CommonPageRound ( ULONG cb )
00033 {
00034     return ( cb + (COMMON_PAGE_SIZE-1) ) & ~(COMMON_PAGE_SIZE-1);
00035 }
00036
00037 inline ULONG CommonPageTrunc ( ULONG cb )
00038 {
00039     return( cb & ~(COMMON_PAGE_SIZE-1));
00040 }
00041
00042 //+-------------------------------------------------------------------------
00043 //
00044 //  Function:   CommonPageRound, public
00045 //
00046 //  Synopsis:   Round number up to multiple of common page size
00047 //
00048 //  Arguments:  [cbLow] - low part of the number
00049 //              [cbHigh] - high part
00050 //
00051 //--------------------------------------------------------------------------
00052
00053 inline void CommonPageRound ( ULONG& cbLow, ULONG& cbHigh )
00054 {
00055     if (cbLow > ((0xffffffff & ~(COMMON_PAGE_SIZE-1)) + 1))
00056     {
00057         cbLow = 0;
00058         cbHigh++;
00059     }
00060     else
00061     {
00062         cbLow = (cbLow + (COMMON_PAGE_SIZE-1) ) & ~(COMMON_PAGE_SIZE-1);
00063     }
00064 }
00065
00066 inline
00067 LONGLONG
00068 llfromuls(
00069     IN const ULONG &ulLowPart,
00070     IN const ULONG &ulHighPart
00071     )
00072 {
00073     LARGE_INTEGER li = {ulLowPart, ulHighPart};
00074     return li.QuadPart;
00075
00076 }
00077
00078 class CMmStreamBuf;
00079 class PStorage;
00080 class CMemBuf;
00081
00082 //+---------------------------------------------------------------------------
00083 //
00084 //  Class:      PMmStream
00085 //
00086 //  Purpose:    Memory Mapped Stream protocol
00087 //
00088 //----------------------------------------------------------------------------
00089
00090 class PMmStream
00091 {
00092 public:
00093     virtual ~PMmStream() {}
00094
00095     virtual BOOL Ok() = 0;
00096
00097     virtual void   Close() = 0;
00098
00099     virtual void   SetSize ( PStorage& storage,
00100                              ULONG newSizeLow,
00101                              ULONG newSizeHigh=0 ) = 0;
00102
00103     virtual BOOL   isEmpty() = 0;
00104
00105     virtual LONGLONG Size() const = 0;
00106
00107     virtual ULONG  SizeLow()=0;
00108
00109     virtual ULONG  SizeHigh()=0;
00110
00111     virtual BOOL   isWritable()=0;
00112
00113     virtual void   MapAll ( CMmStreamBuf& sbuf ) = 0;
00114
00115     virtual void   Map ( CMmStreamBuf& sbuf,
00116                          ULONG cb = 0,
00117                          ULONG offLow = 0,
00118                          ULONG offHigh = 0,
00119                          BOOL  fMapForWrite = FALSE ) = 0;
00120
00121     virtual void   Unmap ( CMmStreamBuf& sbuf ) = 0;
00122
00123     virtual void   Flush ( CMmStreamBuf& sbuf, ULONG cb ) = 0;
00124
00125     virtual void   Flush() {}
00126
00127     virtual ULONG  ShrinkFromFront( ULONG firstPage, ULONG numPages ) { return 0; }
00128
00129 };
00130
00131 // Safe pointer to memory mapped stream
00132
00133 class SMmStream
00134 {
00135 public:
00136     SMmStream ( PMmStream* pStream ): _pStream(pStream)
00137     {
00138     }
00139     ~SMmStream();
00140     PMmStream* operator->() { return _pStream; }
00141     PMmStream& operator * () { return *_pStream; }
00142     BOOL operator! () { return _pStream == 0; }
00143
00144     PMmStream* Acquire ()
00145     {
00146         PMmStream* pStream = _pStream;
00147         _pStream = 0;
00148         return(pStream);
00149     }
00150
00151     void Set( PMmStream * pStream )
00152     {
00153         Win4Assert( 0 == _pStream );
00154         _pStream = pStream;
00155     }
00156
00157 private:
00158
00159     PMmStream* _pStream;
00160 };
00161
00162 //+---------------------------------------------------------------------------
00163 //
00164 //  Class:      CMmStreamBuf
00165 //
00166 //  Purpose:    Memory Mapped Stream Buffer
00167 //
00168 //----------------------------------------------------------------------------
00169 class CMmStreamBuf
00170 {
00171
00172 public:
00173
00174     CMmStreamBuf();
00175
00176     ~CMmStreamBuf();
00177
00178     void * Get() { return (void *)_buf; }
00179
00180     ULONG  Size() const { return _cb; }
00181
00182     void   SetSize( ULONG cb) { _cb = cb; }
00183
00184     void   SetBuf( void* buf ) { _buf = (BYTE *) buf; }
00185
00186     void   SetStream ( PMmStream* pStream ) { _pStream = pStream; }
00187
00188
00189 private:
00190
00191     BYTE*       _buf;
00192
00193     ULONG       _cb;
00194
00195     PMmStream*  _pStream;
00196 };
00197
00198 inline CMmStreamBuf::CMmStreamBuf() : _buf(0), _cb(0), _pStream(0)
00199 {
00200 }
00201
00202 #endif
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/utils.cpp Source File

  • Web
  • NetMeeting
  • PlugTransport

utils.cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     PLUGTRANSPORT.EXE
00003 //  File:       UTILS.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #include "precomp.h"
00017
00018
00019 //****************************************************************************
00020 //
00021 // CLASS RefCount
00022 //
00023 //****************************************************************************
00024
00025 //****************************************************************************
00026 //
00027 //    FUNCTION:   RefCount::RefCount(void)
00028 //
00029 //    PURPOSE:    Construction
00030
00031 //    COMMENTS:
00032 //
00033 //
00034 //
00035 //
00036 //
00037 //****************************************************************************
00038
00039 RefCount::RefCount(void)
00040 {
00041     m_cRef = 1;
00042 }
00043
00044
00045 //****************************************************************************
00046 //
00047 //    FUNCTION:   RefCount::~RefCount(void)
00048 //
00049 //    PURPOSE:    Destruction
00050
00051 //    COMMENTS:
00052 //
00053 //
00054 //****************************************************************************
00055
00056 RefCount::~RefCount(void)
00057 {}
00058
00059
00060 //****************************************************************************
00061 //
00062 //    FUNCTION:   ULONG STDMETHODCALLTYPE RefCount::AddRef(void)
00063 //
00064 //    PURPOSE:    Implementetion of AddRef
00065
00066 //    COMMENTS:
00067 //
00068 //
00069 //****************************************************************************
00070
00071 ULONG STDMETHODCALLTYPE RefCount::AddRef(void)
00072 {
00073     ASSERT(m_cRef >= 0);
00074
00075     InterlockedIncrement(&m_cRef);
00076
00077     return (ULONG) m_cRef;
00078 }
00079
00080
00081 //****************************************************************************
00082 //
00083 //    FUNCTION:   ULONG STDMETHODCALLTYPE RefCount::Release(void)
00084 //
00085 //    PURPOSE:    Implementation of Release
00086
00087 //    COMMENTS:
00088 //
00089 //
00090 //****************************************************************************
00091
00092 ULONG STDMETHODCALLTYPE RefCount::Release(void)
00093 {
00094     if (0 == InterlockedDecrement(&m_cRef))
00095     {
00096         delete this;
00097         return 0;
00098     }
00099
00100     ASSERT(m_cRef > 0);
00101     return (ULONG) m_cRef;
00102 }
00103
00104
00105 //****************************************************************************
00106 //
00107 // CLASS CNotify
00108 //
00109 //****************************************************************************
00110
00111 //****************************************************************************
00112 //
00113 //    FUNCTION:   CNotify::CNotify()
00114 //
00115 //    PURPOSE:
00116
00117 //    COMMENTS:
00118 //
00119 //
00120 //****************************************************************************
00121
00122 CNotify::CNotify() :
00123     m_pcnpcnt(NULL),
00124     m_pcnp(NULL),
00125     m_dwCookie(0),
00126     m_pUnk(NULL)
00127 {}
00128
00129
00130 //****************************************************************************
00131 //
00132 //    FUNCTION:   CNotify::~CNotify()
00133 //
00134 //    PURPOSE:
00135
00136 //    COMMENTS:
00137 //
00138 //
00139 //****************************************************************************
00140
00141 CNotify::~CNotify()
00142 {
00143     Disconnect(); // Make sure we're disconnected
00144 }
00145
00146
00147 //****************************************************************************
00148 //
00149 //    FUNCTION:   HRESULT CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN)
00150 //
00151 //    PURPOSE:
00152
00153 //    COMMENTS:
00154 //
00155 //
00156 //****************************************************************************
00157
00158 HRESULT CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN)
00159 {
00160     HRESULT hr;
00161
00162     ASSERT(0 == m_dwCookie);
00163     ASSERT(NULL == m_pcnpcnt);
00164     ASSERT(NULL == m_pcnp);
00165     ASSERT(NULL == m_pUnk);
00166
00167     if (NULL == pUnk)
00168         return E_POINTER;
00169
00170     if (NULL == pUnkN)
00171         return E_POINTER;
00172
00173     // Get the connection container
00174     hr = pUnk->QueryInterface(IID_IConnectionPointContainer, (void **)&m_pcnpcnt);
00175     if (SUCCEEDED(hr))
00176     {
00177         // Find an appropriate connection point
00178         hr = m_pcnpcnt->FindConnectionPoint(riid, &m_pcnp);
00179         if (SUCCEEDED(hr))
00180         {
00181             ASSERT(NULL != m_pcnp);
00182             // Connect the sink object
00183             hr = m_pcnp->Advise((IUnknown *)pUnkN, &m_dwCookie);
00184         }
00185     }
00186
00187     if (FAILED(hr))
00188     {
00189         m_dwCookie = 0;
00190     }
00191     else
00192     {
00193         m_pUnk = pUnk; // keep around for caller
00194         m_pUnk->AddRef();
00195     }
00196
00197     return hr;
00198 }
00199
00200
00201 //****************************************************************************
00202 //
00203 //    FUNCTION:   HRESULT CNotify::Disconnect (void)
00204 //
00205 //    PURPOSE:
00206
00207 //    COMMENTS:
00208 //
00209 //
00210 //****************************************************************************
00211
00212 HRESULT CNotify::Disconnect (void)
00213 {
00214     if (0 != m_dwCookie)
00215     {
00216
00217         // Disconnect the sink object
00218         m_pcnp->Unadvise(m_dwCookie);
00219         m_dwCookie = 0;
00220
00221         m_pcnp->Release();
00222         m_pcnp = NULL;
00223
00224         m_pcnpcnt->Release();
00225         m_pcnpcnt = NULL;
00226
00227         m_pUnk->Release();
00228         m_pUnk = NULL;
00229     }
00230
00231     return S_OK;
00232 }
00233
00234
00235 /*****************************************************/
00236 //  BSTR to LPSTR converison functions
00237 /*********************************************************/
00238
00239 //****************************************************************************
00240 //
00241 //    FUNCTION:   BSTR LPSTR2BSTR(LPSTR pszString)
00242 //
00243 //    PURPOSE:    Converts a string to BSTR
00244
00245 //    COMMENTS:
00246 //
00247 //
00248 //****************************************************************************
00249
00250 BSTR LPSTR2BSTR(LPSTR pszString)
00251 {
00252     WCHAR wszConnID[CONNIDMAXLENGTH];
00253
00254     if (::MultiByteToWideChar(CP_ACP, 0, pszString, -1, wszConnID, CONNIDMAXLENGTH))
00255     {
00256         return ::SysAllocString(wszConnID);
00257     }
00258
00259     return NULL;
00260 }
00261
00262
00263 //****************************************************************************
00264 //
00265 //    FUNCTION:   BOOL BSTR2LPSTR(BSTR bstrConnID, LPSTR pszConnID)
00266 //
00267 //    PURPOSE:    Converts a BSTR to a string
00268
00269 //    COMMENTS:
00270 //
00271 //
00272 //****************************************************************************
00273
00274 BOOL BSTR2LPSTR(BSTR bstrConnID, LPSTR pszConnID)
00275 {
00276     *pszConnID = '\0';
00277     return ::WideCharToMultiByte(CP_ACP, 0, bstrConnID, -1, pszConnID, CONNIDMAXLENGTH, NULL, NULL);
00278 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/repas/Repassu.c Source File

  • NetDS
  • RPC
  • Data
  • repas

Repassu.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         repas Example
00005
00006     FILE:       repassu.c
00007
00008     PURPOSE:    Utility functions used by client side of the RPC
00009                 distributed application.
00010                 This sample demonstrates the represent_as attribute.
00011
00012     RELATED:    repass.c - server main
00013                 repasp.c - remote procedures
00014                 repasc.c - client main
00015
00016     FUNCTIONS:  CHAR_STRING_to_local    - convert CHAR_STRING to WCHAR_STRING
00017                 CHAR_STRING_from_local  - convert CHAR_STRING from WCHAR_STRING
00018                 CHAR_STRING_free_inst   - free CHAR_STRING memory
00019                 CHAR_STRING_free_local  - free WCHAR_STRING memory
00020                 midl_user_allocate - user-supplied memory allocator
00021                 midl_user_free - user-supplied routine to free memory
00022
00023
00024     COMMENTS:   This sample program generates a client and server can share
00025                 an interface, but one side can use a different representation
00026                 than the other.
00027
00028                 The client side in this example does all operations using
00029                 character strings, and the server side does all operations
00030                 using UNICODE strings.  Two procedures are provided, one
00031                 defined with ASCII strings, one with UNICODE strings.
00032                 The wire format reflects these definitions, yet the client
00033                 and server see pure ASCII and pure UNICODE respectively.
00034
00035                 The [represent_as] attribute (used in the client and server
00036                 side acf files) requires the four user-supplied functions
00037                 whose names start with the name of the transmitted type
00038                 (in the server side's case: CHAR_STRING)
00039
00040                 The [in, out] attributes applied to remote procedure
00041                 parameters require the two user-supplied functions
00042                 midl_user_allocate and midl_user_free.
00043
00044                 The other functions are utilities that are used to
00045                 build or display the data structures.
00046
00047 ****************************************************************************/
00048
00049 #include <stdlib.h>
00050 #include <stdio.h>
00051 #include "repass.h"    // header file generated by MIDL compiler for client
00052
00053
00054
00055 /*
00056  Description:   Allocates memory for the transmitted type and converts from
00057                 local type to the transmitted type
00058
00059  Arguments:
00060     pLocal:     pointer to local type
00061     ppWire:     pointer to the transmitted type pointer. This function should
00062                 allocate memory for the transmitted data type.
00063
00064  Return Value:  None.
00065 */
00066 void __RPC_USER
00067 CHAR_STRING_from_local(
00068     WCHAR_STRING __RPC_FAR * pLocal,
00069     CHAR_STRING __RPC_FAR * __RPC_FAR * ppWire )
00070 {
00071     CHAR_STRING    *   pWireString;
00072
00073     pWireString = midl_user_allocate( sizeof( CHAR_STRING ) );
00074
00075     *ppWire = pWireString;
00076
00077     wcstombs( *pWireString, *pLocal, STRING_SIZE );
00078 }
00079
00080 /*
00081  Description:   Converts from transmitted type to local type.
00082                 Memory for the local type has already been allocated by
00083                 the stubs.
00084
00085  Arguments:
00086     pWire :     pointer to transmitted type
00087     pLocal:     pointer to local type
00088
00089  Return Value:  None.
00090 */
00091 void __RPC_USER
00092 CHAR_STRING_to_local(
00093     CHAR_STRING __RPC_FAR * pWire,
00094     WCHAR_STRING __RPC_FAR * pLocal )
00095 {
00096     mbstowcs( *pLocal, *pWire, STRING_SIZE );
00097 }
00098
00099
00100 /*
00101  Description:   Frees the memory allocated for the transmitted type.This
00102                 includes the embedded pointers (if any).
00103
00104  Arguments:
00105     pWire:      pointer to the transmitted type
00106
00107  Return Value:  None
00108  */
00109 void __RPC_USER
00110 CHAR_STRING_free_inst(
00111     CHAR_STRING __RPC_FAR * pWire)
00112 {
00113     midl_user_free( pWire );
00114 }
00115
00116
00117 /*
00118  Descripton:    Frees embedded pointers in the local type(if any).
00119                 Do not free the type itself
00120
00121  Arguments:
00122     pLocal:     pointer to the local type
00123
00124  Return Value:  None
00125  */
00126 void __RPC_USER
00127 CHAR_STRING_free_local(
00128     WCHAR_STRING __RPC_FAR * pLocal)
00129 {
00130      /* As there are no embedded pointers in the
00131      * local type. So nothing to free
00132      */
00133
00134      return;
00135 }
00136
00137 /***************************************************************************/
00138
00139 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00140 {
00141     return(malloc(len));
00142 }
00143
00144 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00145 {
00146     free(ptr);
00147 }
00148
00149
00150 /***************************************************************************/
00151
00152 /* end file repassu.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ColumnProvider/columnprovider.h Source File

  • WinUI
  • Shell
  • ColumnProvider

columnprovider.h

Go to the documentation of this file.
00001 // ColumnProvider.h: interface for the CColumnProvider class.
00002 //
00003 //////////////////////////////////////////////////////////////////////
00004
00005 #if !defined(AFX_COLUMNPROVIDER_H__01039060_03F3_11D3_B1BF_00600893AD51__INCLUDED_)
00006 #define AFX_COLUMNPROVIDER_H__01039060_03F3_11D3_B1BF_00600893AD51__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 class CColumnProvider : public IColumnProvider
00013 {
00014 public:
00015     CColumnProvider();
00016     virtual ~CColumnProvider();
00017
00018     // IUnknown methods
00019     STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObject);
00020     STDMETHODIMP_(ULONG) AddRef();
00021     STDMETHODIMP_(ULONG) Release();
00022
00023     // IColumnProvider methods
00024     STDMETHODIMP Initialize (LPCSHCOLUMNINIT psci);
00025     STDMETHODIMP GetColumnInfo (DWORD dwIndex, LPSHCOLUMNINFO psci);
00026     STDMETHODIMP GetItemData (LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvartData);
00027
00028 private:
00029     ULONG m_nRefCount;
00030 };
00031
00032 #endif // !defined(AFX_COLUMNPROVIDER_H__01039060_03F3_11D3_B1BF_00600893AD51__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/comp.Cpp Source File

  • SysMgmt
  • MMC
  • CutCopy

comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "CompData.h"
00021 #include "Space.h"
00022 #include "DataObj.h"
00023 #include <commctrl.h>        // Needed for button styles...
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "DeleBase.h"
00028 #include "CompData.h"
00029
00030 CComponent::CComponent(CComponentData *pParent)
00031 : m_pParent(pParent), m_cref(0), m_ipConsole(NULL), m_pLastNode(NULL)
00032 {
00033     OBJECT_CREATED
00034 }
00035
00036 CComponent::~CComponent()
00037 {
00038     OBJECT_DESTROYED
00039 }
00040
00041 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00042 {
00043     if (!ppv)
00044         return E_FAIL;
00045
00046     *ppv = NULL;
00047
00048     if (IsEqualIID(riid, IID_IUnknown))
00049         *ppv = static_cast<IComponent *>(this);
00050     else if (IsEqualIID(riid, IID_IComponent))
00051         *ppv = static_cast<IComponent *>(this);
00052     else if (IsEqualIID(riid, IID_IResultOwnerData))
00053         *ppv = static_cast<IResultOwnerData *>(this);
00054
00055     if (*ppv)
00056     {
00057         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00058         return S_OK;
00059     }
00060
00061     return E_NOINTERFACE;
00062 }
00063
00064 STDMETHODIMP_(ULONG) CComponent::AddRef()
00065 {
00066     return InterlockedIncrement((LONG *)&m_cref);
00067 }
00068
00069 STDMETHODIMP_(ULONG) CComponent::Release()
00070 {
00071     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00072     {
00073         delete this;
00074         return 0;
00075     }
00076     return m_cref;
00077
00078 }
00079
00080 ///////////////////////////////
00081 // Interface IComponent
00082 ///////////////////////////////
00083 STDMETHODIMP CComponent::Initialize(
00084                                    /* [in] */ LPCONSOLE lpConsole)
00085 {
00086     HRESULT hr = S_OK;
00087
00088     // Save away all the interfaces we'll need.
00089     // Fail if we can't QI the required interfaces.
00090
00091     m_ipConsole = lpConsole;
00092     m_ipConsole->AddRef();
00093
00094     return hr;
00095 }
00096
00097 STDMETHODIMP CComponent::Notify(
00098                                /* [in] */ LPDATAOBJECT lpDataObject,
00099                                /* [in] */ MMC_NOTIFY_TYPE event,
00100                                /* [in] */ LPARAM arg,
00101                                /* [in] */ LPARAM param)
00102 {
00103     MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00104
00105   //Return S_FALSE for any unhandled notifications. MMC then
00106   //performs a default operation for the particular notification
00107     HRESULT hr = S_FALSE;
00108
00109
00110     // MMCN_VIEW_CHANGE and MMCN_CUTORMOVE
00111
00112     static CDelegationBase *pLastPasteQuery = NULL;
00113
00114     if (MMCN_VIEW_CHANGE == event)
00115     {
00116         switch (param)
00117         {//arg holds the data. For a scope item, this is the
00118          //item's HSCOPEITEM. For a result item, this is
00119          //the item's nId value, but we don't use it
00120
00121          //param holds the hint passed to IConsole::UpdateAllViews.
00122          //hint is a value of the UPDATE_VIEWS_HINT enumeration
00123
00124         case UPDATE_SCOPEITEM:
00125             hr = m_ipConsole->SelectScopeItem( (HSCOPEITEM)arg );
00126             _ASSERT( S_OK == hr);
00127             break;
00128         case UPDATE_RESULTITEM:
00129             CDelegationBase *base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00130             hr = base->OnUpdateItem(m_ipConsole, (long)arg, RESULT);
00131             break;
00132         }
00133
00134         return S_OK;
00135     }
00136
00137     if (MMCN_CUTORMOVE == event && pLastPasteQuery != NULL)
00138     {
00139         //arg contains the data object of the cut object
00140         //we get its CDelegationBase and then cast it
00141         //to its proper type.
00142         CDelegationBase *base = GetOurDataObject( (LPDATAOBJECT)arg )->GetBaseNodeObject();
00143         CRocket *pRocket = dynamic_cast<CRocket *>(base);
00144
00145         if (NULL == pRocket)
00146         {// The cut item is a scope item. Delete it.
00147             CSpaceStation* pSpaceStn = dynamic_cast<CSpaceStation*>(base);
00148             if (NULL != pSpaceStn)
00149             {
00150         hr = pSpaceStn->OnDeleteScopeItem(m_pParent->GetConsoleNameSpace());
00151
00152                 return hr;
00153             }
00154         }
00155
00156     //The cut item is a result item. Set its isDeleted member to TRUE.
00157     //This tells the source scope item that the object no longer
00158         //needs to be inserted in its result pane
00159         pRocket->setDeletedStatus(TRUE);
00160
00161         //Update the source scope item in all views. We need
00162         //a dummy data object for UpdateAllViews.
00163         //pLastPasteQuery is the lpDataObject of the source scope item
00164         //See MMCN_SHOW below
00165         IDataObject *pDummy = NULL;
00166         hr = m_pParent->m_ipConsole->UpdateAllViews(pDummy, (long)(pLastPasteQuery->GetHandle()), UPDATE_SCOPEITEM);
00167         _ASSERT( S_OK == hr);
00168
00169         return S_OK;
00170     }
00171
00172     //Remaining notifications
00173
00174   //Get our data object. If it is NULL, we return with S_FALSE.
00175   //See implementation of GetOurDataObject() to see how to
00176   //handle special data objects.
00177   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00178   if (NULL == pDataObject)
00179     return S_FALSE;
00180
00181   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00182
00183     switch (event)
00184     {
00185     case MMCN_SHOW:
00186         if (arg)
00187         {//scope item selected
00188             OutputDebugString(_T("Changing selected scope node\n"));
00189             //We use this for drag-and-drop operations.
00190             pLastPasteQuery = base;
00191         }
00192         hr = base->OnShow(m_ipConsole, (BOOL)arg, (HSCOPEITEM)param);
00193         break;
00194
00195     case MMCN_ADD_IMAGES:
00196         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00197         break;
00198
00199     case MMCN_SELECT:
00200         hr = base->OnSelect(m_ipConsole, (BOOL)LOWORD(arg), (BOOL)HIWORD(arg));
00201         break;
00202
00203     case MMCN_REFRESH:
00204         hr = base->OnRefresh(m_pParent->m_ipConsole);
00205         break;
00206
00207     case MMCN_DELETE:
00208         //first delete the selected result item
00209         hr = base->OnDelete(m_ipConsole);
00210
00211         //Now call IConsole::UpdateAllViews to redraw all views
00212         //owned by the parent scope item. OnRefresh already does
00213         //this for us, so use it.
00214         hr = base->OnRefresh(m_pParent->m_ipConsole);
00215         break;
00216
00217     case MMCN_RENAME:
00218         hr = base->OnRename((LPOLESTR)param);
00219
00220         //Now call IConsole::UpdateAllViews to redraw the item in all views.
00221         hr = m_pParent->m_ipConsole->UpdateAllViews(lpDataObject, 0, UPDATE_RESULTITEM);
00222         _ASSERT( S_OK == hr);
00223
00224         break;
00225
00226
00227     case MMCN_QUERY_PASTE:
00228         {
00229             CDataObject *pPastedDO = GetOurDataObject((IDataObject *)arg);
00230             if (pPastedDO != NULL)
00231             {
00232                 CDelegationBase *pasted = pPastedDO->GetBaseNodeObject();
00233
00234                 if (pasted != NULL)
00235                 {
00236                     hr = base->OnQueryPaste(pasted);
00237                 }
00238             }
00239         }
00240         break;
00241
00242     case MMCN_PASTE:
00243         {
00244             CDataObject *pPastedDO = GetOurDataObject((IDataObject *)arg);
00245             if (pPastedDO != NULL)
00246             {
00247                 CDelegationBase *pasted = pPastedDO->GetBaseNodeObject();
00248
00249                 if (pasted != NULL)
00250                 {
00251                     hr = base->OnPaste(m_ipConsole, m_pParent, pasted);
00252
00253                     if (SUCCEEDED(hr))
00254                     {
00255                         // Determine if the item to be pasted is scope or result item.
00256                         CRocket* pRocket = dynamic_cast<CRocket*>(pasted);
00257                         BOOL bResult = pRocket ? TRUE : FALSE;     // Rocket item is result item.
00258
00259                         CDataObject *pObj = new CDataObject((MMC_COOKIE)pasted, bResult ? CCT_RESULT : CCT_SCOPE);
00260
00261                         if (!pObj)
00262                             return E_OUTOFMEMORY;
00263
00264                         pObj->QueryInterface(IID_IDataObject, (void **)param);
00265
00266                         //now update the destination scope item in all views.
00267                         //But only do this if this is not a drag-and-drop
00268                         //operation. That is, the destination scope item
00269                         //is the currently selected one.
00270
00271                         if (pLastPasteQuery != NULL && pLastPasteQuery == base)
00272                         {
00273                             IDataObject *pDummy = NULL;
00274                             hr = m_pParent->m_ipConsole->UpdateAllViews(pDummy,
00275                                                                         (long)(pLastPasteQuery->GetHandle()), UPDATE_SCOPEITEM);
00276                             _ASSERT( S_OK == hr);
00277                         }
00278                     }
00279                 }
00280             }
00281         }
00282
00283         break;
00284     }
00285
00286     return hr;
00287 }
00288
00289 STDMETHODIMP CComponent::Destroy(
00290                                 /* [in] */ MMC_COOKIE cookie)
00291 {
00292     if (m_ipConsole)
00293     {
00294         m_ipConsole->Release();
00295         m_ipConsole = NULL;
00296     }
00297
00298     return S_OK;
00299 }
00300
00301
00302 STDMETHODIMP CComponent::QueryDataObject(
00303                                         /* [in] */ MMC_COOKIE cookie,
00304                                         /* [in] */ DATA_OBJECT_TYPES type,
00305                                         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00306 {
00307     CDataObject *pObj = NULL;
00308     CDelegationBase *pBase = NULL;
00309
00310     if (IsBadReadPtr((void *)cookie, sizeof(CDelegationBase)))
00311     {
00312         if (NULL == m_pLastNode)
00313             return E_FAIL;
00314
00315         pBase = m_pLastNode->GetChildPtr((int)cookie);
00316     }
00317     else
00318     {
00319         pBase = (cookie == 0) ? m_pParent->m_pStaticNode : (CDelegationBase *)cookie;
00320     }
00321
00322     if (pBase == NULL)
00323         return E_FAIL;
00324
00325     pObj = new CDataObject((MMC_COOKIE)pBase, type);
00326
00327     if (!pObj)
00328         return E_OUTOFMEMORY;
00329
00330     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00331
00332     return S_OK;
00333 }
00334
00335 STDMETHODIMP CComponent::GetResultViewType(
00336                                           /* [in] */ MMC_COOKIE cookie,
00337                                           /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00338                                           /* [out] */ long __RPC_FAR *pViewOptions)
00339 {
00340     CDelegationBase *base = m_pLastNode = (CDelegationBase *)cookie;
00341
00342     //
00343     // Ask for default listview.
00344     //
00345     if (base == NULL)
00346     {
00347         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00348         *ppViewType = NULL;
00349     }
00350     else
00351         return base->GetResultViewType(ppViewType, pViewOptions);
00352
00353     return S_OK;
00354 }
00355
00356 STDMETHODIMP CComponent::GetDisplayInfo(
00357                                        /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00358 {
00359     HRESULT hr = S_OK;
00360     CDelegationBase *base = NULL;
00361
00362     // if they are asking for the RDI_STR we have one of those to give
00363
00364     if (pResultDataItem->lParam)
00365     {
00366         base = (CDelegationBase *)pResultDataItem->lParam;
00367         if (pResultDataItem->mask & RDI_STR)
00368         {
00369             LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00370             MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00371             pResultDataItem->str = pszW;
00372         }
00373
00374         if (pResultDataItem->mask & RDI_IMAGE)
00375         {
00376             pResultDataItem->nImage = base->GetBitmapIndex();
00377         }
00378     }
00379     else
00380     {
00381         m_pLastNode->GetChildColumnInfo(pResultDataItem);
00382     }
00383
00384     return hr;
00385 }
00386
00387
00388 STDMETHODIMP CComponent::CompareObjects(
00389                                        /* [in] */ LPDATAOBJECT lpDataObjectA,
00390                                        /* [in] */ LPDATAOBJECT lpDataObjectB)
00391 {
00392     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00393     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00394
00395     // compare the object pointers
00396     if (baseA->GetCookie() == baseB->GetCookie())
00397         return S_OK;
00398
00399     return S_FALSE;
00400 }
00401
00402 ///////////////////////////////
00403 // Interface IComponent
00404 ///////////////////////////////
00405 STDMETHODIMP CComponent::FindItem(
00406 /* [in] */ LPRESULTFINDINFO pFindInfo,
00407 /* [out] */ int __RPC_FAR *pnFoundIndex)
00408 {
00409     return E_NOTIMPL;
00410 }
00411
00412 STDMETHODIMP CComponent::CacheHint(
00413 /* [in] */ int nStartIndex,
00414 /* [in] */ int nEndIndex)
00415 {
00416     return E_NOTIMPL;
00417 }
00418
00419 STDMETHODIMP CComponent::SortItems(
00420 /* [in] */ int nColumn,
00421 /* [in] */ DWORD dwSortOptions,
00422 /* [in] */ LPARAM lUserParam)
00423 {
00424     return E_NOTIMPL;
00425 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook Server/StringUtils.h Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook Server

StringUtils.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      StringUtils.h
00007 //
00008 //  Description:
00009 //      Declaration of string manipulation routines.
00010 //
00011 //  Author:
00012 //      <name> (<e-mail name>) Mmmm DD, 2003
00013 //
00014 //  Revision History:
00015 //
00016 //  Notes:
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019
00020 #pragma once
00021
00022 #include "ClRes.h"
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // Custom string compare function declarations. Used to replace lstrcmp*
00026 /////////////////////////////////////////////////////////////////////////////
00027
00028 //
00029 // Full string compares.
00030 //
00031
00032 int
00033 IBSTRCompareW(
00034       BSTR  bstrString1In
00035     , BSTR  bstrString2In
00036     );
00037
00038 int
00039 BSTRCompareW(
00040       BSTR  bstrString1In
00041     , BSTR  bstrString2In
00042     );
00043
00044 int
00045 IStringCompareW(
00046       LPCWSTR pcwszString1In
00047     , LPCWSTR pcwszString2In
00048     );
00049
00050 int
00051 StringCompareW(
00052       LPCWSTR pcwszString1In
00053     , LPCWSTR pcwszString2In
00054     );
00055
00056 int
00057 IStringCompareW(
00058       LPCWSTR   pcwszString1In
00059     , size_t    cch1In
00060     , LPCWSTR   pcwszString2In
00061     , size_t    cch2In
00062     );
00063
00064 int
00065 StringCompareW(
00066       LPCWSTR   pcwszString1In
00067     , size_t    cch1In
00068     , LPCWSTR   pcwszString2In
00069     , size_t    cch2In
00070     );
00071
00072 //
00073 // Partial string compares.  They use whichever one's length is shortest
00074 // if both are specified or the NBSTR routines are used.
00075 //
00076
00077 int
00078 NIBSTRCompareW(
00079       BSTR  bstrString1In
00080     , BSTR  bstrString2In
00081     );
00082
00083 int
00084 NBSTRCompareW(
00085       BSTR  bstrString1In
00086     , BSTR  bstrString2In
00087     );
00088
00089 int
00090 NIStringCompareW(
00091       LPCWSTR   pcwszString1In
00092     , LPCWSTR   pcwszString2In
00093     , size_t    cchIn
00094     );
00095
00096 int
00097 NStringCompareW(
00098       LPCWSTR   pcwszString1In
00099     , LPCWSTR   pcwszString2In
00100     , size_t    cchIn
00101     );
00102
00103 int
00104 NIStringCompareW(
00105       LPCWSTR   pcwszString1In
00106     , size_t    cch1In
00107     , LPCWSTR   pcwszString2In
00108     , size_t    cch2In
00109     );
00110
00111 int
00112 NStringCompareW(
00113       LPCWSTR   pcwszString1In
00114     , size_t    cch1In
00115     , LPCWSTR   pcwszString2In
00116     , size_t    cch2In
00117     );
00118
00119
00120 //////////////////////////////////////////////////////////////////////////////
00121 // Load string routines
00122 //////////////////////////////////////////////////////////////////////////////
00123
00124 HRESULT
00125 HrLoadStringIntoBSTR(
00126       HINSTANCE hInstanceIn
00127     , LANGID    langidIn
00128     , UINT      idsIn
00129     , BSTR *    pbstrInout
00130     );
00131
00132 inline
00133 HRESULT
00134 HrLoadStringIntoBSTR(
00135       UINT      idsIn
00136     , BSTR *    pbstrInout
00137     )
00138 {
00139     return HrLoadStringIntoBSTR(
00140                           NULL
00141                         , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00142                         , idsIn
00143                         , pbstrInout
00144                         );
00145 } //*** HrLoadStringIntoBSTR
00146
00147 inline
00148 HRESULT
00149 HrLoadStringIntoBSTR(
00150       HINSTANCE hInstanceIn
00151     , UINT      idsIn
00152     , BSTR *    pbstrInout
00153     )
00154
00155 {
00156     return HrLoadStringIntoBSTR(
00157                           hInstanceIn
00158                         , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00159                         , idsIn
00160                         , pbstrInout
00161                         );
00162
00163 } //*** HrLoadStringIntoBSTR
00164
00165 //////////////////////////////////////////////////////////////////////////////
00166 // Format string ID routines
00167 //////////////////////////////////////////////////////////////////////////////
00168
00169 HRESULT
00170 HrFormatStringIntoBSTR(
00171       HINSTANCE hInstanceIn
00172     , LANGID    langidIn
00173     , UINT      idsIn
00174     , BSTR *    pbstrInout
00175     , ...
00176     );
00177
00178 HRESULT
00179 HrFormatStringWithVAListIntoBSTR(
00180       HINSTANCE hInstanceIn
00181     , LANGID    langidIn
00182     , UINT      idsIn
00183     , BSTR *    pbstrInout
00184     , va_list   valistIn
00185     );
00186
00187 inline
00188 HRESULT
00189 HrFormatStringIntoBSTR(
00190       HINSTANCE hInstanceIn
00191     , UINT      idsIn
00192     , BSTR *    pbstrInout
00193     , ...
00194     )
00195 {
00196     HRESULT hr;
00197     va_list valist;
00198
00199     va_start( valist, pbstrInout );
00200
00201     hr = HrFormatStringWithVAListIntoBSTR(
00202                   hInstanceIn
00203                 , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00204                 , idsIn
00205                 , pbstrInout
00206                 , valist
00207                 );
00208
00209     va_end( valist );
00210
00211     return hr;
00212
00213 } //*** HrFormatStringIntoBSTR
00214
00215 inline
00216 HRESULT
00217 HrFormatStringIntoBSTR(
00218       UINT      idsIn
00219     , BSTR *    pbstrInout
00220     , ...
00221     )
00222 {
00223     HRESULT hr;
00224     va_list valist;
00225
00226     va_start( valist, pbstrInout );
00227
00228     hr = HrFormatStringWithVAListIntoBSTR(
00229                   NULL
00230                 , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00231                 , idsIn
00232                 , pbstrInout
00233                 , valist
00234                 );
00235
00236     va_end( valist );
00237
00238     return hr;
00239
00240 } //*** HrFormatStringIntoBSTR
00241
00242 inline
00243 HRESULT
00244 HrFormatStringWithVAListIntoBSTR(
00245       HINSTANCE hInstanceIn
00246     , UINT      idsIn
00247     , BSTR *    pbstrInout
00248     , va_list   valistIn
00249     )
00250 {
00251     return HrFormatStringWithVAListIntoBSTR(
00252                   hInstanceIn
00253                 , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00254                 , idsIn
00255                 , pbstrInout
00256                 , valistIn
00257                 );
00258
00259 } //*** HrFormatStringWithVAListIntoBSTR
00260
00261 //////////////////////////////////////////////////////////////////////////////
00262 // Format string routines
00263 //////////////////////////////////////////////////////////////////////////////
00264
00265 HRESULT
00266 HrFormatStringIntoBSTR(
00267       LPCWSTR   pcwszFmtIn
00268     , BSTR *    pbstrInout
00269     , ...
00270     );
00271
00272 HRESULT
00273 HrFormatStringWithVAListIntoBSTR(
00274       LPCWSTR   pcwszFmtIn
00275     , BSTR *    pbstrInout
00276     , va_list   valistIn
00277     );
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/sdkdiff.cpp Source File

  • Begin
  • sdkdiff

sdkdiff.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * Sdkdiff
00013  *
00014  * file and directory comparisons.
00015  *
00016  * Compare two directories (including all files and subdirs). Look for names
00017  * that are present in both (report all that are not). For files that
00018  * are present in both, produce a line-by-line comparison of the differences
00019  * between the two files (if any).
00020  *
00021  * Overview of Sdkdiff internals - the whole program.
00022  *
00023  * Sdkdiff is built from several modules (a "module" has a .h file
00024  * which describes its interface and a .c file which implements it)
00025  * Apart from THIS comment which tries to give an overview of the whole
00026  * scheme of things, each module is as self-contained as possible.
00027  * This is enforced by the use of opaque data types.  Modules cannot
00028  * see each others' internal data structures.  Modules are abstract
00029  * data types.  The term "Module" (from Modula2) and "Class" (from C++)
00030  * are used synonymously.
00031  *
00032  *    Sdkdiff  - main program - parse arguments, put up main window,
00033  *               handle input, calling other modules as needed
00034  *               invoke table class to create the main display and
00035  *               service callbacks from the table class.
00036  *               Contains global flags for options (e.g. ignore_blanks)
00037  *    list     - (in gutils) a generalised LIST of anything data type
00038  *               has full set of operations for insert, delete, join etc.
00039  *    line     - a LINE is a numbered line of text.  Information is kept to
00040  *               allow fast comparisons of LINEs.  A LINE can hold a
00041  *               link to another LINE.  The links are used to connect
00042  *               lines in one file to matching lines in the other file.
00043  *    file     - a FILEDATA represents a file as a file name in the form
00044  *               of a DIRITEM and a LIST of LINEs
00045  *    scandir  - a DIRITEM represents information about a file.  (for
00046  *               instance its name, whether it has a known checksum whether
00047  *               it has a local copy).
00048  *               a DIRLIST represents a directory, has information on how to
00049  *               get to it (pipename? password? UNC name etc) and
00050  *               (within an imbedded DIRECT structure) a LIST of DIRITEMs
00051  *               representing the files in the directory and a LIST of
00052  *               DIRECTs representing its subdirectories.
00053  *    compitem - a COMPITEM is a pair of files together with information
00054  *               on how they compare in the form of a breakdown of the
00055  *               files into a LIST of matching or non-matching sections.
00056  *               Either file can be absent.  This module contains the
00057  *               file "contrast" algorithm used for the actual comparison
00058  *               (Algorithm people see ci_compare then talk to Laurie).
00059  *    tree       (in gutils) A binary tree.  Important because it is what
00060  *               gives the file comparison its speed as it makes it
00061  *               an "N log N" algorithm rather than "N squared"
00062  *    complist - a COMPLIST is the master data structure.  It has a DIRLIST
00063  *               of the left hand files, a DIRLIST of the right hand files
00064  *               and a LIST of COMPITEMs. The left and right hand DIRLISTs
00065  *               are working data used to produce the COMPLIST.  The LIST
00066  *               is displayed as the outline table.  Any given COMPITEM can
00067  *               be displayed as an expanded item.
00068  *    section  - a SECTION is a section of a file (first line, last line)
00069  *               and information as to what it matches in the other file.
00070  *    bar.c    - the picture down the left of the screen
00071  *               has a WNDPROC.  There is no bar.h, neither is there much
00072  *               of writeup! ???
00073  *    view     - Although the COMPLIST is the master state, it doesn't do
00074  *               all the work itself.  The data is actually displayed by
00075  *               the table class which is highly generalised.  View
00076  *               owns a COMPLIST (and therefore calls upon the functions
00077  *               in complist to fill it and interrogate it) and calls
00078  *               upon (and is called back by) the functions in table to
00079  *               actually display it.  Read about table in gutils.h
00080  *    table.c    (in gutils) a highly generalised system for displaying
00081  *               data in rows and columns.  The interface is in gutils.h
00082  *               read it if you hope to understand view!
00083  *    status.c   (in gutils) the status line at the top. See gutils.h
00084  *
00085  * The data structures:
00086  * Each "module" owns storage which is an encapsulated data type, inaccessable
00087  * from the outside.  Thus COMPLIST holds a list of COMPITEMs, but they are
00088  * pointers to structures whose definitions are out of scope, thus they are
00089  * "just opaque pointers".  To access anything in the COMPITEM you have to
00090  * call functions in COMPITEM.C.  And so on.  The overall scheme of how they
00091  * link together is below.  Some things are identified by field name, some by
00092  * type name, some both, some abbreviations.  Many connecting arrows omitted.
00093  * Look in the C files for details.
00094  *
00095  * COMPLIST
00096  * > left   -----------> DIRLIST    <--------------------
00097  * > right  -----------> > rootname                       |
00098  * > LIST of items--     > bFile                          |
00099  *                  |    > bSum                           |
00100  *  ----------------     > dot--------> DIRECT     <------+-------------------------
00101  * |                     > server       > relname         |                         |
00102  * |                     > hpipe        > DIRLIST head ---                          |
00103  * |                     > uncname      > DIRECT parent                             |
00104  * |                     > password     > bScanned                                  |
00105  * |                                    > LIST of diritems-----> DIRITEM            |
00106  * |                                    > LIST OF directs     -> > name             |
00107  * |                                    > enum pos           |   > int size         |
00108  * |                                    > DIRECT curdir      |   > int checksum     |
00109  * |                                                         |   > bool sumvalid    |
00110  * |                                                         |   > DIRECT direct ---
00111  * |                                                         |   > localname
00112  *  --->COMPITEM                                             |   > bLocalIsTemp
00113  *      > left-------------------> FILEDATA                  |
00114  *      > right------------------> > DIRITEM-----------------
00115  *      > LIST of CompSecs---      > LIST of lines--> LINE
00116  *      > LIST of LeftSecs---|                    --> > flags
00117  *      > LIST of RightSecs--|                   |    > text
00118  *                           |                   |    > hash
00119  *                           |                   |    > link
00120  *                           |                   |    > linenr
00121  *                            --> SECTION        |
00122  *                                > first--------|
00123  *                                > last---------
00124  *                                > bDiscard
00125  *                                > SECTION link
00126  *                                > SECTION correspond
00127  *                                > int state
00128  *                                > int leftbase
00129  *                                > int rightbase
00130  *
00131  *
00132  *************************************************************************
00133  *
00134  * Overview of THIS file's business:
00135  *
00136  *   we create a table window (gutils.dll) to show the files and the
00137  *   results of their comparisons. We create a COMPLIST object representing
00138  *   a list of files and their differences, and a VIEW object to map between
00139  *   the rows of the table window and the COMPLIST.
00140  *
00141  *   This module is responsible for creating and managing the main window,
00142  *   placing the child windows (table, status window etc) within it, and
00143  *   handling all menu items. We maintain global option flags set by
00144  *   menu commands.
00145  *
00146  *   Creating a COMPLIST creates a list of unmatched files, and of matching
00147  *   files that are compared with each other (these are COMPITEMS).
00148  *   The VIEW provides a mapping between rows on the screen, and items in
00149  *   the COMPLIST.
00150  *
00151  * Something about threads:  (See also thread DOGMA, below)
00152  *
00153  *   The win32 version tries to maintain a responsive user interface by
00154  *   creating worker threads to do long jobs.  This potentially creates
00155  *   conflicts between the threads as they will both want to update common
00156  *   variables (for instance the UI thread may be changing the options to
00157  *   exclude identical files while the worker thread is adding in the
00158  *   results of new comparisons).  Critical sections are used to manage
00159  *   the conflicts (as you'd expect).
00160  *
00161  *   The Edit options invoke an editor on a separate thread.  This allows
00162  *   us to repaint our window and thereby allow the user to refer back to
00163  *   what he saw before invoking the editor.  When he's finished editing,
00164  *   we would of course like to refresh things and if this is still on the
00165  *   separate thread it might clash. We avoid this clash by POSTing ourselves
00166  *   a (WM_COMMAND, IDM_UPDATE) message.
00167  */
00168
00169 #include "precomp.h"
00170 #include <shellapi.h>
00171
00172 #include "table.h"
00173 #include <richedit.h>           /* needed for usage dialog */
00174
00175 #include "list.h"               /* needed for compitem.h */
00176 #include "scandir.h"            /* needed for file.h     */
00177 #include "file.h"               /* needed for compitem.h */
00178 #include "compitem.h"           /* needed for view.h     */
00179 #include "complist.h"
00180 #include "view.h"
00181 #include "findgoto.h"
00182
00183 #include "state.h"
00184 #include "sdkdiff.h"
00185 #include "wdiffrc.h"
00186
00187
00188
00189 /*--constants and data types--------------------------------------------*/
00190 CRITICAL_SECTION CSSdkdiff;
00191 /* IF EVER YOU MIGHT ACQUIRE BOTH CSSdkdiff AND CSView, THEN DO SO IN
00192    THE ORDER:  FIRST GET CSSdkdiff  THEN GET CSView
00193    else risk deadlock when an idm_exit happens!
00194 */
00195 #define WDEnter()       EnterCriticalSection(&CSSdkdiff);
00196 #define WDLeave()       LeaveCriticalSection(&CSSdkdiff);
00197
00198 int Version = 2;
00199 int SubVersion = 01;
00200 char pszWorkingDirectoryName[MAX_PATH];
00201
00202 /* When we print the current table, we pass this id as the table id
00203  * When we are queried for the properties of this table, we know they
00204  * want the printing properties for the current view. We use this to
00205  * select different fonts and colours for the printer.
00206  */
00207 #define TABID_PRINTER   1
00208
00209 BOOL __BERR;
00210
00211 /*
00212  * structure containing args passed to worker thread in initial
00213  * case (executing command line instructions) (in WIN16 case,
00214  * the worker thread function is called synchronously with these args).
00215  */
00216 typedef struct {
00217     LPSTR first;
00218     LPSTR second;
00219     LPSTR savelist;
00220     LPSTR savecomp;
00221     LPSTR notify;
00222     UINT listopts;
00223     UINT compopts;
00224     VIEW view;
00225     BOOL fDeep;
00226     BOOL fExit;
00227     BOOL fOpenedFiles;
00228     BOOL fDescribeFiles;
00229     BOOL fInputFile;                    // TRUE means read file list from input file
00230     BOOL fInputFileSingle;              // TRUE means input file has one filename per line
00231 } THREADARGS, FAR * PTHREADARGS;
00232
00233
00234 /* structure containing all the arguments we'd like to give to do_editfile
00235    Need a structure because CreateThread only allows for one argument.
00236 */
00237 typedef struct {
00238     VIEW view;
00239     int option;
00240     long selection;
00241 } EDITARGS, FAR * PEDITARGS;
00242
00243 /*---- string constants --------------------------- */
00244
00245 const CHAR szSdkDiff[]                = "SdkDiff";
00246 static const char szD[]                      = "%d";
00247 static const char szBlanks[]                 = "Blanks";
00248 static const char szAlgorithm2[]             = "Algorithm2";
00249 static const char szPicture[]                = "Picture";
00250 static const char szMonoColours[]            = "MonoColours";
00251 static const char szHideMark[]               = "HideMark";
00252 static const char szSdkDiffViewerClass[]     = "SdkDiffViewerClass";
00253 static const char szSdkDiffMenu[]            = "SdkDiffMenu";
00254 static const char szOutlineMenu[]            = "OutlineFloatMenu";
00255 static const char szExpandMenu[]             = "ExpandFloatMenu";
00256 static const char szSdkDiffAccel[]           = "SdkDiffAccel";
00257 static const char szBarClass[]               = "BarClass";
00258 static const char szLineNumbers[]            = "LineNumbers";
00259 static const char szFileInclude[]            = "FileInclude";
00260 static const char szLineInclude[]            = "LineInclude";
00261 static const char szOutlineSaved[]           = "OutlineSaved";
00262 static const char szOutlineShowCmd[]         = "OutlineShowCmd";
00263 static const char szOutlineMaxX[]            = "OutlineMaxX";
00264 static const char szOutlineMaxY[]            = "OutlineMaxY";
00265 static const char szOutlineNormLeft[]        = "OutlineNormLeft";
00266 static const char szOutlineNormTop[]         = "OutlineNormTop";
00267 static const char szOutlineNormRight[]       = "OutlineNormRight";
00268 static const char szOutlineNormBottom[]      = "OutlineNormBottom";
00269 static const char szEditor[]                 = "Editor";
00270 static const char szFontFaceName[]           = "FontFaceName";
00271 static const char szFontHeight[]             = "FontHeight";
00272 static const char szFontBold[]               = "FontBold";
00273 static const char szFontCharSet[]            = "FontCharSet";
00274 static const char szExpandedSaved[]          = "ExpandedSaved";
00275 static const char szExpandShowCmd[]          = "ExpandShowCmd";
00276 static const char szExpandMaxX[]             = "ExpandMaxX";
00277 static const char szExpandMaxY[]             = "ExpandMaxY";
00278 static const char szExpandNormLeft[]         = "ExpandNormLeft";
00279 static const char szExpandNormTop[]          = "ExpandNormTop";
00280 static const char szExpandNormRight[]        = "ExpandNormRight";
00281 static const char szExpandNormBottom[]       = "ExpandNormBottom";
00282 static const char szColourPrinting[]         = "ColourPrinting";
00283 static const char szTabWidth[]               = "TabWidth";
00284 static const char szShowWhitespace[]         = "ShowWhitespace";
00285 static const char szrgb_outlinehi[]          = "RGBOutlineHi";
00286 static const char szrgb_leftfore[]           = "RGBLeftFore";
00287 static const char szrgb_leftback[]           = "RGBLeftBack";
00288 static const char szrgb_rightfore[]          = "RGBRightFore";
00289 static const char szrgb_rightback[]          = "RGBRightBack";
00290 static const char szrgb_similarleft[]        = "RGBSimilarLeft";
00291 static const char szrgb_similarright[]       = "RGBSimilarRight";
00292 static const char szrgb_similar[]            = "RGBSimilar";
00293 static const char szrgb_mleftfore[]          = "RGBMLeftFore";
00294 static const char szrgb_mleftback[]          = "RGBMLeftBack";
00295 static const char szrgb_mrightfore[]         = "RGBMRightFore";
00296 static const char szrgb_mrightback[]         = "RGBMRightBack";
00297 static const char szrgb_barleft[]            = "RGBBarLeft";
00298 static const char szrgb_barright[]           = "RGBBarRight";
00299 static const char szrgb_barcurrent[]         = "RGBBarCurrent";
00300 static const char szrgb_defaultfore[]        = "RGBDefaultFore";
00301 static const char szrgb_defaultforews[]      = "RGBDefaultForeWS";
00302 static const char szrgb_defaultback[]        = "RGBDefaultBack";
00303
00304 static const char szrgb_fileleftfore[]       = "RGBFileLeftFore";
00305 static const char szrgb_fileleftback[]       = "RGBFileLeftBack";
00306 static const char szrgb_filerightfore[]      = "RGBFileRightFore";
00307 static const char szrgb_filerightback[]      = "RGBFileRightBack";
00308
00309 /*---- colour scheme------------------------------- */
00310
00311 DWORD rgb_outlinehi = RGB(255, 0, 0);   /* hilighted files in outline mode  */
00312
00313 /* expand view */
00314 DWORD rgb_leftfore;          /* foregrnd for left lines */
00315 DWORD rgb_leftback;          /* backgrnd for left lines */
00316 DWORD rgb_rightfore;         /* foregrnd for right lines*/
00317 DWORD rgb_rightback;         /* backgrnd for right lines*/
00318
00319 /* temp hack */
00320 DWORD rgb_similarleft;       /* forground zebra         */
00321 DWORD rgb_similarright;      /* foreground zebra        */
00322 DWORD rgb_similar;           /* unused                  */
00323
00324 /* moved lines */
00325 DWORD rgb_mleftfore;         /* foregrnd for moved-left */
00326 DWORD rgb_mleftback;         /* backgrnd for moved-left */
00327 DWORD rgb_mrightfore;        /* foregrnd for moved-right*/
00328 DWORD rgb_mrightback;        /* backgrnd for moved-right*/
00329
00330 /* bar window */
00331 DWORD rgb_barleft;           /* bar sections in left only  */
00332 DWORD rgb_barright;          /* bar sections in right only */
00333 DWORD rgb_barcurrent;        /* current pos markers in bar */
00334
00335 DWORD rgb_defaultfore;       /* default foreground */
00336 DWORD rgb_defaultforews;     /* default foreground whitespace */
00337 DWORD rgb_defaultback;       /* default background */
00338
00339 DWORD rgb_fileleftfore;       /* outline mode left only file */
00340 DWORD rgb_fileleftback;       /* outline mode left only file */
00341 DWORD rgb_filerightfore;      /* outline mode right only file */
00342 DWORD rgb_filerightback;      /* outline mode right only file */
00343
00344 BOOL gbPerverseCompare = FALSE; // break lines on punctuation (broken & useless)
00345
00346 /* PickUpProfile */
00347 void PickUpProfile( DWORD * pfoo, LPCSTR szfoo)
00348 {
00349     *pfoo = GetProfileInt(APPNAME, szfoo, *pfoo);
00350 }
00351
00352
00353 void SetColours(void)
00354 {
00355     /* outline */
00356
00357     rgb_outlinehi = (DWORD)RGB(255, 0, 0);   /* hilighted files in outline mode  */
00358     PickUpProfile(&rgb_outlinehi, szrgb_outlinehi);
00359
00360     rgb_fileleftfore = (DWORD)RGB(0, 0, 0);   /* left only outline mode  */
00361     PickUpProfile(&rgb_fileleftfore, szrgb_fileleftfore);
00362     rgb_fileleftback = (DWORD)RGB(255, 255, 255);
00363     PickUpProfile(&rgb_fileleftback, szrgb_fileleftback);
00364
00365     rgb_filerightfore = (DWORD)RGB(0, 0, 0);  /* right only outline mode  */
00366     PickUpProfile(&rgb_filerightfore, szrgb_filerightfore);
00367     rgb_filerightback = (DWORD)RGB(255, 255, 255);
00368     PickUpProfile(&rgb_filerightback, szrgb_filerightback);
00369
00370     /* expand view */
00371     rgb_leftfore =   (DWORD)RGB(  0,   0,   0);         /* foregrnd for left lines */
00372     PickUpProfile(&rgb_leftfore, szrgb_leftfore);
00373     rgb_leftback  =  (DWORD)RGB(255,   0,   0);         /* backgrnd for left lines */
00374     PickUpProfile(&rgb_leftback, szrgb_leftback);
00375     rgb_rightfore =  (DWORD)RGB(  0,   0,   0);         /* foregrnd for right lines*/
00376     PickUpProfile(&rgb_rightfore, szrgb_rightfore);
00377     rgb_rightback =  (DWORD)RGB(255, 255,   0);         /* backgrnd for right lines*/
00378     PickUpProfile(&rgb_rightback, szrgb_rightback);
00379
00380     rgb_similarleft= (DWORD)RGB(  0, 255, 255);         /* foreground zebra        */
00381     PickUpProfile(&rgb_similarleft, szrgb_similarleft);
00382     rgb_similarright=(DWORD)RGB(  0, 127, 127);         /* forground zebra         */
00383     PickUpProfile(&rgb_similarright, szrgb_similarright);
00384     rgb_similar   =  (DWORD)RGB(  127, 127, 255);       /* same within comp options*/
00385     PickUpProfile(&rgb_similar, szrgb_similar);
00386
00387     /* moved lines */
00388     rgb_mleftfore =  (DWORD)RGB(  0,   0, 128);         /* foregrnd for moved-left */
00389     PickUpProfile(&rgb_mleftfore, szrgb_mleftfore);
00390     rgb_mleftback =  (DWORD)RGB(255,   0,   0);         /* backgrnd for moved-left */
00391     PickUpProfile(&rgb_mleftback, szrgb_mleftback);
00392     rgb_mrightfore = (DWORD)RGB(  0,   0, 255);         /* foregrnd for moved-right*/
00393     PickUpProfile(&rgb_mrightfore, szrgb_mrightfore);
00394     rgb_mrightback = (DWORD)RGB(255, 255,   0);         /* backgrnd for moved-right*/
00395     PickUpProfile(&rgb_mrightback, szrgb_mrightback);
00396
00397     /* bar window */
00398     rgb_barleft =    (DWORD)RGB(255,   0,   0);         /* bar sections in left only  */
00399     PickUpProfile(&rgb_barleft, szrgb_barleft);
00400     rgb_barright =   (DWORD)RGB(255, 255,   0);         /* bar sections in right only */
00401     PickUpProfile(&rgb_barright, szrgb_barright);
00402     rgb_barcurrent = (DWORD)RGB(  0,   0, 255);         /* current pos markers in bar */
00403     PickUpProfile(&rgb_barcurrent, szrgb_barcurrent);
00404
00405     /* defaults */
00406     rgb_defaultfore = (DWORD)RGB(   0,   0,   0);       /* default foreground colour */
00407     PickUpProfile(&rgb_defaultfore, szrgb_defaultfore);
00408     rgb_defaultforews = (DWORD)RGB(192, 192, 192);      /* default foreground whitespace colour */
00409     PickUpProfile(&rgb_defaultforews, szrgb_defaultforews);
00410     rgb_defaultback = (DWORD)RGB(255, 255, 255);        /* default background colour */
00411     PickUpProfile(&rgb_defaultback, szrgb_defaultback);
00412
00413 } /* SetColours */
00414
00415 void SetMonoColours(void)
00416 {
00417     rgb_outlinehi = GetSysColor(COLOR_WINDOW);   /* hilighted files in outline mode  */
00418
00419     /* expand view - all changed or moved lines are white on black */
00420     rgb_leftfore =   GetSysColor(COLOR_WINDOW);         /* foregrnd for left lines */
00421     rgb_leftback  =  GetSysColor(COLOR_WINDOWTEXT);     /* backgrnd for left lines */
00422     rgb_rightfore =  GetSysColor(COLOR_WINDOW);         /* foregrnd for right lines*/
00423     rgb_rightback =  GetSysColor(COLOR_WINDOWTEXT);     /* backgrnd for right lines*/
00424
00425     rgb_similarleft= GetSysColor(COLOR_WINDOW);         /* foreground zebra        */
00426     rgb_similarright=GetSysColor(COLOR_WINDOW);         /* foreground zebra        */
00427     rgb_similar   =  GetSysColor(COLOR_WINDOWTEXT);     /* same within comp options*/
00428
00429     /* moved lines - black on white */
00430     rgb_mleftfore =  GetSysColor(COLOR_WINDOWTEXT);     /* foregrnd for moved-left */
00431     rgb_mleftback =  GetSysColor(COLOR_WINDOW);         /* backgrnd for moved-left */
00432     rgb_mrightfore = GetSysColor(COLOR_WINDOWTEXT);     /* foregrnd for moved-right*/
00433     rgb_mrightback = GetSysColor(COLOR_WINDOW);         /* backgrnd for moved-right*/
00434
00435     /* bar WINDOWTEXT */
00436     rgb_barleft =    GetSysColor(COLOR_WINDOWTEXT);     /* bar sections in left only  */
00437     rgb_barright =   GetSysColor(COLOR_WINDOWTEXT);     /* bar sections in right only */
00438     rgb_barcurrent = GetSysColor(COLOR_WINDOWTEXT);     /* current pos markers in bar */
00439
00440
00441     rgb_defaultfore = GetSysColor(COLOR_WINDOWTEXT);    /* default foreground colour */
00442     rgb_defaultforews = GetSysColor(COLOR_WINDOWTEXT);  /* default foreground whitespace colour */
00443     rgb_defaultback = GetSysColor(COLOR_WINDOW);        /* default background colour */
00444
00445 } /* SetMonoColours */
00446
00447 /* -------------------------------------------------- */
00448
00449 /* module static data -------------------------------------------------*/
00450
00451
00452 /* current value of window title */
00453 char AppTitle[256];
00454
00455
00456 HWND hwndClient;        /* main window */
00457 HWND hwndRCD;           /* table window */
00458 HWND hwndStatus;        /* status bar across top */
00459 HWND hwndBar;           /* graphic of sections as vertical bars */
00460
00461 HACCEL haccel;
00462
00463 /* the status bar told us it should be this high. Rest of client area
00464  * goes to the hwndBar and hwndRCD.
00465  */
00466 int status_height;
00467
00468 #if 0
00469     #ifndef HINSTANCE
00470         #define HINSTANCE HANDLE
00471     #endif
00472 #endif
00473
00474 HINSTANCE hInst;   /* handle to current app instance */
00475 HMENU hMenu;    /* handle to menu for hwndClient */
00476
00477 int nMinMax = SW_SHOWNORMAL;         /* default state of window normal */
00478
00479 /* the message sent to us as a callback by the table window needs to be
00480  * registered - table_msgcode is the result of the RegisterMessage call
00481  */
00482 UINT table_msgcode;
00483
00484 /* true if we are currently doing some scan or comparison.
00485  * WIN32: must get critical section before checking/changing this (call
00486  * SetBusy.
00487  */
00488 BOOL fBusy = FALSE;
00489
00490
00491 long     selection      =       -1;     /* selected row in table*/
00492 long selection_nrows    =       0;      /* number of rows in selection */
00493
00494 /* options for DisplayMode field indicating what is currently shown.
00495  * we use this to know whether or not to show the graphic bar window.
00496  */
00497 #define MODE_NULL       0       /* nothing displayed */
00498 #define MODE_OUTLINE    1       /* a list of files displayed */
00499 #define MODE_EXPAND     2       /* view is expanded view of one file */
00500
00501 int DisplayMode = MODE_NULL;    /* indicates whether we are in expand mode */
00502
00503 VIEW current_view = NULL;
00504
00505 BOOL fAutoExpand = TRUE;        /* Should we auto expand ? */
00506
00507 /* These two flags are peeked at by lots of other modules */
00508 BOOL bAbort;            /* set to request abort of current operation */
00509 BOOL bTrace;            /* set if tracing is to be enabled */
00510 BOOL bJapan;            /* set if primary language is Japanese */
00511 BOOL bDBCS;             /* set if primary language is Japanese/Korean/Chinese */
00512
00513 extern char*s;
00514
00515 char editor_cmdline[256] = "notepad %p";  /* editor cmdline */
00516
00517 char g_szFontFaceName[LF_FACESIZE];
00518 int g_nFontHeight;
00519 BOOL g_fFontBold;
00520 BYTE g_bFontCharSet;
00521 HFONT g_hFont = 0;
00522
00523 /* app-wide global data --------------------------------------------- */
00524
00525
00526 /* current state of menu options */
00527 int line_numbers = IDM_LNRS;
00528 int expand_mode = IDM_BOTHFILES;
00529 int outline_include = INCLUDE_ALL;
00530 int expand_include = INCLUDE_ALL;
00531 BOOL ignore_blanks = TRUE;
00532 BOOL show_whitespace = FALSE;
00533 BOOL Algorithm2 = TRUE;  /* Try duplicates - used in compitem.c */
00534 BOOL picture_mode = TRUE;
00535 BOOL hide_markedfiles = FALSE;
00536 BOOL mono_colours = FALSE;       /* monochrome display */
00537
00538 // tab width - set from TabWidth entry in registry
00539 int g_tabwidth = TABWIDTH_DEFAULT;
00540
00541 BOOL TrackLeftOnly = TRUE;
00542 BOOL TrackRightOnly = TRUE;
00543 BOOL TrackSame = TRUE;
00544 BOOL TrackDifferent = TRUE;
00545 BOOL TrackReadonly = TRUE;
00546
00547 /* function prototypes ---------------------------------------------*/
00548
00549 BOOL InitApplication(HINSTANCE hInstance);
00550 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow);
00551 void CreateTools(void);
00552 void DeleteTools(void);
00553 INT_PTR APIENTRY MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00554 BOOL SetBusy(void);
00555 void SetNotBusy(void);
00556 void SetSelection(long rownr, long nrows, long dyRowsFromTop);
00557 void SetButtonText(LPSTR cmd);
00558 BOOL ToExpand(HWND hwnd);
00559 void ParseArgs(char * lpCmdLine);
00560 void Trace_Status(LPSTR str);
00561
00562 DWORD WINAPI wd_initial(LPVOID arg);
00563
00564 static HANDLE ghThread = NULL;
00565 /* Some DOGMA about threads:
00566    When we spin off threads and then while they are still running, try to Exit
00567    we get race conditions with one thread allocating and the other freeing the
00568    storage.
00569    It might be that given a final structure of A->B->C we have A->B with NULL
00570    pointers in B when the Exit comes in.  The cleanup thread will clear out
00571    B and A and THEN the worker thread might try to attach C to B which is no
00572    longer there.  This means that the worker thread must be Stopped.  To allow
00573    this to happen quickly, we TerminateThread it.  This will leave the initial
00574    stack around, but presumably that gets cleaned up on app exit anyway.
00575    There is only at most one worker thread running, and ghThread is its handle.
00576 */
00577
00578 static DWORD gdwMainThreadId;     /* threadid of main (user interface) thread
00579                                      initialised in winmain(), thereafter constant.
00580                                      See sdkdiff_UI()
00581                                   */
00582
00583 /* if you are about to put up a dialog box or in fact process input in any way
00584    on any thread other than the main thread - or if you MIGHT be on a thread other
00585    than the main thread, then you must call this function with TRUE before doing
00586    it and with FALSE immediately afterwards.  Otherwise you will get one of a
00587    number of flavours of not-very-responsiveness
00588 */
00589 void sdkdiff_UI(BOOL bAttach)
00590 {
00591     DWORD dwThreadId = GetCurrentThreadId();
00592     if (dwThreadId==gdwMainThreadId) return;
00593
00594     if (bAttach) GetDesktopWindow();
00595     AttachThreadInput(dwThreadId, gdwMainThreadId, bAttach);
00596 } /* sdkdiff_UI */
00597
00598 /*-functions----------------------------------------------------------*/
00599
00600 /* main entry point. register window classes, create windows,
00601  * parse command line arguments and then perform a message loop
00602  */
00603
00604
00605 int WINAPI
00606 WinMain(
00607         HINSTANCE hInstance,
00608         HINSTANCE hPrevInstance,
00609         LPSTR lpCmdLine,
00610         int nCmdShow
00611         )
00612 {
00613     MSG msg;
00614   int len = 0;
00615
00616   // Get working directory.
00617   memset(pszWorkingDirectoryName, 0, MAX_PATH);
00618   len = GetModuleFileName(hInstance, pszWorkingDirectoryName, MAX_PATH);
00619   if (len != 0) {
00620     while (pszWorkingDirectoryName[len-1] != '\\' ) {
00621       len--;
00622     }
00623     pszWorkingDirectoryName[len] = 0;
00624   }
00625
00626     InitGutils(GetModuleHandle(NULL), DLL_PROCESS_ATTACH, NULL);
00627
00628     gdwMainThreadId = GetCurrentThreadId();
00629
00630     /* create any pens/brushes etc and read in profile defaults */
00631     CreateTools();
00632
00633     /* init window class unless other instances running */
00634     if (!hPrevInstance)
00635         if (!InitApplication(hInstance))
00636             return(FALSE);
00637
00638
00639     /* init this instance - create all the windows */
00640     if (!InitInstance(hInstance, nCmdShow))
00641         return(FALSE);
00642
00643     ParseArgs(lpCmdLine);
00644
00645     /* message loop */
00646     while (GetMessage(&msg, NULL, 0, 0)) {
00647         if (!TranslateAccelerator(hwndClient, haccel, &msg)) {
00648             TranslateMessage(&msg);
00649             DispatchMessage(&msg);
00650         }
00651     }
00652
00653     Trace_Close();
00654     return (msg.wParam ? 1 : 0);
00655 }
00656
00657 /* InitApplication
00658  *
00659  * - register window class for the main window and the bar window.
00660  */
00661 BOOL
00662 InitApplication(
00663                 HINSTANCE hInstance
00664                 )
00665 {
00666     WNDCLASS    wc;
00667     BOOL resp;
00668
00669     LCID lcid = GetThreadLocale();
00670
00671     // set the boolean value for bJapan variable
00672     bJapan = (PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_JAPANESE);
00673     bDBCS = ((PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_JAPANESE) ||
00674              (PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_KOREAN)   ||
00675              (PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_CHINESE));
00676
00677     /* register the bar window class */
00678     InitBarClass(hInstance);
00679
00680     wc.style = 0;
00681     wc.lpfnWndProc = (WNDPROC)MainWndProc;
00682     wc.cbClsExtra = 0;
00683     wc.cbWndExtra = 0;
00684     wc.hInstance = hInstance;
00685     wc.hIcon = LoadIcon(hInstance, szSdkDiff);
00686     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00687     wc.hbrBackground = NULL;
00688     wc.lpszClassName = (LPSTR) szSdkDiffViewerClass;
00689     wc.lpszMenuName = NULL;
00690
00691     resp = RegisterClass(&wc);
00692
00693     return(resp);
00694 }
00695
00696 /*
00697  * create and show the windows
00698  */
00699 BOOL
00700 InitInstance(
00701              HINSTANCE hInstance,
00702              int nCmdShow
00703              )
00704 {
00705     RECT rect;
00706     HANDLE hstatus;
00707     int bar_width;
00708     RECT childrc;
00709     HIGHCONTRAST hc;
00710
00711     hInst = hInstance;
00712
00713     /* initialise the list package */
00714     List_Init();
00715
00716
00717     hMenu = LoadMenu(hInstance, szSdkDiffMenu);
00718     haccel = LoadAccelerators(hInstance, szSdkDiffAccel);
00719
00720     /* create the main window */
00721     hwndClient = CreateWindow(szSdkDiffViewerClass,
00722                               szSdkDiff,
00723                               WS_OVERLAPPEDWINDOW,
00724                               CW_USEDEFAULT,
00725                               CW_USEDEFAULT,
00726                               CW_USEDEFAULT,
00727                               CW_USEDEFAULT,
00728                               NULL,
00729                               hMenu,
00730                               hInstance,
00731                               NULL
00732                              );
00733
00734
00735
00736     if (!hwndClient) {
00737         return(FALSE);
00738     }
00739
00740     /* create 3 child windows, one status, one table and one bar
00741      * Initially, the bar window is hidden and covered by the table.
00742      */
00743
00744     /* create a status bar window as
00745      * a child of the main window.
00746      */
00747
00748     /* build a status struct for two labels and an abort button */
00749     hstatus = StatusAlloc(3);
00750     StatusAddItem(hstatus, 0, SF_STATIC, SF_LEFT|SF_VAR|SF_SZMIN, IDL_STATLAB, 14, NULL);
00751     StatusAddItem(hstatus, 1, SF_BUTTON, SF_RIGHT|SF_RAISE, IDM_ABORT, 8,
00752                 LoadRcString(IDS_EXIT));
00753     StatusAddItem(hstatus, 2, SF_STATIC, SF_LOWER|SF_LEFT|SF_VAR,
00754                   IDL_NAMES, 60, NULL);
00755
00756     /* ask the status bar how high it should be for the controls
00757      * we have chosen, and save this value for re-sizing.
00758      */
00759     status_height = StatusHeight(hstatus);
00760
00761     /* create a window of this height */
00762     GetClientRect(hwndClient, &rect);
00763     childrc = rect;
00764     childrc.bottom = status_height;
00765     hwndStatus = StatusCreate(hInst, hwndClient, IDC_STATUS, &childrc,
00766                               hstatus);
00767
00768     /* layout constants are stated as percentages of the window width */
00769     bar_width = (rect.right - rect.left) * BAR_WIN_WIDTH / 100;
00770
00771     /* create the table class covering all the remaining part of
00772      * the main window
00773      */
00774     hwndRCD = CreateWindow(TableClassName,
00775                            NULL,
00776                            WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL,
00777                            0,
00778                            status_height,
00779                            (int)(rect.right - rect.left),
00780                            (int)(rect.bottom - status_height),
00781                            hwndClient,
00782                            (HMENU) IDC_RCDISP1,
00783                            hInst,
00784                            NULL);
00785
00786     /* create a bar window as a child of the main window.
00787      * this window remains hidden until we switch into MODE_EXPAND
00788      */
00789     hwndBar = CreateWindow(szBarClass,
00790                            NULL,
00791                            WS_CHILD | WS_VISIBLE,
00792                            0,
00793                            status_height,
00794                            bar_width,
00795                            (int)(rect.bottom - status_height),
00796                            hwndClient,
00797                            (HMENU) IDC_BAR,
00798                            hInst,
00799                            NULL);
00800
00801     /* nMinMax indicates whether we are to be minimised on startup,
00802      * on command line parameters
00803      */
00804     ShowWindow(hwndBar, SW_HIDE);
00805
00806     if (GetProfileInt(APPNAME, szOutlineSaved, 0)) {
00807         WINDOWPLACEMENT wp;
00808         /* restore the previous expanded size and position */
00809         wp.length = sizeof(wp);
00810         wp.flags                   = 0;
00811         wp.showCmd                 = GetProfileInt( APPNAME, szOutlineShowCmd,
00812                                                     SW_SHOWNORMAL);
00813         wp.ptMaxPosition.x         = GetProfileInt( APPNAME, szOutlineMaxX,       0);
00814         wp.ptMaxPosition.y         = GetProfileInt( APPNAME, szOutlineMaxY,       0);
00815         wp.rcNormalPosition.left   = (int)GetProfileInt( APPNAME, szOutlineNormLeft,  (UINT)(-1));
00816         wp.rcNormalPosition.top    = (int)GetProfileInt( APPNAME, szOutlineNormTop,   (UINT)(-1));
00817         wp.rcNormalPosition.right  = (int)GetProfileInt( APPNAME, szOutlineNormRight, (UINT)(-1));
00818         wp.rcNormalPosition.bottom = (int)GetProfileInt( APPNAME, szOutlineNormBottom,(UINT)(-1));
00819
00820         if (!SetWindowPlacement(hwndClient,&wp)) {
00821             ShowWindow(hwndClient, nMinMax);
00822         }
00823     } else ShowWindow(hwndClient, nMinMax);
00824
00825
00826     /* initialise busy flag and status line to show we are idle
00827      * (ie not comparing or scanning)
00828      */
00829     SetNotBusy();
00830
00831     /* initialise the colour globals */
00832     hc.cbSize = sizeof(hc);
00833     SystemParametersInfo(SPI_GETHIGHCONTRAST,0 ,&hc, 0);
00834     mono_colours = (hc.dwFlags & HCF_HIGHCONTRASTON);
00835     if (mono_colours) {
00836         SetMonoColours();
00837     } else {
00838         SetColours();
00839     }
00840     PostMessage(hwndClient, WM_SYSCOLORCHANGE, 0 , 0);
00841     UpdateWindow(hwndClient);
00842
00843     return(TRUE);
00844
00845 } /* InitInstance */
00846
00847
00848
00849 /*
00850  * complain to command line users about poor syntax
00851  */
00852
00853 typedef struct
00854 {
00855     UINT m_ids;
00856     BOOL m_fInternalOnly;
00857     BOOL m_fExternalOnly;
00858     int m_cIndent;
00859 } UsageStringInfo;
00860
00861 static const UsageStringInfo c_rg[] =
00862 {
00863     { (UINT)-1,             0, 0, 0 },
00864     { IDS_USAGE_STR00,      0, 0, 0 },
00865     { IDS_USAGE_STR01,      0, 0, 0 },
00866     { IDS_USAGE_STR02,      0, 0, 1 },
00867     { IDS_USAGE_STR03,      0, 0, 1 },
00868     { IDS_USAGE_STR04,      0, 0, 3 },
00869     { IDS_USAGE_STR05,      0, 0, 1 },
00870     { IDS_USAGE_STR06,      0, 1, 1 },
00871     { IDS_USAGE_STR07,      1, 0, 1 },
00872     { IDS_USAGE_STR08,      1, 0, 1 },
00873     { IDS_USAGE_STR08B,     0, 0, 1 },
00874     { IDS_USAGE_STR09,      1, 0, 1 },
00875     { IDS_USAGE_STR10,      1, 0, 1 },
00876     { IDS_USAGE_STR11,      1, 0, 1 },
00877     { IDS_USAGE_STR12,      1, 0, 1 },
00878     { IDS_USAGE_STR12B,     1, 0, 1 },
00879     { IDS_USAGE_STR12C,     1, 0, 1 },
00880     { IDS_USAGE_STR13,      1, 0, 1 },
00881     { IDS_USAGE_STR14,      1, 0, 1 },
00882     { IDS_USAGE_STR15,      0, 0, 1 },
00883     { IDS_USAGE_STR16,      0, 0, 1 },
00884     { IDS_USAGE_STR17,      0, 0, 1 },
00885     { IDS_USAGE_STR18,      0, 0, 1 },
00886     { IDS_USAGE_STR19,      0, 0, 3 },
00887     { IDS_USAGE_STR20,      0, 0, 1 },
00888     { IDS_USAGE_STR21,      1, 0, 1 },
00889     { IDS_USAGE_STR22,      1, 0, 3 },
00890     { IDS_USAGE_STR23,      1, 0, 0 },
00891     { IDS_USAGE_STR24,      1, 0, -1 },
00892     { IDS_USAGE_STR25,      1, 0, -1 },
00893     { IDS_USAGE_STR26,      1, 0, -1 },
00894 };
00895
00896 INT_PTR FAR PASCAL UsageDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00897 {
00898     switch (message)
00899     {
00900     case WM_INITDIALOG:
00901         {
00902             HWND hwnd = GetDlgItem(hDlg, IDC_USAGE_TEXT);
00903             if (hwnd)
00904             {
00905                 const UsageStringInfo *p;
00906                 int c;
00907                 PARAFORMAT pf;
00908                 CHARFORMAT cf;
00909                 int pos;
00910
00911                 pf.cbSize = sizeof(pf);
00912
00913                 SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
00914                 SendMessage(hwnd, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(4, 4));
00915
00916                 for (p = c_rg, c = NUMELMS(c_rg); c--; p++)
00917                 {
00918                     LPCSTR psz;
00919           psz=LoadRcString(p->m_ids);
00920                     if (p->m_fExternalOnly)
00921                         continue;
00922                     if (p->m_fInternalOnly)
00923                         continue;
00924
00925                     pos = LOWORD(SendMessage(hwnd, EM_GETSEL, 0, 0));
00926                     SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM)psz);
00927                     SendMessage(hwnd, EM_SETSEL, pos, -1);
00928
00929                     SendMessage(hwnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
00930                     if (p->m_cIndent >= 0)
00931                     {
00932                         static const int c_rgIndents[] = { 320*1, 320*5, 320*6 };
00933                         static const int c_rgOffsets[] = { 320*4, 0, 0 };
00934
00935                         pf.dwMask |= PFM_STARTINDENT|PFM_OFFSET|PFM_TABSTOPS;
00936                         pf.dxStartIndent = 0;
00937                         pf.dxOffset = 0;
00938                         if (p->m_cIndent)
00939                         {
00940                             pf.dxStartIndent = c_rgIndents[p->m_cIndent - 1];
00941                             pf.dxOffset = c_rgOffsets[p->m_cIndent - 1];
00942                         }
00943                         pf.cTabCount = 2;
00944                         pf.rgxTabs[0] = c_rgIndents[0];
00945                         pf.rgxTabs[1] = c_rgIndents[1];
00946                     }
00947                     else
00948                     {
00949                         pf.dwMask |= PFM_STARTINDENT|PFM_OFFSET|PFM_NUMBERING;
00950                         pf.dxStartIndent = 320;
00951                         pf.dxOffset = 180;
00952                         pf.wNumbering = PFN_BULLET;
00953                     }
00954                     SendMessage(hwnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
00955
00956                     SendMessage(hwnd, EM_SETSEL, (WPARAM)-1, -1);
00957                 }
00958
00959                 cf.cbSize = sizeof(cf);
00960                 cf.dwMask = CFM_COLOR;
00961                 cf.dwEffects = 0;
00962                 cf.crTextColor = GetSysColor(COLOR_BTNTEXT);
00963                 SendMessage(hwnd, EM_SETSEL, 0, -1);
00964                 SendMessage(hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
00965                 SendMessage(hwnd, EM_SETSEL, (WPARAM)-1, -1);
00966                 pos = LOWORD(SendMessage(hwnd, EM_GETSEL, 0, 0));
00967                 SendMessage(hwnd, EM_SETSEL, pos - 1, pos);
00968                 SendMessage(hwnd, EM_REPLACESEL, 0, (LPARAM)"");
00969                 SendMessage(hwnd, EM_SETSEL, 0, 0);
00970             }
00971         }
00972         break;
00973
00974     case WM_COMMAND:
00975         switch (wParam)
00976         {
00977         case IDOK:
00978         case IDCANCEL:
00979             EndDialog(hDlg, wParam);
00980             break;
00981         }
00982         break;
00983
00984     default:
00985         return FALSE;
00986     }
00987
00988     return TRUE;
00989 }
00990
00991 void
00992 sdkdiff_usage(
00993               LPSTR msg
00994               )
00995 {
00996     INT_PTR retval;
00997     UINT fuStyle =  MB_ICONINFORMATION|MB_OKCANCEL;
00998   HRESULT hr;
00999
01000
01001     if (msg)
01002     {
01003         char Usage[4096];
01004
01005         // since msg may be a pointer returned by LoadRcString, copy it off so
01006         // we don't stomp on the string when we load IDS_SDKDIFF_USAGE.
01007         hr = StringCchCopy(Usage, 4096, msg);
01008     if (FAILED(hr))
01009       OutputError(hr, IDS_SAFE_COPY);
01010         msg = Usage;
01011
01012         retval = MessageBox(hwndClient,
01013                             msg,
01014                             LoadRcString(IDS_SDKDIFF_USAGE),
01015                             fuStyle);
01016     }
01017     else
01018     {
01019         HINSTANCE h;
01020
01021         h = LoadLibrary("riched20.dll");
01022         if (!h)
01023             h = LoadLibrary("riched32.dll");
01024         if (h)
01025         {
01026             retval = DialogBox(hInst, (LPCSTR)IDD_USAGE, hwndClient, UsageDlgProc);
01027             FreeLibrary(h);
01028         }
01029         else
01030         {
01031             sdkdiff_usage(LoadRcString(IDS_ERROR_CANTLOADRICHEDIT));
01032             retval = IDOK;
01033         }
01034     }
01035
01036     if (retval == IDCANCEL)
01037         exit(1);
01038 }
01039
01040
01041 /*  Functionally similar to strtok except that " ... " is a token, even if
01042     it contains spaces and the delimiters are built in (no second parameter)
01043     GetNextToken(foo) delivers the first token in foo (or NULL if foo is empty)
01044     and caches foo so that GetNextToken(NULL) then gives the next token.  When there
01045     are no more tokens left it returns NULL
01046     It mangles the original by peppering it with NULLs as it chops the tokens
01047     off.  Each time except the last it inserts a new NULL.
01048     Obviously not thread safe!
01049     Command line is limited to 512 chars.
01050
01051 */
01052 char *
01053 GetNextToken(
01054              char * Tok
01055              )
01056 {
01057     static char * Source;     // The address of the original source string
01058                               // which gets progressively mangled
01059
01060     static char RetBuff[512]; // We will build results in here
01061     static char *Ret;         // We build the results here (in RetBuff)
01062                               // but moved along each time.
01063
01064     static char * p;       // the next char to parse in Source
01065                            // NULL if none left.
01066   HRESULT hr;
01067
01068     // Quotes are a damned nuisance (they are the whole reason why strtok
01069     // wouldn't work).  If the string starts with quotes then we potentially
01070     // need to pull together fragments of the string "foo""ba"r => foobar
01071     // We want to pull these together into storage that we can safely write
01072     // into and return (can't be stack).  Mangling the original parameter
01073     // gets very messy so we cache a pointer to the original source that
01074     // we work through and we build up output tokens in a static
01075     // and therefore permanently wasted buffer of (arbitrarily) 512 bytes.
01076     // then we can set Ret to \0 and concatenate bits on as we find them.
01077     // The rule is that we split at the first space outside quotes.
01078
01079
01080     // cache the Source if a "first time" call.  Kill the "finished" case.
01081     if (Tok!=NULL) {
01082         Source = Tok;
01083         Ret = RetBuff;
01084         RetBuff[0] = '\0';
01085         p = Source;
01086     } else if (p==NULL) {
01087         return NULL;          // finished
01088     } else {
01089         Ret +=strlen(Ret)+1;  // slide it past last time's stuff
01090     }
01091
01092     *Ret = '\0';              // empty string to concatenate onto
01093
01094     // from here on Tok is used as a temporary.
01095
01096     // keep taking sections and adding them to the start of Source
01097     for (; ; ) {
01098
01099         // for each possibility we grow Ret and move p on.
01100         if (*p=='\"') {
01101             ++p;
01102             Tok = My_mbschr(p, '"');
01103             if (Tok==NULL) {
01104                 hr = StringCchCat(Ret, 512, p);
01105         if (FAILED(hr)) {
01106           OutputError(hr, IDS_SAFE_CAT);
01107           return(NULL);
01108         }
01109                 p = NULL;
01110                 return Ret;
01111             } else {
01112                 *Tok = '\0';    // split the section off, replaceing the "
01113                 hr = StringCchCat(Ret, 512, p); // add it to the result
01114         if (FAILED(hr)) {
01115           OutputError(hr, IDS_SAFE_CAT);
01116           return (NULL);
01117         }
01118                 p = Tok+1;      // move past the quote
01119             }
01120         } else {
01121             int i = (int)strcspn(p," \"");   // search for space or quote
01122             if (p[i]=='\0') {
01123                 // It's fallen off the end
01124                 hr = StringCchCat(Ret, 512, p);
01125         if (FAILED(hr)) {
01126           OutputError(hr, IDS_SAFE_CAT);
01127           return (NULL);
01128         }
01129                 p = NULL;
01130                 return Ret;
01131             } else if (p[i]==' ') {
01132                 // We've hit a genuine delimiting space
01133                 p[i] = '\0';
01134                 hr = StringCchCat(Ret,512, p);
01135         if (FAILED(hr)) {
01136           OutputError(hr, IDS_SAFE_CAT);
01137           return (NULL);
01138         }
01139                 p +=i+1;
01140
01141                 // strip trailing spaces (leading spaces for next time)
01142                 while (*p==' ')
01143                     ++p;
01144                 if (*p=='\0')
01145                     p = NULL;
01146
01147                 return Ret;
01148             } else {
01149                 // we've hit a quote
01150                 p[i] = '\0';
01151                 hr = StringCchCat(Ret, 512, p);
01152         if (FAILED(hr)) {
01153           OutputError(hr, IDS_SAFE_CAT);
01154           return (NULL);
01155         }
01156                 p[i] = '\"';     // put it back so that we can find it again
01157                 p +=i;           // aim at it and iterate
01158             }
01159         }
01160
01161     } // for
01162
01163 } // GetNextToken
01164
01165
01166
01167
01168
01169 /*
01170  * parse command line arguments
01171  *
01172  * The user can give one or two paths. if only one, we assume the second
01173  * is '.' for the current directory. if one of the two paths is a directory
01174  * and the other a file, we compare a file of the same name in the two dirs.
01175  *
01176  * the command -s filename causes the outline list to be written to a file
01177  * -s{slrd} filename allows selection of which files are written out;
01178  * by default, we assume -sld for files left and different.
01179  * -s{slrd}x causes the program to exit after the list has been written out
01180  *
01181  *
01182  * -T means tree.  Go deep.
01183  * -D means Directory or Don't go deep.
01184  * -O means Stay in outline mode.  No auto expand.
01185  *
01186  */
01187 void
01188 ParseArgs(
01189           char * lpCmdLine
01190           )
01191 {
01192     PTHREADARGS ta;
01193
01194     BOOL fAllowTwoPaths = TRUE;         // FALSE means -l or -lr was used
01195     BOOL fReverse = FALSE;              // -lr means reverse
01196     BOOL fDeepDefault = TRUE;
01197     char * tok;         /* token from lpCmdLine */
01198
01199     DWORD threadid;
01200     UINT idsError = 0;
01201
01202     /* thread args can't be on the stack since the stack will change
01203      * before the thread completes execution
01204      */
01205     ta = (PTHREADARGS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(THREADARGS));
01206     if (ta == NULL)
01207     return;
01208
01209   ta->first = NULL;
01210     ta->second = NULL;
01211     ta->savelist = NULL;
01212     ta->savecomp = NULL;
01213     ta->listopts = 0;
01214     ta->compopts = 0;
01215     ta->notify = NULL;
01216     ta->fExit = FALSE;
01217     ta->fDeep = FALSE;  /* No -T option seen yet */
01218
01219     tok = GetNextToken(lpCmdLine);
01220
01221     while ((tok!=NULL) && (lstrlen(tok) > 0)) {
01222
01223         if (tok[0] == '/' && tok[1] == '/')
01224         {
01225             goto LFile;
01226         }
01227
01228         /* is this an option ? */
01229         if ((tok[0] == '-') || (tok[0] == '/')) {
01230             switch (tok[1]) {
01231                 case 's':
01232                 case 'S':
01233                     /* read letters for the save option: s,l,r,d */
01234                     for (tok+=2; *tok != '\0'; ++tok) {
01235                         switch (*tok) {
01236                             case 's':
01237                             case 'S':
01238                                 ta->listopts |= INCLUDE_SAME;
01239                                 break;
01240                             case 'l':
01241                             case 'L':
01242                                 ta->listopts |= INCLUDE_LEFTONLY;
01243                                 break;
01244                             case 'r':
01245                             case 'R':
01246                                 ta->listopts |= INCLUDE_RIGHTONLY;
01247                                 break;
01248                             case 'd':
01249                             case 'D':
01250                                 ta->listopts |= INCLUDE_DIFFER;
01251                                 break;
01252                             case 'x':
01253                             case 'X':
01254                                 ta->fExit = TRUE;
01255                                 break;
01256                             default:
01257                                 idsError = 0;
01258                                 goto LUsage;
01259                         }
01260                     }
01261
01262                     if (ta->listopts == 0) {
01263                         /* default to left and differ */
01264                         ta->listopts = (INCLUDE_LEFTONLY) | (INCLUDE_DIFFER);
01265                     }
01266                     ta->savelist = GetNextToken(NULL);
01267                     break;
01268                 case 'f':
01269                 case 'F':
01270           /* read letters for the save option: s,l,r,d,e,i */
01271                     for(tok = &tok[2]; *tok != '\0'; ++tok) {
01272                         switch(*tok) {
01273                         case 'i':
01274                         case 'I':
01275                                 ta->compopts |= INCLUDE_SAME;
01276                                 break;
01277                         case 'l':
01278                         case 'L':
01279                                 ta->compopts |= INCLUDE_LEFTONLY;
01280                                 break;
01281                         case 'r':
01282                         case 'R':
01283                                 ta->compopts |= INCLUDE_RIGHTONLY;
01284                                 break;
01285                         case 'f':
01286                         case 'F':
01287                                 ta->compopts |= INCLUDE_MOVEDLEFT;
01288                                 break;
01289                         case 'g':
01290                         case 'G':
01291                                 ta->compopts |= INCLUDE_MOVEDRIGHT;
01292                                 break;
01293                         case 's':
01294                         case 'S':
01295                                 ta->compopts |= INCLUDE_SIMILARLEFT;
01296                                 break;
01297                         case 'a':
01298                         case 'A':
01299                                 ta->compopts |= INCLUDE_SIMILARRIGHT;
01300                                 break;
01301                         case 'x':
01302                         case 'X':
01303                                 ta->fExit = TRUE;
01304                                 break;
01305                         default:
01306                                 idsError = 0;
01307                                 goto LUsage;
01308                         }
01309                     }
01310
01311                     if (ta->compopts == 0) {
01312                             /* default to showing all diffs (everything but same) */
01313                             ta->compopts = INCLUDE_LEFTONLY | INCLUDE_RIGHTONLY
01314                                          | INCLUDE_DIFFER | INCLUDE_MOVEDLEFT
01315                                          | INCLUDE_MOVEDRIGHT;
01316                     }
01317                     ta->savecomp = GetNextToken(NULL);
01318                     break;
01319                 case 'i':
01320                 case 'I':
01321                     ta->fInputFile = TRUE;
01322                     if (tok[2] == '1')
01323                     {
01324                         ta->fInputFileSingle = TRUE;
01325                         tok++;
01326                     }
01327                     tok += 2;
01328                     // allow (but don't require) a space between '-I' and the
01329                     // 'inputfilename' argument.
01330                     if (!*tok)
01331                         tok = GetNextToken(NULL);
01332                     if (!tok || !*tok)
01333                     {
01334                         idsError = IDS_ERROR_IARGS;
01335                         goto LUsage;
01336                     }
01337                     break;
01338                 case 'n':
01339                 case 'N':
01340                     ta->notify = GetNextToken(NULL);
01341                     break;
01342                 case 't':
01343                 case 'T':
01344                     ta->fDeep = TRUE;
01345                     break;
01346                 case 'd':
01347                 case 'D':
01348                     ta->fDeep = FALSE;     // This directory only
01349                     fDeepDefault = FALSE;
01350                     break;
01351                 case 'o':
01352                 case 'O':
01353                     fAutoExpand = FALSE;
01354                     break;
01355                 case 'p':
01356                 case 'P':
01357                     gbPerverseCompare = TRUE;
01358                     break;
01359                 case 'x':
01360                 case 'X':
01361                     {
01362                         BOOL track;
01363                         char *c = &tok[2];
01364                         if (*c == '\0') {
01365                             TrackLeftOnly = FALSE;
01366                             TrackRightOnly = FALSE;
01367                             TrackSame = FALSE;
01368                             TrackDifferent = TRUE;
01369                             TrackReadonly = TRUE;
01370                             break;
01371                         }
01372                         track = FALSE;
01373                         while (*c != '\0') {
01374                             if (toupper(*c) == 'L') {
01375                                 TrackLeftOnly = track;
01376                                 track = FALSE;
01377                             } else if (toupper(*c) == 'R') {
01378                                 TrackRightOnly = track;
01379                                 track = FALSE;
01380                             } else if (toupper(*c) == 'S') {
01381                                 TrackSame = track;
01382                                 track = FALSE;
01383                             } else if (toupper(*c) == 'D') {
01384                                 TrackDifferent = track;
01385                                 track = FALSE;
01386                             } else if (toupper(*c) == 'O') {
01387                                 TrackReadonly = track;
01388                                 track = FALSE;
01389                             } else if (toupper(*c) == 'I') {
01390                                 track = FALSE;
01391                             } else if (toupper(*c) == '-') {
01392                                 track = TRUE;
01393                             } else {
01394                                 idsError = 0;
01395                                 goto LUsage;
01396                             }
01397                             c++;
01398                         }
01399                         break;
01400                     }
01401
01402 #ifdef DEBUG
01403                 case '!':
01404                     DebugBreak();
01405                     break;
01406 #endif
01407
01408                 case '?':
01409                     {
01410                         int j = 0;
01411                         sdkdiff_usage(NULL);
01412                         for (++tok; tok[1] != '\0'; ++tok)
01413                             if ('?'==*tok) ++j;
01414
01415                         if (2==j) {
01416                             WriteProfileString(APPNAME, "SYSUK", "1");
01417                         }
01418                         return;
01419                     }
01420                 default:
01421                     idsError = 0;
01422                     goto LUsage;
01423             }
01424         } else {
01425         LFile:
01426             if (ta->first == NULL) {
01427                 ta->first = tok;
01428             } else {
01429                 ta->second = tok;
01430             }
01431         }
01432         tok = GetNextToken(NULL);
01433     }
01434
01435     if (ta->fInputFile && ta->first)
01436     {
01437         idsError = IDS_ERROR_IARGS;
01438         goto LUsage;
01439     }
01440
01441     /* set the correct depth */
01442     if (ta->fDeep)
01443         ;                       /* explicitly set -- leave it alone */
01444
01445     else ta->fDeep = fDeepDefault;  /* global default */
01446
01447     if (!ta->fInputFile)
01448     {
01449         /* any paths to scan ? */
01450         if (ta->first == NULL)
01451             return;
01452
01453         if (ta->second == NULL)
01454             ta->second = ".";
01455     }
01456     else
01457     {
01458         ta->fDeep = FALSE;
01459     }
01460
01461     SetBusy();
01462
01463     /* minimise the window if -s flag given */
01464     if (ta->savelist != NULL || ta->savecomp != NULL) {
01465         ShowWindow(hwndClient, SW_MINIMIZE);
01466     }
01467
01468     /* make an empty view */
01469     current_view = view_new(hwndRCD);
01470     DisplayMode = MODE_OUTLINE;
01471
01472     ta->view = current_view;
01473
01474     /* attempt to create a worker thread */
01475
01476     ghThread = CreateThread(NULL, 0, wd_initial, (LPVOID) ta,
01477                             0, &threadid);
01478     if (ghThread == NULL)
01479   {
01480         wd_initial( (LPVOID) ta);
01481     }
01482
01483     return;
01484
01485 LUsage:
01486     sdkdiff_usage(idsError ? LoadRcString(idsError) : NULL);
01487 } /* ParseArgs */
01488
01489
01490 void
01491 GetFontPref(void)
01492 {
01493     DeleteObject(g_hFont);
01494     g_hFont = 0;
01495
01496     GetProfileString(APPNAME, szFontFaceName, "FixedSys", g_szFontFaceName, sizeof(g_szFontFaceName));
01497     g_nFontHeight = GetProfileInt(APPNAME, szFontHeight, 12);
01498     g_fFontBold = GetProfileInt(APPNAME, szFontBold, FALSE);
01499     g_bFontCharSet = (BYTE)GetProfileInt(APPNAME, szFontCharSet, 0);
01500
01501     g_hFont = CreateFont(g_nFontHeight, 0, 0, 0,
01502                          g_fFontBold ? FW_BOLD : FW_DONTCARE,
01503                          FALSE, FALSE, FALSE,
01504                          g_bFontCharSet,
01505                          OUT_DEFAULT_PRECIS,
01506                          CLIP_LH_ANGLES|CLIP_STROKE_PRECIS,
01507                          DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
01508                          g_szFontFaceName);
01509 }
01510
01511
01512 /* create any pens/brushes, and read defaults
01513  * from the profile file for menu settings etc.
01514  */
01515 void
01516 CreateTools(void)
01517 {
01518
01519     /* standard message that table class sends us for
01520      * notifications and queries.
01521      */
01522     table_msgcode = RegisterWindowMessage(TableMessage);
01523
01524     line_numbers = GetProfileInt(APPNAME, szLineNumbers, line_numbers);
01525     outline_include = GetProfileInt(APPNAME, szFileInclude, outline_include);
01526     expand_include = GetProfileInt(APPNAME, szLineInclude, expand_include);
01527     ignore_blanks = GetProfileInt(APPNAME, szBlanks, ignore_blanks);
01528     Algorithm2 = GetProfileInt(APPNAME, szAlgorithm2, Algorithm2);
01529     mono_colours = GetProfileInt(APPNAME, szMonoColours, mono_colours);
01530     picture_mode = GetProfileInt(APPNAME, szPicture, picture_mode);
01531     hide_markedfiles = GetProfileInt(APPNAME, szHideMark, hide_markedfiles);
01532
01533     GetProfileString(APPNAME, szEditor, editor_cmdline, editor_cmdline,
01534                      sizeof(editor_cmdline));
01535
01536     g_tabwidth = GetProfileInt(APPNAME, szTabWidth, g_tabwidth);
01537
01538     InitializeCriticalSection(&CSSdkdiff);
01539
01540     GetFontPref();
01541 }
01542
01543 /* delete any pens or brushes that were created in CreateTools */
01544 void
01545 DeleteTools(void)
01546 {
01547     DeleteCriticalSection(&CSSdkdiff);
01548     DeleteObject(g_hFont);
01549 }
01550
01551
01552 /* check for messages to keep the UI working. Also check whether
01553  * we have had an abort request (IDM_ABORT), and
01554  * return TRUE if abort requested, otherwise FALSE
01555  */
01556 BOOL
01557 Poll(void)
01558 {
01559     MSG msg;
01560
01561     /* don't do the message loop in the WIN32 version since we
01562      * have multiple threads to handle that, and this is being called
01563      * on a worker thread, not the UI thread.
01564      *
01565      * in the WIN32 case, just check for abort requests
01566      */
01567
01568     /* message loop */
01569     while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
01570         if (!TranslateAccelerator(hwndClient, haccel, &msg)) {
01571             TranslateMessage(&msg);
01572             DispatchMessage(&msg);
01573         }
01574     }
01575
01576     return(bAbort);
01577 }
01578
01579 /* position child windows on a resize of the main window */
01580
01581 void
01582 DoResize(
01583          HWND hWnd
01584          )
01585 {
01586     RECT rc;
01587     int bar_width;
01588
01589     GetClientRect(hWnd, &rc);
01590     MoveWindow(hwndStatus, 0, 0, rc.right - rc.left, status_height, TRUE);
01591
01592     bar_width = (rc.right - rc.left) * BAR_WIN_WIDTH / 100;
01593
01594     /* bar window is hidden unless in expand mode */
01595     if ((DisplayMode == MODE_EXPAND) && (picture_mode)) {
01596         MoveWindow(hwndBar, 0, status_height,
01597                    bar_width, rc.bottom - status_height, TRUE);
01598         MoveWindow(hwndRCD, bar_width, status_height,
01599                    (rc.right - rc.left) - bar_width,
01600                    rc.bottom - status_height, TRUE);
01601         ShowWindow(hwndBar, SW_SHOW);
01602     } else {
01603         MoveWindow(hwndRCD, 0, status_height, (rc.right - rc.left),
01604                    rc.bottom - status_height, TRUE);
01605         ShowWindow(hwndBar, SW_HIDE);
01606     }
01607
01608 }
01609
01610 INT_PTR
01611 APIENTRY
01612 AboutBox(
01613          HWND hDlg,
01614          unsigned message,
01615          WPARAM wParam,
01616          LPARAM lParam
01617          )
01618 {
01619     char ch[256];
01620   HRESULT hr;
01621
01622     switch (message) {
01623
01624         case WM_INITDIALOG:
01625             hr = StringCchPrintf(ch, 256, "%d.%02d", Version, SubVersion);
01626       if (FAILED(hr))
01627         OutputError(hr, IDS_SAFE_PRINTF);
01628             SetDlgItemText(hDlg, IDD_VERSION, ch);
01629             return(TRUE);
01630
01631         case WM_COMMAND:
01632             switch (GET_WM_COMMAND_ID(wParam, lParam)) {
01633                 case IDOK:
01634                     EndDialog(hDlg, 0);
01635                     return(TRUE);
01636             }
01637             break;
01638     }
01639     return(FALSE);
01640 }
01641
01642
01643 /* -- menu commands ---------------------------------------------------*/
01644
01645 /* print the current view */
01646 void
01647 DoPrint(void)
01648 {
01649     Title head, foot;
01650     PrintContext context;
01651     TCHAR szPage[50];
01652     TCHAR szTitle[20];
01653   HRESULT hr;
01654
01655     /* print context contains the header and footer. Use the
01656      * default margins and printer selection
01657      */
01658
01659     /* we set the table id to be TABID_PRINTER. When the table calls
01660      * back to get text and properties, we use this to indicate
01661      * that the table refered to is the 'current_view', but in print
01662      * mode, and thus we will use different colours/fonts.
01663      */
01664     context.head = &head;
01665     context.foot = &foot;
01666     context.margin = NULL;
01667     context.pd = NULL;
01668     context.id = TABID_PRINTER;
01669
01670     /* header is filenames or just SdkDiff if no names known*/
01671     if (strlen(AppTitle) > 0) {
01672         head.ptext = AppTitle;
01673     } else {
01674         head.ptext = (LPSTR)szSdkDiff;
01675     }
01676
01677     /* header is centred, footer is right-aligned and
01678      * consists of the page number
01679      */
01680     head.props.valid = P_ALIGN;
01681     head.props.alignment = P_CENTRE;
01682     hr = StringCchCopy(szPage, 50, LoadRcString(IDS_PAGE));
01683   if (FAILED(hr))
01684     OutputError(hr, IDS_SAFE_COPY);
01685     foot.ptext = (LPSTR)szPage;
01686     foot.props.valid = P_ALIGN;
01687     foot.props.alignment = P_RIGHT;
01688
01689     if ( SendMessage(hwndRCD, TM_PRINT, 0, (LPARAM) &context)) {
01690         Trace_Status(LoadRcString(IDS_SENT_TO_PRINTER));
01691     } else {
01692         sdkdiff_UI(TRUE);
01693         hr = StringCchCopy(szTitle, 20, LoadRcString(IDS_SDKDIFF_ERROR));
01694     if (FAILED(hr))
01695       OutputError(hr, IDS_SAFE_COPY);
01696     MessageBox(hwndClient, LoadRcString(IDS_UNABLE_TO_PRINT),
01697                 szTitle, MB_ICONEXCLAMATION);
01698         sdkdiff_UI(FALSE);
01699     }
01700 }
01701
01702 /* find the next line in the current view that is
01703  * not STATE_SAME. Start from the current selection, if valid, or
01704  * from the top of the window if no selection.
01705  *
01706  */
01707 #define FindNextChange()    _FindNextChange(TRUE, TRUE)
01708 #define FindPrevChange()    _FindPrevChange(TRUE, TRUE)
01709
01710 BOOL
01711 _FindNextChange(BOOL fErrorPopup, BOOL fForceAutoCenter)
01712 {
01713     long row;
01714     long dyRowsFromTop = -1;
01715     long top = (int)SendMessage(hwndRCD, TM_TOPROW, FALSE, 0);
01716
01717     /* start from the selection or top of the window if no selection */
01718     if (selection >= 0)
01719     {
01720         row = selection + 1;
01721         if (!fForceAutoCenter)
01722             dyRowsFromTop = selection - top;
01723     }
01724     else
01725     {
01726         row = top;
01727     }
01728
01729
01730     /* find the next 'interesting' line */
01731     row = view_findchange(current_view, row, TRUE);
01732     if (row >= 0) {
01733         SetSelection(row, 1, dyRowsFromTop);
01734         return(TRUE);
01735     } else if (fErrorPopup) {
01736         sdkdiff_UI(TRUE);
01737         MessageBox(hwndClient, LoadRcString(IDS_NO_MORE_CHANGES), szSdkDiff,
01738                    MB_ICONINFORMATION|MB_OK);
01739         sdkdiff_UI(FALSE);
01740
01741     }
01742     return(FALSE);
01743 }
01744
01745 /* find the previous line in the current view that is not STATE_SAME
01746  */
01747 BOOL
01748 _FindPrevChange(BOOL fErrorPopup, BOOL fForceAutoCenter)
01749 {
01750     long row;
01751     long dyRowsFromTop = -1;
01752     long top = (int)SendMessage(hwndRCD, TM_TOPROW, FALSE, 0);
01753
01754     /* start from the selection or top of window if no selection */
01755     if (selection >= 0)
01756     {
01757         row = selection - 1;
01758         if (!fForceAutoCenter)
01759             dyRowsFromTop = selection - top;
01760     }
01761     else
01762     {
01763         row = top;
01764     }
01765
01766     /* find the previous 'interesting' line */
01767     row = view_findchange(current_view, row, FALSE);
01768     if (row >= 0) {
01769         SetSelection(row, 1, dyRowsFromTop);
01770         return(TRUE);
01771     } else if (fErrorPopup) {
01772         sdkdiff_UI(TRUE);
01773         MessageBox(hwndClient, LoadRcString(IDS_NO_PREV_CHANGES), szSdkDiff,
01774                    MB_ICONINFORMATION|MB_OK);
01775         sdkdiff_UI(FALSE);
01776
01777     }
01778     return(FALSE);
01779 }
01780
01781 #ifndef WriteProfileInt // Only needed if the profile->registry
01782 // mapping is not in use
01783 BOOL
01784 WriteProfileInt(
01785                 LPSTR AppName,
01786                 LPSTR Key,
01787                 int Int
01788                 )
01789 {       char Str[40];
01790     HRESULT hr = StringCchPrintf(Str, 40, szD, Int);
01791   if (FAILED(hr))
01792     OutputError(hr, IDS_SAFE_PRINTF);
01793     return WriteProfileString(AppName, Key, Str);
01794
01795 } /* WriteProfileInt */
01796 #endif
01797
01798
01799 /* switch to expand view of the selected line */
01800 BOOL
01801 ToExpand(
01802          HWND hwnd
01803          )
01804 {
01805
01806
01807     if (selection < 0) {
01808         return(FALSE);
01809     }
01810
01811     // nothing to do if already expanded
01812     if (view_isexpanded(current_view)) {
01813         return(FALSE);
01814     }
01815
01816     /*
01817      * note that we are starting expansion
01818      */
01819     view_expandstart(current_view);
01820
01821
01822     if (!view_isexpanded(current_view)) {
01823         /* save the current outline size and position */
01824         WINDOWPLACEMENT wp;
01825
01826         wp.length = sizeof(wp);
01827
01828         if (GetWindowPlacement(hwndClient,&wp)) {
01829             WriteProfileInt(APPNAME, szOutlineShowCmd, wp.showCmd);
01830             WriteProfileInt(APPNAME, szOutlineMaxX, wp.ptMaxPosition.x);
01831             WriteProfileInt(APPNAME, szOutlineMaxY, wp.ptMaxPosition.y);
01832             WriteProfileInt(APPNAME, szOutlineNormLeft, wp.rcNormalPosition.left);
01833             WriteProfileInt(APPNAME, szOutlineNormTop, wp.rcNormalPosition.top);
01834             WriteProfileInt(APPNAME, szOutlineNormRight, wp.rcNormalPosition.right);
01835             WriteProfileInt(APPNAME, szOutlineNormBottom, wp.rcNormalPosition.bottom);
01836             WriteProfileInt(APPNAME, szOutlineSaved, 1);
01837         }
01838
01839         /* restore the previous expanded size and position, if any */
01840         if (GetProfileInt(APPNAME, szExpandedSaved, 0)) {
01841             wp.flags                   = 0;
01842             wp.showCmd
01843             = GetProfileInt( APPNAME, szExpandShowCmd
01844                              , SW_SHOWMAXIMIZED);
01845             wp.ptMaxPosition.x
01846             = GetProfileInt( APPNAME, szExpandMaxX, 0);
01847             wp.ptMaxPosition.y
01848             = GetProfileInt( APPNAME, szExpandMaxY, 0);
01849             wp.rcNormalPosition.left
01850             = GetProfileInt( APPNAME, szExpandNormLeft
01851                              , wp.rcNormalPosition.left);
01852             wp.rcNormalPosition.top
01853             = GetProfileInt( APPNAME, szExpandNormTop
01854                              , wp.rcNormalPosition.top);
01855             wp.rcNormalPosition.right
01856             = GetProfileInt( APPNAME, szExpandNormRight
01857                              , wp.rcNormalPosition.right);
01858             wp.rcNormalPosition.bottom
01859             = GetProfileInt( APPNAME, szExpandNormBottom
01860                              , wp.rcNormalPosition.bottom);
01861             SetWindowPlacement(hwndClient,&wp);
01862         } else ShowWindow(hwndClient, SW_SHOWMAXIMIZED);
01863     }
01864
01865     /*change the view mapping to expand mode */
01866     if (view_expand(current_view, selection)) {
01867
01868         /* ok - we now have an expanded view - change status
01869          * to show this
01870          */
01871
01872         DisplayMode = MODE_EXPAND;
01873
01874         /* resize to show the graphic bar picture */
01875         DoResize(hwndClient);
01876
01877
01878         /* change button,status text-if we are not still busy*/
01879         if (!fBusy) {
01880             TCHAR szBuf[10];
01881             /* the status field when we are expanded shows the
01882              * tag field (normally the file name) for the
01883              * item we are expanding
01884              */
01885             SetStatus(view_getcurrenttag(current_view) );
01886             HRESULT hr = StringCchCopy(szBuf, 10, LoadRcString(IDS_OUTLINE));
01887       if (FAILED(hr))
01888         OutputError(hr, IDS_SAFE_COPY);
01889             SetButtonText(szBuf);
01890         }
01891
01892         // Skip to the first change.  (But don't do this if the first
01893         // line of the file itself has changed; otherwise we would skip
01894         // over it!)
01895         if (view_getrowstate(current_view, 0) == STATE_SAME) {
01896             _FindNextChange(FALSE, TRUE);
01897         }
01898
01899         return(TRUE);
01900     }
01901     return(FALSE);
01902 } /* ToExpand */
01903
01904 /* switch back to outline view - showing just the list of file names.
01905  */
01906 void
01907 ToOutline(
01908           HWND hwnd
01909           )
01910 {
01911     // if current_view is NULL, don't access it with view_xxx functions.
01912     if (!current_view)
01913         return;
01914
01915     /*
01916      * if we are in the middle of expanding, ignore the
01917      * key stroke - user can try again later
01918      */
01919     if (view_expanding(current_view)) {
01920         return;
01921     }
01922
01923     if (view_isexpanded(current_view)) {
01924         /* save the current expanded size and position */
01925         WINDOWPLACEMENT wp;
01926
01927         wp.length = sizeof(wp);
01928         if (GetWindowPlacement(hwndClient,&wp)) {
01929             WriteProfileInt(APPNAME, szExpandShowCmd, wp.showCmd);
01930             WriteProfileInt(APPNAME, szExpandMaxX, wp.ptMaxPosition.x);
01931             WriteProfileInt(APPNAME, szExpandMaxY, wp.ptMaxPosition.y);
01932             WriteProfileInt(APPNAME, szExpandNormLeft, wp.rcNormalPosition.left);
01933             WriteProfileInt(APPNAME, szExpandNormTop, wp.rcNormalPosition.top);
01934             WriteProfileInt(APPNAME, szExpandNormRight, wp.rcNormalPosition.right);
01935             WriteProfileInt(APPNAME, szExpandNormBottom, wp.rcNormalPosition.bottom);
01936             WriteProfileInt(APPNAME, szExpandedSaved, 1);
01937         }
01938
01939         /* restore the previous expanded size and position, if any */
01940         if (GetProfileInt(APPNAME, szOutlineSaved, 0)) {
01941             wp.flags = 0;
01942             wp.showCmd
01943             = GetProfileInt( APPNAME, szOutlineShowCmd
01944                              , SW_SHOWNORMAL);
01945             wp.ptMaxPosition.x
01946             = GetProfileInt( APPNAME, szOutlineMaxX, 0);
01947             wp.ptMaxPosition.y
01948             = GetProfileInt( APPNAME, szOutlineMaxY, 0);
01949             wp.rcNormalPosition.left
01950             = GetProfileInt( APPNAME, szOutlineNormLeft
01951                              , wp.rcNormalPosition.left);
01952             wp.rcNormalPosition.top
01953             = GetProfileInt( APPNAME, szOutlineNormTop
01954                              , wp.rcNormalPosition.top);
01955             wp.rcNormalPosition.right
01956             = GetProfileInt( APPNAME, szOutlineNormRight
01957                              , wp.rcNormalPosition.right);
01958             wp.rcNormalPosition.bottom
01959             = GetProfileInt( APPNAME, szOutlineNormBottom
01960                              , wp.rcNormalPosition.bottom);
01961             SetWindowPlacement(hwndClient,&wp);
01962         } else {
01963             ShowWindow(hwndClient, SW_SHOWNORMAL);
01964         }
01965     }
01966
01967     DisplayMode = MODE_OUTLINE;
01968
01969     /* switch mapping back to outline view */
01970     view_outline(current_view);
01971
01972     /* hide bar window and resize to cover */
01973     DoResize(hwndClient);
01974
01975
01976     /* change label on button */
01977     if (!fBusy) {
01978         TCHAR szBuf[8];
01979         HRESULT hr = StringCchCopy(szBuf, 8, LoadRcString(IDS_EXPAND));
01980     if (FAILED(hr))
01981       OutputError(hr, IDS_SAFE_COPY);
01982         SetButtonText(szBuf);
01983         SetStatus(NULL);
01984     }
01985 } /* ToOutline */
01986
01987 /*
01988  * if the user clicks on a MOVED line in expand mode, we jump to the
01989  * other line. We return TRUE if this was possible,  or FALSE otherwise.
01990  * If bMove is not true, then just test to see if it is possible to move
01991  * and don't actually make the selection change. (I was going to have
01992  * an IsMoved function but there seemed to be so much in common).
01993  */
01994 BOOL
01995 ToMoved(
01996         HWND hwnd,
01997         BOOL bMove
01998         )
01999 {
02000     BOOL bIsLeft;
02001     int linenr, state;
02002     long i, total;
02003
02004     if (DisplayMode != MODE_EXPAND) {
02005         return(FALSE);
02006     }
02007     if (selection < 0) {
02008         return(FALSE);
02009     }
02010
02011     state = view_getstate(current_view, selection);
02012     if (state == STATE_MOVEDLEFT || state == STATE_SIMILARLEFT) {
02013         bIsLeft = TRUE;
02014         /* get the linenr of the other copy */
02015         linenr = abs(view_getlinenr_right(current_view, selection));
02016     } else if (state == STATE_MOVEDRIGHT || state == STATE_SIMILARRIGHT) {
02017         bIsLeft = FALSE;
02018         /* get the linenr of the other copy */
02019         linenr = abs(view_getlinenr_left(current_view, selection));
02020     } else {
02021         /* not a moved line - so we can't find another copy */
02022         return(FALSE);
02023     }
02024
02025     /* search the view for this line nr */
02026     total = view_getrowcount(current_view);
02027     for (i = 0; i < total; i++) {
02028         if (bIsLeft) {
02029             if (linenr == view_getlinenr_right(current_view, i)) {
02030                 /* found it */
02031                 if (bMove) {
02032                     SetSelection(i, 1, -1);
02033                 }
02034                 return(TRUE);
02035             }
02036         } else {
02037             if (linenr == view_getlinenr_left(current_view, i)) {
02038                 if (bMove) {
02039                     SetSelection(i, 1, -1);
02040                 }
02041                 return(TRUE);
02042             }
02043         }
02044     }
02045     return(FALSE);
02046 } /* ToMoved */
02047
02048
02049 void
02050 RescanFile(
02051            HWND hwnd
02052            )
02053 {
02054     COMPITEM ci=NULL;
02055     int iStart;
02056     int iEnd;
02057     int i;
02058
02059     if (selection_nrows > 0 || DisplayMode == MODE_EXPAND) {
02060         if (DisplayMode == MODE_EXPAND) {
02061             iStart = 0;
02062             iEnd = 1;
02063         } else {
02064             iStart = selection;
02065             iEnd = iStart + selection_nrows;
02066         }
02067         for (i = iStart; i < iEnd; i++) {
02068             ci = view_getitem(current_view, i);
02069             if (ci != NULL) {
02070                 compitem_rescan(ci);
02071             }
02072         }
02073     } else {
02074         sdkdiff_UI(TRUE);
02075         MessageBox(hwndClient, LoadRcString(IDS_NOTHING_RESCANNED),
02076                    szSdkDiff, MB_ICONSTOP|MB_OK);
02077         sdkdiff_UI(FALSE);
02078
02079         return;
02080     }
02081     PostMessage(hwndClient, WM_COMMAND, IDM_UPDATE, (LPARAM) ci);
02082 } /* RescanFile */
02083
02084
02085 /*
02086  * launch an editor on the current file (the file we are expanding, or
02087  * in outline mode the selected row. Option allows selection of the
02088  * left file, the right file or the composite view of this item.
02089  * pe points to a packet of parameters that must be freed before returning.
02090  * The return value is meaningless (just to conform to CreateThread).
02091  */
02092 LONG WINAPI
02093 do_editfile(
02094             PEDITARGS pe
02095             )
02096 {
02097     VIEW view = pe->view;
02098     int option = pe->option;
02099     long L_selection = pe->selection;
02100
02101     COMPITEM item;
02102     LPSTR fname;
02103     char cmdline[MAX_PATH] = {'\0'};
02104     long selline, currentline;
02105     char * pOut = cmdline;
02106     char * pIn = editor_cmdline;
02107     STARTUPINFO si;
02108     PROCESS_INFORMATION pi;
02109   HRESULT hr;
02110
02111     item = view_getitem(view, L_selection);
02112     if (item == NULL) {
02113         sdkdiff_UI(TRUE);
02114         MessageBox(hwndClient, LoadRcString(IDS_NOTHING_TO_EDIT),
02115                    szSdkDiff, MB_ICONSTOP|MB_OK);
02116         sdkdiff_UI(FALSE);
02117
02118         return -1;
02119     }
02120
02121     fname = compitem_getfilename(view, item, option);
02122
02123     if ( 0 == fname ) {
02124         sdkdiff_UI(TRUE);
02125         MessageBox(hwndClient, LoadRcString(IDS_FILE_DOESNT_EXIST),
02126                    szSdkDiff, MB_ICONSTOP|MB_OK);
02127         sdkdiff_UI(FALSE);
02128         goto error;
02129     }
02130
02131     // convert the selected line into a line number within the file
02132     if (L_selection > 0) {
02133         selline = L_selection;
02134     } else {
02135         // if no current selection, look for the line at top of window
02136         selline = (long) SendMessage(hwndRCD, TM_TOPROW, FALSE, 0);
02137     }
02138
02139     switch ( option ) {
02140         case CI_LEFT:
02141             do {
02142                 currentline = view_getlinenr_left( view, selline);
02143
02144                 // if the selected line is not in the left file,
02145                 // backup one line and try again until we hit the top of
02146                 // file or find a line that is within the left file
02147
02148                 if (selline > 0) {
02149                     selline--;
02150                 }
02151             } while ((currentline <= 0) && (selline > 0));
02152
02153             break;
02154
02155         case CI_RIGHT:
02156             do {
02157                 currentline = view_getlinenr_right( view, selline);
02158                 if (selline > 0) {
02159                     selline--;
02160                 }
02161             } while ((currentline <= 0) && (selline > 0));
02162             break;
02163
02164         default:
02165             currentline = 1;
02166             break;
02167     }
02168
02169     if (currentline <=0) {
02170         currentline = 1;
02171     }
02172
02173
02174     while ( *pIn ) {
02175         switch ( *pIn ) {
02176             case '%':
02177                 pIn++;
02178                 switch ( *pIn ) {
02179                     case 'p':
02180                         hr = StringCchCopy( pOut, MAX_PATH, fname);
02181             if (FAILED(hr))
02182               OutputError(hr, IDS_SAFE_COPY);
02183                         while ( *pOut )
02184                             pOut++;
02185                         break;
02186
02187                     case 'l':
02188                         _ltoa( currentline, pOut, 10 );
02189                         while ( *pOut )
02190                             pOut++;
02191                         break;
02192
02193                     default:
02194                         if (IsDBCSLeadByte(*pIn) && *(pIn+1)) {
02195                             *pOut++ = *pIn++;
02196                         }
02197                         *pOut++ = *pIn;
02198                         break;
02199                 }
02200                 pIn++;
02201                 break;
02202
02203             default:
02204                 if (IsDBCSLeadByte(*pIn) && *(pIn+1)) {
02205                     *pOut++ = *pIn++;
02206                 }
02207                 *pOut++ = *pIn++;
02208                 break;
02209         }
02210     }
02211
02212     *pOut = '\0';
02213
02214     si.lpTitle = "Edit File";
02215     si.cb = sizeof(STARTUPINFO);
02216     si.lpReserved = NULL;
02217     si.lpReserved2 = NULL;
02218     si.cbReserved2 = 0;
02219     si.lpDesktop = NULL;
02220     si.dwFlags = STARTF_FORCEONFEEDBACK;
02221
02222
02223     if (!CreateProcess(NULL,
02224                        cmdline,
02225                        NULL,
02226                        NULL,
02227                        FALSE,
02228                        NORMAL_PRIORITY_CLASS,
02229                        NULL,
02230                        NULL,
02231                        &si,
02232                        &pi)) {
02233         sdkdiff_UI(TRUE);
02234         MessageBox(hwndClient, LoadRcString(IDS_FAILED_TO_LAUNCH_EDT),
02235                    szSdkDiff, MB_ICONSTOP|MB_OK);
02236         sdkdiff_UI(FALSE);
02237         goto error;
02238     }
02239
02240     /* wait for completion. */
02241     WaitForSingleObject(pi.hProcess, INFINITE);
02242
02243     /* close process and thread handles */
02244     CloseHandle(pi.hThread);
02245     CloseHandle(pi.hProcess);
02246
02247     /* finished with the filename. deletes it if it was a temp. */
02248     compitem_freefilename(item, option, fname);
02249
02250     /*
02251      * refresh cached view always .  A common trick is to edit the
02252      * composite file and then save it as a new left or right file.
02253      * Equally the user can edit the left and save as a new right.
02254      */
02255
02256     /* We want to force both files to be re-read, but it's not a terribly
02257      * good idea to throw the lines away on this thread.  Someone might
02258      * be reading them on another thread! (e.g. user tries to expand
02259      * file, seems to be taking a long time, so user decides to edit it
02260      * to have a look!
02261      */
02262
02263     /* We don't discard the lines (well, not on this thread) but we do discard
02264      * status information.  (Used to work only in expanded mode, relying on
02265      * status being reset when we go back to outline).
02266      */
02267
02268
02269     /* force the compare to be re-done */
02270     compitem_rescan(item);
02271     PostMessage(hwndClient, WM_COMMAND, IDM_UPDATE, (LPARAM)item);
02272
02273     error:
02274     HeapFree(GetProcessHeap(), NULL, pe);
02275
02276     return 0;
02277
02278 } /* do_editfile */
02279
02280
02281 /* Launch an editor on a separate thread.  It will actually get a separate
02282    process, but we want our own thread in this process.  This thread will
02283    wait until it's finished and then order up a refresh of the UI.
02284 */
02285 void
02286 do_editthread(
02287               VIEW view,
02288               int option
02289               )
02290 {
02291     PEDITARGS pe;
02292     HANDLE thread;
02293     DWORD threadid;
02294
02295     pe = (PEDITARGS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(EDITARGS));
02296     if (pe == NULL)
02297     return;
02298   pe->view = view;
02299     pe->option = option;
02300     pe->selection = selection;
02301
02302     thread = CreateThread( NULL
02303                            , 0
02304                            , (LPTHREAD_START_ROUTINE)do_editfile
02305                            , (LPVOID) pe
02306                            , 0
02307                            , &threadid
02308                          );
02309     if (thread == NULL)
02310     {
02311         do_editfile(pe);
02312     }
02313     else CloseHandle(thread);
02314
02315     // new layout not needed as do_editfile sends IDM_UPDATE
02316
02317 } /* do_editthread */
02318
02319
02320 // we are called when the right mouse button is pressed. Before we are
02321 // called, the row clicked on has been selected. We need to put up
02322 // a context menu.
02323 void
02324 OnRightClick(
02325             HWND hWnd,
02326             int x,
02327             int y)
02328 {
02329     HMENU L_hMenu, hSubMenu;
02330     POINT point;
02331     UINT uEnable;
02332
02333     if (DisplayMode == MODE_OUTLINE) {
02334         L_hMenu = LoadMenu(hInst, szOutlineMenu);
02335     } else if (DisplayMode == MODE_EXPAND) {
02336         L_hMenu = LoadMenu(hInst, szExpandMenu);
02337     } else {
02338         return;
02339     }
02340
02341
02342     hSubMenu = GetSubMenu(L_hMenu, 0);
02343
02344     // -- lots of stuff to disable inappropriate menu items --
02345
02346     // enable IDM_TOMOVED only if it is a moved line that we can
02347     // see the other copy of in this view (and only if there is a single
02348     // selected line)
02349
02350     if (DisplayMode == MODE_EXPAND) {
02351         if (ToMoved(hWnd, FALSE) && (1 == selection_nrows)) {
02352             uEnable = MF_ENABLED;
02353         } else {
02354             uEnable = MF_GRAYED;
02355         }
02356         EnableMenuItem(L_hMenu, IDM_TOMOVED, MF_BYCOMMAND | uEnable);
02357     }
02358
02359
02360     // disable next/prev buttons if no more changes in that direction
02361     if (view_findchange(current_view, selection+1, TRUE) >=0) {
02362         uEnable = MF_ENABLED;
02363     } else {
02364         uEnable = MF_GRAYED;
02365     }
02366     EnableMenuItem(hSubMenu, IDM_FCHANGE, MF_BYCOMMAND | uEnable);
02367
02368     if (view_findchange(current_view, selection-1, FALSE) >=0) {
02369         uEnable = MF_ENABLED;
02370     } else {
02371         uEnable = MF_GRAYED;
02372     }
02373     EnableMenuItem(hSubMenu, IDM_FPCHANGE, MF_BYCOMMAND | uEnable);
02374
02375     // check for left-only and right-only files and disable the appropriate
02376     // menu item
02377     // disable all editxxx and Expand if multiple files selected
02378     if ((DisplayMode == MODE_OUTLINE) && (selection_nrows > 1)) {
02379         EnableMenuItem(hSubMenu, IDM_EDITLEFT, MF_BYCOMMAND|MF_GRAYED);
02380         EnableMenuItem(hSubMenu, IDM_EDITRIGHT, MF_BYCOMMAND|MF_GRAYED);
02381         EnableMenuItem(hSubMenu, IDM_EDITCOMP, MF_BYCOMMAND|MF_GRAYED);
02382         EnableMenuItem(hSubMenu, IDM_EXPAND, MF_BYCOMMAND|MF_GRAYED);
02383     } else {
02384         COMPITEM item = view_getitem(current_view, selection);
02385         UINT uEnableLeft = MF_ENABLED;
02386         UINT uEnableRight = MF_ENABLED;
02387         UINT uEnableComp = MF_ENABLED;
02388         int state;
02389         FILEDATA fd;
02390
02391         state = compitem_getstate(item);
02392
02393         if (state == STATE_FILERIGHTONLY) {
02394             uEnableLeft = MF_GRAYED;
02395         } else if (state == STATE_FILELEFTONLY) {
02396             uEnableRight = MF_GRAYED;
02397         }
02398
02399         fd = compitem_getleftfile(item);
02400         if (fd && file_IsUnicode(fd)) {
02401             uEnableComp = MF_GRAYED;
02402         }
02403         fd = compitem_getrightfile(item);
02404         if (fd && file_IsUnicode(fd)) {
02405             uEnableComp = MF_GRAYED;
02406         }
02407
02408         EnableMenuItem(hSubMenu, IDM_EDITLEFT, MF_BYCOMMAND | uEnableLeft);
02409         EnableMenuItem(hSubMenu, IDM_EDITRIGHT, MF_BYCOMMAND | uEnableRight);
02410         EnableMenuItem(hSubMenu, IDM_EDITCOMP, MF_BYCOMMAND | uEnableComp);
02411
02412         if (DisplayMode == MODE_OUTLINE) {
02413             EnableMenuItem(hSubMenu, IDM_EXPAND, MF_BYCOMMAND|MF_ENABLED);
02414         }
02415     }
02416
02417
02418     // convert the window-based co-ord to a screen co-ord
02419     point.x = x;
02420     point.y = y;
02421     ClientToScreen(hwndRCD, &point);
02422
02423     TrackPopupMenu(
02424                   hSubMenu,
02425                   TPM_LEFTALIGN|TPM_RIGHTBUTTON,
02426                   point.x, point.y,
02427                   0,
02428                   hWnd,
02429                   NULL);
02430
02431     DestroyMenu(L_hMenu);
02432 }
02433
02434 //
02435 // refresh the display after a rescan of a given line.
02436 // try to maintain existing scroll position and selection.
02437 void
02438 OnUpdate(
02439          COMPITEM item
02440          )
02441 {
02442
02443     // save current scroll position
02444     long row = (long) SendMessage(hwndRCD, TM_TOPROW, FALSE, 0);
02445
02446     // ... and current selection
02447     long lSel = selection;
02448     long cSel = selection_nrows;
02449
02450     /* update the display.  Options or files may have changed */
02451     /* discard lines  (thereby forcing re-read).
02452      */
02453     file_discardlines(compitem_getleftfile(item));
02454     file_discardlines(compitem_getrightfile(item));
02455
02456     view_changediffoptions(current_view);
02457
02458     // tell the table view to recalculate its
02459     // idea of the width of each col etc
02460
02461     SendMessage(hwndRCD, TM_NEWLAYOUT, 0, (LPARAM) current_view);
02462
02463     // set old scroll position
02464     SendMessage(hwndRCD, TM_TOPROW, TRUE, row);
02465
02466     // set back old selection
02467     SetSelection(lSel, cSel, lSel - row);
02468
02469
02470     /* force repaint of bar window */
02471     InvalidateRect(hwndBar, NULL, TRUE);
02472 }
02473
02474 /* status bar and busy flags --------------------------------------------*/
02475
02476
02477 /* set the Text on the statusbar button to reflect the current state */
02478 void
02479 SetButtonText(
02480               LPSTR cmd
02481               )
02482 {
02483     SendMessage(hwndStatus, SM_SETTEXT, IDM_ABORT, (LPARAM) cmd);
02484 }
02485
02486 /* set the status field (left-hand part) of the status bar. */
02487 void
02488 SetStatus(
02489           LPSTR cmd
02490           )
02491 {
02492     SendMessage(hwndStatus, SM_SETTEXT, IDL_STATLAB, (LPARAM) cmd);
02493 }
02494
02495 /*
02496  * Trace_Status is called from the ssclient.lib functions to report
02497  * non-fatal errors - put them on the status line
02498  */
02499 void
02500 Trace_Status(
02501              LPSTR str
02502              )
02503 {
02504     SetStatus(str);
02505 }
02506
02507
02508 /* set the names field - the central box in the status bar */
02509 void
02510 SetNames(
02511          LPSTR names
02512          )
02513 {
02514     SendMessage(hwndStatus, SM_SETTEXT, IDL_NAMES, (LPARAM) names);
02515     if (names == NULL) {
02516         AppTitle[0] = '\0';
02517     } else {
02518         My_mbsncpy(AppTitle, names, sizeof(AppTitle));
02519     }
02520 }
02521
02522 /*
02523  * if we are not already busy, set the busy flag.
02524  *
02525  * WIN32: enter critical section first.
02526  */
02527 BOOL
02528 SetBusy(void)
02529 {
02530     HMENU hmenu;
02531
02532
02533     WDEnter();
02534
02535     if (fBusy) {
02536         WDLeave();
02537         return(FALSE);
02538     }
02539
02540
02541     fBusy = TRUE;
02542
02543     SetStatus(LoadRcString(IDS_COMPARING));
02544     /* status also on window text, so that you can see even from
02545      * the icon when the scan has finished
02546      */
02547     SetWindowText(hwndClient, LoadRcString(IDS_SCANNING));
02548
02549     /* disable appropriate parts of menu */
02550     hmenu = GetMenu(hwndClient);
02551     EnableMenuItem(hmenu, IDM_FILE,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND);
02552     EnableMenuItem(hmenu, IDM_DIR,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND);
02553     EnableMenuItem(hmenu, IDM_PRINT,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND);
02554     EnableMenuItem(hmenu, IDM_SAVELIST,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND);
02555     EnableMenuItem(hmenu, IDM_COPYFILES,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND);
02556
02557     /* enable abort only when busy */
02558     EnableMenuItem(hmenu, IDM_ABORT,MF_ENABLED|MF_BYCOMMAND);
02559     SetButtonText(LoadRcString(IDS_ABORT));  /* leave DisplayMode unchanged */
02560
02561     WDLeave();
02562     return(TRUE);
02563 } /* SetBusy */
02564
02565 void
02566 SetNotBusy(void)
02567 {
02568     HMENU hmenu;
02569   HRESULT hr;
02570
02571     /*
02572      * this function can be called from the worker thread.
02573      * Thus we must not cause any SendMessage calls to windows
02574      * owned by the main thread while holding the CritSec or we
02575      * could cause deadlock.
02576      *
02577      * the critsec is only needed to protect the fBusy flag - so
02578      * clear the busy flag last, and only get the crit sec as needed.
02579      */
02580
02581     /* reset button and status bar (clearing out busy flags) */
02582     if (current_view == NULL) {
02583         SetButtonText(LoadRcString(IDS_EXIT));
02584         SetStatus(NULL);
02585         DisplayMode = MODE_NULL;
02586     } else if (view_isexpanded(current_view)) {
02587         TCHAR szBuf[10];
02588         hr = StringCchCopy(szBuf, 10, LoadRcString(IDS_OUTLINE));
02589     if (FAILED(hr))
02590       OutputError(hr, IDS_SAFE_COPY);
02591         SetButtonText(szBuf);
02592         SetStatus(view_getcurrenttag(current_view) );
02593         DisplayMode = MODE_EXPAND;
02594     } else {
02595         TCHAR szBuf[8];
02596         hr = StringCchCopy(szBuf,8, LoadRcString(IDS_EXPAND));
02597     if (FAILED(hr))
02598       OutputError(hr, IDS_SAFE_COPY);
02599         SetButtonText(szBuf);
02600         SetStatus(NULL);
02601         DisplayMode = MODE_OUTLINE;
02602     }
02603
02604     SetWindowText(hwndClient, szSdkDiff);
02605
02606     /* re-enable appropriate parts of menu */
02607     hmenu = GetMenu(hwndClient);
02608     EnableMenuItem(hmenu, IDM_FILE,MF_ENABLED|MF_BYCOMMAND);
02609     EnableMenuItem(hmenu, IDM_DIR,MF_ENABLED|MF_BYCOMMAND);
02610     EnableMenuItem(hmenu, IDM_PRINT,MF_ENABLED|MF_BYCOMMAND);
02611     EnableMenuItem(hmenu, IDM_SAVELIST,MF_ENABLED|MF_BYCOMMAND);
02612     EnableMenuItem(hmenu, IDM_COPYFILES,MF_ENABLED|MF_BYCOMMAND);
02613
02614     /* disable abort now no longer busy */
02615     EnableMenuItem(hmenu, IDM_ABORT,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND);
02616
02617     /* clear the busy flag, protected by critical section */
02618     WDEnter();
02619
02620     fBusy = FALSE;
02621     bAbort = FALSE;
02622
02623     if (ghThread!=NULL) {
02624         CloseHandle(ghThread);
02625         ghThread = NULL;
02626     }
02627     WDLeave();
02628 } /* SetNotBusy */
02629
02630
02631 BOOL
02632 IsBusy()
02633 {
02634     BOOL bOK;
02635
02636     WDEnter();
02637     bOK = fBusy;
02638     WDLeave();
02639     return(bOK);
02640 } /* IsBusy */
02641
02642 void
02643 BusyError(void)
02644 {
02645     sdkdiff_UI(TRUE);
02646     MessageBox(hwndClient,
02647                LoadRcString(IDS_PLEASE_WAIT),
02648                szSdkDiff, MB_OK|MB_ICONSTOP);
02649     sdkdiff_UI(FALSE);
02650 } /* BusyError */
02651
02652 /* --- colour scheme --------------------------------------------------- */
02653
02654 /*
02655  * map the state given into a foreground and a background colour
02656  * for states that are highlighted. Return P_FCOLOUR if the foreground
02657  * colour (put in *foreground) is to be used, return P_FCOLOUR|P_BCOLOUR if
02658  * both *foreground and *background are to be used, or 0 if the default
02659  * colours are to be used.
02660  */
02661 UINT
02662 StateToColour(
02663               int state,
02664               BOOL bMarked,
02665               int col,
02666               DWORD * foreground,
02667               DWORD * foregroundws,
02668               DWORD * background
02669               )
02670 {
02671
02672     /* we always set both colours - allows all the colours to
02673        be controlled from the profile.  Important for the
02674        visually impaired.  So we first set the dafaults.
02675     */
02676     *foreground = rgb_defaultfore;
02677     *foregroundws = rgb_defaultforews;
02678     *background = rgb_defaultback;
02679
02680     // marked compitems are highlighted specially - for now, use the
02681     // colour scheme used for different lines in expand mode
02682     if (bMarked) {
02683         *foreground = rgb_rightfore;
02684         *background = rgb_rightback;
02685         return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02686     }
02687
02688
02689     switch (state) {
02690
02691         case STATE_DIFFER:
02692             /* files that differ are picked out in a foreground highlight,
02693              * with the default background
02694              */
02695             *foreground = rgb_outlinehi;
02696             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02697
02698         case STATE_FILELEFTONLY:
02699             /* zebra lines in both files - right file version */
02700             *foreground = rgb_fileleftfore;
02701             *background = rgb_fileleftback;
02702             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02703
02704         case STATE_FILERIGHTONLY:
02705             /* zebra lines in both files - right file version */
02706             *foreground = rgb_filerightfore;
02707             *background = rgb_filerightback;
02708             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02709
02710         case STATE_SIMILAR:
02711             /* for files that are same within expand compare options
02712              * e.g. differ only in ignorable blanks  (NYI)
02713             */
02714             *foreground = rgb_similar;
02715             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02716
02717         case STATE_LEFTONLY:
02718             /* lines only in the left file */
02719             *foreground = rgb_leftfore;
02720             *background = rgb_leftback;
02721             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02722
02723         case STATE_RIGHTONLY:
02724             /* lines only in the right file */
02725             *foreground = rgb_rightfore;
02726             *background = rgb_rightback;
02727             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02728
02729         case STATE_MOVEDLEFT:
02730             /* displaced lines in both files - left file version */
02731             *foreground = rgb_mleftfore;
02732             *background = rgb_mleftback;
02733             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02734
02735         case STATE_MOVEDRIGHT:
02736             /* displaced lines in both files - right file version */
02737             *foreground = rgb_mrightfore;
02738             *background = rgb_mrightback;
02739             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02740
02741         case STATE_SIMILARLEFT:
02742             /* zebra lines in both files - left file version */
02743             *foreground = rgb_similarleft;
02744             *background = rgb_leftback;
02745             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02746
02747         case STATE_SIMILARRIGHT:
02748             /* zebra lines in both files - right file version */
02749             *foreground = rgb_similarright;
02750             *background = rgb_rightback;
02751             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02752
02753         default:
02754
02755             /* no highlighting - default colours */
02756             return(P_FCOLOUR|P_FCOLOURWS|P_BCOLOUR);
02757     }
02758
02759 }
02760
02761 /* table window communication routines ---------------------------------*/
02762
02763 /* set a given row as the selected row in the table window */
02764 void
02765 SetSelection(
02766              long rownr,
02767              long nrows,
02768              long dyRowsFromTop
02769              )
02770 {
02771     TableSelection select;
02772
02773     select.startrow = rownr;
02774     select.startcell = 0;
02775     select.nrows = nrows;
02776     select.ncells = 1;
02777     select.dyRowsFromTop = dyRowsFromTop;
02778     SendMessage(hwndRCD, TM_SELECT, 0, (LPARAM)&select);
02779 }
02780
02781
02782 /* handle table class call back to get nr of rows and columns,
02783  * and properties for the whole table.
02784  * the 'table id' is either TABID_PRINTER - meaning we are
02785  * printing the current_view, or it is the view to
02786  * use for row/column nr information
02787  */
02788 long
02789 do_gethdr(
02790           HWND hwnd,
02791           lpTableHdr phdr
02792           )
02793 {
02794     VIEW view;
02795     BOOL bIsPrinter = FALSE;
02796
02797     if (phdr->id == TABID_PRINTER) {
02798         view = current_view;
02799         bIsPrinter = TRUE;
02800     } else {
02801         view = (VIEW) phdr->id;
02802     }
02803     if (view == NULL) {
02804         return(FALSE);
02805     }
02806
02807     phdr->nrows = view_getrowcount(view);
02808
02809     /*  three columns: line nr, tag and rest of line */
02810
02811     /*
02812      * if IDM_NONRS (no line numbers) is selected, suppress the
02813      * line-nr column entirely to save screen space
02814      */
02815     if (line_numbers == IDM_NONRS) {
02816         phdr->ncols = 2;
02817         phdr->fixedcols = 0;
02818     } else {
02819         phdr->ncols = 3;
02820         phdr->fixedcols = 1;
02821     }
02822
02823     phdr->fixedrows = 0;
02824     phdr->fixedselectable = FALSE;
02825     phdr->hseparator = TRUE;
02826     phdr->vseparator = TRUE;
02827
02828     phdr->selectmode = TM_ROW | TM_MANY;
02829     /*
02830      * find if we are in expand mode - ask for the item we are expanding.
02831      */
02832     if (view_isexpanded(view) == TRUE) {
02833
02834         /* use focus rect as selection mode in expand mode
02835          * so as not to interfere with background colours.
02836          */
02837         phdr->selectmode |= TM_FOCUS;
02838     } else {
02839         /* use default solid inversion when possible as it is clearer.*/
02840         phdr->selectmode |= TM_SOLID;
02841     }
02842
02843     /* please send TQ_SCROLL notifications when the table is scrolled */
02844     phdr->sendscroll = TRUE;
02845     if (g_hFont) {
02846         phdr->props.valid = P_FONT;
02847         phdr->props.hFont = g_hFont;
02848     }
02849
02850     return TRUE;
02851 }
02852
02853 /* respond to table callback asking for the size and properties
02854  * of each column. table id is either TABID_PRINTER (meaning the
02855  * current_view, for printing) or it is the view to be used.
02856  */
02857 long
02858 do_getprops(
02859             HWND hwnd,
02860             lpColPropsList propslist
02861             )
02862 {
02863     int i, cell;
02864     BOOL bIsPrinter = FALSE;
02865     VIEW view;
02866     HFONT hfontSystem = (HFONT)GetStockObject(SYSTEM_FONT);
02867     HFONT hfontFixed = g_hFont ? g_hFont : (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
02868
02869     if (propslist->id == TABID_PRINTER) {
02870         view = current_view;
02871         bIsPrinter = TRUE;
02872     } else {
02873         view = (VIEW) propslist->id;
02874     }
02875     if (view == NULL) {
02876         return(FALSE);
02877     }
02878
02879     if (g_hFont)
02880     {
02881         HDC hdc;
02882         TEXTMETRIC tmSystem;
02883         TEXTMETRIC tmFixed;
02884         HFONT hfont;
02885
02886         hdc = GetDC(hwnd);
02887         if (hdc)
02888         {
02889             hfont = (HFONT)SelectObject(hdc, hfontSystem);
02890             GetTextMetrics(hdc, &tmSystem);
02891             SelectObject(hdc, hfontFixed);
02892             GetTextMetrics(hdc, &tmFixed);
02893             SelectObject(hdc, hfont);
02894             ReleaseDC(hwnd, hdc);
02895
02896             if (tmFixed.tmHeight + 1 < tmSystem.tmHeight)
02897                 hfontSystem = hfontFixed;
02898         }
02899     }
02900
02901     /* the table inteface is slightly confused here. we are not
02902      * guaranteed which columns we are being asked about, so instead
02903      * of just setting each column cols[0], cols[1] etc, we need
02904      * to loop through, looking at each column in the table and
02905      * seeing which it is.
02906      */
02907     for (i = 0; i < propslist->ncols; i++) {
02908         cell = i + propslist->startcol;
02909         propslist->plist[i].props.valid = 0;
02910
02911         /* for all column widths, add on 1 for the NULL char. */
02912
02913         /*
02914          * skip the line nr column if IDM_NONRS
02915          */
02916         if (line_numbers == IDM_NONRS) {
02917             cell++;
02918         }
02919
02920         if (cell == 0) {
02921             /* properties for line nr column */
02922
02923             propslist->plist[i].nchars = view_getwidth(view, 0)+1;
02924             propslist->plist[i].props.valid |= P_ALIGN | P_FONT;
02925             propslist->plist[i].props.alignment = P_CENTRE;
02926             propslist->plist[i].props.hFont = hfontSystem;
02927         } else if (cell == 1) {
02928
02929             /* properties for tag field */
02930             propslist->plist[i].nchars = view_getwidth(view, 1)+1;
02931             propslist->plist[i].props.valid |= P_ALIGN | P_FONT;
02932             propslist->plist[i].props.alignment = P_LEFT;
02933             propslist->plist[i].props.hFont = hfontSystem;
02934         } else {
02935             /* properties for main text column -
02936              * use a fixed font unless printing (if
02937              * printing, best to use the default font, because
02938              * of resolution differences.
02939              * add on 8 chars to the width to ensure that
02940              * the width of lines beginning with tabs
02941              * works out ok
02942              */
02943             propslist->plist[i].nchars = view_getwidth(view, 2)+1;
02944             propslist->plist[i].props.valid |= P_ALIGN;
02945             propslist->plist[i].props.alignment = P_LEFT;
02946             if (!bIsPrinter) {
02947                 propslist->plist[i].props.valid |= P_FONT;
02948                 propslist->plist[i].props.hFont = hfontFixed;
02949             }
02950         }
02951     }
02952     return (TRUE);
02953 }
02954
02955 /* respond to a table callback asking for the contents of individual cells.
02956  * table id is either TABID_PRINTER, or it is a pointer to the view
02957  * to use for data. If going to the printer, don't set the
02958  * colours (stick to black and white).
02959  */
02960 long
02961 do_getdata(
02962            HWND hwnd,
02963            lpCellDataList cdlist
02964            )
02965 {
02966     int start, endcell, col, i;
02967     int state, markedstate;
02968     lpCellData cd;
02969     VIEW view;
02970     LPSTR textp;
02971     LPWSTR pwzText;
02972     BOOL bIsPrinter = FALSE;
02973
02974     if (cdlist->id == TABID_PRINTER) {
02975         view = current_view;
02976         bIsPrinter = TRUE;
02977     } else {
02978         view = (VIEW) cdlist->id;
02979     }
02980
02981     /* set state data */
02982     state = view_getstate(view, cdlist->row);
02983     markedstate = view_getmarkstate(view, cdlist->row);
02984     start = cdlist->startcell;
02985     endcell = cdlist->ncells + start;
02986     if (cdlist->row >= view_getrowcount(view)) {
02987         return(FALSE);
02988     }
02989     for (i = start; i < endcell; i++) {
02990         cd = &cdlist->plist[i - start];
02991
02992
02993         /* skip the line number column if IDM_NONRS */
02994         if (line_numbers == IDM_NONRS) {
02995             col = i+1;
02996         } else {
02997             col = i;
02998         }
02999
03000         /* set colour of text to mark out
03001          * lines that are changed, if not printer - for the
03002          * printer everything should stay in the default colours
03003          * or it will be grayed out and look ugly
03004          */
03005
03006         if ( !bIsPrinter
03007           || (GetProfileInt(APPNAME, szColourPrinting, 0) > 0)) {
03008
03009             /* convert the state of the requested row into a
03010              * colour scheme. returns P_FCOLOUR and/or
03011              * P_BCOLOUR if it sets either of the colours
03012              */
03013             cd->props.valid |=
03014             StateToColour(
03015                          state,
03016                          markedstate,
03017                          col,
03018                          &cd->props.forecolour,
03019                          &cd->props.forecolourws,
03020                          &cd->props.backcolour);
03021         }
03022
03023         textp = view_gettext(view, cdlist->row, col);
03024         if (cd->nchars != 0) {
03025             if (textp == NULL) {
03026                 cd->ptext[0] = '\0';
03027             } else {
03028                 My_mbsncpy(cd->ptext, textp, cd->nchars -1);
03029                 cd->ptext[cd->nchars - 1] = '\0';
03030             }
03031         }
03032
03033         pwzText = view_gettextW(view, cdlist->row, col);
03034         if (pwzText && cd->nchars)
03035         {
03036             cd->pwzText = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cd->nchars * sizeof(*cd->pwzText));
03037             if (cd->pwzText == NULL)
03038         return (FALSE);
03039       wcsncpy(cd->pwzText, pwzText, cd->nchars -1);
03040             cd->pwzText[cd->nchars - 1] = 0;
03041         }
03042         else
03043         {
03044             HeapFree(GetProcessHeap(), NULL, cd->pwzText);
03045             cd->pwzText = 0;
03046         }
03047
03048     }
03049     return(TRUE);
03050 }
03051
03052 /* table window has finished with this view. it can be deleted.
03053  */
03054 void
03055 SvrClose(void)
03056 {
03057     view_delete(current_view);
03058     current_view = NULL;
03059
03060     /* hide picture - only visible when we are in MODE_EXPAND */
03061     DisplayMode = MODE_NULL;
03062     DoResize(hwndClient);
03063
03064     /* if we already busy when closing this view (ie
03065      * we are in the process of starting a new scan,
03066      * then leave the status bar alone, otherwise
03067      * we should clean up the state of the status bar
03068      */
03069     if (!fBusy) {
03070         SetButtonText(LoadRcString(IDS_EXIT));
03071         SetNames(NULL);
03072         SetStatus(NULL);
03073
03074     }
03075
03076 } /* SvrClose */
03077
03078
03079 /* handle callbacks and notifications from the table class */
03080 long
03081 TableServer(
03082             HWND hwnd,
03083             WPARAM cmd,
03084             LPARAM lParam
03085             )
03086 {
03087     lpTableHdr phdr;
03088     lpColPropsList proplist;
03089     lpCellDataList cdlist;
03090     lpTableSelection pselect;
03091
03092     switch (cmd) {
03093         case TQ_GETSIZE:
03094             /* get the nr of rows and cols in this table */
03095             phdr = (lpTableHdr) lParam;
03096             return(do_gethdr(hwnd, phdr));
03097
03098         case TQ_GETCOLPROPS:
03099             /* get the size and properties of each column */
03100             proplist = (lpColPropsList) lParam;
03101             return (do_getprops(hwnd, proplist));
03102
03103         case TQ_GETDATA:
03104             /* get the contents of individual cells */
03105             cdlist = (lpCellDataList) lParam;
03106             return (do_getdata(hwnd, cdlist));
03107
03108
03109         case TQ_SELECT:
03110             /* selection has changed */
03111         case TQ_ENTER:
03112             /* user has double-clicked or pressed enter */
03113
03114             pselect = (lpTableSelection) lParam;
03115
03116             /* store location for use in later search (IDM_FCHANGE) */
03117
03118             /*
03119              * convert selection so that it always runs forward - we
03120              * do not need to know where the anchor vs endpoint is
03121              */
03122             if (pselect->nrows == 0) {
03123                 selection = -1;
03124                 selection_nrows = 0;
03125             } else {
03126                 if (pselect->nrows < 0) {
03127                     selection = pselect->startrow + pselect->nrows + 1;
03128                     selection_nrows = -pselect->nrows;
03129                 } else {
03130                     selection = (int) pselect->startrow;
03131                     selection_nrows = pselect->nrows;
03132                 }
03133                 if (cmd == TQ_ENTER) {
03134                     /* try to expand this row */
03135                     if (!ToExpand(hwnd)) {
03136                         /* expand failed - maybe this
03137                          * is a moved line- show the other
03138                          * copy
03139                          */
03140                         ToMoved(hwnd, TRUE);
03141                     }
03142
03143                 }
03144             }
03145             break;
03146
03147         case TQ_CLOSE:
03148             /* close this table - table class no longer needs data*/
03149             SvrClose();
03150             break;
03151
03152         case TQ_SCROLL:
03153             /* notification that the rows visible in the window
03154              * have changed -change the current position lines in
03155              * the graphic bar view (the sections picture)
03156              */
03157             if (picture_mode) {
03158                 BarDrawPosition(hwndBar, NULL, TRUE);
03159             }
03160             break;
03161
03162         case TQ_TABS:
03163             if (lParam != 0) {
03164                 LONG * pTabs = (LONG *) lParam;
03165                 *pTabs = g_tabwidth;
03166             }
03167             return TRUE;
03168
03169         case TQ_SHOWWHITESPACE:
03170             if (lParam != 0) {
03171                 LONG * pbShowWhitespace = (LONG *) lParam;
03172                 *pbShowWhitespace = (show_whitespace && view_isexpanded(current_view));
03173             }
03174             return TRUE;
03175
03176         default:
03177             return(FALSE);
03178     }
03179     return(TRUE);
03180 }
03181
03182 /* --- thread worker routines (called synchoronously in WIN16)--------------*/
03183
03184 /*
03185  * called on worker thread (not UI thread) to handle the work
03186  * requested on the command line.
03187  *
03188  * arg is a pointer to a THREADARGS block allocated using HeapAlloc. This
03189  * needs to be freed before exiting.
03190  */
03191 DWORD WINAPI
03192 wd_initial(
03193            LPVOID arg
03194            )
03195 {
03196     PTHREADARGS pta = (PTHREADARGS) arg;
03197     COMPLIST cl = 0;
03198     COMPITEM ci = NULL;
03199     BOOL fOK = TRUE;
03200     BOOL fPairs = TRUE;
03201
03202     /* build a complist from these args,
03203      * and register with the view we have made
03204      */
03205
03206     {
03207         cl = complist_args(pta->first, pta->second, pta->view, pta->fDeep);
03208     }
03209
03210     /*
03211      * the app can be closed during execution of this routine if
03212      * we don't retain BUSY. This means we can be expanding structures
03213      * while the main thread is freeing them.
03214      *
03215      */
03216
03217     if (cl == NULL || !fOK) {
03218         view_close(pta->view);
03219         HeapFree(GetProcessHeap(), NULL, pta);
03220         SetNotBusy();
03221         return 0;
03222     }
03223
03224
03225     /* if savelist or savecomp was selected, write out the list or comp file */
03226     if (pta->savelist != NULL || pta->savecomp != NULL) {
03227         if (pta->savelist != NULL) {
03228             complist_savelist(cl, pta->savelist, pta->listopts);
03229         }
03230
03231         if (pta->savecomp != NULL) {
03232             /* if list item was selected, use that */
03233             if (selection >= 0) {
03234                 ci = view_getitem(pta->view, selection);
03235           }
03236           else {
03237               /* default to first visible item, if any */
03238               if (view_getrowcount(pta->view) > 0) {
03239                   ci = view_getitem(pta->view, 0);
03240               }
03241           }
03242           compitem_savecomp(pta->view, ci, pta->savecomp, pta->compopts);
03243         }
03244         HeapFree(GetProcessHeap(), NULL, pta);
03245         SetNotBusy();
03246
03247         /* exit if -x was set */
03248         if (pta->fExit) {
03249             exit(0);
03250         }
03251     }
03252
03253
03254     /* if savelist was selected, write out the list and exit if -x was set */
03255     if (pta->savelist != NULL) {
03256         complist_savelist(cl, pta->savelist, pta->listopts);
03257         HeapFree(GetProcessHeap(), NULL, pta);
03258         SetNotBusy();
03259         if (pta->fExit) exit(0);
03260     }
03261
03262     /* if there was only one file, expand it, unless... */
03263     if (view_getrowcount(pta->view) == 1) {
03264         /* The interesting case is where there are a bunch of files
03265            but only one of them is Different.  In this case we do
03266            NOT expand it even though it is the only one showing.
03267         */
03268
03269         UINT nItems = complist_itemcount(cl);
03270         /* And even then, don't expand if the option said don't.
03271         */
03272         if (nItems==1 && fAutoExpand) {
03273             SetSelection(0, 1, -1);
03274             ToExpand(hwndClient);
03275         }
03276     }
03277
03278
03279     HeapFree(GetProcessHeap(), NULL, pta);
03280     SetNotBusy();
03281     return(0);
03282 } /* wd_initial */
03283
03284
03285 /*
03286  * called on worker thread (not UI thread) to handle a Dir request
03287  * (called synchronously if WIN16).
03288  */
03289 DWORD WINAPI
03290 wd_dirdialog(LPVOID arg)
03291 {
03292
03293     VIEW view = (VIEW) arg;
03294
03295     /* make a COMPLIST using the directory dialog,
03296      * and notify the view
03297      */
03298     if (complist_dirdialog(view) == NULL) {
03299         view_close(view);
03300     }
03301
03302     /* all done! */
03303     SetNotBusy();
03304     return(0);
03305 }
03306
03307 /*
03308  * called on worker thread to do a copy-files operation
03309  *
03310  */
03311 DWORD WINAPI
03312 wd_copy(
03313         LPVOID arg
03314         )
03315 {
03316
03317     VIEW view = (VIEW) arg;
03318
03319     complist_copyfiles(view_getcomplist(view), NULL, 0);
03320
03321     SetNotBusy();
03322
03323     return(0);
03324 }
03325
03326
03327 /*----- winproc for main window ---------------------------------
03328  *
03329  */
03330
03331 INT_PTR
03332 APIENTRY
03333 MainWndProc(
03334             HWND hWnd,
03335             UINT message,
03336             WPARAM wParam,
03337             LPARAM lParam
03338             )
03339 {
03340     char str[32];
03341     long ret;
03342     DWORD threadid;
03343   HRESULT hr;
03344
03345     switch (message) {
03346
03347         case WM_CREATE:
03348
03349             /* initialise menu options to default/saved
03350              * option settings
03351              */
03352
03353 #define CHECKMENU(id, fChecked)  \
03354           CheckMenuItem(hMenu, (id), (fChecked) ? MF_CHECKED:MF_UNCHECKED)
03355
03356             /* outline_include options */
03357             CHECKMENU(IDM_OUTLINE_INCSAME,   (outline_include & INCLUDE_SAME));
03358             CHECKMENU(IDM_OUTLINE_INCLEFT,   (outline_include & INCLUDE_LEFTONLY));
03359             CHECKMENU(IDM_OUTLINE_INCRIGHT,  (outline_include & INCLUDE_RIGHTONLY));
03360             CHECKMENU(IDM_OUTLINE_INCDIFFER, (outline_include & INCLUDE_DIFFER));
03361
03362             /* expand_include options */
03363             CHECKMENU(IDM_EXPAND_INCSAME,         (expand_include & INCLUDE_SAME));
03364             CHECKMENU(IDM_EXPAND_INCLEFT,         (expand_include & INCLUDE_LEFTONLY));
03365             CHECKMENU(IDM_EXPAND_INCRIGHT,        (expand_include & INCLUDE_RIGHTONLY));
03366             CHECKMENU(IDM_EXPAND_INCMOVEDLEFT,    (expand_include & INCLUDE_MOVEDLEFT));
03367             CHECKMENU(IDM_EXPAND_INCMOVEDRIGHT,   (expand_include & INCLUDE_MOVEDRIGHT));
03368             CHECKMENU(IDM_EXPAND_INCSIMILARLEFT,  (expand_include & INCLUDE_SIMILARLEFT));
03369             CHECKMENU(IDM_EXPAND_INCSIMILARRIGHT, (expand_include & INCLUDE_SIMILARRIGHT));
03370
03371             /* other options */
03372             CHECKMENU(line_numbers, TRUE);
03373             CHECKMENU(expand_mode, TRUE);
03374             CHECKMENU(IDM_IGNBLANKS, ignore_blanks);
03375             CHECKMENU(IDM_SHOWWHITESPACE, show_whitespace);
03376             CHECKMENU(IDM_ALG2, Algorithm2);
03377             CHECKMENU(IDM_MONOCOLS, mono_colours);
03378             CHECKMENU(IDM_PICTURE, picture_mode);
03379             CHECKMENU(IDM_HIDEMARK, hide_markedfiles);
03380 #undef CHECKMENU
03381
03382             /* nothing currently displayed */
03383             DisplayMode = MODE_NULL;
03384
03385             break;
03386
03387         case WM_SYSCOLORCHANGE:
03388             {
03389                 HIGHCONTRAST hc;
03390
03391                 hc.cbSize = sizeof(hc);
03392                 SystemParametersInfo(SPI_GETHIGHCONTRAST,0 ,&hc, 0);
03393
03394                 mono_colours = (hc.dwFlags & HCF_HIGHCONTRASTON);
03395                 if (mono_colours) {
03396                     SetMonoColours();
03397                 } else {
03398                     SetColours();
03399                 }
03400
03401                 CheckMenuItem(hMenu, IDM_MONOCOLS,
03402                               mono_colours? MF_CHECKED:MF_UNCHECKED);
03403                 hr = StringCchPrintf(str, 32, szD, mono_colours);
03404         if (FAILED(hr))
03405           OutputError(hr, IDS_SAFE_PRINTF);
03406                 WriteProfileString(APPNAME, szMonoColours, str);
03407                 SendMessage(hwndRCD, message, wParam, lParam);
03408                 SendMessage(hwndStatus, message, wParam, lParam);
03409                 SendMessage(hwndBar, message, wParam, lParam);
03410
03411                 /* The diffs are still valid, but force a re-display
03412                  * of bar window and main table.
03413                  */
03414                 SendMessage(hwndBar, WM_COMMAND, IDM_MONOCOLS, 0);
03415                 InvalidateRect(hwndBar, NULL, TRUE);
03416                 view_changeviewoptions(current_view);
03417             }
03418             break;
03419
03420         case WM_COMMAND:
03421             switch (GET_WM_COMMAND_ID(wParam, lParam)) {
03422                 case IDM_EXIT:
03423                     if (ghThread!=NULL) {
03424                         bAbort = TRUE;
03425                         SetStatus(LoadRcString(IDS_ABORT_PENDING));
03426                         break;
03427                     }
03428                     if (!view_isexpanded(current_view)) {
03429                         /* save the current outline size and position */
03430                         WINDOWPLACEMENT wp;
03431                         wp.length = sizeof(wp);
03432                         if (GetWindowPlacement(hwndClient,&wp)) {
03433                             WriteProfileInt(APPNAME, szOutlineShowCmd, wp.showCmd);
03434                             WriteProfileInt(APPNAME, szOutlineMaxX, wp.ptMaxPosition.x);
03435                             WriteProfileInt(APPNAME, szOutlineMaxY, wp.ptMaxPosition.y);
03436                             WriteProfileInt(APPNAME, szOutlineNormLeft, wp.rcNormalPosition.left);
03437                             WriteProfileInt(APPNAME, szOutlineNormTop, wp.rcNormalPosition.top);
03438                             WriteProfileInt(APPNAME, szOutlineNormRight, wp.rcNormalPosition.right);
03439                             WriteProfileInt(APPNAME, szOutlineNormBottom, wp.rcNormalPosition.bottom);
03440                             WriteProfileInt(APPNAME, szOutlineSaved, 1);
03441                         }
03442                     } else {
03443                         /* save the current expanded size and position */
03444                         WINDOWPLACEMENT wp;
03445                         wp.length = sizeof(wp);
03446                         if (GetWindowPlacement(hwndClient,&wp)) {
03447                             WriteProfileInt(APPNAME, szExpandShowCmd, wp.showCmd);
03448                             WriteProfileInt(APPNAME, szExpandMaxX, wp.ptMaxPosition.x);
03449                             WriteProfileInt(APPNAME, szExpandMaxY, wp.ptMaxPosition.y);
03450                             WriteProfileInt(APPNAME, szExpandNormLeft, wp.rcNormalPosition.left);
03451                             WriteProfileInt(APPNAME, szExpandNormTop, wp.rcNormalPosition.top);
03452                             WriteProfileInt(APPNAME, szExpandNormRight, wp.rcNormalPosition.right);
03453                             WriteProfileInt(APPNAME, szExpandNormBottom, wp.rcNormalPosition.bottom);
03454                             WriteProfileInt(APPNAME, szExpandedSaved, 1);
03455                         }
03456                     }
03457                     DestroyWindow(hWnd);
03458                     break;
03459
03460                 case IDM_ABORT:
03461                     /* abort menu item, or status bar button.
03462                      * the status bar button text gives the appropriate
03463                      * action depending on our state - abort, outline
03464                      * or expand. But the command sent is always
03465                      * IDM_ABORT. Thus we need to check the state
03466                      * to see what to do. If we are busy, set the abort
03467                      * flag. If there is nothing to view,
03468                      * exit, otherwise switch outline<->expand
03469                      */
03470                     if (IsBusy()) {
03471                         bAbort = TRUE;
03472                         SetStatus(LoadRcString(IDS_ABORT_PENDING));
03473                     } else if (DisplayMode == MODE_NULL) {
03474                         DestroyWindow(hWnd);
03475                     } else if (DisplayMode == MODE_EXPAND) {
03476                         ToOutline(hWnd);
03477                     } else {
03478                         ToExpand(hWnd);
03479                     }
03480                     break;
03481
03482                 case IDM_FILE:
03483                     /* select two files and compare them */
03484                     if (SetBusy()) {
03485
03486
03487                         /* close the current view */
03488                         view_close(current_view);
03489
03490                         /* make a new empty view */
03491                         current_view = view_new(hwndRCD);
03492
03493                         /* make a COMPLIST using the files dialog,
03494                          * and notify the view
03495                          */
03496                         if (complist_filedialog(current_view) == NULL) {
03497                             view_close(current_view);
03498                         }
03499
03500                         /* all done! */
03501                         SetNotBusy();
03502                     } else {
03503                         BusyError();
03504                     }
03505                     break;
03506
03507                 case IDM_DIR:
03508
03509                     /* read two directory names, scan them and
03510                      * compare all the files and subdirs.
03511                      */
03512                     if (SetBusy()) {
03513
03514                         /* close the current view */
03515                         view_close(current_view);
03516
03517                         /* make a new empty view */
03518                         current_view = view_new(hwndRCD);
03519
03520                         ghThread = CreateThread(NULL, 0, wd_dirdialog,
03521                                                 (LPVOID) current_view, 0, &threadid);
03522
03523                         if (ghThread == NULL)
03524                         {
03525
03526                             /*
03527                              * either we are on WIN16, or the
03528                              * thread call failed. continue
03529                              * single-threaded.
03530                              */
03531                             wd_dirdialog( (LPVOID) current_view);
03532
03533
03534                         }
03535
03536                     } else {
03537                         BusyError();
03538                     }
03539                     break;
03540
03541                 case IDM_CLOSE:
03542                     /* close the output list -
03543                      * discard all results so far
03544                      */
03545                     if (!IsBusy()) {
03546                         view_close(current_view);
03547                     }
03548                     break;
03549
03550                 case IDM_PRINT:
03551                     /* print the current view -
03552                      * either the outline list of filenames,
03553                      * or the currently expanded file.
03554                      */
03555                     if (!IsBusy()) {
03556                         DoPrint();
03557                     } else {
03558                         BusyError();
03559                     }
03560                     break;
03561
03562                 case IDM_TIME:
03563                     /* show time it took */
03564                     {       char msg[50];
03565                         DWORD tim;
03566                         if (IsBusy()) {
03567                             BusyError();
03568                         } else {
03569                             tim = complist_querytime();
03570                             hr = StringCchPrintf(msg, 50, LoadRcString(IDS_SECONDS), tim/1000, tim%1000);
03571               if (FAILED(hr))
03572                 OutputError(hr, IDS_SAFE_PRINTF);
03573                             Trace_Status(msg);
03574                         }
03575                     }
03576                     break;
03577
03578                 case IDM_TRACE:
03579                     /* enable tracing */
03580                     bTrace = TRUE;
03581                     Trace_Status(LoadRcString(IDS_TRACING_ENABLED));
03582                     break;
03583
03584                 case IDM_TRACEOFF:
03585                     /* enable tracing */
03586                     bTrace = FALSE;
03587                     Trace_Status(LoadRcString(IDS_TRACING_DISABLED));
03588                     break;
03589
03590                 case IDM_SAVELIST:
03591                     /* allow user to save list of same/different files
03592                      * to a text file. dialog box to give filename
03593                      * and select which types of file to include
03594                      */
03595                     if (current_view == NULL) {
03596                         MessageBox(hWnd,
03597                                    LoadRcString(IDS_CREATE_DIFF_LIST),
03598                                    szSdkDiff, MB_OK|MB_ICONSTOP);
03599                         break;
03600                     }
03601
03602                     complist_savelist(view_getcomplist(current_view), NULL, outline_include);
03603                     break;
03604
03605                 case IDM_COPYFILES:
03606                     /*
03607                      * copy files that are same/different to a new
03608                      * root directory. dialog box allows user
03609                      * to select new root and inclusion options
03610                      */
03611                     if (current_view == NULL) {
03612                         MessageBox(hWnd,
03613                                    LoadRcString(IDS_CREATE_DIFF_LIST),
03614                                    szSdkDiff, MB_OK|MB_ICONSTOP);
03615                         break;
03616                     }
03617
03618                     if (SetBusy()) {
03619                         ghThread = CreateThread(NULL, 0, wd_copy,
03620                                                 (LPVOID) current_view, 0, &threadid);
03621                         if (ghThread == NULL)
03622                         {
03623                             wd_copy( (LPVOID) current_view);
03624                         }
03625
03626                     } else {
03627                         BusyError();
03628                     }
03629
03630                     break;
03631
03632                 case IDM_ABOUT:
03633                     ShellAbout( hWnd,
03634                                 (LPTSTR)szSdkDiff,
03635                                 LoadRcString(IDS_TOOL_DESCRIPTION),
03636                                 LoadIcon(hInst, szSdkDiff)
03637                               );
03638                     break;
03639
03640                 case IDM_CONTENTS:
03641                     /* Help contents */
03642           TCHAR pszHelp[MAX_PATH];
03643           memset(pszHelp, 0, MAX_PATH);
03644           hr = StringCchCopy(pszHelp, MAX_PATH, pszWorkingDirectoryName);
03645           if (FAILED(hr))
03646             OutputError(hr, IDS_SAFE_COPY);
03647           hr = StringCchCat(pszHelp, MAX_PATH, "sdkdiff.hlp");
03648           if (FAILED(hr))
03649             OutputError(hr, IDS_SAFE_CAT);
03650           WinHelp(hWnd, pszHelp, HELP_INDEX, 0);
03651                     break;
03652
03653                     /* launch an editor on the current item - left, right or
03654                      * composite view
03655                      */
03656                 case IDM_EDITLEFT:
03657                     do_editthread(current_view, CI_LEFT);
03658                     break;
03659
03660                 case IDM_EDITRIGHT:
03661                     do_editthread(current_view, CI_RIGHT);
03662                     break;
03663
03664                 case IDM_EDITCOMP:
03665                     {
03666                         COMPITEM item = view_getitem(current_view, selection);
03667                         FILEDATA fdLeft;
03668                         FILEDATA fdRight;
03669
03670                         fdLeft = compitem_getleftfile(item);
03671                         fdRight = compitem_getrightfile(item);
03672                         if ((fdLeft && file_IsUnicode(fdLeft)) || (fdRight && file_IsUnicode(fdRight))) {
03673                             MessageBox(hWnd, LoadRcString(IDS_NOCOMPUNICODE),
03674                                        szSdkDiff, MB_OK);
03675                         } else {
03676                             do_editthread(current_view, CI_COMP);
03677                         }
03678                     }
03679                     break;
03680
03681                     /* allow customisation of the editor command line */
03682                 case IDM_SETEDIT:
03683                     if (StringInput(editor_cmdline, sizeof(editor_cmdline),
03684                                     LoadRcString(IDS_EDITOR_COMMAND),
03685                                     (LPSTR)szSdkDiff, editor_cmdline)) {
03686                         WriteProfileString(APPNAME, szEditor,
03687                                            editor_cmdline);
03688                     }
03689                     break;
03690
03691                 case IDM_SETTABWIDTH:
03692                     {
03693                         char sz[32];
03694                         int n;
03695
03696 LTabWidth_tryagain:
03697                         hr = StringCchPrintf(sz, 32, "%d", g_tabwidth);
03698             if (FAILED(hr))
03699               OutputError(hr, IDS_SAFE_PRINTF);
03700                         if (StringInput(sz, sizeof(sz),
03701                                         LoadRcString(IDS_TABWIDTH),
03702                                         (LPSTR)szSdkDiff, sz))
03703                         {
03704                             n = atoi(sz);
03705                             if (n <= 0 || n > 100)
03706                             {
03707                                 MessageBox(hWnd,
03708                                            LoadRcString(IDS_BAD_TABWIDTH),
03709                                            szSdkDiff, MB_OK);
03710                                 goto LTabWidth_tryagain;
03711                             }
03712                             WriteProfileInt(APPNAME, szTabWidth, n);
03713                             g_tabwidth = n;
03714                             SendMessage(hwndRCD, TM_SETTABWIDTH, 0, n);
03715                         }
03716                     }
03717                     break;
03718
03719                 case IDM_TABWIDTH4:
03720                 case IDM_TABWIDTH8:
03721                     g_tabwidth = (GET_WM_COMMAND_ID(wParam, lParam) == IDM_TABWIDTH8) ? 8 : 4;
03722                     SendMessage(hwndRCD, TM_SETTABWIDTH, 0, g_tabwidth);
03723                     break;
03724
03725                 case IDM_SETFONT:
03726                     {
03727                         CHOOSEFONT cf;
03728                         LOGFONT lf;
03729                         char szFace[LF_FACESIZE];
03730
03731                         hr = StringCchCopy(szFace, LF_FACESIZE, g_szFontFaceName);
03732             if (FAILED(hr))
03733               OutputError(hr, IDS_SAFE_COPY);
03734
03735                         memset(&lf, 0, sizeof(lf));
03736                         hr = StringCchCopy(lf.lfFaceName, LF_FACESIZE, szFace);
03737             if (FAILED(hr))
03738               OutputError(hr, IDS_SAFE_COPY);
03739                         lf.lfWeight = g_fFontBold ? FW_BOLD : FW_DONTCARE;
03740                         lf.lfHeight = g_nFontHeight;
03741                         lf.lfCharSet = g_bFontCharSet;
03742
03743                         memset(&cf, 0, sizeof(cf));
03744                         cf.lStructSize = sizeof(CHOOSEFONT);
03745                         cf.hwndOwner = hWnd;
03746                         cf.lpLogFont = &lf;
03747                         cf.Flags = CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|
03748                                 CF_SCREENFONTS|CF_LIMITSIZE;
03749                         cf.nSizeMin = 8;
03750                         cf.nSizeMax = 36;
03751                         cf.lpszStyle = szFace;
03752                         if (ChooseFont(&cf))
03753                             {
03754                             hr = StringCchCopy(g_szFontFaceName, LF_FACESIZE, lf.lfFaceName);
03755               if (FAILED(hr))
03756                 OutputError(hr, IDS_SAFE_COPY);
03757                             g_fFontBold = (lf.lfWeight == FW_BOLD);
03758                             g_nFontHeight = lf.lfHeight;
03759                             g_bFontCharSet = lf.lfCharSet;
03760
03761                             WriteProfileString(APPNAME, szFontFaceName, g_szFontFaceName);
03762                             WriteProfileInt(APPNAME, szFontHeight, g_nFontHeight);
03763                             WriteProfileInt(APPNAME, szFontBold, g_fFontBold);
03764                             WriteProfileInt(APPNAME, szFontCharSet, g_bFontCharSet);
03765
03766                             GetFontPref();
03767
03768                             view_changeviewoptions(current_view);
03769                             }
03770                     }
03771                     break;
03772
03773
03774
03775                 case IDM_LNRS:
03776                 case IDM_RNRS:
03777                 case IDM_NONRS:
03778
03779                     /* option selects whether the line nrs displayed
03780                      * in expand mode are the line nrs in the left
03781                      * file, the right file or none
03782                      */
03783
03784                     CheckMenuItem(GetMenu(hWnd),
03785                                   line_numbers, MF_UNCHECKED);
03786                     line_numbers = GET_WM_COMMAND_ID(wParam, lParam);
03787                     CheckMenuItem(GetMenu(hWnd), line_numbers, MF_CHECKED);
03788                     hr = StringCchPrintf(str, 32, szD, line_numbers);
03789           if (FAILED(hr))
03790             OutputError(hr, IDS_SAFE_PRINTF);
03791                     WriteProfileString(APPNAME, szLineNumbers, str);
03792
03793                     /* change the display to show the line nr style
03794                      * chosen
03795                      */
03796
03797                     view_changeviewoptions(current_view);
03798                     break;
03799
03800                 /*
03801                  * options selecting which lines to include in the
03802                  * expand listing, based on their state
03803                  */
03804                 case IDM_EXPAND_INCSAME:
03805                         /* toggle flag in expand_include options */
03806                         expand_include ^= INCLUDE_SAME;
03807
03808                         /* check/uncheck as necessary */
03809                         CheckMenuItem(hMenu, IDM_EXPAND_INCSAME,
03810                               (expand_include & INCLUDE_SAME) ?
03811                                         MF_CHECKED:MF_UNCHECKED);
03812                         hr = StringCchPrintf(str, 32, szD, expand_include);
03813             if (FAILED(hr))
03814               OutputError(hr, IDS_SAFE_PRINTF);
03815                         WriteProfileString(APPNAME, szLineInclude, str);
03816                         view_changeviewoptions(current_view);
03817                         break;
03818
03819                 case IDM_EXPAND_INCLEFT:
03820                         /* toggle flag in expand_include options */
03821                         expand_include ^= INCLUDE_LEFTONLY;
03822
03823                         /* check/uncheck as necessary */
03824                         CheckMenuItem(hMenu, IDM_EXPAND_INCLEFT,
03825                               (expand_include & INCLUDE_LEFTONLY) ?
03826                                         MF_CHECKED:MF_UNCHECKED);
03827                         hr = StringCchPrintf(str, 32, szD, expand_include);
03828             if (FAILED(hr))
03829               OutputError(hr, IDS_SAFE_PRINTF);
03830                         WriteProfileString(APPNAME, szLineInclude, str);
03831                         view_changeviewoptions(current_view);
03832                         break;
03833
03834                 case IDM_EXPAND_INCRIGHT:
03835                         /* toggle flag in expand_include options */
03836                         expand_include ^= INCLUDE_RIGHTONLY;
03837
03838                         /* check/uncheck as necessary */
03839                         CheckMenuItem(hMenu, IDM_EXPAND_INCRIGHT,
03840                               (expand_include & INCLUDE_RIGHTONLY) ?
03841                                         MF_CHECKED:MF_UNCHECKED);
03842                         hr = StringCchPrintf(str, 32, szD, expand_include);
03843             if (FAILED(hr))
03844               OutputError(hr, IDS_SAFE_PRINTF);
03845                         WriteProfileString(APPNAME, szLineInclude, str);
03846                         view_changeviewoptions(current_view);
03847                         break;
03848
03849                 case IDM_EXPAND_INCMOVEDLEFT:
03850                         /* toggle flag in expand_include options */
03851                         expand_include ^= INCLUDE_MOVEDLEFT;
03852
03853                         /* check/uncheck as necessary */
03854                         CheckMenuItem(hMenu, IDM_EXPAND_INCMOVEDLEFT,
03855                               (expand_include & INCLUDE_MOVEDLEFT) ?
03856                                         MF_CHECKED:MF_UNCHECKED);
03857                         hr = StringCchPrintf(str, 32, szD, expand_include);
03858             if (FAILED(hr))
03859               OutputError(hr, IDS_SAFE_PRINTF);
03860                         WriteProfileString(APPNAME, szLineInclude, str);
03861                         view_changeviewoptions(current_view);
03862                         break;
03863
03864                 case IDM_EXPAND_INCMOVEDRIGHT:
03865                         /* toggle flag in expand_include options */
03866                         expand_include ^= INCLUDE_MOVEDRIGHT;
03867
03868                         /* check/uncheck as necessary */
03869                         CheckMenuItem(hMenu, IDM_EXPAND_INCMOVEDRIGHT,
03870                               (expand_include & INCLUDE_MOVEDRIGHT) ?
03871                                         MF_CHECKED:MF_UNCHECKED);
03872                         hr = StringCchPrintf(str, 32, szD, expand_include);
03873             if (FAILED(hr))
03874               OutputError(hr, IDS_SAFE_PRINTF);
03875                         WriteProfileString(APPNAME, szLineInclude, str);
03876                         view_changeviewoptions(current_view);
03877                         break;
03878
03879                 case IDM_EXPAND_INCSIMILARLEFT:
03880                         /* toggle flag in expand_include options */
03881                         expand_include ^= INCLUDE_SIMILARLEFT;
03882
03883                         /* check/uncheck as necessary */
03884                         CheckMenuItem(hMenu, IDM_EXPAND_INCSIMILARLEFT,
03885                               (expand_include & INCLUDE_SIMILARLEFT) ?
03886                                         MF_CHECKED:MF_UNCHECKED);
03887                         hr = StringCchPrintf(str, 32, szD, expand_include);
03888             if (FAILED(hr))
03889               OutputError(hr, IDS_SAFE_PRINTF);
03890                         WriteProfileString(APPNAME, szLineInclude, str);
03891                         view_changeviewoptions(current_view);
03892                         break;
03893
03894                 case IDM_EXPAND_INCSIMILARRIGHT:
03895                         /* toggle flag in expand_include options */
03896                         expand_include ^= INCLUDE_SIMILARRIGHT;
03897
03898                         /* check/uncheck as necessary */
03899                         CheckMenuItem(hMenu, IDM_EXPAND_INCSIMILARRIGHT,
03900                               (expand_include & INCLUDE_SIMILARRIGHT) ?
03901                                         MF_CHECKED:MF_UNCHECKED);
03902                         hr = StringCchPrintf(str, 32, szD, expand_include);
03903             if (FAILED(hr))
03904               OutputError(hr, IDS_SAFE_PRINTF);
03905                         WriteProfileString(APPNAME, szLineInclude, str);
03906                         view_changeviewoptions(current_view);
03907                         break;
03908
03909                     /*
03910                      * options selecting which files to include in the
03911                      * outline listing, based on their state
03912                      */
03913                 case IDM_OUTLINE_INCLEFT:
03914
03915
03916                     /* toggle flag in outline_include options */
03917                     outline_include ^= INCLUDE_LEFTONLY;
03918
03919                     /* check/uncheck as necessary */
03920                     CheckMenuItem(hMenu, IDM_OUTLINE_INCLEFT,
03921                                   (outline_include & INCLUDE_LEFTONLY) ?
03922                                   MF_CHECKED:MF_UNCHECKED);
03923
03924                     hr = StringCchPrintf(str, 32, szD, outline_include);
03925           if (FAILED(hr))
03926               OutputError(hr, IDS_SAFE_PRINTF);
03927                     WriteProfileString(APPNAME, szFileInclude, str);
03928                     view_changeviewoptions(current_view);
03929
03930
03931                     break;
03932
03933                 case IDM_OUTLINE_INCRIGHT:
03934
03935
03936                     outline_include ^= INCLUDE_RIGHTONLY;
03937
03938                     CheckMenuItem(hMenu, IDM_OUTLINE_INCRIGHT,
03939                                   (outline_include & INCLUDE_RIGHTONLY) ?
03940                                   MF_CHECKED:MF_UNCHECKED);
03941                     hr = StringCchPrintf(str, 32, szD, outline_include);
03942           if (FAILED(hr))
03943               OutputError(hr, IDS_SAFE_PRINTF);
03944                     WriteProfileString(APPNAME, szFileInclude, str);
03945                     view_changeviewoptions(current_view);
03946
03947                     break;
03948
03949                 case IDM_OUTLINE_INCSAME:
03950
03951
03952                     outline_include ^= INCLUDE_SAME;
03953
03954                     CheckMenuItem(hMenu, IDM_OUTLINE_INCSAME,
03955                                   (outline_include & INCLUDE_SAME) ?
03956                                   MF_CHECKED:MF_UNCHECKED);
03957                     hr = StringCchPrintf(str, 32, szD, outline_include);
03958           if (FAILED(hr))
03959               OutputError(hr, IDS_SAFE_PRINTF);
03960                     WriteProfileString(APPNAME, szFileInclude, str);
03961                     view_changeviewoptions(current_view);
03962
03963
03964                     break;
03965
03966
03967                 case IDM_OUTLINE_INCDIFFER:
03968
03969
03970
03971                     outline_include ^= INCLUDE_DIFFER;
03972
03973                     CheckMenuItem(hMenu, IDM_OUTLINE_INCDIFFER,
03974                                   (outline_include & INCLUDE_DIFFER) ?
03975                                   MF_CHECKED:MF_UNCHECKED);
03976
03977                     hr = StringCchPrintf(str, 32, szD, outline_include);
03978           if (FAILED(hr))
03979               OutputError(hr, IDS_SAFE_PRINTF);
03980                     WriteProfileString(APPNAME, szFileInclude, str);
03981                     view_changeviewoptions(current_view);
03982
03983
03984                     break;
03985
03986                 case IDM_UPDATE:
03987                     OnUpdate( (COMPITEM) lParam);
03988                     break;
03989
03990
03991                 case IDM_RESCAN:
03992                     RescanFile(hWnd);
03993
03994                     /* do we need to force any repaints? */
03995                     // - no, as RescanFile sends a IDM_UPDATE
03996                     break;
03997
03998
03999                 case IDM_LONLY:
04000                 case IDM_RONLY:
04001                 case IDM_BOTHFILES:
04002                     /* option selects whether the expanded file
04003                      * show is the combined file, or just one
04004                      * or other of the input files.
04005                      *
04006                      * if we are not in expand mode, this also
04007                      * causes us to expand the selection
04008                      */
04009
04010
04011                     CheckMenuItem(GetMenu(hWnd), expand_mode, MF_UNCHECKED);
04012                     expand_mode = GET_WM_COMMAND_ID(wParam, lParam);
04013                     CheckMenuItem(GetMenu(hWnd), expand_mode, MF_CHECKED);
04014
04015                     /* change the current view to show only the lines
04016                      * of the selected type.
04017                      */
04018                     if (DisplayMode == MODE_OUTLINE) {
04019                         ToExpand(hWnd);
04020                     } else {
04021                         view_changeviewoptions(current_view);
04022                     }
04023
04024
04025                     break;
04026
04027
04028                 case IDM_IGNBLANKS:
04029
04030                     /* if selected, ignore all spaces and tabs on
04031                      * comparison - expand view only: outline view
04032                      * will still show that 'text files differ'
04033                      */
04034
04035                     ignore_blanks = !ignore_blanks;
04036                     CheckMenuItem(hMenu, IDM_IGNBLANKS,
04037                                   ignore_blanks? MF_CHECKED:MF_UNCHECKED);
04038                     hr = StringCchPrintf(str, 32, szD, ignore_blanks);
04039           if (FAILED(hr))
04040               OutputError(hr, IDS_SAFE_PRINTF);
04041                     WriteProfileString(APPNAME, szBlanks, str);
04042
04043                     /* invalidate all diffs since we have
04044                      * changed diff options, and re-do and display the
04045                      * current diff if we are in expand mode.
04046                      */
04047                     view_changediffoptions(current_view);
04048
04049                     /* force repaint of bar window */
04050                     InvalidateRect(hwndBar, NULL, TRUE);
04051
04052                     break;
04053
04054                 case IDM_SHOWWHITESPACE:
04055
04056                         /* if selected, display all spaces and tabs in
04057                            the expanded text view */
04058                         show_whitespace = !show_whitespace;
04059                         CheckMenuItem(hMenu, IDM_SHOWWHITESPACE,
04060                                 show_whitespace ? MF_CHECKED:MF_UNCHECKED);
04061                         hr = StringCchPrintf(str, 32, szD, show_whitespace);
04062             if (FAILED(hr))
04063               OutputError(hr, IDS_SAFE_PRINTF);
04064                         WriteProfileString(APPNAME, szShowWhitespace, str);
04065
04066                         // change the current view to show only the lines
04067                         // of the selected type.
04068                         if (DisplayMode == MODE_EXPAND) {
04069                                 view_changeviewoptions(current_view);
04070                         }
04071
04072                         break;
04073
04074                 case IDM_ALG2:
04075
04076                     /* if selected, do algorithm2 which does not accept
04077                      * unsafe matches.
04078                      */
04079
04080                     Algorithm2 = !Algorithm2;
04081                     CheckMenuItem(hMenu, IDM_ALG2,
04082                                   Algorithm2? MF_CHECKED:MF_UNCHECKED);
04083                     hr = StringCchPrintf(str, 32, szD, Algorithm2);
04084           if (FAILED(hr))
04085               OutputError(hr, IDS_SAFE_PRINTF);
04086                     WriteProfileString(APPNAME, szAlgorithm2, str);
04087
04088                     /* invalidate all diffs since we have
04089                      * changed diff options, and re-do and display the
04090                      * current diff if we are in expand mode.
04091                      */
04092                     view_changediffoptions(current_view);
04093
04094                     /* force repaint of bar window */
04095                     InvalidateRect(hwndBar, NULL, TRUE);
04096
04097                     break;
04098
04099                 case IDM_MONOCOLS:
04100
04101                     /* Use monochrome colours - toggle */
04102
04103                     mono_colours = !mono_colours;
04104                     CheckMenuItem(hMenu, IDM_MONOCOLS,
04105                                   mono_colours? MF_CHECKED:MF_UNCHECKED);
04106                     hr = StringCchPrintf(str, 32, szD, mono_colours);
04107           if (FAILED(hr))
04108               OutputError(hr, IDS_SAFE_PRINTF);
04109                     WriteProfileString(APPNAME, szMonoColours, str);
04110                     if (mono_colours)
04111                         SetMonoColours();
04112                     else
04113                         SetColours();
04114
04115                     /* The diffs are still valid, but force a re-display
04116                      * of bar window and main table.
04117                      */
04118                     SendMessage(hwndBar, WM_COMMAND, IDM_MONOCOLS, 0);
04119                     InvalidateRect(hwndBar, NULL, TRUE);
04120                     view_changeviewoptions(current_view);
04121
04122                     break;
04123
04124                 case IDM_PICTURE:
04125                     picture_mode = !picture_mode;
04126                     CheckMenuItem(hMenu, IDM_PICTURE,
04127                                   picture_mode? MF_CHECKED:MF_UNCHECKED);
04128                     hr = StringCchPrintf(str, 32, szD, picture_mode);
04129           if (FAILED(hr))
04130               OutputError(hr, IDS_SAFE_PRINTF);
04131                     WriteProfileString(APPNAME, szPicture, str);
04132                     DoResize(hWnd);
04133                     break;
04134
04135                 case IDM_HIDEMARK:
04136                     // toggle state of marked files hidden or not
04137                     hide_markedfiles = !hide_markedfiles;
04138                     CheckMenuItem(hMenu, IDM_HIDEMARK,
04139                                   hide_markedfiles? MF_CHECKED : MF_UNCHECKED);
04140                     hr = StringCchPrintf(str, 32, szD, hide_markedfiles);
04141           if (FAILED(hr))
04142               OutputError(hr, IDS_SAFE_PRINTF);
04143                     WriteProfileString(APPNAME, szHideMark, str);
04144
04145                     // rebuild view with new global option
04146                     // - note that marks only affect outline views
04147                     if (!view_isexpanded(current_view)) {
04148                         view_changeviewoptions(current_view);
04149                     }
04150                     break;
04151
04152                 case IDM_FIND:
04153                   {
04154                   int nRet = IDCANCEL;
04155                   DLGPROC lpProc = (DLGPROC) MakeProcInstance((WINPROCTYPE) FindDlgProc, hInst);
04156                   if (lpProc)
04157                     {
04158                     char *pszFind = NULL;
04159                     sdkdiff_UI(TRUE);
04160                     nRet = (BOOL) DialogBoxParam(hInst, (LPCTSTR) IDD_FIND, hwndClient, lpProc, 0L);
04161                     sdkdiff_UI(FALSE);
04162                     FreeProcInstance(lpProc);
04163                     }
04164                   }
04165                   break;
04166
04167                 case IDM_FINDNEXT:
04168                   {
04169                   const LONG iCol = (view_isexpanded(current_view)) ? 2 : 1;
04170                   FindString(hWnd, iCol, NULL, 1, 0);
04171                   break;
04172                   }
04173
04174                 case IDM_FINDPREV:
04175                   {
04176                   const LONG iCol = (view_isexpanded(current_view)) ? 2 : 1;
04177                   FindString(hWnd, iCol, NULL, -1, 0);
04178                   break;
04179                   }
04180
04181                 case IDM_GOTOLINE:
04182                   {
04183                   if (!view_getrowcount(current_view))
04184                     {
04185                     MessageBox(hWnd, LoadRcString(IDS_GOTOLINE_NOLINES), szSdkDiff, MB_OK|MB_ICONSTOP|MB_TASKMODAL);
04186                     }
04187                   else
04188                     {
04189                     DLGPROC lpProc = (DLGPROC) MakeProcInstance((WINPROCTYPE)GoToLineDlgProc, hInst);
04190                     if (lpProc)
04191                       {
04192                       sdkdiff_UI(TRUE);
04193                       DialogBoxParam(hInst, (LPCTSTR) IDD_GOTOLINE, hwndClient, lpProc, 0L);
04194                       sdkdiff_UI(FALSE);
04195                       FreeProcInstance(lpProc);
04196                       }
04197                     }
04198                   }
04199                   break;
04200
04201                 case IDM_EDITCOPY:
04202                     {
04203                         unsigned long cb = 0;
04204                         LPCSTR pszText = NULL;
04205                         long iRow = 0;
04206                         const BOOL fOutline = !view_isexpanded(current_view);
04207
04208                         /* first count total data size */
04209                         for (iRow = 0; iRow < selection_nrows; iRow++) {
04210                             if (fOutline) {
04211                                 pszText = view_gettext(current_view, selection + iRow, 1);
04212                                 if (!pszText)
04213                                     break;
04214                                 cb += (lstrlen(pszText) + 3) * sizeof(char);
04215                             }
04216
04217                             pszText = view_gettext(current_view, selection + iRow, 2);
04218                             if (!pszText)
04219                                 break;
04220                             cb += (lstrlen(pszText)) * sizeof(char);
04221                         }
04222
04223                         if (cb && OpenClipboard(NULL)) {
04224                             /* space for trailing nul char */
04225                             cb++;
04226
04227                             /* copy data to clipboard */
04228                             if (EmptyClipboard()) {
04229                                 HGLOBAL hData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,  cb);
04230
04231                                 if (hData) {
04232                                     void *pv = hData;
04233                                     if (!pv) {
04234                                         HeapFree(GetProcessHeap(), NULL, hData);
04235                                     }
04236                                     else {
04237                                         LPSTR pszBuf = (LPSTR) pv;
04238                                         memset(pv, 0, cb);
04239
04240                                         for (iRow = 0; iRow < selection_nrows; iRow++) {
04241                                             if (fOutline) {
04242                                                 pszText = view_gettext(current_view, selection + iRow, 1);
04243                                                 if (!pszText)
04244                                                     break;
04245
04246                                                 hr = StringCchCopy(pszBuf, cb, pszText);
04247                         if (FAILED(hr))
04248                           OutputError(hr, IDS_SAFE_COPY);
04249                                                 pszBuf += lstrlen(pszBuf);
04250                                                 *(pszBuf++) = '\t';
04251                                                 *pszBuf = 0;
04252                                             }
04253
04254                                             pszText = view_gettext(current_view, selection + iRow, 2);
04255                                             if (!pszText)
04256                                                 break;
04257
04258                                             hr = StringCchCopy(pszBuf, cb, pszText);
04259                       if (FAILED(hr))
04260                         OutputError(hr, IDS_SAFE_COPY);
04261                                             pszBuf += lstrlen(pszBuf);
04262
04263                                             if (fOutline) {
04264                                                 *(pszBuf++) = '\r';
04265                                                 *(pszBuf++) = '\n';
04266                                                 *pszBuf = 0;
04267                                             }
04268                                         }
04269
04270                                         SetClipboardData(CF_TEXT, hData);
04271                                     }
04272                                 }
04273                             }
04274                             CloseClipboard();
04275                         }
04276                     }
04277                     break;
04278
04279                 case IDM_MARK:
04280                     {
04281                         BOOL bChanged = FALSE;
04282                         int i;
04283
04284                         // toggle the mark on the current selection
04285                         // note that the selection could be multiple rows
04286                         for (i = 0; i < selection_nrows; i++) {
04287
04288                             if (view_setmarkstate(current_view, selection + i,
04289                                                   !view_getmarkstate(current_view, selection + i))) {
04290
04291                                 bChanged = TRUE;
04292                             }
04293                         }
04294
04295                         if (bChanged) {
04296                             // yes the mark state was changed - need
04297                             // to rebuild the view.
04298                             if (!view_isexpanded(current_view)) {
04299                                 view_changeviewoptions(current_view);
04300                             }
04301                         }
04302                         break;
04303                     }
04304
04305                 case IDM_TOGGLEMARK:
04306                     // toggle the state of all files: unmark all
04307                     // marked files and vice versa
04308                     complist_togglemark(view_getcomplist(current_view));
04309
04310                     // rebuild view
04311                     if (!view_isexpanded(current_view)) {
04312                         view_changeviewoptions(current_view);
04313                     }
04314                     break;
04315
04316                 case IDM_MARKPATTERN:
04317                     // dialog to query the pattern, then set a mark on
04318                     // all compitems whose title matches that pattern
04319                     // returns TRUE if anything was changed
04320                     if (complist_markpattern(view_getcomplist(current_view))) {
04321
04322                         // rebuild view
04323                         if (!view_isexpanded(current_view)) {
04324                             view_changeviewoptions(current_view);
04325                         }
04326                     }
04327                     break;
04328
04329                 case IDM_EXPAND:
04330
04331                     /* show the expanded view of the
04332                      * selected file
04333                      */
04334                     if (current_view != NULL) {
04335                         ToExpand(hWnd);
04336                     }
04337
04338                     break;
04339
04340                 case IDM_OUTLINE:
04341                     /* return to the outline view (list of filenames) */
04342                     ToOutline(hWnd);
04343
04344                     break;
04345
04346                 case IDM_FCHANGE:
04347                     /* find the next line in the current view
04348                      * that is not the same in both files -
04349                      * in outline view, finds the next filename that
04350                      * is not identical
04351                      */
04352                     FindNextChange();
04353                     break;
04354
04355                 case IDM_FPCHANGE:
04356                     /* same as IDM_FCHANGE, but going backwards from
04357                      * current position
04358                      */
04359                     FindPrevChange();
04360                     break;
04361
04362                 case IDM_FCHANGE_LAURIE:
04363                     /* same as IDM_FCHANGE, but tries to keep cursor on same
04364                      * line.
04365                      */
04366                     _FindNextChange(TRUE, FALSE);
04367                     break;
04368
04369                 case IDM_FPCHANGE_LAURIE:
04370                     /* same as IDM_FPCHANGE, but tries to keep cursor on same
04371                      * line.
04372                      */
04373                     _FindPrevChange(TRUE, FALSE);
04374                     break;
04375
04376                     // given a line that has been moved, jump to the
04377                     // other representation of the same line.
04378                     // this used to be available just through double-click
04379                     // but now is also available from a context menu
04380                 case IDM_TOMOVED:
04381                     ToMoved(hWnd, TRUE);
04382                     break;
04383             }
04384             break;
04385
04386         case WM_SIZE:
04387             DoResize(hWnd);
04388             break;
04389
04390         case WM_SETFOCUS:
04391             /* set the focus on the table class so it can process
04392              * page-up /pagedown keys etc.
04393              */
04394             SetFocus(hwndRCD);
04395             break;
04396
04397         case WM_KEYDOWN:
04398             /* although the table window has the focus, he passes
04399              * back to us any keys he doesn't understand
04400              * We handle escape here to mean 'return to outline view'
04401              */
04402             if (wParam == VK_ESCAPE) {
04403                 ToOutline(hWnd);
04404             } else if (wParam == VK_APPS) {
04405                 // Handle the context menu keyboard key
04406                 POINT posCursor;
04407                 GetCursorPos(&posCursor);
04408                 ScreenToClient(hwndRCD, &posCursor);
04409                 OnRightClick(hWnd, posCursor.x, posCursor.y);
04410             }
04411             break;
04412
04413         case WM_RBUTTONDOWN:
04414             /*
04415              * the table window handles this by performing the
04416              * selection and then passing the message to us, allowing
04417              * us to put up a context menu.
04418              */
04419             OnRightClick(hWnd, LOWORD(lParam), HIWORD(lParam));
04420             break;
04421
04422         case WM_CLOSE:
04423             SendMessage(hWnd, WM_COMMAND, IDM_EXIT, 0);
04424             return TRUE;
04425
04426             /* don't allow close when busy - process this message in
04427              * order to ensure this
04428              */
04429             break;
04430
04431         case WM_DESTROY:
04432       TCHAR pszHelp[MAX_PATH];
04433       memset(pszHelp, 0, MAX_PATH);
04434       hr = StringCchCopy(pszHelp, MAX_PATH, pszWorkingDirectoryName);
04435       if (FAILED(hr))
04436         OutputError(hr, IDS_SAFE_COPY);
04437       hr = StringCchCat(pszHelp, MAX_PATH, "sdkdiff.hlp");
04438       if (FAILED(hr))
04439         OutputError(hr, IDS_SAFE_COPY);
04440             DeleteTools();
04441             WinHelp(hWnd, pszHelp, HELP_QUIT, 0);
04442             PostQuitMessage(0);
04443             break;
04444
04445         case TM_CURRENTVIEW:
04446             /* allow other people such as the bar window to query the
04447              * current view
04448              */
04449             return((INT_PTR) current_view);
04450
04451 #ifdef LATER
04452 #ifdef WM_MOUSEWHEEL
04453         case WM_MOUSEWHEEL:
04454             if (LOWORD(wParam) & MK_MBUTTON) {
04455                 if ((short)HIWORD(wParam) < 0) {
04456                     // The next occurence
04457                     _FindNextChange(FALSE, TRUE);
04458                 }
04459                 else {
04460                     _FindPrevChange(FALSE, TRUE);
04461                 }
04462             }
04463             break;
04464 #endif
04465 #endif
04466
04467         case WM_QUERYENDSESSION:
04468             if (IsBusy())
04469                 return FALSE;
04470             return TRUE;
04471
04472         case WM_ENDSESSION:
04473             SendMessage(hWnd, WM_CLOSE, 0, 0);
04474             break;
04475
04476         default:
04477             /* handle registered table messages */
04478             if (message == table_msgcode) {
04479                 ret = TableServer(hWnd, wParam, lParam);
04480                 return(ret);
04481             }
04482             return(DefWindowProc(hWnd, message, wParam, lParam));
04483     }
04484     return(0);
04485 }
04486
04487 /***************************************************************************
04488  * Function: My_mbspbrk
04489  *
04490  * Purpose:
04491  *
04492  * DBCS version of strpbrk
04493  *
04494  */
04495 PUCHAR
04496 My_mbspbrk(
04497           PUCHAR psz,
04498           PUCHAR pszSep
04499           )
04500 {
04501     PUCHAR pszSepT;
04502     while (*psz != '\0') {
04503         pszSepT = pszSep;
04504         while (*pszSepT != '\0') {
04505             if (*pszSepT == *psz) {
04506                 return psz;
04507             }
04508             pszSepT = (PUCHAR)CharNext((LPCSTR)pszSepT);
04509         }
04510         psz = (PUCHAR)CharNext((LPCSTR)psz);
04511     }
04512     return NULL;
04513 }
04514
04515 /***************************************************************************
04516  * Function: My_mbsstr
04517  *
04518  * Purpose:
04519  *
04520  * DBCS version of strstr
04521  *
04522  */
04523 PUCHAR
04524 My_mbsstr(
04525          PUCHAR str1,
04526          PUCHAR str2,
04527          PUCHAR *pstrEnd
04528          )
04529 {
04530   PUCHAR cp = (PUCHAR) str1;
04531   PUCHAR s1, s2;
04532
04533   if (!*str2)
04534     return ((PUCHAR) str1);
04535
04536   while (*cp)
04537     {
04538     s1 = cp;
04539     s2 = (PUCHAR) str2;
04540
04541     while (*s1 && *s2)
04542       {
04543       if (*s1 - *s2)
04544         break;
04545
04546       if (IsDBCSLeadByte(*s1) && (++(*s1) - ++(*s2)))
04547         break;
04548
04549       s1++;
04550       s2++;
04551       }
04552
04553     if (!*s2)
04554       {
04555       if (pstrEnd)
04556         *pstrEnd = s1;
04557       return cp;
04558       }
04559
04560     cp = (PUCHAR)CharNext((LPCSTR)cp);
04561     }
04562
04563   return NULL;
04564 }
04565
04566 /***************************************************************************
04567  * Function: My_mbsistr
04568  *
04569  * Purpose:
04570  *
04571  * DBCS version of case-independent strstr
04572  *
04573  */
04574 PUCHAR
04575 My_mbsistr(
04576           PUCHAR str1,
04577           PUCHAR str2,
04578           PUCHAR *pstrEnd
04579           )
04580 {
04581   PUCHAR cp = (PUCHAR) str1;
04582   PUCHAR s1, s2;
04583
04584   if (!*str2)
04585     return ((PUCHAR) str1);
04586
04587   while (*cp)
04588     {
04589     s1 = cp;
04590     s2 = (PUCHAR) str2;
04591
04592     while (*s1 && *s2)
04593       {
04594       if (IsDBCSLeadByte(*s1))
04595         {
04596         if ((*s1 - *s2) || (++(*s1) - ++(*s2)))
04597           break;
04598         }
04599       else if (toupper(*s1) - toupper(*s2))
04600         {
04601         break;
04602         }
04603
04604       s1++;
04605       s2++;
04606       }
04607
04608     if (!*s2)
04609       {
04610       if (pstrEnd)
04611         *pstrEnd = s1;
04612       return cp;
04613       }
04614
04615     cp = (PUCHAR)CharNext((LPCSTR)cp);
04616     }
04617
04618   return NULL;
04619 }
04620
04621 /***************************************************************************
04622  * Function: My_mbschr
04623  *
04624  * Purpose:
04625  *
04626  * DBCS version of strchr
04627  *
04628  */
04629 LPSTR
04630 My_mbschr(
04631           LPCSTR psz,
04632           unsigned short uiSep
04633           )
04634 {
04635     while (*psz != '\0' && *psz != uiSep) {
04636         psz = CharNext(psz);
04637     }
04638     return (LPSTR)(*psz == uiSep ? psz : NULL);
04639 }
04640
04641 /***************************************************************************
04642  * Function: My_mbsncpy
04643  *
04644  * Purpose:
04645  *
04646  * DBCS version of strncpy
04647  *
04648  */
04649 LPSTR
04650 My_mbsncpy(
04651            LPSTR psz1,
04652            LPCSTR psz2,
04653            size_t nLen
04654            )
04655 {
04656     LPSTR pszSv = psz1;
04657     int Length = (int)nLen;
04658
04659     while (0 < Length) {
04660         if (*psz2 == '\0') {
04661             *psz1++ = '\0';
04662             Length--;
04663         } else if (IsDBCSLeadByte(*psz2)) {
04664             if (Length == 1) {
04665                 *psz1 = '\0';
04666             } else {
04667                 *psz1++ = *psz2++;
04668                 *psz1++ = *psz2++;
04669             }
04670             Length -= 2;
04671         } else {
04672             *psz1++ = *psz2++;
04673             Length--;
04674         }
04675     }
04676     return pszSv;
04677 }
04678
04679 /***************************************************************************
04680  * Function: My_mbsrchr
04681  *
04682  * Purpose:
04683  *
04684  * DBCS version of strrchr
04685  *
04686  */
04687 LPSTR
04688 My_mbsrchr(
04689            LPCSTR psz,
04690            unsigned short uiSep
04691            )
04692 {
04693     unsigned const char *pszHead;
04694
04695     pszHead = (unsigned char *)psz;
04696
04697     while (*psz != '\0') {
04698         psz++;
04699     }
04700     if (uiSep == '\0') {
04701         return (LPSTR)psz;
04702     }
04703
04704     while ((LPCSTR)psz > (LPCSTR)pszHead) {
04705         psz = CharPrev((LPCSTR)pszHead, psz);
04706         if (*psz == uiSep) {
04707             break;
04708         }
04709     }
04710     return (LPSTR)(*psz == uiSep ? psz : NULL);
04711 }
04712
04713 /***************************************************************************
04714  * Function: My_mbsncmp
04715  *
04716  * Purpose:
04717  *
04718  * DBCS version of strncmp
04719  * If 'nLen' splits a DBC, this function compares the DBC's 2nd byte also.
04720  *
04721  */
04722 int
04723 My_mbsncmp(
04724            LPCSTR psz1,
04725            LPCSTR psz2,
04726            size_t nLen
04727            )
04728 {
04729     int Length = (int)nLen;
04730
04731     while (0 < Length) {
04732         if ('\0' == *psz1 || '\0' == *psz2) {
04733             return *psz1 - *psz2;
04734         }
04735         if (IsDBCSLeadByte(*psz1) || IsDBCSLeadByte(*psz2)) {
04736             if (*psz1 != *psz2 || *(psz1+1) != *(psz2+1)) {
04737                 return *psz1 - *psz2;
04738             }
04739             psz1 += 2;
04740             psz2 += 2;
04741             Length -= 2;
04742         } else {
04743             if (*psz1 != *psz2) {
04744                 return *psz1 - *psz2;
04745             }
04746             psz1++;
04747             psz2++;
04748             Length--;
04749         }
04750     }
04751     return 0;
04752 }
04753
04754 /***************************************************************************
04755  * Function: My_mbsnicmp
04756  *
04757  * Purpose:
04758  *
04759  * DBCS version of strncmp
04760  * If 'nLen' splits a DBC, this function compares the DBC's 2nd byte also.
04761  *
04762  */
04763 int
04764 My_mbsnicmp(
04765            PUCHAR psz1,
04766            PUCHAR psz2,
04767            size_t nLen
04768            )
04769 {
04770     int Length = (int)nLen;
04771
04772     while (0 < Length) {
04773         if ('\0' == *psz1 || '\0' == *psz2) {
04774             return *psz1 - *psz2;
04775         }
04776         if (IsDBCSLeadByte(*psz1) || IsDBCSLeadByte(*psz2)) {
04777             if (*psz1 != *psz2 || *(psz1+1) != *(psz2+1)) {
04778                 return *psz1 - *psz2;
04779             }
04780             psz1 += 2;
04781             psz2 += 2;
04782             Length -= 2;
04783         } else {
04784             if (toupper(*psz1) != toupper(*psz2)) {
04785                 return *psz1 - *psz2;
04786             }
04787             psz1++;
04788             psz2++;
04789             Length--;
04790         }
04791     }
04792     return 0;
04793 }
04794
04795 /***************************************************************************
04796  * Function: LoadRcString
04797  *
04798  * Purpose: Loads a resource string from string table and returns a pointer
04799  *          to the string.
04800  *
04801  * Parameters: wID - resource string id
04802  *
04803  */
04804
04805 LPTSTR
04806 APIENTRY
04807 LoadRcString(
04808              UINT wID
04809              )
04810 {
04811     static TCHAR szBuf[512];
04812
04813     LoadString((HINSTANCE)GetModuleHandle(NULL),wID,szBuf,sizeof(szBuf));
04814     return szBuf;
04815 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/space.h Source File

  • SysMgmt
  • MMC
  • Complete

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "globals.h"
00024 #include "DeleBase.h"
00025
00026 //forward declaration
00027 class CSpaceVehicle;
00028
00029 class CRocket : public CDelegationBase {
00030
00031 public:
00032     CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload, CSpaceVehicle *pParent);
00033     virtual ~CRocket();
00034
00035     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00036     virtual const GUID & getNodeType() { return thisGuid; }
00037     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00038     BOOL getDeletedStatus() { return isDeleted; }
00039
00040 public:
00041     // virtual functions go here (for MMCN_*)
00042     virtual HRESULT OnRename(LPOLESTR pszNewName);
00043     virtual HRESULT OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect);
00044
00045     virtual HRESULT CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle);
00046     virtual HRESULT HasPropertySheets();
00047     virtual HRESULT GetWatermarks(HBITMAP *lphWatermark,
00048         HBITMAP *lphHeader,
00049         HPALETTE *lphPalette,
00050         BOOL *bStretch);
00051
00052     virtual HRESULT OnPropertyChange(IConsole *pConsole, CComponent *pComponent);
00053
00054     virtual HRESULT OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject);
00055     virtual HRESULT OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect);
00056     virtual HRESULT OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype);
00057     virtual HRESULT OnRefresh(IConsole *pConsole);
00058     virtual HRESULT OnDelete(IConsole *pConsoleComp);
00059
00060
00061 private:
00062     // {B95E11F5-6BE7-11d3-9156-00C04F65B3F9}
00063     static const GUID thisGuid;
00064
00065     _TCHAR *szName;
00066     LONG   lWeight;
00067     LONG   lHeight;
00068     LONG   lPayload;
00069     int    nId;
00070     enum ROCKET_STATUS {RUNNING, PAUSED, STOPPED} iStatus;
00071
00072     LONG_PTR m_ppHandle;
00073
00074     static BOOL CALLBACK DialogProc(
00075         HWND hwndDlg,  // handle to dialog box
00076         UINT uMsg,     // message
00077         WPARAM wParam, // first message parameter
00078         LPARAM lParam  // second message parameter
00079         );
00080
00081         CSpaceVehicle* m_pParent;
00082
00083         BOOL isDeleted;
00084 };
00085
00086 class CSpaceVehicle : public CDelegationBase {
00087 public:
00088     CSpaceVehicle();
00089
00090     virtual ~CSpaceVehicle();
00091
00092     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00093     virtual const GUID & getNodeType() { return thisGuid; }
00094     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00095
00096     virtual void SetScopeItemValue(HSCOPEITEM hscopeitem) { m_hParentHScopeItem = hscopeitem; }
00097     virtual HSCOPEITEM GetParentScopeItem() { return m_hParentHScopeItem; }
00098
00099 public:
00100     // virtual functions go here (for MMCN_*)
00101     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00102     virtual HRESULT OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed);
00103     virtual HRESULT OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject);
00104
00105 private:
00106     enum { IDM_NEW_SPACE = 4 };
00107
00108     // {B95E11F4-6BE7-11d3-9156-00C04F65B3F9}
00109     static const GUID thisGuid;
00110
00111 private:
00112     enum { NUMBER_OF_CHILDREN = 4 };
00113     enum { MAX_NUMBER_OF_CHILDREN = 6 };
00114     CRocket *children[MAX_NUMBER_OF_CHILDREN];
00115     int m_cchildren;
00116     HSCOPEITEM m_hParentHScopeItem;
00117 };
00118
00119 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • Taskpads

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Rend/RendSam.Cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Rend

RendSam.Cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1995 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     rend.cpp
00008
00009 Abstract:
00010
00011     This demonstrates how to use some of the APIs in TAPI 3.0 Rendezvous
00012     Controls, and SDP Blob COM Interfaces to:
00013
00014     . open an ILS directory,
00015     . configure a conference,
00016     . add a conference,
00017     . enumerate conferences,
00018     . delete a conference,
00019     . configure a user,
00020     . add a user,
00021     . enumerate users, and
00022     . delete a user.
00023
00024 Notes:
00025
00026     1. Build the program, and the exe is obj\*\rendsam.exe
00027     2. To run it, type "rendsam <ils>" on the command line.
00028
00029 Author:
00030
00031     17-Aug-1997
00032
00033 Revision History:
00034
00035     dd-mmm-yyyy <email>
00036     11-Feb-1999 massive update for Beta3 release
00037
00038 --*/
00039
00040 ///////////////////////////////////////////////////////////////////////////////
00041 //                                                                           //
00042 // include                                                                   //
00043 //                                                                           //
00044
00045 #include <windows.h>
00046 #include <objbase.h>
00047 #include <comdef.h>
00048 #include <stdio.h>
00049 #include <winsock.h>
00050 #include <rend.h>
00051 #include <sdpblb.h>
00052 #include <strsafe.h>
00053
00054 const _bstr_t bstrtEMPTY = _bstr_t(L"");
00055
00056
00057
00058 ///////////////////////////////////////////////////////////////////////////////
00059 //                                                                           //
00060 // define                                                                    //
00061 //                                                                           //
00062
00063 #define RND_MAX_STRING_FORMAT   4096
00064 WCHAR szText[RND_MAX_STRING_FORMAT];
00065 #define RETURN_IF_FAILED(hr)    \
00066     {   \
00067         if (FAILED(hr)) \
00068         {               \
00069             return hr;  \
00070         }               \
00071     }
00072
00073 #define RELEASE_COM_IF(pInterface)  \
00074     {   \
00075         if (NULL != pInterface) \
00076         {                       \
00077             pInterface->Release();\
00078             pInterface = NULL;  \
00079         }                       \
00080     }
00081
00082 #define START_STEP(wszStep) \
00083 {  \
00084   StringCbPrintfW(szText, RND_MAX_STRING_FORMAT, L"%s ...\n", wszStep); \
00085   _putws(szText);  \
00086 }
00087
00088 #define END_STEP(hr) \
00089     {   \
00090         if (FAILED(hr)) \
00091         {               \
00092            wprintf(L"\tFailed with error 0x%x\n", hr);\
00093            return hr;   \
00094         }               \
00095         else            \
00096         {               \
00097             wprintf(L"\tDone.\n");\
00098         }               \
00099     }
00100
00101
00102 ///////////////////////////////////////////////////////////////////////////////
00103 //                                                                           //
00104 // functions                                                                 //
00105 //                                                                           //
00106 ///////////////////////////////////////////////////////////////////////////////
00107
00108
00109 //
00110 // SetConnectionIP
00111 //
00112 HRESULT
00113 SetConnectionIP(ITDirectoryObjectConference *   pIConf,
00114                 _bstr_t                         bstrtMediaName,
00115                 _bstr_t                         bstrtIP
00116                )
00117 /*++
00118
00119 Routine Description:
00120
00121     Set a multicast IP address of the specified media. If no media is specified,
00122     the conference's default connection will be used.
00123
00124     Note: 1. For simplicity, it is assumed there is at most one ITConnection
00125              for each media
00126           2. Will not check if the given IP address is a valid multicast IP
00127
00128 Arguments:
00129
00130     pIConf          : the conference
00131     bstrtMediaName  : name of the media, in lower case, such as "audio" or
00132                       "video". if it's an empty string, then the conference's
00133                       default connection will be used
00134     bstrtIP         : the multicast IP address
00135
00136 Return Value:
00137
00138     HRESULT
00139
00140 --*/
00141 {
00142     //
00143     // check parameters
00144     //
00145
00146     if (NULL == pIConf)
00147     {
00148         return E_POINTER;
00149     }
00150
00151     if (bstrtEMPTY == bstrtIP)
00152     {
00153         return E_INVALIDARG;
00154     }
00155
00156     BOOL    fDefault = FALSE;   // if it's the conference's default connection
00157     if (bstrtEMPTY == bstrtMediaName)
00158     {
00159         fDefault = TRUE;
00160     }
00161
00162     //
00163     // get ITConnection interface
00164     //
00165
00166     ITConnection *  pIConnection;
00167     HRESULT         hr;
00168
00169     if (fDefault)
00170     {   // the conference's default connection
00171         hr = pIConf->QueryInterface(IID_ITConnection,
00172                                     (void **) &pIConnection);
00173         RETURN_IF_FAILED(hr);
00174     }
00175     else
00176     {   // search for the specified media, then use its first connection
00177
00178         //
00179         // get the media enumerator
00180         //
00181
00182         ITSdp * pISdp;
00183         hr = pIConf->QueryInterface(IID_ITSdp, (void **) &pISdp);
00184         RETURN_IF_FAILED(hr);
00185
00186         ITMediaCollection * pIMediaCollec;
00187         hr = pISdp->get_MediaCollection(&pIMediaCollec);
00188         RELEASE_COM_IF(pISdp);
00189         RETURN_IF_FAILED(hr);
00190
00191         IEnumMedia *    pIEnumMedia;
00192         hr = pIMediaCollec->get_EnumerationIf(&pIEnumMedia);
00193         RELEASE_COM_IF(pIMediaCollec);
00194         RETURN_IF_FAILED(hr);
00195
00196         //
00197         // parse each media in the collection to find the one specified
00198         //
00199
00200         ITMedia *   pIMedia;
00201         while ( 1 )
00202         {
00203             hr = pIEnumMedia->Next(1, &pIMedia, NULL);
00204
00205             if (FAILED(hr))
00206             {
00207                 return hr;
00208             }
00209             if (S_FALSE == hr)
00210             {
00211                 // reach the end of the enumerator, not finding the media
00212                 return E_FAIL;
00213             }
00214
00215             //
00216             // get MediaName then compare it with the given media
00217             //
00218
00219             BSTR bstrCurrentMediaName;
00220             hr = pIMedia->get_MediaName(&bstrCurrentMediaName);
00221             RETURN_IF_FAILED(hr);
00222
00223             BOOL fFound = bstrtMediaName == _bstr_t(bstrCurrentMediaName);
00224             ::SysFreeString (bstrCurrentMediaName );
00225
00226             if (fFound)
00227             {
00228                 break;
00229             }
00230             else
00231             {
00232                 RELEASE_COM_IF(pIMedia);
00233             }
00234         }
00235
00236         RELEASE_COM_IF(pIEnumMedia);
00237
00238         //
00239         // query ITConnection interface
00240         //
00241
00242         hr = pIMedia->QueryInterface(IID_ITConnection,
00243                                      (void **) &pIConnection);
00244         RELEASE_COM_IF(pIMedia);
00245         RETURN_IF_FAILED(hr);
00246     }
00247
00248     //
00249     // set the IP address
00250     //
00251     hr = pIConnection->SetAddressInfo((BSTR) bstrtIP,
00252                                       1,
00253                                       15);
00254
00255     RELEASE_COM_IF(pIConnection);
00256
00257     return hr;
00258
00259 } // SetConnectionIP
00260
00261 ///////////////////////////////////////////////////////////////////////////////
00262 //
00263 // OpenILS
00264 //
00265 HRESULT
00266 OpenILS(ITRendezvous *  pIRend,
00267         _bstr_t         bstrtILS,
00268         ITDirectory **  ppIDir
00269         )
00270 /*++
00271
00272 Description:
00273
00274     Connect to a specified ILS server, then Bind with currently logged on
00275     credentials. Since the program does not require logging into a domain,
00276     the Bind operation may fail, and this routine will ignore Bind error.
00277
00278     An unsecured channel will be used in Connect, as "secured channel" is not
00279     supported as of the day this is written (NT5 Beta3)
00280
00281 Arguments:
00282
00283     pIRend  : pointer to an ITRendezvous interface
00284     bstrtILS: ILS server name
00285     ppIDir  : pointer to an ITDirectory interface pointer
00286
00287 Return value:
00288
00289     HRESULT. Bind error will be ignored.
00290
00291 --*/
00292 {
00293     //
00294     // check parameter validity
00295     //
00296     if ((NULL == pIRend) || (NULL == ppIDir))
00297     {
00298         return E_POINTER;
00299     }
00300
00301     if (bstrtEMPTY == bstrtILS)
00302     {
00303         return E_INVALIDARG;
00304     }
00305
00306     //
00307     // create an ITDirectory object
00308     //
00309     HRESULT hr = pIRend->CreateDirectory(DT_ILS, bstrtILS, ppIDir);
00310     RETURN_IF_FAILED(hr);
00311
00312     //
00313     // Connect to the ILS server using an unsecured connection
00314     //
00315     hr = (*ppIDir)->Connect(VARIANT_FALSE);
00316     RETURN_IF_FAILED(hr);
00317
00318     //
00319     // Bind to the ILS server with default credentials
00320     //
00321     (*ppIDir)->Bind(NULL,
00322                     NULL,
00323                     NULL,
00324                     RENDBIND_DEFAULTCREDENTIALS || RENDBIND_AUTHENTICATE
00325                    );
00326
00327     return hr;
00328
00329 } // OpenILS
00330
00331 ///////////////////////////////////////////////////////////////////////////////
00332 //
00333 // ConfigConference
00334 //
00335 HRESULT
00336 ConfigConference(ITDirectoryObject *    pIObj)
00337 /*++
00338
00339 Routine Description:
00340
00341     Configure a conference's selected attributes:
00342     1. set StartTime as current, and StopTime as 1 day later
00343     2. set the conference's default multicast IP address
00344     3. set "video" media's multicast IP address. "audio" media will use the
00345        conference's default IP address set in the above step
00346
00347 Arguments:
00348
00349     pIObj : ITDirectoryObject interface
00350
00351 Return Value:
00352
00353     HRESULT
00354
00355 --*/
00356 {
00357     if (NULL == pIObj)
00358     {
00359         return E_POINTER;
00360     }
00361
00362     //
00363     // query the ITDirectoryObjectConference interface
00364     //
00365
00366     ITDirectoryObjectConference *   pIConf;
00367     HRESULT hr = pIObj->QueryInterface(IID_ITDirectoryObjectConference,
00368                                        (void **) &pIConf
00369                                        );
00370     RETURN_IF_FAILED(hr);
00371
00372     //
00373     // set StartTime to current local time
00374     //
00375
00376     SYSTEMTIME  LocalSysTime;
00377     GetLocalTime(&LocalSysTime);
00378
00379     double vTime;
00380     SystemTimeToVariantTime(&LocalSysTime, &vTime);
00381
00382     RETURN_IF_FAILED(pIConf->put_StartTime(vTime));
00383
00384     //
00385     // set StopTime to one day later
00386     //
00387
00388     hr = pIConf->put_StopTime(vTime + 1);
00389
00390     //
00391     // set the conference's default multicast IP address
00392     // use an arbitrary IP address for simplicity
00393     //
00394
00395     hr = SetConnectionIP(pIConf,
00396                          bstrtEMPTY,
00397                          _bstr_t(L"224.0.0.1"));
00398     RETURN_IF_FAILED(hr);
00399
00400     //
00401     // set media "video"'s multicast IP address
00402     // for simplicity, use an arbitrary IP address
00403     //
00404
00405     hr = SetConnectionIP(pIConf,
00406                          _bstr_t(L"video"),
00407                          _bstr_t(L"224.0.0.2"));
00408     RETURN_IF_FAILED(hr);
00409
00410     //
00411     // clean-up
00412     //
00413
00414     RELEASE_COM_IF(pIConf);
00415
00416     return hr;
00417
00418 } // ConfigConference
00419
00420 ///////////////////////////////////////////////////////////////////////////////
00421 //
00422 // AddConference
00423 //
00424 HRESULT
00425 AddConference(ITRendezvous *   pIRend,
00426               ITDirectory *    pIDir,
00427               _bstr_t          bstrtConfName
00428              )
00429 /*++
00430
00431 Routine Description:
00432
00433     Add a conference to an ILS server. Use ConfigConference to set selected
00434     attributes of the conference.
00435     Existing conference with same name is deleted first to avoid "Object
00436     already exists" error.
00437
00438 Arguments:
00439
00440     pIRend  : an ITRendezvous interface
00441     pIDir   : an ITDirectory interface
00442     bstrtConfName : name of the conference
00443
00444 Return Value:
00445
00446     HRESULT
00447
00448 --*/
00449 {
00450     //
00451     // verify parameter validity
00452     //
00453     if ((NULL == pIRend) || (NULL == pIDir))
00454     {
00455         return E_POINTER;
00456     }
00457
00458     if (bstrtEMPTY == bstrtConfName)
00459     {
00460         return E_INVALIDARG;
00461     }
00462
00463     ITDirectoryObject   *pIObj;
00464
00465     //
00466     // create an conference object
00467     //
00468     HRESULT hr = pIRend->CreateDirectoryObject(OT_CONFERENCE,
00469                                                bstrtConfName,
00470                                                &pIObj
00471                                               );
00472     RETURN_IF_FAILED(hr);
00473
00474     // to ensure a successful creating, delete it first in case a same
00475     // name conference already exists. since it'll fail if the conference
00476     // does not exist, i don't bother checking the error code
00477     pIDir->DeleteDirectoryObject(pIObj);
00478
00479     //
00480     // cofigure the conference
00481     //
00482     RETURN_IF_FAILED(ConfigConference(pIObj));
00483
00484     //
00485     // add the conference to the ILS server
00486     //
00487     hr = pIDir->AddDirectoryObject(pIObj);
00488
00489     // release the ITDirectoryObject interface
00490     RELEASE_COM_IF(pIObj);
00491
00492     RETURN_IF_FAILED(hr);
00493
00494     return S_OK;
00495
00496 } // AddConference
00497
00498 ///////////////////////////////////////////////////////////////////////////////
00499 //
00500 // CreateUser
00501 //
00502 HRESULT
00503 CreateUser(ITRendezvous *       pIRend,
00504            bstr_t               bstrtUserName,
00505            bstr_t               bstrtIPPhonePriamry,
00506            ITDirectoryObject ** ppIObj)
00507 /*++
00508
00509 Routine Description:
00510
00511     Create an ITDirectoryObject of type user with specified IPPhonePrimary.
00512
00513 Arguments:
00514
00515     bstrtUserName       : user name
00516     bstrtIPPhonePriamry : IPPhonePriamry value
00517     ppIObj              : return the pointer to an ITDirectoryObject pointer
00518
00519 Return Value:
00520
00521     HRESULT
00522
00523 --*/
00524 {
00525     if ((NULL == pIRend) || (NULL == ppIObj))
00526     {
00527         return E_POINTER;
00528     }
00529
00530     if ((bstrtEMPTY == bstrtUserName) ||
00531         (bstrtEMPTY == bstrtIPPhonePriamry))
00532     {
00533         return E_INVALIDARG;
00534     }
00535
00536     //
00537     // create an conference object
00538     //
00539     HRESULT hr = pIRend->CreateDirectoryObject(OT_USER,
00540                                                bstrtUserName,
00541                                                ppIObj
00542                                               );
00543     RETURN_IF_FAILED(hr);
00544
00545     //
00546     // query the ITDirectoryObjectUser interface
00547     //
00548     ITDirectoryObjectUser *   pIUser;
00549     hr = (*ppIObj)->QueryInterface(IID_ITDirectoryObjectUser,
00550                                    (void **) &pIUser
00551                                   );
00552     RETURN_IF_FAILED(hr);
00553
00554     //
00555     // set IPPhonePriamry
00556     //
00557     hr = pIUser->put_IPPhonePrimary((BSTR) bstrtIPPhonePriamry);
00558     RETURN_IF_FAILED(hr);
00559
00560     // release the ITDirectoryObjectUser interface
00561     RELEASE_COM_IF(pIUser);
00562
00563     return hr;
00564
00565 } // CreateUser
00566
00567 ///////////////////////////////////////////////////////////////////////////////
00568 //
00569 // ConfigUser
00570 //
00571 HRESULT
00572 ConfigUser(ITDirectoryObject *  pIObj)
00573 /*++
00574
00575 Routine Description:
00576
00577     Configure selected attributes of a user object.
00578     Currently none is selected, so this routine does nothing.
00579     Will expand this routine when more attributes are defined.
00580
00581 Arguments:
00582
00583     pIObj               : ITDirectoryObject interface
00584
00585 Return Value:
00586
00587     HRESULT
00588
00589 --*/
00590 {
00591     if (NULL == pIObj)
00592     {
00593         return E_POINTER;
00594     }
00595
00596     //
00597     // query the ITDirectoryObjectUser interface
00598     //
00599     ITDirectoryObjectUser *   pIUser;
00600     HRESULT hr = pIObj->QueryInterface(IID_ITDirectoryObjectUser,
00601                                        (void **) &pIUser
00602                                        );
00603     RETURN_IF_FAILED(hr);
00604
00605     //
00606     // config selected attributes: currently none
00607     //
00608
00609     // release the ITDirectoryObjectUser interface
00610     RELEASE_COM_IF(pIUser);
00611
00612     return hr;
00613
00614 } // ConfigUser
00615
00616 ///////////////////////////////////////////////////////////////////////////////
00617 //
00618 // AddUser
00619 //
00620 HRESULT
00621 AddUser(ITRendezvous *  pIRend,
00622         ITDirectory *   pIDir,
00623         _bstr_t         bstrtUserName,
00624         _bstr_t         bstrtIPPhonePrimary
00625        )
00626 /*++
00627
00628 Routine Description:
00629
00630     Add a user object to the ILS server.
00631     Existing user with same IPPhonePrimary is deleted first to avoid "Object
00632     already exists" error.
00633
00634 Arguments:
00635
00636     pIRend  : an ITRendezvous interface
00637     pIDir   : an ITDirectory interface
00638     bstrtUserName       : name of the user
00639     bstrtIPPhonePrimary : IPPhonePrimary value
00640
00641 Return Value:
00642
00643     HRESULT
00644
00645 --*/
00646 {
00647     if (NULL == pIDir)
00648     {
00649         return E_POINTER;
00650     }
00651
00652     // no need to check other parameter validity. will be done in CreatUser
00653
00654     ITDirectoryObject   *pIObj;
00655
00656     //
00657     // create the user object with given IPPhonePrimary
00658     //
00659     RETURN_IF_FAILED(CreateUser(pIRend,
00660                                 bstrtUserName,
00661                                 bstrtIPPhonePrimary,
00662                                 &pIObj)
00663                     );
00664
00665     //
00666     // configure other attributes of the user object
00667     //
00668     RETURN_IF_FAILED(ConfigUser(pIObj));
00669
00670     // to ensure a successful creating, delete it first in case a same
00671     // name user with same IPPhonePrimary already exists. since it'll fail
00672     // if the conference does not exist, i won't bother checking the error
00673     // code
00674     pIDir->DeleteDirectoryObject(pIObj);
00675
00676     //
00677     // add the user object to the ILS server
00678     //
00679     HRESULT hr = pIDir->AddDirectoryObject(pIObj);
00680
00681     // release the ITDirectoryObject interface
00682     RELEASE_COM_IF(pIObj);
00683
00684     return S_OK;
00685
00686 } // AddUser
00687
00688 ///////////////////////////////////////////////////////////////////////////////
00689 //
00690 // ListObject
00691 //
00692 HRESULT
00693 ListObject(ITDirectoryObject *  pIObj)
00694 /*++
00695
00696 Routine Description:
00697
00698     Print out selected object attributes.
00699     For a conference, conference name and description will be printed.
00700     For a user, user name and IPPhonePrimary will be printed.
00701
00702 Arguments:
00703
00704     pIObj   : an ITDirectoryObject interface
00705
00706 Return Value:
00707
00708     HREULST
00709
00710 --*/
00711 {
00712     if (NULL == pIObj)
00713     {
00714         return E_POINTER;
00715     }
00716
00717     //
00718     // get the object type
00719     //
00720     DIRECTORY_OBJECT_TYPE DirectoryObjectType;
00721     HRESULT hr = pIObj->get_ObjectType(&DirectoryObjectType);
00722     RETURN_IF_FAILED(hr);
00723
00724     //
00725     // get and print object name
00726     //
00727     BSTR bstrName;
00728     hr = pIObj->get_Name( &bstrName);
00729     RETURN_IF_FAILED(hr);
00730
00731     if (OT_CONFERENCE == DirectoryObjectType)
00732     {
00733         wprintf(L"\t<CONF> ");
00734     }
00735     else
00736     {
00737         wprintf(L"\t<USER> ");
00738     }
00739
00740
00741   WCHAR szName[RND_MAX_STRING_FORMAT];
00742     StringCbPrintfW(szName, RND_MAX_STRING_FORMAT, L"%s\n",(WCHAR *) bstrName);
00743     _putws(szName);
00744
00745     ::SysFreeString (bstrName);
00746
00747     if (OT_CONFERENCE == DirectoryObjectType)
00748     {
00749         ITDirectoryObjectConference * pIConf;
00750         hr = pIObj->QueryInterface(IID_ITDirectoryObjectConference,
00751                                    (void **) &pIConf
00752                                   );
00753         RETURN_IF_FAILED(hr);
00754
00755         //
00756         // get the ITConferenceBlob interface
00757         //
00758         ITConferenceBlob *  pIConfBlob;
00759         hr = pIConf->QueryInterface(IID_ITConferenceBlob,
00760                                     (void **) &pIConfBlob
00761                                     );
00762         RETURN_IF_FAILED(hr);
00763
00764         //
00765         // get and print the conference's blob
00766         //
00767
00768         BSTR bstrBlob;
00769         hr = pIConfBlob->get_ConferenceBlob(&bstrBlob);
00770         RELEASE_COM_IF(pIConfBlob);
00771         RELEASE_COM_IF(pIConf);
00772         RETURN_IF_FAILED(hr);
00773
00774
00775     WCHAR szBlob[RND_MAX_STRING_FORMAT];
00776     StringCbPrintfW(szBlob, RND_MAX_STRING_FORMAT, L"\t\tBlob:\n%s", (WCHAR *) bstrBlob);
00777     _putws(szBlob);
00778
00779         ::SysFreeString (bstrBlob);
00780     }
00781     else
00782     {   // OT_USER
00783         ITDirectoryObjectUser * pIUser;
00784         hr = pIObj->QueryInterface(IID_ITDirectoryObjectUser,
00785                                    (void **) &pIUser
00786                                   );
00787         RETURN_IF_FAILED(hr);
00788
00789         //
00790         // get and print the user's IPPhonePrimary
00791         //
00792
00793         BSTR bstrIPPhonePrimary;
00794         hr = pIUser->get_IPPhonePrimary(&bstrIPPhonePrimary);
00795         RELEASE_COM_IF(pIUser);
00796         RETURN_IF_FAILED(hr);
00797
00798     WCHAR szPrimary[RND_MAX_STRING_FORMAT];
00799     StringCbPrintfW(szPrimary, RND_MAX_STRING_FORMAT, L"\t\tIPPhonePrimary: %s\n", (WCHAR *) bstrIPPhonePrimary);
00800     _putws(szPrimary);
00801
00802         ::SysFreeString(bstrIPPhonePrimary);
00803     }
00804
00805     return S_OK;
00806
00807 } // ListObject
00808
00809 ///////////////////////////////////////////////////////////////////////////////
00810 //
00811 // EnumObjects
00812 //
00813 HRESULT
00814 EnumObjects(ITDirectory *           pIDir,
00815             DIRECTORY_OBJECT_TYPE   DirectoryObjectType,
00816             _bstr_t                 bstrtFilter)
00817 /*++
00818
00819 Routine Description:
00820
00821     Enumerate all conference or user objects whose names starting with a
00822     string specified by bstrtFilter.
00823
00824 Arguments:
00825
00826     pIDir   : an ITDirectory interface
00827     DirectoryObjectType : type of objects to enumerate
00828     bstrtFilter : conference name filter
00829
00830 Return Value:
00831
00832     HRESULT
00833
00834 --*/
00835 {
00836     //
00837     // verify parameter validity
00838     //
00839     if (NULL == pIDir)
00840     {
00841         return E_POINTER;
00842     }
00843
00844     if (bstrtEMPTY == bstrtFilter)
00845     {
00846         return E_INVALIDARG;
00847     }
00848
00849     //
00850     // get the enumerator
00851     //
00852     IEnumDirectoryObject *  pIEnumObjects;
00853     HRESULT hr = pIDir->EnumerateDirectoryObjects(DirectoryObjectType,
00854                                                   bstrtFilter,
00855                                                   &pIEnumObjects
00856                                                   );
00857     RETURN_IF_FAILED(hr);
00858
00859     //
00860     // enumerate objects returned in the enumerator
00861     //
00862     while (1)
00863     {
00864         ITDirectoryObject * pIObj;
00865         ULONG   cFetched;
00866
00867         //
00868         // get an object
00869         //
00870         hr = pIEnumObjects->Next(1, &pIObj, &cFetched);
00871
00872         if (S_OK != hr)
00873         {
00874             // either reach the end of the enumerator: hr == S_FALSE
00875             // or get an error: FAILED(hr) == TRUE
00876             break;
00877         }
00878
00879         ListObject(pIObj);
00880
00881         RELEASE_COM_IF(pIObj);
00882     }
00883
00884     RELEASE_COM_IF(pIEnumObjects);
00885
00886     return hr;
00887 } // EnumObjects
00888
00889 ///////////////////////////////////////////////////////////////////////////////
00890 //
00891 // DeleteConference
00892 //
00893 HRESULT
00894 DeleteConference(ITRendezvous * pIRend,
00895                  ITDirectory *  pIDir,
00896                  _bstr_t        bstrtConfName)
00897 /*++
00898
00899 Routine Description:
00900
00901     Delete an object
00902
00903 Arguments:
00904
00905     pIRend  : pointer to an ITRendezvous interface
00906     pIDir   : pointer to the ILS server's ITDirectory interface
00907     bstrtConfName : name of the conference to delete
00908
00909 Return Value:
00910
00911     HRESULT
00912
00913 --*/
00914 {
00915     if ((NULL == pIRend) || (NULL == pIDir))
00916     {
00917         return E_POINTER;
00918     }
00919
00920     if (bstrtEMPTY == bstrtConfName)
00921     {
00922         return E_INVALIDARG;
00923     }
00924
00925     //
00926     // create the object
00927     //
00928     ITDirectoryObject * pIObj;
00929     HRESULT hr = pIRend->CreateDirectoryObject(OT_CONFERENCE,
00930                                                bstrtConfName,
00931                                                &pIObj
00932                                                );
00933     RETURN_IF_FAILED(hr);
00934
00935     //
00936     // delete it
00937     //
00938
00939     hr = pIDir->DeleteDirectoryObject(pIObj);
00940
00941     RELEASE_COM_IF(pIObj);
00942
00943     return hr;
00944
00945 } // DeleteConference
00946
00947 ///////////////////////////////////////////////////////////////////////////////
00948 //
00949 // DeleteUser
00950 //
00951 HRESULT
00952 DeleteUser(ITRendezvous *  pIRend,
00953            ITDirectory *   pIDir,
00954            _bstr_t         bstrtUserName,
00955            _bstr_t         bstrtIPPhonePrimary
00956           )
00957 /*++
00958
00959 Routine Description:
00960
00961     Delete a user object from the ILS server.
00962
00963 Arguments:
00964
00965     pIRend  : an ITRendezvous interface
00966     pIDir   : an ITDirectory interface
00967     bstrtUserName       : name of the user
00968     bstrtIPPhonePrimary : IPPhonePrimary value
00969
00970 Return Value:
00971
00972     HRESULT
00973
00974 --*/
00975 {
00976     // no need to other check parameter validity. will be done in CreatUser
00977     if (NULL == pIDir)
00978     {
00979         return E_POINTER;
00980     }
00981
00982     ITDirectoryObject   *pIObj;
00983
00984     //
00985     // create the user object with given IPPhonePrimary
00986     //
00987     RETURN_IF_FAILED(CreateUser(pIRend,
00988                                 bstrtUserName,
00989                                 bstrtIPPhonePrimary,
00990                                 &pIObj)
00991                     );
00992
00993     HRESULT hr = pIDir->DeleteDirectoryObject(pIObj);
00994
00995     // release the ITDirectoryObject interface
00996     RELEASE_COM_IF(pIObj);
00997
00998     return hr;
00999
01000 } // AddUser
01001
01002 ///////////////////////////////////////////////////////////////////////////////
01003 //
01004 // main
01005 //
01006 int _cdecl
01007 main(int argc,
01008      char *argv[]
01009      )
01010 {
01011     /*
01012      * 0. Get ILS server name, if it is specified
01013      */
01014     if (argc != 2)
01015     {
01016         wprintf(L"No ILS server specified.\n");
01017         return 1;
01018     }
01019
01020     _bstr_t bstrtILSServer = _bstr_t(argv[1]);
01021
01022     /*
01023      * 1. Create ITRendezvous interface
01024      */
01025
01026     wprintf(L"\n\n");
01027     START_STEP(L"Initialize Rendezvous Control");
01028
01029     ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
01030
01031     // create an ITRendezvous interface
01032     ITRendezvous    *pIRend;
01033     HRESULT hr = ::CoCreateInstance(CLSID_Rendezvous,
01034                                     NULL,
01035                                     CLSCTX_INPROC_SERVER,
01036                                     IID_ITRendezvous,
01037                                     (void**)&pIRend
01038                                    );
01039     END_STEP(hr);
01040
01041     /*
01042      * 2. Connect and bind to the ILS server
01043      */
01044
01045     START_STEP(L"Connect and Bind to the ILS server");
01046     ITDirectory *pIDir;
01047     hr = OpenILS(pIRend,
01048                  bstrtILSServer,
01049                  &pIDir
01050                 );
01051     END_STEP(hr);
01052
01053     /*
01054      * 3. Add a conference
01055      */
01056
01057     START_STEP(L"Add a conference");
01058     _bstr_t bstrtConfName = _bstr_t(L"Rendezvous Controls Sample Program");
01059     hr = AddConference(pIRend,
01060                        pIDir,
01061                        bstrtConfName
01062                       );
01063     END_STEP(hr);
01064
01065     /*
01066      * 4. Enumerate conferences
01067      */
01068
01069     // use the conference name as a filter for enumeration to limit the set of
01070     // conferences that will be retrieved.
01071     // if no filter is set, all conferences will be retrieved
01072
01073     START_STEP(L"Enumerate conferences");
01074     hr = EnumObjects(pIDir,
01075                      OT_CONFERENCE,
01076                      bstrtConfName);
01077     END_STEP(hr);
01078
01079     /*
01080      * 5. Delete a conference
01081      */
01082
01083     START_STEP(L"Delete a conference");
01084     hr = DeleteConference(pIRend,
01085                           pIDir,
01086                           bstrtConfName);
01087     END_STEP(hr);
01088
01089     /*
01090      * 6. Add a user: must specify the IPPhonePrimary value associated with
01091      *    this user
01092      */
01093
01094     //
01095     // get the local machine's name
01096     // note: WSAStartup is called in creating ITRendezvous *, so no need to
01097     // start Winsock for the gethostbyname call
01098     //
01099
01100     const int MAXHOSTNAMELEN = 255;
01101     CHAR        LocalHostName[MAXHOSTNAMELEN];
01102
01103     if (SOCKET_ERROR == gethostname(LocalHostName, MAXHOSTNAMELEN))
01104     {
01105         wprintf(L"Can't find local host name.\n");
01106         return E_FAIL;
01107     }
01108
01109     _bstr_t bstrtUserName = _bstr_t(L"TAPI3 Rend SDK User");
01110     _bstr_t bstrtIPPhonePrimary = _bstr_t(LocalHostName);
01111
01112     START_STEP(L"Add a user");
01113     hr = AddUser(pIRend,
01114                  pIDir,
01115                  bstrtUserName,
01116                  bstrtIPPhonePrimary
01117                 );
01118     END_STEP(hr);
01119
01120     /*
01121      * 7. Enumerate users
01122      */
01123
01124     // use the user name as a filter for enumeration to limit the set of
01125     // users that will be retrieved. all user objects (may having different
01126     // IPPhonePrimary) with this name will be retrieved
01127     // if no filter is set, all users will be retrieved
01128
01129     START_STEP(L"Enumerate users");
01130     hr = EnumObjects(pIDir,
01131                      OT_USER,
01132                      bstrtUserName);
01133     END_STEP(hr);
01134
01135     /*
01136      * 8. Delete a user: must specify the IPPhonePrimary associated with
01137      *    this user to identify which entry to delete. Note one user may
01138      *    have several different IPPhonePrimary values.
01139      */
01140
01141     START_STEP(L"Delete a user");
01142     hr = DeleteUser(pIRend,
01143                     pIDir,
01144                     bstrtUserName,
01145                     bstrtIPPhonePrimary);
01146     END_STEP(hr);
01147
01148     /*
01149      * 9. Clean-up
01150      */
01151
01152     RELEASE_COM_IF(pIDir);
01153     RELEASE_COM_IF(pIRend);
01154
01155     ::CoUninitialize();
01156
01157     wprintf(L"\n\n");
01158
01159     return 0;
01160
01161 } // end of main
01162
01163
01164
01165
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsError/IADsError.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsError

IADsError.cpp

Go to the documentation of this file.
00001 // IADsError.cpp : Implementation of CADsErrorApp and DLL registration.
00002
00003 #include "stdafx.h"
00004 #include "ADsError.h"
00005 #include "IADsError.h"
00006
00007
00008 /////////////////////////////////////////////////////
00009 //
00010 // Private Functions
00011 HRESULT GetADSIError( HRESULT hr, CComBSTR &bstr );
00012 HRESULT GetErrorMessage( HRESULT hr, CComBSTR &bstr );
00013 BOOL GetMessageHelper(DWORD flags, HMODULE hModule, HRESULT hr, CComBSTR &bstr );
00014
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 //
00018
00019 STDMETHODIMP ADsError::InterfaceSupportsErrorInfo(REFIID riid)
00020 {
00021   static const IID* arr[] =
00022   {
00023     &IID_IADsError,
00024   };
00025
00026   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00027   {
00028     if (::InlineIsEqualGUID(*arr[i],riid))
00029       return S_OK;
00030   }
00031   return S_FALSE;
00032 }
00033
00034 STDMETHODIMP ADsError::GetErrorMessage(long hResult, BSTR *pbMsg)
00035 {
00036   CComBSTR bstr;
00037   HRESULT hr;
00038   hr = ::GetErrorMessage( hResult, bstr );
00039
00040   if ( SUCCEEDED(hr) )
00041   {
00042     *pbMsg = SysAllocString(bstr);
00043   }
00044
00045
00046   return hr;
00047 }
00048
00049
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // ADSI Error Message
00054 //
00055 ////////////////////////////////////////////////////////
00056
00057 #define FACILITY_ADSI  0x00005000
00058
00059
00060
00061 HRESULT GetErrorMessage( HRESULT hr, CComBSTR &bstr )
00062 {
00063
00064   bstr.Empty();
00065   if ( SUCCEEDED(hr) )
00066   {
00067     bstr = _T("SUCCESS");
00068     return S_OK;
00069   }
00070
00071   int code = HRESULT_CODE(hr);
00072
00073     if (code == -1)
00074     {
00075        bstr = _T("Unknown Error Code");
00076      return S_OK;
00077     }
00078
00079   // default is the system error message table
00080    HMODULE hModule = 0;
00081
00082    DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM;
00083
00084    int facility = HRESULT_FACILITY(hr);
00085    if ( hr & FACILITY_ADSI ) // standard ADSI Errors
00086    {
00087
00088         static HMODULE adsi_err_res_dll = 0;
00089         // use the net error message resource dll
00090         if (adsi_err_res_dll == 0)
00091         {
00092                adsi_err_res_dll =LoadLibraryEx(_T("activeds.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);
00093         }
00094
00095         hModule = adsi_err_res_dll;
00096         dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
00097
00098         // the message dll expects the entire error code
00099         code = hr;
00100
00101    }
00102    else
00103    {
00104
00105     switch (facility)
00106     {
00107
00108       case FACILITY_WIN32:    // 0x7
00109       {
00110         // included here:
00111         // lanman error codes (in it's own dll)
00112         // dns
00113         // winsock
00114
00115              static HMODULE lm_err_res_dll = 0;
00116          if (code >= NERR_BASE && code <= MAX_NERR)
00117          {
00118           // use the net error message resource dll
00119           if (lm_err_res_dll == 0)
00120           {
00121             lm_err_res_dll = LoadLibraryEx(_T("netmsg.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);
00122           }
00123
00124           hModule = lm_err_res_dll;
00125           dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
00126          }
00127       }
00128       break;
00129
00130       case FACILITY_SSPI: // 0x9
00131       {
00132         // some of these are in their own dll (those declared in issperr.h),
00133         // some are in the system message tables.
00134         // first try the system message tables.
00135         CComBSTR bTest;
00136         if( !GetMessageHelper( dwFlags, 0, code, bTest ) )
00137         {
00138           // not found.  try the secur32.dll resources
00139                 // @@ use SafeDLL here.
00140           static HMODULE sec_err_res_dll = 0;
00141           if (sec_err_res_dll == 0)
00142           {
00143             sec_err_res_dll = LoadLibraryEx(_T("secur32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);
00144           }
00145
00146           hModule = sec_err_res_dll;
00147           dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
00148         }
00149         break;
00150       }
00151
00152       default:
00153       {
00154         //do nothing;
00155         break;
00156       }
00157
00158
00159     } // switch
00160
00161
00162
00163
00164    } // end else
00165
00166
00167   // Retrieve the message
00168     GetMessageHelper( dwFlags, hModule, code, bstr );
00169
00170
00171
00172
00173
00174   //////////////////////////////////////////////////////////////////
00175   //
00176   // Extended error message may be occured.
00177   //
00178   // IADs, IADsContainer, IDirectoryObject or IDirectorySearch may return
00179   // this extended error message
00180   //
00181   ////////////////////////////////////////////////////////////////////
00182
00183   if (  (hr & FACILITY_ADSI)  ||         //adsi
00184       facility == FACILITY_WIN32  )   // and win32
00185   {
00186     WCHAR szBuffer[MAX_PATH];
00187     WCHAR szName[MAX_PATH];
00188     DWORD dwError;
00189
00190
00191     hr = ADsGetLastError( &dwError, szBuffer, (sizeof(szBuffer)/sizeof(WCHAR))-1,
00192                         szName, (sizeof(szName)/sizeof(WCHAR))-1 );
00193
00194
00195     if ( SUCCEEDED(hr) && dwError != ERROR_INVALID_DATA  && wcslen(szBuffer))
00196     {
00197       USES_CONVERSION;
00198       bstr.Append(_T("  -- Extended Error:"));
00199       bstr.Append(szName);
00200       bstr.Append(_T(" : "));
00201       bstr.Append( szBuffer );
00202     }
00203   }
00204
00205
00206   return S_OK;
00207 }
00208
00209
00210
00211
00212
00213
00214 BOOL GetMessageHelper(DWORD dwFlags, HMODULE hModule, HRESULT hr, CComBSTR &bstr )
00215 {
00216       BOOL bRet;
00217     LPTSTR lpBuffer=NULL;
00218
00219     /////////////////////////////////////////////
00220     //
00221     // Retrieve the Error message
00222     //
00223     /////////////////////////////////////////////////
00224
00225     bRet = FormatMessage(dwFlags,
00226                hModule,  hr,
00227                MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
00228                (LPTSTR) &lpBuffer, 0, NULL);
00229
00230     if ( !bRet )
00231     {
00232       TCHAR szErr[256];
00233       wsprintf(szErr, _T("Error %X"), hr );
00234       bstr =  szErr;
00235     }
00236
00237     if ( lpBuffer )
00238     {
00239       bstr.Append( lpBuffer );
00240       LocalFree( lpBuffer );
00241     }
00242
00243     return bRet;
00244
00245 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/logindlg.h Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

logindlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // logindlg.h : header file
00014 //
00015
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CLoginDlg dialog
00019
00020 class CLoginDlg : public CDialog
00021 {
00022 // Construction
00023 public:
00024   CLoginDlg(CWnd* pParent = NULL);   // standard constructor
00025
00026 // Dialog Data
00027   //{{AFX_DATA(CLoginDlg)
00028   enum { IDD = IDD_LOGIN };
00029   CString m_strLogin;
00030   //}}AFX_DATA
00031 //Data
00032   BOOL m_fDsEnabledLocaly;
00033
00034
00035
00036 // Overrides
00037   // ClassWizard generated virtual function overrides
00038   //{{AFX_VIRTUAL(CLoginDlg)
00039   protected:
00040   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00041   //}}AFX_VIRTUAL
00042
00043 // Implementation
00044 protected:
00045   BOOL IsDsEnabledLocaly();
00046
00047   // Generated message map functions
00048   //{{AFX_MSG(CLoginDlg)
00049     // NOTE: the ClassWizard will add member functions here
00050   //}}AFX_MSG
00051   DECLARE_MESSAGE_MAP()
00052 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/Msi/setup.exe/upgrdmsi.cpp Source File

  • SysMgmt
  • Msi
  • setup.exe

upgrdmsi.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved.
00004 //
00005 //  File:       upgrdmsi.cpp
00006 //
00007 //--------------------------------------------------------------------------
00008
00009 #include "setup.h"
00010 #include "resource.h"
00011
00012 // internet download
00013 #include "wininet.h"  // DeleteUrlCacheEntry, InternetCanonicalizeUrl
00014 #include "urlmon.h"   // URLDownloadToCacheFile
00015
00016 #include "wintrust.h" // WTD_UI_NONE
00017 #include <assert.h>
00018 #include <stdlib.h>
00019 #include "strsafe.h"
00020
00021 #define WIN // scope W32 API
00022
00023 #define MSISIPAPI_DllRegisterServer "DllRegisterServer"
00024 typedef HRESULT (WINAPI* PFnMsiSIPDllRegisterServer)();
00025 /////////////////////////////////////////////////////////////////////////////
00026 // IsMsiUpgradeNecessary
00027 //
00028
00029 bool IsMsiUpgradeNecessary(ULONG ulReqMsiMinVer)
00030 {
00031     // attempt to load msi.dll in the system directory
00032
00033     char szSysMsiDll[MAX_PATH] = {0};
00034     char szSystemFolder[MAX_PATH] = {0};
00035
00036     DWORD dwRet = WIN::GetSystemDirectory(szSystemFolder, MAX_PATH);
00037     if (0 == dwRet || MAX_PATH < dwRet)
00038     {
00039         // failure or buffer too small; assume upgrade is necessary
00040         DebugMsg("[Info] Can't obtain system directory; assuming upgrade is necessary");
00041         return true;
00042     }
00043
00044     if (FAILED(StringCchCopy(szSysMsiDll, sizeof(szSysMsiDll)/sizeof(szSysMsiDll[0]), szSystemFolder))
00045         || FAILED(StringCchCat(szSysMsiDll, sizeof(szSysMsiDll)/sizeof(szSysMsiDll[0]), "\\MSI.DLL")))
00046     {
00047         // failure to get path to msi.dll; assume upgrade is necessary
00048         DebugMsg("[Info] Can't obtain msi.dll path; assuming upgrade is necessary");
00049         return true;
00050     }
00051
00052     HINSTANCE hinstMsiSys = LoadLibrary(szSysMsiDll);
00053     if (0 == hinstMsiSys)
00054     {
00055         // can't load msi.dll; assume upgrade is necessary
00056         DebugMsg("[Info] Can't load msi.dll; assuming upgrade is necessary");
00057
00058         return true;
00059     }
00060     FreeLibrary(hinstMsiSys);
00061
00062     // get version on msi.dll
00063     DWORD dwInstalledMSVer;
00064     dwRet = GetFileVersionNumber(szSysMsiDll, &dwInstalledMSVer, NULL);
00065     if (ERROR_SUCCESS != dwRet)
00066     {
00067         // can't obtain version information; assume upgrade is necessary
00068         DebugMsg("[Info] Can't obtain version information; assuming upgrade is necessary");
00069
00070         return true;
00071     }
00072
00073     // compare version in system to the required minimum
00074     ULONG ulInstalledVer = HIWORD(dwInstalledMSVer) * 100 + LOWORD(dwInstalledMSVer);
00075     if (ulInstalledVer < ulReqMsiMinVer)
00076     {
00077         // upgrade is necessary
00078         DebugMsg("[Info] Windows Installer upgrade is required.  System Version = %d, Minimum Version = %d.\n", ulInstalledVer, ulReqMsiMinVer);
00079
00080         return true;
00081     }
00082
00083     // no upgrade is necessary
00084     DebugMsg("[Info] No upgrade is necessary.  System version meets minimum requirements\n");
00085     return false;
00086 }
00087
00088 /////////////////////////////////////////////////////////////////////////////
00089 // UpgradeMsi
00090 //
00091
00092 UINT UpgradeMsi(HINSTANCE hInst, CDownloadUI *piDownloadUI, LPCSTR szAppTitle, LPCSTR szBase, LPCSTR szUpdate, ULONG ulMinVer)
00093 {
00094     char *szTempPath    = 0;
00095     char *szUpdatePath = 0;
00096     char *szFilePart    = 0;
00097
00098     DWORD cchTempPath    = 0;
00099     DWORD cchUpdatePath = 0;
00100     DWORD cchReturn      = 0;
00101     DWORD dwLastError    = 0;
00102     DWORD dwFileAttrib   = 0;
00103     UINT  uiRet          = 0;
00104
00105     HRESULT hr           = S_OK;
00106
00107     // generate the path to the MSI update file =  szBase + szUpdate
00108     //   note: szUpdate is a relative path
00109
00110     cchTempPath = lstrlen(szBase) + lstrlen(szUpdate) + 2; // 1 for null terminator, 1 for back slash
00111     szTempPath = new char[cchTempPath];
00112     if (!szTempPath)
00113     {
00114         ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00115         uiRet = ERROR_OUTOFMEMORY;
00116         goto CleanUp;
00117     }
00118     memset((void*)szTempPath, 0x00, cchTempPath*sizeof(char));
00119
00120     // find 'setup.exe' in the path so we can remove it -- this is an already expanded path, that represents
00121     //  our current running location.  It includes our executable name -- we want to find that and get rid of it
00122     if (0 == GetFullPathName(szBase, cchTempPath, szTempPath, &szFilePart))
00123     {
00124         uiRet = GetLastError();
00125         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00126         goto CleanUp;
00127     }
00128     if (szFilePart)
00129         *szFilePart = '\0';
00130
00131     hr = StringCchCat(szTempPath, cchTempPath, szUpdate);
00132     if (FAILED(hr))
00133     {
00134         uiRet = HRESULT_CODE(hr);
00135         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00136         goto CleanUp;
00137     }
00138
00139     cchUpdatePath = 2*cchTempPath;
00140     szUpdatePath = new char[cchUpdatePath];
00141     if (!szUpdatePath)
00142     {
00143         ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00144         uiRet = ERROR_OUTOFMEMORY;
00145         goto CleanUp;
00146     }
00147
00148     // normalize the path
00149     cchReturn = GetFullPathName(szTempPath, cchUpdatePath, szUpdatePath, &szFilePart);
00150     if (cchReturn > cchUpdatePath)
00151     {
00152         // try again, with larger buffer
00153         delete [] szUpdatePath;
00154         cchUpdatePath = cchReturn;
00155         szUpdatePath = new char[cchUpdatePath];
00156         if (!szUpdatePath)
00157         {
00158             ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00159             uiRet = ERROR_OUTOFMEMORY;
00160             goto CleanUp;
00161         }
00162         cchReturn = GetFullPathName(szTempPath, cchUpdatePath, szUpdatePath, &szFilePart);
00163     }
00164     if (0 == cchReturn)
00165     {
00166         uiRet = GetLastError();
00167         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00168         goto CleanUp;
00169     }
00170
00171     // no download is necessary -- but we can check for the file's existence
00172     dwFileAttrib = GetFileAttributes(szUpdatePath);
00173     if (0xFFFFFFFF == dwFileAttrib)
00174     {
00175         // Update executable is missing
00176         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_NOUPDATE, szUpdatePath);
00177         uiRet = ERROR_FILE_NOT_FOUND;
00178         goto CleanUp;
00179     }
00180
00181     uiRet = ValidateUpdate(hInst, piDownloadUI, szAppTitle, szUpdatePath, szUpdatePath, ulMinVer);
00182
00183 CleanUp:
00184     if (szTempPath)
00185         delete [] szTempPath;
00186     if (szUpdatePath)
00187         delete [] szUpdatePath;
00188
00189     return uiRet;
00190 }
00191
00192 /////////////////////////////////////////////////////////////////////////////
00193 // DownloadAndUpgradeMsi
00194 //
00195
00196 UINT DownloadAndUpgradeMsi(HINSTANCE hInst, CDownloadUI *piDownloadUI, LPCSTR szAppTitle, LPCSTR szUpdateLocation, LPCSTR szUpdate, LPCSTR szModuleFile, ULONG ulMinVer)
00197 {
00198     char *szTempPath         = 0;
00199     char *szUpdatePath       = 0;
00200     char *szUpdateCacheFile  = 0;
00201     const char *pch          = 0;
00202
00203     DWORD cchTempPath         = 0;
00204     DWORD cchUpdatePath       = 0;
00205     DWORD cchUpdateCacheFile  = 0;
00206     DWORD dwLastError         = 0;
00207     UINT  uiRet               = 0;
00208     HRESULT hr                = 0;
00209     DWORD Status              = ERROR_SUCCESS;
00210
00211     char szDebugOutput[MAX_STR_LENGTH] = {0};
00212     char szText[MAX_STR_CAPTION]       = {0};
00213
00214     // generate the path to the update == UPDATELOCATION + szUpdate
00215     //   note: szUpdate is a relative path
00216     cchTempPath = lstrlen(szUpdateLocation) + lstrlen(szUpdate) + 2; // 1 for slash, 1 for null
00217     szTempPath = new char[cchTempPath];
00218     if (!szTempPath)
00219     {
00220         ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00221         uiRet = ERROR_OUTOFMEMORY;
00222         goto CleanUp;
00223     }
00224     memset((void*)szTempPath, 0x0, cchTempPath*sizeof(char));
00225     hr = StringCchCopy(szTempPath, cchTempPath, szUpdateLocation);
00226     if (FAILED(hr))
00227     {
00228         uiRet = HRESULT_CODE(hr);
00229         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00230         goto CleanUp;
00231     }
00232
00233     // check for trailing slash on szUpdateLocation
00234     pch = szUpdateLocation + lstrlen(szUpdateLocation) + 1; // put at null terminator
00235     pch = CharPrev(szUpdateLocation, pch);
00236     if (*pch != '/')
00237     {
00238         hr = StringCchCat(szTempPath, cchTempPath, szUrlPathSep);
00239         if (FAILED(hr))
00240         {
00241             uiRet = HRESULT_CODE(hr);
00242             PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00243             goto CleanUp;
00244         }
00245     }
00246
00247     hr = StringCchCat(szTempPath, cchTempPath, szUpdate);
00248     if (FAILED(hr))
00249     {
00250         uiRet = HRESULT_CODE(hr);
00251         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00252         goto CleanUp;
00253     }
00254
00255     // canonicalize the URL path
00256     cchUpdatePath = cchTempPath*2;
00257     szUpdatePath = new char[cchUpdatePath];
00258     if (!szUpdatePath)
00259     {
00260         ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00261         uiRet = ERROR_OUTOFMEMORY;
00262         goto CleanUp;
00263     }
00264
00265     if (!InternetCanonicalizeUrl(szTempPath, szUpdatePath, &cchUpdatePath, 0))
00266     {
00267         dwLastError = GetLastError();
00268         if (ERROR_INSUFFICIENT_BUFFER == dwLastError)
00269         {
00270             // try again
00271             delete [] szUpdatePath;
00272             szUpdatePath = new char[cchUpdatePath];
00273             if (!szUpdatePath)
00274             {
00275                 ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00276                 uiRet = ERROR_OUTOFMEMORY;
00277                 goto CleanUp;
00278             }
00279             dwLastError = 0; // reset to success for 2nd attempt
00280             if (!InternetCanonicalizeUrl(szTempPath, szUpdatePath, &cchUpdatePath, 0))
00281                 dwLastError = GetLastError();
00282         }
00283     }
00284     if (0 != dwLastError)
00285     {
00286         // error -- invalid path/Url
00287         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INVALID_PATH, szTempPath);
00288         uiRet = dwLastError;
00289         goto CleanUp;
00290     }
00291
00292     DebugMsg("[Info] Downloading update package from --> %s\n", szUpdatePath);
00293
00294     // set action text for download
00295     WIN::LoadString(hInst, IDS_DOWNLOADING_UPDATE, szText, MAX_STR_CAPTION);
00296     if (irmCancel == piDownloadUI->SetActionText(szText))
00297     {
00298         ReportUserCancelled(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00299         uiRet = ERROR_INSTALL_USEREXIT;
00300         goto CleanUp;
00301     }
00302
00303     // download the Update file so we can run it -- must be local to execute
00304     szUpdateCacheFile = new char[MAX_PATH];
00305     cchUpdateCacheFile = MAX_PATH;
00306     if (!szUpdateCacheFile)
00307     {
00308         ReportErrorOutOfMemory(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00309         uiRet = ERROR_OUTOFMEMORY;
00310         goto CleanUp;
00311     }
00312
00313     hr = WIN::URLDownloadToCacheFile(NULL, szUpdatePath, szUpdateCacheFile, cchUpdateCacheFile, 0, /* IBindStatusCallback = */ &CDownloadBindStatusCallback(piDownloadUI));
00314     if (piDownloadUI->HasUserCanceled())
00315     {
00316         ReportUserCancelled(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle);
00317         uiRet = ERROR_INSTALL_USEREXIT;
00318         goto CleanUp;
00319     }
00320     if (FAILED(hr))
00321     {
00322         // error during download -- probably because file not found (or lost connection)
00323         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_NOUPDATE, szUpdatePath);
00324         uiRet = ERROR_FILE_NOT_FOUND;
00325         goto CleanUp;
00326     }
00327
00328
00329     //
00330     // Perform trust check on MSI. Note, this must be done in a separate process.
00331     // This is because MSI 2.0 and higher register sip callbacks for verifying
00332     // digital signatures on msi files. At this point, it is quite likely that
00333     // the SIP callbacks have not been registered. So we don't want to load
00334     // wintrust.dll into this process's image yet, otherwise it will remain unaware
00335     // of the sip callbacks registered by WindowsInstaller-KB884016-x86.exe and will
00336     // fail later when it tries to verify the signature on the msi file downloaded
00337     // from the web.
00338     //
00339     Status = ExecuteVerifyUpdate(szModuleFile, szUpdateCacheFile);
00340     if (TRUST_E_PROVIDER_UNKNOWN == Status)
00341     {
00342         PostError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_NO_WINTRUST);
00343         uiRet = ERROR_CALL_NOT_IMPLEMENTED;
00344         goto CleanUp;
00345     }
00346     else if (ERROR_SUCCESS != Status)
00347     {
00348         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_UNTRUSTED, szUpdateCacheFile);
00349         uiRet = HRESULT_CODE(TRUST_E_SUBJECT_NOT_TRUSTED);
00350         goto CleanUp;
00351     }
00352
00353     // continue other validations
00354     uiRet = ValidateUpdate(hInst, piDownloadUI, szAppTitle, szUpdateCacheFile, szModuleFile, ulMinVer);
00355
00356 CleanUp:
00357     if (szTempPath)
00358         delete [] szTempPath;
00359     if (szUpdatePath)
00360         delete [] szUpdatePath;
00361     if (szUpdateCacheFile)
00362     {
00363         WIN::DeleteUrlCacheEntry(szUpdateCacheFile);
00364         delete [] szUpdateCacheFile;
00365     }
00366
00367     return uiRet;
00368 }
00369
00370 /////////////////////////////////////////////////////////////////////////////
00371 // IsUpdateRequiredVersion
00372 //
00373 //  update package version is stamped as rmj.rmm.rup.rin
00374 //
00375
00376 bool IsUpdateRequiredVersion(LPSTR szFilename, ULONG ulMinVer)
00377 {
00378     // get version of update package
00379     DWORD dwUpdateMSVer;
00380     DWORD dwRet = GetFileVersionNumber(szFilename, &dwUpdateMSVer, NULL);
00381     if (ERROR_SUCCESS != dwRet)
00382     {
00383         // can't obtain version information; assume not proper version
00384         DebugMsg("[Info] Can't obtain version information for update package; assuming it is not the proper version\n");
00385         return false;
00386     }
00387
00388     // compare version at source to required minimum
00389     ULONG ulSourceVer = HIWORD(dwUpdateMSVer) * 100 + LOWORD(dwUpdateMSVer);
00390     if (ulSourceVer < ulMinVer)
00391     {
00392         // source version won't get us to our minimum version
00393         char szDebugOutput[MAX_STR_LENGTH] = {0};
00394         DebugMsg("[Info] The update package is improper version for upgrade. Update package Version = %d, Minimum Version = %d.\n", ulSourceVer, ulMinVer);
00395
00396         return false;
00397     }
00398
00399     return true;
00400 }
00401
00402 /////////////////////////////////////////////////////////////////////////////
00403 // ValidateUpdate
00404 //
00405
00406 UINT ValidateUpdate(HINSTANCE hInst, CDownloadUI *piDownloadUI, LPCSTR szAppTitle, LPSTR szUpdatePath, LPCSTR szModuleFile, ULONG ulMinVer)
00407 {
00408     UINT uiRet = ERROR_SUCCESS;
00409
00410     char szShortPath[MAX_PATH]          = {0};
00411
00412     // ensure Update is right version for Windows Installer upgrade
00413     if (!IsUpdateRequiredVersion(szUpdatePath, ulMinVer))
00414     {
00415         // Update won't get us the right upgrade
00416         PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_INCORRECT_UPDATE, szUpdatePath);
00417         return ERROR_INVALID_PARAMETER;
00418     }
00419
00420     // upgrade msi
00421     uiRet = ExecuteUpgradeMsi(szUpdatePath);
00422     switch (uiRet)
00423     {
00424     case ERROR_SUCCESS:
00425     case ERROR_SUCCESS_REBOOT_REQUIRED:
00426         {
00427             // nothing required at this time
00428             break;
00429         }
00430     case ERROR_FILE_NOT_FOUND:
00431         {
00432             // Update executable not found
00433             PostFormattedError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_NOUPDATE, szUpdatePath);
00434             break;
00435         }
00436     default: // failure
00437         {
00438             // report error
00439             PostError(hInst, piDownloadUI->GetCurrentWindow(), szAppTitle, IDS_FAILED_TO_UPGRADE_MSI);
00440             break;
00441         }
00442     }
00443     return uiRet;
00444 }
00445
00446 /////////////////////////////////////////////////////////////////////////////
00447 // ExecuteUpgradeMsi
00448 //
00449
00450 DWORD ExecuteUpgradeMsi(LPSTR szUpgradeMsi)
00451 {
00452     DebugMsg("[Info] Running update package from --> %s\n", szUpgradeMsi);
00453
00454     DWORD dwResult = 0;
00455
00456     // build up CreateProcess structures
00457     STARTUPINFO          sui;
00458     PROCESS_INFORMATION  pi;
00459
00460     memset((void*)&pi, 0x00, sizeof(PROCESS_INFORMATION));
00461     memset((void*)&sui, 0x00, sizeof(STARTUPINFO));
00462     sui.cb          = sizeof(STARTUPINFO);
00463     sui.dwFlags     = STARTF_USESHOWWINDOW;
00464     sui.wShowWindow = SW_SHOW;
00465
00466     //
00467     // build command line and specify delayreboot option to Update
00468     //  three acounts for terminating null plus quotes for module
00469     DWORD cchCommandLine = lstrlen(szUpgradeMsi) + lstrlen(szDelayReboot) + 3;
00470     char *szCommandLine = new char[cchCommandLine];
00471
00472     if (!szCommandLine)
00473         return ERROR_OUTOFMEMORY;
00474
00475     if (FAILED(StringCchCopy(szCommandLine, cchCommandLine, "\""))
00476         || FAILED(StringCchCat(szCommandLine, cchCommandLine, szUpgradeMsi))
00477         || FAILED(StringCchCat(szCommandLine, cchCommandLine, "\""))
00478         || FAILED(StringCchCat(szCommandLine, cchCommandLine, szDelayReboot)))
00479     {
00480         delete [] szCommandLine;
00481         return ERROR_INSTALL_FAILURE;
00482     }
00483
00484     //
00485     // run update process
00486     if(!WIN::CreateProcess(NULL, szCommandLine, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &sui, &pi))
00487     {
00488         // failed to launch.
00489         dwResult = GetLastError();
00490         delete [] szCommandLine;
00491         return dwResult;
00492     }
00493
00494     dwResult = WaitForProcess(pi.hProcess);
00495     if(ERROR_SUCCESS != dwResult)
00496     {
00497         delete [] szCommandLine;
00498         return dwResult;
00499     }
00500
00501     DWORD dwExitCode = 0;
00502     WIN::GetExitCodeProcess(pi.hProcess, &dwExitCode);
00503
00504     WIN::CloseHandle(pi.hProcess);
00505
00506     delete [] szCommandLine;
00507
00508     return dwExitCode;
00509 }
00510
00511 /////////////////////////////////////////////////////////////////////////////
00512 // ExecuteVerifyUpdate
00513 //
00514 DWORD ExecuteVerifyUpdate(LPCSTR szModuleFile, LPCSTR szUpdateCachePath)
00515 {
00516     DWORD dwResult = 0;
00517
00518     // build up CreateProcess structures
00519     STARTUPINFO          sui;
00520     PROCESS_INFORMATION  pi;
00521
00522     memset((void*)&pi, 0x00, sizeof(PROCESS_INFORMATION));
00523     memset((void*)&sui, 0x00, sizeof(STARTUPINFO));
00524     sui.cb          = sizeof(STARTUPINFO);
00525     sui.dwFlags     = STARTF_USESHOWWINDOW;
00526     sui.wShowWindow = SW_SHOW;
00527
00528     //
00529     // Build command line and specify delayreboot option to Update
00530     // The nine extra characters are required for the following:
00531     //      2 for the quotes enclosing the module path
00532     //      2 for /v
00533     //      2 for the spaces before and after /v
00534     //      2 for the quotes enclosing the Update path
00535     //      1 for the terminating null.
00536     //
00537     DWORD cchCommandLine = lstrlen(szModuleFile) + lstrlen(szUpdateCachePath) + 9;
00538     char *szCommandLine = new char[cchCommandLine];
00539
00540     if (!szCommandLine)
00541         return ERROR_OUTOFMEMORY;
00542
00543     if (FAILED(StringCchCopy(szCommandLine, cchCommandLine, "\""))
00544         || FAILED(StringCchCat(szCommandLine, cchCommandLine, szModuleFile))
00545         || FAILED(StringCchCat(szCommandLine, cchCommandLine, "\""))
00546         || FAILED(StringCchCat(szCommandLine, cchCommandLine, " /v \""))
00547         || FAILED(StringCchCat(szCommandLine, cchCommandLine, szUpdateCachePath))
00548         || FAILED(StringCchCat(szCommandLine, cchCommandLine, "\"")))
00549     {
00550         delete [] szCommandLine;
00551         return ERROR_INSTALL_FAILURE;
00552     }
00553
00554     //
00555     // Run the verification process. We use a copy of ourselves to do this.
00556     //
00557     if(!WIN::CreateProcess(NULL, szCommandLine, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &sui, &pi))
00558     {
00559         // failed to launch.
00560         delete [] szCommandLine;
00561         dwResult = GetLastError();
00562         return dwResult;
00563     }
00564
00565     dwResult = WaitForProcess(pi.hProcess);
00566     if(ERROR_SUCCESS != dwResult)
00567     {
00568         delete [] szCommandLine;
00569         return dwResult;
00570     }
00571
00572     DWORD dwExitCode = 0;
00573     WIN::GetExitCodeProcess(pi.hProcess, &dwExitCode);
00574
00575     WIN::CloseHandle(pi.hProcess);
00576
00577     DebugMsg("[Info] Verification of Update returned %d\n", dwExitCode);
00578
00579     delete [] szCommandLine;
00580
00581     return dwExitCode;
00582 }
00583
00584 /////////////////////////////////////////////////////////////////////////////
00585 // WaitForProcess
00586 //
00587
00588 DWORD WaitForProcess(HANDLE handle)
00589 {
00590     DWORD dwResult = NOERROR;
00591
00592     MSG msg;
00593     memset((void*)&msg, 0x00, sizeof(MSG));
00594
00595     //loop forever to wait
00596     while (true)
00597     {
00598         //wait for object
00599         switch (WIN::MsgWaitForMultipleObjects(1, &handle, false, INFINITE, QS_ALLINPUT))
00600         {
00601         //success!
00602         case WAIT_OBJECT_0:
00603             goto Finish;
00604
00605         //not the process that we're waiting for
00606         case (WAIT_OBJECT_0 + 1):
00607             {
00608                 if (WIN::PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
00609                 {
00610                     WIN::TranslateMessage(&msg);
00611                     WIN::DispatchMessage(&msg);
00612                 }
00613
00614                 break;
00615             }
00616         //did not return an OK; return error status
00617         default:
00618             {
00619                 dwResult = WIN::GetLastError();
00620                 goto Finish;
00621             }
00622         }
00623     }
00624
00625 Finish:
00626     return dwResult;
00627 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EdAnnotator/AnnotatorProject/Annotator.h Source File

  • Web
  • Browser
  • EdAnnotator
  • AnnotatorProject

Annotator.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // Annotator.h : Declaration of the CAnnotator
00006
00007 #ifndef __ANNOTATOR_H_
00008 #define __ANNOTATOR_H_
00009
00010 #include "resource.h"       // main symbols
00011 #include <atlctl.h>
00012 #include "mshtml.h"
00013
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CAnnotator
00017 class ATL_NO_VTABLE CAnnotator :
00018     public CComObjectRootEx<CComSingleThreadModel>,
00019     public IDispatchImpl<IAnnotator, &IID_IAnnotator, &LIBID_EDANNOTATORLib>,
00020     public CComControl<CAnnotator>,
00021     public IPersistStreamInitImpl<CAnnotator>,
00022     public IOleControlImpl<CAnnotator>,
00023     public IOleObjectImpl<CAnnotator>,
00024     public IOleInPlaceActiveObjectImpl<CAnnotator>,
00025     public IViewObjectExImpl<CAnnotator>,
00026     public IOleInPlaceObjectWindowlessImpl<CAnnotator>,
00027     public CComCoClass<CAnnotator, &CLSID_Annotator>,
00028     /* The following untrusted use of IObjectSafetyImpl is for simplicity
00029     in this sample code.  This usage in production code can expose a
00030     security risk in some situations. */
00031     public IObjectSafetyImpl<CAnnotator,
00032                              INTERFACESAFE_FOR_UNTRUSTED_CALLER |
00033                              INTERFACESAFE_FOR_UNTRUSTED_DATA>,
00034     public IHTMLEditDesigner
00035
00036 {
00037 public:
00038     CAnnotator()
00039     {
00040     }
00041
00042 DECLARE_REGISTRY_RESOURCEID(IDR_ANNOTATOR)
00043
00044 DECLARE_PROTECT_FINAL_CONSTRUCT()
00045
00046 BEGIN_COM_MAP(CAnnotator)
00047     COM_INTERFACE_ENTRY(IAnnotator)
00048     COM_INTERFACE_ENTRY(IDispatch)
00049     COM_INTERFACE_ENTRY(IViewObjectEx)
00050     COM_INTERFACE_ENTRY(IViewObject2)
00051     COM_INTERFACE_ENTRY(IViewObject)
00052     COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
00053     COM_INTERFACE_ENTRY(IOleInPlaceObject)
00054     COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
00055     COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
00056     COM_INTERFACE_ENTRY(IOleControl)
00057     COM_INTERFACE_ENTRY(IOleObject)
00058     COM_INTERFACE_ENTRY(IPersistStreamInit)
00059     COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
00060     COM_INTERFACE_ENTRY(IObjectSafety)
00061     COM_INTERFACE_ENTRY(IHTMLEditDesigner)
00062 END_COM_MAP()
00063
00064 BEGIN_PROP_MAP(CAnnotator)
00065     PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
00066     PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
00067     // Example entries
00068     // PROP_ENTRY("Property Description", dispid, clsid)
00069     // PROP_PAGE(CLSID_StockColorPage)
00070 END_PROP_MAP()
00071
00072 BEGIN_MSG_MAP(CAnnotator)
00073     CHAIN_MSG_MAP(CComControl<CAnnotator>)
00074     DEFAULT_REFLECTION_HANDLER()
00075 END_MSG_MAP()
00076 // Handler prototypes:
00077 //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00078 //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00079 //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
00080
00081 // IViewObjectEx
00082     DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
00083
00084 // IHTMLEditDesigner
00085 STDMETHOD(PostEditorEventNotify)(DISPID inEvtDispId, IHTMLEventObj *pIEventObj);
00086 STDMETHOD(PostHandleEvent)(DISPID inEvtDispId, IHTMLEventObj *pIEventObj);
00087 STDMETHOD(PreHandleEvent)(DISPID inEvtDispId, IHTMLEventObj *pIEventObj);
00088 STDMETHOD(TranslateAccelerator)(DISPID inEvtDispId, IHTMLEventObj *pIEventObj);
00089
00090 // IAnnotator
00091 public:
00092   STDMETHOD(AddComment)();
00093     STDMETHOD(ShowCommentGlyphs)(BOOL bShow);
00094     STDMETHOD(DetachAnnotator)();
00095     STDMETHOD(AttachAnnotator)(IHTMLDocument2* pDoc);
00096
00097 // Helper Methods
00098 private:
00099     STDMETHOD(OpenCommentEditBox)(IHTMLElement* pSrcElem);
00100     STDMETHOD(CloseCommentEditBox)();
00101
00102     HRESULT OnDraw(ATL_DRAWINFO& di)
00103     {
00104         RECT& rc = *(RECT*)di.prcBounds;
00105         Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
00106
00107         SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
00108         LPCTSTR pszText = _T("ATL 3.0 : Annotator");
00109         TextOut(di.hdcDraw,
00110             (rc.left + rc.right) / 2,
00111             (rc.top + rc.bottom) / 2,
00112             pszText,
00113             lstrlen(pszText));
00114
00115         return S_OK;
00116     }
00117
00118 private:
00119     CComPtr<IHTMLDocument2> m_spDoc;
00120     CComPtr<IHTMLEditDesigner> m_spDesigner;
00121     CComPtr<IHTMLElement> m_spSrcElem;
00122     CComPtr<IHTMLElement> m_spCommentEditBox;
00123     HCURSOR m_hOldCursor;
00124 };
00125
00126 #endif //__ANNOTATOR_H_
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CInstPro Member List

This is the complete list of members for CInstPro, including all inherited members.
CancelAsyncCall(IWbemObjectSink __RPC_FAR *pSink) | CInstPro | [inline]
CInstPro(BSTR ObjectPath=NULL, BSTR User=NULL, BSTR Password=NULL, IWbemContext *pCtx=NULL) | CInstPro |
CreateClassEnum(const BSTR Superclass, long lFlags, IWbemContext __RPC_FAR *pCtx, IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) | CInstPro | [inline]
CreateClassEnumAsync(const BSTR Superclass, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
CreateInstanceEnum(const BSTR Class, long lFlags, IWbemContext __RPC_FAR *pCtx, IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) | CInstPro | [inline]
CreateInstanceEnumAsync(const BSTR Class, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro |
DeleteClass(const BSTR Class, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) | CInstPro | [inline]
DeleteClassAsync(const BSTR Class, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
DeleteInstance(const BSTR ObjectPath, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) | CInstPro | [inline]
DeleteInstanceAsync(const BSTR ObjectPath, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
ExecMethod(const BSTR, const BSTR, long, IWbemContext *, IWbemClassObject *, IWbemClassObject **, IWbemCallResult **) | CInstPro | [inline]
ExecMethodAsync(const BSTR, const BSTR, long, IWbemContext *, IWbemClassObject *, IWbemObjectSink *) | CInstPro | [inline]
ExecNotificationQuery(const BSTR QueryLanguage, const BSTR Query, long lFlags, IWbemContext __RPC_FAR *pCtx, IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) | CInstPro | [inline]
ExecNotificationQueryAsync(const BSTR QueryLanguage, const BSTR Query, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
ExecQuery(const BSTR QueryLanguage, const BSTR Query, long lFlags, IWbemContext __RPC_FAR *pCtx, IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) | CInstPro | [inline]
ExecQueryAsync(const BSTR QueryLanguage, const BSTR Query, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
GetByPath(BSTR Path, IWbemClassObject FAR *FAR *pObj, IWbemContext *pCtx) | CInstPro |
GetObject(const BSTR ObjectPath, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject, IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) | CInstPro | [inline]
GetObjectAsync(const BSTR ObjectPath, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro |
Initialize(LPWSTR pszUser, LONG lFlags, LPWSTR pszNamespace, LPWSTR pszLocale, IWbemServices *pNamespace, IWbemContext *pCtx, IWbemProviderInitSink *pInitSink) | CInstPro |
m_cRef | CInstPro | [protected]
m_pNamespace | CInstPro | [protected]
OpenNamespace(const BSTR Namespace, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace, IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) | CInstPro | [inline]
PutClass(IWbemClassObject __RPC_FAR *pObject, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) | CInstPro | [inline]
PutClassAsync(IWbemClassObject __RPC_FAR *pObject, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
PutInstance(IWbemClassObject __RPC_FAR *pInst, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) | CInstPro | [inline]
PutInstanceAsync(IWbemClassObject __RPC_FAR *pInst, long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pResponseHandler) | CInstPro | [inline]
QueryInterface(REFIID, PPVOID) | CInstPro |
QueryObjectSink(long lFlags, IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) | CInstPro | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CInstPro |
STDMETHODIMP_(ULONG) Release(void) | CInstPro |
~CInstPro(void) | CInstPro |
Generated on Wed Nov 13 2024 16:56:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConClien/SINK.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConClien

SINK.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SINK.CPP
00003
00004   Summary:   Implementation file for the COBallSink COM Object Class.
00005
00006              COBallSink offers a main IUnknown interface and the IBallSink
00007              interface (with the Moving Ball related event features).
00008              This multiple interface COM Object Class is achieved via the
00009              technique of nested classes.  The implementation of the
00010              IBallSink interface is nested inside the COBallSink Class.
00011
00012              For a comprehensive tutorial code tour of this module's
00013              contents and offerings see the tutorial CONCLIEN.HTM
00014              file. For more specific technical details on the internal
00015              workings see the comments dispersed throughout the module's
00016              source code.
00017
00018   Classes:   COBallSink.
00019
00020   Functions: none.
00021
00022   Origin:    6-3-96: atrent - Editor-inheritance from BALL.CPP in
00023              the CONSERVE Tutorial Code Sample.
00024
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040
00041 /*---------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will be calling the COM/OLE Libraries.
00044   We include OLECTL.H because it has definitions for connectable objects.
00045   We include APPUTIL.H because we will be building this application using
00046     the convenient Virtual Window and Dialog classes and other
00047     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00048   We include IBALL.H and BALLGUID.H for the common Ball-related Interface
00049     class, GUID, and CLSID specifications.
00050   We include GUIBALL.H because it declares the class for the main C++
00051     object that can service the Sink events.
00052   We include SINK.H because it has the class COBallSink declarations.
00053 ---------------------------------------------------------------------------*/
00054 #include <windows.h>
00055 #include <ole2.h>
00056 #include <olectl.h>
00057 #include <apputil.h>
00058 #include <iball.h>
00059 #include <ballguid.h>
00060 #include "guiball.h"
00061 #include "sink.h"
00062
00063
00064 /*---------------------------------------------------------------------------
00065   COBallSink's implementation of its main COM object class including
00066   Constructor, Destructor, QueryInterface, AddRef, and Release.
00067 ---------------------------------------------------------------------------*/
00068
00069 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00070   Method:   COBallSink::COBallSink
00071
00072   Summary:  COBallSink Constructor. Note the member initializer:
00073             "m_ImpIBallSink(this, pUnkOuter)" which is used to pass the
00074             'this' and pUnkOuter pointers of this constructor function to
00075             the constructor in the instantiation of the implementation of
00076             the CImpIBallSink interface (which is nested inside this
00077             present COBallSink Object Class).
00078
00079   Args:     IUnknown* pUnkOuter,
00080               Pointer to the the outer Unknown.  NULL means this COM Object
00081               is not being Aggregated.  Non NULL means it is being created
00082               on behalf of an outside COM object that is reusing it via
00083               aggregation.
00084             CGuiBall* pGuiBall)
00085               Pointer to the main C++ object that can service the BallSink
00086               events.
00087
00088   Modifies: m_cRefs, m_pUnkOuter, m_pGuiBall.
00089
00090   Returns:  void
00091 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00092 COBallSink::COBallSink(
00093   IUnknown* pUnkOuter,
00094   CGuiBall* pGuiBall) :
00095   m_ImpIBallSink(this, pUnkOuter)
00096 {
00097   // Zero the COM object's reference count.
00098   m_cRefs = 0;
00099
00100   // No AddRef necessary if non-NULL, as we're nested.
00101   m_pUnkOuter = pUnkOuter;
00102
00103   // Assign the pointer to the Sink service C++ object.
00104   m_pGuiBall = pGuiBall;
00105
00106   return;
00107 }
00108
00109
00110 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00111   Method:   COBallSink::~COBallSink
00112
00113   Summary:  COBallSink Destructor.
00114
00115   Args:     void
00116
00117   Modifies: .
00118
00119   Returns:  void
00120 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00121 COBallSink::~COBallSink(void)
00122 {
00123   return;
00124 }
00125
00126
00127 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00128   Method:   COBallSink::QueryInterface
00129
00130   Summary:  QueryInterface of the COBallSink non-delegating
00131             IUnknown implementation.
00132
00133   Args:     REFIID riid,
00134               [in] GUID of the Interface being requested.
00135             PPVOID ppv)
00136               [out] Address of the caller's pointer variable that will
00137               receive the requested interface pointer.
00138
00139   Modifies: .
00140
00141   Returns:  HRESULT
00142 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00143 STDMETHODIMP COBallSink::QueryInterface(
00144                REFIID riid,
00145                PPVOID ppv)
00146 {
00147   HRESULT hr = E_NOINTERFACE;
00148
00149   *ppv = NULL;
00150
00151   if (IID_IUnknown == riid)
00152     *ppv = this;
00153   else if (IID_IBallSink == riid)
00154     *ppv = &m_ImpIBallSink;
00155
00156   if (NULL != *ppv)
00157   {
00158     // We've handed out a pointer to the interface so obey the COM rules
00159     // and AddRef the reference count.
00160     ((LPUNKNOWN)*ppv)->AddRef();
00161     hr = NOERROR;
00162   }
00163
00164
00165   return (hr);
00166 }
00167
00168
00169 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00170   Method:   COBallSink::AddRef
00171
00172   Summary:  AddRef of the COBallSink non-delegating IUnknown implementation.
00173
00174   Args:     void
00175
00176   Modifies: m_cRefs.
00177
00178   Returns:  ULONG
00179               New value of m_cRefs (COM object's reference count).
00180 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00181 STDMETHODIMP_(ULONG) COBallSink::AddRef(void)
00182 {
00183   ULONG cRefs;
00184
00185   cRefs = ++m_cRefs;
00186
00187   return cRefs;
00188 }
00189
00190
00191 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00192   Method:   COBallSink::Release
00193
00194   Summary:  Release of the COBallSink non-delegating IUnknown implementation.
00195
00196   Args:     void
00197
00198   Modifies: m_cRefs.
00199
00200   Returns:  ULONG
00201               New value of m_cRefs (COM object's reference count).
00202 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00203 STDMETHODIMP_(ULONG) COBallSink::Release(void)
00204 {
00205   ULONG cRefs;
00206
00207   cRefs = --m_cRefs;
00208
00209   if (0 == cRefs)
00210   {
00211     // We artificially bump the main ref count to prevent reentrancy
00212     // via the main object destructor.  Not really needed in this
00213     // COBallSink but a good practice because we are aggregatable and
00214     // may at some point in the future add something entertaining like
00215     // some Releases to the COBallSink destructor.
00216     m_cRefs++;
00217     delete this;
00218   }
00219
00220   return cRefs;
00221 }
00222
00223
00224 /*---------------------------------------------------------------------------
00225   COBallSink's nested implementation of the IBallSink interface including
00226   Constructor, Destructor, QueryInterface, AddRef, Release, Reset, Move,
00227   and GetBall. This interface implementation also has internal methods
00228   that are not particulary intended for outside clients: GetDimensions,
00229   SetDimensions, GetDirection, SetDirection, GetPosition, SetPostion,
00230   CheckBounce, and FindThread. The IBallSink interface only provides client
00231   access to the IUnknown methods and the Reset, Move, and GetBall methods.
00232   Some or all of these internal methods could be exposed by the IBallSink
00233   interface by adding them to the IBallSink declaration in IBALL.H.
00234 ---------------------------------------------------------------------------*/
00235
00236 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00237   Method:   COBallSink::CImpIBallSink::CImpIBallSink
00238
00239   Summary:  Constructor for the CImpIBallSink interface instantiation.
00240
00241   Args:     COBallSink* pBackObj,
00242               Back pointer to the parent outer object.
00243             IUnknown* pUnkOuter
00244               Pointer to the outer Unknown.  For delegation.
00245
00246   Modifies: m_pBackObj, m_pUnkOuter.
00247
00248   Returns:  void
00249 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00250 COBallSink::CImpIBallSink::CImpIBallSink(
00251   COBallSink* pBackObj,
00252   IUnknown* pUnkOuter)
00253 {
00254   // Init the Back Object Pointer to point to the parent object.
00255   m_pBackObj = pBackObj;
00256
00257   // Init the CImpIBallSink interface's delegating Unknown pointer.  We
00258   // use the Back Object pointer for IUnknown delegation here if we are
00259   // not being aggregated.  If we are being aggregated we use the supplied
00260   // pUnkOuter for IUnknown delegation.  In either case the pointer
00261   // assignment requires no AddRef because the CImpIBallSink lifetime is
00262   // quaranteed by the lifetime of the parent object in which
00263   // CImpIBallSink is nested.
00264   if (NULL == pUnkOuter)
00265     m_pUnkOuter = pBackObj;
00266   else
00267     m_pUnkOuter = pUnkOuter;
00268
00269   return;
00270 }
00271
00272
00273 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00274   Method:   COBallSink::CImpIBallSink::~CImpIBallSink
00275
00276   Summary:  Destructor for the CImpIBallSink interface instantiation.
00277
00278   Args:     void
00279
00280   Modifies: .
00281
00282   Returns:  void
00283 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00284 COBallSink::CImpIBallSink::~CImpIBallSink(void)
00285 {
00286   return;
00287 }
00288
00289
00290 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00291   Method:   COBallSink::CImpIBallSink::QueryInterface
00292
00293   Summary:  The QueryInterface IUnknown member of this IBallSink interface
00294             implementation that delegates to m_pUnkOuter, whatever it is.
00295
00296   Args:     REFIID riid,
00297               [in] GUID of the Interface being requested.
00298             PPVOID ppv)
00299               [out] Address of the caller's pointer variable that will
00300               receive the requested interface pointer.
00301
00302   Modifies: .
00303
00304   Returns:  HRESULT
00305               Returned by the delegated outer QueryInterface call.
00306 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00307 STDMETHODIMP COBallSink::CImpIBallSink::QueryInterface(
00308                REFIID riid,
00309                PPVOID ppv)
00310 {
00311   // Delegate this call to the outer object's QueryInterface.
00312   return m_pUnkOuter->QueryInterface(riid, ppv);
00313 }
00314
00315
00316 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00317   Method:   COBallSink::CImpIBallSink::AddRef
00318
00319   Summary:  The AddRef IUnknown member of this IBallSink interface
00320             implementation that delegates to m_pUnkOuter, whatever it is.
00321
00322   Args:     void
00323
00324   Modifies: .
00325
00326   Returns:  ULONG
00327               Returned by the delegated outer AddRef call.
00328 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00329 STDMETHODIMP_(ULONG) COBallSink::CImpIBallSink::AddRef(void)
00330 {
00331   // Delegate this call to the outer object's AddRef.
00332   return m_pUnkOuter->AddRef();
00333 }
00334
00335
00336 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00337   Method:   COBallSink::CImpIBallSink::Release
00338
00339   Summary:  The Release IUnknown member of this IBallSink interface
00340             implementation that delegates to m_pUnkOuter, whatever it is.
00341
00342   Args:     void
00343
00344   Modifies: .
00345
00346   Returns:  ULONG
00347               Returned by the delegated outer Release call.
00348 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00349 STDMETHODIMP_(ULONG) COBallSink::CImpIBallSink::Release(void)
00350 {
00351   // Delegate this call to the outer object's Release.
00352   return m_pUnkOuter->Release();
00353 }
00354
00355
00356 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00357   Method:   COBallSink::CImpIBallSink::BounceBottom
00358
00359   Summary:  Perform actions appropriate for when the ball bounces against
00360             the bottom boundary. For example, ask GUI to make a sound.
00361
00362   Args:     void
00363
00364   Modifies: ...
00365
00366   Returns:  void
00367 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00368 STDMETHODIMP COBallSink::CImpIBallSink::BounceBottom(
00369                void)
00370 {
00371   HRESULT hr = NOERROR;
00372
00373   // Ask the GUI Ball to issue an appropriate sound indicating the ball
00374   // bouncing off the Bottom boundary.
00375   m_pBackObj->m_pGuiBall->BounceBottom();
00376
00377   return hr;
00378 }
00379
00380
00381 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00382   Method:   COBallSink::CImpIBallSink::BounceLeft
00383
00384   Summary:  Perform actions appropriate for when the ball bounces against
00385             the Left boundary. For example, ask GUI to make a sound.
00386
00387   Args:     void
00388
00389   Modifies: ...
00390
00391   Returns:  void
00392 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00393 STDMETHODIMP COBallSink::CImpIBallSink::BounceLeft(
00394                void)
00395 {
00396   HRESULT hr = NOERROR;
00397
00398   // Ask the GUI Ball to issue an appropriate sound indicating the ball
00399   // bouncing off the Side boundary.
00400   m_pBackObj->m_pGuiBall->BounceSide();
00401
00402   return hr;
00403 }
00404
00405
00406 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00407   Method:   COBallSink::CImpIBallSink::BounceRight
00408
00409   Summary:  Perform actions appropriate for when the ball bounces against
00410             the right boundary. For example, ask GUI to make a sound.
00411
00412   Args:     void
00413
00414   Modifies: ...
00415
00416   Returns:  void
00417 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00418 STDMETHODIMP COBallSink::CImpIBallSink::BounceRight(
00419                void)
00420 {
00421   HRESULT hr = NOERROR;
00422
00423   // Ask the GUI Ball to issue an appropriate sound indicating the ball
00424   // bouncing off the Side boundary.
00425   m_pBackObj->m_pGuiBall->BounceSide();
00426
00427   return hr;
00428 }
00429
00430
00431 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00432   Method:   COBallSink::CImpIBallSink::BounceTop
00433
00434   Summary:  Perform actions appropriate for when the ball bounces against
00435             the Top boundary. For example, ask GUI to make a sound.
00436
00437   Args:     void
00438
00439   Modifies: ...
00440
00441   Returns:  void
00442 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00443 STDMETHODIMP COBallSink::CImpIBallSink::BounceTop(
00444                void)
00445 {
00446   HRESULT hr = NOERROR;
00447
00448   // Ask the GUI Ball to issue an appropriate sound indicating the ball
00449   // bouncing off the Top boundary.
00450   m_pBackObj->m_pGuiBall->BounceTop();
00451
00452   return hr;
00453 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/authz/common.c Source File

  • Security
  • Authorization
  • authz

common.c

Go to the documentation of this file.
00001 /*++
00002
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1999 - 2001 Microsoft Corporation.  All rights reserved.
00009
00010 Module Name:
00011
00012     common.c
00013
00014 Abstract:
00015
00016     Pipe and error displaying routines for AuthzSample
00017
00018 --*/
00019
00020 #include<windows.h>
00021 #include<stdio.h>
00022 #include<tchar.h>
00023
00024
00025 //////////////////////////////////////////////////////////////////////
00026 DWORD DisplayAPIError(TCHAR *pszAPI,BOOL bConsole,
00027                      BOOL bMsgBox, BOOL bExit)
00028 {
00029    LPVOID   lpvMessageBuffer;
00030    TCHAR    szErrMsgBuffer[500];
00031    DWORD    nWrote;
00032    DWORD    dwError;
00033
00034    dwError = GetLastError();
00035
00036    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00037                   NULL, dwError,
00038                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00039                   (LPTSTR)&lpvMessageBuffer, 0, NULL);
00040
00041     //... now display this string
00042     wsprintf(  szErrMsgBuffer,
00043                TEXT("ERROR: API = %s.\n"
00044                     "ERROR CODE = %d.\n"
00045                     "           = %x.\n"
00046                     "MESSAGE = %s.\n"),
00047                pszAPI, dwError,dwError,(char*)lpvMessageBuffer);
00048
00049     if (bConsole)
00050        WriteConsole( GetStdHandle(STD_OUTPUT_HANDLE),szErrMsgBuffer,
00051                      lstrlen(szErrMsgBuffer),&nWrote,NULL);
00052     if (bMsgBox)
00053        MessageBox(GetDesktopWindow(),szErrMsgBuffer,TEXT("Execution Error"), MB_OK);
00054
00055     OutputDebugString(szErrMsgBuffer);
00056
00057     // Free the buffer allocated by the system
00058     LocalFree(lpvMessageBuffer);
00059
00060     if (bExit)
00061       ExitProcess(dwError);
00062
00063     return dwError;
00064 }
00065
00066
00067 void HandleError(DWORD dwErr, TCHAR *pszAPI, BOOL fAPI, BOOL fExit)
00068 {
00069    if (fAPI) {
00070       DisplayAPIError(pszAPI,TRUE, TRUE, fExit);
00071    }
00072    else
00073    {
00074       _tprintf(TEXT("%s"),pszAPI);
00075       if (dwErr)
00076          _tprintf(TEXT("%u\n"),dwErr);
00077
00078       if (fExit)
00079          ExitProcess(0);
00080    }
00081
00082    return;
00083 }
00084
00085 BOOL
00086 BuildGenericAccessAcl(
00087     PACL* ppAcl,
00088     PDWORD cbAclSize
00089     )
00090 /*++
00091
00092     Routine Description
00093
00094       This function builds a Dacl which grants the creator of the objects
00095       GENERIC_ALL (Full Control) and Everyone GENERIC_READ, GENERIC_WRITE and
00096       GENERIC_EXECUTE access to the object.
00097
00098       This Dacl allows for higher security than a NULL Dacl, as this only grants
00099       the creator/owner write access to the security descriptor, and grants
00100       Everyone the ability to "use" the object. This scenario prevents a
00101       malevolent user from disrupting service by preventing arbitrary access
00102       manipulation.
00103
00104     Arguments
00105
00106       PACL* pAcl - Pointer to buffer for pointer to allocated PACL. Must be
00107                    freed with LocalFree
00108
00109       PDWORD cbAclSize - Pointer to dword receiving size of acl.
00110
00111     Return value
00112
00113       Bool, true on success, false on error
00114
00115 --*/
00116 {
00117     DWORD dwAclSize;
00118
00119     SID_IDENTIFIER_AUTHORITY siaWorld = SECURITY_WORLD_SID_AUTHORITY;
00120     SID_IDENTIFIER_AUTHORITY siaCreator = SECURITY_CREATOR_SID_AUTHORITY;
00121
00122     PSID pEveryoneSid = NULL;
00123     PSID pOwnerSid = NULL;
00124     BOOL bSuccess = FALSE;
00125
00126     __try {
00127
00128       //
00129       // compute size of acl
00130       //
00131       dwAclSize = sizeof(ACL) +
00132         2 * ( sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) ) +
00133         GetSidLengthRequired( 1 ) + // well-known Everyone Sid
00134         GetSidLengthRequired( 1 ) ; // well-known Creator Owner Sid
00135
00136       (*ppAcl) = LocalAlloc(0,dwAclSize);
00137       if(*ppAcl == NULL) {
00138          HandleError(GetLastError(), TEXT("LocalAlloc"), TRUE, TRUE);
00139          __leave;
00140       }
00141
00142       *cbAclSize = dwAclSize;
00143
00144       InitializeAcl(*ppAcl,dwAclSize,ACL_REVISION);
00145
00146       //
00147       // build well known sids
00148       //
00149
00150       // build EVERYONE SID
00151       AllocateAndInitializeSid( &siaWorld, 1, SECURITY_WORLD_RID,
00152                                 0,0,0,0,0,0,0,
00153                                 &pEveryoneSid
00154                                 );
00155
00156       // build Creator/Owner SID
00157       AllocateAndInitializeSid( &siaCreator, 1, SECURITY_CREATOR_OWNER_RID,
00158                                 0,0,0,0,0,0,0,
00159                                 &pOwnerSid
00160                                 );
00161
00162
00163       if (!AddAccessAllowedAce( *ppAcl,
00164                                 ACL_REVISION,
00165                                 GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE,
00166                                 pEveryoneSid
00167                                 )) {
00168          HandleError(GetLastError(),TEXT("AddAccessAllowedAce"),TRUE,TRUE);
00169          __leave;
00170       }
00171
00172
00173
00174       if (!AddAccessAllowedAce( *ppAcl,
00175                                 ACL_REVISION,
00176                                 GENERIC_ALL,
00177                                 pOwnerSid
00178                                 )) {
00179          HandleError(GetLastError(),TEXT("AddAccessAllowedAce (2)"),TRUE,TRUE);
00180          __leave;
00181       }
00182
00183
00184       bSuccess = TRUE;
00185    }
00186    __finally {
00187       if (pEveryoneSid) FreeSid(pEveryoneSid);
00188       if (pOwnerSid) FreeSid(pOwnerSid);
00189    }
00190
00191     return bSuccess;
00192 }
00193
00194 BOOL SetupNamedPipe (PHANDLE phPipe, LPTSTR szPipeName)
00195 {
00196    PACL     pDacl = NULL;
00197    DWORD    cbDacl;
00198    SECURITY_ATTRIBUTES sa = {0};
00199    SECURITY_DESCRIPTOR sd = {0};
00200    BOOL bSuccess = FALSE;
00201
00202
00203    __try
00204    {
00205       *phPipe = INVALID_HANDLE_VALUE;
00206
00207       if (!InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION))  {
00208          HandleError(GetLastError(),TEXT("InitializeSecurityDescriptor"),TRUE,TRUE);
00209          __leave;
00210       }
00211
00212       if (!BuildGenericAccessAcl(&pDacl,&cbDacl)) {
00213          HandleError(0,TEXT("Error setting up pipe dacl"),FALSE,TRUE);
00214          __leave;
00215       }
00216
00217       if (!SetSecurityDescriptorDacl(&sd,TRUE,pDacl,FALSE)) {
00218          HandleError(GetLastError(),TEXT("SetSecurityDescriptorDacl"),TRUE,TRUE);
00219          __leave;
00220       }
00221
00222       sa.nLength = sizeof(SECURITY_ATTRIBUTES);
00223       sa.bInheritHandle = FALSE;
00224       sa.lpSecurityDescriptor = &sd;
00225
00226       // setup pipe and wait for a connection
00227       *phPipe = CreateNamedPipe( szPipeName,
00228                      FILE_FLAG_OVERLAPPED|PIPE_ACCESS_DUPLEX,
00229                      PIPE_TYPE_MESSAGE |PIPE_READMODE_MESSAGE|PIPE_WAIT,1,0,0,
00230                      NMPWAIT_USE_DEFAULT_WAIT,&sa);
00231       if (*phPipe == INVALID_HANDLE_VALUE) {
00232          HandleError(GetLastError(),TEXT("CreateNamedPipe"),TRUE,TRUE);
00233          __leave;
00234       }
00235
00236       bSuccess = TRUE;
00237    }
00238    __finally {
00239       // free mem BuildGenericAccessAcl allocated
00240       if (pDacl) { LocalFree(pDacl);}
00241    }
00242
00243    return bSuccess;
00244 }
00245
00246
00247 BOOL WriteToPipe(HANDLE hPipe, BYTE* pData, DWORD cbData)
00248 {
00249    DWORD       dwErr;
00250    BOOL        bRet        = TRUE;
00251    INT         nBytesWrote = 0;
00252
00253    bRet = WriteFile(hPipe,pData,cbData,&nBytesWrote,NULL);
00254    if (!bRet)
00255    {
00256       dwErr = GetLastError();
00257       // if ERROR_BROKEN_PIPE or ERROR_NO_DATA then pipe naturally ended
00258       if ( !( dwErr == ERROR_BROKEN_PIPE || dwErr == ERROR_NO_DATA))
00259          HandleError(dwErr,TEXT("WriteFile"),TRUE,TRUE);
00260    }
00261
00262    return bRet;
00263 }
00264
00265 DWORD ReadFromPipe(HANDLE hPipe, BYTE* pBuffer, DWORD cbBuffer)
00266 {
00267    DWORD       dwErr;
00268    BOOL        bRet   = TRUE;
00269    INT         nBytesRead = 0;
00270
00271
00272   bRet = ReadFile(hPipe, pBuffer, cbBuffer, &nBytesRead, NULL);
00273    if (!bRet)
00274    {
00275       dwErr = GetLastError();
00276       // if ERROR_BROKEN_PIPE or ERROR_NO_DATA then pipe naturally ended
00277       if ( !( dwErr == ERROR_BROKEN_PIPE || dwErr == ERROR_NO_DATA))
00278          HandleError(dwErr,TEXT("ReadFile"),TRUE,TRUE);
00279    }
00280
00281    return nBytesRead;
00282 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_THUMB Member List

This is the complete list of members for _THUMB, including all inherited members.
cBytes | _THUMB
clipFormat | _THUMB
lpByte | _THUMB
lpstzName | _THUMB
selector | _THUMB
vtType | _THUMB
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/atl/StdAfx.h Source File

  • SysMgmt
  • MMC
  • ActiveX
  • atl

StdAfx.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // stdafx.h : include file for standard system include files,
00020 //      or project specific include files that are used frequently,
00021 //      but are changed infrequently
00022
00023 #if !defined(AFX_STDAFX_H__758048CD_C754_11D2_952C_00C04FB92EC2__INCLUDED_)
00024 #define AFX_STDAFX_H__758048CD_C754_11D2_952C_00C04FB92EC2__INCLUDED_
00025
00026 #if _MSC_VER > 1000
00027 #pragma once
00028 #endif // _MSC_VER > 1000
00029
00030 #define STRICT
00031 #ifndef _WIN32_WINNT
00032 #define _WIN32_WINNT 0x0400
00033 #endif
00034 #define _ATL_APARTMENT_THREADED
00035
00036 #include <atlbase.h>
00037 //You may derive a class from CComModule and use it if you want to override
00038 //something, but do not change the name of _Module
00039 extern CComModule _Module;
00040 #include <atlcom.h>
00041 #include <atlhost.h>
00042 #include <atlctl.h>
00043
00044 //{{AFX_INSERT_LOCATION}}
00045 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00046
00047 #endif // !defined(AFX_STDAFX_H__758048CD_C754_11D2_952C_00C04FB92EC2__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SmartCard/SmartCardAPI/SCQuery/SCQuery.Cpp Source File

  • Security
  • SmartCard
  • SmartCardAPI
  • SCQuery

SCQuery.Cpp

Go to the documentation of this file.
00001 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002
00003  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00004  EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00005  WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00006
00007  Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009  Module:      SCQuery.cpp
00010
00011  Abstract:    Main program of SCQuery for Smart Card SDK sample. See
00012               ReadMe.txt for more detail information about this sample.
00013
00014  Environment: Win32 console, C++ w/SEH, UNICODE ready.
00015
00016 ------------------------------------------------------------------------------*/
00017
00018 ////////////////////
00019 //
00020 // INCLUDE
00021 //
00022
00023 #include <tchar.h>
00024 #include <stdio.h>
00025 #include <windows.h>
00026 #include <winscard.h>
00027
00028 #include "SCCommon.h"
00029
00030 ///////////////
00031 //
00032 // Prototype
00033 //
00034
00035 LONG ListReaders (IN SCARDCONTEXT hContext, IN LPCTSTR lpmszReaderGroups);
00036 LONG ListCards   (IN SCARDCONTEXT hContext, IN LPCBYTE lpszATR);
00037 LONG ListGroups  (IN SCARDCONTEXT hContext);
00038 LONG QueryCards  (IN SCARDCONTEXT hContext, IN LPCTSTR lpmszReaderGroups);
00039
00040
00041 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00042
00043  Function : _tmain
00044
00045  Synopsis : Entry point of SCQuery.
00046
00047  Parameter: Standard ANSI C command line parameters.
00048
00049  Return   : SCARD_S_SUCCESS or error code
00050
00051 ------------------------------------------------------------------------------*/
00052
00053 extern "C" int __cdecl _tmain (int argc, _TCHAR  * argv[])
00054 {
00055     LONG lResult;
00056     SCARDCONTEXT hContext = NULL;
00057
00058     __try
00059     {
00060         //
00061         // Establish context with the resource manager.
00062         //
00063         lResult = SCardEstablishContext(SCARD_SCOPE_USER,
00064                                         NULL,
00065                                         NULL,
00066                                         &hContext);
00067         if (lResult != SCARD_S_SUCCESS)
00068         {
00069             __leave;
00070         }
00071
00072         //
00073         // List readers
00074         //
00075         lResult = ListReaders(hContext, NULL);
00076         if (lResult != SCARD_S_SUCCESS)
00077         {
00078             __leave;
00079         }
00080
00081         //
00082         // List cards
00083         //
00084         lResult = ListCards(hContext, NULL);
00085         if (lResult != SCARD_S_SUCCESS)
00086         {
00087             __leave;
00088         }
00089
00090         //
00091         // List groups
00092         //
00093         lResult = ListGroups(hContext);
00094         if (lResult != SCARD_S_SUCCESS)
00095         {
00096             __leave;
00097         }
00098
00099         //
00100         // Query cards
00101         //
00102         lResult = QueryCards(hContext, NULL);
00103     }
00104
00105     __finally
00106     {
00107         //
00108         // Don't forget to release the context handle if established.
00109         //
00110         if (hContext != NULL)
00111         {
00112             LONG lReturn = SCardReleaseContext(hContext);
00113
00114             //
00115             // If successful so far, then capture the SCardReleaseContext()
00116             // return code; otherwise, don't bother
00117             //
00118             if (lResult == SCARD_S_SUCCESS)
00119             {
00120                 lResult = lReturn;
00121             }
00122         }
00123     }
00124
00125     //
00126     // Inform user if an error had occurred.
00127     //
00128     if (lResult != SCARD_S_SUCCESS)
00129     {
00130         _tprintf(_T("\nError [0x%lx]: Program terminated abnormally.\n"),
00131                  lResult);
00132     }
00133
00134     return((int) lResult);
00135 }
00136
00137
00138 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00139
00140  Function : ListReaders
00141
00142  Synopsis : Print out a formatted list of registered Smart Card readers
00143             associated with the specified reader groups to STDOUT.
00144
00145  Parameter: - IN SCARDCONTEXT hContext
00146
00147               Resource manager context returned by SCardEstablishContext(), or
00148               NULL if the query is not directed towards a specific context.
00149
00150             - IN LPCTSTR lpmszReaderGroups
00151
00152               Pointer to multi-string reader group names, or NULL to specify all
00153               readers known to the system.
00154
00155  Return   : SCARD_S_SUCCESS or error code
00156
00157 ------------------------------------------------------------------------------*/
00158
00159 LONG ListReaders (IN SCARDCONTEXT hContext,
00160                   IN LPCTSTR lpmszReaderGroups)
00161 {
00162     LONG lResult;
00163     LPTSTR lpmszReaderNames;
00164
00165     __try
00166     {
00167         //
00168         // Get the list of registered readers associated with the specified
00169         // group(s).
00170         // Note: The buffer is automatically allocated and must be freed
00171         //       by SCFree().
00172         //
00173         lResult = SCListReaders(hContext,
00174                                 lpmszReaderGroups,
00175                                 (LPTSTR *) &lpmszReaderNames);
00176         if (lResult != SCARD_S_SUCCESS)
00177         {
00178             __leave;
00179         }
00180
00181         DWORD  dwNumReaders   = 0;
00182         LPTSTR lpszReaderName = lpmszReaderNames;
00183
00184         _tprintf(_T("\n"));
00185         _tprintf(_T("Registered Reader(s)\n"));
00186         _tprintf(_T("====================\n"));
00187
00188         //
00189         // Walk through the list of readers and print out some information.
00190         // Note: The list of readers are in a multi-string structure.
00191         //
00192         while (*lpszReaderName != _T('\0'))
00193         {
00194             _tprintf(_T("%02d: %s\n"), ++dwNumReaders, lpszReaderName);
00195             lpszReaderName += lstrlen(lpszReaderName) + 1;
00196         }
00197
00198         //
00199         // Inform the user if no reader was found.
00200         //
00201         if (dwNumReaders == 0)
00202         {
00203             _tprintf(_T("No registered reader was found for the specified "
00204                         _T("reader group(s) [%s].\n")), lpmszReaderGroups);
00205         }
00206     }
00207
00208     __finally
00209     {
00210         //
00211         // Don't forget to release memory, if allocated.
00212         //
00213         if (lpmszReaderNames != NULL)
00214         {
00215             LONG lReturn = SCFree((LPVOID) lpmszReaderNames);
00216
00217             //
00218             // If successful so far, then capture the return code
00219             // from SCFree(); otherwise, don't bother.
00220             //
00221             if (lResult == SCARD_S_SUCCESS)
00222             {
00223                 lResult = lReturn;
00224             }
00225         }
00226     }
00227
00228     return lResult;
00229 }
00230
00231
00232 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00233
00234  Function : ListCards
00235
00236  Synopsis : Print out a formatted list of registered Smart Cards associated with
00237             the specified ATR string to STDOUT.
00238
00239  Parameter: - IN SCARDCONTEXT hContext
00240
00241               Resource manager context returned by SCardEstablishContext(), or
00242               NULL if the query is not directed towards a specific context.
00243
00244             - IN LPCBYTE lpszATR
00245
00246               ATR string of the card to list, or NULL to return all cards known
00247               to the system.
00248
00249  Return   : SCARD_S_SUCCESS or error code
00250
00251 ------------------------------------------------------------------------------*/
00252
00253 LONG ListCards (IN SCARDCONTEXT hContext,
00254                 IN LPCBYTE lpszATR)
00255 {
00256     LONG lResult;
00257     LPTSTR lpmszCardNames;
00258
00259     __try
00260     {
00261         //
00262         // Get the list of registered cards associated with the specified ATR.
00263         // Note: The buffer is automatically allocated and must be freed
00264         //       by SCFree().
00265         //
00266         lResult = SCListCards(hContext,
00267                               lpszATR,
00268                               &lpmszCardNames);
00269         if (lResult != SCARD_S_SUCCESS)
00270         {
00271             __leave;
00272         }
00273
00274         DWORD dwNumCards = 0;
00275         LPTSTR lpszCardName = lpmszCardNames;
00276
00277         _tprintf(_T("\n"));
00278         _tprintf(_T("Registered Card(s)\n"));
00279         _tprintf(_T("==================\n"));
00280
00281         //
00282         // Walk through the list of cards and print out some information.
00283         // Note: The list of cards are in a multi-string structure.
00284         //
00285         while (*lpszCardName != _T('\0'))
00286         {
00287             _tprintf(_T("%02d: %s\n"), ++dwNumCards, lpszCardName);
00288             lpszCardName += lstrlen(lpszCardName) + 1;
00289         }
00290
00291         //
00292         // Inform the user if no card was found.
00293         //
00294         if (dwNumCards == 0)
00295         {
00296             _tprintf(_T("No registered Smart Card was found for the "
00297                         _T("specified ATR [%s].\n")), lpszATR);
00298         }
00299     }
00300
00301     __finally
00302     {
00303         //
00304         // Don't forget to release memory, if allocated.
00305         //
00306         if (lpmszCardNames != NULL)
00307         {
00308             LONG lReturn = SCFree((LPVOID) lpmszCardNames);
00309
00310             //
00311             // If successful so far, then capture the return code
00312             // from SCFree(); otherwise, don't bother.
00313             //
00314             if (lResult == SCARD_S_SUCCESS)
00315             {
00316                 lResult = lReturn;
00317             }
00318         }
00319     }
00320
00321     return lResult;
00322 }
00323
00324
00325 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00326
00327  Function : ListGroups
00328
00329  Synopsis : Print out a formatted list of registered reader groups to STDOUT.
00330
00331  Parameter: - IN SCARDCONTEXT hContext
00332
00333               Resource manager context returned by SCardEstablishContext(), or
00334               NULL if the query is not directed towards a specific context.
00335
00336  Return   : SCARD_S_SUCCESS or error code
00337
00338 ------------------------------------------------------------------------------*/
00339
00340 LONG ListGroups (IN SCARDCONTEXT hContext)
00341 {
00342     LONG lResult;
00343     LPTSTR lpmszGroupNames;
00344
00345     __try
00346     {
00347         //
00348         // Get the list of registered reader groups.
00349         // Note: The buffer is automatically allocated and must be freed
00350         //       by SCFree().
00351         //
00352         lResult = SCListGroups(hContext,
00353                                (LPTSTR *) &lpmszGroupNames);
00354         if (lResult != SCARD_S_SUCCESS)
00355         {
00356             __leave;
00357         }
00358
00359         DWORD  dwNumGroups   = 0;
00360         LPTSTR lpszGroupName = lpmszGroupNames;
00361
00362         _tprintf(_T("\n"));
00363         _tprintf(_T("Registered Group(s)\n"));
00364         _tprintf(_T("===================\n"));
00365
00366         //
00367         // Walk through the list of groups and print out some information.
00368         // Note: The list of cards are in a multi-string structure.
00369         //
00370         while (*lpszGroupName != TEXT('\0'))
00371         {
00372             _tprintf(_T("%02d: %s\n"), ++dwNumGroups, lpszGroupName);
00373             lpszGroupName += lstrlen(lpszGroupName) + 1;
00374         }
00375
00376         //
00377         // Inform the user if no group was found.
00378         //
00379         if (dwNumGroups == 0)
00380         {
00381             _tprintf(_T("No registered reader group was found.\n"));
00382         }
00383     }
00384
00385     __finally
00386     {
00387         //
00388         // Don't forget to release memory, if allocated.
00389         //
00390         if (lpmszGroupNames != NULL)
00391         {
00392             LONG lReturn = SCFree((LPVOID) lpmszGroupNames);
00393
00394             //
00395             // If successful so far, then capture the return code
00396             // from SCFree(); otherwise, don't bother.
00397             //
00398             if (lResult == SCARD_S_SUCCESS)
00399             {
00400                 lResult = lReturn;
00401             }
00402         }
00403     }
00404
00405     return lResult;
00406 }
00407
00408 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00409
00410  Function : QueryCards
00411
00412  Synopsis : Print out a formatted list of card found in the specified reader
00413             group to STDOUT.
00414
00415  Parameter: - IN SCARDCONTEXT hContext
00416
00417               Resource manager context returned by SCardEstablishContext(), or
00418               NULL if the query is not directed towards a specific context.
00419
00420             - IN LPCTSTR lpmszReaderGroups
00421
00422               Pointer to multi-string reader group names, or NULL to specify all
00423               readers known to the system.
00424
00425  Return   : SCARD_S_SUCCESS or error code
00426
00427 ------------------------------------------------------------------------------*/
00428
00429 LONG QueryCards (IN SCARDCONTEXT hContext,
00430                  IN LPCTSTR lpmszReaderGroups)
00431 {
00432     LONG   lResult          = SCARD_S_SUCCESS;
00433     LPTSTR lpmszReaderNames = NULL;
00434
00435     __try
00436     {
00437         //
00438         // Get the list of registered readers associated with the specified
00439         // group(s).
00440         // Note: The buffer is automatically allocated and must be freed
00441         //       by SCFree().
00442         //
00443         lResult = SCListReaders(hContext,
00444                                 lpmszReaderGroups,
00445                                 (LPTSTR *) &lpmszReaderNames);
00446         if (lResult != SCARD_S_SUCCESS)
00447         {
00448             __leave;
00449         }
00450
00451         _tprintf(_T("\n"));
00452         _tprintf(_T("Card in reader\n"));
00453         _tprintf(_T("==============\n"));
00454
00455         //
00456         // Note that MAXIMUM_SMARTCARD_READERS (10) only refers to maximum # of
00457         // non-PnP readers. The resource manager is capable of handling any number
00458         // of PnP readers, in addition to the 10 non-PnP readers (your physical
00459         // system is the limiting factor). Make appropriate changes as necessary
00460         // to accomodate more readers.
00461         //
00462
00463         DWORD  dwNumReaders   = 0;
00464         LPTSTR lpszReaderName = lpmszReaderNames;
00465         SCARD_READERSTATE rsReaders[MAXIMUM_SMARTCARD_READERS];
00466
00467         ZeroMemory((LPVOID)rsReaders, sizeof(rsReaders));
00468
00469         //
00470         // Prepare state array
00471         //
00472         while ((*lpszReaderName != _T('\0')) &&
00473                (dwNumReaders < MAXIMUM_SMARTCARD_READERS))
00474         {
00475             rsReaders[dwNumReaders].szReader = (LPCTSTR)lpszReaderName;
00476             rsReaders[dwNumReaders].dwCurrentState = SCARD_STATE_UNAWARE;
00477
00478             dwNumReaders++;
00479             lpszReaderName += lstrlen(lpszReaderName) + 1;
00480         }
00481
00482         if (dwNumReaders == 0)
00483         {
00484             _tprintf(_T("No registered reader was found for the specified "
00485                         _T("reader group(s) [%s].\n")), lpmszReaderGroups);
00486             __leave;
00487         }
00488
00489         //
00490         // Now check state of each reader
00491         //
00492         lResult = SCardGetStatusChange(hContext,
00493                                        INFINITE,
00494                                        rsReaders,
00495                                        dwNumReaders);
00496         if (lResult != SCARD_S_SUCCESS)
00497         {
00498             __leave;
00499         }
00500
00501         for (DWORD dwIndex = 0; dwIndex < dwNumReaders; dwIndex++)
00502         {
00503             //
00504             // Print out reader name
00505             //
00506             _tprintf(_T("%02d: %s\n"), dwIndex + 1, rsReaders[dwIndex].szReader);
00507
00508             //
00509             // If a card is present in this reader, print ATR and
00510             // any extra data from the Select File command.
00511             //
00512             if (!(rsReaders[dwIndex].dwEventState & SCARD_STATE_PRESENT))
00513             {
00514                 _tprintf(_T("    No Smart Card found in this reader.\n"));
00515                 continue;
00516             }
00517
00518             SCARDHANDLE hCard  = NULL;
00519             LPBYTE lpbResponse = NULL;
00520
00521             __try
00522             {
00523                 DWORD dwActiveProtocol;
00524
00525                 //
00526                 // Connect to the card
00527                 //
00528                 lResult = SCardConnect(hContext,
00529                                        rsReaders[dwIndex].szReader,
00530                                        SCARD_SHARE_SHARED,
00531                                        SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
00532                                        &hCard,
00533                                        &dwActiveProtocol);
00534                 if (lResult != SCARD_S_SUCCESS)
00535                 {
00536                     __leave;
00537                 }
00538
00539                 DWORD dwReaderLen = 0;
00540                 DWORD dwState;
00541                 DWORD dwProtocol;
00542                 BYTE  atr[MAXIMUM_ATTR_STRING_LENGTH];
00543                 DWORD dwAtrLen;
00544
00545                 //
00546                 // Get status of card
00547                 //
00548                 lResult = SCardStatus(hCard,
00549                                       NULL,
00550                                       &dwReaderLen,
00551                                       &dwState,
00552                                       &dwProtocol,
00553                                       atr,
00554                                       &dwAtrLen);
00555                 if (lResult != SCARD_S_SUCCESS)
00556                 {
00557                     __leave;
00558                 }
00559
00560                 //
00561                 // Print out ATR bytes of card
00562                 //
00563                 _tprintf(_T("    ATR = "), dwIndex + 1);
00564                 for (DWORD i = 0; i < dwAtrLen; i++)
00565                 {
00566                     _tprintf(_T("%02x "), (DWORD) atr[i]);
00567                 }
00568
00569                 _tprintf(_T("\n"));
00570
00571                 BYTE filename[2] = {0x3f, 0x00};
00572                 DWORD dwExtraBytes;
00573
00574                 //
00575                 // Select Master File (0x3f00)
00576                 //
00577                 lResult = SCSelectFile(hCard,
00578                                        filename,
00579                                        &dwExtraBytes);
00580                 if (lResult != SCARD_S_SUCCESS)
00581                 {
00582                     __leave;
00583                 }
00584
00585                 //
00586                 // Any extra data?
00587                 //
00588                 if (dwExtraBytes)
00589                 {
00590                     //
00591                     // Yes, so retrieve it
00592                     //
00593                     lResult = SCGetResponse(hCard, dwExtraBytes, &lpbResponse);
00594
00595                     if (lResult == SCARD_S_SUCCESS)
00596                     {
00597                         //
00598                         // Print out MF file control information
00599                         //
00600                         _tprintf(_T("    FCI = "), dwIndex + 1);
00601                         for (DWORD i = 0; i < dwExtraBytes; i++)
00602                         {
00603                             _tprintf(_T("%02x "), (DWORD) lpbResponse[i]);
00604                         }
00605
00606                         _tprintf(_T("\n"));
00607                     }
00608                 }
00609
00610                 _tprintf(_T("\n"));
00611             }
00612
00613             __finally
00614             {
00615                 LONG lReturn;
00616
00617                 //
00618                 // Don't forget to release the memory block if it had been
00619                 // allocated by SCGetResponse().
00620                 //
00621                 if (lpbResponse != NULL)
00622                 {
00623                     lReturn = SCFree((LPVOID) lpbResponse);
00624
00625                     //
00626                     // If successful so far, then capture the return code
00627                     // from SCFree(); otherwise, don't bother.
00628                     //
00629                     if (lResult == SCARD_S_SUCCESS)
00630                     {
00631                         lResult = lReturn;
00632                     }
00633                 }
00634
00635                 //
00636                 // Don't forget to disconnect the card.
00637                 //
00638                 if (hCard != NULL)
00639                 {
00640                     lReturn = SCardDisconnect(hCard, SCARD_LEAVE_CARD);
00641
00642                     //
00643                     // If successful so far, then capture the SCardDisconnect()
00644                     // return code; otherwise, don't bother.
00645                     //
00646                     if (lResult == SCARD_S_SUCCESS)
00647                     {
00648                         lResult = lReturn;
00649                     }
00650                 }
00651             }
00652         }
00653     }
00654
00655     __finally
00656     {
00657         LONG lReturn;
00658
00659         //
00660         // Don't forget to release memory, if allocated.
00661         //
00662         if (lpmszReaderNames != NULL)
00663         {
00664             lReturn = SCFree((LPVOID) lpmszReaderNames);
00665
00666             //
00667             // If successful so far, then capture the return code
00668             // from SCFree(); otherwise, don't bother.
00669             //
00670             if (lResult == SCARD_S_SUCCESS)
00671             {
00672                 lResult = lReturn;
00673             }
00674         }
00675     }
00676
00677     return lResult;
00678 }
00679
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/Edit.Cpp Source File

  • WinUI
  • GlobalDev
  • CSSamp

Edit.Cpp

Go to the documentation of this file.
00001 ////    TEXTEDIT.C
00002 //
00003 //
00004 #include "precomp.hxx"
00005 #include "global.h"
00006
00007 BOOL EditKeyDown(WCHAR wc)
00008 {
00009     switch(wc)
00010     {
00011         case VK_LEFT:
00012             if (g_iCurChar)
00013             {
00014                 g_iCurChar--;
00015                 if (    g_iCurChar
00016                     &&  g_wcBuf[g_iCurChar] == 0x000A
00017                     &&  g_wcBuf[g_iCurChar-1] == 0x000D)
00018                 {
00019                     g_iCurChar--;
00020                 }
00021
00022                 // If shift is down, extend selection, else clear it
00023                 if (GetKeyState(VK_SHIFT) >= 0)
00024                 {
00025                     g_iFrom = g_iCurChar;
00026                 }
00027                 g_iTo = g_iCurChar;
00028
00029                 InvalidateText();
00030                 g_fUpdateCaret = TRUE;
00031             }
00032             break;
00033
00034         case VK_RIGHT:
00035             if (g_iCurChar < g_iTextLen)
00036             {
00037                 if (    g_iCurChar < g_iTextLen-1
00038                     &&  g_wcBuf[g_iCurChar] == 0x000D
00039                     &&  g_wcBuf[g_iCurChar+1] == 0x000A)
00040                 {
00041                     g_iCurChar+= 2;
00042                 }
00043                 else
00044                 {
00045                     g_iCurChar++;
00046                 }
00047
00048                 // If shift is down, extend selection, else clear it
00049                 if (GetKeyState(VK_SHIFT) >= 0)
00050                 {
00051                     g_iFrom = g_iCurChar;
00052                 }
00053                 g_iTo = g_iCurChar;
00054
00055                 InvalidateText();
00056                 g_fUpdateCaret = TRUE;
00057             }
00058             break;
00059
00060         case VK_HOME:
00061             // Implemented as - go to start of text
00062             g_iCurChar = 0;
00063             g_iFrom    = 0;
00064             g_iTo      = 0;
00065             InvalidateText();
00066             g_fUpdateCaret = TRUE;
00067             break;
00068
00069         case VK_END:
00070             // Implemented as - go to end of text
00071             g_iCurChar = g_iTextLen;
00072             g_iFrom    = g_iTextLen;
00073             g_iTo      = g_iTextLen;
00074             InvalidateText();
00075             g_fUpdateCaret = TRUE;
00076             break;
00077
00078         case VK_DELETE:
00079             if (g_iFrom != g_iTo)
00080             {
00081                 // Delete selection
00082                 if (g_iFrom < g_iTo)
00083                 {
00084                     TextDelete(g_iFrom, g_iTo-g_iFrom);
00085                     g_iTo      = g_iFrom;
00086                     g_iCurChar = g_iFrom;
00087                 }
00088                 else
00089                 {
00090                     TextDelete(g_iTo, g_iFrom-g_iTo);
00091                     g_iTo      = g_iTo;
00092                     g_iCurChar = g_iTo;
00093                 }
00094             }
00095             else
00096             {
00097                 // Delete character
00098                 if (g_iCurChar < g_iTextLen)
00099                 {
00100                     if (    g_iCurChar < g_iTextLen-1
00101                         &&  g_wcBuf[g_iCurChar] == 0x000D
00102                         &&  g_wcBuf[g_iCurChar+1] == 0x000A)
00103                     {
00104                         TextDelete(g_iCurChar, 2);
00105                     }
00106                     else
00107                     {
00108                         TextDelete(g_iCurChar, 1);
00109                     }
00110                 }
00111             }
00112
00113             InvalidateText();
00114             g_fUpdateCaret = TRUE;
00115             break;
00116     }
00117
00118     return TRUE;
00119 }
00120
00121 BOOL EditChar(WCHAR wc)
00122 {
00123     BOOL bSucess = TRUE;
00124     switch(wc)
00125     {
00126         case VK_RETURN:
00127             if (!TextInsert(g_iCurChar, L"\r\n", 2))
00128             {
00129                 bSucess = FALSE;
00130                 break;
00131             }
00132             InvalidateText();
00133             g_iCurChar+=2;
00134             break;
00135
00136
00137         case VK_BACK:
00138             if (g_iCurChar)
00139             {
00140                 g_iCurChar--;
00141                 if (    g_iCurChar
00142                     &&  g_wcBuf[g_iCurChar] == 0x000A
00143                     &&  g_wcBuf[g_iCurChar-1] == 0x000D)
00144                 {
00145                     g_iCurChar--;
00146                     TextDelete(g_iCurChar, 2);
00147                 }
00148                 else
00149                 {
00150                     TextDelete(g_iCurChar, 1);
00151                 }
00152                 InvalidateText();
00153                 g_fUpdateCaret = TRUE;
00154             }
00155             break;
00156
00157
00158         case 1:  // Ctrl/A - select all
00159             g_iFrom = 0;
00160             g_iTo = g_iTextLen;
00161             InvalidateText();
00162             break;
00163
00164
00165         default:
00166             /* if(!((wc >= 0x0900 && wc < 0x0d80)
00167                       || wc == 0x200c
00168                       || wc == 0x200d))
00169                {
00170                     TranslateCharToUnicode(&wc);
00171                }
00172             */
00173             if (!TextInsert(g_iCurChar, &wc, 1))
00174             {
00175                 bSucess = FALSE;
00176                 break;
00177             }
00178
00179             // If there was a range marked previously, now delete that range
00180             if (g_iFrom < g_iTo)
00181             {
00182                 TextDelete(g_iFrom, g_iTo-g_iFrom);
00183                 g_iTo      = g_iFrom;
00184                 g_iCurChar = g_iFrom+1;
00185             }
00186             else if (g_iTo < g_iFrom)
00187             {
00188                 TextDelete(g_iTo, g_iFrom-g_iTo);
00189                 g_iFrom    = g_iTo;
00190                 g_iCurChar = g_iTo+1;
00191             }
00192             else
00193             {
00194                 // No prior selected text
00195                 g_iCurChar++;
00196             }
00197
00198             InvalidateText();
00199             g_fUpdateCaret = TRUE;
00200             break;
00201     }
00202
00203     return bSucess;
00204 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ConnectionVtbl Member List

This is the complete list of members for _ConnectionVtbl, including all inherited members.
bstr | _ConnectionVtbl
cNames | _ConnectionVtbl
CommandText | _ConnectionVtbl
ConnectionString | _ConnectionVtbl
dispIdMember | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Properties)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_ConnectionString)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_ConnectionString)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CommandTimeout)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CommandTimeout)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_ConnectionTimeout)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_ConnectionTimeout)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Version)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Close)(_ADOConnection __RPC_FAR *This) | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Execute)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *BeginTrans)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *CommitTrans)(_ADOConnection __RPC_FAR *This) | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *RollbackTrans)(_ADOConnection __RPC_FAR *This) | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Open)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Errors)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_DefaultDatabase)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_DefaultDatabase)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_IsolationLevel)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_IsolationLevel)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Attributes)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Attributes)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CursorLocation)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CursorLocation)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Mode)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Mode)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Provider)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Provider)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_State)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Cancel)(_ADOConnection __RPC_FAR *This) | _ConnectionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *OpenSchema)(_ADOConnection __RPC_FAR *This | _ConnectionVtbl
iTInfo | _ConnectionVtbl
lAttr | _ConnectionVtbl
lcid | _ConnectionVtbl
lcid | _ConnectionVtbl
lcid | _ConnectionVtbl
lCursorLoc | _ConnectionVtbl
Level | _ConnectionVtbl
Level | _ConnectionVtbl
lMode | _ConnectionVtbl
lTimeout | _ConnectionVtbl
Options | _ConnectionVtbl
Options | _ConnectionVtbl
Password | _ConnectionVtbl
pbstr | _ConnectionVtbl
pctinfo | _ConnectionVtbl
pDispParams | _ConnectionVtbl
pExcepInfo | _ConnectionVtbl
plAttr | _ConnectionVtbl
plCursorLoc | _ConnectionVtbl
plMode | _ConnectionVtbl
plObjState | _ConnectionVtbl
plTimeout | _ConnectionVtbl
ppiRset | _ConnectionVtbl
pprset | _ConnectionVtbl
ppTInfo | _ConnectionVtbl
ppvObject | _ConnectionVtbl
ppvObject | _ConnectionVtbl
ppvObject | _ConnectionVtbl
Provider | _ConnectionVtbl
puArgErr | _ConnectionVtbl
pVarResult | _ConnectionVtbl
RecordsAffected | _ConnectionVtbl
Restrictions | _ConnectionVtbl
rgDispId | _ConnectionVtbl
rgszNames | _ConnectionVtbl
riid | _ConnectionVtbl
riid | _ConnectionVtbl
riid | _ConnectionVtbl
Schema | _ConnectionVtbl
SchemaID | _ConnectionVtbl
TransactionLevel | _ConnectionVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(_ADOConnection __RPC_FAR *This) | _ConnectionVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(_ADOConnection __RPC_FAR *This) | _ConnectionVtbl
UserID | _ConnectionVtbl
wFlags | _ConnectionVtbl
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/about.Cpp Source File

  • SysMgmt
  • MMC
  • Multisel

about.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));;
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163         MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164         *lpDest = wszStr;
00165
00166
00167     return S_OK;
00168 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/TitleTag.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

TitleTag.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright 1992 - 1998 Microsoft Corporation
00004 //
00005 //  File:       titletag.hxx
00006 //
00007 //  Contents:   Parsing algorithm for title tags
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #if !defined( __TITLETAG_HXX__ )
00012 #define __TITLETAG_HXX__
00013
00014 #include <proptag.hxx>
00015
00016 //+-------------------------------------------------------------------------
00017 //
00018 //  Class:      CTitleTag
00019 //
00020 //  Purpose:    Parsing algorithm for title tag in Html
00021 //
00022 //--------------------------------------------------------------------------
00023
00024 class CTitleTag : public CPropertyTag
00025 {
00026
00027 public:
00028     CTitleTag( CHtmlIFilter& htmlIFilter,
00029                CSerialStream& serialStream,
00030                CFullPropSpec& propSpec,
00031                HtmlTokenType eTokType );
00032
00033     virtual SCODE    GetChunk( STAT_CHUNK *pStat );
00034     virtual SCODE    GetText( ULONG *pcwcOutput, WCHAR *awcBuffer );
00035     virtual SCODE    GetValue( PROPVARIANT **ppPropValue );
00036
00037 private:
00038     int     dummy;       // For unwinding
00039 };
00040
00041
00042 #endif // __TITLETAG_HXX__
00043
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Register.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

Register.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright 1992 - 2000 Microsoft Corporation.
00004 //
00005 //  File:       Register.cxx
00006 //
00007 //  Contents:   DllRegisterServer routines
00008 //
00009 //----------------------------------------------------------------------------
00010
00011 #include <pch.cxx>
00012 #pragma hdrstop
00013
00014 #include <filtreg.hxx>
00015
00016 SClassEntry const aHtmlFiltClasses[] =
00017 {
00018     { L".hhc",  L"hhcfile",       L"HHC file",      L"{7f73b8f6-c19c-11d0-aa66-00c04fc2eddc}", L"HHC file" },
00019     { L".htm",  L"htmlfile",      L"HTML file",     L"{25336920-03f9-11cf-8fd0-00aa00686f13}", L"HTML file" },
00020     { L".html", L"htmlfile",      L"HTML file",     L"{25336920-03f9-11cf-8fd0-00aa00686f13}", L"HTML file" },
00021     { L".htx",  L"htmlfile",      L"HTML file",     L"{25336920-03f9-11cf-8fd0-00aa00686f13}", L"HTML file" },
00022     { L".stm",  L"htmlfile",      L"HTML file",     L"{25336920-03f9-11cf-8fd0-00aa00686f13}", L"HTML file" },
00023     { L".htw",  L"htmlfile",      L"HTML file",     L"{25336920-03f9-11cf-8fd0-00aa00686f13}", L"HTML file" },
00024     { L".asp",  L"asp_auto_file", L"ASP auto file", L"{bd70c020-2d24-11d0-9110-00004c752752}", L"ASP auto file" },
00025 };
00026
00027 SHandlerEntry const HtmlFiltHandler =
00028 {
00029     L"{eec97550-47a9-11cf-b952-00aa0051fe20}",
00030     L"HTML Persistent Handler",
00031     L"{e0ca5340-4534-11cf-b952-00aa0051fe20}",
00032 };
00033
00034 SFilterEntry const HtmlFiltFilter =
00035 {
00036     L"{e0ca5340-4534-11cf-b952-00aa0051fe20}",
00037     L"HTML Filter",
00038     L"HtmlFilt.dll",
00039     L"Both"
00040 };
00041
00042 DEFINE_DLLREGISTERFILTER( HtmlFiltHandler, HtmlFiltFilter, aHtmlFiltClasses )
00043
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step1/ADsFirstExt.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step1

ADsFirstExt.h

Go to the documentation of this file.
00001 /* this ALWAYS GENERATED file contains the definitions for the interfaces */
00002
00003
00004 /* File created by MIDL compiler version 5.01.0164 */
00005 /* at Mon Apr 29 12:44:14 2002
00006  */
00007 /* Compiler settings for C:\sdk\sdkpublic\samples\netds\adsi\samples\Extension\tutorial\Step1\ADsFirstExt.idl:
00008     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00009     error checks: allocation ref bounds_check enum stub_data
00010 */
00011 //@@MIDL_FILE_HEADING(  )
00012
00013
00014 /* verify that the <rpcndr.h> version is high enough to compile this file*/
00015 #ifndef __REQUIRED_RPCNDR_H_VERSION__
00016 #define __REQUIRED_RPCNDR_H_VERSION__ 440
00017 #endif
00018
00019 #include "rpc.h"
00020 #include "rpcndr.h"
00021
00022 #ifndef __RPCNDR_H_VERSION__
00023 #error this stub requires an updated version of <rpcndr.h>
00024 #endif // __RPCNDR_H_VERSION__
00025
00026 #ifndef COM_NO_WINDOWS_H
00027 #include "windows.h"
00028 #include "ole2.h"
00029 #endif /*COM_NO_WINDOWS_H*/
00030
00031 #ifndef __ADsFirstExt_h__
00032 #define __ADsFirstExt_h__
00033
00034 #ifdef __cplusplus
00035 extern "C"{
00036 #endif
00037
00038 /* Forward Declarations */
00039
00040 #ifndef __IHelloWorld_FWD_DEFINED__
00041 #define __IHelloWorld_FWD_DEFINED__
00042 typedef interface IHelloWorld IHelloWorld;
00043 #endif  /* __IHelloWorld_FWD_DEFINED__ */
00044
00045
00046 #ifndef __HelloWorld_FWD_DEFINED__
00047 #define __HelloWorld_FWD_DEFINED__
00048
00049 #ifdef __cplusplus
00050 typedef class HelloWorld HelloWorld;
00051 #else
00052 typedef struct HelloWorld HelloWorld;
00053 #endif /* __cplusplus */
00054
00055 #endif  /* __HelloWorld_FWD_DEFINED__ */
00056
00057
00058 /* header files for imported files */
00059 #include "oaidl.h"
00060 #include "ocidl.h"
00061
00062 void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
00063 void __RPC_USER MIDL_user_free( void __RPC_FAR * );
00064
00065 #ifndef __IHelloWorld_INTERFACE_DEFINED__
00066 #define __IHelloWorld_INTERFACE_DEFINED__
00067
00068 /* interface IHelloWorld */
00069 /* [unique][helpstring][dual][uuid][object] */
00070
00071
00072 EXTERN_C const IID IID_IHelloWorld;
00073
00074 #if defined(__cplusplus) && !defined(CINTERFACE)
00075
00076     MIDL_INTERFACE("E1E3EDF7-48D1-11D2-B22B-0000F87A6B50")
00077     IHelloWorld : public IDispatch
00078     {
00079     public:
00080         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Say( void) = 0;
00081
00082     };
00083
00084 #else   /* C style interface */
00085
00086     typedef struct IHelloWorldVtbl
00087     {
00088         BEGIN_INTERFACE
00089
00090         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00091             IHelloWorld __RPC_FAR * This,
00092             /* [in] */ REFIID riid,
00093             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00094
00095         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00096             IHelloWorld __RPC_FAR * This);
00097
00098         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00099             IHelloWorld __RPC_FAR * This);
00100
00101         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00102             IHelloWorld __RPC_FAR * This,
00103             /* [out] */ UINT __RPC_FAR *pctinfo);
00104
00105         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00106             IHelloWorld __RPC_FAR * This,
00107             /* [in] */ UINT iTInfo,
00108             /* [in] */ LCID lcid,
00109             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00110
00111         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00112             IHelloWorld __RPC_FAR * This,
00113             /* [in] */ REFIID riid,
00114             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00115             /* [in] */ UINT cNames,
00116             /* [in] */ LCID lcid,
00117             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00118
00119         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00120             IHelloWorld __RPC_FAR * This,
00121             /* [in] */ DISPID dispIdMember,
00122             /* [in] */ REFIID riid,
00123             /* [in] */ LCID lcid,
00124             /* [in] */ WORD wFlags,
00125             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00126             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00127             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00128             /* [out] */ UINT __RPC_FAR *puArgErr);
00129
00130         /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Say )(
00131             IHelloWorld __RPC_FAR * This);
00132
00133         END_INTERFACE
00134     } IHelloWorldVtbl;
00135
00136     interface IHelloWorld
00137     {
00138         CONST_VTBL struct IHelloWorldVtbl __RPC_FAR *lpVtbl;
00139     };
00140
00141
00142
00143 #ifdef COBJMACROS
00144
00145
00146 #define IHelloWorld_QueryInterface(This,riid,ppvObject) \
00147     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00148
00149 #define IHelloWorld_AddRef(This)  \
00150     (This)->lpVtbl -> AddRef(This)
00151
00152 #define IHelloWorld_Release(This) \
00153     (This)->lpVtbl -> Release(This)
00154
00155
00156 #define IHelloWorld_GetTypeInfoCount(This,pctinfo)  \
00157     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00158
00159 #define IHelloWorld_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
00160     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00161
00162 #define IHelloWorld_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
00163     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00164
00165 #define IHelloWorld_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
00166     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00167
00168
00169 #define IHelloWorld_Say(This) \
00170     (This)->lpVtbl -> Say(This)
00171
00172 #endif /* COBJMACROS */
00173
00174
00175 #endif  /* C style interface */
00176
00177
00178
00179 /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IHelloWorld_Say_Proxy(
00180     IHelloWorld __RPC_FAR * This);
00181
00182
00183 void __RPC_STUB IHelloWorld_Say_Stub(
00184     IRpcStubBuffer *This,
00185     IRpcChannelBuffer *_pRpcChannelBuffer,
00186     PRPC_MESSAGE _pRpcMessage,
00187     DWORD *_pdwStubPhase);
00188
00189
00190
00191 #endif  /* __IHelloWorld_INTERFACE_DEFINED__ */
00192
00193
00194
00195 #ifndef __ADSFIRSTEXTLib_LIBRARY_DEFINED__
00196 #define __ADSFIRSTEXTLib_LIBRARY_DEFINED__
00197
00198 /* library ADSFIRSTEXTLib */
00199 /* [helpstring][version][uuid] */
00200
00201
00202 EXTERN_C const IID LIBID_ADSFIRSTEXTLib;
00203
00204 EXTERN_C const CLSID CLSID_HelloWorld;
00205
00206 #ifdef __cplusplus
00207
00208 class DECLSPEC_UUID("E1E3EDF8-48D1-11D2-B22B-0000F87A6B50")
00209 HelloWorld;
00210 #endif
00211 #endif /* __ADSFIRSTEXTLib_LIBRARY_DEFINED__ */
00212
00213 /* Additional Prototypes for ALL interfaces */
00214
00215 /* end of Additional Prototypes */
00216
00217 #ifdef __cplusplus
00218 }
00219 #endif
00220
00221 #endif
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/RTCOutgoingDlg.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

RTCOutgoingDlg.cpp

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: RTCOutGoingDlg.cpp
00006  * ---------- [ Source Definition File]
00007  *
00008  *
00009  * @Description :
00010  * -------------
00011  * Class Declaration file for the Main RTCOutgoing Dialog Box
00012  * this Class will contain the state machine transitions
00013  * of the RTC Core Sample,creating PC-PC,PC-PH,PH-PH calls,
00014  * receiving events disconnected calls, displaying video
00015  * starting T120 App Sharing and Starting the Tunning Wizard
00016  *
00017  *
00018  ******************************************************/
00019
00020
00021 #include "stdafx.h"
00022 #include "RTCOutgoing.h"
00023 #include "RTCOutgoingDlg.h"
00024
00025
00026
00027 #ifdef _DEBUG
00028 #define new DEBUG_NEW
00029 #undef THIS_FILE
00030 static char THIS_FILE[] = __FILE__;
00031 #endif
00032
00033
00034 /**********************************************************
00035 //@Class CAboutDlg
00036 //
00037 //@Description
00038 //
00039 //  About Dialog Box
00040 //
00041 //
00042 //
00043 //*********************************************************/
00044
00045 class CAboutDlg : public CDialog
00046 {
00047 public:
00048   CAboutDlg();
00049
00050 // Dialog Data
00051   //{{AFX_DATA(CAboutDlg)
00052   enum { IDD = IDD_ABOUTBOX };
00053   //}}AFX_DATA
00054
00055   // ClassWizard generated virtual function overrides
00056   //{{AFX_VIRTUAL(CAboutDlg)
00057   protected:
00058   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00059   //}}AFX_VIRTUAL
00060
00061 // Implementation
00062 protected:
00063   //{{AFX_MSG(CAboutDlg)
00064   //}}AFX_MSG
00065   DECLARE_MESSAGE_MAP()
00066 };
00067
00068
00069 /**********************************************************
00070 //@CAboutDlg()
00071 //
00072 //@Description
00073 //
00074 //  Constructor
00075 //
00076 //@Args In:     Void
00077 //@Args Out:    Void
00078 //
00079 //
00080 //*********************************************************/
00081 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00082 {
00083   //{{AFX_DATA_INIT(CAboutDlg)
00084   //}}AFX_DATA_INIT
00085 }
00086
00087
00088 /**********************************************************
00089 //@DoDataExchange()
00090 //
00091 //@Description
00092 //
00093 //
00094 //@Args In:     CDataExchange *
00095 //@Args Out:    Void
00096 //
00097 //
00098 //*********************************************************/
00099 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00100 {
00101   CDialog::DoDataExchange(pDX);
00102   //{{AFX_DATA_MAP(CAboutDlg)
00103   //}}AFX_DATA_MAP
00104 }
00105
00106
00107
00108 /**********************************************************
00109 //@CAboutDlg Message Map
00110 //
00111 //@Description
00112 //
00113 //
00114 //
00115 //*********************************************************/
00116
00117 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00118   //{{AFX_MSG_MAP(CAboutDlg)
00119   //}}AFX_MSG_MAP
00120 END_MESSAGE_MAP()
00121
00122
00123
00124
00125 /**********************************************************
00126 //@Class CRTCOutgoingDlg
00127 //
00128 //
00129 //
00130 //*********************************************************/
00131
00132
00133 CRTCOutgoingDlg::CRTCOutgoingDlg(CWnd* pParent /*=NULL*/)
00134   : CDialog(CRTCOutgoingDlg::IDD, pParent)
00135 {
00136   //{{AFX_DATA_INIT(CRTCOutgoingDlg)
00137
00138   m_pIRTCClient    = NULL;
00139   m_pIRTCSession   = NULL;
00140   m_pIRecvVideo    = NULL;
00141   m_pIPrevVideo    = NULL;
00142   m_pIRTCParty     = NULL;
00143   m_SessionType    = RTCST_PC_TO_PC;
00144
00145   //}}AFX_DATA_INIT
00146   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
00147   m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00148 }
00149
00150
00151 /**********************************************************
00152 //@DoDataExchange()
00153 //
00154 //@Description
00155 //
00156 //
00157 //@Args In:     CDataExchange *
00158 //@Args Out:    Void
00159 //
00160 //
00161 //*********************************************************/
00162 void CRTCOutgoingDlg::DoDataExchange(CDataExchange* pDX)
00163 {
00164   CDialog::DoDataExchange(pDX);
00165   //{{AFX_DATA_MAP(CRTCOutgoingDlg)
00166   DDX_Control(pDX, IDC_STATUS, m_ctrlEditStatus);
00167   DDX_Control(pDX, IDC_LURI, m_editLURI);
00168   DDX_Control(pDX, IDC_DURI, m_editDURI);
00169   DDX_Control(pDX, IDC_PARTYLIST, m_lbParties);
00170   DDX_Control(pDX, IDC_PCPHRADIO, m_btnPcPh);
00171   DDX_Control(pDX, IDC_PHPHRADIO, m_btnPhPh);
00172   DDX_Control(pDX, IDC_PCPCRADIO, m_btnPcPc);
00173   DDX_Control(pDX, IDC_TUNE, m_btnTune);
00174   DDX_Control(pDX, IDC_REMOVEPARTY, m_btnRemoveParty);
00175   DDX_Control(pDX, IDC_APPSHARING, m_btnAppSharing);
00176   DDX_Control(pDX, IDC_ADDPARTY, m_btnAddParty);
00177   DDX_Control(pDX, IDC_DISCONNECT, m_btnDisconnect);
00178   DDX_Control(pDX, IDC_CONNECT, m_btnConnect);
00179   //}}AFX_DATA_MAP
00180 }
00181
00182
00183
00184 /**********************************************************
00185 //@CRTCOutGoingDlg MessageMap
00186 //
00187 //@Description
00188 //
00189 //
00190 //
00191 //*********************************************************/
00192
00193 BEGIN_MESSAGE_MAP(CRTCOutgoingDlg, CDialog)
00194   //{{AFX_MSG_MAP(CRTCOutgoingDlg)
00195   ON_WM_SYSCOMMAND()
00196   ON_WM_PAINT()
00197   ON_WM_QUERYDRAGICON()
00198   ON_BN_CLICKED(IDC_PCPCRADIO, OnPcpcradio)
00199   ON_BN_CLICKED(IDC_PCPHRADIO, OnPcphradio)
00200   ON_BN_CLICKED(IDC_PHPHRADIO, OnPhphradio)
00201   ON_BN_CLICKED(IDC_CONNECT, OnConnect)
00202   ON_BN_CLICKED(IDC_DISCONNECT, OnDisconnect)
00203   ON_BN_CLICKED(IDC_APPSHARING, OnAppsharing)
00204   ON_BN_CLICKED(IDC_TUNE, OnTune)
00205   ON_BN_CLICKED(IDC_ADDPARTY, OnAddparty)
00206   ON_BN_CLICKED(IDC_REMOVEPARTY, OnRemoveparty)
00207   ON_WM_CLOSE()
00208   ON_LBN_SELCHANGE(IDC_PARTYLIST, OnSelchangePartylist)
00209   ON_LBN_DBLCLK(IDC_PARTYLIST, OnDblclkPartylist)
00210   //}}AFX_MSG_MAP
00211 END_MESSAGE_MAP()
00212
00213 /**********************************************************
00214 //@OnInitDialog
00215 //
00216 //@Description
00217 //
00218 //
00219 //@Args In:     CDataExchange *
00220 //@Args Out:    Void
00221 //
00222 //
00223 //*********************************************************/
00224 BOOL CRTCOutgoingDlg::OnInitDialog()
00225 {
00226   CDialog::OnInitDialog();
00227
00228   //
00229   //About Menu is Added to the Dialogbox
00230   //
00231
00232   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00233   ASSERT(IDM_ABOUTBOX < 0xF000);
00234
00235   CMenu* pSysMenu = GetSystemMenu(FALSE);
00236   if (pSysMenu != NULL)
00237   {
00238     CString strAboutMenu;
00239     strAboutMenu.LoadString(IDS_ABOUTBOX);
00240     if (!strAboutMenu.IsEmpty())
00241     {
00242       pSysMenu->AppendMenu(MF_SEPARATOR);
00243       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
00244     }
00245   }
00246
00247   //
00248   // Icon Settings
00249   //
00250
00251   SetIcon(m_hIcon, TRUE);
00252   SetIcon(m_hIcon, FALSE);
00253
00254
00255   ::CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
00256
00257   m_ctrlEditStatus.SetWindowText(_T("Initializing ..."));
00258
00259   HRESULT hr = InitializeRTCApp();
00260
00261
00262   if (FAILED(hr))
00263   {
00264
00265     LOGMSGERROR(_T("InitializeRTCApp() Failed: 0x%x"), hr);
00266
00267     return FALSE;
00268
00269   }
00270
00271
00272   //
00273   // Set the Initial States of the Control
00274   //
00275
00276
00277   InitialControlsState();
00278
00279   return TRUE;
00280 }
00281
00282 /**********************************************************
00283 //@OnSysCommand()
00284 //
00285 //@Description
00286 //
00287 //
00288 //@Args In:     UINT, LPARAM
00289 //@Args Out:    Void
00290 //
00291 //
00292 //*********************************************************/
00293 void CRTCOutgoingDlg::OnSysCommand(UINT nID, LPARAM lParam)
00294 {
00295   if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00296   {
00297     CAboutDlg dlgAbout;
00298     dlgAbout.DoModal();
00299   }
00300   else
00301   {
00302     CDialog::OnSysCommand(nID, lParam);
00303   }
00304 }
00305
00306 /**********************************************************
00307 //@OnPaint
00308 //
00309 //@Description
00310 //
00311 // For minimize/maximize re-painting
00312 //
00313 //
00314 //@Args In:
00315 //@Args Out:    Void
00316 //
00317 //
00318 //*********************************************************/
00319
00320 void CRTCOutgoingDlg::OnPaint()
00321 {
00322   if (IsIconic())
00323   {
00324     CPaintDC dc(this); // device context for painting
00325
00326     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
00327
00328     // Center icon in client rectangle
00329     int cxIcon = GetSystemMetrics(SM_CXICON);
00330     int cyIcon = GetSystemMetrics(SM_CYICON);
00331     CRect rect;
00332     GetClientRect(&rect);
00333     int x = (rect.Width() - cxIcon + 1) / 2;
00334     int y = (rect.Height() - cyIcon + 1) / 2;
00335
00336     // Draw the icon
00337     dc.DrawIcon(x, y, m_hIcon);
00338   }
00339   else
00340   {
00341     CDialog::OnPaint();
00342   }
00343 }
00344
00345
00346 /**********************************************************
00347 //@OnQueryDragIcon
00348 //
00349 //@Description
00350 //
00351 //
00352 //@Args In:     Void
00353 //@Args Out:    HCURSOR
00354 //
00355 //
00356 //*********************************************************/
00357 HCURSOR CRTCOutgoingDlg::OnQueryDragIcon()
00358 {
00359   return (HCURSOR) m_hIcon;
00360 }
00361
00362 /**********************************************************
00363 //@UI Manipulation Methods
00364 //*********************************************************/
00365
00366 /**********************************************************
00367 //@InitlialControlsState
00368 //
00369 //@Description
00370 //
00371 //  Setting the UI Controls to their initial State
00372 //
00373 //
00374 //@Args In:     Void
00375 //@Args Out:    Void
00376 //
00377 //
00378 //*********************************************************/
00379 void
00380 CRTCOutgoingDlg::InitialControlsState()
00381 {
00382
00383   HRESULT   hr  = S_OK;
00384   //
00385   // Disable Buttons that should not be functional
00386   //
00387
00388   StateDisconnectIDC(VARIANT_FALSE);
00389   StateAddPartyIDC(VARIANT_FALSE);
00390   StateRemovePartyIDC(VARIANT_FALSE);
00391   StateLUriIDC(VARIANT_FALSE);
00392   StatePartyListIDC(VARIANT_FALSE);
00393
00394   StateConnectIDCVisible(VARIANT_TRUE);
00395   StateAddPartyIDCVisible(VARIANT_FALSE);
00396
00397   m_btnPcPh.SetCheck(0);
00398   m_btnPhPh.SetCheck(0);
00399
00400   RedrawWindow();
00401
00402   m_btnPcPc.SetCheck(1);
00403
00404   RedrawWindow();
00405
00406 }
00407
00408 /**********************************************************
00409 //@StateConnectIDO
00410 //
00411 //@Description
00412 //
00413 //  Disabled/Enables the Connect Button
00414 //
00415 //@Args In:     Void
00416 //@Args Out:    Void
00417 //
00418 //
00419 //*********************************************************/
00420 void
00421 CRTCOutgoingDlg::StateConnectIDC(VARIANT_BOOL fEnable)
00422 {
00423   if (VARIANT_TRUE == fEnable)
00424   {
00425     m_btnConnect.ModifyStyle( WS_DISABLED , 0 , 0);
00426     RedrawWindow();
00427
00428   }
00429   else
00430   {
00431     m_btnConnect.ModifyStyle( 0 , WS_DISABLED , 0);
00432     RedrawWindow();
00433   }
00434 }
00435
00436
00437 /**********************************************************
00438 //@StateConnectIDOVisible
00439 //
00440 //@Description
00441 //
00442 //  Disabled/Enables the Connect Button
00443 //
00444 //@Args In:     Void
00445 //@Args Out:    Void
00446 //
00447 //
00448 //*********************************************************/
00449 void
00450 CRTCOutgoingDlg::StateConnectIDCVisible(VARIANT_BOOL fVisible)
00451 {
00452   if (VARIANT_TRUE == fVisible)
00453   {
00454     m_btnConnect.ModifyStyle(  0 , WS_VISIBLE , 0);
00455     RedrawWindow();
00456
00457   }
00458   else
00459   {
00460     m_btnConnect.ModifyStyle( WS_VISIBLE , 0 , 0);
00461     RedrawWindow();
00462   }
00463 }
00464
00465 /**********************************************************
00466 //@StateDisconnectIDC
00467 //
00468 //@Description
00469 //
00470 //   Enables /Disables the Disconnect Button
00471 //
00472 //@Args In:     Void
00473 //@Args Out:    Void
00474 //
00475 //
00476 //*********************************************************/
00477 void
00478 CRTCOutgoingDlg::StateDisconnectIDC(VARIANT_BOOL fEnable)
00479 {
00480
00481   if (VARIANT_TRUE == fEnable)
00482   {
00483     m_btnDisconnect.ModifyStyle( WS_DISABLED , 0 , 0);
00484     RedrawWindow();
00485
00486   }
00487   else
00488   {
00489     m_btnDisconnect.ModifyStyle(0,  WS_DISABLED  , 0);
00490     RedrawWindow();
00491   }
00492
00493 }
00494
00495
00496 /**********************************************************
00497 //@StateAddPartyIDC
00498 //
00499 //@Description
00500 //
00501 //  Enable / Disable Add Party
00502 //
00503 //
00504 //@Args In:     Void
00505 //@Args Out:    Void
00506 //
00507 //
00508 //*********************************************************/
00509 void
00510 CRTCOutgoingDlg::StateAddPartyIDC(VARIANT_BOOL fEnable)
00511 {
00512
00513   if (VARIANT_TRUE == fEnable)
00514   {
00515     m_btnAddParty.ModifyStyle( WS_DISABLED , 0 , 0);
00516     RedrawWindow();
00517   }
00518   else
00519   {
00520     m_btnAddParty.ModifyStyle( 0 , WS_DISABLED , 0);
00521     RedrawWindow();
00522   }
00523
00524 }
00525
00526
00527
00528 /**********************************************************
00529 //@StateAddPartyIDCVisible(VARIANT_BOOL fEnable)
00530 //
00531 //@Description
00532 //
00533 //  Disabled/Enables the Connect Button
00534 //
00535 //@Args In:     Void
00536 //@Args Out:    Void
00537 //
00538 //
00539 //*********************************************************/
00540 void
00541 CRTCOutgoingDlg::StateAddPartyIDCVisible(VARIANT_BOOL fVisible)
00542 {
00543   if (VARIANT_TRUE == fVisible)
00544   {
00545     m_btnAddParty.ModifyStyle( 0 , WS_VISIBLE  , 0);
00546     RedrawWindow();
00547
00548   }
00549   else
00550   {
00551     m_btnAddParty.ModifyStyle( WS_VISIBLE , 0 , 0);
00552     RedrawWindow();
00553   }
00554 }
00555
00556 /**********************************************************
00557 //@StateRemovePartyIDC
00558 //
00559 //@Description
00560 //
00561 //   Enable /Disable Remove Party Button
00562 //
00563 //@Args In:     Void
00564 //@Args Out:    Void
00565 //
00566 //
00567 //*********************************************************/
00568 void
00569 CRTCOutgoingDlg::StateRemovePartyIDC(VARIANT_BOOL fEnable)
00570 {
00571
00572   if (VARIANT_TRUE == fEnable)
00573   {
00574     m_btnRemoveParty.ModifyStyle( WS_DISABLED , 0 , 0);
00575     RedrawWindow();
00576   }
00577   else
00578   {
00579     m_btnRemoveParty.ModifyStyle( 0 , WS_DISABLED , 0);
00580     RedrawWindow();
00581   }
00582 }
00583
00584
00585
00586 /**********************************************************
00587 //@StateTuneIDC
00588 //
00589 //@Description
00590 //
00591 // Enable /Disable Tunning Wizard
00592 //
00593 //@Args In:     Void
00594 //@Args Out:    Void
00595 //
00596 //
00597 //*********************************************************/
00598 void
00599 CRTCOutgoingDlg::StateTuneIDC(VARIANT_BOOL fEnable)
00600 {
00601
00602   if (VARIANT_TRUE == fEnable)
00603   {
00604     m_btnTune.ModifyStyle( WS_DISABLED , 0 , 0);
00605     RedrawWindow();
00606
00607   }
00608   else
00609   {
00610     m_btnTune.ModifyStyle( 0 , WS_DISABLED , 0);
00611     RedrawWindow();
00612   }
00613 }
00614
00615
00616 /**********************************************************
00617 //@StateAppSharingIDC
00618 //
00619 //@Description
00620 //
00621 //  Enable / Disable App Sharing Button
00622 //
00623 //@Args In:     Void
00624 //@Args Out:    Void
00625 //
00626 //
00627 //*********************************************************/
00628 void
00629 CRTCOutgoingDlg::StateAppSharingIDC(VARIANT_BOOL fEnable)
00630 {
00631
00632   if (VARIANT_TRUE == fEnable)
00633   {
00634     m_btnAppSharing.ModifyStyle( WS_DISABLED , 0 , 0);
00635     RedrawWindow();
00636
00637   }
00638   else
00639   {
00640     m_btnAppSharing.ModifyStyle( 0 , WS_DISABLED , 0);
00641     RedrawWindow();
00642   }
00643
00644 }
00645
00646
00647 /**********************************************************
00648 //@StateDUriIDC
00649 //
00650 //@Description
00651 //
00652 //  Enable / Disable Destination URI
00653 //
00654 //@Args In:     Void
00655 //@Args Out:    Void
00656 //
00657 //
00658 //*********************************************************/
00659 void
00660 CRTCOutgoingDlg::StateDUriIDC(VARIANT_BOOL fEnable)
00661 {
00662   if (VARIANT_TRUE == fEnable)
00663   {
00664     m_editDURI.ModifyStyle( WS_DISABLED , 0 , 0);
00665     RedrawWindow();
00666
00667   }
00668   else
00669   {
00670     m_editDURI.ModifyStyle( 0 , WS_DISABLED , 0);
00671     RedrawWindow();
00672   }
00673 }
00674
00675
00676 /**********************************************************
00677 //@StateLUriIDC
00678 //
00679 //@Description
00680 //
00681 //  Enable / Disable Local URI (Req for PHPH)
00682 //
00683 //@Args In:     Void
00684 //@Args Out:    Void
00685 //
00686 //
00687 //*********************************************************/
00688 void
00689 CRTCOutgoingDlg::StateLUriIDC(VARIANT_BOOL fEnable)
00690 {
00691
00692   if (VARIANT_TRUE == fEnable)
00693   {
00694     m_editLURI.ModifyStyle( WS_DISABLED , 0 , 0);
00695     RedrawWindow();
00696
00697   }
00698   else
00699   {
00700     m_editLURI.ModifyStyle( 0 , WS_DISABLED , 0);
00701     RedrawWindow();
00702   }
00703
00704 }
00705
00706
00707 /**********************************************************
00708 //@StatePartyListIDC
00709 //
00710 //@Description
00711 //
00712 //   Enable / Disable Participant List
00713 //
00714 //@Args In:     Void
00715 //@Args Out:    Void
00716 //
00717 //
00718 //*********************************************************/
00719 void
00720 CRTCOutgoingDlg::StatePartyListIDC(VARIANT_BOOL fEnable)
00721 {
00722   if (VARIANT_TRUE == fEnable)
00723   {
00724     m_lbParties.ModifyStyle( WS_DISABLED , 0 , 0);
00725     RedrawWindow();
00726   }
00727   else
00728   {
00729     m_lbParties.ModifyStyle( 0 , WS_DISABLED , 0);
00730     RedrawWindow();
00731   }
00732
00733 }
00734
00735
00736 /**********************************************************
00737 //@AddToParticipantList()
00738 //
00739 //@Description
00740 //
00741 //  Adding Participants to the List
00742 //
00743 //@Args In:     Void
00744 //@Args Out:    Void
00745 //
00746 //
00747 //*********************************************************/
00748 void CRTCOutgoingDlg::AddToParticipantList(BSTR bstrParty)
00749 {
00750   _ASSERTE( bstrParty != NULL);
00751
00752   m_lbParties.AddString(bstrParty);
00753   StatePartyListIDC(VARIANT_TRUE);
00754 }
00755
00756
00757 /**********************************************************
00758 //@OnPcPcRadio()
00759 //
00760 //@Description
00761 //
00762 //  For PC/PC Calls Check Box
00763 //
00764 //
00765 //@Args In:     Void
00766 //@Args Out:    Void
00767 //
00768 //
00769 //*********************************************************/
00770
00771 void CRTCOutgoingDlg::OnPcpcradio()
00772 {
00773   HRESULT    hr   = S_OK;
00774
00775   if (1 == m_btnPcPc.GetCheck())
00776   {
00777        m_btnPcPc.SetCheck(1);
00778      m_btnPcPh.SetCheck(0);
00779      m_btnPhPh.SetCheck(0);
00780
00781      StateAppSharingIDC(VARIANT_TRUE);
00782      StateLUriIDC(VARIANT_FALSE);
00783
00784      m_SessionType =   RTCST_PC_TO_PC;
00785
00786      m_editDURI.SetWindowText(_T(""));
00787      m_editLURI.SetWindowText(_T(""));
00788
00789   }
00790 }
00791
00792
00793
00794 /**********************************************************
00795 //@OnPcPhRadio()
00796 //
00797 //@Description
00798 //
00799 // For PC/PH Calls Check Box
00800 //
00801 //@Args In:     Void
00802 //@Args Out:    Void
00803 //
00804 //
00805 //*********************************************************/
00806
00807 void CRTCOutgoingDlg::OnPcphradio()
00808 {
00809
00810   HRESULT   hr = S_OK;
00811   if (1 == m_btnPcPh.GetCheck())
00812   {
00813        m_btnPcPc.SetCheck(0);
00814      m_btnPcPh.SetCheck(1);
00815      m_btnPhPh.SetCheck(0);
00816
00817      StateAppSharingIDC(VARIANT_FALSE);
00818      StateLUriIDC(VARIANT_FALSE);
00819
00820      m_SessionType =  RTCST_PC_TO_PHONE ;
00821
00822      m_editDURI.SetWindowText(_T(""));
00823      m_editLURI.SetWindowText(_T(""));
00824
00825     }
00826 }
00827
00828
00829 /**********************************************************
00830 //@OnPhPhRadio()
00831 //
00832 //@Description
00833 //
00834 // For PH to PH Check Box
00835 //
00836 //@Args In:     Void
00837 //@Args Out:    Void
00838 //
00839 //
00840 //*********************************************************/
00841
00842 void CRTCOutgoingDlg::OnPhphradio()
00843 {
00844   HRESULT     hr = S_OK;
00845   if (1 == m_btnPhPh.GetCheck())
00846   {
00847        m_btnPcPc.SetCheck(0);
00848      m_btnPcPh.SetCheck(0);
00849      m_btnPhPh.SetCheck(1);
00850
00851      StateAppSharingIDC(VARIANT_FALSE);
00852      StateLUriIDC(VARIANT_TRUE);
00853
00854      m_SessionType = RTCST_PHONE_TO_PHONE;
00855
00856
00857      m_editDURI.SetWindowText(_T(""));
00858      m_editLURI.SetWindowText(_T(""));
00859
00860   }
00861 }
00862
00863
00864 /**********************************************************
00865 //@UI Event Handlers and Message Handlers
00866 //*********************************************************/
00867
00868 /**********************************************************
00869 //@WindowProc
00870 //
00871 //@Description
00872 //
00873 //  Overriding to Process the WM_RTCCOREEVENT only
00874 //  for the RTCCE_ASYNC_CLEANUP event
00875 //
00876 //
00877 //*********************************************************/
00878 LRESULT CRTCOutgoingDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
00879 {
00880   HRESULT    hr   = S_OK;
00881
00882   switch(message)
00883   {
00884     case WM_RTCCORE_EVENT:
00885     {
00886       ShutdownRTCApp();
00887       break;
00888     }
00889   default : return CDialog::WindowProc(message, wParam, lParam);
00890
00891   }
00892
00893   return CDialog::WindowProc(message, wParam, lParam);
00894 }
00895
00896 /**********************************************************
00897 //@OnClose()
00898 //
00899 //@Description
00900 //
00901 //   On Close Event Handler
00902 //
00903 //
00904 //*********************************************************/
00905
00906 void CRTCOutgoingDlg::OnClose()
00907 {
00908   HRESULT   hr = S_OK;
00909
00910   _ASSERTE(NULL != m_pIRTCClient);
00911
00912   //
00913   // Need to call PrepareForShutdown Before shutdown
00914   //
00915
00916   hr = m_pIRTCClient->PrepareForShutdown();
00917   if (FAILED(hr))
00918   {
00919      LOGMSGERROR(_T("IRTCClient::PrepareForShutdown Failed 0x%x"), hr);
00920      m_pIRTCClient->Shutdown();
00921      return;
00922   }
00923
00924   ShowWindow( SW_HIDE );
00925 }
00926
00927
00928 /**********************************************************
00929 //@OnConnect
00930 //
00931 //@Description
00932 //
00933 // Called / EventHandler for Connect Button Clicked
00934 //
00935 //
00936 //@Args In:     Void
00937 //@Args Out:    Void
00938 //
00939 //
00940 //*********************************************************/
00941 void CRTCOutgoingDlg::OnConnect()
00942 {
00943   StateSessionControl(STO_CREATE);
00944 }
00945
00946
00947 /**********************************************************
00948 //@OnDisconnect
00949 //
00950 //@Description
00951 //
00952 // Called / EventHandler for Disconnect Button Clicked
00953 //
00954 //@Args In:     Void
00955 //@Args Out:    Void
00956 //
00957 //
00958 //*********************************************************/
00959
00960 void CRTCOutgoingDlg::OnDisconnect()
00961 {
00962   StateSessionControl(STO_TERMINATE);
00963   StateConnectIDC(VARIANT_TRUE);
00964 }
00965
00966
00967 /**********************************************************
00968 //@OnAppsharing
00969 //
00970 //@Description
00971 //
00972 // Called / EventHandler for App Sharing Button Clicked
00973 //
00974 //@Args In:     Void
00975 //@Args Out:    Void
00976 //
00977 //
00978 //*********************************************************/
00979
00980 void CRTCOutgoingDlg::OnAppsharing()
00981 {
00982   StateStartT120(RTCTA_APPSHARING);
00983 }
00984
00985
00986
00987 /**********************************************************
00988 //@OnTune
00989 //
00990 //@Description
00991 //
00992 //  Called / EventHandler for Tune Button Clicked
00993 //
00994 //@Args In:     Void
00995 //@Args Out:    Void
00996 //
00997 //
00998 //*********************************************************/
00999
01000 void CRTCOutgoingDlg::OnTune()
01001 {
01002   StateStartTunning();
01003 }
01004
01005 /**********************************************************
01006 //@OnAddParty
01007 //
01008 //@Description
01009 //
01010 // Called / EventHandler for Add Party Button Clicked
01011 //
01012 //
01013 //@Args In:     Void
01014 //@Args Out:    Void
01015 //
01016 //
01017 //*********************************************************/
01018
01019 void CRTCOutgoingDlg::OnAddparty()
01020 {
01021
01022   StateSessionControl(STO_ADDPARTY);
01023
01024 }
01025
01026
01027 /**********************************************************
01028 //@OnRemoveParty
01029 //
01030 //@Description
01031 //
01032 // Called / EventHandler for Remove Party Button Clicked
01033 //
01034 //
01035 //@Args In:     Void
01036 //@Args Out:    Void
01037 //
01038 //
01039 //*********************************************************/
01040
01041 void CRTCOutgoingDlg::OnRemoveparty()
01042 {
01043   StateSessionControl(STO_REMOVEPARTY);
01044 }
01045
01046
01047 /**********************************************************
01048 //@OnSelchangePartylist()
01049 //
01050 //@Description
01051 //
01052 // Called / EventHandler for Remove Party Button Clicked
01053 // implementation not operational for this sample
01054 //
01055 //@Args In:     Void
01056 //@Args Out:    Void
01057 //
01058 //
01059 //*********************************************************/
01060 void CRTCOutgoingDlg::OnSelchangePartylist()
01061 {
01062
01063   HRESULT               hr            = S_OK;
01064   IRTCEnumParticipants *pIEnumParties = NULL;
01065   IRTCParticipant      *pIParty       = NULL;
01066   CString               cstrURI;
01067   BSTR                  bstrURI = NULL, bstrParty = NULL;
01068   VARIANT_BOOL          fRemove       = VARIANT_FALSE;
01069
01070   INT lIndex = m_lbParties.GetCurSel();
01071   m_lbParties.GetText( lIndex, cstrURI);
01072
01073   bstrURI = cstrURI.AllocSysString();
01074
01075   DBLOGGER(_T("Selected  %s\n"), bstrURI);
01076
01077   hr = m_pIRTCSession->EnumerateParticipants(&pIEnumParties);
01078
01079   if (FAILED(hr))
01080   {
01081       LOGMSGERROR(_T("IRTCSession::EnumerateParticipants Failed 0x%x"), hr);
01082     FREE_BSTR_IF(bstrURI);
01083     return;
01084
01085   }
01086
01087   while (S_OK == (hr = pIEnumParties->Next(1, &pIParty, NULL)))
01088   {
01089
01090     hr = pIParty->get_UserURI(&bstrParty);
01091
01092     if (0 == _tcscmp(bstrParty ,  bstrURI))
01093     {
01094        break;
01095     }
01096     else
01097     {
01098       pIParty->Release();
01099         pIParty = NULL;
01100
01101     }
01102
01103     FREE_BSTR_IF(bstrParty);
01104   }
01105
01106   FREE_BSTR_IF(bstrURI);
01107
01108   if (NULL != pIParty)
01109   {
01110      hr = pIParty->get_Removable(&fRemove);
01111
01112      if (FAILED(hr))
01113      {
01114      LOGMSGERROR(_T("IRTCSession::RemoveParticipant Failed 0x%x"), hr);
01115      return;
01116      }
01117      else
01118      {
01119        if (VARIANT_TRUE == fRemove)
01120        {
01121          StateRemovePartyIDC(VARIANT_TRUE);
01122        }
01123
01124      }
01125
01126      pIParty->Release();
01127      pIParty = NULL;
01128
01129   }
01130   else
01131   {
01132     LOGMSGERROR(_T("Failed to Find Selected Participant"), hr);
01133   }
01134 }
01135
01136 /**********************************************************
01137 //@OnDblclkPartyList
01138 //
01139 //@Description
01140 //
01141 //  When double clicking on a Participant in the list
01142 //  a message box pops up with the participants information
01143 //
01144 //
01145 //@Args In:
01146 //@Args Out:
01147 //
01148 //
01149 //*********************************************************/
01150
01151 void CRTCOutgoingDlg::OnDblclkPartylist()
01152 {
01153   HRESULT               hr            = S_OK;
01154   IRTCEnumParticipants *pIEnumParties = NULL;
01155   IRTCParticipant      *pIParty       = NULL;
01156   CString               cstrURI;
01157   BSTR                  bstrURI = NULL, bstrParty = NULL;
01158
01159   INT lIndex = m_lbParties.GetCurSel();
01160   m_lbParties.GetText( lIndex, cstrURI);
01161
01162   bstrURI = cstrURI.AllocSysString();
01163
01164   DBLOGGER(_T("Selected  %s\n"), bstrURI);
01165
01166   //
01167   // Enumerate the Participants and find the correct one
01168   //
01169
01170   hr = m_pIRTCSession->EnumerateParticipants(&pIEnumParties);
01171
01172   if (FAILED(hr))
01173   {
01174       LOGMSGERROR(_T("IRTCSession::EnumerateParticipants Failed 0x%x"), hr);
01175     FREE_BSTR_IF(bstrURI);
01176     return;
01177
01178   }
01179
01180   while (S_OK == (hr = pIEnumParties->Next(1, &pIParty, NULL)))
01181   {
01182     //
01183     // Note: This application doesnt process the tel: URI
01184     // or sip: string in the name so this would fail to find
01185     // the address.
01186
01187     hr = pIParty->get_UserURI(&bstrParty);
01188
01189     if (0 == _tcscmp(bstrParty ,  bstrURI))
01190     {
01191        break;
01192     }
01193     else
01194     {
01195       pIParty->Release();
01196         pIParty = NULL;
01197
01198     }
01199
01200   }
01201
01202   FREE_BSTR_IF(bstrURI);
01203
01204   //
01205   // Pop Up a Message Box with this Information
01206   //
01207
01208   if (NULL != pIParty)
01209   {
01210
01211      VARIANT_BOOL          fRemove       = VARIANT_FALSE;
01212      RTC_PARTICIPANT_STATE PartyState;
01213
01214
01215      pIParty->get_Removable(&fRemove);
01216      pIParty->get_State(&PartyState);
01217
01218
01219      LOGMSG(_T("Participant URI:%s\nParticipant State:%d\nParticipant Removable:%s"),
01220        bstrParty, PartyState, ( (fRemove == VARIANT_TRUE) ? _T("Yes") :_T("No") ) );
01221
01222      pIParty->Release();
01223      pIParty = NULL;
01224
01225   }
01226   else
01227   {
01228     LOGMSGERROR(_T("Failed to Find Selected Participant"), hr);
01229   }
01230
01231   FREE_BSTR_IF(bstrParty);
01232
01233 }
01234
01235 /**********************************************************
01236 //@RTC Application Entry / Exit Points
01237
01238 //*********************************************************/
01239
01240 /**********************************************************
01241 //@InitializeRTCApp()
01242 //
01243 //@Description
01244 //
01245 //  - CoCreating CLSID_RTCClient object and getting
01246 //    the IRTCClient Interface
01247 //  - Initializing the Client interface
01248 //  - Setting the Event Call Back Connection Point for
01249 //    the Source sink
01250 //  - Setting the Listen mode (opening SIP ports)
01251 //
01252 //@Args In:     Void
01253 //@Args Out:    Void
01254 //
01255 //
01256 //*********************************************************/
01257
01258 HRESULT
01259 CRTCOutgoingDlg::InitializeRTCApp()
01260 {
01261
01262   HRESULT    hr   = S_OK;
01263
01264   //
01265   // CoCreating CLSID_RTCClient object and getting
01266   // the IRTCClient Interface
01267   //
01268
01269
01270   hr = StateCoCreateClient();
01271
01272   if (FAILED(hr))
01273   {
01274     return hr;
01275   }
01276
01277   //
01278   // Initializing the Client
01279   //
01280
01281   hr = StateInitClient();
01282
01283   if (FAILED(hr))
01284   {
01285     return hr;
01286   }
01287
01288   // Setting the Event Call Back Connection Point for
01289   // the Source sink
01290
01291   hr = StateSinkEvent(0);
01292
01293   if (FAILED(hr))
01294   {
01295     return hr;
01296   }
01297
01298   //
01299   // Setting the Listen mode to
01300   // receive incoming calls event notifications
01301   //
01302
01303   hr = StateListenMode( RTCLM_BOTH );
01304
01305   if (FAILED(hr))
01306   {
01307     return hr;
01308   }
01309
01310   return hr;
01311 }
01312
01313 /**********************************************************
01314 //@ShutdownRTCApp()
01315 //
01316 //@Description
01317 //
01318 //
01319 //
01320 //@Args In:     Void
01321 //@Args Out:    Void
01322 //
01323 //
01324 //*********************************************************/
01325
01326 HRESULT
01327 CRTCOutgoingDlg::ShutdownRTCApp()
01328 {
01329
01330   HRESULT hr  = S_OK;
01331
01332     _ASSERTE(NULL != m_pIRTCClient);
01333
01334     StateUnSinkEvent();
01335
01336     hr = m_pIRTCClient->Shutdown();
01337
01338    if (FAILED(hr))
01339    {
01340       LOGMSGERROR(_T("IRTCClient::Shutdown() Failed 0x%x"), hr);
01341    }
01342
01343    ReleaseStateMachine();
01344
01345    CoUninitialize();
01346    DestroyWindow();
01347
01348    return S_OK;
01349
01350 }
01351
01352
01353
01354 /**********************************************************
01355 //@RTC State Machine Methods for RTC Core Operations
01356 //*********************************************************/
01357 /**********************************************************
01358 //@StateCoCreateClient()
01359 //
01360 //@Description
01361 //
01362 //  CoCreate the RTC Client COM Object
01363 //
01364 //@Args In:     None
01365 //@Args Out:    None
01366 //
01367 //
01368 //*********************************************************/
01369 HRESULT
01370 CRTCOutgoingDlg::StateCoCreateClient()
01371 {
01372
01373   HRESULT hr = S_OK;
01374
01375   _ASSERTE(NULL != this);
01376
01377   hr = CoCreateInstance(CLSID_RTCClient,
01378               NULL,
01379               CLSCTX_INPROC_SERVER,
01380               IID_IRTCClient,
01381               reinterpret_cast<void **> (&m_pIRTCClient)
01382               );
01383
01384
01385   if (FAILED(hr))
01386   {
01387     LOGMSGERROR(_T("CoCreateInstance(CLSID_RTCClient) : Failed 0x%x"), hr);
01388     return hr;
01389   }
01390
01391   return hr;
01392
01393 }
01394
01395
01396 /**********************************************************
01397 //@StateInitClient
01398 //
01399 //@Description
01400 //
01401 //  Initialize the RTCClient Interface
01402 //
01403 //@Args In:     None
01404 //@Args Out:    None
01405 //
01406 //
01407 //*********************************************************/
01408 HRESULT
01409 CRTCOutgoingDlg::StateInitClient()
01410 {
01411
01412   HRESULT hr = S_OK;
01413
01414   _ASSERTE(NULL != this);
01415
01416   hr = m_pIRTCClient->Initialize();
01417
01418   if (FAILED(hr))
01419   {
01420
01421     LOGMSGERROR(_T("IRTCClient::Initialize : Failed 0x%x"),
01422       hr);
01423     return hr;
01424   }
01425
01426   return hr;
01427 }
01428
01429 /**********************************************************
01430 //@StateSessionControl
01431 //
01432 //@Description
01433 //
01434 //  Call Control for this App we are only concerned with
01435 //  either answering the call or disconnecting
01436 //
01437
01438 //@Args In:     SESSION_OPERATION = {STO_CREATE |
01439                    STO_ADDPARTY
01440                    STO_REMOVEPARTY
01441                    STO_TERMINATE}
01442 //@Args Out:    HRESULT
01443 //
01444 //*********************************************************/
01445
01446
01447 HRESULT
01448 CRTCOutgoingDlg::StateSessionControl(SESSION_OPERATION soType)
01449 {
01450
01451   HRESULT hr = S_OK;
01452   BSTR    bstrLocalURI  = NULL;
01453   BSTR    bstrURI       = NULL;
01454
01455   _ASSERTE(NULL != this);
01456
01457   switch(soType)
01458   {
01459
01460   case STO_CREATE:
01461     {
01462
01463       //
01464       // Disable the Tunning Wizard upon session creation
01465       //
01466
01467       StateTuneIDC(VARIANT_FALSE);
01468
01469       if (m_SessionType == RTCST_PHONE_TO_PHONE)
01470       {
01471
01472         //
01473         // A valid profile object is required to make Phone to Phone call,
01474         // It is upto the reader to setup the infrastructure and create a
01475         // proper profile based on their local settings. This code has been
01476         // provided as an example. It will fail with proper error code.
01477         //
01478
01479         //
01480         // Phone URI must be a Tel URI in
01481         // canonical format eg: +12223334444
01482         //
01483
01484         CString cstrLocalURI;
01485         m_editLURI.GetWindowText(cstrLocalURI);
01486
01487         if (TRUE  == cstrLocalURI.IsEmpty())
01488         {
01489           LOGMSGERROR(_T("Set the Local URI for Phone to Phone Sessions"));
01490           return E_INVALIDARG;
01491         }
01492         else
01493         {
01494           bstrLocalURI = cstrLocalURI.AllocSysString();
01495           _ASSERTE(NULL != bstrLocalURI);
01496         }
01497       }
01498
01499       hr = m_pIRTCClient->CreateSession( m_SessionType,
01500                          bstrLocalURI,
01501                          NULL,
01502                          0,
01503                          &m_pIRTCSession);
01504
01505       FREE_BSTR_IF(bstrLocalURI);
01506
01507       if ( FAILED(hr) )
01508       {
01509
01510         LOGMSGERROR(_T("IRTCSession::CreateSession() Failed 0x%x"), hr);
01511         return hr;
01512       }
01513
01514
01515
01516       CString cstrURI;
01517
01518       m_editDURI.GetWindowText(cstrURI);
01519
01520       if (TRUE == cstrURI.IsEmpty())
01521       {
01522         LOGMSGERROR(_T("Set the Destination URI"), hr);
01523         return hr;
01524       }
01525       else
01526       {
01527
01528         bstrURI   = cstrURI.AllocSysString();
01529
01530         _ASSERTE(NULL != bstrURI);
01531
01532         hr = m_pIRTCSession->AddParticipant(bstrURI,
01533                           bstrURI,
01534                           &m_pIRTCParty);
01535
01536         if ( FAILED(hr) )
01537         {
01538
01539           LOGMSGERROR(_T("IRTCSession::AddParticipant() Failed 0x%x"), hr);
01540           return hr;
01541         }
01542         else
01543         {
01544           AddToParticipantList(bstrURI);
01545         }
01546
01547         FREE_BSTR_IF(bstrURI);
01548       }
01549
01550       break;
01551     }
01552   case STO_ADDPARTY:
01553     {
01554
01555       CString cstrURI;
01556
01557       m_editDURI.GetWindowText(cstrURI);
01558
01559       if (TRUE == cstrURI.IsEmpty())
01560       {
01561         LOGMSGERROR(_T("Set the Party URI"), hr);
01562         return hr;
01563       }
01564       else
01565       {
01566         bstrURI   = cstrURI.AllocSysString();
01567
01568         _ASSERTE(NULL != bstrURI);
01569
01570         if (NULL != m_pIRTCParty)
01571         {
01572           m_pIRTCParty->Release();
01573           m_pIRTCParty = NULL;
01574         }
01575
01576         hr = m_pIRTCSession->AddParticipant(bstrURI,
01577                           bstrURI,
01578                           &m_pIRTCParty);
01579
01580         if ( FAILED(hr) )
01581         {
01582
01583           LOGMSGERROR(_T("IRTCSession::AddParticipant() Failed 0x%x"), hr);
01584           return hr;
01585         }
01586         else
01587         {
01588           AddToParticipantList(bstrURI);
01589         }
01590
01591         m_editDURI.SetWindowText(_T(""));
01592         FREE_BSTR_IF(bstrURI);
01593       }
01594       break;
01595     }
01596   case STO_REMOVEPARTY:
01597     {
01598       IRTCEnumParticipants *pIEnumParties = NULL;
01599       IRTCParticipant      *pIParty       = NULL;
01600       CString               cstrURI;
01601       BSTR                  bstrURI = NULL, bstrParty = NULL;
01602
01603       INT lIndex = m_lbParties.GetCurSel();
01604       m_lbParties.GetText( lIndex, cstrURI);
01605
01606       bstrURI = cstrURI.AllocSysString();
01607
01608       DBLOGGER(_T("Removing %s\n"), bstrURI);
01609
01610       hr = m_pIRTCSession->EnumerateParticipants(&pIEnumParties);
01611
01612       if (FAILED(hr))
01613       {
01614           LOGMSGERROR(_T("IRTCSession::EnumerateParticipants Failed 0x%x"), hr);
01615         FREE_BSTR_IF(bstrURI);
01616         return hr;
01617       }
01618
01619       while (S_OK == (hr = pIEnumParties->Next(1, &pIParty, NULL)))
01620       {
01621
01622         hr = pIParty->get_UserURI(&bstrParty);
01623
01624         if (0 == _tcscmp(bstrParty ,  bstrURI))
01625         {
01626           break;
01627         }
01628         else
01629         {
01630           pIParty->Release();
01631           pIParty = NULL;
01632
01633         }
01634
01635         FREE_BSTR_IF(bstrParty);
01636       }
01637
01638       FREE_BSTR_IF(bstrURI);
01639
01640       if (NULL != pIParty)
01641       {
01642         hr = m_pIRTCSession->RemoveParticipant(pIParty);
01643
01644         if (FAILED(hr))
01645         {
01646            LOGMSGERROR(_T("IRTCSession::RemoveParticipant Failed 0x%x"), hr);
01647            return hr;
01648         }
01649         else
01650         {
01651           m_lbParties.DeleteString(lIndex);
01652         }
01653
01654         pIParty->Release();
01655         pIParty = NULL;
01656       }
01657       else
01658       {
01659         LOGMSGERROR(_T("Failed to Find Selected Participant"), hr);
01660
01661       }
01662
01663       break;
01664     }
01665   case STO_TERMINATE:
01666     {
01667
01668       hr = m_pIRTCSession->Terminate( RTCTR_NORMAL );
01669
01670       if ( FAILED(hr) )
01671       {
01672         LOGMSGERROR(_T("IRTCSession:::Terminate() Failed 0x%x"), hr);
01673       }
01674
01675       break;
01676     }
01677   default:
01678     return E_NOTIMPL;
01679
01680   }
01681
01682   return hr;
01683 }
01684
01685 /**********************************************************
01686 //@StateListenMode
01687 //
01688 //@Description
01689 //
01690 // Call to set the List Mode on the Client to open and
01691 // list to corresponding SIP ports
01692 //
01693 //
01694 //@Args In:     RTC_LISTEN_MODE = {see RTC SDK for types}
01695 //@Args Out:    HRESULT
01696 //
01697 //*********************************************************/
01698 HRESULT
01699 CRTCOutgoingDlg::StateListenMode(RTC_LISTEN_MODE lMode)
01700 {
01701
01702   HRESULT hr = S_OK;
01703
01704   _ASSERTE(NULL != this);
01705   _ASSERTE(NULL != m_pIRTCClient);
01706
01707   hr = m_pIRTCClient->put_ListenForIncomingSessions(lMode);
01708
01709   if (FAILED(hr))
01710   {
01711
01712     LOGMSGERROR(_T("IRTCClient::put_ListenForIncomingSessions Failed 0x%x"),
01713       hr);
01714     return hr;
01715   }
01716   else
01717   {
01718     m_ctrlEditStatus.SetWindowText(_T("Ready ..."));
01719   }
01720
01721   return hr;
01722 }
01723
01724
01725
01726 /**********************************************************
01727 //@StateQueryActiveMedia
01728 //
01729 //@Description
01730 //
01731 // Query for Active media streams on the Client
01732 //
01733 //
01734 //@Args In:     Void
01735 //@Args Out:    long active media mask
01736 //
01737 //*********************************************************/
01738
01739 HRESULT
01740 CRTCOutgoingDlg::StateQueryActiveMedia(LONG *plActiveMedia)
01741 {
01742   HRESULT hr = S_OK;
01743
01744   _ASSERTE(NULL != this);
01745   _ASSERTE(NULL != m_pIRTCClient);
01746
01747
01748
01749   LONG   lActive   = 0;
01750   BSTR   bstrMedia = NULL;
01751
01752   hr = m_pIRTCClient->get_ActiveMedia(&lActive);
01753
01754   if (FAILED(hr))
01755   {
01756     LOGMSGERROR(_T("IRTCClient::get_ActiveMedia() Failed 0x%x"), hr);
01757     return hr;
01758   }
01759
01760   *plActiveMedia = lActive;
01761
01762
01763   FREE_BSTR_IF(bstrMedia);
01764
01765   return hr;
01766 }
01767
01768 /**********************************************************
01769 //@StateSinkEvent()
01770 //
01771 //@Description
01772 //
01773 //  set the Connection point source and event filter
01774 //
01775 //@Args In:     LONG Event Mask
01776 //@Args Out:    None
01777 //
01778 //
01779 //*********************************************************/
01780 HRESULT
01781 CRTCOutgoingDlg::StateSinkEvent(LONG lEventMask)
01782 {
01783
01784   HRESULT                   hr          = S_OK;
01785   IUnknown                  *pUnknown   = NULL;
01786   IConnectionPointContainer *pCPC       = NULL;
01787   IConnectionPoint          *pCP        = NULL;
01788
01789   _ASSERTE(NULL != this);
01790
01791
01792   //
01793   // Right now I will actually override this.
01794   //
01795
01796   lEventMask = RTCEF_CLIENT                     |
01797          RTCEF_SESSION_STATE_CHANGE       |
01798          RTCEF_MEDIA;
01799
01800
01801   hr = m_pIRTCClient->put_EventFilter(lEventMask);
01802
01803
01804   if (FAILED(hr))
01805   {
01806
01807     LOGMSGERROR(_T("IRTCClient::put_EventFilter Failed 0x%x"),
01808       hr);
01809
01810     return hr;
01811   }
01812
01813   if (FAILED(hr))
01814   {
01815
01816     LOGMSGERROR(_T("InitializeSink() Failed 0x%x"), hr);
01817     return hr;
01818   }
01819
01820   hr = QueryInterface(IID_IUnknown,
01821                 reinterpret_cast<void**> (&pUnknown)
01822              );
01823
01824   if (FAILED(hr))
01825   {
01826     LOGMSGERROR(_T("QueryInterface(IUnknown) Failed 0x%x"), hr);
01827     return hr;
01828   }
01829
01830
01831
01832
01833   hr = m_pIRTCClient->QueryInterface(IID_IConnectionPointContainer,
01834                    reinterpret_cast<void**> (&pCPC)
01835                    );
01836
01837   if (FAILED(hr))
01838   {
01839
01840     LOGMSGERROR(_T("IRTCClient::QueryInterface(IConnectionPointContainer) Failed 0x%x"),
01841       hr);
01842
01843     return hr;
01844   }
01845
01846
01847   hr = pCPC->FindConnectionPoint( IID_IRTCEventNotification,
01848                   &pCP );
01849
01850
01851   if (FAILED(hr))
01852   {
01853     LOGMSGERROR(_T("IConnectionPointContainer::FindConnectionPoint() Failed 0x%x"),
01854       hr);
01855
01856     pCPC->Release();
01857     return hr;
01858   }
01859
01860
01861   hr = pCP->Advise( pUnknown, &m_dwEventCookie );
01862
01863   if (FAILED(hr))
01864   {
01865
01866     LOGMSGERROR(_T("IConnectionPoint::Advise() Failed 0x%x"), hr);
01867
01868     pCPC->Release();
01869     pCP->Release();
01870     return hr;
01871   }
01872
01873
01874   pCP->Release();
01875   pCPC->Release();
01876   pUnknown->Release();
01877
01878   return hr;
01879 }
01880
01881
01882 /**********************************************************
01883 //@StateUnSinkEvent
01884 //
01885 //@Description
01886 //
01887 //  unsink event connection point
01888 //
01889 //@Args In:     None
01890 //@Args Out:    None
01891 //
01892 //
01893 //*********************************************************/
01894 HRESULT
01895 CRTCOutgoingDlg::StateUnSinkEvent()
01896 {
01897
01898   HRESULT            hr       = S_OK;
01899   IUnknown                  *pUnknown   = NULL;
01900   IConnectionPointContainer *pCPC       = NULL;
01901   IConnectionPoint          *pCP        = NULL;
01902
01903
01904   hr = QueryInterface(IID_IUnknown,
01905               reinterpret_cast<void**> (&pUnknown)
01906              );
01907
01908   if (FAILED(hr))
01909   {
01910     LOGMSGERROR(_T("QueryInterface(IUnknown) Failed 0x%x"), hr);
01911     return hr;
01912   }
01913
01914
01915   hr = m_pIRTCClient->QueryInterface(IID_IConnectionPointContainer,
01916                    reinterpret_cast<void**> (&pCPC)
01917                    );
01918
01919   if (FAILED(hr))
01920   {
01921     LOGMSGERROR(_T("IRTCClient::QueryInterface(IConnectionPointContainer) Failed 0x%x"), hr);
01922
01923     return hr;
01924   }
01925
01926
01927   hr = pCPC->FindConnectionPoint( IID_IRTCEventNotification,
01928                   &pCP );
01929
01930
01931   if (FAILED(hr))
01932   {
01933
01934     LOGMSGERROR(_T("IConnectionPointContainer::FindConnectionPoint Failed 0x%x"),
01935       hr);
01936
01937
01938     pCPC->Release();
01939     return hr;
01940   }
01941
01942
01943   hr = pCP->Unadvise( m_dwEventCookie );
01944
01945   if (FAILED(hr))
01946   {
01947
01948     LOGMSGERROR(_T("IConnectionPoint::Unadvise() Failed 0x%x"),
01949       hr);
01950
01951     pCPC->Release();
01952     pCP->Release();
01953     return hr;
01954   }
01955
01956
01957   pCP->Release();
01958   pCPC->Release();
01959   pUnknown->Release();
01960
01961
01962   return hr;
01963 }
01964
01965 /**********************************************************
01966 //@ReleaseStateMachine
01967 //
01968 //@Description
01969 //
01970 //  Internal Destructor , releases all the Interfaces
01971 //
01972 //@Args In:     None
01973 //@Args Out:    None
01974 //
01975 //
01976 //*********************************************************/
01977
01978 HRESULT
01979 CRTCOutgoingDlg::ReleaseStateMachine()
01980 {
01981
01982   ULONG ulRef         = 0;
01983   BOOL  fRet          = FALSE;
01984
01985   if ( NULL != m_pIRecvVideo )
01986   {
01987
01988     ulRef = m_pIRecvVideo->Release();
01989     m_pIRecvVideo  = NULL;
01990   }
01991
01992   if ( NULL != m_pIPrevVideo )
01993   {
01994     ulRef = m_pIPrevVideo->Release();
01995     m_pIRecvVideo = NULL;
01996
01997   }
01998
01999   if ( NULL != m_pIRTCSession )
02000   {
02001     ulRef = m_pIRTCSession->Release();
02002     m_pIRTCSession = NULL;
02003   }
02004
02005   if ( NULL != m_pIRTCParty)
02006   {
02007     ulRef = m_pIRTCParty->Release();
02008     m_pIRTCParty = NULL;
02009   }
02010
02011   return S_OK;
02012
02013 }
02014
02015 /**********************************************************
02016 //@AddToMediaCapabilities
02017 //
02018 //@Description
02019 //
02020 //  Add Media Capability to the Client
02021 //
02022 //@Args In:     None
02023 //@Args Out:    None
02024 //
02025 //
02026 //*********************************************************/
02027
02028 HRESULT
02029 CRTCOutgoingDlg::AddToMediaCapabilities(LONG lMedia, VARIANT_BOOL fPersist)
02030 {
02031
02032   HRESULT hr = S_OK;
02033   LONG    lGetMedia = 0;
02034   LONG    lSetMedia = 0;
02035
02036   _ASSERTE(NULL != m_pIRTCClient);
02037
02038   hr = m_pIRTCClient->get_MediaCapabilities(&lGetMedia);
02039
02040
02041   if (FAILED(hr))
02042   {
02043     LOGMSGERROR(_T("IRTCClient::get_MediaCapabilities() Failed 0x%x"), hr);
02044     return hr;
02045   }
02046   else
02047   {
02048
02049     lSetMedia = lGetMedia | lMedia;
02050
02051
02052
02053     hr = m_pIRTCClient->SetPreferredMediaTypes(lSetMedia, fPersist);
02054
02055     if (FAILED(hr))
02056     {
02057       LOGMSGERROR(_T("IRTCClient::SetPreferredMediaTypes Failed 0x%x"), hr);
02058       return hr;
02059     }
02060
02061   }
02062
02063   return hr;
02064 }
02065
02066
02067 /**********************************************************
02068 //@RemoveFromMediaCapabilities
02069 //
02070 //@Description
02071 //
02072 // Removing Media Capabilities from Media
02073 //
02074 //@Args In:     None
02075 //@Args Out:    None
02076 //
02077 //
02078 //*********************************************************/
02079 HRESULT
02080 CRTCOutgoingDlg::RemoveFromMediaCapabilities(LONG lMedia,
02081                        VARIANT_BOOL fPersist)
02082 {
02083   HRESULT hr = S_OK;
02084   LONG    lGetMedia = 0;
02085   LONG    lSetMedia = 0;
02086
02087   _ASSERTE(NULL != m_pIRTCClient);
02088
02089   hr = m_pIRTCClient->get_MediaCapabilities(&lGetMedia);
02090
02091
02092   if (FAILED(hr))
02093   {
02094     LOGMSGERROR(_T("IRTCClient::get_MediaCapabilities() Failed 0x%x"), hr);
02095     return hr;
02096   }
02097   else
02098   {
02099     //
02100     // are the media bits set
02101     //
02102
02103     if ( (lGetMedia & lMedia) == lMedia )
02104     {
02105
02106       lSetMedia = lGetMedia & (~lMedia);
02107
02108
02109       hr = m_pIRTCClient->SetPreferredMediaTypes(lSetMedia, fPersist);
02110
02111       if (FAILED(hr))
02112       {
02113         LOGMSGERROR(_T("IRTCClient::SetPreferredMediaTypes(%d) Failed 0x%x"),
02114           lSetMedia, hr);
02115         return hr;
02116       }
02117
02118     }
02119   }
02120
02121   return hr;
02122 }
02123
02124 /**********************************************************
02125 //@StateStartT120
02126 //
02127 //@Description
02128 //
02129 // Start the T120 Applet
02130 //
02131 //@Args In:     None
02132 //@Args Out:    None
02133 //
02134 //
02135 //*********************************************************/
02136 HRESULT
02137 CRTCOutgoingDlg::StateStartT120(RTC_T120_APPLET tType)
02138 {
02139   HRESULT hr = S_OK;
02140
02141   _ASSERTE(NULL != m_pIRTCClient);
02142
02143   hr = m_pIRTCClient->StartT120Applet(tType);
02144
02145   if (FAILED(hr))
02146   {
02147     LOGMSGERROR(_T("IRTCClient::StartT120Applet Failed 0x%x"), hr);
02148     return hr;
02149   }
02150
02151   //
02152   // We dont have the Media Capability by Default
02153   // so if we are in connected state we add the stream
02154   //
02155
02156   if (m_pIRTCSession != NULL)
02157   {
02158     RTC_SESSION_STATE SessionState;
02159
02160     hr = m_pIRTCSession->get_State(&SessionState);
02161
02162     if (FAILED(hr))
02163     {
02164       LOGMSGERROR(_T("IRTCSession::get_State Failed 0x%x"), hr);
02165       return hr;
02166     }
02167
02168
02169     if (RTCSS_CONNECTED  == SessionState)
02170     {
02171
02172       hr = m_pIRTCSession->AddStream(RTCMT_T120_SENDRECV, 200);
02173
02174       if (FAILED(hr))
02175       {
02176
02177         LOGMSGERROR(_T("IRTCSession::AddStream(T120) Failed 0x%x"), hr);
02178         return hr;
02179       }
02180     }
02181
02182   }
02183
02184   return hr;
02185 }
02186
02187 /**********************************************************
02188 //@StateStartTunning
02189 //
02190 //@Description
02191 //  Starts the Tunning Wizard
02192 //
02193 //@Args In:     None
02194 //@Args Out:    None
02195 //
02196 //
02197 //*********************************************************/
02198 HRESULT
02199 CRTCOutgoingDlg::StateStartTunning()
02200 {
02201   HRESULT hr = S_OK;
02202
02203   _ASSERTE(NULL != m_pIRTCClient);
02204
02205   //
02206   // Send Parent Window
02207   //
02208
02209   hr = m_pIRTCClient->InvokeTuningWizard( (OAHWND) m_hWnd);
02210
02211   if (FAILED(hr))
02212   {
02213     LOGMSGERROR(_T("IRTCClient::InvokeTuningWizard Failed 0x%x"), hr);
02214     return hr;
02215   }
02216
02217   return hr;
02218
02219 }
02220 /**********************************************************
02221 //@QueryInterface
02222 //
02223 //@Description
02224 //
02225 //  QI
02226 //
02227 //@Args In:     None
02228 //@Args Out:    None
02229 //
02230 //
02231 //*********************************************************/
02232
02233 HRESULT
02234 CRTCOutgoingDlg::QueryInterface(REFIID iid,
02235                    void **ppvObject)
02236 {
02237   if(iid == IID_IRTCEventNotification)
02238   {
02239
02240     *ppvObject = static_cast<IRTCEventNotification *> (this);
02241     AddRef();
02242     return S_OK;
02243   }
02244
02245
02246   if(iid == IID_IUnknown)
02247   {
02248
02249     *ppvObject = static_cast<IUnknown *> (this);
02250     AddRef();
02251     return S_OK;
02252   }
02253
02254   else
02255   {
02256      *ppvObject = NULL;
02257      return E_NOINTERFACE;
02258   }
02259
02260   return S_OK;
02261 }
02262
02263
02264 /**********************************************************
02265 //@ RTCEventNotification Interface Implementations
02266 //*********************************************************/
02267
02268 /**********************************************************
02269 //@AddRef
02270 //
02271 //@Description
02272 //
02273 //  Ref Count
02274 //
02275 //@Args In:     None
02276 //@Args Out:    None
02277 //
02278 //
02279 //*********************************************************/
02280
02281 ULONG
02282 CRTCOutgoingDlg::AddRef()
02283 {
02284
02285   ULONG ulrefCount = InterlockedIncrement(&m_dwRefCount);
02286   return ulrefCount;
02287 }
02288
02289
02290 /**********************************************************
02291 //@Release
02292 //
02293 //@Description
02294 //
02295 //  object release
02296 //
02297 //@Args In:     None
02298 //@Args Out:    None
02299 //
02300 //
02301 //*********************************************************/
02302
02303 ULONG
02304 CRTCOutgoingDlg::Release()
02305 {
02306
02307   ULONG ulrefCount = InterlockedDecrement(&m_dwRefCount);
02308
02309
02310   if(0 == ulrefCount)
02311   {
02312     delete this;
02313   }
02314
02315   return ulrefCount;
02316 }
02317
02318 /**********************************************************
02319 //@Event
02320 //
02321 //@Description
02322 //  RTC CallBack for Events, the messages are
02323 //  posted to the thread message pump
02324 //
02325 //
02326 //
02327 //@Args In:     RTC_EVENT , IDispatch
02328 //@Args Out:    HRESULT
02329 //
02330 //
02331 //*********************************************************/
02332
02333 HRESULT
02334 STDMETHODCALLTYPE
02335 CRTCOutgoingDlg::Event(
02336               RTC_EVENT RTCEvent,
02337             IDispatch * pEvent
02338             )
02339
02340 {
02341
02342   HRESULT hr  = S_OK;
02343
02344   if (NULL != pEvent)
02345   {
02346
02347     switch (RTCEvent)
02348     {
02349
02350        case RTCE_CLIENT                    :
02351       hr =  RTCClientEvent(pEvent);
02352       break;
02353       case RTCE_SESSION_STATE_CHANGE      :
02354       hr =  RTCSessionStateEvent(pEvent);
02355       break;
02356       case RTCE_MEDIA                     :
02357       hr =    RTCMediaEvent(pEvent);
02358       break;
02359       default:  break;
02360     }
02361
02362
02363   }
02364
02365     return hr;
02366 }
02367
02368
02369 /**********************************************************
02370 //@ RTC Event Parsers
02371 //*********************************************************/
02372
02373 /**********************************************************
02374 //@RTCClientEvent
02375 //
02376 //@Description
02377 //
02378 // No Parsing
02379 //
02380 //@Args In:
02381 //@Args Out:
02382 //
02383 //
02384 //*********************************************************/
02385
02386 HRESULT
02387 CRTCOutgoingDlg::RTCClientEvent(IDispatch *pIDispatch)
02388 {
02389   HRESULT               hr            = S_OK;
02390   IRTCClientEvent      *pIClientEvent = NULL;
02391   RTC_CLIENT_EVENT_TYPE EventType;
02392
02393   hr = pIDispatch->QueryInterface(IID_IRTCClientEvent,
02394                   reinterpret_cast<void**> (&pIClientEvent)
02395                   );
02396
02397   if (FAILED(hr))
02398   {
02399     LOGMSGERROR(_T("IDispatch::QueryInterface(IRTCClientEvent) Failed 0x%x"),
02400       hr);
02401     return hr;
02402   }
02403
02404   //
02405   // Getting the Session Interface
02406   //
02407
02408   hr = pIClientEvent->get_EventType(&EventType);
02409
02410   if (FAILED(hr))
02411   {
02412     LOGMSGERROR(_T("IRTCClientEvent::get_EventType Failed 0x%x"), hr);
02413
02414     pIClientEvent->Release();
02415     pIClientEvent = NULL;
02416     return hr;
02417   }
02418
02419
02420   if (RTCCET_ASYNC_CLEANUP_DONE  == EventType)
02421   {
02422     //
02423     // When the WndProc gets this message we can
02424     // destroy the window
02425     //
02426
02427     DBLOGGER(_T("Final Exit ... ASYNC_CLEANUP_DONE\n"));
02428
02429     SendMessage(WM_RTCCORE_EVENT, (WPARAM) EventType, (LPARAM) NULL);
02430   }
02431
02432   if (NULL != pIClientEvent)
02433   {
02434     pIClientEvent->Release();
02435     pIClientEvent = NULL;
02436
02437   }
02438   return hr;
02439 }
02440
02441
02442 /**********************************************************
02443 //@RTCSessionStateEvent
02444 //
02445 //@Description
02446 //
02447 //  Destructor
02448 //
02449 //@Args In:
02450 //@Args Out:
02451 //
02452 //
02453 //*********************************************************/
02454 HRESULT
02455 CRTCOutgoingDlg::RTCSessionStateEvent(IDispatch *pIDispatch)
02456 {
02457   HRESULT hr                                  = S_OK;
02458   IRTCSessionStateChangeEvent *pISessionState = NULL;
02459   RTC_SESSION_STATE SessionState;
02460
02461
02462   hr = pIDispatch->QueryInterface(IID_IRTCSessionStateChangeEvent,
02463                   reinterpret_cast<void**> (&pISessionState)
02464                   );
02465
02466   if (FAILED(hr))
02467   {
02468
02469     LOGMSGERROR(_T("IDispatch::QueryInterface(IRTCSessionStateChangeEvent) Failed 0x%x"),
02470       hr);
02471     return hr;
02472   }
02473
02474
02475   hr = pISessionState->get_State(&SessionState);
02476
02477   if (FAILED(hr))
02478   {
02479     LOGMSGERROR(_T("IRTCSessionStateChangeEvent::get_State Failed 0x%x"), hr);
02480
02481     pISessionState->Release();
02482     pISessionState = NULL;
02483     return hr;
02484   }
02485
02486
02487   switch(SessionState)
02488   {
02489   case RTCSS_IDLE: break;
02490   case RTCSS_INCOMING:
02491   {
02492     m_ctrlEditStatus.SetWindowText(_T("Incoming Call..."));
02493     break;
02494   }
02495   case RTCSS_ANSWERING:
02496     m_ctrlEditStatus.SetWindowText(_T("Answering ..."));
02497     break;
02498   case RTCSS_INPROGRESS:
02499     m_ctrlEditStatus.SetWindowText(_T("In Progress ..."));
02500     break;
02501   case RTCSS_CONNECTED :
02502     {
02503       VARIANT_BOOL  fCanAdd  = VARIANT_FALSE;
02504
02505       StateConnectIDC(VARIANT_FALSE);
02506       StateDisconnectIDC(VARIANT_TRUE);
02507       m_ctrlEditStatus.SetWindowText(_T("Connected ..."));
02508
02509       //
02510       // Check if you can add participants to the session
02511       // enable the add participant button
02512       //
02513       hr = m_pIRTCSession->get_CanAddParticipants(&fCanAdd);
02514
02515       if (FAILED(hr))
02516       {
02517         LOGMSGERROR(_T("IRTCSessionStateChangeEvent::get_State Failed 0x%x"), hr);
02518         return hr;
02519       }
02520       else if (VARIANT_TRUE == fCanAdd)
02521       {
02522         StateAddPartyIDC(VARIANT_TRUE);
02523
02524         StateConnectIDCVisible(VARIANT_FALSE);
02525         StateAddPartyIDCVisible(VARIANT_TRUE);
02526
02527         m_editDURI.SetWindowText(_T(""));
02528       }
02529       break;
02530     }
02531   case RTCSS_DISCONNECTED:
02532     {
02533
02534       //
02535       // Disabling call-control related UI
02536       //
02537
02538       StateDisconnectIDC(VARIANT_FALSE);
02539       StateConnectIDC(VARIANT_TRUE);
02540       StateConnectIDCVisible(VARIANT_TRUE);
02541       StatePartyListIDC(VARIANT_FALSE);
02542       StateTuneIDC(VARIANT_TRUE);
02543
02544       StateAddPartyIDC(VARIANT_FALSE);
02545       StateRemovePartyIDC(VARIANT_FALSE);
02546
02547
02548       StateAddPartyIDCVisible(VARIANT_FALSE);
02549
02550       //
02551       // Removing All Participants from the listbox
02552       //
02553
02554       for (INT lIndex = 0; lIndex < m_lbParties.GetCount(); lIndex++)
02555       {
02556         m_lbParties.DeleteString(lIndex);
02557       }
02558
02559       m_ctrlEditStatus.SetWindowText(_T("Disconnected ..."));
02560       m_ctrlEditStatus.SetWindowText(_T("Ready ..."));
02561
02562       //
02563       // Releasing the Session Interface
02564       //
02565
02566       m_pIRTCSession->Release();
02567       m_pIRTCSession = NULL;
02568
02569       break;
02570     }
02571   default :
02572     {
02573       pISessionState->Release();
02574       pISessionState = NULL;
02575       return E_UNEXPECTED;
02576     }
02577
02578   }
02579
02580   if (NULL != pISessionState)
02581   {
02582
02583     pISessionState->Release();
02584     pISessionState = NULL;
02585
02586   }
02587
02588   return hr;
02589 }
02590
02591 /**********************************************************
02592 //@RTCMediaEvent
02593 //
02594 //@Description
02595 //
02596 //  Parser for Media Event
02597 //
02598 //  here we start the video window in a specific
02599 //  window location of the dialog box, we can
02600 //  only do this if the video stream has started
02601 //  if an application doesnt care about setting
02602 //  the video window coordinated you can get the
02603 //  video window and put_AutoShow(TRUE) , this will
02604 //  make the video window automatically visible when
02605 //  the stream has started.
02606 //
02607 //
02608 //@Args In:     IDispatch Event Interface
02609 //@Args Out:    HRESULT
02610 //
02611 //
02612 //*********************************************************/
02613
02614 HRESULT
02615 CRTCOutgoingDlg::RTCMediaEvent(IDispatch *pIDispatch)
02616 {
02617   HRESULT hr                          = S_OK;
02618   IRTCMediaEvent        *pIMediaEvent = NULL;
02619   LONG                   lMediaType   = 0;
02620   HWND                   hwdVideoRecv , hwdVideoSend;
02621   RTC_MEDIA_EVENT_TYPE   EventType;
02622
02623   hr = pIDispatch->QueryInterface(IID_IRTCMediaEvent,
02624                   reinterpret_cast<void**> (&pIMediaEvent)
02625                   );
02626
02627   if (FAILED(hr))
02628   {
02629
02630     LOGMSGERROR(_T("IDispatch::QueryInterface(IRTCMediaEvent) Failed 0x%x"), hr);
02631     return hr;
02632   }
02633
02634   pIMediaEvent->get_MediaType(&lMediaType);
02635   pIMediaEvent->get_EventType(&EventType);
02636
02637   if ( (lMediaType == RTCMT_VIDEO_RECEIVE) && (EventType == RTCMET_STARTED) )
02638   {
02639
02640        RECT    rectPos;
02641
02642        hr = m_pIRTCClient->get_IVideoWindow(  RTCVD_RECEIVE , &m_pIRecvVideo);
02643
02644       if (SUCCEEDED(hr))
02645       {
02646         CString cstrText;
02647
02648         hr = m_pIRecvVideo->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
02649
02650         if(FAILED(hr))
02651         {
02652           LOGMSGERROR(_T("IVideoWindow::put_WindowStyle() Failed 0x%x"), hr);
02653
02654           pIMediaEvent->Release();
02655           pIMediaEvent = NULL;
02656
02657           return hr;
02658         }
02659
02660         hr = m_pIRecvVideo->put_Owner((OAHWND) m_hWnd);
02661
02662         if(FAILED(hr))
02663         {
02664
02665           LOGMSGERROR(_T("IVideoWindow::put_Owner() Failed 0x%x"), hr);
02666
02667           pIMediaEvent->Release();
02668           pIMediaEvent = NULL;
02669
02670           return hr;
02671         }
02672
02673
02674         GetDlgItem( IDC_VRECVS, &hwdVideoRecv );
02675
02676         ::GetClientRect(hwdVideoRecv, &rectPos);
02677
02678             hr = m_pIRecvVideo->SetWindowPosition(
02679           rectPos.left   + RECVVID_LEFT,
02680         rectPos.top    + RECVVID_TOP,
02681         rectPos.right  - RECVVID_RIGHT,
02682         rectPos.bottom - RECVVID_BOTTOM
02683         );
02684
02685         if(FAILED(hr))
02686         {
02687           LOGMSGERROR(_T("IVideoWindow::SetWindowPosition() Failed 0x%x"), hr);
02688
02689           pIMediaEvent->Release();
02690           pIMediaEvent = NULL;
02691
02692           return hr;
02693         }
02694
02695         hr = m_pIRecvVideo->put_Visible(TRUE);
02696
02697         if (FAILED(hr))
02698         {
02699           LOGMSGERROR(_T("IVideoWindow::put_Visible Failed 0x%x"), hr);
02700
02701           pIMediaEvent->Release();
02702           pIMediaEvent = NULL;
02703
02704           return hr;
02705         }
02706
02707       }
02708
02709   }
02710
02711   else if ( ( lMediaType == RTCMT_VIDEO_RECEIVE) && (EventType == RTCMET_STOPPED))
02712   {
02713
02714     //
02715     // we must put_Visible false and set the owner
02716     // as null See DShow IVideoWindow SDK
02717     // NOTE: should not close window without releasing video
02718     // or not removing handler ownership from video window.
02719     //
02720
02721     m_pIRecvVideo->put_Visible(FALSE);
02722     m_pIRecvVideo->put_Owner(NULL);
02723
02724
02725     m_pIRecvVideo->Release();
02726     m_pIRecvVideo = NULL;
02727
02728   }
02729
02730   else if ( (lMediaType == RTCMT_VIDEO_SEND) &&  (EventType == RTCMET_STARTED))
02731   {
02732
02733        RECT    rectPos;
02734
02735        hr = m_pIRTCClient->get_IVideoWindow(  RTCVD_PREVIEW , &m_pIPrevVideo);
02736
02737       if (SUCCEEDED(hr))
02738       {
02739         CString cstrText;
02740
02741         hr = m_pIPrevVideo->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
02742
02743         if(FAILED(hr))
02744         {
02745           LOGMSGERROR(_T("IVideoWindow::put_WindowStyle() Failed 0x%x"), hr);
02746
02747           pIMediaEvent->Release();
02748           pIMediaEvent = NULL;
02749
02750           return hr;
02751         }
02752
02753         hr = m_pIPrevVideo->put_Owner((OAHWND) m_hWnd);
02754
02755         if(FAILED(hr))
02756         {
02757
02758           LOGMSGERROR(_T("IVideoWindow::put_Owner() Failed 0x%x"), hr);
02759
02760           pIMediaEvent->Release();
02761           pIMediaEvent = NULL;
02762           return hr;
02763         }
02764
02765         GetDlgItem( IDC_VSENDS , &hwdVideoSend );
02766
02767         ::GetClientRect(hwdVideoSend, &rectPos);
02768
02769             hr = m_pIPrevVideo->SetWindowPosition(
02770             rectPos.left + PREVVID_LEFT,
02771         rectPos.top  + PREVVID_TOP,
02772         rectPos.right - PREVVID_RIGHT,
02773         rectPos.bottom - PREVVID_BOTTOM);
02774
02775
02776         if(FAILED(hr))
02777         {
02778           LOGMSGERROR(_T("IVideoWindow::SetWindowPosition() Failed 0x%x"), hr);
02779
02780           pIMediaEvent->Release();
02781           pIMediaEvent = NULL;
02782           return hr;
02783         }
02784
02785         hr = m_pIPrevVideo->put_Visible(TRUE);
02786
02787         if (FAILED(hr))
02788         {
02789           LOGMSGERROR(_T("IVideoWindow::put_Visible Failed 0x%x"), hr);
02790
02791           pIMediaEvent->Release();
02792           pIMediaEvent = NULL;
02793           return hr;
02794         }
02795
02796       }
02797
02798   }
02799
02800   else if ( ( lMediaType == RTCMT_VIDEO_SEND) &&
02801      (EventType == RTCMET_STOPPED))
02802   {
02803
02804     //
02805     // we must put_Visible false and set the owner
02806     // as null See DShow IVideoWindow SDK
02807     // NOTE: should not close window without releasing video
02808     // or not removing handler ownership from video window.
02809     //
02810
02811     m_pIPrevVideo->put_Visible(FALSE);
02812     m_pIPrevVideo->put_Owner(NULL);
02813
02814     m_pIPrevVideo->Release();
02815     m_pIPrevVideo = NULL;
02816
02817
02818   }
02819
02820
02821   if (NULL != pIMediaEvent)
02822   {
02823
02824     pIMediaEvent->Release();
02825     pIMediaEvent = NULL;
02826
02827   }
02828
02829   return hr;
02830 }
02831
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/land.h Source File

  • SysMgmt
  • MMC
  • CutCopy

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035 private:
00036     enum { IDM_NEW_LAND = 2 };
00037
00038     // {2974380E-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • Nameext

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030   static TCHAR error[64];
00031
00032   switch (verb) {
00033     case MMC_VERB_NONE:
00034     return _T("NONE");
00035     case MMC_VERB_OPEN:
00036     return _T("OPEN");
00037     case MMC_VERB_COPY:
00038     return _T("COPY");
00039     case MMC_VERB_PASTE:
00040     return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042     return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044     return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046     return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048     return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050     return _T("PRINT");
00051     case MMC_VERB_CUT:
00052     return _T("CUT");
00053   default:
00054     wsprintf(error, _T("Unknown verb id %d"), verb);
00055     return error;
00056   }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061         IComponentData *pCompData,
00062         IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064         LPARAM arg,
00065         LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069   TCHAR message[cchMessage] = {0};
00070
00071   if (bComponentData == TRUE)
00072     OutputDebugString(_T("IComponentData::Notify( "));
00073   else
00074     OutputDebugString(_T("IComponent::Notify( "));
00075
00076   wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077   OutputDebugString(message);
00078
00079     switch (event)  {
00080     case MMCN_ACTIVATE:
00081       wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082       break;
00083
00084     case MMCN_ADD_IMAGES:
00085       wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086       break;
00087
00088     case MMCN_BTN_CLICK:
00089       wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090       break;
00091
00092     case MMCN_COLUMN_CLICK:
00093       wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,   param);
00094       break;
00095
00096     case MMCN_COLUMNS_CHANGED:
00097       wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098       break;
00099
00100     case MMCN_CONTEXTHELP:
00101       wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102       break;
00103
00104     case MMCN_CONTEXTMENU:
00105       wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106       break;
00107
00108     case MMCN_CUTORMOVE:
00109       wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110       break;
00111
00112     case MMCN_DBLCLICK:
00113       wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114       break;
00115
00116     case MMCN_DELETE:
00117       wsprintf(message, _T("MMCN_DELETE\n"));
00118       break;
00119
00120     case MMCN_DESELECT_ALL:
00121       wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122       break;
00123
00124     case MMCN_EXPAND:
00125       wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126       break;
00127
00128     case MMCN_EXPANDSYNC:
00129       wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130       break;
00131
00132     case MMCN_FILTERBTN_CLICK:
00133       wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134       break;
00135
00136     case MMCN_FILTER_CHANGE:
00137       wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138       break;
00139
00140     case MMCN_HELP:
00141       wsprintf(message, _T("MMCN_HELP\n"));
00142       break;
00143
00144     case MMCN_INITOCX:
00145       wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146       break;
00147
00148     case MMCN_LISTPAD:
00149       wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150       break;
00151
00152     case MMCN_MENU_BTNCLICK:
00153       wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154       break;
00155
00156     case MMCN_MINIMIZED:
00157       wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158       break;
00159
00160     case MMCN_PASTE:
00161       wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162       break;
00163
00164     case MMCN_PRELOAD:
00165       wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166       break;
00167
00168     case MMCN_PRINT:
00169       wsprintf(message, _T("MMCN_PRINT\n"));
00170       break;
00171
00172     case MMCN_PROPERTY_CHANGE:
00173       wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174       break;
00175
00176     case MMCN_QUERY_PASTE:
00177       wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178       break;
00179
00180     case MMCN_REFRESH:
00181       wsprintf(message, _T("MMCN_REFRESH\n"));
00182       break;
00183
00184     case MMCN_REMOVE_CHILDREN:
00185       wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186       break;
00187
00188     case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192       StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193       break;
00194
00195     case MMCN_RESTORE_VIEW:
00196       wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197       break;
00198
00199     case MMCN_SELECT:
00200       wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201       break;
00202
00203     case MMCN_SHOW:
00204       wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205       break;
00206
00207     case MMCN_SNAPINHELP:
00208       wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209       break;
00210
00211     case MMCN_VIEW_CHANGE:
00212       wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213       break;
00214   }
00215
00216   if (message[0] != 0)
00217     OutputDebugString(message);
00218   else
00219     OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222   return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/Utils.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

Utils.h

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: Utils.h
00006  * ---------- [ Header Definition File]
00007  *
00008  *
00009  * @Description:
00010  * -------------
00011  * Utilities for logging Error Messages in the debugger
00012  * or in a Popup message box
00013  *
00014  *
00015  ******************************************************/
00016
00017 #ifndef __RTCOUTGOINGUTILS__H__
00018 #define __RTCOUTGOINGUTILS__H__
00019
00020
00021 #define FREE_BSTR_IF(bstrVal) \
00022   { if (NULL != bstrVal) { SysFreeString(bstrVal); bstrVal = NULL ;}  else bstrVal = NULL; }
00023
00024
00025
00026
00027
00028 #ifdef __cplusplus
00029 //
00030 // for C Var length parameters
00031 //
00032 extern "C" {
00033 #endif
00034
00035 int  DBLOGGER(TCHAR *str, ...) ;
00036 void LOGMSGERROR(TCHAR *str, ...);
00037 void LOGMSG(TCHAR *str, ...);
00038
00039 #ifdef __cplusplus
00040 }
00041 #endif
00042
00043
00044
00045 #endif
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/basesnap.h Source File

  • SysMgmt
  • MMC
  • Multisel

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/c_draw/StdAfx.Cpp Source File

  • NetDS
  • MessageQueuing
  • c_draw

StdAfx.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // stdafx.cpp : source file that includes just the standard includes
00013 //  disdraw.pch will be the pre-compiled header
00014 //  stdafx.obj will contain the pre-compiled type information
00015
00016 #include "stdafx.h"
00017
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_OPEN_FILE Member List

This is the complete list of members for _OPEN_FILE, including all inherited members.
hFile | _OPEN_FILE
nHits | _OPEN_FILE
nRefs | _OPEN_FILE
pNext | _OPEN_FILE
rgchFile | _OPEN_FILE
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Guid.c Source File

  • NetDS
  • SyncMgr
  • SyncDir

Guid.c

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #pragma data_seg(".text")
00013 #define INITGUID
00014 #include <objbase.h>
00015 #include <initguid.h>
00016
00017 #include <mobsync.h>
00018 #include "guid.h"
00019
00020
00021 #pragma data_seg()
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat2/applet.h Source File

  • Web
  • NetMeeting
  • NMChat2

applet.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       APPLET.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1999-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #ifndef _APPLET_H_
00016 #define _APPLET_H_
00017
00018 //****************************************************************************
00019 //
00020 // CLASS CApplet
00021 //
00022 //****************************************************************************
00023
00024 class CApplet : public CRefCount, public IAppletNotify
00025 {
00026 public:
00027
00028   CApplet(IApplet *pIApplet);
00029   ~CApplet(void);
00030
00031   // IUnknown methods
00032   ULONG STDMETHODCALLTYPE AddRef(void);
00033   ULONG STDMETHODCALLTYPE Release(void);
00034   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void * *ppvObj);
00035
00036   // IAppletNotify
00037     HRESULT STDMETHODCALLTYPE PermitToJoinSessionIndication(
00038                     AppletConfID   nConfID,
00039                     BOOL           fPermissionGranted);
00040     HRESULT STDMETHODCALLTYPE AutoJoinSessionIndication(
00041                     IAppletSession    *pSession,
00042                     HRESULT            hrResult,
00043                     AppletUserID       uidMyself,
00044                     AppletNodeID       nidMyself,
00045                     AppletSessionID    sidMyself,
00046                     AppletEntityID     eidMyself,
00047                     ULONG              cDynamicChannels,
00048                     AppletChannelID aDynamicChannels[]);
00049
00050     HRESULT Advise(void) { return m_pIApplet->Advise((IAppletNotify *) this, &m_dwCookie); }
00051     HRESULT UnAdvise(void) { return m_pIApplet->UnAdvise(m_dwCookie); }
00052
00053 private:
00054
00055     IApplet            *m_pIApplet;
00056     DWORD               m_dwCookie;
00057 };
00058
00059 extern CApplet *g_pApplet;
00060 HRESULT InitApplet(void);
00061 void FreeApplet(void);
00062
00063 #endif // _APPLET_H_
00064
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/Font.Cxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

Font.Cxx

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <windowsx.h>
00003 #include <commdlg.h>
00004 #include <string.h>
00005 #include <memory.h>
00006 #include "app.h"
00007
00008 #include "font.hxx"
00009 //+--------------------------------------------------------
00010 // Class:       CFont
00011 //
00012 // Purpose:     Abstract a font
00013 //
00014 // History:     22-Jan-1993     asmusf  created
00015 //----------------------------------------------------------
00016 CFont::CFont(HFONT hfont)
00017 {
00018     _hfont = hfont;
00019     _fDel = FALSE;       // owned elsewhere
00020 }
00021
00022 CFont::CFont(TCHAR *szFace, int iHeight, BOOL fBold, BOOL fItalic, BOOL fUnder)
00023 {
00024     LOGFONT lf;
00025     _fDel = FALSE;      // not initialized
00026
00027     memset(&lf,0,sizeof (LOGFONT));
00028     // rude but effective: truncate
00029     if( lstrlen( szFace ) > (sizeof(lf.lfFaceName)/sizeof(TCHAR)) )
00030     {
00031         szFace[sizeof(lf.lfFaceName)/sizeof(TCHAR)] = TEXT('\0');
00032     }
00033     lstrcpyn(lf.lfFaceName, szFace, sizeof(lf.lfFaceName)/sizeof(TCHAR));
00034
00035     lf.lfHeight = iHeight * 20;         // twips internal, points in API
00036
00037     if( fBold )
00038     {
00039         lf.lfWeight = FW_BOLD;
00040     }
00041     lf.lfItalic = (BYTE)fItalic;
00042     lf.lfUnderline = (BYTE)fUnder;
00043     Create(lf);
00044 }
00045
00046 BOOL CFont::Create(LOGFONT &lf)
00047 {
00048     if( _fDel )
00049     {
00050         DeleteObject(_hfont);
00051         _fDel = FALSE;
00052     }
00053     if( _hfont = CreateFontIndirect(&lf) )
00054     {
00055         _fDel = TRUE;
00056         return TRUE;
00057     }
00058     return FALSE;
00059 }
00060
00061 CFont::~CFont()
00062 {
00063     if( _fDel )
00064     {
00065         DeleteObject(_hfont);
00066     }
00067 }
00068
00069 BOOL CFont::Update(int iHeight, BOOL fBold)
00070 {
00071     LOGFONT lf;
00072     GetObject(_hfont, sizeof(LOGFONT), &lf);
00073     lf.lfWeight = (fBold ? FW_BOLD : FW_NORMAL );
00074
00075     lf.lfHeight = iHeight * 20;         // twips internal, points in API
00076
00077
00078     return Create(lf);
00079 }
00080
00081
00082 BOOL CFont::Choose(HWND hwnd)
00083 {
00084     CHOOSEFONT cf ;
00085     LOGFONT lf ;
00086
00087     GetObject(_hfont, sizeof(LOGFONT), &lf);
00088
00089
00090     // match from TWIPS to LOGPIXELS used in common Dialog
00091     CScreenCanvas canvas(NULL);
00092     lf.lfHeight = MulDiv(lf.lfHeight,GetDeviceCaps(canvas, LOGPIXELSY),INCH1);
00093
00094     lf.lfCharSet = ANSI_CHARSET;
00095
00096     cf.lStructSize      = sizeof (CHOOSEFONT) ;
00097     cf.hwndOwner        = hwnd ;
00098     cf.hDC              = NULL ;
00099     cf.lpLogFont        = &lf ;
00100     cf.iPointSize       = 0 ;
00101     cf.Flags            = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS
00102                                                  | CF_EFFECTS ;
00103     cf.rgbColors        = 0L ;
00104     cf.lCustData        = 0L ;
00105     cf.lpfnHook         = NULL ;
00106     cf.lpTemplateName   = NULL ;
00107     cf.hInstance        = NULL ;
00108     cf.lpszStyle        = NULL ;
00109     cf.nFontType        = 0 ;               // Returned from ChooseFont
00110     cf.nSizeMin         = 0 ;
00111     cf.nSizeMax         = 0 ;
00112
00113     if( !ChooseFont (&cf) )
00114     {
00115         return FALSE;
00116     }
00117 //    MessageBox( hwnd, lf.lfFaceName, TEXT("Font Chosen"), MB_OK );
00118
00119     // adjust back to using TWIPS
00120     lf.lfHeight = MulDiv(lf.lfHeight,INCH1,GetDeviceCaps(canvas, LOGPIXELSY));
00121     lf.lfWidth=0;               // font mapper knows best
00122
00123     // create the font
00124     return Create(lf);
00125 }
00126
00127 
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/CDTest.h Source File

  • WinUI
  • CommDlg
  • CDTest

CDTest.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 #define UMSG_DECREMENTDLGCOUNT (WM_USER+1)
00007
00008
00009
00010 HINSTANCE hInst;
00011
00012 BOOL InitApplication(HANDLE);
00013 BOOL InitInstance(HANDLE, int);
00014 LRESULT APIENTRY MainWndProc(HWND, UINT, WPARAM, LPARAM);
00015 void HandleTheCommand(HWND, WPARAM, LPARAM) ;
00016 INT_PTR APIENTRY AboutProc(HWND, UINT, WPARAM, LPARAM) ;
00017
00018 #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
00019
00020 TCHAR szTemp[100] ;
00021
00022 TCHAR szShortFilter[5] ;
00023 TCHAR szLongFilter[5] ;
00024 TCHAR szPointerFilter[5] ;
00025
00026 #define IDM_COLOR   100
00027 #define IDM_FONT    101
00028 #define IDM_FIND    102
00029 #define IDM_TITLE   103
00030 #define IDM_OPEN    104
00031 #define IDM_SAVE    105
00032 #define IDM_PRINT   106
00033 #define IDM_REPLACE 107
00034 #define IDM_EXIT    108
00035 #define IDM_HEXMODE 200
00036 #define IDM_DECIMALMODE 201
00037 #define IDM_MULTITHREAD2 300
00038 #define IDM_ABOUT   301
00039
00040
00041 UINT nFindMsg ;
00042 UINT nOpenShareVMsg ;
00043 UINT nHelpMessage ;
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tag_MMC_VERSION_INFO Member List

This is the complete list of members for _tag_MMC_VERSION_INFO, including all inherited members.
nMajor | _tag_MMC_VERSION_INFO
nMinor | _tag_MMC_VERSION_INFO
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ICONIMAGE Member List

This is the complete list of members for ICONIMAGE, including all inherited members.
Colors | ICONIMAGE
dwNumBytes | ICONIMAGE
Height | ICONIMAGE
pAND | ICONIMAGE
pbi | ICONIMAGE
pBits | ICONIMAGE
pXOR | ICONIMAGE
Width | ICONIMAGE
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/StdAfx.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

StdAfx.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // stdafx.h : include file for standard system include files,
00013 //  or project specific include files that are used frequently, but
00014 //      are changed infrequently
00015 //
00016
00017
00018 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00019
00020 #include <afxwin.h>         // MFC core and standard components
00021 #include <afxext.h>         // MFC extensions
00022 #ifndef _AFX_NO_AFXCMN_SUPPORT
00023 #include <afxcmn.h>     // MFC support for Windows 95 Common Controls
00024 #endif // _AFX_NO_AFXCMN_SUPPORT
00025
00026
00027 #include <afxole.h>
00028 #include <afxtempl.h>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/registry.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

registry.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef __Registry_H__
00015 #define __Registry_H__
00016
00017 #include <tchar.h>
00018
00019 // This function will register a component in the Registry.
00020 // The component calls this function from its DllRegisterServer function.
00021 HRESULT RegisterServer( HMODULE hModule,
00022                         const CLSID& clsid,
00023                         const TCHAR* szFriendlyName) ;
00024
00025 // This function will unregister a component.  Components
00026 // call this function from their DllUnregisterServer function.
00027 HRESULT UnregisterServer( const CLSID& clsid ) ;
00028
00029
00030 // This function will register a Snap-In component.  Components
00031 // call this function from their DllRegisterServer function.
00032 HRESULT RegisterSnapin( const CLSID& clsid,            // Class ID
00033                         const TCHAR* szNameString,     // NameString
00034                         const CLSID& clsidAbout,       // Class Id for About Class
00035                         const BOOL fSupportExtensions = FALSE
00036                       );
00037
00038 HRESULT UnregisterSnapin( const CLSID& clsid );        // Class ID
00039
00040 #endif //__Registry_H__
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/resource.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by PropPageX.rc
00004 //
00005 #define IDD_VFILE_PPAGE0                111
00006 #define IDD_PPAGE0                      111
00007 #define IDC_ATTR_COMPRESSED             1010
00008 #define IDC_ATTR_ENCRYPTED              1011
00009
00010 // Next default values for new objects
00011 //
00012 #ifdef APSTUDIO_INVOKED
00013 #ifndef APSTUDIO_READONLY_SYMBOLS
00014 #define _APS_NEXT_RESOURCE_VALUE        113
00015 #define _APS_NEXT_COMMAND_VALUE         40001
00016 #define _APS_NEXT_CONTROL_VALUE         1011
00017 #define _APS_NEXT_SYMED_VALUE           101
00018 #endif
00019 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/Xmit/Xmitp.c Source File

  • NetDS
  • RPC
  • Data
  • Xmit

Xmitp.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                          xmit Example
00005
00006     FILE:       xmitp.c
00007
00008     PURPOSE:    Remote procedures that are linked with the server
00009                 side of RPC distributed application
00010
00011     FUNCTIONS:  ModifyListProc() - changes the doubly-linked list
00012                 Shutdown() - shuts down the server side
00013
00014     COMMENTS:   Related to xmits.c
00015
00016 ****************************************************************************/
00017
00018 #include <stdlib.h>
00019 #include <stdio.h>
00020 #include "xmit.h"    // header file generated by MIDL compiler
00021
00022
00023 /****************************************************************************
00024
00025 Function:   ModifyListProc
00026
00027 Parameters: pFirst : Pointer to the head of a doubly-linked list.
00028
00029 Returns:    none
00030
00031 Purpose:    Display the list passed to the function.
00032             For each element in the list, add another element.
00033             Display the modified list.
00034
00035 Comments:   This sample is meant to demonstrate a typical use of the
00036             transmit_as attribute:  A complex data structure is simplified
00037             for transmission over the network, restored on the server,
00038             then manipulated by the remote function on the server.
00039             The modified data is returned to the client.
00040
00041             Calls InsertNewNode(param1, param2), a utility routine
00042             in xmits.c that creates a new node, assigns to it the
00043             value param1, and inserts it into the list after param2.
00044
00045 ****************************************************************************/
00046
00047 DOUBLE_LINK_TYPE * InsertNewNode(short sValue, DOUBLE_LINK_TYPE * pPrevious);
00048
00049 void ModifyListProc(DOUBLE_LINK_TYPE * pFirst)
00050 {
00051     DOUBLE_LINK_TYPE * pList = pFirst;
00052     short newNumber;
00053
00054     printf("ModifyListProc: Display contents of doubly linked list:\n");
00055     while (pList != NULL) {
00056          printf("pList @0x%p = %d, Next = 0x%p\n",
00057                 pList, pList->sNumber, pList->pNext);
00058          pList = pList->pNext;
00059     }
00060
00061     printf("ModifyListProc: Add one node for every node in tree\n");
00062     for (pList = pFirst; pList != NULL; pList = pList->pNext) {
00063         newNumber = pList->sNumber + 1;
00064         pList = InsertNewNode(newNumber, pList);
00065     }
00066
00067     printf("ModifyListProc: Display modified contents of doubly linked list:\n");
00068     for (pList = pFirst; pList != NULL; pList = pList->pNext) {
00069         printf("pList @0x%p = %d, Next = 0x%p\n",
00070                pList, pList->sNumber, pList->pNext);
00071     }
00072 }
00073
00074
00075 /****************************************************************************
00076
00077 Function:   Shutdown
00078
00079 Parameters: none
00080
00081 Returns:    none
00082
00083 Purpose:    Make the server stop listening for client applications.
00084
00085 Comments:   The two NULL parameters passed to RpcServerUnregisterIf are
00086             a show of brute force:  they tell the function to turn
00087             off all registered interfaces.  See the RPC API function
00088             reference for more information about these functions.
00089
00090 ****************************************************************************/
00091
00092 void Shutdown(void)
00093 {
00094     RPC_STATUS status;
00095
00096     printf("Calling RpcMgmtStopServerListening\n");
00097     status = RpcMgmtStopServerListening(NULL);
00098     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00099     if (status) {
00100         exit(status);
00101     }
00102
00103     printf("Calling RpcServerUnregisterIf\n");
00104     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00105     printf("RpcServerUnregisterIf returned 0x%x\n", status);
00106     if (status) {
00107         exit(status);
00108     }
00109 }
00110
00111 /* end file xmitp.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/txsub.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

txsub.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "ComSpyCtl.h"
00019 #include "ComSpyAudit.h"
00020 #include <comsvcs.h>
00021 #include "CComSpy.h"
00022 #include "SysLCESub.h"
00023 #include "TxSub.h"
00024
00025 CComBSTR GuidToBstr(REFGUID guid);
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // CTxSub
00029
00030 STDMETHODIMP CTxSub::OnTransactionStart(COMSVCSEVENTINFO * pInfo, REFGUID guidTx, REFGUID tsid, BOOL bRoot)
00031 {
00032   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnTransactionStart"), GuidToBstr(pInfo->guidApp));
00033
00034     CComBSTR sGuidTx = GuidToBstr(guidTx);
00035   m_pSpy -> AddParamValueToList(L"GuidTx", sGuidTx);
00036
00037   CComBSTR sTsid = GuidToBstr(tsid);
00038   m_pSpy -> AddParamValueToList(L"tsid", sTsid);
00039
00040   m_pSpy -> AddParamValueToList(L"Is a Root Tx?", bRoot ? L"Yes" : L"No");
00041
00042   IF_AUDIT_DO(OnTransactionStart)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00043                     sGuidTx,
00044                     sTsid,
00045                     bRoot);
00046
00047   return S_OK;
00048 }
00049
00050 STDMETHODIMP CTxSub::OnTransactionPrepare(COMSVCSEVENTINFO * pInfo, REFGUID guidTx, BOOL bVoteYes)
00051 {
00052   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnTransactionPrepare"), GuidToBstr(pInfo->guidApp));
00053
00054     CComBSTR sguidTx = GuidToBstr(guidTx);
00055     m_pSpy -> AddParamValueToList(L"*guidTx", sguidTx);
00056
00057   m_pSpy -> AddParamValueToList(L"Vote",  bVoteYes == TRUE ? L"Yes" : L"No");
00058
00059   IF_AUDIT_DO(OnTransactionPrepared)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00060                     sguidTx,
00061                     bVoteYes);
00062   return S_OK;
00063 }
00064
00065 STDMETHODIMP CTxSub::OnTransactionAbort(COMSVCSEVENTINFO * pInfo, REFGUID guidTx)
00066 {
00067   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnTransactionAbort"), GuidToBstr(pInfo->guidApp));
00068
00069     CComBSTR sguidTx = GuidToBstr(guidTx);
00070     m_pSpy -> AddParamValueToList(L"*guidTx", sguidTx);
00071
00072   IF_AUDIT_DO(OnTransactionAborted)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),sguidTx);
00073
00074   return S_OK;
00075 }
00076
00077 STDMETHODIMP CTxSub::OnTransactionCommit(COMSVCSEVENTINFO * pInfo, REFGUID guidTx)
00078 {
00079   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnTransactionCommit"), GuidToBstr(pInfo->guidApp));
00080
00081   CComBSTR sguidTx = GuidToBstr(guidTx);
00082   m_pSpy -> AddParamValueToList(L"*guidTx", sguidTx);
00083
00084   IF_AUDIT_DO(OnTransactionCommit)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),sguidTx);
00085   return S_OK;
00086 }
00087
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/BaseSnap.Cpp Source File

  • SysMgmt
  • MMC
  • Help

BaseSnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cdialoglite.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cdialoglite.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CDIALOGLITE.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011
00012 //////////////////////////////////////////////////////////////////////////
00013 // Defines
00014 //
00015 //////////////////////////////////////////////////////////////////////////
00016 #ifndef __CDIALOGLITE_H__
00017 #define __CDIALOGLITE_H__
00018
00019
00020 //////////////////////////////////////////////////////////////////////////
00021 // Macros
00022 //
00023 //////////////////////////////////////////////////////////////////////////
00024 #define ON_COMMAND(ID, func)      case ID: (func); return TRUE;
00025 #define ON_COMMAND_UI(ID, flags)    case ID: (*pdwFlags = (flags)); return TRUE;
00026 #define ON_COMMAND_UI_ENABLED(ID, func) ON_COMMAND_UI(ID, (func) ? MF_ENABLED : MF_GRAYED)
00027 #define ON_COMMAND_UI_CHECKED(ID, func) ON_COMMAND_UI(ID, (func) ? MF_CHECKED : MF_UNCHECKED)
00028
00029 #define STATEIMAGEINDEX(iImage)     INDEXTOSTATEIMAGEMASK(iImage+1)
00030 #define BST2STATE(dwValue)        ((dwValue) ? BST_CHECKED : BST_UNCHECKED)
00031 #define BST3STATE(dwValue)        ((dwValue) ? ((dwValue) == BST_INDETERMINATE ? (dwValue) : BST_CHECKED) : BST_UNCHECKED)
00032
00033 //INDEX
00034 typedef LRESULT INDEX;
00035 const INDEX   INVALID_INDEX = -1;
00036
00037
00038 //////////////////////////////////////////////////////////////////////////
00039 // Includes
00040 //
00041 //////////////////////////////////////////////////////////////////////////
00042 #include <richedit.h>
00043 #include <exdisp.h>     //IWebBrowser2, DIID_DWebBrowserEvents2
00044 #include <exdispid.h>   //DISPID_DOCUMENTCOMPLETE
00045 #include <mshtmdid.h>   //DISPID_AMBIENT_DLCONTROL
00046 #include <msxml.h>      //DOM
00047
00048 #include "Error.h"
00049
00050
00051 //////////////////////////////////////////////////////////////////////////
00052 // Typedefs
00053 //
00054 //////////////////////////////////////////////////////////////////////////
00055 #define REFPOINTS const POINTS &
00056 #define REFRECT   const RECT &
00057
00058
00059 //////////////////////////////////////////////////////////////////////////
00060 // Forwards
00061 //
00062 //////////////////////////////////////////////////////////////////////////
00063 class CPropSheetLite;
00064 class CFrameWndLite;
00065 class CAppLite;
00066
00067
00068 //////////////////////////////////////////////////////////////////////////
00069 // Globals
00070 //
00071 //////////////////////////////////////////////////////////////////////////
00072 CAppLite*   GetAppLite();
00073 void      SetAppLite(CAppLite* pCAppLite);
00074
00075 BOOL      DisplayContextMenu(HWND hWnd, UINT iID, REFPOINTS pts, HWND hWndParent, BOOL fRelCords = FALSE);
00076 LRESULT     DisplayDialog(UINT uID, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM lParam);
00077
00078
00079 /////////////////////////////////////////////////////////////////////
00080 // CAppLite
00081 //
00082 /////////////////////////////////////////////////////////////////////
00083 class CAppLite
00084 {
00085 public:
00086   CAppLite(UINT nAppID);
00087   virtual ~CAppLite();
00088
00089   BOOL      AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR* pszCmdLine, INT nCmdShow);
00090   virtual BOOL  InitInstance();
00091   virtual int   ExitInstance();
00092   virtual int   Run();
00093
00094 //protected:
00095   //data
00096   HINSTANCE   m_hInstance;
00097   HINSTANCE   m_hPrevInstance;
00098   CHAR*     m_pszCmdLine;
00099   INT       m_nCmdShow;
00100
00101   UINT      m_nAppID;
00102
00103   static  HWND      m_hWndModeless;
00104   static  CFrameWndLite*  m_pCMainWindow;
00105 };
00106
00107
00108 /////////////////////////////////////////////////////////////////////
00109 // CWndLite
00110 //
00111 /////////////////////////////////////////////////////////////////////
00112 class CWndLite
00113 {
00114 public:
00115   //constructors
00116   CWndLite(HWND hWndParent = NULL, UINT nID = 0);
00117   virtual ~CWndLite();
00118
00119   //Window Proc
00120   static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00121   virtual BOOL      HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00122   virtual LRESULT     UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00123
00124   //Inline helpers, (that deal with hWnds)
00125   HWND  GetDlgItem(INT iResourceID)         { return ::GetDlgItem(m_hWnd, iResourceID);         }
00126   UINT  IsDlgButtonChecked(INT iResourceID)     { return ::IsDlgButtonChecked(m_hWnd, iResourceID);     }
00127   BOOL  CheckDlgButton(INT iResourceID, UINT uCheck){ ASSERT(uCheck == BST_CHECKED || uCheck == BST_UNCHECKED || BST_INDETERMINATE); return ::CheckDlgButton(m_hWnd, iResourceID, uCheck);    }
00128
00129   BOOL  IsVisible()                 { return ::IsWindowVisible(m_hWnd);             }
00130   HFONT GetFont()                 { return (HFONT)::SendMessage(m_hWnd, WM_GETFONT, 0, 0);  }
00131   void  SetFont(HFONT hFont)            { ::SendMessage(m_hWnd, WM_SETFONT, (WPARAM)hFont, 0);    }
00132   BOOL  EnableWindow(BOOL bEnable = TRUE)     { return ::EnableWindow(m_hWnd, bEnable);         }
00133   HWND  SetFocus()                  { return ::SetFocus(m_hWnd);                }
00134
00135   HWND  GetWnd()                  { /*ASSERT(m_hWnd);*/ return m_hWnd;            }
00136   BOOL  GetWindowPlacement()            { memset(&m_wndPlacement, 0, sizeof(WINDOWPLACEMENT)); m_wndPlacement.length  = sizeof(WINDOWPLACEMENT); return ::GetWindowPlacement(m_hWnd, &m_wndPlacement); }
00137   BOOL  SetWindowPlacement()            { m_wndPlacement.length = sizeof(WINDOWPLACEMENT); return ::SetWindowPlacement(m_hWnd, &m_wndPlacement); }
00138
00139   WCHAR*  GetWindowText()                   { return wGetWindowText(m_hWnd);                    }
00140   LRESULT GetWindowText(WCHAR* pwszBuffer, ULONG ulMaxSize) { return wSendMessage(m_hWnd, WM_GETTEXT, ulMaxSize, pwszBuffer);   }
00141   BOOL  SetWindowText(WCHAR* pwszString)          { return (BOOL)wSendMessage(m_hWnd, WM_SETTEXT, 0,     pwszString); }
00142
00143   LONG  ShowWindow(UINT nCmdShow)         { return ::ShowWindow(m_hWnd, nCmdShow);                    }
00144   LONG  UpdateWindow()                { return ::UpdateWindow(m_hWnd);                        }
00145
00146 public:
00147 //protected:
00148   virtual BOOL  PreCreateWindow(CREATESTRUCTW& cs);
00149   virtual BOOL  Create(HWND hWndParent, WCHAR* pwszClassName,
00150                 WCHAR* pwszWindowName, UINT uID,
00151                 DWORD dwStyle = WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL,
00152                 DWORD dwExStyle = WS_EX_CLIENTEDGE,
00153                 int x = CW_USEDEFAULT, int y = CW_USEDEFAULT,
00154                 int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT);
00155
00156   virtual BOOL  CreateIndirect(HWND hWndParent, UINT nID = 0);
00157   virtual BOOL  OnInitialUpdate();
00158   virtual BOOL  DestroyWindow();
00159   virtual BOOL  SubClassWindow(WNDPROC pWndProc);
00160
00161   virtual BOOL  OnMenuSelect(UINT uID);
00162   virtual BOOL  OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu);
00163   virtual BOOL  HandleMenuPos(HMENU hMenu, UINT uPos, DWORD* pdwFlags);
00164
00165   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
00166   virtual BOOL  OnCommand(UINT iID, HWND hWndCtrl);
00167   virtual BOOL  OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl);
00168   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00169   virtual BOOL  OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags);
00170
00171   virtual BOOL  OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious);
00172   virtual BOOL  OnClose();
00173   virtual BOOL  OnDestroy();
00174   virtual BOOL  OnTimer(WPARAM nIDEvent);
00175   virtual BOOL  OnDropFiles(HDROP hDrop);
00176   virtual BOOL  OnSysCommand(WPARAM nCmdType, REFPOINTS pts);
00177
00178   virtual BOOL  OnSize(WPARAM nType, REFPOINTS pts);
00179   virtual BOOL  OnSizing(WPARAM nType, REFPOINTS pts);
00180   virtual BOOL  OnMove(REFPOINTS pts);
00181   virtual BOOL  OnMouseMove(WPARAM nHittest, REFPOINTS pts);
00182
00183   virtual BOOL  OnDblclk(WPARAM fwKeys, REFPOINTS pts);
00184   virtual BOOL  OnLButtonDown(WPARAM fwKeys, REFPOINTS pts);
00185   virtual BOOL  OnLButtonUp(WPARAM fwKeys, REFPOINTS pts);
00186   virtual BOOL  OnRButtonDown(WPARAM fwKeys, REFPOINTS pts);
00187   virtual BOOL  OnRButtonUp(WPARAM fwKeys, REFPOINTS pts);
00188   virtual BOOL  OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg);
00189
00190   virtual BOOL  OnContextMenu(HWND hWnd, REFPOINTS pts);
00191   virtual BOOL  OnChar(TCHAR chCharCode, LPARAM lKeyData);
00192   virtual BOOL  OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData);
00193   virtual BOOL  OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData);
00194   virtual BOOL  OnVScroll(int nScrollCode, int nPos, HWND hWnd);
00195   virtual BOOL  OnHScroll(int nScrollCode, int nPos, HWND hWnd);
00196   virtual BOOL  OnNCMouseMove(WPARAM nHittest, REFPOINTS pts);
00197   virtual BOOL  OnNCButtonDown(WPARAM nHittest, REFPOINTS pts);
00198   virtual BOOL  OnSetFocus(HWND hWndPrevFocus);
00199
00200   //Protect against leaks (reusing the window without destroying it...)
00201   virtual BOOL  IsDestroyed()           { return !m_hWnd && !m_hWndParent && !m_pSubClassProc && !m_pwszClassName;  }
00202
00203   //Data
00204   HWND      m_hWnd;
00205   HWND      m_hWndParent;
00206   WINDOWPLACEMENT m_wndPlacement;
00207   WCHAR*      m_pwszClassName;
00208   UINT      m_nID;
00209   BOOL      m_bUnicodeMsg;
00210
00211   //SubClass
00212   WNDPROC     m_pSubClassProc;
00213 };
00214
00215
00216
00217 /////////////////////////////////////////////////////////////////////
00218 // CMDIChildLite
00219 //
00220 /////////////////////////////////////////////////////////////////////
00221 class CMDIChildLite : public CWndLite
00222 {
00223 public:
00224   //Constructors
00225   CMDIChildLite();
00226   virtual ~CMDIChildLite();
00227
00228   //Window Proc
00229   static LRESULT WINAPI MDIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00230   virtual BOOL      HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00231   virtual LRESULT     UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00232
00233   //Messages
00234   virtual BOOL      OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate);
00235
00236   //Helpers
00237   virtual BOOL      AutoPosition(BOOL fDefaultPosition = TRUE);
00238
00239 //protected:
00240   virtual BOOL      Create(HWND hWndParent, WCHAR* pwszClassName,
00241                 WCHAR* pwszWindowName, UINT uID, HICON hIcon,
00242                 DWORD dwStyle = WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_BORDER,
00243                 DWORD dwExStyle = WS_EX_CLIENTEDGE,
00244                 int x = CW_USEDEFAULT, int y = CW_USEDEFAULT,
00245                 int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT);
00246
00247 //protected:
00248   //data
00249 };
00250
00251
00252 /////////////////////////////////////////////////////////////////////
00253 // CFrameWndLite
00254 //
00255 /////////////////////////////////////////////////////////////////////
00256 class CFrameWndLite : public CWndLite
00257 {
00258 public:
00259   //constructors
00260   CFrameWndLite();
00261   virtual ~CFrameWndLite();
00262
00263   virtual BOOL  Create(HWND hWndParent, WCHAR* pwszClassName,
00264                 WCHAR* pwszWindowName, UINT uID, HICON hIcon,
00265                 DWORD dwStyle = WS_OVERLAPPEDWINDOW,
00266                 DWORD dwExStyle = WS_EX_APPWINDOW,
00267                 int x = CW_USEDEFAULT, int y = CW_USEDEFAULT,
00268                 int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT);
00269
00270   virtual BOOL  PreTranslateMessage(MSG* pmsg);
00271
00272   //Messages
00273   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00274   virtual BOOL  OnClose();
00275   virtual BOOL  OnDestroy();
00276
00277   //Messages
00278   virtual void  OnToolTip(INT idCtrl, NMHDR* pNMHDR);
00279 };
00280
00281
00282
00283 /////////////////////////////////////////////////////////////////////
00284 // CMDIFrameLite
00285 //
00286 /////////////////////////////////////////////////////////////////////
00287 class CMDIFrameLite : public CFrameWndLite
00288 {
00289 public:
00290   //constructors
00291   CMDIFrameLite();
00292   virtual ~CMDIFrameLite();
00293
00294   //Overloads
00295   virtual LRESULT UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00296   virtual BOOL  PreTranslateMessage(MSG* pmsg);
00297
00298   //Overloads
00299   virtual BOOL  OnCommand(UINT iID, HWND hWndCtrl);
00300   virtual BOOL  OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl);
00301   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00302   virtual BOOL  OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags);
00303
00304   //Messages
00305   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
00306   virtual BOOL  OnCreateClient(CREATESTRUCT* pCREATESTRUCT);
00307   virtual BOOL  OnDestroy();
00308
00309   //Helpers
00310   virtual void  OnAutoPosition();
00311
00312   //Helpers
00313   virtual void  MDIActivate(HWND hWnd)  { SendMessage(m_hWndMDIClient, WM_MDIACTIVATE, (WPARAM)hWnd, 0);  }
00314   virtual void  MDIDestroy(HWND hWnd) { SendMessage(m_hWndMDIClient, WM_MDIDESTROY, (WPARAM)hWnd, 0);   }
00315
00316   //Helpers
00317   virtual CMDIChildLite* GetActiveWindow(WCHAR* pwszClassName = NULL);
00318   virtual CMDIChildLite* FindWindow(WCHAR* pwszClassName = NULL);
00319
00320   //Protect against leaks (reusing the window without destroying it...)
00321   virtual BOOL  IsDestroyed()     { return !m_hWndMDIClient && CFrameWndLite::IsDestroyed();      }
00322
00323 //protected:
00324   //Data
00325   HWND  m_hWndMDIClient;
00326 };
00327
00328
00329 /////////////////////////////////////////////////////////////////////
00330 // CDialogLite
00331 //
00332 /////////////////////////////////////////////////////////////////////
00333 class CDialogLite : public CWndLite
00334 {
00335 public:
00336   //constructors
00337   CDialogLite(UINT uIDD = 0);
00338   virtual ~CDialogLite();
00339
00340   //members
00341   virtual LRESULT     DoModal(HWND hWndParent);   //Modal
00342   virtual HWND      CreateDlg(HWND hWndParent);   //Modeless (non-Modal)
00343   virtual void      EndDialog(int nResult);
00344
00345   //Dialog Proc
00346   static  INT_PTR WINAPI  DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00347   virtual BOOL      HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00348
00349 //protected:
00350   virtual BOOL      OnInitDialog();
00351   virtual BOOL      OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious);
00352
00353   virtual BOOL      OnOK();
00354   virtual BOOL      OnCancel();
00355
00356   //Data
00357   UINT      m_uIDD;
00358   BOOL      m_fModal;
00359 };
00360
00361
00362
00363 /////////////////////////////////////////////////////////////////////
00364 // CSplitterLite
00365 //
00366 /////////////////////////////////////////////////////////////////////
00367 class CSplitterLite : public CWndLite
00368 {
00369 public:
00370   //constructors
00371   CSplitterLite(HWND hWndParent = NULL, UINT nID = 0);
00372
00373   //Helpers
00374   virtual BOOL  SetSplitter(CSplitterLite* pCWndTop, CSplitterLite* pCWndBottom = NULL, CSplitterLite* pCWndLeft = NULL, CSplitterLite* pCWndRight = NULL);
00375   virtual BOOL  StartTracking(REFPOINTS ptsScreen, REFRECT rectLeft, REFRECT rectRight, BOOL fVertical, POINT* pPoint);
00376   virtual BOOL  DrawSplitter(HDC hDC, BOOL fVertical, REFRECT rectLeft, REFRECT rectRight, REFPOINTS ptsClient);
00377
00378   //Messages
00379   virtual BOOL  OnNCMouseMove(WPARAM nHittest, REFPOINTS pts);
00380   virtual BOOL  OnNCButtonDown(WPARAM nHittest, REFPOINTS pts);
00381   virtual BOOL  OnBorder(REFPOINTS pts, INT iBorder);
00382
00383 //protected:
00384   //Data
00385   CSplitterLite*  m_pCWndTop;
00386   CSplitterLite*  m_pCWndBottom;
00387   CSplitterLite*  m_pCWndLeft;
00388   CSplitterLite*  m_pCWndRight;
00389
00390   HCURSOR     m_hCursorOld;
00391   HCURSOR     m_hCursorTop;
00392   HCURSOR     m_hCursorRight;
00393
00394   INT       m_iBorderCX;
00395   INT       m_iBorderCY;
00396 };
00397
00398
00399 /////////////////////////////////////////////////////////////////////
00400 // CEditBoxLite
00401 //
00402 /////////////////////////////////////////////////////////////////////
00403 class CEditBoxLite : public CSplitterLite
00404 {
00405 public:
00406   //constructors
00407   CEditBoxLite(HWND hWndParent = NULL, UINT nID = 0);
00408   virtual ~CEditBoxLite();
00409
00410   //Messages
00411   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
00412
00413   //Interface
00414   virtual void  SetSel(INDEX iMin, INDEX iMax)              { SendMessage(m_hWnd, EM_SETSEL, (WPARAM)iMin, (LPARAM)iMax); }
00415   virtual BOOL  GetSel(INDEX* piMin, INDEX* piMax)            { CHARRANGE cr; BOOL bReturn = GetSel(&cr); if(piMin) *piMin = cr.cpMin;  if(piMax) *piMax = cr.cpMax; return bReturn;    }
00416   virtual BOOL  GetSel(CHARRANGE* pcr)                  { ASSERT(pcr); SendMessageA(m_hWnd, EM_GETSEL, (WPARAM)&pcr->cpMin, (LPARAM)&pcr->cpMax); return pcr->cpMin != pcr->cpMax;  }
00417
00418   //Inline helpers, (that deal with hWnds)
00419   BOOL      SetReadOnly(bool bReadOnly)               { return (BOOL)SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L);                }
00420   INDEX     LineIndex(INDEX nLine)                  { return (INDEX)SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0);                  }
00421   INDEX     LineLength(INDEX nStartChar)              { return (INDEX)SendMessage(m_hWnd, EM_LINELENGTH, nStartChar, 0);                }
00422   void      LineScroll(INDEX nLines, INDEX nChars = 0)        { SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines);                     }
00423   LRESULT     SetOptions(UINT dwOptions, UINT fOperation = ECOOP_OR)  { return SendMessage(m_hWnd, EM_SETOPTIONS, fOperation, dwOptions);               }
00424
00425   BOOL      CanPaste()                        { return (BOOL)SendMessage(m_hWnd, EM_CANPASTE, 0, 0);                      }
00426   void      Cut()                         { SendMessage(m_hWnd, WM_CUT, 0, 0);                              }
00427   void      Copy()                          { SendMessage(m_hWnd, WM_COPY, 0, 0);                             }
00428   void      Paste()                         { SendMessage(m_hWnd, WM_PASTE, 0, 0);                              }
00429   BOOL      ScrollCaret()                     { return (BOOL)SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0);                   }
00430
00431   virtual void  ReplaceSel(LPCWSTR pwszString, bool bCanUndo)     { wSendMessage(m_hWnd, EM_REPLACESEL, (WPARAM)bCanUndo, (WCHAR*)pwszString);          }
00432   virtual void  ReplaceAll(LPCWSTR pwszString, bool bReplaceAll = FALSE, bool fHighlight = FALSE);
00433
00434   INDEX     GetLineCount()                      { return (INDEX)SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0);                   }
00435   INDEX     GetLine(INDEX iLine, CHAR* pszBuffer, ULONG ulMaxSize);
00436   INDEX     GetTextRange(CHARRANGE& cr, WCHAR* pwszBuffer);
00437   INDEX     GetTextRange(CHARRANGE& cr, CHAR* pszBuffer);
00438
00439   //Helpers
00440   BOOL      Save(LPCWSTR pwszFileName);
00441
00442 //protected:
00443   //data
00444 };
00445
00446
00447 /////////////////////////////////////////////////////////////////////////////
00448 // COLORA
00449 //
00450 // These are the same as defined in CFM_*.  But we need a "enumerable" type
00451 // so that we can easily pass these to operators, and it knows from the type
00452 // which function to call
00453 //
00454 /////////////////////////////////////////////////////////////////////////////
00455 enum COLORA
00456 {
00457   CA_NORMAL     = 0,
00458   CA_BOLD       = CFM_BOLD,
00459   CA_ITALIC     = CFM_ITALIC,
00460   CA_UNDERLINE    = CFM_UNDERLINE,
00461   CA_STRIKEOUT    = CFM_STRIKEOUT,
00462   CA_PROTECTED    = CFM_PROTECTED,
00463   CA_LINK       = CFM_LINK,
00464   CA_AUTO_COLOR   = CFE_AUTOCOLOR,
00465   CA_COLOR      = CFM_COLOR,
00466   CA_DISABLE      = CFM_CHARSET,
00467 };
00468
00469 enum OUTPUT_SPECIAL
00470 {
00471   NEWLINE       = 00000001,
00472 };
00473
00474 /////////////////////////////////////////////////////////////////////////////
00475 // CConsole
00476 //
00477 /////////////////////////////////////////////////////////////////////////////
00478 class CConsole  /*: public CStringCache*/
00479 {
00480 public:
00481   //Constructors
00482   CConsole()
00483   {
00484     m_pwszNewLine = wWndEOL;
00485   }
00486   virtual ~CConsole()
00487   {
00488   }
00489
00490   //Interface
00491   inline  CConsole& GetConsole()  { return *this; }
00492
00493   //Strings
00494   virtual CConsole& operator << (LPCWSTR pwsz )
00495   {
00496     Write(pwsz);
00497     return GetConsole();
00498   }
00499 //  virtual CConsole& operator << (OUTPUT_SPECIAL eSpecial);
00500 //  virtual CConsole& operator << (void* pv);
00501
00502   //Overloads
00503   virtual HRESULT   Write(LPCWSTR pwsz) = 0;
00504   virtual HRESULT   WriteLine(LPCWSTR pwsz = NULL)
00505   {
00506     if(pwsz)
00507       Write(pwsz);
00508     return Write(m_pwszNewLine);
00509   }
00510
00511   //Helpers
00512 //  virtual HRESULT   WriteMBCS(LPCSTR pwsz);
00513
00514   //Colors
00515   virtual void    SetColor(COLORREF refColor)
00516   {
00517   }
00518   virtual void    SetColorAttrib(COLORA attColor, BOOL fEnable = TRUE)
00519   {
00520   }
00521   virtual CConsole& operator << (COLORREF refColor)
00522   {
00523     SetColor(refColor);
00524     return GetConsole();
00525   }
00526   virtual CConsole& operator << (COLORA attColor)
00527   {
00528     SetColorAttrib(attColor);
00529     return GetConsole();
00530   }
00531
00532 protected:
00533   //Overloads
00534   //TODO: We should be implementing this here, the derived class of the console should...
00535 //  virtual HRESULT WriteCore(ULONG cbBytes, BYTE* rgBytes, ULONG* pcbWritten = NULL);
00536
00537   //Data
00538   WCHAR*        m_pwszNewLine;
00539
00540 private:
00541   //NOTE: Don't use MBCS - requires expensive conversions...
00542 //  virtual CConsole& operator << (LPCSTR pwsz );
00543 };
00544
00545
00546 /////////////////////////////////////////////////////////////////////
00547 // CRichEditLite
00548 //
00549 /////////////////////////////////////////////////////////////////////
00550 class CRichEditLite : public CEditBoxLite, public CConsole
00551 {
00552 public:
00553   //constructors
00554   CRichEditLite(HWND hWndParent = NULL, UINT nID = 0);
00555   virtual ~CRichEditLite();
00556
00557   //Messages
00558   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
00559   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00560   virtual BOOL  SetWordWrap(BOOL fWordWrap);
00561
00562   //Messages
00563   virtual BOOL  OnLink(INT idCtrl, ENLINK* pEnLink);
00564
00565   //Abstract - CConsole implementation
00566   virtual HRESULT Write(LPCWSTR pwszText)
00567   {
00568     Append(pwszText);
00569     return S_OK;
00570   }
00571   virtual void    SetColor(COLORREF refColor)
00572   {
00573     if(refColor == RGB_NONE)
00574     {
00575       //Restore color
00576       SetEffects(CFM_COLOR, CFE_AUTOCOLOR, 0);
00577     }
00578     else
00579     {
00580       //Change color
00581       SetEffects(CFM_COLOR, 0, refColor);
00582     }
00583   }
00584   virtual void    SetColorAttrib(COLORA attColor, BOOL fEnable = TRUE)
00585   {
00586     if(attColor == CA_NORMAL)
00587     {
00588       //Restore (all) Attributes
00589       //NOTE: Just simply using ULONG_MAX as the mask causes problems since
00590       //other things (ie: charset, etc) are also affected...
00591       SetEffects(CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_PROTECTED | CFM_LINK, 0, 0);
00592     }
00593     else
00594     {
00595       //Change Attributes
00596       SetEffects(attColor, fEnable ? attColor : ~attColor, 0);
00597     }
00598   }
00599
00600   //Interface
00601   //NOTE: We overload Get and Set since for RichEdit controls these have different messages for > 64k
00602   virtual void  SetSel(INDEX iMin, INDEX iMax)              { CHARRANGE cr = { (LONG)iMin, (LONG)iMax }; SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr);  }
00603   virtual BOOL  GetSel(INDEX* piMin, INDEX* piMax)            { CHARRANGE cr; BOOL bReturn = GetSel(&cr); if(piMin) *piMin = cr.cpMin;  if(piMax) *piMax = cr.cpMax; return bReturn;    }
00604   virtual BOOL  GetSel(CHARRANGE* pcr)                  { ASSERT(pcr); SendMessageA(m_hWnd, EM_EXGETSEL, 0, (LPARAM)pcr); return pcr->cpMin != pcr->cpMax;  }
00605
00606   //Inline helpers, (that deal with hWnds)
00607   INDEX     LineFromChar(INDEX nIndex)                { return (INDEX)SendMessage(m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex);      }
00608
00609   BOOL      SetEffects(DWORD dwMask, DWORD  dwEffects, COLORREF crTextColor);
00610   BOOL      SetCharFormat(DWORD dwMask, CHARFORMATW& charFormatW);
00611
00612   virtual void  ReplaceSel(LPCWSTR pwszString, bool bCanUndo)     { wSendMessage(m_hWnd, EM_REPLACESEL, (WPARAM)bCanUndo, (WCHAR*)pwszString);  }
00613   virtual void  ReplaceSel(LPCWSTR pwszString, bool bCanUndo, DWORD dwMask, DWORD dwColor);
00614   virtual void  Append(LPCWSTR pwszString, bool bCanUndo = TRUE, DWORD dwMask = 0, DWORD dwColor = 0);
00615
00616   virtual INDEX FindText(DWORD dwFindFlags, FINDTEXTEXW* pFINDTEXT);
00617   virtual BOOL  FindNext(DWORD dwFindFlags, WCHAR* pwszText);
00618
00619   //Helpers
00620   LRESULT     SetDefaultFont();
00621   WCHAR*      GetSelectedText(BOOL fEntireLine = TRUE);
00622
00623
00624 //protected:
00625   //data
00626 };
00627
00628
00629
00630 /////////////////////////////////////////////////////////////////////
00631 // CScrollBarLite
00632 //
00633 /////////////////////////////////////////////////////////////////////
00634 class CScrollBarLite : public CSplitterLite
00635 {
00636 public:
00637   //constructors
00638   CScrollBarLite();
00639   virtual ~CScrollBarLite();
00640
00641   //Messages
00642
00643   //Inline helpers, (that deal with hWnds)
00644   virtual INT   SetScrollPos( int nPos, BOOL bRedraw = TRUE )       { return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw);     }
00645   virtual INT   GetScrollPos()                        { return ::GetScrollPos(m_hWnd, SB_CTL);            }
00646
00647   virtual BOOL  SetScrollRange( int nMin, int nMax, BOOL bRedraw = TRUE ) { return ::SetScrollRange(m_hWnd, SB_CTL, nMin, nMax, bRedraw); }
00648   virtual BOOL  GetScrollRange( int* pnMin, int* pnMax )          { return ::GetScrollRange(m_hWnd, SB_CTL, pnMin, pnMax);    }
00649
00650   //Helpers
00651   virtual INT   SetScroll( int nPos, BOOL bRedraw = TRUE );
00652   virtual INT   SetScrollInfo(INT iPos, INT iRangeSize, INT iPageSize, BOOL fRedraw = TRUE);
00653   virtual BOOL  GetScrollInfo(INT* piPos, INT* piRangeSize, INT* piPageSize);
00654
00655 //protected:
00656   //data
00657 };
00658
00659
00660 /////////////////////////////////////////////////////////////////////
00661 // CListBoxLite
00662 //
00663 /////////////////////////////////////////////////////////////////////
00664 class CListBoxLite : public CWndLite
00665 {
00666 public:
00667   //constructors
00668   CListBoxLite(HWND hWndParent = NULL, UINT nID = 0);
00669   virtual ~CListBoxLite();
00670
00671   //Messages
00672   virtual BOOL  OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl);
00673
00674   //Overloads
00675   virtual BOOL  OnDblClk(INT iID, HWND hWndCtrl);
00676
00677   //Inline helpers, (that deal with hWnds)
00678   virtual INDEX SetCurSel(WPARAM nSelect)         { return (INDEX)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0);      }
00679   virtual INDEX GetCurSel() const             { return (INDEX)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0);            }
00680   virtual INDEX AddString(WCHAR* pwszString)        { return (INDEX)wSendMessage(m_hWnd,  LB_ADDSTRING, 0, pwszString);       }
00681   virtual INDEX DeleteString(WPARAM wParam)         { return (INDEX)wSendMessage(m_hWnd,  LB_DELETESTRING, wParam, 0);    }
00682   virtual INDEX GetText(INDEX nIndex, WCHAR* pwszBuffer)  { return (INDEX)wSendMessage(m_hWnd,  LB_GETTEXT, nIndex, pwszBuffer);      }
00683   virtual INDEX GetTextLen(INDEX nIndex)          { return (INDEX)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0); }
00684
00685   virtual BOOL  SetItemParam(INDEX nIndex, LPARAM lParam) { return ::SendMessage(m_hWnd,  LB_SETITEMDATA, nIndex, lParam) != CB_ERR;      }
00686   virtual LPARAM  GetItemParam(INDEX nIndex) const      { return ::SendMessage(m_hWnd,  LB_GETITEMDATA, nIndex, 0);         }
00687
00688   virtual INDEX GetCount()                  { return (INDEX)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0); }
00689   //Helpers
00690
00691 //protected:
00692   //data
00693 };
00694
00695
00696 /////////////////////////////////////////////////////////////////////
00697 // CListViewLite
00698 //
00699 /////////////////////////////////////////////////////////////////////
00700 class CListViewLite : public CSplitterLite
00701 {
00702 public:
00703   //constructors
00704   CListViewLite(HWND hWndParent = NULL, UINT nID = 0);
00705   virtual ~CListViewLite();
00706
00707   //Messages
00708   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
00709   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00710
00711   virtual BOOL  OnColumnClick(INT idCtrl, NMLISTVIEW* pNMListView);
00712   virtual BOOL  OnItemActivate(INT idCtrl, NMLISTVIEW* pNMListView);
00713   virtual BOOL  OnItemChanged(INT idCtrl, NMLISTVIEW* pNMListView);
00714
00715   //Inline helpers, (that deal with hWnds)
00716   BOOL      DeleteColumn(INDEX nCol)                { return (BOOL)SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0);                }
00717   BOOL      DeleteItem(INDEX iItem)                 { return (BOOL)SendMessage(m_hWnd, LVM_DELETEITEM, iItem, 0L);                }
00718   BOOL      DeleteAllItems()                    { return (BOOL)SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L);                }
00719   INDEX     GetNextItem(INDEX iItem, INT nFlags)          { return (INDEX)SendMessage(m_hWnd, LVM_GETNEXTITEM, iItem, MAKELPARAM(nFlags, 0));     }
00720   INDEX     GetColumnWidth(INDEX nCol)                { return (INDEX)SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0);             }
00721   BOOL      SetColumnWidth(INDEX nCol, INT cx)            { return (BOOL)SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0));      }
00722   UINT      GetItemState(INDEX iItem, UINT nMask)         { return (UINT)SendMessage(m_hWnd, LVM_GETITEMSTATE, iItem, nMask);             }
00723   BOOL      EnsureVisible(INDEX iItem, bool fPartialOK = FALSE)   { return (BOOL)SendMessage(m_hWnd, LVM_ENSUREVISIBLE, iItem, MAKELPARAM(fPartialOK, 0));  }
00724   INDEX     GetItemCount()                      { return (INDEX)SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0);                }
00725   INDEX     GetCountPerPage()                   { return (INDEX)SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0);               }
00726   HWND      EditLabel(INDEX iItem)                  { return (HWND)SendMessage(m_hWnd, LVM_EDITLABEL, iItem, 0L);               }
00727
00728   //Helpers
00729   LPARAM      GetItemParam(INDEX iItem);
00730   INDEX     GetItemText(INDEX iItem, INDEX iSubItem, WCHAR* wszName, ULONG ulMaxChars);
00731   INDEX     InsertColumn(INDEX iColumn, WCHAR* wszName, INT iImage = IMAGE_NONE);
00732   BOOL      SetColumn(INDEX iColumn, WCHAR* wszName, INT iImage = IMAGE_NONE);
00733
00734   INDEX     InsertItem(INDEX iItem, INDEX iSubItem, WCHAR* wszName, LPARAM lParam = PARAM_NONE, INT iImage = IMAGE_NONE, UINT iState = IMAGE_NONE, UINT iStateMask = IMAGE_NONE);
00735   BOOL      SetItemText(INDEX iItem, INDEX iSubItem, WCHAR* pwszName);
00736   BOOL      SetItemState(INDEX iItem, INDEX iSubItem, UINT iState, UINT iStateMask);
00737   INDEX     HitTest(REFPOINTS pts, UINT* pFlags = NULL, BOOL fClientCoords = TRUE);
00738
00739   INT       GetItemImage(INDEX iItem, INDEX iSubItem = 0);
00740   BOOL      SetItemImage(INDEX iItem, INDEX iSubItem, INT iImage);
00741   BOOL      SetItemParam(INDEX iItem, INDEX iSubItem, LPARAM lParam);
00742 };
00743
00744
00745
00746 /////////////////////////////////////////////////////////////////////
00747 // CTreeViewLite
00748 //
00749 /////////////////////////////////////////////////////////////////////
00750 class CTreeViewLite : public CSplitterLite
00751 {
00752 public:
00753   //constructors
00754   CTreeViewLite(HWND hWndParent = NULL, UINT nID = 0);
00755   virtual ~CTreeViewLite();
00756
00757   //Messages
00758   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
00759   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00760
00761   virtual BOOL  OnSelChanged(INT idCtrl, NMTREEVIEW* pNMTreeView);
00762   virtual BOOL  OnBeginLabelEdit(INT idCtrl, NMTVDISPINFO* ptvdi);
00763   virtual BOOL  OnEndLabelEdit(INT idCtrl, NMTVDISPINFO* ptvdi);
00764   virtual BOOL  OnBeginDrag(INT idCtrl, NMTREEVIEW* pNMTreeView);
00765   virtual BOOL  OnMouseMove(WPARAM nHittest, REFPOINTS pts);
00766   virtual BOOL  OnLButtonUp(WPARAM fwKeys, REFPOINTS pts);
00767
00768   //Inline helpers, (that deal with hWnds)
00769   BOOL      SelectItem(HTREEITEM hItem)               { ASSERT(IsWindow(m_hWnd));   return (BOOL)SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem);    }
00770   HTREEITEM   GetSelectedItem()                   { ASSERT(IsWindow(m_hWnd));   return (HTREEITEM)SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0);        }
00771   BOOL      DeleteAllItems()                    { ASSERT(IsWindow(m_hWnd));   return (BOOL)SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);        }
00772   HTREEITEM   GetNextItem(HTREEITEM hItem, UINT nCode = TVGN_NEXT)  { ASSERT(IsWindow(m_hWnd));   return (HTREEITEM)SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem);   }
00773   HTREEITEM   GetChildItem(HTREEITEM hItem)             { ASSERT(IsWindow(m_hWnd));   return (HTREEITEM)SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);  }
00774   HTREEITEM   GetParentItem(HTREEITEM hItem)              { ASSERT(IsWindow(m_hWnd));   return (HTREEITEM)SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); }
00775   BOOL      DeleteItem(HTREEITEM hItem)               { ASSERT(IsWindow(m_hWnd));   return (BOOL)SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem);         }
00776   BOOL      EnsureVisible(HTREEITEM hItem)              { ASSERT(IsWindow(m_hWnd));   return (BOOL)SendMessage(m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem);        }
00777   BOOL      Expand(HTREEITEM hItem, UINT flag = TVE_EXPAND)     { ASSERT(IsWindow(m_hWnd));   return (BOOL)SendMessage(m_hWnd, TVM_EXPAND, flag, (LPARAM)hItem);          }
00778
00779   //Helpers
00780   LPARAM      GetItemParam(HTREEITEM hItem);
00781   HTREEITEM   HitTest(REFPOINTS pts, UINT* pFlags = NULL, BOOL fClientCoords = TRUE);
00782   BOOL      SetItemState(HTREEITEM hItem, UINT iState, UINT iStateMask);
00783   BOOL      SetItemImage(HTREEITEM hItem, INT iImage, INT iSelectedImage);
00784   BOOL      SetItemParam(HTREEITEM hItem, LPARAM lParam);
00785
00786   HTREEITEM   InsertItem(HTREEITEM hParent, HTREEITEM hInsAfter, WCHAR* wszName, LPARAM lParam = PARAM_NONE, INT iImage = IMAGE_NONE, INT iSelectedImage = IMAGE_NONE, UINT iState = IMAGE_NONE, UINT iStateMask = IMAGE_NONE);
00787   BOOL      SetItemText(HTREEITEM hItem, WCHAR* pwszText);
00788
00789 protected:
00790   //Data
00791   HTREEITEM   m_hDraggingItem;
00792 };
00793
00794
00795
00796 /////////////////////////////////////////////////////////////////////
00797 // CComboBoxLite
00798 //
00799 /////////////////////////////////////////////////////////////////////
00800 class CComboBoxLite : public CWndLite
00801 {
00802 public:
00803   //constructors
00804   CComboBoxLite(HWND hWndParent = NULL, UINT nID = 0);
00805   virtual ~CComboBoxLite();
00806
00807   //Messages
00808   virtual BOOL    OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl);
00809
00810   //Overloads
00811   virtual BOOL    OnSelChange(INT iID, HWND hWndCtrl);
00812   virtual BOOL    OnDropDown(INT iID, HWND hWndCtrl);
00813
00814   //Inline helpers, (that deal with hWnds)
00815   virtual INDEX   GetCount()                    { return (INDEX)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0);         }
00816   virtual INDEX   GetCurSel() const               { return (INDEX)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0);        }
00817   virtual INDEX   SetCurSel(WPARAM nSelect)           { return (INDEX)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0);      }
00818
00819   virtual INDEX   AddString(WCHAR* pwszString)          { return (INDEX)::wSendMessage(m_hWnd,  CB_ADDSTRING, 0, pwszString);   }
00820   virtual INDEX   DeleteString(INDEX nIndex)            { return (INDEX)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0);    }
00821   virtual BOOL    SetItemParam(INDEX nIndex, LPARAM lParam)   { return ::SendMessage(m_hWnd,  CB_SETITEMDATA, nIndex, lParam) != CB_ERR;  }
00822   virtual void    ResetContent()                  { ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0);               }
00823
00824   virtual LPARAM    GetItemParam(INDEX nIndex) const          { return ::SendMessage(m_hWnd,  CB_GETITEMDATA, nIndex, 0);         }
00825   virtual LRESULT   GetTextLength(INDEX nIndex)           { return ::SendMessage(m_hWnd,  CB_GETLBTEXTLEN, nIndex, 0);        }
00826   virtual INDEX   GetText(INDEX nIndex, WCHAR* pwszBuffer)    { return (INDEX)::wSendMessage(m_hWnd,  CB_GETLBTEXT, nIndex, pwszBuffer);  }
00827   virtual INDEX   FindString(WCHAR* pwszString, INDEX nStartIndex = -1)       { return (INDEX)wSendMessage(m_hWnd,  CB_FINDSTRING,    nStartIndex, pwszString);   }
00828   virtual INDEX   FindStringExact(WCHAR* pwszString, INDEX nStartIndex = -1)      { return (INDEX)wSendMessage(m_hWnd,  CB_FINDSTRINGEXACT, nStartIndex, pwszString);   }
00829
00830   //Helpers
00831   virtual INDEX   GetSelText(WCHAR* pwszBuffer, ULONG ulMaxSize);
00832   virtual INDEX   SetSelText(WCHAR* pwszBuffer, BOOL fAddItem = FALSE);
00833   virtual INDEX   SetSelValue(LPARAM lParam);
00834   virtual LPARAM    GetSelValue();
00835   virtual INDEX   AddString(WCHAR* pwszString, LPARAM lParam);
00836
00837   //Helpers
00838   virtual INDEX   SaveSelection()                 { return m_iSavedSel = GetCurSel();                     }
00839   virtual INDEX   RestoreSelection()                { return SetCurSel(m_iSavedSel);                      }
00840   virtual BOOL    Populate(ULONG cItems, const WIDENAMEMAP* rgItems);
00841
00842
00843 //protected:
00844   //data
00845   INDEX   m_iSavedSel;
00846 };
00847
00848
00849 /////////////////////////////////////////////////////////////////////
00850 // CButtonLite
00851 //
00852 /////////////////////////////////////////////////////////////////////
00853 class CButtonLite : public CWndLite
00854 {
00855 public:
00856   //constructors
00857   CButtonLite(HWND hWndParent = NULL, UINT nID = 0);
00858   virtual ~CButtonLite();
00859
00860   //Inline helpers, (that deal with hWnds)
00861   virtual UINT  IsButtonChecked()       { return ::IsDlgButtonChecked(m_hWndParent, m_nID);             }
00862   virtual BOOL  CheckButton(UINT uCheck)    { ASSERT(uCheck == BST_CHECKED || uCheck == BST_UNCHECKED || BST_INDETERMINATE); return ::CheckDlgButton(m_hWndParent, m_nID, uCheck);    }
00863
00864 //protected:
00865   //data
00866 };
00867
00868
00869 /////////////////////////////////////////////////////////////////////
00870 // CComboBoxEx
00871 //
00872 /////////////////////////////////////////////////////////////////////
00873 class CComboBoxEx : public CComboBoxLite
00874 {
00875 public:
00876   //constructors
00877   CComboBoxEx(HWND hWndParent = NULL, UINT nID = 0);
00878   virtual ~CComboBoxEx();
00879
00880   //Overrides
00881   virtual BOOL    OnInitialUpdate();
00882
00883   //Messages
00884   INDEX       InsertItem(INDEX iItem, WCHAR* pwszName, LPARAM lParam = PARAM_NONE, INT iIndent = PARAM_NONE, INT iImage = IMAGE_NONE, UINT iSelectedImage = IMAGE_NONE);
00885
00886   //Inline helpers, (that deal with hWnds)
00887   //NOTE: AddString is not processed by ComboBoxEx so we have to fabricate the functionality
00888   virtual INDEX   AddString(WCHAR* pwszString)                    { return InsertItem(-1/*iItem*/, pwszString);               }
00889   virtual INDEX   AddString(WCHAR* pwszString, LPARAM lParam)             { return InsertItem(-1/*iItem*/, pwszString, lParam);           }
00890
00891   virtual BOOL    SetUnicodeFormat(BOOL fUnicode = TRUE)                { return (BOOL)::SendMessage(m_hWnd, CBEM_SETUNICODEFORMAT, fUnicode, 0); }
00892
00893   //NOTE: FindString is not processed by ComboBoxEx, but FindStringExact is...
00894   virtual INDEX   FindString(WCHAR* pwszString, INDEX nStartIndex = -1)       { ASSERT(!L"FindString is not processed by ComboBoxEx, change code to use FindStringExact.");   return FindStringExact(pwszString, nStartIndex);  }
00895
00896   //protected:
00897   //data
00898 };
00899
00900
00901 /////////////////////////////////////////////////////////////////////
00902 // CToolBarLite
00903 //
00904 /////////////////////////////////////////////////////////////////////
00905 class CToolBarLite : public CWndLite
00906 {
00907 public:
00908   //constructors
00909   CToolBarLite();
00910   virtual ~CToolBarLite();
00911
00912   virtual BOOL Create(HWND hWndParent, UINT nID,  UINT nBitmapID, UINT cButtons, TBBUTTON* rgButtons, DWORD dwStyle = WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS /*| TBSTYLE_WRAPABLE | TBSTYLE_ALTDRAG | CCS_ADJUSTABLE*/);
00913
00914   //Helpers
00915   virtual BOOL EnableButton(UINT nID, bool fEnable)     { return (BOOL)SendMessage(m_hWnd, TB_ENABLEBUTTON, nID, fEnable);        }
00916 };
00917
00918
00919 /////////////////////////////////////////////////////////////////////
00920 // CStatusBarLite
00921 //
00922 /////////////////////////////////////////////////////////////////////
00923 class CStatusBarLite : public CWndLite
00924 {
00925 public:
00926   //constructors
00927   CStatusBarLite();
00928   virtual ~CStatusBarLite();
00929
00930   //Creation
00931   virtual BOOL Create(HWND hWndParent, UINT nID,  WCHAR* pwszText = L"", DWORD dwStyle = WS_CHILD | WS_VISIBLE);
00932
00933   //Helpers
00934   virtual BOOL SetText(WCHAR* pwszText, int nPane, int nType) { return (BOOL)wSendMessage(m_hWnd, SB_SETTEXTW, (nPane|nType), pwszText);    }
00935   virtual BOOL SetParts(int nParts, int* pWidths)       { return (BOOL)SendMessage(m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths);   }
00936 };
00937
00938
00939 /////////////////////////////////////////////////////////////////////
00940 // CPropPageLite
00941 //
00942 /////////////////////////////////////////////////////////////////////
00943 class CPropPageLite : public CDialogLite
00944 {
00945 public:
00946   //constructors
00947   CPropPageLite(UINT uIDD, TCHAR* ptszTitle = NULL);
00948   virtual ~CPropPageLite();
00949
00950   //Dialog Proc
00951   static INT_PTR WINAPI PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00952   virtual BOOL      HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00953
00954   //Interface
00955   virtual void        SetParent(CPropSheetLite* pCPropSheetLite);
00956   virtual CPropSheetLite*   GetParent() { return m_pCPropSheet; }
00957
00958 //protected:
00959   virtual BOOL  OnSetActive();
00960   virtual BOOL  OnKillActive();
00961
00962   virtual BOOL  OnOK();
00963   virtual BOOL  OnApply();
00964
00965   virtual BOOL  OnCancel();
00966   virtual BOOL  OnReset();
00967
00968   //Data
00969   PROPSHEETPAGE   m_psPage;
00970
00971   //Parent Property Sheet
00972   CPropSheetLite* m_pCPropSheet;
00973 };
00974
00975
00976 /////////////////////////////////////////////////////////////////////
00977 // CPropSheetLite
00978 //
00979 /////////////////////////////////////////////////////////////////////
00980 class CPropSheetLite : public CWndLite
00981 {
00982 public:
00983   //constructors
00984   CPropSheetLite(TCHAR* ptszTitle = NULL, HICON hIcon = NULL);
00985   virtual ~CPropSheetLite();
00986
00987 //protected:
00988   virtual void    AddPage(CPropPageLite* pCPropPageLite);
00989   virtual LRESULT   DoModal(HWND hWndParent, INT nStartPage = 0);
00990
00991   //Data
00992   PROPSHEETHEADER m_psHeader;
00993 };
00994
00995
00996
00997 /////////////////////////////////////////////////////////////////////////////
00998 // CTabLite
00999 //
01000 /////////////////////////////////////////////////////////////////////////////
01001 class CTabLite : public CSplitterLite
01002 {
01003 public:
01004   //constructors
01005   CTabLite(HWND hWndParent = NULL, UINT nID = 0);
01006   virtual ~CTabLite();
01007
01008   //messages
01009   virtual BOOL  OnCreate(CREATESTRUCT* pCREATESTRUCT);
01010   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
01011
01012   virtual BOOL  OnSelChange(INT iID, HWND hWndCtrl);
01013   virtual BOOL  OnSelChanging(INT iID, HWND hWndCtrl);
01014
01015   //Inlines
01016   virtual INDEX GetItemCount()                      { return (INDEX)::SendMessageA(m_hWnd, TCM_GETITEMCOUNT, 0, 0);     }
01017   virtual INDEX GetCurSel() const                   { return (INDEX)::SendMessageA(m_hWnd, TCM_GETCURSEL, 0, 0);      }
01018   virtual INDEX SetCurSel(INDEX iItem, BOOL fSendNotification = FALSE);
01019
01020   virtual BOOL  DeleteAllItems()                    { return (BOOL)::SendMessageA(m_hWnd, TCM_DELETEALLITEMS, 0, 0);    }
01021   virtual BOOL  DeleteItem(INDEX iItem)                 { return (BOOL)::SendMessageA(m_hWnd, TCM_DELETEITEM, iItem, 0);    }
01022   virtual void  AdjustRect(RECT* pRect, BOOL fLarger = FALSE)     { SendMessageA(m_hWnd, TCM_ADJUSTRECT, fLarger, (LPARAM)pRect);     }
01023   virtual INDEX FindTab(LPARAM lParam);
01024
01025   //Helpers
01026   BOOL      GetItem(INDEX iItem, WCHAR* pwszText, ULONG ulMaxLength, LPARAM* plParam = NULL);
01027   LPARAM      GetItemData(INDEX iItem);
01028
01029   virtual BOOL  SetItem(INDEX iItem, LPCWSTR pwszName, LPARAM lParam = PARAM_NONE, INT iImage = IMAGE_NONE, DWORD dwState = STATE_NONE, DWORD dwStateMask = STATE_NONE);
01030   virtual BOOL  SetItemText(INDEX iItem, LPCWSTR pwszName);
01031
01032   virtual INDEX InsertItem(INDEX iItem, LPCWSTR pwszText, LPARAM lParam = PARAM_NONE, INT iImage = IMAGE_NONE, DWORD dwState = STATE_NONE, DWORD dwStateMask = STATE_NONE);
01033
01034 //protected:
01035   //data
01036 };
01037
01038
01039
01040 //////////////////////////////////////////////////////////////////////////
01041 // CCmdLineLite
01042 //
01043 //////////////////////////////////////////////////////////////////////////
01044 class CCmdLineLite
01045 {
01046 protected:
01047
01048   // Attributes
01049 public:
01050   CCmdLineLite();
01051   virtual ~CCmdLineLite();
01052
01053 // Operations
01054   virtual void ResetParser();
01055
01056 //protected:
01057   virtual void ParseParam(WCHAR* pwszParam, BOOL bFlag, BOOL bLast );
01058   virtual BOOL ParseCommandLine();
01059   virtual BOOL ParseFile(WCHAR* pwszFileName);
01060
01061   WCHAR m_wszLastCmd[MAX_QUERY_LEN];
01062 };
01063
01064
01065 /////////////////////////////////////////////////////////////////////
01066 // CWaitCursor
01067 //
01068 /////////////////////////////////////////////////////////////////////
01069 class CWaitCursor
01070 {
01071 public:
01072   //Constructors
01073   CWaitCursor();
01074   virtual ~CWaitCursor();
01075
01076   //Helpers
01077   void WaitCursor();
01078   void RestoreCursor();
01079
01080 protected:
01081   //Data
01082   HCURSOR m_hPrevCursor;
01083 };
01084
01085
01086 static const WCHAR UNICODE_BYTE_ORDER_MARK = 0xFEFF;
01087 /////////////////////////////////////////////////////////////////////
01088 // CFileLite
01089 //
01090 /////////////////////////////////////////////////////////////////////
01091 class CFileLite
01092 {
01093 public:
01094   //constructor
01095   CFileLite();
01096   virtual ~CFileLite();
01097
01098   //Open
01099   virtual HRESULT Open(LPCWSTR pwszFileName, DWORD dwDesiredAccess = GENERIC_READ, DWORD dwShareMode = FILE_SHARE_READ, DWORD dwCreationDisposition = OPEN_EXISTING, BOOL fDisplayDialog = FALSE, HWND hWndParent = NULL);
01100   virtual HRESULT Open(LPCSTR pszFileName, DWORD dwDesiredAccess = GENERIC_READ, DWORD dwShareMode = FILE_SHARE_READ, DWORD dwCreationDisposition = OPEN_EXISTING, BOOL fDisplayDialog = FALSE, HWND hWndParent = NULL);
01101
01102   //Low Level Byte Operations
01103   virtual HRESULT ReadBytes(ULONG cbBytes, BYTE* rgBytes, ULONG* pcbRead = NULL);
01104   virtual HRESULT WriteBytes(ULONG cBytes, BYTE* rgBytes, ULONG* pcbWritten = NULL);
01105
01106   //Read
01107   virtual HRESULT Read(ULONG cbBytes, WCHAR* pwszText, ULONG* pcbRead = NULL);
01108   virtual HRESULT Read(ULONG cbBytes, CHAR* pszText, ULONG* pcbRead = NULL);
01109
01110   //Write
01111   virtual HRESULT Write(LPCWSTR pwszText, ULONG* pcbWritten = NULL);
01112   virtual HRESULT Write(LPCSTR pszText, ULONG* pcbWritten = NULL);
01113   virtual HRESULT WriteQuoted(LPCWSTR pwszText);
01114   virtual HRESULT WriteFormat(LPCWSTR pwszFmt, ...);
01115
01116   //Helpers
01117   virtual HRESULT Flush();
01118   virtual HRESULT Close();
01119   virtual DWORD Seek(LONG lDistanceToMove, DWORD dwOrigin);
01120
01121   //Interface
01122   virtual BOOL  IsOpen()              { return m_hFile != NULL; }
01123   virtual BOOL    IsEOF()               { return m_bEOF;      }
01124
01125   //Unicode vs. MBCS
01126   virtual BOOL  IsUnicode()             { return m_bUnicode;    }
01127   virtual void  SetUnicode(BOOL bUnicode = TRUE)  { m_bUnicode = bUnicode;  }
01128   virtual BOOL  DetermineUnicode();
01129
01130 private:
01131   //Data
01132   HANDLE  m_hFile;
01133   BOOL  m_bEOF;
01134
01135   BOOL  m_bUnicode;
01136   ULONG m_cbWritten;
01137   ULONG m_cbRead;
01138 };
01139
01140
01141 /////////////////////////////////////////////////////////////////////
01142 // CDropObject
01143 //
01144 /////////////////////////////////////////////////////////////////////
01145 class CDropObject : public IDataObject
01146 {
01147 public:
01148   //constructor
01149   CDropObject();
01150   virtual ~CDropObject();
01151
01152   //IUnknown
01153   STDMETHODIMP      QueryInterface(REFIID riid, void** ppvObject);
01154     STDMETHODIMP_(ULONG)  AddRef();
01155     STDMETHODIMP_(ULONG)  Release();
01156
01157   //Interface
01158     STDMETHODIMP      GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium);
01159     STDMETHODIMP      GetDataHere(FORMATETC* pformatetc, STGMEDIUM* pmedium);
01160     STDMETHODIMP      QueryGetData(FORMATETC* pformatetc);
01161     STDMETHODIMP      GetCanonicalFormatEtc(FORMATETC* pformatectIn, FORMATETC* pformatetcOut);
01162     STDMETHODIMP      SetData(FORMATETC* pformatetc, STGMEDIUM* pmedium, BOOL fRelease);
01163     STDMETHODIMP      EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc);
01164     STDMETHODIMP      DAdvise(FORMATETC* pformatetc, DWORD advf, IAdviseSink* pAdvSink, DWORD* pdwConnection);
01165     STDMETHODIMP      DUnadvise(DWORD dwConnection);
01166     STDMETHODIMP      EnumDAdvise(IEnumSTATDATA** ppenumAdvise);
01167
01168 private:
01169   //Data
01170
01171   //IUnknown
01172   ULONG         m_cRef;
01173 };
01174
01175
01176 /////////////////////////////////////////////////////////////////////
01177 // CDropSource
01178 //
01179 /////////////////////////////////////////////////////////////////////
01180 class CDropSource : public IDropSource
01181 {
01182 public:
01183   //constructor
01184   CDropSource();
01185   virtual ~CDropSource();
01186
01187   //IUnknown
01188   STDMETHODIMP      QueryInterface(REFIID riid, void** ppvObject);
01189     STDMETHODIMP_(ULONG)  AddRef();
01190     STDMETHODIMP_(ULONG)  Release();
01191
01192   //Interface
01193     STDMETHODIMP      QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState);
01194     STDMETHODIMP      GiveFeedback(DWORD dwEffect);
01195
01196 private:
01197   //Data
01198
01199   //IUnknown
01200   ULONG         m_cRef;
01201 };
01202
01203
01204 /////////////////////////////////////////////////////////////////////
01205 // CDropTarget
01206 //
01207 /////////////////////////////////////////////////////////////////////
01208 class CDropTarget : public IDropTarget
01209 {
01210 public:
01211   //constructor
01212   CDropTarget();
01213   virtual ~CDropTarget();
01214
01215   //IUnknown
01216   STDMETHODIMP      QueryInterface(REFIID riid, void** ppvObject);
01217     STDMETHODIMP_(ULONG)  AddRef();
01218     STDMETHODIMP_(ULONG)  Release();
01219
01220   //Interface
01221     STDMETHODIMP      DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
01222     STDMETHODIMP      DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
01223     STDMETHODIMP      DragLeave();
01224     STDMETHODIMP      Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
01225
01226 private:
01227   //Data
01228
01229   //IUnknown
01230   ULONG         m_cRef;
01231 };
01232
01233
01234
01235 ///////////////////////////////////////////////////////////////////////////////
01236 // COleClient
01237 //
01238 ///////////////////////////////////////////////////////////////////////////////
01239 class COleClient : public CWndLite,
01240 //          public IDocHostUIHandler,
01241 //          public IDocHostShowUI,
01242           public IOleClientSite,
01243           public IOleInPlaceSite,
01244           public IDispatch
01245 {
01246 public:
01247   //Constructors
01248   COleClient(HWND hWndParent = NULL, UINT nID = 0)
01249     : CWndLite(hWndParent, nID)
01250   {
01251     m_cRef = 0;
01252   }
01253   virtual ~COleClient()
01254   {
01255   }
01256
01257   //IUnknown
01258   STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject)
01259   {
01260     *ppvObject = NULL;
01261      if(riid == IID_IUnknown)
01262        *ppvObject = (IOleClientSite*)this;
01263      else if(riid == IID_IDispatch)
01264        *ppvObject = (IDispatch*)this;
01265      else if(riid == IID_IOleClientSite)
01266        *ppvObject = (IOleClientSite*)this;
01267      else if(riid == IID_IOleInPlaceSite)
01268        *ppvObject = (IOleInPlaceSite*)this;
01269      else if(riid == IID_IOleWindow)
01270        *ppvObject = (IOleWindow*)this;
01271      else if(riid == DIID_DWebBrowserEvents2)
01272        *ppvObject = (IDispatch*)this;
01273     else
01274        return E_NOINTERFACE;
01275
01276      return S_OK;
01277   }
01278
01279     STDMETHOD_(ULONG, AddRef)()
01280   {
01281     return ++m_cRef;
01282   }
01283
01284     STDMETHOD_(ULONG, Release)()
01285   {
01286     return --m_cRef;
01287   }
01288
01289   //IDispatch
01290   STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
01291   {
01292     return E_NOTIMPL;
01293   }
01294   STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
01295   {
01296     return E_NOTIMPL;
01297   }
01298   STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
01299     LCID lcid, DISPID* rgdispid)
01300   {
01301     return E_NOTIMPL;
01302   }
01303
01304   STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
01305                                DISPPARAMS* pDispParams, VARIANT* pvarResult,
01306                                EXCEPINFO*  pExcepInfo,  UINT* puArgErr)
01307
01308   {
01309     return E_NOTIMPL;
01310   }
01311
01312   //IOleClientSite
01313    STDMETHOD(SaveObject)(void)
01314   {
01315       return S_OK;
01316   }
01317
01318    STDMETHOD(GetMoniker)(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
01319   {
01320     ATLTRACENOTIMPL(_T("IOleClientSite::GetMoniker"));
01321   }
01322
01323    STDMETHOD(GetContainer)(IOleContainer **ppContainer)
01324   {
01325     ATLTRACENOTIMPL(_T("IOleClientSite::GetContainer"));
01326   }
01327
01328    STDMETHOD(ShowObject)(void)
01329   {
01330       return S_OK;
01331   }
01332
01333    STDMETHOD(OnShowWindow)(BOOL fShow)
01334   {
01335       return S_OK;
01336   }
01337
01338    STDMETHOD(RequestNewObjectLayout)(void)
01339   {
01340       return S_OK;
01341   }
01342
01343  // IOleWindow
01344    STDMETHOD(GetWindow)(HWND *phwnd)
01345   {
01346      *phwnd = m_hWnd;
01347       return S_OK;
01348   }
01349
01350    STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode)
01351   {
01352       return S_OK;
01353   }
01354
01355  // IOleInPlaceSite
01356    STDMETHOD(CanInPlaceActivate)(void)
01357   {
01358      return S_OK;
01359   }
01360
01361    STDMETHOD(OnInPlaceActivate)(void)
01362   {
01363     return S_OK;
01364   }
01365
01366    STDMETHOD(OnUIActivate)(void)
01367   {
01368       return S_OK;
01369   }
01370
01371    STDMETHOD(GetWindowContext)(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc,
01372                               LPRECT lprcPosRect, LPRECT lprcClipRect,
01373                                LPOLEINPLACEFRAMEINFO lpFrameInfo)
01374   {
01375     GetClientRect(m_hWnd, lprcPosRect);
01376     GetClientRect(m_hWnd, lprcClipRect);
01377     return S_OK;
01378   }
01379
01380    STDMETHOD(Scroll)(SIZE scrollExtant)
01381   {
01382       return S_OK;
01383   }
01384
01385    STDMETHOD(OnUIDeactivate)(BOOL fUndoable)
01386   {
01387       return S_OK;
01388   }
01389
01390    STDMETHOD(OnInPlaceDeactivate)( void)
01391   {
01392     return S_OK;
01393   }
01394
01395    STDMETHOD(DiscardUndoState)( void)
01396   {
01397       return S_OK;
01398   }
01399
01400    STDMETHOD(DeactivateAndUndo)( void)
01401   {
01402       return S_OK;
01403   }
01404
01405    STDMETHOD(OnPosRectChange)(LPCRECT lprcPosRect)
01406   {
01407       return S_OK;
01408   }
01409
01410 protected:
01411   //Data
01412
01413   //IUnknown
01414   ULONG         m_cRef;
01415 };
01416
01417
01418
01419 ///////////////////////////////////////////////////////////////////////////////
01420 // CWebBrowser
01421 //
01422 ///////////////////////////////////////////////////////////////////////////////
01423 class CWebBrowser : public COleClient
01424 {
01425 public:
01426   //Constructors
01427   CWebBrowser(HWND hWndParent = NULL, UINT nID = 0)
01428     : COleClient(hWndParent, nID)
01429   {
01430   }
01431   virtual ~CWebBrowser()
01432   {
01433   }
01434
01435   //Helpers
01436   virtual BOOL  OnInitialUpdate()
01437   {
01438     HRESULT hr = S_OK;
01439     DWORD dwCookie = 0;
01440
01441     //Create the WebBrowser Control
01442     m_spOleObject.Release();
01443     TESTC(hr = m_spOleObject.CoCreateInstance(CLSID_WebBrowser));
01444
01445     //Obtain the WebBrowser interface
01446     m_spWebBrowser2.Release();
01447     TESTC(hr = m_spOleObject->QueryInterface(&m_spWebBrowser2));
01448
01449     //Advise our liseners
01450     TESTC(hr = AtlAdvise(m_spWebBrowser2, (IDispatch*)this, DIID_DWebBrowserEvents2, &dwCookie));
01451
01452     //Set the client to be this window
01453     TESTC(hr = m_spOleObject->SetClientSite(this));
01454
01455   CLEANUP:
01456     return SUCCEEDED(hr);
01457   }
01458
01459   virtual HRESULT Show(LONG iVerb =  OLEIVERB_INPLACEACTIVATE)
01460   {
01461     HRESULT hr = S_OK;
01462     MSG msg;
01463     RECT rect;
01464     GetClientRect(m_hWnd, &rect);
01465
01466     //OLEIVERB_HIDE
01467     TESTC(hr = m_spOleObject->DoVerb(iVerb, &msg, this, 0, m_hWnd, &rect));
01468
01469   CLEANUP:
01470     return hr;
01471   }
01472
01473   virtual HRESULT Navigate(LPWSTR pwszURL)
01474   {
01475     HRESULT hr = S_OK;
01476
01477     //Navigate
01478     TESTC(hr = m_spWebBrowser2->Navigate(pwszURL, NULL, NULL, NULL, NULL));
01479
01480     //Show
01481     TESTC(hr = Show());
01482
01483   CLEANUP:
01484     return hr;
01485   }
01486
01487   virtual HRESULT Load(IStream* pIStream)
01488   {
01489     HRESULT hr = S_OK;
01490
01491     //We need a defualt page
01492     TESTC(hr = Navigate(L"about:blank"));
01493
01494     //Save the stream for later use, since we have to wait for DocumentComplete
01495     //Before we can finish loading the stream.  Se OnDocumentComplete for the remainder of
01496     //this function...
01497     m_spLoadStream = pIStream;
01498
01499   CLEANUP:
01500     return hr;
01501   }
01502
01503   //
01504   // IDispatch Methods
01505   //
01506   STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
01507                    DISPPARAMS* pDispParams, VARIANT* pvarResult,
01508                    EXCEPINFO*  pExcepInfo,  UINT* puArgErr)
01509   {
01510      switch (dispidMember)
01511      {
01512       case DISPID_DOWNLOADBEGIN:
01513        OnDownloadBegin();
01514        break;
01515
01516       case DISPID_DOWNLOADCOMPLETE:
01517        OnDownloadComplete();
01518        break;
01519
01520       case DISPID_DOCUMENTCOMPLETE:
01521        OnDocumentComplete();
01522        break;
01523
01524       case DISPID_NAVIGATECOMPLETE:
01525        OnNavigateComplete();
01526        break;
01527
01528     case DISPID_AMBIENT_DLCONTROL:
01529       OnDownloadControl();
01530       break;
01531
01532     default:
01533        return DISP_E_MEMBERNOTFOUND;
01534      }
01535
01536      return S_OK;
01537   }
01538
01539   //Dispatched Messages
01540   virtual BOOL  OnDownloadBegin()
01541   {
01542     return FALSE;
01543   }
01544   virtual BOOL  OnDownloadComplete()
01545   {
01546     return FALSE;
01547   }
01548   virtual BOOL  OnDocumentComplete()
01549   {
01550     HRESULT hr = S_OK;
01551
01552     //Default Implementation
01553     if(m_spLoadStream)
01554     {
01555       CComPtr<IDispatch>        spDocument;
01556       CComPtr<IPersistStreamInit>   spPersistStream;
01557
01558
01559       CComPtr<IStream>        spStream;
01560         CHAR szHTMLText[] = "<html><h1>Stream Test</h1><p>This HTML content is being loaded from a stream.</html>";
01561
01562
01563       HGLOBAL hHTMLText = GlobalAlloc(GPTR, lstrlen(szHTMLText)+1);
01564       TESTC(hr = CreateStreamOnHGlobal(hHTMLText, TRUE, &spStream));
01565
01566         //Obtain the document
01567       TESTC(hr = m_spWebBrowser2->get_Document(&spDocument));
01568       TESTC(hr = spDocument->QueryInterface(&spPersistStream));
01569
01570       //Load the passed in stream
01571       TESTC(hr = spPersistStream->InitNew());
01572       TESTC(hr = spPersistStream->Load(/*m_spLoadStream*/spStream));
01573 //      TESTC(hr = m_spWebBrowser2->Refresh());
01574
01575       //We are now done with the stream
01576       m_spLoadStream.Release();
01577     }
01578
01579   CLEANUP:
01580     return SUCCEEDED(hr);
01581   }
01582   virtual BOOL  OnNavigateComplete()
01583   {
01584     return FALSE;
01585   }
01586   virtual BOOL  OnDownloadControl()
01587   {
01588     return FALSE;
01589   }
01590
01591 //protected:
01592   //Data
01593    CComPtr<IOleObject>    m_spOleObject;
01594    CComPtr<IWebBrowser2>  m_spWebBrowser2;
01595    CComPtr<IStream>     m_spLoadStream;
01596 };
01597
01598
01599
01600 /////////////////////////////////////////////////////////////////////
01601 // _NoAddRefReleaseQIOnSmartPtr
01602 //
01603 // Make sure all calls go through the object, not overloaded operators.
01604 // This serves two purposes, firs tit prevent users from using spComPtr->Release(),
01605 // otherwise they have release the internal pointer, but our object still has a reference.
01606 // Second it ensures all calls (AddRef, Release, QI), actually go through the class
01607 // so we can correctly trace all (IUnknown) calls...
01608 /////////////////////////////////////////////////////////////////////
01609 template <class T>
01610 class _NoAddRefReleaseQIOnSmartPtr : public T
01611 {
01612   private:
01613     STDMETHOD_(ULONG, AddRef)()=0;
01614     STDMETHOD_(ULONG, Release)()=0;
01615     STDMETHOD_(HRESULT, QI)(REFIID, void**)=0;
01616 };
01617
01618
01619 /////////////////////////////////////////////////////////////////////
01620 // CSmartPtr
01621 //
01622 // CComPtr
01623 /////////////////////////////////////////////////////////////////////
01624 template <class T>
01625 class CSmartPtr
01626 {
01627 public:
01628   //Constructors
01629   CSmartPtr()
01630   {
01631     m_p = NULL;
01632   }
01633   ~CSmartPtr()
01634   {
01635     Release();
01636   }
01637
01638   //Inlines
01639   inline  REFIID  iid() { return __uuidof(T); }
01640
01641   //Operators
01642   _NoAddRefReleaseQIOnSmartPtr<T>* operator->() const
01643   {
01644     ASSERT(m_p);
01645     return (_NoAddRefReleaseQIOnSmartPtr<T>*)m_p;
01646   }
01647
01648   //The assert on operator& usually indicates a bug.  If this is really
01649   //what is needed, however, take the address of the p member explicitly.
01650   T** operator&()
01651   {
01652     ASSERT(!m_p);
01653     return &m_p;
01654   }
01655
01656   operator T*() const
01657   {
01658     return (T*)m_p;
01659   }
01660
01661   bool operator!() const
01662   {
01663     return (m_p == NULL);
01664   }
01665
01666   bool operator==(T* pT) const
01667   {
01668     return m_p == pT;
01669   }
01670
01671   //IUnknown
01672   ULONG AddRef()
01673   {
01674     ASSERT(m_p);
01675     return m_p->AddRef();
01676   }
01677
01678   ULONG Release()
01679   {
01680     ULONG ulRefCount = 0;
01681
01682     if(m_p)
01683     {
01684       ulRefCount = m_p->Release();
01685       m_p = NULL;
01686     }
01687
01688     return ulRefCount;
01689   }
01690
01691   template <class Q> HRESULT QueryInterface(Q** pp) const
01692   {
01693     ASSERT(pp && !*pp);
01694     return m_p->QueryInterface(__uuidof(Q), (void**)pp);
01695   }
01696
01697   //Helpers
01698   HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
01699   {
01700     ASSERT(!m_p);
01701     return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&m_p);
01702   }
01703
01704   HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
01705   {
01706     CLSID clsid;
01707     HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
01708
01709     if(SUCCEEDED(hr))
01710       hr = CoCreateInstance(clsid, pUnkOuter, dwClsContext);
01711     return hr;
01712   }
01713
01714 protected:
01715   T*  m_p;
01716 };
01717
01718
01719 /////////////////////////////////////////////////////////////////////
01720 // CSmartPtrTrace
01721 //
01722 /////////////////////////////////////////////////////////////////////
01723 template <class T>
01724 class CSmartPtrTrace  : public CSmartPtr<T>
01725 {
01726 public:
01727   //Overload
01728   ULONG AddRef()
01729   {
01730     //Delegate
01731     ULONG ulRefCount = CSmartPtr<T>::AddRef();
01732
01733     //Trace the call
01734     Write(GetInterfaceName(__uuidof(T)));
01735     WriteLine(L"::AddRef() - ");
01736     return ulRefCount;
01737   }
01738
01739   //Overload
01740   ULONG Release()
01741   {
01742     //Delegate
01743     ULONG ulRefCount = CSmartPtr<T>::Release();
01744
01745     //Trace the call
01746     Write(GetInterfaceName(__uuidof(T)));
01747     WriteLine(L"::Release() - ");
01748     return ulRefCount;
01749   }
01750
01751   //Overload
01752   template <class Q> HRESULT QueryInterface(Q** pp) const
01753   {
01754     //Delegate
01755     HRESULT hr = CSmartPtr<T>::QueryInterface(pp);
01756
01757     //Trace the call
01758 //    CSmartPtrTrace<T>::Write(GetInterfaceName(__uuidof(T)));
01759 //    CSmartPtrTrace<T>::Write(L"::QueryInterface(");
01760 //    CSmartPtrTrace<T>::Write(GetInterfaceName(__uuidof(Q)));
01761 //    CSmartPtrTrace<T>::WriteLine(L") - ");
01762     return hr;
01763   }
01764
01765   //Helpers
01766   HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
01767   {
01768     //Delegate
01769     HRESULT hr = CSmartPtr<T>::CoCreateInstance(rclsid, pUnkOuter, dwClsContext);
01770
01771     //Trace the call
01772 //    WriteLine(L"CoCreateInstance(..." WIDESTRING(__uuidof(T)) "...");
01773     return hr;
01774   }
01775
01776   inline void Write(LPCWSTR pwsz)
01777   {
01778     TRACE(pwsz);
01779 //    CTrace* pCTrace = GetTrace();
01780 //    if(pCTrace)
01781 //      pCTrace->OutputText(0, 0, pwsz);
01782   }
01783
01784   inline void WriteLine(LPCWSTR pwsz)
01785   {
01786     Write(pwsz);
01787     Write(wWndEOL);
01788 //    CTrace* pCTrace = GetTrace();
01789 //    if(pCTrace)
01790 //    {
01791 //      pCTrace->OutputText(0, 0, pwsz);
01792 //      pCTrace->OutputLineEnd();
01793 //    }
01794   }
01795 };
01796
01797
01798 ///////////////////////////////////////////////////////////////////////////////
01799 // CXmlDOM
01800 //
01801 ///////////////////////////////////////////////////////////////////////////////
01802 class CXmlDOM
01803 {
01804 public:
01805   //Constructors
01806   CXmlDOM();
01807   virtual ~CXmlDOM();
01808
01809   //Helpers
01810   virtual HRESULT Create()
01811   {
01812     HRESULT hr = S_OK;
01813
01814     //Create the DOM
01815     TESTC(hr = m_spXMLDocument.CoCreateInstance(CLSID_DOMDocument));
01816
01817     //TODO: Why is the DOM Asynch by default?
01818     //This makes it so an app has to register to events just to know when its complete...
01819     //We will make the Document Synchquential unless the user makes it asynch before they call load...
01820     TESTC(hr = m_spXMLDocument->put_async(VARIANT_FALSE));
01821
01822   CLEANUP:
01823     return hr;
01824   }
01825
01826   virtual HRESULT LoadStream(IUnknown* pIUnkStream)
01827   {
01828     //Delegate
01829     CComVariant varXML = pIUnkStream;
01830     return LoadFile(&varXML);
01831   }
01832
01833   virtual HRESULT LoadXML(BSTR bstrXML)
01834   {
01835     HRESULT hr = S_OK;
01836     VARIANT_BOOL bSuccessful = VARIANT_FALSE;
01837
01838     //Load the document
01839     TESTC(hr = m_spXMLDocument->loadXML(bstrXML, &bSuccessful));
01840
01841     if(!bSuccessful)
01842       TESTC(hr = E_FAIL);
01843
01844   CLEANUP:
01845     return hr;
01846   }
01847
01848   virtual HRESULT LoadFile(VARIANT* pVariant)
01849   {
01850     ASSERT(pVariant);
01851     HRESULT hr = S_OK;
01852     VARIANT_BOOL bSuccessful = VARIANT_FALSE;
01853
01854     //Load the document
01855     TESTC(hr = m_spXMLDocument->load(*pVariant, &bSuccessful));
01856
01857     if(!bSuccessful)
01858       TESTC(hr = E_FAIL);
01859
01860   CLEANUP:
01861     return hr;
01862   }
01863
01864   virtual HRESULT Save(BSTR bstrFileName)
01865   {
01866     //Prevent a copy of the BSTR
01867     CComVariant varFileName;
01868     varFileName.vt    = VT_BSTR;
01869     varFileName.bstrVal = bstrFileName;
01870
01871     //Delegate
01872     HRESULT hr = Save(&varFileName);
01873
01874     varFileName.bstrVal = NULL;
01875     return hr;
01876   }
01877
01878   virtual HRESULT Save(VARIANT* pVariant)
01879   {
01880     ASSERT(pVariant);
01881     HRESULT hr = S_OK;
01882
01883     //Save the XML
01884     TESTC(hr = m_spXMLDocument->save(*pVariant));
01885
01886   CLEANUP:
01887     return hr;
01888   }
01889
01890   virtual HRESULT PrintNode(IXMLDOMNode* spNode, CConsole& rConsole, ULONG ullevel = 0);
01891   virtual HRESULT PrintAttributes(IXMLDOMNode* spNode, CConsole& rConsole);
01892
01893 //protected:
01894   //Data
01895   CSmartPtr<IXMLDOMDocument>  m_spXMLDocument;
01896 };
01897
01898
01899
01900 /////////////////////////////////////////////////////////////////////
01901 // CComWSTR
01902 //
01903 /////////////////////////////////////////////////////////////////////
01904 class CComWSTR
01905 {
01906 protected:
01907   //Data
01908   WCHAR*  m_str;
01909
01910 private:
01911   //NOTE: Don't use Copy Constructors or Operators - Very DANGEROUS!
01912   //We have already have to track down a bug where SAFE_ALLOC(cwstr, WCHAR, 1),
01913   //corrupted memory later one, since it really means cwstr = "garbage-no-terminator-memory"
01914   CComWSTR(LPCOLESTR pSrc)        { ASSERT(FALSE);  }
01915   CComWSTR(const CComWSTR& src)     { ASSERT(FALSE);  }
01916 //  CComWSTR& operator=(const CComWSTR& src){ ASSERT(FALSE);  }
01917 //  CComWSTR& operator=(LPCOLESTR pSrc)   { ASSERT(FALSE);  }
01918
01919 public:
01920   //Constructors
01921   CComWSTR()
01922   {
01923     m_str = NULL;
01924   }
01925   virtual ~CComWSTR()
01926   {
01927     Empty();
01928   }
01929   void Empty()
01930   {
01931     SAFE_FREE(m_str);
01932   }
01933   CComWSTR& operator+=(LPCOLESTR pSrc)
01934   {
01935     Append(pSrc);
01936     return *this;
01937   }
01938   bool operator!() const
01939   {
01940     return (m_str == NULL);
01941   }
01942   WCHAR** operator&()
01943   {
01944     ASSERT(m_str == NULL);
01945     return &m_str;
01946   }
01947
01948   //Cast operator - so we can use this class in instances of just WCHAR
01949   operator WCHAR*() const
01950   {
01951     return m_str;
01952   }
01953
01954   //Helpers
01955   unsigned int Length() const
01956   {
01957     return (m_str == NULL) ? 0 : wcslen(m_str);
01958   }
01959   WCHAR* Copy() const
01960   {
01961     return wcsDuplicate(m_str);
01962   }
01963   HRESULT CopyFrom(LPCOLESTR pSrc)
01964   {
01965     Empty();
01966     m_str = wcsDuplicate(pSrc);
01967     return S_OK;
01968   }
01969
01970   //Non allocating functions - quick and easy attaching to exiting strings
01971   void Attach(WCHAR* src)
01972   {
01973     ASSERT(m_str == NULL);
01974     m_str = src;
01975   }
01976   WCHAR* Detach()
01977   {
01978     WCHAR* s = m_str;
01979     m_str = NULL;
01980     return s;
01981   }
01982
01983   //Appending
01984   HRESULT Append(LPCOLESTR pSrc)
01985   {
01986     return Append(pSrc, pSrc ? wcslen(pSrc) : 0);
01987   }
01988   HRESULT Append(LPCOLESTR pSrc, int nLen)
01989   {
01990     HRESULT hr = S_OK;
01991
01992     if(nLen)
01993     {
01994       ASSERT(pSrc);
01995       int n1 = Length();
01996
01997       //Realloc the current string
01998       SAFE_REALLOC(m_str, WCHAR, n1+nLen+1);
01999       memcpy(m_str+n1, pSrc, nLen*sizeof(WCHAR));
02000       m_str[n1+nLen] = NULL;
02001     }
02002
02003   CLEANUP:
02004     return hr;
02005   }
02006 };
02007
02008
02009 /////////////////////////////////////////////////////////////////////
02010 // ListView Helpers
02011 //
02012 /////////////////////////////////////////////////////////////////////
02013 INDEX   LV_InsertColumn(HWND hWnd, INDEX iColumn, WCHAR* wszName, INT iImage = IMAGE_NONE);
02014 INDEX   LV_InsertItem(HWND hWnd, INDEX iItem, INDEX iSubItem, WCHAR* wszName, LPARAM lParam = PARAM_NONE, INT iImage = IMAGE_NONE, UINT iState = IMAGE_NONE, UINT iStateMask = IMAGE_NONE);
02015
02016 BOOL    LV_SetItemState(HWND hWnd, INDEX iItem, INDEX iSubItem, UINT iState, UINT iStateMask);
02017 BOOL    LV_SetItemText(HWND hWnd, INDEX iItem, INDEX iSubItem, WCHAR* pwszName);
02018 BOOL    LV_SetItemImage(HWND hWnd, INDEX iItem, INDEX iSubItem, INT iImage);
02019 BOOL    LV_SetItemParam(HWND hWnd, INDEX iItem, INDEX iSubItem, LPARAM lParam);
02020
02021 INDEX   LV_GetItemText(HWND hWnd, INDEX iItem, INDEX iSubItem, WCHAR* pwszName, ULONG ulMaxSize);
02022 UINT    LV_GetItemState(HWND hWnd, INDEX iItem, UINT iMask = 0);
02023 INT     LV_GetItemImage(HWND hWnd, INDEX iItem, INDEX iSubItem);
02024 LPARAM    LV_GetItemParam(HWND hWnd, INDEX iItem, INDEX iSubItem);
02025
02026 INDEX   LV_FindItem(HWND hWnd, LPARAM lParam, INDEX iStart = -1);
02027
02028 LRESULT   LV_GetSelItems(HWND hWnd, INDEX* pcItems = NULL, INDEX** prgSelItems = NULL, LPARAM** prgSelParams = NULL);
02029 LRESULT   LV_GetAllItems(HWND hWnd, INDEX* pcItems = NULL, INDEX** prgItems = NULL, LPARAM** prgParams = NULL);
02030
02031
02032 /////////////////////////////////////////////////////////////////////
02033 // TreeView Helpers
02034 //
02035 /////////////////////////////////////////////////////////////////////
02036 HTREEITEM TV_InsertItem(HWND hWnd, HTREEITEM hParent, HTREEITEM hInsAfter, WCHAR* wszName, LPARAM lParam = 0, INT iImage = 0, INT iSelectedImage = 0, UINT iState = 0, UINT iStateMask = 0);
02037
02038 BOOL    TV_GetItemText(HWND hWnd, HTREEITEM hItem, WCHAR* pwszBuffer, LONG ulMaxSize);
02039 LPARAM    TV_GetItemParam(HWND hWnd, HTREEITEM hItem);
02040 BOOL    TV_SetItemState(HWND hWnd, HTREEITEM hItem, UINT iState, UINT iStateMask);
02041
02042 HTREEITEM TV_FindItem(HWND hWnd, HTREEITEM hParent, WCHAR* wszName);
02043
02044
02045
02046 #endif //__CDIALOGLITE_H__
Generated on Wed Nov 13 2024 16:52:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CReceiveWaitDialog Member List

This is the complete list of members for CReceiveWaitDialog, including all inherited members.
CenterWindow() | CReceiveWaitDialog |
CReceiveWaitDialog(CWnd *pParent=NULL) | CReceiveWaitDialog |
DoDataExchange(CDataExchange *pDX) | CReceiveWaitDialog | [protected, virtual]
IDD enum value | CReceiveWaitDialog |
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/customdial/resource.h Source File

  • NetDS
  • Ras
  • customdial

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by customdial.rc
00004 //
00005 #define IDD_CUSTOMDIALDLG               101
00006 #define IDD_CUSTOMENTRYDLG              102
00007 #define IDC_EDIT_PHONENO                1000
00008 #define IDC_EDIT_USERNAME               1001
00009 #define IDC_EDIT_PASSWORD               1002
00010 #define IDC_EDIT_ENTRYNAME              1002
00011 #define IDC_EDIT_DOMAIN                 1003
00012 #define IDC_LIST_MODEMS                 1003
00013
00014 // Next default values for new objects
00015 //
00016 #ifdef APSTUDIO_INVOKED
00017 #ifndef APSTUDIO_READONLY_SYMBOLS
00018 #define _APS_NEXT_RESOURCE_VALUE        104
00019 #define _APS_NEXT_COMMAND_VALUE         40001
00020 #define _APS_NEXT_CONTROL_VALUE         1004
00021 #define _APS_NEXT_SYMED_VALUE           101
00022 #endif
00023 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cerror.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cerror.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CDATASOURCE.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 /////////////////////////////////////////////////////////////////
00019 // CError::CError
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CError::CError(CMainWindow* pCMainWindow)
00023   : CBase(eCError, pCMainWindow, NULL)
00024 {
00025   //OLE DB Interfaces
00026   m_pIErrorInfo       = NULL;   //Error interface
00027   m_pIErrorRecords      = NULL;   //Error interface
00028 }
00029
00030 /////////////////////////////////////////////////////////////////
00031 // CError::~CError
00032 //
00033 /////////////////////////////////////////////////////////////////
00034 CError::~CError()
00035 {
00036   ReleaseObject(0);
00037 }
00038
00039
00040 /////////////////////////////////////////////////////////////////
00041 // IUnknown** CError::GetInterfaceAddress
00042 //
00043 /////////////////////////////////////////////////////////////////
00044 IUnknown** CError::GetInterfaceAddress(REFIID riid)
00045 {
00046   HANDLE_GETINTERFACE(IErrorInfo);
00047   HANDLE_GETINTERFACE(IErrorRecords);
00048
00049   //Otherwise delegate
00050   return CBase::GetInterfaceAddress(riid);
00051 }
00052
00053
00054 /////////////////////////////////////////////////////////////////
00055 // HRESULT CError::AutoRelease
00056 //
00057 /////////////////////////////////////////////////////////////////
00058 HRESULT CError::AutoRelease()
00059 {
00060   //Error
00061   RELEASE_INTERFACE(IErrorInfo);
00062   RELEASE_INTERFACE(IErrorRecords);
00063
00064   //Delegate
00065   return CBase::AutoRelease();
00066 }
00067
00068
00069 /////////////////////////////////////////////////////////////////
00070 // HRESULT CError::AutoQI
00071 //
00072 /////////////////////////////////////////////////////////////////
00073 HRESULT CError::AutoQI(DWORD dwCreateOpts)
00074 {
00075   //Delegate First so we have base interfaces
00076   CBase::AutoQI(dwCreateOpts);
00077
00078   //[MANDATORY]
00079   if(dwCreateOpts & CREATE_QI_MANDATORY)
00080   {
00081     OBTAIN_INTERFACE(IErrorInfo);
00082     OBTAIN_INTERFACE(IErrorRecords);
00083   }
00084
00085   //[OPTIONAL]
00086   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00087   {
00088   }
00089
00090   return S_OK;
00091 }
00092
00093
00094 /////////////////////////////////////////////////////////////////////////////
00095 // CError::GetObjectDesc
00096 //
00097 /////////////////////////////////////////////////////////////////////////////
00098 WCHAR* CError::GetObjectDesc()
00099 {
00100   if(!m_strObjectDesc)
00101   {
00102     CComBSTR bstr;
00103     if(SUCCEEDED(GetDescription(&bstr)) && bstr)
00104       m_strObjectDesc.CopyFrom(bstr);
00105   }
00106
00107   return m_strObjectDesc;
00108 }
00109
00110
00111 /////////////////////////////////////////////////////////////////
00112 // HRESULT CError::GetDescription
00113 //
00114 /////////////////////////////////////////////////////////////////
00115 HRESULT CError::GetDescription(BSTR* pbstrDescription)
00116 {
00117   HRESULT hr = S_OK;
00118
00119   if(m_pIErrorInfo)
00120   {
00121     //IErrorInfo::GetDescription
00122     XTEST(hr = m_pIErrorInfo->GetDescription(pbstrDescription));
00123     TRACE_METHOD(hr, L"IErrorInfo::GetDescription(&\"%s\")", pbstrDescription ? *pbstrDescription : NULL);
00124   }
00125
00126   return hr;
00127 }
00128
00129
00130 /////////////////////////////////////////////////////////////////
00131 // HRESULT CError::GetSource
00132 //
00133 /////////////////////////////////////////////////////////////////
00134 HRESULT CError::GetSource(BSTR* pbstrSource)
00135 {
00136   HRESULT hr = S_OK;
00137
00138   if(m_pIErrorInfo)
00139   {
00140     //IErrorInfo::GetSource
00141     XTEST(hr = m_pIErrorInfo->GetSource(pbstrSource));
00142     TRACE_METHOD(hr, L"IErrorInfo::GetSource(&\"%s\")", pbstrSource ? *pbstrSource : NULL);
00143   }
00144
00145   return hr;
00146 }
00147
00148
00149 /////////////////////////////////////////////////////////////////
00150 // HRESULT CError::GetHelpFile
00151 //
00152 /////////////////////////////////////////////////////////////////
00153 HRESULT CError::GetHelpFile(BSTR* pbstrHelpFile)
00154 {
00155   HRESULT hr = S_OK;
00156
00157   if(m_pIErrorInfo)
00158   {
00159     //IErrorInfo::GetHelpFile
00160     XTEST(hr = m_pIErrorInfo->GetHelpFile(pbstrHelpFile));
00161     TRACE_METHOD(hr, L"IErrorInfo::GetHelpFile(&\"%s\")", pbstrHelpFile ? *pbstrHelpFile : NULL);
00162   }
00163
00164   return hr;
00165 }
00166
00167
00168 /////////////////////////////////////////////////////////////////
00169 // HRESULT CError::GetHelpContext
00170 //
00171 /////////////////////////////////////////////////////////////////
00172 HRESULT CError::GetHelpContext(DWORD* pdwHelpContext)
00173 {
00174   HRESULT hr = S_OK;
00175
00176   if(m_pIErrorInfo)
00177   {
00178     //IErrorInfo::GetHelpContext
00179     XTEST(hr = m_pIErrorInfo->GetHelpContext(pdwHelpContext));
00180     TRACE_METHOD(hr, L"IErrorInfo::GetHelpContext(&0x%08x)", pdwHelpContext ? *pdwHelpContext : NULL);
00181   }
00182
00183   return hr;
00184 }
00185
00186
00187 /////////////////////////////////////////////////////////////////
00188 // HRESULT CError::GetGUID
00189 //
00190 /////////////////////////////////////////////////////////////////
00191 HRESULT CError::GetGUID(GUID* pGuid)
00192 {
00193   HRESULT hr = S_OK;
00194   WCHAR* pwszProgID = NULL;
00195
00196   if(m_pIErrorInfo)
00197   {
00198     //IErrorInfo::GetGUID
00199     XTEST(hr = m_pIErrorInfo->GetGUID(pGuid));
00200
00201     if(pGuid)
00202       pwszProgID = GetProgID(*pGuid);
00203     TRACE_METHOD(hr, L"IErrorInfo::GetGuid(&\"%s\")", pwszProgID);
00204   }
00205
00206   SAFE_FREE(pwszProgID);
00207   return hr;
00208 }
00209
00210
00211 /////////////////////////////////////////////////////////////////
00212 // HRESULT CError::GetRecordCount
00213 //
00214 /////////////////////////////////////////////////////////////////
00215 HRESULT CError::GetRecordCount(ULONG* pulCount)
00216 {
00217   HRESULT hr = S_OK;
00218
00219   if(m_pIErrorRecords)
00220   {
00221     //IErrorRecords::GetRecordCount
00222     XTEST(hr = m_pIErrorRecords->GetRecordCount(pulCount));
00223     TRACE_METHOD(hr, L"IErrorRecords::GetRecordCount(&%d)", pulCount ? *pulCount : NULL);
00224   }
00225
00226   return hr;
00227 }
00228
00229
00230
00231 /////////////////////////////////////////////////////////////////
00232 // HRESULT CError::GetCustomErrorObject
00233 //
00234 /////////////////////////////////////////////////////////////////
00235 HRESULT CError::GetCustomErrorObject(ULONG ulRecordNum, REFIID riid, IUnknown** ppObject)
00236 {
00237   HRESULT hr = S_OK;
00238
00239   if(m_pIErrorRecords)
00240   {
00241     //IErrorRecords::GetCustomErrorObject
00242     XTEST(hr = m_pIErrorRecords->GetCustomErrorObject(ulRecordNum, riid, ppObject));
00243     TRACE_METHOD(hr, L"IErrorRecords::GetCustomErrorObject(%lu, %s, &%p)", ulRecordNum, GetInterfaceName(riid), ppObject ? *ppObject : NULL);
00244   }
00245
00246   return hr;
00247 }
00248
00249
00250 /////////////////////////////////////////////////////////////////
00251 // HRESULT CError::GetErrorInfo
00252 //
00253 /////////////////////////////////////////////////////////////////
00254 HRESULT CError::GetErrorInfo(ULONG ulRecordNum, LCID lcid, IErrorInfo** ppErrorInfo)
00255 {
00256   HRESULT hr = S_OK;
00257
00258   if(m_pIErrorRecords)
00259   {
00260     //IErrorRecords::GetErrorInfo
00261     XTEST(hr = m_pIErrorRecords->GetErrorInfo(ulRecordNum, lcid, ppErrorInfo));
00262     TRACE_METHOD(hr, L"IErrorRecords::GetErrorInfo(%lu, %ld, &%p)", ulRecordNum, lcid, ppErrorInfo ? *ppErrorInfo : NULL);
00263   }
00264
00265   return hr;
00266 }
00267
00268
00269 /////////////////////////////////////////////////////////////////
00270 // CCustomError::CCustomError
00271 //
00272 /////////////////////////////////////////////////////////////////
00273 CCustomError::CCustomError(CMainWindow* pCMainWindow)
00274   : CBase(eCCustomError, pCMainWindow, NULL)
00275 {
00276   //OLE DB Interfaces
00277   m_pISQLErrorInfo      = NULL;   //Error interface
00278 }
00279
00280 /////////////////////////////////////////////////////////////////
00281 // CCustomError::~CCustomError
00282 //
00283 /////////////////////////////////////////////////////////////////
00284 CCustomError::~CCustomError()
00285 {
00286   ReleaseObject(0);
00287 }
00288
00289
00290 /////////////////////////////////////////////////////////////////
00291 // IUnknown** CCustomError::GetInterfaceAddress
00292 //
00293 /////////////////////////////////////////////////////////////////
00294 IUnknown** CCustomError::GetInterfaceAddress(REFIID riid)
00295 {
00296   HANDLE_GETINTERFACE(ISQLErrorInfo);
00297
00298   //Otherwise delegate
00299   return CBase::GetInterfaceAddress(riid);
00300 }
00301
00302
00303 /////////////////////////////////////////////////////////////////
00304 // HRESULT CCustomError::AutoRelease
00305 //
00306 /////////////////////////////////////////////////////////////////
00307 HRESULT CCustomError::AutoRelease()
00308 {
00309   //Error
00310   RELEASE_INTERFACE(ISQLErrorInfo);
00311
00312   //Delegate
00313   return CBase::AutoRelease();
00314 }
00315
00316
00317 /////////////////////////////////////////////////////////////////
00318 // HRESULT CCustomError::AutoQI
00319 //
00320 /////////////////////////////////////////////////////////////////
00321 HRESULT CCustomError::AutoQI(DWORD dwCreateOpts)
00322 {
00323   //Delegate First so we have base interfaces
00324   CBase::AutoQI(dwCreateOpts);
00325
00326   //[MANDATORY]
00327   if(dwCreateOpts & CREATE_QI_MANDATORY)
00328   {
00329   }
00330
00331   //[OPTIONAL]
00332   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00333   {
00334     OBTAIN_INTERFACE(ISQLErrorInfo);
00335   }
00336
00337   return S_OK;
00338 }
00339
00340
00341 /////////////////////////////////////////////////////////////////////////////
00342 // CCustomError::GetObjectDesc
00343 //
00344 /////////////////////////////////////////////////////////////////////////////
00345 WCHAR* CCustomError::GetObjectDesc()
00346 {
00347   if(!m_strObjectDesc)
00348   {
00349     CComBSTR bstr;
00350     LONG lNativeError = 0;
00351
00352     //ISQLErrorInfo::GetSQLInfo
00353     if(SUCCEEDED(GetSQLInfo(&bstr, &lNativeError)) && bstr)
00354     {
00355       m_strObjectDesc.CopyFrom(bstr);
00356     }
00357   }
00358
00359   return m_strObjectDesc;
00360 }
00361
00362
00363 /////////////////////////////////////////////////////////////////
00364 // HRESULT CCustomError::GetSQLInfo
00365 //
00366 /////////////////////////////////////////////////////////////////
00367 HRESULT CCustomError::GetSQLInfo(BSTR* pbstrSQLState, LONG* plNativeError)
00368 {
00369   HRESULT hr = S_OK;
00370
00371   if(m_pISQLErrorInfo)
00372   {
00373     //ISQLErrorInfo::GetSQLInfo
00374     XTEST(hr = m_pISQLErrorInfo->GetSQLInfo(pbstrSQLState, plNativeError));
00375     TRACE_METHOD(hr, L"ISQLErrorInfo::GetSQLInfo(&\"%s\", &%ld)", pbstrSQLState ? *pbstrSQLState : NULL, plNativeError ? *plNativeError : NULL);
00376   }
00377
00378   return hr;
00379 }
Generated on Wed Nov 13 2024 16:52:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/compdata.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

compdata.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENTDATA_
00016 #define _CLASS_CCOMPONENTDATA_
00017
00018
00019 #include <ObjIdl.h>
00020 #include "Globals.h"
00021 #include "StaticNode.h"
00022 #include "Comp.h"
00023
00024 //---------------------------------------------------------------------------
00025 class CComponentData : public IComponentData2
00026 {
00027   private:
00028     ULONG                m_cRef;
00029     LPCONSOLE            m_ipConsole2;           // Not used in this sample
00030     LPCONSOLENAMESPACE   m_ipConsoleNameSpace2;  // Not used in this sample
00031     CStaticNode*         m_pStaticNode;
00032
00033   public:
00034     CComponentData();
00035     ~CComponentData();
00036
00037     /////////////////////////////////////////////////////////////////////////
00038     // Interface IUnknown
00039     //
00040     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00041     STDMETHODIMP_(ULONG) AddRef();
00042     STDMETHODIMP_(ULONG) Release();
00043
00044     /////////////////////////////////////////////////////////////////////////
00045     // Interface IComponentData
00046     //
00047     HRESULT STDMETHODCALLTYPE Initialize
00048             ( /*[in] */ LPUNKNOWN pUnknown );
00049
00050     HRESULT STDMETHODCALLTYPE CreateComponent
00051             ( /*[out]*/ LPCOMPONENT __RPC_FAR* ppComponent);
00052
00053     HRESULT STDMETHODCALLTYPE Notify
00054             ( /*[in] */ LPDATAOBJECT ipDataObject,
00055               /*[in] */ MMC_NOTIFY_TYPE MmcEvent,
00056               /*[in] */ LONG nArg,
00057               /*[in] */ LONG nParam
00058             );
00059
00060     HRESULT STDMETHODCALLTYPE Destroy( void);
00061
00062     HRESULT STDMETHODCALLTYPE QueryDataObject
00063             ( /*[in] */  MMC_COOKIE uCookie,
00064               /*[in] */  DATA_OBJECT_TYPES nEnumType,
00065               /*[out] */ LPDATAOBJECT __RPC_FAR* ppDataObject
00066             );
00067
00068     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00069             ( /*[in,out]*/ SCOPEDATAITEM __RPC_FAR* pScopeDataItem );
00070
00071     HRESULT STDMETHODCALLTYPE CompareObjects
00072             ( /*[in] */ LPDATAOBJECT lpDataObjectA,
00073               /*[in] */ LPDATAOBJECT lpDataObjectB
00074             );
00075
00076     HRESULT STDMETHODCALLTYPE QueryDispatch
00077             ( /*[in] */  MMC_COOKIE  nCookie,
00078               /*[in] */  DATA_OBJECT_TYPES eType,
00079               /*[out]*/  LPDISPATCH* pipDispatch
00080             );
00081
00082   // Pulic helper methods
00083   public:
00084     CStaticNode* GetStaticNode() { return m_pStaticNode; }
00085
00086 };
00087
00088 #endif //_CLASS_CCOMPONENTDATA_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/Sample.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

Sample.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SAMPLE.H
00003
00004   Summary:   Declares a COLicCarSample utility COM object used to
00005              implement the server as a code sample (mainly with an Init
00006              method to enable setting up Trace logging of activity in the
00007              server to the logging facility in the Client).
00008
00009              For a comprehensive tutorial code tour of this module's
00010              contents and offerings see the tutorial LICSERVE.HTM
00011              file. For more specific technical details on the internal
00012              workings see the comments dispersed throughout the module's
00013              source code.
00014
00015   Classes:   COLicCarSample.
00016
00017   Functions: none
00018
00019   Origin:    10-5-95: atrent - Editor-inheritance from SAMPLE.H in
00020                the DLLSERVE Tutorial Code Sample.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 #if !defined(SAMPLE_H)
00038 #define SAMPLE_H
00039
00040 #ifdef __cplusplus
00041
00042 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00043   ObjectClass: COLicCarSample
00044
00045   Summary:     Utility LicCarSample COM Object Class for the LICSERVE
00046                server as a code sample.
00047
00048   Interfaces:  IUnknown
00049                  Standard interface providing COM object features.
00050                ISample
00051                  Sample-specific Utility services for server as a whole.
00052
00053   Aggregation: Yes, COLicCarSample COM objects are aggregatable by
00054                passing a non-NULL pUnkOuter IUnknown pointer into the
00055                constructor.
00056 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00057 class COLicCarSample : public IUnknown
00058 {
00059   public:
00060     // Main Object Constructor & Destructor.
00061     COLicCarSample(IUnknown* pUnkOuter, CServer* pServer);
00062     ~COLicCarSample(void);
00063
00064     // IUnknown methods. Main object, non-delegating.
00065     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00066     STDMETHODIMP_(ULONG) AddRef(void);
00067     STDMETHODIMP_(ULONG) Release(void);
00068
00069   private:
00070     // We declare nested class interface implementations here.
00071
00072     // We implement the ISample interface in this COLicCarSample
00073     // COM object class.
00074     class CImpISample : public ISample
00075     {
00076       public:
00077         // Interface Implementation Constructor & Destructor.
00078         CImpISample(
00079           COLicCarSample* pBackObj,
00080           IUnknown* pUnkOuter,
00081           CServer* pServer);
00082         ~CImpISample(void);
00083
00084         // IUnknown methods.
00085         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00086         STDMETHODIMP_(ULONG) AddRef(void);
00087         STDMETHODIMP_(ULONG) Release(void);
00088
00089         // ISample methods.
00090         STDMETHODIMP         Init(HWND, PVOID);
00091         STDMETHODIMP         AboutBox(HWND);
00092
00093       private:
00094         // Data private to this interface implementation of ISample.
00095         ULONG            m_cRefI;        // Interface Ref Count (debugging).
00096         COLicCarSample*  m_pBackObj;     // Parent Object back pointer.
00097         IUnknown*        m_pUnkOuter;    // Outer unknown for Delegation.
00098         CServer*         m_pServer;      // Server Control object.
00099     };
00100
00101     // Make the otherwise private and nested ISample interface
00102     // implementation a friend to COM object instantiations of this
00103     // selfsame COLicCarSample COM object class.
00104     friend CImpISample;
00105
00106     // Private data of COLicCarSample COM objects.
00107
00108     // Nested ISample implementation instantiation.
00109     CImpISample      m_ImpISample;
00110
00111     // Main Object reference count.
00112     ULONG            m_cRefs;
00113
00114     // Outer unknown (aggregation & delegation). Used when this
00115     // COLicCarSample object is being aggregated.  Otherwise it is used
00116     // for delegation if this object is reused via containment.
00117     IUnknown*        m_pUnkOuter;
00118
00119     // Pointer to this component server's control object.
00120     CServer*         m_pServer;
00121 };
00122
00123 typedef COLicCarSample* PCOLicCarSample;
00124
00125 #endif // __cplusplus
00126
00127
00128 #endif // SAMPLE_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/CChan.h Source File

  • Web
  • NetMeeting
  • NMUI

CChan.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       CCHAN.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 //****************************************************************************
00016 //
00017 // CLASS CChannelNotify
00018 //
00019 //****************************************************************************
00020
00021 class CChannelNotify : public RefCount, public CNotify, public INmChannelNotify
00022 {
00023 public:
00024   CChannelNotify();
00025   ~CChannelNotify();
00026
00027   // INmChannelNotify
00028   HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
00029   HRESULT STDMETHODCALLTYPE MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember);
00030
00031   // ICNotify methods
00032   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00033   HRESULT STDMETHODCALLTYPE Disconnect(void);
00034
00035   // IUnknown methods
00036   ULONG STDMETHODCALLTYPE AddRef(void);
00037   ULONG STDMETHODCALLTYPE Release(void);
00038   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00039 };
00040
00041
00042 //****************************************************************************
00043 //
00044 // Global Variables
00045 //
00046 //****************************************************************************
00047
00048 extern COBLIST * g_pListChannel;
00049 extern COBLIST * g_pListChannelNotify;
00050
00051
00052 //****************************************************************************
00053 //
00054 // Global Routines
00055 //
00056 //****************************************************************************
00057
00058 HRESULT HookChannel(INmChannel * pChannel);
00059 VOID UnHookChannel(INmChannel * pChannel);
00060 VOID UpdateChannelState(INmChannel * pChannel);
00061 VOID FreeChannels(void);
00062 VOID FreeFt(void);
00063 VOID FreeAs(void);
00064
00065 VOID SendFile(INmMember * pMember);
00066 VOID DoFtCancel(void);
00067
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletObjectKey Member List

This is the complete list of members for tagAppletObjectKey, including all inherited members.
eType | tagAppletObjectKey
lstrObjectID | tagAppletObjectKey
ostrH221NonStdID | tagAppletObjectKey
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

WININFO Member List

This is the complete list of members for WININFO, including all inherited members.
bWindowed | WININFO
hInstance | WININFO
nBPP | WININFO
nHeight | WININFO
nWidth | WININFO
Generated on Wed Nov 13 2024 16:58:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/PersistSubs/Persistatl/INewsEvent.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • PersistSubs
  • Persistatl

INewsEvent.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc2.tmp" /nologo /d "D:\ComPlusSamples\Source\LCE\PersistSubs" "D:\ComPlusSamples\Source\LCE\PersistSubs\PersistATL.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package persistatl;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface INewsEvent
00019 /** @com.interface(iid=4BF5E480-A5D3-11D2-AD4D-0080C7BFF6DB, thread=AUTO, type=DUAL) */
00020 public interface INewsEvent extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=1, type=METHOD, name="NewsFlash", addFlagsVtable=4)
00023       @com.parameters([in,type=DATE] dtTimeStamp, [in,type=STRING] Symbol, [in,type=STRING] Headline, [in,type=STRING] URL) */
00024   public void NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL);
00025
00026   /** @com.method(vtoffset=5, dispid=2, type=METHOD, name="ShortQuote", addFlagsVtable=4)
00027       @com.parameters([in,type=STRING] Symbol, [in,type=R8] BidPrice, [in,type=R8] AskPrice, [in,type=DATE] LastTradeTime, [in,type=R8] LastTradePrice, [in,type=R8] NetChange, [in,type=R8] DailyHigh, [in,type=R8] DailyLow) */
00028   public void ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow);
00029
00030   /** @com.method(vtoffset=6, dispid=3, type=METHOD, name="LongQuote", addFlagsVtable=4)
00031       @com.parameters([in,type=STRING] Symbol, [in,type=R8] BidPrice, [in,type=R8] AskPrice, [in,type=STRING] LastTradeTime, [in,type=R8] LastTradePrice, [in,type=R8] NetChange, [in,type=R8] DailyHigh, [in,type=R8] DailyLow, [in,type=I4] AskSize, [in,type=I4] BidSize, [in,type=R8] OpenPrice, [in,type=R8] ClosePrice, [in,type=STRING] CloseDate) */
00032   public void LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate);
00033
00034
00035   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x4bf5e480, (short)0xa5d3, (short)0x11d2, (byte)0xad, (byte)0x4d, (byte)0x0, (byte)0x80, (byte)0xc7, (byte)0xbf, (byte)0xf6, (byte)0xdb);
00036 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/land.h Source File

  • SysMgmt
  • MMC
  • Proppage

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035 private:
00036     enum { IDM_NEW_LAND = 2 };
00037
00038     // {2974380E-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ISAPI_EXTENSION Member List

This is the complete list of members for ISAPI_EXTENSION, including all inherited members.
_csInit | ISAPI_EXTENSION | [private]
_fFirstHitInitDone | ISAPI_EXTENSION | [private]
_fInitialized | ISAPI_EXTENSION | [private]
_pfnInit | ISAPI_EXTENSION | [private]
_strModuleName | ISAPI_EXTENSION | [private]
_strModulePath | ISAPI_EXTENSION | [private]
Initialize(LPSTR szModuleName) | ISAPI_EXTENSION |
InitOnce(PFN_FIRST_HIT_INIT pfnInit, VOID *pContext) | ISAPI_EXTENSION |
ISAPI_EXTENSION() | ISAPI_EXTENSION |
QueryModulePath(VOID) | ISAPI_EXTENSION |
~ISAPI_EXTENSION() | ISAPI_EXTENSION | [virtual]
Generated on Wed Nov 13 2024 16:57:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCNotify/Resource.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCNotify

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by QCNotify.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_ORDER                       101
00007 #define IDR_NOTIFY                      102
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           103
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DragImg/Resource.h Source File

  • WinUI
  • Shell
  • DragImg

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by DragImg.rc
00004 //
00005 #define IDR_MAINMENU                    101
00006 #define IDI_MAINICON                    102
00007 #define IDD_ABOUT                       103
00008 #define IDB_DRAG_IMAGE                  106
00009 #define IDM_EXIT                        2000
00010 #define IDM_ABOUT                       2001
00011 #define IDM_FROM_WINDOW                 2002
00012 #define IDM_FROM_BITMAP                 2003
00013 #define IDM_LARGEICONS                  2004
00014 #define IDM_SMALLICONS                  2005
00015 #define IDM_LIST                        2006
00016 #define IDM_REPORT                      2007
00017
00018 // Next default values for new objects
00019 //
00020 #ifdef APSTUDIO_INVOKED
00021 #ifndef APSTUDIO_READONLY_SYMBOLS
00022 #define _APS_NO_MFC                     1
00023 #define _APS_NEXT_RESOURCE_VALUE        107
00024 #define _APS_NEXT_COMMAND_VALUE         2008
00025 #define _APS_NEXT_CONTROL_VALUE         1000
00026 #define _APS_NEXT_SYMED_VALUE           104
00027 #endif
00028 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/cData.Cpp Source File

  • Web
  • NetMeeting
  • NMChat

cData.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       CDATA.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 INmChannelData * g_pChannelData = NULL;
00018 CDataNotify * g_pNotifyData   = NULL;
00019
00020 //****************************************************************************
00021 //
00022 // VOID DisplayMsg(LPTSTR pszMsg, INmMember * pMember)
00023 //
00024 //****************************************************************************
00025
00026 VOID DisplayMsg(LPTSTR pszMsg, INmMember * pMember)
00027 {
00028 #ifdef NM2_CHAT_PROTOCOL
00029 #ifndef UNICODE
00030   // Convert UNICODE to ANSI
00031   char sz[MAX_PATH + 1];
00032   ZeroMemory(sz, (MAX_PATH + 1) * sizeof(char));
00033
00034   WideCharToMultiByte(CP_ACP, 0, (LPWSTR) pszMsg, -1, sz, MAX_PATH, NULL, NULL);
00035   pszMsg = sz;
00036 #endif /* UNICODE */
00037 #endif /* NM2_CHAT_PROTOCOL */
00038
00039   DisplaySysMsg(pszMsg, pMember);
00040 }
00041
00042
00043 //****************************************************************************
00044 //
00045 // VOID DisplaySysMsg(LPTSTR pszMsg, INmMember * pMember)
00046 //
00047 //****************************************************************************
00048
00049 VOID DisplaySysMsg(LPTSTR pszMsg, INmMember * pMember)
00050 {
00051   LPTSTR pszUser = NULL;
00052
00053   if (NULL != pMember)
00054   {
00055     PUSER pUser = PUserFromINmMember(pMember);
00056     if (NULL != pUser)
00057     {
00058       pszUser = pUser->pszName;
00059     }
00060   }
00061
00062   if (NULL == pszUser)
00063   {
00064     pszUser = TEXT("");
00065   }
00066
00067   DisplayMessage(pszMsg, pszUser);
00068 }
00069
00070
00071 //****************************************************************************
00072 //
00073 // VOID DisplayMessage(LPTSTR pszMsg, LPTSTR pszUser)
00074 //
00075 //****************************************************************************
00076
00077 VOID DisplayMessage(LPTSTR pszMsg, LPTSTR pszUser)
00078 {
00079   int iItem = 0;
00080   LV_ITEM  lvItem;
00081
00082   ClearStruct(&lvItem);           // Zero's memory
00083   lvItem.iItem = 0x0FFFFFFF;
00084   lvItem.mask = LVIF_PARAM | LVIF_TEXT;
00085   lvItem.pszText = pszUser;
00086   lvItem.cchTextMax = lstrlen(lvItem.pszText);
00087   iItem = ListView_InsertItem(ghwndMsg, &lvItem);
00088
00089   {
00090     TCHAR sz[MAX_PATH + 1];
00091     ZeroMemory(sz, (MAX_PATH + 1) * sizeof(TCHAR));
00092
00093     SYSTEMTIME sysTime;
00094     GetLocalTime(&sysTime);
00095
00096     _sntprintf(sz, MAX_PATH, TEXT("%02d:%02d:%02d"), sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
00097     ListView_SetItemText(ghwndMsg, iItem, ILV_TIME, sz);
00098   }
00099
00100   ListView_SetItemText(ghwndMsg, iItem, ILV_TEXT, pszMsg);
00101 }
00102
00103
00104 //****************************************************************************
00105 //
00106 // HRESULT HookData(INmChannelData * pChannelData)
00107 //
00108 //****************************************************************************
00109
00110 HRESULT HookData(INmChannelData * pChannelData)
00111 {
00112   HRESULT hr        = NO_ERROR;
00113   CDataNotify * pNotify = NULL;
00114
00115   ASSERT(NULL != pChannelData);
00116   ASSERT(NULL == g_pChannelData);
00117
00118   if(NULL == pChannelData)
00119   {
00120     return E_POINTER;
00121   }
00122
00123   if(NULL != g_pChannelData)
00124   {
00125     return E_POINTER;
00126   }
00127
00128   g_pChannelData = pChannelData;
00129
00130     // Connect to the channel object
00131     pNotify = new CDataNotify();
00132     if (pNotify == NULL)
00133     {
00134         hr = E_OUTOFMEMORY;
00135     }
00136     else
00137     {
00138     hr = pNotify->Connect(pChannelData);
00139     if (SUCCEEDED(hr))
00140     {
00141       g_pNotifyData = pNotify;
00142     }
00143   }
00144
00145   if (FAILED(hr))
00146   {
00147     FreeDataChannel();
00148   }
00149
00150   return hr;
00151 }
00152
00153
00154 //****************************************************************************
00155 //
00156 // VOID FreeDataChannel(void)
00157 //
00158 //****************************************************************************
00159
00160 VOID FreeDataChannel(void)
00161 {
00162   // Release all notify
00163   if (NULL != g_pNotifyData)
00164   {
00165     g_pNotifyData->Disconnect();
00166     g_pNotifyData->Release();
00167     g_pNotifyData = NULL;
00168   }
00169
00170   if (NULL != g_pChannelData)
00171   {
00172     g_pChannelData->Release();
00173     g_pChannelData = NULL;
00174   }
00175 }
00176
00177
00178 //****************************************************************************
00179 //
00180 // CLASS CDataNotify
00181 //
00182 //****************************************************************************
00183
00184
00185 //****************************************************************************
00186 //
00187 // Constructor
00188 //
00189 //****************************************************************************
00190
00191 CDataNotify::CDataNotify() : RefCount(), CNotify()
00192 {
00193 }
00194
00195
00196 //****************************************************************************
00197 //
00198 // Destructor
00199 //
00200 //****************************************************************************
00201
00202 CDataNotify::~CDataNotify()
00203 {
00204 }
00205
00206
00207 //****************************************************************************
00208 //
00209 // Methods from IUnknown
00210 //
00211 //****************************************************************************
00212
00213 ULONG STDMETHODCALLTYPE CDataNotify::AddRef(void)
00214 {
00215   return RefCount::AddRef();
00216 }
00217
00218
00219 ULONG STDMETHODCALLTYPE CDataNotify::Release(void)
00220 {
00221   return RefCount::Release();
00222 }
00223
00224 HRESULT STDMETHODCALLTYPE CDataNotify::QueryInterface(REFIID riid, PVOID *ppvObject)
00225 {
00226   if(NULL == ppvObject)
00227   {
00228     return E_POINTER;
00229   }
00230
00231   HRESULT hr = S_OK;
00232
00233   if (riid == IID_IUnknown)
00234   {
00235     *ppvObject = (IUnknown *)this;
00236   }
00237   else if (riid == IID_INmChannelDataNotify)
00238   {
00239     *ppvObject = (INmChannelDataNotify *)this;
00240   }
00241   else
00242   {
00243     hr = E_NOINTERFACE;
00244     *ppvObject = NULL;
00245   }
00246
00247   if(SUCCEEDED(hr))
00248   {
00249     AddRef();
00250   }
00251
00252   return hr;
00253 }
00254
00255
00256 //****************************************************************************
00257 //
00258 // Methods from ICNotify
00259 //
00260 //****************************************************************************
00261
00262 HRESULT STDMETHODCALLTYPE CDataNotify::Connect(IUnknown *pUnk)
00263 {
00264   return CNotify::Connect(pUnk, IID_INmChannelDataNotify, (IUnknown *)this);
00265 }
00266
00267 HRESULT STDMETHODCALLTYPE CDataNotify::Disconnect(void)
00268 {
00269   return CNotify::Disconnect();
00270 }
00271
00272
00273 //****************************************************************************
00274 //
00275 // Methods from INmChannelNotify
00276 //
00277 //****************************************************************************
00278
00279 HRESULT STDMETHODCALLTYPE CDataNotify::NmUI(CONFN uNotify)
00280 {
00281   return S_OK;
00282 }
00283
00284 HRESULT STDMETHODCALLTYPE CDataNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
00285 {
00286   if (NM_MEMBER_ADDED == uNotify)
00287   {
00288     AddMember(pMember);
00289   }
00290   else if (NM_MEMBER_REMOVED == uNotify)
00291   {
00292     RemoveMember(pMember);
00293   }
00294
00295   return S_OK;
00296 }
00297
00298 HRESULT STDMETHODCALLTYPE CDataNotify::DataSent(INmMember *pMember, ULONG uSize, LPBYTE pb)
00299 {
00300   LPTSTR psz = NULL;
00301
00302 #ifdef NM2_CHAT_PROTOCOL
00303   ASSERT(uSize > CB_NM2_HDR);
00304   if(uSize <= CB_NMUI_HDR)
00305   {
00306     return E_FAIL;
00307   }
00308
00309   psz = (LPTSTR) (pb + *(LPDWORD) pb);  // skip past header
00310 #else
00311   psz = (LPTSTR) pb;
00312 #endif /* NM2_CHAT_PROTOCOL */
00313
00314   DisplayMsg(psz, g_pMemberLocal);
00315
00316   return S_OK;
00317 }
00318
00319 HRESULT STDMETHODCALLTYPE CDataNotify::DataReceived(INmMember *pMember, ULONG uSize, LPBYTE pb, ULONG dwFlags)
00320 {
00321   LPTSTR psz = NULL;
00322
00323   // Warning : Doesn't handle broken packets
00324   // TODO: Check dwFlags & NM_DF_SEGMENT_END
00325
00326 #ifdef NM2_CHAT_PROTOCOL
00327   ASSERT(uSize > CB_NM2_HDR);
00328   if(uSize <= CB_NMUI_HDR)
00329   {
00330     return E_FAIL;
00331   }
00332
00333   psz = (LPTSTR) (pb + *(LPDWORD) pb);  // skip past header
00334 #else
00335   psz = (LPTSTR) pb;
00336 #endif /* NM2_CHAT_PROTOCOL */
00337
00338   DisplayMsg(psz, pMember);
00339
00340   return S_OK;
00341 }
00342
00343 /*  C H E C K  D A T A  C H A N N E L  */
00344 /*-------------------------------------------------------------------------
00345     %%Function: CheckDataChannel
00346
00347     Check if the data channel can be created.
00348 -------------------------------------------------------------------------*/
00349 VOID CheckDataChannel(void)
00350 {
00351   ULONG id            = 0;
00352   HRESULT hr            = NO_ERROR;
00353   INmChannelData * pChannelData = NULL;
00354
00355   if (NULL != g_pChannelData)
00356   {
00357     return; // already created
00358   }
00359
00360   if (NULL == g_pMemberLocal)
00361   {
00362     return; // we're not in the conference yet
00363   }
00364
00365   if (FAILED(g_pMemberLocal->GetID(&id)))
00366   {
00367     return;
00368   }
00369
00370   if (0 == id)
00371   {
00372     return; // no local data id
00373   }
00374
00375 #ifdef NM2_CHAT_PROTOCOL
00376   hr = g_pConference->CreateDataChannel(&pChannelData, g_guidNM2Chat);
00377 #else
00378   hr = g_pConference->CreateDataChannel(&pChannelData, g_guidApp);
00379 #endif /* NM2_CHAT_PROTOCOL */
00380
00381   if(SUCCEEDED(hr))
00382   {
00383     hr = HookData(pChannelData);  // Real hook is g_pChannelData
00384   }
00385
00386   DisplaySysMsg((SUCCEEDED(hr)) ? TEXT("Chat Started") : TEXT("Chat failed to start!"), NULL);
00387 }
00388
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/SmpFilt/SmpFilt.Hxx Source File

  • WinBase
  • Indexing
  • SmpFilt

SmpFilt.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (c) Microsoft Corporation. All rights reserved.
00009 //
00010 //  File:       smpfilt.hxx
00011 //
00012 //  Contents:   Sample filter declarations
00013 //
00014 //  Platform:   Windows 2000
00015 //
00016 //--------------------------------------------------------------------------
00017
00018 #pragma once
00019
00020 //+-------------------------------------------------------------------------
00021 //
00022 //  Global definitions
00023 //
00024 //--------------------------------------------------------------------------
00025
00026 const ULONG TEXT_FILTER_CHUNK_SIZE = 10000L;  // size of character buffers
00027 long g_lInstances = 0;  // Global count of CSmpFilt and CSmpFiltCF instances
00028 GUID const guidStorage = PSGUID_STORAGE;    // GUID for storage property set
00029
00030 //C-------------------------------------------------------------------------
00031 //
00032 //  Class:      CSmpFilter
00033 //
00034 //  Purpose:    Implements interfaces of sample filter
00035 //
00036 //--------------------------------------------------------------------------
00037
00038 // SmpFilter Class ID
00039 // {8B0E5E70-3C30-11d1-8C0D-00AA00C26CD4}
00040
00041 GUID const CLSID_CSmpFilter =
00042 {
00043     0x8b0e5e70,
00044     0x3c30,
00045     0x11d1,
00046     { 0x8c, 0xd, 0x0, 0xaa, 0x0, 0xc2, 0x6c, 0xd4 }
00047 };
00048
00049 class CSmpFilter : public IFilter, public IPersistFile
00050 {
00051 public:
00052
00053     //
00054     // From IUnknown
00055     //
00056
00057     virtual  SCODE STDMETHODCALLTYPE  QueryInterface(
00058         REFIID riid,
00059         void  ** ppvObject
00060     );
00061     virtual  ULONG STDMETHODCALLTYPE  AddRef();
00062     virtual  ULONG STDMETHODCALLTYPE  Release();
00063
00064     //
00065     // From IFilter
00066     //
00067
00068     virtual  SCODE STDMETHODCALLTYPE  Init(
00069         ULONG grfFlags,
00070         ULONG cAttributes,
00071         FULLPROPSPEC const * aAttributes,
00072         ULONG * pFlags
00073     );
00074     virtual  SCODE STDMETHODCALLTYPE  GetChunk(
00075         STAT_CHUNK * pStat
00076     );
00077     virtual  SCODE STDMETHODCALLTYPE  GetText(
00078         ULONG * pcwcBuffer,
00079         WCHAR * awcBuffer
00080     );
00081     virtual  SCODE STDMETHODCALLTYPE  GetValue(
00082         PROPVARIANT ** ppPropValue
00083     );
00084     virtual  SCODE STDMETHODCALLTYPE  BindRegion(
00085         FILTERREGION origPos,
00086         REFIID riid,
00087         void ** ppunk
00088     );
00089
00090     //
00091     // From IPersistFile
00092     //
00093
00094     virtual  SCODE STDMETHODCALLTYPE  GetClassID(
00095         CLSID * pClassID
00096     );
00097     virtual  SCODE STDMETHODCALLTYPE  IsDirty();
00098     virtual  SCODE STDMETHODCALLTYPE  Load(
00099         LPCWSTR pszFileName,
00100         DWORD dwMode
00101     );
00102     virtual  SCODE STDMETHODCALLTYPE  Save(
00103         LPCWSTR pszFileName,
00104         BOOL fRemember
00105     );
00106     virtual  SCODE STDMETHODCALLTYPE  SaveCompleted(
00107         LPCWSTR pszFileName
00108     );
00109     virtual  SCODE STDMETHODCALLTYPE  GetCurFile(
00110         LPWSTR  * ppszFileName
00111     );
00112
00113 private:
00114
00115     friend class CSmpFilterCF;
00116
00117     CSmpFilter();
00118     ~CSmpFilter();
00119
00120     HANDLE  m_hFile;                // Handle to the input file
00121     long    m_lRefs;                // Reference count
00122     WCHAR * m_pwszFileName;         // Name of input file to filter
00123     ULONG   m_ulBufferLen;          // Characters read from file to buffer
00124     ULONG   m_ulCharsRead;          // Characters read from chunk buffer
00125     ULONG   m_ulChunkID;            // Current chunk id
00126     ULONG   m_ulCodePage;           // Current default codepage
00127     BOOL    m_fContents;            // TRUE if contents requested
00128     BOOL    m_fEof;                 // TRUE if end of file reached
00129     WCHAR   m_wcsBuffer[TEXT_FILTER_CHUNK_SIZE];  // Buffer for UNICODE
00130 };
00131
00132 //C-------------------------------------------------------------------------
00133 //
00134 //  Class:      CSmpFilterCF
00135 //
00136 //  Purpose:    Implements class factory for sample filter
00137 //
00138 //--------------------------------------------------------------------------
00139
00140 class CSmpFilterCF : public IClassFactory
00141 {
00142 public:
00143
00144     //
00145     // From IUnknown
00146     //
00147
00148     virtual  SCODE STDMETHODCALLTYPE  QueryInterface(
00149         REFIID riid,
00150         void  ** ppvObject
00151     );
00152     virtual  ULONG STDMETHODCALLTYPE  AddRef();
00153     virtual  ULONG STDMETHODCALLTYPE  Release();
00154
00155     //
00156     // From IClassFactory
00157     //
00158
00159     virtual  SCODE STDMETHODCALLTYPE  CreateInstance(
00160         IUnknown * pUnkOuter,
00161         REFIID riid, void  ** ppvObject
00162     );
00163     virtual  SCODE STDMETHODCALLTYPE  LockServer(
00164         BOOL fLock
00165     );
00166
00167 private:
00168
00169     friend SCODE STDMETHODCALLTYPE DllGetClassObject(
00170         REFCLSID   cid,
00171         REFIID     iid,
00172         void **    ppvObj
00173     );
00174
00175     CSmpFilterCF();
00176     ~CSmpFilterCF();
00177
00178     long m_lRefs;           // Reference count
00179 };
00180
00181
00182
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAVIFileWriter Member List

This is the complete list of members for CAVIFileWriter, including all inherited members.
CAVIFileWriter() | CAVIFileWriter |
Initialize(IN const CHAR *psFileName, IN const WAVEFORMATEX &WaveFormat) | CAVIFileWriter |
m_nSampleSize | CAVIFileWriter | [private]
m_pAudioStream | CAVIFileWriter | [private]
m_pAVIFile | CAVIFileWriter | [private]
Write(IN BYTE *pBuffer, IN ULONG nBytesToWrite, IN OUT ULONG *pnBytesWritten) | CAVIFileWriter |
~CAVIFileWriter() | CAVIFileWriter | [virtual]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_Collection Member List

This is the complete list of members for msado15::_Collection, including all inherited members.
_NewEnum() | msado15::_Collection |
getCount() | msado15::_Collection |
iid | msado15::_Collection | [static]
Refresh() | msado15::_Collection |
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/Imp_Draw/Resource.h Source File

  • NetDS
  • MessageQueuing
  • Imp_Draw

Resource.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 //{{NO_DEPENDENCIES}}
00013 // Microsoft Developer Studio generated include file.
00014 // Used by Imp_Draw.rc
00015 //
00016 #define IDC_CONTINUE                    3
00017 #define IDD_IMP_DRAW_DIALOG             102
00018 #define IDR_MAINFRAME                   128
00019 #define IDD_LOGIN                       130
00020 #define IDC_EDIT_FRIEND                 1000
00021 #define IDC_BUTTON_ATTACH               1001
00022 #define IDC_RADIO_EXPRESS               1002
00023 #define IDC_RADIO_RECOVERABLE           1003
00024 #define IDC_DRAWAREA_SCRIBLLE           1004
00025 #define IDC_EDIT_LOGIN                  1005
00026 #define IDC_EDIT_FRIEND_COMPUTER        1005
00027 #define IDC_RADIO_DS                    1006
00028 #define IDC_RADIO_WORKGROUP             1007
00029 #define IDC_STATIC_CHOOSE_DS            1009
00030 #define IDC_STATIC_Q_LABEL              1010
00031 #define IDC_STATIC_CHOOSE_MESSAGE       1011
00032 #define IDC_STATIC_C_LABEL              1012
00033
00034 // Next default values for new objects
00035 //
00036 #ifdef APSTUDIO_INVOKED
00037 #ifndef APSTUDIO_READONLY_SYMBOLS
00038 #define _APS_NEXT_RESOURCE_VALUE        131
00039 #define _APS_NEXT_COMMAND_VALUE         32771
00040 #define _APS_NEXT_CONTROL_VALUE         1000
00041 #define _APS_NEXT_SYMED_VALUE           101
00042 #endif
00043 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/OPBank/OPBank.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • OPBank

OPBank.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      OPBank.cpp
00003   Summary:   Implementation of WinMain
00004 -----------------------------------------------------------------------------
00005
00006 This file is part of the Microsoft COM+ Samples.
00007
00008 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00009
00010 This source code is intended only as a supplement to Microsoft
00011 Development Tools and/or on-line documentation. See these other
00012 materials for detailed information regarding Microsoft code samples.
00013
00014 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 PARTICULAR PURPOSE.
00018
00019 ==========================================================================+*/
00020
00021
00022 // Note: Proxy/Stub Information
00023 //      To build a separate proxy/stub DLL,
00024 //      run nmake -f OPBankps.mk in the project directory.
00025
00026 #include "stdafx.h"
00027 #include "resource.h"
00028 #include "initguid.h"
00029 #include "OPBank.h"
00030
00031
00032 #ifndef DBNTWIN32
00033 #define DBNTWIN32
00034 #include <SQL.h>
00035 #include <SQLEXT.h>
00036 #endif
00037
00038 #include "bankdlg.h"
00039 extern HACCEL g_hAccel;
00040
00041 BOOL g_bUnattended = FALSE;
00042 WCHAR  * g_szLogFile = NULL;
00043
00044
00045 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00046   Function: CExeModule::Unlock()
00047   Summary:  This is an EXE server, so override ATL's default Unlock
00048 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00049 LONG CExeModule::Unlock()
00050 {
00051   LONG l = CComModule::Unlock();
00052   if (l == 0)
00053   {
00054 #if _WIN32_WINNT >= 0x0400
00055     if (CoSuspendClassObjects() == S_OK)
00056       PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00057 #else
00058     PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00059 #endif
00060   }
00061   return l;
00062 }
00063
00064 CExeModule _Module;
00065
00066 BEGIN_OBJECT_MAP(ObjectMap)
00067 END_OBJECT_MAP()
00068
00069
00070 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00071   Function: FindOneOf
00072   Summary:  return string if match found
00073 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00074 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
00075 {
00076     while (p1 != NULL && *p1 != NULL)
00077     {
00078         LPCTSTR p = p2;
00079         while (p != NULL && *p != NULL)
00080         {
00081             if (*p1 == *p)
00082                 return CharNext(p1);
00083             p = CharNext(p);
00084         }
00085         p1 = CharNext(p1);
00086     }
00087     return NULL;
00088 }
00089
00090
00091 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00092   Function: _tWinMain
00093   Summary:  WinMain -- main windows entry point
00094 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00095 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00096   HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
00097 {
00098   lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
00099   HRESULT hRes = CoInitialize(NULL);
00100 //  If you are running on NT 4.0 or higher you can use the following call
00101 //  instead to make the EXE free threaded.
00102 //  This means that calls come in on a random RPC thread
00103 //  HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00104   _ASSERTE(SUCCEEDED(hRes));
00105   _Module.Init(ObjectMap, hInstance);
00106   _Module.dwThreadID = GetCurrentThreadId();
00107   TCHAR szTokens[] = _T("-/");
00108
00109   int nRet = 0;
00110   BOOL bRun = TRUE;
00111   LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
00112   while (lpszToken != NULL)
00113   {
00114     if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
00115     {
00116       _Module.UpdateRegistryFromResource(IDR_OPBank, FALSE);
00117       nRet = _Module.UnregisterServer();
00118       bRun = FALSE;
00119       break;
00120     }
00121     if (lstrcmpi(lpszToken, _T("RegServer"))==0)
00122     {
00123       _Module.UpdateRegistryFromResource(IDR_OPBank, TRUE);
00124       nRet = _Module.RegisterServer(TRUE);
00125       bRun = FALSE;
00126       break;
00127     }
00128
00129     lpszToken = FindOneOf(lpszToken, szTokens);
00130   }
00131
00132   TCHAR * p = lpCmdLine;
00133
00134   while (*p != '-' && *p)
00135     p++;
00136
00137   while (*p)
00138   {
00139
00140     switch (*p)
00141     {
00142
00143       case 'u':
00144       case 'U':
00145         g_bUnattended = TRUE;
00146         if (!g_szLogFile)
00147         {
00148           g_szLogFile = new WCHAR[64];
00149           lstrcpy(g_szLogFile, L"C:\\vcbank.log");
00150         }
00151         break;
00152       case 'f':
00153       case 'F':
00154         {
00155
00156           if (g_szLogFile)
00157           {
00158             delete [] g_szLogFile;
00159             g_szLogFile = NULL;
00160           }
00161           p+=2; // skip "f:" or "f "
00162           TCHAR * q = p;
00163           while (*q  && *q != ' ')
00164             q++;
00165
00166           int nChars =  q-p+1;
00167           g_szLogFile = new WCHAR[nChars];
00168           _ASSERTE(p!= NULL);
00169           lstrcpyn(g_szLogFile, p, nChars);
00170           p = q;
00171         }
00172         break;
00173       default:
00174         break;
00175     }
00176
00177     p++;
00178   }
00179
00180   if (bRun)
00181   {
00182     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00183       REGCLS_MULTIPLEUSE);
00184     _ASSERTE(SUCCEEDED(hRes));
00185
00186     CBankDlg dlg;
00187     HWND hWnd = dlg.Create(NULL);
00188     if (hWnd)
00189     {
00190       g_hAccel = LoadAccelerators(_Module.m_hInst, MAKEINTRESOURCE(IDR_ACCELERATORS));
00191       _ASSERTE(g_hAccel);
00192       ShowWindow(hWnd, SW_SHOWNORMAL);
00193       MSG msg;
00194       while (GetMessage(&msg, 0, 0, 0))
00195       {
00196         if (!TranslateAccelerator(hWnd, g_hAccel, &msg))
00197         {
00198           if (!IsDialogMessage(hWnd, &msg))
00199           {
00200             TranslateMessage(&msg);
00201             DispatchMessage(&msg);
00202           }
00203         }
00204
00205       }
00206     }
00207     else
00208     {
00209       MessageBox(NULL, L"Unable to load dialog!", L"C Bank", MB_ICONSTOP);
00210     }
00211     _Module.RevokeClassObjects();
00212   }
00213
00214   if (g_szLogFile)
00215     delete [] g_szLogFile;
00216
00217   CoUninitialize();
00218   return nRet;
00219 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ActiveDirectory/PropSheetHost/PropSheetHost.h Source File

  • NetDS
  • ActiveDirectory
  • PropSheetHost

PropSheetHost.h

Go to the documentation of this file.
00001 //***************************************************************************
00002 //    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003 //    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 //    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 //    PARTICULAR PURPOSE.
00006 //
00007 //    Copyright Microsoft Corporation. All Rights Reserved.
00008 //***************************************************************************
00009
00010 //***************************************************************************
00011 //
00012 //    File:          PropSheetHost.h
00013 //
00014 //***************************************************************************
00015
00016 #pragma once
00017
00018 //***************************************************************************
00019 //    #include statements
00020 //***************************************************************************
00021
00022 #include "stdafx.h"
00023
00024 //***************************************************************************
00025 //    data type definitions
00026 //***************************************************************************
00027
00028 #define VIEW_POINTER_OFFSET   GWLP_USERDATA
00029
00030 #ifndef CFSTR_DS_PARENTHWND
00031     #define CFSTR_DS_PARENTHWND_W L"DsAdminParentHwndClipFormat"
00032     #define CFSTR_DS_PARENTHWND_A "DsAdminParentHwndClipFormat"
00033
00034     #ifdef UNICODE
00035         #define CFSTR_DS_PARENTHWND CFSTR_DS_PARENTHWND_W
00036     #else
00037         #define CFSTR_DS_PARENTHWND CFSTR_DS_PARENTHWND_A
00038     #endif //UNICODE
00039 #endif //CFSTR_DS_PARENTHWND
00040
00041 #ifndef CFSTR_DS_PROPSHEETCONFIG
00042     #define CFSTR_DS_PROPSHEETCONFIG_W L"DsPropSheetCfgClipFormat"
00043     #define CFSTR_DS_PROPSHEETCONFIG_A "DsPropSheetCfgClipFormat"
00044
00045     #ifdef UNICODE
00046         #define CFSTR_DS_PROPSHEETCONFIG CFSTR_DS_PROPSHEETCONFIG_W
00047     #else
00048         #define CFSTR_DS_PROPSHEETCONFIG CFSTR_DS_PROPSHEETCONFIG_A
00049     #endif //UNICODE
00050 #endif //CFSTR_DS_PROPSHEETCONFIG
00051
00052
00053 #ifndef WM_ADSPROP_SHEET_CREATE
00054     #define WM_ADSPROP_SHEET_CREATE (WM_USER + 1108)
00055 #endif
00056
00057
00058 #ifndef WM_DSA_SHEET_CREATE_NOTIFY
00059     #define WM_DSA_SHEET_CREATE_NOTIFY (WM_USER + 6)
00060 #endif
00061
00062
00063 #ifndef WM_DSA_SHEET_CLOSE_NOTIFY
00064     #define WM_DSA_SHEET_CLOSE_NOTIFY (WM_USER + 5)
00065 #endif
00066
00067
00068 #ifndef DSA_SEC_PAGE_INFO
00069     typedef struct _DSA_SEC_PAGE_INFO
00070     {
00071         HWND hwndParentSheet;
00072         DWORD offsetTitle;
00073         DSOBJECTNAMES dsObjectNames;
00074     } DSA_SEC_PAGE_INFO, *PDSA_SEC_PAGE_INFO;
00075 #endif //DSA_SEC_PAGE_INFO
00076
00077 #ifndef PROPSHEETCFG
00078     typedef struct _PROPSHEETCFG
00079     {
00080         LONG_PTR lNotifyHandle;
00081         HWND hwndParentSheet;
00082         HWND hwndHidden;
00083         WPARAM wParamSheetClose;
00084     } PROPSHEETCFG, *PPROPSHEETCFG;
00085 #endif //PROPSHEETCFG
00086
00087 #define PROP_SHEET_HOST_ID 0xCDCDCDCD
00088
00089 #define PROP_SHEET_PREFIX_ADMIN L"admin"
00090 #define PROP_SHEET_PREFIX_SHELL L"shell"
00091
00092 /**************************************************************************
00093
00094    CPropSheetHost class definition
00095
00096 **************************************************************************/
00097
00098 class CPropSheetHost : public IDataObject
00099 {
00100 private:
00101     HWND m_hwndParent;
00102     HWND m_hwndHidden;
00103     DWORD m_ObjRefCount;
00104     CComPtr<IADs> m_spADObject;
00105     ATOM m_cfDSPropSheetConfig;
00106     ATOM m_cfDSObjectNames;
00107     ATOM m_cfDSDispSpecOptions;
00108     CSimpleArray<HPROPSHEETPAGE> m_rgPageHandles;
00109     LPTSTR m_szHiddenWindowClass;
00110     HINSTANCE m_hInst;
00111     LPWSTR m_pwszPrefix;
00112
00113 public:
00114     CPropSheetHost(HINSTANCE hInstance, HWND hwndParent = NULL);
00115     ~CPropSheetHost();
00116
00117 public:
00118     HRESULT SetObject(LPCWSTR pwszADsPath);
00119     HRESULT SetObject(IADs *pads);
00120     void Run();
00121
00122 private:
00123     HWND _CreateHiddenWindow();
00124     static LRESULT CALLBACK _HiddenWindowProc(HWND, UINT, WPARAM, LPARAM);
00125     void _CreatePropertySheet();
00126     static BOOL CALLBACK _AddPagesCallback(HPROPSHEETPAGE hPage, LPARAM lParam);
00127     HRESULT _AddPagesForObject(IADs *padsObject);
00128     void _CreateSecondaryPropertySheet(DSA_SEC_PAGE_INFO *pDSASecPageInfo);
00129     HRESULT _GetDSDispSpecOption(FORMATETC *pFormatEtc, STGMEDIUM *pStgMedium);
00130     HRESULT _GetDSObjectNames(FORMATETC *pFormatEtc, STGMEDIUM *pStgMedium);
00131     HRESULT _GetDSPropSheetConfig(FORMATETC *pFormatEtc, STGMEDIUM *pStgMedium);
00132     HRESULT _ExtractSecPageInfo(WPARAM wParam, PDSA_SEC_PAGE_INFO *ppSecPageInfo);
00133
00134 public:
00135     //IUnknown methods
00136     STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
00137     STDMETHODIMP_(DWORD) AddRef();
00138     STDMETHODIMP_(DWORD) Release();
00139
00140     //IDataObject methods
00141     STDMETHODIMP GetData(FORMATETC*, STGMEDIUM*);
00142     STDMETHODIMP GetDataHere(FORMATETC*, STGMEDIUM*);
00143     STDMETHODIMP QueryGetData(FORMATETC*);
00144     STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
00145     STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
00146     STDMETHODIMP EnumFormatEtc(DWORD, IEnumFORMATETC**);
00147     STDMETHODIMP DAdvise(FORMATETC*, DWORD, IAdviseSink*, LPDWORD);
00148     STDMETHODIMP DUnadvise(DWORD dwConnection);
00149     STDMETHODIMP EnumDAdvise(IEnumSTATDATA** ppEnumAdvise);
00150 };
00151
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/SecFile/c/SecFile.c Source File

  • Security
  • Authorization
  • SecFile
  • c

SecFile.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright 1995 - 2000 Microsoft Corporation. All Rights Reserved.
00008
00009 COMMENTS:
00010   All buffers allocated in this sample come from HeapAlloc.  If
00011   HeapAlloc fails, the PERR macro is not used because HeapAlloc does
00012   not call SetLastError().
00013 -----------------------------------------------------------------------------*/
00014 #include <windows.h>
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017
00018
00019 //
00020 //  Constants and Macros
00021 //
00022 #define USER_ACCESS             GENERIC_ALL
00023 #define WORLD_ACCESS            GENERIC_READ
00024 #define FILENAME                "testfile.txt"
00025
00026 #define PERR(s) fprintf(stderr, "%s(%d) %s : Error %d\n%s\n", \
00027                     __FILE__, __LINE__, (s), GetLastError(), \
00028                     GetLastErrorText())
00029
00030 //
00031 //  Prototypes
00032 //
00033 PSID GetUserSid(void);
00034 PSID CreateWorldSid(void);
00035 LPSTR GetLastErrorText(void);
00036
00037
00038 //
00039 //  FUNCTION: main
00040 //
00041 //  PURPOSE: Driving routine for this sample.
00042 //
00043 //  PARAMETERS:
00044 //      none
00045 //
00046 //  RETURN VALUE:
00047 //      none
00048 //
00049 //  COMMENTS:
00050 //
00051 void main()
00052 {
00053     PSID psidUser, psidEveryone;
00054     PACL pAcl;
00055     SECURITY_DESCRIPTOR sd;
00056     SECURITY_ATTRIBUTES sa;
00057     BOOL bRes;
00058     HANDLE hFile;
00059     DWORD dwBytesWritten, cbMsg, cbAcl;
00060     char szMsg[] = "Protected data\n";
00061
00062
00063     // Get the SIDs we'll need for the DACL
00064     //
00065     psidUser = GetUserSid();
00066     psidEveryone = CreateWorldSid();
00067
00068
00069     // Allocate space for the ACL
00070         //      For information about computing the size of the ACL, see
00071         //      the Win32 SDK reference entry for InitializeAcl()
00072     //
00073     cbAcl = GetLengthSid (psidUser) + GetLengthSid (psidEveryone) +
00074             sizeof(ACL) + (2 * (sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)));
00075
00076     pAcl = (PACL) HeapAlloc(GetProcessHeap(), 0, cbAcl);
00077     if (NULL == pAcl) {
00078                 fprintf(stderr, "HeapAlloc failed.\n");
00079                 ExitProcess(EXIT_FAILURE);
00080     }
00081
00082
00083     bRes = InitializeAcl(pAcl,
00084                     cbAcl,
00085                     ACL_REVISION);
00086     if (FALSE == bRes) {
00087                 PERR("InitializeAcl");
00088                 ExitProcess(EXIT_FAILURE);
00089     }
00090
00091     // Add Aces for User and World
00092     //
00093     bRes = AddAccessAllowedAce(pAcl,
00094                     ACL_REVISION,
00095                     USER_ACCESS,
00096                     psidUser);
00097     if (FALSE == bRes) {
00098                 PERR("AddAccessAllowedAce");
00099                 ExitProcess(EXIT_FAILURE);
00100     }
00101
00102     bRes = AddAccessAllowedAce(pAcl,
00103                     ACL_REVISION,
00104                     WORLD_ACCESS,
00105                     psidEveryone);
00106     if (FALSE == bRes) {
00107                 PERR("AddAccessAllowedAce");
00108                 ExitProcess(EXIT_FAILURE);
00109     }
00110
00111     // Put together the security descriptor
00112     //
00113     bRes = InitializeSecurityDescriptor(&sd,
00114                         SECURITY_DESCRIPTOR_REVISION);
00115     if (FALSE == bRes) {
00116                 PERR("InitializeSecurityDescriptor");
00117                 ExitProcess(EXIT_FAILURE);
00118     }
00119
00120     bRes = SetSecurityDescriptorDacl(&sd,
00121                         TRUE,
00122                         pAcl,
00123                         FALSE);
00124     if (FALSE == bRes) {
00125                 PERR("SetSecurityDescriptorDacl");
00126                 ExitProcess(EXIT_FAILURE);
00127     }
00128
00129     // Add the security descriptor to the sa structure
00130     //
00131     sa.nLength = sizeof(sa);
00132     sa.lpSecurityDescriptor = &sd;
00133     sa.bInheritHandle = FALSE;
00134
00135     // Generate the file using the security attributes that
00136     // we've assembled
00137     //
00138     hFile = CreateFile(FILENAME,
00139                        GENERIC_READ |
00140                        GENERIC_WRITE,
00141                        0,
00142                        &sa,
00143                        CREATE_ALWAYS,
00144                        FILE_ATTRIBUTE_NORMAL,
00145                        NULL);
00146     if (INVALID_HANDLE_VALUE == hFile) {
00147                 PERR("CreateFile");
00148                 ExitProcess(EXIT_FAILURE);
00149     }
00150
00151     cbMsg = lstrlen(szMsg);
00152
00153     bRes = WriteFile(hFile,
00154                      szMsg,
00155                      cbMsg,
00156                      &dwBytesWritten,
00157                      NULL);
00158     if (FALSE == bRes) {
00159                 PERR("WriteFile");
00160                 ExitProcess(EXIT_FAILURE);
00161     }
00162
00163     if (!CloseHandle(hFile)) {
00164                 PERR("CloseHandle");
00165                 ExitProcess(EXIT_FAILURE);
00166     }
00167
00168     // Clean up
00169     //
00170     HeapFree(GetProcessHeap(), 0, pAcl);
00171     HeapFree(GetProcessHeap(), 0, psidUser);
00172     HeapFree(GetProcessHeap(), 0, psidEveryone);
00173
00174
00175     printf ("Created %s with special access.\n", FILENAME);
00176
00177     ExitProcess(EXIT_SUCCESS);
00178 }
00179
00180
00181 //
00182 //  FUNCTION: GetUserSid
00183 //
00184 //  PURPOSE: Obtains a pointer to the SID for the current user
00185 //
00186 //  PARAMETERS:
00187 //      none
00188 //
00189 //  RETURN VALUE:
00190 //      Pointer to the SID
00191 //
00192 //  COMMENTS:
00193 //      The SID buffer returned by this function is allocated with
00194 //      HeapAlloc and should be freed with HeapFree.
00195 //
00196 PSID GetUserSid()
00197 {
00198     HANDLE hToken;
00199     BOOL bRes;
00200     DWORD cbBuffer, cbRequired;
00201     PTOKEN_USER pUserInfo;
00202     PSID pUserSid;
00203
00204     // The User's SID can be obtained from the process token
00205     //
00206     bRes = OpenProcessToken(GetCurrentProcess(),
00207                             TOKEN_QUERY,
00208                             &hToken);
00209     if (FALSE == bRes) {
00210                 PERR("OpenProcessToken");
00211                 ExitProcess(EXIT_FAILURE);
00212     }
00213
00214     // Set buffer size to 0 for first call to determine
00215     // the size of buffer we need.
00216     //
00217     cbBuffer = 0;
00218     bRes = GetTokenInformation(hToken,
00219                         TokenUser,
00220                         NULL,
00221                         cbBuffer,
00222                         &cbRequired);
00223
00224     if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
00225                 PERR("GetTokenInformation");
00226                 ExitProcess(EXIT_FAILURE);
00227     }
00228
00229     // Allocate a buffer for our token user data
00230     //
00231     cbBuffer = cbRequired;
00232     pUserInfo = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), 0, cbBuffer);
00233     if (NULL == pUserInfo) {
00234                 fprintf(stderr, "HeapAlloc failed.\n");
00235                 ExitProcess(EXIT_FAILURE);
00236     }
00237
00238     // Make the "real" call
00239     //
00240     bRes = GetTokenInformation(hToken,
00241                         TokenUser,
00242                         pUserInfo,
00243                         cbBuffer,
00244                         &cbRequired);
00245     if (FALSE == bRes) {
00246                 PERR("GetTokenInformation");
00247                 ExitProcess(EXIT_FAILURE);
00248     }
00249
00250     // Make another copy of the SID for the return value
00251     //
00252     cbBuffer = GetLengthSid(pUserInfo->User.Sid);
00253
00254     pUserSid = (PSID) HeapAlloc(GetProcessHeap(), 0, cbBuffer);
00255     if (NULL == pUserSid) {
00256                 fprintf(stderr, "HeapAlloc failed.\n");
00257                 ExitProcess(EXIT_FAILURE);
00258     }
00259
00260     bRes = CopySid(cbBuffer, pUserSid, pUserInfo->User.Sid);
00261     if (FALSE == bRes) {
00262                 PERR("CopySid");
00263                 ExitProcess(EXIT_FAILURE);
00264     }
00265
00266     bRes = HeapFree(GetProcessHeap(), 0, pUserInfo);
00267     if (FALSE == bRes) {
00268                 fprintf(stderr, "HeapFree failed.\n");
00269                 ExitProcess(EXIT_FAILURE);
00270     }
00271
00272     return pUserSid;
00273 }
00274
00275
00276 //
00277 //  FUNCTION: CreateWorldSid
00278 //
00279 //  PURPOSE: Creates a SID that represents "Everyone"
00280 //
00281 //  PARAMETERS:
00282 //      none
00283 //
00284 //  RETURN VALUE:
00285 //      A pointer to the SID.
00286 //
00287 //  COMMENTS:
00288 //      The SID buffer returned by this function is allocated with
00289 //      HeapAlloc and should be freed with HeapFree.  I made a copy
00290 //      of the SID on the heap so that when the calling code is done
00291 //      with the SID it can use HeapFree().  This is consistent with
00292 //      other parts of this sample.
00293 //
00294 //      The SID Authority and RID used here are defined in winnt.h.
00295 //
00296 PSID CreateWorldSid()
00297 {
00298     SID_IDENTIFIER_AUTHORITY authWorld = SECURITY_WORLD_SID_AUTHORITY;
00299     PSID pSid, psidWorld;
00300     BOOL bRes;
00301     DWORD cbSid;
00302
00303     bRes = AllocateAndInitializeSid(&authWorld,
00304                     1,
00305                     SECURITY_WORLD_RID,
00306                     0,
00307                     0,
00308                     0,
00309                     0,
00310                     0,
00311                     0,
00312                     0,
00313                     &psidWorld);
00314     if (FALSE == bRes) {
00315                 PERR("AllocateAndInitializeSid");
00316                 ExitProcess(EXIT_FAILURE);
00317     }
00318
00319     // Make a copy of the SID using a HeapAlloc'd block for return
00320     //
00321     cbSid = GetLengthSid(psidWorld);
00322
00323     pSid = (PSID) HeapAlloc(GetProcessHeap(), 0, cbSid);
00324     if (NULL == pSid) {
00325                 fprintf(stderr, "HeapAlloc failed.\n");
00326                 ExitProcess(EXIT_FAILURE);
00327     }
00328
00329     bRes = CopySid(cbSid, pSid, psidWorld);
00330     if (FALSE == bRes) {
00331                 PERR("CopySid");
00332                 ExitProcess(EXIT_FAILURE);
00333     }
00334
00335     FreeSid(psidWorld);
00336
00337     return pSid;
00338 }
00339
00340
00341 //
00342 //  FUNCTION: GetLastErrorText
00343 //
00344 //  PURPOSE: Retrieves the text associated with the last system error.
00345 //
00346 //  PARAMETERS:
00347 //      none
00348 //
00349 //  RETURN VALUE:
00350 //      A pointer to the error text.
00351 //
00352 //  COMMENTS:
00353 //      The contents of the returned buffer will only be valid until
00354 //      the next call to this routine.
00355 //
00356 LPSTR GetLastErrorText()
00357 {
00358 #define MAX_MSG_SIZE 256
00359
00360     static char szMsgBuf[MAX_MSG_SIZE];
00361     DWORD dwError, dwRes;
00362
00363     dwError = GetLastError ();
00364
00365     dwRes = FormatMessage (
00366                                 FORMAT_MESSAGE_FROM_SYSTEM,
00367                 NULL,
00368                 dwError,
00369                 MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US),
00370                                 szMsgBuf,
00371                                 MAX_MSG_SIZE,
00372                                 NULL);
00373     if (0 == dwRes) {
00374                 fprintf(stderr, "FormatMessage failed with %d\n", GetLastError());
00375                 ExitProcess(EXIT_FAILURE);
00376     }
00377
00378     return szMsgBuf;
00379 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CListViewLite Member List

This is the complete list of members for CListViewLite, including all inherited members.
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CListViewLite(HWND hWndParent=NULL, UINT nID=0) | CListViewLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CSplitterLite(HWND hWndParent=NULL, UINT nID=0) | CSplitterLite |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeleteAllItems() | CListViewLite | [inline]
DeleteColumn(INDEX nCol) | CListViewLite | [inline]
DeleteItem(INDEX iItem) | CListViewLite | [inline]
DestroyWindow() | CWndLite | [virtual]
DrawSplitter(HDC hDC, BOOL fVertical, REFRECT rectLeft, REFRECT rectRight, REFPOINTS ptsClient) | CSplitterLite | [virtual]
EditLabel(INDEX iItem) | CListViewLite | [inline]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EnsureVisible(INDEX iItem, bool fPartialOK=FALSE) | CListViewLite | [inline]
GetColumnWidth(INDEX nCol) | CListViewLite | [inline]
GetCountPerPage() | CListViewLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetItemCount() | CListViewLite | [inline]
GetItemImage(INDEX iItem, INDEX iSubItem=0) | CListViewLite |
GetItemParam(INDEX iItem) | CListViewLite |
GetItemState(INDEX iItem, UINT nMask) | CListViewLite | [inline]
GetItemText(INDEX iItem, INDEX iSubItem, WCHAR *wszName, ULONG ulMaxChars) | CListViewLite |
GetNextItem(INDEX iItem, INT nFlags) | CListViewLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
HitTest(REFPOINTS pts, UINT *pFlags=NULL, BOOL fClientCoords=TRUE) | CListViewLite |
InsertColumn(INDEX iColumn, WCHAR *wszName, INT iImage=IMAGE_NONE) | CListViewLite |
InsertItem(INDEX iItem, INDEX iSubItem, WCHAR *wszName, LPARAM lParam=PARAM_NONE, INT iImage=IMAGE_NONE, UINT iState=IMAGE_NONE, UINT iStateMask=IMAGE_NONE) | CListViewLite |
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hCursorOld | CSplitterLite |
m_hCursorRight | CSplitterLite |
m_hCursorTop | CSplitterLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iBorderCX | CSplitterLite |
m_iBorderCY | CSplitterLite |
m_nID | CWndLite |
m_pCWndBottom | CSplitterLite |
m_pCWndLeft | CSplitterLite |
m_pCWndRight | CSplitterLite |
m_pCWndTop | CSplitterLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnBorder(REFPOINTS pts, INT iBorder) | CSplitterLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnColumnClick(INT idCtrl, NMLISTVIEW *pNMListView) | CListViewLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CListViewLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnItemActivate(INT idCtrl, NMLISTVIEW *pNMListView) | CListViewLite | [virtual]
OnItemChanged(INT idCtrl, NMLISTVIEW *pNMListView) | CListViewLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CSplitterLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CListViewLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetColumn(INDEX iColumn, WCHAR *wszName, INT iImage=IMAGE_NONE) | CListViewLite |
SetColumnWidth(INDEX nCol, INT cx) | CListViewLite | [inline]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetItemImage(INDEX iItem, INDEX iSubItem, INT iImage) | CListViewLite |
SetItemParam(INDEX iItem, INDEX iSubItem, LPARAM lParam) | CListViewLite |
SetItemState(INDEX iItem, INDEX iSubItem, UINT iState, UINT iStateMask) | CListViewLite |
SetItemText(INDEX iItem, INDEX iSubItem, WCHAR *pwszName) | CListViewLite |
SetSplitter(CSplitterLite *pCWndTop, CSplitterLite *pCWndBottom=NULL, CSplitterLite *pCWndLeft=NULL, CSplitterLite *pCWndRight=NULL) | CSplitterLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
StartTracking(REFPOINTS ptsScreen, REFRECT rectLeft, REFRECT rectRight, BOOL fVertical, POINT *pPoint) | CSplitterLite | [virtual]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CListViewLite() | CListViewLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCOrder/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCOrder

StdAfx.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      stdafx.cpp
00003
00004   Summary:   source file that includes just the standard includes
00005              stdafx.pch will be the pre-compiled header
00006              stdafx.obj will contain the pre-compiled type information
00007
00008   Classes:   None
00009 -----------------------------------------------------------------------------
00010
00011 This file is part of the Microsoft COM+ Samples.
00012
00013 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00014
00015 This source code is intended only as a supplement to Microsoft
00016 Development Tools and/or on-line documentation. See these other
00017 materials for detailed information regarding Microsoft code samples.
00018
00019 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00020 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00022 PARTICULAR PURPOSE.
00023
00024 ==========================================================================+*/
00025
00026 #include "stdafx.h"
00027
00028 #ifdef _ATL_STATIC_REGISTRY
00029 #include <statreg.h>
00030 #include <statreg.cpp>
00031 #endif
00032
00033 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/delebase.h Source File

  • SysMgmt
  • MMC
  • Multisel

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CComponentData;
00030
00031 class CDelegationBase {
00032 public:
00033     CDelegationBase();
00034     virtual ~CDelegationBase();
00035
00036     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00037     virtual void GetChildColumnInfo(RESULTDATAITEM *rdi) { }
00038     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00039
00040     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00041     virtual const int GetBitmapIndex() = 0;
00042
00043   virtual CDelegationBase *GetChildPtr(int index) { return NULL; }
00044
00045     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00046
00047   virtual HRESULT SelectItem(IConsole *pConsole)
00048   {
00049     return pConsole->SelectScopeItem(HSCOPEITEM(m_handle));
00050   }
00051
00052 public:
00053     // virtual functions go here (for MMCN_*)
00054     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00055     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00056     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00057     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00058     virtual HRESULT OnRefresh(IConsole *pConsole) { return S_FALSE; }
00059   virtual HRESULT OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) { return S_FALSE; }
00060     virtual HRESULT OnRename(LPOLESTR pszNewName) { return S_FALSE; }
00061
00062   virtual HRESULT OnDelete(IConsole *pConsole) { return S_FALSE; }
00063
00064 public:
00065     static HBITMAP m_pBMapSm;
00066     static HBITMAP m_pBMapLg;
00067
00068   HANDLE GetHandle() { return m_handle; }
00069   void SetHandle(HANDLE handle) { m_handle = handle; }
00070
00071 protected:
00072     static void LoadBitmaps() {
00073         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00074         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00075     }
00076
00077     BOOL bExpanded;
00078
00079 private:
00080     // {2974380B-4C4B-11d2-89D8-000021473128}
00081     static const GUID thisGuid;
00082   HANDLE m_handle;
00083 };
00084
00085 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/ListWIN.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

ListWIN.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      LISTWIN.H
00003
00004   Summary:   Include file for the C++ object that encapsulates the
00005              list box control that displays the page list.
00006
00007   Classes:   CListWin
00008
00009   Functions: none.
00010
00011   Origin:    5-25-97: atrent - Editor Inheritance from CMsgLog in
00012              APPUTIL.H.
00013
00014 ----------------------------------------------------------------------------
00015   This file is part of the Microsoft COM Tutorial Code Samples.
00016
00017   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00018
00019   This source code is intended only as a supplement to Microsoft
00020   Development Tools and/or on-line documentation.  See these other
00021   materials for detailed information regarding Microsoft code samples.
00022
00023   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00024   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00025   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00026   PARTICULAR PURPOSE.
00027 ==========================================================================+*/
00028
00029 // Don't allow recursive includes of this file.
00030 #ifndef LISTWIN_H
00031 #define LISTWIN_H
00032
00033 #define MAXLINE_SIZE 128
00034 #define MAX_SHOW_LINES 200
00035
00036 // ListWin command IDs.
00037 #define IDC_LISTWIN 7000
00038
00039
00040 #ifdef __cplusplus
00041
00042
00043 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00044   Class:    CListWin
00045
00046   Summary:  Class for the PageList display Listbox window.
00047
00048   Methods:  CListWin
00049               Constructor.
00050             ~CListWin
00051               Destructor.
00052             BOOL Create(HINSTANCE hInst, HWND hWndParent, BOOL bSeparate);
00053               Creates the CListWin List Box as a separate child window.
00054             BOOL SetCurSel(INT iIndex);
00055               Set current selection to specified list item. Zero-based.
00056             BOOL GetCurSel(INT* piIndex);
00057               Get the index (page number) of current listbox selection.
00058             BOOL AddFmt(LPTSTR szFmt, ...);
00059               Add a printf-style formatted string as new line in listbox.
00060             BOOL InsertFmt(INT iIndex, LPTSTR szFmt, ...);
00061               Insert a printf-style formatted line in the listbox.
00062             BOOL Resize(INT nWidth, INT nHeight);
00063               Resizes the ListWin listbox to a new width and height.
00064             BOOL Clear(void);
00065               Clears all display lines from the ListWin.
00066 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00067 class CListWin
00068 {
00069 public:
00070   // Constructor.
00071   CListWin()
00072   {
00073     m_hInst = NULL;
00074     m_hWnd = NULL;
00075     m_bSeparate = FALSE;
00076   };
00077
00078   ~CListWin()
00079   {
00080   };
00081
00082   BOOL Create(HINSTANCE hInst, HWND hWndParent, BOOL bSeparate);
00083   BOOL SetCurSel(INT iIndex);
00084   BOOL GetCurSel(INT* piIndex);
00085   BOOL AddFmt(LPTSTR szFmt, ...);
00086   BOOL InsertFmt(INT iIndex, LPTSTR szFmt, ...);
00087   BOOL Resize(INT nWidth, INT nHeight);
00088   BOOL Clear(void);
00089
00090 private:
00091   // Remember the App Instance Handle.
00092   HINSTANCE m_hInst;
00093   // Remember the handle of the listbox window.
00094   HWND m_hWnd;
00095   // Remember if CListWin was created as separate window.
00096   BOOL m_bSeparate;
00097 };
00098
00099
00100 #endif //__cplusplus
00101
00102 #endif //LISTWIN_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SECTION Member List

This is the complete list of members for _SECTION, including all inherited members.
cBytes | _SECTION
cProperties | _SECTION
rgPropId | _SECTION
rgPropValue | _SECTION
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDBFile Member List

This is the complete list of members for CDBFile, including all inherited members.
AddRow(CRow *pRow, ATLCOLUMNINFO *prgColInfo, ULONG ulCols) | CDBFile |
AllocateProxyBuffers(bool bUseBookmarks) | CDBFile |
CDBFile() | CDBFile | [inline]
Close() | CDBFile |
DeleteRowImmediate(CRow *pRow) | CDBFile |
ExpandFileAndAdjustRowObjects(ULONG ulBytesNeeded, bool bExpOrCon=EXPAND_FILE) | CDBFile |
FetchRow(CRow **pRow) | CDBFile |
FillRowArray() | CDBFile |
GetFileSchemaInfo(LPCTSTR pszFileName) | CDBFile |
GetSchemaInfo(ULONG *pNumCols) | CDBFile |
InsertRowImmediate(CRow *pRow, ATLCOLUMNINFO *pColInfo, ULONG ulCols, bool bData) | CDBFile |
m_bClosed | CDBFile |
m_cCols | CDBFile |
m_hFile | CDBFile |
m_hMapFile | CDBFile |
m_pbCurrentPos | CDBFile |
m_pbEOF | CDBFile |
m_pFileMap | CDBFile |
m_prgColInfo | CDBFile |
m_Rows | CDBFile |
m_szTblNm | CDBFile |
Open(LPCTSTR pszFileName, bool bOpenMode=false) | CDBFile |
SaveAndReOpenFile() | CDBFile |
UpdateRowImmediate(CRow *pRow, ATLCOLUMNINFO *pColInfo, ULONG ulCols) | CDBFile |
~CDBFile() | CDBFile |
Generated on Wed Nov 13 2024 16:56:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/Cset.Hxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

Cset.Hxx

Go to the documentation of this file.
00001
00002 /*
00003     this option allows to select a type of characters
00004     and either print/display only the characters in the
00005   set, or to color them, whatever.
00006
00007   To make this work i need to
00008     a) have a way to
00009       1) identify
00010       2) create
00011       3) combine
00012         the subsets
00013
00014     b) be able to determin whether a character
00015        IsInSet
00016        and which is the next character in the set
00017
00018     c) associate an action with the set
00019       actions are
00020         fg, bg color and ignore
00021         (can use fg color=white for ignore)
00022       and can be kept in a single WORD
00023
00024   As sources for subsets I have:
00025     i)  named subsets (ISO 10646)
00026     ii) character properties
00027
00028 */
00029
00030 #ifndef _CSET_HXX_
00031 #define _CSET_HXX_
00032
00033 // base class for any form of set
00034
00035 class CSet
00036 {
00037   public:
00038     virtual BOOL In(WORD iChar) = 0;
00039     //virtual WORD Next(WORD iChar) = 0;
00040     //virtual WORD Prev(WORD iChar) = 0;
00041   protected:
00042 } ;
00043
00044
00045
00046 // Set based on CType
00047 class CCTypeSet : public CSet
00048 {
00049   public:
00050     CCTypeSet(WORD fC1Mask, WORD fC2Test, WORD fC3Mask);
00051     BOOL In(WORD iChar);
00052   protected:
00053     void GetPageData( WORD iPage );
00054     BOOL _pCharInSet[256];
00055     BOOL _pPageInSet[256];
00056     WORD _fC1Mask;
00057     WORD _fC2Test;  // C2 is an enumerated field
00058     WORD _fC3Mask;
00059     WORD _iPage;
00060 } ;
00061
00062
00063
00064 // Set based on font coverage
00065 class CFontSet: public CSet
00066 {
00067   public:
00068     CFontSet(HWND hwnd, HFONT hfont) ;
00069 } ;
00070
00071 #endif
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EdAnnotator/AnnotatorProject/dlldata.c Source File

  • Web
  • Browser
  • EdAnnotator
  • AnnotatorProject

dlldata.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 /*********************************************************
00006    DllData file -- generated by MIDL compiler
00007
00008         DO NOT ALTER THIS FILE
00009
00010    This file is regenerated by MIDL on every IDL file compile.
00011
00012    To completely reconstruct this file, delete it and rerun MIDL
00013    on all the IDL files in this DLL, specifying this file for the
00014    /dlldata command line option
00015
00016 *********************************************************/
00017
00018 #define PROXY_DELEGATION
00019
00020 #include <rpcproxy.h>
00021
00022 #ifdef __cplusplus
00023 extern "C"   {
00024 #endif
00025
00026 EXTERN_PROXY_FILE( EDAnnotator )
00027
00028
00029 PROXYFILE_LIST_START
00030 /* Start of list */
00031   REFERENCE_PROXY_FILE( EDAnnotator ),
00032 /* End of list */
00033 PROXYFILE_LIST_END
00034
00035
00036 DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
00037
00038 #ifdef __cplusplus
00039 }  /*extern "C" */
00040 #endif
00041
00042 /* end of generated dlldata file */
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/Encrypt/Encrypt.c Source File

  • Security
  • CryptoApi
  • Encrypt

Encrypt.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008 \******************************************************************************/
00009
00010 #include <windows.h>
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <wincrypt.h>
00014
00015
00016 #ifdef USE_BLOCK_CIPHER
00017     // defines for RC2 block cipher
00018     #define ENCRYPT_ALGORITHM   CALG_RC2
00019     #define ENCRYPT_BLOCK_SIZE  8
00020 #else
00021     // defines for RC4 stream cipher
00022     #define ENCRYPT_ALGORITHM   CALG_RC4
00023     #define ENCRYPT_BLOCK_SIZE  1
00024 #endif
00025
00026 // This sample uses an explicit key length instead of a default key length
00027 // so that it can be used between different relases of the OS that have different
00028 // default key lengths. Key length here is set to 128 bits.
00029
00030 #define KEYLENGTH 0x00800000
00031
00032 static BOOL CAPIEncryptFile(PCHAR szSource, PCHAR szDestination, PCHAR szPassword);
00033
00034 /*****************************************************************************/
00035 void _cdecl main(int argc, char *argv[])
00036 {
00037     PCHAR szSource      = NULL;
00038     PCHAR szDestination = NULL;
00039     PCHAR szPassword    = NULL;
00040
00041     // Validate argument count.
00042     if(argc != 3 && argc != 4) {
00043         printf("USAGE: encrypt <source file> <dest file> [ <password> ]\n");
00044         exit(1);
00045     }
00046
00047     // Parse arguments.
00048     szSource       = argv[1];
00049     szDestination  = argv[2];
00050     if(argc == 4) {
00051         szPassword = argv[3];
00052     }
00053
00054     if(!CAPIEncryptFile(szSource, szDestination, szPassword)) {
00055         printf("Error encrypting file!\n");
00056         exit(1);
00057     }
00058
00059     exit(0);
00060 }
00061
00062 /*****************************************************************************/
00063 static BOOL CAPIEncryptFile(PCHAR szSource, PCHAR szDestination, PCHAR szPassword)
00064 {
00065     FILE *hSource      = NULL;
00066     FILE *hDestination = NULL;
00067     INT eof = 0;
00068
00069     HCRYPTPROV hProv   = 0;
00070     HCRYPTKEY hKey     = 0;
00071     HCRYPTKEY hXchgKey = 0;
00072     HCRYPTHASH hHash   = 0;
00073
00074     PBYTE pbKeyBlob = NULL;
00075     DWORD dwKeyBlobLen;
00076
00077     PBYTE pbBuffer = NULL;
00078     DWORD dwBlockLen;
00079     DWORD dwBufferLen;
00080     DWORD dwCount;
00081
00082     BOOL status = FALSE;
00083
00084     // Open source file.
00085     if((hSource = fopen(szSource,"rb")) == NULL) {
00086         printf("Error opening Plaintext file!\n");
00087         goto done;
00088     }
00089
00090     // Open destination file.
00091     if((hDestination = fopen(szDestination,"wb")) == NULL) {
00092         printf("Error opening Ciphertext file!\n");
00093         goto done;
00094     }
00095
00096     // Get handle to the CSP. In order to be used with different OSs
00097   // with different default provides, the CSP is explicitly set.
00098   // If the Microsoft Enhanced Provider is not installed, set parameter
00099   // three to MS_DEF_PROV
00100
00101   if(!CryptAcquireContext(&hProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)) {
00102         printf("Error %x during CryptAcquireContext!\n", GetLastError());
00103         goto done;
00104     }
00105
00106     if(szPassword == NULL) {
00107         // Encrypt the file with a random session key.
00108
00109         // Create a random session key.
00110         if(!CryptGenKey(hProv, ENCRYPT_ALGORITHM, KEYLENGTH | CRYPT_EXPORTABLE, &hKey)) {
00111             printf("Error %x during CryptGenKey!\n", GetLastError());
00112             goto done;
00113         }
00114
00115         // Get handle to key exchange public key.
00116         if(!CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hXchgKey)) {
00117             printf("Error %x during CryptGetUserKey!\n", GetLastError());
00118             goto done;
00119         }
00120
00121         // Determine size of the key blob and allocate memory.
00122         if(!CryptExportKey(hKey, hXchgKey, SIMPLEBLOB, 0, NULL, &dwKeyBlobLen)) {
00123             printf("Error %x computing blob length!\n", GetLastError());
00124             goto done;
00125         }
00126         if((pbKeyBlob = (unsigned char *) malloc(dwKeyBlobLen)) == NULL) {
00127             printf("Out of memory!\n");
00128             goto done;
00129         }
00130
00131         // Export session key into a simple key blob.
00132         if(!CryptExportKey(hKey, hXchgKey, SIMPLEBLOB, 0, pbKeyBlob, &dwKeyBlobLen)) {
00133             printf("Error %x during CryptExportKey!\n", GetLastError());
00134             goto done;
00135         }
00136
00137         // Release key exchange key handle.
00138         CryptDestroyKey(hXchgKey);
00139         hXchgKey = 0;
00140
00141         // Write size of key blob to destination file.
00142         fwrite(&dwKeyBlobLen, sizeof(DWORD), 1, hDestination);
00143         if(ferror(hDestination)) {
00144             printf("Error writing header!\n");
00145             goto done;
00146         }
00147
00148         // Write key blob to destination file.
00149         fwrite(pbKeyBlob, 1, dwKeyBlobLen, hDestination);
00150         if(ferror(hDestination)) {
00151             printf("Error writing header!\n");
00152             goto done;
00153         }
00154
00155     } else {
00156         // Encrypt the file with a session key derived from a password.
00157
00158         // Create a hash object.
00159         if(!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)) {
00160             printf("Error %x during CryptCreateHash!\n", GetLastError());
00161             goto done;
00162         }
00163
00164         // Hash in the password data.
00165         if(!CryptHashData(hHash, (const unsigned char *)szPassword, (DWORD)strlen(szPassword), 0)) {
00166             printf("Error %x during CryptHashData!\n", GetLastError());
00167             goto done;
00168         }
00169
00170         // Derive a session key from the hash object.
00171         if(!CryptDeriveKey(hProv, ENCRYPT_ALGORITHM, hHash, KEYLENGTH, &hKey)) {
00172             printf("Error %x during CryptDeriveKey!\n", GetLastError());
00173             goto done;
00174         }
00175
00176         // Destroy the hash object.
00177         CryptDestroyHash(hHash);
00178         hHash = 0;
00179     }
00180
00181     // Determine number of bytes to encrypt at a time. This must be a multiple
00182     // of ENCRYPT_BLOCK_SIZE.
00183     dwBlockLen = 1000 - 1000 % ENCRYPT_BLOCK_SIZE;
00184
00185     // Determine the block size. If a block cipher is used this must have
00186     // room for an extra block.
00187     if(ENCRYPT_BLOCK_SIZE > 1) {
00188         dwBufferLen = dwBlockLen + ENCRYPT_BLOCK_SIZE;
00189     } else {
00190         dwBufferLen = dwBlockLen;
00191     }
00192
00193     // Allocate memory.
00194     if((pbBuffer = (unsigned char *) malloc(dwBufferLen)) == NULL) {
00195         printf("Out of memory!\n");
00196         goto done;
00197     }
00198
00199     // Encrypt source file and write to Source file.
00200     do {
00201         // Read up to 'dwBlockLen' bytes from source file.
00202         dwCount = (DWORD)fread(pbBuffer, 1, dwBlockLen, hSource);
00203         if(ferror(hSource)) {
00204             printf("Error reading Plaintext!\n");
00205             goto done;
00206         }
00207         eof = feof(hSource);
00208
00209         // Encrypt data
00210         if(!CryptEncrypt(hKey, 0, eof, 0, pbBuffer, &dwCount, dwBufferLen)) {
00211             printf("bytes required:%d\n",dwCount);
00212             printf("Error %x during CryptEncrypt!\n", GetLastError());
00213             goto done;
00214         }
00215
00216         // Write data to destination file.
00217         fwrite(pbBuffer, 1, dwCount, hDestination);
00218         if(ferror(hDestination)) {
00219             printf("Error writing Ciphertext!\n");
00220             goto done;
00221         }
00222     } while(!feof(hSource));
00223
00224     status = TRUE;
00225
00226     printf("OK\n");
00227
00228     done:
00229
00230     // Close files.
00231     if(hSource) fclose(hSource);
00232     if(hDestination) fclose(hDestination);
00233
00234     // Free memory.
00235     if(pbKeyBlob) free(pbKeyBlob);
00236     if(pbBuffer) free(pbBuffer);
00237
00238     // Destroy session key.
00239     if(hKey) CryptDestroyKey(hKey);
00240
00241     // Release key exchange key handle.
00242     if(hXchgKey) CryptDestroyKey(hXchgKey);
00243
00244     // Destroy hash object.
00245     if(hHash) CryptDestroyHash(hHash);
00246
00247     // Release provider handle.
00248     if(hProv) CryptReleaseContext(hProv, 0);
00249
00250     return(status);
00251 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/llistimpl.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

llistimpl.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.cpp: implementation of CLListImpl helper functions
00013 //
00014
00015
00016 #include "LListImpl.h"
00017
00018
00019 //---------------------------------------------------------------------------
00020 CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
00021 {
00022   _ASSERT( nMax > 0 && cbElement > 0 );
00023   CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
00024       // may throw exception
00025   p->pNext = pHead;
00026   pHead = p;  // change head (adds in reverse order for simplicity)
00027   return p;
00028
00029 } //end Create()
00030
00031 //---------------------------------------------------------------------------
00032 // Free this one and links
00033 //
00034 void CPlex::FreeDataChain()
00035 {
00036   CPlex* p = this;
00037   while (p != NULL)
00038   {
00039     BYTE* bytes = (BYTE*) p;
00040     CPlex* pNext = p->pNext;
00041     delete[] bytes;
00042     p = pNext;
00043   }
00044 } //end FreeDataChain()
00045
00046 //---------------------------------------------------------------------------
00047 // IsValidAddress() returns TRUE if the passed parameter points
00048 // to at least nBytes of accessible memory. If bReadWrite is TRUE,
00049 // the memory must be writeable; if bReadWrite is FALSE, the memory
00050 // may be const.
00051 //
00052 BOOL IsValidAddress
00053 (
00054   const void*  lp,
00055   UINT         nBytes,
00056   BOOL         bReadWrite /* TRUE */
00057 )
00058 {
00059   // Simple version using Win-32 APIs for pointer validation.
00060   return (lp != NULL && !IsBadReadPtr(lp, nBytes) &&
00061          (!bReadWrite || !IsBadWritePtr((LPVOID)lp, nBytes)));
00062
00063 } //end IsValidAddress()
00064
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Custom/SpinCube/SpinTest.h Source File

  • WinUI
  • Controls
  • Custom
  • SpinCube

SpinTest.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *
00003 *                                 SPINTEST.H
00004 *
00005 \******************************************************************************/
00006
00007
00008
00009 /******************************************************************************\
00010 *                             SYMBOLIC CONSTANTS
00011 \******************************************************************************/
00012
00013 #define IDM_DLGEDITDIALOG  101  /* menuitem id's */
00014 #define IDM_SPINTESTSTATS  102
00015 #define IDM_ABOUT          103
00016
00017 #define BORDER             4
00018
00019 #define IDS_REGCLASSFAIL    16
00020 #define IDS_WINDOWTITLE     17
00021
00022 //
00023 // Spincube window styles as defined in spincube.h.
00024 //
00025
00026 #define SS_ERASE                0x0001
00027 #define SS_INMOTION             0x0002
00028
00029
00030
00031 /******************************************************************************\
00032 *                               GLOBAL VARIABLES
00033 \******************************************************************************/
00034
00035 HINSTANCE   ghInst;
00036 HWND        gahwndSpin[4];
00037
00038
00039 /******************************************************************************\
00040 *                              FUNCTION PROTOTYPES
00041 \******************************************************************************/
00042
00043 LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM);
00044 LRESULT CALLBACK DlgProc     (HWND, UINT, WPARAM, LPARAM);
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSpaceVehicle Member List

This is the complete list of members for CSpaceVehicle, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
children | CSpaceVehicle | [private]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CSpaceVehicle(CComponentData *pComponentData=NULL) | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
CSpaceVehicle(CComponentData *pComponentData=NULL) | CSpaceVehicle |
CSpaceVehicle() | CSpaceVehicle |
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetBitmapIndex() | CSpaceVehicle | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceVehicle | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
getNodeType() | CSpaceVehicle | [inline, virtual]
GetParentScopeItem() | CSpaceVehicle | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
IDM_NEW_SPACE enum value | CSpaceVehicle | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_cchildren | CSpaceVehicle | [private]
m_hParentHScopeItem | CSpaceVehicle | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
MAX_NUMBER_OF_CHILDREN enum value | CSpaceVehicle | [private]
NUMBER_OF_CHILDREN enum value | CSpaceVehicle | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CSpaceVehicle | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CSpaceVehicle | [virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CSpaceVehicle | [virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CSpaceVehicle | [virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CSpaceVehicle | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CSpaceVehicle | [virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CSpaceVehicle | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
~CSpaceVehicle() | CSpaceVehicle | [virtual]
Generated on Wed Nov 13 2024 16:57:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

MainDlg Member List

This is the complete list of members for MainDlg, including all inherited members.
AgentNotifySink class | MainDlg | [friend]
Init() | MainDlg |
ListBoxWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | MainDlg | [friend]
LoadCharacter(LPCTSTR pszFilename) | MainDlg |
m_bAddedCommands | MainDlg | [private]
m_bHasMRUSeparator | MainDlg | [private]
m_hAccel | MainDlg |
m_hWnd | MainDlg |
m_lCharacterID | MainDlg | [private]
m_lCmdPropertiesID | MainDlg | [private]
m_lSinkID | MainDlg | [private]
m_pAgent | MainDlg | [private]
m_pBalloon | MainDlg | [private]
m_pCharacter | MainDlg | [private]
m_pSink | MainDlg | [private]
m_wpListBox | MainDlg | [private]
m_wpMoveX | MainDlg | [private]
m_wpMoveY | MainDlg | [private]
m_wpSpeakText | MainDlg | [private]
MainDlg() | MainDlg |
MakeEllipsisPath(LPCTSTR pszPath, LPTSTR pszEllipsisPath, UINT cchMaxEllipsisPath) | MainDlg | [private]
MoveXWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | MainDlg | [friend]
MoveYWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | MainDlg | [friend]
OnActivateApp(BOOL bActive) | MainDlg | [private]
OnButtonClick(UINT uID) | MainDlg | [private]
OnCharacterCommand(long lID) | MainDlg | [private]
OnCharacterMove(long x, long y) | MainDlg | [private]
OnCharacterRightClick(long x, long y) | MainDlg | [private]
OnCommand(WPARAM wParam, LPARAM lParam) | MainDlg | [private]
OnDestroy() | MainDlg | [private]
OnDropFiles(HDROP hDrop) | MainDlg | [private]
OnInitDialog() | MainDlg | [private]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL bSysMenu) | MainDlg | [private]
OnPropertyChange() | MainDlg | [private]
OnRecentFile(UINT uFile) | MainDlg | [private]
OnSpeak() | MainDlg | [private]
OnSysCommand(WPARAM wParam) | MainDlg | [private]
SpeakTextWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | MainDlg | [friend]
UpdateRecentFiles(LPCTSTR pszFilename) | MainDlg | [private]
WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | MainDlg | [friend]
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/rtcsample/rtcdialogs.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • rtcsample

rtcdialogs.cpp

Go to the documentation of this file.
00001 // rtcdialogs.cpp
00002 //
00003
00004 #include "stdafx.h"
00005
00006 /////////////////////////////////////////////
00007 //
00008 // CleanUserURI
00009 //
00010 // Assumes buffer length to be MAX_STRING
00011 //
00012
00013 void CleanUserURI(WCHAR * szURI)
00014 {
00015     // If the user URI does not start with sip: then
00016     // add it
00017     if (wcsncmp(szURI, L"sip:", 4))
00018     {
00019         WCHAR szTemp[MAX_STRING];
00020
00021         wcscpy(szTemp, szURI);
00022         _snwprintf(szURI, MAX_STRING, L"sip:%s", szTemp);
00023     szURI[MAX_STRING-1] = L'\0';
00024
00025     }
00026
00027     // Also, strip off any parameters to the user URI
00028     WCHAR *ch = wcschr(szURI, L';');
00029
00030     if (ch != NULL)
00031     {
00032         *ch = L'\0';
00033     }
00034 }
00035
00036 /////////////////////////////////////////////
00037 //
00038 // LOGON_DATA
00039 //
00040
00041 struct LOGON_DATA
00042 {
00043     WCHAR szUserURI[MAX_STRING];
00044     WCHAR szServer[MAX_STRING];
00045     WCHAR szTransport[MAX_STRING];
00046 };
00047
00048 /////////////////////////////////////////////
00049 //
00050 // LogonDialogProc
00051 //
00052
00053 INT_PTR CALLBACK LogonDialogProc(
00054   HWND hwndDlg,  // handle to dialog box
00055   UINT uMsg,     // message
00056   WPARAM wParam, // first message parameter
00057   LPARAM lParam  // second message parameter
00058 )
00059 {
00060     LOGON_DATA *pLD;
00061     pLD = (LOGON_DATA *)GetWindowLong(hwndDlg, DWL_USER);
00062
00063     switch (uMsg)
00064     {
00065     case WM_INITDIALOG:
00066         {
00067             // Store the LOGON_DATA pointer in the
00068             // window's user data
00069             SetWindowLong(hwndDlg, DWL_USER, lParam);
00070
00071             // Populate the transport combo box
00072             HWND hwndCombo = GetDlgItem(hwndDlg, IDC_COMBO_LOGON_TRANSPORT);
00073
00074             SendMessageW(hwndCombo, CB_ADDSTRING, 0, (LPARAM)L"TCP");
00075             SendMessageW(hwndCombo, CB_ADDSTRING, 0, (LPARAM)L"UDP");
00076             SendMessageW(hwndCombo, CB_ADDSTRING, 0, (LPARAM)L"TLS");
00077             SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
00078         }
00079         return TRUE;
00080
00081     case WM_COMMAND:
00082         switch (LOWORD(wParam))
00083         {
00084         case IDOK:
00085             {
00086                 GetDlgItemTextW(
00087                     hwndDlg,
00088                     IDC_EDIT_LOGON_USERURI,
00089                     pLD->szUserURI,
00090                     MAX_STRING
00091                     );
00092
00093                 GetDlgItemTextW(
00094                     hwndDlg,
00095                     IDC_EDIT_LOGON_SERVER,
00096                     pLD->szServer,
00097                     MAX_STRING
00098                     );
00099
00100                 GetDlgItemTextW(
00101                     hwndDlg,
00102                     IDC_COMBO_LOGON_TRANSPORT,
00103                     pLD->szTransport,
00104                     MAX_STRING
00105                     );
00106
00107                 // Fall through
00108             }
00109
00110         case IDCANCEL:
00111             EndDialog(hwndDlg, wParam);
00112             return TRUE;
00113         }
00114     }
00115
00116     return FALSE;
00117 }
00118
00119 /////////////////////////////////////////////
00120 //
00121 // ShowLogonDialog
00122 //
00123
00124 HRESULT ShowLogonDialog(HWND hWndParent,
00125                         BSTR *pbstrURI, BSTR *pbstrServer, BSTR *pbstrTransport)
00126 {
00127     int iRes;
00128     LOGON_DATA ld;
00129
00130     // Show the dialog
00131     iRes = DialogBoxParam(
00132         GetModuleHandle(NULL),
00133         MAKEINTRESOURCE(IDD_DIALOG_LOGON),
00134         hWndParent,
00135         (DLGPROC)LogonDialogProc,
00136         (LPARAM)&ld
00137         );
00138
00139     if (iRes == IDOK)
00140     {
00141         // Check for empty strings
00142         if ((ld.szUserURI[0] == L'\0') ||
00143             (ld.szServer[0] == L'\0') ||
00144             (ld.szTransport[0] == L'\0'))
00145         {
00146             return E_FAIL;
00147         }
00148
00149         // Cleanup the user URI
00150         CleanUserURI(ld.szUserURI);
00151
00152         *pbstrURI = SysAllocString(ld.szUserURI);
00153
00154         if (!(*pbstrURI))
00155         {
00156             // Out of memory
00157             return E_OUTOFMEMORY;
00158         }
00159
00160         *pbstrServer = SysAllocString(ld.szServer);
00161
00162         if (!(*pbstrServer))
00163         {
00164             // Out of memory
00165             SAFE_FREE_STRING(*pbstrURI);
00166             return E_OUTOFMEMORY;
00167         }
00168
00169         *pbstrTransport = SysAllocString(ld.szTransport);
00170
00171         if (!(*pbstrTransport))
00172         {
00173             // Out of memory
00174             SAFE_FREE_STRING(*pbstrURI);
00175             SAFE_FREE_STRING(*pbstrServer);
00176             return E_OUTOFMEMORY;
00177         }
00178
00179         return S_OK;
00180     }
00181
00182     return E_FAIL;
00183 }
00184
00185 /////////////////////////////////////////////
00186 //
00187 // AUTH_DATA
00188 //
00189
00190 struct AUTH_DATA
00191 {
00192     BSTR bstrOldURI;
00193     WCHAR szUserURI[MAX_STRING];
00194     WCHAR szAccount[MAX_STRING];
00195     WCHAR szPassword[MAX_STRING];
00196 };
00197
00198 /////////////////////////////////////////////
00199 //
00200 // AuthDialogProc
00201 //
00202
00203 INT_PTR CALLBACK AuthDialogProc(
00204   HWND hwndDlg,  // handle to dialog box
00205   UINT uMsg,     // message
00206   WPARAM wParam, // first message parameter
00207   LPARAM lParam  // second message parameter
00208 )
00209 {
00210     AUTH_DATA *pAD;
00211     pAD = (AUTH_DATA *)GetWindowLong(hwndDlg, DWL_USER);
00212
00213     switch (uMsg)
00214     {
00215     case WM_INITDIALOG:
00216         {
00217             // Store the AUTH_DATA pointer in the
00218             // window's user data
00219             SetWindowLong(hwndDlg, DWL_USER, lParam);
00220
00221             pAD = (AUTH_DATA *)lParam;
00222
00223             // Populate the user URI edit box
00224             SetDlgItemTextW(hwndDlg, IDC_EDIT_AUTH_USERURI,
00225                             pAD->bstrOldURI);
00226         }
00227         return TRUE;
00228
00229     case WM_COMMAND:
00230         switch (LOWORD(wParam))
00231         {
00232         case IDOK:
00233             {
00234                 GetDlgItemTextW(
00235                     hwndDlg,
00236                     IDC_EDIT_AUTH_USERURI,
00237                     pAD->szUserURI,
00238                     MAX_STRING
00239                     );
00240
00241                 GetDlgItemTextW(
00242                     hwndDlg,
00243                     IDC_EDIT_AUTH_ACCOUNT,
00244                     pAD->szAccount,
00245                     MAX_STRING
00246                     );
00247
00248                 GetDlgItemTextW(
00249                     hwndDlg,
00250                     IDC_EDIT_AUTH_PASSWORD,
00251                     pAD->szPassword,
00252                     MAX_STRING
00253                     );
00254
00255                 // Fall through
00256             }
00257
00258         case IDCANCEL:
00259             EndDialog(hwndDlg, wParam);
00260             return TRUE;
00261         }
00262     }
00263
00264     return FALSE;
00265 }
00266
00267 /////////////////////////////////////////////
00268 //
00269 // ShowAuthDialog
00270 //
00271
00272 HRESULT ShowAuthDialog(HWND hWndParent, BSTR bstrOldURI,
00273                        BSTR *pbstrURI, BSTR *pbstrAccount, BSTR *pbstrPassword)
00274 {
00275     int iRes;
00276     AUTH_DATA ad;
00277
00278     ad.bstrOldURI = bstrOldURI;
00279
00280     // Show the dialog
00281     iRes = DialogBoxParam(
00282         GetModuleHandle(NULL),
00283         MAKEINTRESOURCE(IDD_DIALOG_AUTH),
00284         hWndParent,
00285         (DLGPROC)AuthDialogProc,
00286         (LPARAM)&ad
00287         );
00288
00289     if (iRes == IDOK)
00290     {
00291         // Check for empty strings
00292         if ((ad.szUserURI[0] == L'\0') ||
00293             (ad.szAccount[0] == L'\0') ||
00294             (ad.szPassword[0] == L'\0'))
00295         {
00296             return E_FAIL;
00297         }
00298
00299         // Cleanup the user URI
00300         CleanUserURI(ad.szUserURI);
00301
00302         *pbstrURI = SysAllocString(ad.szUserURI);
00303
00304         if (!(*pbstrURI))
00305         {
00306             // Out of memory
00307             return E_OUTOFMEMORY;
00308         }
00309
00310         *pbstrAccount = SysAllocString(ad.szAccount);
00311
00312         if (!(*pbstrAccount))
00313         {
00314             // Out of memory
00315             SAFE_FREE_STRING(*pbstrURI);
00316             return E_OUTOFMEMORY;
00317         }
00318
00319         *pbstrPassword = SysAllocString(ad.szPassword);
00320
00321         if (!(*pbstrPassword))
00322         {
00323             // Out of memory
00324             SAFE_FREE_STRING(*pbstrURI);
00325             SAFE_FREE_STRING(*pbstrAccount);
00326             return E_OUTOFMEMORY;
00327         }
00328
00329         return S_OK;
00330     }
00331
00332     return E_FAIL;
00333 }
00334
00335 /////////////////////////////////////////////
00336 //
00337 // WATCHER_DATA
00338 //
00339
00340 struct WATCHER_DATA
00341 {
00342     BSTR bstrName;
00343     BSTR bstrURI;
00344     BOOL fAllow;
00345     BOOL fAddBuddy;
00346 };
00347
00348 /////////////////////////////////////////////
00349 //
00350 // WatcherDialogProc
00351 //
00352
00353 INT_PTR CALLBACK WatcherDialogProc(
00354   HWND hwndDlg,  // handle to dialog box
00355   UINT uMsg,     // message
00356   WPARAM wParam, // first message parameter
00357   LPARAM lParam  // second message parameter
00358 )
00359 {
00360     WATCHER_DATA *pWD;
00361     pWD = (WATCHER_DATA *)GetWindowLong(hwndDlg, DWL_USER);
00362
00363     switch (uMsg)
00364     {
00365     case WM_INITDIALOG:
00366         {
00367             // Store the WATCHER_DATA pointer in the
00368             // window's user data
00369             SetWindowLong(hwndDlg, DWL_USER, lParam);
00370             pWD = (WATCHER_DATA *)lParam;
00371
00372             // Populate the watcher text
00373             SendDlgItemMessageW(hwndDlg, IDC_STATIC_WATCHER_NAME,
00374                 WM_SETTEXT, 0, (LPARAM)(pWD->bstrName));
00375
00376             SendDlgItemMessageW(hwndDlg, IDC_STATIC_WATCHER_URI,
00377                 WM_SETTEXT, 0, (LPARAM)(pWD->bstrURI));
00378
00379             // Check the add buddy box by default
00380             SendDlgItemMessage(hwndDlg, IDC_CHECK_WATCHER_ADD_BUDDY,
00381                                 BM_SETCHECK, BST_CHECKED, 0);
00382         }
00383         return TRUE;
00384
00385     case WM_COMMAND:
00386         switch (LOWORD(wParam))
00387         {
00388         case IDC_BUTTON_WATCHER_ALLOW:
00389             {
00390                 pWD->fAddBuddy = (SendDlgItemMessage(
00391                                 hwndDlg,
00392                                 IDC_CHECK_WATCHER_ADD_BUDDY,
00393                                 BM_GETCHECK,
00394                                 0, 0) == BST_CHECKED);
00395
00396                 pWD->fAllow = TRUE;
00397
00398                 EndDialog(hwndDlg, IDOK);
00399             }
00400             return TRUE;
00401
00402         case IDC_BUTTON_WATCHER_BLOCK:
00403             {
00404                 pWD->fAddBuddy = (SendDlgItemMessage(
00405                                 hwndDlg,
00406                                 IDC_CHECK_WATCHER_ADD_BUDDY,
00407                                 BM_GETSTATE,
00408                                 0, 0) == BST_CHECKED);
00409
00410                 pWD->fAllow = FALSE;
00411
00412                 EndDialog(hwndDlg, IDOK);
00413             }
00414             return TRUE;
00415
00416         case IDCANCEL:
00417             EndDialog(hwndDlg, wParam);
00418             return TRUE;
00419         }
00420     }
00421
00422     return FALSE;
00423 }
00424
00425 /////////////////////////////////////////////
00426 //
00427 // ShowWatcherDialog
00428 //
00429
00430 HRESULT ShowWatcherDialog(
00431         HWND hWndParent,
00432         BSTR bstrName, BSTR bstrURI,
00433         BOOL *pfAllow, BOOL *pfAddBuddy)
00434 {
00435     int iRes;
00436     WATCHER_DATA wd;
00437
00438     wd.bstrName = bstrName;
00439     wd.bstrURI = bstrURI;
00440
00441     // Show the dialog
00442     iRes = DialogBoxParam(
00443         GetModuleHandle(NULL),
00444         MAKEINTRESOURCE(IDD_DIALOG_WATCHER),
00445         hWndParent,
00446         (DLGPROC)WatcherDialogProc,
00447         (LPARAM)&wd
00448         );
00449
00450     if (iRes == IDOK)
00451     {
00452         *pfAllow = wd.fAllow;
00453         *pfAddBuddy = wd.fAddBuddy;
00454
00455         return S_OK;
00456     }
00457
00458     return E_FAIL;
00459 }
00460
00461 /////////////////////////////////////////////
00462 //
00463 // ADDRESS_DATA
00464 //
00465
00466 struct ADDRESS_DATA
00467 {
00468     PWSTR szTitle;
00469     WCHAR szURI[MAX_STRING];
00470     WCHAR szName[MAX_STRING];
00471 };
00472
00473 /////////////////////////////////////////////
00474 //
00475 // AddressDialogProc
00476 //
00477
00478 INT_PTR CALLBACK AddressDialogProc(
00479   HWND hwndDlg,  // handle to dialog box
00480   UINT uMsg,     // message
00481   WPARAM wParam, // first message parameter
00482   LPARAM lParam  // second message parameter
00483 )
00484 {
00485     ADDRESS_DATA *pAD;
00486     pAD = (ADDRESS_DATA *)GetWindowLong(hwndDlg, DWL_USER);
00487
00488     switch (uMsg)
00489     {
00490     case WM_INITDIALOG:
00491         {
00492             // Store the ADDRESS_DATA pointer in the
00493             // window's user data
00494             SetWindowLong(hwndDlg, DWL_USER, lParam);
00495             pAD = (ADDRESS_DATA *)lParam;
00496
00497             // Set the dialog title
00498             SetWindowText(hwndDlg, pAD->szTitle);
00499         }
00500         return TRUE;
00501
00502     case WM_COMMAND:
00503         switch (LOWORD(wParam))
00504         {
00505         case IDOK:
00506             {
00507                 GetDlgItemTextW(
00508                     hwndDlg,
00509                     IDC_EDIT_ADDRESS_URI,
00510                     pAD->szURI,
00511                     MAX_STRING
00512                     );
00513
00514                 GetDlgItemTextW(
00515                     hwndDlg,
00516                     IDC_EDIT_ADDRESS_NAME,
00517                     pAD->szName,
00518                     MAX_STRING
00519                     );
00520
00521                 // Fall through
00522             }
00523
00524         case IDCANCEL:
00525             EndDialog(hwndDlg, wParam);
00526             return TRUE;
00527         }
00528     }
00529
00530     return FALSE;
00531 }
00532
00533 /////////////////////////////////////////////
00534 //
00535 // ShowAddressDialog
00536 //
00537
00538 HRESULT ShowAddressDialog(HWND hWndParent,
00539                           PWSTR szTitle, BOOL fGetName,
00540                           BSTR *pbstrURI, BSTR *pbstrName)
00541 {
00542     int iRes;
00543     ADDRESS_DATA ad;
00544
00545     ad.szTitle = szTitle;
00546
00547     // Show the dialog
00548     iRes = DialogBoxParam(
00549         GetModuleHandle(NULL),
00550         MAKEINTRESOURCE(fGetName ? IDD_DIALOG_ADDRESS_NAME : IDD_DIALOG_ADDRESS),
00551         hWndParent,
00552         (DLGPROC)AddressDialogProc,
00553         (LPARAM)&ad
00554         );
00555
00556     if (iRes == IDOK)
00557     {
00558         // Check for empty strings
00559         if (ad.szURI[0] == L'\0')
00560         {
00561             return E_FAIL;
00562         }
00563
00564         *pbstrURI = SysAllocString(ad.szURI);
00565
00566         if (!(*pbstrURI))
00567         {
00568             // Out of memory
00569             return E_OUTOFMEMORY;
00570         }
00571
00572         if (fGetName)
00573         {
00574             *pbstrName = SysAllocString(ad.szName);
00575
00576             if (!(*pbstrName))
00577             {
00578                 // Out of memory
00579                 SAFE_FREE_STRING(*pbstrURI);
00580
00581                 return E_OUTOFMEMORY;
00582             }
00583         }
00584
00585         return S_OK;
00586     }
00587
00588     return E_FAIL;
00589 }
00590
00591 /////////////////////////////////////////////
00592 //
00593 // SESSION_DATA
00594 //
00595
00596 struct SESSION_DATA
00597 {
00598     BSTR bstrName;
00599     BSTR bstrURI;
00600     BOOL fAccept;
00601 };
00602
00603 /////////////////////////////////////////////
00604 //
00605 // SessionDialogProc
00606 //
00607
00608 INT_PTR CALLBACK SessionDialogProc(
00609   HWND hwndDlg,  // handle to dialog box
00610   UINT uMsg,     // message
00611   WPARAM wParam, // first message parameter
00612   LPARAM lParam  // second message parameter
00613 )
00614 {
00615     SESSION_DATA *pSD;
00616     pSD = (SESSION_DATA *)GetWindowLong(hwndDlg, DWL_USER);
00617
00618     switch (uMsg)
00619     {
00620     case WM_INITDIALOG:
00621         {
00622             // Store the SESSION_DATA pointer in the
00623             // window's user data
00624             SetWindowLong(hwndDlg, DWL_USER, lParam);
00625             pSD = (SESSION_DATA *)lParam;
00626
00627             // Populate the session text
00628             SendDlgItemMessageW(hwndDlg, IDC_STATIC_SESSION_NAME,
00629                 WM_SETTEXT, 0, (LPARAM)(pSD->bstrName));
00630
00631             SendDlgItemMessageW(hwndDlg, IDC_STATIC_SESSION_URI,
00632                 WM_SETTEXT, 0, (LPARAM)(pSD->bstrURI));
00633         }
00634         return TRUE;
00635
00636     case WM_COMMAND:
00637         switch (LOWORD(wParam))
00638         {
00639         case IDC_BUTTON_SESSION_ACCEPT:
00640             {
00641                 pSD->fAccept = TRUE;
00642
00643                 EndDialog(hwndDlg, IDOK);
00644             }
00645             return TRUE;
00646
00647         case IDC_BUTTON_SESSION_REJECT:
00648         case IDCANCEL:
00649             {
00650                 pSD->fAccept = FALSE;
00651
00652                 EndDialog(hwndDlg, IDOK);
00653             }
00654             return TRUE;
00655         }
00656     }
00657
00658     return FALSE;
00659 }
00660
00661 /////////////////////////////////////////////
00662 //
00663 // ShowSessionDialog
00664 //
00665
00666 HRESULT ShowSessionDialog(
00667         HWND hWndParent,
00668         BSTR bstrName, BSTR bstrURI,
00669         BOOL *pfAccept)
00670 {
00671     int iRes;
00672     SESSION_DATA sd;
00673
00674     sd.bstrName = bstrName;
00675     sd.bstrURI = bstrURI;
00676
00677     // Show the dialog
00678     iRes = DialogBoxParam(
00679         GetModuleHandle(NULL),
00680         MAKEINTRESOURCE(IDD_DIALOG_SESSION),
00681         hWndParent,
00682         (DLGPROC)SessionDialogProc,
00683         (LPARAM)&sd
00684         );
00685
00686     if (iRes == IDOK)
00687     {
00688         *pfAccept = sd.fAccept;
00689
00690         return S_OK;
00691     }
00692
00693     return E_FAIL;
00694 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Replace.h Source File

  • WinUI
  • CommDlg
  • CDTest

Replace.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 void DoReplaceDialog(HWND) ;
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tree Member List

This is the complete list of members for tree, including all inherited members.
first tree
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/CeLib.Cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

CeLib.Cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1995 - 2000
00006 //
00007 //  File:       celib.cpp
00008 //
00009 //  Contents:   helper functions
00010 //
00011 //--------------------------------------------------------------------------
00012
00013 #include "pch.cpp"
00014 #pragma hdrstop
00015
00016 #include <stdio.h>
00017 #include <assert.h>
00018 #include "celibw2k.h"
00019
00020 #ifndef wszDURATIONUNITSDAYS
00021 # define wszDURATIONUNITSDAYS   wszPERIODDAYS
00022 # define wszDURATIONUNITSHOURS    wszPERIODHOURS
00023 # define wszDURATIONUNITSMINUTES  wszPERIODMINUTES
00024 # define wszDURATIONUNITSMONTHS   wszPERIODMONTHS
00025 # define wszDURATIONUNITSSECONDS  wszPERIODSECONDS
00026 # define wszDURATIONUNITSWEEKS    wszPERIODWEEKS
00027 # define wszDURATIONUNITSYEARS    wszPERIODYEARS
00028 #endif
00029
00030 //+--------------------------------------------------------------------------
00031 // ceDecodeObject -- call CryptDecodeObject, and allocate memory for output
00032 //
00033 //+--------------------------------------------------------------------------
00034
00035 BOOL
00036 ceDecodeObject(
00037     IN DWORD dwEncodingType,
00038     IN LPCSTR lpszStructType,
00039     IN BYTE const *pbEncoded,
00040     IN DWORD cbEncoded,
00041     IN BOOL fCoTaskMemAlloc,
00042     OUT VOID **ppvStructInfo,
00043     OUT DWORD *pcbStructInfo)
00044 {
00045     BOOL b;
00046
00047     assert(!fCoTaskMemAlloc);
00048     *ppvStructInfo = NULL;
00049     *pcbStructInfo = 0;
00050     while (TRUE)
00051     {
00052   b = CryptDecodeObject(
00053         dwEncodingType,
00054         lpszStructType,
00055         pbEncoded,
00056         cbEncoded,
00057         0,                  // dwFlags
00058         *ppvStructInfo,
00059         pcbStructInfo);
00060   if (b && 0 == *pcbStructInfo)
00061   {
00062       SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_DATA));
00063       b = FALSE;
00064   }
00065   if (!b)
00066   {
00067       if (NULL != *ppvStructInfo)
00068       {
00069     HRESULT hr = GetLastError();
00070
00071     LocalFree(*ppvStructInfo);
00072     *ppvStructInfo = NULL;
00073     SetLastError(hr);
00074       }
00075       break;
00076   }
00077   if (NULL != *ppvStructInfo)
00078   {
00079       break;
00080   }
00081   *ppvStructInfo = (BYTE *) LocalAlloc(LMEM_FIXED, *pcbStructInfo);
00082   if (NULL == *ppvStructInfo)
00083   {
00084       b = FALSE;
00085       break;
00086   }
00087     }
00088     return(b);
00089 }
00090
00091
00092 BOOL
00093 ceEncodeObject(
00094     IN DWORD dwEncodingType,
00095     IN LPCSTR lpszStructType,
00096     IN VOID const *pvStructInfo,
00097     IN DWORD dwFlags,
00098     IN BOOL fCoTaskMemAlloc,
00099     OUT BYTE **ppbEncoded,
00100     OUT DWORD *pcbEncoded)
00101 {
00102     BOOL b;
00103
00104     assert(0 == dwFlags);
00105     assert(!fCoTaskMemAlloc);
00106     *ppbEncoded = NULL;
00107     *pcbEncoded = 0;
00108     while (TRUE)
00109     {
00110   b = CryptEncodeObject(
00111         dwEncodingType,
00112         lpszStructType,
00113         const_cast<VOID *>(pvStructInfo),
00114         *ppbEncoded,
00115         pcbEncoded);
00116   if (b && 0 == *pcbEncoded)
00117   {
00118       SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_DATA));
00119       b = FALSE;
00120   }
00121   if (!b)
00122   {
00123       if (NULL != *ppbEncoded)
00124       {
00125     HRESULT hr = GetLastError();
00126
00127     LocalFree(*ppbEncoded);
00128     *ppbEncoded = NULL;
00129     SetLastError(hr);
00130       }
00131       break;
00132   }
00133   if (NULL != *ppbEncoded)
00134   {
00135       break;
00136   }
00137   *ppbEncoded = (BYTE *) LocalAlloc(LMEM_FIXED, *pcbEncoded);
00138   if (NULL == *ppbEncoded)
00139   {
00140       b = FALSE;
00141       break;
00142   }
00143     }
00144     return(b);
00145 }
00146
00147
00148 // The returned pszObjId is a constant that must not be freed.  CryptFindOIDInfo
00149 // has a static internal database that is valid until crypt32.dll is unloaded.
00150
00151 WCHAR const *
00152 ceGetOIDNameA(
00153     IN char const *pszObjId)
00154 {
00155     CRYPT_OID_INFO const *pInfo = NULL;
00156     WCHAR const *pwszName = L"";
00157
00158     // First try looking up the ObjectId as an Extension or Attribute, because
00159     // we get a better Display Name, especially for Subject RDNs: CN, L, etc.
00160     // If that fails, look it up withoput restricting the group.
00161
00162     pInfo = CryptFindOIDInfo(
00163       CRYPT_OID_INFO_OID_KEY,
00164       (VOID *) pszObjId,
00165       CRYPT_EXT_OR_ATTR_OID_GROUP_ID);
00166
00167     if (NULL == pInfo || NULL == pInfo->pwszName || L'\0' == pInfo->pwszName[0])
00168     {
00169   pInfo = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (VOID *) pszObjId, 0);
00170     }
00171     if (NULL != pInfo && NULL != pInfo->pwszName && L'\0' != pInfo->pwszName[0])
00172     {
00173   pwszName = pInfo->pwszName;
00174     }
00175     return(pwszName);
00176 }
00177
00178
00179 WCHAR const *
00180 ceGetOIDName(
00181     IN WCHAR const *pwszObjId)
00182 {
00183     char *pszObjId = NULL;
00184     WCHAR const *pwszName = L"";
00185
00186     if (!ceConvertWszToSz(&pszObjId, pwszObjId, -1))
00187     {
00188   _JumpError(E_OUTOFMEMORY, error, "ceConvertWszToSz");
00189     }
00190     pwszName = ceGetOIDNameA(pszObjId);
00191
00192 error:
00193     if (NULL != pszObjId)
00194     {
00195   LocalFree(pszObjId);
00196     }
00197     return(pwszName);
00198 }
00199
00200
00201 WCHAR *
00202 ceDuplicateString(
00203     IN WCHAR const *pwsz)
00204 {
00205     WCHAR *pwszOut;
00206
00207     pwszOut = (WCHAR *) LocalAlloc(
00208         LMEM_FIXED,
00209         (wcslen(pwsz) + 1) * sizeof(pwsz[0]));
00210     if (NULL != pwszOut)
00211     {
00212   wcscpy(pwszOut, pwsz);
00213     }
00214     return(pwszOut);
00215 }
00216
00217
00218 BOOL
00219 ceConvertWszToSz(
00220     OUT CHAR **ppsz,
00221     IN WCHAR const *pwc,
00222     IN LONG cwc)
00223 {
00224     BOOL fOk = FALSE;
00225     LONG cch = 0;
00226
00227     *ppsz = NULL;
00228     while (TRUE)
00229     {
00230   cch = WideCharToMultiByte(
00231       GetACP(),
00232       0,          // dwFlags
00233       pwc,
00234       cwc,        // cchWideChar, -1 => null terminated
00235       *ppsz,
00236       cch,
00237       NULL,
00238       NULL);
00239   if (0 >= cch)
00240   {
00241       DWORD err;
00242
00243       err = GetLastError();
00244       ceERRORPRINTLINE("WideCharToMultiByte", err);
00245       if (NULL != *ppsz)
00246       {
00247     LocalFree(*ppsz);
00248     *ppsz = NULL;
00249       }
00250       break;
00251   }
00252   if (NULL != *ppsz)
00253   {
00254       fOk = TRUE;
00255       break;
00256   }
00257   *ppsz = (CHAR *) LocalAlloc(LMEM_FIXED, cch + 1);
00258   if (NULL == *ppsz)
00259   {
00260       break;
00261   }
00262     }
00263     return(fOk);
00264 }
00265
00266
00267 BOOL
00268 ceConvertWszToBstr(
00269     OUT BSTR *pbstr,
00270     IN WCHAR const *pwc,
00271     IN LONG cb)
00272 {
00273     BOOL fOk = FALSE;
00274     BSTR bstr;
00275
00276     ceFreeBstr(pbstr);
00277     do
00278     {
00279   bstr = NULL;
00280   if (NULL != pwc)
00281   {
00282       if (-1 == cb)
00283       {
00284     cb = (LONG)(wcslen(pwc) * sizeof(WCHAR));
00285       }
00286       bstr = SysAllocStringByteLen((char const *) pwc, cb);
00287       if (NULL == bstr)
00288       {
00289     break;
00290       }
00291   }
00292   *pbstr = bstr;
00293   fOk = TRUE;
00294     } while (FALSE);
00295     return(fOk);
00296 }
00297
00298
00299 BOOL
00300 ceConvertSzToWsz(
00301     OUT WCHAR **ppwsz,
00302     IN char const *pch,
00303     IN LONG cch)
00304 {
00305     BOOL fOk = FALSE;
00306     LONG cwc = 0;
00307
00308     *ppwsz = NULL;
00309     while (TRUE)
00310     {
00311   cwc = MultiByteToWideChar(GetACP(), 0, pch, cch, *ppwsz, cwc);
00312   if (0 >= cwc)
00313   {
00314       DWORD err;
00315
00316       err = GetLastError();
00317       ceERRORPRINTLINE("MultiByteToWideChar", err);
00318       if (NULL != *ppwsz)
00319       {
00320     LocalFree(*ppwsz);
00321     *ppwsz = NULL;
00322       }
00323       break;
00324   }
00325   if (NULL != *ppwsz)
00326   {
00327       fOk = TRUE;
00328       break;
00329   }
00330   *ppwsz = (WCHAR *) LocalAlloc(LMEM_FIXED, (cwc + 1) * sizeof(WCHAR));
00331   if (NULL == *ppwsz)
00332   {
00333       break;
00334   }
00335     }
00336     return(fOk);
00337 }
00338
00339
00340 BOOL
00341 ceConvertSzToBstr(
00342     OUT BSTR *pbstr,
00343     IN CHAR const *pch,
00344     IN LONG cch)
00345 {
00346     BOOL fOk = FALSE;
00347     BSTR bstr = NULL;
00348     LONG cwc = 0;
00349
00350     ceFreeBstr(pbstr);
00351     if (-1 == cch)
00352     {
00353   cch = (LONG)strlen(pch);
00354     }
00355     while (TRUE)
00356     {
00357   cwc = MultiByteToWideChar(GetACP(), 0, pch, cch, bstr, cwc);
00358   if (0 >= cwc)
00359   {
00360       //hr = ceHLastError();
00361       //printf("MultiByteToWideChar returned %d (%x)\n", hr, hr);
00362       break;
00363   }
00364   if (NULL != bstr)
00365   {
00366       bstr[cwc] = L'\0';
00367       *pbstr = bstr;
00368       fOk = TRUE;
00369       break;
00370   }
00371   bstr = SysAllocStringLen(NULL, cwc);
00372   if (NULL == bstr)
00373   {
00374       break;
00375   }
00376     }
00377     return(fOk);
00378 }
00379
00380
00381 VOID
00382 ceFreeBstr(
00383     IN OUT BSTR *pstr)
00384 {
00385     if (NULL != *pstr)
00386     {
00387   SysFreeString(*pstr);
00388   *pstr = NULL;
00389     }
00390 }
00391
00392
00393 HRESULT
00394 ceHError(
00395     IN HRESULT hr)
00396 {
00397     assert(S_FALSE != hr);
00398
00399     if (S_OK != hr && S_FALSE != hr && !FAILED(hr))
00400     {
00401         hr = HRESULT_FROM_WIN32(hr);
00402   if (0 == HRESULT_CODE(hr))
00403   {
00404       // A call failed without properly setting an error condition!
00405       hr = E_UNEXPECTED;
00406   }
00407   assert(FAILED(hr));
00408     }
00409     return(hr);
00410 }
00411
00412
00413 HRESULT
00414 ceHLastError(VOID)
00415 {
00416     return(ceHError(GetLastError()));
00417 }
00418
00419
00420 VOID
00421 ceErrorPrintLine(
00422     IN char const *pszFile,
00423     IN DWORD line,
00424     IN char const *pszMessage,
00425     IN HRESULT hr)
00426 {
00427     wprintf(
00428   L"CertEnc.Dll: Error: %hs(%u): %hs 0x%x (%d)\n",
00429   pszFile,
00430   line,
00431   pszMessage,
00432   hr,
00433   hr);
00434 }
00435
00436
00437 HRESULT
00438 ceDateToFileTime(
00439     IN DATE const *pDate,
00440     OUT FILETIME *pft)
00441 {
00442     SYSTEMTIME st;
00443     HRESULT hr = S_OK;
00444
00445     if (*pDate == 0.0)
00446     {
00447         GetSystemTime(&st);
00448     }
00449     else
00450     {
00451   if (!VariantTimeToSystemTime(*pDate, &st))
00452   {
00453       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00454       _JumpError(hr, error, "VariantTimeToSystemTime");
00455   }
00456     }
00457
00458     if (!SystemTimeToFileTime(&st, pft))
00459     {
00460         hr = ceHLastError();
00461         _JumpError(hr, error, "SystemTimeToFileTime");
00462     }
00463
00464 error:
00465     return(hr);
00466 }
00467
00468
00469 HRESULT
00470 ceFileTimeToDate(
00471     IN FILETIME const *pft,
00472     OUT DATE *pDate)
00473 {
00474     SYSTEMTIME st;
00475     HRESULT hr = S_OK;
00476
00477     if (!FileTimeToSystemTime(pft, &st))
00478     {
00479         hr = ceHLastError();
00480         _JumpError(hr, error, "FileTimeToSystemTime");
00481     }
00482     if (!SystemTimeToVariantTime(&st, pDate))
00483     {
00484         hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00485         _JumpError(hr, error, "SystemTimeToVariantTime");
00486     }
00487
00488 error:
00489     return(hr);
00490 }
00491
00492
00493 VOID
00494 ceMakeExprDateTime(
00495     IN OUT FILETIME *pft,
00496     IN LONG lDelta,
00497     IN enum ENUM_PERIOD enumPeriod)
00498 {
00499     LONGLONG llDelta;
00500     BOOL fSysTimeDelta;
00501
00502     llDelta = lDelta;
00503     fSysTimeDelta = FALSE;
00504     switch (enumPeriod)
00505     {
00506   case ENUM_PERIOD_WEEKS:   llDelta *= CVT_WEEKS;    break;
00507   case ENUM_PERIOD_DAYS:    llDelta *= CVT_DAYS;     break;
00508   case ENUM_PERIOD_HOURS:   llDelta *= CVT_HOURS;    break;
00509   case ENUM_PERIOD_MINUTES: llDelta *= CVT_MINUTES;  break;
00510   case ENUM_PERIOD_SECONDS:         break;
00511   default:
00512       fSysTimeDelta = TRUE;
00513       break;
00514     }
00515     if (fSysTimeDelta)
00516     {
00517       SYSTEMTIME SystemTime;
00518
00519       FileTimeToSystemTime(pft, &SystemTime);
00520       switch (enumPeriod)
00521       {
00522           case ENUM_PERIOD_MONTHS:
00523         if (0 > lDelta)
00524         {
00525             DWORD dwDelta = (DWORD) -lDelta;
00526
00527             SystemTime.wYear -= (WORD) (dwDelta / 12) + 1;
00528             SystemTime.wMonth += 12 - (WORD) (dwDelta % 12);
00529         }
00530         else
00531         {
00532             SystemTime.wMonth += (WORD) lDelta;
00533         }
00534         if (12 < SystemTime.wMonth)
00535         {
00536             SystemTime.wYear += (SystemTime.wMonth - 1) / 12;
00537             SystemTime.wMonth = ((SystemTime.wMonth - 1) % 12) + 1;
00538         }
00539         break;
00540
00541           case ENUM_PERIOD_YEARS:
00542         SystemTime.wYear += (WORD) lDelta;
00543         break;
00544
00545           default:
00546         SystemTime.wYear += 1;
00547         break;
00548       }
00549
00550 DoConvert:
00551         if (!SystemTimeToFileTime(&SystemTime, pft))
00552         {
00553             if (GetLastError() != ERROR_INVALID_PARAMETER)
00554             {
00555                 assert(!"Unable to do time conversion");
00556                 return;
00557             }
00558
00559             // In some cases we'll convert to an invalid month-end
00560
00561             // only one month changes length from year to year
00562             if (SystemTime.wMonth == 2)
00563             {
00564                 // > 29? try leap year
00565                 if (SystemTime.wDay > 29)
00566                 {
00567                     SystemTime.wDay = 29;
00568                     goto DoConvert;
00569                 }
00570                 // == 29? try non-leap year
00571                 else if (SystemTime.wDay == 29)
00572                 {
00573                     SystemTime.wDay = 28;
00574                     goto DoConvert;
00575                 }
00576             }
00577             // sept (9), apr(4), jun(6), nov(11) all have 30 days
00578             else if ((SystemTime.wMonth == 9) ||
00579                      (SystemTime.wMonth == 4) ||
00580                      (SystemTime.wMonth == 6) ||
00581                      (SystemTime.wMonth == 11))
00582             {
00583                 if (SystemTime.wDay > 30)
00584                 {
00585                     SystemTime.wDay = 30;
00586                     goto DoConvert;
00587                 }
00588             }
00589
00590             // should never get here
00591             assert(!"Month/year processing: inaccessible code");
00592             return;
00593         }
00594     }
00595     else
00596     {
00597       *(LONGLONG *) pft += llDelta * CVT_BASE;
00598     }
00599 }
00600
00601
00602 HRESULT
00603 ceMakeExprDate(
00604     IN OUT DATE *pDate,
00605     IN LONG lDelta,
00606     IN enum ENUM_PERIOD enumPeriod)
00607 {
00608     HRESULT hr;
00609     FILETIME ft;
00610
00611     hr = ceDateToFileTime(pDate, &ft);
00612     _JumpIfError(hr, error, "ceDateToFileTime");
00613
00614     ceMakeExprDateTime(&ft, lDelta, enumPeriod);
00615
00616     hr = ceFileTimeToDate(&ft, pDate);
00617     _JumpIfError(hr, error, "ceFileTimeToDate");
00618
00619 error:
00620     return(hr);
00621 }
00622
00623
00624 typedef struct _UNITSTABLE
00625 {
00626     WCHAR const     *pwszString;
00627     enum ENUM_PERIOD enumPeriod;
00628 } UNITSTABLE;
00629
00630
00631 UNITSTABLE g_aut[] =
00632 {
00633     { wszDURATIONUNITSSECONDS, ENUM_PERIOD_SECONDS },
00634     { wszDURATIONUNITSMINUTES, ENUM_PERIOD_MINUTES },
00635     { wszDURATIONUNITSHOURS,   ENUM_PERIOD_HOURS },
00636     { wszDURATIONUNITSDAYS,    ENUM_PERIOD_DAYS },
00637     { wszDURATIONUNITSWEEKS,   ENUM_PERIOD_WEEKS },
00638     { wszDURATIONUNITSMONTHS,  ENUM_PERIOD_MONTHS },
00639     { wszDURATIONUNITSYEARS,   ENUM_PERIOD_YEARS },
00640 };
00641 #define CUNITSTABLEMAX  (sizeof(g_aut)/sizeof(g_aut[0]))
00642
00643
00644 HRESULT
00645 ceTranslatePeriodUnits(
00646     IN WCHAR const *pwszPeriod,
00647     IN LONG lCount,
00648     OUT enum ENUM_PERIOD *penumPeriod,
00649     OUT LONG *plCount)
00650 {
00651     HRESULT hr;
00652     UNITSTABLE const *put;
00653
00654     for (put = g_aut; put < &g_aut[CUNITSTABLEMAX]; put++)
00655     {
00656   if (0 == lstrcmpi(pwszPeriod, put->pwszString))
00657   {
00658       *penumPeriod = put->enumPeriod;
00659       if (0 > lCount)
00660       {
00661     lCount = MAXLONG;
00662       }
00663       *plCount = lCount;
00664       hr = S_OK;
00665       goto error;
00666   }
00667     }
00668     hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00669
00670 error:
00671     return(hr);
00672 }
00673
00674
00675 HRESULT
00676 ceVerifyObjId(
00677     IN WCHAR const *pwszObjId)
00678 {
00679     HRESULT hr;
00680     CHAR *pszObjId = NULL;
00681     DWORD cbEncoded;
00682     CRYPT_ATTRIBUTE ainfo;
00683
00684     if (!ceConvertWszToSz(&pszObjId, pwszObjId, -1))
00685     {
00686   hr = E_OUTOFMEMORY;
00687         ceERRORPRINTLINE("ceConvertWszToSz", hr);
00688         goto error;
00689     }
00690
00691     ainfo.pszObjId = pszObjId;
00692     ainfo.cValue = 0;
00693     if (!CryptEncodeObject(
00694          X509_ASN_ENCODING,
00695          PKCS_ATTRIBUTE,
00696          &ainfo,
00697          NULL,
00698          &cbEncoded))
00699     {
00700         hr = E_INVALIDARG;
00701         ceERRORPRINTLINE("invalid Obj Id", hr);
00702         goto error;
00703     }
00704     hr = S_OK;
00705
00706 error:
00707     if (NULL != pszObjId)
00708     {
00709       LocalFree(pszObjId);
00710     }
00711     return(hr);
00712 }
00713
00714
00715 HRESULT
00716 ceVerifyAltNameString(
00717     IN LONG NameChoice,
00718     IN WCHAR const *pwszName)
00719 {
00720     HRESULT hr = S_OK;
00721     CERT_ALT_NAME_INFO AltName;
00722     CERT_ALT_NAME_ENTRY Entry;
00723     char *pszObjectId = NULL;
00724     DWORD cbEncoded;
00725
00726     ZeroMemory(&AltName, sizeof(AltName));
00727     AltName.cAltEntry = 1;
00728     AltName.rgAltEntry = &Entry;
00729
00730     ZeroMemory(&Entry, sizeof(Entry));
00731     Entry.dwAltNameChoice = NameChoice;
00732
00733     switch (NameChoice)
00734     {
00735   case CERT_ALT_NAME_RFC822_NAME:
00736       Entry.pwszRfc822Name = const_cast<WCHAR *>(pwszName);
00737       break;
00738
00739   case CERT_ALT_NAME_DNS_NAME:
00740       Entry.pwszDNSName = const_cast<WCHAR *>(pwszName);
00741       break;
00742
00743   case CERT_ALT_NAME_URL:
00744       Entry.pwszURL = const_cast<WCHAR *>(pwszName);
00745       break;
00746
00747   case CERT_ALT_NAME_REGISTERED_ID:
00748       if (!ceConvertWszToSz(&pszObjectId, pwszName, -1))
00749       {
00750     hr = E_OUTOFMEMORY;
00751     ceERRORPRINTLINE("ceConvertWszToSz", hr);
00752     goto error;
00753       }
00754       Entry.pszRegisteredID = pszObjectId;
00755       break;
00756
00757   //case CERT_ALT_NAME_DIRECTORY_NAME:
00758   //case CERT_ALT_NAME_OTHER_NAME:
00759   //case CERT_ALT_NAME_X400_ADDRESS:
00760   //case CERT_ALT_NAME_EDI_PARTY_NAME:
00761   //case CERT_ALT_NAME_IP_ADDRESS:
00762   default:
00763       hr = E_INVALIDARG;
00764       ceERRORPRINTLINE("NameChoice", hr);
00765       goto error;
00766
00767     }
00768
00769     // Encode CERT_ALT_NAME_INFO:
00770
00771     if (!CryptEncodeObject(
00772         X509_ASN_ENCODING,
00773         X509_ALTERNATE_NAME,
00774         &AltName,
00775         NULL,
00776         &cbEncoded))
00777     {
00778   hr = ceHLastError();
00779   ceERRORPRINTLINE("ceEncodeObject", hr);
00780   goto error;
00781     }
00782
00783 error:
00784     if (NULL != pszObjectId)
00785     {
00786   LocalFree(pszObjectId);
00787     }
00788     return(hr);
00789 }
00790
00791
00792 HRESULT
00793 ceDispatchSetErrorInfo(
00794     IN HRESULT hrError,
00795     IN WCHAR const *pwszDescription,
00796     OPTIONAL IN WCHAR const *pwszProgId,
00797     OPTIONAL IN IID const *piid)
00798 {
00799     HRESULT hr;
00800     ICreateErrorInfo *pCreateErrorInfo = NULL;
00801     IErrorInfo *pErrorInfo = NULL;
00802     WCHAR *pwszError = NULL;
00803     WCHAR *pwszText = NULL;
00804
00805     if (NULL == pwszDescription)
00806     {
00807         hr = E_POINTER;
00808         ceERRORPRINTLINE("NULL pointer", hr);
00809         goto error;
00810     }
00811
00812     assert(FAILED(hrError));
00813     pwszError = ceGetErrorMessageText(hrError, TRUE);
00814     if (NULL == pwszError)
00815     {
00816   ceERRORPRINTLINE("ceGetErrorMessageText", E_OUTOFMEMORY);
00817     }
00818     else
00819     {
00820   pwszText = (WCHAR *) LocalAlloc(
00821       LMEM_FIXED,
00822       (wcslen(pwszDescription) + 1 + wcslen(pwszError) + 1) *
00823        sizeof(WCHAR));
00824   if (NULL == pwszText)
00825   {
00826       ceERRORPRINTLINE("LocalAlloc", E_OUTOFMEMORY);
00827   }
00828   else
00829   {
00830       wcscpy(pwszText, pwszDescription);
00831       wcscat(pwszText, L" ");
00832       wcscpy(pwszText, pwszError);
00833   }
00834     }
00835
00836     hr = CreateErrorInfo(&pCreateErrorInfo);
00837     if (S_OK != hr)
00838     {
00839         ceERRORPRINTLINE("CreateErrorInfo", hr);
00840         goto error;
00841     }
00842
00843     if (NULL != piid)
00844     {
00845   hr = pCreateErrorInfo->SetGUID(*piid);
00846   if (S_OK != hr)
00847   {
00848       ceERRORPRINTLINE("SetGUID", hr);
00849   }
00850     }
00851
00852     hr = pCreateErrorInfo->SetDescription(
00853         NULL != pwszText?
00854       pwszText : const_cast<WCHAR *>(pwszDescription));
00855     if (S_OK != hr)
00856     {
00857   ceERRORPRINTLINE("SetDescription", hr);
00858     }
00859
00860     // Set ProgId:
00861
00862     if (NULL != pwszProgId)
00863     {
00864   hr = pCreateErrorInfo->SetSource(const_cast<WCHAR *>(pwszProgId));
00865   if (S_OK != hr)
00866   {
00867       ceERRORPRINTLINE("SetSource", hr);
00868   }
00869     }
00870
00871     hr = pCreateErrorInfo->QueryInterface(
00872             IID_IErrorInfo,
00873             (VOID **) &pErrorInfo);
00874     if (S_OK != hr)
00875     {
00876         ceERRORPRINTLINE("QueryInterface", hr);
00877         goto error;
00878     }
00879
00880     SetErrorInfo(0, pErrorInfo);
00881
00882 error:
00883     if (NULL != pErrorInfo)
00884     {
00885   pErrorInfo->Release();
00886     }
00887     if (NULL != pCreateErrorInfo)
00888     {
00889   pCreateErrorInfo->Release();
00890     }
00891     if (NULL != pwszText)
00892     {
00893   LocalFree(pwszText);
00894     }
00895     if (NULL != pwszError)
00896     {
00897   LocalFree(pwszError);
00898     }
00899     return(hrError);  // return input error!
00900 }
00901
00902
00903 int
00904 ceWtoI(
00905     IN WCHAR const *string,
00906     OUT BOOL *pfValid)
00907 {
00908     HRESULT hr;
00909     WCHAR szBuf[16];
00910     WCHAR *szTmp = szBuf;
00911     int cTmp = ARRAYSIZE(szBuf);
00912     int i = 0;
00913     WCHAR const *pwsz;
00914     BOOL fSawDigit = FALSE;
00915
00916     assert(NULL != pfValid);
00917     cTmp = FoldString(
00918         MAP_FOLDDIGITS,
00919         string,
00920         -1,
00921         szTmp,
00922         cTmp);
00923     if (cTmp == 0)
00924     {
00925         hr = ceHLastError();
00926         if (HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) == hr)
00927         {
00928             hr = S_OK;
00929             cTmp = FoldString(
00930                 MAP_FOLDDIGITS,
00931                 string,
00932                 -1,
00933                 NULL,
00934                 0);
00935
00936             szTmp = (WCHAR*)LocalAlloc(LMEM_FIXED, cTmp*sizeof(WCHAR));
00937       if (NULL == szTmp)
00938       {
00939     hr = E_OUTOFMEMORY;
00940     _JumpError(hr, error, "LocalAlloc");
00941       }
00942
00943             cTmp = FoldString(
00944                 MAP_FOLDDIGITS,
00945                 string,
00946                 -1,
00947                 szTmp,
00948                 cTmp);
00949
00950             if (cTmp == 0)
00951                 hr = ceHLastError();
00952         }
00953         _JumpIfError(hr, error, "FoldString");
00954     }
00955     pwsz = szTmp;
00956     while (iswspace(*pwsz))
00957     {
00958   pwsz++;
00959     }
00960     while (iswdigit(*pwsz))
00961     {
00962   fSawDigit = TRUE;
00963   pwsz++;
00964     }
00965     while (iswspace(*pwsz))
00966     {
00967   pwsz++;
00968     }
00969     if (L'\0' == *pwsz)
00970     {
00971   *pfValid = fSawDigit;
00972     }
00973     i = _wtoi(szTmp);
00974
00975 error:
00976     if (szTmp && (szTmp != szBuf))
00977        LocalFree(szTmp);
00978
00979     return i;
00980 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook Server/MgdResource.idl Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook Server

MgdResource.idl

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      MgdResource.idl
00007 //
00008 //  Description:
00009 //      Definition of COM interfaces for the Cluster Configuration
00010 //      Extension DLL.
00011 //
00012 //  Author:
00013 //      <name> (<e-mail name>) Mmmm DD, 2003
00014 //
00015 //  Revision History:
00016 //
00017 //  Notes:
00018 //      This file will be processed by the MIDL tool to
00019 //      produce the type library (MgdResource.tlb) and marshalling code.
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 [
00024     uuid(8EE244FB-1B3F-4DF6-AFF2-BCAF62A9001C),
00025     version(1.0),
00026     helpstring("CLIPBOOK SERVER 1.0 Type Library")
00027 ]
00028 library MGDRESOURCELib
00029 {
00030     importlib("stdole32.tlb");
00031     importlib("stdole2.tlb");
00032     import "cluscfgserver.idl";
00033
00034     [
00035         uuid(AD4E4946-0400-4A92-81D1-C85FE199970A),
00036         helpstring("ClusCfg CLIPBOOKSERVER Class")
00037     ]
00038     coclass ClipBookServer
00039     {
00040         [default] interface IClusCfgResourceTypeInfo;
00041         interface IClusCfgStartupListener;
00042         interface IClusCfgInitialize;
00043     };
00044
00045 };
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COptionsDataSource Member List

This is the complete list of members for COptionsDataSource, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
COptionsDataSource() | COptionsDataSource |
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | COptionsDataSource | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | COptionsDataSource | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | COptionsDataSource | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CPropPageLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSetActive() | CPropPageLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfcompart/monitor.h Source File

  • WinUI
  • tsfcompart

monitor.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation. All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Compart.h
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 #ifndef COMPARTMENT_MONITOR_H
00019 #define COMPARTMENT_MONITOR_H
00020
00021 /**************************************************************************
00022   #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <windowsx.h>
00027 #include <msctf.h>
00028
00029 typedef HRESULT (CALLBACK* PCOMPARTMENTMONITORPROC)(const GUID*, BOOL, LPARAM);
00030
00031 /**************************************************************************
00032
00033   CCompartmentMonitor class definition
00034
00035 **************************************************************************/
00036
00037 class CCompartmentMonitor : public ITfCompartmentEventSink
00038 {
00039 public:
00040     CCompartmentMonitor(void);
00041     virtual ~CCompartmentMonitor();
00042
00043     //
00044     // IUnknown methods
00045     //
00046     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00047     STDMETHODIMP_(ULONG) AddRef(void);
00048     STDMETHODIMP_(ULONG) Release(void);
00049
00050     //
00051     // ITfCompartmentEventSink
00052     //
00053     STDMETHODIMP OnChange(REFGUID rguid);
00054
00055     //
00056     // APIs
00057     //
00058     HRESULT Initialize( const GUID *pguidCompartment,
00059                         PCOMPARTMENTMONITORPROC pCallback,
00060                         LPARAM lParam);
00061     HRESULT Uninitialize(void);
00062     HRESULT GetStatus(BOOL *pfStatus);
00063
00064 private:
00065     DWORD                   m_dwRef;
00066     DWORD                   m_dwCookie;
00067     ITfCompartment          *m_pCompartment;
00068     GUID                    m_guidCompartment;
00069     PCOMPARTMENTMONITORPROC m_pCallback;
00070     LPARAM                  m_lParam;
00071 };
00072
00073
00074 #endif  //COMPARTMENT_MONITOR_H
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CIceSkateFolder Member List

This is the complete list of members for CIceSkateFolder, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
children | CIceSkateFolder | [private]
children | CIceSkateFolder | [private]
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CIceSkateFolder() | CIceSkateFolder |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetBitmapIndex() | CIceSkateFolder | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CIceSkateFolder | [virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CIceSkateFolder | [virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CIceSkateFolder | [virtual]
GetChildPtr(int index) | CIceSkateFolder | [inline, virtual]
GetChildPtr(int index) | CIceSkateFolder | [inline, virtual]
GetChildPtr(int index) | CIceSkateFolder | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkateFolder | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CIceSkateFolder | [virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
getNodeType() | CIceSkateFolder | [inline, virtual]
GetParentScopeItem() | CIceSkateFolder | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CIceSkateFolder | [virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CIceSkateFolder | [virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CIceSkateFolder | [virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CIceSkateFolder | [virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CIceSkateFolder | [virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CIceSkateFolder | [virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CIceSkateFolder | [virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CIceSkateFolder | [virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_hParentHScopeItem | CIceSkateFolder | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
NUMBER_OF_CHILDREN enum value | CIceSkateFolder | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CIceSkateFolder | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CIceSkateFolder | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CIceSkateFolder | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CIceSkateFolder | [virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CIceSkateFolder | [virtual]
CDelegationBase::OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
CDelegationBase::OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CIceSkateFolder | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CIceSkateFolder | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CIceSkateFolder | [virtual]
thisGuid | CIceSkateFolder | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
~CIceSkateFolder() | CIceSkateFolder | [virtual]
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCShip2/StdAfx.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCShip2

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__6DD1E6D3_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_)
00006 #define AFX_STDAFX_H__6DD1E6D3_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #define _WIN32_WINNT 0x0500
00016 #define _ATL_APARTMENT_THREADED
00017
00018
00019 #include <atlbase.h>
00020 //You may derive a class from CComModule and use it if you want to override
00021 //something, but do not change the name of _Module
00022 extern CComModule _Module;
00023 #include <atlcom.h>
00024
00025 //{{AFX_INSERT_LOCATION}}
00026 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00027
00028 #include <crtdbg.h>
00029 #include <comsvcs.h>
00030 #include <stdlib.h>
00031 #include <vector>
00032 #include <comdef.h>
00033
00034 #endif // !defined(AFX_STDAFX_H__6DD1E6D3_28C1_11D2_B5B6_00C04FC340EE__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/src/IsapiTime.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • src

IsapiTime.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiTime.cpp
00006
00007 Abstract:
00008
00009     Some helper functions to work with time
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee), October 2002
00014
00015 --*/
00016
00017 #include <IsapiTools.h>
00018
00019 //
00020 // Define sizes for time strings.
00021 //
00022 // Note that time strings are generally in the form
00023 // used in an HTTP date header. For example:
00024 //
00025 //   "Tue, 16 Oct 2002 20:25:00 GMT"
00026 //
00027
00028 #define SIZE_DATE           sizeof("ddd, dd MMM yyyy")
00029 #define SIZE_TIME           sizeof("HH:mm:ss")
00030 #define SIZE_TIME_STRING    sizeof("ddd, dd MMMM yyyy HH:mm:ss GMT")
00031
00032 FILETIME g_ftInitTime = {0};
00033
00034 BOOL
00035 InitializeIsapiTime(
00036     VOID
00037     )
00038 /*++
00039
00040 Purpose:
00041
00042     Initializes IsapiTools time functions by initializing g_ftInitTime
00043
00044 Arguments:
00045
00046     None
00047
00048 Returns:
00049
00050     TRUE on success, FALSE on failure
00051
00052 --*/
00053 {
00054     if ( ((LARGE_INTEGER*)&g_ftInitTime)->QuadPart == 0 )
00055     {
00056         if ( GetCurrentTimeAsFileTime( &g_ftInitTime ) == FALSE )
00057         {
00058             return FALSE;
00059         }
00060     }
00061
00062     return TRUE;
00063 }
00064
00065 DWORD
00066 GetCurrentTimeInSeconds(
00067     VOID
00068     )
00069 /*++
00070
00071 Purpose:
00072
00073     Returns the number of seconds since InitializeIsapiTime was called
00074
00075 Arguments:
00076
00077     None
00078
00079 Returns:
00080
00081     The number of seconds
00082
00083 --*/
00084 {
00085     return (DWORD)(GetCurrentTimeInMilliseconds() / 1000);
00086 }
00087
00088 DWORD64
00089 GetCurrentTimeInMilliseconds(
00090     VOID
00091     )
00092 /*++
00093
00094 Purpose:
00095
00096     Returns the number of milliseconds since InitializeIsapiTime was called.
00097
00098 Arguments:
00099
00100     None
00101
00102 Returns:
00103
00104     The number of milliseconds
00105
00106 --*/
00107 {
00108     FILETIME    ftCurrent;
00109
00110     //
00111     // If we haven't been initialized, just return 0
00112     //
00113
00114     if ( ((LARGE_INTEGER*)&g_ftInitTime)->QuadPart == 0 )
00115     {
00116         SetLastError( ERROR_INVALID_PARAMETER );
00117         return 0;
00118     }
00119
00120     //
00121     // Get the current time
00122     //
00123     // Note that GetCurrentTimeAsFileTime calls GetSystemTime,
00124     // which is a system call.  This introduces a performance
00125     // cost due to a kernel transition.  It would be possible
00126     // to use something like GetTickCount to obtain higher
00127     // performance, but GetTickCount returns a DWORD.  This
00128     // would introduce a rollover problem after about 49 days.
00129     //
00130     // This code favors correctness over performance in this
00131     // case.
00132     //
00133
00134     if ( GetCurrentTimeAsFileTime( &ftCurrent ) == FALSE )
00135     {
00136         return 0;
00137     }
00138
00139     return DiffFileTimeInMilliseconds( &g_ftInitTime, &ftCurrent );
00140 }
00141
00142 BOOL
00143 GetCurrentTimeAsFileTime(
00144     FILETIME *  pft
00145     )
00146 /*++
00147
00148 Purpose:
00149
00150     Returns the current time in the provided FILETIME structure
00151
00152 Arguments:
00153
00154     pft - Pointer to the target FILETIME
00155
00156 Returns:
00157
00158     TRUE on success, FALSE on failure
00159
00160 --*/
00161 {
00162     SYSTEMTIME  st;
00163
00164     //
00165     // Get the current time in GMT
00166     //
00167
00168     GetSystemTime( &st );
00169
00170     return SystemTimeToFileTime( &st, pft );
00171 }
00172
00173 BOOL
00174 GetFileTimeFromString(
00175     FILETIME *  pft,
00176     CHAR *      szTimeString
00177     )
00178 /*++
00179
00180 Purpose:
00181
00182     Returns a filetime, corresponding to the provided string,
00183     in the format of:
00184
00185       "Tue, 16 Oct 2002 20:25:00 GMT"
00186
00187 Arguments:
00188
00189     pft          - On return, contains the FILETIME data
00190     szTimeString - The string to parse for time
00191
00192 Returns:
00193
00194     TRUE on success, FALSE on failure
00195
00196 --*/
00197 {
00198     SYSTEMTIME  st;
00199     CHAR *      pCursor;
00200
00201     ZeroMemory( &st, sizeof(SYSTEMTIME) );
00202
00203     //
00204     // Build the members of the systemtime structure from
00205     // the input string.
00206     //
00207
00208     pCursor = szTimeString;
00209
00210     //
00211     // Get the day of week
00212     //
00213
00214     if ( strnicmp( pCursor, "sun", 3 ) == 0 )
00215     {
00216         st.wDayOfWeek = 0;
00217     }
00218     else if ( strnicmp( pCursor, "mon", 3 ) == 0 )
00219     {
00220         st.wDayOfWeek = 1;
00221     }
00222     else if ( strnicmp( pCursor, "tue", 3 ) == 0 )
00223     {
00224         st.wDayOfWeek = 2;
00225     }
00226     else if ( strnicmp( pCursor, "wed", 3 ) == 0 )
00227     {
00228         st.wDayOfWeek = 3;
00229     }
00230     else if ( strnicmp( pCursor, "thu", 3 ) == 0 )
00231     {
00232         st.wDayOfWeek = 4;
00233     }
00234     else if ( strnicmp( pCursor, "fri", 3 ) == 0 )
00235     {
00236         st.wDayOfWeek = 5;
00237     }
00238     else if ( strnicmp( pCursor, "sat", 3 ) == 0 )
00239     {
00240         st.wDayOfWeek = 6;
00241     }
00242     else
00243     {
00244         SetLastError( ERROR_INVALID_PARAMETER );
00245         goto Failed;
00246     }
00247
00248     //
00249     // Get the day
00250     //
00251
00252     pCursor = strchr( pCursor, ' ' );
00253
00254     if ( !pCursor )
00255     {
00256         SetLastError( ERROR_INVALID_PARAMETER );
00257         goto Failed;
00258     }
00259
00260     pCursor++;
00261
00262     st.wDay = atoi( pCursor );
00263
00264     //
00265     // Get the month
00266     //
00267
00268     pCursor = strchr( pCursor, ' ' );
00269
00270     if ( !pCursor )
00271     {
00272         SetLastError( ERROR_INVALID_PARAMETER );
00273         goto Failed;
00274     }
00275
00276     pCursor++;
00277
00278     if ( strnicmp( pCursor, "jan", 3 ) == 0 )
00279     {
00280         st.wMonth = 1;
00281     }
00282     else if ( strnicmp( pCursor, "feb", 3 ) == 0 )
00283     {
00284         st.wMonth = 2;
00285     }
00286     else if ( strnicmp( pCursor, "mar", 3 ) == 0 )
00287     {
00288         st.wMonth = 3;
00289     }
00290     else if ( strnicmp( pCursor, "apr", 3 ) == 0 )
00291     {
00292         st.wMonth = 4;
00293     }
00294     else if ( strnicmp( pCursor, "may", 3 ) == 0 )
00295     {
00296         st.wMonth = 5;
00297     }
00298     else if ( strnicmp( pCursor, "jun", 3 ) == 0 )
00299     {
00300         st.wMonth = 6;
00301     }
00302     else if ( strnicmp( pCursor, "jul", 3 ) == 0 )
00303     {
00304         st.wMonth = 7;
00305     }
00306     else if ( strnicmp( pCursor, "aug", 3 ) == 0 )
00307     {
00308         st.wMonth = 8;
00309     }
00310     else if ( strnicmp( pCursor, "sep", 3 ) == 0 )
00311     {
00312         st.wMonth = 9;
00313     }
00314     else if ( strnicmp( pCursor, "oct", 3 ) == 0 )
00315     {
00316         st.wMonth = 10;
00317     }
00318     else if ( strnicmp( pCursor, "nov", 3 ) == 0 )
00319     {
00320         st.wMonth = 11;
00321     }
00322     else if ( strnicmp( pCursor, "dec", 3 ) == 0 )
00323     {
00324         st.wMonth = 12;
00325     }
00326     else
00327     {
00328         SetLastError( ERROR_INVALID_PARAMETER );
00329         goto Failed;
00330     }
00331
00332     //
00333     // Get the year
00334     //
00335
00336     pCursor = strchr( pCursor, ' ' );
00337
00338     if ( !pCursor )
00339     {
00340         SetLastError( ERROR_INVALID_PARAMETER );
00341         goto Failed;
00342     }
00343
00344     pCursor++;
00345
00346     st.wYear = atoi( pCursor );
00347
00348     //
00349     // Get the Hour
00350     //
00351
00352     pCursor = strchr( pCursor, ' ' );
00353
00354     if ( !pCursor )
00355     {
00356         SetLastError( ERROR_INVALID_PARAMETER );
00357         goto Failed;
00358     }
00359
00360     pCursor++;
00361
00362     st.wHour = atoi( pCursor );
00363
00364     //
00365     // Get the minutes
00366     //
00367
00368     pCursor = strchr( pCursor, ':' );
00369
00370     if ( !pCursor )
00371     {
00372         SetLastError( ERROR_INVALID_PARAMETER );
00373         goto Failed;
00374     }
00375
00376     pCursor++;
00377
00378     st.wMinute = atoi( pCursor );
00379
00380     //
00381     // Get the seconds
00382     //
00383
00384     pCursor = strchr( pCursor, ':' );
00385
00386     if ( !pCursor )
00387     {
00388         SetLastError( ERROR_INVALID_PARAMETER );
00389         goto Failed;
00390     }
00391
00392     pCursor++;
00393
00394     st.wSecond = atoi( pCursor );
00395
00396     //
00397     // Now convert it to a filetime
00398     //
00399
00400     return SystemTimeToFileTime( &st, pft );
00401
00402 Failed:
00403
00404     //
00405     // No special cleanup required
00406     //
00407
00408     return FALSE;
00409 }
00410
00411 BOOL
00412 GetFileTimeAsString(
00413     FILETIME *      pft,
00414     ISAPI_STRING *  pString
00415     )
00416 /*++
00417
00418 Purpose:
00419
00420     Builds string in the following format from the provided FILETIME:
00421
00422       "Tue, 16 Oct 2002 20:25:00 GMT"
00423
00424 Arguments:
00425
00426     pft     - The FILETIME
00427     pString - ISAPI_STRING to store the result
00428
00429 Returns:
00430
00431     TRUE on success, FALSE on failure
00432
00433 --*/
00434 {
00435     SYSTEMTIME  st;
00436     CHAR        szDate[SIZE_DATE];
00437     CHAR        szTime[SIZE_TIME];
00438     DWORD       cbCopied;
00439     BOOL        fResult;
00440
00441     //
00442     // Convert the supplied time to a SYSTEMTIME
00443     //
00444
00445     fResult = FileTimeToSystemTime( pft, &st );
00446
00447     if ( !fResult )
00448     {
00449         goto Failed;
00450     }
00451
00452     //
00453     // Get the date and time as strings
00454     //
00455
00456     cbCopied = GetDateFormat( LOCALE_SYSTEM_DEFAULT,
00457                               0,
00458                               &st,
00459                               "ddd, dd MMM yyyy",
00460                               szDate,
00461                               SIZE_DATE );
00462
00463     if ( cbCopied == 0 )
00464     {
00465         goto Failed;
00466     }
00467
00468     cbCopied = GetTimeFormat( LOCALE_SYSTEM_DEFAULT,
00469                               0,
00470                               &st,
00471                               "HH:mm:ss",
00472                               szTime,
00473                               SIZE_TIME );
00474
00475     if ( cbCopied == 0 )
00476     {
00477         goto Failed;
00478     }
00479
00480     //
00481     // Build the final result into the string
00482     //
00483
00484     fResult = pString->Printf( "%s %s GMT",
00485                                szDate,
00486                                szTime );
00487
00488     if ( !fResult )
00489     {
00490         goto Failed;
00491     }
00492
00493     return TRUE;
00494
00495 Failed:
00496
00497     //
00498     // No special cleanup required
00499     //
00500
00501     return FALSE;
00502 }
00503
00504 BOOL
00505 GetCurrentTimeAsString(
00506     ISAPI_STRING *  pString
00507     )
00508 /*++
00509
00510 Purpose:
00511
00512     Builds string in the following format from the current time:
00513
00514       "Tue, 16 Oct 2002 20:25:00 GMT"
00515
00516 Arguments:
00517
00518     pString - ISAPI_STRING to store the result
00519
00520 Returns:
00521
00522     TRUE on success, FALSE on failure
00523
00524 --*/
00525 {
00526     FILETIME    ft;
00527
00528     if ( GetCurrentTimeAsFileTime( &ft ) == FALSE )
00529     {
00530         goto Failed;
00531     }
00532
00533     return GetFileTimeAsString( &ft, pString );
00534
00535 Failed:
00536
00537     //
00538     // No special cleanup required
00539     //
00540
00541     return FALSE;
00542 }
00543
00544 DWORD
00545 DiffFileTimeInSeconds(
00546     FILETIME *  pft1,
00547     FILETIME *  pft2
00548     )
00549 /*++
00550
00551 Purpose:
00552
00553     Returns the difference, in seconds, between the two
00554     provided FILETIMEs
00555
00556 Arguments:
00557
00558     pft1 - The first FILETIME
00559     pft2 - The second FILETIME
00560
00561 Returns:
00562
00563     The difference, in seconds
00564
00565 --*/
00566 {
00567     return (DWORD)(DiffFileTimeInMilliseconds( pft1, pft2 ) / 1000);
00568 }
00569
00570 DWORD64
00571 DiffFileTimeInMilliseconds(
00572     FILETIME *  pft1,
00573     FILETIME *  pft2
00574     )
00575 /*++
00576
00577 Purpose:
00578
00579     Returns the difference, in milliseconds, between the two
00580     provided FILETIMEs
00581
00582 Arguments:
00583
00584     pft1 - The first FILETIME
00585     pft2 - The second FILETIME
00586
00587 Returns:
00588
00589     The difference, in milliseconds
00590
00591 --*/
00592 {
00593     DWORD64 Time1;
00594     DWORD64 Time2;
00595     DWORD64 DiffTime;
00596
00597     Time1 = ((LARGE_INTEGER*)pft1)->QuadPart;
00598     Time2 = ((LARGE_INTEGER*)pft2)->QuadPart;
00599
00600     DiffTime = Time2 > Time1 ? Time2 - Time1 : Time1 - Time2;
00601
00602     //
00603     // Return result, converted from 100 nanosecond intervals
00604     // to milliseconds.
00605     //
00606
00607     return DiffTime / 10000;
00608 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/networking/httpdump/HeadDump.cpp Source File

  • Web
  • networking
  • httpdump

HeadDump.cpp

Go to the documentation of this file.
00001
00002 //=--------------------------------------------------------------------------=
00003 //  (C) Copyright 1996-2000 Microsoft Corporation. All Rights Reserved.
00004 //=--------------------------------------------------------------------------=
00005 /****************************************************************************
00006 *
00007 * HeadDump: requests the default HTML document from the server and prints
00008 *     along with HTTP headers.
00009 *     Microsoft Corporation (C). L.B.
00010 *
00011 * PURPOSE:
00012 * This sample demonstrates how to create and submit HTTP
00013 * request. Sample requests the default HTML document from the
00014 * server and then display it along with the HTTP transaction headers.
00015 * This sample also allows to access password protected pages. It
00016 * checks for HTTP server response code and it is "401 Access Denied"
00017 * it asks password and user name and then resubmit request.
00018
00019 *
00020 * This sample features:
00021 *  - SSL/PCT support
00022 *  - NTLM Authentication (when IE 3.0 or above is installed)
00023 *  - Basic Authentication
00024 *  - Generating standard user name/password UI to get user credentials.
00025 *  - Getting user name and password without UI
00026 *  - getting any document of any MIME type
00027 *  - translation of Internet error codes to the extended error messages
00028 *  - ability to save remote object to a local file (when no local file
00029 *  specify output goes to STDOUT).
00030 *
00031 * Usage:
00032 *   headdump.exe -h host [-o object] [-p proxy] [-u] [-s] [-?] [-f file]
00033 *   -h host is a HTTP server such as www.server.com
00034 *   -p proxy is optional proxy, in form: http://proxy:80
00035 *   -o object is optional document to GET, in form: /foobar.htm
00036 *   -u use this flag to bring user name and password UI (optional)
00037 *   -f save remote object as local file  (optional)
00038 *   -? get help
00039 *   -s use SSL (optional)
00040 *
00041 * Samples:
00042 * To get help on command line parameters:
00043 * C:> headdump.exe -?
00044 *
00045 * Note that HeadDump can also invoke ISAPI dll or CGI like this:
00046 *   C:> headdump.exe -s www.server.name -o /scripts/myisapi.dll
00047 *
00048 * Since sample generates large output, you may want to pipe to more:
00049 *   C:> headdump.exe -s www.server.name -o /scripts/myisapi.dll  | more
00050 *
00051 * To save remote HTML object as file:
00052 * C:> headdump.exe -s www.server.name -o /exe_files/foo.exe -f foo.exe
00053 *
00054 *
00055 *
00056 ****************************************************************************/
00057
00058 #include <windows.h>
00059 #include <wininet.h>
00060 #include <iostream>
00061 #include <tchar.h>
00062 // Use safe string APIs.
00063 #include <strsafe.h>
00064
00065 #if defined(_UNICODE)
00066 # define _tcout wcout
00067 # define _tcin wcin
00068 # define _tcerr wcerr
00069 #else
00070 # define _tcout cout
00071 # define _tcin cin
00072 # define _tcerr cerr
00073 #endif
00074
00075 using namespace std;
00076
00077 BOOL ErrorOut  ( DWORD dError, TCHAR * szCallingFunc);
00078 BOOL ParseParams (int argc , TCHAR ** argv, TCHAR* szServer, TCHAR* szObject,
00079                   TCHAR* szProxy, TCHAR * szFile, BOOL& bUi, BOOL& bSSL);
00080 void Usage (TCHAR *szName);
00081
00082 int _tmain (int argc, TCHAR *argv[])
00083 {
00084  HINTERNET hOpen, hConnect, hReq;
00085  DWORD  dwSize, dwCode;
00086  DWORD  dwFlags = INTERNET_FLAG_RELOAD |
00087                   INTERNET_FLAG_NO_CACHE_WRITE |
00088                   INTERNET_FLAG_KEEP_CONNECTION;
00089  CHAR *lpBuffer, szData[51];
00090  TCHAR szServer[256], szObject [256], szProxy [256], szFile [256];
00091  BOOL bSSL, bUi;
00092  HANDLE hFile = NULL;
00093  INTERNET_PORT dwPort;
00094  TCHAR szAccept[] = TEXT("*/*");
00095  LPTSTR AcceptTypes[2]={0};
00096
00097
00098  AcceptTypes[0]=szAccept;
00099
00100
00101
00102 if (!ParseParams ( argc , argv, szServer, szObject,
00103                   szProxy,  szFile, bUi, bSSL))
00104     return (FALSE);
00105
00106 if (szFile [0])
00107 {
00108   // Open local file
00109   SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, FALSE};
00110   if  ( !(hFile = CreateFile (szFile,
00111                             GENERIC_WRITE,
00112                 FILE_SHARE_READ,
00113                 &sa,
00114                 CREATE_ALWAYS,
00115                 FILE_ATTRIBUTE_NORMAL, NULL) ))
00116   {
00117     _tcerr << TEXT("Can't open file: ") << szFile << TEXT(" Error: ") << GetLastError() << endl;
00118     return 0;
00119   }
00120 }
00121
00122
00123
00124 if (szProxy [0] == NULL)
00125 {
00126    // No proxy was specified
00127    if ( !(hOpen = InternetOpen ( TEXT("HeadDump"),  LOCAL_INTERNET_ACCESS , NULL, 0, 0) ) )
00128    {
00129        ErrorOut ( GetLastError(), TEXT("InternetOpen"));
00130        return 0;
00131    }
00132  }
00133  else
00134  {
00135    // Use proxy server
00136    if ( !(hOpen = InternetOpen ( TEXT("HeadDump"),  CERN_PROXY_INTERNET_ACCESS, szProxy, NULL, 0) ) )
00137    {
00138         ErrorOut ( GetLastError(), TEXT("InternetOpen"));
00139        return 0;
00140    }
00141  }
00142
00143
00144 if  (bSSL)
00145 {
00146     dwPort = INTERNET_DEFAULT_HTTPS_PORT;
00147     dwFlags |= INTERNET_FLAG_SECURE |
00148                INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
00149                INTERNET_FLAG_IGNORE_CERT_DATE_INVALID  ;
00150 }
00151 else
00152     dwPort = INTERNET_INVALID_PORT_NUMBER;
00153
00154 if ( !(hConnect = InternetConnect ( hOpen, szServer , dwPort, TEXT(""),  TEXT(""), INTERNET_SERVICE_HTTP, 0, 0) ) )
00155 {
00156     ErrorOut (GetLastError(), TEXT("InternetConnect"));
00157     return 0;
00158 }
00159
00160 if ( !(hReq = HttpOpenRequest (hConnect, TEXT("GET"), szObject, HTTP_VERSION, TEXT(""),
00161                                 (LPCTSTR*) AcceptTypes, dwFlags ,0 )))
00162 {
00163     ErrorOut (GetLastError(), TEXT("HttpOpenRequest"));
00164     return 0;
00165 }
00166
00167
00168 again:
00169 if ( !HttpSendRequest (hReq, // handle from HttpOpenRequest
00170                                              NULL, 0, NULL, 0) )
00171 {
00172        ErrorOut (GetLastError(), TEXT("HttpSendRequest"));
00173
00174        dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA                 |
00175                            SECURITY_FLAG_IGNORE_REVOCATION        |
00176                            SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP  |
00177                            SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS |
00178                            SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |
00179                            SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
00180
00181        if ( !InternetSetOption (hReq,
00182                                 INTERNET_OPTION_SECURITY_FLAGS,
00183                                 &dwFlags,
00184                                 sizeof (dwFlags) ) )
00185        {
00186           _tcerr << TEXT("InternetSetOptionFailed: ") << GetLastError() << endl;
00187           return FALSE;
00188        }
00189 }
00190
00191 if ( !HttpSendRequest (hReq, NULL, 0, NULL, 0) )
00192 {
00193        ErrorOut (GetLastError(), TEXT("HttpSendRequest"));
00194        return FALSE;
00195 }
00196
00197 dwSize = sizeof (DWORD) ;
00198 if ( !HttpQueryInfo (hReq, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL))
00199 {
00200   ErrorOut (GetLastError(), TEXT("HttpQueryInfo"));
00201   return FALSE;
00202 }
00203
00204 if ( dwCode == HTTP_STATUS_DENIED || dwCode == HTTP_STATUS_PROXY_AUTH_REQ)
00205 {
00206     // We have to read all outstanding data on the Internet handle
00207     // before we can resubmit request. Just discard the data.
00208     do
00209   {
00210     InternetReadFile (hReq, (LPVOID)szData, 50, &dwSize);
00211   }
00212   while (dwSize != 0);
00213
00214     if (!bUi)
00215     {
00216         // This is a secure page.
00217         _tcerr << TEXT("This page is password protected. ") << endl;
00218       TCHAR szUser[50]=TEXT("");
00219       TCHAR szPass[50]=TEXT("");
00220
00221       wcerr << TEXT("User: ");
00222       _tcin  >> szUser;
00223       _tcerr << TEXT("Pass: ");
00224       _tcin  >> szPass;
00225         if ( !InternetSetOption (hConnect, INTERNET_OPTION_USERNAME, (LPVOID) szUser, lstrlen (szUser) ))
00226         {
00227             _tcerr << TEXT("InternetSetOptionFailed: ") << GetLastError() << endl;
00228             return FALSE;
00229         }
00230
00231         if ( !InternetSetOption (hConnect, INTERNET_OPTION_PASSWORD, (LPVOID) szPass, lstrlen (szPass) ))
00232         {
00233             _tcerr << TEXT("InternetSetOptionFailed: ") << GetLastError() << endl;
00234             return FALSE;
00235         }
00236         goto again;
00237     }
00238     else
00239     {
00240         if ( InternetErrorDlg (GetDesktopWindow(),
00241                                hReq,
00242                                ERROR_INTERNET_INCORRECT_PASSWORD,
00243                                FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
00244                                FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
00245                                FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
00246                                NULL) == ERROR_INTERNET_FORCE_RETRY)
00247             goto again;
00248     }
00249
00250 }
00251
00252
00253 // First time we will find out the size of the headers.
00254 HttpQueryInfo (hReq,HTTP_QUERY_RAW_HEADERS_CRLF,  NULL, &dwSize, NULL);
00255 lpBuffer =  new char [dwSize + 1 ];
00256
00257 // Now we call HttpQueryInfo again to get the headers.
00258 if (!HttpQueryInfo (hReq,HTTP_QUERY_RAW_HEADERS_CRLF, (LPVOID) lpBuffer,
00259     &dwSize, NULL))
00260 {
00261   ErrorOut (GetLastError(), TEXT("HttpQueryInfo"));
00262   return FALSE;
00263 }
00264 *(lpBuffer + dwSize) = '\0';
00265 cout << lpBuffer << endl;
00266
00267
00268 do
00269 {
00270   if (!InternetReadFile (hReq, (LPVOID)szData, 50, &dwSize) )
00271   {
00272     ErrorOut (GetLastError (), TEXT("InternetReadFile"));
00273     return FALSE;
00274   }
00275   if (dwSize != 0)
00276   {
00277     if (!hFile)
00278     {
00279       // dump text to the screen
00280       szData[dwSize] = '\0';
00281       cout << szData;
00282     }
00283     else
00284     {
00285       DWORD dwWritten;
00286       if (!WriteFile(hFile,  szData, dwSize,  &dwWritten,  NULL))
00287       {
00288         CloseHandle (hFile);
00289         _tcerr << TEXT("WriteFile to ") << szFile << TEXT(" failed: ") <<
00290         GetLastError () << endl;
00291         return FALSE;
00292       }
00293     }
00294   }
00295 }
00296 while (dwSize);
00297
00298 _tcout << endl;
00299
00300 if (!InternetCloseHandle (hReq) )
00301 {
00302     ErrorOut (GetLastError (), TEXT("CloseHandle on hReq"));
00303     return FALSE;
00304 }
00305 if (!InternetCloseHandle (hConnect) )
00306 {
00307     ErrorOut (GetLastError (), TEXT("CloseHandle on hConnect"));
00308     return FALSE;
00309 }
00310 if (!InternetCloseHandle (hOpen) )
00311 {
00312     ErrorOut (GetLastError (), TEXT("CloseHandle on hOpen"));
00313     return FALSE;
00314 }
00315
00316
00317 delete [] lpBuffer;
00318
00319 if (hFile)
00320 {
00321   FlushFileBuffers (hFile);
00322   CloseHandle (hFile);
00323 }
00324 return TRUE;
00325 }
00326
00327 /****************************************************************************
00328 *
00329 *    FUNCTION: ErrorOut
00330 *
00331 *    PURPOSE: This function is used to get extended Internet error.
00332 *
00333 *    COMMENTS:  Function returns TRUE on success and FALSE on failure.
00334 *
00335 ****************************************************************************/
00336
00337 BOOL ErrorOut ( DWORD dError, TCHAR * szCallFunc)
00338 {
00339     #define SZTEMP_SIZE 100
00340     TCHAR szTemp[SZTEMP_SIZE] = TEXT(""), *szBuffer=NULL, *szBufferFinal = NULL;
00341     char strName[256]="";
00342     DWORD  dwIntError , dwLength = 0, dwFinalLength;
00343
00344     FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
00345                 GetModuleHandle(TEXT("wininet.dll")),dError,0,
00346                   (LPTSTR)strName,256,NULL);
00347
00348     StringCchPrintf( szTemp, SZTEMP_SIZE, TEXT("%s error code: %d\nMessage: %s\n"),
00349                  szCallFunc, dError, strName);
00350
00351   if (dError == ERROR_INTERNET_EXTENDED_ERROR)
00352   {
00353     InternetGetLastResponseInfo (&dwIntError, NULL, &dwLength);
00354     if (dwLength)
00355     {
00356       if ( !(szBuffer = (TCHAR *) LocalAlloc ( LPTR,  dwLength) ) )
00357       {
00358         StringCchCat(szTemp, SZTEMP_SIZE, TEXT ( "Unable to allocate memory to display Internet error code. Error code: "));
00359         StringCchCat(szTemp, SZTEMP_SIZE, _itot(GetLastError(), szBuffer, 10));
00360         StringCchCat(szTemp, SZTEMP_SIZE, TEXT ("\n") );
00361         _tcerr << szTemp << endl;
00362         return FALSE;
00363       }
00364       if (!InternetGetLastResponseInfo (&dwIntError, (LPTSTR) szBuffer, &dwLength))
00365       {
00366         StringCchCat(szTemp, SZTEMP_SIZE, TEXT ( "Unable to get Internet error. Error code: ") );
00367         StringCchCat(szTemp, SZTEMP_SIZE, _itot (GetLastError(), szBuffer, 10));
00368         StringCchCat(szTemp, SZTEMP_SIZE, TEXT ("\n") );
00369         _tcerr << szTemp << endl;
00370         return FALSE;
00371       }
00372
00373       size_t sizeBuffer;
00374       size_t sizeTemp;
00375       if( FAILED(StringCchLength( szBuffer, dwLength, &sizeBuffer ) )||
00376         FAILED(StringCchLength( szTemp, SZTEMP_SIZE, &sizeTemp ) ) )
00377       {
00378         _tcerr << TEXT("Unable to determine buffer sizes.") << endl;
00379         return FALSE;
00380       }
00381
00382       dwFinalLength = sizeBuffer + sizeTemp + 1;
00383       if ( !(szBufferFinal = (TCHAR *) LocalAlloc ( LPTR,  dwFinalLength)))
00384       {
00385         StringCchCat(szTemp, SZTEMP_SIZE, TEXT ( "Unable to allocate memory. Error code: ") );
00386         StringCchCat(szTemp, SZTEMP_SIZE, _itot (GetLastError(), szBuffer, 10));
00387         StringCchCat(szTemp, SZTEMP_SIZE, TEXT ("\n") );
00388         _tcerr << szTemp << endl;
00389         return FALSE;
00390       }
00391       StringCchCopy(szBufferFinal, dwFinalLength, szTemp);
00392       StringCchCat(szBufferFinal, dwFinalLength, szBuffer);
00393       LocalFree (szBuffer);
00394       _tcerr <<  szBufferFinal  << endl;
00395       LocalFree (szBufferFinal);
00396     }
00397   }
00398   else
00399     _tcerr << szTemp << endl;
00400
00401     return TRUE;
00402 }
00403
00404
00405 BOOL ParseParams (int argc , TCHAR ** argv, TCHAR* szServer, TCHAR* szObject,
00406                   TCHAR* szProxy, TCHAR * szFile, BOOL& bUi, BOOL& bSSL)
00407 {
00408     int i = 1;
00409     BOOL bServer = FALSE;
00410
00411     szProxy[0]  = NULL, bUi = FALSE, bSSL = FALSE, szFile[0]  = NULL;
00412     StringCchCopy(szObject, 256, TEXT(""));
00413
00414     while (i < argc)
00415     {
00416        if ( *argv[i] != '-')
00417        {
00418            Usage (argv[0]);
00419            return FALSE;
00420        }
00421        switch (argv[i][1])
00422        {
00423            case 'H':
00424            case 'h':
00425               StringCchCopy(szServer, 256, argv[i+1]);
00426               i += 2;
00427               bServer = TRUE;
00428            break;
00429            case 'o':
00430            case 'O':
00431               StringCchCopy(szObject, 256, argv[i+1]);
00432               i += 2;
00433            break;
00434
00435            case 'p':
00436            case 'P':
00437               StringCchCopy(szProxy, 256, argv[i+1]);
00438               i += 2;
00439            break;
00440
00441            case 'u':
00442            case 'U':
00443               bUi = TRUE;
00444               i++;
00445            break;
00446
00447            case 's':
00448            case 'S':
00449               bSSL = TRUE;
00450               i++;
00451            break;
00452
00453            case 'f':
00454            case 'F':
00455               StringCchCopy(szFile, 256, argv[i+1]);
00456               i += 2;
00457            break;
00458
00459        case '?':
00460          Usage (argv[0]);
00461          return FALSE;
00462        break;
00463        default:
00464            _tcerr << TEXT("Invalid command line argument: ")<< argv[i] << endl;
00465            Usage (argv[0]);
00466            return FALSE;
00467         }
00468     }
00469     if ( bServer )
00470         return TRUE;
00471     else
00472     {
00473         Usage(argv[0]);
00474         return FALSE;
00475     }
00476 }
00477
00478
00479 void Usage (TCHAR *szName)
00480 {
00481     _tcerr << TEXT("Usage: " << szName <<" -h host [-o object] [-p proxy] [-u] [-s] [-?] [-f file]") << endl;
00482     _tcerr << TEXT("\t-h host is a HTTP server such as www.server.com") << endl;
00483     _tcerr << TEXT("\t-p proxy is optional proxy in form: http://proxy:80") << endl;
00484     _tcerr << TEXT("\t-o object is optional document to GET in form: /foobar.htm") << endl;
00485     _tcerr << TEXT("\t-u use this flag to bring user name and password UI ") << endl;
00486     _tcerr << TEXT("\t-f save remote object as local file ") << endl;
00487     _tcerr << TEXT("\t-? get help ") << endl;
00488     _tcerr << TEXT("\t-s use SSL ") << endl;
00489 }
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCertEncodeCRLDistInfo Member List

This is the complete list of members for CCertEncodeCRLDistInfo, including all inherited members.
_Cleanup(VOID) | CCertEncodeCRLDistInfo | [private]
_MapDistPoint(IN BOOL fEncode, IN LONG DistPointIndex, OUT LONG **ppNameCount, OUT CERT_ALT_NAME_ENTRY ***ppaName) | CCertEncodeCRLDistInfo | [private]
_MapName(IN BOOL fEncode, IN LONG DistPointIndex, IN LONG NameIndex, OUT CERT_ALT_NAME_ENTRY **ppName) | CCertEncodeCRLDistInfo | [private]
_SetErrorInfo(IN HRESULT hrError, IN WCHAR const *pwszDescription) | CCertEncodeCRLDistInfo | [private]
_VerifyNames(IN LONG DistPointIndex) | CCertEncodeCRLDistInfo | [private]
CCertEncodeCRLDistInfo() | CCertEncodeCRLDistInfo | [inline]
Encode(BSTR *pstrBinary) | CCertEncodeCRLDistInfo |
GetName(LONG DistPointIndex, LONG NameIndex, BSTR __RPC_FAR *pstrName) | CCertEncodeCRLDistInfo |
GetNameChoice(LONG DistPointIndex, LONG NameIndex, LONG __RPC_FAR *pNameChoice) | CCertEncodeCRLDistInfo |
GetNameCount(LONG DistPointIndex, LONG __RPC_FAR *pNameCount) | CCertEncodeCRLDistInfo |
m_aValue | CCertEncodeCRLDistInfo | [private]
m_cValue | CCertEncodeCRLDistInfo | [private]
m_DecodeInfo | CCertEncodeCRLDistInfo | [private]
m_fConstructing | CCertEncodeCRLDistInfo | [private]
Reset(LONG DistPointCount) | CCertEncodeCRLDistInfo |
SetNameCount(LONG DistPointIndex, LONG NameCount) | CCertEncodeCRLDistInfo |
SetNameEntry(LONG DistPointIndex, LONG NameIndex, LONG NameChoice, BSTR const strName) | CCertEncodeCRLDistInfo |
~CCertEncodeCRLDistInfo() | CCertEncodeCRLDistInfo |
Generated on Wed Nov 13 2024 16:55:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Helper.h Source File

  • NetDS
  • SyncMgr
  • SyncDir

Helper.h

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #ifndef _HELPERSTUFF_
00013 #define _HELPERSTUFF_
00014
00015 int CalcListViewWidth(HWND hwndList,int iDefault);
00016 BOOL IsValidDir(TCHAR *pDirName);
00017 TCHAR *FormatDateTime(FILETIME *pft,TCHAR *pszDatetimeBuf,DWORD cbBufSize);
00018
00019 LPWSTR lstrcpyX(LPWSTR lpString1,LPCWSTR lpString2);
00020
00021 #undef lstrcpyW
00022 #define lstrcpyW lstrcpyX
00023
00024 #endif // _HELPERSTUFF_
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/IMEApps.h Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

IMEApps.h

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      IMEAPPS.H                                                     */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #include "wapi.h"
00010
00011 #define ORG_X                     10
00012 #define ORG_Y                     10
00013
00014 #define RESULT_X                  10
00015 #define RESULT_Y                  10
00016 #define RESULTREAD_X              10
00017 #define RESULTREAD_Y              30
00018
00019 #define COMPSTR_X                 10
00020 #define COMPSTR_Y                 50
00021 #define COMPREAD_X                10
00022 #define COMPREAD_Y                60
00023
00024 #define IMESTATUS_CY              20
00025 #define CAND_CX                   130
00026
00027 extern HANDLE hInst;
00028 extern HWND hWndMain;
00029 extern HWND hWndToolBar;
00030 extern HWND hWndStatus;
00031 extern HWND hWndCompStr;
00032 extern HWND hWndCandList;
00033
00034 extern LOGFONT lf;
00035 extern HFONT hFont;
00036
00037 extern int nStatusHeight;
00038 extern BOOL fShowCand;
00039 extern DWORD  fdwProperty;
00040
00041 extern DWORD  dwCompStrLen;
00042 extern DWORD  dwCompAttrLen;
00043 extern DWORD  dwCompClsLen;
00044 extern DWORD  dwCompReadStrLen;
00045 extern DWORD  dwCompReadAttrLen;
00046 extern DWORD  dwCompReadClsLen;
00047 extern DWORD  dwResultStrLen;
00048 extern DWORD  dwResultClsLen;
00049 extern DWORD  dwResultReadStrLen;
00050 extern DWORD  dwResultReadClsLen;
00051
00052 extern MYCHAR szCompStr[512];
00053 extern BYTE   bCompAttr[512];
00054 extern DWORD  dwCompCls[128];
00055 extern MYCHAR szCompReadStr[512];
00056 extern BYTE   bCompReadAttr[512];
00057 extern DWORD  dwCompReadCls[128];
00058 extern MYCHAR szResultStr[512];
00059 extern DWORD  dwResultCls[128];
00060 extern MYCHAR szResultReadStr[512];
00061 extern DWORD  dwResultReadCls[128];
00062 extern MYCHAR szPaintResult[512];
00063 extern MYCHAR szPaintResultRead[512];
00064
00065 extern LPCANDIDATELIST lpCandList;
00066 extern POINT ptImeUIPos;
00067
00068
00069
00070 /* imeapps.c */
00071 BOOL InitApplication(HANDLE);
00072 BOOL InitInstance(HANDLE, int);
00073 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
00074 LRESULT CALLBACK CompStrWndProc(HWND, UINT, WPARAM, LPARAM);
00075 LRESULT CALLBACK CandListWndProc(HWND, UINT, WPARAM, LPARAM);
00076 LRESULT CALLBACK AboutDlg(HWND, UINT, WPARAM, LPARAM);
00077 LRESULT HandleStartComposition(HWND,WPARAM,LPARAM);
00078 LRESULT HandleEndComposition(HWND,WPARAM,LPARAM);
00079 LRESULT HandleComposition(HWND,WPARAM,LPARAM);
00080 LRESULT HandleChar(HWND,WPARAM,LPARAM);
00081 LRESULT HandleNotify(HWND,UINT,WPARAM,LPARAM);
00082 LRESULT HandlePaint(HWND, WPARAM, LPARAM);
00083 LRESULT HandleCandPaint(HWND, WPARAM, LPARAM);
00084
00085
00086 // setcomp.c
00087 LRESULT HandleChangeAttr(HWND hWnd,BOOL fNext);
00088
00089 // subs.c
00090 void MoveCompCandWindow(HWND hWnd);
00091 BOOL CreateStatus();
00092 void SetStatusItems(HWND hWnd);
00093 void SetOpenStatusParts(BOOL fOpen);
00094 void SetConvModeParts(DWORD dwConvMode);
00095 void ClearConvModeParts();
00096
00097 // toolbar.c
00098 BOOL CreateTBar(HWND);
00099 LRESULT SetTooltipText(HWND hWnd, LPARAM lparam);
00100 void UpdateButton(UINT iID, UINT iFlags);
00101 void UpdateShowOpenStatusButton(BOOL fOpen);
00102 void UpdateShowCandButton();
00103 void UpdateModeButton(DWORD dwConv);
00104
00105 // mode.c
00106 LRESULT HandleModeCommand(HWND hWnd,WPARAM wParam,LPARAM lParam);
00107 LRESULT HandleConvertCommand(HWND, WPARAM, LPARAM);
00108
00109 // imemenu.c
00110 void EndMenuItemIDTable();
00111 void InitMenuItemIDTable();
00112 DWORD FindItemData(UINT wID);
00113 HMENU CreateImeMenu(HWND hWnd, HIMC hIMC, LPMYIMEMENUITEMINFO lpImeParentMenu, BOOL fRight);
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ErrorVtbl Member List

This is the complete list of members for ErrorVtbl, including all inherited members.
cNames | ErrorVtbl
dispIdMember | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Number)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Source)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Description)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_HelpFile)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_HelpContext)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_SQLState)(ADOError __RPC_FAR *This | ErrorVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_NativeError)(ADOError __RPC_FAR *This | ErrorVtbl
iTInfo | ErrorVtbl
lcid | ErrorVtbl
lcid | ErrorVtbl
lcid | ErrorVtbl
pbstr | ErrorVtbl
pctinfo | ErrorVtbl
pDispParams | ErrorVtbl
pExcepInfo | ErrorVtbl
pl | ErrorVtbl
ppTInfo | ErrorVtbl
ppvObject | ErrorVtbl
puArgErr | ErrorVtbl
pVarResult | ErrorVtbl
rgDispId | ErrorVtbl
rgszNames | ErrorVtbl
riid | ErrorVtbl
riid | ErrorVtbl
riid | ErrorVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(ADOError __RPC_FAR *This) | ErrorVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(ADOError __RPC_FAR *This) | ErrorVtbl
wFlags | ErrorVtbl
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Cap/Resource.h Source File

  • Web
  • MSAgent
  • c
  • Cap

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by cap.rc
00004 //
00005 #define IDS_COMMAND_PROPERTIES          1
00006 #define IDS_ANIMATIONS_LABEL            2
00007 #define IDD_DIALOG1                     101
00008 #define IDD_CAP                         101
00009 #define IDR_MENU                        110
00010 #define IDI_APP                         153
00011 #define IDR_ACCELERATORS                165
00012 #define IDD_ABOUT                       178
00013 #define IDC_ANIMATIONS                  1000
00014 #define IDC_PLAY                        1001
00015 #define IDC_STOP                        1002
00016 #define IDC_SPEAKTEXT                   1003
00017 #define IDC_SPEAK                       1004
00018 #define IDC_BALLOON_USE                 1005
00019 #define IDC_BALLOON_SIZETOTEXT          1006
00020 #define IDC_BALLOON_AUTOPACE            1007
00021 #define IDC_BALLOON_AUTOHIDE            1008
00022 #define IDC_MOVE_X                      1009
00023 #define IDC_MOVE_Y                      1010
00024 #define IDC_MOVE                        1011
00025 #define IDC_STOPBEFOREPLAY              1012
00026 #define IDC_ANIMATIONS_LABEL            1014
00027 #define IDC_SFX                         1015
00028 #define IDC_SPEECHOUTPUT_LABEL          1016
00029 #define IDC_POSITION_LABEL              1017
00030 #define IDC_X_LABEL                     1018
00031 #define IDC_Y_LABEL                     1019
00032 #define IDC_ICONPOS                     1108
00033 #define IDC_VERSION                     1115
00034 #define IDC_AGENTVERSION                1116
00035 #define ID_FILE_EXIT                    40001
00036 #define ID_HELP_ABOUT                   40002
00037 #define ID_FILE_OPENCHARACTER           40010
00038
00039 // Next default values for new objects
00040 //
00041 #ifdef APSTUDIO_INVOKED
00042 #ifndef APSTUDIO_READONLY_SYMBOLS
00043 #define _APS_NO_MFC                     1
00044 #define _APS_NEXT_RESOURCE_VALUE        102
00045 #define _APS_NEXT_COMMAND_VALUE         40003
00046 #define _APS_NEXT_CONTROL_VALUE         1020
00047 #define _APS_NEXT_SYMED_VALUE           101
00048 #endif
00049 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/MTXSample/StdAfx.cpp Source File

  • Web
  • iis
  • Components
  • Cpp
  • MTXSample

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/registry.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "globals.h"
00026
00027 ////////////////////////////////////////////////////////
00028 //
00029 // Internal helper functions prototypes
00030 //
00031
00032 // Set the given key and its value.
00033 BOOL setKeyAndValue(const _TCHAR* pszPath,
00034                     const _TCHAR* szSubkey,
00035                     const _TCHAR* szValue) ;
00036
00037 // Set the given key and its value in the MMC Snapin location
00038 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00039                           const _TCHAR* szSubkey,
00040                           const _TCHAR* szName,
00041                           const _TCHAR* szValue);
00042
00043 // Set the given valuename under the key to value
00044 BOOL setValue(const _TCHAR* szKey,
00045               const _TCHAR* szValueName,
00046               const _TCHAR* szValue);
00047
00048 // Delete szKeyChild and all of its descendents.
00049 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // Constants
00054 //
00055
00056 // Size of a CLSID as a string
00057 //const int CLSID_STRING_SIZE = 39 ;
00058
00059 /////////////////////////////////////////////////////////
00060 //
00061 // Public function implementation
00062 //
00063
00064 //
00065 // Register the component in the registry.
00066 //
00067 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00068                        const CLSID& clsid,         // Class ID
00069                        const _TCHAR* szFriendlyName)       //   IDs
00070 {
00071     // Get server location.
00072     _TCHAR szModule[512] ;
00073     DWORD dwResult =
00074         ::GetModuleFileName(hModule,
00075         szModule,
00076         sizeof(szModule)/sizeof(_TCHAR)) ;
00077
00078     assert(dwResult != 0) ;
00079
00080     // Get CLSID
00081     LPOLESTR wszCLSID = NULL ;
00082     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00083
00084     assert(SUCCEEDED(hr)) ;
00085
00086         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00087
00088     // Build the key CLSID\\{...}
00089     _TCHAR szKey[64] ;
00090     _tcscpy(szKey, _T("CLSID\\")) ;
00091         _tcscat(szKey, pszCLSID) ;
00092
00093     // Add the CLSID to the registry.
00094     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00095
00096     // Add the server filename subkey under the CLSID key.
00097     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00098
00099     // set the threading model
00100     _tcscat(szKey, _T("\\InprocServer32"));
00101     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00102
00103     // Free memory.
00104     CoTaskMemFree(wszCLSID) ;
00105
00106     return S_OK ;
00107 }
00108
00109 //
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00113 {
00114     // Get CLSID
00115     LPOLESTR wszCLSID = NULL ;
00116     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00117
00118
00119     // Build the key CLSID\\{...}
00120     _TCHAR szKey[64] ;
00121     _tcscpy(szKey, _T("CLSID\\")) ;
00122
00123         MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00124         _tcscat(szKey, pszT) ;
00125
00126     // Delete the CLSID Key - CLSID\{...}
00127     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00128     assert((lResult == ERROR_SUCCESS) ||
00129                (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00130
00131     // Free memory.
00132     CoTaskMemFree(wszCLSID) ;
00133
00134     return S_OK ;
00135 }
00136
00137 //
00138 // Register the snap-in in the registry.
00139 //
00140 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00141                        const _TCHAR* szNameString,   // NameString
00142                        const CLSID& clsidAbout,         // Class Id for About Class
00143                        const BOOL fSupportExtensions)
00144 {
00145     // Get CLSID
00146     LPOLESTR wszCLSID = NULL ;
00147     LPOLESTR wszAboutCLSID = NULL;
00148     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00149
00150     if (IID_NULL != clsidAbout)
00151         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00152
00153         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00154         MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00155
00156
00157     // Add the CLSID to the registry.
00158     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00159     setSnapInKeyAndValue(pszCLSID, _T("StandAlone"), NULL, NULL);
00160     if (IID_NULL != clsidAbout)
00161         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00162
00163     if (fSupportExtensions) {
00164         // Build the key NodeType
00165         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00166
00167         _TCHAR szKey[64] ;
00168         _tcscpy(szKey, pszCLSID) ;
00169         _tcscat(szKey, _T("\\NodeTypes")) ;
00170         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00171     }
00172
00173     // Free memory.
00174     CoTaskMemFree(wszCLSID) ;
00175     if (IID_NULL != clsidAbout)
00176         CoTaskMemFree(wszAboutCLSID);
00177
00178     return S_OK ;
00179 }
00180
00181 //
00182 // Unregister the snap-in in the registry.
00183 //
00184 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00185 {
00186     _TCHAR szKeyBuf[1024];
00187     LPOLESTR wszCLSID = NULL;
00188
00189     // Get CLSID
00190     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00191         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00192
00193     // Load the buffer with the Snap-In Location
00194     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00195
00196     // Copy keyname into buffer.
00197     _tcscat(szKeyBuf, _T("\\"));
00198     _tcscat(szKeyBuf, pszCLSID);
00199
00200     // Delete the CLSID Key - CLSID\{...}
00201     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00202     assert((lResult == ERROR_SUCCESS) ||
00203                (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00204
00205     // free the memory
00206     CoTaskMemFree(wszCLSID);
00207
00208     return S_OK;
00209 }
00210
00211 //
00212 // Delete a key and all of its descendents.
00213 //
00214 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00215                         const _TCHAR* lpszKeyChild)  // Key to delete
00216 {
00217     // Open the child.
00218     HKEY hKeyChild ;
00219     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00220         KEY_ALL_ACCESS, &hKeyChild) ;
00221     if (lRes != ERROR_SUCCESS)
00222     {
00223         return lRes ;
00224     }
00225
00226     // Enumerate all of the decendents of this child.
00227     FILETIME time ;
00228     _TCHAR szBuffer[256] ;
00229     DWORD dwSize = 256 ;
00230     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00231         NULL, NULL, &time) == S_OK)
00232     {
00233         // Delete the decendents of this child.
00234         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00235         if (lRes != ERROR_SUCCESS)
00236         {
00237             // Cleanup before exiting.
00238             RegCloseKey(hKeyChild) ;
00239             return lRes;
00240         }
00241         dwSize = 256 ;
00242     }
00243
00244     // Close the child.
00245     RegCloseKey(hKeyChild) ;
00246
00247     // Delete this child.
00248     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00249 }
00250
00251 //
00252 // Create a key and set its value.
00253 //   - This helper function was borrowed and modifed from
00254 //     Kraig Brockschmidt's book Inside OLE.
00255 //
00256 BOOL setKeyAndValue(const _TCHAR* szKey,
00257                     const _TCHAR* szSubkey,
00258                     const _TCHAR* szValue)
00259 {
00260     HKEY hKey;
00261     _TCHAR szKeyBuf[1024] ;
00262
00263     // Copy keyname into buffer.
00264     _tcscpy(szKeyBuf, szKey) ;
00265
00266     // Add subkey name to buffer.
00267     if (szSubkey != NULL)
00268     {
00269         _tcscat(szKeyBuf, _T("\\")) ;
00270         _tcscat(szKeyBuf, szSubkey ) ;
00271     }
00272
00273     // Create and open key and subkey.
00274     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00275         szKeyBuf,
00276         0, NULL, REG_OPTION_NON_VOLATILE,
00277         KEY_ALL_ACCESS, NULL,
00278         &hKey, NULL) ;
00279     if (lResult != ERROR_SUCCESS)
00280     {
00281         return FALSE ;
00282     }
00283
00284     // Set the Value.
00285     if (szValue != NULL)
00286     {
00287         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00288             (BYTE *)szValue,
00289             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00290     }
00291
00292     RegCloseKey(hKey) ;
00293     return TRUE ;
00294 }
00295
00296 //
00297 // Open a key value and set it
00298 //
00299 BOOL setValue(const _TCHAR* szKey,
00300               const _TCHAR* szValueName,
00301               const _TCHAR* szValue)
00302 {
00303     HKEY hKey;
00304     _TCHAR szKeyBuf[1024] ;
00305
00306     // Copy keyname into buffer.
00307     _tcscpy(szKeyBuf, szKey) ;
00308
00309     // Create and open key and subkey.
00310     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00311         szKeyBuf,
00312         0, NULL, REG_OPTION_NON_VOLATILE,
00313         KEY_ALL_ACCESS, NULL,
00314         &hKey, NULL) ;
00315     if (lResult != ERROR_SUCCESS)
00316     {
00317         return FALSE ;
00318     }
00319
00320     // Set the Value.
00321     if (szValue != NULL)
00322     {
00323         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00324             (BYTE *)szValue,
00325             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00326     }
00327
00328     RegCloseKey(hKey) ;
00329     return TRUE ;
00330 }
00331
00332 //
00333 // Create a key and set its value.
00334 //   - This helper function was borrowed and modifed from
00335 //     Kraig Brockschmidt's book Inside OLE.
00336 //
00337 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00338                           const _TCHAR* szSubkey,
00339                           const _TCHAR* szName,
00340                           const _TCHAR* szValue)
00341 {
00342     HKEY hKey;
00343     _TCHAR szKeyBuf[1024] ;
00344
00345     // Load the buffer with the Snap-In Location
00346     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00347
00348     // Copy keyname into buffer.
00349     _tcscat(szKeyBuf, _T("\\")) ;
00350     _tcscat(szKeyBuf, szKey) ;
00351
00352     // Add subkey name to buffer.
00353     if (szSubkey != NULL)
00354     {
00355         _tcscat(szKeyBuf, _T("\\")) ;
00356         _tcscat(szKeyBuf, szSubkey ) ;
00357     }
00358
00359     // Create and open key and subkey.
00360     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00361         szKeyBuf,
00362         0, NULL, REG_OPTION_NON_VOLATILE,
00363         KEY_ALL_ACCESS, NULL,
00364         &hKey, NULL) ;
00365     if (lResult != ERROR_SUCCESS)
00366     {
00367         return FALSE ;
00368     }
00369
00370     // Set the Value.
00371     if (szValue != NULL)
00372     {
00373         RegSetValueEx(hKey, szName, 0, REG_SZ,
00374             (BYTE *)szValue,
00375             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00376     }
00377
00378     RegCloseKey(hKey) ;
00379     return TRUE ;
00380 }
00381
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/bits_ie/resource.h Source File

  • Web
  • bits
  • bits_ie

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by bits_ie.rc
00004 //
00005 #define IDS_LONGPROGRESS                1
00006 #define IDS_ERROR                       2
00007 #define IDS_SHORTPROGRESS               3
00008 #define IDS_QUEUED                      4
00009 #define IDS_CONNECTING                  5
00010 #define IDS_TRANSFERRING                6
00011 #define IDS_SUSPENDED                   7
00012 #define IDS_FATALERROR                  8
00013 #define IDS_TRANSIENTERROR              9
00014 #define IDS_TRANSFERRED                 10
00015 #define IDS_ACKNOWLEDGED                11
00016 #define IDS_CANCELLED                   12
00017 #define IDS_UNKNOWN                     13
00018 #define IDS_DAYSFORMAT                  14
00019 #define IDS_HOURSFORMAT                 15
00020 #define IDS_MINUTESFORMAT               16
00021 #define IDS_SECONDSFORMAT               17
00022 #define IDS_FOREGROUND                  18
00023 #define IDS_HIGH                        19
00024 #define IDS_NORMAL                      20
00025 #define IDS_LOW                         21
00026 #define IDS_ERRORBOXTITLE               22
00027 #define IDS_FILEDLGTITLE                23
00028 #define IDS_CANCELCAPTION               24
00029 #define IDS_CANCELTEXT                  25
00030 #define IDS_NOHTTPORHTTPS               26
00031 #define IDS_ALLFILES                    27
00032 #define IDS_STARTUPLINK                 28
00033 #define IDS_CLOSECAPTION                29
00034 #define IDS_CLOSETEXT                   30
00035 #define IDS_ALREADYFINISHED             31
00036 #define IDS_ALREADYFINISHEDCAPTION      32
00037 #define IDS_GIGAFORMAT                  33
00038 #define IDS_MEGAFORMAT                  34
00039 #define IDS_KILOFORMAT                  35
00040 #define IDS_BYTEFORMAT                  36
00041 #define IDS_DISPLAYERRORCODE            37
00042 #define IDS_MAX                         IDS_DISPLAYERRORCODE
00043 #define IDD_DIALOG                      101
00044 #define IDI_ICON1                       105
00045 #define IDC_COMPLETE2                   1004
00046 #define IDC_FINISH                      1004
00047 #define IDC_CANCEL2                     1005
00048 #define IDC_CANCEL                      1005
00049 #define IDC_SUSPEND2                    1006
00050 #define IDC_SUSPEND                     1006
00051 #define IDC_PROGRESS                    1007
00052 #define IDC_PROGRESSBAR                 1007
00053 #define IDC_STATUSTXT                   1008
00054 #define IDC_CREATIONTIMETXT             1009
00055 #define IDC_MODIFICATONTIMETXT          1010
00056 #define IDC_COMPLETIONTIMETXT           1011
00057 #define IDC_ESTIMATEDTIMETXT            1012
00058 #define IDC_TRANSFERRATETXT             1013
00059 #define IDC_PRIORITY                    1014
00060 #define IDC_RESUME2                     1015
00061 #define IDC_RESUME                      1015
00062 #define IDC_PRIORITYTXT                 1016
00063 #define IDC_ERRORMSGTXT                 1017
00064 #define IDC_STATUS                      1021
00065 #define IDC_STARTTIME                   1022
00066 #define IDC_MODIFICATIONTIME            1023
00067 #define IDC_COMPLETIONTIME              1024
00068 #define IDC_ESTIMATEDTIME               1025
00069 #define IDC_TRANSFERRATE                1026
00070 #define IDC_ERRORMSG                    1027
00071 #define IDC_PROGRESSINFOTXT             1045
00072 #define IDC_PROGRESSINFO                1046
00073 #define IDC_DISPLAYNAME                 1047
00074
00075 // Next default values for new objects
00076 //
00077 #ifdef APSTUDIO_INVOKED
00078 #ifndef APSTUDIO_READONLY_SYMBOLS
00079 #define _APS_NEXT_RESOURCE_VALUE        106
00080 #define _APS_NEXT_COMMAND_VALUE         40001
00081 #define _APS_NEXT_CONTROL_VALUE         1037
00082 #define _APS_NEXT_SYMED_VALUE           101
00083 #endif
00084 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Move/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Move
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__7AB36130_AF42_11D2_9A73_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__7AB36130_AF42_11D2_9A73_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__7AB36130_AF42_11D2_9A73_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCompositionEditSession Member List

This is the complete list of members for CCompositionEditSession, including all inherited members.
_pContext | CEditSessionBase | [protected]
_pMark | CCompositionEditSession | [private]
CCompositionEditSession(ITfContext *pContext, CMarkTextService *pMark) | CCompositionEditSession | [inline]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
DoEditSession(TfEditCookie ec) | CCompositionEditSession | [virtual]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
~CCompositionEditSession() | CCompositionEditSession | [inline]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
Generated on Wed Nov 13 2024 16:55:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/foldernode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

foldernode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CFolderNode class.
00014 //
00015
00016
00017 #include "FolderNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020 #include "AddVFileDlg.h"
00021                              // Tracing stuff
00022 #include "TraceMacro.h"
00023 #undef  MODULESTRING
00024 #define MODULESTRING  _T("CFolderNode")
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CFolderNode::thisGUID = CLSID_CFolderNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 //---------------------------------------------------------------------------
00035 CFolderNode::CFolderNode()
00036 {
00037   m_SDI.mask        = DEFAULT_SDI_MASK;
00038   m_SDI.displayname = MMC_CALLBACK;
00039   m_SDI.nImage      = IMG_FOLDER_DEFAULT;
00040   m_SDI.nOpenImage  = IMG_FOLDER_DEFAULT;
00041   m_SDI.cChildren   = 1;              // Determines if the '+' is displayed
00042   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00043
00044   m_dwAttributes    = 0;
00045   m_pCompData       = NULL;
00046   m_hAddVFileDlg    = NULL;
00047
00048 }
00049
00050 //---------------------------------------------------------------------------
00051 CFolderNode::~CFolderNode()
00052 {
00053   // Clean up our message window
00054   if( NULL != m_hMessageWnd )
00055     DestroyWindow( m_hMessageWnd );
00056 }
00057
00058
00059 //---------------------------------------------------------------------------
00060 HRESULT CFolderNode::Initialize( NODE_PROPERTIES* pNodeProps )
00061 {
00062   _ASSERT( NULL != pNodeProps );
00063   HRESULT hResult = S_FALSE;
00064
00065   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00066   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00067   wcscpy( pszTmp, pNodeProps->szNodeName );
00068   if( NULL != m_pwszNodeName )
00069     CoTaskMemFree( m_pwszNodeName );
00070
00071   m_pwszNodeName = pszTmp;
00072   m_pCompData = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00073   // We don't call back to our parent so pNodeProps->pParentObject is ignored.
00074
00075   RefreshNodeList();         // Create Result Item nodes
00076
00077   // We create a hidden window to allow us to communicate with modeless
00078   // dialogs and other things which run in a seperate thread.
00079
00080   WNDCLASS wc;
00081   ZeroMemory (&wc, sizeof(WNDCLASS));
00082   wc.cbWndExtra    = sizeof(this);
00083   wc.lpfnWndProc   = FolderNodeWndProc;
00084   wc.hInstance     = g_hInst;
00085   wc.lpszClassName = _T("FolderNodeMessageWindow");
00086
00087   RegisterClass( &wc );
00088   m_hMessageWnd = CreateWindow( _T("FolderNodeMessageWindow"), NULL,
00089                                 0, 0, 0, 0, 0, NULL, 0, g_hInst, this);
00090
00091   if( NULL == m_hMessageWnd )
00092     hResult = S_FALSE;
00093
00094   return hResult;
00095 }
00096
00097
00098 //---------------------------------------------------------------------------
00099 //  This is our hidden window which is just used for handling messages.  We
00100 //  go to all this trouble so that we don't ever pass interface pointers or
00101 //  other objects across threads.
00102 //
00103 LRESULT CALLBACK CFolderNode::FolderNodeWndProc
00104 (
00105   HWND   hWnd,     //[in] Handle to window
00106   UINT   uMsg,     //[in] Message identifier
00107   WPARAM wParam,   //[in] First message parameter
00108   LPARAM lParam    //[in] Second message parameter
00109 )
00110 {
00111   switch( uMsg )
00112   {
00113     case WM_CREATE:
00114     {
00115       LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00116       SetWindowLongPtr( hWnd, 0, (LONG_PTR)lpcs->lpCreateParams );
00117       break;
00118     }
00119
00120     case WM_ADD_VIRTUALFILE:
00121     {
00122       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00123       NODE_PROPERTIES* pProps = (NODE_PROPERTIES*)wParam;
00124       pThisNode->AddVirtualFile( pProps );
00125       break;
00126     }
00127
00128     case WM_VIRTUALFILE_CLOSED:
00129     {
00130       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00131       pThisNode->m_hAddVFileDlg = NULL;
00132       break;
00133     }
00134     default:
00135       return DefWindowProc( hWnd, uMsg, wParam, lParam );
00136   }
00137   return 0;
00138 }
00139
00140
00141 /////////////////////////////////////////////////////////////////////////////
00142 // Implementation of virtual methods
00143
00144
00145 //---------------------------------------------------------------------------
00146 HRESULT CFolderNode::GetResultViewType2
00147 (
00148   MMC_COOKIE             nCookie,  //[in] Identifier of object
00149   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00150 )
00151 {
00152   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00153   if( NULL == pszDescStr )
00154     return E_OUTOFMEMORY;
00155
00156   wcscpy( pszDescStr, L"DefaultListView" );
00157   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00158
00159   return S_OK;
00160 }
00161
00162 //---------------------------------------------------------------------------
00163 HRESULT CFolderNode::GetDisplayInfo
00164 (
00165   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00166 )
00167 {
00168   _ASSERT( NULL != pSDI );
00169   pSDI->displayname = m_pwszNodeName;
00170
00171   return S_OK;
00172 }
00173
00174 //---------------------------------------------------------------------------
00175 HRESULT CFolderNode::GetDisplayInfo
00176 (
00177   RESULTDATAITEM* pRDI
00178 )
00179 {
00180   _ASSERT( NULL != pRDI );
00181
00182   HRESULT hResult = S_OK;
00183
00184   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00185   {                                  // for each column
00186     switch( pRDI->nCol )
00187     {
00188       case 0:
00189         pRDI->str = m_pwszNodeName;
00190         break;
00191
00192       case 1:                        // Attributes not supported for this node
00193         pRDI->str = L"";
00194         break;
00195
00196       default:
00197         hResult = S_FALSE;
00198         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00199         break;
00200     }
00201   }
00202   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00203   {
00204     pRDI->nImage = m_SDI.nImage;
00205   }
00206
00207   //TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00208   return hResult;
00209
00210 }
00211
00212 /////////////////////////////////////////////////////////////////////////////
00213 // Implementation of notification handlers
00214
00215
00216 //---------------------------------------------------------------------------
00217 HRESULT CFolderNode::OnSelect
00218 (
00219   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00220   LPARAM        nArg,          //[in] Bools for context & selection state
00221   LPARAM        nParam,        //[in] Not used
00222   LONG_PTR      pComponent     //[in] Points calling CComponent
00223 )
00224 {
00225   HRESULT hResult = S_FALSE;
00226
00227   // Not setting verbs for this node
00228
00229   //TRACE_HRESULT(_T("OnSelect"), hResult );
00230   return hResult;
00231 }
00232
00233
00234 //---------------------------------------------------------------------------
00235 HRESULT CFolderNode::OnShow
00236 (
00237   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00238   LPARAM        nArg,          //[in] TRUE if node was selcted
00239   LPARAM        nParam,        //[in] HSCOPEITEM of selected/deselected item
00240   LONG_PTR      pComponent     //[in] Points calling CComponent
00241 )
00242 {
00243   HRESULT  hResult = S_FALSE;
00244
00245   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00246
00247   LPHEADERCTRL2  ipHeaderCtrl = NULL;
00248   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL, (LONG_PTR*)&ipHeaderCtrl );
00249   if( S_OK != hResult )
00250    return hResult;
00251
00252   LPRESULTDATA  ipResultData = NULL;
00253   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00254   if( S_OK != hResult )
00255    return hResult;
00256
00257
00258   if( TRUE == nArg )         // Selecting a scope node
00259   {
00260     do
00261     {
00262       hResult = ipHeaderCtrl->InsertColumn( 0, L"File Name", 0, 150 );
00263       BREAK_ON_ERROR( hResult );
00264
00265       hResult = ipHeaderCtrl->InsertColumn( 1, L"Attributes", 0, 150 );
00266       BREAK_ON_ERROR( hResult );
00267
00268       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00269       BREAK_ON_ERROR( hResult );
00270
00271       hResult = EnumerateResultItems( ipResultData );
00272       BREAK_ON_ERROR( hResult );
00273
00274     }while(0);
00275   }
00276   else                       // Clean up result items on deselection
00277   {
00278     hResult = ipResultData->DeleteAllRsltItems();
00279   }
00280
00281   //TRACE_HRESULT(_T("OnShow"), hResult );
00282   return hResult;
00283 }
00284
00285 //---------------------------------------------------------------------------
00286 HRESULT CFolderNode::OnExpand
00287 (
00288   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00289   LPARAM         nArg,         //[in] TRUE if node was selcted
00290   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00291   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00292 )
00293 {
00294   HRESULT hResult = S_FALSE;
00295
00296   if( NULL == m_pCompData )
00297     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00298
00299
00300   //TRACE_HRESULT( _T("OnExpand"), hResult );
00301   return hResult;              // Not expanding anything
00302 }
00303
00304 //---------------------------------------------------------------------------
00305 HRESULT CFolderNode::OnRemoveChildren
00306 (
00307   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00308   LPARAM         nArg,         //[in] TRUE if node was selcted
00309   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00310   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00311 )
00312 {
00313   HRESULT hResult = S_OK;      // Just delete our child nodes, the
00314                                // corresponding result items are cleaned
00315   RemoveChildNodes();          // up in MMCN_SHOW -> FALSE
00316
00317   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00318   return hResult;
00319 }
00320
00321 //---------------------------------------------------------------------------
00322 HRESULT CFolderNode::OnViewChange
00323 (
00324   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00325   LPARAM         nArg,         //[in] TRUE if node was selcted
00326   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00327   LONG_PTR       pComponent    //[in] Points to calling IComponent
00328 )
00329 {
00330   HRESULT hResult = S_FALSE;
00331   LPRESULTDATA ipResultData = NULL;
00332
00333   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00334   pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00335
00336   LONG_PTR pScopeCookie = pComp->GetScopeCookie();
00337
00338   if( pScopeCookie == (LONG_PTR)this )
00339     hResult = EnumerateResultItems( ipResultData );
00340
00341   TRACE_HRESULT( _T("OnViewChange"), hResult );
00342   return hResult;
00343 }
00344
00345
00346 /////////////////////////////////////////////////////////////////////////////
00347 //  Support for Context Menus
00348
00349 //---------------------------------------------------------------------------
00350 HRESULT CFolderNode::AddMenuItems
00351 (
00352   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00353   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00354 )
00355 {
00356   _ASSERT( NULL != ipCallback );
00357   HRESULT hResult = S_FALSE;
00358
00359   static CONTEXTMENUITEM ctxMenu;
00360     ctxMenu.lCommandID        = IDM_NEW_VIRTFILE;
00361     ctxMenu.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00362     ctxMenu.fSpecialFlags     = 0;
00363     ctxMenu.strName           = L"New Virtual File...";
00364     ctxMenu.strStatusBarText  = L"Add a new virtual file";
00365
00366
00367   if( NULL == m_hAddVFileDlg )     // If the AddVFile dialog is running
00368     ctxMenu.fFlags = 0;            // gray the menu selection
00369   else
00370     ctxMenu.fFlags = MF_GRAYED;
00371
00372
00373   // Add the 'New Device' option to the New menu if allowed...
00374   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00375   {
00376     hResult = ipCallback->AddItem( &ctxMenu );
00377   }
00378
00379   return hResult;
00380 }
00381
00382 //---------------------------------------------------------------------------
00383 HRESULT CFolderNode::Command
00384 (
00385   long lCommandID          //[in] Indentifier for menu ID
00386 )
00387 {
00388   HRESULT hResult = S_OK;
00389
00390   switch( lCommandID )
00391   {
00392     case IDM_NEW_VIRTFILE:
00393     {
00394       CAddVFileDlg* pDlg = new CAddVFileDlg( IDD_ADDVFILE_DLG, m_hMessageWnd );
00395       m_hAddVFileDlg = pDlg->Create( g_hInst, GetDesktopWindow(), 0 );
00396       break;
00397     }
00398     default:
00399     {
00400       hResult = S_FALSE;
00401       break;
00402     }
00403   }
00404   return hResult;
00405 }
00406
00407 /////////////////////////////////////////////////////////////////////////////
00408 //  Private helpers
00409
00410 //---------------------------------------------------------------------------
00411 HRESULT CFolderNode::RefreshNodeList()
00412 {
00413   NODE_PROPERTIES NodeProps;
00414   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00415   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00416   NodeProps.dwAttributes   = ATTRIBUTE_DATA_ARCHIVE;
00417
00418   WCHAR  szNames[1][32];
00419   wcscpy( szNames[0], L"Virtual File 1" );
00420
00421   RemoveChildNodes();                  // Clean the node list
00422
00423   CVirtualFile* pNode = NULL;
00424   for( DWORD i = 0; i < 1; i++ )
00425   {
00426     wcscpy( NodeProps.szNodeName, szNames[i] );
00427     pNode = new CVirtualFile;
00428     pNode->Initialize( &NodeProps );
00429     m_NodeList.AddTail( pNode );
00430   }
00431
00432   return S_OK;
00433 }
00434
00435 //---------------------------------------------------------------------------
00436 VOID CFolderNode::RemoveChildNodes()
00437 {
00438   CVirtualFile* pNode = NULL;
00439   POSITION   Pos   = m_NodeList.GetHeadPosition();
00440   while( Pos )
00441   {
00442     pNode = m_NodeList.GetNext( Pos );
00443     delete pNode;
00444   }
00445   m_NodeList.RemoveAll();              // Clean the list
00446 }
00447
00448
00449 //---------------------------------------------------------------------------
00450 //  This is where OOP gets to be fun.
00451 //  We use the NodeProperties pointer which originally came from the
00452 //  modeless AddVFileDlg, by way of our hidden window, to create a new
00453 //  Virtual File node and add it to our linked list.
00454 //  This by itself will not cause the new node to be displayed.  To do
00455 //  that we need to call IResultData::InsertItem().  However we don't
00456 //  have a way to get that pointer.  So we have to be indirect.  We call
00457 //  IComponentData::QueryDataObject() to create a data object.  The data
00458 //  object points back to this node.  We can then pass that to
00459 //  IConsole2::UpdateAllViews().  This makes sure all instances of
00460 //  IComponent are called (there may me several running).  Then the
00461 //  MMCN_VIEW_CHANGE notification is delegated back to this node, along
00462 //  with a pointer to the correct IComponent.  With this pointer we can
00463 //  call GetInterface() to get an IResultData pointer which we can then
00464 //  pass to EnumerateResultItems() to display the new Virtual File.
00465 //
00466 HRESULT CFolderNode::AddVirtualFile
00467 (
00468   NODE_PROPERTIES* pProps    //[in] Properties of new node
00469 )
00470 {
00471   _ASSERT( NULL != pProps );
00472   HRESULT hResult = S_FALSE;
00473
00474   pProps->pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00475   pProps->pParentObject  = reinterpret_cast<LONG_PTR>(this);
00476
00477   CVirtualFile* pNode = NULL;
00478   pNode = new CVirtualFile;
00479   pNode->Initialize( pProps );
00480   m_NodeList.AddTail( pNode );
00481
00482   LPCONSOLE3 ipConsole = NULL;
00483   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole );
00484   if( S_OK != hResult )
00485     return hResult;
00486
00487   LPDATAOBJECT pDO = NULL;
00488   m_pCompData->QueryDataObject( (MMC_COOKIE)this, CCT_SCOPE, &pDO );
00489
00490   ipConsole->UpdateAllViews( pDO, 0, 0 );
00491   pDO->Release();
00492
00493   return hResult;
00494 }
00495
00496 //---------------------------------------------------------------------------
00497 //  This is called by a child node to have itself removed from the list
00498 //  of child nodes.  The node itself is not deleted, the child node will
00499 //  delete itself when this function returns.
00500 //
00501 VOID CFolderNode::RemoveVirtualFile
00502 (
00503   CVirtualFile* pDeadNode    //[in] CVirtualFile to remove from list
00504 )
00505 {
00506   CVirtualFile* pNode = NULL;
00507   POSITION     NewPos = m_NodeList.GetHeadPosition();
00508   POSITION     OldPos = NULL;
00509   while( NewPos )
00510   {
00511     OldPos = NewPos;                   // Need to save this
00512     pNode = m_NodeList.GetNext( NewPos );
00513     if( pNode == pDeadNode )
00514     {
00515       m_NodeList.RemoveAt( OldPos );
00516       continue;                        // Exit, found it
00517     }
00518   }
00519 }
00520
00521 //---------------------------------------------------------------------------
00522 HRESULT CFolderNode::EnumerateResultItems
00523 (
00524   LPRESULTDATA ipResultData  //[in] Points to cached IResultData
00525 )
00526 {
00527   _ASSERT( NULL != ipResultData );
00528   HRESULT hResult = S_FALSE;
00529
00530   hResult = ipResultData->DeleteAllRsltItems();
00531
00532   CVirtualFile*  pNode = NULL;
00533   POSITION       Pos   = m_NodeList.GetHeadPosition();
00534   while( Pos )
00535   {
00536     pNode = m_NodeList.GetNext( Pos );
00537     hResult = ipResultData->InsertItem( &pNode->m_RDI );
00538   }
00539
00540   return hResult;
00541 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/FileTerm/FileTerm.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • FileTerm

FileTerm.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////
00002 //
00003 //
00004 // Copyright (c) 1998-2001  Microsoft Corporation
00005 //
00006 //
00007 // FileTerm.h : General declarations, definitions for FileTerm.cpp
00008 //
00009 ////////////////////////////////////////////////////////////////////////////
00010 #ifndef __FILETERM_H__
00011 #define __FILETERM_H__
00012
00013 #define TAPI_TIMEOUT      2000
00014 #define MSGBOX_NAME       _T("TAPI 3.1 File Terminals Sample")
00015
00016
00017 //////////////////////////////////////////////////////////
00018 // PROTOTYPES
00019 //////////////////////////////////////////////////////////
00020 INT_PTR
00021 CALLBACK
00022 MainDialogProc(
00023         HWND hDlg,
00024         UINT uMsg,
00025         WPARAM wParam,
00026         LPARAM lParam
00027         );
00028
00029 HRESULT
00030 GetTerminal(
00031         IN  ITAddress *,
00032         IN  BSTR bstrMedia,
00033         OUT ITTerminal ** ppTerminal
00034         );
00035 HRESULT
00036 RegisterTapiEventInterface();
00037
00038 HRESULT
00039 UnRegisterTapiEventInterface();
00040
00041
00042 HRESULT
00043 ListenOnAddresses();
00044
00045 HRESULT
00046 ListenOnThisAddress(
00047         IN  ITAddress * pAddress
00048         );
00049
00050 HRESULT
00051 AnswerTheCall();
00052
00053 HRESULT
00054 PutPlayList(
00055         IN  ITTerminal *pITTerminal,
00056         IN  BSTR bstrFileName
00057         );
00058
00059 HRESULT
00060 DisconnectTheCall();
00061
00062 void
00063 ReleaseTheCall();
00064
00065 void
00066 DoMessage(
00067         IN  LPWSTR pszMessage
00068         );
00069
00070 void
00071 SetStatusMessage(
00072         IN  LPWSTR pszMessage
00073         );
00074
00075 HRESULT
00076 InitializeTapi();
00077
00078 void
00079 ShutdownTapi();
00080
00081 #endif //__FILETERM_H__
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/delebase.h Source File

  • SysMgmt
  • MMC
  • Nameext

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CDelegationBase {
00030 public:
00031     CDelegationBase();
00032     virtual ~CDelegationBase();
00033
00034     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00035     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00036
00037     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00038     virtual const int GetBitmapIndex() = 0;
00039
00040     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00041
00042 public:
00043     // virtual functions go here (for MMCN_*)
00044     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00045     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00046     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00047     virtual HRESULT OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) { return S_FALSE; }
00048     virtual HRESULT OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) { return S_FALSE; }
00049     virtual HRESULT OnMenuCommand(IConsole *pConsole, long lCommandID) { return S_FALSE; }
00050
00051 public:
00052     static HBITMAP m_pBMapSm;
00053     static HBITMAP m_pBMapLg;
00054
00055 protected:
00056
00057     BOOL bExpanded;
00058
00059   static void LoadBitmaps() {
00060         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00061         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS)); }
00062
00063 private:
00064     // {98015FF3-6A2D-11d3-9154-00C04F65B3F9}
00065     static const GUID thisGuid;
00066 };
00067
00068 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/Rcv/Main.Cpp Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • Rcv

Main.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 #include "stdafx.h"
00013 #include "..\QueueDef.h"
00014 #import "mqoa.tlb"      no_namespace      // MSMQ COM object
00015
00016
00017
00018 #ifdef _DEBUG
00019   #import "..\GraphObj\DebugU\GraphObj.dll" \
00020               no_namespace      // Point and Line object
00021
00022 #else
00023   #import "..\GraphObj\ReleaseU\GraphObj.dll" \
00024               no_namespace      // Point and Line object
00025
00026 #endif
00027
00028
00029
00030 // Initialize OLE library
00031 struct InitOle  _init_InitOle_;
00032
00033
00034
00035 void main()
00036 {
00037     try {
00038     // For these ActiveX components we need only smart interface pointer
00039     IMSMQQueuePtr   pQueue;
00040     IMSMQMessagePtr   pMessage;
00041
00042     // Instanciate the follwing ActiveX components
00043     IMSMQQueueInfoPtr pQueueInfo(__uuidof(MSMQQueueInfo));
00044
00045     int         n = 1;
00046
00047     cout << "\n\nMSMQ IPersistStream Test Object Receiver\n";
00048     cout << "==========================================\n\n";
00049
00050
00051     // Open the queue
00052     pQueueInfo->PathName = ".\\IStreamTest";
00053     try {
00054       pQueue = pQueueInfo->Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);
00055     } catch (_com_error& e) {
00056       if (e.Error() == MQ_ERROR_QUEUE_NOT_FOUND) {
00057         cout << "\n\nERROR queue does not exist\n";
00058         exit(-1);
00059       } else
00060         dump_com_error(e);
00061     }
00062
00063     // Get the next message
00064     pMessage = pQueue->Receive();
00065
00066     IPointPtr   pPoint((IUnknown*)pMessage->Body);
00067
00068     // Check if it's a Point object
00069     if (pPoint != NULL) {
00070
00071       cout << "\nGot a Point Object: " << pPoint->x << "   " << pPoint->y << "\n";
00072
00073     }
00074     else {
00075       ILinePtr  pLine((IUnknown*)pMessage->Body);
00076
00077       // Check if it's a Line object
00078       if (pLine != NULL) {
00079         cout << "\nGot a Line Object: " << pLine->x1 << " " << pLine->y1 << " " << pLine->x2 << " " << pLine->y2 << "\n";
00080       }
00081       else
00082         cout << "\nUnknown Object !!!\n";
00083     }
00084     pQueue->Close();
00085
00086
00087     } catch (_com_error& e) {
00088     dump_com_error(e);
00089     }
00090 }
00091
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/bindtoparent/vc/bindtoparent.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • bindtoparent
  • vc

bindtoparent.cpp

Go to the documentation of this file.
00001 // bindtoparent.cpp : Defines the entry point for the console application.
00002 //
00003 #include <wchar.h>
00004 #include <objbase.h>
00005 #include <activeds.h>
00006
00007 HRESULT GetParentObject(IADs *pObject, //Pointer the object whose parent to bind to.
00008             IADs **ppParent //Return a pointer to the parent object.
00009             );
00010
00011 HRESULT FindUserByName(IDirectorySearch *pSearchBase, //Container to search
00012              LPOLESTR szFindUser, //Name of user to find.
00013              IADs **ppUser); //Return a pointer to the user
00014
00015
00016 void wmain( int argc, wchar_t *argv[ ])
00017 {
00018
00019 //Handle the command line arguments.
00020 LPOLESTR pszBuffer = new OLECHAR[MAX_PATH*2];
00021 if (argv[1] == NULL)
00022 {
00023   wprintf(L"This program finds a user in the current Window 2000 domain\n");
00024   wprintf(L"and displays its parent container's ADsPath and binds to that container.\n");
00025   wprintf(L"Enter Common Name of the user to find:");
00026   _getws(pszBuffer);
00027 }
00028 else
00029    wcscpy(pszBuffer, argv[1]);
00030 //if empty string, exit.
00031 if (0==wcscmp(L"", pszBuffer))
00032 {
00033    delete pszBuffer;
00034    return;
00035 }
00036
00037 wprintf(L"\nFinding user: %s...\n",pszBuffer);
00038
00039 //Intialize COM
00040 CoInitialize(NULL);
00041 HRESULT hr = S_OK;
00042 //Get rootDSE and the domain container's DN.
00043 IADs *pObject = NULL;
00044 IADs *pParent = NULL;
00045 IDirectorySearch *pDS = NULL;
00046 LPOLESTR szPath = new OLECHAR[MAX_PATH]; //[seyitb] delete at the end
00047 VARIANT var;
00048 hr = ADsOpenObject(L"LDAP://rootDSE",
00049          NULL,
00050          NULL,
00051          ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00052          IID_IADs,
00053          (void**)&pObject);
00054 if (FAILED(hr))
00055 {
00056    wprintf(L"Not Found. Could not bind to the domain.\n");
00057    if (pObject)
00058      pObject->Release();
00059     delete pszBuffer;
00060     delete szPath;
00061    return;
00062 }
00063
00064 hr = pObject->Get(L"defaultNamingContext",&var);
00065 if (SUCCEEDED(hr))
00066 {
00067   wcscpy(szPath,L"LDAP://"); // If you're running on NT 4.0 or Win9.x machine, you need to
00068                              // add the server name e.g L"LDAP://myServer"
00069   wcscat(szPath,var.bstrVal);
00070   VariantClear(&var);
00071   if (pObject)
00072   {
00073      pObject->Release();
00074      pObject = NULL;
00075   }
00076   //Bind to the root of the current domain.
00077   hr = ADsOpenObject(szPath,
00078            NULL,
00079            NULL,
00080            ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00081            IID_IDirectorySearch,
00082            (void**)&pDS);
00083   if (SUCCEEDED(hr))
00084   {
00085     hr =  FindUserByName(pDS, //Container to search
00086                pszBuffer, //Name of user to find.
00087                &pObject); //Return a pointer to the user
00088     if (pDS)  pDS->Release();
00089
00090     if (SUCCEEDED(hr))
00091     {
00092       BSTR bstr, bstrC;
00093                 hr = GetParentObject(pObject, //Pointer the object whose parent to bind to.
00094             &pParent //Return a pointer to the parent object.
00095             );
00096       if (SUCCEEDED(hr))
00097       {
00098            wprintf(L"Successfully bound to parent container\n");
00099            //Get ADsPath
00100            hr = pParent->get_ADsPath(&bstr);
00101              //Get the distinguishedName property
00102                 hr = pParent->Get(L"distinguishedName", &var);
00103            //Get class
00104            hr = pParent->get_Class(&bstrC);
00105              if (SUCCEEDED(hr))
00106            {
00107                  wprintf(L"ADsPath: %s\n",bstr);
00108             wprintf(L"DN: %s\n",var.bstrVal);
00109             wprintf(L"Class: %s\n",bstrC);
00110            }
00111            else
00112               wprintf(L"Get method failed with hr: %x\n",hr);
00113            VariantClear(&var);
00114            //Free the BSTR.
00115                    FreeADsStr(bstr);
00116                    FreeADsStr(bstrC);
00117       }
00118       else
00119         wprintf(L"GetParentObject failed with hr: %x\n",hr);
00120       if (pParent)
00121         pParent->Release();
00122     }
00123     else
00124     {
00125                 wprintf(L"User \"%s\" not Found.\n",pszBuffer);
00126       wprintf (L"FindUserByName failed with the following HR: %x\n", hr);
00127     }
00128     if (pObject)
00129       pObject->Release();
00130   }
00131 }
00132
00133
00134 delete pszBuffer;
00135 delete szPath;
00136
00137 //Uninitalize COM
00138 CoUninitialize();
00139
00140 return;
00141 }
00142
00143 HRESULT GetParentObject(IADs *pObject, //Pointer the object whose parent to bind to.
00144             IADs **ppParent //Return a pointer to the parent object.
00145             )
00146 {
00147   if ((!pObject)||(!ppParent))
00148     return E_INVALIDARG;
00149
00150   HRESULT hr = E_FAIL;
00151   BSTR bstr;
00152   hr = pObject->get_Parent(&bstr);
00153   if (SUCCEEDED(hr))
00154   {
00155     //Bind to the parent container.
00156     *ppParent = NULL;
00157         hr = ADsOpenObject(bstr,
00158        NULL,
00159        NULL,
00160        ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00161        IID_IADs,
00162        (void**)ppParent);
00163     if(FAILED(hr))
00164     {
00165       if ((*ppParent))
00166       {
00167           (*ppParent)->Release();
00168               (*ppParent) = NULL;
00169       }
00170     }
00171   }
00172        FreeADsStr(bstr);
00173   return hr;
00174 }
00175
00176
00177
00178
00179
00180 HRESULT FindUserByName(IDirectorySearch *pSearchBase, //Container to search
00181              LPOLESTR szFindUser, //Name of user to find.
00182              IADs **ppUser) //Return a pointer to the user
00183 {
00184   HRESULT hr = S_OK;
00185
00186   if ((!pSearchBase)||(!szFindUser))
00187     return E_INVALIDARG;
00188
00189   //Create search filter
00190   LPOLESTR pszSearchFilter = new OLECHAR[MAX_PATH];
00191   LPOLESTR szADsPath = new OLECHAR[MAX_PATH];
00192   wcscpy(pszSearchFilter, L"(&(objectCategory=person)(objectClass=user)(cn=");
00193   wcscat(pszSearchFilter, szFindUser);
00194   wcscat(pszSearchFilter, L"))");
00195
00196   //Search entire subtree from root.
00197   ADS_SEARCHPREF_INFO SearchPrefs;
00198   SearchPrefs.dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
00199   SearchPrefs.vValue.dwType = ADSTYPE_INTEGER;
00200   SearchPrefs.vValue.Integer = ADS_SCOPE_SUBTREE;
00201   DWORD dwNumPrefs = 1;
00202
00203   // COL for iterations
00204   ADS_SEARCH_COLUMN col;
00205   // Handle used for searching
00206   ADS_SEARCH_HANDLE hSearch;
00207   // Set the search preference
00208
00209   hr = pSearchBase->SetSearchPreference( &SearchPrefs, dwNumPrefs);
00210   if (FAILED(hr))
00211   {
00212     delete pszSearchFilter;
00213     delete szADsPath;
00214     return hr;
00215   }
00216
00217   // Set attributes to return
00218   LPOLESTR pszAttribute[1] = {L"ADsPath"};
00219
00220   // Execute the search
00221   hr = pSearchBase->ExecuteSearch(pszSearchFilter,
00222                                     pszAttribute,
00223                 1,
00224                 &hSearch
00225                 );
00226
00227   DWORD noUsersFound = 0;
00228   if (SUCCEEDED(hr))
00229   {
00230
00231     // Call IDirectorySearch::GetNextRow() to retrieve the next row
00232     //of data
00233     while( pSearchBase->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS )
00234     {
00235
00236       if(noUsersFound>0 && ((*ppUser) != NULL))(*ppUser)->Release();
00237       wprintf(L"Found User %s.\n",szFindUser);
00238       // Get the data for this column
00239       hr = pSearchBase->GetColumn( hSearch, pszAttribute[0], &col );
00240       if ( SUCCEEDED(hr) )
00241       {
00242         // Print the data for the column and free the column
00243         // Note the attribute we asked for is type CaseIgnoreString.
00244         wcscpy(szADsPath, col.pADsValues->CaseIgnoreString);
00245         wprintf(L"%s: %s\r\n",pszAttribute[0],col.pADsValues->CaseIgnoreString);
00246         hr = ADsOpenObject(szADsPath,
00247                  NULL,
00248                  NULL,
00249                  ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00250                  IID_IADs,
00251                  (void**)ppUser);
00252         if(SUCCEEDED(hr)) noUsersFound ++;
00253
00254         pSearchBase->FreeColumn( &col );
00255       }
00256     }
00257     // Close the search handle to clean up
00258           pSearchBase->CloseSearchHandle(hSearch);
00259   }
00260
00261
00262
00263   if (noUsersFound>1)
00264   {
00265     VARIANT var;
00266     wprintf(L"---------------------------------------------------\n");
00267     wprintf(L"More than one user with CN %s was found.\n",szFindUser);
00268     (*ppUser)->Get(L"distinguishedName", &var);
00269     wprintf(L"Returning pointer to User (DN): %s\n",var.bstrVal);
00270     wprintf(L"---------------------------------------------------\n");
00271     VariantClear(&var);
00272   }
00273
00274   if(noUsersFound == 0) hr = E_FAIL;
00275
00276   delete pszSearchFilter;
00277   delete szADsPath;
00278   return hr;
00279 }
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/RemClien/RemClien.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • RemClien

RemClien.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      REMCLIEN.CPP
00003
00004   Summary:   Based largely on the APTCLIEN.EXE application code, this
00005              module is meant to use COM to load and access some COM
00006              components in a separate Remote EXE COM Server (APTSERVE
00007              located on a separate machine). Thus to run REMCLIEN you must
00008              build or copy APTSERVE on the remote machine first. Like
00009              APTCLIEN, this application composes its own native composite
00010              COM object, COUtilityCruiseCar. In this client application,
00011              COUtilityCruiseCar is constructed by containment reuse of the
00012              existing COCruiseCar COM component (provided by the
00013              APTSERVE.EXE remote server). This application augments that
00014              existing component with a native implementation of the
00015              IUtility interface.  Thus, this application illustrates
00016              object composition through containment of an existing
00017              composite object that is itself constructed via containment.
00018
00019              Also like APTCLIEN this client application separately
00020              instantiates the other car-related objects of APTSERVE on the
00021              remote machine and exercises them (ie, for Car, UtilityCar,
00022              CruiseCar, and UtilityCruiseCar).  To this end, REMCLIEN
00023              provides a set of menus for these Car related objects with
00024              choices for the respective methods of the Interfaces exposed
00025              by those COM Objects.
00026
00027              For a comprehensive tutorial code tour of REMCLIEN's
00028              contents and offerings see the tutorial REMCLIEN.HTM file.
00029              For more specific technical details on the internal workings
00030              see the comments dispersed throughout the REMCLIEN source code.
00031              For more details on the APTSERVE.EXE that REMCLIEN works with
00032              see the APTSERVE.HTM file in the main tutorial directory.
00033
00034   Classes:   CMainWindow
00035
00036   Functions: InitApplication, WinMain
00037
00038   Origin:    3-27-96: atrent - Editor-inheritance from APTCLIEN source.
00039
00040 ----------------------------------------------------------------------------
00041   This file is part of the Microsoft COM Tutorial Code Samples.
00042
00043   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00044
00045   This source code is intended only as a supplement to Microsoft
00046   Development Tools and/or on-line documentation.  See these other
00047   materials for detailed information regarding Microsoft code samples.
00048
00049   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00050   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00051   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00052   PARTICULAR PURPOSE.
00053 ==========================================================================+*/
00054
00055 /*--------------------------------------------------------------------------
00056   We include WINDOWS.H for all Win32 applications.
00057   We include OLE2.H because we will be calling the COM/OLE Libraries.
00058   We include INITGUID.H only once (here) in the entire app because we
00059     will be defining GUIDs and want them as constants in the data segment.
00060   We include COMMDLG.H because we will be using the Open File and
00061     potentially other Common dialogs.
00062   We include APPUTIL.H because we will be building this application using
00063     the convenient Virtual Window and Dialog classes and other
00064     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00065   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00066     class, GUID, and CLSID specifications.
00067   We include REMCLIEN.H because it has class and resource definitions
00068     specific to this REMCLIEN application.
00069   We include UTCRUCAR.H because it has COUtilityCar object class.
00070 ---------------------------------------------------------------------------*/
00071 #include <windows.h>
00072 #include <ole2.h>
00073 #include <initguid.h>
00074 #include <commdlg.h>
00075 #include <apputil.h>
00076 #include <micars.h>
00077 #include <carguids.h>
00078 #include "remclien.h"
00079 #include "utcrucar.h"
00080
00081
00082 // Here is a pointer for use by the global Trace Message logging macros.
00083 CMsgLog* g_pMsgLog = NULL;
00084
00085 // Here is a structure for storing the remote server info.
00086 COSERVERINFO g_ServerInfo;
00087 // Storage for the user entered remote machine name.
00088 TCHAR g_szMachineName[MAX_PATH] = TEXT("");
00089 OLECHAR g_wszMachineName[MAX_PATH];
00090
00091 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00092   Method:   CMainWindow::CMainWindow
00093
00094   Summary:  CMainWindow Constructor.
00095
00096   Args:     .
00097
00098   Modifies: .
00099
00100   Returns:  .
00101 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00102 CMainWindow::CMainWindow()
00103 {
00104   // Ensure these member variable strings are null strings.
00105   m_szFileName[0] = 0;
00106   m_szFileTitle[0] = 0;
00107
00108   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00109   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00110   m_ofnFile.hwndOwner = m_hWnd;
00111   m_ofnFile.hInstance = m_hInst;
00112   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00113   m_ofnFile.lpstrCustomFilter = NULL;
00114   m_ofnFile.nMaxCustFilter = 0;
00115   m_ofnFile.nFilterIndex = 1;
00116   m_ofnFile.lpstrFile = m_szFileName;
00117   m_ofnFile.nMaxFile = MAX_PATH;
00118   m_ofnFile.lpstrInitialDir = TEXT(".");
00119   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00120   m_ofnFile.nMaxFileTitle = MAX_PATH;
00121   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00122   m_ofnFile.lpstrDefExt = NULL;
00123   m_ofnFile.Flags = OFN_HIDEREADONLY;
00124
00125   m_pCar = NULL;
00126   m_pUtilityCar = NULL;
00127   m_pCruiseCar = NULL;
00128   m_pUtilityCruiseCar = NULL;
00129
00130   // Null the Message object pointers.
00131   m_pMsgBox = NULL;
00132   m_pMsgLog = NULL;
00133 }
00134
00135
00136 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00137   Method:   CMainWindow::~CMainWindow
00138
00139   Summary:  CMainWindow Destructor.  Destruction of the main window
00140             indicates that the application should quit and thus the
00141             PostQuitMessage API is called.
00142
00143   Args:     .
00144
00145   Modifies: .
00146
00147   Returns:  .
00148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00149 CMainWindow::~CMainWindow()
00150 {
00151   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00152   // message and causes a delete of CMainWindow which in turn causes this
00153   // destructor to run. The WM_DESTROY results when the window is destoyed
00154   // after a close of the window. Prior to exiting the main message loop:
00155
00156   // We release any and all of the pointers to instantiated COM objects.
00157   RELEASE_INTERFACE(m_pCar);
00158   RELEASE_INTERFACE(m_pUtilityCar);
00159   RELEASE_INTERFACE(m_pCruiseCar);
00160   RELEASE_INTERFACE(m_pUtilityCruiseCar);
00161
00162   // We delete the CMsgBox and CMsgLog objects that were made in
00163   // Initinstance.
00164   DELETE_POINTER(m_pMsgBox);
00165   DELETE_POINTER(m_pMsgLog);
00166
00167   // We then post a WM_QUIT message to cause an exit of the main thread's
00168   // message loop and an exit of this instance of the application.
00169   PostQuitMessage(0);
00170 }
00171
00172
00173 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00174   Method:   CMainWindow::GetInterface
00175
00176   Summary:  Convenience method that wraps the QueryInterface call
00177             and accepts a main COM object IUnknown pointer as an argument.
00178
00179   Args:     IUnknown* pObj,
00180               Pointer to the COM Object we are getting an interface on.
00181             REFIID riid,
00182               The GUID for the interface that we are seeking.
00183             PPVOID ppv);
00184               Address of the caller's pointer variable that will
00185               receive the requested interface pointer.
00186
00187   Modifies: .
00188
00189   Returns:  BOOL.
00190               TRUE if succeeded.
00191               FALSE if failed.
00192 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00193 BOOL CMainWindow::GetInterface(
00194        IUnknown* pObj,
00195        REFIID riid,
00196        PPVOID ppv)
00197 {
00198   BOOL bResult = FALSE;
00199   HRESULT hr;
00200
00201   *ppv=NULL;
00202
00203   if (NULL != pObj)
00204   {
00205     LOG("C: --Obtaining Interface Pointer.");
00206     hr = pObj->QueryInterface(riid, ppv);
00207
00208     if (FAILED(hr))
00209     {
00210       LOGERROR("C: ???? QueryInterface", hr);
00211     }
00212     else
00213     {
00214       LOGF1("C: Interface obtained. *ppv=0x%X", *ppv);
00215       bResult = TRUE;
00216     }
00217   }
00218   else
00219   {
00220     LOG("C: ???? Create an object first.");
00221   }
00222
00223   return (bResult);
00224 }
00225
00226
00227 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00228   Function: CreateRemote
00229
00230   Summary:  Creates a Remote COM object.
00231
00232   Args:     COSERVERINFO* pServerInfo
00233               Pointer to server info structure having remote machine name.
00234             REFCLSID rclsid,
00235               The class id of the object to create.
00236             PPVOID ppv
00237               Address of the caller's pointer variable that will
00238               receive the requested IUnknown interface pointer.
00239
00240   Returns:  HRESULT
00241               Standard return code.
00242 ------------------------------------------------------------------------F-F*/
00243 HRESULT CreateRemote(
00244           COSERVERINFO* pServerInfo,
00245           REFCLSID rclsid,
00246           PPVOID ppv)
00247 {
00248   HRESULT hr = E_FAIL;
00249   IClassFactory* pICF = NULL;
00250   HCURSOR hCurPrev;
00251   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00252
00253   // Ensure a remote machine name was specified by user.
00254   if (pServerInfo->pwszName[0])
00255   {
00256     // Change cursor to the hour glass.  Things could take awhile working
00257     // across the network.
00258     hCurPrev = SetCursor(hCurWait);
00259
00260     // Get the COM Object Class Factory.
00261     hr = CoGetClassObject(
00262            rclsid,
00263            CLSCTX_REMOTE_SERVER,
00264            pServerInfo,
00265            IID_IClassFactory,
00266            (PPVOID)&pICF);
00267     LOGERROR("C:CoGetClassObject.",hr);
00268     if (SUCCEEDED(hr))
00269     {
00270       // Use Class Factory to create an instance of the COM object.
00271       hr = pICF->CreateInstance(
00272                    NULL,
00273                    IID_IUnknown,
00274                    ppv);
00275       pICF->Release();
00276       LOGERROR("C:CreateInstance.",hr);
00277     }
00278
00279     // Set Cursor back to what it was.
00280     SetCursor(hCurPrev);
00281   }
00282   else
00283   {
00284     LOG("C: ???? Specify remote machine name first.");
00285   }
00286
00287   return hr;
00288 }
00289
00290
00291 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00292   Method:   CMainWindow::DoMenu
00293
00294   Summary:  Dispatch and handle the main menu commands.
00295
00296   Args:     WPARAM wParam,
00297               First message parameter (word sized).
00298             LPARAM lParam)
00299               Second message parameter (long sized).
00300
00301   Modifies: m_ofnFile, ...
00302
00303   Returns:  LRESULT
00304               Standard Windows WindowProc return value.
00305 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00306 LRESULT CMainWindow::DoMenu(
00307           WPARAM wParam,
00308           LPARAM lParam)
00309 {
00310   LRESULT lResult = FALSE;
00311   HRESULT hr;
00312   HMENU hMenu  = ::GetMenu(m_hWnd);
00313   HCURSOR hCurPrev;
00314   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00315   // Here are some interface pointers used to call methods on
00316   // our COUtilityCar, COCruiseCar, and COUtilityCruiseCar COM objects.
00317   ICar* pICar;
00318   IUtility* pIUtility;
00319   ICruise* pICruise;
00320
00321   switch (LOWORD(wParam))
00322   {
00323     //----------------------------------------------------------------------
00324     // Handle File Menu Commands.
00325     //----------------------------------------------------------------------
00326     case IDM_FILE_MACHINE:
00327       // Ask the user for the name of the machine where the remote
00328       // server is.
00329       {
00330         CDlgRemoteInfo dlgRemoteInfo;
00331
00332         dlgRemoteInfo.ShowDialog(
00333           m_hInst,
00334           MAKEINTRESOURCE(IDD_REMOTE_INFO),
00335           m_hWnd);
00336       }
00337       break;
00338     case IDM_FILE_EXIT:
00339       // The user commands us to exit this application so we tell the
00340       // Main window to close itself.
00341       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00342       break;
00343
00344     //----------------------------------------------------------------------
00345     // Handle Car Menu Commands.
00346     //----------------------------------------------------------------------
00347     case IDM_CAR_CREATE:
00348       LOG("C: === Car Menu: Create.");
00349       if (NULL == m_pCar)
00350       {
00351         // Call COM services to create a remote instance.
00352         hr = CreateRemote(
00353                &g_ServerInfo,
00354                CLSID_AptCar,
00355                (PPVOID)&m_pCar);
00356         if (SUCCEEDED(hr))
00357         {
00358           ::CheckMenuItem(
00359               hMenu,
00360               IDM_CAR_CREATE,
00361               MF_BYCOMMAND | MF_CHECKED);
00362           LOG("C: Car creation succeeded.");
00363         }
00364         else
00365           LOG("C: ???? Car creation failed.");
00366       }
00367       else
00368         LOG("C: ???? Car already exists.");
00369       break;
00370     case IDM_CAR_RELEASE:
00371       LOG("C: === Car Menu: Release.");
00372       if (NULL != m_pCar)
00373       {
00374         // Change cursor to the hour glass.
00375         hCurPrev = SetCursor(hCurWait);
00376         RELEASE_INTERFACE(m_pCar);
00377         // We ask COM to unload any unused COM Servers.
00378         CoFreeUnusedLibraries();
00379         // Set Cursor back to what it was.
00380         SetCursor(hCurPrev);
00381         ::CheckMenuItem(
00382             hMenu,
00383             IDM_CAR_CREATE,
00384             MF_BYCOMMAND | MF_UNCHECKED);
00385       }
00386       else
00387         LOG("C: ???? No Car to Release.");
00388       break;
00389     case IDM_CAR_SHIFT:
00390       LOG("C: === Car Menu: ICar::Shift");
00391       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00392       {
00393         LOG("C: --Calling pICar->Shift");
00394         pICar->Shift(1);
00395         LOG("C: --Releasing pICar");
00396         pICar->Release();
00397       }
00398       break;
00399     case IDM_CAR_CLUTCH:
00400       LOG("C: === Car Menu: ICar::Clutch");
00401       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00402       {
00403         LOG("C: --Calling pICar->Clutch");
00404         pICar->Clutch(100);
00405         LOG("C: --Releasing pICar");
00406         pICar->Release();
00407       }
00408       break;
00409     case IDM_CAR_SPEED:
00410       LOG("C: === Car Menu: ICar::Speed");
00411       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00412       {
00413         LOG("C: --Calling pICar->Speed");
00414         pICar->Speed(20);
00415         LOG("C: --Releasing pICar");
00416         pICar->Release();
00417       }
00418       break;
00419     case IDM_CAR_STEER:
00420       LOG("C: === Car Menu: ICar::Steer");
00421       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00422       {
00423         LOG("C: --Calling pICar->Steer");
00424         pICar->Steer(0);
00425         LOG("C: --Releasing pICar");
00426         pICar->Release();
00427       }
00428       break;
00429
00430     //----------------------------------------------------------------------
00431     // Handle UtilityCar Menu Commands.
00432     //----------------------------------------------------------------------
00433     case IDM_UCAR_CREATE:
00434       LOG("C: === UtilityCar Menu: Create.");
00435       if (NULL == m_pUtilityCar)
00436       {
00437         // Call COM services to create a remote instance.
00438         hr = CreateRemote(
00439                &g_ServerInfo,
00440                CLSID_AptUtilityCar,
00441                (PPVOID)&m_pUtilityCar);
00442         if (SUCCEEDED(hr))
00443         {
00444           ::CheckMenuItem(
00445               hMenu,
00446               IDM_UCAR_CREATE,
00447               MF_BYCOMMAND | MF_CHECKED);
00448           LOG("C: UtilityCar creation succeeded.");
00449         }
00450         else
00451           LOG("C: ???? UtilityCar creation failed.");
00452       }
00453       else
00454         LOG("C: ???? UtilityCar already exists.");
00455       break;
00456     case IDM_UCAR_RELEASE:
00457       LOG("C: === UtilityCar Menu: Release.");
00458       if (NULL != m_pUtilityCar)
00459       {
00460         // Change cursor to the hour glass.
00461         hCurPrev = SetCursor(hCurWait);
00462         RELEASE_INTERFACE(m_pUtilityCar);
00463         // We ask COM to unload any unused COM Servers.
00464         CoFreeUnusedLibraries();
00465         // Set Cursor back to what it was.
00466         SetCursor(hCurPrev);
00467         ::CheckMenuItem(
00468             hMenu,
00469             IDM_UCAR_CREATE,
00470             MF_BYCOMMAND | MF_UNCHECKED);
00471       }
00472       else
00473         LOG("C: ???? No UtilityCar to Release.");
00474       break;
00475     case IDM_UCAR_SHIFT:
00476       LOG("C: === UtilityCar Menu: ICar::Shift");
00477       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00478       {
00479         LOG("C: --Calling pICar->Shift");
00480         pICar->Shift(2);
00481         LOG("C: --Releasing pICar");
00482         pICar->Release();
00483       }
00484       break;
00485     case IDM_UCAR_CLUTCH:
00486       LOG("C: === UtilityCar Menu: ICar::Clutch");
00487       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00488       {
00489         LOG("C: --Calling pICar->Clutch");
00490         pICar->Clutch(100);
00491         LOG("C: --Releasing pICar");
00492         pICar->Release();
00493       }
00494       break;
00495     case IDM_UCAR_SPEED:
00496       LOG("C: === UtilityCar Menu: ICar::Speed");
00497       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00498       {
00499         LOG("C: --Calling pICar->Speed");
00500         pICar->Speed(30);
00501         LOG("C: --Releasing pICar");
00502         pICar->Release();
00503       }
00504       break;
00505     case IDM_UCAR_STEER:
00506       LOG("C: === UtilityCar Menu: ICar::Steer");
00507       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00508       {
00509         LOG("C: --Calling pICar->Steer");
00510         pICar->Steer(10);
00511         LOG("C: --Releasing pICar");
00512         pICar->Release();
00513       }
00514       break;
00515     case IDM_UCAR_OFFROAD:
00516       LOG("C: === UtilityCar Menu: IUtility::Offroad");
00517       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00518       {
00519         LOG("C: --Calling pIUtility->Offroad");
00520         pIUtility->Offroad(1);
00521         LOG("C: --Releasing pIUtility");
00522         pIUtility->Release();
00523       }
00524       break;
00525     case IDM_UCAR_WINCH:
00526       LOG("C: === UtilityCar Menu: IUtility::Winch");
00527       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00528       {
00529         LOG("C: --Calling pIUtility->Winch");
00530         pIUtility->Winch(0);
00531         LOG("C: --Releasing pIUtility");
00532         pIUtility->Release();
00533       }
00534       break;
00535
00536     //----------------------------------------------------------------------
00537     // Handle CruiseCar Menu Commands.
00538     //----------------------------------------------------------------------
00539     case IDM_CCAR_CREATE:
00540       LOG("C: === CruiseCar Menu: Create.");
00541       if (NULL == m_pCruiseCar)
00542       {
00543         // Call COM services to create a remote instance.
00544         hr = CreateRemote(
00545                &g_ServerInfo,
00546                CLSID_AptCruiseCar,
00547                (PPVOID)&m_pCruiseCar);
00548         if (SUCCEEDED(hr))
00549         {
00550           ::CheckMenuItem(
00551               hMenu,
00552               IDM_CCAR_CREATE,
00553               MF_BYCOMMAND | MF_CHECKED);
00554           LOG("C: CruiseCar creation succeeded.");
00555         }
00556         else
00557           LOG("C: ???? CruiseCar creation failed.");
00558       }
00559       else
00560         LOG("C: ???? CruiseCar already exists.");
00561       break;
00562     case IDM_CCAR_RELEASE:
00563       LOG("C: === CruiseCar Menu: Release.");
00564       if (NULL != m_pCruiseCar)
00565       {
00566         // Change cursor to the hour glass.
00567         hCurPrev = SetCursor(hCurWait);
00568         RELEASE_INTERFACE(m_pCruiseCar);
00569         // We ask COM to unload any unused COM Servers.
00570         CoFreeUnusedLibraries();
00571         // Set Cursor back to what it was.
00572         SetCursor(hCurPrev);
00573         ::CheckMenuItem(
00574             hMenu,
00575             IDM_CCAR_CREATE,
00576             MF_BYCOMMAND | MF_UNCHECKED);
00577       }
00578       else
00579         LOG("C: ???? No CruiseCar to Release.");
00580       break;
00581     case IDM_CCAR_SHIFT:
00582       LOG("C: === CruiseCar Menu: ICar::Shift");
00583       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00584       {
00585         LOG("C: --Calling pICar->Shift");
00586         pICar->Shift(4);
00587         LOG("C: --Releasing pICar");
00588         pICar->Release();
00589       }
00590       break;
00591     case IDM_CCAR_CLUTCH:
00592       LOG("C: === CruiseCar Menu: ICar::Clutch");
00593       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00594       {
00595         LOG("C: --Calling pICar->Clutch");
00596         pICar->Clutch(100);
00597         LOG("C: --Releasing pICar");
00598         pICar->Release();
00599       }
00600       break;
00601     case IDM_CCAR_SPEED:
00602       LOG("C: === CruiseCar Menu: ICar::Speed");
00603       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00604       {
00605         LOG("C: --Calling pICar->Speed");
00606         pICar->Speed(60);
00607         LOG("C: --Releasing pICar");
00608         pICar->Release();
00609       }
00610       break;
00611     case IDM_CCAR_STEER:
00612       LOG("C: === CruiseCar Menu: ICar::Steer");
00613       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00614       {
00615         LOG("C: --Calling pICar->Steer");
00616         pICar->Steer(0);
00617         LOG("C: --Releasing pICar");
00618         pICar->Release();
00619       }
00620       break;
00621     case IDM_CCAR_ENGAGE:
00622       LOG("C: === CruiseCar Menu: ICruise::Engage");
00623       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00624       {
00625         LOG("C: --Calling pICruise->Engage");
00626         pICruise->Engage(TRUE);
00627         LOG("C: --Releasing pICruise");
00628         pICruise->Release();
00629       }
00630       break;
00631     case IDM_CCAR_ADJUST:
00632       LOG("C: === CruiseCar Menu: ICruise::Adjust");
00633       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00634       {
00635         LOG("C: --Calling pICruise->Adjust");
00636         pICruise->Adjust(FALSE);
00637         LOG("C: --Releasing pICruise");
00638         pICruise->Release();
00639       }
00640       break;
00641
00642     //----------------------------------------------------------------------
00643     // Handle UtilityCruiseCar Menu Commands.
00644     //----------------------------------------------------------------------
00645     case IDM_UCRU_CREATE:
00646       LOG("C: === UtilityCruiseCar Menu: Create.");
00647       if (NULL == m_pUtilityCruiseCar)
00648       {
00649         if (g_ServerInfo.pwszName[0])
00650         {
00651           // Call a create function to create an instance.
00652           hr = CreateUtilityCruiseCar(
00653                  NULL,
00654                  IID_IUnknown,
00655                  (PPVOID)&m_pUtilityCruiseCar);
00656           if (SUCCEEDED(hr))
00657           {
00658             ::CheckMenuItem(
00659                 hMenu,
00660                 IDM_UCRU_CREATE,
00661                 MF_BYCOMMAND | MF_CHECKED);
00662           }
00663           else
00664             LOG("C: ???? UtilityCruiseCar creation failed.");
00665         }
00666         else
00667           LOG("C: ???? Specify remote machine name first.");
00668       }
00669       else
00670         LOG("C: ???? UtilityCruiseCar already exists.");
00671       break;
00672     case IDM_UCRU_RELEASE:
00673       LOG("C: === UtilityCruiseCar Menu: Release.");
00674       if (NULL != m_pUtilityCruiseCar)
00675       {
00676         // Change cursor to the hour glass.
00677         hCurPrev = SetCursor(hCurWait);
00678         RELEASE_INTERFACE(m_pUtilityCruiseCar);
00679         // We ask COM to unload any unused COM Servers.
00680         CoFreeUnusedLibraries();
00681         // Set Cursor back to what it was.
00682         SetCursor(hCurPrev);
00683         ::CheckMenuItem(
00684             hMenu,
00685             IDM_UCRU_CREATE,
00686             MF_BYCOMMAND | MF_UNCHECKED);
00687       }
00688       else
00689         LOG("C: ???? No UtilityCruiseCar to Release.");
00690       break;
00691     case IDM_UCRU_SHIFT:
00692       LOG("C: === UtilityCruiseCar Menu: ICar::Shift");
00693       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00694       {
00695         LOG("C: --Calling pICar->Shift");
00696         pICar->Shift(1);
00697         LOG("C: --Releasing pICar");
00698         pICar->Release();
00699       }
00700       break;
00701     case IDM_UCRU_CLUTCH:
00702       LOG("C: === UtilityCruiseCar Menu: ICar::Clutch");
00703       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00704       {
00705         LOG("C: --Calling pICar->Clutch");
00706         pICar->Clutch(80);
00707         LOG("C: --Releasing pICar");
00708         pICar->Release();
00709       }
00710       break;
00711     case IDM_UCRU_SPEED:
00712       LOG("C: === UtilityCruiseCar Menu: ICar::Speed");
00713       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00714       {
00715         LOG("C: --Calling pICar->Speed");
00716         pICar->Speed(10);
00717         LOG("C: --Releasing pICar");
00718         pICar->Release();
00719       }
00720       break;
00721     case IDM_UCRU_STEER:
00722       LOG("C: === UtilityCruiseCar Menu: ICar::Steer");
00723       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00724       {
00725         LOG("C: --Calling pICar->Steer");
00726         pICar->Steer(10);
00727         LOG("C: --Releasing pICar");
00728         pICar->Release();
00729       }
00730       break;
00731     case IDM_UCRU_ENGAGE:
00732       LOG("C: === UtilityCruiseCar Menu: ICruise::Engage");
00733       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00734       {
00735         LOG("C: --Calling pICruise->Engage");
00736         pICruise->Engage(FALSE);
00737         LOG("C: --Releasing pICruise");
00738         pICruise->Release();
00739       }
00740       break;
00741     case IDM_UCRU_ADJUST:
00742       LOG("C: === UtilityCruiseCar Menu: ICruise::Adjust");
00743       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00744       {
00745         LOG("C: --Calling pICruise->Adjust");
00746         pICruise->Adjust(FALSE);
00747         LOG("C: --Releasing pICruise");
00748         pICruise->Release();
00749       }
00750       break;
00751     case IDM_UCRU_OFFROAD:
00752       LOG("C: === UtilityCruiseCar Menu: IUtility::Offroad");
00753       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00754       {
00755         LOG("C: --Calling pIUtility->Offroad");
00756         pIUtility->Offroad(3);
00757         LOG("C: --Releasing pIUtility");
00758         pIUtility->Release();
00759       }
00760       break;
00761     case IDM_UCRU_WINCH:
00762       LOG("C: === UtilityCruiseCar Menu: IUtility::Winch");
00763       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00764       {
00765         LOG("C: --Calling pIUtility->Winch");
00766         pIUtility->Winch(0);
00767         LOG("C: --Releasing pIUtility");
00768         pIUtility->Release();
00769       }
00770       break;
00771
00772     //----------------------------------------------------------------------
00773     // Handle Log Menu Commands.
00774     //----------------------------------------------------------------------
00775     case IDM_LOG_LOGCLEAR:
00776       // Clear the message log.
00777       m_pMsgLog->Clear();
00778       // Use macro to log messages.
00779       LOGID(IDS_START_MESSAGE_LOG);
00780       break;
00781     case IDM_LOG_LOGGING:
00782       // Toggle the state of the Message Logging.
00783       // Toggle the checkmark indicator on the menu selection as well.
00784       {
00785         HMENU hMenu  = ::GetMenu(m_hWnd);
00786         BOOL bLogging = ::GetMenuState(
00787                             hMenu,
00788                             IDM_LOG_LOGGING,
00789                             MF_BYCOMMAND) & MF_CHECKED;
00790         if (bLogging)
00791         {
00792           m_pMsgLog->Logging(FALSE);
00793           ::CheckMenuItem(
00794               hMenu,
00795               IDM_LOG_LOGGING,
00796               MF_BYCOMMAND | MF_UNCHECKED);
00797         }
00798         else
00799         {
00800           m_pMsgLog->Logging(TRUE);
00801           ::CheckMenuItem(
00802               hMenu,
00803               IDM_LOG_LOGGING,
00804               MF_BYCOMMAND | MF_CHECKED);
00805         }
00806       }
00807       break;
00808     case IDM_LOG_COPYCLIP:
00809       // Copy trace message log to clipboard.
00810       m_pMsgLog->Copy();
00811       break;
00812
00813     //----------------------------------------------------------------------
00814     // Handle Help Menu Commands.
00815     //----------------------------------------------------------------------
00816     case IDM_HELP_CONTENTS:
00817       // We have some stubbed support here for bringing up the online
00818       // Help for this application.
00819       ReadHelp(m_hWnd, m_szHelpFile);
00820       break;
00821     case IDM_HELP_TUTORIAL:
00822       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00823       // tutorial narrative file associated with this tutorial code sample.
00824       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00825       break;
00826     case IDM_HELP_TUTSERVER:
00827       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00828       // tutorial narrative file associated with the APTSERVE COM server.
00829       ReadTutorial(m_hInst, m_hWnd, TEXT(SERVER_TUTFILE_STR));
00830       break;
00831     case IDM_HELP_TUTMARSHAL:
00832       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00833       // tutorial narrative file associated with the COM marshaling server.
00834       ReadTutorial(m_hInst, m_hWnd, TEXT(MARSHAL_TUTFILE_STR));
00835       break;
00836     case IDM_HELP_READSOURCE:
00837       // Call the APPUTIL utility function ReadSource to allow the
00838       // user to open and read any of the source files of REMCLIEN.
00839       ReadSource(m_hWnd, &m_ofnFile);
00840       break;
00841     case IDM_HELP_ABOUT:
00842       {
00843         CAboutBox dlgAboutBox;
00844
00845         LOG("C: === Help Menu: About REMCLIEN.");
00846         // Show the standard About Box dialog for this EXE by telling the
00847         // dialog C++ object to show itself by invoking its ShowDialog
00848         // method.  Pass it this EXE instance and the parent window handle.
00849         // Use a dialog resource ID for the dialog template stored in
00850         // this EXE module's resources.
00851         dlgAboutBox.ShowDialog(
00852           m_hInst,
00853           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00854           m_hWnd);
00855       }
00856       break;
00857
00858     default:
00859       // Defer all messages NOT handled here to the Default Window Proc.
00860       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00861       break;
00862   }
00863
00864   return(lResult);
00865 }
00866
00867
00868 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00869   Method:   CMainWindow::InitInstance
00870
00871   Summary:  Instantiates an instance of the main application window.
00872             This method must be called only once, immediately after
00873             window class construction.  We take care to delete 'this'
00874             CMainWindow if we must return the error condition FALSE.
00875
00876   Args:     HINSTANCE hInstance,
00877               Handle of the application instance.
00878             int nCmdShow)
00879               Command to pass to ShowWindow.
00880
00881   Modifies: m_szHelpFile, m_pMsgBox, m_pMsgLog.
00882
00883   Returns:  BOOL.
00884               TRUE if succeeded.
00885               FALSE if failed.
00886 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00887 BOOL CMainWindow::InitInstance(
00888        HINSTANCE hInstance,
00889        int nCmdShow)
00890 {
00891   BOOL bOk = FALSE;
00892   HWND hWnd;
00893
00894   // Create the Message Box and Message Log objects.
00895   m_pMsgBox = new CMsgBox;
00896   m_pMsgLog = new CMsgLog;
00897
00898   if (NULL != m_pMsgBox && NULL != m_pMsgLog)
00899   {
00900     // Note, the Create method sets the m_hWnd member so we don't
00901     // need to set it explicitly here first.
00902
00903     // Here is the create of this window.  Size the window reasonably.
00904     // Create sets both m_hInst and m_hWnd.
00905     hWnd = Create(
00906              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00907              TEXT(MAIN_WINDOW_TITLE_STR),
00908              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00909                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00910              CW_USEDEFAULT,
00911              CW_USEDEFAULT,
00912              ::GetSystemMetrics(SM_CXSCREEN)*3/5,
00913              ::GetSystemMetrics(SM_CYSCREEN)*3/5,
00914              NULL,
00915              NULL,
00916              hInstance);
00917     if (hWnd)
00918     {
00919       // Ensure the new window is shown on screen and its content is painted.
00920       ::ShowWindow(m_hWnd, nCmdShow);
00921       ::UpdateWindow(m_hWnd);
00922
00923       // Build a path to where the help file should be (it should be in
00924       // the same directory as the .EXE but with the .HTM extension.
00925       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00926
00927       // Init the Message Box object.
00928       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00929       {
00930         // Create the Trace Message Log ListBox as a child window that
00931         // fits the client area of the Main Window (the TRUE 3rd argument
00932         // specifies such an inside child). If you want the Trace Message
00933         // Log in a separate (but owned) window, then pass a FALSE instead
00934         // for the 3rd argument.
00935         if (m_pMsgLog->Create(m_hInst, m_hWnd, TRUE))
00936         {
00937           // Assign the global MsgLog pointer.
00938           g_pMsgLog = m_pMsgLog;
00939           // Use macro to log an initial start messsage.
00940           LOGID(IDS_START_MESSAGE_LOG);
00941           bOk = TRUE;
00942         }
00943       }
00944     }
00945   }
00946
00947   if (!bOk)
00948   {
00949     DELETE_POINTER(m_pMsgBox);
00950     DELETE_POINTER(m_pMsgLog);
00951   }
00952
00953   return (bOk);
00954 }
00955
00956
00957 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00958   Method:   CDlgRemoteInfo::DialogProc
00959
00960   Summary:  Dialog proc for the Remote Info dialog box.  This DialogProc
00961             method definition overrides the same-named pure virtual
00962             function in abstract base class CVirDialog thus giving unique
00963             message dispatching behavior to this derivation of CVirDialog.
00964             The remaining behavior of CDlgRemoteInfo is inherited from
00965             CVirDialog and is common to all CVirDialogs.
00966
00967   Args:     HWND hWndDlg,
00968               Handle to the dialog.
00969             UINT uMsg,
00970               Windows message to dialog.
00971             WPARAM wParam,
00972               First message parameter (word sized).
00973             LPARAM lParam)
00974               Second message parameter (long sized).
00975
00976   Modifies: .
00977
00978   Returns:  BOOL.  TRUE if message was handled; FALSE otherwise.
00979 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00980 BOOL CDlgRemoteInfo::DialogProc(
00981        HWND hWndDlg,
00982        UINT uMsg,
00983        WPARAM wParam,
00984        LPARAM lParam)
00985 {
00986   BOOL bResult = TRUE;
00987   HWND hCtrl = GetDlgItem(hWndDlg, IDC_EDIT_MACHINE);
00988
00989   switch (uMsg)
00990   {
00991     case WM_INITDIALOG:
00992       SetDlgItemText(hWndDlg, IDC_EDIT_MACHINE, g_szMachineName);
00993       SetFocus(hCtrl);
00994       bResult = FALSE;
00995       break;
00996
00997     case WM_COMMAND:
00998       {
00999         WORD wCmd = LOWORD(wParam);
01000
01001         if (wCmd == IDOK)
01002         {
01003           // Obtain the machine name from the edit control.
01004           GetDlgItemText(hWndDlg, IDC_EDIT_MACHINE, g_szMachineName, MAX_PATH);
01005 #if !defined(UNICODE)
01006           // Convert to WideChar Unicode if we are NOT compiled for Unicode.
01007           AnsiToUc(g_szMachineName, g_wszMachineName, MAX_PATH);
01008 #endif
01009           ::EndDialog(hWndDlg, TRUE);
01010         }
01011         else if (wCmd == IDCANCEL)
01012           ::EndDialog(hWndDlg, TRUE);
01013       }
01014       break;
01015
01016     default:
01017       bResult = FALSE;
01018       break;
01019   }
01020
01021   return(bResult);
01022 }
01023
01024
01025 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01026   Method:   CMainWindow::WindowProc
01027
01028   Summary:  Main window procedure for this window object.  See CVirWindow
01029             in the APPUTIL library (APPUTIL.CPP) for details on how this
01030             method gets called by the global WindowProc.
01031
01032   Args:     UINT uMsg,
01033               Windows message that is "sent" to this window.
01034             WPARAM wParam,
01035               First message parameter (word sized).
01036             LPARAM lParam)
01037               Second message parameter (long sized).
01038
01039   Modifies: ...
01040
01041   Returns:  LRESULT
01042               Standard Windows WindowProc return value.
01043 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01044 LRESULT CMainWindow::WindowProc(
01045           UINT uMsg,
01046           WPARAM wParam,
01047           LPARAM lParam)
01048 {
01049   LRESULT lResult = FALSE;
01050
01051   switch (uMsg)
01052   {
01053     case WM_CREATE:
01054       {
01055         // Setup for painting text in this window.
01056         HDC hdc = GetDC(m_hWnd);
01057         ::GetTextMetrics(hdc, &m_tm);
01058         ::ReleaseDC(m_hWnd, hdc);
01059       }
01060       break;
01061
01062     case WM_MEASUREITEM:
01063       // Get setup for painting text in this window.
01064       {
01065         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
01066         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
01067         lpmis->itemWidth = m_wWidth;
01068         lResult = TRUE;
01069       }
01070
01071     case WM_SIZE:
01072       // Handle a resize of this window.
01073       m_wWidth = LOWORD(lParam);
01074       m_wHeight = HIWORD(lParam);
01075       // Resize the Message Log ListBox
01076       m_pMsgLog->Resize(m_wWidth, m_wHeight);
01077       break;
01078
01079     case WM_COMMAND:
01080       // Dispatch and handle any Menu command messages received.
01081       lResult = DoMenu(wParam, lParam);
01082       break;
01083
01084     case WM_COPYDATA:
01085       // We have been sent a trace log message from a server.
01086       // Log it to our own Client's display.
01087       {
01088         LPTSTR pszMsg = (LPTSTR)((COPYDATASTRUCT*)lParam)->lpData;
01089         g_pMsgLog->Msg(pszMsg);
01090       }
01091       break;
01092
01093     case WM_CLOSE:
01094       // The user selected Close on the main window's System menu
01095       // or Exit on the File menu.
01096     case WM_QUIT:
01097       // If the app is being quit then close any associated help windows.
01098     default:
01099       // Defer all messages NOT handled here to the Default Window Proc.
01100       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
01101       break;
01102   }
01103
01104   return(lResult);
01105 }
01106
01107
01108 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01109   Function: UnicodeOk
01110
01111   Summary:  Checks if the platform will handle unicode versions of
01112             Win32 string API calls.
01113
01114   Args:     void
01115
01116   Returns:  BOOL
01117               TRUE if unicode support; FALSE if not.
01118 ------------------------------------------------------------------------F-F*/
01119 BOOL UnicodeOk(void)
01120 {
01121   BOOL bOk = TRUE;
01122   TCHAR szUserName[MAX_STRING_LENGTH];
01123   DWORD dwSize = MAX_STRING_LENGTH;
01124
01125   if (!GetUserName(szUserName, &dwSize))
01126     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
01127
01128   return bOk;
01129 }
01130
01131
01132 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01133   Function: InitApplication
01134
01135   Summary:  Initializes the application and registers its main window
01136             class. InitApplication is called only once (in WinMain).
01137
01138   Args:     HINSTANCE hInstance)
01139               Handle to the first instance of the application.
01140
01141   Returns:  BOOL.
01142               TRUE if success.
01143               FALSE if fail.
01144 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01145 BOOL InitApplication(
01146        HINSTANCE hInstance)
01147 {
01148   BOOL bOk;
01149   // The window class for all instances of the main frame window.
01150   WNDCLASSEX wcf;
01151
01152   // Assign the appropriate values for this main frame window class.
01153   wcf.cbSize        = sizeof(WNDCLASSEX);
01154   wcf.cbClsExtra    = 0;            // No per-class extra data.
01155   wcf.cbWndExtra    = 0;            // No per-window extra data.
01156   wcf.hInstance     = hInstance;    // Application module instance.
01157   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
01158                                     // APPUTIL for all CVirWindows).
01159   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
01160   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
01161                                 hInstance,
01162                                 TEXT("AppIcon"));
01163   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
01164                                 hInstance,
01165                                 TEXT("AppIcon"),
01166                                 IMAGE_ICON,
01167                                 16, 16,
01168                                 0);
01169   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
01170   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
01171   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
01172   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
01173
01174   // Register the window class and return FALSE if unsuccesful.
01175   bOk = RegisterClassEx(&wcf);
01176
01177   // Zero the g_ServerInfo structure.
01178   memset(&g_ServerInfo, 0, sizeof(COSERVERINFO));
01179
01180   // Init the remote machine name.
01181   g_wszMachineName[0] = 0;
01182 #ifdef UNICODE
01183   g_ServerInfo.pwszName = &g_szMachineName[0];
01184 #else
01185   g_ServerInfo.pwszName = &g_wszMachineName[0];
01186 #endif
01187
01188   return (bOk);
01189 }
01190
01191
01192 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01193   Function: WinMain
01194
01195   Summary:  The Windows main entry point function for this application.
01196             Initializes the application, the COM Libraries, and starts
01197             the main application message loop.
01198
01199   Args:     HINSTANCE hInstance,
01200               Instance handle; a new one for each invocation of this app.
01201             HINSTANCE hPrevInstance,
01202               Instance handle of the previous instance. NULL in Win32.
01203             LPSTR lpCmdLine,
01204               Windows passes a pointer to the application's
01205               invocation command line.
01206             int nCmdShow)
01207               Bits telling the show state of the application.
01208
01209   Returns:  int
01210               msg.wParam (upon exit of message loop).
01211               FALSE if this instance couldn't initialize and run.
01212 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01213 extern "C" int PASCAL WinMain(
01214                         HINSTANCE hInstance,
01215                         HINSTANCE hPrevInstance,
01216                         LPSTR lpCmdLine,
01217                         int nCmdShow)
01218 {
01219   CMainWindow* pWin = NULL;
01220   MSG msg;
01221   HACCEL hAccel;
01222   int iRun = FALSE;
01223
01224   // If we were compiled for UNICODE and the platform seems OK with this
01225   // then proceed.  Else we error and exit the app.
01226   if (UnicodeOk())
01227   {
01228     // Call to initialize the COM Library.  Use the SUCCEEDED macro
01229     // to detect success.  If fail then exit app with error message.
01230     if (SUCCEEDED(CoInitialize(NULL)))
01231     {
01232       // Ensure that DCOM (Distributed COM) is installed.
01233       if (DComOk())
01234       {
01235         // If we succeeded in initializing the COM Library and confirming
01236         // adequate DCOM support, we proceed to initialize the
01237         // application.  If we can't init the application then we signal
01238         // shut down with an error message exit.
01239         iRun = InitApplication(hInstance);
01240         if (iRun)
01241         {
01242           // Assume we'll set iRun to TRUE when initialization is done.
01243           iRun = FALSE;
01244           // We are still go for running so we try to create a nifty new
01245           // CMainWindow object for this app instance.
01246           pWin = new CMainWindow;
01247           if (NULL != pWin)
01248           {
01249             // Now we initialize an instance of the new CMainWindow.
01250             // This includes creating the main window.
01251             if (pWin->InitInstance(hInstance, nCmdShow))
01252             {
01253               // Load the keyboard accelerators from the resources.
01254               hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
01255               if (NULL != hAccel)
01256               {
01257                 // Signal App Initialization is successfully done.
01258                 iRun = TRUE;
01259               }
01260             }
01261           }
01262         }
01263
01264         if (iRun)
01265         {
01266           // If we initialized the app instance properly then we are still
01267           // go for running.  We then start up the main message pump for
01268           // the application.
01269           while (GetMessage(&msg, NULL, 0, 0))
01270           {
01271             if (!TranslateAccelerator(
01272                    pWin->GetHwnd(),
01273                    hAccel,
01274                    &msg))
01275             {
01276               TranslateMessage(&msg);
01277               DispatchMessage(&msg);
01278             }
01279           }
01280
01281           // We ask COM to unload any unused COM Servers.
01282           CoFreeUnusedLibraries();
01283
01284           // We'll pass to Windows the reason why we exited the message loop.
01285           iRun = (int) msg.wParam;
01286         }
01287         else
01288         {
01289           // We failed to initialize the application. Put up error message
01290           // box saying that application couldn't be initialized.  Parent
01291           // window is desktop (ie, NULL). Exit the failed application
01292           // (ie, by returning FALSE to WinMain).
01293           ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
01294
01295           // Delete the CMainWindow object.
01296           DELETE_POINTER(pWin);
01297         }
01298
01299         // We're exiting this app (either normally or by init failure) so
01300         // shut down the COM Library.
01301         CoUninitialize();
01302       }
01303       else
01304       {
01305         // If DCOM is not installed indicate an error and
01306         // exit the app immediately.
01307         ErrorBox(hInstance, NULL, IDS_NODCOM);
01308       }
01309     }
01310     else
01311     {
01312       // We failed to Initialize the COM Library. Put up error message
01313       // box saying that COM Library couldn't be initialized.  Parent
01314       // window is desktop (ie, NULL). Exit the failed application
01315       // (ie, by returning FALSE to WinMain).
01316       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
01317     }
01318   }
01319   else
01320   {
01321     // If we were compiled for UNICODE but the platform has problems with
01322     // this then indicate an error and exit the app immediately.
01323     CHAR szMsg[MAX_STRING_LENGTH];
01324
01325     if (LoadStringA(
01326           hInstance,
01327           IDS_NOUNICODE,
01328           szMsg,
01329           MAX_STRING_LENGTH))
01330     {
01331       MessageBoxA(
01332         NULL,
01333         szMsg,
01334         ERROR_TITLE_STR,
01335         MB_OK | MB_ICONEXCLAMATION);
01336     }
01337   }
01338
01339   return iRun;
01340 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDataAccess Member List

This is the complete list of members for CDataAccess, including all inherited members.
Abort(HCHAPTER hChapter, DBASYNCHOP eOperation) | CAsynchBase | [virtual]
AddRefAccessor(HACCESSOR hAccessor) | CDataAccess | [virtual]
AdviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
AutoQI(DWORD dwCreateOpts) | CDataAccess | [virtual]
AutoRelease() | CDataAccess | [virtual]
CAsynchBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CAsynchBase |
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CContainerBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CContainerBase |
CDataAccess(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CDataAccess |
CreateAccessor(DBACCESSORFLAGS dwAccessorFlags, DBCOUNTITEM cBindings, const DBBINDING *rgBindings, DBLENGTH cRowSize, HACCESSOR *phAccessor) | CDataAccess | [virtual]
CreateAccessors(BINDCOLS eBindCols) | CDataAccess | [virtual]
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
DisplayObject() | CBase | [virtual]
FindConnectionPoint(REFIID riid, IConnectionPoint **ppIConnectionPoint) | CContainerBase | [virtual]
GetBaseType() | CBase | [inline]
GetColInfo() | CDataAccess | [virtual]
GetColInfo(DBORDINAL *pcColumns, DBCOLUMNINFO **prgColumnInfo, WCHAR **ppStringBuffer, DBORDINAL *pcHiddenColumns) | CDataAccess | [virtual]
GetColumnData(const DBBINDING *pBinding, void *pData, DBSTATUS *pdbStatus, DBLENGTH *pdbLength, DBTYPE *pwSubType, WCHAR *pwszValue, ULONG ulMaxSize, DWORD dwFlags, DBTYPE wBackendType) | CDataAccess | [virtual]
GetColumnImage(const DBCOLUMNINFO *pColInfo, DBSTATUS dbStatus=DBSTATUS_S_OK) | CDataAccess | [virtual]
GetColumnsRowset(CAggregate *pCAggregate, bool fOptColumns, REFIID riid, ULONG cPropSets, DBPROPSET *rgPropSets, IUnknown **ppIUnknown) | CDataAccess | [virtual]
GetDefaultInterface()=0 | CBase | [pure virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CDataAccess | [virtual]
GetObjectDesc() | CBase | [inline, virtual]
GetObjectImage()=0 | CBase | [pure virtual]
GetObjectMenu()=0 | CBase | [pure virtual]
GetObjectName()=0 | CBase | [pure virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetParent(SOURCE eSource) | CBase | [virtual]
GetStatus(HCHAPTER hChapter, DBASYNCHOP eOperation, DBCOUNTITEM *pulProgress, DBCOUNTITEM *pulProgressMax, DBASYNCHPHASE *peAsynchPhase, LPOLESTR *ppwszStatusText) | CAsynchBase | [virtual]
Initialize() | CAsynchBase | [virtual]
IsInitialized() | CAsynchBase | [inline, virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_Bindings | CDataAccess |
m_bSchemaRowset | CDataAccess |
m_cbRowSize | CDataAccess |
m_ColumnInfo | CDataAccess |
m_cRef | CBase | [protected]
m_dwCLSCTX | CBase |
m_dwCookieAsynchNotify | CAsynchBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_fInitialized | CAsynchBase |
m_guidSource | CBase |
m_hAccessor | CDataAccess |
m_hBmkAccessor | CDataAccess |
m_hTreeItem | CBase |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pData | CDataAccess |
m_pIAccessor | CDataAccess |
m_pIAggregate | CBase |
m_pIColumnsInfo | CDataAccess |
m_pIColumnsRowset | CDataAccess |
m_pIConnectionPointContainer | CContainerBase |
m_pIConvertType | CDataAccess |
m_pIDBAsynchStatus | CAsynchBase |
m_pIDBInitialize | CAsynchBase |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_strObjectDesc | CBase | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseAccessor(HACCESSOR *phAccessor, BOOL fReleaseAlways=FALSE) | CDataAccess | [virtual]
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetColumnData(const DBBINDING *pBinding, void *pData, DBSTATUS dbStatus, DBLENGTH dbLength, WCHAR *pwszValue, DWORD dwFlags, DBTYPE wBackendType) | CDataAccess | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
SetupBindings(BINDCOLS eBindCols, DBCOUNTITEM *cBindings, DBBINDING **prgBindings, DBLENGTH *pcRowSize=NULL) | CDataAccess | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
UnadviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
Uninitialize() | CAsynchBase | [virtual]
ValidateAccessor(HACCESSOR hAccessor, ULONG ulRefCount=1) | CDataAccess | [virtual]
~CAsynchBase() | CAsynchBase | [virtual]
~CBase() | CBase | [virtual]
~CContainerBase() | CContainerBase | [virtual]
~CDataAccess() | CDataAccess | [virtual]
Generated on Wed Nov 13 2024 16:55:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step2/StdAfx.cpp Source File

  • NetDS
  • upnp
  • StepByStep
  • Step2

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/STAObject/StdAfx.h Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • STAObject

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__B2D88631_F391_11D2_A10A_0080C71F306F__INCLUDED_)
00006 #define AFX_STDAFX_H__B2D88631_F391_11D2_A10A_0080C71F306F__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__B2D88631_F391_11D2_A10A_0080C71F306F__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/wizard.h Source File

  • Dataaccess
  • oledb
  • tablecopy

wizard.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module WIZARD.H
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 #ifndef _WIZARD_H_
00012 #define _WIZARD_H_
00013
00014 /////////////////////////////////////////////////////////////////////
00015 // Includes
00016 //
00017 /////////////////////////////////////////////////////////////////////
00018 #include "winmain.h"
00019 #include "Table.h"
00020
00021
00022 /////////////////////////////////////////////////////////////////
00023 // Defines
00024 //
00025 /////////////////////////////////////////////////////////////////
00026 enum WIZ_STEP
00027 {
00028   WIZ_STEP1 = 0,
00029   WIZ_STEP2 = 1,
00030   WIZ_STEP3 = 2,
00031   WIZ_STEP4 = 3,
00032   WIZ_TYPES = 4,
00033   END_WIZ   = 5
00034 };
00035
00036 struct TREEINFO
00037 {
00038   ULONG ulIndex;
00039   HTREEITEM hParent;
00040   HTREEITEM hItem;
00041 };
00042
00043
00044 /////////////////////////////////////////////////////////////////
00045 // Forward Declarations
00046 //
00047 /////////////////////////////////////////////////////////////////
00048 class CTableCopy;
00049 class CDataSource;
00050 class CProgress;
00051
00052
00053 /////////////////////////////////////////////////////////////////////
00054 // CDialogBase
00055 //
00056 /////////////////////////////////////////////////////////////////////
00057 class CDialogBase
00058 {
00059 public:
00060   //constructors
00061   CDialogBase(HWND hWnd, HINSTANCE hInst);
00062   virtual ~CDialogBase();
00063
00064   //members
00065   virtual ULONG Display() = 0;
00066   virtual ULONG Destroy();
00067
00068   //Data
00069   HWND    m_hWnd;
00070   HINSTANCE m_hInst;
00071 };
00072
00073
00074 /////////////////////////////////////////////////////////////////////
00075 // CS1Dialog
00076 //
00077 /////////////////////////////////////////////////////////////////////
00078 class CS1Dialog : public CDialogBase
00079 {
00080 public:
00081   //constructors
00082   CS1Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pTableCopy);
00083   virtual ~CS1Dialog();
00084
00085   //abstract members
00086   static BOOL WINAPI DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00087   virtual ULONG Display();
00088
00089   //members
00090   virtual BOOL InitControls();
00091   virtual BOOL RefreshControls();
00092
00093   virtual BOOL ResetTableList(HWND hWndTable, HWND hWndCol);
00094   virtual BOOL ChangeTableName(LONG iIndex);
00095
00096   virtual BOOL ResetColInfo(HWND hWndCol);
00097   virtual BOOL GetTableColInfo(HWND hWndCol);
00098   virtual BOOL CreateTableNode(TREEINFO* rgTreeInfo, ULONG ulNameOffset, LONG iParam = 0, LONG iImage = 0, LONG iSelectedImage = 0);
00099
00100   //Data
00101   CTableCopy* m_pCTableCopy;
00102   BOOL    m_fEditing;
00103
00104   ULONG   m_cTables;
00105   TABLEINFO*  m_rgTableInfo;
00106 };
00107
00108
00109 /////////////////////////////////////////////////////////////////////
00110 // CS2Dialog
00111 //
00112 /////////////////////////////////////////////////////////////////////
00113 class CS2Dialog : public CDialogBase
00114 {
00115 public:
00116   //constructors
00117   CS2Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pTableCopy);
00118   virtual ~CS2Dialog();
00119
00120   //abstract members
00121   static BOOL WINAPI DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00122   virtual ULONG Display();
00123
00124   //members
00125   virtual BOOL InitControls();
00126   virtual BOOL RefreshControls();
00127
00128   virtual BOOL GetPrimaryKeys();
00129
00130   virtual BOOL ResetIndexList(HWND hWnd);
00131   virtual BOOL RecordSelectedIndexes(HWND hWnd);
00132
00133   //Data
00134   CTableCopy* m_pCTableCopy;
00135 };
00136
00137
00138
00139 /////////////////////////////////////////////////////////////////////
00140 // CS3Dialog
00141 //
00142 /////////////////////////////////////////////////////////////////////
00143 class CS3Dialog : public CDialogBase
00144 {
00145 public:
00146   //constructors
00147   CS3Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pTableCopy);
00148   virtual ~CS3Dialog();
00149
00150   //abstract members
00151   static BOOL WINAPI DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00152   virtual ULONG Display();
00153
00154   //members
00155   virtual BOOL InitControls();
00156   virtual BOOL RefreshControls();
00157
00158   virtual BOOL Connect(CDataSource* pCDataSource = NULL);
00159   virtual BOOL EnableTable();
00160
00161   //Data
00162   CTableCopy* m_pCTableCopy;
00163 };
00164
00165
00166 /////////////////////////////////////////////////////////////////////
00167 // CS4Dialog
00168 //
00169 /////////////////////////////////////////////////////////////////////
00170 class CS4Dialog : public CDialogBase
00171 {
00172 public:
00173   //constructors
00174   CS4Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pTableCopy);
00175   virtual ~CS4Dialog();
00176
00177   //abstract members
00178   static BOOL WINAPI DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00179   virtual ULONG Display();
00180
00181   //members
00182   virtual BOOL InitControls();
00183   virtual BOOL RefreshControls();
00184
00185   //Data
00186   CTableCopy* m_pCTableCopy;
00187 };
00188
00189
00190 /////////////////////////////////////////////////////////////////////
00191 // CTypesDialog
00192 //
00193 /////////////////////////////////////////////////////////////////////
00194 class CTypesDialog : public CDialogBase
00195 {
00196 public:
00197   //constructors
00198   CTypesDialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pTableCopy);
00199   virtual ~CTypesDialog();
00200
00201   //abstract members
00202   static BOOL WINAPI DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00203   virtual ULONG Display();
00204
00205   //members
00206   virtual BOOL InitControls();
00207   virtual BOOL RefreshControls();
00208
00209   virtual BOOL ResetTypeLists();
00210
00211   //Data
00212   CTableCopy* m_pCTableCopy;
00213 };
00214
00215
00216 /////////////////////////////////////////////////////////////////////
00217 // CWizard
00218 //
00219 /////////////////////////////////////////////////////////////////////
00220 class CWizard : public CDialogBase
00221 {
00222 public:
00223   //Constructors
00224   CWizard(HWND hWnd, HINSTANCE hInst);
00225   virtual ~CWizard();
00226
00227   //Members
00228   virtual ULONG Display();
00229   virtual ULONG DisplayStep(ULONG iStep);
00230   virtual ULONG DestroyPrevStep(ULONG iCurStep);
00231
00232   //Data
00233   CTableCopy* m_pCTableCopy;
00234   CProgress*  m_pCProgress;
00235
00236   ULONG   m_iPrevStep;
00237   CDialogBase*  m_rgDialogSteps[END_WIZ];
00238 };
00239
00240
00241
00242 #endif  //_WIZARD_H_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MSV1_0_INTERACTIVE_LOGON Member List

This is the complete list of members for _MSV1_0_INTERACTIVE_LOGON, including all inherited members.
LogonDomainName | _MSV1_0_INTERACTIVE_LOGON
MessageType | _MSV1_0_INTERACTIVE_LOGON
Password | _MSV1_0_INTERACTIVE_LOGON
UserName | _MSV1_0_INTERACTIVE_LOGON
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/simple/Ioctl.c Source File

  • NetDS
  • WinSock
  • simple

Ioctl.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 * ioctl.c - TCP server
00003 *
00004 *       This is a part of the Microsoft Source Code Samples.
00005 *       Copyright 1996 - 2000 Microsoft Corporation.
00006 *       All rights reserved.
00007 *       This source code is only intended as a supplement to
00008 *       Microsoft Development Tools and/or WinHelp documentation.
00009 *       See these sources for detailed information regarding the
00010 *       Microsoft samples programs.
00011 \******************************************************************************/
00012 #ifdef _IA64_
00013 #pragma warning(disable:4127)
00014 #endif
00015
00016 #ifndef WIN32_LEAN_AND_MEAN
00017 #define WIN32_LEAN_AND_MEAN
00018 #endif
00019
00020 #include <winsock2.h>
00021 #include <ws2tcpip.h>
00022 #include <wspiapi.h>
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026
00027 #define DEFAULT_PORT        "5001"          // Default port for server
00028 #define DEFAULT_BUFFER_LEN  4096            // Default send/recv buffer length
00029
00030 //
00031 // Function Prototypes
00032 //
00033 void FreeSocket(SOCKET s, int rc);
00034
00035 //
00036 // Function: Usage
00037 //
00038 // Description
00039 //    Display usage information and exit.
00040 //
00041 void Usage(char *progname)
00042 {
00043   fprintf(stderr, "Usage\n%s -e [endpoint] -i [interface] [-4] [-6]\n"
00044                   "Where:\n"
00045                     "\t-e endpoint   - is the port to listen on\n"
00046                   "\t-i interface  - is the local string address to bind to\n"
00047                     "\t-4            - force IPv4\n"
00048                     "\t-6            - force IPv6\n"
00049                     "\n"
00050                   "Defaults are 5001 and INADDR_ANY and IN6ADDR_ANY (if IPv6 present)\n",
00051                     progname
00052                     );
00053   WSACleanup();
00054   exit(1);
00055 }
00056
00057 //
00058 // Function: main
00059 //
00060 // Description:
00061 //    Parse the command line and set up a TCP server. This sample creates one
00062 //    listening socket for each resolved address returned and marks the socket
00063 //    non-blocking. It then adds each listening socket to the read FD_SET to
00064 //    await incoming connections. Once a client connection is established,
00065 //    data is received and written on that connection. After the client connection
00066 //    is finished, the listening sockets are added back (i.e. the sample only
00067 //    handles one client at a time). This sample simply illustrates the select
00068 //    function. A more scalable implementation would have to handle a list
00069 //    of connected client sockets and handle them accordingly. See the Accept
00070 //    Winsock sample for an example.
00071 //
00072 int __cdecl main(int argc, char **argv)
00073 {
00074     struct addrinfo hints,
00075                    *results = NULL,
00076                    *addrptr = NULL;
00077     SOCKADDR_STORAGE client;
00078
00079     WSADATA       wsaData;
00080     SOCKET       *server_sockets = NULL,
00081                   client_socket = INVALID_SOCKET;
00082     DWORD         optval = 1;
00083     char          buffer[DEFAULT_BUFFER_LEN],
00084                   hoststr[NI_MAXHOST],
00085                   servstr[NI_MAXSERV],
00086                  *pbuffer = NULL,
00087                  *interface = NULL,
00088                  *port = DEFAULT_PORT;
00089     int           address_family = AF_UNSPEC,
00090                   socket_count=0,
00091                   clientlen,
00092                   bytesread=0,
00093                   retval,
00094                   err,
00095                   i;
00096     struct fd_set readfds,
00097                   writefds;
00098
00099     // Parse the command line
00100     for(i=1;i <argc;i++)
00101     {
00102         if ( (strlen(argv[i]) == 2) && ( (argv[i][0] == '-') || (argv[i][0] == '/') ) )
00103         {
00104             switch(tolower(argv[i][1]))
00105             {
00106                 case '4':           // Force IPv4
00107                     address_family = AF_INET;
00108                     break;
00109
00110                 case '6':           // Force IPv6
00111                     address_family = AF_INET6;
00112                     break;
00113
00114                 case 'i':           // Local interface to bind to
00115                     interface = argv[++i];
00116                     break;
00117
00118                 case 'e':           // Local port to bind to
00119                     port = argv[++i];
00120                     break;
00121
00122                 default:
00123                     Usage(argv[0]);
00124                     break;
00125             }
00126         }
00127         else
00128             Usage(argv[0]);
00129     }
00130
00131     // Load Winsock
00132     if ((retval = WSAStartup(MAKEWORD(2,2), &wsaData)) != 0)
00133     {
00134         fprintf(stderr, "WSAStartup failed with error %d\n", retval);
00135         WSACleanup();
00136         return -1;
00137     }
00138
00139     // Make sure the wildcard port wasn't specified
00140     if ( _strnicmp(port, "0", 1) == 0 )
00141         Usage(argv[0]);
00142
00143     // setup the hints structure for name resolution
00144     memset(&hints, 0, sizeof(hints));
00145     hints.ai_family = address_family;
00146     hints.ai_protocol = IPPROTO_TCP;
00147     hints.ai_socktype = SOCK_STREAM;
00148     hints.ai_flags = ((interface == NULL) ? AI_PASSIVE : 0);
00149
00150     // Resolve the address to bind to. If AF_UNSPEC was specified, interface is NULL,
00151     //    and IPv6 is installed, this call will return two addresses: 0.0.0.0 and ::
00152     retval = getaddrinfo(
00153             interface,
00154             port,
00155            &hints,
00156            &results
00157             );
00158     if (retval != 0)
00159     {
00160         fprintf(stderr, "getaddrinfo failed: %d\n", retval);
00161         goto cleanup;
00162     }
00163
00164     // Make sure the list is non-NULL
00165     if (results == NULL)
00166     {
00167         fprintf(stderr, "Unable to resolve interface %s\n", interface);
00168         goto cleanup;
00169     }
00170
00171     // Count how many address were returned
00172     socket_count = 0;
00173     addrptr = results;
00174     while (addrptr)
00175     {
00176         socket_count++;
00177         addrptr = addrptr->ai_next;
00178     }
00179
00180     // Allocate the server sockets
00181     server_sockets = (SOCKET *)HeapAlloc(
00182             GetProcessHeap(),
00183             HEAP_ZERO_MEMORY,
00184             sizeof(SOCKET) * socket_count
00185             );
00186     if (server_sockets == NULL)
00187     {
00188         fprintf(stderr, "HeapAlloc failed: %d\n", GetLastError());
00189         return -1;
00190     }
00191
00192     // Initialize the socket array
00193     for(i=0; i < socket_count ;i++)
00194         server_sockets[i] = INVALID_SOCKET;
00195
00196     // Setup the server sockets
00197     socket_count = 0;
00198     addrptr = results;
00199     while (addrptr)
00200     {
00201         // Create the server socket
00202         server_sockets[socket_count] = socket(addrptr->ai_family, addrptr->ai_socktype, addrptr->ai_protocol);
00203         if (server_sockets[socket_count] == INVALID_SOCKET)
00204         {
00205             fprintf(stderr, "socket failed: %d\n", WSAGetLastError());
00206             goto cleanup;
00207         }
00208
00209         // Bind the socket
00210         retval = bind(server_sockets[socket_count], addrptr->ai_addr, (int)addrptr->ai_addrlen);
00211         if (retval == SOCKET_ERROR)
00212         {
00213             fprintf(stderr, "bind failed: %d\n", WSAGetLastError());
00214             goto cleanup;
00215         }
00216
00217         // For TCP make the socket listening
00218         retval = listen(server_sockets[socket_count], 7);
00219         if (retval == SOCKET_ERROR)
00220         {
00221             fprintf(stderr, "listen failed: %d\n", WSAGetLastError());
00222             goto cleanup;
00223         }
00224
00225         // Make the socket non-blocking
00226         retval = ioctlsocket(server_sockets[socket_count], FIONBIO, &optval);
00227         if (retval == SOCKET_ERROR)
00228         {
00229             fprintf(stderr, "ioctlsocket failed: %d\n", WSAGetLastError());
00230             goto cleanup;
00231         }
00232
00233         // Display the address we bound to
00234         retval = getnameinfo(
00235                 addrptr->ai_addr,
00236                 (socklen_t)addrptr->ai_addrlen,
00237                 hoststr,
00238                 NI_MAXHOST,
00239                 servstr,
00240                 NI_MAXSERV,
00241                 NI_NUMERICHOST | NI_NUMERICSERV
00242                             );
00243         if (retval != 0)
00244         {
00245             fprintf(stderr, "getnameinfo failed: %d\n", retval);
00246             goto cleanup;
00247         }
00248
00249         printf("Server socket 0x%x listening on %s and port %s\n",
00250                 server_sockets[socket_count], hoststr, servstr);
00251
00252         // Increment counters and pointers
00253         socket_count++;
00254
00255         addrptr = addrptr->ai_next;
00256     }
00257     //
00258     // The fd sets should be zeroed out before using them to prevent errors.
00259     FD_ZERO(&readfds);
00260     FD_ZERO(&writefds);
00261
00262     // Set the server sockets
00263     for(i=0; i < socket_count ;i++)
00264     {
00265 #pragma warning (push)
00266 #pragma warning (disable: 4127)
00267         FD_SET(server_sockets[i], &readfds);
00268 #pragma warning (pop)
00269     }
00270
00271     //
00272     // The structure of the loop below is very simple. We only accept one
00273     // connection at a time. As soon as another client connects, we
00274     // disconnect the first one, and start talking to the new client.
00275     // All this server does is to echo the data received on the socket
00276     // back to the client.
00277     //
00278     // This is not a very realistic server, but it does serve to show that
00279     // select() does not scale very well on win32. If we were dealing
00280     // with more than one client, we would have to have a list of sockets
00281     // that are in each fdset to be able to check them when select()
00282     // returns.
00283     //
00284     for(;;)
00285     {
00286         //
00287         // A socket in the listen() state becomes ready to read when a
00288         // client connects to it. An accept() will complete without
00289         // blocking.
00290         //
00291
00292         retval = select(0, &readfds, &writefds, NULL, NULL);
00293         if (i == SOCKET_ERROR)
00294         {
00295             fprintf(stderr, "select failed %d\n", WSAGetLastError());
00296             goto cleanup;
00297         }
00298
00299         // Check for data on the client socket if connected
00300         if ((client_socket != INVALID_SOCKET) && (FD_ISSET(client_socket, &readfds)))
00301         {
00302             retval = recv(client_socket, buffer, DEFAULT_BUFFER_LEN, 0);
00303             if (retval == 0)
00304             {
00305                 // A successful recv of zero indicates graceful socket closure
00306
00307                 // Close the socket
00308                 FreeSocket(client_socket, retval);
00309                 client_socket = INVALID_SOCKET;
00310
00311                 // Add the listening sockets back to the read set
00312                 FD_ZERO(&readfds);
00313                 FD_ZERO(&writefds);
00314
00315                 for(i=0; i < socket_count ;i++)
00316 #pragma warning (push)
00317 #pragma warning (disable: 4127)
00318                     FD_SET(server_sockets[i], &readfds);
00319 #pragma warning (pop)
00320             }
00321             else if (retval == SOCKET_ERROR)
00322             {
00323                 // For WSAEWOULDBLOCK we simply go back to the top of the loop
00324                 //    and select again. Note that client_socket is already in
00325                 //    the readfds so we don't need to set it again.
00326                 //
00327                 if ((err = WSAGetLastError()) != WSAEWOULDBLOCK)
00328                 {
00329                     // Some other fatal error occurred so close the socket and
00330                     //    prepare to select on the listening sockets again.
00331
00332                     // Close the socket
00333                     FreeSocket(client_socket, retval);
00334                     client_socket = INVALID_SOCKET;
00335
00336                     // Add the listening sockets back to the read set
00337                     FD_ZERO(&readfds);
00338                     FD_ZERO(&writefds);
00339
00340                     for(i=0; i < socket_count ;i++)
00341 #pragma warning (push)
00342 #pragma warning (disable:4127)
00343                         FD_SET(server_sockets[i], &readfds);
00344 #pragma warning (pop)
00345                 }
00346             }
00347             else
00348             {
00349                 // Data was successfully received into 'buffer' so now put the
00350                 //    client_socket into the writefds so we can write it back
00351
00352                 bytesread = retval;
00353
00354                 printf("read %d bytes\n", bytesread);
00355
00356                 pbuffer = buffer;
00357
00358                 // Now wait for writeability to echo the data back
00359                 FD_ZERO(&readfds);
00360                 FD_ZERO(&writefds);
00361 #pragma warning (push)
00362 #pragma warning (disable:4127)
00363                 FD_SET(client_socket, &writefds);
00364 #pragma warning (pop)
00365             }
00366         }
00367         // Check for writeability on the client socket
00368         else if ((client_socket != INVALID_SOCKET) && (FD_ISSET(client_socket, &writefds)))
00369         {
00370             retval = send(client_socket, pbuffer, bytesread, 0);
00371             if (retval == 0)
00372             {
00373                 // Connection was gracefully closed so clean things up and put the
00374                 //    listening sockets back into the readfds
00375
00376                 // Close the socket
00377                 FreeSocket(client_socket, retval);
00378                 client_socket = INVALID_SOCKET;
00379
00380                 // Connection was closed so put the server sockets back in the readfds set
00381                 FD_ZERO(&readfds);
00382                 FD_ZERO(&writefds);
00383                 for(i=0; i < socket_count ;i++)
00384 #pragma warning (push)
00385 #pragma warning (disable:4127)
00386                     FD_SET(server_sockets[i], &readfds);
00387 #pragma warning (pop)
00388             }
00389             else if (retval == SOCKET_ERROR)
00390             {
00391                 // If we got a WSAEWOULDBLOCK we need to try to send again. Note that
00392                 //    client_socket is already in the writefds.
00393
00394                 if ((err = WSAGetLastError()) != WSAEWOULDBLOCK)
00395                 {
00396                     // A fatal error occured so close the socket and put the listening
00397                     //    sockets back into the readfds
00398
00399                     fprintf(stderr, "send failed: %d\n", err);
00400
00401                     // Close the socket
00402                     FreeSocket(client_socket, retval);
00403                     client_socket = INVALID_SOCKET;
00404
00405                     // Connection was closed so put the server sockets back in the readfds set
00406                     FD_ZERO(&readfds);
00407                     FD_ZERO(&writefds);
00408                     for(i=0; i < socket_count ;i++)
00409 #pragma warning (push)
00410 #pragma warning (disable:4127)
00411                         FD_SET(server_sockets[i], &readfds);
00412 #pragma warning (pop)
00413                 }
00414             }
00415             else
00416             {
00417                 // Successfully sent some data
00418                 printf("sent %d bytes\n", retval);
00419
00420                 if (bytesread != retval)
00421                 {
00422                     // We didn't send all the data that was read (e.g. 10 bytes were
00423                     //    read but this send call send less then 10 bytes). We need
00424                     //    to try to send again so increment the buffer pointer to the
00425                     //    data remaining and adjust the byte count. The client_socket
00426                     //    is already in writefds so just continue;
00427                     //
00428                     pbuffer = &buffer[bytesread-retval];
00429                     bytesread -= retval;
00430
00431                     // Write isn't complete so leave the socket in the writefds
00432                     //    set and continue
00433                 }
00434                 else
00435                 {
00436                     pbuffer = buffer;
00437
00438                     // Write complete: set the socket for reading now
00439                     FD_ZERO(&readfds);
00440                     FD_ZERO(&writefds);
00441 #pragma warning (push)
00442 #pragma warning (disable:4127)
00443                     FD_SET(client_socket, &readfds);
00444 #pragma warning (pop)
00445                 }
00446             }
00447         }
00448         // Check for accepted client connection
00449         else
00450         {
00451             // See which listening socket has a connection
00452             for(i=0; i < socket_count ;i++)
00453             {
00454                 if (FD_ISSET(server_sockets[i], &readfds))
00455                 {
00456                     // Accept the connection
00457                     clientlen = sizeof(client);
00458                     client_socket = accept(server_sockets[i], (SOCKADDR *)&client, &clientlen);
00459                     if (client_socket == INVALID_SOCKET)
00460                     {
00461                         fprintf(stderr, "accept failed: %d\n", WSAGetLastError());
00462                         goto cleanup;
00463                     }
00464
00465                     // Print the client's address out
00466                     retval = getnameinfo(
00467                             (SOCKADDR *)&client,
00468                             clientlen,
00469                             hoststr,
00470                             NI_MAXHOST,
00471                             servstr,
00472                             NI_MAXSERV,
00473                             NI_NUMERICHOST | NI_NUMERICSERV
00474                             );
00475                     if (retval != 0)
00476                     {
00477                         fprintf(stderr, "getnameinfo failed: %d\n", retval);
00478                         goto cleanup;
00479                     }
00480
00481                     printf("Accepted client connection from %s and port %s\n",
00482                             hoststr, servstr);
00483
00484                     FD_ZERO(&readfds);
00485 #pragma warning (push)
00486 #pragma warning (disable:4127)
00487                     FD_SET(client_socket, &readfds);
00488 #pragma warning (pop)
00489
00490                     // Since we handle only one conneciton at a time, break out
00491                     //    and start servicing the client connection
00492                     break;
00493                 }
00494             }
00495         }
00496     }
00497
00498 cleanup:
00499
00500     //
00501     // Clean up any allocations and handles, etc.
00502     //
00503
00504     if (results)
00505     {
00506         freeaddrinfo(results);
00507         results = NULL;
00508     }
00509
00510     if (client_socket != INVALID_SOCKET)
00511     {
00512         FreeSocket(client_socket, NO_ERROR);
00513         client_socket = INVALID_SOCKET;
00514     }
00515
00516     if (server_sockets)
00517     {
00518         for(i=0; i < socket_count ;i++)
00519         {
00520             if (server_sockets[i] != INVALID_SOCKET)
00521             {
00522                 closesocket(server_sockets[i]);
00523                 server_sockets[i] = INVALID_SOCKET;
00524             }
00525         }
00526
00527         HeapFree(GetProcessHeap(), 0, server_sockets);
00528         server_sockets = NULL;
00529     }
00530
00531     WSACleanup();
00532     return 0;
00533 }
00534
00535 //
00536 // Function: FreeSocket
00537 //
00538 // Description:
00539 //    If the socket closed without error shut it down and then close the
00540 //    socket handle.
00541 //
00542 void FreeSocket(SOCKET s, int rc)
00543 {
00544     int     retval;
00545
00546     // client connection was closed
00547     if (rc == NO_ERROR)
00548     {
00549         retval = shutdown(s, SD_SEND);
00550         if (retval == SOCKET_ERROR)
00551         {
00552             fprintf(stderr, "FreeSocket: shutdown failed: %d\n", WSAGetLastError());
00553         }
00554     }
00555
00556     // Release the handle
00557     retval = closesocket(s);
00558     if (retval == SOCKET_ERROR)
00559     {
00560         fprintf(stderr, "FreeSocket: closesocket failed: %d\n", WSAGetLastError());
00561     }
00562 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagLogon Member List

This is the complete list of members for _tagLogon, including all inherited members.
hImpToken | _tagLogon
hLogon | _tagLogon
psdCreator | _tagLogon
szDomain | _tagLogon
szUsername | _tagLogon
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/ontemp.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

ontemp.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  OnTemp.cpp
00006 //
00007 // Description:
00008 //  This file implements the register/unregister of temporary
00009 //    event consumers.
00010 //
00011 // History:
00012 //
00013 // **************************************************************************
00014 #include "stdafx.h"
00015 #include "AdvClientDlg.h"
00016
00017 BOOL CAdvClientDlg::OnTempRegister()
00018 {
00019   HRESULT hr;
00020
00021   if(EnsureOfficeNamespace())
00022   {
00023
00024     //create a thread that would call ExecNotificationQuery() semi-synchronously and
00025     //poll for events
00026
00027
00028     hr = CoMarshalInterThreadInterfaceInStream(IID_IWbemServices,
00029                           m_pOfficeService,
00030                           &m_pStream);
00031     if (FAILED(hr))
00032     {
00033       m_eventList.AddString(_T("Failed to marshal IWbemServices pointer"));
00034       return FALSE;
00035
00036     }
00037
00038       m_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc,
00039                 (void *)this, 0, &m_threadId);
00040
00041     if (m_thread == NULL)
00042     {
00043       m_eventList.AddString(_T("Failed to create event polling thread"));
00044       return FALSE;
00045     }
00046
00047     return TRUE;
00048   }
00049
00050   return FALSE;
00051 }
00052
00053 void CAdvClientDlg::OnTempUnregister()
00054 {
00055
00056   if(EnsureOfficeNamespace())
00057   {
00058     StopThread();
00059
00060     m_eventList.ResetContent();
00061     m_eventList.AddString(_T("unregistered"));
00062
00063
00064   }
00065 }
00066
00067 void CAdvClientDlg::StopThread()
00068 {
00069     EnterCriticalSection(&m_critSect);
00070
00071     if (m_thread != NULL)
00072   {
00073     //m_threadCmd = CT_EXIT;
00074     SetEvent(m_stopThread);
00075     WaitForSingleObject(m_ptrReady, 100);
00076
00077         CloseHandle(m_thread);
00078
00079         m_thread = NULL;
00080     }
00081     LeaveCriticalSection(&m_critSect);
00082 }
00083
00084 // ========================================================
00085
00086 DWORD WINAPI CAdvClientDlg::ThreadProc(LPVOID lpParameter)
00087 {
00088
00089   CoInitialize(NULL);
00090
00091   CAdvClientDlg * pThis = (CAdvClientDlg *)lpParameter;
00092
00093   BSTR qLang = SysAllocString(L"WQL");
00094   if (!qLang)
00095   {
00096     (pThis->m_eventList).AddString(_T("SysAllocString failed"));
00097     SetEvent(pThis->m_ptrReady);
00098     return 1;
00099   }
00100   BSTR query = SysAllocString(L"select * from __InstanceCreationEvent where TargetInstance isa \"SAMPLE_OfficeEquipment\"");
00101   if (!query)
00102   {
00103     (pThis->m_eventList).AddString(_T("SysAllocString failed"));
00104     SetEvent(pThis->m_ptrReady);
00105     SysFreeString(qLang);
00106     return 1;
00107   }
00108
00109
00110   IWbemServices * pServices = NULL;
00111   (pThis->m_eventList).ResetContent();
00112
00113   HRESULT hr = CoGetInterfaceAndReleaseStream(pThis->m_pStream,
00114                     IID_IWbemServices,
00115                     (void**)&pServices);
00116   if (FAILED(hr))
00117   {
00118     (pThis->m_eventList).AddString(_T("Failed to unmarshal interface: "));
00119     (pThis->m_eventList).AddString(ErrorString(hr));
00120     SetEvent(pThis->m_ptrReady);
00121     return 1;
00122   }
00123
00124
00125   (pThis->m_eventList).ResetContent();
00126
00127   IEnumWbemClassObject * pEnumEvents = NULL;
00128
00129   // execute the query.
00130   hr = pServices->ExecNotificationQuery(qLang, query,
00131                       WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY,
00132                       NULL, &pEnumEvents);
00133
00134   SysFreeString(qLang);
00135   SysFreeString(query);
00136
00137   if(hr == WBEM_S_NO_ERROR)
00138   {
00139     TRACE(_T("Executed event query\n"));
00140     (pThis->m_eventList).AddString(_T("Ready for events"));
00141
00142     while(WaitForSingleObject((pThis->m_stopThread), 10) != WAIT_OBJECT_0)
00143     {
00144       IWbemClassObject * pEvent = NULL;
00145       ULONG uReturned = 0;
00146
00147       //poll for an event
00148       hr = pEnumEvents->Next(100,
00149                   1,
00150                   &pEvent,
00151                   &uReturned);
00152       if (SUCCEEDED(hr) && uReturned > 0)
00153       {
00154         DisplayEvents(pThis, 1, &pEvent);
00155                 pEvent->Release();
00156       }
00157     }
00158
00159     //thread terminating:
00160     pEnumEvents->Release();
00161
00162   }
00163   else
00164   {
00165     TRACE(_T("ExecNotificationQuery() failed %s\n"), ErrorString(hr));
00166     (pThis->m_eventList).AddString(_T("Failed To Register"));
00167
00168   } //endif ExecQuery()
00169
00170   SetEvent(pThis->m_ptrReady);
00171
00172   return 0;
00173
00174 }
00175
00176 // ========================================================
00177 STDMETHODIMP CAdvClientDlg::DisplayEvents(CAdvClientDlg *pThis,
00178                   LONG lObjectCount,
00179                     IWbemClassObject **ppObjArray)
00180 {
00181
00182   if (!pThis)
00183   {
00184     return E_FAIL;
00185   }
00186   HRESULT  hRes;
00187   CString clMyBuff;
00188   BSTR objName = NULL;
00189   BSTR propName = NULL;
00190   VARIANT pVal, vDisp;
00191   IDispatch *pDisp = NULL;
00192   IWbemClassObject *tgtInst = NULL;
00193
00194   VariantInit(&pVal);
00195   VariantInit(&vDisp);
00196
00197   objName = SysAllocString(L"TargetInstance");
00198   if (!objName)
00199     return E_OUTOFMEMORY;
00200   propName = SysAllocString(L"Item");
00201   if (!propName)
00202   {
00203     SysFreeString(objName);
00204     return E_OUTOFMEMORY;
00205   }
00206
00207   // walk though the classObjects...
00208   for (int i = 0; i < lObjectCount; i++)
00209   {
00210     // clear my output buffer.
00211     clMyBuff.Empty();
00212
00213     // get what was added. This will be an embedded object (VT_DISPATCH). All
00214     // WBEM interfaces are derived from IDispatch.
00215     if ((hRes = ppObjArray[i]->Get(objName, 0L,
00216                     &vDisp, NULL, NULL)) == S_OK)
00217     {
00218       //--------------------------------
00219       // pull the IDispatch out of the various. Dont cast directly to to IWbemClassObject.
00220       // it MIGHT work now but a suptle change later will break your code. The PROPER
00221       // way is to go through QueryInterface and do all the right Release()'s.
00222       pDisp = (IDispatch *)V_DISPATCH(&vDisp);
00223
00224       //--------------------------------
00225       // ask for the IWbemClassObject which is the embedded object. This will be the
00226       // instance that was created.
00227       if(SUCCEEDED(pDisp->QueryInterface(IID_IWbemClassObject, (void **)&tgtInst)))
00228       {
00229         //--------------------------------
00230         // dont need the IDispatch anymore.
00231         pDisp->Release();
00232
00233         //--------------------------------
00234         // get the 'Item' property out of the embedded object.
00235         if ((hRes = tgtInst->Get(propName, 0L,
00236                     &pVal, NULL, NULL)) == S_OK)
00237         {
00238           //--------------------------------
00239           // done with it.
00240           tgtInst->Release();
00241
00242           // compose a string for the listbox.
00243           clMyBuff = _T("SAMPLE_OfficeEquipment Instance added for: ");
00244           clMyBuff += V_BSTR(&pVal);
00245
00246           // output the buffer.
00247           (pThis->m_eventList).AddString(clMyBuff);
00248         }
00249         else
00250         {
00251           TRACE(_T("Get() Item failed %s\n"), ErrorString(hRes));
00252         }
00253       }
00254       else
00255       {
00256         TRACE(_T("QI() failed \n"));
00257       }
00258     }
00259     else
00260     {
00261       TRACE(_T("Get() targetInst failed %s\n"), ErrorString(hRes));
00262       (pThis->m_eventList).AddString(_T("programming error"));
00263     } //endif Get()
00264
00265   } // endfor
00266
00267   SysFreeString(propName);
00268   SysFreeString(objName);
00269   VariantClear(&pVal);
00270
00271   return S_OK;
00272 }
00273
00274
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/CEResyncEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

CEResyncEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: CEResyncEnum
00019
00020 public class CEResyncEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adResyncNone = 0;
00023   public static final short adResyncAutoIncrement = 1;
00024   public static final short adResyncConflicts = 2;
00025   public static final short adResyncUpdates = 4;
00026   public static final short adResyncInserts = 8;
00027   public static final short adResyncAll = 15;
00028 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/resource.h Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by mqfdraw.rc
00004 //
00005 #define IDC_CONTINUE                    3
00006 #define IDD_DISDRAW_DIALOG              102
00007 #define IDR_MAINFRAME                   128
00008 #define IDD_LOGIN                       129
00009 #define IDD_DS                          130
00010 #define IDC_EDIT_FRIEND                 1000
00011 #define IDC_BUTTON_ATTACH               1001
00012 #define IDC_RADIO_EXPRESS               1002
00013 #define IDC_RADIO_RECOVERABLE           1003
00014 #define IDC_DRAWAREA_SCRIBLLE           1004
00015 #define IDC_EDIT_LOGIN                  1005
00016 #define IDC_EDIT_FRIEND_COMPUTER        1005
00017 #define IDC_RADIO_DS                    1006
00018 #define IDC_RADIO_WORKGROUP             1007
00019 #define IDC_STATIC_CHOOSE_DS            1009
00020 #define IDC_STATIC_Q_LABEL              1010
00021 #define IDC_STATIC_CHOOSE_MESSAGE       1011
00022 #define IDC_STATIC_C_LABEL              1012
00023 #define IDC_BUTTON_ADDQUEUE             1013
00024 #define IDC_STATIC_CHOOSE_QUEUE         1017
00025 #define IDC_RADIO_PUBLICQUEUE           1018
00026 #define IDC_RADIO_PRIVATEQUEUE          1020
00027 #define IDC_STATIC_DSFRAME              1022
00028 #define IDC_FRAME_FRIEND                1023
00029 #define IDC_CONNECTION                  1024
00030
00031 // Next default values for new objects
00032 //
00033 #ifdef APSTUDIO_INVOKED
00034 #ifndef APSTUDIO_READONLY_SYMBOLS
00035 #define _APS_NEXT_RESOURCE_VALUE        131
00036 #define _APS_NEXT_COMMAND_VALUE         32771
00037 #define _APS_NEXT_CONTROL_VALUE         1025
00038 #define _APS_NEXT_SYMED_VALUE           101
00039 #endif
00040 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/doc.Cpp Source File

  • Com
  • Fundamentals
  • SimpCntr

doc.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: DOC.CPP
00003 //
00004 //      Implementation file for CSimpleDoc.
00005 //
00006 // Functions:
00007 //
00008 //      See DOC.H for Class Definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "ioipf.h"
00017 #include "ioips.h"
00018 #include "app.h"
00019 #include "site.h"
00020 #include "doc.h"
00021
00022 //**********************************************************************
00023 //
00024 // CSimpleDoc::Create
00025 //
00026 // Purpose:
00027 //
00028 //      Creation for the CSimpleDoc Class
00029 //
00030 // Parameters:
00031 //
00032 //      CSimpleApp FAR * lpApp  -   Pointer to the CSimpleApp Class
00033 //
00034 //      LPRECT lpRect           -   Client area rect of "frame" window
00035 //
00036 //      HWND hWnd               -   Window Handle of "frame" window
00037 //
00038 // Return Value:
00039 //
00040 //      None
00041 //
00042 // Function Calls:
00043 //      Function                    Location
00044 //
00045 //      StgCreateDocfile            OLE API
00046 //      CreateWindow                Windows API
00047 //      ShowWindow                  Windows API
00048 //      UpdateWindow                Windows API
00049 //
00050 // Comments:
00051 //
00052 //      This routine was added so that failure could be returned
00053 //      from object creation.
00054 //
00055 //********************************************************************
00056
00057 CSimpleDoc FAR * CSimpleDoc::Create(CSimpleApp FAR *lpApp, LPRECT lpRect,HWND hWnd)
00058 {
00059         CSimpleDoc FAR * lpTemp = new CSimpleDoc(lpApp, hWnd);
00060
00061         if (!lpTemp)
00062                 return NULL;
00063
00064         // create storage for the doc.
00065         HRESULT hErr = StgCreateDocfile (NULL, STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
00066                                                                          0, &lpTemp->m_lpStorage);
00067
00068         if (hErr != NOERROR)
00069                 goto error;
00070
00071         // create the document Window
00072         lpTemp->m_hDocWnd = CreateWindow(
00073                         "SimpCntrDocWClass",
00074                         NULL,
00075                         WS_CHILD | WS_CLIPCHILDREN,
00076                         lpRect->left,
00077                         lpRect->top,
00078                         lpRect->right,
00079                         lpRect->bottom,
00080                         hWnd,
00081                         NULL,
00082                         lpApp->m_hInst,
00083                         NULL);
00084
00085         if (!lpTemp->m_hDocWnd)
00086                 goto error;
00087
00088         ShowWindow(lpTemp->m_hDocWnd, SW_SHOWNORMAL);  // Show the window
00089         UpdateWindow(lpTemp->m_hDocWnd);               // Sends WM_PAINT message
00090
00091         // Ensable InsertObject menu choice
00092         EnableMenuItem( lpApp->m_hEditMenu, 0, MF_BYPOSITION | MF_ENABLED);
00093
00094         // we will add one ref count on our document. later in CSimpleDoc::Close
00095         // we will release this  ref count. when the document's ref count goes
00096         // to 0, the document will be deleted.
00097         lpTemp->AddRef();
00098
00099         return (lpTemp);
00100
00101 error:
00102         delete (lpTemp);
00103         return NULL;
00104
00105 }
00106
00107 //**********************************************************************
00108 //
00109 // CSimpleDoc::Close
00110 //
00111 // Purpose:
00112 //
00113 //      Close CSimpleDoc object.
00114 //      when the document's reference count goes to 0, the document
00115 //      will be destroyed.
00116 //
00117 // Parameters:
00118 //
00119 //
00120 // Return Value:
00121 //
00122 //      None
00123 //
00124 // Function Calls:
00125 //      Function                    Location
00126 //
00127 //      RevokeDragDrop              OLE API
00128 //      CoLockObjectExternal        OLE API
00129 //      OleFlushClipboard           OLE API
00130 //      ShowWindow                  Windows API
00131 //
00132 // Comments:
00133 //
00134 //********************************************************************
00135
00136 void CSimpleDoc::Close(void)
00137 {
00138         OutputDebugString("In CSimpleDoc::Close\r\n");
00139
00140         ShowWindow(m_hDocWnd, SW_HIDE);  // Hide the window
00141
00142         // Close the OLE object in our document
00143         if (m_lpSite)
00144                 m_lpSite->CloseOleObject();
00145
00146         // Release the ref count added in CSimpleDoc::Create. this will make
00147         // the document's ref count go to 0, and the document will be deleted.
00148         Release();
00149 }
00150
00151 //**********************************************************************
00152 //
00153 // CSimpleDoc::CSimpleDoc
00154 //
00155 // Purpose:
00156 //
00157 //      Constructor for the CSimpleDoc Class
00158 //
00159 // Parameters:
00160 //
00161 //      CSimpleApp FAR * lpApp  -   Pointer to the CSimpleApp Class
00162 //
00163 //      HWND hWnd               -   Window Handle of "frame" window
00164 //
00165 // Return Value:
00166 //
00167 //      None
00168 //
00169 // Function Calls:
00170 //      Function                    Location
00171 //
00172 //      OutputDebugString           Windows API
00173 //      GetMenu                     Windows API
00174 //      GetSubMenu                  Windows API
00175 //
00176 // Comments:
00177 //
00178 //********************************************************************
00179
00180 CSimpleDoc::CSimpleDoc(CSimpleApp FAR * lpApp,HWND hWnd)
00181 {
00182         OutputDebugString("In CSimpleDoc's Constructor\r\n");
00183         m_lpApp = lpApp;
00184         m_lpSite = NULL;
00185         // set up menu handles
00186         m_lpApp->m_hMainMenu = GetMenu(hWnd);
00187         m_lpApp->m_hFileMenu = GetSubMenu(m_lpApp->m_hMainMenu, 0);
00188         m_lpApp->m_hEditMenu = GetSubMenu(m_lpApp->m_hMainMenu, 1);
00189         m_lpApp->m_hHelpMenu = GetSubMenu(m_lpApp->m_hMainMenu, 2);
00190         m_lpApp->m_hCascadeMenu = NULL;
00191
00192         m_lpActiveObject = NULL;
00193
00194         // flags
00195         m_fInPlaceActive = FALSE;
00196         m_fAddMyUI = FALSE;
00197         m_fModifiedMenu = FALSE;
00198 }
00199
00200 //**********************************************************************
00201 //
00202 // CSimpleDoc::~CSimpleDoc
00203 //
00204 // Purpose:
00205 //
00206 //      Destructor for CSimpleDoc
00207 //
00208 // Parameters:
00209 //
00210 //      None
00211 //
00212 // Return Value:
00213 //
00214 //      None
00215 //
00216 // Function Calls:
00217 //      Function                    Location
00218 //
00219 //      OutputDebugString           Windows API
00220 //      CSimpleSite::Release        SITE.CPP
00221 //      IStorage::Release           OLE API
00222 //
00223 // Comments:
00224 //
00225 //********************************************************************
00226
00227 CSimpleDoc::~CSimpleDoc()
00228 {
00229         OutputDebugString("In CSimpleDoc's Destructor\r\n");
00230
00231         // Release all pointers we hold to the OLE object. also release
00232         // the ref count added in CSimpleSite::Create. this will make
00233         // the Site's ref count go to 0, and the Site will be deleted.
00234         if (m_lpSite) {
00235                 m_lpSite->UnloadOleObject();
00236                 m_lpSite->Release();
00237                 m_lpSite = NULL;
00238         }
00239
00240         // Release the Storage
00241         if (m_lpStorage) {
00242                 m_lpStorage->Release();
00243                 m_lpStorage = NULL;
00244         }
00245
00246         // if the edit menu was modified, remove the menu item and
00247         // destroy the popup if it exists
00248         if (m_fModifiedMenu)
00249                 {
00250                 int nCount = GetMenuItemCount(m_lpApp->m_hEditMenu);
00251                 RemoveMenu(m_lpApp->m_hEditMenu, nCount-1, MF_BYPOSITION);
00252                 if (m_lpApp->m_hCascadeMenu)
00253                         DestroyMenu(m_lpApp->m_hCascadeMenu);
00254                 }
00255
00256         DestroyWindow(m_hDocWnd);
00257 }
00258
00259
00260 //**********************************************************************
00261 //
00262 // CSimpleDoc::QueryInterface
00263 //
00264 // Purpose:
00265 //
00266 //      Return a pointer to a requested interface
00267 //
00268 // Parameters:
00269 //
00270 //      REFIID riid         -   ID of interface to be returned
00271 //      LPVOID FAR* ppvObj  -   Location to return the interface
00272 //
00273 // Return Value:
00274 //
00275 //      S_FALSE -   Always
00276 //
00277 // Function Calls:
00278 //      Function                    Location
00279 //
00280 //      OutputDebugString           Windows API
00281 //                   OLE API
00282 //
00283 // Comments:
00284 //
00285 //      In this implementation, there are no doc level interfaces.
00286 //      In an MDI application, there would be an IOleInPlaceUIWindow
00287 //      associated with the document to provide document level tool
00288  //     space negotiation.
00289 //
00290 //********************************************************************
00291
00292 STDMETHODIMP CSimpleDoc::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00293 {
00294         OutputDebugString("In CSimpleDoc::QueryInterface\r\n");
00295
00296         *ppvObj = NULL;     // must set out pointer parameters to NULL
00297
00298         // Not a supported interface
00299         return E_NOINTERFACE;
00300 }
00301
00302 //**********************************************************************
00303 //
00304 // CSimpleDoc::AddRef
00305 //
00306 // Purpose:
00307 //
00308 //      Increments the document reference count
00309 //
00310 // Parameters:
00311 //
00312 //      None
00313 //
00314 // Return Value:
00315 //
00316 //      UINT    -   The current reference count on the document
00317 //
00318 // Function Calls:
00319 //      Function                    Location
00320 //
00321 //      OutputDebugString           Windows API
00322 //      CSimpleApp::AddRef          APP.CPP
00323 //
00324 // Comments:
00325 //
00326 //********************************************************************
00327
00328 STDMETHODIMP_(ULONG) CSimpleDoc::AddRef()
00329 {
00330         OutputDebugString("In CSimpleDoc::AddRef\r\n");
00331         return SafeAddRef();
00332 }
00333
00334 //**********************************************************************
00335 //
00336 // CSimpleDoc::Release
00337 //
00338 // Purpose:
00339 //
00340 //      Decrements the document reference count
00341 //
00342 // Parameters:
00343 //
00344 //      None
00345 //
00346 // Return Value:
00347 //
00348 //      UINT    -   The current reference count on the document
00349 //
00350 // Function Calls:
00351 //      Function                    Location
00352 //
00353 //      OutputDebugString           Windows API
00354 //
00355 // Comments:
00356 //
00357 //********************************************************************
00358
00359 STDMETHODIMP_(ULONG) CSimpleDoc::Release()
00360 {
00361         OutputDebugString("In CSimpleDoc::Release\r\n");
00362
00363         return SafeRelease();
00364 }
00365
00366 //**********************************************************************
00367 //
00368 // CSimpleDoc::InsertObject
00369 //
00370 // Purpose:
00371 //
00372 //      Inserts a new object to this document
00373 //
00374 // Parameters:
00375 //
00376 //      None
00377 //
00378 // Return Value:
00379 //
00380 //      None
00381 //
00382 // Function Calls:
00383 //      Function                    Location
00384 //
00385 //      CSimpleSite::CSimpleSite    SITE.CPP
00386 //      CSimpleSite::InitObject     SITE.CPP
00387 //      memset                      C Runtime
00388 //      OleUIInsertObject           OUTLUI function
00389 //      CSimpleDoc::DisableInsertObject DOC.CPP
00390 //
00391 // Comments:
00392 //
00393 //      This implementation only allows one object to be inserted
00394 //      into a document.  Once the object has been inserted, then
00395 //      the Insert Object menu choice is greyed out, to prevent
00396 //      the user from inserting another.
00397 //
00398 //********************************************************************
00399
00400 void CSimpleDoc::InsertObject()
00401 {
00402         CStabilize stabilize(this);
00403         OLEUIINSERTOBJECT io;
00404         UINT iret;
00405   //@@WTK WIN32, UNICODE
00406         //char szFile[MAX_PATH];
00407         TCHAR szFile[MAX_PATH];
00408
00409         m_lpSite = CSimpleSite::Create(this);
00410
00411         // clear the structure
00412         memset(&io, 0, sizeof(OLEUIINSERTOBJECT));
00413
00414         // fill the structure
00415         io.cbStruct = sizeof(OLEUIINSERTOBJECT);
00416         io.dwFlags = IOF_SELECTCREATENEW |
00417                                         IOF_DISABLELINK | IOF_DISABLEDISPLAYASICON |
00418                                         IOF_CREATENEWOBJECT | IOF_CREATEFILEOBJECT;
00419         io.hWndOwner = m_hDocWnd;
00420   //@@WTK WIN32, UNICODE
00421         //io.lpszCaption = (LPSTR)"Insert Object";
00422         io.lpszCaption = _T("Insert Object");
00423         io.iid = IID_IOleObject;
00424         io.oleRender = OLERENDER_DRAW;
00425         io.lpIOleClientSite = &m_lpSite->m_OleClientSite;
00426         io.lpIStorage = m_lpSite->m_lpObjStorage;
00427         io.ppvObj = (LPVOID FAR *)&m_lpSite->m_lpOleObject;
00428         io.lpszFile = szFile;
00429   //@@WTK WIN32, UNICODE
00430         //io.cchFile = sizeof(szFile);
00431         io.cchFile = sizeof(szFile) / sizeof *szFile;
00432   //@@WTK WIN32, UNICODE
00433         //_fmemset((LPSTR)szFile, 0, sizeof(szFile));
00434         memset(szFile, 0, sizeof(szFile));
00435
00436         // call OUTLUI to do all the hard work
00437         iret = OleUIInsertObject(&io);
00438
00439         if (iret == OLEUI_OK)
00440                 {
00441                 m_lpSite->InitObject((BOOL)(io.dwFlags & IOF_SELECTCREATENEW));
00442                 // disable Insert Object menu item
00443                 DisableInsertObject();
00444                 }
00445         else
00446                 {
00447                 m_lpSite->Release();
00448                 m_lpSite = NULL;
00449                 m_lpStorage->Revert();
00450                 }
00451
00452 }
00453
00454 //**********************************************************************
00455 //
00456 // CSimpleDoc::lResizeDoc
00457 //
00458 // Purpose:
00459 //
00460 //      Resizes the document
00461 //
00462 // Parameters:
00463 //
00464 //      LPRECT lpRect   -   The size of the client are of the "frame"
00465 //                          Window.
00466 //
00467 // Return Value:
00468 //
00469 //      NULL
00470 //
00471 // Function Calls:
00472 //      Function                                Location
00473 //
00474 //      IOleInPlaceActiveObject::ResizeBorder   Object
00475 //      MoveWindow                              Windows API
00476 //
00477 // Comments:
00478 //
00479 //********************************************************************
00480
00481 long CSimpleDoc::lResizeDoc(LPRECT lpRect)
00482 {
00483         CStabilize stabilize(this);
00484         // if we are InPlace, then call ResizeBorder on the object, otherwise
00485         // just move the document window.
00486         if (m_fInPlaceActive)
00487                 m_lpActiveObject->ResizeBorder(lpRect, &m_lpApp->m_OleInPlaceFrame, TRUE);
00488         else
00489                 MoveWindow(m_hDocWnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, TRUE);
00490
00491         return NULL;
00492 }
00493
00494 //**********************************************************************
00495 //
00496 // CSimpleDoc::lAddVerbs
00497 //
00498 // Purpose:
00499 //
00500 //      Adds the objects verbs to the edit menu.
00501 //
00502 // Parameters:
00503 //
00504 //      None
00505 //
00506 // Return Value:
00507 //
00508 //      NULL
00509 //
00510 // Function Calls:
00511 //      Function                    Location
00512 //
00513 //      GetMenuItemCount            Windows API
00514 //      OleUIAddVerbMenu            OUTLUI function
00515 //
00516 // Comments:
00517 //
00518 //********************************************************************
00519
00520 long CSimpleDoc::lAddVerbs(void)
00521 {
00522         CStabilize stabilize(this);
00523         // m_fModifiedMenu is TRUE if the menu has already been modified
00524         // once.  Since we only support one obect every time the application
00525         // is run, then once the menu is modified, it doesn't have
00526         // to be done again.
00527         if (m_lpSite && !m_fInPlaceActive  && !m_fModifiedMenu)
00528                 {
00529                 int nCount = GetMenuItemCount(m_lpApp->m_hEditMenu);
00530
00531                 OleUIAddVerbMenu ( m_lpSite->m_lpOleObject,
00532                                                    NULL,
00533                                                    m_lpApp->m_hEditMenu,
00534                                                    nCount + 1,
00535                                                    IDM_VERB0,
00536                                                    0,           // no maximum verb IDM enforced
00537                                                    FALSE,
00538                                                    0,
00539                                                    &m_lpApp->m_hCascadeMenu);
00540
00541                 m_fModifiedMenu = TRUE;
00542                 }
00543         return (NULL);
00544 }
00545
00546 //**********************************************************************
00547 //
00548 // CSimpleDoc::PaintDoc
00549 //
00550 // Purpose:
00551 //
00552 //      Paints the Document
00553 //
00554 // Parameters:
00555 //
00556 //      HDC hDC -   hDC of the document Window
00557 //
00558 // Return Value:
00559 //
00560 //      None
00561 //
00562 // Function Calls:
00563 //      Function                    Location
00564 //
00565 //      CSimpleSite::PaintObj       SITE.CPP
00566 //
00567 // Comments:
00568 //
00569 //********************************************************************
00570
00571 void CSimpleDoc::PaintDoc (HDC hDC)
00572 {
00573         CStabilize stabilize(this);
00574         // if we supported multiple objects, then we would enumerate
00575         // the objects and call paint on each of them from here.
00576
00577         if (m_lpSite)
00578                 m_lpSite->PaintObj(hDC);
00579
00580 }
00581
00582 //**********************************************************************
00583 //
00584 // CSimpleDoc::DisableInsertObject
00585 //
00586 // Purpose:
00587 //
00588 //      Disable the ability to insert a new object in this document.
00589 //
00590 // Parameters:
00591 //
00592 //      None
00593 //
00594 // Return Value:
00595 //
00596 //      None
00597 //
00598 // Function Calls:
00599 //      Function                    Location
00600 //
00601 //      EnableMenuItem              Windows API
00602 //
00603 // Comments:
00604 //
00605 //      This implementation only allows one object to be inserted
00606 //      into a document.  Once the object has been inserted, then
00607 //      the Insert Object menu choice is greyed out, to prevent
00608 //      the user from inserting another.
00609 //
00610 //********************************************************************
00611
00612 void CSimpleDoc::DisableInsertObject(void)
00613 {
00614         // Disable InsertObject menu choice
00615         EnableMenuItem( m_lpApp->m_hEditMenu, 0, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
00616 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Cap/Cap.Cpp Source File

  • Web
  • MSAgent
  • c
  • Cap

Cap.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 #include "stdafx.h"
00045 #include "MainDlg.h"
00046 #include "Error.h"
00047
00048 // Globals
00049
00050 extern HINSTANCE   g_hInst = NULL;
00051 extern MainDlg    *g_pMainDlg = NULL;
00052
00053 // Application Title
00054
00055 extern const LPTSTR kpszAppTitle = _T("Microsoft Agent Character Previewer");
00056
00057
00058 // WinMain
00059
00060 extern "C" int PASCAL WinMain(HINSTANCE hInst,
00061                 HINSTANCE hInstPrev,
00062                 LPTSTR pszCmdLine,
00063                 int nCmdShow) {
00064   MSG msg;
00065   HRESULT hRes;
00066
00067   g_hInst = hInst;
00068
00069   // Initialize COM
00070
00071   CoInitialize(NULL);
00072
00073   // Create an instance of our main dialog class
00074
00075   g_pMainDlg = new MainDlg;
00076
00077   if (g_pMainDlg == NULL)
00078     return -1;
00079
00080   // And initialize it
00081
00082   hRes = g_pMainDlg->Init();
00083
00084   if (FAILED(hRes)) {
00085     delete g_pMainDlg;
00086     SystemError(NULL, hRes, FALSE);
00087     return -1;
00088   }
00089
00090   // Show the window
00091
00092   ShowWindow(g_pMainDlg->m_hWnd, SW_SHOW);
00093
00094   // See if we got a filename on the command line
00095
00096   if (lstrlen(pszCmdLine) > 0) {
00097
00098     // Sometimes associating a file encloses it in
00099     // double quotes.
00100
00101     if (pszCmdLine[0] == '"')
00102       pszCmdLine = _tcsinc(pszCmdLine);
00103
00104     if (pszCmdLine[_tcslen(pszCmdLine)-1] == '"')
00105       pszCmdLine[_tcslen(pszCmdLine)-1] = 0;
00106
00107     // Load the character specified on the command line.
00108     // This allows someone to associate this program with
00109     // character files so that they can double click them
00110     // and start this application.
00111
00112     g_pMainDlg->LoadCharacter(pszCmdLine);
00113   }
00114
00115   // Standard message loop
00116
00117   while (GetMessage(&msg, NULL, 0, 0) > 0) {
00118     if (TranslateAccelerator(g_pMainDlg->m_hWnd, g_pMainDlg->m_hAccel, &msg))
00119       continue;
00120     if (IsDialogMessage(g_pMainDlg->m_hWnd, &msg))
00121       continue;
00122     TranslateMessage(&msg);
00123     DispatchMessage(&msg);
00124   }
00125
00126   // Clean up
00127
00128   delete g_pMainDlg;
00129
00130   CoUninitialize();
00131
00132   return 0;
00133 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the class factories of the PERDRAW
00005              server.  This server provides the DrawPage COM component.
00006              For this component, IClassFactory is implemented in an
00007              appropriate class factory COM object: CFDrawPage. The COM
00008              component that can be manufactured by this server is known
00009              outside the server by its CLSID: CLSID_DrawPage.
00010
00011              The class factories in this server use the CThreaded
00012              OwnThis mechanism to ensure mutually exclusive access by
00013              contending multiple threads.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial PERDRAW.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   CFDrawPage.
00022
00023   Functions: .
00024
00025   Origin:    5-20-97: atrent - Editor-inheritance from FACTORY.CPP in
00026                the STOSERVE Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 /*---------------------------------------------------------------------------
00044   We include WINDOWS.H for all Win32 applications.
00045   We include OLE2.H because we will be calling the COM/OLE Libraries.
00046   We include OLECTL.H because it has definitions for connectable objects.
00047   We include APPUTIL.H because we will be building this DLL using
00048     the convenient Virtual Window and Dialog classes and other
00049     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00050   We include IPAGES.H and PAGEGUID.H for the common DrawPage-related
00051     Interface class, GUID, and CLSID specifications.
00052   We include SERVER.H because it has the necessary internal class and
00053     resource definitions for this DLL and for the server housing.
00054   We include FACTORY.H because it has the necessary internal class factory
00055     declarations for this DLL component server.  Those are the factories
00056     we will be implementing in this module.
00057   We include CONNECT.H for object class declarations for the various
00058     connection point and connection COM objects used in PERDRAW.
00059   We include DRAWPAGE.H, for the object class declarations for the
00060     CODrawPage COM object.
00061 ---------------------------------------------------------------------------*/
00062 #include <windows.h>
00063 #include <ole2.h>
00064 #include <olectl.h>
00065 #include <apputil.h>
00066 #include <ipages.h>
00067 #include <pageguid.h>
00068 #include "server.h"
00069 #include "factory.h"
00070 #include "connect.h"
00071 #include "drawpage.h"
00072
00073 /*---------------------------------------------------------------------------
00074   Implementation the CFDrawPage Class Factory.  CFDrawPage is the COM
00075   object class for the Class Factory that can manufacture CODrawPage
00076   COM Components.
00077 ---------------------------------------------------------------------------*/
00078
00079 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00080   Method:   CFDrawPage::CFDrawPage
00081
00082   Summary:  CFDrawPage Constructor. Note the member initializer:
00083             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00084             to pass the 'this', pUnkOuter, and pServer pointers of this
00085             constructor function to the constructor executed in the
00086             instantiation of the CImpIClassFactory interface whose
00087             implementation is nested inside this present object class.
00088
00089   Args:     IUnknown* pUnkOuter,
00090               Pointer to the the outer Unknown.  NULL means this COM Object
00091               is not being Aggregated.  Non NULL means it is being created
00092               on behalf of an outside COM object that is reusing it via
00093               aggregation.
00094             CServer* pServer)
00095               Pointer to the server's control object.
00096
00097   Modifies: m_cRefs, m_pUnkOuter.
00098
00099   Returns:  void
00100 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00101 CFDrawPage::CFDrawPage(
00102   IUnknown* pUnkOuter,
00103   CServer* pServer) :
00104   m_ImpIClassFactory(this, pUnkOuter, pServer)
00105 {
00106   // Zero the COM object's reference count.
00107   m_cRefs = 0;
00108
00109   // No AddRef necessary if non-NULL, as we're nested.
00110   m_pUnkOuter = pUnkOuter;
00111
00112   // Init the pointer to the server control object.
00113   m_pServer = pServer;
00114
00115   return;
00116 }
00117
00118
00119 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00120   Method:   CFDrawPage::~CFDrawPage
00121
00122   Summary:  CFDrawPage Destructor.
00123
00124   Args:     void
00125
00126   Returns:  void
00127 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00128 CFDrawPage::~CFDrawPage(void)
00129 {
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   CFDrawPage::QueryInterface
00136
00137   Summary:  QueryInterface of the CFDrawPage non-delegating
00138             IUnknown implementation.
00139
00140   Args:     REFIID riid,
00141               [in] GUID of the Interface being requested.
00142             PPVOID ppv)
00143               [out] Address of the caller's pointer variable that will
00144               receive the requested interface pointer.
00145
00146   Returns:  HRESULT
00147               Standard result code. NOERROR for success.
00148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00149 STDMETHODIMP CFDrawPage::QueryInterface(
00150                REFIID riid,
00151                PPVOID ppv)
00152 {
00153   HRESULT hr = E_NOINTERFACE;
00154
00155   if (OwnThis())
00156   {
00157     *ppv = NULL;
00158
00159     if (IID_IUnknown == riid)
00160       *ppv = this;
00161     else if (IID_IClassFactory == riid)
00162       *ppv = &m_ImpIClassFactory;
00163
00164     if (NULL != *ppv)
00165     {
00166       // We've handed out a pointer to the interface so obey the COM rules
00167       // and AddRef the reference count.
00168       ((LPUNKNOWN)*ppv)->AddRef();
00169       hr = NOERROR;
00170     }
00171
00172     UnOwnThis();
00173   }
00174
00175   return (hr);
00176 }
00177
00178
00179 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00180   Method:   CFDrawPage::AddRef
00181
00182   Summary:  AddRef of the CFDrawPage non-delegating IUnknown implementation.
00183
00184   Args:     void
00185
00186   Modifies: m_cRefs.
00187
00188   Returns:  ULONG
00189               New value of m_cRefs (COM object's reference count).
00190 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00191 STDMETHODIMP_(ULONG) CFDrawPage::AddRef(void)
00192 {
00193   ULONG cRefs;
00194
00195   if (OwnThis())
00196   {
00197     cRefs = ++m_cRefs;
00198
00199     UnOwnThis();
00200   }
00201
00202   return cRefs;
00203 }
00204
00205
00206 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00207   Method:   CFDrawPage::Release
00208
00209   Summary:  Release of the CFDrawPage non-delegating IUnknown implementation.
00210
00211   Args:     void
00212
00213   Modifies: m_cRefs.
00214
00215   Returns:  ULONG
00216               New value of m_cRefs (COM object's reference count).
00217 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00218 STDMETHODIMP_(ULONG) CFDrawPage::Release(void)
00219 {
00220   ULONG cRefs;
00221
00222   if (OwnThis())
00223   {
00224     cRefs = --m_cRefs;
00225
00226     if (0 == cRefs)
00227     {
00228       // We've reached a zero reference count for this COM object.
00229       // So we tell the server housing to decrement its global object
00230       // count so that the server will be unloaded if appropriate.
00231       if (NULL != m_pServer)
00232         m_pServer->ObjectsDown();
00233
00234       // We artificially bump the main ref count to prevent reentrancy
00235       // via the main object destructor.  Not really needed in this
00236       // CFDrawPage but a good practice because we are aggregatable and
00237       // may at some point in the future add something entertaining like
00238       // some Releases to the CFDrawPage destructor.
00239       m_cRefs++;
00240       UnOwnThis();
00241       delete this;
00242     }
00243     else
00244       UnOwnThis();
00245   }
00246
00247   return cRefs;
00248 }
00249
00250
00251 /*---------------------------------------------------------------------------
00252   CFDrawPage's nested implementation of the IClassFactory interface
00253   including Constructor, Destructor, QueryInterface, AddRef, Release,
00254   CreateInstance, and LockServer methods.
00255 ---------------------------------------------------------------------------*/
00256
00257 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00258   Method:   CFDrawPage::CImpIClassFactory::CImpIClassFactory
00259
00260   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00261
00262   Args:     CFDrawPage* pCO,
00263               Back pointer to the parent outer object.
00264             IUnknown* pUnkOuter,
00265               Pointer to the outer Unknown.  For delegation.
00266             CServer* pServer)
00267               Pointer to the server's control object.
00268
00269   Modifies: m_pCO, m_pUnkOuter, m_pServer.
00270
00271   Returns:  void
00272 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00273 CFDrawPage::CImpIClassFactory::CImpIClassFactory(
00274   CFDrawPage* pCO,
00275   IUnknown* pUnkOuter,
00276   CServer* pServer)
00277 {
00278   // Init the main Object Pointer to point to the parent object.
00279   m_pCO = pCO;
00280
00281   // Init the pointer to the server control object.
00282   m_pServer = pServer;
00283
00284   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00285   // We use the main Object pointer for IUnknown delegation here if we are
00286   // not being aggregated. If we are being aggregated we use the supplied
00287   // pUnkOuter for IUnknown delegation. In either case the pointer
00288   // assignment requires no AddRef because the CImpIClassFactory lifetime
00289   // is quaranteed by the lifetime of the parent object in which
00290   // CImpIClassFactory is nested.
00291   if (NULL == pUnkOuter)
00292     m_pUnkOuter = pCO;
00293   else
00294     m_pUnkOuter = pUnkOuter;
00295
00296   return;
00297 }
00298
00299
00300 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00301   Method:   CFDrawPage::CImpIClassFactory::~CImpIClassFactory
00302
00303   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00304
00305   Args:     void
00306
00307   Returns:  void
00308 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00309 CFDrawPage::CImpIClassFactory::~CImpIClassFactory(void)
00310 {
00311   return;
00312 }
00313
00314
00315 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00316   Method:   CFDrawPage::CImpIClassFactory::QueryInterface
00317
00318   Summary:  The QueryInterface IUnknown member of this IClassFactory
00319             interface implementation that delegates to m_pUnkOuter,
00320             whatever it is.
00321
00322   Args:     REFIID riid,
00323               [in] GUID of the Interface being requested.
00324             PPVOID ppv)
00325               [out] Address of the caller's pointer variable that will
00326               receive the requested interface pointer.
00327
00328   Returns:  HRESULT
00329               Standard result code. NOERROR for success.
00330               Returned by the delegated outer QueryInterface call.
00331 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00332 STDMETHODIMP CFDrawPage::CImpIClassFactory::QueryInterface(
00333                REFIID riid,
00334                PPVOID ppv)
00335 {
00336   // Delegate this call to the outer object's QueryInterface.
00337   return m_pUnkOuter->QueryInterface(riid, ppv);
00338 }
00339
00340
00341 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00342   Method:   CFDrawPage::CImpIClassFactory::AddRef
00343
00344   Summary:  The AddRef IUnknown member of this IClassFactory interface
00345             implementation that delegates to m_pUnkOuter, whatever it is.
00346
00347   Args:     void
00348
00349   Returns:  ULONG
00350               Returned by the delegated outer AddRef call.
00351 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00352 STDMETHODIMP_(ULONG) CFDrawPage::CImpIClassFactory::AddRef(void)
00353 {
00354   // Delegate this call to the outer object's AddRef.
00355   return m_pUnkOuter->AddRef();
00356 }
00357
00358
00359 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00360   Method:   CFDrawPage::CImpIClassFactory::Release
00361
00362   Summary:  The Release IUnknown member of this IClassFactory interface
00363             implementation that delegates to m_pUnkOuter, whatever it is.
00364
00365   Args:     void
00366
00367   Returns:  ULONG
00368               Returned by the delegated outer Release call.
00369 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00370 STDMETHODIMP_(ULONG) CFDrawPage::CImpIClassFactory::Release(void)
00371 {
00372   // Delegate this call to the outer object's Release.
00373   return m_pUnkOuter->Release();
00374 }
00375
00376
00377 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00378   Method:   CFDrawPage::CImpIClassFactory::CreateInstance
00379
00380   Summary:  The CreateInstance member method of this IClassFactory
00381             interface implementation.  Creates an instance of the CODrawPage
00382             COM component.
00383
00384   Args:     IUnknown* pUnkOuter,
00385               [in] Pointer to the controlling IUnknown.
00386             REFIID riid,
00387               [in] GUID of the Interface being requested.
00388             PPVOID ppv)
00389               [out] Address of the caller's pointer variable that will
00390               receive the requested interface pointer.
00391
00392   Returns:  HRESULT
00393               Standard result code. NOERROR for success.
00394 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00395 STDMETHODIMP CFDrawPage::CImpIClassFactory::CreateInstance(
00396                IUnknown* pUnkOuter,
00397                REFIID riid,
00398                PPVOID ppv)
00399 {
00400   HRESULT hr = E_FAIL;
00401   CODrawPage* pCO = NULL;
00402
00403   // NULL the output pointer.
00404   *ppv = NULL;
00405
00406   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00407   // the COM rules state the IUnknown interface MUST also be concomitantly
00408   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00409   // an error must be returned indicating that no aggregate creation of
00410   // the CFDrawPage COM Object can be performed.
00411   if (NULL != pUnkOuter && riid != IID_IUnknown)
00412     hr = CLASS_E_NOAGGREGATION;
00413   else
00414   {
00415     // Instantiate a CODrawPage COM Object.
00416     pCO = new CODrawPage(pUnkOuter, m_pServer);
00417     if (NULL != pCO)
00418     {
00419       // Create and initialize any subordinate objects.
00420       hr = pCO->Init();
00421       if (SUCCEEDED(hr))
00422       {
00423         // We successfully created the new COM object so tell the server
00424         // to increment its global server object count to help ensure
00425         // that the server remains loaded until this partial creation
00426         // of a COM component is completed.
00427         m_pServer->ObjectsUp();
00428
00429         // We QueryInterface this new COM Object not only to deposit the
00430         // main interface pointer to the caller's pointer variable, but to
00431         // also automatically bump the Reference Count on the new COM
00432         // Object after handing out this reference to it.
00433         hr = pCO->QueryInterface(riid, (PPVOID)ppv);
00434         if (FAILED(hr))
00435         {
00436           m_pServer->ObjectsDown();
00437           delete pCO;
00438         }
00439       }
00440       else
00441         delete pCO;
00442     }
00443     else
00444       hr = E_OUTOFMEMORY;
00445   }
00446
00447   return hr;
00448 }
00449
00450
00451 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00452   Method:   CFDrawPage::CImpIClassFactory::LockServer
00453
00454   Summary:  The LockServer member method of this IClassFactory interface
00455             implementation.
00456
00457   Args:     BOOL bLock)
00458               [in] Flag determining whether to Lock or Unlock the server.
00459
00460   Returns:  HRESULT
00461               Standard result code. NOERROR for success.
00462 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00463 STDMETHODIMP CFDrawPage::CImpIClassFactory::LockServer(
00464                BOOL bLock)
00465 {
00466   HRESULT hr = NOERROR;
00467
00468   if (bLock)
00469     m_pServer->Lock();
00470   else
00471     m_pServer->Unlock();
00472
00473   return hr;
00474 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_DOSDTTM Member List

This is the complete list of members for _DOSDTTM, including all inherited members.
day | _DOSDTTM
hours | _DOSDTTM
lDOSDttm | _DOSDTTM
mint | _DOSDTTM
month | _DOSDTTM
S1 | _DOSDTTM
sec | _DOSDTTM
U1 | _DOSDTTM
year | _DOSDTTM
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/Dataobj.h Source File

  • SysMgmt
  • MMC
  • Help

Dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/dlldata.c Source File

  • Web
  • Browser
  • EditHost

dlldata.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 /*********************************************************
00006    DllData file -- generated by MIDL compiler
00007
00008         DO NOT ALTER THIS FILE
00009
00010    This file is regenerated by MIDL on every IDL file compile.
00011
00012    To completely reconstruct this file, delete it and rerun MIDL
00013    on all the IDL files in this DLL, specifying this file for the
00014    /dlldata command line option
00015
00016 *********************************************************/
00017
00018 #define PROXY_DELEGATION
00019
00020 #include <rpcproxy.h>
00021
00022 #ifdef __cplusplus
00023 extern "C"   {
00024 #endif
00025
00026 EXTERN_PROXY_FILE( EdHost )
00027
00028
00029 PROXYFILE_LIST_START
00030 /* Start of list */
00031   REFERENCE_PROXY_FILE( EdHost ),
00032 /* End of list */
00033 PROXYFILE_LIST_END
00034
00035
00036 DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
00037
00038 #ifdef __cplusplus
00039 }  /*extern "C" */
00040 #endif
00041
00042 /* end of generated dlldata file */
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/SimpSvr.h Source File

  • Com
  • Fundamentals
  • SimpSvr

SimpSvr.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: simpsvr.h
00003 //
00004 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00005 //**********************************************************************
00006 #define IDM_ABOUT 100
00007 #define IDM_INSERT  101
00008 #define IDM_VERB0 1000
00009
00010
00011 int PASCAL WinMain(HINSTANCE  hInstance,HINSTANCE  hPrevInstance,LPSTR lpCmdLine,int nCmdShow);
00012 BOOL InitApplication(HINSTANCE  hInstance);
00013 BOOL InitInstance(HINSTANCE  hInstance, int nCmdShow);
00014 //@@WTK WIN32, UNICODE _export EXPORT
00015 long FAR PASCAL EXPORT MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00016 long FAR PASCAL EXPORT DocWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00017 //@@WTK WIN32, UNICODE
00018 //BOOL FAR PASCAL export About(HWND hDlg, unsigned message, WORD wParam, LONG lParam);
00019 BOOL FAR PASCAL EXPORT About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/compdata.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

compdata.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "CompData.h"
00021 #include "DataObj.h"
00022 #include "resource.h"
00023 #include <crtdbg.h>
00024
00025 CComponentData::CComponentData()
00026 : m_cref(0), m_ipConsoleNameSpace(NULL), m_ipConsole(NULL)
00027 {
00028     OBJECT_CREATED
00029
00030         m_pStaticNode = new CStaticNode;
00031 }
00032
00033 CComponentData::~CComponentData()
00034 {
00035     if (m_pStaticNode) {
00036         delete m_pStaticNode;
00037     }
00038
00039     OBJECT_DESTROYED
00040 }
00041
00042 ///////////////////////
00043 // IUnknown implementation
00044 ///////////////////////
00045
00046 STDMETHODIMP CComponentData::QueryInterface(REFIID riid, LPVOID *ppv)
00047 {
00048     if (!ppv)
00049         return E_FAIL;
00050
00051     *ppv = NULL;
00052
00053     if (IsEqualIID(riid, IID_IUnknown))
00054         *ppv = static_cast<IComponentData *>(this);
00055     else if (IsEqualIID(riid, IID_IComponentData))
00056         *ppv = static_cast<IComponentData *>(this);
00057
00058     if (*ppv)
00059     {
00060         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00061         return S_OK;
00062     }
00063
00064     return E_NOINTERFACE;
00065 }
00066
00067 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00068 {
00069     return InterlockedIncrement((LONG *)&m_cref);
00070 }
00071
00072 STDMETHODIMP_(ULONG) CComponentData::Release()
00073 {
00074     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00075     {
00076         // we need to decrement our object count in the DLL
00077         delete this;
00078         return 0;
00079     }
00080
00081     return m_cref;
00082 }
00083
00084 ///////////////////////////////
00085 // Interface IComponentData
00086 ///////////////////////////////
00087 HRESULT CComponentData::Initialize(
00088                                    /* [in] */ LPUNKNOWN pUnknown)
00089 {
00090     HRESULT      hr;
00091
00092     //
00093     // Get pointer to name space interface
00094     //
00095     hr = pUnknown->QueryInterface(IID_IConsoleNameSpace, (void **)&m_ipConsoleNameSpace);
00096     _ASSERT( S_OK == hr );
00097
00098     //
00099     // Get pointer to console interface
00100     //
00101     hr = pUnknown->QueryInterface(IID_IConsole, (void **)&m_ipConsole);
00102     _ASSERT( S_OK == hr );
00103
00104     IImageList *pImageList;
00105     m_ipConsole->QueryScopeImageList(&pImageList);
00106     _ASSERT( S_OK == hr );
00107
00108     hr = pImageList->ImageListSetStrip( (long *)m_pStaticNode->m_pBMapSm, // pointer to a handle
00109         (long *)m_pStaticNode->m_pBMapLg, // pointer to a handle
00110         0, // index of the first image in the strip
00111         RGB(0, 128, 128)  // color of the icon mask
00112         );
00113
00114     pImageList->Release();
00115
00116     return S_OK;
00117 }
00118
00119 HRESULT CComponentData::CreateComponent(
00120                                         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent)
00121 {
00122     *ppComponent = NULL;
00123
00124     CComponent *pComponent = new CComponent(this);
00125
00126     if (NULL == pComponent)
00127         return E_OUTOFMEMORY;
00128
00129     return pComponent->QueryInterface(IID_IComponent, (void **)ppComponent);
00130 }
00131
00132 HRESULT CComponentData::Notify(
00133                                /* [in] */ LPDATAOBJECT lpDataObject,
00134                                /* [in] */ MMC_NOTIFY_TYPE event,
00135                                /* [in] */ LPARAM arg,
00136                                /* [in] */ LPARAM param)
00137 {
00138     MMCN_Crack(TRUE, lpDataObject, this, NULL, event, arg, param);
00139
00140     HRESULT hr = S_FALSE;
00141
00142   //Get our data object. If it is NULL, we return with S_FALSE.
00143   //See implementation of GetOurDataObject() to see how to
00144   //handle special data objects.
00145   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00146   if (NULL == pDataObject)
00147     return S_FALSE;
00148
00149   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00150
00151     switch (event)
00152     {
00153     case MMCN_EXPAND:
00154         hr = base->OnExpand(m_ipConsoleNameSpace, m_ipConsole, (HSCOPEITEM)param);
00155         break;
00156
00157     case MMCN_ADD_IMAGES:
00158         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00159         break;
00160     }
00161
00162     return hr;
00163 }
00164
00165 HRESULT CComponentData::Destroy( void)
00166 {
00167     // Free interfaces
00168     if (m_ipConsoleNameSpace) {
00169         m_ipConsoleNameSpace->Release();
00170         m_ipConsoleNameSpace = NULL;
00171     }
00172
00173     if (m_ipConsole) {
00174         m_ipConsole->Release();
00175         m_ipConsole = NULL;
00176     }
00177
00178     return S_OK;
00179 }
00180
00181 HRESULT CComponentData::QueryDataObject(
00182                                         /* [in] */ MMC_COOKIE cookie,
00183                                         /* [in] */ DATA_OBJECT_TYPES type,
00184                                         /* [out] */ LPDATAOBJECT *ppDataObject)
00185 {
00186     CDataObject *pObj = NULL;
00187
00188     if (cookie == 0)
00189         pObj = new CDataObject((MMC_COOKIE)m_pStaticNode, type);
00190     else
00191         pObj = new CDataObject(cookie, type);
00192
00193     if (!pObj)
00194         return E_OUTOFMEMORY;
00195
00196     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00197
00198     return S_OK;
00199 }
00200
00201 HRESULT CComponentData::GetDisplayInfo(
00202                                        /* [out][in] */ SCOPEDATAITEM *pScopeDataItem)
00203 {
00204     HRESULT hr = S_FALSE;
00205
00206     // if they are asking for the SDI_STR we have one of those to give
00207     if (pScopeDataItem->lParam) {
00208         CDelegationBase *base = (CDelegationBase *)pScopeDataItem->lParam;
00209         if (pScopeDataItem->mask & SDI_STR) {
00210       LPCTSTR pszT = base->GetDisplayName();
00211       MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00212             pScopeDataItem->displayname = pszW;
00213         }
00214
00215         if (pScopeDataItem->mask & SDI_IMAGE) {
00216             pScopeDataItem->nImage = base->GetBitmapIndex();
00217         }
00218     }
00219
00220     return hr;
00221 }
00222
00223 HRESULT CComponentData::CompareObjects(
00224                                        /* [in] */ LPDATAOBJECT lpDataObjectA,
00225                                        /* [in] */ LPDATAOBJECT lpDataObjectB)
00226 {
00227     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00228     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00229
00230     // compare the object pointers
00231     if (baseA->GetCookie() == baseB->GetCookie())
00232         return S_OK;
00233
00234     return S_FALSE;
00235 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAdminNotifyHandler Member List

This is the complete list of members for CAdminNotifyHandler, including all inherited members.
Begin(ULONG uEvent, IDataObject *pArg1, IDataObject *pArg2, ULONG *puFlags, BSTR *pBstr) | CAdminNotifyHandler |
CAdminNotifyHandler() | CAdminNotifyHandler |
End(void) | CAdminNotifyHandler |
Initialize(IDataObject *pExtraInfo, ULONG *puEventFlags) | CAdminNotifyHandler |
m_ObjRefCount | CAdminNotifyHandler | [protected]
m_pdoFrom | CAdminNotifyHandler | [protected]
m_pdoTo | CAdminNotifyHandler | [protected]
Notify(ULONG nItem, ULONG uFlags) | CAdminNotifyHandler |
QueryInterface(REFIID, LPVOID FAR *) | CAdminNotifyHandler |
STDMETHOD_(DWORD, AddRef)() | CAdminNotifyHandler |
STDMETHOD_(DWORD, Release)() | CAdminNotifyHandler |
~CAdminNotifyHandler() | CAdminNotifyHandler |
Generated on Wed Nov 13 2024 16:55:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/RecordCreateOptionsEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

RecordCreateOptionsEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: RecordCreateOptionsEnum
00019
00020 public class RecordCreateOptionsEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final int adCreateCollection = 8192;
00023   public static final int adCreateStructDoc = 0x80000000;
00024   public static final int adCreateNonCollection = 0;
00025   public static final int adOpenIfExists = 33554432;
00026   public static final int adCreateOverwrite = 67108864;
00027   public static final int adFailIfNotExists = -1;
00028 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletCapabilityID Member List

This is the complete list of members for tagAppletCapabilityID, including all inherited members.
eType | tagAppletCapabilityID
nNonStdCap | tagAppletCapabilityID
nStdCap | tagAppletCapabilityID
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/oipObj.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

oipObj.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          OIPObj.cpp
00021
00022   Description:   COleInPlaceObject implementation.
00023
00024 **************************************************************************/
00025
00026 /**************************************************************************
00027 #include statements
00028 **************************************************************************/
00029
00030 #include "OIPObj.h"
00031
00032 /**************************************************************************
00033 global variables
00034 **************************************************************************/
00035
00036 /**************************************************************************
00037
00038   COleInPlaceObject::COleInPlaceObject()
00039
00040 **************************************************************************/
00041
00042 COleInPlaceObject::COleInPlaceObject(COleDocument *pOleDoc)
00043 {
00044   OutputDebugString(TEXT("COleInPlaceObject's constructor\n"));
00045
00046   m_pOleDoc = pOleDoc;
00047 }
00048
00049 /**************************************************************************
00050
00051   COleInPlaceObject::~COleInPlaceObject()
00052
00053 **************************************************************************/
00054
00055 COleInPlaceObject::~COleInPlaceObject()
00056 {
00057   OutputDebugString(TEXT("COleInPlaceObject's destructor\n"));
00058 }
00059
00060 /**************************************************************************
00061
00062   COleInPlaceObject::QueryInterface()
00063
00064 **************************************************************************/
00065
00066 STDMETHODIMP COleInPlaceObject::QueryInterface(REFIID riid, LPVOID *ppReturn)
00067 {
00068   OutputDebugString(TEXT("COleInPlaceObject::QueryInterface\n"));
00069
00070   return m_pOleDoc->QueryInterface(riid, ppReturn);
00071 }
00072
00073 /**************************************************************************
00074
00075   COleInPlaceObject::AddRef()
00076
00077 **************************************************************************/
00078
00079 STDMETHODIMP_(ULONG) COleInPlaceObject::AddRef()
00080 {
00081   OutputDebugString(TEXT("COleInPlaceObject::AddRef\n"));
00082
00083   return m_pOleDoc->AddRef();
00084 }
00085
00086 /**************************************************************************
00087
00088   COleInPlaceObject::Release()
00089
00090 **************************************************************************/
00091
00092 STDMETHODIMP_(ULONG) COleInPlaceObject::Release()
00093 {
00094   OutputDebugString(TEXT("COleInPlaceObject::Release\n"));
00095
00096   return m_pOleDoc->Release();
00097 }
00098
00099 /**************************************************************************
00100
00101   COleInPlaceObject::InPlaceDeactivate()
00102
00103 **************************************************************************/
00104
00105 STDMETHODIMP COleInPlaceObject::InPlaceDeactivate()
00106 {
00107   OutputDebugString(TEXT("COleInPlaceObject::InPlaceDeactivate\n"));
00108
00109   return m_pOleDoc->DeactivateInPlace();
00110 }
00111
00112 /**************************************************************************
00113
00114   COleInPlaceObject::UIDeactivate()
00115
00116 **************************************************************************/
00117
00118 STDMETHODIMP COleInPlaceObject::UIDeactivate()
00119 {
00120   OutputDebugString(TEXT("COleInPlaceObject::UIDeactivate\n"));
00121
00122   return m_pOleDoc->DeactivateUI();
00123 }
00124
00125 /**************************************************************************
00126
00127   COleInPlaceObject::SetObjectRects()
00128
00129 **************************************************************************/
00130
00131 STDMETHODIMP COleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
00132 {
00133   UNREFERENCED_PARAMETER(lprcPosRect);
00134   UNREFERENCED_PARAMETER(lprcClipRect);
00135   OutputDebugString(TEXT("COleInPlaceObject::SetObjectRects\n"));
00136
00137   return S_OK;
00138 }
00139
00140 /**************************************************************************
00141
00142   COleInPlaceObject::GetWindow()
00143
00144 **************************************************************************/
00145
00146 STDMETHODIMP COleInPlaceObject::GetWindow(HWND *phwnd)
00147 {
00148   OutputDebugString(TEXT("COleInPlaceObject::GetWindow\n"));
00149
00150   return m_pOleDoc->GetWindow(phwnd);
00151 }
00152
00153 /**************************************************************************
00154
00155   COleInPlaceObject::ContextSensitiveHelp()
00156
00157 **************************************************************************/
00158
00159 STDMETHODIMP COleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
00160 {
00161   UNREFERENCED_PARAMETER(fEnterMode);
00162   OutputDebugString(TEXT("COleInPlaceObject::ContextSensitiveHelp\n"));
00163
00164   return E_NOTIMPL;
00165 }
00166
00167 /**************************************************************************
00168
00169   COleInPlaceObject::ReactivateAndUndo()
00170
00171 **************************************************************************/
00172
00173 STDMETHODIMP COleInPlaceObject::ReactivateAndUndo()
00174 {
00175   OutputDebugString(TEXT("COleInPlaceObject::ReactivateAndUndo\n"));
00176
00177   return INPLACE_E_NOTUNDOABLE;
00178 }
00179
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/First/vc/First.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • First
  • vc

First.cpp

Go to the documentation of this file.
00001 // First.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "activeds.h"
00006
00007 int main(int argc, char* argv[])
00008 {
00009   HRESULT hr;
00010   IADsContainer *pCont;
00011
00012   CoInitialize(NULL);
00013
00014   hr = ADsGetObject(L"WinNT://YOURDOMAIN", IID_IADsContainer, (void**) &pCont );
00015
00016   if ( !SUCCEEDED(hr) )
00017   {
00018     return 0;
00019   }
00020
00021   //----------------------------
00022   // Creating a user
00023   //-----------------------------
00024   IDispatch *pDisp=NULL;
00025   IADs *pUser;
00026   hr = pCont->Create( L"user", L"jsmith", &pDisp );
00027   pCont->Release();
00028
00029   if ( !SUCCEEDED(hr) )
00030   {
00031     return 0;
00032   }
00033
00034   hr = pDisp->QueryInterface( IID_IADs, (void**) &pUser );
00035     pDisp->Release();
00036
00037   if ( !SUCCEEDED(hr) )
00038   {
00039     return 0;
00040   }
00041
00042
00043
00044   // Commit creation to the directory
00045   pUser->SetInfo();
00046
00047   // Release the object
00048   pUser->Release();
00049
00050
00051   CoUninitialize();
00052
00053   return 0;
00054 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EdAnnotator/AnnotatorProject/resource.h Source File

  • Web
  • Browser
  • EdAnnotator
  • AnnotatorProject

resource.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 //{{NO_DEPENDENCIES}}
00006 // Microsoft Developer Studio generated include file.
00007 // Used by EDAnnotator.rc
00008 //
00009 #define IDS_PROJNAME                    100
00010 #define IDB_ANNOTATOR                   101
00011 #define IDR_ANNOTATOR                   102
00012
00013 // Next default values for new objects
00014 //
00015 #ifdef APSTUDIO_INVOKED
00016 #ifndef APSTUDIO_READONLY_SYMBOLS
00017 #define _APS_NEXT_RESOURCE_VALUE        201
00018 #define _APS_NEXT_COMMAND_VALUE         32768
00019 #define _APS_NEXT_CONTROL_VALUE         201
00020 #define _APS_NEXT_SYMED_VALUE           103
00021 #endif
00022 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/dataobj.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

dataobj.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _CLASS_CDATAOBJECT_
00015 #define _CLASS_CDATAOBJECT_
00016
00017 #include "Globals.h"
00018 #include "StaticNode.h"
00019
00020 //---------------------------------------------------------------------------
00021 class CDataObject : public IDataObject
00022 {
00023   private:
00024     ULONG     m_cRef;
00025     LONG_PTR  m_uCookie;
00026     ULONG     m_uContext;
00027
00028   public:
00029     CDataObject();
00030     ~CDataObject();
00031
00032   public:  // Interface IUnknown
00033     STDMETHODIMP QueryInterface( REFIID riid, LPVOID* ppv );
00034     STDMETHODIMP_(ULONG) AddRef();
00035     STDMETHODIMP_(ULONG) Release();
00036
00037   public:  // IDataObject methods
00038     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00039
00040     // The rest are not implemented
00041     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00042     { return E_NOTIMPL; };
00043
00044     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00045     { return E_NOTIMPL; };
00046
00047     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00048     { return E_NOTIMPL; };
00049
00050     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00051     { return E_NOTIMPL; };
00052
00053     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00054     { return E_NOTIMPL; };
00055
00056     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00057     { return E_NOTIMPL; };
00058
00059     STDMETHODIMP DUnadvise (DWORD dwConnection)
00060     { return E_NOTIMPL; };
00061
00062     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00063     { return E_NOTIMPL; };
00064
00065   ///////////////////////////////////////////////////////////////////////////
00066   // Custom Methods
00067   public:
00068     VOID   SetPrivateData( LONG_PTR uCookie, ULONG uContext );
00069
00070     // For future use, not used in this sample
00071     ULONG  GetContext() { return m_uContext; }
00072     ULONG  GetCookie()  { return m_uCookie;  }
00073
00074   ///////////////////////////////////////////////////////////////////////////
00075   // Handlers for required clipboard formats
00076   private:
00077     HRESULT  RetrieveDisplayString( IStream* ipStream );
00078     HRESULT  RetrieveSnapInClassID( IStream* ipStream );
00079     HRESULT  RetrieveNodeTypeGuid( IStream* ipStream );
00080     HRESULT  RetrieveGuidString( IStream* ipStream );
00081     HRESULT  RetrieveBaseNodePtr( IStream* ipStream );
00082     HRESULT  RetrieveDataObjPtr( IStream* ipStream );
00083
00084 };
00085
00086 #endif //_CLASS_CDATAOBJECT_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmDebug/StdAfx.h Source File

  • Com
  • Services
  • Crm
  • CrmDebug

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__FA796168_D8B0_11D1_AB85_00A0C91EEDE9__INCLUDED_)
00006 #define AFX_STDAFX_H__FA796168_D8B0_11D1_AB85_00A0C91EEDE9__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #if !defined(_WIN32_WINNT)
00016 #define _WIN32_WINNT 0x0500
00017 #endif // !defined(_WIN32_WINNT)
00018
00019 #define _ATL_APARTMENT_THREADED
00020
00021
00022 #include <atlbase.h>
00023 //You may derive a class from CComModule and use it if you want to override
00024 //something, but do not change the name of _Module
00025 extern CComModule _Module;
00026 #include <atlcom.h>
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00030
00031 #endif // !defined(AFX_STDAFX_H__FA796168_D8B0_11D1_AB85_00A0C91EEDE9__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/statnode.h Source File

  • SysMgmt
  • MMC
  • Nodes

statnode.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SNAPINBASE_H
00021 #define _SNAPINBASE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CStaticNode : public CDelegationBase {
00026 public:
00027     CStaticNode();
00028
00029     virtual ~CStaticNode();
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) {
00032         static _TCHAR szDisplayName[256];
00033         LoadString(g_hinst, IDS_SNAPINNAME, szDisplayName, (sizeof szDisplayName)/(sizeof szDisplayName[0]));
00034         return szDisplayName;
00035     }
00036     virtual const GUID & getNodeType() { return thisGuid; }
00037     virtual const int GetBitmapIndex() { return INDEX_NONE; }
00038
00039 public:
00040     // virtual functions go here (for MMCN_*)
00041     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00042
00043 private:
00044     enum { NUMBER_OF_CHILDREN = 5 };
00045     CDelegationBase *children[NUMBER_OF_CHILDREN];
00046
00047     // {2974380C-4C4B-11d2-89D8-000021473128}
00048     static const GUID thisGuid;
00049 };
00050
00051
00052
00053 #endif // _SNAPINBASE_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/TSSysInf/Client/SysInf_C.c Source File

  • WinBase
  • WtsApi
  • TSSysInf
  • Client

SysInf_C.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright 1998 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sysinf_c.c
00008
00009 Abstract:
00010
00011     This file contains the code for the client-side DLL to demonstrate the
00012     Virtual Channels feature on Windows Terminal Services.
00013
00014     The server-side app sends a request to the client DLL for one of two
00015     possible types of packet: TSVERSIONINFO or TSMEMORYINFO.  This wakes up a
00016     worker thread which writes the requested packet to the virtual channel.
00017
00018     The client DLL cleans up when the client is terminated.  The worker thread
00019     is signaled to stop, if it doesn't stop within 5 seconds, it is terminated.
00020
00021 Author:
00022
00023     Frank Kim (franki)    18-Mar-99
00024
00025 --*/
00026
00027 #define TSDLL
00028
00029 #include "sysinfo.h"
00030
00031
00032 void DisplayError(LPTSTR pszAPI)
00033 {
00034     int    i;
00035     LPVOID lpvMessageBuffer;
00036     TCHAR  buffer[256] = TEXT("");
00037     DWORD  lastErr;
00038
00039     lastErr = GetLastError();
00040
00041     FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00042                   NULL, lastErr,
00043                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00044                   (LPTSTR)&lpvMessageBuffer, 0, NULL);
00045
00046     //
00047     //... now display this string
00048     //
00049     i = wsprintf(buffer,      TEXT("SYSINF_C ERROR: API        = %s.\n"), pszAPI);
00050     i += wsprintf(buffer + i, TEXT("                error code = %u.\n"), lastErr);
00051     wsprintf(buffer + i,      TEXT("                message    = %s.\n"), (LPTSTR)lpvMessageBuffer);
00052
00053     OutputDebugString(buffer);
00054
00055     //
00056     // Free the buffer allocated by the system
00057     //
00058     LocalFree(lpvMessageBuffer);
00059 }
00060
00061
00062 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
00063 {
00064 UNREFERENCED_PARAMETER(lpvReserved);
00065 UNREFERENCED_PARAMETER(hinstDLL);
00066
00067     switch(fdwReason)
00068     {
00069         case DLL_PROCESS_ATTACH:
00070             OutputDebugString(TEXT("SYSINF_C: process attach\n"));
00071             break;
00072
00073         case DLL_THREAD_ATTACH:
00074             OutputDebugString(TEXT("SYSINF_C: thread attach\n"));
00075             break;
00076
00077         case DLL_THREAD_DETACH:
00078             OutputDebugString(TEXT("SYSINF_C: thread detach\n"));
00079             break;
00080
00081         case DLL_PROCESS_DETACH:
00082             OutputDebugString(TEXT("SYSINF_C: process detach\n"));
00083             break;
00084
00085         default:
00086             OutputDebugString(TEXT("SYSINF_C: Unknown reason in DllMain\n"));
00087             break;
00088     }
00089     return TRUE;
00090 }
00091
00092
00093 void WaitForTheWrite(HANDLE hEvent)
00094 {
00095     OutputDebugString(TEXT("SYSINF_C: worker thread waiting for write to complete\n"));
00096
00097     if (!WaitForSingleObject(hEvent, INFINITE) == WAIT_FAILED)
00098         DisplayError(TEXT("WaitForSingleObject"));
00099 }
00100
00101
00102 void GetMemoryInfo(void)
00103 {
00104     DWORD        dwControlCode = TSMEMORYINFO;
00105     MEMORYSTATUS ms;
00106     UINT         ui;
00107
00108     OutputDebugString(TEXT("SYSINF_C: worker thread get memory info\n"));
00109
00110     GlobalMemoryStatus(&ms);
00111
00112     //
00113     // write memory info to channel
00114     //
00115     ui = gpEntryPoints->pVirtualChannelWrite(gdwOpenChannel,
00116                                              (LPVOID)&ms,
00117                                              sizeof(ms),
00118                                              (LPVOID)&dwControlCode);
00119     if (ui != CHANNEL_RC_OK)
00120         OutputDebugString(TEXT("SYSINF_C: worker thread VirtualChannelWrite failed\n"));
00121
00122     //
00123     // wait for the write to complete
00124     //
00125     WaitForTheWrite(ghWriteEvent);
00126 }
00127
00128
00129 void GetVersionInfo(void)
00130 {
00131     TS_VERSION_INFO tsvi;
00132     OSVERSIONINFO   osvi;
00133     UINT            ui;
00134     DWORD           dwControlCode = TSVERSIONINFO;
00135     SYSTEM_INFO     si;
00136     TCHAR           szUserName[UNLEN+1];
00137     TCHAR           szComputerName[MAX_COMPUTERNAME_LENGTH+1];
00138     DWORD           dwSize;
00139
00140     OutputDebugString(TEXT("SYSINF_C: worker thread get version info\n"));
00141
00142     //
00143     // obtain version info
00144     //
00145     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00146
00147     if (!GetVersionEx(&osvi))
00148         DisplayError(TEXT("GetVersionEx"));
00149
00150     ZeroMemory(&tsvi, sizeof(tsvi));
00151     tsvi.osvi = osvi;
00152
00153     //
00154     // get the client name
00155     //
00156     strcpy(tsvi.szClientName, gszClientName);
00157
00158     //
00159     // get the computer name
00160     //
00161     dwSize = sizeof(szComputerName);
00162     ZeroMemory(szComputerName, dwSize);
00163
00164     if (!GetComputerName(szComputerName, &dwSize))
00165         DisplayError(TEXT("GetComputerName"));
00166
00167     lstrcpy(tsvi.szComputerName, szComputerName);
00168
00169     //
00170     // get system info
00171     //
00172     GetSystemInfo(&si);
00173
00174     tsvi.si = si;
00175
00176     //
00177     // get user name
00178     //
00179     dwSize = sizeof(szUserName);
00180     if (!GetUserName(szUserName, &dwSize))
00181         DisplayError(TEXT("GetUserName"));
00182
00183     lstrcpy(tsvi.szUserName, szUserName);
00184
00185     //
00186     // write memory info to channel
00187     //
00188     ui = gpEntryPoints->pVirtualChannelWrite(gdwOpenChannel,
00189                                              (LPVOID)&tsvi,
00190                                              sizeof(tsvi),
00191                                              (LPVOID)&dwControlCode);
00192     if (ui != CHANNEL_RC_OK)
00193         OutputDebugString(TEXT("SYSINF_C: worker thread VirtualChannelWrite failed\n"));
00194
00195     //
00196     // wait for the write to complete
00197     //
00198     WaitForTheWrite(ghWriteEvent);
00199 }
00200
00201
00202 void WINAPI WorkerThread(void)
00203 {
00204     DWORD  dw;
00205     DWORD  dwControlCode;
00206     HANDLE hEventConnect[2]; // 0 stop, 1 alert
00207     BOOL   bDone = FALSE;
00208
00209     hEventConnect[0] = ghStopThread;
00210     hEventConnect[1] = ghAlertThread;
00211
00212     while( !bDone ) {
00213
00214         OutputDebugString(TEXT("SYSINF_C: worker thread waiting...\n"));
00215
00216         dw = WaitForMultipleObjects(2, hEventConnect, FALSE, INFINITE);
00217
00218         switch(dw)
00219         {
00220             case WAIT_FAILED:
00221             {
00222                 DisplayError(TEXT("WaitForMultipleObjects"));
00223             }
00224             break;
00225
00226             case WAIT_OBJECT_0:
00227             {
00228                 bDone = TRUE;
00229             }
00230             break;
00231
00232             case WAIT_OBJECT_0 + 1:
00233             {
00234                 OutputDebugString(TEXT("SYSINF_C: worker thread wakeup\n"));
00235
00236                 dwControlCode = gdwControlCode;
00237
00238                 //
00239                 // signal
00240                 //
00241                 if (!SetEvent(ghSynchCodeEvent))
00242                     DisplayError(TEXT("SetEvent"));
00243
00244                 if (dwControlCode == TSMEMORYINFO)
00245                     GetMemoryInfo();
00246                 else
00247                     GetVersionInfo();
00248             }
00249             break;
00250
00251             default:
00252             {
00253                 OutputDebugString(TEXT("SYSINF_C: worker thread - unknown wait rc\n"));
00254             }
00255             break;
00256         }
00257     }
00258
00259     OutputDebugString(TEXT("SYSINF_C: worker thread ending\n"));
00260
00261     ExitThread(0);
00262 }
00263
00264
00265 void WINAPI VirtualChannelOpenEvent(DWORD openHandle, UINT event, LPVOID pdata, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
00266 {
00267     LPDWORD pdwControlCode = (LPDWORD)pdata;
00268
00269     UNREFERENCED_PARAMETER(openHandle);
00270     UNREFERENCED_PARAMETER(dataFlags);
00271
00272     if (dataLength == totalLength){
00273         switch(event)
00274         {
00275             case CHANNEL_EVENT_DATA_RECEIVED:
00276             {
00277                 //
00278                 // initialize
00279                 //
00280                 gdwControlCode = *pdwControlCode;
00281
00282                 //
00283                 // initiate a write
00284                 //
00285                 if (!SetEvent(ghAlertThread))
00286                     DisplayError(TEXT("SetEvent"));
00287                 else
00288                     OutputDebugString(TEXT("SYSINF_C: signal to wake up thread\n"));
00289
00290                 //
00291                 // wait for worker thread to read control
00292                 //
00293                 if (WaitForSingleObject(ghSynchCodeEvent, INFINITE) == WAIT_FAILED)
00294                     DisplayError(TEXT("WaitForSingleObject"));
00295             }
00296             break;
00297
00298             case CHANNEL_EVENT_WRITE_COMPLETE:
00299             {
00300                 switch (*pdwControlCode)
00301                 {
00302                     case TSMEMORYINFO:
00303                         OutputDebugString(TEXT("SYSINF_C: write completed for memory info\n"));
00304                         break;
00305
00306                     case TSVERSIONINFO:
00307                         OutputDebugString(TEXT("SYSINF_C: write completed for version info\n"));
00308                         break;
00309
00310                     default:
00311                         OutputDebugString(TEXT("SYSINF_C: write completed for UNKNOWN\n"));
00312                         break;
00313                 }
00314
00315                 //
00316                 // set event to notify write is complete
00317                 //
00318                 if (!SetEvent(ghWriteEvent))
00319                     DisplayError(TEXT("SetEvent"));
00320             }
00321             break;
00322
00323             case CHANNEL_EVENT_WRITE_CANCELLED:
00324             {
00325                 //
00326                 // set event to notify write is complete since write was cancelled
00327                 //
00328                 if (!SetEvent(ghWriteEvent))
00329                     DisplayError(TEXT("SetEvent"));
00330             }
00331             break;
00332
00333             default:
00334             {
00335                 OutputDebugString(TEXT("SYSINF_C: unrecognized open event\n"));
00336             }
00337             break;
00338         }
00339     }
00340     else
00341         OutputDebugString(TEXT("SYSINF_C: data is broken up\n"));
00342 }
00343
00344
00345 VOID VCAPITYPE VirtualChannelInitEventProc(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength)
00346 {
00347     DWORD dwThreadId;
00348     UINT  ui;
00349
00350     UNREFERENCED_PARAMETER(pInitHandle);
00351     UNREFERENCED_PARAMETER(dataLength);
00352
00353     switch(event)
00354     {
00355         case CHANNEL_EVENT_INITIALIZED:
00356         {
00357             OutputDebugString(TEXT("SYSINF_C: channel initialized\n"));
00358         }
00359         break;
00360
00361         case CHANNEL_EVENT_CONNECTED:
00362         {
00363             //
00364             // save client machine
00365             //
00366             ZeroMemory(gszClientName, sizeof(gszClientName));
00367             strcpy(gszClientName, (LPSTR)pData);
00368
00369             OutputDebugString(TEXT("SYSINF_C: channel connected\n"));
00370
00371             //
00372             // open channel
00373             //
00374             ui = gpEntryPoints->pVirtualChannelOpen(gphChannel,
00375                                                     &gdwOpenChannel,
00376                                                     CHANNELNAME,
00377                                                     (PCHANNEL_OPEN_EVENT_FN)VirtualChannelOpenEvent);
00378             if (ui != CHANNEL_RC_OK){
00379                 OutputDebugString(TEXT("SYSINF_C: virtual channel open failed\n"));
00380                 return;
00381             }
00382
00383             //
00384             // create write completion event
00385             //
00386             ghWriteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00387             if (ghWriteEvent == NULL)
00388                 DisplayError(TEXT("CreateEvent"));
00389
00390             //
00391             // create thread wakeup event
00392             //
00393             ghAlertThread = CreateEvent(NULL, FALSE, FALSE, NULL);
00394             if (ghAlertThread == NULL)
00395                 DisplayError(TEXT("CreateEvent"));
00396
00397             //
00398             // create thread stop event
00399             //
00400             ghStopThread = CreateEvent(NULL, FALSE, FALSE, NULL);
00401             if (ghStopThread == NULL)
00402                 DisplayError(TEXT("CreateEvent"));
00403
00404             //
00405             // create thread synch event
00406             //
00407             ghSynchCodeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00408             if (ghSynchCodeEvent == NULL)
00409                 DisplayError(TEXT("CreateEvent"));
00410
00411             //
00412             // spawn the worker thread
00413             //
00414             ghThread = CreateThread(NULL,
00415                                     0,
00416                                     (LPTHREAD_START_ROUTINE)WorkerThread,
00417                                     NULL,
00418                                     0,
00419                                     &dwThreadId);
00420             if (ghThread == NULL)
00421                 DisplayError(TEXT("CreateThread"));
00422         }
00423         break;
00424
00425         case CHANNEL_EVENT_V1_CONNECTED:
00426         {
00427             OutputDebugString(TEXT("SYSINF_C: v1 connected\n"));
00428             MessageBox(NULL,
00429                        TEXT("Connecting to a non Windows 2000 Terminal Server"),
00430                        TEXT("sysinf_c.dll"),
00431                        MB_OK);
00432         }
00433         break;
00434
00435         case CHANNEL_EVENT_DISCONNECTED:
00436         {
00437             DWORD dw;
00438
00439             OutputDebugString(TEXT("SYSINF_C: disconnected\n"));
00440
00441             //
00442             // signal worker thread to end
00443             //
00444             if (!SetEvent(ghStopThread))
00445                 DisplayError(TEXT("SetEvent"));
00446
00447             //
00448             // wait for thread to die
00449             //
00450             dw = WaitForSingleObject(ghThread, 5000);
00451
00452             switch(dw)
00453             {
00454                 case WAIT_TIMEOUT:
00455                     //
00456                     // blow away thread since time expired
00457                     //
00458                     OutputDebugString(TEXT("SYSINF_C: blowing away worker thread\n"));
00459                     if (!TerminateThread(ghThread, 0))
00460                         DisplayError(TEXT("TerminateThread"));
00461                     break;
00462
00463                 case WAIT_FAILED:
00464                     DisplayError(TEXT("WaitForSingleObject"));
00465                     break;
00466                 default:
00467                     break;
00468             }
00469
00470             OutputDebugString(TEXT("SYSINF_C: worker thread terminated\n"));
00471
00472             //
00473             // close handles
00474             //
00475             CloseHandle(ghStopThread);
00476             CloseHandle(ghAlertThread);
00477             CloseHandle(ghWriteEvent);
00478             CloseHandle(ghSynchCodeEvent);
00479         }
00480         break;
00481
00482         case CHANNEL_EVENT_TERMINATED:
00483         {
00484             OutputDebugString(TEXT("SYSINF_C: client terminated\n"));
00485             //
00486             // free the entry points table
00487             //
00488             LocalFree((HLOCAL)gpEntryPoints);
00489         }
00490         break;
00491
00492         default:
00493         {
00494             OutputDebugString(TEXT("SYSINF_C: unrecognized init event\n"));
00495         }
00496         break;
00497     }
00498 }
00499
00500
00501 BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
00502 {
00503     CHANNEL_DEF cd;
00504     UINT        uRet;
00505
00506     OutputDebugString(TEXT("SYSINF_C: virtualchannelentry called\n"));
00507
00508     //
00509     // allocate memory
00510     //
00511     gpEntryPoints = LocalAlloc(LPTR, pEntryPoints->cbSize);
00512     if (gpEntryPoints == NULL)
00513         DisplayError(TEXT("LocalAlloc"));
00514
00515     memcpy(gpEntryPoints, pEntryPoints, pEntryPoints->cbSize);
00516
00517     //
00518     // initialize global
00519     //
00520     //gpEntryPoints = pEntryPoints;
00521
00522     //
00523     // initialize CHANNEL_DEF structure
00524     //
00525     ZeroMemory(&cd, sizeof(CHANNEL_DEF));
00526     strcpy(cd.name, CHANNELNAME); // ANSI ONLY
00527
00528     //
00529     // register channel
00530     //
00531     uRet = gpEntryPoints->pVirtualChannelInit((LPVOID *)&gphChannel,
00532                                               (PCHANNEL_DEF)&cd, 1,
00533                                               VIRTUAL_CHANNEL_VERSION_WIN2000,
00534                                               (PCHANNEL_INIT_EVENT_FN)VirtualChannelInitEventProc);
00535     if (uRet != CHANNEL_RC_OK)
00536         return FALSE;
00537
00538     //
00539     // make sure channel was initialized
00540     //
00541     if (cd.options != CHANNEL_OPTION_INITIALIZED)
00542         return FALSE;
00543
00544     return TRUE;
00545 }
00546
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DragImg/Dragsrc.h Source File

  • WinUI
  • Shell
  • DragImg

Dragsrc.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          DragSrc.h
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 #ifndef DRAGSRC_H
00019 #define DRAGSRC_H
00020
00021 /**************************************************************************
00022    #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <ole2.h>
00027
00028 /**************************************************************************
00029    class definitions
00030 **************************************************************************/
00031
00032 class CDragSource : public IDropSource
00033 {
00034 private:
00035    DWORD m_cRefCount;
00036
00037 public:
00038    CDragSource();
00039    ~CDragSource();
00040
00041    //IUnknown members
00042    STDMETHOD(QueryInterface)(REFIID, LPVOID*);
00043    STDMETHOD_(ULONG, AddRef)(void);
00044    STDMETHOD_(ULONG, Release)(void);
00045
00046    //IDataObject members
00047    STDMETHOD(GiveFeedback)(DWORD);
00048    STDMETHOD(QueryContinueDrag)(BOOL, DWORD);
00049 };
00050
00051 #endif   //DRAGSRC_H
00052
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step1/ADsFirstExt.idl Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step1

ADsFirstExt.idl

Go to the documentation of this file.
00001 // ADsFirstExt.idl : IDL source for ADsFirstExt.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (ADsFirstExt.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009
00010
00011   [
00012     object,
00013     uuid(E1E3EDF7-48D1-11D2-B22B-0000F87A6B50),
00014     dual,
00015     helpstring("IHelloWorld Interface"),
00016     pointer_default(unique)
00017   ]
00018   interface IHelloWorld : IDispatch
00019   {
00020     [id(1), helpstring("method Say")] HRESULT Say();
00021   };
00022
00023 [
00024   uuid(E1E3EDEA-48D1-11D2-B22B-0000F87A6B50),
00025   version(1.0),
00026   helpstring("ADsFirstExt 1.0 Type Library")
00027 ]
00028 library ADSFIRSTEXTLib
00029 {
00030   importlib("stdole32.tlb");
00031   importlib("stdole2.tlb");
00032
00033
00034   [
00035     uuid(E1E3EDF8-48D1-11D2-B22B-0000F87A6B50),
00036     helpstring("HelloWorld Class")
00037   ]
00038   coclass HelloWorld
00039   {
00040     [default] interface IHelloWorld;
00041   };
00042 };
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • CutCopy

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030         static TCHAR error[64];
00031
00032         switch (verb) {
00033     case MMC_VERB_NONE:
00034                 return _T("NONE");
00035     case MMC_VERB_OPEN:
00036                 return _T("OPEN");
00037     case MMC_VERB_COPY:
00038                 return _T("COPY");
00039     case MMC_VERB_PASTE:
00040                 return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042                 return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044                 return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046                 return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048                 return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050                 return _T("PRINT");
00051     case MMC_VERB_CUT:
00052                 return _T("CUT");
00053         default:
00054                 wsprintf(error, _T("Unknown verb id %d"), verb);
00055                 return error;
00056         }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061                                 IComponentData *pCompData,
00062                                 IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064                                 LPARAM arg,
00065                                 LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069         TCHAR message[cchMessage] = {0};
00070
00071         if (bComponentData == TRUE)
00072                 OutputDebugString(_T("IComponentData::Notify( "));
00073         else
00074                 OutputDebugString(_T("IComponent::Notify( "));
00075
00076         wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077         OutputDebugString(message);
00078
00079     switch (event)      {
00080                 case MMCN_ACTIVATE:
00081                         wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082                         break;
00083
00084                 case MMCN_ADD_IMAGES:
00085                         wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086                         break;
00087
00088                 case MMCN_BTN_CLICK:
00089                         wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090                         break;
00091
00092                 case MMCN_COLUMN_CLICK:
00093                         wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,       param);
00094                         break;
00095
00096                 case MMCN_COLUMNS_CHANGED:
00097                         wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098                         break;
00099
00100                 case MMCN_CONTEXTHELP:
00101                         wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102                         break;
00103
00104                 case MMCN_CONTEXTMENU:
00105                         wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106                         break;
00107
00108                 case MMCN_CUTORMOVE:
00109                         wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110                         break;
00111
00112                 case MMCN_DBLCLICK:
00113                         wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114                         break;
00115
00116                 case MMCN_DELETE:
00117                         wsprintf(message, _T("MMCN_DELETE\n"));
00118                         break;
00119
00120                 case MMCN_DESELECT_ALL:
00121                         wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122                         break;
00123
00124                 case MMCN_EXPAND:
00125                         wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126                         break;
00127
00128                 case MMCN_EXPANDSYNC:
00129                         wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130                         break;
00131
00132                 case MMCN_FILTERBTN_CLICK:
00133                         wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134                         break;
00135
00136                 case MMCN_FILTER_CHANGE:
00137                         wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138                         break;
00139
00140                 case MMCN_HELP:
00141                         wsprintf(message, _T("MMCN_HELP\n"));
00142                         break;
00143
00144                 case MMCN_INITOCX:
00145                         wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146                         break;
00147
00148                 case MMCN_LISTPAD:
00149                         wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150                         break;
00151
00152                 case MMCN_MENU_BTNCLICK:
00153                         wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154                         break;
00155
00156                 case MMCN_MINIMIZED:
00157                         wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158                         break;
00159
00160                 case MMCN_PASTE:
00161                         wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162                         break;
00163
00164                 case MMCN_PRELOAD:
00165                         wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166                         break;
00167
00168                 case MMCN_PRINT:
00169                         wsprintf(message, _T("MMCN_PRINT\n"));
00170                         break;
00171
00172                 case MMCN_PROPERTY_CHANGE:
00173                         wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174                         break;
00175
00176                 case MMCN_QUERY_PASTE:
00177                         wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178                         break;
00179
00180                 case MMCN_REFRESH:
00181                         wsprintf(message, _T("MMCN_REFRESH\n"));
00182                         break;
00183
00184                 case MMCN_REMOVE_CHILDREN:
00185                         wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186                         break;
00187
00188                 case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192                         StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193                         break;
00194
00195                 case MMCN_RESTORE_VIEW:
00196                         wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197                         break;
00198
00199                 case MMCN_SELECT:
00200                         wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201                         break;
00202
00203                 case MMCN_SHOW:
00204                         wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205                         break;
00206
00207                 case MMCN_SNAPINHELP:
00208                         wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209                         break;
00210
00211                 case MMCN_VIEW_CHANGE:
00212                         wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213                         break;
00214         }
00215
00216         if (message[0] != 0)
00217                 OutputDebugString(message);
00218         else
00219                 OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222         return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/SdiDoc.Cpp Source File

  • NetDS
  • fax
  • PrintSdi

SdiDoc.Cpp

Go to the documentation of this file.
00001 // PrintSDIDoc.cpp : implementation of the CPrintSDIDoc class
00002 //
00003
00004 #include "stdafx.h"
00005 #include "PrintSDI.h"
00006
00007 #include "PrintSDIDoc.h"
00008 #include "newdocdlg.h"
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // CPrintSDIDoc
00018
00019 IMPLEMENT_DYNCREATE(CPrintSDIDoc, CDocument)
00020
00021 BEGIN_MESSAGE_MAP(CPrintSDIDoc, CDocument)
00022   //{{AFX_MSG_MAP(CPrintSDIDoc)
00023     // NOTE - the ClassWizard will add and remove mapping macros here.
00024     //    DO NOT EDIT what you see in these blocks of generated code!
00025   //}}AFX_MSG_MAP
00026 END_MESSAGE_MAP()
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CPrintSDIDoc construction/destruction
00030
00031 CPrintSDIDoc::CPrintSDIDoc()
00032 {
00033   m_szText.Empty();
00034   m_polytype = 0;
00035
00036 }
00037
00038 CPrintSDIDoc::~CPrintSDIDoc()
00039 {
00040 }
00041
00042 BOOL CPrintSDIDoc::OnNewDocument()
00043 {
00044   if (!CDocument::OnNewDocument())
00045     return FALSE;
00046
00047   NewDocDlg newdlg;
00048   newdlg.DoModal();
00049   m_szText = newdlg.m_szText;
00050
00051   m_polytype = newdlg.m_polytype;
00052
00053   return TRUE;
00054 }
00055
00056
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // CPrintSDIDoc serialization
00060
00061 void CPrintSDIDoc::Serialize(CArchive& ar)
00062 {
00063   if (ar.IsStoring())
00064   {
00065     ar << m_szText;
00066         ar << m_polytype;
00067   }
00068   else
00069   {
00070     try {
00071       ar >> m_szText;
00072       ar >> m_polytype;
00073     }
00074   catch( CMemoryException* ) {
00075     // Handle out-of-memory exception. Reset
00076       m_szText = _T("");
00077       m_polytype = -1;
00078     }
00079   }
00080 }
00081
00082 /////////////////////////////////////////////////////////////////////////////
00083 // CPrintSDIDoc diagnostics
00084
00085 #ifdef _DEBUG
00086 void CPrintSDIDoc::AssertValid() const
00087 {
00088   CDocument::AssertValid();
00089 }
00090
00091 void CPrintSDIDoc::Dump(CDumpContext& dc) const
00092 {
00093   CDocument::Dump(dc);
00094 }
00095 #endif //_DEBUG
00096
00097 /////////////////////////////////////////////////////////////////////////////
00098 // CPrintSDIDoc commands
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Alloc.h Source File

  • NetDS
  • SyncMgr
  • SyncDir

Alloc.h

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #ifndef _SAMPLEALLOC_
00013 #define _SAMPLEALLOC_
00014
00015 inline void* __cdecl operator new (size_t size);
00016 inline void __cdecl operator delete(void FAR* lpv);
00017
00018
00019 LPVOID ALLOC(ULONG cb);
00020 void FREE(void* pv);
00021 LPVOID REALLOC(void *pv,ULONG cb);
00022
00023 #ifdef _DEBUG
00024
00025 #define MEMINITVALUE 0xff
00026 #define MEMFREEVALUE 0xfe
00027
00028 #endif // DEBUG
00029
00030
00031 #endif // _SAMPLEALLOC_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/cedebug.cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

cedebug.cpp

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 //  File:   cedebug.cpp
00007 //
00008 //  Contents: Debug support
00009 //
00010 //----------------------------------------------------------------------------
00011
00012 #include <pch.cpp>
00013
00014 #pragma hdrstop
00015
00016 #include "celib.h"
00017 #include <stdarg.h>
00018
00019
00020 //+-------------------------------------------------------------------------
00021 //
00022 //  Function:  ceDbgPrintf
00023 //
00024 //  Synopsis:  outputs debug info to stdout and debugger
00025 //
00026 //  Returns:   number of chars output
00027 //
00028 //--------------------------------------------------------------------------
00029
00030 int WINAPIV
00031 ceDbgPrintf(
00032     IN BOOL fDebug,
00033     IN LPCSTR lpFmt,
00034     ...)
00035 {
00036     va_list arglist;
00037     CHAR ach[4096];
00038     int cch = 0;
00039     HANDLE hStdOut;
00040     DWORD dwErr;
00041
00042     dwErr = GetLastError();
00043     if (fDebug)
00044     {
00045   __try
00046   {
00047       va_start(arglist, lpFmt);
00048       cch = _vsnprintf(ach, sizeof(ach), lpFmt, arglist);
00049       ach[ARRAYSIZE(ach)-1] = L'\0';
00050       va_end(arglist);
00051
00052       if (0 > cch)
00053       {
00054     strcpy(&ach[sizeof(ach) - 5], "...\n");
00055       }
00056
00057       if (!IsDebuggerPresent())
00058       {
00059     hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
00060     if (hStdOut != INVALID_HANDLE_VALUE)
00061     {
00062         fputs(ach, stdout);
00063         fflush(stdout);
00064     }
00065       }
00066       OutputDebugStringA(ach);
00067   }
00068   __except(EXCEPTION_EXECUTE_HANDLER)
00069   {
00070       // return failure
00071       cch = 0;
00072   }
00073     }
00074     SetLastError(dwErr);
00075     return(cch);
00076 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagProperties Member List

This is the complete list of members for tagProperties, including all inherited members.
m_dwType | tagProperties
m_tcsPropertyName | tagProperties
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/land.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

BSTRING Member List

This is the complete list of members for BSTRING, including all inherited members.
BSTRING() | BSTRING | [inline]
BSTRING(LPCWSTR lpcwString) | BSTRING | [inline]
BSTRING(LPCSTR lpcString) | BSTRING |
BSTRING() | BSTRING | [inline]
BSTRING(LPCWSTR lpcwString) | BSTRING | [inline]
BSTRING(LPCSTR lpcString) | BSTRING |
BSTRING() | BSTRING | [inline]
BSTRING(LPCWSTR lpcwString) | BSTRING | [inline]
BSTRING(LPCSTR lpcString) | BSTRING |
BSTRING() | BSTRING | [inline]
BSTRING(LPCWSTR lpcwString) | BSTRING | [inline]
BSTRING(LPCSTR lpcString) | BSTRING |
GetLPBSTR(void) | BSTRING | [inline]
GetLPBSTR(void) | BSTRING | [inline]
GetLPBSTR(void) | BSTRING | [inline]
GetLPBSTR(void) | BSTRING | [inline]
m_bstr | BSTRING | [private]
operator BSTR() | BSTRING | [inline]
operator BSTR() | BSTRING | [inline]
operator BSTR() | BSTRING | [inline]
operator BSTR() | BSTRING | [inline]
~BSTRING() | BSTRING | [inline]
~BSTRING() | BSTRING | [inline]
~BSTRING() | BSTRING | [inline]
~BSTRING() | BSTRING | [inline]
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminAccessChecksLevelOptions.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminAccessChecksLevelOptions.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminAccessChecksLevelOptions
00019
00020 public interface COMAdminAccessChecksLevelOptions
00021 {
00022   public static final int COMAdminAccessChecksApplicationLevel = 0;
00023   public static final int COMAdminAccessChecksApplicationComponentLevel = 1;
00024 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/mark.h Source File

  • WinUI
  • TSFmark

mark.h

Go to the documentation of this file.
00001 //
00002 // mark.h
00003 //
00004 // CMarkTextService declaration.
00005 //
00006
00007 #ifndef MARK_H
00008 #define MARK_H
00009
00010 class CLangBarItemButton;
00011
00012 class CMarkTextService : public ITfTextInputProcessor,
00013                          public ITfDisplayAttributeProvider,
00014                          public ITfCreatePropertyStore,
00015                          public ITfThreadMgrEventSink,
00016                          public ITfTextEditSink,
00017                          public ITfCompositionSink,
00018                          public ITfCleanupContextDurationSink,
00019                          public ITfCleanupContextSink,
00020                          public ITfCompartmentEventSink,
00021                          public ITfKeyEventSink
00022 {
00023 public:
00024     CMarkTextService();
00025     ~CMarkTextService();
00026
00027     // IUnknown
00028     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00029     STDMETHODIMP_(ULONG) AddRef(void);
00030     STDMETHODIMP_(ULONG) Release(void);
00031
00032     // ITfTextInputProcessor
00033     STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId);
00034     STDMETHODIMP Deactivate();
00035
00036     // ITfDisplayAttributeProvider
00037     STDMETHODIMP EnumDisplayAttributeInfo(IEnumTfDisplayAttributeInfo **ppEnum);
00038     STDMETHODIMP GetDisplayAttributeInfo(REFGUID guidInfo, ITfDisplayAttributeInfo **ppInfo);
00039
00040     // ITfCreatePropertyStore
00041     STDMETHODIMP IsStoreSerializable(REFGUID guidProperty, ITfRange *pRange, ITfPropertyStore *pPropertyStore, BOOL *pfSerializable);
00042     STDMETHODIMP CreatePropertyStore(REFGUID guidProperty, ITfRange *pRange, ULONG cb, IStream *pStream, ITfPropertyStore **ppStore);
00043
00044     // ITfThreadMgrEventSink
00045     STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr);
00046     STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr);
00047     STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus);
00048     STDMETHODIMP OnPushContext(ITfContext *pContext);
00049     STDMETHODIMP OnPopContext(ITfContext *pContext);
00050
00051     // ITfTextEditSink
00052     STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord);
00053
00054     // ITfCompositionSink
00055     STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition);
00056
00057     // ITfCleanupContextDurationSink
00058     STDMETHODIMP OnStartCleanupContext();
00059     STDMETHODIMP OnEndCleanupContext();
00060
00061     // ITfCleanupContextSink
00062     STDMETHODIMP OnCleanupContext(TfEditCookie ecWrite, ITfContext *pContext);
00063
00064     // ITfCompartmentEventSink
00065     STDMETHODIMP OnChange(REFGUID rguidCompartment);
00066
00067     // ITfKeyEventSink
00068     STDMETHODIMP OnSetFocus(BOOL fForeground);
00069     STDMETHODIMP OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00070     STDMETHODIMP OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00071     STDMETHODIMP OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00072     STDMETHODIMP OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00073     STDMETHODIMP OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pfEaten);
00074
00075     // CClassFactory factory callback
00076     static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
00077
00078     // server registration
00079     static BOOL RegisterProfiles();
00080     static void UnregisterProfiles();
00081     static BOOL RegisterCategories(BOOL fRegister);
00082     static BOOL RegisterServer();
00083     static void UnregisterServer();
00084
00085     // language bar menu handlers
00086     static void _Menu_OnComposition(CMarkTextService *_this);
00087     static void _Menu_OnSetGlobalCompartment(CMarkTextService *_this);
00088     static void _Menu_OnSetCaseProperty(CMarkTextService *_this);
00089     static void _Menu_OnViewCaseProperty(CMarkTextService *_this);
00090     static void _Menu_OnViewCustomProperty(CMarkTextService *_this);
00091     static void _Menu_OnSetCustomProperty(CMarkTextService *_this);
00092
00093     // keystroke handlers
00094     HRESULT _HandleKeyDown(TfEditCookie ec, ITfContext *pContext, WPARAM wParam);
00095     HRESULT _HandleArrowKey(TfEditCookie ec, ITfContext *pContext, WPARAM wParam);
00096     HRESULT _HandleReturn(TfEditCookie ec, ITfContext *pContext);
00097
00098     // callbacks for CCompositionEditSession
00099     BOOL _IsComposing()
00100     {
00101         return _pComposition != NULL;
00102     }
00103     ITfComposition *_GetComposition()
00104     {
00105         return _pComposition;
00106     }
00107     void _SetComposition(ITfComposition *pComposition)
00108     {
00109         _pComposition = pComposition;
00110     }
00111     void _TerminateComposition(TfEditCookie ec)
00112     {
00113         if (_pComposition != NULL)
00114         {
00115             _ClearCompositionDisplayAttributes(ec);
00116             _pComposition->EndComposition(ec);
00117             SafeReleaseClear(_pComposition);
00118         }
00119     }
00120     void _TerminateCompositionInContext(ITfContext *pContext);
00121     void _ClearCompositionDisplayAttributes(TfEditCookie ec);
00122     BOOL _SetCompositionDisplayAttributes(TfEditCookie ec);
00123
00124     // messages for the worker wnd
00125     enum { WM_DISPLAY_PROPERTY = WM_USER + 1 };
00126     // property methods
00127     void _ViewCaseProperty(TfEditCookie ec, ITfContext *pContext);
00128     void _SetCaseProperty(TfEditCookie ec, ITfContext *pContext);
00129     void _ViewCustomProperty(TfEditCookie ec, ITfContext *pContext);
00130     void _SetCustomProperty(TfEditCookie ec, ITfContext *pContext);
00131
00132 private:
00133     // init methods
00134     BOOL _InitLanguageBar();
00135     BOOL _InitThreadMgrSink();
00136     BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr);
00137     BOOL _InitDisplayAttributeGuidAtom();
00138     BOOL _InitCleanupContextDurationSink();
00139     BOOL _InitCleanupContextSink(ITfContext *pContext);
00140     BOOL _InitContextCompartment(ITfContext *pContext);
00141     BOOL _InitGlobalCompartment();
00142     BOOL _InitWorkerWnd();
00143     BOOL _InitKeystrokeSink();
00144
00145     // uninit methods
00146     void _UninitLanguageBar();
00147     void _UninitThreadMgrSink();
00148     void _UninitCleanupContextDurationSink();
00149     void _UninitCleanupContextSink(ITfContext *pContext);
00150     void _UninitCompartment(ITfContext *pContext);
00151     void _UninitGlobalCompartment();
00152     void _UninitWorkerWnd();
00153     void _UninitKeystrokeSink();
00154
00155     // property methods
00156     void _RequestPropertyEditSession(ULONG ulCallback);
00157     static LRESULT CALLBACK _WorkerWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00158
00159     //
00160     // state
00161     //
00162
00163     ITfThreadMgr *_pThreadMgr;
00164     TfClientId _tfClientId;
00165
00166     ITfComposition *_pComposition; // pointer to an ongoing composition, or NULL if there is none
00167
00168     BOOL _fCleaningUp;
00169
00170     TfGuidAtom _gaDisplayAttribute;
00171
00172     CLangBarItemButton *_pLangBarItem;
00173
00174     DWORD _dwThreadMgrEventSinkCookie;
00175     DWORD _dwThreadFocusSinkCookie;
00176     DWORD _dwTextEditSinkCookie;
00177     DWORD _dwGlobalCompartmentEventSinkCookie;
00178
00179     ITfContext *_pTextEditSinkContext;
00180
00181     HWND _hWorkerWnd;
00182     // buffers for the popup property displays
00183     WCHAR _achDisplayText[64];
00184     WCHAR _achDisplayPropertyText[64];
00185
00186     LONG _cRef;     // COM ref count
00187 };
00188
00189
00190 #endif // MARK_H
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagSERVERINFO Member List

This is the complete list of members for tagSERVERINFO, including all inherited members.
cBuff | tagSERVERINFO
cErrors | tagSERVERINFO
failed | tagSERVERINFO
fDebug | tagSERVERINFO
fIsolate | tagSERVERINFO
fLog | tagSERVERINFO
fScreen | tagSERVERINFO
hdbc | tagSERVERINFO
henv | tagSERVERINFO
hLoadedInst | tagSERVERINFO
hstmt | tagSERVERINFO
hwnd | tagSERVERINFO
rglMask | tagSERVERINFO
szBuff | tagSERVERINFO
szKeywords | tagSERVERINFO
szLogFile | tagSERVERINFO
szSource | tagSERVERINFO
szValidLogin0 | tagSERVERINFO
szValidPassword0 | tagSERVERINFO
szValidServer0 | tagSERVERINFO
vCursorLib | tagSERVERINFO
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::IsolationLevelEnum Member List

This is the complete list of members for msado15::IsolationLevelEnum, including all inherited members.
adXactBrowse | msado15::IsolationLevelEnum | [static]
adXactChaos | msado15::IsolationLevelEnum | [static]
adXactCursorStability | msado15::IsolationLevelEnum | [static]
adXactIsolated | msado15::IsolationLevelEnum | [static]
adXactReadCommitted | msado15::IsolationLevelEnum | [static]
adXactReadUncommitted | msado15::IsolationLevelEnum | [static]
adXactRepeatableRead | msado15::IsolationLevelEnum | [static]
adXactSerializable | msado15::IsolationLevelEnum | [static]
adXactUnspecified | msado15::IsolationLevelEnum | [static]
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/ContextSamplePropPage/ContextSamplePropPage.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification
  • ContextSamplePropPage

ContextSamplePropPage.cpp

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName: ContextSamplePropPage.cpp
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011 #include "stdafx.h"
00012 #include "resource.h"
00013 #include <initguid.h>
00014 #include "ContextSamplePropPage.h"
00015 #include "ContextSamplePropPageImpl.h"
00016
00017 #include "ContextSamplePropPage_i.c"
00018
00019 #ifdef _MERGE_PROXYSTUB
00020 extern "C" HINSTANCE hProxyDll;
00021 #endif
00022
00023 CComModule _Module;
00024
00025 BEGIN_OBJECT_MAP(ObjectMap)
00026 OBJECT_ENTRY(CLSID_ContextSamplePropPage, CContextSamplePropPage)
00027 END_OBJECT_MAP()
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // DLL Entry Point
00031
00032 extern "C"
00033 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00034 {
00035     lpReserved;
00036 #ifdef _MERGE_PROXYSTUB
00037     if (!PrxDllMain(hInstance, dwReason, lpReserved))
00038         return FALSE;
00039 #endif
00040     if (dwReason == DLL_PROCESS_ATTACH)
00041     {
00042         _Module.Init(ObjectMap, hInstance, &LIBID_CONTEXTSAMPLEPROPPAGELib);
00043         DisableThreadLibraryCalls(hInstance);
00044     }
00045     else if (dwReason == DLL_PROCESS_DETACH)
00046         _Module.Term();
00047     return TRUE;    // ok
00048 }
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 // Used to determine whether the DLL can be unloaded by OLE
00052
00053 STDAPI DllCanUnloadNow(void)
00054 {
00055 #ifdef _MERGE_PROXYSTUB
00056     if (PrxDllCanUnloadNow() != S_OK)
00057         return S_FALSE;
00058 #endif
00059     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00060 }
00061
00062 /////////////////////////////////////////////////////////////////////////////
00063 // Returns a class factory to create an object of the requested type
00064
00065 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00066 {
00067 #ifdef _MERGE_PROXYSTUB
00068     if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00069         return S_OK;
00070 #endif
00071     return _Module.GetClassObject(rclsid, riid, ppv);
00072 }
00073
00074 /////////////////////////////////////////////////////////////////////////////
00075 // DllRegisterServer - Adds entries to the system registry
00076
00077 STDAPI DllRegisterServer(void)
00078 {
00079 #ifdef _MERGE_PROXYSTUB
00080     HRESULT hRes = PrxDllRegisterServer();
00081     if (FAILED(hRes))
00082         return hRes;
00083 #endif
00084     // registers object, typelib and all interfaces in typelib
00085     return _Module.RegisterServer(TRUE);
00086 }
00087
00088 /////////////////////////////////////////////////////////////////////////////
00089 // DllUnregisterServer - Removes entries from the system registry
00090
00091 STDAPI DllUnregisterServer(void)
00092 {
00093 #ifdef _MERGE_PROXYSTUB
00094     PrxDllUnregisterServer();
00095 #endif
00096     return _Module.UnregisterServer(TRUE);
00097 }
00098
00099
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Intermediate/Catlpwr.Cpp Source File

  • Web
  • iis
  • Components
  • Cpp
  • Intermediate

Catlpwr.Cpp

Go to the documentation of this file.
00001 // CATLPwr.cpp : Implementation of DLL Exports.
00002
00003 // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this
00004 // project.  This is because you will need MIDL 3.00.15 or higher and new
00005 // headers and libs.  If you have VC 4.2 installed, then everything should
00006 // already be configured correctly.
00007
00008 // Note: Proxy/Stub Information
00009 //    To build a separate proxy/stub DLL,
00010 //    run nmake -f CATLPwrps.mak in the project directory.
00011
00012 #include "stdafx.h"
00013 #include "resource.h"
00014 #include "initguid.h"
00015 #include "CATLPwr.h"
00016 #include "Power.h"
00017
00018 #define IID_DEFINED
00019 #include "CATLPwr_i.c"
00020
00021
00022 CComModule _Module;
00023
00024 BEGIN_OBJECT_MAP(ObjectMap)
00025   OBJECT_ENTRY(CLSID_CPower, CPower)
00026 END_OBJECT_MAP()
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // DLL Entry Point
00030
00031 extern "C"
00032 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00033 {
00034   if (dwReason == DLL_PROCESS_ATTACH)
00035   {
00036     _Module.Init(ObjectMap, hInstance);
00037     DisableThreadLibraryCalls(hInstance);
00038   }
00039   else if (dwReason == DLL_PROCESS_DETACH)
00040     _Module.Term();
00041   return TRUE;    // ok
00042 }
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // Used to determine whether the DLL can be unloaded by OLE
00046
00047 STDAPI DllCanUnloadNow(void)
00048 {
00049   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00050 }
00051
00052 /////////////////////////////////////////////////////////////////////////////
00053 // Returns a class factory to create an object of the requested type
00054
00055 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00056 {
00057   return _Module.GetClassObject(rclsid, riid, ppv);
00058 }
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // DllRegisterServer - Adds entries to the system registry
00062
00063 STDAPI DllRegisterServer(void)
00064 {
00065   // registers object, typelib and all interfaces in typelib
00066   return _Module.RegisterServer(TRUE);
00067 }
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 // DllUnregisterServer - Removes entries from the system registry
00071
00072 STDAPI DllUnregisterServer(void)
00073 {
00074   _Module.UnregisterServer();
00075   return S_OK;
00076 }
00077
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/InstCodc/InstCodc.Cpp Source File

  • Web
  • NetMeeting
  • InstCodc

InstCodc.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:      INSTCODC.EXE
00003 //  File:        INSTCODC.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1999 - 2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include <stdio.h>
00016 #include <stdarg.h>
00017 #include <tchar.h>
00018
00019 #include <windows.h>
00020 #include <windowsx.h>
00021 #include <objbase.h>
00022 #include <initguid.h>
00023
00024 #include "resource.h"
00025 #include "codecs.h"
00026
00027
00028 typedef enum {AUDIOCODEC, NONE} CODECTYPE;
00029
00030 //*******************
00031 //GLOBALS
00032 //*******************
00033 const int           MID_SZ      = 128;
00034 CODECTYPE           gtCodec     = AUDIOCODEC;       // Global depicting type of codec being displayed, installed,
00035                                                     // removed, or reordered.
00036
00037 HINSTANCE           ghInstance  = NULL;
00038
00039 WAVEFORMATEX*       gpWFmt      = NULL;             //Structures used for adding and removing codecs
00040 AUDCAP_INFO         gWInfo;
00041
00042 //CAP_INFO lists
00043 AUDCAP_INFO_LIST*   gpsAudCapInfoList       = NULL; // Contains a list of the installed
00044                                                     // audio codecs and their properties.
00045 int*                gpnAudCapOrderedIndex   = NULL; // Contains, in installed order, indexes
00046                                                     // of the structures in the AUDCAP_INFO_LIST.
00047
00048
00049 //*******************
00050 //GLOBAL Interfaces
00051 //*******************
00052 static IInstallAudioCodecs* pAudio          = NULL;
00053
00054 //*******************
00055 //MAIN UI FUNCTIONS
00056 //*******************
00057
00058 LRESULT CALLBACK MainUIProc (HWND hwnd, UINT message, UINT wParam, LONG lParam);
00059 LRESULT CALLBACK ReorderUIProc (HWND hwnd, UINT message, UINT wParam, LONG lParam);
00060 BOOL InitAppInstance (HINSTANCE hInstance);
00061 void DeinitAppInstance(HINSTANCE hInstance);
00062
00063 //*******************
00064 //Misc. Functions
00065 //*******************
00066
00067 void LoadInstalledCodecs(void);
00068 void IndexInstalledCodecs(void);
00069 void UpdateCapInfoListsFromIndex(void);
00070 void DlgDisplayInstalledCodecs(HWND);
00071 void DebugTextOut(TCHAR* ptszFormat, ... );
00072
00073
00074 //*******************
00075 //helper function  converts HRESULT to error message
00076 //*******************
00077
00078 TCHAR gszHRError[MID_SZ];
00079 inline void HRErrorToString(HRESULT hr)
00080 {
00081     FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,(DWORD)hr,LANG_SYSTEM_DEFAULT,gszHRError,MID_SZ,NULL);
00082 }
00083
00084
00085
00086
00087 //****************************************************************************
00088 //
00089 //    FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
00090 //
00091 //    PURPOSE: calls initialization function
00092 //
00093 //    COMMENTS:
00094 //
00095 //        Windows recognizes this function by name as the initial entry point
00096 //        for the program.  This function calls the application initialization
00097 //        routine.
00098 //
00099 //****************************************************************************
00100
00101
00102 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
00103 {
00104     BOOL fProcessed = FALSE;
00105
00106     fProcessed = InitAppInstance(hInstance);
00107     if (fProcessed == FALSE)
00108     {
00109         DebugTextOut(TEXT("InitAppInstance failed\n"));
00110     }
00111
00112     DeinitAppInstance(hInstance);
00113     return fProcessed;
00114 }
00115
00116 //****************************************************************************
00117 //
00118 // BOOL InitAppInstance (HINSTANCE hInstance)
00119 //
00120 // This function initializes this instance of the application.
00121 //
00122 //****************************************************************************
00123
00124 BOOL InitAppInstance (HINSTANCE hInstance)
00125 {
00126     WNDCLASS    wc;
00127     BYTE        gWFmtEx[] = {0x40,0x01};
00128
00129     ghInstance = hInstance;
00130
00131     //Register WNDCLASS for the app.
00132
00133     //This class enables the main dialog box to have additional properties
00134     //such as an icon.
00135     wc.style            = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW;
00136     wc.lpfnWndProc      = DefDlgProc;
00137     wc.cbClsExtra       = 0;
00138     wc.cbWndExtra       = DLGWINDOWEXTRA;
00139     wc.hInstance        = hInstance;
00140     wc.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_INSTCODC));
00141     wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
00142     wc.hbrBackground    = (HBRUSH)GetStockObject(WHITE_BRUSH);
00143     wc.lpszMenuName     = NULL;
00144     wc.lpszClassName    = TEXT("CodecInstClass");
00145
00146     if (!RegisterClass(&wc))
00147     {
00148         DebugTextOut(TEXT("Register class failed!\n"));
00149         return FALSE;
00150     }
00151
00152
00153     //Setup audio codec structures
00154     //This particular codec is: GSM 6.10, 8,000 Hz, Mono
00155     gpWFmt = (WAVEFORMATEX *)LocalAlloc(LPTR,sizeof(WAVEFORMATEX)+sizeof(gWFmtEx));
00156     if (NULL == gpWFmt)
00157     {
00158         DebugTextOut(TEXT("Out of memory\n"));
00159         return FALSE;
00160     }
00161
00162     gpWFmt->wFormatTag      = 49;
00163     gpWFmt->nChannels       = 1;
00164     gpWFmt->nSamplesPerSec  = 8000;
00165     gpWFmt->nAvgBytesPerSec = 1625;
00166     gpWFmt->nBlockAlign     = 65;
00167     gpWFmt->wBitsPerSample  = 0;
00168     gpWFmt->cbSize          = sizeof(gWFmtEx);
00169
00170     CopyMemory((gpWFmt + 1), gWFmtEx, gpWFmt->cbSize);
00171
00172     ZeroMemory(&gWInfo,sizeof(AUDCAP_INFO));
00173     gWInfo.wFormatTag = 49;
00174     gWInfo.uAvgBitrate = 13000;
00175     gWInfo.wCPUUtilizationEncode = 50; //arbitrary
00176     gWInfo.wCPUUtilizationDecode = 20; //artitrary
00177     gWInfo.bSendEnabled = 1;
00178     gWInfo.bRecvEnabled = 1;
00179
00180     //Setup COM support
00181     if (FAILED(CoInitialize(NULL)))
00182     {
00183         DebugTextOut(TEXT("CoInitialize failed\n"));
00184         return FALSE;
00185     }
00186
00187     //Application is a Modal Dialog.
00188     return DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAINUI),0,(DLGPROC)MainUIProc);
00189 }
00190
00191 //****************************************************************************
00192 //
00193 // void DeinitAppInstance (HINSTANCE hInstance)
00194 //
00195 // This function initializes this instance of the application.
00196 //
00197 //****************************************************************************
00198
00199 void DeinitAppInstance(HINSTANCE hInstance)
00200 {
00201     //End COM support
00202     CoUninitialize();
00203
00204     //free the allocated memory
00205     LocalFree(gpWFmt);
00206     gpWFmt = NULL;
00207 }
00208
00209 //****************************************************************************
00210 //
00211 // BOOL MainUI_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
00212 //
00213 // This function is called when the Main Dialog initializes.  It sets up
00214 // the initial interface pointers and updates the dialog accordingly
00215 //
00216 //****************************************************************************
00217
00218 BOOL MainUI_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
00219 {
00220     HRESULT hr  = S_OK;
00221     TCHAR   szString[MID_SZ];
00222
00223     gtCodec = NONE;
00224
00225     //Get an interface to the audio codec methods
00226     hr = CoCreateInstance(  CLSID_InstallCodecs,
00227                             NULL,
00228                             CLSCTX_INPROC_SERVER,
00229                             IID_IInstallAudioCodecs,
00230                             (void **) &pAudio);
00231     if (FAILED(hr))
00232     {
00233         pAudio = NULL;
00234         HRErrorToString(hr);
00235         LoadString(ghInstance,IDS_GETIAUDIO,szString,MID_SZ);
00236         MessageBox(NULL,gszHRError,szString,MB_OK);
00237     }
00238     else
00239     {
00240         gtCodec = AUDIOCODEC;
00241     }
00242
00243
00244     // If no interfaces were available, disable everything.
00245     if (gtCodec == NONE)
00246     {
00247         EnableWindow(GetDlgItem(hwnd,IDC_INSTALL),FALSE);
00248         EnableWindow(GetDlgItem(hwnd,IDC_UNINSTALL),FALSE);
00249         EnableWindow(GetDlgItem(hwnd,IDC_REORDER),FALSE);
00250         EnableMenuItem(GetMenu(hwnd),0,MF_BYPOSITION|MF_GRAYED);
00251         return TRUE;
00252     }
00253
00254     //Load installed codec formats
00255     LoadInstalledCodecs();
00256
00257     //display codecs
00258     DlgDisplayInstalledCodecs(hwnd);
00259     return TRUE;
00260 }
00261
00262 //****************************************************************************
00263 //
00264 // void MainUI_OnDestroy(HWND hwnd)
00265 //
00266 //****************************************************************************
00267
00268 void MainUI_OnDestroy(HWND hwnd)
00269 {
00270     HRESULT hr = S_OK;
00271
00272     if (NULL == pAudio)
00273     {
00274         DebugTextOut(TEXT("Application not initialized!\n"));
00275         return;
00276     }
00277
00278     // Free CapInfo structures
00279     if (NULL != gpsAudCapInfoList)
00280     {
00281         hr = pAudio->FreeBuffer(gpsAudCapInfoList);
00282         if (FAILED(hr))
00283         {
00284             // Simply log the failure, and continue. We want to continue and clean up
00285             DebugTextOut(TEXT("pAudio->FreeBuffer failed, hr = 0x%08p"), hr);
00286         }
00287     }
00288
00289     // Release the interfaces
00290     if (NULL != pAudio)
00291     {
00292         pAudio->Release();
00293         pAudio = NULL;
00294     }
00295
00296     // Free CapInfoIndexs
00297     LocalFree(gpnAudCapOrderedIndex);
00298     gpnAudCapOrderedIndex = NULL;
00299 }
00300
00301 //****************************************************************************
00302 //
00303 // void MainUI_OnClose(HWND hwnd)
00304 //
00305 //****************************************************************************
00306
00307 void MainUI_OnClose(HWND hwnd)
00308 {
00309     EndDialog(hwnd,0);
00310 }
00311
00312 //****************************************************************************
00313 //
00314 // void MainUI_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
00315 //
00316 //****************************************************************************
00317
00318 void MainUI_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
00319 {
00320     TCHAR szString[MID_SZ];
00321     TCHAR szString2[MID_SZ];
00322
00323     if (NULL == pAudio)
00324     {
00325         DebugTextOut(TEXT("Application not initialized!\n"));
00326         return;
00327     }
00328
00329     switch(id)
00330     {
00331         //Install the codec
00332         case IDC_INSTALL:
00333         {
00334             if (gtCodec==AUDIOCODEC)
00335             {
00336                 if (FAILED(pAudio->AddACMFormat(gpWFmt,&gWInfo)))
00337                 {
00338                     LoadString(ghInstance,IDS_IAFMT,szString,MID_SZ);
00339                     LoadString(ghInstance,IDS_AAFMT,szString2,MID_SZ);
00340                     MessageBox(hwnd,szString,szString2,MB_OK|MB_ICONEXCLAMATION);
00341                 }
00342             }
00343             LoadInstalledCodecs();
00344             break;
00345         }
00346
00347         // Uninstall the codec
00348         case IDC_UNINSTALL:
00349         {
00350             if (gtCodec==AUDIOCODEC)
00351             {
00352                 if (FAILED(pAudio->RemoveACMFormat(gpWFmt)))
00353                 {
00354                     LoadString(ghInstance,IDS_UAFMT,szString,MID_SZ);
00355                     LoadString(ghInstance,IDS_RAFMT,szString2,MID_SZ);
00356                     MessageBox(hwnd,szString,szString2,MB_OK|MB_ICONEXCLAMATION);
00357                 }
00358             }
00359
00360             LoadInstalledCodecs();
00361             break;
00362         }
00363
00364         // Reorder the codecs
00365         case IDC_REORDER:
00366         {
00367             DialogBox(ghInstance,MAKEINTRESOURCE(IDD_REORDER),hwnd,(DLGPROC)ReorderUIProc);
00368             break;
00369         }
00370     }
00371
00372     DlgDisplayInstalledCodecs(hwnd);
00373 }
00374
00375 //****************************************************************************
00376 //
00377 // LRESULT CALLBACK MainUIProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
00378 //
00379 //****************************************************************************
00380
00381 LRESULT CALLBACK MainUIProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
00382 {
00383
00384     LRESULT fProcessed=TRUE;
00385
00386     switch(message)
00387     {
00388         HANDLE_MSG(hwnd,WM_INITDIALOG,MainUI_OnInitDialog);
00389         HANDLE_MSG(hwnd,WM_CLOSE,MainUI_OnClose);
00390         HANDLE_MSG(hwnd,WM_DESTROY,MainUI_OnDestroy);
00391         HANDLE_MSG(hwnd,WM_COMMAND,MainUI_OnCommand);
00392
00393     default:
00394         fProcessed=FALSE;
00395         break;
00396     }
00397     return (fProcessed);
00398 }
00399
00400 //****************************************************************************
00401 //
00402 // BOOL ReorderUI_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
00403 //
00404 //****************************************************************************
00405
00406 BOOL ReorderUI_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
00407 {
00408     DlgDisplayInstalledCodecs(hwnd);
00409     return TRUE;
00410 }
00411
00412 //****************************************************************************
00413 //
00414 // void ReorderUI_OnDestroy(HWND hwnd)
00415 //
00416 //****************************************************************************
00417
00418 void ReorderUI_OnDestroy(HWND hwnd)
00419 {
00420     EndDialog(hwnd,TRUE);
00421 }
00422
00423 //****************************************************************************
00424 //
00425 // void ReorderUI_OnClose(HWND hwnd)
00426 //
00427 //****************************************************************************
00428
00429 void ReorderUI_OnClose(HWND hwnd)
00430 {
00431     IndexInstalledCodecs();
00432     ReorderUI_OnDestroy(hwnd);
00433 }
00434
00435 //****************************************************************************
00436 //
00437 // void ReorderUI_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
00438 //
00439 //****************************************************************************
00440
00441 void ReorderUI_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
00442 {
00443     HWND    hListBox    = NULL;
00444     HRESULT hr          = S_OK;
00445     int     tmp         = 0;
00446     int     index       = 0;
00447
00448     switch(id)
00449     {
00450         // Move the selected codec up in the list box, and update the CapInfoIndex
00451         case IDC_UP:
00452         {
00453             if (NULL == gpsAudCapInfoList)
00454             {
00455                 DebugTextOut(TEXT("gpsAudCapInfoList not initialized.\n"));
00456                 return;
00457             }
00458
00459             if (NULL == gpnAudCapOrderedIndex)
00460             {
00461                 DebugTextOut(TEXT("gpnAudCapOrderedIndex not initialized.\n"));
00462                 return;
00463             }
00464
00465             hListBox = GetDlgItem(hwnd,IDC_LBINSTALLEDCODECS);
00466             if (NULL == hListBox)
00467             {
00468                 DebugTextOut(TEXT("GetDlgItem failed! Error = 0x%08p.\n"), HRESULT_FROM_WIN32(GetLastError()));
00469                 return;
00470             }
00471
00472             //get text of current selection
00473             index = SendMessage(hListBox,LB_GETCURSEL,0,0);
00474
00475             //if wasn't able to get selection
00476             if (index==0 || index==LB_ERR)
00477                 return;
00478
00479             SendMessage(hListBox,LB_DELETESTRING,index,0);
00480             SendMessage(hListBox,LB_INSERTSTRING,index-1,(LPARAM)(LPCSTR)gpsAudCapInfoList->aFormats[gpnAudCapOrderedIndex[index]].szFormat);
00481
00482             tmp = gpnAudCapOrderedIndex[index-1];
00483             gpnAudCapOrderedIndex[index-1] = gpnAudCapOrderedIndex[index];
00484             gpnAudCapOrderedIndex[index] = tmp;
00485
00486             SendMessage(hListBox,LB_SETCURSEL,index-1,0);
00487             break;
00488         }
00489
00490         // Move the selected codec down in the list box, and update the CapInfoIndex
00491         case IDC_DOWN:
00492         {
00493             if (NULL == gpsAudCapInfoList)
00494             {
00495                 DebugTextOut(TEXT("gpsAudCapInfoList not initialized.\n"));
00496                 return;
00497             }
00498
00499             hListBox = GetDlgItem(hwnd,IDC_LBINSTALLEDCODECS);
00500             if (NULL == hListBox)
00501             {
00502                 DebugTextOut(TEXT("GetDlgItem failed! Error = 0x%08p.\n"), HRESULT_FROM_WIN32(GetLastError()));
00503                 return;
00504             }
00505
00506             //get text of current selection
00507             index = SendMessage(hListBox,LB_GETCURSEL,0,0);
00508
00509             if (    (index == (int)(gpsAudCapInfoList->cFormats - 1)) ||
00510                     (index == (int)LB_ERR))
00511                 return;
00512
00513             SendMessage(hListBox,LB_DELETESTRING,index,0);
00514             SendMessage(hListBox,LB_INSERTSTRING,index+1,(LPARAM)(LPCSTR)gpsAudCapInfoList->aFormats[gpnAudCapOrderedIndex[index]].szFormat);
00515
00516             tmp = gpnAudCapOrderedIndex[index+1];
00517             gpnAudCapOrderedIndex[index+1] = gpnAudCapOrderedIndex[index];
00518             gpnAudCapOrderedIndex[index] = tmp;
00519
00520             SendMessage(hListBox,LB_SETCURSEL,index+1,0);
00521             break;
00522         }
00523
00524
00525         // Update the CapInfoList from the CapInfoIndex
00526         // Call ReorderFormats to reorder the codecs in NetMtg
00527         // Reload the CapInfoList w/ the new info.
00528         case IDC_OK:
00529         {
00530             UpdateCapInfoListsFromIndex();
00531
00532             if (NULL == pAudio)
00533             {
00534                 DebugTextOut(TEXT("pAudio is NULL\n"));
00535                 return;
00536             }
00537
00538             hr = pAudio->ReorderFormats(gpsAudCapInfoList);
00539             if (FAILED(hr))
00540             {
00541                 DebugTextOut(TEXT("pAudio->ReorderFormats failed. hr = 0x%08p\n"), hr);
00542                 return;
00543             }
00544
00545             //refresh display
00546             LoadInstalledCodecs();
00547             EndDialog(hwnd,TRUE);
00548             break;
00549         }
00550
00551         // Cancel changes by reinitializing the CapInfoIndexs from the
00552         // CapInfoLists and ending the dialog.
00553         case IDC_CANCEL:
00554         {
00555             IndexInstalledCodecs();
00556             EndDialog(hwnd,TRUE);
00557             break;
00558         }
00559     }
00560 }
00561
00562 //****************************************************************************
00563 //
00564 // LRESULT CALLBACK ReorderUIProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
00565 //
00566 //****************************************************************************
00567
00568 LRESULT CALLBACK ReorderUIProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
00569 {
00570     LRESULT fProcessed=TRUE;
00571
00572     switch(message)
00573     {
00574         HANDLE_MSG(hwnd,WM_INITDIALOG,ReorderUI_OnInitDialog);
00575         HANDLE_MSG(hwnd,WM_CLOSE,ReorderUI_OnClose);
00576         HANDLE_MSG(hwnd,WM_DESTROY,ReorderUI_OnDestroy);
00577         HANDLE_MSG(hwnd,WM_COMMAND,ReorderUI_OnCommand);
00578
00579     default:
00580         fProcessed=FALSE;
00581         break;
00582     }
00583     return (fProcessed);
00584 }
00585
00586 //****************************************************************************
00587 //
00588 // void LoadInstalledCodecs(void)
00589 //
00590 // Loads a list of the installed codecs w/ their properties.
00591 //
00592 //****************************************************************************
00593
00594 void LoadInstalledCodecs(void)
00595 {
00596     HRESULT hr = S_OK;
00597
00598     // Make sure that we have an IInstallAudioCodecs*
00599     if (NULL == pAudio)
00600     {
00601         DebugTextOut(TEXT("pAudio is NULL\n"));
00602         return;
00603     }
00604
00605     //free any existing info
00606     if (gtCodec==AUDIOCODEC)
00607     {
00608         if (NULL != gpsAudCapInfoList)
00609         {
00610             hr = pAudio->FreeBuffer(gpsAudCapInfoList);
00611             if (FAILED(hr))
00612             {
00613                 DebugTextOut(TEXT("pAudio->FreeBuffer failed. hr = 0x%08p\n"), hr);
00614                 return;
00615             }
00616         }
00617
00618         //Get Installed Audio Codecs
00619         hr = pAudio->EnumFormats(&gpsAudCapInfoList);
00620         if (FAILED(hr))
00621         {
00622             DebugTextOut(TEXT("pAudio->EnumFormats failed. hr = 0x%08p\n"), hr);
00623             gpsAudCapInfoList=NULL;
00624         }
00625         else
00626         {
00627             LocalFree(gpnAudCapOrderedIndex);
00628
00629             gpnAudCapOrderedIndex = (int *)LocalAlloc(LPTR,sizeof(int) * gpsAudCapInfoList->cFormats);
00630             if (NULL == gpnAudCapOrderedIndex)
00631             {
00632                 DebugTextOut(TEXT("Out of memory\n"));
00633             }
00634         }
00635     }
00636
00637     //Structures returned by EnumFormats not guarenteed to be inorder.
00638     IndexInstalledCodecs();
00639 }
00640
00641 //****************************************************************************
00642 //
00643 // void IndexInstalledCodecs(void)
00644 //
00645 // Updates the CapOrderedIndexes to contain lists of indexes to the codecs
00646 // represented in the CapInfoLists in installed order.
00647 //
00648 //****************************************************************************
00649
00650 void IndexInstalledCodecs(void)
00651 {
00652     unsigned int i;
00653
00654     if (NULL == gpsAudCapInfoList)
00655     {
00656         DebugTextOut(TEXT("gpsAudCapInfoList is NULL\n"));
00657         return;
00658     }
00659
00660     if (NULL == gpnAudCapOrderedIndex)
00661     {
00662         DebugTextOut(TEXT("gpnAudCapOrderedIndex is NULL\n"));
00663         return;
00664     }
00665
00666     if (gtCodec==AUDIOCODEC)
00667     {
00668         for (i=0;i<gpsAudCapInfoList->cFormats;i++)
00669         {
00670             gpnAudCapOrderedIndex[gpsAudCapInfoList->aFormats[i].wSortIndex]=i;
00671         }
00672     }
00673
00674 }
00675
00676 //****************************************************************************
00677 //
00678 // void UpdateCapInfoListsFromIndex(void)
00679 //
00680 // Updates the CapInfoLists with the installed order represended in the CapOrderedIndexes
00681 //
00682 //****************************************************************************
00683
00684 void UpdateCapInfoListsFromIndex(void)
00685 {
00686     unsigned int i;
00687
00688     if (NULL == gpsAudCapInfoList)
00689     {
00690         DebugTextOut(TEXT("gpsAudCapInfoList is NULL\n"));
00691         return;
00692     }
00693
00694     if (NULL == gpnAudCapOrderedIndex)
00695     {
00696         DebugTextOut(TEXT("gpnAudCapOrderedIndex is NULL\n"));
00697         return;
00698     }
00699
00700     if (gtCodec==AUDIOCODEC)
00701     {
00702         for (i=0;i<gpsAudCapInfoList->cFormats;i++)
00703         {
00704             gpsAudCapInfoList->aFormats[gpnAudCapOrderedIndex[i]].wSortIndex=i;
00705         }
00706     }
00707
00708 }
00709
00710 //****************************************************************************
00711 //
00712 // void DlgDisplayInstalledCodecs(HWND hwnd)
00713 //
00714 // Displays the installed codecs in the order specified by the CapOrderedIndexes.
00715 //
00716 //****************************************************************************
00717
00718 void DlgDisplayInstalledCodecs(HWND hwnd)
00719 {
00720     unsigned int    i;
00721     HWND            hListBox = NULL;
00722
00723     if (NULL == gpsAudCapInfoList)
00724     {
00725         DebugTextOut(TEXT("gpsAudCapInfoList is NULL\n"));
00726         return;
00727     }
00728
00729     if (NULL == gpnAudCapOrderedIndex)
00730     {
00731         DebugTextOut(TEXT("gpnAudCapOrderedIndex is NULL\n"));
00732         return;
00733     }
00734
00735     //Display Installed Codecs
00736     hListBox = GetDlgItem(hwnd,IDC_LBINSTALLEDCODECS);
00737     SendMessage(hListBox,LB_RESETCONTENT,0,0);
00738
00739     if (gtCodec==AUDIOCODEC)
00740     {
00741         for (i=0;i<gpsAudCapInfoList->cFormats;i++)
00742         {
00743             SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)(LPCSTR)gpsAudCapInfoList->aFormats[gpnAudCapOrderedIndex[i]].szFormat);
00744         }
00745     }
00746
00747 }
00748
00749
00750 //****************************************************************************
00751 //
00752 // void DebugTextOut(TCHAR* ptszFormat, ... )
00753 //
00754 //
00755 //
00756 //****************************************************************************
00757
00758 void DebugTextOut(TCHAR* ptszFormat, ... )
00759 {
00760     TCHAR       ptszBuffer[1048];
00761     va_list     pArgList;
00762
00763     va_start(pArgList, ptszFormat);
00764     _vsntprintf(ptszBuffer, sizeof(ptszBuffer)/sizeof(ptszBuffer[0]), ptszFormat, pArgList);
00765     va_end(pArgList);
00766
00767     OutputDebugString(ptszBuffer);
00768 }
00769
00770
00771 //*****************************************************************************
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcReq.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcReq.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "ACReq.h"
00052
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // CAgentCtlRequest properties
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CAgentCtlRequest operations
00059
00060 long CAgentCtlRequest::GetStatus()
00061 {
00062   long result;
00063   InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00064   return result;
00065 }
00066
00067 CString CAgentCtlRequest::GetDescription()
00068 {
00069   CString result;
00070   InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00071   return result;
00072 }
00073
00074 long CAgentCtlRequest::GetNumber()
00075 {
00076   long result;
00077   InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00078   return result;
00079 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMShare/CConf.h Source File

  • Web
  • NetMeeting
  • NMShare

CConf.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMSHARE.EXE
00003 //  File:       CCONF.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 //****************************************************************************
00017 //
00018 // CLASS CMgrNotify
00019 //
00020 //****************************************************************************
00021
00022 class CMgrNotify : public RefCount, public CNotify, public INmManagerNotify
00023 {
00024 public:
00025   CMgrNotify();
00026   ~CMgrNotify();
00027
00028   // INmManagerNotify
00029   HRESULT STDMETHODCALLTYPE NmUI(CONFN confn);
00030   HRESULT STDMETHODCALLTYPE ConferenceCreated(INmConference *pConference);
00031   HRESULT STDMETHODCALLTYPE CallCreated(INmCall *pCall);
00032
00033   // ICNotify methods
00034   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00035   HRESULT STDMETHODCALLTYPE Disconnect(void);
00036
00037   // IUnknown methods
00038   ULONG STDMETHODCALLTYPE AddRef(void);
00039   ULONG STDMETHODCALLTYPE Release(void);
00040   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00041 };
00042
00043
00044 //****************************************************************************
00045 //
00046 // CLASS CConfNotify
00047 //
00048 //****************************************************************************
00049
00050 class CConfNotify : public RefCount, public CNotify, public INmConferenceNotify
00051 {
00052 public:
00053   CConfNotify();
00054   ~CConfNotify();
00055
00056   // INmConferenceNotify
00057   HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
00058   HRESULT STDMETHODCALLTYPE StateChanged(NM_CONFERENCE_STATE uState);
00059   HRESULT STDMETHODCALLTYPE MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pfMember);
00060   HRESULT STDMETHODCALLTYPE ChannelChanged(NM_CHANNEL_NOTIFY uNotify, INmChannel *pChannel);
00061
00062   // ICNotify methods
00063   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00064   HRESULT STDMETHODCALLTYPE Disconnect(void);
00065
00066   // IUnknown methods
00067   ULONG STDMETHODCALLTYPE AddRef(void);
00068   ULONG STDMETHODCALLTYPE Release(void);
00069   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00070 };
00071
00072
00073
00074 // Global Variables
00075 extern INmManager * g_pMgr;
00076 extern INmConference * g_pConference;
00077
00078 // Global Functions
00079 HRESULT InitConfMgr(void);
00080 VOID FreeConfMgr(void);
00081 VOID FreeConference(void);
00082 HRESULT HookConference(INmConference * pConference);
00083
00084
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/CStorageResType.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

CStorageResType.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      CStorageResType.h
00005 //
00006 //  Description:
00007 //      This file contains the declaration of the CStorageResType class.
00008 //
00009 //  Implementation Files:
00010 //      CStorageResType.cpp
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 #pragma once
00015
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Include Files
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 #include "stdafx.h"
00022 #include "CMgdClusCfgInit.h"
00023
00024
00025 //////////////////////////////////////////////////////////////////////////////
00026 //++
00027 //
00028 //  class CStorageResType
00029 //
00030 //  Description:
00031 //      The CStorageResType class is an implementation of the
00032 //      IClusCfgResourceTypeInfo interface.
00033 //
00034 //--
00035 //////////////////////////////////////////////////////////////////////////////
00036 class CStorageResType
00037     : public IClusCfgResourceTypeInfo
00038     , public IClusCfgStartupListener
00039     , public CMgdClusCfgInit
00040     , public CComCoClass< CStorageResType, &CLSID_CStorageResType >
00041 {
00042 public:
00043     CStorageResType( void ) {}
00044     virtual ~CStorageResType( void ) {}
00045
00046 BEGIN_COM_MAP( CStorageResType )
00047     COM_INTERFACE_ENTRY( IClusCfgResourceTypeInfo )
00048     COM_INTERFACE_ENTRY( IClusCfgStartupListener )
00049     COM_INTERFACE_ENTRY( IClusCfgInitialize )
00050 END_COM_MAP()
00051
00052 DECLARE_NOT_AGGREGATABLE( CStorageResType )
00053
00054 BEGIN_CATEGORY_MAP( CStorageResType )
00055     IMPLEMENTED_CATEGORY( CATID_ClusCfgResourceTypes )
00056     IMPLEMENTED_CATEGORY( CATID_ClusCfgStartupListeners )
00057 END_CATEGORY_MAP()
00058
00059 #pragma warning( push, 3 )
00060 #pragma warning( disable : 4995 ) // warning C4995: '<x>': name was marked as #pragma deprecated
00061 DECLARE_REGISTRY_RESOURCEID(IDR_CStorageResType)
00062 #pragma warning( pop )
00063
00064     //
00065     //  IClusCfgResourceTypeInfo interface
00066     //
00067
00068     STDMETHOD( CommitChanges )( IUnknown * punkClusterInfoIn, IUnknown * punkResTypeServicesIn );
00069     STDMETHOD( GetTypeGUID )( GUID * pguidGUIDOut );
00070     STDMETHOD( GetTypeName )( BSTR * pbstrTypeNameOut );
00071
00072     //
00073     //  IClusCfgStartupListener methods
00074     //
00075
00076     STDMETHOD( Notify )( IUnknown * punkIn );
00077
00078 private:
00079
00080     //
00081     //  Private copy constructor to avoid copying.
00082     //
00083
00084     CStorageResType( const CStorageResType & rSrcIn );
00085
00086     //
00087     //  Private assignment operator to avoid copying.
00088     //
00089
00090     const CStorageResType & operator = ( const CStorageResType & rSrcIn );
00091
00092 }; //*** class CStorageResType
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Colors.h Source File

  • WinUI
  • CommDlg
  • CDTest

Colors.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 void DoColorsDialog(HWND) ;
00007 INT_PTR APIENTRY ColorsProc(HWND, UINT, WPARAM, LPARAM) ;
00008
00009
00010 #define ID_HWNDOWNERC               500
00011 #define ID_STRUCTSIZEC              501
00012 #define ID_HINSTANCEC               502
00013 #define ID_CUSTCOLORSC              503
00014 #define ID_CUSTDATAC                504
00015 #define ID_HOOKC                    505
00016 #define ID_TEMPLATEC                506
00017 #define ID_RGBRESULTC               507
00018 #define ID_ADD1C                    508
00019 #define ID_CLEAR1C                  509
00020 #define ID_ERRORC                   510
00021 #define ID_RETURNC                  511
00022
00023 #define ID_COLORSDIALOG             602
00024
00025 #define ID_FLAGSC                   512
00026 #define ID_RESETC                   603
00027 #define ID_NULLSTRUCTCOLOR          604
00028 #define ID_PRELOADEDCOLORS          605
00029 #define ID_MULTITHREADCOLORS        606
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authentication/StdAfx.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • Authentication

StdAfx.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       StdAfx.cpp
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 // stdafx.cpp : source file that includes just the standard includes
00013 //  stdafx.pch will be the pre-compiled header
00014 //  stdafx.obj will contain the pre-compiled type information
00015
00016 #include "stdafx.h"
00017
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ComObj/CRUCAR.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • ComObj

CRUCAR.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CRUCAR.H
00003
00004   Summary:   Include file for the aggregatable COCruiseCar COM object class.
00005
00006              CRUCAR showcases the construction of the COCruiseCar COM
00007              object class with the IUnknown, ICar, and ICruise interfaces.
00008              This is done through Aggregation reuse of a COCar COM
00009              object (specifically providing its ICar interface features).
00010
00011              This multiple interface COM Object Class is achieved via
00012              the technique of nested classes: the implementation of the
00013              ICar and ICruise interfaces are nested inside of the
00014              COCruiseCar COM object class.
00015
00016              For a comprehensive tutorial code tour of this module's
00017              contents and offerings see the tutorial COMOBJ.HTM
00018              file.  For more specific technical details on the internal
00019              workings see the comments dispersed throughout the
00020              module's source code.
00021
00022   Classes:   COCruiseCar
00023
00024   Functions: .
00025
00026   Origin:    8-21-95: atrent - Editor inheritance from UTILCAR.H.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 #if !defined(CRUCAR_H)
00044 #define CRUCAR_H
00045
00046 #ifdef __cplusplus
00047
00048 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00049   ObjectClass: COCruiseCar
00050
00051   Summary:     COM Object Class for COCruiseCar COM Objects.  COM objects
00052                of this class augment COCar COM objects (which offer ICar
00053                interface features of Shift, Clutch, Speed, and Steer) with
00054                ICruise interface features (Engage and Adjust).  This
00055                COCruiseCar COM object class is constructed by aggregation
00056                reuse of the COCar COM object class.  The mulitple
00057                interfaces on this COM object class are constructed via
00058                the nested interface classes technique.
00059
00060   Interfaces:  IUnknown
00061                  Standard interface providing COM object features.
00062                ICar
00063                  Basic Car operation features.
00064                ICruise
00065                  Cruise control features.
00066
00067   Aggregation: Yes, COCruiseCar COM objects are aggregatable by passing
00068                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00069 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00070 class COCruiseCar : public IUnknown
00071 {
00072   public:
00073     // Main Object Constructor & Destructor.
00074     COCruiseCar(IUnknown* pUnkOuter);
00075     ~COCruiseCar(void);
00076
00077     // A general public method for initializing this newly created
00078     // COCruiseCar object. Creates any subordinate arrays, structures, or
00079     // objects. Not exposed as a method in an interface.
00080     HRESULT Init(void);
00081
00082     // IUnknown methods. Main object, non-delegating.
00083     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00084     STDMETHODIMP_(ULONG) AddRef(void);
00085     STDMETHODIMP_(ULONG) Release(void);
00086
00087   private:
00088     // We declare nested class interface implementations here.
00089
00090     // We implement the ICruise interface (ofcourse) in this COCruiseCar
00091     // COM object class.  This is the interface that we are using as an
00092     // augmentation to the existing COCar COM object class.
00093     class CImpICruise : public ICruise
00094     {
00095       public:
00096         // Interface Implementation Constructor & Destructor.
00097         CImpICruise(COCruiseCar* pBackObj, IUnknown* pUnkOuter);
00098         ~CImpICruise(void);
00099
00100         // IUnknown methods.
00101         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00102         STDMETHODIMP_(ULONG) AddRef(void);
00103         STDMETHODIMP_(ULONG) Release(void);
00104
00105         // ICruise methods.
00106         STDMETHODIMP Engage(BOOL bOnOff);
00107         STDMETHODIMP Adjust(BOOL bUpDown);
00108
00109       private:
00110         // Data private to this interface implementation of ICruise.
00111         ULONG         m_cRefI;       // Interface Ref Count (for debugging).
00112         COCruiseCar*  m_pBackObj;    // Parent Object back pointer.
00113         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00114     };
00115
00116     // Make the otherwise private and nested ICar interface implementation
00117     // a friend to COM object instantiations of this selfsame COCruiseCar
00118     // COM object class.
00119     friend CImpICruise;
00120
00121     // Private data of COCruiseCar COM objects.
00122
00123     // Nested ICruise implementation instantiation.  This ICruise interface
00124     // is implemented inside this COCruiseCar object as a native interface.
00125     CImpICruise     m_ImpICruise;
00126
00127     // Main Object reference count.
00128     ULONG           m_cRefs;
00129
00130     // Outer unknown (aggregation & delegation). Used when this COCruiseCar
00131     // object is being aggregated.  Otherwise it is used for delegation
00132     // if this object is reused via containment.
00133     IUnknown*       m_pUnkOuter;
00134
00135     // We need to save the IUnknown interface pointer on the COCar
00136     // object that we aggregate.  We use this when we need to delegate
00137     // IUnknown calls to this aggregated inner object.
00138     IUnknown*       m_pUnkCar;
00139 };
00140
00141 typedef COCruiseCar* PCOCruiseCar;
00142
00143 #endif // __cplusplus
00144
00145
00146 #endif // CRUCAR_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/TPCInfo/resource.h Source File

  • TabletPC
  • TPCInfo

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by TPCInfo.rc
00004 //
00005 #define IDI_INK_ICON                    100
00006 #define IDD_DIALOG                      102
00007 #define IDC_TABLETPC_ENABLED            1001
00008 #define IDC_TABLETPC                    1001
00009 #define IDC_TABLETPC_DISABLED           1002
00010 #define IDC_TSF                         1002
00011 #define IDC_DEFAULT_HW_RECO             1003
00012 #define IDC_HWR_NAME                    1003
00013 #define IDC_DEFAULT_SPEECH_RECO         1004
00014 #define IDC_SPR_NAME                    1004
00015 #define IDC_CONTROL1                    1005
00016 #define IDC_CTL1_NAME                   1005
00017 #define IDC_CONTROL2                    1006
00018 #define IDC_HWR_VENDOR                  1007
00019 #define IDC_SPR_VENDOR                  1008
00020 #define IDC_CTL1_VER                    1009
00021 #define IDC_CTL2_NAME                   1010
00022 #define IDC_CTL2_VER                    1011
00023
00024 // Next default values for new objects
00025 //
00026 #ifdef APSTUDIO_INVOKED
00027 #ifndef APSTUDIO_READONLY_SYMBOLS
00028 #define _APS_NEXT_RESOURCE_VALUE        104
00029 #define _APS_NEXT_COMMAND_VALUE         40001
00030 #define _APS_NEXT_CONTROL_VALUE         1022
00031 #define _APS_NEXT_SYMED_VALUE           101
00032 #endif
00033 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventConsumer/PermEventsdlg.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • EventConsumer

PermEventsdlg.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  PermEventsDlg.cpp
00006 //
00007 // Description:
00008 //    implementation file for event consumer sample dialog box
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #include "stdafx.h"
00015 #include "PermEvents.h"
00016 #include "PermEventsDlg.h"
00017
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CAboutDlg dialog used for App About
00026
00027 class CAboutDlg : public CDialog
00028 {
00029 public:
00030   CAboutDlg();
00031
00032 // Dialog Data
00033   //{{AFX_DATA(CAboutDlg)
00034   enum { IDD = IDD_ABOUTBOX };
00035   //}}AFX_DATA
00036
00037   // ClassWizard generated virtual function overrides
00038   //{{AFX_VIRTUAL(CAboutDlg)
00039   protected:
00040   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00041   //}}AFX_VIRTUAL
00042
00043 // Implementation
00044 protected:
00045   //{{AFX_MSG(CAboutDlg)
00046   //}}AFX_MSG
00047   DECLARE_MESSAGE_MAP()
00048 };
00049
00050 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00051 {
00052   //{{AFX_DATA_INIT(CAboutDlg)
00053   //}}AFX_DATA_INIT
00054 }
00055
00056 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00057 {
00058   CDialog::DoDataExchange(pDX);
00059   //{{AFX_DATA_MAP(CAboutDlg)
00060   //}}AFX_DATA_MAP
00061 }
00062
00063 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00064   //{{AFX_MSG_MAP(CAboutDlg)
00065     // No message handlers
00066   //}}AFX_MSG_MAP
00067 END_MESSAGE_MAP()
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 // CPermEventsDlg dialog
00071
00072 CPermEventsDlg::CPermEventsDlg(CWnd* pParent /*=NULL*/)
00073   : CDialog(CPermEventsDlg::IDD, pParent)
00074 {
00075   //{{AFX_DATA_INIT(CPermEventsDlg)
00076     // NOTE: the ClassWizard will add member initialization here
00077   //}}AFX_DATA_INIT
00078   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
00079   m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00080 }
00081
00082 void CPermEventsDlg::DoDataExchange(CDataExchange* pDX)
00083 {
00084   CDialog::DoDataExchange(pDX);
00085   //{{AFX_DATA_MAP(CPermEventsDlg)
00086   DDX_Control(pDX, IDC_OUTPUTLIST, m_outputList);
00087   //}}AFX_DATA_MAP
00088 }
00089
00090 BEGIN_MESSAGE_MAP(CPermEventsDlg, CDialog)
00091   //{{AFX_MSG_MAP(CPermEventsDlg)
00092   ON_WM_SYSCOMMAND()
00093   ON_WM_PAINT()
00094   ON_WM_QUERYDRAGICON()
00095   //}}AFX_MSG_MAP
00096 END_MESSAGE_MAP()
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // CPermEventsDlg message handlers
00100
00101 BOOL CPermEventsDlg::OnInitDialog()
00102 {
00103   CDialog::OnInitDialog();
00104
00105   // Add "About..." menu item to system menu.
00106
00107   // IDM_ABOUTBOX must be in the system command range.
00108   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00109   ASSERT(IDM_ABOUTBOX < 0xF000);
00110
00111   CMenu* pSysMenu = GetSystemMenu(FALSE);
00112   if (pSysMenu != NULL)
00113   {
00114     CString strAboutMenu;
00115     strAboutMenu.LoadString(IDS_ABOUTBOX);
00116     if (!strAboutMenu.IsEmpty())
00117     {
00118       pSysMenu->AppendMenu(MF_SEPARATOR);
00119       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
00120     }
00121   }
00122
00123   // Set the icon for this dialog.  The framework does this automatically
00124   //  when the application's main window is not a dialog
00125   SetIcon(m_hIcon, TRUE);     // Set big icon
00126   SetIcon(m_hIcon, FALSE);    // Set small icon
00127
00128   // TODO: Add extra initialization here
00129
00130   return TRUE;  // return TRUE  unless you set the focus to a control
00131 }
00132
00133 void CPermEventsDlg::OnSysCommand(UINT nID, LPARAM lParam)
00134 {
00135   if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00136   {
00137     CAboutDlg dlgAbout;
00138     dlgAbout.DoModal();
00139   }
00140   else
00141   {
00142     CDialog::OnSysCommand(nID, lParam);
00143   }
00144 }
00145
00146 // If you add a minimize button to your dialog, you will need the code below
00147 //  to draw the icon.  For MFC applications using the document/view model,
00148 //  this is automatically done for you by the framework.
00149
00150 void CPermEventsDlg::OnPaint()
00151 {
00152   if (IsIconic())
00153   {
00154     CPaintDC dc(this); // device context for painting
00155
00156     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
00157
00158     // Center icon in client rectangle
00159     int cxIcon = GetSystemMetrics(SM_CXICON);
00160     int cyIcon = GetSystemMetrics(SM_CYICON);
00161     CRect rect;
00162     GetClientRect(&rect);
00163     int x = (rect.Width() - cxIcon + 1) / 2;
00164     int y = (rect.Height() - cyIcon + 1) / 2;
00165
00166     // Draw the icon
00167     dc.DrawIcon(x, y, m_hIcon);
00168   }
00169   else
00170   {
00171     CDialog::OnPaint();
00172   }
00173 }
00174
00175 // The system calls this to obtain the cursor to display while the user drags
00176 //  the minimized window.
00177 HCURSOR CPermEventsDlg::OnQueryDragIcon()
00178 {
00179   return (HCURSOR) m_hIcon;
00180 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/space.Cpp Source File

  • SysMgmt
  • MMC
  • CMenu

space.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Space.h"
00021 #include "Comp.h"
00022 #include <stdio.h>
00023 #define STRSAFE_NO_DEPRECATE
00024 #include <strsafe.h>
00025
00026 const GUID CSpaceVehicle::thisGuid = { 0x29743810, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00027 const GUID CRocket::thisGuid = { 0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00028
00029 //==============================================================
00030 //
00031 // CSpaceVehicle implementation
00032 //
00033 //
00034 CSpaceVehicle::CSpaceVehicle()
00035 {
00036     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00037         children[n] = new CRocket();
00038         children[n]->Initialize(_T("Vehicle"), 500000, 265, 75000);
00039     }
00040 }
00041
00042 CSpaceVehicle::~CSpaceVehicle()
00043 {
00044     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00045         if (children[n]) {
00046             delete children[n];
00047         }
00048 }
00049
00050 HRESULT CSpaceVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00051 {
00052     HRESULT      hr = S_OK;
00053
00054     IHeaderCtrl *pHeaderCtrl = NULL;
00055     IResultData *pResultData = NULL;
00056
00057     if (bShow) {
00058         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00059         _ASSERT( SUCCEEDED(hr) );
00060
00061         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00062         _ASSERT( SUCCEEDED(hr) );
00063
00064         // Set the column headers in the results pane
00065         hr = pHeaderCtrl->InsertColumn( 0, L"Rocket Class", 0, MMCLV_AUTO );
00066         _ASSERT( S_OK == hr );
00067         hr = pHeaderCtrl->InsertColumn( 1, L"Rocket Weight", 0, MMCLV_AUTO );
00068         _ASSERT( S_OK == hr );
00069         hr = pHeaderCtrl->InsertColumn( 2, L"Rocket Height", 0, MMCLV_AUTO );
00070         _ASSERT( S_OK == hr );
00071         hr = pHeaderCtrl->InsertColumn( 3, L"Rocket Payload", 0, MMCLV_AUTO );
00072         _ASSERT( S_OK == hr );
00073         hr = pHeaderCtrl->InsertColumn( 4, L"Status", 0, MMCLV_AUTO );
00074         _ASSERT( S_OK == hr );
00075
00076         // insert items here
00077         RESULTDATAITEM rdi;
00078
00079         hr = pResultData->DeleteAllRsltItems();
00080         _ASSERT( SUCCEEDED(hr) );
00081
00082         if (!bExpanded) {
00083             // create the child nodes, then expand them
00084             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00085                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00086                 rdi.mask       = RDI_STR       |   // Displayname is valid
00087                     RDI_IMAGE     |
00088                     RDI_PARAM;        // nImage is valid
00089
00090                 rdi.nImage      = children[n]->GetBitmapIndex();
00091                 rdi.str         = MMC_CALLBACK;
00092                 rdi.nCol        = 0;
00093                 rdi.lParam      = (LPARAM)children[n];
00094
00095                 hr = pResultData->InsertItem( &rdi );
00096
00097                 _ASSERT( SUCCEEDED(hr) );
00098             }
00099         }
00100
00101         pHeaderCtrl->Release();
00102         pResultData->Release();
00103     }
00104
00105     return hr;
00106 }
00107
00108 HRESULT CSpaceVehicle::OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed)
00109 {
00110     HRESULT hr = S_OK;
00111     CONTEXTMENUITEM menuItemsNew[] =
00112     {
00113         {
00114             L"Space based", L"Add a new space based vehicle",
00115                 IDM_NEW_SPACE, CCM_INSERTIONPOINTID_PRIMARY_NEW, 0, CCM_SPECIAL_DEFAULT_ITEM
00116         },
00117         { NULL, NULL, 0, 0, 0 }
00118     };
00119
00120     // Loop through and add each of the menu items
00121     if (*pInsertionsAllowed & CCM_INSERTIONALLOWED_NEW)
00122     {
00123         for (LPCONTEXTMENUITEM m = menuItemsNew; m->strName; m++)
00124         {
00125             hr = pContextMenuCallback->AddItem(m);
00126
00127             if (FAILED(hr))
00128                 break;
00129         }
00130     }
00131
00132     return hr;
00133 }
00134
00135 HRESULT CSpaceVehicle::OnMenuCommand(IConsole *pConsole, long lCommandID)
00136 {
00137     switch (lCommandID)
00138     {
00139     case IDM_NEW_SPACE:
00140         pConsole->MessageBox(L"This sample does not create a new item\nSee Complete sample for a demonstration", L"Menu Command", MB_OK|MB_ICONINFORMATION, NULL);
00141         break;
00142     }
00143
00144     return S_OK;
00145 }
00146
00147 //==============================================================
00148 //
00149 // CRocket implementation
00150 //
00151 //
00152 CRocket::CRocket()
00153 : szName(NULL), lWeight(0), lHeight(0), lPayload(0), iStatus(STOPPED)
00154 {
00155 }
00156
00157 CRocket::~CRocket()
00158 {
00159     if (szName)
00160         delete [] szName;
00161 }
00162
00163 void CRocket::Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload)
00164 {
00165     if (szName) {
00166         this->szName = new _TCHAR[_tcslen(szName) + 1];
00167         _tcscpy(this->szName, szName);
00168     }
00169
00170     this->lWeight = lWeight;
00171     this->lHeight = lHeight;
00172     this->lPayload = lPayload;
00173 }
00174
00175 const _TCHAR *CRocket::GetDisplayName(int nCol)
00176 {
00177     const size_t cchBuffer = 128;
00178     static _TCHAR buf[cchBuffer];
00179
00180     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00181     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00182
00183     switch (nCol) {
00184     case 0:
00185         StringCchCopy(buf, cchBuffer, szName ? szName : _T(""));
00186         break;
00187
00188     case 1:
00189         StringCchPrintf(buf, cchBuffer, _T("%ld metric tons"), lWeight);
00190         break;
00191
00192     case 2:
00193         StringCchPrintf(buf, cchBuffer, _T("%ld meters"), lHeight);
00194         break;
00195
00196     case 3:
00197         StringCchPrintf(buf, cchBuffer, _T("%ld kilos"), lPayload);
00198         break;
00199
00200     case 4:
00201         StringCchPrintf(buf, cchBuffer, _T("%s"),
00202             iStatus == RUNNING ? _T("running") :
00203         iStatus == PAUSED ? _T("paused") :
00204         iStatus == STOPPED ? _T("stopped") : _T("unknown"));
00205         break;
00206
00207     }
00208
00209     return buf;
00210 }
00211
00212 HRESULT CRocket::OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed)
00213 {
00214     HRESULT hr = S_OK;
00215     CONTEXTMENUITEM menuItemsTask[] =
00216     {
00217         {
00218             L"Start vehicle", L"Start the space vehicle",
00219                 IDM_START_SPACE, CCM_INSERTIONPOINTID_PRIMARY_TASK, 0, CCM_SPECIAL_DEFAULT_ITEM
00220         },
00221         {
00222             L"Pause vehicle", L"Pause the space vehicle",
00223                 IDM_PAUSE_SPACE, CCM_INSERTIONPOINTID_PRIMARY_TASK, 0, 0
00224         },
00225         {
00226             L"Stop vehicle", L"Stop the space vehicle",
00227                 IDM_STOP_SPACE, CCM_INSERTIONPOINTID_PRIMARY_TASK, 0, 0
00228         },
00229         { NULL, NULL, 0, 0, 0 }
00230     };
00231
00232     // Loop through and add each of the menu items
00233     if (*pInsertionsAllowed & CCM_INSERTIONALLOWED_TASK)
00234     {
00235         for (LPCONTEXTMENUITEM m = menuItemsTask; m->strName; m++)
00236         {
00237             hr = pContextMenuCallback->AddItem(m);
00238
00239             if (FAILED(hr))
00240                 break;
00241         }
00242     }
00243
00244     return hr;
00245 }
00246
00247 HRESULT CRocket::OnMenuCommand(IConsole *pConsole, long lCommandID)
00248 {
00249     const size_t cchBuffer = 128;
00250     _TCHAR szVehicle[cchBuffer];
00251
00252     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00253     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00254
00255     switch (lCommandID) {
00256     case IDM_START_SPACE:
00257         iStatus = RUNNING;
00258         break;
00259
00260     case IDM_PAUSE_SPACE:
00261         iStatus = PAUSED;
00262         break;
00263
00264     case IDM_STOP_SPACE:
00265         iStatus = STOPPED;
00266         break;
00267     }
00268
00269     StringCchPrintf(szVehicle, cchBuffer, _T("%s has been %s"), szName,
00270         (long)iStatus == RUNNING ? _T("started") :
00271     (long)iStatus == PAUSED ? _T("paused") :
00272     (long)iStatus == STOPPED ? _T("stopped") : _T("!!!unknown command!!!"));
00273
00274     MAKE_WIDEPTR_FROMTSTR(ptrname, szVehicle);
00275     int ret = 0;
00276     pConsole->MessageBox(ptrname,
00277         L"Vehicle command", MB_OK | MB_ICONINFORMATION, &ret);
00278
00279     return S_OK;
00280   }
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/winhttp/WinHttpAsyncSample/defs.h Source File

  • Web
  • winhttp
  • WinHttpAsyncSample

defs.h

Go to the documentation of this file.
00001 //  WinHttpAsyncSample
00002 //  Copyright (c) Microsoft Corporation. All rights reserved.
00003
00004 #ifndef _DEFS_H
00005 #define _DEFS_H
00006
00007 #define ASSERT(fVal) if (!(fVal)) DebugBreak();
00008
00009 /*++
00010
00011 LINK list:
00012
00013     Definitions for a double link list.
00014
00015 --*/
00016
00017 //
00018 // Calculate the address of the base of the structure given its type, and an
00019 // address of a field within the structure.
00020 //
00021 #ifndef CONTAINING_RECORD
00022 #define CONTAINING_RECORD(address, type, field) \
00023     ((type *)((PCHAR)(address) - (ULONG_PTR)(&((type *)0)->field)))
00024 #endif
00025
00026
00027 #ifndef InitializeListHead
00028 //
00029 //  VOID
00030 //  InitializeListHead(
00031 //      PLIST_ENTRY ListHead
00032 //      );
00033 //
00034
00035 #define InitializeListHead(ListHead) (\
00036     (ListHead)->Flink = (ListHead)->Blink = (ListHead))
00037
00038 //
00039 //  BOOLEAN
00040 //  IsListEmpty(
00041 //      PLIST_ENTRY ListHead
00042 //      );
00043 //
00044
00045 #define IsListEmpty(ListHead) \
00046     ((ListHead)->Flink == (ListHead))
00047
00048 //
00049 //  PLIST_ENTRY
00050 //  RemoveHeadList(
00051 //      PLIST_ENTRY ListHead
00052 //      );
00053 //
00054
00055 #define RemoveHeadList(ListHead) \
00056     (ListHead)->Flink;\
00057     {RemoveEntryList((ListHead)->Flink)}
00058
00059 //
00060 //  PLIST_ENTRY
00061 //  RemoveTailList(
00062 //      PLIST_ENTRY ListHead
00063 //      );
00064 //
00065
00066 #define RemoveTailList(ListHead) \
00067     (ListHead)->Blink;\
00068     {RemoveEntryList((ListHead)->Blink)}
00069
00070 //
00071 //  VOID
00072 //  RemoveEntryList(
00073 //      PLIST_ENTRY Entry
00074 //      );
00075 //
00076
00077 #define RemoveEntryList(Entry) {\
00078     PLIST_ENTRY _EX_Blink;\
00079     PLIST_ENTRY _EX_Flink;\
00080     _EX_Flink = (Entry)->Flink;\
00081     _EX_Blink = (Entry)->Blink;\
00082     _EX_Blink->Flink = _EX_Flink;\
00083     _EX_Flink->Blink = _EX_Blink;\
00084     }
00085
00086 //
00087 //  VOID
00088 //  InsertTailList(
00089 //      PLIST_ENTRY ListHead,
00090 //      PLIST_ENTRY Entry
00091 //      );
00092 //
00093
00094 #define InsertTailList(ListHead,Entry) {\
00095     PLIST_ENTRY _EX_Blink;\
00096     PLIST_ENTRY _EX_ListHead;\
00097     _EX_ListHead = (ListHead);\
00098     _EX_Blink = _EX_ListHead->Blink;\
00099     (Entry)->Flink = _EX_ListHead;\
00100     (Entry)->Blink = _EX_Blink;\
00101     _EX_Blink->Flink = (Entry);\
00102     _EX_ListHead->Blink = (Entry);\
00103     }
00104
00105 //
00106 //  VOID
00107 //  InsertHeadList(
00108 //      PLIST_ENTRY ListHead,
00109 //      PLIST_ENTRY Entry
00110 //      );
00111 //
00112
00113 #define InsertHeadList(ListHead,Entry) {\
00114     PLIST_ENTRY _EX_Flink;\
00115     PLIST_ENTRY _EX_ListHead;\
00116     _EX_ListHead = (ListHead);\
00117     _EX_Flink = _EX_ListHead->Flink;\
00118     (Entry)->Flink = _EX_Flink;\
00119     (Entry)->Blink = _EX_ListHead;\
00120     _EX_Flink->Blink = (Entry);\
00121     _EX_ListHead->Flink = (Entry);\
00122     }
00123
00124
00125
00126 BOOL IsNodeOnList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
00127
00128
00129 #endif //InitializeListHead
00130
00131 #endif // _DEFS_H
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/registry.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

registry.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef __Registry_H__
00015 #define __Registry_H__
00016
00017 #include <tchar.h>
00018
00019 // This function will register a component in the Registry.
00020 // The component calls this function from its DllRegisterServer function.
00021 HRESULT RegisterServer( HMODULE hModule,
00022                         const CLSID& clsid,
00023                         const TCHAR* szFriendlyName) ;
00024
00025 // This function will unregister a component.  Components
00026 // call this function from their DllUnregisterServer function.
00027 HRESULT UnregisterServer( const CLSID& clsid ) ;
00028
00029
00030 // This function will register a Snap-In component.  Components
00031 // call this function from their DllRegisterServer function.
00032 HRESULT RegisterSnapin( const CLSID& clsid,            // Class ID
00033                         const TCHAR* szNameString,     // NameString
00034                         const CLSID& clsidAbout,       // Class Id for About Class
00035                         const BOOL fSupportExtensions = FALSE
00036                       );
00037
00038 HRESULT UnregisterSnapin( const CLSID& clsid );        // Class ID
00039
00040 #endif //__Registry_H__
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/SockAuth/Server.cpp Source File

  • Security
  • SSPI
  • SockAuth

Server.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 Module Name:
00006
00007     server.cpp
00008
00009 Abstract:
00010
00011     A command line app that establishes an authenticated connection
00012    with a client.
00013
00014 Revision History:
00015
00016 --*/
00017
00018 #include <windows.h>
00019 #include <winsock.h>
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include "security.h"
00023 #include "comm.h"
00024 #define SECURITY_WIN32
00025 #include "sspi.h"
00026
00027
00028 #define SOCKET_BUFF_SIZE   65536
00029 #define SMALL_BUFF         256
00030
00031 BOOL AcceptAuthSocket (SOCKET *s);
00032 BOOL CloseAuthSocket (SOCKET *s);
00033 BOOL DoAuthentication (SOCKET s);
00034
00035 static PBYTE g_pInBuf = NULL;
00036 static DWORD g_cbMaxMessage = 0;
00037 static unsigned short g_usPort = 2000;
00038 static TCHAR g_lpPackageName[SMALL_BUFF];
00039 static BOOL  g_fUseConfidentiality = FALSE;
00040 static BOOL  g_fUseIntegrity = FALSE;
00041 static BOOL  g_fVerbose = FALSE;
00042
00043 void Usage(void)
00044 {
00045
00046    printf ("usage: server [ <options> ]\n");
00047    printf ("\n");
00048    printf ("    -h              show usage\n");
00049    printf ("    -p<package>     name of security package (default = negotiate).\n");
00050    printf ("    -c              message confidentiality (encryption).\n");
00051    printf ("    -i              message integrity (signing).\n");
00052    printf ("    -v              verbose mode.\n");
00053    printf ("\n");
00054    printf ("  example: server -pnegotiate -c\n");
00055
00056 }
00057
00058 void main (int argc, char *argv[])
00059 {
00060    PCHAR pMessage = NULL;
00061    DWORD cbMessage = 0;
00062    PBYTE pDataToClient = NULL;
00063    DWORD cbDataToClient = 0;
00064    PCHAR pUserName = NULL;
00065    DWORD cbUserName = 0;
00066    SOCKET s = 0;
00067
00068    int    i;
00069    int    iOption;
00070    char   *pszOption = NULL;
00071
00072    printf("\nUse \"%s /h\" to see the options for this sample application\n\n",
00073       argv[0]);
00074
00075    // default package is negotiate
00076    //
00077    lstrcpy(g_lpPackageName, "Negotiate");
00078
00079    for(i = 1; i < argc; i++)
00080    {
00081       if(argv[i][0] == '/') argv[i][0] = '-';
00082
00083       if(argv[i][0] != '-')
00084       {
00085          printf("**** Invalid argument \"%s\"\n", argv[i]);
00086          Usage();
00087          return;
00088       }
00089       iOption = argv[i][1];
00090       pszOption = &argv[i][2];
00091
00092       switch(iOption)
00093       {
00094       case 'h':
00095          Usage();
00096          return;
00097
00098       case 'p':
00099          lstrcpyn(g_lpPackageName, pszOption, 1024);
00100          break;
00101
00102       case 'c':
00103          g_fUseConfidentiality = TRUE;
00104          break;
00105
00106       case 'i':
00107          g_fUseIntegrity = TRUE;
00108          break;
00109
00110       case 'v':
00111          g_fVerbose = TRUE;
00112          break;
00113
00114       default:
00115          printf("**** Invalid option \"%s\"\n", argv[i]);
00116          Usage();
00117          return;
00118
00119       }
00120
00121    }
00122
00123    // initialize
00124    //
00125    if (!InitWinsock ())
00126       goto cleanup;
00127
00128    if (!InitPackage (g_lpPackageName, g_fVerbose))
00129       goto cleanup;
00130
00131    g_pInBuf = (PBYTE) malloc (SOCKET_BUFF_SIZE);
00132
00133    if (NULL == g_pInBuf)
00134       goto cleanup;
00135
00136    //
00137    // Start looping for clients
00138    //
00139    while(TRUE)
00140    {
00141
00142       printf("Waiting for client to connect...\n");
00143
00144       // Make an authenticated connection with client
00145       //
00146       if (!AcceptAuthSocket (&s))
00147          goto endsession;
00148
00149       // impersonate the client
00150       //
00151       if (!ImpersonateContext (s))
00152          goto endsession;
00153
00154       GetUserName (NULL, &cbUserName);
00155       pUserName = (PCHAR) malloc (cbUserName);
00156
00157       if (!pUserName)
00158          goto cleanup;
00159
00160       if (!GetUserName (pUserName, &cbUserName))
00161          goto cleanup;
00162
00163       // display the user name
00164       //
00165       printf ("Client connected as user %s\n", pUserName);
00166
00167       // revert to self
00168       //
00169       if (!RevertContext (s))
00170          goto cleanup;
00171
00172       //
00173       // Send back the client's username
00174       //
00175       cbMessage = cbUserName;
00176       pMessage = pUserName;
00177
00178       // do the appropriate operation as the context attributes indicate
00179       //
00180       if(g_fUseConfidentiality)
00181       {
00182          EncryptThis (
00183             s,
00184             (PBYTE) pMessage,
00185             cbMessage,
00186             &pDataToClient,
00187             &cbDataToClient
00188             );
00189       }
00190
00191       else
00192       {
00193          // only sign if we didn't encrypt
00194          //
00195          if(g_fUseIntegrity)
00196          {
00197             SignThis (
00198                s,
00199                (PBYTE) pMessage,
00200                cbMessage,
00201                &pDataToClient,
00202                &cbDataToClient
00203                );
00204          }
00205
00206          // do the default and just send the raw message
00207          //
00208          else
00209          {
00210             pDataToClient = (PBYTE) malloc(cbMessage);
00211             memcpy(pDataToClient, pMessage, cbMessage);
00212             cbDataToClient = cbMessage;
00213          }
00214
00215       }
00216
00217
00218 endsession:
00219
00220       // send data to client
00221       //
00222       if (!SendBytes (s, pDataToClient, cbDataToClient))
00223          goto cleanup;
00224
00225
00226       if (s)
00227       {
00228          CloseAuthSocket (&s);
00229          s = 0;
00230       }
00231
00232       if (pUserName)
00233       {
00234          free (pUserName);
00235          pUserName = NULL;
00236          cbUserName = 0;
00237       }
00238
00239       if(pDataToClient)
00240       {
00241          free (pDataToClient);
00242          pDataToClient = NULL;
00243          cbDataToClient = 0;
00244       }
00245
00246       g_fUseConfidentiality = 0;
00247       g_fUseIntegrity =0;
00248
00249       printf("\n");
00250
00251    }
00252
00253 cleanup:
00254
00255    if (g_pInBuf)
00256       free (g_pInBuf);
00257
00258    TermPackage ();
00259
00260    TermWinsock ();
00261
00262
00263 }
00264
00265 BOOL AcceptAuthSocket (SOCKET *s)
00266 /*++
00267
00268  Routine Description:
00269
00270     Establishes an authenticated socket connection with a client and
00271    initializes any needed security package resources.
00272
00273  Return Value:
00274
00275     Returns TRUE is successful; otherwise FALSE is returned.
00276
00277 --*/
00278 {
00279    SOCKET sockListen;
00280    SOCKET sockClient;
00281    SOCKADDR_IN sin;
00282    int nRes;
00283
00284    // create listening socket
00285    //
00286    sockListen = socket (PF_INET, SOCK_STREAM, 0);
00287    if (INVALID_SOCKET == sockListen)  {
00288       fprintf (stderr, "Failed to create socket: %u\n", GetLastError ());
00289       return(FALSE);
00290    }
00291
00292    // bind to local port
00293    //
00294    sin.sin_family = AF_INET;
00295    sin.sin_addr.s_addr = 0;
00296    sin.sin_port = htons(g_usPort);
00297    nRes = bind (sockListen, (LPSOCKADDR) &sin, sizeof (sin));
00298    if (SOCKET_ERROR == nRes)  {
00299       fprintf (stderr, "bind failed: %u\n", GetLastError ());
00300       return(FALSE);
00301    }
00302
00303    // listen for client
00304    //
00305    nRes = listen (sockListen, 1);
00306    if (SOCKET_ERROR == nRes)  {
00307       fprintf (stderr, "listen failed: %u\n", GetLastError ());
00308       return(FALSE);
00309    }
00310
00311    // accept client
00312    //
00313    sockClient = accept (sockListen, NULL, NULL);
00314    if (INVALID_SOCKET == sockClient)  {
00315       fprintf (stderr, "accept failed: %u\n", GetLastError ());
00316       return(FALSE);
00317    }
00318
00319    closesocket (sockListen);
00320
00321    // return socket even if we fail next steps
00322    //
00323    *s = sockClient;
00324
00325    if (!InitSession (sockClient))
00326       return(FALSE);
00327
00328    if (!DoAuthentication (sockClient))
00329       return(FALSE);
00330
00331    return(TRUE);
00332 }
00333
00334 BOOL CloseAuthSocket (SOCKET *s)
00335 /*++
00336
00337  Routine Description:
00338
00339     Closes a socket and releases security resources associated with
00340    the socket
00341
00342  Return Value:
00343
00344     Returns TRUE is successful; otherwise FALSE is returned.
00345
00346 --*/
00347 {
00348    TermSession (*s);
00349    shutdown (*s, 2);
00350    closesocket (*s);
00351    *s = 0;
00352    return(TRUE);
00353 }
00354
00355 BOOL DoAuthentication (SOCKET s)
00356 /*++
00357
00358  Routine Description:
00359
00360     Manages the authentication conversation with the client via the
00361     supplied socket handle.
00362
00363  Return Value:
00364
00365     Returns TRUE is successful; otherwise FALSE is returned.
00366
00367 --*/
00368 {
00369    DWORD cbIn, cbOut;
00370    BOOL done = FALSE;
00371    ULONG attrib = 0;
00372    PBYTE pOutBuf = NULL;
00373
00374    if (g_fUseConfidentiality)
00375       attrib |= ASC_REQ_CONFIDENTIALITY;
00376
00377    if (g_fUseIntegrity)
00378       attrib |= ASC_REQ_INTEGRITY;
00379
00380    do {
00381       if (!ReceiveMsg (
00382          s,
00383          g_pInBuf,
00384          g_cbMaxMessage,
00385          &cbIn))
00386
00387          return(FALSE);
00388
00389       pOutBuf = NULL;
00390
00391       if (!GenServerContext (
00392          s,
00393          g_pInBuf,
00394          cbIn,
00395          &pOutBuf,
00396          &cbOut,
00397          &done,
00398          &attrib))
00399
00400          return(FALSE);
00401
00402       if (!SendMsg (s, pOutBuf, cbOut))
00403          return(FALSE);
00404
00405       // done with package allocated buffer - free it
00406       if(pOutBuf)
00407          FreeContextBuffer(pOutBuf);
00408
00409    }
00410    while(!done);
00411
00412    if(g_fVerbose)
00413       printf("Context Attributes = 0x%08x\n", attrib);
00414
00415    // check the context flags and see if we got what we want
00416    //
00417    if (g_fUseConfidentiality && !(attrib & ASC_RET_CONFIDENTIALITY))
00418    {
00419       fprintf (stderr, "** confidentiality flags not set on context\n");
00420
00421       // The application can decide to either terminate the conversation
00422       // or continue. We are going to let the client make these decisions
00423       // and continue.
00424       //
00425       g_fUseConfidentiality = FALSE;
00426    }
00427
00428    if (g_fUseIntegrity && !(attrib & ASC_RET_INTEGRITY))
00429    {
00430       fprintf (stderr, " ** integrity flags not set on context\n");
00431
00432       // The application can decide to either terminate the conversation
00433       // or continue. We are going to let the client make these decisions
00434       // and continue.
00435       //
00436       g_fUseIntegrity = FALSE;
00437    }
00438
00439    // or the client could have requested the context flags and the package obliged
00440    //
00441    g_fUseConfidentiality = (attrib & ASC_RET_CONFIDENTIALITY);
00442
00443    g_fUseIntegrity = (attrib & ASC_RET_INTEGRITY);
00444
00445
00446    return(TRUE);
00447 }
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/cunknown.h Source File

  • Com
  • async
  • server

cunknown.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #if !defined(__CUnknown_h__)
00018 #define __CUnknown_h__
00019
00020 #include <objidl.h>
00021
00022
00023 ///////////////////////////////////////////////////////////
00024 //
00025 // Macro's for setting DCOM security structures
00026 //
00027 //
00028
00029 #define SETAUTHINFO(ai, athnsvc, athzsvc, name, athnl, impl, ident, cap) \
00030   { \
00031   (ai).dwAuthnSvc=athnsvc; \
00032   (ai).dwAuthzSvc=athzsvc; \
00033   (ai).pwszServerPrincName=name; \
00034   (ai).dwAuthnLevel=athnl; \
00035   (ai).dwImpersonationLevel=impl; \
00036   (ai).pAuthIdentityData=ident; \
00037   (ai).dwCapabilities=cap; \
00038   }
00039
00040 #define SETDEFAUTHINFO(ai, athnl, impl) \
00041   SETAUTHINFO(ai, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, athnl, impl, NULL, RPC_C_QOS_CAPABILITIES_DEFAULT)
00042
00043
00044 #define SETDEFSERVERINFO(psi, name) \
00045   { \
00046   (psi)->dwReserved1=0; \
00047   (psi)->pwszName=name; \
00048   (psi)->pAuthInfo=reinterpret_cast<COAUTHINFO*>((psi)+1); \
00049   SETDEFAUTHINFO(*(psi)->pAuthInfo,RPC_C_AUTHN_LEVEL_CONNECT,RPC_C_IMP_LEVEL_IMPERSONATE); \
00050   (psi)->dwReserved2=0; \
00051   }
00052
00053 #define SETAUTHIDENTITY(aid, usr, pw, d) \
00054   { \
00055   (aid).User=usr; \
00056   (aid).UserLength=lstrlenW(usr); \
00057   (aid).Domain=d; \
00058   (aid).DomainLength=d==NULL?0:lstrlenW(d); \
00059   (aid).Password=pw; \
00060   (aid).PasswordLength=pw==NULL?0:lstrlenW(pw); \
00061   (aid).Flags=SEC_WINNT_AUTH_IDENTITY_UNICODE; \
00062   }
00063
00064
00065
00066
00067
00068 ///////////////////////////////////////////////////////////
00069 //
00070 // Nondelegating IUnknown interface
00071 //   - Nondelegating version of IUnknown
00072 //
00073 interface INondelegatingUnknown
00074 {
00075   virtual HRESULT __stdcall
00076     NondelegatingQueryInterface(const IID& iid, void** ppv) = 0;
00077   virtual ULONG   __stdcall NondelegatingAddRef() = 0;
00078   virtual ULONG   __stdcall NondelegatingRelease() = 0;
00079 };
00080
00081
00082 ///////////////////////////////////////////////////////////
00083 //
00084 // Declaration of CUnknown
00085 //   - Base class for implementing IUnknown
00086 //
00087
00088 struct CFactoryData;
00089
00090 class CUnknown : public INondelegatingUnknown
00091 {
00092
00093 friend class CFactory;
00094
00095 protected:
00096   // Nondelegating IUnknown implementation
00097   virtual HRESULT __stdcall NondelegatingQueryInterface(const IID&,
00098                                                         void**);
00099   virtual ULONG   __stdcall NondelegatingAddRef();
00100   virtual ULONG   __stdcall NondelegatingRelease();
00101
00102   // Constructor
00103   CUnknown(IUnknown* pUnknownOuter, LPCSTR className = "CUnknown");
00104
00105   // Destructor
00106   virtual ~CUnknown();
00107
00108   // Initialization (especially for aggregates)
00109   virtual HRESULT __stdcall Init(const CFactoryData *pData) = 0;
00110   virtual HRESULT Init() {return S_OK;}
00111
00112   // Notification to derived classes that we are releasing
00113   virtual void __stdcall FinalRelease();
00114
00115   // Count of currently active components
00116   static DWORD ActiveComponents()
00117     { return s_cActiveComponents ;}
00118
00119   // Helper function
00120   HRESULT _stdcall FinishQI(IUnknown* pI, REFIID iid, void** ppv);
00121
00122 public:
00123   LPUNKNOWN GetOuterUnknown() const
00124     { return m_pUnknownOuter;}
00125
00126 protected:
00127   virtual HRESULT __stdcall Quit();
00128
00129 private:
00130   // Reference count for this object
00131   long m_cRef;
00132
00133   // Pointer to (external) outer IUnknown
00134   IUnknown* m_pUnknownOuter;
00135
00136   // Count of all active instances
00137   static long s_cActiveComponents;
00138
00139   LPCSTR m_lpstrClass;
00140 };
00141
00142
00143 ///////////////////////////////////////////////////////////
00144 //
00145 // Delegating IUnknown
00146 //   - Delegates to the nondelegating IUnknown, or to the
00147 //     outer IUnknown if the component is aggregated.
00148 //
00149 #define DECLARE_IUNKNOWN                                 \
00150   virtual HRESULT __stdcall                              \
00151     QueryInterface(const IID& iid, void** ppv)           \
00152   {                                                      \
00153     return GetOuterUnknown()->QueryInterface(iid,ppv) ;  \
00154   } ;                                                      \
00155   virtual ULONG __stdcall AddRef()                       \
00156   {                                                      \
00157     return GetOuterUnknown()->AddRef() ;                 \
00158   } ;                                                      \
00159   virtual ULONG __stdcall Release()                      \
00160   {                                                      \
00161     return GetOuterUnknown()->Release() ;                \
00162   } ;
00163 #endif
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminCatalogCollection.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminCatalogCollection.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.class(classid=F618C516-DFB8-11D1-A2CF-00805FC79235,DynamicCasts)
00019     @com.interface(iid=6EB22872-8A19-11D0-81B6-00A0C9231C29, thread=AUTO, type=DUAL) */
00020 public class COMAdminCatalogCollection implements IUnknown,com.ms.com.NoAutoScripting,comadmin.ICatalogCollection
00021 {
00022   /** @com.method(vtoffset=4, dispid=4294967292, type=PROPGET, name="_NewEnum", addFlagsVtable=4)
00023       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00024   public native IUnknown get_NewEnum();
00025
00026   /** @com.method(vtoffset=5, dispid=1, type=PROPGET, name="Item", addFlagsVtable=4)
00027       @com.parameters([in,type=I4] lIndex, [iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] return) */
00028   public native Object getItem(int lIndex);
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=PROPGET, name="Count", addFlagsVtable=4)
00031       @com.parameters([type=I4] return) */
00032   public native int getCount();
00033
00034   /** @com.method(vtoffset=7, dispid=1610743811, type=METHOD, name="Remove", addFlagsVtable=4)
00035       @com.parameters([in,type=I4] lIndex) */
00036   public native void Remove(int lIndex);
00037
00038   /** @com.method(vtoffset=8, dispid=1610743812, type=METHOD, name="Add", addFlagsVtable=4)
00039       @com.parameters([iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] return) */
00040   public native Object Add();
00041
00042   /** @com.method(vtoffset=9, dispid=2, type=METHOD, name="Populate", addFlagsVtable=4)
00043       @com.parameters() */
00044   public native void Populate();
00045
00046   /** @com.method(vtoffset=10, dispid=3, type=METHOD, name="SaveChanges", addFlagsVtable=4)
00047       @com.parameters([type=I4] return) */
00048   public native int SaveChanges();
00049
00050   /** @com.method(vtoffset=11, dispid=4, type=METHOD, name="GetCollection", addFlagsVtable=4)
00051       @com.parameters([in,type=STRING] bstrCollName, [in,type=VARIANT] varObjectKey, [iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] return) */
00052   public native Object GetCollection(String bstrCollName, Variant varObjectKey);
00053
00054   /** @com.method(vtoffset=12, dispid=6, type=PROPGET, name="Name", addFlagsVtable=4)
00055       @com.parameters([type=VARIANT] return) */
00056   public native Variant getName();
00057
00058   /** @com.method(vtoffset=13, dispid=7, type=PROPGET, name="AddEnabled", addFlagsVtable=4)
00059       @com.parameters([type=BOOLEAN] return) */
00060   public native boolean getAddEnabled();
00061
00062   /** @com.method(vtoffset=14, dispid=8, type=PROPGET, name="RemoveEnabled", addFlagsVtable=4)
00063       @com.parameters([type=BOOLEAN] return) */
00064   public native boolean getRemoveEnabled();
00065
00066   /** @com.method(vtoffset=15, dispid=9, type=METHOD, name="GetUtilInterface", addFlagsVtable=4)
00067       @com.parameters([iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] return) */
00068   public native Object GetUtilInterface();
00069
00070   /** @com.method(vtoffset=16, dispid=10, type=PROPGET, name="DataStoreMajorVersion", addFlagsVtable=4)
00071       @com.parameters([type=I4] return) */
00072   public native int getDataStoreMajorVersion();
00073
00074   /** @com.method(vtoffset=17, dispid=11, type=PROPGET, name="DataStoreMinorVersion", addFlagsVtable=4)
00075       @com.parameters([type=I4] return) */
00076   public native int getDataStoreMinorVersion();
00077
00078   /** @com.method(vtoffset=18, dispid=12, type=METHOD, name="PopulateByKey", addFlagsVtable=4)
00079       @com.parameters([in,vt=12,type=SAFEARRAY] aKeys) */
00080   public native void PopulateByKey(com.ms.com.SafeArray aKeys);
00081
00082   /** @com.method(vtoffset=19, dispid=13, type=METHOD, name="PopulateByQuery", addFlagsVtable=4)
00083       @com.parameters([in,type=STRING] bstrQueryString, [in,type=I4] lQueryType) */
00084   public native void PopulateByQuery(String bstrQueryString, int lQueryType);
00085
00086
00087   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x6eb22872, (short)0x8a19, (short)0x11d0, (byte)0x81, (byte)0xb6, (byte)0x0, (byte)0xa0, (byte)0xc9, (byte)0x23, (byte)0x1c, (byte)0x29);
00088
00089   public static final com.ms.com._Guid clsid = new com.ms.com._Guid((int)0xf618c516, (short)0xdfb8, (short)0x11d1, (byte)0xa2, (byte)0xcf, (byte)0x0, (byte)0x80, (byte)0x5f, (byte)0xc7, (byte)0x92, (byte)0x35);
00090 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Menu/Menu.c Source File

  • WinUI
  • Menu

Menu.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corp.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /***************************************************************************
00013  *                                                                         *
00014  *  PROGRAM     : Menu.c                                                   *
00015  *                                                                         *
00016  *  PURPOSE     : To give a demonstration of the use of popup menus, user  *
00017  *                defined menus and menu functions.                        *
00018  *                                                                         *
00019  *  FUNCTIONS   : WinMain()           - Calls the initialization function  *
00020  *                                      and enters the message loop.       *
00021  *                                                                         *
00022  *                MenuInit()          - Registers the app. window class.   *
00023  *                                                                         *
00024  *                AboutDialogProc ()  - Dialog function for the About..    *
00025  *                                      dialog.                            *
00026  *                                                                         *
00027  *                ShrinkBitmap()      - Shrinks a 64x64 bitmap to a size   *
00028  *                                      useable for a user-defined menu    *
00029  *                                      checkmark.                         *
00030  *                                                                         *
00031  *                HandleCreate()      - Creates a new menu and appends it  *
00032  *                                      to the main menu                   *
00033  *                                                                         *
00034  *                HandlePaint()       - Handles repainting the app's client*
00035  *                                      area                               *
00036  *                                                                         *
00037  *                HandleChangeColors()- Changes the state of the "colors"  *
00038  *                                      menu item.                         *
00039  *                                                                         *
00040  *                HandleDrawItem()    - Redraws the menu items in the      *
00041  *                                      "colors" menu                      *
00042  *                                                                         *
00043  *                HandlePopupMenu()   - handles display of the "floating"  *
00044  *                                      popup.                             *
00045  *                                                                         *
00046  *                MenuWindowProc()    - Window function for the app.       *
00047  *                                                                         *
00048  *                                                                         *
00049  ***************************************************************************/
00050 #include <windows.h>
00051 #include <tchar.h>
00052 #include "menu.h"
00053
00054
00055 HINSTANCE hInst;
00056 HMENU     hBigMenu;
00057 HBITMAP   hbmCheckOn;
00058 HBITMAP   hbmCheckOff;
00059
00060 /****************************************************************************
00061  *                                                                          *
00062  *  FUNCTION   : WinMain (HINSTANCE, HINSTANCE, LPSTR, int)                 *
00063  *                                                                          *
00064  *  PURPOSE    : Creates the main app. window, calls an initialization      *
00065  *               function and enters the message loop.                      *
00066  *                                                                          *
00067  ****************************************************************************/
00068 int WINAPI WinMain(
00069     HINSTANCE hInstance,
00070     HINSTANCE hPrevInstance,
00071     LPSTR     lpCmdLine,
00072     int       nCmdShow )
00073 {
00074     HWND hWnd = NULL;
00075     MSG  msg = {0};   /* message */
00076     BOOL bRet = FALSE;
00077     BOOL bSuccess = TRUE;
00078
00079     if (!MenuInit (hInstance))
00080     {
00081         bSuccess = FALSE;
00082         goto exit_func;
00083     }
00084
00085     hInst = hInstance;
00086
00087     /* Create the app. window */
00088     hWnd = CreateWindow (TEXT("menu"),
00089                          TEXT("Menu Example"),
00090                          WS_OVERLAPPEDWINDOW,
00091                          CW_USEDEFAULT, 0,
00092                          CW_USEDEFAULT, 0,
00093                          NULL, NULL, hInstance, NULL);
00094
00095     if (!hWnd)
00096     {
00097         bSuccess = FALSE;
00098         goto exit_func;
00099     }
00100
00101     ShowWindow (hWnd, nCmdShow);
00102     UpdateWindow (hWnd);
00103
00104     while (bRet = GetMessage (&msg, NULL, 0, 0) != 0)
00105     {
00106         if (bRet == -1)
00107         {
00108             bSuccess = FALSE;
00109             goto exit_func;
00110         }
00111         else
00112         {
00113             TranslateMessage (&msg);
00114             DispatchMessage (&msg);
00115         }
00116     }
00117
00118 exit_func:
00119     if (bSuccess)
00120     {
00121         return (int) msg.wParam;
00122     }
00123     else
00124     {
00125         return 0;
00126     }
00127 }
00128
00129
00130 /****************************************************************************
00131  *                                                                          *
00132  *  FUNCTION   : MenuInit (hInstance)                                       *
00133  *                                                                          *
00134  *  PURPOSE    : Registers the main window class.                           *
00135  *                                                                          *
00136  *  RETURNS    : TRUE   -  if RegisterClass() went off ok                   *
00137  *               FALSE  -  otherwise.                                       *
00138  *                                                                          *
00139  ****************************************************************************/
00140 BOOL MenuInit (
00141     HINSTANCE hInstance )
00142 {
00143     WNDCLASS wc = {0};
00144
00145     wc.lpfnWndProc   = (WNDPROC) MenuWindowProc;
00146     wc.hInstance     = hInstance;
00147     wc.hIcon         = LoadIcon (hInstance, TEXT("menu"));
00148     wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
00149     wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
00150     wc.lpszMenuName  = TEXT("MenuMenu");
00151     wc.lpszClassName = TEXT("menu");
00152
00153     return RegisterClass (&wc);
00154 }
00155
00156
00157 /****************************************************************************
00158  *                                                                          *
00159  *  FUNCTION   : AboutDialogProc (hDlg, message, wParam, lParam)            *
00160  *                                                                          *
00161  *  PURPOSE    : Dialog function for the About menu... dialog.              *
00162  *                                                                          *
00163  ****************************************************************************/
00164 INT_PTR CALLBACK AboutDialogProc (
00165     HWND   hDlg,
00166     UINT   msg,
00167     WPARAM wParam,
00168     LPARAM lParam )
00169 {
00170     BOOL ret = FALSE;
00171
00172     switch (msg)
00173     {
00174         case WM_INITDIALOG:
00175             ret = TRUE;
00176             break;
00177
00178         case WM_COMMAND:
00179             // LOWORD added for portability
00180             if (LOWORD(wParam) == IDOK)
00181             {
00182                 EndDialog (hDlg, 0);
00183                 ret = TRUE;
00184             }
00185             else
00186             {
00187                 ret = FALSE;
00188             }
00189             break;
00190
00191         case WM_SYSCOMMAND:
00192             if (wParam == SC_CLOSE)
00193             {
00194                 EndDialog (hDlg, 0);
00195                 ret = TRUE;
00196             }
00197             else
00198             {
00199                 ret = FALSE;
00200             }
00201             break;
00202
00203
00204         default:
00205             ret = FALSE;
00206             break;
00207     }
00208
00209     return (INT_PTR) ret;
00210 }
00211
00212
00213 /****************************************************************************
00214  *                                                                          *
00215  *  FUNCTION   : ShrinkBitmap(hwnd, hbm)                                    *
00216  *                                                                          *
00217  *  PURPOSE    : This function shrinks a 64x64 bitmap into a bitmap useable *
00218  *               for the user-defined checkmark for menu items. This can be *
00219  *               easily generalized to shrink bitmaps of any size.          *
00220  *                                                                          *
00221  *  RETURNS    : HBITMAP - A handle to the new bitmap.                      *
00222  *                                                                          *
00223  ****************************************************************************/
00224 HBITMAP ShrinkBitmap (
00225     HWND    hwnd,
00226     HBITMAP hbm )
00227 {
00228     HDC     hdc            = NULL;
00229     HDC     hmemorydcNew   = NULL;
00230     HDC     hmemorydcOld   = NULL;
00231     LONG    checkMarkSize  = 0;
00232     HBITMAP hCheckBitmap   = NULL;
00233     HBITMAP hOldBitmapSave = NULL;
00234     HBITMAP hNewBitmapSave = NULL;
00235
00236     hdc = GetDC (hwnd);
00237
00238     /* Create DCs for the source (old) and target (new) bitmaps */
00239     hmemorydcNew = CreateCompatibleDC (hdc);
00240     hmemorydcOld = CreateCompatibleDC (hdc);
00241
00242     /* Determine the dimensions of the default menu checkmark and
00243      * create a target bitmap of the same dimensions
00244      */
00245     checkMarkSize = GetMenuCheckMarkDimensions ();
00246     hCheckBitmap  = CreateCompatibleBitmap (hdc,
00247                                             LOWORD (checkMarkSize),
00248                                             HIWORD (checkMarkSize));
00249
00250     /* Select the source bitmap and the target bitmap into their
00251      * respective DCs.
00252      */
00253     hOldBitmapSave = SelectObject (hmemorydcNew, hCheckBitmap);
00254     hNewBitmapSave = SelectObject (hmemorydcOld, hbm);
00255
00256     /* Shrink the source bitmap into the target DC */
00257     StretchBlt (hmemorydcNew,
00258                 0, 0,
00259                 LOWORD(checkMarkSize),
00260                 HIWORD(checkMarkSize),
00261                 hmemorydcOld,
00262                 0, 0,
00263                 64, 64,
00264                 SRCCOPY);
00265
00266     /* De-select the bitmaps and clean up .. */
00267     SelectObject (hmemorydcNew, hOldBitmapSave);
00268     SelectObject (hmemorydcOld, hNewBitmapSave);
00269     DeleteDC (hmemorydcNew);
00270     DeleteDC (hmemorydcOld);
00271     ReleaseDC (hwnd, hdc);
00272
00273     /* .. and return a handle to the target bitmap */
00274     return hCheckBitmap;
00275 }
00276
00277
00278 /****************************************************************************
00279  *                                                                          *
00280  *  FUNCTION   : HandleCreate ( hwnd )                                      *
00281  *                                                                          *
00282  *  PURPOSE    : Creates a new (empty) menu and appends to it the "State"   *
00283  *               menu items. It sets up the user-defined checkmarks for the *
00284  *               menu. It then inserts this menu into the main menu bar.    *
00285  *                                                                          *
00286  ****************************************************************************/
00287 VOID HandleCreate (
00288     HWND hwnd)
00289 {
00290     HMENU   hMenu    = NULL;
00291     HMENU   hWndMenu = NULL;
00292
00293     /* Create a new menu into the menubar on the fly */
00294     hMenu = CreateMenu ();
00295     if (!hMenu)
00296     {
00297         return;
00298     }
00299
00300     /* Append the state menu items to it */
00301     AppendMenu (hMenu, MF_STRING, IDM_STATE1, TEXT("South Dakota"));
00302     AppendMenu (hMenu, MF_STRING, IDM_STATE2, TEXT("Washington"));
00303     AppendMenu (hMenu, MF_STRING, IDM_STATE3, TEXT("California"));
00304     if (!AppendMenu (hMenu, MF_STRING, IDM_STATE4, TEXT("Oregon")))
00305     {
00306         /* It is unlikely the other appends will fail and this will succeed.
00307          * So just check this one. And if it fails, Destroy the menu for
00308          * good measure and return.
00309          */
00310         DestroyMenu(hMenu);
00311         return;
00312     }
00313     hbmCheckOn  = ShrinkBitmap (hwnd, LoadBitmap (hInst, TEXT("checkon")));
00314     hbmCheckOff = ShrinkBitmap (hwnd, LoadBitmap (hInst, TEXT("checkoff")));
00315
00316     /* Set up the user-defined check marks */
00317     SetMenuItemBitmaps (hMenu, 0, MF_BYPOSITION, hbmCheckOff, hbmCheckOn);
00318     SetMenuItemBitmaps (hMenu, 1, MF_BYPOSITION, hbmCheckOff, hbmCheckOn);
00319     SetMenuItemBitmaps (hMenu, 2, MF_BYPOSITION, hbmCheckOff, hbmCheckOn);
00320     SetMenuItemBitmaps (hMenu, 3, MF_BYPOSITION, hbmCheckOff, hbmCheckOn);
00321
00322     /* Now insert the menu into the main menu bar. */
00323     hWndMenu = GetMenu (hwnd);
00324     InsertMenu (hWndMenu, 2, MF_POPUP|MF_BYPOSITION, (DWORD_PTR)hMenu, TEXT("States"));
00325
00326     return;
00327 }
00328
00329 /****************************************************************************
00330  *                                                                          *
00331  *  FUNCTION   : HandlePaint ( hwnd )                                       *
00332  *                                                                          *
00333  *  PURPOSE    : Handles the repainting of the main app's client area.      *
00334  *                                                                          *
00335  ****************************************************************************/
00336 VOID HandlePaint (
00337     HWND hwnd )
00338 {
00339     HDC         hdc = NULL;
00340     PAINTSTRUCT ps  = {0};
00341     RECT        rc  = {0};
00342     TCHAR       text[] = TEXT("Click in the window for a popup menu");
00343
00344     hdc = BeginPaint (hwnd, (LPPAINTSTRUCT)&ps);
00345
00346     /* Center the text in the client area */
00347     GetClientRect (hwnd, &rc);
00348     DrawText (hdc,
00349               text,
00350               (INT)_tcslen (text),
00351               &rc,
00352               DT_CENTER | DT_WORDBREAK);
00353     EndPaint(hwnd, (LPPAINTSTRUCT)&ps);
00354 }
00355
00356
00357 /****************************************************************************
00358  *                                                                          *
00359  *  FUNCTION   : HandleChangeColors (hwnd)                                  *
00360  *                                                                          *
00361  *  PURPOSE    : Toggles the state of the Owner Draw item in the Colors     *
00362  *               menu. If it is on, the "Black", "Blue", "Red", and "Green" *
00363  *               individual menu text items are modified so that they will  *
00364  *               contain bands of color. Otherwise, the colors are replaced *
00365  *               by the text.                                               *
00366  *                                                                          *
00367  ****************************************************************************/
00368 VOID HandleChangeColors (
00369     HWND hwnd )
00370 {
00371     HMENU hMenu      = NULL;
00372     BOOL  fOwnerDraw = FALSE;
00373
00374     /* Get a handle to the Colors menu. This is at position 1. */
00375     hMenu = GetSubMenu (GetMenu (hwnd), IDCOLORS_POS);
00376
00377     /* Get the current state of the item */
00378     fOwnerDraw = GetMenuState ( hMenu,
00379                                 IDM_COLOROWNERDR, MF_BYCOMMAND) & MF_CHECKED;
00380
00381     /* Toggle the state of the item. */
00382     CheckMenuItem ( hMenu,
00383                     IDM_COLOROWNERDR,
00384                     MF_BYCOMMAND | (fOwnerDraw ? MF_UNCHECKED : MF_CHECKED));
00385
00386     if (!fOwnerDraw)
00387     {
00388         /* Change the items to owner-draw items. Pass the RGB value for the
00389          * color as the application-supplied data. This makes it easier for
00390          * us to draw the items.
00391          */
00392         ModifyMenu(hMenu,
00393                    IDM_BLACK,
00394                    MF_OWNERDRAW | MF_BYCOMMAND,
00395                    IDM_BLACK,
00396                    (LPCTSTR)(INT_PTR)RGB (0,0,0));
00397
00398         ModifyMenu(hMenu,
00399                    IDM_BLUE,
00400                    MF_OWNERDRAW | MF_BYCOMMAND,
00401                    IDM_BLUE,
00402                    (LPCTSTR)(INT_PTR)RGB (0,0,255));
00403
00404         ModifyMenu(hMenu,
00405                    IDM_RED,
00406                    MF_OWNERDRAW | MF_BYCOMMAND,
00407                    IDM_RED,
00408                    (LPCTSTR)(INT_PTR)RGB (255,0,0));
00409
00410         ModifyMenu(hMenu,
00411                    IDM_GREEN,
00412                    MF_OWNERDRAW | MF_BYCOMMAND,
00413                    IDM_GREEN,
00414                    (LPCTSTR)(INT_PTR)RGB (0,255,0));
00415     }
00416     else
00417     {
00418         /* Change the items to normal text items. */
00419         ModifyMenu(hMenu, IDM_BLACK, MF_BYCOMMAND, IDM_BLACK, TEXT("Black"));
00420         ModifyMenu(hMenu, IDM_BLUE,  MF_BYCOMMAND, IDM_BLUE,  TEXT("Blue"));
00421         ModifyMenu(hMenu, IDM_RED,   MF_BYCOMMAND, IDM_RED,   TEXT("Red"));
00422         ModifyMenu(hMenu, IDM_GREEN, MF_BYCOMMAND, IDM_GREEN, TEXT("Green"));
00423     }
00424 }
00425
00426
00427 /****************************************************************************
00428  *                                                                          *
00429  *  FUNCTION   : HandleDrawItem ( hwnd, lpdis)                              *
00430  *                                                                          *
00431  *  PURPOSE    : Called in response to a WM_DRAWITEM message, i.e. when the *
00432  *               colors menu is being modified to an owner-draw menu, or    *
00433  *               one of the items is selected. It sizes the checkmark bitmap*
00434  *               to fit next to a color band and draws the color bands and  *
00435  *               the checkmark on the popup menu.                           *
00436  *                                                                          *
00437  ****************************************************************************/
00438 VOID HandleDrawItem (
00439         HWND             hwnd,
00440         LPDRAWITEMSTRUCT lpdis )
00441
00442 {
00443     HDC     hdcBitmap      = NULL;
00444     HBITMAP hbmSave        = NULL;
00445     HBRUSH  hbr            = NULL;
00446     RECT    rc             = {0};
00447     LONG    checkMarkSize  = 0;
00448     DWORD   textColorSave  = 0;
00449     DWORD   bkColorSave    = 0;
00450
00451     /* Get the size of the checkmark so we can leave room for it since we
00452      * want to be able to check the selected color.
00453      */
00454     checkMarkSize = GetMenuCheckMarkDimensions ();
00455
00456     if (lpdis->itemAction == ODA_SELECT ||
00457         lpdis->itemAction == ODA_DRAWENTIRE)
00458     {
00459         CopyRect ((LPRECT)&rc, (LPRECT)&lpdis->rcItem);
00460         InflateRect ((LPRECT)&rc, (-2 - LOWORD(checkMarkSize)), -2);
00461
00462         if (lpdis->itemState & ODS_SELECTED)
00463         {
00464             /* Item has been selected -- hilite with a gray frame */
00465             hbr = GetStockObject (GRAY_BRUSH);
00466             FrameRect (lpdis->hDC, (LPRECT)&rc, hbr);
00467         }
00468         else if (lpdis->itemAction == ODA_SELECT)
00469         {
00470             /* Item has been de-selected -- remove gray frame */
00471             hbr = CreateSolidBrush (GetSysColor (COLOR_MENU));
00472             FrameRect (lpdis->hDC, (LPRECT)&rc, hbr);
00473             DeleteObject (hbr);
00474         }
00475     }
00476
00477     if (lpdis->itemAction == ODA_DRAWENTIRE)
00478     {
00479         /* Paint the color item in the color requested. */
00480         hbr = CreateSolidBrush ((COLORREF) lpdis->itemData);
00481         CopyRect ((LPRECT)&rc, (LPRECT)&lpdis->rcItem);
00482         InflateRect ((LPRECT)&rc, -10-LOWORD(checkMarkSize), -10);
00483         FillRect (lpdis->hDC, (LPRECT)&rc, hbr);
00484         DeleteObject (hbr);
00485
00486         if (lpdis->itemState & ODS_CHECKED)
00487         {
00488             /* Draw the check mark if the item is checked. */
00489             hdcBitmap = CreateCompatibleDC (lpdis->hDC);
00490             hbmSave = SelectObject (hdcBitmap, hbmCheckOn);
00491
00492             textColorSave = SetTextColor (lpdis->hDC, 0x00000000L);
00493             bkColorSave   = SetBkColor (lpdis->hDC, 0x00FFFFFFL);
00494
00495             /* Use Magic bitblt op so that monochrome bitmaps preserve
00496                background and foreground colors. */
00497             BitBlt (lpdis->hDC,
00498                     lpdis->rcItem.left,
00499                     lpdis->rcItem.top+
00500                            (MEASUREITEMHEIGHT - HIWORD (checkMarkSize)) / 2,
00501                     LOWORD (checkMarkSize),
00502                     HIWORD (checkMarkSize),
00503                     hdcBitmap,
00504                     0,
00505                     0,
00506                     ROP_PSDPxax);
00507
00508             /* Restore colors and bitmap and clean up */
00509             SetTextColor (lpdis->hDC, textColorSave);
00510             SetBkColor (lpdis->hDC, bkColorSave);
00511             SelectObject (hdcBitmap, hbmSave);
00512             DeleteDC (hdcBitmap);
00513         }
00514     }
00515 }
00516
00517 /****************************************************************************
00518  *                                                                          *
00519  *  FUNCTION   : HandlePopupMenu (hwnd, point)                              *
00520  *                                                                          *
00521  *  PURPOSE    : Handles the display of the "floating" popup that appears   *                                                           *
00522  *               on a mouse click in the app's client area.                 *
00523  *                                                                          *
00524  ****************************************************************************/
00525 VOID HandlePopupMenu (
00526         HWND   hwnd,
00527         POINT point )
00528
00529 {
00530     HMENU hMenu           = NULL;
00531     HMENU hMenuTrackPopup = NULL;
00532
00533     /* Get the menu for the popup from the resource file. */
00534     hMenu = LoadMenu (hInst, TEXT("PopupMenu"));
00535     if (!hMenu)
00536     {
00537         return;
00538     }
00539
00540     /* Get the first menu in it which we will use for the call to
00541      * TrackPopup(). This could also have been created on the fly using
00542      * CreatePopupMenu and then we could have used InsertMenu() or
00543      * AppendMenu.
00544      */
00545     hMenuTrackPopup = GetSubMenu (hMenu, 0);
00546
00547     /* Convert the mouse point to screen coordinates since that is what
00548      * TrackPopup expects.
00549      */
00550     ClientToScreen (hwnd, (LPPOINT)&point);
00551
00552     /* Draw and track the "floating" popup */
00553     TrackPopupMenu (hMenuTrackPopup, 0, point.x, point.y, 0, hwnd, NULL);
00554
00555     /* Destroy the menu since were are done with it. */
00556     DestroyMenu (hMenu);
00557 }
00558
00559 /****************************************************************************
00560  *                                                                          *
00561  *  FUNCTION   : MenuWindowProc (hWnd, message, wParam, lParam)                *
00562  *                                                                          *
00563  *  PURPOSE    : Window function for the main app. window. Processes all the*
00564  *               menu selections and oter messages.                         *
00565  *                                                                          *
00566  ****************************************************************************/
00567 LRESULT CALLBACK MenuWindowProc (
00568         HWND hWnd,
00569         UINT message,
00570         WPARAM wParam,
00571         LPARAM lParam )
00572
00573 {
00574     HMENU hMenu   = NULL;
00575     RECT  rc      = {0};
00576     POINT pt      = {0};
00577     BOOL  bRetDWP = FALSE;
00578
00579
00580     switch (message)
00581     {
00582         case WM_SYSCOMMAND:
00583             /* Show the About ... dialog */
00584             if (wParam == ID_ABOUT)
00585             {
00586                 DialogBox (hInst,
00587                            TEXT("AboutBox"),
00588                            hWnd,
00589                            AboutDialogProc);
00590                 break;
00591             }
00592             else
00593             {
00594                 bRetDWP = TRUE;
00595                 goto exit_func;
00596             }
00597
00598         case WM_COMMAND:
00599             // LOWORD added for portability
00600             switch (LOWORD(wParam))
00601             {
00602                  case IDM_EXIT:
00603                    DestroyWindow (hWnd);
00604                    break;
00605
00606                  case IDM_ABOUT:
00607                    /* Bring up the About.. dialog box */
00608                    DialogBox (hInst,
00609                               TEXT("AboutBox"),
00610                               hWnd,
00611                               AboutDialogProc);
00612                    break;
00613
00614                  case IDM_COLOROWNERDR:
00615                      /* Change colors in color menu depending on state of this
00616                         menu item. */
00617                      HandleChangeColors (hWnd);
00618                      break;
00619
00620                  case IDM_STATE1: /* fall through */
00621                  case IDM_STATE2: /* fall through */
00622                  case IDM_STATE3: /* fall through */
00623                  case IDM_STATE4:
00624                       /* Get a handle to the states menu... */
00625                       hMenu = GetSubMenu (GetMenu (hWnd), IDSTATES_POS);
00626
00627                       /* Uncheck all the items. */
00628                       CheckMenuItem (hMenu, IDM_STATE1,
00629                                      MF_BYCOMMAND | MF_UNCHECKED);
00630                       CheckMenuItem (hMenu, IDM_STATE2,
00631                                      MF_BYCOMMAND | MF_UNCHECKED);
00632                       CheckMenuItem (hMenu, IDM_STATE3,
00633                                      MF_BYCOMMAND | MF_UNCHECKED);
00634                       CheckMenuItem (hMenu, IDM_STATE4,
00635                                      MF_BYCOMMAND | MF_UNCHECKED);
00636
00637                       /* ...and just check the selected one.*/
00638                       CheckMenuItem (hMenu, (WORD)wParam,
00639                                      MF_BYCOMMAND | MF_CHECKED);
00640                      break;
00641
00642                  case IDM_BLACK: /* fall through */
00643                  case IDM_RED:   /* fall through */
00644                  case IDM_BLUE:  /* fall through */
00645                  case IDM_GREEN:
00646                       /* Get a handle to the Colors menu. */
00647                       hMenu = GetSubMenu (GetMenu (hWnd),IDCOLORS_POS);
00648
00649                       /* Uncheck all the items. */
00650                       CheckMenuItem (hMenu, IDM_BLACK,
00651                                      MF_BYCOMMAND | MF_UNCHECKED);
00652                       CheckMenuItem (hMenu, IDM_RED,
00653                                      MF_BYCOMMAND | MF_UNCHECKED);
00654                       CheckMenuItem (hMenu, IDM_BLUE,
00655                                      MF_BYCOMMAND | MF_UNCHECKED);
00656                       CheckMenuItem (hMenu, IDM_GREEN,
00657                                      MF_BYCOMMAND | MF_UNCHECKED);
00658
00659                       /* ...and just check the selected one.*/
00660                       CheckMenuItem (hMenu, (WORD)wParam,
00661                                      MF_BYCOMMAND | MF_CHECKED);
00662                       break;
00663
00664                  case IDM_FONT:
00665                       /* Messages sent to us from TrackPopupMenu when
00666                        * items are selected from the "floating" popups
00667                        */
00668                       MessageBox (hWnd,
00669                                   TEXT("A font was selected"),
00670                                   TEXT("Popup Menu Alert"),
00671                                   MB_APPLMODAL|MB_OK);
00672                       break;
00673
00674                  case IDM_SIZE:
00675                       MessageBox (hWnd,
00676                                   TEXT("A size was selected"),
00677                                   TEXT("Popup Menu Alert"),
00678                                   MB_APPLMODAL|MB_OK);
00679                       break;
00680
00681                  case IDM_STYLE:
00682                       MessageBox (hWnd,
00683                                   TEXT("A style was selected"),
00684                                   TEXT("Popup Menu Alert"),
00685                                   MB_APPLMODAL|MB_OK);
00686                       break;
00687             }
00688             break;
00689
00690         case WM_SIZE:
00691             if (lParam)
00692             {
00693                 /* If window is being sized to a non zero value...
00694                  * invalidate it's client area.
00695                  */
00696                 InvalidateRect (hWnd, NULL, TRUE);
00697             }
00698             break;
00699
00700         case WM_PAINT:
00701             HandlePaint (hWnd);
00702             break;
00703
00704         case WM_MEASUREITEM:
00705             /* Use the same width for all items. We could examine the item id
00706                and use different widths/heights for each item. */
00707             ((LPMEASUREITEMSTRUCT)lParam)->itemWidth  = MEASUREITEMWIDTH;
00708             ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = MEASUREITEMHEIGHT;
00709             return TRUE;
00710             break;
00711
00712         case WM_DRAWITEM:
00713             /* Redraw the "colors" menu in normal/ownerdrawmode */
00714             HandleDrawItem (hWnd,(LPDRAWITEMSTRUCT)lParam);
00715             return TRUE;
00716             break;
00717
00718         case WM_CREATE:
00719             /* Create the menu */
00720             HandleCreate (hWnd);
00721             break;
00722
00723         case WM_DESTROY:
00724             /* Delete the on/off bitmaps so that they don't waste memory. */
00725             DeleteObject (hbmCheckOn);
00726             DeleteObject (hbmCheckOff);
00727
00728             PostQuitMessage (0);
00729             break;
00730
00731         case WM_LBUTTONDOWN:
00732             /* Draw the "floating" popup in the app's client area */
00733             GetClientRect (hWnd, (LPRECT)&rc);
00734
00735             // Temporary porting macro
00736             LONG2POINT(lParam, pt);
00737             if (PtInRect ((LPRECT)&rc, pt))
00738             {
00739                 HandlePopupMenu (hWnd, pt);
00740             }
00741             break;
00742
00743         default:
00744             bRetDWP = TRUE;
00745             goto exit_func;
00746             break;
00747     }
00748
00749 exit_func:
00750     if (bRetDWP)
00751     {
00752         return DefWindowProc (hWnd, message, wParam, lParam);
00753     }
00754     else
00755     {
00756         return 0;
00757     }
00758 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCommBand Member List

This is the complete list of members for CCommBand, including all inherited members.
CCommBand() | CCommBand |
CloseDW(DWORD dwReserved) | CCommBand |
ContextSensitiveHelp(BOOL) | CCommBand |
FocusChange(BOOL) | CCommBand | [private]
GetBandInfo(DWORD, DWORD, DESKBANDINFO *) | CCommBand |
GetClassID(LPCLSID) | CCommBand |
GetSite(REFIID, LPVOID *) | CCommBand |
GetSizeMax(ULARGE_INTEGER *) | CCommBand |
GetWindow(HWND *) | CCommBand |
HasFocusIO(void) | CCommBand |
IsDirty(void) | CCommBand |
Load(LPSTREAM) | CCommBand |
m_bFocus | CCommBand | [private]
m_dwBandID | CCommBand | [private]
m_dwViewMode | CCommBand | [private]
m_hWnd | CCommBand | [private]
m_hwndParent | CCommBand | [private]
m_ObjRefCount | CCommBand | [protected]
m_pSite | CCommBand | [private]
OnCommand(WPARAM wParam, LPARAM lParam) | CCommBand | [private]
OnKillFocus(void) | CCommBand | [private]
OnPaint(void) | CCommBand | [private]
OnSetFocus(void) | CCommBand | [private]
QueryInterface(REFIID, LPVOID *) | CCommBand |
RegisterAndCreateWindow(void) | CCommBand | [private]
ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) | CCommBand |
Save(LPSTREAM, BOOL) | CCommBand |
SetSite(IUnknown *) | CCommBand |
ShowDW(BOOL fShow) | CCommBand |
STDMETHODIMP_(DWORD) AddRef() | CCommBand |
STDMETHODIMP_(DWORD) Release() | CCommBand |
TranslateAcceleratorIO(LPMSG) | CCommBand |
UIActivateIO(BOOL, LPMSG) | CCommBand |
WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) | CCommBand | [private, static]
~CCommBand() | CCommBand |
Generated on Wed Nov 13 2024 16:55:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/osp/vj/myospobject.java Source File

  • Dataaccess
  • osp
  • vj

myospobject.java

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample OLEDB Simple Provider
00003 // (C) Copyright 1991-1999 Microsoft Corporation.  All Rights Reserved.
00004 //
00005 // module MyOSPObject.java | OLEDBSimpleProvider implementation
00006 //
00007 // Notes:
00008 //
00009 // 0.  For latest COM interfaces, install the Microsoft SDK for Java(tm)
00010 //     2.0.
00011 //
00012 // 1.  For Java the function definitions are different than for C++.
00013 //     Since there are no pointers, what would be the output argument
00014 //     is the return value.
00015
00016
00017 ////////////////////////////////////////////////////////
00018 // Imports
00019 //
00020 ////////////////////////////////////////////////////////
00021 import java.io.*;
00022 import java.util.*;
00023 import com.ms.com.*;
00024 import com.ms.osp.*;
00025
00026
00027 class MyOSPObject implements OLEDBSimpleProvider
00028 {
00029   // data
00030   int       m_cRows;
00031   int       m_cColumns;
00032   String      m_sFilePath;
00033   Vector      m_vListeners;
00034   String[][]    m_rsTable;
00035
00036   //constructors
00037   public MyOSPObject()
00038   {
00039     // The file name is not set until the DataSource object
00040     // does it:
00041     m_sFilePath   = null;
00042     m_cRows     = 0;
00043     m_cColumns    = 0;
00044     m_vListeners  = new Vector();
00045   }
00046
00047   // Ancillary methods for loading and saving simple data
00048
00049   public void setFile(String sFilePath)
00050   {
00051     m_sFilePath = sFilePath;
00052   }
00053
00054   public void loadData()
00055   {
00056     int       i = 0, j = 0, iStart, iEnd;
00057     BufferedReader  rdr;
00058     FileReader    frdr;
00059     Integer     iToken;
00060     String      s, t;
00061     StringTokenizer st;
00062
00063     // Build the internal array by reading the file:
00064     try
00065     {
00066       frdr = new FileReader(m_sFilePath);
00067       rdr = new BufferedReader(frdr);
00068
00069       // Line 1 contains cRows ; cColumns
00070       s = new String(rdr.readLine());
00071       st = new StringTokenizer(s, ";");
00072       iToken = new Integer(st.nextToken());
00073       m_cRows = iToken.intValue();
00074       iToken = new Integer(st.nextToken());
00075       m_cColumns = iToken.intValue();
00076
00077       // Create arrary of size cRows+1 X cColumns+1:
00078       m_rsTable = new String[m_cRows+1][m_cColumns+1];
00079
00080       // Read the rest of the file and stuff each line into the next row:
00081       for (i = 0; i <= m_cRows; i++)
00082       {
00083         m_rsTable[i][0] = new String("");
00084         s = new String(rdr.readLine());
00085         iStart = 0;
00086         iEnd = s.indexOf(';');
00087         j = 1;
00088         while (iEnd != -1 & j <= m_cColumns)
00089         {
00090           t = new String(s.substring(0, iEnd));
00091           s = new String(s.substring(iEnd+1));
00092           iEnd = s.indexOf(';');
00093           //System.out.println("[j = " + j + "]: " + t);
00094           m_rsTable[i][j] = t;
00095           j++;
00096         }
00097         if (s != "" & j <= m_cColumns)
00098         {
00099           m_rsTable[i][j] = s;
00100           j++;
00101         }
00102       }
00103       rdr.close();
00104       frdr.close();
00105     }
00106     catch(NullPointerException npe)
00107     {
00108     }
00109     catch(Exception e)
00110     {
00111       System.out.println(e.toString() + "\n");
00112       throw new ComFailException();
00113     }
00114     return;
00115   }
00116
00117   public void saveData()
00118   {
00119     int       i = 0, j = 0;
00120     BufferedWriter  bwtr = null;
00121     FileWriter    fwtr = null;
00122     PrintWriter   pwtr = null;
00123
00124     try
00125     {
00126       // Prepare the file for output:
00127       fwtr = new FileWriter(m_sFilePath);
00128       bwtr = new BufferedWriter(fwtr);
00129       pwtr = new PrintWriter(bwtr);
00130
00131       // Write out the first line
00132       pwtr.println(m_cRows + ";" + m_cColumns);
00133
00134       // Write the columns of each row on a line:
00135       for (i = 0; i <= m_cRows; i++)
00136       {
00137         for (j = 1; j <= m_cColumns; j++)
00138         {
00139           if (m_rsTable[i][j].equals(""))
00140             pwtr.print(';');
00141           else
00142               pwtr.print(m_rsTable[i][j] + ';');
00143         }
00144         pwtr.println();
00145       }
00146
00147       // Close the Writers:
00148       pwtr.close();
00149     }
00150     catch(Exception e)
00151     {
00152       pwtr.close();
00153       System.out.println("Error in saveData() when i = " + i + ", j = " + j);
00154       System.out.println(e.toString() + "\n");
00155       throw new ComFailException();
00156     }
00157   }
00158
00159   public boolean compareString(String s1, String s2, boolean fCaseSensitive, int findFlags)
00160   {
00161     if (fCaseSensitive)
00162     {
00163       switch (findFlags)
00164       {
00165       case OSPCOMP.OSPCOMP_EQ:
00166         return s1.equals(s2);
00167       case OSPCOMP.OSPCOMP_LT:
00168         return (s1.compareTo(s2) < 0) ? true : false;
00169       case OSPCOMP.OSPCOMP_LE:
00170         return (s1.compareTo(s2) <= 0) ? true : false;
00171       case OSPCOMP.OSPCOMP_GE:
00172         return (s1.compareTo(s2) >= 0) ? true : false;
00173       case OSPCOMP.OSPCOMP_GT:
00174         return (s1.compareTo(s2) > 0) ? true : false;
00175       };
00176     }
00177     else
00178     {
00179       if (findFlags == OSPCOMP.OSPCOMP_EQ)
00180         return s1.equalsIgnoreCase(s2);
00181       else
00182       {
00183         String ls1 = new String(s1.toLowerCase());
00184         String ls2 = new String(s2.toLowerCase());
00185         switch (findFlags)
00186         {
00187         case OSPCOMP.OSPCOMP_LT:
00188           return (ls1.compareTo(ls2) < 0) ? true : false;
00189         case OSPCOMP.OSPCOMP_LE:
00190           return (ls1.compareTo(ls2) <= 0) ? true : false;
00191         case OSPCOMP.OSPCOMP_GE:
00192           return (ls1.compareTo(ls2) >= 0) ? true : false;
00193         case OSPCOMP.OSPCOMP_GT:
00194           return (ls1.compareTo(ls2) > 0) ? true : false;
00195         };
00196       }
00197     }
00198     return false;
00199   }
00200
00201   // OLEDBSimpleProvider methods
00202
00203   public int deleteRows(int iRow, int cRows) throws ComException
00204   {
00205     if (iRow <= 0)
00206       throw new ComFailException();
00207
00208     if (cRows < 1)
00209       throw new ComFailException();
00210
00211     if (iRow > m_cRows)
00212       throw new ComFailException();
00213
00214     // Adjust row count to stay within range:
00215     if (iRow + cRows > m_cRows + 1)
00216       cRows = m_cRows - iRow + 1;
00217
00218     // Create new array with reduced rows; copy over remaining rows:
00219     int cNewRows = m_cRows - cRows;
00220     String[][] rsNewTable = new String[cNewRows+1][m_cColumns+1];
00221     int i, j, k = 0;
00222     for (i = 0; i <= m_cRows; i++)
00223     {
00224       if (i < iRow || i > (iRow + cRows - 1))
00225       {
00226         for (j = 1; j <= m_cColumns; j++)
00227           rsNewTable[k][j] = m_rsTable[i][j];
00228         k++;
00229       }
00230     }
00231
00232     //  Refer to new table and adjust row count:
00233     for (Enumeration e = m_vListeners.elements(); e.hasMoreElements(); )
00234       ((OLEDBSimpleProviderListener)e.nextElement()).aboutToDeleteRows(iRow, cRows);
00235     m_rsTable = rsNewTable;
00236     m_cRows = cNewRows;
00237     saveData();
00238     for (Enumeration e = m_vListeners.elements(); e.hasMoreElements(); )
00239       ((OLEDBSimpleProviderListener)e.nextElement()).deletedRows(iRow, cRows);
00240
00241     // Return the count of rows deleted:
00242     return cRows;
00243   }
00244
00245   public int getColumnCount() throws ComException
00246   {
00247     return m_cColumns;
00248   }
00249
00250   public String getLocale() throws ComException
00251   {
00252     Locale lc = Locale.US;
00253     return lc.getDisplayName(Locale.US);
00254   }
00255
00256   public int getRowCount() throws ComException
00257   {
00258     return m_cRows;
00259   }
00260
00261   public int getRWStatus(int iRow, int iColumn) throws ComException
00262   {
00263     if (iColumn == 1)
00264       return OSPRW.OSPRW_READONLY;
00265     else
00266       return OSPRW.OSPRW_READWRITE;
00267   }
00268
00269   public Object getVariant(int iRow, int iColumn, int format) throws ComException
00270   {
00271     if (iRow < 0 || iColumn < 0 || iRow > m_cRows || iColumn > m_cColumns)
00272       throw new ComFailException();
00273     // Allocate a new object because the caller will free it when it wants
00274     // to:
00275     String s = new String(m_rsTable[iRow][iColumn]);
00276     return s;
00277   }
00278
00279   public void setVariant(int iRow, int iColumn, int format, Object obj) throws ComException
00280   {
00281     if (iRow < 0 || iColumn < 0)
00282       throw new ComFailException();
00283     for (Enumeration e = m_vListeners.elements(); e.hasMoreElements(); )
00284       ((OLEDBSimpleProviderListener)e.nextElement()).aboutToChangeCell(iRow, iColumn);
00285     m_rsTable[iRow][iColumn] = (String)obj;
00286     saveData();
00287     for (Enumeration e = m_vListeners.elements(); e.hasMoreElements(); )
00288       ((OLEDBSimpleProviderListener)e.nextElement()).cellChanged(iRow, iColumn);
00289   }
00290
00291   public int insertRows(int iRow, int cRows) throws ComException
00292   {
00293     //  Do not handle label or wildcard rows:
00294     if (iRow <= 0)
00295       throw new ComFailException();
00296
00297     //  Count of rows to insert must be more than 0:
00298     if (cRows <= 0)
00299       throw new ComFailException();
00300
00301     //  If called to insert after the end, adjust to insert at the end:
00302     if (iRow > m_cRows)
00303       iRow = m_cRows + 1;
00304
00305     //  Create new array with additional rows:
00306     int cNewRows = m_cRows + cRows;
00307     String[][] rsNewTable = new String[cNewRows+1][m_cColumns+1];
00308     int i, j, k = 0;
00309     for (i = 0; i <= cNewRows; i++)
00310     {
00311       if (i < iRow || i > (iRow + cRows - 1))
00312       {
00313         for (j = 1; j <= m_cColumns; j++)
00314           rsNewTable[i][j] = m_rsTable[k][j];
00315         k++;
00316       }
00317       else
00318       {
00319         for (j = 1; j <= m_cColumns; j++)
00320         {
00321           rsNewTable[i][j] = new String("");
00322         }
00323       }
00324     }
00325
00326     //  Refer to new table and adjust row count:
00327     for (Enumeration e = m_vListeners.elements(); e.hasMoreElements(); )
00328       ((OLEDBSimpleProviderListener)e.nextElement()).aboutToInsertRows(iRow, cRows);
00329     m_rsTable = rsNewTable;
00330     m_cRows = cNewRows;
00331     saveData();
00332     for (Enumeration e = m_vListeners.elements(); e.hasMoreElements(); )
00333       ((OLEDBSimpleProviderListener)e.nextElement()).insertedRows(iRow, cRows);
00334
00335     // Return the count of rows inserted::
00336     return cRows;
00337   }
00338
00339   public int find(int iRowStart, int iColumn, Object obj, int findFlags, int compType) throws ComException
00340   {
00341     // Check arguments:
00342     if (iRowStart <= 0 || iRowStart > m_cRows)
00343       throw new ComFailException();
00344     if (iColumn <= 0 || iColumn > m_cColumns)
00345       throw new ComFailException();
00346
00347     // Determine search order:
00348     int   iRowStop = (findFlags == OSPFIND.OSPFIND_UP) ? 0 : m_cRows+1;
00349     boolean fCaseSensitive = (compType == OSPFIND.OSPFIND_CASESENSITIVE);
00350
00351     // Linear search through all rows:
00352     while (iRowStart != iRowStop)
00353     {
00354       if (compareString(m_rsTable[iRowStart][iColumn], (String)obj, fCaseSensitive, findFlags))
00355         return iRowStart;
00356
00357       if(findFlags == OSPFIND.OSPFIND_UP)
00358         iRowStart--;
00359       else
00360         iRowStart++;
00361     }
00362
00363     return 0;
00364   }
00365
00366   public void addOLEDBSimpleProviderListener(OLEDBSimpleProviderListener rListener) throws ComException
00367   {
00368     // Add a listener:
00369     m_vListeners.addElement(rListener);
00370     return;
00371   }
00372
00373   public void removeOLEDBSimpleProviderListener(OLEDBSimpleProviderListener rListener) throws ComException
00374   {
00375     // Remove a listener:
00376     m_vListeners.removeElement(rListener);
00377     return;
00378   }
00379
00380   public int isAsync() throws ComException
00381   {
00382     // This function should return TRUE or FALSE.  But the interface definition
00383     // converts it to "int".  Return the equivalent of 'FALSE":
00384     return 0;
00385   }
00386
00387   public int getEstimatedRows() throws ComException
00388   {
00389     return getRowCount();
00390   }
00391
00392   public void stopTransfer() throws ComException
00393   {
00394     // Do nothing in this simple example.
00395     return;
00396   }
00397
00398   public static void main(String args[])
00399   {
00400     // Test code:
00401     MyOSPObject osp = new MyOSPObject();
00402     System.out.println("Locale = " + osp.getLocale());
00403     osp.m_sFilePath = new String("C:\\Customer.txt");
00404     osp.loadData();
00405     osp.m_sFilePath = new String("C:\\Savedata.txt");
00406     Variant var;
00407     int i = 70, j = 3;
00408     var = (Variant)osp.getVariant(i, j, 0);
00409     System.out.println("Column[" + j + "] = {" + var.getString() + "}");
00410     //osp.deleteRows(1, 1);
00411     osp.insertRows(89, 1);
00412     var = null;
00413     var = (Variant)osp.getVariant(i, j, 0);
00414     System.out.println("Column[" + j + "] = {" + var.getString() + "}");
00415     //osp.saveData();
00416   }
00417 }
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Print.c Source File

  • Multimedia
  • Gdi
  • WinCap32

Print.c

Go to the documentation of this file.
00001 //********************************************************************
00002 //
00003 //  print.c
00004 //
00005 //  Source file for Device-Independent Bitmap (DIB) API.  Provides
00006 //  the following functions:
00007 //
00008 //  PrintWindowSamp()       - Prints all or part of a window
00009 //  PrintScreen()       - Prints the entire screen
00010 //  PrintDIB()          - Prints the specified DIB
00011 //
00012 // Written by Microsoft Product Support Services, Developer Support.
00013 // Copyright 1991 - 2000 Microsoft Corporation. All rights reserved.
00014 //********************************************************************
00015
00016 #define     STRICT      // enable strict type checking
00017
00018 #include <windows.h>
00019 #include <commdlg.h>
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include "dibdll.h"     // Header for printing dialog & DLL instance handle
00023 #include "dibapi.h"     // Header for DIB functions
00024 #include "dibutil.h"    // Auxiliary functions
00025
00026
00027 extern HANDLE   ghDLLInst;      // Global handle to DLL's instance
00028
00029 /***************************************************************
00030  * Typedefs
00031  **************************************************************/
00032
00033 // Structure used for Banding
00034
00035 typedef struct
00036 {
00037    BOOL bGraphics;
00038    BOOL bText;
00039    RECT GraphicsRect;
00040 } BANDINFOSTRUCT;
00041
00042
00043 /****************************************************************
00044  * Variables
00045  ***************************************************************/
00046
00047 HWND hDlgAbort;                    // Handle to Abort Dialog
00048 char szPrintDlg[] = "PRINTING";    // Name of Print dialog from .RC
00049 BOOL bAbort = FALSE;               // Abort a print operation?
00050 char gszDevice[50];                // Keeps track out device (e.g. "HP LaserJet")
00051 char gszOutput[50];                // Output device (e.g. "LPT1:")
00052
00053 /***************************************************************
00054  * Function prototypes for functions local to this module
00055  **************************************************************/
00056
00057 BOOL CALLBACK PrintAbortProc(HDC, int);
00058 int CALLBACK PrintAbortDlg(HWND, UINT, WPARAM, LPARAM);
00059 WORD PrintBand(HDC, LPRECT, LPRECT, BOOL, BOOL, LPBITMAPINFOHEADER, LPSTR);
00060 HDC GetPrinterDC(void);
00061 void CalculatePrintRect(HDC, LPRECT, WORD, DWORD, DWORD);
00062
00063
00064 /**********************************************************************
00065  *
00066  * PrintWindowSamp()
00067  *
00068  *
00069  * Description:
00070  *
00071  * This function prints the specified window on the default
00072  * printer.
00073  *
00074  * Parameters:
00075  *
00076  * HWND hWnd       - Specifies the window to print.  The window must
00077  *                   not be iconic and must be topmost on the display.
00078  *
00079  * WORD fPrintArea - Specifies the area of the window to print.  Must be
00080  *                   one of PW_ALL, PW_CLIENT, PW_CAPTION,  or PW_MENUBAR
00081  *
00082  * WORD fPrintOpt  - Print options (one of PW_BESTFIT, PW_STRETCHTOPAGE, or
00083  *                   PW_SCALE)
00084  *
00085  * WORD wXScale, wYScale - X and Y scaling factors if PW_SCALE is specified
00086  *
00087  * LPSTR szJobName - Name that you would like to give to this print job (this
00088  *                   name shows up in the Print Manager as well as the
00089  *                   "Now Printing..." dialog box).
00090  * Return Value:
00091  *      ERR_DIBFUNCTION or any return value from PrintDIB
00092  *
00093  **********************************************************************/
00094
00095
00096 WORD PrintWindowSamp(HWND hWnd, WORD fPrintArea, WORD fPrintOpt, WORD wXScale,
00097         WORD wYScale, LPSTR szJobName)
00098 {
00099     HDIB    hDib;          // Handle to the DIB
00100     WORD    wReturn;       // our return value
00101
00102     // Parameter validation
00103
00104     if (!hWnd)
00105         return ERR_INVALIDHANDLE;  // Invalid Window
00106
00107     // Copy the Window to a DIB and print it.
00108
00109     hDib = CopyWindowToDIB(hWnd, fPrintArea);
00110     if (!hDib)
00111         return ERR_DIBFUNCTION; // CopyWindowToDIB failed!
00112
00113     wReturn = PrintDIB(hDib, fPrintOpt, wXScale, wYScale, szJobName);
00114
00115     // Call DestroyDIB to free the memory the dib takes up.
00116
00117     DestroyDIB(hDib);
00118     return wReturn;   // return the value from PrintDIB
00119 }
00120
00121
00122 /**********************************************************************
00123  *
00124  * PrintScreen()
00125  *
00126  *
00127  * Description:
00128  *
00129  * This function prints the specified portion of the display screen on the
00130  * default printer using the print options specified.  The print
00131  * options are listed in dibapi.h.
00132  *
00133  * Parameters:
00134  *
00135  * LPRECT rRegion  - Specifies the region of the screen (in screen
00136  *                   coordinates) to print
00137  *
00138  * WORD fPrintOpt  - Print options  (PW_BESTFIT, PW_STRETCHTOPAGE, or PW_SCALE)
00139  *
00140  * WORD wXScale, wYScale - X and Y scaling factors if PW_SCALE is specified
00141  *
00142  * LPSTR szJobName - Name that you would like to give to this print job (this
00143  *                   name shows up in the Print Manager as well as the
00144  *                   "Now Printing..." dialog box).
00145  *
00146  * Return Value:
00147  *      ERR_DIBFUNCTION or any return value from PrintDIB
00148  *
00149  **********************************************************************/
00150
00151 WORD PrintScreen(LPRECT rRegion, WORD fPrintOpt, WORD wXScale, WORD wYScale,
00152         LPSTR szJobName)
00153 {
00154     HDIB     hDib;          // A Handle to our DIB
00155     WORD     wReturn;       // Return value
00156
00157     // Copy the screen contained in the specified rectangle to a DIB
00158
00159     hDib = CopyScreenToDIB(rRegion);
00160
00161     if (!hDib)
00162         return ERR_DIBFUNCTION;   // CopyScreenToDIB failed!
00163
00164     wReturn = PrintDIB(hDib, fPrintOpt, wXScale, wYScale, szJobName);
00165     DestroyDIB(hDib);
00166     return wReturn; // Return the value that PrintDIB returned
00167 }
00168
00169
00170 /**********************************************************************
00171  *
00172  * PrintDIB()
00173  *
00174  * Description:
00175  *
00176  * This routine prints the specified DIB.  The actual printing is done
00177  * in the PrintBand() routine (see below), this procedure drives the
00178  * printing operation.  PrintDIB() has the code to handle both banding
00179  * and non-banding printers.  A banding printer can be distinguished by
00180  * the GetDeviceCaps() API (see the code below).  On banding devices,
00181  * must repeatedly call the NEXTBAND escape to get the next banding
00182  * rectangle to print into.  If the device supports the BANDINFO escape,
00183  * it should be used to determine whether the band "wants" text or
00184  * graphics (or both).  On non-banding devices, we can ignore all this
00185  * and call PrintBand() on the entire page.
00186  *
00187  * Parameters:
00188  *
00189  * HDIB hDib       - Handle to dib to be printed
00190  *
00191  * WORD fPrintOpt  - tells which print option to use (PW_BESTFIT,
00192  *                   PW_STRETCHTOPAGE, OR PW_SCALE)
00193  *
00194  * WORD wXScale, wYScale - X and Y scaling factors (integers) for
00195  *                   printed output if the PW_SCALE option is used.
00196  *
00197  * LPSTR szJobName - Name that you would like to give to this print job (this
00198  *                   name shows up in the Print Manager as well as the
00199  *                   "Now Printing..." dialog box).
00200  *
00201  * Return Value:  (see errors.h for description)
00202  *
00203  * One of: ERR_INVALIDHANDLE
00204  *         ERR_LOCK
00205  *         ERR_SETABORTPROC
00206  *         ERR_STARTDOC
00207  *         ERR_NEWFRAME
00208  *         ERR_ENDDOC
00209  *         ERR_GETDC
00210  *         ERR_STRETCHDIBITS
00211  *
00212  ********************************************************************/
00213
00214 WORD PrintDIB(HDIB hDib, WORD fPrintOpt, WORD wXScale, WORD wYScale,
00215         LPSTR szJobName)
00216 {
00217     HDC                 hPrnDC;         // DC to the printer
00218     RECT                rect;           // Rect structure used for banding
00219     LPSTR               lpBits;         // pointer to the DIB bits
00220     LPBITMAPINFOHEADER  lpDIBHdr;       // Pointer to DIB header
00221     int                 nBandCount = 0; // used for print dialog box to count bands
00222     WORD                wErrorCode = 0; // Error code to return
00223     RECT                rPrintRect;     // specifies the area on the printer
00224                                         // (in printer coordinates) which we
00225                                         // want the DIB to go to
00226     char                szBuffer[70];   // Buffer to hold message for "Printing" dlg box
00227     char                szJobNameTrunc[35];     // szJobName truncated to 31
00228                                         // characters, since STARTDOC can't
00229                                         // accept a string longer than 31
00230     DOCINFO             DocInfo;        // structure for StartDoc
00231     int                 nTemp;          // used to check banding capability
00232     CHAR                lpBuffer[128];  // Buffer for strings retrieved from resources
00233
00234
00235     // Paramter validation
00236
00237     if (!hDib)
00238         return ERR_INVALIDHANDLE;
00239
00240     // Get pointer to DIB header
00241
00242     lpDIBHdr = (LPBITMAPINFOHEADER)GlobalLock(hDib);
00243     if (!lpDIBHdr) // Check that we have a valid pointer
00244         return ERR_LOCK;
00245     lpBits = FindDIBBits((LPSTR)lpDIBHdr); // Find pointer to DIB bits
00246
00247     if (hPrnDC = GetPrinterDC())
00248     {
00249         SetStretchBltMode(hPrnDC, COLORONCOLOR);
00250
00251         // Determine rPrintRect (printer area to print to) from the
00252         // fPrintOpt.  Fill in rPrintRect.left and .top from wXScale and
00253         // wYScale just in case we use PW_SCALE (see the function
00254         // CalculatePrintRect).
00255
00256         rPrintRect.left = wXScale;
00257         rPrintRect.top = wYScale;
00258         CalculatePrintRect(hPrnDC, &rPrintRect, fPrintOpt, lpDIBHdr->biWidth,
00259                          lpDIBHdr->biHeight);
00260
00261         // Initialize the abort procedure.
00262
00263         hDlgAbort = CreateDialog(ghDLLInst, szPrintDlg, GetFocus(),
00264                 (DLGPROC)PrintAbortDlg);
00265
00266         // ISet the text inside the dialog to the name of our print job
00267
00268         lstrcpyn(szJobNameTrunc, szJobName, sizeof(szJobNameTrunc) - 1);
00269         szJobNameTrunc[31] = '\0';           // Truncate string to 31 chars
00270         LoadString(ghDLLInst, IDS_PRINTMSG, lpBuffer, sizeof(lpBuffer) );
00271         _snprintf(szBuffer, sizeof(szBuffer) - 1, lpBuffer, (LPSTR)szJobNameTrunc);
00272         SetDlgItemText(hDlgAbort, IDC_PRINTTEXT1, (LPSTR)szBuffer);
00273
00274         // Set global variable bAbort to FALSE.  This will get set to TRUE
00275         // in our PrintAbortDlg() procedure if the user selects the
00276         // CANCEL button in our dialog box
00277
00278         bAbort = FALSE;
00279
00280         // set up the Abort Procedure
00281
00282         if (SetAbortProc(hPrnDC, (ABORTPROC)PrintAbortProc) < 0)
00283                 return ERR_SETABORTPROC;
00284
00285         // start print job
00286
00287         ZeroMemory(&DocInfo, sizeof(DOCINFO));
00288         DocInfo.cbSize = sizeof(DOCINFO);
00289         DocInfo.lpszDocName = (LPTSTR)szJobNameTrunc;
00290         DocInfo.lpszOutput = NULL;
00291
00292         if (StartDoc(hPrnDC, &DocInfo) <= 0)
00293         {
00294             // Oops, something happened, let's clean up here and return
00295
00296              DestroyWindow(hDlgAbort);   // Remove abort dialog box
00297              DeleteDC(hPrnDC);
00298              GlobalUnlock(hDib);
00299              return ERR_STARTDOC;
00300         }
00301
00302 // Note: the following banding code applies to Windows 3.1.  With the new
00303 //       printing architecture of Win32, send out both the graphics and
00304 //       text in one band (like a non-banding device).  This code is used
00305 //       for Win32s since Win32s depends on Windows 3.1 printing architecture.
00306 //
00307         // Check if need to do banding.  If we do, loop through
00308         // each band in the page, calling NEXTBAND and BANDINFO
00309         // (if supported) calling PrintBand() on the band.  Else,
00310         // call PrintBand() with the entire page as our clipping
00311         // rectangle!
00312
00313         // If Wincap32 is running on Win32s, then use banding
00314
00315         nTemp = NEXTBAND;
00316         if (Escape(hPrnDC, QUERYESCSUPPORT, sizeof(int), (LPSTR)&nTemp, NULL) &&
00317                 (GetVersion() & 0x80000000) && (LOWORD(GetVersion()) == 3))
00318         {
00319             BOOL                bBandInfoDevice;
00320             BANDINFOSTRUCT      biBandInfo;         // Used for banding
00321
00322             // Fill in initial values for our BandInfo Structure to
00323             // tell driver we can want to do graphics and text, and
00324             // also which area we want the graphics to go in.
00325
00326             biBandInfo.bGraphics = TRUE;
00327             biBandInfo.bText = TRUE;
00328             biBandInfo.GraphicsRect = rPrintRect;
00329
00330             // Check if device supports the BANDINFO escape.
00331
00332             nTemp = BANDINFO;
00333             bBandInfoDevice = Escape(hPrnDC, QUERYESCSUPPORT, sizeof(int),
00334                     (LPSTR)&nTemp, NULL);
00335
00336             // Do each band -- Call Escape() with NEXTBAND, then the
00337             // rect structure returned is the area where we are to
00338             // print in.  This loop exits when the rect area is empty.
00339
00340             while (Escape(hPrnDC, NEXTBAND, 0, NULL, (LPSTR)&rect) && !
00341                 IsRectEmpty(&rect))
00342             {
00343                 char szTmpBuf[100];
00344
00345
00346                 // Do the BANDINFO, if needed.
00347
00348                 if (bBandInfoDevice)
00349                     Escape(hPrnDC, BANDINFO, sizeof(BANDINFOSTRUCT), (LPSTR)&
00350                             biBandInfo, (LPSTR)&biBandInfo);
00351                 LoadString(ghDLLInst, IDS_BANDNMBR, lpBuffer, sizeof(lpBuffer));
00352                 _snprintf(szTmpBuf, sizeof(szTmpBuf) - 1, lpBuffer, ++nBandCount);
00353         szTmpBuf[sizeof(szTmpBuf) - 1] = '\0';
00354                 SetDlgItemText(hDlgAbort, IDC_PERCENTAGE, (LPSTR)szTmpBuf);
00355
00356                 // Call PrintBand() to do actual output into band.
00357                 // Pass in our band-info flags to tell what sort
00358                 // of data to output into the band.  Note that on
00359                 // non-banding devices, we pass in the default bandinfo
00360                 // stuff set above (i.e. bText=TRUE, bGraphics=TRUE).
00361
00362                 wErrorCode = PrintBand(hPrnDC, &rPrintRect, &rect,
00363                         biBandInfo.bText, biBandInfo.bGraphics, lpDIBHdr,
00364                         lpBits);
00365             }
00366         }
00367         else
00368         {
00369             // Print the whole page -- non-banding device.
00370
00371             if (StartPage(hPrnDC) <= 0)
00372                 return ERR_STARTPAGE;
00373
00374             rect = rPrintRect;
00375             LoadString(ghDLLInst, IDS_SENDINGBAND, lpBuffer, sizeof(lpBuffer));
00376             SetDlgItemText(hDlgAbort, IDC_PERCENTAGE, lpBuffer);
00377             wErrorCode = PrintBand(hPrnDC, &rPrintRect, &rect, TRUE, TRUE,
00378                     lpDIBHdr, lpBits);
00379
00380             // Non-banding devices need a NEWFRAME
00381
00382             if (EndPage(hPrnDC) <= 0)
00383                 return ERR_ENDPAGE;
00384         }
00385
00386
00387         // End the print operation.  Only send the ENDDOC if
00388         //  we didn't abort or error.
00389
00390         if (!bAbort)
00391         {
00392             // We errored out on ENDDOC, but don't return here - we still
00393             // need to close the dialog box, free proc instances, etc.
00394
00395             if (EndDoc(hPrnDC) <= 0)
00396                 wErrorCode = ERR_ENDDOC;
00397
00398             DestroyWindow(hDlgAbort);
00399         }
00400
00401         // All done, clean up.
00402
00403         DeleteDC(hPrnDC);
00404     }
00405     else
00406         wErrorCode = ERR_GETDC;   // Couldn't get Printer DC!
00407
00408     GlobalUnlock(hDib);
00409     return wErrorCode;
00410 }
00411
00412
00413
00414
00415 // *******************************************************************
00416 // Auxiliary Functions
00417 //     -- Local to this module only
00418 // *******************************************************************
00419
00420
00421 /*********************************************************************
00422  *
00423  * CalculatePrintRect()
00424  *
00425  * Given fPrintOpt and a size of the DIB, return the area on the
00426  * printer where the image should go (in printer coordinates).  If
00427  * fPrintOpt is PW_SCALE, then lpPrintRect.left and .top should
00428  * contain WORDs which specify the scaling factor for the X and
00429  * Y directions, respecively.
00430  *
00431  ********************************************************************/
00432
00433 void CalculatePrintRect(HDC hDC, LPRECT lpPrintRect, WORD fPrintOpt,
00434         DWORD cxDIB, DWORD cyDIB)
00435 {
00436     int  cxPage, cyPage, cxInch, cyInch;
00437
00438     if (!hDC)
00439         return;
00440
00441     // Get some info from printer driver
00442
00443     cxPage = GetDeviceCaps(hDC, HORZRES);   // Width of printr page - pixels
00444     cyPage = GetDeviceCaps(hDC, VERTRES);   // Height of printr page - pixels
00445     cxInch = GetDeviceCaps(hDC, LOGPIXELSX);// Printer pixels per inch - X
00446     cyInch = GetDeviceCaps(hDC, LOGPIXELSY);// Printer pixels per inch - Y
00447
00448     switch (fPrintOpt)
00449     {
00450
00451         // Best Fit case -- create a rectangle which preserves
00452         // the DIB's aspect ratio, and fills the page horizontally.
00453
00454         // The formula in the "->bottom" field below calculates the Y
00455         // position of the printed bitmap, based on the size of the
00456         // bitmap, the width of the page, and the relative size of
00457         // a printed pixel (cyInch / cxInch).
00458
00459         case PW_BESTFIT:
00460             lpPrintRect->top = 0;
00461             lpPrintRect->left = 0;
00462             lpPrintRect->bottom = (int)(((double)cyDIB * cxPage * cyInch) /
00463                     ((double)cxDIB * cxInch));
00464             lpPrintRect->right = cxPage;
00465             break;
00466
00467         // Scaling option -- lpPrintRect's top/left contain
00468         // multipliers to multiply the DIB's height/width by.
00469
00470         case PW_SCALE:
00471         {
00472             int     cxMult, cyMult;
00473
00474             cxMult = lpPrintRect->left;
00475             cyMult = lpPrintRect->top;
00476             lpPrintRect->top = 0;
00477             lpPrintRect->left = 0;
00478             lpPrintRect->bottom = (int)(cyDIB * cyMult);
00479             lpPrintRect->right = (int)(cxDIB * cxMult);
00480             break;
00481         }
00482
00483         // Stretch To Page case -- create a rectangle
00484         // which covers the entire printing page (note that this
00485         // is also the default).
00486
00487         case PW_STRETCHTOPAGE:
00488
00489         default:
00490             lpPrintRect->top = 0;
00491             lpPrintRect->left = 0;
00492             lpPrintRect->bottom = cyPage;
00493             lpPrintRect->right = cxPage;
00494             break;
00495     }
00496 }
00497
00498
00499 /*********************************************************************
00500  *
00501  * PrintBand()
00502  *
00503  * This routine does ALL output to the printer.  It is called from
00504  * the PrintDIB() routine.  It is called for both banding and non-
00505  * banding printing devices.  lpRectClip contains the rectangular
00506  * area we should do our output into (i.e. we should clip our output
00507  * to this area).  The flags fDoText and fDoGraphics should be set
00508  * appropriately (if we want any text output to the rectangle, set
00509  * fDoText to true).  Normally these flags are returned on banding
00510  * devices which support the BANDINFO escape.
00511  *
00512  ********************************************************************/
00513
00514 WORD PrintBand(HDC hDC, LPRECT lpRectOut, LPRECT lpRectClip, BOOL fDoText,
00515         BOOL fDoGraphics, LPBITMAPINFOHEADER lpDIBHdr, LPSTR lpDIBBits)
00516 {
00517     RECT    rect;           // Temporary rectangle
00518     double  dblXScaling,    // X and Y scaling factors
00519             dblYScaling;
00520     WORD    wReturn = 0;    // Return code
00521
00522     if (fDoGraphics)
00523     {
00524         dblXScaling = ((double)lpRectOut->right - lpRectOut->left) / (double)
00525                 lpDIBHdr->biWidth;
00526         dblYScaling = ((double)lpRectOut->bottom - lpRectOut->top) / (double)
00527                 lpDIBHdr->biHeight;
00528
00529         // Now we set up a temporary rectangle -- this rectangle
00530         // holds the coordinates on the paper where our bitmap
00531         // WILL be output.  We can intersect this rectangle with
00532         // the lpClipRect to see what we NEED to output to this
00533         // band.  Then, we determine the coordinates in the DIB
00534         // to which this rectangle corresponds (using dbl?Scaling).
00535
00536         IntersectRect(&rect, lpRectOut, lpRectClip);
00537         if (!IsRectEmpty(&rect))
00538         {
00539             RECT    rectIn;
00540
00541             rectIn.left = (int)((rect.left - lpRectOut->left) / dblXScaling +
00542                     0.5
00543                        );
00544             rectIn.top = (int)((rect.top - lpRectOut->top) / dblYScaling + 0.5);
00545             rectIn.right = (int)(rectIn.left + (rect.right - rect.left) /
00546                     dblXScaling + 0.5);
00547             rectIn.bottom = (int)(rectIn.top + (rect.bottom - rect.top) /
00548                     dblYScaling + 0.5);
00549             if (!StretchDIBits(hDC, rect.left, rect.top,
00550                     rect.right - rect.left, rect.bottom - rect.top,
00551                     rectIn.left, (int)(lpDIBHdr->biHeight) -
00552                     rectIn.top - (rectIn.bottom - rectIn.top),
00553                     rectIn.right - rectIn.left, rectIn.bottom - rectIn.top,
00554                     lpDIBBits, (LPBITMAPINFO)lpDIBHdr, DIB_RGB_COLORS,
00555                     SRCCOPY))
00556                 wReturn = ERR_STRETCHDIBITS; // StretchDIBits() failed!
00557         }
00558     }
00559
00560     return wReturn;
00561 }
00562
00563
00564 /***********************************************************************
00565  *
00566  * GetPrinterDC()
00567  *
00568  * Uses PrinDlg common dialog for printer selection and creates a dc.
00569  * Returns NULL on error.
00570  *
00571  ***********************************************************************/
00572
00573 HDC GetPrinterDC() {
00574
00575     PRINTDLG pd;
00576
00577     ZeroMemory(&pd, sizeof(pd));
00578
00579     pd.lStructSize = sizeof(PRINTDLG);
00580     pd.Flags = PD_RETURNDC;
00581
00582     if (PrintDlg(&pd) == TRUE)
00583     {
00584         DEVNAMES    *pDevNames = GlobalLock(pd.hDevNames);
00585
00586         lstrcpyn((LPSTR)gszDevice,
00587                 (LPSTR)((char *)pDevNames+pDevNames->wDeviceOffset),
00588         sizeof(gszDevice) - 1);
00589
00590     gszDevice[sizeof(gszDevice) - 1] = '\0';
00591
00592         if(!lstrcmpi((LPSTR)((char *)pDevNames+pDevNames->wDeviceOffset),
00593                 (LPSTR)((char *)pDevNames+pDevNames->wOutputOffset)))
00594     {
00595             lstrcpyn((LPSTR)gszOutput, "net:", 5);
00596       gszOutput[4] = '\0';
00597     }
00598         else
00599     {
00600             lstrcpyn((LPSTR)gszOutput,
00601                     (LPSTR)((char *)pDevNames+pDevNames->wOutputOffset),
00602           sizeof(gszOutput) - 1);
00603             gszOutput[sizeof(gszOutput) - 1] = '\0';
00604     }
00605
00606         GlobalUnlock(pd.hDevNames);
00607         return pd.hDC;
00608     }
00609
00610     else
00611         return NULL;
00612 }
00613
00614
00615 /**********************************************************************
00616  * PrintAbortProc()
00617  *
00618  * Abort procedure - contains the message loop while printing is
00619  * in progress.  By using a PeekMessage() loop, multitasking
00620  * can occur during printing.
00621  *
00622  **********************************************************************/
00623
00624 BOOL CALLBACK PrintAbortProc(HDC hDC, int code)
00625 {
00626     MSG  msg;
00627
00628     while (!bAbort && PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
00629         if (!IsDialogMessage(hDlgAbort, &msg))
00630         {
00631             TranslateMessage(&msg);
00632             DispatchMessage(&msg);
00633         }
00634
00635     return !bAbort;
00636 }
00637
00638 /***********************************************************************
00639  *
00640  * PrintAbortDlg()
00641  *
00642  *
00643  * This is the Dialog Procedure which will handle the "Now Printing"
00644  * dialog box.  When the user presses the "Cancel" button, the
00645  * global variable bAbort is set to TRUE, which causes the
00646  * PrintAbortProc to exit, which in turn causes the printing
00647  * operation to terminate.
00648  *
00649  ***********************************************************************/
00650
00651 int CALLBACK PrintAbortDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00652 {
00653     switch (msg)
00654     {
00655         case WM_INITDIALOG:
00656         {
00657             char szBuffer[100];
00658             CHAR msgBuffer[128];
00659
00660
00661             // Fill in the text which specifies where this bitmap
00662             // is going ("on HP LaserJet on LPT1", for example)
00663             LoadString(ghDLLInst, IDS_ABORTSTRING, msgBuffer, sizeof(msgBuffer));
00664             _snprintf(szBuffer, sizeof(szBuffer) - 1, msgBuffer, (LPSTR)gszDevice,
00665                     (LPSTR)gszOutput);
00666       szBuffer[sizeof(szBuffer) - 1] = '\0';
00667             SetDlgItemText(hWnd, IDC_PRINTTEXT2, (LPSTR)szBuffer);
00668             SetFocus(GetDlgItem(hWnd, IDCANCEL));
00669             return TRUE;     // Return TRUE because we called SetFocus()
00670         }
00671
00672         case WM_COMMAND:
00673             bAbort = TRUE;
00674             DestroyWindow(hWnd);
00675             return TRUE;
00676             break;
00677     }
00678
00679     return FALSE;
00680 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/people.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

people.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include "People.h"
00021
00022 const GUID CPeoplePoweredVehicle::thisGuid = { 0x96713509, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00023 // {96713509-6BE7-11d3-9156-00C04F65B3F9}
00024 //DEFINE_GUID(<<name>>,
00025 //0x96713509, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00026
00027
00028 const GUID CBicycleFolder::thisGuid = { 0x9671350a, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00029 // {9671350A-6BE7-11d3-9156-00C04F65B3F9}
00030 //DEFINE_GUID(<<name>>,
00031 //0x9671350a, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00032
00033
00034 const GUID CSkateboardFolder::thisGuid = { 0x9671350b, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00035 // {9671350B-6BE7-11d3-9156-00C04F65B3F9}
00036 //DEFINE_GUID(<<name>>,
00037 //0x9671350b, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00038
00039 const GUID CIceSkateFolder::thisGuid = { 0x9e3ff365, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00040 // {9E3FF365-6BE7-11d3-9156-00C04F65B3F9}
00041 //DEFINE_GUID(<<name>>,
00042 //0x9e3ff365, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00043
00044 const GUID CBicycle::thisGuid = { 0x9e3ff366, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00045 // {9E3FF366-6BE7-11d3-9156-00C04F65B3F9}
00046 //DEFINE_GUID(<<name>>,
00047 //0x9e3ff366, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00048
00049
00050 const GUID CSkateboard::thisGuid = { 0xa6707e01, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00051 // {A6707E01-6BE7-11d3-9156-00C04F65B3F9}
00052 //DEFINE_GUID(<<name>>,
00053 //0xa6707e01, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00054
00055
00056 const GUID CIceSkate::thisGuid = { 0xa6707e02, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00057 // {A6707E02-6BE7-11d3-9156-00C04F65B3F9}
00058 //DEFINE_GUID(<<name>>,
00059 //0xa6707e02, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00060
00061
00062 //==============================================================
00063 //
00064 // CPeoplePoweredVehicle implementation
00065 //
00066 //
00067 CPeoplePoweredVehicle::CPeoplePoweredVehicle()
00068 {
00069     children[0] = new CBicycleFolder;
00070     children[1] = new CSkateboardFolder;
00071     children[2] = new CIceSkateFolder;
00072 }
00073
00074 CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
00075 {
00076     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00077         delete children[n];
00078 }
00079
00080 HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00081 {
00082     SCOPEDATAITEM sdi;
00083
00084     if (!bExpanded) {
00085         // create the child nodes, then expand them
00086         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00087             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00088             sdi.mask = SDI_STR       |   // Displayname is valid
00089                 SDI_PARAM     |   // lParam is valid
00090                 SDI_IMAGE     |   // nImage is valid
00091                 SDI_OPENIMAGE |   // nOpenImage is valid
00092                 SDI_PARENT    |   // relativeID is valid
00093                 SDI_CHILDREN;     // cChildren is valid
00094
00095             sdi.relativeID  = (HSCOPEITEM)parent;
00096             sdi.nImage      = children[n]->GetBitmapIndex();
00097             sdi.nOpenImage  = INDEX_OPENFOLDER;
00098             sdi.displayname = MMC_CALLBACK;
00099             sdi.lParam      = (LPARAM)children[n];       // The cookie
00100             sdi.cChildren   = 0;
00101
00102             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00103
00104             _ASSERT( SUCCEEDED(hr) );
00105
00106             children[n]->SetScopeItemValue(sdi.ID);
00107         }
00108     }
00109
00110     return S_OK;
00111 }
00112
00113 CBicycleFolder::CBicycleFolder()
00114 {
00115     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00116         children[n] = new CBicycle(n + 1);
00117     }
00118 }
00119
00120 CBicycleFolder::~CBicycleFolder()
00121 {
00122     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00123         if (children[n]) {
00124             delete children[n];
00125         }
00126 }
00127
00128 HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00129 {
00130     HRESULT      hr = S_OK;
00131
00132     IHeaderCtrl *pHeaderCtrl = NULL;
00133     IResultData *pResultData = NULL;
00134
00135     if (bShow) {
00136         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00137         _ASSERT( SUCCEEDED(hr) );
00138
00139         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00140         _ASSERT( SUCCEEDED(hr) );
00141
00142         // Set the column headers in the results pane
00143         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00144         _ASSERT( S_OK == hr );
00145
00146         // insert items here
00147         RESULTDATAITEM rdi;
00148
00149         hr = pResultData->DeleteAllRsltItems();
00150         _ASSERT( SUCCEEDED(hr) );
00151
00152         if (!bExpanded) {
00153             // create the child nodes, then expand them
00154             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00155                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00156                 rdi.mask       = RDI_STR       |   // Displayname is valid
00157                     RDI_IMAGE     |
00158                     RDI_PARAM;        // nImage is valid
00159
00160                 rdi.nImage      = children[n]->GetBitmapIndex();
00161                 rdi.str         = MMC_CALLBACK;
00162                 rdi.nCol        = 0;
00163                 rdi.lParam      = (LPARAM)children[n];
00164
00165                 hr = pResultData->InsertItem( &rdi );
00166                 _ASSERT( SUCCEEDED(hr) );
00167             }
00168         }
00169
00170         pHeaderCtrl->Release();
00171         pResultData->Release();
00172     }
00173
00174     return hr;
00175 }
00176
00177 CIceSkateFolder::CIceSkateFolder()
00178 {
00179     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00180         children[n] = new CIceSkate(n + 1);
00181     }
00182 }
00183
00184 CIceSkateFolder::~CIceSkateFolder()
00185 {
00186     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00187         if (children[n]) {
00188             delete children[n];
00189         }
00190 }
00191
00192 HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00193 {
00194     HRESULT      hr = S_OK;
00195
00196     IHeaderCtrl *pHeaderCtrl = NULL;
00197     IResultData *pResultData = NULL;
00198
00199     if (bShow) {
00200         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00201         _ASSERT( SUCCEEDED(hr) );
00202
00203         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00204         _ASSERT( SUCCEEDED(hr) );
00205
00206         // Set the column headers in the results pane
00207         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00208         _ASSERT( S_OK == hr );
00209
00210         // insert items here
00211         RESULTDATAITEM rdi;
00212
00213         hr = pResultData->DeleteAllRsltItems();
00214         _ASSERT( SUCCEEDED(hr) );
00215
00216         if (!bExpanded) {
00217             // create the child nodes, then expand them
00218             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00219                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00220                 rdi.mask       = RDI_STR       |   // Displayname is valid
00221                     RDI_IMAGE     |
00222                     RDI_PARAM;        // nImage is valid
00223
00224                 rdi.nImage      = children[n]->GetBitmapIndex();
00225                 rdi.str         = MMC_CALLBACK;
00226                 rdi.nCol        = 0;
00227                 rdi.lParam      = (LPARAM)children[n];
00228
00229                 hr = pResultData->InsertItem( &rdi );
00230                 _ASSERT( SUCCEEDED(hr) );
00231            }
00232         }
00233
00234         pHeaderCtrl->Release();
00235         pResultData->Release();
00236     }
00237
00238     return hr;
00239 }
00240
00241 CSkateboardFolder::CSkateboardFolder()
00242 {
00243     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00244         children[n] = new CSkateboard(n + 1);
00245     }
00246 }
00247
00248 CSkateboardFolder::~CSkateboardFolder()
00249 {
00250     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00251         if (children[n]) {
00252             delete children[n];
00253         }
00254 }
00255
00256 HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00257 {
00258     HRESULT      hr = S_OK;
00259
00260     IHeaderCtrl *pHeaderCtrl = NULL;
00261     IResultData *pResultData = NULL;
00262
00263     if (bShow) {
00264         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00265         _ASSERT( SUCCEEDED(hr) );
00266
00267         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00268         _ASSERT( SUCCEEDED(hr) );
00269
00270         // Set the column headers in the results pane
00271         hr = pHeaderCtrl->InsertColumn( 0, L"Name                      ", 0, MMCLV_AUTO );
00272         _ASSERT( S_OK == hr );
00273
00274         // insert items here
00275         RESULTDATAITEM rdi;
00276
00277         hr = pResultData->DeleteAllRsltItems();
00278         _ASSERT( SUCCEEDED(hr) );
00279
00280         if (!bExpanded) {
00281             // create the child nodes, then expand them
00282             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00283                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00284                 rdi.mask       = RDI_STR       |   // Displayname is valid
00285                     RDI_IMAGE     |
00286                     RDI_PARAM;        // nImage is valid
00287
00288                 rdi.nImage      = children[n]->GetBitmapIndex();
00289                 rdi.str         = MMC_CALLBACK;
00290                 rdi.nCol        = 0;
00291                 rdi.lParam      = (LPARAM)children[n];
00292
00293                 hr = pResultData->InsertItem( &rdi );
00294                 _ASSERT( SUCCEEDED(hr) );
00295            }
00296         }
00297
00298         pHeaderCtrl->Release();
00299         pResultData->Release();
00300     }
00301
00302     return hr;
00303 }
00304
00305 const _TCHAR *CBicycle::GetDisplayName(int nCol)
00306 {
00307     static _TCHAR buf[128];
00308
00309     _stprintf(buf, _T("Bicycle #%d"), id);
00310
00311     return buf;
00312 }
00313
00314 const _TCHAR *CSkateboard::GetDisplayName(int nCol)
00315 {
00316     static _TCHAR buf[128];
00317
00318     _stprintf(buf, _T("Skateboard #%d"), id);
00319
00320     return buf;
00321 }
00322
00323 const _TCHAR *CIceSkate::GetDisplayName(int nCol)
00324 {
00325     static _TCHAR buf[128];
00326
00327     _stprintf(buf, _T("Ice Skate #%d"), id);
00328
00329     return buf;
00330 }
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

RealTimeStylusPlugins::CustomDynamicRendererPlugin Member List

This is the complete list of members for RealTimeStylusPlugins::CustomDynamicRendererPlugin, including all inherited members.
CustomDynamicRendererPlugin(Graphics g) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
DataInterest | RealTimeStylusPlugins::CustomDynamicRendererPlugin |
Error(RealTimeStylus sender, ErrorData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
InAirPackets(RealTimeStylus sender, InAirPacketsData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
myGraphics | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [private]
Packets(RealTimeStylus sender, PacketsData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
RealTimeStylusDisabled(RealTimeStylus sender, RealTimeStylusDisabledData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
RealTimeStylusEnabled(RealTimeStylus sender, RealTimeStylusEnabledData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
StylusButtonDown(RealTimeStylus sender, StylusButtonDownData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
StylusButtonUp(RealTimeStylus sender, StylusButtonUpData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
StylusDown(RealTimeStylus sender, StylusDownData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
StylusInRange(RealTimeStylus sender, StylusInRangeData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
StylusOutOfRange(RealTimeStylus sender, StylusOutOfRangeData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
StylusUp(RealTimeStylus sender, StylusUpData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
SystemGesture(RealTimeStylus sender, SystemGestureData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
TabletAdded(RealTimeStylus sender, TabletAddedData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
TabletRemoved(RealTimeStylus sender, TabletRemovedData data) | RealTimeStylusPlugins::CustomDynamicRendererPlugin | [inline]
Generated on Wed Nov 13 2024 16:58:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Dialogs.c Source File

  • Multimedia
  • Gdi
  • WinCap32

Dialogs.c

Go to the documentation of this file.
00001 //***********************************************************************
00002 //
00003 // dialogs.c
00004 //
00005 // Contains all the dialog procedures for WinCap Windows Screen Capture
00006 // Program.
00007 //
00008 // Dialog Functions:
00009 //
00010 // AboutDlgProc()         // About Box
00011 // PrintDlgProc()         // Print Options Dialog
00012 // SavingDlgProc()        // Dialog which displays "Saving to file..."
00013 //
00014 // Written by Microsoft Product Support Services, Developer Support.
00015 // Copyright 1991 - 2000 Microsoft Corporation. All rights reserved.
00016 //***********************************************************************
00017
00018 #define     STRICT      // enable strict type checking
00019
00020 #include <windows.h>
00021 #include <string.h>
00022 #include <stdlib.h>
00023 #include "WINCAP.h"
00024 #include "DIALOGS.h"
00025 #include "commdlg.h"
00026 #include "resource.h"
00027
00028 // Global variables which are set in main program
00029
00030 extern char         szAppName[20];  /// Name of app
00031 extern HINSTANCE    ghInst;         /// Handle to instance
00032 extern HWND         ghWndMain;      /// Handle to main window
00033 extern BOOL         gbNowCapturing;
00034 extern BOOL     gbCaptRect;
00035
00036 //**********************************************************************
00037 //
00038 //"About" Dialog Box Window Procedure
00039 //
00040 // Notable features:  This dialog box draws the application's icon
00041 // in the dialog box itself. The icon is actually stretched larger to
00042 // fit in the specified area, which must be done manually.
00043 // See WM_PAINT case.
00044 //
00045 //
00046 //***********************************************************************
00047
00048 LRESULT APIENTRY AboutDlgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM
00049         lParam)
00050 {
00051     static HBITMAP  ghAboutBmp = NULL;
00052
00053     switch (Message)
00054     {
00055         // Set focus on the OK button.  Since we set focus, return FALSE
00056
00057         case WM_INITDIALOG:
00058             SetFocus(GetDlgItem(hWndDlg, IDOK));
00059             ghAboutBmp = LoadBitmap(ghInst, "ABOUTBMP");
00060             return FALSE;
00061
00062         //Closing the Dialog behaves the same as Cancel
00063
00064         case WM_CLOSE:
00065             PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
00066             break;
00067
00068         case WM_COMMAND:
00069             switch (wParam)
00070             {
00071                 case IDOK:
00072
00073                 case IDCANCEL:
00074                     EndDialog(hWndDlg, FALSE);
00075                     if (ghAboutBmp)
00076                         DeleteObject(ghAboutBmp);
00077
00078                     break;
00079             }
00080             break;    //End of WM_COMMAND
00081
00082         // Paint our bitmap in the about box in the WM_PAINT case
00083
00084         case WM_PAINT:
00085         {
00086             HBITMAP     hbm;
00087             HDC         hdcMem;
00088             PAINTSTRUCT ps;
00089             RECT        r1;        // Coordinates of TEXT1 control
00090             POINT       p1;        // Used to convert screen to client coords
00091             BITMAP      bm;        // For getting info about "About" bitmap
00092
00093             BeginPaint(hWndDlg, &ps);
00094
00095             // Place screen coords of TEXT1 in r1
00096
00097             GetWindowRect(GetDlgItem(hWndDlg, IDC_TEXT1), &r1);
00098             p1.x = r1.left;
00099             p1.y = r1.top;
00100
00101             ScreenToClient(hWndDlg, &p1);
00102
00103             // p1 now describes the location of upper-left corner
00104             // for the top text in the dialog.  Let's use this
00105             // to make sure we don't draw our bitmap over the text
00106
00107             r1.left = 12;
00108             r1.top = p1.y;
00109             r1.right = p1.x - 25;
00110             r1.bottom = r1.top + (r1.right - r1.left); // Make it square
00111
00112             if (hdcMem = CreateCompatibleDC(ps.hdc))
00113             {
00114                 GetObject(ghAboutBmp, sizeof(BITMAP), (LPVOID)&bm);
00115                 hbm = SelectObject(hdcMem, ghAboutBmp);
00116                 StretchBlt(ps.hdc, r1.left, r1.top, r1.right, r1.bottom, hdcMem,
00117                         0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
00118                 SelectObject(hdcMem, hbm);
00119                 DeleteDC(hdcMem);
00120             }
00121
00122             EndPaint(hWndDlg, &ps);
00123             break;
00124         }
00125
00126         default:
00127             return FALSE;
00128     }
00129
00130     return TRUE;
00131 } // End of DIALOGSMsgProc
00132
00133
00134 //***********************************************************************
00135 //
00136 // "Print" Dialog Box Window Procedure
00137 //
00138 // This procedure takes care of the processing for the "Print" dialog
00139 // box, which contains the printing options.
00140 //
00141 // This Dialog Box Procedure is called using DialogBoxParam.  This
00142 // allows us to pass a parameter into the dialog box procedure -- the
00143 // parameter that gets passed in here is a LPSTR to a structure holding
00144 // all the options that the user specified in this dialog box.  This
00145 // allows passing the options back to the main program WITHOUT using
00146 // global variables.
00147 //
00148 //***********************************************************************
00149
00150 LRESULT APIENTRY PrintDlgProc(HWND hWndDlg, UINT Message, WPARAM wParam,
00151         LPARAM lParam)
00152 {
00153     static LPOPTIONSTRUCT   lpOS;
00154
00155     switch (Message)
00156     {
00157         case WM_INITDIALOG:
00158         {
00159
00160             // Because DialogBoxParam() was used to invoke this dialog box,
00161             // lParam contains a pointer to the OPTIONSTRUCT.
00162             // Place user input in this structure before returning.
00163
00164             lpOS = (LPOPTIONSTRUCT)lParam;
00165
00166             // Check the default button -- "BEST FIT"
00167
00168             CheckRadioButton(hWndDlg, IDC_BESTFIT, IDC_STRETCHTOPAGE, IDC_BESTFIT);
00169
00170             // Gray out the stuff under "SCALE"
00171
00172             EnableWindow(GetDlgItem(hWndDlg, IDC_XAXIS), FALSE);
00173             EnableWindow(GetDlgItem(hWndDlg, IDC_YAXIS), FALSE);
00174             EnableWindow(GetDlgItem(hWndDlg, IDC_XTEXT), FALSE);
00175             EnableWindow(GetDlgItem(hWndDlg, IDC_YTEXT), FALSE);
00176             break;
00177         }
00178
00179         // Closing the Dialog should behave the same as Cancel
00180
00181         case WM_CLOSE:
00182             PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
00183             break;
00184
00185         case WM_COMMAND:
00186             switch (wParam)
00187             {
00188                 case IDC_BESTFIT:
00189
00190                 case IDC_STRETCHTOPAGE:
00191
00192                 case IDC_SCALE:
00193
00194                     // Check the correct button
00195
00196                     CheckRadioButton(hWndDlg, IDC_BESTFIT, IDC_SCALE, (int)wParam);
00197
00198                     // And enable or disable the options under "Scale",
00199                     // depending on whether or not the IDC_SCALE button
00200                     // is checked
00201
00202                     EnableWindow(GetDlgItem(hWndDlg, IDC_XAXIS),
00203                             (BOOL)(wParam == IDC_SCALE));
00204                     EnableWindow(GetDlgItem(hWndDlg, IDC_YAXIS),
00205                             (BOOL)(wParam == IDC_SCALE));
00206                     EnableWindow(GetDlgItem(hWndDlg, IDC_XTEXT),
00207                             (BOOL)(wParam == IDC_SCALE));
00208                     EnableWindow(GetDlgItem(hWndDlg, IDC_YTEXT),
00209                             (BOOL)(wParam == IDC_SCALE));
00210                     break;
00211
00212                 case IDOK:
00213                 {
00214                     char    szTmp[100];
00215
00216                     // Save the user's selection into the OPTIONSTRUCT
00217
00218                     if (!lpOS)
00219                     {
00220                         EndDialog(hWndDlg, FALSE);
00221                         break;
00222                     }
00223
00224                     if (IsDlgButtonChecked(hWndDlg, IDC_BESTFIT))
00225                         lpOS->iOption = IDC_BESTFIT;
00226
00227                     if (IsDlgButtonChecked(hWndDlg, IDC_STRETCHTOPAGE))
00228                         lpOS->iOption = IDC_STRETCHTOPAGE;
00229
00230                     if (IsDlgButtonChecked(hWndDlg, IDC_SCALE))
00231                         lpOS->iOption = IDC_SCALE;
00232
00233                     if (GetDlgItemText(hWndDlg, IDC_XAXIS, (LPSTR)szTmp, 100))
00234                         lpOS->iXScale = atoi(szTmp);
00235
00236                     if (GetDlgItemText(hWndDlg, IDC_YAXIS, (LPSTR)szTmp, 100))
00237                         lpOS->iYScale = atoi(szTmp);
00238
00239                     EndDialog(hWndDlg, TRUE);
00240                     break;
00241                 }
00242
00243
00244                 case IDCANCEL:
00245                     EndDialog(hWndDlg, FALSE);
00246                     break;
00247             } // End of WM_COMMAND
00248
00249             break;
00250
00251         default:
00252             return FALSE;
00253     }
00254
00255     return TRUE;
00256 }
00257
00258
00259 //***********************************************************************
00260 //
00261 // "Saving file to..." Dialog Box Window Procedure
00262 //
00263 // This is a modeless dialog box which is called when we save the bitmap
00264 // to a file (so the user dosen't think his machine has hung).
00265 //
00266 //***********************************************************************
00267
00268 LRESULT APIENTRY SavingDlgProc(HWND hDlg, UINT message, WPARAM wParam,
00269         LPARAM lParam)
00270 {
00271     switch (message)
00272     {
00273         case WM_SETFOCUS:
00274             MessageBeep(0);
00275             break;
00276
00277         case WM_INITDIALOG:
00278
00279             // Set the text of the filename in the dialog box.  This dialog
00280             // should be called with DialogBoxParam, and the parameter should
00281             // be a pointer to the filename.  It shows up as the lParam here.
00282
00283             SetDlgItemText(hDlg, IDC_FILETEXT, (LPSTR)lParam);
00284             return TRUE;
00285             break;
00286
00287         case WM_DESTROY:
00288             return TRUE;
00289             break;
00290     }
00291
00292   // default return value.
00293   return FALSE;
00294 }
00295
00296
00297 //***********************************************************************
00298 //
00299 // Selection Help Dialog Box Window Procedure
00300 //
00301 // This is a modeless dialog box which displays how to select a window to
00302 // be captured
00303 //
00304 //***********************************************************************
00305 LRESULT APIENTRY SelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
00306         lParam)
00307 {
00308     switch (message)
00309     {
00310         case WM_INITDIALOG:
00311         {
00312             HGLOBAL     hMem;
00313             char        *szText;
00314
00315             hMem = GlobalAlloc(GHND, 200);
00316       if (!hMem)
00317         return FALSE;
00318
00319             szText = (char *)GlobalLock(hMem);
00320             if(szText == NULL)
00321                 return TRUE;
00322
00323             LoadString(ghInst, IDS_SELECT2, szText, 200);
00324             SetDlgItemText(hDlg, IDC_STATIC_SELECT2, szText);
00325             LoadString(ghInst, IDS_SELECT3, szText, 200);
00326             SetDlgItemText(hDlg, IDC_STATIC_SELECT3, szText);
00327
00328             GlobalUnlock(hMem);
00329             GlobalFree(hMem);
00330
00331             return TRUE;
00332         }
00333
00334         case WM_COMMAND:
00335             if ((wParam) != IDCANCEL)
00336                 return FALSE;
00337             else
00338             {
00339                 ShowWindow(hDlg, SW_HIDE);
00340                 gbNowCapturing = FALSE;
00341                 return TRUE;
00342             }
00343
00344         case WM_SYSCOMMAND:
00345             if(wParam == SC_CLOSE)
00346             {
00347                 ShowWindow(hDlg, SW_HIDE);
00348                 gbNowCapturing = FALSE;
00349                 return TRUE;
00350             }
00351             else
00352                 return FALSE;
00353
00354         case WM_DESTROY:
00355             return TRUE;
00356
00357         default:
00358             return FALSE;
00359     }
00360 }
00361
00362
00363 //***********************************************************************
00364 //
00365 // Selection Help Dialog Box Window Procedure
00366 //
00367 // This is a modeless dialog box which displays how to select a window to
00368 // be captured
00369 //
00370 //***********************************************************************
00371 LRESULT APIENTRY RectangleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
00372         lParam)
00373 {
00374     switch (message)
00375     {
00376         case WM_INITDIALOG:
00377         {
00378             HGLOBAL     hMem;
00379             char        *szText;
00380
00381             hMem = GlobalAlloc(GHND, 200);
00382       if (!hMem)
00383         return FALSE;
00384
00385             szText = (char *)GlobalLock(hMem);
00386             if(szText == NULL)
00387                 return TRUE;
00388
00389             LoadString(ghInst, IDS_RECT2, szText, 200);
00390             SetDlgItemText(hDlg, IDC_STATIC_RECT2, szText);
00391             LoadString(ghInst, IDS_RECT3, szText, 200);
00392             SetDlgItemText(hDlg, IDC_STATIC_RECT3, szText);
00393
00394             GlobalUnlock(hMem);
00395             GlobalFree(hMem);
00396
00397             return TRUE;
00398         }
00399
00400         case WM_COMMAND:
00401             if ((wParam) != IDCANCEL)
00402                 return FALSE;
00403             else
00404             {
00405                 ShowWindow(hDlg, SW_HIDE);
00406                 gbNowCapturing = FALSE;
00407         gbCaptRect = FALSE;
00408                 return TRUE;
00409             }
00410
00411         case WM_SYSCOMMAND:
00412             if(wParam == SC_CLOSE)
00413             {
00414                 ShowWindow(hDlg, SW_HIDE);
00415                 gbNowCapturing = FALSE;
00416                 return TRUE;
00417             }
00418             else
00419                 return FALSE;
00420
00421         case WM_DESTROY:
00422             return TRUE;
00423
00424         default:
00425             return FALSE;
00426     }
00427 }
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/GraphObj/Point.Cpp Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • GraphObj

Point.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 // Point.cpp : Implementation of CPoint
00013 #include "stdafx.h"
00014 #include "GraphObj.h"
00015 #include "Point.h"
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CPoint
00019
00020 STDMETHODIMP CPoint::IMyPersistStreamImpl_Load(LPSTREAM pIStream)
00021 {
00022     ULONG           cb;
00023     HRESULT         hr;
00024
00025     if (NULL==pIStream)
00026         return ResultFromScode(E_POINTER);
00027     //
00028     // Read an object from the stream.
00029     //
00030     hr=pIStream->Read(&m_Point, sizeof(POINT), &cb);
00031     if (FAILED(hr))
00032         return hr;
00033     if (sizeof(POINT) != cb)
00034         return E_FAIL;
00035
00036   return NOERROR;
00037 }
00038
00039
00040
00041 STDMETHODIMP CPoint::IMyPersistStreamImpl_Save(LPSTREAM pIStream, BOOL /*fClearDirty */)
00042 {
00043     ULONG           cb;
00044     HRESULT         hr;
00045
00046     if (NULL==pIStream)
00047         return ResultFromScode(E_POINTER);
00048
00049     //
00050     // Write the object into the stream.
00051     //
00052     hr=pIStream->Write(&m_Point, (ULONG)sizeof(POINT), &cb);
00053
00054     if (FAILED(hr) || sizeof(POINT)!=cb)
00055        return ResultFromScode(STG_E_WRITEFAULT);
00056
00057   return NOERROR;
00058 }
00059
00060
00061 STDMETHODIMP CPoint::IMyPersistStreamImpl_GetSizeMax(ULARGE_INTEGER FAR* pcbSize)
00062 {
00063   pcbSize->LowPart = (DWORD)(sizeof(POINT));
00064   pcbSize->HighPart = 0L;
00065   return NOERROR;
00066 }
00067
00068
00069 STDMETHODIMP CPoint::get_x(long * pVal)
00070 {
00071   *pVal = m_Point.x;
00072   return S_OK;
00073 }
00074
00075 STDMETHODIMP CPoint::put_x(long newVal)
00076 {
00077   m_Point.x = newVal;
00078   return S_OK;
00079 }
00080
00081 STDMETHODIMP CPoint::get_y(long * pVal)
00082 {
00083   *pVal = m_Point.y;
00084   return S_OK;
00085 }
00086
00087 STDMETHODIMP CPoint::put_y(long newVal)
00088 {
00089   m_Point.y = newVal;
00090   return S_OK;
00091 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Bcast/Bcast.c Source File

  • NetDS
  • WinSock
  • Bcast

Bcast.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1996 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \******************************************************************************/
00010
00011 /*
00012 Module Name:
00013
00014     bcast.c
00015
00016 Abstract:
00017
00018     This module illustrates the Win32 Winsock and Mailslot APIs to do a generic
00019     broadcast over IPX, UDP and Mailslot protocols.
00020
00021     This example implements a client and a server. The example has a number of
00022     command line options. For example,
00023
00024     -s To run the example as a server(default role).
00025
00026     -c To run the example as a client.
00027
00028     -p <i or m or u> To specify the protocol to be used.
00029      i - IPX.
00030      m - Mailslots.
00031      u - UDP(default protocol).
00032
00033     -e <Endpoint> To specify an end point of your choice. This is a mandatory
00034     parameter. Servers create this endpoint and read broadcast messages. An
00035     endpoint in case Mailslot protocol is a Mailslot name.(default is 5005).
00036
00037     -d <DomainName> - To specify a domain name or a workgroup name. This is
00038     useful for Mailslot clients, only.
00039
00040     To run the application as a server, the following command lines can be
00041     specified:
00042
00043     bcast -s -e 8000 -p u
00044     bcast -s -e 8000 -p i
00045     bcast -s -e MAILSLOT1 -p m
00046
00047     To run the application as a client, the following command lines can be
00048     specified:
00049
00050     bcast -c -e 8000 -p u
00051     bcast -c -e 8000 -p i
00052     bcast -c -e MAILSLOT1 -p m -d DOMAIN1
00053     bcast -c -e MAILSLOT1 -p m -d WORKGROUP1
00054
00055 Author:
00056
00057     Rajesh Dadhia (rajeshd) 02-Mar-96
00058
00059 Revision History:
00060
00061     Stephen R. Husak 06-Dec-99    fix for empty commandline
00062 */
00063
00064 #pragma warning (disable:4127)
00065
00066 #include <stdlib.h>
00067 #include <stdio.h>
00068 #include <time.h>
00069 #include <windows.h>
00070 #include <strsafe.h>
00071 #include <winsock.h>
00072 #include <wsipx.h>
00073 #include <wsnwlink.h>
00074
00075
00076
00077 #define MAX_MSGLEN 80
00078 #define MAX_ADDLEN 80
00079 #define MAX_MSLOTNAME 80
00080
00081 typedef enum _MODE
00082 {
00083     CLIENT=0, SERVER
00084 } MODE;
00085 typedef enum _PROTOCOL
00086 {
00087     UDP=0, IPX, MAILSLOT
00088 } PROTOCOL;
00089
00090 BOOL __stdcall
00091 CtrlCHandler (
00092              DWORD dwEvent
00093              );
00094
00095 void __stdcall
00096 DoMailSlot (
00097            MODE mRole,
00098            LPSTR lpsEndPoint,
00099            LPSTR lpsDomainName
00100            );
00101
00102 void __stdcall
00103 DoIpx (
00104       MODE mRole,
00105       USHORT usEndPoint
00106       );
00107
00108 void __stdcall
00109 DoUdp (
00110       MODE mRole,
00111       USHORT usEndPoint
00112       );
00113
00114 void __stdcall
00115 DoMailSlotServer (
00116                  LPSTR lpsEndPoint
00117                  );
00118
00119 void __stdcall
00120 DoMailSlotClient (
00121                  LPSTR lpsEndPoint,
00122                  LPSTR lpsDomainName
00123                  );
00124
00125 void __stdcall
00126 DoUdpServer (
00127             USHORT usEndPoint
00128             );
00129
00130 void __stdcall
00131 DoUdpClient (
00132             USHORT usEndPoint
00133             );
00134
00135 void __stdcall
00136 DoIpxServer (
00137             USHORT usEndPoint
00138             );
00139
00140 void __stdcall
00141 DoIpxClient (
00142             USHORT usEndPoint
00143             );
00144
00145 void __stdcall
00146 Usage (
00147       CHAR *pszProgramName
00148       );
00149
00150 void __stdcall
00151 PrintError (
00152            LPSTR lpszRoutine,
00153            LPSTR lpszCallName,
00154            DWORD dwError
00155            );
00156
00157 CHAR * __stdcall
00158 IpxnetAddr (
00159            CHAR *lpBuffer,
00160            CHAR *lpsNetnum,
00161            CHAR *lpsNodenum
00162            );
00163
00164 void __stdcall
00165 DoStartup ( void );
00166
00167 void __stdcall
00168 DoCleanup ( void );
00169
00170 //
00171 // Global Variables
00172 //
00173
00174 // If Startup was successful, fStarted is used to keep track.
00175 BOOL fStarted = FALSE;
00176
00177 // Global socket descriptor
00178 SOCKET sock = INVALID_SOCKET;
00179
00180 //GLobal Mail Slot handle for server and client
00181 HANDLE hSlot = INVALID_HANDLE_VALUE;
00182
00183 void __cdecl
00184 main (
00185      INT argc,
00186      CHAR **argv
00187      )
00188 {
00189
00190     // Default role of the application is SERVER, which means receiver of
00191     // the broadcast messages.
00192     MODE mRole = SERVER;
00193
00194     // Deafult protocol used is UDP.
00195     PROTOCOL pProto = UDP;
00196
00197     // Default Endpoint.
00198     USHORT usEndPoint = 5005;
00199
00200     // Strings pointing to Endpoint and DomainName(necessary for Mailslots).
00201     LPSTR lpsEndPoint = NULL, lpsDomainName = NULL;
00202     INT  i = 0;
00203     CHAR chProto = '\0';
00204
00205     //
00206     // Install the CTRL+BREAK Handler
00207     //
00208     if ( FALSE == SetConsoleCtrlHandler ( (PHANDLER_ROUTINE) CtrlCHandler,
00209                                           TRUE
00210                                         ) )
00211     {
00212         PrintError ( "main", "SetConsoleCtrlHandler", GetLastError ( ) );
00213     }
00214
00215     //
00216     // allow the user to override settings with command line switches
00217     //
00218     for ( i = 1; i < argc; i++ )
00219     {
00220         if ( ( *argv[i] == '-' ) || ( *argv[i] == '/' ) )
00221         {
00222             switch ( tolower ( *( argv[i]+1 ) ) )
00223             {
00224             //
00225             // Role of the application (Client - Sender of broadcasts).
00226             //
00227             case 'c':
00228                 mRole = CLIENT;
00229                 break;
00230
00231                 //
00232                 // Role of the application (Server - Receiver of broadcasts)
00233                 //
00234             case 's':
00235                 mRole = SERVER;
00236                 break;
00237
00238                 //
00239                 // Network protocol (Mailslots, IPX or UDP).
00240                 //
00241             case 'p':
00242                 chProto = (char)tolower ( *argv[++i] );
00243                 if ( 'm' == (char)chProto )
00244                 {
00245                     pProto = MAILSLOT;
00246                 } else if ( 'i' == chProto )
00247                 {
00248                     pProto = IPX;
00249                 } else
00250                     pProto = UDP;
00251                 break;
00252
00253                 //
00254                 // EndPoint.
00255                 //
00256             case 'e':
00257                 lpsEndPoint = argv[++i];
00258                 break;
00259
00260                 //
00261                 // DomainName (Important for Mailslot broadcasts, only).
00262                 //
00263             case 'd':
00264                 lpsDomainName = argv[++i];
00265                 break;
00266
00267                 //
00268                 // Help.
00269                 //
00270             case 'h':
00271             case '?':
00272             default:
00273                 Usage ( argv[0] );
00274             }
00275         } else
00276             //
00277             // Help.
00278             //
00279             Usage ( argv[0] );
00280     }
00281
00282     //
00283     // If the protocol specified is not MAILSLOT, convert the endpoint
00284     // information to integer format from the string format.
00285     //
00286     if ( MAILSLOT != pProto )
00287     {
00288         if (lpsEndPoint != NULL)
00289             usEndPoint = (USHORT)atoi ( lpsEndPoint );
00290     }
00291
00292     //
00293     // Print a Summary of the switches specfied
00294     // Helpful for debugging
00295     //
00296     fprintf ( stdout, "SUMMARY:\n" );
00297     fprintf ( stdout, "\tRole-> %s\n", (CLIENT == mRole)?"Client":"Server" );
00298     fprintf ( stdout, "\tProtocol-> %s\n",
00299               ( MAILSLOT == pProto ) ? "MAILSLOT" :
00300               ( IPX == pProto ) ? "IPX" : "UDP" );
00301     if (lpsEndPoint != NULL)
00302         fprintf ( stdout, "\tEndpoint-> %s\n", lpsEndPoint );
00303     else
00304         fprintf ( stdout, "\tEndPoint-> %d\n", usEndPoint );
00305
00306     //
00307     // Check the protocol specified.
00308     // Call the appropriate handler rouine. By default the protocol
00309     // is UDP.
00310     //
00311     switch ( pProto )
00312     {
00313     case MAILSLOT :
00314         DoMailSlot ( mRole, lpsEndPoint, lpsDomainName );
00315         break;
00316
00317     case IPX:
00318         DoStartup ( );
00319         DoIpx ( mRole, usEndPoint );
00320         break;
00321
00322     default:
00323         DoStartup ( );
00324         DoUdp ( mRole, usEndPoint );
00325         break;
00326     }
00327
00328     return;
00329 }
00330
00331 //
00332 // CtrlCHandler () intercepts the CTRL+BREAK or CTRL+C events and calls the
00333 // cleanup routines.
00334 //
00335 BOOL __stdcall
00336 CtrlCHandler (
00337              DWORD dwEvent
00338              )
00339 {
00340     if ( ( CTRL_C_EVENT == dwEvent ) || ( CTRL_BREAK_EVENT == dwEvent ) )
00341     {
00342         DoCleanup ( );
00343     }
00344
00345     return FALSE;
00346 }
00347
00348 //
00349 // DoMailSlot () function calls appropriate handler function (client/server),
00350 // if protocol=MAILSLOT is specified. By default, the role of the application
00351 // is - SERVER.
00352 //
00353 void __stdcall
00354 DoMailSlot (
00355            MODE mRole,
00356            LPSTR lpsEndPoint,
00357            LPSTR lpsDomainName
00358            )
00359 {
00360     switch ( mRole )
00361     {
00362     case CLIENT:
00363         DoMailSlotClient ( lpsEndPoint, lpsDomainName );
00364         break;
00365
00366     default:
00367         DoMailSlotServer ( lpsEndPoint );
00368     }
00369     return;
00370 }
00371
00372 //
00373 // DoIpx () function calls appropriate handler function (client/server),
00374 // if protocol=IPX  is specified. By default, the role of the application
00375 // is - SERVER.
00376 //
00377 void __stdcall
00378 DoIpx (
00379       MODE mRole,
00380       USHORT usEndPoint
00381       )
00382 {
00383     //
00384     // Initialize the global socket descriptor.
00385     //
00386     sock = socket ( AF_IPX, SOCK_DGRAM, NSPROTO_IPX );
00387
00388     if ( INVALID_SOCKET ==  sock )
00389     {
00390         PrintError( "DoIpx", "socket", WSAGetLastError ( ) );
00391     }
00392
00393     switch ( mRole )
00394     {
00395     case CLIENT:
00396         DoIpxClient ( usEndPoint );
00397         break;
00398
00399     default:
00400         DoIpxServer ( usEndPoint );
00401     }
00402     return;
00403 }
00404
00405
00406 //
00407 // DoUdp () function calls appropriate handler function (client/server),
00408 // if protocol=UDP  is specified. By default, the role of the application
00409 // is - SERVER.
00410 //
00411 void __stdcall
00412 DoUdp (
00413       MODE mRole,
00414       USHORT usEndPoint
00415       )
00416 {
00417     //
00418     // Initialize the global socket descriptor.
00419     //
00420     sock = socket ( AF_INET, SOCK_DGRAM, 0 );
00421
00422     if ( INVALID_SOCKET ==  sock)
00423     {
00424         PrintError ( "DoUdp", "socket", WSAGetLastError() );
00425     }
00426
00427     switch ( mRole )
00428     {
00429     case CLIENT:
00430         DoUdpClient ( usEndPoint );
00431         break;
00432
00433     default:
00434         DoUdpServer ( usEndPoint );
00435     }
00436     return;
00437 }
00438
00439 //
00440 // DoMailSlotServer () function receives a mailslot message on a particular
00441 // mailslot. The function creates a mailslot, posts a ReadFile () to receive
00442 // the message. The function then checks the first four bytes of the message
00443 // for the message ID, and discards all the messages with same ID, in future.
00444 //
00445 void __stdcall
00446 DoMailSlotServer (
00447                  LPSTR lpsEndPoint
00448                  )
00449 {
00450
00451
00452     // Variables that store MessageID, previous messageID, number of bytes to
00453     // read/read, size of next available message and the number of messages.
00454     DWORD dwMessageID = 0,
00455     dwPrevID = 0,
00456     cbMessage = 0,
00457     cbRead = 0,
00458     cbToRead = 0,
00459     nMessages  = 0;
00460     HRESULT hRet;
00461     size_t dwSize;
00462
00463     BOOL fResult = FALSE;
00464
00465     CHAR achMailSlotName[MAX_MSLOTNAME],
00466     achBuffer[MAX_MSGLEN + sizeof ( DWORD )];
00467
00468     // Variable that points past the message ID part in the message.
00469     LPSTR lpsMessage = NULL;
00470
00471     //
00472     // Create a string for the mailslot name.
00473     //
00474
00475     if(FAILED(hRet = StringCchPrintf(achMailSlotName, MAX_MSLOTNAME, "\\\\.\\mailslot\\%s", lpsEndPoint)))
00476     {
00477         PrintError("DoMailSlotServer","StringCchPrintf",hRet);
00478     }
00479
00480
00481     //
00482     // Create the mailslot.
00483     //
00484     hSlot = CreateMailslot ( achMailSlotName,
00485                              0,
00486                              MAILSLOT_WAIT_FOREVER,
00487                              (LPSECURITY_ATTRIBUTES) NULL
00488                            );
00489
00490     if ( INVALID_HANDLE_VALUE == hSlot )
00491     {
00492         PrintError ( "DoMailSlotServer",  "CreateMailSlot", GetLastError() );
00493     }
00494
00495     //
00496     // Post ReadFile() and read a message.
00497     //
00498     cbToRead = MAX_MSGLEN + sizeof (DWORD);
00499
00500     fResult = ReadFile ( hSlot,
00501                          achBuffer,
00502                          cbToRead,
00503                          &cbRead,
00504                          (LPOVERLAPPED) NULL
00505                        );
00506
00507     if ( TRUE != fResult )
00508     {
00509         PrintError ( "DoMailSlotServer", "ReadFile", GetLastError() );
00510     }
00511
00512     achBuffer[cbRead] = '\0';
00513
00514     //
00515     // Get the message ID part from the message.
00516     //
00517
00518     memcpy ( &dwMessageID, achBuffer, sizeof ( DWORD ) );
00519
00520     //
00521     // Adjust the actual message pointer.
00522     //
00523     lpsMessage = achBuffer + sizeof ( DWORD );
00524
00525     hRet = StringCbLength(lpsMessage,cbRead,&dwSize);
00526
00527     //
00528     // Print the message
00529     //
00530     fprintf ( stdout,
00531               "A MailSlot Message of %d bytes received with ID %d\n",
00532               dwSize,
00533               dwMessageID
00534             );
00535
00536     fprintf ( stdout, "MessageText->%s\n", lpsMessage );
00537
00538     //
00539     // Check for duplicate messages.
00540     //
00541     dwPrevID = dwMessageID;
00542
00543     while ( TRUE )
00544     {
00545         //
00546         // get information on pending messages.
00547         //
00548         fResult = GetMailslotInfo ( hSlot,
00549                                     (LPDWORD) NULL,
00550                                     &cbMessage,
00551                                     &nMessages,
00552                                     (LPDWORD) NULL
00553                                   );
00554         if ( TRUE != fResult )
00555         {
00556             PrintError ( "DoMailSlotServer",
00557                          "GetMailSlotInfo",
00558                          GetLastError ( )
00559                        );
00560         }
00561
00562         //
00563         // Break if no more messages.
00564         //
00565         if ( MAILSLOT_NO_MESSAGE == cbMessage )
00566             break;
00567
00568         //
00569         // We now know how much to read.
00570         //
00571         cbToRead = cbMessage;
00572         fResult = ReadFile ( hSlot,
00573                              achBuffer,
00574                              cbToRead,
00575                              &cbRead,
00576                              (LPOVERLAPPED) NULL
00577                            );
00578
00579         if ( TRUE != fResult )
00580         {
00581             PrintError ( "DoMailSlotServer",
00582                          "ReadFile",
00583                          GetLastError ( )
00584                        );
00585         }
00586
00587         achBuffer[cbRead] = '\0';
00588         memcpy ( &dwMessageID, achBuffer, sizeof (DWORD) );
00589
00590         //
00591         // print the message only if it is not a duplicate.
00592         //
00593         lpsMessage = achBuffer + sizeof (DWORD);
00594         hRet = StringCbLength(lpsMessage,cbRead,&dwSize);
00595         if ( dwMessageID != dwPrevID )
00596         {
00597
00598
00599             fprintf ( stdout,
00600                       "A MailSlot Message of %d bytes received with ID %d\n",
00601                       dwSize,
00602                       dwMessageID
00603                     );
00604
00605             fprintf ( stdout, "MessageText->%s\n", achBuffer );
00606         }
00607
00608         dwPrevID = dwMessageID;
00609     }
00610
00611     //
00612     // Close the handle to our mailslot.
00613     //
00614     fResult = CloseHandle ( hSlot );
00615
00616     if ( TRUE != fResult )
00617     {
00618         PrintError ( "DoMailSlotServer", "CloseHandle", GetLastError() );
00619     }
00620     return;
00621 }
00622
00623 //
00624 // DoMailSlotClient () function implements the broadcast routine for a
00625 // Mailslot client. The function opens handle to the mailslot using
00626 // CreateFile (). CreateFile will fail on Windows NT for local mailslots,
00627 // if the mailslot is not already created using CreateMailSlot () API.
00628 //
00629 // The function appends a message number to the message which the server uses
00630 // to discard duplicate messages. In the event of a client runnig on a system
00631 // with multiple transport protocols loaded, a mailsot message is sent over
00632 // each protocol.
00633 //
00634 // This routine broadcasts a mailslot message to everyone on a Windows NT
00635 // domain, it can also be used to send a mailslot message to a particular
00636 // host or a workgroup.
00637 //
00638 void __stdcall
00639 DoMailSlotClient (
00640                  LPSTR lpsEndPoint,
00641                  LPSTR lpsDomainName
00642                  )
00643 {
00644     // Variables that store MessageID, number of bytes to write/written.
00645     DWORD dwMessageID = 0,
00646     cbWritten = 0,
00647     cbToWrite = 0;
00648     HRESULT hRet;
00649
00650     BOOL fResult = FALSE;
00651
00652     CHAR achMailSlotName[MAX_MSLOTNAME],
00653     achBuffer[MAX_MSGLEN + sizeof ( DWORD ) ];
00654
00655     if ( NULL == lpsDomainName )
00656     {
00657         fprintf ( stdout,
00658                   "Domain/Workgroup name must be specified....Exiting\n"
00659                 );
00660         exit ( 1 );
00661     }
00662
00663     //
00664     // Create a string for the mailslot name.
00665     //
00666
00667
00668     if(FAILED(hRet = StringCchPrintf(achMailSlotName,
00669                            MAX_MSLOTNAME,
00670                            "\\\\%s\\mailslot\\%s",
00671                            lpsDomainName,
00672                            lpsEndPoint
00673                           )))
00674     {
00675         PrintError("DoMailSlotClient","StringCchPrintf",hRet);
00676     }
00677
00678
00679     //
00680     // Open a handle to the mailslot.
00681     //
00682     hSlot = CreateFile ( achMailSlotName,
00683                          GENERIC_WRITE,
00684                          FILE_SHARE_READ,
00685                          (LPSECURITY_ATTRIBUTES) NULL,
00686                          OPEN_EXISTING,
00687                          FILE_ATTRIBUTE_NORMAL,
00688                          (HANDLE) NULL
00689                        );
00690
00691     if ( INVALID_HANDLE_VALUE == hSlot)
00692     {
00693         PrintError ( "DoMailSlotClient", "CreateFile", GetLastError ( ) );
00694     }
00695
00696     //
00697     // Generate a Message ID.
00698     //
00699     srand ( (UINT) time ( NULL) );
00700     dwMessageID = rand ( );
00701
00702     if(FAILED(hRet = StringCbPrintf(achBuffer,sizeof(DWORD),"%d",dwMessageID)))
00703     {
00704         PrintError("DoMailSlotClient","StringCchPrintf",hRet);
00705     }
00706
00707     if(FAILED(hRet = StringCchCopy(achBuffer + sizeof(DWORD),MAX_MSGLEN,"A MailSlot Broadcast Message")))
00708     {
00709         PrintError("DoMailSlotClient","StringCchCopy",hRet);
00710     }
00711
00712     //
00713     // Total number of bytes to write.
00714     //
00715     cbToWrite = sizeof ( DWORD ) + (int) ( strlen ( achBuffer + sizeof ( DWORD ) ) );
00716
00717     //
00718     // Send a mailslot message.
00719     //
00720     fResult = WriteFile ( hSlot,
00721                           achBuffer,
00722                           cbToWrite,
00723                           &cbWritten,
00724                           (LPOVERLAPPED) NULL
00725                         );
00726
00727     if ( TRUE != fResult )
00728     {
00729         PrintError ( "DoMailSlotClient", "WriteFile", GetLastError ( ) );
00730     }
00731
00732     fprintf ( stdout,
00733               "%d bytes of MailSlot data broadcasted with ID %d\n",
00734               cbWritten,
00735               dwMessageID
00736             );
00737
00738     //
00739     // Close the mailslot handle.
00740     //
00741     fResult = CloseHandle ( hSlot );
00742
00743     if ( TRUE != fResult )
00744     {
00745         PrintError ( "DoMailSlotClient", "CloseHandle", GetLastError() );
00746     }
00747     return;
00748 }
00749
00750 //
00751 // DoUdpServer () function receives the broadcast on a specified port. The
00752 // server will have to post a recv (), before the client sends the broadcast.
00753 //
00754 void __stdcall
00755 DoUdpServer (
00756             USHORT usEndPoint
00757             )
00758 {
00759
00760     // IP address structures needed to bind to a local port and get the sender's
00761     // information.
00762     SOCKADDR_IN saUdpServ = {0}, saUdpCli = {0};
00763
00764     INT err = 0, nSize = 0;
00765
00766     CHAR achBuffer[MAX_MSGLEN] = {'\0'};
00767
00768     //
00769     // bind to the specified port.
00770     //
00771     saUdpServ.sin_family = AF_INET;
00772     saUdpServ.sin_addr.s_addr = htonl ( INADDR_ANY );
00773     saUdpServ.sin_port = htons ( usEndPoint );
00774
00775     err = bind ( sock, (SOCKADDR FAR *)&saUdpServ, sizeof ( SOCKADDR_IN ) );
00776
00777     if ( SOCKET_ERROR == err )
00778     {
00779         PrintError ( "DoUdpServer", "bind", WSAGetLastError ( ) );
00780     }
00781
00782     //
00783     // receive a datagram on the bound port number.
00784     //
00785     nSize = sizeof ( SOCKADDR_IN );
00786     err = recvfrom ( sock,
00787                      achBuffer,
00788                      MAX_MSGLEN,
00789                      0,
00790                      (SOCKADDR FAR *) &saUdpCli,
00791                      &nSize
00792                    );
00793
00794     if ( SOCKET_ERROR == err )
00795     {
00796         PrintError ( "DoUdpServer", "recvfrom", WSAGetLastError ( ) );
00797     }
00798
00799     //
00800     // print the sender's information.
00801     //
00802     achBuffer[err] = '\0';
00803     fprintf ( stdout, "A Udp Datagram of length %d bytes received from ", err );
00804     fprintf ( stdout, "\n\tIP Adress->%s ", inet_ntoa ( saUdpCli.sin_addr ) );
00805     fprintf ( stdout, "\n\tPort Number->%d\n", ntohs ( saUdpCli.sin_port ) );
00806     fprintf ( stdout, "MessageText->%s\n", achBuffer );
00807
00808     //
00809     // Call the cleanup routine
00810     //
00811     DoCleanup ( );
00812
00813     return;
00814 }
00815
00816 //
00817 // DoUdpClient () function implements the broadcast routine for an UDP
00818 // client. The function sets the SO_BROADCAST option with the global socket.
00819 // Calling this API is important. After binding to a local port, it sends an
00820 // UDP boradcasts to the IP address INADDR_BROADCAST, with a particular
00821 // port number.
00822 //
00823 void __stdcall
00824 DoUdpClient (
00825             USHORT usEndPoint
00826             )
00827 {
00828
00829     // IP address structures needed to fill the source and destination
00830     // addresses.
00831     SOCKADDR_IN saUdpServ = {0}, saUdpCli = {0};
00832     INT err = 0;
00833     CHAR achMessage[MAX_MSGLEN] = {'\0'};
00834     HRESULT hRet;
00835     size_t dwSize;
00836
00837     // Variable to set the broadcast option with setsockopt ().
00838     BOOL fBroadcast = TRUE;
00839
00840
00841     err = setsockopt ( sock,
00842                        SOL_SOCKET,
00843                        SO_BROADCAST,
00844                        (CHAR *) &fBroadcast,
00845                        sizeof ( BOOL )
00846                      );
00847
00848     if ( SOCKET_ERROR == err )
00849     {
00850         PrintError ( "DoUdpClient", "setsockopt", WSAGetLastError ( )  );
00851     }
00852
00853     //
00854     // bind to a local socket and an interface.
00855     //
00856     saUdpCli.sin_family = AF_INET;
00857     saUdpCli.sin_addr.s_addr = htonl ( INADDR_ANY );
00858     saUdpCli.sin_port = htons ( 0 );
00859
00860     err = bind ( sock, (SOCKADDR *) &saUdpCli, sizeof (SOCKADDR_IN) );
00861
00862     if ( SOCKET_ERROR == err )
00863     {
00864         PrintError ( "DoUdpClient", "bind", WSAGetLastError ( ) );
00865     }
00866
00867     //
00868     // Fill an IP address structure, to send an IP broadcast. The
00869     // packet will be broadcasted to the specified port.
00870     //
00871     saUdpServ.sin_family = AF_INET;
00872     saUdpServ.sin_addr.s_addr = htonl ( INADDR_BROADCAST );
00873     saUdpServ.sin_port = htons ( usEndPoint );
00874
00875
00876
00877     if(FAILED(hRet = StringCchCopy(achMessage,MAX_MSGLEN,"A Broadcast Datagram")))
00878     {
00879         PrintError("DoUdpClient","StringCchCopy",hRet);
00880     }
00881
00882     if(FAILED(hRet = StringCbLength(achMessage,MAX_MSGLEN,&dwSize)))
00883     {
00884         PrintError("DoUdpClient","StringCbLength",hRet);
00885     }
00886
00887     err = sendto ( sock,
00888                    achMessage,
00889                    (int)dwSize,
00890                    0,
00891                    (SOCKADDR *) &saUdpServ,
00892                    (int)sizeof ( SOCKADDR_IN )
00893                  );
00894
00895     if ( SOCKET_ERROR == err )
00896     {
00897         PrintError ( "DoUdpClient", "sendto", WSAGetLastError ( ) );
00898     }
00899
00900     fprintf ( stdout, "%d bytes of data broadcasted\n", err );
00901
00902     //
00903     // Call the cleanup routine.
00904     //
00905     DoCleanup ( );
00906
00907     return;
00908 }
00909
00910
00911 //
00912 // DoIpxServer () function receives the broadcast on a specified socket. The
00913 // server will have to post a recv (), before the client sends the broadcast.
00914 // It is necessary call setsockopt () with SO_BROADCAST flag set, in order to
00915 // receive IPX broadcasts on Windows 95.
00916 //
00917 void __stdcall
00918 DoIpxServer (
00919             USHORT usEndPoint
00920             )
00921 {
00922
00923     // IPX address structures needed to bind to a local socket and get the
00924     // sender's information.
00925     SOCKADDR_IPX saIpxServ = {0}, saIpxCli = {0};
00926
00927     INT err = 0, nSize = 0;
00928
00929     CHAR achBuffer[MAX_MSGLEN] = {'\0'},
00930     achAddress[MAX_ADDLEN] = {'\0'};
00931
00932     OSVERSIONINFO osVer = {0};
00933
00934     // Variable to set the broadcast option with setsockopt ().
00935     BOOL fResult = FALSE, fBroadcast = TRUE;
00936
00937     //
00938     // Check the platform.
00939     //
00940     osVer.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO );
00941     fResult  = GetVersionEx ( &osVer);
00942
00943     if ( FALSE == fResult)
00944     {
00945         PrintError ( "DoIpxServer", "GetVersionEx", GetLastError ( ) );
00946     }
00947
00948     //
00949     // If the platform is Windows 95, call setsockopt ().
00950     //
00951     if ( VER_PLATFORM_WIN32_WINDOWS == osVer.dwPlatformId )
00952     {
00953         err = setsockopt ( sock,
00954                            SOL_SOCKET,
00955                            SO_BROADCAST,
00956                            (CHAR *) &fBroadcast,
00957                            sizeof ( BOOL )
00958                          );
00959
00960         if ( SOCKET_ERROR == err )
00961         {
00962             PrintError ( "DoIpxServer", "setsockopt", WSAGetLastError() );
00963         }
00964     }
00965
00966     //
00967     // bind to the specified socket.
00968     //
00969     saIpxServ.sa_family = AF_IPX;
00970     saIpxServ.sa_socket = usEndPoint;
00971     memset ( saIpxServ.sa_netnum, 0, sizeof (saIpxServ.sa_netnum ) );
00972     memset ( saIpxServ.sa_nodenum, 0, sizeof (saIpxServ.sa_nodenum ) );
00973
00974     err = bind ( sock, (SOCKADDR *) &saIpxServ, sizeof (SOCKADDR_IPX) );
00975
00976     if ( SOCKET_ERROR == err )
00977     {
00978         PrintError ( "DoIpxServer", "bind", WSAGetLastError ( ) );
00979     }
00980
00981     //
00982     // receive a datagram on the bound socket number.
00983     //
00984     nSize = sizeof ( SOCKADDR_IPX );
00985     err = recvfrom ( sock,
00986                      achBuffer,
00987                      MAX_MSGLEN,
00988                      0,
00989                      (SOCKADDR *) &saIpxCli,
00990                      &nSize
00991                    );
00992
00993     if ( SOCKET_ERROR == err )
00994     {
00995         PrintError ( "DoIpxServer", "recvfrom", WSAGetLastError ( ) );
00996     }
00997
00998     //
00999     // print the sender's information.
01000     //
01001     achBuffer[err] = '\0';
01002     fprintf ( stdout,
01003               "An Ipx Datagram of length %d bytes received from ",
01004               err );
01005     fprintf ( stdout,
01006               "\n\tIPX Adress->%s ",
01007               IpxnetAddr ( achAddress,
01008                            saIpxCli.sa_netnum,
01009                            saIpxCli.sa_nodenum
01010                          )
01011             );
01012     fprintf ( stdout, "\n\tSocket Number->%d\n", saIpxCli.sa_socket );
01013     fprintf ( stdout, "MessageText->%s\n", achBuffer );
01014
01015     //
01016     // Call the cleanup routine.
01017     //
01018     DoCleanup ( );
01019     return;
01020
01021 }
01022
01023 //
01024 // DoIpxClient () function implements the broadcast routine for a an IPX
01025 // client. The fucntion sets the SO_BROADCAST option with the gloabal socket.
01026 // Calling this API is important. After binding to a local port, it sends an IPX
01027 // packet to the address with node number as all 1's and net number as all 0's,
01028 // with a particuler socket number.
01029 //
01030 void __stdcall
01031 DoIpxClient (
01032             USHORT usEndPoint
01033             )
01034 {
01035
01036     // IPX address structures needed to fill the source and destination
01037     // addresses.
01038     SOCKADDR_IPX saIpxServ = {0}, saIpxCli = {0};
01039     INT err = 0;
01040     CHAR achMessage[MAX_MSGLEN] = {'\0'};
01041     HRESULT hRet;
01042     size_t dwSize;
01043
01044     // Variable to set the broadcast option with setsockopt ().
01045     BOOL fBroadcast = TRUE;
01046
01047     err = setsockopt ( sock,
01048                        SOL_SOCKET,
01049                        SO_BROADCAST,
01050                        (CHAR *) &fBroadcast,
01051                        sizeof ( BOOL )
01052                      );
01053
01054     if ( SOCKET_ERROR == err )
01055     {
01056         PrintError ( "DoIpxClient", "setsockopt", WSAGetLastError ( ) );
01057     }
01058
01059     //
01060     // bind to a local socket and an interface.
01061     //
01062     saIpxCli.sa_family = AF_IPX;
01063     saIpxCli.sa_socket = (USHORT) 0;
01064     memset ( saIpxCli.sa_netnum, 0, sizeof ( saIpxCli.sa_netnum ) );
01065     memset ( saIpxCli.sa_nodenum, 0, sizeof ( saIpxCli.sa_nodenum ) );
01066
01067     err = bind ( sock, (SOCKADDR  *) &saIpxCli, sizeof ( SOCKADDR_IPX ) );
01068
01069     if ( SOCKET_ERROR == err )
01070     {
01071         PrintError ( "DoIpxClient", "bind", WSAGetLastError() );
01072     }
01073
01074     //
01075     // Fill an IPX address structure, to send an IPX broadcast. The
01076     // packet will be broadcasted to the specified socket.
01077     //
01078     saIpxServ.sa_family = AF_IPX;
01079     saIpxServ.sa_socket = usEndPoint;
01080     memset ( saIpxServ.sa_netnum, 0, sizeof ( saIpxServ.sa_netnum ) );
01081     memset ( saIpxServ.sa_nodenum, 0xFF, sizeof ( saIpxServ.sa_nodenum ) );
01082
01083     if(FAILED(hRet = StringCchCopy(achMessage,MAX_MSGLEN,"A Broadcast Datagram")))
01084     {
01085         PrintError("DoIpxClient","StringCchCopy",hRet);
01086     }
01087
01088     if(FAILED(hRet = StringCbLength(achMessage,MAX_MSGLEN,&dwSize)))
01089     {
01090         PrintError("DoIpxClient","StringCbLength",hRet);
01091     }
01092
01093
01094     err = sendto ( sock,
01095                    achMessage,
01096                    (int)dwSize,
01097                    0,
01098                    (SOCKADDR *) &saIpxServ,
01099                    sizeof ( SOCKADDR_IPX )
01100                  );
01101
01102     if ( SOCKET_ERROR == err )
01103     {
01104         PrintError ( "DoIpxClient", "sendto", WSAGetLastError ( ) );
01105     }
01106
01107     fprintf ( stdout, "%d bytes of data broadcasted\n", err);
01108
01109     //
01110     // Call the cleanup routine.
01111     //
01112     DoCleanup ( );
01113
01114     return;
01115 }
01116
01117 //
01118 // Usage () lists the available command line options.
01119 //
01120 void __stdcall
01121 Usage (
01122       CHAR *pszProgramName
01123       )
01124 {
01125     fprintf ( stderr, "Usage:  %s\n", pszProgramName );
01126     fprintf ( stderr,
01127               "\t-s or -c (s - server, c - client, default - server)\n" );
01128     fprintf ( stderr,
01129               "\t-p <i or m or u> (i - IPX, m - Mailslots, u - UDP)\n" );
01130     fprintf ( stderr, "\t-e <Endpoint>\n" );
01131     fprintf ( stderr,
01132               "\t-d <DomainName> - needed only for a Mailslot client\n" );
01133     fprintf ( stderr,
01134               "\n\tDefault Values-> Role:Server, Protocol:UDP, EndPoint:5005\n" );
01135
01136     exit ( 1 );
01137 }
01138
01139
01140 //
01141 // PrintError () is a function available globally for printing the error and
01142 // doing the cleanup.
01143 //
01144 void __stdcall
01145 PrintError (
01146            LPSTR lpszRoutine,
01147            LPSTR lpszCallName,
01148            DWORD dwError
01149            )
01150 {
01151
01152     fprintf ( stderr,
01153               "The Call to %s() in routine() %s failed with error %d\n",
01154               lpszCallName,
01155               lpszRoutine,
01156               dwError
01157             );
01158
01159     DoCleanup ( );
01160
01161     exit ( 1 );
01162 }
01163
01164 //
01165 // IpxnetAddr () function converts an IPX address address in the binary form
01166 // to ascii format, it fills the input buffer with the address and returns a
01167 // pointer to it.
01168 //
01169 CHAR * __stdcall
01170 IpxnetAddr (
01171            CHAR *lpBuffer,
01172            CHAR *lpsNetnum,
01173            CHAR *lpsNodenum
01174            )
01175 {
01176
01177     HRESULT hRet;
01178
01179     if (NULL == lpBuffer)
01180         return NULL;
01181     if (NULL == lpsNetnum)
01182         return NULL;
01183     if (NULL == lpsNodenum)
01184         return NULL;
01185
01186
01187     if(FAILED(hRet = StringCchPrintf(lpBuffer,
01188                            MAX_MSGLEN,
01189                            "%02X%02X%02X%02X.%02X%02X%02X%02X%02X%02X",
01190                            (UCHAR) lpsNetnum[0], (UCHAR) lpsNetnum[1],
01191                            (UCHAR) lpsNetnum[2], (UCHAR) lpsNetnum[3],
01192                            (UCHAR) lpsNodenum[0], (UCHAR) lpsNodenum[1],
01193                            (UCHAR) lpsNodenum[2], (UCHAR) lpsNodenum[3],
01194                            (UCHAR) lpsNodenum[4], (USHORT) lpsNodenum[5]
01195                           )))
01196     {
01197         PrintError("IpxnetAddr","StringCchPrintf",hRet);
01198     }
01199
01200
01201
01202
01203     return( lpBuffer);
01204 }
01205
01206 //
01207 // DoStartup () initializes the Winsock DLL with Winsock version 1.1
01208 //
01209 void __stdcall
01210 DoStartup ( void )
01211 {
01212     WSADATA wsaData;
01213
01214     INT iRetVal = 0;
01215
01216     iRetVal = WSAStartup ( MAKEWORD ( 1,1 ), &wsaData );
01217
01218     if ( 0 != iRetVal)
01219     {
01220         PrintError ( "DoStartup", "WSAStartup", iRetVal );
01221     }
01222
01223     //
01224     // Set the global flag.
01225     //
01226     fStarted = TRUE;
01227
01228     return;
01229 }
01230
01231 //
01232 // DoCleanup () will close the global socket which was opened successfully by
01233 // a call to socket (). Additionally, it will call WSACleanup (), if a call
01234 // to WSAStartup () was made successfully.
01235 //
01236 void __stdcall
01237 DoCleanup ( void )
01238 {
01239     if ( INVALID_SOCKET != sock )
01240     {
01241         closesocket ( sock );
01242         sock = INVALID_SOCKET;
01243     }
01244
01245     if (INVALID_HANDLE_VALUE != hSlot)
01246     {
01247         CloseHandle(hSlot);
01248         hSlot = INVALID_HANDLE_VALUE;
01249     }
01250
01251     if ( TRUE == fStarted )
01252     {
01253         WSACleanup ( );
01254     }
01255
01256     fprintf ( stdout, "DONE\n" );
01257
01258     return;
01259 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/llistimpl.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

llistimpl.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //  This is a part of the MMC SDK.
00003 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  MMC SDK Reference and related
00008 //  electronic documentation provided with the library.
00009 //  See these sources for detailed information regarding the
00010 //  MMC Library product.
00011 //
00012 //  LListImple.h:  Definition and implementation of CLListImpl.  This is a
00013 //                 generic linked list class which emulates CList from MFC.
00014 //
00015
00016
00017 #ifndef __CLASS_CLLISTIMPL__
00018 #define __CLASS_CLLISTIMPL__
00019
00020 #if _MSC_VER > 1000
00021 #pragma once
00022 #endif // _MSC_VER > 1000
00023
00024 #include <CrtDbg.h>
00025 #include <Windows.h>
00026 #include <new.h>
00027
00028
00029 // Abstract iteration position
00030 struct  __POSITION { };
00031 typedef __POSITION*  POSITION;
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 //  CPlex stuff for allocating nodes
00035 //
00036
00037 //---------------------------------------------------------------------------
00038 struct CPlex     // warning variable length structure
00039 {
00040   CPlex* pNext;
00041 //#if (_AFX_PACKING >= 8)
00042   DWORD dwReserved[1];    // align on 8 byte boundary
00043 //#endif
00044
00045   // BYTE data[maxNum*elementSize];
00046
00047   void* data() { return this+1; }
00048
00049   static CPlex* PASCAL Create(CPlex*& head, UINT nMax, UINT cbElement);
00050       // like 'calloc' but no zero fill
00051       // may throw memory exceptions
00052
00053   void FreeDataChain();       // free this one and links
00054 };
00055
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 //  Helpers
00059 //
00060
00061 BOOL IsValidAddress( const void*  lp, UINT nBytes, BOOL bReadWrite = TRUE );
00062
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // CLListImpl<TYPE, ARG_TYPE>
00066
00067 template<class TYPE, class ARG_TYPE>
00068 class CLListImpl
00069 {
00070   public:
00071     CLListImpl( int nBlockSize = 10 );
00072     ~CLListImpl();
00073
00074   protected:
00075     struct CNode
00076     {
00077       CNode* pNext;
00078       CNode* pPrev;
00079       TYPE   data;
00080     };
00081
00082   public:
00083                                          // Attributes (head and tail)
00084    int       GetCount() const;
00085    BOOL      IsEmpty() const;
00086
00087    TYPE&     GetHead();                  // Peek at head and tail
00088    TYPE      GetHead() const;
00089    TYPE&     GetTail();
00090    TYPE      GetTail() const;
00091                                          // Operations
00092    TYPE      RemoveHead();
00093    TYPE      RemoveTail();
00094                                          // Add before head or after tail
00095    POSITION  AddHead( ARG_TYPE NewElement );
00096    POSITION  AddTail( ARG_TYPE NewElement );
00097
00098    void      AddHead(CLListImpl* pNewList);  // Add another list
00099    void      AddTail(CLListImpl* pNewList);
00100
00101    void      RemoveAll();                // Remove all elements
00102
00103    POSITION  GetHeadPosition() const;
00104    POSITION  GetTailPosition() const;
00105    TYPE&     GetNext(POSITION& rPosition);       // return *Position++
00106    TYPE      GetNext(POSITION& rPosition) const; // return *Position++
00107    TYPE&     GetPrev(POSITION& rPosition);       // return *Position--
00108    TYPE      GetPrev(POSITION& rPosition) const; // return *Position--
00109
00110    // Getting/modifying an element at a given position
00111    TYPE&     GetAt(POSITION Position);
00112    TYPE      GetAt(POSITION Position) const;
00113    void      SetAt(POSITION Pos, ARG_TYPE NewElement);
00114    void      RemoveAt(POSITION Position);
00115
00116    // inserting before or after a given position
00117    POSITION InsertBefore(POSITION position, ARG_TYPE newElement);
00118    POSITION InsertAfter(POSITION position, ARG_TYPE newElement);
00119
00120    // Helper functions (note: O(n) speed)
00121
00122    // Defaults to starting at the HEAD, return NULL if not found
00123    POSITION Find(ARG_TYPE SearchValue, POSITION StartAfter = NULL) const;
00124
00125    // Get the 'nIndex'th element (may return NULL)
00126    POSITION FindIndex(int nIndex) const;
00127
00128   // Implementation
00129   protected:
00130     CNode*   m_pNodeHead;
00131     CNode*   m_pNodeTail;
00132     int      m_nCount;
00133     CNode*   m_pNodeFree;
00134     struct   CPlex* m_pBlocks;
00135     int m_nBlockSize;
00136
00137     CNode*   NewNode(CNode*, CNode*);
00138     void     FreeNode(CNode*);
00139
00140 #ifdef _DEBUG
00141
00142   void AssertValid() const;
00143
00144 #endif //_DEBUG
00145
00146 }; //end class CLListImpl
00147
00148 /////////////////////////////////////////////////////////////////////////////
00149 // CLListImpl<TYPE, ARG_TYPE> inline functions
00150
00151 template<class TYPE, class ARG_TYPE>
00152 inline int CLListImpl<TYPE, ARG_TYPE>::GetCount() const
00153   { return m_nCount; }
00154
00155 template<class TYPE, class ARG_TYPE>
00156 inline BOOL CLListImpl<TYPE, ARG_TYPE>::IsEmpty() const
00157   { return m_nCount == 0; }
00158
00159 template<class TYPE, class ARG_TYPE>
00160 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetHead()
00161   {
00162     _ASSERT( NULL != m_pNodeHead );
00163     return m_pNodeHead->data;
00164   }
00165
00166 template<class TYPE, class ARG_TYPE>
00167 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetHead() const
00168   {
00169     _ASSERT( NULL != m_pNodeHead );
00170     return m_pNodeHead->data;
00171   }
00172
00173 template<class TYPE, class ARG_TYPE>
00174 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetTail()
00175   {
00176     _ASSERT( NULL != m_pNodeTail );
00177     return m_pNodeTail->data;
00178   }
00179
00180 template<class TYPE, class ARG_TYPE>
00181 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetTail() const
00182   {
00183     _ASSERT( NULL != m_pNodeTail );
00184     return m_pNodeTail->data;
00185   }
00186
00187 template<class TYPE, class ARG_TYPE>
00188 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetHeadPosition() const
00189   { return (POSITION)m_pNodeHead; }
00190
00191 template<class TYPE, class ARG_TYPE>
00192 inline POSITION CLListImpl<TYPE, ARG_TYPE>::GetTailPosition() const
00193   { return (POSITION)m_pNodeTail; }
00194
00195 template<class TYPE, class ARG_TYPE>
00196 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) // return *Position++
00197   {
00198     CNode* pNode = (CNode*) rPosition;
00199     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00200     rPosition = (POSITION) pNode->pNext;
00201     return pNode->data;
00202   }
00203
00204 template<class TYPE, class ARG_TYPE>
00205 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetNext(POSITION& rPosition) const // return *Position++
00206   {
00207     CNode* pNode = (CNode*) rPosition;
00208     _ASSERT(IsValidAddress(pNode, sizeof(CNode)));
00209     rPosition = (POSITION) pNode->pNext;
00210     return pNode->data;
00211   }
00212
00213 template<class TYPE, class ARG_TYPE>
00214 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) // return *Position--
00215   {
00216     CNode* pNode = (CNode*) rPosition;
00217     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00218     rPosition = (POSITION) pNode->pPrev;
00219     return pNode->data;
00220   }
00221
00222 template<class TYPE, class ARG_TYPE>
00223 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetPrev(POSITION& rPosition) const // return *Position--
00224   {
00225     CNode* pNode = (CNode*) rPosition;
00226     ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00227     rPosition = (POSITION) pNode->pPrev;
00228     return pNode->data;
00229   }
00230
00231 template<class TYPE, class ARG_TYPE>
00232 inline TYPE& CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position)
00233   {
00234     CNode* pNode = (CNode*)Position;
00235     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00236     return pNode->data;
00237   }
00238
00239 template<class TYPE, class ARG_TYPE>
00240 inline TYPE CLListImpl<TYPE, ARG_TYPE>::GetAt(POSITION Position) const
00241   {
00242     CNode* pNode = (CNode*) Position;
00243     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00244     return pNode->data;
00245   }
00246
00247 template<class TYPE, class ARG_TYPE>
00248 inline void CLListImpl<TYPE, ARG_TYPE>::SetAt(POSITION Pos, ARG_TYPE NewElement)
00249   {
00250     CNode* pNode = (CNode*)Pos;
00251     _ASSERT( IsValidAddress(pNode, sizeof(CNode)) );
00252     pNode->data = newElement;
00253   }
00254
00255
00256 template<class TYPE, class ARG_TYPE>
00257 CLListImpl<TYPE, ARG_TYPE>::CLListImpl( int nBlockSize )
00258 {
00259   _ASSERT( nBlockSize > 0 );
00260
00261   m_nCount     = 0;
00262   m_pNodeHead  = m_pNodeTail = m_pNodeFree = NULL;
00263   m_pBlocks    = NULL;
00264   m_nBlockSize = nBlockSize;
00265 }
00266
00267 template<class TYPE, class ARG_TYPE>
00268 void CLListImpl<TYPE, ARG_TYPE>::RemoveAll()
00269 {
00270   // destroy elements
00271   CNode* pNode;
00272   for( pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext )
00273     (pNode->data).~TYPE();
00274
00275   m_nCount = 0;
00276   m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL;
00277   m_pBlocks->FreeDataChain();
00278   m_pBlocks = NULL;
00279 }
00280
00281 template<class TYPE, class ARG_TYPE>
00282 CLListImpl<TYPE, ARG_TYPE>::~CLListImpl()
00283 {
00284   RemoveAll();
00285   _ASSERT(m_nCount == 0);
00286 }
00287
00288
00289 /////////////////////////////////////////////////////////////////////////////
00290 // Node helpers
00291 //
00292 //  Implementation note: CNode's are stored in CPlex blocks and
00293 //  chained together. Free blocks are maintained in a singly linked list
00294 //  using the 'pNext' member of CNode with 'm_pNodeFree' as the head.
00295 //  Used blocks are maintained in a doubly linked list using both 'pNext'
00296 //  and 'pPrev' as links and 'm_pNodeHead' and 'm_pNodeTail'
00297 //  as the head/tail.
00298 //
00299 //  We never free a CPlex block unless the List is destroyed or RemoveAll()
00300 //  is used - so the total number of CPlex blocks may grow large depending
00301 //  on the maximum past size of the list.
00302 //
00303
00304
00305 template<class TYPE, class ARG_TYPE>
00306 CLListImpl<TYPE, ARG_TYPE>::CNode*
00307 CLListImpl<TYPE, ARG_TYPE>::NewNode(CLListImpl::CNode* pPrev, CLListImpl::CNode* pNext)
00308 {
00309   if( NULL == m_pNodeFree )
00310   {
00311     // add another block
00312     CPlex* pNewBlock = CPlex::Create( m_pBlocks, m_nBlockSize, sizeof(CNode) );
00313
00314     // chain them into free list
00315     CNode* pNode = (CNode*) pNewBlock->data();
00316     // free in reverse order to make it easier to debug
00317     pNode += m_nBlockSize - 1;
00318     for( int i = m_nBlockSize-1; i >= 0; i--, pNode-- )
00319     {
00320       pNode->pNext = m_pNodeFree;
00321       m_pNodeFree = pNode;
00322     }
00323   }
00324   _ASSERT( NULL != m_pNodeFree );  // we must have something
00325
00326   CLListImpl::CNode* pNode = m_pNodeFree;
00327   m_pNodeFree = m_pNodeFree->pNext;
00328   pNode->pPrev = pPrev;
00329   pNode->pNext = pNext;
00330   m_nCount++;
00331   _ASSERT(m_nCount > 0);  // make sure we don't overflow
00332
00333   new (&pNode->data) TYPE; // Placement new
00334
00335   return pNode;
00336 }
00337
00338
00339 template<class TYPE, class ARG_TYPE>
00340 void CLListImpl<TYPE, ARG_TYPE>::FreeNode(CLListImpl::CNode* pNode)
00341 {
00342   (pNode->data).~TYPE();
00343   pNode->pNext = m_pNodeFree;
00344   m_pNodeFree = pNode;
00345   m_nCount--;
00346   _ASSERT(m_nCount >= 0);  // make sure we don't underflow
00347
00348   // if no more elements, cleanup completely
00349   if( 0 == m_nCount )
00350     RemoveAll();
00351 }
00352
00353 template<class TYPE, class ARG_TYPE>
00354 POSITION CLListImpl<TYPE, ARG_TYPE>::AddHead( ARG_TYPE NewElement )
00355 {
00356   _ASSERT( NULL != NewElement );
00357
00358   CNode* pNewNode = NewNode( NULL, m_pNodeHead );
00359   pNewNode->data = NewElement;
00360   if( NULL != m_pNodeHead )
00361     m_pNodeHead->pPrev = pNewNode;
00362   else
00363     m_pNodeTail = pNewNode;
00364
00365   m_pNodeHead = pNewNode;
00366   return (POSITION)pNewNode;
00367 }
00368
00369
00370 template<class TYPE, class ARG_TYPE>
00371 POSITION CLListImpl<TYPE, ARG_TYPE>::AddTail(ARG_TYPE NewElement)
00372 {
00373   _ASSERT( NULL != NewElement );
00374
00375   CNode* pNewNode = NewNode( m_pNodeTail, NULL );
00376   pNewNode->data = NewElement;
00377   if( NULL != m_pNodeTail )
00378     m_pNodeTail->pNext = pNewNode;
00379   else
00380     m_pNodeHead = pNewNode;
00381
00382   m_pNodeTail = pNewNode;
00383   return (POSITION)pNewNode;
00384 }
00385
00386
00387 template<class TYPE, class ARG_TYPE>
00388 void CLListImpl<TYPE, ARG_TYPE>::AddHead( CLListImpl* pNewList )
00389 {
00390   _ASSERT( NULL != pNewList );
00391
00392   // Add a list of same elements to head (maintain order)
00393   POSITION Pos = pNewList->GetTailPosition();
00394   while( NULL != Pos )
00395     AddHead(pNewList->GetPrev( Pos ));
00396 }
00397
00398
00399 template<class TYPE, class ARG_TYPE>
00400 void CLListImpl<TYPE, ARG_TYPE>::AddTail(CLListImpl* pNewList)
00401 {
00402   _ASSERT( NULL != pNewList );
00403
00404   // Add a list of same elements
00405   POSITION Pos = pNewList->GetHeadPosition();
00406   while( NULL != Pos )
00407     AddTail(pNewList->GetNext( Pos ));
00408 }
00409
00410
00411 template<class TYPE, class ARG_TYPE>
00412 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveHead()
00413 {
00414   _ASSERT( NULL != m_pNodeHead );  // don't call on empty list !!!
00415   _ASSERT( IsValidAddress( m_pNodeHead, sizeof(CNode)) );
00416
00417   CNode* pOldNode = m_pNodeHead;
00418   TYPE returnValue = pOldNode->data;
00419
00420   m_pNodeHead = pOldNode->pNext;
00421   if( NULL != m_pNodeHead )
00422     m_pNodeHead->pPrev = NULL;
00423   else
00424     m_pNodeTail = NULL;
00425
00426   FreeNode(pOldNode);
00427   return returnValue;
00428 }
00429
00430
00431 template<class TYPE, class ARG_TYPE>
00432 TYPE CLListImpl<TYPE, ARG_TYPE>::RemoveTail()
00433 {
00434   _ASSERT( NULL != m_pNodeTail );  // don't call on empty list !!!
00435   _ASSERT( IsValidAddress( m_pNodeTail, sizeof(CNode)) );
00436
00437   CNode* pOldNode = m_pNodeTail;
00438   TYPE returnValue = pOldNode->data;
00439
00440   m_pNodeTail = pOldNode->pPrev;
00441   if( NULL != m_pNodeTail )
00442     m_pNodeTail->pNext = NULL;
00443   else
00444     m_pNodeHead = NULL;
00445
00446   FreeNode(pOldNode);
00447   return returnValue;
00448 }
00449
00450
00451 template<class TYPE, class ARG_TYPE>
00452 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertBefore(POSITION Position, ARG_TYPE NewElement)
00453 {
00454   _ASSERT( NULL != NewElement );
00455
00456   if( NULL == Position )
00457     return AddHead( NewElement ); // insert before nothing -> head of the list
00458
00459   // Insert it before position
00460   CNode* pOldNode = (CNode*)Position;
00461   CNode* pNewNode = NewNode( pOldNode->pPrev, pOldNode );
00462   pNewNode->data  = NewElement;
00463
00464   if( NULL != pOldNode->pPrev )
00465   {
00466     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00467     pOldNode->pPrev->pNext = pNewNode;
00468   }
00469   else
00470   {
00471     _ASSERT( pOldNode == m_pNodeHead );
00472     m_pNodeHead = pNewNode;
00473   }
00474   pOldNode->pPrev = pNewNode;
00475   return (POSITION)pNewNode;
00476 }
00477
00478
00479 template<class TYPE, class ARG_TYPE>
00480 POSITION CLListImpl<TYPE, ARG_TYPE>::InsertAfter(POSITION Position, ARG_TYPE NewElement)
00481 {
00482   ASSERT( NULL != NewElement );
00483
00484   if( NULL == Position )
00485     return AddTail( NewElement ); // insert after nothing -> tail of the list
00486
00487   // Insert it before position
00488   CNode* pOldNode = (CNode*)Position;
00489   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode) ) );
00490   CNode* pNewNode = NewNode( pOldNode, pOldNode->pNext );
00491   pNewNode->data = NewElement;
00492
00493   if( NULL != pOldNode->pNext )
00494   {
00495     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00496     pOldNode->pNext->pPrev = pNewNode;
00497   }
00498   else
00499   {
00500     _ASSERT( pOldNode == m_pNodeTail );
00501     m_pNodeTail = pNewNode;
00502   }
00503   pOldNode->pNext = pNewNode;
00504   return (POSITION)pNewNode;
00505 }
00506
00507
00508 template<class TYPE, class ARG_TYPE>
00509 void CLListImpl<TYPE, ARG_TYPE>::RemoveAt( POSITION Position )
00510 {
00511   _ASSERT( NULL != Position );
00512
00513   CNode* pOldNode = (CNode*)Position;
00514   _ASSERT( IsValidAddress( pOldNode, sizeof(CNode)) );
00515
00516   // Remove pOldNode from list
00517   if( pOldNode == m_pNodeHead )
00518   {
00519     m_pNodeHead = pOldNode->pNext;
00520   }
00521   else
00522   {
00523     _ASSERT( IsValidAddress( pOldNode->pPrev, sizeof(CNode)) );
00524     pOldNode->pPrev->pNext = pOldNode->pNext;
00525   }
00526   if( pOldNode == m_pNodeTail )
00527   {
00528     m_pNodeTail = pOldNode->pPrev;
00529   }
00530   else
00531   {
00532     _ASSERT( IsValidAddress( pOldNode->pNext, sizeof(CNode)) );
00533     pOldNode->pNext->pPrev = pOldNode->pPrev;
00534   }
00535   FreeNode( pOldNode );
00536 }
00537
00538
00539 template<class TYPE, class ARG_TYPE>
00540 POSITION CLListImpl<TYPE, ARG_TYPE>::FindIndex(int nIndex) const
00541 {
00542   if( nIndex >= m_nCount || nIndex < 0 )
00543     return NULL;  // went too far
00544
00545   CNode* pNode = m_pNodeHead;
00546   while (nIndex--)
00547   {
00548     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00549     pNode = pNode->pNext;
00550   }
00551   return (POSITION)pNode;
00552 }
00553
00554
00555 template<class TYPE, class ARG_TYPE>
00556 POSITION CLListImpl<TYPE, ARG_TYPE>::Find(ARG_TYPE SearchValue, POSITION StartAfter) const
00557 {
00558   _ASSERT( NULL != SearchValue );
00559
00560   CNode* pNode = (CNode*)StartAfter;
00561   if( NULL == pNode )
00562   {
00563     pNode = m_pNodeHead;  // start at head
00564   }
00565   else
00566   {
00567     _ASSERT( IsValidAddress( pNode, sizeof(CNode)) );
00568     pNode = pNode->pNext;  // start after the one specified
00569   }
00570
00571   for (; pNode != NULL; pNode = pNode->pNext)
00572     if (CompareElements<TYPE>(&pNode->data, &searchValue))
00573       return (POSITION)pNode;
00574
00575   return NULL;
00576 }
00577
00578 #ifdef _DEBUG
00579
00580 template<class TYPE, class ARG_TYPE>
00581 void CLListImpl<TYPE, ARG_TYPE>::AssertValid() const
00582 {
00583   if( 0 == m_nCount )
00584   {
00585     // empty list
00586     _ASSERT( NULL == m_pNodeHead );
00587     _ASSERT( NULL == m_pNodeTail );
00588   }
00589   else
00590   {
00591     // non-empty list
00592     _ASSERT( IsValidAddress(m_pNodeHead, sizeof(CNode)) );
00593     _ASSERT( IsValidAddress(m_pNodeTail, sizeof(CNode)) );
00594   }
00595 }
00596 #endif //_DEBUG
00597
00598 #endif //__CLASS_CLLISTIMPL__
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/GetImage/MainWnd.cpp Source File

  • Multimedia
  • wia
  • GetImage

MainWnd.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 --*/
00006
00007 #include "stdafx.h"
00008 #include "resource.h"
00009
00010 #include "WiaWrap.h"
00011 #include "BitmapWnd.h"
00012 #include "MainWnd.h"
00013
00014 //////////////////////////////////////////////////////////////////////////
00015 //
00016 // CMainWindow::CMainWindow
00017 //
00018
00019 CMainWindow::CMainWindow()
00020 {
00021     m_cRef = 0;
00022
00023     m_nNumImages = 0;
00024
00025     m_bDisplayWaitCursor = FALSE;
00026
00027     m_pEventCallback = new WiaWrap::CEventCallback;
00028
00029     if (m_pEventCallback != NULL)
00030     {
00031         m_pEventCallback->Register();
00032     }
00033 }
00034
00035 //////////////////////////////////////////////////////////////////////////
00036 //
00037 // CMainWindow::QueryInterface
00038 //
00039
00040 STDMETHODIMP CMainWindow::QueryInterface(REFIID iid, LPVOID *ppvObj)
00041 {
00042     if (ppvObj == NULL)
00043     {
00044       return E_POINTER;
00045     }
00046
00047     if (iid == IID_IUnknown)
00048     {
00049       *ppvObj = (IUnknown *) this;
00050     }
00051     else
00052     {
00053         *ppvObj = NULL;
00054         return E_NOINTERFACE;
00055     }
00056
00057   AddRef();
00058     return S_OK;
00059 }
00060
00061 //////////////////////////////////////////////////////////////////////////
00062 //
00063 // CMainWindow::AddRef
00064 //
00065
00066 STDMETHODIMP_(ULONG) CMainWindow::AddRef()
00067 {
00068     return InterlockedIncrement(&m_cRef);
00069 }
00070
00071 //////////////////////////////////////////////////////////////////////////
00072 //
00073 // CMainWindow::Release
00074 //
00075
00076 STDMETHODIMP_(ULONG) CMainWindow::Release()
00077 {
00078     LONG cRef = InterlockedDecrement(&m_cRef);
00079
00080     if (cRef == 0)
00081     {
00082         delete this;
00083     }
00084
00085     return cRef;
00086 }
00087
00088 //////////////////////////////////////////////////////////////////////////
00089 //
00090 // CMainWindow::Register
00091 //
00092
00093 ATOM CMainWindow::Register()
00094 {
00095     WNDCLASSEX wcex = { 0 };
00096
00097     wcex.cbSize         = sizeof(wcex);
00098     wcex.style          = CS_HREDRAW | CS_VREDRAW;
00099     wcex.lpfnWndProc    = WindowProc;
00100     wcex.hInstance      = g_hInstance;
00101     wcex.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
00102     wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
00103     wcex.hbrBackground  = (HBRUSH) (COLOR_APPWORKSPACE + 1);
00104     wcex.lpszMenuName   = MAKEINTRESOURCE(IDR_MENU);
00105     wcex.lpszClassName  = _T("MainWindow");
00106
00107     return RegisterClassEx(&wcex);
00108 }
00109
00110 //////////////////////////////////////////////////////////////////////////
00111 //
00112 // CMainWindow::DoModal
00113 //
00114
00115 int CMainWindow::DoModal()
00116 {
00117     MSG msg;
00118
00119     while (GetMessage(&msg, NULL, 0, 0))
00120     {
00121         if (!TranslateMDISysAccel(m_hMDIClient, &msg))
00122         {
00123             TranslateMessage(&msg);
00124             DispatchMessage(&msg);
00125         }
00126     }
00127
00128     return (int) msg.wParam;
00129 }
00130
00131 //////////////////////////////////////////////////////////////////////////
00132 //
00133 // CMainWindow::WindowProc
00134 //
00135
00136 LRESULT
00137 CALLBACK
00138 CMainWindow::WindowProc(
00139     HWND   hWnd,
00140     UINT   uMsg,
00141     WPARAM wParam,
00142     LPARAM lParam
00143 )
00144 {
00145     CMainWindow *that = (CMainWindow *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
00146
00147     switch (uMsg)
00148     {
00149         case WM_CREATE:
00150         {
00151             LPCREATESTRUCT pcs = (LPCREATESTRUCT) lParam;
00152
00153             that = (CMainWindow *) pcs->lpCreateParams;
00154
00155             // Create the MDI client window that will handle the MDI child windows
00156
00157             CLIENTCREATESTRUCT ccs = { 0 };
00158
00159             ccs.hWindowMenu  = GetSubMenu(GetMenu(hWnd), WINDOW_MENU_POSITION);
00160             ccs.idFirstChild = FIRST_MDI_CHILD;
00161
00162             that->m_hMDIClient = CreateWindowEx(
00163                 0,
00164                 _T("MDICLIENT"),
00165                 0,
00166                 WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE,
00167                 0,
00168                 0,
00169                 0,
00170                 0,
00171                 hWnd,
00172                 NULL,
00173                 g_hInstance,
00174                 &ccs
00175             );
00176
00177             if (that->m_hMDIClient == NULL)
00178             {
00179                 return -1;
00180             }
00181
00182             that->AddRef();
00183
00184             SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) that);
00185
00186             break;
00187         }
00188
00189         case WM_DESTROY:
00190         {
00191             SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL);
00192
00193             that->Release();
00194
00195             PostQuitMessage(0);
00196
00197             break;
00198         }
00199
00200         case WM_SETCURSOR:
00201         {
00202             if (that->m_bDisplayWaitCursor)
00203             {
00204                 SetCursor(LoadCursor(NULL, IDC_WAIT));
00205
00206                 return TRUE;
00207             }
00208
00209             break;
00210         }
00211
00212         case WM_INITMENU:
00213         {
00214             if (that->m_pEventCallback != NULL)
00215             {
00216                 LONG nNumDevices = that->m_pEventCallback->GetNumDevices();
00217
00218                 UINT uEnable = nNumDevices > 0 ? MF_ENABLED : MF_GRAYED;
00219
00220                 EnableMenuItem((HMENU) wParam, ID_FILE_FROM_SCANNER_OR_CAMERA, uEnable);
00221             }
00222
00223             break;
00224         }
00225
00226         case WM_COMMAND:
00227         {
00228             switch (LOWORD(wParam))
00229             {
00230                 case ID_FILE_FROM_SCANNER_OR_CAMERA:
00231                 {
00232                     that->OnFromScannerOrCamera();
00233                     break;
00234                 }
00235
00236                 case ID_FILE_EXIT:
00237                 {
00238                     DestroyWindow(hWnd);
00239                     break;
00240                 }
00241
00242                 case ID_WINDOW_CASCADE:
00243                 {
00244                     SendMessage(that->m_hMDIClient, WM_MDICASCADE, 0, 0);
00245                     break;
00246                 }
00247
00248                 case ID_WINDOW_TILE_HORIZONTALLY:
00249                 {
00250                     SendMessage(that->m_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
00251                     break;
00252                 }
00253
00254                 case ID_WINDOW_TILE_VERTICALLY:
00255                 {
00256                     SendMessage(that->m_hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0);
00257                     break;
00258                 }
00259
00260                 case ID_WINDOW_ARRANGE_ICONS:
00261                 {
00262                     SendMessage(that->m_hMDIClient, WM_MDIICONARRANGE, 0, 0);
00263                     break;
00264                 }
00265
00266                 case ID_HELP_ABOUT:
00267                 {
00268                     TCHAR szAppName[DEFAULT_STRING_SIZE] = _T("");
00269
00270                   LoadString(g_hInstance, IDS_APP_NAME, szAppName, COUNTOF(szAppName));
00271
00272                     ShellAbout(hWnd, szAppName, NULL, NULL);
00273
00274                     break;
00275                 }
00276             }
00277
00278             break;
00279         }
00280     }
00281
00282     return DefFrameProc(
00283         hWnd,
00284         that == NULL ? NULL : that->m_hMDIClient,
00285         uMsg,
00286         wParam,
00287         lParam
00288     );
00289 }
00290
00291 //////////////////////////////////////////////////////////////////////////
00292 //
00293 // CMainWindow::OnFromScannerOrCamera
00294 //
00295
00296 LRESULT CMainWindow::OnFromScannerOrCamera()
00297 {
00298     HRESULT hr;
00299
00300     m_bDisplayWaitCursor = TRUE;
00301
00302     // Launch the get image dialog
00303
00304     WiaWrap::CComPtrArray<IStream> ppStream;
00305
00306     hr = WiaWrap::WiaGetImage(
00307         m_hMDIClient,
00308         StiDeviceTypeDefault,
00309         0,
00310         WIA_INTENT_NONE,
00311         NULL,
00312         NULL,
00313         NULL,
00314         NULL,
00315         NULL,
00316         &ppStream.Count(),
00317         &ppStream
00318     );
00319
00320     m_bDisplayWaitCursor = FALSE;
00321
00322     // If there was an error, display an error message box
00323
00324   if (FAILED(hr))
00325     {
00326     TCHAR szError[DEFAULT_STRING_SIZE] = _T("");
00327
00328     LoadString(g_hInstance, IDS_ERROR_GET_IMAGE_DLG, szError, COUNTOF(szError));
00329
00330         MessageBox(m_hMDIClient, szError, NULL, MB_ICONHAND | MB_OK);
00331   }
00332
00333     // Open a new window for each successfully transferred image
00334
00335     for (int i = 0; i < ppStream.Count(); ++i)
00336     {
00337         CComPtr<CBitmapWnd> pBitmapWnd = new CBitmapWnd(ppStream[i]);
00338
00339         if (pBitmapWnd != NULL)
00340         {
00341             m_nNumImages += 1;
00342
00343             TCHAR szFormat[DEFAULT_STRING_SIZE] = _T("%d");
00344
00345         LoadString(g_hInstance, IDS_BITMAP_WINDOW_TITLE, szFormat, COUNTOF(szFormat));
00346
00347         TCHAR szTitle[DEFAULT_STRING_SIZE];
00348
00349           _sntprintf(szTitle, COUNTOF(szTitle) - 1, szFormat, m_nNumImages);
00350
00351             szTitle[COUNTOF(szTitle) - 1] = _T('\0');
00352
00353             CreateWindowEx(
00354                 WS_EX_MDICHILD,
00355                 _T("BitmapWindow"),
00356                 szTitle,
00357                 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
00358                 CW_USEDEFAULT,
00359                 CW_USEDEFAULT,
00360                 CW_USEDEFAULT,
00361                 CW_USEDEFAULT,
00362                 m_hMDIClient,
00363                 NULL,
00364                 g_hInstance,
00365                 pBitmapWnd
00366             );
00367         }
00368     }
00369
00370     return 0;
00371 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/OPBank/bankthrds.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • OPBank

bankthrds.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      bankthrds.cpp
00003   Summary:   Thread routines for Bank client
00004   Classes:   None
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #include "stdafx.h"
00023 #ifndef DBNTWIN32
00024 #define DBNTWIN32
00025 #include <SQL.h>
00026 #include <SQLEXT.h>
00027 #endif
00028
00029 #define MSG_BUF_SIZE  256
00030
00031 #include "BankDlg.h"
00032 #include "stdio.h"
00033
00034
00035 #include <fstream.h>
00036
00037 #include "commctrl.h"
00038 #include "stdlib.h"
00039
00040 #include "..\account.vc\account_i.c"
00041 #include "..\account.vc\account.h"
00042
00043 #define SQL_FAILED(rc)  ( (rc) != SQL_SUCCESS && (rc) != SQL_SUCCESS_WITH_INFO)
00044 #define ASSERT_SQL_SUCCESS(rc) { _ASSERTE(rc==SQL_SUCCESS || rc==SQL_SUCCESS_WITH_INFO);}
00045
00046 //
00047 //  execute these queries to create the schema
00048 //
00049 static LPOLESTR sCreateSchema[] =
00050 {
00051   L"if exists (select * from sysobjects where id = object_id('dbo.VcAccount') and sysstat & 0xf = 3)  drop table dbo.VcAccount",
00052   L"CREATE TABLE dbo.VcAccount (AccountNo int IDENTITY (1, 1) NOT NULL ,Balance int NULL, Name char (255) NULL, CONSTRAINT PK___1__17 PRIMARY KEY  CLUSTERED(AccountNo))",
00053   L"if exists (select * from sysobjects where id = object_id('dbo.Receipt') and sysstat & 0xf = 3)  drop table dbo.Receipt",
00054   L"CREATE TABLE dbo.Receipt (NextReceipt int NULL)"
00055 };
00056
00057 //
00058 //  execute these queries (and check SQLRowCount()) to verify schema
00059 //
00060 static LPOLESTR sCheckSchema[] =
00061 {
00062   L"select * from sysobjects where id = object_id('dbo.VcAccount') and sysstat & 0xf = 3",
00063   L"select * from sysobjects where id = object_id('dbo.Receipt') and sysstat & 0xf = 3)"
00064 };
00065
00066 HRESULT GetConnection(HENV  * phEnv, HDBC * phdbc, HSTMT * phstmt);
00067 HRESULT GetRowCount(HSTMT hstmt, long * pRowCount);
00068 HRESULT FreeConnection(HENV henv, HDBC hdbc, HSTMT hstmt);
00069 HRESULT VerifySchema(HSTMT hstmt);
00070 HRESULT CreateSchema(HSTMT hstmt);
00071 HRESULT CreateRows(long nRows, HSTMT hstmt);
00072 LARGE_INTEGER g_PerfFreq;
00073 void ShowResults(BSTR sString, BOOL bError);
00074 extern long g_nRows;
00075 extern BOOL g_bRetry;
00076
00077
00078 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00079   Function: RandInt
00080   Summary:  Return a random integer with 0 <= i < max
00081       This routine is thread-safe, and returns different random number
00082       streams for each thread.
00083       In 48-bit arithmentic, set seed = seed * multiplier + increment
00084       Then, take the upper-most 32 bits and multiply by ulMax.
00085       The overflow into the next DWORD is the return value.
00086   Args:     unsigned long ulMax   Max integer size
00087   Returns:  unsigned long
00088 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00089 static const unsigned long g_ulTlsRandomHigh = TlsAlloc();
00090 static const unsigned long g_ulTlsRandomLow = TlsAlloc();
00091 static const __int64 g_llMultiplier = 0x5DEECE66D;
00092 static const __int64 g_llIncrement = 0xB;
00093 union UnionInt64 { __int64 n; unsigned long l[2]; unsigned short i[4]; };
00094
00095 unsigned long RandInt (unsigned long ulMax)
00096 {
00097
00098   UnionInt64 seed;
00099   seed.l[1] = (unsigned long) TlsGetValue (g_ulTlsRandomHigh);
00100   seed.l[0] = (unsigned long) TlsGetValue (g_ulTlsRandomLow);
00101
00102   if (seed.n == 0)
00103   {
00104     // initialize random number stream
00105     seed.l[1] = GetCurrentThreadId();
00106     seed.l[0] = GetTickCount();
00107     seed.n ^= g_llMultiplier;
00108     seed.i[3] = 0;
00109   }
00110
00111   seed.n = seed.n * g_llMultiplier + g_llIncrement;
00112   seed.i[3] = 0;  // clear high 16 bits;
00113
00114   TlsSetValue (g_ulTlsRandomHigh, (void*) seed.l[1]);
00115   TlsSetValue (g_ulTlsRandomLow, (void*) seed.l[0]);
00116
00117   // shift so that high DWORD is zero, low DWORD contains most significant bits
00118   seed.i[0] = seed.i[1];
00119   seed.i[1] = seed.i[2];
00120   seed.i[2] = 0;
00121
00122   seed.n *= ulMax;
00123   return seed.l[1];
00124 }
00125
00126
00127 extern HWND g_hWndResults;
00128 extern HWND g_hWndSubmit;
00129 extern HWND g_hWndStop;
00130 extern HWND g_hDlg;
00131 extern BOOL g_bStop;
00132 extern BOOL g_bAssertOnErrors;
00133 extern BOOL g_bStopOnODBCErrors;
00134
00135
00136 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00137   Function: CreateObject
00138   Summary:  All calls to create a COM object end up here
00139   Args:     REFCLSID clsid    Class ID to create
00140       DWORD clsctx    clsctx to create object
00141       REFIID iid      Interface ID
00142       void **ppv      Reference to interface
00143       DWORD *pdwTime    Time is ms to do the create
00144   Returns:  HRESULT
00145 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00146 HRESULT CreateObject(REFCLSID clsid, DWORD clsctx, REFIID iid, void **ppv, DWORD * pdwTime)
00147 {
00148
00149   HRESULT hr = E_FAIL;
00150   LARGE_INTEGER stop;
00151   LARGE_INTEGER start;
00152   LARGE_INTEGER total;
00153
00154   QueryPerformanceCounter( &start);
00155   hr = CoCreateInstance(clsid, NULL, clsctx, iid, ppv);
00156   QueryPerformanceCounter( &stop);
00157   total.QuadPart = 1000*(stop.QuadPart-start.QuadPart)/g_PerfFreq.QuadPart;
00158   if (total.HighPart != 0)
00159     ShowResults(SysAllocString(L"Overflow in performance counters!"), TRUE);
00160
00161   *pdwTime  = total.LowPart;
00162
00163   return hr;
00164 }
00165
00166
00167 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00168   Function: GetOdbcError
00169   Summary:  Call SQLError to get the error from ODBC
00170   Args:     HENV henv   An ODBC environment handle
00171       HDBC hdbc   An ODBC database connection handle
00172       HSTMT hstmt   An ODBC statement handle
00173       BSTR* sErr    Output error string
00174   Returns:  void
00175 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00176 void GetOdbcError(HENV henv, HDBC hdbc, HSTMT hstmt, BSTR * sErr)
00177 {
00178     WCHAR szSqlState[64];
00179     SDWORD NativeError;
00180     WCHAR szErr[512];
00181     SWORD cbErrorMsg;
00182     SQLError(henv, hdbc, hstmt, (SQLWCHAR *)szSqlState, &NativeError, (SQLWCHAR *)szErr, 511, &cbErrorMsg);
00183     *sErr = ::SysAllocString(szErr);
00184 }
00185
00186
00187 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00188   Function: ShowResults
00189   Summary:  Show the results in a listview (not thread safe)
00190   Args:     BSTR sString  String to display
00191       BOOL bError   Is this an error?
00192   Returns:  void
00193 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00194 void ShowResults(BSTR sString, BOOL bError)
00195 {
00196
00197
00198   if (bError)
00199   {
00200     ::PostMessage(g_hDlg, WM_SHOWERROR, (WPARAM)GetCurrentThreadId() , (LPARAM)sString);
00201   }
00202   else
00203   {
00204     ::PostMessage(g_hDlg, WM_SHOWRESULTS, (WPARAM)GetCurrentThreadId() , (LPARAM)sString);
00205   }
00206
00207 }
00208
00209
00210 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00211   Function: CreateRowsThread
00212   Summary:  Populates the database with rows
00213   Args:   LPVOID v    Number of rows to create
00214       BOOL bError   Is this an error?
00215   Returns:  DWORD
00216 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00217 DWORD WINAPI CreateRowsThread( LPVOID v)
00218 {
00219
00220   CreateRows((long)v, NULL);
00221   return S_OK;
00222 }
00223
00224
00225 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00226   Function: MoveMoneyThread
00227   Summary:  Transfers money from one account to another
00228   Args:   LPVOID v    Thread data
00229   Returns:  DWORD
00230 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00231 DWORD WINAPI MoveMoneyThread( LPVOID v)
00232 {
00233
00234   THREADDATA * pTd = (THREADDATA *)v;
00235   HRESULT hr;
00236   BOOL bLocalStop = FALSE;
00237   BSTR s;
00238   EnumCoInit eCoInit = pTd -> eCoInit;
00239   if (eCoInit == CoInitRandom)
00240   {
00241     eCoInit = (EnumCoInit)RandInt(2);
00242
00243   }
00244   switch (eCoInit)
00245   {
00246   case CoInitMTA:
00247     s = SysAllocString(L"Initializing COM (MTA)");
00248     ShowResults(s, FALSE);
00249     hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00250     break;
00251   case CoInitSTA:
00252     s = SysAllocString(L"Initializing COM (STA)");
00253     ShowResults(s, FALSE);
00254     hr = CoInitialize(NULL);
00255     break;
00256   default:
00257     _ASSERTE(0);
00258
00259   }
00260   WCHAR sz[MSG_BUF_SIZE];
00261
00262   if (hr)
00263   {
00264     wsprintf(sz, L"CoInitialize or CoInitializeEx failed.  hr = %Hx", hr);
00265     ShowResults(SysAllocString(sz), TRUE);
00266     CoUninitialize();
00267     return hr;
00268   }
00269
00270   CLSID clsid = CLSID_CMoveMoney;
00271   IID   iid = IID_IMoveMoney;
00272   switch (pTd -> eLang)
00273   {
00274   case VB:
00275     hr = CLSIDFromProgID(L"Bank.IMoveMoney", &clsid);
00276     if (FAILED(hr))
00277     {
00278       //ShowResults(SysAllocString(L"VB Account Not registered.  Using VC Account."), TRUE);
00279       clsid = CLSID_CMoveMoney;
00280     }
00281     break;
00282   case VC:
00283     break;
00284   case Java:
00285     ShowResults(SysAllocString(L"Java not supported (yet).  Using VC Account."), TRUE);
00286     break;
00287     // (04.26.00 mdl) Included support for Delphi.
00288   case Delphi:
00289         hr = CLSIDFromProgID(L"DelphiBank.MoveMoney", &clsid);
00290     IIDFromString(L"{A8C18C7A-4D78-475B-A5E7-96F73DB2CE8D}", &iid);
00291     if (FAILED(hr))
00292     {
00293       ShowResults(SysAllocString(L"Delphi MoveMoney Not registered.  Using VC Account."), TRUE);
00294       clsid = CLSID_CMoveMoney;
00295       iid = IID_IMoveMoney;
00296     }
00297         break;
00298   default:
00299     _ASSERTE(0);
00300   }
00301
00302   int nCount = 0;
00303
00304   BSTR sResult = 0;
00305
00306   int nFrom = pTd -> nFrom;
00307   int nTo = pTd -> nTo;
00308
00309   DWORD liStartTime = GetTickCount();
00310
00311
00312   IErrorInfo * pInfo = NULL;
00313   nCount = 0;
00314   IMoveMoney * pMove = NULL;
00315   DWORD dwTime;
00316   LARGE_INTEGER stop;
00317   LARGE_INTEGER start;
00318   while (g_bStop == FALSE && (nCount < pTd -> nIters)  && bLocalStop == FALSE )
00319   {
00320
00321     if (pMove == NULL)
00322     {
00323       if (pTd -> bChatty)
00324       {
00325         ShowResults(SysAllocString(L"Creating MoveMoney"), FALSE);
00326       }
00327
00328
00329       // (04.26.00 mdl) Modified to use variable vs. fixed iid.
00330       //hr = CreateObject(clsid, CLSCTX_ALL, IID_IMoveMoney, (void **)&pMove, &dwTime);
00331       hr = CreateObject(clsid, CLSCTX_ALL, iid, (void **)&pMove, &dwTime);
00332       if (pTd -> bChatty)
00333       {
00334         wsprintf(sz, L"CoCreateInstance took %d ms", dwTime);
00335         ShowResults(SysAllocString(sz), FALSE);
00336       }
00337       if (hr)
00338       {
00339
00340         wsprintf(sz, L"Failed to create the move money component! HRESULT: %lX", hr);
00341         ShowResults(SysAllocString(sz), TRUE);
00342         if (g_bAssertOnErrors)
00343           _ASSERTE(0);
00344         if (g_bRetry == FALSE) // don't exit for Wolfpack
00345           break; // exit thread if create fails
00346         else
00347         {
00348           ShowResults(SysAllocString(L"Waiting for 100 ms"), FALSE);
00349           Sleep(100);
00350         }
00351       }
00352     }
00353
00354     if (pMove) // may be NULL w/ Wolfpack failover
00355     {
00356       IMoveMoneyOptions * pOptions = NULL;
00357       hr = pMove -> QueryInterface(IID_IMoveMoneyOptions, (void **)&pOptions);
00358       if (pOptions)
00359       {
00360         pOptions -> UseComPlus();
00361         pOptions -> SetAccountClsctx(CLSCTX_ALL);
00362         pOptions -> Release();
00363       }
00364
00365       if (pTd -> bRandom)
00366       {
00367         nFrom = 0;
00368         nTo = 0;
00369         nFrom = RandInt(g_nRows);
00370         nFrom++; // we want 1 --> nRows
00371         nTo = RandInt(g_nRows);
00372         nTo++;
00373         if (nFrom > nTo) //always move from lowest to highest to stop deadlocks
00374         {
00375           int nTemp = nTo;
00376           nTo = nFrom;
00377           nFrom = nTemp;
00378         }
00379       }
00380
00381       QueryPerformanceCounter( &start);
00382       hr = pMove -> Perform(nFrom, nTo, pTd -> nAmount, pTd -> nTranType, &sResult);
00383       QueryPerformanceCounter( &stop);
00384       if (pTd -> bChatty)
00385       {
00386         wsprintf(sz, L"MoveMoney Perform took %d ms",  1000*(stop.QuadPart-start.QuadPart)/g_PerfFreq.QuadPart);
00387         ShowResults(SysAllocString(sz), FALSE);
00388       }
00389       if (hr)
00390       {
00391         GetErrorInfo(NULL, &pInfo);
00392         if( pInfo )
00393         {
00394           pInfo -> GetDescription(&sResult);
00395           pInfo -> Release();
00396         }
00397         if (g_bAssertOnErrors)
00398           _ASSERTE(0);
00399         if (hr == E_UNEXPECTED && g_bStopOnODBCErrors) // E_UNEXPECTED returned on ODBC errors
00400         {
00401           if (!g_bRetry)
00402             bLocalStop = TRUE;
00403           else // retry for wolfpack
00404           {
00405             if (pMove)
00406             {
00407               pMove -> Release();
00408               pMove = NULL;
00409             }
00410           }
00411         }
00412         else  // non-ODBC error, stop all threads
00413         {
00414           if (!g_bRetry)
00415             g_bStop = TRUE;
00416           else // retry for wolfpack
00417           {
00418             if (pMove)
00419             {
00420               pMove -> Release();
00421               pMove = NULL;
00422             }
00423           }
00424         }
00425         *sz = NULL;
00426         if (!sResult)
00427         {
00428           if (hr == E_ACCESSDENIED)
00429             sResult = ::SysAllocString(L"Call failed due to security violation ");
00430           else
00431             sResult = ::SysAllocString(L"Call failed ");
00432
00433         }
00434         wsprintf(sz, L"%s HRESULT: 0x%lx", sResult, hr);
00435         ShowResults(SysAllocString(sz), TRUE);
00436         SysFreeString(sResult); // not posting it
00437         sResult = NULL;
00438       }
00439       else
00440       {
00441         if (pTd -> bChatty)
00442           ShowResults(sResult, FALSE);
00443       }
00444
00445
00446
00447
00448
00449       if (pTd -> bCreatePerIteration && pMove)
00450       {
00451         pMove -> Release();
00452         pMove = NULL;
00453       }
00454     }
00455
00456     nCount++;
00457   }
00458
00459   if (pMove)
00460   {
00461     pMove -> Release();
00462     pMove = NULL;
00463   }
00464
00465
00466   float t = (GetTickCount() - (float)liStartTime)  / 1000;
00467   _snwprintf(sz, MSG_BUF_SIZE, L"Done.  Time: %2.4f seconds for %ld iterations", t, nCount);
00468   ShowResults(SysAllocString(sz), FALSE);
00469   CoUninitialize();
00470   return 0;
00471 }
00472
00473
00474 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00475   Function: AccountThread
00476   Summary:  Changes the balance on an account
00477   Args:   LPVOID v    Thread data
00478   Returns:  DWORD
00479 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00480 DWORD WINAPI AccountThread( LPVOID v)
00481 {
00482   THREADDATA * pTd = (THREADDATA *)v;
00483   HRESULT hr;
00484   BOOL bLocalStop = FALSE;
00485   BSTR s;
00486   EnumCoInit eCoInit = pTd -> eCoInit;
00487   if (eCoInit == CoInitRandom)
00488   {
00489     eCoInit = (EnumCoInit)RandInt(2);
00490
00491   }
00492   switch (eCoInit)
00493   {
00494   case CoInitMTA:
00495     s = SysAllocString(L"Initializing COM (MTA)");
00496     ShowResults(s, FALSE);
00497     hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00498     break;
00499   case CoInitSTA:
00500     s = SysAllocString(L"Initializing COM (STA)");
00501     ShowResults(s, FALSE);
00502     hr = CoInitialize(NULL);
00503     break;
00504   default:
00505     _ASSERTE(0);
00506
00507   }
00508
00509   WCHAR sz[MSG_BUF_SIZE];
00510   if (hr)
00511   {
00512     wsprintf(sz, L"CoInitialize or CoInitializeEx failed.  hr = %Hx", hr);
00513     ShowResults(SysAllocString(sz), TRUE);
00514     CoUninitialize();
00515     return hr;
00516   }
00517
00518   CLSID clsid = CLSID_CAccount;
00519   IID iid = IID_IAccount;
00520   switch (pTd -> eLang)
00521   {
00522   case VB:
00523     hr = CLSIDFromProgID(L"Bank.IAccount", &clsid);
00524     if (FAILED(hr))
00525     {
00526       //ShowResults(SysAllocString(L"VB Account Not registered.  Using VC Account."), TRUE);
00527       clsid = CLSID_CAccount;
00528     }
00529     break;
00530   case VC:
00531     break;
00532   case Java:
00533     ShowResults(SysAllocString(L"Java not supported (yet).  Using VC Account."), TRUE);
00534     break;
00535   // (04.26.00 mdl) Included support for Delphi.
00536   case Delphi:
00537         hr  = CLSIDFromProgID(L"DelphiBank.Account", &clsid);
00538     IIDFromString(L"{4D237DC1-041A-11D4-81A3-005004D0FBC3}", &iid);
00539     if (FAILED(hr))
00540     {
00541       ShowResults(SysAllocString(L"Delphi Account Not registered.  Using VC Account."), TRUE);
00542       clsid = CLSID_CAccount;
00543       iid = IID_IAccount;
00544     }
00545         break;
00546   default:
00547     _ASSERTE(0);
00548   }
00549
00550   int nCount = 0;
00551
00552
00553   BSTR sResult = 0;
00554
00555   int nFrom = pTd -> nFrom;
00556   int nTo = pTd -> nTo;
00557
00558
00559   DWORD liStartTime = GetTickCount();
00560   IAccount * pAccount = NULL;
00561   IErrorInfo * pInfo = NULL;
00562   nCount = 0;
00563   DWORD dwTime;
00564   LARGE_INTEGER stop;
00565   LARGE_INTEGER start;
00566   while (g_bStop == FALSE && (nCount < pTd -> nIters) && bLocalStop == FALSE)
00567   {
00568
00569     if (!pAccount)
00570     {
00571       if (pTd -> bChatty)
00572       {
00573         s = SysAllocString(L"Creating Account");
00574         ShowResults(s, FALSE);
00575       }
00576       // (04.26.00 mdl) Modified to use variable vs. fixed iid.
00577       //hr = CreateObject(clsid, CLSCTX_ALL, IID_IAccount, (void **)&pAccount, &dwTime);
00578       hr = CreateObject(clsid, CLSCTX_ALL, iid, (void **)&pAccount, &dwTime);
00579       if (pTd -> bChatty)
00580       {
00581         wsprintf(sz, L"CoCreateInstance took %d ms", dwTime);
00582         ShowResults(SysAllocString(sz), FALSE);
00583       }
00584
00585       if (hr)
00586       {
00587
00588         wsprintf(sz, L"Failed to create the account component! HRESULT: %lX", hr);
00589         ShowResults(SysAllocString(sz), TRUE);
00590         if (g_bAssertOnErrors)
00591           _ASSERTE(0);
00592         if (g_bRetry == FALSE) // don't exit for Wolfpack
00593           break; // exit thread if create fails
00594         else
00595         {
00596           ShowResults(SysAllocString(L"Waiting for 100 ms"), FALSE);
00597           Sleep(100);
00598         }
00599
00600
00601       }
00602
00603     }
00604     if (pAccount)
00605     {
00606
00607       int nAmount = pTd -> nAmount;
00608       if (pTd -> nTranType == DEBIT)
00609         nAmount = -1  * nAmount;
00610
00611       if (pTd -> bRandom)
00612       {
00613         if (!g_nRows)
00614         {
00615           ShowResults(SysAllocString(L"Put in a valid number of rows you dweeb!"), TRUE);
00616           g_bStop = TRUE;
00617         }
00618         else
00619         {
00620           nTo = RandInt(g_nRows); // nTo==nFrom legal?
00621           nTo++;
00622         }
00623       }
00624       QueryPerformanceCounter( &start);
00625       hr = pAccount -> Post(nTo, nAmount, &sResult);
00626       QueryPerformanceCounter( &stop);
00627       if (pTd -> bChatty)
00628       {
00629         wsprintf(sz, L"Account Post took %d ms", 1000*(stop.QuadPart-start.QuadPart)/g_PerfFreq.QuadPart);
00630         ShowResults(SysAllocString(sz), FALSE);
00631       }
00632       if (hr)
00633       {
00634         GetErrorInfo(NULL, &pInfo);
00635         if( pInfo )
00636         {
00637           pInfo -> GetDescription(&sResult);
00638           pInfo -> Release();
00639         }
00640         if (g_bAssertOnErrors)
00641           _ASSERTE(0);
00642         if (hr == E_UNEXPECTED && g_bStopOnODBCErrors) // E_UNEXPECTED returned on ODBC errors
00643         {
00644           if (!g_bRetry)
00645               bLocalStop = TRUE;
00646           else // retry for wolfpack
00647           {
00648             if (pAccount)
00649             {
00650               pAccount -> Release();
00651               pAccount = NULL;
00652             }
00653           }
00654
00655         }
00656         else  // non-ODBC error
00657         {
00658           if (!g_bRetry)
00659             g_bStop = TRUE;
00660           else // retry for wolfpack
00661           {
00662             if (pAccount)
00663             {
00664               pAccount -> Release();
00665               pAccount = NULL;
00666             }
00667           }
00668
00669         }
00670         if (!sResult || SysStringLen(sResult) == 0)
00671         {
00672           SysFreeString(sResult);
00673           if (hr == E_ACCESSDENIED)
00674             sResult = ::SysAllocString(L"Call failed due to security violation ");
00675           else
00676             sResult = ::SysAllocString(L"Call failed ");
00677         }
00678         wsprintf(sz, L"%s HRESULT: 0x%lx", sResult, hr);
00679         ShowResults(SysAllocString(sz), TRUE);
00680         SysFreeString(sResult); // not posting it
00681
00682       }
00683       else
00684       {
00685
00686         if (pTd -> bChatty)
00687         {
00688           ShowResults(sResult, FALSE);
00689         }
00690       }
00691
00692       if (pTd -> bCreatePerIteration && pAccount)
00693       {
00694         pAccount -> Release();
00695         pAccount = NULL;
00696       }
00697     }
00698
00699     nCount++;
00700   }
00701
00702   if (pAccount)
00703   {
00704     pAccount -> Release();
00705     pAccount = NULL;
00706   }
00707
00708   float t = (GetTickCount() - (float)liStartTime)  / 1000;
00709   _snwprintf(sz,MSG_BUF_SIZE, L"Done.  Time: %2.4f seconds for %ld iterations", t, nCount);
00710   ShowResults(SysAllocString(sz), FALSE);
00711   CoUninitialize();
00712   return 0;
00713
00714
00715 }
00716
00717
00718 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00719   Function: CreateSchemaThread
00720   Summary:  Creates the database in SQL Server
00721   Args:   LPVOID v    Reserved
00722   Returns:  DWORD
00723 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00724 DWORD WINAPI CreateSchemaThread( LPVOID v)
00725 {
00726   HENV henv = 0;
00727   HDBC hdbc = 0;
00728   HSTMT hstmt = 0;
00729   HRESULT hr= S_OK;
00730   BSTR sErr = NULL;
00731   WORD nSize = 255;
00732   hr = GetConnection(&henv, &hdbc, &hstmt);
00733   if (FAILED(hr))
00734   {
00735     ShowResults(SysAllocString(L"Done -- failed to get connection"), FALSE);
00736     return -1;
00737   }
00738
00739   CreateSchema(hstmt);
00740
00741
00742   if (hr != S_OK)
00743   {
00744     GetOdbcError(henv, hdbc, hstmt, &sErr);
00745     ShowResults(sErr, TRUE);
00746   }
00747   else
00748   {
00749     ShowResults(SysAllocString(L"Done creating schema"), FALSE);
00750   }
00751
00752
00753   if (hstmt)
00754   {
00755     SQLFreeStmt(hstmt, SQL_DROP);
00756   }
00757   if (hdbc)
00758   {
00759     SQLDisconnect(hdbc);
00760     SQLFreeConnect(hdbc);
00761   }
00762   if (henv)
00763     SQLFreeEnv(henv);
00764
00765   return 0;
00766 }
00767
00768
00769 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00770   Function: GetConnection
00771   Summary:  Get the ODBC connection to SQL Server
00772   Args:     WCHAR* sDsn     ODBC DSN to connect to
00773       HENV* phEnv     An ODBC environment handle
00774       HDBC* phdbc     An ODBC database connection handle
00775       HSTMT* phstmt   An ODBC statement handle
00776   Returns:  HRESULT
00777 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00778 HRESULT GetConnection(HENV  * phEnv, HDBC * phdbc, HSTMT * phstmt)
00779 {
00780   WCHAR * sDsn = L"FILEDSN=OPBankSamples;DATABASE=pubs;UID=sa;PWD=;APP=VC Bank";
00781   RETCODE rc;
00782   HRESULT hr= S_OK;
00783   BSTR sErr = NULL;
00784   rc = SQLAllocEnv(&*phEnv);
00785   ASSERT_SQL_SUCCESS(rc);
00786   BSTR s;
00787   s = SysAllocString(L"Getting Connection");
00788   ShowResults(s, FALSE);
00789   rc = SQLAllocConnect(*phEnv, phdbc);
00790   if (SQL_FAILED(rc))
00791   {
00792     GetOdbcError(*phEnv, *phdbc, *phstmt, &sErr);
00793     ShowResults(sErr, TRUE);
00794     return (DWORD)E_FAIL;
00795   }
00796   WCHAR szConn[255];
00797   WORD nSize = 255;
00798   rc = SQLDriverConnect(*phdbc, NULL, (SQLWCHAR *)sDsn, SQL_NTS, (SQLWCHAR *)szConn, 255, (short *)&nSize, (UWORD)SQL_DRIVER_NOPROMPT);
00799   if (SQL_FAILED(rc))
00800   {
00801     GetOdbcError(*phEnv, *phdbc, *phstmt, &sErr);
00802     ShowResults(sErr, TRUE);
00803     SQLFreeEnv(*phEnv);
00804     return (DWORD)E_FAIL;
00805   }
00806   rc = SQLAllocStmt(*phdbc, phstmt); // generic stmt
00807   if (SQL_FAILED(rc))
00808   {
00809     GetOdbcError(*phEnv, *phdbc, *phstmt, &sErr);
00810     ShowResults(sErr, TRUE);
00811     SQLFreeConnect(*phdbc);
00812     SQLFreeEnv(*phEnv);
00813     return (DWORD)E_FAIL;
00814   }
00815
00816   return S_OK;
00817 }
00818
00819
00820 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00821   Function: GetRowCount
00822   Summary:  Get the number of existing account rows in the database
00823   Args:     HSTMT hstmt     An ODBC statement handle
00824       long *pRowCount   Number of rows in database
00825   Returns:  HRESULT
00826 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00827 HRESULT GetRowCount(HSTMT hstmt, long * pRowCount)
00828 {
00829
00830   HRESULT hr;
00831   HENV henv = 0;
00832   HDBC hdbc = 0;
00833
00834   BOOL bGotConnection = FALSE;
00835   if (!hstmt)
00836   {
00837     hr = GetConnection(&henv, &hdbc, &hstmt);
00838     bGotConnection = TRUE;
00839     if (hr)
00840       return hr;
00841   }
00842
00843   //
00844   //  get the current number of rows
00845   //
00846
00847   int nRows = 0;
00848   long len = 0;
00849   RETCODE rc;
00850   ShowResults(SysAllocString(L"Getting Current Row Count"), FALSE);
00851   rc = SQLExecDirect(hstmt, L"select max(AccountNo) from VcAccount", SQL_NTS);
00852   while (SQLFetch(hstmt) == SQL_SUCCESS) // only get the first one for now
00853   {
00854
00855     rc = SQLGetData(hstmt, 1, SQL_C_LONG, &nRows, 0, &len);
00856     if (SQL_FAILED(rc))
00857     {
00858       BSTR sErr;
00859       GetOdbcError(henv, hdbc, hstmt, &sErr);
00860       ShowResults(sErr, TRUE);
00861     }
00862   }
00863
00864   *pRowCount = nRows;
00865   if (bGotConnection)
00866   {
00867     FreeConnection(henv, hdbc, hstmt);
00868   }
00869   else
00870   {
00871     SQLFreeStmt(hstmt, SQL_CLOSE);
00872   }
00873
00874   return S_OK;
00875 }
00876
00877
00878 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00879   Function: FreeConnection
00880   Summary:  Free the ODBC connection to SQL Server
00881   Args:     HENV henv     An ODBC environment handle
00882       HDBC hdbc     An ODBC database connection handle
00883       HSTMT hstmt     An ODBC statement handle
00884   Returns:  HRESULT
00885 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00886 HRESULT FreeConnection(HENV henv, HDBC hdbc, HSTMT hstmt)
00887 {
00888   ShowResults(SysAllocString(L"Freeing Connection"), FALSE);
00889
00890   if (hstmt)
00891     SQLFreeStmt(hstmt, SQL_DROP);
00892   if (hdbc)
00893   {
00894     SQLDisconnect(hdbc);
00895     SQLFreeConnect(hdbc);
00896   }
00897   if (henv)
00898     SQLFreeEnv(henv);
00899   return S_OK;
00900 }
00901
00902
00903 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00904   Function: VerifySchema
00905   Summary:  Verify that the database tables exist
00906   Args:     HENV henv     An ODBC environment handle
00907       HDBC hdbc     An ODBC database connection handle
00908       HSTMT hstmt     An ODBC statement handle
00909   Returns:  HRESULT
00910 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00911 HRESULT VerifySchema(HSTMT hstmt)
00912 {
00913   HRESULT hr = S_OK;
00914   BOOL bGotConnection = FALSE;
00915   HENV henv = 0;
00916   HDBC hdbc = 0;
00917   if (!hstmt)
00918   {
00919     hr = GetConnection(&henv, &hdbc, &hstmt);
00920     bGotConnection = TRUE;
00921     if (hr)
00922       return hr;
00923   }
00924
00925   ShowResults(SysAllocString(L"Verifying schema"), FALSE);
00926   int i;
00927   RETCODE rc;
00928   long nRowCount = 0;
00929   for (i=0;i< sizeof(sCheckSchema) / sizeof(sCheckSchema[0]); i++)
00930   {
00931     rc = SQLExecDirect(hstmt, sCheckSchema[i], SQL_NTS);
00932     if (SQL_FAILED(rc))
00933     {
00934       hr = E_FAIL;
00935       break;
00936     }
00937
00938     rc = SQLRowCount(hstmt, &nRowCount);
00939     if (nRowCount != 1)
00940     {
00941       hr = E_FAIL;
00942       break;
00943     }
00944   }
00945
00946
00947   if (bGotConnection)
00948   {
00949     FreeConnection(henv, hdbc, hstmt);
00950   }
00951   else
00952   {
00953     SQLFreeStmt(hstmt, SQL_CLOSE);
00954   }
00955
00956   return hr;
00957
00958 }
00959
00960
00961 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00962   Function: CreateRows
00963   Summary:  Inserts rows into the account table
00964   Args:     long nRows      Account number to populate up to
00965       HSTMT hstmt     An ODBC statement handle
00966   Returns:  HRESULT
00967 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00968 HRESULT CreateRows(long nRows, HSTMT hstmt)
00969 {
00970
00971   HENV henv = 0;
00972   HDBC hdbc = 0;
00973   HRESULT hr;
00974   BSTR sErr;
00975   BOOL bGotConnection = FALSE;
00976   RETCODE rc;
00977
00978   if (!hstmt)
00979   {
00980     hr = GetConnection(&henv, &hdbc, &hstmt);
00981     bGotConnection = TRUE;
00982     if (hr)
00983       return hr;
00984   }
00985
00986   //
00987   //  get the current rowcount
00988   //
00989
00990   long nCurRows = 0;
00991
00992   hr = GetRowCount(hstmt, &nCurRows);
00993   if (FAILED(hr))
00994     return hr;
00995
00996   WCHAR szSQL[64];
00997   wsprintf(szSQL, L"Current Row count is %d", nCurRows+1);
00998   ShowResults(SysAllocString(szSQL), FALSE);
00999   wsprintf(szSQL, L"setting rowcount to be %d", nRows);
01000   ShowResults(SysAllocString(szSQL), FALSE);
01001   if (nCurRows <= nRows)
01002   {
01003     int i;
01004     for (i=nCurRows+1; i<=nRows; i++)
01005     {
01006       wsprintf(szSQL, L"insert into VcAccount values (%i, '')", 100000);
01007       rc = SQLExecDirect(hstmt, szSQL, SQL_NTS);
01008       if (SQL_FAILED(rc))
01009       {
01010         GetOdbcError(0,0,hstmt,&sErr);
01011         ShowResults(sErr, TRUE);
01012         break;
01013       }
01014     }
01015   }
01016   else
01017   {
01018     ShowResults(SysAllocString(L"truncating rows"), FALSE);
01019     wsprintf(szSQL, L"delete from VcAccount where AccountNo > %d", nRows);
01020     rc = SQLExecDirect(hstmt, szSQL, SQL_NTS);
01021     if (SQL_FAILED(rc))
01022     {
01023       GetOdbcError(0,0,hstmt,&sErr);
01024       ShowResults(sErr, TRUE);
01025     }
01026   }
01027
01028
01029   ShowResults(SysAllocString(L"Done setting row count"), FALSE);
01030   if (bGotConnection)
01031   {
01032     FreeConnection(henv, hdbc, hstmt);
01033   }
01034   else
01035   {
01036     SQLFreeStmt(hstmt, SQL_CLOSE);
01037   }
01038
01039   return S_OK;
01040
01041 }
01042
01043
01044 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01045   Function: CreateSchema
01046   Summary:  Create the database tables
01047   Args:     HSTMT hstmt     An ODBC statement handle
01048   Returns:  HRESULT
01049 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01050 HRESULT CreateSchema(HSTMT hstmt)
01051 {
01052   HENV henv = 0;
01053   HDBC hdbc = 0;
01054   HRESULT hr;
01055   int i;
01056   RETCODE rc;
01057   BOOL bGotConnection = FALSE;
01058
01059   if (!hstmt)
01060   {
01061     hr = GetConnection(&henv, &hdbc, &hstmt);
01062     bGotConnection = TRUE;
01063     if (hr)
01064       return hr;
01065   }
01066   ShowResults(SysAllocString(L"Creating schema"), FALSE);
01067   for (i=0; i< sizeof(sCreateSchema)/sizeof(sCreateSchema[0]); i++)
01068   {
01069     rc = SQLExecDirect(hstmt, sCreateSchema[i], SQL_NTS);
01070     if (SQL_FAILED(rc))
01071     {
01072       _ASSERTE(0);
01073       ShowResults(SysAllocString(L"Failed to create schema!"), TRUE);
01074       break;
01075     }
01076   }
01077
01078   //
01079   //  we always need to add a row to the receipt table
01080
01081   SQLExecDirect(hstmt, L"insert into receipt values(0)", SQL_NTS);
01082
01083   if (bGotConnection)
01084   {
01085     FreeConnection(henv, hdbc, hstmt);
01086   }
01087   else
01088   {
01089     SQLFreeStmt(hstmt, SQL_CLOSE);
01090   }
01091
01092   return S_OK;
01093 }
01094
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRTCIncomingApp Member List

This is the complete list of members for CRTCIncomingApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CRTCIncomingApp() | CRTCIncomingApp |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CRTCIncomingApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:57:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminAuthenticationLevelOptions.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminAuthenticationLevelOptions.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminAuthenticationLevelOptions
00019
00020 public interface COMAdminAuthenticationLevelOptions
00021 {
00022   public static final int COMAdminAuthenticationDefault = 0;
00023   public static final int COMAdminAuthenticationNone = 1;
00024   public static final int COMAdminAuthenticationConnect = 2;
00025   public static final int COMAdminAuthenticationCall = 3;
00026   public static final int COMAdminAuthenticationPacket = 4;
00027   public static final int COMAdminAuthenticationIntegrity = 5;
00028   public static final int COMAdminAuthenticationPrivacy = 6;
00029 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/progress.h Source File

  • Dataaccess
  • oledb
  • tablecopy

progress.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module PROGRESS.H
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 #ifndef _PROGRESS_H_
00012 #define _PROGRESS_H_
00013
00014 //////////////////////////////////////////////////////////////////////
00015 // Includes
00016 //
00017 //////////////////////////////////////////////////////////////////////
00018 #include "wizard.h"
00019
00020
00021
00022 //////////////////////////////////////////////////////////////////////
00023 // CProgress
00024 //
00025 //////////////////////////////////////////////////////////////////////
00026 class CProgress : public CDialogBase
00027 {
00028 public:
00029
00030   //Constructors
00031   CProgress(HWND hWnd, HINSTANCE hInst);
00032   virtual ~CProgress();
00033
00034   //members
00035   static  BOOL WINAPI DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00036   virtual ULONG   Display();
00037   virtual ULONG   Destroy();
00038
00039   virtual BOOL SetHeading(WCHAR* pwszText);
00040   virtual BOOL SetText(WCHAR* pwszText);
00041
00042   virtual BOOL Update(WCHAR* pwszText);
00043   virtual BOOL Cancel();
00044
00045   //data
00046   BOOL    m_fCancel;
00047 };
00048
00049 #endif //_PROGRESS_H_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows.Net/cedebug.cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows.Net

cedebug.cpp

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 //  File:   cedebug.cpp
00007 //
00008 //  Contents: Debug support
00009 //
00010 //----------------------------------------------------------------------------
00011
00012 #include <pch.cpp>
00013
00014 #pragma hdrstop
00015
00016 #include "celib.h"
00017 #include <stdarg.h>
00018
00019
00020 //+-------------------------------------------------------------------------
00021 //
00022 //  Function:  ceDbgPrintf
00023 //
00024 //  Synopsis:  outputs debug info to stdout and debugger
00025 //
00026 //  Returns:   number of chars output
00027 //
00028 //--------------------------------------------------------------------------
00029
00030 int WINAPIV
00031 ceDbgPrintf(
00032     IN BOOL fDebug,
00033     IN LPCSTR lpFmt,
00034     ...)
00035 {
00036     va_list arglist;
00037     CHAR ach[4096];
00038     int cch = 0;
00039     HANDLE hStdOut;
00040     DWORD dwErr;
00041
00042     dwErr = GetLastError();
00043     if (fDebug)
00044     {
00045   __try
00046   {
00047       va_start(arglist, lpFmt);
00048       cch = _vsnprintf(ach, sizeof(ach), lpFmt, arglist);
00049       ach[ARRAYSIZE(ach)-1] = L'\0';
00050       va_end(arglist);
00051
00052       if (0 > cch)
00053       {
00054     strcpy(&ach[sizeof(ach) - 5], "...\n");
00055       }
00056
00057       if (!IsDebuggerPresent())
00058       {
00059     hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
00060     if (hStdOut != INVALID_HANDLE_VALUE)
00061     {
00062         fputs(ach, stdout);
00063         fflush(stdout);
00064     }
00065       }
00066       OutputDebugStringA(ach);
00067   }
00068   __except(EXCEPTION_EXECUTE_HANDLER)
00069   {
00070       // return failure
00071       cch = 0;
00072   }
00073     }
00074     SetLastError(dwErr);
00075     return(cch);
00076 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IWMIServices Member List

This is the complete list of members for IWMIServices, including all inherited members.
SetWbemServices(IWbemServices *pIWbemServicesIn) IWMIServices
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Recordset Member List

This is the complete list of members for msado15::Recordset, including all inherited members.
_xClone() | msado15::Recordset |
_xResync(int AffectRecords) | msado15::Recordset |
_xSave(String FileName, int PersistFormat) | msado15::Recordset |
AddNew(Variant FieldList, Variant Values) | msado15::Recordset |
Cancel() | msado15::Recordset |
CancelBatch(int AffectRecords) | msado15::Recordset |
CancelUpdate() | msado15::Recordset |
Clone(int LockType) | msado15::Recordset |
Close() | msado15::Recordset |
clsid | msado15::Recordset | [static]
CompareBookmarks(Variant Bookmark1, Variant Bookmark2) | msado15::Recordset |
Delete(int AffectRecords) | msado15::Recordset |
Find(String Criteria, int SkipRecords, int SearchDirection, Variant Start) | msado15::Recordset |
getAbsolutePage() | msado15::Recordset |
getAbsolutePosition() | msado15::Recordset |
getActiveCommand() | msado15::Recordset |
getActiveConnection() | msado15::Recordset |
getBOF() | msado15::Recordset |
getBookmark() | msado15::Recordset |
getCacheSize() | msado15::Recordset |
getCollect(Variant Index) | msado15::Recordset |
getCursorLocation() | msado15::Recordset |
getCursorType() | msado15::Recordset |
getDataMember() | msado15::Recordset |
getDataSource() | msado15::Recordset |
getEditMode() | msado15::Recordset |
getEOF() | msado15::Recordset |
getFields() | msado15::Recordset |
getFilter() | msado15::Recordset |
getIndex() | msado15::Recordset |
getLockType() | msado15::Recordset |
getMarshalOptions() | msado15::Recordset |
getMaxRecords() | msado15::Recordset |
getPageCount() | msado15::Recordset |
getPageSize() | msado15::Recordset |
getProperties() | msado15::Recordset |
getRecordCount() | msado15::Recordset |
GetRows(int Rows, Variant Start, Variant Fields) | msado15::Recordset |
getSort() | msado15::Recordset |
getSource() | msado15::Recordset |
getState() | msado15::Recordset |
getStatus() | msado15::Recordset |
getStayInSync() | msado15::Recordset |
GetString(int StringFormat, int NumRows, String ColumnDelimeter, String RowDelimeter, String NullExpr) | msado15::Recordset |
iid | msado15::Recordset | [static]
Move(int NumRecords, Variant Start) | msado15::Recordset |
MoveFirst() | msado15::Recordset |
MoveLast() | msado15::Recordset |
MoveNext() | msado15::Recordset |
MovePrevious() | msado15::Recordset |
NextRecordset(Variant RecordsAffected) | msado15::Recordset |
Open(Variant Source, Variant ActiveConnection, int CursorType, int LockType, int Options) | msado15::Recordset |
Requery(int Options) | msado15::Recordset |
Resync(int AffectRecords, int ResyncValues) | msado15::Recordset |
Save(Variant Destination, int PersistFormat) | msado15::Recordset |
Seek(Variant KeyValues, int SeekOption) | msado15::Recordset |
setAbsolutePage(int pl) | msado15::Recordset |
setAbsolutePosition(int pl) | msado15::Recordset |
setActiveConnection(Object pvar) | msado15::Recordset |
setActiveConnection(Variant pvar) | msado15::Recordset |
setBookmark(Variant pvBookmark) | msado15::Recordset |
setCacheSize(int pl) | msado15::Recordset |
setCollect(Variant Index, Variant pvar) | msado15::Recordset |
setCursorLocation(int plCursorLoc) | msado15::Recordset |
setCursorType(int plCursorType) | msado15::Recordset |
setDataMember(String pbstrDataMember) | msado15::Recordset |
setDataSource(IUnknown ppunkDataSource) | msado15::Recordset |
setFilter(Variant Criteria) | msado15::Recordset |
setIndex(String pbstrIndex) | msado15::Recordset |
setLockType(int plLockType) | msado15::Recordset |
setMarshalOptions(int peMarshal) | msado15::Recordset |
setMaxRecords(int plMaxRecords) | msado15::Recordset |
setPageSize(int pl) | msado15::Recordset |
setSort(String Criteria) | msado15::Recordset |
setSource(Object pvSource) | msado15::Recordset |
setSource(String pvSource) | msado15::Recordset |
setStayInSync(boolean pbStayInSync) | msado15::Recordset |
Supports(int CursorOptions) | msado15::Recordset |
Update(Variant Fields, Variant Values) | msado15::Recordset |
UpdateBatch(int AffectRecords) | msado15::Recordset |
Generated on Wed Nov 13 2024 16:58:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cmultipleresults.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cmultipleresults.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CMULTIPLERESULTS.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CMULTIPLERESULTS_H_
00012 #define _CMULTIPLERESULTS_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019
00020
00021 /////////////////////////////////////////////////////////////////
00022 // CMultipleResults
00023 //
00024 /////////////////////////////////////////////////////////////////
00025 class CMultipleResults : public CBase
00026 {
00027 public:
00028   //Constructors
00029   CMultipleResults(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00030   virtual ~CMultipleResults();
00031
00032   //IUnknown Helpers
00033   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00034   virtual HRESULT     AutoRelease();
00035   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00036
00037   //Pure Virtual
00038   virtual WCHAR*    GetObjectName()     { return L"MultipleResults";    }
00039   virtual UINT    GetObjectMenu()     { return IDM_MULTIPLERESULTSMENU; }
00040   virtual LONG    GetObjectImage()    { return IMAGE_MULTIPLE;      }
00041   virtual REFIID    GetDefaultInterface() { return IID_IMultipleResults;    }
00042
00043   //Members
00044   virtual HRESULT   GetResult(CAggregate* pCAggregate, DB_LRESERVE lResultFlag, REFIID riid, DBROWCOUNT* pcRowsAffected, IUnknown** ppIUnknown);
00045
00046   //MultipleResults
00047   //[MANADATORY]
00048   IMultipleResults* m_pIMultipleResults;
00049
00050   //[OPTIONAL]
00051
00052   //Data
00053 };
00054
00055
00056
00057
00058 #endif //_CROWSET_H_
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMallocSpy Member List

This is the complete list of members for CMallocSpy, including all inherited members.
AddToList(void *pv) | CMallocSpy | [virtual]
AddToList(void *pv) | CMallocSpy | [virtual]
CAllocList | CMallocSpy | [protected]
CAllocList | CMallocSpy | [private]
cbRequest | CMallocSpy |
cbRequest | CMallocSpy |
cbRequest | CMallocSpy |
CMallocSpy(void) | CMallocSpy |
CMallocSpy() | CMallocSpy |
CMallocSpy(void) | CMallocSpy |
DumpLeaks() | CMallocSpy | [virtual]
DumpLeaks() | CMallocSpy | [virtual]
fActual | CMallocSpy |
fActual | CMallocSpy |
fSpyed | CMallocSpy |
fSpyed | CMallocSpy |
fSpyed | CMallocSpy |
fSpyed | CMallocSpy |
fSpyed | CMallocSpy |
lpVtbl | CMallocSpy |
m_cAllocations | CMallocSpy | [protected]
m_cbRequest | CMallocSpy | [private]
m_cbRequest | CMallocSpy | [private]
m_cbRequested | CMallocSpy |
m_cRef | CMallocSpy | [private]
ppNewRequest | CMallocSpy |
ppNewRequest | CMallocSpy |
ppNewRequest | CMallocSpy |
QueryInterface(REFIID riid, LPVOID *ppUnk) | CMallocSpy |
QueryInterface(REFIID riid, void **ppIUnknown) | CMallocSpy | [virtual]
QueryInterface(REFIID riid, void **ppIUnknown) | CMallocSpy | [virtual]
Register() | CMallocSpy | [virtual]
RemoveFromList(void *pv) | CMallocSpy | [virtual]
RemoveFromList(void *pv) | CMallocSpy | [virtual]
Reset() | CMallocSpy | [virtual]
STDMETHOD_(ULONG, AddRef)(void) | CMallocSpy |
STDMETHOD_(ULONG, Release)(void) | CMallocSpy |
STDMETHOD_(SIZE_T, PreAlloc)(SIZE_T cbRequest) | CMallocSpy |
STDMETHOD_(void *, PostAlloc)(void *pActual) | CMallocSpy |
STDMETHOD_(void *, PreFree)(void *pRequest | CMallocSpy |
STDMETHOD_(void, PostFree)(BOOL fSpyed) | CMallocSpy |
STDMETHOD_(SIZE_T, PreRealloc)(void *pRequest | CMallocSpy |
STDMETHOD_(void *, PostRealloc)(void *pActual | CMallocSpy |
STDMETHOD_(void *, PreGetSize)(void *pRequest | CMallocSpy |
STDMETHOD_(SIZE_T, PostGetSize)(SIZE_T cbActual | CMallocSpy |
STDMETHOD_(void *, PreDidAlloc)(void *pRequest | CMallocSpy |
STDMETHOD_(BOOL, PostDidAlloc)(void *pRequest | CMallocSpy |
STDMETHOD_(void, PreHeapMinimize)(void) | CMallocSpy |
STDMETHOD_(void, PostHeapMinimize)(void) | CMallocSpy |
STDMETHODIMP_(ULONG) AddRef() | CMallocSpy | [virtual]
STDMETHODIMP_(ULONG) Release() | CMallocSpy | [virtual]
STDMETHODIMP_(SIZE_T) PreAlloc(SIZE_T cbRequest) | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PostAlloc(void *pActual) | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PreFree(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(void) PostFree(BOOL fSpyed) | CMallocSpy | [virtual]
STDMETHODIMP_(SIZE_T) PreRealloc(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PostRealloc(void *pActual | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PreGetSize(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(SIZE_T) PostGetSize(SIZE_T cbActual | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PreDidAlloc(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(BOOL) PostDidAlloc(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(void) PreHeapMinimize() | CMallocSpy | [virtual]
STDMETHODIMP_(void) PostHeapMinimize() | CMallocSpy | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CMallocSpy | [virtual]
STDMETHODIMP_(ULONG) Release() | CMallocSpy | [virtual]
STDMETHODIMP_(ULONG) PreAlloc(ULONG cbRequest) | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PostAlloc(void *pActual) | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PreFree(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(void) PostFree(BOOL fSpyed) | CMallocSpy | [virtual]
STDMETHODIMP_(ULONG) PreRealloc(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PostRealloc(void *pActual | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PreGetSize(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(ULONG) PostGetSize(ULONG cbActual | CMallocSpy | [virtual]
STDMETHODIMP_(void *) PreDidAlloc(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(BOOL) PostDidAlloc(void *pRequest | CMallocSpy | [virtual]
STDMETHODIMP_(void) PreHeapMinimize() | CMallocSpy | [virtual]
STDMETHODIMP_(void) PostHeapMinimize() | CMallocSpy | [virtual]
Unregister() | CMallocSpy | [virtual]
~CMallocSpy(void) | CMallocSpy |
~CMallocSpy() | CMallocSpy | [virtual]
~CMallocSpy(void) | CMallocSpy | [virtual]
Generated on Wed Nov 13 2024 16:56:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Range/callback.hpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Range

callback.hpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include <urlmon.h>
00018 #include "recvbuf.hpp"
00019 #include "range.h"
00020
00021 class CUrlmonCallback :
00022     public IBindStatusCallback,
00023     public IHttpNegotiate,
00024     public RecvBuf
00025 {
00026 public:
00027
00028     // IUnknown methods
00029     STDMETHODIMP    QueryInterface(REFIID riid,void ** ppv);
00030     STDMETHODIMP_(ULONG) AddRef(void);
00031     STDMETHODIMP_(ULONG) Release(void);
00032
00033   // IHttpNegotiate methods
00034   STDMETHODIMP BeginningTransaction (LPCWSTR szURL, LPCWSTR szHeaders,
00035         DWORD dwReserved, LPWSTR __RPC_FAR *pszAdditionalHeaders);
00036   STDMETHODIMP OnResponse (DWORD dwResponseCode, LPCWSTR szResponseHeaders,
00037         LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders);
00038
00039     // IBindStatusCallback methods
00040     STDMETHODIMP    OnStartBinding(DWORD grfBSCOption, IBinding* pBinding);
00041     STDMETHODIMP    GetPriority(LONG* pnPriority);
00042     STDMETHODIMP    OnLowResource(DWORD dwReserved);
00043     STDMETHODIMP    OnProgress(ULONG ulProgress, ULONG ulProgressMax,
00044         ULONG ulStatusCode, LPCWSTR pwzStatusText);
00045     STDMETHODIMP    OnStopBinding(HRESULT hrResult, LPCWSTR szError);
00046     STDMETHODIMP    GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo);
00047     STDMETHODIMP    OnDataAvailable(DWORD grfBSCF, DWORD dwSize,
00048         FORMATETC *pfmtetc, STGMEDIUM* pstgmed);
00049     STDMETHODIMP    OnObjectAvailable(REFIID riid, IUnknown* punk);
00050
00051     // constructors/destructors
00052     CUrlmonCallback (PHTTP_REQUEST_PARAM);
00053     ~CUrlmonCallback();
00054
00055     // read range processing functions
00056     BOOL ParseMultiPartHeader (void);
00057     HRESULT ParseMultiPartBuffer (BOOL fLastCall);
00058
00059     // data members
00060     DWORD           m_cRef;
00061     IBinding*       m_pBinding;
00062     IStream*        m_pstm;
00063     DWORD           m_dwOffset;
00064
00065     PHTTP_REQUEST_PARAM  m_pParam;  // initialization parameters
00066     HTTP_REQUESTCB_PARAM m_CBParam;
00067
00068     DWORD  m_dwResponseCode;
00069
00070     // range variables
00071     PSTR   m_pszRangeDelimiter;
00072     DWORD  m_cchRangeDelimiter;
00073     DWORD  m_dwRangeBeg;
00074     DWORD  m_dwRangeEnd;
00075 };
00076
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ColumnProvider/UnRegisterServer.Cpp Source File

  • WinUI
  • Shell
  • ColumnProvider

UnRegisterServer.Cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  UnregisterServer.cpp
00011 //
00012 //      Unregisters the Column Provider
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #include "ShortName.h"
00017 #include "Resource.h"
00018
00019 extern HINSTANCE hDllInstance;
00020
00021 STDAPI DllUnregisterServer (VOID)
00022 {
00023     HRESULT     hResult     = S_OK;
00024     LRESULT     lResult     = NOERROR;
00025     HKEY        hKey        = NULL;
00026     TCHAR       szClsid[MAX_PATH] = TEXT("");
00027     TCHAR       szSubKey[MAX_PATH] = TEXT("");
00028
00029     //
00030     //  Load some necessary string values
00031     //
00032     LoadString (hDllInstance, IDS_CLSID, szClsid, MAX_PATH);
00033
00034     //
00035     //  Delete the key HKCR\CLSID\{CLSID}\InprocServer32
00036     //
00037     wsprintf (szSubKey, TEXT("CLSID\\%s\\InprocServer32"), szClsid);
00038     lResult = RegDeleteKey (HKEY_CLASSES_ROOT, szSubKey);
00039     if (lResult != NOERROR)
00040     {
00041         hResult = SELFREG_E_CLASS;
00042     }
00043
00044     //
00045     //  Delete the key HKCR\CLSID\{CLSID}
00046     //
00047     wsprintf (szSubKey, TEXT("CLSID\\%s"), szClsid);
00048     lResult = RegDeleteKey (HKEY_CLASSES_ROOT, szSubKey);
00049     if (lResult != NOERROR)
00050     {
00051         hResult = SELFREG_E_CLASS;
00052     }
00053
00054     //
00055     //  Delete the key HKCR\Folder\shellex\ColumnHandlers\{CLSID}
00056     //
00057     LoadString (hDllInstance, IDS_REGKEY_COLUMNPROVIDER, szSubKey, MAX_PATH);
00058     StrCatBuff (szSubKey, TEXT("\\"), ARRAYSIZE(szSubKey));
00059     StrCatBuff (szSubKey, szClsid, ARRAYSIZE(szSubKey));
00060     lResult = RegDeleteKey (HKEY_CLASSES_ROOT, szSubKey);
00061     if (lResult != NOERROR)
00062     {
00063         hResult = SELFREG_E_CLASS;
00064     }
00065
00066     return hResult;
00067 }
00068
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Hello/Hellop.c Source File

  • NetDS
  • RPC
  • Hello

Hellop.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         Hello Example
00005
00006     FILE:       hellop.c
00007
00008     PURPOSE:    Remote procedures that are linked with the server
00009                 side of RPC distributed application
00010
00011     FUNCTIONS:  HelloProc() - prints "hello, world" or other string
00012                 sent by client to server
00013
00014     COMMENTS:   This version of the distributed application that prints
00015                 "hello, world" (or other string) on the server features
00016                 a client that manages its connection to the server.
00017                 It uses the binding handle hello_IfHandle, defined in
00018                 the file hello.h.
00019
00020 ****************************************************************************/
00021
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024 #include "hello.h"    // header file generated by MIDL compiler
00025
00026 void HelloProc(unsigned char * pszString)
00027 {
00028     printf("%s\n", pszString);
00029 }
00030
00031 void Shutdown(void)
00032 {
00033     RPC_STATUS status;
00034
00035     printf("Calling RpcMgmtStopServerListening\n");
00036     status = RpcMgmtStopServerListening(NULL);
00037     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00038     if (status) {
00039        exit(status);
00040     }
00041
00042     printf("Calling RpcServerUnregisterIf\n");
00043     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00044     printf("RpcServerUnregisterIf returned 0x%x\n", status);
00045     if (status) {
00046        exit(status);
00047     }
00048 }
00049
00050 /* end file hellop.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImp_DrawApp Member List

This is the complete list of members for CImp_DrawApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CImp_DrawApp() | CImp_DrawApp |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CImp_DrawApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/TextFx/GuidE.h Source File

  • Multimedia
  • Gdi
  • TextFx

GuidE.h

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1992 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \*****************************************************************************/
00010 /*****************************************************************************
00011  *                                       *
00012  *  GUIDE.H                                              *
00013  *                                       *
00014  *  PURPOSE:  Routines for reading and displaying guide lines        *
00015  *                                       *
00016  ****************************************************************************/
00017
00018 #define MAXGUIDESEGMENTS 1000  // Max number of segments to read from user
00019
00020 BOOL GetGuideLine(HWND, LPPOINT*, LPDWORD);
00021 BOOL ShowGuide(HDC, LPPOINT, DWORD);
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/GraphObj/Line.Cpp Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • GraphObj

Line.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 // Line.cpp : Implementation of CLine
00013 #include "stdafx.h"
00014 #include "GraphObj.h"
00015 #include "Line.h"
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CLine
00019
00020 STDMETHODIMP CLine::InterfaceSupportsErrorInfo(REFIID riid)
00021 {
00022   static const IID* arr[] =
00023   {
00024     &IID_ILine,
00025   };
00026   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00027   {
00028     if ( ::InlineIsEqualGUID(*arr[i], riid) )
00029
00030       return S_OK;
00031   }
00032   return S_FALSE;
00033 }
00034
00035 STDMETHODIMP CLine::get_x1(long * pVal)
00036 {
00037   *pVal = m_Line.x1;
00038   return S_OK;
00039 }
00040
00041 STDMETHODIMP CLine::put_x1(long newVal)
00042 {
00043   m_Line.x1 = newVal;
00044
00045   return S_OK;
00046 }
00047
00048 STDMETHODIMP CLine::get_y1(long * pVal)
00049 {
00050   *pVal = m_Line.y1;
00051
00052   return S_OK;
00053 }
00054
00055 STDMETHODIMP CLine::put_y1(long newVal)
00056 {
00057   m_Line.y1 = newVal;
00058
00059   return S_OK;
00060 }
00061
00062 STDMETHODIMP CLine::get_x2(long * pVal)
00063 {
00064   *pVal = m_Line.x2;
00065
00066   return S_OK;
00067 }
00068
00069 STDMETHODIMP CLine::put_x2(long newVal)
00070 {
00071   m_Line.x2 = newVal;
00072
00073   return S_OK;
00074 }
00075
00076 STDMETHODIMP CLine::get_y2(long * pVal)
00077 {
00078   *pVal = m_Line.y2;
00079
00080   return S_OK;
00081 }
00082
00083 STDMETHODIMP CLine::put_y2(long newVal)
00084 {
00085   m_Line.y2 = newVal;
00086
00087   return S_OK;
00088 }
00089
00090 STDMETHODIMP CLine::IMyPersistStreamImpl_Load(LPSTREAM pIStream)
00091 {
00092     ULONG           cb;
00093     HRESULT         hr;
00094
00095     if (NULL==pIStream)
00096         return ResultFromScode(E_POINTER);
00097     //
00098     // Read an object from the stream.
00099     //
00100     hr=pIStream->Read(&m_Line, sizeof(LINEDATA), &cb);
00101     if (FAILED(hr))
00102         return hr;
00103     if (sizeof(LINEDATA) != cb)
00104         return E_FAIL;
00105
00106   return NOERROR;
00107 }
00108
00109
00110
00111 STDMETHODIMP CLine::IMyPersistStreamImpl_Save(LPSTREAM pIStream, BOOL /* fClearDirty */)
00112 {
00113     ULONG           cb;
00114     HRESULT         hr;
00115
00116     if (NULL==pIStream)
00117         return ResultFromScode(E_POINTER);
00118
00119     //
00120     // Write an object into the stream.
00121     //
00122     hr=pIStream->Write(&m_Line, (ULONG)sizeof(LINEDATA), &cb);
00123
00124     if (FAILED(hr) || sizeof(LINEDATA)!=cb)
00125        return ResultFromScode(STG_E_WRITEFAULT);
00126
00127   return NOERROR;
00128 }
00129
00130
00131 STDMETHODIMP CLine::IMyPersistStreamImpl_GetSizeMax(ULARGE_INTEGER FAR* pcbSize)
00132 {
00133   pcbSize->LowPart = (DWORD)(sizeof(LINEDATA));
00134   pcbSize->HighPart = 0L;
00135   return NOERROR;
00136 }
00137
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpy/SpyCon.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpy

SpyCon.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "COMSpy.h"
00019 #include "ComSpyCtl.h"
00020 #include "SpyCon.h"
00021
00022 static LPTSTR gsSubKey = _T("Software\\Microsoft\\COMSpy");
00023 /////////////////////////////////////////////////////////////////////////////
00024 // CSpyCon
00025
00026
00027 STDMETHODIMP CSpyCon::Run()
00028 {
00029   RECT rcPos = { CW_USEDEFAULT, 0, 0, 0 };
00030   HMENU hMenu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MENU1));
00031   Create(GetDesktopWindow(), rcPos, _T("COM Spy"), WS_VISIBLE | WS_OVERLAPPEDWINDOW, 0, PtrToUint(hMenu));
00032   //
00033   //  Set the right icon
00034   //
00035   HICON hIcon = LoadIcon(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAIN));
00036   if (hIcon)
00037     SetIcon(hIcon, TRUE);
00038
00039   // create the spy control
00040   CoCreateInstance(CLSID_ComSpy, NULL, CLSCTX_INPROC, IID_IOleObject, (void**)&m_pOleObject);
00041   if (!m_pOleObject)
00042   {
00043     MessageBox(_T("CoCreateInstance failed"));
00044     return 0;
00045   }
00046   m_pOleObject->SetClientSite(this);
00047   m_pOleObject -> QueryInterface(IID_IComSpy, (void **)&m_pSpy);
00048   _ASSERTE(m_pSpy);
00049
00050 // get our window state from the registry
00051   HKEY hKey = NULL;
00052   DWORD dwDisp;
00053   LONG lRes = RegCreateKeyEx(HKEY_LOCAL_MACHINE, gsSubKey, NULL, NULL, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,  NULL,  &hKey, &dwDisp);
00054   if (hKey)
00055   {
00056
00057     DWORD dwType = REG_DWORD;
00058     DWORD dwSize = sizeof(m_wp.rcNormalPosition.left);
00059     lRes = RegQueryValueEx(hKey, _T("Left"), NULL, &dwType, (BYTE *)&m_wp.rcNormalPosition.left, &dwSize);
00060     lRes = RegQueryValueEx(hKey, _T("Top"), NULL, &dwType, (BYTE *)&m_wp.rcNormalPosition.top, &dwSize);
00061     lRes = RegQueryValueEx(hKey, _T("Right"), NULL, &dwType, (BYTE *)&m_wp.rcNormalPosition.right, &dwSize);
00062     lRes = RegQueryValueEx(hKey, _T("Bottom"), NULL, &dwType, (BYTE *)&m_wp.rcNormalPosition.bottom, &dwSize);
00063     lRes = RegQueryValueEx(hKey, _T("ShowWindow"), NULL, &dwType, (BYTE *)&m_wp.showCmd, &dwSize);
00064     //always on top option
00065     lRes = RegQueryValueEx(hKey, _T("AlwaysOnTop"), NULL, &dwType, (BYTE *)&m_bTopmost, &dwSize);
00066     m_bTopmost = 1 - m_bTopmost;
00067     BOOL bHandled;
00068     OnAlwaysOnTop(0,0,0,bHandled);
00069
00070     // save on exit
00071     lRes = RegQueryValueEx(hKey, _T("SaveOnExit"), NULL, &dwType, (BYTE *)&m_bSaveOnExit, &dwSize);
00072
00073     // get the stream from the registry
00074     dwType = REG_BINARY;
00075     lRes = RegQueryValueEx(hKey, _T("ControlProperties"), NULL, &dwType, NULL, &dwSize);
00076     if (lRes == ERROR_SUCCESS)
00077     {
00078       HGLOBAL hGlobal = GlobalAlloc(GPTR, dwSize);
00079       BYTE * pByte = (BYTE *)GlobalLock(hGlobal);
00080       lRes = RegQueryValueEx(hKey, _T("ControlProperties"), NULL, &dwType, (BYTE *)pByte, &dwSize);
00081       GlobalUnlock(hGlobal);
00082       IStream * pStream;
00083       CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
00084
00085       CComQIPtr<IPersistStreamInit, &IID_IPersistStreamInit> pPersist(m_pSpy);
00086       _ASSERTE(pPersist.p);
00087
00088       if (pPersist != NULL)
00089       {
00090         pPersist -> Load(pStream);
00091
00092       }
00093       pStream -> Release();
00094     }
00095   }
00096
00097
00098   if (!( ( m_wp.rcNormalPosition.right - m_wp.rcNormalPosition.left < 10) && (m_wp.rcNormalPosition.bottom - m_wp.rcNormalPosition.top < 10)))
00099     SetWindowPlacement(&m_wp);
00100   else
00101     ShowWindow(SW_SHOWNORMAL);
00102
00103   GetClientRect(&rcPos);
00104   MSG msg;
00105   m_pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, m_hWnd, &rcPos);
00106   return S_OK;
00107 }
00108
00109 //
00110 //  show the select filter dialog
00111 //
00112 LRESULT CSpyCon::OnSelectFilter(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00113 {
00114   _ASSERTE(m_pSpy);
00115   m_pSpy->SelectApplications();
00116   return 0;
00117 }
00118 //
00119 //  the user clicks on the system menu
00120 //
00121 LRESULT CSpyCon::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00122 {
00123
00124   bHandled = FALSE; // always do default processing
00125
00126   if (wParam == SC_CLOSE)
00127     OnExit(NULL, NULL, NULL, bHandled);
00128
00129
00130   return 0;
00131 }
00132 //
00133 //  sets a glog to log to file
00134 //  if the user hasn't chosen a log file, show the common dialog to allow them to select one
00135 //
00136 LRESULT CSpyCon::OnLogToFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00137 {
00138
00139   _ASSERTE(m_pSpy);
00140   BOOL bVal;
00141   m_pSpy -> get_LogToFile(&bVal);
00142   bVal = 1 - bVal;
00143   m_pSpy -> put_LogToFile(bVal);
00144   return 0;
00145 }
00146 //
00147 //  User wants to choose a log file -- show the common dialog
00148 //
00149 LRESULT CSpyCon::OnChooseLogFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00150 {
00151   CComBSTR sFileName;
00152   BOOL bCanceled;
00153   m_pSpy -> ChooseLogFile(&sFileName, &bCanceled);
00154   return 0;
00155
00156 }
00157 //
00158 //  toggle the save on exit flag
00159 //
00160 LRESULT CSpyCon::OnToggleSaveOnExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00161
00162 {
00163   m_bSaveOnExit = 1 - m_bSaveOnExit;
00164   //
00165   //  the UI semantics are odd here...if you have this selected, and deselect it
00166   //  the fact you deselected it won't be saved (you have to click on "Save Now"
00167   //  so I'm going to always write what you choose to the registry if you deselect it
00168
00169   if (FALSE == m_bSaveOnExit)
00170   {
00171     HKEY hKey = NULL;
00172     DWORD dwDisp;
00173     LONG lRes = RegCreateKeyEx(HKEY_LOCAL_MACHINE, gsSubKey, NULL, NULL, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,  NULL,  &hKey, &dwDisp);
00174     if (hKey)
00175     {
00176       lRes = RegSetValueEx(hKey, _T("SaveOnExit"), NULL, REG_DWORD, (BYTE *)&m_bSaveOnExit, sizeof(BOOL));
00177       RegCloseKey(hKey);
00178     }
00179   }
00180
00181   return 0;
00182
00183 }
00184 //
00185 //  toggle the show on screen flag
00186 //
00187 LRESULT CSpyCon::OnToggleShowOnScreen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00188 {
00189   _ASSERTE(m_pSpy);
00190   BOOL bVal;
00191   m_pSpy -> get_ShowOnScreen(&bVal);
00192   bVal = 1 - bVal;
00193   m_pSpy -> put_ShowOnScreen(bVal);
00194   return 0;
00195
00196 }
00197 //
00198 //  update the UI in menus
00199 //
00200 LRESULT CSpyCon::OnInitMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00201 {
00202
00203   HMENU hMenu = (HMENU)wParam;
00204   CComBSTR temp = "&Log to File ";
00205   CComBSTR sFileName;
00206   m_pSpy -> get_LogFile(&sFileName);
00207   if (sFileName.Length() > 5)
00208     temp += sFileName;
00209   else
00210     temp = "&Log To file...";
00211
00212   USES_CONVERSION;
00213   ModifyMenu(hMenu, ID_LOG, MF_BYCOMMAND|MF_STRING, ID_LOG, OLE2T(temp));
00214   BOOL bVal;
00215   m_pSpy -> get_LogToFile(&bVal);
00216   CheckMenuItem(hMenu, ID_LOG,   bVal ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00217   m_pSpy -> get_ShowGridLines(&bVal);
00218   CheckMenuItem(hMenu, ID_OPTIONS_GRID_LINES,  bVal ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00219   m_pSpy -> get_ShowOnScreen(&bVal);
00220   CheckMenuItem(hMenu, ID_SHOW_ON_SCREEN,  bVal ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00221   CheckMenuItem(hMenu, IDM_ON_TOP,  m_bTopmost ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00222   CheckMenuItem(hMenu, ID_SAVE_ON_EXIT,  m_bSaveOnExit ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00223
00224   return 0;
00225 }
00226
00227 //
00228 //  show/hide gridlines in the list
00229 //
00230 //  NOTE:  This will only work if the user has installed IE 3.0 or greater
00231 //
00232 LRESULT CSpyCon::OnToggleGridLines(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00233 {
00234
00235   _ASSERTE(m_pSpy);
00236   BOOL bVal;
00237   m_pSpy -> get_ShowGridLines(&bVal);
00238   bVal = 1 - bVal;
00239   m_pSpy -> put_ShowGridLines(bVal);
00240   return 0;
00241 }
00242 //
00243 //  Toggle the Always on top option
00244 //
00245 LRESULT CSpyCon::OnAlwaysOnTop(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00246 {
00247
00248   m_bTopmost = 1 - m_bTopmost;
00249   if (m_bTopmost)
00250     SetWindowPos(HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
00251   else
00252     SetWindowPos(HWND_NOTOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
00253   return 0;
00254 }
00255 //
00256 //  show the standard Shell About box
00257 //
00258 LRESULT CSpyCon::OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00259 {
00260   m_pSpy -> About();
00261   return 0;
00262 }
00263 //
00264 //  pick the font to use in the list
00265 //
00266 LRESULT CSpyCon::OnChooseFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00267 {
00268   m_pSpy -> ChooseFont();
00269   return 0;
00270 }
00271 //
00272 //  called on a WM_CLOSE & WM_SYSCOMMAND (SC_CLOSE) message.  If appropriate, save settings
00273 //  and then destroy the window
00274 //
00275 LRESULT CSpyCon::OnExit(WORD /*wNotifyCode*/, WORD /* wID */, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00276 {
00277   if (m_bSaveOnExit)
00278     SaveSettings();
00279   m_pOleObject->Close(OLECLOSE_NOSAVE);
00280   SafeRelease(m_pOleObject);
00281   SafeRelease(m_pSpy);
00282   DestroyWindow();
00283   return 0;
00284 }
00285
00286 //
00287 //  save current settings to the registyr
00288 //
00289 LRESULT CSpyCon::OnSaveNow(WORD /*wNotifyCode*/, WORD /* wID */, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00290 {
00291   SaveSettings();
00292   return 0;
00293 }
00294
00295
00296 //
00297 //  clear the list box
00298 //
00299 LRESULT CSpyCon::OnClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00300 {
00301   m_pSpy -> ClearAllEvents();
00302   return 0;
00303 }
00304
00305
00306 //
00307 //  save the items in the list box to the log file
00308 //
00309 LRESULT CSpyCon::OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00310 {
00311   m_pSpy -> SaveToFile();
00312   return 0;
00313
00314 }
00315 //
00316 //  saves settings.  asks the control fro a stream to save its state
00317 //
00318 HRESULT CSpyCon::SaveSettings()
00319 {
00320   _ASSERTE(m_pSpy);
00321   if(!m_pSpy)
00322     return E_UNEXPECTED;
00323   HKEY hKey = NULL;
00324   DWORD dwDisp;
00325   LONG lRes = RegCreateKeyEx(HKEY_LOCAL_MACHINE, gsSubKey, NULL, NULL, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,  NULL,  &hKey, &dwDisp);
00326   if (hKey)
00327   {
00328     lRes = RegSetValueEx(hKey, _T("Left"), NULL, REG_DWORD, (BYTE *)&m_wp.rcNormalPosition.left, sizeof(m_wp.rcNormalPosition.left));
00329     lRes = RegSetValueEx(hKey, _T("Top"), NULL, REG_DWORD, (BYTE *)&m_wp.rcNormalPosition.top, sizeof(m_wp.rcNormalPosition.left));
00330     lRes = RegSetValueEx(hKey, _T("Right"), NULL, REG_DWORD, (BYTE *)&m_wp.rcNormalPosition.right, sizeof(m_wp.rcNormalPosition.left));
00331     lRes = RegSetValueEx(hKey, _T("Bottom"), NULL, REG_DWORD, (BYTE *)&m_wp.rcNormalPosition.bottom, sizeof(m_wp.rcNormalPosition.left));
00332     lRes = RegSetValueEx(hKey, _T("ShowWindow"), NULL, REG_DWORD, (BYTE *)&m_wp.showCmd, sizeof(BOOL));
00333     lRes = RegSetValueEx(hKey, _T("AlwaysOnTop"), NULL, REG_DWORD, (BYTE *)&m_bTopmost, sizeof(BOOL));
00334     lRes = RegSetValueEx(hKey, _T("SaveOnExit"), NULL, REG_DWORD, (BYTE *)&m_bSaveOnExit, sizeof(BOOL));
00335
00336
00337     CComQIPtr<IPersistStreamInit, &IID_IPersistStreamInit> pPersist(m_pSpy);
00338     _ASSERTE(pPersist.p);
00339     IStream * pStream;
00340     CreateStreamOnHGlobal(NULL, TRUE, &pStream);
00341     if (pPersist != NULL)
00342     {
00343       pPersist -> Save(pStream, TRUE);
00344       HGLOBAL hGlobal;
00345       GetHGlobalFromStream(pStream, &hGlobal);
00346       BYTE * pStByte = (BYTE *)GlobalLock(hGlobal);
00347       SIZE_T dwSize = GlobalSize(hGlobal);
00348       lRes = RegSetValueEx(hKey, _T("ControlProperties"), NULL, REG_BINARY, (BYTE *)pStByte, (DWORD) dwSize);
00349       GlobalUnlock(hGlobal);
00350
00351     }
00352     pStream -> Release();
00353     RegCloseKey(hKey);
00354   }
00355   return S_OK;
00356 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cdatalinks.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cdatalinks.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CDATALINKS.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CDATALINKS_H_
00012 #define _CDATALINKS_H_
00013
00014
00015 ///////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 ///////////////////////////////////////////////////////////////
00019
00020
00021
00022
00023 /////////////////////////////////////////////////////////////////
00024 // CServiceComp class
00025 //
00026 /////////////////////////////////////////////////////////////////
00027 class CServiceComp : public CBase
00028 {
00029 public:
00030   //Constructors
00031   CServiceComp(CMainWindow* pCMainWindow);
00032   virtual ~CServiceComp();
00033
00034   //IUnknown Helpers
00035   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00036   virtual HRESULT     AutoRelease();
00037   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00038
00039   //Pure Virtual
00040   virtual WCHAR*      GetObjectName()     { return L"Service Components"; }
00041   virtual UINT      GetObjectMenu()     { return IDM_SERVICECOMPMENU; }
00042   virtual LONG      GetObjectImage()    { return IMAGE_SERVICECOMP;   }
00043   virtual REFIID      GetDefaultInterface() { return IID_IDataInitialize; }
00044   virtual void      OnDefOperation();
00045
00046   //Helpers
00047   virtual HRESULT     Create(CBase* pCSource, DWORD dwCSLCTX = CLSCTX_INPROC_SERVER, WCHAR* pwszRemoteServer = NULL);
00048
00049   //IDataInitialize
00050   virtual HRESULT     CreateDBInstance(REFCLSID clsid, CAggregate* pCAggregate, DWORD dwCLSCTX, REFIID riid, IUnknown** ppIUnknown);
00051   virtual HRESULT     GetDataSource(CAggregate* pCAggregate, DWORD dwCLSCTX, WCHAR* pwszInitString, REFIID riid, IUnknown** ppIUnknown);
00052   virtual HRESULT     GetInitString(IUnknown* pIUnknown, boolean fIncludePassword, WCHAR** ppwszInitString);
00053   virtual HRESULT     SaveInitString(WCHAR* pwszFileName, WCHAR* pwszInitString, DWORD dwCreateOpts = CREATE_ALWAYS);
00054   virtual HRESULT     LoadInitString(WCHAR* pwszFileName, WCHAR** pwszInitString = NULL);
00055
00056   //Helpers
00057   virtual HRESULT     ConnectFromFile(WCHAR* pwszInitString);
00058
00059
00060   //Data
00061   WCHAR*              m_pwszInitString;
00062
00063   //OLE DB Interfaces
00064   //[MANADATORY]
00065   IDataInitialize*        m_pIDataInitialize;       //DataLink interface
00066
00067   //[OPTIONAL]
00068
00069   //Extra interfaces
00070 };
00071
00072
00073
00074 /////////////////////////////////////////////////////////////////
00075 // CDataLinks class
00076 //
00077 /////////////////////////////////////////////////////////////////
00078 class CDataLinks : public CBase
00079 {
00080 public:
00081   //Constructors
00082   CDataLinks(CMainWindow* pCMainWindow);
00083   virtual ~CDataLinks();
00084
00085   //IUnknown Helpers
00086   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00087   virtual HRESULT     AutoRelease();
00088   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00089
00090   //Pure Virtual
00091   virtual WCHAR*      GetObjectName()     { return L"Data Links";       }
00092   virtual UINT      GetObjectMenu()     { return IDM_DATALINKSMENU;     }
00093   virtual LONG      GetObjectImage()    { return IMAGE_DATALINKS;     }
00094   virtual REFIID      GetDefaultInterface() { return IID_IDBPromptInitialize; }
00095   virtual void      OnDefOperation();
00096
00097   //Helpers
00098   virtual HRESULT     Create(CBase* pCSource, DWORD dwCSLCTX = CLSCTX_INPROC_SERVER, WCHAR* pwszRemoteServer = NULL);
00099
00100   //IDBPromptInitialize
00101   virtual HRESULT     PromptDataSource(CAggregate* pCAggregate, HWND hWndParent, DBPROMPTOPTIONS dwPromptOptions, ULONG cTypeFilters, DBSOURCETYPE* rgTypeFilters, WCHAR* pwszProvFilter, REFIID riid, IUnknown** ppDataSource);
00102   virtual HRESULT     PromptFileName(HWND hWndParent, DBPROMPTOPTIONS dwPromptOptions, WCHAR* pwszDirectory, WCHAR* pwszFileName, WCHAR** ppwszSelectedFile);
00103
00104   //OLE DB Interfaces
00105   //[MANADATORY]
00106   IDBPromptInitialize*  m_pIDBPromptInitialize;     //DataLink interface
00107
00108   //[OPTIONAL]
00109 };
00110
00111
00112 #endif  //_CDATALINKS_H_
Generated on Wed Nov 13 2024 16:52:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinNT/HalfTone/halftone.c Source File

  • Multimedia
  • Gdi
  • WinNT
  • HalfTone

halftone.c

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *
00003 *       THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *       ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *       TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 *       PARTICULAR PURPOSE.
00007 *
00008 *       Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 *
00010 \*****************************************************************************/
00011
00012 /*****************************************************************************
00013  *                                                                           *
00014  *   PROGRAM: HalfTone.c                                                     *
00015  *                                                                           *
00016  *   PURPOSE: Demonstrate halftone stretching capabilities of Windows NT     *
00017  *                                                                           *
00018  *   FUNCTIONS:                                                              *
00019  *                                                                           *
00020  *   GetLastErrorBox() - Report GetLastError() values as text                *
00021  *   WinMain() - calls initialization function, processes message loop       *
00022  *   InitApplication() - initializes window data and registers window        *
00023  *   InitInstance() - saves instance handle and creates main window          *
00024  *   WndProc() - processes messages                                          *
00025  *   CenterWindow() - used to center the "About" box over application window *
00026  *   About() - processes messages for "About" dialog box                     *
00027  *                                                                           *
00028  *****************************************************************************/
00029
00030 #include <windows.h>   // required for all Windows applications
00031 #include <commctrl.h>
00032 #include <commdlg.h>
00033 #include <strsafe.h>
00034 #include "resource.h"   // specific to this program
00035
00036 HINSTANCE hInst;          // current instance
00037 HICON hIcon = NULL;
00038 HANDLE ghWnd;
00039 COLORADJUSTMENT caHalf;
00040 HWND hWndMain;
00041
00042 char szAppName[] = "HalfTone";   // The name of this application
00043 char szTitle[]   = "Halftone Stretching Demo"; // The title bar text
00044
00045 BOOL InitApplication(HANDLE);
00046 BOOL InitInstance(HANDLE, int);
00047 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
00048 LRESULT CALLBACK About  (HWND, UINT, WPARAM, LPARAM);
00049
00050
00051 /*****************************************************************************
00052  *                                                                           *
00053  * FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)                       *
00054  *                                                                           *
00055  * PURPOSE: calls initialization function, processes message loop            *
00056  *                                                                           *
00057  * COMMENTS:                                                                 *
00058  *                                                                           *
00059  *    Windows recognizes this function by name as the initial entry point    *
00060  *    for the program.  This function calls the application initialization   *
00061  *    routine, if no other instance of the program is running, and always    *
00062  *    calls the instance initialization routine.  It then executes a message *
00063  *    retrieval and dispatch loop that is the top-level control structure    *
00064  *    for the remainder of execution.  The loop is terminated when a WM_QUIT *
00065  *    message is received, at which time this function exits the application *
00066  *    instance by returning the value passed by PostQuitMessage().           *
00067  *                                                                           *
00068  *    If this function must abort before entering the message loop, it       *
00069  *    returns the conventional value NULL.                                   *
00070  *                                                                           *
00071  ****************************************************************************/
00072 int APIENTRY WinMain(
00073         HINSTANCE hInstance,
00074         HINSTANCE hPrevInstance,
00075         LPSTR lpCmdLine,
00076         int nCmdShow)
00077 {
00078     MSG msg;
00079     HANDLE hAccelTable;
00080
00081     if (!hPrevInstance) {       // Other instances of app running?
00082             if (!InitApplication(hInstance)) { // Initialize shared things
00083             return (FALSE);     // Exits if unable to initialize
00084         }
00085     }
00086
00087     /* Perform initializations that apply to a specific instance */
00088
00089     if (!InitInstance(hInstance, nCmdShow)) {
00090             return (FALSE);
00091     }
00092
00093     hAccelTable = LoadAccelerators (hInstance, "HALFTONE");
00094
00095     /* Acquire and dispatch messages until a WM_QUIT message is received. */
00096
00097     while (GetMessage(&msg, // message structure
00098        NULL,   // handle of window receiving the message
00099        0,      // lowest message to examine
00100        0))     // highest message to examine
00101     {
00102         if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg)) {
00103             TranslateMessage(&msg);// Translates virtual key codes
00104             DispatchMessage(&msg); // Dispatches message to window
00105         }
00106     }
00107
00108     return (msg.wParam); // Returns the value from PostQuitMessage
00109
00110     UNREFERENCED_PARAMETER(lpCmdLine); // This will prevent 'unused formal parameter' warnings
00111 }
00112
00113
00114 /*****************************************************************************
00115  *                                                                           *
00116  *  FUNCTION: InitApplication(HINSTANCE)                                     *
00117  *                                                                           *
00118  *  PURPOSE: Initializes window data and registers window class              *
00119  *                                                                           *
00120  *  COMMENTS:                                                                *
00121  *                                                                           *
00122  *    This function is called at initialization time only if no other        *
00123  *    instances of the application are running.  This function performs      *
00124  *    initialization tasks that can be done once for any number of running   *
00125  *    instances.                                                             *
00126  *                                                                           *
00127  *    In this case, we initialize a window class by filling out a data       *
00128  *    structure of type WNDCLASS and calling the Windows RegisterClass()     *
00129  *    function.  Since all instances of this application use the same window *
00130  *    class, we only need to do this when the first instance is initialized. *
00131  *                                                                           *
00132  *****************************************************************************/
00133 BOOL InitApplication(HINSTANCE hInstance)
00134 {
00135     WNDCLASS  wc;
00136
00137     // Fill in window class structure with parameters that describe the
00138     // main window.
00139
00140     wc.style         = CS_VREDRAW | CS_HREDRAW;  // Class style(s).
00141     wc.lpfnWndProc   = (WNDPROC)WndProc;       // Window Procedure
00142     wc.cbClsExtra    = 0;                      // No per-class extra data.
00143     wc.cbWndExtra    = 0;                      // No per-window extra data.
00144     wc.hInstance     = hInstance;              // Owner of this class
00145     wc.hIcon         = LoadIcon (hInstance, "HT_ICON"); // Icon name from .RC
00146     wc.hCursor       = LoadCursor(NULL, IDC_ARROW); // Cursor
00147     wc.hbrBackground = GetStockObject(NULL_BRUSH);
00148     wc.lpszMenuName  = "HT_MENU";              // Menu name from .RC
00149     wc.lpszClassName = szAppName;              // Name to register as
00150
00151     // Register the window class and return success/failure code.
00152     return (RegisterClass(&wc));
00153 }
00154
00155
00156 /*****************************************************************************
00157  *                                                                           *
00158  *   FUNCTION:  InitInstance(HINSTANCE, int)                                 *
00159  *                                                                           *
00160  *   PURPOSE:  Saves instance handle and creates main window                 *
00161  *                                                                           *
00162  *   COMMENTS:                                                               *
00163  *                                                                           *
00164  *      This function is called at initialization time for every instance of *
00165  *      this application.  This function performs initialization tasks that  *
00166  *      cannot be shared by multiple instances.                              *
00167  *                                                                           *
00168  *      In this case, we save the instance handle in a static variable and   *
00169  *      create and display the main program window.                          *
00170  *                                                                           *
00171  ****************************************************************************/
00172 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00173 {
00174     HWND            hWnd; // Main window handle.
00175
00176     // Save the instance handle in static variable, which will be used in
00177     // many subsequence calls from this application to Windows.
00178
00179     hInst = hInstance; // Store instance handle in our global variable
00180
00181     // Create a main window for this application instance.
00182     hWndMain =
00183     hWnd = CreateWindow(
00184             szAppName,           // See RegisterClass() call.
00185             szTitle,             // Text for window title bar.
00186             WS_OVERLAPPEDWINDOW,// Window style.
00187             CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, // Use default positioning
00188             NULL,                // Overlapped windows have no parent.
00189             NULL,                // Use the window class menu.
00190             hInstance,           // This instance owns this window.
00191             NULL                 // We don't use any data in our WM_CREATE
00192     );
00193
00194     // If window could not be created, return "failure"
00195     if (!hWnd) {
00196             return (FALSE);
00197     }
00198
00199     // Make the window visible; update its client area; and return "success"
00200     ShowWindow(hWnd, nCmdShow); // Show the window
00201     UpdateWindow(hWnd);         // Sends WM_PAINT message
00202
00203     return (TRUE);              // We succeeded...
00204
00205 }
00206
00207 #define GetControlScrollPos(hDlg, uBar) SendMessage(GetDlgItem(hDlg, uBar), TBM_GETPOS, (WPARAM)0, (LPARAM)0)
00208 #define SetSliderPos(hSld, iPos) SendMessage(hSld, TBM_SETPOS, (WPARAM)TRUE, (LONG)iPos)
00209
00210 void SetupControls(HWND hDlg, UINT uBar, UINT uEdit, int iMin, int iMax, int iPos, BOOL bScale)
00211 {
00212     HWND hWndTrack = GetDlgItem(hDlg, uBar);
00213
00214     if (!hWndTrack) return;
00215
00216     SendMessage(hWndTrack, TBM_SETRANGE, TRUE, MAKELONG((short)iMin, (short)iMax));
00217     SendMessage(hWndTrack, TBM_SETTICFREQ, ((iMax-iMin) / 50)+1, (LPARAM)0);
00218
00219     SetSliderPos(hWndTrack, iPos);
00220
00221     if (bScale) iPos *=10;
00222
00223     SetDlgItemInt(hDlg, uEdit, iPos, TRUE);
00224 }
00225
00226
00227 BOOL CALLBACK HalftoneDialog (HWND hDlg,        /* window handle of the dialog box */
00228                               UINT message,     /* type of message */
00229                               WPARAM uParam,    /* message-specific information */
00230                               LPARAM lParam)
00231 {
00232   BOOL bError;
00233   static COLORADJUSTMENT caOld = {0};
00234   static BOOL bUpdate = TRUE;
00235
00236   switch (message) {
00237   case WM_INITDIALOG:           /* message: initialize dialog box */
00238     // Store the old copy so that we can cancel out
00239     caOld = caHalf;
00240
00241     CheckDlgButton(hDlg, IDC_UPDATE, bUpdate);
00242
00243     SendDlgItemMessage (hDlg, IDC_FLAGS, CB_ADDSTRING, 0, (LPARAM) "None");
00244     SendDlgItemMessage (hDlg, IDC_FLAGS, CB_ADDSTRING, 0, (LPARAM) "Negative");
00245     SendDlgItemMessage (hDlg, IDC_FLAGS, CB_ADDSTRING, 0, (LPARAM) "Log Filter");
00246     SendDlgItemMessage (hDlg, IDC_FLAGS, CB_SETCURSEL, caHalf.caFlags, 0);
00247
00248     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Device's default");
00249     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Tungsten lamp");
00250     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Noon sunlight");
00251     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "NTSC daylight");
00252     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Normal print");
00253     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Bond paper print");
00254     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Standard daylight");
00255     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Northern daylight");
00256     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_ADDSTRING, 0, (LPARAM) "Cool white lamp");
00257     SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_SETCURSEL, caHalf.caIlluminantIndex, 0);
00258
00259     SetupControls(hDlg, IDC_REDGAMMASLIDER,     IDC_REDGAMMA,     250,  6500, caHalf.caRedGamma / 10, TRUE);
00260     SetupControls(hDlg, IDC_GREENGAMMASLIDER,   IDC_GREENGAMMA,   250,  6500, caHalf.caGreenGamma / 10, TRUE);
00261     SetupControls(hDlg, IDC_BLUEGAMMASLIDER,    IDC_BLUEGAMMA,    250,  6500, caHalf.caBlueGamma / 10, TRUE);
00262
00263     SetupControls(hDlg, IDC_REFBLACKSLIDER,     IDC_REFBLACK,       0,  4000, caHalf.caReferenceBlack, FALSE);
00264     SetupControls(hDlg, IDC_REFWHITESLIDER,     IDC_REFWHITE,    6000, 10000, caHalf.caReferenceWhite, FALSE);
00265
00266     SetupControls(hDlg, IDC_CONTRASTSLIDER,     IDC_CONTRAST,     -100,  100, caHalf.caContrast, FALSE);
00267     SetupControls(hDlg, IDC_BRIGHTNESSSLIDER,   IDC_BRIGHTNESS,   -100,  100, caHalf.caBrightness, FALSE);
00268     SetupControls(hDlg, IDC_COLORFULNESSSLIDER, IDC_COLORFULNESS, -100,  100, caHalf.caColorfulness, FALSE);
00269     SetupControls(hDlg, IDC_TINTSLIDER,         IDC_TINT,         -100,  100, caHalf.caRedGreenTint, FALSE);
00270     return (TRUE);
00271
00272   case WM_HSCROLL:
00273         {
00274             int iTemp = SendMessage((HWND)lParam, TBM_GETPOS, (WPARAM)0, (LPARAM)0);
00275
00276             if ((HWND)lParam == GetDlgItem(hDlg, IDC_REDGAMMASLIDER))
00277                 SetDlgItemInt(hDlg, IDC_REDGAMMA, iTemp*10, TRUE);
00278
00279             if ((HWND)lParam == GetDlgItem(hDlg, IDC_GREENGAMMASLIDER))
00280                 SetDlgItemInt(hDlg, IDC_GREENGAMMA, iTemp*10, TRUE);
00281
00282             if ((HWND)lParam == GetDlgItem(hDlg, IDC_BLUEGAMMASLIDER))
00283                 SetDlgItemInt(hDlg, IDC_BLUEGAMMA, iTemp*10, TRUE);
00284
00285             if ((HWND)lParam == GetDlgItem(hDlg, IDC_REFBLACKSLIDER))
00286                 SetDlgItemInt(hDlg, IDC_REFBLACK, iTemp, TRUE);
00287
00288             if ((HWND)lParam == GetDlgItem(hDlg, IDC_REFWHITESLIDER))
00289                 SetDlgItemInt(hDlg, IDC_REFWHITE, iTemp, TRUE);
00290
00291             if ((HWND)lParam == GetDlgItem(hDlg, IDC_CONTRASTSLIDER))
00292                 SetDlgItemInt(hDlg, IDC_CONTRAST, iTemp, TRUE);
00293
00294             if ((HWND)lParam == GetDlgItem(hDlg, IDC_BRIGHTNESSSLIDER))
00295                 SetDlgItemInt(hDlg, IDC_BRIGHTNESS, iTemp, TRUE);
00296
00297             if ((HWND)lParam == GetDlgItem(hDlg, IDC_COLORFULNESSSLIDER))
00298                 SetDlgItemInt(hDlg, IDC_COLORFULNESS, iTemp, TRUE);
00299
00300             if ((HWND)lParam == GetDlgItem(hDlg, IDC_TINTSLIDER))
00301                 SetDlgItemInt(hDlg, IDC_TINT, iTemp, TRUE);
00302
00303             caHalf.caRedGamma = (WORD)GetDlgItemInt (hDlg, IDC_REDGAMMA, &bError, FALSE);
00304             caHalf.caGreenGamma = (WORD)GetDlgItemInt (hDlg, IDC_GREENGAMMA, &bError, FALSE);
00305             caHalf.caBlueGamma = (WORD)GetDlgItemInt (hDlg, IDC_BLUEGAMMA, &bError, FALSE);
00306             caHalf.caReferenceBlack = (WORD)GetDlgItemInt (hDlg, IDC_REFBLACK, &bError, FALSE);
00307             caHalf.caReferenceWhite = (WORD)GetDlgItemInt (hDlg, IDC_REFWHITE, &bError, FALSE);
00308             caHalf.caContrast = (WORD)GetDlgItemInt (hDlg, IDC_CONTRAST, &bError, FALSE);
00309             caHalf.caBrightness = (WORD)GetDlgItemInt (hDlg, IDC_BRIGHTNESS, &bError, FALSE);
00310             caHalf.caColorfulness = (WORD)GetDlgItemInt (hDlg, IDC_COLORFULNESS, &bError, FALSE);
00311             caHalf.caRedGreenTint = (WORD)GetDlgItemInt (hDlg, IDC_TINT, &bError, TRUE);
00312
00313             if (IsDlgButtonChecked(hDlg, IDC_UPDATE))
00314                 InvalidateRect(hWndMain, NULL, FALSE);
00315         }
00316         return FALSE;
00317
00318   case WM_COMMAND:          /* message: received a command */
00319
00320     if (HIWORD(uParam) == CBN_SELCHANGE) {
00321         caHalf.caFlags = (WORD) SendDlgItemMessage (hDlg, IDC_FLAGS, CB_GETCURSEL, 0, 0);
00322         caHalf.caIlluminantIndex = (WORD) SendDlgItemMessage (hDlg, IDC_ILLUMINATE, CB_GETCURSEL, 0, 0);
00323
00324         if (IsDlgButtonChecked(hDlg, IDC_UPDATE))
00325             InvalidateRect(hWndMain, NULL, FALSE);
00326     }
00327
00328     if (LOWORD (uParam) == IDOK || LOWORD (uParam) == IDCANCEL) {   /* System menu close command? */
00329
00330       if (LOWORD (uParam) != IDOK)  // if cancel was pressed
00331         caHalf = caOld; // restore the old version
00332       else
00333         bUpdate = IsDlgButtonChecked(hDlg, IDC_UPDATE);
00334
00335       EndDialog (hDlg, TRUE);   /* Exit the dialog */
00336       return (TRUE);
00337     }
00338     break;
00339   }
00340   return (FALSE);           /* Didn't process the message */
00341
00342   lParam;                   /* This will prevent 'unused formal parameter' warnings */
00343 }
00344
00345 /****************************************************************************
00346
00347         FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
00348
00349         PURPOSE:  Processes messages
00350
00351         MESSAGES:
00352
00353         WM_COMMAND    - application menu (About dialog box)
00354         WM_DESTROY    - destroy window
00355
00356         COMMENTS:
00357
00358         To process the IDM_ABOUT message, call MakeProcInstance() to get the
00359         current instance address of the About() function.  Then call Dialog
00360         box which will create the box according to the information in your
00361         HALFTONE.rc file and turn control over to the About() function.  When
00362         it returns, free the intance address.
00363
00364 ****************************************************************************/
00365
00366 LRESULT CALLBACK WndProc(
00367                 HWND hWnd,         // window handle
00368                 UINT message,      // type of message
00369                 WPARAM uParam,     // additional information
00370                 LPARAM lParam)     // additional information
00371 {
00372     int wmId, wmEvent;
00373     static HBITMAP hbmp = NULL;
00374     static HANDLE hPalette = NULL;
00375
00376     switch (message) {
00377         case WM_CREATE:
00378             {
00379                 HDC hDC = GetDC(NULL);
00380
00381         if (!hDC)
00382           return -1;  // Something is profoundly wrong, bail!
00383
00384                 // Initialize the global color adjustment structure
00385                 caHalf.caSize = sizeof(caHalf);
00386
00387                 // Does the OS we are running on support GetColorAdjustment?
00388                 if (!GetColorAdjustment (hDC, &caHalf)) {
00389                     MessageBox(hWnd, "Please be sure that the version of the OS you are running supports "
00390                                      "HALFTONE stretching.",
00391                                      "Unable to retrieve COLORADJUSTMENT settings", MB_ICONSTOP);
00392                     return  -1;   // No, bail!
00393                 }
00394
00395                 // Create a halftone palette
00396                 hPalette = CreateHalftonePalette(hDC);
00397
00398                 InitCommonControls();
00399
00400                 ReleaseDC(NULL, hDC);
00401             }
00402             return 0;
00403
00404         case WM_PAINT:
00405             {
00406                PAINTSTRUCT ps;
00407                HDC    hDC = BeginPaint(hWnd, &ps);
00408          BOOL   bError;  // Track the error status
00409                RECT   rect;
00410                HDC    hdcMem;
00411                BITMAP bm;
00412
00413                // Get the extents of our drawing area
00414                GetClientRect(hWnd, &rect);
00415
00416                if (hbmp) { // If we have a DIB section loaded
00417                    // Prepare for our DC for a halftone stretch
00418                    bError = (SetStretchBltMode(hDC, HALFTONE) == 0);
00419            bError |= (SetColorAdjustment(hDC, &caHalf) == 0);
00420
00421            bError |= (SelectPalette(hDC, hPalette, FALSE) == NULL);
00422                    bError |= (RealizePalette(hDC) == GDI_ERROR);
00423
00424                    // Get the extents of our DIB
00425                    bError |= (GetObject(hbmp, sizeof(BITMAP), &bm) == 0);
00426
00427                    hdcMem = CreateCompatibleDC(hDC);
00428            bError |= (hdcMem == NULL);
00429
00430                    if (!bError) {
00431              SelectObject(hdcMem, hbmp);
00432              StretchBlt(hDC,    0, 0, rect.right, rect.bottom,
00433                   hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
00434            } else // reprt that an error
00435              PostMessage(hWnd, WM_COMMAND, IDM_ERRORMESSAGE, 0);
00436
00437                    DeleteDC(hdcMem);
00438                } else
00439                    PatBlt(hDC, 0, 0, rect.right, rect.bottom, BLACKNESS);
00440
00441                EndPaint(hWnd, &ps);
00442             }
00443             break;
00444
00445         case WM_PALETTECHANGED:
00446             if ((HWND) uParam == hWnd)
00447                 return 0;
00448
00449         /* Otherwise, fall through to WM_QUERYNEWPALETTE. */
00450         case WM_QUERYNEWPALETTE:
00451             {
00452                 HDC hdc = GetDC(hWnd);
00453                 HPALETTE hpal;
00454                 UINT i;
00455
00456                 /*
00457                  * If realizing the palette causes the palette to change,
00458                  * redraw completely.
00459                  */
00460                 hpal = SelectPalette (hdc, hPalette, FALSE);
00461                 i = RealizePalette(hdc); /* i == entries that changed  */
00462
00463                 SelectPalette (hdc, hpal, FALSE);
00464                 ReleaseDC(hWnd, hdc);
00465
00466                 /* If any palette entries changed, repaint the entire window. */
00467                 if (i > 0)
00468                     InvalidateRect(hWnd, NULL, TRUE);
00469                 return i;
00470             }
00471
00472
00473         case WM_COMMAND:
00474             wmId    = LOWORD(uParam);
00475             wmEvent = HIWORD(uParam);
00476
00477             switch (wmId) {
00478         case IDM_ERRORMESSAGE:
00479           // Report that an error has occurred and exit
00480           MessageBox(hWnd, "An error has occurred in the handling of the WM_PAINT\n"
00481                        "Press OK to exit this application.", "Error!", MB_ICONSTOP);
00482           PostQuitMessage(-1);
00483           break;
00484
00485                 case IDM_LOADDIB:
00486                         {
00487                             OPENFILENAME ofn = {0};
00488                             char szNewTitle[MAX_PATH];
00489                             char szDirName[MAX_PATH];
00490                             char szFilename[MAX_PATH] = "*.BMP";
00491
00492                             /* Get the windows directory name, and store in szDirName */
00493                             GetWindowsDirectory(szDirName, sizeof(szDirName));
00494
00495                             /* Set all structure members to zero. */
00496                             ZeroMemory(&ofn, sizeof(OPENFILENAME));
00497
00498                             ofn.lStructSize = sizeof(OPENFILENAME);
00499                             ofn.hwndOwner = hWnd;
00500                             ofn.lpstrFilter = "BMP Files (*.BMP)\0 *.BMP\0\0";
00501                             ofn.lpstrFile = szFilename;
00502                             ofn.nMaxFile = sizeof(szFilename);
00503                             ofn.lpstrDefExt = "BMP";
00504                             ofn.lpstrInitialDir = szDirName;
00505                             ofn.Flags = OFN_EXPLORER | OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
00506
00507                             if (hbmp)
00508                                 DeleteObject(hbmp);
00509
00510                             if (GetOpenFileName(&ofn)) {
00511                                hbmp = LoadImage(NULL,
00512                                              szFilename,
00513                                              IMAGE_BITMAP, 0, 0,
00514                                              LR_CREATEDIBSECTION | LR_LOADFROMFILE );
00515                                if (!hbmp)
00516                                   MessageBox(hWnd, "Unable to load file!", szFilename, MB_ICONSTOP);
00517                             } else {
00518                                 if (strlen(szFilename) != 0)
00519                                   MessageBox(hWnd, "Unable to load file!", szFilename, MB_ICONSTOP);
00520
00521                                 return 0;
00522                             }
00523
00524                             // Set our title to reflect the name of the file we loaded
00525                             StringCchCopy(szNewTitle, MAX_PATH, szTitle);
00526                             StringCchCat (szNewTitle, MAX_PATH, " - ");
00527                             StringCchCat (szNewTitle, MAX_PATH, szFilename);
00528                             SetWindowText(hWnd, szNewTitle);
00529
00530                             InvalidateRect(hWnd, NULL, FALSE);
00531                         }
00532                         break;
00533
00534                 case IDM_PROPERTIES:
00535                         DialogBox (hInst,       /* current instance */
00536                                    "HT_DIALOG", /* dlg resource to use */
00537                                    hWnd,        /* parent handle */
00538                                    (DLGPROC) HalftoneDialog);   /* Halftone() instance address */
00539
00540                         // Redraw with the new properties
00541                         InvalidateRect(hWnd, NULL, FALSE);
00542                         break;
00543
00544                 case IDM_ABOUT:
00545                     DialogBox(hInst,          // current instance
00546                              "ABOUTBOX",      // dlg resource to use
00547                              hWnd,            // parent handle
00548                              (DLGPROC)About); // About() instance address
00549
00550                     break;
00551
00552                 case IDM_EXIT:
00553                         if (hbmp)
00554                             DeleteObject(hbmp);
00555
00556                         DestroyWindow (hWnd);
00557                         break;
00558
00559                 default:
00560                         return (DefWindowProc(hWnd, message, uParam, lParam));
00561             }
00562             break;
00563
00564         case WM_DESTROY:  // message: window being destroyed
00565         if (hPalette)
00566           DeleteObject(hPalette);
00567                 PostQuitMessage(0);
00568                 break;
00569
00570         default:          // Passes it on if unproccessed
00571                 return (DefWindowProc(hWnd, message, uParam, lParam));
00572     }
00573     return (0);
00574 }
00575
00576 /*****************************************************************************
00577  *                                                                           *
00578  *   FUNCTION: CenterWindow (HWND, HWND)                                     *
00579  *                                                                           *
00580  *   PURPOSE:  Center one window over another                                *
00581  *                                                                           *
00582  *   COMMENTS:                                                               *
00583  *                                                                           *
00584  *   Dialog boxes take on the screen position that they were designed at,    *
00585  *   which is not always appropriate. Centering the dialog over a particular *
00586  *   window usually results in a better position.                            *
00587  *                                                                           *
00588  ****************************************************************************/
00589
00590 BOOL CenterWindow (HWND hwndChild, HWND hwndParent)
00591 {
00592         RECT    rChild, rParent;
00593         int     wChild, hChild, wParent, hParent;
00594         int     wScreen, hScreen, xNew, yNew;
00595         HDC     hdc;
00596
00597         // Get the Height and Width of the child window
00598         GetWindowRect (hwndChild, &rChild);
00599         wChild = rChild.right - rChild.left;
00600         hChild = rChild.bottom - rChild.top;
00601
00602         // Get the Height and Width of the parent window
00603         GetWindowRect (hwndParent, &rParent);
00604         wParent = rParent.right - rParent.left;
00605         hParent = rParent.bottom - rParent.top;
00606
00607         // Get the display limits
00608         hdc = GetDC (hwndChild);
00609         wScreen = GetDeviceCaps (hdc, HORZRES);
00610         hScreen = GetDeviceCaps (hdc, VERTRES);
00611         ReleaseDC (hwndChild, hdc);
00612
00613         // Calculate new X position, then adjust for screen
00614         xNew = rParent.left + ((wParent - wChild) /2);
00615         if (xNew < 0) {
00616                 xNew = 0;
00617         } else if ((xNew+wChild) > wScreen) {
00618                 xNew = wScreen - wChild;
00619         }
00620
00621         // Calculate new Y position, then adjust for screen
00622         yNew = rParent.top  + ((hParent - hChild) /2);
00623         if (yNew < 0) {
00624                 yNew = 0;
00625         } else if ((yNew+hChild) > hScreen) {
00626                 yNew = hScreen - hChild;
00627         }
00628
00629         // Set it, and return
00630         return SetWindowPos (hwndChild, NULL,
00631                 xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
00632 }
00633
00634
00635 /*****************************************************************************
00636  *                                                                           *
00637  *   FUNCTION: About(HWND, UINT, WPARAM, LPARAM)                             *
00638  *                                                                           *
00639  *   PURPOSE:  Processes messages for "About" dialog box                     *
00640  *                                                                           *
00641  *   MESSAGES:                                                               *
00642  *                                                                           *
00643  *   WM_INITDIALOG - initialize dialog box                                   *
00644  *   WM_COMMAND    - Input received                                          *
00645  *                                                                           *
00646  *   COMMENTS:                                                               *
00647  *                                                                           *
00648  *   Display version information from the version section of the             *
00649  *   application resource.                                                   *
00650  *                                                                           *
00651  *   Wait for user to click on "Ok" button, then close the dialog box.       *
00652  *                                                                           *
00653  ****************************************************************************/
00654
00655 LRESULT CALLBACK About(
00656                 HWND hDlg,           // window handle of the dialog box
00657                 UINT message,        // type of message
00658                 WPARAM uParam,       // message-specific information
00659                 LPARAM lParam)
00660 {
00661     switch (message) {
00662         case WM_INITDIALOG:  // message: initialize dialog box
00663             // Center the dialog over the application window
00664             CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
00665             return (TRUE);
00666
00667         case WM_COMMAND:                      // message: received a command
00668             if (LOWORD(uParam) == IDOK || LOWORD(uParam) == IDCANCEL) {
00669                 EndDialog(hDlg, TRUE);        // Exit the dialog
00670                 return (TRUE);
00671             }
00672             break;
00673     }
00674     return (FALSE); // Didn't process the message
00675
00676     UNREFERENCED_PARAMETER(lParam); // This will prevent 'unused formal parameter' warnings
00677 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_IPSAMPLE_IP_ADDRESS Member List

This is the complete list of members for _IPSAMPLE_IP_ADDRESS, including all inherited members.
dwAddress | _IPSAMPLE_IP_ADDRESS
dwMask | _IPSAMPLE_IP_ADDRESS
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

HtmlPropIFilter Member List

This is the complete list of members for HtmlPropIFilter, including all inherited members.
_awcName | HtmlPropIFilter | [protected]
_fMetaProperty | HtmlPropIFilter | [protected]
_lRefs | HtmlPropIFilter | [protected]
_pHtmlFilter | HtmlPropIFilter | [protected]
_pPersistFile | HtmlPropIFilter | [protected]
AddRef() | HtmlPropIFilter |
BindRegion(FILTERREGION origPos, REFIID riid, void **ppunk) | HtmlPropIFilter |
GetChunk(STAT_CHUNK *pStat) | HtmlPropIFilter |
GetClassID(CLSID *pClassID) | HtmlPropIFilter |
GetCurFile(LPWSTR *ppszFileName) | HtmlPropIFilter |
GetText(ULONG *pcwcBuffer, WCHAR *awcBuffer) | HtmlPropIFilter |
GetValue(PROPVARIANT **ppPropValue) | HtmlPropIFilter |
HtmlPropIFilter() | HtmlPropIFilter | [protected]
HtmlPropIFilterCF class | HtmlPropIFilter | [friend]
Init(ULONG grfFlags, ULONG cAttributes, FULLPROPSPEC const *aAttributes, ULONG *pFlags) | HtmlPropIFilter |
IsDirty() | HtmlPropIFilter |
Load(LPCWSTR pszFileName, DWORD dwMode) | HtmlPropIFilter |
QueryInterface(REFIID riid, void **ppvObject) | HtmlPropIFilter |
Release() | HtmlPropIFilter |
Save(LPCWSTR pszFileName, BOOL fRemember) | HtmlPropIFilter |
SaveCompleted(LPCWSTR pszFileName) | HtmlPropIFilter |
~HtmlPropIFilter() | HtmlPropIFilter | [protected]
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::CopyRecordOptionsEnum Member List

This is the complete list of members for msado15::CopyRecordOptionsEnum, including all inherited members.
adCopyAllowEmulation | msado15::CopyRecordOptionsEnum | [static]
adCopyNonRecursive | msado15::CopyRecordOptionsEnum | [static]
adCopyOverWrite | msado15::CopyRecordOptionsEnum | [static]
Generated on Wed Nov 13 2024 16:58:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Objconstsub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Objconstsub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __OBJCONSTSUB_H__
00018 #define __OBJCONSTSUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CObjConstSub
00028 Summary: Object Construction Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CObjConstSub :
00031   public CSysLCESub,
00032   public IComObjectConstructionEvents
00033 {
00034 public:
00035   CObjConstSub(CComSpy * pSpy)
00036   {
00037     m_pSpy = pSpy;
00038   }
00039
00040   CObjConstSub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045   DECLARE_NOT_AGGREGATABLE(CObjConstSub)
00046   DECLARE_GET_CONTROLLING_UNKNOWN()
00047
00048   BEGIN_COM_MAP(CObjConstSub)
00049     COM_INTERFACE_ENTRY(IComObjectConstructionEvents)
00050     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00051   END_COM_MAP()
00052
00053   STDMETHODIMP GetEventType(EventEnum * e){*e = ObjectConstruction;return S_OK;}
00054   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00055   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComObjectConstructionEvents;return S_OK;}
00056
00057   STDMETHODIMP OnObjectConstruct(COMSVCSEVENTINFO * pInfo,
00058                   REFGUID guidClass,
00059                   LPCOLESTR pszConstructString,
00060                   ULONG64 ObjectID)
00061   {
00062
00063     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjConstPutObject"), GuidToBstr(pInfo->guidApp));
00064     m_pSpy -> AddParamValueToList(L"guidClass", GuidToBstr( guidClass ));
00065     m_pSpy -> AddParamValueToList(L"sConstructString", pszConstructString);
00066
00067     WCHAR szObjectID[32];
00068     wsprintfW(szObjectID, L"0x%016X", ObjectID);
00069     m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00070
00071     IF_AUDIT_DO(OnObjectConstruct)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00072                     GuidToBstr( guidClass ),
00073                     pszConstructString,
00074                     szObjectID
00075                     );
00076
00077     return S_OK;
00078   }
00079
00080 };
00081
00082 #endif //__OBJCONSTSUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Include/BttnCur.h Source File

  • Com
  • Fundamentals
  • Include

BttnCur.h

Go to the documentation of this file.
00001 /*
00002  * BTTNCUR.H
00003  * Buttons & Cursors Version 1.1, March 1993
00004  *
00005  * Public include file for the Button Images and Cursor DLL, including
00006  * structures, definitions, and function prototypes.
00007  *
00008  * Copyright (c)1992 - 2000 Microsoft Corporation, All Rights Reserved,
00009  * as applied to redistribution of this source code in source form
00010  * License is granted to use of compiled code in shipped binaries.
00011  */
00012
00013
00014 #ifndef _BTTNCUR_H_
00015 #define _BTTNCUR_H_
00016
00017 #ifdef __cplusplus
00018 extern "C"
00019   {
00020 #endif
00021
00022
00023 //Standard image bitmap
00024
00025 //WARNING:  Obsolete.  Use the return from UIToolDisplayData
00026 #define IDB_STANDARDIMAGES              400
00027
00028 //New values for display types
00029 #define IDB_STANDARDIMAGESMIN           400
00030 #define IDB_STANDARDIMAGES96            400
00031 #define IDB_STANDARDIMAGES72            401
00032 #define IDB_STANDARDIMAGES120           402
00033
00034
00035
00036 //Image indices inside the standard bitmap.
00037 #define TOOLIMAGE_MIN                   0
00038 #define TOOLIMAGE_EDITCUT               0
00039 #define TOOLIMAGE_EDITCOPY              1
00040 #define TOOLIMAGE_EDITPASTE             2
00041 #define TOOLIMAGE_FILENEW               3
00042 #define TOOLIMAGE_FILEOPEN              4
00043 #define TOOLIMAGE_FILESAVE              5
00044 #define TOOLIMAGE_FILEPRINT             6
00045 #define TOOLIMAGE_HELP                  7
00046 #define TOOLIMAGE_HELPCONTEXT           8
00047 #define TOOLIMAGE_MAX                   8
00048
00049
00050 //Additional Standard Cursors as defined in the UI Design Guide.
00051 #define IDC_NEWUICURSORMIN              500
00052 #define IDC_RIGHTARROW                  500
00053 #define IDC_CONTEXTHELP                 501
00054 #define IDC_MAGNIFY                     502
00055 #define IDC_NODROP                      503
00056 #define IDC_TABLETOP                    504
00057 #define IDC_HSIZEBAR                    505
00058 #define IDC_VSIZEBAR                    506
00059 #define IDC_HSPLITBAR                   507
00060 #define IDC_VSPLITBAR                   508
00061 #define IDC_SMALLARROWS                 509
00062 #define IDC_LARGEARROWS                 510
00063 #define IDC_HARROWS                     511
00064 #define IDC_VARROWS                     512
00065 #define IDC_NESWARROWS                  513
00066 #define IDC_NWSEARROWS                  514
00067 #define IDC_NEWUICURSORMAX              514
00068
00069
00070
00071 //Standard sizes for toolbar buttons and bitmaps on display types
00072
00073 //WARNING:  These are obsolete for version 1.0 compatibility/
00074 #define TOOLBUTTON_STDWIDTH             24
00075 #define TOOLBUTTON_STDHEIGHT            22
00076 #define TOOLBUTTON_STDIMAGEWIDTH        16
00077 #define TOOLBUTTON_STDIMAGEHEIGHT       15
00078
00079 /*
00080  * Applications can call UIToolDisplayData to get the particular
00081  * values to use for the current display instead of using these values
00082  * directly.  However, if the application has the aspect ratio already
00083  * then these are available for them.
00084  */
00085
00086 //Sizes for 72 DPI (EGA)
00087 #define TOOLBUTTON_STD72WIDTH           24
00088 #define TOOLBUTTON_STD72HEIGHT          16
00089 #define TOOLBUTTON_STD72IMAGEWIDTH      16
00090 #define TOOLBUTTON_STD72IMAGEHEIGHT     11
00091
00092 //Sizes for 96 DPI (VGA)
00093 #define TOOLBUTTON_STD96WIDTH           24
00094 #define TOOLBUTTON_STD96HEIGHT          22
00095 #define TOOLBUTTON_STD96IMAGEWIDTH      16
00096 #define TOOLBUTTON_STD96IMAGEHEIGHT     15
00097
00098 //Sizes for 120 DPI (8514/a)
00099 #define TOOLBUTTON_STD120WIDTH          32
00100 #define TOOLBUTTON_STD120HEIGHT         31
00101 #define TOOLBUTTON_STD120IMAGEWIDTH     24
00102 #define TOOLBUTTON_STD120IMAGEHEIGHT    23
00103
00104
00105 //Sizes of a standard button bar depending on the display
00106 #define CYBUTTONBAR72                   23
00107 #define CYBUTTONBAR96                   29
00108 #define CYBUTTONBAR120                  38
00109
00110
00111
00112 /*
00113  * The low-word of the state contains the display state where each
00114  * value is mutually exclusive and contains one or more grouping bits.
00115  * Each group represents buttons that share some sub-state in common.
00116  *
00117  * The high-order byte controls which colors in the source bitmap,
00118  * black, white, gray, and dark gray, are to be converted into the
00119  * system colors COLOR_BTNTEXT, COLOR_HILIGHT, COLOR_BTNFACE, and
00120  * COLOR_BTNSHADOW.  Any or all of these bits may be set to allow
00121  * the application control over specific colors.
00122  *
00123  * The actual state values are split into a command group and an
00124  * attribute group.  Up, mouse down, and disabled states are identical,
00125  * but only attributes can have down, down disabled, and indeterminate
00126  * states.
00127  *
00128  * BUTTONGROUP_BLANK is defined so an application can draw only the button
00129  * without an image in the up, down, mouse down, or indeterminate
00130  * state, that is, BUTTONGROUP_BLANK is inclusive with BUTTONGROUP_DOWN
00131  * and BUTTONGROUP_LIGHTFACE.
00132  */
00133
00134
00135 #define BUTTONGROUP_DOWN                0x0001
00136 #define BUTTONGROUP_ACTIVE              0x0002
00137 #define BUTTONGROUP_DISABLED            0x0004
00138 #define BUTTONGROUP_LIGHTFACE           0x0008
00139 #define BUTTONGROUP_BLANK               0x0010
00140
00141 //Command buttons only
00142 #define COMMANDBUTTON_UP                (BUTTONGROUP_ACTIVE)
00143 #define COMMANDBUTTON_MOUSEDOWN         (BUTTONGROUP_ACTIVE | BUTTONGROUP_DOWN)
00144 #define COMMANDBUTTON_DISABLED          (BUTTONGROUP_DISABLED)
00145
00146 //Attribute buttons only
00147 #define ATTRIBUTEBUTTON_UP              (BUTTONGROUP_ACTIVE)
00148 #define ATTRIBUTEBUTTON_MOUSEDOWN       (BUTTONGROUP_ACTIVE | BUTTONGROUP_DOWN)
00149 #define ATTRIBUTEBUTTON_DISABLED        (BUTTONGROUP_DISABLED)
00150 #define ATTRIBUTEBUTTON_DOWN            (BUTTONGROUP_ACTIVE | BUTTONGROUP_DOWN | BUTTONGROUP_LIGHTFACE)
00151 #define ATTRIBUTEBUTTON_INDETERMINATE   (BUTTONGROUP_ACTIVE | BUTTONGROUP_LIGHTFACE)
00152 #define ATTRIBUTEBUTTON_DOWNDISABLED    (BUTTONGROUP_DISABLED | BUTTONGROUP_DOWN | BUTTONGROUP_LIGHTFACE)
00153
00154 //Blank buttons only
00155 #define BLANKBUTTON_UP                  (BUTTONGROUP_ACTIVE | BUTTONGROUP_BLANK)
00156 #define BLANKBUTTON_DOWN                (BUTTONGROUP_ACTIVE | BUTTONGROUP_BLANK | BUTTONGROUP_DOWN | BUTTONGROUP_LIGHTFACE)
00157 #define BLANKBUTTON_MOUSEDOWN           (BUTTONGROUP_ACTIVE | BUTTONGROUP_BLANK | BUTTONGROUP_DOWN)
00158 #define BLANKBUTTON_INDETERMINATE       (BUTTONGROUP_ACTIVE | BUTTONGROUP_BLANK | BUTTONGROUP_LIGHTFACE)
00159
00160
00161 /*
00162  * Specific bits to prevent conversions of specific colors to system
00163  * colors.  If an application uses this newer library and never specified
00164  * any bits, then they benefit from color conversion automatically.
00165  */
00166 #define PRESERVE_BLACK                  0x0100
00167 #define PRESERVE_DKGRAY                 0x0200
00168 #define PRESERVE_LTGRAY                 0x0400
00169 #define PRESERVE_WHITE                  0x0800
00170
00171 #define PRESERVE_ALL                    (PRESERVE_BLACK | PRESERVE_DKGRAY | PRESERVE_LTGRAY | PRESERVE_WHITE)
00172 #define PRESERVE_NONE                   0   //Backwards compatible
00173
00174
00175
00176 //Structure for UIToolConfigureForDisplay
00177 typedef struct tagTOOLDISPLAYDATA
00178   {
00179   UINT        uDPI;       //Display driver DPI
00180   UINT        cyBar;      //Vertical size for a bar containing buttons.
00181   UINT        cxButton;   //Dimensions of a button.
00182   UINT        cyButton;
00183   UINT        cxImage;    //Dimensions of bitmap image
00184   UINT        cyImage;
00185   UINT        uIDImages;  //Standard resource ID for display-sensitive images
00186   } TOOLDISPLAYDATA, FAR *LPTOOLDISPLAYDATA;
00187
00188
00189
00190 //Public functions in BTTNCUR.DLL
00191 HCURSOR WINAPI UICursorLoad(UINT);
00192 BOOL    WINAPI UIToolConfigureForDisplay(LPTOOLDISPLAYDATA);
00193 BOOL    WINAPI UIToolButtonDraw(HDC, int, int, int, int, HBITMAP, int, int, int, UINT);
00194 BOOL    WINAPI UIToolButtonDrawTDD(HDC, int, int, int, int, HBITMAP, int, int, int, UINT, LPTOOLDISPLAYDATA);
00195
00196
00197 #ifdef __cplusplus
00198   }
00199 #endif
00200
00201 #endif //_BTTNCUR_H_
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_AUTH_SEQ Member List

This is the complete list of members for _AUTH_SEQ, including all inherited members.
_cbMaxToken | _AUTH_SEQ
_fHaveCredHandle | _AUTH_SEQ
_fHaveCtxtHandle | _AUTH_SEQ
_fNewConversation | _AUTH_SEQ
_fUUEncodeData | _AUTH_SEQ
_hcred | _AUTH_SEQ
_hctxt | _AUTH_SEQ
cbMaxSignature | _AUTH_SEQ
cbSecurityTrailer | _AUTH_SEQ
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Common/Rebar/Resource.h Source File

  • WinUI
  • Controls
  • Common
  • Rebar

Resource.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 //{{NO_DEPENDENCIES}}
00011 // Microsoft Developer Studio generated include file.
00012 // Used by ReBar.rc
00013 //
00014 #define IDI_ICON1                       100
00015 #define IDM_ABOUT                       100
00016 #define IDD_ABOUTBOX                    101
00017 #define IDM_EXIT                        101
00018 #define IDB_BACKGROUND                  102
00019 #define IDM_TOP                         102
00020 #define IDB_LOGO                        103
00021 #define IDM_LEFT                        103
00022 #define IDM_GENERICMENU                 104
00023 #define IDM_RIGHT                       104
00024 #define IDM_BOTTOM                      105
00025
00026 // Next default values for new objects
00027 //
00028 #ifdef APSTUDIO_INVOKED
00029 #ifndef APSTUDIO_READONLY_SYMBOLS
00030 #define _APS_NEXT_RESOURCE_VALUE        105
00031 #define _APS_NEXT_COMMAND_VALUE         107
00032 #define _APS_NEXT_CONTROL_VALUE         1000
00033 #define _APS_NEXT_SYMED_VALUE           101
00034 #endif
00035 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/customdrawbuttondlg/CustomDrawButtonDlg.cpp Source File

  • WinUI
  • Shell
  • customdrawbuttondlg

CustomDrawButtonDlg.cpp

Go to the documentation of this file.
00001 // CustomDrawButtonDlg.cpp : Defines the entry point for the application.
00002 //
00003
00004 #include "Windows.h"
00005 #include <commctrl.h>
00006 #include "shlwapi.h"
00007 #include "resource.h"
00008
00009
00010 // Forward declarations of functions included in this code module:
00011 LRESULT CALLBACK  DlgProc(HWND, UINT, WPARAM, LPARAM);
00012
00013 int APIENTRY WinMain(HINSTANCE hInstance,
00014                      HINSTANCE hPrevInstance,
00015                      LPSTR     lpCmdLine,
00016                      int       nCmdShow)
00017
00018 {
00019   InitCommonControls();
00020   DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, (DLGPROC)DlgProc);
00021
00022   return 0;
00023 }
00024
00025
00026
00027
00028 //
00029 //  FUNCTION: DlgProc(HWND, unsigned, WORD, LONG)
00030 //
00031 LRESULT CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00032 {
00033   int wmId, wmEvent;
00034   static HWND hStatic = NULL;
00035   static const int nSleepTime = 750;
00036
00037   switch (message)
00038   {
00039   case WM_COMMAND:
00040     wmId    = LOWORD(wParam);
00041     wmEvent = HIWORD(wParam);
00042     // Parse the menu selections:
00043     switch (wmId)
00044     {
00045
00046       case IDCANCEL:
00047         EndDialog(hWnd, 0);
00048         break;
00049       default:
00050         return 0;
00051     }
00052     break;
00053   case WM_INITDIALOG:
00054     {
00055       hStatic = GetDlgItem(hWnd, IDC_STATIC);
00056     }
00057     break;
00058   case WM_NOTIFY:
00059     {
00060       NMHDR* nmhdr = (NMHDR*)lParam;
00061
00062       if (!nmhdr)
00063         break;
00064
00065       switch (nmhdr->code)
00066       {
00067       case NM_CUSTOMDRAW:
00068         {
00069           if (nmhdr->idFrom != ID_CUSTOM_BUTTON)
00070             break;
00071
00072           LPNMCUSTOMDRAW lpCD = (LPNMCUSTOMDRAW)lParam;
00073
00074           TCHAR szOut[150];
00075           BOOL bStateAdded = FALSE;
00076           if ((lpCD->uItemState & CDIS_CHECKED) == CDIS_CHECKED)// The item is
00077                                                                                               // is checked.
00078           {
00079             if (bStateAdded)
00080               StrCat(szOut, TEXT(" | CDIS_CHECKED"));
00081             else
00082             {
00083               bStateAdded = TRUE;
00084               StrCpy(szOut, TEXT("State = CDIS_CHECKED"));
00085             }
00086           }
00087
00088
00089           if ((lpCD->uItemState & CDIS_DEFAULT) ==  CDIS_DEFAULT)// The item
00090                                                                                                // is in its
00091                                                                                                // default
00092                                                                                                // state.
00093           {
00094             if (bStateAdded)
00095               StrCat(szOut, TEXT(" | CDIS_DEFAULT"));
00096             else
00097             {
00098               bStateAdded = TRUE;
00099               StrCpy(szOut, TEXT("State = CDIS_DEFAULT"));
00100             }
00101           }
00102
00103           if ((lpCD->uItemState & CDIS_DISABLED) ==  CDIS_DISABLED) // The item is
00104                                                                                                   // disabled.
00105           {
00106             if (bStateAdded)
00107               StrCat(szOut, TEXT(" | CDIS_DISABLED"));
00108             else
00109             {
00110               bStateAdded = TRUE;
00111               StrCpy(szOut, TEXT("State = CDIS_DISABLED"));
00112             }
00113           }
00114
00115           if ((lpCD->uItemState & CDIS_FOCUS) ==  CDIS_FOCUS) // The item is in focus.
00116           {
00117             if (bStateAdded)
00118               StrCat(szOut, TEXT(" | CDIS_FOCUS"));
00119             else
00120             {
00121               bStateAdded = TRUE;
00122               StrCpy(szOut, TEXT("State = CDIS_FOCUS"));
00123             }
00124           }
00125
00126           if ((lpCD->uItemState & CDIS_GRAYED) ==  CDIS_GRAYED) // The item is grayed.
00127           {
00128             if (bStateAdded)
00129               StrCat(szOut, TEXT(" | CDIS_GRAYED"));
00130             else
00131             {
00132               bStateAdded = TRUE;
00133               StrCpy(szOut, TEXT("State = CDIS_GRAYED"));
00134             }
00135           }
00136
00137           if ((lpCD->uItemState & CDIS_HOT) ==  CDIS_HOT) // The item is currently
00138                                                                                         // under the pointer
00139                                                                                         // ("hot").
00140           {
00141             if (bStateAdded)
00142               StrCat(szOut, TEXT(" | CDIS_HOT"));
00143             else
00144             {
00145               bStateAdded = TRUE;
00146               StrCpy(szOut, TEXT("State = CDIS_HOT"));
00147             }
00148           }
00149
00150           if ((lpCD->uItemState & CDIS_INDETERMINATE) == CDIS_INDETERMINATE)
00151                                                                                          // The item is in an
00152                                                                                          // indeterminate state.
00153
00154           {
00155             if (bStateAdded)
00156               StrCat(szOut, TEXT(" | CDIS_INDETERMINATE"));
00157             else
00158             {
00159               bStateAdded = TRUE;
00160               StrCpy(szOut, TEXT("State = CDIS_INDETERMINATE"));
00161             }
00162           }
00163
00164           if ((lpCD->uItemState & CDIS_MARKED) ==  CDIS_MARKED) // The item is marked.
00165                                                                                               // The meaning of this
00166                                                                                               // is up to the
00167                                                                                               // implementation.
00168           {
00169             if (bStateAdded)
00170               StrCat(szOut, TEXT(" | CDIS_MARKED"));
00171             else
00172             {
00173               bStateAdded = TRUE;
00174               StrCpy(szOut, TEXT("State = CDIS_MARKED"));
00175             }
00176           }
00177
00178           if ((lpCD->uItemState & CDIS_SELECTED) ==  CDIS_SELECTED) // The item is
00179                                                                                                   // selected.
00180           {
00181             if (bStateAdded)
00182               StrCat(szOut, TEXT(" | CDIS_SELECTED"));
00183             else
00184             {
00185               bStateAdded = TRUE;
00186               StrCpy(szOut, TEXT("State = CDIS_SELECTED"));
00187             }
00188           }
00189
00190
00191           if (lpCD->dwDrawStage == CDDS_PREPAINT)
00192           {
00193             if (!bStateAdded)
00194               StrCpy(szOut, TEXT("CDDS_PREPAINT"));
00195             else
00196               StrCat(szOut, TEXT(", CDDS_PREPAINT"));
00197             SetWindowText(hStatic, szOut);
00198             Sleep(nSleepTime);
00199             SetWindowLong(hWnd, DWL_MSGRESULT, (LONG)(CDRF_NOTIFYITEMDRAW |                                                                  CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE));
00200             return 1;
00201           }
00202
00203           if (lpCD->dwDrawStage == CDDS_POSTPAINT )
00204           {
00205             if (!bStateAdded)
00206               StrCpy(szOut, TEXT("CDDS_POSTPAINT"));
00207             else
00208               StrCat(szOut, TEXT(", CDDS_POSTPAINT"));
00209             SetWindowText(hStatic, szOut);
00210             Sleep(nSleepTime);
00211           }
00212
00213
00214           if (lpCD->dwDrawStage == CDDS_PREERASE )
00215           {
00216             if (!bStateAdded)
00217               StrCpy(szOut, TEXT("CDDS_PREERASE"));
00218             else
00219               StrCat(szOut, TEXT(", CDDS_PREERASE"));
00220
00221             SetWindowText(hStatic, szOut);
00222             Sleep(nSleepTime);
00223             SetWindowLong(hWnd, DWL_MSGRESULT, (LONG)(CDRF_NOTIFYITEMDRAW |                                                               CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE));
00224             return 1;
00225           }
00226
00227           if (lpCD->dwDrawStage == CDDS_POSTERASE)
00228           {
00229             if (!bStateAdded)
00230               StrCpy(szOut, TEXT("CDDS_POSTERASE"));
00231             else
00232               StrCat(szOut, TEXT(", CDDS_POSTERASE"));
00233
00234             SetWindowText(hStatic, szOut);
00235             Sleep(nSleepTime);
00236           }
00237         }
00238       }
00239       break;
00240     }
00241   }
00242   return 0;
00243 }
00244
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/DHCP/DHCPPersist/dhcppersist.cpp Source File

  • NetDS
  • DHCP
  • DHCPPersist

dhcppersist.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright © 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00008  *
00009  * Author: Stephen R. Husak - Microsoft Developer Support
00010  *
00011  * Abstract:
00012  *    This code demonstrates the use of the DHCP Client Options API -
00013  *    DhcpRequestParams/DhcpUndoRequestParams for setting options
00014  *    to be persistent
00015  *
00016  */
00017
00018 /*
00019  * Includes
00020  */
00021 #include <windows.h>      // windows
00022 #include <stdio.h>        // standard i/o
00023 #include <iphlpapi.h>     // ip helper
00024 #include <dhcpcsdk.h>     // dhcp client options api
00025
00026 // initial buffer size for options buffer
00027 #define INITIAL_BUFFER_SIZE 256
00028 #define DHCP_PERSISTENT_APP_STRING L"DhcpRequestSample"
00029
00030 /*
00031  * OutputError
00032  *
00033  * retrieves the system message for an error
00034  */
00035 void OutputError(DWORD dwError)
00036 {
00037   LPVOID lpMsgBuf;    // buffer to copy string into (allocated by call)
00038
00039   if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
00040                 FORMAT_MESSAGE_FROM_SYSTEM |
00041                 FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwError,
00042                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00043                 (LPTSTR) &lpMsgBuf, 0, NULL) == 0)
00044     printf("Error Reported: %d GetLastError: %d\n", dwError, GetLastError());
00045   else
00046     {
00047     printf("Error %d: %s\n", dwError, (LPCSTR) lpMsgBuf);
00048
00049     // free the buffer.
00050     LocalFree(lpMsgBuf);
00051     }
00052 }
00053
00054 /*
00055  * DetermineAdapter
00056  *
00057  * NOTE:
00058  *
00059  *    This code retrieves the Adapter Name to use for the DHCP Client API
00060  *    using the IPHelper API.
00061  *
00062  *    NT has a name for the adapter that through this API has device
00063  *    information in front of it followed by a {GUID}, 98 does not and
00064  *    the Index is used instead. So if the string is set to ?? (what it is
00065  *    in 98) we revert to using the string representation of the index.
00066  *
00067  */
00068 LPSTR DetermineAdapter()
00069 {
00070   DWORD dwResult;                            // result of API calls
00071   IP_INTERFACE_INFO * pInfo = NULL;          // adapter information structure
00072   DWORD dwSize = 0;                          // size of required buffer
00073   CHAR szAdapter[MAX_ADAPTER_NAME] = {0};    // the adapter to use
00074   char * ptr;                                // pointer to adapter name
00075
00076   // get buffer size
00077   dwResult = GetInterfaceInfo(NULL, &dwSize);
00078   if (dwResult == ERROR_INSUFFICIENT_BUFFER)
00079     {
00080     // allocate buffer
00081     pInfo = (IP_INTERFACE_INFO *) LocalAlloc(LPTR, dwSize);
00082     if (!pInfo)
00083       {
00084       OutputError(GetLastError());
00085       exit(1);
00086       }
00087
00088     // make the actual call
00089     dwResult = GetInterfaceInfo(pInfo, &dwSize);
00090     if (dwResult != ERROR_SUCCESS)
00091       {
00092       OutputError(GetLastError());
00093       exit(2);
00094       }
00095     }
00096   else
00097     {
00098     OutputError(GetLastError());
00099     exit(3);
00100     }
00101
00102   // convert, parse, and convert back
00103   ptr = NULL;
00104   WideCharToMultiByte(0, 0, pInfo->Adapter[0].Name,
00105                             lstrlenW(pInfo->Adapter[0].Name),
00106                             szAdapter, MAX_ADAPTER_NAME, NULL, NULL);
00107   if (szAdapter[0] != '?')
00108     {
00109     // find the GUID
00110     ptr = strchr(szAdapter, '{');
00111     }
00112
00113   // use index if the pointer is not set
00114   if (!ptr)
00115     {
00116     sprintf(szAdapter, "%ld\0", pInfo->Adapter[0].Index);
00117     ptr = szAdapter;
00118     }
00119
00120   // free what was allocated
00121   if (pInfo)
00122     LocalFree(pInfo);
00123
00124   return ptr;
00125 }
00126
00127 /*
00128  * main
00129  *
00130  * this is where it all happens
00131  */
00132 int main(int argc, char * argv[])
00133 {
00134   DWORD dwResult;                            // result from API call
00135   DWORD dwVersion;                           // API version reported
00136   WCHAR wszAdapter[MAX_ADAPTER_NAME] = {0};  // the adapter name in wide chars
00137   char * ptr = NULL;                         // pointer to adapter name
00138   BOOL bRemovePersist = FALSE;               // remove persistent request
00139   BOOL bAddPersist = FALSE;                  // add persistent request
00140
00141   // check for persist options and adapter ID
00142   for (int i = 1; i < argc; i++)
00143     {
00144     char * p;
00145     p = argv[i];
00146     if ((p[0] == '/') || (p[0] == '-'))
00147       {
00148       p++;
00149       if ((p[0] == 'p') || (p[0] == 'P'))
00150         bAddPersist = TRUE;
00151       if ((p[0] == 'r') || (p[0] == 'R'))
00152         bRemovePersist = TRUE;
00153       }
00154     else
00155       ptr = argv[i];
00156     }
00157
00158   if (!ptr)
00159     ptr = DetermineAdapter();
00160
00161   // convert it for the API call
00162   MultiByteToWideChar(0, 0, ptr, (int) strlen(ptr), wszAdapter, MAX_ADAPTER_NAME);
00163
00164   // initialize the DHCP Client Options API
00165   dwResult = DhcpCApiInitialize(&dwVersion);
00166   if (dwResult != 0)
00167     {
00168     OutputError(dwResult);
00169     exit(4);
00170     }
00171   else
00172     printf("DHCP Client Options API version %d\n", dwVersion);
00173
00174   printf("Setting DHCP Options on Adapter [%S]\n", wszAdapter);
00175
00176   // remove persistence if required
00177   if (bRemovePersist)
00178     {
00179     printf("Removing Option Persistence...\n");
00180     dwResult = DhcpUndoRequestParams(0, NULL, wszAdapter,
00181                                      DHCP_PERSISTENT_APP_STRING);
00182     if (dwResult != ERROR_SUCCESS)
00183       OutputError(dwResult);
00184     }
00185   else
00186     {
00187     //
00188     // Here the request is set up - since this is an easy example, the request
00189     // is set up statically, however in a real-world scenario this may require
00190     // building the request array in a more 'dynamic' way
00191     //
00192     // the DHCP Client Options API arrays for getting the options
00193     DHCPCAPI_PARAMS requests[1] =
00194                 {{0, OPTION_TIME_SERVERS, FALSE, NULL, 0}}; // gateway address
00195
00196     // set-up the actual arrays
00197     DHCPCAPI_PARAMS_ARRAY sendarray = {0, NULL}; // we aren't sending anything
00198     DHCPCAPI_PARAMS_ARRAY requestarray = {1, requests}; // we are requesting 1
00199
00200     // buffer variables
00201     DWORD dwSize = INITIAL_BUFFER_SIZE; // size of buffer for options
00202     LPBYTE buffer = NULL;               // buffer for options
00203     IN_ADDR addr;                       // address in return code
00204
00205     // loop until buffer is big enough to get the data and then make request
00206     do
00207       {
00208       if (buffer)
00209         LocalFree(buffer);
00210
00211       buffer = (LPBYTE) LocalAlloc(LPTR, dwSize);       // allocate the buffer
00212       if (!buffer)
00213         {
00214         OutputError(GetLastError());
00215         exit(5);
00216         }
00217
00218       // make the request on the adapter
00219       DWORD dwFlags = DHCPCAPI_REQUEST_SYNCHRONOUS;
00220       if (bAddPersist)
00221         {
00222         dwFlags = DHCPCAPI_REQUEST_PERSISTENT;
00223         printf("Making the request persistent...\n");
00224         }
00225
00226       dwResult = DhcpRequestParams(dwFlags,
00227                                    NULL,
00228                                    wszAdapter,
00229                                    NULL, sendarray,
00230                                    requestarray,
00231                                    buffer, &dwSize,
00232                                    bAddPersist ?
00233                                         DHCP_PERSISTENT_APP_STRING : NULL);
00234       }
00235     while (dwResult == ERROR_MORE_DATA);
00236
00237     // parse out results only if we made the synchronous request
00238     if (dwResult == ERROR_SUCCESS)
00239       {
00240       if (bAddPersist != TRUE)
00241         {
00242         // check for time server
00243         if (requests[0].nBytesData > 0)
00244           {
00245           memcpy(&addr, (LPVOID) requests[0].Data, 4);
00246           printf("Time Server: %s\n", inet_ntoa(addr));
00247           }
00248         else
00249           printf("Time Server NOT present!\n");
00250         }
00251       }
00252     else
00253       {
00254       OutputError(dwResult);
00255       }
00256
00257     // free the buffer
00258     if (buffer)
00259       LocalFree(buffer);
00260     }
00261
00262   // de-init the api
00263   DhcpCApiCleanup();
00264
00265   return 0;
00266 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSkateboard Member List

This is the complete list of members for CSkateboard, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
CSkateboard(int i) | CSkateboard | [inline]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetBitmapIndex() | CSkateboard | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetDisplayName(int nCol=0) | CSkateboard | [virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
getNodeType() | CSkateboard | [inline, virtual]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
id | CSkateboard | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CSkateboard | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
~CSkateboard() | CSkateboard | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/StdAfx.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

StdAfx.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // stdafx.cpp : source file that includes just the standard includes
00013 //  test.pch will be the pre-compiled header
00014 //  stdafx.obj will contain the pre-compiled type information
00015
00016 #include "stdafx.h"
00017
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IPC/NamePipe/npClient/Client32.h Source File

  • WinBase
  • IPC
  • NamePipe
  • npClient

Client32.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00009
00010 *       This source code is only intended as a supplement to
00011 *       Microsoft Development Tools and/or WinHelp documentation.
00012 *       See these sources for detailed information regarding the
00013 *       Microsoft samples programs.
00014 \******************************************************************************/
00015
00016 // Various buffer sizes
00017 #define IN_BUF_SIZE        1000
00018 #define OUT_BUF_SIZE       1000
00019 #define PLEASE_READ        1000
00020 #define PLEASE_WRITE       1000
00021 #define LINE_LEN           80
00022 #define NAME_SIZE          25
00023
00024 // For the Client dialog box.
00025 #define IDB_SEND           904
00026 #define IDD_EDITWRITE      905
00027 #define IDD_EDITREAD       906
00028
00029 // For the Init dialog box.
00030 #define IDD_SVREDIT        701
00031 #define IDB_INITOK         705
00032 #define IDD_CLNTEDIT       704
00033
00034
00035 #define WM_APP             0x8000
00036 #define WM_INITCLIENT      WM_APP
00037 #define WM_GO_AWAY         WM_APP+1
00038
00039 // Stringtable identifiers
00040 #define IDS_CANTFINDPIPE    100
00041 #define IDS_GENERALERROR    101
00042 #define IDS_DEBUGTITLE      102
00043 #define IDS_CONNECTBROKEN   103
00044 #define IDS_READFAILED      104
00045 #define IDS_CLIENTDBG       105
00046
00047
00048
00049 LONG CALLBACK MainWndProc   (HWND, UINT, WPARAM, LPARAM);
00050 LONG CALLBACK ClientDlgProc (HWND, UINT, WPARAM, LPARAM);
00051 LONG CALLBACK InitDlgProc   (HWND, UINT, WPARAM, LPARAM);
00052 VOID          ReadPipe      (HANDLE *);
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/StoClien.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

StoClien.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      STOCLIEN.CPP
00003
00004   Summary:   This client loads and accesses the Connectable DllPaper
00005              component provided in a separate in-process COM Server
00006              (STOSERVE built in the sibling STOSERVE directory). Thus to
00007              run STOCLIEN you must build STOSERVE first. This client
00008              application is meant to exercise the STOSERVE in-process
00009              server and to illustrate the use of the compound file storage
00010              supported by both the CPapFile C++ object in STOCLIEN and the
00011              COPaper COM object in the STOSERVE server. Both client and
00012              server cooperate to use compound files to store drawing
00013              paper data.
00014
00015              The COPaper object maintains logic and data to represent a
00016              white sheet of free-form drawing paper. The behavior is much
00017              like other C++ scribble code samples except that the
00018              STOCLIEN/STOSERVE pair are implemented using custom COM
00019              objects, interfaces, and standard COM services. The client
00020              mouse activity is used to draw ink lines on the paper
00021              surface. The COPaper object keeps a memory array of the Ink
00022              data but performs no GUI display. This STOCLIEN (largely
00023              within the CGuiPaper object) manages the display of the
00024              current drawing data.
00025
00026              There is no GUI behavior in the server--it is all in this
00027              client.  This client instantiates one instance of the
00028              server's COPaper COM object and then allows the user to
00029              use the mouse to draw lines in the client area of the
00030              main window.
00031
00032              For a comprehensive tutorial code tour of STOCLIEN's contents
00033              and offerings see the tutorial STOCLIEN.HTM file. For
00034              more specific technical details on the internal workings see
00035              the comments dispersed throughout the STOCLIEN source code.
00036              For more details on the STOSERVE.DLL that STOCLIEN works with
00037              see the STOSERVE.HTM file in the main tutorial directory.
00038
00039   Classes:   CMainWindow.
00040
00041   Functions: InitApplication, WinMain
00042
00043   Origin:    6-10-96: atrent - Editor-inheritance from the CONCLIEN source.
00044
00045 ----------------------------------------------------------------------------
00046   This file is part of the Microsoft COM Tutorial Code Samples.
00047
00048   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00049
00050   This source code is intended only as a supplement to Microsoft
00051   Development Tools and/or on-line documentation.  See these other
00052   materials for detailed information regarding Microsoft code samples.
00053
00054   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00055   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00056   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00057   PARTICULAR PURPOSE.
00058 ==========================================================================+*/
00059
00060 /*--------------------------------------------------------------------------
00061   We include WINDOWS.H for all Win32 applications.
00062   We include OLE2.H because we will be calling the COM/OLE Libraries.
00063   We include OLECTL.H because it has definitions for connectable objects.
00064   We include INITGUID.H only once (here) in the entire app because we
00065     will be defining GUIDs and want them as constants in the data segment.
00066   We include COMMDLG.H because we will be using the Open File
00067     and potentially other Common dialogs.
00068   We include APPUTIL.H because we will be building this application using
00069     the convenient Virtual Window and Dialog classes and other
00070     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00071   We include IPAPER.H and PAPGUIDS.H for the common paper-related Interface
00072     class, GUID, and CLSID specifications.
00073   We include PAPFILE.H because it has the C++ class used for compound file
00074     storage of drawing paper data.
00075   We include GUIPAPER.H because it has the C++ class used for GUI display
00076     of the drawing paper.
00077   We include STOCLIEN.H because it has class and resource definitions
00078     specific to this STOCLIEN application.
00079 ---------------------------------------------------------------------------*/
00080 #include <windows.h>
00081 #include <ole2.h>
00082 #include <olectl.h>
00083 #include <initguid.h>
00084 #include <commdlg.h>
00085 #include <apputil.h>
00086 #include <ipaper.h>
00087 #include <papguids.h>
00088 #include "papfile.h"
00089 #include "guipaper.h"
00090 #include "stoclien.h"
00091
00092
00093 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00094   Method:   CMainWindow::CMainWindow
00095
00096   Summary:  CMainWindow Constructor.
00097
00098   Args:     .
00099
00100   Returns:  .
00101 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00102 CMainWindow::CMainWindow()
00103 {
00104   // Ensure these member variable strings are null strings.
00105   m_szFileName[0] = 0;
00106   m_szFileTitle[0] = 0;
00107
00108   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00109   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00110   m_ofnFile.hwndOwner = m_hWnd;
00111   m_ofnFile.hInstance = m_hInst;
00112   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00113   m_ofnFile.lpstrCustomFilter = NULL;
00114   m_ofnFile.nMaxCustFilter = 0;
00115   m_ofnFile.nFilterIndex = 1;
00116   m_ofnFile.lpstrFile = m_szFileName;
00117   m_ofnFile.nMaxFile = MAX_PATH;
00118   m_ofnFile.lpstrInitialDir = TEXT(".");
00119   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00120   m_ofnFile.nMaxFileTitle = MAX_PATH;
00121   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00122   m_ofnFile.lpstrDefExt = NULL;
00123   m_ofnFile.Flags = OFN_HIDEREADONLY;
00124
00125   m_pMsgBox  = NULL;
00126   m_pGuiPaper = NULL;
00127 }
00128
00129
00130 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00131   Method:   CMainWindow::~CMainWindow
00132
00133   Summary:  CMainWindow Destructor.  Destruction of the main window
00134             indicates that the application should quit and thus the
00135             PostQuitMessage API is called.
00136
00137   Args:     .
00138
00139   Returns:  .
00140 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00141 CMainWindow::~CMainWindow()
00142 {
00143   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00144   // message and causes a delete of CMainWindow which in turn causes this
00145   // destructor to run. The WM_DESTROY results when the window is destoyed
00146   // after a close of the window. Prior to exiting the main message loop:
00147
00148   // We delete the CGuiPaper and CMsgBox objects that were made in
00149   // Initinstance.
00150   DELETE_POINTER(m_pGuiPaper);
00151   DELETE_POINTER(m_pMsgBox);
00152
00153   // We then post a WM_QUIT message to cause an exit of the main
00154   // message loop and an exit of this instance of the application.
00155   PostQuitMessage(0);
00156 }
00157
00158
00159 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00160   Method:   CMainWindow::InitInstance
00161
00162   Summary:  Instantiates an instance of the main application window.
00163             This method must be called only once, immediately after
00164             window class construction.  We take care to delete 'this'
00165             CMainWindow if we must return the error condition FALSE.
00166
00167   Args:     HINSTANCE hInstance,
00168               Handle of the application instance.
00169             LPSTR pszCmdLine,
00170               Pointer to the application's invocation command line.
00171             int nCmdShow)
00172               Command to pass to ShowWindow.
00173
00174   Modifies: m_szHelpFile, m_pMsgBox.
00175
00176   Returns:  BOOL.
00177               TRUE if succeeded.
00178               FALSE if failed.
00179 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00180 BOOL CMainWindow::InitInstance(
00181        HINSTANCE hInstance,
00182        LPSTR pszCmdLine,
00183        int nCmdShow)
00184 {
00185   BOOL bOk = FALSE;
00186   HWND hWnd = NULL;
00187   HRESULT hr = E_FAIL;
00188
00189   // Create the Message Box and Message Log objects.
00190   m_pMsgBox = new CMsgBox;
00191
00192   // Create the CGuiPaper C++ object.
00193   m_pGuiPaper = new CGuiPaper;
00194
00195   if (NULL != m_pMsgBox && NULL != m_pGuiPaper)
00196   {
00197     // Note, the Create method sets the m_hWnd member so we don't
00198     // need to set it explicitly here first. Here is the create of this
00199     // window.  Size the window reasonably. Create sets both m_hInst and
00200     // m_hWnd. This creates the main client window.
00201     hWnd = Create(
00202              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00203              TEXT(MAIN_WINDOW_TITLE_STR),
00204              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00205                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00206              CW_USEDEFAULT,
00207              CW_USEDEFAULT,
00208              ::GetSystemMetrics(SM_CXSCREEN)*2/5,
00209              ::GetSystemMetrics(SM_CYSCREEN)*2/5,
00210              NULL,
00211              NULL,
00212              hInstance);
00213     if (NULL != hWnd)
00214     {
00215       if (pszCmdLine[0] == 0)
00216         pszCmdLine = NULL;
00217
00218 #if defined(UNICODE)
00219       {
00220         WCHAR wszUc[MAX_PATH];
00221
00222         if (pszCmdLine)
00223         {
00224           // Convert Ansi command line string to Unicode if we are
00225           // compiled for Unicode.
00226           AnsiToUc(pszCmdLine, wszUc, MAX_PATH);
00227           // Init the new GuiPaper.
00228           bOk = m_pGuiPaper->Init(m_hInst, m_hWnd, wszUc);
00229         }
00230         else
00231           bOk = m_pGuiPaper->Init(m_hInst, m_hWnd, NULL);
00232       }
00233 #else
00234       // Init the new GuiPaper.
00235       bOk = m_pGuiPaper->Init(m_hInst, m_hWnd, pszCmdLine);
00236 #endif
00237
00238       if (bOk)
00239       {
00240         // Ensure the new window is shown on screen and content
00241         // is painted.
00242         ::ShowWindow(m_hWnd, nCmdShow);
00243         ::UpdateWindow(m_hWnd);
00244
00245         // Build a path to where the help file should be (it should be in
00246         // the same directory as the .EXE but with the .HTM extension).
00247         MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00248
00249         // Init the Message Box object.
00250         bOk = m_pMsgBox->Init(m_hInst, m_hWnd);
00251
00252         // Lock the paper object for drawing by this client. Can't draw
00253         // with mouse until doing this. Set the proper checkmark
00254         // indicator on the menu selections as well.
00255         hr = m_pGuiPaper->DrawOn();
00256         if (SUCCEEDED(hr))
00257         {
00258           HMENU hMenu  = ::GetMenu(m_hWnd);
00259
00260           ::CheckMenuItem(
00261               hMenu,
00262               IDM_DRAW_ON,
00263               MF_BYCOMMAND | MF_CHECKED);
00264           ::CheckMenuItem(
00265               hMenu,
00266               IDM_DRAW_OFF,
00267               MF_BYCOMMAND | MF_UNCHECKED);
00268
00269           // Connect the new Paper Sink in this client to receive event
00270           // calls from a COPaper source in the server.
00271           hr = m_pGuiPaper->ConnectPaperSink();
00272           if (SUCCEEDED(hr))
00273           {
00274             ::CheckMenuItem(
00275                 hMenu,
00276                 IDM_SINK_ON,
00277                 MF_BYCOMMAND | MF_CHECKED);
00278             ::CheckMenuItem(
00279                 hMenu,
00280                 IDM_SINK_OFF,
00281                 MF_BYCOMMAND | MF_UNCHECKED);
00282
00283             // Try to load the paper data compound file. Either the
00284             // default STOCLIEN.PAP or the one specified on the
00285             // invocation command line.
00286             m_pGuiPaper->Load();
00287           }
00288         }
00289       }
00290     }
00291   }
00292
00293   if (!bOk)
00294   {
00295     DELETE_POINTER(m_pMsgBox);
00296     DELETE_POINTER(m_pGuiPaper);
00297   }
00298
00299   bOk = SUCCEEDED(hr);
00300
00301   return (bOk);
00302 }
00303
00304
00305 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00306   Method:   CMainWindow::DoMenu
00307
00308   Summary:  Dispatch and handle the main menu commands.
00309
00310   Args:     WPARAM wParam,
00311               First message parameter (word sized).
00312             LPARAM lParam)
00313               Second message parameter (long sized).
00314
00315   Modifies: m_ofnFile, ...
00316
00317   Returns:  LRESULT
00318               Standard Windows WindowProc return value.
00319 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00320 LRESULT CMainWindow::DoMenu(
00321           WPARAM wParam,
00322           LPARAM lParam)
00323 {
00324   LRESULT lResult = FALSE;
00325   HMENU hMenu  = ::GetMenu(m_hWnd);
00326
00327   switch (LOWORD(wParam))
00328   {
00329     //----------------------------------------------------------------------
00330     // Handle File Menu Commands.
00331     //----------------------------------------------------------------------
00332     case IDM_FILE_OPEN:
00333       // Open existing compound file and ask COPaper to load itself from it.
00334       m_pGuiPaper->Open();
00335       break;
00336     case IDM_FILE_SAVE:
00337       // Open current compound file and ask COPaper to save itself to it.
00338       m_pGuiPaper->Save();
00339       break;
00340     case IDM_FILE_SAVEAS:
00341       // Create new compound file and ask COPaper to save itself to it.
00342       m_pGuiPaper->SaveAs();
00343       break;
00344     case IDM_FILE_EXIT:
00345       // The user commands us to exit this application so we tell the
00346       // Main window to close itself.
00347       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00348       break;
00349
00350     //----------------------------------------------------------------------
00351     // Handle Draw Menu Choice Commands.
00352     //----------------------------------------------------------------------
00353     case IDM_DRAW_ON:
00354       // Lock the paper object for drawing by this client. Can't draw
00355       // with mouse until doing this. Set the proper checkmark indicator
00356       // on the menu selections as well.
00357       {
00358         HRESULT hr;
00359         HMENU hMenu  = ::GetMenu(m_hWnd);
00360         BOOL bDrawOn = ::GetMenuState(
00361                            hMenu,
00362                            IDM_DRAW_ON,
00363                            MF_BYCOMMAND) & MF_CHECKED;
00364         if (!bDrawOn)
00365         {
00366           hr = m_pGuiPaper->DrawOn();
00367           if (SUCCEEDED(hr))
00368           {
00369             ::CheckMenuItem(
00370                 hMenu,
00371                 IDM_DRAW_ON,
00372                 MF_BYCOMMAND | MF_CHECKED);
00373             ::CheckMenuItem(
00374                 hMenu,
00375                 IDM_DRAW_OFF,
00376                 MF_BYCOMMAND | MF_UNCHECKED);
00377             // Ask Paper object to redraw its current content.
00378             m_pGuiPaper->PaintWin();
00379           }
00380         }
00381       }
00382       break;
00383     case IDM_DRAW_OFF:
00384       // Unlock the paper object for drawing by this client. Set the
00385       // proper checkmark indicator on the menu selections as well.
00386       {
00387         HRESULT hr;
00388         HMENU hMenu  = ::GetMenu(m_hWnd);
00389         BOOL bDrawOff = ::GetMenuState(
00390                             hMenu,
00391                             IDM_DRAW_OFF,
00392                             MF_BYCOMMAND) & MF_CHECKED;
00393         if (!bDrawOff)
00394         {
00395           hr = m_pGuiPaper->DrawOff();
00396           if (SUCCEEDED(hr))
00397           {
00398             ::CheckMenuItem(
00399                 hMenu,
00400                 IDM_DRAW_ON,
00401                 MF_BYCOMMAND | MF_UNCHECKED);
00402             ::CheckMenuItem(
00403                 hMenu,
00404                 IDM_DRAW_OFF,
00405                 MF_BYCOMMAND | MF_CHECKED);
00406           }
00407         }
00408       }
00409       break;
00410     case IDM_DRAW_REDRAW:
00411       // Ask Paper object to redraw its current content.
00412       m_pGuiPaper->PaintWin();
00413       break;
00414     case IDM_DRAW_ERASE:
00415       // Ask Paper object to erase its current content and if it can
00416       // Clear drawing display window.
00417       m_pGuiPaper->Erase();
00418       break;
00419
00420     //----------------------------------------------------------------------
00421     // Handle Pen Menu Commands.
00422     //----------------------------------------------------------------------
00423     case IDM_PEN_COLOR:
00424       // Select Ink drawing color using ChooseColor common dialog.
00425       {
00426         COLORREF crNewColor = m_pGuiPaper->PickColor();
00427         m_pGuiPaper->InkColor(crNewColor);
00428       }
00429       break;
00430     case IDM_PEN_THIN:
00431       // Select thin Ink width. Set menu check indicator.
00432       {
00433         HRESULT hr;
00434         HMENU hMenu  = ::GetMenu(m_hWnd);
00435         BOOL bOn = ::GetMenuState(
00436                        hMenu,
00437                        IDM_PEN_THIN,
00438                        MF_BYCOMMAND) & MF_CHECKED;
00439         if (!bOn)
00440         {
00441           hr = m_pGuiPaper->InkWidth(INK_THIN);
00442           if (SUCCEEDED(hr))
00443           {
00444             ::CheckMenuItem(
00445                 hMenu,
00446                 IDM_PEN_THIN,
00447                 MF_BYCOMMAND | MF_CHECKED);
00448             ::CheckMenuItem(
00449                 hMenu,
00450                 IDM_PEN_MEDIUM,
00451                 MF_BYCOMMAND | MF_UNCHECKED);
00452             ::CheckMenuItem(
00453                 hMenu,
00454                 IDM_PEN_THICK,
00455                 MF_BYCOMMAND | MF_UNCHECKED);
00456           }
00457         }
00458       }
00459       break;
00460     case IDM_PEN_MEDIUM:
00461       // Select medium Ink width. Set menu check indicator.
00462       {
00463         HRESULT hr;
00464         HMENU hMenu  = ::GetMenu(m_hWnd);
00465         BOOL bOn = ::GetMenuState(
00466                        hMenu,
00467                        IDM_PEN_MEDIUM,
00468                        MF_BYCOMMAND) & MF_CHECKED;
00469         if (!bOn)
00470         {
00471           hr = m_pGuiPaper->InkWidth(INK_MEDIUM);
00472           if (SUCCEEDED(hr))
00473           {
00474             ::CheckMenuItem(
00475                 hMenu,
00476                 IDM_PEN_MEDIUM,
00477                 MF_BYCOMMAND | MF_CHECKED);
00478             ::CheckMenuItem(
00479                 hMenu,
00480                 IDM_PEN_THICK,
00481                 MF_BYCOMMAND | MF_UNCHECKED);
00482             ::CheckMenuItem(
00483                 hMenu,
00484                 IDM_PEN_THIN,
00485                 MF_BYCOMMAND | MF_UNCHECKED);
00486           }
00487         }
00488       }
00489       break;
00490     case IDM_PEN_THICK:
00491       // Select thick Ink width. Set menu check indicator.
00492       {
00493         HRESULT hr;
00494         HMENU hMenu  = ::GetMenu(m_hWnd);
00495         BOOL bOn = ::GetMenuState(
00496                        hMenu,
00497                        IDM_PEN_THICK,
00498                        MF_BYCOMMAND) & MF_CHECKED;
00499         if (!bOn)
00500         {
00501           hr = m_pGuiPaper->InkWidth(INK_THICK);
00502           if (SUCCEEDED(hr))
00503           {
00504             ::CheckMenuItem(
00505                 hMenu,
00506                 IDM_PEN_THICK,
00507                 MF_BYCOMMAND | MF_CHECKED);
00508             ::CheckMenuItem(
00509                 hMenu,
00510                 IDM_PEN_MEDIUM,
00511                 MF_BYCOMMAND | MF_UNCHECKED);
00512             ::CheckMenuItem(
00513                 hMenu,
00514                 IDM_PEN_THIN,
00515                 MF_BYCOMMAND | MF_UNCHECKED);
00516           }
00517         }
00518       }
00519       break;
00520
00521     //----------------------------------------------------------------------
00522     // Handle Sink Menu Commands.
00523     //----------------------------------------------------------------------
00524     case IDM_SINK_ON:
00525       // Connect the client's event Paper Sink to the COPaper event
00526       // source in the server. Set the proper checkmark indicator on
00527       // the menu selections as well.
00528       {
00529         HRESULT hr;
00530         HMENU hMenu  = ::GetMenu(m_hWnd);
00531         BOOL bConnected = ::GetMenuState(
00532                               hMenu,
00533                               IDM_SINK_ON,
00534                               MF_BYCOMMAND) & MF_CHECKED;
00535         if (!bConnected)
00536         {
00537           hr = m_pGuiPaper->ConnectPaperSink();
00538           if (SUCCEEDED(hr))
00539           {
00540             ::CheckMenuItem(
00541                 hMenu,
00542                 IDM_SINK_ON,
00543                 MF_BYCOMMAND | MF_CHECKED);
00544             ::CheckMenuItem(
00545                 hMenu,
00546                 IDM_SINK_OFF,
00547                 MF_BYCOMMAND | MF_UNCHECKED);
00548           }
00549         }
00550       }
00551       break;
00552     case IDM_SINK_OFF:
00553       // Disconnect the client's event Paper Sink from the COPaper
00554       // event source in the server. Set the proper checkmark indicator
00555       // on the menu selections as well.
00556       {
00557         HRESULT hr;
00558         HMENU hMenu  = ::GetMenu(m_hWnd);
00559         BOOL bDisConnected = ::GetMenuState(
00560                                 hMenu,
00561                                 IDM_SINK_OFF,
00562                                 MF_BYCOMMAND) & MF_CHECKED;
00563         if (!bDisConnected)
00564         {
00565           hr = m_pGuiPaper->DisconnectPaperSink();
00566           if (SUCCEEDED(hr))
00567           {
00568             ::CheckMenuItem(
00569                 hMenu,
00570                 IDM_SINK_ON,
00571                 MF_BYCOMMAND | MF_UNCHECKED);
00572             ::CheckMenuItem(
00573                 hMenu,
00574                 IDM_SINK_OFF,
00575                 MF_BYCOMMAND | MF_CHECKED);
00576           }
00577         }
00578       }
00579       break;
00580
00581     //----------------------------------------------------------------------
00582     // Handle Help Menu Commands.
00583     //----------------------------------------------------------------------
00584     case IDM_HELP_CONTENTS:
00585       // We have some stubbed support here for bringing up the online
00586       // Help for this application.
00587       ReadHelp(m_hWnd, m_szHelpFile);
00588       break;
00589     case IDM_HELP_TUTORIAL:
00590       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00591       // tutorial narrative file associated with this tutorial code sample.
00592       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00593       break;
00594     case IDM_HELP_TUTSERVER:
00595       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00596       // tutorial narrative file associated with the STOSERVE COM server.
00597       ReadTutorial(m_hInst, m_hWnd, TEXT(SERVER_TUTFILE_STR));
00598       break;
00599     case IDM_HELP_READSOURCE:
00600       // Call the APPUTIL utility function ReadSource to allow the
00601       // user to open and read any of the source files of STOCLIEN.
00602       ReadSource(m_hWnd, &m_ofnFile);
00603       break;
00604     case IDM_HELP_ABOUT:
00605       {
00606         CAboutBox dlgAboutBox;
00607
00608         // Show the standard About Box dialog for this EXE by telling the
00609         // dialog C++ object to show itself by invoking its ShowDialog
00610         // method.  Pass it this EXE instance and the parent window handle.
00611         // Use a dialog resource ID for the dialog template stored in
00612         // this EXE module's resources.
00613         dlgAboutBox.ShowDialog(
00614           m_hInst,
00615           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00616           m_hWnd);
00617       }
00618       break;
00619
00620     default:
00621       // Defer all messages NOT handled here to the Default Window Proc.
00622       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00623       break;
00624   }
00625
00626   return(lResult);
00627 }
00628
00629
00630 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00631   Method:   CMainWindow::WindowProc
00632
00633   Summary:  Main window procedure for this window object.  See CVirWindow
00634             in the APPUTIL library (APPUTIL.CPP) for details on how this
00635             method gets called by the global WindowProc.
00636
00637   Args:     UINT uMsg,
00638               Windows message that is "sent" to this window.
00639             WPARAM wParam,
00640               First message parameter (word sized).
00641             LPARAM lParam)
00642               Second message parameter (long sized).
00643
00644   Modifies: ...
00645
00646   Returns:  LRESULT
00647               Standard Windows WindowProc return value.
00648 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00649 LRESULT CMainWindow::WindowProc(
00650           UINT uMsg,
00651           WPARAM wParam,
00652           LPARAM lParam)
00653 {
00654   LRESULT lResult = FALSE;
00655
00656   switch (uMsg)
00657   {
00658     case WM_CREATE:
00659       break;
00660
00661     case WM_ACTIVATE:
00662       // If we were newly activated by a mouse click then don't just sit
00663       // there--re-paint. This is needed when another window was topped
00664       // over part of STOCLIEN and the user then topped STOCLIEN using
00665       // a mouse click on the visible part of STOCLIEN. In any case let
00666       // the windows default WindowProc handle this message to set
00667       // keyboard focus to the newly active window.
00668       if (WA_CLICKACTIVE == LOWORD(wParam))
00669         m_pGuiPaper->PaintWin();
00670       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00671       break;
00672
00673     case WM_MEASUREITEM:
00674       // Get setup for painting text in this window. For later evolution.
00675       {
00676         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00677         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00678         lpmis->itemWidth = m_wWidth;
00679         lResult = TRUE;
00680       }
00681
00682     case WM_SIZE:
00683       // Handle a resize of this window.
00684       m_wWidth = LOWORD(lParam);
00685       m_wHeight = HIWORD(lParam);
00686       // Inform CGuiPaper of the change.
00687       m_pGuiPaper->Resize(m_wWidth, m_wHeight);
00688       break;
00689
00690     case WM_PAINT:
00691       // If something major happened repaint the whole window.
00692       {
00693         PAINTSTRUCT ps;
00694
00695         if(BeginPaint(m_hWnd, &ps))
00696         {
00697           m_pGuiPaper->PaintWin();
00698           EndPaint(m_hWnd, &ps);
00699         }
00700       }
00701       break;
00702
00703     case WM_LBUTTONDOWN:
00704       // Start sequence of ink drawing to the paper.
00705       m_pGuiPaper->InkStart(LOWORD(lParam), HIWORD(lParam));
00706       break;
00707
00708     case WM_MOUSEMOVE:
00709       // Draw inking sequence data.
00710       m_pGuiPaper->InkDraw(LOWORD(lParam), HIWORD(lParam));
00711       break;
00712
00713     case WM_LBUTTONUP:
00714       // Stop an ink drawing sequence.
00715       m_pGuiPaper->InkStop(LOWORD(lParam), HIWORD(lParam));
00716       break;
00717
00718     case WM_COMMAND:
00719       // Dispatch and handle any Menu command messages received.
00720       lResult = DoMenu(wParam, lParam);
00721       break;
00722
00723     case WM_CHAR:
00724       if (wParam == 0x1b)
00725       {
00726         // Exit this app if user hits ESC key.
00727         ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00728       }
00729       break;
00730
00731     case WM_CLOSE:
00732       // The user selected Close on the main window's System menu
00733       // or Exit on the File menu.
00734       // If there is ink data that has not been saved then ask user
00735       // if it should be saved. If user cancels then cancel the exit.
00736       if (IDCANCEL == m_pGuiPaper->AskSave())
00737         break;
00738     case WM_QUIT:
00739       // If the app is being quit then close any associated help windows.
00740     default:
00741       // Defer all messages NOT handled above to the Default Window Proc.
00742       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00743       break;
00744   }
00745
00746   return(lResult);
00747 }
00748
00749
00750 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00751   Function: UnicodeOk
00752
00753   Summary:  Checks if the platform will handle unicode versions of
00754             Win32 string API calls.
00755
00756   Args:     void
00757
00758   Returns:  BOOL
00759               TRUE if unicode support; FALSE if not.
00760 ------------------------------------------------------------------------F-F*/
00761 BOOL UnicodeOk(void)
00762 {
00763   BOOL bOk = TRUE;
00764   TCHAR szUserName[MAX_STRING_LENGTH];
00765   DWORD dwSize = MAX_STRING_LENGTH;
00766
00767   if (!GetUserName(szUserName, &dwSize))
00768     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00769
00770   return bOk;
00771 }
00772
00773
00774 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00775   Function: InitApplication
00776
00777   Summary:  Initializes the application and registers its main window
00778             class. InitApplication is called only once (in WinMain).
00779
00780   Args:     HINSTANCE hInstance)
00781               Handle to the first instance of the application.
00782
00783   Returns:  BOOL.
00784               TRUE if success.
00785               FALSE if fail.
00786 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00787 BOOL InitApplication(
00788        HINSTANCE hInstance)
00789 {
00790   BOOL bOk;
00791   // The window class for all instances of the main frame window.
00792   WNDCLASSEX wcf;
00793
00794   // Assign the appropriate values for this main frame window class.
00795   wcf.cbSize        = sizeof(WNDCLASSEX);
00796   wcf.cbClsExtra    = 0;            // No per-class extra data.
00797   wcf.cbWndExtra    = 0;            // No per-window extra data.
00798   wcf.hInstance     = hInstance;    // Application module instance.
00799   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00800                                     // APPUTIL for all CVirWindows).
00801   wcf.hCursor       = LoadCursor(                  // Load app cursor.
00802                         hInstance,
00803                         TEXT("AppCursor"));
00804   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00805                                 hInstance,
00806                                 TEXT("AppIcon"));
00807   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00808                                 hInstance,
00809                                 TEXT("AppIcon"),
00810                                 IMAGE_ICON,
00811                                 16, 16,
00812                                 0);
00813   wcf.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // Backgnd color.
00814   wcf.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Class style(s).
00815   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR);   // Class name.
00816   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR);   // Menu name.
00817
00818   // Register the window class and return FALSE if unsuccesful.
00819   bOk = RegisterClassEx(&wcf);
00820
00821   return (bOk);
00822 }
00823
00824
00825 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00826   Function: WinMain
00827
00828   Summary:  The Windows main entry point function for this application.
00829             Initializes the application, the COM Libraries, and starts
00830             the main application message loop.
00831
00832   Args:     HINSTANCE hInstance,
00833               Instance handle; a new one for each invocation of this app.
00834             HINSTANCE hPrevInstance,
00835               Instance handle of the previous instance. NULL in Win32.
00836             LPSTR pszCmdLine,
00837               Windows passes a pointer to the application's
00838               invocation command line.
00839             int nCmdShow)
00840               Bits telling the show state of the application.
00841
00842   Returns:  int
00843               msg.wParam (upon exit of message loop).
00844               FALSE if this instance couldn't initialize and run.
00845 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00846 extern "C" int PASCAL WinMain(
00847                         HINSTANCE hInstance,
00848                         HINSTANCE hPrevInstance,
00849                         LPSTR pszCmdLine,
00850                         int nCmdShow)
00851 {
00852   CMainWindow* pWin = NULL;
00853   MSG msg;
00854   HACCEL hAccel;
00855   int iRun = FALSE;
00856
00857   // If we were compiled for UNICODE and the platform seems OK with this
00858   // then proceed.  Else we error and exit the app.
00859   if (UnicodeOk())
00860   {
00861     // Call to initialize the COM Library.  Use the SUCCEEDED macro
00862     // to detect success.  If fail then exit app with error message.
00863     // Tell COM that this client process and all subordinate threads
00864     // will live in an apartment threaded world.
00865     if (SUCCEEDED(CoInitialize(NULL)))
00866     {
00867       // If we succeeded in initializing the COM Library we proceed to
00868       // initialize the application.  If we can't init the application
00869       // then we signal shut down with an error message exit.
00870       iRun = InitApplication(hInstance);
00871       if (iRun)
00872       {
00873         // Assume we'll set iRun to TRUE when initialization is done.
00874         iRun = FALSE;
00875         // We are still go for running so we try to create a nifty new
00876         // CMainWindow object for this app instance.
00877         pWin = new CMainWindow;
00878         if (NULL != pWin)
00879         {
00880           // Now we initialize an instance of the new CMainWindow.
00881           // This includes creating the main window.
00882           if (pWin->InitInstance(hInstance, pszCmdLine, nCmdShow))
00883           {
00884             // Load the keyboard accelerators from the resources.
00885             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
00886             if (NULL != hAccel)
00887             {
00888               // Signal App Initialization is successfully done.
00889               iRun = TRUE;
00890             }
00891           }
00892         }
00893       }
00894
00895       if (iRun)
00896       {
00897         // If we initialized the app instance properly then we are still
00898         // go for running.  We then start up the main message pump for
00899         // the application.
00900         while (GetMessage(&msg, NULL, 0, 0))
00901         {
00902           if (!TranslateAccelerator(pWin->GetHwnd(), hAccel, &msg))
00903           {
00904             TranslateMessage(&msg);
00905             DispatchMessage(&msg);
00906           }
00907         }
00908
00909         // We also ask COM to unload any unused COM Servers, including our
00910         // friend, STOSERVE.
00911         CoFreeUnusedLibraries();
00912
00913         // We'll pass to Windows the reason why we exited the message loop.
00914         iRun = (int) msg.wParam;
00915       }
00916       else
00917       {
00918         // We failed to initialize the application. Put up error message
00919         // box saying that application couldn't be initialized.  Parent
00920         // window is desktop (ie, NULL). Exit the failed application
00921         // (ie, by returning FALSE to WinMain).
00922         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
00923
00924         // Delete the CMainWindow object.
00925         DELETE_POINTER(pWin);
00926       }
00927
00928       // We're exiting this app (either normally or by init failure) so
00929       // shut down the COM Library.
00930       CoUninitialize();
00931     }
00932     else
00933     {
00934       // We failed to Initialize the COM Library. Put up error message
00935       // box saying that COM Library couldn't be initialized.  Parent
00936       // window is desktop (ie, NULL). Exit the failed application
00937       // (ie, by returning FALSE to WinMain).
00938       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
00939     }
00940   }
00941   else
00942   {
00943     // If we were compiled for UNICODE but the platform has problems with
00944     // this then indicate an error and exit the app immediately.
00945     CHAR szMsg[MAX_STRING_LENGTH];
00946
00947     if (LoadStringA(
00948           hInstance,
00949           IDS_NOUNICODE,
00950           szMsg,
00951           MAX_STRING_LENGTH))
00952     {
00953       MessageBoxA(
00954         NULL,
00955         szMsg,
00956         ERROR_TITLE_STR,
00957         MB_OK | MB_ICONEXCLAMATION);
00958     }
00959   }
00960
00961   return iRun;
00962 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Handles/cxhndl/Cxhndlp.c Source File

  • NetDS
  • RPC
  • Handles
  • cxhndl

Cxhndlp.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         cxhndl Example
00005
00006     FILE:       cxhndlp.c
00007
00008     PURPOSE:    Remote procedures used in server application cxhndls
00009
00010     FUNCTIONS:  RemoteOpen() - Open the file
00011                 RemoteRead() - Read a buffer's worth of the file
00012                 RemoteClose() - Close the file and shutdown server
00013                 Shutdown() - Shutdown the server
00014
00015     COMMENTS:   This distributed application uses a context handle.
00016
00017 ****************************************************************************/
00018
00019 #include <stdlib.h>
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include "cxhndl.h"    // header file generated by MIDL compiler
00023
00024
00025 typedef struct {
00026     FILE *hFile;
00027     char achFile[256];
00028 } FILE_CONTEXT_TYPE;
00029
00030
00031 /* This remote procedure opens a file on the server. */
00032 short RemoteOpen(PCONTEXT_HANDLE_TYPE  *pphContext,
00033                  unsigned char         *pszFileName
00034     )
00035 {
00036     FILE *hFile;
00037     FILE_CONTEXT_TYPE *pFileContext;
00038
00039     if ((hFile = fopen(pszFileName, "r")) == NULL) {
00040         *pphContext = (PCONTEXT_HANDLE_TYPE) NULL;
00041         return(-1);
00042     }
00043     else {
00044         pFileContext = (FILE_CONTEXT_TYPE *)
00045                        midl_user_allocate(sizeof(FILE_CONTEXT_TYPE));
00046         pFileContext->hFile = hFile;
00047         strncpy(pFileContext->achFile, pszFileName, 255);
00048         *pphContext = (PCONTEXT_HANDLE_TYPE) pFileContext;
00049         return(0);
00050     }
00051 }
00052
00053 /* This remote procedure reads a file on the server. */
00054 short RemoteRead(PCONTEXT_HANDLE_TYPE  phContext,
00055                  unsigned char         *pbBuf,
00056                  short                 *pcbBuf)
00057 {
00058     FILE_CONTEXT_TYPE *pFileContext;
00059
00060     printf("in RemoteRead\n");
00061
00062     pFileContext = (FILE_CONTEXT_TYPE *) phContext;
00063     *pcbBuf = (short) fread(pbBuf,
00064                             sizeof(char),
00065                             BUFSIZE,
00066                             pFileContext->hFile);
00067     return(*pcbBuf);
00068 }
00069
00070 /* This remote procedure closes a file on the server. */
00071 short RemoteClose(PCONTEXT_HANDLE_TYPE *pphContext)
00072 {
00073     FILE_CONTEXT_TYPE *pFileContext;
00074
00075     printf("in RemoteClose\n");
00076
00077     pFileContext = (FILE_CONTEXT_TYPE *) *pphContext;
00078
00079     if ( fclose( pFileContext->hFile ) == 0)
00080         {
00081         midl_user_free( *pphContext );
00082         *pphContext = NULL;
00083         return(0);
00084         }
00085     else
00086         /* Context Rundown routine will attempt to close it again */
00087         return(-1);
00088 }
00089
00090 /* The Shutdown procedure tells the server to stop listening */
00091 /* for client requests.                                      */
00092 void Shutdown(void)
00093 {
00094     RPC_STATUS status;
00095
00096     printf("Calling RpcMgmtStopServerListening\n");
00097     status = RpcMgmtStopServerListening(NULL);
00098     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
00099     if (status) {
00100         exit(status);
00101     }
00102
00103     printf("Calling RpcServerUnregisterIf\n");
00104     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00105     printf("RpcServerUnregisterIf returned 0x%x\n", status);
00106     if (status) {
00107         exit(status);
00108     }
00109 }
00110
00111 /* The rundown routine is associated with the context handle type. */
00112 void __RPC_USER PCONTEXT_HANDLE_TYPE_rundown(PCONTEXT_HANDLE_TYPE phContext)
00113 {
00114     FILE_CONTEXT_TYPE *pFileContext;
00115
00116     printf("Context rundown routine\n");
00117
00118     if ( phContext )
00119     {
00120         pFileContext = (FILE_CONTEXT_TYPE *) phContext;
00121         if (pFileContext->hFile != NULL)
00122             fclose(pFileContext->hFile);
00123
00124         midl_user_free( phContext );
00125     }
00126
00127 }
00128
00129 /* end file cxhndlp.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RU_SOCKET Member List

This is the complete list of members for _RU_SOCKET, including all inherited members.
addr | _RU_SOCKET
Socket | _RU_SOCKET
uiSize | _RU_SOCKET
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIGetSourceRow Member List

This is the complete list of members for CImpIGetSourceRow, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CStream, CImpIGetSourceRow) | CImpIGetSourceRow
GetSourceRow(REFIID riid, IUnknown **ppRow) | CImpIGetSourceRow
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagENUMPRTLOOKUP Member List

This is the complete list of members for tagENUMPRTLOOKUP, including all inherited members.
dwValue | tagENUMPRTLOOKUP
szValue | tagENUMPRTLOOKUP
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/StdAfx.h Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

StdAfx.h

Go to the documentation of this file.
00001 // Filename: stdafx.h
00002 //
00003 // Description: Include file for standard system include files,
00004 //        or project specific include files that are used frequently,
00005 //        but are changed infrequently
00006 //
00007 // This file is provided as part of the Microsoft Transaction Server Samples
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00010 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00011 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00012 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00013 // PURPOSE.
00014 //
00015 // Copyright (C) 1997 - 2000 Microsoft Corporation, All rights reserved
00016
00017 #define _ATL_STATIC_REGISTRY
00018
00019 #if !defined(AFX_STDAFX_H__AA22C995_FD72_11D0_B5DC_00C04FB957D8__INCLUDED_)
00020 #define AFX_STDAFX_H__AA22C995_FD72_11D0_B5DC_00C04FB957D8__INCLUDED_
00021
00022 #if _MSC_VER >= 1000
00023 #pragma once
00024 #endif // _MSC_VER >= 1000
00025
00026 #define STRICT
00027
00028
00029 #if !defined(_WIN32_WINNT)
00030 #define _WIN32_WINNT 0x0500
00031 #endif // !defined(_WIN32_WINNT)
00032
00033 #define _ATL_APARTMENT_THREADED
00034
00035
00036 #include <atlbase.h>
00037 //You may derive a class from CComModule and use it if you want to override
00038 //something, but do not change the name of _Module
00039 extern CComModule _Module;
00040 #include <atlcom.h>
00041
00042
00043 #define THROW_ERR(exp) if (FAILED (hr = (exp))) throw hr
00044
00045 inline BSTR TCHAR2BSTR (TCHAR* szBuf) {
00046
00047   WCHAR* wszBuf;
00048
00049 #ifndef UNICODE
00050   wszBuf = new WCHAR [512];
00051   MultiByteToWideChar( CP_ACP, 0, szBuf, -1, wszBuf, 512 );
00052 #else
00053   wszBuf = szBuf;
00054 #endif
00055
00056   BSTR bstrNew = ::SysAllocString (wszBuf);
00057
00058 #ifndef UNICODE
00059   delete [] wszBuf;
00060 #endif
00061
00062   return bstrNew;
00063 }
00064
00065
00066 //{{AFX_INSERT_LOCATION}}
00067 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00068
00069 #endif // !defined(AFX_STDAFX_H__AA22C995_FD72_11D0_B5DC_00C04FB957D8__INCLUDED)
00070
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/About.Cpp Source File

  • SysMgmt
  • MMC
  • Help

About.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));;
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163   MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164   *lpDest = wszStr;
00165
00166     return S_OK;
00167 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/delebase.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

delebase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021
00022 const GUID CDelegationBase::thisGuid = { 0x786c6f77, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00023 // {786C6F77-6BE7-11d3-9156-00C04F65B3F9}
00024 //DEFINE_GUID(<<name>>,
00025 //0x786c6f77, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00026
00027
00028
00029 HBITMAP CDelegationBase::m_pBMapSm = NULL;
00030 HBITMAP CDelegationBase::m_pBMapLg = NULL;
00031
00032
00033 //==============================================================
00034 //
00035 // CDelegationBase implementation
00036 //
00037 //
00038 CDelegationBase::CDelegationBase()
00039 : bExpanded(FALSE)
00040 {
00041     if (NULL == m_pBMapSm || NULL == m_pBMapLg)
00042         LoadBitmaps();
00043 }
00044
00045 CDelegationBase::~CDelegationBase()
00046 {
00047 }
00048
00049 // CDelegationBase::AddImages sets up the collection of images to be displayed
00050 // by the IComponent in the result pane as a result of its MMCN_SHOW handler
00051 HRESULT CDelegationBase::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
00052 {
00053     return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
00054         (long *)m_pBMapLg, // pointer to a handle
00055         0, // index of the first image in the strip
00056         RGB(0, 128, 128)  // color of the icon mask
00057         );
00058 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyMemberSetChangeListener/dll.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyMemberSetChangeListener

dll.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      Dll.cpp
00005 //
00006 //  Description:
00007 //      Implementation of DLL Exports.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #include "stdafx.h"
00012 #include "resource.h"
00013 #include <initguid.h>
00014
00015 #include "MyMemberSetChangeListener.h"
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP( ObjectMap )
00020 OBJECT_ENTRY( CLSID_MyMemberSetChangeListener, CMyMemberSetChangeListener )
00021 END_OBJECT_MAP()
00022
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //++
00026 //
00027 // DllMain
00028 //
00029 // Description:
00030 //      DLL entry point.
00031 //
00032 //--
00033 /////////////////////////////////////////////////////////////////////////////
00034 extern "C"
00035 BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/ )
00036 {
00037     if ( dwReason == DLL_PROCESS_ATTACH )
00038     {
00039         _Module.Init( ObjectMap, hInstance ); // no typelib
00040         DisableThreadLibraryCalls( hInstance );
00041     }
00042     else if ( dwReason == DLL_PROCESS_DETACH )
00043     {
00044         _Module.Term();
00045     }
00046     return TRUE;    // ok
00047
00048 } //*** DllMain
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 //++
00052 //
00053 // DllCanUnloadNow
00054 //
00055 // Description:
00056 //      Used to determine whether the DLL can be unloaded by OLE.
00057 //
00058 //--
00059 /////////////////////////////////////////////////////////////////////////////
00060 STDAPI DllCanUnloadNow( void )
00061 {
00062     return ( _Module.GetLockCount()==0 ) ? S_OK : S_FALSE;
00063
00064 } //*** DllCanUnloadNow
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 //++
00068 //
00069 // DllGetClassObject
00070 //
00071 // Description:
00072 //      Returns a class factory to create an object of the requested type.
00073 //
00074 //--
00075 /////////////////////////////////////////////////////////////////////////////
00076 STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID * ppv )
00077 {
00078     return _Module.GetClassObject( rclsid, riid, ppv );
00079
00080 } //*** DllGetClassObject
00081
00082 /////////////////////////////////////////////////////////////////////////////
00083 //++
00084 //
00085 // DllRegisterServer
00086 //
00087 // Description:
00088 //      Adds entries to the system registry.
00089 //
00090 //--
00091 /////////////////////////////////////////////////////////////////////////////
00092 STDAPI DllRegisterServer( void )
00093 {
00094     // registers object; FALSE => no typelib
00095     return _Module.RegisterServer( FALSE );
00096
00097 } //*** DllRegisterServer
00098
00099 /////////////////////////////////////////////////////////////////////////////
00100 //++
00101 //
00102 // DllUnregisterServer
00103 //
00104 // Description:
00105 //      Removes entries from the system registry.
00106 //
00107 //--
00108 /////////////////////////////////////////////////////////////////////////////
00109 STDAPI DllUnregisterServer( void )
00110 {
00111     return _Module.UnregisterServer( FALSE ); // FALSE => no typelib
00112
00113 } //*** DllUnregisterServer
00114
00115
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CMD Member List

This is the complete list of members for _CMD, including all inherited members.
fn | _CMD
pfncmd | _CMD
shorttoken | _CMD
token | _CMD
wCmd | _CMD
wCommand | _CMD
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Binding/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Binding
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Binding.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • CutCopy

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Range/download.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Range

download.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include <urlmon.h>
00018 #include <wininet.h>
00019 // #include <datapath.h>
00020 #include "range.h"
00021 #include "callback.hpp"
00022
00023 //==============================================================================
00024 HRESULT GetAnInterface
00025 (
00026     IUnknown  *     punk,
00027     const IID &     riid,
00028     void **         pout,
00029     BOOL            bCheckServiceProvider,
00030     const IID &     siid,
00031     const IID &     siid_riid,
00032     void **         sout
00033 )
00034 {
00035     IOleObject *      oleObj    = 0;
00036     IOleClientSite *  oleSite   = 0;
00037     IOleContainer *   container = 0;
00038     IUnknown *        service   = 0;
00039
00040     HRESULT       hr = E_FAIL;
00041
00042     // Initialize passed in interface pointers: calling code assumes NULL for failure
00043     if(pout)
00044         *pout = NULL;
00045     if(sout)
00046         *sout = NULL;
00047
00048     if(punk)
00049         hr = punk->QueryInterface( IID_IOleObject, (void **)&oleObj );
00050
00051     while( SUCCEEDED(hr) && oleObj )
00052     {
00053         if( oleSite )
00054         {
00055             //oleSite->Release();
00056             oleSite = 0;
00057         }
00058
00059         hr = oleObj->GetClientSite(&oleSite);
00060
00061         if( FAILED(hr) )
00062             break;
00063
00064         if( bCheckServiceProvider )
00065         {
00066             IServiceProvider * servProv;
00067
00068             hr = oleSite->QueryInterface( IID_IServiceProvider, (void**)&servProv);
00069
00070             if( SUCCEEDED(hr) )
00071             {
00072                 hr = servProv->QueryService
00073                     (siid, siid_riid, (void **) &service);
00074                 servProv->Release();
00075             }
00076
00077             if( SUCCEEDED(hr) )
00078             {
00079                 bCheckServiceProvider = FALSE;
00080
00081                 hr = service->QueryInterface( riid, pout );
00082             }
00083
00084             if( SUCCEEDED(hr) )
00085                 break;
00086
00087         }
00088
00089         if( container )
00090         {
00091             container->Release();
00092             container = 0;
00093         }
00094
00095         hr = oleSite->GetContainer( &container );
00096
00097         if( FAILED(hr) )
00098             break;
00099
00100         hr = container->QueryInterface( riid, pout );
00101
00102         if( SUCCEEDED(hr) )
00103             break;
00104
00105         oleObj->Release();
00106         oleObj = 0;
00107
00108         hr = container->QueryInterface( IID_IOleObject, (void**)&oleObj );
00109
00110     }
00111
00112     if( oleSite )
00113     {
00114         //oleSite->Release();
00115     }
00116
00117     if( oleObj )
00118         oleObj->Release();
00119
00120     if( container )
00121         container->Release();
00122
00123     if( service )
00124         *sout = service;
00125
00126     return( hr );
00127
00128 }
00129
00130 //==============================================================================
00131 BOOL HttpReadFromServer (PHTTP_REQUEST_PARAM pParam)
00132 {
00133     IMoniker*            m_pmk   = NULL;
00134     IBindStatusCallback* m_pbsc  = NULL;
00135     HRESULT hr = S_OK;
00136
00137     IBindHost *pBindHost = NULL;
00138
00139     // Create a callback object.
00140     m_pbsc = new CUrlmonCallback (pParam);
00141     if (m_pbsc == NULL)
00142     {
00143         hr = E_OUTOFMEMORY;
00144         goto err;
00145     }
00146
00147     // Look for a bind host.
00148     if (pParam->punkOuter)
00149     {
00150         hr = GetAnInterface
00151         (
00152             (IUnknown *) pParam->punkOuter,
00153             IID_IBindHost,           // const IID &  riid,
00154             (void **) &pBindHost,    // void **      pout,
00155             TRUE,                    // BOOL         bCheckServiceProvider,
00156             IID_IBindHost,           // const IID &  siid,
00157             IID_IBindHost,           // const IID &  siid_riid,
00158             (void **) &pBindHost     // void **      sout
00159         );
00160     }
00161
00162     // Convert ANSI URL to Unicode.
00163     WCHAR wszUrl[INTERNET_MAX_URL_LENGTH];
00164     MultiByteToWideChar(CP_ACP, 0, pParam->pszUrl, -1, wszUrl, sizeof(wszUrl)/
00165       sizeof(WCHAR));
00166
00167     // Initialize bind context, stream.
00168     IBindCtx *pbc;
00169     IStream *pstm;
00170     pbc =  NULL;
00171     pstm = NULL;
00172
00173     // Call the appropriate BindToStorage.
00174     if (pBindHost)
00175     {
00176          pBindHost->CreateMoniker (wszUrl, NULL, &m_pmk, 0);
00177          pBindHost->MonikerBindToStorage
00178              (m_pmk, NULL, m_pbsc, IID_IStream, (void **) &pstm);
00179     }
00180     else
00181     {
00182         CreateURLMoniker(NULL, wszUrl, &m_pmk);
00183         CreateAsyncBindCtx(0, m_pbsc, NULL, &pbc);
00184         m_pmk->BindToStorage(pbc, NULL, IID_IStream, (void **) &pstm);
00185     }
00186
00187     // Clean up bind context, stream.
00188     if (pbc)
00189         pbc->Release();
00190     if (pstm)
00191         pstm->Release();
00192
00193     return SUCCEEDED(hr);
00194
00195 err:
00196     delete m_pbsc;
00197
00198     if (m_pmk != NULL)
00199     {
00200         m_pmk->Release();
00201         m_pmk = NULL;
00202     }
00203     return FALSE;
00204
00205 }
00206
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminTransactionOptions.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminTransactionOptions.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminTransactionOptions
00019
00020 public interface COMAdminTransactionOptions
00021 {
00022   public static final int COMAdminTransactionIgnored = 0;
00023   public static final int COMAdminTransactionNone = 1;
00024   public static final int COMAdminTransactionSupported = 2;
00025   public static final int COMAdminTransactionRequired = 3;
00026   public static final int COMAdminTransactionRequiresNew = 4;
00027 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyMemberSetChangeListener/StdAfx.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyMemberSetChangeListener

StdAfx.cpp

Go to the documentation of this file.
00001 //
00002 //  stdafx.cpp : source file that includes just the standard includes
00003 //  stdafx.pch will be the pre-compiled header
00004 //  stdafx.obj will contain the pre-compiled type information
00005 //
00006
00007 #include "stdafx.h"
00008
00009 #ifdef _ATL_STATIC_REGISTRY
00010 #include <statreg.h>
00011 #endif
00012
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/PersistATL/stdafx.h Source File

  • Com
  • Services
  • Events
  • EventNews
  • PersistATL

stdafx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__3BE14161_A5D3_11D2_AD4D_0080C7BFF6DB__INCLUDED_)
00006 #define AFX_STDAFX_H__3BE14161_A5D3_11D2_AD4D_0080C7BFF6DB__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__3BE14161_A5D3_11D2_AD4D_0080C7BFF6DB__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/globals.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

globals.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "BaseNode.h"
00016
00017 //---------------------------------------------------------------------------
00018 // MMC's requiered clipboard formats
00019
00020 UINT g_cfDisplayName = 0;      // DisplayName for our SnapIn node
00021 UINT g_cfNodeType    = 0;      // GUID of the selected node
00022 UINT g_cfszNodeType  = 0;      // String representation of namespace GUID
00023 UINT g_cfSnapinClsid = 0;      // Class ID of this SnapIn
00024
00025 //---------------------------------------------------------------------------
00026 //  Custom clipboard formats
00027
00028 UINT g_cfBaseNodePtr = 0;
00029 UINT g_cfDataObjPtr  = 0;
00030 UINT g_cfNodePropPtr = 0;      // DRAGDROP: New format for node properties
00031 UINT g_cfNodeTypeFlg = 0;      // DRAGDROP: New format for node type
00032
00033
00034 // Global variables
00035
00036 HINSTANCE g_hInst = NULL;      // Our global instance handle
00037 ULONG g_uObjectCount = 0;      // Global object count
00038 ULONG g_uServerLocks = 0;      // Global lock count
00039
00040 CONSOLE_VERSION  g_CV;         // MMC20: Global Console Version struct is
00041                                //        defined in Globals.h
00042
00043 //---------------------------------------------------------------------------
00044 //  Returns the version of the console we are attached to
00045 //
00046 HRESULT GetConsoleVersion( CONSOLE_VERSION* pVersion )
00047 {
00048   _ASSERT( NULL != pVersion );
00049   HRESULT hResult = S_FALSE;
00050
00051   pVersion->nMajor = 0;
00052   pVersion->nMinor = 0;
00053
00054   IMMCVersionInfo* ipVersionInfo = NULL;
00055   hResult = CoCreateInstance( CLSID_MMCVersionInfo,
00056                               NULL,
00057                               CLSCTX_INPROC_SERVER,
00058                               IID_IMMCVersionInfo,
00059                               (void**)&ipVersionInfo
00060                             );
00061   // If the call to CoCreateInstance fails, the return value
00062   // will be "ClassFactory cannot supply requested class"
00063   if( S_OK != hResult )
00064     return S_FALSE;
00065
00066   hResult = ipVersionInfo->GetMMCVersion( &pVersion->nMajor, &pVersion->nMinor );
00067   ipVersionInfo->Release();
00068
00069   return hResult;
00070 }
00071
00072 //---------------------------------------------------------------------------
00073 //  This is the fast, simple way to convert unicode to ansi.  It does NOT
00074 //  handle multibyte ansi strings and is not localized.  But it should be
00075 //  fine for registry entries
00076 //  NOTE:  The caller is responsible for freeing the memory.
00077 //
00078 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide )
00079 {
00080   LONG nLen = wcslen( szWide ) +1;
00081   *pszAnsi = (char*)CoTaskMemAlloc( nLen );
00082   char* pCounter = *pszAnsi;
00083
00084   while( *szWide )
00085   {
00086     *pCounter = LOBYTE(*szWide);
00087     pCounter++;
00088     szWide++;
00089   }
00090   *pCounter = NULL;
00091 }
00092
00093 //---------------------------------------------------------------------------
00094 //  copies a string ( like strncpy )
00095 //  in non-unicode version coverts ansi-to-unicode first.
00096 //
00097 void _fastcall CopyT2W( LPWSTR strDest, LPCTSTR strSource, size_t count)
00098 {
00099 #ifndef _UNICODE
00100
00101   MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, strSource, -1, strDest, count );
00102
00103 #else
00104
00105   wcsncpy( strDest, strSource, count );
00106
00107 #endif
00108
00109   if ( count > 0 )
00110     strDest[ count - 1 ] = 0;
00111 }
00112
00113 //---------------------------------------------------------------------------
00114 //
00115 void InitClipboardFormats()
00116 {
00117   g_cfDisplayName  = RegisterClipboardFormat( T_CCF_DISPLAY_NAME );
00118   g_cfNodeType     = RegisterClipboardFormat( T_CCF_NODETYPE );
00119   g_cfszNodeType   = RegisterClipboardFormat( T_CCF_SZNODETYPE );
00120   g_cfSnapinClsid  = RegisterClipboardFormat( T_CCF_SNAPIN_CLASSID );
00121
00122   g_cfBaseNodePtr  = RegisterClipboardFormat( T_CCF_BASENODE_PTR );
00123   g_cfDataObjPtr   = RegisterClipboardFormat( T_CCF_DATAOBJ_PTR );
00124
00125   //DRAGDROP: Register our new clipboard formats
00126   g_cfNodePropPtr  = RegisterClipboardFormat( T_CCF_NODEPROP_PTR );
00127   g_cfNodeTypeFlg  = RegisterClipboardFormat( T_CCF_NODETYPE_FLG );
00128
00129 }
00130
00131 //---------------------------------------------------------------------------
00132 //  Extracts data based on the passed-in clipboard format
00133 //
00134 HRESULT ExtractFromDataObject
00135 (
00136   LPDATAOBJECT ipDataObject,   // [in]  Points to data object
00137   UINT         cfClipFormat,   // [in]  Clipboard format to use
00138   ULONG        nByteCount,     // [in]  Number of bytes to allocate
00139   HGLOBAL      *phGlobal       // [out] Points to the data we want
00140 )
00141 {
00142   _ASSERT( NULL != ipDataObject );
00143
00144             *phGlobal = NULL;
00145   HRESULT   hResult   = S_FALSE;
00146   STGMEDIUM StgMedium = { TYMED_HGLOBAL,  NULL  };
00147   FORMATETC FormatEtc = { cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00148
00149   do
00150   {
00151     // Allocate memory for the stream
00152     StgMedium.hGlobal = ::GlobalAlloc( GMEM_SHARE, nByteCount );
00153
00154     if( NULL == StgMedium.hGlobal )
00155     {
00156       hResult = E_OUTOFMEMORY;
00157       break;
00158     }
00159
00160     // Attempt to get data from the object
00161     hResult = ipDataObject->GetDataHere( &FormatEtc, &StgMedium );
00162     if( FAILED(hResult) )
00163     {
00164       break;
00165     }
00166     // StgMedium now has the data we need
00167     *phGlobal = StgMedium.hGlobal;
00168     StgMedium.hGlobal = NULL;
00169
00170   } while (0);
00171
00172   if( FAILED(hResult) && StgMedium.hGlobal )
00173   {
00174     HGLOBAL hRetVal = ::GlobalFree(StgMedium.hGlobal);
00175     _ASSERT( NULL == hRetVal );         // Must return NULL
00176   }
00177   return hResult;
00178 }
00179
00180
00181 //---------------------------------------------------------------------------
00182 //  This helper returns the current BaseNode object on the custom
00183 //  g_cfBaseNodePtr clipboard format
00184 //
00185 CBaseNode* ExtractBaseNodePtr
00186 (
00187   LPDATAOBJECT ipDataObject      // [in] IComponent pointer
00188 )
00189 {
00190   LPBASENODE  pNode   = NULL;
00191   HGLOBAL     hGlobal = NULL;
00192   HRESULT     hResult = S_FALSE;
00193
00194   hResult = ExtractFromDataObject( ipDataObject,
00195                                    g_cfBaseNodePtr,
00196                                    sizeof(LPBASENODE),
00197                                    &hGlobal
00198                                  );
00199   if( SUCCEEDED(hResult) )
00200   {
00201     pNode = *(LPBASENODE*)(hGlobal);
00202     HGLOBAL hRetVal = GlobalFree(hGlobal);
00203     _ASSERT( NULL == hRetVal );        // Must return NULL
00204   }
00205
00206   return pNode;
00207
00208 }
00209
00210
00211 //---------------------------------------------------------------------------
00212 //  This helper returns the NodeType Flag.  It uses the g_cfNodeTypeFlg
00213 //  clipboard format.  This is needed to support interprocess Cut/Paste
00214 //  because we can't pass a pointer to the object itself.
00215 //
00216 ULONG ExtractNodeTypeFlg
00217 (
00218   LPDATAOBJECT ipDataObject      //[in] IComponent pointer
00219 )
00220 {
00221   _ASSERT( NULL != ipDataObject );
00222
00223   ULONG    nTypeFlg = 0;
00224   ULONG*   pTypeFlg = &nTypeFlg;
00225   HGLOBAL  hRetVal  = NULL;
00226   BOOL     bStatus  = FALSE;
00227   HRESULT  hResult  = S_FALSE;
00228
00229   STGMEDIUM StgMedium = { TYMED_HGLOBAL,  NULL  };
00230   FORMATETC FormatEtc = { g_cfNodeTypeFlg, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00231
00232   hResult = ipDataObject->GetData( &FormatEtc, &StgMedium );
00233   if( S_OK == hResult )
00234   {
00235     pTypeFlg = (ULONG*)::GlobalLock( StgMedium.hGlobal );
00236     nTypeFlg = *pTypeFlg;
00237     bStatus  = ::GlobalUnlock( StgMedium.hGlobal );
00238     hRetVal  = GlobalFree( StgMedium.hGlobal );
00239     _ASSERT( NULL == hRetVal );        // Must return NULL
00240   }
00241                                        // Return 0 if the call to
00242   return nTypeFlg;                     // ::GetData() failed
00243 }
00244
00245
00246 //---------------------------------------------------------------------------
00247 //  Converts an IDataObject pointer to a CDataObject pointer by
00248 //  retrieving a "this" pointer using a custom clipboard format.
00249 //
00250 CDataObject* ExtractDataObjPtr
00251 (
00252   LPDATAOBJECT ipDataObject      //[in] IDataObject pointer
00253 )
00254 {
00255   _ASSERT( 0 != g_cfDataObjPtr );
00256
00257   HGLOBAL      hGlobal = NULL;
00258   HRESULT      hResult = S_OK;
00259   CDataObject* pDO     = NULL;
00260
00261   hResult = ExtractFromDataObject( ipDataObject,
00262                                    g_cfDataObjPtr,
00263                                    sizeof(CDataObject **),
00264                                    &hGlobal
00265                                  );
00266
00267   if( SUCCEEDED(hResult) )
00268   {
00269     pDO = *(CDataObject **)(hGlobal);
00270     _ASSERT( NULL != pDO );
00271
00272     HGLOBAL hRetVal = GlobalFree(hGlobal);
00273     _ASSERT( NULL == hRetVal );       // Must return NULL
00274   }
00275
00276   return pDO;
00277
00278 }
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDropObject Member List

This is the complete list of members for CDropObject, including all inherited members.
CDropObject() | CDropObject |
DAdvise(FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection) | CDropObject |
DUnadvise(DWORD dwConnection) | CDropObject |
EnumDAdvise(IEnumSTATDATA **ppenumAdvise) | CDropObject |
EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc) | CDropObject |
GetCanonicalFormatEtc(FORMATETC *pformatectIn, FORMATETC *pformatetcOut) | CDropObject |
GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) | CDropObject |
GetDataHere(FORMATETC *pformatetc, STGMEDIUM *pmedium) | CDropObject |
m_cRef | CDropObject | [private]
QueryGetData(FORMATETC *pformatetc) | CDropObject |
QueryInterface(REFIID riid, void **ppvObject) | CDropObject |
SetData(FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease) | CDropObject |
STDMETHODIMP_(ULONG) AddRef() | CDropObject |
STDMETHODIMP_(ULONG) Release() | CDropObject |
~CDropObject() | CDropObject | [virtual]
Generated on Wed Nov 13 2024 16:56:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/ClsFact.h Source File

  • WinUI
  • Shell
  • BandObjs

ClsFact.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ClsFact.h
00013
00014    Description:   CClassFactory definitions.
00015
00016 **************************************************************************/
00017
00018 #ifndef CLASSFACTORY_H
00019 #define CLASSFACTORY_H
00020
00021 #include <windows.h>
00022 #include "Globals.h"
00023 #include "DeskBand.h"
00024 #include "ExplrBar.h"
00025 #include "CommBand.h"
00026 #include "ToolBand.h"
00027
00028 /**************************************************************************
00029
00030    CClassFactory class definition
00031
00032 **************************************************************************/
00033
00034 class CClassFactory : public IClassFactory
00035 {
00036 protected:
00037    DWORD m_ObjRefCount;
00038
00039 public:
00040    CClassFactory(CLSID);
00041    ~CClassFactory();
00042
00043    //IUnknown methods
00044    STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00045    STDMETHODIMP_(DWORD) AddRef();
00046    STDMETHODIMP_(DWORD) Release();
00047
00048    //IClassFactory methods
00049    STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
00050    STDMETHODIMP LockServer(BOOL);
00051
00052 private:
00053    CLSID m_clsidObject;
00054 };
00055
00056 #endif   //CLASSFACTORY_H
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Dynept/Dynept.Idl Source File

  • NetDS
  • RPC
  • Dynept

Dynept.Idl

Go to the documentation of this file.
00001 [ uuid (6238dc00-af17-11cd-b799-00aa003cd575),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface dynept
00006 {
00007
00008 void HelloProc([in, string] unsigned char * pszString);
00009
00010 void Shutdown(void);
00011
00012 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::RecordsetEventsVt Member List

This is the complete list of members for msado15::RecordsetEventsVt, including all inherited members.
EndOfRecordset(boolean[] fMoreData, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
FetchComplete(msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
FetchProgress(int Progress, int MaxProgress, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
FieldChangeComplete(int cFields, Variant Fields, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
iid | msado15::RecordsetEventsVt | [static]
MoveComplete(int adReason, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
RecordChangeComplete(int adReason, int cRecords, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
RecordsetChangeComplete(int adReason, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
WillChangeField(int cFields, Variant Fields, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
WillChangeRecord(int adReason, int cRecords, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
WillChangeRecordset(int adReason, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
WillMove(int adReason, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEventsVt |
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/devicenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

devicenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CDeviceNode class.  This node is a child of
00014 //                CStaticNode.  It represents a Virtual Storage device
00015 //
00016 //
00017
00018
00019 #ifndef _CLASS_CDEVICENODE_
00020 #define _CLASS_CDEVICENODE_
00021
00022 #include "Globals.h"
00023 #include "FolderNode.h"      // Folders are children of this node
00024 #include "LListImpl.h"
00025
00026
00027 class CComponentData;        // References
00028 class CStaticNode;
00029
00030 //---------------------------------------------------------------------------
00031 class CDeviceNode : public CBaseNode
00032 {
00033   public:
00034     CDeviceNode();
00035     virtual ~CDeviceNode();
00036
00037     HRESULT Initialize( LPNODEPROPS pNodeProps );
00038     VOID    ToggleStatus();
00039
00040   // Virtual methods
00041   public:
00042     HRESULT GetProperties( LPNODEPROPS* ppNodeProps );
00043     ULONG   GetNodeType() { return NODETYPE_DEVICE; }
00044     GUID&   GetNodeGUID() { return thisGUID; }
00045
00046     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00047     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00048     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00049
00050   ///////////////////////////////////////////////////////////////////////////
00051   // Notification handlers
00052   //
00053   public:
00054     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00055     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00056     HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00057     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00058     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00059
00060     // DRAGDROP:  Support for additional notifications
00061     HRESULT OnQueryPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00062     HRESULT OnPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00063     HRESULT OnCutOrMove( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00064
00065
00066   ///////////////////////////////////////////////////////////////////////////
00067   //  Context Menu methods
00068   //
00069   public:
00070     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00071     HRESULT Command( long lCommandID );
00072
00073   ///////////////////////////////////////////////////////////////////////////
00074   // Public helpers
00075   public:
00076     VOID    RemoveChildNode( LONG_PTR pChildNode );
00077
00078   ///////////////////////////////////////////////////////////////////////////
00079   // Private helpers
00080   private:
00081     HRESULT  DeleteChildItems( LPCONSOLENAMESPACE2 ipCNS );
00082     HRESULT  InsertChildItems( LPCONSOLENAMESPACE2 ipCNS );
00083     HRESULT  InitDefaultFolder();
00084     VOID     RemoveNodes();
00085
00086   private:
00087     static GUID  thisGUID;
00088     DWORD        m_dwAttributes;
00089     HSCOPEITEM   m_hParentNode;
00090     LPWSTR       m_wzStatus;
00091     BOOL         m_bOnlineStatus;
00092
00093     CLListImpl<CBaseNode*,CBaseNode*>  m_NodeList;
00094     CComponentData*                    m_pCompData;
00095     CStaticNode*                       m_pParentNode;
00096
00097 };
00098
00099 #endif //_CLASS_CDEVICENODE_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellIconOverlay/Resource.h Source File

  • WinUI
  • Shell
  • ShellIconOverlay

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by IcnOvrly.rc
00004 //
00005 #define IDI_ICON1                       101
00006 #define IDI_OVERLAY_ICON                101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        102
00013 #define _APS_NEXT_COMMAND_VALUE         40001
00014 #define _APS_NEXT_CONTROL_VALUE         1000
00015 #define _APS_NEXT_SYMED_VALUE           101
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDialogStream Member List

This is the complete list of members for CDialogStream, including all inherited members.
Align16() | CDialogStream |
Align32() | CDialogStream |
CDialogStream(HGLOBAL hResource) | CDialogStream |
GetInt16() | CDialogStream |
GetInt32() | CDialogStream |
GetInt8() | CDialogStream |
GetStr() | CDialogStream |
GetUInt16() | CDialogStream |
m_pch | CDialogStream | [private]
Move(int cbBytes) | CDialogStream |
Undo16() | CDialogStream |
~CDialogStream() | CDialogStream |
Generated on Wed Nov 13 2024 16:56:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/OLEDocVw.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

OLEDocVw.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /******************************************************************************
00019
00020   File:          OleDoctVw.h
00021
00022   Description:   COleDocumentView definitions.
00023
00024 ******************************************************************************/
00025
00026 #ifndef OLEDOCUMENTVIEW_H
00027 #define OLEDOCUMENTVIEW_H
00028
00029 #include "DOServer.h"
00030
00031 #define VIEW_CLASS_NAME TEXT("DocObject_View_Class")
00032
00033 /**************************************************************************
00034
00035   COleDocumentView class definition
00036
00037 **************************************************************************/
00038
00039 class COleDocument;
00040
00041 class COleDocumentView : public IOleDocumentView
00042 {
00043   friend class COleDocument;
00044   friend class COleInPlaceActiveObject;
00045
00046 private:
00047   BOOL                       m_fInPlaceActive;
00048   RECT                       m_Rect;
00049   COleDocument               *m_pOleDoc;
00050   LPOLEINPLACESITE           m_pInPlaceSite;
00051   HWND                       m_hwndView;
00052   LPOLEINPLACEFRAME      m_pInPlaceFrame;
00053   LPOLEINPLACEUIWINDOW       m_pInPlaceUIWindow;
00054   OLEINPLACEFRAMEINFO        m_FrameInfo;
00055   HMENU                      m_hSharedMenu;
00056   HOLEMENU                   m_hOleMenu;
00057   OLEMENUGROUPWIDTHS         m_mgw;
00058   BOOL                       m_fUIActive;
00059
00060 public:
00061   COleDocumentView(COleDocument*);
00062   ~COleDocumentView();
00063
00064   //IUnknown methods
00065   STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00066   STDMETHODIMP_(DWORD) AddRef();
00067   STDMETHODIMP_(DWORD) Release();
00068
00069   //IOleDocumentView methods
00070   STDMETHODIMP SetInPlaceSite(IOleInPlaceSite*);
00071   STDMETHODIMP GetInPlaceSite(IOleInPlaceSite**);
00072   STDMETHODIMP GetDocument(IUnknown**);
00073   STDMETHODIMP SetRect(LPRECT);
00074   STDMETHODIMP GetRect(LPRECT);
00075   STDMETHODIMP SetRectComplex(LPRECT, LPRECT, LPRECT, LPRECT);
00076   STDMETHODIMP Show(BOOL);
00077   STDMETHODIMP UIActivate(BOOL);
00078   STDMETHODIMP Open(void);
00079   STDMETHODIMP CloseView(DWORD);
00080   STDMETHODIMP SaveViewState(IStream*);
00081   STDMETHODIMP ApplyViewState(IStream*);
00082   STDMETHODIMP Clone(IOleInPlaceSite*, IOleDocumentView**);
00083
00084 private:
00085   STDMETHODIMP ActivateInPlace();
00086   STDMETHODIMP DeactivateInPlace();
00087   STDMETHODIMP ActivateUI();
00088   STDMETHODIMP DeactivateUI();
00089   STDMETHODIMP CreateViewWindow();
00090   static LRESULT CALLBACK ViewWndProc(HWND, UINT, WPARAM, LPARAM);
00091   LRESULT OnPaint(void);
00092   LRESULT OnCommand(UINT, UINT, HWND);
00093   LRESULT OnCreate(void);
00094   BOOL MergeMenus(void);
00095   BOOL RemoveMenus(void);
00096   BOOL UpdateMenu(HMENU);
00097 };
00098
00099 #endif   //OLEDOCUMENTVIEW_H
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/AppBar/Util.c Source File

  • WinUI
  • Shell
  • AppBar

Util.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1993 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:     util.c
00009 //
00010 //  PURPOSE:    Contains utility functions used by the AppBar.
00011 //
00012 //  PLATFORMS:  Windows 95, Windows 98, Windows 2000, Windows NT 4.0
00013 //
00014 //  FUNCTIONS:
00015 //      SlideWindow()   - Sides the appbar on and off the screen
00016 //
00017 //  COMMENTS:
00018 //
00019 //
00020
00021 #include <windows.h>
00022 #include <windowsx.h>
00023 #include "globals.h"
00024 #include "appbar.h"
00025
00026 const int g_dtSlideHide = 400;
00027 const int g_dtSlideShow = 200;
00028
00029 //
00030 //  FUNCTION:   SlideWindow(HWND, LPRECT)
00031 //
00032 //  PURPOSE:    Slides the AppBar off the edge of the screen when the AppBar
00033 //              has the AutoHide state set.
00034 //
00035 //  PARAMETERS:
00036 //      hwnd    - handle of the window to scroll off the screen
00037 //      prc     - rectangle you wish the appbar to occupy
00038 //
00039 //  COMMENTS:
00040 //
00041
00042 void SlideWindow(HWND hwnd, LPRECT prc)
00043 {
00044     RECT rcOld;
00045     RECT rcNew;
00046     int x, y, dx, dy, dt, t, t0;
00047     BOOL fShow;
00048     HANDLE hThreadMe;
00049     int priority;
00050
00051     rcNew = *prc;
00052
00053     if ((g_dtSlideShow > 0) && (g_dtSlideHide > 0))
00054     {
00055         GetWindowRect(hwnd, &rcOld);
00056
00057         fShow = (rcNew.bottom - rcNew.top) > (rcOld.bottom - rcOld.top) ||
00058                 (rcNew.right - rcNew.left) > (rcOld.right - rcOld.left);
00059
00060         dx = (rcNew.right - rcOld.right) + (rcNew.left - rcOld.left);
00061         dy = (rcNew.bottom - rcOld.bottom) + (rcNew.top - rcOld.top);
00062
00063         if (fShow)
00064         {
00065             rcOld = rcNew;
00066             OffsetRect(&rcOld, -dx, -dy);
00067             SetWindowPos(hwnd, NULL, rcOld.left, rcOld.top,
00068                     rcOld.right - rcOld.left, rcOld.bottom - rcOld.top,
00069                     SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME);
00070
00071             dt = g_dtSlideShow;
00072         }
00073         else
00074         {
00075             dt = g_dtSlideHide;
00076         }
00077
00078         hThreadMe = GetCurrentThread();
00079         priority = GetThreadPriority(hThreadMe);
00080         SetThreadPriority(hThreadMe, THREAD_PRIORITY_HIGHEST);
00081
00082         t0 = GetTickCount();
00083         while ((t = GetTickCount()) < t0 + dt)
00084         {
00085             x = rcOld.left + dx * (t - t0) / dt;
00086             y = rcOld.top + dy * (t - t0) / dt;
00087
00088             SetWindowPos(hwnd, NULL, x, y, 0, 0,
00089                          SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
00090             if (fShow)
00091                 UpdateWindow(hwnd);
00092             else
00093                 UpdateWindow(GetDesktopWindow());
00094         }
00095
00096         SetThreadPriority(hThreadMe, priority);
00097     }
00098
00099     SetWindowPos(hwnd, NULL, rcNew.left, rcNew.top,
00100                  rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
00101                  SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME);
00102
00103 }
00104
00105
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsimple/filerepserver.idl Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsimple

filerepserver.idl

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005
00006     FILE: FileRepClient.idl
00007
00008     PURPOSE:  Defines the interface for the server system service.
00009
00010 */
00011
00012 [
00013     uuid(fe7f2eda-5da1-4041-928c-d2534d3fa128),
00014     pointer_default(ref),
00015     version(1.0)
00016 ]
00017
00018 interface FileRepServer {
00019
00020 // Declare the string data type. This should work for UNICODE.
00021 #ifdef _UNICODE
00022     typedef wchar_t * STR;
00023 #else
00024     typedef unsigned char * STR;
00025 #endif
00026
00027     // The size of the buffer returned with the RemoteOpen call.
00028     // It allows us to send back some data with the server reply for free:
00029     // since the TCP MTU size is at least 1500 bytes, we can make
00030     // use of the remaining bytes.
00031     const unsigned short OPEN_BUFSIZE = 1024 * 1;
00032
00033     // The size of the buffer returned with RemoteRead.  It is larger
00034     // due to being optimized for data transfer.
00035     const unsigned short READ_BUFSIZE = 10000;
00036
00037     // Used to define fixed-size buffer to receive data on the client.
00038     // The buffer size is basically the larger of the above values +1.
00039     cpp_quote("#define MAX_BUFSIZE (READ_BUFSIZE+1)")
00040
00041     typedef [context_handle] void * PCONTEXT_HANDLE_TYPE;
00042
00043    /*
00044       Opens a file specified by pszFile, reads up to OPEN_BUFSIZE bytes
00045       from it, and returns the number of bytes read as well as
00046       the data read in achBuf[].  If the whole file has been read,
00047       it is closed and the returned context handle is NULL.  Thus,
00048       the file may be transfered with a single call to
00049       RemoteOpen().  If the returned context handle is not NULL, subsequent
00050       calls to RemoteRead with the context handle will return additional
00051       file data.
00052     */
00053     void RemoteOpen([in] handle_t hFileRepServer,
00054         [out] PCONTEXT_HANDLE_TYPE *pphContext,
00055         [in, ref, string] STR pszFile,
00056         [out, ref, size_is(OPEN_BUFSIZE+1), length_is(*cbRead)] byte *Buf,
00057         [in, out, ref] unsigned long *cbRead);
00058
00059     /*
00060       Reads up to READ_BUFSIZE bytes from a previously opened file
00061       corresponding to the context handle phContext and returns
00062       the number of bytes read.  If the whole file has been read,
00063       it is closed and the returned context handle is NULL.  This cuts
00064       down on the number fo calls necessary for file transfer.  The [in]
00065       context handle must be a non-NULL context handle returned by RemoteOpen.
00066       The [out] context handle can be NULL is the read has completed and the
00067       file has been closed.
00068     */
00069     void RemoteRead([in] handle_t hFileRepServer,
00070         [in, out] PCONTEXT_HANDLE_TYPE *pphContext,
00071         [out, ref, size_is(READ_BUFSIZE+1), length_is(*cbRead)] byte *Buf,
00072         [in, out, ref] unsigned long *cbRead);
00073
00074 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/basesnap.h Source File

  • SysMgmt
  • MMC
  • Taskpads

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_DYNAMIC_READWRITE_LOCK Member List

This is the complete list of members for _DYNAMIC_READWRITE_LOCK, including all inherited members.
leLink | _DYNAMIC_READWRITE_LOCK
rwlLock | _DYNAMIC_READWRITE_LOCK
ulCount | _DYNAMIC_READWRITE_LOCK
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAgentCtlUserInput Member List

This is the complete list of members for CAgentCtlUserInput, including all inherited members.
CAgentCtlUserInput() | CAgentCtlUserInput | [inline]
CAgentCtlUserInput(LPDISPATCH pDispatch) | CAgentCtlUserInput | [inline]
CAgentCtlUserInput(const CAgentCtlUserInput &dispatchSrc) | CAgentCtlUserInput | [inline]
GetAlt1Confidence() | CAgentCtlUserInput |
GetAlt1Name() | CAgentCtlUserInput |
GetAlt1Voice() | CAgentCtlUserInput |
GetAlt2Confidence() | CAgentCtlUserInput |
GetAlt2Name() | CAgentCtlUserInput |
GetAlt2Voice() | CAgentCtlUserInput |
GetCharacterID() | CAgentCtlUserInput |
GetConfidence() | CAgentCtlUserInput |
GetCount() | CAgentCtlUserInput |
GetName() | CAgentCtlUserInput |
GetVoice() | CAgentCtlUserInput |
Generated on Wed Nov 13 2024 16:55:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/globaldev/gres409/resource.h Source File

  • WinUI
  • GlobalDev
  • globaldev
  • gres409

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Generated include file.
00003 // Used by GRes409.rc
00004 //
00005 #define STR_LANGID                      1
00006 #define STR_LANG                        2
00007 #define STR_NLANG                       3
00008 #define STR_NCOUNTRY                    4
00009 #define STR_ACP                         5
00010 #define STR_OEMCP                       6
00011 #define IDS_RESTART                     7
00012 #define IDS_NLSWEB                      8
00013 #define IDS_MUIWEB                      9
00014 #define IDS_GLOBALDEV                   10
00015 #define IDS_MULTILINGUAL                11
00016 #define DLG_NLS                         101
00017 #define DLG_FONT                        102
00018 #define DLG_USP                         103
00019 #define DLG_MIRRORING                   104
00020 #define DLG_GENERAL                     104
00021 #define DLG_MUI                         105
00022 #define DLG_TEXT                        106
00023 #define DLG_LCID                        107
00024 #define IDB_BITMAP1                     108
00025 #define IDC_LV_LCID                     1005
00026 #define IDC_POS_NUMBER                  1009
00027 #define IDC_NEG_NUMBER                  1010
00028 #define IDC_POS_CURRENCY                1011
00029 #define IDC_NEG_CURRENCY                1012
00030 #define IDC_TIMESAMPLE                  1013
00031 #define IDC_TIMEFORMAT                  1015
00032 #define IDC_SDATESAMPLE                 1016
00033 #define IDC_SDATEFORMAT                 1017
00034 #define IDC_LDATESAMPLE                 1018
00035 #define IDC_LANGNAME                    1018
00036 #define IDC_EDITWIN                     1018
00037 #define IDC_LDATEFORMAT                 1019
00038 #define IDC_NLANGNAME                   1019
00039 #define IDB_CLEAR                       1019
00040 #define IDC_CALFORMAT                   1020
00041 #define IDC_NCOUNTRYNAME                1020
00042 #define IDB_FONT                        1020
00043 #define IDC_LANGUAGES                   1020
00044 #define IDC_ACP                         1021
00045 #define IDB_READING                     1021
00046 #define IDC_OEM                         1022
00047 #define IDB_ALIGN                       1022
00048 #define IDC_PURPOSE                     1044
00049
00050 // Next default values for new objects
00051 //
00052 #ifdef APSTUDIO_INVOKED
00053 #ifndef APSTUDIO_READONLY_SYMBOLS
00054 #define _APS_NEXT_RESOURCE_VALUE        113
00055 #define _APS_NEXT_COMMAND_VALUE         40001
00056 #define _APS_NEXT_CONTROL_VALUE         1050
00057 #define _APS_NEXT_SYMED_VALUE           101
00058 #endif
00059 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSampleInstance Member List

This is the complete list of members for CSampleInstance, including all inherited members.
CS | CSampleInstance | [private]
CSampleInstance() | CSampleInstance |
CSampleInstance(const CSampleInstance &aInst) | CSampleInstance |
GetCounter(long lCtr, DWORD *pdwVal) | CSampleInstance |
Lock(bool bLock) | CSampleInstance |
m_aCounter | CSampleInstance | [private]
SetCounter(long lCtr, DWORD dwVal) | CSampleInstance |
~CSampleInstance() | CSampleInstance |
Generated on Wed Nov 13 2024 16:57:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepmultiuser/common.h Source File

  • NetDS
  • RPC
  • FileRep
  • filerepmultiuser

common.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Server System Service
00006
00007     FILE: common.h
00008
00009     PURPOSE: Provides common file replication service declarations.
00010
00011 */
00012
00013 #pragma once
00014
00015 #include <windows.h>
00016 #include <crtdbg.h>
00017
00018 // Macro for printing out error message and exiting the program if an
00019 // error occured during an RPC library call.
00020 #define EXIT_IF_FAIL(x, string){ \
00021         ((x) != RPC_S_OK) ? _tprintf(TEXT("%s failed with error %d\n"), \
00022         TEXT(string), (x)), exit(EXIT_FAILURE) : 0;}
00023
00024 #define RPC_EEINFO_EXIT_IF_FAIL(x, string){ \
00025         ((x) != RPC_S_OK) ? PrintProcFailureEEInfo(string, x), \
00026         exit(EXIT_FAILURE) : 0;}
00027
00028 // Make sure the ASSERTE macro is defined.
00029 #ifndef ASSERTE
00030 #define ASSERTE _ASSERTE
00031 #endif
00032
00033 // Size for short message strings.
00034 #define MSG_SIZE (256)
00035
00036 VOID GetEEInfoText(TCHAR *Msg, UINT BuffSize, UINT *MsgSize);
00037
00038 VOID PrintProcFailureEEInfo(LPTSTR ProcName, DWORD ErrCode);
00039
00040 VOID * AutoHeapAlloc(size_t dwBytes);
00041
00042 VOID AutoHeapFree(VOID * lpMem);
00043
00044 // end common.h
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Cap/StdAfx.h Source File

  • Web
  • MSAgent
  • c
  • Cap

StdAfx.h

Go to the documentation of this file.
00001 #ifndef _stdafx_h_
00002 #define _stdafx_h_
00003
00004 #ifndef STRICT
00005 #define STRICT
00006 #endif
00007
00008 #include <crtdbg.h>
00009
00010 #ifdef _DEBUG
00011 #define _CRTDBG_MAP_ALLOC
00012 #define MY_DEBUG_NEW  new(_NORMAL_BLOCK, __FILE__, __LINE__)
00013 #define new MY_DEBUG_NEW
00014 #endif
00015
00016 #include <windows.h>
00017 #include <tchar.h>
00018 #include <malloc.h>
00019 #include "AgtSvr.h"
00020 #include "AgtErr.h"
00021
00022
00023 #endif
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/Setcomp.c Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

Setcomp.c

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      comp.C                                                        */
00004 /*                                                                    */
00005 /**********************************************************************/
00006
00007 #include <windows.h>
00008 #include <imm.h>
00009 #include "resource.h"
00010 #include "imeapps.h"
00011
00012 DWORD GetTargetClause()
00013 {
00014     int nMaxClause = (int)(dwCompClsLen / sizeof(DWORD)) - 1;
00015     int nCnt;
00016
00017
00018     if (nMaxClause <= 0)
00019     {
00020         return (DWORD)-1L;
00021     }
00022
00023     for (nCnt = 0; nCnt < nMaxClause; nCnt++)
00024     {
00025         DWORD dwCls = dwCompCls[nCnt];
00026
00027         if ((bCompAttr[dwCompCls[nCnt]] == ATTR_TARGET_CONVERTED) ||
00028             (bCompAttr[dwCompCls[nCnt]] == ATTR_TARGET_NOTCONVERTED))
00029         {
00030             return nCnt;
00031         }
00032     }
00033
00034     return (DWORD)-1L;
00035 }
00036
00037 LRESULT HandleChangeAttr(HWND hWnd, BOOL fNext)
00038 {
00039     BYTE bAttr[512];
00040     BYTE bAttrRead[512];
00041     UINT i,j;
00042     UINT uClause;
00043     UINT uMaxClause;
00044     UINT uCnt;
00045     UINT uCntRead;
00046     BYTE bAt;
00047     BOOL fAttrOK = FALSE;
00048     BOOL fAttrReadOK = FALSE;
00049     HIMC hIMC = NULL;
00050     BOOL bRet = FALSE;
00051
00052
00053     uMaxClause = (dwCompClsLen / sizeof(DWORD)) - 1;
00054     uClause = GetTargetClause();
00055
00056     if (uClause == (DWORD)-1L)
00057     {
00058          return 0L;
00059     }
00060
00061     if (fNext)
00062     {
00063         if (uClause + 1 <= uMaxClause)
00064         {
00065             uClause++;
00066         }
00067         else
00068         {
00069             return 0L;
00070         }
00071     }
00072     else
00073     {
00074         if (uClause > 0)
00075         {
00076             uClause--;
00077         }
00078         else
00079         {
00080             return 0L;
00081         }
00082     }
00083
00084
00085     uCnt = 0;
00086
00087     if (uClause < uMaxClause)
00088     {
00089         for (i=0; i < uMaxClause; i++)
00090         {
00091             if (i == uClause)
00092             {
00093                 switch (bCompAttr[dwCompCls[i]])
00094                 {
00095                     case ATTR_INPUT:
00096                         bAt = ATTR_TARGET_NOTCONVERTED;
00097                         break;
00098                         break;
00099
00100                     case ATTR_CONVERTED:
00101                         bAt = ATTR_TARGET_CONVERTED;
00102                         break;
00103
00104                     default:
00105                         bAt = bCompAttr[dwCompCls[i]];
00106                         break;
00107                 }
00108             }
00109             else
00110             {
00111                 switch (bCompAttr[dwCompCls[i]])
00112                 {
00113                     case ATTR_TARGET_CONVERTED:
00114                         bAt = ATTR_CONVERTED;
00115                         break;
00116                         break;
00117
00118                     case ATTR_TARGET_NOTCONVERTED:
00119                         bAt = ATTR_INPUT;
00120                         break;
00121
00122                     default:
00123                         bAt = bCompAttr[dwCompCls[i]];
00124                         break;
00125                 }
00126             }
00127
00128             for (j = 0; j < (dwCompCls[i+1] - dwCompCls[i]); j++)
00129             {
00130                 bAttr[uCnt++] = bAt;
00131             }
00132         }
00133         fAttrOK = TRUE;
00134     }
00135
00136     uCntRead = 0;
00137
00138     if (uClause < uMaxClause)
00139     {
00140         for (i=0; i < uMaxClause; i++)
00141         {
00142             if (i == uClause)
00143             {
00144                 switch (bCompReadAttr[dwCompReadCls[i]])
00145                 {
00146                     case ATTR_INPUT:
00147                         bAt = ATTR_TARGET_NOTCONVERTED;
00148                         break;
00149                         break;
00150
00151                     case ATTR_CONVERTED:
00152                         bAt = ATTR_TARGET_CONVERTED;
00153                         break;
00154
00155                     default:
00156                         bAt = bCompReadAttr[dwCompReadCls[i]];
00157                         break;
00158                 }
00159             }
00160             else
00161             {
00162                 switch (bCompReadAttr[dwCompReadCls[i]])
00163                 {
00164                     case ATTR_TARGET_CONVERTED:
00165                         bAt = ATTR_CONVERTED;
00166                         break;
00167                         break;
00168
00169                     case ATTR_TARGET_NOTCONVERTED:
00170                         bAt = ATTR_INPUT;
00171                         break;
00172
00173                     default:
00174                         bAt = bCompReadAttr[dwCompReadCls[i]];
00175                         break;
00176                 }
00177             }
00178
00179             for (j = 0; j < (dwCompReadCls[i+1] - dwCompReadCls[i]); j++)
00180             {
00181                 bAttrRead[uCntRead++] = bAt;
00182             }
00183         }
00184         fAttrReadOK = TRUE;
00185     }
00186
00187
00188     if (fAttrReadOK && fAttrOK)
00189     {
00190         hIMC = ImmGetContext(hWndCompStr);
00191 #ifdef USEWAPI
00192         bRet = ImmSetCompositionStringW(hIMC,SCS_CHANGEATTR,bAttr,uCnt,
00193                                                     bAttrRead,uCntRead);
00194 #else
00195         bRet = ImmSetCompositionString(hIMC,SCS_CHANGEATTR,bAttr,uCnt,
00196                                                     bAttrRead,uCntRead);
00197 #endif
00198         // bRet = ImmSetCompositionString(hIMC,SCS_CHANGEATTR,NULL,0,
00199         //                                             bAttrRead,uCntRead);
00200         // bRet = ImmSetCompositionString(hIMC,SCS_CHANGEATTR,bAttr,uCnt,
00201         //                                             NULL,0);
00202         ImmReleaseContext(hWndCompStr,hIMC);
00203     }
00204     else
00205     {
00206 #ifdef DEBUG
00207         OutputDebugString("Can not call ImmSetCompositionString\r\n");
00208         bRet = TRUE;
00209 #endif
00210     }
00211
00212 #ifdef DEBUG
00213     if (!bRet)
00214     {
00215         OutputDebugString("ImmSetCompositionString return FALSE\r\n");
00216     }
00217 #endif
00218
00219
00220     return 1;
00221 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/Server.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

Server.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.H
00003
00004   Summary:   Internal include file for the LICSERVE.DLL server code
00005              sample.  Contains class declarations, Resource IDs and
00006              string macros for internal use in constructing this DLL
00007              as a COM component server.  Declares the CServer server
00008              control object class to control server object and lock
00009              counts as well as server licensing.
00010
00011              For a comprehensive tutorial code tour of this module's
00012              contents and offerings see the tutorial LICSERVE.HTM
00013              file. For more specific technical details on the internal
00014              workings see the comments dispersed throughout the module's
00015              source code.
00016
00017   Classes:   CServer.
00018
00019   Functions: none
00020
00021   Origin:    10-5-95: atrent - Editor-inheritance from CAR.H in
00022                the COMOBJ Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039
00040 #if !defined(SERVER_H)
00041 #define SERVER_H
00042
00043 // String Macros.
00044 #define ABOUT_TITLE_STR  "LICSERVE: Tutorial Code Sample"
00045 #define LICENSE_EXT_STR  ".LIC"
00046
00047 #define MAX_LICENSEKEY              128
00048
00049 // Dialog IDs.
00050 #define IDD_ABOUTBOX                1000
00051
00052 // Error-related String Identifiers.
00053 #define IDS_ASSERT_FAIL             2200
00054
00055 #ifdef __cplusplus
00056
00057 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00058   Class:    CServer
00059
00060   Summary:  Class to encapsulate control of this COM server (eg, handle
00061             Lock and Object counting, encapsulate otherwise global data).
00062
00063   Methods:  none
00064 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00065 class CServer
00066 {
00067   public:
00068     CServer(void);
00069     ~CServer(void);
00070
00071     void Lock(void);
00072     void Unlock(void);
00073     void ObjectsUp(void);
00074     void ObjectsDown(void);
00075     BOOL CheckLicense(void);
00076
00077     // A place to store the handle to loaded instance of this DLL module.
00078     HINSTANCE m_hDllInst;
00079
00080     // A place to store a client's parent window.
00081     HWND m_hWndParent;
00082
00083     // A Pointer to a Message Box object.
00084     CMsgBox* m_pMsgBox;
00085
00086     // Global DLL Server living Object count.
00087     LONG m_cObjects;
00088
00089     // Global DLL Server Client Lock count.
00090     LONG m_cLocks;
00091
00092     // The Machine License key string for the LICSERVE server.
00093     CHAR m_szLicenseKey[MAX_LICENSEKEY];
00094
00095     // Length of the global g_szLicenseKey string.
00096     UINT m_cLicenseLen;
00097
00098     // Machine license verified.
00099     BOOL m_bLicensed;
00100 };
00101
00102 #endif // __cplusplus
00103
00104 // Allow other internal LICSERVE modules to get at the globals.
00105 extern CServer* g_pServer;
00106 extern CMsgLog* g_pMsgLog;
00107
00108
00109 #endif // SERVER_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/tapirecv/Processing.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • tapirecv

Processing.cpp

Go to the documentation of this file.
00001 /*
00002
00003
00004 Copyright (c) 1999 - 2000  Microsoft Corporation
00005
00006
00007 Module Name:
00008
00009     Processing.cpp
00010
00011 Abstract:
00012
00013     Implementation of the ITTAPIEventNotification interface. An application
00014     must implement and register this interface in order to receive calls and
00015     events related to calls. See TAPI documentation for more information on
00016     this interface.
00017
00018     This file also contains a collection of functions related to event
00019     processing
00020
00021 */
00022
00023
00024 #include "common.h"
00025
00026 #include "Processing.h"
00027
00028 #include "WorkerThread.h"
00029
00030 #include "AVIFileWriter.h"
00031
00032
00033 //
00034 // the name of the file we will save the incoming audio to
00035 //
00036
00037 #define SZ_OUTPUTFILENAME "recording.wav"
00038
00039
00040 //
00041 // the worker thread for asycnhronous message processing
00042 //
00043
00044 CWorkerThread g_WorkerThread;
00045
00046
00047 ///////////////////////////////////////////////////////////////////////////////
00048 //
00049 // ITTAPIEventNotification::Event
00050 //
00051 // the method on the tapi callback object that will be called
00052 // when tapi notifies the application of an event
00053 //
00054 // this method should return as soon as possible, so we are not
00055 // going to actually process the events here. Instead, we will post
00056 // events to a worker thread for asynchronous processing.
00057 //
00058 // in a real life application that could be another thread, the
00059 // application's main thread, or we could post events to a window.
00060 //
00061 ///////////////////////////////////////////////////////////////////////////////
00062
00063 HRESULT STDMETHODCALLTYPE CTAPIEventNotification::Event(IN TAPI_EVENT TapiEvent,
00064                                                         IN IDispatch *pEvent)
00065 {
00066
00067     LogMessage("CTAPIEventNotification::Event "
00068                "posting message for asynchronous processing");
00069
00070
00071     //
00072     // AddRef the event so it doesn't go away after we return
00073     //
00074
00075     pEvent->AddRef();
00076
00077
00078     //
00079     // Post a message to our own worker thread to be processed asynchronously
00080     //
00081
00082     g_WorkerThread.PostMessage(WM_PRIVATETAPIEVENT,
00083                               (WPARAM) TapiEvent,
00084                               (LPARAM) pEvent);
00085
00086     return S_OK;
00087 }
00088
00089
00090 ///////////////////////////////////////////////////////////////////////////////
00091 //
00092 // GetTerminalFromStreamEvent
00093 //
00094 //
00095 // given pCallMediaEvent, find the one and only terminal selected on its stream
00096 //
00097 // return the terminal and S_OK if success, error otherwise
00098 //
00099 ///////////////////////////////////////////////////////////////////////////////
00100
00101 HRESULT GetTerminalFromStreamEvent(IN ITCallMediaEvent *pCallMediaEvent,
00102                                    OUT ITTerminal **ppTerminal)
00103 {
00104
00105     HRESULT hr = E_FAIL;
00106
00107
00108     //
00109     // don't return garbage
00110     //
00111
00112     *ppTerminal = NULL;
00113
00114
00115     //
00116     // Get the stream for this event.
00117     //
00118
00119     ITStream *pStream = NULL;
00120
00121     hr = pCallMediaEvent->get_Stream(&pStream);
00122
00123     if ( FAILED(hr) )
00124     {
00125
00126         LogMessage("GetTerminalFromStreamEvent: "
00127                    "Failed to get stream from pCallMediaEvent hr = 0x%lx", hr);
00128
00129         return hr;
00130     }
00131
00132
00133     //
00134     // Enumerate terminals on this stream.
00135     //
00136
00137     IEnumTerminal *pEnumTerminal = NULL;
00138
00139     hr = pStream->EnumerateTerminals(&pEnumTerminal);
00140
00141     pStream->Release();
00142     pStream = NULL;
00143
00144     if ( FAILED(hr) )
00145     {
00146         LogMessage("GetTerminalFromStreamEvent: "
00147                    "Failed to enumerate terminals hr = 0x%lx", hr);
00148         return hr;
00149     }
00150
00151
00152     //
00153     // we should have at most one terminal selected on the stream, so
00154     // get the first terminal
00155     //
00156
00157     ITTerminal *pTerminal = NULL;
00158
00159     hr = pEnumTerminal->Next(1, &pTerminal, NULL);
00160
00161     if ( hr != S_OK )
00162     {
00163         LogMessage("GetTerminalFromStreamEvent: "
00164                    "Failed to get a terminal from enumeration hr = 0x%lx", hr);
00165
00166         pEnumTerminal->Release();
00167         pEnumTerminal = NULL;
00168
00169         return E_FAIL;
00170     }
00171
00172     *ppTerminal = pTerminal;
00173
00174     pTerminal = NULL;
00175
00176
00177     //
00178     // we should not have any more terminals on this stream,
00179     // double-check this.
00180     //
00181
00182     hr = pEnumTerminal->Next(1, &pTerminal, NULL);
00183
00184     if (hr == S_OK)
00185     {
00186         LogError("GetTerminalFromStreamEvent: "
00187                  "more than one terminal on the stream!");
00188
00189         _ASSERTE(FALSE);
00190
00191         pTerminal->Release();
00192         pTerminal = NULL;
00193
00194     }
00195
00196     pEnumTerminal->Release();
00197     pEnumTerminal = NULL;
00198
00199
00200     return S_OK;
00201 }
00202
00203
00204
00205
00206
00207 ///////////////////////////////////////////////////////////////////////////////
00208 //
00209 // IsMessageForActiveCall
00210 //
00211 // return TRUE if the event received is for the currently active call
00212 //
00213 ///////////////////////////////////////////////////////////////////////////////
00214
00215 BOOL IsMessageForActiveCall(IN ITCallStateEvent *pCallStateEvent)
00216 {
00217
00218     EnterCriticalSection(&g_CurrentCallCritSection);
00219
00220     //
00221     // if we don't have an active call we have not received call notification
00222     // for a call that we own, so return FALSE
00223     //
00224
00225     if (NULL == g_pCurrentCall)
00226     {
00227         LogMessage("IsMessageForActiveCall: no active call. return FALSE");
00228
00229         LeaveCriticalSection(&g_CurrentCallCritSection);
00230
00231
00232         return FALSE;
00233     }
00234
00235
00236     //
00237     // get the call corresponding to the event
00238     //
00239
00240     ITCallInfo *pCallInfo = NULL;
00241
00242     HRESULT hr = pCallStateEvent->get_Call(&pCallInfo);
00243
00244     if (FAILED(hr))
00245     {
00246         LogError("IsMessageForActiveCall: failed to get call. "
00247                  "returning FALSE");
00248
00249         LeaveCriticalSection(&g_CurrentCallCritSection);
00250
00251         return FALSE;
00252     }
00253
00254
00255     //
00256     // get IUnknown of the call from the event
00257     //
00258
00259     IUnknown *pIncomingCallUnk = NULL;
00260
00261     hr = pCallInfo->QueryInterface(IID_IUnknown, (void**)&pIncomingCallUnk);
00262
00263     pCallInfo->Release();
00264     pCallInfo = NULL;
00265
00266     if (FAILED(hr))
00267     {
00268         LogError("IsMessageForActiveCall: "
00269                  "failed to qi incoming call for IUnknown. returning FALSE");
00270
00271         LeaveCriticalSection(&g_CurrentCallCritSection);
00272
00273         return FALSE;
00274     }
00275
00276
00277     //
00278     // get IUnknown of the call from the event
00279     //
00280
00281     IUnknown *pCurrentCallUnk = NULL;
00282
00283     hr = g_pCurrentCall->QueryInterface(IID_IUnknown, (void**)&pCurrentCallUnk);
00284
00285     LeaveCriticalSection(&g_CurrentCallCritSection);
00286
00287     if (FAILED(hr))
00288     {
00289         LogError("IsMessageForActiveCall: "
00290                  "Failed to QI current call for IUnknown. returning FALSE.");
00291
00292         pIncomingCallUnk->Release();
00293         pIncomingCallUnk = NULL;
00294
00295
00296         return FALSE;
00297     }
00298
00299
00300     //
00301     // compare IUnknowns of the current call and the event call
00302     // if they are the same, this is the same call
00303     //
00304
00305     BOOL bSameCall = FALSE;
00306
00307     if (pCurrentCallUnk == pIncomingCallUnk)
00308     {
00309         bSameCall = TRUE;
00310     }
00311     else
00312     {
00313         LogMessage("IsMessageForActiveCall: "
00314                     "current and event calls are different. returning FALSE.");
00315
00316         bSameCall = FALSE;
00317     }
00318
00319     pCurrentCallUnk->Release();
00320     pCurrentCallUnk = NULL;
00321
00322     pIncomingCallUnk->Release();
00323     pIncomingCallUnk = NULL;
00324
00325     return bSameCall;
00326 }
00327
00328
00329 ///////////////////////////////////////////////////////////////////////////////
00330 //
00331 // GetAddressFromCall
00332 //
00333 //
00334 // return ITAddress of the address corresponding to the supplied
00335 // ITBasicCallControl
00336 //
00337 ///////////////////////////////////////////////////////////////////////////////
00338
00339 HRESULT GetAddressFromCall(IN ITBasicCallControl *pCallControl,
00340                            OUT ITAddress **ppAddress)
00341 {
00342
00343     HRESULT hr = E_FAIL;
00344
00345
00346     //
00347     // don't return garbage
00348     //
00349
00350     *ppAddress = NULL;
00351
00352
00353     //
00354     // get ITCallInfo so we can get the call's address
00355     //
00356
00357     ITCallInfo *pCallInfo = NULL;
00358
00359     hr = pCallControl->QueryInterface(IID_ITCallInfo, (void**)&pCallInfo);
00360
00361     if (FAILED(hr))
00362     {
00363         LogError("GetAddressFromCall: "
00364                  "Failed to QI call for ITCallInfo");
00365
00366         return hr;
00367     }
00368
00369
00370     //
00371     // get the call's address
00372     //
00373
00374     ITAddress *pAddress = NULL;
00375
00376     hr = pCallInfo->get_Address(&pAddress);
00377
00378
00379     pCallInfo->Release();
00380     pCallInfo = NULL;
00381
00382
00383     if (FAILED(hr))
00384     {
00385         LogError("GetAddressFromCall: failed to get address");
00386
00387     }
00388     else
00389     {
00390         *ppAddress = pAddress;
00391     }
00392
00393     return hr;
00394 }
00395
00396
00397 ///////////////////////////////////////////////////////////////////////////////
00398 //
00399 // CreateRenderMediaStreamingTerminal
00400 //
00401 // create rendering media streaming terminal.
00402 //
00403 // if success, return the pointer to the terminal
00404 // if failed, return NULL
00405 //
00406 ///////////////////////////////////////////////////////////////////////////////
00407
00408 ITTerminal *CreateRenderMediaStreamingTerminal(IN ITBasicCallControl *pCallControl)
00409 {
00410
00411     HRESULT hr = E_FAIL;
00412
00413
00414     //
00415     // get address from call
00416     //
00417
00418     ITAddress *pAddress = NULL;
00419
00420     hr = GetAddressFromCall(pCallControl, &pAddress);
00421
00422     if (FAILED(hr))
00423     {
00424         LogError("CreateRenderMediaStreamingTerminal: failed to get address from call");
00425
00426         return NULL;
00427     }
00428
00429
00430     //
00431     // get the terminal support interface from the address
00432     //
00433
00434     ITTerminalSupport *pTerminalSupport = NULL;
00435
00436     hr = pAddress->QueryInterface( IID_ITTerminalSupport,
00437                                    (void **)&pTerminalSupport );
00438
00439     pAddress->Release();
00440     pAddress = NULL;
00441
00442     if (FAILED(hr))
00443     {
00444         LogError("CreateRenderMediaStreamingTerminal: "
00445                  "failed to QI pAddress for ITTerminalSupport");
00446
00447         return NULL;
00448     }
00449
00450
00451     //
00452     // get string for the terminal's class id
00453     //
00454
00455     WCHAR *pszTerminalClass = NULL;
00456
00457     hr = StringFromIID(CLSID_MediaStreamTerminal, &pszTerminalClass);
00458
00459     if (FAILED(hr))
00460     {
00461         LogError("CreateRenderMediaStreamingTerminal: "
00462                  "Failed to generate string from terminal's class id");
00463
00464         pTerminalSupport->Release();
00465         pTerminalSupport = NULL;
00466
00467         return NULL;
00468     }
00469
00470
00471     //
00472     // make bstr out of the class id
00473     //
00474
00475     BSTR bstrTerminalClass = SysAllocString (pszTerminalClass);
00476
00477
00478     //
00479     // free the string returned by StringFromIID
00480     //
00481
00482     CoTaskMemFree(pszTerminalClass);
00483     pszTerminalClass = NULL;
00484
00485
00486     //
00487     // create media streaming terminal for rendering
00488     //
00489
00490     ITTerminal *pTerminal = NULL;
00491
00492     hr = pTerminalSupport->CreateTerminal(bstrTerminalClass,
00493                                           TAPIMEDIATYPE_AUDIO,
00494                                           TD_RENDER,
00495                                           &pTerminal);
00496
00497
00498     //
00499     // release resources no longer needed
00500     //
00501
00502     SysFreeString(bstrTerminalClass);
00503     bstrTerminalClass = NULL;
00504
00505     pTerminalSupport->Release();
00506     pTerminalSupport = NULL;
00507
00508
00509     if (FAILED(hr))
00510     {
00511         LogError("CreateRenderMediaStreamingTerminal: "
00512                  "failed to create media streaming terminal hr = 0x%lx", hr);
00513
00514         return NULL;
00515     }
00516
00517
00518     //
00519     // successfully created media streaming terminal. return.
00520     //
00521
00522     LogMessage("CreateRenderMediaStreamingTerminal: "
00523                "Terminal created successfully");
00524
00525     return pTerminal;
00526
00527 }
00528
00529
00530 ///////////////////////////////////////////////////////////////////////////////
00531 //
00532 // SetAudioFormat
00533 //
00534 // tell media streaming terminal the audio format we would like
00535 // to receive
00536 //
00537 ///////////////////////////////////////////////////////////////////////////////
00538
00539 HRESULT SetAudioFormat(IN ITTerminal *pTerminal)
00540 {
00541
00542     HRESULT hr = E_FAIL;
00543
00544
00545     //
00546     // get ITAMMediaFormat interface on the terminal
00547     //
00548
00549     ITAMMediaFormat *pITMediaFormat = NULL;
00550
00551     hr = pTerminal->QueryInterface(IID_ITAMMediaFormat,
00552                                    (void **)&pITMediaFormat);
00553
00554     if (FAILED(hr))
00555     {
00556         LogError("SetAudioFormat: failed to QI terminal for ITAMMediaFormat");
00557
00558         return hr;
00559     }
00560
00561     //
00562     // will ask media streaming terminal for audio in this format
00563     //
00564
00565     WAVEFORMATEX WaveFormat;
00566
00567     ZeroMemory(&WaveFormat, sizeof(WAVEFORMATEX));
00568
00569     WaveFormat.wFormatTag = WAVE_FORMAT_PCM; // pcm
00570     WaveFormat.nChannels = 1;                // mono
00571     WaveFormat.nSamplesPerSec = 8000;        // 8 khz
00572     WaveFormat.nAvgBytesPerSec = 16000;      // 16000 bytes per sec
00573     WaveFormat.nBlockAlign = 2;              // 2 bytes per block
00574     WaveFormat.wBitsPerSample = 16;          // 16 bits per sample
00575     WaveFormat.cbSize = 0;                   // no extra format-specific data
00576
00577     //
00578     // configure the wave format we want
00579     //
00580
00581     AM_MEDIA_TYPE MediaType;
00582
00583     MediaType.majortype            = MEDIATYPE_Audio;
00584     MediaType.subtype              = MEDIASUBTYPE_PCM;
00585     MediaType.bFixedSizeSamples    = TRUE;
00586     MediaType.bTemporalCompression = FALSE;
00587     MediaType.lSampleSize          = 0;
00588     MediaType.formattype           = FORMAT_WaveFormatEx;
00589     MediaType.pUnk                 = NULL;
00590     MediaType.cbFormat             = sizeof(WAVEFORMATEX);
00591     MediaType.pbFormat             = (BYTE*)&WaveFormat;
00592
00593
00594     //
00595     // log the wave format we are setting on the terminal
00596     //
00597
00598     LogMessage("SetAudioFormat: setting wave format on terminal. ");
00599     LogFormat(&WaveFormat);
00600
00601
00602     //
00603     // set the format
00604     //
00605
00606     hr = pITMediaFormat->put_MediaFormat(&MediaType);
00607
00608
00609     if (FAILED(hr))
00610     {
00611
00612         //
00613         // try to see what format the terminal wanted
00614         //
00615
00616         LogError("SetAudioFormat: failed to set format");
00617
00618         AM_MEDIA_TYPE *pMediaFormat = NULL;
00619
00620         HRESULT hr2 = pITMediaFormat->get_MediaFormat(&pMediaFormat);
00621
00622
00623         if (SUCCEEDED(hr2))
00624         {
00625
00626             if (pMediaFormat->formattype == FORMAT_WaveFormatEx)
00627             {
00628
00629                 //
00630                 // log the terminal's format
00631                 //
00632
00633                 LogError("SetAudioFormat: terminal's format is");
00634                 LogFormat((WAVEFORMATEX*) pMediaFormat->pbFormat);
00635
00636             }
00637             else
00638             {
00639
00640                 LogError("SetAudioFormat: "
00641                          "terminal's format is not WAVEFORMATEX");
00642             }
00643
00644
00645             //
00646             // note: we are responsible for deallocating the format returned by
00647             // get_MediaFormat
00648             //
00649
00650             DeleteMediaType(pMediaFormat);
00651
00652         } //  succeeded getting terminal's format
00653         else
00654         {
00655
00656             LogError("SetAudioFormat: failed to get terminal's format");
00657
00658         }
00659
00660     }
00661
00662     pITMediaFormat->Release();
00663     pITMediaFormat = NULL;
00664
00665
00666     LogError("SetAudioFormat: completed");
00667
00668
00669     return hr;
00670
00671 }
00672
00673
00674 ///////////////////////////////////////////////////////////////////////////////
00675 //
00676 // SetAllocatorProperties
00677 //
00678 // suggest allocator properties to the terminal
00679 //
00680 ///////////////////////////////////////////////////////////////////////////////
00681
00682 HRESULT SetAllocatorProperties(IN ITTerminal *pTerminal)
00683 {
00684
00685
00686     //
00687     // different buffer sizes may produce different sound quality, depending
00688     // on the underlying transport that is being used.
00689     //
00690     // this function illustrates how an app can control the number and size of
00691     // buffers. A multiple of 30 ms (480 bytes at 16-bit 8 KHz PCM) is the most
00692     // appropriate sample size for IP (especailly G.723.1).
00693     //
00694     // However, small buffers can cause poor audio quality on some voice boards.
00695     //
00696     // If this method is not called, the allocator properties suggested by the
00697     // connecting filter will be used.
00698     //
00699
00700
00701     HRESULT hr = E_FAIL;
00702
00703
00704     //
00705     // get ITAllocator properties interface on the terminal
00706     //
00707
00708     ITAllocatorProperties *pITAllocatorProperties = NULL;
00709
00710
00711     hr = pTerminal->QueryInterface(IID_ITAllocatorProperties,
00712                                    (void **)&pITAllocatorProperties);
00713
00714
00715     if (FAILED(hr))
00716     {
00717         LogError("SetAllocatorProperties: "
00718                  "failed to QI terminal for ITAllocatorProperties");
00719
00720         return hr;
00721     }
00722
00723
00724     //
00725     // configure allocator properties
00726     //
00727     // suggest the size and number of the samples for MST to pre-allocate.
00728     //
00729
00730     ALLOCATOR_PROPERTIES AllocProps;
00731
00732     AllocProps.cBuffers   = 5;    // ask MST to allocate 5 buffers
00733     AllocProps.cbBuffer   = 4800; // 4800 bytes each
00734     AllocProps.cbAlign    = 1;    // no need to align buffers
00735     AllocProps.cbPrefix   = 0;    // no extra memory preceeding the actual data
00736
00737
00738     hr = pITAllocatorProperties->SetAllocatorProperties(&AllocProps);
00739
00740     if (FAILED(hr))
00741     {
00742         LogError("SetAllocatorProperties: "
00743                  "failed to set allocator properties. hr = 0x%lx", hr);
00744
00745         pITAllocatorProperties->Release();
00746         pITAllocatorProperties = NULL;
00747
00748         return hr;
00749     }
00750
00751
00752     //
00753     // ask media streaming terminal to allocate buffers for us.
00754     // TRUE is the default, so strictly speaking, we didn't have to call
00755     // this method.
00756     //
00757
00758     hr = pITAllocatorProperties->SetAllocateBuffers(TRUE);
00759
00760
00761     pITAllocatorProperties->Release();
00762     pITAllocatorProperties = NULL;
00763
00764
00765     if (FAILED(hr))
00766     {
00767         LogError("SetAllocatorProperties: "
00768                  "failed to SetAllocateBuffers, hr = 0x%lx", hr);
00769
00770         return hr;
00771     }
00772
00773
00774     //
00775     // succeeded setting allocator properties
00776     //
00777
00778     LogMessage("SetAllocatorProperties: succeeded.");
00779
00780
00781     return S_OK;
00782
00783 }
00784
00785
00786 ///////////////////////////////////////////////////////////////////////////////
00787 //
00788 // SelectAndInitializeTerminal
00789 //
00790 //
00791 // Set audio format and allocator properties on the terminal and
00792 // select the terminal on the stream
00793 //
00794 ///////////////////////////////////////////////////////////////////////////////
00795
00796 HRESULT SelectAndInitializeTerminal(IN ITTerminal *pRecordTerminal,
00797                                     IN ITStream *pStream)
00798 {
00799
00800     HRESULT hr = E_FAIL;
00801
00802
00803     //
00804     // set audio format on the created terminal
00805     //
00806
00807     hr = SetAudioFormat(pRecordTerminal);
00808
00809     if (FAILED(hr))
00810     {
00811
00812         //
00813         // the terminal does not support the wave format we wanted.
00814         // no big deal for the receiver, we'll just have to create the
00815         // file in the format requested by MST.
00816         //
00817
00818         LogMessage("CreateAndSelectMST: "
00819                    "Failed to set audio format on recording terminal. "
00820                    "Continuing");
00821
00822     }
00823
00824
00825     //
00826     // set allocator properties for this terminal
00827     //
00828
00829     hr = SetAllocatorProperties(pRecordTerminal);
00830
00831     if (FAILED(hr))
00832     {
00833
00834         //
00835         // not a fatal error. our allocator props were rejected,
00836         // but this does not necessarily mean streaming will fail.
00837         //
00838
00839         LogError("CreateAndSelectMST: Failed to set "
00840                  "allocator properties on recording terminal");
00841     }
00842
00843
00844     //
00845     // select terminal on the stream
00846     //
00847
00848     hr = pStream->SelectTerminal(pRecordTerminal);
00849
00850     if (FAILED(hr))
00851     {
00852
00853         LogError("CreateAndSelectMST: Failed to select "
00854                  "terminal on the stream");
00855     }
00856
00857     return hr;
00858
00859 }
00860
00861
00862 ///////////////////////////////////////////////////////////////////////////////
00863 //
00864 // IsRenderingStream
00865 //
00866 // returns TRUE if the stream's direction is TD_RENDER
00867 //
00868 ///////////////////////////////////////////////////////////////////////////////
00869
00870 BOOL IsRenderingStream(ITStream *pStream)
00871 {
00872
00873     //
00874     // check the stream's direction
00875     //
00876
00877     TERMINAL_DIRECTION TerminalDirection;
00878
00879     HRESULT hr = pStream->get_Direction(&TerminalDirection);
00880
00881     if (FAILED(hr))
00882     {
00883         LogError("IsRenderingStream: Failed to get stream direction");
00884
00885         return FALSE;
00886     }
00887
00888
00889     if (TD_RENDER == TerminalDirection)
00890     {
00891         return TRUE;
00892     }
00893     else
00894     {
00895         return FALSE;
00896     }
00897 }
00898
00899
00900 ///////////////////////////////////////////////////////////////////////////////
00901 //
00902 // IsAudioStream
00903 //
00904 // returns TRUE if the stream's type is TAPIMEDIATYPE_AUDIO
00905 //
00906 ///////////////////////////////////////////////////////////////////////////////
00907
00908 BOOL IsAudioStream(ITStream *pStream)
00909 {
00910
00911     //
00912     // check the stream's media type
00913     //
00914
00915     long nMediaType = 0;
00916
00917     HRESULT hr = pStream->get_MediaType(&nMediaType);
00918
00919     if (FAILED(hr))
00920     {
00921         LogError("IsAudioStream: Failed to get media type");
00922
00923         return FALSE;
00924     }
00925
00926
00927     //
00928     // return true if the stream is audio
00929     //
00930
00931     if (TAPIMEDIATYPE_AUDIO == nMediaType)
00932     {
00933
00934         return TRUE;
00935     }
00936     else
00937     {
00938
00939         return FALSE;
00940     }
00941
00942 }
00943
00944
00945 ///////////////////////////////////////////////////////////////////////////////
00946 //
00947 // CreateAndSelectMST
00948 //
00949 // check the call's streams. create media streaming terminal on the first
00950 // incoming audio stream
00951 //
00952 // returns:
00953 //
00954 // S_OK if a terminal was created and selected
00955 // S_FALSE if no appropriate stream was found
00956 // error if failed
00957 //
00958 ///////////////////////////////////////////////////////////////////////////////
00959
00960 HRESULT CreateAndSelectMST()
00961 {
00962
00963     LogMessage("CreateAndSelectMST: started");
00964
00965
00966     //
00967     // we should already have the call
00968     //
00969
00970     if (NULL == g_pCurrentCall)
00971     {
00972         LogError("CreateAndSelectMST: g_pCurrentCall is NULL");
00973
00974         return E_UNEXPECTED;
00975     }
00976
00977
00978     HRESULT hr = E_FAIL;
00979
00980
00981     //
00982     // get the ITStreamControl interface for this call
00983     //
00984
00985     ITStreamControl *pStreamControl = NULL;
00986
00987     hr = g_pCurrentCall->QueryInterface(IID_ITStreamControl,
00988                                         (void**)&pStreamControl);
00989
00990     if (FAILED(hr))
00991     {
00992         LogError("CreateAndSelectMST: failed to QI call for ITStreamControl");
00993
00994         return hr;
00995     }
00996
00997
00998     //
00999     // enumerate the streams on the call
01000     //
01001
01002     IEnumStream *pEnumStreams = NULL;
01003
01004     hr = pStreamControl->EnumerateStreams(&pEnumStreams);
01005
01006     pStreamControl->Release();
01007     pStreamControl = NULL;
01008
01009     if (FAILED(hr))
01010     {
01011         LogError("CreateAndSelectMST: failed to enumerate streams on call");
01012
01013         return hr;
01014     }
01015
01016
01017     //
01018     // walk through the list of streams on the call
01019     // for the first incoming audio stream, create a media streaming terminal
01020     // and select it on the stream
01021     //
01022
01023     BOOL bTerminalCreatedAndSelected = FALSE;
01024
01025     while (!bTerminalCreatedAndSelected)
01026     {
01027
01028         ITStream *pStream = NULL;
01029
01030         hr = pEnumStreams->Next(1, &pStream, NULL);
01031
01032         if (S_OK != hr)
01033         {
01034             //
01035             // no more streams or error
01036             //
01037
01038             LogError("CreateAndSelectMST: didn't find an incoming audio stream."
01039                      " terminal not selected.");
01040
01041             break;
01042         }
01043
01044
01045         //
01046         // create and select media streaming terminal on the first incoming
01047         // audio stream
01048         //
01049
01050         if ( IsRenderingStream(pStream) && IsAudioStream(pStream))
01051         {
01052
01053             LogMessage("CreateAndSelectMST: creating mst");
01054
01055             //
01056             // create media streaming terminal and select it on the stream
01057             //
01058
01059             ITTerminal *pRecordTerminal = NULL;
01060
01061             pRecordTerminal = CreateRenderMediaStreamingTerminal(g_pCurrentCall);
01062
01063             if (NULL != pRecordTerminal)
01064             {
01065
01066                 hr = SelectAndInitializeTerminal(pRecordTerminal, pStream);
01067
01068                 pRecordTerminal->Release();
01069                 pRecordTerminal = NULL;
01070
01071
01072                 if (SUCCEEDED(hr))
01073                 {
01074                     //
01075                     // set the flag, so we can break out of the loop
01076                     //
01077
01078                     bTerminalCreatedAndSelected = TRUE;
01079                 }
01080
01081             } // media streaming terminal created successfully
01082
01083         } // stream is rendering and audio
01084         else
01085         {
01086             //
01087             // the stream is of wrong direction, or type
01088             //
01089
01090         }
01091
01092         pStream->Release();
01093         pStream = NULL;
01094
01095     } // while (enumerating streams on the call)
01096
01097
01098     //
01099     // done with the stream enumeration. release
01100     //
01101
01102     pEnumStreams->Release();
01103     pEnumStreams = NULL;
01104
01105
01106     if (bTerminalCreatedAndSelected)
01107     {
01108         LogMessage("CreateAndSelectMST: terminal selected");
01109
01110         return S_OK;
01111     }
01112     else
01113     {
01114         LogMessage("CreateAndSelectMST: no terminal selected");
01115
01116         return S_FALSE;
01117     }
01118
01119 }
01120
01121
01122 ///////////////////////////////////////////////////////////////////////////////
01123 //
01124 // GetTerminalFromMediaEvent
01125 //
01126 //
01127 // get the terminal selected on the event's stream
01128 //
01129 ///////////////////////////////////////////////////////////////////////////////
01130
01131 HRESULT GetTerminalFromMediaEvent(IN ITCallMediaEvent *pCallMediaEvent,
01132                                   OUT ITTerminal **ppTerminal)
01133 {
01134
01135     HRESULT hr = E_FAIL;
01136
01137
01138     //
01139     // don't return garbage if we fail
01140     //
01141
01142     *ppTerminal = NULL;
01143
01144
01145     //
01146     // get the stream corresponding to this event
01147     //
01148
01149     ITStream *pStream = NULL;
01150
01151     hr = pCallMediaEvent->get_Stream(&pStream);
01152
01153     if ( FAILED(hr) )
01154     {
01155         LogError("GetTerminalFromMediaEvent: "
01156                  "failed to get stream hr = 0x%lx", hr);
01157
01158         return hr;
01159     }
01160
01161
01162     //
01163     // find the terminal on this stream
01164     //
01165
01166     //
01167     // get terminal enumeration on the stream
01168     //
01169
01170     IEnumTerminal *pEnumTerminal = NULL;
01171
01172     hr = pStream->EnumerateTerminals(&pEnumTerminal);
01173
01174     pStream->Release();
01175     pStream = NULL;
01176
01177
01178     if ( FAILED(hr) )
01179     {
01180         LogError("GetTerminalFromMediaEvent: failed to enumerate terminals, "
01181             "hr = 0x%lx", hr);
01182
01183         return hr;
01184
01185     }
01186
01187
01188     //
01189     // walk through terminal enumeration
01190     //
01191
01192     ULONG nTerminalsFetched = 0;
01193
01194     ITTerminal *pStreamTerminal = NULL;
01195
01196
01197     //
01198     // assuming there is at most one terminal selected on the stream
01199     //
01200
01201     hr = pEnumTerminal->Next(1, &pStreamTerminal, &nTerminalsFetched);
01202
01203     pEnumTerminal->Release();
01204     pEnumTerminal = NULL;
01205
01206     if (S_OK != hr)
01207     {
01208         LogError("GetTerminalFromMediaEvent: enumeration returned no "
01209                  "terminals, hr = 0x%lx", hr);
01210
01211         return hr;
01212
01213     }
01214
01215     *ppTerminal = pStreamTerminal;
01216
01217
01218     LogMessage("GetTerminalFromMediaEvent: succeeded");
01219
01220     return S_OK;
01221 }
01222
01223
01224 ///////////////////////////////////////////////////////////////////////////////
01225 //
01226 // GetNumberOfSamplesOnStream
01227 //
01228 // read the terminal's allocator properties to return the number of samples
01229 // the terminal provides
01230 //
01231 ///////////////////////////////////////////////////////////////////////////////
01232
01233 HRESULT GetNumberOfSamplesOnStream(IN IMediaStream *pTerminalMediaStream,
01234                                    IN OUT DWORD *pnNumberOfSamples)
01235 {
01236
01237     HRESULT hr = S_OK;
01238
01239
01240     //
01241     // don't return garbage
01242     //
01243
01244     *pnNumberOfSamples = 0;
01245
01246
01247     //
01248     // get allocator properties
01249     //
01250
01251     ITAllocatorProperties *pAllocProperites = NULL;
01252
01253     hr = pTerminalMediaStream->QueryInterface(IID_ITAllocatorProperties,
01254                                         (void **)&pAllocProperites);
01255
01256     if (FAILED(hr))
01257     {
01258         LogError("GetNumberOfSamplesOnStream: "
01259                  "Failed to QI terminal for ITAllocatorProperties");
01260
01261         return hr;
01262     }
01263
01264
01265     //
01266     // we want to know the number of samples we will be getting
01267     //
01268
01269     ALLOCATOR_PROPERTIES AllocProperties;
01270
01271     hr = pAllocProperites->GetAllocatorProperties(&AllocProperties);
01272
01273     pAllocProperites->Release();
01274     pAllocProperites = NULL;
01275
01276
01277     if (FAILED(hr))
01278     {
01279         LogError("GetNumberOfSamplesOnStream: "
01280                  "Failed to get terminal's allocator properties");
01281
01282         return hr;
01283     }
01284
01285
01286     *pnNumberOfSamples = AllocProperties.cBuffers;
01287
01288
01289     //
01290     // log the number of buffers and their sizes
01291     //
01292
01293     LogMessage("GetNumberOfSamplesOnStream: [%ld] samples, [%ld] bytes each",
01294                *pnNumberOfSamples, AllocProperties.cbBuffer);
01295
01296
01297     return S_OK;
01298 }
01299
01300
01301 ///////////////////////////////////////////////////////////////////////////////
01302 //
01303 // ReleaseEvents
01304 //
01305 //
01306 // close the handles passed into the function and release the array of handles
01307 //
01308 ///////////////////////////////////////////////////////////////////////////////
01309
01310 void ReleaseEvents(IN OUT HANDLE *pEvents,   // array of events to be freed
01311                    IN DWORD nNumberOfEvents  // number of events in the array
01312                    )
01313 {
01314
01315     //
01316     // close all the handles in the array
01317     //
01318
01319     for (DWORD i = 0; i < nNumberOfEvents; i++)
01320     {
01321         CloseHandle(pEvents[i]);
01322         pEvents[i] = NULL;
01323     }
01324
01325
01326     //
01327     // free the array itself
01328     //
01329
01330     FreeMemory(pEvents);
01331     pEvents = NULL;
01332 }
01333
01334
01335 ///////////////////////////////////////////////////////////////////////////////
01336 //
01337 // AllocateEvents
01338 //
01339 // allocate the array of events of size nNumberOfSamples
01340 //
01341 // return pointer to the allocated and initialized array if success
01342 // or NULL if failed
01343 //
01344 ///////////////////////////////////////////////////////////////////////////////
01345
01346 HANDLE *AllocateEvents(IN DWORD nNumberOfEvents)
01347 {
01348
01349     //
01350     // pointer to an array of event handles
01351     //
01352
01353     HANDLE *pSampleReadyEvents = NULL;
01354
01355     pSampleReadyEvents =
01356         (HANDLE*)AllocateMemory(sizeof(HANDLE) * nNumberOfEvents);
01357
01358     if (NULL == pSampleReadyEvents)
01359     {
01360         LogError("AllocateEvents: Failed to allocate sample ready events.");
01361
01362         return NULL;
01363     }
01364
01365
01366     //
01367     // create an event for every allocated handle
01368     //
01369
01370
01371     for (DWORD i = 0; i < nNumberOfEvents; i++)
01372     {
01373
01374         pSampleReadyEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
01375
01376         if (NULL == pSampleReadyEvents[i])
01377         {
01378
01379             LogError("AllocateEvents: "
01380                      "Failed to create event for sample %d", i);
01381
01382
01383             //
01384             // close handles we have created already
01385             //
01386
01387             for (DWORD j = 0; j< i; j++)
01388             {
01389                 CloseHandle(pSampleReadyEvents[j]);
01390
01391                 pSampleReadyEvents[j] = NULL;
01392             }
01393
01394
01395             FreeMemory(pSampleReadyEvents);
01396             pSampleReadyEvents = NULL;
01397
01398             return NULL;
01399
01400         }
01401
01402     } // creating events for each sample
01403
01404
01405     //
01406     // succeded creating events. return the pointer to the array
01407     //
01408
01409     return pSampleReadyEvents;
01410
01411 }
01412
01413
01414 ///////////////////////////////////////////////////////////////////////////////
01415 //
01416 // ReleaseSamples
01417 //
01418 // aborts and releases every sample in the array of samples of size
01419 // nNumberOfSamples and deallocates the array itself
01420 //
01421 // ppStreamSamples becomes invalid when the function returns
01422 //
01423 ///////////////////////////////////////////////////////////////////////////////
01424
01425 void ReleaseSamples(IN OUT IStreamSample **ppStreamSamples,
01426                     IN DWORD nNumberOfSamples)
01427 {
01428
01429     for (DWORD i = 0; i < nNumberOfSamples; i++)
01430     {
01431         ppStreamSamples[i]->CompletionStatus(COMPSTAT_WAIT |
01432                                              COMPSTAT_ABORT,
01433                                              INFINITE);
01434
01435
01436         //
01437         // regardless of the error code, release the sample
01438         //
01439
01440         ppStreamSamples[i]->Release();
01441         ppStreamSamples[i] = NULL;
01442     }
01443
01444     FreeMemory(ppStreamSamples);
01445     ppStreamSamples = NULL;
01446 }
01447
01448
01449 ///////////////////////////////////////////////////////////////////////////////
01450 //
01451 // AllocateStreamSamples
01452 //
01453 // allocate the array of nNumberOfSamples samples, and initialize each sample
01454 // pointer in the array with samples from the supplied stream.
01455 //
01456 // return pointer to the allocated and initialized array if success
01457 // or NULL if failed
01458 //
01459 ///////////////////////////////////////////////////////////////////////////////
01460
01461 IStreamSample **AllocateStreamSamples(IN IMediaStream *pMediaStream,
01462                                       IN DWORD nNumberOfSamples)
01463 {
01464
01465     //
01466     // allocate stream sample array
01467     //
01468
01469     IStreamSample **ppStreamSamples = (IStreamSample **)
01470         AllocateMemory( sizeof(IStreamSample*) * nNumberOfSamples );
01471
01472
01473     if (NULL == ppStreamSamples)
01474     {
01475         LogError("AllocateStreamSamples: Failed to allocate stream sample array");
01476
01477         return NULL;
01478     }
01479
01480
01481     //
01482     // allocate samples from the stream and put them into the array
01483     //
01484
01485     for (DWORD i = 0; i < nNumberOfSamples; i++)
01486     {
01487
01488         HRESULT hr = pMediaStream->AllocateSample(0, &ppStreamSamples[i]);
01489
01490         if (FAILED(hr))
01491         {
01492
01493             LogError("AllocateStreamSamples: Failed to allocateSample. "
01494                      "Sample #%d", i);
01495
01496             for (DWORD j = 0; j < i; j++)
01497             {
01498                 ppStreamSamples[j]->Release();
01499                 ppStreamSamples[j] = NULL;
01500             }
01501
01502             FreeMemory(ppStreamSamples);
01503             ppStreamSamples = NULL;
01504
01505             return NULL;
01506
01507         } // failed AllocateSample()
01508
01509     } // allocating samples on the stream
01510
01511
01512
01513     //
01514     // succeeded allocating samples
01515     //
01516
01517     return ppStreamSamples;
01518
01519 }
01520
01521
01522 ///////////////////////////////////////////////////////////////////////////////
01523 //
01524 // AssociateEventsWithSamples
01525 //
01526 // call Update() on every sample of the array of stream samples to associate it
01527 // with an event from the array of events. The events will be signaled when the
01528 // corresponding sample has data and is ready to be written to a file
01529 //
01530 ///////////////////////////////////////////////////////////////////////////////
01531
01532 HRESULT AssociateEventsWithSamples(IN HANDLE *pSampleReadyEvents,
01533                                    IN IStreamSample **ppStreamSamples,
01534                                    IN DWORD nNumberOfSamples)
01535 {
01536
01537
01538     for (DWORD i = 0; i < nNumberOfSamples; i++)
01539     {
01540
01541         //
01542         // the event passed to Update will be signaled when the sample is
01543         // filled with data
01544         //
01545
01546         HRESULT hr =
01547             ppStreamSamples[i]->Update(0, pSampleReadyEvents[i], NULL, 0);
01548
01549
01550         if (FAILED(hr))
01551         {
01552
01553             LogError("AssociateEventsWithSamples: "
01554                      "Failed to call update on sample #%d", i);
01555
01556
01557             //
01558             // abort the samples we have Update()'d
01559             //
01560
01561             for (DWORD j = 0; j < i; j++)
01562             {
01563
01564                 //
01565                 // no need to check the return code here -- best effort attempt
01566                 // if failed -- too bad
01567                 //
01568
01569                 ppStreamSamples[j]->CompletionStatus(COMPSTAT_WAIT |
01570                                                      COMPSTAT_ABORT,
01571                                                      INFINITE);
01572             }
01573
01574             return hr;
01575
01576         } // Update() failed
01577
01578     } // Update()'ing all samples
01579
01580
01581     return S_OK;
01582 }
01583
01584
01585 ///////////////////////////////////////////////////////////////////////////////
01586 //
01587 // GetAudioFormat
01588 //
01589 // return a pointer to wave format structure for the audio data produced by
01590 // the stream. the caller is responsible for deallocating returned stucture
01591 //
01592 // returns NULL if failed
01593 //
01594 //////////////////////////////////////////////////////////////////////////////
01595
01596 WAVEFORMATEX *GetAudioFormat(IMediaStream *pTerminalMediaStream)
01597 {
01598
01599
01600     //
01601     // get ITAMMediaFormat interface on the terminal, so we can query for
01602     // audio format
01603     //
01604
01605     ITAMMediaFormat *pITMediaFormat = NULL;
01606
01607     HRESULT hr = pTerminalMediaStream->QueryInterface(IID_ITAMMediaFormat,
01608                                                      (void **)&pITMediaFormat);
01609
01610     if (FAILED(hr))
01611     {
01612         LogError("GetAudioFormat: "
01613                  "failed to QI terminal for ITAMMediaFormat");
01614
01615         return NULL;
01616     }
01617
01618
01619     //
01620     // use ITAMMediaFormat to get terminal's media format
01621     //
01622
01623     AM_MEDIA_TYPE *pMediaType = NULL;
01624
01625     hr = pITMediaFormat->get_MediaFormat(&pMediaType);
01626
01627     pITMediaFormat->Release();
01628     pITMediaFormat = NULL;
01629
01630
01631     if (FAILED(hr))
01632     {
01633         LogError("GetAudioFormat: failed to get_MediaFormat hr = 0x%lx", hr);
01634
01635         return NULL;
01636     }
01637
01638
01639     //
01640     // did we get back a format that we can use?
01641     //
01642
01643     if ((pMediaType->pbFormat == NULL) ||
01644         pMediaType->formattype != FORMAT_WaveFormatEx)
01645     {
01646
01647         LogError("GetAudioFormat: invalid format");
01648
01649         DeleteMediaType(pMediaType);
01650         pMediaType = NULL;
01651
01652         return NULL;
01653     }
01654
01655     //
01656     // allocate and return wave format
01657     //
01658
01659     WAVEFORMATEX *pFormat =
01660         (WAVEFORMATEX *)AllocateMemory(pMediaType->cbFormat);
01661
01662     if (NULL != pFormat)
01663     {
01664         CopyMemory(pFormat, pMediaType->pbFormat, pMediaType->cbFormat);
01665     }
01666     else
01667     {
01668         LogError("GetAudioFormat: Failed to allocate memory for audio format");
01669     }
01670
01671
01672     //
01673     // remember to release AM_MEDIA_TYPE that we no longer need
01674     //
01675
01676     DeleteMediaType(pMediaType);
01677     pMediaType = NULL;
01678
01679     return pFormat;
01680
01681 }
01682
01683
01684 ///////////////////////////////////////////////////////////////////////////////
01685 //
01686 // WriteSampleToFile
01687 //
01688 // This function writes the data portion of the sample into the file
01689 //
01690 ///////////////////////////////////////////////////////////////////////////////
01691
01692 HRESULT WriteSampleToFile(IN IStreamSample *pStreamSample, // sample to record
01693                           IN CAVIFileWriter *pFileWriter)  // file to record to
01694 {
01695
01696     //
01697     // get the sample's IMemoryData interface so we can get to the
01698     // sample's data
01699     //
01700
01701     IMemoryData *pSampleMemoryData = NULL;
01702
01703     HRESULT hr = pStreamSample->QueryInterface(IID_IMemoryData,
01704                                                (void **)&pSampleMemoryData);
01705
01706     if (FAILED(hr))
01707     {
01708
01709         LogError("WriteSampleToFile: "
01710                  "Failed to qi sample for IMemoryData");
01711
01712         return hr;
01713     }
01714
01715
01716     //
01717     // get to the sample's data buffer
01718     //
01719
01720     DWORD nBufferSize = 0;
01721
01722     BYTE *pnDataBuffer = NULL;
01723
01724     DWORD nActualDataSize = 0;
01725
01726
01727     hr = pSampleMemoryData->GetInfo(&nBufferSize,
01728                                     &pnDataBuffer,
01729                                     &nActualDataSize);
01730
01731
01732     pSampleMemoryData->Release();
01733     pSampleMemoryData = NULL;
01734
01735
01736     if (FAILED(hr))
01737     {
01738         LogError("WriteSampleToFile: "
01739                  "Failed to get to the sample's data");
01740
01741         return hr;
01742     }
01743
01744
01745     //
01746     // write the data buffer to the avi file
01747     //
01748
01749     LogMessage("WriteSampleToFile: received a sample of size %ld bytes",
01750                 nActualDataSize);
01751
01752
01753     ULONG nBytesWritten = 0;
01754
01755     hr = pFileWriter->Write(pnDataBuffer,
01756                             nActualDataSize,
01757                             &nBytesWritten);
01758
01759     if (FAILED(hr) || (0 == nBytesWritten))
01760     {
01761         LogError("WriteSampleToFile: FileWriter.Write() wrote no data.");
01762
01763         return E_FAIL;
01764     }
01765
01766
01767     return hr;
01768 }
01769
01770
01771 ///////////////////////////////////////////////////////////////////////////////
01772 //
01773 // GetSampleID
01774 //
01775 // given the return code fom WaitForMultipleObjects, this function determines
01776 // which sample was signal and returns S_OK and the id of the signaled sample
01777 // or E_FAIL if WaitForMultipleEvents returned an error
01778 //
01779 ///////////////////////////////////////////////////////////////////////////////
01780
01781 HRESULT GetSampleID(IN DWORD nWaitCode,         // code from WaitForMultiple...
01782                     IN DWORD nNumberOfSamples,  // the total number of samples
01783                     IN OUT DWORD *pnSampleID)   // the calculated id of the
01784                                                 //          signaled sample
01785 {
01786
01787
01788     //
01789     // event abandoned?
01790     //
01791
01792     if ( (nWaitCode >= WAIT_ABANDONED_0) &&
01793          (nWaitCode < WAIT_ABANDONED_0 + nNumberOfSamples) )
01794     {
01795
01796         LogError("GetSampleID: event for sample #%lu abandoned.",
01797                  nWaitCode - WAIT_ABANDONED_0);
01798
01799         return E_FAIL;
01800     }
01801
01802
01803     //
01804     // any other error?
01805     //
01806
01807     if ( (WAIT_OBJECT_0 > nWaitCode) ||
01808          (WAIT_OBJECT_0 + nNumberOfSamples <= nWaitCode) )
01809     {
01810         LogMessage("GetSampleID: "
01811                    "waiting for samples failed or timed out. "
01812                    "WaitForMultipleObjects returned %lu", nWaitCode);
01813
01814         return E_FAIL;
01815     }
01816
01817
01818     //
01819     // which sample was signaled?
01820     //
01821
01822     *pnSampleID = nWaitCode - WAIT_OBJECT_0;
01823
01824     return S_OK;
01825 }
01826
01827
01828 ///////////////////////////////////////////////////////////////////////////////
01829 //
01830 // WriteStreamToFile
01831 //
01832 // extract samples from the terminal's media stream and write them into a file
01833 //
01834 // returns when the call is disconnected (call disconnect causes media streaming
01835 // terminal to abort the samples
01836 //
01837 ///////////////////////////////////////////////////////////////////////////////
01838
01839 HRESULT WriteStreamToFile(IN IMediaStream *pTerminalMediaStream)
01840 {
01841
01842     LogMessage("WriteStreamToFile: started");
01843
01844
01845     HRESULT hr = E_FAIL;
01846
01847
01848     //
01849     // get the number of stream samples we will be using
01850     //
01851
01852     DWORD nNumberOfSamples = 0;
01853
01854     hr = GetNumberOfSamplesOnStream(pTerminalMediaStream, &nNumberOfSamples);
01855
01856     if (FAILED(hr))
01857     {
01858         LogError("WriteStreamToFile: failed to get the number of samples");
01859
01860         return hr;
01861     }
01862
01863
01864     //
01865     // the number of samples directly corresponds the number of events we will
01866     // be waiting on later. WaitForMultipleObjects has a limit of
01867     // MAXIMUM_WAIT_OBJECTS events.
01868     //
01869
01870     if (nNumberOfSamples > MAXIMUM_WAIT_OBJECTS)
01871     {
01872
01873         LogError("WriteStreamToFile: the number of samples [%ld] "
01874                  "exceeds the number allowed by the design of this "
01875                  "application [%ld]",
01876                  nNumberOfSamples, MAXIMUM_WAIT_OBJECTS);
01877
01878         return E_FAIL;
01879
01880     }
01881
01882
01883     //
01884     // allocate events that will be signaled when each sample is ready to be
01885     // saved to a file
01886     //
01887
01888     HANDLE *pSampleReadyEvents = NULL;
01889
01890     pSampleReadyEvents = AllocateEvents(nNumberOfSamples);
01891
01892     if (NULL == pSampleReadyEvents)
01893     {
01894         LogError("WriteStreamToFile: Failed to allocate sample ready events.");
01895
01896         return E_OUTOFMEMORY;
01897     }
01898
01899
01900     //
01901     // allocate array of stream samples
01902     //
01903
01904     IStreamSample **ppStreamSamples = NULL;
01905
01906     ppStreamSamples = AllocateStreamSamples(pTerminalMediaStream,
01907                                             nNumberOfSamples);
01908
01909     if (NULL == ppStreamSamples)
01910     {
01911
01912         LogError("WriteStreamToFile: Failed to allocate stream sample array");
01913
01914
01915         //
01916         // release events we have allocated
01917         //
01918
01919         ReleaseEvents(pSampleReadyEvents, nNumberOfSamples);
01920         pSampleReadyEvents = NULL;
01921
01922         return E_FAIL;
01923     }
01924
01925
01926     //
01927     // we have the samples, we have the events.
01928     // associate events with samples so events get signaled when the
01929     // corresponding samples are ready to be written to a file
01930     //
01931
01932     hr = AssociateEventsWithSamples(pSampleReadyEvents,
01933                                     ppStreamSamples,
01934                                     nNumberOfSamples);
01935
01936     if (FAILED(hr))
01937     {
01938         LogError("WriteStreamToFile: Failed to associate events with samples");
01939
01940
01941         //
01942         // release events and samples we have allocated
01943         //
01944
01945         ReleaseEvents(pSampleReadyEvents, nNumberOfSamples);
01946         pSampleReadyEvents = NULL;
01947
01948         ReleaseSamples(ppStreamSamples, nNumberOfSamples);
01949         ppStreamSamples = NULL;
01950
01951         return E_FAIL;
01952     }
01953
01954
01955     //
01956     // get the format of the data delivered by media streaming terminal
01957     //
01958
01959     WAVEFORMATEX *pAudioFormat = NULL;
01960
01961     pAudioFormat = GetAudioFormat(pTerminalMediaStream);
01962
01963     if (NULL == pAudioFormat)
01964     {
01965         LogError("WriteStreamToFile: Failed to get audio format");
01966
01967
01968         //
01969         // release events and samples we have allocated
01970         //
01971
01972         ReleaseEvents(pSampleReadyEvents, nNumberOfSamples);
01973         pSampleReadyEvents = NULL;
01974
01975         ReleaseSamples(ppStreamSamples, nNumberOfSamples);
01976         ppStreamSamples = NULL;
01977
01978         return E_FAIL;
01979
01980     }
01981
01982
01983     //
01984     // create a file with the required name and format.
01985     //
01986
01987     CAVIFileWriter FileWriter;
01988
01989     hr = FileWriter.Initialize(SZ_OUTPUTFILENAME, *pAudioFormat);
01990
01991
01992     //
01993     // no longer need audio format
01994     //
01995
01996     FreeMemory(pAudioFormat);
01997     pAudioFormat = NULL;
01998
01999
02000     if (FAILED(hr))
02001     {
02002         LogError("WriteStreamToFile: open file");
02003
02004
02005         //
02006         // release events and samples we have allocated
02007         //
02008
02009         ReleaseEvents(pSampleReadyEvents, nNumberOfSamples);
02010         pSampleReadyEvents = NULL;
02011
02012         ReleaseSamples(ppStreamSamples, nNumberOfSamples);
02013         ppStreamSamples = NULL;
02014
02015         return hr;
02016
02017     }
02018
02019
02020     //
02021     // just for logging, count the number of samples we have recorded
02022     //
02023
02024     ULONG nStreamSamplesRecorded = 0;
02025
02026
02027     while(TRUE)
02028     {
02029
02030         //
02031         // wait for the events associated with the samples
02032         // when a samples has data, the corresponding event will be
02033         // signaled
02034         //
02035
02036         DWORD nWaitCode = WaitForMultipleObjects(nNumberOfSamples,
02037                                                  pSampleReadyEvents,
02038                                                  FALSE,
02039                                                  INFINITE);
02040
02041
02042         //
02043         // get the id of the sample that was signaled. fail if Wait returned
02044         // error
02045         //
02046
02047         DWORD nSampleID = 0;
02048
02049         hr = GetSampleID(nWaitCode, nNumberOfSamples, &nSampleID);
02050
02051         if (FAILED(hr))
02052         {
02053             LogError("WriteStreamToFile: wait failed");
02054
02055             break;
02056         }
02057
02058
02059         //
02060         // we filtered out all invalid error codes. so nSampleID has no
02061         // choice but be a valid sample index.
02062         //
02063
02064         _ASSERTE(nSampleID < nNumberOfSamples);
02065
02066
02067         //
02068         // make sure the sample is ready to be read
02069         //
02070
02071         hr = ppStreamSamples[nSampleID]->CompletionStatus(COMPSTAT_WAIT, 0);
02072
02073
02074         //
02075         // check against S_OK explicitly -- not all success codes mean the
02076         // sample is ready to be used (MS_S_ENDOFSTREAM, etc)
02077         //
02078
02079         if (S_OK != hr)
02080         {
02081
02082             if (E_ABORT == hr)
02083             {
02084
02085                 //
02086                 // recording was aborted, probably because
02087                 // the call was disconnected
02088                 //
02089
02090                 LogMessage("WriteStreamToFile: recording aborted");
02091             }
02092             else
02093             {
02094
02095                 LogMessage("WriteStreamToFile: sample is not completed. "
02096                             "hr = 0x%lx", hr);
02097             }
02098
02099             break;
02100         }
02101
02102
02103         //
02104         // we have the sample that was signaled and which is now ready to be
02105         // saved to a file. Record the sample.
02106         //
02107
02108         hr = WriteSampleToFile(ppStreamSamples[nSampleID], &FileWriter);
02109
02110         if (FAILED(hr))
02111         {
02112             LogError("WriteStreamToFile: failed to write sample to file");
02113
02114             break;
02115         }
02116
02117
02118         //
02119         // one more sample was recorded. update the count.
02120         //
02121
02122         nStreamSamplesRecorded++;
02123
02124
02125         //
02126         // we are done with this sample. return it to the source stream
02127         // to be refilled with data
02128         //
02129
02130         hr = ppStreamSamples[nSampleID]->Update(0,
02131                                                pSampleReadyEvents[nSampleID],
02132                                                NULL,
02133                                                0);
02134
02135         if (FAILED(hr))
02136         {
02137             LogError("WriteStreamToFile: "
02138                      "Failed to Update the sample recorded. "
02139                      "hr = 0x%lx", hr);
02140
02141             break;
02142         }
02143
02144     } // sample-writing loop
02145
02146
02147     LogMessage("WriteStreamToFile: wrote the total of %lu samples",
02148                 nStreamSamplesRecorded);
02149
02150
02151     //
02152     // release samples and events
02153     //
02154
02155     ReleaseSamples(ppStreamSamples, nNumberOfSamples);
02156     ppStreamSamples = NULL;
02157
02158     ReleaseEvents(pSampleReadyEvents, nNumberOfSamples);
02159     pSampleReadyEvents = NULL;
02160
02161
02162     //
02163     // deallocated samples and events. safe to exit.
02164     //
02165
02166     LogMessage("WriteStreamToFile: completed, hr = 0x%lx", hr);
02167
02168
02169     return hr;
02170 }
02171
02172
02173 ///////////////////////////////////////////////////////////////////////////////
02174 //
02175 // RecordMessage
02176 //
02177 // record the terminal's stream into a file
02178 //
02179 ///////////////////////////////////////////////////////////////////////////////
02180
02181 HRESULT RecordMessage(IN ITTerminal *pRecordTerm)
02182 {
02183
02184     LogMessage("RecordMessage: started");
02185
02186     HRESULT hr = E_FAIL;
02187
02188
02189     //
02190     // get IMediaStream interface on the terminal
02191     //
02192
02193     IMediaStream *pTerminalMediaStream = NULL;
02194
02195     hr = pRecordTerm->QueryInterface(IID_IMediaStream,
02196                                      (void**)&pTerminalMediaStream);
02197
02198     if (FAILED(hr))
02199     {
02200         LogError("RecordMessage: Failed to qi terminal for IMediaStream.");
02201
02202         return hr;
02203     }
02204
02205
02206     //
02207     // write terminal stream data to a file
02208     //
02209
02210     hr = WriteStreamToFile(pTerminalMediaStream);
02211
02212
02213     //
02214     // done with the terminal stream, release.
02215     //
02216
02217     pTerminalMediaStream->Release();
02218     pTerminalMediaStream = NULL;
02219
02220
02221     LogMessage("RecordMessage: finished");
02222
02223     return hr;
02224
02225 }
02226
02227
02228 ///////////////////////////////////////////////////////////////////////////////
02229 //
02230 // ProcessCallNotificationEvent
02231 //
02232 // processing for TE_CALLNOTIFICATION event
02233 //
02234 ///////////////////////////////////////////////////////////////////////////////
02235
02236 HRESULT ProcessCallNotificationEvent(IDispatch *pEvent)
02237 {
02238
02239     HRESULT hr = E_FAIL;
02240
02241
02242     //
02243     // we are being notified of a new call
02244     //
02245     // if we own the call and there is not other active call
02246     // consider this to be the active call
02247     //
02248     // wait for CS_OFFERING message before answering the call
02249     //
02250
02251     ITCallNotificationEvent *pCallNotificationEvent = NULL;
02252
02253     hr = pEvent->QueryInterface( IID_ITCallNotificationEvent,
02254                                 (void **)&pCallNotificationEvent);
02255
02256     if (FAILED(hr))
02257     {
02258         LogError("ProcessCallNotificationEvent: "
02259                  "Failed to QI event for ITCallNotificationEvent");
02260
02261         return hr;
02262     }
02263
02264
02265     //
02266     // get the call from notification event
02267     //
02268
02269     ITCallInfo *pCall = NULL;
02270
02271     hr = pCallNotificationEvent->get_Call(&pCall);
02272
02273     //
02274     // release the ITCallNotificationEvent interface
02275     //
02276
02277     pCallNotificationEvent->Release();
02278     pCallNotificationEvent = NULL;
02279
02280
02281     if (FAILED(hr))
02282     {
02283         LogError("ProcessCallNotificationEvent: "
02284                  "Failed to get call from Call notification event");
02285
02286
02287         return hr;
02288     }
02289
02290
02291     //
02292     // if we already have an active call, reject the new incoming call
02293     //
02294
02295     EnterCriticalSection(&g_CurrentCallCritSection);
02296
02297     if (NULL != g_pCurrentCall)
02298     {
02299
02300         LeaveCriticalSection(&g_CurrentCallCritSection);
02301
02302         LogMessage("ProcessCallNotificationEvent: "
02303                    "incoming call while another call in progress");
02304
02305
02306         ITBasicCallControl *pSecondCall = NULL;
02307
02308         hr = pCall->QueryInterface(IID_ITBasicCallControl,
02309                                    (void**)&pSecondCall);
02310
02311         pCall->Release();
02312         pCall = NULL;
02313
02314
02315         if (FAILED(hr))
02316         {
02317             LogError("ProcessCallNotificationEvent: failed to qi incoming call "
02318                      "for ITBasicCallConrtrol");
02319
02320             return hr;
02321         }
02322
02323
02324         //
02325         // reject the incoming call
02326         //
02327
02328         LogMessage("ProcessCallNotificationEvent: rejecting the incoming call");
02329
02330
02331         hr = pSecondCall->Disconnect(DC_REJECTED);
02332
02333         pSecondCall->Release();
02334         pSecondCall = NULL;
02335
02336         return E_FAIL;
02337     }
02338
02339
02340     //
02341     // check to see if we own the call
02342     //
02343
02344     CALL_PRIVILEGE cp;
02345
02346     hr = pCall->get_Privilege( &cp );
02347
02348
02349     if ( FAILED(hr) )
02350     {
02351         LogError("ProcessCallNotificationEvent: Failed to get call owner info");
02352
02353         pCall->Release();
02354         pCall = NULL;
02355
02356         LeaveCriticalSection(&g_CurrentCallCritSection);
02357
02358         return hr;
02359     }
02360
02361     if ( CP_OWNER != cp )
02362     {
02363
02364         //
02365         // we don't own the call. ignore it.
02366         //
02367
02368         LogMessage("ProcessCallNotificationEvent: We don't own the call.");
02369
02370         pCall->Release();
02371         pCall = NULL;
02372
02373         LeaveCriticalSection(&g_CurrentCallCritSection);
02374
02375         return E_FAIL;
02376     }
02377     else
02378     {
02379         LogMessage("ProcessCallNotificationEvent: Incoming call.");
02380     }
02381
02382
02383     //
02384     // keep the call for future use
02385     //
02386
02387     hr = pCall->QueryInterface(IID_ITBasicCallControl,
02388                                (void**)&g_pCurrentCall);
02389
02390
02391     if (FAILED(hr))
02392     {
02393         LogError("ProcessCallNotificationEvent: failed to qi incoming call for"
02394                   "ITBasicCallControl.");
02395
02396         g_pCurrentCall = NULL;
02397     }
02398
02399     LeaveCriticalSection(&g_CurrentCallCritSection);
02400
02401     pCall->Release();
02402     pCall = NULL;
02403
02404
02405     return hr;
02406
02407 } // ProcessCallNotificationEvent
02408
02409
02410 ///////////////////////////////////////////////////////////////////////////////
02411 //
02412 // ProcessCallMediaEvent
02413 //
02414 // processing for TE_CALLMEDIA event. if stream is active, record the
02415 // incoming data
02416 //
02417 ///////////////////////////////////////////////////////////////////////////////
02418
02419 HRESULT ProcessCallMediaEvent(IDispatch *pEvent)
02420 {
02421
02422     //
02423     // Get ITCallMediaEvent interface from the event
02424     //
02425
02426     ITCallMediaEvent *pCallMediaEvent = NULL;
02427
02428     HRESULT hr = pEvent->QueryInterface( IID_ITCallMediaEvent,
02429                                  (void **)&pCallMediaEvent );
02430
02431     if (FAILED(hr))
02432     {
02433
02434         //
02435         // the event does not have the interface we want
02436         //
02437
02438         LogError("ProcessCallMediaEvent: TE_CALLMEDIA. "
02439                  "Failed to QI event for ITCallMediaEvent");
02440
02441         return hr;
02442     }
02443
02444
02445     //
02446     // get the CALL_MEDIA_EVENT that we are being notified of.
02447     //
02448
02449     CALL_MEDIA_EVENT CallMediaEvent;
02450
02451     hr = pCallMediaEvent->get_Event(&CallMediaEvent);
02452
02453     if ( FAILED(hr) )
02454     {
02455
02456         //
02457         // failed to get call media event
02458         //
02459
02460         LogError("ProcessCallMediaEvent: TE_CALLMEDIA. "
02461                  "Failed to get call media event hr = 0x%lx", hr);
02462
02463         pCallMediaEvent->Release();
02464         pCallMediaEvent = NULL;
02465
02466         return hr;
02467     }
02468
02469
02470     LogMessage("ProcessCallMediaEvent: processing call media event");
02471
02472     switch (CallMediaEvent)
02473     {
02474
02475         case CME_STREAM_INACTIVE:
02476         {
02477
02478             LogMessage("ProcessCallMediaEvent: CME_STREAM_INACTIVE");
02479
02480             break;
02481         }
02482
02483         case CME_STREAM_NOT_USED:
02484
02485             LogMessage("ProcessCallMediaEvent: CME_STREAM_NOT_USED");
02486
02487             break;
02488
02489         case CME_NEW_STREAM:
02490
02491             LogMessage("ProcessCallMediaEvent: CME_NEW_STREAM received");
02492
02493             break;
02494
02495         case CME_STREAM_FAIL:
02496
02497             LogError("ProcessCallMediaEvent: CME_STREAM_FAIL received");
02498
02499             break;
02500
02501         case CME_TERMINAL_FAIL:
02502
02503             LogError("ProcessCallMediaEvent: CME_STREAM_FAIL received");
02504
02505             break;
02506
02507         case CME_STREAM_ACTIVE:
02508         {
02509
02510             LogError("ProcessCallMediaEvent: CME_STREAM_ACTIVE received");
02511
02512
02513             //
02514             // Get the terminal on the active stream
02515             //
02516
02517             ITTerminal *pRecordStreamTerminal = NULL;
02518
02519             hr = GetTerminalFromMediaEvent(pCallMediaEvent,
02520                                            &pRecordStreamTerminal);
02521
02522             if ( FAILED(hr) )
02523             {
02524                 //
02525                 // the stream has no terminals associated with it
02526                 //
02527
02528                 LogError("ProcessCallMediaEvent: "
02529                          "failed to get terminal on the active stream");
02530
02531                 break;
02532             }
02533
02534
02535             //
02536             // make sure the direction is right -- we are recording, so the
02537             // terminal should be TD_RENDER
02538             //
02539
02540             TERMINAL_DIRECTION td;
02541
02542             hr = pRecordStreamTerminal->get_Direction( &td);
02543
02544             if ( FAILED(hr) )
02545             {
02546
02547                 LogError("ProcessCallMediaEvent: "
02548                          "failed to get record terminal's direction.");
02549
02550                 pRecordStreamTerminal->Release();
02551                 pRecordStreamTerminal = NULL;
02552
02553                 break;
02554             }
02555
02556
02557             //
02558             // double check that the terminal is rendering terminal
02559             // since we are the recording side
02560             //
02561
02562             if ( TD_RENDER != td )
02563             {
02564
02565                 //
02566                 // this should never ever happen
02567                 //
02568
02569                 LogError("ProcessCallMediaEvent: bad terminal direction");
02570
02571                 pRecordStreamTerminal->Release();
02572                 pRecordStreamTerminal = NULL;
02573
02574                 hr = E_FAIL;
02575
02576                 break;
02577
02578             }
02579
02580             //
02581             // Now do the actual streaming.
02582             //
02583
02584             //
02585             // this will block until:
02586             //
02587             // the call is disconnected, or
02588             // the user chooses to close the app, or
02589             // there is an error
02590             //
02591             // Since we are in the message processing thread,
02592             // the application will not be able to process messages
02593             // (the messages will still be queued) until this call
02594             // returns.
02595             //
02596             // If it is important that messages are processed while
02597             // file is being recorded, recording should be done on
02598             // a different thread.
02599             //
02600
02601             RecordMessage(pRecordStreamTerminal);
02602
02603             pRecordStreamTerminal->Release();
02604             pRecordStreamTerminal = NULL;
02605
02606             break;
02607         }
02608
02609         default:
02610
02611             break;
02612
02613     } // switch (call media event)
02614
02615
02616     //
02617     // We no longer need the event interface.
02618     //
02619
02620     pCallMediaEvent->Release();
02621     pCallMediaEvent = NULL;
02622
02623
02624     return S_OK;
02625
02626 }
02627
02628
02629 ///////////////////////////////////////////////////////////////////////////////
02630 //
02631 // ProcessCallStateEvent
02632 //
02633 // processing for TE_CALLSTATE. if CS_OFFERING, creates and selects MST,
02634 // answers the call . Release call if disconnected.
02635 //
02636 // also verifies that the event is for the current call
02637 //
02638 ///////////////////////////////////////////////////////////////////////////////
02639
02640 HRESULT ProcessCallStateEvent(IDispatch *pEvent)
02641 {
02642
02643     HRESULT hr = S_OK;
02644
02645
02646     //
02647     // TE_CALLSTATE is a call state event.
02648     // pEvent is an ITCallStateEvent
02649     //
02650
02651     ITCallStateEvent *pCallStateEvent = NULL;
02652
02653
02654     //
02655     // Get the interface
02656     //
02657
02658     hr = pEvent->QueryInterface(IID_ITCallStateEvent,
02659                                 (void **)&pCallStateEvent);
02660
02661     if ( FAILED(hr) )
02662     {
02663
02664         LogError("ProcessCallStateEvent: "
02665                  "Failed to QI event for ITCallStateEvent");
02666
02667         return hr;
02668     }
02669
02670
02671     //
02672     // make sure the message is for the active call!
02673     //
02674
02675     EnterCriticalSection(&g_CurrentCallCritSection);
02676
02677     if (!IsMessageForActiveCall(pCallStateEvent))
02678     {
02679         LogMessage("ProcessCallStateEvent: received TE_CALLSTATE message "
02680                    "for a different call. ignoring.");
02681
02682         pCallStateEvent->Release();
02683         pCallStateEvent = NULL;
02684
02685         LeaveCriticalSection(&g_CurrentCallCritSection);
02686
02687         return E_FAIL;
02688     }
02689
02690
02691     //
02692     // get the CallState that we are being notified of.
02693     //
02694
02695     CALL_STATE CallState;
02696
02697     hr = pCallStateEvent->get_State(&CallState);
02698
02699
02700     //
02701     // no longer need the event
02702     //
02703
02704     pCallStateEvent->Release();
02705     pCallStateEvent = NULL;
02706
02707
02708     if (FAILED(hr))
02709     {
02710          LogError("ProcessCallStateEvent: "
02711                   "failed to get state from call state event.");
02712
02713          LeaveCriticalSection(&g_CurrentCallCritSection);
02714
02715          return hr;
02716     }
02717
02718
02719
02720     //
02721     // log the new call state
02722     //
02723
02724     if (CS_OFFERING == CallState)
02725     {
02726
02727         LogMessage("ProcessCallStateEvent: call state is CS_OFFERING");
02728
02729
02730         //
02731         // try to create and select media streaming terminal on one of
02732         // the call's incoming audio streams
02733         //
02734
02735         hr = CreateAndSelectMST();
02736
02737         if (S_OK == hr)
02738         {
02739
02740             //
02741             // we have selected a terminal on one of the streams
02742             // answer the call
02743             //
02744
02745             LogMessage("ProcessCallStateEvent: answering the call");
02746
02747             hr = g_pCurrentCall->Answer();
02748
02749             if (FAILED(hr))
02750             {
02751                 LogError("ProcessCallStateEvent: Failed to answer the call");
02752             }
02753
02754         }
02755         else
02756         {
02757
02758             //
02759             // we could not create mst on any of the streams of
02760             // the incoming call. reject the call.
02761             //
02762
02763             LogMessage("ProcessCallStateEvent: rejecting the call");
02764
02765             HRESULT hr2 = g_pCurrentCall->Disconnect(DC_REJECTED);
02766
02767             if (FAILED(hr2))
02768             {
02769                 LogError("ProcessCallStateEvent: Failed to reject the call");
02770             }
02771
02772         }
02773
02774
02775
02776     } // CS_OFFERING
02777     else if (CS_DISCONNECTED == CallState)
02778     {
02779
02780         LogMessage("ProcessCallStateEvent: call state is CS_DISCONNECTED. "
02781                    "Releasing the call.");
02782
02783
02784         //
02785         // release the call -- no longer need it!
02786         //
02787
02788         g_pCurrentCall->Release();
02789         g_pCurrentCall = NULL;
02790
02791
02792         //
02793         // signal the main thread that it can exit if it is time to exit
02794         //
02795
02796         LogMessage("ProcessCallStateEvent: signaling main thread.");
02797
02798         SetEvent(g_hExitEvent);
02799
02800     } // CS_DISCONNECTED
02801     else if (CS_CONNECTED == CallState)
02802     {
02803
02804         LogMessage("ProcessCallStateEvent: call state is CS_CONNECTED");
02805
02806     } // CS_CONNECTED
02807
02808
02809     //
02810     // no longer need to protect current call
02811     //
02812
02813     LeaveCriticalSection(&g_CurrentCallCritSection);
02814
02815     return hr;
02816
02817 }
02818
02819
02820
02821 /////////////////////////////////////////////////////////////////////////////
02822 //
02823 // OnTapiEvent
02824 //
02825 // handler for tapi events. called on a thread that provides asychronous
02826 // processing of tapi messages
02827 //
02828 /////////////////////////////////////////////////////////////////////////////
02829
02830 HRESULT OnTapiEvent(TAPI_EVENT TapiEvent, IDispatch *pEvent)
02831 {
02832
02833     LogMessage("OnTapiEvent: message received");
02834
02835
02836     HRESULT hr = S_OK;
02837
02838
02839     switch ( TapiEvent )
02840     {
02841
02842         case TE_CALLNOTIFICATION:
02843         {
02844
02845             LogMessage("OnTapiEvent: received TE_CALLNOTIFICATION");
02846
02847             hr = ProcessCallNotificationEvent(pEvent);
02848
02849             break;
02850
02851         } // TE_CALLNOTIFICATION
02852
02853
02854         case TE_CALLSTATE:
02855         {
02856             LogMessage("OnTapiEvent: received TE_CALLSTATE");
02857
02858             hr = ProcessCallStateEvent(pEvent);
02859
02860             break;
02861
02862         } // TE_CALLSTATE
02863
02864
02865         case TE_CALLMEDIA:
02866         {
02867
02868             LogMessage("OnTapiEvent: received TE_CALLMEDIA");
02869
02870             hr = ProcessCallMediaEvent(pEvent);
02871
02872             break;
02873
02874         } // case TE_CALLMEDIA
02875
02876
02877     default:
02878
02879         LogMessage("OnTapiEvent: received message %d. not handled.", TapiEvent);
02880
02881         break;
02882
02883     }
02884
02885
02886     //
02887     // the event was AddRef()'ed when it was posted for asynchronous processing
02888     // no longer need the event, release it.
02889     //
02890
02891     pEvent->Release();
02892     pEvent = NULL;
02893
02894     LogMessage("OnTapiEvent: exiting.");
02895
02896     return hr;
02897 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COptionsRowset Member List

This is the complete list of members for COptionsRowset, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
COptionsRowset() | COptionsRowset |
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | COptionsRowset | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | COptionsRowset | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | COptionsRowset | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CPropPageLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSetActive() | CPropPageLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

INVOKE_INFO Member List

This is the complete list of members for INVOKE_INFO, including all inherited members.
fValid | INVOKE_INFO
nConfID | INVOKE_INFO
nidInitiator | INVOKE_INFO
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsError/resource.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsError

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ADsError.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDS_ADSERROR_DESC               101
00007 #define IDR_ADsError                    102
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           103
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step2/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step2

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__E1E3EDEE_48D1_11D2_B22B_0000F87A6B50__INCLUDED_)
00006 #define AFX_STDAFX_H__E1E3EDEE_48D1_11D2_B22B_0000F87A6B50__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0400
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <afxwin.h>
00019 #include <afxdisp.h>
00020
00021 #include <atlbase.h>
00022 //You may derive a class from CComModule and use it if you want to override
00023 //something, but do not change the name of _Module
00024 extern CComModule _Module;
00025 #include <atlcom.h>
00026
00027 #include "activeds.h"
00028
00029 //{{AFX_INSERT_LOCATION}}
00030 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00031
00032 #endif // !defined(AFX_STDAFX_H__E1E3EDEE_48D1_11D2_B22B_0000F87A6B50__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/stdpal.h Source File

  • Com
  • Fundamentals
  • SimpCntr

stdpal.h

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------
00002 |   stdpal.h
00003 |
00004 |   Standard App Palette useful for OLE applications.  v 1.01
00005 |
00006 |   #include this file in the same file as HpalCreateAppPalette
00007 |
00008 |   NOTE:  Palette MUST be created with HpalCreateAppPalette
00009 |
00010 |   Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 |
00012 -----------------------------------------------------------------------*/
00013
00014
00015 unsigned char palSVGA[256][3] =
00016         {
00017         // R     G     B
00018         {0x00, 0x00, 0x00}, // 0 Sys Black  gray 0
00019         {0x80, 0x00, 0x00}, // 1 Sys Dk Red
00020         {0x00, 0x80, 0x00}, // 2 Sys Dk Green
00021         {0x80, 0x80, 0x00}, // 3 Sys Dk Yellow
00022         {0x00, 0x00, 0x80}, // 4 Sys Dk Blue
00023         {0x80, 0x00, 0x80}, // 5 Sys Dk Violet
00024         {0x00, 0x80, 0x80}, // 6 Sys Dk Cyan
00025         {0xc0, 0xc0, 0xc0}, // 7 Sys Lt Grey    gray 192
00026         {0xc0, 0xdc, 0xc0}, // 8 Sys 8
00027         {0xa6, 0xca, 0xf0}, // 9 Sys 9 (the first 10 are fixed by Windows)
00028
00029         {0x80, 0x00, 0x00}, // 10 Sys Dk Red repeat
00030         {0x00, 0x80, 0x00}, // 11 Sys Dk Green repeat
00031         {0x80, 0x80, 0x00}, // 12 Sys Dk Yellow repeat
00032         {0x00, 0x00, 0x80}, // 13 Sys Dk Blue repeat
00033         {0x80, 0x00, 0x80}, // 14 Sys Dk Violet repeat
00034         {0x00, 0x80, 0x80}, // 15 Sys Dk Cyan repeat
00035         {0x80, 0x80, 0x80}, // 16 Sys Dk Grey repeat    gray 128
00036         {0x80, 0x80, 0xff}, // 17 Excel Chart Fill 1
00037         {0x80, 0x20, 0x60}, // 18 Excel Chart Fill 2
00038         {0xff, 0xff, 0xc0}, // 19 Excel Chart Fill 3
00039         {0xa0, 0xe0, 0xe0}, // 20 Excel Chart Fill 4
00040         {0x60, 0x00, 0x80}, // 21 Excel Chart Fill 4
00041         {0xff, 0x80, 0x80}, // 22 Excel Chart Fill 6
00042         {0x00, 0x80, 0xc0}, // 23 Excel Chart Fill 7
00043         {0xc0, 0xc0, 0xff}, // 24 Excel Chart Fill 8
00044         {0x00, 0xcf, 0xff}, // 25 Excel clrt entry
00045         {0x69, 0xff, 0xff}, // 26 Excel clrt entry
00046         {0xe0, 0xff, 0xe0}, // 27 Excel clrt entry
00047         {0xdd, 0x9c, 0xb3}, // 28 Excel clrt entry
00048         {0xb3, 0x8f, 0xee}, // 29 Excel clrt entry
00049         {0x2a, 0x6f, 0xf9}, // 30 Excel clrt entry
00050         {0x3f, 0xb8, 0xcd}, // 31 Excel clrt entry
00051         {0x48, 0x84, 0x36}, // 32 Excel clrt entry
00052         {0x95, 0x8c, 0x41}, // 33 Excel clrt entry
00053         {0x8e, 0x5e, 0x42}, // 34 Excel clrt entry
00054         {0xa0, 0x62, 0x7a}, // 35 Excel clrt entry
00055         {0x62, 0x4f, 0xac}, // 36 Excel clrt entry
00056         {0x1d, 0x2f, 0xbe}, // 37 Excel clrt entry
00057         {0x28, 0x66, 0x76}, // 38 Excel clrt entry
00058         {0x00, 0x45, 0x00}, // 39 Excel clrt entry
00059         {0x45, 0x3e, 0x01}, // 40 Excel clrt entry
00060         {0x6a, 0x28, 0x13}, // 41 Excel clrt entry
00061         {0x85, 0x39, 0x6a}, // 42 Excel clrt entry
00062         {0x4a, 0x32, 0x85}, // 43 Excel clrt entry
00063         {0x04, 0x04, 0x04}, // 44   gray 4
00064         {0x08, 0x08, 0x08}, // 45   gray 8
00065         {0x0c, 0x0c, 0x0c}, // 46   gray 12
00066         {0x11, 0x11, 0x11}, // 47   gray 17
00067         {0x16, 0x16, 0x16}, // 48   gray 22
00068         {0x1c, 0x1c, 0x1c}, // 49   gray 28
00069         {0x22, 0x22, 0x22}, // 50   gray 34
00070         {0x29, 0x29, 0x29}, // 51   gray 41
00071         {0x30, 0x30, 0x30}, // 52   gray 48
00072         {0x5f, 0x5f, 0x5f}, // 53 swapped so inversions look good   gray 95
00073         {0x55, 0x55, 0x55}, // 54 swapped so inversions look good   gray 85
00074         {0x4d, 0x4d, 0x4d}, // 55 swapped so inversions look good   gray 77
00075         {0x42, 0x42, 0x42}, // 56 swapped so inversions look good   gray 66
00076         {0x39, 0x39, 0x39}, // 57 swapped so inversions look good   gray 57
00077         {0x00, 0x07, 0x00}, // 58
00078         {0x0d, 0x00, 0x00}, // 59
00079         {0xb7, 0x99, 0x81}, // 60
00080         {0x84, 0x99, 0xb4}, // 61
00081         {0xbd, 0xbd, 0x90}, // 62
00082         {0x7f, 0x7f, 0x60}, // 63
00083         {0x60, 0x60, 0x7f}, // 64
00084         {0x00, 0x0e, 0x00}, // 65
00085         {0x1b, 0x00, 0x00}, // 66
00086         {0x28, 0x00, 0x00}, // 67
00087         {0x08, 0x09, 0x2b}, // 68
00088         {0x00, 0x1d, 0x00}, // 69
00089         {0x39, 0x00, 0x00}, // 70
00090         {0x00, 0x00, 0x9b}, // 71
00091         {0x00, 0x25, 0x00}, // 72
00092         {0x49, 0x00, 0x00}, // 73
00093         {0x11, 0x11, 0x3b}, // 74
00094         {0x00, 0x2f, 0x00}, // 75
00095         {0x5d, 0x00, 0x00}, // 76
00096         {0x17, 0x17, 0x45}, // 77
00097         {0x00, 0x3a, 0x00}, // 78
00098         {0x49, 0x11, 0x11}, // 79
00099         {0x1c, 0x1c, 0x53}, // 80
00100         {0x00, 0x16, 0xff}, // 81
00101         {0x2b, 0x00, 0xff}, // 82
00102         {0x21, 0x21, 0x6c}, // 83
00103         {0x59, 0x14, 0x14}, // 84
00104         {0x00, 0x51, 0x00}, // 85
00105         {0x47, 0x1a, 0x6a}, // 86
00106         {0x19, 0x32, 0x67}, // 87
00107         {0x00, 0x61, 0x00}, // 88
00108         {0x00, 0x31, 0xff}, // 89
00109         {0x61, 0x00, 0xff}, // 90
00110         {0x53, 0x20, 0x7b}, // 91
00111         {0x16, 0x43, 0x67}, // 92
00112         {0x2e, 0x2e, 0xe2}, // 93
00113         {0x26, 0x59, 0x16}, // 94
00114         {0x51, 0x46, 0x04}, // 95
00115         {0x68, 0x2e, 0x49}, // 96
00116         {0x07, 0x52, 0x8f}, // 97
00117         {0x6a, 0x18, 0xb8}, // 98
00118         {0x90, 0x23, 0x15}, // 99
00119         {0x00, 0x53, 0xff}, // 100
00120         {0xa3, 0x00, 0xff}, // 101
00121         {0x6a, 0x4a, 0x12}, // 102
00122         {0x75, 0x33, 0x6c}, // 103
00123         {0x4a, 0x41, 0x9a}, // 104
00124         {0x37, 0x65, 0x0b}, // 105
00125         {0xa4, 0x2c, 0x15}, // 106
00126         {0x83, 0x1f, 0xb1}, // 107
00127         {0x4e, 0x2c, 0xff}, // 108
00128         {0x20, 0x51, 0xb6}, // 109
00129         {0x08, 0x64, 0x92}, // 110
00130         {0x6f, 0x56, 0x0b}, // 111
00131         {0x59, 0x43, 0xad}, // 112
00132         {0x36, 0x72, 0x12}, // 113
00133         {0xb0, 0x33, 0x17}, // 114
00134         {0x00, 0xa1, 0x00}, // 115
00135         {0x77, 0x5f, 0x1f}, // 116
00136         {0x89, 0x47, 0x71}, // 117
00137         {0xb0, 0x43, 0x1c}, // 118
00138         {0xb7, 0x2d, 0x7d}, // 119
00139         {0x00, 0x86, 0x95}, // 120
00140         {0x7a, 0x6e, 0x23}, // 121
00141         {0x26, 0x9f, 0x00}, // 122
00142         {0x73, 0xa9, 0x01}, // 123
00143         {0x00, 0x00, 0x00}, // 124 free 0   gray 0
00144         {0x00, 0x00, 0x00}, // 125 free 2   gray 0
00145         {0x00, 0x00, 0x00}, // 126 free 4   gray 0
00146         {0x00, 0x00, 0x00}, // 127 free 6   gray 0
00147         {0x00, 0x00, 0x00}, // 128 free 7   gray 0
00148         {0x00, 0x00, 0x00}, // 129 free 5   gray 0
00149         {0x00, 0x00, 0x00}, // 130 free 3   gray 0
00150         {0x00, 0x00, 0x00}, // 131 free 1   gray 0
00151         {0x00, 0xca, 0x00}, // 132
00152         {0xac, 0x5b, 0x01}, // 133
00153         {0x20, 0x1d, 0xc2}, // 134
00154         {0x94, 0x52, 0x70}, // 135
00155         {0x24, 0xaa, 0x4c}, // 136
00156         {0x0a, 0x94, 0x89}, // 137
00157         {0x36, 0x6e, 0x7b}, // 138
00158         {0x44, 0x75, 0x90}, // 139
00159         {0xff, 0x00, 0xa8}, // 140
00160         {0x00, 0x71, 0xff}, // 141
00161         {0xdf, 0x00, 0xff}, // 142
00162         {0x56, 0x91, 0x4a}, // 143
00163         {0x34, 0x48, 0xf8}, // 144
00164         {0xcc, 0x32, 0x82}, // 145
00165         {0xe4, 0x41, 0x70}, // 146
00166         {0x68, 0xca, 0x01}, // 147
00167         {0x36, 0xbc, 0x42}, // 148
00168         {0x00, 0x9a, 0xff}, // 149
00169         {0x96, 0x22, 0xb7}, // 150
00170         {0x85, 0x7d, 0x33}, // 151
00171         {0x25, 0xb7, 0x8c}, // 152
00172         {0x36, 0x5a, 0xed}, // 153
00173         {0x5c, 0xff, 0x00}, // 154
00174         {0xff, 0x48, 0x00}, // 155
00175         {0x22, 0x9b, 0xa2}, // 156
00176         {0x42, 0xcf, 0x4d}, // 157
00177         {0xc2, 0x58, 0x52}, // 158
00178         {0x20, 0xd3, 0x95}, // 159
00179         {0xa5, 0x24, 0xe0}, // 160
00180         {0x73, 0x56, 0xb5}, // 161
00181         {0xa9, 0xa9, 0x00}, // 162
00182         {0xd0, 0x6f, 0x3c}, // 163
00183         {0x67, 0x9f, 0x58}, // 164
00184         {0x89, 0xcf, 0x0b}, // 165
00185         {0xff, 0xac, 0x00}, // 166
00186         {0xa7, 0x2e, 0xfe}, // 167
00187         {0xe2, 0x59, 0x7f}, // 168
00188         {0x4c, 0xdc, 0x67}, // 169
00189         {0xff, 0x18, 0xff}, // 170
00190         {0x3a, 0x7d, 0xff}, // 171
00191         {0xb1, 0xd0, 0x18}, // 172
00192         {0xc7, 0xff, 0x00}, // 173
00193         {0xff, 0xe2, 0x00}, // 174
00194         {0xdf, 0x9a, 0x3d}, // 175
00195         {0x56, 0x81, 0x9f}, // 176
00196         {0xc6, 0x43, 0xba}, // 177
00197         {0xaf, 0x71, 0x8b}, // 178
00198         {0x38, 0xa2, 0xc9}, // 179
00199         {0xd1, 0x53, 0xce}, // 180
00200         {0xff, 0x9a, 0x65}, // 181
00201         {0x46, 0xca, 0xdb}, // 182
00202         {0xff, 0x4d, 0xff}, // 183
00203         {0xc8, 0xe9, 0x6a}, // 184
00204         {0x4c, 0xde, 0xe0}, // 185
00205         {0xff, 0x98, 0xff}, // 186
00206         {0xdf, 0xc0, 0x82}, // 187
00207         {0xe9, 0xec, 0xa5}, // 188
00208         {0xf5, 0xf6, 0xcd}, // 189
00209         {0xff, 0xd0, 0xff}, // 190
00210         {0xb1, 0xac, 0x5a}, // 191
00211         {0x63, 0x91, 0xae}, // 192
00212         {0x22, 0x4c, 0x65}, // 193
00213         {0x8d, 0x4e, 0x3f}, // 194
00214         {0x50, 0x70, 0x70}, // 195
00215         {0xd0, 0xff, 0xff}, // 196
00216         {0xff, 0xe7, 0xff}, // 197
00217         {0x69, 0x69, 0x69}, // 198  gray 105
00218         {0x77, 0x77, 0x77}, // 199  gray 119
00219         {0x86, 0x86, 0x86}, // 200  gray 134
00220         {0x96, 0x96, 0x96}, // 201  gray 150
00221         {0x9d, 0x9d, 0x9d}, // 202  gray 157
00222         {0xa4, 0xa4, 0xa4}, // 203  gray 164
00223         {0xb2, 0xb2, 0xb2}, // 204  gray 178
00224         {0xcb, 0xcb, 0xcb}, // 205  gray 203
00225         {0xd7, 0xd7, 0xd7}, // 206  gray 215
00226         {0xdd, 0xdd, 0xdd}, // 207  gray 221
00227         {0xe3, 0xe3, 0xe3}, // 208  gray 227
00228         {0xea, 0xea, 0xea}, // 209  gray 234
00229         {0xf1, 0xf1, 0xf1}, // 210  gray 241
00230         {0xf8, 0xf8, 0xf8}, // 211  gray 248
00231         {0xb2, 0xc1, 0x66}, // 212
00232         {0x80, 0xbf, 0x78}, // 213
00233         {0xc6, 0xf0, 0xf0}, // 214
00234         {0xb2, 0xa4, 0xff}, // 215
00235         {0xff, 0xb3, 0xff}, // 216
00236         {0xd1, 0x8e, 0xa3}, // 217
00237         {0xc3, 0xdc, 0x37}, // 218
00238         {0xa0, 0x9e, 0x54}, // 219
00239         {0x76, 0xae, 0x70}, // 220
00240         {0x78, 0x9e, 0xc1}, // 221
00241         {0x83, 0x64, 0xbf}, // 222
00242         {0xa4, 0x83, 0xd3}, // 223
00243         {0xd1, 0x3f, 0x32}, // 224
00244         {0xff, 0x7d, 0x00}, // 225
00245         {0x44, 0x78, 0x23}, // 226
00246         {0x24, 0x5f, 0x60}, // 227
00247         {0x0e, 0x0e, 0x2c}, // 228
00248         {0xbe, 0x00, 0x00}, // 229
00249         {0xff, 0x1f, 0x00}, // 230
00250         {0x31, 0x39, 0x00}, // 231
00251         {0xd9, 0x85, 0x3e}, // 232
00252         {0x02, 0x77, 0x85}, // 233
00253         {0xb0, 0xd8, 0x81}, // 234
00254         {0x56, 0x21, 0x1d}, // 235
00255         {0x00, 0x00, 0x30}, // 236
00256         {0x88, 0xc8, 0xb3}, // 237
00257         {0xa0, 0x79, 0x00}, // 238
00258         {0xc0, 0xc0, 0xc0}, // 239 Sys Dk Grey repeat inversion gray 192
00259         {0xea, 0x70, 0x81}, // 240
00260         {0x51, 0xf1, 0x69}, // 241
00261         {0xff, 0xff, 0x80}, // 242
00262         {0x91, 0x74, 0xcd}, // 243
00263         {0xff, 0x7c, 0xff}, // 244
00264         {0xa2, 0xff, 0xff}, // 245
00265
00266         {0xff, 0xfb, 0xf0}, // 246 Sys Reserved
00267         {0xa0, 0xa0, 0xa4}, // 247 Sys Reserved
00268         {0x80, 0x80, 0x80}, // 248 Sys Lt Gray  gray 128
00269         {0xff, 0x00, 0x00}, // 249 Sys Red
00270         {0x00, 0xff, 0x00}, // 250 Sys Green
00271         {0xff, 0xff, 0x00}, // 251 Sys Yellow
00272         {0x00, 0x00, 0xff}, // 252 Sys Blue
00273         {0xff, 0x00, 0xff}, // 253 Sys Violet
00274         {0x00, 0xff, 0xff}, // 254 Sys Cyan
00275         {0xff, 0xff, 0xff} // 255 Sys White gray 255
00276         };
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/InvokObjThreads/InvokObjThreads.cpp Source File

  • Web
  • iis
  • extensions
  • InvokObjThreads

InvokObjThreads.cpp

Go to the documentation of this file.
00001 //  Copyright (c) 1997-2002 Microsoft Corporation
00002 //
00003 //  Module Name:
00004 //
00005 //    InvokObjThreads.cpp
00006 //
00007 //  Abstract:
00008 //
00009 //  ISAPI Extension sample to invoke an automation server method
00010 //  from worker threads
00011
00012 #define _WIN32_WINNT 0x0400
00013 #include <windows.h>
00014 #include <httpext.h>
00015 #include "IsapiThread.h"
00016
00017 // Prototype for worker thread function
00018
00019 DWORD WINAPI WorkerThread(LPVOID pParam);
00020
00021 // Import type library information about the COM object
00022
00023 #import "GetUserName.dll"
00024
00025 // Global thread pool object
00026
00027 ISAPITHREAD *pThreadPool;
00028
00029 //  Description:
00030 //
00031 //    The initialization function for this DLL.
00032 //
00033 //  Arguments:
00034 //
00035 //    hinstDll - Instance handle of the DLL
00036 //    dwReason - Reason why NT called this DLL
00037 //    lpvContext - Reserved parameter for future use
00038 //
00039 //  Return Value:
00040 //
00041 //    Returns TRUE if successfull; otherwise FALSE.
00042
00043 BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
00044 {
00045   switch (ul_reason_for_call) {
00046
00047     case DLL_PROCESS_ATTACH:
00048
00049       // Allocate the thread pool object
00050
00051       pThreadPool = new ISAPITHREAD;
00052
00053       if (!pThreadPool) {
00054
00055         #ifdef _DEBUG
00056           OutputDebugString("Failed to allocate thread pool object. InvokObjThreads is terminating.\r\n");
00057         #endif  // _DEBUG
00058
00059         return FALSE;
00060       }
00061
00062       // Initialize the worker threads
00063
00064       if (!pThreadPool->InitThreadPool(WorkerThread)) {
00065
00066         #ifdef _DEBUG
00067           OutputDebugString("Failed to initialize worker threads. InvokObjThreads is terminating.\r\n");
00068         #endif  // _DEBUG
00069
00070         delete pThreadPool;
00071
00072         return FALSE;
00073       }
00074
00075       break;
00076
00077     case DLL_PROCESS_DETACH:
00078
00079       break;
00080
00081     default:
00082
00083       return TRUE;
00084   }
00085
00086   return TRUE;
00087 }
00088
00089 //  Description:
00090 //
00091 //    This is required ISAPI Extension DLL entry point.
00092 //
00093 //  Arguments:
00094 //
00095 //    pVer - poins to extension version info structure
00096 //
00097 //  Returns:
00098 //
00099 //    Always returns TRUE
00100
00101 BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
00102 {
00103   pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR, HSE_VERSION_MAJOR );
00104
00105   lstrcpyn( pVer->lpszExtensionDesc, "InvokObjThreads ISAPI Sample", HSE_MAX_EXT_DLL_NAME_LEN );
00106
00107   return TRUE;
00108 }
00109
00110 //  Purpose:
00111 //
00112 //    Demonstrate how to create an instance of the automation object
00113 //    using VC++ 5.0 extensions and how to invoke its method.
00114 //
00115 //  Arguments:
00116 //
00117 //    pECB - pointer to the extenstion control block
00118 //
00119 //  Returns:
00120 //
00121 //    HSE_STATUS_SUCCESS on successful transmission completion
00122 //    HSE_STATUS_ERROR on failure
00123
00124 DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pecb)
00125 {
00126   HSE_SEND_HEADER_EX_INFO HeaderExInfo;
00127
00128   // Add the request to the work item queue.
00129   // If successful, we're done.  If not, return an error to the client
00130
00131   if (pThreadPool->QueueWorkItem(pecb))
00132       return HSE_STATUS_PENDING;
00133
00134   // Send headers back to client
00135
00136   HeaderExInfo.pszStatus = "200 OK";
00137   HeaderExInfo.cchStatus = strlen(HeaderExInfo.pszStatus);
00138   HeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n";
00139   HeaderExInfo.cchHeader = strlen(HeaderExInfo.pszHeader);
00140   HeaderExInfo.fKeepConn = FALSE;
00141
00142   pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL);
00143
00144   // Send back a message to the client indicating that the queue is full
00145
00146   CHAR szOutput[] = "<h1>InvokObjThreads.dll</h1><hr>The resource is busy.  Pleast try again later.";
00147
00148   DWORD dwBuffSize = strlen(szOutput);
00149
00150   pecb->WriteClient(pecb->ConnID, szOutput, &dwBuffSize, 0);
00151
00152   return HSE_STATUS_SUCCESS;
00153 }
00154
00155 //  Description:
00156 //
00157 //    This is optional ISAPI extension DLL entry point.
00158 //    If present, it will be called before unloading the DLL,
00159 //    giving it a chance to perform any shutdown procedures.
00160 //
00161 //  Arguments:
00162 //
00163 //    dwFlags - specifies whether the DLL can refuse to unload or not
00164 //
00165 //  Returns:
00166 //
00167 //    TRUE, if the DLL can be unloaded
00168
00169 BOOL WINAPI TerminateExtension(DWORD dwFlags)
00170 {
00171   // Delete the thread pool object
00172
00173   delete pThreadPool;
00174
00175   // It is now OK to unload
00176
00177   return TRUE;
00178 }
00179
00180 //  Description:
00181 //
00182 //    Implements the worker thread functionality
00183 //
00184 //  Arguments:
00185 //
00186 //    pParam - A pointer to the threadpool object to which the thread belongs
00187 //
00188 //  Returns:
00189 //
00190 //    0
00191
00192 DWORD WINAPI WorkerThread(LPVOID pParam)
00193 {
00194   ISAPITHREAD *pThreadPool = (ISAPITHREAD *)pParam;
00195
00196   #ifdef _DEBUG
00197     CHAR szDebug[1024];
00198   #endif
00199
00200   // Get the ThreadId for this thread
00201
00202   DWORD dwThreadId = GetCurrentThreadId();
00203
00204   #ifdef _DEBUG
00205     wsprintf(szDebug, "Initializing worker thread %d.\r\n", dwThreadId);
00206
00207     OutputDebugString(szDebug);
00208   #endif // _DEBUG
00209
00210   // Initialize COM for this thread
00211
00212   HRESULT hr = CoInitialize(NULL);
00213
00214   if (FAILED(hr)) {
00215
00216     #ifdef _DEBUG
00217       wsprintf(szDebug, "CoIntialize failed for thread %d: 0x%08x (%d)\r\n", dwThreadId, hr, hr);
00218
00219       OutputDebugString(szDebug);
00220     #endif // _DEBUG
00221
00222     return FALSE;
00223   }
00224
00225   // Initialize and instance of the automation server for this thread
00226
00227   GETUSERNAMELib::IGetUserNameObjPtr pItf;
00228
00229   hr = pItf.CreateInstance(L"GetUserNameObj.GetUserNameObj.1");
00230
00231   if (FAILED(hr)) {
00232
00233     #ifdef _DEBUG
00234       wsprintf(szDebug, "Failed to get interface pointer for thread %d: 0x%08x (%d)\r\n", dwThreadId, hr, hr);
00235
00236       OutputDebugString(szDebug);
00237     #endif // _DEBUG
00238
00239     goto ExitWorkerThread;
00240   }
00241
00242   // Completed thread initialization.  Now wait for work
00243
00244   for (;;) {
00245
00246     #ifdef _DEBUG
00247       wsprintf(szDebug, "Thread %d waiting for work.\r\n", dwThreadId);
00248
00249       OutputDebugString(szDebug);
00250     #endif  // _DEBUG
00251
00252     DWORD dwResult = WaitForSingleObject(pThreadPool->m_hWorkerThreadSemaphore, INFINITE);
00253
00254     // Check to see that the wait succeeded
00255
00256     if (dwResult != WAIT_OBJECT_0) {
00257
00258       #ifdef _DEBUG
00259         wsprintf(szDebug, "Thread %d exiting due to wait failure.\r\n", dwThreadId);
00260
00261         OutputDebugString(szDebug);
00262       #endif  // _DEBUG
00263
00264       goto ExitWorkerThread;
00265     }
00266
00267     // Get the next work item in the queue.  If the work item is NULL,
00268     // the thread should exit gracefully.
00269
00270     EXTENSION_CONTROL_BLOCK *pecb = pThreadPool->GetWorkItem();
00271
00272     if (!pecb) {
00273
00274       #ifdef _DEBUG
00275         wsprintf(szDebug, "Thread %d exiting gracefully.\r\n", dwThreadId);
00276
00277         OutputDebugString(szDebug);
00278       #endif  // _DEBUG
00279
00280       goto ExitWorkerThread;
00281     }
00282
00283     ///////
00284     // Process the work item
00285     ///////
00286
00287     #ifdef _DEBUG
00288       wsprintf(szDebug, "Thread %d processing work item.\r\n", dwThreadId);
00289
00290       OutputDebugString(szDebug);
00291     #endif  // _DEBUG
00292
00293     // Get the request token from IIS and set the token for this thead
00294
00295     HANDLE hRequestToken;
00296
00297     pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_GET_IMPERSONATION_TOKEN, &hRequestToken, NULL, NULL);
00298
00299     SetThreadToken(NULL, hRequestToken);
00300
00301     // Send headers back to client
00302
00303     HSE_SEND_HEADER_EX_INFO HeaderExInfo;
00304
00305     HeaderExInfo.pszStatus = "200 OK";
00306     HeaderExInfo.cchStatus = strlen( HeaderExInfo.pszStatus );
00307     HeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n";
00308     HeaderExInfo.cchHeader = strlen( HeaderExInfo.pszHeader );
00309     HeaderExInfo.fKeepConn = FALSE;
00310
00311     pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL);
00312
00313     // Build the output using the result of the call to GetUserNameObj's GetMyName method
00314
00315     char szOutput[1024];
00316
00317     wsprintf(szOutput, "<h1>Request handled by thread %d.</h1><hr>The GetMyName method returned %s.", dwThreadId, (char *)pItf->GetMyName());
00318
00319     // Send the output back to the client
00320
00321     DWORD dwBuffSize = strlen(szOutput);
00322
00323     pecb->WriteClient(pecb->ConnID, szOutput, &dwBuffSize, 0);
00324
00325     // Notify IIS that we are done processing the request
00326
00327     pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_DONE_WITH_SESSION, NULL, NULL, NULL);
00328   }
00329
00330 ExitWorkerThread:
00331
00332   // Uninitialize COM for this thread and return
00333
00334   CoUninitialize();
00335
00336   return 0;
00337 }
00338
00339
00340
00341
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMgdResType Member List

This is the complete list of members for CMgdResType, including all inherited members.
CMgdClusCfgInit(void) | CMgdClusCfgInit |
CMgdClusCfgInit(void) | CMgdClusCfgInit |
CMgdResType(void) | CMgdResType | [inline]
CMgdResType(const CMgdResType &rSrcIn) | CMgdResType | [private]
CommitChanges(IUnknown *punkClusterInfoIn, IUnknown *punkResTypeServicesIn) | CMgdResType |
GetCallback(void) | CMgdClusCfgInit | [inline]
GetCallback(void) | CMgdClusCfgInit | [inline]
GetDisplayName(void) | CMgdClusCfgInit | [inline]
GetDisplayName(void) | CMgdClusCfgInit | [inline]
GetDllName(void) | CMgdClusCfgInit | [inline]
GetDllName(void) | CMgdClusCfgInit | [inline]
GetLCID(void) | CMgdClusCfgInit | [inline]
GetLCID(void) | CMgdClusCfgInit | [inline]
GetNodeName(void) | CMgdClusCfgInit | [inline]
GetNodeName(void) | CMgdClusCfgInit | [inline]
GetResTypeName(void) | CMgdClusCfgInit | [inline]
GetResTypeName(void) | CMgdClusCfgInit | [inline]
GetTypeGUID(GUID *pguidGUIDOut) | CMgdResType |
GetTypeName(BSTR *pbstrTypeNameOut) | CMgdResType |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, LPCWSTR pcszReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, UINT idsDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, LPCWSTR pcszReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, UINT idsDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMgdClusCfgInit |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMgdClusCfgInit |
Notify(IUnknown *punkIn) | CMgdResType |
operator=(const CMgdResType &rSrcIn) | CMgdResType | [private]
~CMgdClusCfgInit(void) | CMgdClusCfgInit | [virtual]
~CMgdClusCfgInit(void) | CMgdClusCfgInit | [virtual]
~CMgdResType(void) | CMgdResType | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::SearchDirectionEnum Member List

This is the complete list of members for msado15::SearchDirectionEnum, including all inherited members.
adSearchBackward | msado15::SearchDirectionEnum | [static]
adSearchForward | msado15::SearchDirectionEnum | [static]
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcADO/Resource.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcADO

Resource.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ADOKB.rc
00004 //
00005 // This file is part of the Microsoft COM+ Samples
00006 //
00007 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00008 //
00009 // This source code is intended only as a supplement to Microsoft
00010 // Development Tools and/or on-line documentation.  See these other
00011 // materials for detailed information reagrding Microsoft code samples.
00012 //
00013 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00014 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00015 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00016 // PARTICULAR PURPOSE.
00017 //
00018 //==============================================================================
00019 //{{NO_DEPENDENCIES}}
00020
00021 #define IDS_PROJNAME                    100
00022 #define IDR_ADOCOMPONENT                101
00023
00024 // Next default values for new objects
00025 //
00026 #ifdef APSTUDIO_INVOKED
00027 #ifndef APSTUDIO_READONLY_SYMBOLS
00028 #define _APS_NEXT_RESOURCE_VALUE        201
00029 #define _APS_NEXT_COMMAND_VALUE         32768
00030 #define _APS_NEXT_CONTROL_VALUE         201
00031 #define _APS_NEXT_SYMED_VALUE           102
00032 #endif
00033 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_EVENT_SINK_INFO Member List

This is the complete list of members for _EVENT_SINK_INFO, including all inherited members.
eEvent | _EVENT_SINK_INFO
sDisplayName | _EVENT_SINK_INFO
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/app.Cpp Source File

  • Com
  • Fundamentals
  • SimpSvr

app.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: app.cpp
00003 //
00004 //    Implementation file for the CSimpSvrApp Class
00005 //
00006 // Functions:
00007 //
00008 //    See app.h for a list of member functions.
00009 //
00010 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "obj.h"
00015 #include "app.h"
00016 #include "doc.h"
00017 #include "icf.h"
00018
00019 #include "initguid.h"
00020 DEFINE_GUID(GUID_SIMPLE, 0xBCF6D4A0, 0xBE8C, 0x1068, 0xB6, 0xD4, 0x00, 0xDD, 0x01, 0x0C, 0x05, 0x09);
00021
00022
00023 //**********************************************************************
00024 //
00025 // CSimpSvrApp::CSimpSvrApp()
00026 //
00027 // Purpose:
00028 //
00029 //      Constructor for CSimpSvrApp
00030 //
00031 // Parameters:
00032 //
00033 //      None
00034 //
00035 // Return Value:
00036 //
00037 //      None
00038 //
00039 // Function Calls:
00040 //      Function                    Location
00041 //
00042 //      OutputDebugString           Windows API
00043 //      SetRectEmpty                Windows API
00044 //
00045 // Comments:
00046 //
00047 //
00048 //********************************************************************
00049
00050 CSimpSvrApp::CSimpSvrApp()
00051 {
00052         OutputDebugString("In CSimpSvrApp's Constructor \r\n");
00053
00054         // clear members
00055         m_hAppWnd = NULL;
00056         m_hInst = NULL;
00057         m_lpDoc = NULL;
00058
00059         // clear flags
00060         m_fInitialized = m_fOleStdInit = FALSE;
00061
00062         // used for inplace
00063         SetRectEmpty(&nullRect);
00064 }
00065
00066 //**********************************************************************
00067 //
00068 // CSimpSvrApp::~CSimpSvrApp()
00069 //
00070 // Purpose:
00071 //
00072 //      Destructor for CSimpSvrApp Class.
00073 //
00074 // Parameters:
00075 //
00076 //      None
00077 //
00078 // Return Value:
00079 //
00080 //      None
00081 //
00082 // Function Calls:
00083 //      Function                    Location
00084 //
00085 //      OutputDebugString           Windows API
00086 //      DestroyWindow               Windows API
00087 //      CSimpSvrApp::IsInitialized  APP.H
00088 //      OleUninitialize             OLE API
00089 //
00090 // Comments:
00091 //
00092 //********************************************************************
00093
00094 CSimpSvrApp::~CSimpSvrApp()
00095 {
00096         OutputDebugString("In CSimpSvrApp's Destructor\r\n");
00097
00098         if (m_fOleStdInit)
00099             OleStdUninitialize();
00100
00101         // need to uninit the library...
00102         if (IsInitialized())
00103                 OleUninitialize();
00104
00105         DestroyWindow(m_hAppWnd);
00106 }
00107
00108
00109 //**********************************************************************
00110 //
00111 // CSimpSvrApp::QueryInterface
00112 //
00113 // Purpose:
00114 //
00115 //      Used for interface negotiation at the Application level.
00116 //
00117 // Parameters:
00118 //
00119 //      REFIID riid         -   A reference to the interface that is
00120 //                              being queried.
00121 //
00122 //      LPVOID FAR* ppvObj  -   An out parameter to return a pointer to
00123 //                              the interface.
00124 //
00125 // Return Value:
00126 //
00127 //      S_OK          -   The interface is supported.
00128 //      E_NOINTERFACE -   The interface is not supported
00129 //
00130 // Function Calls:
00131 //      Function                    Location
00132 //
00133 //      OutputDebugString           Windows API
00134 //                   OLE API
00135 //      IUnknown::AddRef            APP.CPP
00136 //
00137 // Comments:
00138 //
00139 //
00140 //********************************************************************
00141
00142 STDMETHODIMP CSimpSvrApp::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00143 {
00144         OutputDebugString("In CSimpSvrApp::QueryInterface\r\n");
00145
00146         SCODE sc = S_OK;
00147
00148         if (riid == IID_IUnknown)
00149                 *ppvObj = this;
00150         else
00151                 {
00152                 *ppvObj = NULL;
00153                 sc = E_NOINTERFACE;
00154                 }
00155
00156         if (*ppvObj)
00157                 ((LPUNKNOWN)*ppvObj)->AddRef();
00158
00159         // asking for something we don't understand at this level.
00160         return sc;
00161 }
00162
00163 //**********************************************************************
00164 //
00165 // CSimpSvrApp::AddRef
00166 //
00167 // Purpose:
00168 //
00169 //      Adds to the reference count at the Application level.
00170 //
00171 // Parameters:
00172 //
00173 //      None
00174 //
00175 // Return Value:
00176 //
00177 //      ULONG   -   The new reference count of the application.
00178 //
00179 // Function Calls:
00180 //      Function                    Location
00181 //
00182 //      OutputDebugString           Windows API
00183 //
00184 // Comments:
00185 //
00186 //      Due to the reference counting model that is used in this
00187 //      implementation, this reference count is the sum of the
00188 //      reference counts on all interfaces of all objects open
00189 //      in the application.
00190 //
00191 //********************************************************************
00192
00193 STDMETHODIMP_(ULONG) CSimpSvrApp::AddRef()
00194 {
00195         OutputDebugString("In CSimpSvrApp::AddRef\r\n");
00196         return SafeAddRef();
00197 }
00198
00199 //**********************************************************************
00200 //
00201 // CSimpSvrApp::Release
00202 //
00203 // Purpose:
00204 //
00205 //      Decrements the reference count at this level
00206 //
00207 // Parameters:
00208 //
00209 //      None
00210 //
00211 // Return Value:
00212 //
00213 //      ULONG   -   The new reference count of the application.
00214 //
00215 // Function Calls:
00216 //      Function                    Location
00217 //
00218 //      OutputDebugString           Windows API
00219 //
00220 // Comments:
00221 //
00222 //      Due to the reference counting model that is used in this
00223 //      implementation, this reference count is the sum of the
00224 //      reference counts on all interfaces of all objects open
00225 //      in the application.
00226 //
00227 //********************************************************************
00228
00229 STDMETHODIMP_(ULONG) CSimpSvrApp::Release()
00230 {
00231         OutputDebugString("In CSimpSvrApp::Release\r\n");
00232
00233         return SafeRelease();
00234 }
00235
00236 //**********************************************************************
00237 //
00238 // CSimpSvrApp::fInitApplication
00239 //
00240 // Purpose:
00241 //
00242 //      Initializes the application
00243 //
00244 // Parameters:
00245 //
00246 //      HANDLE hInstance    -   Instance handle of the application.
00247 //
00248 // Return Value:
00249 //
00250 //      TRUE    -   Application was successfully initialized.
00251 //      FALSE   -   Application could not be initialized
00252 //
00253 // Function Calls:
00254 //      Function                    Location
00255 //
00256 //      LoadIcon                    Windows API
00257 //      LoadCursor                  Windows API
00258 //      GetStockObject              Windows API
00259 //      RegisterClass               Windows API
00260 //      RegisterHatchWindowClass    OUTLUI.DLL
00261 //
00262 // Comments:
00263 //
00264 //********************************************************************
00265
00266 BOOL CSimpSvrApp::fInitApplication(HINSTANCE hInstance)
00267 {
00268         CStabilize stabilize(this);
00269         WNDCLASS  wc;
00270
00271         // Fill in window class structure with parameters that describe the
00272         // main window.
00273
00274         wc.style = NULL;                    // Class style(s).
00275         wc.lpfnWndProc = MainWndProc;       // Function to retrieve messages for
00276                                                                                 // windows of this class.
00277         wc.cbClsExtra = 0;                  // No per-class extra data.
00278         wc.cbWndExtra = 0;                  // No per-window extra data.
00279         wc.hInstance = hInstance;           // Application that owns the class.
00280         wc.hIcon = LoadIcon(hInstance, "SimpSvr");
00281         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00282         wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00283         wc.lpszMenuName =  "SimpSvrMENU";    // Name of menu resource in .RC file.
00284         wc.lpszClassName = "SimpSvrWClass";  // Name used in call to CreateWindow.
00285
00286         if (!RegisterClass(&wc))
00287                 return FALSE;
00288
00289         wc.style = CS_VREDRAW | CS_HREDRAW;                    // Class style(s).
00290         wc.lpfnWndProc = DocWndProc;        // Function to retrieve messages for
00291                                                                                 // windows of this class.
00292         wc.cbClsExtra = 0;                  // No per-class extra data.
00293         wc.cbWndExtra = 0;                  // No per-window extra data.
00294         wc.hInstance = hInstance;           // Application that owns the class.
00295         wc.hIcon = NULL;
00296         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00297         wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00298         wc.lpszMenuName =  NULL;
00299         wc.lpszClassName = "DocWClass";     // Name used in call to CreateWindow.
00300
00301         // Register the window class and return success/failure code.
00302
00303         if (!RegisterClass(&wc))
00304                 return FALSE;
00305
00306         return (RegisterHatchWindowClass(hInstance));
00307 }
00308
00309 //**********************************************************************
00310 //
00311 // CSimpSvrApp::fInitInstance
00312 //
00313 // Purpose:
00314 //
00315 //      Instance initialization.
00316 //
00317 // Parameters:
00318 //
00319 //      HANDLE hInstance    -   App. Instance Handle.
00320 //
00321 //      int nCmdShow        -   Show parameter from WinMain
00322 //
00323 // Return Value:
00324 //
00325 //      TRUE    -   Initialization Successful
00326 //      FALSE   -   Initialization Failed.
00327 //
00328 //
00329 // Function Calls:
00330 //      Function                    Location
00331 //
00332 //      CreateWindow                Windows API
00333 //      InvalidateRect              Windows API
00334 //      ShowWindow                  Windows API
00335 //      UpdateWindow                Windows API
00336 //      CoRegisterClassObject       OLE API
00337 //      OleBuildVersion             OLE API
00338 //      OleInitialize               OLE API
00339 //      CSimpSvrDoc::CreateObject   DOC.CPP
00340 //
00341 // Comments:
00342 //
00343 //      Note that successful Initalization of the OLE libraries
00344 //      is remembered so the UnInit is only called if needed.
00345 //
00346 //********************************************************************
00347
00348 BOOL CSimpSvrApp::fInitInstance (HINSTANCE hInstance, int nCmdShow, CClassFactory FAR * lpClassFactory)
00349 {
00350         CStabilize stabilize(this);
00351         m_hInst = hInstance;
00352
00353                 DWORD dwVer = OleBuildVersion();
00354
00355         // check to see if we are compatible with this version of the libraries
00356         if (HIWORD(dwVer) != rmm || LOWORD(dwVer) < rup)
00357                 OutputDebugString("*** WARNING:  Not compatible with current libs ***\r\n");
00358
00359         // initialize the libraries
00360         if (OleInitialize(NULL) == NOERROR)
00361                 m_fInitialized = TRUE;
00362
00363         m_fOleStdInit = OleStdInitialize(hInstance);
00364
00365         // Create the "application" windows
00366         m_hAppWnd = CreateWindow ("SimpSvrWClass",
00367                                                           "Simple OLE 2.0 Server",
00368                                                           WS_OVERLAPPEDWINDOW,
00369                                                           CW_USEDEFAULT,
00370                                                           CW_USEDEFAULT,
00371                                                           CW_USEDEFAULT,
00372                                                           CW_USEDEFAULT,
00373                                                           NULL,
00374                                                           NULL,
00375                                                           hInstance,
00376                                                           NULL);
00377
00378         if (!m_hAppWnd)
00379                 return FALSE;
00380
00381         // if not started by OLE, then show the Window, and create a "fake" object, else
00382         // Register a pointer to IClassFactory so that OLE can instruct us to make an
00383         // object at the appropriate time.
00384         if (!m_fStartByOle)
00385                 {
00386                 ShowAppWnd(nCmdShow);
00387                 m_lpDoc->CreateObject(IID_IOleObject, (LPVOID FAR *)&m_OleObject);
00388                 InvalidateRect(m_lpDoc->GethDocWnd(), NULL, TRUE);
00389                 }
00390         else
00391                 {
00392                 lpClassFactory = new CClassFactory(this);
00393
00394                 // shouldn't pass an API an object with a zero ref count
00395                 lpClassFactory->AddRef();
00396
00397                 CoRegisterClassObject(GUID_SIMPLE,(IUnknown FAR *)lpClassFactory, CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &m_dwRegisterClass);
00398
00399                 // remove artificial Ref. count
00400                 lpClassFactory->Release();
00401                 }
00402
00403         m_hMainMenu = GetMenu(m_hAppWnd);
00404         m_hColorMenu = GetSubMenu(m_hMainMenu, 1);
00405         m_hHelpMenu = GetSubMenu(m_hMainMenu, 2);
00406
00407
00408         return m_fInitialized;
00409 }
00410
00411 //**********************************************************************
00412 //
00413 // CSimpSvrApp::lCommandHandler
00414 //
00415 // Purpose:
00416 //
00417 //      Handles the processing of WM_COMMAND.
00418 //
00419 // Parameters:
00420 //
00421 //      HWND hWnd       -   Handle to the application Window
00422 //
00423 //      UINT message    -   message (always WM_COMMAND)
00424 //
00425 //      WPARAM wParam   -   Same as passed to the WndProc
00426 //
00427 //      LPARAM lParam   -   Same as passed to the WndProc
00428 //
00429 // Return Value:
00430 //
00431 //      NULL
00432 //
00433 // Function Calls:
00434 //      Function                                    Location
00435 //
00436 //      GetClientRect                               Windows API
00437 //      MessageBox                                  Windows API
00438 //      DialogBox                                   Windows API
00439 //      MakeProcInstance                            Windows API
00440 //      FreeProcInstance                            Windows API
00441 //      SendMessage                                 Windows API
00442 //      DefWindowProc                               Windows API
00443 //      InvalidateRect                              Windows API
00444 //      CSimpSvrDoc::InsertObject                   DOC.CPP
00445 //      CSimpSvrObj::SetColor                       OBJ.CPP
00446 //      CSimpSvrObj::RotateColor                    OBJ.CPP
00447 //
00448 // Comments:
00449 //
00450 //********************************************************************
00451
00452 long CSimpSvrApp::lCommandHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00453 {
00454         CStabilize stabilize(this);
00455         //@@WTK WIN32, UNICODE
00456         //switch (wParam) {
00457         switch (LOWORD(wParam)) {
00458                 // bring up the About box
00459                 case IDM_ABOUT:
00460                         {
00461
00462                         DialogBox(m_hInst,               // current instance
00463                                         "AboutBox",                  // resource to use
00464                                         m_hAppWnd,                   // parent handle
00465                                         (DLGPROC) About);                // About() instance address
00466
00467                         break;
00468                         }
00469
00470                 // exit the application
00471                 case IDM_EXIT:
00472                         SendMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
00473                         break;
00474
00475                 case IDM_RED:
00476                         m_lpDoc->GetObj()->SetColor (128, 0, 0);
00477                         InvalidateRect(m_lpDoc->GethDocWnd(), NULL, TRUE);
00478                         break;
00479
00480                 case IDM_GREEN:
00481                         m_lpDoc->GetObj()->SetColor (0,128, 0);
00482                         InvalidateRect(m_lpDoc->GethDocWnd(), NULL, TRUE);
00483                         break;
00484
00485                 case IDM_BLUE:
00486                         m_lpDoc->GetObj()->SetColor (0, 0, 128);
00487                         InvalidateRect(m_lpDoc->GethDocWnd(), NULL, TRUE);
00488                         break;
00489
00490                 case IDM_ROTATE:
00491                         m_lpDoc->GetObj()->RotateColor();
00492                         InvalidateRect(m_lpDoc->GethDocWnd(), NULL, TRUE);
00493                         break;
00494
00495                 default:
00496                         return (DefWindowProc(hWnd, message, wParam, lParam));
00497                    }   // end of switch
00498         return NULL;
00499 }
00500
00501 //**********************************************************************
00502 //
00503 // CSimpSvrApp::lSizeHandler
00504 //
00505 // Purpose:
00506 //
00507 //      Handles the WM_SIZE message
00508 //
00509 // Parameters:
00510 //
00511 //      HWND hWnd       -   Handle to the application Window
00512 //
00513 //      UINT message    -   message (always WM_SIZE)
00514 //
00515 //      WPARAM wParam   -   Same as passed to the WndProc
00516 //
00517 //      LPARAM lParam   -   Same as passed to the WndProc
00518 //
00519 // Return Value:
00520 //
00521 //      LONG    -   returned from the "document" resizing
00522 //
00523 // Function Calls:
00524 //      Function                    Location
00525 //
00526 //      GetClientRect               Windows API
00527 //      CSimpSvrDoc::lResizeDoc      DOC.CPP
00528 //
00529 // Comments:
00530 //
00531 //********************************************************************
00532
00533 long CSimpSvrApp::lSizeHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00534 {
00535         RECT rect;
00536         CStabilize stabilize(this);
00537
00538         GetClientRect(m_hAppWnd, &rect);
00539         return m_lpDoc->lResizeDoc(&rect);
00540 }
00541
00542 //**********************************************************************
00543 //
00544 // CSimpSvrApp::lCreateDoc
00545 //                                                         d
00546 // Purpose:
00547 //
00548 //      Handles the creation of a document.
00549 //
00550 // Parameters:
00551 //
00552 //      HWND hWnd       -   Handle to the application Window
00553 //
00554 //      UINT message    -   message (always WM_CREATE)
00555 //
00556 //      WPARAM wParam   -   Same as passed to the WndProc
00557 //
00558 //      LPARAM lParam   -   Same as passed to the WndProc
00559 //
00560 // Return Value:
00561 //
00562 //      NULL
00563 //
00564 // Function Calls:
00565 //      Function                    Location
00566 //
00567 //      GetClientRect               Windows API
00568 //      CSimpSvrDoc::Create         DOC.CPP
00569 //
00570 // Comments:
00571 //
00572 //********************************************************************
00573
00574 long CSimpSvrApp::lCreateDoc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00575 {
00576         RECT rect;
00577         CStabilize stabilize(this);
00578
00579         GetClientRect(hWnd, &rect);
00580
00581         m_lpDoc = CSimpSvrDoc::Create(this, &rect, hWnd);
00582
00583         return NULL;
00584 }
00585
00586
00587
00588 //**********************************************************************
00589 //
00590 // CSimpSvrApp::PaintApp
00591 //
00592 // Purpose:
00593 //
00594 //      Handles the painting of the doc window.
00595 //
00596 //
00597 // Parameters:
00598 //
00599 //      HDC hDC -   hDC to the Doc Window.
00600 //
00601 // Return Value:
00602 //
00603 //      None
00604 //
00605 // Function Calls:
00606 //      Function                    Location
00607 //
00608 //      CSimpSvrDoc::PaintDoc        DOC.CPP
00609 //
00610 // Comments:
00611 //
00612 //
00613 //********************************************************************
00614
00615 void CSimpSvrApp::PaintApp (HDC hDC)
00616 {
00617         CStabilize stabilize(this);
00618
00619         // if we supported multiple documents, we would enumerate
00620         // through each of the open documents and call paint.
00621
00622         if (m_lpDoc)
00623                 m_lpDoc->PaintDoc(hDC);
00624
00625 }
00626
00627 //**********************************************************************
00628 //
00629 // CSimpSvrApp::ParseCmdLine
00630 //
00631 // Purpose:
00632 //
00633 //      Determines if the app was started by OLE
00634 //
00635 //
00636 // Parameters:
00637 //
00638 //      LPSTR lpCmdLine -   Pointer to the command line
00639 //
00640 // Return Value:
00641 //
00642 //      None
00643 //
00644 // Function Calls:
00645 //      Function                    Location
00646 //
00647 //      lstrlen                     Windows API
00648 //      lstrcmp                     Windows API
00649 //
00650 //
00651 // Comments:
00652 //
00653 //      Parses the command line looking for the -Embedding or /Embedding
00654 //      flag.
00655 //
00656 //********************************************************************
00657
00658 void CSimpSvrApp::ParseCmdLine(LPSTR lpCmdLine)
00659 {
00660         char szTemp[255];
00661
00662         m_fStartByOle = TRUE;
00663
00664         ::ParseCmdLine (lpCmdLine, &m_fStartByOle, szTemp);
00665 }
00666
00667 //**********************************************************************
00668 //
00669 // CSimpSvrApp::SetStatusText
00670 //
00671 // Purpose:
00672 //
00673 //      Blanks out the text in the status bar
00674 //
00675 //
00676 // Parameters:
00677 //
00678 //      None
00679 //
00680 // Return Value:
00681 //
00682 //      None
00683 //
00684 // Function Calls:
00685 //      Function                    Location
00686 //
00687 //      CSimpSvrDoc::SetStatusText  DOC.CPP
00688 //
00689 //
00690 // Comments:
00691 //
00692 //
00693 //********************************************************************
00694
00695 void CSimpSvrApp::SetStatusText()
00696 {
00697         CStabilize stabilize(this);
00698         m_lpDoc->SetStatusText();
00699 }
00700
00701
00702 //**********************************************************************
00703 //
00704 // CSimpSvrApp::IsInPlaceActive
00705 //
00706 // Purpose:
00707 //
00708 //      Safely determines from the app level if currently inplace active.
00709 //
00710 //
00711 // Parameters:
00712 //
00713 //      None
00714 //
00715 // Return Value:
00716 //
00717 //      TRUE    - Inplace active
00718 //      FALSE   - Not Inplace active
00719 //
00720 // Function Calls:
00721 //      Function                    Location
00722 //
00723 //      CSimpSvrDoc::GetObject      OBJ.H
00724 //      CSimpSvrObj:IsInPlaceActive OBJ.H
00725 //
00726 //
00727 // Comments:
00728 //
00729 //
00730 //********************************************************************
00731
00732 BOOL CSimpSvrApp::IsInPlaceActive()
00733 {
00734         CStabilize stabilize(this);
00735         BOOL retval = FALSE;
00736
00737         if (m_lpDoc)
00738                 if (m_lpDoc->GetObj())
00739                         retval = m_lpDoc->GetObj()->IsInPlaceActive();
00740
00741         return retval;
00742 }
00743
00744 //**********************************************************************
00745 //
00746 // CSimpSvrApp::ShowAppWnd
00747 //
00748 // Purpose:
00749 //
00750 //      Shows the Application Window
00751 //
00752 // Parameters:
00753 //
00754 //      int nCmdShow    - Window State
00755 //
00756 // Return Value:
00757 //
00758 //      None
00759 //
00760 // Function Calls:
00761 //      Function                        Location
00762 //
00763 //      ShowWindow                      Windows API
00764 //      UpdateWindow                    Windows API
00765 //      CoLockObjectExternal            OLE API
00766 //
00767 // Comments:
00768 //
00769 //********************************************************************
00770
00771 void CSimpSvrApp::ShowAppWnd(int nCmdShow)
00772 {
00773         CoLockObjectExternal(this, TRUE, FALSE);
00774         ShowWindow (m_hAppWnd, nCmdShow);
00775         UpdateWindow (m_hAppWnd);
00776 }
00777
00778 //**********************************************************************
00779 //
00780 // CSimpSvrApp::ShowAppWnd
00781 //
00782 // Purpose:
00783 //
00784 //      Hides the Application Window
00785 //
00786 // Parameters:
00787 //
00788 //      None
00789 //
00790 // Return Value:
00791 //
00792 //      None
00793 //
00794 // Function Calls:
00795 //      Function                        Location
00796 //
00797 //      ShowWindow                      Windows API
00798 //      CoLockObjectExternal            OLE API
00799 //
00800 // Comments:
00801 //
00802 //********************************************************************
00803
00804 void CSimpSvrApp::HideAppWnd()
00805 {
00806         CoLockObjectExternal(this, FALSE, TRUE);
00807         ShowWindow (m_hAppWnd, SW_HIDE);
00808 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DragImg/DragImg.Cpp Source File

  • WinUI
  • Shell
  • DragImg

DragImg.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          DragImg.cpp
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023 #include <windowsx.h>
00024 #include <shlobj.h>
00025 #include <strsafe.h>
00026 #define ARRAYSIZE(a)    (sizeof(a)/sizeof(a[0]))
00027 #include "resource.h"
00028 #include "DragSrc.h"
00029 #include "DataObj.h"
00030 #include "DropTgt.h"
00031 #include "Render.h"
00032
00033 /**************************************************************************
00034    function prototypes
00035 **************************************************************************/
00036
00037 BOOL InitApplication(HINSTANCE);
00038 BOOL InitInstance(HINSTANCE, int);
00039 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
00040 BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
00041 HWND CreateListView(HINSTANCE, HWND);
00042 void ResizeListView(HWND, HWND);
00043 BOOL InitListView(HWND);
00044 BOOL InsertListViewItems(HWND);
00045 LRESULT HandleNotify(HWND, LPARAM);
00046 void HandleDragDrop(HWND, BOOL);
00047 void SwitchView(HWND, DWORD);
00048
00049 /**************************************************************************
00050    global variables and definitions
00051 **************************************************************************/
00052
00053 TCHAR       g_szClassName[] = TEXT("DragImageClass");
00054 TCHAR       g_szTitle[] = TEXT("Drag Image Helper Sample Application");
00055 HINSTANCE   g_hInst;
00056 USHORT      g_cfFileContents = 0;
00057 USHORT      g_cfFileGroupDescriptor = 0;
00058 HWND        g_hwndMain;
00059 BOOL        g_fUseList;
00060
00061 #define ID_LISTVIEW  1000
00062
00063 /**************************************************************************
00064
00065    WinMain()
00066
00067 **************************************************************************/
00068
00069 int CALLBACK WinMain(   HINSTANCE hInstance,
00070                         HINSTANCE hPrevInstance,
00071                         LPSTR lpCmdLine,
00072                         int nCmdShow)
00073 {
00074 MSG   msg;
00075 INITCOMMONCONTROLSEX icc;
00076
00077 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
00078 icc.dwICC = ICC_LISTVIEW_CLASSES;
00079 InitCommonControlsEx(&icc);
00080
00081 g_hInst = hInstance;
00082
00083 if(OleInitialize(NULL) != S_OK)
00084    return FALSE;
00085
00086 if(!InitApplication(hInstance))
00087    return FALSE;
00088
00089 if(!InitInstance(hInstance, nCmdShow))
00090    return FALSE;
00091
00092 while(GetMessage(&msg, NULL,0, 0))
00093    {
00094    TranslateMessage(&msg);
00095    DispatchMessage(&msg);
00096    }
00097
00098 OleUninitialize();
00099
00100 return (int)msg.wParam;
00101 }
00102
00103 /**************************************************************************
00104
00105    InitApplication()
00106
00107 **************************************************************************/
00108
00109 BOOL InitApplication(HINSTANCE hInstance)
00110 {
00111 WNDCLASS  wc;
00112
00113 wc.style         = CS_HREDRAW | CS_VREDRAW;
00114 wc.lpfnWndProc   = (WNDPROC)MainWndProc;
00115 wc.cbClsExtra    = 0;
00116 wc.cbWndExtra    = 0;
00117 wc.hInstance     = hInstance;
00118 wc.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAINICON));
00119 wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00120 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
00121 wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MAINMENU);
00122 wc.lpszClassName = g_szClassName;
00123
00124 return(RegisterClass(&wc));
00125 }
00126
00127 /**************************************************************************
00128
00129    InitInstance()
00130
00131 **************************************************************************/
00132
00133 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00134 {
00135 HWND hWnd;
00136
00137 //get the ID for the File Group Descriptor clipboard format
00138 g_cfFileGroupDescriptor = (USHORT) RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
00139
00140 //get the ID for the File Contents clipboard format
00141 g_cfFileContents = (USHORT) RegisterClipboardFormat(CFSTR_FILECONTENTS);
00142
00143 // Create a main window for this application instance.
00144 hWnd = CreateWindow( g_szClassName,
00145                      g_szTitle,
00146                      WS_OVERLAPPEDWINDOW,
00147                      CW_USEDEFAULT,
00148                      CW_USEDEFAULT,
00149                      CW_USEDEFAULT,
00150                      CW_USEDEFAULT,
00151                      NULL,
00152                      NULL,
00153                      hInstance,
00154                      NULL);
00155
00156 // If window could not be created, return "failure"
00157 if(!hWnd)
00158    return FALSE;
00159
00160 ShowWindow(hWnd, nCmdShow);
00161 UpdateWindow(hWnd);
00162 return TRUE;
00163 }
00164
00165 /**************************************************************************
00166
00167    MainWndProc()
00168
00169 **************************************************************************/
00170
00171 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00172 {
00173 static HWND s_hwndList;
00174
00175 switch(uMsg)
00176    {
00177    case WM_CREATE:
00178       {
00179       g_hwndMain = hWnd;
00180
00181       CDropTarget *pDropTarget = new CDropTarget;
00182
00183       if(pDropTarget)
00184          RegisterDragDrop(hWnd, pDropTarget);
00185
00186       s_hwndList = CreateListView(g_hInst, hWnd);
00187       if(s_hwndList)
00188          InitListView(s_hwndList);
00189
00190       g_fUseList = TRUE;
00191       }
00192       break;
00193
00194    case WM_DESTROY:
00195       RevokeDragDrop(hWnd);
00196
00197       PostQuitMessage(0);
00198       break;
00199
00200    case WM_SIZE:
00201       ResizeListView(s_hwndList, hWnd);
00202       break;
00203
00204    case WM_SETFOCUS:
00205       SetFocus(s_hwndList);
00206       return 0;
00207
00208    case WM_INITMENUPOPUP:
00209       {
00210       DWORD dwStyle;
00211       UINT  uID;
00212
00213       CheckMenuRadioItem((HMENU)wParam, IDM_FROM_WINDOW, IDM_FROM_BITMAP, g_fUseList ? IDM_FROM_WINDOW : IDM_FROM_BITMAP, MF_BYCOMMAND);
00214
00215       dwStyle = GetWindowLong(s_hwndList, GWL_STYLE);
00216       switch(dwStyle & LVS_TYPEMASK)
00217          {
00218          default:
00219          case LVS_ICON:
00220             uID = IDM_LARGEICONS;
00221             break;
00222
00223          case LVS_SMALLICON:
00224             uID = IDM_SMALLICONS;
00225             break;
00226
00227          case LVS_LIST:
00228             uID = IDM_LIST;
00229             break;
00230
00231          case LVS_REPORT:
00232             uID = IDM_REPORT;
00233             break;
00234          }
00235       CheckMenuRadioItem((HMENU)wParam, IDM_LARGEICONS, IDM_REPORT, uID,  MF_BYCOMMAND | MF_CHECKED);
00236       }
00237       break;
00238
00239    case WM_COMMAND:
00240       switch(GET_WM_COMMAND_ID(wParam, lParam))
00241          {
00242          case IDM_FROM_WINDOW:
00243             g_fUseList = TRUE;
00244             break;
00245
00246          case IDM_FROM_BITMAP:
00247             g_fUseList = FALSE;
00248             break;
00249
00250          case IDM_LARGEICONS:
00251             SwitchView(s_hwndList, LVS_ICON);
00252             break;
00253
00254          case IDM_SMALLICONS:
00255             SwitchView(s_hwndList, LVS_SMALLICON);
00256             break;
00257
00258          case IDM_LIST:
00259             SwitchView(s_hwndList, LVS_LIST);
00260             break;
00261
00262          case IDM_REPORT:
00263             SwitchView(s_hwndList, LVS_REPORT);
00264             break;
00265
00266          case IDM_ABOUT:
00267             DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, (DLGPROC)AboutDlgProc);
00268             break;
00269
00270          case IDM_EXIT:
00271             DestroyWindow(hWnd);
00272             break;
00273          }
00274       break;
00275
00276    case WM_NOTIFY:
00277       return HandleNotify(hWnd, lParam);
00278
00279    default:
00280       break;
00281   }
00282
00283 return DefWindowProc(hWnd, uMsg, wParam, lParam);
00284 }
00285
00286 /**************************************************************************
00287
00288    AboutDlgProc()
00289
00290 **************************************************************************/
00291
00292 BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
00293 {
00294 switch(uMsg)
00295    {
00296    case WM_COMMAND:
00297       switch(GET_WM_COMMAND_ID(wParam, lParam))
00298          {
00299          case IDOK:
00300             EndDialog(hDlg, IDOK);
00301             break;
00302
00303          case IDCANCEL:
00304             EndDialog(hDlg, IDCANCEL);
00305          }
00306       break;
00307    }
00308
00309 return FALSE;
00310 }
00311
00312 /******************************************************************************
00313
00314    CreateListView
00315
00316 ******************************************************************************/
00317
00318 HWND CreateListView(HINSTANCE hInstance, HWND hwndParent)
00319 {
00320 DWORD       dwStyle;
00321 HWND        hwndListView;
00322 BOOL        bSuccess = TRUE;
00323
00324 dwStyle =   WS_TABSTOP |
00325             WS_CHILD |
00326             WS_BORDER |
00327             LVS_AUTOARRANGE |
00328             LVS_ICON |
00329             LVS_SHOWSELALWAYS |
00330             WS_VISIBLE;
00331
00332 hwndListView = CreateWindowEx(   WS_EX_CLIENTEDGE,
00333                                  WC_LISTVIEW,
00334                                  NULL,
00335                                  dwStyle,
00336                                  0,
00337                                  0,
00338                                  0,
00339                                  0,
00340                                  hwndParent,
00341                                  (HMENU)ID_LISTVIEW,
00342                                  g_hInst,
00343                                  NULL);
00344
00345 if(!hwndListView)
00346    return NULL;
00347
00348 return hwndListView;
00349 }
00350
00351 /******************************************************************************
00352
00353    ResizeListView
00354
00355 ******************************************************************************/
00356
00357 void ResizeListView(HWND hwndListView, HWND hwndParent)
00358 {
00359 RECT  rc;
00360
00361 GetClientRect(hwndParent, &rc);
00362
00363 MoveWindow( hwndListView,
00364             rc.left,
00365             rc.top,
00366             rc.right - rc.left,
00367             rc.bottom - rc.top,
00368             TRUE);
00369
00370 }
00371
00372 /******************************************************************************
00373
00374    InitListView
00375
00376 ******************************************************************************/
00377
00378 BOOL InitListView(HWND hwndListView)
00379 {
00380 LV_COLUMN   lvColumn;
00381 HIMAGELIST  himlSmall;
00382 HIMAGELIST  himlLarge;
00383
00384 //empty the list
00385 ListView_DeleteAllItems(hwndListView);
00386
00387 //initialize the columns
00388 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
00389 lvColumn.fmt = LVCFMT_LEFT;
00390 lvColumn.cx = 150;
00391 lvColumn.pszText = TEXT("Source File Name");
00392 ListView_InsertColumn(hwndListView, 0, &lvColumn);
00393
00394 //set the image lists
00395 himlSmall = ImageList_Create(16, 16, ILC_COLORDDB | ILC_MASK, 1, 0);
00396 himlLarge = ImageList_Create(32, 32, ILC_COLORDDB | ILC_MASK, 1, 0);
00397
00398 if (himlSmall && himlLarge)
00399    {
00400    HICON hIcon;
00401
00402    //set up the small image list
00403    hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAINICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
00404    ImageList_AddIcon(himlSmall, hIcon);
00405
00406    //set up the large image list
00407    hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_MAINICON));
00408    ImageList_AddIcon(himlLarge, hIcon);
00409
00410    ListView_SetImageList(hwndListView, himlSmall, LVSIL_SMALL);
00411    ListView_SetImageList(hwndListView, himlLarge, LVSIL_NORMAL);
00412    }
00413
00414 InsertListViewItems(hwndListView);
00415
00416 return TRUE;
00417 }
00418
00419 /******************************************************************************
00420
00421    InsertListViewItems
00422
00423 ******************************************************************************/
00424
00425 #define FILE_COUNT   10
00426
00427 BOOL InsertListViewItems(HWND hwndListView)
00428 {
00429 //empty the list
00430 ListView_DeleteAllItems(hwndListView);
00431
00432 UINT     i;
00433 LVITEM   lvItem;
00434
00435 for(i = 0; i < FILE_COUNT; i++)
00436    {
00437    TCHAR szName[MAX_PATH];
00438
00439    StringCchPrintf(szName, ARRAYSIZE(szName), TEXT("File%02d.txt"), i);
00440
00441    ZeroMemory(&lvItem, sizeof(lvItem));
00442    lvItem.iItem = i;
00443    lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
00444    lvItem.pszText = szName;
00445    lvItem.iImage = 0;
00446    ListView_InsertItem(hwndListView, &lvItem);
00447    }
00448
00449 return TRUE;
00450 }
00451
00452 /**************************************************************************
00453
00454    HandleNotify()
00455
00456 **************************************************************************/
00457
00458 LRESULT HandleNotify(HWND hWnd, LPARAM lParam)
00459 {
00460 LPNMHDR  lpnmh = (LPNMHDR)lParam;
00461 HWND     hwndList = GetDlgItem(hWnd, ID_LISTVIEW);
00462
00463 switch(lpnmh->code)
00464    {
00465    case LVN_BEGINDRAG:
00466       HandleDragDrop(hwndList, g_fUseList);
00467       return 0;
00468    }
00469
00470 return 0;
00471 }
00472
00473 /**************************************************************************
00474
00475    HandleDragDrop()
00476
00477 **************************************************************************/
00478
00479 void HandleDragDrop(HWND hwndList, BOOL fFromWindow)
00480 {
00481 DWORD       dwEffect;
00482 HRESULT     hr;
00483 CDragSource *pDropSource;
00484 CDataObject *pDataObject;
00485 int         nItems;
00486
00487 nItems = ListView_GetSelectedCount(hwndList);
00488 if(!nItems)
00489    return;
00490
00491 pDropSource = new CDragSource;
00492 if(pDropSource)
00493    {
00494    pDataObject = new CDataObject;
00495    if(pDataObject)
00496       {
00497       FORMATETC   fe;
00498       STGMEDIUM   sm;
00499       int         i,
00500                   nStart;
00501       int         *anItems;
00502       DWORD       dwChars;
00503
00504       //get the indexes of the selected items
00505       anItems = new int[nItems];
00506       for(i = 0, nStart = -1; i < nItems; i++)
00507          {
00508          nStart = anItems[i] = ListView_GetNextItem(hwndList, nStart, LVNI_SELECTED);
00509          }
00510
00511       //get the length of the text for each selected item
00512       for(i = 0, dwChars = 0; i < nItems; i++)
00513          {
00514          TCHAR szText[MAX_PATH] = TEXT("");
00515
00516          ListView_GetItemText(hwndList, anItems[i], 0, szText, MAX_PATH);
00517
00518          dwChars += lstrlen(szText) + 1;
00519          }
00520
00521       //add one for the double-NULL terminator
00522       dwChars += 1;
00523
00524       LPTSTR pszFiles = new TCHAR[dwChars];
00525       LPTSTR pszThis;
00526
00527       //get the text for each selected item
00528       for(i = 0, pszThis = pszFiles; i < nItems; i++)
00529          {
00530          ListView_GetItemText(hwndList, anItems[i], 0, pszThis, dwChars - (DWORD)(pszThis - pszFiles));
00531
00532          pszThis += lstrlen(pszThis) + 1;
00533          }
00534
00535       //double NULL terminate the list
00536       *pszThis = 0;
00537
00538       //initialize the data object
00539       fe.cfFormat = g_cfFileGroupDescriptor;
00540       fe.ptd = NULL;
00541       fe.dwAspect = DVASPECT_CONTENT;
00542       fe.lindex = -1;
00543       fe.tymed = TYMED_HGLOBAL;
00544
00545       sm.tymed = TYMED_HGLOBAL;
00546       sm.pUnkForRelease = NULL;
00547       sm.hGlobal = CreateFileGroupDescriptor(pszFiles);
00548
00549       pDataObject->SetData(&fe, &sm, TRUE);
00550
00551       fe.cfFormat = g_cfFileContents;
00552       fe.ptd = NULL;
00553       fe.dwAspect = DVASPECT_CONTENT;
00554       fe.tymed = TYMED_HGLOBAL;
00555
00556       sm.tymed = TYMED_HGLOBAL;
00557       sm.pUnkForRelease = NULL;
00558
00559       for(i = 0; i < nItems; i++)
00560          {
00561          fe.lindex = i;
00562          sm.hGlobal = CreateFileContents(pszFiles, i);
00563
00564          pDataObject->SetData(&fe, &sm, TRUE);
00565          }
00566
00567       IDragSourceHelper *pDragSourceHelper = NULL;
00568
00569       CoCreateInstance( CLSID_DragDropHelper,
00570                         NULL,
00571                         CLSCTX_INPROC_SERVER,
00572                         IID_IDragSourceHelper,
00573                         (LPVOID*)&pDragSourceHelper);
00574
00575       if(pDragSourceHelper)
00576          {
00577          POINT pt;
00578
00579          pt.x = 0;
00580          pt.y = 0;
00581
00582          GetCursorPos(&pt);
00583          ScreenToClient(hwndList, &pt);
00584
00585          if(fFromWindow)
00586             {
00587             /*
00588             The pt parameter appears to be ignored, or at least overridden by
00589             the window.
00590             */
00591             pDragSourceHelper->InitializeFromWindow(hwndList, &pt, pDataObject);
00592             }
00593          else
00594             {
00595             SHDRAGIMAGE di;
00596             HBITMAP     hbm;
00597             BITMAP      bm;
00598             RECT  rc;
00599
00600             hbm = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_DRAG_IMAGE));
00601
00602             GetObject(hbm, sizeof(bm), &bm);
00603
00604             di.sizeDragImage.cx = bm.bmWidth;
00605             di.sizeDragImage.cy = bm.bmHeight;
00606             di.hbmpDragImage = hbm;
00607             di.crColorKey = RGB(0, 0, 0); //transparent color
00608
00609             //get the offset for the cursor compared to the first selected item
00610             ListView_GetItemRect(hwndList, anItems[0], &rc, LVIR_SELECTBOUNDS);
00611             di.ptOffset.x = pt.x - rc.left;
00612             di.ptOffset.y = pt.y - rc.top;
00613
00614             pDragSourceHelper->InitializeFromBitmap(&di, pDataObject);
00615             }
00616          }
00617
00618       delete anItems;
00619       delete pszFiles;
00620
00621       // do the drag and drop
00622       hr = DoDragDrop(pDataObject, pDropSource, DROPEFFECT_COPY, &dwEffect);
00623
00624       if(pDragSourceHelper)
00625          {
00626          pDragSourceHelper->Release();
00627          }
00628
00629       pDataObject->Release();
00630       }
00631
00632    pDropSource->Release();
00633    }
00634 }
00635
00636 /**************************************************************************
00637
00638    SwitchView()
00639
00640 **************************************************************************/
00641
00642 void SwitchView(HWND hwndListView, DWORD dwView)
00643 {
00644 DWORD dwStyle = GetWindowLong(hwndListView, GWL_STYLE);
00645
00646 SetWindowLong(hwndListView, GWL_STYLE, (dwStyle & ~LVS_TYPEMASK) | dwView);
00647 ResizeListView(hwndListView, GetParent(hwndListView));
00648 }
00649
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl Member List

This is the complete list of members for CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl, including all inherited members.
Collection | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [private]
GetCacheUrl(out string url) | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [inline, private]
GetContentInformation(out IWMSContext contentinfo) | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [inline, private]
GetContentSize(out int sizeLow, out int sizeHigh) | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [inline, private]
GetOriginUrl(out string url) | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [inline, private]
IWMSCacheItemDescriptorImpl(IWMSCacheItemCollectionImpl collection, DataRow row) | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [inline]
Row | CacheProxySamplePlugin::IWMSCacheItemDescriptorImpl | [private]
Generated on Wed Nov 13 2024 16:58:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/Resource.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

Resource.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 //{{NO_DEPENDENCIES}}
00019 // Microsoft Developer Studio generated include file.
00020 // Used by DOServer.rc
00021 //
00022 #define IDI_MAINICON                    101
00023 #define IDR_COLOR_MENU                  102
00024 #define IDD_MAIN_DIALOG                 103
00025 #define IDD_COLOR_DIALOG                104
00026 #define IDM_RED                         1000
00027 #define IDM_GREEN                       1001
00028 #define IDM_BLUE                        1002
00029 #define IDC_REGISTER                    2000
00030 #define IDC_CREATE_FILE                 2001
00031 #define IDC_RED                         2001
00032 #define IDC_GREEN                       2002
00033 #define IDC_BLUE                        2003
00034
00035 // Next default values for new objects
00036 //
00037 #ifdef APSTUDIO_INVOKED
00038 #ifndef APSTUDIO_READONLY_SYMBOLS
00039 #define _APS_NEXT_RESOURCE_VALUE        105
00040 #define _APS_NEXT_COMMAND_VALUE         1003
00041 #define _APS_NEXT_CONTROL_VALUE         2004
00042 #define _APS_NEXT_SYMED_VALUE           101
00043 #endif
00044 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/CertPSam.Cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

CertPSam.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        certpsam.cpp
00007 //
00008 // Contents:    Cert Server Policy Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013
00014 #pragma hdrstop
00015
00016 #include "celibw2k.h"
00017 #include "policy.h"
00018 #include "module.h"
00019
00020 CComModule _Module;
00021
00022 BEGIN_OBJECT_MAP(ObjectMap)
00023     OBJECT_ENTRY(CLSID_CCertPolicySample, CCertPolicySample)
00024     OBJECT_ENTRY(CLSID_CCertManagePolicyModuleSample, CCertManagePolicyModuleSample)
00025 END_OBJECT_MAP()
00026
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // DLL Entry Point
00030
00031 extern "C"
00032 BOOL WINAPI
00033 DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00034 {
00035     switch (dwReason)
00036     {
00037   case DLL_PROCESS_ATTACH:
00038       _Module.Init(ObjectMap, hInstance);
00039       DisableThreadLibraryCalls(hInstance);
00040       break;
00041
00042         case DLL_PROCESS_DETACH:
00043       _Module.Term();
00044             break;
00045     }
00046     return(TRUE);    // ok
00047 }
00048
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 // Used to determine whether the DLL can be unloaded by OLE
00052
00053 STDAPI
00054 DllCanUnloadNow(void)
00055 {
00056     return(_Module.GetLockCount() == 0? S_OK : S_FALSE);
00057 }
00058
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // Returns a class factory to create an object of the requested type
00062
00063 STDAPI
00064 DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00065 {
00066     return(_Module.GetClassObject(rclsid, riid, ppv));
00067 }
00068
00069
00070 /////////////////////////////////////////////////////////////////////////////
00071 // DllRegisterServer - Adds entries to the system registry
00072
00073 STDAPI
00074 DllRegisterServer(void)
00075 {
00076     // registers object, typelib and all interfaces in typelib
00077     return(_Module.RegisterServer(TRUE));
00078 }
00079
00080
00081 /////////////////////////////////////////////////////////////////////////////
00082 // DllUnregisterServer - Removes entries from the system registry
00083
00084 STDAPI
00085 DllUnregisterServer(void)
00086 {
00087     _Module.UnregisterServer();
00088     return(S_OK);
00089 }
00090
00091
00092 void __RPC_FAR *__RPC_USER
00093 MIDL_user_allocate(size_t cb)
00094 {
00095     return(LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, cb));
00096 }
00097
00098
00099 void __RPC_USER
00100 MIDL_user_free(void __RPC_FAR *pb)
00101 {
00102     LocalFree(pb);
00103 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/tracemacro.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

tracemacro.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "TraceMacro.h"
00017 #include <StdIo.h>             // Needed for sprintf on Win98
00018
00019
00020 //---------------------------------------------------------------------------
00021 //  Function implementations
00022 //
00023 //---------------------------------------------------------------------------
00024 //  Provides trace output for HRESULTs in hex.
00025 //
00026 VOID Trace_HR
00027 (
00028   LPCTSTR pszClass,        //[in] Class name for message
00029   LPCTSTR pszFunction,     //[in] Function name for message
00030   HRESULT hr               //[in] HRESULT to display as a value
00031 )
00032 {
00033 #ifdef _DEBUG
00034
00035   TCHAR  szBuffer[512];
00036   TCHAR  szFormat[] = _T("%s::%s-> Returned 0x%X\n");
00037   INT    nChars     = 0;
00038
00039   nChars = _stprintf( szBuffer, szFormat, pszClass, pszFunction, hr );
00040   _ASSERTE( nChars < sizeof(szBuffer) );
00041
00042   OutputDebugString( szBuffer );
00043
00044 #endif
00045 } //end Trace_HR()
00046
00047
00048 //---------------------------------------------------------------------------
00049 //  Provides trace output for user defined numeric values in the form:
00050 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00051 //
00052 VOID Trace_Value
00053 (
00054   LPCTSTR pszClass,        //[in] Class name for message
00055   LPCTSTR pszFunction,     //[in] Function name for message
00056   LPCTSTR pszValueName,    //[in] Value name for message
00057   LONG    nValue           //[in] Numeric value for message
00058 )
00059 {
00060 #ifdef _DEBUG
00061
00062   TCHAR  szBuffer[512];
00063   TCHAR  szFormat[] = _T("%s::%s-> %s = %u\n");
00064   INT    nChars     = 0;
00065
00066   nChars = _stprintf( szBuffer,
00067                       szFormat,
00068                       pszClass,
00069                       pszFunction,
00070                       pszValueName,
00071                       nValue
00072                     );
00073   _ASSERTE( nChars < sizeof(szBuffer) );
00074
00075   OutputDebugString( szBuffer );
00076
00077 #endif
00078 } //end Trace_Value()
00079
00080
00081 //---------------------------------------------------------------------------
00082 //  Provides trace output which shows the class name, function name, and
00083 //  a string which maps to an MMC notification.
00084 //
00085 VOID Trace_Event
00086 (
00087   LPCTSTR pszClass,        //[in] Class name for message
00088   LPCTSTR pszFunction,     //[in] Event name for message
00089   LONG    nEvent           //[in] Event code to map to string
00090 )
00091 {
00092 #ifdef _DEBUG
00093
00094   TCHAR  szEventStr[22];
00095   TCHAR  szBuffer[512];
00096   TCHAR  szFormat[] = _T("%s::%s-> Event = %s\n");
00097   INT    nChars     = 0;
00098
00099   MapEvent( nEvent, szEventStr );
00100
00101   nChars = _stprintf( szBuffer,
00102                       szFormat,
00103                       pszClass,
00104                       pszFunction,
00105                       szEventStr
00106                     );
00107   _ASSERTE( nChars < sizeof(szBuffer) );
00108
00109   OutputDebugString( szBuffer );
00110
00111 #endif
00112 } //end Trace_Event()
00113
00114 //---------------------------------------------------------------------------
00115 //  Provides trace output which shows the class name and function name
00116 //
00117 VOID Trace_Start
00118 (
00119   LPCTSTR pszClass,        //[in] Class name for message
00120   LPCTSTR pszFunction      //[in] Event name for message
00121 )
00122 {
00123 #ifdef _DEBUG
00124
00125   TCHAR  szBuffer[512];
00126   TCHAR  szFormat[] = _T("%s::%s-> Started \n");
00127   INT    nChars     = 0;
00128
00129   nChars = _stprintf( szBuffer,
00130                       szFormat,
00131                       pszClass,
00132                       pszFunction
00133                     );
00134   _ASSERTE( nChars < sizeof(szBuffer) );
00135
00136   OutputDebugString( szBuffer );
00137
00138 #endif
00139 } //end Trace_Start()
00140
00141
00142
00143 //---------------------------------------------------------------------------
00144 // Provides human readable output for notifications
00145 //
00146 VOID MapEvent( LONG Event, LPTSTR szEventStr )
00147 {
00148 #ifdef _DEBUG
00149
00150   switch( Event )
00151   {
00152     case 0x8001:
00153       _tcscpy( szEventStr, _T("MMCN_ACTIVATE       ") );
00154       break;
00155
00156     case 0x8002:
00157       _tcscpy( szEventStr, _T("MMCN_ADD_IMAGES     ") );
00158       break;
00159
00160     case 0x8003:
00161       _tcscpy( szEventStr, _T("MMCN_BTN_CLICK      ") );
00162       break;
00163
00164     case 0x8004:
00165       _tcscpy( szEventStr, _T("MMCN_CLICK          ") );
00166       break;
00167
00168     case 0x8005:
00169       _tcscpy( szEventStr, _T("MMCN_COLUMN_CLICK   ") );
00170       break;
00171
00172     case 0x8006:
00173       _tcscpy( szEventStr, _T("MMCN_CONTEXTMENU    ") );
00174       break;
00175
00176     case 0x8007:
00177       _tcscpy( szEventStr, _T("MMCN_CUTORMOVE      ") );
00178       break;
00179
00180     case 0x8008:
00181       _tcscpy( szEventStr, _T("MMCN_DBLCLICK       ") );
00182       break;
00183
00184     case 0x8009:
00185       _tcscpy( szEventStr, _T("MMCN_DELETE         ") );
00186       break;
00187
00188     case 0x800A:
00189       _tcscpy( szEventStr, _T("MMCN_DESELECT_ALL   ") );
00190       break;
00191
00192     case 0x800B:
00193       _tcscpy( szEventStr, _T("MMCN_EXPAND         ") );
00194       break;
00195
00196     case 0x800C:
00197       _tcscpy( szEventStr, _T("MMCN_HELP           ") );
00198       break;
00199
00200     case 0x800D:
00201       _tcscpy( szEventStr, _T("MMCN_MENU_BTNCLICK  ") );
00202       break;
00203
00204     case 0x800E:
00205       _tcscpy( szEventStr, _T("MMCN_MINIMIZED      ") );
00206       break;
00207
00208     case 0x800F:
00209       _tcscpy( szEventStr, _T("MMCN_PASTE          ") );
00210       break;
00211
00212     case 0x8010:
00213       _tcscpy( szEventStr, _T("MMCN_PROPERTY_CHANGE") );
00214       break;
00215
00216     case 0x8011:
00217       _tcscpy( szEventStr, _T("MMCN_QUERY_PASTE    ") );
00218       break;
00219
00220     case 0x8012:
00221       _tcscpy( szEventStr, _T("MMCN_REFRESH        ") );
00222       break;
00223
00224     case 0x8013:
00225       _tcscpy( szEventStr, _T("MMCN_REMOVE_CHILDREN") );
00226       break;
00227
00228     case 0x8014:
00229       _tcscpy( szEventStr, _T("MMCN_RENAME         ") );
00230       break;
00231
00232     case 0x8015:
00233       _tcscpy( szEventStr, _T("MMCN_SELECT         ") );
00234       break;
00235
00236     case 0x8016:
00237       _tcscpy( szEventStr, _T("MMCN_SHOW           ") );
00238       break;
00239
00240     case 0x8017:
00241       _tcscpy( szEventStr, _T("MMCN_VIEW_CHANGE    ") );
00242       break;
00243
00244     case 0x8018:
00245       _tcscpy( szEventStr, _T("MMCN_SNAPINHELP     ") );
00246       break;
00247
00248     case 0x8019:
00249       _tcscpy( szEventStr, _T("MMCN_CONTEXTHELP    ") );
00250       break;
00251
00252     case 0x801A:
00253       _tcscpy( szEventStr, _T("MMCN_INITOCX        ") );
00254       break;
00255
00256     case 0x8021:
00257       _tcscpy( szEventStr, _T("MMCN_EXPANDSYNC     ") );
00258       break;
00259
00260     default:
00261       _stprintf( szEventStr, _T("0x%X"), Event );
00262       break;
00263   }
00264
00265 #endif
00266 } //end MapEvent()
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Write/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Write
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__C9BCEED0_AFFD_11D2_9A74_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__C9BCEED0_AFFD_11D2_9A74_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__C9BCEED0_AFFD_11D2_9A74_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows.Net/certxsam.cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows.Net

certxsam.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        certxsam.cpp
00007 //
00008 // Contents:    Cert Server Exit Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013
00014 #pragma hdrstop
00015
00016 #include "celib.h"
00017 #include "exit.h"
00018 #include "module.h"
00019
00020 CComModule _Module;
00021
00022 BEGIN_OBJECT_MAP(ObjectMap)
00023     OBJECT_ENTRY(CLSID_CCertExitSample, CCertExitSample)
00024     OBJECT_ENTRY(CLSID_CCertManageExitModuleSample, CCertManageExitModuleSample)
00025 END_OBJECT_MAP()
00026
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // DLL Entry Point
00030
00031 extern "C"
00032 BOOL WINAPI
00033 DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00034 {
00035     switch (dwReason)
00036     {
00037   case DLL_PROCESS_ATTACH:
00038       _Module.Init(ObjectMap, hInstance);
00039       DisableThreadLibraryCalls(hInstance);
00040       break;
00041
00042         case DLL_PROCESS_DETACH:
00043       _Module.Term();
00044             break;
00045     }
00046     return(TRUE);    // ok
00047 }
00048
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 // Used to determine whether the DLL can be unloaded by OLE
00052
00053 STDAPI
00054 DllCanUnloadNow(void)
00055 {
00056     return(_Module.GetLockCount() == 0? S_OK : S_FALSE);
00057 }
00058
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // Returns a class factory to create an object of the requested type
00062
00063 STDAPI
00064 DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00065 {
00066     return(_Module.GetClassObject(rclsid, riid, ppv));
00067 }
00068
00069
00070 /////////////////////////////////////////////////////////////////////////////
00071 // DllRegisterServer - Adds entries to the system registry
00072
00073 STDAPI
00074 DllRegisterServer(void)
00075 {
00076     // registers object, typelib and all interfaces in typelib
00077     return(_Module.RegisterServer(TRUE));
00078 }
00079
00080
00081 /////////////////////////////////////////////////////////////////////////////
00082 // DllUnregisterServer - Removes entries from the system registry
00083
00084 STDAPI
00085 DllUnregisterServer(void)
00086 {
00087     _Module.UnregisterServer();
00088     return(S_OK);
00089 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoServe/Server.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoServe

Server.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.H
00003
00004   Summary:   Internal include file for the STOSERVE.DLL server code
00005              sample.  Contains class declarations, resource IDs and
00006              string macros for internal use in constructing this DLL
00007              as a COM component server.  Declares the CServer server
00008              control object class.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial STOSERVE.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   CServer.
00017
00018   Functions: .
00019
00020   Origin:    6-10-96: atrent - Editor-inheritance from SERVER.H in
00021                the CONSERVE Tutorial Code Sample.
00022
00023 ----------------------------------------------------------------------------
00024   This file is part of the Microsoft COM Tutorial Code Samples.
00025
00026   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00027
00028   This source code is intended only as a supplement to Microsoft
00029   Development Tools and/or on-line documentation.  See these other
00030   materials for detailed information regarding Microsoft code samples.
00031
00032   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00033   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00034   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00035   PARTICULAR PURPOSE.
00036 ==========================================================================+*/
00037
00038
00039 #if !defined(SERVER_H)
00040 #define SERVER_H
00041
00042 // Error-related String Identifiers.
00043 #define IDS_ASSERT_FAIL 2200
00044
00045
00046 #ifdef __cplusplus
00047
00048 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00049   Class:    CServer
00050
00051   Summary:  Class to encapsulate control of this COM server (eg, handle
00052             Lock and Object counting, encapsulate otherwise global data).
00053
00054   Methods:  none
00055 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00056 class CServer : public CThreaded
00057 {
00058   public:
00059     CServer(void);
00060     ~CServer(void);
00061
00062     // Methods for server lifetime control: object counts and lock counts.
00063     void Lock(void);
00064     void Unlock(void);
00065     void ObjectsUp(void);
00066     void ObjectsDown(void);
00067     HRESULT CanUnloadNow(void);
00068
00069     // A place to store the handle to loaded instance of this DLL module.
00070     HINSTANCE m_hDllInst;
00071
00072     // A place to store a client's parent window.
00073     HWND m_hWndParent;
00074
00075     // Global DLL Server living Object count.
00076     LONG m_cObjects;
00077
00078     // Global DLL Server Client Lock count.
00079     LONG m_cLocks;
00080 };
00081
00082 #endif // __cplusplus
00083
00084 // Allow other internal STOSERVE modules to get at the globals.
00085 extern CServer* g_pServer;
00086
00087
00088 #endif // SERVER_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/FileRepServer.idl Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

FileRepServer.idl

Go to the documentation of this file.
00001 import "wtypes.idl";
00002 [
00003     uuid(fe7f2eda-5da1-4041-928c-d2534d3fa128),
00004     pointer_default(unique),
00005     version(1.0)
00006 ]
00007
00008 interface FileRepServer {
00009
00010 // Declare the string data type. This should work for UNICODE.
00011 #ifdef _UNICODE
00012     typedef wchar_t CHAR_TYPE;
00013     typedef wchar_t * STR;
00014 #else
00015     typedef unsigned char CHAR_TYPE;
00016     typedef unsigned char * STR;
00017 #endif
00018
00019     typedef pipe CHAR CHAR_PIPE_TYPE;
00020
00021     // The size of the buffer returned with the RemoteOpen call.
00022     // It allows us to send back some data with the server reply for free:
00023     // since the TCP MTU size is at least 1500 bytes, we can make
00024     // use of the remaining bytes.
00025     const unsigned short PUSH_BUFSIZE = 10*1024;
00026
00027     // The size of the buffer returned with RemoteRead.  It is larger
00028     // due to being optimized for data transfer.
00029     const unsigned short PULL_BUFSIZE = 10*1024;
00030
00031     /*
00032       Opens a file with name that is sent on the in-direction of the pipe
00033       and sends back its contents via the out pipe.
00034     */
00035     void RemoteReadAsyncPipe([in] handle_t hFileRepServer,
00036            [in, ref, string] STR RemoteFileName,
00037                              [out] CHAR_PIPE_TYPE *PipeData);
00038 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/CrmFilesCompensator.Cpp Source File

  • Com
  • Services
  • Crm
  • CrmFiles

CrmFilesCompensator.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmFilesCompensator.cpp
00004
00005 Summary:
00006
00007   This is a sample Compensating Resource Manager (CRM) that creates and deletes files.
00008
00009   The CRM Worker provides an interface for creating or deleting files.
00010
00011   The CRM Compensator implements ICrmCompensator to receive transaction outcome notifications.
00012
00013   The CRM Compensator also implements ICrmFormatLogRecords to support monitoring.
00014
00015   This CRM can be installed in a server application or in a library application.
00016
00017   The CRM Worker requires a transaction. The CRM Compensator should not have a transaction.
00018
00019 Classes:
00020
00021   CCrmFilesCompensator
00022
00023 ----------------------------------------------------------------------------
00024
00025 This file is part of the Microsoft COM+ Samples.
00026
00027
00028
00029 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00030
00031
00032
00033 This source code is intended only as a supplement to Microsoft
00034
00035 Development Tools and/or on-line documentation. See these other
00036
00037 materials for detailed information regarding Microsoft code samples.
00038
00039
00040
00041 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00042
00043 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00044
00045 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00046
00047 PARTICULAR PURPOSE.
00048
00049 ==========================================================================+*/
00050 // CrmFilesCompensator.cpp : Implementation of CCrmFilesCompensator
00051
00052
00053 #include "stdafx.h"
00054 #include "CrmFiles.h"
00055 #include "CrmFilesCompensator.h"
00056
00057
00058 #pragma warning(disable: 4100)  // unreferenced formal parameter
00059 #pragma warning(disable: 4189)  // local variable is initialized but not referenced
00060
00061
00062 /////////////////////////////////////////////////////////////////////////////
00063 // CCrmFilesCompensator
00064
00065 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00066
00067 Method: CCrmFilesCompensator::SetLogControl()
00068
00069 Summary: Delivers an ICrmLogControl Interface to the CRM Compensator so that
00070      it can write further log records during transaction completion.
00071
00072 Returns: HRESULT
00073
00074 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00075
00076
00077 HRESULT CCrmFilesCompensator::SetLogControl(
00078     /* [in] */ ICrmLogControl __RPC_FAR *pLogControl)
00079 {
00080     m_pICrmLogControl = pLogControl;
00081
00082     _ASSERTE(m_pICrmLogControl);
00083
00084     return S_OK;
00085
00086 } // CCrmFilesCompensator::SetLogControl
00087
00088 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00089
00090 Method: CCrmFilesCompensator::BeginPrepare()
00091
00092 Summary: Notifies the CRM Compensator of the prepare phase of the transaction
00093      completion and that records are about to be delivered.
00094
00095 Returns: HRESULT
00096
00097 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00098
00099
00100 HRESULT CCrmFilesCompensator::BeginPrepare( void)
00101 {
00102     // do nothing
00103
00104     return S_OK;
00105
00106 } // CCrmFilesCompensator::BeginPrepare
00107
00108
00109 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00110
00111 Method: CCrmFilesCompensator::PrepareRecord()
00112
00113 Summary: Delivers a log record in forward order during the prepare phase.
00114
00115 Returns: HRESULT
00116
00117 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00118
00119
00120 HRESULT CCrmFilesCompensator::PrepareRecord(
00121     /* [in] */ CrmLogRecordRead crmLogRec,
00122     /* [retval][out] */ BOOL __RPC_FAR *pfForget)
00123 {
00124     _ASSERTE(pfForget);
00125
00126     *pfForget = FALSE;
00127
00128     // do nothing
00129
00130     return S_OK;
00131
00132 } // CCrmFilesCompensator::PrepareRecord
00133
00134
00135 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00136
00137 Method: CCrmFilesCompensator::EndPrepare()
00138
00139 Summary: Notifies the CRM Compensator that it has had all the log records
00140      available during the prepare phase.
00141
00142 Returns: HRESULT
00143
00144 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00145
00146
00147 HRESULT CCrmFilesCompensator::EndPrepare(
00148     /* [retval][out] */ BOOL __RPC_FAR *pfOkToPrepare)
00149 {
00150     // always vote yes
00151
00152     _ASSERTE(pfOkToPrepare);
00153
00154     *pfOkToPrepare = TRUE;
00155
00156     return S_OK;
00157
00158 } // CCrmFilesCompensator::EndPrepare
00159
00160
00161 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00162
00163 Method: CCrmFilesCompensator::BeginCommit()
00164
00165 Summary: Notifies the CRM Compensator of the commit phase of the transaction
00166      completion and that records are about to be delivered.
00167
00168 Returns: HRESULT
00169
00170 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00171
00172
00173 HRESULT CCrmFilesCompensator::BeginCommit(
00174     /* [in] */ BOOL fRecovery)
00175 {
00176     // do nothing
00177
00178     return S_OK;
00179
00180 } // CCrmFilesCompensator::BeginCommit
00181
00182
00183 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00184
00185 Method: CCrmFilesCompensator::CommitRecord()
00186
00187 Summary: Delivers a log record in forward order during the commit phase.
00188
00189 Returns: HRESULT
00190
00191 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00192
00193
00194 HRESULT CCrmFilesCompensator::CommitRecord(
00195     /* [in] */ CrmLogRecordRead crmLogRec,
00196     /* [retval][out] */ BOOL __RPC_FAR *pfForget)
00197 {
00198     _ASSERTE(pfForget);
00199
00200     *pfForget = FALSE;
00201
00202     HRESULT hr = S_OK;
00203
00204     hr = ProcessLogRecord(crmLogRec);
00205
00206     _ASSERTE(S_OK == hr);
00207
00208     if (ct_DeleteFile == m_CommandType)
00209     {
00210         // clean up temp file
00211
00212         BOOL fRc = DeleteFileW(m_wszTempFileName);
00213
00214         // NOTE: we do not care whether this succeeds or not... worst case we leave temp files around
00215     }
00216
00217     // no cleanup required for "create file"
00218
00219     // OPTIONAL - forget this record
00220
00221      *pfForget = TRUE;
00222
00223     // NOTE: this forget is not forced - could force on next record if required
00224
00225     return S_OK;
00226
00227 } // CCrmFilesCompensator::CommitRecord
00228
00229
00230 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00231
00232 Method: CCrmFilesCompensator::EndCommit()
00233
00234 Summary: Notifies the CRM Compensator that it has delivered all the log
00235      records available during the commit phase.
00236
00237 Returns: HRESULT
00238
00239 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00240
00241
00242 HRESULT CCrmFilesCompensator::EndCommit( void)
00243 {
00244     // do nothing
00245
00246     return S_OK;
00247
00248 } // CCrmFilesCompensator::EndCommit
00249
00250
00251 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00252
00253 Method: CCrmFilesCompensator::BeginAbort()
00254
00255 Summary: Notifies the CRM Compensator of the abort phase of the transaction
00256      completion, and that records are about to be delivered.
00257
00258 Returns: HRESULT
00259
00260 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00261
00262
00263 HRESULT CCrmFilesCompensator::BeginAbort(
00264     /* [in] */ BOOL fRecovery)
00265 {
00266     // do nothing
00267
00268     return S_OK;
00269
00270 } // CCrmFilesCompensator::BeginAbort
00271
00272
00273 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00274
00275 Method: CCrmFilesCompensator::AbortRecord()
00276
00277 Summary: Delivers a log record to the CRM Compensator during the abort phase.
00278
00279 Returns: HRESULT
00280
00281 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00282
00283
00284 HRESULT CCrmFilesCompensator::AbortRecord(
00285     /* [in] */ CrmLogRecordRead crmLogRec,
00286     /* [retval][out] */ BOOL __RPC_FAR *pfForget)
00287 {
00288     _ASSERTE(pfForget);
00289
00290     *pfForget = FALSE;
00291
00292     HRESULT hr = S_OK;
00293
00294     hr = ProcessLogRecord(crmLogRec);
00295
00296     _ASSERTE(S_OK == hr);
00297
00298     if (ct_DeleteFile == m_CommandType)
00299     {
00300         // put back the original file
00301
00302         // is it there already?
00303
00304         WIN32_FIND_DATAW FindFileData;
00305
00306         HANDLE hSearch = FindFirstFileW(
00307                                 m_wszSourceFileName,
00308                                 &FindFileData);
00309
00310         bool fSourceFileExists = (INVALID_HANDLE_VALUE != hSearch);
00311
00312         hSearch = FindFirstFileW(
00313                             m_wszTempFileName,
00314                             &FindFileData);
00315
00316         bool fTempFileExists = (INVALID_HANDLE_VALUE != hSearch);
00317
00318         if (!fSourceFileExists)
00319         {
00320             _ASSERTE(fTempFileExists);      // it had better exist, otherwise something is hosed
00321
00322             // was not found, so move (rename) the temp file back
00323
00324             DWORD dwFlags = MOVEFILE_WRITE_THROUGH;
00325
00326             BOOL fRc = MoveFileExW(
00327                             m_wszTempFileName,
00328                   m_wszSourceFileName,
00329                             dwFlags);
00330
00331             _ASSERTE(fRc);
00332
00333         }
00334
00335         // clean up temp file
00336
00337         BOOL fRc = DeleteFileW(m_wszTempFileName);
00338
00339         // NOTE: we do not care whether this succeeds or not... worst case we leave temp files around
00340
00341     }
00342
00343     else
00344     {
00345         _ASSERTE(ct_CreateFile == m_CommandType);
00346
00347         // delete the file we created
00348
00349         // does it exist?
00350
00351         WIN32_FIND_DATAW FindFileData;
00352
00353         HANDLE hSearch = FindFirstFileW(
00354                                 m_wszSourceFileName,
00355                                 &FindFileData);
00356
00357         if (INVALID_HANDLE_VALUE != hSearch)
00358         {
00359             // the file exists, so we must delete it
00360
00361             BOOL fRc = DeleteFileW(m_wszSourceFileName);
00362
00363             // IGNORE ERRORS
00364
00365             // allow for the case where we wrote the log record, but did not create the file
00366
00367         }
00368     }
00369
00370     // OPTIONAL - forget this record
00371
00372      *pfForget = TRUE;
00373
00374     // NOTE: this forget is not forced - could force on next record if required
00375
00376     return S_OK;
00377
00378 } // CCrmFilesCompensator::AbortRecord
00379
00380
00381 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00382
00383 Method: CCrmFilesCompensator::EndAbort()
00384
00385 Summary: Notifies the CRM Compensator that it has received all the log
00386      records available during the abort phase.
00387
00388 Returns: HRESULT
00389
00390 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00391
00392
00393 HRESULT CCrmFilesCompensator::EndAbort( void)
00394 {
00395     // do nothing
00396
00397     return S_OK;
00398
00399 } // CCrmFilesCompensator::EndAbort
00400
00401
00402 ///// ICrmFormatLogRecords
00403
00404 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00405
00406 Method: CCrmFilesCompensator::ProcessLogRecord(CrmLogRecordRead crmLogRec)
00407
00408 Summary: Process the raw log record into a form that is meaningful for this
00409      CRM Compensator
00410
00411 Returns: HRESULT
00412
00413 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00414
00415 HRESULT CCrmFilesCompensator::ProcessLogRecord(CrmLogRecordRead crmLogRec)
00416 {
00417     ZeroMemory(&m_wszSourceFileName, MAX_PATH * sizeof(WCHAR));
00418
00419     ZeroMemory(&m_wszTempFileName, MAX_PATH * sizeof(WCHAR));
00420
00421     // what kind of log record did we get?
00422
00423     // initially assume a "create file" log record
00424
00425     CrmFilesCreateFileLogRecord * pCreateFileRec = (CrmFilesCreateFileLogRecord *)crmLogRec.blobUserData.pBlobData;
00426
00427     m_CommandType = pCreateFileRec->CommandType;
00428
00429     if (ct_CreateFile == m_CommandType)
00430     {
00431         WCHAR * pName = (WCHAR *)(pCreateFileRec + 1);      // skip over header
00432
00433     _ASSERTE(pName != NULL);
00434         wcsncpy(m_wszSourceFileName, pName, pCreateFileRec->dwSourceSize);
00435     }
00436
00437     else
00438     {
00439         _ASSERTE(ct_DeleteFile == m_CommandType);
00440
00441         CrmFilesDeleteFileLogRecord * pDeleteFileRec = (CrmFilesDeleteFileLogRecord *)pCreateFileRec;
00442
00443         // get the source name
00444
00445         WCHAR * pName = (WCHAR *)(pDeleteFileRec + 1);      // skip over header
00446     _ASSERTE(pName != NULL);
00447         wcsncpy(m_wszSourceFileName, pName, pDeleteFileRec->dwSourceSize);
00448
00449         // get the temp name
00450
00451         pName += pDeleteFileRec->dwSourceSize;              // skip over source name
00452     _ASSERTE(pName != NULL);
00453         wcsncpy(m_wszTempFileName, pName, pDeleteFileRec->dwTempSize);
00454     }
00455
00456     return S_OK;
00457
00458 } // CCrmFilesCompensator::ProcessLogRecord
00459
00460
00461 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00462
00463 Method: CCrmFilesCompensator::GetColumnCount(long __RPC_FAR *plColumnCount)
00464
00465 Summary: The purpose of this interface is to format the log records in a
00466      viewable format. It can be used for monitoring
00467
00468 Returns: HRESULT, plColumnCount returns the max # of columns in the formatted
00469      record
00470
00471 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00472
00473
00474 HRESULT STDMETHODCALLTYPE CCrmFilesCompensator::GetColumnCount(
00475     /* [out] */ long __RPC_FAR *plColumnCount)
00476 {
00477   _ASSERTE(plColumnCount);
00478
00479   *plColumnCount = 3;
00480
00481   return S_OK;
00482
00483 } // CCrmFilesCompensator::GetColumnCount
00484
00485
00486 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00487
00488 Method: CCrmFilesCompensator::GetColumnHeaders(LPVARIANT pHeaders)
00489
00490 Summary: Return the column headers as an array of variants
00491
00492 Returns: HRESULT
00493
00494 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00495
00496
00497 HRESULT STDMETHODCALLTYPE CCrmFilesCompensator::GetColumnHeaders(
00498     /* [out] */ LPVARIANT pHeaders)
00499 {
00500   _ASSERTE(pHeaders);
00501
00502   _variant_t vCols[3] = { L"Command Type", L"Source File", L"Temp File" };
00503
00504   MakeVariantArray(3, vCols, pHeaders);
00505
00506   return S_OK;
00507
00508 } // CCrmFilesCompensator::GetColumnHeaders
00509
00510
00511 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00512
00513 Method: CCrmFilesCompensator::MakeVariantArray(
00514                   int       i_iNumVariants,
00515                   _variant_t    *i_vArray,
00516                   LPVARIANT   i_pVarSafeArray)
00517
00518 Summary: Create a variant array
00519
00520 Returns: HRESULT
00521
00522 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00523
00524
00525 void CCrmFilesCompensator::MakeVariantArray
00526 (
00527   int       i_iNumVariants,
00528   _variant_t    *i_vArray,
00529   LPVARIANT   i_pVarSafeArray
00530 )
00531 {
00532     SAFEARRAYBOUND sab;
00533
00534     sab.cElements = i_iNumVariants;
00535
00536     sab.lLbound = 1;                    // VB convention
00537
00538     SAFEARRAY * pSa;
00539
00540     pSa = SafeArrayCreate(VT_VARIANT, 1, &sab);
00541
00542     _ASSERTE(pSa);
00543
00544     VARIANT * pSaVars = NULL;
00545
00546     SafeArrayAccessData(pSa, (PVOID*)&pSaVars);
00547
00548     _ASSERTE(pSaVars);
00549
00550     // copy from the original array to the SafeArray
00551
00552   for (int i = 0; i < i_iNumVariants; i++)
00553   {
00554     // put them in the SafeArray
00555
00556     pSaVars[i] = i_vArray[i];
00557   }
00558
00559     // done filling the SafeArray, put it in a variant
00560
00561     SafeArrayUnaccessData(pSa);
00562
00563     _ASSERTE(i_pVarSafeArray);
00564
00565     i_pVarSafeArray->vt = VT_ARRAY | VT_VARIANT;      // array of variants
00566
00567     i_pVarSafeArray->parray = pSa;
00568
00569 } // CCrmFilesCompensator::MakeVariantArray
00570
00571
00572 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00573
00574 Method: CCrmFilesCompensator::GetColumn(
00575               [in]  CrmLogRecordRead CrmLogRec,
00576               [out] LPVARIANT pFormattedLogRecord)
00577
00578 Summary: Given the unformatted record, return a formatted record as an array
00579      of variants
00580
00581 Returns: HRESULT
00582
00583 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00584
00585
00586 HRESULT STDMETHODCALLTYPE CCrmFilesCompensator::GetColumn(
00587     /* [in] */ CrmLogRecordRead CrmLogRec,
00588     /* [out] */ LPVARIANT pFormattedLogRecord)
00589 {
00590   HRESULT hr = S_OK;
00591
00592     hr = ProcessLogRecord(CrmLogRec);
00593
00594   _ASSERTE(S_OK == hr);
00595
00596   _variant_t vFields[3];
00597
00598   if (ct_CreateFile == m_CommandType)
00599   {
00600     vFields[0] = L"CreateFile";
00601
00602     vFields[2] = L"<None>";
00603   }
00604   else
00605   {
00606     vFields[0] = L"DeleteFile";
00607
00608     vFields[2] = _variant_t(m_wszTempFileName);
00609   }
00610
00611   vFields[1] = _variant_t(m_wszSourceFileName);
00612
00613   MakeVariantArray(3, vFields, pFormattedLogRecord);
00614
00615   return S_OK;
00616
00617 } // CCrmFilesCompensator::GetColumn
00618
00619
00620 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00621
00622 Method: CCrmFilesCompensator::GetColumnVariants(
00623                   [in]  VARIANT LogRecord,
00624                 [out] LPVARIANT pFormattedLogRecord)
00625
00626 Summary: Return a single formatted record given the unformatted record as an
00627      array of variants
00628
00629
00630 Returns: HRESULT
00631
00632 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00633
00634
00635 HRESULT STDMETHODCALLTYPE CCrmFilesCompensator::GetColumnVariants(
00636     /* [in] */ VARIANT LogRecord,
00637     /* [out] */ LPVARIANT pFormattedLogRecord)
00638 {
00639   _ASSERTE(!"NOT IMPLEMENTED");
00640
00641   return E_FAIL;
00642
00643 } // CCrmFilesCompensator::GetColumnVariants
00644
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/helper.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

helper.h

Go to the documentation of this file.
00001
00002
00003 HRESULT  VariantToStringList(  VARIANT& refvar, CStringList& refstringlist);
00004 HRESULT StringListToVariant( VARIANT& refvar, const CStringList& refstringlist);
00005 void StringToStringList( CString s, CStringList &sList );
00006 void StringListToString( CStringList &sList, CString &s );
00007 void PopulateListBoxFromStringList( CListBox &list, CStringList &sList );
00008 void PopulateComboBoxFromStringList( CComboBox &list, CStringList &sList );
00009 void ADsToStringList(ADSVALUE *pValue, DWORD dwNumber, CStringList &sList );
00010 HRESULT  VariantToPtrList(  VARIANT& refvar, CPtrList & refptrlist);
00011 HRESULT PropertyValueToString( LONG lADsType, IADsPropertyValue *pValue, CString &sValue );
00012 CString GetErrorMessage( HRESULT hr );
00013 HRESULT ReportError( HRESULT hr );
00014 CString GetADSIError( HRESULT hr );
00015 HRESULT OctetVariantToString(  VARIANT& refvar, CString &sResult);
00016
00017
00018 #define RETURN_ON_FAILURE(hr) if (!SUCCEEDED(hr)) { ReportError(hr); return; }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cwinapp.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cwinapp.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CWINAPP.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CWINAPP_H_
00012 #define _CWINAPP_H_
00013
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019 #include "CDialogLite.h"  //CAppLite
00020 #include "Spy.h"      //CMallocSpy
00021
00022
00023 //////////////////////////////////////////////////////////////////////////
00024 // CWinApp
00025 //
00026 //////////////////////////////////////////////////////////////////////////
00027 class CWinApp : public CAppLite
00028 {
00029 public:
00030   CWinApp();
00031   virtual ~CWinApp();
00032
00033   //Overrides
00034   virtual BOOL  InitInstance();
00035   virtual int   ExitInstance();
00036
00037   //Helpers
00038
00039 //protected:
00040   //Data
00041   CMallocSpy*   m_pCMallocSpy;
00042 };
00043
00044
00045 #endif //_CWINAPP_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/devicenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

devicenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CDeviceNode class.  This node is a child of
00014 //                CStaticNode.  It represents a Virtual Storage device
00015 //
00016 //
00017
00018
00019 #ifndef _CLASS_CDEVICENODE_
00020 #define _CLASS_CDEVICENODE_
00021
00022 #include "Globals.h"
00023 #include "FolderNode.h"      // Folders are children of this node
00024 #include "LListImpl.h"
00025
00026
00027 class CComponentData;        // References
00028
00029 //---------------------------------------------------------------------------
00030 class CDeviceNode : public CBaseNode
00031 {
00032   public:
00033     CDeviceNode();
00034     virtual ~CDeviceNode();
00035
00036     HRESULT Initialize( NODE_PROPERTIES* pNodeProps );
00037     VOID    ToggleStatus();
00038
00039   // Virtual methods
00040   public:
00041     ULONG   GetNodeType() { return NODETYPE_DEVICE; };
00042     GUID&   GetNodeGUID() { return thisGUID; };
00043
00044     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00045     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00046     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00047
00048   // Property page methods
00049   public:
00050     HRESULT QueryForPropertyPage()
00051             { return E_NOTIMPL; }
00052
00053     HRESULT CreatePropertyPages( LPPROPERTYSHEETCALLBACK lpCallback, LONG_PTR Handle )
00054             { return E_NOTIMPL; }
00055
00056     HRESULT GetWatermarks( HBITMAP __RPC_FAR *lphWatermark,
00057                            HBITMAP __RPC_FAR *lphHeader,
00058                            HPALETTE __RPC_FAR *lphPalette,
00059                            BOOL __RPC_FAR *bStretch )
00060             { return E_NOTIMPL; }
00061
00062
00063   ///////////////////////////////////////////////////////////////////////////
00064   // Required Notification handlers
00065   //
00066   public:
00067     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00068     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00069     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00070     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00071     HRESULT OnContextHelp( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00072     HRESULT OnDelete( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00073             { return E_NOTIMPL; }
00074
00075   ///////////////////////////////////////////////////////////////////////////
00076   //  Context Menu methods
00077   //
00078   public:
00079     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00080     HRESULT Command( long lCommandID );
00081
00082
00083   ///////////////////////////////////////////////////////////////////////////
00084   // Private helpers
00085   private:
00086     HRESULT  DeleteChildItems( LPCONSOLENAMESPACE2 ipCNS2 );
00087     HRESULT  InsertChildItems( LPCONSOLENAMESPACE2 ipCNS2 );
00088     HRESULT  RefreshNodeList();
00089     VOID     RemoveNodes();
00090
00091
00092   private:
00093     static GUID  thisGUID;
00094     DWORD        m_dwAttributes;
00095     HSCOPEITEM   m_hParentNode;
00096     LPWSTR       m_wzStatus;
00097     BOOL         m_bOnlineStatus;
00098
00099     CLListImpl<CBaseNode*,CBaseNode*>  m_NodeList;
00100     CComponentData*                    m_pCompData;
00101
00102 };
00103
00104 #endif //_CLASS_CDEVICENODE_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ParametersVtbl Member List

This is the complete list of members for ParametersVtbl, including all inherited members.
c | ParametersVtbl
cNames | ParametersVtbl
dispIdMember | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Count)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *_NewEnum)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Refresh)(ADOParameters __RPC_FAR *This) | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Append)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Delete)(ADOParameters __RPC_FAR *This | ParametersVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Item)(ADOParameters __RPC_FAR *This | ParametersVtbl
Index | ParametersVtbl
iTInfo | ParametersVtbl
lcid | ParametersVtbl
lcid | ParametersVtbl
lcid | ParametersVtbl
Object | ParametersVtbl
pctinfo | ParametersVtbl
pDispParams | ParametersVtbl
pExcepInfo | ParametersVtbl
ppTInfo | ParametersVtbl
ppvObject | ParametersVtbl
ppvObject | ParametersVtbl
ppvObject | ParametersVtbl
puArgErr | ParametersVtbl
pVarResult | ParametersVtbl
rgDispId | ParametersVtbl
rgszNames | ParametersVtbl
riid | ParametersVtbl
riid | ParametersVtbl
riid | ParametersVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(ADOParameters __RPC_FAR *This) | ParametersVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(ADOParameters __RPC_FAR *This) | ParametersVtbl
wFlags | ParametersVtbl
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagLSTSLOT Member List

This is the complete list of members for tagLSTSLOT, including all inherited members.
cbCommitCurrent | tagLSTSLOT
cbCommitMax | tagLSTSLOT
cbExtra | tagLSTSLOT
cbPage | tagLSTSLOT
cbSlot | tagLSTSLOT
cbslotLeftOver | tagLSTSLOT
islotFirst | tagLSTSLOT
islotMax | tagLSTSLOT
islotMin | tagLSTSLOT
islotRov | tagLSTSLOT
pbitsSlot | tagLSTSLOT
rgslot | tagLSTSLOT
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/ADsPropertyList.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

ADsPropertyList.h

Go to the documentation of this file.
00001 #if !defined(AFX_ADSPROPERTYLIST_H__FA1B9781_0880_11D2_A3EA_0080C7D071BF__INCLUDED_)
00002 #define AFX_ADSPROPERTYLIST_H__FA1B9781_0880_11D2_A3EA_0080C7D071BF__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007 // ADsPropertyList.h : header file
00008 //
00009
00010 /////////////////////////////////////////////////////////////////////////////
00011 // CDlgIADsPropertyList dialog
00012
00013 class CDlgIADsPropertyList : public CDialog
00014 {
00015 // Construction
00016 public:
00017   CDlgIADsPropertyList( LPUNKNOWN pUnk, CWnd* pParent = NULL);   // standard constructor
00018   ~CDlgIADsPropertyList();
00019 // Dialog Data
00020   //{{AFX_DATA(CDlgIADsPropertyList)
00021   enum { IDD = IDD_PROPERTYLIST };
00022   CListBox  m_cValueList;
00023   CComboBox m_cADsType;
00024   CString m_sAttribute;
00025   //}}AFX_DATA
00026
00027
00028 // Overrides
00029   // ClassWizard generated virtual function overrides
00030   //{{AFX_VIRTUAL(CDlgIADsPropertyList)
00031   protected:
00032   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00033   //}}AFX_VIRTUAL
00034
00035 // Implementation
00036 protected:
00037   IADsPropertyList *m_pPropList;
00038
00039   // Generated message map functions
00040   //{{AFX_MSG(CDlgIADsPropertyList)
00041   virtual BOOL OnInitDialog();
00042   afx_msg void OnGet();
00043   afx_msg void OnPurge();
00044   //}}AFX_MSG
00045   DECLARE_MESSAGE_MAP()
00046 };
00047
00048 //{{AFX_INSERT_LOCATION}}
00049 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00050
00051 #endif // !defined(AFX_ADSPROPERTYLIST_H__FA1B9781_0880_11D2_A3EA_0080C7D071BF__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028 #include "Extend.h"
00029
00030 // our globals
00031 HINSTANCE g_hinst;
00032
00033 // list all nodes that are extendable here
00034 // List the GUID and then the description
00035 // terminate with a NULL, NULL set.
00036 NODESTRUCT g_Nodes[] = {
00037
00038     { 0xc094012c, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00039         _T("Snap-in Static Node")},
00040
00041     { 0x96713509, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} ,
00042         _T("People-powered Vehicles Scope Item")},
00043
00044     { 0x9671350a, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00045         _T("Bicyles Scope Item")},
00046
00047     { 0x9671350b, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} ,
00048         _T("Skate Boards Scope Item")},
00049
00050     { 0x9e3ff365, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} ,
00051         _T("Ice Skates Scope Item")},
00052
00053     { 0x9e3ff366, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00054         _T("Bicyle Result Item")},
00055
00056     { 0xa6707e01, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00057         _T("Skateboard Result Item")},
00058
00059     { 0xa6707e02, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} ,
00060         _T("IceSkate Result Item")},
00061
00062     {  0x8512760b, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00063         _T("Land-based Vehicles Scope Item")},
00064
00065     { 0xb17867b9, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00066         _T("Sky-based Vehicles Scope Item")},
00067
00068     { 0xb95e11f4, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9},
00069         _T("Future Vehicles Scope Item")},
00070
00071     {  0xb95e11f5, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} ,
00072         _T("Rocket Result Item")},
00073
00074     {NULL, NULL}
00075 };
00076
00077
00078
00079 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00080                     DWORD fdwReason,
00081                     void* lpvReserved)
00082 {
00083
00084     if (fdwReason == DLL_PROCESS_ATTACH) {
00085         g_hinst = hinstDLL;
00086     }
00087
00088     return TRUE;
00089 }
00090
00091
00092 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00093 {
00094     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00095         return CLASS_E_CLASSNOTAVAILABLE;
00096
00097
00098     if (!ppvObj)
00099         return E_FAIL;
00100
00101     *ppvObj = NULL;
00102
00103     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00104     // if they ask for anything else.
00105     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00106         return E_NOINTERFACE;
00107
00108     CClassFactory *pFactory = NULL;
00109
00110     // make the factory passing in the creation function for the type of object they want
00111     if (rclsid == CLSID_CComponentData)
00112         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00113     else if (rclsid == CLSID_CSnapinAbout)
00114         pFactory = new CClassFactory(CClassFactory::ABOUT);
00115
00116     if (NULL == pFactory)
00117         return E_OUTOFMEMORY;
00118
00119     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00120
00121     return hr;
00122 }
00123
00124 STDAPI DllCanUnloadNow(void)
00125 {
00126     if (g_uObjects == 0 && g_uSrvLock == 0)
00127         return S_OK;
00128     else
00129         return S_FALSE;
00130 }
00131
00132
00133 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00134 : m_cref(0), m_factoryType(factoryType)
00135 {
00136     OBJECT_CREATED
00137 }
00138
00139 CClassFactory::~CClassFactory()
00140 {
00141     OBJECT_DESTROYED
00142 }
00143
00144 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00145 {
00146     if (!ppv)
00147         return E_FAIL;
00148
00149     *ppv = NULL;
00150
00151     if (IsEqualIID(riid, IID_IUnknown))
00152         *ppv = static_cast<IClassFactory *>(this);
00153     else
00154         if (IsEqualIID(riid, IID_IClassFactory))
00155             *ppv = static_cast<IClassFactory *>(this);
00156
00157         if (*ppv)
00158         {
00159             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00160             return S_OK;
00161         }
00162
00163         return E_NOINTERFACE;
00164 }
00165
00166 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00167 {
00168     return InterlockedIncrement((LONG *)&m_cref);
00169 }
00170
00171 STDMETHODIMP_(ULONG) CClassFactory::Release()
00172 {
00173     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00174     {
00175         delete this;
00176         return 0;
00177     }
00178     return m_cref;
00179 }
00180
00181 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00182 {
00183     HRESULT  hr;
00184     void* pObj;
00185
00186     if (!ppvObj)
00187         return E_FAIL;
00188
00189     *ppvObj = NULL;
00190
00191     // Our object does does not support aggregation, so we need to
00192     // fail if they ask us to do aggregation.
00193     if (pUnkOuter)
00194         return CLASS_E_NOAGGREGATION;
00195
00196     if (COMPONENT == m_factoryType) {
00197         pObj = new CComponentData();
00198     } else {
00199         pObj = new CSnapinAbout();
00200     }
00201
00202     if (!pObj)
00203         return E_OUTOFMEMORY;
00204
00205     // QueryInterface will do the AddRef() for us, so we do not
00206     // do it in this function
00207     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00208
00209     if (FAILED(hr))
00210         delete pObj;
00211
00212     return hr;
00213 }
00214
00215 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00216 {
00217     if (fLock)
00218         InterlockedIncrement((LONG *)&g_uSrvLock);
00219     else
00220         InterlockedDecrement((LONG *)&g_uSrvLock);
00221
00222     return S_OK;
00223 }
00224
00225 //////////////////////////////////////////////////////////
00226 //
00227 // Exported functions
00228 //
00229
00230
00231 //
00232 // Server registration
00233 //
00234 STDAPI DllRegisterServer()
00235 {
00236     HRESULT hr = SELFREG_E_CLASS;
00237     _TCHAR szName[256];
00238     _TCHAR szSnapInName[256];
00239
00240     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00241     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00242
00243     _TCHAR szAboutName[256];
00244
00245     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00246
00247     // register our CoClasses
00248     hr = RegisterServer(g_hinst,
00249         CLSID_CComponentData,
00250         szName);
00251
00252     if SUCCEEDED(hr)
00253         hr = RegisterServer(g_hinst,
00254         CLSID_CSnapinAbout,
00255         szAboutName);
00256
00257     // place the registry information for SnapIns
00258     if SUCCEEDED(hr)
00259         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout);
00260
00261     return hr;
00262 }
00263
00264
00265 STDAPI DllUnregisterServer()
00266 {
00267     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00268         return UnregisterSnapin(CLSID_CComponentData);
00269     else
00270         return E_FAIL;
00271 }
00272
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/inc/IsapiModule.h Source File

  • Web
  • iis
  • ISAPI_6.0
  • inc

IsapiModule.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiModule.h
00006
00007 Abstract:
00008
00009     Module functions for ISAPI tools library
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee), October 2002
00014
00015 --*/
00016
00017 #ifndef _isapimodule_h
00018 #define _isapimodule_h
00019
00020 VOID
00021 InitializeIsapiTools(
00022     CHAR *  szModuleName
00023     );
00024
00025 #endif _isapimodule_h
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CS4Dialog Member List

This is the complete list of members for CS4Dialog, including all inherited members.
CDialogBase(HWND hWnd, HINSTANCE hInst) | CDialogBase |
CS4Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy *pTableCopy) | CS4Dialog |
Destroy() | CDialogBase | [virtual]
Display() | CS4Dialog | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CS4Dialog | [static]
InitControls() | CS4Dialog | [virtual]
m_hInst | CDialogBase |
m_hWnd | CDialogBase |
m_pCTableCopy | CS4Dialog |
RefreshControls() | CS4Dialog | [virtual]
~CDialogBase() | CDialogBase | [virtual]
~CS4Dialog() | CS4Dialog | [virtual]
Generated on Wed Nov 13 2024 16:57:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Tbarext/registry.Cpp Source File

  • SysMgmt
  • MMC
  • Tbarext

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "Extend.h"
00026 #include "globals.h"
00027
00028 // list all of the nodes that we extend
00029
00030 EXTENDER_NODE _NodeExtensions[] = {
00031     {ToolBarExtension,
00032     {0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28}},
00033     {0x20e42dd2, 0x5ccf, 0x11d3, {0x91, 0x47, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9}},
00034     _T("Extension to the Vehicle Node Toolbar")},
00035
00036     {DummyExtension,
00037     NULL,
00038     NULL,
00039     NULL}
00040 };
00041
00042 ////////////////////////////////////////////////////////
00043 //
00044 // Internal helper functions prototypes
00045 //
00046
00047 // Set the given key and its value.
00048 BOOL setKeyAndValue(const _TCHAR* pszPath,
00049                     const _TCHAR* szSubkey,
00050                     const _TCHAR* szValue) ;
00051
00052 // Set the given key and its value in the MMC Snapin location
00053 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00054                           const _TCHAR* szSubkey,
00055                           const _TCHAR* szName,
00056                           const _TCHAR* szValue);
00057
00058 // Set the given valuename under the key to value
00059 BOOL setValue(const _TCHAR* szKey,
00060               const _TCHAR* szValueName,
00061               const _TCHAR* szValue);
00062
00063 // Delete szKeyChild and all of its descendents.
00064 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00065
00066 ////////////////////////////////////////////////////////
00067 //
00068 // Constants
00069 //
00070
00071 // Size of a CLSID as a string
00072 //const int CLSID_STRING_SIZE = 39 ;
00073
00074 /////////////////////////////////////////////////////////
00075 //
00076 // Public function implementation
00077 //
00078
00079 //
00080 // Register the component in the registry.
00081 //
00082 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00083                        const CLSID& clsid,         // Class ID
00084                        const _TCHAR* szFriendlyName)       //   IDs
00085 {
00086     // Get server location.
00087     _TCHAR szModule[512] ;
00088     DWORD dwResult =
00089         ::GetModuleFileName(hModule,
00090         szModule,
00091         sizeof(szModule)/sizeof(_TCHAR)) ;
00092
00093     assert(dwResult != 0) ;
00094
00095     // Get CLSID
00096     LPOLESTR wszCLSID = NULL ;
00097     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00098
00099     assert(SUCCEEDED(hr)) ;
00100
00101   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00102
00103     // Build the key CLSID\\{...}
00104     _TCHAR szKey[64] ;
00105     _tcscpy(szKey, _T("CLSID\\")) ;
00106   _tcscat(szKey, pszCLSID) ;
00107
00108     // Add the CLSID to the registry.
00109     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00110
00111     // Add the server filename subkey under the CLSID key.
00112     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00113
00114     // set the threading model
00115     _tcscat(szKey, _T("\\InprocServer32"));
00116     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00117
00118     // Free memory.
00119     CoTaskMemFree(wszCLSID) ;
00120
00121     return S_OK ;
00122 }
00123
00124 //
00125 // Remove the component from the registry.
00126 //
00127 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00128 {
00129     // Get CLSID
00130     LPOLESTR wszCLSID = NULL ;
00131     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00132
00133
00134     // Build the key CLSID\\{...}
00135     _TCHAR szKey[64] ;
00136     _tcscpy(szKey, _T("CLSID\\")) ;
00137
00138   MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00139   _tcscat(szKey, pszT) ;
00140
00141     // Delete the CLSID Key - CLSID\{...}
00142     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00143     assert((lResult == ERROR_SUCCESS) ||
00144          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00145
00146     // Free memory.
00147     CoTaskMemFree(wszCLSID) ;
00148
00149     return S_OK ;
00150 }
00151
00152 //
00153 // Register the snap-in in the registry.
00154 //
00155
00156 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00157                        const _TCHAR* szNameString,   // NameString
00158                        const CLSID& clsidAbout,   // Class Id for About Class
00159                        const BOOL fSupportExtensions)
00160 {
00161     // Get CLSID
00162     LPOLESTR wszCLSID = NULL ;
00163     LPOLESTR wszAboutCLSID = NULL;
00164     LPOLESTR wszExtendCLSID = NULL;
00165     LPOLESTR wszNodeCLSID = NULL;
00166     EXTENDER_NODE *pNodeExtension;
00167     _TCHAR szKeyBuf[1024] ;
00168     HKEY hKey;
00169
00170
00171     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00172
00173     if (IID_NULL != clsidAbout)
00174         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00175
00176   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00177   MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00178
00179
00180     // Add the CLSID to the registry.
00181     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00182     if (IID_NULL != clsidAbout)
00183         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00184
00185     if (fSupportExtensions) {
00186         // Build the key NodeType
00187         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00188
00189         _TCHAR szKey[64] ;
00190         _tcscpy(szKey, pszCLSID) ;
00191         _tcscat(szKey, _T("\\NodeTypes")) ;
00192         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00193     }
00194
00195     // register each of the node extensions
00196     for (pNodeExtension = &(_NodeExtensions[0]);*pNodeExtension->szDescription;pNodeExtension++)
00197     {
00198         hr = StringFromCLSID(pNodeExtension->guidNode, &wszExtendCLSID);
00199         MAKE_TSTRPTR_FROMWIDE(pszExtendCLSID, wszExtendCLSID);
00200         _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes\\"));
00201         _tcscat(szKeyBuf, pszExtendCLSID);
00202
00203         switch (pNodeExtension->eType) {
00204         case ToolBarExtension:
00205             _tcscat(szKeyBuf, _T("\\Extensions\\ToolBar"));
00206             break;
00207         default:
00208             break;
00209         }
00210
00211         // Create and open key and subkey.
00212         long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00213             szKeyBuf,
00214             0, NULL, REG_OPTION_NON_VOLATILE,
00215             KEY_ALL_ACCESS, NULL,
00216             &hKey, NULL) ;
00217
00218         if (lResult != ERROR_SUCCESS)
00219         {
00220             return FALSE ;
00221         }
00222
00223         hr = StringFromCLSID(pNodeExtension->guidExtension, &wszNodeCLSID);
00224         assert(SUCCEEDED(hr));
00225
00226         MAKE_TSTRPTR_FROMWIDE(pszNodeCLSID, wszNodeCLSID);
00227         // Set the Value.
00228         if (pNodeExtension->szDescription != NULL)
00229         {
00230             RegSetValueEx(hKey, pszNodeCLSID, 0, REG_SZ,
00231                 (BYTE *)pNodeExtension->szDescription,
00232                 (_tcslen(pNodeExtension->szDescription)+1)*sizeof(_TCHAR)) ;
00233         }
00234
00235         RegCloseKey(hKey) ;
00236
00237         CoTaskMemFree(wszExtendCLSID);
00238         CoTaskMemFree(wszNodeCLSID);
00239     }
00240
00241
00242     // Free memory.
00243     CoTaskMemFree(wszCLSID) ;
00244     if (IID_NULL != clsidAbout)
00245         CoTaskMemFree(wszAboutCLSID);
00246
00247     return S_OK ;
00248 }
00249
00250 //
00251 // Unregister the snap-in in the registry.
00252 //
00253 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00254 {
00255     _TCHAR szKeyBuf[1024];
00256     LPOLESTR wszCLSID = NULL;
00257
00258     // Get CLSID
00259     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00260   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00261
00262     // Load the buffer with the Snap-In Location
00263     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00264
00265     // Copy keyname into buffer.
00266     _tcscat(szKeyBuf, _T("\\"));
00267     _tcscat(szKeyBuf, pszCLSID);
00268
00269     // Delete the CLSID Key - CLSID\{...}
00270     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00271     assert((lResult == ERROR_SUCCESS) ||
00272          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00273
00274     // free the memory
00275     CoTaskMemFree(wszCLSID);
00276
00277     return S_OK;
00278 }
00279
00280 //
00281 // Delete a key and all of its descendents.
00282 //
00283 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00284                         const _TCHAR* lpszKeyChild)  // Key to delete
00285 {
00286     // Open the child.
00287     HKEY hKeyChild ;
00288     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00289         KEY_ALL_ACCESS, &hKeyChild) ;
00290     if (lRes != ERROR_SUCCESS)
00291     {
00292         return lRes ;
00293     }
00294
00295     // Enumerate all of the decendents of this child.
00296     FILETIME time ;
00297     _TCHAR szBuffer[256] ;
00298     DWORD dwSize = 256 ;
00299     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00300         NULL, NULL, &time) == S_OK)
00301     {
00302         // Delete the decendents of this child.
00303         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00304         if (lRes != ERROR_SUCCESS)
00305         {
00306             // Cleanup before exiting.
00307             RegCloseKey(hKeyChild) ;
00308             return lRes;
00309         }
00310         dwSize = 256 ;
00311     }
00312
00313     // Close the child.
00314     RegCloseKey(hKeyChild) ;
00315
00316     // Delete this child.
00317     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00318 }
00319
00320 //
00321 // Create a key and set its value.
00322 //   - This helper function was borrowed and modifed from
00323 //     Kraig Brockschmidt's book Inside OLE.
00324 //
00325 BOOL setKeyAndValue(const _TCHAR* szKey,
00326                     const _TCHAR* szSubkey,
00327                     const _TCHAR* szValue)
00328 {
00329     HKEY hKey;
00330     _TCHAR szKeyBuf[1024] ;
00331
00332     // Copy keyname into buffer.
00333     _tcscpy(szKeyBuf, szKey) ;
00334
00335     // Add subkey name to buffer.
00336     if (szSubkey != NULL)
00337     {
00338         _tcscat(szKeyBuf, _T("\\")) ;
00339         _tcscat(szKeyBuf, szSubkey ) ;
00340     }
00341
00342     // Create and open key and subkey.
00343     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00344         szKeyBuf,
00345         0, NULL, REG_OPTION_NON_VOLATILE,
00346         KEY_ALL_ACCESS, NULL,
00347         &hKey, NULL) ;
00348     if (lResult != ERROR_SUCCESS)
00349     {
00350         return FALSE ;
00351     }
00352
00353     // Set the Value.
00354     if (szValue != NULL)
00355     {
00356         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00357             (BYTE *)szValue,
00358             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00359     }
00360
00361     RegCloseKey(hKey) ;
00362     return TRUE ;
00363 }
00364
00365 //
00366 // Open a key value and set it
00367 //
00368 BOOL setValue(const _TCHAR* szKey,
00369               const _TCHAR* szValueName,
00370               const _TCHAR* szValue)
00371 {
00372     HKEY hKey;
00373     _TCHAR szKeyBuf[1024] ;
00374
00375     // Copy keyname into buffer.
00376     _tcscpy(szKeyBuf, szKey) ;
00377
00378     // Create and open key and subkey.
00379     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00380         szKeyBuf,
00381         0, NULL, REG_OPTION_NON_VOLATILE,
00382         KEY_ALL_ACCESS, NULL,
00383         &hKey, NULL) ;
00384     if (lResult != ERROR_SUCCESS)
00385     {
00386         return FALSE ;
00387     }
00388
00389     // Set the Value.
00390     if (szValue != NULL)
00391     {
00392         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00393             (BYTE *)szValue,
00394             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00395     }
00396
00397     RegCloseKey(hKey) ;
00398     return TRUE ;
00399 }
00400
00401 //
00402 // Create a key and set its value.
00403 //   - This helper function was borrowed and modifed from
00404 //     Kraig Brockschmidt's book Inside OLE.
00405 //
00406 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00407                           const _TCHAR* szSubkey,
00408                           const _TCHAR* szName,
00409                           const _TCHAR* szValue)
00410 {
00411     HKEY hKey;
00412     _TCHAR szKeyBuf[1024] ;
00413
00414     // Load the buffer with the Snap-In Location
00415     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00416
00417     // Copy keyname into buffer.
00418     _tcscat(szKeyBuf, _T("\\")) ;
00419     _tcscat(szKeyBuf, szKey) ;
00420
00421     // Add subkey name to buffer.
00422     if (szSubkey != NULL)
00423     {
00424         _tcscat(szKeyBuf, _T("\\")) ;
00425         _tcscat(szKeyBuf, szSubkey ) ;
00426     }
00427
00428     // Create and open key and subkey.
00429     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00430         szKeyBuf,
00431         0, NULL, REG_OPTION_NON_VOLATILE,
00432         KEY_ALL_ACCESS, NULL,
00433         &hKey, NULL) ;
00434     if (lResult != ERROR_SUCCESS)
00435     {
00436         return FALSE ;
00437     }
00438
00439     // Set the Value.
00440     if (szValue != NULL)
00441     {
00442         RegSetValueEx(hKey, szName, 0, REG_SZ,
00443             (BYTE *)szValue,
00444             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00445     }
00446
00447     RegCloseKey(hKey) ;
00448     return TRUE ;
00449 }
00450
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/stdafxx.cpp Source File

  • Dataaccess
  • rds
  • handler
  • vc

stdafxx.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:        StdAfxX.cpp
00004 //
00005 // Copyright:   Copyright (c) 1997-1999 Microsoft Corporation
00006 //
00007 // Contents:    source file that includes just the standard includes
00008 //
00009 // Comments:    stdafx.pch will be the pre-compiled header
00010 //              stdafx.obj will contain the pre-compiled type information
00011 //
00012 //-----------------------------------------------------------------------------
00013
00014 #include "stdafx.h"
00015
00016 #ifdef _ATL_STATIC_REGISTRY
00017 #include <statreg.h>
00018 #include <statreg.cpp>
00019 #endif
00020
00021 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/about.h Source File

  • SysMgmt
  • MMC
  • Complete

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/addvfiledlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

addvfiledlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddVFileDlg.h:   Header for the CAddVFileDlg class.  This is a
00014 //                   modeless dialog class used to add Virtual Files.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDVFILEDLG_
00019 #define _CLASS_ADDVFILEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddVFileDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddVFileDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddVFileDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDVFILEDLG_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ATTRIBUTES Member List

This is the complete list of members for ATTRIBUTES, including all inherited members.
attrid | ATTRIBUTES
dwFlags | ATTRIBUTES
varDefaultValue | ATTRIBUTES
varValue | ATTRIBUTES
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCascade Member List

This is the complete list of members for CCascade, including all inherited members.
CCascade() CCascade [inline]
Generated on Wed Nov 13 2024 16:55:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/Misc.c Source File

  • NetDS
  • WinSock
  • IpxChat

Misc.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   misc.c
00009 //
00010 //  PURPOSE:  Contains all helper functions "global" to the application.
00011 //
00012 //  FUNCTIONS:
00013 //    CenterWindow - Center one window over another.
00014 //    ReceiveInBox - Reads incoming socket data.
00015 //    SendOutBox   - Writes outgoing socket data.
00016 //    AtoH         - Converts ascii string to network order hex
00017 //    BtoH         - Converts ascii byte to hex
00018 //    CleanUp      - closes sockets and detaches winsock dll
00019 //    GetAddrString - Puts IPX address into <network>.<node>.<socket> string format
00020 //    HtoA          - Converts network order hex to ascii string
00021 //    HtoB          - Converts hex byte to asci string
00022 //
00023 //  COMMENTS:
00024 //
00025 //
00026 #include "globals.h"            // prototypes specific to this application
00027 #include <windows.h>            // required for all Windows applications
00028 #include <windowsx.h>
00029
00030
00031
00032 //
00033 //  FUNCTION: CenterWindow(HWND, HWND)
00034 //
00035 //  PURPOSE:  Center one window over another.
00036 //
00037 //  PARAMETERS:
00038 //    hwndChild - The handle of the window to be centered.
00039 //    hwndParent- The handle of the window to center on.
00040 //
00041 //  RETURN VALUE:
00042 //
00043 //    TRUE  - Success
00044 //    FALSE - Failure
00045 //
00046 //  COMMENTS:
00047 //
00048 //    Dialog boxes take on the screen position that they were designed
00049 //    at, which is not always appropriate. Centering the dialog over a
00050 //    particular window usually results in a better position.
00051 //
00052
00053 BOOL CenterWindow(HWND hwndChild, HWND hwndParent)
00054 {
00055     RECT    rcChild, rcParent;
00056     int     cxChild, cyChild, cxParent, cyParent;
00057     int     cxScreen, cyScreen, xNew, yNew;
00058     HDC     hdc;
00059
00060     // Get the Height and Width of the child window
00061     if(!GetWindowRect(hwndChild, &rcChild))
00062         return FALSE;
00063     cxChild = rcChild.right - rcChild.left;
00064     cyChild = rcChild.bottom - rcChild.top;
00065
00066     // Get the Height and Width of the parent window
00067     if(!GetWindowRect(hwndParent, &rcParent))
00068         return FALSE;
00069     cxParent = rcParent.right - rcParent.left;
00070     cyParent = rcParent.bottom - rcParent.top;
00071
00072     // Get the display limits
00073     if(NULL == (hdc = GetDC(hwndChild)))
00074         return FALSE;
00075     cxScreen = GetDeviceCaps(hdc, HORZRES);
00076     cyScreen = GetDeviceCaps(hdc, VERTRES);
00077     if(0 == ReleaseDC(hwndChild, hdc))
00078         return FALSE;
00079
00080     // Calculate new X position, then adjust for screen
00081     xNew = rcParent.left + ((cxParent - cxChild) / 2);
00082     if (xNew < 0)
00083     {
00084         xNew = 0;
00085     }
00086     else if ((xNew + cxChild) > cxScreen)
00087     {
00088         xNew = cxScreen - cxChild;
00089     }
00090
00091     // Calculate new Y position, then adjust for screen
00092     yNew = rcParent.top  + ((cyParent - cyChild) / 2);
00093     if (yNew < 0)
00094     {
00095         yNew = 0;
00096     }
00097     else if ((yNew + cyChild) > cyScreen)
00098     {
00099         yNew = cyScreen - cyChild;
00100     }
00101
00102     // Set it, and return
00103     return SetWindowPos(hwndChild,
00104                         NULL,
00105                         xNew, yNew,
00106                         0, 0,
00107                         SWP_NOSIZE | SWP_NOZORDER);
00108 }
00109
00110 //
00111 //  FUNCTION: ReceiveInBox(HWND, WPARAM, LPARAM, char *, int)
00112 //
00113 //  PURPOSE:  Reads incoming data from socket
00114 //
00115 //  PARAMETERS:
00116 //    hWnd      - Handle to current window
00117 //    uParam    - WPARAM (unused)
00118 //    lParam    - LPARAM contains event (FD_READ or FD_CLOSE).
00119 //    szRBuf    - Receive Buffer
00120 //    cRBufLen  - size of Receive Buffer
00121 //
00122 //  RETURN VALUE:
00123 //
00124 //    TRUE  - Data Read
00125 //    FALSE - If FD_CLOSE message
00126 //
00127 //  COMMENTS:
00128 //
00129 //    Called if socket has data OR if it is closed.  If closed post
00130 //    WM_DISCONNECTED message.  Else read data and make sure it is
00131 //    NULL terminated.
00132 //
00133
00134 BOOL ReceiveInBox(HWND hWnd, WPARAM uParam, LPARAM lParam, char * szRBuf, int cRBufLen)
00135 {
00136     char * pRBuf;     // temp buf pointer
00137     int cBytesRead;   // count of bytes actually read
00138
00139
00140     if (LOWORD(lParam) == FD_CLOSE)                   // Is this a FD_CLOSE event?
00141     {
00142         SendMessage(hWnd, MW_DISCONNECTED, 0, 0);     // Yes, post message
00143         return(FALSE);
00144     }
00145
00146     pRBuf = szRBuf;   // Set temp pointer
00147     cRBufLen--;       // Save room for null terminator
00148
00149     // read socket
00150     if((cBytesRead = recv(sock, pRBuf, cRBufLen, 0)) != SOCKET_ERROR)
00151         pRBuf += cBytesRead;    // Move temp pointer to end of buffer
00152
00153     *pRBuf = 0;   // Null terminate - if recv() failed, then prBuf will
00154                   // point to first byte of the buffer
00155
00156     return (TRUE);   // We've got a buffer to display
00157 }
00158
00159 //
00160 //  FUNCTION: SendOutBox(char *, int)
00161 //
00162 //  PURPOSE:  Reads incoming data from socket
00163 //
00164 //  PARAMETERS:
00165 //    szSBuf    - Send Buffer
00166 //    cSBufLen  - size of Send Buffer
00167 //
00168 //  COMMENTS:
00169 //
00170 //    Writes send buffer to socket -- repeats until all data is sent.
00171 //
00172
00173 void SendOutBox(char * szSBuf, int cSBufLen)
00174 {
00175     char * pSBuf;
00176     int cBytesSent;
00177
00178     pSBuf = szSBuf; // Set temp pointer
00179
00180     while((cBytesSent = send(sock,
00181                              pSBuf,
00182                              cSBufLen,
00183                              0)) != SOCKET_ERROR)
00184     {
00185         pSBuf += cBytesSent;
00186         cSBufLen -= cBytesSent;
00187         if(!cSBufLen) return;
00188     }
00189 }
00190
00191 //
00192 //  FUNCTION: AtoH(char *, char *, int)
00193 //
00194 //  PURPOSE:  Converts ascii string to network order hex
00195 //
00196 //  PARAMETERS:
00197 //    src    - pointer to input ascii string
00198 //    dest   - pointer to output hex
00199 //    destlen - size of dest
00200 //
00201 //  COMMENTS:
00202 //
00203 //    2 ascii bytes make a hex byte so must put 1st ascii byte of pair
00204 //    into upper nibble and 2nd ascii byte of pair into lower nibble.
00205 //
00206
00207 void AtoH(char * src, char * dest, int destlen)
00208 {
00209     char * srcptr;
00210
00211     srcptr = src;
00212
00213     while(destlen--)
00214     {
00215         *dest = BtoH(*srcptr++) << 4;    // Put 1st ascii byte in upper nibble.
00216         *dest++ += BtoH(*srcptr++);      // Add 2nd ascii byte to above.
00217     }
00218 }
00219
00220 //
00221 //  FUNCTION: BtoH(char *, char *, int)
00222 //
00223 //  PURPOSE:  Converts ascii byte to numeric
00224 //
00225 //  PARAMETERS:
00226 //    ch - ascii byte to convert
00227 //
00228 //  RETURNS:
00229 //    associated numeric value
00230 //
00231 //  COMMENTS:
00232 //
00233 //    Will convert any hex ascii digit to its numeric counterpart.
00234 //    Puts in 0xff if not a valid hex digit.
00235 //
00236
00237 unsigned char BtoH(char ch)
00238 {
00239     if (ch >= '0' && ch <= '9') return (ch - '0');        // Handle numerals
00240     if (ch >= 'A' && ch <= 'F') return (ch - 'A' + 0xA);  // Handle capitol hex digits
00241     if (ch >= 'a' && ch <= 'f') return (ch - 'a' + 0xA);  // Handle small hex digits
00242     return(255);
00243 }
00244
00245 //
00246 //  FUNCTION: CleanUp(void)
00247 //
00248 //  PURPOSE:  Protocol specific cleanup function
00249 //
00250 //  COMMENTS:
00251 //
00252 //    Deletes our two possible sockets (they might not exist which
00253 //    just means closesocket might return an error -- we don't care).
00254 //
00255
00256 void CleanUp(void)
00257 {
00258     if(INVALID_SOCKET != SrvSock)
00259     {
00260         closesocket(SrvSock);  // Close our server side socket
00261         SrvSock = INVALID_SOCKET;
00262     }
00263     if (INVALID_SOCKET != sock)
00264     {
00265         closesocket(sock);     // Close our connection specific socket
00266         sock = INVALID_SOCKET;
00267     }
00268     WSACleanup();          // Nix the DLL
00269 }
00270
00271 //
00272 //  FUNCTION: GetAddrString(PSOCKADDR_IPX, char *)
00273 //
00274 //  PURPOSE:  Converts IPX address to ascii string for displaying
00275 //
00276 //  PARAMETERS:
00277 //    pSAddr - pointer to socket address struc
00278 //    dest   - pointer to destination string
00279 //
00280 //  COMMENTS:
00281 //
00282 //    Address is in network order to use HtoA to convert to ascii.
00283 //
00284 //    Final format is
00285 //      <8 char network address>.<12 char node address>.<4 char sock address>
00286 //
00287
00288 void GetAddrString(PSOCKADDR_IPX pSAddr, char * dest)
00289 {
00290     char abuf[15];                                // temp buffer
00291     char * currptr;                               // temp destination pointer
00292     int saddrlen = sizeof(struct sockaddr_ipx);   // sizeof address struc
00293
00294     currptr = dest; // initialize destination pointer
00295
00296     HtoA((char *)&pSAddr->sa_netnum, abuf, 4);    // convert network number
00297     StringCchCopy(currptr,15,abuf);
00298     currptr += 8;
00299     StringCchCat(currptr,18,".");                   // don't forget seperator
00300     currptr++;
00301
00302     HtoA((char *)&pSAddr->sa_nodenum, abuf, 6);   // convert node number
00303     StringCchCat(currptr,18,abuf);
00304     currptr += 12;
00305     StringCchCat(currptr,18,".");                          // seperator
00306     currptr++;
00307
00308     HtoA((char *)&pSAddr->sa_socket, abuf, 2);    // convert socket number
00309     StringCchCat(currptr,18,abuf);
00310
00311 }
00312
00313 //
00314 //  FUNCTION: HtoA(char *, char *, int)
00315 //
00316 //  PURPOSE:  Converts network ordered hex to ascii string
00317 //
00318 //  PARAMETERS:
00319 //    src     - pointer to network ordered hex
00320 //    dest    - pointer to ascii string
00321 //    srclen  - size of hex number in bytes
00322 //
00323 //  COMMENTS:
00324 //
00325 //    1 byte hex = 2 bytes ascii so convert high order nibble with HtoB()
00326 //    then convert low order nibble. dest buffer better be 2*srclen + 1.
00327 //
00328
00329 void HtoA(char * src, char * dest, int srclen)
00330 {
00331     char * destptr; // temp pointers
00332     UCHAR * srcptr;
00333
00334     srcptr = (UCHAR *)src;
00335     destptr = dest;
00336
00337     while(srclen--)
00338     {
00339     *destptr++ = HtoB((UCHAR)(*srcptr >> 4));      // Convert high order nibble
00340     *destptr++ = HtoB((UCHAR)(*srcptr++ & 0x0F));  // Convert low order nibble
00341     }
00342     *destptr = 0;  // Null terminator
00343 }
00344
00345 //
00346 //  FUNCTION: HtoB(UCHAR)
00347 //
00348 //  PURPOSE:  Converts hex byte to ascii byte
00349 //
00350 //  PARAMETERS:
00351 //    ch - Hex byte
00352 //
00353 //  RETURNS:
00354 //    ascii byte
00355 //
00356 //  COMMENTS:
00357 //
00358 //    We actually only convert a nibble since 1 byte hex = 2 bytes ascii.
00359 //    So if ch > 0xf we just return 'X'.
00360 //
00361
00362 char HtoB(UCHAR ch)
00363 {
00364     if (ch <= 9) return ('0' + ch);             // handle decimal values
00365     if (ch <= 0xf) return ('A' + ch - 10);      // handle hexidecimal specific values
00366     return('X');                                // Someone screwed up
00367 }
00368
00369
00370 //---------------------------------------------------------------------------
00371 //
00372 // FUNCTION:    GetStringRes (int id INPUT ONLY)
00373 //
00374 // COMMENTS:    Load the resource string with the ID given, and return a
00375 //              pointer to it.  Notice that the buffer is common memory so
00376 //              the string must be used before this call is made a second time.
00377 //
00378 //---------------------------------------------------------------------------
00379
00380 LPTSTR GetStringRes (int id)
00381 {
00382   static TCHAR buffer[MAX_PATH];
00383
00384   buffer[0]=0;
00385   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
00386   return buffer;
00387 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/Eap/Resource.h Source File

  • NetDS
  • RRas
  • Eap

Resource.h

Go to the documentation of this file.
00001 #define IDC_STATIC                          (-1)
00002 #define IDR_EAPCFG                          1001
00003 #define IDD_DIALOG                          1002
00004 #define IDC_EDIT_NAME                       1003
00005 #define IDC_EDIT_PASSWD                     1004
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/Snd/Main.Cpp Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • Snd

Main.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 #include "stdafx.h"
00013 #include "..\QueueDef.h"
00014 #import "mqoa.tlb"      no_namespace      // MSMQ COM object
00015
00016 #ifdef _DEBUG
00017   #import "..\GraphObj\DebugU\GraphObj.dll" \
00018               no_namespace        // Point and Line object
00019 #else
00020   #import "..\GraphObj\ReleaseU\GraphObj.dll" \
00021               no_namespace        // Point and Line object
00022 #endif
00023
00024
00025
00026
00027 // Initialize OLE library
00028 struct InitOle  _init_InitOle_;
00029
00030 void main()
00031 {
00032     try {
00033
00034     // For these ActiveX components we need only smart interface pointer
00035     IMSMQQueueInfosPtr  pQueueInfos;
00036     IMSMQQueueInfoPtr pQueueInfo;
00037     IMSMQQueuePtr   pQueue;
00038     IUnknownPtr     pIUnknown;
00039
00040     // Instanciate the follwing ActiveX components
00041     IMSMQQueryPtr   pQuery(__uuidof(MSMQQuery));
00042     IMSMQMessagePtr   pMessage(__uuidof(MSMQMessage));
00043     ILinePtr      pLine(__uuidof(Line));
00044     IPointPtr     pPoint(__uuidof(Point));
00045
00046     int         n = 1;
00047     _variant_t      varQueueNameInit(STR_QUEUE_LABEL);
00048     VARIANT       varQueueName;
00049
00050     cout << "\n\nMSMQ IPersistStream Test\n";
00051     cout << "==========================\n\n";
00052
00053     varQueueName = varQueueNameInit.Detach();
00054
00055     // Find the queue
00056     pQueueInfos = pQuery->LookupQueue(&vtMissing, &vtMissing, &varQueueName);
00057     varQueueNameInit.Attach(varQueueName);
00058     pQueueInfos->Reset();
00059
00060     if ((pQueueInfo = pQueueInfos->Next()) == NULL) {
00061
00062       //  The queue was not found create it on the local system
00063       pQueueInfo = new IMSMQQueueInfoPtr( __uuidof(MSMQQueueInfo) );
00064       pQueueInfo->PathName = STR_QUEUE_NAME;
00065       pQueueInfo->Label = STR_QUEUE_LABEL;
00066       pQueueInfo->Create();
00067       cout << "\nNew Queue created\n";
00068     }
00069
00070     cout << "Which object should be send ?\n";
00071     cout << "1 - Point\n";
00072     cout << "2 - Line\n";
00073     cout << ":";
00074     cin >> n;
00075
00076
00077     // Open the queue
00078     pQueue = pQueueInfo->Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
00079
00080     if (n == 1) {
00081       // Initialize point object
00082       pPoint->x = 8;
00083       pPoint->y = 9;
00084       pMessage->Body = static_cast<IUnknown*>(pPoint); // The message body gets the IUnknown pointer
00085
00086     }
00087     else {
00088       // Initialize line object
00089       pLine->x1 = 1;
00090       pLine->y1 = 2;
00091       pLine->x2 = 3;
00092       pLine->y2 = 4;
00093       pMessage->Body = static_cast<IUnknown*>(pLine); // The message body gets the IUnknown pointer
00094     }
00095     cout << "Sending Object\n";
00096     pMessage->Send(pQueue);
00097
00098     // Close the Queue
00099     pQueue->Close();
00100
00101     } catch (_com_error& e) {
00102     dump_com_error(e);
00103     }
00104 }
00105
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/comp.Cpp Source File

  • SysMgmt
  • MMC
  • WMI

comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "DataObj.h"
00021 #include <commctrl.h>        // Needed for button styles...
00022 #include <crtdbg.h>
00023 #include "globals.h"
00024 #include "resource.h"
00025 #include "DeleBase.h"
00026 #include "CompData.h"
00027
00028 CComponent::CComponent(CComponentData *parent)
00029 : m_pComponentData(parent), m_cref(0), m_ipConsole(NULL)
00030 {
00031     OBJECT_CREATED
00032 }
00033
00034 CComponent::~CComponent()
00035 {
00036     OBJECT_DESTROYED
00037 }
00038
00039 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00040 {
00041     if (!ppv)
00042         return E_FAIL;
00043
00044     *ppv = NULL;
00045
00046     if (IsEqualIID(riid, IID_IUnknown))
00047         *ppv = static_cast<IComponent *>(this);
00048     else if (IsEqualIID(riid, IID_IComponent))
00049         *ppv = static_cast<IComponent *>(this);
00050
00051     // first things first, make sure that when MMC
00052     // asks if we do property sheets, that we actually
00053     // say "yes"
00054     else if (IsEqualIID(riid, IID_IExtendPropertySheet))
00055         *ppv = static_cast<IExtendPropertySheet2 *>(this);
00056     else if (IsEqualIID(riid, IID_IExtendPropertySheet2))
00057         *ppv = static_cast<IExtendPropertySheet2 *>(this);
00058
00059     if (*ppv)
00060     {
00061         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00062         return S_OK;
00063     }
00064
00065     return E_NOINTERFACE;
00066 }
00067
00068 STDMETHODIMP_(ULONG) CComponent::AddRef()
00069 {
00070     return InterlockedIncrement((LONG *)&m_cref);
00071 }
00072
00073 STDMETHODIMP_(ULONG) CComponent::Release()
00074 {
00075     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00076     {
00077         delete this;
00078         return 0;
00079     }
00080     return m_cref;
00081
00082 }
00083
00084 ///////////////////////////////
00085 // Interface IComponent
00086 ///////////////////////////////
00087 STDMETHODIMP CComponent::Initialize(
00088                                     /* [in] */ LPCONSOLE lpConsole)
00089 {
00090     HRESULT hr = S_OK;
00091
00092     // Save away all the interfaces we'll need.
00093     // Fail if we can't QI the required interfaces.
00094
00095     m_ipConsole = lpConsole;
00096     m_ipConsole->AddRef();
00097
00098     return hr;
00099 }
00100
00101 STDMETHODIMP CComponent::Notify(
00102                                 /* [in] */ LPDATAOBJECT lpDataObject,
00103                                 /* [in] */ MMC_NOTIFY_TYPE event,
00104                                 /* [in] */ LPARAM arg,
00105                                 /* [in] */ LPARAM param)
00106 {
00107         MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00108
00109     HRESULT hr = S_FALSE;
00110     CDelegationBase *base = NULL;
00111
00112     // we need to watch for property change and delegate it
00113     // a little differently, we're actually going to send
00114     // the CDelegationBase object pointer in the property page
00115     // PSN_APPLY handler via MMCPropPageNotify()
00116     if (MMCN_PROPERTY_CHANGE != event) {
00117         if (NULL == lpDataObject)
00118             return S_FALSE;
00119
00120         base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00121     } else {
00122         base = (CDelegationBase *)param;
00123     }
00124
00125     switch (event)      {
00126     case MMCN_SHOW:
00127         hr = base->OnShow(m_ipConsole, (BOOL)arg, (HSCOPEITEM)param);
00128         break;
00129
00130     case MMCN_ADD_IMAGES:
00131         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00132         break;
00133
00134     case MMCN_SELECT:
00135         hr = base->OnSelect(m_ipConsole, (BOOL)LOWORD(arg), (BOOL)HIWORD(arg));
00136         break;
00137
00138     case MMCN_RENAME:
00139         hr = base->OnRename((LPOLESTR)param);
00140         break;
00141
00142     // handle the property change notification if we need to do anything
00143     // special with it
00144     case MMCN_PROPERTY_CHANGE:
00145         hr = base->OnPropertyChange(m_ipConsole);
00146         break;
00147     }
00148
00149     return hr;
00150 }
00151
00152 STDMETHODIMP CComponent::Destroy(
00153                                  /* [in] */ MMC_COOKIE cookie)
00154 {
00155     if (m_ipConsole) {
00156         m_ipConsole->Release();
00157         m_ipConsole = NULL;
00158     }
00159
00160     return S_OK;
00161 }
00162
00163
00164 STDMETHODIMP CComponent::QueryDataObject(
00165                                          /* [in] */ MMC_COOKIE cookie,
00166                                          /* [in] */ DATA_OBJECT_TYPES type,
00167                                          /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00168 {
00169     CDataObject *pObj = NULL;
00170
00171     if (cookie == 0)
00172         pObj = new CDataObject((MMC_COOKIE)m_pComponentData->m_pStaticNode, type);
00173     else
00174         pObj = new CDataObject(cookie, type);
00175
00176     if (!pObj)
00177         return E_OUTOFMEMORY;
00178
00179     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00180
00181     return S_OK;
00182 }
00183
00184 STDMETHODIMP CComponent::GetResultViewType(
00185                                            /* [in] */ MMC_COOKIE cookie,
00186                                            /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00187                                            /* [out] */ long __RPC_FAR *pViewOptions)
00188 {
00189     CDelegationBase *base = (CDelegationBase *)cookie;
00190
00191     //
00192     // Ask for default listview.
00193     //
00194     if (base == NULL)
00195     {
00196         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00197         *ppViewType = NULL;
00198     }
00199     else
00200         return base->GetResultViewType(ppViewType, pViewOptions);
00201
00202     return S_OK;
00203 }
00204
00205 STDMETHODIMP CComponent::GetDisplayInfo(
00206                                         /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00207 {
00208     HRESULT hr = S_OK;
00209     CDelegationBase *base = NULL;
00210
00211     // if they are asking for the RDI_STR we have one of those to give
00212
00213     if (pResultDataItem->lParam) {
00214         base = (CDelegationBase *)pResultDataItem->lParam;
00215         if (pResultDataItem->mask & RDI_STR) {
00216                         LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00217                         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00218             pResultDataItem->str = pszW;
00219         }
00220
00221         if (pResultDataItem->mask & RDI_IMAGE) {
00222             pResultDataItem->nImage = base->GetBitmapIndex();
00223         }
00224     }
00225
00226     return hr;
00227 }
00228
00229
00230 STDMETHODIMP CComponent::CompareObjects(
00231                                         /* [in] */ LPDATAOBJECT lpDataObjectA,
00232                                         /* [in] */ LPDATAOBJECT lpDataObjectB)
00233 {
00234     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00235     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00236
00237     // compare the object pointers
00238     if (baseA->GetCookie() == baseB->GetCookie())
00239         return S_OK;
00240
00241     return S_FALSE;
00242 }
00243
00244 ///////////////////////////////////
00245 // Interface IExtendPropertySheet2
00246 ///////////////////////////////////
00247 HRESULT CComponent::CreatePropertyPages(
00248                                         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00249                                         /* [in] */ LONG_PTR handle,
00250                                         /* [in] */ LPDATAOBJECT lpIDataObject)
00251 {
00252     CDelegationBase *base = GetOurDataObject(lpIDataObject)->GetBaseNodeObject();
00253
00254     return base->CreatePropertyPages(lpProvider, handle);
00255 }
00256
00257 HRESULT CComponent::QueryPagesFor(
00258                                   /* [in] */ LPDATAOBJECT lpDataObject)
00259 {
00260     CDelegationBase *base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00261
00262     return base->HasPropertySheets();
00263 }
00264
00265 HRESULT CComponent::GetWatermarks(
00266                                   /* [in] */ LPDATAOBJECT lpIDataObject,
00267                                   /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00268                                   /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00269                                   /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00270                                   /* [out] */ BOOL __RPC_FAR *bStretch)
00271 {
00272     CDelegationBase *base = GetOurDataObject(lpIDataObject)->GetBaseNodeObject();
00273
00274     return base->GetWatermarks(lphWatermark, lphHeader, lphPalette, bStretch);
00275 }
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagStatus Member List

This is the complete list of members for _tagStatus, including all inherited members.
hwnd | _tagStatus
iGiveWidth | _tagStatus
iMaxWidth | _tagStatus
iMinWidth | _tagStatus
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/virtualfile.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

virtualfile.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Implements our virtual file class derived from CBaseNode.  This
00014 //             class will represent our result items
00015 //
00016
00017 #include <stdio.h>
00018 #include "VirtualFile.h"
00019 #include "Globals.h"
00020 #include "CompData.h"
00021 #include "Comp.h"
00022 #include "FolderNode.h"
00023 #include "Scripts.h"         // Supporting scripts in this node
00024
00025                              // Tracing stuff
00026 #include "TraceMacro.h"
00027 #undef  MODULESTRING
00028 #define MODULESTRING  _T("CVirtualFile")
00029
00030
00031 // Initialize our static GUID just once
00032 GUID CVirtualFile::thisGUID = CLSID_CVirtualFile;
00033
00034
00035 /////////////////////////////////////////////////////////////////////////////
00036 // Construction/Destruction
00037
00038 //---------------------------------------------------------------------------
00039 CVirtualFile::CVirtualFile()
00040 {
00041   m_RDI.mask      = DEFAULT_RDI_MASK;
00042   m_RDI.str       = MMC_CALLBACK;
00043   m_RDI.nImage    = IMG_DATA_FILE;
00044   m_RDI.lParam    = reinterpret_cast<LPARAM>(this);
00045
00046   m_dwAttributes  = 0;
00047   m_pParentFolder = NULL;
00048   m_pCompData     = NULL;
00049 }
00050
00051
00052 //---------------------------------------------------------------------------
00053 CVirtualFile::~CVirtualFile()
00054 {
00055 }
00056
00057
00058 //---------------------------------------------------------------------------
00059 HRESULT CVirtualFile::Initialize( NODE_PROPERTIES* pNodeProps )
00060 {
00061   _ASSERT( NULL != pNodeProps );
00062
00063   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00064   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00065   wcscpy( pszTmp, pNodeProps->szNodeName );
00066   if( NULL != m_pwszNodeName )
00067     CoTaskMemFree( m_pwszNodeName );
00068
00069   m_pwszNodeName  = pszTmp;
00070   m_pParentFolder = reinterpret_cast<CFolderNode*>(pNodeProps->pParentObject);
00071   m_pCompData     = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00072   m_dwAttributes  = pNodeProps->dwAttributes;
00073
00074   wcscpy( m_pDescripStr, L"VFile object created at " );
00075
00076   GetLocalTime( &m_InitTime );
00077   WCHAR  szTimeBuffer[32];
00078   swprintf( szTimeBuffer, L"%u:%u:%u ", m_InitTime.wHour, m_InitTime.wMinute, m_InitTime.wSecond );
00079   wcscat( m_pDescripStr, szTimeBuffer );
00080
00081   return S_OK;
00082 }
00083
00084
00085 /////////////////////////////////////////////////////////////////////////////
00086 // Implementation of virtual methods
00087
00088 //---------------------------------------------------------------------------
00089 HRESULT CVirtualFile::GetDisplayInfo
00090 (
00091   RESULTDATAITEM* pRDI       //[in-out] RESULTDATAITEM struct
00092 )
00093 {
00094   HRESULT hResult = S_OK;
00095
00096   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00097   {                                  // for each column
00098     switch( pRDI->nCol )
00099     {
00100       case 0:
00101         pRDI->str = m_pwszNodeName;
00102         break;
00103
00104       case 1:                        // Return attributes as a string
00105         pRDI->str = GetAttributeString();
00106         break;
00107
00108       default:
00109         hResult = S_FALSE;
00110         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00111         break;
00112     }
00113   }
00114
00115   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00116   {
00117     pRDI->nImage = m_RDI.nImage;
00118   }
00119
00120
00121   //TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00122   return hResult;
00123 }
00124
00125
00126 /////////////////////////////////////////////////////////////////////////////
00127 // Implementation of virtual methods
00128
00129
00130 //---------------------------------------------------------------------------
00131 HRESULT CVirtualFile::OnSelect
00132 (
00133   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00134   LPARAM        nArg,          //[in] Bools for context & selection state
00135   LPARAM        nParam,        //[in] Not used
00136   LONG_PTR      pComponent     //[in] Points calling CComponent
00137 )
00138 {
00139   HRESULT hResult = S_FALSE;
00140
00141   BOOL  fScopePane = LOWORD(nArg);
00142   BOOL  fSelected  = HIWORD(nArg);
00143
00144   // Don't care about de-select notifications so just return
00145   if( FALSE == fSelected )
00146     return hResult;
00147
00148   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00149
00150   IConsoleVerb* ipConsoleVerb = NULL;
00151   hResult = pComp->GetInterface( REQUEST_ICONSOLEVERB, (LONG_PTR*)&ipConsoleVerb );
00152   if( S_OK != hResult )
00153    return hResult;
00154
00155   // Not setting a default verb
00156   //
00157   hResult = ipConsoleVerb->SetVerbState( MMC_VERB_DELETE, ENABLED, TRUE );
00158   hResult = ipConsoleVerb->SetVerbState( MMC_VERB_RENAME, ENABLED, TRUE );
00159
00160   //TRACE_HRESULT(_T("OnSelect"), hResult );
00161   return hResult;
00162 }
00163
00164
00165 //---------------------------------------------------------------------------
00166 HRESULT CVirtualFile::OnShow
00167 (
00168   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00169   LPARAM        nArg,          //[in] TRUE if node was selcted
00170   LPARAM        nParam,        //[in] HSCOPEITEM of selected/deselected item
00171   LONG_PTR      pComponent     //[in] Points calling CComponent
00172 )
00173 {
00174   HRESULT  hResult = S_FALSE;
00175
00176   //TRACE_HRESULT(_T("OnShow"), hResult );
00177   return hResult;
00178 }
00179
00180
00181 //---------------------------------------------------------------------------
00182 //  This message must return S_OK to allow the rename.  Anything else will
00183 //  disallow the rename
00184 //
00185 HRESULT CVirtualFile::OnRename
00186 (
00187   LPDATAOBJECT ipDataObject,   //[in] Points to Data Object
00188   LPARAM       nArg,           //[in] Not used
00189   LPARAM       nParam,         //[in] Pointer to the new name
00190   LONG_PTR     pComponent      //[in] Points to calling IComponent
00191 )
00192 {
00193   HRESULT hResult = S_OK;
00194
00195   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00196
00197   LPWSTR pszTmpName = NULL;
00198   LPWSTR pszNewName = (LPWSTR)nParam;  // New name
00199   LONG   nLen = wcslen( pszNewName ) + 1;
00200
00201   pszTmpName = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00202   if( NULL == pszTmpName )
00203   {
00204     hResult = S_FALSE;                 // Can't change the name
00205   }
00206   else
00207   {
00208     wcscpy( pszTmpName, pszNewName );
00209     CoTaskMemFree( m_pwszNodeName );   // Free existing name...
00210     m_pwszNodeName = pszTmpName;       // Assign new name to pointer
00211   }
00212
00213   LPRESULTDATA  ipResultData = NULL;
00214   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00215   if( S_OK != hResult )
00216    return hResult;
00217
00218   // VIEWEX:  When MMCN_RENAME is called from the object model via a
00219   //          script, there is no automatic call to GetDisplayInfo, so
00220   //          we need to explicitly call UpdateItem to redraw the node
00221   hResult = ipResultData->UpdateItem( m_RDI.itemID );
00222
00223   // In order to handle the case where multiple windows are open we need to
00224   // create a data object which represents our parent node.  We can then call
00225   // IConsole::UpdateAllViews with this data object.  MMC will direct the
00226   // MMCN_VIEW_CHANGE notification to the parent node which will update all
00227   // result views which it owns (is the selected scope node)
00228   //
00229   LPCONSOLE3 ipConsole = NULL;
00230   hResult = pComp->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole );
00231   _ASSERT( NULL != ipConsole );
00232
00233   LPDATAOBJECT pDO = NULL;
00234   hResult = pComp->QueryDataObject( (LONG_PTR)m_pParentFolder, CCT_SCOPE, &pDO );
00235   hResult = ipConsole->UpdateAllViews( pDO, NULL, HINT_UPDATE_ITEM );
00236   pDO->Release();
00237
00238   return hResult;
00239 }
00240
00241
00242 //---------------------------------------------------------------------------
00243 HRESULT CVirtualFile::OnDelete
00244 (
00245   LPDATAOBJECT ipDataObject,   //[in] Points to Data Object
00246   LPARAM       nArg,           //[in] Not used
00247   LPARAM       nParam,         //[in] Not used
00248   LONG_PTR     pComponent      //[in] Points to calling IComponent
00249 )
00250 {
00251   _ASSERT( NULL != ipDataObject );
00252   _ASSERT( NULL != m_pParentFolder );
00253
00254   HRESULT hResult = S_FALSE;
00255
00256   // Tell our parent node to remove us from it's list of children
00257   m_pParentFolder->RemoveVirtualFile( this );
00258
00259   LPRESULTDATA ipResultData = NULL;
00260   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00261   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00262   if( S_OK != hResult )
00263     return hResult;
00264
00265   hResult = ipResultData->DeleteItem( m_RDI.itemID, 0 );
00266
00267   // In order to handle the case where multiple windows are open we need to
00268   // create a data object which represents our parent node.  We can then call
00269   // IConsole::UpdateAllViews with this data object.  MMC will direct the
00270   // MMCN_VIEW_CHANGE notification to the parent node which will update all
00271   // result views which it owns (is the selected scope node)
00272   //
00273   LPCONSOLE3 ipConsole = NULL;
00274   hResult = pComp->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole );
00275   _ASSERT( NULL != ipConsole );
00276
00277   LPDATAOBJECT pDO = NULL;
00278   hResult = pComp->QueryDataObject( (LONG_PTR)m_pParentFolder, CCT_SCOPE, &pDO );
00279   hResult = ipConsole->UpdateAllViews( pDO, NULL, HINT_UPDATE_ITEM );
00280   pDO->Release();
00281
00282   delete this;
00283
00284   return hResult;
00285 }
00286
00287 /////////////////////////////////////////////////////////////////////////////
00288 // CVirtualFile does not support a context menu
00289
00290 //---------------------------------------------------------------------------
00291 HRESULT CVirtualFile::AddMenuItems
00292 (
00293   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00294   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00295 )
00296 {
00297   HRESULT hResult = E_NOTIMPL;
00298   //TRACE_HRESULT(_T("AddMenuItems"), hResult );
00299   return hResult;
00300 }
00301
00302
00303 //---------------------------------------------------------------------------
00304 HRESULT CVirtualFile::Command
00305 (
00306   long lCommandID          //[in] Indentifier for menu ID
00307 )
00308 {
00309   HRESULT hResult = E_NOTIMPL;
00310   //TRACE_HRESULT(_T("Command"), hResult );
00311   return hResult;
00312 }
00313
00314 /////////////////////////////////////////////////////////////////////////////
00315 // CVirtualFile methods to support INodeProperties
00316
00317 //---------------------------------------------------------------------------
00318 //  VIEWEX:  This method is called by the View Extension to get the text
00319 //           properties of the selected node.  It passes in the text
00320 //           representation of the clipboard formats.  This method is the
00321 //           the prefered method of doing this although the clipboard
00322 //           formats can also be handled in the data object.
00323 //
00324 HRESULT CVirtualFile::GetProperty
00325 (
00326   BSTR   bstrPropertyName,   //[in]  Name of the property being retrieved
00327   PBSTR  pbstrProperty       //[out] Text value for the property
00328 )
00329 {
00330   HRESULT hResult = S_FALSE;
00331   BSTR bstrDesc = SysAllocString( L"CCF_DESCRIPTION" );
00332   BSTR bstrHTML = SysAllocString( L"CCF_HTML_DETAILS");
00333
00334   if( NULL == bstrDesc || NULL == bstrHTML )
00335     return E_OUTOFMEMORY;
00336
00337   if( VARCMP_EQ == VarBstrCmp(bstrPropertyName, bstrDesc, 0, 0) )
00338   {
00339     *pbstrProperty = SysAllocString( m_pDescripStr );
00340     if( NULL != *pbstrProperty )
00341       hResult = S_OK;
00342   }
00343
00344   if( VARCMP_EQ == VarBstrCmp( bstrPropertyName, bstrHTML, 0, 0 ) )
00345   {
00346     // Build the script we want to run from our predefined mini-scripts
00347     // which are defined in Scripts.h
00348     //
00349     WCHAR szScriptBuffer[1024];
00350     wcscpy( szScriptBuffer, GSCRP_BEGIN_FORM    );
00351     wcscat( szScriptBuffer, GSCRP_RENAME_BUTTON );
00352     wcscat( szScriptBuffer, GSCRP_DELETE_BUTTON );
00353     wcscat( szScriptBuffer, GSCRP_LINK_HOMEPAGE );
00354     wcscat( szScriptBuffer, GSCRP_END_FORM      );
00355
00356     *pbstrProperty = SysAllocString( szScriptBuffer );
00357     if( NULL != *pbstrProperty )
00358       hResult = S_OK;                  // If you don't return S_OK the HTML
00359   }                                    // code will not be executed
00360
00361   SysFreeString( bstrDesc );           // Free string resources
00362   SysFreeString( bstrHTML );
00363
00364   return hResult;
00365  }
00366
00367
00368 /////////////////////////////////////////////////////////////////////////////
00369 //  CVirtualFile methods to support attributes
00370
00371 //---------------------------------------------------------------------------
00372 BOOL CVirtualFile::IsAttributeSet
00373 (
00374   DWORD dwAttribute           //[in] Attribute to set
00375 )
00376 {
00377   return (m_dwAttributes & dwAttribute) ? TRUE : FALSE;
00378 }
00379
00380 //---------------------------------------------------------------------------
00381 VOID CVirtualFile::SetAttribute
00382 (
00383   DWORD dwAttribute           //[in] Attribute to set
00384 )
00385 {
00386   m_dwAttributes |= dwAttribute;
00387 }
00388
00389 //---------------------------------------------------------------------------
00390 VOID CVirtualFile::RemoveAttribute
00391 (
00392   DWORD dwAttribute           //[in] Attribute to remove
00393 )
00394 {
00395   m_dwAttributes &= ~dwAttribute;
00396 }
00397
00398 //---------------------------------------------------------------------------
00399 //  Return a string representation of the node's attributes.
00400 //
00401 LPWSTR CVirtualFile::GetAttributeString()
00402 {
00403   *m_pAttribStr = NULL;
00404
00405   if( IsAttributeSet(ATTRIBUTE_DATA_ARCHIVE) )
00406     wcscat( m_pAttribStr, L"A " );
00407
00408   if( IsAttributeSet(ATTRIBUTE_DATA_HIDDEN) )
00409     wcscat( m_pAttribStr, L"H " );
00410
00411   if( IsAttributeSet(ATTRIBUTE_DATA_LOCKED) )
00412     wcscat( m_pAttribStr, L"L " );
00413
00414   if( IsAttributeSet(ATTRIBUTE_DATA_READONLY) )
00415     wcscat( m_pAttribStr, L"R " );
00416
00417   return m_pAttribStr;
00418 }
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ThreadArg_Struct Member List

This is the complete list of members for ThreadArg_Struct, including all inherited members.
m_EventSink | ThreadArg_Struct
m_Registrar | ThreadArg_Struct
m_Service | ThreadArg_Struct
m_Sink | ThreadArg_Struct
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/FVText.h Source File

  • WinUI
  • Shell
  • FileView

FVText.h

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  PROGRAM: FVTEXT.H
00009 //
00010 //  PURPOSE:   Classes that implement the CFileViewer object for integration
00011 // with the Windows 95 Explorer.  Necessary modifications for a
00012 // custom viewer marked with MODIFY
00013 //
00014 //  PLATFORMS:  Windows 95
00015 //
00016 //  SPECIAL INSTRUCTIONS:
00017 //
00018 //DO NOT USE THESE GUIDS:  These are for this sample ONLY
00019 //File CLSID for the text compound file example:  this is nothing official.
00020 //Forward class references
00021
00022 DEFINE_GUID(CLSID_SampleTextFile, 0x00021116, 0, 0, 0xC0,0,0,0,0,0,0,0x46);
00023
00024 //MODIFY:  Define your custom FileViewer CLSID(s) here.
00025 DEFINE_GUID(CLSID_FileViewerText, 0x00021117, 0, 0, 0xC0,0,0,0,0,0,0,0x46);
00026
00027 #ifndef _FVTEXT_H_
00028 #define _FVTEXT_H_
00029
00030 class CImpIPersistFile;
00031 typedef class CImpIPersistFile *PIMPIPERSISTFILE;
00032
00033 class CImpIFileViewer;
00034 typedef class CImpIFileViewer *PIMPIFILEVIEWER;
00035
00036 //FVPROC.CPP
00037 //MODIFY:  Window procedures for frame and viewport windows
00038 LRESULT WINAPI FileViewerFrameProc(HWND, UINT, WPARAM, LPARAM);
00039
00040 //Extra bytes for frame
00041 #define CBWNDEXTRAFRAME             sizeof(LPVOID)
00042 #define FVWL_OBJECTPOINTER          0
00043
00044 /*
00045  * MODIFY:  Change viewport window procedure and defintions
00046  * to be specific to the file viewer in use.
00047  */
00048 LRESULT WINAPI ViewportWndProc(HWND, UINT, WPARAM, LPARAM);
00049
00050 //Extra bytes for viewport
00051 #define CBWNDEXTRAVIEWPORT          sizeof(LPVOID)
00052 #define VPWL_OBJECTPOINTER          0
00053
00054
00055 BOOL APIENTRY AboutProc(HWND, UINT, WPARAM, LPARAM);
00056
00057
00058 //Child window IDs
00059 #define ID_TOOLBAR                  50
00060 #define ID_STATUSBAR                51
00061 #define ID_VIEWPORT                 52
00062
00063
00064 //Options for CFileViewer::FontChange.
00065 typedef enum
00066     {
00067     VIEWFONT_SELECT=0,
00068     VIEWFONT_INCREASESIZE,
00069     VIEWFONT_DECREASESIZE
00070     } VIEWFONTOPTION;
00071
00072 /*
00073  * Limits to font sizes for the Font dialog.  The increase and
00074  * decrease buttons change the point size by different amounts
00075  * (FONTSIZEDELTA*) depending on the size of the current font
00076  * (where it falls in the FONTSIZETHRESHOLD*).  Note that these
00077  * values have to be multiplied by logical_pixels_per_inch/72
00078  * on the display to be accurate.  See CFileViewer::FontChange.
00079  *
00080  * Of course, there are better ways to do this that are font
00081  * specific.  This way works well for stock fonts (Arial, Courier
00082  * New, Times New Roman).
00083  */
00084 #define FONTSIZETHRESHOLDMIN    4
00085 #define FONTSIZETHRESHOLDLOW    32
00086 #define FONTSIZETHRESHOLDMID    48
00087 #define FONTSIZETHRESHOLDMAX    120
00088 #define FONTSIZEDELTASMALL      2       //4 to 32pt
00089 #define FONTSIZEDELTAMEDIUM     8       //32 to 48pt
00090 #define FONTSIZEDELTALARGE      24      //48 to 120pt
00091
00092 //FVTEXT.CPP, FVINIT.CPP
00093 /*
00094  * MODIFY:  Change this CFileViewer object to be more specific to
00095  * your implementations.  Specific parts are listed below.
00096  *
00097  * The CFileViewer object is implemented in its own class with its own
00098  * IUnknown to support aggregation.  It contains two interface
00099  * implementation objects (CImpIPersistFile and CImpIFileViewer)
00100  * to implement the externally exposed interfaces.
00101  */
00102
00103 class CFileViewer : public IUnknown
00104     {
00105     //Make any contained interfaces your friends
00106     friend class CImpIPersistFile;
00107     friend class CImpIFileViewer;
00108
00109     friend LRESULT WINAPI FileViewerFrameProc(HWND, UINT, WPARAM, LPARAM);
00110     friend LRESULT WINAPI ViewportWndProc(HWND, UINT, WPARAM, LPARAM);
00111
00112     protected:
00113         //NOTE:  These members usually need no modification
00114         ULONG               m_cRef;             //Object reference count
00115
00116         LPUNKNOWN           m_pUnkOuter;        //Controlling unknown
00117         HINSTANCE           m_hInst;            //Module instance
00118         PFNDESTROYED        m_pfnDestroy;       //To call on closure
00119         LPFILEVIEWERSITE m_lpfsi;       // file viewer site
00120
00121         CLSID               m_clsID;            //CLSID of this FileViewer
00122         LPSTR               m_pszPath;          //Path from IPersitFile::Load
00123         DWORD               m_grfMode;          //Open mode for the file
00124         BOOL                m_fLoadCalled;      //Load called already?
00125         BOOL                m_fShowInit;        //ShowInitialize called?
00126
00127         BOOL                m_fClassReg;        //RegisterClass work?
00128         BOOL                m_fPostQuitMsg;     // Should destroy post quit
00129         HWND                m_hWnd;             //Main window
00130         HWND                m_hWndOld;          // Old Main window.
00131         HWND                m_hWndToolbar;      //Child windows
00132         HWND                m_hWndStatus;
00133         HWND                m_hWndViewport;
00134         HACCEL              m_hAccel;
00135
00136         UINT                m_cyTools;          //Child window heights
00137         UINT                m_cyStatus;
00138
00139         BOOL                m_fToolsVisible;    //Visible child windows.
00140         BOOL                m_fStatusVisible;
00141
00142         PCStringTable       m_pST;              //Stringtable object
00143         PCStatusHelper      m_pSH;              //For WM_MENUSELECT
00144
00145         //Interface implementations
00146         PIMPIPERSISTFILE    m_pIPersistFile;
00147         PIMPIFILEVIEWER     m_pIFileViewer;
00148         LPFVSHOWINFO        m_pvsi;
00149
00150         /*
00151          * MODIFY:  Change these to your own FileViewer specifics.
00152          * The variables here are specific to text viewing.
00153          */
00154         HGLOBAL             m_hMemText;         //Loaded text.
00155         HFONT               m_hFont;            //Current viewport font
00156         int                 m_cyPPI;            //logical pix/inch
00157         int                 m_xPos;             //Scroll positions
00158         int                 m_yPos;
00159
00160     protected:
00161         BOOL                FInitFrameControls(void);
00162         HRESULT             FileLoad(void);
00163
00164         void                OnCommand(WORD, WORD, HWND);
00165         void                ChildrenResize(void);
00166         void                ViewportResize(void);
00167         BOOL                FOpenAs(void);
00168         LPSTR               PszToolTip(UINT);
00169
00170         //MODIFY:  These may be irrelevant for a custom viewer
00171         void                ViewportScrollSet(void);
00172         void                FontChange(VIEWFONTOPTION);
00173         void                ReplaceWindowModeChange(void);
00174         BOOL                DropFiles(HDROP);
00175
00176     public:
00177         CFileViewer(LPUNKNOWN, HINSTANCE, PFNDESTROYED);
00178         ~CFileViewer(void);
00179
00180         HRESULT             Init(void);        //Called from IClassFactory::CreateInstance
00181         LPSTR               String(UINT);      //inline--see FVTEXT.CPP
00182         LPVOID              MemAlloc(ULONG);   //IMalloc helpers
00183         void                MemFree(LPVOID);
00184
00185         //IFileViewer implementataions (called from CImpIFileViewer)
00186         STDMETHODIMP        FileShowInit(LPFILEVIEWERSITE lpfsi);
00187         STDMETHODIMP        FileShow(LPFVSHOWINFO pvsi);
00188         STDMETHODIMP        PrintTo(LPSTR, BOOL);
00189
00190
00191         //Non-delegating object IUnknown interface
00192         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00193         STDMETHODIMP_(ULONG) AddRef(void);
00194         STDMETHODIMP_(ULONG) Release(void);
00195     };
00196
00197 typedef CFileViewer * PCFileViewer;
00198
00199
00200
00201 /*
00202  * Interface implementations for the CFileViewer object.
00203  */
00204
00205 //IPERFILE.CPP
00206 class CImpIPersistFile : public IPersistFile
00207     {
00208     private:
00209         PCFileViewer    m_pObj;         //Back pointer to object
00210         LPUNKNOWN       m_pUnkOuter;    //Controlling unknown
00211
00212     public:
00213         CImpIPersistFile(PCFileViewer, LPUNKNOWN);
00214         ~CImpIPersistFile(void);
00215
00216         //IUnknown members that delegate to m_pUnkOuter.
00217         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00218         STDMETHODIMP_(ULONG) AddRef(void);
00219         STDMETHODIMP_(ULONG) Release(void);
00220
00221         //IPersist members
00222         STDMETHODIMP GetClassID(LPCLSID);
00223
00224         //IPersistFile members
00225         STDMETHODIMP IsDirty(void);
00226         STDMETHODIMP Load(LPCOLESTR, DWORD);
00227         STDMETHODIMP Save(LPCOLESTR, BOOL);
00228         STDMETHODIMP SaveCompleted(LPCOLESTR);
00229         STDMETHODIMP GetCurFile(LPOLESTR *);
00230     };
00231
00232
00233
00234
00235 //IFILEVW.CPP
00236 class CImpIFileViewer : public IFileViewer
00237     {
00238     private:
00239         PCFileViewer    m_pObj;         //Back pointer to object
00240         LPUNKNOWN       m_pUnkOuter;    //Controlling unknown
00241
00242     public:
00243         CImpIFileViewer(PCFileViewer, LPUNKNOWN);
00244         ~CImpIFileViewer(void);
00245
00246         //IUnknown members that delegate to m_pUnkOuter.
00247         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00248         STDMETHODIMP_(ULONG) AddRef(void);
00249         STDMETHODIMP_(ULONG) Release(void);
00250
00251         //IFileViewer members
00252         STDMETHODIMP PrintTo(LPSTR, BOOL);
00253         STDMETHODIMP ShowInitialize(LPFILEVIEWERSITE lpfsi);
00254         STDMETHODIMP Show(LPFVSHOWINFO pvsi);
00255     };
00256
00257
00258
00259 #endif //_FVTEXT_H_
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/util.cpp Source File

  • Web
  • bits
  • Upload

util.cpp

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  util.cpp
00011 //
00012 //  Purpose:
00013 //  Implementation of auxiliary functions used by the sample.
00014 //
00015 //----------------------------------------------------------------------------
00016
00017
00018
00019 #include <windows.h>
00020 #include <crtdbg.h>
00021 #include <strsafe.h>
00022
00023 #include "util.h"
00024 #include "main.h"
00025
00026
00027
00028 HRESULT DisplayErrorMessage(LPCWSTR pwszAdditionalMsg, HRESULT hrCode)
00029 {
00030     HRESULT hr                    = S_OK;
00031     HRESULT LookupHr              = HRESULT_FROM_WIN32( ERROR_RESOURCE_LANG_NOT_FOUND );
00032     WCHAR   wszErrorMessage[512]  = { 0 };
00033     WCHAR  *pwszBITSErrorMsg      = NULL;
00034
00035     if (FAILED(hrCode))
00036     {
00037
00038         //
00039         // Prepare to get a locale-specific error message.
00040         // We we are going to try different LCIDs; depending if this is a localized OS or not,
00041         // we may be able to get localized error messages. Otherwise fall back to English strings.
00042         //
00043         LCID LcidsToTry[] =
00044         {
00045             GetThreadLocale(),
00046             GetUserDefaultLCID(),
00047             GetSystemDefaultLCID(),
00048             MAKELCID( MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), 0 )
00049         };
00050
00051         SIZE_T NumberOfLCIDs = ARRAYSIZE(LcidsToTry);
00052
00053         //
00054         // Loop until we run out of LCIDs or until we succeed.
00055         // Note that if the error is not BITS specific, the function will search
00056         // winhttp and the system for a description.
00057         //
00058         for (SIZE_T i = 0;
00059                 (( HRESULT_FROM_WIN32( ERROR_RESOURCE_LANG_NOT_FOUND ) == LookupHr ||
00060                    HRESULT_FROM_WIN32( ERROR_MR_MID_NOT_FOUND ) == LookupHr)
00061                 && i < NumberOfLCIDs);
00062                 i++)
00063         {
00064             LookupHr = g_JobManager->GetErrorDescription(hrCode, LcidsToTry[i], &pwszBITSErrorMsg);
00065             if (SUCCEEDED(LookupHr))
00066             {
00067                 break;
00068             }
00069         }
00070
00071         //
00072         // Build the full message that we are going to display to the user.
00073         // Note that maybe we didn't get an error description from BITS after all,
00074         // or the pwszAdditionalMsg parameter given was NULL. We need to test for those.
00075         //
00076         hr = StringCbPrintfW(
00077             wszErrorMessage,
00078             sizeof(wszErrorMessage),
00079             L"%s\n\nThe specific error message returned by the system is: [Error 0x%8.8x] %s\nPlease check the BITS SDK or post a question to the BITS newsgroup if you need \nassistance troubleshooting this issue.",
00080             (pwszAdditionalMsg? pwszAdditionalMsg : L""),
00081             hrCode,
00082             (pwszBITSErrorMsg? pwszBITSErrorMsg : L"")
00083         );
00084
00085         if (FAILED(hr))
00086         {
00087             goto cleanup;
00088         }
00089
00090         MessageBoxW(NULL, wszErrorMessage, L"BITS Upload Sample", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND );
00091     }
00092
00093 cleanup:
00094
00095     return hr;
00096 }
00097
00098
00099 LPCWSTR ConvertGuidToString(REFGUID guid)
00100 {
00101     static WCHAR wszGuid[MAX_GUID_STRING_LENGTH];
00102
00103     if (!StringFromGUID2(guid, wszGuid, MAX_GUID_STRING_LENGTH))
00104     {
00105         wszGuid[0] = L'\0';
00106     }
00107
00108     return reinterpret_cast<WCHAR *>(wszGuid);
00109 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/marshalhelpers.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

marshalhelpers.h

Go to the documentation of this file.
00001 #include <comdef.h>
00002
00003 #pragma warning( disable : 4290 )
00004
00005 // This code is derived from the CComVariant implementation
00006 // of WriteToStream
00007 inline unsigned long GetVariantSize(VARIANT& var)
00008 {
00009   VARTYPE vt = var.vt;
00010   unsigned long sz = sizeof(VARTYPE);
00011   HRESULT hr = 0;
00012
00013   switch (vt)
00014   {
00015   case VT_UNKNOWN:
00016   case VT_DISPATCH:
00017     {
00018       {
00019         IUnknown* punkVal = var.punkVal;
00020         CComPtr<IPersistStream> spStream;
00021         if (punkVal != NULL)
00022         {
00023           hr = punkVal->QueryInterface(IID_IPersistStream, (void**)&spStream);
00024           if (FAILED(hr))
00025             return sz;
00026           ULARGE_INTEGER pcbSize;
00027           hr = spStream->GetSizeMax(&pcbSize);
00028           if (FAILED(hr))
00029             return sz;
00030           sz += pcbSize.LowPart;
00031           sz += 256;
00032         }
00033       }
00034     }
00035   case VT_UI1:
00036   case VT_I1:
00037     sz  +=  sizeof(BYTE);
00038     break;
00039   case VT_I2:
00040   case VT_UI2:
00041   case VT_BOOL:
00042     sz  +=  sizeof(short);
00043     break;
00044   case VT_I4:
00045   case VT_UI4:
00046   case VT_R4:
00047   case VT_INT:
00048   case VT_UINT:
00049   case VT_ERROR:
00050   case VT_NULL:
00051     sz  +=  sizeof(long);
00052     break;
00053   case VT_R8:
00054   case VT_CY:
00055   case VT_DATE:
00056     sz  +=  sizeof(double);
00057     break;
00058   case VT_BSTR:
00059     sz += ((SysStringLen(var.bstrVal) * sizeof(OLECHAR))+6);
00060     break;
00061   case VT_VARIANT:
00062     sz += sizeof(VARIANT);
00063     sz += GetVariantSize(*(var.pvarVal));
00064   default:
00065     break;
00066   }
00067   return sz;
00068 }
00069
00070 // IStream / C++ stream operator support functions
00071
00072 template <class _T_> IStream& operator<<( IStream& stream, const _T_& data ) throw(_com_error)
00073 {
00074   _com_util::CheckError(stream.Write( &data, sizeof(data), 0));
00075   return stream;
00076 }
00077
00078 template <class _T_> IStream& operator>>( IStream& stream, _T_& data ) throw(_com_error)
00079 {
00080   _com_util::CheckError(stream.Read( &data, sizeof(data), 0));
00081   return stream;
00082 }
00083
00084 inline IStream& operator<<( IStream& stream, CFastVariant& data ) throw(_com_error)
00085 {
00086   _com_util::CheckError(data.WriteToStream( &stream ));
00087   return stream;
00088 }
00089
00090 inline IStream& operator>>( IStream& stream, CFastVariant& data ) throw(_com_error)
00091 {
00092   _com_util::CheckError(data.ReadFromStream( &stream ));
00093   return stream;
00094 }
00095
00096 inline IStream& operator<<( IStream& stream, VARIANT data ) throw(_com_error)
00097 {
00098   CFastVariant v;
00099   v.Attach(&data);
00100
00101   stream<<v;
00102
00103   v.Detach(&data);
00104
00105   return stream;
00106 }
00107
00108 inline IStream& operator>>( IStream& stream, VARIANT& data ) throw(_com_error)
00109 {
00110   CFastVariant v;
00111
00112   stream>>v;
00113
00114   v.Detach(&data);
00115   return stream;
00116 }
00117
00118 inline IStream& operator<<( IStream& stream, const char* data ) throw(_com_error)
00119 {
00120   long length = strlen(data) + 1;
00121
00122   stream<<length;
00123   _com_util::CheckError(stream.Write( data, length*sizeof(*data), 0));
00124
00125   return stream;
00126 }
00127
00128 inline IStream& operator>>( IStream& stream, char* data ) throw(_com_error)
00129 {
00130   long length;
00131
00132   stream>>length;
00133   _com_util::CheckError(stream.Read( data, length*sizeof(*data), 0));
00134   return stream;
00135 }
00136
00137 inline IStream& operator<<( IStream& stream, const wchar_t *data ) throw(_com_error)
00138 {
00139   long length = wcslen(data) + 1;
00140
00141   stream << length;
00142   _com_util::CheckError(stream.Write( data, length*sizeof(*data), 0));
00143
00144   return stream;
00145 }
00146
00147 inline IStream& operator>>( IStream& stream, wchar_t *data ) throw(_com_error)
00148 {
00149   long length;
00150
00151   stream>>length;
00152   _com_util::CheckError(stream.Read( data, length * sizeof(*data), 0));
00153   return stream;
00154 }
00155
00156 inline IStream& operator>>( IStream& stream, CString &data ) throw(_com_error)
00157 {
00158   long length;
00159   LPWSTR wszData;
00160
00161   stream>>length;
00162
00163   wszData = data.GetBuffer(length+1);
00164
00165   _com_util::CheckError(stream.Read( (void*)wszData, length * sizeof(*wszData), 0));
00166
00167   data.ReleaseBuffer();
00168   return stream;
00169 }
00170
00171 inline IStream& operator<<( IStream& stream, const _bstr_t& data ) throw(_com_error)
00172 {
00173   CComBSTR bstr;
00174
00175   bstr.Attach(data);
00176
00177   _com_util::CheckError(bstr.WriteToStream(&stream));
00178   bstr.Detach();
00179
00180   return stream;
00181 }
00182
00183 inline IStream& operator>>( IStream& stream, _bstr_t& data ) throw(_com_error)
00184 {
00185   CComBSTR bstr;
00186
00187   _com_util::CheckError(bstr.ReadFromStream(&stream));
00188
00189   _bstr_t  bs(bstr.Detach(),false); // use ref counting to prevent copy
00190
00191   data = bs;
00192
00193   return stream;
00194 }
00195
00196 inline IStream& operator>>( IStream& stream, CComBSTR& data ) throw(_com_error)
00197 {
00198   _com_util::CheckError(data.ReadFromStream(&stream));
00199   return stream;
00200 }
00201
00202 inline IStream& operator<<( IStream& stream, CComBSTR& data ) throw(_com_error)
00203 {
00204   _com_util::CheckError(data.WriteToStream(&stream));
00205   return stream;
00206 }
00207
00208 #pragma warning( default : 4290 )
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/progress.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

progress.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module PROGRESS.CPP
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 ////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 ////////////////////////////////////////////////////////////////////
00015 #include "progress.h"
00016 #include "common.h"
00017
00018
00019
00020 ////////////////////////////////////////////////////////////////////
00021 // CProgress::CProgress
00022 //
00023 ////////////////////////////////////////////////////////////////////
00024 CProgress::CProgress(HWND hWnd, HINSTANCE hInst)
00025   : CDialogBase(hWnd, hInst)
00026 {
00027 }
00028
00029 ////////////////////////////////////////////////////////////////////
00030 // CProgress::~CProgress
00031 //
00032 ////////////////////////////////////////////////////////////////////
00033 CProgress::~CProgress()
00034 {
00035   Destroy();
00036 }
00037
00038
00039 ////////////////////////////////////////////////////////////////////
00040 // BOOL WINAPI CProgress::DlgProc
00041 //
00042 ////////////////////////////////////////////////////////////////////
00043 BOOL WINAPI CProgress::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00044 {
00045   switch(msg)
00046   {
00047     case WM_INITDIALOG:
00048     {
00049       //Save the this pointer, since this is a static method
00050       Busy();
00051       CProgress* pThis = (CProgress*)lParam;
00052       SetWindowLong(hWnd, GWL_USERDATA, (LONG)pThis);
00053
00054       //On INIT we know we have a valid hWnd to store
00055       pThis->m_hWnd = hWnd;
00056
00057       CenterDialog(hWnd);
00058       return TRUE;
00059     }
00060     break;
00061
00062     case WM_COMMAND:
00063     {
00064       // All buttons are handled the same way
00065       //Restore instance pointer, since this is a static function
00066       CProgress* pThis = (CProgress*)GetWindowLong(hWnd, GWL_USERDATA);
00067
00068       switch(GET_WM_COMMAND_ID(wParam, lParam))
00069       {
00070                 case IDCANCEL:
00071           Busy();
00072           pThis->m_fCancel = TRUE;
00073                   return TRUE;
00074       }
00075       return FALSE;
00076     }
00077     break;
00078
00079     default:
00080       return FALSE;
00081   }
00082 }
00083
00084
00085 ////////////////////////////////////////////////////////////////////
00086 // ULONG CProgress::Display
00087 //
00088 ////////////////////////////////////////////////////////////////////
00089 ULONG CProgress::Display()
00090 {
00091   m_fCancel = FALSE;
00092
00093   //Create a ModeLess Dialog Box
00094   m_hWnd = CreateDialogParam(m_hInst, MAKEINTRESOURCE(IDD_PROGRESS), NULL, DlgProc, (LPARAM)this);
00095   return TRUE;
00096 }
00097
00098
00099 ////////////////////////////////////////////////////////////////////
00100 // ULONG CProgress::Destroy
00101 //
00102 ////////////////////////////////////////////////////////////////////
00103 ULONG CProgress::Destroy()
00104 {
00105   if(m_hWnd)
00106   {
00107     DestroyWindow(m_hWnd);
00108     m_hWnd = NULL;
00109   }
00110   return TRUE;
00111 }
00112
00113
00114 ////////////////////////////////////////////////////////////////////
00115 // BOOL CProgress::SetHeading
00116 //
00117 ////////////////////////////////////////////////////////////////////
00118 BOOL CProgress::SetHeading(WCHAR* pwszText)
00119 {
00120   ASSERT(pwszText);
00121
00122   wSetDlgItemText(m_hWnd, IDT_STATUS, pwszText);
00123   return TRUE;
00124 }
00125
00126
00127 ////////////////////////////////////////////////////////////////////
00128 // BOOL CProgress::SetText
00129 //
00130 ////////////////////////////////////////////////////////////////////
00131 BOOL CProgress::SetText(WCHAR* pwszText)
00132 {
00133   ASSERT(pwszText);
00134
00135   wSetDlgItemText(m_hWnd, IDT_STAT_INFO, pwszText);
00136   return TRUE;
00137 }
00138
00139
00140 ////////////////////////////////////////////////////////////////////
00141 // BOOL CProgress::Cancel
00142 //
00143 ////////////////////////////////////////////////////////////////////
00144 BOOL CProgress::Cancel()
00145 {
00146   MSG   msg;
00147
00148   //Must have an existing window to cancel
00149   if(m_hWnd==NULL)
00150     return FALSE;
00151
00152   while(PeekMessage(&msg, m_hWnd, 0, 0, PM_REMOVE))
00153   {
00154     if(!IsDialogMessage(m_hWnd, &msg))
00155     {
00156       TranslateMessage(&msg);
00157       DispatchMessage(&msg);
00158     }
00159   }
00160
00161   return m_fCancel;
00162 }
00163
00164
00165 ////////////////////////////////////////////////////////////////////
00166 // BOOL CProgress::Update
00167 //
00168 ////////////////////////////////////////////////////////////////////
00169 BOOL CProgress::Update(WCHAR* pwszText)
00170 {
00171   ASSERT(pwszText);
00172
00173   //Update the progress text
00174   SetText(pwszText);
00175
00176   // Now check for a cancel from the user, by checking
00177   // the messages from the user
00178   if(Cancel())
00179   {
00180     if(IDYES == wMessageBox(m_hWnd, MB_TASKMODAL | MB_ICONEXCLAMATION | MB_YESNO, wsz_CANCEL, wsz_CANCEL_OP))
00181     {
00182       //Indicate the users wishes to stop
00183       return FALSE;
00184     }
00185     else
00186     {
00187       m_fCancel = FALSE;
00188     }
00189   }
00190
00191   //Indicate the user wishes to continue
00192   return TRUE;
00193 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Explore.VC/VCExplore.h Source File

  • Com
  • Administration
  • Explore.VC

VCExplore.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018
00019
00020 #include "comadmin.h"
00021
00022
00023 #if !defined(AFX_VCEXPLORE_H__12723F25_B2F5_11D2_86A1_000000000000__INCLUDED_)
00024 #define AFX_VCEXPLORE_H__12723F25_B2F5_11D2_86A1_000000000000__INCLUDED_
00025
00026 #if _MSC_VER > 1000
00027 #pragma once
00028 #endif // _MSC_VER > 1000
00029
00030 #ifndef __AFXWIN_H__
00031   #error include 'stdafx.h' before including this file for PCH
00032 #endif
00033
00034 #include "resource.h"   // main symbols
00035
00036 /////////////////////////////////////////////////////////////////////////////
00037 // CVCExploreApp:
00038 // See VCExplore.cpp for the implementation of this class
00039 //
00040
00041 class CVCExploreApp : public CWinApp
00042 {
00043 public:
00044   CVCExploreApp();
00045
00046 // Overrides
00047   // ClassWizard generated virtual function overrides
00048   //{{AFX_VIRTUAL(CVCExploreApp)
00049   public:
00050   virtual BOOL InitInstance();
00051   //}}AFX_VIRTUAL
00052
00053 // Implementation
00054
00055   //{{AFX_MSG(CVCExploreApp)
00056     // NOTE - the ClassWizard will add and remove member functions here.
00057     //    DO NOT EDIT what you see in these blocks of generated code !
00058   //}}AFX_MSG
00059   DECLARE_MESSAGE_MAP()
00060 };
00061
00062
00063 /////////////////////////////////////////////////////////////////////////////
00064
00065 //{{AFX_INSERT_LOCATION}}
00066 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00067
00068 #endif // !defined(AFX_VCEXPLORE_H__12723F25_B2F5_11D2_86A1_000000000000__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/resource.h Source File

  • SysMgmt
  • MMC
  • Openserv

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Resources.rc
00004 //
00005 #define IDS_HELPFILE                    1
00006 #define IDS_SNAPINDESC                  2
00007 #define IDS_NAME                        3
00008 #define IDB_WATERMARK                   3
00009 #define IDB_HEADER                      4
00010 #define IDS_SNAPINNAME                  6
00011 #define IDS_ABOUTNAME                   9
00012 #define IDS_PST_ROCKET                  10
00013 #define IDD_PROPPAGE_LARGE              107
00014 #define IDI_ICON1                       108
00015 #define IDB_SMOPEN                      111
00016 #define IDB_SMBMP                       112
00017 #define IDB_LGBMP                       113
00018 #define IDI_PSI_ROCKET                  114
00019 #define IDR_SMICONS                     120
00020 #define IDR_LGICONS                     121
00021 #define IDC_ROCKET_NAME                 1000
00022 #define IDC_ROCKET_HEIGHT               1001
00023 #define IDC_ROCKET_WEIGHT               1002
00024 #define IDC_ROCKET_PAYLOAD              1003
00025 #define IDC_ROCKET_STATUS               1005
00026 #define IDB_ROCKET                      10004
00027 #define IDB_CAR                         10005
00028 #define IDB_PLANE                       10006
00029 #define IDB_BIKE                        10007
00030 #define IDB_ROCKET2                     10008
00031 #define IDB_CAR2                        10009
00032 #define IDB_PLANE2                      10010
00033 #define IDB_BIKE2                       10011
00034 #define IDB_CLOSED2                     10012
00035 #define IDB_OPEN2                       10013
00036 #define IDB_CLOSED                      10014
00037 #define IDB_OPEN                        10015
00038 #define IDD_CHOOSER_CHOOSE_MACHINE      10016
00039 #define IDC_CHOOSER_STATIC              10017
00040 #define IDC_CHOOSER_GROUP_TARGET_MACHINE 10018
00041 #define IDC_CHOOSER_RADIO_LOCAL_MACHINE 10019
00042 #define IDC_CHOOSER_RADIO_SPECIFIC_MACHINE 10020
00043 #define IDC_CHOOSER_EDIT_MACHINE_NAME   10021
00044 #define IDC_CHOOSER_BUTTON_BROWSE_MACHINENAMES 10022
00045 #define IDC_CHOOSER_CHECK_OVERRIDE_MACHINE_NAME 10023
00046 #define IDS_CHOOSER_INVALID_COMPUTERNAME 10024
00047 #define IDS_SELECT_COMPUTER             10025
00048 #define IDS_UNABLE_TO_OPEN_COMPUTER_SELECTOR 10026
00049 #define IDS_COMPUTER_BROWSER_CAPTION    10027
00050 #define ID_FILE_PROPERTYSHEET           10028
00051 #define IDS_PST_LANDBASED               10028
00052 #define ID_FILE_DASH                    10029
00053 #define ID_FILE_EXIT                    10030
00054
00055 // Next default values for new objects
00056 //
00057 #ifdef APSTUDIO_INVOKED
00058 #ifndef APSTUDIO_READONLY_SYMBOLS
00059 #define _APS_NEXT_RESOURCE_VALUE        5
00060 #define _APS_NEXT_COMMAND_VALUE         40031
00061 #define _APS_NEXT_CONTROL_VALUE         40031
00062 #define _APS_NEXT_SYMED_VALUE           40031
00063 #endif
00064 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Snmp/TestDll/TestDll.C Source File

  • NetDS
  • Snmp
  • TestDll

TestDll.C

Go to the documentation of this file.
00001 /*++ BUILD Version: 0001    // Increment this if a change has global effects
00002
00003 Copyright (c) 1992 - 2000  Microsoft Corporation
00004
00005 Module Name:
00006
00007     testdll.c
00008
00009 Abstract:
00010
00011     Sample SNMP Extension Agent for Windows NT.
00012
00013     These files (testdll.c, testmib.c, and testmib.h) provide an example of
00014     how to structure an Extension Agent DLL which works in conjunction with
00015     the SNMP Extendible Agent for Windows NT.
00016
00017     Extensive comments have been included to describe its structure and
00018     operation.  See also "Microsoft Windows NT SNMP Programmer's Reference".
00019
00020 --*/
00021
00022
00023 // General notes:
00024 //
00025 //   Microsoft's Extendible Agent for Windows NT is implemented by dynamically
00026 // linking to Extension Agent DLLs that implement portions of the MIB.  These
00027 // Extension Agents are configured in the Windows NT Registration Database.
00028 // When the Extendible Agent Service is started, it queries the registry to
00029 // determine which Extension Agent DLLs have been installed and need to be
00030 // loaded and initialized.  The Extendible Agent invokes various DLL entry
00031 // points (examples follow in this file) to request MIB queries and obtain
00032 // Extension Agent generated traps.
00033
00034
00035 // Necessary includes.
00036
00037 #include <windows.h>
00038
00039 #include <snmp.h>
00040
00041
00042 // Contains definitions for the table structure describing the MIB.  This
00043 // is used in conjunction with testmib.c where the MIB requests are resolved.
00044
00045 #include "testmib.h"
00046
00047
00048 // Extension Agent DLLs need access to elapsed time agent has been active.
00049 // This is implemented by initializing the Extension Agent with a time zero
00050 // reference, and allowing the agent to compute elapsed time by subtracting
00051 // the time zero reference from the current system time.  This example
00052 // Extension Agent implements this reference with dwTimeZero.
00053
00054 DWORD dwTimeZero = 0;
00055
00056
00057 // Extension Agent DLLs that generate traps must create a Win32 Event object
00058 // to communicate occurence of traps to the Extendible Agent.  The event
00059 // handle is given to the Extendible Agent when the Extension Agent is
00060 // initialized, it should be NULL if traps will not be generated.  This
00061 // example Extension Agent simulates the occurance of traps with hSimulateTrap.
00062
00063 HANDLE hSimulateTrap = NULL;
00064
00065
00066 // This is a standard Win32 DLL entry point.  See the Win32 SDK for more
00067 // information on its arguments and their meanings.  This example DLL does
00068 // not perform any special actions using this mechanism.
00069
00070 BOOL WINAPI DllMain(
00071     HANDLE hDll,
00072     DWORD  dwReason,
00073     LPVOID lpReserved)
00074     {
00075     switch(dwReason)
00076         {
00077         case DLL_PROCESS_ATTACH:
00078         case DLL_PROCESS_DETACH:
00079         case DLL_THREAD_ATTACH:
00080         case DLL_THREAD_DETACH:
00081         default:
00082             break;
00083
00084         } // end switch()
00085
00086     return TRUE;
00087
00088     } // end DllEntryPoint()
00089
00090
00091 // Extension Agent DLLs provide the following entry point to coordinate the
00092 // initializations of the Extension Agent and the Extendible Agent.  The
00093 // Extendible Agent provides the Extension Agent with a time zero reference;
00094 // and the Extension Agent provides the Extendible Agent with an Event handle
00095 // for communicating occurence of traps, and an object identifier representing
00096 // the root of the MIB subtree that the Extension Agent supports.
00097
00098 BOOL WINAPI SnmpExtensionInit(
00099     IN  DWORD               dwTimeZeroReference,
00100     OUT HANDLE              *hPollForTrapEvent,
00101     OUT AsnObjectIdentifier *supportedView)
00102     {
00103
00104     // Record the time reference provided by the Extendible Agent.
00105
00106     dwTimeZero = dwTimeZeroReference;
00107
00108
00109     // Create an Event that will be used to communicate the occurence of traps
00110     // to the Extendible Agent.  The Extension Agent will assert this Event
00111     // when a trap has occured.  This is explained further later in this file.
00112
00113     if ((*hPollForTrapEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL)
00114         {
00115         // Indicate error?, be sure that NULL is returned to Extendible Agent.
00116         }
00117
00118
00119     // Indicate the MIB view supported by this Extension Agent, an object
00120     // identifier representing the sub root of the MIB that is supported.
00121
00122     *supportedView = MIB_OidPrefix; // NOTE!  structure copy
00123
00124
00125     // Record the trap Event.  This example Extension Agent simulates traps by
00126     // generating a trap after every given number of processed requests.
00127
00128     hSimulateTrap = *hPollForTrapEvent;
00129
00130
00131     // Indicate that Extension Agent initialization was sucessfull.
00132
00133     return TRUE;
00134
00135     } // end SnmpExtensionInit()
00136
00137
00138 // Extension Agent DLLs provide the following entry point to communcate traps
00139 // to the Extendible Agent.  The Extendible Agent will query this entry point
00140 // when the trap Event (supplied at initialization time) is asserted, which
00141 // indicates that zero or more traps may have occured.  The Extendible Agent
00142 // will repetedly call this entry point until FALSE is returned, indicating
00143 // that all outstanding traps have been processed.
00144
00145 BOOL WINAPI SnmpExtensionTrap(
00146     OUT AsnObjectIdentifier *enterprise,
00147     OUT AsnInteger          *genericTrap,
00148     OUT AsnInteger          *specificTrap,
00149     OUT AsnTimeticks        *timeStamp,
00150     OUT RFC1157VarBindList  *variableBindings)
00151     {
00152     // The body of this routine is an extremely simple example/simulation of
00153     // the trap functionality.  A real implementation will be more complex.
00154
00155
00156     // The following define data inserted into the trap below.  The Lan Manager
00157     // bytesAvailAlert from the Lan Manager Alerts-2 MIB is generated with an
00158     // empty variable bindings list.
00159
00160     static UINT OidList[]  = { 1, 3, 6, 1, 4, 1, 77, 2 };
00161     static UINT OidListLen = 8;
00162
00163
00164     // The following variable is used for the simulation, it allows a single
00165     // trap to be generated and then causes FALSE to be returned indicating
00166     // no more traps.
00167
00168     static whichTime = 0;
00169
00170
00171     // The following if/else support the simulation.
00172
00173     if (whichTime == 0)
00174         {
00175         whichTime = 1;    // Supports the simulation.
00176
00177
00178         // Communicate the trap data to the Extendible Agent.
00179
00180         enterprise->idLength = OidListLen;
00181         enterprise->ids = OidList;
00182
00183         *genericTrap      = SNMP_GENERICTRAP_ENTERSPECIFIC;
00184
00185         *specificTrap     = 1;                    // the bytesAvailAlert trap
00186
00187         *timeStamp        = GetCurrentTime() - dwTimeZero;
00188
00189         variableBindings->list = NULL;
00190         variableBindings->len  = 0;
00191
00192
00193         // Indicate that valid trap data exists in the parameters.
00194
00195         return TRUE;
00196         }
00197     else
00198         {
00199         whichTime = 0;    // Supports the simulation.
00200
00201
00202         // Indicate that no more traps are available and parameters do not
00203         // refer to any valid data.
00204
00205         return FALSE;
00206         }
00207
00208     } // end SnmpExtensionTrap()
00209
00210
00211 // Extension Agent DLLs provide the following entry point to resolve queries
00212 // for MIB variables in their supported MIB view (supplied at initialization
00213 // time).  The requestType is Get/GetNext/Set.
00214
00215 BOOL WINAPI SnmpExtensionQuery(
00216     IN BYTE                   requestType,
00217     IN OUT RFC1157VarBindList *variableBindings,
00218     OUT AsnInteger            *errorStatus,
00219     OUT AsnInteger            *errorIndex)
00220     {
00221     static unsigned long requestCount = 0;  // Supports the trap simulation.
00222     UINT    I;
00223
00224
00225     // Iterate through the variable bindings list to resolve individual
00226     // variable bindings.
00227
00228     for ( I=0;I < variableBindings->len;I++ )
00229         {
00230         *errorStatus = ResolveVarBind( &variableBindings->list[I],
00231                                        requestType );
00232
00233
00234         // Test and handle case where Get Next past end of MIB view supported
00235         // by this Extension Agent occurs.  Special processing is required to
00236         // communicate this situation to the Extendible Agent so it can take
00237         // appropriate action, possibly querying other Extension Agents.
00238
00239         if ( *errorStatus == SNMP_ERRORSTATUS_NOSUCHNAME &&
00240              requestType == MIB_ACTION_GETNEXT )
00241            {
00242            *errorStatus = SNMP_ERRORSTATUS_NOERROR;
00243
00244
00245            // Modify variable binding of such variables so the OID points
00246            // just outside the MIB view supported by this Extension Agent.
00247            // The Extendible Agent tests for this, and takes appropriate
00248            // action.
00249
00250            SnmpUtilOidFree( &variableBindings->list[I].name );
00251            SnmpUtilOidCpy( &variableBindings->list[I].name, &MIB_OidPrefix );
00252            variableBindings->list[I].name.ids[MIB_PREFIX_LEN-1] ++;
00253            }
00254
00255
00256         // If an error was indicated, communicate error status and error
00257         // index to the Extendible Agent.  The Extendible Agent will ensure
00258         // that the origional variable bindings are returned in the response
00259         // packet.
00260
00261         if ( *errorStatus != SNMP_ERRORSTATUS_NOERROR )
00262            {
00263      *errorIndex = I+1;
00264      goto Exit;
00265      }
00266         }
00267
00268 Exit:
00269
00270
00271     // Supports the trap simulation.
00272
00273     if (++requestCount % 3 == 0 && hSimulateTrap != NULL)
00274         SetEvent(hSimulateTrap);
00275
00276
00277     // Indicate that Extension Agent processing was sucessfull.
00278
00279     return SNMPAPI_NOERROR;
00280
00281     } // end SnmpExtensionQuery()
00282
00283
00284 //-------------------------------- END --------------------------------------
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/about.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

about.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     This class implements ISnapinAbout
00014
00015
00016
00017 #ifndef _CLASS_CSNAPINABOUT_
00018 #define _CLASS_CSNAPINABOUT_
00019
00020 #include <mmc.h>
00021
00022
00023 //---------------------------------------------------------------------------
00024 class CSnapinAbout : public ISnapinAbout
00025 {
00026   private:
00027     ULONG       m_cRef;
00028     HBITMAP     m_hSmallImage;
00029     HBITMAP     m_hLargeImage;
00030     HBITMAP     m_hOpenImage;
00031     HICON       m_hAppIcon;
00032
00033   public:
00034     CSnapinAbout();
00035     ~CSnapinAbout();
00036
00037     /////////////////////////////////////////////////////////////////////////
00038     // Interface IUnknown
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     /////////////////////////////////////////////////////////////////////////
00044     // Interface ISnapinAbout
00045     STDMETHODIMP GetSnapinDescription(/*[out]*/ LPOLESTR* pszDescription );
00046
00047     STDMETHODIMP GetProvider(/*[out]*/ LPOLESTR* pszProvider );
00048
00049     STDMETHODIMP GetSnapinVersion(/*[out]*/ LPOLESTR* pszVersion);
00050
00051     STDMETHODIMP GetSnapinImage(/*[out]*/ HICON* hAppIcon );
00052
00053     STDMETHODIMP GetStaticFolderImage
00054                  (/*[out]*/ HBITMAP*  hSmallImage,
00055                   /*[out]*/ HBITMAP*  hOpenImage,
00056                   /*[out]*/ HBITMAP*  hLargeImage,
00057                   /*[out]*/ COLORREF* cMask
00058                  );
00059 };
00060
00061 #endif _CLASS_CSNAPINABOUT_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/common.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

common.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module COMMON.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////////////////
00012 // Defines
00013 //
00014 /////////////////////////////////////////////////////////////////////////////
00015 #define DBINITCONSTANTS
00016 #define INITGUID
00017
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // Include
00021 //
00022 /////////////////////////////////////////////////////////////////////////////
00023 #include "Headers.h"
00024 #include <errno.h>    //ERANGE
00025
00026
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // Externs
00030 //
00031 //////////////////////////////////////////////////////////////////////////////
00032 CComPtr<IDataConvert> g_spDataConvert;
00033
00034
00035
00036 /////////////////////////////////////////////////////////////////////////////
00037 // IsUnicodeOS
00038 //
00039 /////////////////////////////////////////////////////////////////////////////
00040 BOOL IsUnicodeOS()
00041 {
00042   static BOOL fInitialized = FALSE;
00043   static BOOL fUnicode = TRUE;
00044
00045   //NOTE:  Don't call another other helper functions from within this function
00046   //that might also use the IsUnicodeOS flag, otherwise this will be an infinite loop...
00047
00048   if(!fInitialized)
00049   {
00050     HKEY hkJunk = HKEY_CURRENT_USER;
00051
00052     // Check to see if we have win95's broken registry, thus we do not have Unicode support
00053     if((RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE", 0, KEY_READ, &hkJunk) == S_OK) && hkJunk == HKEY_CURRENT_USER)
00054     {
00055       // Try the ANSI version
00056       if((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ, &hkJunk) == S_OK) && (hkJunk != HKEY_CURRENT_USER))
00057       {
00058         fUnicode = FALSE;
00059       }
00060     }
00061
00062     if(hkJunk != HKEY_CURRENT_USER)
00063       RegCloseKey(hkJunk);
00064     fInitialized = TRUE;
00065   }
00066
00067   return fUnicode;
00068 }
00069
00070
00071 /////////////////////////////////////////////////////////////////////////////
00072 // WCHAR* StringCopy
00073 //
00074 /////////////////////////////////////////////////////////////////////////////
00075 WCHAR* StringCopy(WCHAR* pwszDest, LPCWSTR pwszSource, DBLENGTH cMaxLen)
00076 {
00077   //Safe guard against overflow...
00078   WCHAR* pwszReturn = wcsncpy(pwszDest, pwszSource, (size_t)cMaxLen);
00079   if(cMaxLen)
00080   {
00081     pwszDest[cMaxLen-1] = wEOL;
00082   }
00083
00084   return pwszReturn;
00085 }
00086
00087 /////////////////////////////////////////////////////////////////////////////
00088 // WCHAR* StackFormat
00089 //
00090 /////////////////////////////////////////////////////////////////////////////
00091 WCHAR* StackFormat(LPCWSTR pwszFmt, ...)
00092 {
00093   va_list   marker;
00094
00095   ASSERT(pwszFmt);
00096   static WCHAR wszBuffer[MAX_QUERY_LEN];
00097   wszBuffer[0] = wEOL;
00098
00099   // Use format and arguements as input
00100   //This version will not overwrite the stack, since it only copies
00101   //upto the max size of the array
00102   va_start(marker, pwszFmt);
00103   _vsnwprintf(wszBuffer, NUMELE(wszBuffer), pwszFmt, marker);
00104   va_end(marker);
00105
00106   //Make sure there is a NULL Terminator, vsnwprintf will not copy
00107   //the terminator if length==MAX_QUERY_LEN
00108   wszBuffer[NUMELE(wszBuffer)-1] = wEOL;
00109   return wszBuffer;
00110 }
00111
00112 /////////////////////////////////////////////////////////////////////////////
00113 // WCHAR* StringFormat
00114 //
00115 /////////////////////////////////////////////////////////////////////////////
00116 WCHAR* StringFormat(WCHAR* pwszDest, DBLENGTH ulStrLen, LPCWSTR pwszFmt, ...)
00117 {
00118   ASSERT(pwszDest);
00119   ASSERT(ulStrLen);
00120   ASSERT(pwszFmt);
00121
00122   va_list   marker;
00123
00124   // Use format and arguements as input
00125   //This version will not overwrite the stack, since it only copies
00126   //upto the max size of the array
00127   va_start(marker, pwszFmt);
00128   _vsnwprintf(pwszDest, ulStrLen, pwszFmt, marker);
00129   va_end(marker);
00130
00131   //Make sure there is a NULL Terminator, vsnwprintf will not copy
00132   //the terminator if length==MAX_QUERY_LEN
00133   pwszDest[ulStrLen-1] = wEOL;
00134   return pwszDest;
00135 }
00136
00137
00138 /////////////////////////////////////////////////////////////////////////////
00139 // StringCompare
00140 //
00141 /////////////////////////////////////////////////////////////////////////////
00142 BOOL StringCompare(LPCWSTR pwsz1, LPCWSTR pwsz2)
00143 {
00144   //Safe guard against NULL...
00145   if(pwsz1 && pwsz2)
00146     return wcscmp(pwsz1, pwsz2)==0;
00147
00148   return pwsz1 == pwsz2;
00149 }
00150
00151
00152 /////////////////////////////////////////////////////////////////////////////
00153 // StringCompareI
00154 //
00155 /////////////////////////////////////////////////////////////////////////////
00156 BOOL StringCompareI(LPCWSTR pwsz1, LPCWSTR pwsz2)
00157 {
00158   //Safe guard against NULL...
00159   if(pwsz1 && pwsz2)
00160     return _wcsicmp(pwsz1, pwsz2)==0;
00161
00162   return pwsz1 == pwsz2;
00163 }
00164
00165 /////////////////////////////////////////////////////////////////////////////
00166 // CHAR* StringCopy
00167 //
00168 /////////////////////////////////////////////////////////////////////////////
00169 CHAR* StringCopy(CHAR* pszDest, LPCSTR pszSource, DBLENGTH cMaxLen)
00170 {
00171   //Safe guard against overflow...
00172   CHAR* pszReturn = strncpy(pszDest, pszSource, (size_t)cMaxLen);
00173   if(cMaxLen)
00174   {
00175     pszDest[cMaxLen-1] = EOL;
00176   }
00177
00178   return pszReturn;
00179 }
00180
00181
00182 /////////////////////////////////////////////////////////////////////////////
00183 // ConvertToMBCS
00184 //
00185 /////////////////////////////////////////////////////////////////////////////
00186 INT ConvertToMBCS(LPCWSTR pwsz, CHAR* psz, INT cchDst)
00187 {
00188   return ConvertToMBCS(pwsz, -1, psz, cchDst);
00189 }
00190
00191
00192 /////////////////////////////////////////////////////////////////////////////
00193 // INT ConvertToMBCS
00194 //
00195 /////////////////////////////////////////////////////////////////////////////
00196 INT ConvertToMBCS(LPCWSTR pwsz, INT cchSrc, CHAR* psz, INT cchDst)
00197 {
00198   //NOTE: The user can call this function with the Destination as NULL to indicate
00199   //just provide the length of the required conversion
00200
00201   //No source
00202   if(!pwsz && psz)
00203   {
00204     //Conveience for the caller:
00205     //always make sure the result is null-terminated - if their is enough room
00206     if(cchDst >= 1)
00207     {
00208       psz[0] = EOL;
00209       return 1;
00210     }
00211     return 0;
00212   }
00213
00214   //NOTE: WideCharToMultiByte destination buffer is really in (cb) count of bytes,
00215   //but to make things simplier since MultiByteToWideChar is opposite for the output
00216   //buffer, we will operate everything in cch - this is not a perf hit either since we don't
00217   //need a conversion since for CHAR -> cch == cb
00218   ASSERT(1/*cch*/ == sizeof(CHAR)/*cb*/);
00219
00220   //Convert the string to MBCS
00221   INT cchWritten = WideCharToMultiByte(CP_ACP, 0, pwsz, cchSrc/*cch*/, psz, cchDst/*cb*/, NULL, NULL);
00222
00223   //Since the buffer we passed in may be smaller than the actual data returned
00224   //we may not actually get to copy the NULL termintor, so make sure there is one at least
00225   //at the end of the buffer...
00226   if(cchDst && (cchDst < cchSrc))
00227   {
00228     cchWritten = cchDst;
00229     psz[cchWritten-1] = '\0';
00230   }
00231
00232   return cchWritten;
00233 }
00234
00235
00236 /////////////////////////////////////////////////////////////////////////////
00237 // ConvertToMBCS
00238 //    Dynamically allocated memory
00239 /////////////////////////////////////////////////////////////////////////////
00240 CHAR* ConvertToMBCS(LPCWSTR pwsz)
00241 {
00242   HRESULT hr = S_OK;
00243
00244   //no-op case
00245   if(!pwsz)
00246     return NULL;
00247
00248   //Determine the space required for the conversion
00249   INT iLen = ConvertToMBCS(pwsz, -1, NULL, 0);
00250
00251   //Allocate space for the string
00252   CHAR* pszBuffer = NULL;
00253   SAFE_ALLOC(pszBuffer, CHAR, iLen+1);
00254
00255   //Now convert the string
00256   ConvertToMBCS(pwsz, pszBuffer, iLen+1);
00257
00258 CLEANUP:
00259   return pszBuffer;
00260 }
00261
00262
00263 /////////////////////////////////////////////////////////////////////////////
00264 // ConvertToWCHAR
00265 //
00266 /////////////////////////////////////////////////////////////////////////////
00267 INT ConvertToWCHAR(LPCSTR psz, WCHAR* pwsz, INT cchDst)
00268 {
00269   //Delegate
00270   return ConvertToWCHAR(psz, -1, pwsz, cchDst);
00271 }
00272
00273
00274
00275 /////////////////////////////////////////////////////////////////////////////
00276 // ConvertToWCHAR
00277 //
00278 /////////////////////////////////////////////////////////////////////////////
00279 INT ConvertToWCHAR(LPCSTR psz, INT cchSrc, WCHAR* pwsz, INT cchDst)
00280 {
00281   //NOTE: The user can call this function with the Destination as NULL to indicate
00282   //just provide the length of the required conversion
00283
00284   //No source
00285   if(!psz && pwsz)
00286   {
00287     //Conveience for the caller:
00288     //always make sure the result is null-terminated - if their is enough room
00289     if(cchDst >= 1)
00290     {
00291       pwsz[0] = wEOL;
00292       return 1;
00293     }
00294     return 0;
00295   }
00296
00297   //NOTE: WideCharToMultiByte destination buffer is really in (cb) count of bytes,
00298   //but to make things simplier since MultiByteToWideChar is opposite for the output
00299   //buffer, we will operate everything in cch - this is not a perf hit either since we don't
00300   //need a conversion since for CHAR -> cch == cb
00301   ASSERT(1/*cch*/ == sizeof(CHAR)/*cb*/);
00302
00303   //Convert the string to MBCS
00304   INT cchWritten = MultiByteToWideChar(CP_ACP, 0, psz, cchSrc/*cb*/, pwsz, cchDst/*cch*/);
00305
00306   //Since the buffer we passed in may be smaller than the actual data returned
00307   //we may not actually get to copy the NULL termintor, so make sure there is one at least
00308   //at the end of the buffer...
00309   if(cchDst && (cchDst < cchSrc))
00310   {
00311     cchWritten = cchDst;
00312     pwsz[cchWritten-1] = L'\0';
00313   }
00314
00315   return cchWritten;
00316 }
00317
00318
00319 /////////////////////////////////////////////////////////////////////////////
00320 // HRESULT ConvertToWCHAR
00321 //    Dynamically allocated memory
00322 /////////////////////////////////////////////////////////////////////////////
00323 WCHAR* ConvertToWCHAR(LPCSTR psz)
00324 {
00325   HRESULT hr = S_OK;
00326
00327   //no-op case
00328   if(!psz)
00329     return NULL;
00330
00331   //Determine the space required for the conversion
00332   INT iLen = ConvertToWCHAR(psz, -1, NULL, 0);
00333
00334   //Allocate space for the string
00335   WCHAR* pwszBuffer = NULL;
00336   SAFE_ALLOC(pwszBuffer, WCHAR, iLen+1);
00337
00338   //Now convert the string
00339   ConvertToWCHAR(psz, pwszBuffer, iLen+1);
00340
00341 CLEANUP:
00342   return pwszBuffer;
00343 }
00344
00345
00346
00347 /////////////////////////////////////////////////////////////////////////////
00348 // HRESULT PostProcessString
00349 //
00350 /////////////////////////////////////////////////////////////////////////////
00351 HRESULT PostProcessString(WCHAR* pwsz, DBLENGTH ulMaxSize, DWORD dwFlags)
00352 {
00353   ASSERT(pwsz);
00354   ASSERT(ulMaxSize);
00355   WCHAR* pwszStop = NULL;
00356   LONG lValue = 0;
00357
00358   //Currently only deals with HEX or DECIMAL
00359   ASSERT(dwFlags & CONV_HEX || dwFlags & CONV_DECIMAL);
00360
00361   //Convert String to integer
00362   if(!ConvertToLONG(pwsz, &lValue, LONG_MIN, LONG_MAX, 0/*0 base indicates WinAPI to interpret*/))
00363     return E_FAIL;
00364
00365   //Convert Integer back to requested Format
00366   if(dwFlags & CONV_HEX)
00367     StringFormat(pwsz, ulMaxSize, L"0x%x", lValue);
00368   else
00369     StringFormat(pwsz, ulMaxSize, L"%d", lValue);
00370
00371   return S_OK;
00372 }
00373
00374
00375
00376 /////////////////////////////////////////////////////////////////////////////
00377 // HRESULT DataConvert
00378 //
00379 /////////////////////////////////////////////////////////////////////////////
00380 HRESULT DataConvert
00381 (
00382   DBSTATUS     dbSrcStatus,   // @parm IN | source data status
00383   DBLENGTH     cbSrcLength,   // @parm IN | size of source data
00384   DBLENGTH     cbSrcMaxLength,  // @parm IN | max size of input buffer
00385   DBTYPE       wSrcType,      // @parm IN | type of source data
00386   void*      pSrcValue,     // @parm IN | ptr to source data
00387   BYTE       bPrecision,    // @parm IN | precision to use for dst
00388   BYTE       bScale,      // @parm IN | scale to use for dst
00389
00390   DBTYPE       wDstType,      // @parm IN | type of output data
00391   DBSTATUS*    pdbDstStatus,    // @parm OUT | ptr to output data status
00392   DBLENGTH*    pcbDstLength,    // @parm OUT | ptr to size of output data
00393   void*      pDstValue,     // @parm OUT | ptr to output data
00394   DBLENGTH     cbDstMaxLength,  // @parm IN | max size of output buffer
00395   DWORD      dwConvFlags    // @parm IN | Conversion flags
00396 )
00397 {
00398   HRESULT hr = S_OK;
00399   if(pdbDstStatus)
00400     *pdbDstStatus = DBSTATUS_S_OK;
00401   if(pcbDstLength)
00402     *pcbDstLength = 0;
00403
00404
00405   //NOTE: cbSrcLength passed in is the actual length of the data (untruncated).
00406   //cbSrcMaxLength is the maximum size of the source (read) buffer thats valid.  This is useful to
00407   //seperate into two seperate items, since for String data this doesn't include the null terminator
00408   //and for fixed length it is the maximum.  But all data source is bound by cbSrcMaxLength...
00409   cbSrcLength = (wSrcType & DBTYPE_BYREF) ? cbSrcLength : min(cbSrcLength, cbSrcMaxLength);
00410
00411   //STATUS...
00412   switch(dbSrcStatus)
00413   {
00414     case DBSTATUS_S_ISNULL:
00415     case DBSTATUS_S_DEFAULT:
00416     case DBSTATUS_S_IGNORE:
00417       hr = S_OK;
00418       goto CLEANUP;
00419
00420     case DBSTATUS_S_TRUNCATED:
00421       hr = S_OK;
00422       break;
00423
00424     case DBSTATUS_S_OK:
00425       hr = S_OK;
00426       break;
00427
00428     default:
00429       hr = DB_E_CANTCONVERTVALUE;
00430       goto CLEANUP;
00431   };
00432
00433   //LENGTH...
00434
00435   //VALUE...
00436   if(!pSrcValue || !pDstValue)
00437     goto CLEANUP;
00438
00439   //Can we convert this "locally" without bringing in DC?
00440   if(!(dwConvFlags & CONV_MSDADC_ONLY))
00441   {
00442     switch(DBTYPE_SRC_DST(wSrcType, wDstType))
00443     {
00444       case DBTYPE_SRC_DST(DBTYPE_WSTR, DBTYPE_WSTR):
00445       {
00446         //cbSrcLength - doesn't account for Null terminator
00447         DBLENGTH cbSrcLengthPlusTerm  = min(cbSrcLength + sizeof(WCHAR), cbSrcMaxLength);
00448
00449         //VALUE
00450         //NOTE: We don't use wcscpy since user data could have embedded NULLs
00451         memcpy(pDstValue, pSrcValue, (size_t)(min(cbSrcLengthPlusTerm, cbDstMaxLength)));
00452
00453         //Since the buffer we passed in may be smaller than the actual data returned
00454         //we may not actually get to copy the NULL termintor, so make sure there is one at least
00455         //at the end of the buffer...
00456         if(cbDstMaxLength && (cbDstMaxLength < cbSrcLengthPlusTerm))
00457           ((WCHAR*)pDstValue)[cbDstMaxLength/sizeof(WCHAR)-1] = L'\0';
00458
00459         //LENGTH
00460         //NOTE: This doesn't include the NULL terminator
00461         if(pcbDstLength)
00462           *pcbDstLength = min(cbSrcLength, cbDstMaxLength);
00463         break;
00464       }
00465
00466       case DBTYPE_SRC_DST(DBTYPE_STR, DBTYPE_WSTR):
00467       {
00468         //cbSrcLength - doesn't account for Null terminator
00469         DBLENGTH cbSrcLengthPlusTerm  = min(cbSrcLength + sizeof(CHAR), cbSrcMaxLength);
00470
00471         //VALUE
00472         INT chWritten = ConvertToWCHAR((CHAR*)pSrcValue, (INT)cbSrcLengthPlusTerm/sizeof(CHAR), (WCHAR*)pDstValue, (INT)cbDstMaxLength/sizeof(WCHAR));
00473
00474         //NOTE: LENGTH doesn't include the NULL terminator
00475         if(pcbDstLength && chWritten)
00476           *pcbDstLength = (chWritten * sizeof(WCHAR)) - sizeof(WCHAR);
00477         break;
00478       }
00479
00480       case DBTYPE_SRC_DST(DBTYPE_WSTR, DBTYPE_STR):
00481       {
00482         //cbSrcLength - doesn't account for Null terminator
00483         DBLENGTH cbSrcLengthPlusTerm  = min(cbSrcLength + sizeof(WCHAR), cbSrcMaxLength);
00484
00485         //VALUE
00486         INT chWritten = ConvertToMBCS((WCHAR*)pSrcValue, (INT)cbSrcLengthPlusTerm/sizeof(WCHAR), (CHAR*)pDstValue, (INT)cbDstMaxLength/sizeof(CHAR));
00487
00488         //NOTE: LENGTH doesn't include the NULL terminator
00489         if(pcbDstLength && chWritten)
00490           *pcbDstLength   = (chWritten * sizeof(CHAR)) - sizeof(CHAR);
00491         break;
00492       }
00493
00494       case DBTYPE_SRC_DST(DBTYPE_VARIANT, DBTYPE_WSTR):
00495       {
00496         hr = VariantToString((VARIANT*)pSrcValue, (WCHAR*)pDstValue, cbDstMaxLength/sizeof(WCHAR), dwConvFlags);
00497
00498         //LENGTH
00499         //NOTE: This doesn't include the NULL terminator
00500         if(pcbDstLength)
00501           *pcbDstLength   = wcslen((WCHAR*)pDstValue)*sizeof(WCHAR);
00502         break;
00503       }
00504
00505       case DBTYPE_SRC_DST(DBTYPE_WSTR, DBTYPE_VARIANT):
00506       {
00507         VARIANT vVariant;
00508         V_VT(&vVariant) = VT_BSTR;
00509         V_BSTR(&vVariant) = SysAllocString((WCHAR*)pSrcValue);
00510         memcpy(pDstValue, &vVariant, sizeof(VARIANT));
00511
00512         //LENGTH
00513         if(pcbDstLength)
00514           *pcbDstLength   = sizeof(VARIANT);
00515         break;
00516       }
00517
00518       case DBTYPE_SRC_DST(DBTYPE_HCHAPTER, DBTYPE_WSTR):
00519       {
00520         //TODO
00521         IUnknown* pIUnknown = *(IUnknown**)pSrcValue;
00522         StringFormat((WCHAR*)pDstValue, cbDstMaxLength/sizeof(WCHAR), L"0x%p", pIUnknown);
00523
00524         //LENGTH
00525         //NOTE: This doesn't include the NULL terminator
00526         if(pcbDstLength)
00527           *pcbDstLength   = wcslen((WCHAR*)pDstValue)*sizeof(WCHAR);
00528         break;
00529       }
00530
00531       case DBTYPE_SRC_DST(DBTYPE_WSTR, DBTYPE_HCHAPTER):
00532       {
00533         //TODO - I have no clue how to update a hChapter columns?
00534         //But since we allow binding in the Accessor as native HCHAPTER we
00535         //need to support the SetData case, otherwise it will assert...
00536
00537         //LENGTH
00538         if(pcbDstLength)
00539           *pcbDstLength   = sizeof(HCHAPTER);
00540         break;
00541       }
00542
00543       default:
00544       {
00545         if(wSrcType & DBTYPE_VECTOR && wDstType == DBTYPE_WSTR)
00546         {
00547           hr = VectorToString((DBVECTOR*)pSrcValue, wSrcType, (WCHAR*)pDstValue, cbDstMaxLength/sizeof(WCHAR));
00548
00549           //LENGTH
00550           if(pcbDstLength)
00551             *pcbDstLength   = wcslen((WCHAR*)pDstValue)*sizeof(WCHAR);
00552           break;
00553         }
00554         else if(wDstType & DBTYPE_VECTOR && wSrcType == DBTYPE_WSTR)
00555         {
00556           hr = StringToVector((WCHAR*)pSrcValue, wDstType, (DBVECTOR*)pDstValue);
00557
00558           //LENGTH
00559           if(pcbDstLength)
00560             *pcbDstLength   = sizeof(DBVECTOR);
00561           break;
00562         }
00563         else if(wSrcType & DBTYPE_ARRAY && wDstType == DBTYPE_WSTR)
00564         {
00565           hr = SafeArrayToString(*(SAFEARRAY**)pSrcValue, wSrcType, (WCHAR*)pDstValue, cbDstMaxLength/sizeof(WCHAR));
00566
00567           //LENGTH
00568           if(pcbDstLength)
00569             *pcbDstLength   = wcslen((WCHAR*)pDstValue)*sizeof(WCHAR);
00570           break;
00571         }
00572         else if(wDstType & DBTYPE_ARRAY && wSrcType == DBTYPE_WSTR)
00573         {
00574           hr = StringToSafeArray((WCHAR*)pSrcValue, wDstType, (SAFEARRAY**)pDstValue);
00575
00576           //LENGTH
00577           if(pcbDstLength)
00578             *pcbDstLength   = sizeof(DBVECTOR);
00579           break;
00580         }
00581         else
00582         {
00583           //Unhandled Conversion?
00584           hr = DB_E_CANTCONVERTVALUE;
00585         }
00586       }
00587     };
00588   }
00589
00590   //Otherwise use the DataConversion Library...
00591   //Either we didn't support the conversion, or the user explcitly requested DC
00592   if((dwConvFlags & CONV_MSDADC_ONLY) || FAILED(hr))
00593   {
00594     //Obtain DataConversion library
00595     if(!g_spDataConvert)
00596       TESTC(hr = g_spDataConvert.CoCreateInstance(CLSID_OLEDB_CONVERSIONLIBRARY));
00597
00598     //Unable to obtain DC or not allowed to use it...
00599     if(!g_spDataConvert)
00600       TESTC(hr = DB_E_CANTCONVERTVALUE);
00601
00602     //We need to convert from the consumers type to ours...
00603     hr = g_spDataConvert->DataConvert(
00604         wSrcType,             // wSrcType
00605         wDstType,             // wDstType
00606         cbSrcLength,            // cbSrcLength
00607         pcbDstLength,           // pcbDstLength
00608         pSrcValue,              // pSrc
00609         pDstValue,              // pDst
00610         cbDstMaxLength,           // cbDstMaxLength
00611         dbSrcStatus,            // dbsSrcStatus
00612         pdbDstStatus,           // pdbsStatus
00613         bPrecision,             // bPrecision
00614         bScale,               // bScale
00615         0L );               // dwFlags
00616   }
00617
00618
00619 CLEANUP:
00620   return hr;
00621 }
00622
00623
00624
00625
00626 ///////////////////////////////////////////////////////////////
00627 // CVariant::CVariant
00628 //
00629 ///////////////////////////////////////////////////////////////
00630 CVariant::CVariant()
00631 {
00632   Init();
00633 }
00634
00635 ///////////////////////////////////////////////////////////////
00636 // CVariant::~CVariant
00637 //
00638 ///////////////////////////////////////////////////////////////
00639 CVariant::~CVariant()
00640 {
00641   Clear();
00642 }
00643
00644 ///////////////////////////////////////////////////////////////
00645 // CVariant::Init
00646 //
00647 ///////////////////////////////////////////////////////////////
00648 HRESULT CVariant::Init()
00649 {
00650   return VariantInitFast(this);
00651 }
00652
00653 ///////////////////////////////////////////////////////////////
00654 // CVariant::CVariant
00655 //
00656 ///////////////////////////////////////////////////////////////
00657 HRESULT CVariant::Clear()
00658 {
00659   return VariantClearFast(this);
00660 }
00661
00662
00663 ///////////////////////////////////////////////////////////////
00664 // CVariant::Attach
00665 //
00666 ///////////////////////////////////////////////////////////////
00667 HRESULT CVariant::Attach(VARIANT* pSrc)
00668 {
00669   ASSERT(pSrc);
00670
00671   //Clear the previous value
00672   HRESULT hr = Clear();
00673   if(SUCCEEDED(hr))
00674   {
00675     memcpy(this, pSrc, sizeof(VARIANT));
00676     pSrc->vt = VT_EMPTY;
00677   }
00678
00679   return hr;
00680 }
00681
00682
00683 ///////////////////////////////////////////////////////////////
00684 // CVariant::Detach
00685 //
00686 ///////////////////////////////////////////////////////////////
00687 HRESULT CVariant::Detach(VARIANT* pDest)
00688 {
00689   ASSERT(pDest);
00690
00691   //Clear the previous value
00692   HRESULT hr = VariantClearFast(pDest);
00693   if(SUCCEEDED(hr))
00694   {
00695     memcpy(pDest, this, sizeof(VARIANT));
00696     vt = VT_EMPTY;
00697   }
00698
00699   return hr;
00700 }
00701
00702
00703 ///////////////////////////////////////////////////////////////
00704 // CVariant::Copy
00705 //
00706 ///////////////////////////////////////////////////////////////
00707 HRESULT CVariant::Copy(VARIANT* pSrc)
00708 {
00709   ASSERT(pSrc);
00710   return VariantCopyFast(pSrc, this);
00711 }
00712
00713
00714 ///////////////////////////////////////////////////////////////
00715 // CVariant::ChangeType
00716 //
00717 ///////////////////////////////////////////////////////////////
00718 HRESULT CVariant::ChangeType(VARTYPE vt, VARIANT* pSrc)
00719 {
00720   //If NULL, we are doing an inplace conversion
00721   if(!pSrc)
00722     pSrc = this;
00723
00724   return VariantChangeFast(this, pSrc, ULONG_MAX, 0, vt);
00725 }
00726
00727
00728
00729 /////////////////////////////////////////////////////////////////////////////
00730 // HRESULT VariantInitFast
00731 //
00732 /////////////////////////////////////////////////////////////////////////////
00733 HRESULT VariantInitFast(VARIANT* pVariant)
00734 {
00735   ASSERT(pVariant);
00736   V_VT(pVariant) = VT_EMPTY;
00737
00738   return S_OK;
00739 }
00740
00741
00742 /////////////////////////////////////////////////////////////////////////////
00743 // HRESULT VariantClearFast
00744 //
00745 /////////////////////////////////////////////////////////////////////////////
00746 HRESULT VariantClearFast(VARIANT* pVariant)
00747 {
00748   ASSERT(pVariant);
00749   HRESULT hr = S_OK;
00750
00751   switch(V_VT(pVariant))
00752   {
00753     case VT_EMPTY:
00754       break;
00755
00756     case VT_NULL:
00757     case VT_I8:
00758       V_VT(pVariant) = VT_EMPTY;
00759       break;
00760
00761     default:
00762       //Nice to know if this fails, display error
00763       XTESTC(hr = VariantClear(pVariant));
00764       break;
00765   }
00766
00767 CLEANUP:
00768   return hr;
00769 }
00770
00771
00772
00773 /////////////////////////////////////////////////////////////////////////////
00774 // HRESULT VariantCopyFast
00775 //
00776 /////////////////////////////////////////////////////////////////////////////
00777 HRESULT VariantCopyFast(VARIANT* pVarDest, VARIANT* pVarSrc)
00778 {
00779   ASSERT(pVarDest);
00780   ASSERT(pVarSrc);
00781   HRESULT hr = S_OK;
00782
00783   //First Free the Destination.
00784   //NOTE: This is the same symmantics as VariantCopy.  We do this always since
00785   //we know how to clear other types as well...
00786   TESTC(hr = VariantClearFast(pVarDest));
00787
00788   //Now do the copy...
00789   switch(V_VT(pVarSrc))
00790   {
00791     case VT_EMPTY:
00792     case VT_NULL:
00793       V_VT(pVarDest) = V_VT(pVarSrc);
00794       break;
00795
00796     case VT_I8:
00797       V_VT(pVarDest) = V_VT(pVarSrc);
00798       pVarDest->ullVal = pVarSrc->ullVal;
00799       break;
00800
00801     default:
00802       //Nice to know if this fails, display error
00803       XTESTC(hr = VariantCopy(pVarDest, pVarSrc));
00804       break;
00805   };
00806
00807 CLEANUP:
00808   return hr;
00809 }
00810
00811
00812
00813 /////////////////////////////////////////////////////////////////////////////
00814 // VariantChangeFast
00815 //
00816 /////////////////////////////////////////////////////////////////////////////
00817 HRESULT VariantChangeFast(VARIANT* pVarDest, VARIANT* pVarSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
00818 {
00819   HRESULT hr = S_OK;
00820   static LCID lcidDef = GetSystemDefaultLCID();
00821
00822   //Delegate...
00823   TESTC(hr = VariantChangeTypeEx(
00824     pVarDest, // Destination (convert in place)
00825     pVarSrc,  // Source
00826     lcid != ULONG_MAX ? lcid : lcidDef,   // LCID
00827     wFlags,   // dwFlags
00828     vt ));
00829
00830
00831 CLEANUP:
00832   return hr;
00833 }
00834
00835
00836
00837 /////////////////////////////////////////////////////////////////////////////
00838 // HRESULT VariantToString
00839 //
00840 /////////////////////////////////////////////////////////////////////////////
00841 HRESULT VariantToString(VARIANT* pVariant, WCHAR* pwsz, DBLENGTH ulMaxSize, DWORD dwFlags)
00842 {
00843   //No-op
00844   if(!ulMaxSize)
00845     return S_OK;
00846
00847   //Convert a VARIANT to a WCHAR
00848   ASSERT(pVariant);
00849   ASSERT(pwsz);
00850   pwsz[0] = EOL;
00851
00852   //Find the VariantType
00853   DBTYPE wType = V_VT(pVariant);
00854   CVariant cVariant;
00855   HRESULT hr = S_OK;
00856
00857   //VT_ARRAY is not handled by VariantChangeType
00858   if(wType & VT_ARRAY)
00859   {
00860     TESTC(hr = SafeArrayToString(V_ARRAY(pVariant), wType, pwsz, ulMaxSize));
00861     goto CLEANUP;
00862   }
00863
00864   switch(wType)
00865   {
00866     case VT_NULL:
00867     case VT_EMPTY:
00868       //pwsz is already set to null terminator above
00869       break;
00870
00871     case VT_BOOL:
00872       if(V_BOOL(pVariant) == VARIANT_TRUE)
00873         StringFormat(pwsz, ulMaxSize, L"%s", dwFlags & CONV_VARBOOL ? L"VARIANT_TRUE" : L"True");
00874       else if(V_BOOL(pVariant) == VARIANT_FALSE)
00875         StringFormat(pwsz, ulMaxSize, L"%s", dwFlags & CONV_VARBOOL ? L"VARIANT_FALSE" : L"False");
00876       else
00877         StringFormat(pwsz, ulMaxSize, L"%d", V_BOOL(pVariant));
00878       break;
00879
00880     case VT_ERROR:
00881       StringFormat(pwsz, ulMaxSize, L"%d", V_ERROR(pVariant));
00882       break;
00883
00884     case VT_I8:
00885     {
00886       //TODO64: OLEAUT doesn't have support for this type yet, so we have to special case...
00887 //      StringFormat(pwsz, ulMaxSize, L"%ld", V_I8(pVariant));
00888       StringFormat(pwsz, ulMaxSize, L"%ld", pVariant->ullVal);
00889       break;
00890     }
00891
00892     default:
00893     {
00894       TESTC(hr = VariantChangeFast(
00895         &cVariant,  // Destination (convert not in place)
00896         pVariant, // Source
00897         ULONG_MAX,  // LCID
00898         0,      // dwFlags
00899         VT_BSTR ));
00900
00901       StringCopy(pwsz, V_BSTR(&cVariant), ulMaxSize);
00902
00903       //May need Hex postprocessing
00904       if(dwFlags & CONV_HEX)
00905       {
00906         switch(V_VT(pVariant))
00907         {
00908           case DBTYPE_I4:
00909             //"0x" + 10 characters
00910             if(ulMaxSize >= 12)
00911               StringFormat(pwsz, ulMaxSize, L"0x%x", V_I4(pVariant));
00912             break;
00913         }
00914       }
00915     }
00916   };
00917
00918 CLEANUP:
00919   pwsz[ulMaxSize ? ulMaxSize-1 : 0] = wEOL;
00920   return hr;
00921 }
00922
00923
00924 /////////////////////////////////////////////////////////////////////////////
00925 // HRESULT StringToVariant
00926 //
00927 /////////////////////////////////////////////////////////////////////////////
00928 HRESULT StringToVariant(WCHAR* pwsz, VARTYPE vt, VARIANT* pVariant, DWORD dwFlags)
00929 {
00930   //Convert a VARIANT to a WCHAR
00931   ASSERT(pVariant);
00932   HRESULT hr = S_OK;
00933
00934   //Assign the type...
00935   V_VT(pVariant) = vt;
00936
00937   //VT_ARRAY is not handled by VariantChangeType
00938   if(vt & VT_ARRAY)
00939   {
00940     SAFEARRAY* pSafeArray = NULL;
00941     TESTC(hr = StringToSafeArray(pwsz, vt, &pSafeArray));
00942     V_ARRAY(pVariant) = pSafeArray;
00943     goto CLEANUP;
00944   }
00945
00946   //VariantChangeType seems to handle most types,
00947   //except the following cases...
00948   switch(vt)
00949   {
00950     case VT_NULL:
00951     case VT_EMPTY:
00952       break;
00953
00954     case VT_BOOL:
00955     {
00956       //This type requires a string
00957       if(!pwsz)
00958         TESTC(hr = E_INVALIDARG);
00959
00960       if(dwFlags & CONV_VARBOOL && StringCompareI(pwsz, L"VARIANT_TRUE"))
00961         V_BOOL(pVariant) = VARIANT_TRUE;
00962       else if(dwFlags & CONV_VARBOOL && StringCompareI(pwsz, L"VARIANT_FALSE"))
00963         V_BOOL(pVariant) = VARIANT_FALSE;
00964       else if(dwFlags & CONV_ALPHABOOL && StringCompareI(pwsz, L"True"))
00965         V_BOOL(pVariant) = VARIANT_TRUE;
00966       else if(dwFlags & CONV_ALPHABOOL && StringCompareI(pwsz, L"False"))
00967         V_BOOL(pVariant) = VARIANT_FALSE;
00968       else
00969       {
00970         LONG lValue = 0;
00971         if(!ConvertToLONG(pwsz, &lValue, SHRT_MIN, SHRT_MAX, 0/*Base*/))
00972         {
00973           hr = E_FAIL;
00974           goto CLEANUP;
00975         }
00976         V_BOOL(pVariant) = (VARIANT_BOOL)lValue;
00977       }
00978       break;
00979     }
00980
00981     case VT_I4:
00982     case VT_ERROR:
00983     case VT_UI4:
00984     {
00985       //This type requires a string
00986       if(!pwsz)
00987         TESTC(hr = E_INVALIDARG);
00988
00989       //We handle this case seperatly since we want to handle HEX values
00990       WCHAR* pwszStop = NULL;
00991       BOOL fSigned = (vt != VT_UI4);
00992       errno = 0;
00993
00994       //Convert
00995       ULONG ulValue = vt==VT_UI4 ? wcstoul(pwsz, &pwszStop, 0) : wcstol(pwsz, &pwszStop, 0);
00996
00997       //Function stopped converting prematurely...
00998       if(pwszStop==NULL || pwszStop[0]!=wEOL || errno==ERANGE)
00999         TESTC(hr = E_FAIL);
01000
01001       V_UI4(pVariant) = ulValue;
01002       break;
01003     }
01004
01005     case VT_I8:
01006     {
01007       //This type requires a string
01008       if(!pwsz)
01009         TESTC(hr = E_INVALIDARG);
01010
01011       //TODO64: OLEAUT doesn't have support for this type yet, so we have to special case...
01012       LONGLONG llValue = _wtoi64(pwsz);
01013 //      V_I8(pVariant) = ulValue;
01014       pVariant->ullVal = llValue;
01015       break;
01016     }
01017
01018     case VT_VARIANT:
01019     {
01020       //Place the string into the BSTR of the VARIANT
01021       V_VT(pVariant) = VT_BSTR;
01022       V_BSTR(pVariant) = SysAllocString(pwsz);
01023       break;
01024     }
01025
01026     default:
01027     {
01028       //Place the string into the BSTR of the VARIANT
01029       V_VT(pVariant) = VT_BSTR;
01030       V_BSTR(pVariant) = SysAllocString(pwsz);
01031
01032       //Now delegate to VariantChangeType...
01033       TESTC(hr = VariantChangeFast(
01034         pVariant, // Destination (convert in place)
01035         pVariant, // Source
01036         ULONG_MAX,  // LCID
01037         0,      // dwFlags
01038         vt ));
01039     }
01040   };
01041
01042 CLEANUP:
01043   return hr;
01044 }
01045
01046
01047 /////////////////////////////////////////////////////////////////////////////
01048 // HRESULT SafeArrayToString
01049 //
01050 /////////////////////////////////////////////////////////////////////////////
01051 HRESULT SafeArrayToString(SAFEARRAY* pSafeArray, DBTYPE wType, WCHAR* pwszBuffer, DBLENGTH ulMaxSize)
01052 {
01053   ASSERT(pSafeArray);
01054   ASSERT(pwszBuffer);
01055
01056   //No-op
01057   if(!ulMaxSize)
01058     return S_OK;
01059
01060   //This method is capable of handling N-Dimenstions of Data!!
01061   //We need to take N-Dimensions of Data and convert it to a string
01062
01063   //For example:  We have a 3D data, where z-dim has 2 elements, y-Dim has 3 ele
01064   //and x-dim has 2 elements we end up with the following matrix of points
01065
01066   //  (z, y, x)  => value [[[
01067   //  (1, 1, 1)  => 1
01068   //  (1, 1, 2)  => 2
01069   //  (1, 2, 1)  => 3   ][
01070   //  (1, 2, 2)  => 4
01071   //  (1, 3, 1)  => 5   ][
01072   //  (1, 3, 2)  => 6
01073   //  (2, 1, 1)  => 7   ]][[
01074   //  (2, 1, 2)  => 8
01075   //  (2, 2, 1)  => 9   ][
01076   //  (2, 2, 2)  => A
01077   //  (2, 3, 1)  => B   ][
01078   //  (2, 3, 2)  => C
01079   //            ]]]
01080
01081   //So what we need to generate is a string of:
01082   //  [ [[1,2][3,4][5,6]] [[7,8][9,A][B,C]] ]
01083
01084   //The algorythm we are using is bascially based upon a "ripple" counter.
01085   //We keep a counter for each dimension.  So when CounterDim[0] hits the Upper
01086   //Limit, we increment CounterDim[1] and set CounterDim[0] back to LowerLimit.
01087   //This continues until all have reached the upper limit together:
01088   //{CounterDim[n-1]==UpperLimt, ... Dim[0]==UpperLimit}
01089
01090   //The braces are determined by rising/falling edges of the ripple counter.
01091   //Everytime a dimension restarts its value from Upper->Lower we see a "][".
01092   //So we have a pre and a post set of - "[[[" braces "]]]" for the number of dimensions.
01093   //You'll notices the set of braces in the above example on the rising/falling
01094   //edges of the ripple counter....
01095
01096   HRESULT hr = S_OK;
01097
01098   CVariant cVariant;
01099   WCHAR* pwsz = pwszBuffer;
01100   WCHAR* pwszEnd = pwsz + ulMaxSize;
01101
01102   ULONG i,iDim, ulInnerElements = 0;
01103   ULONG cDimensions = SafeArrayGetDim(pSafeArray);
01104   BOOL bDone = FALSE;
01105
01106   //No-op
01107   if(!cDimensions)
01108     return E_FAIL;
01109
01110   //Make sure there is no Array in the type
01111   wType &= ~VT_ARRAY;
01112   pwsz[0] = wEOL;
01113
01114   LONG* rgIndices = NULL;
01115   SAFE_ALLOC(rgIndices, LONG, cDimensions);
01116
01117   //Loop over all dimenstions and fill in "pre" info...
01118   for(iDim=0; iDim<cDimensions; iDim++)
01119   {
01120     //Fill in lower bound
01121     LONG lLowerBound = 0;
01122     SafeArrayGetLBound(pSafeArray, iDim+1, &lLowerBound);
01123     rgIndices[iDim] = lLowerBound;
01124
01125     //Fill in outer dimension indicater
01126     *pwsz = L'[';
01127     pwsz++;
01128   }
01129
01130   //Calculate the total number of inner items...
01131   //This is easy, all dimensions will have the same number "inner" items
01132   //IE:  rg[y][x] - all y arrays have x elements.
01133   //IE:  rg[z][y][x] - all z arrays, have y arrays, which have x elements
01134   ulInnerElements = pSafeArray->rgsabound[0].cElements;
01135   while(!bDone && (pwsz < pwszEnd))
01136   {
01137     //Dimension[0] always goes through a complete cycle every time
01138     //Just do this part of the ripple counter seperately...
01139     for(i=0; i<ulInnerElements; i++)
01140     {
01141       //Initialize Variant
01142       cVariant.Init();
01143
01144       //Obtain the data from the safe array...
01145       switch(wType)
01146       {
01147         case VT_EMPTY:
01148         case VT_NULL:
01149         case VT_I2:
01150         case VT_I4:
01151         case VT_R4:
01152         case VT_R8:
01153         case VT_CY:
01154         case VT_DATE:
01155         case VT_BSTR:
01156         case VT_DISPATCH:
01157         case VT_ERROR:
01158         case VT_BOOL:
01159         case VT_UNKNOWN:
01160         case VT_I1:
01161         case VT_UI1:
01162         case VT_UI2:
01163         case VT_UI4:
01164         case VT_I8:
01165         case VT_UI8:
01166         case VT_INT:
01167         case VT_UINT:
01168           //Otherwise if its a valid variant type, we can place it within
01169           //our variant as a subtype and delegate to VariantToString to
01170           //do the converion
01171           V_VT(&cVariant) = wType;
01172           TESTC(hr = SafeArrayGetElement(pSafeArray, rgIndices, &V_I4(&cVariant)));
01173           break;
01174
01175         case VT_VARIANT:
01176           //just place directly into our variant.
01177           TESTC(hr = SafeArrayGetElement(pSafeArray, rgIndices, &cVariant));
01178           break;
01179
01180         case VT_DECIMAL:
01181           //DECIMAL is not part of the VARIANT union
01182           V_VT(&cVariant)   = wType;
01183           TESTC(hr = SafeArrayGetElement(pSafeArray, rgIndices, &V_DECIMAL(&cVariant)));
01184           break;
01185
01186         default:
01187           //Unable to handle this type...
01188           TESTC(hr = E_FAIL);
01189       }
01190
01191       rgIndices[0]++;
01192
01193       //Convert VARIANT To String
01194       TESTC(hr = VariantToString(&cVariant, pwsz, pwszEnd - pwsz, CONV_NONE));
01195       pwsz += wcslen(pwsz);
01196
01197       //Array Seperator
01198       if(i<ulInnerElements-1 && (pwsz < pwszEnd))
01199       {
01200         *pwsz = L',';
01201         pwsz++;
01202       }
01203
01204       //Clear the Variant, (could be outofline memory...)
01205       XTEST(cVariant.Clear());
01206
01207       if(!(pwsz < pwszEnd))
01208         break;
01209     }
01210
01211     //Adjust the other Dimensions of the ripple counter
01212     for(iDim=0; iDim<cDimensions; iDim++)
01213     {
01214       LONG lUpperBound = 0;
01215       SafeArrayGetUBound(pSafeArray, iDim+1, &lUpperBound);
01216
01217       //Increment this ripple if below max bound, and exit out (break)
01218       if(rgIndices[iDim] < lUpperBound)
01219       {
01220         rgIndices[iDim]++;
01221
01222         //Need to add opening braces...
01223         for(ULONG j=iDim; j>0 && (pwsz < pwszEnd); j--)
01224         {
01225           *pwsz = L'[';
01226           pwsz++;
01227         }
01228         break;
01229       }
01230       //Otherwise reset this one and move onto the
01231       //next Dimension (ie: Don't break...)
01232       else if(iDim != cDimensions-1)
01233       {
01234         LONG lLowerBound = 0;
01235         SafeArrayGetLBound(pSafeArray, iDim+1, &lLowerBound);
01236         rgIndices[iDim] = lLowerBound;
01237
01238         if(pwsz < pwszEnd)
01239         {
01240           *pwsz = L']';
01241           pwsz++;
01242         }
01243       }
01244       //If we have hit the last Dimension and its over the value
01245       //This means were done...
01246       else
01247       {
01248         bDone = TRUE;
01249       }
01250     }
01251   }
01252
01253   //Display Right outer braces
01254   for(iDim=0; iDim<cDimensions && (pwsz < pwszEnd); iDim++)
01255   {
01256     *pwsz = L']';
01257     pwsz++;
01258   }
01259
01260 CLEANUP:
01261   SAFE_FREE(rgIndices);
01262   return hr;
01263 }
01264
01265
01266 /////////////////////////////////////////////////////////////////////////////
01267 // HRESULT StringToSafeArray
01268 //
01269 /////////////////////////////////////////////////////////////////////////////
01270 HRESULT StringToSafeArray(WCHAR* pwszBuffer, DBTYPE wType, SAFEARRAY** ppSafeArray)
01271 {
01272   ASSERT(ppSafeArray);
01273   if(!pwszBuffer)
01274     return E_INVALIDARG;
01275
01276   //We already know we need to create an array
01277   wType &= ~VT_ARRAY;
01278
01279   //This method is capable of handling N-Dimenstions of Data!!
01280   //We need to a String of N Dimensions and turn it into a SafeArray
01281
01282   //For example:  We have a 3D data, where z-dim has 2 elements, y-Dim has 3 ele
01283   //and x-dim has 2 elements we end up with the following matrix of points
01284
01285   //  (z, y, x)  => value [[[
01286   //  (1, 1, 1)  => 1
01287   //  (1, 1, 2)  => 2
01288   //  (1, 2, 1)  => 3   ][
01289   //  (1, 2, 2)  => 4
01290   //  (1, 3, 1)  => 5   ][
01291   //  (1, 3, 2)  => 6
01292   //  (2, 1, 1)  => 7   ]][[
01293   //  (2, 1, 2)  => 8
01294   //  (2, 2, 1)  => 9   ][
01295   //  (2, 2, 2)  => A
01296   //  (2, 3, 1)  => B   ][
01297   //  (2, 3, 2)  => C
01298   //            ]]]
01299
01300   //So we could be passed a string of:
01301   //  [ [[1,2][3,4][5,6]] [[7,8][9,A][B,C]] ]
01302
01303   //The algorythm we are using is bascially based upon a "ripple" counter.
01304   //We keep a counter for each dimension.  So when CounterDim[0] hits the Upper
01305   //Limit, we increment CounterDim[1] and set CounterDim[0] back to LowerLimit.
01306   //This continues until all have reached the upper limit together:
01307   //{CounterDim[n-1]==UpperLimt, ... Dim[0]==UpperLimit}
01308
01309   //The braces are determined by rising/falling edges of the ripple counter.
01310   //Everytime a dimension restarts its value from Upper->Lower we see a "][".
01311   //So we have a pre and a post set of - "[[[" braces "]]]" for the number of dimensions.
01312   //You'll notices the set of braces in the above example on the rising/falling
01313   //edges of the ripple counter....
01314
01315   HRESULT hr = S_OK;
01316   CVariant cVariant;
01317
01318   WCHAR wszBuffer[MAX_COL_SIZE];
01319   wszBuffer[0] = wEOL;
01320   WCHAR* pwsz = pwszBuffer;
01321
01322   ULONG i,iDim, ulInnerElements = 0;
01323
01324   //Determine the Number of Dimensions...
01325   ULONG cDimensions = 0;
01326   while(pwsz[0]==L'[')
01327   {
01328     cDimensions++;
01329     pwsz++;
01330     wcscat(wszBuffer, L"]");
01331   }
01332
01333   //Find the End of the Data (where everever "]...") is...
01334   WCHAR* pwszNext = pwsz;
01335   WCHAR* pwszEnd = pwsz;
01336   WCHAR* pwszCurEnd = wcschr(pwsz, L']');
01337
01338   //No-op
01339   if(cDimensions < 1)
01340     return E_FAIL;
01341
01342   //Create SafeArray
01343   SAFEARRAY* pSafeArray = NULL;
01344   *ppSafeArray = NULL;
01345
01346   LONG* rgIndices = NULL;
01347   SAFEARRAYBOUND* rgSafeArrayBounds = NULL;
01348
01349   //Indices array...
01350   SAFE_ALLOC(rgIndices, LONG, cDimensions);
01351   memset(rgIndices, 0, cDimensions * sizeof(LONG));
01352
01353   //SafeArrayBounds array...
01354   SAFE_ALLOC(rgSafeArrayBounds, SAFEARRAYBOUND, cDimensions);
01355   memset(rgSafeArrayBounds, 0, cDimensions*sizeof(SAFEARRAYBOUND));
01356
01357   //Need to find out how many elements are in Dim[0]
01358   //NOTE: <= 'Allow empty string safearrays'
01359   while(pwszNext && pwszNext <= pwszCurEnd)
01360   {
01361     ulInnerElements++;
01362     rgIndices[0]++;
01363     pwszNext = wcschr(pwszNext, L',');
01364     if(pwszNext)
01365       pwszNext++;
01366   }
01367
01368   //Now from the [] notation find out how many elements in the other dimenstions
01369   //  [ [[1,2][3,4][5,6]] [[7,8][9,A][B,C]] ]
01370
01371   //The algorythm we will use is:
01372   //Everytime we see a "]" we need to increment the next Dimension elements
01373   //Everytime we see a "[" we need to reset the previous Dimension elements
01374
01375   //TODO
01376   //Currently this algorythm only handles 1 dimension.
01377   //No reason it couldn't use the above method and work for more, just on
01378   //a time constraint, and the only provider we have supports max 1 dim...
01379
01380   ASSERT(cDimensions == 1);
01381
01382   //Create the SafeArrayBounds
01383   for(iDim=0; iDim<cDimensions; iDim++)
01384   {
01385     rgSafeArrayBounds[iDim].lLbound = 0;
01386     rgSafeArrayBounds[iDim].cElements = rgIndices[0];
01387   }
01388
01389   //Now actually create the SafeArray
01390   pSafeArray = SafeArrayCreate(wType, cDimensions, rgSafeArrayBounds);
01391   ASSERT(pSafeArray);
01392
01393   pwszCurEnd = wcschr(pwsz, L']');
01394   rgIndices[0] = 0;
01395   pwszNext = pwsz;
01396   for(i=0; i<ulInnerElements; i++)
01397   {
01398     //Obtain the start and end of the value
01399     pwszEnd = wcschr(pwszNext, L',');
01400     if(pwszEnd==NULL || pwszEnd>pwszCurEnd)
01401       pwszEnd = pwszCurEnd;
01402
01403     //Setup rgIndicaes
01404     rgIndices[0] = i;
01405
01406     //Convert Value to a Variant
01407     void* pValue = NULL;
01408     StringCopy(wszBuffer, pwszNext, pwszEnd-pwszNext+1);
01409     TESTC(hr = StringToVariant(wszBuffer, wType, &cVariant, CONV_NONE));
01410
01411     //Add this Value to the SafeArray
01412     //NOTE: According to the spec for SafeArrayPutElement
01413     //VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not require another level of indirection.
01414     switch(wType)
01415     {
01416       case VT_DISPATCH:
01417       case VT_UNKNOWN:
01418       case VT_BSTR:
01419         pValue = V_UNKNOWN(&cVariant);
01420         break;
01421
01422       case VT_VARIANT:
01423         pValue = &cVariant;
01424         break;
01425
01426       case VT_DECIMAL:
01427         //DECIMAL is not part of the VARIANT union
01428         pValue = &V_DECIMAL(&cVariant);
01429         break;
01430
01431       default:
01432         pValue = &V_I4(&cVariant);
01433         break;
01434     };
01435
01436     //Add this Value to the SafeArray
01437     TESTC(hr = SafeArrayPutElement(pSafeArray, rgIndices, pValue));
01438     XTEST(cVariant.Clear());
01439
01440     //Incement to next value...
01441     pwszNext = wcschr(pwszNext, L',');
01442     if(pwszNext)
01443       pwszNext += 1;
01444   }
01445
01446   //Everything complete successfully...
01447   *ppSafeArray = pSafeArray;
01448
01449 CLEANUP:
01450   SAFE_FREE(rgIndices);
01451   SAFE_FREE(rgSafeArrayBounds);
01452   return hr;
01453 }
01454
01455
01456 /////////////////////////////////////////////////////////////////////////////
01457 // HRESULT VectorToString
01458 //
01459 /////////////////////////////////////////////////////////////////////////////
01460 HRESULT VectorToString(DBVECTOR* pVector, DBTYPE wType, WCHAR* pwszBuffer, DBLENGTH ulMaxSize)
01461 {
01462   ASSERT(pVector);
01463   ASSERT(pwszBuffer);
01464   HRESULT hr = S_OK;
01465
01466   //No-op
01467   if(!ulMaxSize)
01468     return S_OK;
01469
01470   VARIANT Variant;
01471   VARIANT* pVariant = NULL;
01472   WCHAR* pwsz = pwszBuffer;
01473   WCHAR* pwszEnd = pwsz + ulMaxSize;
01474   pwsz[0] = wEOL;
01475
01476   //Make sure we are dealing with the base type...
01477   wType &= ~DBTYPE_VECTOR;
01478
01479   //Loop over the vector...
01480   for(ULONG iEle=0; iEle<pVector->size; iEle++)
01481   {
01482     //Initialize Variant
01483     pVariant = &Variant;
01484     pVariant->vt = VT_EMPTY;
01485
01486     //NOTE: The pVariant is really just a pointer to the data.  We don't free the data
01487     //since the vector data doesn't belong to us, we are just convering the given data to
01488     //a string.  The simplest way to do this is to dump into a variant and let our helper
01489     //function VariantToString deal with this...
01490
01491     //Obtain the data from the vector...
01492     switch(wType)
01493     {
01494       case VT_EMPTY:
01495       case VT_NULL:
01496         V_VT(pVariant) = wType;
01497         break;
01498
01499       case VT_I2:
01500       case VT_I4:
01501       case VT_R4:
01502       case VT_R8:
01503       case VT_CY:
01504       case VT_DATE:
01505       case VT_BSTR:
01506       case VT_DISPATCH:
01507       case VT_ERROR:
01508       case VT_BOOL:
01509       case VT_UNKNOWN:
01510       case VT_I1:
01511       case VT_UI1:
01512       case VT_UI2:
01513       case VT_UI4:
01514       case VT_I8:
01515       case VT_UI8:
01516       case VT_INT:
01517       case VT_UINT:
01518       {
01519         DBLENGTH ulTypeSize = 0;
01520         if(SUCCEEDED(GetDBTypeMaxSize(wType, &ulTypeSize)))
01521         {
01522           V_VT(pVariant) = wType;
01523           memcpy(&V_I4(pVariant), (BYTE*)pVector->ptr + (ulTypeSize*iEle), (size_t)ulTypeSize);
01524         }
01525         break;
01526       }
01527
01528       case VT_VARIANT:
01529         //just place directly into our variant.
01530         pVariant = (VARIANT*)((BYTE*)pVector->ptr + (sizeof(VARIANT)*iEle));
01531         break;
01532
01533       case VT_DECIMAL:
01534         //DECIMAL is not part of the VARIANT union
01535         V_VT(pVariant)    = wType;
01536         V_DECIMAL(pVariant) = *(DECIMAL*)((BYTE*)pVector->ptr + (sizeof(DECIMAL)*iEle));
01537         break;
01538
01539       default:
01540         //Unable to handle this type...
01541         TESTC(hr = E_FAIL);
01542     }
01543
01544     //Convert VARIANT To String
01545     TESTC(hr = VariantToString(pVariant, pwsz, pwszEnd - pwsz, CONV_NONE));
01546     pwsz += wcslen(pwsz);
01547
01548     //Vector Seperator
01549     if(iEle<pVector->size-1 && (pwsz < pwszEnd))
01550     {
01551       *pwsz = L',';
01552       pwsz++;
01553     }
01554   }
01555
01556 CLEANUP:
01557   return hr;
01558 }
01559
01560
01561 /////////////////////////////////////////////////////////////////////////////
01562 // HRESULT StringToVector
01563 //
01564 /////////////////////////////////////////////////////////////////////////////
01565 HRESULT StringToVector(WCHAR* pwszBuffer, DBTYPE wType, DBVECTOR* pVector)
01566 {
01567   ASSERT(pVector);
01568   if(!pwszBuffer)
01569     return E_INVALIDARG;
01570
01571   //Make sure we are dealing with the base type...
01572   wType &= ~DBTYPE_VECTOR;
01573
01574   HRESULT hr = S_OK;
01575   VARIANT Variant;
01576   VariantInitFast(&Variant);
01577
01578   WCHAR wszBuffer[MAX_COL_SIZE] = {0};
01579   ULONG iEle = 0;
01580
01581   //Determine the Number of Elements...
01582   pVector->size = 1;
01583   WCHAR* pwsz = pwszBuffer;
01584   while(pwsz = wcschr(pwsz, L','))
01585   {
01586     pVector->size++;
01587     pwsz++;
01588   }
01589
01590   //Obtain the size of each element
01591   DBLENGTH ulTypeSize = 0;
01592   if(FAILED(GetDBTypeMaxSize(wType, &ulTypeSize)))
01593     return hr;
01594
01595   //Alloc the vector...
01596   SAFE_ALLOC(pVector->ptr, BYTE, ulTypeSize*pVector->size);
01597
01598   pwsz = pwszBuffer;
01599   for(iEle=0; iEle<pVector->size; iEle++)
01600   {
01601     //Obtain the start and end of the value
01602     WCHAR* pwszEnd = wcschr(pwsz, L',');
01603     void* pElement = (BYTE*)pVector->ptr + (ulTypeSize*iEle);
01604
01605     //Convert Value to a Variant
01606     StringCopy(wszBuffer, pwsz, pwszEnd ? pwszEnd-pwsz+1 : MAX_COL_SIZE);
01607     TESTC(hr = StringToVariant(wszBuffer, wType, &Variant, CONV_NONE));
01608
01609     //Add this to the vector...
01610     switch(wType)
01611     {
01612       case VT_EMPTY:
01613       case VT_NULL:
01614         break;
01615
01616       case VT_I2:
01617         *(SHORT*)pElement = V_I2(&Variant);
01618         break;
01619
01620       case VT_I4:
01621       case VT_R4:
01622       case VT_R8:
01623       case VT_CY:
01624       case VT_DATE:
01625       case VT_BSTR:
01626       case VT_DISPATCH:
01627       case VT_ERROR:
01628       case VT_BOOL:
01629       case VT_UNKNOWN:
01630       case VT_I1:
01631       case VT_UI1:
01632       case VT_UI2:
01633       case VT_UI4:
01634       case VT_I8:
01635       case VT_UI8:
01636       case VT_INT:
01637       case VT_UINT:
01638         memcpy(pElement, &V_I4(&Variant), (size_t)ulTypeSize);
01639         break;
01640
01641       case VT_VARIANT:
01642         //just place directly into our variant.
01643         *(VARIANT*)pElement = Variant;
01644         break;
01645
01646       case VT_DECIMAL:
01647         *(DECIMAL*)pElement = V_DECIMAL(&Variant);
01648         break;
01649
01650
01651       default:
01652         //Unable to handle this type...
01653         TESTC(hr = E_NOTIMPL);
01654     };
01655
01656     //Incement to next value...
01657     pwsz = wcschr(pwsz, L',');
01658     if(pwsz)
01659       pwsz += 1;
01660   }
01661
01662 CLEANUP:
01663   return hr;
01664 }
01665
01666
01667 /////////////////////////////////////////////////////////////////////////////
01668 // CHAR* strDuplicate
01669 //
01670 /////////////////////////////////////////////////////////////////////////////
01671 CHAR* strDuplicate(LPCSTR psz)
01672 {
01673   HRESULT hr = S_OK;
01674
01675   //no-op case
01676   if(!psz)
01677     return NULL;
01678
01679   ULONG cLen  = strlen(psz);
01680
01681   //Allocate space for the string
01682   CHAR* pszBuffer = NULL;
01683   SAFE_ALLOC(pszBuffer, CHAR, cLen+1);
01684
01685   //Now copy the string
01686   strcpy(pszBuffer, psz);
01687
01688 CLEANUP:
01689   return pszBuffer;
01690 }
01691
01692
01693
01694 /////////////////////////////////////////////////////////////////////////////
01695 // WCHAR* wcsDuplicate
01696 //
01697 /////////////////////////////////////////////////////////////////////////////
01698 WCHAR* wcsDuplicate(LPCWSTR pwsz)
01699 {
01700   HRESULT hr = S_OK;
01701
01702   //no-op case
01703   if(!pwsz)
01704     return NULL;
01705
01706   ULONG cLen  = wcslen(pwsz);
01707
01708   //Allocate space for the string
01709   WCHAR* pwszBuffer = NULL;
01710   SAFE_ALLOC(pwszBuffer, WCHAR, cLen+1);
01711
01712   //Now copy the string
01713   StringCopy(pwszBuffer, pwsz, cLen+1);
01714
01715 CLEANUP:
01716   return pwszBuffer;
01717 }
01718
01719
01720
01721 /////////////////////////////////////////////////////////////////////////////
01722 // HRESULT DBIDToString
01723 //
01724 /////////////////////////////////////////////////////////////////////////////
01725 HRESULT DBIDToString(const DBID* pDBID, WCHAR* pwsz, ULONG ulMaxLen)
01726 {
01727   //No-op
01728   if(!ulMaxLen)
01729     return S_OK;
01730
01731   ASSERT(pwsz);
01732   WCHAR wszBuffer[MAX_NAME_LEN] = {0};
01733   pwsz[0] = wEOL;
01734
01735   //No-op
01736   if(pDBID == NULL)
01737   {
01738     StringCopy(pwsz, L"NULL", MAX_NAME_LEN);
01739     return S_OK;
01740   }
01741
01742   //ColumnID (SubItem)  DBID
01743   switch(pDBID->eKind)
01744   {
01745     case DBKIND_NAME:
01746       StringFormat(pwsz, ulMaxLen, L"{\"%s\"}", pDBID->uName.pwszName);
01747       break;
01748
01749     case DBKIND_PROPID:
01750       StringFormat(pwsz, ulMaxLen, L"{%ld}", pDBID->uName.ulPropid);
01751       break;
01752
01753     case DBKIND_GUID:
01754       StringFromGUID2(pDBID->uGuid.guid, pwsz, ulMaxLen);
01755       break;
01756
01757     case DBKIND_GUID_NAME:
01758       StringFromGUID2(pDBID->uGuid.guid, wszBuffer, MAX_NAME_LEN);
01759       StringFormat(pwsz, ulMaxLen, L"{%s,\"%s\"}", wszBuffer, pDBID->uName.pwszName);
01760       break;
01761
01762     case DBKIND_GUID_PROPID:
01763     {
01764       //Special Case:  Maybe this is a defined RowCol DBID
01765       WCHAR* pwszColName = GetRowColName(pDBID);
01766       if(pwszColName)
01767       {
01768         StringCopy(pwsz, pwszColName, ulMaxLen);
01769       }
01770       else
01771       {
01772         StringFromGUID2(pDBID->uGuid.guid, wszBuffer, MAX_NAME_LEN);
01773         StringFormat(pwsz, ulMaxLen, L"{%s,%ld}", wszBuffer, pDBID->uName.ulPropid);
01774       }
01775       break;
01776     }
01777
01778     case DBKIND_PGUID_NAME:
01779       if(pDBID->uGuid.pguid)
01780         StringFromGUID2(*pDBID->uGuid.pguid, wszBuffer, MAX_NAME_LEN);
01781       StringFormat(pwsz, ulMaxLen, L"{&%s,\"%s\"}", wszBuffer, pDBID->uName.pwszName);
01782       break;
01783
01784     case DBKIND_PGUID_PROPID:
01785       if(pDBID->uGuid.pguid)
01786         StringFromGUID2(*pDBID->uGuid.pguid, wszBuffer, MAX_NAME_LEN);
01787       StringFormat(pwsz, ulMaxLen, L"{&%s,%ld}", wszBuffer, pDBID->uName.ulPropid);
01788       break;
01789
01790     default:
01791       ASSERT(!"Unhandled Type!");
01792       break;
01793   };
01794
01795   //Make sure the resulting string is NULL terminated
01796   pwsz[ulMaxLen ? ulMaxLen-1 : 0] = wEOL;
01797   return S_OK;
01798 }
01799
01800
01801 /////////////////////////////////////////////////////////////////////////////
01802 // DBIDFree
01803 //
01804 /////////////////////////////////////////////////////////////////////////////
01805 void  DBIDFree(DBID* pDBID)
01806 {
01807   if(pDBID)
01808   {
01809     switch(pDBID->eKind)
01810     {
01811       case DBKIND_PGUID_NAME:
01812         SAFE_FREE(pDBID->uGuid.pguid);
01813         SAFE_FREE(pDBID->uName.pwszName);
01814         break;
01815
01816       case DBKIND_GUID_NAME:
01817       case DBKIND_NAME:
01818         SAFE_FREE(pDBID->uName.pwszName);
01819         break;
01820
01821       case DBKIND_PGUID_PROPID:
01822         SAFE_FREE(pDBID->uGuid.pguid);
01823         break;
01824     };
01825   }
01826 }
01827
01828
01829 /////////////////////////////////////////////////////////////////////////////
01830 // HRESULT DBIDCopy
01831 //
01832 /////////////////////////////////////////////////////////////////////////////
01833 HRESULT  DBIDCopy(DBID* pDst, const DBID* pSrc)
01834 {
01835   ASSERT(pDst && pSrc);
01836   HRESULT hr = S_OK;
01837
01838   //Simple case, no out-of-line data...
01839   memcpy(pDst, pSrc, sizeof(DBID));
01840
01841   //Now copy any outofline data...
01842   switch(pDst->eKind)
01843   {
01844     case DBKIND_PGUID_PROPID:
01845       pDst->uGuid.pguid = NULL;
01846       if(pSrc->uGuid.pguid)
01847       {
01848         SAFE_ALLOC(pDst->uGuid.pguid, GUID, 1);
01849         memcpy(pDst->uGuid.pguid, pSrc->uGuid.pguid, sizeof(GUID));
01850       }
01851       break;
01852
01853     case DBKIND_PGUID_NAME:
01854       pDst->uGuid.pguid = NULL;
01855       if(pSrc->uGuid.pguid)
01856       {
01857         SAFE_ALLOC(pDst->uGuid.pguid, GUID, 1);
01858         memcpy(pDst->uGuid.pguid, pSrc->uGuid.pguid, sizeof(GUID));
01859       }
01860       pDst->uName.pwszName = wcsDuplicate(pDst->uName.pwszName);
01861       break;
01862
01863     case DBKIND_GUID_NAME:
01864     case DBKIND_NAME:
01865       pDst->uName.pwszName = wcsDuplicate(pDst->uName.pwszName);
01866       break;
01867   };
01868
01869 CLEANUP:
01870   return hr;
01871 }
01872
01873
01874
01875 /////////////////////////////////////////////////////////////////////////////
01876 // HRESULT DBIDEqual
01877 //
01878 /////////////////////////////////////////////////////////////////////////////
01879 BOOL DBIDEqual(const DBID* pDst, const DBID* pSrc)
01880 {
01881   ASSERT(pDst && pSrc);
01882   BOOL bEqual = FALSE;
01883
01884   if(pDst->eKind == pSrc->eKind)
01885   {
01886     //Now compare sub-parts...
01887     switch(pDst->eKind)
01888     {
01889       case DBKIND_PGUID_NAME:
01890         if(bEqual = pDst->uGuid.pguid && pSrc->uGuid.pguid ? memcmp(pDst->uGuid.pguid, pSrc->uGuid.pguid, sizeof(GUID))==0 : pDst->uGuid.pguid == pSrc->uGuid.pguid)
01891           bEqual = StringCompare(pDst->uName.pwszName, pSrc->uName.pwszName);
01892         break;
01893
01894       case DBKIND_PGUID_PROPID:
01895         if(bEqual = pDst->uGuid.pguid && pSrc->uGuid.pguid ? memcmp(pDst->uGuid.pguid, pSrc->uGuid.pguid, sizeof(GUID))==0 : pDst->uGuid.pguid == pSrc->uGuid.pguid)
01896           bEqual = (pDst->uName.ulPropid == pSrc->uName.ulPropid);
01897         break;
01898
01899       case DBKIND_PROPID:
01900         bEqual = (pDst->uName.ulPropid == pSrc->uName.ulPropid);
01901         break;
01902
01903       case DBKIND_GUID_PROPID:
01904         bEqual = (pDst->uName.ulPropid == pSrc->uName.ulPropid);
01905         break;
01906
01907       case DBKIND_GUID:
01908         bEqual = memcmp(&pDst->uGuid.guid, &pSrc->uGuid.guid, sizeof(GUID))==0;
01909         break;
01910
01911       case DBKIND_GUID_NAME:
01912         if(bEqual = memcmp(&pDst->uGuid.guid, &pSrc->uGuid.guid, sizeof(GUID))==0)
01913           bEqual = StringCompare(pDst->uName.pwszName, pSrc->uName.pwszName);
01914         break;
01915
01916       case DBKIND_NAME:
01917         bEqual = StringCompare(pDst->uName.pwszName, pSrc->uName.pwszName);
01918         break;
01919
01920       default:
01921         break;
01922     };
01923
01924   }
01925
01926   //Otherwise
01927   return bEqual;
01928 }
01929
01930
01931
01932 /////////////////////////////////////////////////////////////////////////////
01933 // IsVariableType
01934 //
01935 /////////////////////////////////////////////////////////////////////////////
01936 BOOL IsVariableType(DBTYPE wType)
01937 {
01938   //According to OLE DB Spec Appendix A (Variable-Length Data Types)
01939   switch(wType)
01940   {
01941     case DBTYPE_STR:
01942     case DBTYPE_WSTR:
01943     case DBTYPE_BYTES:
01944     case DBTYPE_VARNUMERIC:
01945       return TRUE;
01946   }
01947   return FALSE;
01948 }
01949
01950
01951 /////////////////////////////////////////////////////////////////////////////
01952 // IsFixedType
01953 //
01954 /////////////////////////////////////////////////////////////////////////////
01955 BOOL IsFixedType(DBTYPE wType)
01956 {
01957   return !IsVariableType(wType);
01958 }
01959
01960 /////////////////////////////////////////////////////////////////////////////
01961 // IsNumericType
01962 //
01963 /////////////////////////////////////////////////////////////////////////////
01964 BOOL IsNumericType(DBTYPE wType)
01965 {
01966   //According to OLE DB Spec Appendix A (Numeric Data Types)
01967   switch(wType)
01968   {
01969     case DBTYPE_I1:
01970     case DBTYPE_I2:
01971     case DBTYPE_I4:
01972     case DBTYPE_I8:
01973     case DBTYPE_UI1:
01974     case DBTYPE_UI2:
01975     case DBTYPE_UI4:
01976     case DBTYPE_UI8:
01977     case DBTYPE_R4:
01978     case DBTYPE_R8:
01979     case DBTYPE_CY:
01980     case DBTYPE_DECIMAL:
01981     case DBTYPE_NUMERIC:
01982       return TRUE;
01983   }
01984   return FALSE;
01985 }
01986
01987
01988 /////////////////////////////////////////////////////////////////////////////
01989 // HRESULT GetDBTypeMaxSize
01990 //
01991 /////////////////////////////////////////////////////////////////////////////
01992 HRESULT GetDBTypeMaxSize(DBTYPE wType, DBLENGTH* pulMaxSize, BYTE* pbPrecision, BYTE* pbScale)
01993 {
01994   HRESULT   hr = S_OK;
01995
01996   //On failure we will set the column size to the max, so callers
01997   //don't have to condition this for normal unknown types...
01998   DBLENGTH  ulMaxSize = MAX_COL_SIZE;
01999   BYTE    bPrecision  = 0;
02000   BYTE    bScale    = 0;
02001
02002   //Values taken from OLE DB Spec, Appendix A
02003   //In some situations we need to know ulMaxSize, Prec, Scale, as defaults or creating
02004   //an accessor before we actually have ColumnsInfo.  Useful info, but mainly used
02005   //only for defaults for dialogs...
02006
02007   switch(wType)
02008   {
02009     case DBTYPE_EMPTY:
02010     case DBTYPE_NULL:
02011       ulMaxSize = 0;
02012       break;
02013
02014     case DBTYPE_STR:
02015     case DBTYPE_WSTR:
02016     case DBTYPE_BYTES:
02017     case DBTYPE_VARNUMERIC:
02018       ulMaxSize = MAX_COL_SIZE;
02019       break;
02020
02021     case DBTYPE_BSTR:
02022       ulMaxSize = sizeof(BSTR);
02023       break;
02024
02025     case DBTYPE_I1:
02026     case DBTYPE_UI1:
02027       ulMaxSize = 1;
02028       bPrecision = 3;
02029       break;
02030
02031     case DBTYPE_I2:
02032     case DBTYPE_UI2:
02033       ulMaxSize = 2;
02034       bPrecision = 5;
02035       break;
02036
02037     case DBTYPE_I4:
02038     case DBTYPE_UI4:
02039       ulMaxSize = 4;
02040       bPrecision = 10;
02041       break;
02042
02043     case DBTYPE_I8:
02044       ulMaxSize = 8;
02045       bPrecision = 19;
02046       break;
02047
02048     case DBTYPE_UI8:
02049       ulMaxSize = 8;
02050       bPrecision = 20;
02051       break;
02052
02053     case DBTYPE_R4:
02054       ulMaxSize = sizeof(float);
02055       bPrecision = 7;
02056       break;
02057
02058     case DBTYPE_R8:
02059       ulMaxSize = sizeof(double);
02060       bPrecision = 16;
02061       break;
02062
02063     case DBTYPE_CY:
02064       ulMaxSize = 8;
02065       bPrecision = 19;
02066       break;
02067
02068     case DBTYPE_NUMERIC:
02069       ulMaxSize = sizeof(DB_NUMERIC);
02070       bPrecision = 38;
02071       break;
02072
02073     case DBTYPE_DATE:
02074       ulMaxSize = sizeof(double);
02075       break;
02076
02077     case DBTYPE_BOOL:
02078       ulMaxSize = 2;
02079       break;
02080
02081     case DBTYPE_VARIANT:
02082       ulMaxSize = sizeof(VARIANT);
02083       break;
02084
02085     case DBTYPE_IDISPATCH:
02086     case DBTYPE_IUNKNOWN:
02087       ulMaxSize = sizeof(IUnknown*);
02088       break;
02089
02090     case DBTYPE_GUID:
02091       ulMaxSize = sizeof(GUID);
02092       break;
02093
02094     case DBTYPE_ERROR:
02095       ulMaxSize = sizeof(SCODE);
02096       break;
02097
02098     case DBTYPE_DBDATE:
02099       ulMaxSize = sizeof(DBDATE);
02100       break;
02101
02102     case DBTYPE_DBTIME:
02103       ulMaxSize = sizeof(DBTIME);
02104       break;
02105
02106     case DBTYPE_DBTIMESTAMP:
02107       ulMaxSize = sizeof(DBTIMESTAMP);
02108       break;
02109
02110     case DBTYPE_DECIMAL:
02111       ulMaxSize = sizeof(DECIMAL);
02112       bPrecision = 28;
02113       break;
02114
02115     default:
02116       //DBTYPE_BYREF
02117       if(wType & DBTYPE_BYREF)
02118       {
02119         ulMaxSize = sizeof(void*);
02120       }
02121       //DBTYPE_ARRAY
02122       else if(wType & DBTYPE_ARRAY)
02123       {
02124         ulMaxSize = sizeof(SAFEARRAY*);
02125       }
02126       //DBTYPE_VECTOR
02127       else if(wType & DBTYPE_VECTOR)
02128       {
02129         ulMaxSize = sizeof(DBVECTOR*);
02130       }
02131       else
02132       {
02133         //On failure we will set the column size to the max (already done above), so callers
02134         //don't have to condition this for normal unknown types...
02135         hr = E_FAIL;
02136       }
02137       break;
02138   };
02139
02140   if(pulMaxSize)
02141     *pulMaxSize = ulMaxSize;
02142   if(pbPrecision)
02143     *pbPrecision = bPrecision;
02144   if(pbScale)
02145     *pbScale = bScale;
02146   return hr;
02147 }
02148
02149
02150
02151 /////////////////////////////////////////////////////////////////////////////
02152 // WCHAR* GetDBTypeName
02153 //
02154 /////////////////////////////////////////////////////////////////////////////
02155 WCHAR* GetDBTypeName(DBTYPE wType)
02156 {
02157   return GetBitMapName(wType, g_cDBTypes, g_rgDBTypes, DBTYPE_VECTOR | DBTYPE_ARRAY | DBTYPE_BYREF | DBTYPE_RESERVED/*dwBitStart*/);
02158 }
02159
02160
02161 /////////////////////////////////////////////////////////////////////////////
02162 // DBTYPE GetDBType
02163 //
02164 /////////////////////////////////////////////////////////////////////////////
02165 DBTYPE GetDBType(WCHAR* pwsz)
02166 {
02167   return (DBTYPE)GetMapName(pwsz, g_cDBTypes, g_rgDBTypes);
02168 }
02169
02170
02171 /////////////////////////////////////////////////////////////////////////////
02172 // WCHAR* GetVariantTypeName
02173 //
02174 /////////////////////////////////////////////////////////////////////////////
02175 WCHAR* GetVariantTypeName(VARTYPE vt)
02176 {
02177   return GetBitMapName(vt, g_cVariantTypes, g_rgVariantTypes, VT_VECTOR | VT_ARRAY | VT_BYREF | VT_RESERVED/*dwBitStart*/);
02178 }
02179
02180
02181 /////////////////////////////////////////////////////////////////////////////
02182 // WCHAR* GetVariantTypeName
02183 //
02184 /////////////////////////////////////////////////////////////////////////////
02185 DBTYPE GetVariantType(WCHAR* pwsz)
02186 {
02187   return (DBTYPE)GetMapName(pwsz, g_cVariantTypes, g_rgVariantTypes);
02188 }
02189
02190
02191
02192 ///////////////////////////////////////////////////////////////
02193 // FreeData
02194 //
02195 ///////////////////////////////////////////////////////////////
02196 HRESULT FreeData(DBTYPE wType, DBLENGTH cData, void* rgData)
02197 {
02198   //no-op
02199   if(!rgData)
02200     return S_OK;
02201
02202   //Loop over all elements of the array
02203   for(ULONG i=0; i<cData; i++)
02204   {
02205     //Free any "out-of-line" memory
02206     switch(wType)
02207     {
02208       case DBTYPE_BSTR:
02209       {
02210         BSTR* pbstr = &((BSTR*)rgData)[i];
02211         SAFE_BSTRFREE(*pbstr);
02212         break;
02213       }
02214
02215       case DBTYPE_VARIANT:
02216       {
02217         VARIANT* pVariant = &((VARIANT*)rgData)[i];
02218         VariantClearFast(pVariant);
02219         break;
02220       }
02221
02222       case DBTYPE_IDISPATCH:
02223       case DBTYPE_IUNKNOWN:
02224       {
02225         IUnknown* pIUnknown = ((IUnknown**)rgData)[i];
02226         SAFE_RELEASE(pIUnknown);
02227         break;
02228       }
02229
02230       case DBTYPE_VARNUMERIC:
02231       case DBTYPE_PROPVARIANT:
02232         //TODO:
02233         break;
02234
02235       default:
02236       {
02237         //NOTE: All the modifiers are mutually exclusive.
02238
02239         //DBTYPE_BYREF
02240         if(wType & DBTYPE_BYREF)
02241         {
02242           void* pByRef  = ((void**)rgData)[i];
02243
02244           //Free any outofline sub elements, (recursive)
02245           FreeData(wType & ~DBTYPE_BYREF, 1, pByRef);
02246
02247           //Free the allocated block
02248           SAFE_FREE(pByRef);
02249         }
02250
02251         //DBTYPE_VECTOR
02252         else if(wType & DBTYPE_VECTOR)
02253         {
02254           DBVECTOR* pVector = &((DBVECTOR*)rgData)[i];
02255
02256           //Free any outofline sub elements, (recursive)
02257           FreeData(wType & ~DBTYPE_VECTOR, pVector->size, pVector->ptr);
02258
02259           //Free the block of memory
02260           SAFE_FREE(pVector->ptr);
02261         }
02262
02263         //DBTYPE_ARRAY
02264         else if(wType & DBTYPE_ARRAY)
02265         {
02266           SAFEARRAY** ppSafeArray = &((SAFEARRAY**)rgData)[i];
02267           if(*ppSafeArray)
02268             SafeArrayDestroy(*ppSafeArray);
02269           *ppSafeArray = NULL;
02270         }
02271
02272         break;
02273       }
02274     };
02275   }
02276
02277   return S_OK;
02278 }
02279
02280
02281 ///////////////////////////////////////////////////////////////
02282 // FreeBindingData
02283 //
02284 ///////////////////////////////////////////////////////////////
02285 HRESULT FreeBindingData(DBCOUNTITEM cBindings, const DBBINDING* rgBindings, void* pData, BOOL fSetData)
02286 {
02287   //Need to walk the array and free any other alloc memory
02288   for(ULONG i=0; i<cBindings; i++)
02289   {
02290     //First make sure we have valid data...
02291     if(!VALUE_IS_BOUND(rgBindings[i]) || !STATUS_IS_BOUND(rgBindings[i]))
02292       continue;
02293
02294     //Free any "out-of-line" memory
02295     DBSTATUS dbStatus = BINDING_STATUS(rgBindings[i], pData);
02296     switch(dbStatus)
02297     {
02298       case DBSTATUS_S_OK:
02299       case DBSTATUS_S_TRUNCATED:
02300       case DBSTATUS_S_ALREADYEXISTS:
02301         //Always free in successful status (either Getting or Setting).
02302         if(rgBindings[i].dwMemOwner == DBMEMOWNER_CLIENTOWNED)
02303           FreeData(rgBindings[i].wType, 1, &BINDING_VALUE(rgBindings[i], pData));
02304         break;
02305
02306       case DBSTATUS_S_ISNULL:
02307       case DBSTATUS_S_DEFAULT:
02308       case DBSTATUS_S_IGNORE:
02309         //Nothing to do in either case Getting or Setting.
02310         //In Getting data in undefined, in Setting the value was never setup...
02311         break;
02312
02313       default:
02314         //Otherwise data is undefined for retrieval from the provider (GetData, GetColumns, etc)
02315         //But for Setting (SetData, InsertRow, SetColumns, etc), we created the data
02316         //which has to be free'd even if the provider failed.
02317
02318         //NOTE: For IUnknown columns the provider releases on Setting, but instead of
02319         //having special logic all over, we AddRef the Stream an extra time before
02320         //setting, so it can always be released like the rest of the data and doesn't
02321         //have to be special cased...
02322
02323 //        if(fSetData && rgBindings[i].dwMemOwner == DBMEMOWNER_CLIENTOWNED)
02324 //          FreeData(rgBindings[i].wType, 1, &BINDING_VALUE(rgBindings[i], pData));
02325         break;
02326     }
02327   }
02328
02329   return S_OK;
02330 }
02331
02332
02333 ///////////////////////////////////////////////////////////////
02334 // FreeBindings
02335 //
02336 ///////////////////////////////////////////////////////////////
02337 HRESULT CopyBinding(DBBINDING* pDest, DBBINDING* pSource)
02338 {
02339   ASSERT(pDest);
02340   ASSERT(pSource);
02341   HRESULT hr = S_OK;
02342
02343   //First just memcopy the inline info
02344   memcpy(pDest, pSource, sizeof(DBBINDING));
02345
02346   //Now we need to allocate any out-of-line info
02347   if(pSource->pObject)
02348   {
02349     SAFE_ALLOC(pDest->pObject, DBOBJECT, 1);
02350     memcpy(pDest->pObject, pSource->pObject, sizeof(DBOBJECT));
02351   }
02352
02353 CLEANUP:
02354   return hr;
02355 }
02356
02357
02358 ///////////////////////////////////////////////////////////////
02359 // FreeBindings
02360 //
02361 ///////////////////////////////////////////////////////////////
02362 HRESULT FreeBindings(DBCOUNTITEM* pcBindings, DBBINDING** prgBindings)
02363 {
02364   ASSERT(pcBindings);
02365   ASSERT(prgBindings);
02366
02367   //Need to walk the array and free any other alloc memory
02368   for(ULONG i=0; i<*pcBindings; i++)
02369   {
02370     //Free any pObjects
02371     if(*prgBindings)
02372       SAFE_FREE((*prgBindings)[i].pObject);
02373   }
02374
02375   //Now we can free the outer struct
02376   *pcBindings = 0;
02377   SAFE_FREE(*prgBindings);
02378   return S_OK;
02379 }
02380
02381
02382 ///////////////////////////////////////////////////////////////
02383 // FreeColAccess
02384 //
02385 ///////////////////////////////////////////////////////////////
02386 HRESULT FreeColAccess(ULONG* pcColAccess, DBCOLUMNACCESS** prgColAccess, void** ppData)
02387 {
02388   ASSERT(pcColAccess);
02389   ASSERT(prgColAccess);
02390
02391   //Now we can free the outer struct
02392   *pcColAccess = 0;
02393   SAFE_FREE(*prgColAccess);
02394   SAFE_FREE(*ppData);
02395   return S_OK;
02396 }
02397
02398
02399
02400 ///////////////////////////////////////////////////////////////
02401 // FreeConstraintDesc
02402 //
02403 ///////////////////////////////////////////////////////////////
02404 HRESULT FreeConstraintDesc(
02405   DBORDINAL*      pcConsDesc,
02406   DBCONSTRAINTDESC**  prgConsDesc,
02407   BOOL        fFree
02408 )
02409 {
02410   DBORDINAL     indexCol;
02411   DBCONSTRAINTDESC  *rgConsDesc;
02412
02413   ASSERT(pcConsDesc);
02414   ASSERT(prgConsDesc);
02415
02416   rgConsDesc = *prgConsDesc;
02417   for(DBORDINAL index = 0; index<*pcConsDesc; index++)
02418   {
02419     // release the current element
02420     DBIDFree(rgConsDesc[index].pConstraintID);
02421     SAFE_FREE(rgConsDesc[index].pConstraintID);
02422
02423     DBIDFree(rgConsDesc[index].pReferencedTableID);
02424     SAFE_FREE(rgConsDesc[index].pReferencedTableID);
02425
02426     SAFE_FREE(rgConsDesc[index].pwszConstraintText);
02427
02428     for (indexCol = 0; indexCol < rgConsDesc[index].cColumns; indexCol++)
02429       DBIDFree(&rgConsDesc[index].rgColumnList[indexCol]);
02430
02431     SAFE_FREE(rgConsDesc[index].rgColumnList);
02432
02433     for (indexCol = 0; indexCol < rgConsDesc[index].cForeignKeyColumns; indexCol++)
02434       DBIDFree(&rgConsDesc[index].rgForeignKeyColumnList[indexCol]);
02435
02436     SAFE_FREE(rgConsDesc[index].rgForeignKeyColumnList);
02437   }
02438
02439   //Now we can free the outer struct
02440   *pcConsDesc = 0;
02441   if(fFree)
02442     SAFE_FREE(*prgConsDesc);
02443   return S_OK;
02444 }
02445
02446
02447
02448 /////////////////////////////////////////////////////////////////
02449 // WCHAR* GetColName
02450 //
02451 /////////////////////////////////////////////////////////////////
02452 WCHAR* GetColName(const DBCOLUMNINFO* pColInfo)
02453 {
02454   static WCHAR* pwszNullName = L"<NULL>";
02455   static WCHAR* pwszEmptyName = L"<Empty>";
02456   static WCHAR* pwszBookmarkName = L"<Bookmark>";
02457
02458   //Providers are not required to return a Column Name for any column
02459   //Useful information, but some columns (ie: Bookmarks) and others
02460   //May not have a column name.  So this method will either just return
02461   //whatever the provider returned or will generate an appropiate one if not...
02462   //We really need a column name to help for the GUI headers
02463
02464   if(pColInfo == NULL)
02465     return NULL;
02466
02467   WCHAR* pwszColName = pColInfo->pwszName;
02468   if(pColInfo->iOrdinal == 0)
02469   {
02470     //Bookmark
02471     if(!pwszColName || !pwszColName[0])
02472       pwszColName = pwszBookmarkName;
02473   }
02474   else
02475   {
02476     //otherwise
02477     if(!pwszColName || !pwszColName[0])
02478     {
02479       //If this is a DBID defined column
02480       if(pColInfo->columnid.eKind == DBKIND_GUID_PROPID)
02481         pwszColName = GetRowColName(&pColInfo->columnid);
02482     }
02483   }
02484
02485   //Handle Boundaries
02486   if(!pwszColName)
02487     pwszColName = pwszNullName;
02488   else if(!pwszColName[0])
02489     pwszColName = pwszEmptyName;
02490
02491   ASSERT(pwszColName);
02492   return pwszColName;
02493 }
02494
02495
02496
02497 /////////////////////////////////////////////////////////////////
02498 // GetMaxDisplaySize
02499 //
02500 /////////////////////////////////////////////////////////////////
02501 DBLENGTH GetMaxDisplaySize(DBTYPE wBindingType, DBTYPE wBackendType, DBLENGTH ulColumnSize, DBLENGTH ulMaxVarSize)
02502 {
02503   //Obtain the correct number of bytes to respresent the data in the wBindingType format.
02504   //NOTE: For variable types, the bytes will be bounded by ulMaxVarSize (cbMaxLen), for
02505   //fixed length type bindings, the size will be bounded by the type, (ie: NOT ulMaxVarSize),
02506   //since the provider ignores cbMaxLen for fixed length types and assumes their is enough
02507   //storage for the type...
02508   DBLENGTH cbMaxLen = 0;
02509
02510   //May need to adjust the MaxLen, depending upon what the BindingType is
02511   switch(wBindingType)
02512   {
02513     //Strings are kind of a pain.  Although we get the luxury of
02514     //Having the provider coerce the type, we need to allocate a buffer
02515     //large enough for the provider to store the type in "string" format
02516     case DBTYPE_STR:
02517     case DBTYPE_WSTR:
02518     {
02519       switch(wBackendType)
02520       {
02521         case DBTYPE_NULL:
02522         case DBTYPE_EMPTY:
02523           //Don't need much room for these...
02524           cbMaxLen = 0 + 1;
02525           break;
02526
02527         case DBTYPE_I1:
02528         case DBTYPE_I2:
02529         case DBTYPE_I4:
02530         case DBTYPE_UI1:
02531         case DBTYPE_UI2:
02532         case DBTYPE_UI4:
02533         case DBTYPE_R4:
02534         case DBTYPE_HCHAPTER:
02535           //All of the above fit well into 15 characters of display size
02536           cbMaxLen = 15 + 1;
02537           break;
02538
02539         case DBTYPE_I8:
02540         case DBTYPE_UI8:
02541         case DBTYPE_R8:
02542         case DBTYPE_CY:
02543         case DBTYPE_ERROR:
02544         case DBTYPE_BOOL:
02545           //All of the above fit well into 25 characters of display size
02546           cbMaxLen = 25 + 1;
02547           break;
02548
02549         case DBTYPE_DECIMAL:
02550         case DBTYPE_NUMERIC:
02551         case DBTYPE_DATE:
02552         case DBTYPE_DBDATE:
02553         case DBTYPE_DBTIMESTAMP:
02554         case DBTYPE_GUID:
02555           //All of the above fit well into 50 characters of display size
02556           cbMaxLen = 50 + 1;
02557           break;
02558
02559         case DBTYPE_BYTES:
02560           //Bytes -> String, 1 byte = 2 Ascii chars. (0xFF == "FF")
02561           cbMaxLen = min(ulColumnSize, ulMaxVarSize) * 2 + 1;
02562           break;
02563
02564         case DBTYPE_STR:
02565         case DBTYPE_WSTR:
02566           //String -> String
02567           //ulColumnSize already contains the length
02568           cbMaxLen = min(ulColumnSize, ulMaxVarSize) + 1;
02569           break;
02570
02571         case DBTYPE_IUNKNOWN:
02572         case DBTYPE_IDISPATCH:
02573           cbMaxLen = sizeof(IUnknown*);
02574           break;
02575
02576         default:
02577           //For everything else
02578           //Just default to our largest buffer size
02579           cbMaxLen = ulMaxVarSize;
02580           break;
02581       };
02582
02583       //Adjust for Unicode strings
02584       if(wBindingType == DBTYPE_WSTR)
02585         cbMaxLen *= 2;
02586
02587       //Make sure variable types are bounded by the maximum variable size,
02588       //since we are binding this is a string (STR/WSTR)
02589       cbMaxLen = min(cbMaxLen, ulMaxVarSize);
02590       break;
02591     }
02592
02593     default:
02594     {
02595       //Otherwise were not binding it as an inline string, so we don't need to know the
02596       //total formating string length, we can simply specify the size of the type...
02597
02598       //NOTE: On failure this function already sets the maxlen to the max for unrecognized types.
02599       GetDBTypeMaxSize(wBindingType, &cbMaxLen);
02600
02601       //Make sure variable types are bounded by the maximum variable size.
02602       //We can't do this for fixed length types since the provider assumes this memory
02603       //is at least the size of the data type...
02604       if(IsVariableType(wBindingType))
02605         cbMaxLen = min(cbMaxLen, ulMaxVarSize);
02606       break;
02607     }
02608   };
02609
02610   return cbMaxLen;
02611 }
02612
02613
02614 /////////////////////////////////////////////////////////////////////
02615 // Helper Functions
02616 //
02617 /////////////////////////////////////////////////////////////////////
02618 void*  SetThis(HWND hWnd, void* pThis)
02619 {
02620   ASSERT(hWnd);
02621   void* pPrev = (void*)SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);
02622
02623   //NOTE: We need to help prevent the case of overwriting the "this" pointer
02624   //in a nested senario.  If you hit this assert a subwindow has subclassed the window
02625   //as well.  By replacing the this pointer, the previous window will lose the correct
02626   //class assoicted with it.
02627   ASSERT(!pPrev || !pThis || pPrev == pThis);
02628
02629   //Return the current value...
02630   return pThis;
02631 }
02632
02633 void*  GetThis(HWND hWnd)
02634 {
02635   //Return the current value...
02636   ASSERT(hWnd);
02637   return (void*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
02638 }
02639
02640
02641 //////////////////////////////////////////////////////////////////
02642 // SyncSibling
02643 //
02644 //////////////////////////////////////////////////////////////////
02645 void SyncSibling(HWND hToWnd, HWND hFromWnd)
02646 {
02647   ASSERT(hToWnd && hFromWnd);
02648
02649   //Make both windows synched,
02650   //Get the current selection from the Source
02651   INDEX iItem = (INDEX)SendMessage(hFromWnd, LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)LVNI_SELECTED);
02652
02653   //Tell the Target to select the same selection
02654   if(iItem != LVM_ERR)
02655   {
02656     //Get the current selection from the Target and Unselect it
02657     INDEX iOldItem = (INDEX)SendMessage(hToWnd, LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)LVNI_SELECTED);
02658     if(iItem != iOldItem)
02659     {
02660       //Unselect previous one
02661       LV_SetItemState(hToWnd, iOldItem, 0, 0, LVIS_SELECTED);
02662
02663       //Select the new one
02664       LV_SetItemState(hToWnd, iItem, 0, LVIS_SELECTED, LVNI_SELECTED);
02665
02666       //Ensure that it is visible
02667       SendMessage(hToWnd, LVM_ENSUREVISIBLE, (WPARAM)iItem, (LPARAM)FALSE);
02668     }
02669   }
02670 }
02671
02672
02673
02674 typedef struct _SynchInfo
02675 {
02676   WNDPROC wpProc;
02677   HWND  hWndSynch;
02678 } SYNCHINFO;
02679
02680
02681 ////////////////////////////////////////////////////////////////
02682 // SynchSubProc
02683 //
02684 /////////////////////////////////////////////////////////////////
02685 INT_PTR WINAPI SynchSubProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
02686 {
02687   SYNCHINFO* pSynchInfo = (SYNCHINFO*)GetThis(hWnd);
02688   static BOOL fInsideSend = FALSE;
02689
02690   switch(message)
02691   {
02692     case WM_INITDIALOG:
02693     {
02694       //SubClass
02695       pSynchInfo = new SYNCHINFO;
02696       pSynchInfo->wpProc    = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC);
02697       pSynchInfo->hWndSynch = (HWND)lParam;
02698
02699       SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)SynchSubProc);
02700       SetThis(hWnd, (void*)pSynchInfo);
02701       return 0;
02702     }
02703
02704     case WM_DESTROY:
02705       SetThis(hWnd, NULL);
02706       SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)pSynchInfo->wpProc);
02707       SAFE_DELETE(pSynchInfo);
02708       break;
02709
02710     case WM_VSCROLL:
02711       if(!fInsideSend)
02712       {
02713         //Send a synch message to the other control
02714         fInsideSend = TRUE;
02715         SendMessage(pSynchInfo->hWndSynch, message, wParam, lParam);
02716         fInsideSend = FALSE;
02717       }
02718       break;
02719   }
02720
02721   if(pSynchInfo && pSynchInfo->wpProc)
02722     return CallWindowProc(pSynchInfo->wpProc, hWnd, message, wParam, lParam);
02723   return TRUE;
02724 }
02725
02726
02727
02728 //////////////////////////////////////////////////////////////////
02729 // InternalTrace
02730 //
02731 //////////////////////////////////////////////////////////////////
02732 void InternalTrace(LPCWSTR pwszText)
02733 {
02734   //NOTE:  We have a fixed argument version and a variable version (...), since
02735   //we have problems with calls to a variable length version and trying to use the '%'
02736   //operator as a real character and not as a format specifier...
02737
02738   if(pwszText)
02739   {
02740     if(IsUnicodeOS())
02741     {
02742       OutputDebugStringW(pwszText);
02743     }
02744     else
02745     {
02746       //Output to the DebugWindow
02747       CHAR szBuffer[MAX_QUERY_LEN];
02748       ConvertToMBCS(pwszText, szBuffer, MAX_QUERY_LEN);
02749       OutputDebugStringA(szBuffer);
02750     }
02751   }
02752 }
02753
02754
02755 //////////////////////////////////////////////////////////////////
02756 // InternalTraceFmt
02757 //
02758 //////////////////////////////////////////////////////////////////
02759 void InternalTraceFmt(LPCWSTR pwszFmt, ...)
02760 {
02761   va_list   marker;
02762   WCHAR   wszBuffer[MAX_QUERY_LEN];
02763
02764   // Use format and arguements as input
02765   //This version will not overwrite the stack, since it only copies
02766   //upto the max size of the array
02767   va_start(marker, pwszFmt);
02768   _vsnwprintf(wszBuffer, MAX_QUERY_LEN, pwszFmt, marker);
02769   va_end(marker);
02770
02771   //Make sure there is a NULL Terminator, vsnwprintf will not copy
02772   //the terminator if length==MAX_QUERY_LEN
02773   wszBuffer[MAX_QUERY_LEN-1] = wEOL;
02774
02775   //Delegate
02776   InternalTrace(wszBuffer);
02777 }
02778
02779
02780 //////////////////////////////////////////////////////////////////
02781 // CenterDialog
02782 //
02783 //////////////////////////////////////////////////////////////////
02784 BOOL CenterDialog(HWND hdlg)
02785 {
02786   RECT  rcParent;                         // Parent window client rect
02787   RECT  rcDlg;                            // Dialog window rect
02788   int   nLeft, nTop;                      // Top-left coordinates
02789   int   cWidth, cHeight;                  // Width and height
02790   HWND  hwnd;
02791
02792   // Get frame window client rect in screen coordinates
02793   hwnd = GetParent(hdlg);
02794   if(hwnd == NULL || hwnd == GetDesktopWindow())
02795   {
02796     rcParent.top = rcParent.left = 0;
02797     rcParent.right = GetSystemMetrics(SM_CXFULLSCREEN);
02798     rcParent.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
02799   }
02800   else
02801   {
02802     GetWindowRect(hwnd, &rcParent);
02803   }
02804
02805   // Determine the top-left point for the dialog to be centered
02806   GetWindowRect(hdlg, &rcDlg);
02807   cWidth  = rcDlg.right  - rcDlg.left;
02808   cHeight = rcDlg.bottom - rcDlg.top;
02809   nLeft   = rcParent.left +
02810             (((rcParent.right  - rcParent.left) - cWidth ) / 2);
02811   nTop    = rcParent.top  +
02812             (((rcParent.bottom - rcParent.top ) - cHeight) / 2);
02813   if (nLeft < 0) nLeft = 0;
02814   if (nTop  < 0) nTop  = 0;
02815
02816   // Place the dialog
02817   return MoveWindow(hdlg, nLeft, nTop, cWidth, cHeight, TRUE);
02818 }
02819
02820
02821 //////////////////////////////////////////////////////////////////
02822 // MoveWindow
02823 //
02824 //////////////////////////////////////////////////////////////////
02825 BOOL MoveWindow(HWND hWnd, ULONG x, ULONG y)
02826 {
02827   RECT  rcParent;                         // Parent window client rect
02828   RECT  rcDlg;                            // Dialog window rect
02829   int   nLeft, nTop;                      // Top-left coordinates
02830   int   cWidth, cHeight;                  // Width and height
02831   HWND  hWndParent;
02832
02833   // Get frame window client rect in screen coordinates
02834   hWndParent = GetParent(hWnd);
02835   if(hWndParent == NULL || hWndParent == GetDesktopWindow())
02836   {
02837     rcParent.top = rcParent.left = 0;
02838     rcParent.right = GetSystemMetrics(SM_CXFULLSCREEN);
02839     rcParent.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
02840   }
02841   else
02842     GetWindowRect(hWndParent, &rcParent);
02843
02844   // Determine the top-left point for the dialog to be centered
02845   GetWindowRect(hWnd, &rcDlg);
02846   cWidth  = rcDlg.right  - rcDlg.left;
02847   cHeight = rcDlg.bottom - rcDlg.top;
02848   nLeft   = rcParent.left + x;
02849   nTop    = rcParent.top + y;
02850
02851   // Place the dialog
02852   return MoveWindow(hWnd, nLeft, nTop, cWidth, cHeight, TRUE);
02853 }
02854
02855
02856 //////////////////////////////////////////////////////////////////
02857 // GetWindowPos
02858 //
02859 //////////////////////////////////////////////////////////////////
02860 BOOL GetWindowPos(HWND hWnd, POINTS* pPTS)
02861 {
02862   ASSERT(pPTS);
02863
02864   RECT rect;
02865   if(GetWindowRect(hWnd, &rect))
02866   {
02867     pPTS->x = (SHORT)rect.left;
02868     pPTS->y = (SHORT)rect.top;
02869   }
02870
02871   return FALSE;
02872 }
02873
02874
02875 //////////////////////////////////////////////////////////////////
02876 // GetWindowSize
02877 //
02878 //////////////////////////////////////////////////////////////////
02879 SIZE GetWindowSize(HWND hWnd)
02880 {
02881   RECT rect = { 0,0,0,0 };
02882   SIZE size = { 0,0 };
02883
02884   //Obtain window cordinates.
02885   if(GetWindowRect(hWnd, &rect))
02886   {
02887     //Fillin SIZE struct
02888     size.cx = rect.right - rect.left;
02889     size.cy = rect.bottom - rect.top;
02890   }
02891   return size;
02892 }
02893
02894
02895 //////////////////////////////////////////////////////////////////
02896 // GetClientSize
02897 //
02898 //////////////////////////////////////////////////////////////////
02899 SIZE GetClientSize(HWND hWnd)
02900 {
02901   RECT rect = { 0,0,0,0 };
02902   SIZE size = { 0,0 };
02903
02904   //Obtain window cordinates.
02905   if(GetClientRect(hWnd, &rect))
02906   {
02907     //Fillin SIZE struct
02908     size.cx = rect.right - rect.left;
02909     size.cy = rect.bottom - rect.top;
02910   }
02911   return size;
02912 }
02913
02914
02915 //////////////////////////////////////////////////////////////////
02916 // GetClientCoords
02917 //
02918 //////////////////////////////////////////////////////////////////
02919 RECT GetClientCoords(HWND hWndParent, HWND hWnd)
02920 {
02921   //Need the Boundary Rectangle in Client Coordinates, with
02922   //respect to the parent window...
02923   RECT rect, rectClientCoords;
02924   GetWindowRect(hWnd, &rect);
02925
02926   POINT ptTopLeft = { rect.left, rect.top };
02927   ScreenToClient(hWndParent, &ptTopLeft);
02928   POINT ptBottomRight = { rect.right, rect.bottom };
02929   ScreenToClient(hWndParent, &ptBottomRight);
02930
02931   rectClientCoords.top    = ptTopLeft.y;
02932   rectClientCoords.left   = ptTopLeft.x;
02933   rectClientCoords.bottom   = ptBottomRight.y;
02934   rectClientCoords.right    = ptBottomRight.x;
02935   return rectClientCoords;
02936 }
02937
02938 //////////////////////////////////////////////////////////////////
02939 // wMessageBox
02940 //
02941 //////////////////////////////////////////////////////////////////
02942 INT wMessageBox(
02943   HWND hwnd,              // Parent window for message display
02944   UINT uiStyle,           // Style of message box
02945   WCHAR* pwszTitle,         // Title for message
02946   WCHAR* pwszFmt,           // Format string
02947   ...                 // Substitution parameters
02948   )
02949 {
02950   va_list   marker;
02951   WCHAR   wszBuffer[MAX_QUERY_LEN];
02952
02953   // Use format and arguements as input
02954   //This version will not overwrite the stack, since it only copies
02955   //upto the max size of the array
02956   va_start(marker, pwszFmt);
02957   _vsnwprintf(wszBuffer, MAX_QUERY_LEN, pwszFmt, marker);
02958   va_end(marker);
02959
02960   //Make sure there is a NULL Terminator, vsnwprintf will not copy
02961   //the terminator if length==MAX_QUERY_LEN
02962   wszBuffer[MAX_QUERY_LEN-1] = wEOL;
02963
02964   //Unicode version is supported on both Win95/WinNT
02965   return MessageBoxW(hwnd, wszBuffer, pwszTitle, uiStyle);
02966 }
02967
02968
02969 //////////////////////////////////////////////////////////////////
02970 // wSendMessage
02971 //
02972 //////////////////////////////////////////////////////////////////
02973 LRESULT wSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, WCHAR* pwszText)
02974 {
02975   LRESULT lResult = 0;
02976   HRESULT hr = S_OK;
02977
02978   if(IsUnicodeOS())
02979   {
02980     //WinNT - Unicode, no need for conversions...
02981     lResult = SendMessageW(hWnd, Msg, (WPARAM)wParam, (LPARAM)pwszText);
02982   }
02983   else
02984   {
02985     //Win95 - Unicode not supported...
02986     CHAR szBuffer[MAX_QUERY_LEN] = { 0, 0, 0, 0 };
02987     ULONG ulDestSize = MAX_QUERY_LEN;
02988     CHAR* psz = szBuffer;
02989
02990     //All messages that have [input] strings
02991     switch(Msg)
02992     {
02993       case EM_GETLINE:
02994         ((WORD*)psz)[0] = MAX_QUERY_LEN;
02995         break;
02996
02997       case WM_GETTEXT:
02998         //We may need to dynamically allocate this...
02999         if(wParam > MAX_QUERY_LEN)
03000           SAFE_ALLOC(psz, CHAR, wParam);
03001         break;
03002
03003       case EM_GETSELTEXT:
03004         ASSERT(wParam && "wSendMessage EM_GETSELTEXT requires a length so the conversion buffer so it doesn't overflow...");
03005         ulDestSize = (ULONG)wParam;
03006
03007         //We may need to dynamically allocate this...
03008         if(wParam > MAX_QUERY_LEN)
03009           SAFE_ALLOC(psz, CHAR, wParam);
03010         wParam = 0;
03011         break;
03012
03013       case SB_SETTEXTW:
03014         Msg = SB_SETTEXT;
03015
03016       case WM_SETTEXT:
03017       case EM_REPLACESEL:
03018       case CB_FINDSTRINGEXACT:
03019       case CB_FINDSTRING:
03020       case CB_ADDSTRING:
03021       case LB_ADDSTRING:
03022       case SB_SETTEXTA:
03023         //Convert to ANSI before sending
03024         //We may need to dynamically allocate this...
03025         if(!ConvertToMBCS(pwszText, psz, MAX_QUERY_LEN))
03026           psz = ConvertToMBCS(pwszText);
03027         break;
03028     };
03029
03030     //Send the message with an ANSI Buffer
03031     lResult = SendMessageA(hWnd, Msg, (WPARAM)wParam, (LPARAM)psz);
03032
03033     //All messages that have [output] messages (return strings)
03034     switch(Msg)
03035     {
03036       case WM_GETTEXT:
03037         //Now convert the result into the users WCHAR buffer
03038         //wParam indicates the max length
03039         ConvertToWCHAR(psz, pwszText, (INT)wParam);
03040         break;
03041
03042       case EM_GETLINE:
03043         //Now convert the result into the users WCHAR buffer
03044         ASSERT(pwszText);
03045         ConvertToWCHAR(psz, pwszText, ((WORD*)pwszText)[0]);
03046         break;
03047
03048       case CB_GETLBTEXT:
03049       case EM_GETSELTEXT:
03050       case LB_GETTEXT:
03051         //Now convert the result into the users WCHAR buffer
03052         ConvertToWCHAR(psz, pwszText, ulDestSize);
03053         break;
03054     };
03055
03056     //Free any dynamically allocated memory
03057     if(psz != szBuffer)
03058       SAFE_FREE(psz);
03059   }
03060
03061 CLEANUP:
03062   return lResult;
03063 }
03064
03065
03066 //////////////////////////////////////////////////////////////////
03067 // wSendMessageFmt
03068 //
03069 //////////////////////////////////////////////////////////////////
03070 LRESULT wSendMessageFmt(HWND hWnd, UINT Msg, WPARAM wParam, WCHAR* pwszFmt, ...)
03071 {
03072   ASSERT(pwszFmt);
03073   ASSERT(wParam != WM_GETTEXT);
03074
03075   va_list   marker;
03076   WCHAR   wszBuffer[MAX_QUERY_LEN];
03077
03078   // Use format and arguements as input
03079   //This version will not overwrite the stack, since it only copies
03080   //upto the max size of the array
03081   va_start(marker, pwszFmt);
03082   _vsnwprintf(wszBuffer, MAX_QUERY_LEN, pwszFmt, marker);
03083   va_end(marker);
03084
03085   //Make sure there is a NULL Terminator, vsnwprintf will not copy
03086   //the terminator if length==MAX_QUERY_LEN
03087   wszBuffer[MAX_QUERY_LEN-1] = wEOL;
03088
03089   //Delegate
03090   return wSendMessage(hWnd, Msg, wParam, wszBuffer);
03091 }
03092
03093
03094 //////////////////////////////////////////////////////////////////
03095 // WCHAR wGetWindowText
03096 //
03097 //////////////////////////////////////////////////////////////////
03098 WCHAR* wGetWindowText(HWND hWnd)
03099 {
03100   //Dynamic Memory Version of the the WinAPI GetWindowText
03101   WCHAR* pwsz = NULL;
03102   HRESULT hr = S_OK;
03103
03104   //First obtain the length of the string
03105   LRESULT iLength = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
03106   if(iLength>0)
03107   {
03108     LRESULT iActLength = 0;
03109
03110     //Allocate our string
03111     SAFE_ALLOC(pwsz, WCHAR, iLength+1);
03112
03113     //Now get the text from the window...
03114     iActLength = wSendMessage(hWnd, WM_GETTEXT, iLength+1, pwsz);
03115
03116     //Ensure NULL terminated...
03117     pwsz[iActLength>0 ? min(iActLength, iLength) : 0] = wEOL;
03118   }
03119
03120 CLEANUP:
03121   return pwsz;
03122 }
03123
03124
03125 //////////////////////////////////////////////////////////////////
03126 // ConvertToLONG
03127 //
03128 //////////////////////////////////////////////////////////////////
03129 BOOL ConvertToLONG(LPCWSTR pwszText, LONG* plValue, LONG lMin, LONG lMax, INT iBase)
03130 {
03131   ASSERT(plValue);
03132   if(!pwszText || !pwszText[0])
03133     return FALSE;
03134
03135   errno = 0;
03136   WCHAR*  pwszEnd = NULL;
03137
03138   //Convert to LONG
03139   LONG lValue = wcstol(pwszText, &pwszEnd, iBase);
03140   if(errno==ERANGE || !pwszText[0] || lValue<lMin || lValue>lMax || pwszEnd==NULL || pwszEnd[0]!=wEOL)
03141     return FALSE;
03142
03143   //Only change the input value on success...
03144   *plValue = lValue;
03145   return TRUE;
03146 }
03147
03148
03149 //////////////////////////////////////////////////////////////////
03150 // GetEditBoxValue
03151 //
03152 //////////////////////////////////////////////////////////////////
03153 BOOL GetEditBoxValue(HWND hEditWnd, LONG* plValue, LONG lMin, LONG lMax, BOOL fAllowEmpty)
03154 {
03155   ASSERT(hEditWnd);
03156   ASSERT(plValue);
03157   WCHAR wszBuffer[MAX_QUERY_LEN] = {0};
03158
03159   //Get the EditText
03160   wSendMessage(hEditWnd, WM_GETTEXT, MAX_QUERY_LEN, wszBuffer);
03161   if(wszBuffer[0] || !fAllowEmpty)
03162   {
03163     //Delegate
03164     if(!wszBuffer[0] || !ConvertToLONG(wszBuffer, plValue, lMin, lMax))
03165     {
03166       wMessageBox(hEditWnd, MB_TASKMODAL | MB_ICONERROR | MB_OK,  wsz_ERROR,
03167         wsz_INVALID_VALUE_, wszBuffer, lMin, lMax);
03168       SetFocus(hEditWnd);
03169       return FALSE;
03170     }
03171   }
03172
03173   return TRUE;
03174 }
03175
03176
03177 /////////////////////////////////////////////////////////////////
03178 // SetMenuData
03179 //
03180 /////////////////////////////////////////////////////////////////
03181 BOOL SetMenuData(HMENU hMenu, UINT uItem, BOOL fByPosition, ULONG_PTR dwItemData)
03182 {
03183   //Setup our Menu Structure...
03184   //NOTE: HBITMAP was added in IE5, and may not work on older controls...
03185   MENUITEMINFOA menuinfo = { offsetof(MENUITEMINFOA, cch) + sizeof(UINT), MIIM_DATA, 0, 0, 0, NULL, NULL, NULL, dwItemData, NULL, 0};
03186
03187 #ifndef _WIN64
03188   //Set this menu's item data
03189   //NOTE: HBITMAP was added in IE5, and may not work on older controls...
03190   //So we will first try with the smaller size, since this should be backward compatible...
03191   if(SetMenuItemInfoA(hMenu, uItem, fByPosition, &menuinfo))
03192     return TRUE;
03193 #endif //_WIN64
03194
03195   //Retry Logic
03196   //On some OS's, (Win64), it only assumes the full NT5 structure size
03197   //thus for a new OS doesn't have backward compatability issues...
03198   menuinfo.cbSize = sizeof(MENUITEMINFOA);
03199   return SetMenuItemInfoA(hMenu, uItem, fByPosition, &menuinfo);
03200 }
03201
03202
03203 /////////////////////////////////////////////////////////////////////////////
03204 // SetSubMenuData
03205 //
03206 /////////////////////////////////////////////////////////////////////////////
03207 BOOL SetSubMenuData(HMENU hMenu, UINT uItem, BOOL fByPosition, ULONG_PTR dwItemData)
03208 {
03209   //NOTE: Having every menu item in all objects menu have unique ids, makes adding the same interface
03210   //to another object very painful, and causes manually editing the menu resources, making sure its
03211   //added to OnUpdateCommand for enabling/disabling the menu item, as well as adding another
03212   //case in OnCommand for the same interface!
03213
03214   //Instead we have devised a design where we can intitally set the item data of every menu
03215   //to contain the object identifier.  This way we can always obtain the stored data of the menu
03216   //and instantly know the type of object this interface/method is called from.  Saves hundreads
03217   //of lines of code, and almost ellimiates all places to remember to add code to...
03218
03219   //First set this menu's item data
03220   if(SetMenuData(hMenu, 0, TRUE/*fByPosition*/, dwItemData))
03221   {
03222     //Now that we have successfully set the data, we should loop through any child
03223     //menus and also set that data, since there is no current way to traverse backward in a menu...
03224     INT iItems = GetMenuItemCount(hMenu);
03225     for(INT i=0; i<iItems; i++)
03226     {
03227       ULONG ulMenuID = GetMenuItemID(hMenu, i);
03228       if(ulMenuID == ULONG_MAX)
03229       {
03230         //Recursive Alogorytm
03231         HMENU hSubMenu = GetSubMenu(hMenu, i);
03232         if(hSubMenu)
03233           SetSubMenuData(hSubMenu, 0, TRUE/*fByPosition*/, dwItemData);
03234       }
03235     }
03236
03237     return TRUE;
03238   }
03239
03240   return FALSE;
03241 }
03242
03243
03244 /////////////////////////////////////////////////////////////////
03245 // GetMenuData
03246 //
03247 /////////////////////////////////////////////////////////////////
03248 ULONG_PTR GetMenuData(HMENU hMenu, UINT uItem, BOOL fByPosition)
03249 {
03250   //Setup our Menu Structure...
03251   //NOTE: HBITMAP was added in IE5, and may not work on older controls...
03252   MENUITEMINFOA menuinfo = { offsetof(MENUITEMINFOA, cch) + sizeof(UINT), MIIM_DATA, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0 };
03253
03254 #ifndef _WIN64
03255   //First set this menu's item data
03256   //NOTE: HBITMAP was added in IE5, and may not work on older controls...
03257   //So we will first try with the smaller size, since this should be backward compatible...
03258   if(GetMenuItemInfoA(hMenu, uItem, fByPosition, &menuinfo))
03259     return menuinfo.dwItemData;
03260 #endif //_WIN64
03261
03262   //Retry Logic
03263   //On some OS's, (Win64), it only assumes the full NT5 structure size
03264   //thus for a new OS doesn't have backward compatability issues...
03265   menuinfo.cbSize = sizeof(MENUITEMINFOA);
03266   if(GetMenuItemInfoA(hMenu, uItem, fByPosition, &menuinfo))
03267     return menuinfo.dwItemData;
03268   return 0;
03269 }
03270
03271
03272 ///////////////////////////////////////////////////////////////
03273 // BrowseOpenFileName
03274 //
03275 ///////////////////////////////////////////////////////////////
03276 HRESULT BrowseOpenFileName(HINSTANCE hInstance, HWND hWnd, WCHAR* pwszTitle, WCHAR* pwszFileName, ULONG ulMaxSize, WCHAR* pwszExtension, WCHAR* pwszFilter, DWORD* pdwFileOffset, DWORD dwFlags)
03277 {
03278   static ULONG ulFilterIndex = 1;  //Default to first filter
03279   HRESULT hr = E_FAIL;
03280
03281   if(IsUnicodeOS())
03282   {
03283     //Setup OPENFILENAME struct...
03284     OPENFILENAMEW    ofn;
03285     memset( &ofn, 0, sizeof( ofn ));
03286     ofn.lStructSize       = sizeof( OPENFILENAMEW );
03287     ofn.hwndOwner         = hWnd;
03288     ofn.hInstance         = hInstance;
03289     ofn.nMaxFile          = ulMaxSize;
03290     ofn.nMaxCustFilter    = MAX_NAME_LEN;
03291     ofn.nFilterIndex    = ulFilterIndex;
03292     ofn.lpstrFile         = pwszFileName;
03293     ofn.lpstrTitle      = pwszTitle;
03294     ofn.lpstrFilter     = pwszFilter;
03295     ofn.lpstrDefExt     = pwszExtension;
03296     ofn.Flags             = dwFlags;
03297
03298     //Display Common Dialog to obtain File To Load...
03299     TESTC_(GetOpenFileNameW(&ofn),TRUE);
03300
03301     //Save the Choosen Filter Index
03302     ulFilterIndex = ofn.nFilterIndex;
03303     hr = S_OK;
03304
03305     //Save the first FileName offset (if multiselet)
03306     if(pdwFileOffset)
03307       *pdwFileOffset = ofn.nFileOffset;
03308   }
03309   else
03310   {
03311     CHAR szFileName[MAX_NAME_LEN];
03312     ConvertToMBCS(pwszFileName, szFileName, MAX_NAME_LEN);
03313     CHAR szTitle[MAX_NAME_LEN];
03314     ConvertToMBCS(pwszTitle, szTitle, MAX_NAME_LEN);
03315     CHAR szExtension[MAX_NAME_LEN];
03316     ConvertToMBCS(pwszExtension, szExtension, MAX_NAME_LEN);
03317
03318     //NOTE:  pwszFilter is a double null terminated string, (containing an array of singurally
03319     //null terminated sub strings).
03320     CHAR szFilter[MAX_QUERY_LEN] = {0};
03321     CHAR* pszFilter = szFilter;
03322     while(pwszFilter && *pwszFilter)
03323     {
03324       ConvertToMBCS(pwszFilter, pszFilter, MAX_QUERY_LEN-(INT)(pszFilter-szFilter));
03325       pwszFilter += wcslen(pwszFilter) + 1;
03326       pszFilter += strlen(pszFilter) + 1;
03327     }
03328
03329     //Setup OPENFILENAME struct...
03330     OPENFILENAMEA    ofn;
03331     memset( &ofn, 0, sizeof( ofn ));
03332     ofn.lStructSize       = sizeof( OPENFILENAMEA );
03333     ofn.hwndOwner         = hWnd;
03334     ofn.hInstance         = hInstance;
03335     ofn.nMaxFile          = ulMaxSize;
03336     ofn.nMaxCustFilter    = MAX_NAME_LEN;
03337     ofn.nFilterIndex    = ulFilterIndex;
03338     ofn.lpstrFile         = szFileName;
03339     ofn.lpstrTitle      = szTitle;
03340     ofn.lpstrFilter     = szFilter;
03341     ofn.lpstrDefExt     = szExtension;
03342     ofn.Flags             = dwFlags;
03343
03344     //Display Common Dialog to obtain File To Load...
03345     TESTC_(GetOpenFileNameA(&ofn), TRUE)
03346     ConvertToWCHAR(szFileName, pwszFileName, MAX_NAME_LEN);
03347
03348     //Save the Choosen Filter Index
03349     ulFilterIndex = ofn.nFilterIndex;
03350     hr = S_OK;
03351
03352     //Save the first FileName offset (if multiselet)
03353     if(pdwFileOffset)
03354       *pdwFileOffset = ofn.nFileOffset;
03355   }
03356
03357 CLEANUP:
03358   return hr;
03359 }
03360
03361
03362 ///////////////////////////////////////////////////////////////
03363 // CreateDefFileName
03364 //
03365 ///////////////////////////////////////////////////////////////
03366 HRESULT CreateDefFileName(LPCWSTR pwszFileName, WCHAR* pwszFullPath, ULONG ulMaxSize, BOOL fCurrentDir)
03367 {
03368   if(pwszFileName == NULL || pwszFullPath == NULL || ulMaxSize == 0)
03369     return E_INVALIDARG;
03370
03371   //Obtain the current Directory
03372   DWORD ulStrLen = 0;
03373   if(fCurrentDir)
03374   {
03375     if(IsUnicodeOS())
03376     {
03377       ulStrLen = GetCurrentDirectoryW(ulMaxSize, pwszFullPath);
03378     }
03379     else
03380     {
03381       CHAR szBuffer[MAX_PATH+1];
03382       ulStrLen = GetCurrentDirectoryA(MAX_PATH, szBuffer);
03383       ConvertToWCHAR(szBuffer, pwszFullPath, ulMaxSize);
03384     }
03385   }
03386   else
03387   {
03388     if(IsUnicodeOS())
03389     {
03390       ulStrLen = GetSystemDirectoryW(pwszFullPath, ulMaxSize);
03391     }
03392     else
03393     {
03394       CHAR szBuffer[MAX_PATH+1];
03395       ulStrLen = GetSystemDirectoryA(szBuffer, MAX_PATH);
03396       ConvertToWCHAR(szBuffer, pwszFullPath, ulMaxSize);
03397     }
03398   }
03399
03400   if(ulStrLen)
03401   {
03402     //We can't just strcat a "\filename" since depending upon the current
03403     //directory sometimes it returns "c:\" or "c:\oledb", etc...
03404     if(pwszFullPath[ulStrLen-1] != L'\\')
03405       wcscat(pwszFullPath, L"\\");
03406
03407     //Now tack on the suggested filename...
03408     wcscat(pwszFullPath, pwszFileName);
03409     return S_OK;
03410   }
03411
03412   return E_FAIL;
03413 }
03414
03415
03416 ///////////////////////////////////////////////////////////////
03417 // BrowseSaveFileName
03418 //
03419 ///////////////////////////////////////////////////////////////
03420 HRESULT BrowseSaveFileName(HINSTANCE hInstance, HWND hWnd, WCHAR* pwszTitle, WCHAR* pwszFileName, ULONG ulMaxSize, WCHAR* pwszExtension, WCHAR* pwszFilter, DWORD* pdwFileOffset, DWORD dwFlags)
03421 {
03422   HRESULT hr = E_FAIL;
03423   static ULONG ulFilterIndex = 1;  //Default to first filter
03424
03425   if(IsUnicodeOS())
03426   {
03427     //Setup OPENFILENAME struct...
03428     OPENFILENAMEW    ofn;
03429     memset( &ofn, 0, sizeof( ofn ));
03430     ofn.lStructSize       = sizeof( OPENFILENAMEW );
03431     ofn.hwndOwner         = hWnd;
03432     ofn.hInstance         = hInstance;
03433     ofn.nMaxFile          = ulMaxSize;
03434     ofn.lpstrFile         = pwszFileName;
03435     ofn.lpstrTitle      = pwszTitle;
03436     ofn.lpstrFilter     = pwszFilter;
03437     ofn.nMaxCustFilter    = MAX_NAME_LEN;
03438     ofn.nFilterIndex    = ulFilterIndex;
03439     ofn.lpstrDefExt     = pwszExtension;
03440     ofn.Flags             = dwFlags;
03441
03442     //Display Common Dialog to obtain File To Save...
03443     if(GetSaveFileNameW(&ofn))
03444     {
03445       ulFilterIndex = ofn.nFilterIndex;
03446
03447       //Save the first FileName offset (if multiselet)
03448       if(pdwFileOffset)
03449         *pdwFileOffset = ofn.nFileOffset;
03450
03451       hr = S_OK;
03452     }
03453   }
03454   else
03455   {
03456     CHAR szFileName[MAX_NAME_LEN];
03457     ConvertToMBCS(pwszFileName, szFileName, MAX_NAME_LEN);
03458     CHAR szTitle[MAX_NAME_LEN];
03459     ConvertToMBCS(pwszTitle, szTitle, MAX_NAME_LEN);
03460     CHAR szExtension[MAX_NAME_LEN];
03461     ConvertToMBCS(pwszExtension, szExtension, MAX_NAME_LEN);
03462
03463     //NOTE:  pwszFilter is a double null terminated string, (containing an array of singurally
03464     //null terminated sub strings).
03465     CHAR szFilter[MAX_QUERY_LEN] = {0};
03466     CHAR* pszFilter = szFilter;
03467     while(pwszFilter && *pwszFilter)
03468     {
03469       ConvertToMBCS(pwszFilter, pszFilter, MAX_QUERY_LEN-(INT)(pszFilter-szFilter));
03470       pwszFilter += wcslen(pwszFilter) + 1;
03471       pszFilter += strlen(pszFilter) + 1;
03472     }
03473
03474     //Setup OPENFILENAME struct...
03475     OPENFILENAMEA    ofn;
03476     memset( &ofn, 0, sizeof( ofn ));
03477     ofn.lStructSize       = sizeof( OPENFILENAMEA );
03478     ofn.hwndOwner         = hWnd;
03479     ofn.hInstance         = hInstance;
03480     ofn.nMaxFile          = ulMaxSize;
03481     ofn.lpstrFile         = szFileName;
03482     ofn.lpstrTitle      = szTitle;
03483     ofn.lpstrFilter     = szFilter;
03484     ofn.nMaxCustFilter    = MAX_NAME_LEN;
03485     ofn.nFilterIndex    = ulFilterIndex;
03486     ofn.lpstrDefExt     = szExtension;
03487     ofn.Flags             = dwFlags;
03488
03489     //Display Common Dialog to obtain File To Save...
03490     if(GetSaveFileNameA(&ofn))
03491     {
03492       ConvertToWCHAR(szFileName, pwszFileName, MAX_NAME_LEN);
03493       ulFilterIndex = ofn.nFilterIndex;
03494
03495       //Save the first FileName offset (if multiselet)
03496       if(pdwFileOffset)
03497         *pdwFileOffset = ofn.nFileOffset;
03498
03499       hr = S_OK;
03500     }
03501   }
03502
03503   return hr;
03504 }
03505
03506
03507 ////////////////////////////////////////////////////////
03508 // HRESULT CreateRegKey
03509 //
03510 ////////////////////////////////////////////////////////
03511 HRESULT CreateRegKey(HKEY hRootKey, WCHAR* pwszKeyName, HKEY* phKey, REGSAM samDesired)
03512 {
03513   HRESULT hr = E_FAIL;
03514   ULONG dwDisposition = 0;
03515
03516   //Need the name of the key to open
03517   if(!pwszKeyName)
03518     return E_FAIL;
03519
03520   if(IsUnicodeOS())
03521   {
03522     hr = RegCreateKeyExW(hRootKey, pwszKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, samDesired, NULL, phKey, &dwDisposition);
03523   }
03524   else
03525   {
03526     CHAR szBuffer[MAX_NAME_LEN];
03527     ConvertToMBCS(pwszKeyName, szBuffer, MAX_NAME_LEN);
03528
03529     hr = RegCreateKeyExA(hRootKey, szBuffer, 0, NULL, REG_OPTION_NON_VOLATILE, samDesired, NULL, phKey, &dwDisposition);
03530   }
03531
03532   if(hr != S_OK)
03533     hr = E_FAIL;
03534   return hr;
03535 }
03536
03537
03538 ////////////////////////////////////////////////////////
03539 // HRESULT OpenRegKey
03540 //
03541 ////////////////////////////////////////////////////////
03542 HRESULT OpenRegKey(HKEY hRootKey, WCHAR* pwszKeyName, DWORD ulOptions, REGSAM samDesired, HKEY* phKey)
03543 {
03544   HRESULT hr = E_FAIL;
03545
03546   if(IsUnicodeOS())
03547   {
03548     //Obtain the Key for HKEY_CLASSES_ROOT\"SubKey"
03549     hr = RegOpenKeyExW(hRootKey, pwszKeyName, ulOptions, samDesired, phKey);
03550   }
03551   else
03552   {
03553     CHAR szBuffer[MAX_NAME_LEN];
03554     ConvertToMBCS(pwszKeyName, szBuffer, MAX_NAME_LEN);
03555
03556     //Obtain the Key for HKEY_CLASSES_ROOT\"SubKey"
03557     hr = RegOpenKeyExA(hRootKey, szBuffer, ulOptions, samDesired, phKey);
03558   }
03559
03560   if(hr != S_OK)
03561     return E_FAIL;
03562   return hr;
03563 }
03564
03565
03566 ////////////////////////////////////////////////////////
03567 // WCHAR* GetProgID
03568 //
03569 ////////////////////////////////////////////////////////
03570 WCHAR* GetProgID(REFCLSID clsid)
03571 {
03572   WCHAR* pwszProgID = NULL;
03573   WCHAR wszBuffer[MAX_NAME_LEN];
03574   wszBuffer[0] = wEOL;
03575
03576   //ProgID From the Sprecified CLSID
03577   if(FAILED(ProgIDFromCLSID(clsid, &pwszProgID)))
03578   {
03579     //If that does work, we will just return the
03580     //String representation of the GUID
03581     StringFromGUID2(clsid, wszBuffer, MAX_NAME_LEN);
03582     pwszProgID = wcsDuplicate(wszBuffer);
03583   }
03584
03585   return pwszProgID;
03586 }
03587
03588
03589 ////////////////////////////////////////////////////////
03590 // HRESULT GetRegEnumKey
03591 //
03592 ////////////////////////////////////////////////////////
03593 HRESULT GetRegEnumKey(HKEY hRootKey, WCHAR* pwszKeyName, DWORD dwIndex, WCHAR* pwszSubKeyName, ULONG cBytes)
03594 {
03595   HRESULT hr = E_FAIL;
03596   HKEY hKey = NULL;
03597
03598   //Need some place to put the key name returned!
03599   if(!pwszSubKeyName)
03600     return E_FAIL;
03601
03602   //Obtain the Key for HKEY_CLASSES_ROOT\"KeyName"
03603   if(pwszKeyName)
03604   {
03605     if(FAILED(OpenRegKey(hRootKey, pwszKeyName, 0, KEY_READ, &hKey)))
03606       goto CLEANUP;
03607   }
03608
03609   if(IsUnicodeOS())
03610   {
03611     //Obtain the specified RegItem at the index specified
03612     hr = RegEnumKeyW(hKey ? hKey : hRootKey, dwIndex, pwszSubKeyName, cBytes);
03613   }
03614   else
03615   {
03616     CHAR szBuffer[MAX_NAME_LEN] = {0};
03617
03618     //Obtain the specified RegItem at the index specified
03619     hr = RegEnumKeyA(hKey ? hKey : hRootKey, dwIndex, szBuffer, MAX_NAME_LEN);
03620     ConvertToWCHAR(szBuffer, pwszSubKeyName, cBytes);
03621   }
03622
03623
03624 CLEANUP:
03625   if(hr != S_OK && hr != ERROR_NO_MORE_ITEMS)
03626     hr = E_FAIL;
03627   CloseRegKey(hKey);
03628   return hr;
03629 }
03630
03631
03632 ////////////////////////////////////////////////////////
03633 // HRESULT GetRegEnumValue
03634 //
03635 ////////////////////////////////////////////////////////
03636 HRESULT GetRegEnumValue(HKEY hRootKey, WCHAR* pwszKeyName, DWORD dwIndex, WCHAR** ppwszValueName)
03637 {
03638   HRESULT hr = S_OK;
03639   ULONG cBytes = 0;
03640   HKEY hKey = NULL;
03641   ULONG cMaxValueChars = 0;
03642
03643   //Obtain the Key for HKEY_CLASSES_ROOT\"KeyName"
03644   if(pwszKeyName)
03645   {
03646     if(FAILED(OpenRegKey(hRootKey, pwszKeyName, 0, KEY_READ, &hKey)))
03647       goto CLEANUP;
03648   }
03649
03650   //First obtain the length of the Value...
03651   if(S_OK == RegQueryInfoKey(hKey ? hKey : hRootKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &cMaxValueChars, NULL, NULL, NULL))
03652   {
03653     //Alloc a buffer large enough...
03654     SAFE_ALLOC(*ppwszValueName, WCHAR, cMaxValueChars+1);
03655     (*ppwszValueName)[0] = wEOL;
03656
03657     //Now obtain the data...
03658     cBytes = (cMaxValueChars+1)*sizeof(WCHAR);
03659     hr = GetRegEnumValue(hRootKey, pwszKeyName, dwIndex, *ppwszValueName, &cBytes);
03660   }
03661
03662 CLEANUP:
03663   CloseRegKey(hKey);
03664   return hr;
03665 }
03666
03667
03668 ////////////////////////////////////////////////////////
03669 // HRESULT GetRegEnumValue
03670 //
03671 ////////////////////////////////////////////////////////
03672 HRESULT GetRegEnumValue(HKEY hRootKey, WCHAR* pwszKeyName, DWORD dwIndex, WCHAR* pwszValueName, ULONG* pcBytes)
03673 {
03674   HRESULT hr = E_FAIL;
03675   HKEY hKey = NULL;
03676   ASSERT(pcBytes);
03677
03678   //Obtain the Key for HKEY_CLASSES_ROOT\"KeyName"
03679   if(pwszKeyName)
03680   {
03681     if(FAILED(OpenRegKey(hRootKey, pwszKeyName, 0, KEY_READ, &hKey)))
03682       goto CLEANUP;
03683   }
03684
03685   if(IsUnicodeOS())
03686   {
03687     //Obtain the specified RegItem at the index specified
03688     hr = RegEnumValueW(hKey ? hKey : hRootKey, dwIndex, pwszValueName, pcBytes, 0, NULL, NULL, 0);
03689   }
03690   else
03691   {
03692     CHAR szBuffer[MAX_NAME_LEN] = {0};
03693     ULONG cTotal = sizeof(szBuffer);
03694
03695     //Obtain the specified RegItem at the index specified
03696     hr = RegEnumValueA(hKey ? hKey : hRootKey, dwIndex, pwszValueName ? szBuffer : NULL, &cTotal, 0, NULL, NULL, 0);
03697
03698     if(pwszValueName)
03699       ConvertToWCHAR(szBuffer, pwszValueName, *pcBytes);
03700     *pcBytes = cTotal;
03701   }
03702
03703 CLEANUP:
03704   if(hr != S_OK && hr != ERROR_NO_MORE_ITEMS)
03705     hr = E_FAIL;
03706   CloseRegKey(hKey);
03707   return hr;
03708 }
03709
03710
03711 ////////////////////////////////////////////////////////
03712 // HRESULT GetRegEntry
03713 //
03714 ////////////////////////////////////////////////////////
03715 HRESULT GetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, WCHAR* pwszValue, ULONG cBytes)
03716 {
03717   if(IsUnicodeOS())
03718   {
03719     return GetRegEntry(hRootKey, pwszKeyName, pwszValueName, pwszValue, cBytes, NULL, REG_SZ);
03720   }
03721   else
03722   {
03723     CHAR szBuffer[MAX_NAME_LEN];
03724     HRESULT hr = GetRegEntry(hRootKey, pwszKeyName, pwszValueName, szBuffer, MAX_NAME_LEN, NULL, REG_SZ);
03725     if(SUCCEEDED(hr))
03726       ConvertToWCHAR(szBuffer, pwszValue, cBytes);
03727
03728     return hr;
03729   }
03730 }
03731
03732
03733 ////////////////////////////////////////////////////////
03734 // HRESULT GetRegEntry
03735 //
03736 ////////////////////////////////////////////////////////
03737 HRESULT GetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, WCHAR** ppwszValue)
03738 {
03739   HRESULT hr = S_OK;
03740   ASSERT(ppwszValue);
03741   ULONG cBytes = 0;
03742   CHAR* pszBuffer = NULL;
03743
03744   //Obtain the length first (value = NULL)
03745   TESTC(hr = GetRegEntry(hRootKey, pwszKeyName, pwszValueName, NULL, 0, &cBytes, REG_SZ));
03746
03747   //Allocate the string
03748   //NOTE: The length returned from RegQueryValueEx also includes the NULL terminator
03749   SAFE_ALLOC(*ppwszValue, WCHAR, cBytes);
03750
03751   if(IsUnicodeOS())
03752   {
03753     //Now obtain the data
03754     TESTC(hr = GetRegEntry(hRootKey, pwszKeyName, pwszValueName, *ppwszValue, cBytes, &cBytes, REG_SZ));
03755   }
03756   else
03757   {
03758     //Allocate the string
03759     SAFE_ALLOC(pszBuffer, CHAR, cBytes);
03760
03761     //Now obtain the data
03762     TESTC(hr = GetRegEntry(hRootKey, pwszKeyName, pwszValueName, pszBuffer, cBytes, &cBytes, REG_SZ));
03763     ConvertToWCHAR(pszBuffer, *ppwszValue, cBytes);
03764     return hr;
03765   }
03766
03767 CLEANUP:
03768   SAFE_FREE(pszBuffer);
03769   return hr;
03770 }
03771
03772
03773 ////////////////////////////////////////////////////////
03774 // HRESULT GetRegEntry
03775 //
03776 ////////////////////////////////////////////////////////
03777 HRESULT GetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, ULONG* pulValue)
03778 {
03779   return GetRegEntry(hRootKey, pwszKeyName, pwszValueName, pulValue, sizeof(ULONG), NULL, REG_DWORD);
03780 }
03781
03782
03783 ////////////////////////////////////////////////////////
03784 // HRESULT GetRegEntry
03785 //
03786 ////////////////////////////////////////////////////////
03787 HRESULT GetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, void* pStruct, ULONG cBytes, ULONG* pcActualBytes, ULONG dwType)
03788 {
03789   HRESULT hr = E_FAIL;
03790   HKEY hKey = NULL;
03791
03792   //NOTE: pStruct can be NULL if the user is just obtaining the length...
03793
03794   //Obtain the Data for the above key
03795   if(pwszKeyName)
03796   {
03797     if(FAILED(OpenRegKey(hRootKey, pwszKeyName, 0, KEY_READ, &hKey)))
03798       goto CLEANUP;
03799   }
03800
03801   if(IsUnicodeOS())
03802   {
03803     hr = RegQueryValueExW(hKey ? hKey : hRootKey, pwszValueName, NULL, &dwType, (BYTE*)pStruct, &cBytes);
03804   }
03805   else
03806   {
03807     //Obtain the Data for the above key
03808     CHAR szBuffer[MAX_NAME_LEN];
03809     ConvertToMBCS(pwszValueName, szBuffer, MAX_NAME_LEN);
03810
03811     hr = RegQueryValueExA(hKey ? hKey : hRootKey, szBuffer, NULL, &dwType, (BYTE*)pStruct, &cBytes);
03812   }
03813
03814   if(hr != S_OK)
03815     hr = E_FAIL;
03816
03817 CLEANUP:
03818   if(pcActualBytes)
03819     *pcActualBytes = cBytes;
03820
03821   CloseRegKey(hKey);
03822   return hr;
03823 }
03824
03825
03826 ////////////////////////////////////////////////////////
03827 // HRESULT SetRegEntry
03828 //
03829 ////////////////////////////////////////////////////////
03830 HRESULT SetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, WCHAR* pwszValue)
03831 {
03832   if(IsUnicodeOS())
03833   {
03834     return SetRegEntry(hRootKey, pwszKeyName, pwszValueName, pwszValue ? pwszValue : L"", pwszValue ? (wcslen(pwszValue)+1)*sizeof(WCHAR) : sizeof(WCHAR), REG_SZ);
03835   }
03836   else
03837   {
03838     CHAR szBuffer[MAX_NAME_LEN];
03839     ConvertToMBCS(pwszValue, szBuffer, MAX_NAME_LEN);
03840     return SetRegEntry(hRootKey, pwszKeyName, pwszValueName, pwszValue ? szBuffer : "", pwszValue ? (strlen(szBuffer)+1)*sizeof(CHAR) : sizeof(CHAR), REG_SZ);
03841   }
03842 }
03843
03844
03845 ////////////////////////////////////////////////////////
03846 // HRESULT SetRegEntry
03847 //
03848 ////////////////////////////////////////////////////////
03849 HRESULT SetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, ULONG ulValue)
03850 {
03851   return SetRegEntry(hRootKey, pwszKeyName, pwszValueName, &ulValue, sizeof(ULONG), REG_DWORD);
03852 }
03853
03854
03855 ////////////////////////////////////////////////////////
03856 // HRESULT SetRegEntry
03857 //
03858 ////////////////////////////////////////////////////////
03859 HRESULT SetRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, WCHAR* pwszValueName, void* pStruct, ULONG cBytes, DWORD dwType)
03860 {
03861   HRESULT hr = E_FAIL;
03862   HKEY hKey = NULL;
03863
03864   //Obtain the Data for the above key
03865   if(pwszKeyName)
03866   {
03867     if(FAILED(hr = CreateRegKey(hRootKey, pwszKeyName, &hKey)))
03868       goto CLEANUP;
03869   }
03870
03871   if(IsUnicodeOS())
03872   {
03873     //Set the data for the above key (or the root key...)
03874     hr = RegSetValueExW(hKey ? hKey : hRootKey, pwszValueName, 0, dwType, (BYTE*)pStruct, cBytes);
03875   }
03876   else
03877   {
03878     //Set the data for the above key (or the root key...)
03879     CHAR szBuffer[MAX_NAME_LEN];
03880     ConvertToMBCS(pwszValueName, szBuffer, MAX_NAME_LEN);
03881     hr = RegSetValueExA(hKey ? hKey : hRootKey, szBuffer, 0, dwType, (BYTE*)pStruct, cBytes);
03882   }
03883
03884   if(hr != S_OK)
03885     hr = E_FAIL;
03886
03887 CLEANUP:
03888   CloseRegKey(hKey);
03889   return hr;
03890 }
03891
03892
03893
03894 ////////////////////////////////////////////////////////
03895 // HRESULT DelRegEntry
03896 //
03897 ////////////////////////////////////////////////////////
03898 HRESULT DelRegEntry(HKEY hRootKey, WCHAR* pwszKeyName)
03899 {
03900   HRESULT hr;
03901
03902   //DelRegEntry
03903   if(IsUnicodeOS())
03904   {
03905     hr = RegDeleteKeyW(hRootKey, pwszKeyName);
03906   }
03907   else
03908   {
03909     CHAR szBuffer[MAX_NAME_LEN];
03910     ConvertToMBCS(pwszKeyName, szBuffer, MAX_NAME_LEN);
03911     hr = RegDeleteKeyA(hRootKey, szBuffer);
03912   }
03913
03914   //Entry successfully deleted - return S_OK
03915   if(hr==S_OK)
03916     return S_OK;
03917
03918   //Entry not found - return S_FALSE
03919   if(hr==ERROR_FILE_NOT_FOUND)
03920     return S_FALSE;
03921
03922   return E_FAIL;
03923 }
03924
03925
03926 ////////////////////////////////////////////////////////
03927 // HRESULT DelRegEntry
03928 //
03929 ////////////////////////////////////////////////////////
03930 HRESULT DelRegEntry(HKEY hRootKey, WCHAR* pwszKeyName, BOOL fSubKeys)
03931 {
03932   HKEY hKey = NULL;
03933   WCHAR wszBuffer[MAX_NAME_LEN];
03934   HRESULT hr = S_OK;
03935
03936   //RegDeleteKey only deletes the key if there are no subkeys
03937   if(SUCCEEDED(hr = OpenRegKey(hRootKey, pwszKeyName, 0, KEY_READ | KEY_WRITE, &hKey)))
03938   {
03939     //This is a pain to always have to delete the subkeys to remove the key...
03940     if(fSubKeys)
03941     {
03942       //Loop over all subkeys...
03943       //NOTE: GetRegEnum requires KEY_ENUMERATE_SUB_KEYS which is found in KEY_READ.
03944       while((hr = GetRegEnumKey(hKey, NULL, 0, wszBuffer, MAX_NAME_LEN))==S_OK)
03945       {
03946         //Recurse and delete the sub key...
03947         if(FAILED(hr = DelRegEntry(hKey, wszBuffer, fSubKeys)))
03948           break;
03949       }
03950     }
03951
03952     //Now we can delete the root key
03953     hr = DelRegEntry(hRootKey, pwszKeyName);
03954     CloseRegKey(hKey);
03955   }
03956
03957   return hr;
03958 }
03959
03960
03961 ////////////////////////////////////////////////////////
03962 // HRESULT CloseRegKey
03963 //
03964 ////////////////////////////////////////////////////////
03965 HRESULT CloseRegKey(HKEY hKey)
03966 {
03967   HRESULT hr = S_OK;
03968
03969   //RegCloseKey
03970   if(hKey)
03971     hr = RegCloseKey(hKey);
03972
03973   if(hr != S_OK)
03974     hr = E_FAIL;
03975   return hr;
03976 }
03977
03978
03979 ///////////////////////////////////////////////////////////////
03980 // Static Strings Messages
03981 //
03982 ///////////////////////////////////////////////////////////////
03983
03984 extern WCHAR wsz_SUCCESS[]        = L"Microsoft OLE DB RowsetViewer - Success";
03985 extern WCHAR wsz_WARNING[]        = L"Microsoft OLE DB RowsetViewer - Warning";
03986 extern WCHAR wsz_INFO[]         = L"Microsoft OLE DB RowsetViewer - Info";
03987 extern WCHAR wsz_ERROR[]        = L"Microsoft OLE DB RowsetViewer - Error";
03988 extern WCHAR wsz_EXCEPTION[]      = L"Microsoft OLE DB RowsetViewer - Exception";
03989 extern WCHAR wsz_ERRORINFO[]      = L"Microsoft OLE DB RowsetViewer - IErrorInfo";
03990
03991 //General String Values
03992 extern WCHAR wsz_INVALID_VALUE_[]   = L"Invalid Value '%s' specified.  Please specify a value >= %lu and <= %lu.";
03993
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/CClusterUtils.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

CClusterUtils.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      CClusterUtils.h
00005 //
00006 //  Description:
00007 //      This file contains the declaration of the CClusterUtils class.
00008 //
00009 //  Implementation Files:
00010 //      CClusterUtils.cpp
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 #pragma once
00015
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Include Files
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 #include "stdafx.h"
00022
00023
00024 //////////////////////////////////////////////////////////////////////////////
00025 // Constant Declarations
00026 //////////////////////////////////////////////////////////////////////////////
00027
00028
00029 //////////////////////////////////////////////////////////////////////////////
00030 //++
00031 //
00032 //  class CClusterUtils
00033 //
00034 //  Description:
00035 //      The CClusterUtils class contains utility functions for
00036 //      dealing with cluster resources.
00037 //
00038 //  Interfaces:
00039 //      None.
00040 //
00041 //--
00042 //////////////////////////////////////////////////////////////////////////////
00043 class CClusterUtils
00044 {
00045 private:
00046
00047     //
00048     // Private member functions and data
00049     //
00050
00051     //
00052     //  Private copy constructor to prevent copying.
00053     //
00054
00055     CClusterUtils( const CClusterUtils & nodeSrc );
00056
00057     //
00058     //  Private assignment operator to prevent copying.
00059     //
00060
00061     const CClusterUtils & operator = ( const CClusterUtils & nodeSrc );
00062
00063 protected:
00064
00065     //
00066     //  constructors and destructors
00067     //
00068
00069     CClusterUtils( void ) {};
00070     virtual ~CClusterUtils( void ) {};
00071
00072 public:
00073
00074     HRESULT HrIsGroupOwnedByThisNode( HGROUP hGroupIn, BSTR bstrNodeNameIn );
00075     HRESULT HrIsNodeClustered( void );
00076     HRESULT HrEnumNodeResources( BSTR bstrNodeNameIn );
00077     HRESULT HrLoadGroupResources( HCLUSTER hClusterIn, HGROUP hGroupIn );
00078     HRESULT HrGetQuorumResourceName( BSTR * pbstrQuorumResourceNameOut );
00079     HRESULT HrIsClusterServiceRunning( void );
00080     HRESULT HrIsCoreResource( HRESOURCE hResourceIn );
00081
00082     virtual HRESULT HrNodeResourceCallback( HRESOURCE hResourceIn ) = 0;
00083
00084 }; //*** class CClusterUtils
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DcdServe/Server.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • DcdServe

Server.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.H
00003
00004   Summary:   Internal include file for the DCDSERVE.EXE out-of-process
00005              server. Declares the CServer server control object class.
00006
00007              For a comprehensive tutorial code tour of this module's
00008              contents and offerings see the tutorial DCDSERVE.HTM
00009              file. For more specific technical details on the internal
00010              workings see the comments dispersed throughout the module's
00011              source code.
00012
00013   Classes:   CServer.
00014
00015   Functions: none.
00016
00017   Origin:    8-23-97: atrent - Editor-inheritance from SERVER.H in
00018                the LOCSERVE Tutorial Code Sample. [Revised]
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035
00036 #if !defined(SERVER_H)
00037 #define SERVER_H
00038
00039
00040 #ifdef __cplusplus
00041
00042
00043 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00044   Class:    CServer
00045
00046   Summary:  Class to encapsulate control of this COM server (eg, handle
00047             Lock and Object counting, encapsulate otherwise global data).
00048             There is an instance of CServer for every attached process.
00049
00050   Methods:  none
00051 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00052 class CServer : public CThreaded
00053 {
00054   public:
00055     CServer(void);
00056     ~CServer(void);
00057
00058     // Methods for server lifetime control: object counts and lock counts.
00059     void Lock(void);
00060     void Unlock(void);
00061     void ObjectsUp(void);
00062     void ObjectsDown(void);
00063     BOOL ObjectFirst(void);
00064     HRESULT ObjectSet(IUnknown* pCob);
00065     HRESULT ObjectQI(REFIID riid, PPVOID ppv);
00066     BOOL OpenFactories(void);
00067     BOOL CloseFactories(void);
00068
00069     // A place to store the server's instance handle.
00070     HINSTANCE m_hInstServer;
00071
00072     // A place to store the server's main window.
00073     HWND m_hWndServer;
00074
00075     // Global Server living Object count.
00076     LONG m_cObjects;
00077
00078     // Global Server Client Lock count.
00079     LONG m_cLocks;
00080
00081     // Some member variables to store pointers to Class Factories.
00082     IUnknown* m_pCFPaper;
00083
00084     // Some member variables to store Class Factory registration keys.
00085     DWORD m_dwCFPaper;
00086
00087     // Global IUnknown interface pointer to the single COPaper object.
00088     IUnknown* m_pCOPaper;
00089 };
00090
00091 #endif // __cplusplus
00092
00093 // Allow other internal DCDSERVE modules to get at the globals.
00094 extern CServer* g_pServer;
00095
00096
00097 #endif // SERVER_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepmultiuser/dbgmsg.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepmultiuser

dbgmsg.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Debugging Routines
00005
00006     FILE: DbgMsg.cpp
00007
00008     PURPOSE: Routines for debugging system services.
00009
00010 */
00011
00012 #include <windows.h>
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <process.h>
00016 #include <tchar.h>
00017
00018 #include "DbgMsg.h"
00019 #include "Service.h"
00020 #include "common.h"
00021
00022 // Handle to the debug log file.
00023 HANDLE hDbgMsgLog = NULL;
00024
00025 // Current size of the debug log.
00026 UINT nDbgMsgLogSize = 0;
00027
00028 CRITICAL_SECTION DbgMsgCriticalSection;
00029
00030 VOID DbgMsgOpenLog(LPTSTR LogFileName) {
00031
00032     // Init the critsec.
00033     if (InitializeCriticalSectionAndSpinCount(&DbgMsgCriticalSection, 0) == 0) {
00034         AddToMessageLogProcFailure(TEXT("DbgMsgOpenLog: InitializeCriticalSectionAndSpinCount"), GetLastError());
00035         return;
00036     }
00037
00038     // Open the profiling log.
00039     if ((hDbgMsgLog = CreateFile(LogFileName,
00040                                GENERIC_WRITE,
00041                                0,
00042                                NULL,
00043                                CREATE_ALWAYS,
00044                                FILE_ATTRIBUTE_NORMAL,
00045                                NULL)) == INVALID_HANDLE_VALUE) {
00046         AddToMessageLogProcFailure(TEXT("DbgMsgOpenLog: CreateFile"), GetLastError());
00047     }
00048 }
00049
00050 VOID DbgMsgRecord(LPTSTR msg) {
00051     ULONG cbWritten;
00052
00053     EnterCriticalSection(&DbgMsgCriticalSection);
00054
00055     // Write the entry only if there is enough space left in
00056     // the log.
00057     if (nDbgMsgLogSize < DEBUG_LOG_MAX_SIZE + _tcslen(msg)) {
00058
00059         // Append the entry to the log.
00060         nDbgMsgLogSize += _tcslen(msg);
00061         if(!WriteFile(hDbgMsgLog,
00062                       (LPVOID)msg,
00063                       _tcslen(msg)*sizeof(TCHAR),
00064                       &cbWritten,
00065                       NULL)) {
00066             AddToMessageLogProcFailure(TEXT("DbgMsgRecord: WriteFile"), GetLastError());
00067         }
00068     }
00069
00070     LeaveCriticalSection(&DbgMsgCriticalSection);
00071     return;
00072 }
00073
00074 VOID DbgMsgCloseLog(VOID) {
00075     DWORD status;
00076
00077     // Delete and the critsec.
00078     DeleteCriticalSection(&DbgMsgCriticalSection);
00079
00080     // Close the debug log.
00081     if (hDbgMsgLog != NULL && hDbgMsgLog != INVALID_HANDLE_VALUE) {
00082         status = CloseHandle(hDbgMsgLog);
00083         ASSERTE(status);
00084     }
00085 }
00086
00087 // end DbgMsg.cpp
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ColProps Member List

This is the complete list of members for ColProps, including all inherited members.
nchars | ColProps
props | ColProps
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/dbh/dbh.cpp Source File

  • WinBase
  • Debug
  • dbh

dbh.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (C) 2002.  Microsoft Corporation.  All rights reserved.
00008  *
00009  * dbh.c
00010  *
00011  * This file implements a command line utility that shows how to
00012  * use the dbghelp API to query symbolic information from an image
00013  * or pdb file.
00014  *
00015  * Requires dbghelp.dll version 6.1 or greater.
00016  */
00017
00018 #include <windows.h>
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <malloc.h>
00022 #include <assert.h>
00023 #include <dbghelp.h>
00024 #include <strsafe.h>
00025
00026 // general #defines
00027
00028 #define DIMAT(Array, EltType) (sizeof(Array) / sizeof(EltType))
00029 #define DIMA(Array) DIMAT(Array, (Array)[0])
00030
00031 #ifndef true
00032  #define true TRUE
00033  #define false FALSE
00034 #endif
00035
00036 #define MAX_STR         256
00037 #define WILD_UNDERSCORE 1
00038 #define SYM_BUFFER_SIZE (sizeof(IMAGEHLP_SYMBOL64) + MAX_SYM_NAME)
00039 #define SI_BUFFER_SIZE (sizeof(SYMBOL_INFO) + MAX_SYM_NAME)
00040
00041 // for calling SymEnumSymbols
00042
00043 typedef struct {
00044     char    mask[MAX_STR];
00045     DWORD64 base;
00046 } ENUMSYMDATA, *PENUMSYMDATA;
00047
00048 // available commands
00049
00050 typedef enum
00051 {
00052     cmdQuit = 0,
00053     cmdHelp,
00054     cmdVerbose,
00055     cmdLoad,
00056     cmdUnload,
00057     cmdEnum,
00058     cmdName,
00059     cmdAddr,
00060     cmdBase,
00061     cmdNext,
00062     cmdPrev,
00063     cmdLine,
00064     cmdLineNext,
00065     cmdLinePrev,
00066     cmdUndec,
00067     cmdFindFile,
00068     cmdAdd,
00069     cmdDelete,
00070     cmdEnumForAddr,
00071     cmdLocals,
00072     cmdType,
00073     cmdInfo,
00074     cmdMax
00075 };
00076
00077 // this struct associates commands with functions
00078
00079 typedef BOOL (*CMDPROC)(char *params);
00080
00081 typedef struct _CMD
00082 {
00083     char    token[MAX_STR + 1];
00084     char    shorttoken[4];
00085     CMDPROC fn;
00086 } CMD, *PCMD;
00087
00088 // and here are the functions
00089
00090 BOOL fnQuit(char *);
00091 BOOL fnHelp(char *);
00092 BOOL fnVerbose(char *);
00093 BOOL fnLoad(char *);
00094 BOOL fnUnload(char *);
00095 BOOL fnEnum(char *);
00096 BOOL fnName(char *);
00097 BOOL fnAddr(char *);
00098 BOOL fnBase(char *);
00099 BOOL fnNext(char *);
00100 BOOL fnPrev(char *);
00101 BOOL fnLine(char *);
00102 BOOL fnLineNext(char *);
00103 BOOL fnLinePrev(char *);
00104 BOOL fnUndec(char *);
00105 BOOL fnFindFile(char *);
00106 BOOL fnAdd(char *);
00107 BOOL fnDelete(char *);
00108 BOOL fnEnumForAddr(char *);
00109 BOOL fnLocals(char *);
00110 BOOL fnType(char *);
00111 BOOL fnInfo(char *);
00112
00113 // array of command structs
00114
00115 CMD gCmd[cmdMax] =
00116 {
00117     {"addr",    "a", fnAddr},
00118     {"base",    "b", fnBase},
00119 //  {"",        "c", fn},
00120 //  {"",        "d", fn},
00121 //  {"elines",  "e",  fnEnumLines},
00122     {"ff",      "f", fnFindFile},
00123 //  {"",        "g", fn},
00124 //  {"",        "h", fn},
00125     {"info",    "i",  fnInfo},
00126     {"linenext","j", fnLineNext},
00127     {"lineprev","k", fnLinePrev},
00128     {"line",    "l", fnLine},
00129     {"enumaddr","m", fnEnumForAddr},
00130     {"name",    "n", fnName},
00131 //  {"obj",     "o", fnObj},
00132     {"prev",    "p", fnPrev},
00133     {"quit",    "q", fnQuit},
00134 //  {"src",     "r", fnEnumSrcFiles},
00135     {"next",    "s", fnNext},
00136     {"type",    "t", fnType},
00137     {"unload",  "u", fnUnload},
00138     {"verbose", "v", fnVerbose},
00139 //  {"",        "w", fn},
00140     {"enum",    "x", fnEnum},
00141 //  {"ss",      "y", fnSymbolServer},
00142     {"locals",  "z", fnLocals},
00143
00144     {"add",     "+", fnAdd},
00145     {"del",     "-", fnDelete},
00146     {"help",    "?", fnHelp},
00147     {"undec",   "",  fnUndec},
00148     {"load",    "",  fnLoad},
00149 //  {"map",     "",  fnMap},
00150 //  {"multi",   "",  fnMulti},
00151 //  {"etag",    "",  fnEnumTag},
00152 };
00153
00154 // globals
00155
00156 char            gModName[MAX_STR] = "";
00157 char            gImageName[MAX_STR];
00158 char            gSymbolSearchPath[MAX_STR];
00159 DWORD64         gBase;
00160 DWORD64         gDefaultBase;
00161 DWORD64         gDefaultBaseForVirtualMods;
00162 DWORD           gOptions;
00163 HANDLE          gTID;
00164 IMAGEHLP_LINE64 gLine;
00165 char            gExecCmd[MAX_STR] = "";
00166 char            gSrcFileName[MAX_PATH + 1] = "";
00167 char            gObj[MAX_PATH + 1] = "";
00168
00169
00170 // Use this to display verbose information, when
00171 // the -v switch is used.
00172
00173 int
00174 dprintf(
00175     LPSTR Format,
00176     ...
00177     )
00178 {
00179     static char buf[1000] = "";
00180     va_list args;
00181
00182     if ((gOptions & SYMOPT_DEBUG) == 0)
00183         return 1;
00184
00185     va_start(args, Format);
00186     StringCchVPrintf(buf, DIMA(buf), Format, args);
00187     va_end(args);
00188     fputs(buf, stdout);
00189     return 1;
00190 }
00191
00192
00193 __inline int ucase(int c)
00194 {
00195     return (gOptions & SYMOPT_CASE_INSENSITIVE) ? toupper(c) : c;
00196 }
00197
00198
00199 #define MAX_FORMAT_STRINGS 8
00200
00201 char *
00202 _dispaddr(
00203     ULONG64 addr,
00204     BOOL    pad
00205     )
00206 {
00207     static char sz[20];
00208
00209     if ((addr >> 32) != 0)
00210         StringCchPrintf(sz, DIMA(sz), "%8x`%08x", (ULONG)(addr>>32), (ULONG)addr);
00211     else
00212         StringCchPrintf(sz, DIMA(sz), pad ? "         %8x" : "%8x", (ULONG)addr);
00213     return sz;
00214 }
00215
00216 #define dispaddr(addr) _dispaddr(addr, false)
00217
00218 BOOL
00219 validnum(
00220     char *sz
00221     )
00222 {
00223     int c;
00224
00225     for (; *sz; sz++)
00226     {
00227         c = tolower(*sz);
00228         if (c >= '0' && c <= '9')
00229             continue;
00230         if (c >= 'a' && c <= 'f')
00231             continue;
00232         return false;
00233     }
00234
00235     return true;
00236 }
00237
00238 DWORD64
00239 sz2addr(
00240     char *sz
00241     )
00242 {
00243     char   *p;
00244     DWORD64 addr = 0;
00245
00246     if (sz && *sz)
00247     {
00248         p = sz;
00249         if (*(p + 1) == 'x' || *(p + 1) == 'X')
00250             p += 2;
00251         if (!validnum(p))
00252             return 0;
00253         if (sscanf(p, "%I64x", &addr) < 1)
00254             return 0;
00255     }
00256
00257     return addr;
00258 }
00259
00260
00261 void _dumpsym(
00262     PIMAGEHLP_SYMBOL64 sym,
00263     BOOL               pad
00264     )
00265 {
00266     printf(" name : %s\n", sym->Name);
00267     printf(" addr : %s\n", _dispaddr(sym->Address, pad));
00268     printf(" size : %x\n", sym->Size);
00269     printf("flags : %x\n", sym->Flags);
00270 }
00271
00272 #define dumpsym(sym) _dumpsym(sym, false)
00273
00274 void dumpsym32(
00275     PIMAGEHLP_SYMBOL sym
00276     )
00277 {
00278     printf(" name : %s\n", sym->Name);
00279     printf(" addr : %s\n", dispaddr(sym->Address));
00280     printf(" size : %x\n", sym->Size);
00281     printf("flags : %x\n", sym->Flags);
00282 }
00283
00284
00285 void dumpLine(
00286     PIMAGEHLP_LINE64 line
00287     )
00288 {
00289     printf("file : %s\n", line->FileName);
00290     printf("line : %d\n", line->LineNumber);
00291     printf("addr : %s\n", dispaddr(line->Address));
00292 }
00293
00294
00295 #ifndef _WIN64
00296 void dumpdbi(
00297     PIMAGE_DEBUG_INFORMATION dbi
00298     )
00299 {
00300     printf("              List : 0x%x\n", dbi->List);
00301     printf("         ImageBase : 0x%x\n", dbi->ImageBase);
00302     printf("       SizeOfImage : 0x%x\n", dbi->SizeOfImage);
00303     printf(" SizeOfCoffSymbols : 0x%x\n", dbi->SizeOfCoffSymbols);
00304     printf("       CoffSymbols : 0x%x\n", dbi->CoffSymbols);
00305     printf("     ImageFilePath : %s\n",   dbi->ImageFilePath);
00306     printf("     ImageFileName : %s\n",   dbi->ImageFileName);
00307 }
00308 #endif
00309
00310 // This stuff displays the symbol tag descriptions.
00311
00312 #ifndef SymTagMax
00313  // normally found in cvconst.h which ships with Visual Studio
00314  #define SymTagMax 0x1f
00315 #endif
00316
00317 char* g_SymTagNames[] =
00318 {
00319     "SymTagNull",
00320     "SymTagExe",
00321     "SymTagCompiland",
00322     "SymTagCompilandDetails",
00323     "SymTagCompilandEnv",
00324     "SymTagFunction",
00325     "SymTagBlock",
00326     "SymTagData",
00327     "SymTagAnnotation",
00328     "SymTagLabel",
00329     "SymTagPublicSymbol",
00330     "SymTagUDT",
00331     "SymTagEnum",
00332     "SymTagFunctionType",
00333     "SymTagPointerType",
00334     "SymTagArrayType",
00335     "SymTagBaseType",
00336     "SymTagTypedef",
00337     "SymTagBaseClass",
00338     "SymTagFriend",
00339     "SymTagFunctionArgType",
00340     "SymTagFuncDebugStart",
00341     "SymTagFuncDebugEnd",
00342     "SymTagUsingNamespace",
00343     "SymTagVTableShape",
00344     "SymTagVTable",
00345     "SymTagCustom",
00346     "SymTagThunk",
00347     "SymTagCustomType",
00348     "SymTagManagedType",
00349     "SymTagDimension",
00350 };
00351
00352 char* dispsymtag(
00353     ULONG symtag
00354     )
00355 {
00356     if (symtag >= SymTagMax) {
00357         return "<Invalid>";
00358     } else {
00359         return g_SymTagNames[symtag];
00360     }
00361 }
00362
00363
00364 void dumpsi(
00365     PSYMBOL_INFO si
00366     )
00367 {
00368     printf("   name : %s\n", si->Name);
00369     printf("   addr : %s\n", dispaddr(si->Address));
00370     printf("   size : %x\n", si->Size);
00371     printf("  flags : %x\n", si->Flags);
00372     printf("   type : %x\n", si->TypeIndex);
00373     printf("modbase : %s\n", dispaddr(si->ModBase));
00374     printf("  value : %s\n", dispaddr(si->Value));
00375     printf("    reg : %x\n", si->Register);
00376     printf("  scope : %s (%x)\n", dispsymtag(si->Scope), si->Scope);
00377     printf("    tag : %s (%x)\n", dispsymtag(si->Tag), si->Tag);
00378 }
00379
00380
00381 BOOL
00382 CALLBACK
00383 cbEnumSymbols(
00384     PSYMBOL_INFO  si,
00385     ULONG         size,
00386     PVOID         context
00387     )
00388 {
00389     PENUMSYMDATA esd = (PENUMSYMDATA)context;
00390
00391     printf(" %8s : ", _dispaddr(si->Address, true));
00392     if (si->Flags & SYMF_FORWARDER)
00393         printf("%c ", 'F');
00394     else if (si->Flags & SYMF_EXPORT)
00395         printf("%c ", 'E');
00396     else
00397         printf("  ");
00398     printf("%s\n", si->Name);
00399
00400     return true;
00401 }
00402
00403
00404 BOOL
00405 cbSrcFiles(
00406     PSOURCEFILE pSourceFile,
00407     PVOID       UserContext
00408     )
00409 {
00410     if (!pSourceFile)
00411         return false;
00412
00413     printf("%s\n", pSourceFile->FileName);
00414
00415     return true;
00416 }
00417
00418
00419 BOOL
00420 CALLBACK
00421 cbSymbol(
00422     HANDLE  hProcess,
00423     ULONG   ActionCode,
00424     ULONG64 CallbackData,
00425     ULONG64 UserContext
00426     )
00427 {
00428     PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 idsl;
00429
00430     idsl = (PIMAGEHLP_DEFERRED_SYMBOL_LOAD64) CallbackData;
00431
00432     switch ( ActionCode )
00433     {
00434     case CBA_DEBUG_INFO:
00435         printf("%s", (LPSTR)CallbackData);
00436         break;
00437
00438     default:
00439         return false;
00440     }
00441
00442     return false;
00443 }
00444
00445
00446 // exit this program
00447
00448 BOOL fnQuit(char *param)
00449 {
00450     printf("goodbye\n");
00451     return false;
00452 }
00453
00454
00455 // display command help
00456
00457 BOOL fnHelp(char *param)
00458 {
00459     printf("      dbh commands :\n");
00460     printf("?             help : prints this message\n");
00461     printf("q             quit : quits this program\n");
00462     printf("v verbose <on/off> : controls debug spew\n");
00463     printf("    load <modname> : loads the requested module\n");
00464     printf("u           unload : unloads the current module\n");
00465     printf("x      enum <mask> : enumerates all matching symbols\n");
00466     printf("n   name <symname> : finds a symbol by it's name\n");
00467     printf("a      addr <addr> : finds a symbol by it's hex address\n");
00468     printf("m  enumaddr <addr> : lists all symbols with a certain hex address\n");
00469     printf("b   base <address> : sets the new default base address\n");
00470     printf("s   next <add/nam> : finds the symbol after the passed sym\n");
00471     printf("p   prev <add/nam> : finds the symbol before the passed sym\n");
00472     printf("l    line <file:#> : finds the matching line number\n");
00473     printf("j         linenext : goes to the next line after the current\n");
00474     printf("k         lineprev : goes to the line previous to the current\n");
00475     printf("f ff <path> <file> : finds file in path\n");
00476     printf("+  add <name addr> : adds symbols with passed name and address\n");
00477     printf("-  del <name/addr> : deletes symbols with passed name or address\n");
00478     printf("m  enumaddr <addr> : enum all symbols for address\n");
00479     printf("z    locals <name> : enum all scoped symbols for a named function\n");
00480     printf("t      type <name> : lists the type information for the symbol\n");
00481     printf("i             info : displays information about the loaded module\n");
00482     printf("      undec <name> : undecorates a given symbol name\n");
00483
00484     return true;
00485 }
00486
00487
00488 // display debug spew from debughlp
00489
00490 BOOL fnVerbose(char *param)
00491 {
00492     int opts = gOptions;
00493
00494     if (!param || !*param)
00495         printf("");
00496     else if (!_strcmpi(param, "on"))
00497         opts |= SYMOPT_DEBUG;
00498     else if (!_strcmpi(param, "off"))
00499         opts = gOptions & ~SYMOPT_DEBUG;
00500     else
00501         printf("verbose <on//off>\n");
00502
00503     gOptions = SymSetOptions(opts);
00504
00505     printf("verbose mode %s.\n", gOptions & SYMOPT_DEBUG ? "on" : "off");
00506
00507     return true;
00508 }
00509
00510
00511 // load an image
00512
00513 BOOL fnLoad(char *param)
00514 {
00515     char    ext[MAX_STR];
00516     char    mod[MAX_STR];
00517     DWORD   flags = 0;
00518     DWORD64 addr  = 0;
00519     DWORD   size  = 0x1000000;
00520     HANDLE  hf = NULL;
00521     BOOL    dontopen = false;
00522
00523     if (!*param)
00524     {
00525         printf("load <modname> - you must specify a module to load\n");
00526         return true;
00527     }
00528
00529     _splitpath(param, NULL, NULL, mod, ext);
00530
00531     if (!*ext) {
00532         flags = SLMFLAG_VIRTUAL;
00533         addr = gDefaultBaseForVirtualMods;
00534     } else if (!_strcmpi(ext, ".pdb")) {
00535         addr = gDefaultBaseForVirtualMods;
00536         dontopen = true;
00537     } else {
00538         addr = gDefaultBase;
00539     }
00540
00541     fnUnload(NULL);
00542
00543     StringCchCopy(gModName, DIMA(gModName), mod);
00544
00545     // you can do this with or without an open file handle
00546
00547     if (!dontopen) {
00548         hf = CreateFile(param,
00549                         GENERIC_READ,
00550                         0,
00551                         NULL,
00552                         OPEN_EXISTING,
00553                         0,
00554                         0);
00555         size = GetFileSize(hf, NULL);
00556     }
00557
00558     addr = SymLoadModuleEx(gTID,
00559                            hf,         // hFile,
00560                            param,      // ImageName,
00561                            mod,        // ModuleName,
00562                            addr,       // BaseOfDll,
00563                            size,       // SizeOfDll
00564                            NULL,       // Data
00565                            flags);     // Flags
00566
00567     if (!addr)
00568     {
00569         *gModName = 0;
00570         printf("error 0x%x loading %s.\n", GetLastError(), param);
00571         return true;
00572     }
00573     StringCchCopy(gImageName, DIMA(gImageName), param);
00574     gBase = addr;
00575
00576     if (hf != INVALID_HANDLE_VALUE)
00577         CloseHandle(hf);
00578
00579     return true;
00580 }
00581
00582
00583 // unload the image
00584
00585 BOOL fnUnload(char *param)
00586 {
00587     if (!gBase)
00588         return true;
00589
00590     if (!SymUnloadModule64(gTID, gBase))
00591         printf("error unloading %s at %s\n", gModName, dispaddr(gBase));
00592
00593     gBase = 0;
00594     *gModName = 0;
00595
00596     return true;
00597 }
00598
00599
00600 // enumerate the symbols
00601
00602 BOOL fnEnum(char *param)
00603 {
00604     BOOL rc;
00605     ENUMSYMDATA esd;
00606
00607     esd.base = gBase;
00608     StringCchCopy(esd.mask, MAX_STR, param ? param : "");
00609
00610     rc = SymEnumSymbols(gTID, gBase, param, cbEnumSymbols, &esd);
00611     if (!rc)
00612         printf("error 0x%x calling SymEnumSymbols()\n", GetLastError());
00613
00614     return true;
00615 }
00616
00617
00618 // search for a symbol by name
00619
00620 BOOL fnName(char *param)
00621 {
00622     SYMBOL_INFO_PACKAGE sip;    // this struct saves allocation code
00623     char         name[MAX_STR];
00624
00625     if (!param || !*param)
00626     {
00627         printf("name <symbolname> - finds a symbol by it's name\n");
00628         return true;
00629     }
00630     StringCchPrintf(name, DIMA(name), "%s!%s", gModName, param);
00631
00632     ZeroMemory(&sip, sizeof(sip));
00633     sip.si.MaxNameLen = MAX_SYM_NAME;
00634
00635     if (SymFromName(gTID, name, &sip.si))
00636         dumpsi(&sip.si);
00637
00638     return true;
00639 }
00640
00641
00642 // search for a symbol by address
00643
00644 BOOL fnAddr(char *param)
00645 {
00646     BOOL               rc;
00647     DWORD64            addr;
00648     DWORD64            disp;
00649     PSYMBOL_INFO       si;
00650
00651     addr = sz2addr(param);
00652     if (!addr)
00653     {
00654         printf("addr <address> : finds a symbol by it's hex address\n");
00655         return true;
00656     }
00657
00658     si = (PSYMBOL_INFO)malloc(SI_BUFFER_SIZE);
00659     if (!si)
00660         return false;
00661     ZeroMemory(si, SI_BUFFER_SIZE);
00662     si->MaxNameLen = MAX_SYM_NAME;
00663
00664     rc = SymFromAddr(gTID, addr, &disp, si);
00665     if (rc)
00666     {
00667         printf("%s", si->Name);
00668         if (disp)
00669             printf("+%I64x", disp);
00670         printf("\n");
00671         dumpsi(si);
00672     }
00673
00674     free(si);
00675
00676     return true;
00677 }
00678
00679
00680 // enumerate all symbols with the passed address
00681
00682 BOOL fnEnumForAddr(char *param)
00683 {
00684     BOOL               rc;
00685     DWORD64            addr;
00686     ENUMSYMDATA        esd;
00687
00688     addr = sz2addr(param);
00689     if (!addr)
00690     {
00691         printf("enumaddr <addr> : lists all symbols with a certain hex address\n");
00692         return true;
00693     }
00694
00695     esd.base = gBase;
00696     StringCchCopy(esd.mask, MAX_STR, "");
00697
00698     rc = SymEnumSymbolsForAddr(gTID, addr, cbEnumSymbols, &esd);
00699     if (!rc)
00700         printf("error 0x%0 calling SymEnumSymbolsForAddr()\n", GetLastError());
00701
00702     return true;
00703 }
00704
00705
00706 // find locals for passed symbol
00707
00708 BOOL fnLocals(char *param)
00709 {
00710     PSYMBOL_INFO         si;
00711     char                 name[MAX_STR];
00712     IMAGEHLP_STACK_FRAME frame;
00713     ENUMSYMDATA          esd;
00714
00715     if (!param || !*param)
00716     {
00717         printf("locals <symbolname> - finds all locals a function\n");
00718         return true;
00719     }
00720     StringCchPrintf(name, DIMA(name), "%s!%s", gModName, param);
00721
00722     si = (PSYMBOL_INFO)malloc(SI_BUFFER_SIZE);
00723     if (!si)
00724         return false;
00725     ZeroMemory(si, SI_BUFFER_SIZE);
00726     si->MaxNameLen = MAX_SYM_NAME;
00727
00728     if (!SymFromName(gTID, name, si))
00729         goto exit;
00730
00731     printf("dumping locals for %s...\n", si->Name);
00732
00733     ZeroMemory(&frame, sizeof(frame));
00734     frame.InstructionOffset = si->Address;
00735
00736     SymSetContext(gTID, &frame, NULL);
00737
00738     esd.base = gBase;
00739     StringCchCopy(esd.mask, MAX_STR, "*");
00740     if (!SymEnumSymbols(gTID, 0, esd.mask, cbEnumSymbols, &esd))
00741         printf("error 0x%0 calling SymEnumSymbols()\n", GetLastError());
00742
00743 exit:
00744     free(si);
00745
00746     return true;
00747 }
00748
00749
00750 // obtain simple type information
00751
00752 BOOL fnType(char *param)
00753 {
00754     PSYMBOL_INFO si;
00755
00756     if (!param || !*param)
00757     {
00758         printf("type <typename> - finds type info\n");
00759         return true;
00760     }
00761
00762     si = (PSYMBOL_INFO)malloc(SI_BUFFER_SIZE);
00763     if (!si)
00764         return false;
00765     ZeroMemory(si, SI_BUFFER_SIZE);
00766     si->MaxNameLen = MAX_SYM_NAME;
00767
00768     if (SymGetTypeFromName(gTID, gBase, param, si))
00769         dumpsi(si);
00770
00771     free(si);
00772
00773     return true;
00774 }
00775
00776
00777 // get module information
00778
00779 BOOL fnInfo(char *param)
00780 {
00781   IMAGEHLP_MODULE64 mi;
00782
00783     static char *symtypes[NumSymTypes] =
00784     {
00785         "SymNone",
00786         "SymCoff",
00787         "SymCv",
00788         "SymPdb",
00789         "SymExport",
00790         "SymDeferred",
00791         "SymSym",
00792         "SymDia",
00793         "SymVirtual"
00794     };
00795
00796     ZeroMemory((void *)&mi, sizeof(mi));
00797     mi.SizeOfStruct = sizeof(mi);
00798
00799   if (!SymGetModuleInfo64(gTID, gBase, &mi))
00800   {
00801     printf("error 0x%x calling SymGetModuleInfo64()\n", GetLastError());
00802     return true;
00803   }
00804
00805     printf("    SizeOfStruct : 0x%x\n", mi.SizeOfStruct);
00806     printf("     BaseOfImage : 0x%i64x\n", mi.BaseOfImage);
00807     printf("       ImageSize : 0x%x\n", mi.ImageSize);
00808     printf("   TimeDateStamp : 0x%x\n", mi.TimeDateStamp);
00809     printf("        CheckSum : 0x%x\n", mi.CheckSum);
00810     printf("         NumSyms : 0x%x\n", mi.NumSyms);
00811     printf("         SymType : %s\n", symtypes[mi.SymType]);
00812     printf("      ModuleName : %s\n", mi.ModuleName);
00813     printf("       ImageName : %s\n", mi.ImageName);
00814     printf(" LoadedImageName : %s\n", mi.LoadedImageName);
00815
00816     return true;
00817 }
00818
00819
00820 PIMAGEHLP_SYMBOL64 SymbolFromName(char *param)
00821 {
00822     BOOL               rc;
00823     PIMAGEHLP_SYMBOL64 sym;
00824     char               name[MAX_STR];
00825
00826     if (!name || !*name)
00827         return NULL;
00828
00829     sym = (PIMAGEHLP_SYMBOL64)malloc(SYM_BUFFER_SIZE);
00830     if (!sym)
00831         return false;
00832     ZeroMemory(sym, SYM_BUFFER_SIZE);
00833     sym->MaxNameLength = MAX_SYM_NAME;
00834
00835     StringCchPrintf(name, DIMA(name), "%s!%s", gModName, param);
00836     rc = SymGetSymFromName64(gTID, name, sym);
00837     if (!rc) {
00838         free(sym);
00839         return NULL;
00840     }
00841
00842     return sym;
00843 }
00844
00845
00846 // worker function for the SymNext and SymPrev stuff
00847
00848 BOOL fnNextPrev(int direction, char *param)
00849 {
00850     BOOL               rc;
00851     PIMAGEHLP_SYMBOL64 sym;
00852     DWORD64            addr;
00853
00854     addr = sz2addr(param);
00855     if (!addr)
00856     {
00857         sym = SymbolFromName(param);
00858         if (!sym)
00859             return true;
00860         addr = sym->Address;
00861         if (!addr) {
00862             free(sym);
00863             return true;
00864         }
00865     }
00866     else
00867     {
00868         sym = (PIMAGEHLP_SYMBOL64)malloc(SYM_BUFFER_SIZE);
00869         if (!sym)
00870             return false;
00871         rc = SymGetSymFromAddr64(gTID, addr, NULL, sym);
00872         if (!rc)
00873             return true;
00874     }
00875
00876     if (direction > 0)
00877         rc = SymGetSymNext64(gTID, sym);
00878     else
00879         rc = SymGetSymPrev64(gTID, sym);
00880
00881     if (rc)
00882         dumpsym(sym);
00883
00884     free(sym);
00885
00886     return true;
00887 }
00888
00889
00890 // find the next symbol
00891
00892 BOOL fnNext(char *param)
00893 {
00894     return fnNextPrev(1, param);
00895 }
00896
00897
00898 // find the previous symbol
00899
00900 BOOL fnPrev(char *param)
00901 {
00902     return fnNextPrev(-1, param);
00903 }
00904
00905
00906 // set the module base and reload, if needed
00907
00908 BOOL fnBase(char *param)
00909 {
00910     DWORD64            addr;
00911
00912     addr = sz2addr(param);
00913     if (!addr)
00914     {
00915         printf("base <address> : sets the base address for module loads\n");
00916         return true;
00917     }
00918
00919     gDefaultBase = addr;
00920     gDefaultBaseForVirtualMods = addr;
00921     if (gBase)
00922         fnLoad(gImageName);
00923
00924     return true;
00925 }
00926
00927
00928 // search for a line by it's name
00929
00930 BOOL fnLine(char *param)
00931 {
00932     char              *file;
00933     DWORD              linenum;
00934     BOOL               rc;
00935     IMAGEHLP_LINE64    line;
00936     LONG               disp;
00937
00938     if (!param || !*param)
00939         return true;
00940
00941     file = param;
00942
00943     while (*param != ':') {
00944         if (!*param)
00945             return true;
00946         param++;
00947     }
00948     *param++ = 0;
00949     linenum = atoi(param);
00950     if (!linenum)
00951         return true;
00952
00953     memset(&line, 0, sizeof(line));
00954     line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
00955     rc = SymGetLineFromName64(gTID,
00956                               gModName,
00957                               file,
00958                               linenum,
00959                               &disp,
00960                               &line);
00961
00962     if (!rc) {
00963         printf("line: error 0x%x looking for %s#%d\n",
00964                GetLastError(),
00965                file,
00966                linenum);
00967         return true;
00968     }
00969
00970     dumpLine(&line);
00971     printf("disp : %x\n", disp);
00972
00973     // save for future next/prev calls
00974
00975     memcpy(&gLine, &line, sizeof(gLine));
00976
00977     return true;
00978 }
00979
00980
00981 // worker function for the LineNext and LinePrev stuff
00982
00983 BOOL lineNextPrev(BOOL prev)
00984 {
00985     BOOL               rc;
00986     IMAGEHLP_LINE64    line;
00987
00988     if (!gLine.SizeOfStruct)
00989         return true;
00990     memcpy(&line, &gLine, sizeof(line));
00991
00992     if (prev)
00993         rc = SymGetLinePrev64(gTID, &line);
00994     else
00995         rc = SymGetLineNext64(gTID, &line);
00996
00997     if (!rc) {
00998         printf("line: error 0x%x looking for %s#%d\n",
00999                GetLastError(),
01000                line.FileName,
01001                line.LineNumber);
01002         return true;
01003     }
01004
01005     dumpLine(&line);
01006
01007     // save for future next/prev calls
01008
01009     memcpy(&gLine, &line, sizeof(gLine));
01010
01011     return true;
01012 }
01013
01014
01015 // find the next line
01016
01017 BOOL fnLineNext(char *param)
01018 {
01019     return lineNextPrev(false);
01020 }
01021
01022
01023 // find the previous line
01024
01025 BOOL fnLinePrev(char *param)
01026 {
01027     return lineNextPrev(true);
01028 }
01029
01030
01031 // undecorate a symbol name
01032
01033 BOOL fnUndec(char *param)
01034 {
01035     DWORD rc;
01036     char uname[MAX_SYM_NAME + 1];
01037
01038     if (!param || !*param)
01039     {
01040         printf("undec <symbolname> - undecorates a C++ mangled symbol name\n");
01041         return true;
01042     }
01043
01044     rc = UnDecorateSymbolName(param, uname, MAX_SYM_NAME, UNDNAME_COMPLETE);
01045     if (!rc)
01046         printf("error 0x%u undecorating %s\n", GetLastError(), param);
01047     else
01048         printf("%s =\n%s\n", param, uname);
01049
01050     return true;
01051 }
01052
01053
01054 // search for a file in a tree
01055
01056 BOOL fnFindFile(char *param)
01057 {
01058     DWORD rc;
01059     char  root[MAX_PATH + 1];
01060     char  file[MAX_PATH + 1];
01061     char  found[MAX_PATH + 1];
01062
01063     if (!param)
01064     {
01065         printf("ff <root path> <file name> - finds file in path\n");
01066         return true;
01067     }
01068
01069     rc = sscanf(param, "%s %s", root, file);
01070     if ((rc < 2) || !*root || !*file)
01071     {
01072         printf("ff <root path> <file name> - finds file in path\n");
01073         return true;
01074     }
01075
01076     *found = 0;
01077
01078     rc = SearchTreeForFile(root, file, found);
01079
01080     if (!rc) {
01081         printf("error 0x%u looking for %s\n", GetLastError(), file);
01082     } else {
01083         printf("found %s\n", found);
01084     }
01085
01086     return true;
01087 }
01088
01089
01090 // create a virtual symbol
01091
01092 BOOL fnAdd(char *param)
01093 {
01094     BOOL               rc;
01095     DWORD64            addr;
01096     DWORD              size;
01097     char              *p;
01098     char               name[MAX_STR];
01099     char              *n;
01100
01101     if (!param || !*param) {
01102         printf("add <name address> : must specify a symbol name, address, and size.\n");
01103         return true;
01104     }
01105
01106     p = param;
01107     while (isspace(*p)) p++;
01108     *name = 0;
01109     for (n = name; *p; p++, n++) {
01110         if (isspace(*p)) {
01111             *n = 0;
01112             break;
01113         }
01114         *n = *p;
01115     }
01116
01117     addr = 0;
01118     size = 0;
01119     while (isspace(*p)) p++;
01120     if (*(p + 1) == 'x' || *(p + 1) == 'X')
01121         p += 2;
01122     rc = sscanf(p, "%I64x %x", &addr, &size);
01123     if ((rc < 2) || !addr || !*name)
01124     {
01125         printf("add <name address> : must specify a symbol name, address, and size.\n");
01126         return true;
01127     }
01128
01129     rc = SymAddSymbol(gTID, 0, name, addr, size, 0);
01130     if (!rc)
01131         printf("Error 0x%x trying to add symbol\n", GetLastError());
01132
01133     return true;
01134 }
01135
01136
01137 // delete a virtual symbol
01138
01139 BOOL fnDelete(char *param)
01140 {
01141     BOOL               rc;
01142     DWORD64            addr;
01143     DWORD              err;
01144     char              *name = NULL;
01145
01146     if (!param || !*param) {
01147         printf("del <name/address> : must specify a symbol name or address to delete.\n");
01148         return true;
01149     }
01150
01151     addr = sz2addr(param);
01152     if (!addr)
01153         name = param;
01154
01155     rc = SymDeleteSymbol(gTID, 0, name, addr, 0);
01156     if (!rc) {
01157         err = GetLastError();
01158         if (err == ERROR_NOT_FOUND)
01159             printf("Couldn't find %s to delete.\n", param);
01160         else
01161             printf("Error 0x%x trying to delete symbol\n", err);
01162     }
01163
01164     return true;
01165 }
01166
01167
01168 // read the command line
01169
01170 char *GetParameters(char *cmd)
01171 {
01172     char *p     = cmd;
01173     char *param = NULL;
01174
01175     while (*p++)
01176     {
01177         if (isspace(*p))
01178         {
01179             *p++ = 0;
01180              return *p ? p : NULL;
01181         }
01182     }
01183
01184     return NULL;
01185 }
01186
01187
01188 void prompt()
01189 {
01190     if (!*gModName)
01191         printf("dbh: ");
01192     else
01193         printf("%s [%I64x]: ", gModName, gBase);
01194 }
01195
01196
01197 char *
01198 getstr(
01199     char *buf,
01200     int size
01201     )
01202 {
01203     char *rc;
01204
01205     rc = fgets(buf, size, stdin);
01206     if (!rc)
01207         return 0;
01208
01209     while (*buf)
01210     {
01211         switch (*buf)
01212         {
01213         case 0xa:
01214             *buf = 0;
01215             // pass through
01216         case 0:
01217             return rc;
01218         }
01219         buf++;
01220     }
01221
01222     return rc;
01223 }
01224
01225
01226 int InputLoop()
01227 {
01228     char  cmd[MAX_STR + 1];
01229     char *params;
01230     int   i;
01231     BOOL  rc;
01232
01233     do
01234     {
01235         rc = true;
01236         prompt();
01237         if (*gExecCmd) {
01238             StringCchCopy(cmd, DIMA(cmd), gExecCmd);
01239             printf(cmd);
01240             printf("\n");
01241         } else if (!getstr(cmd, sizeof(cmd)))
01242             return 0;
01243         params = GetParameters(cmd);
01244
01245         for (i = 0; i < cmdMax; i++)
01246         {
01247             if (!_strcmpi(cmd, gCmd[i].token)
01248                 || !_strcmpi(cmd, gCmd[i].shorttoken))
01249             {
01250                 break;
01251             }
01252         }
01253
01254         if (i == cmdMax)
01255             printf("[%s] is an unrecognized command.\n", cmd);
01256         else
01257             rc = gCmd[i].fn(params);
01258
01259         if (*gExecCmd)
01260             rc = false;
01261     } while (rc);
01262
01263     return 0;
01264 }
01265
01266
01267 BOOL init()
01268 {
01269     int i;
01270     BOOL rc;
01271
01272     *gModName = 0;
01273     gBase = 0;;
01274     gDefaultBaseForVirtualMods = 0x1000000;
01275     gDefaultBase = 0x1000000;
01276     ZeroMemory(&gLine, sizeof(gLine));
01277
01278     dprintf("dbh: initializing...\n");
01279     i = GetEnvironmentVariable("_NT_SYMBOL_PATH", gSymbolSearchPath, MAX_STR);
01280     if (i < 1)
01281         *gSymbolSearchPath = 0;
01282     dprintf("Symbol Path = [%s]\n", gSymbolSearchPath);
01283
01284     gTID = (HANDLE)(ULONG_PTR)GetCurrentThreadId();
01285     rc = SymInitialize(gTID, gSymbolSearchPath, false);
01286     if (!rc)
01287     {
01288         printf("error 0x%x from SymInitialize()\n", GetLastError());
01289         return rc;
01290     }
01291     rc = SymInitialize(gTID, gSymbolSearchPath, false);
01292     if (!rc)
01293     {
01294         printf("error 0x%x from SymInitialize()\n", GetLastError());
01295         return rc;
01296     }
01297
01298     gOptions = SymSetOptions(SYMOPT_CASE_INSENSITIVE | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS | SYMOPT_AUTO_PUBLICS);
01299     dprintf("SymOpts = 0x%x\n", gOptions);
01300
01301     rc = SymRegisterCallback64(gTID, cbSymbol, 0);
01302     if (!rc)
01303     {
01304         printf("error 0x%x from SymRegisterCallback64()\n", GetLastError());
01305         return rc;
01306     }
01307
01308     return rc;
01309 }
01310
01311
01312 void cleanup()
01313 {
01314     int i;
01315
01316     fnUnload(NULL);
01317     for (i = 0; i < 50; i++)
01318         SymCleanup(gTID);
01319 }
01320
01321
01322 BOOL cmdline(int argc, char *argv[])
01323 {
01324     int   i;
01325     char *p;
01326
01327     for (i = 1; i < argc; i++)
01328     {
01329         p = argv[i];
01330         switch (*p)
01331         {
01332         case '/':
01333         case '-':
01334             p++;
01335             switch (tolower(*p))
01336             {
01337             case 'v':
01338                 fnVerbose("on");
01339                 break;
01340             default:
01341                 printf("%s is an unknown switch\n", argv[i]);
01342                 break;
01343             }
01344             break;
01345
01346         default:
01347             if (*gModName) {
01348                 StringCchCat(gExecCmd, DIMA(gExecCmd), argv[i]);
01349                 StringCchCat(gExecCmd, DIMA(gExecCmd), " ");
01350             } else
01351                 fnLoad(argv[i]);
01352             break;
01353         }
01354     }
01355
01356     return true;
01357 }
01358
01359 #include <crtdbg.h>
01360
01361 __cdecl
01362 main(
01363     int argc,
01364     char *argv[],
01365     char *envp[]
01366     )
01367 {
01368     DWORD rc;
01369
01370     _CrtSetDbgFlag( ( _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF ) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG ) );
01371
01372     if (!init())
01373         return 1;
01374     cmdline(argc, argv);
01375     rc = InputLoop();
01376     cleanup();
01377
01378     _CrtDumpMemoryLeaks();
01379
01380     return rc;
01381 }
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/DevGuide/banner.inc Source File

  • NetDS
  • ADSI
  • DevGuide

banner.inc

Go to the documentation of this file.
00001 <td valign="top" align="left" height="28"><!--webbot bot="ImageMap"
00002 rectangle="(420,1) (515, 18)  rtk.htm" rectangle="(350,1) (415, 19)  interopt.htm"
00003 rectangle="(233,1) (345, 19)  ad.htm" rectangle="(165,1) (223, 19)  winnt.htm"
00004 rectangle="(67,1) (165, 19)  dev.htm" rectangle="(13,1) (65, 20)  default.htm"
00005 src="router.gif" alt="router.gif (3874 bytes)" border="0" startspan --><MAP NAME="FrontPageMap"><AREA SHAPE="RECT" COORDS="420, 1, 515, 18" HREF="rtk.htm"><AREA SHAPE="RECT" COORDS="350, 1, 415, 19" HREF="interopt.htm"><AREA SHAPE="RECT" COORDS="233, 1, 345, 19" HREF="ad.htm"><AREA SHAPE="RECT" COORDS="165, 1, 223, 19" HREF="winnt.htm"><AREA SHAPE="RECT" COORDS="67, 1, 165, 19" HREF="dev.htm"><AREA SHAPE="RECT" COORDS="13, 1, 65, 20" HREF="default.htm"></MAP><a href="../_vti_bin/shtml.dll/sdk/dq.htm/map"><img src="router.gif" alt="router.gif (3874 bytes)" border="0" ismap width="536" height="26" usemap="#FrontPageMap"></a><!--webbot bot="ImageMap" endspan i-checksum="31120" --></td>
00006 <td width="3%" height="28"></td>
00007 <td width="21%" height="28"></td>
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step2/ADsFirstExt.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step2

ADsFirstExt.h

Go to the documentation of this file.
00001 /* this ALWAYS GENERATED file contains the definitions for the interfaces */
00002
00003
00004 /* File created by MIDL compiler version 5.01.0164 */
00005 /* at Mon Apr 29 12:54:31 2002
00006  */
00007 /* Compiler settings for C:\sdk\sdkpublic\samples\netds\adsi\samples\Extension\tutorial\Step2\ADsFirstExt.idl:
00008     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00009     error checks: allocation ref bounds_check enum stub_data
00010 */
00011 //@@MIDL_FILE_HEADING(  )
00012
00013
00014 /* verify that the <rpcndr.h> version is high enough to compile this file*/
00015 #ifndef __REQUIRED_RPCNDR_H_VERSION__
00016 #define __REQUIRED_RPCNDR_H_VERSION__ 440
00017 #endif
00018
00019 #include "rpc.h"
00020 #include "rpcndr.h"
00021
00022 #ifndef __RPCNDR_H_VERSION__
00023 #error this stub requires an updated version of <rpcndr.h>
00024 #endif // __RPCNDR_H_VERSION__
00025
00026 #ifndef COM_NO_WINDOWS_H
00027 #include "windows.h"
00028 #include "ole2.h"
00029 #endif /*COM_NO_WINDOWS_H*/
00030
00031 #ifndef __ADsFirstExt_h__
00032 #define __ADsFirstExt_h__
00033
00034 #ifdef __cplusplus
00035 extern "C"{
00036 #endif
00037
00038 /* Forward Declarations */
00039
00040 #ifndef __IHelloWorld_FWD_DEFINED__
00041 #define __IHelloWorld_FWD_DEFINED__
00042 typedef interface IHelloWorld IHelloWorld;
00043 #endif  /* __IHelloWorld_FWD_DEFINED__ */
00044
00045
00046 #ifndef __HelloWorld_FWD_DEFINED__
00047 #define __HelloWorld_FWD_DEFINED__
00048
00049 #ifdef __cplusplus
00050 typedef class HelloWorld HelloWorld;
00051 #else
00052 typedef struct HelloWorld HelloWorld;
00053 #endif /* __cplusplus */
00054
00055 #endif  /* __HelloWorld_FWD_DEFINED__ */
00056
00057
00058 /* header files for imported files */
00059 #include "oaidl.h"
00060 #include "ocidl.h"
00061
00062 void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
00063 void __RPC_USER MIDL_user_free( void __RPC_FAR * );
00064
00065 #ifndef __IHelloWorld_INTERFACE_DEFINED__
00066 #define __IHelloWorld_INTERFACE_DEFINED__
00067
00068 /* interface IHelloWorld */
00069 /* [unique][helpstring][dual][uuid][object] */
00070
00071
00072 EXTERN_C const IID IID_IHelloWorld;
00073
00074 #if defined(__cplusplus) && !defined(CINTERFACE)
00075
00076     MIDL_INTERFACE("E1E3EDF7-48D1-11D2-B22B-0000F87A6B50")
00077     IHelloWorld : public IDispatch
00078     {
00079     public:
00080         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Say( void) = 0;
00081
00082     };
00083
00084 #else   /* C style interface */
00085
00086     typedef struct IHelloWorldVtbl
00087     {
00088         BEGIN_INTERFACE
00089
00090         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00091             IHelloWorld __RPC_FAR * This,
00092             /* [in] */ REFIID riid,
00093             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00094
00095         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00096             IHelloWorld __RPC_FAR * This);
00097
00098         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00099             IHelloWorld __RPC_FAR * This);
00100
00101         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00102             IHelloWorld __RPC_FAR * This,
00103             /* [out] */ UINT __RPC_FAR *pctinfo);
00104
00105         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00106             IHelloWorld __RPC_FAR * This,
00107             /* [in] */ UINT iTInfo,
00108             /* [in] */ LCID lcid,
00109             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00110
00111         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00112             IHelloWorld __RPC_FAR * This,
00113             /* [in] */ REFIID riid,
00114             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00115             /* [in] */ UINT cNames,
00116             /* [in] */ LCID lcid,
00117             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00118
00119         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00120             IHelloWorld __RPC_FAR * This,
00121             /* [in] */ DISPID dispIdMember,
00122             /* [in] */ REFIID riid,
00123             /* [in] */ LCID lcid,
00124             /* [in] */ WORD wFlags,
00125             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00126             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00127             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00128             /* [out] */ UINT __RPC_FAR *puArgErr);
00129
00130         /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Say )(
00131             IHelloWorld __RPC_FAR * This);
00132
00133         END_INTERFACE
00134     } IHelloWorldVtbl;
00135
00136     interface IHelloWorld
00137     {
00138         CONST_VTBL struct IHelloWorldVtbl __RPC_FAR *lpVtbl;
00139     };
00140
00141
00142
00143 #ifdef COBJMACROS
00144
00145
00146 #define IHelloWorld_QueryInterface(This,riid,ppvObject) \
00147     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00148
00149 #define IHelloWorld_AddRef(This)  \
00150     (This)->lpVtbl -> AddRef(This)
00151
00152 #define IHelloWorld_Release(This) \
00153     (This)->lpVtbl -> Release(This)
00154
00155
00156 #define IHelloWorld_GetTypeInfoCount(This,pctinfo)  \
00157     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00158
00159 #define IHelloWorld_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
00160     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00161
00162 #define IHelloWorld_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
00163     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00164
00165 #define IHelloWorld_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
00166     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00167
00168
00169 #define IHelloWorld_Say(This) \
00170     (This)->lpVtbl -> Say(This)
00171
00172 #endif /* COBJMACROS */
00173
00174
00175 #endif  /* C style interface */
00176
00177
00178
00179 /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IHelloWorld_Say_Proxy(
00180     IHelloWorld __RPC_FAR * This);
00181
00182
00183 void __RPC_STUB IHelloWorld_Say_Stub(
00184     IRpcStubBuffer *This,
00185     IRpcChannelBuffer *_pRpcChannelBuffer,
00186     PRPC_MESSAGE _pRpcMessage,
00187     DWORD *_pdwStubPhase);
00188
00189
00190
00191 #endif  /* __IHelloWorld_INTERFACE_DEFINED__ */
00192
00193
00194
00195 #ifndef __ADSFIRSTEXTLib_LIBRARY_DEFINED__
00196 #define __ADSFIRSTEXTLib_LIBRARY_DEFINED__
00197
00198 /* library ADSFIRSTEXTLib */
00199 /* [helpstring][version][uuid] */
00200
00201
00202 EXTERN_C const IID LIBID_ADSFIRSTEXTLib;
00203
00204 EXTERN_C const CLSID CLSID_HelloWorld;
00205
00206 #ifdef __cplusplus
00207
00208 class DECLSPEC_UUID("E1E3EDF8-48D1-11D2-B22B-0000F87A6B50")
00209 HelloWorld;
00210 #endif
00211 #endif /* __ADSFIRSTEXTLib_LIBRARY_DEFINED__ */
00212
00213 /* Additional Prototypes for ALL interfaces */
00214
00215 /* end of Additional Prototypes */
00216
00217 #ifdef __cplusplus
00218 }
00219 #endif
00220
00221 #endif
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/localres.h Source File

  • SysMgmt
  • MMC
  • Menubtn

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventProvider/EvProv.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • EventProvider

EvProv.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  EVPROV.cpp
00006 //
00007 // Description:
00008 //    Sample event provider.
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #define _WIN32_WINNT 0x0500
00015 #ifndef _WIN32_DCOM
00016 #define _WIN32_DCOM
00017 #endif
00018
00019 #include <windows.h>
00020 #include <stdio.h>
00021 #include <objbase.h>
00022
00023 #include <wbemidl.h>
00024
00025 #include "oahelp.inl"
00026 #include "evprov.h"
00027
00028 #include <strsafe.h>
00029 #include <sddl.h>
00030
00031
00032 #define MASK_CLIENT_ACCESS_BIND 1
00033 static GENERIC_MAPPING s_ClientAccessMapping = {
00034   0,
00035   0,
00036   STANDARD_RIGHTS_REQUIRED | MASK_CLIENT_ACCESS_BIND,
00037   STANDARD_RIGHTS_REQUIRED | MASK_CLIENT_ACCESS_BIND
00038 };
00039
00040
00041 //***************************************************************************
00042 //
00043 //***************************************************************************
00044 // ok
00045
00046 CMyEventProvider::CMyEventProvider()
00047 {
00048     m_pNs = 0;
00049     m_pSink = 0;
00050     m_cRef = 0;
00051     m_pEventClassDef = 0;
00052     m_eStatus = Pending;
00053     m_hThread = 0;
00054 }
00055
00056
00057 //***************************************************************************
00058 //
00059 //***************************************************************************
00060 // ok
00061
00062 CMyEventProvider::~CMyEventProvider()
00063 {
00064     if (m_hThread)
00065         CloseHandle(m_hThread);
00066
00067     if (m_pNs)
00068         m_pNs->Release();
00069
00070     if (m_pSink)
00071         m_pSink->Release();
00072
00073     if (m_pEventClassDef)
00074         m_pEventClassDef->Release();
00075 }
00076
00077
00078 //***************************************************************************
00079 //
00080 //***************************************************************************
00081 // ok
00082
00083 STDMETHODIMP CMyEventProvider::QueryInterface(REFIID riid, LPVOID * ppv)
00084 {
00085     *ppv = 0;
00086
00087     if (IID_IUnknown==riid || IID_IWbemEventProvider==riid)
00088     {
00089         *ppv = (IWbemEventProvider *) this;
00090         AddRef();
00091         return NOERROR;
00092     }
00093
00094     if (IID_IWbemProviderInit==riid)
00095     {
00096         *ppv = (IWbemProviderInit *) this;
00097         AddRef();
00098         return NOERROR;
00099     }
00100
00101     return E_NOINTERFACE;
00102 }
00103
00104
00105
00106 //***************************************************************************
00107 //
00108 //***************************************************************************
00109 // ok
00110
00111 ULONG CMyEventProvider::AddRef()
00112 {
00113     return ++m_cRef;
00114 }
00115
00116
00117
00118 //***************************************************************************
00119 //
00120 //***************************************************************************
00121 // ok
00122
00123 ULONG CMyEventProvider::Release()
00124 {
00125     if (0 != --m_cRef)
00126         return m_cRef;
00127
00128     // If here, we are shutting down.
00129     // ==============================
00130
00131     m_eStatus = PendingStop;
00132
00133     return 0;
00134 }
00135
00136
00137 //***************************************************************************
00138 //
00139 //***************************************************************************
00140 // ok
00141
00142 HRESULT CMyEventProvider::ProvideEvents(
00143     /* [in] */ IWbemObjectSink __RPC_FAR *pSink,
00144     /* [in] */ long lFlags
00145     )
00146 {
00147     // Copy the sink.
00148     // ==============
00149
00150     m_pSink = pSink;
00151     m_pSink->AddRef();
00152
00153     // Create the event thread.
00154     // ========================
00155
00156     DWORD dwTID;
00157
00158     m_hThread = CreateThread(
00159         0,
00160         0,
00161         CMyEventProvider::EventThread,
00162         this,
00163         0,
00164         &dwTID
00165         );
00166
00167
00168     // Wait for provider to be 'ready'.
00169     // ================================
00170
00171     while (m_eStatus != Running)
00172         Sleep(100);
00173
00174     return WBEM_NO_ERROR;
00175 }
00176
00177
00178 //***************************************************************************
00179 //
00180 //  This particular provider, being in a DLL operates via its own thread.
00181 //
00182 //  In practice, such a provider would probably be implemented within a
00183 //  separate EXE.
00184 //
00185 //***************************************************************************
00186 // ok
00187
00188 DWORD WINAPI CMyEventProvider::EventThread(LPVOID pArg)
00189 {
00190     // Make transition to the per-instance method.
00191     // ===========================================
00192
00193     ((CMyEventProvider *)pArg)->InstanceThread();
00194     return 0;
00195 }
00196
00197 //***************************************************************************
00198 //
00199 //  Events are generated from here
00200 //
00201 //***************************************************************************
00202 // ok
00203
00204 void CMyEventProvider::InstanceThread()
00205 {
00206     int nIteration = 0;
00207
00208     CoInitializeEx(NULL, COINIT_MULTITHREADED);
00209
00210     m_eStatus = Running;
00211
00212     while (m_eStatus == Running)
00213     {
00214         Sleep(2000);    // Provide an event every two seconds
00215
00216
00217         // Generate a new event object.
00218         // ============================
00219
00220         IWbemClassObject *pEvt = 0;
00221
00222         HRESULT hRes = m_pEventClassDef->SpawnInstance(0, &pEvt);
00223         if (hRes != 0)
00224             continue;   // Failed
00225
00226
00227         // Generate some values to put in the event.
00228         // =========================================
00229
00230         wchar_t Buf[128];
00231     StringCbPrintfW(Buf, sizeof(Buf), L"Test Event <%d>", nIteration);
00232
00233         CVARIANT vName(Buf);
00234         hRes = pEvt->Put(CBSTR(L"Name"), 0, vName, 0);
00235     if (FAILED(hRes))
00236         {
00237             // If here, delivery failed.  This could be due to an out of memory condition.
00238       // Do something to report it.
00239     }
00240
00241         CVARIANT vCount((LONG) nIteration);
00242         hRes = pEvt->Put(CBSTR(L"Value"), 0, vCount, 0);
00243     if (FAILED(hRes))
00244         {
00245             // If here, delivery failed.  This could be due to an out of memory condition.
00246       // Do something to report it.
00247     }
00248
00249         // Deliver the event to CIMOM.
00250         // ============================
00251
00252         hRes = m_pSink->Indicate(1, &pEvt);
00253
00254         if (FAILED(hRes))
00255         {
00256             // If here, delivery failed.  Do something to report it.
00257         }
00258
00259         pEvt->Release();
00260         nIteration++;
00261     }
00262
00263     // When we get to here, we are no longer interested in the
00264     // provider and Release() has long since returned.
00265
00266     m_eStatus = Stopped;
00267     delete this;
00268 }
00269
00270
00271
00272
00273
00274 //***************************************************************************
00275 //
00276 //***************************************************************************
00277
00278     // Inherited from IWbemProviderInit
00279     // ================================
00280
00281 HRESULT CMyEventProvider::Initialize(
00282             /* [in] */ LPWSTR pszUser,
00283             /* [in] */ LONG lFlags,
00284             /* [in] */ LPWSTR pszNamespace,
00285             /* [in] */ LPWSTR pszLocale,
00286             /* [in] */ IWbemServices __RPC_FAR *pNamespace,
00287             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00288             /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink
00289             )
00290 {
00291     // We don't care about most of the incoming parameters in this
00292     // simple sample.  However, we will save the namespace pointer
00293     // and get our event class definition.
00294     // ===========================================================
00295     if(! pNamespace)
00296   {
00297       pInitSink->SetStatus(WBEM_E_FAILED , 0);
00298       return WBEM_NO_ERROR;
00299   }
00300
00301   m_pNs = pNamespace;
00302   m_pNs->AddRef();
00303
00304
00305     // Grab the class definition for the event.
00306     // ======================================
00307
00308     IWbemClassObject *pObj = 0;
00309
00310     HRESULT hRes = m_pNs->GetObject(
00311         CBSTR(EVENTCLASS),
00312         0,
00313         pCtx,
00314         &pObj,
00315         0
00316         );
00317
00318     if (hRes != 0)
00319   {
00320       pInitSink->SetStatus(WBEM_E_FAILED , 0);
00321       return WBEM_NO_ERROR;
00322   }
00323
00324     m_pEventClassDef = pObj;
00325
00326     // Tell CIMOM that we're up and running.
00327     // =====================================
00328
00329     pInitSink->SetStatus(WBEM_S_INITIALIZED,0);
00330
00331     return WBEM_NO_ERROR;
00332 }
00333
00334 // ================================
00335 // Inherited from IWbemEventProviderSecurity. This sample does not analyze the query and
00336 // applies the same policy to all queries.
00337 // ================================
00338
00339 HRESULT CMyEventProvider::AccessCheck(
00340                 WBEM_CWSTR wszQueryLanguage,
00341                 WBEM_CWSTR wszQuery,
00342                 long lSidLength,
00343                 const BYTE* pSid)
00344 {
00345
00346   HRESULT hr = WBEM_S_NO_ERROR;
00347
00348   //this is a temporary subscription, and therefore we have the thread token
00349
00350   //Grant access for built-in admins, local system, local admins, local service and network service.
00351   PSECURITY_DESCRIPTOR secDescriptor = NULL;
00352   BOOL bRes = ConvertStringSecurityDescriptorToSecurityDescriptor //this function is only available on Windows 2000 and above
00353     ( "O:BAG:BAD:(A;;0x10000001;;;BA)(A;;0x10000001;;;SY)(A;;0x10000001;;;LA)(A;;0x10000001;;;SY)(A;;0x10000001;;;S-1-5-20)(A;;0x10000001;;;S-1-5-19)",
00354     SDDL_REVISION_1,
00355     (PSECURITY_DESCRIPTOR *) &secDescriptor,
00356     NULL);
00357
00358   if (! bRes)
00359   {
00360     return WBEM_E_ACCESS_DENIED;
00361   }
00362
00363   if (pSid == NULL)
00364   {
00365
00366
00367     hr = CoImpersonateClient () ;
00368     if ( FAILED ( hr ) )
00369     {
00370       LocalFree(secDescriptor);
00371       return WBEM_E_ACCESS_DENIED ;
00372     }
00373
00374     // perform an access check.
00375
00376     hr = CheckAccess((SECURITY_DESCRIPTOR *)secDescriptor,
00377               MASK_CLIENT_ACCESS_BIND,
00378               &s_ClientAccessMapping);
00379
00380     LocalFree(secDescriptor);
00381
00382     //  Revert before we perform any operations
00383     CoRevertToSelf () ;
00384
00385     if (FAILED(hr))
00386       return WBEM_E_ACCESS_DENIED;
00387     else
00388       return WBEM_S_NO_ERROR;
00389   }
00390   else
00391   {
00392     //check against the SID passed to us. This op
00393
00394     // Call GetSecurityDescriptorDacl() to obtain the DACL for secDescriptor.
00395     // Then, retrieve the access mask corresponding to permissions granted
00396     // by DACL to account denoted in pSid.  Please refer to Security SDK samples
00397     // and documentation for more details.
00398
00399     LocalFree(secDescriptor);
00400
00401         if(0) //pSID is not privileged enough to receive events from this proviuder
00402             return WBEM_E_ACCESS_DENIED;
00403     else
00404       return WBEM_S_NO_ERROR;
00405
00406   }
00407
00408   return WBEM_S_NO_ERROR;
00409 }
00410
00411 /******************************************************************************
00412  *
00413  *  Name: CheckAccess
00414  *
00415  *  Description:  Allow provider to evaluate permissions against a security descriptor
00416  *
00417  *  This method should be called by WMI providers in scenarios where
00418  *      they cannot or should not impersonate the client. This happens in two scenarios:
00419  *      a) when the providers access resources that are not protected by ACL's
00420  *      b) when the client connects at the impersonation level of RPC_C_IMP_LEVEL_IDENTIFY
00421  *
00422  *****************************************************************************/
00423
00424 HRESULT CMyEventProvider::CheckAccess (SECURITY_DESCRIPTOR *a_SecurityDescriptor ,
00425           DWORD a_Access ,
00426           GENERIC_MAPPING *a_Mapping)
00427 {
00428   HRESULT t_Result = S_OK ;
00429
00430   HANDLE t_Token = NULL ;
00431
00432   BOOL t_Status = OpenThreadToken (
00433
00434     GetCurrentThread () ,
00435     TOKEN_QUERY ,
00436     TRUE ,
00437     & t_Token
00438   ) ;
00439
00440   DWORD t_LastError = GetLastError () ;
00441   if ( ! t_Status)
00442   {
00443     //the thread token should always be available
00444
00445     if ( t_LastError ==E_ACCESSDENIED)
00446       return  WBEM_E_ACCESS_DENIED ;
00447     else
00448       return WBEM_E_FAILED ;
00449
00450   }
00451
00452
00453   DWORD t_Access = 0 ;
00454   BOOL t_AccessStatus = FALSE ;
00455   PRIVILEGE_SET *t_PrivilegeSet = NULL ;
00456   DWORD t_PrivilegeSetSize = 0 ;
00457
00458   MapGenericMask (
00459
00460     & a_Access ,
00461     a_Mapping
00462   ) ;
00463
00464   t_Status = ::AccessCheck (
00465
00466     a_SecurityDescriptor ,
00467     t_Token,
00468     a_Access ,
00469     a_Mapping ,
00470     NULL ,
00471     & t_PrivilegeSetSize ,
00472     & t_Access ,
00473     & t_AccessStatus
00474   ) ;
00475
00476   if (!t_Status || !t_AccessStatus )
00477   {
00478     DWORD t_LastError = GetLastError () ;
00479     if ( t_LastError == ERROR_INSUFFICIENT_BUFFER )
00480     {
00481       t_PrivilegeSet = ( PRIVILEGE_SET * ) new BYTE [ t_PrivilegeSetSize ] ;
00482       if ( t_PrivilegeSet )
00483       {
00484         t_Status = ::AccessCheck (
00485           a_SecurityDescriptor ,
00486           t_Token,
00487           a_Access ,
00488           a_Mapping ,
00489           t_PrivilegeSet ,
00490           & t_PrivilegeSetSize ,
00491           & t_Access ,
00492           & t_AccessStatus
00493         ) ;
00494
00495         if ( !t_Status || !t_AccessStatus )
00496         {
00497           t_Result = WBEM_E_ACCESS_DENIED ;
00498         }
00499
00500         delete [] ( BYTE * ) t_PrivilegeSet ;
00501       }
00502       else
00503       {
00504         t_Result = WBEM_E_OUT_OF_MEMORY ;
00505       }
00506     }
00507     else
00508     {
00509       t_Result = WBEM_E_ACCESS_DENIED;
00510     }
00511
00512   }
00513
00514   CloseHandle ( t_Token ) ;
00515
00516
00517   return t_Result ;
00518 }
00519
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagMULTI_SZ Member List

This is the complete list of members for tagMULTI_SZ, including all inherited members.
nChar | tagMULTI_SZ
pwszValue | tagMULTI_SZ
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/Driver/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • Driver

StdAfx.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      stdafx.cpp
00003
00004   Summary:   source file that includes just the standard includes
00005              stdafx.pch will be the pre-compiled header
00006              stdafx.obj will contain the pre-compiled type information
00007
00008   Classes:   None
00009 -----------------------------------------------------------------------------
00010
00011 This file is part of the Microsoft COM+ Samples.
00012
00013 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00014
00015 This source code is intended only as a supplement to Microsoft
00016 Development Tools and/or on-line documentation. See these other
00017 materials for detailed information regarding Microsoft code samples.
00018
00019 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00020 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00022 PARTICULAR PURPOSE.
00023
00024 ==========================================================================+*/
00025
00026 #include "stdafx.h"
00027
00028
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/EnumDesk/list.cpp Source File

  • WinUI
  • Shell
  • EnumDesk

list.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          List.cpp
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023 #include <windowsx.h>
00024 #include <commctrl.h>
00025 #include <shlobj.h>
00026 #include "EnumDesk.h"
00027 #include "resource.h"
00028
00029 /**************************************************************************
00030    function prototypes
00031 **************************************************************************/
00032
00033 void List_EnumObjects(HWND, LPSHELLFOLDER, LPITEMIDLIST);
00034 int CALLBACK List_CompareProc(LPARAM, LPARAM, LPARAM);
00035 void List_DoDefault(HWND hwndListView, int iItem);
00036
00037 /**************************************************************************
00038    global variables and definitions
00039 **************************************************************************/
00040
00041 IShellFolder   *g_psfCurFolder = NULL;
00042 LPITEMIDLIST   g_pidlCurFQ = NULL;
00043
00044 /******************************************************************************
00045
00046    List_Create
00047
00048 ******************************************************************************/
00049
00050 HWND List_Create( HINSTANCE hInstance,
00051                   HWND hwndParent,
00052                   HIMAGELIST himlLarge,
00053                   HIMAGELIST himlSmall)
00054 {
00055 DWORD       dwStyle;
00056 HWND        hwndListView;
00057
00058 dwStyle =   WS_TABSTOP |
00059             WS_CHILD |
00060             WS_BORDER |
00061             WS_VISIBLE |
00062             LVS_AUTOARRANGE |
00063             LVS_LIST |
00064             LVS_SHAREIMAGELISTS |
00065             LVS_SHOWSELALWAYS |
00066             0;
00067
00068 hwndListView = CreateWindowEx(   WS_EX_CLIENTEDGE,
00069                                  WC_LISTVIEW,
00070                                  NULL,
00071                                  dwStyle,
00072                                  0,
00073                                  0,
00074                                  0,
00075                                  0,
00076                                  hwndParent,
00077                                  (HMENU)IDC_LISTVIEW,
00078                                  hInstance,
00079                                  NULL);
00080
00081 if(hwndListView)
00082    {
00083    //set the image lists
00084    ListView_SetImageList(hwndListView, himlLarge, LVSIL_NORMAL);
00085    ListView_SetImageList(hwndListView, himlSmall, LVSIL_SMALL);
00086    }
00087
00088 return hwndListView;
00089 }
00090
00091 /**************************************************************************
00092
00093    List_ReleaseCurrentFolder()
00094
00095 **************************************************************************/
00096
00097 void List_ReleaseCurrentFolder(void)
00098 {
00099 if(g_psfCurFolder)
00100    {
00101    g_psfCurFolder->Release();
00102    g_psfCurFolder = NULL;
00103
00104    Pidl_Free(g_pidlCurFQ);
00105    g_pidlCurFQ = NULL;
00106    }
00107 }
00108
00109 /**************************************************************************
00110
00111    List_LockCurrentFolder()
00112
00113 **************************************************************************/
00114
00115 void List_LockCurrentFolder(LPITEMINFO pItemInfo)
00116 {
00117 if(pItemInfo && pItemInfo->pParentFolder)
00118    {
00119    pItemInfo->pParentFolder->BindToObject(pItemInfo->pidlRel, NULL, IID_IShellFolder, (LPVOID*)&g_psfCurFolder);
00120
00121    g_pidlCurFQ = Pidl_Copy(pItemInfo->pidlFQ);
00122    }
00123 else
00124    {
00125    SHGetDesktopFolder(&g_psfCurFolder);
00126
00127    if(pItemInfo)
00128       g_pidlCurFQ = Pidl_Copy(pItemInfo->pidlFQ);
00129    }
00130 }
00131
00132 /**************************************************************************
00133
00134    List_DisplayFolder()
00135
00136 **************************************************************************/
00137
00138 HRESULT List_DisplayFolder(HWND hwndListView, LPITEMINFO pItemInfo)
00139 {
00140 if(pItemInfo)
00141    {
00142    List_ReleaseCurrentFolder();
00143
00144    List_LockCurrentFolder(pItemInfo);
00145    }
00146
00147 HRESULT  hr = E_FAIL;
00148
00149 ListView_DeleteAllItems(hwndListView);
00150
00151 if(g_psfCurFolder)
00152    {
00153    HCURSOR  hCur = LoadCursor(NULL, IDC_WAIT);
00154
00155    hCur = SetCursor(hCur);
00156
00157    //turn redawing off in the ListView. This will speed things up as we add items
00158    SendMessage(hwndListView, WM_SETREDRAW, FALSE, 0);
00159
00160    List_EnumObjects(hwndListView, g_psfCurFolder, g_pidlCurFQ);
00161
00162    ListView_SortItems(hwndListView, List_CompareProc, 0);
00163
00164    //turn redawing back on
00165    SendMessage(hwndListView, WM_SETREDRAW, TRUE, 0);
00166
00167    SetCursor(hCur);
00168    }
00169
00170 return hr;
00171 }
00172
00173 /**************************************************************************
00174
00175    List_Refresh()
00176
00177 **************************************************************************/
00178
00179 HRESULT List_Refresh(HWND hwndListView)
00180 {
00181 return List_DisplayFolder(hwndListView, NULL);
00182 }
00183
00184 /**************************************************************************
00185
00186    List_Notify()
00187
00188 **************************************************************************/
00189
00190 LRESULT List_Notify(HWND hWnd, LPARAM lParam)
00191 {
00192 LPNMHDR  pnmh = (LPNMHDR) lParam;
00193 HWND     hwndListView = GetDlgItem(hWnd, IDC_LISTVIEW);
00194
00195 switch(pnmh->code)
00196    {
00197    case LVN_GETDISPINFO:
00198       {
00199       NMLVDISPINFO   *pdi = (NMLVDISPINFO*)lParam;
00200       LPITEMINFO     pItem = (LPITEMINFO)pdi->item.lParam;
00201
00202       //do we need to supply the text?
00203       if(pdi->item.mask & LVIF_TEXT)
00204          {
00205          switch(pdi->item.iSubItem)
00206             {
00207             case 0:  //name
00208                {
00209                SHFILEINFO     sfi;
00210
00211                //get the display name of the item
00212                if(SHGetFileInfo((LPCTSTR)pItem->pidlFQ, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME))
00213                   {
00214                   lstrcpyn(pdi->item.pszText, sfi.szDisplayName, pdi->item.cchTextMax);
00215                   }
00216                }
00217                break;
00218
00219             case 1:  //size
00220                break;
00221             }
00222          }
00223
00224       //do we need to supply the unselected image?
00225       if(pdi->item.mask & LVIF_IMAGE)
00226          {
00227          SHFILEINFO     sfi;
00228
00229          //get the unselected image for this item
00230          if(SHGetFileInfo((LPCTSTR)pItem->pidlFQ, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY))
00231             {
00232             pdi->item.iImage = sfi.iIcon;
00233             }
00234          }
00235       }
00236       break;
00237
00238    case LVN_DELETEITEM:
00239       {
00240       LPNMLISTVIEW   pnmlv = (LPNMLISTVIEW)lParam;
00241       LPITEMINFO     pItem = (LPITEMINFO)pnmlv->lParam;
00242
00243       //free up the pidls that we allocated
00244       Pidl_Free(pItem->pidlFQ);
00245       Pidl_Free(pItem->pidlRel);
00246
00247       //this may be NULL if this is the root item
00248       if(pItem->pParentFolder)
00249          pItem->pParentFolder->Release();
00250
00251       GlobalFree((HGLOBAL)pItem);
00252       }
00253       break;
00254
00255 #ifdef LVN_ITEMACTIVATE
00256
00257    case LVN_ITEMACTIVATE:
00258
00259 #else    //LVN_ITEMACTIVATE
00260
00261    case NM_DBLCLK:
00262    case NM_RETURN:
00263
00264 #endif   //LVN_ITEMACTIVATE
00265       {
00266       //get the item that has the focus
00267       int   nItem = ListView_GetNextItem(hwndListView, -1, LVNI_FOCUSED);
00268
00269       if(-1 != nItem)
00270          List_DoDefault(hwndListView, nItem);
00271       }
00272       break;
00273
00274    default:
00275       break;
00276    }
00277
00278 return 0;
00279 }
00280
00281 /**************************************************************************
00282
00283    List_EnumObjects
00284
00285 **************************************************************************/
00286
00287 void List_EnumObjects(  HWND hwndListView,
00288                         LPSHELLFOLDER pParentFolder,
00289                         LPITEMIDLIST pidlParent)
00290 {
00291 LPENUMIDLIST   pEnum;
00292
00293 if(SUCCEEDED(pParentFolder->EnumObjects(  NULL,
00294                                           SHCONTF_FOLDERS |
00295                                              SHCONTF_NONFOLDERS |
00296                                              SHCONTF_INCLUDEHIDDEN,
00297                                           &pEnum)))
00298    {
00299    LPITEMIDLIST   pidlTemp;
00300    DWORD          dwFetched = 1;
00301    LPITEMINFO     pItem;
00302
00303    //enumerate the item's PIDLs
00304    while(S_OK == (pEnum->Next(1, &pidlTemp, &dwFetched)) && dwFetched)
00305       {
00306       LVITEM   lvItem;
00307       DWORD    dwAttr;
00308
00309       ZeroMemory(&lvItem, sizeof(lvItem));
00310
00311       //fill in the TV_ITEM structure for this item
00312       lvItem.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
00313
00314       //AddRef the parent folder so it's pointer stays valid
00315       pParentFolder->AddRef();
00316
00317       //put the private information in the lParam
00318       pItem = (LPITEMINFO)GlobalAlloc(GPTR, sizeof(ITEMINFO));
00319
00320       pItem->pidlRel = pidlTemp;
00321       pItem->pidlFQ = Pidl_Concatenate(pidlParent, pidlTemp);
00322
00323       pItem->pParentFolder = pParentFolder;
00324       lvItem.lParam = (LPARAM)pItem;
00325
00326       //text and images are done on a callback basis
00327       lvItem.pszText = LPSTR_TEXTCALLBACK;
00328       lvItem.iImage = I_IMAGECALLBACK;
00329
00330       //determine if the item is shared
00331       dwAttr = SFGAO_DISPLAYATTRMASK;
00332       pParentFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlTemp, &dwAttr);
00333
00334       if(dwAttr & SFGAO_SHARE)
00335          {
00336          lvItem.mask |= LVIF_STATE;
00337          lvItem.stateMask |= LVIS_OVERLAYMASK;
00338          lvItem.state |= INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
00339          }
00340
00341       if(dwAttr & SFGAO_GHOSTED)
00342          {
00343          lvItem.mask |= LVIF_STATE;
00344          lvItem.stateMask |= LVIS_CUT;
00345          lvItem.state |= LVIS_CUT;
00346          }
00347
00348       ListView_InsertItem(hwndListView, &lvItem);
00349
00350       dwFetched = 0;
00351       }
00352
00353    pEnum->Release();
00354    }
00355 }
00356
00357 /**************************************************************************
00358
00359    List_CompareProc
00360
00361 **************************************************************************/
00362
00363 int CALLBACK List_CompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
00364 {
00365 UNREFERENCED_PARAMETER(lParamSort);
00366
00367 LPITEMINFO  pItem1 = (LPITEMINFO)lParam1;
00368 LPITEMINFO  pItem2 = (LPITEMINFO)lParam2;
00369 HRESULT     hr;
00370
00371 hr = pItem1->pParentFolder->CompareIDs(   0,
00372                                           pItem1->pidlRel,
00373                                           pItem2->pidlRel);
00374
00375 if(FAILED(hr))
00376    return 0;
00377
00378 return (short)SCODE_CODE(GetScode(hr));
00379 }
00380
00381 /**************************************************************************
00382
00383    List_DoItemMenu
00384
00385 **************************************************************************/
00386
00387 void List_DoItemMenu(   HWND hwndListView,
00388                         LPINT piItems,
00389                         UINT cbItems,
00390                         LPPOINT pptScreen)
00391 {
00392 LPITEMIDLIST   *pPidls;
00393
00394 pPidls = (LPITEMIDLIST*)g_pMalloc->Alloc(sizeof(LPITEMIDLIST) * cbItems);
00395 if(!pPidls)
00396    return;
00397
00398 LVITEM   lvItem;
00399 UINT     i;
00400
00401 for(i = 0; i < cbItems; i++)
00402    {
00403    ZeroMemory(&lvItem, sizeof(lvItem));
00404    lvItem.mask = LVIF_PARAM;
00405    lvItem.iItem = piItems[i];
00406    if(ListView_GetItem(hwndListView, &lvItem))
00407       {
00408       LPITEMINFO  pInfo = (LPITEMINFO)lvItem.lParam;
00409       pPidls[i] = pInfo->pidlRel;
00410       }
00411    }
00412
00413 if(pPidls[0])
00414    {
00415    HRESULT        hr;
00416    IContextMenu   *pcm;
00417
00418    if(g_psfCurFolder)
00419       {
00420       hr = g_psfCurFolder->GetUIObjectOf( hwndListView,
00421                                           cbItems,
00422                                           (LPCITEMIDLIST*)pPidls,
00423                                           IID_IContextMenu,
00424                                           NULL,
00425                                           (LPVOID*)&pcm);
00426
00427       if(SUCCEEDED(hr))
00428          {
00429          HMENU hPopup;
00430
00431          hPopup = CreatePopupMenu();
00432          if(hPopup)
00433             {
00434             hr = pcm->QueryContextMenu(hPopup, 0, 1, 0x7fff, CMF_NORMAL | CMF_EXPLORE);
00435
00436             if(SUCCEEDED(hr))
00437                {
00438                pcm->QueryInterface(IID_IContextMenu2, (LPVOID*)&g_pcm2);
00439
00440                UINT  idCmd;
00441
00442                idCmd = TrackPopupMenu( hPopup,
00443                                        TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON,
00444                                        pptScreen->x,
00445                                        pptScreen->y,
00446                                        0,
00447                                        GetParent(hwndListView),
00448                                        NULL);
00449
00450                if(g_pcm2)
00451                   {
00452                   g_pcm2->Release();
00453                   g_pcm2 = NULL;
00454                   }
00455
00456                if(idCmd)
00457                   {
00458                   CMINVOKECOMMANDINFO  cmi;
00459                   cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
00460                   cmi.fMask = 0;
00461                   cmi.hwnd = (HWND)GetParent(hwndListView);
00462                   cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1);
00463                   cmi.lpParameters = NULL;
00464                   cmi.lpDirectory = NULL;
00465                   cmi.nShow = SW_SHOWNORMAL;
00466                   cmi.dwHotKey = 0;
00467                   cmi.hIcon = NULL;
00468                   hr = pcm->InvokeCommand(&cmi);
00469
00470                   /*
00471                   The operation performed by the context menu may have changed
00472                   the contents of the folder, so do a refresh.
00473                   */
00474                   List_Refresh(hwndListView);
00475                   }
00476                }
00477             }
00478
00479          pcm->Release();
00480          }
00481       }
00482    }
00483
00484 g_pMalloc->Free(pPidls);
00485 }
00486
00487 /**************************************************************************
00488
00489    List_DoBackgroundMenu
00490
00491 **************************************************************************/
00492
00493 void List_DoBackgroundMenu(HWND hwndListView, LPPOINT pptScreen)
00494 {
00495 HWND           hwndParent = GetParent(hwndListView);
00496 HRESULT        hr;
00497
00498 if(g_psfCurFolder)
00499    {
00500    IContextMenu   *pcm;
00501
00502    hr = g_psfCurFolder->CreateViewObject( hwndParent,
00503                                           IID_IContextMenu,
00504                                           (LPVOID*)&pcm);
00505
00506    if(SUCCEEDED(hr))
00507       {
00508       HMENU hMenu;
00509
00510       hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_MAIN_MENU));
00511       if(hMenu)
00512          {
00513          HMENU hPopup;
00514          hPopup = GetSubMenu(hMenu, 1);
00515
00516          if(hPopup)
00517             {
00518             int   i;
00519             UINT  idCmdFirst;
00520             UINT  idCmd;
00521
00522             //find the largest ID in the menu
00523             i = 0;
00524             idCmdFirst = 0;
00525
00526             while((idCmd = GetMenuItemID(hPopup, i)) != (UINT)-1)
00527                {
00528                if(idCmd > idCmdFirst)
00529                   idCmdFirst = idCmd;
00530
00531                i++;
00532                }
00533
00534             hr = pcm->QueryContextMenu(hPopup, 0, ++idCmdFirst, (UINT)-1, CMF_NORMAL | CMF_EXPLORE);
00535
00536             if(SUCCEEDED(hr))
00537                {
00538                pcm->QueryInterface(IID_IContextMenu2, (LPVOID*)&g_pcm2);
00539
00540                idCmd = TrackPopupMenu( hPopup,
00541                                        TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON,
00542                                        pptScreen->x,
00543                                        pptScreen->y,
00544                                        0,
00545                                        hwndParent,
00546                                        NULL);
00547
00548                if(g_pcm2)
00549                   {
00550                   g_pcm2->Release();
00551                   g_pcm2 = NULL;
00552                   }
00553
00554                if(idCmd)
00555                   {
00556                   if(idCmd < idCmdFirst)
00557                      {
00558                      //this is one of our commands
00559                      FORWARD_WM_COMMAND(hwndParent, idCmd, NULL, 0, SendMessage);
00560                      }
00561                   else
00562                      {
00563                      CMINVOKECOMMANDINFO  cmi;
00564                      cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
00565                      cmi.fMask = 0;
00566                      cmi.hwnd = hwndParent;
00567                      cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - idCmdFirst);
00568                      cmi.lpParameters = NULL;
00569                      cmi.lpDirectory = NULL;
00570                      cmi.nShow = SW_SHOWNORMAL;
00571                      cmi.dwHotKey = 0;
00572                      cmi.hIcon = NULL;
00573                      hr = pcm->InvokeCommand(&cmi);
00574
00575                      /*
00576                      The operation performed by the context menu may have
00577                      changed the contents of the folder, so do a refresh.
00578                      */
00579                      List_Refresh(hwndListView);
00580                      }
00581                   }
00582                }
00583             }
00584          DestroyMenu(hMenu);
00585          }
00586
00587       pcm->Release();
00588       }
00589    }
00590 }
00591
00592 /**************************************************************************
00593
00594    List_DoContextMenu
00595
00596 **************************************************************************/
00597
00598 void List_DoContextMenu(HWND hwndListView, LPPOINT pptScreen)
00599 {
00600 LVHITTESTINFO  lvhti;
00601
00602 lvhti.pt = *pptScreen;
00603 ScreenToClient(hwndListView, &lvhti.pt);
00604
00605 lvhti.flags = LVHT_NOWHERE;
00606
00607 ListView_HitTest(hwndListView, &lvhti);
00608
00609 if(LVHT_ONITEM & lvhti.flags)
00610    {
00611    //get the selected items
00612    UINT  nItems = ListView_GetSelectedCount(hwndListView);
00613    LPINT pItems = (LPINT)GlobalAlloc(GPTR, sizeof(int) * nItems);
00614
00615    if(pItems)
00616       {
00617       UINT  i;
00618       int   nCurItem;
00619
00620       //put the item clicked on first in the list
00621       pItems[0] = lvhti.iItem;
00622
00623       for(i = 1, nCurItem = -1; i < nItems; i++)
00624          {
00625          nCurItem = ListView_GetNextItem(hwndListView, nCurItem, LVNI_SELECTED);
00626          if(nCurItem != lvhti.iItem)
00627             pItems[i] = nCurItem;
00628          else
00629             i--;
00630          }
00631
00632       List_DoItemMenu(hwndListView, pItems, nItems, pptScreen);
00633
00634       GlobalFree(pItems);
00635       }
00636    }
00637 else
00638    {
00639    List_DoBackgroundMenu(hwndListView, pptScreen);
00640    }
00641 }
00642
00643 /**************************************************************************
00644
00645    List_DoDefault
00646
00647 **************************************************************************/
00648
00649 void List_DoDefault(HWND hwndListView, int iItem)
00650 {
00651 LVITEM   lvItem;
00652
00653 ZeroMemory(&lvItem, sizeof(lvItem));
00654 lvItem.mask = LVIF_PARAM;
00655 lvItem.iItem = iItem;
00656
00657 if(ListView_GetItem(hwndListView, &lvItem))
00658    {
00659    HRESULT        hr;
00660    LPITEMINFO     pInfo = (LPITEMINFO)lvItem.lParam;
00661    IContextMenu   *pcm;
00662    IShellFolder   *psfFolder = pInfo->pParentFolder;
00663
00664    if(!psfFolder)
00665       {
00666       SHGetDesktopFolder(&psfFolder);
00667       }
00668    else
00669       {
00670       psfFolder->AddRef();
00671       }
00672
00673    if(psfFolder)
00674       {
00675       hr = psfFolder->GetUIObjectOf(   hwndListView,
00676                                        1,
00677                                        (LPCITEMIDLIST*)&pInfo->pidlRel,
00678                                        IID_IContextMenu,
00679                                        NULL,
00680                                        (LPVOID*)&pcm);
00681
00682       if(SUCCEEDED(hr))
00683          {
00684          HMENU hPopup;
00685
00686          hPopup = CreatePopupMenu();
00687          if(hPopup)
00688             {
00689             hr = pcm->QueryContextMenu(hPopup, 0, 1, 0x7fff, CMF_DEFAULTONLY | CMF_EXPLORE);
00690
00691             if(SUCCEEDED(hr))
00692                {
00693                UINT  idCmd;
00694
00695                idCmd = GetMenuItemID(hPopup, 0);
00696
00697                if(idCmd && (idCmd != (UINT)-1))
00698                   {
00699                   CMINVOKECOMMANDINFO  cmi;
00700                   cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
00701                   cmi.fMask = 0;
00702                   cmi.hwnd = GetParent(hwndListView);
00703                   cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1);
00704                   cmi.lpParameters = NULL;
00705                   cmi.lpDirectory = NULL;
00706                   cmi.nShow = SW_SHOWNORMAL;
00707                   cmi.dwHotKey = 0;
00708                   cmi.hIcon = NULL;
00709                   hr = pcm->InvokeCommand(&cmi);
00710                   }
00711                }
00712             }
00713
00714          pcm->Release();
00715          }
00716
00717       psfFolder->Release();
00718       }
00719    }
00720 }
00721
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/Common.h Source File

  • Com
  • Fundamentals
  • OleStd

Common.h

Go to the documentation of this file.
00001 /*
00002  * COMMON.H
00003  *
00004  * Structures and definitions applicable to all OLE 2.0 UI dialogs.
00005  *
00006  * Copyright (c)1992 - 2000 Microsoft Corporation, All Right Reserved
00007  */
00008
00009
00010 #ifndef _COMMON_H_
00011 #define _COMMON_H_
00012
00013 #include "ansiapi.h"
00014
00015 //Structure for label and source extraction from a metafile
00016 typedef struct tagLABELEXTRACT
00017    {
00018    LPOLESTR    lpsz;
00019    UINT        Index;      // index in lpsz (so we can retrieve 2+ lines)
00020    DWORD       PrevIndex;  // index of last line (so we can mimic word wrap)
00021
00022    union
00023       {
00024       UINT    cch;        //Length of label for label extraction
00025       UINT    iIcon;      //Index of icon in source extraction.
00026       } u;
00027
00028    //For internal use in enum procs
00029    BOOL        fFoundIconOnly;
00030    BOOL        fFoundSource;
00031    BOOL        fFoundIndex;
00032    } LABELEXTRACT, FAR * LPLABELEXTRACT;
00033
00034
00035 //Structure for extracting icons from a metafile (CreateIcon parameters)
00036 typedef struct tagICONEXTRACT
00037    {
00038    HICON       hIcon;          //Icon created in the enumeration proc.
00039
00040    /*
00041     * Since we want to handle multitasking well we have the caller
00042     * of the enumeration proc instantiate these variables instead of
00043     * using statics in the enum proc (which would be bad).
00044     */
00045    BOOL        fAND;
00046    HGLOBAL     hMemAND;        //Enumeration proc allocates and copies
00047    } ICONEXTRACT, FAR * LPICONEXTRACT;
00048
00049
00050 //Structure to use to pass info to EnumMetafileDraw
00051 typedef struct tagDRAWINFO
00052    {
00053    RECT     Rect;
00054    BOOL     fIconOnly;
00055    } DRAWINFO, FAR * LPDRAWINFO;
00056
00057 int CALLBACK EXPORT EnumMetafileIconDraw(HDC, HANDLETABLE FAR *, METARECORD FAR *, int, LPARAM);
00058 int CALLBACK EXPORT EnumMetafileExtractLabel(HDC, HANDLETABLE FAR *, METARECORD FAR *, int, LPLABELEXTRACT);
00059 int CALLBACK EXPORT EnumMetafileExtractIcon(HDC, HANDLETABLE FAR *, METARECORD FAR *, int, LPICONEXTRACT);
00060 int CALLBACK EXPORT EnumMetafileExtractIconSource(HDC, HANDLETABLE FAR *, METARECORD FAR *, int, LPLABELEXTRACT);
00061
00062 //Shared globals:  our instance and clipboard formats used by the PasteSpecial dialog
00063
00064 extern HINSTANCE  ghInst;
00065
00066 extern UINT       cfObjectDescriptor;
00067 extern UINT       cfLinkSrcDescriptor;
00068 extern UINT       cfEmbedSource;
00069 extern UINT       cfEmbeddedObject;
00070 extern UINT       cfLinkSource;
00071 extern UINT       cfOwnerLink;
00072 extern UINT       cfFileName;
00073
00074 #endif //_COMMON_H_
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/GenericUCP/CPP/util.h Source File

  • NetDS
  • upnp
  • GenericUCP
  • CPP

util.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005
00006 --*/
00007
00008 void ReleaseObj(IUnknown* pInterface);
00009
00010 void PrintErrorText(HRESULT hr);
00011
00012 void SafeStrCopy(TCHAR* src, TCHAR* dst, size_t srcBufLen);
00013
00014 // For Invoke Action
00015 HRESULT HrCreateSafeArray(VARTYPE vt, int nArgs, SAFEARRAY **ppsa);
00016 HRESULT HrCreateArgVariants(DWORD dwArgs, VARIANT*** pppVars);
00017 HRESULT HrDestroyArgVariants(DWORD dwArgs, VARIANT*** pppVars);
00018 void VariantSetVar(VARIANT* pvarToSet, VARIANT& va);
00019 void VariantSetArray(SAFEARRAY* psa, VARIANT& va);
00020 HRESULT HrGetSafeArrayBounds(SAFEARRAY *psa, long* plLBound, long* plUBound);
00021 HRESULT HrGetVariantElement(SAFEARRAY *psa, int lPosition, VARIANT* pvar);
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/SampleRoute/FaxSiren.Cpp Source File

  • NetDS
  • fax
  • SampleRoute

FaxSiren.Cpp

Go to the documentation of this file.
00001     /*--
00002     Copyright (c) 1998 - 2000  Microsoft Corporation
00003
00004     Module Name:
00005
00006         faxsiren.cpp
00007
00008     Abstract:
00009
00010         sample routing extension.  Sets an event when a fax is received, writes routing data into a log file.
00011
00012     --*/
00013
00014     #include <windows.h>
00015     #include <tchar.h>
00016     #include <stdio.h>
00017     #include <stdlib.h>
00018     #include <faxroute.h>
00019     #include <winfax.h>
00020     //support for sddl is only on win2000 and above
00021     #define _WIN32_WINNT 0x0500
00022     #include <sddl.h>
00023     //
00024     // macros
00025     //
00026     #define ValidString( String ) ((String) ? (String) : L"" )
00027
00028     #ifdef DBG
00029     #define MYDEBUG( parm ) DebugPrint parm
00030     #else
00031     #define MYDEBUG( parm )
00032     #endif
00033
00034
00035     //
00036     // constants
00037     //
00038     #define ROUTEITGUID           L"{5797dee0-e738-11d0-83c0-00c04fb6e984}"
00039     #define FAXSIREN              L"FaxSirenEvent"
00040     #define LOGNAME               L"%temp%\\ReceiveLog.txt"
00041     #define ININAME               L"%temp%\\FaxRoute.ini"
00042     #define SIRENDIR              L"SampleRouteFolder"
00043
00044     #define EXTENSIONNAME         L"SampleRoute Routing Extension"
00045     #define EXTENSIONFRIENDLYNAME L"SampleRoute: Fax Siren"
00046     #define EXTENSIONPATH         L"%systemroot%\\system32\\SampleRoute.dll"
00047
00048     #define FAXSIRENMETHOD        L"Siren"
00049     #define FAXSIRENFRIENDLYNAME  L"Routing Siren"
00050     #define FAXSIRENFUNCTION      L"RouteIt"
00051
00052
00053     //
00054     // forward declarations
00055     //
00056     BOOL
00057     WriteRoutingInfoIntoIniFile(
00058         LPWSTR TiffFileName,
00059         PFAX_ROUTE FaxRoute
00060         );
00061
00062     BOOL
00063     AppendFileNametoLogFile(
00064         LPWSTR TiffFileName,
00065         PFAX_ROUTE FaxRoute
00066         );
00067
00068     void
00069     DebugPrint(
00070         LPWSTR,
00071         ...
00072         );
00073
00074     BOOL WINAPI
00075     ExtensionCallback(
00076         IN HANDLE FaxHandle,
00077         IN LPVOID Context,
00078         IN OUT LPWSTR MethodName,
00079         IN OUT LPWSTR FriendlyName,
00080         IN OUT LPWSTR FunctionName,
00081         IN OUT LPWSTR Guid
00082         );
00083
00084
00085     //
00086     // globals
00087     //
00088     PFAXROUTEADDFILE    FaxRouteAddFile;
00089     PFAXROUTEDELETEFILE FaxRouteDeleteFile;
00090     PFAXROUTEGETFILE    FaxRouteGetFile;
00091     PFAXROUTEENUMFILES  FaxRouteEnumFiles;
00092     PFAXROUTEMODIFYROUTINGDATA  FaxRouteModifyRoutingData;
00093
00094     HANDLE              hHeap;
00095     HANDLE              hReceiveEvent;
00096     CRITICAL_SECTION    csRoute;
00097     LPWSTR              IniFile = NULL;
00098     LPWSTR              LogFile = NULL;
00099     HINSTANCE           MyhInstance;
00100
00101     extern "C"
00102     DWORD
00103     DllEntry(
00104         HINSTANCE hInstance,
00105         DWORD     Reason,
00106         LPVOID    Context
00107         )
00108
00109     /*++
00110
00111     Routine Description:
00112
00113         dll entrypoint
00114
00115     Arguments:
00116
00117         hInstance   - Module handle
00118         Reason      - Reason for being called
00119         Context     - Register context
00120
00121     Return Value:
00122
00123         TRUE for success, otherwise FALSE.
00124
00125     --*/
00126
00127     {
00128         switch (Reason) {
00129         case DLL_PROCESS_ATTACH:
00130           MyhInstance = hInstance;
00131           DisableThreadLibraryCalls(hInstance);
00132           break;
00133         case DLL_PROCESS_DETACH:
00134
00135            //
00136            // cleanup
00137            //
00138            if (hReceiveEvent) CloseHandle(hReceiveEvent);
00139            break;
00140         }
00141
00142         return TRUE;
00143     }
00144
00145
00146     STDAPI
00147     DllRegisterServer(
00148         VOID
00149         )
00150     /*++
00151
00152     Routine Description:
00153
00154       Function for the in-process server to create its registry entries
00155
00156     Return Value:
00157
00158       S_OK on success
00159
00160     Notes:
00161       We leverage the DllRegisterServer entrypoint as an easy way to configure
00162       our routing extension for use on the system.  Note that the extension doesn't
00163       have any COM code in it per se, but this makes installation much simpler since
00164       the setup code doesn't have to use custom code to setup the routing extension.
00165
00166     --*/
00167     {
00168       HRESULT RetCode;
00169       HMODULE hWinFax;
00170       PFAXREGISTERROUTINGEXTENSION pFaxRegisterRoutingExtension;
00171       PFAXCONNECTFAXSERVER pFaxConnectFaxServer;
00172       PFAXCLOSE pFaxClose;
00173       HANDLE hFax;
00174       DWORD ExtensionCount = 0;
00175         TCHAR lpszWinFaxDllLocation[MAX_PATH+13]={0};
00176       //
00177       // we assume that the routing extension has already been installed into the
00178       // proper location by the setup code.
00179       //
00180       //we assume that winfax.dll is located in SystemDirectory path
00181
00182       if (GetSystemDirectory(lpszWinFaxDllLocation, MAX_PATH+1) == 0)
00183       {
00184         MYDEBUG(( L"GetSystemDirectory failed, ec = %d\n", GetLastError() ));
00185         RetCode = E_UNEXPECTED;
00186         goto e0;
00187       }
00188
00189       _tcscat(lpszWinFaxDllLocation,_T("\\winfax.dll") );
00190     if (_tcslen(lpszWinFaxDllLocation) >= MAX_PATH)
00191     {
00192         MYDEBUG(( L"Library path too long\n", 0 ));
00193         RetCode = E_UNEXPECTED;
00194         goto e0;
00195       }
00196
00197       hWinFax = LoadLibrary(lpszWinFaxDllLocation);
00198       if (!hWinFax)
00199       {
00200         MYDEBUG(( L"LoadLibrary failed, ec = %d\n", GetLastError() ));
00201         RetCode = E_UNEXPECTED;
00202         goto e0;
00203       }
00204
00205       pFaxRegisterRoutingExtension = (PFAXREGISTERROUTINGEXTENSION) GetProcAddress(hWinFax, "FaxRegisterRoutingExtensionW" );
00206       pFaxConnectFaxServer = (PFAXCONNECTFAXSERVER) GetProcAddress(hWinFax, "FaxConnectFaxServerW");
00207       pFaxClose = (PFAXCLOSE) GetProcAddress(hWinFax, "FaxClose" );
00208
00209       if (!pFaxRegisterRoutingExtension || !pFaxConnectFaxServer || !pFaxClose)
00210       {
00211         MYDEBUG(( L"GetProcAddress failed, ec = %d\n", GetLastError() ));
00212         RetCode = E_UNEXPECTED;
00213         goto e1;
00214       }
00215
00216       if (!pFaxConnectFaxServer( NULL, &hFax ))
00217       {
00218         MYDEBUG(( L"FaxConnectFaxServer failed, ec = %d\n", GetLastError() ));
00219         RetCode = HRESULT_FROM_WIN32( GetLastError() );
00220         goto e1;
00221       }
00222
00223       if (!pFaxRegisterRoutingExtension(
00224         hFax,
00225             EXTENSIONNAME,
00226             EXTENSIONFRIENDLYNAME,
00227             EXTENSIONPATH,
00228             ExtensionCallback,
00229             (LPVOID) &ExtensionCount
00230             ))
00231       {
00232         MYDEBUG(( L"FaxRegisterRoutingExtension failed, ec = %d\n", GetLastError() ));
00233         RetCode = HRESULT_FROM_WIN32( GetLastError() );
00234         goto e2;
00235       }
00236       RetCode = S_OK;
00237
00238     e2:
00239       pFaxClose( hFax );
00240     e1:
00241       FreeLibrary( hWinFax );
00242     e0:
00243       return RetCode;
00244     }
00245
00246
00247     BOOL WINAPI
00248     ExtensionCallback(
00249       IN HANDLE FaxHandle,
00250         IN LPVOID Context,
00251         IN OUT LPWSTR MethodName,
00252         IN OUT LPWSTR FriendlyName,
00253         IN OUT LPWSTR FunctionName,
00254         IN OUT LPWSTR Guid
00255         )
00256     /*++
00257
00258     Routine Description:
00259
00260       Callback function for adding our routing extensions
00261
00262     Return Value:
00263
00264       TRUE if we added another extension, FALSE if we're done adding extensions
00265
00266     --*/
00267     {
00268       PDWORD ExtensionCount = (PDWORD) Context;
00269
00270       //
00271       // since we only have one extension, this is a really simple function
00272       // --we don't really need the context data above, it's just here to
00273       //   illustrate what you might use the context data for.
00274       //
00275
00276         if (ExtensionCount)
00277       {
00278         MYDEBUG(( L"ExtensionCallback called for extension %d\n", *ExtensionCount ));
00279         }
00280       else
00281       {
00282         MYDEBUG(( L"context data is NULL, can't continue\n", *ExtensionCount ));
00283             return FALSE;
00284         }
00285
00286         if (*ExtensionCount != 0)
00287       {
00288             //
00289             // we've added all of our methods, return FALSE to signify that we're done
00290             //
00291             return FALSE;
00292         }
00293
00294       wcscpy(MethodName,   FAXSIRENMETHOD );
00295       wcscpy(FriendlyName, FAXSIRENFRIENDLYNAME );
00296       wcscpy(FunctionName, FAXSIRENFUNCTION );
00297       wcscpy(Guid,         ROUTEITGUID );
00298
00299         *ExtensionCount += 1;
00300         return TRUE;
00301     }
00302
00303
00304
00305     //
00306     // required exports
00307     //
00308
00309     BOOL WINAPI
00310     FaxRouteInitialize(
00311         IN HANDLE HeapHandle,
00312         IN PFAX_ROUTE_CALLBACKROUTINES FaxRouteCallbackRoutines
00313         )
00314     /*++
00315
00316     Routine Description:
00317
00318         This functions is called by the fax service to initialize the routing extension.  This function
00319         should only be called once per instantiation of the fax service
00320
00321     Arguments:
00322
00323         HeapHandle               - Heap handle for memory all allocations
00324         FaxRouteCallbackRoutines - structure containing callback functions
00325
00326     Return Value:
00327
00328         TRUE for success, otherwise FALSE.
00329
00330     --*/
00331
00332     {
00333       DWORD dwNeeded;
00334         SECURITY_ATTRIBUTES sa;
00335
00336         //
00337         // make sure we can understand the structure
00338         //
00339         if ( FaxRouteCallbackRoutines->SizeOfStruct < sizeof(FAX_ROUTE_CALLBACKROUTINES) )
00340       {
00341         MYDEBUG (
00342           (L"The passed in SizeOfStruct (%d) is smaller than expected (%d) ",
00343           FaxRouteCallbackRoutines->SizeOfStruct,
00344             sizeof(FAX_ROUTE_CALLBACKROUTINES))
00345             );
00346         return FALSE;
00347       }
00348
00349         hHeap = HeapHandle;
00350         FaxRouteAddFile = FaxRouteCallbackRoutines->FaxRouteAddFile;
00351         FaxRouteDeleteFile = FaxRouteCallbackRoutines->FaxRouteDeleteFile;
00352         FaxRouteGetFile = FaxRouteCallbackRoutines->FaxRouteGetFile;
00353         FaxRouteEnumFiles = FaxRouteCallbackRoutines->FaxRouteEnumFiles;
00354         FaxRouteModifyRoutingData = FaxRouteCallbackRoutines->FaxRouteModifyRoutingData;
00355
00356         InitializeCriticalSection( &csRoute );
00357
00358         //
00359         // create a named event
00360         //
00361         // note that we need to create a security descriptor with a DACL (everyone read, administrators full control) because we want the named
00362         // event to be opened by programs that might not be running in same context as the fax service
00363         //
00364
00365         sa.nLength = sizeof(SECURITY_ATTRIBUTES);
00366         sa.bInheritHandle = FALSE;
00367       //owner is builtin administrators
00368       //everyone read ace
00369       //built-in administrators full control
00370         LPCWSTR pwszSD=L"O:BAG:BAD:(A;;GR;;;WD) (A;;GA;;;BA)";
00371
00372
00373         if (ConvertStringSecurityDescriptorToSecurityDescriptor(
00374                                 pwszSD,
00375                                 SDDL_REVISION_1,
00376                                 &(sa.lpSecurityDescriptor),
00377                                 NULL))
00378         {
00379         MYDEBUG(( L"ConvertStringSecurityDescriptorToSecurityDescriptor failed, ec = %d\n", GetLastError() ));
00380             return FALSE;
00381         }
00382
00383         hReceiveEvent = CreateEvent(&sa,FALSE,FALSE,FAXSIREN);
00384
00385       if (!hReceiveEvent)
00386       {
00387         if (GetLastError() != ERROR_ALREADY_EXISTS)
00388         {
00389           MYDEBUG (( L"CreateEvent failed, ec = %d\n", GetLastError() ));
00390           return FALSE;
00391         }
00392       }
00393         LocalFree(sa.lpSecurityDescriptor);
00394
00395         //
00396         // get path to files for logging, etc.
00397         //
00398         dwNeeded = ExpandEnvironmentStrings(ININAME,IniFile,0);
00399         IniFile  = (LPWSTR) HeapAlloc(hHeap,HEAP_ZERO_MEMORY,(dwNeeded)*sizeof(WCHAR));
00400         if (!IniFile)
00401       {
00402         MYDEBUG((L"HeapAlloc failed, ec = %d\n", GetLastError() ));
00403         return FALSE;
00404         }
00405         DWORD dwSuccess = ExpandEnvironmentStrings(ININAME,IniFile,dwNeeded);
00406
00407         if (dwSuccess == 0)
00408       {
00409         return FALSE;
00410         }
00411
00412         dwNeeded = ExpandEnvironmentStrings(LOGNAME,LogFile,0);
00413         LogFile  = (LPWSTR) HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(WCHAR)*(dwNeeded));
00414         if (!LogFile)
00415       {
00416         MYDEBUG(( L"HeapAlloc failed, ec = %d\n", GetLastError() ));
00417         return FALSE;
00418         }
00419         dwSuccess = ExpandEnvironmentStrings(LOGNAME,LogFile,dwNeeded);
00420
00421         if (dwSuccess == 0)
00422       {
00423         return FALSE;
00424         }
00425
00426       MYDEBUG (( L"Logfile : %s\n", LogFile ));
00427         MYDEBUG (( L"Inifile : %s\n", IniFile ));
00428         return TRUE;
00429     }
00430
00431     BOOL WINAPI
00432     FaxRouteGetRoutingInfo(
00433         IN  LPWSTR RoutingGuid,
00434         IN  DWORD DeviceId,
00435         IN  LPBYTE RoutingInfo,
00436         OUT LPDWORD RoutingInfoSize
00437         )
00438
00439     /*++
00440
00441     Routine Description:
00442
00443         This functions is called by the fax service to
00444         get routing configuration data.
00445
00446     Arguments:
00447
00448         RoutingGuid         - Unique identifier for the requested routing method
00449         DeviceId            - Device that is being configured
00450         RoutingInfo         - Routing info buffer
00451         RoutingInfoSize     - Size of the buffer (in bytes)
00452
00453     Return Value:
00454
00455         TRUE for success, otherwise FALSE.
00456
00457     --*/
00458
00459     {
00460         //
00461         // the sample doesn't have any per device routing data, so this function is
00462         // just stubbed out -- if you have per device routing data, it would be
00463         // retrieved here.
00464         //
00465       if (RoutingInfoSize)
00466       {
00467         *RoutingInfoSize = 0;
00468         }
00469         return TRUE;
00470     }
00471
00472
00473     BOOL WINAPI
00474     FaxRouteSetRoutingInfo(
00475         IN  LPWSTR RoutingGuid,
00476         IN  DWORD DeviceId,
00477         IN  LPBYTE RoutingInfo,
00478         IN  DWORD RoutingInfoSize
00479         )
00480     /*++
00481
00482     Routine Description:
00483
00484         This functions is called by the fax service to
00485         set routing configuration data.
00486
00487     Arguments:
00488
00489         RoutingGuid         - Unique identifier for the requested routing method
00490         DeviceId            - Device that is being configured
00491         RoutingInfo         - Routing info buffer
00492         RoutingInfoSize     - Size of the buffer (in bytes)
00493
00494     Return Value:
00495
00496         TRUE for success, otherwise FALSE.
00497
00498     --*/
00499     {
00500         //
00501         // the sample doesn't have any per device routing data, so this function is
00502         // just stubbed out -- if you have per device routing data, it would be
00503         // commited to storage here.
00504         //
00505       return TRUE;
00506     }
00507
00508     BOOL WINAPI
00509     FaxRouteDeviceEnable(
00510         IN  LPWSTR RoutingGuid,
00511         IN  DWORD DeviceId,
00512         IN  LONG Enabled
00513         )
00514     /*++
00515
00516     Routine Description:
00517
00518         This functions is called by the fax service to determine if a routing extension is enabled or
00519         to enable a routing extension
00520
00521     Arguments:
00522
00523         RoutingGuid         - Unique identifier for the requested routing method
00524         DeviceId            - Device that is being configured
00525         Enabled             - meaning differs based on context (see FAXROUTE_ENABLE enumerated type)
00526
00527     Return Value:
00528
00529         depends on context.
00530
00531     --*/
00532     {
00533         //
00534         // -note that we make the assumption that there are never more than 4 devices in this sample
00535         // -also note that this isn't thread safe
00536         // -a real routing extension wouldn't make these assumptions, and would probably have some
00537         //  persistent store which kept track of the enabled state of an extension per-routing method
00538         //
00539       static long MyEnabled[4] = {STATUS_ENABLE,STATUS_ENABLE,STATUS_ENABLE,STATUS_ENABLE};
00540         static DWORD DeviceIdIndex[4] = {0,0,0,0};
00541         DWORD count;
00542
00543         //
00544         // make sure that we're dealing with our routing method
00545         //
00546         if (wcsicmp(RoutingGuid,ROUTEITGUID) != 0)
00547       {
00548         MYDEBUG (( L"Passed a GUID (%s) for a method not in this extension!\n", RoutingGuid ));
00549             return FALSE;
00550         }
00551
00552         for (count = 0 ; count <4; count ++)
00553       {
00554         if (DeviceIdIndex[count] == DeviceId)
00555         {
00556           break;
00557             }
00558         else if (DeviceIdIndex[count] == 0)
00559         {
00560           DeviceIdIndex[count] = DeviceId;
00561             }
00562         }
00563
00564         if (Enabled == QUERY_STATUS)
00565       {
00566         return MyEnabled[count];
00567         }
00568
00569         MYDEBUG ((
00570         L"Setting enabled state to %s\n",
00571             (Enabled == STATUS_DISABLE) ? L"STATUS_DISABLE" : L"STATUS_ENABLE"
00572             ));
00573
00574       MyEnabled[count] = Enabled;
00575         return TRUE;
00576     }
00577
00578
00579     BOOL WINAPI
00580     FaxRouteDeviceChangeNotification(
00581         IN  DWORD DeviceId,
00582         IN  BOOL  NewDevice
00583         )
00584
00585     /*++
00586
00587     Routine Description:
00588
00589         This functions is called by the fax service to alert the routing extension that a device
00590         has changed
00591
00592     Arguments:
00593
00594         DeviceId            - Device that has changed
00595         NewDevice           - TRUE means device was added, FALSE means a device was removed
00596
00597     Return Value:
00598
00599         TRUE for success
00600
00601     --*/
00602     {
00603       //
00604       // We don't have any per device routing data, so this is just stubbed out
00605       //
00606       return TRUE;
00607     }
00608
00609
00610     //
00611     // routing method(s)
00612     //
00613
00614
00615     BOOL WINAPI
00616     RouteIt(
00617       PFAX_ROUTE FaxRoute,
00618       PVOID *FailureData,
00619       LPDWORD FailureDataSize
00620       )
00621
00622     /*++
00623
00624     Routine Description:
00625
00626         This functions is called by the fax service to
00627         route a received fax.
00628
00629     Arguments:
00630
00631         FaxRoute            - Routing information
00632         FailureData         - Failure data buffer
00633         FailureDataSize     - Size of failure data buffer
00634
00635     Return Value:
00636
00637         TRUE for success, otherwise FALSE.
00638
00639     --*/
00640
00641     {
00642       WCHAR TiffFileName[MAX_PATH];
00643         WCHAR Dir[_MAX_DIR],Drive[_MAX_DRIVE],File[_MAX_FNAME],Ext[_MAX_EXT];
00644         WCHAR CopyOfTiff[MAX_PATH+1];
00645
00646         DWORD Size = sizeof(TiffFileName);
00647
00648         //
00649         // serialize access to this function so that data is written into the logfile accurately
00650         //
00651         EnterCriticalSection( &csRoute );
00652
00653       if (!FaxRouteGetFile(
00654         FaxRoute->JobId,
00655             1,
00656             TiffFileName,
00657             &Size))
00658       {
00659         MYDEBUG(( L"Couldn't FaxRouteGetFile, ec = %d", GetLastError() ));
00660         LeaveCriticalSection( &csRoute );
00661         return FALSE;
00662         }
00663
00664         MYDEBUG ((
00665         L"Received fax %s\n\tCSID :%s\n\t Name : %s\n\t #: %s\n\tDevice: %s\n",
00666             TiffFileName,
00667             ValidString ( FaxRoute->Csid ),
00668             ValidString ( FaxRoute->ReceiverName),
00669             ValidString ( FaxRoute->ReceiverNumber),
00670             ValidString ( FaxRoute->DeviceName )
00671         ));
00672
00673       _wsplitpath(TiffFileName, Drive, Dir, File, Ext );
00674     if ((wcslen(Drive) + wcslen(SIRENDIR) + wcslen(File) + wcslen(Ext)) >= MAX_PATH) {
00675         LeaveCriticalSection( &csRoute );
00676         return FALSE;
00677         }
00678
00679         wsprintf(CopyOfTiff,L"%s\\%s\\%s%s",Drive,SIRENDIR,File,Ext);
00680
00681         //
00682         // copy the tiff so it persists after this routine exits
00683         //
00684         CopyFile(TiffFileName,CopyOfTiff,FALSE);
00685
00686         //
00687         // write some logging data
00688         //
00689         WriteRoutingInfoIntoIniFile(CopyOfTiff,FaxRoute);
00690         AppendFileNametoLogFile(TiffFileName, FaxRoute);
00691
00692         //
00693         // signal event -- another application could use this named event to do something
00694         // with the file that was just copied into this directory
00695         // (note that the INI file isn't thread-safe accross applications, we could have the routing data overwritten by
00696         //  another fax being received)
00697         //
00698         SetEvent(hReceiveEvent);
00699
00700         //
00701         // service needs to be able to interact with the current desktop for this to work
00702         //
00703         MessageBeep(MB_ICONEXCLAMATION);
00704
00705         LeaveCriticalSection( &csRoute );
00706         return TRUE;
00707     }
00708
00709
00710     //
00711     // utility fcn's
00712     //
00713
00714     BOOL WriteRoutingInfoIntoIniFile(LPWSTR TiffFileName,PFAX_ROUTE FaxRoute)
00715     {
00716       WCHAR Buffer[MAX_PATH*2];
00717         ULONG ulBufferSize = sizeof(Buffer);
00718     ULONG ulArraySize = ulBufferSize/sizeof(Buffer[0]);
00719       //
00720       // write each routing info member into ini file
00721       //
00722
00723       //filename
00724       ZeroMemory(Buffer,ulBufferSize);
00725     wcsncpy(Buffer,ValidString (TiffFileName), ulArraySize - 1);
00726       WritePrivateProfileString(
00727         L"RoutingInfo",// pointer to section name
00728         L"FileName",// pointer to key name
00729         Buffer,   // pointer to string to add
00730         IniFile // pointer to initialization filename
00731         );
00732
00733
00734       //jobid
00735     ZeroMemory(Buffer,ulBufferSize);
00736       wsprintf(Buffer, L"%u",FaxRoute->JobId);
00737       WritePrivateProfileString(
00738         L"RoutingInfo",// pointer to section name
00739         L"JobId",// pointer to key name
00740         Buffer,   // pointer to string to add
00741         IniFile // pointer to initialization filename
00742         );
00743
00744       //elapsedtime
00745     ZeroMemory(Buffer,ulBufferSize);
00746       wsprintf(Buffer, L"%u",FaxRoute->ElapsedTime);
00747       WritePrivateProfileString(
00748         L"RoutingInfo",// pointer to section name
00749         L"ElapsedTime",// pointer to key name
00750         Buffer,   // pointer to string to add
00751         IniFile // pointer to initialization filename
00752         );
00753
00754       //receivetime
00755     ZeroMemory(Buffer,ulBufferSize);
00756       wsprintf(Buffer, L"%u",FaxRoute->ReceiveTime);
00757       WritePrivateProfileString(
00758         L"RoutingInfo",// pointer to section name
00759         L"ReceiveTime",// pointer to key name
00760         Buffer,   // pointer to string to add
00761         IniFile // pointer to initialization filename
00762         );
00763
00764       //pagecount
00765     ZeroMemory(Buffer,ulBufferSize);
00766       wsprintf(Buffer, L"%u",FaxRoute->PageCount);
00767       WritePrivateProfileString(
00768         L"RoutingInfo",// pointer to section name
00769         L"PageCount",// pointer to key name
00770         Buffer,   // pointer to string to add
00771         IniFile // pointer to initialization filename
00772         );
00773
00774       //Csid
00775     ZeroMemory(Buffer,ulBufferSize);
00776     wcsncpy(Buffer,ValidString (FaxRoute->Csid), ulArraySize - 1);
00777       WritePrivateProfileString(
00778         L"RoutingInfo",// pointer to section name
00779         L"Csid",// pointer to key name
00780         Buffer,   // pointer to string to add
00781         IniFile // pointer to initialization filename
00782         );
00783
00784       //CallerId
00785     ZeroMemory(Buffer,ulBufferSize);
00786     wcsncpy(Buffer, ValidString (FaxRoute->CallerId ), ulArraySize - 1);
00787       WritePrivateProfileString(
00788         L"RoutingInfo",// pointer to section name
00789         L"CallerId",// pointer to key name
00790         Buffer,   // pointer to string to add
00791         IniFile // pointer to initialization filename
00792         );
00793
00794       //RoutingInfo
00795     ZeroMemory(Buffer,ulBufferSize);
00796     wcsncpy(Buffer, ValidString (FaxRoute->RoutingInfo ), ulArraySize - 1);
00797       WritePrivateProfileString(
00798         L"RoutingInfo",// pointer to section name
00799         L"RoutingInfo",// pointer to key name
00800         Buffer,   // pointer to string to add
00801         IniFile // pointer to initialization filename
00802         );
00803
00804       //ReceiverName
00805     ZeroMemory(Buffer,ulBufferSize);
00806     wcsncpy(Buffer, ValidString (FaxRoute->ReceiverName ), ulArraySize - 1);
00807       WritePrivateProfileString(
00808         L"RoutingInfo",// pointer to section name
00809         L"ReceiverName",// pointer to key name
00810         Buffer,   // pointer to string to add
00811         IniFile // pointer to initialization filename
00812         );
00813
00814       //ReceiverNumber
00815     ZeroMemory(Buffer,ulBufferSize);
00816     wcsncpy(Buffer, ValidString (FaxRoute->ReceiverNumber ), ulArraySize - 1);
00817       WritePrivateProfileString(
00818         L"RoutingInfo",// pointer to section name
00819         L"ReceiverNumber",// pointer to key name
00820         Buffer,   // pointer to string to add
00821         IniFile // pointer to initialization filename
00822         );
00823
00824       //DeviceName
00825     ZeroMemory(Buffer,ulBufferSize);
00826     wcsncpy(Buffer, ValidString (FaxRoute->DeviceName ), ulArraySize - 1);
00827       WritePrivateProfileString(
00828         L"RoutingInfo",// pointer to section name
00829         L"DeviceName",// pointer to key name
00830         Buffer,   // pointer to string to add
00831         IniFile // pointer to initialization filename
00832         );
00833
00834       //DeviceId
00835     ZeroMemory(Buffer,ulBufferSize);
00836       wsprintf(Buffer, L"%u",FaxRoute->DeviceId );
00837       WritePrivateProfileString(
00838         L"RoutingInfo",// pointer to section name
00839         L"DeviceId",// pointer to key name
00840         Buffer,   // pointer to string to add
00841         IniFile // pointer to initialization filename
00842         );
00843
00844       return TRUE;
00845     }
00846
00847     BOOL AppendFileNametoLogFile (LPWSTR TiffFileName,PFAX_ROUTE FaxRoute)
00848     {
00849       HANDLE hFile = INVALID_HANDLE_VALUE;
00850       WCHAR Buffer[2*MAX_PATH];
00851       WCHAR szDateTime[104];
00852       WCHAR lpDate[50];
00853       WCHAR lpTime[50];
00854
00855       DWORD dwWrote = 0;
00856
00857       hFile = CreateFile(
00858         LogFile,
00859         GENERIC_WRITE,
00860         FILE_SHARE_WRITE,
00861         NULL,
00862         OPEN_ALWAYS,
00863         FILE_ATTRIBUTE_NORMAL,
00864         NULL
00865         );
00866
00867       if (hFile == INVALID_HANDLE_VALUE)
00868       {
00869         MYDEBUG (( L"CreateFile failed, ec = %d\n", GetLastError() ));
00870         return FALSE;
00871       }
00872
00873       if ( !GetDateFormat(
00874         LOCALE_SYSTEM_DEFAULT,
00875         DATE_SHORTDATE,
00876         NULL,                // use system date
00877         NULL,                // use locale format
00878         lpDate,
00879         (sizeof lpDate)/(sizeof lpDate[0]) ) )
00880       {
00881         MYDEBUG(( L"GetDateFormat failed, ec = %d\n", GetLastError() ));
00882         return FALSE;
00883       }
00884
00885
00886       if ( !GetTimeFormat(
00887         LOCALE_SYSTEM_DEFAULT,
00888         TIME_NOSECONDS,
00889         NULL,                // use system time
00890         NULL,                // use locale format
00891         lpTime,
00892         (sizeof lpTime)/(sizeof lpTime[0]) ) )
00893       {
00894         MYDEBUG(( L"GetTimeFormat failed, ec = %d\n", GetLastError() ));
00895         return FALSE;
00896       }
00897
00898       wsprintf( szDateTime, TEXT("%-8s %-8s"), lpDate, lpTime);
00899
00900       wsprintf(Buffer, L"%s :Received %s\r\n",ValidString(szDateTime),ValidString(TiffFileName));
00901
00902       SetFilePointer(hFile,0,0,FILE_END);
00903
00904       if (!WriteFile(hFile,Buffer,lstrlen(Buffer)*sizeof(WCHAR),&dwWrote,NULL))
00905       {
00906         MYDEBUG (( L"WriteFile() failed, ec = %d\n", GetLastError() ));
00907         CloseHandle(hFile);
00908         return FALSE;
00909       }
00910
00911       CloseHandle(hFile);
00912        return TRUE;
00913     }
00914
00915     void
00916     DebugPrint(LPTSTR Format, ...)
00917
00918     /*++
00919
00920     Routine Description:
00921
00922         Prints a debug string
00923
00924     Arguments:
00925
00926         format      - wsprintf() format string
00927         ...         - Variable data
00928
00929     Return Value:
00930
00931         None.
00932
00933     --*/
00934
00935     {
00936       TCHAR Buffer[1024];
00937       TCHAR AppName[MAX_PATH];
00938       TCHAR ShortName[MAX_PATH];
00939       SYSTEMTIME CurrentTime;
00940       int len=0;
00941
00942       va_list marker;
00943
00944       ZeroMemory(AppName,MAX_PATH);
00945       ZeroMemory(ShortName,MAX_PATH);
00946
00947       if (  GetModuleFileName(
00948         NULL, // handle to module to find filename for
00949         AppName,
00950         MAX_PATH)
00951         )
00952       {
00953         _tsplitpath(AppName,NULL,NULL,ShortName,NULL);
00954       }
00955
00956       ZeroMemory(&CurrentTime,sizeof(SYSTEMTIME));
00957
00958       GetLocalTime(&CurrentTime);
00959
00960       wsprintf(
00961         Buffer,
00962         TEXT ("%02d.%02d.%02d.%03d %s: "),
00963         CurrentTime.wHour,
00964         CurrentTime.wMinute,
00965         CurrentTime.wSecond,
00966         CurrentTime.wMilliseconds,
00967         ShortName
00968         );
00969
00970       // init arg list
00971       va_start(marker,Format);
00972
00973       // point to rest of blank buffer
00974       len = lstrlen(Buffer);
00975
00976       _vsntprintf(
00977         &Buffer[len], // don't want to overwrite the start of the string!
00978             sizeof(Buffer) - len - 3, //size of the rest of the buffer
00979             Format,
00980             marker
00981         );
00982
00983       len = lstrlen(Buffer);
00984       if (Buffer[len-1] == L'\n' )
00985       {
00986         Buffer[len-1] = L'\r';
00987         Buffer[len] = L'\n';
00988         Buffer[len+1] = 0;
00989       }
00990       else
00991       {
00992         Buffer[len] = L'\r';
00993         Buffer[len+1] = L'\n';
00994         Buffer[len+2] = 0;
00995       }
00996       OutputDebugString(Buffer);
00997       va_end(marker);
00998     }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/CertPSam.Idl Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

CertPSam.Idl

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        certpsam.idl
00007 //
00008 // Contents:    IDL source for certpsam
00009 //
00010 //---------------------------------------------------------------------------
00011
00012
00013 import "wtypes.idl";
00014 import "certpol.idl";
00015 import "certmod.idl";
00016
00017
00018 //+--------------------------------------------------------------------------
00019 // certpol Type library
00020 //+--------------------------------------------------------------------------
00021
00022 [
00023     uuid(98a77720-c2c8-11d2-b313-00c04f79dc72),
00024     version(1.0),
00025     helpstring("CertPolicySample 1.0 Type Library")
00026 ]
00027
00028 library CERTPOLICYSAMPLELib
00029 {
00030     importlib("stdole2.tlb");
00031
00032     [
00033   uuid(98f87410-c2c8-11d2-b313-00c04f79dc72),
00034   helpstring("CertPolicySample Class")
00035     ]
00036     coclass CCertPolicySample
00037     {
00038   [default] interface ICertPolicy;
00039     };
00040
00041     [
00042   uuid(98567a30-c2c8-11d2-b313-00c04f79dc72),
00043   helpstring("CertManagePolicyModuleSample Class")
00044     ]
00045     coclass CCertManagePolicyModuleSample
00046     {
00047   [default] interface ICertManageModule;
00048     };
00049 };
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/GenericUCP/CPP/GenericUCPDlg.cpp Source File

  • NetDS
  • upnp
  • GenericUCP
  • CPP

GenericUCPDlg.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005
00006 --*/
00007
00008 // GenericUCPDlg.cpp : implementation file
00009 //
00010
00011 #include "stdafx.h"
00012 #include "GenericUCP.h"
00013 #include "GenericUCPDlg.h"
00014 #include "deviceprop.h"
00015 #include "util.h"
00016
00017
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CAboutDlg dialog used for App About
00026
00027 class CAboutDlg : public CDialog
00028 {
00029 public:
00030   CAboutDlg();
00031 // Dialog Data
00032   //{{AFX_DATA(CAboutDlg)
00033   enum { IDD = IDD_ABOUTBOX };
00034   //}}AFX_DATA
00035   //{{AFX_VIRTUAL(CAboutDlg)
00036   protected:
00037   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00038   //}}AFX_VIRTUAL
00039
00040 // Implementation
00041 protected:
00042   //{{AFX_MSG(CAboutDlg)
00043   //}}AFX_MSG
00044   DECLARE_MESSAGE_MAP()
00045 };
00046
00047 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00048 {
00049   //{{AFX_DATA_INIT(CAboutDlg)
00050   //}}AFX_DATA_INIT
00051 }
00052
00053 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00054 {
00055   CDialog::DoDataExchange(pDX);
00056   //{{AFX_DATA_MAP(CAboutDlg)
00057   //}}AFX_DATA_MAP
00058 }
00059
00060 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00061   //{{AFX_MSG_MAP(CAboutDlg)
00062   // No message handlers
00063   //}}AFX_MSG_MAP
00064 END_MESSAGE_MAP()
00065
00066
00067 // App command to run the dialog
00068 void CGenericUCPDlg::OnAppAbout()
00069 {
00070   CAboutDlg aboutDlg;
00071   aboutDlg.DoModal();
00072 }
00073
00074
00075 /////////////////////////////////////////////////////////////////////////////
00076 // CGenericUCPDlg dialog
00077
00078
00079 //+---------------------------------------------------------------------------
00080 //
00081 //  Member:   CGenericUCPDlg
00082 //
00083 //  Purpose:    Constructor
00084 //
00085 //  Arguments:
00086 //      pParent         [in]        Parent Window
00087 //
00088 //  Returns:    None
00089 //
00090 //  Notes:
00091 //     We create the callback objects for device finder and service objects.
00092 //
00093
00094 CGenericUCPDlg::CGenericUCPDlg(CWnd* pParent)
00095    : CDialog(CGenericUCPDlg::IDD, pParent)
00096 {
00097    HRESULT hr = S_OK;
00098
00099    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
00100    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00101
00102    // Create a device finder callback object
00103    m_pDeviceFinderCallback = NULL;
00104    m_pDeviceFinderCallback = CDeviceFinderCallback::Create();
00105    if (m_pDeviceFinderCallback == NULL)
00106    {
00107       MessageBox(
00108          _T("Error: DeviceFinderCallback object creation failed")
00109          );
00110    }
00111    else
00112    {
00113       ((CDeviceFinderCallback*)m_pDeviceFinderCallback)->SetDialogPointer(
00114                                                             this
00115                                                             );
00116    }
00117
00118    // Create a service callback object
00119    m_pServiceCallback = NULL;
00120    m_pServiceCallback = CServiceCallback::Create();
00121    if (m_pServiceCallback == NULL)
00122    {
00123       MessageBox(_T("Error: ServiceCallback object creation failed"));
00124    }
00125    else
00126    {
00127       ((CServiceCallback*)m_pServiceCallback)->SetDialogPointer(this);
00128    }
00129
00130 }
00131
00132
00133 //+---------------------------------------------------------------------------
00134 //
00135 //  Member:   ~CGenericUCPDlg
00136 //
00137 //  Purpose:    Destructor
00138 //
00139 //  Arguments:
00140 //    None
00141 //
00142 //  Returns:    None
00143 //
00144 //  Notes:
00145 //     We stop the async find if it is proceeding, and release the callback
00146 //     objects
00147 //
00148
00149 CGenericUCPDlg::~CGenericUCPDlg()
00150 {
00151    // Destructor
00152    ReleaseObj(m_pServiceCallback);
00153    m_pServiceCallback = NULL;
00154    ReleaseObj(m_pDeviceFinderCallback);
00155    m_pDeviceFinderCallback = NULL;
00156    StopAsyncFindIfStarted();
00157    ReleaseObj(m_pDeviceFinder);
00158    m_pDeviceFinder = NULL;
00159 }
00160
00161
00162 // MFC Function
00163 void CGenericUCPDlg::DoDataExchange(CDataExchange* pDX)
00164 {
00165   CDialog::DoDataExchange(pDX);
00166   //{{AFX_DATA_MAP(CGenericUCPDlg)
00167   DDX_Control(pDX, IDC_VARIABLENAME, m_VariableName);
00168   DDX_Control(pDX, IDC_ACTIONNAME, m_ActionName);
00169   DDX_Control(pDX, IDC_STATUS, m_StatusText);
00170   DDX_Control(pDX, IDC_EVENTS, m_EventText);
00171   DDX_Control(pDX, IDC_VIEWSCPD, m_ViewSCPD);
00172   DDX_Control(pDX, IDC_SCPDURL, m_SCPDURL);
00173   DDX_Control(pDX, IDC_PRESENTATION, m_Presentation);
00174   DDX_Control(pDX, IDC_QUERYVARIABLE, m_QueryVariable);
00175   DDX_Control(pDX, IDC_INVOKEACTION, m_InvokeAction);
00176   DDX_Control(pDX, IDC_DISCOVERY, m_StartDiscovery);
00177   DDX_Control(pDX, IDC_DEVPROP, m_DeviceProperties);
00178   DDX_Control(pDX, IDC_COMBOSERVICE, m_ServiceCombo);
00179   DDX_Control(pDX, IDC_COMBOFIND, m_FindCombo);
00180   DDX_Control(pDX, IDC_COMBODEVICE, m_DeviceCombo);
00181   DDX_Control(pDX, IDC_CLOSE, m_CloseApp);
00182   DDX_Control(pDX, IDC_ACTIONOUTARGUMENT, m_ActionOutArgument);
00183   DDX_Control(pDX, IDC_ACTIONINARGUMENT, m_ActionInArgument);
00184   DDX_Control(pDX, IDC_FINDBYTYPE, m_FindByType);
00185   DDX_Control(pDX, IDC_FINDBYUDN, m_FindByUDN);
00186   DDX_Control(pDX, IDC_ASYNCFIND, m_AsyncFind);
00187   //}}AFX_DATA_MAP
00188 }
00189
00190 //Message Map
00191 BEGIN_MESSAGE_MAP(CGenericUCPDlg, CDialog)
00192   //{{AFX_MSG_MAP(CGenericUCPDlg)
00193   ON_WM_SYSCOMMAND()
00194   ON_WM_PAINT()
00195   ON_WM_QUERYDRAGICON()
00196   ON_BN_CLICKED(IDC_FINDBYTYPE, OnFindByType)
00197   ON_BN_CLICKED(IDC_DISCOVERY, OnDiscoveryClicked)
00198   ON_BN_CLICKED(IDC_FINDBYUDN, OnFindbyUDN)
00199   ON_BN_CLICKED(IDC_ASYNCFIND, OnAsyncFind)
00200   ON_CBN_SELENDOK(IDC_COMBODEVICE, OnSelEndOkComboDevice)
00201   ON_CBN_SELENDOK(IDC_COMBOSERVICE, OnSelEndOkComboService)
00202   ON_BN_CLICKED(IDC_DEVPROP, OnDevpropClick)
00203   ON_BN_CLICKED(IDC_QUERYVARIABLE, OnQueryVariable)
00204   ON_BN_CLICKED(IDC_INVOKEACTION, OnInvokeAction)
00205   ON_BN_CLICKED(IDC_CLOSE, OnCloseClick)
00206   ON_WM_CLOSE()
00207   //}}AFX_MSG_MAP
00208 END_MESSAGE_MAP()
00209
00210
00211 /////////////////////////////////////////////////////////////////////////////
00212 // CGenericUCPDlg message handlers
00213
00214
00215
00216 //+---------------------------------------------------------------------------
00217 //
00218 //  Member:   OnInitDialog
00219 //
00220 //  Purpose:    Initialization of the dialog box.
00221 //
00222 //  Arguments:
00223 //        None
00224 //
00225 //  Returns:    TRUE
00226 //
00227 //  Notes:
00228 //     Default to AsyncFind search and set the flag for m_fAsyncFindRunning to
00229 //     FALSE
00230 //
00231
00232 BOOL CGenericUCPDlg::OnInitDialog()
00233 {
00234   CDialog::OnInitDialog();
00235
00236   // Add "About..." menu item to system menu.
00237
00238   // IDM_ABOUTBOX must be in the system command range.
00239   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00240   ASSERT(IDM_ABOUTBOX < 0xF000);
00241
00242   CMenu* pSysMenu = GetSystemMenu(FALSE);
00243   if (pSysMenu != NULL)
00244   {
00245     CString strAboutMenu;
00246     strAboutMenu.LoadString(IDS_ABOUTBOX);
00247     if (!strAboutMenu.IsEmpty())
00248     {
00249       pSysMenu->AppendMenu(MF_SEPARATOR);
00250       pSysMenu->AppendMenu(
00251                                      MF_STRING,
00252                                      IDM_ABOUTBOX,
00253                                      strAboutMenu
00254                                      );
00255     }
00256   }
00257
00258
00259   // Set the icon for this dialog.  The framework does this automatically
00260   //  when the application's main window is not a dialog
00261   SetIcon(m_hIcon, TRUE);     // Set big icon
00262   SetIcon(m_hIcon, FALSE);    // Set small icon
00263   m_pDeviceFinder = NULL;
00264   m_fAsyncFindRunning = FALSE; // Async Find is not running
00265   m_DeviceCombo.SetCurSel(-1);
00266   m_ServiceCombo.SetCurSel(-1);
00267
00268         // Grow the size of the array five at a time
00269   m_astrDevType.SetSize(5,5);
00270   m_AsyncFind.SetCheck(TRUE);
00271
00272         // Initialize the Device Types.
00273         InitializeDevTypeArray();
00274
00275   // Tell the user to click on Start Discovery Button
00276   m_StatusText.SetWindowText(
00277             _T("Choose the type of device discovery and proceed")
00278             );
00279
00280   return TRUE;
00281 }
00282
00283
00284 //MFC function
00285 BOOL CGenericUCPDlg::PreTranslateMessage(MSG *pMsg)
00286 {
00287   if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
00288   {
00289     DWORD def_id=GetDefID();
00290     if (def_id!=0)
00291     {
00292       CWnd *wnd=FromHandle(pMsg->hwnd);
00293       // you may implement other ways of testing, e.g.
00294       //  comparing to array of CWnd*, comparing to array of IDs etc.
00295       char class_name[16];
00296       if (GetClassName(wnd->GetSafeHwnd(),class_name,sizeof(class_name))!=0)
00297       {
00298         if (_strnicmp(class_name,"edit",5)==0)
00299         {
00300           return TRUE;
00301           // discard the message!
00302         }
00303       }
00304     }
00305   }
00306   // be a good citizen - call the base class
00307   return CDialog::PreTranslateMessage(pMsg);
00308 }
00309
00310 // MFC generated function
00311 void CGenericUCPDlg::OnSysCommand(UINT nID, LPARAM lParam)
00312 {
00313   if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00314   {
00315     CAboutDlg dlgAbout;
00316     dlgAbout.DoModal();
00317   }
00318   else
00319   {
00320     CDialog::OnSysCommand(nID, lParam);
00321   }
00322 }
00323
00324 // If you add a minimize button to your dialog, you will need the code below
00325 //  to draw the icon.  For MFC applications using the document/view model,
00326 //  this is automatically done for you by the framework.
00327
00328 void CGenericUCPDlg::OnPaint()
00329 {
00330   if (IsIconic())
00331   {
00332     CPaintDC dc(this); // device context for painting
00333
00334     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
00335
00336     // Center icon in client rectangle
00337     int cxIcon = GetSystemMetrics(SM_CXICON);
00338     int cyIcon = GetSystemMetrics(SM_CYICON);
00339     CRect rect;
00340     GetClientRect(&rect);
00341     int x = (rect.Width() - cxIcon + 1) / 2;
00342     int y = (rect.Height() - cyIcon + 1) / 2;
00343
00344     // Draw the icon
00345     dc.DrawIcon(x, y, m_hIcon);
00346   }
00347   else
00348   {
00349     CDialog::OnPaint();
00350   }
00351 }
00352
00353 // The system calls this to obtain the cursor to display while the user drags
00354 //  the minimized window.
00355 HCURSOR CGenericUCPDlg::OnQueryDragIcon()
00356 {
00357   return (HCURSOR) m_hIcon;
00358 }
00359
00360
00361 //+---------------------------------------------------------------------------
00362 //
00363 //  Member:   ClearDeviceCombo
00364 //
00365 //  Purpose:    Clears the device combo and releases the device pointer stored
00366 //        in the list
00367 //
00368 //  Arguments:
00369 //        None
00370 //
00371 //  Returns:    None
00372 //
00373 //  Notes:
00374 //
00375
00376 void CGenericUCPDlg::ClearDeviceCombo(void)
00377 {
00378     IUPnPDevice *pDevice = NULL;
00379
00380   // We are going to release the device pointers we have stored in ItemDataPtr of each item
00381     int nCount = m_DeviceCombo.GetCount();
00382
00383   for (int i=0; i < nCount; i++){
00384         pDevice = (IUPnPDevice *) m_DeviceCombo.GetItemDataPtr(i);
00385         ReleaseObj(pDevice);
00386   }
00387     m_DeviceCombo.ResetContent();
00388 }
00389
00390 //+---------------------------------------------------------------------------
00391 //
00392 //  Member:   ClearServiceCombo
00393 //
00394 //  Purpose:    Clears the service combo and releases the service pointer stored
00395 //        in the list
00396 //
00397 //  Arguments:
00398 //        None
00399 //
00400 //  Returns:    None
00401 //
00402 //  Notes:
00403 //
00404
00405 void CGenericUCPDlg::ClearServiceCombo(void)
00406 {
00407     IUPnPService *pService = NULL;
00408
00409   // We are going to release the service pointers we have stored in ItemDataPtr of each item
00410     int nCount = m_ServiceCombo.GetCount();
00411
00412   for (int i=0; i < nCount; i++){
00413         pService = (IUPnPService *) m_ServiceCombo.GetItemDataPtr(i);
00414         ReleaseObj(pService);
00415   }
00416     m_ServiceCombo.ResetContent();
00417   m_EventText.SetWindowText(_T("")); // Clear  the event text
00418 }
00419
00420 //+---------------------------------------------------------------------------
00421 //
00422 //  Member:   ClearAllDataStructures
00423 //
00424 //  Purpose:    Clears various combo boxes, sets the text of the labels
00425 //
00426 //  Arguments:
00427 //    fClearFindCombo [in]  Flag to clear the findCombo box.
00428 //
00429 //  Returns:    None
00430 //
00431 //  Notes:
00432 //
00433
00434
00435 void CGenericUCPDlg::ClearAllDataStructures(BOOL fClearFindCombo)
00436 {
00437    // We are going to clear all the combo boxes and all the COM interfaces.
00438    if (fClearFindCombo)
00439    {
00440   // Clear the find combo box
00441   m_FindCombo.ResetContent();
00442   m_astrDevType.RemoveAll();
00443    }
00444
00445    ClearDeviceCombo();
00446    ClearServiceCombo();
00447
00448    m_StatusText.SetWindowText(_T(""));
00449    m_EventText.SetWindowText(_T(""));
00450 }
00451
00452
00453 //+---------------------------------------------------------------------------
00454 //
00455 //  Member:   OnFindByType
00456 //
00457 //  Purpose:    Initialize the find combo box with the device types
00458 //    from devType.txt and stop async find if necessary
00459 //
00460 //  Arguments:
00461 //    None
00462 //
00463 //  Returns:    None
00464 //
00465 //  Notes:  Called when FindByType radio button is clicked
00466 //
00467
00468 void CGenericUCPDlg::OnFindByType()
00469 {
00470    // We are going to do a FindByType
00471    // Hence we are going to load the FindCombo with the list of the types
00472    // from devType.txt.
00473
00474    StopAsyncFindIfStarted();
00475    ClearAllDataStructures(TRUE);
00476    InitializeDevTypeArray();
00477 }
00478
00479
00480 //+---------------------------------------------------------------------------
00481 //
00482 //  Member:   OnFindByUDN
00483 //
00484 //  Purpose:    Initialize the find combo box with the UDNs
00485 //        from udn.txt and stop async find if necessary
00486 //
00487 //  Arguments:
00488 //        None
00489 //
00490 //  Returns:    None
00491 //
00492 //  Notes:    Called when FindByUDN radio button is clicked
00493 //
00494 void CGenericUCPDlg::OnFindbyUDN()
00495 {
00496
00497    // We are going to do a FindByUDN
00498    // Hence we are going to load the FindCombo with the list of the types
00499    // from UDN.txt.
00500    StopAsyncFindIfStarted();
00501    ClearAllDataStructures(TRUE);
00502    InitializeUDNList();
00503 }
00504
00505
00506 //+---------------------------------------------------------------------------
00507 //
00508 //  Member:   OnAsyncFind
00509 //
00510 //  Purpose:    Initialize the find combo box with the device types
00511 //              from devType.txt and stop async find if necessary
00512 //
00513 //  Arguments:
00514 //    None
00515 //
00516 //  Returns:    None
00517 //
00518 //  Notes:    Called when AsyncFind radio button is clicked
00519 //
00520 void CGenericUCPDlg::OnAsyncFind()
00521 {
00522    // We are going to do AsyncFind
00523    // Hence we are going to load the FindCombo with the list of the types
00524    // from devType.txt.
00525    StopAsyncFindIfStarted();
00526    ClearAllDataStructures(TRUE);
00527    InitializeDevTypeArray();
00528 }
00529
00530
00531 //+---------------------------------------------------------------------------
00532 //
00533 //  Member:   OnDiscoveryClicked
00534 //
00535 //  Purpose:    Start the discovery of the type of search requested
00536 //
00537 //  Arguments:
00538 //        None
00539 //
00540 //  Returns:    None
00541 //
00542 //  Notes:    Called when "Start Discovery" button is clicked
00543 //
00544
00545 void CGenericUCPDlg::OnDiscoveryClicked()
00546 {
00547     // Disable the StartDiscovey Button if the find is a synchronous find.
00548     if (m_FindByType.GetCheck() || m_FindByUDN.GetCheck())
00549     {
00550        m_StartDiscovery.EnableWindow(FALSE);
00551     }
00552
00553     HRESULT hr = S_OK;
00554     CString strWindowString;
00555
00556     StopAsyncFindIfStarted(); // If AsyncFind is in progress, stop it
00557     ClearAllDataStructures(FALSE); // Don't clear the find combo box
00558
00559     m_StatusText.SetWindowText(_T("Discovery Clicked"));
00560     m_EventText.SetWindowText(_T(""));
00561
00562     // Check if we chosen an item in the list
00563     m_FindCombo.GetWindowText(strWindowString);
00564     if(strWindowString.IsEmpty() && m_FindCombo.GetCurSel()==-1)
00565     {
00566         MessageBox(_T("Select one of the items from the list"));
00567         return;
00568     }
00569
00570     // We have to get the search parameters
00571     CString strSearchParameter;
00572     if(m_FindByType.GetCheck() || m_AsyncFind.GetCheck())
00573     {
00574         if(m_FindCombo.GetCurSel()==-1)
00575         {
00576             strSearchParameter=strWindowString; // Get it from the edit box
00577         }
00578         else
00579         {
00580             strSearchParameter=m_astrDevType[m_FindCombo.GetCurSel()];
00581         }
00582     }
00583     else
00584     {
00585         if(m_FindByUDN.GetCheck())
00586         {
00587             strSearchParameter=strWindowString;
00588         }
00589     }
00590
00591     ReleaseObj(m_pDeviceFinder);
00592     m_pDeviceFinder = NULL;
00593
00594     // Instantiate the device finder object
00595     hr = CoCreateInstance( CLSID_UPnPDeviceFinder,
00596                            NULL,
00597                            CLSCTX_SERVER,
00598                            IID_IUPnPDeviceFinder,
00599                            (LPVOID *)&m_pDeviceFinder);
00600
00601     if(hr!=S_OK)
00602     {
00603         m_StatusText.SetWindowText(
00604                         _T("CoCreateInstance failed for device finder object")
00605                         );
00606         PrintErrorText(hr);
00607         return;
00608     }
00609
00610     BSTR bstrSearchType = NULL;
00611     bstrSearchType = strSearchParameter.AllocSysString();
00612     if (bstrSearchType != NULL)
00613     {
00614         if(m_FindByType.GetCheck())
00615         {
00616             // We have to process the FindByType.
00617             ProcessFindByType(bstrSearchType);
00618             m_StartDiscovery.EnableWindow(TRUE);
00619         }
00620         else if (m_FindByUDN.GetCheck())
00621         {
00622             // We have to process the FindByUDN.
00623             ProcessFindByUDN(bstrSearchType);
00624             m_StartDiscovery.EnableWindow(TRUE);
00625         }
00626         else if (m_AsyncFind.GetCheck())
00627         {
00628             // We have to process the AsyncFind.
00629             ProcessAsyncFind(bstrSearchType);
00630             SysFreeString(bstrSearchType);
00631
00632             // We should not release the device finder object.
00633             // Hence we are going to handle the exit here
00634             return;
00635         }
00636         m_StatusText.SetWindowText(_T("End of discovery process"));
00637
00638   if(m_DeviceCombo.GetCount()>0)
00639         {
00640             m_DeviceCombo.SetCurSel(0);
00641             OnSelEndOkComboDevice();
00642         }
00643
00644   SysFreeString(bstrSearchType);
00645
00646         // We are not releasing the device finder interface in the case of
00647         // async find
00648         ReleaseObj(m_pDeviceFinder);
00649
00650         m_pDeviceFinder = NULL;
00651     }
00652
00653 }
00654
00655
00656 //+---------------------------------------------------------------------------
00657 //
00658 //  Member:   ProcessFindByType
00659 //
00660 //  Purpose:    Helper function for processing the FindByType search
00661 //
00662 //  Arguments:
00663 //    bstrSearchType  [in]  Search type identifier
00664 //
00665 //  Returns:    None
00666 //
00667 //  Notes:
00668 //
00669
00670
00671 void CGenericUCPDlg::ProcessFindByType(BSTR bstrSearchType)
00672 {
00673    // We have to process FindByType search
00674    HRESULT hr = S_OK;
00675    IUPnPDevices* pDevices = NULL;
00676    IUnknown* punkEnum = NULL;
00677    IEnumUnknown *pEU = NULL;
00678
00679    ASSERT(m_pDeviceFinder);
00680    m_StatusText.SetWindowText(_T("FindByType selected"));
00681    hr = m_pDeviceFinder->FindByType(bstrSearchType, 0,  &pDevices);
00682    if (SUCCEEDED(hr))
00683    {
00684       // We have to enumerate the devices
00685       long lCount;
00686       hr = pDevices->get_Count(&lCount);
00687       if (SUCCEEDED(hr))
00688       {
00689          if (lCount != 0)
00690          {
00691             hr = pDevices->get__NewEnum(&punkEnum);
00692             if (SUCCEEDED(hr))
00693             {
00694                hr = punkEnum->QueryInterface(IID_IEnumUnknown, (VOID **) &pEU);
00695                if (SUCCEEDED(hr))
00696                {
00697                   for (long lIndex = 0; lIndex<lCount; lIndex++)
00698                   {
00699                      IUnknown* punkDevice = NULL;
00700                      IUPnPDevice* pDevice=NULL;
00701                      hr = pEU->Next(1, &punkDevice, NULL);
00702                      if (SUCCEEDED(hr))
00703                      {
00704                         // Get a IUPnPDevice pointer to the device just got
00705                         hr = punkDevice->QueryInterface(
00706                                             IID_IUPnPDevice,
00707                                             (VOID **)&pDevice
00708                                             );
00709                         if (SUCCEEDED(hr))
00710                         {
00711                            // Add the found device to the device list
00712                            // Get the friendly name of the device
00713                            BSTR bstrFriendlyName = NULL;
00714                            hr = pDevice->get_FriendlyName(&bstrFriendlyName);
00715                            if (SUCCEEDED(hr))
00716                            {
00717                               TCHAR tszFriendlyName[DATA_BUFSIZE];
00718                               _sntprintf(
00719                                   tszFriendlyName,
00720                                   DATA_BUFSIZE - 1,
00721                                   _T("%S"),
00722                                   bstrFriendlyName
00723                                   );
00724                               m_DeviceCombo.AddString(tszFriendlyName);
00725                               m_DeviceCombo.SetItemDataPtr(
00726                                                (int)lIndex,
00727                                                pDevice
00728                                                );
00729                               SysFreeString(bstrFriendlyName);
00730                            }
00731                            else
00732                            {
00733                               m_StatusText.SetWindowText(
00734                                               _T("Error: FriendlyName failed")
00735                                               );
00736                               PrintErrorText(hr);
00737                               ReleaseObj(pDevice);
00738                               ReleaseObj(punkDevice);
00739                               break;
00740                            }
00741                         }
00742                         else
00743                         {
00744                             m_StatusText.SetWindowText(
00745                              _T("Error: QueryInterface for IUPnPDevice failed")
00746                              );
00747                             PrintErrorText(hr);
00748                             ReleaseObj(punkDevice);
00749                             break;
00750                         }
00751                         ReleaseObj(punkDevice);
00752                      }
00753                      else
00754                      {
00755                         m_StatusText.SetWindowText(
00756                            _T("Error: Traversing the device list using Next"
00757                               " method failed")
00758                            );
00759                         PrintErrorText(hr);
00760                         break; // Get out of the for loop
00761                      }
00762                   } // For loop
00763                   ReleaseObj(pEU);
00764                }
00765                else
00766                {
00767                   m_StatusText.SetWindowText(
00768                       _T("Error: QueryInterface for IID_IEnumUnknown failed")
00769                       );
00770                   PrintErrorText(hr);
00771                }
00772                ReleaseObj(punkEnum);
00773             }
00774             else
00775             {
00776                m_StatusText.SetWindowText(
00777                                _T("get__NewEnum in IUPnPDevices failed")
00778                                );
00779                PrintErrorText(hr);
00780             }
00781          }
00782          else
00783          {
00784             MessageBox(_T("Found no devices"));
00785          }
00786       }
00787       else
00788       {
00789          m_StatusText.SetWindowText(_T("get_Count in IUPnPDevices failed"));
00790          PrintErrorText(hr);
00791       }
00792       ReleaseObj(pDevices);
00793    }
00794    else
00795    {
00796       m_StatusText.SetWindowText(_T("FindByType failed"));
00797       PrintErrorText(hr);
00798    }
00799 }
00800
00801
00802 //+---------------------------------------------------------------------------
00803 //
00804 //  Member:   ProcessFindByUDN
00805 //
00806 //  Purpose:    Helper function for processing the FindByUDN search
00807 //
00808 //  Arguments:
00809 //        bstrSearchType  [in]  Search type identifier
00810 //
00811 //  Returns:    None
00812 //
00813 //  Notes:
00814 //
00815
00816 void CGenericUCPDlg::ProcessFindByUDN(BSTR bstrSearchType)
00817 {
00818   // FindByUDN selected
00819   HRESULT hr= S_OK;
00820
00821   m_StatusText.SetWindowText(_T("FindByUDN selected"));
00822   ASSERT(m_pDeviceFinder);
00823   IUPnPDevice* pDevice = NULL;
00824   hr = m_pDeviceFinder->FindByUDN(bstrSearchType, &pDevice);
00825   if(hr==S_OK){
00826     // Found a device with given udn
00827     // Add the found device to the device list
00828     // Get the friendly name of the device
00829     BSTR bstrFriendlyName = NULL;
00830     hr = pDevice->get_FriendlyName(&bstrFriendlyName);
00831     if(SUCCEEDED(hr)){
00832       TCHAR tszFriendlyName[DATA_BUFSIZE];
00833       _sntprintf(tszFriendlyName, DATA_BUFSIZE-1, _T("%S"), bstrFriendlyName);
00834       m_DeviceCombo.AddString(tszFriendlyName);
00835       m_DeviceCombo.SetItemDataPtr(0, pDevice); // Add as the first element
00836       SysFreeString(bstrFriendlyName);
00837     }
00838     else{
00839       m_StatusText.SetWindowText(_T("Error: FriendlyName failed"));
00840       PrintErrorText(hr);
00841     }
00842   }
00843   else{
00844     MessageBox(_T("Found no device with given udn"));
00845   }
00846 }
00847
00848
00849 //+---------------------------------------------------------------------------
00850 //
00851 //  Member:   ProcessAsyncFind
00852 //
00853 //  Purpose:    Helper function for processing the AsyncFind search
00854 //
00855 //  Arguments:
00856 //        bstrSearchType  [in]  Search type identifier
00857 //
00858 //  Returns:    None
00859 //
00860 //  Notes:
00861 //
00862 void CGenericUCPDlg::ProcessAsyncFind(BSTR bstrSearchType)
00863 {
00864    HRESULT hr = S_OK;
00865
00866    ASSERT(m_pDeviceFinder);
00867    m_StatusText.SetWindowText(_T("AsyncFind selected"));
00868
00869    // We have to start the AsyncFind.
00870    if (m_pDeviceFinderCallback!=NULL)
00871    {
00872        hr = m_pDeviceFinder->CreateAsyncFind(
00873                                 bstrSearchType,
00874                                 NULL,
00875                                 m_pDeviceFinderCallback,
00876                                 &m_lAsyncFindHandle
00877                                 );
00878        if (SUCCEEDED(hr))
00879        {
00880           hr = m_pDeviceFinder->StartAsyncFind(m_lAsyncFindHandle);
00881           if (SUCCEEDED(hr))
00882           {
00883              m_fAsyncFindRunning = TRUE;
00884           }
00885           else
00886           {
00887              PrintErrorText(hr);
00888              m_StatusText.SetWindowText(
00889                              _T("Error: StartAsyncFind failed")
00890                              );
00891              hr = m_pDeviceFinder->CancelAsyncFind(m_lAsyncFindHandle);
00892              if (FAILED(hr))
00893              {
00894                 m_StatusText.SetWindowText(_T("CancelAsyncFind failed"));
00895                 PrintErrorText(hr);
00896              }
00897           }
00898        }
00899        else
00900        {
00901           PrintErrorText(hr);
00902           m_StatusText.SetWindowText(_T("Error: CreateAsyncFind failed"));
00903        }
00904    }
00905    else
00906    {
00907       m_StatusText.SetWindowText(
00908                       _T("DeviceFinderCallback object is not available")
00909                       );
00910    }
00911 }
00912
00913
00914 //+---------------------------------------------------------------------------
00915 //
00916 //  Member: InitializeDevTypeArray
00917 //
00918 //  Purpose:    Helper function for initializing the find combo box
00919 //    with list of device types
00920 //
00921 //  Arguments:
00922 //    None
00923 //
00924 //  Returns:    None
00925 //
00926 //  Notes:  Called when FindByType or AsyncFind is clicked
00927 //
00928 void CGenericUCPDlg::InitializeDevTypeArray()
00929 {
00930    // First remove all the stored elements in the devType array
00931    m_astrDevType.RemoveAll();
00932
00933    // Also remove the items in the FindCombo
00934    m_FindCombo.ResetContent();
00935
00936    // Check whether the file devtype.txt exists
00937    if (!fFileExists(_T("devtype.txt")))
00938    {
00939       // devtype.txt file doesn't exist
00940       m_StatusText.SetWindowText(_T("Warning: devType.txt doesn't exist"));
00941       return;
00942    }
00943
00944    // We can start reading the file
00945    CStdioFile fileDevType;
00946    if (!fileDevType.Open(_T("devtype.txt"), CFile::modeRead|CFile::typeText))
00947    {
00948       MessageBox(_T("Error: Can't open the devtype.txt file"));
00949       return;
00950    }
00951
00952    CString strLine;
00953    while (fileDevType.ReadString(strLine))
00954    {
00955       // We have got one line at a time
00956       if (!strLine.IsEmpty())
00957       {
00958          // We are going to split the string first
00959          int iSpacePos;
00960          iSpacePos = strLine.Find(' '); // Find the first space character
00961          if (iSpacePos == -1) //space character not found
00962          {
00963             MessageBox(
00964                _T("Error: Malformed line in devType.txt, no space " \
00965                "type and description")
00966                );
00967             fileDevType.Close();
00968             return;
00969          }
00970
00971          CString strDeviceType = strLine.Left(iSpacePos);
00972          CString strDeviceDesc = strLine.Right(
00973                                             strLine.GetLength() - iSpacePos - 1
00974                                             );
00975
00976          // We are going to add this to the szaDevType Array
00977          m_astrDevType.Add(strDeviceType);
00978          //Also add the device description to the findCombo
00979          m_FindCombo.AddString(strDeviceDesc);
00980       }
00981    }
00982
00983    fileDevType.Close();
00984    m_FindCombo.SetCurSel(0); // Select the first item in the list
00985 }
00986
00987
00988 //+---------------------------------------------------------------------------
00989 //
00990 //  Member:   fFileExists
00991 //
00992 //  Purpose:    Find whether the given file exists
00993 //
00994 //  Arguments:
00995 //  ptszFileName [in] File name of the file to check
00996 //
00997 //  Returns:    TRUE or FALSE
00998 //
00999 //  Notes:
01000 //
01001 BOOL CGenericUCPDlg::fFileExists(LPTSTR ptszFileName)
01002 {
01003     DWORD   dwValue;
01004     dwValue = GetFileAttributes(ptszFileName);
01005
01006     if (dwValue == -1 )
01007     {
01008   // Return false if we are not able to get the file attributes
01009         return FALSE;
01010     }
01011     else
01012     {
01013   return TRUE;
01014     }
01015 }
01016
01017
01018 //+---------------------------------------------------------------------------
01019 //
01020 //  Member:   InitializeUDNList
01021 //
01022 //  Purpose:    Helper function for initializing the find combo box
01023 //        with list of UDNs
01024 //
01025 //  Arguments:
01026 //        None
01027 //
01028 //  Returns:    None
01029 //
01030 //  Notes:    Called when FindByUDN is clicked
01031 //
01032 void CGenericUCPDlg::InitializeUDNList()
01033 {
01034    // Also remove the items in the FindCombo
01035    m_FindCombo.ResetContent();
01036
01037    // Check whether the file udn.txt exists
01038    if (!fFileExists(_T("udn.txt")))
01039    {
01040       // udn.txt file doesn't exist
01041       m_StatusText.SetWindowText(_T("Warning: udn.txt doesn't exist"));
01042       return;
01043    }
01044
01045    // We can start reading the file
01046
01047    CStdioFile fileDevType;
01048    if (!fileDevType.Open(_T("udn.txt"), CFile::modeRead|CFile::typeText))
01049    {
01050        MessageBox(_T("Error: Can't open the udn.txt file"));
01051        return;
01052    }
01053
01054    CString strLine;
01055    while (fileDevType.ReadString(strLine))
01056    {
01057       // We have got one line at a time
01058       if (!strLine.IsEmpty())
01059       {
01060          m_FindCombo.AddString(strLine);
01061       }
01062    }
01063
01064    fileDevType.Close();
01065    m_FindCombo.SetCurSel(0); // Select the first item in the list
01066
01067 }
01068
01069
01070 //+---------------------------------------------------------------------------
01071 //
01072 //  Member:   StopAsyncFindIfStarted
01073 //
01074 //  Purpose:    Helper function for stopping the async find if proceeding
01075 //
01076 //  Arguments:
01077 //        None
01078 //
01079 //  Returns:    None
01080 //
01081 //  Notes:
01082 //
01083 void CGenericUCPDlg::StopAsyncFindIfStarted()
01084 {
01085    HRESULT hr = S_OK;
01086
01087    // This will stop the async find if it is in progress
01088    if (m_fAsyncFindRunning == TRUE)
01089    {
01090       ASSERT(m_pDeviceFinder != NULL);
01091       hr = m_pDeviceFinder->CancelAsyncFind(m_lAsyncFindHandle);
01092       if (FAILED(hr))
01093       {
01094          m_StatusText.SetWindowText(_T("CancelAsyncFind failed"));
01095          MessageBox("Cancel Async Find Failed.", "Error");
01096       }
01097
01098       m_fAsyncFindRunning=FALSE;
01099    }
01100 }
01101
01102
01103 //+---------------------------------------------------------------------------
01104 //
01105 //  Member:   AddDevice
01106 //
01107 //  Purpose:    Helper function for adding devices to the device combo box
01108 //
01109 //  Arguments:
01110 //    pDevice [in]  COM interface pointer of the device being added
01111 //
01112 //  Returns:    None
01113 //
01114 //  Notes:
01115 //     This is called by the devicefinder callback object (DeviceAdded func)
01116 //
01117 void CGenericUCPDlg::AddDevice(IUPnPDevice *pDevice)
01118 {
01119    //We are going to add a device
01120    HRESULT hr=S_OK;
01121    BSTR bstrFriendlyName = NULL;
01122
01123    hr = pDevice->get_FriendlyName(&bstrFriendlyName);
01124    if (SUCCEEDED(hr))
01125    {
01126       pDevice->AddRef(); // Add Ref for the device
01127       TCHAR tszFriendlyName[DATA_BUFSIZE];
01128       TCHAR tszStatusString[DATA_BUFSIZE];
01129       _sntprintf(tszFriendlyName, DATA_BUFSIZE-1, _T("%S"), bstrFriendlyName);
01130       _sntprintf(
01131           tszStatusString,
01132           DATA_BUFSIZE - 1,
01133           _T("Added Device %s"),
01134           tszFriendlyName
01135           );
01136
01137       m_StatusText.SetWindowText(tszStatusString);
01138
01139       int nCount = m_DeviceCombo.GetCount(); // Find the end of the list
01140
01141       m_DeviceCombo.AddString(tszFriendlyName);
01142
01143       // Explicitly AddRef for passing off the ownership to the combolist item.
01144       pDevice->AddRef();
01145
01146       // Add the item at the end of the combolist
01147       m_DeviceCombo.SetItemDataPtr(nCount, pDevice);
01148       pDevice->Release(); // Release the current ownership of the pointer
01149
01150       if (nCount==0)
01151       {
01152          m_DeviceCombo.SetCurSel(0);
01153          OnSelEndOkComboDevice();
01154       }
01155
01156       SysFreeString(bstrFriendlyName);
01157    }
01158    else
01159    {
01160       PrintErrorText(hr);
01161       m_StatusText.SetWindowText(
01162                       _T("Error: FriendlyName failed for device added failed")
01163                       );
01164    }
01165 }
01166
01167
01168 //+---------------------------------------------------------------------------
01169 //
01170 //  Member: RemoveDevice
01171 //
01172 //  Purpose:    Helper function for removing device from the device combo box
01173 //
01174 //  Arguments:
01175 //    bstrUDN [in]  UDN of the device being deleted
01176 //
01177 //  Returns:    None
01178 //
01179 //  Notes:
01180 //     This is called by the devicefinder callback object (DeviceRemoved func)
01181 //
01182 void CGenericUCPDlg::RemoveDevice(BSTR bstrUDN)
01183 {
01184     //We are going to remove the device
01185     HRESULT hr=S_OK;
01186     IUPnPDevice *pDevice = NULL;
01187     BSTR bstrTemp = NULL;
01188
01189     // We are going to release the device pointers we have stored in ItemDataPtr of each item
01190     int nCount = m_DeviceCombo.GetCount();
01191
01192     for (int i=0; i < nCount; i++)
01193     {
01194         pDevice = (IUPnPDevice *) m_DeviceCombo.GetItemDataPtr(i);
01195
01196         pDevice->AddRef();
01197
01198         // Check if the device pointer is the one we want
01199         hr=pDevice->get_UniqueDeviceName(&bstrTemp);
01200
01201         if(SUCCEEDED(hr))
01202         {
01203             if(wcscmp(bstrTemp, bstrUDN)==0)
01204             {
01205                 // This is the removed device
01206                 ReleaseObj(pDevice); //Since we are going to remove the device, we have to release it totally.
01207                 m_DeviceCombo.DeleteString(i);
01208                 i--; // So that we search the next device in the list
01209                 nCount--;
01210
01211                 break;
01212             }
01213
01214             SysFreeString(bstrTemp);
01215
01216             bstrTemp = NULL;
01217         }
01218         else
01219         {
01220             PrintErrorText(hr);
01221             m_StatusText.SetWindowText(_T("Error: GetUniqueDeviceName failed for the device in the list"));
01222         }
01223         ReleaseObj(pDevice);
01224     }
01225
01226     if ( bstrTemp != NULL )
01227     {
01228         SysFreeString(bstrTemp);
01229     }
01230
01231 }
01232
01233
01234 //+---------------------------------------------------------------------------
01235 //
01236 //  Member:   OnSelEndOkComboDevice
01237 //
01238 //  Purpose:    To populate the service list for the device selected
01239 //
01240 //  Arguments:
01241 //        None
01242 //
01243 //  Returns:    None
01244 //
01245 //  Notes:
01246 //
01247 void CGenericUCPDlg::OnSelEndOkComboDevice()
01248 {
01249   // Current Device is changed
01250   TRACE(_T("SelendokDevice\n"));
01251
01252   HRESULT hr = S_OK;
01253   IUPnPDevice *pDevice=NULL;
01254   IUPnPServices* pServices = NULL;
01255   IUnknown *punkEnum = NULL;
01256   IEnumUnknown *pEU = NULL;
01257   int iSelectedItem;
01258   long lIndex;
01259   m_StatusText.SetWindowText(_T(""));
01260   m_EventText.SetWindowText(_T(""));
01261   iSelectedItem = m_DeviceCombo.GetCurSel();
01262   if(iSelectedItem!=CB_ERR){
01263     pDevice=(IUPnPDevice *) m_DeviceCombo.GetItemDataPtr(iSelectedItem);
01264     pDevice->AddRef();
01265     ClearServiceCombo();
01266     hr = pDevice->get_Services(&pServices);
01267     if(hr==S_OK){
01268       long lCount;
01269       hr = pServices->get_Count(&lCount);
01270       if(SUCCEEDED(hr)){
01271         if(lCount!=0){
01272           // We have to get a IEnumUnknown pointer
01273           hr = pServices->get__NewEnum(&punkEnum);
01274           if(SUCCEEDED(hr)){
01275             hr = punkEnum->QueryInterface(IID_IEnumUnknown, (VOID **) &pEU);
01276             if(SUCCEEDED(hr)){
01277               for(lIndex = 0; lIndex<lCount; lIndex++){
01278                 IUnknown *punkService = NULL;
01279                 IUPnPService *pService=NULL;
01280                 hr = pEU->Next(1, &punkService, NULL);
01281                 if(SUCCEEDED(hr)){
01282                   // Get a IUPnPService pointer to the service just got
01283                   hr = punkService->QueryInterface(IID_IUPnPService, (VOID **)&pService);
01284                   if(SUCCEEDED(hr)){
01285                     BSTR bstrServiceId = NULL;
01286                     hr = pService->get_Id(&bstrServiceId);
01287                     if(SUCCEEDED(hr)){
01288                       TCHAR tszServiceId[DATA_BUFSIZE];
01289                       _sntprintf(tszServiceId, DATA_BUFSIZE-1, _T("%S"), bstrServiceId);
01290                       m_ServiceCombo.AddString(tszServiceId);
01291                       m_ServiceCombo.SetItemDataPtr((int)lIndex, pService);
01292                       SysFreeString(bstrServiceId);
01293                     }
01294                     else{
01295                       PrintErrorText(hr);
01296                       m_StatusText.SetWindowText(_T("Error: get_Id failed"));
01297                       ReleaseObj(pService);
01298                       ReleaseObj(punkService);
01299                       break;
01300                     }
01301                   }
01302                   else{
01303                     m_StatusText.SetWindowText(_T("Error: QueryInterface for IUPnPService failed"));
01304                     ReleaseObj(punkService);
01305                     break;
01306                   }
01307                   ReleaseObj(punkService);
01308                 }
01309                 else{
01310                   m_StatusText.SetWindowText(_T("Error: Traversing the service list using Next method failed"));
01311                   break; // Get out of the for loop
01312                 }
01313
01314               }//For loop
01315               if(m_ServiceCombo.GetCount()>0){
01316                 m_ServiceCombo.SetCurSel(0);
01317                 OnSelEndOkComboService();
01318               }
01319               ReleaseObj(pEU);
01320             }
01321             else{
01322               PrintErrorText(hr);
01323               m_StatusText.SetWindowText(_T("Error: QueryInterface for IID_IEnumUnknown failed"));
01324             }
01325             ReleaseObj(punkEnum);
01326           }
01327           else{
01328             PrintErrorText(hr);
01329             m_StatusText.SetWindowText(_T("get__NewEnum in IUPnPServices failed"));
01330           }
01331         }
01332         else{
01333           MessageBox(_T("Found no services"));
01334         }
01335       }
01336       else{
01337         PrintErrorText(hr);
01338         m_StatusText.SetWindowText(_T("get_Count in IUPnPServices failed"));
01339       }
01340       ReleaseObj(pServices);
01341     }
01342     else{
01343       PrintErrorText(hr);
01344       m_StatusText.SetWindowText(_T("Error: Getting services for the current device failed"));
01345     }
01346     ReleaseObj(pDevice); // Release the pDevice which is the currently selected device
01347   }
01348 }
01349
01350 //+---------------------------------------------------------------------------
01351 //
01352 //  Member:   OnSelEndOkComboService
01353 //
01354 //  Purpose:    To add the callback for the service selected
01355 //
01356 //  Arguments:
01357 //        None
01358 //
01359 //  Returns:    None
01360 //
01361 //  Notes:
01362 //
01363 void CGenericUCPDlg::OnSelEndOkComboService()
01364 {
01365    HRESULT hr = S_OK;
01366    IUPnPService* pService = NULL;
01367
01368    int iSelectedItem ;
01369
01370    iSelectedItem = m_ServiceCombo.GetCurSel();
01371
01372    if (iSelectedItem!=CB_ERR)
01373    {
01374       pService=(IUPnPService*)m_ServiceCombo.GetItemDataPtr(
01375                                                 m_ServiceCombo.GetCurSel()
01376                                                 );
01377       pService->AddRef();
01378       m_EventText.SetWindowText(_T(""));
01379       hr = pService->AddCallback(m_pServiceCallback);
01380
01381       if (FAILED(hr))
01382       {
01383      PrintErrorText(hr);
01384    m_StatusText.SetWindowText(_T("Error: AddCallback failed"));
01385       }
01386       ReleaseObj(pService);
01387    }
01388 }
01389
01390
01391 //+---------------------------------------------------------------------------
01392 //
01393 //  Member: OnDevpropClick
01394 //
01395 //  Purpose:    Show the properties of the selected device
01396 //
01397 //  Arguments:
01398 //    None
01399 //
01400 //  Returns:    None
01401 //
01402 //  Notes:
01403 //      This starts up the modal CDeviceProp dialog and displays the properties
01404 //
01405 void CGenericUCPDlg::OnDevpropClick()
01406 {
01407    int iSelectedDevice;
01408    IUPnPDevice* pDevice = NULL;
01409
01410    // We have to show the properties of the current device
01411    iSelectedDevice = m_DeviceCombo.GetCurSel();
01412    if (iSelectedDevice != CB_ERR)
01413    {
01414       pDevice =
01415           (IUPnPDevice*)m_DeviceCombo.GetItemDataPtr(iSelectedDevice);
01416       CDeviceProp dlg(pDevice);
01417       dlg.DoModal();
01418    }
01419    else
01420    {
01421       MessageBox(_T("No device selected"));
01422    }
01423
01424 }
01425
01426
01427 //+---------------------------------------------------------------------------
01428 //
01429 //  Member:   OnQueryVariable
01430 //
01431 //  Purpose:    Query the variable for the selected service in the service list
01432 //
01433 //  Arguments:
01434 //        None
01435 //
01436 //  Returns:    None
01437 //
01438 //  Notes:    Displays the result in the action out edit box.
01439 //
01440 void CGenericUCPDlg::OnQueryVariable()
01441 {
01442    HRESULT hr=S_OK;
01443    TCHAR tszMessage[DATA_BUFSIZE];
01444    CString strVariable;
01445    int iCurrentDevice, iCurrentService;
01446
01447    // We are going to query the variable which is present in the variable
01448    // edit box
01449    m_ActionOutArgument.SetWindowText(_T(""));
01450
01451    iCurrentDevice = m_DeviceCombo.GetCurSel();
01452
01453    if (iCurrentDevice != CB_ERR)
01454    {
01455       iCurrentService = m_ServiceCombo.GetCurSel();
01456       if (iCurrentService != CB_ERR)
01457       {
01458          m_VariableName.GetWindowText(strVariable);
01459          if (!strVariable.IsEmpty())
01460          {
01461             BSTR bstrVariableName = NULL;
01462             bstrVariableName=strVariable.AllocSysString();
01463             if (bstrVariableName!=NULL)
01464             {
01465                VARIANT varValue;
01466                VariantInit(&varValue);
01467                IUPnPService* pService;
01468                pService=(IUPnPService*)m_ServiceCombo.GetItemDataPtr(
01469                                                          iCurrentService
01470                                                          );
01471                pService->AddRef();
01472                hr = pService->QueryStateVariable(bstrVariableName, &varValue);
01473
01474                if (SUCCEEDED(hr))
01475                {
01476                   hr = VariantChangeType(
01477                           &varValue,
01478                           &varValue,
01479                           VARIANT_ALPHABOOL,
01480                           VT_BSTR
01481                           );
01482
01483                   if (SUCCEEDED(hr))
01484                   {
01485                     _sntprintf(
01486                         tszMessage,
01487                         DATA_BUFSIZE - 1,
01488                         _T("%S"),
01489                         varValue.bstrVal
01490                         );
01491                      m_ActionOutArgument.SetWindowText(tszMessage);
01492                   }
01493                   else
01494                   {
01495                      PrintErrorText(hr);
01496                   }
01497                }
01498                else
01499                {
01500                   PrintErrorText(hr);
01501                }
01502
01503                ReleaseObj(pService);
01504                VariantClear (&varValue);
01505                SysFreeString(bstrVariableName);
01506             }
01507             else
01508             {
01509          MessageBox(_T("Error: Could not allocate the memory for BSTR"));
01510             }
01511          }
01512          else
01513          {
01514       MessageBox(_T("Please specify a query variable"));
01515          }
01516       }
01517       else
01518       {
01519          MessageBox(_T("No service selected"));
01520       }
01521    }
01522    else
01523    {
01524       MessageBox(_T("No device selected"));
01525    }
01526
01527 }
01528
01529
01530 //+---------------------------------------------------------------------------
01531 //
01532 //  Member:   OnInvokeAction
01533 //
01534 //  Purpose:    Invoke the action for the selected service in the service list
01535 //
01536 //  Arguments:
01537 //        None
01538 //
01539 //  Returns:    None
01540 //
01541 //  Notes:    Displays the result in the action out edit box.
01542 //
01543
01544 void CGenericUCPDlg::OnInvokeAction()
01545 {
01546     HRESULT hr=S_OK;
01547     TCHAR tszString[DATA_BUFSIZE];
01548     TCHAR tszTempString[DATA_BUFSIZE];
01549     CString strArg;
01550     CString strAction;
01551     int iCurrentDevice, iCurrentService;
01552     int i, iCount;
01553     long lIndex;
01554
01555     // We are going to query the variable which is present in the variable edit box
01556     m_ActionOutArgument.SetWindowText(_T(""));
01557
01558     iCurrentDevice=m_DeviceCombo.GetCurSel();
01559     if(iCurrentDevice!=CB_ERR)
01560     {
01561         iCurrentService=m_ServiceCombo.GetCurSel();
01562         if(iCurrentService!=CB_ERR)
01563         {
01564             m_ActionName.GetWindowText(strAction);
01565             if(!strAction.IsEmpty())
01566             {
01567                 BSTR bstrActionName = NULL;
01568                 bstrActionName=strAction.AllocSysString();
01569                 if(bstrActionName!=NULL)
01570                 {
01571                     m_ActionInArgument.GetWindowText(
01572                                           tszString,
01573                                           DATA_BUFSIZE - 1
01574                                           );
01575
01576                     // Make a copy of the read string so that the main string
01577                     // is not modified
01578                     SafeStrCopy(tszTempString, tszString, DATA_BUFSIZE);
01579
01580                     int iArgs = iNumberOfInArguments(tszTempString); // Get the number of arguments in the inArguments edit box
01581
01582                     VARIANT vaActionArgs, vaArray, vaOutArgs, vaRet, vaOutElement;
01583                     VARIANT**          ppVars = NULL;
01584                     SAFEARRAY          *psaArgs = NULL;
01585                     long               lPos;
01586                     long    lLBound = 0L, lUBound = 0L; // For out arguments
01587
01588                     //Initialize all the variants
01589                     VariantInit(&vaActionArgs);
01590                     VariantInit(&vaArray);
01591                     VariantInit(&vaOutArgs);
01592                     VariantInit(&vaRet);
01593                     VariantInit(&vaOutElement);
01594
01595                     if(!(FAILED(HrCreateSafeArray(VT_VARIANT, iArgs, &psaArgs))||
01596                          FAILED(HrCreateArgVariants(iArgs, &ppVars))))
01597                     {
01598                         VariantSetArray(psaArgs, vaArray);
01599                         VariantSetVar(&vaArray, vaActionArgs);
01600                         vaArray.pparray=&psaArgs;
01601
01602                         // Get the in arguments
01603                         // Put the arguments as strings
01604
01605                         TCHAR *token;
01606                         iCount=0; // Initialize the counter
01607                         token = _tcstok(tszString, _T(" "));
01608                         while(token!=NULL)
01609                         {
01610                             ASSERT(iCount<iArgs); // Make sure
01611                             strArg=token;
01612                             ppVars[iCount]->vt=VT_BSTR;
01613                             ppVars[iCount]->bstrVal=strArg.AllocSysString(); // Converting the argument into a BSTR
01614                             token = _tcstok(NULL, _T(" ")); // We have the space character as the separator
01615                             iCount++;
01616                         }
01617
01618                         for(i=0; i<iArgs; i++)
01619                         {
01620                             lPos=i+1;
01621                             SafeArrayPutElement(psaArgs, &lPos, ppVars[i]);
01622                         }
01623
01624                         IUPnPService *pService=NULL;
01625                         pService = (IUPnPService *)m_ServiceCombo.GetItemDataPtr(iCurrentService);
01626                         pService->AddRef();
01627                         hr = pService->InvokeAction( bstrActionName,
01628                                                      vaActionArgs,
01629                                                      &vaOutArgs,
01630                                                      &vaRet);
01631
01632                         if(SUCCEEDED(hr))
01633                         {
01634
01635                             // We have to print the return value and out arguments
01636                             *tszString=0; // Empty the string
01637                             *tszTempString=0; // Empty the string
01638
01639                             if(vaRet.vt!=VT_EMPTY)
01640                             {
01641                                 hr=VariantChangeType(&vaRet, &vaRet, VARIANT_ALPHABOOL, VT_BSTR);
01642                                 if(SUCCEEDED(hr))
01643                                 {
01644                                     _sntprintf(
01645                                         tszTempString,
01646                                         DATA_BUFSIZE - 1,
01647                                         _T("%S "),
01648                                         vaRet.bstrVal
01649                                         );
01650                                     _tcsncat(
01651                                         tszString,
01652                                         tszTempString,
01653                                         DATA_BUFSIZE - 1
01654                                         );
01655                                 }
01656                                 else
01657                                 {
01658                                     PrintErrorText(hr);
01659                                     m_StatusText.SetWindowText(
01660                                        _T("Error getting the return value for"
01661                                           " the action invoked")
01662                                        );
01663                                 }
01664                             }
01665
01666                             // We have to process the out arguments now
01667                             hr = HrGetSafeArrayBounds(
01668                                     vaOutArgs.parray,
01669                                     &lLBound,
01670                                     &lUBound
01671                                     );
01672                             if(SUCCEEDED(hr))
01673                             {
01674                                 // We have got the bounds of the arguments
01675                                 for (lIndex = lLBound;
01676                                     lIndex<=lUBound;
01677                                     ++lIndex
01678                                     )
01679                                 {
01680                                     VariantClear(&vaOutElement);
01681                                     hr = HrGetVariantElement(
01682                                             vaOutArgs.parray,
01683                                             lIndex,
01684                                             &vaOutElement
01685                                             );
01686                                     if(SUCCEEDED(hr))
01687                                     {
01688                                         hr = VariantChangeType(
01689                                                 &vaOutElement,
01690                                                 &vaOutElement,
01691                                                 VARIANT_ALPHABOOL,
01692                                                 VT_BSTR
01693                                                 );
01694                                         if (SUCCEEDED(hr))
01695                                         {
01696                                            _sntprintf(
01697                                                tszTempString,
01698                                                DATA_BUFSIZE - 1,
01699                                                _T("%S "),
01700                                                vaOutElement.bstrVal
01701                                                );
01702                                             _tcsncat(
01703                                                 tszString,
01704                                                 tszTempString,
01705                                                 (DATA_BUFSIZE -
01706                                                  _tcslen(tszString) - 1)
01707                                                 );
01708                                         }
01709                                         else
01710                                         {
01711                                             PrintErrorText(hr);
01712                                             m_StatusText.SetWindowText(
01713                                                _T("Error changing the out"
01714                                                   " argument type for the"
01715                                                   " action invoked")
01716                                                   );
01717                                         }
01718                                     }
01719                                     else
01720                                     {
01721                                         m_StatusText.SetWindowText(_T("Error getting the out argument for the action invoked"));
01722                                         PrintErrorText(hr);
01723                                     }
01724                                 } // For loop
01725
01726                                 VariantClear(&vaOutElement);
01727                             }
01728
01729                             m_ActionOutArgument.SetWindowText(tszString); // Print the return value and out arguments.
01730                         }
01731                         else
01732                         {
01733                             PrintErrorText(hr);
01734                         }
01735                         if(NULL != ppVars)
01736                             HrDestroyArgVariants(iArgs, &ppVars);
01737                         if(NULL != psaArgs)
01738                         {
01739                             SafeArrayDestroy(psaArgs);
01740                         }
01741                         ReleaseObj(pService);
01742                     }
01743
01744                     VariantClear(&vaActionArgs);
01745                     VariantClear(&vaArray);
01746                     VariantClear(&vaOutArgs);
01747                     VariantClear(&vaRet);
01748                     VariantClear(&vaOutElement);
01749                     SysFreeString(bstrActionName);
01750                 }
01751                 else
01752                 {
01753                     MessageBox(_T("Error: Could not allocate the memory for BSTR"));
01754                 }
01755
01756
01757             }
01758             else
01759             {
01760                 MessageBox(_T("Please specify an action name"));
01761             }
01762
01763
01764         }
01765         else
01766         {
01767             MessageBox(_T("No service selected"));
01768         }
01769     }
01770     else
01771     {
01772         MessageBox(_T("No device selected"));
01773     }
01774 }
01775
01776 //+---------------------------------------------------------------------------
01777 //
01778 //  Member:   OnCloseClick
01779 //
01780 //  Purpose:    Close the dialog
01781 //
01782 //  Arguments:
01783 //        None
01784 //
01785 //  Returns:    None
01786 //
01787 //  Notes:
01788 //
01789
01790 void CGenericUCPDlg::OnCloseClick()
01791 {
01792   EndDialog(1);
01793   return;
01794 }
01795
01796 //+---------------------------------------------------------------------------
01797 //
01798 //  Member:   iNumberOfInArguments
01799 //
01800 //  Purpose:    Calculate the number of arguments in action box
01801 //
01802 //  Arguments:
01803 //        tszString [in]  Arguments string
01804 //
01805 //  Returns:    None
01806 //
01807 //  Notes:
01808 //
01809
01810 int CGenericUCPDlg::iNumberOfInArguments(TCHAR *tszString)
01811 {
01812   int iCount = 0;
01813   TCHAR *token;
01814   token = _tcstok(tszString, _T(" "));
01815   while(token!=NULL){
01816     iCount++;
01817     token = _tcstok(NULL, _T(" "));
01818   }
01819   return iCount;
01820 }
01821
01822 ///////////////////////////////////////////////////////////////////
01823 //   CDeviceFinderCallback
01824 ///////////////////////////////////////////////////////////////////
01825
01826
01827 //+---------------------------------------------------------------------------
01828 //
01829 //  Member:   Create
01830 //
01831 //  Purpose:    Create the Device Finder callback object
01832 //
01833 //  Arguments:
01834 //        None
01835 //
01836 //  Returns:    None
01837 //
01838 //  Notes:    This is a static function
01839 //
01840
01841 CDeviceFinderCallback* CDeviceFinderCallback::Create()
01842 {
01843     CComObject<CDeviceFinderCallback> * pCallback = NULL;
01844     pCallback->CreateInstance(&pCallback);
01845     pCallback->GetUnknown()->AddRef();
01846     return pCallback;
01847 }
01848
01849 //+---------------------------------------------------------------------------
01850 //
01851 //  Member:   SetDialogPointer
01852 //
01853 //  Purpose:    Set the CGenericUCPDlg Dialog Pointer to call back
01854 //
01855 //  Arguments:
01856 //        None
01857 //
01858 //  Returns:    None
01859 //
01860 //  Notes:
01861 //
01862
01863 void CDeviceFinderCallback::SetDialogPointer(CGenericUCPDlg* pDialog){
01864   m_pGenericUCPDlg=pDialog;
01865 }
01866
01867 //+---------------------------------------------------------------------------
01868 //
01869 //  Member:   DeviceAdded
01870 //
01871 //  Purpose:    Called when a device is added
01872 //
01873 //  Arguments:
01874 //        lFindData [in]  AsyncFindHandle
01875 //        pDevice   [in]  COM interface pointer of the device being added
01876 //
01877 //  Returns:    S_OK
01878 //
01879 //  Notes:
01880 //
01881
01882 HRESULT CDeviceFinderCallback::DeviceAdded(
01883     LONG            lFindData,
01884     IUPnPDevice *   pDevice)
01885 {
01886   HRESULT HR = S_OK;
01887   TRACE(_T("Device Added\n"));
01888   m_pGenericUCPDlg->AddDevice(pDevice);
01889   return HR;
01890 }
01891
01892
01893 //+---------------------------------------------------------------------------
01894 //
01895 //  Member:   DeviceRemoved
01896 //
01897 //  Purpose:    Called when a device is removed
01898 //
01899 //  Arguments:
01900 //        lFindData [in]  AsyncFindHandle
01901 //        bstrUDN   [in]  UDN of the device being removed
01902 //
01903 //  Returns:    S_OK
01904 //
01905 //  Notes:
01906 //
01907
01908 HRESULT CDeviceFinderCallback::DeviceRemoved(
01909   LONG    lFindData,
01910     BSTR    bstrUDN)
01911 {
01912   TRACE(_T("Device Removed\n"));
01913   m_pGenericUCPDlg->RemoveDevice(bstrUDN);
01914   return S_OK;
01915 }
01916
01917
01918 //+---------------------------------------------------------------------------
01919 //
01920 //  Member:   SearchComplete
01921 //
01922 //  Purpose:    Called when the search is complete
01923 //
01924 //  Arguments:
01925 //        lFindData [in]  AsyncFindHandle
01926 //
01927 //  Returns:    S_OK
01928 //
01929 //  Notes:
01930 //
01931 HRESULT CDeviceFinderCallback::SearchComplete(
01932     LONG    lFindData)
01933 {
01934     TRACE(_T("Search Complete\n"));
01935   m_pGenericUCPDlg->m_StatusText.SetWindowText(_T("Device Search Completed"));
01936
01937   if(m_pGenericUCPDlg->m_DeviceCombo.GetCount()==0){
01938     m_pGenericUCPDlg->MessageBox(_T("Found no devices"));
01939   }
01940   return S_OK;
01941 }
01942
01943
01944
01945 ///////////////////////////////////////////////////////////////////
01946 //   CServiceCallback
01947 ///////////////////////////////////////////////////////////////////
01948
01949
01950
01951 //+---------------------------------------------------------------------------
01952 //
01953 //  Member:   Create
01954 //
01955 //  Purpose:    Create the Device Finder callback object
01956 //
01957 //  Arguments:
01958 //        None
01959 //
01960 //  Returns:    None
01961 //
01962 //  Notes:    This is a static function
01963 //
01964
01965 CServiceCallback* CServiceCallback::Create()
01966 {
01967     CComObject<CServiceCallback> * pCallback = NULL;
01968     pCallback->CreateInstance(&pCallback);
01969     pCallback->GetUnknown()->AddRef();
01970     return pCallback;
01971 }
01972
01973
01974 //+---------------------------------------------------------------------------
01975 //
01976 //  Member:   SetDialogPointer
01977 //
01978 //  Purpose:    Set the CGenericUCPDlg Dialog Pointer to call back
01979 //
01980 //  Arguments:
01981 //        None
01982 //
01983 //  Returns:    None
01984 //
01985 //  Notes:
01986 //
01987
01988 void CServiceCallback::SetDialogPointer(CGenericUCPDlg* pDialog){
01989   m_pGenericUCPDlg=pDialog;
01990 }
01991
01992 //+---------------------------------------------------------------------------
01993 //
01994 //  Member:   StateVariableChanged
01995 //
01996 //  Purpose:    Called when the state variable is changed
01997 //
01998 //  Arguments:
01999 //        pus         [in]  COM interface pointer of the service
02000 //        pcwszStateVarName [in]  State Variable Name
02001 //        varValue      [in]  State Variable Value
02002 //
02003 //  Returns:    HRESULT
02004 //
02005 //  Notes:
02006 //
02007
02008 HRESULT CServiceCallback::StateVariableChanged(
02009     IUPnPService *pus,
02010   LPCWSTR pcwszStateVarName,
02011   VARIANT varValue)
02012 {
02013   HRESULT hr = S_OK;
02014   TCHAR tszMessage[DATA_BUFSIZE];
02015   TRACE(_T("State Variable Changed\n"));
02016
02017   BSTR bstrServiceId = NULL;
02018   hr = pus->get_Id(&bstrServiceId);
02019   if(SUCCEEDED(hr)){
02020     TCHAR tszServiceId[DATA_BUFSIZE];
02021     _sntprintf(tszServiceId, DATA_BUFSIZE-1, _T("%S"), bstrServiceId);
02022     SysFreeString(bstrServiceId);
02023     hr=VariantChangeType(&varValue, &varValue, VARIANT_ALPHABOOL, VT_BSTR);
02024     if(SUCCEEDED(hr)){
02025       _sntprintf(tszMessage, DATA_BUFSIZE-1,_T("State variable %S changed to %S in %S"),pcwszStateVarName, varValue.bstrVal, bstrServiceId);
02026       Sleep(350);
02027       m_pGenericUCPDlg->m_EventText.SetWindowText(tszMessage);
02028     }
02029     else{
02030       PrintErrorText(hr);
02031     }
02032   }
02033   else{
02034     PrintErrorText(hr);
02035     m_pGenericUCPDlg->m_StatusText.SetWindowText(_T("Error: ServiceId failed"));
02036   }
02037   return hr;
02038 }
02039
02040
02041 //+---------------------------------------------------------------------------
02042 //
02043 //  Member:   ServiceInstanceDied
02044 //
02045 //  Purpose:    Called when the service dies
02046 //
02047 //  Arguments:
02048 //        pus         [in]  COM interface pointer of the service
02049 //
02050 //  Returns:    HRESULT
02051 //
02052 //  Notes:
02053 //
02054
02055 HRESULT CServiceCallback::ServiceInstanceDied(
02056   IUPnPService *pus)
02057 {
02058   HRESULT hr=S_OK;
02059   TCHAR tszMessage[DATA_BUFSIZE];
02060   TRACE(_T("Service instance died\n"));
02061
02062   BSTR bstrServiceId = NULL;
02063   hr = pus->get_Id(&bstrServiceId);
02064   if(SUCCEEDED(hr)){
02065     _sntprintf(tszMessage, DATA_BUFSIZE-1, _T("Service %S died"),bstrServiceId);
02066     m_pGenericUCPDlg->m_EventText.SetWindowText(tszMessage);
02067     SysFreeString(bstrServiceId);
02068   }
02069   else{
02070     PrintErrorText(hr);
02071     m_pGenericUCPDlg->m_StatusText.SetWindowText(_T("Error: ServiceId failed"));
02072   }
02073   return hr;
02074 }
02075
02076
02077 //+---------------------------------------------------------------------------
02078 //
02079 //  Member:   OnClose
02080 //
02081 //  Purpose:    Called when the dialog box closes
02082 //
02083 //  Arguments:
02084 //        None
02085 //
02086 //  Returns:    S_OK
02087 //
02088 //  Notes:
02089 //
02090
02091
02092 void CGenericUCPDlg::OnClose()
02093 {
02094   ClearAllDataStructures(TRUE);
02095   CDialog::OnClose();
02096 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/space.h Source File

  • SysMgmt
  • MMC
  • Openserv

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CRocket : public CDelegationBase {
00026 public:
00027     CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload);
00028     virtual ~CRocket();
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00033
00034 public:
00035     // virtual functions go here (for MMCN_*)
00036     virtual HRESULT OnRename(LPOLESTR pszNewName);
00037     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00038
00039     virtual HRESULT CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle);
00040     virtual HRESULT HasPropertySheets();
00041     virtual HRESULT GetWatermarks(HBITMAP *lphWatermark,
00042         HBITMAP *lphHeader,
00043         HPALETTE *lphPalette,
00044         BOOL *bStretch);
00045
00046 private:
00047     // {29743810-4C4B-11d2-89D8-000021473128}
00048     static const GUID thisGuid;
00049
00050     _TCHAR *szName;
00051     LONG   lWeight;
00052     LONG   lHeight;
00053     LONG   lPayload;
00054     int    nId;
00055     enum ROCKET_STATUS {RUNNING, PAUSED, STOPPED} iStatus;
00056
00057     static BOOL CALLBACK CRocket::DialogProc(
00058         HWND hwndDlg,  // handle to dialog box
00059         UINT uMsg,     // message
00060         WPARAM wParam, // first message parameter
00061         LPARAM lParam  // second message parameter
00062         );
00063
00064 };
00065
00066 class CSpaceVehicle : public CDelegationBase {
00067 public:
00068     CSpaceVehicle();
00069
00070     virtual ~CSpaceVehicle();
00071
00072     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00073     virtual const GUID & getNodeType() { return thisGuid; }
00074     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00075
00076 public:
00077     // virtual functions go here (for MMCN_*)
00078     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00079
00080 private:
00081     enum { IDM_NEW_SPACE = 4 };
00082
00083     // {29743810-4C4B-11d2-89D8-000021473128}
00084     static const GUID thisGuid;
00085
00086 private:
00087     enum { NUMBER_OF_CHILDREN = 4 };
00088     CRocket *children[NUMBER_OF_CHILDREN];
00089 };
00090
00091 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Title Member List

This is the complete list of members for Title, including all inherited members.
props | Title
ptext | Title
xpos | Title
ypos | Title
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/delebase.h Source File

  • SysMgmt
  • MMC
  • Openserv

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CDelegationBase {
00030 public:
00031     CDelegationBase();
00032     virtual ~CDelegationBase();
00033
00034     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00035     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00036
00037     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00038     virtual const int GetBitmapIndex() = 0;
00039     virtual const HANDLE GetHandle() { return m_handle; }
00040     virtual SetHandle(HANDLE handle) { m_handle = handle; }
00041
00042     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00043
00044 public:
00045     // virtual functions go here (for MMCN_*)
00046     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00047     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00048     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00049     virtual HRESULT OnRename(LPOLESTR pszNewName) { return S_FALSE; }
00050     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00051
00052     virtual HRESULT CreatePropertyPages(IPropertySheetCallback *lpProvider,
00053         LONG_PTR handle) { return S_FALSE; }
00054     virtual HRESULT HasPropertySheets() { return S_FALSE; }
00055     virtual HRESULT GetWatermarks(HBITMAP *lphWatermark,
00056         HBITMAP *lphHeader,
00057         HPALETTE *lphPalette,
00058         BOOL *bStretch) { return S_FALSE; }
00059
00060 public:
00061     static HBITMAP m_pBMapSm;
00062     static HBITMAP m_pBMapLg;
00063
00064 protected:
00065     static void LoadBitmaps() {
00066         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00067         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00068     }
00069
00070     BOOL bExpanded;
00071     HANDLE m_handle;
00072
00073 private:
00074     // {2974380B-4C4B-11d2-89D8-000021473128}
00075     static const GUID thisGuid;
00076 };
00077
00078 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/sky.h Source File

  • SysMgmt
  • MMC
  • Taskpads

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025 class CSkyBasedVehicle : public CDelegationBase {
00026 public:
00027     CSkyBasedVehicle() { }
00028
00029     virtual ~CSkyBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00034
00035 private:
00036     enum { IDM_NEW_SKY = 3 };
00037
00038     // {2974380F-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSmpFilterCF Member List

This is the complete list of members for CSmpFilterCF, including all inherited members.
AddRef() | CSmpFilterCF | [virtual]
CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject) | CSmpFilterCF | [virtual]
CSmpFilterCF() | CSmpFilterCF | [private]
DllGetClassObject(REFCLSID cid, REFIID iid, void **ppvObj) | CSmpFilterCF | [friend]
LockServer(BOOL fLock) | CSmpFilterCF | [virtual]
m_lRefs | CSmpFilterCF | [private]
QueryInterface(REFIID riid, void **ppvObject) | CSmpFilterCF | [virtual]
Release() | CSmpFilterCF | [virtual]
~CSmpFilterCF() | CSmpFilterCF | [private]
Generated on Wed Nov 13 2024 16:57:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Explore.VC/ConnectDlg.Cpp Source File

  • Com
  • Administration
  • Explore.VC

ConnectDlg.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018
00019 #include "stdafx.h"
00020 #include "VCExplore.h"
00021 #include "ConnectDlg.h"
00022
00023
00024 #ifdef _DEBUG
00025 #define new DEBUG_NEW
00026 #undef THIS_FILE
00027 static char THIS_FILE[] = __FILE__;
00028 #endif
00029
00030
00031
00032
00033 #define CONNECTION_TYPE_UNDEFINED -1
00034 #define CONNECTION_TYPE_LOCAL   0
00035 #define CONNECTION_TYPE_REMOTE    1
00036
00037
00038 /////////////////////////////////////////////////////////////////////////////
00039 // CConnectDlg dialog
00040
00041
00042 CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
00043   : CDialog(CConnectDlg::IDD, pParent)
00044 {
00045   //{{AFX_DATA_INIT(CConnectDlg)
00046     // NOTE: the ClassWizard will add member initialization here
00047   //}}AFX_DATA_INIT
00048
00049   // Load the dialogs icon resource
00050   m_hIcon = AfxGetApp()->LoadIcon(IDI_CONNECT);
00051
00052   // Initialize members
00053   m_pCatalog = NULL;
00054   m_pParentDlg = NULL;
00055   m_nConnectionType = CONNECTION_TYPE_UNDEFINED;
00056 }
00057
00058
00059 void CConnectDlg::DoDataExchange(CDataExchange* pDX)
00060 {
00061   CDialog::DoDataExchange(pDX);
00062   //{{AFX_DATA_MAP(CConnectDlg)
00063   DDX_Control(pDX, IDC_EDIT_REMOTE_COMPUTER_NAME, m_edtRemoteComputerName);
00064   //}}AFX_DATA_MAP
00065 }
00066
00067
00068 BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
00069   //{{AFX_MSG_MAP(CConnectDlg)
00070   ON_BN_CLICKED(IDC_RADIO_REMOTE_COMPUTER, OnRemoteComputer)
00071   ON_BN_CLICKED(IDC_RADIO_THIS_COMPUTER, OnLocalComputer)
00072   ON_WM_CLOSE()
00073   //}}AFX_MSG_MAP
00074 END_MESSAGE_MAP()
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // CConnectDlg message handlers
00078
00079 void CConnectDlg::set_Catalog(ICOMAdminCatalog* pCatalog)
00080 {
00081   // Only can have one Catalog object reference... release all prior references before assignment
00082   ReleaseCatalog();
00083
00084   // Assign the new Catalog reference
00085   m_pCatalog = pCatalog;
00086 }
00087
00088 void CConnectDlg::OnOK()
00089 {
00090   if (NULL != m_pCatalog)
00091   {
00092     ICatalogCollection* pRootCollection = NULL;
00093     HRESULT       hr = 0;
00094     _bstr_t       bstrInputValue = "";
00095
00096     // Get a reference to the "Root" collection depending upon the
00097     //  specified connection type
00098     switch (m_nConnectionType)
00099     {
00100     case CONNECTION_TYPE_LOCAL:
00101         bstrInputValue = "Root";
00102         hr = m_pCatalog->GetCollection(bstrInputValue,
00103                       (IDispatch**) &pRootCollection);
00104         bstrInputValue = "( Local )";
00105         break;
00106     case CONNECTION_TYPE_REMOTE:
00107         int nMaxLength = m_edtRemoteComputerName.GetWindowTextLength() + 1;
00108         char* pBuf = new char[nMaxLength];
00109         m_edtRemoteComputerName.GetWindowText(pBuf, nMaxLength);
00110         bstrInputValue = pBuf;
00111         delete [] pBuf;
00112         hr = m_pCatalog->Connect(bstrInputValue,
00113                     (IDispatch**) &pRootCollection);
00114         break;
00115     }
00116
00117     // Contine only if we successfully get a reference to the specified "Root" collection
00118     if SUCCEEDED(hr)
00119     {
00120       // Attempt assignment only if correctly setup
00121       if (NULL != m_pParentDlg)
00122       {
00123         // Increment the reference count on the object before we pass it
00124         //  back to the parent dialog
00125         pRootCollection->AddRef();
00126         // Set the new remote connection
00127         m_pParentDlg->set_CurrentCollection(pRootCollection);
00128         // Set the computer name
00129         m_pParentDlg->set_ComputerName(bstrInputValue);
00130         // Release the temporary object
00131         pRootCollection->Release();
00132       }
00133       else
00134         MessageBox("Invalid parent reference.\n\nYou must call CConnectDlg->set_ParentDlg() before attempting to execute ICatalog::Connect().\n\nPress OK to continue.",
00135               "Error",
00136               (MB_OK | MB_ICONERROR));
00137     }
00138     else
00139       MessageBox("Failed to connect to specified root collection.\n\nPress OK to continue.",
00140             "Error",
00141             (MB_OK | MB_ICONERROR));
00142   }
00143   else
00144     MessageBox("Invalid Catalog reference.\n\nNo processing will be performed.\n\nPress OK to continue.",
00145           "Error",
00146           (MB_OK | MB_ICONERROR));
00147
00148   // Release the reference to our Catalog object
00149   ReleaseCatalog();
00150
00151   CDialog::OnOK();
00152 }
00153
00154 void CConnectDlg::OnRemoteComputer()
00155 {
00156   // Enable the edit control
00157   ToggleEditControl(true);
00158 }
00159
00160 void CConnectDlg::OnLocalComputer()
00161 {
00162   // Clear and disable the edit control
00163   ToggleEditControl(false);
00164 }
00165
00166 BOOL CConnectDlg::OnInitDialog()
00167 {
00168   CDialog::OnInitDialog();
00169
00170   // Set the dialogs icon resource
00171   SetIcon(m_hIcon, true);   // 32x32 icon
00172   SetIcon(m_hIcon, false);  // 16x16 icon
00173
00174   // Select and set default connection type
00175   CheckRadioButton(IDC_RADIO_THIS_COMPUTER, IDC_RADIO_REMOTE_COMPUTER, IDC_RADIO_THIS_COMPUTER);
00176
00177   // Set the import type and description to match the current selection
00178   OnLocalComputer();
00179
00180   // Set the edit control to it's default state
00181   ToggleEditControl(false);
00182
00183   return TRUE;  // return TRUE unless you set the focus to a control
00184                 // EXCEPTION: OCX Property Pages should return FALSE
00185 }
00186
00187 void CConnectDlg::ToggleEditControl(bool Flag)
00188 {
00189   // Clear the control if we are disabling it
00190   if (Flag)
00191     m_nConnectionType = CONNECTION_TYPE_REMOTE;
00192   else
00193   {
00194     m_nConnectionType = CONNECTION_TYPE_LOCAL;
00195     m_edtRemoteComputerName.SetSel(0, -1, false);
00196     m_edtRemoteComputerName.Clear();
00197   }
00198
00199   // Toggle the control state
00200   m_edtRemoteComputerName.EnableWindow(Flag);
00201 }
00202
00203 void CConnectDlg::set_ParentDlg(CVCExploreDlg *pDlg)
00204 {
00205   m_pParentDlg = pDlg;
00206 }
00207
00208 void CConnectDlg::OnClose()
00209 {
00210   // Release the reference to the Catalog object if needed
00211   ReleaseCatalog();
00212
00213   CDialog::OnClose();
00214 }
00215
00216 void CConnectDlg::ReleaseCatalog()
00217 {
00218   // Release the reference to the Catalog object if needed
00219   if (NULL != m_pCatalog)
00220     m_pCatalog->Release();
00221 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventProvider/OleSrvr.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • EventProvider

OleSrvr.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 //
00004
00005 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00006 //
00007 // File:  OLESRVR.CPP
00008 //
00009 // Description:
00010 //      Event provider sample - COM server implementations
00011 //
00012 // History:
00013 //
00014 // **************************************************************************
00015
00016 #include <windows.h>
00017 #include <stdio.h>
00018 #include <time.h>
00019 #include <locale.h>
00020
00021 #include <wbemidl.h>
00022 #include <initguid.h>
00023
00024 #include "evprov.h"
00025
00026 #include <strsafe.h>
00027
00028 static HINSTANCE g_hInstance;
00029
00030 //***************************************************************************
00031 //
00032 //  DllMain
00033 //
00034 //***************************************************************************
00035
00036 BOOL WINAPI DllMain(
00037     HINSTANCE hinstDLL,
00038     DWORD dwReason,
00039     LPVOID lpReserved
00040     )
00041 {
00042     if (dwReason == DLL_PROCESS_ATTACH)
00043     {
00044         g_hInstance = hinstDLL;
00045         setlocale(LC_ALL, "");
00046     }
00047     else if (dwReason == DLL_PROCESS_DETACH)
00048     {
00049     }
00050
00051     return TRUE;
00052 }
00053
00054
00055
00056 //***************************************************************************
00057 //
00058 //  class CFactory
00059 //
00060 //***************************************************************************
00061
00062 class CFactory : public IClassFactory
00063 {
00064     ULONG           m_cRef;
00065     CLSID           m_ClsId;
00066
00067 public:
00068     CFactory(const CLSID & ClsId);
00069     ~CFactory();
00070
00071     //
00072     // IUnknown members
00073     //
00074     STDMETHODIMP         QueryInterface(REFIID, LPVOID *);
00075     STDMETHODIMP_(ULONG) AddRef(void);
00076     STDMETHODIMP_(ULONG) Release(void);
00077
00078     //
00079     // IClassFactory members
00080     //
00081     STDMETHODIMP     CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00082     STDMETHODIMP     LockServer(BOOL);
00083 };
00084
00085
00086
00087
00088 //***************************************************************************
00089 //
00090 // Count number of objects and number of locks on this DLL.
00091 //
00092 //***************************************************************************
00093
00094 static ULONG g_cObj = 0;
00095 static ULONG g_cLock = 0;
00096
00097
00098
00099 //***************************************************************************
00100 //
00101 //  DllGetClassObject
00102 //
00103 //***************************************************************************
00104
00105 extern "C"
00106 HRESULT APIENTRY DllGetClassObject(
00107     REFCLSID rclsid,
00108     REFIID riid,
00109     LPVOID * ppv
00110     )
00111 {
00112     HRESULT         hr;
00113
00114
00115     CFactory *pFactory;
00116
00117     //
00118     //  Verify the caller is asking for our type of object.
00119     //
00120     if (CLSID_MyEventProvider != rclsid)
00121             return E_FAIL;
00122
00123     //
00124     // Check that we can provide the interface.
00125     //
00126     if (IID_IUnknown != riid && IID_IClassFactory != riid)
00127         return E_NOINTERFACE;
00128
00129     //
00130     // Get a new class factory.
00131     //
00132     pFactory = new CFactory(rclsid);
00133
00134     if (!pFactory)
00135         return E_OUTOFMEMORY;
00136
00137     //
00138     // Verify we can get an instance.
00139     //
00140     hr = pFactory->QueryInterface(riid, ppv);
00141
00142     if (FAILED(hr))
00143         delete pFactory;
00144
00145     return hr;
00146 }
00147
00148 //***************************************************************************
00149 //
00150 //  DllCanUnloadNow
00151 //
00152 //***************************************************************************
00153 extern "C"
00154 HRESULT APIENTRY DllCanUnloadNow(void)
00155 {
00156     SCODE sc = TRUE;
00157
00158     if (g_cObj || g_cLock)
00159         sc = S_FALSE;
00160
00161     return sc;
00162 }
00163
00164 //***************************************************************************
00165 //
00166 //***************************************************************************
00167
00168 void ObjectCreated(DWORD dwType)
00169 {
00170     InterlockedIncrement((LONG *) &g_cObj);
00171 }
00172
00173 void ObjectDestroyed(DWORD dwType)
00174 {
00175     InterlockedDecrement((LONG *) &g_cObj);
00176 }
00177
00178
00179 //***************************************************************************
00180 //
00181 //  CFactory::CFactory
00182 //
00183 //***************************************************************************
00184
00185 CFactory::CFactory(const CLSID & ClsId)
00186 {
00187     m_cRef = 0;
00188     m_ClsId = ClsId;
00189     ObjectCreated(0);
00190 }
00191
00192 //***************************************************************************
00193 //
00194 //  CFactory::~CFactory
00195 //
00196 //***************************************************************************
00197
00198 CFactory::~CFactory()
00199 {
00200     // nothing
00201     ObjectDestroyed(0);
00202 }
00203
00204 //***************************************************************************
00205 //
00206 //  CFactory::QueryInterface, AddRef and Release
00207 //
00208 //***************************************************************************
00209
00210 STDMETHODIMP CFactory::QueryInterface(REFIID riid, LPVOID * ppv)
00211 {
00212     *ppv = 0;
00213
00214     if (IID_IUnknown==riid || IID_IClassFactory==riid)
00215     {
00216         *ppv = this;
00217         AddRef();
00218         return NOERROR;
00219     }
00220
00221     return E_NOINTERFACE;
00222 }
00223
00224
00225 ULONG CFactory::AddRef()
00226 {
00227     return ++m_cRef;
00228 }
00229
00230
00231 ULONG CFactory::Release()
00232 {
00233     if (0 != --m_cRef)
00234         return m_cRef;
00235     delete this;
00236     return 0;
00237 }
00238
00239 //***************************************************************************
00240 //
00241 //  CFactory::CreateInstance
00242 //
00243 //***************************************************************************
00244
00245 STDMETHODIMP CFactory::CreateInstance(
00246     LPUNKNOWN pUnkOuter,
00247     REFIID riid,
00248     LPVOID * ppvObj)
00249 {
00250     IUnknown* pObj;
00251     HRESULT  hr;
00252
00253     //
00254     //  Defaults
00255     //
00256     *ppvObj=NULL;
00257     hr = E_OUTOFMEMORY;
00258
00259     //
00260     // We aren't supporting aggregation.
00261     //
00262     if (pUnkOuter)
00263         return CLASS_E_NOAGGREGATION;
00264
00265     if (m_ClsId == CLSID_MyEventProvider)
00266     {
00267         pObj = (IWbemProviderInit *) new CMyEventProvider;
00268     }
00269
00270     if (!pObj)
00271         return hr;
00272
00273     //
00274     //  Initialize the object and verify that it can return the
00275     //  interface in question.
00276     //
00277     hr = pObj->QueryInterface(riid, ppvObj);
00278
00279     //
00280     // Kill the object if initial creation or Init failed.
00281     //
00282     if (FAILED(hr))
00283         delete pObj;
00284
00285     return hr;
00286 }
00287
00288 //***************************************************************************
00289 //
00290 //***************************************************************************
00291
00292 STDMETHODIMP CFactory::LockServer(BOOL fLock)
00293 {
00294     if (fLock)
00295         InterlockedIncrement((LONG *) &g_cLock);
00296     else
00297         InterlockedDecrement((LONG *) &g_cLock);
00298
00299     return NOERROR;
00300 }
00301
00302
00303
00304
00305 //***************************************************************************
00306 //
00307 //  DllRegisterServer
00308 //
00309 //  Standard OLE entry point for registering the server.
00310 //
00311 //  RETURN VALUES:
00312 //
00313 //      S_OK        Registration was successful
00314 //      E_FAIL      Registration failed.
00315 //
00316 //***************************************************************************
00317
00318 extern "C"
00319 HRESULT APIENTRY DllRegisterServer(void)
00320 {
00321     wchar_t Path[MAX_PATH + 1];
00322     wchar_t *pGuidStr = 0;
00323     wchar_t KeyPath[1024];
00324
00325     // Where are we?
00326     // =============
00327   memset (Path, NULL, sizeof(Path));
00328     GetModuleFileNameW(g_hInstance, Path, sizeof(Path)/sizeof(wchar_t) - 1);
00329
00330     // Convert CLSID to string.
00331     // ========================
00332
00333     StringFromCLSID(CLSID_MyEventProvider, &pGuidStr);
00334   StringCbPrintfW(KeyPath, sizeof(KeyPath), L"CLSID\\\\%s", pGuidStr);
00335
00336
00337     HKEY hKey;
00338   LONG lRes = RegCreateKeyExW( HKEY_CLASSES_ROOT, KeyPath, 0, NULL,
00339                     REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
00340                     &hKey, NULL );
00341     if (lRes)
00342         return E_FAIL;
00343
00344     wchar_t *pName = L"WMI Sample Event Provider";
00345     RegSetValueExW(hKey, 0, 0, REG_SZ, (const BYTE *) pName,
00346     (DWORD)(wcslen(pName) * sizeof(wchar_t) + sizeof(wchar_t)));
00347
00348     HKEY hSubkey;
00349   lRes = RegCreateKeyExW( hKey, L"InprocServer32", 0, NULL,
00350                     REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
00351                     &hSubkey, NULL );
00352   if (lRes)
00353         return E_FAIL;
00354
00355     RegSetValueExW(hSubkey, 0, 0, REG_SZ, (const BYTE *) Path,
00356     (DWORD)(wcslen(Path) * sizeof(wchar_t) + sizeof(wchar_t)));
00357     RegSetValueExW(hSubkey, L"ThreadingModel", 0, REG_SZ, (const BYTE *) L"Both",
00358     (DWORD)(wcslen(L"Both") * sizeof(wchar_t) + sizeof(wchar_t)));
00359
00360
00361     RegCloseKey(hSubkey);
00362     RegCloseKey(hKey);
00363
00364     CoTaskMemFree(pGuidStr);
00365
00366     return S_OK;
00367 }
00368
00369 //***************************************************************************
00370 //
00371 //  DllUnregisterServer
00372 //
00373 //  Standard OLE entry point for unregistering the server.
00374 //
00375 //  RETURN VALUES:
00376 //
00377 //      S_OK        Unregistration was successful
00378 //      E_FAIL      Unregistration failed.
00379 //
00380 //***************************************************************************
00381
00382 extern "C"
00383 HRESULT APIENTRY DllUnregisterServer(void)
00384 {
00385     wchar_t *pGuidStr = 0;
00386     HKEY hKey;
00387     wchar_t KeyPath[256];
00388
00389     StringFromCLSID(CLSID_MyEventProvider, &pGuidStr);
00390   StringCbPrintfW(KeyPath, sizeof(KeyPath), L"CLSID\\%s", pGuidStr);
00391
00392     // Delete InProcServer32 subkey.
00393     // =============================
00394     LONG lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, KeyPath, 0, KEY_WRITE, &hKey);
00395     if (lRes)
00396         return E_FAIL;
00397
00398     RegDeleteKeyW(hKey, L"InprocServer32");
00399     RegCloseKey(hKey);
00400
00401     // Delete CLSID GUID key.
00402     // ======================
00403
00404     lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hKey);
00405     if (lRes)
00406         return E_FAIL;
00407
00408     RegDeleteKeyW(hKey, pGuidStr);
00409     RegCloseKey(hKey);
00410
00411     CoTaskMemFree(pGuidStr);
00412
00413     return S_OK;
00414 }
00415
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcAnim.h Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcAnim.h

Go to the documentation of this file.
00001 #if !defined(AFX_AGENTCTLANIMATIONNAMES_H__AB8FEBA9_3841_11D2_8512_00C04FA34A14__INCLUDED_)
00002 #define AFX_AGENTCTLANIMATIONNAMES_H__AB8FEBA9_3841_11D2_8512_00C04FA34A14__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00008
00009 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00010 //  Microsoft Visual C++, your modifications will be overwritten.
00011
00012 /////////////////////////////////////////////////////////////////////////////
00013 // CAgentCtlAnimationNames wrapper class
00014
00015 class CAgentCtlAnimationNames : public COleDispatchDriver
00016 {
00017 public:
00018   CAgentCtlAnimationNames() {}    // Calls COleDispatchDriver default constructor
00019   CAgentCtlAnimationNames(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
00020   CAgentCtlAnimationNames(const CAgentCtlAnimationNames& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
00021
00022 // Attributes
00023 public:
00024
00025 // Operations
00026 public:
00027 };
00028
00029 //{{AFX_INSERT_LOCATION}}
00030 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00031
00032 #endif // !defined(AFX_AGENTCTLANIMATIONNAMES_H__AB8FEBA9_3841_11D2_8512_00C04FA34A14__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/MultiUI/MultiWnd.C Source File

  • WinUI
  • Input
  • Ime
  • MultiUI

MultiWnd.C

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      MULTIWND.C                                                    */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation              */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #include <windows.h>
00010 #include <Commdlg.h>
00011 #include <imm.h>
00012 #include <tchar.h>
00013 #include "resource.h"
00014 #include "multiui.h"
00015
00016
00017 /**********************************************************************/
00018 /*                                                                    */
00019 /*    InitStringBuffer (HWND)                                         */
00020 /*                                                                    */
00021 /**********************************************************************/
00022 DWORD InitStringBuffer (
00023     HWND hWnd )
00024 {
00025     DWORD error = ERROR_SUCCESS;
00026     PTSTR pStr = NULL;
00027
00028     pStr = GlobalAlloc (GPTR, MAXSIZE_STR * sizeof(TCHAR));
00029     if (NULL == pStr)
00030     {
00031         error = GetLastError ();
00032     }
00033
00034     if (0 == SetWindowLongPtr(hWnd, MYGWL_STR, (LONG_PTR)pStr))
00035     {
00036         error = GetLastError ();
00037     }
00038
00039     return error;
00040 }
00041
00042 /**********************************************************************/
00043 /*                                                                    */
00044 /*    DestroyStringBuffer (HWND)                                      */
00045 /*                                                                    */
00046 /**********************************************************************/
00047 DWORD DestroyStringBuffer (
00048     HWND hWnd )
00049 {
00050     DWORD error = ERROR_SUCCESS;
00051     PTSTR pStr = NULL;
00052
00053     pStr = (PTSTR)GetWindowLongPtr(hWnd, MYGWL_STR);
00054     if (pStr)
00055     {
00056         GlobalFree((HANDLE)pStr);
00057     }
00058     else
00059     {
00060         error = GetLastError ();
00061     }
00062
00063     return error;
00064 }
00065
00066 /**********************************************************************/
00067 /*                                                                    */
00068 /*    MyDrawString (HWND, WPARAM, LPARAM)                             */
00069 /*                                                                    */
00070 /**********************************************************************/
00071 DWORD MyDrawString (
00072     HWND hWnd,
00073     WPARAM wParam,
00074     LPARAM lParam)
00075 {
00076     DWORD       error    = ERROR_SUCCESS;
00077     PTSTR       pStr     = NULL;
00078     HDC         hDC      = NULL;
00079     PAINTSTRUCT ps       = {0};
00080     HFONT       hOldFont = NULL;
00081     HFONT       hFont    = NULL;
00082     DWORD       dwHeight = 0;
00083     TEXTMETRIC  tm       = {0};
00084     RECT        rc       = {0};
00085
00086     pStr = (PTSTR)GetWindowLongPtr(hWnd, MYGWL_STR);
00087     if (!pStr)
00088     {
00089         error = GetLastError ();
00090         goto exit_func;
00091     }
00092
00093     hFont = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00094     if (!hFont)
00095     {
00096         error = GetLastError ();
00097         goto exit_func;
00098     }
00099
00100
00101     hDC = BeginPaint(hWnd, &ps);
00102     hOldFont = SelectObject(hDC, hFont);
00103
00104     pStr = (PTSTR)GetWindowLongPtr(hWnd, MYGWL_STR);
00105     // Get dwHeight.
00106     GetTextMetrics(hDC,&tm);
00107     dwHeight = tm.tmHeight + tm.tmExternalLeading;
00108
00109
00110     GetClientRect(hWnd,&rc);
00111     rc.bottom -= dwHeight;
00112
00113     DrawText(hDC, pStr, -1, &rc, DT_LEFT | DT_WORDBREAK);
00114
00115     SelectObject(hDC, hOldFont);
00116     EndPaint(hWnd, &ps);
00117
00118 exit_func:
00119     return error;
00120 }
00121
00122 /**********************************************************************/
00123 /*                                                                    */
00124 /*    MySetCompositionFont (HWND)                                     */
00125 /*                                                                    */
00126 /**********************************************************************/
00127 void MySetCompositionFont (
00128     HWND hWnd)
00129 {
00130     HIMC hIMC;
00131
00132     if (hIMC = ImmGetContext(hWnd))
00133     {
00134         LOGFONT lf;
00135         HFONT   hFont = (HFONT)GetWindowLongPtr(hWnd, MYGWL_FONT);
00136         GetObject(hFont, sizeof(lf), &lf);
00137
00138         ImmSetCompositionFont(hIMC, &lf);
00139         ImmReleaseContext(hWnd, hIMC);
00140     }
00141 }
00142
00143 /**********************************************************************/
00144 /*                                                                    */
00145 /*    MySetCompositionForm (HWND)                                     */
00146 /*                                                                    */
00147 /**********************************************************************/
00148 DWORD MySetCompositionForm (
00149     HWND hWnd)
00150 {
00151     DWORD           error    = ERROR_SUCCESS;
00152     RECT            rc       = {0};
00153     HIMC            hIMC     = NULL;
00154     HDC             hDC      = NULL;
00155     TEXTMETRIC      tm       = {0};
00156     DWORD           dwHeight = 0;
00157     HFONT           hFont    = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00158     HFONT           hOldFont = NULL;
00159     COMPOSITIONFORM CompForm = {0};
00160
00161     if (!hFont)
00162     {
00163         error = GetLastError ();
00164         goto exit_func;
00165     }
00166
00167     if (hIMC = ImmGetContext(hWnd))
00168     {
00169         // Get dwHeight.
00170         hDC = GetDC(hWnd);
00171         hOldFont = SelectObject(hDC, hFont);
00172         GetTextMetrics(hDC,&tm);
00173         dwHeight = tm.tmHeight + tm.tmExternalLeading;
00174         SelectObject(hDC, hOldFont);
00175         ReleaseDC(hWnd,hDC);
00176
00177
00178         GetClientRect(hWnd,&rc);
00179         CompForm.dwStyle = CFS_POINT;
00180         CompForm.ptCurrentPos.x = rc.left;
00181         CompForm.ptCurrentPos.y = rc.bottom - dwHeight;
00182         ImmSetCompositionWindow(hIMC,&CompForm);
00183
00184         ImmReleaseContext(hWnd, hIMC);
00185     }
00186
00187 exit_func:
00188     return error;
00189 }
00190
00191 /**********************************************************************/
00192 /*                                                                    */
00193 /*    MyChangeFont (HWND)                                             */
00194 /*                                                                    */
00195 /**********************************************************************/
00196 void MyChangeFont (
00197     HWND hWnd)
00198 {
00199     LOGFONT    lf    = {0};
00200     CHOOSEFONT cf    = {0};
00201     HFONT      hFont = NULL;
00202
00203     /* Set all structure fields to zero. */
00204     memset(&cf, 0, sizeof(CHOOSEFONT));
00205
00206     cf.lStructSize = sizeof(CHOOSEFONT);
00207     cf.hwndOwner = hWnd;
00208     cf.lpLogFont = &lf;
00209     cf.Flags = CF_SCREENFONTS | CF_EFFECTS;
00210     cf.rgbColors = RGB(0, 255, 255); /* light blue */
00211     cf.nFontType = SCREEN_FONTTYPE;
00212
00213     if (ChooseFont(&cf))
00214     {
00215         hFont = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00216         DeleteObject(hFont);
00217
00218         hFont = CreateFontIndirect(&lf);
00219         SetWindowLongPtr(hWnd,MYGWL_FONT,(LONG_PTR)hFont);
00220         MySetCompositionForm(hWnd);
00221         MySetCompositionFont(hWnd);
00222     }
00223     SetFocus(hWnd);
00224 }
00225
00226 /**********************************************************************/
00227 /*                                                                    */
00228 /*    GetDefaultGUIFont (VOID)                                        */
00229 /*                                                                    */
00230 /**********************************************************************/
00231 HFONT GetDefaultGUIFont (
00232     VOID)
00233 {
00234     static HFONT hFont;
00235     OSVERSIONINFO VerInfo = {0};
00236
00237     if (hFont)
00238     {
00239         return hFont;
00240     }
00241
00242     VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00243     GetVersionEx(&VerInfo);
00244
00245     if (VerInfo.dwMajorVersion < 4)
00246     {
00247         NONCLIENTMETRICS ncm = {0};
00248
00249         ncm.cbSize = sizeof(NONCLIENTMETRICS);
00250         SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
00251         hFont = CreateFontIndirect(&ncm.lfStatusFont);
00252
00253         if (!hFont)
00254         {
00255             hFont = GetStockObject(SYSTEM_FONT);
00256         }
00257     }
00258     else
00259     {
00260         hFont = GetStockObject(DEFAULT_GUI_FONT);
00261     }
00262
00263     return hFont;
00264 }
00265
00266 /**********************************************************************/
00267 /*                                                                    */
00268 /*    OverFlowText (HWND, PTSTR, PTSTR)                               */
00269 /*                                                                    */
00270 /**********************************************************************/
00271 BOOL OverFlowText (
00272     HWND hWnd,
00273     PTSTR pStr,
00274     PTSTR pResultStr)
00275 {
00276     BOOL        bRet     = FALSE;
00277     RECT        rc       = {0};
00278     HDC         hDC      = NULL;
00279     TEXTMETRIC  tm       = {0};
00280     int         nHeight  = 0;
00281     HFONT       hFont    = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00282     HFONT       hOldFont = NULL;
00283     PTSTR       pTempStr = NULL;
00284
00285     if (!hFont)
00286     {
00287         return FALSE;
00288     }
00289
00290     if (_tcsclen(pStr) + _tcsclen(pResultStr) > MAXSIZE_STR)
00291     {
00292         bRet = TRUE;
00293     }
00294     else
00295     {
00296         pTempStr = GlobalAlloc(GPTR, MAXSIZE_STR * sizeof(TCHAR));
00297
00298         if (pTempStr)
00299         {
00300             _tcsncpy(pTempStr, pStr, MAXSIZE_STR - 1);
00301             _tcsncat(pTempStr, pResultStr, min(MAXSIZE_STR - _tcslen(pTempStr) - 1, _tcslen(pResultStr)));
00302
00303             GetClientRect(hWnd,&rc);
00304
00305             hDC = GetDC(hWnd);
00306             hOldFont = SelectObject(hDC, hFont);
00307             GetTextMetrics(hDC,&tm);
00308
00309             rc.bottom -= tm.tmHeight + tm.tmExternalLeading;
00310             nHeight = rc.bottom;
00311
00312             if (nHeight < DrawText(hDC, pTempStr, -1, &rc, DT_LEFT | DT_WORDBREAK | DT_CALCRECT))
00313             {
00314                 bRet = TRUE;
00315             }
00316
00317             SelectObject(hDC, hOldFont);
00318             ReleaseDC(hWnd,hDC);
00319
00320             GlobalFree((HANDLE)pTempStr);
00321         }
00322     }
00323
00324
00325     return bRet;
00326 }
00327
00328 /**********************************************************************/
00329 /*                                                                    */
00330 /*    AddResultString (HWND)                                          */
00331 /*                                                                    */
00332 /**********************************************************************/
00333 void AddResultString(
00334     HWND hWnd)
00335 {
00336     HIMC  hIMC       = NULL;
00337     DWORD dwLen      = 0;
00338     PTSTR pStr       = NULL;
00339     PTSTR pResultStr = NULL;
00340
00341     pStr = (PTSTR)GetWindowLongPtr(hWnd, MYGWL_STR);
00342
00343     hIMC = ImmGetContext(hWnd);
00344
00345     if (!hIMC)
00346     {
00347         return;
00348     }
00349
00350     dwLen = ImmGetCompositionString(hIMC,GCS_RESULTSTR,NULL,0L);
00351
00352     if (dwLen)
00353     {
00354         pResultStr = GlobalAlloc(GPTR, dwLen + 1);
00355
00356         if (pResultStr)
00357         {
00358             ImmGetCompositionString(hIMC, GCS_RESULTSTR,
00359                                     pResultStr,dwLen+1);
00360
00361             if (OverFlowText(hWnd, pStr, pResultStr))
00362             {
00363                 _tcsncpy(pStr, pResultStr, MAXSIZE_STR - 1);
00364             }
00365             else
00366             {
00367                 _tcsncat(pStr, pResultStr, min(MAXSIZE_STR - _tcslen(pStr) - 1, _tcslen(pResultStr)));
00368             }
00369
00370             InvalidateRect(hWnd,NULL,TRUE);
00371
00372             GlobalFree((HANDLE)pResultStr);
00373         }
00374     }
00375
00376     ImmReleaseContext(hWnd,hIMC);
00377
00378 }
00379
00380 /**********************************************************************/
00381 /*                                                                    */
00382 /*    NoUINoIMCWndProc (HWND, UINT, WPARAM, LPARAM)                   */
00383 /*                                                                    */
00384 /**********************************************************************/
00385 LRESULT CALLBACK  NoUINoIMCWndProc (
00386     HWND hWnd,
00387     UINT message,
00388     WPARAM wParam,
00389     LPARAM lParam)
00390 {
00391     HFONT hFont = NULL;
00392     BOOL bRetDWP = FALSE;
00393
00394     switch (message)
00395     {
00396         case WM_CREATE:
00397             hFont = GetDefaultGUIFont();
00398             SetWindowLongPtr(hWnd,MYGWL_FONT,(LONG_PTR)hFont);
00399             InitStringBuffer(hWnd);
00400             break;
00401
00402         case WM_LBUTTONDBLCLK:
00403             MyChangeFont(hWnd);
00404             break;
00405
00406         case WM_LBUTTONDOWN:
00407             SetFocus(hWnd);
00408             break;
00409
00410         case WM_SETFOCUS:
00411             MySetCompositionFont(hWnd);
00412             MySetCompositionForm(hWnd);
00413             break;
00414
00415         case WM_IME_COMPOSITION:
00416             if (lParam & GCS_RESULTSTR)
00417             {
00418                 AddResultString(hWnd);
00419             }
00420             bRetDWP = TRUE;
00421             break;
00422
00423         case WM_SIZE:
00424             switch (wParam)
00425             {
00426                 case SIZENORMAL: /* fall-through */
00427                 case SIZEFULLSCREEN:
00428                     if (hWnd == GetFocus())
00429                     {
00430                         MySetCompositionForm(hWnd);
00431                     }
00432                     InvalidateRect(hWnd,NULL,TRUE);
00433                     break;
00434
00435
00436                 case SIZEICONIC:
00437                     bRetDWP = TRUE;
00438                     break;
00439             }
00440             break;
00441
00442
00443         case WM_PAINT:
00444             MyDrawString(hWnd,wParam,lParam);
00445             break;
00446
00447         case WM_DESTROY:
00448             hFont = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00449             DeleteObject(hFont);
00450             DestroyStringBuffer(hWnd);
00451             break;
00452
00453         default:
00454             bRetDWP = TRUE;
00455             break;
00456     }
00457
00458     if (bRetDWP)
00459     {
00460         return DefWindowProc(hWnd, message, wParam, lParam);
00461     }
00462     else
00463     {
00464         return 0;
00465     }
00466 }
00467
00468 /**********************************************************************/
00469 /*                                                                    */
00470 /*    NoUIOwnIMCWndProc (HWND, UINT, WPARAM, LPARAM)                  */
00471 /*                                                                    */
00472 /**********************************************************************/
00473 LRESULT CALLBACK NoUIOwnIMCWndProc (
00474     HWND hWnd,
00475     UINT message,
00476     WPARAM wParam,
00477     LPARAM lParam)
00478 {
00479     HIMC  hIMC    = NULL;
00480     HFONT hFont   = NULL;
00481     BOOL  bRetDWP = FALSE;
00482
00483     switch (message)
00484     {
00485         case WM_CREATE:
00486             hFont = GetDefaultGUIFont();
00487             SetWindowLongPtr(hWnd,MYGWL_FONT,(LONG_PTR)hFont);
00488
00489             hIMC = ImmCreateContext();
00490             ImmAssociateContext(hWnd,hIMC);
00491
00492             // Save hIMC into WndExtra.
00493             SetWindowLongPtr(hWnd,MYGWL_IMC,(LONG_PTR)hIMC);
00494
00495             MySetCompositionFont(hWnd);
00496             MySetCompositionForm(hWnd);
00497
00498             InitStringBuffer(hWnd);
00499             break;
00500
00501         case WM_LBUTTONDBLCLK:
00502             MyChangeFont(hWnd);
00503             break;
00504
00505         case WM_LBUTTONDOWN:
00506             SetFocus(hWnd);
00507             break;
00508
00509         case WM_IME_COMPOSITION:
00510             if (lParam & GCS_RESULTSTR)
00511             {
00512                 AddResultString(hWnd);
00513             }
00514             bRetDWP = TRUE;
00515             break;
00516
00517         case WM_SIZE:
00518             switch (wParam)
00519             {
00520                 case SIZENORMAL: /* fall-through */
00521                 case SIZEFULLSCREEN:
00522                     MySetCompositionForm(hWnd);
00523                     InvalidateRect(hWnd,NULL,TRUE);
00524                     break;
00525
00526                 case SIZEICONIC:
00527                     bRetDWP = TRUE;
00528                     break;
00529             }
00530             break;
00531
00532         case WM_PAINT:
00533             MyDrawString(hWnd,wParam,lParam);
00534             break;
00535
00536         case WM_DESTROY:
00537             hFont = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00538             DeleteObject(hFont);
00539
00540             hIMC = (HIMC)GetWindowLongPtr(hWnd,MYGWL_IMC);
00541             ImmDestroyContext(hIMC);
00542
00543             DestroyStringBuffer(hWnd);
00544             break;
00545
00546         default:
00547             bRetDWP = TRUE;
00548             break;
00549     }
00550
00551
00552     if (bRetDWP)
00553     {
00554         return DefWindowProc(hWnd, message, wParam, lParam);
00555     }
00556     else
00557     {
00558         return 0;
00559     }
00560 }
00561
00562 /**********************************************************************/
00563 /*                                                                    */
00564 /*    OwnUIOwnIMCWndProc (HWND, UINT, WPARAM, LPARAM)                 */
00565 /*                                                                    */
00566 /**********************************************************************/
00567 LRESULT CALLBACK OwnUIOwnIMCWndProc (
00568     HWND hWnd,
00569     UINT message,
00570     WPARAM wParam,
00571     LPARAM lParam)
00572 {
00573     HFONT hFont   = NULL;
00574     HIMC  hIMC    = 0L;
00575     HWND  hIMEWnd = (HWND)GetWindowLongPtr(hWnd,MYGWL_IMEWND);
00576     BOOL  bRetDWP = FALSE;
00577
00578
00579
00580     if (IsWindow(hIMEWnd) && ImmIsUIMessage(hIMEWnd,message,wParam,lParam))
00581     {
00582         switch (message)
00583         {
00584             case WM_IME_COMPOSITION:
00585                 if (lParam & GCS_RESULTSTR)
00586                 {
00587                     AddResultString(hWnd);
00588                 }
00589                 break;
00590
00591             default:
00592                 break;
00593         }
00594
00595         goto exit_func;
00596     }
00597
00598     switch (message)
00599     {
00600         case WM_CREATE:
00601             hFont = GetDefaultGUIFont();
00602             SetWindowLongPtr(hWnd,MYGWL_FONT,(LONG_PTR)hFont);
00603
00604             hIMC = ImmCreateContext();
00605             ImmAssociateContext(hWnd,hIMC);
00606
00607             // Save hIMC into WndExtra.
00608             SetWindowLongPtr(hWnd,MYGWL_IMC,(LONG_PTR)hIMC);
00609
00610             if (!(hIMEWnd = CreateWindow(
00611                             TEXT("Ime"), TEXT(""),
00612                             WS_POPUP | WS_DISABLED,
00613                             0,0,0,0,
00614                             hWnd, NULL, hInst, NULL)))
00615             {
00616               return -1;
00617             }
00618
00619             // Save hIMEWnd into WndExtra.
00620             SetWindowLongPtr(hWnd,MYGWL_IMEWND,(LONG_PTR)hIMEWnd);
00621
00622             MySetCompositionFont(hWnd);
00623             MySetCompositionForm(hWnd);
00624
00625             InitStringBuffer(hWnd);
00626             break;
00627
00628         case WM_LBUTTONDBLCLK:
00629             MyChangeFont(hWnd);
00630             break;
00631
00632         case WM_LBUTTONDOWN:
00633             SetFocus(hWnd);
00634             break;
00635
00636         case WM_SIZE:
00637             switch (wParam)
00638             {
00639                 case SIZENORMAL: /* fall-through */
00640                 case SIZEFULLSCREEN:
00641                     MySetCompositionForm(hWnd);
00642                     InvalidateRect(hWnd,NULL,TRUE);
00643                     break;
00644
00645                 case SIZEICONIC:
00646                     bRetDWP = TRUE;
00647                     break;
00648             }
00649             break;
00650
00651         case WM_PAINT:
00652             MyDrawString(hWnd,wParam,lParam);
00653             break;
00654
00655         case WM_DESTROY:
00656             hFont = (HFONT)GetWindowLongPtr(hWnd,MYGWL_FONT);
00657             DeleteObject(hFont);
00658
00659             hIMC = (HIMC)GetWindowLongPtr(hWnd,MYGWL_IMC);
00660             ImmDestroyContext(hIMC);
00661
00662             DestroyStringBuffer(hWnd);
00663             break;
00664
00665         default:
00666             bRetDWP = TRUE;
00667             break;
00668     }
00669
00670 exit_func:
00671     if (bRetDWP)
00672     {
00673         return DefWindowProc(hWnd, message, wParam, lParam);
00674     }
00675     else
00676     {
00677         return 0;
00678     }
00679 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/about.h Source File

  • SysMgmt
  • MMC
  • Nodes

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/ias.Cpp Source File

  • Com
  • Fundamentals
  • SimpCntr

ias.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IAS.CPP
00003 //
00004 //      Implementation file of CAdviseSink
00005 //
00006 //
00007 // Functions:
00008 //
00009 //      See IAS.H for Class Definition
00010 //
00011 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00012 //**********************************************************************
00013
00014 #include "pre.h"
00015 #include "iocs.h"
00016 #include "ias.h"
00017 #include "ioipf.h"
00018 #include "ioips.h"
00019 #include "app.h"
00020 #include "site.h"
00021 #include "doc.h"
00022
00023 //**********************************************************************
00024 //
00025 // CAdviseSink::QueryInterface
00026 //
00027 // Purpose:
00028 //
00029 //      Returns a pointer to a requested interface.
00030 //
00031 // Parameters:
00032 //
00033 //      REFIID riid         - The requested interface
00034 //
00035 //      LPVOID FAR* ppvObj  - Place to return the interface
00036 //
00037 // Return Value:
00038 //
00039 //      HRESULT from CSimpleSite::QueryInterface
00040 //
00041 // Function Calls:
00042 //      Function                    Location
00043 //
00044 //      CSimpleSite::QueryInterface SITE.CPP
00045 //      OutputDebugString           Windows API
00046 //
00047 // Comments:
00048 //
00049 //      This function simply delegates to the Object class, which is
00050 //      aware of the supported interfaces.
00051 //
00052 //********************************************************************
00053
00054 STDMETHODIMP CAdviseSink::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00055 {
00056         OutputDebugString("In IAS::QueryInterface\r\n");
00057
00058         // delegate to the document Object
00059         return m_pSite->QueryInterface(riid, ppvObj);
00060 }
00061
00062 //**********************************************************************
00063 //
00064 // CAdviseSink::AddRef
00065 //
00066 // Purpose:
00067 //
00068 //      Increments the reference count on this interface
00069 //
00070 // Parameters:
00071 //
00072 //      None
00073 //
00074 // Return Value:
00075 //
00076 //      The current reference count on this interface.
00077 //
00078 // Function Calls:
00079 //      Function                    Location
00080 //
00081 //      CSimpleSite::AddReff        SITE.CPP
00082 //      OutputDebugString           Windows API
00083 //
00084 // Comments:
00085 //
00086 //      This function adds one to the ref count of the interface,
00087 //      and calls then calls CSimpleSite to increment its ref.
00088 //      count.
00089 //
00090 //********************************************************************
00091
00092 STDMETHODIMP_(ULONG) CAdviseSink::AddRef()
00093 {
00094         OutputDebugString("In IAS::AddRef\r\n");
00095
00096         // increment the interface reference count (for debugging only)
00097         ++m_nCount;
00098
00099         // delegate to the container Site
00100         return m_pSite->AddRef();
00101 }
00102
00103 //**********************************************************************
00104 //
00105 // CAdviseSink::Release
00106 //
00107 // Purpose:
00108 //
00109 //      Decrements the reference count on this interface
00110 //
00111 // Parameters:
00112 //
00113 //      None
00114 //
00115 // Return Value:
00116 //
00117 //      The current reference count on this interface.
00118 //
00119 // Function Calls:
00120 //      Function                    Location
00121 //
00122 //      CSimpleSite::Release        SITE.CPP
00123 //      OutputDebugString           Windows API
00124 //
00125 // Comments:
00126 //
00127 //      This function subtracts one from the ref count of the interface,
00128 //      and calls then calls CSimpleSite to decrement its ref.
00129 //      count.
00130 //
00131 //********************************************************************
00132
00133 STDMETHODIMP_(ULONG) CAdviseSink::Release()
00134 {
00135         OutputDebugString("In IAS::Release\r\n");
00136
00137         // decrement the interface reference count (for debugging only)
00138         m_nCount--;
00139
00140         // delegate to the container Site
00141         return m_pSite->Release();
00142 }
00143
00144 //**********************************************************************
00145 //
00146 // CAdviseSink::OnDataChange
00147 //
00148 // Purpose:
00149 //
00150 //      Not Implemented (needs to be stubbed out)
00151 //
00152 // Parameters:
00153 //
00154 //      Not Implemented (needs to be stubbed out)
00155 //
00156 // Return Value:
00157 //
00158 //      Not Implemented (needs to be stubbed out)
00159 //
00160 // Function Calls:
00161 //      Function                    Location
00162 //
00163 //      OutputDebugString           Windows API
00164 //
00165 // Comments:
00166 //
00167 //      Not Implemented (needs to be stubbed out)
00168 //
00169 //********************************************************************
00170
00171 STDMETHODIMP_(void) CAdviseSink::OnDataChange (FORMATETC FAR* pFormatetc, STGMEDIUM FAR* pStgmed)
00172 {
00173         OutputDebugString("In IAS::OnDataChange\r\n");
00174 }
00175
00176 //**********************************************************************
00177 //
00178 // CAdviseSink::OnViewChange
00179 //
00180 // Purpose:
00181 //
00182 //      Notifies us that the view has changed and needs to be updated.
00183 //
00184 // Parameters:
00185 //
00186 //      DWORD dwAspect  - Aspect that has changed
00187 //
00188 //      LONG lindex     - Index that has changed
00189 //
00190 // Return Value:
00191 //
00192 //      None
00193 //
00194 // Function Calls:
00195 //      Function                    Location
00196 //
00197 //      OutputDebugString           Windows API
00198 //      InvalidateRect              Windows API
00199 //      IViewObject2::GetExtent     Object
00200 //
00201 // Comments:
00202 //
00203 //********************************************************************
00204
00205 STDMETHODIMP_(void) CAdviseSink::OnViewChange (DWORD dwAspect, LONG lindex)
00206 {
00207         CStabilize stabilize(m_pSite);
00208         LPVIEWOBJECT2 lpViewObject2;
00209         OutputDebugString("In IAS::OnViewChange\r\n");
00210
00211         // get a pointer to IViewObject2
00212         HRESULT hErr = m_pSite->m_lpOleObject->QueryInterface(
00213                         IID_IViewObject2,(LPVOID FAR *)&lpViewObject2);
00214
00215         if (hErr == NOERROR) {
00216                 // get extent of the object
00217                 // NOTE: this method will never be remoted; it can be called w/i this async method
00218                 lpViewObject2->GetExtent(DVASPECT_CONTENT, -1 , NULL, &m_pSite->m_sizel);
00219                 lpViewObject2->Release();
00220         }
00221
00222         InvalidateRect(m_pSite->m_lpDoc->m_hDocWnd, NULL, TRUE);
00223 }
00224
00225 //**********************************************************************
00226 //
00227 // CAdviseSink::OnRename
00228 //
00229 // Purpose:
00230 //
00231 //      Not Implemented (needs to be stubbed out)
00232 //
00233 // Parameters:
00234 //
00235 //      Not Implemented (needs to be stubbed out)
00236 //
00237 // Return Value:
00238 //
00239 //      Not Implemented (needs to be stubbed out)
00240 //
00241 // Function Calls:
00242 //      Function                    Location
00243 //
00244 //      OutputDebugString           Windows API
00245 //
00246 // Comments:
00247 //
00248 //      Not Implemented (needs to be stubbed out)
00249 //
00250 //********************************************************************
00251
00252 STDMETHODIMP_(void) CAdviseSink::OnRename (LPMONIKER pmk)
00253 {
00254         OutputDebugString("In IAS::OnRename\r\n");
00255 }
00256
00257 //**********************************************************************
00258 //
00259 // CAdviseSink::OnSave
00260 //
00261 // Purpose:
00262 //
00263 //      Not Implemented (needs to be stubbed out)
00264 //
00265 // Parameters:
00266 //
00267 //      Not Implemented (needs to be stubbed out)
00268 //
00269 // Return Value:
00270 //
00271 //      Not Implemented (needs to be stubbed out)
00272 //
00273 // Function Calls:
00274 //      Function                    Location
00275 //
00276 //      OutputDebugString           Windows API
00277 //
00278 // Comments:
00279 //
00280 //      Not Implemented (needs to be stubbed out)
00281 //
00282 //********************************************************************
00283
00284 STDMETHODIMP_(void) CAdviseSink::OnSave ()
00285 {
00286         OutputDebugString("In IAS::OnSave\r\n");
00287 }
00288
00289 //**********************************************************************
00290 //
00291 // CAdviseSink::OnClose
00292 //
00293 // Purpose:
00294 //
00295 //      Not Implemented (needs to be stubbed out)
00296 //
00297 // Parameters:
00298 //
00299 //      Not Implemented (needs to be stubbed out)
00300 //
00301 // Return Value:
00302 //
00303 //      Not Implemented (needs to be stubbed out)
00304 //
00305 // Function Calls:
00306 //      Function                    Location
00307 //
00308 //      OutputDebugString           Windows API
00309 //
00310 // Comments:
00311 //
00312 //      Not Implemented (needs to be stubbed out)
00313 //
00314 //********************************************************************
00315
00316 STDMETHODIMP_(void) CAdviseSink::OnClose()
00317 {
00318         OutputDebugString("In IAS::OnClose\r\n");
00319 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows.Net/exit.cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows.Net

exit.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        exit.cpp
00007 //
00008 // Contents:    CCertExitSample implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013 #pragma hdrstop
00014
00015 #include <assert.h>
00016 #include "celib.h"
00017 #include "exit.h"
00018 #include "module.h"
00019
00020 BOOL fDebug = DBG_CERTSRV;
00021
00022 #ifndef DBG_CERTSRV
00023 #error -- DBG_CERTSRV not defined!
00024 #endif
00025
00026 #define ceEXITEVENTS \
00027   (EXITEVENT_CERTISSUED | \
00028    EXITEVENT_CERTPENDING | \
00029    EXITEVENT_CERTDENIED | \
00030    EXITEVENT_CERTREVOKED | \
00031    EXITEVENT_CERTRETRIEVEPENDING | \
00032    EXITEVENT_CRLISSUED | \
00033    EXITEVENT_SHUTDOWN)
00034
00035 extern HINSTANCE g_hInstance;
00036
00037
00038 HRESULT
00039 GetServerCallbackInterface(
00040     OUT ICertServerExit** ppServer,
00041     IN LONG Context)
00042 {
00043     HRESULT hr;
00044
00045     if (NULL == ppServer)
00046     {
00047         hr = E_POINTER;
00048   _JumpError(hr, error, "Exit:NULL pointer");
00049     }
00050
00051     hr = CoCreateInstance(
00052                     CLSID_CCertServerExit,
00053                     NULL,               // pUnkOuter
00054                     CLSCTX_INPROC_SERVER,
00055                     IID_ICertServerExit,
00056                     (VOID **) ppServer);
00057     _JumpIfError(hr, error, "Exit:CoCreateInstance");
00058
00059     if (*ppServer == NULL)
00060     {
00061         hr = E_UNEXPECTED;
00062   _JumpError(hr, error, "Exit:NULL *ppServer");
00063     }
00064
00065     // only set context if nonzero
00066     if (0 != Context)
00067     {
00068         hr = (*ppServer)->SetContext(Context);
00069         _JumpIfError(hr, error, "Exit: SetContext");
00070     }
00071
00072 error:
00073     return(hr);
00074 }
00075
00076
00077 //+--------------------------------------------------------------------------
00078 // CCertExitSample::~CCertExitSample -- destructor
00079 //
00080 // free memory associated with this instance
00081 //+--------------------------------------------------------------------------
00082
00083 CCertExitSample::~CCertExitSample()
00084 {
00085     if (NULL != m_strCAName)
00086     {
00087         SysFreeString(m_strCAName);
00088     }
00089     if (NULL != m_pwszRegStorageLoc)
00090     {
00091         LocalFree(m_pwszRegStorageLoc);
00092     }
00093     if (NULL != m_hExitKey)
00094     {
00095         RegCloseKey(m_hExitKey);
00096     }
00097     if (NULL != m_strDescription)
00098     {
00099         SysFreeString(m_strDescription);
00100     }
00101 }
00102
00103
00104 //+--------------------------------------------------------------------------
00105 // CCertExitSample::Initialize -- initialize for a CA & return interesting Event Mask
00106 //
00107 // Returns S_OK on success.
00108 //+--------------------------------------------------------------------------
00109
00110 STDMETHODIMP
00111 CCertExitSample::Initialize(
00112     /* [in] */ BSTR const strConfig,
00113     /* [retval][out] */ LONG __RPC_FAR *pEventMask)
00114 {
00115     HRESULT hr = S_OK;
00116     DWORD       cbbuf;
00117     DWORD       dwType;
00118     ENUM_CATYPES CAType;
00119     ICertServerExit* pServer = NULL;
00120     VARIANT varValue;
00121     WCHAR sz[MAX_PATH];
00122
00123     VariantInit(&varValue);
00124
00125     assert(wcslen(wsz_SAMPLE_DESCRIPTION) < ARRAYSIZE(sz));
00126     wcsncpy(sz, wsz_SAMPLE_DESCRIPTION, ARRAYSIZE(sz));
00127     sz[ARRAYSIZE(sz) - 1] = L'\0';
00128
00129     m_strDescription = SysAllocString(sz);
00130     if (NULL == m_strDescription)
00131     {
00132         hr = E_OUTOFMEMORY;
00133         _JumpError(hr, error, "Exit:SysAllocString");
00134     }
00135
00136     m_strCAName = SysAllocString(strConfig);
00137     if (NULL == m_strCAName)
00138     {
00139       hr = E_OUTOFMEMORY;
00140         _JumpError(hr, error, "Exit:SysAllocString");
00141     }
00142
00143     *pEventMask = ceEXITEVENTS;
00144     DBGPRINT((fDebug, "Exit:Initialize(%ws) ==> %x\n", m_strCAName, *pEventMask));
00145
00146     // get server callbacks
00147
00148     hr = GetServerCallbackInterface(&pServer, 0);
00149     _JumpIfError(hr, error, "Exit:GetServerCallbackInterface");
00150
00151     // get storage location
00152
00153     hr = exitGetProperty(
00154         pServer,
00155         FALSE,  // fRequest
00156         wszPROPMODULEREGLOC,
00157         PROPTYPE_STRING,
00158         &varValue);
00159     _JumpIfErrorStr(hr, error, "Exit:exitGetProperty", wszPROPMODULEREGLOC);
00160
00161     m_pwszRegStorageLoc = (LPWSTR)LocalAlloc(LMEM_FIXED, (wcslen(varValue.bstrVal)+1) *sizeof(WCHAR));
00162     if (NULL == m_pwszRegStorageLoc)
00163     {
00164         hr = E_OUTOFMEMORY;
00165         _JumpError(hr, error, "Exit:LocalAlloc");
00166     }
00167     wcscpy(m_pwszRegStorageLoc, varValue.bstrVal);
00168     VariantClear(&varValue);
00169
00170     // get CA type
00171     hr = exitGetProperty(
00172         pServer,
00173         FALSE,  // fRequest
00174         wszPROPCATYPE,
00175         PROPTYPE_LONG,
00176         &varValue);
00177     _JumpIfErrorStr(hr, error, "Exit:exitGetProperty", wszPROPCATYPE);
00178
00179     CAType = (ENUM_CATYPES) varValue.lVal;
00180     VariantClear(&varValue);
00181
00182     hr = RegOpenKeyEx(
00183                 HKEY_LOCAL_MACHINE,
00184                 m_pwszRegStorageLoc,
00185                 0,              // dwReserved
00186                 KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE,
00187                 &m_hExitKey);
00188
00189     if (S_OK != hr)
00190     {
00191         if ((HRESULT) ERROR_FILE_NOT_FOUND == hr)
00192         {
00193             hr = S_OK;
00194             goto error;
00195         }
00196         _JumpError(hr, error, "Exit:RegOpenKeyEx");
00197     }
00198
00199     hr = exitGetProperty(
00200         pServer,
00201         FALSE,  // fRequest
00202         wszPROPCERTCOUNT,
00203         PROPTYPE_LONG,
00204         &varValue);
00205     _JumpIfErrorStr(hr, error, "Exit:exitGetProperty", wszPROPCERTCOUNT);
00206
00207     m_cCACert = varValue.lVal;
00208
00209     cbbuf = sizeof(m_dwExitPublishFlags);
00210     hr = RegQueryValueEx(
00211         m_hExitKey,
00212         wszREGCERTPUBLISHFLAGS,
00213         NULL,           // lpdwReserved
00214         &dwType,
00215         (BYTE *) &m_dwExitPublishFlags,
00216         &cbbuf);
00217     if (S_OK != hr)
00218     {
00219         m_dwExitPublishFlags = 0;
00220     }
00221
00222
00223     hr = S_OK;
00224
00225 error:
00226     VariantClear(&varValue);
00227     if (NULL != pServer)
00228     {
00229         pServer->Release();
00230     }
00231     return(ceHError(hr));
00232 }
00233
00234
00235 //+--------------------------------------------------------------------------
00236 // CCertExitSample::_ExpandEnvironmentVariables -- Expand environment variables
00237 //
00238 //+--------------------------------------------------------------------------
00239
00240 HRESULT
00241 CCertExitSample::_ExpandEnvironmentVariables(
00242     IN WCHAR const *pwszIn,
00243     OUT WCHAR *pwszOut,
00244     IN DWORD cwcOut)
00245 {
00246     HRESULT hr = HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW);
00247     WCHAR awcVar[MAX_PATH];
00248     WCHAR const *pwszSrc;
00249     WCHAR *pwszDst;
00250     WCHAR *pwszDstEnd;
00251     WCHAR *pwszVar;
00252     DWORD cwc;
00253
00254     pwszSrc = pwszIn;
00255     pwszDst = pwszOut;
00256     pwszDstEnd = &pwszOut[cwcOut];
00257
00258     while (L'\0' != (*pwszDst = *pwszSrc++))
00259     {
00260   if ('%' == *pwszDst)
00261   {
00262       *pwszDst = L'\0';
00263       pwszVar = awcVar;
00264
00265       while (L'\0' != *pwszSrc)
00266       {
00267     if ('%' == *pwszSrc)
00268     {
00269         pwszSrc++;
00270         break;
00271     }
00272     *pwszVar++ = *pwszSrc++;
00273     if (pwszVar >= &awcVar[sizeof(awcVar)/sizeof(awcVar[0]) - 1])
00274     {
00275         _JumpError(hr, error, "Exit:overflow 1");
00276     }
00277       }
00278       *pwszVar = L'\0';
00279       cwc = GetEnvironmentVariable(awcVar, pwszDst, SAFE_SUBTRACT_POINTERS(pwszDstEnd, pwszDst));
00280       if (0 == cwc)
00281       {
00282     hr = ceHLastError();
00283     _JumpError(hr, error, "Exit:GetEnvironmentVariable");
00284       }
00285       if ((DWORD) (pwszDstEnd - pwszDst) <= cwc)
00286       {
00287     _JumpError(hr, error, "Exit:overflow 2");
00288       }
00289       pwszDst += cwc;
00290   }
00291   else
00292   {
00293       pwszDst++;
00294   }
00295   if (pwszDst >= pwszDstEnd)
00296   {
00297       _JumpError(hr, error, "Exit:overflow 3");
00298   }
00299     }
00300     hr = S_OK;
00301
00302 error:
00303     return(hr);
00304 }
00305
00306
00307 HRESULT
00308 exitGetRequestAttribute(
00309     IN ICertServerExit *pServer,
00310     IN WCHAR const *pwszAttributeName,
00311     OUT BSTR *pstrOut)
00312 {
00313     HRESULT hr;
00314     BSTR strName = NULL;
00315
00316     *pstrOut = NULL;
00317     strName = SysAllocString(pwszAttributeName);
00318     if (NULL == strName)
00319     {
00320   hr = E_OUTOFMEMORY;
00321   _JumpError(hr, error, "Exit:SysAllocString");
00322     }
00323     hr = pServer->GetRequestAttribute(strName, pstrOut);
00324     _JumpIfErrorStr2(
00325     hr,
00326     error,
00327     "Exit:GetRequestAttribute",
00328     pwszAttributeName,
00329     CERTSRV_E_PROPERTY_EMPTY);
00330
00331 error:
00332     if (NULL != strName)
00333     {
00334   SysFreeString(strName);
00335     }
00336     return(hr);
00337 }
00338
00339
00340 //+--------------------------------------------------------------------------
00341 // CCertExitSample::_WriteCertToFile -- write binary certificate to a file
00342 //
00343 //+--------------------------------------------------------------------------
00344
00345 HRESULT
00346 CCertExitSample::_WriteCertToFile(
00347     IN ICertServerExit *pServer,
00348     IN BYTE const *pbCert,
00349     IN DWORD cbCert)
00350 {
00351     HRESULT hr;
00352     BSTR strCertFile = NULL;
00353     DWORD cbWritten;
00354     HANDLE hFile = INVALID_HANDLE_VALUE;
00355     WCHAR wszDir[MAX_PATH];
00356     WCHAR *pwszPath = NULL;
00357     WCHAR wszFile[cwcDWORDSPRINTF+5]; //format "requestid.cer"
00358     VARIANT varRequestID;
00359
00360     VariantInit(&varRequestID);
00361
00362     // Old functionality asked requester to pass in a CertFile attribute with
00363     // the output request file name. After the security review we decided
00364     // to not allow file name from user but to build it at server. Still, we
00365     // don't want to start publishing all certificates, so we'll maintain the
00366     // CertFile property; if present, we'll just ignore its content, if not
00367     // present we won't publish.
00368     hr = exitGetRequestAttribute(pServer, wszPROPEXITCERTFILE, &strCertFile);
00369     if (S_OK != hr)
00370     {
00371   DBGPRINT((
00372       fDebug,
00373       "Exit:exitGetRequestAttribute(%ws): %x%hs\n",
00374       wszPROPEXITCERTFILE,
00375       hr,
00376       CERTSRV_E_PROPERTY_EMPTY == hr? " EMPTY VALUE" : ""));
00377   if (CERTSRV_E_PROPERTY_EMPTY == hr)
00378   {
00379       hr = S_OK;
00380   }
00381   goto error;
00382     }
00383
00384     // build file name as "requestid.cer"
00385
00386     hr = exitGetProperty(
00387         pServer,
00388         TRUE,  // fRequest,
00389         wszPROPREQUESTREQUESTID,
00390         PROPTYPE_LONG,
00391         &varRequestID);
00392     _JumpIfErrorStr(hr, error, "Exit:exitGetProperty", wszPROPREQUESTREQUESTID);
00393
00394     wsprintf(wszFile, L"%d.cer", V_I4(&varRequestID));
00395
00396     hr = _ExpandEnvironmentVariables(
00397         L"%SystemRoot%\\System32\\" wszCERTENROLLSHAREPATH L"\\",
00398         wszDir,
00399         ARRAYSIZE(wszDir));
00400     _JumpIfError(hr, error, "_ExpandEnvironmentVariables");
00401
00402     hr = ceBuildPathAndExt(wszDir, wszFile, NULL, &pwszPath);
00403     _JumpIfError(hr, error, "ceBuildPathAndExt");
00404
00405     // open file & write binary cert out.
00406
00407     hFile = CreateFile(
00408         pwszPath,
00409         GENERIC_WRITE,
00410         0,      // dwShareMode
00411         NULL,   // lpSecurityAttributes
00412         CREATE_NEW,
00413         FILE_ATTRIBUTE_NORMAL,
00414         NULL);    // hTemplateFile
00415     if (INVALID_HANDLE_VALUE == hFile)
00416     {
00417   hr = ceHLastError();
00418   _JumpErrorStr(hr, error, "Exit:CreateFile", pwszPath);
00419     }
00420     if (!WriteFile(hFile, pbCert, cbCert, &cbWritten, NULL))
00421     {
00422   hr = ceHLastError();
00423   _JumpErrorStr(hr, error, "Exit:WriteFile", pwszPath);
00424     }
00425     if (cbWritten != cbCert)
00426     {
00427   hr = STG_E_WRITEFAULT;
00428   DBGPRINT((
00429       fDebug,
00430       "Exit:WriteFile(%ws): attempted %x, actual %x bytes: %x\n",
00431       pwszPath,
00432       cbCert,
00433       cbWritten,
00434       hr));
00435   goto error;
00436     }
00437
00438 error:
00439
00440     if (INVALID_HANDLE_VALUE != hFile)
00441     {
00442   CloseHandle(hFile);
00443     }
00444     if (NULL != pwszPath)
00445     {
00446   LocalFree(pwszPath);
00447     }
00448     if (NULL != strCertFile)
00449     {
00450   SysFreeString(strCertFile);
00451     }
00452     return(hr);
00453 }
00454
00455
00456 //+--------------------------------------------------------------------------
00457 // CCertExitSample::_NotifyNewCert -- Notify the exit module of a new certificate
00458 //
00459 //+--------------------------------------------------------------------------
00460
00461 HRESULT
00462 CCertExitSample::_NotifyNewCert(
00463     /* [in] */ LONG Context)
00464 {
00465     HRESULT hr;
00466     VARIANT varCert;
00467     ICertServerExit *pServer = NULL;
00468
00469     VariantInit(&varCert);
00470
00471     // only call write fxns if server policy allows
00472
00473     if (m_dwExitPublishFlags & EXITPUB_FILE)
00474     {
00475         hr = CoCreateInstance(
00476             CLSID_CCertServerExit,
00477             NULL,               // pUnkOuter
00478             CLSCTX_INPROC_SERVER,
00479             IID_ICertServerExit,
00480             (VOID **) &pServer);
00481         _JumpIfError(hr, error, "Exit:CoCreateInstance");
00482
00483         hr = pServer->SetContext(Context);
00484         _JumpIfError(hr, error, "Exit:SetContext");
00485
00486         hr = exitGetProperty(
00487             pServer,
00488             FALSE,  // fRequest,
00489             wszPROPRAWCERTIFICATE,
00490             PROPTYPE_BINARY,
00491             &varCert);
00492         _JumpIfErrorStr(
00493         hr,
00494         error,
00495         "Exit:exitGetProperty",
00496         wszPROPRAWCERTIFICATE);
00497
00498         if (VT_BSTR != varCert.vt)
00499         {
00500       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00501       _JumpError(hr, error, "Exit:BAD cert var type");
00502         }
00503
00504   hr = _WriteCertToFile(
00505       pServer,
00506       (BYTE const *) varCert.bstrVal,
00507       SysStringByteLen(varCert.bstrVal));
00508   _JumpIfError(hr, error, "_WriteCertToFile");
00509     }
00510
00511     hr = S_OK;
00512
00513 error:
00514     VariantClear(&varCert);
00515     if (NULL != pServer)
00516     {
00517   pServer->Release();
00518     }
00519     return(hr);
00520 }
00521
00522 //+--------------------------------------------------------------------------
00523 // CCertExitSample::_NotifyCRLIssued -- Notify the exit module of a new certificate
00524 //
00525 //+--------------------------------------------------------------------------
00526
00527 HRESULT
00528 CCertExitSample::_NotifyCRLIssued(
00529     /* [in] */ LONG Context)
00530 {
00531     HRESULT hr;
00532     ICertServerExit *pServer = NULL;
00533     DWORD i;
00534     VARIANT varBaseCRL;
00535     VARIANT varDeltaCRL;
00536     BOOL fDeltaCRLsDisabled;
00537
00538     VariantInit(&varBaseCRL);
00539     VariantInit(&varDeltaCRL);
00540
00541     hr = CoCreateInstance(
00542         CLSID_CCertServerExit,
00543         NULL,               // pUnkOuter
00544         CLSCTX_INPROC_SERVER,
00545         IID_ICertServerExit,
00546         (VOID **) &pServer);
00547     _JumpIfError(hr, error, "Exit:CoCreateInstance");
00548
00549     hr = pServer->SetContext(Context);
00550     _JumpIfError(hr, error, "Exit:SetContext");
00551
00552
00553     hr = exitGetProperty(
00554         pServer,
00555         FALSE,  // fRequest,
00556         wszPROPDELTACRLSDISABLED,
00557         PROPTYPE_LONG,
00558         &varBaseCRL);
00559     _JumpIfErrorStr(
00560     hr,
00561     error,
00562     "Exit:exitGetProperty",
00563     wszPROPDELTACRLSDISABLED);
00564
00565     fDeltaCRLsDisabled = varBaseCRL.lVal;
00566
00567     // How many CRLs are there?
00568
00569     // Loop for each CRL
00570     for (i = 0; i < m_cCACert; i++)
00571     {
00572         // array size for wsprintf("%s.%u")
00573         #define MAX_CRL_PROP ( \
00574             max( max( ARRAYSIZE(wszPROPCRLSTATE), \
00575                       ARRAYSIZE(wszPROPRAWCRL) ), \
00576                  ARRAYSIZE(wszPROPRAWDELTACRL) ) + 1 + cwcDWORDSPRINTF)
00577
00578         WCHAR wszCRLPROP[MAX_CRL_PROP];
00579
00580         // Verify the CRL State says we should update this CRL
00581
00582         wsprintf(wszCRLPROP, wszPROPCRLSTATE L".%u", i);
00583         hr = exitGetProperty(
00584       pServer,
00585       FALSE,  // fRequest,
00586       wszCRLPROP,
00587       PROPTYPE_LONG,
00588       &varBaseCRL);
00589         _JumpIfErrorStr(hr, error, "Exit:exitGetProperty", wszCRLPROP);
00590
00591   if (CA_DISP_VALID != varBaseCRL.lVal)
00592   {
00593       continue;
00594   }
00595
00596         // Grab the raw base CRL
00597
00598         wsprintf(wszCRLPROP, wszPROPRAWCRL L".%u", i);
00599         hr = exitGetProperty(
00600       pServer,
00601       FALSE,  // fRequest,
00602       wszCRLPROP,
00603       PROPTYPE_BINARY,
00604       &varBaseCRL);
00605         _JumpIfErrorStr(hr, error, "Exit:exitGetProperty", wszCRLPROP);
00606
00607         // Grab the raw delta CRL (which may not exist)
00608
00609         wsprintf(wszCRLPROP, wszPROPRAWDELTACRL L".%u", i);
00610         hr = exitGetProperty(
00611       pServer,
00612       FALSE,  // fRequest,
00613       wszCRLPROP,
00614       PROPTYPE_BINARY,
00615       &varDeltaCRL);
00616         _PrintIfErrorStr2(
00617         hr,
00618         "Exit:exitGetProperty",
00619         wszCRLPROP,
00620         fDeltaCRLsDisabled?
00621       HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) : S_OK);
00622   if (S_OK != hr && !fDeltaCRLsDisabled)
00623   {
00624       goto error;
00625   }
00626
00627         // Publish the CRL(s) ...
00628     }
00629
00630     hr = S_OK;
00631
00632 error:
00633     if (NULL != pServer)
00634     {
00635   pServer->Release();
00636     }
00637     VariantClear(&varBaseCRL);
00638     VariantClear(&varDeltaCRL);
00639     return(hr);
00640 }
00641
00642
00643 //+--------------------------------------------------------------------------
00644 // CCertExitSample::Notify -- Notify the exit module of an event
00645 //
00646 // Returns S_OK.
00647 //+--------------------------------------------------------------------------
00648
00649 STDMETHODIMP
00650 CCertExitSample::Notify(
00651     /* [in] */ LONG ExitEvent,
00652     /* [in] */ LONG Context)
00653 {
00654     char *psz = "UNKNOWN EVENT";
00655     HRESULT hr = S_OK;
00656
00657     switch (ExitEvent)
00658     {
00659   case EXITEVENT_CERTISSUED:
00660       hr = _NotifyNewCert(Context);
00661       psz = "certissued";
00662       break;
00663
00664   case EXITEVENT_CERTPENDING:
00665       psz = "certpending";
00666       break;
00667
00668   case EXITEVENT_CERTDENIED:
00669       psz = "certdenied";
00670       break;
00671
00672   case EXITEVENT_CERTREVOKED:
00673       psz = "certrevoked";
00674       break;
00675
00676   case EXITEVENT_CERTRETRIEVEPENDING:
00677       psz = "retrievepending";
00678       break;
00679
00680   case EXITEVENT_CRLISSUED:
00681       hr = _NotifyCRLIssued(Context);
00682       psz = "crlissued";
00683       break;
00684
00685   case EXITEVENT_SHUTDOWN:
00686       psz = "shutdown";
00687       break;
00688     }
00689
00690
00691     DBGPRINT((
00692   fDebug,
00693   "Exit:Notify(%hs=%x, ctx=%x) rc=%x\n",
00694   psz,
00695   ExitEvent,
00696   Context,
00697   hr));
00698     return(hr);
00699 }
00700
00701
00702 STDMETHODIMP
00703 CCertExitSample::GetDescription(
00704     /* [retval][out] */ BSTR *pstrDescription)
00705 {
00706     HRESULT hr = S_OK;
00707     WCHAR sz[MAX_PATH];
00708
00709     assert(wcslen(wsz_SAMPLE_DESCRIPTION) < ARRAYSIZE(sz));
00710     wcscpy(sz, wsz_SAMPLE_DESCRIPTION);
00711
00712     *pstrDescription = SysAllocString(sz);
00713     if (NULL == *pstrDescription)
00714     {
00715   hr = E_OUTOFMEMORY;
00716   _JumpError(hr, error, "Exit:SysAllocString");
00717     }
00718
00719 error:
00720     return(hr);
00721 }
00722
00723
00724 //+--------------------------------------------------------------------------
00725 // CCertExitSample::GetManageModule
00726 //
00727 // Returns S_OK on success.
00728 //+--------------------------------------------------------------------------
00729
00730 STDMETHODIMP
00731 CCertExitSample::GetManageModule(
00732     /* [out, retval] */ ICertManageModule **ppManageModule)
00733 {
00734     HRESULT hr;
00735
00736     *ppManageModule = NULL;
00737     hr = CoCreateInstance(
00738             CLSID_CCertManageExitModuleSample,
00739             NULL,               // pUnkOuter
00740             CLSCTX_INPROC_SERVER,
00741             IID_ICertManageModule,
00742             (VOID **) ppManageModule);
00743     _JumpIfError(hr, error, "CoCreateInstance");
00744
00745 error:
00746     return(hr);
00747 }
00748
00749
00750 /////////////////////////////////////////////////////////////////////////////
00751 //
00752
00753 STDMETHODIMP
00754 CCertExitSample::InterfaceSupportsErrorInfo(REFIID riid)
00755 {
00756     int i;
00757     static const IID *arr[] =
00758     {
00759   &IID_ICertExit,
00760     };
00761
00762     for (i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
00763     {
00764   if (IsEqualGUID(*arr[i],riid))
00765   {
00766       return(S_OK);
00767   }
00768     }
00769     return(S_FALSE);
00770 }
00771
00772
00773 HRESULT
00774 exitGetProperty(
00775     IN ICertServerExit *pServer,
00776     IN BOOL fRequest,
00777     IN WCHAR const *pwszPropertyName,
00778     IN DWORD PropType,
00779     OUT VARIANT *pvarOut)
00780 {
00781     HRESULT hr;
00782     BSTR strName = NULL;
00783
00784     VariantInit(pvarOut);
00785     strName = SysAllocString(pwszPropertyName);
00786     if (NULL == strName)
00787     {
00788   hr = E_OUTOFMEMORY;
00789   _JumpError(hr, error, "Exit:SysAllocString");
00790     }
00791     if (fRequest)
00792     {
00793   hr = pServer->GetRequestProperty(strName, PropType, pvarOut);
00794   _JumpIfErrorStr2(
00795         hr,
00796         error,
00797         "Exit:GetRequestProperty",
00798         pwszPropertyName,
00799         CERTSRV_E_PROPERTY_EMPTY);
00800     }
00801     else
00802     {
00803   hr = pServer->GetCertificateProperty(strName, PropType, pvarOut);
00804   _JumpIfErrorStr2(
00805         hr,
00806         error,
00807         "Exit:GetCertificateProperty",
00808         pwszPropertyName,
00809         CERTSRV_E_PROPERTY_EMPTY);
00810     }
00811
00812 error:
00813     if (NULL != strName)
00814     {
00815   SysFreeString(strName);
00816     }
00817     return(hr);
00818 }
00819
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcRDO/StdAfx.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcRDO

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__DB28BB75_D3C1_11D0_8233_00AA00A3F13E__INCLUDED_)
00006 #define AFX_STDAFX_H__DB28BB75_D3C1_11D0_8233_00AA00A3F13E__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #if !defined(_WIN32_WINNT)
00016 #define _WIN32_WINNT 0x0500
00017 #endif // !defined(_WIN32_WINNT)
00018
00019 #define _ATL_APARTMENT_THREADED
00020
00021
00022 #include <atlbase.h>
00023 //You may derive a class from CComModule and use it if you want to override
00024 //something, but do not change the name of _Module
00025 extern CComModule _Module;
00026 #include <atlcom.h>
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00030
00031 #endif // !defined(AFX_STDAFX_H__DB28BB75_D3C1_11D0_8233_00AA00A3F13E__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/step1.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

step1.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1995-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module STEP1.CPP
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////////
00015 #include "wizard.h"
00016 #include "common.h"
00017 #include "table.h"
00018
00019 /////////////////////////////////////////////////////////////////////
00020 // Defines
00021 //
00022 /////////////////////////////////////////////////////////////////////
00023
00024 //Enum Column Header for the ListView controls
00025 enum COL_HEADERS
00026 {
00027   //IDL_COLUMNS
00028   COL_COLNAME     = 0,  //ColInfo.pwszName
00029   COL_COLTYPE     = 1,  //ColInfo.wType
00030   COL_COLORDINAL    = 2,  //ColInfo.iOrdinal
00031   COL_COLSIZE     = 3,  //ColInfo.ulColumnSize
00032   COL_COLPREC     = 4,  //ColInfo.bPrecision
00033   COL_COLSCALE    = 5,  //ColInfo.bScale
00034   COL_COLISFIXED    = 6,  //ColInfo.dwFlags ISFIXEDLENGTH
00035   COL_COLISLONG   = 7,  //ColInfo.dwFlags ISLONG
00036   COL_COLISNULLABLE = 8,  //ColInfo.dwFlags ISNULLABLE
00037   COL_COLWRITE    = 9,  //ColInfo.dwFlags WRITE
00038   COL_COLISROWID    =10,  //ColInfo.dwFlags ISROWID
00039   COL_COLISROWVER   =11,  //ColInfo.dwFlags ISROWVER
00040 };
00041
00042 enum EICON
00043 {
00044   ICON_CATALOG    = 0,
00045   ICON_SCHEMA     = 1,
00046   ICON_TYPE     = 2,
00047   ICON_TABLE      = 3,
00048   ICON_SYSTABLE   = 4,
00049   ICON_VIEW     = 5,
00050   ICON_SYNONYM    = 6,
00051
00052   ICON_COLUMN     = 0,
00053   ICON_READONLY   = 1,
00054   ICON_LONG     = 2,
00055 };
00056
00057
00058 /////////////////////////////////////////////////////////////////////
00059 // CS1Dialog::CS1Dialog
00060 //
00061 /////////////////////////////////////////////////////////////////////
00062 CS1Dialog::CS1Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pCTableCopy)
00063   : CDialogBase(hWnd, hInst)
00064 {
00065   ASSERT(pCTableCopy);
00066   m_pCTableCopy = pCTableCopy;
00067   m_fEditing = FALSE;
00068
00069   m_cTables = 0;
00070   m_rgTableInfo = NULL;
00071 }
00072
00073
00074 /////////////////////////////////////////////////////////////////////
00075 // CS1Dialog::~CS1Dialog
00076 //
00077 /////////////////////////////////////////////////////////////////////
00078 CS1Dialog::~CS1Dialog()
00079 {
00080   SAFE_FREE(m_rgTableInfo);
00081 }
00082
00083
00084 /////////////////////////////////////////////////////////////////////////////
00085 // ULONG CS1Dialog::Display
00086 //
00087 /////////////////////////////////////////////////////////////////////////////
00088 ULONG CS1Dialog::Display()
00089 {
00090   //Create a Modal dialog box
00091   return DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_FROM_INFO), NULL, DlgProc, (LPARAM)this);
00092 }
00093
00094
00095 /////////////////////////////////////////////////////////////////////
00096 // CS1Dialog::DlgProc
00097 //
00098 /////////////////////////////////////////////////////////////////////
00099 BOOL WINAPI CS1Dialog::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00100 {
00101   static WCHAR  wszBuffer[MAX_NAME_LEN+1];
00102
00103   switch(msg)
00104   {
00105     case WM_INITDIALOG:
00106     {
00107       Busy();
00108       CS1Dialog* pThis = (CS1Dialog*)lParam;
00109       SetWindowLong(hWnd, GWL_USERDATA, (LONG)pThis);
00110
00111       //On INIT we know we have a valid hWnd to store
00112       CenterDialog(hWnd);
00113       pThis->m_hWnd = hWnd;
00114       CTable* pCFromTable = pThis->m_pCTableCopy->m_pCFromTable;
00115
00116       //Init all controls to the default values
00117       pThis->InitControls();
00118
00119       // If there is a source to look at, Display the table list
00120       if(pCFromTable->IsConnected())
00121         pThis->ResetTableList(GetDlgItem(hWnd, IDL_TABLES), GetDlgItem(hWnd, IDL_COLUMNS));
00122
00123       pThis->RefreshControls();
00124       pThis->m_pCTableCopy->m_pCWizard->DestroyPrevStep(WIZ_STEP1);
00125       return HANDLED_MSG;
00126     }//case WM_INITDIALOG
00127
00128     case WM_COMMAND:
00129     {
00130       //Obtain the "this" pointer
00131       CS1Dialog *pThis = (CS1Dialog*)GetWindowLong(hWnd, GWL_USERDATA);
00132
00133       CTable    *pCFromTable    = pThis->m_pCTableCopy->m_pCFromTable;
00134       CTable    *pCToTable      = pThis->m_pCTableCopy->m_pCToTable;
00135       CDataSource *pCToDataSource   = pCToTable->m_pCDataSource;
00136       CDataSource *pCFromDataSource = pCFromTable->m_pCDataSource;
00137
00138       //Filter out any Control Notification codes
00139       if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
00140       {
00141         return UNHANDLED_MSG;
00142       }
00143
00144       //LBN_SELCHANGE ListBox Selection change
00145       if(GET_WM_COMMAND_CMD(wParam, lParam) == LBN_SELCHANGE
00146         && IDC_PROVIDER_NAME == GET_WM_COMMAND_ID(wParam, lParam))
00147       {
00148         Busy();
00149 /*
00150         //Get new selection
00151         LONG iSel = 0;
00152         if((iSel = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR)
00153         {
00154           //Since we have the CBS_SORT turned on, the order in the Combo Box does
00155           //not match our array, so we pass the array index (lParam) as the item data
00156           LONG lParam = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L);
00157           if((lParam < (LONG)pCFromDataSource->m_cProviderInfo) && (wcscmp(pCFromDataSource->m_rgProviderInfo[lParam].wszName, pCFromDataSource->m_pwszProviderName)!=0))
00158           {
00159             //Clear Table/Column List Views
00160             SendMessage(GetDlgItem(hWnd, IDL_TABLES), TVM_DELETEITEM, (WPARAM)0, (LPARAM)TVI_ROOT);
00161             SendMessage(GetDlgItem(hWnd, IDL_COLUMNS), LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0);
00162
00163             //Clear Table info
00164             memset(&pCFromTable->m_TableInfo, 0, sizeof(TABLEINFO));
00165             pCFromTable->m_wszQualTableName[0] = EOL;
00166
00167             //Disconnect from the DataSource and Update controls
00168             pCFromTable->m_pCDataSource->Disconnect();
00169             pThis->RefreshControls();
00170           }
00171         }
00172         else
00173         {
00174           //The user must have typed in a Provider Name directly
00175           //This may not map to a provider in the list, so assume the name is a ProgID/CLSID
00176           LONG lParam = wSendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETLBTEXT, 0, wszBuffer);
00177         }
00178         return HANDLED_MSG;
00179 */
00180       }
00181       if(pThis->m_fEditing)
00182       {
00183         //There is a bug in the TreeView control for editing here is KB article
00184         //Article ID: Q130691 BUG: ESC/ENTER Keys Don't Work When Editing Labels in TreeView
00185         //So one way to work around this is to just have a flag (m_fEditing)
00186         //to indicate we were in editing mode.
00187         SendDlgItemMessage(hWnd, IDL_TABLES, TVM_ENDEDITLABELNOW, (WPARAM) (wParam==IDCANCEL ? TRUE : FALSE), (LPARAM)0);
00188         return HANDLED_MSG;
00189       }
00190
00191       // Now check for regular command ids
00192       switch(GET_WM_COMMAND_ID(wParam, lParam))
00193       {
00194         case IDB_FROM_CONNECT:
00195         {
00196           //on connect get whatever is now listed in the drop down
00197           LONG iSel = 0;
00198           if((iSel = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR)
00199           {
00200             //Since we have the CBS_SORT turned on, the order in the Combo Box does
00201             //not match our array, so we pass the array index (lParam) as the item data
00202             LONG lParam = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L);
00203             pCFromTable->m_pCDataSource->m_pwszProviderName = pCFromDataSource->m_rgProviderInfo[lParam].wszName;
00204             if((lParam < (LONG)pCFromDataSource->m_cProviderInfo) && (wcscmp(pCFromDataSource->m_rgProviderInfo[lParam].wszName, pCFromDataSource->m_pwszProviderName)!=0))
00205             {
00206               //Clear Table/Column List Views
00207               SendMessage(GetDlgItem(hWnd, IDL_TABLES), TVM_DELETEITEM, (WPARAM)0, (LPARAM)TVI_ROOT);
00208               SendMessage(GetDlgItem(hWnd, IDL_COLUMNS), LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0);
00209
00210               //Clear Table info
00211               memset(&pCFromTable->m_TableInfo, 0, sizeof(TABLEINFO));
00212               pCFromTable->m_wszQualTableName[0] = EOL;
00213
00214               //Disconnect from the DataSource and Update controls
00215               pCFromTable->m_pCDataSource->Disconnect();
00216             }
00217           }
00218           else
00219           {
00220             //The user must have typed in a Provider Name directly
00221             //This may not map to a provider in the list, so assume the name is a ProgID/CLSID
00222             wSendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
00223             pCFromTable->m_pCDataSource->m_pwszProviderName = wszBuffer;
00224           }
00225
00226           //Try to connect to the DataSource
00227           Busy();
00228           if(pCFromTable->Connect(hWnd))
00229           {
00230             Busy();
00231             //Clear Table info
00232             memset(&pCFromTable->m_TableInfo, 0, sizeof(TABLEINFO));
00233             pCFromTable->m_wszQualTableName[0] = EOL;
00234
00235             //ResetTableList
00236             pThis->ResetTableList(GetDlgItem(hWnd, IDL_TABLES), GetDlgItem(hWnd, IDL_COLUMNS));
00237           }
00238
00239           pThis->RefreshControls();
00240           return HANDLED_MSG;
00241         }//case IDB_FROM_CONNECT
00242
00243                 case IDOK:
00244           Busy();
00245           pThis->GetTableColInfo(GetDlgItem(hWnd, IDL_COLUMNS));
00246           pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP2);
00247           return HANDLED_MSG;
00248
00249         case IDCANCEL:
00250           Busy();
00251           EndDialog(hWnd, GET_WM_COMMAND_ID(wParam, lParam));
00252           return HANDLED_MSG;
00253       }//switch GET_WM_COMMAND_ID
00254
00255       return UNHANDLED_MSG;
00256     }//case WM_COMMAND
00257
00258
00259     // Now look for WM_NOTIFY messages
00260     case WM_NOTIFY:
00261     {
00262       if(wParam == IDL_COLUMNS)
00263       {
00264         //Obtain the "this" pointer
00265         CS1Dialog* pThis = (CS1Dialog*)GetWindowLong(hWnd, GWL_USERDATA);
00266         NM_LISTVIEW* pListView = (NM_LISTVIEW*)lParam;
00267
00268         switch(pListView->hdr.code)
00269         {
00270           case LVN_ITEMCHANGED:
00271           {
00272             //Refresh Controls, ("Next" button)
00273             pThis->RefreshControls();
00274             return UNHANDLED_MSG;
00275           }
00276         }
00277         return UNHANDLED_MSG;
00278       }
00279
00280       if(wParam == IDL_TABLES)
00281       {
00282         //Obtain the "this" pointer
00283         CS1Dialog* pThis = (CS1Dialog*)GetWindowLong(hWnd, GWL_USERDATA);
00284         CTable* pCFromTable = pThis->m_pCTableCopy->m_pCFromTable;
00285         NM_TREEVIEW* pTreeView = (NM_TREEVIEW*)lParam;
00286
00287         switch(pTreeView->hdr.code)
00288         {
00289           case TVN_BEGINLABELEDIT:
00290           {
00291             //Idicate we have started to edit
00292             pThis->m_fEditing = TRUE;
00293             return FALSE; //Allow the edited change
00294           }
00295
00296           case TVN_ENDLABELEDIT:
00297           {
00298             Busy();
00299             pThis->m_fEditing = FALSE;
00300             TV_DISPINFO* pDispInfo = (TV_DISPINFO*)lParam;
00301
00302             //If Schemas are available - don't allow the change
00303             if(pCFromTable->m_pCDataSource->m_pIDBSchemaRowset)
00304               return FALSE;
00305
00306             //Just need to obtain the new tablename...
00307             if(pDispInfo->item.pszText)
00308             {
00309               //Now update the window TableName myself
00310               TV_ITEM tvItem = { TVIF_TEXT | TVIF_STATE, pDispInfo->item.hItem, TVIS_SELECTED, TVIS_SELECTED, pDispInfo->item.pszText, 0, 0, 0, 0, 0};
00311               SendDlgItemMessage(hWnd, IDL_TABLES, TVM_SETITEM, (WPARAM)0, (LPARAM)&tvItem);
00312
00313               //Change the TableName (if different)
00314               memset(&pThis->m_rgTableInfo[0], 0, sizeof(TABLEINFO));
00315               ConvertToWCHAR(pDispInfo->item.pszText, pThis->m_rgTableInfo[0].wszTableName, MAX_NAME_LEN);
00316               pThis->ChangeTableName(0);
00317             }
00318
00319             //Refresh Controls ("Next" button);
00320             pThis->RefreshControls();
00321             return TRUE; //Allow the edited change
00322           }
00323
00324           case TVN_SELCHANGED:
00325           {
00326             //There is a problem with the SELCHANGED notification
00327             //It can be sent when either a item is selected or
00328             //DELETED, since when an item deleted the selection moves
00329             //to a different selection.
00330             if((pTreeView->itemNew.state == TVIS_SELECTED && pTreeView->action)
00331               || (pTreeView->itemNew.state & TVIS_SELECTED && pTreeView->itemNew.state != TVIS_SELECTED))
00332             {
00333               Busy();
00334               //We assume it sends us the Param of the item
00335               ASSERT(pTreeView->itemNew.mask & TVIF_PARAM);
00336
00337               //Change the TableName (if different)
00338               pThis->ChangeTableName(pTreeView->itemNew.lParam);
00339             }
00340
00341             //Refresh Controls ("Next" button);
00342             pThis->RefreshControls();
00343             return UNHANDLED_MSG;
00344           }
00345         }
00346         return UNHANDLED_MSG;
00347       }//IDL_TABLES
00348       return UNHANDLED_MSG;
00349     }//WM_NOTIFY
00350   }//msg
00351
00352   return UNHANDLED_MSG;
00353 }
00354
00355
00356 /////////////////////////////////////////////////////////////////////////////
00357 // BOOL CS1Dialog::InitControls
00358 //
00359 /////////////////////////////////////////////////////////////////////////////
00360 BOOL CS1Dialog::InitControls()
00361 {
00362   HWND    hWndTable   = GetDlgItem(m_hWnd, IDL_TABLES);
00363   HWND    hWndCol     = GetDlgItem(m_hWnd, IDL_COLUMNS);
00364   HWND    hWndProv    = GetDlgItem(m_hWnd, IDC_PROVIDER_NAME);
00365   CDataSource *pCDataSource = m_pCTableCopy->m_pCFromTable->m_pCDataSource;
00366   HRESULT   hr;
00367
00368   //Create the Table ImageList
00369   HIMAGELIST hTableImageList = ImageList_Create(16, 16, ILC_MASK, 1, 0 );
00370
00371   //IDI_CATALOG - normal catalog icon
00372   HICON hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_CATALOG));
00373   ImageList_AddIcon(hTableImageList, hIcon);
00374   //IDI_SCHEMA - normal schema icon
00375   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_SCHEMA));
00376   ImageList_AddIcon(hTableImageList, hIcon);
00377   //IDI_TYPE - normal type icon
00378   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_TYPE));
00379   ImageList_AddIcon(hTableImageList, hIcon);
00380   //IDI_TABLE - normal table icon
00381   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_TABLE));
00382   ImageList_AddIcon(hTableImageList, hIcon);
00383   //IDI_SYSTABLE - normal system table icon
00384   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_SYSTABLE));
00385   ImageList_AddIcon(hTableImageList, hIcon);
00386   //IDI_VIEW - normal view icon
00387   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_VIEW));
00388   ImageList_AddIcon(hTableImageList, hIcon);
00389   //IDI_SYNONYM - normal synonym icon
00390   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_SYNONYM));
00391   ImageList_AddIcon(hTableImageList, hIcon);
00392
00393   //Set image list to the Table Window
00394   TreeView_SetImageList(hWndTable, hTableImageList, TVSIL_NORMAL);
00395
00396   //Create the Col ImageList
00397   HIMAGELIST hColImageList = ImageList_Create(16, 16, ILC_MASK, 1, 0 );
00398
00399   //IDI_COLUMN - normal column icon
00400   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_COLUMN));
00401   ImageList_AddIcon(hColImageList, hIcon);
00402   //IDI_COLUMNREAD - read-only column icon
00403   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_COLUMNREAD));
00404   ImageList_AddIcon(hColImageList, hIcon);
00405   //IDI_COLUMNLONG - long column icon
00406   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_COLUMNLONG));
00407   ImageList_AddIcon(hColImageList, hIcon);
00408
00409   //Set image list to the Table Window
00410   ListView_SetImageList(hWndCol, hColImageList, LVSIL_SMALL);
00411
00412   //ListView COLUMNS
00413   LV_InsertColumn(hWndCol,  COL_COLNAME,    "ColName");
00414   LV_InsertColumn(hWndCol,  COL_COLTYPE,    "Type");
00415   LV_InsertColumn(hWndCol,  COL_COLSIZE,    "Size");
00416   LV_InsertColumn(hWndCol,  COL_COLORDINAL,   "Ordinal");
00417   LV_InsertColumn(hWndCol,  COL_COLPREC,    "Precision");
00418   LV_InsertColumn(hWndCol,  COL_COLSCALE,   "Scale");
00419   LV_InsertColumn(hWndCol,  COL_COLISFIXED,   "ISFIXED");
00420   LV_InsertColumn(hWndCol,  COL_COLISLONG,    "ISLONG");
00421   LV_InsertColumn(hWndCol,  COL_COLISNULLABLE,  "ISNULLABLE");
00422   LV_InsertColumn(hWndCol,  COL_COLWRITE,   "WRITE");
00423   LV_InsertColumn(hWndCol,  COL_COLISROWID,   "ISROWID");
00424   LV_InsertColumn(hWndCol,  COL_COLISROWVER,  "ISROWVER");
00425
00426   //AutoSize all columns
00427   for(ULONG i=0; i<=COL_COLISROWVER; i++)
00428     SendMessage(hWndCol, LVM_SETCOLUMNWIDTH, (WPARAM)i,   (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
00429
00430   //Use Extended ListView Styles!
00431   SendMessage(hWndCol, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
00432
00433   //Initialize the Provider List (if not done so already)
00434   if(pCDataSource->m_rgProviderInfo == NULL)
00435   {
00436     hr =  pCDataSource->GetProviders();
00437   }
00438
00439   WCHAR wszBuffer[MAX_NAME_LEN*2];
00440
00441   //Fill out the provider name combo box.
00442   for(i=0; i<pCDataSource->m_cProviderInfo; i++)
00443   {
00444     //Add the name to the list
00445     //Since we have the CBS_SORT turned on, the order in the Combo Box does
00446     //not match our array, so we pass the array index (lParam) as the item data
00447     swprintf(wszBuffer, wsz_PROVIDER_INFO_, pCDataSource->m_rgProviderInfo[i].wszName);
00448     LONG iIndex = wSendMessage(hWndProv, CB_ADDSTRING, (WPARAM)0, wszBuffer);
00449     SendMessage(hWndProv, CB_SETITEMDATA, (WPARAM)iIndex, (LPARAM)i);
00450   }
00451
00452   //By default, it selects MSDASQL
00453   if(pCDataSource->m_pwszProviderName == NULL)
00454   {
00455     pCDataSource->m_pwszProviderName = L"MSDASQL";
00456   }
00457
00458   //Try and select the previous selected Provider
00459   if(CB_ERR == wSendMessage(hWndProv, CB_SELECTSTRING, 0, pCDataSource->m_pwszProviderName))
00460   {
00461     //If not found, just select the first one
00462     SendMessage(hWndProv, CB_SETCURSEL, 0, 0);
00463   }
00464
00465   //Indicate were not in the middle of an TreeView editing command
00466   m_fEditing = FALSE;
00467
00468   // Enable Connect button only if there are providers installed.
00469   EnableWindow(GetDlgItem(m_hWnd, IDB_FROM_CONNECT), SendMessage(hWndProv, CB_GETCURSEL, 0, 0L) != CB_ERR);
00470   return TRUE;
00471 }
00472
00473
00474 /////////////////////////////////////////////////////////////////////////////
00475 // BOOL CS1Dialog::RefreshControls
00476 //
00477 /////////////////////////////////////////////////////////////////////////////
00478 BOOL CS1Dialog::RefreshControls()
00479 {
00480   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00481   CDataSource* pCDataSource = pCFromTable->m_pCDataSource;
00482
00483   // Must have a connection to edit other controls
00484   BOOL fConnected = pCFromTable->IsConnected();
00485   ULONG cSelColumns = SendDlgItemMessage(m_hWnd, IDL_COLUMNS, LVM_GETSELECTEDCOUNT, 0, 0);
00486
00487   //Enable dialog items, only if connected
00488   EnableWindow(GetDlgItem(m_hWnd, IDL_TABLES),    fConnected);
00489   EnableWindow(GetDlgItem(m_hWnd, IDL_COLUMNS),   fConnected);
00490   EnableWindow(GetDlgItem(m_hWnd, IDT_FROMTABLEHELP), fConnected);
00491
00492   //Enable OK/Next if there is a table and at least 1 column selected
00493   EnableWindow(GetDlgItem(m_hWnd, IDOK),  fConnected && cSelColumns);
00494
00495   //Store the selected ProviderName and ProviderDesc
00496   LONG iSel = 0;
00497   if((iSel = SendMessage(GetDlgItem(m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR)
00498   {
00499     //Since we have the CBS_SORT turned on, the order in the Combo Box does
00500     //not match our array, so we pass the array index (lParam) as the item data
00501     LONG lParam = SendMessage(GetDlgItem(m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L);
00502     ASSERT(lParam < (LONG)pCDataSource->m_cProviderInfo);
00503     pCDataSource->m_pwszProviderName = pCDataSource->m_rgProviderInfo[lParam].wszName;
00504     pCDataSource->m_pwszProviderParseName = pCDataSource->m_rgProviderInfo[lParam].wszParseName;
00505   }
00506
00507   // Show user the connection string
00508   if(fConnected)
00509   {
00510     //CONNECT_STRING
00511     wSetDlgItemText(m_hWnd, IDT_CONNECT, wsz_CONNECT_STRING_,
00512       pCDataSource->m_pwszProviderName,
00513       pCDataSource->m_pwszDataSource,
00514       pCDataSource->m_pwszDBMS,
00515       pCDataSource->m_pwszDBMSVer,
00516       pCDataSource->m_pwszProviderFileName,
00517       pCDataSource->m_pwszProviderVer);
00518
00519     //TABLEHELPMSG
00520     //Display the Qualified TableName
00521     if(pCFromTable->m_TableInfo.wszTableName[0])
00522       wSetDlgItemText(m_hWnd, IDT_FROMTABLEHELP, wsz_FROMQUALTABLE_, pCFromTable->m_wszQualTableName, cSelColumns);
00523     else
00524       wSetDlgItemText(m_hWnd, IDT_FROMTABLEHELP, wsz_FROMTABLEHELP_, pCDataSource->m_pwszTableTerm);
00525   }
00526   else
00527   {
00528     //NO CONNECT_STRING
00529     wSetDlgItemText(m_hWnd, IDT_CONNECT, wsz_NOT_CONNECTED);
00530   }
00531
00532   return TRUE;
00533 }
00534
00535
00536
00537 /////////////////////////////////////////////////////////////////////////////
00538 // BOOL CS1Dialog::GetTableColInfo
00539 //
00540 /////////////////////////////////////////////////////////////////////////////
00541 BOOL CS1Dialog::GetTableColInfo(HWND hWndCol)
00542 {
00543   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00544
00545   // Get the count of selected items
00546   LONG cSelColumns = SendMessage(hWndCol, LVM_GETSELECTEDCOUNT, (WPARAM)0, (LPARAM)0);
00547   LONG iIndex = -1;
00548
00549   //Loop over all the selected columns in the list
00550   pCFromTable->m_cColumns = cSelColumns;
00551   for(LONG i=0; i<cSelColumns; i++)
00552   {
00553     iIndex = SendMessage(hWndCol, LVM_GETNEXTITEM, (WPARAM)iIndex, (LPARAM)LVNI_SELECTED);
00554
00555     //"compact" the m_rgColDesc array to only the selected items
00556     if(iIndex != LVM_ERR)
00557       memmove(&pCFromTable->m_rgColDesc[i], &pCFromTable->m_rgColDesc[iIndex], sizeof(COLDESC));
00558   }
00559   return TRUE;
00560 }
00561
00562
00563 /////////////////////////////////////////////////////////////////////////////
00564 // BOOL CS1Dialog::CreateTableNode
00565 //
00566 /////////////////////////////////////////////////////////////////////////////
00567 BOOL CS1Dialog::CreateTableNode(TREEINFO* rgTreeInfo, ULONG ulNameOffset, LONG iParam, LONG iImage, LONG iSelectedImage)
00568 {
00569   //ulNameOffset is the offset into TABELEINFO indicating
00570   //Catalog / Schema / Type name were interested in comparing
00571   ASSERT(ulNameOffset == offsetof(TABLEINFO, wszCatalogName)
00572     || ulNameOffset == offsetof(TABLEINFO, wszSchemaName)
00573     || ulNameOffset == offsetof(TABLEINFO, wszType));
00574
00575   //Create the specified node in the tree.
00576   //Basically this is a fairly complex function that builds the nodes to the
00577   //TreeView control, listing Catalog/Schema/TableType/TableName heieracrcy.
00578
00579   //This is an extremly simple algortym that loops over the specified column
00580   //(Catalog/Schema/Type) and adds only unique names as a node to the TreeView.
00581   //It then updates "rgTreeInfo" hParents and hItems accordingly.
00582
00583   CHAR szBuffer[MAX_NAME_LEN];
00584
00585   //Loop over all Tables
00586   ULONG cFoundInfo = 0;
00587   for(ULONG i=0; i<m_cTables; i++)
00588   {
00589     BOOL bFound = FALSE;
00590     WCHAR* pwszName = (WCHAR*)((BYTE*)&m_rgTableInfo[i] + ulNameOffset);
00591
00592     //Try to find Type value in the FoundList
00593     for(ULONG j=0; j<cFoundInfo; j++)
00594     {
00595       ULONG ulFoundIndex = rgTreeInfo[j].ulIndex;
00596       WCHAR* pwszFoundName = (WCHAR*)((BYTE*)&m_rgTableInfo[ulFoundIndex] + ulNameOffset);
00597
00598       if(wcscmp(pwszName, pwszFoundName)==0
00599         && rgTreeInfo[i].hParent == rgTreeInfo[ulFoundIndex].hParent)
00600       {
00601         bFound = TRUE;
00602         rgTreeInfo[i].hItem = rgTreeInfo[ulFoundIndex].hItem;
00603         break;
00604       }
00605     }
00606
00607     if(!bFound && pwszName[0])
00608     {
00609       //Add it to the list
00610       rgTreeInfo[cFoundInfo].ulIndex = i;
00611       cFoundInfo++;
00612
00613       //Add it to the TreeView
00614       ConvertToMBCS(pwszName, szBuffer, MAX_NAME_LEN);
00615       rgTreeInfo[i].hItem = TV_InsertItem(GetDlgItem(m_hWnd, IDL_TABLES), rgTreeInfo[i].hParent, TVI_SORT, szBuffer, iParam, iImage, iSelectedImage);
00616     }
00617   }
00618
00619   //Update Parents
00620   for(i=0; i<m_cTables; i++)
00621     rgTreeInfo[i].hParent = rgTreeInfo[i].hItem;
00622
00623   return TRUE;
00624 }
00625
00626 /////////////////////////////////////////////////////////////////////////////
00627 // BOOL CS1Dialog::ResetTableList
00628 //
00629 /////////////////////////////////////////////////////////////////////////////
00630 BOOL CS1Dialog::ResetTableList(HWND hWndTable, HWND hWndCol)
00631 {
00632   HRESULT hr;
00633   CHAR      szBuffer[MAX_NAME_LEN];
00634
00635   IRowset* pIRowset = NULL;
00636   IAccessor* pIAccessor = NULL;
00637
00638   //get the data
00639   HROW* rghRows = NULL;
00640   ULONG i,cRowsObtained = 0;
00641   BOOL    bFound = FALSE;
00642
00643   HACCESSOR hAccessor = DB_NULL_HACCESSOR;
00644   TREEINFO* rgTreeInfo = NULL;
00645
00646   //Use the passed in Session interface
00647   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00648   CDataSource* pCFromDataSource = pCFromTable->m_pCDataSource;
00649   IOpenRowset* pIOpenRowset = pCFromTable->m_pCDataSource->m_pIOpenRowset;
00650   IDBSchemaRowset* pIDBSchemaRowset = pCFromTable->m_pCDataSource->m_pIDBSchemaRowset;
00651
00652   //Delete all previous items
00653   SendMessage(hWndTable, TVM_DELETEITEM, (WPARAM)0, (LPARAM)TVI_ROOT);
00654   SendMessage(hWndCol, LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0);
00655
00656   // Bind the user and table name for the list
00657   const static ULONG cBindings = 4;
00658   const static DBBINDING rgBindings[cBindings] =
00659   {
00660     //TABLE_CATALOG
00661     1,
00662     offsetof(TABLEINFO, wszCatalogName),  // offset of value in consumers buffer
00663     0,                  // offset of length
00664     0,                  // offset of status
00665     NULL,               // reserved
00666     NULL,               // for ole object
00667     NULL,               // reserved
00668     DBPART_VALUE,           // specifies Value is bound only
00669     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
00670     DBPARAMIO_NOTPARAM,         //
00671     MAX_NAME_LEN,           // size in bytes of the value part in the consumers buffer
00672     0,                  // reserved
00673     DBTYPE_WSTR,            // data type indicator
00674     0,                  // precision
00675     0,                  // scale
00676
00677     //TABLE_SCHEMA
00678     2,
00679     offsetof(TABLEINFO, wszSchemaName), // offset of value in consumers buffer
00680     0,                  // offset of length
00681     0,                  // offset of status
00682     NULL,               // reserved
00683     NULL,               // for ole object
00684     NULL,               // reserved
00685     DBPART_VALUE,           // specifies Value is bound only
00686     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
00687     DBPARAMIO_NOTPARAM,         //
00688     MAX_NAME_LEN,           // size in bytes of the value part in the consumers buffer
00689     0,                  // reserved
00690     DBTYPE_WSTR,            // data type indicator
00691     0,                  // precision
00692     0,                  // scale
00693
00694     //TABLE_NAME
00695     3,                  // ordinal
00696     offsetof(TABLEINFO, wszTableName),    // offset of value in consumers buffer
00697     0,                  // offset of length in consumers buffer
00698     0,                  // offset of status in consumers buffer
00699     NULL,               // reserved
00700     NULL,               // for ole object
00701     NULL,               // reserved
00702     DBPART_VALUE,           // specifies Value only
00703     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
00704     DBPARAMIO_NOTPARAM,         // input param
00705     MAX_NAME_LEN,           // size in bytes of the value part in the consumers buffer
00706     0,                  // reserved
00707     DBTYPE_WSTR,            // data type indicator
00708     0,                  // precision
00709     0,                  // scale
00710
00711     //TABLE_TYPE
00712     4,                  // ordinal
00713     offsetof(TABLEINFO, wszType), // offset of value in consumers buffer
00714     0,                  // offset of length in consumers buffer
00715     0,                  // offset of status in consumers buffer
00716     NULL,               // reserved
00717     NULL,               // for ole object
00718     NULL,               // reserved
00719     DBPART_VALUE,           // specifies Value only
00720     DBMEMOWNER_CLIENTOWNED,       // memory is client owned
00721     DBPARAMIO_NOTPARAM,         // input param
00722     MAX_NAME_LEN,           // size in bytes of the value part in the consumers buffer
00723     0,                  // reserved
00724     DBTYPE_WSTR,            // data type indicator
00725     0,                  // precision
00726     0,                  // scale
00727     };
00728
00729   //Reset TableInfo
00730   m_cTables = 0;
00731   SAFE_FREE(m_rgTableInfo);
00732
00733   //Provider doesn't have to support IDBSchemaRowset
00734   if(pIDBSchemaRowset)
00735   {
00736     //GetRowset
00737     //DBSCHEMA_TABLES is required a SCHEMA (if IDBSchemaRowset is supported)
00738     XTESTC(hr = pIDBSchemaRowset->GetRowset(NULL, DBSCHEMA_TABLES, 0, NULL, IID_IRowset, 0, NULL,(IUnknown **)&pIRowset));
00739
00740     //Create the Accessor
00741     XTESTC(hr = pIRowset->QueryInterface(IID_IAccessor, (void **)&pIAccessor));
00742     XTESTC(hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, 0, &hAccessor, NULL));
00743
00744     //Grab all the rows
00745     while(TRUE)
00746     {
00747       XTESTC(hr = pIRowset->GetNextRows(NULL, 0, MAX_BLOCK_SIZE, &cRowsObtained, &rghRows));
00748
00749       //ENDOFROWSET
00750       if(cRowsObtained==0)
00751         break;
00752
00753       //Realloc Table struct for Table
00754       SAFE_REALLOC(m_rgTableInfo, TABLEINFO, m_cTables + cRowsObtained);
00755       memset(&m_rgTableInfo[m_cTables], 0, cRowsObtained*sizeof(TABLEINFO));
00756
00757       //Loop over the rows retrived
00758       for(i=0; i<cRowsObtained; i++)
00759       {
00760         //Get the Data
00761         XTESTC(hr = pIRowset->GetData(rghRows[i], hAccessor, &m_rgTableInfo[m_cTables]));
00762         m_cTables++;
00763       }
00764
00765       //Release the rows obtained
00766       XTESTC(hr = pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL));
00767       SAFE_FREE(rghRows);
00768     }
00769   }
00770
00771   //Provider doesn't have to support IDBSchemaRowset
00772   if(pIDBSchemaRowset == NULL)
00773   {
00774     m_cTables = 1;
00775     SAFE_ALLOC(m_rgTableInfo, TABLEINFO, 1);
00776     memset(m_rgTableInfo, 0, sizeof(TABLEINFO));
00777
00778     if(pCFromTable->m_TableInfo.wszTableName[0])
00779     {
00780       //Just Display the TableName in the EditBox
00781       wcscpy(m_rgTableInfo[0].wszTableName, pCFromTable->m_TableInfo.wszTableName);
00782     }
00783     else
00784     {
00785       //Just Display "Enter - <TableTerm>"
00786       wcscpy(m_rgTableInfo[0].wszTableName, L"Enter - ");
00787       wcscat(m_rgTableInfo[0].wszTableName, pCFromDataSource->m_pwszTableTerm);
00788     }
00789   }
00790
00791
00792   //Create rgTreeInfo array
00793   SAFE_ALLOC(rgTreeInfo, TREEINFO, m_cTables);
00794   memset(rgTreeInfo, 0, m_cTables*sizeof(TREEINFO));
00795
00796   //Create Tree Nodes for the TreeView control
00797   CreateTableNode(rgTreeInfo, offsetof(TABLEINFO, wszCatalogName), -1, ICON_CATALOG, ICON_CATALOG);
00798   CreateTableNode(rgTreeInfo, offsetof(TABLEINFO, wszSchemaName),  -1, ICON_SCHEMA, ICON_SCHEMA);
00799   CreateTableNode(rgTreeInfo, offsetof(TABLEINFO, wszType),    -1, ICON_TYPE, ICON_TYPE);
00800
00801   //Now display all the tables
00802   for(i=0; i<m_cTables; i++)
00803   {
00804     //Add it to the TreeView
00805     ConvertToMBCS(m_rgTableInfo[i].wszTableName, szBuffer, MAX_NAME_LEN);
00806
00807     if(wcscmp(m_rgTableInfo[i].wszType, L"TABLE")==0)
00808       rgTreeInfo[i].hItem = TV_InsertItem(hWndTable, rgTreeInfo[i].hParent, TVI_SORT, szBuffer, (LONG)i, ICON_TABLE, ICON_TABLE);
00809     else if(wcscmp(m_rgTableInfo[i].wszType, L"VIEW")==0)
00810       rgTreeInfo[i].hItem = TV_InsertItem(hWndTable, rgTreeInfo[i].hParent, TVI_SORT, szBuffer, (LONG)i, ICON_VIEW, ICON_VIEW);
00811     else if(wcscmp(m_rgTableInfo[i].wszType, L"SYSTEM TABLE")==0)
00812       rgTreeInfo[i].hItem = TV_InsertItem(hWndTable, rgTreeInfo[i].hParent, TVI_SORT, szBuffer, (LONG)i, ICON_SYSTABLE, ICON_SYSTABLE);
00813     else
00814       rgTreeInfo[i].hItem = TV_InsertItem(hWndTable, rgTreeInfo[i].hParent, TVI_SORT, szBuffer, (LONG)i, ICON_SYNONYM, ICON_SYNONYM);
00815   }
00816
00817   // If there was a previous selection, select it again on Back
00818   bFound = FALSE;
00819     if(pCFromTable->m_TableInfo.wszTableName[0])
00820   {
00821     //Find the previously selected TableName
00822     //With TreeView controls there is no "Find" method as in ListView controls!
00823     //So we have to simulate our own find, by seraching for the TableName
00824     for(i=0; i<m_cTables; i++)
00825     {
00826       if(memcmp(&m_rgTableInfo[i], &pCFromTable->m_TableInfo, sizeof(TABLEINFO))==0)
00827       {
00828         bFound = TRUE;
00829         //Select Table in the TreeView control
00830         SendMessage(hWndTable, TVM_SELECTITEM, (WPARAM)TVGN_CARET, (LPARAM)rgTreeInfo[i].hItem);
00831         ResetColInfo(GetDlgItem(m_hWnd, IDL_COLUMNS));
00832         break;
00833       }
00834     }
00835   }
00836
00837   if(!bFound)
00838   {
00839     //Reset TableInfo
00840     memset(&pCFromTable->m_TableInfo, 0, sizeof(TABLEINFO));
00841
00842     //Otheriwse if there was no previous selection, default to auto expand
00843     //the "TABLE" type, or the first type in the tree
00844     bFound = FALSE;
00845     for(i=0; i<m_cTables; i++)
00846     {
00847       if(wcscmp(m_rgTableInfo[i].wszType, L"TABLE")==0)
00848       {
00849         bFound = TRUE;
00850         SendMessage(hWndTable, TVM_ENSUREVISIBLE, (WPARAM)0, (LPARAM)rgTreeInfo[i].hItem);
00851         break;
00852       }
00853     }
00854
00855     if(!bFound && m_cTables)
00856       SendMessage(hWndTable, TVM_ENSUREVISIBLE, (WPARAM)0, (LPARAM)rgTreeInfo[0].hItem);
00857   }
00858
00859
00860 CLEANUP:
00861   if(hAccessor && pIAccessor)
00862     XTEST(pIAccessor->ReleaseAccessor(hAccessor,NULL));
00863
00864   SAFE_RELEASE(pIRowset);
00865   SAFE_RELEASE(pIAccessor);
00866
00867   SAFE_FREE(rgTreeInfo);
00868   SAFE_FREE(rghRows);
00869   return hr==S_OK;
00870 }
00871
00872
00873 /////////////////////////////////////////////////////////////////////////////
00874 // BOOL CS1Dialog::ResetColInfo
00875 //
00876 /////////////////////////////////////////////////////////////////////////////
00877 BOOL CS1Dialog::ResetColInfo(HWND hWndCol)
00878 {
00879   HRESULT hr;
00880   CHAR  szBuffer[MAX_NAME_LEN];
00881   ULONG i;
00882   LONG    lFoundColumn;
00883
00884   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00885   IOpenRowset* pIOpenRowset = pCFromTable->m_pCDataSource->m_pIOpenRowset;
00886
00887   //Save the currently selected columns
00888   ULONG cSelColumns = pCFromTable->m_cColumns;
00889   COLDESC* rgSelColDesc = pCFromTable->m_rgColDesc;
00890
00891   //Reset current Window Column ListView
00892   SendMessage(hWndCol, LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0L);
00893
00894   // Get a list of columns based on the selected table
00895   pCFromTable->m_cColumns = 0;
00896   pCFromTable->m_rgColDesc = NULL;
00897   QTESTC(hr = pCFromTable->GetColInfo(IDR_PARAM_SETS));
00898
00899   //Loop through all columns and update window
00900   for(i=0; i<pCFromTable->m_cColumns; i++)
00901   {
00902     COLDESC* pColDesc = &pCFromTable->m_rgColDesc[i];
00903
00904     //COLNAME (item)
00905     ConvertToMBCS(pColDesc->wszColName, szBuffer, MAX_NAME_LEN);
00906     LV_InsertItem(hWndCol, i, COL_COLNAME, szBuffer, 0, pColDesc->dwFlags & (DBCOLUMNFLAGS_WRITE | DBCOLUMNFLAGS_WRITEUNKNOWN) ? ((pColDesc->dwFlags & DBCOLUMNFLAGS_ISLONG) ? ICON_LONG : ICON_COLUMN) : ICON_READONLY);
00907
00908     //COLTYPE (subitem)
00909     ConvertToMBCS(GetDBTypeName(pColDesc->wType), szBuffer, MAX_NAME_LEN);
00910     LV_InsertItem(hWndCol, i, COL_COLTYPE, szBuffer);
00911
00912     //Ordinal (SubItem)
00913     sprintf(szBuffer, "%d", pColDesc->iOrdinal);
00914     LV_InsertItem(hWndCol, i, COL_COLORDINAL, szBuffer);
00915
00916     //ColumnSize (SubItem)
00917     sprintf(szBuffer, "%d", pColDesc->ulColumnSize);
00918     LV_InsertItem(hWndCol, i, COL_COLSIZE, szBuffer);
00919
00920     //Precision (SubItem)
00921     sprintf(szBuffer, "%d", pColDesc->bPrecision);
00922     LV_InsertItem(hWndCol, i, COL_COLPREC, szBuffer);
00923
00924     //Scale (SubItem)
00925     sprintf(szBuffer, "%d", pColDesc->bScale);
00926     LV_InsertItem(hWndCol, i, COL_COLSCALE, szBuffer);
00927
00928     //FLAGS (SubItem)
00929     LV_InsertItem(hWndCol, i, COL_COLISFIXED, pColDesc->dwFlags & DBCOLUMNFLAGS_ISFIXEDLENGTH ? "TRUE" : "FALSE");
00930     LV_InsertItem(hWndCol, i, COL_COLISLONG, pColDesc->dwFlags & DBCOLUMNFLAGS_ISLONG ? "TRUE" : "FALSE");
00931     LV_InsertItem(hWndCol, i, COL_COLISNULLABLE, pColDesc->dwFlags & DBCOLUMNFLAGS_ISNULLABLE ? "TRUE" : "FALSE");
00932     LV_InsertItem(hWndCol, i, COL_COLWRITE, pColDesc->dwFlags & (DBCOLUMNFLAGS_WRITE | DBCOLUMNFLAGS_WRITEUNKNOWN) ? "TRUE" : "FALSE");
00933     LV_InsertItem(hWndCol, i, COL_COLISROWID, pColDesc->dwFlags & DBCOLUMNFLAGS_ISROWID ? "TRUE" : "FALSE");
00934     LV_InsertItem(hWndCol, i, COL_COLISROWVER, pColDesc->dwFlags & DBCOLUMNFLAGS_ISROWVER ? "TRUE" : "FALSE");
00935
00936   }
00937
00938   // If there is an existing columns list (only on Back or error), then
00939   // the user already has a list so use it.
00940   lFoundColumn = -1;
00941   for(i=0; i<cSelColumns; i++)
00942   {
00943     //Find the Column Name in the Window List
00944     ConvertToMBCS(rgSelColDesc[i].wszColName, szBuffer, MAX_NAME_LEN);
00945     lFoundColumn = LV_FindItem(hWndCol, szBuffer, lFoundColumn);
00946
00947     //Select the Column Name if found in the list, and bring into view
00948     if(lFoundColumn != LVM_ERR)
00949     {
00950       LV_SetItemState(hWndCol, lFoundColumn, COL_COLNAME, LVIS_SELECTED, LVIS_SELECTED);
00951
00952       //Ensure that the first item is Visible
00953       if(i==0)
00954         SendMessage(hWndCol, LVM_ENSUREVISIBLE, (WPARAM)lFoundColumn, (LPARAM)FALSE);
00955     }
00956   }
00957
00958   //Otherwise, just select all as default
00959   if(cSelColumns == 0)
00960   {
00961     for(i=0; i<pCFromTable->m_cColumns; i++)
00962       LV_SetItemState(hWndCol, i, COL_COLNAME, LVIS_SELECTED, LVIS_SELECTED);
00963   }
00964
00965 CLEANUP:
00966   SAFE_FREE(rgSelColDesc);
00967   return hr==S_OK;
00968 }
00969
00970
00971 /////////////////////////////////////////////////////////////////////////////
00972 // BOOL CS1Dialog::ChangeTableName
00973 //
00974 /////////////////////////////////////////////////////////////////////////////
00975 BOOL CS1Dialog::ChangeTableName(LONG iIndex)
00976 {
00977   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00978   CTable* pCToTable = m_pCTableCopy->m_pCToTable;
00979
00980   //Index must fall with the m_rgTableInfo array range
00981   //Otherwise we have selected a "tree-folder" and need to free the column list
00982   if(iIndex < 0 || iIndex >= (LONG)m_cTables)
00983   {
00984     //Resest TableName
00985     memset(&pCFromTable->m_TableInfo, 0, sizeof(TABLEINFO));
00986
00987     //Reset current Window Column ListView
00988     SendMessage(GetDlgItem(m_hWnd, IDL_COLUMNS), LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0L);
00989     return FALSE;
00990   }
00991
00992   //Only change the TableName if not equal to "Enter - <TableTerm>"
00993   if(wcsstr(m_rgTableInfo[iIndex].wszTableName, L"Enter - "))
00994     return FALSE;
00995
00996   //TableInfo
00997   memcpy(&pCFromTable->m_TableInfo, &m_rgTableInfo[iIndex], sizeof(TABLEINFO));
00998
00999   //QualifiedTableName syntax
01000   // #1.  TableName
01001   // #2.  Owner.TableName (always a ".")
01002   // #3.  Catalog[CatalogSeperator]TableName
01003   // #4.  Catalog[CatalogSeperator]Owner.TableName
01004   if(pCFromTable->m_TableInfo.wszSchemaName[0])
01005     swprintf(pCFromTable->m_wszQualTableName, L"%s.%s", pCFromTable->m_TableInfo.wszSchemaName, pCFromTable->m_TableInfo.wszTableName);
01006   else
01007     wcscpy(pCFromTable->m_wszQualTableName, pCFromTable->m_TableInfo.wszTableName);
01008
01009   //Free the current columns list, since the new
01010   //table will have diffent columns
01011   pCFromTable->m_cColumns = 0;
01012   SAFE_FREE(pCFromTable->m_rgColDesc);
01013
01014   //Reset the column list, since we have a new table
01015   ResetColInfo(GetDlgItem(m_hWnd, IDL_COLUMNS));
01016
01017   //Reset the index list, since we have a new table
01018   pCFromTable->m_cIndexes = 0;
01019   SAFE_FREE(pCFromTable->m_rgIndexInfo);
01020
01021   //Reset the "To" table, since we have a new table
01022   memset(&pCToTable->m_TableInfo, 0, sizeof(TABLEINFO));
01023   return TRUE;
01024 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Printer/Printer.c Source File

  • Multimedia
  • Gdi
  • Printer

Printer.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /******************************************************************************\
00013 *
00014 *  PROGRAM:     PRINTER.C
00015 *
00016 *  PURPOSE:     This is a sample application demostrating some of the new
00017 *               printing functionality in Windows NT. This app allows the
00018 *               user to select between various GDI graphics primitives,
00019 *               to choose pen & brush colors, styles, and sizes, and to
00020 *               the print these graphics to a printer. Also, the app
00021 *               provides the user the ability to query information (reso-
00022 *               lution, etc.) about the various printers & drivers by
00023 *               making calls to GetDeviceCaps, etc.
00024 *
00025 *               Functionality for PRINTER is split into six different
00026 *               modules as follows:
00027 *
00028 *                 printer.c - main event loop
00029 *                             main window procedure
00030 *                             about & abort dialog procedures
00031 *                             printing thread
00032 *
00033 *                 paint.c   - handles all painting printers & most painting
00034 *                             to window
00035 *
00036 *                 enumprt.c - manages the display of information returned
00037 *                             from calling EnumPrinters, EnumPrinterDrivers
00038 *
00039 *                 devcapsx.c- manages the display of information returned
00040 *                             from calling DeviceCapabilitiesEx
00041 *
00042 *                 getpdriv.c- manages the display of information returned
00043 *                             from calling GetPrinterDriver
00044 *
00045 *                 getcaps.c - manages the display of information returned
00046 *                             from calling GetDeviceCaps
00047 *
00048 *  FUNCTIONS:   WinMain               - initialization, create window, msg loop
00049 *               MainWndProc           - processes main window msgs
00050 *               AboutDlgProc          - processes About dlg msgs
00051 *               InvalidateClient      - invalidates graphics part of client wnd
00052 *               RefreshPrinterCombobox- updates list of printers
00053 *               PrintThread           - printing done here
00054 *               AbortProc             - msg loop for abort
00055 *               AbortDlgProc          - processes abort dialog messages
00056 *
00057 \******************************************************************************/
00058 #include <windows.h>
00059 #include <stdio.h>
00060 #include <string.h>
00061 #include <stdlib.h> // for _mbstrlen
00062 #include <winspool.h>
00063 #include <commdlg.h>
00064 #include "common.h"
00065 #include "resource.h"
00066 #include "printer.h"
00067
00068 // for internationalization
00069 #define My_mbslen _mbstrlen
00070
00071 /******************************************************************************\
00072 *
00073 *  FUNCTION:    WinMain (standard WinMain INPUTS/RETURNS)
00074 *
00075 *  COMMENTS:    Register & create main window, loop for messages
00076 *
00077 \******************************************************************************/
00078
00079 int WINAPI WinMain (HINSTANCE ghInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
00080                     int    nCmdShow)
00081 {
00082   MSG msg;
00083
00084   ghInst = ghInstance;
00085
00086   if (!hPrevInstance)
00087   {
00088     WNDCLASS wc;
00089
00090     wc.style         = MAIN_CLASS_STYLE;
00091     wc.lpfnWndProc   = (WNDPROC) MainWndProc;
00092     wc.cbClsExtra    = 0;
00093     wc.cbWndExtra    = 0;
00094     wc.hInstance     = ghInst;
00095     wc.hIcon         = LoadIcon (ghInst, MAKEINTRESOURCE(MAIN_ICON));
00096     wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
00097     wc.hbrBackground = NULL;
00098     wc.lpszMenuName  = (LPCSTR) MAIN_MENU_NAME;
00099     wc.lpszClassName = (LPCSTR) MAIN_CLASS_NAME;
00100
00101     if (!RegisterClass (&wc))
00102     {
00103       MessageBox (NULL, "WinMain(): RegisterClass() failed",
00104                   GetStringRes2(ERR_MOD_NAME), MB_OK | MB_ICONHAND);
00105
00106       return FALSE;
00107     }
00108   }
00109
00110   if (!(ghwndMain = CreateWindow ((LPCSTR) MAIN_CLASS_NAME,
00111                                   (LPCSTR) GetStringRes(MAIN_WND_TITLE),
00112                                   MAIN_WND_STYLE,
00113                                   CW_USEDEFAULT, CW_USEDEFAULT,
00114                                   CW_USEDEFAULT, CW_USEDEFAULT,
00115                                   NULL, NULL, ghInst, NULL)))
00116     return FALSE;
00117
00118   ShowWindow (ghwndMain, nCmdShow);
00119
00120   while (GetMessage (&msg, NULL, 0, 0))
00121   {
00122     TranslateMessage (&msg);
00123     DispatchMessage  (&msg);
00124   }
00125
00126   return (int)msg.wParam;
00127 }
00128
00129
00130
00131 /******************************************************************************\
00132 *
00133 *  FUNCTION:    MainWndProc (standard window procedure INPUTS/RETURNS)
00134 *
00135 *  COMMENTS:    Handles main app window msg processing
00136 *
00137 \******************************************************************************/
00138
00139 LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00140 {
00141   static HMENU hMappingModesSubMenu;
00142   static HMENU hGraphicsSubMenu;
00143   static HMENU hPenWidthSubMenu;
00144   static HMENU hPenStyleSubMenu;
00145   static HMENU hBrushStyleSubMenu;
00146   static HWND  hwndCombobox;
00147   static int   iComboboxWidth;
00148   static LONG  lTextHeight;
00149
00150   int i;
00151
00152   switch (msg)
00153   {
00154     case WM_COMMAND:
00155
00156       switch (LOWORD (wParam))
00157       {
00158         case IDM_PRINT:
00159         case IDM_PRINTDLG:
00160         {
00161           DWORD  threadId;
00162       HANDLE hThread;
00163
00164           if (!(hThread = CreateThread (NULL, 0,
00165                        (LPTHREAD_START_ROUTINE) PrintThread,
00166                              (LPVOID) wParam, 0, &threadId)))
00167             MessageBox (hwnd,
00168                         "MainWndProc(): Error creating print thread",
00169                         GetStringRes2(ERR_MOD_NAME), MB_OK | MB_ICONHAND);
00170       else
00171         CloseHandle(hThread);
00172           break;
00173         }
00174
00175         case IDM_GETDEVICECAPS:
00176
00177           DialogBox (ghInst, (LPCTSTR) "List", hwnd,
00178                      (DLGPROC) GetDeviceCapsDlgProc);
00179           break;
00180
00181         case IDM_ENUMPRINTERS:
00182
00183           DialogBox (ghInst, (LPCTSTR) "List", hwnd,
00184                      (DLGPROC) EnumPrintersDlgProc);
00185           break;
00186
00187         case IDM_GETPRINTERDRIVER:
00188
00189           if (strcmp (gszDeviceName, "Display"))
00190
00191             DialogBox (ghInst, (LPCTSTR) "List", hwnd,
00192                        (DLGPROC) GetPrinterDriverDlgProc);
00193           else
00194
00195             MessageBox (hwnd, (LPCTSTR) GetStringRes(IDS_ASKSELPRT),
00196                         (LPCTSTR) "PRINTER.EXE:", MB_OK);
00197
00198           break;
00199
00200         case IDM_ENUMPRINTERDRIVERS:
00201
00202           DialogBox (ghInst, (LPCTSTR) "List", hwnd,
00203                      (DLGPROC) EnumPrinterDriversDlgProc);
00204           break;
00205
00206         case IDM_REFRESH:
00207
00208           RefreshPrinterCombobox (hwndCombobox);
00209           break;
00210
00211         case IDM_ABOUT:
00212
00213           DialogBox (ghInst, (LPCTSTR) "About", hwnd, (DLGPROC) AboutDlgProc);
00214           break;
00215
00216     case IDM_EXIT:
00217       DestroyWindow (hwnd);
00218       break;
00219
00220         case IDM_HIENGLISH:
00221         case IDM_HIMETRIC:
00222         case IDM_LOENGLISH:
00223         case IDM_LOMETRIC:
00224         case IDM_TWIPS:
00225         case IDM_ISOTROPIC:
00226         case IDM_ANISOTROPIC:
00227         case IDM_TEXT:
00228
00229           //
00230           // Uncheck the last map mode menuitem, check the new map mode
00231           //   menuitem, set iMappingMode according to menu id, cause a
00232           //   repaint
00233           //
00234
00235           for (i = 0; i < MAX_MAP_MODES; i++)
00236
00237             if (giMapMode == gaMMLookup[i].iMapMode)
00238             {
00239               CheckMenuItem (hMappingModesSubMenu, gaMMLookup[i].wMenuItem,
00240                              MF_UNCHECKED | MF_BYCOMMAND);
00241               break;
00242             }
00243
00244           CheckMenuItem (hMappingModesSubMenu, LOWORD (wParam),
00245                          MF_CHECKED | MF_BYCOMMAND);
00246
00247           for (i = 0; i < MAX_MAP_MODES; i++)
00248
00249             if (LOWORD (wParam) == gaMMLookup[i].wMenuItem)
00250             {
00251               giMapMode = gaMMLookup[i].iMapMode;
00252               break;
00253             }
00254
00255           //
00256           // invalidate the entire client so toolbar text gets updated
00257           //
00258
00259           InvalidateRect (hwnd, NULL, TRUE);
00260           break;
00261
00262         case IDM_ARC:
00263         case IDM_ELLIPSE:
00264         case IDM_LINETO:
00265         case IDM_PIE:
00266         case IDM_PLGBLT:
00267         case IDM_POLYBEZIER:
00268         case IDM_POLYGON:
00269         case IDM_POLYLINE:
00270         case IDM_POLYPOLYGON:
00271         case IDM_RECTANGLE:
00272         case IDM_ROUNDRECT:
00273         case IDM_STRETCHBLT:
00274         {
00275           //
00276           // Retrieve the DWORD flag value for the particular menuitem,
00277           //   toggle (un/check) the menuitem, set/clear the flag in
00278           //   gdwGraphicsOptions, cause a repaint
00279           //
00280
00281           DWORD dwGraphic;
00282
00283           for (i = 0; i < MAX_GRAPHICS; i++)
00284
00285             if (LOWORD (wParam) == gaGraphicLookup[i].wMenuItem)
00286             {
00287               dwGraphic = gaGraphicLookup[i].dwGraphic;
00288               break;
00289             }
00290
00291           if (GetMenuState (hGraphicsSubMenu, LOWORD(wParam), MF_BYCOMMAND)
00292               & MF_CHECKED)
00293
00294           {
00295             gdwGraphicsOptions &= ~dwGraphic;
00296             CheckMenuItem (hGraphicsSubMenu, LOWORD(wParam),
00297                             MF_UNCHECKED | MF_BYCOMMAND);
00298           }
00299           else
00300           {
00301             //
00302             // Clear/uncheck the ENUMFONTS flag/menuitem
00303             //
00304
00305             gdwGraphicsOptions &= ~ENUMFONTS;
00306             CheckMenuItem (hGraphicsSubMenu, IDM_ENUMFONTS,
00307                            MF_UNCHECKED | MF_BYCOMMAND);
00308
00309             gdwGraphicsOptions |= dwGraphic;
00310             CheckMenuItem (hGraphicsSubMenu, LOWORD(wParam),
00311                             MF_CHECKED | MF_BYCOMMAND);
00312           }
00313           InvalidateClient ();
00314           break;
00315         }
00316
00317         case IDM_ALLGRAPHICS:
00318
00319           //
00320           // Clear/uncheck the ENUMFONTS flag/menuitem, set/check all
00321           //   other graphics flags/menuitems, cause a repaint
00322           //
00323
00324           CheckMenuItem (hGraphicsSubMenu, IDM_ENUMFONTS,
00325                           MF_UNCHECKED | MF_BYCOMMAND);
00326
00327           for (i = 0; i < MAX_GRAPHICS; i++)
00328
00329             CheckMenuItem (hGraphicsSubMenu, IDM_ARC + i,
00330                            MF_CHECKED | MF_BYCOMMAND);
00331
00332           gdwGraphicsOptions = ALLGRAPHICS | (gdwGraphicsOptions & DRAWAXIS);
00333
00334           InvalidateClient ();
00335           break;
00336
00337         case IDM_NOGRAPHICS:
00338
00339           //
00340           // Clear/uncheck all graphics flags/menuitems, cause a repaint
00341           //
00342
00343           for (i = 0; i < MAX_GRAPHICS; i++)
00344
00345             CheckMenuItem (hGraphicsSubMenu, IDM_ARC + i,
00346                            MF_UNCHECKED | MF_BYCOMMAND);
00347
00348           gdwGraphicsOptions &= (DRAWAXIS | ENUMFONTS);
00349
00350           InvalidateClient ();
00351           break;
00352
00353         case IDM_ENUMFONTS:
00354
00355           //
00356           // Set/clear ENUMFONTS flag, toggle (un/check) menuitem, if
00357           //   checking IDM_ENUMFONTS then uncheck all other items,
00358           //   cause a repaint
00359           //
00360
00361           if (GetMenuState (hGraphicsSubMenu, IDM_ENUMFONTS, MF_BYCOMMAND)
00362                 & MF_CHECKED)
00363           {
00364             gdwGraphicsOptions &= DRAWAXIS;
00365
00366             CheckMenuItem (hGraphicsSubMenu, IDM_ENUMFONTS,
00367                            MF_UNCHECKED | MF_BYCOMMAND);
00368           }
00369
00370           else
00371           {
00372             SendMessage (hwnd, WM_COMMAND, IDM_NOGRAPHICS, 0);
00373
00374             gdwGraphicsOptions = ENUMFONTS | (gdwGraphicsOptions & DRAWAXIS);
00375
00376             CheckMenuItem (hGraphicsSubMenu, IDM_ENUMFONTS,
00377                            MF_CHECKED | MF_BYCOMMAND);
00378           }
00379           InvalidateClient ();
00380           break;
00381
00382         case IDM_DRAWAXIS:
00383
00384           //
00385           // Set/clear DRAWAXIS flag, toggle (un/check) menuitem,
00386           //   cause a repaint
00387           //
00388
00389           if (GetMenuState (hGraphicsSubMenu, IDM_DRAWAXIS, MF_BYCOMMAND)
00390                 & MF_CHECKED)
00391           {
00392             gdwGraphicsOptions &= ~DRAWAXIS;
00393
00394             CheckMenuItem (hGraphicsSubMenu, IDM_DRAWAXIS,
00395                            MF_UNCHECKED | MF_BYCOMMAND);
00396           }
00397
00398           else
00399           {
00400             gdwGraphicsOptions |= DRAWAXIS;
00401
00402             CheckMenuItem (hGraphicsSubMenu, IDM_DRAWAXIS,
00403                            MF_CHECKED | MF_BYCOMMAND);
00404           }
00405           InvalidateClient ();
00406           break;
00407
00408         case IDM_SETPENCOLOR:
00409         case IDM_SETBRUSHCOLOR:
00410         case IDM_TEXTCOLOR:
00411         {
00412           CHOOSECOLOR cc;
00413
00414           static DWORD adwCustColors[16];
00415
00416           memset ((void *) &cc, 0, sizeof (CHOOSECOLOR));
00417
00418           cc.lStructSize  = sizeof (CHOOSECOLOR);
00419           cc.hwndOwner    = hwnd;
00420           cc.Flags        = CC_RGBINIT;
00421           cc.lpCustColors = adwCustColors;
00422
00423           if (LOWORD (wParam) == IDM_SETPENCOLOR)
00424
00425             cc.rgbResult = gdwPenColor;
00426
00427           else if (LOWORD (wParam) == IDM_SETBRUSHCOLOR)
00428
00429             cc.rgbResult = gdwBrushColor;
00430
00431           else
00432
00433             cc.rgbResult = gdwTextColor;
00434
00435           //
00436           // bring up choose color common dialog
00437           //
00438
00439           ChooseColor (&cc);
00440
00441           if (LOWORD (wParam) == IDM_SETPENCOLOR)
00442
00443             gdwPenColor   = cc.rgbResult;
00444
00445           else if (LOWORD (wParam) == IDM_SETBRUSHCOLOR)
00446
00447             gdwBrushColor = cc.rgbResult;
00448
00449           else
00450
00451             gdwTextColor  = cc.rgbResult;
00452
00453           InvalidateClient ();
00454           break;
00455         }
00456
00457         case IDM_PENWIDTH_1:
00458         case IDM_PENWIDTH_2:
00459         case IDM_PENWIDTH_3:
00460         case IDM_PENWIDTH_4:
00461         case IDM_PENWIDTH_5:
00462         case IDM_PENWIDTH_6:
00463         case IDM_PENWIDTH_7:
00464         case IDM_PENWIDTH_8:
00465
00466           //
00467           // uncheck old pen width menuitem, check new one, cause a repaint
00468           //
00469
00470           for (i = 0; i < MAX_PENWIDTHS; i++)
00471
00472             if (giPenWidth == gaPenWidths[i].iPenWidth)
00473             {
00474               CheckMenuItem (hPenWidthSubMenu, gaPenWidths[i].wMenuItem,
00475                              MF_UNCHECKED | MF_BYCOMMAND);
00476               break;
00477             }
00478
00479           for (i = 0; i < MAX_PENWIDTHS; i++)
00480
00481             if (LOWORD(wParam) == gaPenWidths[i].wMenuItem)
00482             {
00483               CheckMenuItem (hPenWidthSubMenu, gaPenWidths[i].wMenuItem,
00484                              MF_CHECKED | MF_BYCOMMAND);
00485
00486               giPenWidth = gaPenWidths[i].iPenWidth;
00487
00488               break;
00489             }
00490
00491           InvalidateClient ();
00492           break;
00493
00494         case IDM_PENCOLOR_SOLID:
00495         case IDM_PENCOLOR_DASH:
00496         case IDM_PENCOLOR_DOT:
00497         case IDM_PENCOLOR_DASHDOT:
00498         case IDM_PENCOLOR_DASHDOTDOT:
00499         case IDM_PENCOLOR_NULL:
00500         case IDM_PENCOLOR_INSIDEFRAME:
00501
00502           //
00503           // uncheck old pen style menuitem, check new one, cause a repaint
00504           //
00505
00506           for (i = 0; i < MAX_PENSTYLES; i++)
00507
00508             if (giPenStyle == gaPenStyles[i].iPenStyle)
00509             {
00510               CheckMenuItem (hPenStyleSubMenu, gaPenStyles[i].wMenuItem,
00511                              MF_UNCHECKED | MF_BYCOMMAND);
00512               break;
00513             }
00514
00515           for (i = 0; i < MAX_PENSTYLES; i++)
00516
00517             if (LOWORD(wParam) == gaPenStyles[i].wMenuItem)
00518             {
00519               CheckMenuItem (hPenStyleSubMenu, gaPenStyles[i].wMenuItem,
00520                              MF_CHECKED | MF_BYCOMMAND);
00521
00522               giPenStyle = gaPenStyles[i].iPenStyle;
00523
00524               break;
00525             }
00526
00527           InvalidateClient ();
00528           break;
00529
00530         case IDM_BRUSHSTYLE_HORIZONTAL:
00531         case IDM_BRUSHSTYLE_VERTICAL:
00532         case IDM_BRUSHSTYLE_FDIAGONAL:
00533         case IDM_BRUSHSTYLE_BDIAGONAL:
00534         case IDM_BRUSHSTYLE_CROSS:
00535         case IDM_BRUSHSTYLE_DIAGCROSS:
00536
00537             for (i = 0; i < MAX_BRUSHSTYLES; i++) {
00538
00539         // Uncheck the old option
00540         if (giBrushStyle == gaBrushStyles[i].iBrushStyle) {
00541           CheckMenuItem (hBrushStyleSubMenu, gaBrushStyles[i].wMenuItem,
00542                    MF_UNCHECKED | MF_BYCOMMAND);
00543         }
00544
00545         // Check the new option
00546         if (LOWORD(wParam) == gaBrushStyles[i].wMenuItem) {
00547
00548           CheckMenuItem (hBrushStyleSubMenu, gaBrushStyles[i].wMenuItem,
00549                    MF_CHECKED | MF_BYCOMMAND);
00550
00551           giBrushStyle = gaBrushStyles[i].iBrushStyle;
00552         }
00553       }
00554
00555           InvalidateClient ();
00556           break;
00557
00558         case ID_COMBOBOX:
00559
00560           switch (HIWORD(wParam))
00561           {
00562             case CBN_SELCHANGE:
00563             {
00564               DWORD dwIndex;
00565               char  buf[BUFSIZE];
00566
00567               //
00568               // User clicked on one of the items in the toolbar combobox;
00569               //   figure out which item, then parse the text apart and
00570               //   copy it to the gszDriverName, gszDeviceName, and gszPort
00571               //   variables.
00572               //
00573
00574               dwIndex = (DWORD) SendMessage ((HWND) lParam,
00575                                              CB_GETCURSEL, 0, 0);
00576               SendMessage ((HWND) lParam, CB_GETLBTEXT, dwIndex,
00577                            (LONG_PTR) buf);
00578
00579               if (!strcmp (buf, "Display"))
00580               {
00581                 lstrcpyn (gszDeviceName, "Display", BUFSIZE);
00582
00583                 gszPort[0]       =
00584                 gszDriverName[0] = '\0';
00585               }
00586               else
00587               {
00588                 LPSTR   lpszSrc;
00589                 LPSTR   lpszDst;
00590
00591                 for (lpszSrc = buf, lpszDst = gszDeviceName;
00592                     *lpszSrc && *lpszSrc != ';';    ) {
00593                     if (IsDBCSLeadByte(*lpszSrc)) {
00594                         *lpszDst++ = *lpszSrc++;
00595                     }
00596                     *lpszDst++ = *lpszSrc++;
00597                 }
00598                 *lpszDst = '\0';
00599
00600                 for (lpszSrc++, lpszDst = gszPort;
00601                     *lpszSrc && *lpszSrc != ';';    ) {
00602                     if (IsDBCSLeadByte(*lpszSrc)) {
00603                         *lpszDst++ = *lpszSrc++;
00604                     }
00605                     *lpszDst++ = *lpszSrc++;
00606                 }
00607                 *lpszDst = '\0';
00608
00609                 for (lpszSrc++, lpszDst = gszDriverName; *lpszSrc;    ) {
00610                     if (IsDBCSLeadByte(*lpszSrc)) {
00611                         *lpszDst++ = *lpszSrc++;
00612                     }
00613                     *lpszDst++ = *lpszSrc++;
00614                 }
00615                 *lpszDst = '\0';
00616               }
00617               break;
00618             }
00619           }
00620           break;
00621       }
00622       break;
00623
00624     case WM_PAINT:
00625     {
00626       PAINTSTRUCT ps;
00627       RECT        rect;
00628       HRGN        hrgn;
00629       HPEN        hpen, hpenSave;
00630       HBRUSH      hbr;
00631       char        buf[BUFSIZE];
00632       POINT       p;
00633
00634       BeginPaint (hwnd, &ps);
00635
00636       //
00637       // paint 3d toolbar background & client size text
00638       //
00639
00640       GetClientRect (hwnd, &rect);
00641       rect.bottom = 2*glcyMenu;
00642       FillRect (ps.hdc, &rect, GetStockObject (LTGRAY_BRUSH));
00643       SelectObject (ps.hdc, GetStockObject (WHITE_PEN));
00644       MoveToEx (ps.hdc, 0, 2*glcyMenu - 2, NULL);
00645       LineTo   (ps.hdc, 0, 0);
00646       LineTo   (ps.hdc, (int) rect.right, 0);
00647       hpen = CreatePen (PS_SOLID, 1, 0x808080);
00648       hpenSave = SelectObject (ps.hdc, hpen);
00649       MoveToEx (ps.hdc, 0, (int) 2*glcyMenu-1, NULL);
00650       LineTo   (ps.hdc, (int) rect.right - 1, (int) 2*glcyMenu-1);
00651       LineTo   (ps.hdc, (int) rect.right - 1, 1);
00652       SelectObject (ps.hdc, hpenSave);
00653       DeleteObject (hpen);
00654
00655       GetClientRect (hwnd, &rect);
00656
00657       //
00658       // positioning of the string based upon x,y,cx,cy of combobox
00659       //
00660
00661       SetBkMode (ps.hdc, TRANSPARENT);
00662
00663       p.x = rect.right;
00664       p.y = (rect.bottom - 2*glcyMenu < 0 ? 0 : rect.bottom - 2*glcyMenu);
00665       SetMapMode (ps.hdc, giMapMode);
00666       DPtoLP (ps.hdc, &p, 1);
00667
00668       if ((giMapMode != MM_TEXT) && (giMapMode != MM_ANISOTROPIC))
00669
00670         //
00671         // p.y will come out negative because we started with origin in
00672         //   upper left corner
00673         //
00674
00675         p.y = -p.y;
00676
00677       SetMapMode (ps.hdc, MM_TEXT);
00678       _snprintf (buf, BUFSIZE -1, "cxClient = %ld (%ld)", rect.right, p.x);
00679       TextOut (ps.hdc, iComboboxWidth + (int) 3*glcyMenu/2, (int) glcyMenu/8,
00680                buf, (int) strlen (buf));
00681       _snprintf (buf, BUFSIZE -1, "cyClient = %ld (%ld)",
00682                rect.bottom - 2*glcyMenu < 0 ? 0 : rect.bottom - 2*glcyMenu,
00683                p.y);
00684       TextOut (ps.hdc, iComboboxWidth + (int) 3*glcyMenu/2,
00685                (int) (glcyMenu/8 + lTextHeight),
00686                buf, (int) strlen (buf));
00687
00688       //
00689       // paint graphics background white
00690       //
00691
00692       rect.top    += 2*glcyMenu;
00693       FillRect (ps.hdc, &rect, GetStockObject (WHITE_BRUSH));
00694
00695
00696       if (rect.bottom <= 4*glcyMenu)
00697
00698         //
00699         // we don't want to overpaint the toolbar, so just skip Paint() call
00700         //
00701
00702         goto done_painting;
00703
00704       //
00705       // set up a clip region so we don't draw all over our toolbar
00706       //
00707
00708       GetClientRect (hwnd, &rect);
00709       rect.top += 2*glcyMenu;
00710       hrgn = CreateRectRgnIndirect (&rect);
00711       SelectClipRgn (ps.hdc, hrgn);
00712       DeleteObject (hrgn);
00713
00714       //
00715       // set up view port, pens/brushes, & map mode, then paint
00716       //
00717
00718       rect.top -= 2*glcyMenu;
00719
00720       if (giMapMode == MM_TEXT || giMapMode == MM_ANISOTROPIC)
00721
00722         SetViewportOrgEx (ps.hdc, glcyMenu, 3*glcyMenu, NULL);
00723
00724       else
00725
00726         SetViewportOrgEx (ps.hdc, glcyMenu, rect.bottom - glcyMenu, NULL);
00727
00728       rect.bottom -= 4*glcyMenu;
00729       rect.right  -= 2*glcyMenu;
00730
00731       hpen = CreatePen (giPenStyle, giPenWidth, gdwPenColor);
00732       SelectObject (ps.hdc, hpen);
00733       hbr  = CreateHatchBrush (giBrushStyle, gdwBrushColor);
00734       SelectObject (ps.hdc, hbr);
00735
00736       SetTextColor (ps.hdc, gdwTextColor);
00737
00738       SetMapMode (ps.hdc, giMapMode);
00739       Paint      (ps.hdc, &rect);
00740
00741       DeleteObject (hpen);
00742       DeleteObject (hbr);
00743
00744 done_painting:
00745
00746       EndPaint (hwnd, &ps);
00747       break;
00748     }
00749
00750     case WM_CREATE:
00751     {
00752       HDC         hdc;
00753       TEXTMETRIC  tm;
00754       SIZE        size;
00755       HMENU       hmenu, hPenSubMenu, hBrushSubMenu;
00756
00757       //
00758       // initialize the globals
00759       //
00760
00761       glcyMenu = (LONG) GetSystemMetrics (SM_CYMENU);
00762
00763       hmenu                = GetMenu (hwnd);
00764       hMappingModesSubMenu = GetSubMenu (hmenu, 2);
00765       hGraphicsSubMenu     = GetSubMenu (hmenu, 3);
00766       hPenSubMenu          = GetSubMenu (hmenu, 4);
00767       hPenWidthSubMenu     = GetSubMenu (hPenSubMenu, 1);
00768       hPenStyleSubMenu     = GetSubMenu (hPenSubMenu, 2);
00769       hBrushSubMenu        = GetSubMenu (hmenu, 5);
00770       hBrushStyleSubMenu   = GetSubMenu (hBrushSubMenu, 1);
00771
00772       GetTextMetrics ((hdc = GetDC (hwnd)), &tm);
00773       lTextHeight = tm.tmHeight;
00774
00775       //
00776       // create combobox to display current printers in. the width
00777       //   is caluculated by getting the text extent of a typical
00778       //   entry in the listbox.
00779       //
00780
00781
00782       #define ASTRING "long  printer  name;long  port  name;long  driver  name"
00783
00784       GetTextExtentPoint (hdc, ASTRING, sizeof (ASTRING), &size);
00785
00786       iComboboxWidth = (int) size.cx;
00787
00788       ReleaseDC (hwnd, hdc);
00789
00790       hwndCombobox = CreateWindow ((LPCSTR) "COMBOBOX", (LPCSTR) "",
00791                                    WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL,
00792                                    (int) glcyMenu/2,
00793                                    (int) glcyMenu/2 - 2,  // - 2 = fudge factor
00794                                    iComboboxWidth,
00795                                    (int) 6*glcyMenu,
00796                                    hwnd, NULL, ghInst, NULL);
00797
00798       SetWindowLongPtr (hwndCombobox, GWLP_ID, ID_COMBOBOX);
00799
00800       PostMessage (hwnd, WM_COMMAND,
00801                    (WPARAM) MAKELONG (IDM_REFRESH, 0),
00802                    (LPARAM) 0);
00803       PostMessage (hwnd, WM_COMMAND,
00804                    (WPARAM) MAKELONG (IDM_POLYPOLYGON, 0),
00805                    (LPARAM) 0);
00806       break;
00807     }
00808
00809     case WM_DESTROY:
00810
00811       PostQuitMessage (0);
00812       break;
00813
00814     default:
00815
00816       return (DefWindowProc (hwnd, msg, wParam, lParam));
00817   }
00818   return 0;
00819 }
00820
00821
00822
00823 /******************************************************************************\
00824 *
00825 *  FUNCTION:    AboutDlgProc (standard dialog procedure INPUTS/RETURNS)
00826 *
00827 *  COMMENTS:    Handles "About" dialog messages
00828 *
00829 \******************************************************************************/
00830
00831 LRESULT CALLBACK AboutDlgProc (HWND   hwnd, UINT msg, WPARAM wParam,
00832                                LPARAM lParam)
00833 {
00834   switch (msg)
00835   {
00836     case WM_INITDIALOG:
00837
00838       return TRUE;
00839
00840     case WM_COMMAND:
00841
00842       switch (LOWORD (wParam))
00843       {
00844         case IDOK:
00845
00846           EndDialog (hwnd, TRUE);
00847
00848           return 1;
00849       }
00850       break;
00851   }
00852   return 0;
00853 }
00854
00855
00856
00857 /******************************************************************************\
00858 *
00859 *  FUNCTION:    InvalidateClient
00860 *
00861 *  COMMENTS:    Eliminates the flashing of the toolbar when we redraw
00862 *
00863 \******************************************************************************/
00864
00865 void InvalidateClient ()
00866 {
00867   RECT rect;
00868
00869   GetClientRect (ghwndMain, &rect);
00870
00871   rect.top += 2*glcyMenu;
00872
00873   InvalidateRect (ghwndMain, &rect, TRUE);
00874 }
00875
00876
00877
00878 /******************************************************************************\
00879 *
00880 *  FUNCTION:    RefreshPrinterCombobox
00881 *
00882 *  INPUTS:      hwndCombobox- handle of the toolbar combobox
00883 *
00884 *  COMMENTS:    The idea here is to enumerate all printers & list them in
00885 *               then combobox in the form: "DEVICE_NAME;PORT;DRIVER_NAME".
00886 *               Then later, when a user selects one of these, we just
00887 *               query out the string & parse it apart, sticking the
00888 *               appropriate parts into the DriverName, DeviceName, and
00889 *               Port variables.
00890 *
00891 *               Also, the "Display" option is added to the combobox so
00892 *               that user can get DevCaps info about it.
00893 *
00894 \******************************************************************************/
00895
00896 void RefreshPrinterCombobox (HWND hwndCombobox)
00897 {
00898   DWORD            dwFlags = PRINTER_ENUM_FAVORITE | PRINTER_ENUM_LOCAL;
00899   LPPRINTER_INFO_2 pPrinters;
00900   DWORD            cbPrinters;
00901   DWORD            cReturned, i;
00902   char             buf[BUFSIZE];
00903
00904   SendMessage (hwndCombobox, CB_RESETCONTENT, 0, 0);
00905
00906   //
00907   // add the "Display" option to the combobox
00908   //
00909
00910   lstrcpyn (buf, "Display", BUFSIZE);
00911   SendMessage (hwndCombobox, CB_INSERTSTRING, (UINT)-1, (LONG_PTR) buf);
00912
00913   //
00914   // get byte count needed for buffer, alloc buffer, the enum the printers
00915   //
00916
00917   EnumPrinters (dwFlags, NULL, 2, NULL, 0, &cbPrinters,
00918                 &cReturned);
00919
00920   if (!(pPrinters = (LPPRINTER_INFO_2) LocalAlloc (LPTR, cbPrinters + 4)))
00921   {
00922     MessageBox (ghwndMain, (LPCTSTR) GetStringRes(IDS_LALLOCFAIL),
00923                 (LPCTSTR)GetStringRes2(ERR_MOD_NAME), MB_OK | MB_ICONEXCLAMATION);
00924     goto done_refreshing;
00925   }
00926
00927
00928   if (!EnumPrinters (dwFlags, NULL, 2, (LPBYTE) pPrinters,
00929                      cbPrinters, &cbPrinters, &cReturned))
00930   {
00931     MessageBox (ghwndMain, (LPCTSTR) GetStringRes(IDS_ENUMPRTFAIL),
00932                 (LPCTSTR) GetStringRes2(ERR_MOD_NAME), MB_OK | MB_ICONEXCLAMATION);
00933     goto done_refreshing;
00934   }
00935
00936   if (cReturned > 0)
00937
00938     for (i = 0; i < cReturned; i++)
00939     {
00940       //
00941       // for each printer in the PRINTER_INFO_2 array: build a string that
00942       //   looks like "DEVICE_NAME;PORT;DRIVER_NAME"
00943       //
00944
00945       lstrcpyn (buf, (pPrinters + i)->pPrinterName, BUFSIZE);
00946       strncat (buf, ";", BUFSIZE - strlen(buf));
00947       strncat (buf, (pPrinters + i)->pPortName, BUFSIZE - strlen(buf));
00948       strncat (buf, ";", BUFSIZE - strlen(buf));
00949       strncat (buf, (pPrinters + i)->pDriverName, BUFSIZE - strlen(buf));
00950
00951       SendMessage (hwndCombobox, CB_INSERTSTRING, (UINT)-1, (LONG_PTR) buf);
00952     }
00953
00954   else
00955
00956     MessageBox (ghwndMain, GetStringRes(IDS_NOPRTLST), "PRINTER.EXE", MB_OK);
00957
00958 done_refreshing:
00959
00960   SendMessage (hwndCombobox, CB_SELECTSTRING, (UINT) -1, (LONG_PTR) buf);
00961
00962   PostMessage (ghwndMain, WM_COMMAND,
00963                (WPARAM) MAKELONG (ID_COMBOBOX, CBN_SELCHANGE),
00964                (LPARAM) hwndCombobox);
00965
00966   LocalFree (LocalHandle (pPrinters));
00967 }
00968
00969
00970
00971 /******************************************************************************\
00972 *
00973 *  FUNCTION:    PrintThread
00974 *
00975 *  INPUTS:      wParam - wParam of a WM_COMMAND message containing menuitem id
00976 *
00977 *  COMMENTS:    This is the code for the print thread created when the user
00978 *               selects the "Print" or "PrintDlg" menuitems. A thread is used
00979 *               here more demostration purposes only, since we really don't
00980 *               have any background processing to do. A real app would want
00981 *               to have alot more error checking here (e.g. check return of
00982 *               StartDoc, StartPage...).
00983 *
00984 \******************************************************************************/
00985
00986 void PrintThread (LPVOID wParam)
00987 {
00988   DOCINFO di;
00989   RECT    rect;
00990   HPEN    hpen;
00991   HBRUSH  hbr;
00992
00993   switch (LOWORD((WPARAM) wParam)) {
00994     case IDM_PRINT:
00995     {
00996       if (!strcmp (gszDeviceName, "Display"))
00997       {
00998         MessageBox (ghwndMain, GetStringRes(IDS_ASKSELPRT),
00999                     "PRINTER.EXE:", MB_OK);
01000         return;
01001       }
01002       else if (!(ghdc = CreateDC (gszDriverName, gszDeviceName, gszPort, NULL)))
01003       {
01004         MessageBox (ghwndMain, "PrintThread(): CreateDC() failed",
01005                     GetStringRes2(ERR_MOD_NAME), MB_OK);
01006         return;
01007       }
01008       break;
01009     }
01010
01011     case IDM_PRINTDLG:
01012     {
01013       PRINTDLG  pd;
01014
01015       //
01016       // Initialize a PRINTDLG struct and call PrintDlg to allow user to
01017       //   specify various printing options...
01018       //
01019
01020       memset ((void *) &pd, 0, sizeof(PRINTDLG));
01021
01022       pd.lStructSize = sizeof(PRINTDLG);
01023       pd.hwndOwner   = ghwndMain;
01024       pd.Flags       = PD_RETURNDC;
01025       pd.hInstance   = NULL;
01026
01027       PrintDlg(&pd);
01028       ghdc = pd.hDC;
01029
01030       if (pd.hDevMode)
01031
01032         GlobalFree (pd.hDevMode);
01033
01034       if (pd.hDevNames)
01035
01036         GlobalFree (pd.hDevNames);
01037
01038       if (!ghdc)
01039       {
01040         MessageBox (ghwndMain, GetStringRes(IDS_PRTDLGFAIL),
01041                     GetStringRes2(ERR_MOD_NAME), MB_OK);
01042         return;
01043       }
01044     }
01045   }
01046
01047   //
01048   // put up Abort & install the abort procedure
01049   //
01050
01051   gbAbort = FALSE;
01052   ghwndAbort = CreateDialog (ghInst, (LPCTSTR) "Abort", ghwndMain,
01053     (DLGPROC) AbortDlgProc);
01054   EnableWindow (ghwndMain, FALSE);
01055   SetAbortProc (ghdc, AbortProc);
01056
01057   //
01058   // create & select pen/brush
01059   //
01060
01061   hpen = CreatePen (giPenStyle, giPenWidth, gdwPenColor);
01062   SelectObject (ghdc, hpen);
01063
01064   hbr  = CreateHatchBrush (giBrushStyle, gdwBrushColor);
01065   SelectObject (ghdc, hbr);
01066
01067   SetTextColor (ghdc, gdwTextColor);
01068
01069   SetMapMode (ghdc, giMapMode);
01070
01071   SetRect(&rect, 0,0, GetDeviceCaps (ghdc, HORZRES), GetDeviceCaps (ghdc, VERTRES));
01072
01073   di.cbSize      = sizeof(DOCINFO);
01074   di.lpszDocName = GetStringRes(IDS_PRTTST);
01075   di.lpszOutput  = NULL;
01076   di.fwType      = 0; // Windows 95 only; ignored on Windows NT
01077
01078   StartDoc  (ghdc, &di);
01079
01080   if (gdwGraphicsOptions) {
01081
01082     Paint (ghdc, &rect);
01083
01084   } else {
01085     LPSTR pBuf = GetStringRes(IDS_BLANKPG);
01086     TextOut (ghdc, 5, 5, (LPCTSTR) pBuf, (int) My_mbslen(pBuf));
01087   }
01088
01089   // If we didn't abort the job
01090   if (!gbAbort)
01091   {
01092     EndPage   (ghdc);
01093     EndDoc    (ghdc);
01094
01095     DestroyWindow (ghwndAbort);
01096   }
01097
01098   // Clean up
01099   DeleteDC  (ghdc);
01100   DeleteObject(hpen);
01101   DeleteObject(hbr);
01102
01103   EnableWindow  (ghwndMain, TRUE);
01104 }
01105
01106 /******************************************************************************\
01107 *
01108 *  FUNCTION:    AbortProc
01109 *
01110 *  COMMENTS:    Standard printing abort proc
01111 *
01112 \******************************************************************************/
01113
01114 BOOL CALLBACK AbortProc (HDC hdc, int error)
01115 {
01116   MSG msg;
01117
01118   while (!gbAbort && PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
01119
01120     if (!IsDialogMessage (ghwndAbort, &msg)) {
01121       TranslateMessage (&msg);
01122       DispatchMessage (&msg);
01123     }
01124
01125   }
01126
01127   return !gbAbort;
01128 }
01129
01130
01131
01132 /******************************************************************************\
01133 *
01134 *  FUNCTION:    AbortDlgProc (standard dialog procedure INPUTS/RETURNS)
01135 *
01136 *  COMMENTS:    Handles "Abort" dialog messages
01137 *
01138 \******************************************************************************/
01139
01140 LRESULT CALLBACK AbortDlgProc (HWND   hwnd, UINT msg, WPARAM wParam,
01141                                LPARAM lParam)
01142 {
01143   switch (msg) {
01144     case WM_INITDIALOG:
01145     EnableMenuItem (GetSystemMenu (hwnd, FALSE), SC_CLOSE, MF_GRAYED);
01146     return TRUE;
01147
01148     case WM_COMMAND:   // There's only one
01149     switch (LOWORD (wParam)) {
01150     case DID_CANCEL:
01151       MessageBeep(MB_OK);
01152       gbAbort = TRUE;
01153       AbortDoc (ghdc);
01154       DestroyWindow (hwnd);
01155       break;
01156     }
01157     break;
01158   }
01159   return 0;
01160 }
01161 /******************************************************************************\
01162 *
01163 *  FUNCTION:    GetStringRes (int id INPUT ONLY)
01164 *
01165 *  COMMENTS:    Load the resource string with the ID given, and return a
01166 *               pointer to it.  Notice that the buffer is common memory so
01167 *               the string must be used before this call is made a second time.
01168 *
01169 \******************************************************************************/
01170
01171 LPTSTR   GetStringRes (int id)
01172 {
01173   static TCHAR buffer[MAX_PATH];
01174
01175   buffer[0]=0;
01176   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
01177   return buffer;
01178 }
01179
01180 LPTSTR   GetStringRes2 (int id)
01181 {
01182   static TCHAR buffer[MAX_PATH];
01183
01184   buffer[0]=0;
01185   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
01186   return buffer;
01187 }
01188
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/about.Cpp Source File

  • SysMgmt
  • MMC
  • ActiveX

about.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163         MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164         *lpDest = wszStr;
00165
00166
00167     return S_OK;
00168 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

DEB_PROCESS_NODE_INFO_STRUCT Member List

This is the complete list of members for DEB_PROCESS_NODE_INFO_STRUCT, including all inherited members.
dwProcessId | DEB_PROCESS_NODE_INFO_STRUCT
dwThreadId | DEB_PROCESS_NODE_INFO_STRUCT
lpstrFileName | DEB_PROCESS_NODE_INFO_STRUCT
lpstrPathName | DEB_PROCESS_NODE_INFO_STRUCT
pDllList | DEB_PROCESS_NODE_INFO_STRUCT
ProcessDebugInfo | DEB_PROCESS_NODE_INFO_STRUCT
pThreadList | DEB_PROCESS_NODE_INFO_STRUCT
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/dll/Demo.h Source File

  • Begin
  • dll

Demo.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012
00013 #define IDM_BOX     101
00014 #define IDM_BLOCK   102
00015 #define IDM_RETAIN  103
00016 #define IDM_ABOUT   104
00017
00018 #define IDS_APPNAME     1001
00019 #define IDS_NOMEM       1002
00020
00021 BOOL DemoInit(HANDLE);
00022 LRESULT APIENTRY DemoWndProc(HWND, UINT, UINT, LONG);
00023 BOOL APIENTRY About(HWND, UINT, UINT, LONG);
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DropExt/DropExt.C Source File

  • WinUI
  • Shell
  • DropExt

DropExt.C

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1994 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Development Tools and/or SDK documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \******************************************************************************/
00010
00011 //---------------------------------------------------------------------------
00012 //
00013 // File: dropext.c
00014 //
00015 //  This file contains a sample source code of context menu extension handler.
00016 //
00017 //---------------------------------------------------------------------------
00018
00019 #include "priv.h"
00020
00021 #ifdef _IA64_
00022 #pragma warning(disable:4338)
00023 #endif
00024
00025 //
00026 // Initialize GUIDs (should be done only and at-least once per DLL/EXE)
00027 //
00028 #define INITGUID
00029 #include <initguid.h>
00030 #include <strsafe.h>
00031 #define ARRAYSIZE(a)    (sizeof(a)/sizeof(a[0]))
00032 #include "dropext.h"
00033
00034 //
00035 // Function prototypes
00036 //
00037 HRESULT CALLBACK DropExt_CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR*);
00038
00039 //
00040 // Global variables
00041 //
00042 UINT g_cRefThisDll = 0;   // Reference count of this DLL.
00043 UINT g_cfNetResource = 0; // Clipboard format
00044
00045 //---------------------------------------------------------------------------
00046 // LibMain
00047 //---------------------------------------------------------------------------
00048 BOOL APIENTRY LibMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
00049 {
00050     switch(dwReason)
00051     {
00052     case DLL_PROCESS_ATTACH:
00053       break;
00054     case DLL_PROCESS_DETACH:
00055       break;
00056
00057     case DLL_THREAD_DETACH:
00058         break;
00059
00060     case DLL_THREAD_ATTACH:
00061     default:
00062       break;
00063     } // end switch()
00064
00065     return TRUE;
00066 }
00067
00068 //---------------------------------------------------------------------------
00069 // DllCanUnloadNow
00070 //---------------------------------------------------------------------------
00071
00072 STDAPI DllCanUnloadNow(void)
00073 {
00074     return ResultFromScode((g_cRefThisDll==0) ? S_OK : S_FALSE);
00075 }
00076
00077 //---------------------------------------------------------------------------
00078 //
00079 // DllGetClassObject
00080 //
00081 //  This is the entry of this DLL, which all the In-Proc server DLLs should
00082 // export. See the description of "DllGetClassObject" of OLE 2.0 reference
00083 // manual for detail.
00084 //
00085 //---------------------------------------------------------------------------
00086
00087 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppvOut)
00088 {
00089     //
00090     //  This DLL has only one class (CLSID_SampleDropExt). If a DLL supports
00091     // multiple classes, it should have either multiple if-statements or
00092     // efficient table lookup code.
00093     //
00094     if (IsEqualIID(rclsid, &CLSID_SampleDropExt))
00095     {
00096   //
00097   //  We are supposed return the class object for this class. Instead
00098   // of fully implementing it in this DLL, we just call a helper
00099   // function in the shell DLL which creates a default class factory
00100   // object for us. When its CreateInstance member is called, it
00101   // will call back our create instance function (DropExt_CreateInstance).
00102   //
00103   return SHCreateDefClassObject(
00104         riid,       //
00105         ppvOut,       //
00106         DropExt_CreateInstance, // callback function
00107         &g_cRefThisDll,     // reference count of this DLL
00108         &IID_IShellExtInit      // init interface
00109         );
00110     }
00111
00112     return ResultFromScode(E_FAIL);
00113 }
00114
00115
00116 //---------------------------------------------------------------------------
00117 //
00118 // CSampleDropExt class
00119 //
00120 // In C++:
00121 //  class CSampleDropExt : protected IContextMenu, protected IShellExtInit
00122 //  {
00123 //  protected:
00124 //      UINT         _cRef;
00125 //      LPDATAOBJECT _pdtobj;
00126 //  HKEY       _hkeyProgID;
00127 //  public:
00128 //      CSampleDropExt() _cRef(1), _pdtobj(NULL), _hkeyProgID(NULL) {};
00129 //      ...
00130 //  };
00131 //
00132 //---------------------------------------------------------------------------
00133 typedef struct _CSampleDropExt  // smx
00134 {
00135     IContextMenu    _ctm;           // 1st base class
00136     IShellExtInit   _sxi;     // 2nd base class
00137     UINT            _cRef;          // reference count
00138     LPDATAOBJECT    _pdtobj;      // data object
00139     HKEY      _hkeyProgID;    // reg. database key to ProgID
00140     char      _szTargetFolder[MAX_PATH];
00141 } CSampleDropExt, * PSAMPLEDROPEXT;
00142
00143 #define SMX_OFFSETOF(x)         ((UINT_PTR)(&((PSAMPLEDROPEXT)0)->x))
00144 #define PVOID2PSMX(pv,offset)   ((PSAMPLEDROPEXT)(((LPBYTE)pv)-offset))
00145 #define PCTM2PSMX(pctm)         PVOID2PSMX(pctm, SMX_OFFSETOF(_ctm))
00146 #define PSXI2PSMX(psxi)         PVOID2PSMX(psxi, SMX_OFFSETOF(_sxi))
00147
00148 //
00149 // Vtable prototype
00150 //
00151 extern IContextMenuVtbl     c_SampleDropExt_CTMVtbl;
00152 extern IShellExtInitVtbl    c_SampleDropExt_SXIVtbl;
00153
00154 //---------------------------------------------------------------------------
00155 //
00156 // DropExt_CreateInstance
00157 //
00158 //  This function is called back from within IClassFactory::CreateInstance()
00159 // of the default class factory object, which is created by SHCreateClassObject.
00160 //
00161 //---------------------------------------------------------------------------
00162
00163 HRESULT CALLBACK DropExt_CreateInstance(LPUNKNOWN punkOuter,
00164                 REFIID riid, LPVOID FAR* ppvOut)
00165 {
00166     HRESULT hres;
00167     PSAMPLEDROPEXT psmx;
00168
00169     //
00170     // Shell extentions typically does not support aggregation.
00171     //
00172     if (punkOuter) {
00173   return ResultFromScode(CLASS_E_NOAGGREGATION);
00174     }
00175
00176     //
00177     // in C++:
00178     //  psmx = new CSampleDropExt();
00179     //
00180     psmx = LocalAlloc(LPTR, sizeof(CSampleDropExt));
00181     if (!psmx) {
00182   return ResultFromScode(E_OUTOFMEMORY);
00183     }
00184     psmx->_ctm.lpVtbl = &c_SampleDropExt_CTMVtbl;
00185     psmx->_sxi.lpVtbl = &c_SampleDropExt_SXIVtbl;
00186     psmx->_cRef = 1;
00187     psmx->_pdtobj = NULL;
00188     psmx->_hkeyProgID = NULL;
00189     g_cRefThisDll++;
00190
00191     //
00192     // in C++:
00193     //  hres = psmx->QueryInterface(riid, ppvOut);
00194     //  psmx->Release();
00195     //
00196     // Note that the Release member will free the object, if QueryInterface
00197     // failed.
00198     //
00199     hres = c_SampleDropExt_CTMVtbl.QueryInterface(&psmx->_ctm, riid, ppvOut);
00200     c_SampleDropExt_CTMVtbl.Release(&psmx->_ctm);
00201
00202     return hres;  // S_OK or E_NOINTERFACE
00203 }
00204
00205
00206 //---------------------------------------------------------------------------
00207 // CSampleDropExt::Initialize (IShellExtInit override)
00208 //---------------------------------------------------------------------------
00209 STDMETHODIMP DropExt_Initialize(LPSHELLEXTINIT psxi,
00210     LPCITEMIDLIST pidlFolder,
00211     LPDATAOBJECT pdtobj,
00212     HKEY hkeyProgID)
00213 {
00214     PSAMPLEDROPEXT this = PSXI2PSMX(psxi);
00215
00216     // Initialize can be called more than once.
00217     if (this->_pdtobj) {
00218   this->_pdtobj->lpVtbl->Release(this->_pdtobj);
00219     }
00220
00221     if (this->_hkeyProgID) {
00222   RegCloseKey(this->_hkeyProgID);
00223     }
00224
00225     // Duplicate the pdtobj pointer
00226     if (pdtobj) {
00227   this->_pdtobj = pdtobj;
00228   pdtobj->lpVtbl->AddRef(pdtobj);
00229     }
00230
00231     // Duplicate the handle
00232     if (hkeyProgID) {
00233   RegOpenKeyEx(hkeyProgID, NULL, 0L, MAXIMUM_ALLOWED, &this->_hkeyProgID);
00234     }
00235
00236     // Get the path to the drop target folder
00237     if (pidlFolder) {
00238   SHGetPathFromIDList(pidlFolder, this->_szTargetFolder);
00239     }
00240
00241     return NOERROR;
00242 }
00243
00244 STDMETHODIMP DropExt_QueryContextMenu(LPCONTEXTMENU pctm,
00245                                                HMENU hmenu,
00246                                                UINT indexMenu,
00247                                                UINT idCmdFirst,
00248                                                UINT idCmdLast,
00249                  UINT uFlags)
00250 {
00251     UINT idCmd = idCmdFirst;
00252     InsertMenu(hmenu, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, "Check H&DROP (dropext)");
00253     InsertMenu(hmenu, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, "Check H&NRES (dropext)");
00254     return ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_NULL, (USHORT)2));
00255 }
00256
00257 //
00258 // Converts an offset to a string to a string pointer.
00259 //
00260 LPCSTR _Offset2Ptr(LPSTR pszBase, UINT_PTR offset, UINT * pcb)
00261 {
00262     LPSTR pszRet;
00263     if (offset==0) {
00264   pszRet = NULL;
00265   *pcb = 0;
00266     } else {
00267   pszRet = pszBase + offset;
00268   *pcb = lstrlen(pszRet) + 1;
00269     }
00270     return pszRet;
00271 }
00272
00273 //
00274 // This is a helper routine which extracts a specified NETRESOURCE from hnres.
00275 //
00276 UINT DropExt_GetNetResource(HGLOBAL hnres, UINT iItem, LPNETRESOURCE pnresOut, UINT cbMax)
00277 {
00278     LPNRESARRAY panr = GlobalLock(hnres);
00279     UINT iRet = 0;  // assume error
00280     if (hnres)
00281     {
00282   if (iItem==(UINT)-1)
00283   {
00284       iRet = panr->cItems;
00285   }
00286   else if (iItem < panr->cItems)
00287   {
00288       UINT cbProvider, cbRemoteName;
00289       LPCSTR pszProvider = _Offset2Ptr((LPSTR)panr, (UINT_PTR)panr->nr[iItem].lpProvider, &cbProvider);
00290       LPCSTR pszRemoteName = _Offset2Ptr((LPSTR)panr, (UINT_PTR)panr->nr[iItem].lpRemoteName, &cbRemoteName);
00291       iRet = sizeof(NETRESOURCE) + cbProvider + cbRemoteName;
00292       if (iRet <= cbMax)
00293       {
00294     LPSTR psz = (LPSTR)(pnresOut+1);
00295     *pnresOut = panr->nr[iItem];
00296     if (pnresOut->lpProvider) {
00297         pnresOut->lpProvider = psz;
00298         StringCbCopy(psz, cbProvider, pszProvider);
00299         psz += cbProvider;
00300     }
00301     if (pnresOut->lpRemoteName) {
00302         pnresOut->lpRemoteName = psz;
00303         StringCbCopy(psz, cbRemoteName, pszRemoteName);
00304     }
00305       }
00306   }
00307   GlobalUnlock(hnres);
00308     }
00309     return iRet;
00310 }
00311
00312 HRESULT DropExt_CheckForHDROP(PSAMPLEDROPEXT this, HWND hwnd)
00313 {
00314     FORMATETC fmte = {
00315           CF_HDROP,
00316           (DVTARGETDEVICE FAR *)NULL,
00317           DVASPECT_CONTENT,
00318           -1,
00319           TYMED_HGLOBAL };
00320     STGMEDIUM medium;
00321     HRESULT hres = this->_pdtobj->lpVtbl->GetData(this->_pdtobj, &fmte, &medium);
00322
00323     if (SUCCEEDED(hres))
00324     {
00325   HDROP hdrop = medium.hGlobal;
00326   UINT cFiles = DragQueryFile(hdrop, (UINT)-1, NULL, 0);
00327   char szFile[MAX_PATH];
00328   char szBuf[MAX_PATH*2+64];
00329
00330   DragQueryFile(hdrop, 0, szFile, sizeof(szFile));
00331   StringCchPrintf(szBuf, ARRAYSIZE(szBuf),
00332      "The drop target is %s.\n"
00333      "%d files/directories in HDROP\n"
00334      "The path to the first object is\n"
00335        "\t%s.",
00336      this->_szTargetFolder,
00337      cFiles,
00338      szFile);
00339
00340   MessageBox(hwnd, szBuf, "DropExt", MB_OK);
00341
00342   ReleaseStgMedium(&medium);
00343
00344     }
00345     else
00346     {
00347   MessageBox(hwnd, "No file system object in the selection", "DropExt", MB_OK);
00348     }
00349
00350     return hres;
00351 }
00352
00353 HRESULT DropExt_CheckForHNRES(PSAMPLEDROPEXT this, HWND hwnd)
00354 {
00355     FORMATETC fmte = {
00356           (CLIPFORMAT)(g_cfNetResource ? g_cfNetResource
00357         : (g_cfNetResource= RegisterClipboardFormat("Net Resource"))),
00358           (DVTARGETDEVICE FAR *)NULL,
00359           DVASPECT_CONTENT,
00360           -1,
00361           TYMED_HGLOBAL };
00362     STGMEDIUM medium;
00363     HRESULT hres = this->_pdtobj->lpVtbl->GetData(this->_pdtobj, &fmte, &medium);
00364     if (SUCCEEDED(hres))
00365     {
00366   HGLOBAL hnres = medium.hGlobal;
00367   LPNETRESOURCE pnr = (LPNETRESOURCE)LocalAlloc(LPTR, 1024);
00368
00369   if (pnr)
00370   {
00371       char szBuf[512];
00372       UINT cItems = DropExt_GetNetResource(hnres, (UINT)-1, NULL, 0);
00373
00374       // Get the NETRESOURCE of the first item
00375       DropExt_GetNetResource(hnres, 0, pnr, 1024);
00376
00377       StringCchPrintf(szBuf, ARRAYSIZE(szBuf),
00378          "%d network resource objects in HNRES\n"
00379          "The attributes of the first object are\n"
00380          "\tProvider      = %s\n"
00381          "\tRemoteName    = %s\n"
00382          "\tdwDisplayType = %x\n"
00383          "\tdwType        = %x\n"
00384          "\tdwUsage       = %x\n",
00385          cItems,
00386          pnr->lpProvider,
00387          pnr->lpRemoteName ? pnr->lpRemoteName : "N/A",
00388          pnr->dwDisplayType,
00389          pnr->dwType,
00390          pnr->dwUsage);
00391
00392       MessageBox(hwnd, szBuf, "DropExt", MB_OK);
00393
00394       LocalFree(pnr);
00395   }
00396   else
00397   {
00398       hres = ResultFromScode(E_OUTOFMEMORY);
00399   }
00400
00401   ReleaseStgMedium(&medium);
00402     }
00403     else
00404     {
00405   MessageBox(hwnd, "No network objects in the selection", "DropExt", MB_OK);
00406     }
00407     return hres;
00408 }
00409
00410 STDMETHODIMP DropExt_InvokeCommand(LPCONTEXTMENU pctm,
00411            LPCMINVOKECOMMANDINFO lpici)
00412 {
00413     PSAMPLEDROPEXT this = PCTM2PSMX(pctm);
00414     HRESULT hres = ResultFromScode(E_INVALIDARG); // assume error
00415     //
00416     // No need to support string based command.
00417     //
00418     if (!HIWORD(lpici->lpVerb))
00419     {
00420   UINT idCmd = LOWORD(lpici->lpVerb);
00421
00422   switch(idCmd)
00423   {
00424   case 0:
00425       hres = DropExt_CheckForHDROP(this, lpici->hwnd);
00426       break;
00427
00428   case 1:
00429       hres = DropExt_CheckForHNRES(this, lpici->hwnd);
00430       break;
00431   }
00432     }
00433     return hres;
00434 }
00435
00436 STDMETHODIMP DropExt_GetCommandString(
00437                                         LPCONTEXTMENU pctm,
00438                                         UINT_PTR    idCmd,
00439                                         UINT        wReserved,
00440                                         UINT FAR *  pwReserved,
00441                                         LPSTR       pszName,
00442                                         UINT        cchMax)
00443 {
00444     return NOERROR;
00445 }
00446
00447 //---------------------------------------------------------------------------
00448 // CSampleDropExt::AddRef (IContextMenu override)
00449 //---------------------------------------------------------------------------
00450
00451 STDMETHODIMP_(ULONG) DropExt_CTM_AddRef(LPCONTEXTMENU pctm)
00452 {
00453     PSAMPLEDROPEXT this = PCTM2PSMX(pctm);
00454     return ++this->_cRef;
00455 }
00456
00457
00458 //---------------------------------------------------------------------------
00459 // CSampleDropExt::AddRef (IShellExtInit override)
00460 //---------------------------------------------------------------------------
00461
00462 STDMETHODIMP_(ULONG) DropExt_SXI_AddRef(LPSHELLEXTINIT psxi)
00463 {
00464     PSAMPLEDROPEXT this = PSXI2PSMX(psxi);
00465     return ++this->_cRef;
00466 }
00467
00468 //---------------------------------------------------------------------------
00469 // CSampleDropExt::Release (IContextMenu override)
00470 //---------------------------------------------------------------------------
00471
00472 STDMETHODIMP_(ULONG) DropExt_CTM_Release(LPCONTEXTMENU pctm)
00473 {
00474     PSAMPLEDROPEXT this = PCTM2PSMX(pctm);
00475     if (--this->_cRef) {
00476   return this->_cRef;
00477     }
00478
00479     if (this->_pdtobj) {
00480   this->_pdtobj->lpVtbl->Release(this->_pdtobj);
00481     }
00482
00483     if (this->_hkeyProgID) {
00484   RegCloseKey(this->_hkeyProgID);
00485     }
00486
00487     LocalFree((HLOCAL)this);
00488     g_cRefThisDll--;
00489
00490     return 0;
00491 }
00492
00493 //---------------------------------------------------------------------------
00494 // CSampleDropExt::Release (IShellExtInit thunk)
00495 //---------------------------------------------------------------------------
00496
00497 STDMETHODIMP_(ULONG) DropExt_SXI_Release(LPSHELLEXTINIT psxi)
00498 {
00499     PSAMPLEDROPEXT this = PSXI2PSMX(psxi);
00500     return DropExt_CTM_Release(&this->_ctm);
00501 }
00502
00503 //---------------------------------------------------------------------------
00504 // CSampleDropExt::QueryInterface (IContextMenu override)
00505 //---------------------------------------------------------------------------
00506
00507 STDMETHODIMP DropExt_CTM_QueryInterface(LPCONTEXTMENU pctm, REFIID riid, LPVOID FAR* ppvOut)
00508 {
00509     PSAMPLEDROPEXT this = PCTM2PSMX(pctm);
00510     if (IsEqualIID(riid, &IID_IContextMenu) || IsEqualIID(riid, &IID_IUnknown))
00511     {
00512         (LPCONTEXTMENU)*ppvOut=pctm;
00513         this->_cRef++;
00514         return NOERROR;
00515     }
00516     if (IsEqualIID(riid, &IID_IShellExtInit))
00517     {
00518         (LPSHELLEXTINIT)*ppvOut=&this->_sxi;
00519         this->_cRef++;
00520         return NOERROR;
00521     }
00522     return ResultFromScode(E_NOINTERFACE);
00523 }
00524
00525 //---------------------------------------------------------------------------
00526 // CSampleDropExt::QueryInterface (IShellExtInit thunk)
00527 //---------------------------------------------------------------------------
00528
00529 STDMETHODIMP DropExt_SXI_QueryInterface(LPSHELLEXTINIT psxi, REFIID riid, LPVOID FAR* ppv)
00530 {
00531     PSAMPLEDROPEXT this = PSXI2PSMX(psxi);
00532     return DropExt_CTM_QueryInterface(&this->_ctm, riid, ppv);
00533 }
00534
00535
00536 //---------------------------------------------------------------------------
00537 // CSampleDropExt class : Vtables
00538 //---------------------------------------------------------------------------
00539
00540 IContextMenuVtbl c_SampleDropExt_CTMVtbl = {
00541     DropExt_CTM_QueryInterface,
00542     DropExt_CTM_AddRef,
00543     DropExt_CTM_Release,
00544     DropExt_QueryContextMenu,
00545     DropExt_InvokeCommand,
00546     DropExt_GetCommandString,
00547 };
00548
00549 IShellExtInitVtbl c_SampleDropExt_SXIVtbl = {
00550     DropExt_SXI_QueryInterface,
00551     DropExt_SXI_AddRef,
00552     DropExt_SXI_Release,
00553     DropExt_Initialize
00554 };
00555
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/customdial/customdialreg.cpp Source File

  • NetDS
  • Ras
  • customdial

customdialreg.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright © 2000  Microsoft Corporation.  All Rights Reserved.
00008  *
00009  * Author: Stephen R. Husak - Microsoft Developer Support
00010  *
00011  * Abstract:
00012  *    The DLL provides DLLRegisterServer/DLLUnregisterServer
00013  *    exports to provide a way to install the DLL into the registry
00014  *    correctly for Windows 2000. In this manner one can use regsvr32.exe
00015  *    to add/remove the custom DLL in the registry. This is normally used
00016  *    for COM objects and servers but I use it here as a simple technique of
00017  *    wrapping everything in one place.
00018  */
00019
00020 /*
00021  * Includes
00022  */
00023 #define WINVER 0x0500   // needed for Windows 2000 RAS extensions
00024 #define UNICODE         // this is UNICODE
00025 #include <windows.h>    // include windows
00026 #include <ras.h>        // include RAS for creating the entry
00027 #include <raserror.h>
00028
00029 /*
00030  * constants for configuration
00031  */
00032 #define RASCUSTOMDIAL_KEYPATH   L"SYSTEM\\CurrentControlSet\\Services\\Rasman\\Parameters"
00033 #define RASCUSTOMDIAL_VALUENAME L"CustomDLL"
00034 #define RASCUSTOMDIAL_ENTRYNAME L"Steelhead"
00035 #define RASCUSTOMDIAL_PHONENO   L"29719"
00036
00037 /*
00038  * from the customdial.cpp file
00039  */
00040 extern HANDLE g_hInstance;      // from DLLMain
00041 extern void OutputTraceString(LPTSTR lpszFormatString, ...);
00042
00043 /*
00044  * CreateTestEntry
00045  *
00046  * creates a test entry for testing this DLL
00047  */
00048 BOOL CreateTestEntry(LPCTSTR szDLLPath)
00049 {
00050   DWORD rc;               // return code from function calls
00051   DWORD dwSize;           // structure size
00052   RASENTRY *RasEntry = NULL;      // Ras Entry structure
00053   BOOL bResult = TRUE;    // return for the function
00054   RasEntry = (RASENTRY *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
00055     sizeof(RASENTRY));
00056
00057   OutputTraceString(L"CreateTestEntry called in customdial.dll\n");
00058   rc = RasGetEntryProperties(NULL, L"", RasEntry, &dwSize, NULL, NULL);
00059   while (rc == ERROR_BUFFER_TOO_SMALL) {
00060   RasEntry = (RASENTRY *) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
00061     RasEntry, dwSize);
00062   rc = RasGetEntryProperties(NULL, L"", RasEntry, &dwSize, NULL, NULL);
00063   }
00064   // Initialize the RASENTRY structure.
00065   RasEntry->dwSize = dwSize;
00066
00067   // Validate the format of the connection entry name.
00068   rc = RasValidateEntryName(NULL, RASCUSTOMDIAL_ENTRYNAME);
00069   if (rc == ERROR_INVALID_NAME)
00070     {
00071     OutputTraceString(L"--- RasValidateEntryName returned invalid name in CreateTestEntry: %d\n", rc);
00072     bResult = FALSE;
00073     }
00074   else if (rc == ERROR_ALREADY_EXISTS)
00075     {
00076     rc = RasGetEntryProperties(NULL, RASCUSTOMDIAL_ENTRYNAME, RasEntry, &dwSize, NULL, NULL);
00077  while (rc == ERROR_BUFFER_TOO_SMALL) {
00078   RasEntry = (RASENTRY *) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
00079     RasEntry, dwSize);
00080   rc = RasGetEntryProperties(NULL, RASCUSTOMDIAL_ENTRYNAME, RasEntry, &dwSize, NULL, NULL);
00081   }
00082     if (rc != ERROR_SUCCESS)
00083       {
00084       OutputTraceString(L"--- RasGetEntryProperties failed in CreateTestEntry: %d\n", rc);
00085       bResult = FALSE;
00086       }
00087     else
00088       // Just modify the existing entry to make sure DLL is set
00089       lstrcpy(RasEntry->szCustomDialDll, szDLLPath);
00090     }
00091   else
00092     {
00093     rc = RasGetEntryProperties(NULL, L"", RasEntry, &dwSize, NULL, NULL);
00094
00095     if (rc != ERROR_SUCCESS)
00096       {
00097       OutputTraceString(L"--- RasGetEntryProperties failed in CreateTestEntry: %d\n", rc);
00098       bResult = FALSE;
00099       }
00100     else
00101       {
00102       // Modify the default entry
00103       lstrcpy(RasEntry->szLocalPhoneNumber, RASCUSTOMDIAL_PHONENO);
00104       lstrcpy(RasEntry->szDeviceType, RASDT_Modem);
00105       lstrcpy(RasEntry->szCustomDialDll, szDLLPath);
00106
00107       //
00108       // enumerate to get the device name to use - we'll just pick one (a modem)
00109       //
00110       // first get the size of the buffer required
00111       LPRASDEVINFO lpRasDevInfo;
00112       DWORD dwNumEntries;
00113
00114       RasEnumDevices(NULL, &dwSize, &dwNumEntries);
00115       lpRasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
00116       if (lpRasDevInfo == NULL)
00117         {
00118         OutputTraceString(L"--- HeapAlloc failed in CreateTestEntry (GetLastError = %d)\n", GetLastError());
00119         bResult = FALSE;
00120         }
00121       else
00122         {
00123         lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
00124
00125         rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries);
00126         if (rc != ERROR_SUCCESS)
00127           {
00128           OutputTraceString(L"--- RasEnumDevices failed in CreateTestEntry: %d", rc);
00129           bResult = FALSE;
00130           }
00131         else
00132           {
00133           for (UINT i=0; i < dwNumEntries; i++, lpRasDevInfo++)
00134             {
00135             if (lstrcmpi(lpRasDevInfo->szDeviceType, RASDT_Modem) == 0)
00136               {
00137               OutputTraceString(L"-- Modem device: %s\n", lpRasDevInfo->szDeviceName);
00138               lstrcpy(RasEntry->szDeviceName, lpRasDevInfo->szDeviceName);
00139               break;
00140               }
00141             }
00142           }
00143
00144         HeapFree(GetProcessHeap(), 0, lpRasDevInfo);
00145         }
00146       }
00147     }
00148
00149   // write the phonebook entry.
00150   rc = RasSetEntryProperties(NULL, RASCUSTOMDIAL_ENTRYNAME, RasEntry, sizeof(RASENTRY), NULL, 0);
00151   if (rc != ERROR_SUCCESS)
00152     {
00153     OutputTraceString(L"--- RasSetEntryProperties failed in CreateTestEntry: %d\n", rc);
00154     bResult = FALSE;
00155     }
00156
00157   OutputTraceString(L"CreateTestEntry exiting customdial.dll\n");
00158
00159   return bResult;
00160 }
00161
00162 /*
00163  * CheckForSelf
00164  *
00165  * checks a buffer of \0 terminated strings for an instance of
00166  * string that could be present and returns the position of that
00167  * string in the buffer
00168  */
00169 TCHAR * CheckForSelf(LPCTSTR pSrc, LPBYTE pDest, DWORD dwBufLen)
00170 {
00171   DWORD dwLen = 0;  // length of the buffer
00172   TCHAR * p;        // pointer into the buffer
00173
00174   // loop through the buffer up to the length
00175   while (dwLen < dwBufLen)
00176     {
00177     p = (LPTSTR) &pDest[dwLen];   // get out string
00178
00179     if (lstrcmpi(pSrc, p) == 0)   // check it
00180       return p;
00181
00182     // go past string we just checked + the terminating '\0'
00183     dwLen = dwLen + ((lstrlen(p) + 1) * sizeof(TCHAR));
00184     }
00185
00186   return NULL;      // string was not found
00187 }
00188
00189 /*
00190  * DllRegisterServer
00191  *
00192  * We are "overriding" the intent of this to provide an easy way to
00193  * install our DLL into the correct registry locations using "common" tools
00194  * such as regsvr32.exe.
00195  *
00196  * We need to add our DLL to the list of custom dial DLLs in:
00197  * Path:       \\HKLM\System\CurrentControlSet\Services\Rasman\Parameters
00198  * Key Type:   REG_MULTI_SZ
00199  * Value Name: CustomDLL
00200  * Value:      Full path to the DLL
00201  *
00202  * this either return E_UNEXPECTED if any error occurred or S_OK if success or
00203  * if it is already there
00204  */
00205 STDAPI DllRegisterServer(void)
00206 {
00207   HRESULT hr = E_UNEXPECTED;    // return code
00208   HKEY hKey;                    // handle to open registry key
00209   TCHAR wszPath[MAX_PATH];      // full path to this DLL
00210
00211
00212   OutputTraceString(L"DllRegisterServer called in customdial.dll\n");
00213
00214   // get the path to this DLL
00215   GetModuleFileName((HMODULE) g_hInstance, wszPath, MAX_PATH);
00216
00217   // open registry for reading/writing
00218   if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, RASCUSTOMDIAL_KEYPATH,
00219                0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
00220     {
00221     // read in current value
00222     DWORD dwSize = 0;     // size of buffer for reading registry
00223     DWORD dwBufSize = 0;  // size of buffer for writing to registry
00224     DWORD dwType;         // type of buffer
00225     LPBYTE buffer = NULL; // the buffer
00226
00227     __try
00228       {
00229       // obtain current value size
00230       RegQueryValueEx(hKey, RASCUSTOMDIAL_VALUENAME, NULL, &dwType, NULL, &dwSize);
00231
00232       // allocate buffer to read (and write) all NULLs will be there
00233       if (dwSize > 0)
00234         dwBufSize = dwSize + (lstrlen(wszPath) * sizeof(TCHAR)) + sizeof(TCHAR);   // should be terminated in a \0
00235       else
00236         dwBufSize = (lstrlen(wszPath) * sizeof(TCHAR)) + (2 * sizeof(TCHAR));   // should be terminated in a \0\0 pair
00237
00238       buffer = (LPBYTE) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS, dwBufSize);
00239
00240       // read it if dwSize was > 0
00241       if (dwSize > 0)
00242         {
00243         if (RegQueryValueEx(hKey, RASCUSTOMDIAL_VALUENAME, NULL, &dwType, buffer, &dwSize) != ERROR_SUCCESS)
00244           return hr;    // force to finally block via AbnormalTermination
00245         }
00246
00247       // if it isn't there add it in
00248       if (CheckForSelf(wszPath, buffer, dwSize) == NULL)
00249         {
00250         DWORD dwBufPosition = 0;    // position of new string in the buffer
00251
00252         if (dwSize > 0)
00253           dwBufPosition = dwSize - sizeof(TCHAR); // back off original pos
00254
00255         // add to the buffer
00256         CopyMemory(&buffer[dwBufPosition], wszPath, lstrlen(wszPath) * sizeof(TCHAR));
00257
00258         // write it
00259         dwType = REG_MULTI_SZ;
00260         if (RegSetValueEx(hKey, RASCUSTOMDIAL_VALUENAME, 0, dwType, buffer, dwBufSize) != ERROR_SUCCESS)
00261           return hr;    // force to finally block via AbnormalTermination
00262         }
00263       else
00264         __leave;      // it is already there - force to finally block normally
00265       }
00266     __finally
00267       {
00268       if (!AbnormalTermination())
00269         {
00270         hr = S_OK;
00271         }
00272
00273       if (buffer)
00274         HeapFree(GetProcessHeap(), 0, buffer);
00275
00276       RegCloseKey(hKey);
00277       } // finally block
00278     }
00279
00280   CreateTestEntry(wszPath);
00281
00282   if (hr == S_OK)
00283     MessageBox(NULL, L"Windows may have to be restarted for the changes to take effect.",
00284                      L"CustomDial DLL Sample", MB_OK);
00285
00286   OutputTraceString(L"DllRegisterServer exiting customdial.dll with return code: 0x%08x\n", hr);
00287
00288   return hr;
00289 }
00290
00291 /*
00292  * DllUnregisterServer
00293  *
00294  * We are "overriding" the intent of this to provide an easy way to
00295  * uninstall our DLL from the registry using "common" tools such as
00296  * regsvr32.exe.
00297  *
00298  * this either return E_UNEXPECTED if any error occurred or S_OK if success or
00299  * if it isn't there
00300  */
00301 STDAPI DllUnregisterServer(void)
00302 {
00303   HRESULT hr = E_UNEXPECTED;    // return code
00304   HKEY hKey;                    // handle to open registry key
00305   TCHAR wszPath[MAX_PATH];      // full path to this DLL
00306   DebugBreak();
00307
00308   OutputTraceString(L"DllUnregisterServer called in customdial.dll\n");
00309
00310   // get the path to this DLL
00311   GetModuleFileName((HMODULE) g_hInstance, wszPath, MAX_PATH);
00312
00313   // open registry for reading/writing
00314   if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, RASCUSTOMDIAL_KEYPATH,
00315                0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
00316     {
00317     DWORD dwSize = 0;         // size of buffer for reading/writing registry
00318     DWORD dwType;             // type of buffer
00319     LPBYTE buffer = NULL;     // the buffer
00320     LPBYTE newBuffer = NULL;  // pointer to buffer
00321     TCHAR * p;                // pointer to the string in the buffer
00322     DWORD dwPos;              // position of string in buffer
00323
00324     __try
00325       {
00326       // obtain current value size
00327       RegQueryValueEx(hKey, RASCUSTOMDIAL_VALUENAME, NULL, &dwType, NULL, &dwSize);
00328
00329       if (dwSize > 0)
00330         {
00331         // allocate buffer to read
00332         buffer = (LPBYTE) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS, dwSize);
00333         }
00334       else
00335         __leave;        // there's nothing there...
00336
00337       // read current value
00338       if (RegQueryValueEx(hKey, RASCUSTOMDIAL_VALUENAME, NULL, &dwType, buffer, &dwSize) != ERROR_SUCCESS)
00339         return hr;    // force to finally block via AbnormalTermination
00340
00341       // rebuild buffer without the string in there
00342       newBuffer = buffer;
00343       p = CheckForSelf(wszPath, newBuffer, dwSize);
00344
00345       if (p == NULL)    // it's not there
00346         __leave;
00347
00348       // determine the position of the string in the buffer, move other data
00349       // accordingly and adjust size
00350       dwPos = (LPBYTE) p - newBuffer;
00351       if (dwPos == 0)
00352         {
00353         // it's the beginning - just move the buffer
00354         newBuffer = &newBuffer[(lstrlen(p) + 1) * sizeof(TCHAR)];
00355         dwSize = dwSize - ((lstrlen(p) + 1) * sizeof(TCHAR));
00356         }
00357       else
00358         if (dwPos + (lstrlen(p) * sizeof(TCHAR)) + (2 * sizeof(TCHAR)) == dwSize)
00359           {
00360           // it's the last one - adjust size and add a double termination
00361           dwSize = dwSize - ((lstrlen(p) + 1) * sizeof(TCHAR));
00362           CopyMemory(&newBuffer[dwSize - sizeof(TCHAR)], L"\0", sizeof(TCHAR));
00363           }
00364         else
00365           {
00366           // it's in the middle - move the back to overwriting the org. position
00367           DWORD dwCopySize = dwSize - (dwPos + ((lstrlen(p) + 1) * sizeof(TCHAR)));
00368           dwSize = dwSize - ((lstrlen(p) + 1) * sizeof(TCHAR));
00369           CopyMemory(&newBuffer[dwPos], &newBuffer[dwPos + ((lstrlen(p) + 1) * sizeof(TCHAR))], dwCopySize);
00370           }
00371
00372       // write it or delete it
00373       if (dwSize > sizeof(TCHAR))     // there is only 1 '\0' left...
00374         {
00375         dwType = REG_MULTI_SZ;
00376         if (RegSetValueEx(hKey, RASCUSTOMDIAL_VALUENAME, 0, dwType, newBuffer, dwSize) != ERROR_SUCCESS)
00377           return hr;    // force to finally block via AbnormalTermination
00378         }
00379       else
00380         if (RegDeleteValue(hKey, RASCUSTOMDIAL_VALUENAME) != ERROR_SUCCESS)
00381           return hr;    // force to finally block via AbnormalTermination
00382       }
00383     __finally
00384       {
00385       if (!AbnormalTermination())
00386         {
00387         // means there was no error during calls and we reached here via normal
00388         // unwrapping of the stack
00389         hr = S_OK;
00390         }
00391
00392       if (buffer)
00393         HeapFree(GetProcessHeap(), 0, buffer);
00394
00395       RegCloseKey(hKey);
00396       } // finally block
00397     }
00398
00399   // remove the test entry
00400   if (DWORD rc = RasDeleteEntry(NULL, RASCUSTOMDIAL_ENTRYNAME) != ERROR_SUCCESS)
00401     OutputTraceString(L"--- RasDeleteEntry failed in DllUnregisterServer: Error = %d\n", rc);
00402
00403   if (hr == S_OK)
00404     MessageBox(NULL, L"Windows may have to be restarted for the changes to take effect.",
00405                      L"CustomDial DLL Sample", MB_OK);
00406
00407   OutputTraceString(L"DllUnregisterServer exiting customdial.dll with return code: 0x%08x\n", hr);
00408
00409   return hr;
00410 }
00411
00412 // EOF: customdialreg.cpp
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/basenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

basenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Generic base node class.  All nodes are derived from this.
00014
00015
00016 #ifndef _CLASS_CBASENODE_
00017 #define _CLASS_CBASENODE_
00018
00019 #include "Globals.h"
00020 #include "Resource.h"
00021
00022
00023 #define DEFAULT_SDI_MASK  (SDI_STR | SDI_PARAM | SDI_IMAGE | SDI_OPENIMAGE | SDI_PARENT | SDI_CHILDREN)
00024 #define DEFAULT_RDI_MASK  (RDI_STR | RDI_PARAM | RDI_IMAGE)
00025
00026 #define MAX_NAME_LEN     64
00027
00028
00029 class CBaseNode;
00030
00031
00032 //---------------------------------------------------------------------------
00033 //  Data types specific to this object
00034 //
00035 typedef struct tag_BASENODE_PROPERTIES
00036 {
00037   WCHAR      szNodeName[MAX_NAME_LEN];
00038   LONG_PTR   pComponentData;
00039   LONG_PTR   pParentObject;
00040   DWORD      dwAttributes;         // CONTEXTMENU:  New member for creating
00041                                    //               nodes from a menu
00042 }NODE_PROPERTIES;
00043
00044
00045 typedef NODE_PROPERTIES*  LPNODE_PROPERTIES;
00046 typedef CBaseNode*        LPBASENODE;
00047
00048
00049 //---------------------------------------------------------------------------
00050 class CBaseNode
00051 {
00052   public:
00053     CBaseNode()
00054     {
00055       m_pwszNodeName      = NULL;
00056
00057       ZeroMemory( &m_SDI, sizeof(SCOPEDATAITEM) );
00058       ZeroMemory( &m_RDI, sizeof(RESULTDATAITEM) );
00059     };
00060
00061     virtual ~CBaseNode()
00062     {
00063       if( NULL != m_pwszNodeName )
00064         CoTaskMemFree( m_pwszNodeName );
00065     };
00066
00067   public:
00068     LPWSTR   GetNodeName()     { return m_pwszNodeName;  }
00069
00070     virtual  HRESULT Initialize( NODE_PROPERTIES* pProperties ) = 0;
00071     virtual  ULONG   GetNodeType() = 0;
00072     virtual  GUID&   GetNodeGUID() = 0;
00073
00074   ///////////////////////////////////////////////////////////////////////////
00075   // These virtual methods handle calls from the console
00076   //
00077   public:
00078     virtual  HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI ) = 0;
00079     virtual  HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI ) = 0;
00080     virtual  HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo ) = 0;
00081
00082   ///////////////////////////////////////////////////////////////////////////
00083   // CONTEXTMENU:  Support calls in the basenode
00084   //
00085   public:
00086     virtual  HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed ) = 0;
00087     virtual  HRESULT Command( long lCommandID ) = 0;
00088
00089   ///////////////////////////////////////////////////////////////////////////
00090   // These virtual methods handle notifications
00091   //
00092   public:
00093     virtual  HRESULT OnSelect( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent ) = 0;
00094     virtual  HRESULT OnShow( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent ) = 0;
00095     virtual  HRESULT OnExpand( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData ) = 0;
00096     virtual  HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData ) = 0;
00097
00098   public:
00099     SCOPEDATAITEM    m_SDI;
00100     RESULTDATAITEM   m_RDI;
00101
00102   protected:
00103     LPWSTR     m_pwszNodeName;
00104
00105 }; //end class CBaseNode
00106
00107 #endif //_CLASS_CBASENODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Find.h Source File

  • WinUI
  • CommDlg
  • CDTest

Find.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 BOOL bDoFindDlg ;
00007
00008 HHOOK hHook ;
00009
00010 LRESULT CALLBACK lpfnFilterProc(int, WPARAM, LPARAM) ;
00011
00012
00013 void DoFindDialog(HWND) ;
00014 INT_PTR APIENTRY FindProc(HWND, UINT, WPARAM, LPARAM) ;
00015
00016
00017
00018 #define ID_STRUCTSIZEFT             111
00019 #define ID_HWNDOWNERFT              112
00020 #define ID_FLAGSFT                  113
00021 #define ID_FINDWHATFT               114
00022 #define ID_REPLACEWITHFT            115
00023 #define ID_FINDWHATLENFT            116
00024 #define ID_REPLACEWITHLENFT         117
00025 #define ID_CUSTDATAFT               118
00026 #define ID_HOOKFT                   119
00027 #define ID_TEMPLATEFT               120
00028 #define ID_ERRORFT                  123
00029 #define ID_RETURNFT                 124
00030
00031
00032 #define ID_FINDDIALOG               600
00033 #define ID_HINSTANCEFT              125
00034 #define ID_RESETFIND                127
00035 #define ID_FLAGSMSG                 128
00036 #define ID_FRNULLSTRUCT             601
00037 #define ID_PRELOADEDFIND            602
00038 #define ID_MULTITHREADFINDREP       603
00039
00040
00041 #define ID_FINDLEFT                 604
00042 #define ID_FINDRIGHT                605
00043 #define ID_DEFSTRINGS               101
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/PerfDllS/AppMem/appDll/AppMema.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • PerfDllS
  • AppMem
  • appDll

AppMema.h

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1995 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011     appmema.h
00012
00013 Abstract:
00014
00015     application memory performance counter definitions
00016
00017 --*/
00018 #ifndef _APPMEMA_H_
00019 #define _APPMEMA_H_
00020
00021 #include "..\inc\appmemi.h"
00022
00023 struct _APPMEM_DATA_HEADER * pDataHeader;
00024 struct _APPMEM_INSTANCE    * pAppData;
00025
00026 #endif // _APPMEMA_H_
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/_Command.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

_Command.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface _Command
00019 /** @com.interface(iid=0000054E-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface _Command extends msado15.Command15
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=1610809344, type=PROPGET, name="ActiveConnection", name2="getActiveConnection", addFlagsVtable=4)
00027       @com.parameters([iid=00000550-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00028   public msado15._Connection getActiveConnection();
00029
00030   /** @com.method(vtoffset=6, dispid=1610809344, type=PROPPUTREF, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00031       @com.parameters([in,iid=00000550-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] ppvObject) */
00032   public void setActiveConnection(msado15._Connection ppvObject);
00033
00034   /** @com.method(vtoffset=7, dispid=1610809344, type=PROPPUT, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00035       @com.parameters([in,type=VARIANT] ppvObject) */
00036   public void setActiveConnection(Variant ppvObject);
00037
00038   /** @com.method(vtoffset=8, dispid=1610809347, type=PROPGET, name="CommandText", name2="getCommandText", addFlagsVtable=4)
00039       @com.parameters([type=STRING] return) */
00040   public String getCommandText();
00041
00042   /** @com.method(vtoffset=9, dispid=1610809347, type=PROPPUT, name="CommandText", name2="putCommandText", addFlagsVtable=4)
00043       @com.parameters([in,type=STRING] pbstr) */
00044   public void setCommandText(String pbstr);
00045
00046   /** @com.method(vtoffset=10, dispid=1610809349, type=PROPGET, name="CommandTimeout", name2="getCommandTimeout", addFlagsVtable=4)
00047       @com.parameters([type=I4] return) */
00048   public int getCommandTimeout();
00049
00050   /** @com.method(vtoffset=11, dispid=1610809349, type=PROPPUT, name="CommandTimeout", name2="putCommandTimeout", addFlagsVtable=4)
00051       @com.parameters([in,type=I4] pl) */
00052   public void setCommandTimeout(int pl);
00053
00054   /** @com.method(vtoffset=12, dispid=1610809351, type=PROPGET, name="Prepared", name2="getPrepared", addFlagsVtable=4)
00055       @com.parameters([type=BOOLEAN] return) */
00056   public boolean getPrepared();
00057
00058   /** @com.method(vtoffset=13, dispid=1610809351, type=PROPPUT, name="Prepared", name2="putPrepared", addFlagsVtable=4)
00059       @com.parameters([in,type=BOOLEAN] pfPrepared) */
00060   public void setPrepared(boolean pfPrepared);
00061
00062   /** @com.method(vtoffset=14, dispid=1610809353, type=METHOD, name="Execute", addFlagsVtable=4)
00063       @com.parameters([out,elementType=VARIANT,type=PTR] RecordsAffected, [in,elementType=VARIANT,type=PTR] Parameters, [in,type=I4] Options, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00064   public msado15._Recordset Execute(Variant RecordsAffected, Variant Parameters, int Options);
00065
00066   /** @com.method(vtoffset=15, dispid=1610809354, type=METHOD, name="CreateParameter", addFlagsVtable=4)
00067       @com.parameters([in,type=STRING] Name, [in,type=I4] Type, [in,type=I4] Direction, [in,type=I4] Size, [in,type=VARIANT] Value, [iid=0000050C-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00068   public msado15._Parameter CreateParameter(String Name, int Type, int Direction, int Size, Variant Value);
00069
00070   /** @com.method(vtoffset=16, dispid=0, type=PROPGET, name="Parameters", name2="getParameters", addFlagsVtable=4)
00071       @com.parameters([iid=0000050D-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00072   public msado15.Parameters getParameters();
00073
00074   /** @com.method(vtoffset=17, dispid=1610809356, type=PROPPUT, name="CommandType", name2="putCommandType", addFlagsVtable=4)
00075       @com.parameters([in,type=I4] plCmdType) */
00076   public void setCommandType(int plCmdType);
00077
00078   /** @com.method(vtoffset=18, dispid=1610809356, type=PROPGET, name="CommandType", name2="getCommandType", addFlagsVtable=4)
00079       @com.parameters([type=I4] return) */
00080   public int getCommandType();
00081
00082   /** @com.method(vtoffset=19, dispid=1610809358, type=PROPGET, name="Name", name2="getName", addFlagsVtable=4)
00083       @com.parameters([type=STRING] return) */
00084   public String getName();
00085
00086   /** @com.method(vtoffset=20, dispid=1610809358, type=PROPPUT, name="Name", name2="putName", addFlagsVtable=4)
00087       @com.parameters([in,type=STRING] pbstrName) */
00088   public void setName(String pbstrName);
00089
00090   /** @com.method(vtoffset=21, dispid=1610874880, type=PROPGET, name="State", name2="getState", addFlagsVtable=4)
00091       @com.parameters([type=I4] return) */
00092   public int getState();
00093
00094   /** @com.method(vtoffset=22, dispid=1610874881, type=METHOD, name="Cancel", addFlagsVtable=4)
00095       @com.parameters() */
00096   public void Cancel();
00097
00098
00099   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x54e, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00100 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/land.Cpp Source File

  • SysMgmt
  • MMC
  • ActiveX

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPTLauncher Member List

This is the complete list of members for CPTLauncher, including all inherited members.
CPTLauncher() | CPTLauncher | [inline]
LaunchPT() | CPTLauncher |
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ipv6_fragment_hdr Member List

This is the complete list of members for ipv6_fragment_hdr, including all inherited members.
ipv6_frag_id | ipv6_fragment_hdr
ipv6_frag_nexthdr | ipv6_fragment_hdr
ipv6_frag_offset | ipv6_fragment_hdr
ipv6_frag_reserved | ipv6_fragment_hdr
Generated on Wed Nov 13 2024 16:57:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/AdvReco/resource.h Source File

  • TabletPC
  • AdvReco

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by AdvReco.rc
00004 //
00005 #define IDR_APPICON                     50
00006 #define IDS_GESTURE_UNKNOWN             99
00007 #define IDS_SSGESTURE_FIRST             100
00008 #define IDR_MENU                        101
00009 #define IDS_STRING101                   101
00010 #define IDS_STRING102                   102
00011 #define IDS_STRING103                   103
00012 #define IDS_STRING104                   104
00013 #define IDS_STRING105                   105
00014 #define IDS_STRING106                   106
00015 #define IDS_STRING107                   107
00016 #define IDS_STRING108                   108
00017 #define IDS_STRING109                   109
00018 #define IDS_STRING110                   110
00019 #define IDS_STRING111                   111
00020 #define IDS_STRING112                   112
00021 #define IDS_STRING113                   113
00022 #define IDS_STRING114                   114
00023 #define IDS_STRING115                   115
00024 #define IDS_STRING116                   116
00025 #define IDS_STRING117                   117
00026 #define IDS_STRING118                   118
00027 #define IDS_STRING119                   119
00028 #define IDS_STRING120                   120
00029 #define IDS_STRING121                   121
00030 #define IDS_STRING122                   122
00031 #define IDS_STRING123                   123
00032 #define IDS_STRING124                   124
00033 #define IDS_STRING125                   125
00034 #define IDS_STRING126                   126
00035 #define IDS_STRING127                   127
00036 #define IDS_STRING128                   128
00037 #define IDS_STRING129                   129
00038 #define IDS_STRING130                   130
00039 #define IDS_STRING131                   131
00040 #define IDS_STRING132                   132
00041 #define IDS_STRING133                   133
00042 #define IDS_STRING134                   134
00043 #define IDS_STRING135                   135
00044 #define IDS_STRING136                   136
00045 #define IDS_MSGESTURE_FIRST             200
00046 #define IDS_STRING201                   201
00047 #define IDS_STRING202                   202
00048 #define IDS_STRING203                   203
00049 #define IDS_STRING204                   204
00050 #define IDS_STRING205                   205
00051 #define IDS_STRING206                   206
00052 #define IDS_STRING207                   207
00053 #define ID_RECOGNIZER_DEFAULT           40000
00054 #define ID_RECOGNIZER_FIRST             40001
00055 #define ID_RECOGNIZER_LAST              40099
00056 #define ID_INPUTSCOPE_COERCE           40100
00057 #define ID_INPUTSCOPE_FIRST                40101
00058 #define ID_INPUTSCOPE_LAST                 40199
00059 #define ID_RECOGNIZE                    40301
00060 #define ID_CLEAR                        40302
00061 #define ID_GUIDE_NONE                   40303
00062 #define ID_GUIDE_LINES                  40304
00063 #define ID_GUIDE_BOXES                  40305
00064 #define ID_MODE_INK                     40306
00065 #define ID_MODE_INK_AND_GESTURES        40307
00066 #define ID_MODE_GESTURES                40308
00067 #define ID_EXIT                         40309
00068
00069 // Next default values for new objects
00070 //
00071 #ifdef APSTUDIO_INVOKED
00072 #ifndef APSTUDIO_READONLY_SYMBOLS
00073 #define _APS_NEXT_RESOURCE_VALUE        104
00074 #define _APS_NEXT_COMMAND_VALUE         40310
00075 #define _APS_NEXT_CONTROL_VALUE         1000
00076 #define _APS_NEXT_SYMED_VALUE           101
00077 #endif
00078 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/dxtrans/dxsurf1/dxsurf1.cpp Source File

  • Web
  • dxtrans
  • dxsurf1

dxsurf1.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // File: DXSurf1.CPP
00003 //
00004 // Desc: DXSurface example program 1.  Allows the user to load an image onto a
00005 //       DXSurface and then blits it to a second, primary DXSurface.
00006 //
00007 // Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
00008 //-----------------------------------------------------------------------------
00009
00010 //-----------------------------------------------------------------------------
00011 // Include files
00012 //-----------------------------------------------------------------------------
00013 #include <windows.h>
00014 #include <initguid.h>
00015 #include <stdio.h>
00016 #include <stdarg.h>
00017 #include <dxtrans.h>  // DXSurface header file
00018 #include <dxtguid.c>  // Guids for DXSurfaces
00019 #include <dxterror.h> // DXSurface error codes
00020 #include <dxbounds.h> // Contains the CDXDVec and CDXDBnds classes used in this program
00021 #include "resource.h"
00022
00023 //-----------------------------------------------------------------------------
00024 // Local definitions
00025 //-----------------------------------------------------------------------------
00026 #define NAME                "DXSurf1"
00027 #define TITLE               "DXSurface Example 1"
00028 #define SAFE_RELEASE( ptr )         \
00029 {                                   \
00030         if (ptr) ptr->Release();    \
00031         ptr=NULL;                   \
00032 }
00033 //-----------------------------------------------------------------------------
00034 // Global data
00035 //-----------------------------------------------------------------------------
00036 IDXSurfaceFactory*      g_pSurfFact                 = NULL;
00037 IDXSurface*             g_pDXImageSurf              = NULL;
00038 IDXSurface*             g_pPrimaryDXSurf            = NULL;
00039 BOOL                    g_bActive                   = FALSE;
00040
00041 //-----------------------------------------------------------------------------
00042 // Name: ReleaseAllObjects()
00043 // Desc: Finished with all objects we use; release them.
00044 //-----------------------------------------------------------------------------
00045 static void ReleaseAllObjects( void )
00046 {
00047     SAFE_RELEASE( g_pDXImageSurf )
00048     SAFE_RELEASE( g_pPrimaryDXSurf )
00049     SAFE_RELEASE( g_pSurfFact )
00050 }
00051
00052 //-----------------------------------------------------------------------------
00053 // Name: InitFail()
00054 // Desc: This function is called if an initialization function fails.
00055 //-----------------------------------------------------------------------------
00056 HRESULT InitFail( HWND hWnd, HRESULT hr, LPCTSTR szError,... )
00057 {
00058     char                        szBuff[128];
00059     va_list                     vl;
00060
00061     g_bActive = FALSE;
00062     va_start( vl, szError );
00063     vsprintf( szBuff, szError, vl );
00064     ReleaseAllObjects();
00065     MessageBox( hWnd, szBuff, TITLE, MB_OK );
00066     DestroyWindow( hWnd );
00067     va_end( vl );
00068     return hr;
00069 }
00070
00071 //-----------------------------------------------------------------------------
00072 // Name: OnFileOpen()
00073 // Desc: This function pops the Open File Dialog and retrieves a string for
00074 //       the call to LoadImage.
00075 //-----------------------------------------------------------------------------
00076 BOOL OnFileOpen( HWND hWnd, LPSTR szName )
00077 {
00078     OPENFILENAME    ofn;
00079
00080     // Initialize the OPENFILENAME structure.
00081     memset( &ofn, 0, sizeof( OPENFILENAME ) );
00082     ofn.lStructSize      = sizeof( OPENFILENAME );
00083     ofn.hwndOwner        = hWnd;
00084     ofn.lpstrFilter      = "Image files (*.png;*.jpg;*.bmp)\0*.png;*.jpg;*.bmp\0All files {*.*}\0*.*\0\0";
00085     ofn.lpstrFile        = szName;
00086     ofn.lpstrInitialDir  = "c:\\dxmedia\\samples\\multimedia\\media\\image";
00087     ofn.nMaxFile         = 256;
00088     ofn.Flags            = OFN_FILEMUSTEXIST;
00089     ofn.lpstrDefExt      = "png";
00090
00091     // Create the open file dialog.
00092     return GetOpenFileName( &ofn );
00093 }
00094
00095 //-----------------------------------------------------------------------------
00096 // Name: RestoreLostSurfaces()
00097 // Desc: Restores the underlying DirectDraw surface if the display memory is
00098 //       lost to another application . This can happen if the user presses
00099 //       Alt-Tab (see DirectDraw SDK for more information on this). We only need
00100 //       to worry about the primary surface since its a video memory surface.
00101 //       The other DXSurface (g_pDXImageSurf) which contains the image is a
00102 //       system memory surface since that is the default DXSurface type.
00103 //-----------------------------------------------------------------------------
00104 void RestoreLostSurfaces( HWND hWnd )
00105 {
00106     HRESULT                 hr;
00107     IDirectDrawSurface2*    pUnderlyingPrimaryDDSurf    = NULL;
00108
00109     // Get the underlying DirectDraw surface for the Primary DXSurface.
00110     hr = g_pPrimaryDXSurf->GetDirectDrawSurface( IID_IDirectDrawSurface,
00111                                             (void**)&pUnderlyingPrimaryDDSurf );
00112     if( SUCCEEDED( hr ) )
00113     {
00114         // Restore any potentially lost contents from window swapping.
00115         if( pUnderlyingPrimaryDDSurf->IsLost() == DDERR_SURFACELOST )
00116         {
00117             hr = pUnderlyingPrimaryDDSurf->Restore();
00118         }
00119
00120         // Release the Direct Draw Surface.
00121         pUnderlyingPrimaryDDSurf->Release();
00122     }
00123
00124     if ( FAILED( hr ) )
00125         InitFail( hWnd, hr, "RestoreLostSurfaces() failed" );
00126 }
00127
00128 //-----------------------------------------------------------------------------
00129 // Name: WindowProc()
00130 // Desc: The Main Window Procedure
00131 //-----------------------------------------------------------------------------
00132 LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
00133 {
00134     HRESULT         hr = S_OK;
00135     HDC             hdcWnd;
00136     PAINTSTRUCT     ps;
00137     RECT            rect;
00138     POINT           point;
00139     char            szError[256] = "";
00140     char            szFileName[256] = "";
00141     WCHAR           szWFileName[256];
00142
00143     switch( iMsg )
00144     {
00145     case WM_PAINT:
00146         hdcWnd = BeginPaint( hWnd, &ps );
00147
00148         GetClientRect( hWnd, &rect );
00149         SetBkMode( hdcWnd, TRANSPARENT );
00150
00151         // Render the DXSurface.
00152         if( g_bActive )
00153         {
00154             point.x = rect.top;
00155             point.y = rect.left;
00156             ClientToScreen(hWnd, &point);
00157
00158             // Initialize the placement vector for the BitBlt with the top left corner
00159             // coordinates of the window.
00160             CDXDVec   vPlacement( point.x, point.y, 0, 0 );
00161
00162             // Set the portion of the primary surface that we want to BitBlt to to be
00163             // the size of the window.
00164             CDXDBnds  PortionBnds( rect.right, rect.bottom );
00165
00166             // Use IDXSurfaceFactory::BitBlt to blit the eagle (g_pDXImageSurf) to the Primary
00167             // Surface (g_pPrimaryDXSurf).
00168             hr = g_pSurfFact->BitBlt( g_pPrimaryDXSurf, &vPlacement, g_pDXImageSurf,
00169                                                 &PortionBnds, DXBOF_DO_OVER );
00170             if ( FAILED( hr ) )
00171                 return InitFail( hWnd, hr, "BitBlt failed" );
00172
00173             DrawText( hdcWnd, "DXSurface Sample 1. Demonstrates DXSurface BitBlt to a "
00174                       "Primary Surface.", -1, &rect,
00175                       DT_CENTER | DT_BOTTOM | DT_SINGLELINE );
00176         }
00177         else
00178         {
00179             DrawText( hdcWnd, "DXSurface Sample 1. Please open an image file.", -1, &rect,
00180                       DT_CENTER | DT_BOTTOM | DT_SINGLELINE );
00181         }
00182
00183         EndPaint( hWnd, &ps );
00184         break;
00185
00186     case WM_ACTIVATE:
00187         {
00188             if( g_bActive )
00189             {
00190                 // If someone switches between windows using Alt-Tab the contents of the
00191                 // underlying DDraw Surfaces may get lost. This function restores them.
00192                 RestoreLostSurfaces( hWnd );
00193             }
00194             break;
00195         }
00196
00197     case WM_COMMAND :
00198         switch( LOWORD( wParam ) )
00199         {
00200             case IDM_OPEN:
00201                 // Check if the open file dialog succeed.
00202                 if( OnFileOpen( hWnd, szFileName ) )
00203                 {
00204                     // Convert the szFileName string to a Unicode string.
00205                     mbstowcs( szWFileName, szFileName, 256 );
00206
00207                     // Release any previous image surfaces.
00208                     SAFE_RELEASE( g_pDXImageSurf );
00209
00210                     // Call load image which creates a DXSurface with an image on it.
00211                     hr = g_pSurfFact->LoadImage( szWFileName, NULL, NULL,
00212                                     &DDPF_PMARGB32, IID_IDXSurface, (void**)&g_pDXImageSurf );
00213                     if( FAILED( hr ) )
00214                     {
00215                         if( hr == DXTERR_REQ_IE_DLLNOTFOUND ) // Possibly need IE4.0 or greater.
00216                         {
00217                             return InitFail( hWnd, hr, "LoadImage failed!\n"
00218                                 "Possible cause is that IE4.0 or greater is not installed.");
00219                         }
00220                         else
00221                         {
00222                             // Note - some possible errors may include:
00223                             // MK_E_SYNTAX - Couldn't find the image directory
00224                             // INET_E_RESOURCE_NOT_FOUND - Couldn't find the image filename
00225                             sprintf( szError, "LoadImage failed with error code 0x%X.", hr );
00226                             return InitFail( hWnd, hr, szError );
00227                         }
00228                     }
00229
00230                     // Let the app know that its now active and from here on when it processes
00231                     // WM_PAINT messages it can Blit. Prior to this we don't want to call
00232                     // BitBlt in WM_PAINT.
00233                     g_bActive = TRUE;
00234
00235                     // Force a WM_PAINT message.
00236                     InvalidateRect( NULL, NULL, TRUE );
00237                 }
00238                 break;
00239
00240             case IDM_EXIT:
00241                 SendMessage( hWnd, WM_DESTROY, 0, 0 );
00242                 break;
00243
00244             case IDM_ABOUT:
00245                 MessageBox( hWnd, "DXSurface Sample 1.\nDemonstrates DXSurface BitBlt to a "
00246                           "Primary Surface.\n\nCopyright © 2001 Microsoft® Corporation",
00247                           "About", MB_OK );
00248                 break;
00249         }
00250         break;
00251
00252     case WM_DESTROY:
00253         ReleaseAllObjects();
00254         PostQuitMessage( 0 );
00255         break;
00256     }
00257
00258     return DefWindowProc( hWnd, iMsg, wParam, lParam );
00259 }
00260
00261 //-----------------------------------------------------------------------------
00262 // Name: InitApp()
00263 // Desc: Do work required for every instance of the application:
00264 //       Create the window, initialize data.
00265 //-----------------------------------------------------------------------------
00266 static HRESULT
00267 InitApp( HINSTANCE hInstance, int iCmdShow )
00268 {
00269     HRESULT     hr;
00270     HWND        hWnd;
00271     WNDCLASSEX  wndclass;
00272
00273     wndclass.cbSize         = sizeof( wndclass );
00274     wndclass.style          = CS_HREDRAW | CS_VREDRAW;
00275     wndclass.lpfnWndProc    = WndProc;
00276     wndclass.cbClsExtra     = 0;
00277     wndclass.cbWndExtra     = 0;
00278     wndclass.hInstance      = hInstance;
00279     wndclass.hIcon          = LoadIcon( hInstance, MAKEINTRESOURCE(IDI_DXTICON) );
00280     wndclass.hCursor        = LoadCursor( NULL, IDC_ARROW );
00281     wndclass.hbrBackground  = ( HBRUSH ) GetStockObject( GRAY_BRUSH );
00282     wndclass.lpszMenuName   = MAKEINTRESOURCE(IDR_MENU1);
00283     wndclass.lpszClassName  = NAME;
00284     wndclass.hIconSm        = LoadIcon( hInstance, MAKEINTRESOURCE(IDI_DXTICON) );
00285
00286     RegisterClassEx( &wndclass );
00287
00288     hWnd = CreateWindowEx( NULL,
00289                            NAME,
00290                            TITLE,
00291                            WS_OVERLAPPEDWINDOW,
00292                            CW_USEDEFAULT,
00293                            CW_USEDEFAULT,
00294                            CW_USEDEFAULT,
00295                            CW_USEDEFAULT,
00296                            NULL,
00297                            NULL,
00298                            hInstance,
00299                            NULL );
00300
00301     if ( !hWnd )
00302         return FALSE;
00303     ShowWindow( hWnd, iCmdShow );
00304     UpdateWindow( hWnd );
00305
00306     // Create the Surface Factory and return a pointer
00307     // (note the CLSID says DXTransformFactory but these are the same object).
00308     hr = CoCreateInstance( CLSID_DXTransformFactory, NULL, CLSCTX_INPROC,
00309                              IID_IDXSurfaceFactory, (void **)&g_pSurfFact );
00310     if ( FAILED( hr ) )
00311         return InitFail( hWnd, hr, "Failed to create the Surface Factory" );
00312
00313     // Initialize the DDSURFACEDESC structure.
00314     DDSURFACEDESC   ddsd;
00315
00316     ZeroMemory( &ddsd, sizeof( ddsd ) );
00317     ddsd.dwSize = sizeof( ddsd );
00318     ddsd.dwFlags = DDSD_CAPS;
00319     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
00320
00321     // Pass in DDraw info to the call to IDXSurfaceFactory::CreateSurface so it
00322     // will know what type of underlying surface to create. Note that applications
00323     // that don't care what type of underlying Direct Draw surface to use would just
00324     // pass NULL for the first 2 parameters.
00325     // Applications that use this method for creating surfaces other than primary
00326     // surfaces will have to specify dimensions either through the DDSURFACEDESC
00327     // parameter (param 2) or throught the DXBNDS parameter (param 4).
00328     hr = g_pSurfFact->CreateSurface( NULL, &ddsd, NULL, NULL, 0,
00329                             NULL, IID_IDXSurface, (void **)&g_pPrimaryDXSurf );
00330     if ( FAILED( hr ) )
00331         return InitFail( hWnd, hr, "Failed to create a primary DXSurface." );
00332
00333     return hr;
00334 }
00335
00336 //-----------------------------------------------------------------------------
00337 // Name: WinMain()
00338 // Desc: Initialization, message loop.
00339 //-----------------------------------------------------------------------------
00340 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
00341 {
00342     MSG         msg;
00343
00344     // Initialize the COM library.
00345     CoInitialize( NULL );
00346
00347     if ( InitApp( hInstance, iCmdShow ) != S_OK )
00348     {
00349         ReleaseAllObjects();
00350         return FALSE;
00351     }
00352
00353     while( GetMessage ( &msg, NULL, 0, 0 ) )
00354     {
00355         TranslateMessage( &msg );
00356         DispatchMessage( &msg );
00357     }
00358
00359     // Uninitialize the COM library.
00360     CoUninitialize();
00361
00362     return msg.wParam;
00363 }
00364
00365
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/adoid.h Source File

  • Dataaccess
  • rds
  • handler
  • vc

adoid.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:    adoid.h
00004 //
00005 // Copyright: Copyright (c) 1996-1999 Microsoft Corporation
00006 //
00007 // Contents:  ADO Guids
00008 //
00009 // Comments:
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 #ifndef _ADOID_H_
00014 #define _ADOID_H_
00015
00016 // The following range of 255 guids has been reserved for the base objects.
00017 //  00000200-0000-0010-8000-00AA006D2EA4 - 000002FF-0000-0010-8000-00AA006D2EA4
00018 // If you need more then please take a range from daoguid.txt and update that file in
00019
00020 #define DEFINE_DAOGUID(name, l) \
00021     DEFINE_GUID(name, l, 0, 0x10, 0x80,0,0,0xAA,0,0x6D,0x2E,0xA4)
00022
00023 // major version of the ADO type library
00024 #define ADO_MAJOR 2
00025
00026 // Type library
00027 DEFINE_DAOGUID(LIBID_CADO10,          0x00000200);
00028 DEFINE_DAOGUID(LIBID_CADOR10,         0x00000300);
00029
00030 // Error
00031 DEFINE_DAOGUID(IID_IADOError,            0x00000500);
00032 DEFINE_DAOGUID(IID_IADOErrors,           0x00000501);
00033
00034 // Property
00035 DEFINE_DAOGUID(IID_IADOProperty,         0x00000503);
00036 DEFINE_DAOGUID(IID_IADOProperties,       0x00000504);
00037
00038 // Field
00039 DEFINE_DAOGUID(IID_IADOField,            0x00000505);
00040 DEFINE_DAOGUID(IID_IADOFields,           0x00000506);
00041
00042 // Command
00043 DEFINE_DAOGUID(CLSID_CADOCommand,   0x00000507);
00044 DEFINE_DAOGUID(IID_IADOCommand,     0x00000508);
00045 DEFINE_DAOGUID(IID_IADOCommands,        0x00000509);
00046
00047 // Parameter
00048 DEFINE_DAOGUID(CLSID_CADOParameter,   0x0000050B);
00049 DEFINE_DAOGUID(IID_IADOParameter,        0x0000050C);
00050 DEFINE_DAOGUID(IID_IADOParameters,       0x0000050D);
00051
00052 //Recordset
00053 DEFINE_DAOGUID(CLSID_CADORecordset,    0x00000535);
00054 DEFINE_DAOGUID(IID_IADORecordset,    0x0000050E);
00055 DEFINE_DAOGUID(IID_IADORecordsets,     0x0000050F);
00056 DEFINE_DAOGUID(IID_IADORecordsetConstruction,     0x00000283);
00057
00058 // Collections
00059 DEFINE_DAOGUID(IID_IADOCollection,       0x00000512);
00060 DEFINE_DAOGUID(IID_IADODynaCollection,   0x00000513);
00061
00062 // Connection
00063 DEFINE_DAOGUID(CLSID_CADOConnection,     0x00000514);
00064 DEFINE_DAOGUID(IID_IADOConnection,       0x00000515);
00065 DEFINE_DAOGUID(IID_IADOConnections,      0x00000518);
00066
00067 // Enums
00068 DEFINE_DAOGUID(IID_EnumCursorType,      0x0000051B);
00069 DEFINE_DAOGUID(IID_EnumCursorOption,    0x0000051C);
00070 DEFINE_DAOGUID(IID_EnumLockType,      0x0000051D);
00071 DEFINE_DAOGUID(IID_EnumExecuteOption,   0x0000051E);
00072 DEFINE_DAOGUID(IID_EnumDataType,      0x0000051F);
00073 DEFINE_DAOGUID(IID_EnumConnectPrompt,   0x00000520);
00074 DEFINE_DAOGUID(IID_EnumConnectMode,     0x00000521);
00075 DEFINE_DAOGUID(IID_EnumPrepareOption,   0x00000522);
00076 DEFINE_DAOGUID(IID_EnumIsolationLevel,    0x00000523);
00077 DEFINE_DAOGUID(IID_EnumXactAttribute,   0x00000524);
00078 DEFINE_DAOGUID(IID_EnumFieldAttribute,    0x00000525);
00079 DEFINE_DAOGUID(IID_EnumEditMode,      0x00000526);
00080 DEFINE_DAOGUID(IID_EnumRecordStatus,    0x00000527);
00081 DEFINE_DAOGUID(IID_EnumPosition,      0x00000528);
00082 DEFINE_DAOGUID(IID_EnumPropertyAttributes,  0x00000529);
00083 DEFINE_DAOGUID(IID_EnumErrorValue,      0x0000052A);
00084 DEFINE_DAOGUID(IID_EnumParameterAttributes, 0x0000052B);
00085 DEFINE_DAOGUID(IID_EnumParameterDirection,  0x0000052C);
00086 DEFINE_DAOGUID(IID_EnumFilterCriteria,    0x0000052D);
00087 DEFINE_DAOGUID(IID_EnumCommandType,     0x0000052E);
00088 DEFINE_DAOGUID(IID_EnumCursorLocation,    0x0000052F);
00089 DEFINE_DAOGUID(IID_EnumEventStatus,     0x00000530);
00090 DEFINE_DAOGUID(IID_EnumEventReason,     0x00000531);
00091 DEFINE_DAOGUID(IID_EnumObjectState,     0x00000532);
00092 DEFINE_DAOGUID(IID_EnumSchema,        0x00000533);
00093 DEFINE_DAOGUID(IID_EnumMarshalOptions,    0x00000540);
00094
00095 #endif // _ADOID_H_
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IAnnotator Member List

This is the complete list of members for IAnnotator, including all inherited members.
AddComment() | IAnnotator
AttachAnnotator(IHTMLDocument2 *pDoc) | IAnnotator
DetachAnnotator() | IAnnotator
ShowCommentGlyphs(BOOL bShow) | IAnnotator
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Recordset15 Member List

This is the complete list of members for msado15::Recordset15, including all inherited members.
_xClone() | msado15::Recordset15 |
_xResync(int AffectRecords) | msado15::Recordset15 |
AddNew(Variant FieldList, Variant Values) | msado15::Recordset15 |
CancelBatch(int AffectRecords) | msado15::Recordset15 |
CancelUpdate() | msado15::Recordset15 |
Close() | msado15::Recordset15 |
Delete(int AffectRecords) | msado15::Recordset15 |
Find(String Criteria, int SkipRecords, int SearchDirection, Variant Start) | msado15::Recordset15 |
getAbsolutePage() | msado15::Recordset15 |
getAbsolutePosition() | msado15::Recordset15 |
getActiveConnection() | msado15::Recordset15 |
getBOF() | msado15::Recordset15 |
getBookmark() | msado15::Recordset15 |
getCacheSize() | msado15::Recordset15 |
getCollect(Variant Index) | msado15::Recordset15 |
getCursorLocation() | msado15::Recordset15 |
getCursorType() | msado15::Recordset15 |
getEditMode() | msado15::Recordset15 |
getEOF() | msado15::Recordset15 |
getFields() | msado15::Recordset15 |
getFilter() | msado15::Recordset15 |
getLockType() | msado15::Recordset15 |
getMarshalOptions() | msado15::Recordset15 |
getMaxRecords() | msado15::Recordset15 |
getPageCount() | msado15::Recordset15 |
getPageSize() | msado15::Recordset15 |
getProperties() | msado15::Recordset15 |
getRecordCount() | msado15::Recordset15 |
GetRows(int Rows, Variant Start, Variant Fields) | msado15::Recordset15 |
getSort() | msado15::Recordset15 |
getSource() | msado15::Recordset15 |
getState() | msado15::Recordset15 |
getStatus() | msado15::Recordset15 |
iid | msado15::Recordset15 | [static]
Move(int NumRecords, Variant Start) | msado15::Recordset15 |
MoveFirst() | msado15::Recordset15 |
MoveLast() | msado15::Recordset15 |
MoveNext() | msado15::Recordset15 |
MovePrevious() | msado15::Recordset15 |
NextRecordset(Variant RecordsAffected) | msado15::Recordset15 |
Open(Variant Source, Variant ActiveConnection, int CursorType, int LockType, int Options) | msado15::Recordset15 |
Requery(int Options) | msado15::Recordset15 |
setAbsolutePage(int pl) | msado15::Recordset15 |
setAbsolutePosition(int pl) | msado15::Recordset15 |
setActiveConnection(Object pvar) | msado15::Recordset15 |
setActiveConnection(Variant pvar) | msado15::Recordset15 |
setBookmark(Variant pvBookmark) | msado15::Recordset15 |
setCacheSize(int pl) | msado15::Recordset15 |
setCollect(Variant Index, Variant pvar) | msado15::Recordset15 |
setCursorLocation(int plCursorLoc) | msado15::Recordset15 |
setCursorType(int plCursorType) | msado15::Recordset15 |
setFilter(Variant Criteria) | msado15::Recordset15 |
setLockType(int plLockType) | msado15::Recordset15 |
setMarshalOptions(int peMarshal) | msado15::Recordset15 |
setMaxRecords(int plMaxRecords) | msado15::Recordset15 |
setPageSize(int pl) | msado15::Recordset15 |
setSort(String Criteria) | msado15::Recordset15 |
setSource(Object pvSource) | msado15::Recordset15 |
setSource(String pvSource) | msado15::Recordset15 |
Supports(int CursorOptions) | msado15::Recordset15 |
Update(Variant Fields, Variant Values) | msado15::Recordset15 |
UpdateBatch(int AffectRecords) | msado15::Recordset15 |
Generated on Wed Nov 13 2024 16:58:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/rowinfo.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

rowinfo.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module ROWINFO.CPP | IRowsetInfo interface implementation
00008 //
00009
00010 // Includes ------------------------------------------------------------------
00011
00012 #include "headers.h"
00013
00014 // Code ----------------------------------------------------------------------
00015
00016
00017 // IRowsetInfo specific methods
00018
00019 // CImpIRowsetInfo::GetReferencedRowset ----------------------------------------------------
00020 //
00021 // @mfunc Returns an interface pointer to the rowset to which the bookmark
00022 // applies
00023 //
00024 // @rdesc HRESULT
00025 //    @flag E_INVALIDARG    | ppReferencedRowset was NULL
00026 //    @flag DB_E_BADORDINAL | iOrdinal was greater than number of columns in rowset
00027 //      @flag DB_E_NOTAREFERENCECOLUMN | This rowset does not support bookmarks
00028 //
00029 STDMETHODIMP CImpIRowsetInfo::GetReferencedRowset
00030 (
00031     DBORDINAL iOrdinal,     //@parm IN | Bookmark Column
00032     REFIID    riid,       //@parm IN | ID of the interface pointer to return
00033   IUnknown ** ppReferencedRowset  //@parm OUT | IRowset Interface Pointer
00034 )
00035 {
00036   //
00037   // Asserts
00038     //
00039   assert( m_pObj );
00040
00041     //
00042     // Check in-params and NULL out-params in case of error
00043     //
00044   if( !ppReferencedRowset )
00045         return( E_INVALIDARG );
00046
00047   *ppReferencedRowset = NULL;
00048
00049     //
00050   // The oridinal was greater than the number of columns that we have.
00051     //
00052   if( iOrdinal == 0 || iOrdinal > m_pObj->m_cCols )
00053     return( DB_E_BADORDINAL );
00054
00055     //
00056   // Since we don't support bookmarks, this will alway return an error
00057     //
00058     return( DB_E_NOTAREFERENCECOLUMN );
00059 }
00060
00061
00062
00063 // CImpIRowsetInfo::GetProperties ----------------------------------------------------
00064 //
00065 // @mfunc Returns current settings of all properties supported by the rowset
00066 //
00067 // @rdesc HRESULT
00068 //      @flag S_OK          | The method succeeded
00069 //      @flag E_INVALIDARG  | pcProperties or prgProperties was NULL
00070 //      @flag E_OUTOFMEMORY | Out of memory
00071 //
00072 STDMETHODIMP CImpIRowsetInfo::GetProperties
00073 (
00074     const ULONG         cPropertySets,    //@parm IN | # of property sets
00075     const DBPROPIDSET rgPropertySets[], //@parm IN | Array of DBPROPIDSET
00076     ULONG*              pcProperties,   //@parm OUT | count of properties returned
00077     DBPROPSET**     prgProperties   //@parm OUT | property information returned
00078 )
00079 {
00080     HRESULT hr;
00081
00082   //
00083   // Asserts
00084     //
00085   assert(m_pObj);
00086     assert(m_pObj->m_pUtilProp);
00087
00088     //
00089     // Check in-params and NULL out-params in case of error
00090     //
00091   hr = m_pObj->m_pUtilProp->GetPropertiesArgChk(PROPSET_ROWSET,cPropertySets,
00092                   rgPropertySets,pcProperties,prgProperties);
00093   if( FAILED(hr) )
00094     return hr;
00095
00096     //
00097     // Just pass this call on to the utility object that manages our properties
00098     //
00099     return m_pObj->m_pUtilProp->GetProperties(PROPSET_ROWSET,cPropertySets,
00100                   rgPropertySets,pcProperties,prgProperties);
00101 }
00102
00103
00104
00105 // CImpIRowsetInfo::GetSpecification ---------------------------------------
00106 //
00107 // @mfunc Returns the interface pointer of the object that created the rowset
00108 //
00109 // @rdesc HRESULT
00110 //      @flag S_OK          | Method Succeeded
00111 //      @flag E_INVALIDARG  | Invalid parameters were specified
00112 //
00113 STDMETHODIMP CImpIRowsetInfo::GetSpecification
00114 (
00115   REFIID   riid,              //@parm IN | Interface ID of the interface being queried for.
00116   IUnknown **ppSpecification  //@parm OUT | Pointer to interface that instantiated this object
00117 )
00118 {
00119     //
00120   // Asserts
00121     //
00122   assert(m_pObj);
00123   assert(m_pObj->m_pParentObj);
00124   assert(m_pObj->m_pParentObj->GetOuterUnknown());
00125
00126     //
00127     // Check in-params and NULL out-params in case of error
00128     //
00129     if( !ppSpecification )
00130         return (E_INVALIDARG);
00131
00132     *ppSpecification = NULL;
00133
00134   return m_pObj->m_pParentObj->GetOuterUnknown()->QueryInterface(riid,(void**)ppSpecification);
00135 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/Dialer/Dialhelp.h Source File

  • NetDS
  • Tapi
  • Tapi2
  • Dialer

Dialhelp.h

Go to the documentation of this file.
00001 //
00002 // (c) 1995 Microsoft Corporation.  All Rights Reserved.
00003 //
00004 #define IDH_DIALER_CHANGE_DIAL_HELPER    1000
00005 #define IDH_DIALER_CHANGE_DIGITS         1001
00006 #define IDH_DIALER_CHANGE_OPTIONS        1002
00007 #define IDH_DIALER_CHANGE_REDIAL_BUTTON  1003
00008 #define IDH_DIALER_DIALING_LOGNAME       1004
00009 #define IDH_DIALER_DIALING_STATUS        1005
00010 #define IDH_DIALER_HANGUP                1006
00011 #define IDH_DIALER_LOG_IN                1007
00012 #define IDH_DIALER_LOG_OUT               1008
00013 #define IDH_DIALER_OPTIONS_ADDRESS       1009
00014 #define IDH_DIALER_OPTIONS_LINE          1010
00015 #define IDH_DIALER_OPTIONS_NONVOICE      1011
00016 #define IDH_DIALER_OPTIONS_VOICE         1012
00017 #define IDH_DIALER_PAUSE_CONTINUE        1013
00018 #define IDH_DIALER_SPEED_CHOOSE          1014
00019 #define IDH_DIALER_SPEED_NAME            1015
00020 #define IDH_DIALER_SPEED_NUMBER          1016
00021 #define IDH_DIALER_SPEED_SAVE            1017
00022 #define IDH_DIALER_SPEED_SAVE_DIAL       1018
00023 #define IDH_DIALER_DIAL_NUMBER           1019
00024 #define IDH_DIALER_DIAL_SPEED_CHOOSE     1020
00025 #define IDH_DIALER_DIAL_BUTTON           1021
00026 #define IDH_DIALER_DIAL_KEYPAD           1022
00027 #define IDH_DIALER_LOG                   1023
00028 #define IDH_DIALER_OPTIONS_PROPERTIES    1024
00029 #define IDH_DIALER_BUTTONS               1025
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030         static TCHAR error[64];
00031
00032         switch (verb) {
00033     case MMC_VERB_NONE:
00034                 return _T("NONE");
00035     case MMC_VERB_OPEN:
00036                 return _T("OPEN");
00037     case MMC_VERB_COPY:
00038                 return _T("COPY");
00039     case MMC_VERB_PASTE:
00040                 return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042                 return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044                 return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046                 return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048                 return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050                 return _T("PRINT");
00051     case MMC_VERB_CUT:
00052                 return _T("CUT");
00053         default:
00054                 wsprintf(error, _T("Unknown verb id %d"), verb);
00055                 return error;
00056         }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061                                 IComponentData *pCompData,
00062                                 IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064                                 LPARAM arg,
00065                                 LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069         TCHAR message[cchMessage] = {0};
00070
00071         if (bComponentData == TRUE)
00072                 OutputDebugString(_T("IComponentData::Notify( "));
00073         else
00074                 OutputDebugString(_T("IComponent::Notify( "));
00075
00076         wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077         OutputDebugString(message);
00078
00079     switch (event)      {
00080                 case MMCN_ACTIVATE:
00081                         wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082                         break;
00083
00084                 case MMCN_ADD_IMAGES:
00085                         wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086                         break;
00087
00088                 case MMCN_BTN_CLICK:
00089                         wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090                         break;
00091
00092                 case MMCN_COLUMN_CLICK:
00093                         wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,       param);
00094                         break;
00095
00096                 case MMCN_COLUMNS_CHANGED:
00097                         wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098                         break;
00099
00100                 case MMCN_CONTEXTHELP:
00101                         wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102                         break;
00103
00104                 case MMCN_CONTEXTMENU:
00105                         wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106                         break;
00107
00108                 case MMCN_CUTORMOVE:
00109                         wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110                         break;
00111
00112                 case MMCN_DBLCLICK:
00113                         wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114                         break;
00115
00116                 case MMCN_DELETE:
00117                         wsprintf(message, _T("MMCN_DELETE\n"));
00118                         break;
00119
00120                 case MMCN_DESELECT_ALL:
00121                         wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122                         break;
00123
00124                 case MMCN_EXPAND:
00125                         wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126                         break;
00127
00128                 case MMCN_EXPANDSYNC:
00129                         wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130                         break;
00131
00132                 case MMCN_FILTERBTN_CLICK:
00133                         wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134                         break;
00135
00136                 case MMCN_FILTER_CHANGE:
00137                         wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138                         break;
00139
00140                 case MMCN_HELP:
00141                         wsprintf(message, _T("MMCN_HELP\n"));
00142                         break;
00143
00144                 case MMCN_INITOCX:
00145                         wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146                         break;
00147
00148                 case MMCN_LISTPAD:
00149                         wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150                         break;
00151
00152                 case MMCN_MENU_BTNCLICK:
00153                         wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154                         break;
00155
00156                 case MMCN_MINIMIZED:
00157                         wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158                         break;
00159
00160                 case MMCN_PASTE:
00161                         wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162                         break;
00163
00164                 case MMCN_PRELOAD:
00165                         wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166                         break;
00167
00168                 case MMCN_PRINT:
00169                         wsprintf(message, _T("MMCN_PRINT\n"));
00170                         break;
00171
00172                 case MMCN_PROPERTY_CHANGE:
00173                         wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174                         break;
00175
00176                 case MMCN_QUERY_PASTE:
00177                         wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178                         break;
00179
00180                 case MMCN_REFRESH:
00181                         wsprintf(message, _T("MMCN_REFRESH\n"));
00182                         break;
00183
00184                 case MMCN_REMOVE_CHILDREN:
00185                         wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186                         break;
00187
00188                 case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192                         StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193                         break;
00194
00195                 case MMCN_RESTORE_VIEW:
00196                         wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197                         break;
00198
00199                 case MMCN_SELECT:
00200                         wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201                         break;
00202
00203                 case MMCN_SHOW:
00204                         wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205                         break;
00206
00207                 case MMCN_SNAPINHELP:
00208                         wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209                         break;
00210
00211                 case MMCN_VIEW_CHANGE:
00212                         wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213                         break;
00214         }
00215
00216         if (message[0] != 0)
00217                 OutputDebugString(message);
00218         else
00219                 OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222         return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ColumnProvider/Resource.h Source File

  • WinUI
  • Shell
  • ColumnProvider

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ShortName.rc
00004 //
00005 #define IDS_DESCRIPTION                 1
00006 #define IDS_CLSID                       2
00007 #define IDS_REGKEY_COLUMNPROVIDER       3
00008 #define IDS_TITLE                       4
00009 #define IDI_ICON1                       101
00010
00011 // Next default values for new objects
00012 //
00013 #ifdef APSTUDIO_INVOKED
00014 #ifndef APSTUDIO_READONLY_SYMBOLS
00015 #define _APS_NEXT_RESOURCE_VALUE        102
00016 #define _APS_NEXT_COMMAND_VALUE         40001
00017 #define _APS_NEXT_CONTROL_VALUE         1000
00018 #define _APS_NEXT_SYMED_VALUE           101
00019 #endif
00020 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/vcAcct/IUpdateReceipt.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • vcAcct

IUpdateReceipt.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc19.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\mssdk\samples\com\Services\Transaction\SampleBank\vcacct\release\vcacct.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package vcacct;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface IUpdateReceipt
00019 /** @com.interface(iid=A81260B7-DDC8-11D0-B5A0-00C04FB957D8, thread=AUTO, type=DUAL) */
00020 public interface IUpdateReceipt extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=METHOD, name="Update", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int Update();
00025
00026
00027   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0xa81260b7, (short)0xddc8, (short)0x11d0, (byte)0xb5, (byte)0xa0, (byte)0x0, (byte)0xc0, (byte)0x4f, (byte)0xb9, (byte)0x57, (byte)0xd8);
00028 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/Utility.c Source File

  • Com
  • Fundamentals
  • OleStd

Utility.c

Go to the documentation of this file.
00001 /*
00002  * UTILITY.C
00003  *
00004  * Utility routines for functions inside OLESTD.LIB
00005  *
00006  *  General:
00007  *  ----------------------
00008  *  HourGlassOn             Displays the hourglass
00009  *  HourGlassOff            Hides the hourglass
00010  *
00011  *  Misc Tools:
00012  *  ----------------------
00013  *  Browse                  Displays the "File..." or "Browse..." dialog.
00014  *  ReplaceCharWithNull     Used to form filter strings for Browse.
00015  *  ErrorWithFile           Creates an error message with embedded filename
00016  *  OpenFileError           Give error message for OpenFile error return
00017  *  ChopText                Chop a file path to fit within a specified width
00018  *  DoesFileExist           Checks if file is valid
00019  *
00020  *  Registration Database:
00021  *  ----------------------
00022  *  HIconFromClass          Extracts the first icon in a class's server path
00023  *  FServerFromClass        Retrieves the server path for a class name (fast)
00024  *  UClassFromDescription   Finds the classname given a description (slow)
00025  *  UDescriptionFromClass   Retrieves the description for a class name (fast)
00026  *  FGetVerb                Retrieves a specific verb for a class (fast)
00027  *
00028  *
00029  * Copyright (c)1992 - 2000 Microsoft Corporation, All Right Reserved
00030  */
00031
00032 #define STRICT  1
00033 #include "olestd.h"
00034 #include <stdlib.h>
00035 #include <commdlg.h>
00036 #include <memory.h>
00037 #include <cderr.h>
00038 #include "common.h"
00039 #include "utility.h"
00040
00041 #ifdef WIN32
00042 /* 1/23/94 - define LINK_COMMDLG to avoid LoadLibrary("commdlg.dll") */
00043 #define LINK_COMMDLG
00044 #endif
00045
00046 OLEDBGDATA
00047
00048 /*
00049  * HourGlassOn
00050  *
00051  * Purpose:
00052  *  Shows the hourglass cursor returning the last cursor in use.
00053  *
00054  * Parameters:
00055  *  None
00056  *
00057  * Return Value:
00058  *  HCURSOR         Cursor in use prior to showing the hourglass.
00059  */
00060
00061 HCURSOR WINAPI HourGlassOn(void)
00062    {
00063    HCURSOR     hCur;
00064
00065    hCur=SetCursor(LoadCursor(NULL, IDC_WAIT));
00066    ShowCursor(TRUE);
00067
00068    return hCur;
00069    }
00070
00071
00072
00073 /*
00074  * HourGlassOff
00075  *
00076  * Purpose:
00077  *  Turns off the hourglass restoring it to a previous cursor.
00078  *
00079  * Parameters:
00080  *  hCur            HCURSOR as returned from HourGlassOn
00081  *
00082  * Return Value:
00083  *  None
00084  */
00085
00086 void WINAPI HourGlassOff(HCURSOR hCur)
00087    {
00088    ShowCursor(FALSE);
00089    SetCursor(hCur);
00090    return;
00091    }
00092
00093
00094
00095
00096 /*
00097  * Browse
00098  *
00099  * Purpose:
00100  *  Displays the standard GetOpenFileName dialog with the title of
00101  *  "Browse."  The types listed in this dialog are controlled through
00102  *  iFilterString.  If it's zero, then the types are filled with "*.*"
00103  *  Otherwise that string is loaded from resources and used.
00104  *
00105  * Parameters:
00106  *  hWndOwner       HWND owning the dialog
00107  *  lpszFile        LPSTR specifying the initial file and the buffer in
00108  *                  which to return the selected file.  If there is no
00109  *                  initial file the first character of this string should
00110  *                  be NULL.
00111  *  lpszInitialDir  LPSTR specifying the initial directory.  If none is to
00112  *                  set (ie, the cwd should be used), then this parameter
00113  *                  should be NULL.
00114  *  cchFile         UINT length of pszFile
00115  *  iFilterString   UINT index into the stringtable for the filter string.
00116  *  dwOfnFlags      DWORD flags to OR with OFN_HIDEREADONLY
00117  *
00118  * Return Value:
00119  *  BOOL            TRUE if the user selected a file and pressed OK.
00120  *                  FALSE otherwise, such as on pressing Cancel.
00121  */
00122
00123 BOOL WINAPI Browse(HWND hWndOwner, LPSTR lpszFile, LPSTR lpszInitialDir, UINT cchFile, UINT iFilterString, DWORD dwOfnFlags)
00124    {
00125       UINT           cch;
00126       char           szFilters[256];
00127       OPENFILENAME   ofn;
00128       BOOL           fStatus;
00129       DWORD          dwError;
00130       char            szDlgTitle[128];  // that should be big enough
00131 #if !defined( LINK_COMMDLG )
00132       HINSTANCE hinstCommDlg = NULL;
00133       typedef BOOL (WINAPI* LPFNGETOPENFILENAME) (OPENFILENAME FAR*);
00134       LPFNGETOPENFILENAME lpfnGetOpenFileName;
00135       typedef DWORD (WINAPI* LPFNCOMMDLGEXTENDEDERROR) (void);
00136       LPFNCOMMDLGEXTENDEDERROR lpfnCommDlgExtendedError;
00137 #endif
00138
00139    if (NULL==lpszFile || 0==cchFile)
00140       return FALSE;
00141
00142    /*
00143     * REVIEW:  Exact contents of the filter combobox is TBD.  One idea
00144     * is to take all the extensions in the RegDB and place them in here
00145     * with the descriptive class name associate with them.  This has the
00146     * extra step of finding all extensions of the same class handler and
00147     * building one extension string for all of them.  Can get messy quick.
00148     * UI demo has only *.* which we do for now.
00149     */
00150
00151    if (0!=iFilterString)
00152       cch=LoadString(ghInst, iFilterString, /*(LPSTR)*/szFilters, sizeof(szFilters));
00153    else
00154       {
00155       szFilters[0]=0;
00156       cch=1;
00157       }
00158
00159    if (0==cch)
00160       return FALSE;
00161
00162    ReplaceCharWithNull(szFilters, szFilters[cch-1]);
00163
00164    //Prior string must also be initialized, if there is one.
00165    _fmemset((LPOPENFILENAME)&ofn, 0, sizeof(ofn));
00166    ofn.lStructSize =sizeof(ofn);
00167    ofn.hwndOwner   =hWndOwner;
00168    ofn.lpstrFile   =lpszFile;
00169    ofn.nMaxFile    =cchFile;
00170    ofn.lpstrFilter =/*(LPSTR)*/szFilters;
00171    ofn.nFilterIndex=1;
00172    if (LoadString(ghInst, (UINT)IDS_BROWSE, /*(LPSTR)*/szDlgTitle, sizeof(szDlgTitle)))
00173       ofn.lpstrTitle  =/*(LPSTR)*/szDlgTitle;
00174    ofn.hInstance = ghInst;
00175    ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILEOPEN);
00176    if (NULL != lpszInitialDir)
00177      ofn.lpstrInitialDir = lpszInitialDir;
00178
00179    ofn.Flags= OFN_HIDEREADONLY | OFN_ENABLETEMPLATE | (dwOfnFlags) ;
00180
00181 #if !defined( LINK_COMMDLG )
00182    // Load the COMMDLG.DLL library module
00183    hinstCommDlg = LoadLibrary("COMMDLG.DLL");
00184    if (hinstCommDlg <= HINSTANCE_ERROR)   /* load failed */
00185       return FALSE;
00186
00187    // Retrieve the address of required functions
00188    lpfnGetOpenFileName = (LPFNGETOPENFILENAME)
00189          GetProcAddress(hinstCommDlg, "GetOpenFileName");
00190    lpfnCommDlgExtendedError = (LPFNCOMMDLGEXTENDEDERROR)
00191          GetProcAddress(hinstCommDlg, "CommDlgExtendedError");
00192
00193    if (lpfnGetOpenFileName == NULL || lpfnCommDlgExtendedError == NULL)
00194       {
00195       FreeLibrary(hinstCommDlg);
00196       return FALSE;
00197       }
00198
00199    //On success, copy the chosen filename to the static display
00200    fStatus = (*lpfnGetOpenFileName) ((LPOPENFILENAME)&ofn);
00201    dwError = (*lpfnCommDlgExtendedError)();
00202
00203    FreeLibrary(hinstCommDlg);
00204    return fStatus;
00205 #else
00206    //On success, copy the chosen filename to the static display
00207    fStatus = GetOpenFileName((LPOPENFILENAME)&ofn);
00208    dwError = CommDlgExtendedError();
00209    return fStatus;
00210 #endif
00211    }
00212
00213
00214
00215
00216
00217 /*
00218  * ReplaceCharWithNull
00219  *
00220  * Purpose:
00221  *  Walks a null-terminated string and replaces a given character
00222  *  with a zero.  Used to turn a single string for file open/save
00223  *  filters into the appropriate filter string as required by the
00224  *  common dialog API.
00225  *
00226  * Parameters:
00227  *  psz             LPSTR to the string to process.
00228  *  ch              int character to replace.
00229  *
00230  * Return Value:
00231  *  int             Number of characters replaced.  -1 if psz is NULL.
00232  */
00233
00234 int WINAPI ReplaceCharWithNull(LPSTR psz, int ch)
00235    {
00236    int             cChanged=-1;
00237
00238    if (NULL!=psz)
00239       {
00240       while (0!=*psz)
00241          {
00242          if (ch==*psz)
00243             {
00244             *psz=0;
00245             cChanged++;
00246             }
00247          psz++;
00248          }
00249       }
00250    return cChanged;
00251    }
00252
00253
00254
00255
00256
00257
00258 /*
00259  * ErrorWithFile
00260  *
00261  * Purpose:
00262  *  Displays a message box built from a stringtable string containing
00263  *  one %s as a placeholder for a filename and from a string of the
00264  *  filename to place there.
00265  *
00266  * Parameters:
00267  *  hWnd            HWND owning the message box.  The caption of this
00268  *                  window is the caption of the message box.
00269  *  hInst           HINSTANCE from which to draw the idsErr string.
00270  *  idsErr          UINT identifier of a stringtable string containing
00271  *                  the error message with a %s.
00272  *  lpszFile        LPSTR to the filename to include in the message.
00273  *  uFlags          UINT flags to pass to MessageBox, like MB_OK.
00274  *
00275  * Return Value:
00276  *  int             Return value from MessageBox.
00277  */
00278
00279 int WINAPI ErrorWithFile(HWND hWnd, HINSTANCE hInst, UINT idsErr
00280               , LPSTR pszFile, UINT uFlags)
00281    {
00282    int             iRet=0;
00283    HANDLE          hMem;
00284    const UINT      cb=(2*OLEUI_CCHPATHMAX);
00285    LPSTR           psz1, psz2, psz3;
00286
00287    if (NULL==hInst || NULL==pszFile)
00288       return iRet;
00289
00290    //Allocate three 2*OLEUI_CCHPATHMAX byte work buffers
00291    hMem=GlobalAlloc(GHND, (DWORD)(3*cb));
00292
00293    if (NULL==hMem)
00294       return iRet;
00295
00296    psz1=GlobalLock(hMem);
00297    psz2=psz1+cb;
00298    psz3=psz2+cb;
00299
00300    if (0!=LoadString(hInst, idsErr, psz1, cb))
00301       {
00302       wsprintf(psz2, psz1, pszFile);
00303
00304       //Steal the caption of the dialog
00305       GetWindowText(hWnd, psz3, cb);
00306       iRet=MessageBox(hWnd, psz2, psz3, uFlags);
00307       }
00308
00309    GlobalUnlock(hMem);
00310    GlobalFree(hMem);
00311    return iRet;
00312    }
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322 /*
00323  * HIconFromClass
00324  *
00325  * Purpose:
00326  *  Given an object class name, finds an associated executable in the
00327  *  registration database and extracts the first icon from that
00328  *  executable.  If none is available or the class has no associated
00329  *  executable, this function returns NULL.
00330  *
00331  * Parameters:
00332  *  pszClass        LPSTR giving the object class to look up.
00333  *
00334  * Return Value:
00335  *  HICON           Handle to the extracted icon if there is a module
00336  *                  associated to pszClass.  NULL on failure to either
00337  *                  find the executable or extract and icon.
00338  */
00339
00340 HICON WINAPI HIconFromClass(LPSTR pszClass)
00341    {
00342    HICON           hIcon;
00343    char            szEXE[OLEUI_CCHPATHMAX];
00344    UINT            Index;
00345    CLSID           clsid;
00346    OLECHAR         szUniStr[256];
00347
00348    if (NULL==pszClass)
00349       return NULL;
00350
00351    A2W (pszClass, szUniStr, 256);
00352    CLSIDFromString(szUniStr, &clsid);
00353
00354    if (!FIconFileFromClass((REFCLSID)&clsid, szEXE, sizeof(szEXE), &Index))
00355       return NULL;
00356
00357    hIcon=ExtractIcon(ghInst, szEXE, Index);
00358
00359    if ((HICON)32 > hIcon)
00360       hIcon=NULL;
00361
00362    return hIcon;
00363    }
00364
00365
00366
00367
00368
00369 /*
00370  * FServerFromClass
00371  *
00372  * Purpose:
00373  *  Looks up the classname in the registration database and retrieves
00374  *  the name under CLSID\[Local|InProc]Server.
00375  *
00376  * Parameters:
00377  *  pszClass        LPSTR to the classname to look up.
00378  *  pszEXE          LPSTR at which to store the server name
00379  *  cch             UINT size of pszEXE
00380  *
00381  * Return Value:
00382  *  BOOL            TRUE if one or more characters were loaded into pszEXE.
00383  *                  FALSE otherwise.
00384  */
00385
00386 BOOL WINAPI FServerFromClass(LPSTR pszClass, LPSTR pszEXE, UINT cch)
00387 {
00388
00389    DWORD       dw;
00390    LONG        lRet;
00391    HKEY        hKey;
00392
00393    if (NULL==pszClass || NULL==pszEXE || 0==cch)
00394       return FALSE;
00395
00396    /*
00397     * We have to go walking in the registration database under the
00398     * classname, so we first open the classname key and then check
00399     * under "\\LocalServer" to get the .EXE.
00400     */
00401
00402    //Open up the class key
00403    lRet=RegOpenKey(HKEY_CLASSES_ROOT, pszClass, &hKey);
00404
00405    if ((LONG)ERROR_SUCCESS!=lRet)
00406       return FALSE;
00407
00408    //Get the executable path.
00409    dw=(DWORD)cch;
00410 #ifdef WIN32
00411    lRet=RegQueryValue(hKey, "LocalServer32", pszEXE, &dw);
00412 #else
00413    lRet=RegQueryValue(hKey, "LocalServer", pszEXE, &dw);
00414 #endif
00415
00416    if ((LONG)ERROR_SUCCESS!=lRet)
00417         {
00418         //Try InprocServer
00419 #ifdef WIN32
00420         lRet=RegQueryValue(hKey, "InProcServer32", pszEXE, &dw);
00421 #else
00422         lRet=RegQueryValue(hKey, "InProcServer32", pszEXE, &dw);
00423 #endif
00424         }
00425
00426    RegCloseKey(hKey);
00427
00428    return ((ERROR_SUCCESS == lRet) && (dw > 0));
00429 }
00430
00431
00432
00433 /*
00434  * UClassFromDescription
00435  *
00436  * Purpose:
00437  *  Looks up the actual OLE class name in the registration database
00438  *  for the given descriptive name chosen from a listbox.
00439  *
00440  * Parameters:
00441  *  psz             LPSTR to the descriptive name.
00442  *  pszClass        LPSTR in which to store the class name.
00443  *  cb              UINT maximum length of pszClass.
00444  *
00445  * Return Value:
00446  *  UINT            Number of characters copied to pszClass.  0 on failure.
00447  */
00448
00449 UINT WINAPI UClassFromDescription(LPSTR psz, LPSTR pszClass, UINT cb)
00450    {
00451    DWORD           dw;
00452    HKEY            hKey;
00453    char            szClass[OLEUI_CCHKEYMAX];
00454    LONG            lRet;
00455    UINT            i;
00456
00457    //Open up the root key.
00458    lRet=RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
00459
00460    if ((LONG)ERROR_SUCCESS!=lRet)
00461       return 0;
00462
00463    i=0;
00464    lRet=RegEnumKey(hKey, i++, szClass, OLEUI_CCHKEYMAX);
00465
00466    //Walk the available keys
00467    while ((LONG)ERROR_SUCCESS==lRet)
00468       {
00469       dw=(DWORD)cb;
00470       lRet=RegQueryValue(hKey, szClass, pszClass, &dw);
00471
00472       //Check if the description matches the one just enumerated
00473       if ((LONG)ERROR_SUCCESS==lRet)
00474          {
00475          if (!lstrcmp(pszClass, psz))
00476             break;
00477          }
00478
00479       //Continue with the next key.
00480       lRet=RegEnumKey(hKey, i++, szClass, OLEUI_CCHKEYMAX);
00481       }
00482
00483    //If we found it, copy to the return buffer
00484    if ((LONG)ERROR_SUCCESS==lRet)
00485       lstrcpy(pszClass, szClass);
00486    else
00487       dw=0L;
00488
00489    RegCloseKey(hKey);
00490    return (UINT)dw;
00491    }
00492
00493
00494
00495
00496
00497
00498
00499
00500 /*
00501  * UDescriptionFromClass
00502  *
00503  * Purpose:
00504  *  Looks up the actual OLE descriptive name name in the registration
00505  *  database for the given class name.
00506  *
00507  * Parameters:
00508  *  pszClass        LPSTR to the class name.
00509  *  psz             LPSTR in which to store the descriptive name.
00510  *  cb              UINT maximum length of psz.
00511  *
00512  * Return Value:
00513  *  UINT            Number of characters copied to pszClass.  0 on failure.
00514  */
00515
00516 UINT WINAPI UDescriptionFromClass(LPSTR pszClass, LPSTR psz, UINT cb)
00517    {
00518    DWORD           dw;
00519    HKEY            hKey;
00520    LONG            lRet;
00521
00522    if (NULL==pszClass || NULL==psz)
00523       return 0;
00524
00525    //Open up the root key.
00526    lRet=RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
00527
00528    if ((LONG)ERROR_SUCCESS!=lRet)
00529       return 0;
00530
00531    //Get the descriptive name using the class name.
00532    dw=(DWORD)cb;
00533    lRet=RegQueryValue(hKey, pszClass, psz, &dw);
00534
00535    RegCloseKey(hKey);
00536
00537    psz+=lstrlen(psz)+1;
00538    *psz=0;
00539
00540    if ((LONG)ERROR_SUCCESS!=lRet)
00541       return 0;
00542
00543    return (UINT)dw;
00544    }
00545
00546
00547
00548 // returns width of line of text. this is a support routine for ChopText
00549 static LONG GetTextWSize(HDC hDC, LPSTR lpsz)
00550 {
00551    SIZE size;
00552
00553    if (GetTextExtentPoint(hDC, lpsz, lstrlen(lpsz), (LPSIZE)&size))
00554       return size.cx;
00555    else {
00556       return 0;
00557    }
00558 }
00559
00560
00561 /*
00562  * ChopText
00563  *
00564  * Purpose:
00565  *  Parse a string (pathname) and convert it to be within a specified
00566  *  length by chopping the least significant part
00567  *
00568  * Parameters:
00569  *  hWnd            window handle in which the string resides
00570  *  nWidth          max width of string in pixels
00571  *                  use width of hWnd if zero
00572  *  lpch            pointer to beginning of the string
00573  *
00574  * Return Value:
00575  *  pointer to the modified string
00576  */
00577 LPSTR WINAPI ChopText(HWND hWnd, int nWidth, LPSTR lpch)
00578 {
00579 #define PREFIX_SIZE    7 + 1
00580 #define PREFIX_FORMAT "%c%c%c...\\"
00581
00582    char    szPrefix[PREFIX_SIZE];
00583    BOOL    fDone = FALSE;
00584    int     i;
00585    RECT    rc;
00586    HDC     hdc;
00587    HFONT   hfont;
00588    HFONT   hfontOld = NULL;
00589
00590    if (!hWnd || !lpch)
00591       return NULL;
00592
00593    /* Get length of static field. */
00594    if (!nWidth) {
00595       GetClientRect(hWnd, (LPRECT)&rc);
00596       nWidth = rc.right - rc.left;
00597    }
00598
00599    /* Set up DC appropriately for the static control */
00600    hdc = GetDC(hWnd);
00601    hfont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0L);
00602
00603    if (NULL != hfont)   // WM_GETFONT returns NULL if window uses system font
00604       hfontOld = SelectObject(hdc, hfont);
00605
00606    /* check horizontal extent of string */
00607    if (GetTextWSize(hdc, lpch) > nWidth) {
00608
00609       /* string is too long to fit in static control; chop it */
00610       /* set up new prefix & determine remaining space in control */
00611       wsprintf(/*(LPSTR)*/ szPrefix, PREFIX_FORMAT, lpch[0], lpch[1], lpch[2]);
00612       nWidth -= (int)GetTextWSize(hdc, /*(LPSTR)*/ szPrefix);
00613
00614       /*
00615       ** advance a directory at a time until the remainder of the
00616       ** string fits into the static control after the "x:\...\" prefix
00617       */
00618       while (!fDone) {
00619
00620 #ifdef DBCS
00621          while (*lpch && (*lpch != '\\'))
00622             lpch = AnsiNext(lpch);
00623          if (*lpch)
00624             lpch = AnsiNext(lpch);
00625 #else
00626          while (*lpch && (*lpch++ != '\\'));
00627 #endif
00628
00629          if (!*lpch || GetTextWSize(hdc, lpch) <= nWidth) {
00630             if (!*lpch)
00631                /*
00632                ** Nothing could fit after the prefix; remove the
00633                ** final "\" from the prefix
00634                */
00635                szPrefix[lstrlen(/*(LPSTR)*/ szPrefix) - 1] = 0;
00636
00637                /* rest or string fits -- stick prefix on front */
00638                for (i = lstrlen(/*(LPSTR)*/ szPrefix) - 1; i >= 0; --i)
00639                   *--lpch = szPrefix[i];
00640                fDone = TRUE;
00641          }
00642       }
00643    }
00644
00645    if (NULL != hfont)
00646      SelectObject(hdc, hfontOld);
00647    ReleaseDC(hWnd, hdc);
00648
00649    return(lpch);
00650
00651 #undef PREFIX_SIZE
00652 #undef PREFIX_FORMAT
00653 }
00654
00655
00656 /*
00657  * OpenFileError
00658  *
00659  * Purpose:
00660  *  display message for error returned from OpenFile
00661  *
00662  * Parameters:
00663  *  hDlg            HWND of the dialog.
00664  *  nErrCode        UINT error code returned in OFSTRUCT passed to OpenFile
00665  *  lpszFile        LPSTR file name passed to OpenFile
00666  *
00667  * Return Value:
00668  *  None
00669  */
00670 void WINAPI OpenFileError(HWND hDlg, UINT nErrCode, LPSTR lpszFile)
00671 {
00672    switch (nErrCode) {
00673       case 0x0005:    // Access denied
00674          ErrorWithFile(hDlg, ghInst, (UINT)IDS_CIFILEACCESS, lpszFile, MB_OK);
00675          break;
00676
00677       case 0x0020:    // Sharing violation
00678          ErrorWithFile(hDlg, ghInst, (UINT)IDS_CIFILESHARE, lpszFile, MB_OK);
00679          break;
00680
00681       case 0x0002:    // File not found
00682       case 0x0003:    // Path not found
00683          ErrorWithFile(hDlg, ghInst, (UINT)IDS_CIINVALIDFILE, lpszFile, MB_OK);
00684          break;
00685
00686       default:
00687          ErrorWithFile(hDlg, ghInst, (UINT)IDS_CIFILEOPENFAIL, lpszFile, MB_OK);
00688          break;
00689    }
00690 }
00691
00692 #define chSpace        ' '
00693 #define chPeriod       '.'
00694 #define PARSE_EMPTYSTRING   -1
00695 #define PARSE_INVALIDDRIVE  -2
00696 #define PARSE_INVALIDPERIOD -3
00697 #define PARSE_INVALIDDIRCHAR    -4
00698 #define PARSE_INVALIDCHAR   -5
00699 #define PARSE_WILDCARDINDIR -6
00700 #define PARSE_INVALIDNETPATH    -7
00701 #define PARSE_INVALIDSPACE  -8
00702 #define PARSE_EXTENTIONTOOLONG  -9
00703 #define PARSE_DIRECTORYNAME -10
00704 #define PARSE_FILETOOLONG   -11
00705
00706 /*---------------------------------------------------------------------------
00707  * ParseFile
00708  * Purpose:  Determine if the filename is a legal DOS name
00709  * Input:    Long pointer to a SINGLE file name
00710  *           Circumstance checked:
00711  *           1) Valid as directory name, but not as file name
00712  *           2) Empty String
00713  *           3) Illegal Drive label
00714  *           4) Period in invalid location (in extention, 1st in file name)
00715  *           5) Missing directory character
00716  *           6) Illegal character
00717  *           7) Wildcard in directory name
00718  *           8) Double slash beyond 1st 2 characters
00719  *           9) Space character in the middle of the name (trailing spaces OK)
00720  *          10) Filename greater than 8 characters
00721  *          11) Extention greater than 3 characters
00722  * Notes:
00723  *   Filename length is NOT checked.
00724  *   Valid filenames will have leading spaces, trailing spaces and
00725  *     terminating period stripped in place.
00726  *
00727  * Returns:  If valid, LOWORD is byte offset to filename
00728  *                     HIWORD is byte offset to extention
00729  *                            if string ends with period, 0
00730  *                            if no extention is given, string length
00731  *           If invalid, LOWORD is error code suggesting problem (< 0)
00732  *                       HIWORD is approximate offset where problem found
00733  *                       Note that this may be beyond the offending character
00734  *--------------------------------------------------------------------------*/
00735
00736 static long ParseFile(LPSTR lpstrFileName)
00737 {
00738   short nFile, nExt, nFileOffset, nExtOffset;
00739   BOOL bExt;
00740   BOOL bWildcard;
00741   short nNetwork = 0;
00742   BOOL  bUNCPath = FALSE;
00743   LPSTR lpstr = lpstrFileName;
00744
00745 /* Strip off initial white space.  Note that TAB is not checked */
00746 /* because it cannot be received out of a standard edit control */
00747 /* 30 January 1991  clarkc                                      */
00748   while (*lpstr == chSpace)
00749      lpstr++;
00750
00751   if (!*lpstr)
00752    {
00753      nFileOffset = PARSE_EMPTYSTRING;
00754      goto FAILURE;
00755    }
00756
00757   if (lpstr != lpstrFileName)
00758    {
00759      lstrcpy(lpstrFileName, lpstr);
00760      lpstr = lpstrFileName;
00761    }
00762
00763   if (*AnsiNext(lpstr) == ':')
00764    {
00765      char cDrive = (*lpstr | (BYTE) 0x20);  /* make lowercase */
00766
00767 /* This does not test if the drive exists, only if it's legal */
00768      if ((cDrive < 'a') || (cDrive > 'z'))
00769       {
00770         nFileOffset = PARSE_INVALIDDRIVE;
00771         goto FAILURE;
00772       }
00773      lpstr = AnsiNext(AnsiNext(lpstr));
00774    }
00775
00776   if ((*lpstr == '\\') || (*lpstr == '/'))
00777    {
00778      if (*++lpstr == chPeriod)               /* cannot have c:\. */
00779       {
00780         if ((*++lpstr != '\\') && (*lpstr != '/'))
00781          {
00782            if (!*lpstr)        /* it's the root directory */
00783               goto MustBeDir;
00784
00785            nFileOffset = PARSE_INVALIDPERIOD;
00786            goto FAILURE;
00787          }
00788         else
00789            ++lpstr;   /* it's saying top directory (again), thus allowed */
00790       }
00791      else if ((*lpstr == '\\') && (*(lpstr-1) == '\\'))
00792       {
00793 /* It seems that for a full network path, whether a drive is declared or
00794  * not is insignificant, though if a drive is given, it must be valid
00795  * (hence the code above should remain there).
00796  * 13 February 1991           clarkc
00797  */
00798         ++lpstr;            /* ...since it's the first slash, 2 are allowed */
00799         nNetwork = -1;      /* Must receive server and share to be real     */
00800         bUNCPath = TRUE;    /* No wildcards allowed if UNC name             */
00801       }
00802      else if (*lpstr == '/')
00803       {
00804         nFileOffset = PARSE_INVALIDDIRCHAR;
00805         goto FAILURE;
00806       }
00807    }
00808   else if (*lpstr == chPeriod)
00809    {
00810      if (*++lpstr == chPeriod)  /* Is this up one directory? */
00811         ++lpstr;
00812      if (!*lpstr)
00813         goto MustBeDir;
00814      if ((*lpstr != '\\') && (*lpstr != '/'))
00815       {
00816         nFileOffset = PARSE_INVALIDPERIOD;
00817         goto FAILURE;
00818       }
00819      else
00820         ++lpstr;   /* it's saying directory, thus allowed */
00821    }
00822
00823   if (!*lpstr)
00824    {
00825      goto MustBeDir;
00826    }
00827
00828 /* Should point to first char in 8.3 filename by now */
00829   nFileOffset = nExtOffset = nFile = nExt = 0;
00830   bWildcard = bExt = FALSE;
00831   while (*lpstr)
00832    {
00833 /*
00834  *  The next comparison MUST be unsigned to allow for extended characters!
00835  *  21 Feb 1991   clarkc
00836  */
00837      if (*lpstr < chSpace)
00838       {
00839         nFileOffset = PARSE_INVALIDCHAR;
00840         goto FAILURE;
00841       }
00842      switch (*lpstr)
00843       {
00844         case '"':             /* All invalid */
00845         case '+':
00846         case ',':
00847         case ':':
00848         case ';':
00849         case '<':
00850         case '=':
00851         case '>':
00852         case '[':
00853         case ']':
00854         case '|':
00855          {
00856            nFileOffset = PARSE_INVALIDCHAR;
00857            goto FAILURE;
00858          }
00859
00860         case '\\':      /* Subdirectory indicators */
00861         case '/':
00862          nNetwork++;
00863          if (bWildcard)
00864            {
00865             nFileOffset = PARSE_WILDCARDINDIR;
00866             goto FAILURE;
00867            }
00868
00869          else if (nFile == 0)        /* can't have 2 in a row */
00870            {
00871             nFileOffset = PARSE_INVALIDDIRCHAR;
00872             goto FAILURE;
00873            }
00874          else
00875            {                         /* reset flags */
00876             ++lpstr;
00877             if (!nNetwork && !*lpstr)
00878               {
00879                nFileOffset = PARSE_INVALIDNETPATH;
00880                goto FAILURE;
00881               }
00882             nFile = nExt = 0;
00883             bExt = FALSE;
00884            }
00885          break;
00886
00887         case chSpace:
00888          {
00889            LPSTR lpSpace = lpstr;
00890
00891            *lpSpace = '\0';
00892            while (*++lpSpace)
00893             {
00894               if (*lpSpace != chSpace)
00895                {
00896                  *lpstr = chSpace;        /* Reset string, abandon ship */
00897                  nFileOffset = PARSE_INVALIDSPACE;
00898                  goto FAILURE;
00899                }
00900             }
00901          }
00902          break;
00903
00904         case chPeriod:
00905          if (nFile == 0)
00906            {
00907             if (*++lpstr == chPeriod)
00908                ++lpstr;
00909             if (!*lpstr)
00910                goto MustBeDir;
00911
00912             if ((*lpstr != '\\') && (*lpstr != '/'))
00913               {
00914                nFileOffset = PARSE_INVALIDPERIOD;
00915                goto FAILURE;
00916               }
00917
00918             ++lpstr;              /* Flags are already set */
00919            }
00920          else if (bExt)
00921            {
00922             nFileOffset = PARSE_INVALIDPERIOD;  /* can't have one in ext */
00923             goto FAILURE;
00924            }
00925          else
00926            {
00927             nExtOffset = 0;
00928             ++lpstr;
00929             bExt = TRUE;
00930            }
00931          break;
00932
00933         case '*':
00934         case '?':
00935          if (bUNCPath)
00936            {
00937             nFileOffset = PARSE_INVALIDNETPATH;
00938             goto FAILURE;
00939            }
00940          bWildcard = TRUE;
00941 /* Fall through to normal character processing */
00942
00943         default:
00944          if (bExt)
00945            {
00946             if (++nExt == 1)
00947                nExtOffset = lpstr - lpstrFileName;
00948             else if (nExt > 3)
00949               {
00950                nFileOffset = PARSE_EXTENTIONTOOLONG;
00951                goto FAILURE;
00952               }
00953             if ((nNetwork == -1) && (nFile + nExt > 11))
00954               {
00955                nFileOffset = PARSE_INVALIDNETPATH;
00956                goto FAILURE;
00957               }
00958            }
00959          else if (++nFile == 1)
00960             nFileOffset = lpstr - lpstrFileName;
00961          else if (nFile > 8)
00962            {
00963             /* If it's a server name, it can have 11 characters */
00964             if (nNetwork != -1)
00965               {
00966                nFileOffset = PARSE_FILETOOLONG;
00967                goto FAILURE;
00968               }
00969             else if (nFile > 11)
00970               {
00971                nFileOffset = PARSE_INVALIDNETPATH;
00972                goto FAILURE;
00973               }
00974            }
00975
00976          lpstr = AnsiNext(lpstr);
00977          break;
00978       }
00979    }
00980
00981 /* Did we start with a double backslash but not have any more slashes? */
00982   if (nNetwork == -1)
00983    {
00984      nFileOffset = PARSE_INVALIDNETPATH;
00985      goto FAILURE;
00986    }
00987
00988   if (!nFile)
00989    {
00990 MustBeDir:
00991      nFileOffset = PARSE_DIRECTORYNAME;
00992      goto FAILURE;
00993    }
00994
00995   if ((*(lpstr - 1) == chPeriod) &&          /* if true, no extention wanted */
00996            (*AnsiNext(lpstr-2) == chPeriod))
00997      *(lpstr - 1) = '\0';               /* Remove terminating period   */
00998   else if (!nExt)
00999 FAILURE:
01000      nExtOffset = lpstr - lpstrFileName;
01001
01002   return(MAKELONG(nFileOffset, nExtOffset));
01003 }
01004
01005
01006 /*
01007  * DoesFileExist
01008  *
01009  * Purpose:
01010  *  Determines if a file path exists
01011  *
01012  * Parameters:
01013  *  lpszFile        LPSTR - file name
01014  *  lpOpenBuf       OFSTRUCT FAR* - points to the OFSTRUCT structure that
01015  *                      will receive information about the file when the
01016  *                      file is first opened. this field is filled by the
01017  *                      Windows OpenFile API.
01018  *
01019  * Return Value:
01020  *  HFILE   HFILE_ERROR - file does NOT exist
01021  *          file handle (as returned from OpenFile) - file exists
01022  */
01023 HFILE WINAPI DoesFileExist(LPSTR lpszFile, OFSTRUCT FAR* lpOpenBuf)
01024 {
01025    long        nRet;
01026    int         i;
01027    static char *arrIllegalNames[] = {
01028       "LPT1",
01029       "LPT2",
01030       "LPT3",
01031       "COM1",
01032       "COM2",
01033       "COM3",
01034       "COM4",
01035       "CON",
01036       "AUX",
01037       "PRN"
01038    };
01039
01040    // Check if file name is syntactically correct.
01041    //   (OpenFile sometimes crashes if path is not syntactically correct)
01042    nRet = ParseFile(lpszFile);
01043    if (LOWORD(nRet) < 0)
01044       goto error;
01045
01046    // Check is the name is an illegal name (eg. the name of a device)
01047    for (i=0; i < (sizeof(arrIllegalNames)/sizeof(arrIllegalNames[0])); i++) {
01048       if (lstrcmpi(lpszFile, arrIllegalNames[i])==0)
01049          goto error; // illegal name FOUND
01050    }
01051    return OpenFile(lpszFile, lpOpenBuf, OF_EXIST);
01052
01053 error:
01054    _fmemset(lpOpenBuf, 0, sizeof(OFSTRUCT));
01055    lpOpenBuf->nErrCode = 0x0002;   // File not found
01056    return HFILE_ERROR;
01057 }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/utils.h Source File

  • Web
  • NetMeeting
  • PlugTransport

utils.h

Go to the documentation of this file.
00001 #ifndef _PLUG_UTILS_H_
00002 #define _PLUG_UTILS_H_
00003
00004 #define ASSERT assert
00005
00006 //****************************************************************************
00007 //
00008 // CLASS RefCount
00009 //
00010 //****************************************************************************
00011
00012 class RefCount
00013 {
00014 private:
00015    LONG m_cRef;
00016
00017 public:
00018    RefCount();
00019    // Virtual destructor defers destruction to destructor of derived class.
00020    virtual ~RefCount();
00021
00022    ULONG STDMETHODCALLTYPE AddRef(void);
00023    ULONG STDMETHODCALLTYPE Release(void);
00024 };
00025
00026
00027
00028 //****************************************************************************
00029 //
00030 // CLASS CNotify
00031 //
00032 // Notification sink
00033 //
00034 //****************************************************************************
00035
00036 class CNotify
00037 {
00038 private:
00039     DWORD  m_dwCookie;
00040   IUnknown * m_pUnk;
00041     IConnectionPoint           * m_pcnp;
00042     IConnectionPointContainer  * m_pcnpcnt;
00043 public:
00044     CNotify(void);
00045     ~CNotify();
00046
00047     HRESULT Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN);
00048     HRESULT Disconnect(void);
00049
00050     IUnknown * GetPunk() {return m_pUnk;}
00051 };
00052
00053 #endif  // _PLUG_UTILS_H_
00054
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/test.c Source File

  • NetDS
  • RRas
  • ip

test.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\test.c
00008
00009 Abstract:
00010
00011     The file contains test utilities.
00012
00013 --*/
00014
00015 #include "pchsample.h"
00016 #pragma hdrstop
00017
00018 // Macro for counting maximum characters that will fit into a buffer
00019 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00020
00021
00022 #ifdef TEST
00023
00024 #define TEST_NUM_IE         230
00025 #define TEST_NUM_INTERFACE  2
00026 #define TEST_SLEEP_TIME     3*PERIODIC_INTERVAL
00027 #define TEST_NUM_START_STOP 2
00028
00029
00030 VOID
00031 ErrorCodes()
00032 {
00033     TRACE1(DEBUG, "ERROR_CAN_NOT_COMPLETE: %u",
00034            ERROR_CAN_NOT_COMPLETE);
00035     TRACE1(DEBUG, "ERROR_INSUFFICIENT_BUFFER: %u",
00036            ERROR_INSUFFICIENT_BUFFER);
00037     TRACE1(DEBUG, "ERROR_NO_MORE_ITEMS: %u",
00038            ERROR_NO_MORE_ITEMS);
00039     TRACE1(DEBUG, "ERROR_INVALID_PARAMETER: %u",
00040            ERROR_INVALID_PARAMETER);
00041 }
00042
00043
00044
00045 VOID
00046 HT_Test()
00047 {
00048     ULONG               i, ulNumDeleted = 0, ulNumGotten = 0;
00049     DWORD               dwErr;
00050     PNETWORK_ENTRY      pneNetworkEntry;
00051     PINTERFACE_ENTRY    pieInterfaceEntry;
00052     INTERFACE_ENTRY     ieKey;
00053     PLIST_ENTRY         plePtr;
00054     WCHAR               pwszIfName[20];
00055
00056     do                          // breakout loop
00057     {
00058         dwErr = NE_Create(&pneNetworkEntry);
00059         if (dwErr != NO_ERROR)
00060         {
00061             TRACE0(DEBUG, "HT_Test: Could not create NetworkEntry");
00062             break;
00063         }
00064
00065         for (i = 0; i < TEST_NUM_IE; i++)
00066         {
00067             _snwprintf(pwszIfName, CELEMS(pwszIfName), L"if%u", i);
00068             dwErr = IE_Create(pwszIfName,
00069                               i,
00070                               IEFLAG_MULTIACCESS,
00071                               &pieInterfaceEntry);
00072             if (dwErr != NO_ERROR)
00073             {
00074                 TRACE1(DEBUG, "HT_Test: Could not Create %u", i);
00075                 break;
00076             }
00077
00078             dwErr = HT_InsertEntry(pneNetworkEntry->phtInterfaceTable,
00079                                    &(pieInterfaceEntry->leInterfaceTableLink));
00080             if (dwErr != NO_ERROR)
00081             {
00082                 TRACE1(DEBUG, "HT_Test: Could not Insert %u", i);
00083                 break;
00084             }
00085         }
00086
00087         TRACE1(DEBUG, "Hash Table Size %u",
00088                HT_Size(pneNetworkEntry->phtInterfaceTable));
00089
00090         for (i = 0; i < TEST_NUM_IE; i += 2)
00091         {
00092             ieKey.dwIfIndex = i;
00093
00094             dwErr = HT_DeleteEntry(pneNetworkEntry->phtInterfaceTable,
00095                                    &(ieKey.leInterfaceTableLink),
00096                                    &plePtr);
00097             if (dwErr != NO_ERROR)
00098             {
00099                 TRACE1(DEBUG, "HT_Test: Could not Delete %u", i);
00100                 break;
00101             }
00102
00103             // indicate deletion
00104             InitializeListHead(plePtr);
00105             IE_Destroy(CONTAINING_RECORD(plePtr,
00106                                          INTERFACE_ENTRY,
00107                                          leInterfaceTableLink));
00108             ulNumDeleted++;
00109         }
00110
00111         TRACE2(DEBUG, "NumDeleted %u Hash Table Size %u",
00112                ulNumDeleted, HT_Size(pneNetworkEntry->phtInterfaceTable));
00113
00114         for (i = 0; i < TEST_NUM_IE; i++)
00115         {
00116             ieKey.dwIfIndex = i;
00117
00118             if (HT_IsPresentEntry(pneNetworkEntry->phtInterfaceTable,
00119                                   &(ieKey.leInterfaceTableLink)))
00120             {
00121                 dwErr = HT_GetEntry(pneNetworkEntry->phtInterfaceTable,
00122                                     &(ieKey.leInterfaceTableLink),
00123                                     &plePtr);
00124
00125                 if (dwErr != NO_ERROR)
00126                 {
00127                     TRACE1(DEBUG, "HT_Test: Could not Get %u", i);
00128                     break;
00129                 }
00130
00131                 ulNumGotten++;
00132             }
00133         }
00134
00135         TRACE1(DEBUG, "NumGotten %u", ulNumGotten);
00136     } while (FALSE);
00137
00138     NE_Destroy(pneNetworkEntry);
00139 }
00140
00141
00142
00143 VOID
00144 MM_Test(HANDLE  hEvent)
00145 {
00146     ROUTING_PROTOCOL_EVENTS         rpeEvent;
00147     MESSAGE                         mMessage;
00148     ULONG                           ulSize;
00149     BYTE                            byBuffer[100];
00150     PIPSAMPLE_GLOBAL_CONFIG         pigc;
00151     PIPSAMPLE_IP_ADDRESS            piia;
00152     PIPSAMPLE_IF_BINDING            piib;
00153     PIPSAMPLE_IF_CONFIG             piic;
00154
00155     IPSAMPLE_MIB_GET_INPUT_DATA     imgid;
00156     PIPSAMPLE_MIB_SET_INPUT_DATA    pimsid =
00157         (PIPSAMPLE_MIB_SET_INPUT_DATA) byBuffer;
00158     PIPSAMPLE_MIB_GET_OUTPUT_DATA   pimgod =
00159         (PIPSAMPLE_MIB_GET_OUTPUT_DATA) byBuffer;
00160
00161
00162     // mib set global configuration
00163     pimsid->IMSID_TypeID        = IPSAMPLE_GLOBAL_CONFIG_ID;
00164     pimsid->IMSID_BufferSize    = sizeof(IPSAMPLE_GLOBAL_CONFIG);
00165     pigc = (PIPSAMPLE_GLOBAL_CONFIG) pimsid->IMSID_Buffer;
00166     pigc->dwLoggingLevel = IPSAMPLE_LOGGING_ERROR;
00167     MM_MibSet(pimsid);
00168     TRACE2(MIB, "MIB SET: %u %u", pimsid->IMSID_TypeID, pigc->dwLoggingLevel);
00169
00170     WaitForSingleObject(hEvent, INFINITE);
00171     CM_GetEventMessage(&rpeEvent, &mMessage);
00172     TRACE1(DEBUG, "SetMib %u", rpeEvent);
00173
00174
00175     // mib get global configuration
00176     ulSize = 0;
00177     imgid.IMGID_TypeID = IPSAMPLE_GLOBAL_CONFIG_ID;
00178     pigc = (PIPSAMPLE_GLOBAL_CONFIG) pimgod->IMGOD_Buffer;
00179
00180     MM_MibGet(&imgid, pimgod, &ulSize, GET_EXACT);
00181     TRACE3(MIB, "MIB GET: %u %u %u",
00182            ulSize, pimgod->IMGOD_TypeID, pigc->dwLoggingLevel);
00183
00184     MM_MibGet(&imgid, pimgod, &ulSize, GET_EXACT);
00185     TRACE3(MIB, "MIB GET: %u %u %u",
00186            ulSize, pimgod->IMGOD_TypeID, pigc->dwLoggingLevel);
00187
00188
00189     // mib get first interface binding
00190     ulSize = 0;
00191     imgid.IMGID_TypeID  = IPSAMPLE_IF_BINDING_ID;
00192     imgid.IMGID_IfIndex = 0;
00193     piib = (PIPSAMPLE_IF_BINDING) pimgod->IMGOD_Buffer;
00194     piia = IPSAMPLE_IF_ADDRESS_TABLE(piib);
00195
00196     MM_MibGet(&imgid, pimgod, &ulSize, GET_FIRST);
00197     TRACE4(MIB, "MIB GET: %u %u %u %u",
00198            ulSize, pimgod->IMGOD_TypeID, piib->dwState, piib->ulCount);
00199
00200     MM_MibGet(&imgid, pimgod, &ulSize, GET_FIRST);
00201     TRACE5(MIB, "MIB GET: %u %u %u %u %u",
00202            ulSize, pimgod->IMGOD_TypeID, piib->dwState, piib->ulCount,
00203            piia->dwAddress);
00204
00205
00206     // mib get next interface binding
00207     ulSize = 0;
00208     MM_MibGet(&imgid, pimgod, &ulSize, GET_NEXT);
00209     TRACE4(MIB, "MIB GET: %u %u %u %u",
00210            ulSize, pimgod->IMGOD_TypeID, piib->dwState, piib->ulCount);
00211
00212     MM_MibGet(&imgid, pimgod, &ulSize, GET_NEXT);
00213     TRACE5(MIB, "MIB GET: %u %u %u %u %u",
00214            ulSize, pimgod->IMGOD_TypeID, piib->dwState, piib->ulCount,
00215            piia->dwAddress);
00216
00217
00218     // mib set interface configuration
00219     pimsid->IMSID_TypeID        = IPSAMPLE_IF_CONFIG_ID;
00220     pimsid->IMSID_IfIndex       = 0;
00221     pimsid->IMSID_BufferSize    = sizeof(IPSAMPLE_IF_CONFIG);
00222     piic = (PIPSAMPLE_IF_CONFIG) pimsid->IMSID_Buffer;
00223     piic->ulMetric              = 0;
00224     MM_MibSet(pimsid);
00225     TRACE1(MIB, "MIB SET: %u", pimsid->IMSID_TypeID);
00226
00227     WaitForSingleObject(hEvent, INFINITE);
00228     CM_GetEventMessage(&rpeEvent, &mMessage);
00229     TRACE1(DEBUG, "SetMib %u", rpeEvent);
00230
00231
00232     // mib get interface configuration
00233     ulSize = 0;
00234     imgid.IMGID_TypeID  = IPSAMPLE_IF_CONFIG_ID;
00235     imgid.IMGID_IfIndex = 0;
00236     piic = (PIPSAMPLE_IF_CONFIG) pimgod->IMGOD_Buffer;
00237
00238     MM_MibGet(&imgid, pimgod, &ulSize, GET_EXACT);
00239     TRACE3(MIB, "MIB GET: %u %u %u",
00240            ulSize, pimgod->IMGOD_TypeID, piic->ulMetric);
00241
00242
00243     MM_MibGet(&imgid, pimgod, &ulSize, GET_EXACT);
00244     TRACE3(MIB, "MIB GET: %u %u %u",
00245            ulSize, pimgod->IMGOD_TypeID, piic->ulMetric);
00246 }
00247
00248
00249
00250 VOID
00251 NM_Test(HANDLE  hEvent)
00252 {
00253     DWORD                       dwErr = NO_ERROR;
00254     ULONG                       i;
00255     WCHAR                       pwszIfName[20];
00256     ROUTING_PROTOCOL_EVENTS     rpeEvent;
00257     MESSAGE                     mMessage;
00258     IPSAMPLE_IF_CONFIG          iic = { 1 };
00259     PIP_ADAPTER_BINDING_INFO    pBinding;
00260
00261     MALLOC(&pBinding,
00262            (sizeof(IP_ADAPTER_BINDING_INFO) + 3 * sizeof(IP_LOCAL_BINDING)),
00263            &dwErr);
00264     pBinding->AddressCount = 3;
00265     pBinding->Address[0].Address    = 0xfffffffd;
00266     pBinding->Address[0].Mask       = 0xffffffff;
00267     pBinding->Address[1].Address    = INADDR_ANY;
00268     pBinding->Address[1].Mask       = 0xffffffff;
00269     pBinding->Address[2].Address    = 0xfffffffe;
00270     pBinding->Address[2].Mask       = 0xffffffff;
00271
00272
00273     // add interfaces
00274     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00275     {
00276         _snwprintf(pwszIfName, CELEMS(pwszIfName), L"if%u", i);
00277         dwErr = NM_AddInterface(pwszIfName,
00278                                 i,
00279                                 PERMANENT,
00280                                 &iic);
00281         if (dwErr != NO_ERROR)
00282         {
00283             TRACE1(DEBUG, "NM_Test: Could not Add Interface %u", i);
00284             break;
00285         }
00286     }
00287     TRACE1(DEBUG, "...AddInterface %u", dwErr);
00288     CE_Display(&g_ce);
00289
00290
00291     // bind interfaces
00292     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00293     {
00294         pBinding->Address[0].Address    = i;
00295
00296         dwErr = NM_InterfaceStatus(i,
00297                                    FALSE,
00298                                    RIS_INTERFACE_ADDRESS_CHANGE,
00299                                    (PVOID) pBinding);
00300         if (dwErr != NO_ERROR)
00301         {
00302             TRACE1(DEBUG, "NM_Test: Could not Bind Interface %u", i);
00303             break;
00304         }
00305     }
00306     TRACE1(DEBUG, "...BindInterface %u", dwErr);
00307     CE_Display(&g_ce);
00308
00309     // activate interfaces
00310     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00311     {
00312         dwErr = NM_InterfaceStatus(i,
00313                                    TRUE,
00314                                    RIS_INTERFACE_ENABLED,
00315                                    NULL);
00316         if (dwErr != NO_ERROR)
00317         {
00318             TRACE1(DEBUG, "NM_Test: Could not Activate Interface %u", i);
00319             break;
00320         }
00321     }
00322     TRACE1(DEBUG, "...ActivateInterface %u", dwErr);
00323     CE_Display(&g_ce);
00324
00325     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00326     {
00327         dwErr = NM_DoUpdateRoutes(i);
00328         if (dwErr != NO_ERROR)
00329         {
00330             TRACE1(DEBUG, "NM_Test: Couldn't UpdateRoutes on Interface %u", i);
00331             break;
00332         }
00333
00334         dwErr = WaitForSingleObject(hEvent, INFINITE);
00335         dwErr = CM_GetEventMessage(&rpeEvent, &mMessage);
00336         TRACE2(DEBUG, "DidUpdateRoutes %u %u", rpeEvent, dwErr);
00337     }
00338     TRACE1(DEBUG, "...DoUpdateRoutes %u", dwErr);
00339     CE_Display(&g_ce);
00340
00341
00342     // interface is active (enabled and bound)
00343     TRACE1(DEBUG, "Sleeping...", dwErr);
00344     Sleep(SECTOMILLISEC(TEST_SLEEP_TIME));
00345     TRACE1(DEBUG, "...Awake", dwErr);
00346
00347
00348     // mib manager test
00349     MM_Test(hEvent);
00350     TRACE0(DEBUG, "...MM_Test");
00351
00352
00353     // deactivate interfaces
00354     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00355     {
00356         dwErr = NM_InterfaceStatus(i,
00357                                    FALSE,
00358                                    RIS_INTERFACE_DISABLED,
00359                                    NULL);
00360         if (dwErr != NO_ERROR)
00361         {
00362             TRACE1(DEBUG, "NM_Test: Could not Deactivate Interface %u", i);
00363             break;
00364         }
00365     }
00366     TRACE1(DEBUG, "...DeactivateInterface %u", dwErr);
00367     CE_Display(&g_ce);
00368
00369
00370     // unbind interfaces
00371     pBinding->AddressCount = 0;
00372     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00373     {
00374         dwErr = NM_InterfaceStatus(i,
00375                                    FALSE,
00376                                    RIS_INTERFACE_ADDRESS_CHANGE,
00377                                    (PVOID) pBinding);
00378         if (dwErr != NO_ERROR)
00379         {
00380             TRACE1(DEBUG, "NM_Test: Could not Unbind Interface %u", i);
00381             break;
00382         }
00383     }
00384     TRACE1(DEBUG, "...UnbindInterface %u", dwErr);
00385     CE_Display(&g_ce);
00386
00387
00388     // delete interfaces
00389     for (i = 0; i < TEST_NUM_INTERFACE; i++)
00390     {
00391         dwErr = NM_DeleteInterface(i);
00392         if (dwErr != NO_ERROR)
00393         {
00394             TRACE1(DEBUG, "CM_Test: Could not Delete Interface %u", i);
00395             break;
00396         }
00397     }
00398     TRACE1(DEBUG, "...DeleteInterface %u", dwErr);
00399     CE_Display(&g_ce);
00400 }
00401
00402
00403
00404 VOID
00405 CM_Test()
00406 {
00407     DWORD                   dwErr = NO_ERROR;
00408     IPSAMPLE_GLOBAL_CONFIG  igc = { IPSAMPLE_LOGGING_INFO };
00409     ROUTING_PROTOCOL_EVENTS rpeEvent;
00410     MESSAGE                 mMessage;
00411     HANDLE                  hEvent;
00412
00413     hEvent = CreateEvent(NULL, FALSE, FALSE, "RouterManagerEvent");
00414
00415
00416     // start protocol
00417     dwErr = CM_StartProtocol(hEvent, NULL, (PVOID) (&igc));
00418     TRACE1(DEBUG, "StartProtocol %u", dwErr);
00419     CE_Display(&g_ce);
00420
00421
00422     // network manager test
00423     NM_Test(hEvent);
00424     TRACE0(DEBUG, "...NM_Test");
00425
00426
00427     // stop protocol
00428     dwErr = CM_StopProtocol();
00429     TRACE1(DEBUG, "StopProtocol %u", dwErr);
00430     CE_Display(&g_ce);
00431
00432
00433     // wait for stop event
00434     dwErr = WaitForSingleObject(hEvent, INFINITE);
00435     dwErr = CM_GetEventMessage(&rpeEvent, &mMessage);
00436     TRACE2(DEBUG, "Stopped %u %u", rpeEvent, dwErr);
00437     CE_Display(&g_ce);
00438
00439     CloseHandle(hEvent);
00440 }
00441
00442
00443
00444 VOID
00445 WINAPI
00446 TestProtocol(VOID)
00447 {
00448     ULONG   i;
00449
00450     TRACE0(DEBUG, "Hello World!!!");
00451
00452     for (i = 0; i < TEST_NUM_START_STOP; i++)
00453     {
00454         CM_Test();
00455         TRACE1(DEBUG, "...CM_Test (%u)", i);
00456     }
00457
00458     HT_Test();
00459     TRACE0(DEBUG, "...HT_Test");
00460
00461     ErrorCodes();
00462     TRACE0(DEBUG, "...ErrorCodes");
00463 }
00464
00465 #else   // TEST
00466
00467 VOID
00468 WINAPI
00469 TestProtocol(VOID)
00470 {
00471     TRACE0(ANY, "Hello World!");
00472 }
00473
00474 #endif  // TEST
00475
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ADSTYPEsyntaxmapping Member List

This is the complete list of members for ADSTYPEsyntaxmapping, including all inherited members.
adsType | ADSTYPEsyntaxmapping
pwszSyntax | ADSTYPEsyntaxmapping
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SEARCH_REQUEST Member List

This is the complete list of members for _SEARCH_REQUEST, including all inherited members.
File | _SEARCH_REQUEST
FileData | _SEARCH_REQUEST
FileSize | _SEARCH_REQUEST
FullPathName | _SEARCH_REQUEST
OverlappedIO | _SEARCH_REQUEST
WorkItem | _SEARCH_REQUEST
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Note Member List

This is the complete list of members for Note, including all inherited members.
dwFlag | Note
szText | Note
Generated on Wed Nov 13 2024 16:57:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/EventSink/EventSink.h Source File

  • TabletPC
  • EventSink

EventSink.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      EventSink.h
00013 //
00014 // Description:
00015 //      The header file for the CMyInkEvents and CMyInkCollector used
00016 //      by the EventSink sample. This file contains both the class
00017 //    definitions and the implementations of the methods.
00018 //
00019 //--------------------------------------------------------------------------
00020 #pragma once
00021
00022 #include "resource.h"
00023
00024 /////////////////////////////////////////////////////////
00025 //
00026 // class CMyInkEvents
00027 //
00028 // The CMyInkEvents class overrides the default implementation
00029 // of the stroke event handler specified in the class
00030 // InkCollectorEvents.
00031 //
00032 // It is important to note that there are two steps in
00033 // receiving an event using this class:
00034 //
00035 // 1. It is necessary to add an override of the event function
00036 //    to this class.
00037 //
00038 // 2. Use IInkCollector::SetEventInterest to ensure that the
00039 //    InkCollector generates the event.  Stroke, CursorInRange,
00040 //    CursorOutOfRange are the only event interests that are on
00041 //    by default.
00042 //
00043 /////////////////////////////////////////////////////////
00044 class CMyInkEvents : public InkCollectorEvents
00045 {
00046 public:
00047
00048     // Event: Stroke
00049     virtual void Stroke(
00050         IInkCursor* Cursor,
00051         IInkStrokeDisp* Stroke,
00052         VARIANT_BOOL *Cancel)
00053     {
00054         // Demonstrate that we received the event notification.
00055         MessageBox(m_hWnd, TEXT("Stroke Event"), TEXT("Event Received"), MB_OK);
00056     }
00057
00058     CMyInkEvents()
00059     {
00060         m_hWnd = NULL;
00061     }
00062
00063     HRESULT Init(
00064         HWND hWnd)
00065     {
00066         m_hWnd = hWnd;
00067         return InkCollectorEvents::Init();
00068     }
00069
00070     HWND m_hWnd;
00071 };
00072
00073 /////////////////////////////////////////////////////////
00074 //
00075 // class CMyInkCollector
00076 //
00077 // The CMyInkCollector class handles the connection between
00078 // the window and the Ink Collector. It sets up the connection
00079 // at start up and tears it down at exit.
00080 //
00081 /////////////////////////////////////////////////////////
00082 class CMyInkCollector
00083 {
00084 public:
00085
00086     // Constructor: just initialize memory
00087     CMyInkCollector()
00088     {
00089         m_pInkCollector = NULL;
00090     }
00091
00092     // Destructor: if there is an InkCollector, then release
00093     //  all resources connected with that InkCollector.
00094     ~CMyInkCollector()
00095     {
00096         if (m_pInkCollector != NULL)
00097         {
00098             m_InkEvents.UnadviseInkCollector();
00099             m_pInkCollector->put_Enabled(VARIANT_FALSE);
00100             m_pInkCollector->Release();
00101         }
00102     }
00103
00104     // Handle all initializaton
00105     HRESULT Init(
00106         HWND hWnd)
00107     {
00108         // Initialize event sink. This consists of setting
00109         //  up the free threaded marshaler.
00110         HRESULT hr = m_InkEvents.Init(hWnd);
00111
00112         if (FAILED(hr))
00113         {
00114             return hr;
00115         }
00116
00117         // Create the ink collector
00118         hr = CoCreateInstance(CLSID_InkCollector, NULL, CLSCTX_ALL,
00119             IID_IInkCollector, (void **) &m_pInkCollector);
00120
00121         if (FAILED(hr))
00122         {
00123             return hr;
00124         }
00125
00126         // Since this sample only handles the Stroke event, it is
00127         // not necessary to set the event interest (Stroke, CursorInRange,
00128         // CursorOutOfRange are the only event interests that are on by
00129         // default).  In order to handle an event that is not on by default,
00130         // it is necessary to set the event interest at this point.  The
00131         // following code illustrates how to listen for the NewPackets
00132         // event:
00133         //
00134         //hr = m_pInkCollector->SetEventInterest(ICEI_NewPackets, VARIANT_TRUE);
00135         //
00136         //if (FAILED(hr))
00137         //{
00138         //    return hr;
00139         //}
00140
00141         // Set up connection between Ink Collector and our event sink
00142         hr = m_InkEvents.AdviseInkCollector(m_pInkCollector);
00143
00144         if (FAILED(hr))
00145         {
00146             return hr;
00147         }
00148
00149         // Attach Ink Collector to window
00150         hr = m_pInkCollector->put_hWnd((long) hWnd);
00151
00152         if (FAILED(hr))
00153         {
00154             return hr;
00155         }
00156
00157         // Allow Ink Collector to receive input.
00158         return m_pInkCollector->put_Enabled(VARIANT_TRUE);
00159     }
00160
00161 private:
00162
00163     IInkCollector *m_pInkCollector;
00164
00165     CMyInkEvents m_InkEvents;
00166 };
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/netshell/sampinterface.cpp Source File

  • NetDS
  • netshell

sampinterface.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft Netsh Sample.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "nshsamp.h"
00018
00019 extern SAMPLE_HELPER_DATA g_OnlineData;
00020 extern SAMPLE_HELPER_DATA g_OfflineData;
00021 extern PSAMPLE_HELPER_DATA g_CurrentData;
00022 extern HANDLE g_hModule;
00023
00024 DWORD WINAPI
00025 DumpSampleInterface(
00026     IN      LPCWSTR     pwszRouter,
00027     IN OUT  LPWSTR     *ppwcArguments,
00028     IN      DWORD       dwArgCount,
00029     IN      LPCVOID     pvData
00030     )
00031 {
00032     DWORD       dwRet;
00033     UINT        OSType;
00034     UINT        OSProductSuite;
00035     WCHAR       OSVersion[MAX_PATH];
00036     WCHAR       OSBuildNumber[MAX_PATH];
00037     WCHAR       ServicePackMajorVersion[MAX_PATH];
00038     WCHAR       ServicePackMinorVersion[MAX_PATH];
00039     UINT        ProcessorArchitecture;
00040     LPWSTR      lpArchitecture = NULL;
00041
00042     //
00043     // This function is provided by netsh so that you can take different
00044     // actions in any function depending on the machine type.
00045     //
00046     dwRet = GetHostMachineInfo(
00047                 &OSType,
00048                 &OSProductSuite,
00049                 OSVersion,
00050                 OSBuildNumber,
00051                 ServicePackMajorVersion,
00052                 ServicePackMinorVersion,
00053                 &ProcessorArchitecture);
00054
00055     if (NO_ERROR == dwRet)
00056     {
00057
00058
00059         //
00060         // Note that these values (0 and 6) are WMI values that specify
00061         // the architecture.  At the time of this writing, these values
00062         // as listed in MSDN were off by one, ie x86 was listed as 1 and
00063         // IA64 was listed as 7.  The values here are the correct values
00064         // to check against.
00065         //
00066         switch(ProcessorArchitecture)
00067         {
00068             case 0:
00069                 lpArchitecture = TOKEN_X86;
00070                 break;
00071             case 6:
00072                 lpArchitecture = TOKEN_IA64;
00073                 break;
00074             default:
00075                 lpArchitecture = TOKEN_UNKNOWN;
00076                 break;
00077         }
00078     }
00079
00080     LPWSTR lpPotential = 0;
00081
00082     switch(g_CurrentData->Potential)
00083     {
00084         case LOW:
00085             lpPotential = TOKEN_LOW;
00086             break;
00087         case MEDIUM:
00088             lpPotential = TOKEN_MEDIUM;
00089             break;
00090         case HIGH:
00091             lpPotential = TOKEN_HIGH;
00092             break;
00093     }
00094
00095     //
00096     // Output the string that shows our settings.
00097     // The idea here is to spit out a script that,
00098     // when run from the command line (netsh -f script)
00099     // will cause your component to be configured
00100     // exactly as it is when this dump command is run.
00101     //
00102     PrintMessageFromModule(g_hModule, DUMP_SAMPINTERFACE,
00103                            TOKEN_SET,
00104                            TOKEN_INTERFACE,
00105                            TOKEN_ID,
00106                            g_CurrentData->InterfaceID,
00107                            g_CurrentData->bEnabled ? TOKEN_ENABLED : TOKEN_DISABLED,
00108                            TOKEN_SUPERMETRIC,
00109                            g_CurrentData->Supermetric,
00110                            TOKEN_POTENTIAL,
00111                            lpPotential,
00112                            // Second set command starts here.
00113                            TOKEN_GATEWAY,
00114                            TOKEN_USERDATA,
00115                            (DWORD)LOBYTE(LOWORD(g_CurrentData->GatewayUserData)),
00116                            (DWORD)HIBYTE(LOWORD(g_CurrentData->GatewayUserData)),
00117                            (DWORD)LOBYTE(HIWORD(g_CurrentData->GatewayUserData)),
00118                            (DWORD)HIBYTE(HIWORD(g_CurrentData->GatewayUserData)),
00119                            lpArchitecture);
00120
00121     return NO_ERROR;
00122 }
00123
00124 DWORD WINAPI
00125 HandleSetInterfaceCommand(
00126 IN      LPCWSTR pwszMachine,
00127 IN OUT  LPWSTR  *ppwcArguments,
00128 IN      DWORD   dwCurrentIndex,
00129 IN      DWORD   dwArgCount,
00130 IN      DWORD   dwFlags,
00131 IN      LPCVOID pvData,
00132 OUT     BOOL    *pbDone)
00133 {
00134     DWORD dwRet = ERROR_SHOW_USAGE;
00135     const DWORD MAX_CMDS = 4;
00136     DWORD dwTagType[MAX_CMDS];
00137
00138     //
00139     // This command line is more complicated, and allows us
00140     // to show the results of using PreprocessCommand on a
00141     // more complicated command line.
00142     //
00143
00144     TAG_TYPE ValidCommands[] =
00145     {
00146         {TOKEN_ID,  NS_REQ_PRESENT, FALSE},
00147         {TOKEN_ENABLED, NS_REQ_ZERO, FALSE},
00148         {TOKEN_DISABLED, NS_REQ_ZERO, FALSE},
00149         {TOKEN_SUPERMETRIC, NS_REQ_ZERO, FALSE},
00150         {TOKEN_POTENTIAL, NS_REQ_ZERO, FALSE}
00151     };
00152
00153     dwRet = PreprocessCommand(
00154         0,
00155         ppwcArguments,
00156         dwCurrentIndex,
00157         dwArgCount,
00158         ValidCommands,
00159         sizeof(ValidCommands)/sizeof(TAG_TYPE),
00160         // At least two commands are required - the id specification for the interface and some other bit of data.
00161         2,
00162         MAX_CMDS,
00163         dwTagType);
00164
00165     if (NO_ERROR == dwRet)
00166     {
00167         for (DWORD i = 0; i < (dwArgCount - dwCurrentIndex); i++)
00168         {
00169             //
00170             // This switch works because these were #defined to match with
00171             // ValidCommands above.
00172             //
00173             // #define ID                              0
00174             // #define ENABLED                         1
00175             // #define DISABLED                        2
00176             // #define SUPERMETRIC                     3
00177             // #define POTENTIAL                       4
00178             //
00179
00180             switch (dwTagType[i])
00181             {
00182                 case ID:
00183                     g_CurrentData->InterfaceID = wcstoul(ppwcArguments[i + dwCurrentIndex], NULL, 10);
00184                     break;
00185                 case ENABLED:
00186                     g_CurrentData->bEnabled = TRUE;
00187                     break;
00188                 case DISABLED:
00189                     g_CurrentData->bEnabled = FALSE;
00190                     break;
00191                 case SUPERMETRIC:
00192                     g_CurrentData->Supermetric = wcstoul(ppwcArguments[i + dwCurrentIndex], NULL, 10);
00193                     break;
00194                 case POTENTIAL:
00195                     if (MatchToken(ppwcArguments[i + dwCurrentIndex], TOKEN_LOW))
00196                     {
00197                         g_CurrentData->Potential = LOW;
00198                     }
00199                     else if (MatchToken(ppwcArguments[i + dwCurrentIndex], TOKEN_MEDIUM))
00200                     {
00201                         g_CurrentData->Potential = MEDIUM;
00202                     }
00203                     else if (MatchToken(ppwcArguments[i + dwCurrentIndex], TOKEN_HIGH))
00204                     {
00205                         g_CurrentData->Potential = HIGH;
00206                     }
00207                     break;
00208                 default:
00209                     //
00210                     // Shouldn't reach this point.
00211                     //
00212                     dwRet = ERROR_INVALID_SYNTAX;
00213                     break;
00214             }
00215         }
00216     }
00217
00218     return dwRet;
00219 }
00220
00221 DWORD WINAPI
00222 HandleSetGatewayCommand(
00223 IN      LPCWSTR pwszMachine,
00224 IN OUT  LPWSTR  *ppwcArguments,
00225 IN      DWORD   dwCurrentIndex,
00226 IN      DWORD   dwArgCount,
00227 IN      DWORD   dwFlags,
00228 IN      LPCVOID pvData,
00229 OUT     BOOL    *pbDone)
00230 {
00231     DWORD dwRet = ERROR_SHOW_USAGE;
00232     const DWORD MAX_CMDS = 4;
00233     const DWORD MAX_VALUE = 255;
00234
00235     DWORD dwTagType[MAX_CMDS];
00236
00237
00238     TAG_TYPE ValidCommands[] =
00239     {
00240         //
00241         // Specify that it is acceptable to put this token in a command
00242         // multiple times.
00243         //
00244         {TOKEN_USERDATA,     NS_REQ_ALLOW_MULTIPLE, FALSE}
00245     };
00246
00247     //
00248     // Since our command should have an = in it, PreprocessCommand will
00249     // do most of the parsing for us.
00250     //
00251     dwRet = PreprocessCommand(
00252         0,
00253         ppwcArguments,
00254         dwCurrentIndex,
00255         dwArgCount,
00256         ValidCommands,
00257         sizeof(ValidCommands)/sizeof(TAG_TYPE),
00258         1,
00259         // We'll put a limit of MAX_CMDS pieces of data (so it fits in one DWORD.)
00260         MAX_CMDS,
00261         dwTagType);
00262
00263     if (NO_ERROR == dwRet)
00264     {
00265         //
00266         // Reset GatewayUserData to 0.
00267         //
00268         g_CurrentData->GatewayUserData = 0;
00269
00270         for (DWORD i = dwCurrentIndex; i < dwArgCount; i++)
00271         {
00272             //
00273             // If we got to this point, then we can just start converting bits of data
00274             // because there is only one possible argument.
00275             //
00276             DWORD dwResult = wcstoul(ppwcArguments[i], NULL, 10);
00277             if (dwResult > 0 && dwResult < MAX_VALUE)
00278             {
00279                 //
00280                 // Store our data in the global DWORD by bitshifting each
00281                 // arg by (i - dwCurrentIndex) * 8 bits.  So, the first time
00282                 // through, i - dwCurrentIndex will be 0, and the value
00283                 // won't be shifted.  The second time through, i - dwCurrentIndex
00284                 // is 1, so the value will be shifted left by 8 bits, which
00285                 // when |'d with g_GatewayUserData, will store our number in the
00286                 // second byte.
00287                 //
00288                 g_CurrentData->GatewayUserData |= dwResult << ((i - dwCurrentIndex) * 8);
00289             }
00290             else
00291             {
00292                 dwRet = ERROR_SHOW_USAGE;
00293             }
00294         }
00295     }
00296
00297     return dwRet;
00298 }
00299
00300 DWORD WINAPI
00301 HandleShowRandomSettingsCommand(
00302 IN      LPCWSTR pwszMachine,
00303 IN OUT  LPWSTR  *ppwcArguments,
00304 IN      DWORD   dwCurrentIndex,
00305 IN      DWORD   dwArgCount,
00306 IN      DWORD   dwFlags,
00307 IN      LPCVOID pvData,
00308 OUT     BOOL    *pbDone)
00309 {
00310     LPWSTR lpPotential = 0;
00311
00312     switch(g_CurrentData->Potential)
00313     {
00314         case LOW:
00315             lpPotential = TOKEN_LOW;
00316             break;
00317         case MEDIUM:
00318             lpPotential = TOKEN_MEDIUM;
00319             break;
00320         case HIGH:
00321             lpPotential = TOKEN_HIGH;
00322             break;
00323     }
00324
00325     //
00326     // Output the current settings.
00327     //
00328     PrintMessageFromModule(g_hModule,
00329                            GEN_SAMPLEINTERFACE_SETTINGS,
00330                            g_CurrentData->InterfaceID,
00331                            g_CurrentData->bEnabled ? TOKEN_ENABLED : TOKEN_DISABLED,
00332                            g_CurrentData->Supermetric,
00333                            lpPotential);
00334
00335     PrintMessageFromModule(g_hModule,
00336                            GEN_SAMPLEGATEWAY_SETTINGS,
00337                            (DWORD)LOBYTE(LOWORD(g_CurrentData->GatewayUserData)),
00338                            (DWORD)HIBYTE(LOWORD(g_CurrentData->GatewayUserData)),
00339                            (DWORD)LOBYTE(HIWORD(g_CurrentData->GatewayUserData)),
00340                            (DWORD)HIBYTE(HIWORD(g_CurrentData->GatewayUserData)));
00341
00342
00343     //
00344     // There wasn't really any error checking to do for this one
00345     // so just return NO_ERROR.
00346     //
00347     return NO_ERROR;
00348 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIOleClientSite Member List

This is the complete list of members for CImpIOleClientSite, including all inherited members.
CImpIOleClientSite(class CSite *, IUnknown *) | CImpIOleClientSite |
GetContainer(LPOLECONTAINER *) | CImpIOleClientSite |
GetMoniker(DWORD, DWORD, LPMONIKER *) | CImpIOleClientSite |
m_cRef | CImpIOleClientSite | [protected]
m_pSite | CImpIOleClientSite | [protected]
m_pUnkOuter | CImpIOleClientSite | [protected]
OnShowWindow(BOOL) | CImpIOleClientSite |
QueryInterface(REFIID, void **) | CImpIOleClientSite |
RequestNewObjectLayout(void) | CImpIOleClientSite |
SaveObject(void) | CImpIOleClientSite |
ShowObject(void) | CImpIOleClientSite |
STDMETHODIMP_(ULONG) AddRef(void) | CImpIOleClientSite |
STDMETHODIMP_(ULONG) Release(void) | CImpIOleClientSite |
~CImpIOleClientSite(void) | CImpIOleClientSite |
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ComObj/ComObj.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • ComObj

ComObj.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      COMOBJ.H
00003
00004   Summary:   Include file for the COMOBJ.DLL dynamic link library that
00005              provides access to the services of the COMOBJ DLL.  This
00006              include file is meant to serve double duty as providing
00007              general set of macros that (1) when included in a COMOBJ
00008              implementation file wherein it provides a STDENTRY macro for
00009              the definition of exported functions and (2) when included in
00010              an app that uses these function calls it provides a STDENTRY
00011              macro for the declaration of imported functions.  The default
00012              behavior is to serve consumer apps that import the functions
00013              in the providing DLL.  Prior to the #include of this COMOBJ.H
00014              if _DLLEXPORT_ is #defined, the STDENTRY, STDENTRY_ and
00015              DLLENTRY macro expansion bahavior is directed to serve the
00016              COMOBJ itself in defining the functions as exported. If
00017              _DLLEXPORT_ is not defined and _LOCALCALLS_ is defined before
00018              the #include then the STDENTRY macro reduces to externs for
00019              support of local calls within the modules of the DLL.
00020
00021              This .H file is written to be #included in either C or C++
00022              programs.
00023
00024              For a comprehensive tutorial code tour of COMOBJ's
00025              contents and offerings see the tutorial COMOBJ.HTM file.
00026              For more specific technical details on the internal workings
00027              see the comments dispersed throughout the COMOBJ source code.
00028
00029   Classes:   none
00030
00031   Functions: none
00032
00033   Origin:    10-3-97: atrent - Editor-inheritance from DLLSKEL.H in
00034                the DLLSKEL Tutorial Code Sample. [Revised]
00035
00036 ----------------------------------------------------------------------------
00037   This file is part of the Microsoft COM Tutorial Code Samples.
00038
00039   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00040
00041   This source code is intended only as a supplement to Microsoft
00042   Development Tools and/or on-line documentation.  See these other
00043   materials for detailed information regarding Microsoft code samples.
00044
00045   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00046   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00047   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00048   PARTICULAR PURPOSE.
00049 ==========================================================================+*/
00050
00051 #if !defined(COMOBJ_H)
00052 #define COMOBJ_H
00053
00054 #if !defined(RC_INCLUDE)
00055
00056 #if !defined(_DLLEXPORT_)
00057
00058 // If _DLLEXPORT_ is not defined then the default is to import.
00059 #if defined(__cplusplus)
00060
00061 #if defined(_LOCALCALLS_)
00062 #define DLLENTRY extern "C"
00063 #else
00064 #define DLLENTRY extern "C" __declspec(dllimport)
00065 #endif
00066
00067 #else   // __cplusplus
00068
00069 #if defined(_LOCALCALLS_)
00070 #define DLLENTRY extern
00071 #else
00072 #define DLLENTRY extern __declspec(dllimport)
00073 #endif
00074
00075 #endif  // __cplusplus
00076
00077 #define STDENTRY DLLENTRY HRESULT WINAPI
00078 #define STDENTRY_(type) DLLENTRY type WINAPI
00079
00080 // Here is the list of service APIs offered by the DLL (using the
00081 // appropriate entry API declaration macros just #defined above).
00082
00083 STDENTRY_(BOOL) ComObjInitMsgLog(
00084                   CMsgLog* pMsgLog);
00085
00086 STDENTRY_(BOOL) ComObjAboutBox (HWND);
00087
00088 STDENTRY CreateCar(
00089            IUnknown* pUnkOuter,
00090            REFIID riid,
00091            PPVOID ppv);
00092
00093 STDENTRY CreateUtilityCar(
00094            IUnknown* pUnkOuter,
00095            REFIID riid,
00096            PPVOID ppv);
00097
00098 STDENTRY CreateCruiseCar(
00099            IUnknown* pUnkOuter,
00100            REFIID riid,
00101            PPVOID ppv);
00102
00103 #else  // _DLLEXPORT_
00104
00105 // Else if _DLLEXPORT_ is defined then we've been told to export.
00106 #if defined(__cplusplus)
00107
00108 #if defined(_LOCALCALLS_)
00109 #define DLLENTRY extern "C"
00110 #else
00111 #define DLLENTRY extern "C" __declspec(dllexport)
00112 #endif
00113
00114 #else   // __cplusplus
00115
00116 #if defined(_LOCALCALLS_)
00117 #define DLLENTRY
00118 #else
00119 #define DLLENTRY __declspec(dllexport)
00120 #endif
00121
00122 #endif  // __cplusplus
00123
00124 #define STDENTRY DLLENTRY HRESULT WINAPI
00125 #define STDENTRY_(type) DLLENTRY type WINAPI
00126
00127 #endif // _DLLEXPORT_
00128
00129 #endif // RC_INCLUDE
00130
00131 #endif // COMOBJ_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Create/vc/Create.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Create
  • vc

Create.cpp

Go to the documentation of this file.
00001 // Create.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "stdio.h"
00006 #include "activeds.h"
00007
00008 HRESULT CreateUserIADsContainer(void)
00009 {
00010 HRESULT hr;
00011 IADsContainer *pCont = NULL;
00012 IDispatch *pDisp=NULL;
00013 IADsUser *pIADsUser=NULL;
00014
00015 ///////////////////////////////////////////////////
00016 // Create a user using IADsContainer::Create
00017 ////////////////////////////////////////////////////
00018 hr = ADsGetObject( L"WinNT://seyitb-dev", IID_IADsContainer, (void**) &pCont );
00019 if (FAILED(hr) )
00020   return hr;
00021
00022
00023 hr = pCont->Create(L"user", L"AliceW", &pDisp );
00024 pCont->Release();
00025
00026 if(FAILED(hr) )
00027   return hr;
00028
00029 hr = pDisp->QueryInterface( IID_IADsUser, (void**) &pIADsUser );
00030 if (FAILED(hr))
00031     return hr;
00032
00033
00034 //do NOT hard code your password into the source code in production code
00035 //take user input instead
00036 pIADsUser->SetPassword(L"MysEcret1");
00037 hr = pIADsUser->SetInfo(); // Commit
00038 if(SUCCEEDED(hr))
00039     wprintf(L"User created successfully\n");
00040
00041 pIADsUser->Release();
00042
00043 return hr;
00044 }
00045
00046
00047 HRESULT CreateUserIDirectoryObject(void)
00048 {
00049 ///////////////////////////////////////////////////////////
00050 // Use IDirectoryObject to create an object
00051 ////////////////////////////////////////////////////////////
00052 HRESULT hr;
00053 IDispatch *pDisp=NULL;
00054 IDirectoryObject *pDirObject=NULL;
00055 ADSVALUE   sAMValue;
00056 ADSVALUE   uPNValue;
00057 ADSVALUE   classValue;
00058
00059 ADS_ATTR_INFO  attrInfo[] =
00060 {
00061   { L"objectClass",   ADS_ATTR_UPDATE,
00062                     ADSTYPE_CASE_IGNORE_STRING, &classValue, 1 },
00063   {L"sAMAccountName", ADS_ATTR_UPDATE,
00064                         ADSTYPE_CASE_IGNORE_STRING, &sAMValue, 1},
00065   {L"userPrincipalName", ADS_ATTR_UPDATE,
00066                         ADSTYPE_CASE_IGNORE_STRING, &uPNValue, 1},
00067 };
00068 DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
00069
00070 classValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
00071 classValue.CaseIgnoreString = L"user";
00072
00073 sAMValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
00074 sAMValue.CaseIgnoreString = L"mikes";
00075
00076 uPNValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
00077 uPNValue.CaseIgnoreString = L"mikes@fabrikam.com";
00078
00079 // Create this user in an organizational unit
00080 hr = ADsGetObject(L"LDAP://OU=MyOU,DC=fabrikam,DC=com",
00081             IID_IDirectoryObject, (void**) &pDirObject );
00082
00083 if ( SUCCEEDED(hr) )
00084 {
00085   hr = pDirObject->CreateDSObject( L"CN=Mike Smith",  attrInfo,
00086                    dwAttrs, &pDisp );
00087   if ( SUCCEEDED(hr) )
00088   {
00089     pDisp->Release();
00090   }
00091     pDirObject->Release();
00092 }
00093
00094 return hr;
00095 }
00096
00097 int main(int argc, char* argv[])
00098 {
00099 HRESULT hr;
00100 CoInitialize(NULL);
00101
00102 // Create a local user account
00103 hr = CreateUserIADsContainer();
00104 wprintf(L"Result: 0x%x\n", hr);
00105
00106 // Create a domain user account in Active Directory
00107 // hr = CreateUserIDirectoryObject();
00108 // wprintf(L"Result: 0x%x\n", hr);
00109
00110 CoUninitialize();
00111 return 0;
00112 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

NILNode_c< T > Member List

This is the complete list of members for NILNode_c< T >, including all inherited members.
Back | NILNode_c< T > | [private]
Data | NILNode_c< T > | [private]
Next | NILNode_c< T > | [private]
NIDeque_c< T > class | NILNode_c< T > | [friend]
NIDequeIter_c< T > class | NILNode_c< T > | [friend]
NILNode_c() | NILNode_c< T > |
Generated on Wed Nov 13 2024 16:57:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

UDDI::Tools::CategoryTreeNode Member List

This is the complete list of members for UDDI::Tools::CategoryTreeNode, including all inherited members.
_categoryValue | UDDI::Tools::CategoryTreeNode | [private]
_hasDownloadedChildren | UDDI::Tools::CategoryTreeNode | [private]
CategoryTreeNode() | UDDI::Tools::CategoryTreeNode | [inline, private]
CategoryTreeNode(CategoryValue val) | UDDI::Tools::CategoryTreeNode | [inline]
CategoryValue | UDDI::Tools::CategoryTreeNode |
HasDownloadedChildren | UDDI::Tools::CategoryTreeNode | [private]
IsSchemeNode | UDDI::Tools::CategoryTreeNode | [private]
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/statnode.h Source File

  • SysMgmt
  • MMC
  • Simple

statnode.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SNAPINBASE_H
00021 #define _SNAPINBASE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CStaticNode : public CDelegationBase {
00026 public:
00027     CStaticNode();
00028     virtual ~CStaticNode();
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0) {
00031         static _TCHAR szDisplayName[256];
00032         LoadString(g_hinst, IDS_SNAPINNAME, szDisplayName, (sizeof szDisplayName)/(sizeof szDisplayName[0]));
00033         return szDisplayName;
00034     }
00035     virtual const GUID & getNodeType() { return thisGuid; }
00036     virtual const int GetBitmapIndex() { return INDEX_NONE; }
00037
00038 public:
00039     // virtual functions for MMCN_* go here
00040
00041 private:
00042     // {2974380C-4C4B-11d2-89D8-000021473128}
00043     static const GUID thisGuid;
00044
00045     struct privateData {
00046         _TCHAR host[MAX_PATH];
00047         bool isDirty;
00048
00049         privateData() : isDirty(false) {
00050             ZeroMemory(host, sizeof(host));
00051         }
00052     } snapInData;
00053
00054     public:
00055         LONG getDataSize() { return sizeof(privateData); }
00056         void *getData() { return &snapInData; }
00057         bool isDirty() { return snapInData.isDirty; }
00058         void clearDirty() { snapInData.isDirty = false; };
00059 };
00060
00061 #endif // _SNAPINBASE_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWaitCursor Member List

This is the complete list of members for CWaitCursor, including all inherited members.
CWaitCursor() | CWaitCursor |
m_hPrevCursor | CWaitCursor | [protected]
RestoreCursor() | CWaitCursor |
WaitCursor() | CWaitCursor |
~CWaitCursor() | CWaitCursor | [virtual]
Generated on Wed Nov 13 2024 16:57:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/DllDatax.c Source File

  • Com
  • Services
  • Crm
  • CrmFiles

DllDatax.c

Go to the documentation of this file.
00001 // wrapper for dlldata.c
00002
00003 #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
00004
00005 #define REGISTER_PROXY_DLL //DllRegisterServer, etc.
00006
00007 #if !defined(_WIN32_WINNT)
00008 #define _WIN32_WINNT 0x0500
00009 #endif // !defined(_WIN32_WINNT)
00010 #define USE_STUBLESS_PROXY  //defined only with MIDL switch /Oicf
00011
00012 #pragma comment(lib, "rpcndr.lib")
00013 #pragma comment(lib, "rpcns4.lib")
00014 #pragma comment(lib, "rpcrt4.lib")
00015
00016 #define DllMain       PrxDllMain
00017 #define DllRegisterServer PrxDllRegisterServer
00018 #define DllUnregisterServer PrxDllUnregisterServer
00019 #define DllGetClassObject   PrxDllGetClassObject
00020 #define DllCanUnloadNow     PrxDllCanUnloadNow
00021
00022 #include "dlldata.c"
00023 #include "CrmFiles_p.c"
00024
00025 #ifdef _NOPROXY //no midl generated dlldata.c
00026
00027 #define STRICT 1
00028 #include <ole2.h>
00029
00030 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00031 {return TRUE;}
00032
00033 STDAPI PrxDllCanUnloadNow(void){return S_OK;}
00034
00035 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00036 {return CLASS_E_CLASSNOTAVAILABLE;}
00037
00038 STDAPI PrxDllRegisterServer(void){return S_OK;}
00039
00040 STDAPI PrxDllUnregisterServer(void){return S_OK;}
00041
00042 #endif //!PROXY_DELEGATION
00043
00044 #endif //_MERGE_PROXYSTUB
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Dibapi.h Source File

  • Multimedia
  • Gdi
  • WinCap32

Dibapi.h

Go to the documentation of this file.
00001 /*    PortTool v2.2     dibapi.h          */
00002
00003 /*
00004  *  dibapi.h
00005  *
00006  *  ** Win32 Version **
00007  *
00008  *  Copyright 1991 - 2000 Microsoft Corporation. All rights reserved
00009  *
00010  *  Header file for Device-Independent Bitmap (DIB) API.  Provides
00011  *  function prototypes and constants for the following functions:
00012  *
00013  *  BitmapToDIB()        - Creates a DIB from a bitmap
00014  *  ChangeBitmapFormat() - Changes a bitmap to a specified DIB format
00015  *  ChangeDIBFormat()    - Changes a DIB's BPP and/or compression format
00016  *  CopyScreenToBitmap() - Copies entire screen to a standard Bitmap
00017  *  CopyScreenToDIB()    - Copies entire screen to a DIB
00018  *  CopyWindowToBitmap() - Copies a window to a standard Bitmap
00019  *  CopyWindowToDIB()    - Copies a window to a DIB
00020  *  CreateDIBPalette()   - Creates a palette from a DIB
00021  *  CreateDIB()          - Creates a new DIB
00022  *  DestroyDIB()         - Deletes DIB when finished using it
00023  *  DIBError()           - Displays message box with error message
00024  *  DIBHeight()          - Gets the DIB height
00025  *  DIBNumColors()       - Calculates number of colors in the DIB's color table
00026  *  DIBToBitmap()        - Creates a bitmap from a DIB
00027  *  DIBWidth()           - Gets the DIB width
00028  *  FindDIBBits()        - Sets pointer to the DIB bits
00029  *  GetSystemPalette()   - Gets the current palette
00030  *  LoadDIB()            - Loads a DIB from a file
00031  *  PaintBitmap()        - Displays standard bitmap in the specified DC
00032  *  PaintDIB()           - Displays DIB in the specified DC
00033  *  PalEntriesOnDevice() - Gets the number of palette entries
00034  *  PaletteSize()        - Calculates the buffer size required by a palette
00035  *  PrintDIB()           - Prints the specified DIB
00036  *  PrintScreen()        - Prints the entire screen
00037  *  PrintWindowSamp()        - Prints all or part of a window
00038  *  SaveDIB()            - Saves the specified dib in a file
00039  *
00040  * See the file DIBAPI.TXT for more information about these functions.
00041  *
00042  */
00043
00044
00045 /* Handle to a DIB */
00046 #define HDIB HANDLE
00047
00048
00049 /* Print Area selection */
00050 #define PW_WINDOW        1
00051 #define PW_CLIENT        2
00052
00053
00054 /* Print Options selection */
00055 #define PW_BESTFIT       1
00056 #define PW_STRETCHTOPAGE 2
00057 #define PW_SCALE         3
00058
00059 /* DIB Macros*/
00060
00061 // WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits"
00062 // parameter is the bit count for the scanline (biWidth * biBitCount),
00063 // and this macro returns the number of DWORD-aligned bytes needed
00064 // to hold those bits.
00065
00066 #define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)
00067
00068 /* Error constants */
00069 enum {
00070       ERR_MIN = 0,                     // All error #s >= this value
00071       ERR_NOT_DIB = 0,                 // Tried to load a file, NOT a DIB!
00072       ERR_MEMORY,                      // Not enough memory!
00073       ERR_READ,                        // Error reading file!
00074       ERR_LOCK,                        // Error on a GlobalLock()!
00075       ERR_OPEN,                        // Error opening a file!
00076       ERR_CREATEPAL,                   // Error creating palette.
00077       ERR_GETDC,                       // Couldn't get a DC.
00078       ERR_CREATEDDB,                   // Error create a DDB.
00079       ERR_STRETCHBLT,                  // StretchBlt() returned failure.
00080       ERR_STRETCHDIBITS,               // StretchDIBits() returned failure.
00081       ERR_SETDIBITSTODEVICE,           // SetDIBitsToDevice() failed.
00082       ERR_STARTDOC,                    // Error calling StartDoc().
00083       ERR_NOGDIMODULE,                 // Couldn't find GDI module in memory.
00084       ERR_SETABORTPROC,                // Error calling SetAbortProc().
00085       ERR_STARTPAGE,                   // Error calling StartPage().
00086       ERR_NEWFRAME,                    // Error calling NEWFRAME escape.
00087       ERR_ENDPAGE,                     // Error calling EndPage().
00088       ERR_ENDDOC,                      // Error calling EndDoc().
00089       ERR_SETDIBITS,                   // Error calling SetDIBits().
00090       ERR_FILENOTFOUND,                // Error opening file in GetDib()
00091       ERR_INVALIDHANDLE,               // Invalid Handle
00092       ERR_DIBFUNCTION,                 // Error on call to DIB function
00093       ERR_MAX                          // All error #s < this value
00094      };
00095
00096
00097
00098 /* Function prototypes */
00099
00100 HDIB BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal);
00101 HDIB ChangeBitmapFormat (HBITMAP  hBitmap,
00102                                    WORD     wBitCount,
00103                                    DWORD    dwCompression,
00104                                    HPALETTE hPal);
00105 HDIB ChangeDIBFormat (HDIB hDIB, WORD wBitCount,
00106                                 DWORD dwCompression);
00107 HBITMAP CopyScreenToBitmap (LPRECT);
00108 HDIB CopyScreenToDIB (LPRECT);
00109 HBITMAP CopyWindowToBitmap (HWND, WORD);
00110 HDIB CopyWindowToDIB (HWND, WORD);
00111 HPALETTE CreateDIBPalette (HDIB);
00112 HDIB CreateDIB(DWORD, DWORD, WORD);
00113 WORD DestroyDIB (HDIB);
00114 void DIBError (int ErrNo);
00115 DWORD DIBHeight (LPSTR lpDIB);
00116 WORD DIBNumColors (LPSTR lpDIB);
00117 HBITMAP DIBToBitmap (HDIB hDIB, HPALETTE hPal);
00118 DWORD DIBWidth (LPSTR lpDIB);
00119 LPSTR FindDIBBits (LPSTR lpDIB);
00120 HPALETTE GetSystemPalette (void);
00121 HDIB LoadDIB (LPSTR);
00122 BOOL PaintBitmap (HDC, LPRECT, HBITMAP, LPRECT, HPALETTE);
00123 BOOL PaintDIB (HDC, LPRECT, HDIB, LPRECT, HPALETTE);
00124 int PalEntriesOnDevice (HDC hDC);
00125 WORD PaletteSize (LPSTR lpDIB);
00126 WORD PrintDIB (HDIB, WORD, WORD, WORD, LPSTR);
00127 WORD PrintScreen (LPRECT, WORD, WORD, WORD, LPSTR);
00128 WORD PrintWindowSamp (HWND, WORD, WORD, WORD, WORD, LPSTR);
00129 WORD SaveDIB (HDIB, LPSTR);
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authorization/dbauth.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • Authorization

dbauth.cpp

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName: DBAuth.cpp
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011
00012 // Note: Proxy/Stub Information
00013 //      To build a separate proxy/stub DLL,
00014 //      run nmake -f DBAuthps.mk in the project directory.
00015
00016 #include "stdafx.h"
00017 #include "resource.h"
00018 #include <initguid.h>
00019 #include "DBAuth.h"
00020
00021 #include "DBAuthPlugin.h"
00022
00023
00024 CComModule _Module;
00025
00026 BEGIN_OBJECT_MAP(ObjectMap)
00027 OBJECT_ENTRY(CLSID_DBAuthPlugin, CDBAuthPlugin)
00028 END_OBJECT_MAP()
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // DLL Entry Point
00032
00033 extern "C"
00034 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00035 {
00036     if (dwReason == DLL_PROCESS_ATTACH)
00037     {
00038         _Module.Init(ObjectMap, hInstance, &LIBID_DBAUTHPLUGINLib);
00039         DisableThreadLibraryCalls(hInstance);
00040     }
00041     else if (dwReason == DLL_PROCESS_DETACH)
00042         _Module.Term();
00043     return TRUE;    // ok
00044 }
00045
00046 /////////////////////////////////////////////////////////////////////////////
00047 // Used to determine whether the DLL can be unloaded by OLE
00048
00049 STDAPI DllCanUnloadNow(void)
00050 {
00051     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00052 }
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // Returns a class factory to create an object of the requested type
00056
00057 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00058 {
00059     return _Module.GetClassObject(rclsid, riid, ppv);
00060 }
00061
00062 /////////////////////////////////////////////////////////////////////////////
00063 // DllRegisterServer - Adds entries to the system registry
00064
00065 STDAPI DllRegisterServer(void)
00066 {
00067     // registers object, typelib and all interfaces in typelib
00068     return _Module.RegisterServer(TRUE);
00069 }
00070
00071 /////////////////////////////////////////////////////////////////////////////
00072 // DllUnregisterServer - Removes entries from the system registry
00073
00074 STDAPI DllUnregisterServer(void)
00075 {
00076     return _Module.UnregisterServer(TRUE);
00077 }
00078
00079
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/SampleFSP/NewFsp.h Source File

  • NetDS
  • fax
  • SampleFSP

NewFsp.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1997 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007   newfsp.h
00008
00009 Abstract:
00010
00011   This module contains the newfsp definitions
00012
00013 --*/
00014
00015 #include <windows.h>
00016 #include <stdio.h>
00017 #include <tapi.h>
00018 #include <faxdev.h>
00019 #include <winfax.h>
00020
00021 #include "macros.h"
00022 #include "reg.h"
00023
00024 // RESOURCE_STRING_LEN is the maximum length of a resource string
00025 #define RESOURCE_STRING_LEN        256
00026 // MAX_PATH_LEN is the maximum length of a fully-qualified path without the filename
00027 #define MAX_PATH_LEN               MAX_PATH - 16
00028
00029 // NEWFSP_DEVICE_LIMIT is the virtual fax device limit of the newfsp service provider
00030 #define NEWFSP_DEVICE_LIMIT        4
00031
00032 // NEWFSP_LOG_FILE is the name of the log file
00033 #define NEWFSP_LOG_FILE            L"SampleFSP.log"
00034
00035 // DEVICE_NAME_PREFIX is the name prefix for the virtual fax devices
00036 #define NEWFSP_DEVICE_NAME_PREFIX  L"SampleFSP Device "
00037 // DEVICE_ID_PREFIX is the value that identifies the virtual fax devices
00038 #define NEWFSP_DEVICE_ID_PREFIX    0x5000
00039
00040 // DEVICE_IDLE indicates the virtual fax device is idle
00041 #define DEVICE_IDLE                1
00042 // DEVICE_START indicates the virtual fax device is pending a fax job
00043 #define DEVICE_START               2
00044 // DEVICE_SEND indicates the virtual fax device is sending
00045 #define DEVICE_SEND                3
00046 // DEVICE_RECEIVE indicates the virtual fax device is receiving
00047 #define DEVICE_RECEIVE             4
00048 // DEVICE_ABORTING indicates the virtual fax device is aborting
00049 #define DEVICE_ABORTING            5
00050
00051 // JOB_UNKNOWN indicates the fax job is pending
00052 #define JOB_UNKNOWN                1
00053 // JOB_SEND indicates the fax job is a send
00054 #define JOB_SEND                   2
00055 // JOB_RECEIVE indicates the fax job is a receive
00056 #define JOB_RECEIVE                3
00057
00058 typedef struct _DEVICE_INFO {
00059     CRITICAL_SECTION     cs;                      // object to serialize access to the virtual fax device
00060     DWORD                DeviceId;                // specifies the identifier of the virtual fax device
00061     WCHAR                Directory[MAX_PATH_LEN]; // specifies the virtual fax device's incoming fax directory
00062     DWORD                Status;                  // specifies the current status of the virtual fax device
00063     HANDLE               ExitEvent;               // specifies the handle to the event to indicate the thread to watch for an incoming fax transmission is to exit
00064     struct _DEVICE_INFO  *pNextDeviceInfo;        // pointer to the next virtual fax device
00065     struct _JOB_INFO     *pJobInfo;               // pointer to the fax job associated with the virtual fax device
00066 } DEVICE_INFO, *PDEVICE_INFO;
00067
00068 typedef struct _JOB_INFO {
00069     PDEVICE_INFO         pDeviceInfo;             // pointer to the virtual fax device data associated with the fax job
00070     HANDLE               CompletionPortHandle;    // specifies a handle to an I/O completion port
00071     ULONG_PTR            CompletionKey;           // specifies a completion port key value
00072     DWORD                JobType;                 // specifies the fax job type
00073     DWORD                Status;                  // specifies the current status of the fax job
00074     HLINE                LineHandle;              // specifies a handle to the open line device associated with the fax job
00075     HCALL                CallHandle;              // specifies a handle to the active call associated with the fax job
00076     LPWSTR               FileName;                // specifies the full path to the file that contains the data stream for the fax document
00077     LPWSTR               CallerName;              // specifies the name of the calling device
00078     LPWSTR               CallerNumber;            // specifies the telephone number of the calling device
00079     LPWSTR               ReceiverName;            // specifies the name of the receiving device
00080     LPWSTR               ReceiverNumber;          // specifies the telephone number of the receiving device
00081     DWORD                RetryCount;              // specifies the number of retries associated with the fax job
00082     BOOL                 Branding;                // specifies whether the fax service provider should generate a brand at the top of the fax transmission
00083     DWORD                PageCount;               // specifies the number of pages associated with the fax job
00084     LPWSTR               CSI;                     // specifies the identifier of the remote fax device
00085     LPWSTR               CallerId;                // specifies the identifier of the calling fax device
00086     LPWSTR               RoutingInfo;             // specifies the routing string associated with the fax job
00087 } JOB_INFO, *PJOB_INFO;
00088
00089 HANDLE        g_hInstance;       // g_hInstance is the global handle to the module
00090 HLINEAPP      g_LineAppHandle;   // g_LineAppHandle is the global handle to the fax service's registration with TAPI
00091 HANDLE        g_CompletionPort;  // g_CompletionPort is the global handle to an I/O completion port that the fax service provider must use to post I/O completion port packets to the fax service for asynchronous line status events
00092 ULONG_PTR     g_CompletionKey;   // g_CompletionKey is the global completion port key value
00093
00094 HANDLE        g_hLogFile;        // g_hLogFile is the global handle to the log file
00095 PDEVICE_INFO  *g_pDeviceInfo;    // g_pDeviceInfo is the global pointer to the virtual fax device data
00096
00097 // Function definitions:
00098
00099 BOOL
00100 GetNewFspRegistryData(
00101     BOOL          *bLoggingEnabled,
00102     LPWSTR        lpszLoggingDirectory,
00103   DWORD     dwLoggingDirectoryBufferSize,
00104     PDEVICE_INFO  *pDeviceInfo,
00105     LPDWORD       pdwNumDevices
00106 );
00107
00108 VOID
00109 SetNewFspRegistryData(
00110     BOOL          bLoggingEnabled,
00111     LPWSTR        lpszLoggingDirectory,
00112     PDEVICE_INFO  pDeviceInfo
00113 );
00114
00115 BOOL
00116 OpenLogFile(
00117     BOOL    bLoggingEnabled,
00118     LPWSTR  lpszLoggingDirectory
00119 );
00120
00121 VOID
00122 CloseLogFile(
00123 );
00124
00125 VOID
00126 WriteDebugString(
00127     LPWSTR  lpszFormatString,
00128     ...
00129 );
00130
00131 VOID
00132 PostJobStatus(
00133     HANDLE     CompletionPort,
00134     ULONG_PTR  CompletionKey,
00135     DWORD      StatusId,
00136     DWORD      ErrorCode
00137 );
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Accept/ASAccept.cpp Source File

  • NetDS
  • WinSock
  • Accept

ASAccept.cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: ASAccept.cpp
00009 //
00010 // Description:
00011 //             This file contains the functions for implementing the
00012 // Async Select version of the accept. Many of the functions that are common
00013 // to Non-blocking accept and Async Select accept are defined in Common.cpp.
00014
00015 #include "common.h"
00016
00017 /*
00018     This function converts the FD_XXX events into a printable string.
00019     As the returned strings are static strings, they must not be modified.
00020 */
00021 const char *FDImage(long lEvent)
00022 {
00023     const char *szRetVal;
00024
00025     // return the printable strings corresponding to the event.
00026     switch(lEvent)
00027     {
00028         case FD_READ:       szRetVal = "FD_READ";
00029                             break;
00030         case FD_WRITE:      szRetVal = "FD_WRITE";
00031                             break;
00032         case FD_ACCEPT:     szRetVal = "FD_ACCEPT";
00033                             break;
00034         case FD_CLOSE:      szRetVal = "FD_CLOSE";
00035                             break;
00036         default:            szRetVal = "Unexpected";
00037                             break;
00038     }
00039
00040     return szRetVal;
00041 }
00042
00043 /*
00044     This is the call back function for the WSAAsyncSelect call.
00045     This is called by winsock whenever a event is available on a
00046     AsyncSelect-ed socket to be processed.
00047     wParam contains the socket handle.
00048     lParam contains the signalled event as well as error code, if any.
00049 */
00050 void ProcessAsyncSelectMessage(WPARAM wParam, LPARAM lParam)
00051 {
00052     // get the socket handle from wParam.
00053     SOCKET sock = (SOCKET) wParam;
00054
00055     // get the type of event using the macro below.
00056     long event = WSAGETSELECTEVENT(lParam);
00057
00058     // get the error associated with the event, if any, using the macro below.
00059     int error = WSAGETSELECTERROR(lParam);
00060     BOOL bSocketToBeClosed = FALSE;
00061     PSOCK_INFO pSockInfo;
00062     int rc;
00063
00064     printf("Entering ProcessAsyncSelectMessage() for "
00065            "Sock = %d, Event = %s, Error = %d\n",
00066             sock, FDImage(event), error);
00067
00068     // first, get the SockInfo object corresponding to the signalled socket
00069     // to retrieve the context of this socket.
00070     for(pSockInfo = g_AcceptContext.pSockList;pSockInfo;
00071                                               pSockInfo = pSockInfo->next)
00072     {
00073         if (sock == pSockInfo->sock)
00074             break; // found.
00075     }
00076
00077     // check if we found one.
00078     if (!pSockInfo)
00079     {
00080         // no, we couldn't find one. This will happen usually because of
00081         // dummy FD_READs that we are posting which might show up even
00082         // after we closed the socket and removed the SockInfo structure
00083         // from the global sockets list. This condition is not an error,
00084         // but a normal timing condition. So, we don't have to do anything
00085         // with this socket.
00086         printf("Couldn't find SockInfo. Socket might have been closed.\n");
00087         goto CLEANUP;
00088     }
00089
00090     // if we were signalled an error event instead of a positive event
00091     // then we don't have to process the socket.
00092     if (error)
00093     {
00094         // some error has happened on this socket.
00095         // need to close the socket.
00096         bSocketToBeClosed = TRUE;
00097         goto CLEANUP;
00098     }
00099
00100     // take the corresponding action depending on the event signalled.
00101     switch(event)
00102     {
00103         case FD_ACCEPT:
00104
00105             // Accept the new connection.
00106             pSockInfo = ProcessAcceptEvent(pSockInfo);
00107             if (pSockInfo == NULL)
00108             {
00109                 // some error in accepting the connection or allocating
00110                 // resources for the new socket.
00111                 break;
00112             }
00113
00114             // request the specified events to be notified asynchronously
00115             // to the hAcceptWindow for the given sock.
00116             rc = WSAAsyncSelect(pSockInfo->sock,
00117                                 g_AcceptContext.hAcceptWindow,
00118                                 WM_USER_ASYNCSELECT_MSG,
00119                                 FD_READ | FD_WRITE | FD_CLOSE);
00120
00121             // check if the request went through.
00122             if (rc == SOCKET_ERROR)
00123             {
00124                 printf("ERROR: WSAAsyncSelect failed on sock %d. Error = %d\n",
00125                        pSockInfo->sock, WSAGetLastError());
00126                 bSocketToBeClosed = TRUE;
00127             }
00128             break;
00129
00130         case FD_READ:
00131
00132             // Read data from the socket, if there's room for the new data.
00133             bSocketToBeClosed = ProcessReadEvent(pSockInfo);
00134
00135             // check if the recv call indicated that the remote side has closed
00136             // the socket and that we should also close it.
00137             if (bSocketToBeClosed == FALSE)
00138             {
00139                 // no, it didn't. so, go ahead and echo the received data back
00140                 // if possible.
00141                 bSocketToBeClosed = SendData(pSockInfo);
00142
00143                 // check if the echo was successful.
00144                 if (bSocketToBeClosed == FALSE)
00145                 {
00146                     // yes it was.
00147                     // now, if this happens to be the last piece of the
00148                     // incoming data, and a FD_CLOSE was already notified to
00149                     // us, we may not receive any more FD_READ notifications.
00150                     // So, we need to post a dummy FD_READ notification to
00151                     // this socket so that we again do a recv until we get
00152                     // a 0 from recv, which means graceful disconnect from
00153                     // other side or until we receive an error from recv.
00154                     if (pSockInfo->isFdCloseRecd)
00155                     {
00156                         // post ourselves another FD_READ in case
00157                         // there's no data left.
00158                         printf("Posting a dummy FD_READ \n");
00159                         PostMessage(g_AcceptContext.hAcceptWindow,
00160                                     WM_USER_ASYNCSELECT_MSG,
00161                                     pSockInfo->sock,
00162                                     FD_READ);
00163                     }
00164                 }
00165             }
00166             break;
00167
00168         case FD_WRITE:
00169
00170             // since we usually echo the data immediately after receiving it
00171             // in the FD_READ case above, we may not need this case, except
00172             // for one important condition: when send fails with WSAEWOULDBLOCK
00173             // then we'll be notified with this event once the remote side
00174             // has started consuming the data and we can continue our send.
00175             bSocketToBeClosed = SendData(pSockInfo);
00176
00177             // in this case, most likely, while the previous data wasn't
00178             // sent, there would have been a FD_READ which didn't result
00179             // in a recv call. Hence, there won't be another FD_READ posted
00180             // unless we call recv. So, we post a dummy FD_READ ourselves
00181             // to allow the FD_READ handling code to be explicitly called.
00182
00183             // Note: In a real implementation, we would have to maintain
00184             // more elaborate state to avoid posting these possibly redundant
00185             // window messages.
00186
00187             printf("Posting a dummy FD_READ \n");
00188             PostMessage(g_AcceptContext.hAcceptWindow,
00189                         WM_USER_ASYNCSELECT_MSG,
00190                         pSockInfo->sock,
00191                         FD_READ);
00192
00193             break;
00194
00195         case FD_CLOSE:
00196
00197             // even though the remote side has closed the socket, there might
00198             // still be data that's left to read. so, we should just remember
00199             // that we received a FD_CLOSE but not close the socket until
00200             // we have read all the data.
00201             pSockInfo->isFdCloseRecd = TRUE;
00202
00203             // post ourselves another FD_READ in case there's no data
00204             // left in which case, we'll actually close the socket when recv
00205             // returns 0.
00206             printf("Posting a dummy FD_READ \n");
00207             PostMessage(g_AcceptContext.hAcceptWindow,
00208                         WM_USER_ASYNCSELECT_MSG,
00209                         pSockInfo->sock,
00210                         FD_READ);
00211
00212             break;
00213
00214         default:
00215             printf("Unexpected event: 0x%x for socket %d\n", event, sock);
00216             bSocketToBeClosed = TRUE;
00217             break;
00218     }
00219
00220 CLEANUP:
00221
00222     // if we were told in any of the above cases to close the socket,
00223     // e.g. remote side closed and we got an error or recv returned 0,etc.
00224     // then we close our socket.
00225     if (bSocketToBeClosed)
00226     {
00227         // make sure we cancel the WSAAsyncSelect event with the event mask 0.
00228         WSAAsyncSelect(pSockInfo->sock, g_AcceptContext.hAcceptWindow, 0, 0);
00229
00230         // shutdown the socket so as not to hang the client just in case it
00231         // expects us to send any more data.
00232         if (shutdown(pSockInfo->sock, SD_SEND) == SOCKET_ERROR)
00233             printf("ERROR: Shutdown failed. Error = %d\n", WSAGetLastError());
00234
00235         // close the socket.
00236         closesocket(pSockInfo->sock);
00237         printf("Closed socket %d. "
00238                "Total Bytes Recd = %d, "
00239                "Total Bytes Sent = %d\n",
00240                 pSockInfo->sock,
00241                 pSockInfo->nTotalRecd,
00242                 pSockInfo->nTotalSent);
00243
00244         // delete it from the global list and free the memory.
00245         DeleteSockInfoFromList(&g_AcceptContext.pSockList,
00246                                pSockInfo);
00247     }
00248
00249     printf("Exiting ProcessAsyncSelectMessage()\n");
00250   return ;
00251 }
00252
00253
00254 /*
00255     This is the Windows procedure for handling all the messages for
00256     the given window. We are interested in only one message. The
00257     rest of them will be passed on to the default windows procedure.
00258 */
00259 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message,
00260                              WPARAM wParam, LPARAM lParam)
00261 {
00262     LRESULT res = 0;
00263
00264     // check what the message type is.
00265     switch (message) {
00266
00267         case WM_DESTROY:
00268         PostQuitMessage(0);
00269             break;
00270
00271       // this is the message that that we gave in WSAAsyncSelect which
00272       // winsock will send us back for notifying us of socket events.
00273         case WM_USER_ASYNCSELECT_MSG:
00274           ProcessAsyncSelectMessage(wParam, lParam);
00275         break;
00276
00277       default:
00278         res = DefWindowProc(hWnd, message, wParam, lParam);
00279             break;
00280     }
00281
00282   return res;
00283 }
00284
00285
00286 /*
00287     This function creates a hidden window to receive the
00288     async select messages sent by winsock for socket events.
00289 */
00290 HWND CreateAcceptWindow(void)
00291 {
00292   WNDCLASS window;
00293   HWND windowHandle = NULL;
00294
00295     // set the window properties.
00296   memset(&window, 0, sizeof(WNDCLASS));
00297   window.lpszClassName = "Accept Window";
00298   window.hInstance = NULL;
00299   window.lpfnWndProc = (WNDPROC) MainWndProc;
00300   window.hCursor = NULL;
00301   window.hIcon = NULL;
00302   window.lpszMenuName = NULL;
00303   window.hbrBackground = NULL;
00304   window.style = 0;
00305   window.cbClsExtra = 0;
00306   window.cbWndExtra = 0;
00307
00308   // register the window class.
00309   if (!RegisterClass(&window)) {
00310     printf("Registerclass failed %d\n", GetLastError());
00311         goto CLEANUP;
00312   }
00313
00314   // create the window.
00315   windowHandle = CreateWindow("Accept Window",
00316                 "Accept Window",
00317                 WS_OVERLAPPEDWINDOW,  //WS_MINIMIZE,
00318                 CW_USEDEFAULT,
00319                 CW_USEDEFAULT,
00320                 CW_USEDEFAULT,
00321                 CW_USEDEFAULT,
00322                 (HWND) NULL,
00323                 (HMENU) NULL,
00324                 (HINSTANCE) NULL,
00325                 (LPVOID) NULL);
00326
00327   // check if a window was created.
00328   if (windowHandle == NULL)
00329   {
00330     printf("CreateWindow failed %d\n", GetLastError());
00331     return NULL;
00332   }
00333
00334     // uncomment the line below to see the window on the taskbar.
00335     // ShowWindow(windowHandle, SW_MINIMIZE);
00336
00337 CLEANUP:
00338
00339   return windowHandle;
00340 }
00341
00342
00343
00344 /*
00345     This function is the entry point for the AsyncSelect Accept implementation.
00346 */
00347 void AsyncSelectAcceptMain()
00348 {
00349     PSOCK_INFO pSockInfo;
00350     int rc;
00351     MSG msg;
00352
00353     printf("Entering AsyncSelectAcceptMain()\n");
00354
00355     // create a dummy hidden window to receive the async select messages.
00356     g_AcceptContext.hAcceptWindow = CreateAcceptWindow();
00357     if (g_AcceptContext.hAcceptWindow == NULL)
00358     {
00359         printf("Error in creating the accept window.\n");
00360         goto CLEANUP;
00361     }
00362
00363     // Set for all the listening sockets to be signalled on FD_ACCEPT event.
00364     for(pSockInfo = g_AcceptContext.pSockList; pSockInfo != NULL;
00365                                                pSockInfo = pSockInfo->next)
00366     {
00367         // request asynchronous notifications for the FD_ACCEPT and FD_CLOSE
00368         // events to be sent to the hAcceptWindow for this sock.
00369         rc = WSAAsyncSelect(pSockInfo->sock,
00370                             g_AcceptContext.hAcceptWindow,
00371                             WM_USER_ASYNCSELECT_MSG,
00372                             FD_ACCEPT | FD_CLOSE);
00373         if (rc == SOCKET_ERROR)
00374         {
00375             printf("ERROR: WSAAsyncSelect failed for sock %d. Error = %d\n",
00376                                     pSockInfo->sock, WSAGetLastError());
00377             continue;
00378         }
00379     }
00380
00381     // Main message loop to process messages to the Accept Window.
00382     // This will indirectly call MainWndProc which will in turn call
00383     // ProcessAsyncSelectMessage.
00384     while (GetMessage(&msg, (HWND) NULL, 0, 0)) {
00385         TranslateMessage(&msg);
00386         DispatchMessage(&msg);
00387     }
00388
00389
00390 CLEANUP:
00391
00392     printf("Exiting AsyncSelectAcceptMain()\n");
00393     return ;
00394 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tag_NODE_ATTRIB_ Member List

This is the complete list of members for _tag_NODE_ATTRIB_, including all inherited members.
szObjectPath _tag_NODE_ATTRIB_
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/crowset.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

crowset.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CROWSET.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CROWSET_H_
00012 #define _CROWSET_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Defines
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019 enum BINDCOLS
00020 {
00021   BIND_ALLCOLS        = 0x00000001,
00022   BIND_ALLCOLSEXPECTBOOKMARK  = 0x00000002,
00023   BIND_UPDATEABLECOLS     = 0x00000004
00024 };
00025
00026
00027 //////////////////////////////////////////////////////////////////////////////
00028 // Forwards
00029 //
00030 //////////////////////////////////////////////////////////////////////////////
00031 class CMainWindow;
00032 class CMDIChild;
00033
00034
00035 /////////////////////////////////////////////////////////////////
00036 // CBindings class
00037 //
00038 /////////////////////////////////////////////////////////////////
00039 class CBindings : public CVector<DBBINDING, DBCOUNTITEM>
00040 {
00041 public:
00042   //Constructor
00043   CBindings() {}
00044   ~CBindings() {}
00045
00046   //Overload
00047   void    RemoveAll()
00048   {
00049     //Overloaded - inorder to first free out-of-line data
00050 		::FreeBindings(&m_cElements, &m_rgElements);
00051
00052     //Now - Delegate
00053     CVector<DBBINDING, DBCOUNTITEM>::RemoveAll();
00054   }
00055
00056   HRESULT   FreeData(void* pv, BOOL fSetData = FALSE)
00057   {
00058     //Delegate
00059     return ::FreeBindingData(m_cElements, m_rgElements, pv, fSetData);
00060   }
00061
00062   const DBBINDING*  GetOrdinal(DBORDINAL iOrdinal)
00063   {
00064     //Due to the bookmark column being present or absent causes the Binding
00065     //to not be lined exactly (1:1) to the Ordinal position...
00066
00067     //no-ops
00068     if(!GetCount() || !GetElements() || (iOrdinal==0 && GetElement(0).iOrdinal!=0))
00069       return NULL;
00070
00071     //Bookmark
00072     if(GetElement(0).iOrdinal == 0)
00073     {
00074       //[0,1,2,3,4,5...]
00075       ASSERT(GetElement(iOrdinal).iOrdinal == iOrdinal);
00076       return &GetElement(iOrdinal);
00077     }
00078     else
00079     {
00080       //[1,2,3,4,5...]
00081       ASSERT(GetElement(iOrdinal-1).iOrdinal == iOrdinal);
00082       return &GetElement(iOrdinal-1);
00083     }
00084
00085     return NULL;
00086   }
00087
00088 protected:
00089   //Data
00090 };
00091
00092
00093 /////////////////////////////////////////////////////////////////
00094 // CColumnInfo class
00095 //
00096 /////////////////////////////////////////////////////////////////
00097 class CColumnInfo : public CVector<DBCOLUMNINFO, DBORDINAL>
00098 {
00099 public:
00100   //Constructor
00101   CColumnInfo()
00102   {
00103     m_cHiddenColumns  = 0;
00104   }
00105   ~CColumnInfo()
00106   {
00107   }
00108
00109   //Overload
00110   void    RemoveAll()
00111   {
00112     //Overloaded - inorder to first free out-of-line data
00113     m_cstrStringBuffer.Empty();
00114     m_cHiddenColumns  = 0;
00115
00116     //Now - Delegate
00117     CVector<DBCOLUMNINFO, DBORDINAL>::RemoveAll();
00118   }
00119
00120   //Overload
00121   void    Attach(DBORDINAL cColumnInfo, DBCOLUMNINFO* rgColumnInfo, WCHAR* pwszStringBuffer, DBORDINAL cHiddenColumns = 0)
00122   {
00123     //First - Delegate
00124     //NOTE: We have to do this first, since this method call RemoveAll, which will empty
00125     //anything we do in this class, since its virtual...
00126     CVector<DBCOLUMNINFO, DBORDINAL>::Attach(cColumnInfo, rgColumnInfo);
00127
00128     //Overloaded - inorder to first obtain other items
00129     m_cstrStringBuffer.Attach(pwszStringBuffer);
00130     m_cHiddenColumns  = cHiddenColumns;
00131
00132   }
00133
00134   BOOL    IsHidden(DBORDINAL iOrdinal)
00135   {
00136     //Hidden Column
00137     if(m_cHiddenColumns)
00138     {
00139       //cColInfo already includes cHiddenColumns, this...
00140       ASSERT(m_cHiddenColumns <= m_cElements);
00141
00142       //Is this a hidden column
00143       //If this ordinal is >= to the first hidden column then its hidden...
00144       if(iOrdinal >= m_rgElements[m_cElements - m_cHiddenColumns].iOrdinal)
00145         return TRUE;
00146     }
00147
00148     return FALSE;
00149
00150   }
00151
00152   const DBCOLUMNINFO* GetOrdinal(DBORDINAL iOrdinal)
00153   {
00154     //Due to the bookmark column being present or absent causes the Binding
00155     //to not be lined exactly (1:1) to the Ordinal position...
00156
00157     //no-ops
00158     if(!GetCount() || !GetElements() || (iOrdinal==0 && GetElement(0).iOrdinal!=0))
00159       return NULL;
00160
00161     //Bookmark
00162     if(GetElement(0).iOrdinal == 0)
00163     {
00164       //[0,1,2,3,4,5...]
00165       ASSERT(GetElement(iOrdinal).iOrdinal == iOrdinal);
00166       return &GetElement(iOrdinal);
00167     }
00168     else
00169     {
00170       //[1,2,3,4,5...]
00171       ASSERT(GetElement(iOrdinal-1).iOrdinal == iOrdinal);
00172       return &GetElement(iOrdinal-1);
00173     }
00174
00175     return NULL;
00176   }
00177
00178 protected:
00179   //Data
00180   CComWSTR  m_cstrStringBuffer;
00181   DBORDINAL m_cHiddenColumns; //DBPROP_HIDDENCOLUMNS
00182 };
00183
00184
00185 ////////////////////////////////////////////////////////////////
00186 // CDataAccess
00187 //
00188 /////////////////////////////////////////////////////////////////
00189 class CDataAccess : public CAsynchBase
00190 {
00191 public:
00192   //Constructors
00193   CDataAccess(SOURCE eObjectType, CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00194   virtual ~CDataAccess();
00195
00196   //IUnknown Helpers
00197   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00198   virtual HRESULT     AutoRelease();
00199   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00200
00201   //Members
00202   virtual HRESULT     GetColInfo();
00203   virtual HRESULT     GetColInfo(DBORDINAL* pcColumns, DBCOLUMNINFO** prgColumnInfo, WCHAR** ppStringBuffer, DBORDINAL* pcHiddenColumns);
00204   virtual INT       GetColumnImage(const DBCOLUMNINFO* pColInfo, DBSTATUS dbStatus = DBSTATUS_S_OK);
00205
00206   virtual HRESULT     ValidateAccessor(HACCESSOR hAccessor, ULONG ulRefCount = 1);
00207   virtual HRESULT     SetColumnData(const DBBINDING* pBinding, void* pData, DBSTATUS   dbStatus, DBLENGTH   dbLength, WCHAR* pwszValue, DWORD dwFlags, DBTYPE wBackendType);
00208   virtual HRESULT     GetColumnData(const DBBINDING* pBinding, void* pData, DBSTATUS* pdbStatus, DBLENGTH* pdbLength, DBTYPE* pwSubType, WCHAR* pwszValue, ULONG ulMaxSize, DWORD dwFlags, DBTYPE wBackendType);
00209
00210   virtual HRESULT     CreateAccessors(BINDCOLS eBindCols);
00211   virtual HRESULT     CreateAccessor(DBACCESSORFLAGS dwAccessorFlags, DBCOUNTITEM cBindings, const DBBINDING* rgBindings, DBLENGTH cRowSize, HACCESSOR* phAccessor);
00212   virtual HRESULT     SetupBindings(BINDCOLS eBindCols, DBCOUNTITEM* cBindings, DBBINDING** prgBindings, DBLENGTH* pcRowSize = NULL);
00213
00214   virtual HRESULT     AddRefAccessor(HACCESSOR hAccessor);
00215   virtual HRESULT     ReleaseAccessor(HACCESSOR* phAccessor, BOOL fReleaseAlways = FALSE);
00216   virtual HRESULT     GetColumnsRowset(CAggregate* pCAggregate, bool fOptColumns, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown);
00217
00218   //Rowset
00219   //[MANADATORY]
00220   IAccessor*          m_pIAccessor;
00221   IColumnsInfo*       m_pIColumnsInfo;
00222   IConvertType*       m_pIConvertType;
00223
00224   //[OPTIONAL]
00225   IColumnsRowset*       m_pIColumnsRowset;
00226
00227   //ColInfo
00228   CColumnInfo         m_ColumnInfo;
00229
00230   //Accessor
00231   CBindings         m_Bindings;
00232   HACCESSOR         m_hAccessor;
00233   DBLENGTH          m_cbRowSize;
00234   void*           m_pData;
00235
00236   //Bookmark Accessor
00237   HACCESSOR         m_hBmkAccessor;
00238   BOOL            m_bSchemaRowset;
00239 };
00240
00241
00242 ////////////////////////////////////////////////////////////////
00243 // CRowset
00244 //
00245 /////////////////////////////////////////////////////////////////
00246 class CRowset : public CDataAccess
00247 {
00248 public:
00249   //Constructors
00250   CRowset(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00251   virtual ~CRowset();
00252
00253   //IUnknown Helpers
00254   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00255   virtual HRESULT     AutoRelease();
00256   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00257
00258   //Pure Virtual
00259   virtual WCHAR*      GetObjectName()     { return m_hChapter ? L"Chapter" : L"Rowset";   }
00260   virtual UINT      GetObjectMenu()     { return IDM_ROWSETMENU;              }
00261   virtual LONG      GetObjectImage()    { return m_hChapter ? IMAGE_CHAPTER : IMAGE_TABLE;  }
00262   virtual REFIID      GetDefaultInterface() { return IID_IRowset;               }
00263
00264   virtual WCHAR*      GetObjectDesc();
00265   virtual HRESULT     DisplayObject();
00266
00267   //Members
00268   virtual HRESULT     ValidateRow(HROW hRow, ULONG ulRefCount = 1);
00269
00270   virtual HRESULT     GetData(HROW hRow, HACCESSOR hAccessor = NULL, void* pData = NULL, DBPROPID dwSourceID = DBPROP_IRowset);
00271   virtual HRESULT     GetBookmark(HROW hRow, DBBKMARK* pcbBookmark, BYTE** ppBookmark);
00272   virtual HRESULT     GetChapter(HROW hRow, DBORDINAL iOrdinal, HCHAPTER* phChapter);
00273
00274   virtual HRESULT     RestartPosition();
00275   virtual HRESULT     GetNextRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, DBCOUNTITEM* pcRowsObtained, HROW** prghRows);
00276   virtual HRESULT     AddRefRows(DBROWCOUNT cRows, HROW* rghRows, ULONG* rgRefCounts = NULL);
00277   virtual HRESULT     ReleaseRows(DBROWCOUNT cRows, HROW* rghRows, ULONG* rgRefCounts = NULL);
00278   virtual HRESULT     GetRowFromHROW(CAggregate* pCAggregate, HROW hRow, REFIID riid, IUnknown** ppIUnknown);
00279
00280
00281   //Rowset
00282   //[MANADATORY]
00283   IRowset*          m_pIRowset;
00284   IRowsetInfo*        m_pIRowsetInfo;
00285
00286   //[OPTIONAL]
00287   IRowsetChange*        m_pIRowsetChange;
00288   IRowsetIdentity*      m_pIRowsetIdentity;
00289   IRowsetLocate*        m_pIRowsetLocate;
00290   IRowsetFind*        m_pIRowsetFind;
00291   IRowsetView*        m_pIRowsetView;
00292   IChapteredRowset*     m_pIChapteredRowset;
00293   IRowsetResynch*       m_pIRowsetResynch;
00294   IRowsetRefresh*       m_pIRowsetRefresh;
00295   IRowsetIndex*       m_pIRowsetIndex;
00296   IRowsetScroll*        m_pIRowsetScroll;
00297   IRowsetUpdate*        m_pIRowsetUpdate;
00298   IRowsetBookmark*      m_pIRowsetBookmark;
00299   IGetRow*          m_pIGetRow;
00300
00301   //Notifications
00302   DWORD           m_dwCookieRowsetNotify;
00303
00304   //Chapters
00305   HCHAPTER          m_hChapter;
00306
00307   //Properties
00308   BOOL            m_fRemoveDeleted;
00309 };
00310
00311
00312
00313
00314
00315 #endif //_CROWSET_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/tablecopy.h Source File

  • Dataaccess
  • oledb
  • tablecopy

tablecopy.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module TABLECOPY.H
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 #ifndef _TABLECOPY_H_
00012 #define _TABLECOPY_H_
00013
00014
00015 ///////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 ///////////////////////////////////////////////////////////////
00019 #include "oledb.h"
00020
00021
00022 ///////////////////////////////////////////////////////////////
00023 // Forward Declarations
00024 //
00025 ///////////////////////////////////////////////////////////////
00026 class CTable;
00027 class CWizard;
00028
00029
00030 ///////////////////////////////////////////////////////////////
00031 // Defines
00032 //
00033 ///////////////////////////////////////////////////////////////
00034 #define MAX_QUERY_LEN     4096
00035 #define MAX_NAME_LEN      256
00036
00037 #define MAX_COL_SIZE       50000
00038 #define MAX_BLOCK_SIZE        20
00039 #define MAX_STREAM_BLOCK_SIZE 2000
00040
00041 // Create param bitmasks describe the parameter required on create table
00042 #define CP_PRECISION    0x0001
00043 #define CP_SCALE      0x0002
00044 #define CP_LENGTH     0x0004
00045 #define CP_MAXLENGTH    0x0008
00046
00047 // This macro will determine if the type is numeric, and
00048 // if numeric -> bPrecision, if not numeric -> dwColumnSize
00049 #define COLINFO_SIZE(ColInfo) (IsNumericType(ColInfo.wType) ? ColInfo.bPrecision : ColInfo.ulColumnSize)
00050
00051
00052 /////////////////////////////////////////////////////////////////
00053 // CTableCopy
00054 //
00055 /////////////////////////////////////////////////////////////////
00056 class CTableCopy
00057 {
00058 public:
00059   //Constructors
00060   CTableCopy(CWizard* pCWizard);
00061   virtual ~CTableCopy();
00062
00063   //Members
00064   virtual HRESULT MapTypes();
00065   virtual HRESULT CopyTables();
00066
00067   //Row Options
00068   DWORD   m_dwRowOpt;     // Row Options
00069   ULONG   m_ulMaxRows;    // Maximum rows or ALL_ROWS
00070
00071   //Insert Options
00072   DWORD   m_dwInsertOpt;    // Insert Options
00073   ULONG   m_ulParamSets;    // Number of Parameters Sets
00074
00075   //BLOB options
00076   DWORD   m_dwBlobOpt;        // Blob Options
00077   ULONG   m_ulBlobSize;       // Maximum Size for BLOB Columns
00078
00079   //Options
00080   BOOL    m_fShowQuery;   // TRUE to display SQL statements
00081   BOOL    m_fCopyTables;    // TRUE to create the table definition
00082   BOOL    m_fCopyIndexes;   // TRUE to create indexes on new table
00083   BOOL    m_fCopyPrimaryKeys; // TRUE to copy primary keys on new table
00084
00085   //Data
00086   CTable*   m_pCFromTable;    //Source Table
00087   CTable*   m_pCToTable;    //Target Table
00088
00089   BOOL    m_fTranslate;   // TRUE to translate object names
00090   CWizard*    m_pCWizard;
00091 };
00092
00093
00094 #endif  //_TABLECOPY_H_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/LocatDlg.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

LocatDlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // LocatDlg.h : header file
00013 //
00014
00015
00016
00017
00018 /////////////////////////////////////////////////////////////////////////////
00019 // CLocateDialog dialog
00020
00021 class CLocateDialog : public CDialog
00022 {
00023 // Construction
00024 public:
00025   CLocateDialog(CWnd* pParent = NULL);   // standard constructor
00026
00027 // Dialog Data
00028   //{{AFX_DATA(CLocateDialog)
00029   enum { IDD = IDD_LOCATE_DIALOG };
00030   CString m_szLabel;
00031   //}}AFX_DATA
00032
00033
00034 // Overrides
00035   // ClassWizard generated virtual function overrides
00036   //{{AFX_VIRTUAL(CLocateDialog)
00037   protected:
00038   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00039   //}}AFX_VIRTUAL
00040
00041 // Implementation
00042 protected:
00043
00044   // Generated message map functions
00045   //{{AFX_MSG(CLocateDialog)
00046     // NOTE: the ClassWizard will add member functions here
00047   //}}AFX_MSG
00048   DECLARE_MESSAGE_MAP()
00049
00050 public:
00051   void GetLabel(TCHAR szLabelBuffer[BUFFERSIZE])
00052   {
00053     ASSERT(szLabelBuffer != NULL);
00054
00055     _tcsncpy (szLabelBuffer, m_szLabel, BUFFERSIZE-1);
00056     szLabelBuffer[BUFFERSIZE-1] = '\0';
00057
00058   }
00059
00060
00061 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/FCopy/FCopy.Cpp Source File

  • WinBase
  • IO
  • FCopy

FCopy.Cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000 Microsoft Corporation.  All rights reserved.
00008
00009 fcopy.cpp
00010
00011 This program demonstrates how to use file mappings to implement a file-copy
00012 program.  It can copy any size file on Windows NT.
00013
00014 The size of the file mapping view is a multiple of the system's
00015 allocation size. With relatively large views, this program
00016 runs faster than if it used many small views.  The size of the view
00017 can be adjusted up or down by changing the ALLOCATION_MULTIPLIER constant.
00018 The only recommendation is that the view size must be no more than can fit
00019 into the process's address space.
00020
00021 Note:  Supports 64-bit file systems.
00022 ---------------------------------------------------------------------------*/
00023
00024 #define WIN32_LEAN_AND_MEAN
00025
00026 #include <windows.h>
00027 #include <stdio.h>
00028
00029
00030 #if defined (DEBUG)
00031 #define DEBUG_PRINT(X) printf(X)
00032 #else
00033 #define DEBUG_PRINT(X)
00034 #endif
00035
00036 #include <crtdbg.h>
00037
00038 // maximum view size
00039 DWORD dwMaxViewSize ;
00040
00041 // multiplying the system allocation size by the following constant
00042 // determines the maximum view size
00043 const WORD ALLOCATION_MULTIPLIER = 1 ;
00044
00045 const int   SUCCESS = 0;   /* for return value from main() */
00046 const int   FAILURE = 1;   /* for return value from main() */
00047
00048 /*---------------------------------------------------------------------------
00049 main (argc, argv)
00050
00051 The main program.  Takes the command line arguments, copies the source file
00052 to the destination file.
00053
00054 Parameters
00055    argc
00056       Count of command-line arguments, including the name of the program.
00057    argv
00058       Array of pointers to strings that contain individual command-line
00059       arguments.
00060
00061 Returns
00062    Zero if program executed successfully, non-zero otherwise.
00063 ---------------------------------------------------------------------------*/
00064 int main (int argc, char **argv)
00065 {
00066    int   fResult = FAILURE;
00067
00068    SYSTEM_INFO siSystemInfo ;
00069    DWORD dwMaxViewSize ;
00070
00071    ULARGE_INTEGER liSrcFileSize,
00072                   liBytesRemaining,
00073                   liMapSize,
00074                   liOffset;
00075
00076    HANDLE hSrcFile    = INVALID_HANDLE_VALUE,
00077           hDstFile    = INVALID_HANDLE_VALUE,
00078           hSrcMap     = 0,
00079           hDstMap     = 0;
00080
00081    BYTE * pSrc = 0,
00082         * pDst = 0;
00083
00084    char * pszSrcFileName = 0,
00085         * pszDstFileName = 0;
00086
00087    if (argc != 3)
00088    {
00089       printf("usage: fcopy <srcfile> <dstfile>\n");
00090       return (FAILURE);
00091    }
00092
00093    pszSrcFileName = argv[argc-2];  // Src is second to last argument
00094    pszDstFileName = argv[argc-1];  // Dst is the last argument
00095
00096    // Obtain the system's allocation granularity, then multiply it by an
00097    // arbitrary factor to obtain the maximum view size
00098    GetSystemInfo(&siSystemInfo);
00099    dwMaxViewSize = siSystemInfo.dwAllocationGranularity * ALLOCATION_MULTIPLIER;
00100
00101    /*
00102       Steps to open and access a file's contents:
00103          1) Open the file,
00104          2) Create a mapping of the file,
00105          3) Map a view of the file.
00106
00107       This yields a pointer to the file's contents, which can then be used
00108       to access the file, just as if it's contents were in a memory buffer.
00109
00110       For the source file, open and map it as read only; for the destination
00111       file, open and map it as read-write.  We allow other processes to read
00112       the source file while we're copying it, but do not allow access to the
00113       destination file since we're writing it.
00114    */
00115
00116    // Open the source and destination files
00117    hSrcFile = CreateFile (pszSrcFileName, GENERIC_READ, FILE_SHARE_READ,
00118                           0, OPEN_EXISTING, 0, 0);
00119    if (INVALID_HANDLE_VALUE == hSrcFile)
00120    {
00121       printf("fcopy: couldn't open source file.\n");
00122       goto DONE;
00123    }
00124
00125    hDstFile = CreateFile (pszDstFileName, GENERIC_READ|GENERIC_WRITE, 0,
00126                           0, CREATE_ALWAYS, 0, 0);
00127    if (INVALID_HANDLE_VALUE == hDstFile)
00128    {
00129       printf("fcopy: couldn't create destination file.\n");
00130       goto DONE;
00131    }
00132
00133
00134    // Need source file's size to know how big to make the destination mapping.
00135    liSrcFileSize.LowPart = GetFileSize(hSrcFile, &liSrcFileSize.HighPart);
00136    if ( (-1 == liSrcFileSize.LowPart) && (GetLastError() != NO_ERROR) )
00137    {
00138       DEBUG_PRINT("couldn't get size of source file.\n");
00139       goto DONE;
00140    }
00141
00142    /*
00143       Special case:  If the source file is zero bytes, we don't map it because
00144       there's no need to and CreateFileMapping cannot map a zero-length file.
00145       But since we've created the destination, we've successfully "copied" the
00146       source.
00147    */
00148    if (0 == liSrcFileSize.QuadPart)
00149    {
00150       fResult = SUCCESS;
00151       goto DONE;
00152    }
00153
00154
00155    /*
00156       Map the source and destination files.  A mapping size of zero means the
00157       whole file will be mapped.
00158    */
00159    hSrcMap = CreateFileMapping (hSrcFile, 0, PAGE_READONLY, 0, 0, 0);
00160    if (!hSrcMap)
00161    {
00162       DEBUG_PRINT("couldn't map source file\n");
00163       goto DONE;
00164    }
00165
00166    hDstMap = CreateFileMapping (hDstFile, 0, PAGE_READWRITE,
00167                                 liSrcFileSize.HighPart,
00168                                 liSrcFileSize.LowPart, 0);
00169    if (!hDstMap)
00170    {
00171       DEBUG_PRINT("couldn't map destination file.\n");
00172       goto DONE;
00173    }
00174
00175
00176    /*
00177       Now that we have the source and destination mapping objects, map views
00178       of the source and destination files, and do the file copy.
00179
00180       To minimize the amount of memory consumed for large files and make it
00181       possible to copy files that couldn't be mapped into our virtual address
00182       space entirely (those over 2GB), we limit the source and destination
00183       views to the smaller of the file size or a specified maximum view size
00184       (dwMaxViewSize, which is ALLOCATION_MULTIPLIER times the system's
00185       allocation size).
00186
00187       If the file is smaller than the max view size, we'll just map and copy
00188       it.  Otherwise, we'll map a portion of the file, copy it, then map the
00189       next portion, copy it, etc. until the entire file is copied.
00190
00191       MAP_SIZE is 32 bits because MapViewOfFile requires a 32-bit value for
00192       the size of the view.  This makes sense because a Win32 process's
00193       address space is 4GB, of which only 2GB (2^31) bytes may be used by the
00194       process.  However, for the sake of making 64-bit arithmetic work below
00195       for file offets, we need to make sure that all 64 bits of liMapSize
00196       are initialized correctly.
00197
00198       Note structured exception handling is used in case a MapViewOfFile call
00199       failed.  That should never happen in this program, but in case it does,
00200       we should handle it.  Since the possibility is so remote, it is faster
00201       to handle the exception when it occurs rather than test for failure in
00202       the loop.
00203    */
00204    __try
00205    {
00206       liBytesRemaining.QuadPart = liSrcFileSize.QuadPart;
00207
00208       // stan bug fix
00209       liMapSize.QuadPart        = dwMaxViewSize;
00210
00211       // Make sure that the arithmetic below is correct during debugging.
00212       _ASSERT(liMapSize.HighPart == 0);
00213
00214       do
00215       {
00216          liMapSize.QuadPart = min(liBytesRemaining.QuadPart, liMapSize.QuadPart);
00217
00218          liOffset.QuadPart = liSrcFileSize.QuadPart - liBytesRemaining.QuadPart;
00219
00220          pSrc = (BYTE *)MapViewOfFile (hSrcMap, FILE_MAP_READ, liOffset.HighPart,
00221                                        liOffset.LowPart, liMapSize.LowPart);
00222
00223          pDst = (BYTE *)MapViewOfFile (hDstMap, FILE_MAP_WRITE, liOffset.HighPart,
00224                                        liOffset.LowPart, liMapSize.LowPart);
00225
00226          CopyMemory (pDst, pSrc, liMapSize.LowPart);
00227
00228          UnmapViewOfFile (pSrc);
00229          UnmapViewOfFile (pDst);
00230
00231          liBytesRemaining.QuadPart -= liMapSize.QuadPart;
00232       }
00233       while (liBytesRemaining.QuadPart > 0);
00234
00235       fResult = SUCCESS;
00236    }
00237    __except (EXCEPTION_EXECUTE_HANDLER)
00238    {
00239       /*
00240          Only way we should get here is if a MapViewOfFile failed.  That
00241          shouldn't happen, but in case it does clean up the resources.
00242       */
00243       if (pSrc)
00244          UnmapViewOfFile (pSrc);
00245
00246       if (pDst)
00247          UnmapViewOfFile (pDst);
00248    }
00249
00250
00251 DONE:
00252    /* Clean up all outstanding resources.  Note views are already unmapped. */
00253    if (hDstMap)
00254       CloseHandle (hDstMap);
00255
00256    if (hDstFile != INVALID_HANDLE_VALUE)
00257       CloseHandle (hDstFile);
00258
00259    if (hSrcMap)
00260       CloseHandle (hSrcMap);
00261
00262    if (hSrcFile != INVALID_HANDLE_VALUE)
00263       CloseHandle (hSrcFile);
00264
00265
00266    // Report to user only if a problem occurred.
00267    if (fResult != SUCCESS)
00268    {
00269       printf("fcopy: copying failed.\n");
00270       DeleteFile (pszDstFileName);
00271    }
00272
00273
00274    return (fResult);
00275 }
00276
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

XPtr< T > Member List

This is the complete list of members for XPtr< T >, including all inherited members.
_p | XPtr< T > | [private]
Acquire() | XPtr< T > | [inline]
Acquire() | XPtr< T > | [inline]
Free() | XPtr< T > | [inline]
Free() | XPtr< T > | [inline]
Get() const | XPtr< T > | [inline]
Get() const | XPtr< T > | [inline]
IsNull() const | XPtr< T > | [inline]
IsNull() const | XPtr< T > | [inline]
operator[](unsigned i) | XPtr< T > | [inline]
operator[](unsigned i) const | XPtr< T > | [inline]
operator[](unsigned i) | XPtr< T > | [inline]
operator[](unsigned i) const | XPtr< T > | [inline]
Set(T *p) | XPtr< T > | [inline]
Set(T *p) | XPtr< T > | [inline]
SetSize(unsigned c) | XPtr< T > | [inline]
SetSize(unsigned c) | XPtr< T > | [inline]
XPtr(unsigned c=0) | XPtr< T > | [inline]
XPtr(T *p) | XPtr< T > | [inline]
XPtr(unsigned c) | XPtr< T > | [inline]
~XPtr() | XPtr< T > | [inline]
~XPtr() | XPtr< T > | [inline]
Generated on Wed Nov 13 2024 16:58:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptServe/CRUCAR.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptServe

CRUCAR.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CRUCAR.H
00003
00004   Summary:   Include file for the aggregatable COCruiseCar COM object class.
00005
00006              CRUCAR showcases the construction of the COCruiseCar COM
00007              object class with the IUnknown, ICar, and ICruise interfaces.
00008              This is done through Containment reuse of a COCar COM
00009              object (specifically providing its ICar interface features).
00010
00011              This multiple interface COM Object Class is achieved via
00012              the technique of nested classes: the implementation of the
00013              ICar and ICruise interfaces are nested inside of the
00014              COCruiseCar COM object class.
00015
00016              For a comprehensive tutorial code tour of this module's
00017              contents and offerings see the tutorial APTSERVE.HTM file.
00018              For more specific technical details on the internal workings
00019              see the comments dispersed throughout the module's source code.
00020
00021   Classes:   COCruiseCar.
00022
00023   Functions: .
00024
00025   Origin:    3-20-95: atrent - Editor-inheritance from CRUCAR.H in
00026                the LOCSERVE Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 #if !defined(CRUCAR_H)
00044 #define CRUCAR_H
00045
00046 #ifdef __cplusplus
00047
00048 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00049   ObjectClass: COCruiseCar
00050
00051   Summary:     COM Object Class for COCruiseCar COM Objects.  COM objects
00052                of this class augment COCar COM objects (which offer ICar
00053                interface features of Shift, Clutch, Speed, and Steer) with
00054                ICruise interface features (Engage and Adjust).  This
00055                COCruiseCar COM object class is constructed by containment
00056                reuse of the COCar COM object class.  The mulitple
00057                interfaces on this COM object class are constructed via
00058                the nested interface classes technique.
00059
00060   Interfaces:  IUnknown
00061                  Standard interface providing COM object features.
00062                ICar
00063                  Basic Car operation features.
00064                ICruise
00065                  Cruise control features.
00066
00067   Aggregation: Yes, COCruiseCar COM objects are aggregatable by passing
00068                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00069 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00070 class COCruiseCar : public IUnknown
00071 {
00072   public:
00073     // Main Object Constructor & Destructor.
00074     COCruiseCar(IUnknown* pUnkOuter, CServer* pServer);
00075     ~COCruiseCar(void);
00076
00077     // A general method for initializing a newly created COCruiseCar.
00078     HRESULT Init(void);
00079
00080     // IUnknown methods. Main object, non-delegating.
00081     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00082     STDMETHODIMP_(ULONG) AddRef(void);
00083     STDMETHODIMP_(ULONG) Release(void);
00084
00085     // We get this ICar interface pointer via containment reuse of the
00086     // ICar interface in an instantiated COCar.
00087     ICar*           m_pICar;
00088
00089   private:
00090     // We declare nested class interface implementations here.
00091
00092     // We implement the basic ICar interface in this COCruiseCar
00093     // COM object class.
00094     class CImpICar : public ICar
00095     {
00096       public:
00097         // Interface Implementation Constructor & Destructor.
00098         CImpICar(COCruiseCar* pBackObj, IUnknown* pUnkOuter);
00099         ~CImpICar(void);
00100
00101         // IUnknown methods.
00102         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00103         STDMETHODIMP_(ULONG) AddRef(void);
00104         STDMETHODIMP_(ULONG) Release(void);
00105
00106         // ICar methods.
00107         STDMETHODIMP Shift(short nGear);
00108         STDMETHODIMP Clutch(short nEngaged);
00109         STDMETHODIMP Speed(short nMph);
00110         STDMETHODIMP Steer(short nAngle);
00111
00112       private:
00113         // Data private to this COCruiseCar interface implementation of ICar.
00114         ULONG         m_cRefI;       // Interface Ref Count (for debugging).
00115         COCruiseCar*  m_pBackObj;    // Parent Object back pointer.
00116         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00117     };
00118
00119     // We implement the ICruise interface (ofcourse) in this COCruiseCar
00120     // COM object class.  This is the native interface that we are using
00121     // as an augmentation to the existing COCar COM object class.
00122     class CImpICruise : public ICruise
00123     {
00124       public:
00125         // Interface Implementation Constructor & Destructor.
00126         CImpICruise(COCruiseCar* pBackObj, IUnknown* pUnkOuter);
00127         ~CImpICruise(void);
00128
00129         // IUnknown methods.
00130         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00131         STDMETHODIMP_(ULONG) AddRef(void);
00132         STDMETHODIMP_(ULONG) Release(void);
00133
00134         // ICruise methods.
00135         STDMETHODIMP Engage(BOOL bOnOff);
00136         STDMETHODIMP Adjust(BOOL bUpDown);
00137
00138       private:
00139         // Data private to this interface implementation of ICruise.
00140         ULONG         m_cRefI;       // Interface Ref Count (for debugging).
00141         COCruiseCar*  m_pBackObj;    // Parent Object back pointer.
00142         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00143     };
00144
00145     // Make the otherwise private and nested ICar and ICruise interface
00146     // implementations a friend to COM object instantiations of this
00147     // selfsame COCruiseCar COM object class.
00148     friend CImpICar;
00149     friend CImpICruise;
00150
00151     // Private data of COCruiseCar COM objects.
00152
00153     // Nested ICar implementation instantiation.
00154     CImpICar        m_ImpICar;
00155
00156     // Nested ICruise implementation instantiation.  This ICruise interface
00157     // is implemented inside this COCruiseCar object as a native interface.
00158     CImpICruise     m_ImpICruise;
00159
00160     // Main Object reference count.
00161     ULONG           m_cRefs;
00162
00163     // Outer unknown (aggregation & delegation). Used when this COCruiseCar
00164     // object is being aggregated.  Otherwise it is used for delegation
00165     // if this object is reused via containment.
00166     IUnknown*       m_pUnkOuter;
00167
00168     // Pointer to this component server's control object.
00169     CServer*        m_pServer;
00170 };
00171
00172 typedef COCruiseCar* PCOCruiseCar;
00173
00174 #endif // __cplusplus
00175
00176
00177 #endif // CRUCAR_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/StdAfx.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification

StdAfx.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       StdAfx.cpp
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011 #include "stdafx.h"
00012
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/cdialog.h Source File

  • Web
  • bits
  • Upload

cdialog.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  cdialog.h
00011 //
00012 //  Purpose:
00013 //  Defines the class CSimpleDialog, used to instantiate and control
00014 //  the user interface.
00015 //
00016 //----------------------------------------------------------------------------
00017
00018 #pragma once
00019 #include <Windows.h>
00020
00021 #ifndef CALLBACK
00022 #define CALLBACK __stdcall
00023 #endif
00024
00025 //---------------------------------------------------------------------------
00026 class CSimpleDialog
00027 {
00028     HINSTANCE m_hInstance;
00029     HWND      m_hWnd;         // Handle from CreateDialogParam
00030     ULONG     m_ulDialogId;   // Dialog template ID
00031     DLGPROC   m_DlgProc;      // Points to Dialog Proc
00032
00033     static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00034
00035     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00036     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00037     LRESULT OnCancel( HWND hDlg, WPARAM wParam, LPARAM lParam );
00038     LRESULT OnNcDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam );
00039     LRESULT OnDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam );
00040     LRESULT OnClose( HWND hDlg, WPARAM wParam, LPARAM lParam );
00041
00042     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00043
00044     HRESULT CollectUserInput(
00045         IN OUT WCHAR *wszBuffVirtualDir,
00046         IN     DWORD  cchBuffVirtualDir,
00047         IN OUT WCHAR *wszBuffSampleText,
00048         IN     DWORD  cchBuffSampleText,
00049         OUT    BOOL  *fRequireUploadReply
00050     );
00051
00052   public:
00053     CSimpleDialog(HINSTANCE hInstance, ULONG ulDialogId);
00054     ~CSimpleDialog();
00055
00056     HRESULT Show(INT iShowState);
00057     HWND    GetHwnd();
00058     HRESULT AddStatusMessage(LPCWSTR wszFormat, ...);
00059 };
00060
00061
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/DbgMsg.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

DbgMsg.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Debugging Routines
00005
00006     FILE: DbgMsg.cpp
00007
00008     PURPOSE: Routines for debugging system services.
00009
00010 */
00011
00012 #include "common.h"
00013
00014 #include "DbgMsg.h"
00015 #include "Service.h"
00016
00017 // Handle to the debug log file.
00018 HANDLE hDbgMsgLog = NULL;
00019
00020 // Current size of the debug log.
00021 UINT nDbgMsgLogSize = 0;
00022
00023 CRITICAL_SECTION DbgMsgCriticalSection;
00024
00025 VOID DbgMsgOpenLog(LPTSTR LogFileName) {
00026
00027     // Init the critsec.
00028     if (InitializeCriticalSectionAndSpinCount(&DbgMsgCriticalSection, 0) == 0) {
00029         AddToMessageLogProcFailure(TEXT("DbgMsgOpenLog: InitializeCriticalSectionAndSpinCount"), GetLastError());
00030         return;
00031     }
00032
00033     // Open the profiling log.
00034     if ((hDbgMsgLog = CreateFile(LogFileName,
00035                                GENERIC_WRITE,
00036                                0,
00037                                NULL,
00038                                CREATE_ALWAYS,
00039                                FILE_ATTRIBUTE_NORMAL,
00040                                NULL)) == INVALID_HANDLE_VALUE) {
00041         AddToMessageLogProcFailure(TEXT("DbgMsgOpenLog: CreateFile"), GetLastError());
00042     }
00043 }
00044
00045 VOID DbgMsgRecord(LPTSTR msg) {
00046     ULONG cbWritten;
00047
00048     EnterCriticalSection(&DbgMsgCriticalSection);
00049
00050     // Write the entry only if there is enough space left in
00051     // the log.
00052     if (nDbgMsgLogSize < DEBUG_LOG_MAX_SIZE + _tcslen(msg)) {
00053
00054         // Append the entry to the log.
00055         nDbgMsgLogSize += _tcslen(msg);
00056         if(!WriteFile(hDbgMsgLog,
00057                       (LPVOID)msg,
00058                       _tcslen(msg)*sizeof(TCHAR),
00059                       &cbWritten,
00060                       NULL)) {
00061             AddToMessageLogProcFailure(TEXT("DbgMsgRecord: WriteFile"), GetLastError());
00062         }
00063     }
00064
00065     LeaveCriticalSection(&DbgMsgCriticalSection);
00066     return;
00067 }
00068
00069 VOID DbgMsgCloseLog(VOID) {
00070     DWORD status;
00071
00072     // Delete and the critsec.
00073     DeleteCriticalSection(&DbgMsgCriticalSection);
00074
00075     // Close the debug log.
00076     if (hDbgMsgLog != NULL && hDbgMsgLog != INVALID_HANDLE_VALUE) {
00077         status = CloseHandle(hDbgMsgLog);
00078         ASSERT(status);
00079     }
00080 }
00081
00082 // end DbgMsg.cpp
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAgentCtlAudioObject Member List

This is the complete list of members for CAgentCtlAudioObject, including all inherited members.
CAgentCtlAudioObject() | CAgentCtlAudioObject | [inline]
CAgentCtlAudioObject(LPDISPATCH pDispatch) | CAgentCtlAudioObject | [inline]
CAgentCtlAudioObject(const CAgentCtlAudioObject &dispatchSrc) | CAgentCtlAudioObject | [inline]
GetEnabled() | CAgentCtlAudioObject |
GetSoundEffects() | CAgentCtlAudioObject |
Generated on Wed Nov 13 2024 16:55:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/DRAWSINK.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

DRAWSINK.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DRAWSINK.H
00003
00004   Summary:   Include file for the CODrawPageSink COM object class.
00005
00006              CODrawPageSink offers a main IUnknown interface and the
00007              custom IDrawPageSink interface (outgoing connection events
00008              from CODrawPage DrawPage objects). This multiple interface
00009              COM Object Class is achieved via the technique of nested
00010              classes.  The implementation of the IDrawPageSink interface
00011              is nested inside of the CODrawPageSink Class.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial PERCLIEN.HTM
00015              file. For more specific technical details on the internal
00016              workings see the comments dispersed throughout the module's
00017              source code.
00018
00019   Functions: .
00020
00021   Classes:   CODrawPageSink.
00022
00023   Origin:    5-24-97: atrent - Editor-inheritance from TEXTSINK.H in the
00024              PERCLIEN Tutorial Code Sample.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(DRAWSINK_H)
00042 #define DRAWSINK_H
00043
00044 #ifdef __cplusplus
00045
00046
00047 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00048   ObjectClass: CODrawPageSink
00049
00050   Summary:     The main Sink COM object class for CODrawPageSink COM
00051                objects. COM objects of this class offer the IDrawPageSink
00052                sink interface supporting various DrawPage events. The
00053                mulitple interfaces on this COM object are constructed via
00054                the nested interface classes technique.
00055
00056   Interfaces:  IUnknown
00057                  Standard interface providing COM object features.
00058                IDrawPageSink
00059                  Sink interface for DrawPage events.
00060
00061   Aggregation: Yes, CODrawPageSink COM Objects are aggregatable by passing
00062                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00063 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00064 class CODrawPageSink : public IUnknown
00065 {
00066   public:
00067     // Main Object Constructor & Destructor.
00068     CODrawPageSink(IUnknown* pUnkOuter, CGuiDraw* pGuiDraw);
00069     ~CODrawPageSink(void);
00070
00071     // IUnknown methods. Main object, non-delegating.
00072     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00073     STDMETHODIMP_(ULONG) AddRef(void);
00074     STDMETHODIMP_(ULONG) Release(void);
00075
00076   private:
00077     // We declare nested class interface implementations here.
00078
00079     class CImpIDrawPageSink : public IDrawPageSink
00080     {
00081       public:
00082         // Interface Implementation Constructor & Destructor.
00083         CImpIDrawPageSink(CODrawPageSink* pCO, IUnknown* pUnkOuter);
00084         ~CImpIDrawPageSink(void);
00085
00086         // IUnknown methods.
00087         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00088         STDMETHODIMP_(ULONG) AddRef(void);
00089         STDMETHODIMP_(ULONG) Release(void);
00090
00091         // IDrawPageSink methods.
00092         STDMETHODIMP         Loaded(void);
00093         STDMETHODIMP         Saved(void);
00094         STDMETHODIMP         Cleared(void);
00095         STDMETHODIMP         Resized(SHORT nWidth, SHORT nHeight);
00096         STDMETHODIMP         InkStart(
00097                                SHORT nX,
00098                                SHORT nY,
00099                                SHORT nWidth,
00100                                COLORREF crInkColor);
00101         STDMETHODIMP         InkDraw(
00102                                SHORT nX,
00103                                SHORT nY);
00104         STDMETHODIMP         InkStop(
00105                                SHORT nX,
00106                                SHORT nY);
00107
00108       private:
00109         // Data private to this interface implementation of IDrawPage.
00110         CODrawPageSink*  m_pCO;          // Parent Object back pointer.
00111         IUnknown*        m_pUnkOuter;    // Outer unknown for Delegation.
00112     };
00113
00114     // Make the otherwise private and nested IDrawPageSink interface
00115     // implementation a friend to COM object instantiations of this
00116     // CODrawPageSink COM object class.
00117     friend CImpIDrawPageSink;
00118
00119     // Private data of CODrawPageSink COM objects.
00120
00121     // Nested IDrawPageSink implementation instantiation.  This
00122     // IDrawPageSink interface is instantiated inside this CODrawPageSink
00123     // object as a native interface.
00124     CImpIDrawPageSink    m_ImpIDrawPageSink;
00125
00126     // Main Object reference count.
00127     ULONG                m_cRefs;
00128
00129     // Outer unknown (aggregation delegation). Used when this COM object
00130     // is being aggregated.
00131     IUnknown*            m_pUnkOuter;
00132
00133     // Pointer to the main object that can service the Sink events.
00134     CGuiDraw*            m_pGuiDraw;
00135 };
00136
00137 #endif // __cplusplus
00138
00139
00140 #endif // DRAWSINK_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/NetMon/experts/blrplate/blrplate.cpp Source File

  • NetDS
  • NetMon
  • experts
  • blrplate

blrplate.cpp

Go to the documentation of this file.
00001 //============================================================================
00002 //  MODULE: BLRPLATE.cpp
00003 //
00004 //  Description:
00005 //
00006 //  BLRPLATE expert module
00007 //
00008 //  Modification History:
00009 //
00010 //  Your Name Here      01/01/70    Created
00011 //============================================================================
00012 #define STRICT 1
00013
00014 #include "BLRPLATE.h"
00015 #include "resrc1.h"
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Global Variables
00019 HINSTANCE g_hInstance;
00020
00021 char g_StatusString[MAX_PATH];
00022 char g_Col0Name[MAX_PATH];
00023 char g_Col1Name[MAX_PATH];
00024 char g_ExpertName[MAX_PATH];
00025 char g_EventName[MAX_PATH];
00026 char g_Justification[MAX_PATH];
00027
00028
00029 //////////////////////////////////////////////////////////////////////////////
00030 // The DLL entry point
00031 //
00032 BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
00033 {
00034     switch( ulReason )
00035     {
00036         case DLL_PROCESS_ATTACH:
00037             g_hInstance = hInstance;
00038             break;
00039
00040         case DLL_PROCESS_DETACH:
00041             break;
00042     }
00043     return TRUE;
00044 }
00045
00046 //////////////////////////////////////////////////////////////////////////////
00047 // The Expert Registration entry point
00048 //
00049 BOOL WINAPI Register( PEXPERTENUMINFO lpExpertInfo)
00050 {
00051     // fill in the expert info data structure
00052     // TODO: Choose the proper flags
00053     lpExpertInfo->Flags = EXPERT_ENUM_FLAG_VIEWER_PRIVATE |
00054                           EXPERT_ENUM_FLAG_CONFIGURABLE;
00055     lpExpertInfo->Version = 1;
00056     LoadString( g_hInstance, IDS_EXPERTNAME, lpExpertInfo->szName, MAX_PATH);
00057     LoadString( g_hInstance, IDS_COMMENT, lpExpertInfo->szDescription, MAX_PATH);
00058     LoadString( g_hInstance, IDS_AUTHOR, lpExpertInfo->szVendor, MAX_PATH);
00059     return TRUE;
00060 }
00061
00062 //////////////////////////////////////////////////////////////////////////////
00063 // The Expert Configuration entry point
00064 //
00065 BOOL WINAPI Configure( HEXPERTKEY hExpertKey,
00066                        PEXPERTCONFIG* ppConfig,
00067                        PEXPERTSTARTUPINFO pStartupInfo,
00068                        DWORD StartupFlags,
00069                        HWND hWnd )
00070 {
00071     // is the startup info from a right mouse click?
00072     if( (pStartupInfo == NULL) &&
00073         (StartupFlags & EXPERT_STARTUP_FLAG_USE_STARTUP_DATA_OVER_CONFIG_DATA) )
00074     {
00075         // The user started this expert by right mouse clicking...
00076
00077         // TODO: pull the relevant data out of the pStartupInfo
00078         // and put it in the (possibly resized) ppConfig
00079     }
00080
00081     // call the dialog
00082     return ConfigBLRPLATEDlg_Do(hWnd,
00083                                 (PBLRPLATECONFIG *)ppConfig,
00084                                 hExpertKey);
00085 }
00086
00087
00088 //////////////////////////////////////////////////////////////////////////////
00089 // The Expert Start entry point
00090 //
00091 BOOL WINAPI Run( HEXPERTKEY hExpertKey,
00092                  PEXPERTCONFIG lpConfig,
00093                  PEXPERTSTARTUPINFO pStartupInfo,
00094                  DWORD StartupFlags,
00095                  HWND hwnd)
00096 {
00097     DWORD                   rc;
00098     EXPERTSTATUS            Status;
00099
00100     HFILTER                 hFilter;
00101     FILTEROBJECT2            FilterObj;
00102
00103     PBLRPLATECONFIG         pBLRPLATEConfig = (PBLRPLATECONFIG)lpConfig;
00104
00105     PNMEVENTDATA            pEvent;
00106
00107     DWORD                   TotalFrames;
00108     DWORD                   CurrentFrameNumber;
00109     BYTE                    CurrentPercentDone;
00110     BYTE                    ReportedPercentDone;
00111
00112     EXPERTFRAMEDESCRIPTOR   FrameDescriptor;
00113
00114     // -----------------------------------------------------------------------
00115     // Zero out all of our stack data structures
00116     memset( &Status, 0, sizeof(EXPERTSTATUS) );
00117     memset( &FilterObj, 0, sizeof(FILTEROBJECT) );
00118     memset( &FrameDescriptor, 0, sizeof(EXPERTFRAMEDESCRIPTOR) );
00119
00120
00121     // -----------------------------------------------------------------------
00122     // Set up our status structure and tell the world that we are initializing
00123     Status.Frame       = 0;
00124     Status.PercentDone = 0;
00125     Status.Status      = EXPERTSTATUS_STARTING;
00126     Status.SubStatus   = 0;
00127     LoadString(g_hInstance, IDS_INITIALIZING, Status.szStatusText, MAX_PATH);
00128     rc = ExpertIndicateStatus(hExpertKey,
00129                               Status.Status,
00130                               Status.SubStatus,
00131                               Status.szStatusText,
00132                               Status.PercentDone);
00133     if( rc == NMERR_EXPERT_TERMINATE )
00134     {
00135         // we have been asked to terminate
00136         return TRUE;
00137     }
00138     else if( rc != NMERR_SUCCESS )
00139     {
00140         // something bad happened
00141         return FALSE;
00142     }
00143
00144
00145     // -----------------------------------------------------------------------
00146     // prefill the event
00147     // TODO: the 2s below should be mondified to reflect the desired event
00148     // TODO: this code needs to be copied for any extra types of events
00149     pEvent = (PNMEVENTDATA)ExpertAllocMemory( hExpertKey,
00150                                               sizeof(NMEVENTDATA) +
00151                                               2 * sizeof(NMCOLUMNINFO),
00152                                               &rc);
00153     if( pEvent == NULL )
00154     {
00155         LoadString(g_hInstance, IDS_CANTALLOCMEM, g_StatusString, MAX_PATH);
00156         ExpertIndicateStatus( hExpertKey,
00157                               EXPERTSTATUS_PROBLEM,
00158                               0,
00159                               g_StatusString,
00160                               0);
00161         return FALSE;
00162     }
00163
00164     pEvent->Version      = 0;
00165     pEvent->EventIdent   = 1;
00166     pEvent->Flags        = NMEVENTFLAG_DO_NOT_DISPLAY_MACHINE;
00167     pEvent->Severity     = NMEVENT_SEVERITY_INFORMATIONAL;
00168     pEvent->NumColumns   = 2;
00169     memset( &(pEvent->SysTime), 0, sizeof(SYSTEMTIME));
00170     pEvent->Justification= g_Justification;
00171     LoadString(g_hInstance, IDS_EXPERTNAME, g_ExpertName, MAX_PATH);
00172     pEvent->szSourceName = g_ExpertName;
00173     LoadString(g_hInstance, IDS_EVENTNAME, g_EventName, MAX_PATH);
00174     pEvent->szEventName  = g_EventName;
00175 //    pEvent->szUrl        = NULL;
00176     pEvent->szDescription= NULL;
00177     pEvent->szMachine    = NULL;
00178
00179     LoadString(g_hInstance, IDS_COLZERO, g_Col0Name, MAX_PATH);
00180     pEvent->Column[0].szColumnName = g_Col0Name;
00181     pEvent->Column[0].VariantData.Type = NMCOLUMNTYPE_IPADDR;
00182     LoadString(g_hInstance, IDS_COLONE, g_Col1Name, MAX_PATH);
00183     pEvent->Column[1].szColumnName = g_Col1Name;
00184     pEvent->Column[1].VariantData.Type = NMCOLUMNTYPE_IPADDR;
00185
00186     // ------------------------------------------------------------------------
00187     // create a filter which will only find frames which we are interested in
00188     hFilter = CreateFilter();
00189     if( hFilter == NULL )
00190     {
00191         // can't make filter
00192         LoadString(g_hInstance, IDS_CANTCREATEFILTER, g_StatusString, MAX_PATH);
00193         ExpertIndicateStatus( hExpertKey,
00194                               EXPERTSTATUS_PROBLEM,
00195                               0,
00196                               g_StatusString,
00197                               0);
00198         return FALSE;
00199     }
00200
00201     // TODO: Fill the filter
00202     // This example returns only frames which contain TCP
00203     FilterObj.Action = FILTERACTION_PROTOCOLEXIST;
00204     FilterObj.hProtocol = GetProtocolFromName( "TCP" );
00205     rc = FilterAddObject( hFilter, &FilterObj);
00206     if( rc != NMERR_SUCCESS )
00207     {
00208         // can't add to the filter
00209         LoadString(g_hInstance, IDS_CANTADDTOFILTER, g_StatusString, MAX_PATH);
00210         ExpertIndicateStatus( hExpertKey,
00211                               EXPERTSTATUS_PROBLEM,
00212                               0,
00213                               g_StatusString,
00214                               0);
00215         DestroyFilter( hFilter);
00216         return FALSE;
00217     }
00218
00219     // -----------------------------------------------------------------------
00220     // send the first status message which will indicate that we are now running
00221     rc = ExpertIndicateStatus( hExpertKey,
00222                                EXPERTSTATUS_RUNNING,
00223                                0,
00224                                "",
00225                                0);
00226     if( rc == NMERR_EXPERT_TERMINATE )
00227     {
00228         // we were terminated
00229         DestroyFilter( hFilter );
00230         return FALSE;
00231     }
00232
00233     // -----------------------------------------------------------------------
00234     // the main loop
00235     TotalFrames = GetCaptureTotalFrames( pStartupInfo->hCapture);
00236     CurrentFrameNumber = -1;
00237     do
00238     {
00239         // get the next frame which passes both the user's filter and ours
00240         rc = ExpertGetFrame( hExpertKey,
00241                              GET_FRAME_NEXT_FORWARD,
00242                              ( FLAGS_DEFER_TO_UI_FILTER |
00243                                FLAGS_ATTACH_PROPERTIES ),
00244                              CurrentFrameNumber,
00245                              hFilter,
00246                              &FrameDescriptor);
00247         if( rc == NMERR_EXPERT_TERMINATE )
00248         {
00249             // we were terminated
00250             DestroyFilter( hFilter );
00251             return FALSE;
00252         }
00253         if( rc != NMERR_SUCCESS )
00254         {
00255             // we failed to get a frame, break out of the loop
00256             break;
00257         }
00258
00259         // got a frame, which one?
00260         CurrentFrameNumber = FrameDescriptor.FrameNumber;
00261
00262         // update our status if we need to
00263         CurrentPercentDone = (BYTE)((CurrentFrameNumber*100)
00264                                          /TotalFrames);
00265         if( CurrentPercentDone > ReportedPercentDone )
00266         {
00267             // new number
00268             rc = ExpertIndicateStatus( hExpertKey,
00269                                          EXPERTSTATUS_RUNNING,
00270                                          0,
00271                                          "",
00272                                          CurrentPercentDone);
00273             ReportedPercentDone = CurrentPercentDone;
00274             if( rc == NMERR_EXPERT_TERMINATE )
00275             {
00276                 // we were terminated
00277                 DestroyFilter( hFilter );
00278                 return FALSE;
00279             }
00280         }
00281
00282         // TODO: This is were the expert actually uses the frame
00283         // returned by either sending an event or recording information
00284         // for a summary type event later.
00285
00286     } while( rc == NMERR_SUCCESS );
00287
00288     // -----------------------------------------------------------------------
00289     // TODO: submit summary type events here
00290
00291     // -----------------------------------------------------------------------
00292     // we are done
00293     DestroyFilter( hFilter );
00294     return rc;
00295 }
00296
00297
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/statnode.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

statnode.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "StatNode.h"
00021
00022 #include "Space.h"
00023 #include "Sky.h"
00024 #include "People.h"
00025 #include "Land.h"
00026
00027 const GUID CStaticNode::thisGuid = { 0xc094012c, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
00028
00029 //==============================================================
00030 //
00031 // CStaticNode implementation
00032 //
00033 //
00034 CStaticNode::CStaticNode()
00035 {
00036     children[0] = new CPeoplePoweredVehicle;
00037     children[1] = new CLandBasedVehicle;
00038     children[2] = new CSkyBasedVehicle;
00039     children[3] = new CSpaceVehicle;
00040 }
00041
00042 CStaticNode::~CStaticNode()
00043 {
00044     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00045         if (children[n]) {
00046             delete children[n];
00047         }
00048 }
00049
00050 HRESULT CStaticNode::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00051 {
00052
00053     //cache static node's HSCOPEITEM for future use
00054     m_hParentHScopeItem = parent;
00055
00056     SCOPEDATAITEM sdi;
00057
00058     if (!bExpanded) {
00059         // create the child nodes, then expand them
00060         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00061             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00062             sdi.mask = SDI_STR       |   // Displayname is valid
00063                 SDI_PARAM     |   // lParam is valid
00064                 SDI_IMAGE     |   // nImage is valid
00065                 SDI_OPENIMAGE |   // nOpenImage is valid
00066                 SDI_PARENT    |
00067                 SDI_CHILDREN;
00068
00069             sdi.relativeID  = (HSCOPEITEM)parent;
00070             sdi.nImage      = children[n]->GetBitmapIndex();
00071             sdi.nOpenImage  = INDEX_OPENFOLDER;
00072             sdi.displayname = MMC_CALLBACK;
00073             sdi.lParam      = (LPARAM)children[n];       // The cookie
00074             sdi.cChildren   = (n == 0); // only the first child has children
00075
00076             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00077             _ASSERT( SUCCEEDED(hr) );
00078
00079             children[n]->SetScopeItemValue(sdi.ID);
00080
00081
00082         }
00083     }
00084
00085     return S_OK;
00086 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

AgentNotifySink Member List

This is the complete list of members for AgentNotifySink, including all inherited members.
ActivateInputState(long dwCharID, long bActivated) | AgentNotifySink |
ActivateInputState(long dwCharID, long bActivated) | AgentNotifySink |
ActivateInputState(long dwCharID, long bActivated) | AgentNotifySink |
ActiveClientChange(long dwCharID, long bActive) | AgentNotifySink |
ActiveClientChange(long dwCharID, long lStatus) | AgentNotifySink |
ActiveClientChange(long dwCharID, long lStatus) | AgentNotifySink |
AgentNotifySink(MainDlg *pMainDlg) | AgentNotifySink | [inline]
AgentNotifySink() | AgentNotifySink | [inline]
AgentNotifySink() | AgentNotifySink | [inline]
AgentPropertyChange() | AgentNotifySink |
AgentPropertyChange() | AgentNotifySink |
AgentPropertyChange() | AgentNotifySink |
BalloonVisibleState(long dwCharID, long bVisible) | AgentNotifySink |
BalloonVisibleState(long dwCharID, long bVisible) | AgentNotifySink |
BalloonVisibleState(long dwCharID, long bVisible) | AgentNotifySink |
BookMark(long dwBookMarkID) | AgentNotifySink |
BookMark(long dwBookMarkID) | AgentNotifySink |
BookMark(long dwBookMarkID) | AgentNotifySink |
Click(long dwCharID, short fwKeys, long x, long y) | AgentNotifySink |
Click(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
Click(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
Command(long dwCommandID, IUnknown *punkUserInput) | AgentNotifySink |
Command(long dwCommandID, IUnknown *punkUserInput) | AgentNotifySink |
Command(long dwCommandID, IUnknown *punkUserInput) | AgentNotifySink |
DblClick(long dwCharID, short fwKeys, long x, long y) | AgentNotifySink |
DblClick(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
DblClick(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
DefaultCharacterChange(BSTR bszGUID) | AgentNotifySink |
DefaultCharacterChange(BSTR bszGUID) | AgentNotifySink |
DefaultCharacterChange(BSTR bszGUID) | AgentNotifySink |
DragComplete(long dwCharID, short fwKeys, long x, long y) | AgentNotifySink |
DragComplete(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
DragComplete(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
DragStart(long dwCharID, short fwKeys, long x, long y) | AgentNotifySink |
DragStart(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
DragStart(long dwCharID, short fwKeys, long X, long Y) | AgentNotifySink |
GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID, DISPID *) | AgentNotifySink |
GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID, DISPID *) | AgentNotifySink |
GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID, DISPID *) | AgentNotifySink |
GetTypeInfo(UINT, LCID, ITypeInfo **) | AgentNotifySink |
GetTypeInfo(UINT, LCID, ITypeInfo **) | AgentNotifySink |
GetTypeInfo(UINT, LCID, ITypeInfo **) | AgentNotifySink |
GetTypeInfoCount(UINT *) | AgentNotifySink |
GetTypeInfoCount(UINT *) | AgentNotifySink |
GetTypeInfoCount(UINT *) | AgentNotifySink |
HelpComplete(long dwCharID, long dwCommandID, long dwCause) | AgentNotifySink |
HelpComplete(long dwCharID, long dwCommandID, long dwCause) | AgentNotifySink |
HelpComplete(long dwCharID, long dwCommandID, long dwCause) | AgentNotifySink |
Idle(long dwCharID, long bStart) | AgentNotifySink |
Idle(long dwCharID, long bStart) | AgentNotifySink |
Idle(long dwCharID, long bStart) | AgentNotifySink |
Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) | AgentNotifySink |
Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) | AgentNotifySink |
Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) | AgentNotifySink |
ListeningState(long dwCharID, long bListening, long dwCause) | AgentNotifySink |
ListeningState(long dwCharacterID, long bListenState, long dwCause) | AgentNotifySink |
ListeningState(long dwCharacterID, long bListenState, long dwCause) | AgentNotifySink |
m_cRefs | AgentNotifySink | [private]
m_pMainDlg | AgentNotifySink | [private]
Move(long dwCharID, long x, long y, long lCause) | AgentNotifySink |
Move(long dwCharID, long X, long Y, long lCause) | AgentNotifySink |
Move(long dwCharID, long X, long Y, long lCause) | AgentNotifySink |
QueryInterface(REFIID, LPVOID FAR *) | AgentNotifySink |
QueryInterface(REFIID, LPVOID FAR *) | AgentNotifySink |
QueryInterface(REFIID, LPVOID FAR *) | AgentNotifySink |
RequestComplete(long dwRequestID, long hrStatus) | AgentNotifySink |
RequestComplete(long dwRequestID, long hrStatus) | AgentNotifySink |
RequestComplete(long dwRequestID, long hrStatus) | AgentNotifySink |
RequestStart(long dwRequestID) | AgentNotifySink |
RequestStart(long dwRequestID) | AgentNotifySink |
RequestStart(long dwRequestID) | AgentNotifySink |
Restart() | AgentNotifySink |
Restart() | AgentNotifySink |
Restart() | AgentNotifySink |
Shutdown() | AgentNotifySink |
Shutdown() | AgentNotifySink |
Shutdown() | AgentNotifySink |
Size(long dwCharID, long lWidth, long lHeight) | AgentNotifySink |
Size(long dwCharID, long lWidth, long lHeight) | AgentNotifySink |
Size(long dwCharID, long lWidth, long lHeight) | AgentNotifySink |
STDMETHODIMP_(ULONG) AddRef() | AgentNotifySink |
STDMETHODIMP_(ULONG) Release() | AgentNotifySink |
STDMETHODIMP_(ULONG) AddRef() | AgentNotifySink |
STDMETHODIMP_(ULONG) Release() | AgentNotifySink |
STDMETHODIMP_(ULONG) AddRef() | AgentNotifySink |
STDMETHODIMP_(ULONG) Release() | AgentNotifySink |
Suspend() | AgentNotifySink |
VisibleState(long dwCharID, long bVisible, long lCause) | AgentNotifySink |
VisibleState(long dwCharID, long bVisible, long lCause) | AgentNotifySink |
VisibleState(long dwCharID, long bVisible, long lCause) | AgentNotifySink |
~AgentNotifySink() | AgentNotifySink | [inline]
~AgentNotifySink() | AgentNotifySink | [inline]
~AgentNotifySink() | AgentNotifySink | [inline]
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/spy.h Source File

  • Dataaccess
  • oledb
  • tablecopy

spy.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module SPY.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _SPY_H_
00012 #define _SPY_H_
00013
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 /////////////////////////////////////////////////////////////////////////////
00019 #include "objidl.h" //IMallocSpy
00020 #include "Common.h" //ASSERT
00021 #include "List.h"   //CList
00022
00023
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // CMallocSpy
00027 //
00028 /////////////////////////////////////////////////////////////////////////////
00029 class CMallocSpy : public IMallocSpy
00030 {
00031 public:
00032     CMallocSpy(void);
00033   virtual ~CMallocSpy(void);
00034
00035   //Interface
00036   virtual HRESULT AddToList(void* pv);
00037   virtual HRESULT RemoveFromList(void* pv);
00038   virtual HRESULT DumpLeaks();
00039
00040     // IUnknown methods
00041     virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppIUnknown);
00042     virtual STDMETHODIMP_(ULONG) AddRef();
00043     virtual STDMETHODIMP_(ULONG) Release();
00044
00045   // IMallocSpy methods
00046
00047     //Alloc
00048   virtual STDMETHODIMP_(ULONG) PreAlloc(ULONG cbRequest);
00049     virtual STDMETHODIMP_(void*) PostAlloc(void *pActual);
00050
00051     //Free
00052   virtual STDMETHODIMP_(void*) PreFree(void *pRequest, BOOL fSpyed);
00053     virtual STDMETHODIMP_(void ) PostFree(BOOL fSpyed);
00054
00055     //Realloc
00056   virtual STDMETHODIMP_(ULONG) PreRealloc(void *pRequest, ULONG cbRequest, void **ppNewRequest, BOOL fSpyed);
00057     virtual STDMETHODIMP_(void*) PostRealloc(void *pActual, BOOL fSpyed);
00058
00059     //GetSize
00060   virtual STDMETHODIMP_(void*) PreGetSize(void *pRequest, BOOL fSpyed);
00061     virtual STDMETHODIMP_(ULONG) PostGetSize(ULONG cbActual, BOOL fSpyed);
00062
00063     //DidAlloc
00064   virtual STDMETHODIMP_(void*) PreDidAlloc(void *pRequest, BOOL fSpyed);
00065     virtual STDMETHODIMP_(BOOL)  PostDidAlloc(void *pRequest, BOOL fSpyed, BOOL fActual);
00066
00067     //HeapMinimize
00068   virtual STDMETHODIMP_(void ) PreHeapMinimize();
00069     virtual STDMETHODIMP_(void ) PostHeapMinimize();
00070
00071
00072 private:
00073     ULONG    m_cRef;      //Reference count
00074     ULONG    m_cbRequest;   //Bytes requested
00075
00076   CList<void*> CAllocList;  //List to keep track of leaks
00077 };
00078
00079 /////////////////////////////////////////////////////////////////////////////
00080 // Registration
00081 //
00082 /////////////////////////////////////////////////////////////////////////////
00083 HRESULT MallocSpyRegister(CMallocSpy** ppCMallocSpy);
00084 HRESULT MallocSpyUnRegister(CMallocSpy* pCMallocSpy);
00085 HRESULT MallocSpyDump(CMallocSpy* pCMallocSpy);
00086
00087
00088 #endif // _SPY_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/WinCap.h Source File

  • Multimedia
  • Gdi
  • WinCap32

WinCap.h

Go to the documentation of this file.
00001 /*    PortTool v2.2     wincap.h          */
00002
00003 /* Header file for wincap.c */
00004 /* Copyright 1991 - 2000 Microsoft Corporation. All rights reserved. */
00005
00006 //
00007 // constants for menu items
00008 //
00009
00010
00011 #define IDM_SAVE            110
00012 #define IDM_PRINT           120
00013 #define IDM_EXIT            130
00014 #define IDM_ABOUT           140
00015 #define IDM_EDITCOPY        180
00016 #define IDM_CAPTWINDOW      210
00017 #define IDM_CAPTCLIENT      220
00018 #define IDM_CAPTRECT        230
00019 #define IDM_CAPTUREHIDE     240
00020 #define IDM_ACTIVEWINDOW    250
00021 #define IDM_DESKTOP         260
00022 #define IDM_VIEWFULL        310
00023 #define IDM_VIEWRESTORED    320
00024 #define IDM_VIEWCLEAR       330
00025 #define IDM_CURSORSELECT    340
00026 #define IDM_SELECTRECT      350
00027
00028
00029 // Constants for string table
00030
00031 #define IDS_SAVEASTITLE      1
00032
00033
00034
00035 #define OPTION_FILE        0x0001
00036 #define OPTION_PRINTER     0x0002
00037
00038 // For common dialog file/save
00039
00040 #define IDD_FILETYPE        101
00041 #define IDD_RGB             102
00042 #define IDD_RLE4            103
00043 #define IDD_RLE8            104
00044 #define IDD_PM              105
00045 #define IDD_1               106
00046 #define IDD_4               107
00047 #define IDD_8               108
00048 #define IDD_24              109
00049 #define IDD_FILETYPEGROUP   110
00050 #define IDD_BPP             111
00051
00052 // Stuff for "File.Print" dialog
00053
00054 typedef struct tagOPTIONS {
00055     int iOption;       // Print Options
00056     int iXScale;       // X scale factor (if iOption is DLGPRINT_SCALE)
00057     int iYScale;       // Y scale factor ('')
00058     } OPTIONSTRUCT, *LPOPTIONSTRUCT;
00059
00060 /*
00061  * function prototypes
00062  */
00063
00064 void cwCenter(HWND, int);
00065 LONG WINAPI WndProc(HWND, UINT, WPARAM, LPARAM);
00066 LRESULT APIENTRY PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
00067 LRESULT APIENTRY AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
00068 int WINAPI InstallHook (HWND hWnd, BOOL bCode );
00069 BOOL WINAPI HelpDlgProc(HWND, UINT, WPARAM, LPARAM);
00070 LRESULT APIENTRY SavingDlgProc(HWND, UINT, WPARAM, LPARAM);
00071 BOOL GetFileName (HWND hWndOwner, LPSTR szFileName, PDWORD_PTR dwFlags);
00072 void DrawIndent(HWND hDlg, int ID, int iType);
00073 void StretchIconToWindow(HWND hWndDlg, LPSTR szIconName);
00074 void DoCapture(HWND hWnd, WORD wCommand);
00075 void RubberBandScreen(LPRECT lpRect);
00076 void DrawSelect( HDC hdc, BOOL fDraw, LPRECT lprClip);
00077 void WINAPI NormalizeRect (LPRECT prc);
00078 LONG APIENTRY FullViewWndProc(HWND, UINT, WPARAM, LPARAM);
00079 void SaveMe(void);
00080 void PrintMe(void);
00081 void DoSize(HWND);
00082 void ReallyGetClientRect(HWND, LPRECT);
00083 void SetupScrollBars(HWND, WORD, WORD);
00084 void DoScroll(HWND, int, int, int);
00085 void DoPaint(HWND);
00086 LRESULT CALLBACK SelectDlgProc(HWND, UINT, WPARAM, LPARAM);
00087 LRESULT CALLBACK RectangleDlgProc(HWND, UINT, WPARAM, LPARAM);
00088 void FrameWindow(HWND);
00089 BOOL CenterWindow (HWND hwndChild, HWND hwndParent);
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPageFormat Member List

This is the complete list of members for CPageFormat, including all inherited members.
_fontChar | CBlockFormat |
_fontCode | CBlockFormat |
_fontHeader | CFrameFormat |
_fontLabel | CFrameFormat |
_fontPageNum | CPageFormat |
_fuFormat | CPageFormat |
_pt | CPageFormat |
_ptPE | CPageFormat |
_size | CBlockFormat |
CBlockFormat() | CBlockFormat | [protected]
CFrameFormat() | CFrameFormat | [protected]
CPageFormat(UINT fuFormat) | CPageFormat |
SetFormat(UINT fuFormat=HEXADECIMAL) | CPageFormat |
Generated on Wed Nov 13 2024 16:57:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/Iconpro/Dib.h Source File

  • WinUI
  • Resource
  • Iconpro

Dib.h

Go to the documentation of this file.
00001 /****************************************************************************\
00002 *
00003 *     FILE:     DIB.H
00004 *
00005 *     PURPOSE:  IconPro Project DIB handling header file
00006 *
00007 *     COMMENTS: Icons are stored in something almost identical to DIB
00008 *               format, which makes it real easy to treat them as DIBs
00009 *               when manipulating them.
00010 *
00011 *     Copyright 1995 - 2000 Microsoft Corp.
00012 *
00013 *
00014 * History:
00015 *                July '95 - Created
00016 *
00017 \****************************************************************************/
00018
00019
00020 /****************************************************************************/
00021 // local #defines
00022
00023 // How wide, in bytes, would this many bits be, DWORD aligned?
00024 #define WIDTHBYTES(bits)      ((((bits) + 31)>>5)<<2)
00025 /****************************************************************************/
00026
00027
00028 /****************************************************************************/
00029 // Exported function prototypes
00030 PSTR FindDIBBits ( PSTR pbi );
00031 WORD DIBNumColors ( PSTR pbi );
00032 WORD PaletteSize ( PSTR pbi );
00033 DWORD BytesPerLine ( PBITMAPINFOHEADER pBMIH );
00034 PBYTE ConvertDIBFormat ( PBITMAPINFO pSrcDIB, UINT nWidth, UINT nHeight, UINT nColors, BOOL bStretch );
00035 VOID SetMonoDIBPixel ( PBYTE pANDBits, DWORD dwWidth, DWORD dwHeight, DWORD x, DWORD y, BOOL bWhite );
00036 PBYTE ReadBMPFile ( PCTSTR szFileName );
00037 BOOL WriteBMPFile ( PCTSTR szFileName, PBYTE lpDIB );
00038 /****************************************************************************/
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/UserEvents/VCAcct/CAccount.h Source File

  • Com
  • Services
  • Events
  • UserEvents
  • VCAcct

CAccount.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: CAccount.h
00003 //
00004 // Description: Declaration of CAccount
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022 #include "resource.h"       // main symbols
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // Account
00026
00027 class CAccount :
00028   public IDispatchImpl<IAccount, &IID_IAccount, &LIBID_ACCOUNT>,
00029   public ISupportErrorInfo,
00030   public CComObjectRoot,
00031   public CComCoClass<CAccount,&CLSID_CAccount>
00032 {
00033 public:
00034   CAccount() { d_acctBalance = 0L; }
00035 BEGIN_COM_MAP(CAccount)
00036   COM_INTERFACE_ENTRY(IDispatch)
00037   COM_INTERFACE_ENTRY(IAccount)
00038   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00039 END_COM_MAP()
00040 //DECLARE_NOT_AGGREGATABLE(CAccount)
00041 // Remove the comment from the line above if you don't want your object to
00042 // support aggregation.  The default is to support it
00043
00044 DECLARE_REGISTRY_RESOURCEID(IDR_Account)
00045 // ISupportsErrorInfo
00046   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00047
00048 // IAccount
00049 public:
00050   STDMETHOD(Post)(
00051     IN long lAccount,
00052     IN long lAmount,
00053     OUT BSTR* pbstrResult);
00054
00055 private:
00056   long d_acctBalance;
00057 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/iphdrinc/resolve.c Source File

  • NetDS
  • WinSock
  • iphdrinc

resolve.c

Go to the documentation of this file.
00001 //
00002 // Common routines for resolving addresses and hostnames
00003 //
00004 // Files:
00005 //      resolve.c       - Common routines
00006 //      resolve.h       - Header file for common routines
00007 //
00008 // Description:
00009 //      This file contains common name resolution and name printing
00010 //      functions.
00011 //
00012 // NOTE:
00013 //    From Network Programming for Microsoft Windows, Second Edition
00014 //    by Anthony Jones and James Ohlund.  Copyright 2002.
00015 //    Reproduced by permission of Microsoft Press.  All rights reserved.
00016 //
00017 #include <winsock2.h>
00018 #include <ws2tcpip.h>
00019
00020 // This sample uses the new getaddrinfo/getnameinfo functions which are new to
00021 // Windows XP. To run this sample on older OSes, include the following header
00022 // file which makes it work automagically.
00023 #include <wspiapi.h>
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027
00028 #include "resolve.h"
00029
00030 //
00031 // Function: PrintAddress
00032 //
00033 // Description:
00034 //    This routine takes a SOCKADDR structure and its lenght and prints
00035 //    converts it to a string representation. This string is printed
00036 //    to the console via stdout.
00037 //
00038 int PrintAddress(SOCKADDR *sa, int salen)
00039 {
00040     char    host[NI_MAXHOST],
00041             serv[NI_MAXSERV];
00042     int     hostlen = NI_MAXHOST,
00043             servlen = NI_MAXSERV,
00044             rc;
00045
00046     // Validate argument
00047     if (sa == NULL)
00048         return WSAEFAULT;
00049
00050     rc = getnameinfo(
00051             sa,
00052             salen,
00053             host,
00054             hostlen,
00055             serv,
00056             servlen,
00057             NI_NUMERICHOST | NI_NUMERICSERV
00058             );
00059     if (rc != 0)
00060     {
00061         fprintf(stderr, "%s: getnameinfo failed: %d\n", __FILE__, rc);
00062         return rc;
00063     }
00064
00065     // If the port is zero then don't print it
00066     if (strncmp(serv, "0", 1) != 0)
00067     {
00068         if (sa->sa_family == AF_INET6)
00069             printf("[%s]:%s", host, serv);
00070         else
00071             printf("%s:%s", host, serv);
00072     }
00073     else
00074         printf("%s", host);
00075
00076     return NO_ERROR;
00077 }
00078
00079 //
00080 // Function: FormatAddress
00081 //
00082 // Description:
00083 //    This is similar to the PrintAddress function except that instead of
00084 //    printing the string address to the console, it is formatted into
00085 //    the supplied string buffer.
00086 //
00087 int FormatAddress(SOCKADDR *sa, int salen, char *addrbuf, int addrbuflen)
00088 {
00089     char    host[NI_MAXHOST],
00090             serv[NI_MAXSERV];
00091     int     hostlen = NI_MAXHOST,
00092             servlen = NI_MAXSERV,
00093             rc;
00094
00095     // Validate input
00096     if ((sa == NULL) || (addrbuf == NULL))
00097         return WSAEFAULT;
00098
00099     // Format the name
00100     rc = getnameinfo(
00101             sa,
00102             salen,
00103             host,
00104             hostlen,
00105             serv,
00106             servlen,
00107             NI_NUMERICHOST | NI_NUMERICSERV     // Convert to numeric representation
00108             );
00109     if (rc != 0)
00110     {
00111         fprintf(stderr, "%s: getnameinfo failed: %d\n", __FILE__, rc);
00112         return rc;
00113     }
00114     if ( (strlen(host) + strlen(serv) + 1) > (unsigned)addrbuflen)
00115         return WSAEFAULT;
00116     if (strncmp(serv, "0", 1) != 0)
00117     {
00118         if (sa->sa_family == AF_INET)
00119             _snprintf(addrbuf, addrbuflen-1, "%s:%s", host, serv);
00120         else if (sa->sa_family == AF_INET6)
00121             _snprintf(addrbuf, addrbuflen-1, "[%s]:%s", host, serv);
00122         else
00123             addrbuf[0] = '\0';
00124     }
00125     else
00126     {
00127         _snprintf(addrbuf, addrbuflen-1, "%s", host);
00128     }
00129
00130     return NO_ERROR;
00131 }
00132
00133 //
00134 // Function: ResolveAddress
00135 //
00136 // Description:
00137 //    This routine resolves the specified address and returns a list of addrinfo
00138 //    structure containing SOCKADDR structures representing the resolved addresses.
00139 //    Note that if 'addr' is non-NULL, then getaddrinfo will resolve it whether
00140 //    it is a string listeral address or a hostname.
00141 //
00142 struct addrinfo *ResolveAddress(char *addr, char *port, int af, int type, int proto)
00143 {
00144     struct addrinfo hints,
00145     *res = NULL;
00146     int             rc;
00147
00148     memset(&hints, 0, sizeof(hints));
00149     hints.ai_flags  = ((addr) ? 0 : AI_PASSIVE);
00150     hints.ai_family = af; //((addr) ? AF_UNSPEC : af);
00151     hints.ai_socktype = type;
00152     hints.ai_protocol = proto;
00153
00154     rc = getaddrinfo(
00155             addr,
00156             port,
00157            &hints,
00158            &res
00159             );
00160     if (rc != 0)
00161     {
00162         printf("Invalid address %s, getaddrinfo failed: %d\n", addr, rc);
00163         return NULL;
00164     }
00165     return res;
00166 }
00167
00168 //
00169 // Function: ReverseLookup
00170 //
00171 // Description:
00172 //    This routine takes a SOCKADDR and does a reverse lookup for the name
00173 //    corresponding to that address.
00174 //
00175 int ReverseLookup(SOCKADDR *sa, int salen, char *buf, int buflen)
00176 {
00177     char    host[NI_MAXHOST];
00178     int     hostlen=NI_MAXHOST,
00179             rc;
00180
00181     // Validate parameters
00182     if ((sa == NULL) || (buf == NULL))
00183         return WSAEFAULT;
00184
00185     rc = getnameinfo(
00186             sa,
00187             salen,
00188             host,
00189             hostlen,
00190             NULL,
00191             0,
00192             0
00193             );
00194     if (rc != 0)
00195     {
00196         fprintf(stderr, "getnameinfo failed: %d\n", rc);
00197         return rc;
00198     }
00199
00200     strncpy(buf, host, buflen-1);
00201
00202     return NO_ERROR;
00203 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CChannelNotify Member List

This is the complete list of members for CChannelNotify, including all inherited members.
AddRef(void) | CChannelNotify |
RefCount::AddRef(void) | RefCount |
CChannelNotify() | CChannelNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
Connect(IUnknown *pUnk) | CChannelNotify |
CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Disconnect(void) | CChannelNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CChannelNotify |
NmUI(CONFN uNotify) | CChannelNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CChannelNotify |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
Release(void) | CChannelNotify |
RefCount::Release(void) | RefCount |
~CChannelNotify() | CChannelNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
Generated on Wed Nov 13 2024 16:55:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/mqfdraw.cpp Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

mqfdraw.cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // mqfdraw.cpp : Defines the class behaviors for the application.
00014 //
00015
00016
00017 #include "stdafx.h"
00018 #include "mqfdraw.h"
00019 #include "drawdlg.h"
00020 #include "logindlg.h"
00021 #include "connectdlg.h"
00022
00023 #ifdef _DEBUG
00024 #define new DEBUG_NEW
00025 #undef THIS_FILE
00026 static char THIS_FILE[] = __FILE__;
00027 #endif
00028
00029 #define MAX_USERNAME_LEN 32
00030 #define MAX_VAR 20
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 // CDisdrawApp
00034
00035 BEGIN_MESSAGE_MAP(CDisdrawApp, CWinApp)
00036   //{{AFX_MSG_MAP(CDisdrawApp)
00037     // NOTE - the ClassWizard will add and remove mapping macros here.
00038     //    DO NOT EDIT what you see in these blocks of generated code!
00039   //}}AFX_MSG
00040   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00041 END_MESSAGE_MAP()
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // CDisdrawApp construction
00045
00046 CDisdrawApp::CDisdrawApp()
00047 {
00048   // TODO: add construction code here,
00049   // Place all significant initialization in InitInstance
00050 }
00051
00052 /////////////////////////////////////////////////////////////////////////////
00053 // The one and only CDisdrawApp object
00054
00055 CDisdrawApp theApp;
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058
00059
00060 // CDisdrawApp initialization
00061
00062 BOOL CDisdrawApp::InitInstance()
00063 {
00064   // Standard initialization
00065   // If you are not using these features and wish to reduce the size
00066   //  of your final executable, you should remove from the following
00067   //  the specific initialization routines you do not need.
00068
00069 #ifdef _AFXDLL
00070   Enable3dControls();     // Call this when using MFC in a shared DLL
00071 #else
00072   Enable3dControlsStatic(); // Call this when linking to MFC statically
00073 #endif
00074
00075   //
00076   // Prompt for the user's name
00077   //
00078   char mbsUserName[MAX_USERNAME_LEN];
00079   DWORD dwNumBytes = MAX_USERNAME_LEN;
00080   GetUserName(mbsUserName, &dwNumBytes);
00081   CLoginDlg dlgLogin;
00082   dlgLogin.m_strLogin = mbsUserName;
00083   if (dlgLogin.DoModal() == IDCANCEL || dlgLogin.m_strLogin == "" )
00084   {
00085     return FALSE;
00086   }
00087
00088   dlgLogin.m_strLogin.MakeUpper();
00089
00090
00091   CConnectDlg dlgConnect;
00092
00093   if(dlgLogin.m_fDsEnabledLocaly)
00094   {
00095     dlgConnect.m_strLogin = dlgLogin.m_strLogin;
00096     if (dlgConnect.DoModal() == IDCANCEL )
00097     {
00098       return FALSE;
00099     }
00100   }
00101   CDisdrawDlg dlg;
00102   m_pMainWnd = &dlg;
00103   dlg.m_strLogin = dlgLogin.m_strLogin;
00104   dlg.m_iRadioDS = dlgConnect.m_iRadioDS;
00105   dlg.m_fDsEnabledLocaly = dlgLogin.m_fDsEnabledLocaly;
00106
00107
00108   int nResponse = dlg.DoModal();
00109   if (nResponse == IDOK)
00110   {
00111     // TODO: Place code here to handle when the dialog is
00112     //  dismissed with OK
00113   }
00114   else if (nResponse == IDCANCEL)
00115   {
00116     // TODO: Place code here to handle when the dialog is
00117     //  dismissed with Cancel
00118   }
00119
00120   // Since the dialog has been closed, return FALSE so that we exit the
00121   //  application, rather than start the application's message pump.
00122   return FALSE;
00123 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAgentCtlRequest Member List

This is the complete list of members for CAgentCtlRequest, including all inherited members.
CAgentCtlRequest() | CAgentCtlRequest | [inline]
CAgentCtlRequest(LPDISPATCH pDispatch) | CAgentCtlRequest | [inline]
CAgentCtlRequest(const CAgentCtlRequest &dispatchSrc) | CAgentCtlRequest | [inline]
GetDescription() | CAgentCtlRequest |
GetNumber() | CAgentCtlRequest |
GetStatus() | CAgentCtlRequest |
Generated on Wed Nov 13 2024 16:55:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIDBBinderProperties Member List

This is the complete list of members for CImpIDBBinderProperties, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBinder, CImpIDBBinderProperties) | CImpIDBBinderProperties
GetProperties(ULONG cPropertySets, const DBPROPIDSET rgPropertySets[], ULONG *pcPropertySets, DBPROPSET **prgPropertySets) | CImpIDBBinderProperties
GetPropertyInfo(ULONG cPropertySets, const DBPROPIDSET rgPropertySets[], ULONG *pcPropertyInfoSets, DBPROPINFOSET **prgPropertyInfoSets, WCHAR **ppDescBuffer) | CImpIDBBinderProperties
Reset() | CImpIDBBinderProperties
SetProperties(ULONG cPropertySets, DBPROPSET rgPropertySets[]) | CImpIDBBinderProperties
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenuex/globals.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenuex

globals.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _MMC_GLOBALS_H
00015 #define _MMC_GLOBALS_H
00016
00017 #include <TChar.h>
00018 #include <Mmc.h>
00019 #include <CrtDbg.h>
00020 #include "Guids.h"
00021
00022 class CDataObject;
00023
00024
00025 //---------------------------------------------------------------------------
00026 extern HINSTANCE g_hInst;              // Global instance handle
00027 extern ULONG     g_uObjectCount;       // Instance count for this object
00028 extern ULONG     g_uServerLocks;       // Server lock count for this object
00029
00030
00031 #define MAX_OBJECT_PATH      255
00032
00033 #define IDM_QUERY_ATTRIBS    2000
00034
00035 //---------------------------------------------------------------------------
00036 //  Global function prototypes
00037
00038 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide );
00039
00040 //---------------------------------------------------------------------------
00041 //  Global Strings
00042
00043
00044 static TCHAR*  gtszSNAPIN_NAME   = _T("Sample D1 (MMC 2.0) - ContextMenuEx");
00045
00046 // This string is used under \Nodetypes\Extensions\View to identify the object.
00047 static TCHAR*  gtszOBJECT_NAME   = _T("MMC SDK Custom ContextMenu Extension");
00048
00049
00050 //CONTEXTMENUX:  GUID strings for nodes which we access in the registry.
00051 static TCHAR*  gtszDEVICE_GUID   = _T("{520F23F9-775D-4015-B437-98A24B9D085E}");
00052 static TCHAR*  gtszCTXMENUX_GUID = _T("{6568A231-D647-4E60-BB38-B8B3878B9DDF}");
00053
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // Helper classes and macros
00057
00058 #define BYTE_SIZE(string)          ((_tcslen(string)+1) * sizeof(TCHAR))
00059
00060 #define BREAK_ON_ERROR( hResult )  if( S_OK != hResult ) continue
00061
00062 // Useful only for debugging.  Never use modal dialogs in release builds!!
00063 #define MsgBox(wszMsg, wszTitle) ::MessageBox(NULL, wszMsg, wszTitle, MB_OK)
00064
00065
00066 //---------------------------------------------------------------------------
00067 template<class TYPE>
00068 inline void SAFE_RELEASE( TYPE*& pObj )
00069 {
00070   if( NULL != pObj )
00071   {
00072     pObj->Release();
00073     pObj = NULL;
00074   }
00075   else
00076   {
00077     OutputDebugString(_T("Attempted to release NULL Com pointer.\n"));
00078   }
00079 }
00080
00081 //---------------------------------------------------------------------------
00082 template<class TYPE>
00083 inline void SAFE_FREE_BITMAP( TYPE*& pObj )
00084 {
00085   if( NULL != pObj )
00086   {
00087     BOOL bStatus = DeleteObject( pObj );
00088     pObj = NULL;
00089   }
00090   else
00091   {
00092     OutputDebugString(_T("Attempted to delete NULL Bitmap handle.\n"));
00093   }
00094 }
00095
00096 //---------------------------------------------------------------------------
00097 template<class TYPE>
00098 inline void SAFE_FREE_ICON( TYPE*& pObj )
00099 {
00100   if( NULL != pObj )
00101   {
00102     BOOL bStatus = DestroyIcon( pObj );
00103     pObj = NULL;
00104   }
00105   else
00106   {
00107     OutputDebugString(_T("Attempted to delete NULL Icon handle.\n"));
00108   }
00109 }
00110
00111 //---------------------------------------------------------------------------
00112 //  W2T converts a wide character string to unicode if _UNICODE is not
00113 //  defined.  If it is defined then the sting is copied to another buffer.
00114 //
00115 #ifndef _UNICODE
00116 #define W2T( szAnsiPtr, szWide )   Unicode2Ansi( szAnsiPtr, szWide )
00117 #else
00118 #define W2T( szAnsiPtr, szWide )                                 \
00119         *szAnsiPtr = (WCHAR*)CoTaskMemAlloc(BYTE_SIZE(szWide) ); \
00120         CopyMemory( *szAnsiPtr, szWide, BYTE_SIZE(szWide) )
00121
00122 #endif //_UNICODE
00123
00124
00125 #endif //_MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/foldernode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

foldernode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CFolderNode class.  This node is a child of
00014 //                CDeviceNode.  It represents a Virtual Storage folder
00015 //
00016 //
00017
00018
00019 #ifndef _CLASS_CFOLDERNODE_
00020 #define _CLASS_CFOLDERNODE_
00021
00022 #include "Globals.h"
00023 #include "BaseNode.h"
00024 #include "VirtualFile.h"     // Result item children of this node
00025 #include "LListImpl.h"       // Linked list class
00026
00027
00028 class CComponentData;        // References
00029 class CDeviceNode;
00030
00031 //---------------------------------------------------------------------------
00032 class CFolderNode : public CBaseNode
00033 {
00034   public:
00035     CFolderNode();
00036     virtual ~CFolderNode();
00037
00038     HRESULT Initialize( LPNODEPROPS pNodeProps );
00039
00040   ///////////////////////////////////////////////////////////////////////////
00041   // Virtual methods
00042   public:
00043     HRESULT GetProperties( LPNODEPROPS* ppNodeProps );
00044     ULONG   GetNodeType() { return NODETYPE_FOLDER; }
00045     GUID&   GetNodeGUID() { return thisGUID; }
00046
00047     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00048     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00049     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00050
00051   ///////////////////////////////////////////////////////////////////////////
00052   //  Notification handlers
00053   //
00054   public:
00055     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00056     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00057     HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00058     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00059     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00060     HRESULT OnViewChange( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00061
00062     // DRAGDROP:  Support for additional notifications
00063     HRESULT OnQueryPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00064     HRESULT OnPaste( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00065     HRESULT OnCutOrMove( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00066
00067
00068   ///////////////////////////////////////////////////////////////////////////
00069   //  Context Menu methods
00070   //
00071   public:
00072     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00073     HRESULT Command( long lCommandID );
00074
00075   ///////////////////////////////////////////////////////////////////////////
00076   // Private helpers
00077   private:
00078     HRESULT InitDefaultVFile();
00079     VOID    RemoveNodes();
00080     HRESULT EnumerateResultItems( LPRESULTDATA ipResultData );
00081     HRESULT AddVirtualFile( NODE_PROPERTIES* pProps = NULL );
00082
00083   private:
00084     static GUID  thisGUID;
00085     DWORD        m_dwAttributes;
00086
00087     CLListImpl<CVirtualFile*,CVirtualFile*>  m_NodeList;
00088     CComponentData* m_pCompData;
00089     HWND            m_hMessageWnd;     // Our message handler
00090     CDeviceNode*    m_pParentNode;
00091
00092   public:
00093     HWND   m_hAddVFileDlg;             // Instance of AddDeviceDlg
00094
00095     static LRESULT CALLBACK FolderNodeWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
00096
00097     VOID RemoveChildNode( LONG_PTR pChildNode );
00098
00099 };
00100
00101 #endif //_CLASS_CFOLDERNODE_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/AdvQuery/AdvQuery.Cxx Source File

  • WinBase
  • Indexing
  • AdvQuery

AdvQuery.Cxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 // PARTICULAR PURPOSE.
00007 //
00008 // Copyright (c) Microsoft Corporation. All rights reserved.
00009 //
00010 // PROGRAM:  advquery.cxx
00011 //
00012 // PURPOSE:  Illustrates an advanced query using Indexing Service.
00013 //           Uses the OLE DB Provider for Indexing Service, not
00014 //           Indexing Service helper functions.
00015 //
00016 // PLATFORM: Windows 2000
00017 //
00018 //--------------------------------------------------------------------------
00019
00020 #ifndef UNICODE
00021   #define UNICODE
00022 #endif
00023
00024 #include <stdio.h>
00025 #include <windows.h>
00026
00027 #define OLEDBVER 0x0250 // need the command tree definitions
00028 #define DBINITCONSTANTS
00029
00030 #include <oledberr.h>
00031 #include <oledb.h>
00032 #include <cmdtree.h>
00033 #include <olectl.h>
00034
00035 #include <ntquery.h>
00036
00037 // This is found in disptree.cxx
00038
00039 extern void DisplayCommandTree( DBCOMMANDTREE * pNode, ULONG iLevel = 0 );
00040
00041 //+-------------------------------------------------------------------------
00042 //
00043 //  Template:   XInterface
00044 //
00045 //  Synopsis:   Template for managing ownership of interfaces
00046 //
00047 //--------------------------------------------------------------------------
00048
00049 template<class T> class XInterface
00050 {
00051 public:
00052     XInterface( T * p = 0 ) : _p( p ) {}
00053     ~XInterface() { if ( 0 != _p ) _p->Release(); }
00054     T * operator->() { return _p; }
00055     T * GetPointer() const { return _p; }
00056     IUnknown ** GetIUPointer() { return (IUnknown **) &_p; }
00057     T ** GetPPointer() { return &_p; }
00058     void ** GetQIPointer() { return (void **) &_p; }
00059     T * Acquire() { T * p = _p; _p = 0; return p; }
00060
00061 private:
00062     T * _p;
00063 };
00064
00065 //+-------------------------------------------------------------------------
00066 //
00067 //  Function:   CreateICommand
00068 //
00069 //  Synopsis:   Creates an ICommand.
00070 //
00071 //  Arguments:  [ppICommand] - Where the ICommand is returned on success
00072 //
00073 //  Returns:    HRESULT result
00074 //
00075 //--------------------------------------------------------------------------
00076
00077 HRESULT CreateICommand( ICommand ** ppICommand )
00078 {
00079     // Instantiate the data source object
00080
00081     XInterface<IDBInitialize> xIDBInit;
00082     static const GUID guidIndexingServiceDSO = CLSID_INDEX_SERVER_DSO;
00083     HRESULT hr = CoCreateInstance( guidIndexingServiceDSO,
00084                                    0,
00085                                    CLSCTX_INPROC_SERVER,
00086                                    IID_IDBInitialize,
00087                                    xIDBInit.GetQIPointer() );
00088     if ( FAILED(hr) )
00089         return hr;
00090
00091     // Initialize, verifying that we supplied the right variables
00092
00093     hr = xIDBInit->Initialize();
00094     if ( FAILED(hr) )
00095         return hr;
00096
00097     // Get a session object
00098
00099     XInterface<IDBCreateSession> xIDBSess;
00100     hr = xIDBInit->QueryInterface( IID_IDBCreateSession,
00101                                    xIDBSess.GetQIPointer() );
00102     if ( FAILED(hr) )
00103         return hr;
00104
00105     // Get a Create Command object
00106
00107     XInterface<IDBCreateCommand> xICreateCommand;
00108     hr = xIDBSess->CreateSession( 0,
00109                                   IID_IDBCreateCommand,
00110                                   xICreateCommand.GetIUPointer() );
00111     if ( FAILED(hr) )
00112         return hr;
00113
00114     // Create the ICommand
00115
00116     XInterface<ICommand> xICommand;
00117     hr = xICreateCommand->CreateCommand( 0,
00118                                          IID_ICommand,
00119                                          xICommand.GetIUPointer() );
00120     if ( FAILED(hr) )
00121         return hr;
00122
00123     *ppICommand = xICommand.Acquire();
00124
00125     return hr;
00126 } //CreateICommand
00127
00128 //+-------------------------------------------------------------------------
00129 //
00130 //  Function:   SetCommandProperties
00131 //
00132 //  Synopsis:   Sets the DBPROP_USEEXTENDEDDBTYPES property to TRUE, so
00133 //              data is returned in PROPVARIANTs, as opposed to the
00134 //              default, which is OLE automation VARIANTs.  PROPVARIANTS
00135 //              allow a superset of VARIANT data types.  Use of these
00136 //              types avoids costly coercions.
00137 //
00138 //              Also sets the DBPROP_USECONTENTINDEX property to TRUE, so
00139 //              the index will always be used to resolve the query (as
00140 //              opposed to enumerating all the files on the disk), even
00141 //              if the index is out of date.
00142 //
00143 //              Also sets the asynchronous property, so the Execute() call
00144 //              returns before the query is complete.
00145 //
00146 //              Both of these properties are unique to the OLE DB Provider
00147 //              for Indexing Service implementation.
00148 //
00149 //  Arguments:  [pICommand] - The ICommand used to set the property
00150 //
00151 //  Returns:    HRESULT result of setting the properties
00152 //
00153 //--------------------------------------------------------------------------
00154
00155 HRESULT SetCommandProperties( ICommand * pICommand )
00156 {
00157     static const DBID dbcolNull = { { 0,0,0, { 0,0,0,0,0,0,0,0 } },
00158                                     DBKIND_GUID_PROPID, 0 };
00159     static const GUID guidQueryExt = DBPROPSET_QUERYEXT;
00160     static const GUID guidRowsetProps = DBPROPSET_ROWSET;
00161
00162     DBPROP aProp[3];
00163
00164     aProp[0].dwPropertyID = DBPROP_USEEXTENDEDDBTYPES;
00165     aProp[0].dwOptions = DBPROPOPTIONS_OPTIONAL;
00166     aProp[0].dwStatus = 0;
00167     aProp[0].colid = dbcolNull;
00168     aProp[0].vValue.vt = VT_BOOL;
00169     aProp[0].vValue.boolVal = VARIANT_TRUE;
00170
00171     aProp[1] = aProp[0];
00172     aProp[1].dwPropertyID = DBPROP_USECONTENTINDEX;
00173
00174     aProp[2] = aProp[0];
00175     aProp[2].dwOptions = DBPROPOPTIONS_REQUIRED;
00176     aProp[2].dwPropertyID = DBPROP_IDBAsynchStatus;
00177
00178     DBPROPSET aPropSet[2];
00179
00180     aPropSet[0].rgProperties = &aProp[0];
00181     aPropSet[0].cProperties = 2;
00182     aPropSet[0].guidPropertySet = guidQueryExt;
00183
00184     aPropSet[1].rgProperties = &aProp[2];
00185     aPropSet[1].cProperties = 1;
00186     aPropSet[1].guidPropertySet = guidRowsetProps;
00187
00188     XInterface<ICommandProperties> xICommandProperties;
00189     HRESULT hr = pICommand->QueryInterface( IID_ICommandProperties,
00190                                             xICommandProperties.GetQIPointer() );
00191     if ( FAILED( hr ) )
00192         return hr;
00193
00194     return xICommandProperties->SetProperties( 2,          // 2 property sets
00195                                                aPropSet ); // the properties
00196 } //SetCommandProperties
00197
00198 //+-------------------------------------------------------------------------
00199 //
00200 //  Function:   SetScopeCatalogAndMachine
00201 //
00202 //  Synopsis:   Sets the catalog and machine properties in the ICommand.
00203 //              Also sets a default scope.
00204 //
00205 //  Arguments:  [pICommand]       - ICommand to set props on
00206 //              [pwcQueryScope]   - Scope for the query
00207 //              [pwcQueryCatalog] - Catalog name over which query is run
00208 //              [pwcQueryMachine] - Machine name on which query is run
00209 //
00210 //  Returns:    HRESULT result of the operation
00211 //
00212 //--------------------------------------------------------------------------
00213
00214 HRESULT SetScopeCatalogAndMachine(
00215     ICommand *    pICommand,
00216     WCHAR const * pwcQueryScope,
00217     WCHAR const * pwcQueryCatalog,
00218     WCHAR const * pwcQueryMachine )
00219 {
00220     // Get an ICommandProperties so we can set the properties
00221
00222     XInterface<ICommandProperties> xICommandProperties;
00223     HRESULT hr = pICommand->QueryInterface( IID_ICommandProperties,
00224                                             xICommandProperties.GetQIPointer() );
00225     if ( FAILED( hr ) )
00226         return hr;
00227
00228     const GUID guidCI = DBPROPSET_CIFRMWRKCORE_EXT;
00229     const GUID guidFSCI = DBPROPSET_FSCIFRMWRK_EXT;
00230
00231     SAFEARRAY * pMachines = 0;
00232     SAFEARRAY * pCatalogs = 0;
00233     SAFEARRAY * pScopes = 0;
00234     SAFEARRAY * pFlags = 0;
00235
00236
00237     // note: SysAllocString, SafeArrayCreate, and SafeArrayPutElement can
00238     // fail, but this isn't checked here for brevity.
00239
00240     SAFEARRAYBOUND rgBound[1];
00241     rgBound[0].lLbound = 0;
00242     rgBound[0].cElements = 1;
00243     pMachines = SafeArrayCreate( VT_BSTR, 1, rgBound );
00244     if ( 0 == pMachines )
00245     {
00246         hr = E_OUTOFMEMORY;
00247         goto cleanup;
00248     }
00249
00250    {
00251     long i = 0;
00252     hr = SafeArrayPutElement( pMachines, &i, SysAllocString( pwcQueryMachine ) );
00253     if ( FAILED( hr ) )
00254         goto cleanup;
00255
00256     pCatalogs = SafeArrayCreate( VT_BSTR, 1, rgBound );
00257     if ( 0 == pCatalogs )
00258     {
00259         hr = E_OUTOFMEMORY;
00260         goto cleanup;
00261     }
00262
00263     hr = SafeArrayPutElement( pCatalogs, &i, SysAllocString( pwcQueryCatalog ) );
00264     if ( FAILED( hr ) )
00265         goto cleanup;
00266
00267     pScopes = SafeArrayCreate( VT_BSTR, 1, rgBound );
00268     if ( 0 == pScopes )
00269     {
00270         hr = E_OUTOFMEMORY;
00271         goto cleanup;
00272     }
00273
00274     hr = SafeArrayPutElement( pScopes, &i, SysAllocString( pwcQueryScope ) );
00275     if ( FAILED( hr ) )
00276         goto cleanup;
00277
00278     LONG lFlags = QUERY_DEEP;
00279     pFlags = SafeArrayCreate( VT_I4, 1, rgBound );
00280     if ( 0 == pFlags )
00281     {
00282         hr = E_OUTOFMEMORY;
00283         goto cleanup;
00284     }
00285
00286     hr = SafeArrayPutElement( pFlags, &i, &lFlags );
00287     if ( FAILED( hr ) )
00288         goto cleanup;
00289
00290     DBPROP aScopeProperties[2];
00291     memset( aScopeProperties, 0, sizeof aScopeProperties );
00292     aScopeProperties[0].dwPropertyID = DBPROP_CI_INCLUDE_SCOPES;
00293     aScopeProperties[0].vValue.vt = VT_BSTR | VT_ARRAY;
00294     aScopeProperties[0].vValue.parray = pScopes;
00295     aScopeProperties[0].colid.eKind = DBKIND_GUID_PROPID;
00296
00297     aScopeProperties[1].dwPropertyID = DBPROP_CI_SCOPE_FLAGS;
00298     aScopeProperties[1].vValue.vt = VT_I4 | VT_ARRAY;
00299     aScopeProperties[1].vValue.parray = pFlags;
00300     aScopeProperties[1].colid.eKind = DBKIND_GUID_PROPID;
00301
00302     DBPROP aCatalogProperties[1];
00303     memset( aCatalogProperties, 0, sizeof aCatalogProperties );
00304     aCatalogProperties[0].dwPropertyID = DBPROP_CI_CATALOG_NAME;
00305     aCatalogProperties[0].vValue.vt = VT_BSTR | VT_ARRAY;
00306     aCatalogProperties[0].vValue.parray = pCatalogs;
00307     aCatalogProperties[0].colid.eKind = DBKIND_GUID_PROPID;
00308
00309     DBPROP aMachineProperties[1];
00310     memset( aMachineProperties, 0, sizeof aMachineProperties );
00311     aMachineProperties[0].dwPropertyID = DBPROP_MACHINE;
00312     aMachineProperties[0].vValue.vt = VT_BSTR | VT_ARRAY;
00313     aMachineProperties[0].vValue.parray = pMachines;
00314     aMachineProperties[0].colid.eKind = DBKIND_GUID_PROPID;
00315
00316     DBPROPSET aAllPropsets[3];
00317     aAllPropsets[0].rgProperties = aScopeProperties;
00318     aAllPropsets[0].cProperties = 2;
00319     aAllPropsets[0].guidPropertySet = guidFSCI;
00320
00321     aAllPropsets[1].rgProperties = aCatalogProperties;
00322     aAllPropsets[1].cProperties = 1;
00323     aAllPropsets[1].guidPropertySet = guidFSCI;
00324
00325     aAllPropsets[2].rgProperties = aMachineProperties;
00326     aAllPropsets[2].cProperties = 1;
00327     aAllPropsets[2].guidPropertySet = guidCI;
00328
00329     const ULONG cPropertySets = sizeof aAllPropsets / sizeof aAllPropsets[0];
00330
00331     hr = xICommandProperties->SetProperties( cPropertySets,  // # of propsets
00332                                              aAllPropsets ); // the propsets
00333    } // scope resolution to get rid of errors on stricter compilers
00334
00335 cleanup:
00336
00337     if ( 0 != pScopes )
00338         SafeArrayDestroy( pScopes );
00339
00340     if ( 0 != pFlags )
00341         SafeArrayDestroy( pFlags );
00342
00343     if ( 0 != pCatalogs )
00344         SafeArrayDestroy( pCatalogs );
00345
00346     if ( 0 != pMachines )
00347         SafeArrayDestroy( pMachines );
00348
00349     return hr;
00350 } //SetScopeCatalogAndMachine
00351
00352 //+-------------------------------------------------------------------------
00353 //
00354 //  Function:   AllocAndCopy
00355 //
00356 //  Synopsis:   Allocates and duplicates a string.
00357 //
00358 //  Arguments:  [pwcIn]  - The string to copy
00359 //
00360 //  Returns:    A string
00361 //
00362 //--------------------------------------------------------------------------
00363
00364 WCHAR * AllocAndCopy( WCHAR const * pwcIn )
00365 {
00366     ULONG cwc = (ULONG) ( wcslen( pwcIn ) + 1 );
00367
00368     // note: CoTaskMemAlloc can return 0 if out of memory, not checked
00369
00370     WCHAR * pwc = (WCHAR *) CoTaskMemAlloc( cwc * sizeof WCHAR );
00371     wcscpy( pwc, pwcIn );
00372     return pwc;
00373 } //AllocAndCopy
00374
00375 //+-------------------------------------------------------------------------
00376 //
00377 //  Function:   NewTreeNode
00378 //
00379 //  Synopsis:   Allocates and initializes a DBCOMMANDTREE object
00380 //
00381 //  Arguments:  [op]     - The node's operator
00382 //              [wKind]  - The kind of node
00383 //
00384 //  Returns:    an initialized DBCOMMANDTREE object
00385 //
00386 //--------------------------------------------------------------------------
00387
00388 DBCOMMANDTREE * NewTreeNode(
00389     DBCOMMANDOP op,
00390     WORD        wKind )
00391 {
00392     DBCOMMANDTREE * pTree = (DBCOMMANDTREE *)
00393                              CoTaskMemAlloc( sizeof DBCOMMANDTREE );
00394     memset( pTree, 0, sizeof DBCOMMANDTREE );
00395     pTree->op = op;
00396     pTree->wKind = wKind;
00397     return pTree;
00398 } //NewTreeNode
00399
00400 //+-------------------------------------------------------------------------
00401 //
00402 //  Function:   CreateQueryTree
00403 //
00404 //  Synopsis:   Creates a DBCOMMANDTREE for the query
00405 //
00406 //  Arguments:  [pwcQueryRestrition] - The actual query string
00407 //              [ppTree]             - Resulting query tree
00408 //
00409 //  Returns:    HRESULT result of the operation
00410 //
00411 //  Notes:      The query tree has a string restriction, a list of
00412 //              columns to return (rank, size, and path), and a sort
00413 //              order (rank).
00414 //              Here are two views of the query tree
00415 //
00416 //              sort:
00417 //                child: project
00418 //                  sibling: sort_list_anchor
00419 //                    child: sort_list_element
00420 //                      value: SORTINFO (descending, lcid)
00421 //                      child: column_name
00422 //                        value: DBID rank
00423 //                  child: select
00424 //                    sibling: project_list_anchor
00425 //                      child: project_list_element
00426 //                        child: column_name
00427 //                          value: DBID rank
00428 //                        sibling: project_list_element
00429 //                          child: column_name
00430 //                            value: DBID size
00431 //                          sibling: project_list_element
00432 //                            child: column_name
00433 //                              value: DBID path
00434 //                    child: table_name
00435 //                      value: WSTR: "Table"
00436 //                      sibling: content
00437 //                        value: DBCONTENT (restriction, weight, lcid)
00438 //                        child: column_name
00439 //                          value: DBID contents
00440 //
00441 // +---------------------------+
00442 // | DBOP_sort                 |
00443 // | DBVALUEKIND_EMPTY         |
00444 // +---------------------------+
00445 // |
00446 // |child
00447 // |                            sibling
00448 // +---------------------------+-------+---------------------------+
00449 // | DBOP_project              |       | DBOP_sort_list_anchor     |
00450 // | DBVALUEKIND_EMPTY         |       | DBVALUEKIND_EMPTY         |
00451 // +---------------------------+       +---------------------------+
00452 // |                                   |
00453 // |child                              |child
00454 // |                                   |
00455 // |                                   +---------------------------+
00456 // |                                   | DBOP_sort_list_element    |
00457 // |                                   | DBVALUEKIND_SORTINFO      |
00458 // |                                   +---------------------------+
00459 // |                                   |            |
00460 // |                                   |child       | pdbsrtinfValue
00461 // |                                   |            |
00462 // |                                   |     +-------------+
00463 // |                                   |     | DBSORTIFO   |
00464 // |                                   |     | fDesc TRUE  |
00465 // |                                   |     | lcid system |
00466 // |                                   |     +-------------+
00467 // |                                   |
00468 // |                                   |
00469 // |                                   |
00470 // |                                   +---------------------------+
00471 // |                                   | DBOP_column_name          |
00472 // |                                   | DBVALUEKIND_ID            |
00473 // |                                   +---------------------------+
00474 // |                                                |
00475 // |                                                | pdbidValue
00476 // |                                                |
00477 // |                                             +------+
00478 // |                                             | DBID |
00479 // |                                             | rank |
00480 // |                                             +------+
00481 // |
00482 // |                            sibling
00483 // +---------------------------+-------+---------------------------+-------+
00484 // | DBOP_select               |       | DBOP_project_list_anchor  |       | s
00485 // | DBVALUEKIND_EMPTY         |       | DBVALUEKIND_EMPTY         |       | i
00486 // +---------------------------+       +---------------------------+       | b
00487 // |                                   |                                   | l
00488 // |child                              |child                              | i
00489 // |                                   |                                   | n
00490 // |                                   +---------------------------+       | g
00491 // |                                   | DBOP_project_list_element |       |
00492 // |                                   | DBVALUEKIND_EMPTY         |       |
00493 // |                                   +---------------------------+       |
00494 // |                                   |                                   |
00495 // |                                   |child                              |
00496 // |                                   |                                   |
00497 // |                                   +---------------------------+       |
00498 // |                                   | DBOP_column_name          |       |
00499 // |                                   | DBVALUEKIND_ID            |       |
00500 // |                                   +---------------------------+       |
00501 // |                                                |                      |
00502 // |                                                | pdbidValue           |
00503 // |                                                |                      |
00504 // |                                             +------+                  |
00505 // |                                             | DBID |                  |
00506 // |                                             | rank |                  |
00507 // |                                             +------+                  |
00508 // |                                                                       |
00509 // |                                   +-----------------------------------+
00510 // |                                   |
00511 // |                                   +---------------------------+-------+
00512 // |                                   | DBOP_project_list_element |       | s
00513 // |                                   | DBVALUEKIND_EMPTY         |       | i
00514 // |                                   +---------------------------+       | b
00515 // |                                   |                                   | l
00516 // |                                   |child                              | i
00517 // |                                   |                                   | n
00518 // |                                   +---------------------------+       | g
00519 // |                                   | DBOP_column_name          |       |
00520 // |                                   | DBVALUEKIND_ID            |       |
00521 // |                                   +---------------------------+       |
00522 // |                                                |                      |
00523 // |                                                | pdbidValue           |
00524 // |                                                |                      |
00525 // |                                             +------+                  |
00526 // |                                             | DBID |                  |
00527 // |                                             | size |                  |
00528 // |                                             +------+                  |
00529 // |                                                                       |
00530 // |                                   +-----------------------------------+
00531 // |                                   |
00532 // |                                   +---------------------------+
00533 // |                                   | DBOP_project_list_element |
00534 // |                                   | DBVALUEKIND_EMPTY         |
00535 // |                                   +---------------------------+
00536 // |                                   |
00537 // |                                   |child
00538 // |                                   |
00539 // |                                   +---------------------------+
00540 // |                                   | DBOP_column_name          |
00541 // |                                   | DBVALUEKIND_ID            |
00542 // |                                   +---------------------------+
00543 // |                                                |
00544 // |                                                | pdbidValue
00545 // |                                                |
00546 // |                                             +------+
00547 // |                                             | DBID |
00548 // |                                             | path |
00549 // |                                             +------+
00550 // |
00551 // |                            sibling
00552 // +---------------------------+-------+---------------------------+
00553 // | DBOP_table_name           |       | DBOP_content              |
00554 // | DBVALUEKIND_WSTR: 'Table' |       | DBVALUEKIND_CONTENT       |
00555 // +---------------------------+       +---------------------------+
00556 //                                     |            |
00557 //                                     |child       | pdbcntntValue
00558 //                                     |            |
00559 //                                     |  +---------------------------+
00560 //                                     |  | DBCONTENT                 |
00561 //                                     |  | dwGenerateMethod: GENERATE_METHOD_EXACT |
00562 //                                     |  | lWeight: 1000             |
00563 //                                     |  | lcid: system              |
00564 //                                     |  | pwszPhrase: the query     |
00565 //                                     |  +---------------------------+
00566 //                                     |
00567 //                                     |
00568 //                                     |
00569 //                                     +---------------------------+
00570 //                                     | DBOP_column_name          |
00571 //                                     | DBVALUEKIND_ID            |
00572 //                                     +---------------------------+
00573 //                                                  |
00574 //                                                  | pdbidValue
00575 //                                                  |
00576 //                                             +----------+
00577 //                                             | DBID     |
00578 //                                             | contents |
00579 //                                             +----------+
00580 //
00581 //--------------------------------------------------------------------------
00582
00583 HRESULT CreateQueryTree(
00584     WCHAR const *    pwcQueryRestriction,
00585     DBCOMMANDTREE ** ppTree )
00586 {
00587     // These are the properties that'll be referenced below
00588
00589     const DBID dbidContents = { PSGUID_STORAGE, DBKIND_GUID_PROPID,
00590                                 (LPOLESTR) PID_STG_CONTENTS };
00591     const DBID dbidPath =     { PSGUID_STORAGE, DBKIND_GUID_PROPID,
00592                                 (LPOLESTR) PID_STG_PATH };
00593     const DBID dbidSize =     { PSGUID_STORAGE, DBKIND_GUID_PROPID,
00594                                 (LPOLESTR) PID_STG_SIZE };
00595     DBID dbidRank;
00596     dbidRank.uGuid.guid = PSGUID_QUERY;
00597     dbidRank.eKind = DBKIND_GUID_PROPID;
00598     dbidRank.uName.ulPropid = PROPID_QUERY_RANK ;
00599
00600     // The restriction is a content node with either a word or a phrase.
00601     // This is the most simple possible query.  Other types of nodes include
00602     // AND, OR, NOT, etc.
00603     // The CITextToFullTree function is available for building more complex
00604     // queries given a text string.
00605
00606     DBCOMMANDTREE *pRestriction = NewTreeNode( DBOP_content,
00607                                                DBVALUEKIND_CONTENT );
00608     DBCONTENT * pDBContent = (DBCONTENT *) CoTaskMemAlloc( sizeof DBCONTENT );
00609     memset( pDBContent, 0, sizeof DBCONTENT );
00610     pRestriction->value.pdbcntntValue = pDBContent;
00611     pDBContent->dwGenerateMethod = GENERATE_METHOD_EXACT;
00612     pDBContent->lWeight = 1000; // maximum possible weight
00613     pDBContent->lcid = GetSystemDefaultLCID();
00614     pDBContent->pwszPhrase = AllocAndCopy( pwcQueryRestriction );
00615
00616     // This identifies "file contents" as the property for the restrition
00617
00618     DBCOMMANDTREE *pPropID = NewTreeNode( DBOP_column_name, DBVALUEKIND_ID );
00619     pRestriction->pctFirstChild = pPropID;
00620     DBID *pDBID = (DBID *) CoTaskMemAlloc( sizeof DBID );
00621     *pDBID = dbidContents;
00622     pPropID->value.pdbidValue = pDBID;
00623
00624     DBCOMMANDTREE *pSelect = NewTreeNode( DBOP_select, DBVALUEKIND_EMPTY );
00625     DBCOMMANDTREE *pTableId = NewTreeNode( DBOP_table_name, DBVALUEKIND_WSTR );
00626     pSelect->pctFirstChild = pTableId;
00627     pTableId->value.pwszValue = AllocAndCopy( L"Table" );
00628     pTableId->pctNextSibling = pRestriction;
00629
00630     DBCOMMANDTREE *pProject = NewTreeNode( DBOP_project, DBVALUEKIND_EMPTY );
00631     pProject->pctFirstChild = pSelect;
00632
00633     // The project anchor holds the list of columns that are retrieved
00634
00635     DBCOMMANDTREE * pProjectAnchor = NewTreeNode( DBOP_project_list_anchor,
00636                                                   DBVALUEKIND_EMPTY );
00637     pSelect->pctNextSibling = pProjectAnchor;
00638
00639     // Retrieve rank as column 1
00640
00641     DBCOMMANDTREE * pProjectRank = NewTreeNode( DBOP_project_list_element,
00642                                                   DBVALUEKIND_EMPTY );
00643     pProjectAnchor->pctFirstChild = pProjectRank;
00644
00645     DBCOMMANDTREE * pColumnRank = NewTreeNode( DBOP_column_name,
00646                                                DBVALUEKIND_ID );
00647     pProjectRank->pctFirstChild = pColumnRank;
00648     DBID *pDBIDRank = (DBID *) CoTaskMemAlloc( sizeof DBID );
00649     pColumnRank->value.pdbidValue = pDBIDRank;
00650     *pDBIDRank = dbidRank;
00651
00652     // Retrieve file size as column 2
00653
00654     DBCOMMANDTREE * pProjectSize = NewTreeNode( DBOP_project_list_element,
00655                                                 DBVALUEKIND_EMPTY );
00656     pProjectRank->pctNextSibling = pProjectSize;
00657
00658     DBCOMMANDTREE * pColumnSize = NewTreeNode( DBOP_column_name,
00659                                                DBVALUEKIND_ID );
00660     pProjectSize->pctFirstChild = pColumnSize;
00661     DBID *pDBIDSize = (DBID *) CoTaskMemAlloc( sizeof DBID );
00662     pColumnSize->value.pdbidValue = pDBIDSize;
00663     *pDBIDSize = dbidSize;
00664
00665     // Retrieve file path as column 3
00666
00667     DBCOMMANDTREE * pProjectPath = NewTreeNode( DBOP_project_list_element,
00668                                                 DBVALUEKIND_EMPTY );
00669     pProjectSize->pctNextSibling = pProjectPath;
00670
00671     DBCOMMANDTREE * pColumnPath = NewTreeNode( DBOP_column_name,
00672                                                DBVALUEKIND_ID );
00673     pProjectPath->pctFirstChild = pColumnPath;
00674     DBID *pDBIDPath = (DBID *) CoTaskMemAlloc( sizeof DBID );
00675     pColumnPath->value.pdbidValue = pDBIDPath;
00676     *pDBIDPath = dbidPath;
00677
00678     // The sort node specifies the sort order for the results
00679
00680     DBCOMMANDTREE * pSort = NewTreeNode( DBOP_sort, DBVALUEKIND_EMPTY );
00681     pSort->pctFirstChild = pProject;
00682
00683     // The sort anchor is the start of the list of sort properties
00684
00685     DBCOMMANDTREE * pSortAnchor = NewTreeNode( DBOP_sort_list_anchor,
00686                                                DBVALUEKIND_EMPTY );
00687     pProject->pctNextSibling = pSortAnchor;
00688
00689     // The sort order is rank
00690
00691     DBCOMMANDTREE * pSortRank = NewTreeNode( DBOP_sort_list_element,
00692                                              DBVALUEKIND_SORTINFO );
00693     pSortAnchor->pctFirstChild = pSortRank;
00694
00695     DBSORTINFO * pSortInfo = (DBSORTINFO *) CoTaskMemAlloc( sizeof DBSORTINFO );
00696     memset( pSortInfo, 0, sizeof DBSORTINFO );
00697     pSortRank->value.pdbsrtinfValue = pSortInfo;
00698     pSortInfo->fDesc = TRUE; // descending, not ascending
00699     pSortInfo->lcid = GetSystemDefaultLCID();
00700
00701     DBCOMMANDTREE * pSortColumnRank = NewTreeNode( DBOP_column_name,
00702                                                    DBVALUEKIND_ID );
00703     pSortRank->pctFirstChild = pSortColumnRank;
00704     DBID *pDBIDSortRank = (DBID *) CoTaskMemAlloc( sizeof DBID );
00705     pSortColumnRank->value.pdbidValue = pDBIDSortRank;
00706     *pDBIDSortRank = dbidRank;
00707
00708     // The sort node is the head of the tree
00709
00710     *ppTree = pSort;
00711
00712     return S_OK;
00713 } //CreateQueryTree
00714
00715 //+---------------------------------------------------------------------------
00716 //
00717 //  Class:      CAsynchNotify
00718 //
00719 //  Synopsis:   Class for the IDBAsynchNotify callbacks
00720 //
00721 //----------------------------------------------------------------------------
00722
00723 class CAsynchNotify : public IDBAsynchNotify
00724 {
00725 public:
00726     CAsynchNotify() :
00727         _cRef( 1 ),
00728         _cLowResource( 0 ),
00729         _hEvent( 0 )
00730     {
00731         _hEvent = CreateEventW( 0, TRUE, FALSE, 0 );
00732     }
00733
00734     ~CAsynchNotify()
00735     {
00736         if ( 0 != _hEvent )
00737             CloseHandle( _hEvent );
00738     }
00739
00740     BOOL IsValid() const { return 0 != _hEvent; }
00741
00742     //
00743     // IUnknown methods.
00744     //
00745
00746     STDMETHOD(QueryInterface) ( REFIID riid, LPVOID *ppiuk )
00747     {
00748         *ppiuk = (void **) this; // hold our breath and jump
00749         AddRef();
00750         return S_OK;
00751     }
00752
00753     STDMETHOD_( ULONG, AddRef ) () { return InterlockedIncrement( &_cRef ); }
00754
00755     STDMETHOD_( ULONG, Release) () { return InterlockedDecrement( &_cRef ); }
00756
00757     //
00758     // IDBAsynchNotify methods
00759     //
00760
00761     STDMETHOD( OnLowResource ) ( DB_DWRESERVE dwReserved )
00762     {
00763         _cLowResource++;
00764
00765         // If we've failed a few times due to low resource, give up
00766         // on the query since there may not be sufficient resources
00767         // to ever get an OnStop call.
00768
00769         if ( _cLowResource >= 5 )
00770             SetEvent( _hEvent );
00771
00772         return S_OK;
00773     }
00774
00775     STDMETHOD( OnProgress ) ( HCHAPTER hChap, DBASYNCHOP ulOp,
00776                               DBCOUNTITEM ulProg, DBCOUNTITEM ulProgMax,
00777                               DBASYNCHPHASE ulStat, LPOLESTR pwszStatus )
00778     {
00779         return S_OK;
00780     }
00781
00782     STDMETHOD( OnStop ) ( HCHAPTER hChap, ULONG ulOp,
00783                           HRESULT hrStat, LPOLESTR pwszStatus )
00784     {
00785         // If the query is complete (successfully or not), set the event
00786
00787         if ( DBASYNCHOP_OPEN == ulOp )
00788             SetEvent( _hEvent );
00789
00790         return S_OK;
00791     }
00792
00793     void Wait()
00794     {
00795         WaitForSingleObject( _hEvent, INFINITE );
00796     }
00797
00798 private:
00799     LONG   _cRef;
00800     LONG   _cLowResource;
00801     HANDLE _hEvent;
00802 };
00803
00804 //+-------------------------------------------------------------------------
00805 //
00806 //  Function:   WaitForQueryToComplete
00807 //
00808 //  Synopsis:   Waits for the query to complete.  This function polls for
00809 //              completion.  Alternatively, the IConnectionPointContainer
00810 //              and IRowsetWatchNotify interfaces could be used for
00811 //              asynchronous notification when the query completes.
00812 //
00813 //  Arguments:  [pRowset]  -- The rowset to wait for
00814 //
00815 //  Returns:    HRESULT result
00816 //
00817 //--------------------------------------------------------------------------
00818
00819 HRESULT WaitForQueryToComplete( IRowset * pRowset )
00820 {
00821     HRESULT hr;
00822
00823     //
00824     // Both methods (notifications and polling) work.  It depends on the
00825     // application which is the best choice.
00826     //
00827
00828 #if 1
00829
00830     // Register for notifications
00831
00832     XInterface<IConnectionPointContainer> xCPC;
00833     hr = pRowset->QueryInterface( IID_IConnectionPointContainer,
00834                                   xCPC.GetQIPointer() );
00835     if (FAILED(hr))
00836         return hr;
00837
00838     XInterface<IConnectionPoint> xCP;
00839     hr = xCPC->FindConnectionPoint( IID_IDBAsynchNotify,
00840                                     xCP.GetPPointer() );
00841     if (FAILED(hr) && CONNECT_E_NOCONNECTION != hr )
00842         return hr;
00843
00844     CAsynchNotify Notify;
00845
00846     if ( !Notify.IsValid() )
00847         return HRESULT_FROM_WIN32( GetLastError() );
00848
00849     DWORD dwAdviseID;
00850     hr = xCP->Advise( (IUnknown *) &Notify, &dwAdviseID );
00851     if (FAILED(hr))
00852         return hr;
00853
00854     //
00855     // In a real app, we'd be off doing other work rather than waiting
00856     // for the query to complete, but this will do.
00857     // MsgWaitForSingleObject is a good choice for a GUI app.  You could
00858     // also post a user-defined windows message when a notification is
00859     // received.
00860     //
00861
00862     Notify.Wait();
00863
00864     hr = xCP->Unadvise( dwAdviseID );
00865     if ( S_OK != hr )
00866         return hr;
00867
00868     Notify.Release();
00869
00870 #else
00871
00872     // Poll for query completion
00873
00874     XInterface<IDBAsynchStatus> xIDBAsynch;
00875     hr = pRowset->QueryInterface( IID_IDBAsynchStatus,
00876                                   xIDBAsynch.GetQIPointer() );
00877     if ( FAILED( hr ) )
00878         return hr;
00879
00880     do
00881     {
00882         DBCOUNTITEM Numerator, Denominator;
00883         DBASYNCHPHASE Phase;
00884         hr = xIDBAsynch->GetStatus( DB_NULL_HCHAPTER,
00885                                     DBASYNCHOP_OPEN,
00886                                     &Numerator,
00887                                     &Denominator,
00888                                     &Phase,
00889                                     0 );
00890         if ( FAILED( hr ) )
00891             return hr;
00892
00893         if ( DBASYNCHPHASE_COMPLETE == Phase )
00894             break;
00895
00896         Sleep( 50 );  // Give the query a chance to run
00897     } while ( TRUE );
00898
00899 #endif
00900
00901     return hr;
00902 } //WaitForQueryToComplete
00903
00904 //+-------------------------------------------------------------------------
00905 //
00906 //  Function:   DoQuery
00907 //
00908 //  Synopsis:   Creates and executes a query, then displays the results.
00909 //
00910 //  Arguments:  [pwcQueryScope]      - Root path for all results
00911 //              [pwcQueryCatalog]    - Catalog name over which query is run
00912 //              [pwcQueryMachine]    - Machine name on which query is run
00913 //              [pwcQueryRestrition] - The actual query string
00914 //              [fDisplayTree]       - TRUE to display the command tree
00915 //
00916 //  Returns:    HRESULT result of the query
00917 //
00918 //--------------------------------------------------------------------------
00919
00920 HRESULT DoQuery(
00921     WCHAR const * pwcQueryScope,
00922     WCHAR const * pwcQueryCatalog,
00923     WCHAR const * pwcQueryMachine,
00924     WCHAR const * pwcQueryRestriction,
00925     BOOL          fDisplayTree )
00926 {
00927     // Create an ICommand object.  The default scope for the query is the
00928     // entire catalog.
00929
00930     XInterface<ICommand> xICommand;
00931     HRESULT hr = CreateICommand( xICommand.GetPPointer() );
00932     if ( FAILED( hr ) )
00933         return hr;
00934
00935     // Set the scope, catalog, and machine in the ICommand
00936
00937     hr = SetScopeCatalogAndMachine( xICommand.GetPointer(),
00938                                     pwcQueryScope,
00939                                     pwcQueryCatalog,
00940                                     pwcQueryMachine );
00941     if ( FAILED( hr ) )
00942         return hr;
00943
00944     // Set required properties on the ICommand
00945
00946     hr = SetCommandProperties( xICommand.GetPointer() );
00947     if ( FAILED( hr ) )
00948         return hr;
00949
00950     // Create an OLE DB query tree from a text restriction
00951
00952     DBCOMMANDTREE * pTree;
00953     hr = CreateQueryTree( pwcQueryRestriction, // the input query
00954                           &pTree );            // the output tree
00955     if ( FAILED( hr ) )
00956         return hr;
00957
00958     // If directed, display the command tree
00959
00960     if ( fDisplayTree )
00961         DisplayCommandTree( pTree );
00962
00963     // Set the tree in the ICommandTree
00964
00965     XInterface<ICommandTree> xICommandTree;
00966     hr = xICommand->QueryInterface( IID_ICommandTree,
00967                                     xICommandTree.GetQIPointer() );
00968     if ( FAILED( hr ) )
00969         return hr;
00970
00971     hr = xICommandTree->SetCommandTree( &pTree,
00972                                         DBCOMMANDREUSE_NONE,
00973                                         FALSE );
00974     if ( FAILED( hr ) )
00975         return hr;
00976
00977     // Execute the query.  The query is asynchronously executed.
00978
00979     XInterface<IRowset> xIRowset;
00980     hr = xICommand->Execute( 0,            // no aggregating IUnknown
00981                              IID_IRowset,  // IID for interface to return
00982                              0,            // no DBPARAMs
00983                              0,            // no rows affected
00984                              xIRowset.GetIUPointer() ); // result
00985     if ( FAILED( hr ) )
00986         return hr;
00987
00988     // Wait for the query to complete, since DBPROP_IDBAsynchStatus was set
00989     // as a command property.  If DBPROP_IDBAsynchStatus isn't set, Execute()
00990     // is synchronous and there is no need to wait for completion here.
00991
00992     hr = WaitForQueryToComplete( xIRowset.GetPointer() );
00993     if ( FAILED( hr ) )
00994         return hr;
00995
00996     // Create an accessor, so data can be retrieved from the rowset
00997
00998     XInterface<IAccessor> xIAccessor;
00999     hr = xIRowset->QueryInterface( IID_IAccessor,
01000                                    xIAccessor.GetQIPointer() );
01001     if ( FAILED( hr ) )
01002         return hr;
01003
01004     // Column iOrdinals are parallel with those passed to CiTextToFullTree,
01005     // so MapColumnIDs isn't necessary.  These binding values for dwPart,
01006     // dwMemOwner, and wType are the most optimal bindings for Indexing
01007     // Service.
01008
01009     const ULONG cColumns = 3; // 3 for Rank, Size, and Path
01010     DBBINDING aColumns[ cColumns ];
01011     memset( aColumns, 0, sizeof aColumns );
01012
01013     aColumns[0].iOrdinal   = 1; // first column specified above (rank)
01014     aColumns[0].obValue    = 0; // offset where value is written in GetData
01015     aColumns[0].dwPart     = DBPART_VALUE;  // retrieve value, not status
01016     aColumns[0].dwMemOwner = DBMEMOWNER_PROVIDEROWNED; // Provider owned
01017     aColumns[0].wType      = DBTYPE_VARIANT | DBTYPE_BYREF; // VARIANT *
01018
01019     aColumns[1] = aColumns[0];
01020     aColumns[1].iOrdinal   = 2; // second column specified above (size)
01021     aColumns[1].obValue    = sizeof (PROPVARIANT *); // offset for value
01022
01023     aColumns[2] = aColumns[0];
01024     aColumns[2].iOrdinal   = 3; // third column specified above (path)
01025     aColumns[2].obValue    = 2 * sizeof (PROPVARIANT *); // offset for value
01026
01027     HACCESSOR hAccessor;
01028     hr = xIAccessor->CreateAccessor( DBACCESSOR_ROWDATA, // rowdata accessor
01029                                      cColumns,           // # of columns
01030                                      aColumns,           // columns
01031                                      0,                  // ignored
01032                                      &hAccessor,         // result
01033                                      0 );                // no status
01034     if ( FAILED( hr ) )
01035         return hr;
01036
01037     // Display the results of the query.  Print file size and file path.
01038
01039     printf( " Rank       Size  Path\n" );
01040
01041     DBCOUNTITEM cRowsSoFar = 0;
01042
01043     do
01044     {
01045         DBCOUNTITEM cRowsReturned = 0;
01046         const ULONG cRowsAtATime = 10;
01047         HROW aHRow[cRowsAtATime];
01048         HROW * pgrHRows = aHRow;
01049         hr = xIRowset->GetNextRows( 0,              // no chapter
01050                                     0,              // no rows to skip
01051                                     cRowsAtATime,   // # rows to get
01052                                     &cRowsReturned, // # rows returned
01053                                     &pgrHRows);     // resulting hrows
01054
01055         if ( FAILED( hr ) )
01056             break;
01057
01058         for ( DBCOUNTITEM iRow = 0; iRow < cRowsReturned; iRow++ )
01059         {
01060             PROPVARIANT * aData[cColumns];
01061             hr = xIRowset->GetData( aHRow[iRow],  // hrow being accessed
01062                                     hAccessor,    // accessor to use
01063                                     &aData );     // resulting data
01064             if ( FAILED( hr ) )
01065                 break;
01066
01067             if ( VT_I4 ==     aData[0]->vt &&
01068                  VT_I8 ==     aData[1]->vt &&
01069                  VT_LPWSTR == aData[2]->vt )
01070                 printf( "%5d %10I64d  %ws\n",
01071                         aData[0]->lVal,
01072                         aData[1]->hVal,
01073                         aData[2]->pwszVal );
01074             else
01075                 printf( "could not retrieve a file's values\n" );
01076         }
01077
01078         if ( 0 != cRowsReturned )
01079             xIRowset->ReleaseRows( cRowsReturned, // # of rows to release
01080                                    aHRow,         // rows to release
01081                                    0,             // no options
01082                                    0,             // no refcounts
01083                                    0 );           // no status
01084
01085         if ( DB_S_ENDOFROWSET == hr || DB_S_ROWLIMITEXCEEDED == hr )
01086         {
01087             hr = S_OK; // succeeded, return S_OK from DoQuery
01088             break;
01089         }
01090
01091         if ( FAILED( hr ) )
01092             break;
01093
01094         cRowsSoFar += cRowsReturned;
01095     } while ( TRUE );
01096
01097     printf( "%d files matched the query '%ws'\n",
01098             cRowsSoFar,
01099             pwcQueryRestriction );
01100
01101     xIAccessor->ReleaseAccessor( hAccessor, 0 );
01102
01103     return hr;
01104 } //DoQuery
01105
01106 //+-------------------------------------------------------------------------
01107 //
01108 //  Function:   Usage
01109 //
01110 //  Synopsis:   Displays information about how to use the app and exits
01111 //
01112 //--------------------------------------------------------------------------
01113
01114 void Usage()
01115 {
01116     printf( "usage: ADVQUERY query [/c:catalog] [/m:machine] [/s:scope] [/d]\n\n" );
01117     printf( "    query        word or phrase used for the search\n" );
01118     printf( "    /c:catalog   name of the catalog, default is SYSTEM\n" );
01119     printf( "    /m:machine   name of the machine, default is local machine\n" );
01120     printf( "    /s:scope     root path, default is entire catalog (\\) \n" );
01121     printf( "    /d           display the DBCOMMANDTREE, default is off\n" );
01122     exit( -1 );
01123 } //Usage
01124
01125 //+-------------------------------------------------------------------------
01126 //
01127 //  Function:   wmain
01128 //
01129 //  Synopsis:   Entry point for the app.  Parses command line arguments
01130 //              and issues a query.
01131 //
01132 //  Arguments:  [argc]     - Argument count
01133 //              [argv]     - Arguments
01134 //
01135 //--------------------------------------------------------------------------
01136
01137 extern "C" int __cdecl wmain( int argc, WCHAR * argv[] )
01138 {
01139     WCHAR const * pwcScope       = L"\\";     // default scope: entire catalog
01140     WCHAR const * pwcCatalog     = L"system"; // default: system catalog
01141     WCHAR const * pwcMachine     = L".";      // default: local machine
01142     WCHAR const * pwcRestriction = 0;         // no default restriction
01143     BOOL fDisplayTree            = FALSE;     // don't display the tree
01144
01145     // Parse command line parameters
01146
01147     for ( int i = 1; i < argc; i++ )
01148     {
01149         if ( L'-' == argv[i][0] || L'/' == argv[i][0] )
01150         {
01151             WCHAR wc = towupper( argv[i][1] );
01152
01153             if ( ':' != argv[i][2] && 'D' != wc )
01154                 Usage();
01155
01156             if ( 'C' == wc )
01157                 pwcCatalog = argv[i] + 3;
01158             else if ( 'M' == wc )
01159                 pwcMachine = argv[i] + 3;
01160             else if ( 'S' == wc )
01161                 pwcScope = argv[i] + 3;
01162             else if ( 'D' == wc )
01163                 fDisplayTree = TRUE;
01164             else
01165                 Usage();
01166         }
01167         else if ( 0 != pwcRestriction )
01168             Usage();
01169         else
01170             pwcRestriction = argv[i];
01171     }
01172
01173     // A query restriction is necessary.  Fail if none is given.
01174
01175     if ( 0 == pwcRestriction )
01176         Usage();
01177
01178     // Initialize COM
01179
01180     HRESULT hr = CoInitialize( 0 );
01181
01182     if ( SUCCEEDED( hr ) )
01183     {
01184         // Run the query
01185
01186         hr = DoQuery( pwcScope,
01187                       pwcCatalog,
01188                       pwcMachine,
01189                       pwcRestriction,
01190                       fDisplayTree );
01191
01192         CoUninitialize();
01193     }
01194
01195     if ( FAILED( hr ) )
01196     {
01197         printf( "the query '%ws' failed with error %#x\n",
01198                 pwcRestriction, hr );
01199         return -1;
01200     }
01201
01202     return 0;
01203 } //wmain
01204
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagBRUSHSTYLELOOKUP Member List

This is the complete list of members for tagBRUSHSTYLELOOKUP, including all inherited members.
iBrushStyle | tagBRUSHSTYLELOOKUP
wMenuItem | tagBRUSHSTYLELOOKUP
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/comp.h Source File

  • SysMgmt
  • MMC
  • WMI

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent,
00025 IExtendPropertySheet2
00026 {
00027 private:
00028     ULONG       m_cref;
00029
00030     IConsole*   m_ipConsole;
00031
00032     class CComponentData *m_pComponentData;
00033
00034     public:
00035         CComponent(CComponentData *parent);
00036         ~CComponent();
00037
00038         ///////////////////////////////
00039         // Interface IUnknown
00040         ///////////////////////////////
00041         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042         STDMETHODIMP_(ULONG) AddRef();
00043         STDMETHODIMP_(ULONG) Release();
00044
00045         ///////////////////////////////
00046         // Interface IComponent
00047         ///////////////////////////////
00048         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00049             /* [in] */ LPCONSOLE lpConsole);
00050
00051             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00052             /* [in] */ LPDATAOBJECT lpDataObject,
00053             /* [in] */ MMC_NOTIFY_TYPE event,
00054             /* [in] */ LPARAM arg,
00055             /* [in] */ LPARAM param);
00056
00057             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00058             /* [in] */ MMC_COOKIE cookie);
00059
00060             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00061             /* [in] */ MMC_COOKIE cookie,
00062             /* [in] */ DATA_OBJECT_TYPES type,
00063             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00064
00065             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00066             /* [in] */ MMC_COOKIE cookie,
00067             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00068             /* [out] */ long __RPC_FAR *pViewOptions);
00069
00070             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00071             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00072
00073             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00074             /* [in] */ LPDATAOBJECT lpDataObjectA,
00075             /* [in] */ LPDATAOBJECT lpDataObjectB);
00076
00077             //////////////////////////////////
00078             // Interface IExtendPropertySheet2
00079             //////////////////////////////////
00080             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreatePropertyPages(
00081             /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00082             /* [in] */ LONG_PTR handle,
00083             /* [in] */ LPDATAOBJECT lpIDataObject);
00084
00085             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryPagesFor(
00086             /* [in] */ LPDATAOBJECT lpDataObject);
00087
00088             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetWatermarks(
00089             /* [in] */ LPDATAOBJECT lpIDataObject,
00090             /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00091             /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00092             /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00093             /* [out] */ BOOL __RPC_FAR *bStretch);
00094 };
00095
00096 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CObjSecurity Member List

This is the complete list of members for CObjSecurity, including all inherited members.
CObjSecurity() | CObjSecurity | [inline]
GetAccessRights(const GUID *pguidObjectType, DWORD dwFlags, PSI_ACCESS *ppAccess, ULONG *pcAccesses, ULONG *piDefaultAccess) | CObjSecurity |
GetInheritTypes(PSI_INHERIT_TYPE *ppInheritTypes, ULONG *pcInheritTypes) | CObjSecurity |
GetObjectInformation(PSI_OBJECT_INFO pObjectInfo) | CObjSecurity |
GetSecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR *ppSD, BOOL fDefault) | CObjSecurity |
Initialize(DWORD dwFlags, PSECURITY_DESCRIPTOR *ppSD, WORD wClient, LPCWSTR pszServer, BOOL fContainer) | CObjSecurity |
m_cRef | CObjSecurity | [protected]
m_dwSIFlags | CObjSecurity | [protected]
m_ppSD | CObjSecurity | [protected]
m_pszObjectName | CObjSecurity | [protected]
m_pszServerName | CObjSecurity | [protected]
m_wClient | CObjSecurity | [protected]
MapGeneric(const GUID *pguidObjectType, UCHAR *pAceFlags, ACCESS_MASK *pmask) | CObjSecurity |
PropertySheetPageCallback(HWND hwnd, UINT uMsg, SI_PAGE_TYPE uPage) | CObjSecurity |
QueryInterface(REFIID, LPVOID *) | CObjSecurity |
SetSecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR pSD) | CObjSecurity |
STDMETHOD_(ULONG, AddRef)() | CObjSecurity |
STDMETHOD_(ULONG, Release)() | CObjSecurity |
~CObjSecurity() | CObjSecurity | [virtual]
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocServe/CRUCAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocServe

CRUCAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CRUCAR.CPP
00003
00004   Summary:   Implementation file for the aggregatable COCruiseCar COM
00005              object class.
00006
00007              CRUCAR showcases the construction of the COCruiseCar COM
00008              object class with the IUnknown, ICar, and ICruise interfaces.
00009              This is done through Aggregation reuse of COCar's ICar
00010              interface features.  This multiple interface COM Object Class
00011              is achieved via the technique of nested classes.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial LOCSERVE.HTM file.
00015              For more specific technical details on the internal workings
00016              see the comments dispersed throughout the module's source code.
00017
00018   Classes:   COCruiseCar.
00019
00020   Functions: none.
00021
00022   Origin:    11-14-95: atrent - Editor-inheritance from CRUCAR.CPP in
00023                the DLLSERVE Tutorial Code Sample.
00024
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040 /*---------------------------------------------------------------------------
00041   We include WINDOWS.H for all Win32 applications.
00042   We include OLE2.H because we will be calling the COM/OLE Libraries.
00043   We include APPUTIL.H because we will be building this application using
00044     the convenient Virtual Window and Dialog classes and other
00045     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00046   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00047     class, GUID, and CLSID specifications.
00048   We include SERVER.H because it has the necessary internal class and
00049     resource definitions for this DLL.
00050   We include CAR.H because it has the class COCar declarations.
00051   We include CRUCAR.H because it has the class COCruiseCar declarations.
00052 ---------------------------------------------------------------------------*/
00053 #include <windows.h>
00054 #include <ole2.h>
00055 #include <apputil.h>
00056 #include <micars.h>
00057 #include <carguids.h>
00058 #include "server.h"
00059 #include "car.h"
00060 #include "crucar.h"
00061
00062
00063 /*---------------------------------------------------------------------------
00064   COCruiseCar's implementation of its main COM object class including
00065   Constructor, Destructor, QueryInterface, AddRef, and Release.
00066 ---------------------------------------------------------------------------*/
00067
00068 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00069   Method:   COCruiseCar::COCruiseCar
00070
00071   Summary:  COCruiseCar Constructor. Note the member initializer:
00072             "m_ImpICruise(this, pUnkOuter)" which is used to pass the
00073             'this' and pUnkOuter pointers of this constructor function
00074             to the constructor in the instantiation of the implementation
00075             of the CImpICruise interface (which is nested inside this
00076             present COCruiseCar Object Class).
00077
00078   Args:     IUnknown* pUnkOuter,
00079               Pointer to the the outer Unknown.  NULL means this COM Object
00080               is not being Aggregated.  Non NULL means it is being created
00081               on behalf of an outside COM object that is reusing it via
00082               aggregation.
00083             CServer* pServer)
00084               Pointer to the server's control object.
00085
00086   Modifies: m_cRefs, m_pUnkOuter.
00087
00088   Returns:  void
00089 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00090 COCruiseCar::COCruiseCar(
00091   IUnknown* pUnkOuter,
00092   CServer* pServer) :
00093   m_ImpICruise(this, pUnkOuter)
00094 {
00095   // Zero the COM object's reference count.
00096   m_cRefs = 0;
00097
00098   // No AddRef necessary if non-NULL, as this present COM object's lifetime
00099   // is totally coupled with the controlling Outer object's lifetime.
00100   m_pUnkOuter = pUnkOuter;
00101
00102   // Zero the pointer to the aggregated COCar object's IUnknown
00103   // interface (for delegation of IUnknown calls to it).
00104   m_pUnkCar = NULL;
00105
00106   // Assign the pointer to the server's control object.
00107   m_pServer = pServer;
00108
00109   LOGF1("L: COCruiseCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00110
00111   return;
00112 }
00113
00114
00115 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00116   Method:   COCruiseCar::~COCruiseCar
00117
00118   Summary:  COCruiseCar Destructor.
00119
00120   Args:     void
00121
00122   Modifies: .
00123
00124   Returns:  void
00125 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00126 COCruiseCar::~COCruiseCar(void)
00127 {
00128   LOG("L: COCruiseCar::Destructor.");
00129
00130   // Release the aggragated COCar object.
00131   RELEASE_INTERFACE(m_pUnkCar);
00132
00133   return;
00134 }
00135
00136
00137 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00138   Method:   COCruiseCar::Init
00139
00140   Summary:  COCruiseCar Initialization method.  Creates any subordinate
00141             COM objects.
00142
00143   Args:     void
00144
00145   Modifies: m_pUnkCar, m_pICar, m_cRefs.
00146
00147   Returns:  HRESULT
00148               Standard result code. NOERROR for success.
00149 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00150 HRESULT COCruiseCar::Init(void)
00151 {
00152   HRESULT hr;
00153
00154   LOG("L: COCruiseCar::Init.");
00155
00156   // Set up the right pIUnknown for delegation.  If we are being
00157   // aggregated then we pass the pUnkOuter in turn to any COM objects
00158   // that we are aggregating.  m_pUnkOuter was set in the Constructor.
00159   IUnknown* pUnkOuter = (NULL == m_pUnkOuter) ? this : m_pUnkOuter;
00160
00161   // We create an instance of the COCar object and do this via the
00162   // Aggregation reuse technique.  Note we pass pUnkOuter as the
00163   // Aggregation pointer.  It is the 'this' pointer to this present
00164   // CruiseCar object if we are not being aggregated; otherwise it is the
00165   // pointer to the outermost object's controlling IUnknown.  Following
00166   // the rules of Aggregation we must ask for an IID_IUnknown interface.
00167   // We cache the requested  pointer to the IUnknown of the new COCar COM
00168   // object for later use in delegating IUnknown calls. Since we know that
00169   // this LocCar component is housed in this very same server, we can
00170   // specify an execution context of CLSCTX_INPROC_SERVER. This allows us
00171   // to aggregate the COCar COM object. Though the object is in a local
00172   // server, it will be instantiated and run within the same process of
00173   // this present local server. If we specify CLSCTX_LOCAL_SERVER, COM
00174   // will not currently permit the creation using aggregation across
00175   // process boundaries and CoCreateInstance would return an error.
00176   hr = CoCreateInstance(
00177          CLSID_LocCar,
00178          pUnkOuter,
00179          CLSCTX_INPROC_SERVER,
00180          IID_IUnknown,
00181          (PPVOID)&m_pUnkCar);
00182
00183   if (SUCCEEDED(hr))
00184   {
00185     LOG("L: COCruiseCar::Init (New Aggregation of COCar) Succeeded.");
00186   }
00187   else
00188   {
00189     LOGERROR("L: COCruiseCar::Init (New Containment of COCar)",hr);
00190   }
00191
00192   return (hr);
00193 }
00194
00195
00196 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00197   Method:   COCruiseCar::QueryInterface
00198
00199   Summary:  QueryInterface of the COCruiseCar non-delegating
00200             IUnknown implementation.
00201
00202   Args:     REFIID riid,
00203               [in] GUID of the Interface being requested.
00204             PPVOID ppv)
00205               [out] Address of the caller's pointer variable that will
00206               receive the requested interface pointer.
00207
00208   Modifies: *ppv.
00209
00210   Returns:  HRESULT
00211 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00212 STDMETHODIMP COCruiseCar::QueryInterface(
00213                REFIID riid,
00214                PPVOID ppv)
00215 {
00216   HRESULT hr = E_NOINTERFACE;
00217   *ppv = NULL;
00218
00219   if (IID_IUnknown == riid)
00220   {
00221     *ppv = this;
00222     LOG("L: COCruiseCar::QueryInterface. 'this' pIUnknown returned.");
00223   }
00224   else if (IID_ICruise == riid)
00225   {
00226     // This ICruise interface is implemented in this COCruiseCar object and
00227     // might be called a native interface of COCruiseCar.
00228     *ppv = &m_ImpICruise;
00229     LOG("L: COCruiseCar::QueryInterface. pICruise returned.");
00230   }
00231
00232   if (NULL != *ppv)
00233   {
00234     // We've handed out a pointer to an interface so obey the COM rules
00235     //   and AddRef its reference count.
00236     ((LPUNKNOWN)*ppv)->AddRef();
00237     hr = NOERROR;
00238   }
00239   else if (IID_ICar == riid)
00240   {
00241     LOG("L: COCruiseCar::QueryInterface. ICar delegating.");
00242     // We didn't implement the ICar interface in this COCruiseCar object.
00243     // The aggregated inner COCar object is contributing the ICar
00244     // interface to this present composite or aggregating CruiseCar object.
00245     // So, to satisfy a QI request for the ICar interface, we delegate
00246     // the QueryInterface to the inner object's principal IUnknown.
00247     hr = m_pUnkCar->QueryInterface(riid, ppv);
00248   }
00249
00250   return (hr);
00251 }
00252
00253
00254 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00255   Method:   COCruiseCar::AddRef
00256
00257   Summary:  AddRef of the COCruiseCar non-delegating IUnknown implementation.
00258
00259   Args:     void
00260
00261   Modifies: m_cRefs.
00262
00263   Returns:  ULONG
00264               New value of m_cRefs (COM object's reference count).
00265 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00266 STDMETHODIMP_(ULONG) COCruiseCar::AddRef(void)
00267 {
00268   m_cRefs++;
00269
00270   LOGF1("L: COCruiseCar::AddRef. New cRefs=%i.", m_cRefs);
00271
00272   return m_cRefs;
00273 }
00274
00275
00276 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00277   Method:   COCruiseCar::Release
00278
00279   Summary:  Release of the COCruiseCar non-delegating IUnknown
00280             implementation.
00281
00282   Args:     void
00283
00284   Modifies: m_cRefs.
00285
00286   Returns:  ULONG
00287               New value of m_cRefs (COM object's reference count).
00288 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00289 STDMETHODIMP_(ULONG) COCruiseCar::Release(void)
00290 {
00291   ULONG ulCount = --m_cRefs;
00292
00293   LOGF1("L: COCruiseCar::Release. New cRefs=%i.", m_cRefs);
00294
00295   if (0 == m_cRefs)
00296   {
00297     CServer* pServer = m_pServer;
00298     // We artificially bump the main ref count.  This fulfills one of
00299     // the rules of aggregated objects and ensures that an indirect
00300     // recursive call to this release won't occur because of other
00301     // delegating releases that might happen in our own destructor.
00302     m_cRefs++;
00303     delete this;
00304
00305     // We've reached a zero reference count for this COM object.
00306     // So we tell the server housing to decrement its global object
00307     // count so that the server will be unloaded if appropriate.
00308     if (NULL != pServer)
00309       pServer->ObjectsDown();
00310   }
00311
00312   return ulCount;
00313 }
00314
00315
00316 /*---------------------------------------------------------------------------
00317   COCruiseCar's nested implementation of the ICruise interface including
00318   Constructor, Destructor, QueryInterface, AddRef, Release,
00319   Engage, and Adjust.
00320 ---------------------------------------------------------------------------*/
00321
00322 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00323   Method:   COCruiseCar::CImpICruise::CImpICruise
00324
00325   Summary:  Constructor for the CImpICruise interface instantiation.
00326
00327   Args:     COCruiseCar* pBackObj,
00328               Back pointer to the parent outer object.
00329             IUnknown* pUnkOuter)
00330               Pointer to the outer Unknown.  For delegation.
00331
00332   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00333
00334   Returns:  void
00335 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00336 COCruiseCar::CImpICruise::CImpICruise(
00337   COCruiseCar* pBackObj,
00338   IUnknown* pUnkOuter)
00339 {
00340   // Init the Interface Ref Count (used for debugging only).
00341   m_cRefI = 0;
00342
00343   // Init the Back Object Pointer to point to the outer object.
00344   m_pBackObj = pBackObj;
00345
00346   // Init the CImpICruise interface's delegating Unknown pointer.  We use
00347   // the Back Object pointer for IUnknown delegation here if we are not
00348   // being aggregated.  If we are being aggregated we use the supplied
00349   // pUnkOuter for IUnknown delegation.  In either case the pointer
00350   // assignment requires no AddRef because the CImpICruise lifetime is
00351   // quaranteed by the lifetime of the parent object in which
00352   // CImpICruise is nested.
00353   if (NULL == pUnkOuter)
00354   {
00355     m_pUnkOuter = pBackObj;
00356     LOG("L: COCruiseCar::CImpICruise Constructor. Non-Aggregating.");
00357   }
00358   else
00359   {
00360     m_pUnkOuter = pUnkOuter;
00361     LOG("L: COCruiseCar::CImpICruise Constructor. Aggregating.");
00362   }
00363
00364   return;
00365 }
00366
00367
00368 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00369   Method:   COCruiseCar::CImpICruise::~CImpICruise
00370
00371   Summary:  Destructor for the CImpICruise interface instantiation.
00372
00373   Args:     void
00374
00375   Modifies: .
00376
00377   Returns:  void
00378 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00379 COCruiseCar::CImpICruise::~CImpICruise(void)
00380 {
00381   LOG("L: COCruiseCar::CImpICruise Destructor.");
00382
00383   return;
00384 }
00385
00386
00387 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00388   Method:   COCruiseCar::CImpICruise::QueryInterface
00389
00390   Summary:  The QueryInterface IUnknown member of this ICruise interface
00391             implementation that delegates to m_pUnkOuter, whatever it is.
00392
00393   Args:     REFIID riid,
00394               [in] GUID of the Interface being requested.
00395             PPVOID ppv)
00396               [out] Address of the caller's pointer variable that will
00397               receive the requested interface pointer.
00398
00399   Modifies: .
00400
00401   Returns:  HRESULT
00402               Returned by the delegated outer QueryInterface call.
00403 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00404 STDMETHODIMP COCruiseCar::CImpICruise::QueryInterface(
00405                REFIID riid,
00406                PPVOID ppv)
00407 {
00408   LOG("L: COCruiseCar::CImpICruise::QueryInterface. Delegating.");
00409
00410   // Delegate this call to the outer object's QueryInterface.
00411   return m_pUnkOuter->QueryInterface(riid, ppv);
00412 }
00413
00414
00415 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00416   Method:   COCruiseCar::CImpICruise::AddRef
00417
00418   Summary:  The AddRef IUnknown member of this ICruise interface
00419             implementation that delegates to m_pUnkOuter, whatever it is.
00420
00421   Args:     void
00422
00423   Modifies: m_cRefI.
00424
00425   Returns:  ULONG
00426               Returned by the delegated outer AddRef call.
00427 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00428 STDMETHODIMP_(ULONG) COCruiseCar::CImpICruise::AddRef(void)
00429 {
00430   // Increment the Interface Reference Count.
00431   ++m_cRefI;
00432
00433   LOGF1("L: COCruiseCar::CImpICruise::Addref. Delegating. New cI=%i.", m_cRefI);
00434
00435   // Delegate this call to the outer object's AddRef.
00436   return m_pUnkOuter->AddRef();
00437 }
00438
00439
00440 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00441   Method:   COCruiseCar::CImpICruise::Release
00442
00443   Summary:  The Release IUnknown member of this ICruise interface
00444             implementation that delegates to m_pUnkOuter, whatever it is.
00445
00446   Args:     void
00447
00448   Modifies: m_cRefI.
00449
00450   Returns:  ULONG
00451               Returned by the delegated outer Release call.
00452 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00453 STDMETHODIMP_(ULONG) COCruiseCar::CImpICruise::Release(void)
00454 {
00455   // Decrement the Interface Reference Count.
00456   --m_cRefI;
00457
00458   LOGF1("L: COCruiseCar::CImpICruise::Release. Delegating. New cI=%i.",m_cRefI);
00459
00460   // Delegate this call to the outer object's Release.
00461   return m_pUnkOuter->Release();
00462 }
00463
00464
00465 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00466   Method:   COCruiseCar::CImpICruise::Engage
00467
00468   Summary:  The Engage member method of this ICruise interface
00469             implementation.  A simple empty method on a COCruiseCar COM
00470             object for tutorial purposes.  Presumably if this Car object
00471             were modeling a real Car then the Engage method would turn
00472             the Cruise control system on or off.
00473
00474   Args:     BOOL bOnOff)
00475               TRUE for On; FALSE for Off.
00476
00477   Modifies: .
00478
00479   Returns:  HRESULT
00480               NOERROR
00481 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00482 STDMETHODIMP COCruiseCar::CImpICruise::Engage(
00483                BOOL bOnOff)
00484 {
00485   LOGF1("L: COCruiseCar::CImpICruise::Engage. Called. bOnOff=%i.",bOnOff);
00486
00487   return NOERROR;
00488 }
00489
00490
00491 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00492   Method:   COCruiseCar::CImpICruise::Adjust
00493
00494   Summary:  The Adjust member method of this ICruise interface
00495             implementation.  A simple empty method on a COCruiseCar COM
00496             object for tutorial purposes.  Presumably if this Car object
00497             were modeling a real Car then the Adjust method would allow
00498             notching the cruise set speed up or down by increments of 3 mph.
00499
00500   Args:     BOOL bUpDown)
00501               TRUE for Up; FALSE for Down.
00502
00503   Modifies: .
00504
00505   Returns:  HRESULT
00506               NOERROR
00507 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00508 STDMETHODIMP COCruiseCar::CImpICruise::Adjust(
00509                BOOL bUpDown)
00510 {
00511   LOGF1("L: COCruiseCar::CImpICruise::Adjust. Called. bUpDown=%i.",bUpDown);
00512
00513   return NOERROR;
00514 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyCapabilities/Dll.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyCapabilities

Dll.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      Dll.cpp
00005 //
00006 //  Description:
00007 //      Implementation of DLL Exports.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #include "stdafx.h"
00012 #include "resource.h"
00013 #include <initguid.h>
00014
00015 #include "MyCapabilities.h"
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP( ObjectMap )
00020 OBJECT_ENTRY( CLSID_MyCapabilities, CMyCapabilities )
00021 END_OBJECT_MAP()
00022
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //++
00026 //
00027 // DllMain
00028 //
00029 // Description:
00030 //      DLL entry point.
00031 //
00032 //--
00033 /////////////////////////////////////////////////////////////////////////////
00034 extern "C"
00035 BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/ )
00036 {
00037     if ( dwReason == DLL_PROCESS_ATTACH )
00038     {
00039         _Module.Init( ObjectMap, hInstance ); // no typelib
00040         DisableThreadLibraryCalls( hInstance );
00041     }
00042     else if ( dwReason == DLL_PROCESS_DETACH )
00043     {
00044         _Module.Term();
00045     }
00046     return TRUE;    // ok
00047
00048 } //*** DllMain
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 //++
00052 //
00053 // DllCanUnloadNow
00054 //
00055 // Description:
00056 //      Used to determine whether the DLL can be unloaded by OLE.
00057 //
00058 //--
00059 /////////////////////////////////////////////////////////////////////////////
00060 STDAPI DllCanUnloadNow( void )
00061 {
00062     return ( _Module.GetLockCount()==0 ) ? S_OK : S_FALSE;
00063
00064 } //*** DllCanUnloadNow
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 //++
00068 //
00069 // DllGetClassObject
00070 //
00071 // Description:
00072 //      Returns a class factory to create an object of the requested type.
00073 //
00074 //--
00075 /////////////////////////////////////////////////////////////////////////////
00076 STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID * ppv )
00077 {
00078     return _Module.GetClassObject( rclsid, riid, ppv );
00079
00080 } //*** DllGetClassObject
00081
00082 /////////////////////////////////////////////////////////////////////////////
00083 //++
00084 //
00085 // DllRegisterServer
00086 //
00087 // Description:
00088 //      Adds entries to the system registry.
00089 //
00090 //--
00091 /////////////////////////////////////////////////////////////////////////////
00092 STDAPI DllRegisterServer( void )
00093 {
00094     // registers object; FALSE => no typelib
00095     return _Module.RegisterServer( FALSE );
00096
00097 } //*** DllRegisterServer
00098
00099 /////////////////////////////////////////////////////////////////////////////
00100 //++
00101 //
00102 // DllUnregisterServer
00103 //
00104 // Description:
00105 //      Removes entries from the system registry.
00106 //
00107 //--
00108 /////////////////////////////////////////////////////////////////////////////
00109 STDAPI DllUnregisterServer( void )
00110 {
00111     return _Module.UnregisterServer( FALSE ); // FALSE => no typelib
00112
00113 } //*** DllUnregisterServer
00114
00115
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/usersub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

usersub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __USERSUB_H__
00018 #define __USERSUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CUserSub
00028 Summary: User Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CUserSub :
00031   public CSysLCESub,
00032   public IComUserEvent
00033 {
00034 public:
00035
00036   CUserSub(CComSpy * pSpy)
00037   {
00038     m_pSpy = pSpy;
00039   }
00040   CUserSub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045   DECLARE_NOT_AGGREGATABLE(CUserSub)
00046   DECLARE_GET_CONTROLLING_UNKNOWN()
00047
00048   BEGIN_COM_MAP(CUserSub)
00049     COM_INTERFACE_ENTRY(IComUserEvent)
00050     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00051   END_COM_MAP()
00052
00053   STDMETHODIMP GetEventType(EventEnum * e){*e = User;return S_OK;}
00054   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00055   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComUserEvent;return S_OK;}
00056
00057   STDMETHODIMP OnUserEvent(COMSVCSEVENTINFO * pInfo, VARIANT * var)
00058   {
00059     if (var -> vt == VT_BSTR)
00060     {
00061       m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnUserEvent"), GuidToBstr(pInfo->guidApp));
00062       m_pSpy -> AddParamValueToList(L"String Value",  var->bstrVal);
00063     }
00064     else if (var -> vt == VT_UNKNOWN)
00065     {
00066       IMtsEventInfo * pEvtInfo = NULL;
00067
00068       var -> punkVal -> QueryInterface(IID_IMtsEventInfo, (void **)&pEvtInfo);
00069       if(pEvtInfo)
00070       {
00071         CComBSTR s;
00072         pEvtInfo -> get_DisplayName(&s.m_str);
00073         m_pSpy -> AddEventToList(pInfo->perfCount, s.m_str, GuidToBstr(pInfo->guidApp));
00074
00075         long lCount;
00076         pEvtInfo -> get_Count(&lCount);
00077         if (lCount)
00078         {
00079           VARIANT var;
00080           LPOLESTR * pKeys = new LPOLESTR[lCount+1];
00081           IUnknown * pUnk = NULL;
00082           pEvtInfo -> get_Names(&pUnk);
00083           _ASSERTE(pUnk);
00084           IEnumString * pEnum;
00085           pUnk -> QueryInterface(IID_IEnumString, (void **)&pEnum);
00086           _ASSERTE(pEnum);
00087           pUnk -> Release();
00088           ULONG lFetched;
00089           pEnum -> Next(lCount, pKeys, &lFetched);
00090           pEnum -> Release();
00091           _ASSERTE(lFetched == lCount);
00092           UINT i;
00093           for (i=0; i<lFetched; i++)
00094           {
00095             s = pKeys[i];
00096             pEvtInfo -> get_Value(s, &var);
00097             if (var.vt == VT_BSTR)
00098             {
00099               m_pSpy -> AddParamValueToList(pKeys[i],  var.bstrVal);
00100               VariantClear(&var);
00101             }
00102           }
00103           for (i=0;i<lCount;i++)
00104             CoTaskMemFree(pKeys[i]);
00105
00106           delete pKeys;
00107         }
00108         pEvtInfo -> Release();
00109       }
00110     }
00111     else
00112       m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnUserEvent"), GuidToBstr(pInfo->guidApp));
00113
00114
00115     return S_OK;
00116   }
00117
00118 };
00119
00120 #endif //__USERSUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/SampleMSP/SampStrm.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • SampleMSP

SampStrm.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sampstrm.h
00008
00009 Abstract:
00010
00011     Declaration of the sample MSP stream class.
00012
00013 --*/
00014
00015 #ifndef __SAMPSTRM_H_
00016 #define __SAMPSTRM_H_
00017
00018 #if _MSC_VER >= 1000
00019 #pragma once
00020 #endif // _MSC_VER >= 1000
00021
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // CSampleMSPStream
00025 /////////////////////////////////////////////////////////////////////////////
00026 class CSampleMSPStream : public CMSPStream
00027     //  if you want to allow your object to be used in scripting apps
00028     //  it has to expose IObjectSafety interface. if your object is safe for
00029     //  scripting on all of its interfaces, you can use the implementation
00030     //  of IObjectSafety from MSPUtils.h
00031     //, public CMSPObjectSafetyImpl
00032
00033 {
00034 public:
00035 // DECLARE_POLY_AGGREGATABLE(CSampleMSP)
00036
00037 // To add extra interfaces to this class, use the following:
00038 // BEGIN_COM_MAP(CSampleMSPStream)
00039 //     COM_INTERFACE_ENTRY( YOUR_INTERFACE_HERE )
00040 //     // if you want to allow your object to be used in scripting apps
00041 //     // it has to expose IObjectSafety interface
00042 //     // COM_INTERFACE_ENTRY( IObjectSafety )
00043 //     COM_INTERFACE_ENTRY_CHAIN(CMSPStream)
00044 // END_COM_MAP()
00045
00046 public:
00047
00048     //
00049     // Construction and destruction.
00050     //
00051
00052     CSampleMSPStream();
00053     virtual ~CSampleMSPStream();
00054     virtual void FinalRelease();
00055
00056     //
00057     // Required base class overrides.
00058     //
00059
00060     STDMETHOD (get_Name) (
00061         OUT     BSTR *                  ppName
00062         );
00063
00064     //
00065     // We override these methods to implement our terminal handling.
00066     // This consists of only allowing one terminal on the stream at a time
00067     // and adding our filters and the terminal to the graph at the right
00068     // times.
00069     //
00070
00071     STDMETHOD (SelectTerminal) (
00072         IN      ITTerminal *            pTerminal
00073         );
00074
00075     STDMETHOD (UnselectTerminal) (
00076         IN     ITTerminal *             pTerminal
00077         );
00078
00079     STDMETHOD (StartStream) ();
00080
00081     STDMETHOD (PauseStream) ();
00082
00083     STDMETHOD (StopStream) ();
00084
00085     //
00086     // Overrides for event handling.
00087     //
00088
00089     virtual HRESULT ProcessGraphEvent(
00090         IN  long lEventCode,
00091         IN  long lParam1,
00092         IN  long lParam2
00093         );
00094
00095     //
00096     // Public methods specific to our implementation.
00097     //
00098
00099     virtual HRESULT FireEvent(IN MSP_CALL_EVENT        type,
00100                               IN HRESULT               hrError,
00101                               IN MSP_CALL_EVENT_CAUSE  cause);
00102
00103     // A real MSP would have some arguments to this method,
00104     // which would then be used to configure transport filters. For example,
00105     // an MSP whose transports are wavein and waveout filters might have
00106     // WaveInIDs and WaveOutIDs passed as arguments to this method.
00107     virtual HRESULT ConfigureTransport(void);
00108
00109 protected:
00110     //
00111     // Protected data members.
00112     // A real MSP stream will have more... such as pointers to filters.
00113     //
00114
00115     BOOL          m_fTransportConfigured;
00116     BOOL          m_fTerminalConnected;
00117     FILTER_STATE  m_DesiredGraphState;
00118     FILTER_STATE  m_ActualGraphState;
00119
00120 private:
00121     //
00122     // Private helper methods.
00123     //
00124
00125     HRESULT ConnectTerminal(ITTerminal * pTerminal);
00126     HRESULT ConnectToTerminalPin(IPin * pTerminalPin);
00127 };
00128
00129 #endif //__SAMPSTRM_H_
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/ioips.h Source File

  • Com
  • Fundamentals
  • SimpCntr

ioips.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOIPS.H
00003 //
00004 //      Definition of COleInPlaceSite
00005 //
00006 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IOIPS_H_ )
00009 #define _IOIPS_H_
00010
00011
00012 class CSimpleSite;
00013
00014 interface COleInPlaceSite : public IOleInPlaceSite
00015 {
00016   int m_nCount;
00017   CSimpleSite FAR * m_pSite;
00018
00019   COleInPlaceSite(CSimpleSite FAR *pSite) {
00020     OutputDebugString("In IOIPS's constructor\r\n");
00021     m_pSite = pSite;
00022     m_nCount = 0;
00023     };
00024
00025   ~COleInPlaceSite() {
00026     OutputDebugString("In IOIPS;s destructor\r\n");
00027     assert(m_nCount == 0);
00028     };
00029
00030   STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
00031   STDMETHODIMP_(ULONG) AddRef ();
00032   STDMETHODIMP_(ULONG) Release ();
00033
00034   STDMETHODIMP GetWindow (HWND FAR* lphwnd);
00035   STDMETHODIMP ContextSensitiveHelp (BOOL fEnterMode);
00036
00037   // *** IOleInPlaceSite methods ***
00038   STDMETHODIMP CanInPlaceActivate ();
00039   STDMETHODIMP OnInPlaceActivate ();
00040   STDMETHODIMP OnUIActivate ();
00041   STDMETHODIMP GetWindowContext (LPOLEINPLACEFRAME FAR* lplpFrame,
00042                    LPOLEINPLACEUIWINDOW FAR* lplpDoc,
00043                    LPRECT lprcPosRect,
00044                    LPRECT lprcClipRect,
00045                    LPOLEINPLACEFRAMEINFO lpFrameInfo);
00046   STDMETHODIMP Scroll (SIZE scrollExtent);
00047   STDMETHODIMP OnUIDeactivate (BOOL fUndoable);
00048   STDMETHODIMP OnInPlaceDeactivate ();
00049   STDMETHODIMP DiscardUndoState ();
00050   STDMETHODIMP DeactivateAndUndo ();
00051   STDMETHODIMP OnPosRectChange (LPCRECT lprcPosRect);
00052 };
00053
00054 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Binding/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Binding
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__A434B1A0_B00B_11D2_9A74_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__A434B1A0_B00B_11D2_9A74_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__A434B1A0_B00B_11D2_9A74_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/UtilLib/PreComp.h Source File

  • SysMgmt
  • WMI
  • VC
  • UtilLib

PreComp.h

Go to the documentation of this file.
00001 //
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 // All Rights Reserved.
00005 //
00006 #define _WIN32_DCOM
00007
00008
00009 #pragma warning (disable : 4786)
00010 #include <ole2.h>
00011 #include <windows.h>
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/ADOVCGEN/datagrid.h Source File

  • Dataaccess
  • ADO
  • ADOVCGEN

datagrid.h

Go to the documentation of this file.
00001 #if !defined(AFX_DATAGRID_H__907B38E2_C700_492E_AEC1_F3CC138BEF29__INCLUDED_)
00002 #define AFX_DATAGRID_H__907B38E2_C700_492E_AEC1_F3CC138BEF29__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00008
00009 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00010 //  Microsoft Visual C++, your modifications will be overwritten.
00011
00012 /////////////////////////////////////////////////////////////////////////////
00013 // CDataGrid wrapper class
00014
00015 class CDataGrid : public CWnd
00016 {
00017 protected:
00018   DECLARE_DYNCREATE(CDataGrid)
00019 public:
00020   CLSID const& GetClsid()
00021   {
00022     static CLSID const clsid
00023       = { 0xcde57a43, 0x8b86, 0x11d0, { 0xb3, 0xc6, 0x0, 0xa0, 0xc9, 0xa, 0xea, 0x82 } };
00024     return clsid;
00025   }
00026   virtual BOOL Create(LPCTSTR lpszClassName,
00027     LPCTSTR lpszWindowName, DWORD dwStyle,
00028     const RECT& rect,
00029     CWnd* pParentWnd, UINT nID,
00030     CCreateContext* pContext = NULL)
00031   { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); }
00032
00033     BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
00034     const RECT& rect, CWnd* pParentWnd, UINT nID,
00035     CFile* pPersist = NULL, BOOL bStorage = FALSE,
00036     BSTR bstrLicKey = NULL)
00037   { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
00038     pPersist, bStorage, bstrLicKey); }
00039
00040 // Attributes
00041 public:
00042
00043 // Operations
00044 public:
00045   long GetAddNewMode();
00046   BOOL GetAllowAddNew();
00047   void SetAllowAddNew(BOOL bNewValue);
00048   BOOL GetAllowArrows();
00049   void SetAllowArrows(BOOL bNewValue);
00050   BOOL GetAllowDelete();
00051   void SetAllowDelete(BOOL bNewValue);
00052   BOOL GetAllowRowSizing();
00053   void SetAllowRowSizing(BOOL bNewValue);
00054   BOOL GetAllowUpdate();
00055   void SetAllowUpdate(BOOL bNewValue);
00056   long GetAppearance();
00057   void SetAppearance(long nNewValue);
00058   long GetApproxCount();
00059   unsigned long GetBackColor();
00060   void SetBackColor(unsigned long newValue);
00061   VARIANT GetBookmark();
00062   void SetBookmark(const VARIANT& newValue);
00063   long GetBorderStyle();
00064   void SetBorderStyle(long nNewValue);
00065   CString GetCaption();
00066   void SetCaption(LPCTSTR lpszNewValue);
00067   short GetCol();
00068   void SetCol(short nNewValue);
00069   BOOL GetColumnHeaders();
00070   void SetColumnHeaders(BOOL bNewValue);
00071   BOOL GetCurrentCellModified();
00072   void SetCurrentCellModified(BOOL bNewValue);
00073   BOOL GetCurrentCellVisible();
00074   void SetCurrentCellVisible(BOOL bNewValue);
00075   BOOL GetDataChanged();
00076   void SetDataChanged(BOOL bNewValue);
00077   LPUNKNOWN GetDataSource();
00078   void SetRefDataSource(LPUNKNOWN newValue);
00079   CString GetDataMember();
00080   void SetDataMember(LPCTSTR lpszNewValue);
00081   float GetDefColWidth();
00082   void SetDefColWidth(float newValue);
00083   BOOL GetEditActive();
00084   void SetEditActive(BOOL bNewValue);
00085   BOOL GetEnabled();
00086   void SetEnabled(BOOL bNewValue);
00087   CString GetErrorText();
00088   LPDISPATCH GetFont();
00089   void SetRefFont(LPDISPATCH newValue);
00090   unsigned long GetForeColor();
00091   void SetForeColor(unsigned long newValue);
00092   VARIANT GetFirstRow();
00093   void SetFirstRow(const VARIANT& newValue);
00094   LPDISPATCH GetHeadFont();
00095   void SetRefHeadFont(LPDISPATCH newValue);
00096   float GetHeadLines();
00097   void SetHeadLines(float newValue);
00098   long GetHWnd();
00099   long GetHWndEditor();
00100   short GetLeftCol();
00101   void SetLeftCol(short nNewValue);
00102   long GetMarqueeStyle();
00103   void SetMarqueeStyle(long nNewValue);
00104   BOOL GetRecordSelectors();
00105   void SetRecordSelectors(BOOL bNewValue);
00106   BOOL GetRightToLeft();
00107   void SetRightToLeft(BOOL bNewValue);
00108   short GetRow();
00109   void SetRow(short nNewValue);
00110   long GetRowDividerStyle();
00111   void SetRowDividerStyle(long nNewValue);
00112   float GetRowHeight();
00113   void SetRowHeight(float newValue);
00114   long GetScrollBars();
00115   void SetScrollBars(long nNewValue);
00116   short GetSelEndCol();
00117   void SetSelEndCol(short nNewValue);
00118   long GetSelLength();
00119   void SetSelLength(long nNewValue);
00120   long GetSelStart();
00121   void SetSelStart(long nNewValue);
00122   short GetSelStartCol();
00123   void SetSelStartCol(short nNewValue);
00124   CString GetSelText();
00125   void SetSelText(LPCTSTR lpszNewValue);
00126   short GetSplit();
00127   void SetSplit(short nNewValue);
00128   BOOL GetTabAcrossSplits();
00129   void SetTabAcrossSplits(BOOL bNewValue);
00130   long GetTabAction();
00131   void SetTabAction(long nNewValue);
00132   CString GetText();
00133   void SetText(LPCTSTR lpszNewValue);
00134   short GetVisibleCols();
00135   short GetVisibleRows();
00136   BOOL GetWrapCellPointer();
00137   void SetWrapCellPointer(BOOL bNewValue);
00138   LPDISPATCH GetDataFormats();
00139   LPDISPATCH CaptureImage();
00140   void ClearSelCols();
00141   void ClearFields();
00142   short ColContaining(float X);
00143   LPDISPATCH GetColumns();
00144   VARIANT GetBookmark(long RowNum);
00145   void HoldFields();
00146   void ReBind();
00147   void Refresh();
00148   VARIANT RowBookmark(short RowNum);
00149   short RowContaining(float Y);
00150   float RowTop(short RowNum);
00151   void Scroll(long Cols, long Rows);
00152   LPDISPATCH GetSelBookmarks();
00153   short SplitContaining(float X, float Y);
00154   LPDISPATCH GetSplits();
00155 };
00156
00157 //{{AFX_INSERT_LOCATION}}
00158 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00159
00160 #endif // !defined(AFX_DATAGRID_H__907B38E2_C700_492E_AEC1_F3CC138BEF29__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/tree.h Source File

  • Begin
  • sdkdiff

tree.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010 #ifndef __TREE_H__
00011 #define __TREE_H__
00012 /*
00013  * tree.h
00014  *
00015  * data type providing a map from a key to a value, where the value is
00016  * an arbitrary area of storage.
00017  *
00018  * The current implementation of this is a binary search tree with no
00019  * balancing, so it will be inefficient if the data is presented in
00020  * strict ascending or descending order.
00021  *
00022  * include gutils.h before this.
00023  */
00024
00025 /* handle for a tree */
00026 typedef struct tree FAR * TREE;
00027
00028 /* keys in these trees are DWORDs */
00029 typedef DWORD TREEKEY;
00030
00031 /* some sort of place-holder understood only by tree_search and
00032  * tree_addafter
00033  */
00034 typedef struct treeitem FAR * TREEITEM;
00035
00036 /* pointer to one of these place holders */
00037 typedef TREEITEM FAR * PTREEITEM;
00038
00039
00040
00041 /*
00042  * create an empty tree and return a handle to it.
00043  */
00044 TREE APIENTRY tree_create();
00045
00046
00047 /* delete a tree and discard any associated memory. The tree need not be
00048  * empty. This will discard the elements of the tree; but if these
00049  * contained pointers to further data blocks, these will not be discarded-
00050  * you must free these before deleting the tree.
00051  */
00052 void APIENTRY tree_delete(TREE tree);
00053
00054
00055 /* add new element to the tree, mapping the key given to the value
00056  *
00057  * a block of data of length bytes will be inserted in the tree, mapped
00058  * to this key, a pointer to this block will be returned. if the
00059  * value pointer is non-null, the block value[0..length-1] will be copied
00060  * to the new block.
00061  *
00062  * if the key already exists, the value block will be replaced with the
00063  * new size and (if value is non-null) contents.
00064  */
00065 LPVOID APIENTRY tree_update(TREE tree, TREEKEY key, LPVOID value, UINT length);
00066
00067
00068 /* return a pointer to the value associated with a given key in this tree.
00069  * returns NULL if the key is not found.
00070  */
00071 LPVOID APIENTRY tree_find(TREE tree, TREEKEY key);
00072
00073 /*
00074  * a common tree operation is to insert a new element into the
00075  * tree only if that key is not found, and otherwise to update in some
00076  * way the existing value. Using the standard functions above, that
00077  * would require one lookup for the tree_find, and then a second lookup
00078  * to insert the new element.
00079  *
00080  * the two functions below provide an optimisation over this. tree_search
00081  * will return the value if found; if not, it will return NULL, and set
00082  * pitem to a pointer to a place holder in the tree where the item
00083  * should be inserted. tree_addafter takes this placeholder as
00084  * an argument, and will insert the key/value in the tree at that point.
00085  *
00086  * as for tree_update, the value pointer can be NULL - in this case
00087  * the block is allocated on the tree, but not initialised.
00088  *
00089  * the return value from tree_addafter is a pointer to the value block in
00090  * the tree
00091  */
00092 LPVOID APIENTRY tree_search(TREE tree, TREEKEY key, PTREEITEM place);
00093
00094 LPVOID APIENTRY tree_addafter(TREE tree, PTREEITEM place, TREEKEY key, LPVOID value,
00095       UINT length);
00096
00097
00098 /* -- ctree ---------------
00099  *
00100  * this is a type of tree based on the tree_ data type above, that implements
00101  * counting for insertions of identical keys.
00102  *
00103  * ctree_update, if the key is unique, will insert the object and set the count
00104  * to 1. if the key is not unique, it will just increment the reference count.
00105  *
00106  * ctree_getcount returns the reference count for a tree.
00107  * ctree_find returns the first value inserted for that key, if any
00108  */
00109
00110 /*
00111  * create an empty counting-tree and return handle.
00112  */
00113 TREE APIENTRY ctree_create();
00114
00115 /*
00116  * delete a tree and all memory associated directly with it.
00117  */
00118 void APIENTRY ctree_delete(TREE tree);
00119
00120 /*
00121  * if the KEY is unique within the tree, insert the value and
00122  * set the count for that key to 1. If the key is not unique, add one to
00123  * the reference count for that key but leave the value untouched.
00124  */
00125 LPVOID APIENTRY ctree_update(TREE tree, TREEKEY key, LPVOID value, UINT length);
00126
00127 /*
00128  * find the reference count for the given key
00129  */
00130 long APIENTRY ctree_getcount(TREE tree, TREEKEY key);
00131
00132 /*
00133  * return the value for the given key (note this will be the value for
00134  * the first insertion of this key
00135  */
00136 LPVOID APIENTRY ctree_find(TREE tree, TREEKEY key);
00137 #endif
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

vcacct::IMoveMoney Member List

This is the complete list of members for vcacct::IMoveMoney, including all inherited members.
iid | vcacct::IMoveMoney | [static]
Perform(int lPrimeAccount, int lSecondAccount, int lAmount, int lTranType) | vcacct::IMoveMoney |
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/space.Cpp Source File

  • SysMgmt
  • MMC
  • Menubtn

space.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include "Space.h"
00021 #include "Comp.h"
00022 #define STRSAFE_NO_DEPRECATE
00023 #include <strsafe.h>
00024
00025 const GUID CSpaceVehicle::thisGuid = { 0x29743810, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00026 const GUID CRocket::thisGuid = { 0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00027
00028 //==============================================================
00029 //
00030 // CSpaceVehicle implementation
00031 //
00032 //
00033 CSpaceVehicle::CSpaceVehicle()
00034 {
00035     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00036         children[n] = new CRocket();
00037         children[n]->Initialize(_T("Vehicle"), 500000, 265, 75000);
00038     }
00039 }
00040
00041 CSpaceVehicle::~CSpaceVehicle()
00042 {
00043     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00044         if (children[n]) {
00045             delete children[n];
00046         }
00047 }
00048
00049 HRESULT CSpaceVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00050 {
00051     HRESULT      hr = S_OK;
00052
00053     IHeaderCtrl *pHeaderCtrl = NULL;
00054     IResultData *pResultData = NULL;
00055
00056     if (bShow) {
00057         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00058         _ASSERT( SUCCEEDED(hr) );
00059
00060         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00061         _ASSERT( SUCCEEDED(hr) );
00062
00063         // Set the column headers in the results pane
00064         hr = pHeaderCtrl->InsertColumn( 0, L"Rocket Class", 0, MMCLV_AUTO );
00065         _ASSERT( S_OK == hr );
00066         hr = pHeaderCtrl->InsertColumn( 1, L"Rocket Weight", 0, MMCLV_AUTO );
00067         _ASSERT( S_OK == hr );
00068         hr = pHeaderCtrl->InsertColumn( 2, L"Rocket Height", 0, MMCLV_AUTO );
00069         _ASSERT( S_OK == hr );
00070         hr = pHeaderCtrl->InsertColumn( 3, L"Rocket Payload", 0, MMCLV_AUTO );
00071         _ASSERT( S_OK == hr );
00072         hr = pHeaderCtrl->InsertColumn( 4, L"Status", 0, MMCLV_AUTO );
00073         _ASSERT( S_OK == hr );
00074
00075         // insert items here
00076         RESULTDATAITEM rdi;
00077
00078         hr = pResultData->DeleteAllRsltItems();
00079         _ASSERT( SUCCEEDED(hr) );
00080
00081         if (!bExpanded) {
00082             // create the child nodes, then expand them
00083             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00084                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00085                 rdi.mask       = RDI_STR       |   // Displayname is valid
00086                     RDI_IMAGE     |
00087                     RDI_PARAM;        // nImage is valid
00088
00089                 rdi.nImage      = children[n]->GetBitmapIndex();
00090                 rdi.str         = MMC_CALLBACK;
00091                 rdi.nCol        = 0;
00092                 rdi.lParam      = (LPARAM)children[n];
00093
00094                 hr = pResultData->InsertItem( &rdi );
00095
00096                 _ASSERT( SUCCEEDED(hr) );
00097             }
00098         }
00099
00100         pHeaderCtrl->Release();
00101         pResultData->Release();
00102     }
00103
00104     return hr;
00105 }
00106
00107 //==============================================================
00108 //
00109 // CRocket implementation
00110 //
00111 //
00112 CRocket::CRocket()
00113 : szName(NULL), lWeight(0), lHeight(0), lPayload(0), iStatus(STOPPED)
00114 {
00115 }
00116
00117 CRocket::~CRocket()
00118 {
00119     if (szName)
00120         delete [] szName;
00121 }
00122
00123 void CRocket::Initialize(_TCHAR *szName, LONG lWeight, LONG lHeight, LONG lPayload)
00124 {
00125     if (szName) {
00126         this->szName = new _TCHAR[_tcslen(szName) + 1];
00127         _tcscpy(this->szName, szName);
00128     }
00129
00130     this->lWeight = lWeight;
00131     this->lHeight = lHeight;
00132     this->lPayload = lPayload;
00133 }
00134
00135 const _TCHAR *CRocket::GetDisplayName(int nCol)
00136 {
00137     const size_t cchBuffer = 128;
00138     static _TCHAR buf[cchBuffer];
00139
00140     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00141     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00142
00143     switch (nCol) {
00144     case 0:
00145         StringCchCopy(buf, cchBuffer, szName ? szName : _T(""));
00146         break;
00147
00148     case 1:
00149         StringCchPrintf(buf, cchBuffer, _T("%ld metric tons"), lWeight);
00150         break;
00151
00152     case 2:
00153         StringCchPrintf(buf, cchBuffer, _T("%ld meters"), lHeight);
00154         break;
00155
00156     case 3:
00157         StringCchPrintf(buf, cchBuffer, _T("%ld kilos"), lPayload);
00158         break;
00159
00160     case 4:
00161         StringCchPrintf(buf, cchBuffer, _T("%s"),
00162             iStatus == RUNNING ? _T("running") :
00163         iStatus == PAUSED ? _T("paused") :
00164         iStatus == STOPPED ? _T("stopped") : _T("unknown"));
00165         break;
00166
00167     }
00168
00169     return buf;
00170 }
00171
00172 HMENU CRocket::GetMenu(int nMenuId)
00173 {
00174     HMENU hResMenu = LoadMenu(g_hinst, MAKEINTRESOURCE(nMenuId));
00175     HMENU hMenu = GetSubMenu(hResMenu,0);
00176
00177     if (IDR_STATE_MENU == nMenuId) {
00178         switch (iStatus)
00179         {
00180         case RUNNING:
00181             EnableMenuItem(hMenu, ID_COMMAND_START, MF_BYCOMMAND | MF_GRAYED);
00182             EnableMenuItem(hMenu, ID_COMMAND_PAUSE, MF_BYCOMMAND | MF_ENABLED);
00183             EnableMenuItem(hMenu, ID_COMMAND_STOP, MF_BYCOMMAND | MF_ENABLED);
00184             break;
00185
00186         case PAUSED:
00187             EnableMenuItem(hMenu, ID_COMMAND_START, MF_BYCOMMAND | MF_ENABLED);
00188             EnableMenuItem(hMenu, ID_COMMAND_PAUSE, MF_BYCOMMAND | MF_GRAYED);
00189             EnableMenuItem(hMenu, ID_COMMAND_STOP, MF_BYCOMMAND | MF_ENABLED);
00190             break;
00191
00192         case STOPPED:
00193             EnableMenuItem(hMenu, ID_COMMAND_START, MF_BYCOMMAND | MF_ENABLED);
00194             EnableMenuItem(hMenu, ID_COMMAND_START, MF_BYCOMMAND | MF_ENABLED);
00195             EnableMenuItem(hMenu, ID_COMMAND_STOP, MF_BYCOMMAND | MF_GRAYED);
00196             break;
00197         }
00198     } else {
00199         // some other menu, set state accordingly
00200     }
00201
00202     return hMenu;
00203 }
00204
00205 HRESULT CRocket::SetMenuState(IControlbar *pControlbar,
00206                                          IMenuButton *pMenuButton,
00207                                          BOOL bScope,
00208                                          BOOL bSelect)
00209 {
00210     HRESULT hr = S_OK;
00211
00212     if (bSelect) {
00213         // Always make sure the menuButton is attached
00214         hr = pControlbar->Attach(MENUBUTTON, pMenuButton);
00215
00216         hr = pMenuButton->SetButtonState(IDR_STATE_MENU, HIDDEN, FALSE);
00217         hr = pMenuButton->SetButtonState(IDR_STATE_MENU, ENABLED, TRUE);
00218     } else if (!bSelect) {
00219         hr = pMenuButton->SetButtonState(IDR_STATE_MENU, ENABLED, FALSE);
00220         hr = pMenuButton->SetButtonState(IDR_STATE_MENU, HIDDEN, TRUE);
00221     }
00222
00223     return hr;
00224 }
00225
00226 HRESULT CRocket::OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd)
00227 {
00228     HMENU hMenu = GetMenu(pmbd->idCommand);
00229     HRESULT hr = S_FALSE;
00230     HWND  hWnd;
00231
00232     if (hMenu) {
00233         hr = pConsole->GetMainWindow(&hWnd);
00234
00235         if (SUCCEEDED(hr)) {
00236             LONG ret = TrackPopupMenuEx(hMenu, TPM_NONOTIFY | TPM_RETURNCMD,
00237                 pmbd->x, pmbd->y, hWnd, NULL);
00238
00239             if (ret != 0) { // !cancelled
00240                 hr = OnMenuButtonCommand(pConsole, pmbd->idCommand, ret);
00241             }
00242         }
00243
00244         DestroyMenu(hMenu);
00245     }
00246
00247     return hr;
00248 }
00249
00250 HRESULT CRocket::OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID)
00251 {
00252     const size_t cchBuffer = 128;
00253     _TCHAR szVehicle[cchBuffer];
00254
00255     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00256     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00257
00258     if (IDR_STATE_MENU == nMenuId) {
00259         switch (lCommandID) {
00260         case ID_COMMAND_START:
00261             iStatus = RUNNING;
00262             break;
00263
00264         case ID_COMMAND_PAUSE:
00265             iStatus = PAUSED;
00266             break;
00267
00268         case ID_COMMAND_STOP:
00269             iStatus = STOPPED;
00270             break;
00271         }
00272
00273         StringCchPrintf(szVehicle, cchBuffer, _T("Vehicle %s has been %s"), szName,
00274             (long)iStatus == RUNNING ? _T("started") :
00275         (long)iStatus == PAUSED ? _T("paused") :
00276         (long)iStatus == STOPPED ? _T("stopped") : _T("!!!unknown command!!!"));
00277
00278         int ret = 0;
00279         MAKE_WIDEPTR_FROMTSTR(pszVehicle, szVehicle);
00280         pConsole->MessageBox(pszVehicle,
00281             L"Vehicle command", MB_OK | MB_ICONINFORMATION, &ret);
00282
00283         }
00284
00285         return S_OK;
00286 }
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcAnim.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcAnim.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "ACAnim.h"
00052
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // CAgentCtlAnimationNames properties
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // CAgentCtlAnimationNames operations
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConServe/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConServe

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the class factories of the CONSERVE
00005              server.  This server provides the DllSndBall COM component.
00006              For this component, IClassFactory is implemented in an
00007              appropriate class factory COM object: CFBall. The COM
00008              component that can be manufactured by this server is known
00009              outside the server by its CLSID: CLSID_DllSndBall.
00010
00011              For a comprehensive tutorial code tour of this module's
00012              contents and offerings see the tutorial CONSERVE.HTM
00013              file. For more specific technical details on the internal
00014              workings see the comments dispersed throughout the module's
00015              source code.
00016
00017   Classes:   CFBall.
00018
00019   Functions: .
00020
00021   Origin:    5-30-96: atrent - Editor-inheritance from FACTORY.CPP in
00022                the FRESERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include OLECTL.H because it has definitions for connectable objects.
00043   We include APPUTIL.H because we will be building this DLL using
00044     the convenient Virtual Window and Dialog classes and other
00045     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00046   We include IBALL.H and BALLGUID.H for the common ball-related Interface
00047     class, GUID, and CLSID specifications.
00048   We include SERVER.H because it has the necessary internal class and
00049     resource definitions for this DLL.
00050   We include FACTORY.H because it has the necessary internal class factory
00051     declarations for this DLL component server.  Those factories we will be
00052     implementing in this module.
00053   We include CONNECT.H for object class declarations for the various
00054     connection point and connection COM objects used in CONSERVE.
00055   We include BALL.H, for the object class declarations for the COBall
00056     COM object.
00057 ---------------------------------------------------------------------------*/
00058 #include <windows.h>
00059 #include <ole2.h>
00060 #include <olectl.h>
00061 #include <apputil.h>
00062 #include <iball.h>
00063 #include <ballguid.h>
00064 #include "server.h"
00065 #include "factory.h"
00066 #include "connect.h"
00067 #include "ball.h"
00068
00069 /*---------------------------------------------------------------------------
00070   Implementation the CFBall Class Factory.  CFBall is the COM
00071   object class for the Class Factory that can manufacture COBall
00072   COM Components.
00073 ---------------------------------------------------------------------------*/
00074
00075 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00076   Method:   CFBall::CFBall
00077
00078   Summary:  CFBall Constructor. Note the member initializer:
00079             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00080             to pass the 'this', pUnkOuter, and pServer pointers of this
00081             constructor function to the constructor executed in the
00082             instantiation of the CImpIClassFactory interface whose
00083             implementation is nested inside this present object class.
00084
00085   Args:     IUnknown* pUnkOuter,
00086               Pointer to the the outer Unknown.  NULL means this COM Object
00087               is not being Aggregated.  Non NULL means it is being created
00088               on behalf of an outside COM object that is reusing it via
00089               aggregation.
00090             CServer* pServer)
00091               Pointer to the server's control object.
00092
00093   Modifies: m_cRefs, m_pUnkOuter.
00094
00095   Returns:  void
00096 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00097 CFBall::CFBall(
00098   IUnknown* pUnkOuter,
00099   CServer* pServer) :
00100   m_ImpIClassFactory(this, pUnkOuter, pServer)
00101 {
00102   // Zero the COM object's reference count.
00103   m_cRefs = 0;
00104
00105   // No AddRef necessary if non-NULL, as we're nested.
00106   m_pUnkOuter = pUnkOuter;
00107
00108   // Init the pointer to the server control object.
00109   m_pServer = pServer;
00110
00111   return;
00112 }
00113
00114
00115 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00116   Method:   CFBall::~CFBall
00117
00118   Summary:  CFBall Destructor.
00119
00120   Args:     void
00121
00122   Returns:  void
00123 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00124 CFBall::~CFBall(void)
00125 {
00126   return;
00127 }
00128
00129
00130 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00131   Method:   CFBall::QueryInterface
00132
00133   Summary:  QueryInterface of the CFBall non-delegating
00134             IUnknown implementation.
00135
00136   Args:     REFIID riid,
00137               [in] GUID of the Interface being requested.
00138             PPVOID ppv)
00139               [out] Address of the caller's pointer variable that will
00140               receive the requested interface pointer.
00141
00142   Returns:  HRESULT
00143               Standard result code. NOERROR for success.
00144 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00145 STDMETHODIMP CFBall::QueryInterface(
00146                REFIID riid,
00147                PPVOID ppv)
00148 {
00149   HRESULT hr = E_NOINTERFACE;
00150
00151   if (OwnThis())
00152   {
00153     *ppv = NULL;
00154
00155     if (IID_IUnknown == riid)
00156       *ppv = this;
00157     else if (IID_IClassFactory == riid)
00158       *ppv = &m_ImpIClassFactory;
00159
00160     if (NULL != *ppv)
00161     {
00162       // We've handed out a pointer to the interface so obey the COM rules
00163       // and AddRef the reference count.
00164       ((LPUNKNOWN)*ppv)->AddRef();
00165       hr = NOERROR;
00166     }
00167
00168     UnOwnThis();
00169   }
00170
00171   return (hr);
00172 }
00173
00174
00175 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00176   Method:   CFBall::AddRef
00177
00178   Summary:  AddRef of the CFBall non-delegating IUnknown implementation.
00179
00180   Args:     void
00181
00182   Modifies: m_cRefs.
00183
00184   Returns:  ULONG
00185               New value of m_cRefs (COM object's reference count).
00186 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00187 STDMETHODIMP_(ULONG) CFBall::AddRef(void)
00188 {
00189   ULONG cRefs;
00190
00191   if (OwnThis())
00192   {
00193     cRefs = ++m_cRefs;
00194
00195     UnOwnThis();
00196   }
00197
00198   return cRefs;
00199 }
00200
00201
00202 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00203   Method:   CFBall::Release
00204
00205   Summary:  Release of the CFBall non-delegating IUnknown implementation.
00206
00207   Args:     void
00208
00209   Modifies: m_cRefs.
00210
00211   Returns:  ULONG
00212               New value of m_cRefs (COM object's reference count).
00213 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00214 STDMETHODIMP_(ULONG) CFBall::Release(void)
00215 {
00216   ULONG cRefs;
00217
00218   if (OwnThis())
00219   {
00220     cRefs = --m_cRefs;
00221
00222     if (0 == cRefs)
00223     {
00224       // We've reached a zero reference count for this COM object.
00225       // So we tell the server housing to decrement its global object
00226       // count so that the server will be unloaded if appropriate.
00227       if (NULL != m_pServer)
00228         m_pServer->ObjectsDown();
00229
00230       // We artificially bump the main ref count to prevent reentrancy
00231       // via the main object destructor.  Not really needed in this
00232       // CFBall but a good practice because we are aggregatable and
00233       // may at some point in the future add something entertaining like
00234       // some Releases to the CFBall destructor.
00235       m_cRefs++;
00236       UnOwnThis();
00237       delete this;
00238     }
00239     else
00240       UnOwnThis();
00241   }
00242
00243   return cRefs;
00244 }
00245
00246
00247 /*---------------------------------------------------------------------------
00248   CFBall's nested implementation of the IClassFactory interface
00249   including Constructor, Destructor, QueryInterface, AddRef, Release,
00250   CreateInstance, and LockServer methods.
00251 ---------------------------------------------------------------------------*/
00252
00253 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00254   Method:   CFBall::CImpIClassFactory::CImpIClassFactory
00255
00256   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00257
00258   Args:     CFBall* pBackObj,
00259               Back pointer to the parent outer object.
00260             IUnknown* pUnkOuter,
00261               Pointer to the outer Unknown.  For delegation.
00262             CServer* pServer)
00263               Pointer to the server's control object.
00264
00265   Modifies: m_pBackObj, m_pUnkOuter, m_pServer.
00266
00267   Returns:  void
00268 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00269 CFBall::CImpIClassFactory::CImpIClassFactory(
00270   CFBall* pBackObj,
00271   IUnknown* pUnkOuter,
00272   CServer* pServer)
00273 {
00274   // Init the Back Object Pointer to point to the parent object.
00275   m_pBackObj = pBackObj;
00276
00277   // Init the pointer to the server control object.
00278   m_pServer = pServer;
00279
00280   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00281   // We use the Back Object pointer for IUnknown delegation here if we are
00282   // not being aggregated. If we are being aggregated we use the supplied
00283   // pUnkOuter for IUnknown delegation. In either case the pointer
00284   // assignment requires no AddRef because the CImpIClassFactory lifetime
00285   // is quaranteed by the lifetime of the parent object in which
00286   // CImpIClassFactory is nested.
00287   if (NULL == pUnkOuter)
00288     m_pUnkOuter = pBackObj;
00289   else
00290     m_pUnkOuter = pUnkOuter;
00291
00292   return;
00293 }
00294
00295
00296 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00297   Method:   CFBall::CImpIClassFactory::~CImpIClassFactory
00298
00299   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00300
00301   Args:     void
00302
00303   Returns:  void
00304 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00305 CFBall::CImpIClassFactory::~CImpIClassFactory(void)
00306 {
00307   return;
00308 }
00309
00310
00311 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00312   Method:   CFBall::CImpIClassFactory::QueryInterface
00313
00314   Summary:  The QueryInterface IUnknown member of this IClassFactory
00315             interface implementation that delegates to m_pUnkOuter,
00316             whatever it is.
00317
00318   Args:     REFIID riid,
00319               [in] GUID of the Interface being requested.
00320             PPVOID ppv)
00321               [out] Address of the caller's pointer variable that will
00322               receive the requested interface pointer.
00323
00324   Returns:  HRESULT
00325               Standard result code. NOERROR for success.
00326               Returned by the delegated outer QueryInterface call.
00327 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00328 STDMETHODIMP CFBall::CImpIClassFactory::QueryInterface(
00329                REFIID riid,
00330                PPVOID ppv)
00331 {
00332   // Delegate this call to the outer object's QueryInterface.
00333   return m_pUnkOuter->QueryInterface(riid, ppv);
00334 }
00335
00336
00337 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00338   Method:   CFBall::CImpIClassFactory::AddRef
00339
00340   Summary:  The AddRef IUnknown member of this IClassFactory interface
00341             implementation that delegates to m_pUnkOuter, whatever it is.
00342
00343   Args:     void
00344
00345   Returns:  ULONG
00346               Returned by the delegated outer AddRef call.
00347 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00348 STDMETHODIMP_(ULONG) CFBall::CImpIClassFactory::AddRef(void)
00349 {
00350   // Delegate this call to the outer object's AddRef.
00351   return m_pUnkOuter->AddRef();
00352 }
00353
00354
00355 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00356   Method:   CFBall::CImpIClassFactory::Release
00357
00358   Summary:  The Release IUnknown member of this IClassFactory interface
00359             implementation that delegates to m_pUnkOuter, whatever it is.
00360
00361   Args:     void
00362
00363   Returns:  ULONG
00364               Returned by the delegated outer Release call.
00365 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00366 STDMETHODIMP_(ULONG) CFBall::CImpIClassFactory::Release(void)
00367 {
00368   // Delegate this call to the outer object's Release.
00369   return m_pUnkOuter->Release();
00370 }
00371
00372
00373 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00374   Method:   CFBall::CImpIClassFactory::CreateInstance
00375
00376   Summary:  The CreateInstance member method of this IClassFactory
00377             interface implementation.  Creates an instance of the COBall
00378             COM component.
00379
00380   Args:     IUnknown* pUnkOuter,
00381               [in] Pointer to the controlling IUnknown.
00382             REFIID riid,
00383               [in] GUID of the Interface being requested.
00384             PPVOID ppvCob)
00385               [out] Address of the caller's pointer variable that will
00386               receive the requested interface pointer.
00387
00388   Returns:  HRESULT
00389               Standard result code. NOERROR for success.
00390 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00391 STDMETHODIMP CFBall::CImpIClassFactory::CreateInstance(
00392                IUnknown* pUnkOuter,
00393                REFIID riid,
00394                PPVOID ppv)
00395 {
00396   HRESULT hr = E_FAIL;
00397   COBall* pCob = NULL;
00398
00399   // NULL the output pointer.
00400   *ppv = NULL;
00401
00402   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00403   // the COM rules state the IUnknown interface MUST also be concomitantly
00404   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00405   // an error must be returned indicating that no aggregate creation of
00406   // the CFBall COM Object can be performed.
00407   if (NULL != pUnkOuter && riid != IID_IUnknown)
00408     hr = CLASS_E_NOAGGREGATION;
00409   else
00410   {
00411     // Instantiate a COBall COM Object.
00412     pCob = new COBall(pUnkOuter, m_pServer);
00413     if (NULL != pCob)
00414     {
00415       // Create and initialize any subordinate objects.
00416       hr = pCob->Init();
00417       if (SUCCEEDED(hr))
00418       {
00419         // We successfully created the new COM object so tell the server
00420         // to increment its global server object count to help ensure
00421         // that the server remains loaded until this partial creation
00422         // of a COM component is completed.
00423         m_pServer->ObjectsUp();
00424
00425         // We QueryInterface this new COM Object not only to deposit the
00426         // main interface pointer to the caller's pointer variable, but to
00427         // also automatically bump the Reference Count on the new COM
00428         // Object after handing out this reference to it.
00429         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00430         if (FAILED(hr))
00431         {
00432           m_pServer->ObjectsDown();
00433           delete pCob;
00434         }
00435       }
00436       else
00437         delete pCob;
00438     }
00439     else
00440       hr = E_OUTOFMEMORY;
00441   }
00442
00443   return hr;
00444 }
00445
00446
00447 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00448   Method:   CFBall::CImpIClassFactory::LockServer
00449
00450   Summary:  The LockServer member method of this IClassFactory interface
00451             implementation.
00452
00453   Args:     BOOL fLock)
00454               [in] Flag determining whether to Lock or Unlock the server.
00455
00456   Returns:  HRESULT
00457               Standard result code. NOERROR for success.
00458 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00459 STDMETHODIMP CFBall::CImpIClassFactory::LockServer(
00460                BOOL fLock)
00461 {
00462   HRESULT hr = NOERROR;
00463
00464   if (fLock)
00465     m_pServer->Lock();
00466   else
00467     m_pServer->Unlock();
00468
00469   return hr;
00470 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIAdviseSink Member List

This is the complete list of members for CImpIAdviseSink, including all inherited members.
CImpIAdviseSink(class CSite *, IUnknown *) | CImpIAdviseSink |
LONG | CImpIAdviseSink |
LPSTGMEDIUM | CImpIAdviseSink |
m_cRef | CImpIAdviseSink | [protected]
m_pSite | CImpIAdviseSink | [protected]
m_pUnkOuter | CImpIAdviseSink | [protected]
QueryInterface(REFIID, void **) | CImpIAdviseSink |
STDMETHODIMP_(ULONG) AddRef(void) | CImpIAdviseSink |
STDMETHODIMP_(ULONG) Release(void) | CImpIAdviseSink |
STDMETHODIMP_(void) OnDataChange(LPFORMATETC | CImpIAdviseSink |
STDMETHODIMP_(void) OnViewChange(DWORD | CImpIAdviseSink |
STDMETHODIMP_(void) OnRename(LPMONIKER) | CImpIAdviseSink |
STDMETHODIMP_(void) OnSave(void) | CImpIAdviseSink |
STDMETHODIMP_(void) OnClose(void) | CImpIAdviseSink |
~CImpIAdviseSink(void) | CImpIAdviseSink |
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWrapVBComponent Member List

This is the complete list of members for CWrapVBComponent, including all inherited members.
CWrapVBComponent() | CWrapVBComponent | [inline]
CWrapVBComponent(IUnknown *pUnk) | CWrapVBComponent | [inline]
GetIDsOfNames(THIS_ REFIID riid, unsigned short FAR *FAR *rgszNames, unsigned int cNames, unsigned long lcid, long FAR *rgdispid) | CWrapVBComponent | [inline]
GetTypeInfo(THIS_ unsigned int itinfo, unsigned long lcid, ITypeInfo FAR *FAR *pptinfo) | CWrapVBComponent | [inline]
GetTypeInfoCount(THIS_ unsigned int FAR *pctinfo) | CWrapVBComponent | [inline]
Invoke(THIS_ long dispidMember, REFIID riid, unsigned long lcid, unsigned short wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR *pexcepinfo, unsigned int FAR *puArgErr) | CWrapVBComponent | [inline]
LaunchError() | CWrapVBComponent | [inline]
m_hrLaunch | CWrapVBComponent | [private]
m_pInternal | CWrapVBComponent | [private]
QueryInterface(THIS_ REFIID riid, void FAR *FAR *ppvObj) | CWrapVBComponent | [inline]
StartAnimation(THIS) | CWrapVBComponent | [inline]
STDMETHOD_(unsigned long, AddRef)(THIS) | CWrapVBComponent | [inline]
STDMETHOD_(unsigned long, Release)(THIS) | CWrapVBComponent | [inline]
StopAnimation(THIS) | CWrapVBComponent | [inline]
~CWrapVBComponent() | CWrapVBComponent | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Resource_Dispenser/StdAfx.h Source File

  • Com
  • Services
  • Resource_Dispenser

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__804E6428_B232_11D1_B32F_00AA006887C3__INCLUDED_)
00006 #define AFX_STDAFX_H__804E6428_B232_11D1_B32F_00AA006887C3__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #define _WIN32_WINNT 0x0500
00016 #define _ATL_APARTMENT_THREADED
00017
00018
00019 #include <atlbase.h>
00020 //You may derive a class from CComModule and use it if you want to override
00021 //something, but do not change the name of _Module
00022 extern CComModule _Module;
00023 #include <atlcom.h>
00024
00025 //{{AFX_INSERT_LOCATION}}
00026 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00027
00028 #endif // !defined(AFX_STDAFX_H__804E6428_B232_11D1_B32F_00AA006887C3__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventConsumer/Consumer.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • EventConsumer

Consumer.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  Consumer.cpp
00006 //
00007 // Description:
00008 //      Event consumer implementation
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #include "stdafx.h"
00015 #include "Consumer.h"
00016 #include <objbase.h>
00017 #include <strsafe.h>
00018
00019 CConsumer::CConsumer(CListBox *pOutputList)
00020 {
00021   m_cRef = 0L;
00022   m_pOutputList = pOutputList;
00023 }
00024
00025 CConsumer::~CConsumer()
00026 {
00027 }
00028
00029 STDMETHODIMP CConsumer::QueryInterface(REFIID riid, LPVOID FAR *ppv)
00030 {
00031     *ppv=NULL;
00032
00033     if (riid == IID_IUnknown || riid == IID_IWbemUnboundObjectSink)
00034         *ppv=this;
00035
00036     if (*ppv != NULL)
00037     {
00038         ((LPUNKNOWN)*ppv)->AddRef();
00039         return NOERROR;
00040     }
00041
00042     return E_NOINTERFACE;
00043 }
00044
00045 STDMETHODIMP_(ULONG) CConsumer::AddRef(void)
00046 {
00047     return ++m_cRef;
00048 }
00049
00050 STDMETHODIMP_(ULONG) CConsumer::Release(void)
00051 {
00052     if (--m_cRef != 0L)
00053         return m_cRef;
00054
00055     delete this;
00056     return 0L;
00057 }
00058
00059 STDMETHODIMP CConsumer::IndicateToConsumer(IWbemClassObject *pLogicalConsumer,
00060                       long lNumObjects,
00061                       IWbemClassObject **ppObjects)
00062 {
00063
00064   // NOTE: If this routine returns a failure code, including GPFs from called routines,
00065   // CIMOM will recreate the object and call here again. If you see this routine being
00066   // called twice for every indication, it means this routine is returning a failure code
00067   // somehow. Especially watch the AddRef()/Release() semantics for the embedded object.
00068   // If they're too low, you'll return a GPF.
00069   HRESULT  hRes;
00070   CString clMyBuff;
00071   BSTR objName = NULL;
00072   BSTR propName = NULL;
00073   VARIANT pVal, vUnk;
00074   IUnknown *pUnk = NULL;
00075   IWbemClassObject *tgtInst = NULL;
00076
00077   VariantInit(&pVal);
00078   VariantInit(&vUnk);
00079
00080   TRACE(_T("Indicate() called\n"));
00081
00082   objName = SysAllocString(L"TargetInstance");
00083   if (!objName)
00084   {
00085     TRACE(_T("SysAllocString failed\n"));
00086     return E_OUTOFMEMORY;
00087   }
00088   propName = SysAllocString(L"Item");
00089   if (!propName)
00090   {
00091     TRACE(_T("SysAllocString failed\n"));
00092     SysFreeString(objName);
00093     return E_OUTOFMEMORY;
00094   }
00095
00096   // walk though the classObjects...
00097   for (int i = 0; i < lNumObjects; i++)
00098   {
00099     // clear my output buffer.
00100     clMyBuff.Empty();
00101
00102     // get what was added. This will be an embedded object (VT_UNKNOWN). All
00103     // WMI interfaces are derived from IUnknown.
00104     if ((hRes = ppObjects[i]->Get(objName, 0L,
00105                     &vUnk, NULL, NULL)) == S_OK)
00106     {
00107       //--------------------------------
00108       // pull the IUnknown out of the various. Dont cast directly to to IWbemClassObject.
00109       // it MIGHT work now but a suptle change later will break your code. The PROPER
00110       // way is to go through QueryInterface and do all the right Release()'s.
00111       pUnk = (IUnknown *)V_UNKNOWN(&vUnk);
00112
00113       //--------------------------------
00114       // Even though you didn't use QI(), you just made a copy of a COM ptr so you
00115       // better do the AddRef() that QI() would otherwise do for you.
00116       pUnk->AddRef();
00117
00118       //--------------------------------
00119       // ask for the IWbemClassObject which is the embedded object. This will be the
00120       // instance that was created.
00121       if(SUCCEEDED(pUnk->QueryInterface(IID_IWbemClassObject, (void **)&tgtInst)))
00122       {
00123         //--------------------------------
00124         // done with it.
00125         pUnk->Release();
00126
00127         //--------------------------------
00128         // get the 'Item' property out of the embedded object.
00129         if ((hRes = tgtInst->Get(propName, 0L,
00130                     &pVal, NULL, NULL)) == S_OK)
00131         {
00132           //--------------------------------
00133           // done with it.
00134           tgtInst->Release();
00135
00136           // compose a string for the listbox.
00137           clMyBuff = _T("OfficeEquipment Instance added for: ");
00138           clMyBuff += V_BSTR(&pVal);
00139
00140           // output the buffer.
00141           m_pOutputList->AddString(clMyBuff);
00142         }
00143         else
00144         {
00145           TRACE(_T("Get() Item failed %s\n"), ErrorString(hRes));
00146         }
00147       }
00148       else
00149       {
00150         TRACE(_T("QI() failed \n"));
00151       }
00152     }
00153     else
00154     {
00155       TRACE(_T("Get() targetInst failed %s\n"), ErrorString(hRes));
00156       m_pOutputList->AddString(_T("programming error"));
00157     } //endif Get()
00158
00159   } // endfor
00160
00161   SysFreeString(propName);
00162   SysFreeString(objName);
00163   VariantClear(&pVal);
00164   VariantClear(&vUnk);
00165
00166   TRACE(_T("walked indication list\n"));
00167
00168   return S_OK;
00169 }
00170
00171 // **************************************************************************
00172 //
00173 //  ErrorString()
00174 //
00175 // Description:
00176 //    Converts an HRESULT to a displayable string.
00177 //
00178 // Parameters:
00179 //    hRes (in) - HRESULT to be converted.
00180 //
00181 // Returns:
00182 //    ptr to displayable string.
00183 //
00184 // Globals accessed:
00185 //    None.
00186 //
00187 // Globals modified:
00188 //    None.
00189 //
00190 //===========================================================================
00191 LPCTSTR CConsumer::ErrorString(HRESULT hRes)
00192 {
00193     TCHAR szBuffer2[19];
00194   static TCHAR szBuffer[24];
00195   LPCTSTR psz;
00196
00197     switch(hRes)
00198     {
00199     case WBEM_NO_ERROR:
00200     psz = _T("WBEM_NO_ERROR");
00201     break;
00202     case WBEM_S_FALSE:
00203     psz = _T("WBEM_S_FALSE");
00204     break;
00205     case WBEM_S_NO_MORE_DATA:
00206     psz = _T("WBEM_S_NO_MORE_DATA");
00207     break;
00208   case WBEM_E_FAILED:
00209     psz = _T("WBEM_E_FAILED");
00210     break;
00211   case WBEM_E_NOT_FOUND:
00212     psz = _T("WBEM_E_NOT_FOUND");
00213     break;
00214   case WBEM_E_ACCESS_DENIED:
00215     psz = _T("WBEM_E_ACCESS_DENIED");
00216     break;
00217   case WBEM_E_PROVIDER_FAILURE:
00218     psz = _T("WBEM_E_PROVIDER_FAILURE");
00219     break;
00220   case WBEM_E_TYPE_MISMATCH:
00221     psz = _T("WBEM_E_TYPE_MISMATCH");
00222     break;
00223   case WBEM_E_OUT_OF_MEMORY:
00224     psz = _T("WBEM_E_OUT_OF_MEMORY");
00225     break;
00226   case WBEM_E_INVALID_CONTEXT:
00227     psz = _T("WBEM_E_INVALID_CONTEXT");
00228     break;
00229   case WBEM_E_INVALID_PARAMETER:
00230     psz = _T("WBEM_E_INVALID_PARAMETER");
00231     break;
00232   case WBEM_E_NOT_AVAILABLE:
00233     psz = _T("WBEM_E_NOT_AVAILABLE");
00234     break;
00235   case WBEM_E_CRITICAL_ERROR:
00236     psz = _T("WBEM_E_CRITICAL_ERROR");
00237     break;
00238   case WBEM_E_INVALID_STREAM:
00239     psz = _T("WBEM_E_INVALID_STREAM");
00240     break;
00241   case WBEM_E_NOT_SUPPORTED:
00242     psz = _T("WBEM_E_NOT_SUPPORTED");
00243     break;
00244   case WBEM_E_INVALID_SUPERCLASS:
00245     psz = _T("WBEM_E_INVALID_SUPERCLASS");
00246     break;
00247   case WBEM_E_INVALID_NAMESPACE:
00248     psz = _T("WBEM_E_INVALID_NAMESPACE");
00249     break;
00250   case WBEM_E_INVALID_OBJECT:
00251     psz = _T("WBEM_E_INVALID_OBJECT");
00252     break;
00253   case WBEM_E_INVALID_CLASS:
00254     psz = _T("WBEM_E_INVALID_CLASS");
00255     break;
00256   case WBEM_E_PROVIDER_NOT_FOUND:
00257     psz = _T("WBEM_E_PROVIDER_NOT_FOUND");
00258     break;
00259   case WBEM_E_INVALID_PROVIDER_REGISTRATION:
00260     psz = _T("WBEM_E_INVALID_PROVIDER_REGISTRATION");
00261     break;
00262   case WBEM_E_PROVIDER_LOAD_FAILURE:
00263     psz = _T("WBEM_E_PROVIDER_LOAD_FAILURE");
00264     break;
00265   case WBEM_E_INITIALIZATION_FAILURE:
00266     psz = _T("WBEM_E_INITIALIZATION_FAILURE");
00267     break;
00268   case WBEM_E_TRANSPORT_FAILURE:
00269     psz = _T("WBEM_E_TRANSPORT_FAILURE");
00270     break;
00271   case WBEM_E_INVALID_OPERATION:
00272     psz = _T("WBEM_E_INVALID_OPERATION");
00273     break;
00274   case WBEM_E_INVALID_QUERY:
00275     psz = _T("WBEM_E_INVALID_QUERY");
00276     break;
00277   case WBEM_E_INVALID_QUERY_TYPE:
00278     psz = _T("WBEM_E_INVALID_QUERY_TYPE");
00279     break;
00280   case WBEM_E_ALREADY_EXISTS:
00281     psz = _T("WBEM_E_ALREADY_EXISTS");
00282     break;
00283     case WBEM_S_ALREADY_EXISTS:
00284         psz = _T("WBEM_S_ALREADY_EXISTS");
00285         break;
00286     case WBEM_S_RESET_TO_DEFAULT:
00287         psz = _T("WBEM_S_RESET_TO_DEFAULT");
00288         break;
00289     case WBEM_S_DIFFERENT:
00290         psz = _T("WBEM_S_DIFFERENT");
00291         break;
00292     case WBEM_E_OVERRIDE_NOT_ALLOWED:
00293         psz = _T("WBEM_E_OVERRIDE_NOT_ALLOWED");
00294         break;
00295     case WBEM_E_PROPAGATED_QUALIFIER:
00296         psz = _T("WBEM_E_PROPAGATED_QUALIFIER");
00297         break;
00298     case WBEM_E_PROPAGATED_PROPERTY:
00299         psz = _T("WBEM_E_PROPAGATED_PROPERTY");
00300         break;
00301     case WBEM_E_UNEXPECTED:
00302         psz = _T("WBEM_E_UNEXPECTED");
00303         break;
00304     case WBEM_E_ILLEGAL_OPERATION:
00305         psz = _T("WBEM_E_ILLEGAL_OPERATION");
00306         break;
00307     case WBEM_E_CANNOT_BE_KEY:
00308         psz = _T("WBEM_E_CANNOT_BE_KEY");
00309         break;
00310     case WBEM_E_INCOMPLETE_CLASS:
00311         psz = _T("WBEM_E_INCOMPLETE_CLASS");
00312         break;
00313     case WBEM_E_INVALID_SYNTAX:
00314         psz = _T("WBEM_E_INVALID_SYNTAX");
00315         break;
00316     case WBEM_E_NONDECORATED_OBJECT:
00317         psz = _T("WBEM_E_NONDECORATED_OBJECT");
00318         break;
00319     case WBEM_E_READ_ONLY:
00320         psz = _T("WBEM_E_READ_ONLY");
00321         break;
00322     case WBEM_E_PROVIDER_NOT_CAPABLE:
00323         psz = _T("WBEM_E_PROVIDER_NOT_CAPABLE");
00324         break;
00325     case WBEM_E_CLASS_HAS_CHILDREN:
00326         psz = _T("WBEM_E_CLASS_HAS_CHILDREN");
00327         break;
00328     case WBEM_E_CLASS_HAS_INSTANCES:
00329         psz = _T("WBEM_E_CLASS_HAS_INSTANCES");
00330         break;
00331     case WBEM_E_QUERY_NOT_IMPLEMENTED:
00332         psz = _T("WBEM_E_QUERY_NOT_IMPLEMENTED");
00333         break;
00334     case WBEM_E_ILLEGAL_NULL:
00335         psz = _T("WBEM_E_ILLEGAL_NULL");
00336         break;
00337     case WBEM_E_INVALID_QUALIFIER_TYPE:
00338         psz = _T("WBEM_E_INVALID_QUALIFIER_TYPE");
00339         break;
00340     case WBEM_E_INVALID_PROPERTY_TYPE:
00341         psz = _T("WBEM_E_INVALID_PROPERTY_TYPE");
00342         break;
00343     case WBEM_E_VALUE_OUT_OF_RANGE:
00344         psz = _T("WBEM_E_VALUE_OUT_OF_RANGE");
00345         break;
00346     case WBEM_E_CANNOT_BE_SINGLETON:
00347         psz = _T("WBEM_E_CANNOT_BE_SINGLETON");
00348         break;
00349   default:
00350         _itot(hRes, szBuffer2, 16);
00351     StringCbCopy(szBuffer, sizeof(szBuffer),_T("0x"));
00352       StringCbCat(szBuffer, sizeof(szBuffer), szBuffer2);
00353     psz = szBuffer;
00354   }
00355   return psz;
00356 }
00357
00358 // **************************************************************************
00359 //
00360 //  ValueToString()
00361 //
00362 // Description:
00363 //    Converts a variant to a displayable string.
00364 //
00365 // Parameters:
00366 //    pValue (in) - variant to be converted.
00367 //    pbuf (out) - ptr to receive displayable string.
00368 //
00369 // Returns:
00370 //    Same as pbuf.
00371 //
00372 // Globals accessed:
00373 //    None.
00374 //
00375 // Globals modified:
00376 //    None.
00377 //
00378 //===========================================================================
00379 #define BLOCKSIZE (32 * sizeof(WCHAR))
00380 #define CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop */
00381
00382 LPWSTR CConsumer::ValueToString(VARIANT *pValue, WCHAR **pbuf)
00383 {
00384    DWORD iNeed = 0;
00385    DWORD iVSize = 0;
00386    DWORD iCurBufSize = 0;
00387
00388    WCHAR *vbuf = NULL;
00389    WCHAR *buf = NULL;
00390
00391    switch (pValue->vt)
00392    {
00393    case VT_NULL:
00394          buf = (WCHAR *)malloc(BLOCKSIZE);
00395      if (buf)
00396       StringCbCopyW(buf, BLOCKSIZE, L"<null>");
00397          break;
00398
00399    case VT_BOOL: {
00400          VARIANT_BOOL b = pValue->boolVal;
00401          buf = (WCHAR *)malloc(BLOCKSIZE);
00402      if (buf)
00403      {
00404       if (!b) {
00405         StringCbCopyW(buf, BLOCKSIZE, L"FALSE");
00406
00407       } else {
00408         StringCbCopyW(buf, BLOCKSIZE, L"TRUE");
00409       }
00410     }
00411          break;
00412       }
00413
00414    case VT_UI1: {
00415       unsigned char b = pValue->bVal;
00416         buf = (WCHAR *)malloc(BLOCKSIZE);
00417         if (buf)
00418         {
00419             if (b >= 32)
00420             {
00421                 StringCbPrintfW(buf, BLOCKSIZE, L"'%c' (%hu, 0x%hX)", b, (unsigned char)b, b);
00422             }
00423             else
00424             {
00425                 StringCbPrintfW(buf, BLOCKSIZE, L"%hu (0x%hX)", (unsigned char)b, b);
00426             }
00427         }
00428         break;
00429   }
00430    case VT_I2:  {
00431         USHORT i = pValue->uiVal;
00432         buf = (WCHAR *)malloc(BLOCKSIZE);
00433         if (buf)
00434         {
00435             StringCbPrintfW(buf, BLOCKSIZE, L"%hu (0x%hX)", i, i);
00436         }
00437         break;
00438     }
00439
00440    case VT_I4: {
00441          LONG l = pValue->lVal;
00442         buf = (WCHAR *)malloc(BLOCKSIZE);
00443         if (buf)
00444         {
00445             StringCbPrintfW(buf, BLOCKSIZE, L"%d (0x%X)", l, l);
00446         }
00447         break;
00448       }
00449
00450    case VT_R4: {
00451         float f = pValue->fltVal;
00452         buf = (WCHAR *)malloc(CVTBUFSIZE * sizeof(WCHAR));
00453         if (buf)
00454         {
00455             StringCbPrintfW(buf, BLOCKSIZE,  L"%10.4f", f);
00456         }
00457         break;
00458       }
00459
00460    case VT_R8: {
00461     double d = pValue->dblVal;
00462         buf = (WCHAR *)malloc(CVTBUFSIZE * sizeof(WCHAR));
00463         if (buf)
00464         {
00465             StringCbPrintfW(buf, BLOCKSIZE, L"%10.4f", d);
00466         }
00467         break;
00468     }
00469
00470    case VT_BSTR: {
00471      LPWSTR pWStr = pValue->bstrVal;
00472      int bufSize = (wcslen(pWStr) * sizeof(WCHAR)) + sizeof(WCHAR) + (2 * sizeof(WCHAR));
00473      buf = (WCHAR *)malloc(bufSize);
00474      if (buf)
00475       StringCbPrintfW(buf, bufSize, L"\"%wS\"", pWStr);
00476      break;
00477     }
00478
00479   // the sample GUI is too simple to make it necessary to display
00480   // these 'complicated' types--so ignore them.
00481    case VT_DISPATCH:  // Currently only used for embedded objects
00482    case VT_BOOL|VT_ARRAY:
00483    case VT_UI1|VT_ARRAY:
00484    case VT_I2|VT_ARRAY:
00485    case VT_I4|VT_ARRAY:
00486    case VT_R4|VT_ARRAY:
00487    case VT_R8|VT_ARRAY:
00488    case VT_BSTR|VT_ARRAY:
00489    case VT_DISPATCH | VT_ARRAY:
00490          break;
00491
00492    default:
00493          buf = (WCHAR *)malloc(BLOCKSIZE);
00494      if (buf)
00495       StringCbCopyW(buf, BLOCKSIZE, L"<conversion error>");
00496    }
00497
00498    *pbuf = buf;
00499    return buf;
00500 }
00501
00502
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/doc.h Source File

  • Com
  • Fundamentals
  • SimpSvr

doc.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: doc.h
00003 //
00004 //      Definition of CSimpSvrDoc
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008
00009 #if !defined( _DOC_H_ )
00010 #define _DOC_H_
00011 #include <stablize.h>
00012
00013 class CSimpSvrApp;
00014 class CSimpSvrObj;
00015
00016 class CSimpSvrDoc : IUnknown, public CSafeRefCount
00017 {
00018 private:
00019         CSimpSvrApp FAR * m_lpApp;
00020         CSimpSvrObj FAR * m_lpObj;
00021
00022         HWND m_hDocWnd;
00023         HWND m_hHatchWnd;
00024         BOOL m_fClosing;
00025
00026 public:
00027         static CSimpSvrDoc FAR * Create(CSimpSvrApp FAR *lpApp, LPRECT lpRect,HWND hWnd);
00028
00029         CSimpSvrDoc();
00030         CSimpSvrDoc(CSimpSvrApp FAR *lpApp, HWND hWnd);
00031         ~CSimpSvrDoc();
00032
00033 // IUnknown Interfaces
00034         STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
00035         STDMETHODIMP_(ULONG) AddRef();
00036         STDMETHODIMP_(ULONG) Release();
00037
00038         long lResizeDoc(LPRECT lpRect);
00039         long lAddVerbs();
00040
00041         BOOL Load(LPSTR lpszFileName);
00042         void PaintDoc(HDC hDC);
00043         void lButtonDown(WPARAM wParam,LPARAM lParam);
00044
00045         HRESULT CreateObject(REFIID riid, LPVOID FAR *ppvObject);
00046
00047         void Close();
00048         void SetStatusText();
00049         void ShowDocWnd();
00050         void ShowHatchWnd();
00051         void CSimpSvrDoc::HideDocWnd();
00052         void CSimpSvrDoc::HideHatchWnd();
00053
00054 // member access
00055         inline HWND GethDocWnd() { return m_hDocWnd; };
00056         inline HWND GethHatchWnd() { return m_hHatchWnd; };
00057         inline HWND GethAppWnd() { return m_lpApp->GethAppWnd(); };
00058         inline CSimpSvrApp FAR * GetApp() { return m_lpApp; };
00059         inline CSimpSvrObj FAR * GetObj() { return m_lpObj; };
00060         inline void ClearObj() { m_lpObj = NULL; };
00061
00062 };
00063
00064 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAddrNode Member List

This is the complete list of members for CAddrNode, including all inherited members.
m_cb | CAddrNode |
m_nAlloc | CAddrNode |
m_next | CAddrNode |
m_pv | CAddrNode |
operator delete(void FAR *pv) | CAddrNode | [inline]
operator new(size_t cb) | CAddrNode | [inline]
Generated on Wed Nov 13 2024 16:55:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/addvfiledlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

addvfiledlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddVFileDlg.h:   Header for the CAddVFileDlg class.  This is a
00014 //                   modeless dialog class used to add Virtual Files.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDVFILEDLG_
00019 #define _CLASS_ADDVFILEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddVFileDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddVFileDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddVFileDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDVFILEDLG_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Framer/IIpSite.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Framer

IIpSite.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*
00019  * IIPSITE.CPP
00020  * IOleInPlaceSite for Document Objects CSite class
00021  *
00022  */
00023
00024
00025 #include "framer.h"
00026
00027
00028 /*
00029  * CImpIOleInPlaceSite::CImpIOleInPlaceSite
00030  * CImpIOleInPlaceSite::~CImpIOleInPlaceSite
00031  *
00032  * Parameters (Constructor):
00033  *  pSite           PCSite of the site we're in.
00034  *  pUnkOuter       LPUNKNOWN to which we delegate.
00035  */
00036
00037 CImpIOleInPlaceSite::CImpIOleInPlaceSite(PCSite pSite
00038     , LPUNKNOWN pUnkOuter)
00039     {
00040     m_cRef=0;
00041     m_pSite=pSite;
00042     m_pUnkOuter=pUnkOuter;
00043     return;
00044     }
00045
00046 CImpIOleInPlaceSite::~CImpIOleInPlaceSite(void)
00047     {
00048     return;
00049     }
00050
00051
00052
00053 /*
00054  * CImpIOleInPlaceSite::QueryInterface
00055  * CImpIOleInPlaceSite::AddRef
00056  * CImpIOleInPlaceSite::Release
00057  *
00058  * Purpose:
00059  *  IUnknown members for CImpIOleInPlaceSite object.
00060  */
00061
00062 STDMETHODIMP CImpIOleInPlaceSite::QueryInterface(REFIID riid
00063     , void **ppv)
00064     {
00065     return m_pUnkOuter->QueryInterface(riid, ppv);
00066     }
00067
00068
00069 STDMETHODIMP_(ULONG) CImpIOleInPlaceSite::AddRef(void)
00070     {
00071     ++m_cRef;
00072     return m_pUnkOuter->AddRef();
00073     }
00074
00075 STDMETHODIMP_(ULONG) CImpIOleInPlaceSite::Release(void)
00076     {
00077     --m_cRef;
00078     return m_pUnkOuter->Release();
00079     }
00080
00081
00082
00083
00084 /*
00085  * CImpIOleInPlaceActiveObject::GetWindow
00086  *
00087  * Purpose:
00088  *  Retrieves the handle of the window associated with the object
00089  *  on which this interface is implemented.
00090  *
00091  * Parameters:
00092  *  phWnd           HWND * in which to store the window handle.
00093  *
00094  * Return Value:
00095  *  HRESULT         NOERROR if successful, E_FAIL if there is no
00096  *                  window.
00097  */
00098
00099 STDMETHODIMP CImpIOleInPlaceSite::GetWindow(HWND *phWnd)
00100     {
00101     //This is the client-area window in the frame
00102     *phWnd=m_pSite->m_hWnd;
00103     return NOERROR;
00104     }
00105
00106
00107
00108
00109 /*
00110  * CImpIOleInPlaceActiveObject::ContextSensitiveHelp
00111  *
00112  * Purpose:
00113  *  Instructs the object on which this interface is implemented to
00114  *  enter or leave a context-sensitive help mode.
00115  *
00116  * Parameters:
00117  *  fEnterMode      BOOL TRUE to enter the mode, FALSE otherwise.
00118  *
00119  * Return Value:
00120  *  HRESULT         NOERROR
00121  */
00122
00123 STDMETHODIMP CImpIOleInPlaceSite::ContextSensitiveHelp
00124     (BOOL fEnterMode)
00125     {
00126     return NOERROR;
00127     }
00128
00129
00130
00131
00132 /*
00133  * CImpIOleInPlaceSite::CanInPlaceActivate
00134  *
00135  * Purpose:
00136  *  Answers the server whether or not we can currently in-place
00137  *  activate its object.  By implementing this interface we say
00138  *  that we support in-place activation, but through this function
00139  *  we indicate whether the object can currently be activated
00140  *  in-place.  Iconic aspects, for example, cannot, meaning we
00141  *  return S_FALSE.
00142  *
00143  * Parameters:
00144  *  None
00145  *
00146  * Return Value:
00147  *  HRESULT         NOERROR if we can in-place activate the object
00148  *                  in this site, S_FALSE if not.
00149  */
00150
00151 STDMETHODIMP CImpIOleInPlaceSite::CanInPlaceActivate(void)
00152     {
00153     /*
00154      * We can always in-place activate--no restrictions for DocObjects.
00155      * We don't worry about other cases since CSite only ever creates
00156      * embedded files.
00157      */
00158     return NOERROR;
00159     }
00160
00161
00162
00163
00164 /*
00165  * CImpIOleInPlaceSite::OnInPlaceActivate
00166  *
00167  * Purpose:
00168  *  Informs the container that an object is being activated in-place
00169  *  such that the container can prepare appropriately.  The
00170  *  container does not, however, make any user interface changes at
00171  *  this point.  See OnUIActivate.
00172  *
00173  * Parameters:
00174  *  None
00175  *
00176  * Return Value:
00177  *  HRESULT         NOERROR or an appropriate error code.
00178  */
00179
00180 STDMETHODIMP CImpIOleInPlaceSite::OnInPlaceActivate(void)
00181     {
00182     m_pSite->m_pObj->QueryInterface(IID_IOleInPlaceObject
00183         , (void **)&m_pSite->m_pIOleIPObject);
00184
00185     return NOERROR;
00186     }
00187
00188
00189
00190
00191 /*
00192  * CImpIOleInPlaceSite::OnInPlaceDeactivate
00193  *
00194  * Purpose:
00195  *  Notifies the container that the object has deactivated itself
00196  *  from an in-place state.  Opposite of OnInPlaceActivate.  The
00197  *  container does not change any UI at this point.
00198  *
00199  * Parameters:
00200  *  None
00201  *
00202  * Return Value:
00203  *  HRESULT         NOERROR or an appropriate error code.
00204  */
00205
00206 STDMETHODIMP CImpIOleInPlaceSite::OnInPlaceDeactivate(void)
00207     {
00208     /*
00209      * Since we don't have an Undo command, we can tell the object
00210      * right away to discard its Undo state.
00211      */
00212     m_pSite->Activate(OLEIVERB_DISCARDUNDOSTATE);
00213     ReleaseInterface(m_pSite->m_pIOleIPObject);
00214     return NOERROR;
00215     }
00216
00217
00218
00219
00220 /*
00221  * CImpIOleInPlaceSite::OnUIActivate
00222  *
00223  * Purpose:
00224  *  Informs the container that the object is going to start munging
00225  *  around with user interface, like replacing the menu.  The
00226  *  container should remove any relevant UI in preparation.
00227  *
00228  * Parameters:
00229  *  None
00230  *
00231  * Return Value:
00232  *  HRESULT         NOERROR or an appropriate error code.
00233  */
00234
00235 STDMETHODIMP CImpIOleInPlaceSite::OnUIActivate(void)
00236     {
00237     //No state we have to set up here.
00238     return NOERROR;
00239     }
00240
00241
00242
00243
00244 /*
00245  * CImpIOleInPlaceSite::OnUIDeactivate
00246  *
00247  * Purpose:
00248  *  Informs the container that the object is deactivating its
00249  *  in-place user interface at which time the container may
00250  *  reinstate its own.  Opposite of OnUIActivate.
00251  *
00252  * Parameters:
00253  *  fUndoable       BOOL indicating if the object will actually
00254  *                  perform an Undo if the container calls
00255  *                  ReactivateAndUndo.
00256  *
00257  * Return Value:
00258  *  HRESULT         NOERROR or an appropriate error code.
00259  */
00260
00261 STDMETHODIMP CImpIOleInPlaceSite::OnUIDeactivate(BOOL fUndoable)
00262     {
00263     //Set focus back to the frame
00264     SetFocus(m_pSite->m_pFR->Window());
00265
00266     //Show our menu again
00267     m_pSite->m_pFR->SetMenu(NULL, NULL, NULL);
00268
00269     return NOERROR;
00270     }
00271
00272
00273
00274
00275 /*
00276  * CImpIOleInPlaceSite::DeactivateAndUndo
00277  *
00278  * Purpose:
00279  *  If immediately after activation the object does an Undo, the
00280  *  action being undone is the activation itself, and this call
00281  *  informs the container that this is, in fact, what happened.
00282  *  The container should call IOleInPlaceObject::UIDeactivate.
00283  *
00284  * Parameters:
00285  *  None
00286  *
00287  * Return Value:
00288  *  HRESULT         NOERROR or an appropriate error code.
00289  */
00290
00291 STDMETHODIMP CImpIOleInPlaceSite::DeactivateAndUndo(void)
00292     {
00293     m_pSite->m_pIOleIPObject->InPlaceDeactivate();
00294     return NOERROR;
00295     }
00296
00297
00298
00299
00300 /*
00301  * CImpIOleInPlaceSite::DiscardUndoState
00302  *
00303  * Purpose:
00304  *  Informs the container that something happened in the object
00305  *  that means the container should discard any undo information
00306  *  it currently maintains for the object.
00307  *
00308  * Parameters:
00309  *  None
00310  *
00311  * Return Value:
00312  *  HRESULT         NOERROR or an appropriate error code.
00313  */
00314
00315 STDMETHODIMP CImpIOleInPlaceSite::DiscardUndoState(void)
00316     {
00317     return E_NOTIMPL;
00318     }
00319
00320
00321
00322
00323 /*
00324  * CImpIOleInPlaceSite::GetWindowContext
00325  *
00326  * Purpose:
00327  *  Provides an in-place object with pointers to the frame and
00328  *  document level in-place interfaces (IOleInPlaceFrame and
00329  *  IOleInPlaceUIWindow) such that the object can do border
00330  *  negotiation and so forth.  Also requests the position and
00331  *  clipping rectangles of the object in the container and a
00332  *  pointer to an OLEINPLACEFRAME info structure which contains
00333  *  accelerator information.
00334  *
00335  *  Note that the two interfaces this call returns are not
00336  *  available through QueryInterface on IOleInPlaceSite since they
00337  *  live with the frame and document, but not the site.
00338  *
00339  * Parameters:
00340  *  ppIIPFrame      LPOLEINPLACEFRAME * in which to return the
00341  *                  AddRef'd pointer to the container's
00342  *                  IOleInPlaceFrame.
00343  *  ppIIPUIWindow   LPOLEINPLACEUIWINDOW * in which to return
00344  *                  the AddRef'd pointer to the container document's
00345  *                  IOleInPlaceUIWindow.
00346  *  prcPos          LPRECT in which to store the object's position.
00347  *  prcClip         LPRECT in which to store the object's visible
00348  *                  region.
00349  *  pFI             LPOLEINPLACEFRAMEINFO to fill with accelerator
00350  *                  stuff.
00351  *
00352  * Return Value:
00353  *  HRESULT         NOERROR
00354  */
00355
00356 STDMETHODIMP CImpIOleInPlaceSite::GetWindowContext
00357     (LPOLEINPLACEFRAME *ppIIPFrame, LPOLEINPLACEUIWINDOW
00358     *ppIIPUIWindow, LPRECT prcPos, LPRECT prcClip
00359     , LPOLEINPLACEFRAMEINFO pFI)
00360     {
00361     *ppIIPUIWindow=NULL;
00362     m_pSite->m_pFR->QueryInterface(IID_IOleInPlaceFrame
00363         , (void **)ppIIPFrame);
00364
00365     if (NULL!=prcPos)
00366         GetClientRect(m_pSite->m_hWnd, prcPos);
00367
00368     *prcClip=*prcPos;
00369
00370     pFI->cb=sizeof(OLEINPLACEFRAMEINFO);
00371     pFI->fMDIApp=FALSE;
00372     pFI->hwndFrame=m_pSite->m_pFR->Window();
00373     pFI->haccel=m_pSite->m_pFR->Accelerators();
00374     pFI->cAccelEntries=CACCELERATORS;
00375
00376     return NOERROR;
00377     }
00378
00379
00380
00381
00382 /*
00383  * CImpIOleInPlaceSite::Scroll
00384  *
00385  * Purpose:
00386  *  Asks the container to scroll the document, and thus the object,
00387  *  by the given amounts in the sz parameter.
00388  *
00389  * Parameters:
00390  *  sz              SIZE containing signed horizontal and vertical
00391  *                  extents by which the container should scroll.
00392  *                  These are in device units.
00393  *
00394  * Return Value:
00395  *  HRESULT         NOERROR
00396  */
00397
00398 STDMETHODIMP CImpIOleInPlaceSite::Scroll(SIZE sz)
00399     {
00400     //Not needed for DocObjects
00401     return E_NOTIMPL;
00402     }
00403
00404
00405
00406
00407 /*
00408  * CImpIOleInPlaceSite::OnPosRectChange
00409  *
00410  * Purpose:
00411  *  Informs the container that the in-place object was resized.
00412  *  The container must call IOleInPlaceObject::SetObjectRects.
00413  *  This does not change the site's rectangle in any case.
00414  *
00415  * Parameters:
00416  *  prcPos          LPCRECT containing the new size of the object.
00417  *
00418  * Return Value:
00419  *  HRESULT         NOERROR
00420  */
00421
00422 STDMETHODIMP CImpIOleInPlaceSite::OnPosRectChange(LPCRECT prcPos)
00423     {
00424     //Not needed for DocObjects
00425     return E_NOTIMPL;
00426     }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMmStreamBuf Member List

This is the complete list of members for CMmStreamBuf, including all inherited members.
_buf | CMmStreamBuf | [private]
_cb | CMmStreamBuf | [private]
_pStream | CMmStreamBuf | [private]
CMmStreamBuf() | CMmStreamBuf | [inline]
Get() | CMmStreamBuf | [inline]
SetBuf(void *buf) | CMmStreamBuf | [inline]
SetSize(ULONG cb) | CMmStreamBuf | [inline]
SetStream(PMmStream *pStream) | CMmStreamBuf | [inline]
Size() const | CMmStreamBuf | [inline]
~CMmStreamBuf() | CMmStreamBuf |
Generated on Wed Nov 13 2024 16:56:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/compdata.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

compdata.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "Comp.h"
00016 #include "CompData.h"
00017 #include "DataObj.h"
00018 #include "Resource.h"
00019
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CComponentData")
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // Construction/Destruction
00028
00029
00030 //---------------------------------------------------------------------------
00031 //  This constructor is called when the Snap-in is selected from the
00032 //  Add/Remove dialog.  Build our static node and load the required
00033 //  clipformats before MMC calls us.
00034 //
00035 CComponentData::CComponentData()
00036 {
00037   // Do not assume only one instance of IComponentData implementation is created.
00038
00039
00040     m_cRef                = 0;
00041     m_ipConsoleNameSpace  = NULL;
00042     m_ipConsole           = NULL;
00043
00044     // Increment this so DllCanUnloadNow works correctly
00045     InterlockedIncrement((long*)&g_uObjectCount);
00046
00047     NODE_PROPERTIES NodeProps;
00048     ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00049     wcscpy( NodeProps.szNodeName, gwszROOT_NODE_NAME );
00050     NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(this);
00051     NodeProps.pParentObject  = NULL;
00052
00053     m_pStaticNode = new CStaticNode;
00054     m_pStaticNode->Initialize( &NodeProps );
00055
00056     InitClipboardFormats();
00057 }
00058
00059 //---------------------------------------------------------------------------
00060 CComponentData::~CComponentData()
00061 {
00062   if( NULL != m_pStaticNode )
00063   {
00064     delete m_pStaticNode;
00065     m_pStaticNode = NULL;
00066   }
00067
00068   // All done, decrement object count so the dll can be unloaded
00069   InterlockedDecrement((long*)&g_uObjectCount);
00070 }
00071
00072
00073 /////////////////////////////////////////////////////////////////////////////
00074 // IUnknown implementation
00075
00076 //---------------------------------------------------------------------------
00077 STDMETHODIMP CComponentData::QueryInterface
00078 (
00079   REFIID   riid,       //[in] Identifier of the requested interface
00080   LPVOID   *ppv        //[out] Address of requested interface
00081 )
00082 {
00083   if( !ppv )
00084     return E_FAIL;
00085
00086   *ppv = NULL;
00087
00088   if( IsEqualIID(riid, IID_IUnknown) )
00089     *ppv = static_cast<IComponentData*>(this);
00090   else if( IsEqualIID(riid, IID_IComponentData) )
00091     *ppv = static_cast<IComponentData*>(this);
00092   else if( IsEqualIID(riid, IID_IComponentData2) )
00093     *ppv = static_cast<IComponentData2*>(this);
00094   else if( IsEqualIID(riid, IID_IExtendContextMenu) )
00095     *ppv = static_cast<IExtendContextMenu *>(this);
00096
00097   if( *ppv )
00098   {
00099     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00100     return S_OK;
00101   }
00102
00103   return E_NOINTERFACE;
00104 }
00105
00106 //---------------------------------------------------------------------------
00107 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00108 {
00109   return InterlockedIncrement((LONG*)&m_cRef);
00110 }
00111
00112 //---------------------------------------------------------------------------
00113 STDMETHODIMP_(ULONG) CComponentData::Release()
00114 {
00115   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00116   {
00117     delete this;
00118     return 0;
00119   }
00120
00121   return m_cRef;
00122 }
00123
00124 /////////////////////////////////////////////////////////////////////////////
00125 // Interface IComponentData
00126
00127 //---------------------------------------------------------------------------
00128 //  Called when the user selects the Snap-in from the scope pane.
00129 //  This is where we QI and cache interfaces we will use later.  These
00130 //  interfaces are for future use since they are not used in this sample
00131 //
00132 HRESULT CComponentData::Initialize
00133 (
00134   LPUNKNOWN pUnknown         //[in] Pointer to the console's IUnknown
00135 )
00136 {
00137   HRESULT hResult = S_FALSE;
00138                              // Fail to initialize if we can't get the
00139   do                         // interfaces we need to cache
00140   {
00141     hResult = pUnknown->QueryInterface(IID_IConsoleNameSpace2, (void**)&m_ipConsoleNameSpace);
00142     BREAK_ON_ERROR( hResult );
00143
00144     hResult = pUnknown->QueryInterface(IID_IConsole3, (void**)&m_ipConsole);
00145     BREAK_ON_ERROR( hResult );
00146
00147     // Add the images for the scope tree
00148     LPIMAGELIST ipScopeImage = NULL;
00149     hResult = m_ipConsole->QueryScopeImageList(&ipScopeImage);
00150     BREAK_ON_ERROR( hResult );
00151
00152     // Load the bitmaps from the dll
00153     HBITMAP hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16) );
00154     if( NULL == hImageStrip16 )
00155     {
00156       hResult = S_FALSE;
00157       continue;
00158     }
00159
00160     HBITMAP hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32) );
00161     if( NULL == hImageStrip32)
00162     {
00163       hResult = S_FALSE;
00164       continue;
00165     }
00166
00167     // Set the images
00168     hResult = ipScopeImage->ImageListSetStrip( (LONG_PTR*)hImageStrip16,
00169                                                (LONG_PTR*)hImageStrip32,
00170                                                0,
00171                                                RGB(0,255,0)
00172                                              );
00173     BREAK_ON_ERROR( hResult );
00174
00175     SAFE_RELEASE( ipScopeImage      ); // Release these here.  IComponent
00176     SAFE_FREE_BITMAP( hImageStrip16 ); // will get an MMCN_ADD_IMAGES when
00177     SAFE_FREE_BITMAP( hImageStrip32 ); // the console needs them again.
00178   }
00179   while( 0 );
00180
00181   return hResult;
00182 }
00183
00184 //---------------------------------------------------------------------------
00185 //  Called by the console every time we need to create a new result view.
00186 //  There can be several different result views. Aside from the default one
00187 //  created when the Snap-in initializes, additional ones are created by
00188 //  selecting "New window from here" in MMC's user interface.
00189 //
00190 HRESULT CComponentData::CreateComponent
00191 (
00192   LPCOMPONENT __RPC_FAR* ppComponent   //[out] Points to new IComponent class
00193 )
00194 {
00195   *ppComponent = NULL;
00196
00197   // Pass the new CComponent a pointer to it's parent
00198   CComponent* pComponent = new CComponent( this );
00199
00200   if( NULL == pComponent )
00201     return E_OUTOFMEMORY;
00202
00203   return pComponent->QueryInterface( IID_IComponent, (void**)ppComponent );
00204 }
00205
00206 //---------------------------------------------------------------------------
00207 //  Handles notification events from MMC
00208 //
00209 HRESULT CComponentData::Notify
00210 (
00211   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00212   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00213   LPARAM           nArg,           //[in] Depends on the notification type
00214   LPARAM           nParam          //[in] Depends on the notification type
00215 )
00216 {
00217   TRACE_EVENT( _T("Notify"), MmcEvent );  // Provides trace output
00218
00219   HRESULT hResult = S_FALSE;
00220   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00221   if( NULL == pNode )
00222     return hResult;
00223
00224   switch( MmcEvent )
00225   {
00226     case MMCN_EXPAND:
00227       hResult = pNode->OnExpand( ipDataObject, nArg, nParam, (LONG_PTR)this );
00228       break;
00229
00230     case MMCN_REMOVE_CHILDREN:
00231       hResult = pNode->OnRemoveChildren( ipDataObject, nArg, nParam, (LONG_PTR)this );
00232       break;
00233
00234     case MMCN_PRELOAD:                 // Function not implemented
00235     case MMCN_PROPERTY_CHANGE:         // Function not implemented
00236     case MMCN_DELETE:                  // Function not implemented
00237     case MMCN_RENAME:                  // Function not implemented
00238     default:
00239       break;
00240   }
00241
00242   return hResult;
00243 }
00244
00245 //---------------------------------------------------------------------------
00246 //  This is where we release any cached interface pointers or any
00247 //  allocated resources.
00248 //
00249 HRESULT CComponentData::Destroy( void)
00250 {
00251   SAFE_RELEASE( m_ipConsoleNameSpace );
00252   SAFE_RELEASE( m_ipConsole          );
00253
00254   return S_OK;
00255 }
00256
00257 //---------------------------------------------------------------------------
00258 //  MMC provides a NULL cookie for the static/root node.  In this sample
00259 //  we don't pass that on, instead we use the pointer to our static node
00260 //  object which handles notifications
00261 //
00262 HRESULT CComponentData::QueryDataObject
00263 (
00264   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00265   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00266   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00267 )
00268 {
00269   HRESULT hResult = S_FALSE;
00270   ULONG   uCookie = 0;
00271
00272   CDataObject* pNewObject = new CDataObject();
00273   if( NULL == pNewObject )
00274     return E_OUTOFMEMORY;
00275
00276   (0 == nCookie) ? uCookie = (ULONG)m_pStaticNode : uCookie = nCookie;
00277   pNewObject->SetPrivateData( uCookie, (ULONG)nEnumType );
00278
00279   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00280
00281   return hResult;
00282 }
00283
00284 //---------------------------------------------------------------------------
00285 //  Delegate the call to the static node object
00286 //
00287 HRESULT CComponentData::GetDisplayInfo
00288 (
00289   SCOPEDATAITEM* pScopeDataItem    //[out][in] Points to a SCOPEDATAITEM struct
00290 )
00291 {
00292   _ASSERT( NULL != pScopeDataItem );
00293   HRESULT hResult = S_OK;
00294
00295   // The console will only ask for the name string
00296   if(  pScopeDataItem->mask & SDI_STR )
00297   {
00298     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(pScopeDataItem->lParam);
00299     hResult = pNode->GetDisplayInfo( pScopeDataItem );
00300   }
00301
00302   return hResult;
00303 }
00304
00305 //---------------------------------------------------------------------------
00306 HRESULT CComponentData::CompareObjects
00307 (
00308   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00309   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00310 )
00311 {
00312   return E_NOTIMPL;
00313 }
00314
00315 //---------------------------------------------------------------------------
00316 HRESULT CComponentData::QueryDispatch
00317 (
00318   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00319   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00320   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00321 )
00322 {
00323   return E_NOTIMPL;
00324 }
00325
00326
00327 /////////////////////////////////////////////////////////////////////////////
00328 // Interface IExtendContextMenu
00329
00330 //---------------------------------------------------------------------------
00331 HRESULT CComponentData::AddMenuItems
00332 (
00333   LPDATAOBJECT ipDataObject,         //[in]
00334   LPCONTEXTMENUCALLBACK ipCallback,  //[in]
00335   long __RPC_FAR* pInsertionAllowed  //[out-in]
00336 )
00337 {
00338   _ASSERT( NULL != ipCallback );
00339   HRESULT hResult = S_FALSE;
00340
00341   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00342   if( NULL != pNode )
00343     hResult = pNode->AddMenuItems( ipCallback, pInsertionAllowed );
00344
00345   return hResult;
00346 }
00347
00348 //---------------------------------------------------------------------------
00349 //
00350 HRESULT CComponentData::Command
00351 (
00352   long         lCommandID,   //[in] Identifier of the menu item
00353   LPDATAOBJECT ipDataObject  //[in] DataObject for selected node
00354 )
00355 {
00356   HRESULT hResult = S_OK;
00357
00358   CBaseNode* pNode = ExtractBaseNodePtr( ipDataObject );
00359   if( NULL != pNode )
00360     hResult = pNode->Command( lCommandID );
00361
00362   return hResult;
00363 }
00364
00365 /////////////////////////////////////////////////////////////////////////////
00366 //  Helper methods
00367
00368 //---------------------------------------------------------------------------
00369 HRESULT CComponentData::GetInterface
00370 (
00371   DWORD     dwRequestedInterface,  //[in] Request flag
00372   LONG_PTR* ppInterface            //[in-out] Interface pointer to return
00373 )
00374 {
00375   _ASSERT( NULL != ppInterface );
00376   HRESULT hResult = S_OK;
00377
00378   switch( dwRequestedInterface )
00379   {
00380     case REQUEST_ICONSOLENAMESPACE:
00381       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleNameSpace);
00382       break;
00383
00384     case REQUEST_ICONSOLE:
00385       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00386       break;
00387
00388     default:
00389       hResult = S_FALSE;
00390       *ppInterface = NULL;
00391       break;
00392   }
00393
00394   return hResult;
00395 }
00396
00397
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/ComSpyCtl.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

ComSpyCtl.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018
00019 #include "resource.h"
00020 #include "initguid.h"
00021 #include "ComSpyCtl.h"
00022 #include "ComSpyAudit.h"
00023 #include <comsvcs.h>
00024 #include "CComSpy.h"
00025
00026 #include "AppInfo.h"
00027 #include "ComSpyPropPage.h"
00028
00029 #define IID_DEFINED
00030 #include "ComSpyAudit_i.c"
00031 #include "ComSpyCtl_i.c"
00032
00033 #ifdef _MERGE_PROXYSTUB
00034 extern "C" HINSTANCE hProxyDll;
00035 #endif
00036
00037
00038
00039 CComModule _Module;
00040
00041 BEGIN_OBJECT_MAP(ObjectMap)
00042   OBJECT_ENTRY(CLSID_ComSpy, CComSpy)
00043   OBJECT_ENTRY(CLSID_ComSpyPropPage, CComSpyPropPage)
00044 END_OBJECT_MAP()
00045
00046 /////////////////////////////////////////////////////////////////////////////
00047 // DLL Entry Point
00048
00049 extern "C"
00050 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00051 {
00052   lpReserved;
00053 #ifdef _MERGE_PROXYSTUB
00054   if (!PrxDllMain(hInstance, dwReason, lpReserved))
00055     return FALSE;
00056 #endif
00057   if (dwReason == DLL_PROCESS_ATTACH)
00058   {
00059     _Module.Init(ObjectMap, hInstance);
00060     DisableThreadLibraryCalls(hInstance);
00061   }
00062   else if (dwReason == DLL_PROCESS_DETACH)
00063     _Module.Term();
00064   return TRUE;    // ok
00065 }
00066
00067 /////////////////////////////////////////////////////////////////////////////
00068 // Used to determine whether the DLL can be unloaded by OLE
00069
00070 STDAPI DllCanUnloadNow(void)
00071 {
00072 #ifdef _MERGE_PROXYSTUB
00073   if (PrxDllCanUnloadNow() != S_OK)
00074     return S_FALSE;
00075 #endif
00076   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00077 }
00078
00079 /////////////////////////////////////////////////////////////////////////////
00080 // Returns a class factory to create an object of the requested type
00081
00082 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00083 {
00084 #ifdef _MERGE_PROXYSTUB
00085   if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00086     return S_OK;
00087 #endif
00088   return _Module.GetClassObject(rclsid, riid, ppv);
00089 }
00090
00091 /////////////////////////////////////////////////////////////////////////////
00092 // DllRegisterServer - Adds entries to the system registry
00093
00094 STDAPI DllRegisterServer(void)
00095 {
00096 #ifdef _MERGE_PROXYSTUB
00097   HRESULT hRes = PrxDllRegisterServer();
00098   if (FAILED(hRes))
00099     return hRes;
00100 #endif
00101   // registers object, typelib and all interfaces in typelib
00102   return _Module.RegisterServer(TRUE);
00103 }
00104
00105 /////////////////////////////////////////////////////////////////////////////
00106 // DllUnregisterServer - Removes entries from the system registry
00107
00108 STDAPI DllUnregisterServer(void)
00109 {
00110 #ifdef _MERGE_PROXYSTUB
00111   PrxDllUnregisterServer();
00112 #endif
00113   _Module.UnregisterServer();
00114   return S_OK;
00115 }
00116
00117
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/ComSpy.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

ComSpy.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include <comsvcs.h>
00019 #include "ComSpyCtl.h"
00020 #include "ComSpyAudit.h"
00021 #include "AppInfo.h"
00022 #include "CComSpy.h"
00023 #include "selecteventsdlg.h"
00024 #include "commdlg.h"
00025 #include <time.h>
00026 #include "shellapi.h"
00027
00028 LONGLONG PerformanceFrequency = 0;
00029
00030 //
00031 //  for some reason this define isn't being included
00032 //
00033
00034 // const GUID CLSID_StockFontPage = {0x7ebdaae0, 0x8120, 0x11cf, { 0x89, 0x9f, 0x0, 0xaa, 0x0, 0x68, 0x8b, 0x10}};
00035
00036
00037 //
00038 //  given a GUID, return its string representation
00039 //
00040 CComBSTR GuidToBstr(REFGUID guid)
00041 {
00042     CComBSTR b(40, L"");
00043     int nRet = StringFromGUID2(guid, b.m_str, 40);
00044     _ASSERTE(nRet);
00045     return b;
00046 }
00047
00048 /////////////////////////////////////////////////////////////////////////////
00049 // CComSpy
00050
00051 #define MAX_MSG_LENGTH (1024*sizeof(TCHAR))
00052 static LPTSTR sColNames[] = {_TEXT("Count"),_TEXT("Event"),_TEXT("Tick Count"),
00053     _TEXT("Application"),_TEXT("Parameter"),TEXT("Value")};
00054
00055
00056 CComSpy::CComSpy() :m_ctlSysListView32(_T("SysListView32"), this, 1)
00057 {
00058   m_hWndList = NULL;
00059   m_bLogToFile = FALSE;
00060   m_hFile = NULL;
00061   m_cEvents = 0;
00062   m_bShowGridLines = TRUE;
00063   m_bWindowOnly = TRUE;
00064   for (int i=0;i<NUMBER_COLUMNS;i++)
00065   {
00066     m_nWidth[i] = 60;
00067   }
00068
00069   m_hFont = NULL;
00070   m_bShowOnScreen = TRUE;
00071   m_bCSV = FALSE;
00072   m_bAudit = FALSE;
00073   m_pSqlAudit = NULL;
00074
00075   CComBSTR bstrAppName(_T("SysApp"));
00076   m_pSysAppInfo = new CAppInfo((TCHAR*)bstrAppName, this);
00077   _ASSERTE(m_pSysAppInfo);
00078 }
00079
00080
00081 HRESULT CComSpy::OnDrawAdvanced(ATL_DRAWINFO& di)
00082 {
00083   return S_OK;
00084 }
00085 LRESULT CComSpy::OnRButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00086 {
00087   HMENU hMenu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_SPYMENU));
00088   if (!hMenu)
00089   {
00090     _ASSERTE(0);
00091     return 0;
00092   }
00093   POINT local;
00094   local.x = LOWORD(lParam);
00095   local.y = HIWORD(lParam);
00096     ClientToScreen(&local);
00097   HMENU hPopup = GetSubMenu(hMenu, 0);
00098     _ASSERTE(hPopup != NULL);
00099   TrackPopupMenu(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, local.x, local.y, NULL, m_hWndList, NULL);
00100
00101   return 0;
00102 }
00103
00104 LRESULT CComSpy::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00105 {
00106   RECT rc;
00107   GetWindowRect(&rc);
00108   rc.right -= rc.left;
00109   rc.bottom -= rc.top;
00110   rc.top = rc.left = 0;
00111   DWORD dwStyle = WS_VISIBLE|WS_CHILD|LVS_REPORT|LVS_SINGLESEL|WS_BORDER;
00112   if (!m_hWndList)
00113     m_hWndList = m_ctlSysListView32.Create(m_hWnd, rc, _T(""), dwStyle);
00114
00115   _ASSERTE(m_hWndList);
00116   put_ShowGridLines(m_bShowGridLines);
00117
00118   //
00119   //  we always want the list to be Full Row Select --
00120   //  note: this only works if the user has IE 3.0 installed
00121   //
00122   dwStyle = ListView_GetExtendedListViewStyle(m_hWndList);
00123   dwStyle |= LVS_EX_FULLROWSELECT;
00124   ListView_SetExtendedListViewStyle(m_hWndList, dwStyle);
00125
00126   //
00127   //  create the columns in our list
00128   //
00129   LV_COLUMN col;
00130   memset(&col,NULL, sizeof(col));
00131   col.mask = LVCF_TEXT|LVCF_WIDTH;
00132   col.fmt = LVCFMT_LEFT;
00133   int i;
00134   for (i=0;i<NUMBER_COLUMNS;i++)
00135   {
00136     col.cx = m_nWidth[i];
00137     col.pszText = sColNames[i];
00138     col.cchTextMax  = lstrlen(col.pszText);
00139     ListView_InsertColumn(m_hWndList, i, &col);
00140   }
00141
00142     QueryPerformanceFrequency((LARGE_INTEGER *)&PerformanceFrequency);
00143
00144   if (m_hFont)
00145   {
00146     // this is set if the container app has set our properties using the property bag
00147     ::SendMessage(m_hWndList, WM_SETFONT, (WPARAM)m_hFont, MAKELPARAM(TRUE,0));
00148   }
00149
00150   return 0;
00151 }
00152
00153
00154 //
00155 //  update the UI in menus
00156 //
00157 LRESULT CComSpy::OnInitMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00158 {
00159   HMENU hMenu = (HMENU)wParam;
00160   CComBSTR temp = "Log to File ";
00161   if (m_sLogFile.Length() > 5)
00162     temp += m_sLogFile;
00163   else
00164     temp += "...";
00165
00166   USES_CONVERSION;
00167   ModifyMenu(hMenu, ID_LOG, MF_BYCOMMAND|MF_STRING, ID_LOG, OLE2T(temp));
00168   CheckMenuItem(hMenu, ID_LOG,  m_bLogToFile ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00169   CheckMenuItem(hMenu, ID_OPTIONS_GRID_LINES,  m_bShowGridLines ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00170   CheckMenuItem(hMenu, ID_SHOW_ON_SCREEN,  m_bShowOnScreen ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00171   CheckMenuItem(hMenu, ID_AUDIT,  m_bAudit ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED);
00172
00173   m_hMenuDebug = GetSubMenu(hMenu, 5);
00174   _ASSERTE(m_hMenuDebug);
00175   AddRunningAspsToDebugMenu(m_hMenuDebug);
00176
00177   return 0;
00178 }
00179
00180
00181 //
00182 //  sets a glog to log to file
00183 //  if the user hasn't chosen a log file, show the common dialog to allow them to select one
00184 //
00185 LRESULT CComSpy::OnLogToFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00186 {
00187
00188
00189   m_bLogToFile = 1 - m_bLogToFile;
00190   if (m_bLogToFile)
00191   {
00192     if (m_sLogFile.Length() == 0)
00193     {
00194       BOOL bHandled = TRUE;
00195       OnChooseLogFile(0,0,0,bHandled);
00196       if (m_sLogFile.Length() == 0)
00197         return 0;
00198     }
00199     m_hFile = CreateFile(m_sLogFile, GENERIC_WRITE,
00200               0, (LPSECURITY_ATTRIBUTES) NULL,
00201               OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
00202               (HANDLE) NULL);
00203
00204     if (!m_hFile)
00205     {
00206       m_bLogToFile = FALSE;
00207       return 0;
00208     }
00209
00210   }
00211   else
00212   {
00213     if (m_hFile)
00214     {
00215       CloseHandle(m_hFile);
00216       m_hFile = NULL;
00217     }
00218
00219   }
00220
00221   return 0;
00222 }
00223 //
00224 //  User wants to choose a log file -- show the common dialog
00225 //
00226 LRESULT CComSpy::OnChooseLogFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00227 {
00228
00229   USES_CONVERSION;
00230   OPENFILENAME OpenFileName;
00231   TCHAR         szFile[MAX_PATH];
00232   memset(szFile, NULL, MAX_PATH * sizeof(TCHAR));
00233   if (m_sLogFile.Length() > 2)
00234     lstrcpyn(szFile, OLE2T(m_sLogFile.m_str), m_sLogFile.Length());
00235   else
00236     lstrcpyn(szFile, _T("ComSpy.Log"), 10);
00237
00238     // Fill in the OPENFILENAME structure to support a template and hook.
00239   OpenFileName.lStructSize       = sizeof(OPENFILENAME);
00240     OpenFileName.hwndOwner         = m_hWndList;
00241     OpenFileName.hInstance         = _Module.GetModuleInstance( );
00242     OpenFileName.lpstrFilter       = _T("TAB seperated Files (*.log)\0*.log\0CSV Files (*.csv)\0*.csv\0");
00243     OpenFileName.lpstrCustomFilter = NULL;
00244     OpenFileName.nMaxCustFilter    = 0;
00245     OpenFileName.nFilterIndex      = 0;
00246     OpenFileName.lpstrFile          = szFile;
00247     OpenFileName.nMaxFile          = sizeof(szFile);
00248     OpenFileName.lpstrFileTitle    = NULL;
00249     OpenFileName.nMaxFileTitle     = 0;
00250     OpenFileName.lpstrInitialDir   = NULL;
00251     OpenFileName.lpstrTitle        = _T("Choose Log File");
00252     OpenFileName.nFileOffset       = 0;
00253     OpenFileName.nFileExtension    = 0;
00254     OpenFileName.lpstrDefExt       = NULL;
00255     OpenFileName.lCustData         = 0;
00256   OpenFileName.lpfnHook        = NULL;
00257   OpenFileName.lpTemplateName    = NULL;
00258     OpenFileName.Flags             = OFN_EXPLORER | OFN_HIDEREADONLY |OFN_NOREADONLYRETURN |OFN_CREATEPROMPT;
00259
00260   // Call the common dialog function.
00261     if (GetSaveFileName(&OpenFileName))
00262     {
00263     m_sLogFile = OpenFileName.lpstrFile;
00264     if (lstrcmpi(OpenFileName.lpstrFile + OpenFileName.nFileExtension, _T("csv")) == 0)
00265       m_bCSV = TRUE;
00266
00267   }
00268
00269   return 0;
00270
00271 }
00272
00273
00274 //
00275 //  show/hide gridlines in the list
00276 //
00277 //  NOTE:  This will only work if the user has installed IE 3.0 or greater
00278 //
00279 LRESULT CComSpy::OnToggleGridLines(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00280 {
00281
00282   m_bShowGridLines = 1 - m_bShowGridLines;
00283
00284   DWORD dwStyle = ListView_GetExtendedListViewStyle(m_hWndList);
00285   (m_bShowGridLines) ? dwStyle |= LVS_EX_GRIDLINES :
00286              dwStyle &= ~LVS_EX_GRIDLINES;
00287
00288   ListView_SetExtendedListViewStyle(m_hWndList, dwStyle);
00289
00290   return 0;
00291 }
00292
00293 //
00294 //  enable/disable auditing
00295 //
00296 //
00297 LRESULT CComSpy::OnToggleAudit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00298 {
00299
00300   m_bAudit = 1 - m_bAudit;
00301   HRESULT hr = EnableAudit(m_bAudit);
00302   if (hr != S_OK)
00303     m_bAudit = FALSE;
00304   return 0;
00305 }
00306
00307
00308 LRESULT CComSpy::OnToggleShowOnScreen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00309 {
00310   m_bShowOnScreen = 1-m_bShowOnScreen;
00311   return 0;
00312
00313 }
00314
00315 //
00316 //  show the standard Shell About box
00317 //
00318 LRESULT CComSpy::OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00319 {
00320   HICON hIcon =  LoadIcon(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAIN));
00321
00322   ShellAbout(m_hWnd, _T("COM Spy"), _T("Version 1.00"), hIcon);
00323   return 0;
00324 }
00325
00326 //
00327 //  clear the list box
00328 //
00329 LRESULT CComSpy::OnClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00330 {
00331
00332   ListView_DeleteAllItems(m_hWndList);
00333   m_cEvents = 0;
00334   return 0;
00335 }
00336
00337
00338 //
00339 //  save the items in the list box to the log file
00340 //
00341 LRESULT CComSpy::OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00342 {
00343   USES_CONVERSION;
00344   OPENFILENAME OpenFileName;
00345   TCHAR         szFile[MAX_PATH];
00346   memset(szFile, NULL, MAX_PATH * sizeof(TCHAR));
00347   if (m_sLogFile.Length() > 2)
00348     lstrcpyn(szFile, OLE2T(m_sLogFile.m_str), m_sLogFile.Length());
00349   else
00350     lstrcpyn(szFile, _T("COMSpy.Log"), 10);
00351
00352   OpenFileName.lStructSize       = sizeof(OPENFILENAME);
00353     OpenFileName.hwndOwner         = m_hWndList;
00354     OpenFileName.hInstance         = _Module.GetModuleInstance( );
00355     OpenFileName.lpstrFilter       = NULL;
00356     OpenFileName.lpstrCustomFilter = NULL;
00357     OpenFileName.nMaxCustFilter    = 0;
00358     OpenFileName.nFilterIndex      = 0;
00359     OpenFileName.lpstrFile          = szFile;
00360     OpenFileName.nMaxFile          = sizeof(szFile);
00361     OpenFileName.lpstrFileTitle    = NULL;
00362     OpenFileName.nMaxFileTitle     = 0;
00363     OpenFileName.lpstrInitialDir   = NULL;
00364     OpenFileName.lpstrTitle        = _T("Log ToFile");
00365     OpenFileName.nFileOffset       = 0;
00366     OpenFileName.nFileExtension    = 0;
00367     OpenFileName.lpstrDefExt       = NULL;
00368     OpenFileName.lCustData         = 0;
00369   OpenFileName.lpfnHook        = NULL;
00370   OpenFileName.lpTemplateName    = NULL;
00371     OpenFileName.Flags             = OFN_EXPLORER | OFN_HIDEREADONLY |OFN_NOREADONLYRETURN;
00372
00373   // Call the common dialog function.
00374     if (GetSaveFileName(&OpenFileName))
00375     {
00376
00377     FILE* f = _tfopen(OpenFileName.lpstrFile, _T("a+"));
00378     if (f)
00379     {
00380       int nCount = ListView_GetItemCount(m_hWndList);
00381       int i, j;
00382       TCHAR buf[MAX_MSG_LENGTH];
00383       for (i=0; i<nCount; i++)
00384       {
00385         for (j=0; j < 4; j++)
00386         {
00387           ListView_GetItemText(m_hWndList, i, j, buf, MAX_MSG_LENGTH);
00388           _ftprintf(f, _T("%s\t"),buf);
00389         }
00390         while ( i < nCount - 1)
00391         {
00392           i++; // move to next column
00393
00394           // now get the name/value pairs
00395           ListView_GetItemText(m_hWndList, i, 4, buf, MAX_MSG_LENGTH);
00396           if (*buf)
00397           {
00398
00399             _ftprintf(f, _T("\n\t\t\t\t%s\t"), buf);
00400             ListView_GetItemText(m_hWndList, i, 5, buf, MAX_MSG_LENGTH);
00401             _ftprintf(f, _T("%s"),buf);
00402           }
00403           else
00404           {
00405             i--;
00406             _ftprintf(f, _T("\n"));
00407             break;
00408           }
00409         }
00410       }
00411
00412       fclose(f);
00413     }
00414
00415
00416   }
00417
00418   return 0;
00419
00420
00421 }
00422
00423 //
00424 //  given the index to the list, we return TRUE if the index
00425 //  should scroll -- this occurs when the user is looking
00426 //  at the last element in the list.  If they have scrolled
00427 //  up to look at a previous element in the list, then we
00428 //  don't scroll when an event is added
00429 //
00430 BOOL CComSpy::ShouldScroll(int nIndex)
00431 {
00432   BOOL bRet = FALSE;
00433   int nCountPage = ListView_GetCountPerPage(m_hWndList);
00434   int nTopIndex = ListView_GetTopIndex(m_hWndList);
00435   if (nTopIndex + nCountPage>= nIndex)
00436     bRet = TRUE;
00437   return bRet;
00438 }
00439
00440 //
00441 //  disconnect & destroy all sinks associated with the given App
00442 //
00443 HRESULT CComSpy::ShutdownApplication(LPCOLESTR sApplicatioinName)
00444 {
00445
00446   USES_CONVERSION;
00447   CAppInfo * pInfo = m_map[W2A(sApplicatioinName)];
00448   if (!pInfo)
00449   {
00450     _ASSERTE(0); // we should never get this unless we have a sink for (at least) the Applicatioin events
00451     return E_FAIL;
00452   }
00453
00454   size_t nElementsRemoved = m_map.erase(W2A(sApplicatioinName));
00455   _ASSERTE(nElementsRemoved == 1);
00456   delete pInfo;
00457   return S_OK;
00458 }
00459
00460 //
00461 //  this method is called by all of the sinks to add an item to the list box
00462 //
00463 BOOL CComSpy::AddEventToList(LONGLONG perfCount, LPCOLESTR sEvent, LPCOLESTR sApplication)
00464 {
00465     long TickCount = 0;
00466     if (PerformanceFrequency != 0)
00467         TickCount = (long)((1000 * perfCount) / PerformanceFrequency);
00468
00469   BOOL bRet;
00470   if (m_bLogToFile)
00471   {
00472     TCHAR sSep[2];
00473     ZeroMemory(sSep,2 * sizeof(TCHAR));
00474     (m_bCSV) ? _tcsncat(sSep, _T(","), 1) : _tcsncat(sSep, _T("\t"),1);
00475     sSep[1] = NULL;
00476     _ASSERTE(m_hFile);
00477     TCHAR sBuf[MAX_MSG_LENGTH];
00478     ZeroMemory(sBuf, MAX_MSG_LENGTH*sizeof(TCHAR));
00479
00480     wsprintf(sBuf, _T("%s%s%d%s%s\n"), sEvent, sSep, TickCount, sSep, sApplication);
00481
00482     if (m_hFile)
00483     {
00484
00485       DWORD cbWritten;
00486       bRet = WriteFile(m_hFile, sBuf, lstrlen(sBuf) * sizeof(TCHAR), &cbWritten, NULL);
00487
00488     }
00489   }
00490   if (m_bShowOnScreen)
00491   {
00492     int nCount = ListView_GetItemCount(m_hWndList);
00493     LV_ITEM item;
00494     TCHAR sz[8];
00495     wsprintf(sz,_TEXT("%ld"), m_cEvents++);
00496     memset(&item, NULL, sizeof(item));
00497     item.mask = LVIF_TEXT;
00498     item.iItem = nCount;
00499     item.pszText = sz;
00500     item.cchTextMax = lstrlen(sz);
00501
00502     ListView_InsertItem(m_hWndList, &item);
00503     ListView_SetItemText(m_hWndList, nCount, 1, (LPWSTR)sEvent);
00504
00505     TCHAR szTick[16];
00506     wsprintf(szTick, _T("%ld"), TickCount);
00507     ListView_SetItemText(m_hWndList, nCount, 2, szTick);
00508     ListView_SetItemText(m_hWndList, nCount, 3, (LPWSTR)sApplication);
00509     if (ShouldScroll(nCount))
00510       ListView_EnsureVisible(m_hWndList, nCount, FALSE);
00511   }
00512   return TRUE;
00513 }
00514 //
00515 //  this method is called by all the sinks to add a Named/Value pair to the
00516 //  list
00517 //
00518 BOOL CComSpy::AddParamValueToList(LPCOLESTR sParamName, LPCOLESTR sValue)
00519 {
00520   BOOL bRet;
00521   if (m_bLogToFile)
00522   {
00523     TCHAR sSep[2];
00524     ZeroMemory(sSep,2 * sizeof(TCHAR));
00525     (m_bCSV) ? _tcsncat(sSep, _T(","),1) : _tcsncat(sSep, _T("\t"),1);
00526     sSep[1] = NULL;
00527     _ASSERTE(m_hFile);
00528     TCHAR sBuf[MAX_MSG_LENGTH];
00529     ZeroMemory(sBuf, MAX_MSG_LENGTH*sizeof(TCHAR));
00530     wsprintf(sBuf, _T("%s%s%s%s%s%s\n"), sSep, sSep, sSep, sParamName,sSep, sValue);
00531     if (m_hFile)
00532     {
00533
00534       DWORD cbWritten;
00535       bRet = WriteFile(m_hFile, sBuf, lstrlen(sBuf) * sizeof(TCHAR), &cbWritten, NULL);
00536     }
00537   }
00538   if (m_bShowOnScreen)
00539   {
00540     int nCount = ListView_GetItemCount(m_hWndList);
00541     LV_ITEM item;
00542     item.mask = LVIF_TEXT;
00543     item.iItem = nCount;
00544     item.pszText = _T("");
00545     item.cchTextMax = 1;
00546     item.iSubItem = 0;
00547     int nItem;
00548     nItem = ListView_InsertItem(m_hWndList, &item);
00549     ListView_SetItemText(m_hWndList, nItem, 4, (LPWSTR)sParamName);
00550     ListView_SetItemText(m_hWndList, nItem, 5, (LPWSTR)sValue);
00551     if (ShouldScroll(nCount))
00552       ListView_EnsureVisible(m_hWndList, nItem, FALSE);
00553   }
00554
00555
00556   return TRUE;
00557 }
00558
00559 //
00560 //  show the select Applications dialog
00561 //
00562 LRESULT CComSpy::OnSelectApplications(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00563 {
00564   CSelectEventsDlg dlg(&m_map, m_pSysAppInfo, this);
00565   dlg.DoModal();
00566   return 0;
00567 }
00568
00569
00570 LRESULT CComSpy::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00571 {
00572   bHandled = FALSE; // continue processing
00573
00574   //
00575   //  clean up our application information
00576   //
00577   MapStringToAppInfo::iterator iter;
00578   CAppInfo * pInfo;
00579   for (iter = m_map.begin(); iter != m_map.end(); ++iter)
00580   {
00581
00582     pInfo = (*iter).second;
00583     delete pInfo;
00584   }
00585   m_map.clear();
00586
00587   if(m_pSysAppInfo)
00588     delete m_pSysAppInfo;
00589
00590
00591   if (m_hFont)
00592   {
00593     DeleteObject(m_hFont);
00594     m_hFont = NULL;
00595   }
00596
00597   m_bLogToFile = FALSE;
00598   if (m_hFile)
00599   {
00600     CloseHandle(m_hFile);
00601     m_hFile = NULL;
00602   }
00603
00604   m_cEvents = 0;
00605   m_bShowGridLines = TRUE;
00606   return 0;
00607 }
00608 //
00609 //  show only the ChooseFont property page
00610 //
00611 LRESULT CComSpy::OnChooseFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00612 {
00613   HRESULT hr = S_OK;
00614   CComPtr<IUnknown> pUnk;
00615   ControlQueryInterface(IID_IUnknown, (void**)&pUnk);
00616   _ASSERTE(pUnk != NULL);
00617   LPOLESTR szTitle = _T("Com Spy - Choose Font");
00618   hr = OleCreatePropertyFrame(m_hWnd, m_rcPos.top, m_rcPos.left, szTitle,
00619     1, &pUnk.p, 1, (GUID *)&CLSID_StockFontPage, LOCALE_USER_DEFAULT, 0, 0);
00620
00621   return 0;
00622 }
00623
00624 STDMETHODIMP CComSpy::get_LogFile(BSTR * pVal)
00625 {
00626   *pVal = m_sLogFile.Copy();
00627   return S_OK;
00628 }
00629
00630 STDMETHODIMP CComSpy::put_LogFile(BSTR newVal)
00631 {
00632
00633   HANDLE hTemp;
00634   hTemp = CreateFile(newVal, GENERIC_WRITE,
00635             0, (LPSECURITY_ATTRIBUTES) NULL,
00636             OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
00637             (HANDLE) NULL);
00638
00639
00640   if (hTemp)
00641   {
00642     if (m_hFile)
00643     {
00644       CloseHandle(m_hFile);
00645     }
00646
00647     m_hFile = hTemp;
00648   }
00649   else
00650     return E_INVALIDARG;
00651
00652
00653   m_sLogFile = newVal;
00654   return S_OK;
00655 }
00656
00657 STDMETHODIMP CComSpy::get_ShowGridLines(BOOL * pVal)
00658 {
00659   *pVal = m_bShowGridLines;
00660   return S_OK;
00661 }
00662
00663 STDMETHODIMP CComSpy::put_ShowGridLines(BOOL newVal)
00664 {
00665
00666   m_bShowGridLines = newVal;
00667   DWORD dwStyle = ListView_GetExtendedListViewStyle(m_hWndList);
00668   (m_bShowGridLines) ? dwStyle |= LVS_EX_GRIDLINES :
00669              dwStyle &= ~LVS_EX_GRIDLINES;
00670
00671   ListView_SetExtendedListViewStyle(m_hWndList, dwStyle);
00672   FireViewChange();
00673   return S_OK;
00674 }
00675
00676
00677 STDMETHODIMP CComSpy::get_Audit(BOOL * pVal)
00678 {
00679   *pVal = m_bAudit;
00680   return S_OK;
00681 }
00682
00683 STDMETHODIMP CComSpy::put_Audit(BOOL newVal)
00684 {
00685
00686   m_bAudit = newVal;
00687   EnableAudit(m_bAudit);
00688   return S_OK;
00689 }
00690
00691
00692 STDMETHODIMP CComSpy::get_ColWidth(short nColumn, long * pVal)
00693 {
00694   _ASSERTE(m_hWndList);
00695   _ASSERTE(nColumn >= 0 && nColumn <= NUMBER_COLUMNS);
00696   *pVal = ListView_GetColumnWidth(m_hWndList, nColumn);
00697   return S_OK;
00698 }
00699
00700 STDMETHODIMP CComSpy::put_ColWidth(short nColumn, long newVal)
00701 {
00702   if (nColumn >= NUMBER_COLUMNS)
00703     return E_INVALIDARG;
00704
00705   m_nWidth[nColumn] = newVal;
00706   ListView_SetColumnWidth(m_hWndList, nColumn, newVal);
00707   FireViewChange();
00708   return S_OK;
00709 }
00710
00711
00712 HRESULT CComSpy::IPersistStreamInit_Load(LPSTREAM pStm, ATL_PROPMAP_ENTRY* pMap)
00713 {
00714
00715   ULONG cbRead;
00716
00717   // read in the version
00718   UINT nVersion;
00719   pStm -> Read((void *)&nVersion, sizeof(UINT), &cbRead);
00720   if (nVersion != 3)
00721   {
00722     ::MessageBox(m_hWndList, _T("The saved information is from a different version of the control.\n\nThe saved state will have to be discarded."), _T("COM Spy"), MB_ICONINFORMATION);
00723     return S_OK;
00724   }
00725
00726   // get log file size
00727   long lLen;
00728   pStm -> Read((void *)&lLen, sizeof(long), &cbRead);
00729
00730   // read in the chars for the log name
00731   char * pLog = new char[lLen+1];
00732   ZeroMemory(pLog, lLen+1);
00733   pStm -> Read((void*)pLog, lLen, &cbRead);
00734
00735   m_sLogFile = pLog;
00736   delete [] pLog;
00737
00738   // gridlines
00739   pStm -> Read((void *)&m_bShowGridLines, sizeof(BOOL),&cbRead);
00740   put_ShowGridLines(m_bShowGridLines);
00741
00742   // show on screen
00743   pStm -> Read((void *)&m_bShowOnScreen, sizeof(BOOL),&cbRead);
00744   put_ShowOnScreen(m_bShowOnScreen);
00745
00746   // log to file
00747   pStm -> Read((void *)&m_bLogToFile, sizeof(BOOL),&cbRead);
00748   put_LogToFile(m_bLogToFile);
00749
00750   // csv files
00751   pStm -> Read((void *)&m_bCSV, sizeof(BOOL), &cbRead);
00752
00753   // csv files
00754   pStm -> Read((void *)&m_bAudit, sizeof(BOOL), &cbRead);
00755   EnableAudit(m_bAudit);
00756
00757   // read the col widths
00758   int i;
00759   long nWidth;
00760   for (i=0;i<NUMBER_COLUMNS;i++)
00761   {
00762     pStm -> Read((void *)&nWidth, sizeof(long), &cbRead);
00763     put_ColWidth(i, nWidth);
00764   }
00765
00766   BOOL bCustomFont = FALSE;
00767   pStm -> Read((void *)&bCustomFont, sizeof(BOOL),&cbRead);
00768   if (bCustomFont)
00769   {
00770     if (!m_pFont)
00771     {
00772       //create an IFontDisp
00773       HRESULT hr= CoCreateInstance(CLSID_StdFont, NULL, CLSCTX_ALL, IID_IFontDisp, (void **)&m_pFont);
00774       _ASSERTE(SUCCEEDED(hr));
00775     }
00776     if (m_pFont)
00777     {
00778       IPersistStream * pFontSt = NULL;
00779       m_pFont -> QueryInterface(IID_IPersistStream, (void **)&pFontSt);
00780       pFontSt -> Load(pStm);
00781       pFontSt -> Release();
00782       if (m_hFont) // should I tell the list that I deleted its font?
00783         DeleteObject(m_hFont);
00784       IFont * pFont = NULL;
00785       m_pFont -> QueryInterface(IID_IFont, (void **)&pFont);
00786       _ASSERTE(pFont);
00787       m_hFont = CreateHFontFromIFont(pFont);
00788       pFont -> Release();
00789     }
00790   }
00791
00792
00793   return S_OK;
00794 }
00795 HRESULT CComSpy::IPersistStreamInit_Save(LPSTREAM pStm, BOOL /* fClearDirty */, ATL_PROPMAP_ENTRY* pMap)
00796 {
00797   _ASSERTE(this);
00798   _ASSERTE(m_hWndList);
00799
00800   ULONG cbWritten = 0;
00801   // write a version
00802   UINT nVersion  = 3;
00803   pStm -> Write((void *)&nVersion, sizeof(UINT), &cbWritten);
00804
00805   // write the log file size
00806   long nChars = m_sLogFile.Length();
00807   pStm -> Write((void *)&nChars, sizeof(long), &cbWritten);
00808   _ASSERTE(cbWritten == sizeof(long));
00809
00810   // write the log file name (in ANSI!)
00811   USES_CONVERSION;
00812   char * sFile = W2A((BSTR)m_sLogFile);
00813   pStm -> Write((void *)sFile, m_sLogFile.Length(), &cbWritten);
00814
00815   // write the BOOL if gridlines should be shown
00816   pStm -> Write((void *)&m_bShowGridLines, sizeof(BOOL), &cbWritten);
00817
00818   // write the BOOL if the user wants to see the messages
00819   pStm -> Write((void *)&m_bShowOnScreen, sizeof(BOOL), &cbWritten);
00820
00821   // write the BOOL if the user wants to log the messages
00822   pStm -> Write((void *)&m_bLogToFile, sizeof(BOOL), &cbWritten);
00823
00824   // write the BOOL if we have CSV files
00825   pStm -> Write((void *)&m_bCSV, sizeof(BOOL), &cbWritten);
00826
00827   // write the BOOL if Auditing is enabled
00828   pStm -> Write((void *)&m_bAudit, sizeof(BOOL), &cbWritten);
00829
00830   // write the col widths
00831   int i;
00832   long nWidth;
00833   for (i=0;i<NUMBER_COLUMNS;i++)
00834   {
00835     get_ColWidth(i, &nWidth);
00836     _ASSERTE(nWidth);
00837     pStm -> Write((void *)&nWidth, sizeof(long), &cbWritten);
00838   }
00839
00840   // ask the font to persist itself in the stream
00841   BOOL bCustomFont;
00842   if (m_pFont)
00843   {
00844     bCustomFont = TRUE;
00845     pStm -> Write((void *)&bCustomFont, sizeof(BOOL), &cbWritten);
00846     IPersistStream * pSt = NULL;
00847     m_pFont -> QueryInterface(IID_IPersistStream, (void **)&pSt);
00848     _ASSERTE(pSt);
00849     pSt -> Save(pStm, FALSE);
00850     pSt -> Release();
00851   }
00852   else
00853   {
00854     bCustomFont = FALSE;
00855     pStm -> Write((void *)&bCustomFont, sizeof(BOOL), &cbWritten);
00856   }
00857
00858   return S_OK;
00859 }
00860
00861
00862
00863 HRESULT CComSpy::Close( DWORD dwSaveOption )
00864 {
00865   return IOleObject_Close(dwSaveOption);
00866 }
00867
00868 HFONT CComSpy::CreateHFontFromIFont(IFont * pFont)
00869 {
00870
00871   _ASSERTE(pFont);
00872   HFONT hFont;
00873   LOGFONT lf;
00874   ZeroMemory(&lf, sizeof(lf));
00875   CComBSTR bstr;
00876   pFont -> get_Name(&bstr);
00877   lstrcpyn(lf.lfFaceName, bstr.m_str, bstr.Length());
00878   CY cy;
00879   pFont -> get_Size(&cy);
00880   HDC hDC = ::GetDC(NULL);
00881   _ASSERTE(hDC);
00882   long lCaps = GetDeviceCaps(hDC, LOGPIXELSY);
00883   lf.lfHeight =  -MulDiv(cy.Hi, lCaps, 72);
00884   lf.lfHeight += -MulDiv(cy.Lo, lCaps, 720000);
00885   ::ReleaseDC(NULL, hDC);
00886   short sVal;
00887   pFont -> get_Weight(&sVal);
00888   lf.lfWeight  = sVal;
00889   BOOL bFlag;
00890   pFont -> get_Italic(&bFlag);
00891   lf.lfItalic = bFlag;
00892   pFont -> get_Underline(&bFlag);
00893   lf.lfUnderline = bFlag;
00894   pFont -> get_Strikethrough(&bFlag);
00895   lf.lfStrikeOut = bFlag;
00896   pFont -> get_Charset(&sVal);
00897   lf.lfCharSet = (BYTE)sVal;
00898   hFont = CreateFontIndirect(&lf);
00899   return hFont;
00900
00901 }
00902
00903 STDMETHODIMP CComSpy::SelectApplications()
00904 {
00905   BOOL bHandled;
00906   OnSelectApplications(0,0,0,bHandled);
00907   return S_OK;
00908 }
00909
00910 STDMETHODIMP CComSpy::SaveToFile()
00911 {
00912
00913   BOOL bHandled;
00914   OnSave(0,0,0,bHandled);
00915   return S_OK;
00916 }
00917
00918 STDMETHODIMP CComSpy::ClearAllEvents()
00919 {
00920
00921   BOOL bHandled;
00922   OnClear(0,0,0,bHandled);
00923   return S_OK;
00924 }
00925
00926 STDMETHODIMP CComSpy::About()
00927 {
00928   BOOL bHandled;
00929   OnAbout(0,0,0,bHandled);
00930   return S_OK;
00931 }
00932
00933 STDMETHODIMP CComSpy::get_LogToFile(BOOL * pVal)
00934 {
00935   *pVal = m_bLogToFile;
00936   return S_OK;
00937 }
00938
00939 STDMETHODIMP CComSpy::put_LogToFile(BOOL newVal)
00940 {
00941   m_bLogToFile = newVal;
00942   if (m_bLogToFile)
00943   {
00944     if (m_sLogFile.Length() == 0)
00945     {
00946       BOOL bHandled = TRUE;
00947       OnChooseLogFile(0,0,0,bHandled);
00948       if (m_sLogFile.Length() == 0)
00949         return 0;
00950     }
00951
00952     if (m_hFile)
00953     {
00954       CloseHandle(m_hFile);
00955       m_hFile = NULL;
00956     }
00957
00958     m_hFile = CreateFile(m_sLogFile, GENERIC_WRITE,
00959               0, (LPSECURITY_ATTRIBUTES) NULL,
00960               OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
00961               (HANDLE) NULL);
00962
00963     if (!m_hFile)
00964     {
00965       m_bLogToFile = FALSE;
00966       return E_FAIL;
00967     }
00968
00969   }
00970   else
00971   {
00972     if (m_hFile)
00973     {
00974       CloseHandle(m_hFile);
00975       m_hFile = NULL;
00976     }
00977
00978   }
00979   return S_OK;
00980 }
00981
00982 STDMETHODIMP CComSpy::ChooseFont()
00983 {
00984   BOOL bHandled;
00985   OnChooseFont(0,0,0,bHandled);
00986   return S_OK;
00987 }
00988
00989 STDMETHODIMP CComSpy::get_ShowOnScreen(BOOL * pVal)
00990 {
00991   *pVal = m_bShowOnScreen;
00992   return S_OK;
00993 }
00994
00995 STDMETHODIMP CComSpy::put_ShowOnScreen(BOOL newVal)
00996 {
00997   m_bShowOnScreen = newVal;
00998   return S_OK;
00999 }
01000
01001 STDMETHODIMP CComSpy::ChooseLogFile(BSTR * sLogFileName, BOOL * bCanceled)
01002 {
01003   *bCanceled = TRUE;
01004   BOOL bHandled = TRUE;
01005   OnChooseLogFile(0,0,0,bHandled);
01006   if (m_sLogFile.Length() == 0)
01007   {
01008     return S_OK;
01009   }
01010
01011   *sLogFileName = ::SysAllocString(m_sLogFile.m_str);
01012   *bCanceled = FALSE;
01013   return S_OK;
01014 }
01015 //
01016 //  loop through the ROT and add Application names
01017 //  to the debug menu
01018 //
01019 BOOL CComSpy::AddRunningAspsToDebugMenu(HMENU hMenu)
01020 {
01021
01022 //
01023 //  remove the <No Running Applications> menu item
01024 //
01025
01026   RemoveMenu(hMenu, 0, MF_BYPOSITION);
01027
01028   HRESULT hr = E_FAIL;
01029   IMtsGrp * pMtsGrp = NULL;
01030   hr = CoCreateInstance (CLSID_MtsGrp, NULL, CLSCTX_ALL, IID_IMtsGrp, (void **)&pMtsGrp);
01031   if (!pMtsGrp)
01032   {
01033     _ASSERTE(0);
01034     return FALSE;
01035   }
01036
01037   long lApplications;
01038   pMtsGrp -> Refresh(); // its important to call this!
01039   pMtsGrp -> get_Count(&lApplications);
01040
01041   IUnknown * pUnk = NULL;
01042   IMtsEvents * pEvents = NULL;
01043   USES_CONVERSION;
01044   long lPID;
01045   TCHAR szBuf[128];
01046   for (int i=0; i<lApplications; i++)
01047   {
01048
01049     pMtsGrp -> Item(i, &pUnk);
01050     _ASSERTE(pUnk);
01051     pUnk -> QueryInterface(IID_IMtsEvents, (void **)&pEvents);
01052     _ASSERTE(pEvents);
01053     if (SUCCEEDED(hr))
01054     {
01055
01056       CComBSTR sName;
01057       pEvents -> get_PackageName(&sName.m_str);
01058       pEvents -> GetProcessID(&lPID);
01059       ZeroMemory(szBuf, 128*sizeof(TCHAR));
01060       if (sName.m_str)
01061       {
01062         wsprintf(szBuf, _T("%s - PID: %ld"), sName.m_str, lPID);
01063         int nRet = InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING, ID_DEBUG_BEGIN + i, szBuf);
01064       }
01065       SafeRelease(pEvents);
01066
01067     }
01068
01069     SafeRelease(pEvents);
01070     SafeRelease(pUnk);
01071   }
01072
01073   SafeRelease(pMtsGrp);
01074   return TRUE;
01075 }
01076
01077 //
01078 //  user wants to debug a Application --
01079 //
01080 //  NOTE:   This is designed to work with Microsoft Developer Studio
01081 //      if you want to add support for another tool, modify the
01082 //      ShellExecute() line below.  This is alson non-robust in
01083 //      the sense that it requires MSDEV.EXE to be in the path
01084 //      and set up correctly.
01085 //
01086 LRESULT CComSpy::OnDebugApplication(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
01087 {
01088
01089   HCURSOR hBusy = LoadCursor(NULL, IDC_WAIT);
01090   HCURSOR hOldCur = SetCursor(hBusy);
01091   TCHAR szBuf[128];
01092   ZeroMemory(szBuf, 128 * sizeof(TCHAR));
01093   int nChars;
01094   _ASSERTE(m_hMenuDebug);
01095   nChars = GetMenuString(m_hMenuDebug, wID, szBuf, 128, MF_BYCOMMAND);
01096   if (nChars)
01097   {
01098     int nCount = lstrlen(szBuf);
01099     LPTSTR p = szBuf + nCount;
01100     while (*p-- != ':' && nCount)
01101     {
01102       nCount --;
01103     }
01104
01105     if (nCount == 0)
01106     {
01107       SetCursor(hOldCur);
01108       return 0;
01109     }
01110
01111     p+=3;
01112     TCHAR buf[MAX_PATH];
01113     wsprintf(buf, _T("-p %s -e %s"), p, p);
01114     HINSTANCE hInst = ShellExecute( NULL, _T("open"), _T("msdev"), buf, NULL, SW_SHOWNORMAL);
01115   }
01116   SetCursor(hOldCur);
01117   return 0;
01118 }
01119 //
01120 //  Enable/Disable auditing
01121 //
01122 HRESULT CComSpy::EnableAudit(BOOL bEnable)
01123 {
01124
01125   if (!bEnable)
01126   {
01127     SafeRelease(m_pSqlAudit);
01128     return S_OK;
01129   }
01130
01131   if (m_pSqlAudit)    // make EnableAudit() idempotent -- we are already enabled
01132     return S_OK;
01133
01134   HRESULT hr;
01135   hr = CoCreateInstance(CLSID_ComSpyAudit, NULL, CLSCTX_ALL, IID_IComSpyAudit, (void **)&m_pSqlAudit);
01136   if (SUCCEEDED(hr))
01137   {
01138     //
01139     //  these hard coded strings (user and pw) should be looked up in the registry for a production
01140     //  app
01141     hr = m_pSqlAudit -> Init(L"ComSpyAudit", L"sa", L"");
01142     if (FAILED(hr))
01143     {
01144       LPTSTR sMsg = _T("Unable to connect to DSN 'ComSpyAudit'.\nMake sure that the DSN exists,the Database has the\n \
01145 schema contained in ComSpyAudit.SQL, and you have \nthe permission to access the database.");
01146
01147       ::MessageBox(m_hWndList, sMsg,  _T("ComSpy"), MB_ICONSTOP);
01148       SafeRelease(m_pSqlAudit);
01149     }
01150   }
01151   else
01152   {
01153
01154     ::MessageBox(m_hWndList, _T("Unable to create the ComSpyAudit component!"),  _T("ComSpy"), MB_ICONSTOP);
01155   }
01156
01157   return hr;
01158 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/dataobj.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

dataobj.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _CLASS_CDATAOBJECT_
00015 #define _CLASS_CDATAOBJECT_
00016
00017 #include "Globals.h"
00018 #include "StaticNode.h"
00019
00020 //---------------------------------------------------------------------------
00021 class CDataObject : public IDataObject
00022 {
00023   private:
00024     ULONG     m_cRef;
00025     ULONG_PTR m_uCookie;
00026     ULONG     m_uContext;
00027
00028   public:
00029     CDataObject();
00030     ~CDataObject();
00031
00032   public:  // Interface IUnknown
00033     STDMETHODIMP QueryInterface( REFIID riid, LPVOID* ppv );
00034     STDMETHODIMP_(ULONG) AddRef();
00035     STDMETHODIMP_(ULONG) Release();
00036
00037   public:  // IDataObject methods
00038     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00039
00040     // The rest are not implemented
00041     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00042     { return E_NOTIMPL; };
00043
00044     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00045     { return E_NOTIMPL; };
00046
00047     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00048     { return E_NOTIMPL; };
00049
00050     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00051     { return E_NOTIMPL; };
00052
00053     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00054     { return E_NOTIMPL; };
00055
00056     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00057     { return E_NOTIMPL; };
00058
00059     STDMETHODIMP DUnadvise (DWORD dwConnection)
00060     { return E_NOTIMPL; };
00061
00062     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00063     { return E_NOTIMPL; };
00064
00065   ///////////////////////////////////////////////////////////////////////////
00066   // Custom Methods
00067   public:
00068     VOID   SetPrivateData( ULONG_PTR uCookie, ULONG uContext );
00069
00070     // For future use, not used in this sample
00071     ULONG  GetContext() { return m_uContext; }
00072     ULONG_PTR  GetCookie()  { return m_uCookie;  }
00073
00074   ///////////////////////////////////////////////////////////////////////////
00075   // Handlers for required clipboard formats
00076   private:
00077     HRESULT  RetrieveDisplayString( IStream* ipStream );
00078     HRESULT  RetrieveSnapInClassID( IStream* ipStream );
00079     HRESULT  RetrieveNodeTypeGuid( IStream* ipStream );
00080     HRESULT  RetrieveGuidString( IStream* ipStream );
00081
00082 };
00083
00084 #endif _CLASS_CDATAOBJECT_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/land.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/CacheProxy/csharp/cacheproxysampleplugin.cs Source File

  • Multimedia
  • WindowsMediaServices9
  • CacheProxy
  • csharp

cacheproxysampleplugin.cs

Go to the documentation of this file.
00001 ﻿//------------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // <autogenerated>
00007 //     This code was generated by a tool.
00008 //     Runtime Version: 1.0.3705.0
00009 //
00010 //     Changes to this file may cause incorrect behavior and will be lost if
00011 //     the code is regenerated.
00012 // </autogenerated>
00013 //------------------------------------------------------------------------------
00014
00015 //
00016 // This source code was auto-generated by xsd, Version=1.0.3705.0.
00017 //
00018 using System.Xml.Serialization;
00019
00020
00021 /// <remarks/>
00022 [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/wms/2002/07/wmsCacheProxyConfigSchema")]
00023 [System.Xml.Serialization.XmlRootAttribute(Namespace="http://schemas.microsoft.com/wms/2002/07/wmsCacheProxyConfigSchema", IsNullable=false)]
00024 public class PersistedConfiguration {
00025
00026     /// <remarks/>
00027     [System.Xml.Serialization.XmlElementAttribute(DataType="normalizedString")]
00028     public string cacheDirectoryPath;
00029
00030     /// <remarks/>
00031     public int diskQuota;
00032
00033     /// <remarks/>
00034     public int archiveQuotaPerStream;
00035
00036     /// <remarks/>
00037     [System.Xml.Serialization.XmlElementAttribute(DataType="anyURI", IsNullable=true)]
00038     public string reverseProxyRedirectURL;
00039
00040     /// <remarks/>
00041     [System.Xml.Serialization.XmlElementAttribute(DataType="normalizedString", IsNullable=true)]
00042     public string backendServer;
00043
00044     /// <remarks/>
00045     public bool enableCaching;
00046
00047     /// <remarks/>
00048     public bool enableProxy;
00049
00050     /// <remarks/>
00051     public bool proxyOnDemandCacheMiss;
00052
00053     /// <remarks/>
00054     public bool cacheOnDemandCacheMiss;
00055
00056     /// <remarks/>
00057     public bool handleUpstreamCacheRequests;
00058
00059     /// <remarks/>
00060     public protocolEnum protocol;
00061 }
00062
00063 /// <remarks/>
00064 [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/wms/2002/07/wmsCacheProxyConfigSchema")]
00065 public enum protocolEnum {
00066
00067     /// <remarks/>
00068     clientprotocol,
00069
00070     /// <remarks/>
00071     HTTP,
00072
00073     /// <remarks/>
00074     RTSPU,
00075
00076     /// <remarks/>
00077     RTSPT,
00078 }
00079
00080 /// <remarks/>
00081 [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/wms/2002/07/wmsCacheProxyConfigSchema")]
00082 [System.Xml.Serialization.XmlRootAttribute("PersistedConfigurationDataSet", Namespace="http://schemas.microsoft.com/wms/2002/07/wmsCacheProxyConfigSchema", IsNullable=false)]
00083 public class PersistedConfigurationDataSet {
00084
00085     /// <remarks/>
00086     [System.Xml.Serialization.XmlElementAttribute("PersistedConfiguration")]
00087     public PersistedConfiguration[] Items;
00088 }
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCrmDebugCompensator Member List

This is the complete list of members for CCrmDebugCompensator, including all inherited members.
AbortRecord(CrmLogRecordRead crmLogRec, BOOL __RPC_FAR *pfForget) | CCrmDebugCompensator |
AbortRecordVariants(VARIANT __RPC_FAR *pLogRecord, VARIANT_BOOL __RPC_FAR *pbForget) | CCrmDebugCompensator |
BeginAbort(BOOL fRecovery) | CCrmDebugCompensator |
BeginAbortVariants(VARIANT_BOOL bRecovery) | CCrmDebugCompensator |
BeginCommit(BOOL fRecovery) | CCrmDebugCompensator |
BeginCommitVariants(VARIANT_BOOL bRecovery) | CCrmDebugCompensator |
BeginPrepare(void) | CCrmDebugCompensator |
BeginPrepareVariants(void) | CCrmDebugCompensator |
CCrmDebugCompensator() | CCrmDebugCompensator | [inline]
CommitRecord(CrmLogRecordRead crmLogRec, BOOL __RPC_FAR *pfForget) | CCrmDebugCompensator |
CommitRecordVariants(VARIANT __RPC_FAR *pLogRecord, VARIANT_BOOL __RPC_FAR *pbForget) | CCrmDebugCompensator |
EndAbort(void) | CCrmDebugCompensator |
EndAbortVariants(void) | CCrmDebugCompensator |
EndCommit(void) | CCrmDebugCompensator |
EndCommitVariants(void) | CCrmDebugCompensator |
EndPrepare(BOOL __RPC_FAR *pfOkToPrepare) | CCrmDebugCompensator |
EndPrepareVariants(VARIANT_BOOL __RPC_FAR *pbOkToPrepare) | CCrmDebugCompensator |
FinalConstruct() | CCrmDebugCompensator |
FinalRelease() | CCrmDebugCompensator |
m_pUnkMarshaler | CCrmDebugCompensator |
PrepareRecord(CrmLogRecordRead crmLogRec, BOOL __RPC_FAR *pfForget) | CCrmDebugCompensator |
PrepareRecordVariants(VARIANT __RPC_FAR *pLogRecord, VARIANT_BOOL __RPC_FAR *pbForget) | CCrmDebugCompensator |
SetLogControl(ICrmLogControl __RPC_FAR *pLogControl) | CCrmDebugCompensator |
SetLogControlVariants(ICrmLogControl __RPC_FAR *pLogControl) | CCrmDebugCompensator |
Generated on Wed Nov 13 2024 16:55:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/dataobj.h Source File

  • SysMgmt
  • MMC
  • ActiveX

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/VCAcct/moveMoney.Cpp Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • VCAcct

moveMoney.Cpp

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: MoveMoney.cpp
00003 //
00004 // Description: Implementation of CMoveMoney
00005 //
00006 //
00007 // This file is part of the Microsoft COM+ Samples
00008 //
00009 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00010 //
00011 // This source code is intended only as a supplement to Microsoft
00012 // Development Tools and/or on-line documentation.  See these other
00013 // materials for detailed information reagrding Microsoft code samples.
00014 //
00015 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 // PARTICULAR PURPOSE.
00019 //
00020 //==============================================================================
00021
00022
00023 #include "stdafx.h"
00024 #include "Account.h"
00025 #include "MoveMoney.h"
00026 #include "Account.h"
00027 #include "GetReceipt.h"
00028
00029 #include <comsvcs.h>
00030 #include <comdef.h>
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 //
00034
00035 STDMETHODIMP CMoveMoney::InterfaceSupportsErrorInfo(REFIID riid)
00036 {
00037   static const IID* arr[] =
00038   {
00039     &IID_IMoveMoney,
00040   };
00041
00042   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00043   {
00044     if (::InlineIsEqualGUID(*arr[i],riid))
00045       return S_OK;
00046   }
00047   return S_FALSE;
00048 }
00049
00050 //F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++
00051 //
00052 // Function:  Perform
00053 //
00054 // Modifies the specified account by the specified amount
00055 //
00056 // Args:  lPrimeAccount:    "From" Account
00057 //      lSecondAccount:   "To" Account
00058 //      lngAmount:      Amount of transaction
00059 //      lngTranType:    Transaction Type:
00060 //                1 - Debit
00061 //                2 - Credit
00062 //                3 - Transfer
00063 //
00064 // Returns:   S_OK or E_FAIL
00065 //
00066 //F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-
00067 STDMETHODIMP CMoveMoney::Perform (IN long lPrimeAccount, IN long lSecondAccount, IN long lAmount,
00068                   IN long lTranType, OUT BSTR* pbstrResult) {
00069
00070   USES_CONVERSION;
00071
00072   HRESULT hr = S_OK;
00073
00074   IObjectContext* pObjectContext = NULL;
00075
00076   IAccount* pObjAccount = NULL;
00077   IGetReceipt* pObjGetReceipt = NULL;
00078
00079   long lErrFlag = 0;
00080   TCHAR* pErrMsg = NULL;
00081
00082   BSTR bstrResult2 = NULL;
00083   BSTR bstrCall1 = NULL;
00084   BSTR bstrCall2 = NULL;
00085
00086   *pbstrResult = NULL;
00087
00088   try {
00089
00090     // Get the object context
00091     THROW_ERR (CoGetObjectContext(IID_IObjectContext, (void**)&pObjectContext), "GetObjectContext" );
00092
00093     // Check security for large transfers
00094     if (lAmount > 500 || lAmount < -500) {
00095
00096       BOOL bInRole;
00097       BSTR bstrRole = ::SysAllocString (L"Managers");
00098       hr = pObjectContext->IsCallerInRole (bstrRole, &bInRole);
00099       ::SysFreeString(bstrRole);
00100
00101       if (!SUCCEEDED ( hr )) {
00102
00103         THROW_STR ( _T("IsCallerInRole() call failed!  Please add the 'Managers' Roll to the package."));
00104       }
00105
00106       if (!bInRole) {
00107         THROW_STR ( _T("Need 'Managers' role for amounts over $500") );
00108       }
00109     }
00110
00111     // Create the account object using our context
00112     THROW_ERR ( CoCreateInstance(CLSID_CAccount, NULL, CLSCTX_ALL, IID_IAccount, (void**)&pObjAccount),
00113       "CreateInstance(CLSID_CAccount)" );
00114
00115     // Call the post function based on the transaction type
00116     switch ( lTranType )
00117     {
00118     case (1): // debit
00119       RETHROW_ERR ( pObjAccount->Post (lPrimeAccount, 0 - lAmount, &bstrResult2) );
00120       break;
00121
00122     case (2): // credit
00123       RETHROW_ERR ( pObjAccount->Post (lPrimeAccount, lAmount, &bstrResult2) );
00124       break;
00125
00126     case (3): // transfer
00127       // Do the credit
00128       RETHROW_ERR ( pObjAccount->Post (lSecondAccount, lAmount, &bstrCall1) );
00129
00130       // Then do the debit
00131       RETHROW_ERR ( pObjAccount->Post (lPrimeAccount, 0 - lAmount, &bstrCall2) );
00132
00133       // Prepare return string
00134       TCHAR szBuf [512];
00135       _tcsncpy (szBuf, W2T( bstrCall1 ), 512);
00136       _tcsncat (szBuf, _T("; "), 2);
00137       _tcsncat (szBuf, W2T( bstrCall2 ), wcslen(bstrCall2));
00138       bstrResult2 = TCHAR2BSTR (szBuf);
00139       break;
00140
00141     default:
00142       THROW_STR ( _T("Invalid Transaction Type") );
00143     }
00144
00145     // Get Receipt Number for the transaction
00146     THROW_ERR ( CoCreateInstance (CLSID_CGetReceipt, NULL, CLSCTX_ALL, IID_IGetReceipt, (void**)&pObjGetReceipt),
00147       "CreateInstance(CLSID_CGetReceipt)" );
00148     long lngReceiptNo;
00149     RETHROW_ERR ( pObjGetReceipt->GetNextReceipt(&lngReceiptNo) );
00150
00151     // Tag receipt information onto return string
00152
00153     TCHAR szBuffer [512];
00154     wsprintf (szBuffer, _T("; Receipt No:  %li"), lngReceiptNo);
00155     BSTR bstrTemp = TCHAR2BSTR (szBuffer);
00156
00157     TCHAR szBuffer2 [512];
00158     _tcsncpy (szBuffer2, W2T ( bstrResult2 ), 512);
00159     _tcsncat (szBuffer2, W2T ( bstrTemp ), wcslen(bstrTemp));
00160     ::SysFreeString (bstrTemp);
00161
00162     *pbstrResult = TCHAR2BSTR (szBuffer2);
00163
00164     // We are finished and happy
00165     pObjectContext->SetComplete();
00166     hr = S_OK;
00167
00168   } catch (HRESULT hr) {
00169
00170     //
00171     //  store error info locally
00172     //
00173
00174     IErrorInfo * pErrorInfo = NULL;
00175     GetErrorInfo(NULL, &pErrorInfo);
00176
00177     // Fill in error information
00178     switch (lErrFlag) {
00179
00180     // Unknown error occurred in this object
00181     case (0):
00182       TCHAR szErr [512];
00183       wsprintf (szErr, _T("Error 0x%x from CMoveMoney calling %s."), hr, pErrMsg);
00184       pErrMsg = szErr;
00185       // Fall through
00186
00187     // An application error occurred in this object
00188     case (1):
00189       //
00190       //  we are going to put our own error in TLS, so if there is one there, clear it
00191       //
00192       if (pErrorInfo)
00193         pErrorInfo -> Release();
00194
00195       AtlReportError( CLSID_CMoveMoney, pErrMsg, IID_IMoveMoney, hr);
00196       break;
00197
00198     case (2):// An error occurred in a called object
00199       //
00200       //  put the error back in TLS
00201       //
00202       SetErrorInfo(NULL, pErrorInfo);
00203       break;
00204
00205     // Will never reach here
00206     default:
00207       break;
00208     }
00209
00210
00211     // Indicate our unhappiness
00212     if (pObjectContext)
00213       pObjectContext->SetAbort();
00214   }
00215
00216
00217   // Release resources
00218   if (pObjAccount)
00219     pObjAccount->Release();
00220
00221   if (pObjectContext)
00222     pObjectContext->Release();
00223
00224   if (pObjGetReceipt)
00225     pObjGetReceipt->Release();
00226
00227   if (bstrResult2)
00228     ::SysFreeString (bstrResult2);
00229
00230   if (bstrCall1)
00231     ::SysFreeString (bstrCall1);
00232
00233   if (bstrCall2)
00234     ::SysFreeString (bstrCall2);
00235
00236   return hr;
00237 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEnumIDList Member List

This is the complete list of members for CEnumIDList, including all inherited members.
AddToEnumList(LPITEMIDLIST) | CEnumIDList | [private]
CEnumIDList(LPCTSTR, DWORD) | CEnumIDList |
Clone(LPENUMIDLIST *) | CEnumIDList |
CreateEnumList(VOID) | CEnumIDList | [private]
DeleteList(VOID) | CEnumIDList | [private]
m_dwFlags | CEnumIDList | [private]
m_ObjRefCount | CEnumIDList | [private]
m_pCurrent | CEnumIDList | [private]
m_pFirst | CEnumIDList | [private]
m_pLast | CEnumIDList | [private]
m_pMalloc | CEnumIDList | [private]
m_pPidlMgr | CEnumIDList | [private]
m_szPath | CEnumIDList | [private]
Next(DWORD, LPITEMIDLIST *, LPDWORD) | CEnumIDList |
QueryInterface(REFIID, LPVOID *) | CEnumIDList |
Reset(VOID) | CEnumIDList |
Skip(DWORD) | CEnumIDList |
STDMETHOD_(DWORD, AddRef)() | CEnumIDList |
STDMETHOD_(DWORD, Release)() | CEnumIDList |
~CEnumIDList() | CEnumIDList |
Generated on Wed Nov 13 2024 16:56:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/virtualfile.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

virtualfile.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Defines a virtual file class derived from CBaseNode.  This
00014 //             class will represent our result items
00015 //
00016
00017
00018 #ifndef _CLASS_VIRTUALFILE_
00019 #define _CLASS_VIRTUALFILE_
00020
00021 #include "Globals.h"
00022 #include "BaseNode.h"
00023
00024
00025 class CFolderNode;           // References
00026 class CComponentData;
00027 class CComponent;
00028
00029 //---------------------------------------------------------------------------
00030 class CVirtualFile : public CBaseNode
00031 {
00032   public:
00033     CVirtualFile();
00034     virtual ~CVirtualFile();
00035
00036     HRESULT Initialize( LPNODEPROPS pNodeProps );
00037
00038   ///////////////////////////////////////////////////////////////////////////
00039   // Virtual methods
00040   public:
00041     ULONG   GetNodeType() { return NODETYPE_VFILE; }
00042     GUID&   GetNodeGUID() { return m_thisGUID; }
00043
00044     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo )
00045             { return E_NOTIMPL; }
00046
00047     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI )
00048             { return E_NOTIMPL; }
00049
00050     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00051
00052   ///////////////////////////////////////////////////////////////////////////
00053   //  Notification handlers
00054   public:
00055     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00056     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00057     HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00058
00059     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData )
00060             { return E_NOTIMPL; }
00061
00062     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData )
00063             { return E_NOTIMPL; }
00064
00065     HRESULT OnViewChange( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00066             { return E_NOTIMPL; }
00067
00068   ///////////////////////////////////////////////////////////////////////////
00069   //  Context Menu methods
00070   public:
00071     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00072     HRESULT Command( long lCommandID );
00073
00074   /////////////////////////////////////////////////////////////////////////
00075   //  IExtendControlbar methods
00076   //
00077   public:
00078     HRESULT ControlbarNotify( LPARAM nArg, LPARAM lParam, LONG_PTR pComp );
00079
00080   ///////////////////////////////////////////////////////////////////////////
00081   //  Helpers
00082   public:
00083     DWORD      GetAttributes() { return m_dwAttributes; }
00084     BOOL       IsAttributeSet( DWORD dwAttribute );
00085     VOID       SetAttribute( DWORD dwAttribute );
00086     VOID       RemoveAttribute( DWORD dwAttribute );
00087     LPWSTR     GetAttributeString();
00088     LONG_PTR   GetParent() { return (LONG_PTR)m_pParentFolder; }
00089
00090
00091   private:
00092     static GUID      m_thisGUID;
00093     DWORD            m_dwAttributes;
00094     WCHAR            m_pAttributeStr[16];
00095     CFolderNode*     m_pParentFolder;
00096     CComponentData*  m_pCompData;
00097     CComponent*      m_pComponent;
00098 };
00099
00100 #endif //_CLASS_VIRTUALFILE_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

THREADDATA Member List

This is the complete list of members for THREADDATA, including all inherited members.
bChatty | THREADDATA
bCreatePerIteration | THREADDATA
bRandom | THREADDATA
eCoInit | THREADDATA
eLang | THREADDATA
nAmount | THREADDATA
nFrom | THREADDATA
nIters | THREADDATA
nTestType | THREADDATA
nThreads | THREADDATA
nTo | THREADDATA
nTranType | THREADDATA
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/CrmFilesWorker.Cpp Source File

  • Com
  • Services
  • Crm
  • CrmFiles

CrmFilesWorker.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmFilesWorker.cpp
00004
00005
00006
00007 Summary:
00008
00009   This is a sample Compensating Resource Manager (CRM) that creates and deletes files.
00010
00011   The CRM Worker provides an interface for creating or deleting files.
00012
00013   The CRM Compensator implements ICrmCompensator to receive transaction outcome notifications.
00014
00015   The CRM Compensator also implements ICrmFormatLogRecords to support monitoring.
00016
00017   This CRM can be installed in a server application or in a library application.
00018
00019   The CRM Worker requires a transaction. The CRM Compensator should not have a transaction.
00020
00021 Classes:
00022
00023
00024   CCrmFilesWorker
00025
00026
00027 ----------------------------------------------------------------------------
00028
00029 This file is part of the Microsoft COM+ Samples.
00030
00031
00032
00033 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00034
00035
00036
00037 This source code is intended only as a supplement to Microsoft
00038
00039 Development Tools and/or on-line documentation. See these other
00040
00041 materials for detailed information regarding Microsoft code samples.
00042
00043
00044
00045 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00046
00047 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00048
00049 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00050
00051 PARTICULAR PURPOSE.
00052
00053 ==========================================================================+*/
00054
00055
00056 #include "stdafx.h"
00057 #include "CrmFiles.h"
00058 #include "CrmFilesWorker.h"
00059
00060 #include <time.h>
00061
00062 #pragma warning(disable: 4189)  // local variable is initialized but not referenced
00063
00064
00065 /////////////////////////////////////////////////////////////////////////////
00066 // CCrmFilesWorker
00067
00068 // IObjectControl Methods
00069
00070 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00071
00072 Method: CCrmFilesWorker::Activate()
00073
00074 Summary: IObjectControl Method. Allows an object to perform context-specific
00075      initialization whenever it's activated. This method is called by
00076      COM+ before any other methods are called on the object.
00077
00078 Returns: HRESULT
00079
00080 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00081
00082
00083 HRESULT STDMETHODCALLTYPE CCrmFilesWorker::Activate(void)
00084 {
00085   ATLTRACE(_T("CCrmFilesWorker::Activate = %08lX, %d\r\n"), this, m_id);
00086
00087   m_pICrmLogControl = NULL;
00088
00089   return S_OK;
00090
00091 } // CCrmFilesWorker::Activate
00092
00093
00094 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00095
00096 Method: CCrmFilesWorker::Deactivate()
00097
00098 Summary: IObjectControl Method. Allows an object to perform whatever cleanup
00099      is necessary before it's recycled or destroyed. This method is
00100      called by COM+ whenever an object is deactivated.
00101
00102 Returns: void
00103
00104 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00105
00106
00107 void STDMETHODCALLTYPE CCrmFilesWorker::Deactivate(void)
00108 {
00109   ATLTRACE(_T("CCrmFilesWorker::Deactivate = %08lX, %d\r\n"), this, m_id);
00110
00111     if (m_pICrmLogControl)
00112     {
00113         m_pICrmLogControl->Release();
00114     }
00115
00116     m_pICrmLogControl = NULL;
00117
00118 } // CCrmFilesWorker::Deactivate
00119
00120 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00121
00122 Method: CCrmFilesWorker::CanBePooled()
00123
00124 Summary: IObjectControl Method. Allows an object to notify COM+ of whether it
00125      can be pooled for reuse.
00126
00127 Returns: BOOL
00128
00129 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00130
00131
00132 BOOL STDMETHODCALLTYPE CCrmFilesWorker::CanBePooled(void)
00133 {
00134   ATLTRACE(_T("CCrmFilesWorker::CanBePooled = %08lX, %d\r\n"), this, m_id);
00135
00136   return TRUE;
00137
00138 } // CCrmFilesWorker::CanBePooled
00139
00140
00141
00142 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00143
00144 Method: CCrmFilesWorker::InternalAddRef()
00145
00146 Summary: Internal AddRef, uncomment if you want to see InternalAddRef Trace
00147      messages.
00148
00149 Returns: ULONG
00150
00151
00152 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00153
00154 /***** /
00155 ULONG CCrmFilesWorker::InternalAddRef()
00156 {
00157   DWORD dwBefore = m_dwRef;
00158
00159   DWORD dwAfter = CComObjectRootEx<CComMultiThreadModel>::InternalAddRef();
00160
00161   ATLTRACE(_T("CCrmFilesWorker::InternalAddRef, b = %d, a = %d\r\n"), dwBefore, dwAfter);
00162
00163   return (ULONG)dwAfter;
00164
00165 } // CCrmFilesWorker::InternalAddRef
00166
00167
00168 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00169
00170 Method: CCrmFilesWorker::InternalRelease()
00171
00172 Summary: Internal Release, uncomment if you want to see InternalRelease Trace
00173      messages.
00174
00175 Returns: ULONG
00176
00177 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00178
00179 /***** /
00180 ULONG CCrmFilesWorker::InternalRelease()
00181 {
00182   DWORD dwBefore = m_dwRef;
00183
00184   DWORD dwAfter = CComObjectRootEx<CComMultiThreadModel>::InternalRelease();
00185
00186   ATLTRACE(_T("CCrmFilesWorker::InternalRelease, b = %d, a = %d\r\n"), dwBefore, dwAfter);
00187
00188   return (ULONG)dwAfter;
00189
00190 } // CCrmFilesWorker::InternalRelease
00191 / *****/
00192
00193
00194 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00195
00196 Method: CCrmFilesWorker::CCrmFilesWorker()
00197
00198 Summary: Constructor
00199
00200 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00201
00202 CCrmFilesWorker::CCrmFilesWorker() :
00203  m_pICrmLogControl(NULL)
00204 {
00205   srand((unsigned)time(NULL));
00206
00207   m_id = rand();
00208
00209   ATLTRACE(_T("CCrmFilesWorker constructor = %08lX, %d\r\n"), this, m_id);
00210
00211 } // CCrmFilesWorker constructor
00212
00213
00214 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00215
00216 Method: CCrmFilesWorker::~CCrmFilesWorker()
00217
00218 Summary: Destructor
00219
00220 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00221
00222
00223 CCrmFilesWorker::~CCrmFilesWorker()
00224 {
00225   ATLTRACE(_T("CCrmFilesWorker destructor = %08lX, %d\r\n"), this, m_id);
00226
00227     if (m_pICrmLogControl)
00228     {
00229         m_pICrmLogControl->Release();
00230     }
00231
00232     m_pICrmLogControl = NULL;
00233
00234 } // CCrmFilesWorker destructor
00235
00236
00237 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00238
00239 Method: CCrmFilesWorker::GetCrmLogControl()
00240
00241 Summary: This creates the CRM Clerk and calls RegisterCompensator on it.
00242
00243 Returns: HRESULT
00244
00245 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00246
00247
00248 HRESULT CCrmFilesWorker::GetCrmLogControl(void)
00249 {
00250     HRESULT hr = S_OK;
00251
00252     _ASSERTE(NULL == m_pICrmLogControl);
00253
00254   hr = CoCreateInstance(
00255         __uuidof(CRMClerk),
00256         NULL,
00257         CLSCTX_INPROC_SERVER,
00258         __uuidof(ICrmLogControl),
00259         (void **)&m_pICrmLogControl);
00260
00261   _ASSERTE(S_OK == hr);
00262   _ASSERTE(m_pICrmLogControl);
00263
00264   // try to register our CRM Compensator (try 5X if recovery is in progress)
00265
00266     for (int i = 0; i < 5; i++)
00267     {
00268         hr = m_pICrmLogControl->RegisterCompensator(
00269                                     L"CrmFilesCompensator.CrmFilesCompensator.1",
00270                                     L"description goes here",
00271                   CRMREGFLAG_ALLPHASES);
00272
00273         if (XACT_E_RECOVERYINPROGRESS == hr)
00274         {
00275             Sleep(1000);
00276
00277             continue;       // try again
00278         }
00279
00280         break;
00281     }
00282
00283     _ASSERTE(hr == S_OK);
00284
00285     return hr;
00286
00287 } // CCrmFilesWorker::GetCrmLogControl
00288
00289
00290
00291 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00292
00293 Method: CCrmFilesWorker::CreateFile(BSTR bstrFileName)
00294
00295 Summary: Record that we are creating a file to the log, then create the file.
00296
00297 Returns: HRESULT
00298
00299 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00300
00301
00302 STDMETHODIMP CCrmFilesWorker::CreateFile(BSTR bstrFileName)
00303 {
00304     HRESULT hr = S_OK;
00305
00306   if (NULL == m_pICrmLogControl)
00307     {
00308         hr = GetCrmLogControl();
00309
00310         _ASSERTE(S_OK == hr);
00311
00312         if (hr != S_OK)
00313         {
00314             return hr;
00315         }
00316     }
00317
00318     _ASSERTE(m_pICrmLogControl);
00319
00320     // does the file already exist?
00321
00322     // We must do this because if the file already exists we will fail to create it. The transaction
00323     // will then abort, and as part of the abort we delete the file that we think we created -
00324     // so in this case we might end up deleting a file that we did not create.
00325
00326   HANDLE hFile = ::CreateFileW(
00327                         bstrFileName,             // pointer to name of the file
00328                 GENERIC_WRITE,              // access (read-write) mode
00329                 0L,                         // share mode
00330                 NULL,                     // pointer to security descriptor
00331                 OPEN_EXISTING,              // how to create
00332                 FILE_ATTRIBUTE_NORMAL,      // file attributes
00333                 NULL);                      // handle to file with attributes to copy
00334
00335   if (INVALID_HANDLE_VALUE != hFile)
00336   {
00337         // file already exists
00338
00339         CloseHandle(hFile);
00340
00341       hr = m_pICrmLogControl->ForceTransactionToAbort();
00342
00343         return hr;
00344   }
00345
00346     // WRITE AHEAD - log that we are about to create the file
00347
00348     CrmFilesCreateFileLogRecord cfr;
00349
00350     cfr.CommandType = ct_CreateFile;
00351
00352   _ASSERTE(bstrFileName != NULL);
00353
00354   cfr.dwSourceSize = (DWORD) wcslen(bstrFileName);
00355
00356     BLOB blobs[2];
00357
00358     blobs[0].pBlobData = (BYTE *)&cfr;
00359
00360     blobs[0].cbSize = sizeof(cfr);
00361
00362     // avoid copying the file name
00363
00364     blobs[1].pBlobData = (BYTE *)bstrFileName;
00365
00366     // wcslen returns # of chars in string, we need # of bytes
00367   _ASSERTE(bstrFileName != NULL);
00368
00369     UINT uNumChars = (UINT) wcslen(bstrFileName);
00370
00371     blobs[1].cbSize = uNumChars * sizeof(WCHAR);
00372
00373     // write the "create file" log record
00374
00375     hr = m_pICrmLogControl->WriteLogRecord(
00376                                 blobs,
00377                                 2);
00378     _ASSERTE(S_OK == hr);
00379
00380     // force the log to ensure this log record is durable in the log
00381
00382     hr = m_pICrmLogControl->ForceLog();
00383
00384     _ASSERTE(S_OK == hr);
00385
00386     // TRY TO CREATE THE FILE
00387
00388   hFile = ::CreateFileW(
00389                     bstrFileName,       // pointer to name of the file
00390             GENERIC_WRITE,              // access (read-write) mode
00391             0L,                         // share mode
00392             NULL,                     // pointer to security descriptor
00393             CREATE_NEW,                 // how to create
00394             FILE_ATTRIBUTE_NORMAL,      // file attributes
00395             NULL);                      // handle to file with attributes to copy
00396
00397   if (INVALID_HANDLE_VALUE == hFile)
00398   {
00399         DWORD dwErr = GetLastError();
00400
00401       hr = m_pICrmLogControl->ForceTransactionToAbort();
00402
00403         return hr;
00404   }
00405
00406   CloseHandle(hFile);
00407
00408   return S_OK;
00409
00410 } // CCrmFilesWorker::CreateFile
00411
00412
00413 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00414
00415 Method: CCrmFilesWorker::DeleteFile(BSTR bstrFileName)
00416
00417 Summary: Record that we are deleting a file to the log, then rename the file.
00418      The compensator will actually delete the file if the Transaction
00419      commits.
00420
00421 Returns: HRESULT
00422
00423 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00424
00425
00426 STDMETHODIMP CCrmFilesWorker::DeleteFile(BSTR bstrFileName)
00427 {
00428     HRESULT hr = S_OK;
00429
00430   if (NULL == m_pICrmLogControl)
00431     {
00432         hr = GetCrmLogControl();
00433
00434         _ASSERTE(S_OK == hr);
00435
00436     }
00437
00438     _ASSERTE(m_pICrmLogControl);
00439
00440     // does the file exist?
00441
00442     // We must do this because MoveFileEx has the unfortunate effect that it will create the
00443     // destination file even if the source file does not exist. If we allowed this to occur,
00444     // then during compensation we might put back a file that never originally existed.
00445
00446   HANDLE hFile = ::CreateFileW(
00447                         bstrFileName,       // pointer to name of the file
00448                 GENERIC_WRITE,              // access (read-write) mode
00449                 0L,                         // share mode
00450                 NULL,                     // pointer to security descriptor
00451                 OPEN_EXISTING,              // how to create
00452                 FILE_ATTRIBUTE_NORMAL,      // file attributes
00453                 NULL);                      // handle to file with attributes to copy
00454
00455   if (INVALID_HANDLE_VALUE == hFile)
00456   {
00457         DWORD dwErr = GetLastError();
00458
00459       hr = m_pICrmLogControl->ForceTransactionToAbort();
00460
00461         return hr;
00462   }
00463
00464   CloseHandle(hFile);
00465
00466     // file exists - there is a window here in which it might be deleted by someone else
00467
00468     WCHAR wszTempFile[MAX_PATH];
00469
00470     ZeroMemory(wszTempFile, MAX_PATH * sizeof(WCHAR));
00471
00472     // the file name itself will be unique, so use it
00473
00474     lstrcatW(wszTempFile, bstrFileName);
00475
00476     lstrcatW(wszTempFile, L".crmtemp");
00477
00478     // WRITE AHEAD - log that we are about to delete (rename) the file
00479
00480     CrmFilesDeleteFileLogRecord dfr;
00481
00482     dfr.CommandType = ct_DeleteFile;
00483
00484   _ASSERTE(bstrFileName != NULL);
00485     dfr.dwSourceSize = (DWORD) wcslen(bstrFileName);
00486
00487   _ASSERTE(wszTempFile != NULL);
00488     dfr.dwTempSize = (DWORD) wcslen(wszTempFile);
00489
00490     BLOB blobs[3];
00491
00492     blobs[0].pBlobData = (BYTE *)&dfr;
00493
00494     blobs[0].cbSize = sizeof(dfr);
00495
00496     // avoid copying the source file name
00497
00498     blobs[1].pBlobData = (BYTE *)bstrFileName;
00499
00500     // wcslen returns # of chars in string, we need # of bytes
00501
00502   _ASSERTE(bstrFileName != NULL);
00503     UINT uNumChars = (UINT) wcslen(bstrFileName);
00504
00505     blobs[1].cbSize = uNumChars * sizeof(WCHAR);
00506
00507     // avoid copying the temp file name
00508
00509     blobs[2].pBlobData = (BYTE *)wszTempFile;
00510
00511   _ASSERTE(wszTempFile != NULL);
00512     uNumChars = (UINT) wcslen(wszTempFile);
00513
00514     blobs[2].cbSize = uNumChars * sizeof(WCHAR);
00515
00516     // write the "delete file" log record
00517
00518     hr = m_pICrmLogControl->WriteLogRecord(
00519                                 blobs,
00520                                 3);
00521     _ASSERTE(S_OK == hr);
00522
00523     // force the log to ensure this log record is durable in the log
00524
00525     hr = m_pICrmLogControl->ForceLog();
00526
00527     _ASSERTE(S_OK == hr);
00528
00529     // TRY TO RENAME THE FILE TO A CRM###.TMP FILE
00530
00531     DWORD dwFlags = MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH;
00532
00533     BOOL fRc = MoveFileExW(
00534                     bstrFileName,
00535           wszTempFile,
00536                     dwFlags);
00537
00538     if (!fRc)
00539     {
00540         DWORD dwErr = GetLastError();
00541
00542       hr = m_pICrmLogControl->ForceTransactionToAbort();
00543
00544         return hr;
00545     }
00546
00547   return hr;
00548
00549 } // CCrmFilesWorker::DeleteFile
00550
00551
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RECVFROMARGS Member List

This is the complete list of members for _RECVFROMARGS, including all inherited members.
dwBufferCount | _RECVFROMARGS
dwFlags | _RECVFROMARGS
dwNumberOfBytesRecvd | _RECVFROMARGS
lpBuffers | _RECVFROMARGS
lpFrom | _RECVFROMARGS
lpFromLen | _RECVFROMARGS
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/MTXSample/MoveMoney.cpp Source File

  • Web
  • iis
  • Components
  • Cpp
  • MTXSample

MoveMoney.cpp

Go to the documentation of this file.
00001 // MoveMoney.cpp : Implementation of CMoveMoney
00002
00003 #include "stdafx.h"
00004 #include "BankVC.h"
00005 #include "MoveMoney.h"
00006
00007 STDMETHODIMP CMoveMoney::InterfaceSupportsErrorInfo(REFIID riid)
00008 {
00009   static const IID* arr[] = { &IID_IMoveMoney };
00010
00011   for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
00012     if (InlineIsEqualGUID(*arr[i], riid))
00013       return S_OK;
00014
00015   return S_FALSE;
00016 }
00017
00018 STDMETHODIMP CMoveMoney::Perform(long lngAcnt1, long lngAcnt2, long lngAmount, long lngType, BSTR *pVal)
00019 {
00020   // Get the ObjectContext object
00021
00022   TCHAR strErr[256];
00023   CComPtr<IObjectContext> pObjectContext = NULL;
00024   CComPtr<IAccount> pAccount;
00025   CComBSTR bstrResult, bstrRes1;
00026
00027   HRESULT hr = GetObjectContext(&pObjectContext);
00028
00029   if (FAILED(hr))
00030   {
00031     wsprintf(strErr, "GetObjectContext() failed!");
00032
00033     goto ErrorHandler;
00034   }
00035
00036   hr = pObjectContext->CreateInstance(CLSID_Account, IID_IAccount, (LPVOID*) &pAccount);
00037
00038   if (FAILED(hr))
00039   {
00040     wsprintf(strErr, "Create Account Object failed!");
00041
00042     goto ErrorHandler;
00043   }
00044
00045   strErr[0]='\0';
00046
00047   switch(lngType){
00048
00049     case 1 :
00050
00051       hr = pAccount->Post(lngAcnt1, 0-lngAmount, &bstrResult);
00052
00053       if (FAILED(hr))
00054         goto ErrorHandler;
00055
00056       *pVal = bstrResult.Copy();
00057
00058       break;
00059
00060     case 2 :
00061
00062       hr = pAccount->Post(lngAcnt1, lngAmount, &bstrResult);
00063
00064       if (FAILED(hr))
00065         goto ErrorHandler;
00066
00067       *pVal = bstrResult.Copy();
00068
00069       break;
00070
00071     case 3 :
00072
00073       hr = pAccount->Post(lngAcnt2, lngAmount, &bstrResult);
00074
00075       if (FAILED(hr))
00076         goto ErrorHandler;
00077
00078       hr = pAccount->Post(lngAcnt1, 0 - lngAmount, &bstrRes1);
00079
00080       if (FAILED(hr))
00081         goto ErrorHandler;
00082
00083       bstrResult.Append(bstrRes1);
00084
00085       *pVal = bstrResult.Copy();
00086
00087       break;
00088
00089     default :
00090
00091       wsprintf(strErr, "Invalid transaction type!");
00092
00093       goto ErrorHandler;
00094   }
00095
00096   pObjectContext->SetComplete();
00097
00098   return S_OK;
00099
00100 ErrorHandler:
00101
00102   Error(strErr, IID_IMoveMoney);
00103
00104   if (pObjectContext)
00105     pObjectContext->SetAbort();
00106
00107   return hr;
00108 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Errors.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Errors.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Errors
00019 /** @com.interface(iid=00000501-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Errors extends msado15._Collection
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=PROPGET, name="Count", name2="getCount", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int getCount();
00025
00026   /** @com.method(vtoffset=5, dispid=4294967292, type=METHOD, name="_NewEnum", addFlagsVtable=4)
00027       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00028   public IUnknown _NewEnum();
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=METHOD, name="Refresh", addFlagsVtable=4)
00031       @com.parameters() */
00032   public void Refresh();
00033
00034   /** @com.method(vtoffset=7, dispid=0, type=PROPGET, name="Item", name2="getItem", addFlagsVtable=4)
00035       @com.parameters([in,type=VARIANT] Index, [iid=00000500-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00036   public msado15.Error getItem(Variant Index);
00037
00038   /** @com.method(vtoffset=8, dispid=1610809345, type=METHOD, name="Clear", addFlagsVtable=4)
00039       @com.parameters() */
00040   public void Clear();
00041
00042
00043   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x501, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00044 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/DirEncrypt/DirEncrypt.Cpp Source File

  • NetDS
  • MessageQueuing
  • DirEncrypt

DirEncrypt.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // file:  drctencp.cpp
00013 //
00014 //
00015
00016
00017
00018
00019 #include <windows.h>
00020 #include <wincrypt.h>
00021 #include <STDIO.H>
00022 #include <mq.h>
00023
00024
00025 //
00026 // Globals.
00027 //
00028
00029 BOOL   fEnhEncrypted = FALSE ;
00030 QMPROPID propidPK = PROPID_QM_ENCRYPTION_PK;
00031 WCHAR  wszMachineName[ 128 ] = {0} ;
00032
00033
00034
00035
00036 void Usage(char * pszProgramName)
00037 {
00038     fprintf(stderr, "...Usage:  %s\n", pszProgramName);
00039     fprintf(stderr, "\t-2 send encrypted, RC2\n") ;
00040     fprintf(stderr, "\t-4 send encrypted, RC4\n") ;
00041     fprintf(stderr, "\t-b <Message Body>\n") ;
00042     fprintf(stderr, "\t-e Enhanced Encryption\n") ;
00043     fprintf(stderr, "\t-l <Message Label>\n") ;
00044     fprintf(stderr, "\t-m <Name of destination machine>\n") ;
00045     fprintf(stderr, "\t-q <Queue name>\n") ;
00046     exit(1);
00047 }
00048
00049 BOOL getPublicKeyBlob( PBYTE* pbPbKeyxKey, DWORD* pdwPbKeyxKeyLen)
00050 /*++
00051
00052 Routine Description:
00053
00054     This routine retrieves the public key of the remote computer.
00055     The key is retrieved using the MQGetMachineProperties() API, which connects to the
00056     directory service (DS) to retrieve the specified properties.
00057     Usually when using workgroup (direct) mode, no DS connection is available.
00058     This routine comes only as a substitute to other means of obtaining the
00059     remote computer public key. (SSL protocol, via disk or file, etc.) .
00060
00061 Arguments:
00062
00063     pbPbKeyxKey     - (OUT) pointer to the key.
00064     pdwPbKeyxKeyLen - (OUT) pointer to the key length
00065
00066 Return Value:
00067
00068     TRUE  - if the key was retreived .
00069     FALSE - if the key couldn't be reteived.
00070
00071 --*/
00072 {
00073     if (fEnhEncrypted)
00074     {
00075         propidPK = PROPID_QM_ENCRYPTION_PK_ENHANCED ;
00076     }
00077
00078     QMPROPID aQmPropId[1] ;
00079     aQmPropId[0] = propidPK ;
00080     #define QMPROPS (sizeof(aQmPropId) / sizeof(*aQmPropId))
00081
00082     MQPROPVARIANT aQmPropVar[QMPROPS];
00083     HRESULT       aQmStatus[QMPROPS];
00084
00085     MQQMPROPS QmProps = {QMPROPS, aQmPropId, aQmPropVar, aQmStatus};
00086
00087     aQmPropVar[0].vt = VT_NULL;
00088
00089     HRESULT hr = MQGetMachineProperties(wszMachineName, NULL, &QmProps);
00090     if (FAILED(hr))
00091     {
00092         printf(
00093            "The public key of %S could not be retrieved. Error code: %lxh\n",
00094                                                   wszMachineName, hr);
00095
00096         return FALSE;
00097     }
00098
00099     if (aQmPropVar[0].vt != (VT_UI1|VT_VECTOR))
00100     {
00101         printf(
00102         "A type indicator in the structure passed to MQGetMachineProperties() is incorrect. Type idicator: %lxh, QMPROPS: %lut, Error code: %lxh\n",
00103                                                  aQmPropVar[0].vt, QMPROPS, hr) ;
00104         return FALSE ;
00105     }
00106
00107     *pbPbKeyxKey = aQmPropVar[0].caub.pElems;
00108     *pdwPbKeyxKeyLen = aQmPropVar[0].caub.cElems;
00109
00110     return TRUE;
00111 }
00112
00113
00114 int main(int argc, char *argv[])
00115 {
00116
00117     DWORD  dwEncryptAlg = CALG_RC2 ;
00118     WCHAR  wszQueueName[ 128 ] = {0} ;
00119     WCHAR  wszMsgLabel[ 128 ] = {TEXT("MessageLabel")} ;
00120     WCHAR  wszMsgBody[ 128 ] = {TEXT("MessageBody")} ;
00121     LPSTR  lpszArg = NULL ;
00122     DWORD  dwMsgSize = sizeof(WCHAR) * (1 + wcslen(wszMsgBody)) ;
00123     DWORD  dwBufferSize = sizeof(wszMsgBody) ;
00124     LPWSTR pMsgBody = wszMsgBody ;
00125   BOOL bQueueName = FALSE, bMachineName = FALSE;
00126
00127   if (argc < 2)
00128   {
00129     Usage(argv[0]);
00130   }
00131     //
00132     // Allow the user to override settings with command line switches.
00133     //
00134     for ( int i = 1; i < argc; i++)
00135     {
00136         if ((*argv[i] == '-') || (*argv[i] == '/'))
00137         {
00138       if(strlen(argv[i]) <2)
00139       {
00140         Usage(argv[0]);
00141       }
00142             switch (*(argv[i]+1))
00143             {
00144             case '2':
00145                 dwEncryptAlg = CALG_RC2 ;
00146                 break ;
00147
00148             case '4':
00149                 dwEncryptAlg = CALG_RC4 ;
00150                 break ;
00151
00152             case 'e':
00153                 fEnhEncrypted = TRUE ;
00154                 break ;
00155
00156             case 'b':
00157         if(i+1 == argc)
00158         {
00159           Usage(argv[0]);
00160         }
00161
00162                 lpszArg = argv[++i];
00163                 mbstowcs(wszMsgBody, lpszArg, 127) ;
00164                 break;
00165
00166             case 'l':
00167         if(i+1 == argc)
00168         {
00169           Usage(argv[0]);
00170         }
00171                 lpszArg = argv[++i];
00172                 mbstowcs(wszMsgLabel, lpszArg, 127) ;
00173                 break;
00174
00175             case 'm':
00176         if(i+1 == argc)
00177         {
00178           Usage(argv[0]);
00179         }
00180         lpszArg = argv[++i];
00181                 mbstowcs(wszMachineName, lpszArg, 127) ;
00182                 bMachineName = TRUE;
00183         break;
00184
00185             case 'q':
00186         if(i+1 == argc)
00187         {
00188           Usage(argv[0]);
00189         }
00190         lpszArg = argv[++i];
00191                 mbstowcs(wszQueueName, lpszArg, 127) ;
00192         bQueueName = TRUE;
00193                 break;
00194
00195             case 'h':
00196             case '?':
00197             default:
00198                 Usage(argv[0]);
00199             }
00200         }
00201         else
00202         {
00203             Usage(argv[0]);
00204         }
00205     }
00206
00207   if(!bMachineName || !bQueueName)
00208   {
00209     Usage(argv[0]);
00210   }
00211
00212     dwMsgSize = sizeof(WCHAR) * (1 + wcslen(wszMsgBody)) ;
00213
00214     //
00215     // Get the public key blob of the destination computer.
00216     //
00217
00218     PBYTE pbPbKeyxKey = NULL;
00219     DWORD dwPbKeyxKeyLen = 0;
00220
00221     if (getPublicKeyBlob( &pbPbKeyxKey, &dwPbKeyxKeyLen))
00222     {
00223         printf("The public key of %S was retrieved successfully. Length: %lut\n",
00224                                      wszMachineName, dwPbKeyxKeyLen) ;
00225
00226     }
00227     else
00228     {
00229         return -1 ;
00230     }
00231
00232     //
00233     // Get a handle to the default cryptographic service provider (CSP).
00234     //
00235     LPWSTR lpwszProviderName = MS_DEF_PROV ;
00236     if (fEnhEncrypted)
00237     {
00238         lpwszProviderName = MS_ENHANCED_PROV ;
00239     }
00240     HCRYPTPROV hProv = NULL;
00241
00242     BOOL bRet = CryptAcquireContext( &hProv,
00243                                        NULL,
00244                                        lpwszProviderName,
00245                                        PROV_RSA_FULL,
00246                                        0 ) ;
00247     if (!bRet)
00248     {
00249         if (GetLastError() == NTE_BAD_KEYSET)
00250         {
00251             //
00252             // The default key container does not exist yet, so create it.
00253             //
00254             if (!CryptAcquireContext( &hProv,
00255                                         NULL,
00256                                         lpwszProviderName,
00257                                         PROV_RSA_FULL,
00258                                         CRYPT_NEWKEYSET ))
00259             {
00260                 printf(
00261                 "CryptAcquireContext(%S, CRYPT_NEWKEYSET) failed. Error code: %lxh\n",
00262                                      lpwszProviderName, GetLastError());
00263                 return -1;
00264             }
00265             printf("CryptAcquireContext(%S, CRYPT_NEWKEYSET) succeeded.\n",
00266                                                        lpwszProviderName) ;
00267         }
00268         else
00269         {
00270             printf(
00271               "CryptAcquireContext(%S) failed. Error code: %lxh\n",
00272                                      lpwszProviderName, GetLastError());
00273             return -1;
00274         }
00275     }
00276     else
00277     {
00278         printf("CryptAcquireContext(%S) succeeded.\n", lpwszProviderName) ;
00279     }
00280
00281     //
00282     // Import the public key blob of the destination computer into the CSP.
00283     //
00284     HCRYPTKEY hPbKey = NULL;
00285
00286     if (!CryptImportKey( hProv,
00287                          pbPbKeyxKey,
00288                          dwPbKeyxKeyLen,
00289                          NULL,
00290                          0,
00291                         &hPbKey ))
00292     {
00293         printf("CryptImportKey() failed. Error code: %lxh\n", GetLastError());
00294         return -1;
00295     }
00296     printf("CryptImportKey() succeeded.\n") ;
00297
00298     //
00299     // Free the public key blob of the destination computer.
00300     //
00301     MQFreeMemory(pbPbKeyxKey);
00302
00303     //
00304     // Create a symmetric key.
00305     //
00306     HCRYPTKEY hSymmKey = NULL;
00307
00308     if (!CryptGenKey(hProv, dwEncryptAlg, CRYPT_EXPORTABLE, &hSymmKey))
00309     {
00310         printf("CryptGenKey() failed. Error code: %lxh\n", GetLastError());
00311         return -1;
00312     }
00313     printf("CryptGenKey(alg- %lut) successfully created a symmetric key.\n",
00314                                                            dwEncryptAlg) ;
00315     //
00316     // Get the encrypted symmetric key blob. This blob should
00317     // be passed to MQSendMessage in PROPID_M_DEST_SYMM_KEY.
00318     //
00319     BYTE  abSymmKey[ 512 ];
00320     DWORD dwSymmKeyLen = sizeof(abSymmKey);
00321
00322     if (!CryptExportKey( hSymmKey,
00323                          hPbKey,
00324                          SIMPLEBLOB,
00325                          0,
00326                          abSymmKey,
00327                          &dwSymmKeyLen ))
00328     {
00329         printf("CryptExportKey() failed. Error code: %lxh\n", GetLastError());
00330         return -1;
00331     }
00332     printf("CryptExportKey() succeeded.\n") ;
00333
00334     //
00335     // Get a handle to the destination queue.
00336     //
00337     WCHAR wszQueueFormat[128] = {0};
00338
00339   if (_snwprintf(wszQueueFormat, (sizeof(wszQueueFormat)/sizeof(wszQueueFormat[0])) - 1, TEXT("DIRECT=OS:%s\\%s"),
00340                                         wszMachineName, wszQueueName) <0)
00341   {
00342     printf("The format name is too long for the buffer specified. Exiting...\n");
00343     exit(1);
00344   }
00345   else
00346   {
00347     wszQueueFormat[(sizeof(wszQueueFormat)/sizeof(wszQueueFormat[0]))-1] = '\0';
00348   }
00349
00350
00351
00352
00353     QUEUEHANDLE hQueue = NULL;
00354
00355     HRESULT hr = MQOpenQueue(wszQueueFormat, MQ_SEND_ACCESS, 0, &hQueue);
00356     if (FAILED(hr))
00357     {
00358         printf("MQOpenQueue(%S) failed. Error code: %lxh\n", wszQueueFormat, hr) ;
00359         return -1;
00360     }
00361     printf("MQOpenQueue(%S) succeeded.\n", wszQueueFormat) ;
00362
00363     //
00364     // Prepare the message properties.
00365     //
00366   GUID guid ;
00367
00368     MSGPROPID aMsgPropId[] = {PROPID_M_BODY,
00369                               PROPID_M_DEST_SYMM_KEY,
00370                               PROPID_M_ENCRYPTION_ALG,
00371                               PROPID_M_CONNECTOR_TYPE,
00372                               PROPID_M_LABEL,
00373                               PROPID_M_PRIV_LEVEL};
00374     #define MSGPROPS (sizeof(aMsgPropId) / sizeof(*aMsgPropId))
00375
00376     MQPROPVARIANT aMsgPropVar[MSGPROPS];
00377     HRESULT       aMsgStatus[MSGPROPS];
00378
00379     MQMSGPROPS MsgProps = {MSGPROPS, aMsgPropId, aMsgPropVar, aMsgStatus};
00380
00381     aMsgPropVar[0].vt = VT_VECTOR | VT_UI1;
00382     aMsgPropVar[0].caub.pElems = (BYTE*) pMsgBody ;
00383
00384     aMsgPropVar[1].vt = VT_VECTOR | VT_UI1;
00385     aMsgPropVar[1].caub.cElems = dwSymmKeyLen;
00386     aMsgPropVar[1].caub.pElems = abSymmKey;
00387
00388     aMsgPropVar[2].vt = VT_UI4;
00389     aMsgPropVar[2].ulVal = dwEncryptAlg ;
00390
00391     aMsgPropVar[3].vt = VT_CLSID;
00392   aMsgPropVar[3].puuid = &guid;
00393
00394     aMsgPropVar[4].vt = VT_LPWSTR;
00395     aMsgPropVar[4].pwszVal = wszMsgLabel;
00396
00397     //
00398     // The connector type (PROPID_M_CONNECTOR_TYPE) is not initialized
00399     // because it is assumed that nobody will bother about it on the
00400     // receiving side; otherwise, it should be initialized.
00401     //
00402
00403     //
00404     // Encrypt the line.
00405     //
00406
00407     if (!CryptEncrypt( hSymmKey,
00408                        NULL,
00409                        TRUE,
00410                        0,
00411                        (BYTE*) pMsgBody,
00412                       &dwMsgSize,
00413                        dwBufferSize ))
00414     {
00415         printf("CryptEncrypt() failed. Error code: %lxh\n", GetLastError());
00416         return -1;
00417     }
00418     printf("CryptEncrypt() succeeded.\n") ;
00419
00420     //
00421     // Update the length of the message according to the result of the
00422     // encryption algorithm. RC4 may enlarge the message size. At the
00423     // destination, the message will be received as clear text with the
00424     // correct (original) message body size.
00425     //
00426     aMsgPropVar[0].caub.cElems = dwMsgSize ;
00427
00428     aMsgPropVar[5].vt = VT_UI4;
00429     if(!fEnhEncrypted)
00430     {
00431         aMsgPropVar[5].ulVal= MQMSG_PRIV_LEVEL_NONE ;
00432     }
00433     else
00434     {
00435         aMsgPropVar[5].ulVal = MQMSG_PRIV_LEVEL_BODY_ENHANCED ;
00436     }
00437     MsgProps.cProp = MSGPROPS ;
00438
00439
00440     //
00441     // Send the mesasge.
00442     //
00443     hr = MQSendMessage(hQueue, &MsgProps, NULL);
00444     if (FAILED(hr))
00445     {
00446         printf("MQSendMessage() failed. Error code: %lxh\n", hr) ;
00447     return -1;
00448     }
00449     printf("MQSendMessage() succeeded.\n") ;
00450
00451     //
00452     // Free resources. This is actually not required here. The code is included
00453     // to show how it is done, if neccessary.
00454     //
00455     MQCloseQueue(hQueue);
00456     CryptDestroyKey(hSymmKey);
00457     CryptDestroyKey(hPbKey);
00458     CryptReleaseContext(hProv, 0);
00459
00460     return 0;
00461 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/ProcList/ProcList.c Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • ProcList

ProcList.c

Go to the documentation of this file.
00001 /*
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009     proclist.c
00010
00011     sample program to list current processes using the PDH.DLL
00012     browsing functions
00013
00014 */
00015 #ifdef UNICODE
00016 #ifndef _UNICODE
00017 #define _UNICODE            1
00018 #endif
00019 #define tmain   wmain
00020 #else
00021 #define tmain   main
00022 #endif
00023
00024 // this program only needs the "bare essential" windows header files
00025 #define WIN32_LEAN_AND_MEAN 1
00026 #include <windows.h>
00027 #include <winperf.h>
00028 #include <malloc.h>
00029 #include <stdio.h>
00030 #include <tchar.h>
00031 #include <pdh.h>
00032 #include <pdhmsg.h>
00033
00034 int
00035 tmain ()
00036 {
00037    PDH_STATUS  pdhStatus               = ERROR_SUCCESS;
00038    LPTSTR      szCounterListBuffer     = NULL;
00039    DWORD       dwCounterListSize       = 0;
00040    LPTSTR      szInstanceListBuffer    = NULL;
00041    DWORD       dwInstanceListSize      = 0;
00042    LPTSTR      szThisInstance          = NULL;
00043
00044
00045    // call the function to determine the required buffer size for the data
00046    pdhStatus = PdhEnumObjectItems(
00047                                   NULL,                   // reserved
00048                                   NULL,                   // local machine
00049                                   TEXT("Process"),        // object to enumerate
00050                                   szCounterListBuffer,    // pass in NULL buffers
00051                                   &dwCounterListSize,     // an 0 length to get
00052                                   szInstanceListBuffer,   // required size
00053                                   &dwInstanceListSize,    // of the buffers in chars
00054                                   PERF_DETAIL_WIZARD,     // counter detail level
00055                                   0);
00056    if (pdhStatus == ERROR_SUCCESS || pdhStatus == PDH_MORE_DATA)
00057    {
00058       // allocate the buffers and try the call again
00059       // PdhEnum functions will return ERROR_SUCCESS in WIN2K, but PDH_MORE_DATA in XP and later.
00060       // In either case, dwCounterListSize and dwInstanceListSize should contain correct buffer size needed.
00061       //
00062       szCounterListBuffer = (LPTSTR)malloc (
00063                                            (dwCounterListSize * sizeof (TCHAR)));
00064       szInstanceListBuffer = (LPTSTR)malloc (
00065                                             (dwInstanceListSize * sizeof (TCHAR)));
00066       if ((szCounterListBuffer != NULL) &&
00067           (szInstanceListBuffer != NULL))
00068       {
00069          pdhStatus = PdhEnumObjectItems (
00070                                         NULL,   // reserved
00071                                         NULL,   // local machine
00072                                         TEXT("Process"), // object to enumerate
00073                                         szCounterListBuffer,    // pass in NULL buffers
00074                                         &dwCounterListSize,     // an 0 length to get
00075                                         szInstanceListBuffer,   // required size
00076                                         &dwInstanceListSize,    // of the buffers in chars
00077                                         PERF_DETAIL_WIZARD,     // counter detail level
00078                                         0);
00079          if (pdhStatus == ERROR_SUCCESS)
00080          {
00081             _tprintf (TEXT("\nRunning Processes:"));
00082             // walk the return instance list
00083             for (szThisInstance = szInstanceListBuffer;
00084                 *szThisInstance != 0;
00085                 szThisInstance += lstrlen(szThisInstance) + 1)
00086             {
00087                _tprintf (TEXT("\n  %s"), szThisInstance);
00088             }
00089          }
00090       }
00091       else
00092       {
00093          _tprintf (TEXT("\nPROCLIST: unable to allocate buffers"));
00094       }
00095       if (szCounterListBuffer != NULL) free (szCounterListBuffer);
00096       if (szInstanceListBuffer != NULL) free (szInstanceListBuffer);
00097    }
00098    else
00099    {
00100       _tprintf (TEXT("\nPROCLIST: unable to determine the necessary buffer size required"));
00101    }
00102    return 0;
00103 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/pluggable/pluggable.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • pluggable

pluggable.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999-2001 Microsoft Corporation
00004
00005 Module Name:
00006
00007     pluggable.cpp
00008
00009 Abstract:
00010
00011     Registration and DLL entry points.
00012
00013 --*/
00014
00015 #include "stdafx.h"
00016 #include <termmgr.h>
00017
00018 #include "PlgTerm.h"
00019
00020 //GUID for our terminal
00021 #include <initguid.h>
00022 #include "GUIDs.h"
00023
00024
00025 #ifdef _MERGE_PROXYSTUB
00026 extern "C" HINSTANCE hProxyDll;
00027 #endif
00028
00029 #ifdef DEBUG_HEAPS
00030 // for heap debugging
00031 #include <crtdbg.h>
00032 #endif // DEBUG_HEAPS
00033
00034 CComModule _Module;
00035
00036 // Must have an entry here for each cocreatable object.
00037
00038 BEGIN_OBJECT_MAP(ObjectMap)
00039     OBJECT_ENTRY(CLSID_PlgTermSample, CPlgTermSample)
00040 END_OBJECT_MAP()
00041
00042 /*++
00043 PTRegisterPluggable
00044
00045 Description:
00046     Register the terminal class
00047 --*/
00048
00049 HRESULT PTRegisterPluggable( BSTR bstrSuperclassCLSID)
00050 {
00051     LOG((MSP_TRACE, "PTRegisterPluggable enter"));
00052
00053     HRESULT hr=E_FAIL;
00054     CComPtr<ITPluggableTerminalClassRegistration> pITPTClassReg=NULL;
00055     hr=CoCreateInstance(CLSID_PluggableTerminalRegistration,
00056               NULL,
00057               CLSCTX_INPROC_SERVER,
00058               IID_ITPluggableTerminalClassRegistration,
00059               reinterpret_cast<void**>(&pITPTClassReg));
00060     if(FAILED(hr))
00061     {
00062         LOG((MSP_ERROR, "CoCreateInstance - ITPluggableTerminalClassRegistration 0x%08x", hr));
00063         return hr;
00064     }
00065
00066     //
00067     // Get the TerminalClass id
00068     //
00069
00070     LPOLESTR pszTerminalCLSID = NULL;
00071     hr = StringFromCLSID(CLSID_PlgTermSampleClass, &pszTerminalCLSID);
00072     if (FAILED(hr))
00073     {
00074         LOG((MSP_ERROR, "StringFromCLSID 0x%08x", hr));
00075         return hr;
00076     }
00077
00078     hr=pITPTClassReg->put_TerminalClass(pszTerminalCLSID);
00079     CoTaskMemFree(pszTerminalCLSID);
00080     if(FAILED(hr))
00081     {
00082         LOG((MSP_ERROR, "ITPluggableTerminalClassRegistration::put_TerminalClass 0x%08x", hr));
00083         return hr;
00084     }
00085
00086     //
00087     // Get terminal's com class id
00088     //
00089
00090     LPOLESTR pszCOMClassID = NULL;
00091     hr = StringFromCLSID(CLSID_PlgTermSample, &pszCOMClassID);
00092     if (FAILED(hr))
00093     {
00094         LOG((MSP_ERROR, "StringFromCLSID 0x%08x", hr));
00095         return hr;
00096     }
00097
00098     hr=pITPTClassReg->put_CLSID(pszCOMClassID);
00099     CoTaskMemFree(pszCOMClassID);
00100     if(FAILED(hr))
00101     {
00102         LOG((MSP_ERROR, "ITPluggableTerminalClassRegistration::put_CLSID 0x%08x", hr));
00103         return hr;
00104     }
00105
00106
00107     //
00108     // Set other terminal attributes - don't care if FAILs or bstrTemp == NULL
00109     //
00110
00111     //
00112     //name
00113     //
00114     BSTR bstrTemp = SysAllocString(SZTERMNAME);
00115     pITPTClassReg->put_Name(bstrTemp);
00116     ::SysFreeString(bstrTemp);
00117
00118     //
00119     //company
00120     //
00121     bstrTemp = SysAllocString( _T("Sample SDK") );
00122     pITPTClassReg->put_Company(bstrTemp);
00123     ::SysFreeString(bstrTemp);
00124
00125     //
00126     //version
00127     //
00128     bstrTemp = SysAllocString( _T("1.2") );
00129     pITPTClassReg->put_Version(bstrTemp);
00130     ::SysFreeString(bstrTemp);
00131
00132     //
00133     //direction
00134     //
00135     TMGR_DIRECTION   td = TMGR_TD_RENDER;
00136     pITPTClassReg->put_Direction(td);
00137
00138     //
00139     //media type
00140     //
00141     long lMediaType=TAPIMEDIATYPE_AUDIO;
00142     pITPTClassReg->put_MediaTypes(lMediaType);
00143
00144     //
00145     // Register terminal
00146     //
00147     hr = pITPTClassReg->Add( bstrSuperclassCLSID );
00148     if(FAILED(hr))
00149     {
00150         LOG((MSP_ERROR, "ITPluggableTerminalClassRegistration::Add 0x%08x", hr));
00151     }
00152     LOG((MSP_TRACE, "PTRegisterPluggable exit - 0x%08x", hr));
00153     return hr;
00154 }
00155
00156
00157 /*++
00158 PTRegister
00159
00160 Description:
00161     Register the terminal superclass
00162   then call the terminal class registration
00163 --*/
00164 HRESULT PTRegister()
00165 {
00166
00167     LOG((MSP_TRACE, "PTRegister enter"));
00168
00169     HRESULT hr=E_FAIL;
00170
00171     //
00172     // need to register superclass terminals
00173     //
00174     CComPtr<ITPluggableTerminalSuperclassRegistration> pITPTSuperReg=NULL;
00175     hr=CoCreateInstance(CLSID_PluggableSuperclassRegistration,
00176               NULL,
00177               CLSCTX_INPROC_SERVER,
00178               IID_ITPluggableTerminalSuperclassRegistration,
00179               reinterpret_cast<void**>(&pITPTSuperReg));
00180     if(FAILED(hr))
00181     {
00182         LOG((MSP_ERROR, "CoCreateInstance - ITPluggableTerminalSuperclassRegistration 0x%08x", hr));
00183         return hr;
00184     }
00185
00186     //
00187     //we need to put_CLSID - first operation - need for GetTerminalSuperclassInfo
00188     //
00189     LPOLESTR bstrSuperCLSID = NULL;
00190     hr = StringFromCLSID(CLSID_PlgSuperSampleClass, &bstrSuperCLSID);
00191
00192     if(FAILED(hr))
00193     {
00194         LOG((MSP_ERROR, "StringFromCLSID 0x%08x", hr));
00195         return hr;
00196     }
00197
00198     hr=pITPTSuperReg->put_CLSID(bstrSuperCLSID);
00199
00200     //
00201     //clean up
00202     //
00203     CoTaskMemFree(bstrSuperCLSID);
00204     bstrSuperCLSID=NULL;
00205
00206     if(FAILED(hr))
00207     {
00208         LOG((MSP_ERROR, "ITPluggableTerminalSuperclassRegistration::put_CLSID 0x%08x", hr));
00209         return hr;
00210     }
00211     if(FAILED(pITPTSuperReg->GetTerminalSuperclassInfo()))
00212     {
00213   //
00214   //it's ok just add one
00215   //
00216   BSTR bstrName = SysAllocString( _T("PluggableTerminalsSamples") );
00217         if(bstrName==NULL)
00218         {
00219             LOG((MSP_ERROR, "SysAllocString failed"));
00220             return E_OUTOFMEMORY;
00221         }
00222         //
00223         //try to put name
00224         //
00225         pITPTSuperReg->put_Name(bstrName);
00226         //
00227         //clean up
00228         //
00229         ::SysFreeString(bstrName);
00230         bstrName=NULL;
00231
00232         hr=pITPTSuperReg->Add();
00233         if(FAILED(hr))
00234         {
00235             LOG((MSP_ERROR, "ITPluggableTerminalSuperclassRegistration::Add 0x%08x", hr));
00236             return hr;
00237         }
00238     }
00239
00240     hr = StringFromCLSID(CLSID_PlgSuperSampleClass, &bstrSuperCLSID);
00241
00242     if(FAILED(hr))
00243     {
00244         LOG((MSP_ERROR, "StringFromCLSID 0x%08x", hr));
00245         return hr;
00246     }
00247
00248     //
00249     //register the class
00250     //
00251     hr=PTRegisterPluggable(bstrSuperCLSID);
00252
00253     //
00254     //clean up
00255     //
00256     CoTaskMemFree(bstrSuperCLSID);
00257     bstrSuperCLSID=NULL;
00258
00259     if(FAILED(hr))
00260     {
00261         LOG((MSP_ERROR, "PTRegisterPluggable 0x%08x", hr));
00262     }
00263
00264     LOG((MSP_TRACE, "PTRegisterPluggable exit - 0x%08x", hr));
00265     return hr;
00266 }
00267
00268 /*++
00269 PTUnregister
00270
00271 Description:
00272     UnRegister the terminal class, terminal superclass
00273 --*/
00274 HRESULT PTUnregister()
00275 {
00276     LOG((MSP_TRACE, "PTUnregister enter"));
00277
00278     HRESULT hr=E_FAIL;
00279     CComPtr<ITPluggableTerminalClassRegistration> pITPTClassReg=NULL;
00280     hr=CoCreateInstance(CLSID_PluggableTerminalRegistration,
00281               NULL,
00282               CLSCTX_INPROC_SERVER,
00283               IID_ITPluggableTerminalClassRegistration,
00284               reinterpret_cast<void**>(&pITPTClassReg));
00285     if(FAILED(hr))
00286     {
00287         LOG((MSP_ERROR, "CoCreateInstance - ITPluggableTerminalClassRegistration 0x%08x", hr));
00288         return hr;
00289     }
00290
00291     //
00292     // Get the TerminalClass id
00293     //
00294
00295     LPOLESTR pszTerminalCLSID = NULL;
00296     hr = StringFromCLSID(CLSID_PlgTermSampleClass, &pszTerminalCLSID);
00297     if (FAILED(hr))
00298     {
00299         LOG((MSP_ERROR, "StringFromCLSID 0x%08x", hr));
00300         return hr;
00301     }
00302
00303     hr=pITPTClassReg->put_TerminalClass(pszTerminalCLSID);
00304     CoTaskMemFree(pszTerminalCLSID);
00305     if(FAILED(hr))
00306     {
00307         LOG((MSP_ERROR, "ITPluggableTerminalClassRegistration::put_TerminalClass 0x%08x", hr));
00308         return hr;
00309     }
00310
00311     //
00312     //CLSID for superclass
00313     //
00314
00315     LPOLESTR bstrSuperCLSID = NULL;
00316     hr = StringFromCLSID(CLSID_PlgSuperSampleClass, &bstrSuperCLSID);
00317
00318     if(FAILED(hr))
00319     {
00320         LOG((MSP_ERROR, "StringFromCLSID 0x%08x", hr));
00321         return hr;
00322     }
00323
00324     hr=pITPTClassReg->Delete(bstrSuperCLSID);
00325
00326     //
00327     //clean up
00328     //
00329     CoTaskMemFree(bstrSuperCLSID);
00330     bstrSuperCLSID=NULL;
00331
00332     LOG((MSP_TRACE, "PTUnregister exit - 0x%08x", hr));
00333     return hr;
00334
00335 }
00336
00337
00338 /////////////////////////////////////////////////////////////////////////////
00339 // DLL Entry Point
00340
00341 extern "C"
00342 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00343 {
00344     lpReserved;
00345
00346 #ifdef _MERGE_PROXYSTUB
00347     if (!PrxDllMain(hInstance, dwReason, lpReserved))
00348     {
00349         return FALSE;
00350     }
00351 #endif
00352
00353     if (dwReason == DLL_PROCESS_ATTACH)
00354     {
00355
00356 #ifdef DEBUG_HEAPS
00357         // turn on leak detection on process exit
00358         _CrtSetDbgFlag( _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF );
00359 #endif // DEBUG_HEAPS
00360
00361         _Module.Init(ObjectMap, hInstance);
00362         DisableThreadLibraryCalls(hInstance);
00363         MSPLOGREGISTER(_T("sampleterm"));
00364
00365     }
00366     else if (dwReason == DLL_PROCESS_DETACH)
00367     {
00368         MSPLOGDEREGISTER();
00369         _Module.Term();
00370     }
00371     return TRUE;    // ok
00372 }
00373
00374 /////////////////////////////////////////////////////////////////////////////
00375 // Used to determine whether the DLL can be unloaded by OLE
00376
00377 STDAPI DllCanUnloadNow(void)
00378 {
00379 #ifdef _MERGE_PROXYSTUB
00380     if ( PrxDllCanUnloadNow() != S_OK )
00381     {
00382         return S_FALSE;
00383     }
00384 #endif
00385
00386     if ( _Module.GetLockCount() == 0 )
00387     {
00388         //
00389         // All references to COM objects in this DLL have been released, so
00390         // the DLL can now be safely unloaded. After this returns, DllMain
00391         // will be called with dwReason == DLL_PROCESS_DETACH.
00392         //
00393         return S_OK;
00394     }
00395     else
00396     {
00397         return S_FALSE;
00398     }
00399 }
00400
00401 /////////////////////////////////////////////////////////////////////////////
00402 // Returns a class factory to create an object of the requested type
00403
00404 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00405 {
00406 #ifdef _MERGE_PROXYSTUB
00407     if ( PrxDllGetClassObject(rclsid, riid, ppv) == S_OK )
00408     {
00409         return S_OK;
00410     }
00411 #endif
00412     return _Module.GetClassObject(rclsid, riid, ppv);
00413 }
00414
00415 /////////////////////////////////////////////////////////////////////////////
00416 // DllRegisterServer - Adds entries to the system registry
00417
00418 STDAPI DllRegisterServer(void)
00419 {
00420     //
00421     // Register terminals
00422     //
00423     PTRegister();
00424
00425 #ifdef _MERGE_PROXYSTUB
00426     HRESULT hRes = PrxDllRegisterServer();
00427
00428     if ( FAILED(hRes) )
00429     {
00430         return hRes;
00431     }
00432 #endif
00433
00434     // registers object, typelib and all interfaces in typelib
00435     return _Module.RegisterServer(TRUE);
00436 }
00437
00438 /////////////////////////////////////////////////////////////////////////////
00439 // DllUnregisterServer - Removes entries from the system registry
00440
00441 STDAPI DllUnregisterServer(void)
00442 {
00443     //
00444     // Unregister terminals
00445     //
00446     PTUnregister();
00447
00448 #ifdef _MERGE_PROXYSTUB
00449     PrxDllUnregisterServer();
00450 #endif
00451
00452     _Module.UnregisterServer();
00453
00454     return S_OK;
00455 }
00456
00457
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COpenQueueDialog Member List

This is the complete list of members for COpenQueueDialog, including all inherited members.
COpenQueueDialog(CArray< ARRAYQ *, ARRAYQ * > *, CWnd *pParent=NULL) | COpenQueueDialog |
DoDataExchange(CDataExchange *pDX) | COpenQueueDialog | [protected, virtual]
GetAccess() | COpenQueueDialog | [inline]
GetFormatName(TCHAR szFormatName[BUFFERSIZE]) | COpenQueueDialog |
GetPathName(TCHAR szPathName[BUFFERSIZE]) | COpenQueueDialog | [inline]
IDD enum value | COpenQueueDialog |
m_FormatNameCB | COpenQueueDialog |
m_iAccessRight | COpenQueueDialog |
m_PathNameCB | COpenQueueDialog |
m_pStrArray | COpenQueueDialog |
m_szFormatName | COpenQueueDialog |
m_szPathName | COpenQueueDialog |
OnEditupdateFormatnameCombo2() | COpenQueueDialog | [protected]
OnEditupdatePathnameCombo() | COpenQueueDialog | [protected]
OnInitDialog() | COpenQueueDialog | [protected, virtual]
OnSelchangeFormatnameCombo2() | COpenQueueDialog | [protected]
OnSelchangePathnameCombo() | COpenQueueDialog | [protected]
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPropertyInfos Member List

This is the complete list of members for CPropertyInfos, including all inherited members.
AddElement(DBPROPINFOelement) | CVector< DBPROPINFO > | [virtual]
AddProperty(DBPROPID dwPropertyID, const DBID &colid) | TPropBase< DBPROPINFO > | [virtual]
Attach(DBPROPINFOSET *pPropSet) | CPropertyInfos | [virtual]
TPropBase< DBPROPINFO >::Attach(CVector &rVector) | CVector< DBPROPINFO > | [virtual]
TPropBase< DBPROPINFO >::Attach(ULONGcElements, DBPROPINFO *rgElements) | CVector< DBPROPINFO > | [virtual]
CPropertyInfos(DBPROPINFOSET *pPropInfoSet=NULL) | CPropertyInfos |
CVector(ULONGulLowerBound=0, ULONGulGrowSize=10) | CVector< DBPROPINFO > |
Detach(DBPROPINFOSET *pPropSet) | CPropertyInfos | [virtual]
TPropBase< DBPROPINFO >::Detach(ULONG *pcElements, DBPROPINFO **prgElements) | CVector< DBPROPINFO > | [virtual]
FindProperty(DBPROPID dwPropertyID, const DBID &colid) | CPropertyInfos | [virtual]
GetCount() | CVector< DBPROPINFO > | [inline, virtual]
GetElement(ULONGiIndex) | CVector< DBPROPINFO > | [virtual]
GetElements() const | CVector< DBPROPINFO > | [inline, virtual]
GetProperties() | TPropBase< DBPROPINFO > | [inline, virtual]
InsertAt(ULONGiIndex, DBPROPINFOelement) | CVector< DBPROPINFO > | [virtual]
m_cElements | CVector< DBPROPINFO > | [protected]
m_rgElements | CVector< DBPROPINFO > | [protected]
m_ulGrowSize | CVector< DBPROPINFO > | [protected]
m_ulLowerBound | CVector< DBPROPINFO > | [protected]
m_ulMaxSize | CVector< DBPROPINFO > | [protected]
operator[](ULONGiIndex) | CVector< DBPROPINFO > | [inline, virtual]
RemoveAll() | CPropertyInfos | [virtual]
RemoveAt(ULONGiIndex) | CVector< DBPROPINFO > | [virtual]
TPropBase(ULONG cElements=0, DBPROPINFO *rgElements=NULL) | TPropBase< DBPROPINFO > |
~CPropertyInfos() | CPropertyInfos | [virtual]
~CVector() | CVector< DBPROPINFO > | [virtual]
~TPropBase() | TPropBase< DBPROPINFO > | [virtual]
Generated on Wed Nov 13 2024 16:57:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsError/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsError

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__417D01D6_F1C6_11D2_BC88_00C04FD430AF__INCLUDED_)
00006 #define AFX_STDAFX_H__417D01D6_F1C6_11D2_BC88_00C04FD430AF__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0400
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023 #include <activeds.h>
00024 #include <lmerr.h>
00025
00026 //{{AFX_INSERT_LOCATION}}
00027 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00028
00029 #endif // !defined(AFX_STDAFX_H__417D01D6_F1C6_11D2_BC88_00C04FD430AF__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/DiskQuota/ProcessMenu.h Source File

  • WinBase
  • IO
  • DiskQuota

ProcessMenu.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 ProcessMenu.h
00011
00012 Description:
00013 Prototypes for functions used to process menu selections
00014 ----------------------------------------------------------------------------*/
00015
00016 #if !defined (_PROCESS_MENU_H_)
00017 #define _PROCESS_MENU_H_
00018
00019 BOOL ProcessMainMenu(WCHAR wcMenuChoice, IDiskQuotaControl* lpDiskQuotaControl);
00020 BOOL ProcessDefaultQuotaMenu(WCHAR wcMenuChoice, IDiskQuotaControl* lpDiskQuotaControl);
00021 BOOL ProcessQuotaLogFlagMenu(WCHAR wcMenuChoice, IDiskQuotaControl* lpDiskQuotaControl);
00022 BOOL ProcessDefaultLimitsMenu(WCHAR wcMenuChoice, IDiskQuotaControl* lpDiskQuotaControl);
00023 BOOL ProcessUserManagerMenu(WCHAR wcMenuChoice, IDiskQuotaControl* lpDiskQuotaControl);
00024 BOOL ProcessQuotaManagerMenu(WCHAR wcMenuChoice, IDiskQuotaControl* lpDiskQuotaControl);
00025
00026 #endif /* _PROCESS_MENU_H_ */
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/comp.Cpp Source File

  • SysMgmt
  • MMC
  • Extens

comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "DataObj.h"
00021 #include <commctrl.h>        // Needed for button styles...
00022 #include <crtdbg.h>
00023 #include "globals.h"
00024 #include "resource.h"
00025 #include "DeleBase.h"
00026 #include "CompData.h"
00027
00028 CComponent::CComponent(CComponentData *parent)
00029 : m_pComponentData(parent), m_cref(0), m_ipConsole(NULL)
00030 {
00031     OBJECT_CREATED
00032 }
00033
00034 CComponent::~CComponent()
00035 {
00036     OBJECT_DESTROYED
00037 }
00038
00039 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00040 {
00041     if (!ppv)
00042         return E_FAIL;
00043
00044     *ppv = NULL;
00045
00046     if (IsEqualIID(riid, IID_IUnknown))
00047         *ppv = static_cast<IComponent *>(this);
00048     else if (IsEqualIID(riid, IID_IComponent))
00049         *ppv = static_cast<IComponent *>(this);
00050     else if (IsEqualIID(riid, IID_IExtendPropertySheet))
00051         *ppv = static_cast<IExtendPropertySheet2 *>(this);
00052
00053     if (*ppv)
00054     {
00055         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00056         return S_OK;
00057     }
00058
00059     return E_NOINTERFACE;
00060 }
00061
00062 STDMETHODIMP_(ULONG) CComponent::AddRef()
00063 {
00064     return InterlockedIncrement((LONG *)&m_cref);
00065 }
00066
00067 STDMETHODIMP_(ULONG) CComponent::Release()
00068 {
00069     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00070     {
00071         delete this;
00072         return 0;
00073     }
00074     return m_cref;
00075
00076 }
00077
00078 ///////////////////////////////
00079 // Interface IComponent
00080 ///////////////////////////////
00081 STDMETHODIMP CComponent::Initialize(
00082                                     /* [in] */ LPCONSOLE lpConsole)
00083 {
00084     HRESULT hr = S_OK;
00085
00086     // Save away all the interfaces we'll need.
00087     // Fail if we can't QI the required interfaces.
00088
00089     m_ipConsole = lpConsole;
00090     m_ipConsole->AddRef();
00091
00092     return hr;
00093 }
00094
00095 STDMETHODIMP CComponent::Notify(
00096                                 /* [in] */ LPDATAOBJECT lpDataObject,
00097                                 /* [in] */ MMC_NOTIFY_TYPE event,
00098                                 /* [in] */ LPARAM arg,
00099                                 /* [in] */ LPARAM param)
00100 {
00101     MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00102
00103     HRESULT hr = S_FALSE;
00104
00105   //Get our data object. If it is NULL, we return with S_FALSE.
00106   //See implementation of GetOurDataObject() to see how to
00107   //handle special data objects.
00108   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00109   if (NULL == pDataObject)
00110     return S_FALSE;
00111
00112   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00113
00114     switch (event)      {
00115     case MMCN_SHOW:
00116         hr = base->OnShow(m_ipConsole, (BOOL)arg, (HSCOPEITEM)param);
00117         break;
00118
00119     case MMCN_ADD_IMAGES:
00120         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00121         break;
00122
00123     case MMCN_SELECT:
00124         hr = base->OnSelect(m_ipConsole, (BOOL)LOWORD(arg), (BOOL)HIWORD(arg));
00125         break;
00126
00127     case MMCN_RENAME:
00128         hr = base->OnRename((LPOLESTR)param);
00129         break;
00130     }
00131
00132     return hr;
00133 }
00134
00135 STDMETHODIMP CComponent::Destroy(
00136                                  /* [in] */ MMC_COOKIE cookie)
00137 {
00138     if (m_ipConsole) {
00139         m_ipConsole->Release();
00140         m_ipConsole = NULL;
00141     }
00142
00143     return S_OK;
00144 }
00145
00146
00147 STDMETHODIMP CComponent::QueryDataObject(
00148                                          /* [in] */ MMC_COOKIE cookie,
00149                                          /* [in] */ DATA_OBJECT_TYPES type,
00150                                          /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00151 {
00152     CDataObject *pObj = NULL;
00153
00154     if (cookie == 0)
00155         pObj = new CDataObject((MMC_COOKIE)m_pComponentData->m_pStaticNode, type);
00156     else
00157         pObj = new CDataObject(cookie, type);
00158
00159     if (!pObj)
00160         return E_OUTOFMEMORY;
00161
00162     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00163
00164     return S_OK;
00165 }
00166
00167 STDMETHODIMP CComponent::GetResultViewType(
00168                                            /* [in] */ MMC_COOKIE cookie,
00169                                            /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00170                                            /* [out] */ long __RPC_FAR *pViewOptions)
00171 {
00172     CDelegationBase *base = (CDelegationBase *)cookie;
00173
00174     //
00175     // Ask for default listview.
00176     //
00177     if (base == NULL)
00178     {
00179         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00180         *ppViewType = NULL;
00181     }
00182     else
00183         return base->GetResultViewType(ppViewType, pViewOptions);
00184
00185     return S_OK;
00186 }
00187
00188 STDMETHODIMP CComponent::GetDisplayInfo(
00189                                         /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00190 {
00191     HRESULT hr = S_OK;
00192     CDelegationBase *base = NULL;
00193
00194     // if they are asking for the RDI_STR we have one of those to give
00195
00196     if (pResultDataItem->lParam) {
00197         base = (CDelegationBase *)pResultDataItem->lParam;
00198         if (pResultDataItem->mask & RDI_STR) {
00199                         LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00200                         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00201             pResultDataItem->str = pszW;
00202         }
00203
00204         if (pResultDataItem->mask & RDI_IMAGE) {
00205             pResultDataItem->nImage = base->GetBitmapIndex();
00206         }
00207     }
00208
00209     return hr;
00210 }
00211
00212
00213 STDMETHODIMP CComponent::CompareObjects(
00214                                         /* [in] */ LPDATAOBJECT lpDataObjectA,
00215                                         /* [in] */ LPDATAOBJECT lpDataObjectB)
00216 {
00217     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00218     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00219
00220     // compare the object pointers
00221     if (baseA->GetCookie() == baseB->GetCookie())
00222         return S_OK;
00223
00224     return S_FALSE;
00225 }
00226
00227 ///////////////////////////////////
00228 // Interface IExtendPropertySheet2
00229 ///////////////////////////////////
00230
00231 //We need to implement IExtendPropertySheet2 methods and
00232 //return S_OK to allow extension snap-ins to extend result item
00233 //by adding their own property pages
00234 HRESULT CComponent::CreatePropertyPages(
00235                                         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00236                                         /* [in] */ LONG_PTR handle,
00237                                         /* [in] */ LPDATAOBJECT lpIDataObject)
00238 {
00239     return S_OK;
00240 }
00241
00242 HRESULT CComponent::QueryPagesFor(
00243                                   /* [in] */ LPDATAOBJECT lpDataObject)
00244 {
00245     return S_OK;
00246 }
00247
00248 HRESULT CComponent::GetWatermarks(
00249                                   /* [in] */ LPDATAOBJECT lpIDataObject,
00250                                   /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00251                                   /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00252                                   /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00253                                   /* [out] */ BOOL __RPC_FAR *bStretch)
00254 {
00255     return S_OK;
00256 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

NONDIALTOKENS Member List

This is the complete list of members for NONDIALTOKENS, including all inherited members.
dwDevCapFlag | NONDIALTOKENS
lError | NONDIALTOKENS
szMsg | NONDIALTOKENS
szToken | NONDIALTOKENS
Generated on Wed Nov 13 2024 16:57:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/FreServe/FreServe.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • FreServe

FreServe.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FRESERVE.CPP
00003
00004   Summary:   Implementation file for a DLL COM Component server providing
00005              a Ball-related COM Component: Ball. Access to Class Factories
00006              is provided in this module.  This server also supports self
00007              registration and unregistration. FRESERVE is a thread-safe
00008              server for the COBall COM objects.
00009
00010              For a comprehensive tutorial code tour of FRESERVE's contents
00011              and offerings see the tutorial FRESERVE.HTM file. For more
00012              specific technical details on the internal workings see the
00013              comments dispersed throughout the FRESERVE source code.
00014              FRESERVE is functioned by the free-threaded client, FRECLIEN.
00015              For more details see FRECLIEN.HTM in the main tutorial
00016              directory.
00017
00018   Classes:   none.
00019
00020   Functions: DllMain, DllGetClassObject, DllCanUnloadNow, DllRegisterServer,
00021              DllUnregisterServer.
00022
00023   Origin:    9-8-97: atrent - Editor-inheritance from DLLSERVE.CPP in
00024                the DLLSERVE Tutorial Code Sample. [Revised]
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 /*---------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will be calling the COM/OLE Libraries.
00044   We include INITGUID.H only once (here) in the entire DLL because we
00045     will be defining GUIDs and want them as constants in the data segment.
00046   We include APPUTIL.H because we will be building this DLL using
00047     the convenient Virtual Window and Dialog classes and other
00048     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00049   We include IBALL.H and BALLGUID.H for the common ball-related Interface
00050     class, GUID, and CLSID specifications.
00051   We include FRESERVE.H because it has the _DLLEXPORT_ controlled import
00052     and export specifications.
00053   We include SERVER.H because it has the necessary internal class and
00054     resource definitions for this DLL.
00055   We include FACTORY.H because it has the necessary internal class factory
00056     declarations for this DLL component server.
00057 ---------------------------------------------------------------------------*/
00058 #include <windows.h>
00059 #include <ole2.h>
00060 #include <initguid.h>
00061 #include <apputil.h>
00062 #include <iball.h>
00063 #include <ballguid.h>
00064 #define _DLLEXPORT_
00065 #include "freserve.h"
00066 #include "server.h"
00067 #include "factory.h"
00068
00069
00070 // Global variable definitions. Some Initialized in DllMain() below.
00071
00072 // We encapsulate the control of this COM server (eg, lock and object
00073 // counting) in a server control C++ object.  Here is it's pointer.
00074 CServer* g_pServer = NULL;
00075
00076
00077 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00078   Function: UnicodeOk
00079
00080   Summary:  Checks if the platform will handle unicode versions of
00081             Win32 string API calls.
00082
00083   Args:     void
00084
00085   Returns:  BOOL
00086               TRUE if unicode support; FALSE if not.
00087 ------------------------------------------------------------------------F-F*/
00088 BOOL UnicodeOk(void)
00089 {
00090   BOOL bOk = TRUE;
00091   TCHAR szUserName[MAX_STRING_LENGTH];
00092   DWORD dwSize = MAX_STRING_LENGTH;
00093
00094   if (!GetUserName(szUserName, &dwSize))
00095     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00096
00097   return bOk;
00098 }
00099
00100
00101 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00102   Function: DllMain
00103
00104   Summary:  Like WinMain is for an EXE application, this DllMain function
00105             is the main entry point for this DLL.  It is called when the
00106             DLL is loaded by a process, and when new threads are created
00107             by a process that has already loaded this DLL.  DllMain is
00108             also called when threads of a process that has loaded the DLL
00109             exit cleanly and when the process itself unloads the DLL.
00110
00111             If you want to use C runtime libraries, keep this function
00112             named "DllMain" and you won't have to do anything special to
00113             initialize the runtime libraries.
00114
00115             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
00116             to determine if the DLL should remain loaded, or should be
00117             immediately unloaded depending upon whether the DLL could be
00118             initialized properly.  For all other values of fdwReason, the
00119             return value is ignored.
00120
00121   Args:     HINSTANCE hDLLInst,
00122               Instance handle of the DLL.
00123             DWORD fdwReason,
00124               Process attach/detach or thread attach/detach.
00125               Reason for calling.
00126             LPVOID lpvReserved)
00127               Reserved and not used.
00128
00129   Returns:  BOOL,
00130               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
00131               TRUE  -  Used to signify that the DLL should remain loaded.
00132               FALSE -  Used to signify that the DLL should be
00133                 immediately unloaded.
00134 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00135 BOOL WINAPI DllMain(
00136               HINSTANCE hDllInst,
00137               DWORD fdwReason,
00138               LPVOID lpvReserved)
00139 {
00140   BOOL bResult = TRUE;
00141
00142   // Dispatch this main call based on the reason it was called.
00143   switch (fdwReason)
00144   {
00145     case DLL_PROCESS_ATTACH:
00146       // The DLL is being loaded for the first time by a given process.
00147       // Perform per-process initialization here.  If the initialization
00148       // is successful, return TRUE; if unsuccessful, return FALSE.
00149       bResult = FALSE;
00150       if (UnicodeOk())
00151       {
00152         // Instantiate the CServer utility class.
00153         g_pServer = new CServer;
00154         if (NULL != g_pServer)
00155         {
00156           // Remember the DLL Instance handle.
00157           g_pServer->m_hDllInst = hDllInst;
00158           bResult = TRUE;
00159         }
00160       }
00161       break;
00162
00163     case DLL_PROCESS_DETACH:
00164       // The DLL is being unloaded by a given process.  Do any
00165       // per-process clean up here, such as undoing what was done in
00166       // DLL_PROCESS_ATTACH.  The return value is ignored.
00167       DELETE_POINTER(g_pServer);
00168       break;
00169
00170     case DLL_THREAD_ATTACH:
00171       // A thread is being created in a process that has already loaded
00172       // this DLL.  Perform any per-thread initialization here.  The
00173       // return value is ignored.
00174       break;
00175
00176     case DLL_THREAD_DETACH:
00177       // A thread is exiting cleanly in a process that has already
00178       // loaded this DLL.  Perform any per-thread clean up here.  The
00179       // return value is ignored.
00180       break;
00181
00182     default:
00183       break;
00184   }
00185
00186   return (bResult);
00187 }
00188
00189
00190 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00191   Function: DllGetClassObject
00192
00193   Summary:  The standard exported function that the COM service library
00194             uses to obtain an object class of the class factory for a
00195             specified component provided by this server DLL.
00196
00197   Args:     REFCLSID rclsid,
00198               [in] The CLSID of the requested Component.
00199             REFIID riid,
00200               [in] GUID of the Interface being requested.
00201             PPVOID ppv)
00202               [out] Address of the caller's pointer variable that will
00203               receive the requested interface pointer.
00204
00205   Returns:  HRESULT
00206               E_FAIL if requested component isn't supported.
00207               E_OUTOFMEMORY if out of memory.
00208               Error code out of the QueryInterface.
00209 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00210 STDAPI DllGetClassObject(
00211          REFCLSID rclsid,
00212          REFIID riid,
00213          PPVOID ppv)
00214 {
00215   HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
00216   IUnknown* pCob = NULL;
00217
00218   if (CLSID_DllBall == rclsid)
00219   {
00220     hr = E_OUTOFMEMORY;
00221     pCob = new CFBall(NULL, g_pServer);
00222   }
00223
00224   if (NULL != pCob)
00225   {
00226     g_pServer->ObjectsUp();
00227     hr = pCob->QueryInterface(riid, ppv);
00228     if (FAILED(hr))
00229     {
00230       g_pServer->ObjectsDown();
00231       DELETE_POINTER(pCob);
00232     }
00233   }
00234
00235   return hr;
00236 }
00237
00238
00239 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00240   Function: DllCanUnloadNow
00241
00242   Summary:  The standard exported function that the COM service library
00243             uses to determine if this server DLL can be unloaded.
00244
00245   Args:     void.
00246
00247   Returns:  HRESULT
00248               S_OK if this DLL server can be unloaded.
00249               S_FALSE if this DLL can not be unloaded.
00250 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00251 STDAPI DllCanUnloadNow(void)
00252 {
00253   HRESULT hr;
00254
00255   // We return S_OK of there are no longer any living objects AND
00256   // there are no outstanding client locks on this server.
00257   hr = g_pServer->CanUnloadNow();
00258
00259   return hr;
00260 }
00261
00262
00263 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00264   Function: DllRegisterServer
00265
00266   Summary:  The standard exported function that can be called to command
00267             this DLL server to register itself in the system registry.
00268
00269   Args:     void.
00270
00271   Returns:  HRESULT
00272               NOERROR
00273 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00274 STDAPI DllRegisterServer(void)
00275 {
00276   HRESULT  hr = NOERROR;
00277   TCHAR    szID[GUID_SIZE+1];
00278   TCHAR    szCLSID[GUID_SIZE+32];
00279   TCHAR    szModulePath[MAX_PATH];
00280
00281   // Obtain the path to this module's executable file for later use.
00282   GetModuleFileName(
00283     g_pServer->m_hDllInst,
00284     szModulePath,
00285     sizeof(szModulePath)/sizeof(TCHAR));
00286
00287   /*-------------------------------------------------------------------------
00288     Create registry entries for the DllBall Component.
00289   -------------------------------------------------------------------------*/
00290   // Create some base key strings.
00291   StringFromGUID2(CLSID_DllBall, szID, GUID_SIZE);
00292   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00293   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00294
00295   // Create ProgID keys.
00296   SetRegKeyValue(
00297     TEXT("CTS.DllBall.1"),
00298     NULL,
00299     TEXT("DllBall Component - FRESERVE Code Sample"));
00300   SetRegKeyValue(
00301     TEXT("CTS.DllBall.1"),
00302     TEXT("CLSID"),
00303     szID);
00304
00305   // Create VersionIndependentProgID keys.
00306   SetRegKeyValue(
00307     TEXT("CTS.DllBall"),
00308     NULL,
00309     TEXT("DllBall Component - FRESERVE Code Sample"));
00310   SetRegKeyValue(
00311     TEXT("CTS.DllBall"),
00312     TEXT("CurVer"),
00313     TEXT("CTS.DllBall.1"));
00314   SetRegKeyValue(
00315     TEXT("CTS.DllBall"),
00316     TEXT("CLSID"),
00317     szID);
00318
00319   // Create entries under CLSID.
00320   SetRegKeyValue(
00321     szCLSID,
00322     NULL,
00323     TEXT("DllBall Component - FRESERVE Code Sample"));
00324   SetRegKeyValue(
00325     szCLSID,
00326     TEXT("ProgID"),
00327     TEXT("CTS.DllBall.1"));
00328   SetRegKeyValue(
00329     szCLSID,
00330     TEXT("VersionIndependentProgID"),
00331     TEXT("CTS.DllBall"));
00332   SetRegKeyValue(
00333     szCLSID,
00334     TEXT("NotInsertable"),
00335     NULL);
00336   SetRegKeyValue(
00337     szCLSID,
00338     TEXT("InprocServer32"),
00339     szModulePath);
00340   AddRegNamedValue(
00341     szCLSID,
00342     TEXT("InprocServer32"),
00343     TEXT("ThreadingModel"),
00344     TEXT("Both"));
00345
00346   return hr;
00347 }
00348
00349
00350 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00351   Function: DllUnregisterServer
00352
00353   Summary:  The standard exported function that can be called to command
00354             this DLL server to unregister itself from the system Registry.
00355
00356   Args:     void.
00357
00358   Returns:  HRESULT
00359               NOERROR
00360 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00361 STDAPI DllUnregisterServer(void)
00362 {
00363   HRESULT  hr = NOERROR;
00364   TCHAR    szID[GUID_SIZE+1];
00365   TCHAR    szCLSID[GUID_SIZE+32];
00366   TCHAR    szTemp[MAX_PATH+GUID_SIZE];
00367
00368   /*-------------------------------------------------------------------------
00369     Delete registry entries for the Ball Component.
00370   -------------------------------------------------------------------------*/
00371   //Create some base key strings.
00372   StringFromGUID2(CLSID_DllBall, szID, GUID_SIZE);
00373   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00374   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00375
00376   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllBall\\CurVer"));
00377   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllBall\\CLSID"));
00378   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllBall"));
00379
00380   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllBall.1\\CLSID"));
00381   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllBall.1"));
00382
00383   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00384   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00385
00386   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00387   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00388
00389   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00390   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00391
00392   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00393   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00394
00395   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00396
00397   return hr;
00398 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Shared_Property_Manager/TServer/Human.Cpp Source File

  • Com
  • Services
  • Shared_Property_Manager
  • TServer

Human.Cpp

Go to the documentation of this file.
00001 // Filename: Human.cpp
00002 //
00003 // Description:  Implementation of CHuman
00004 // This file contains the code that handles the interaction between two
00005 // human players.
00006 //
00007 // This file is provided as part of the Microsoft Transaction Server Samples
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00010 // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00011 // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00012 // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00013 // PURPOSE.
00014 //
00015 // Copyright (C) 1997 - 2000 Microsoft Corporation, All rights reserved
00016
00017 #include "stdafx.h"
00018 #include "tServer.h"
00019 #include "Human.h"
00020
00021 #include <mtx.h>
00022 //#include <mtxspm.h>
00023
00024
00025 STDMETHODIMP CHuman::InterfaceSupportsErrorInfo(REFIID riid)
00026 {
00027   static const IID* arr[] =
00028   {
00029     &IID_IHuman,
00030   };
00031
00032   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00033   {
00034     if (::InlineIsEqualGUID(*arr[i],riid))
00035       return S_OK;
00036   }
00037   return S_FALSE;
00038 }
00039
00040
00041 STDMETHODIMP CHuman::EnterNewGame (IN BSTR bstrLocalName, OUT VARIANT* pvGameID, OUT VARIANT* pvName,
00042                    OUT VARIANT* pvOrder) {
00043
00044   HRESULT hr = S_OK;
00045
00046   IObjectContext* pObjectContext = NULL;
00047
00048   ISharedPropertyGroupManager* spmMgr = NULL;
00049   ISharedPropertyGroup* spmGroup = NULL;
00050
00051   ISharedProperty* spmPropCounter = NULL;
00052   ISharedProperty* spmPropFirstName = NULL;
00053   ISharedProperty* spmPropSecondName = NULL;
00054   ISharedProperty* spmPropState = NULL;
00055
00056   pvGameID->vt = VT_I4;
00057   pvName->vt = VT_BSTR;
00058   pvOrder->vt = VT_I4;
00059
00060   long lGameID = 0;
00061   long lOrder = 0;
00062
00063   try {
00064
00065     // Get the object context
00066     THROW_ERR ( hr = GetObjectContext (&pObjectContext) );
00067     if (pObjectContext == NULL) {
00068       THROW_ERR ( E_FAIL );
00069     }
00070
00071     // Create the SharedPropertyGroupManager
00072     THROW_ERR ( pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager, IID_ISharedPropertyGroupManager, (void**)&spmMgr) );
00073
00074     // Create the SharedPropertyGroup
00075     LONG lIsolationMode = LockMethod;
00076     LONG lReleaseMode = Process;
00077     VARIANT_BOOL bExists = VARIANT_FALSE;
00078     THROW_ERR ( spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode, &bExists, &spmGroup) );
00079
00080     // Create SharedProperties
00081     CComVariant vCounter;
00082
00083     THROW_ERR ( spmGroup->CreateProperty (L"Counter", &bExists, &spmPropCounter) );
00084     THROW_ERR ( spmPropCounter->get_Value (&vCounter) );
00085
00086     CComVariant vSecondName;
00087     CComVariant vState;
00088
00089     TCHAR szBuf [512];
00090     BSTR bstrSecondName;
00091     BSTR bstrFirstName;
00092     BSTR bstrState;
00093
00094     // Find first open two-human game
00095     if (vCounter.lVal == 0) {
00096       vCounter.lVal = 1;
00097     } else {
00098       long lScan = 1;
00099       bool bFlag = false;
00100       while (lScan < vCounter.lVal && !bFlag) {
00101
00102         wsprintf (szBuf, _T("%dState"), lScan);
00103         bstrState = TCHAR2BSTR (szBuf);
00104         THROW_ERR ( spmGroup->CreateProperty (bstrState, &bExists, &spmPropState) );
00105         ::SysFreeString (bstrState);
00106
00107         THROW_ERR ( spmPropState->get_Value (&vState) );
00108
00109         if (vState.lVal < 2) {
00110
00111           // Found a game
00112           bFlag = true;
00113         } else
00114           lScan ++;
00115
00116         THROW_ERR ( spmPropState->Release() );
00117       }
00118
00119       vCounter.lVal = lGameID = lScan;
00120     }
00121
00122     wsprintf (szBuf, _T("%dSecondName"), vCounter.lVal);
00123     bstrSecondName = TCHAR2BSTR (szBuf);
00124     wsprintf (szBuf, _T("%dState"), vCounter.lVal);
00125     bstrState = TCHAR2BSTR (szBuf);
00126     wsprintf (szBuf, _T("%dFirstName"), vCounter.lVal);
00127     bstrFirstName = TCHAR2BSTR (szBuf);
00128
00129     THROW_ERR ( spmGroup->CreateProperty (bstrFirstName, &bExists, &spmPropFirstName) );
00130     THROW_ERR ( spmGroup->CreateProperty (bstrSecondName, &bExists, &spmPropSecondName) );
00131     THROW_ERR ( spmGroup->CreateProperty (bstrState, &bExists, &spmPropState) );
00132
00133     ::SysFreeString (bstrFirstName);
00134     ::SysFreeString (bstrSecondName);
00135     ::SysFreeString (bstrState);
00136
00137     // Get current state
00138     THROW_ERR ( spmPropState->get_Value (&vState) );
00139
00140     // State table
00141     // ===========
00142     // 0 - No one in game
00143     // 1 - One player lurking
00144     // 2 - Second player joined
00145     // 3 - First player's turn
00146     // 4 - Second player's turn
00147
00148     // Is this the first time this property has been accessed?
00149     if (!bExists)
00150       vState.lVal = 0;
00151
00152     // Is there someone lurking already?
00153     if (vState.lVal == 1) {
00154
00155       CComVariant vFirstName;
00156
00157       // Get opponent's name
00158       THROW_ERR ( spmPropFirstName->get_Value (&vFirstName) );
00159
00160       // Submit own name
00161       CComVariant vSecondName2;
00162       vSecondName2.vt = VT_BSTR;
00163
00164       vSecondName2.bstrVal = ::SysAllocString (bstrLocalName);
00165       THROW_ERR ( spmPropSecondName->put_Value (vSecondName2) );
00166       ::SysFreeString (vSecondName2.bstrVal);
00167
00168       // Update state
00169       vState.lVal = 2;
00170       THROW_ERR ( spmPropState->put_Value (vState) );
00171
00172       // Assign gameID
00173       lGameID = vCounter.lVal;
00174
00175       // Initialize the game screen array
00176       InitArray();
00177       THROW_ERR ( SaveArray(lGameID) );
00178
00179       // Prepare return values
00180       pvName->bstrVal = ::SysAllocString (vFirstName.bstrVal);
00181       pvOrder->lVal = 2;
00182       pvGameID->lVal = lGameID;
00183
00184     } else {
00185
00186       CComVariant vFirstName;
00187       vFirstName.vt = VT_BSTR;
00188
00189       // Update first name
00190       vFirstName.bstrVal = ::SysAllocString (bstrLocalName);
00191       THROW_ERR ( spmPropFirstName->put_Value (vFirstName) );
00192       ::SysFreeString (vFirstName.bstrVal);
00193
00194       // Update counter for next game
00195       vCounter.lVal = vCounter.lVal + 1;
00196       THROW_ERR ( spmPropCounter->put_Value (vCounter) );
00197
00198       // Update state
00199       vState.lVal = 1;
00200       THROW_ERR ( spmPropState->put_Value (vState) );
00201
00202       // Assign gameID
00203       lGameID = vCounter.lVal - 1;
00204
00205       // Prepare return values
00206       pvName->bstrVal = ::SysAllocString (L"No one");
00207       pvOrder->lVal = 1;
00208       pvGameID->lVal = lGameID;
00209     }
00210
00211     // We're finished and happy
00212     pObjectContext->SetComplete();
00213
00214   } catch (HRESULT hr) {
00215
00216     // Create an ErrorInfo object
00217     ICreateErrorInfo* pCreateErrInfo = NULL;
00218     IErrorInfo* pErrInfo = NULL;
00219
00220     CreateErrorInfo (&pCreateErrInfo);
00221     pCreateErrInfo->QueryInterface (IID_IErrorInfo, (LPVOID FAR*) &pErrInfo);
00222
00223     // Fill in error information
00224     TCHAR szErr [512];
00225     wsprintf (szErr, _T("Error %d occurred in Human::EnterNewGame()"), hr);
00226     BSTR bstrDesc = TCHAR2BSTR (szErr);
00227
00228     pCreateErrInfo->SetGUID (IID_IComputer);
00229     pCreateErrInfo->SetSource (L"Computer");
00230     pCreateErrInfo->SetDescription (bstrDesc);
00231     ::SysFreeString (bstrDesc);
00232
00233     // Confirm error information
00234     SetErrorInfo (0, pErrInfo);
00235
00236     // Clean up the error objects
00237     if (pCreateErrInfo)
00238       pCreateErrInfo->Release();
00239
00240     if (pErrInfo)
00241       pErrInfo->Release();
00242
00243     // Indicate our unhappiness
00244     if (pObjectContext)
00245       pObjectContext->SetAbort();
00246
00247     hr = E_FAIL;
00248   }
00249
00250   if (pObjectContext)
00251     pObjectContext->Release();
00252
00253   if (spmMgr)
00254     spmMgr->Release();
00255
00256   if (spmGroup)
00257     spmGroup->Release();
00258
00259   if (spmPropCounter)
00260     spmPropCounter->Release();
00261
00262   if (spmPropFirstName)
00263     spmPropFirstName->Release();
00264
00265   if (spmPropSecondName)
00266     spmPropSecondName->Release();
00267
00268   if (spmPropState)
00269     spmPropState->Release();
00270
00271   return hr;
00272 }
00273
00274
00275 STDMETHODIMP CHuman::NewMove (IN long lGameID, IN long lOrder, IN long lX, IN long lY, OUT VARIANT* pvWin) {
00276
00277   // Win protocol
00278   // ============
00279   // 0  -> move did not end game
00280   // 1  -> player won
00281   // -1 -> remote player won (won't occur in this function)
00282   // 2  -> player's move tied the game
00283   // -2 -> remote player's move tied the game (won't occur in this function)
00284
00285   HRESULT hr = S_OK;
00286
00287   IObjectContext* pObjectContext = NULL;
00288
00289   ISharedPropertyGroupManager* spmMgr = NULL;
00290   ISharedPropertyGroup* spmGroup = NULL;
00291
00292   ISharedProperty* spmPropState = NULL;
00293   ISharedProperty* spmPropX = NULL;
00294   ISharedProperty* spmPropY = NULL;
00295   ISharedProperty* spmPropWin = NULL;
00296
00297   pvWin->vt = VT_I4;
00298
00299   long lWin = 0;
00300
00301
00302   try {
00303
00304     // Get the object context
00305     THROW_ERR ( hr = GetObjectContext(&pObjectContext) );
00306     if (pObjectContext == NULL) {
00307       THROW_ERR ( E_FAIL );
00308     }
00309
00310     // Create the SharedPropertyGroupManager
00311     THROW_ERR ( pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager,
00312       IID_ISharedPropertyGroupManager, (void**)&spmMgr) );
00313
00314     // Create the SharedPropertyGroup
00315     LONG lIsolationMode = LockMethod;
00316     LONG lReleaseMode = Process;
00317     VARIANT_BOOL bExists = VARIANT_FALSE;
00318     THROW_ERR ( spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode,
00319       &bExists, &spmGroup) );
00320
00321     // Create SharedProperties
00322     BSTR bstrState;
00323     BSTR bstrX;
00324     BSTR bstrY;
00325     BSTR bstrWin;
00326     TCHAR szBuf[512];
00327     wsprintf (szBuf, _T("%dState"), lGameID);
00328     bstrState = TCHAR2BSTR (szBuf);
00329     wsprintf (szBuf, _T("%dX"), lGameID);
00330     bstrX = TCHAR2BSTR (szBuf);
00331     wsprintf (szBuf, _T("%dY"), lGameID);
00332     bstrY = TCHAR2BSTR (szBuf);
00333     wsprintf (szBuf, _T("%dWin"), lGameID);
00334     bstrWin = TCHAR2BSTR (szBuf);
00335
00336     THROW_ERR ( spmGroup->CreateProperty (bstrState, &bExists, &spmPropState) );
00337     THROW_ERR ( spmGroup->CreateProperty (bstrX, &bExists, &spmPropX) );
00338     THROW_ERR ( spmGroup->CreateProperty (bstrY, &bExists, &spmPropY) );
00339     THROW_ERR ( spmGroup->CreateProperty (bstrWin, &bExists, &spmPropWin) );
00340
00341     ::SysFreeString (bstrState);
00342     ::SysFreeString (bstrX);
00343     ::SysFreeString (bstrY);
00344     ::SysFreeString (bstrWin);
00345
00346     CComVariant vState;
00347     CComVariant vX;
00348     CComVariant vY;
00349     CComVariant vWin;
00350     vState.vt = VT_I4;
00351     vX.vt = VT_I4;
00352     vY.vt = VT_I4;
00353     vWin.vt = VT_I4;
00354
00355     // Load screen data
00356     THROW_ERR ( LoadArray(lGameID) );
00357
00358     // Save player's move to local storage and to Spam
00359     plField[lX][lY] = lOrder;
00360
00361     vX.lVal = lX;
00362     vY.lVal = lY;
00363     THROW_ERR ( spmPropX->put_Value (vX) );
00364     THROW_ERR ( spmPropY->put_Value (vY) );
00365
00366     // Submit new state
00367     if (lOrder == 1)
00368       vState.lVal = 4;
00369     else
00370       vState.lVal = 3;
00371
00372     THROW_ERR ( spmPropState->put_Value (vState) );
00373
00374     // Commit move to global storage
00375     THROW_ERR ( SaveArray (lGameID) );
00376
00377     // Check for win
00378     if (IsWin (lOrder)) {
00379
00380       // Player wins
00381       lWin = 1;
00382
00383       // Other player loses
00384       vWin.lVal = - 1;
00385       THROW_ERR ( spmPropWin->put_Value (vWin) );
00386     }
00387
00388     else if (HowManyTurns() == 9) {
00389
00390       // Player ties on his move
00391       lWin = 2;
00392
00393       // Other player ties on opponent's move
00394       vWin.lVal = - 2;
00395       THROW_ERR ( spmPropWin->put_Value (vWin) );
00396     }
00397
00398     // Prepare return values
00399     pvWin->lVal = lWin;
00400
00401     // We're happy and finished
00402     pObjectContext->SetComplete();
00403
00404   } catch (HRESULT hr) {
00405
00406     // Create an ErrorInfo object
00407     ICreateErrorInfo* pCreateErrInfo = NULL;
00408     IErrorInfo* pErrInfo = NULL;
00409
00410     CreateErrorInfo (&pCreateErrInfo);
00411     pCreateErrInfo->QueryInterface (IID_IErrorInfo, (LPVOID FAR*) &pErrInfo);
00412
00413     // Fill in error information
00414     TCHAR szErr [512];
00415     wsprintf (szErr, _T("Error %d occurred in Human::NewMove()"), hr);
00416     BSTR bstrDesc = TCHAR2BSTR (szErr);
00417     pCreateErrInfo->SetGUID (IID_IComputer);
00418     pCreateErrInfo->SetSource (L"Computer");
00419     pCreateErrInfo->SetDescription (bstrDesc);
00420     ::SysFreeString (bstrDesc);
00421
00422     // Confirm error information
00423     SetErrorInfo (0, pErrInfo);
00424
00425     // Clean up the error objects
00426     if (pCreateErrInfo)
00427       pCreateErrInfo->Release();
00428
00429     if (pErrInfo)
00430       pErrInfo->Release();
00431
00432     // Indicate our unhappiness
00433     if (pObjectContext)
00434       pObjectContext->SetAbort();
00435
00436     hr = E_FAIL;
00437   }
00438
00439   if (pObjectContext)
00440     pObjectContext->Release();
00441
00442   if (spmMgr)
00443     spmMgr->Release();
00444
00445   if (spmGroup)
00446     spmGroup->Release();
00447
00448   if (spmPropState)
00449     spmPropState->Release();
00450
00451   if (spmPropX)
00452     spmPropX->Release();
00453
00454   if (spmPropY)
00455     spmPropY->Release();
00456
00457   if (spmPropWin)
00458     spmPropWin->Release();
00459
00460   return hr;
00461
00462 }
00463
00464
00465 STDMETHODIMP CHuman::GetNewMove (IN long lGameID, IN long lOrder, OUT VARIANT* pvName,
00466                  OUT VARIANT* pvFoeX, OUT VARIANT* pvFoeY, OUT VARIANT* pvWin,
00467                  OUT VARIANT* pvUpdate) {
00468
00469   // Win protocol
00470   // ============
00471   // 0  -> move did not end game
00472   // 1  -> player won (won't occur in this function)
00473   // -1 -> remote player won
00474   // 2  -> player's move tied the game (won't occur in this function)
00475   // -2 -> remote player's move tied the game
00476
00477   HRESULT hr = S_OK;
00478
00479   IObjectContext* pObjectContext = NULL;
00480
00481   ISharedPropertyGroupManager* spmMgr = NULL;
00482   ISharedPropertyGroup* spmGroup = NULL;
00483   ISharedProperty* spmPropState = NULL;
00484   ISharedProperty* spmPropX = NULL;
00485   ISharedProperty* spmPropY = NULL;
00486   ISharedProperty* spmPropWin = NULL;
00487   ISharedProperty* spmPropSecondName = NULL;
00488
00489   pvName->vt = VT_BSTR;
00490   pvFoeX->vt = VT_I4;
00491   pvFoeY->vt = VT_I4;
00492   pvWin->vt = VT_I4;
00493   pvUpdate->vt = VT_I4;
00494
00495   long lWin = 0;
00496   long lUpdate = 0;
00497   long lX = 0;
00498   long lY = 0;
00499
00500
00501   try {
00502
00503     // Get the object context
00504     THROW_ERR ( hr = GetObjectContext(&pObjectContext) );
00505     if (pObjectContext == NULL) {
00506       THROW_ERR ( E_FAIL );
00507     }
00508
00509     // Create the SharedPropertyGroupManager
00510     THROW_ERR ( pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager,
00511       IID_ISharedPropertyGroupManager, (void**)&spmMgr) );
00512
00513     // Create the SharedPropertyGroup
00514     LONG lIsolationMode = LockMethod;
00515     LONG lReleaseMode = Process;
00516     VARIANT_BOOL bExists = VARIANT_FALSE;
00517     THROW_ERR ( spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode,
00518       &bExists, &spmGroup) );
00519
00520     // Create SharedProperties
00521     BSTR bstrState;
00522     BSTR bstrX;
00523     BSTR bstrY;
00524     BSTR bstrWin;
00525     BSTR bstrSecondName;
00526     TCHAR szBuf[512];
00527     wsprintf (szBuf, _T("%dState"), lGameID);
00528     bstrState = TCHAR2BSTR (szBuf);
00529     wsprintf (szBuf, _T("%dX"), lGameID);
00530     bstrX = TCHAR2BSTR (szBuf);
00531     wsprintf (szBuf, _T("%dY"), lGameID);
00532     bstrY = TCHAR2BSTR (szBuf);
00533     wsprintf (szBuf, _T("%dWin"), lGameID);
00534     bstrWin = TCHAR2BSTR (szBuf);
00535     wsprintf (szBuf, _T("%dSecondName"), lGameID);
00536     bstrSecondName = TCHAR2BSTR (szBuf);
00537
00538     THROW_ERR ( spmGroup->CreateProperty (bstrState, &bExists, &spmPropState) );
00539     THROW_ERR ( spmGroup->CreateProperty (bstrX, &bExists, &spmPropX) );
00540     THROW_ERR ( spmGroup->CreateProperty (bstrY, &bExists, &spmPropY) );
00541     THROW_ERR ( spmGroup->CreateProperty (bstrWin, &bExists, &spmPropWin) );
00542     THROW_ERR ( spmGroup->CreateProperty (bstrSecondName, &bExists, &spmPropSecondName) );
00543
00544     ::SysFreeString (bstrState);
00545     ::SysFreeString (bstrX);
00546     ::SysFreeString (bstrY);
00547     ::SysFreeString (bstrWin);
00548     ::SysFreeString (bstrSecondName);
00549
00550     // Get state and move parameters
00551     CComVariant vState;
00552     CComVariant vX;
00553     CComVariant vY;
00554     CComVariant vWin;
00555     CComVariant vSecondName;
00556     THROW_ERR ( spmPropState->get_Value (&vState) );
00557     THROW_ERR ( spmPropX->get_Value (&vX) );
00558     THROW_ERR ( spmPropY->get_Value (&vY) );
00559     THROW_ERR ( spmPropWin->get_Value (&vWin) );
00560     THROW_ERR ( spmPropSecondName->get_Value (&vSecondName) );
00561
00562     switch (vState.lVal) {
00563
00564     case (0):
00565
00566       // Shouldn't happen
00567       THROW_ERR ( E_FAIL);
00568       break;
00569
00570     case (1):
00571
00572       // Still waiting for next player to join
00573       lUpdate = 0;
00574       break;
00575
00576     case (2):
00577
00578       // Other player just joined
00579       if (lOrder == 1) {
00580         lUpdate = 2;
00581         pvName->bstrVal = ::SysAllocString (vSecondName.bstrVal);
00582
00583         // It's now the first player's turn
00584         vState.lVal = 3;
00585         THROW_ERR ( spmPropState->put_Value (vState) );
00586       }
00587
00588       break;
00589
00590     case (3):
00591     case (4):
00592
00593       long lTemp;
00594       if (vState.lVal == 3)
00595         lTemp = 1;
00596       else
00597         lTemp = 2;
00598
00599       // Has other player moved?
00600       if (lOrder == lTemp) {
00601
00602         // Other player has moved
00603         lX = vX.lVal;
00604         lY = vY.lVal;
00605         lWin = vWin.lVal;
00606         lUpdate = 1;
00607
00608       } else {
00609
00610         // Waiting for other player to move
00611         lUpdate = 0;
00612       }
00613
00614       break;
00615
00616     default:
00617
00618       // Shouldn't happen
00619       THROW_ERR ( E_FAIL );
00620       break;
00621     }
00622
00623     // Prepare return values
00624     pvFoeX->lVal = lX;
00625     pvFoeY->lVal = lY;
00626     pvWin->lVal = lWin;
00627     pvUpdate->lVal = lUpdate;
00628
00629     // We are finished and happy
00630     pObjectContext->SetComplete();
00631
00632   } catch (HRESULT hr) {
00633
00634     // Create an ErrorInfo object
00635     ICreateErrorInfo* pCreateErrInfo = NULL;
00636     IErrorInfo* pErrInfo = NULL;
00637
00638     CreateErrorInfo (&pCreateErrInfo);
00639     pCreateErrInfo->QueryInterface (IID_IErrorInfo, (LPVOID FAR*) &pErrInfo);
00640
00641     // Fill in error information
00642     TCHAR szErr [512];
00643     wsprintf (szErr, _T("Error %d occurred in Human::GetNewMove()"), hr);
00644     BSTR bstrDesc = TCHAR2BSTR (szErr);
00645     pCreateErrInfo->SetGUID (IID_IComputer);
00646     pCreateErrInfo->SetSource (L"Computer");
00647     pCreateErrInfo->SetDescription (bstrDesc);
00648     ::SysFreeString (bstrDesc);
00649
00650     // Confirm error information
00651     SetErrorInfo (0, pErrInfo);
00652
00653     // Clean up the error objects
00654     if (pCreateErrInfo)
00655       pCreateErrInfo->Release();
00656
00657     if (pErrInfo)
00658       pErrInfo->Release();
00659
00660     // Indicate our unhappiness
00661     if (pObjectContext)
00662       pObjectContext->SetAbort();
00663
00664     hr = E_FAIL;
00665   }
00666
00667   if (pObjectContext)
00668     pObjectContext->Release();
00669
00670   if (spmMgr)
00671     spmMgr->Release();
00672
00673   if (spmGroup)
00674     spmGroup->Release();
00675
00676   if (spmPropState)
00677     spmPropState->Release();
00678
00679   if (spmPropX)
00680     spmPropX->Release();
00681
00682   if (spmPropY)
00683     spmPropY->Release();
00684
00685   if (spmPropWin)
00686     spmPropWin->Release();
00687
00688   if (spmPropSecondName)
00689     spmPropSecondName->Release();
00690
00691   return hr;
00692 }
00693
00694
00695 bool CHuman::IsWin (long lPlayer) {
00696
00697   bool bWin = false;
00698
00699   for (int i = 0; i < 3; i ++) {
00700     if (plField [i][0] == plField [i][1] && plField [i][1] == plField [i][2] && plField [i][0] == lPlayer)
00701       bWin = true;
00702     if (plField [0][i] == plField [1][i] && plField [1][i] == plField [2][i] && plField [0][i] == lPlayer)
00703       bWin = true;
00704   }
00705
00706   if (plField [0][0] == plField [1][1] && plField [1][1] == plField [2][2] && plField [1][1] == lPlayer)
00707     bWin = true;
00708   if (plField [2][0] == plField [1][1] && plField [1][1] == plField [0][2] && plField [1][1] == lPlayer)
00709     bWin = true;
00710
00711   return bWin;
00712 }
00713
00714
00715 long CHuman::HowManyTurns () {
00716
00717   long lTurns = 0;
00718
00719   for (int i = 0; i < 3; i ++) {
00720     for (int j = 0; j < 3; j ++) {
00721       if (plField[i][j] > 0) {
00722         lTurns ++;
00723       }
00724     }
00725   }
00726
00727   return lTurns;
00728 }
00729
00730
00731 HRESULT CHuman::LoadArray (long lGameID) {
00732
00733   HRESULT hr = S_OK;
00734
00735   IObjectContext* pObjectContext = NULL;
00736
00737   ISharedPropertyGroupManager* spmMgr = NULL;
00738   ISharedPropertyGroup* spmGroup = NULL;
00739   ISharedProperty* spmPropField[3][3];
00740
00741   // Get context
00742   hr = GetObjectContext(&pObjectContext);
00743
00744   // Create the SharedPropertyGroupManager
00745   hr = pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager, IID_ISharedPropertyGroupManager, (void**)&spmMgr);
00746
00747   // Create the SharedPropertyGroup
00748   LONG lIsolationMode = LockMethod;
00749   LONG lReleaseMode = Process;
00750   VARIANT_BOOL bExists = VARIANT_FALSE;
00751   hr = spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode, &bExists, &spmGroup);
00752
00753   // Load the field SharedProperties
00754   TCHAR szBuf [512];
00755   BSTR bstrField;
00756   CComVariant vField;
00757
00758   for (long i = 0; i < 3; i ++ ) {
00759     for (long j = 0; j < 3; j ++) {
00760
00761       wsprintf (szBuf, _T("%dField%d%d"), lGameID, i, j);
00762       bstrField = TCHAR2BSTR (szBuf);
00763       hr = spmGroup->CreateProperty (bstrField, &bExists, &spmPropField[i][j]);
00764       ::SysFreeString (bstrField);
00765
00766       hr = spmPropField[i][j]->get_Value (&vField);
00767       plField[i][j] = vField.lVal;
00768     }
00769   }
00770
00771   if (pObjectContext)
00772     pObjectContext->Release();
00773
00774   if (spmMgr)
00775     spmMgr->Release();
00776
00777   if (spmGroup)
00778     spmGroup->Release();
00779
00780   for (i = 0; i < 3; i ++) {
00781     for (long j = 0; j < 3; j ++) {
00782       if (spmPropField[i][j]) {
00783         spmPropField[i][j]->Release();
00784       }
00785     }
00786   }
00787
00788   return hr;
00789 }
00790
00791
00792 HRESULT CHuman::SaveArray (long lGameID) {
00793
00794   HRESULT hr = S_OK;
00795
00796   IObjectContext* pObjectContext = NULL;
00797
00798   ISharedPropertyGroupManager* spmMgr = NULL;
00799   ISharedPropertyGroup* spmGroup = NULL;
00800   ISharedProperty* spmPropField[3][3];
00801
00802   // Get context
00803   hr = GetObjectContext(&pObjectContext);
00804
00805   // Create the SharedPropertyGroupManager
00806   hr = pObjectContext->CreateInstance (CLSID_SharedPropertyGroupManager, IID_ISharedPropertyGroupManager, (void**)&spmMgr);
00807
00808   // Create the SharedPropertyGroup
00809   LONG lIsolationMode = LockMethod;
00810   LONG lReleaseMode = Process;
00811   VARIANT_BOOL bExists = VARIANT_FALSE;
00812   hr = spmMgr->CreatePropertyGroup (L"TicTacToe", &lIsolationMode, &lReleaseMode, &bExists, &spmGroup);
00813
00814   // Save the field shared properties
00815   TCHAR szBuf [512];
00816   BSTR bstrField;
00817   CComVariant vField;
00818   vField.vt = VT_I4;
00819
00820   for (long i = 0; i < 3; i ++ ) {
00821     for (long j = 0; j < 3; j ++) {
00822
00823       wsprintf (szBuf, _T("%dField%d%d"), lGameID, i, j);
00824       bstrField = TCHAR2BSTR (szBuf);
00825       hr = spmGroup->CreateProperty (bstrField, &bExists, &spmPropField[i][j]);
00826       ::SysFreeString (bstrField);
00827
00828       vField.lVal = plField[i][j];
00829       hr = spmPropField[i][j]->put_Value (vField);
00830     }
00831   }
00832
00833   if (pObjectContext)
00834     pObjectContext->Release();
00835
00836   if (spmMgr)
00837     spmMgr->Release();
00838
00839   if (spmGroup)
00840     spmGroup->Release();
00841
00842   for (i = 0; i < 3; i ++) {
00843     for (long j = 0; j < 3; j ++) {
00844       if (spmPropField[i][j]) {
00845         spmPropField[i][j]->Release();
00846       }
00847     }
00848   }
00849
00850   return hr;
00851 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/crow.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

crow.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CROW.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 //////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 /////////////////////////////////////////////////////////////////
00019 // CRow::CRow
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CRow::CRow(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CDataAccess(eCRow, pCMainWindow, pCMDIChild)
00024 {
00025   //Row
00026   m_pIRow             = NULL;//Row Interface
00027   m_pIGetSession          = NULL;//Row Interface
00028
00029   m_pIColumnsInfo2        = NULL;//Row Interface
00030   m_pICreateRow         = NULL;//Row Interface
00031   m_pIDBCreateCommand       = NULL;//Row Interface
00032   m_pIRowChange         = NULL;//Row Interface
00033   m_pIRowSchemaChange       = NULL;//Row Interface
00034   m_pIBindResource        = NULL;//Row Interface
00035   m_pIScopedOperations      = NULL;//Row Interface
00036
00037   //ColAccess
00038   m_cColAccess  = 0;
00039   m_rgColAccess   = NULL;
00040
00041   //Listeners
00042
00043   //Data
00044   m_hSourceRow  = NULL;
00045 }
00046
00047
00048 /////////////////////////////////////////////////////////////////
00049 // CRow::~CRow
00050 //
00051 /////////////////////////////////////////////////////////////////
00052 CRow::~CRow()
00053 {
00054   ReleaseObject(0);
00055 }
00056
00057
00058 /////////////////////////////////////////////////////////////////
00059 // IUnknown** CRow::GetInterfaceAddress
00060 //
00061 /////////////////////////////////////////////////////////////////
00062 IUnknown** CRow::GetInterfaceAddress(REFIID riid)
00063 {
00064   HANDLE_GETINTERFACE(IRow);
00065   HANDLE_GETINTERFACE(IGetSession);
00066   HANDLE_GETINTERFACE(IColumnsInfo2);
00067   HANDLE_GETINTERFACE(ICreateRow);
00068   HANDLE_GETINTERFACE(IDBCreateCommand);
00069   HANDLE_GETINTERFACE(IRowChange);
00070   HANDLE_GETINTERFACE(IRowSchemaChange);
00071   HANDLE_GETINTERFACE(IBindResource);
00072   HANDLE_GETINTERFACE(IScopedOperations);
00073
00074   //Otherwise delegate
00075   return CDataAccess::GetInterfaceAddress(riid);
00076 }
00077
00078
00079 /////////////////////////////////////////////////////////////////
00080 // CRow::AutoRelease
00081 //
00082 /////////////////////////////////////////////////////////////////
00083 HRESULT CRow::AutoRelease()
00084 {
00085   m_cColAccess = 0;
00086   SAFE_FREE(m_rgColAccess);
00087
00088   //Rowset
00089   RELEASE_INTERFACE(IRow);
00090   RELEASE_INTERFACE(IGetSession);
00091
00092   RELEASE_INTERFACE(IColumnsInfo2);
00093   RELEASE_INTERFACE(ICreateRow);
00094   RELEASE_INTERFACE(IDBCreateCommand);
00095   RELEASE_INTERFACE(IRowChange);
00096   RELEASE_INTERFACE(IRowSchemaChange);
00097   RELEASE_INTERFACE(IBindResource);
00098   RELEASE_INTERFACE(IScopedOperations);
00099
00100   //Delegate
00101   return CDataAccess::AutoRelease();
00102 }
00103
00104
00105 ////////////////////////////////////////////////////////////////
00106 // CRow::AutoQI
00107 //
00108 /////////////////////////////////////////////////////////////////
00109 HRESULT CRow::AutoQI(DWORD dwCreateOpts)
00110 {
00111   //Delegate First so we have base interfaces
00112   CDataAccess::AutoQI(dwCreateOpts);
00113
00114   //[MANDATORY] Obtain [mandatory] interfaces
00115   if(dwCreateOpts & CREATE_QI_MANDATORY)
00116   {
00117     OBTAIN_INTERFACE(IRow);
00118     OBTAIN_INTERFACE(IGetSession);
00119   }
00120
00121   //Auto QI
00122   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00123   {
00124     OBTAIN_INTERFACE(IColumnsInfo2);
00125     OBTAIN_INTERFACE(ICreateRow);
00126     OBTAIN_INTERFACE(IDBCreateCommand);
00127     OBTAIN_INTERFACE(IRowChange);
00128     OBTAIN_INTERFACE(IRowSchemaChange);
00129     OBTAIN_INTERFACE(IBindResource);
00130     OBTAIN_INTERFACE(IScopedOperations);
00131   }
00132
00133   return S_OK;
00134 }
00135
00136
00137
00138 /////////////////////////////////////////////////////////////////
00139 // HRESULT CRow::DisplayObject
00140 //
00141 /////////////////////////////////////////////////////////////////
00142 HRESULT CRow::DisplayObject()
00143 {
00144   HRESULT hr = S_OK;
00145   BINDCOLS eBindCols = (GetOptions()->m_dwAccessorOpts & ACCESSOR_BIND_BOOKMARK ? BIND_ALLCOLS : BIND_ALLCOLSEXPECTBOOKMARK);
00146
00147   if(m_pCMDIChild)
00148   {
00149     //First Clear the existing Window...
00150     m_pCMDIChild->m_pCDataGrid->m_fLastFetchForward = FALSE;
00151     m_pCMDIChild->m_pCDataGrid->m_lCurPos = 0;
00152     TESTC(hr = m_pCMDIChild->m_pCDataGrid->ClearAll());
00153   }
00154
00155   //Setup ColumnAccess Structures, (based off the ColumnInfo)
00156   TESTC(hr = SetupColAccess(eBindCols));
00157
00158   if(m_pCMDIChild)
00159   {
00160     //Refresh the Columns and Rows
00161     TESTC(hr = m_pCMDIChild->m_pCDataGrid->RefreshData());
00162   }
00163
00164   //Delegate
00165   TESTC(hr = CDataAccess::DisplayObject());
00166
00167 CLEANUP:
00168   if(m_pCMDIChild)
00169     m_pCMDIChild->UpdateControls();
00170   return hr;
00171 }
00172
00173
00174
00175 /////////////////////////////////////////////////////////////////////////////
00176 // CRow::GetObjectDesc
00177 //
00178 /////////////////////////////////////////////////////////////////////////////
00179 WCHAR* CRow::GetObjectDesc()
00180 {
00181   HRESULT hr = S_OK;
00182
00183   if(!m_strObjectDesc && m_hSourceRow)
00184   {
00185     WCHAR* pwszValue = NULL;
00186
00187     //0x00000000 = 1 Byte = 2 Asci Chars + "0x" + NULL Terminator
00188     SAFE_ALLOC(pwszValue, WCHAR, POINTER_DISPLAYSIZE);
00189     StringFormat(pwszValue, POINTER_DISPLAYSIZE, L"0x%p", (HANDLE)m_hSourceRow);
00190     m_strObjectDesc.Attach(pwszValue);
00191   }
00192
00193 CLEANUP:
00194   return m_strObjectDesc;
00195 }
00196
00197
00198 /////////////////////////////////////////////////////////////////
00199 // HRESULT CRow::CreateCommand
00200 //
00201 /////////////////////////////////////////////////////////////////
00202 HRESULT CRow::CreateCommand(CAggregate* pCAggregate, REFIID riid, IUnknown** ppIUnknown)
00203 {
00204   HRESULT       hr = S_OK;
00205
00206   //Obtain the IDBCreateCommand Interface
00207   IDBCreateCommand* pIDBCreateCommand = SOURCE_GETINTERFACE(this, IDBCreateCommand);
00208   if(pIDBCreateCommand)
00209   {
00210     //CreateCommand
00211     XTEST(hr = pIDBCreateCommand->CreateCommand(pCAggregate, riid, ppIUnknown));
00212     TESTC(TRACE_METHOD(hr, L"IDBCreateCommand::CreateCommand(0x%p, %s, &0x%p)", pCAggregate, GetInterfaceName(riid), ppIUnknown ? *ppIUnknown : NULL));
00213
00214     //Handle Aggregation
00215     if(pCAggregate)
00216       TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00217   }
00218
00219 CLEANUP:
00220   return hr;
00221 }
00222
00223
00224 /////////////////////////////////////////////////////////////////
00225 // HRESULT CRow::OpenRowset
00226 //
00227 /////////////////////////////////////////////////////////////////
00228 HRESULT CRow::OpenRowset(CAggregate* pCAggregate, DBID* pTableID, DBID* pIndexID, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown)
00229 {
00230   HRESULT       hr = E_FAIL;      // HRESULT
00231
00232   if(!m_pIScopedOperations)
00233     return E_FAIL;
00234
00235   WCHAR wszTableName[MAX_QUERY_LEN+1];
00236   WCHAR wszIndexName[MAX_QUERY_LEN+1];
00237
00238   // From IOpenRowset, get a rowset object
00239   DBIDToString(pTableID, wszTableName, MAX_QUERY_LEN);
00240   DBIDToString(pIndexID, wszIndexName, MAX_QUERY_LEN);
00241
00242   XTEST_(hr = m_pIScopedOperations->OpenRowset(
00243               pCAggregate,    // pUnkOuter
00244               pTableID,     // pTableID
00245               pIndexID,     // pIndexID
00246               riid,       // refiid
00247               cPropSets,      // cProperties
00248               rgPropSets,     // rgProperties
00249               ppIUnknown),S_OK);  // IRowset pointer
00250   TRACE_METHOD(hr, L"IScopedOperations::OpenRowset(0x%p, %s, %s, %s, %d, 0x%p, &0x%p)", pCAggregate, wszTableName, wszIndexName, GetInterfaceName(riid), cPropSets, rgPropSets, ppIUnknown ? *ppIUnknown : NULL);
00251
00252   //Display Errors (if occurred)
00253   TESTC(hr = DisplayPropErrors(hr, cPropSets, rgPropSets));
00254
00255   //Handle Aggregation
00256   if(pCAggregate)
00257     TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00258
00259 CLEANUP:
00260   return hr;
00261 }
00262
00263
00264 /////////////////////////////////////////////////////////////////
00265 // HRESULT CRow::SetupColAccess
00266 //
00267 /////////////////////////////////////////////////////////////////
00268 HRESULT CRow::SetupColAccess(BINDCOLS eBindCols)
00269 {
00270   HRESULT hr = S_OK;
00271   DBLENGTH dwOffset = 0;
00272   ULONG i;
00273
00274   //Only capable of the Following Converions (for Display)
00275   DWORD  dwMaxLength    = GetOptions()->m_dwMaxLength;
00276   DWORD  dwAccessorOpts = GetOptions()->m_dwAccessorOpts;
00277
00278   if(m_pIColumnsInfo == NULL)
00279     return E_FAIL;
00280
00281   //GetColumnInfo
00282   GetColInfo();
00283
00284   //Alloc the space to hold the ColumnAccess structs
00285   ULONG cBindings = 0;
00286   DBBINDING* rgBindings = NULL;
00287   SAFE_ALLOC(m_rgColAccess, DBCOLUMNACCESS, m_ColumnInfo.GetCount());
00288   SAFE_ALLOC(rgBindings, DBBINDING, m_ColumnInfo.GetCount());
00289
00290   //Figure out how big to make the buffer...
00291   for(i=0; i<m_ColumnInfo.GetCount(); i++)
00292   {
00293     //Offset
00294     m_rgColAccess[i].cbMaxLen = GetMaxDisplaySize(GetOptions()->GetBindingType(m_ColumnInfo[i].wType), m_ColumnInfo[i].wType, m_ColumnInfo[i].ulColumnSize, dwMaxLength);
00295     dwOffset = ROUNDUP( dwOffset + m_rgColAccess[i].cbMaxLen );
00296   }
00297
00298   //Size for pData
00299   SAFE_REALLOC(m_pData, BYTE, dwOffset);
00300
00301   dwOffset = 0;
00302   m_cColAccess = 0;
00303   cBindings = 0;
00304   for(i=0; i<m_ColumnInfo.GetCount(); i++)
00305   {
00306     DBCOLUMNINFO* pColInfo  = &m_ColumnInfo[i];
00307     DBCOLUMNACCESS* pColAccess  = &m_rgColAccess[m_cColAccess];
00308     DBBINDING*    pBinding  = &rgBindings[cBindings];
00309
00310     //Setup the Bindings
00311     pColAccess->columnid    = pColInfo->columnid;
00312     pColAccess->bPrecision    = pColInfo->bPrecision;
00313     pColAccess->bScale      = pColInfo->bScale;
00314     pColAccess->wType     = GetOptions()->GetBindingType(pColInfo->wType);
00315     pColAccess->cbDataLen   = 0;
00316
00317     //NOTE: This is setup above in the Previous for loop...
00318     pColAccess->cbMaxLen    = m_rgColAccess[i].cbMaxLen;
00319
00320     //BLOB or IUnknown Bindings
00321     if(pColAccess->wType == DBTYPE_IUNKNOWN || pColInfo->wType == DBTYPE_IUNKNOWN ||
00322       (pColInfo->dwFlags & DBCOLUMNFLAGS_ISLONG && (dwAccessorOpts & (ACCESSOR_BLOB_ISEQSTREAM|ACCESSOR_BLOB_ILOCKBYTES|ACCESSOR_BLOB_ISTORAGE|ACCESSOR_BLOB_ISTREAM))))
00323     {
00324       pColAccess->wType   = DBTYPE_IUNKNOWN;
00325       pColAccess->cbMaxLen  = sizeof(IUnknown*);
00326     }
00327
00328     //If the consumer requested not to bind the Value in Options, then set pData = NULL
00329     //This is how the 2.5 spec says to indicate VALUE is not bound (since their is no dwPart).
00330     pColAccess->pData     = NULL;
00331     if(dwAccessorOpts & ACCESSOR_BIND_VALUE)
00332       pColAccess->pData   = (BYTE*)m_pData + dwOffset;
00333
00334     //Initialize the Status to an error, so we don't end up freeing outofline
00335     //data we haven't retreived yet...
00336     pColAccess->dwStatus    = DBSTATUS_E_UNAVAILABLE;
00337
00338     //Special Handling for other non-OLE DB defined convertable types to WSTR
00339     //NOTE: The spec requires all supported types to be converted to
00340     //WSTR, but this only applies where the OLE DB conversion is defined.
00341     //Some are not defined so we need to bind nativly.
00342     switch(pColInfo->wType)
00343     {
00344       case DBTYPE_IUNKNOWN:
00345       case DBTYPE_IDISPATCH:
00346         pColAccess->wType   = pColInfo->wType;
00347         pColAccess->cbMaxLen  = sizeof(IUnknown*);
00348         break;
00349
00350       case DBTYPE_HCHAPTER:
00351         pColAccess->wType   = pColInfo->wType;
00352         pColAccess->cbMaxLen  = sizeof(HCHAPTER);
00353         break;
00354
00355       default:
00356         //DBTYPE_VECTOR
00357         if(pColInfo->wType  & DBTYPE_VECTOR)
00358         {
00359           pColAccess->wType = pColInfo->wType;
00360           pColAccess->cbMaxLen= sizeof(DBVECTOR);
00361         }
00362
00363         //DBTYPE_ARRAY
00364         if(pColInfo->wType  & DBTYPE_ARRAY)
00365         {
00366           pColAccess->wType = pColInfo->wType;
00367           pColAccess->cbMaxLen= sizeof(SAFEARRAY*);
00368         }
00369         break;
00370     };
00371
00372     //Offset
00373     dwOffset += pColAccess->cbMaxLen;
00374     dwOffset = ROUNDUP( dwOffset );
00375
00376     //Build a real simple binding on top of this ColumnAccess struct.
00377     //The reason is all of our data manipulations routines deal with binding structs, so instead
00378     //have having numerous code lines, we will just map this to a binding struct...
00379     pBinding->iOrdinal    = pColInfo->iOrdinal;
00380     pBinding->obStatus    = (DBBYTEOFFSET)((BYTE*)&pColAccess->dwStatus - (BYTE*)m_pData);
00381     pBinding->obLength    = (DBBYTEOFFSET)((BYTE*)&pColAccess->cbDataLen - (BYTE*)m_pData);
00382     pBinding->obValue   = (DBBYTEOFFSET)((BYTE*)pColAccess->pData - (BYTE*)m_pData);
00383
00384     pBinding->pTypeInfo   = NULL;
00385     pBinding->pObject   = NULL;
00386     pBinding->pBindExt    = NULL;
00387
00388     pBinding->dwPart    = DBPART_LENGTH|DBPART_STATUS;
00389     if(pColAccess->pData)
00390       pBinding->dwPart  |= DBPART_VALUE;
00391
00392     pBinding->dwMemOwner  = (dwAccessorOpts & ACCESSOR_OWNED_PROVIDER) ? DBMEMOWNER_PROVIDEROWNED : DBMEMOWNER_CLIENTOWNED;
00393     pBinding->eParamIO    = DBPARAMIO_NOTPARAM;
00394
00395     pBinding->cbMaxLen    = pColAccess->cbMaxLen;
00396     pBinding->dwFlags   = 0;
00397     pBinding->wType     = pColAccess->wType;
00398
00399     pBinding->bPrecision  = pColAccess->bPrecision;
00400     pBinding->bScale    = pColAccess->bScale;
00401
00402     //Do we real want this column?
00403     switch(eBindCols)
00404     {
00405       case BIND_ALLCOLS:
00406         m_cColAccess++;
00407         cBindings++;
00408         break;
00409
00410       case BIND_ALLCOLSEXPECTBOOKMARK:
00411         if(pColInfo->iOrdinal != 0)
00412         {
00413           m_cColAccess++;
00414           cBindings++;
00415         }
00416         break;
00417
00418       case BIND_UPDATEABLECOLS:
00419         if(pColInfo->dwFlags & DBCOLUMNFLAGS_WRITE || pColInfo->dwFlags & DBCOLUMNFLAGS_WRITEUNKNOWN)
00420         {
00421           m_cColAccess++;
00422           cBindings++;
00423         }
00424         break;
00425
00426       default:
00427         ASSERT(!"Unhandled Type!");
00428         break;
00429     }
00430   }
00431
00432 CLEANUP:
00433   m_Bindings.Attach(cBindings, rgBindings);
00434   return hr;
00435 }
00436
00437
00438 /////////////////////////////////////////////////////////////////
00439 // HRESULT CRow::GetColumns
00440 //
00441 /////////////////////////////////////////////////////////////////
00442 HRESULT CRow::GetColumns(ULONG cColAccess, DBCOLUMNACCESS* rgColAccess)
00443 {
00444   HRESULT hr = S_OK;
00445
00446   if(m_pIRow == NULL)
00447     return E_FAIL;
00448
00449   //GetColumns
00450   XTEST(hr = m_pIRow->GetColumns(cColAccess, rgColAccess));
00451   TESTC(TRACE_METHOD(hr, L"IRow::GetColumns(%lu, 0x%p)", cColAccess, rgColAccess));
00452
00453 CLEANUP:
00454   return hr;
00455 }
00456
00457
00458
00459 /////////////////////////////////////////////////////////////////
00460 // HRESULT CRow::Open
00461 //
00462 /////////////////////////////////////////////////////////////////
00463 HRESULT CRow::Open(CAggregate* pCAggregate, DBID* pColumnID, REFGUID rguidObjectType, REFIID riid, IUnknown** ppIUnknown)
00464 {
00465   HRESULT hr = S_OK;
00466
00467   if(m_pIRow == NULL)
00468     return E_FAIL;
00469
00470   //Convert the DBID to a string for display...
00471   WCHAR wszBuffer[MAX_QUERY_LEN+1] = {0};
00472   DBIDToString(pColumnID, wszBuffer, MAX_QUERY_LEN);
00473
00474   //Open
00475   XTEST(hr = m_pIRow->Open(pCAggregate, pColumnID, rguidObjectType, 0, riid, ppIUnknown));
00476   TESTC(TRACE_METHOD(hr, L"IRow::Open(0x%p, %s, %s, 0, %s, &0x%p)", pCAggregate, wszBuffer, GetObjectTypeName(rguidObjectType), GetInterfaceName(riid), ppIUnknown ? *ppIUnknown : NULL));
00477
00478   //Handle Aggregation
00479   if(pCAggregate)
00480     TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00481
00482 CLEANUP:
00483   return hr;
00484 }
00485
00486
00487
00488
00489 /////////////////////////////////////////////////////////////////
00490 // HRESULT CRow::Bind
00491 //
00492 /////////////////////////////////////////////////////////////////
00493 HRESULT CRow::Bind(CAggregate* pCAggregate, WCHAR* pwszURL, DBBINDURLFLAG dwBindFlags, REFGUID rguidObjectType, REFIID riid, IUnknown** ppIUnknown)
00494 {
00495   HRESULT hr = S_OK;
00496   DBBINDSTATUS dwBindStatus = 0;
00497
00498   if(m_pIBindResource == NULL)
00499     return E_FAIL;
00500
00501   //Open
00502   XTEST(hr = m_pIBindResource->Bind(pCAggregate, pwszURL, dwBindFlags, rguidObjectType,  riid, NULL, NULL, &dwBindStatus, ppIUnknown));
00503   TESTC(TRACE_METHOD(hr, L"IBindResource::Bind(0x%p, \"%s\", 0x%08x, %s, %s, NULL, NULL, &0x%p, &0x%p)", pCAggregate, pwszURL, dwBindFlags, GetObjectTypeName(rguidObjectType), GetInterfaceName(riid), &dwBindStatus, ppIUnknown ? *ppIUnknown : NULL));
00504
00505   //Handle Aggregation
00506   if(pCAggregate)
00507     TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown));
00508
00509 CLEANUP:
00510   return hr;
00511 } //CRow::Bind
00512
00513
00514
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/globals.h Source File

  • SysMgmt
  • MMC
  • CutCopy

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <mmc.h>
00023 #include <tchar.h>
00024
00025 #ifndef STRINGS_ONLY
00026
00027     enum UPDATE_VIEWS_HINT {UPDATE_SCOPEITEM = 1000, DELETE_SCOPEITEM, UPDATE_RESULTITEM, DELETE_RESULTITEM};
00028     enum ITEM_TYPE {SCOPE = 10, RESULT};
00029
00030         #define IDM_BUTTON1    0x100
00031         #define IDM_BUTTON2    0x101
00032
00033         extern HINSTANCE g_hinst;
00034         extern ULONG g_uObjects;
00035
00036         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00037         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00038
00039         // uncomment the following #define to enable message cracking
00040         // #define MMC_CRACK_MESSAGES
00041         void MMCN_Crack(BOOL bComponentData,
00042                                         IDataObject *pDataObject,
00043                                         IComponentData *pCompData,
00044                                         IComponent *pComp,
00045                                         MMC_NOTIFY_TYPE event,
00046                                         LPARAM arg,
00047                                         LPARAM param);
00048 #endif
00049
00050 //=--------------------------------------------------------------------------=
00051 // allocates a temporary buffer that will disappear when it goes out of scope
00052 // NOTE: be careful of that -- make sure you use the string in the same or
00053 // nested scope in which you created this buffer. people should not use this
00054 // class directly.  use the macro(s) below.
00055 //
00056 class TempBuffer {
00057   public:
00058     TempBuffer(ULONG cBytes) {
00059         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00060         m_fHeapAlloc = (cBytes > 120);
00061     }
00062     ~TempBuffer() {
00063         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00064     }
00065     void *GetBuffer() {
00066         return m_pBuf;
00067     }
00068
00069   private:
00070     void *m_pBuf;
00071     // we'll use this temp buffer for small cases.
00072     //
00073     char  m_szTmpBuf[120];
00074     unsigned m_fHeapAlloc:1;
00075 };
00076
00077 //=--------------------------------------------------------------------------=
00078 // string helpers.
00079 //
00080 // given a _TCHAR, copy it into a wide buffer.
00081 // be careful about scoping when using this macro!
00082 //
00083 // how to use the below two macros:
00084 //
00085 //  ...
00086 //  LPTSTR pszT;
00087 //  pszT = MyGetTStringRoutine();
00088 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00089 //  MyUseWideStringRoutine(pwsz);
00090 //  ...
00091 #ifdef UNICODE
00092 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00093     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00094     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00095     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00096     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00097 #else // ANSI
00098 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00099     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00100     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00101     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00102     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00103     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00104 #endif
00105
00106 #ifdef UNICODE
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00109     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00110     lstrcpyW((LPWSTR)ptrname, tstr)
00111 #else // ANSI
00112 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00113     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00114     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00115     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00116     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00117 #endif
00118
00119 //
00120 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00121 // have to be declared, and no clean up must be done.
00122 //
00123 // * 2 for DBCS handling in below length computation
00124 //
00125 #ifdef UNICODE
00126 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00127     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00128     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00129     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00130     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00131 #else // ANSI
00132 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00133     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00134     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00135     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00136     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00137 #endif
00138
00139 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/CascadeEC/resource.h Source File

  • Com
  • Services
  • Events
  • EventNews
  • CascadeEC

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by CascadeEC.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_CASCADE                     101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/precomp.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

precomp.h

Go to the documentation of this file.
00001 #include <mspbase.h>
00002 #include <msptrmac.h>
00003 #include <msptrmar.h>
00004 #include <msptrmvc.h>
00005
00006 #define MSPB_IsBadWritePtr(x, y) IsBadWritePtr((x), (y))
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/guids.h Source File

  • Dataaccess
  • oledb
  • sampprov

guids.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module GUIDS.H | Internal GUIDS
00008 //
00009 //
00010 #ifndef _GUIDS_H_
00011 #define _GUIDS_H_
00012
00013
00014
00015 // @msg CLSID_SampProv | {E8CCCB79-7C36-101B-AC3A-00AA0044773D}
00016 // Provider Class Id
00017 DEFINE_GUID(CLSID_SampProv,  0xE8CCCB79L,0x7C36,0x101B,0xAC,0x3A,0x00,0xAA,0x00,0x44,0x77,0x3D);
00018
00019 // @msg DBGUID_SAMPLEDIALECT | {E9FBAF50-D402-11ce-BEDC-00AA00A14D7D}
00020 //  The dialect GUID for the Sample Provider
00021 DEFINE_GUID(DBGUID_SAMPLEDIALECT, 0xe9fbaf50, 0xd402, 0x11ce, 0xbe, 0xdc, 0x0, 0xaa, 0x0, 0xa1, 0x4d, 0x7d);
00022
00023 // {119C8711-905B-11d2-AF65-00C04F6F8697}
00024 DEFINE_GUID(CLSID_SampProvConnectionPage,
00025 0x119c8711, 0x905b, 0x11d2, 0xaf, 0x65, 0x0, 0xc0, 0x4f, 0x6f, 0x86, 0x97);
00026
00027 // {119C8712-905B-11d2-AF65-00C04F6F8697}
00028 DEFINE_GUID(CLSID_SampProvAdvancedPage,
00029 0x119c8712, 0x905b, 0x11d2, 0xaf, 0x65, 0x0, 0xc0, 0x4f, 0x6f, 0x86, 0x97);
00030
00031 // {245E7460-B577-11D2-AF53-00C04F782926}
00032 DEFINE_GUID(CLSID_SampProvBinder,
00033 0x245e7460, 0xb577, 0x11d2, 0xaf, 0x53, 0x0, 0xc0, 0x4f, 0x78, 0x29, 0x26);
00034
00035 #endif
00036
00037
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepmultiuser/resources.h Source File

  • NetDS
  • RPC
  • FileRep
  • filerepmultiuser

resources.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     FILE: Resources.h
00005
00006     PURPOSE: Declarations for resource management routines and
00007         data structures.
00008
00009 */
00010 #pragma once
00011
00012 typedef struct {
00013     LONG Value;
00014     LONG Bound;
00015 } Counter;
00016
00017 /*
00018     FUNCTION: CounterCreate
00019
00020     PURPOSE: Creates a counter.
00021
00022 */
00023 Counter * CounterCreate(UINT Bound);
00024
00025 /*
00026     FUNCTION: CounterDelete
00027
00028     PURPOSE: Deletes a counter.
00029
00030 */
00031 VOID CounterDelete(Counter * pCounter);
00032
00033 /*
00034     FUNCTION: CounterIncrement
00035
00036     PURPOSE: Attempts to increment a counter.  If the
00037         incremented value is aboove the corresponding bound, does not
00038         increment and returns FALSE, otherwise increments and returns
00039         TRUE.
00040
00041     RETURN VALUE:
00042         TRUE - icremented
00043         FALSE - not incremented, bound exceeded
00044
00045     COMMENTS:
00046
00047 */
00048 BOOL CounterIncrement(Counter *pCounter);
00049
00050 /*
00051     FUNCTION: CounterDecrement
00052
00053     PURPOSE: Decrements a couner.
00054
00055     RETURN VALUE: none
00056
00057     COMMENTS:
00058
00059 */
00060 VOID CounterDecrement(Counter *pCounter);
00061
00062 /*
00063     FUNCTION: CountersCreate
00064
00065     PURPOSE: Creates nCounters counters that can be used to keep track of
00066         the resource use by several users or user groups and returns a
00067         pointer to the structure containing them.
00068
00069     PARAMETERS:
00070         Counters - Array of pointers to counters.  It
00071       is allocate dwithin this call and needs to be freed
00072       with the call to CountersDelete.
00073         nCounters - number of counters to create.
00074         Bounds - array of bound values.
00075
00076     RETURN VALUE:
00077         Pointer to the Counterst structure.
00078
00079     COMMENTS:
00080
00081 */
00082 BOOL CountersCreate(Counter *Counters[], UINT nCounters, UINT * Bounds);
00083
00084 /*
00085     FUNCTION: CountersDelete
00086
00087     PURPOSE: Deallocates an array of counter pointers
00088       and all the counters in it.
00089
00090     RETURN VALUE:
00091       TRUE - success
00092       FALSE - failure
00093
00094     COMMENTS:
00095
00096 */
00097 VOID CountersDelete(Counter *pCounters[], UINT n);
00098
00099 /*
00100     FUNCTION: CountersCheckForNonzero
00101
00102     PURPOSE: Checks if any counter in the array
00103       is nonzero.
00104
00105     PARAMETERS: none
00106
00107     RETURN VALUE:
00108       TRUE - some counter is nonzero
00109       FALSE - otherwise
00110
00111     COMMENTS: This function is not thread-safe.
00112
00113 */
00114 BOOL CountersCheckForNonzero(Counter *pCounters[], UINT n);
00115
00116 typedef struct _QueueNode {
00117     VOID *pData;
00118     _QueueNode *pNext;
00119 } QueueNode;
00120
00121 typedef struct {
00122     QueueNode *pFirst;
00123     QueueNode *pLast;
00124     LPCRITICAL_SECTION lpCriticalSection;
00125 } Queue;
00126
00127 /*
00128     FUNCTION: QueueCreate
00129
00130     PURPOSE: Creates a queue.
00131
00132 */
00133 Queue * QueueCreate(BOOL NoCritSec);
00134
00135 /*
00136     FUNCTION: QueueDelete
00137
00138     PURPOSE: Deletes a queue.
00139
00140     NOTE: It will deallocate all node data and all nodes if the
00141     queue is not empty.  No error checks are performed.
00142 */
00143 VOID QueueDelete(Queue * pQueue);
00144
00145 /*
00146     FUNCTION: QueueisEmpty
00147
00148     PURPOSE: Returns TRUE if a queue has an elt. in it and false
00149     otherwise.
00150
00151 */
00152 BOOL QueueIsEmpty(Queue * pQueue);
00153
00154 /*
00155     FUNCTION: QueueAdd
00156
00157     PURPOSE: Adds an element to the queue.
00158
00159 */
00160 VOID QueueAdd(Queue *pQueue, VOID *pData, BOOL EnterCritSec);
00161
00162 /*
00163     FUNCTION: QueueRemove
00164
00165     PURPOSE: Removes an element from the queue.
00166
00167 */
00168 VOID * QueueRemove(Queue *pQueue);
00169
00170 /*
00171     FUNCTION: QueueMoveToBackNoLock
00172
00173     PURPOSE: Moves an element to the back of the queue.
00174
00175     COMMENTS:
00176
00177 */
00178 VOID QueueMoveToBack(Queue *pQueue, QueueNode *pNode, QueueNode *pPrevNode);
00179
00180 /*
00181     FUNCTION: QueuesCreate
00182
00183     PURPOSE: Creates new queues for an array of pointers to queues.
00184
00185     RETURN VALUE:
00186       TRUE - success
00187       FALSE - failure
00188
00189     COMMENTS:
00190
00191 */
00192 BOOL QueuesCreate(Queue *Queues[], UINT n, BOOL NoCritSec);
00193
00194 /*
00195     FUNCTION: QueuesDelete
00196
00197     PURPOSE: Deletes all queues with addresses in an array of pointers
00198     to queues.
00199
00200 */
00201 VOID QueuesDelete(Queue *Queues[], UINT n);
00202
00203 typedef struct _QueueHashNode {
00204     VOID *pKey;
00205     VOID *pValue;
00206 } QueueHashNode;
00207
00208 /*
00209     FUNCTION: QueueHashAdd
00210
00211     PURPOSE: Adds an element to the hash.
00212
00213     PARAMETERS:
00214       pQueue - The queue of QueuehashNodes
00215       Sid - Sid for the user for whom we create a node
00216       pValue - Valus associated with the Sid
00217
00218 */
00219 VOID QueueHashAdd(Queue *pQueue, PSID Sid, VOID *pValue, BOOL EnterCritSec);
00220
00221 /*
00222     FUNCTION: QueueHashLookup
00223
00224     PURPOSE: Returns the element of the hash queue that
00225     corresponds to a given Sid.
00226
00227 */
00228 VOID * QueueHashLookup(Queue *pQueue, PSID Sid, BOOL EnterCritSec);
00229
00230 /*
00231     FUNCTION: QueueHashAddToSubqueue
00232
00233     PURPOSE: The function assumes that values in the
00234     hash are queues.  It checks if a queue for SID pSID
00235     already exists, and if necessary creates a new queue
00236     for the SID.  It then adds the Data to the queue
00237     corresponding to a SID.
00238
00239 */
00240 VOID QueueHashAddToSubqueue(Queue *pHashQueue, PSID pSID, VOID * pData);
00241
00242 /*
00243     FUNCTION: QueueHashRemoveFromSubqueue
00244
00245     PURPOSE: The function assumes that values in the
00246     hash are queues.  It removes an element from the
00247     first nonempty queue that it can find and puts
00248     that queue into the end of the hash queue.
00249
00250 */
00251 VOID * QueueHashRemoveFromSubqueue(Queue *pQueue);
00252
00253 /*
00254     FUNCTION: QueueHashIncrementCounter
00255
00256     PURPOSE: The function assumes that values in the
00257     hash are counters.  It checks if a counter for SID pSID
00258     already exists, and if necessary creates a new counter
00259     for the SID.  It then attempts to increment that counter.
00260
00261 */
00262 BOOL QueueHashIncrementCounter(Queue *pHashQueue, PSID pSID);
00263
00264 /*
00265     FUNCTION: QueueHashDecrementCounter
00266
00267     PURPOSE: The function assumes that values in the
00268     hash are counters.  It checks if a counter for SID pSID
00269     already exists, and if necessary creates a new counter
00270     for the SID.  It then decrements that counter.
00271
00272 */
00273 VOID QueueHashDecrementCounter(Queue *pQueue, PSID pSID);
00274
00275 // end Resources.h
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/ComPerf/psperf.Idl Source File

  • Com
  • Fundamentals
  • DCom
  • ComPerf

psperf.Idl

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 [
00019   uuid(DDC68871-E08E-11cf-A535-00AA00615B03),
00020   dual,
00021   oleautomation
00022 ]
00023 interface ICOMPerformance : IUnknown
00024 {
00025   import "oaidl.idl";
00026   [id(11)]
00027   HRESULT Test1([in] int l);
00028   [id(12)]
00029   HRESULT Test23([in] BSTR szDesc);
00030 }
00031
00032 [
00033   uuid(DDC68870-E08E-11cf-A535-00AA00615B03)
00034 ]
00035 coclass TestCOMPerformance
00036 {
00037    [default] interface ICOMPerformance;
00038 };
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImp_DrawDlg Member List

This is the complete list of members for CImp_DrawDlg, including all inherited members.
Arrived(IDispatch *pdispQueue, long lErrorCode, long lCursor) | CImp_DrawDlg |
CImp_DrawDlg(CWnd *pParent=NULL) | CImp_DrawDlg |
DoDataExchange(CDataExchange *pDX) | CImp_DrawDlg | [protected, virtual]
GetComputerName() | CImp_DrawDlg | [protected]
GetUserName() | CImp_DrawDlg | [protected]
HandleErrors(_com_error &comerr) | CImp_DrawDlg |
IDD enum value | CImp_DrawDlg |
initializeUI(BOOL fConnectedToDS) | CImp_DrawDlg |
IsDsEnabledLocaly() | CImp_DrawDlg |
LoginPrompt(CString DefaultName) | CImp_DrawDlg | [protected]
m_btnAttach | CImp_DrawDlg |
m_CancelButton | CImp_DrawDlg |
m_cComputerInput | CImp_DrawDlg |
m_cComputerLabel | CImp_DrawDlg |
m_cContinueButton | CImp_DrawDlg |
m_cDsFrame | CImp_DrawDlg |
m_cLines | CImp_DrawDlg |
m_cMessageFrame | CImp_DrawDlg |
m_cQueueInput | CImp_DrawDlg |
m_cQueueLabel | CImp_DrawDlg |
m_cRadioDS | CImp_DrawDlg |
m_cRadioExpress | CImp_DrawDlg |
m_cRadioRecoverable | CImp_DrawDlg |
m_cRadioWorkgroup | CImp_DrawDlg |
m_csFriendName | CImp_DrawDlg |
m_csLogin | CImp_DrawDlg |
m_csScreenText | CImp_DrawDlg |
m_drawScribble | CImp_DrawDlg |
m_fDsEnabledLocaly | CImp_DrawDlg | [protected]
m_hIcon | CImp_DrawDlg | [protected]
m_iArraySize | CImp_DrawDlg |
m_iRadio | CImp_DrawDlg |
m_iRadioDS | CImp_DrawDlg |
m_iWasText | CImp_DrawDlg |
m_lLastX | CImp_DrawDlg |
m_lLastY | CImp_DrawDlg |
m_msgOut | CImp_DrawDlg |
m_pHandler | CImp_DrawDlg | [protected]
m_qevent | CImp_DrawDlg |
m_qFriend | CImp_DrawDlg |
m_queue | CImp_DrawDlg |
m_strRemoteComputerName | CImp_DrawDlg |
m_vtFriendName | CImp_DrawDlg |
m_vtguidDraw | CImp_DrawDlg |
m_vtLogin | CImp_DrawDlg |
OnButtonAttach() | CImp_DrawDlg | [protected]
OnConnect() | CImp_DrawDlg | [protected]
OnInitDialog() | CImp_DrawDlg | [protected, virtual]
OnPaint() | CImp_DrawDlg | [protected]
OnQueryDragIcon() | CImp_DrawDlg | [protected]
OpenPrivateReceiveQueue() | CImp_DrawDlg | [protected]
OpenReceiveQueue() | CImp_DrawDlg | [protected]
SendKeystroke(UINT uChar) | CImp_DrawDlg |
SendMouseMovement(LINE line) | CImp_DrawDlg |
~CImp_DrawDlg() | CImp_DrawDlg |
Generated on Wed Nov 13 2024 16:56:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/land.h Source File

  • SysMgmt
  • MMC
  • Menubtn

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035 public:
00036     // virtual functions go here (for MMCN_*)
00037
00038 private:
00039     enum { IDM_NEW_LAND = 2 };
00040
00041     // {2974380E-4C4B-11d2-89D8-000021473128}
00042     static const GUID thisGuid;
00043 };
00044
00045 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFileIO Member List

This is the complete list of members for CFileIO, including all inherited members.
CFileIO(void) | CFileIO |
DeleteRow(DBCOUNTITEM ulRow) | CFileIO |
Fetch(DBCOUNTITEM ulRow) | CFileIO |
FillBinding(DBORDINAL cColumn, LPTSTR pvCopy) | CFileIO | [private]
fInit(LPTSTR pstrFileName) | CFileIO |
GatherColumnInfo() | CFileIO |
GenerateFileInfo() | CFileIO | [private]
GetColInfo() | CFileIO | [inline]
GetColNameHeap() | CFileIO | [inline]
GetColNameHeapSize() | CFileIO | [inline]
GetColumnCnt() | CFileIO | [inline]
GetColumnData(DBORDINAL cCols, ROWBUFF *pRowBuff) | CFileIO |
GetColumnName(DBORDINAL cCols, LPTSTR *pptstrName=NULL) | CFileIO |
GetDataTypes(DBORDINAL cCols, SWORD *pswType, UDWORD *pudwColDef, BOOL *pfSigned) | CFileIO |
GetRowCnt() | CFileIO | [inline]
GetRowSize() | CFileIO | [inline]
IsDeleted(DBCOUNTITEM ulRow) | CFileIO |
IsReadOnly() | CFileIO | [inline]
m_cbHeapUsed | CFileIO | [private]
m_cbRowSize | CFileIO | [private]
m_cColumns | CFileIO | [private]
m_cRows | CFileIO | [private]
m_FileIdx | CFileIO | [private]
m_FileReadOnly | CFileIO | [private]
m_pbHeap | CFileIO | [private]
m_pColNames | CFileIO | [private]
m_pvInput | CFileIO | [private]
m_rgdbcolinfo | CFileIO | [private]
m_rgdwDataOffsets | CFileIO | [private]
m_rgfSigned | CFileIO | [private]
m_rgpColNames | CFileIO | [private]
m_rgpColumnData | CFileIO | [private]
m_rgsdwMaxLen | CFileIO | [private]
m_rgswColType | CFileIO | [private]
m_rgudwColSize | CFileIO | [private]
m_ulDataTypeOffset | CFileIO | [private]
ParseColumnNames(LPTSTR ptstrInput) | CFileIO | [private]
ParseDataTypes() | CFileIO | [private]
ParseRowValues() | CFileIO |
SetColumnBind(DBORDINAL cCols, PCOLUMNDATA pColumn) | CFileIO |
UpdateRow(DBCOUNTITEM ulRow, BYTE *pbProvRow, UPDTYPE eUpdateType) | CFileIO |
~CFileIO(void) | CFileIO |
Generated on Wed Nov 13 2024 16:56:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CServiceCallback Member List

This is the complete list of members for CServiceCallback, including all inherited members.
Create() | CServiceCallback | [static]
CServiceCallback() | CServiceCallback | [inline]
m_pGenericUCPDlg | CServiceCallback | [private]
ServiceInstanceDied(IUPnPService *pus) | CServiceCallback |
SetDialogPointer(CGenericUCPDlg *pDialog) | CServiceCallback |
StateVariableChanged(IUPnPService *pus, LPCWSTR pcwszStateVarName, VARIANT varValue) | CServiceCallback |
~CServiceCallback() | CServiceCallback | [inline]
Generated on Wed Nov 13 2024 16:57:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/guidbind/vc/ADSIhelpers.h Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • guidbind
  • vc

ADSIhelpers.h

Go to the documentation of this file.
00001
00002 /*
00003
00004     ADSIHelpers.h
00005
00006     General helper rountines for Debugging ADSI applications
00007
00008
00009 */
00010
00011
00012 #ifndef __ADSIHELLPERS_H
00013 #define __ADSIHELLPERS_H
00014
00015 #include <activeds.h>
00016 #include <adsiid.h>
00017
00018
00019 // Function declarations
00020 void      CheckHRESULT(HRESULT hr, const char *pszCause);
00021 const char *  GetVariantStyle(VARTYPE vt);
00022 HRESULT     GetIADsPropertyValueAsBSTR(BSTR * pbsRet,IADsPropertyValue * pAdsPV);
00023 WCHAR*          CrackADError(HRESULT hResult);
00024 void            ADErrMsgBox(HRESULT passedhr);
00025 const char *    QueryAllInterfaces(IUnknown * pUnk);
00026 char *          GetCharFromGUID(GUID idtofind);
00027
00028
00029 // Macros
00030
00031 // Simple Macro to simplyfy reading a bitflag
00032 #define HAS_BIT_STYLE(val, style) \
00033 ((val & style) == style)
00034
00035
00036 // Inline functions
00037
00038 // Will display ADSI or COM error messages
00039 // when passed a BAD Hresult
00040 inline void CheckADHRESULT(HRESULT hr)
00041 {
00042     if (FAILED(hr))
00043         ADErrMsgBox(hr);
00044
00045 }
00046
00047 #endif
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAlterIndexDlg Member List

This is the complete list of members for CAlterIndexDlg, including all inherited members.
AlterIndex(HWND hWndParent, DBID **ppTableID, DBID **ppIndexID, DBID **ppNewIndexID, BOOL *pfUseIndexProps) | CAlterIndexDlg |
CAlterIndexDlg(CMDIChild *pCMDIChild) | CAlterIndexDlg |
CDialogLite(UINT uIDD=0) | CDialogLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CRowsetViewerDlg(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRowsetViewerDlg |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetOptions() | CRowsetViewerDlg | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_CPropSets | CAlterIndexDlg |
m_editIndexName | CAlterIndexDlg |
m_editNewIndexName | CAlterIndexDlg |
m_editTableName | CAlterIndexDlg |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCMainWindow | CRowsetViewerDlg |
m_pCMDIChild | CRowsetViewerDlg |
m_pfUseIndexProps | CAlterIndexDlg |
m_ppIndexID | CAlterIndexDlg |
m_ppNewIndexID | CAlterIndexDlg |
m_ppTableID | CAlterIndexDlg |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnCancel() | CDialogLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CAlterIndexDlg | [virtual]
CDialogLite::OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CAlterIndexDlg | [virtual]
CDialogLite::OnInitDialog() | CDialogLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CAlterIndexDlg | [virtual]
CDialogLite::OnOK() | CDialogLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CAlterIndexDlg() | CAlterIndexDlg | [virtual]
~CDialogLite() | CDialogLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:55:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Dog/iDog.Cpp Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Dog

iDog.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include <windows.h>
00018 #include "idog_i.c"
00019 #include "cdog.h"
00020
00021 // {F40B88C1-D534-11d1-9D01-0060081982D5}
00022 //static const IID IID_IDog =
00023 //{ 0xf40b88c1, 0xd534, 0x11d1, { 0x9d, 0x1, 0x0, 0x60, 0x8, 0x19, 0x82, 0xd5 } };
00024
00025 // {F40B88C2-D534-11d1-9D01-0060081982D5}
00026 //static const CLSID CLSID_Dog =
00027 //{ 0xf40b88c2, 0xd534, 0x11d1, { 0x9d, 0x1, 0x0, 0x60, 0x8, 0x19, 0x82, 0xd5 } };
00028
00029 // IUnknown
00030 STDMETHODIMP CDog::QueryInterface(REFIID iid, void FAR* FAR* ppv)
00031 {
00032     *ppv = NULL;
00033
00034     if (iid == IID_IUnknown || iid == IID_IDog)
00035         *ppv = (IDog*)this;
00036     else
00037         return ResultFromScode(E_NOINTERFACE);
00038
00039     AddRef();
00040     return NOERROR;
00041 }
00042
00043 STDMETHODIMP_(ULONG) CDog::AddRef()
00044 {
00045     return InterlockedIncrement(&m_cRef);
00046 }
00047
00048 STDMETHODIMP_(ULONG) CDog::Release()
00049 {
00050     if(InterlockedDecrement(&m_cRef) == 0)
00051     {
00052         delete this;
00053         return 0;
00054     }
00055     return m_cRef;
00056 }
00057
00058 // IDog
00059 STDMETHODIMP CDog::Bark()
00060 {
00061   OutputDebugString("Bark!");
00062   return S_OK;
00063 }
00064
00065 STDMETHODIMP CDog::Scratch()
00066 {
00067   OutputDebugString("Scratch, scratch...");
00068   return S_OK;
00069 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/enumformatetc.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

enumformatetc.h

Go to the documentation of this file.
00001 /*
00002  * EnumFormatEtc.h
00003  * Data Object Chapter 10
00004  *
00005  * Standard implementation of a FORMATETC enumerator with the
00006  * IEnumFORMATETC interface that will generally not need
00007  * modification.
00008  *
00009  * Copyright (c) 1993 - 2001 Microsoft Corporation, All Rights Reserved
00010  *
00011  */
00012
00013 #if !defined(_IAS_ENUM_FORMAT_ETC_H_)
00014 #define _IAS_ENUM_FORMAT_ETC_H_
00015
00016 #include "Globals.h"
00017
00018 /*
00019  * IEnumFORMATETC object that is created from
00020  * IDataObject::EnumFormatEtc.  This object lives on its own.
00021  */
00022
00023 class CEnumFormatEtc : public IEnumFORMATETC
00024     {
00025     private:
00026         ULONG           m_cRef;         //Object reference count
00027         ULONG           m_iCur;         //Current element.
00028         ULONG           m_cfe;          //Number of FORMATETCs in us
00029         LPFORMATETC     m_prgfe;        //Source of FORMATETCs
00030
00031     public:
00032         CEnumFormatEtc(ULONG, LPFORMATETC);
00033         ~CEnumFormatEtc(void);
00034
00035         //IUnknown members
00036         STDMETHODIMP         QueryInterface(REFIID, VOID **);
00037         STDMETHODIMP_(ULONG) AddRef(void);
00038         STDMETHODIMP_(ULONG) Release(void);
00039
00040         //IEnumFORMATETC members
00041         STDMETHODIMP Next(ULONG, LPFORMATETC, ULONG *);
00042         STDMETHODIMP Skip(ULONG);
00043         STDMETHODIMP Reset(void);
00044         STDMETHODIMP Clone(IEnumFORMATETC **);
00045     };
00046
00047
00048 typedef CEnumFormatEtc *PCEnumFormatEtc;
00049
00050
00051 #endif // _IAS_ENUM_FORMAT_ETC_H_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/mspaddr.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

mspaddr.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1998-1999  Microsoft Corporation
00004
00005 Module Name:
00006
00007     mspaddr.cpp
00008
00009 Abstract:
00010
00011     This module contains implementation of CMSPAddress.
00012
00013 --*/
00014
00015 #include "precomp.h"
00016 #pragma hdrstop
00017
00018
00019
00020 ///////////////////////////////////////////////////////////////////////////////
00021 //
00022 // AllocateEventItem and FreeEventItem are MSPEVENTITEM allocation routines.
00023 // they are be used to allocate and deallocate MSPEVENTITEM structures
00024 //
00025 ///////////////////////////////////////////////////////////////////////////////
00026
00027 //////////////////////////////////////////////////////////////////////////////
00028 //
00029 //  AllocateEventItem
00030 //
00031 //  allocate an MSPEVENTITEM. Since the structure is of variable size, the
00032 //  number of extra bytes to be allocated (in addition to the size of
00033 //  MSPEVENTITEM) is optionally passed as the function's argument
00034 //
00035 //  the function returns a pointer to the newly created structure or NULL in
00036 //  the case of failure. the caller can then call GetLastError to get more
00037 //  information on the failure
00038 //
00039
00040 MSPEVENTITEM *AllocateEventItem(SIZE_T nExtraBytes)
00041 {
00042
00043     LOG((MSP_TRACE, "AllocateEventItem - enter, extra bytes = 0x%p", nExtraBytes));
00044
00045
00046     //
00047     // if the caller passes us too big a number, fail.
00048     //
00049
00050     if ( ( MAXULONG_PTR - sizeof(MSPEVENTITEM) )  < nExtraBytes )
00051     {
00052         SetLastError(ERROR_OUTOFMEMORY);
00053
00054         LOG((MSP_ERROR,
00055             "AllocateEventItem - the caller requested an unreasonably large memory block"));
00056
00057         return NULL;
00058     }
00059
00060
00061     //
00062     // allocate on the process' heap. get the current process' heap handle.
00063     //
00064
00065     HANDLE hHeapHandle = GetProcessHeap();
00066
00067     if (NULL == hHeapHandle)
00068     {
00069
00070         //
00071         // failed to get process's heap. nothing much we can do here.
00072         // this will cause a leak.
00073         //
00074
00075         LOG((MSP_ERROR,
00076             "AllocateEventItem - failed to get current process heap. LastError [%ld]",
00077             GetLastError()));
00078
00079         return NULL;
00080     }
00081
00082
00083     //
00084     // calculate the number of bytes to allocate
00085     //
00086
00087     SIZE_T nTotalAllocationSize = sizeof(MSPEVENTITEM) + nExtraBytes;
00088
00089
00090     //
00091     // attempt to allocate memory and return result of the allocation
00092     //
00093
00094     MSPEVENTITEM *pMspEventItem =
00095          (MSPEVENTITEM *)HeapAlloc(hHeapHandle, 0, nTotalAllocationSize);
00096
00097
00098     if (NULL == pMspEventItem)
00099     {
00100
00101         LOG((MSP_ERROR,
00102             "AllocateEventItem - failed to allocate [0x%p] bytes. Heap Handle [%p] LastError [%ld]",
00103             nTotalAllocationSize, hHeapHandle, GetLastError()));
00104     }
00105     else
00106     {
00107
00108         LOG((MSP_TRACE, "AllocateEventItem - exit. pMspEventItem = [%p]", pMspEventItem));
00109     }
00110
00111     return pMspEventItem;
00112 }
00113
00114
00115 //////////////////////////////////////////////////////////////////////////////
00116 //
00117 //  FreeEventItem
00118 //
00119 //  deallocate the MSPEVENTITEM passed as an argument. The memory must have
00120 //  been previously allocated by AllocateEventItem.
00121 //
00122 //  the function eturns FALSE in case of failure. The caller can use
00123 //  GetLastError to get a more specific error code.
00124 //
00125
00126 BOOL FreeEventItem(MSPEVENTITEM *pEventItemToBeFreed)
00127 {
00128
00129     LOG((MSP_TRACE, "FreeEventItem - enter. pEventItemToBeFreed = [%p]",
00130         pEventItemToBeFreed));
00131
00132
00133     //
00134     // always allow freeing NULL
00135     //
00136
00137     if (NULL == pEventItemToBeFreed)
00138     {
00139
00140         LOG((MSP_TRACE, "FreeEventItem - finish. NULL -- nothing to do"));
00141
00142         return TRUE;
00143     }
00144
00145     //
00146     // the event item should have been allocated on the process' heap.
00147     // get the current process' heap hadle.
00148     //
00149
00150     HANDLE hHeapHandle = GetProcessHeap();
00151
00152     if (NULL == hHeapHandle)
00153     {
00154
00155         //
00156         // failed to get process's heap. nothing much we can do here.
00157         // this will cause a leak.
00158         //
00159
00160         LOG((MSP_ERROR,
00161             "FreeEventItem - failed to get current process heap. LastError = %ld",
00162             GetLastError()));
00163
00164         return FALSE;
00165     }
00166
00167
00168     //
00169     // attempt to free memory and return result of the operation
00170     //
00171
00172     BOOL bFreeSuccess = HeapFree( hHeapHandle, 0, pEventItemToBeFreed );
00173
00174     if (bFreeSuccess)
00175     {
00176          LOG((MSP_TRACE, "FreeEventItem - exit."));
00177     }
00178     else
00179     {
00180          LOG((MSP_ERROR,
00181              "FreeEventItem - failed to free. Heap Handle [%p] LastError = %ld",
00182              hHeapHandle, GetLastError()));
00183     }
00184
00185
00186     return bFreeSuccess;
00187 }
00188
00189
00190 //////////////////////////////////////////////////////////////////////////////
00191
00192
00193 HRESULT CPlugTerminalClassInfo::FinalConstruct(void)
00194 {
00195     LOG((MSP_TRACE, "CPlugTerminalClassInfo::FinalConstruct - enter"));
00196
00197     HRESULT hr = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
00198                                                 & m_pFTM );
00199
00200     if ( FAILED(hr) )
00201     {
00202         LOG((MSP_ERROR, "CPlugTerminalClassInfo::FinalConstruct - "
00203             "create FTM returned 0x%08x; exit", hr));
00204
00205         return hr;
00206     }
00207
00208     LOG((MSP_TRACE, "CPlugTerminalClassInfo::FinalConstruct - exit S_OK"));
00209
00210     return S_OK;
00211
00212 }
00213
00214 //////////////////////////////////////////////////////////////////////////////
00215
00216 STDMETHODIMP CPlugTerminalClassInfo::get_Name(
00217     /*[out, retval]*/ BSTR*     pName
00218     )
00219 {
00220     //
00221     // Critical section
00222     //
00223
00224     CLock lock(m_CritSect);
00225
00226     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Name - enter"));
00227
00228     //
00229     // Validates argument
00230     //
00231
00232     if( MSPB_IsBadWritePtr( pName, sizeof(BSTR)) )
00233     {
00234         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Name exit -"
00235             "pName invalid, returns E_POINTER"));
00236         return E_POINTER;
00237     }
00238
00239     //
00240     // Validates the name
00241     //
00242
00243     if( IsBadStringPtr( m_bstrName, (UINT)-1) )
00244     {
00245         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Name exit -"
00246             "m_bstrName invalid, returns E_UNEXPECTED"));
00247         return E_UNEXPECTED;
00248     }
00249
00250     //
00251     // Return the name
00252     //
00253
00254     *pName = SysAllocString( m_bstrName );
00255
00256     //
00257     // Validates SysAllocString
00258     //
00259
00260     if( *pName == NULL )
00261     {
00262         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Name exit -"
00263             "SysAllocString failed, returns E_OUTOFMEMORY"));
00264         return E_OUTOFMEMORY;
00265     }
00266
00267     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Name - exit"));
00268     return S_OK;
00269 }
00270
00271
00272 //////////////////////////////////////////////////////////////////////////////
00273
00274
00275 STDMETHODIMP CPlugTerminalClassInfo::put_Name(
00276     /*[in]*/    BSTR            bstrName
00277     )
00278 {
00279     //
00280     // Critical section
00281     //
00282
00283     CLock lock(m_CritSect);
00284
00285     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_Name - enter"));
00286
00287     //
00288     // Validates argument
00289     //
00290
00291     if(IsBadStringPtr( bstrName, (UINT)-1) )
00292     {
00293         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_Name exit -"
00294             "bstrName invalid, returns E_POINTER"));
00295         return E_POINTER;
00296     }
00297
00298     //
00299     // Clean-up the old name
00300     //
00301
00302     if(!IsBadStringPtr( m_bstrName, (UINT)-1) )
00303     {
00304         SysFreeString( m_bstrName );
00305         m_bstrName = NULL;
00306     }
00307
00308     //
00309     // Set the new name
00310     //
00311
00312     m_bstrName = SysAllocString( bstrName );
00313
00314     //
00315     // Validates SysAllocString
00316     //
00317
00318     if( NULL == m_bstrName )
00319     {
00320         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_Name exit -"
00321             "SysAllocString failed, returns E_OUTOFMEMORY"));
00322         return E_OUTOFMEMORY;
00323     }
00324
00325     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_Name - exit"));
00326     return S_OK;
00327 }
00328
00329
00330 //////////////////////////////////////////////////////////////////////////////
00331
00332
00333 STDMETHODIMP CPlugTerminalClassInfo::get_Company(
00334     /*[out, retval]*/ BSTR*     pCompany
00335     )
00336 {
00337     //
00338     // Critical section
00339     //
00340
00341     CLock lock(m_CritSect);
00342
00343     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Company - enter"));
00344
00345     //
00346     // Validates argument
00347     //
00348
00349     if( MSPB_IsBadWritePtr( pCompany, sizeof(BSTR)) )
00350     {
00351         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Company exit -"
00352             "pCompany invalid, returns E_POINTER"));
00353         return E_POINTER;
00354     }
00355
00356     //
00357     // Validates the name
00358     //
00359
00360     if( IsBadStringPtr( m_bstrCompany, (UINT)-1) )
00361     {
00362         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Company exit -"
00363             "m_bstrName invalid, returns E_UNEXPECTED"));
00364         return E_UNEXPECTED;
00365     }
00366
00367     //
00368     // Return the name
00369     //
00370
00371     *pCompany = SysAllocString( m_bstrCompany );
00372
00373     //
00374     // Validates SysAllocString
00375     //
00376
00377     if( *pCompany == NULL )
00378     {
00379         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Company exit -"
00380             "SysAllocString failed, returns E_OUTOFMEMORY"));
00381         return E_OUTOFMEMORY;
00382     }
00383
00384     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Company - exit"));
00385     return S_OK;
00386 }
00387
00388
00389 //////////////////////////////////////////////////////////////////////////////
00390
00391
00392 STDMETHODIMP CPlugTerminalClassInfo::put_Company(
00393     /*[in]*/    BSTR            bstrCompany
00394     )
00395 {
00396     //
00397     // Critical section
00398     //
00399
00400     CLock lock(m_CritSect);
00401
00402     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_Company - enter"));
00403
00404     //
00405     // Validates argument
00406     //
00407
00408     if(IsBadStringPtr( bstrCompany, (UINT)-1) )
00409     {
00410         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_Company exit -"
00411             "bstrCompany invalid, returns E_POINTER"));
00412         return E_POINTER;
00413     }
00414
00415     //
00416     // Clean-up the old name
00417     //
00418
00419     if(!IsBadStringPtr( m_bstrCompany, (UINT)-1) )
00420     {
00421         SysFreeString( m_bstrCompany );
00422         m_bstrCompany = NULL;
00423     }
00424
00425     //
00426     // Set the new name
00427     //
00428
00429     m_bstrCompany = SysAllocString( bstrCompany );
00430
00431     //
00432     // Validates SysAllocString
00433     //
00434
00435     if( NULL == m_bstrCompany )
00436     {
00437         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_Company exit -"
00438             "SysAllocString failed, returns E_OUTOFMEMORY"));
00439         return E_OUTOFMEMORY;
00440     }
00441
00442     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_Company - exit"));
00443     return S_OK;
00444 }
00445
00446
00447 //////////////////////////////////////////////////////////////////////////////
00448
00449
00450 STDMETHODIMP CPlugTerminalClassInfo::get_Version(
00451     /*[out, retval]*/ BSTR*     pVersion
00452     )
00453 {
00454     //
00455     // Critical section
00456     //
00457
00458     CLock lock(m_CritSect);
00459
00460     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Version - enter"));
00461
00462     //
00463     // Validates argument
00464     //
00465
00466     if( MSPB_IsBadWritePtr( pVersion, sizeof(BSTR)) )
00467     {
00468         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Version exit -"
00469             "pVersion invalid, returns E_POINTER"));
00470         return E_POINTER;
00471     }
00472
00473     //
00474     // Validates the name
00475     //
00476
00477     if( IsBadStringPtr( m_bstrVersion, (UINT)-1) )
00478     {
00479         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Version exit -"
00480             "m_bstrName invalid, returns E_UNEXPECTED"));
00481         return E_UNEXPECTED;
00482     }
00483
00484     //
00485     // Return the name
00486     //
00487
00488     *pVersion = SysAllocString( m_bstrVersion );
00489
00490     //
00491     // Validates SysAllocString
00492     //
00493
00494     if( *pVersion == NULL )
00495     {
00496         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Version exit -"
00497             "SysAllocString failed, returns E_OUTOFMEMORY"));
00498         return E_OUTOFMEMORY;
00499     }
00500
00501     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Version - exit"));
00502     return S_OK;
00503 }
00504
00505
00506 //////////////////////////////////////////////////////////////////////////////
00507
00508
00509 STDMETHODIMP CPlugTerminalClassInfo::put_Version(
00510     /*[in]*/    BSTR            bstrVersion
00511     )
00512 {
00513     //
00514     // Critical section
00515     //
00516
00517     CLock lock(m_CritSect);
00518
00519     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_Version - enter"));
00520
00521     //
00522     // Validates argument
00523     //
00524
00525     if(IsBadStringPtr( bstrVersion, (UINT)-1) )
00526     {
00527         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_Version exit -"
00528             "bstrVersion invalid, returns E_POINTER"));
00529         return E_POINTER;
00530     }
00531
00532     //
00533     // Clean-up the old name
00534     //
00535
00536     if(!IsBadStringPtr( m_bstrVersion, (UINT)-1) )
00537     {
00538         SysFreeString( m_bstrVersion );
00539         m_bstrVersion = NULL;
00540     }
00541
00542     //
00543     // Set the new name
00544     //
00545
00546     m_bstrVersion = SysAllocString( bstrVersion );
00547
00548     //
00549     // Validates SysAllocString
00550     //
00551
00552     if( NULL == m_bstrVersion )
00553     {
00554         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_Version exit -"
00555             "SysAllocString failed, returns E_OUTOFMEMORY"));
00556         return E_OUTOFMEMORY;
00557     }
00558
00559     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_Version - exit"));
00560     return S_OK;
00561 }
00562
00563
00564 //////////////////////////////////////////////////////////////////////////////
00565
00566
00567 STDMETHODIMP CPlugTerminalClassInfo::get_TerminalClass(
00568     /*[out, retval]*/ BSTR*     pTerminalClass
00569     )
00570 {
00571     //
00572     // Critical section
00573     //
00574
00575     CLock lock(m_CritSect);
00576
00577     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_TerminalClass - enter"));
00578
00579     //
00580     // Validates argument
00581     //
00582
00583     if( MSPB_IsBadWritePtr( pTerminalClass, sizeof(BSTR)) )
00584     {
00585         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_TerminalClass exit -"
00586             "pVersion invalid, returns E_POINTER"));
00587         return E_POINTER;
00588     }
00589
00590     //
00591     // Validates the name
00592     //
00593
00594     if( IsBadStringPtr( m_bstrTerminalClass, (UINT)-1) )
00595     {
00596         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_TerminalClass exit -"
00597             "m_bstrName invalid, returns E_UNEXPECTED"));
00598         return E_UNEXPECTED;
00599     }
00600
00601     //
00602     // Return the name
00603     //
00604
00605     *pTerminalClass = SysAllocString( m_bstrTerminalClass );
00606
00607     //
00608     // Validates SysAllocString
00609     //
00610
00611     if( *pTerminalClass == NULL )
00612     {
00613         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_TerminalClass exit -"
00614             "SysAllocString failed, returns E_OUTOFMEMORY"));
00615         return E_OUTOFMEMORY;
00616     }
00617
00618     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_TerminalClass - exit"));
00619     return S_OK;
00620 }
00621
00622
00623 //////////////////////////////////////////////////////////////////////////////
00624
00625
00626 STDMETHODIMP CPlugTerminalClassInfo::put_TerminalClass(
00627     /*[in]*/    BSTR            bstrTerminalClass
00628     )
00629 {
00630     //
00631     // Critical section
00632     //
00633
00634     CLock lock(m_CritSect);
00635
00636     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_TerminalClass - enter"));
00637
00638     //
00639     // Validates argument
00640     //
00641
00642     if(IsBadStringPtr( bstrTerminalClass, (UINT)-1) )
00643     {
00644         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_TerminalClass exit -"
00645             "bstrTerminalClass invalid, returns E_POINTER"));
00646         return E_POINTER;
00647     }
00648
00649     //
00650     // Is a real CLSID?
00651     //
00652
00653     CLSID clsid;
00654     HRESULT hr = CLSIDFromString(bstrTerminalClass, &clsid);
00655     if( FAILED(hr) )
00656     {
00657         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_TerminalClass exit -"
00658             "bstrTerminalClass is not a CLSID, returns E_INVALIDARG"));
00659         return E_INVALIDARG;
00660     }
00661
00662
00663     //
00664     // Clean-up the old name
00665     //
00666
00667     if(!IsBadStringPtr( m_bstrTerminalClass, (UINT)-1) )
00668     {
00669         SysFreeString( m_bstrTerminalClass );
00670         m_bstrTerminalClass = NULL;
00671     }
00672
00673     //
00674     // Set the new name
00675     //
00676
00677     m_bstrTerminalClass = SysAllocString( bstrTerminalClass );
00678
00679     //
00680     // Validates SysAllocString
00681     //
00682
00683     if( NULL == m_bstrTerminalClass )
00684     {
00685         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_TerminalClass exit -"
00686             "SysAllocString failed, returns E_OUTOFMEMORY"));
00687         return E_OUTOFMEMORY;
00688     }
00689
00690     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_TerminalClass - exit"));
00691     return S_OK;
00692 }
00693
00694
00695 //////////////////////////////////////////////////////////////////////////////
00696
00697
00698 STDMETHODIMP CPlugTerminalClassInfo::get_CLSID(
00699     /*[out, retval]*/ BSTR*     pCLSID
00700     )
00701 {
00702     //
00703     // Critical section
00704     //
00705
00706     CLock lock(m_CritSect);
00707
00708     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_CLSID - enter"));
00709
00710     //
00711     // Validates argument
00712     //
00713
00714     if( MSPB_IsBadWritePtr( pCLSID, sizeof(BSTR)) )
00715     {
00716         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_CLSID exit -"
00717             "pVersion invalid, returns E_POINTER"));
00718         return E_POINTER;
00719     }
00720
00721     //
00722     // Validates the name
00723     //
00724
00725     if( IsBadStringPtr( m_bstrCLSID, (UINT)-1) )
00726     {
00727         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_CLSID exit -"
00728             "m_bstrName invalid, returns E_UNEXPECTED"));
00729         return E_UNEXPECTED;
00730     }
00731
00732     //
00733     // Return the name
00734     //
00735
00736     *pCLSID = SysAllocString( m_bstrCLSID );
00737
00738     //
00739     // Validates SysAllocString
00740     //
00741
00742     if( *pCLSID == NULL )
00743     {
00744         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_CLSID exit -"
00745             "SysAllocString failed, returns E_OUTOFMEMORY"));
00746         return E_OUTOFMEMORY;
00747     }
00748
00749     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_CLSID - exit"));
00750     return S_OK;
00751 }
00752
00753
00754 //////////////////////////////////////////////////////////////////////////////
00755
00756
00757 STDMETHODIMP CPlugTerminalClassInfo::put_CLSID(
00758     /*[in]*/    BSTR            bstrCLSID
00759     )
00760 {
00761     //
00762     // Critical section
00763     //
00764
00765     CLock lock(m_CritSect);
00766
00767     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_CLSID - enter"));
00768
00769     //
00770     // Validates argument
00771     //
00772
00773     if(IsBadStringPtr( bstrCLSID, (UINT)-1) )
00774     {
00775         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_CLSID exit -"
00776             "bstrCLSID invalid, returns E_POINTER"));
00777         return E_POINTER;
00778     }
00779
00780     //
00781     // Is a real CLSID?
00782     //
00783
00784     CLSID clsid;
00785     HRESULT hr = CLSIDFromString(bstrCLSID, &clsid);
00786     if( FAILED(hr) )
00787     {
00788         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_CLSID exit -"
00789             "bstrCLSID is not a CLSID, returns E_INVALIDARG"));
00790         return E_INVALIDARG;
00791     }
00792
00793
00794     //
00795     // Clean-up the old name
00796     //
00797
00798     if(!IsBadStringPtr( m_bstrCLSID, (UINT)-1) )
00799     {
00800         SysFreeString( m_bstrCLSID );
00801         m_bstrCLSID = NULL;
00802     }
00803
00804     //
00805     // Set the new name
00806     //
00807
00808     m_bstrCLSID = SysAllocString( bstrCLSID );
00809
00810     //
00811     // Validates SysAllocString
00812     //
00813
00814     if( NULL == m_bstrCLSID )
00815     {
00816         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_CLSID exit -"
00817             "SysAllocString failed, returns E_OUTOFMEMORY"));
00818         return E_OUTOFMEMORY;
00819     }
00820
00821     LOG((MSP_TRACE, "CPlugTerminalClassInfo::put_CLSID - exit"));
00822     return S_OK;
00823 }
00824
00825
00826 //////////////////////////////////////////////////////////////////////////////
00827
00828
00829 STDMETHODIMP CPlugTerminalClassInfo::get_Direction(
00830     /*[out, retval]*/ TERMINAL_DIRECTION*  pDirection
00831     )
00832 {
00833     //
00834     // Critical section
00835     //
00836
00837     CLock lock(m_CritSect);
00838
00839     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Direction - enter"));
00840
00841     //
00842     // Validates argument
00843     //
00844
00845     if( MSPB_IsBadWritePtr( pDirection, sizeof(long)) )
00846     {
00847         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_Direction exit -"
00848             "pDirection invalid, returns E_POINTER"));
00849         return E_POINTER;
00850     }
00851
00852     //
00853     // Return the name
00854     //
00855
00856     *pDirection = m_Direction;
00857
00858     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_Direction - exit"));
00859     return S_OK;
00860 }
00861
00862
00863 //////////////////////////////////////////////////////////////////////////////
00864
00865
00866 STDMETHODIMP CPlugTerminalClassInfo::put_Direction(
00867     /*[in]*/    TERMINAL_DIRECTION  nDirection
00868     )
00869 {
00870     //
00871     // Critical section
00872     //
00873
00874     CLock lock(m_CritSect);
00875
00876     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_Direction - enter"));
00877
00878     //
00879     // Set the new name
00880     //
00881
00882     m_Direction = nDirection;
00883
00884     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_Direction - exit"));
00885     return S_OK;
00886 }
00887
00888
00889 //////////////////////////////////////////////////////////////////////////////
00890
00891
00892 STDMETHODIMP CPlugTerminalClassInfo::get_MediaTypes(
00893     /*[out, retval]*/ long*     pMediaTypes
00894     )
00895 {
00896     //
00897     // Critical section
00898     //
00899
00900     CLock lock(m_CritSect);
00901
00902     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_MediaTypes - enter"));
00903
00904     //
00905     // Validates argument
00906     //
00907
00908     if( MSPB_IsBadWritePtr( pMediaTypes, sizeof(long)) )
00909     {
00910         LOG((MSP_ERROR, "CPlugTerminalClassInfo::get_MediaTypes exit -"
00911             "pMediaTypes invalid, returns E_POINTER"));
00912         return E_POINTER;
00913     }
00914
00915     //
00916     // Return the name
00917     //
00918
00919     *pMediaTypes = m_lMediaType;
00920
00921     LOG((MSP_TRACE, "CPlugTerminalClassInfo::get_MediaTypes - exit"));
00922     return S_OK;
00923 }
00924
00925
00926 //////////////////////////////////////////////////////////////////////////////
00927
00928
00929 STDMETHODIMP CPlugTerminalClassInfo::put_MediaTypes(
00930     /*[in]*/    long            nMediaTypes
00931     )
00932 {
00933     //
00934     // Critical section
00935     //
00936
00937     CLock lock(m_CritSect);
00938
00939     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_MediaTypes - enter"));
00940
00941     //
00942     // Set the new name
00943     //
00944
00945     m_lMediaType = nMediaTypes;
00946
00947     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_MediaTypes - exit"));
00948     return S_OK;
00949 }
00950
00951 //////////////////////////////////////////////////////////////////////////////
00952
00953
00954 HRESULT CPlugTerminalSuperclassInfo::FinalConstruct(void)
00955 {
00956     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::FinalConstruct - enter"));
00957
00958     HRESULT hr = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
00959                                                 & m_pFTM );
00960
00961     if ( FAILED(hr) )
00962     {
00963         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::FinalConstruct - "
00964             "create FTM returned 0x%08x; exit", hr));
00965
00966         return hr;
00967     }
00968
00969     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::FinalConstruct - exit S_OK"));
00970
00971     return S_OK;
00972
00973 }
00974
00975 //////////////////////////////////////////////////////////////////////////////
00976
00977 STDMETHODIMP CPlugTerminalSuperclassInfo::get_Name(
00978     /*[out, retval]*/ BSTR*          pName
00979     )
00980 {
00981     //
00982     // Critical section
00983     //
00984
00985     CLock lock(m_CritSect);
00986
00987     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::get_Name - enter"));
00988
00989     //
00990     // Validates argument
00991     //
00992
00993     if( MSPB_IsBadWritePtr( pName, sizeof(BSTR)) )
00994     {
00995         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::get_Name exit -"
00996             "pVersion invalid, returns E_POINTER"));
00997         return E_POINTER;
00998     }
00999
01000     //
01001     // Validates the name
01002     //
01003
01004     if( IsBadStringPtr( m_bstrName, (UINT)-1) )
01005     {
01006         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::get_Name exit -"
01007             "m_bstrName invalid, returns E_UNEXPECTED"));
01008         return E_UNEXPECTED;
01009     }
01010
01011     //
01012     // Return the name
01013     //
01014
01015     *pName = SysAllocString( m_bstrName );
01016
01017     //
01018     // Validates SysAllocString
01019     //
01020
01021     if( *pName == NULL )
01022     {
01023         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::get_Name exit -"
01024             "SysAllocString failed, returns E_OUTOFMEMORY"));
01025         return E_OUTOFMEMORY;
01026     }
01027
01028     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::get_Name - exit"));
01029     return S_OK;
01030 }
01031
01032
01033 //////////////////////////////////////////////////////////////////////////////
01034
01035 STDMETHODIMP CPlugTerminalSuperclassInfo::put_Name(
01036     /*[in]*/          BSTR            bstrName
01037     )
01038 {
01039     //
01040     // Critical section
01041     //
01042
01043     CLock lock(m_CritSect);
01044
01045     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_Name - enter"));
01046
01047     //
01048     // Validates argument
01049     //
01050
01051     if(IsBadStringPtr( bstrName, (UINT)-1) )
01052     {
01053         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::put_Name exit -"
01054             "bstrName invalid, returns E_POINTER"));
01055         return E_POINTER;
01056     }
01057
01058     //
01059     // Clean-up the old name
01060     //
01061
01062     if(!IsBadStringPtr( m_bstrName, (UINT)-1) )
01063     {
01064         SysFreeString( m_bstrName );
01065         m_bstrName = NULL;
01066     }
01067
01068     //
01069     // Set the new name
01070     //
01071
01072     m_bstrName = SysAllocString( bstrName );
01073
01074     //
01075     // Validates SysAllocString
01076     //
01077
01078     if( NULL == m_bstrName )
01079     {
01080         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::put_Name exit -"
01081             "SysAllocString failed, returns E_OUTOFMEMORY"));
01082         return E_OUTOFMEMORY;
01083     }
01084
01085     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_Name - exit"));
01086     return S_OK;
01087 }
01088
01089
01090 //////////////////////////////////////////////////////////////////////////////
01091
01092 STDMETHODIMP CPlugTerminalSuperclassInfo::get_CLSID(
01093     /*[out, retval]*/ BSTR*           pCLSID
01094     )
01095 {
01096     //
01097     // Critical section
01098     //
01099
01100     CLock lock(m_CritSect);
01101
01102     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::get_CLSID - enter"));
01103
01104     //
01105     // Validates argument
01106     //
01107
01108     if( MSPB_IsBadWritePtr( pCLSID, sizeof(BSTR)) )
01109     {
01110         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::get_CLSID exit -"
01111             "pVersion invalid, returns E_POINTER"));
01112         return E_POINTER;
01113     }
01114
01115     //
01116     // Validates the name
01117     //
01118
01119     if( IsBadStringPtr( m_bstrCLSID, (UINT)-1) )
01120     {
01121         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::get_CLSID exit -"
01122             "m_bstrName invalid, returns E_UNEXPECTED"));
01123         return E_UNEXPECTED;
01124     }
01125
01126     //
01127     // Return the name
01128     //
01129
01130     *pCLSID = SysAllocString( m_bstrCLSID );
01131
01132     //
01133     // Validates SysAllocString
01134     //
01135
01136     if( *pCLSID == NULL )
01137     {
01138         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::get_CLSID exit -"
01139             "SysAllocString failed, returns E_OUTOFMEMORY"));
01140         return E_OUTOFMEMORY;
01141     }
01142
01143     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::get_CLSID - exit"));
01144     return S_OK;
01145 }
01146
01147
01148 //////////////////////////////////////////////////////////////////////////////
01149
01150
01151 STDMETHODIMP CPlugTerminalSuperclassInfo::put_CLSID(
01152     /*[in]*/         BSTR            bstrCLSID
01153     )
01154 {
01155     //
01156     // Critical section
01157     //
01158
01159     CLock lock(m_CritSect);
01160
01161     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_CLSID - enter"));
01162
01163     //
01164     // Validates argument
01165     //
01166
01167     if(IsBadStringPtr( bstrCLSID, (UINT)-1) )
01168     {
01169         LOG((MSP_ERROR, "CPlugTerminalClassInfo::put_CLSID exit -"
01170             "bstrCLSID invalid, returns E_POINTER"));
01171         return E_POINTER;
01172     }
01173
01174     //
01175     // Is a real CLSID?
01176     //
01177
01178     CLSID clsid;
01179     HRESULT hr = CLSIDFromString(bstrCLSID, &clsid);
01180     if( FAILED(hr) )
01181     {
01182         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::put_CLSID exit -"
01183             "bstrCLSID is not a CLSID, returns E_INVALIDARG"));
01184         return E_INVALIDARG;
01185     }
01186
01187
01188     //
01189     // Clean-up the old name
01190     //
01191
01192     if(!IsBadStringPtr( m_bstrCLSID, (UINT)-1) )
01193     {
01194         SysFreeString( m_bstrCLSID );
01195         m_bstrCLSID = NULL;
01196     }
01197
01198     //
01199     // Set the new name
01200     //
01201
01202     m_bstrCLSID = SysAllocString( bstrCLSID );
01203
01204     //
01205     // Validates SysAllocString
01206     //
01207
01208     if( NULL == m_bstrCLSID )
01209     {
01210         LOG((MSP_ERROR, "CPlugTerminalSuperclassInfo::put_CLSID exit -"
01211             "SysAllocString failed, returns E_OUTOFMEMORY"));
01212         return E_OUTOFMEMORY;
01213     }
01214
01215     LOG((MSP_TRACE, "CPlugTerminalSuperclassInfo::put_CLSID - exit"));
01216     return S_OK;
01217 }
01218
01219
01220 //////////////////////////////////////////////////////////////////////////////
01221
01222
01223 //
01224 // Our available static terminal types.
01225 //
01226
01227 const STATIC_TERMINAL_TYPE CMSPAddress::m_saTerminalTypes[] =
01228 {
01229     {
01230         (DWORD) TAPIMEDIATYPE_AUDIO,
01231         &CLSID_CWaveinClassManager,
01232         CAudioCaptureTerminal::CreateTerminal
01233     },
01234     {
01235         (DWORD) TAPIMEDIATYPE_AUDIO,
01236         &CLSID_CWaveOutClassManager,
01237         CAudioRenderTerminal::CreateTerminal
01238     },
01239     {
01240         (DWORD) TAPIMEDIATYPE_VIDEO,
01241         &CLSID_CVidCapClassManager,
01242         CVideoCaptureTerminal::CreateTerminal
01243     }
01244 };
01245
01246 const DWORD CMSPAddress::m_sdwTerminalTypesCount = sizeof(m_saTerminalTypes)
01247                                               / sizeof (STATIC_TERMINAL_TYPE);
01248
01249 /////////////////////////////////////////////////////////////////////////////
01250 // CMSPAddress
01251 /////////////////////////////////////////////////////////////////////////////
01252
01253 //
01254 // Check to see if the mediatype is non-zero and is in the mask.
01255 // Your MSP can override this if it needs to do atypically complex
01256 // checks on specific combinations of media types (e.g., can never
01257 // have more than one media type on a call, can have video with audio
01258 // but not video alone, etc.). The default implementation accepts any
01259 // nonempty set of media types that is a subset of the set of types
01260 // in the mask.
01261 //
01262
01263 BOOL CMSPAddress::IsValidSetOfMediaTypes(DWORD dwMediaType, DWORD dwMask)
01264 {
01265     return (dwMediaType != 0) && ((dwMediaType & dwMask) == dwMediaType);
01266 }
01267
01268 CMSPAddress::CMSPAddress()
01269     : m_htEvent(NULL),
01270       m_fTerminalsUpToDate(FALSE),
01271       m_pITTerminalManager(NULL)
01272 {
01273     LOG((MSP_TRACE, "CMSPAddress::CMSPAddress[%p] - enter", this));
01274
01275     LOG((MSP_TRACE, "CMSPAddress::CMSPAddress - finished"));
01276 }
01277
01278 CMSPAddress::~CMSPAddress()
01279 {
01280     LOG((MSP_TRACE, "CMSPAddress::~CMSPAddress[%p] - enter", this));
01281
01282
01283     //
01284     // this should have been taken care of in Shutdown,
01285     // but just in case shutdown was never called, do this again, since
01286     // we need to make sure the thread does not have any stale entries in
01287     // its pnp notification list
01288     //
01289     // the call is likely to return error (since the object is likely to have been
01290     // unregisted earlier) -- so ignore return code
01291     //
01292
01293     g_Thread.UnregisterPnpNotification(this);
01294
01295
01296     LOG((MSP_TRACE, "CMSPAddress::~CMSPAddress - finished"));
01297 }
01298
01299 STDMETHODIMP CMSPAddress::Initialize(
01300     IN      MSP_HANDLE          htEvent
01301     )
01302 /*++
01303
01304 Routine Description:
01305
01306 This method is called by TAPI3 when this MSP is first created. The method
01307 initiailzes data members and creates the terminal manager. It also tells
01308 the global thread object to Start().
01309
01310 Arguments:
01311
01312 htEvent
01313     Event the MSP signals when passing an event structure back to TAPI.
01314
01315
01316 Return Value:
01317
01318     S_OK
01319     E_INVALIDARG
01320     E_OUTOFMEMORY
01321     TAPI_E_REGISTERCALLBACK
01322
01323 --*/
01324 {
01325     LOG((MSP_TRACE,
01326         "MSP address %x initialize entered, htEvent:%x",
01327         this, htEvent));
01328
01329     if ( htEvent == NULL )
01330     {
01331         LOG((MSP_ERROR, " bad handle: htEvent:%x", htEvent));
01332
01333         return E_INVALIDARG;
01334     }
01335
01336     // lock the event related data
01337     m_EventDataLock.Lock();
01338
01339     if (m_htEvent != NULL)
01340     {
01341         m_EventDataLock.Unlock();
01342
01343         LOG((MSP_ERROR, "Initialze called twice."));
01344         return E_UNEXPECTED;
01345     }
01346
01347     // save handles.
01348     m_htEvent   = htEvent;
01349
01350     InitializeListHead(&m_EventList);
01351
01352     HRESULT hr;
01353
01354     // release the lock on the event related data
01355     m_EventDataLock.Unlock();
01356
01357     // lock the terminal related data. This is a auto lock that will unlock
01358     // when the function returns.
01359     CLock lock(m_TerminalDataLock);
01360
01361     // Create the terminal manager.
01362     hr = CoCreateInstance(
01363         CLSID_TerminalManager,
01364         NULL,
01365         CLSCTX_INPROC_SERVER,
01366         IID_ITTerminalManager,
01367         (void **) &m_pITTerminalManager
01368         );
01369
01370     if (FAILED(hr))
01371     {
01372         LOG((MSP_ERROR,
01373             "Creating terminal manager failed. return: %x", hr));
01374
01375         return hr;
01376     }
01377
01378     hr = g_Thread.Start();
01379
01380     if (FAILED(hr))
01381     {
01382         LOG((MSP_ERROR,
01383             "Creating thread failed. return: %x", hr));
01384
01385         return hr;
01386     }
01387
01388     hr = g_Thread.RegisterPnpNotification(this);
01389
01390     if (FAILED(hr))
01391     {
01392         LOG((MSP_ERROR,
01393             "Unable to register for PNP notification. return: %x", hr));
01394     }
01395
01396     LOG((MSP_TRACE,
01397         "MSP address %x initialize exited S_OK, htEvent:%x",
01398         this, htEvent));
01399
01400     return S_OK;
01401 }
01402
01403 STDMETHODIMP CMSPAddress::Shutdown ()
01404 /*++
01405
01406 Routine Description:
01407
01408 This method is called by TAPI3 when this address in not in use any more.
01409 This function releases the terminals and releases the terminal manager.
01410 It releases all unprocessed events, and also stops the worker thread.
01411 When this functions is called, no call should be alive. However, bugs in
01412 the app may keep calls or terminals  around. Currently this function
01413 does not attempt to solve this problem. The calls will have their own
01414 refcounts on the terminals, so it shouldn't fail anyway.
01415
01416 Arguments:
01417     None.
01418
01419 Return Value:
01420
01421     S_OK
01422 --*/
01423 {
01424     LOG((MSP_TRACE, "CMSPAddress::Shutdown - "
01425         "MSP address %x is shutting down", this));
01426
01427     HRESULT hr;
01428
01429     //
01430     // Unregister for PNP notification
01431     //
01432
01433     hr = g_Thread.UnregisterPnpNotification(this);
01434
01435     if (FAILED(hr))
01436     {
01437         LOG((MSP_ERROR,
01438             "Unable to unregister for PNP notification. return: %x", hr));
01439     }
01440
01441     //
01442     // Tell the worker thread to stop.
01443     //
01444
01445     g_Thread.Stop();
01446
01447     LOG((MSP_INFO, "CMSPAddress::Shutdown - thread has stopped"));
01448
01449     // acquire the lock on the terminal data because we are writing to it.
01450     m_TerminalDataLock.Lock();
01451
01452     // Release the terminal manager.
01453     if (m_pITTerminalManager != NULL)
01454     {
01455         m_pITTerminalManager->Release();
01456         m_pITTerminalManager = NULL;
01457     }
01458
01459     // release all the terminals.
01460     for (int i = 0; i < m_Terminals.GetSize(); i ++)
01461     {
01462         //
01463         // Clear its CMSPAddress pointer
01464         //
01465         CBaseTerminal * pCTerminal = static_cast<CBaseTerminal *> (m_Terminals[i]);
01466
01467         m_Terminals[i]->Release();
01468     }
01469     m_Terminals.RemoveAll();
01470
01471     // We are done with terminal related data, release the lock.
01472     m_TerminalDataLock.Unlock();
01473
01474
01475     LOG((MSP_INFO, "CMSPAddress::Shutdown - terminals released"));
01476
01477     // acquire the lock on the event data because we are writing to it.
01478     m_EventDataLock.Lock();
01479
01480     m_htEvent = NULL;
01481
01482     // release all the unprocessed events in the list.
01483     while (!IsListEmpty(&m_EventList))
01484     {
01485         // retrieve first entry
01486         PLIST_ENTRY pLE = RemoveHeadList(&m_EventList);
01487
01488         // convert list entry to structure pointer
01489         PMSPEVENTITEM pItem = CONTAINING_RECORD(pLE, MSPEVENTITEM, Link);
01490
01491         // release the refcount in the event.
01492         LOG((MSP_INFO,
01493             "CMSPAddress::Shutdown:releasing event still in the queue: %x",
01494             pItem->MSPEventInfo.Event
01495             ));
01496
01497         switch (pItem->MSPEventInfo.Event)
01498         {
01499         case ME_ADDRESS_EVENT:
01500             if (pItem->MSPEventInfo.MSP_ADDRESS_EVENT_INFO.pTerminal)
01501             {
01502                 pItem->MSPEventInfo.MSP_ADDRESS_EVENT_INFO.pTerminal->Release();
01503             }
01504             break;
01505
01506         case ME_CALL_EVENT:
01507             if (pItem->MSPEventInfo.MSP_CALL_EVENT_INFO.pStream)
01508             {
01509                 pItem->MSPEventInfo.MSP_CALL_EVENT_INFO.pStream->Release();
01510             }
01511
01512             if (pItem->MSPEventInfo.MSP_CALL_EVENT_INFO.pTerminal)
01513             {
01514                 pItem->MSPEventInfo.MSP_CALL_EVENT_INFO.pTerminal->Release();
01515             }
01516             break;
01517
01518         case ME_PRIVATE_EVENT:
01519             if (pItem->MSPEventInfo.MSP_PRIVATE_EVENT_INFO.pEvent)
01520             {
01521                 pItem->MSPEventInfo.MSP_PRIVATE_EVENT_INFO.pEvent->Release();
01522             }
01523             break;
01524
01525         case ME_TSP_DATA:
01526             // nothing inside the structure that we need to free
01527             break;
01528
01529         case ME_FILE_TERMINAL_EVENT:
01530
01531             if( NULL != pItem->MSPEventInfo.MSP_FILE_TERMINAL_EVENT_INFO.pParentFileTerminal)
01532             {
01533                 (pItem->MSPEventInfo.MSP_FILE_TERMINAL_EVENT_INFO.pParentFileTerminal)->Release();
01534                 pItem->MSPEventInfo.MSP_FILE_TERMINAL_EVENT_INFO.pParentFileTerminal = NULL;
01535             }
01536
01537             if( NULL != pItem->MSPEventInfo.MSP_FILE_TERMINAL_EVENT_INFO.pFileTrack )
01538             {
01539                 (pItem->MSPEventInfo.MSP_FILE_TERMINAL_EVENT_INFO.pFileTrack)->Release();
01540                 pItem->MSPEventInfo.MSP_FILE_TERMINAL_EVENT_INFO.pFileTrack = NULL;
01541             }
01542
01543             break;
01544
01545         case ME_ASR_TERMINAL_EVENT:
01546
01547             if( NULL != pItem->MSPEventInfo.MSP_ASR_TERMINAL_EVENT_INFO.pASRTerminal)
01548             {
01549                 (pItem->MSPEventInfo.MSP_ASR_TERMINAL_EVENT_INFO.pASRTerminal)->Release();
01550             }
01551
01552             break;
01553
01554         case ME_TTS_TERMINAL_EVENT:
01555
01556             if( NULL != pItem->MSPEventInfo.MSP_TTS_TERMINAL_EVENT_INFO.pTTSTerminal)
01557             {
01558                 (pItem->MSPEventInfo.MSP_TTS_TERMINAL_EVENT_INFO.pTTSTerminal)->Release();
01559             }
01560
01561             break;
01562
01563         case ME_TONE_TERMINAL_EVENT:
01564
01565             if( NULL != pItem->MSPEventInfo.MSP_TONE_TERMINAL_EVENT_INFO.pToneTerminal)
01566             {
01567                 (pItem->MSPEventInfo.MSP_TONE_TERMINAL_EVENT_INFO.pToneTerminal)->Release();
01568             }
01569
01570             break;
01571
01572         default:
01573             LOG((MSP_WARN, "CMSPAddress::Shutdown: unknown event type: %x",
01574                 pItem->MSPEventInfo.Event));
01575
01576             break;
01577         }
01578
01579         FreeEventItem(pItem);
01580     }
01581
01582     // We are done with event related data, release the lcok.
01583     m_EventDataLock.Unlock();
01584
01585     LOG((MSP_TRACE, "CMSPAddress::Shutdown - exit S_OK"));
01586
01587     return S_OK;
01588 }
01589
01590
01591 STDMETHODIMP CMSPAddress::ReceiveTSPData(
01592     IN      IUnknown        *   pMSPCall,
01593     IN      LPBYTE              pBuffer,
01594     IN      DWORD               dwBufferSize
01595     )
01596 /*++
01597
01598 Routine Description:
01599
01600 This method is called by TAPI3 when the TSP address sends data to this
01601 MSP address object. The semantics of the data passed in the buffer are
01602 specific to each  TSP - MSP pair. This method dispatches the received
01603 buffer to the address (call == NULL) or call (call != NULL).
01604
01605 Arguments:
01606
01607 pMSPCall
01608     The call object that the data is for. If it is NULL, the data is for
01609     this address.
01610
01611 pBuffer
01612     Opaque buffer from TSP.
01613
01614 dwBufferSize
01615     Size in bytes of pBuffer
01616
01617
01618
01619 Return Value:
01620
01621     S_OK
01622
01623 --*/
01624 {
01625     LOG((MSP_TRACE, "CMSPAddress::ReceiveTSPData entered. pMSPCall:%x",
01626         pMSPCall));
01627
01628     _ASSERTE(dwBufferSize > 0);
01629     _ASSERTE(!IsBadReadPtr(pBuffer, sizeof(BYTE) * (dwBufferSize) ) );
01630
01631     HRESULT hr;
01632
01633     if ( NULL == pMSPCall )
01634     {
01635         hr = ReceiveTSPAddressData(pBuffer, dwBufferSize);
01636
01637         if ( FAILED(hr) )
01638         {
01639             LOG((MSP_ERROR, "CMSPAddress::ReceiveTSPData - "
01640                 "ReceiveTSPAddressData failed - exit 0x%08x", hr));
01641
01642             return hr;
01643         }
01644
01645         LOG((MSP_TRACE, "CMSPAddress::ReceiveTSPData - "
01646             "exit S_OK (dispatched to address)"));
01647
01648         return S_OK;
01649     }
01650
01651     //
01652     // We have a call to dispatch to.
01653     //
01654
01655     _ASSERTE(!IsBadReadPtr(pMSPCall, sizeof(IUnknown) ) );
01656
01657     ITStreamControl * pIStreamControl;
01658
01659     hr = pMSPCall->QueryInterface(IID_ITStreamControl,
01660                                   (void **)&pIStreamControl);
01661
01662     if ( FAILED(hr) )
01663     {
01664         LOG((MSP_ERROR, "CMSPAddress::ReceiveTSPData - "
01665             "can't get the ITStream Control interface - exit 0x%08x", hr));
01666
01667         return hr;
01668     }
01669
01670     CMSPCallBase * pCall = static_cast<CMSPCallBase *> (pIStreamControl);
01671
01672     if (pCall == NULL)
01673     {
01674         LOG((MSP_ERROR, "CMSPAddress::ReceiveTSPData - "
01675             "invalid msp call pointer: %x", pMSPCall));
01676
01677         pIStreamControl->Release();
01678
01679         return E_UNEXPECTED;
01680     }
01681
01682     hr = pCall->ReceiveTSPCallData(pBuffer, dwBufferSize);
01683
01684     pIStreamControl->Release();
01685
01686     if ( FAILED(hr) )
01687     {
01688         LOG((MSP_ERROR, "CMSPAddress::ReceiveTSPData - "
01689             "method on call failed - exit 0x%08x", hr));
01690
01691         return hr;
01692     }
01693
01694     LOG((MSP_TRACE, "CMSPAddress::ReceiveTSPData - "
01695         "exit S_OK (dispatched to call)"));
01696
01697     return S_OK;
01698 }
01699
01700
01701 HRESULT CMSPAddress::GetStaticTerminals(
01702     IN OUT  DWORD *             pdwNumTerminals,
01703     OUT     ITTerminal **       ppTerminals
01704     )
01705 /*++
01706
01707 Routine Description:
01708
01709 This method is called by TAPI3 to get a list of static terminals that can
01710 be used on this address. If our list is not empty, just return the list.
01711 If our list is still empty, create the static terminals and return the list.
01712 Derived class can override this method to have their own terminals. Locks
01713 the terminal lists.
01714
01715 Arguments:
01716
01717 pdwNumTerminals
01718     Pointer to a DWORD.  On entry, indicates the size of the buffer pointed
01719     to in ppTerminals. On success, it will be filled in with the actual number
01720     of terminals returned.  If the buffer is not big enough, the method will
01721     return TAPI_E_NOTENOUGHMEMORY, and it will be filled in the with number
01722     of terminals needed.
01723
01724 ppTerminals
01725     On success, filled in with an array of terminals object pointers that are
01726     supported by the MSP for this address.  This value may be NULL, in which
01727     case pdwNumTerminals will return the needed buffer size.
01728
01729
01730 Return Value:
01731
01732 S_OK
01733 E_OUTOFMEMORY
01734 TAPI_E_NOTENOUGHMEMORY
01735
01736 --*/
01737 {
01738     LOG((MSP_TRACE,
01739         "GetStaticTerminals entered. NumTerminals:%x, ppTerminals:%x",
01740         *pdwNumTerminals, ppTerminals
01741         ));
01742
01743     // lock the terminal related data. This is a auto lock that will unlock
01744     // when the function returns.
01745     CLock lock(m_TerminalDataLock);
01746
01747     if (!m_fTerminalsUpToDate)
01748     {
01749         HRESULT hr = UpdateTerminalList();
01750
01751         if (FAILED(hr))
01752         {
01753             LOG((MSP_ERROR,
01754                 "CMSPAddress::GetStaticTerminals - "
01755                 "UpdateTerminalList failed - returning 0x%08x", hr));
01756
01757             return hr;
01758         }
01759     }
01760
01761     //
01762     // Check if initialized.
01763     //
01764
01765     if ( m_htEvent == NULL )
01766     {
01767         LOG((MSP_ERROR, "CMSPAddress::GetStaticTerminals - "
01768             "not initialized - returning E_UNEXPECTED"));
01769
01770         return E_UNEXPECTED;
01771     }
01772
01773     //
01774     // Check parameters.
01775     //
01776
01777     if ( MSPB_IsBadWritePtr(pdwNumTerminals, sizeof(DWORD) ) )
01778     {
01779         LOG((MSP_ERROR, "CMSPAddress::GetStaticTerminals - "
01780             "bad pdwNumTerminals pointer - exit E_POINTER"));
01781
01782         return E_POINTER;
01783     }
01784
01785     if ( ppTerminals != NULL )
01786     {
01787         if ( MSPB_IsBadWritePtr(ppTerminals,
01788                            *pdwNumTerminals * sizeof(ITTerminal *) ) )
01789         {
01790             LOG((MSP_ERROR, "CMSPAddress::GetStaticTerminals - "
01791                 "bad ppTerminals pointer - exit E_POINTER"));
01792
01793             return E_POINTER;
01794         }
01795     }
01796
01797
01798     //
01799     // Grab the size of the terminals list.
01800     //
01801
01802     int   iSize = m_Terminals.GetSize();
01803     _ASSERTE( iSize >= 0 );
01804
01805     //
01806     // Add our terminals to the output list if the caller wants an output
01807     // list, and provided there is enough room in the output list.
01808     //
01809
01810     if ( ( ppTerminals != NULL ) &&
01811          ( (DWORD) iSize <= *pdwNumTerminals ) )
01812     {
01813         //
01814         // For each terminal in the list of terminals we created,
01815         // AddRef and copy the terminal pointer.
01816         //
01817
01818         for (int i = 0; i < iSize; i++)
01819         {
01820             m_Terminals[i]->AddRef();
01821
01822             ppTerminals[i] = m_Terminals[i];
01823         }
01824     }
01825
01826     //
01827     // If there was no output list then we just have to report the number
01828     // of terminals available.
01829     //
01830
01831     if ( ppTerminals == NULL )
01832     {
01833         *pdwNumTerminals = (DWORD) iSize;
01834
01835         LOG((MSP_TRACE,
01836             "CMSPAddress::GetStaticTerminals - just returned number of "
01837             "terminals available - exit S_OK"));
01838
01839         return S_OK;
01840     }
01841
01842     //
01843     // If there was an output list but it was not large enough, then
01844     // return the appropriate error.
01845     //
01846
01847     if ( (DWORD) iSize > *pdwNumTerminals )
01848     {
01849         *pdwNumTerminals = (DWORD) iSize;
01850
01851         LOG((MSP_ERROR,
01852             "CMSPAddress::GetStaticTerminals - passed-in array not "
01853             "large enough - exit TAPI_E_NOTENOUGHMEMORY"));
01854
01855         return TAPI_E_NOTENOUGHMEMORY;
01856     }
01857
01858     //
01859     // Otherwise, everything was fine. We just need to report the actual
01860     // number of terminals we copied and return S_OK.
01861     //
01862
01863     *pdwNumTerminals = (DWORD) iSize;
01864
01865     LOG((MSP_TRACE,
01866         "CMSPAddress::GetStaticTerminals - "
01867         "returned terminals - exit S_OK"));
01868
01869     return S_OK;
01870 }
01871
01872 HRESULT CMSPAddress::IsMonikerInTerminalList(IMoniker* pMoniker)
01873 {
01874     CSingleFilterStaticTerminal *pCSingleFilterStaticTerminal;
01875
01876     //
01877     // Grab the size of the terminals list.
01878     //
01879
01880     int   iSize = m_Terminals.GetSize();
01881     _ASSERTE( iSize >= 0 );
01882
01883     //
01884     // Add our terminals to the output list if the caller wants an output
01885     // list, and provided there is enough room in the output list.
01886     //
01887
01888     for (int i = 0; i < iSize; i++)
01889     {
01890         pCSingleFilterStaticTerminal = static_cast<CSingleFilterStaticTerminal *>(m_Terminals[i]);
01891
01892         if ( pCSingleFilterStaticTerminal->CompareMoniker( pMoniker ) == S_OK )
01893         {
01894             LOG((MSP_TRACE, "CMSPAddress::IsMonikerInTerminalList - "
01895                 "moniker found in terminal list"));
01896
01897             pCSingleFilterStaticTerminal->m_bMark = TRUE;  // mark this terminal so we don't remove it
01898
01899             return S_OK;
01900         }
01901
01902     }
01903
01904     LOG((MSP_TRACE, "CMSPAddress::IsMonikerInTerminalList - "
01905                 "moniker not found in terminal list"));
01906     return S_FALSE;
01907 }
01908
01909 HRESULT CMSPAddress::UpdateTerminalListForPnp(
01910         IN  BOOL    bDeviceArrival
01911         )
01912 {
01913     CSingleFilterStaticTerminal *pCSingleFilterStaticTerminal;
01914
01915     //
01916     // Clear all marks in the terminal list
01917     //
01918
01919     int   iSize = m_Terminals.GetSize();
01920     _ASSERTE( iSize >= 0 );
01921
01922     for (int i = 0; i < iSize; i++)
01923     {
01924         pCSingleFilterStaticTerminal = static_cast<CSingleFilterStaticTerminal *>(m_Terminals[i]);
01925
01926         if (pCSingleFilterStaticTerminal == NULL)
01927         {
01928             LOG((MSP_ERROR, "CMSPAddress::IsMonikerInTerminalList - "
01929                     "bad terminal pointer"));
01930             return E_FAIL;
01931         }
01932
01933         pCSingleFilterStaticTerminal->m_bMark = FALSE;
01934     }
01935
01936     //
01937     // Create DevEnum, which is the DirectShow Category Enumerator Creator
01938     //
01939
01940     HRESULT hr;
01941     ICreateDevEnum * pCreateDevEnum;
01942
01943     hr = CoCreateInstance(CLSID_SystemDeviceEnum,
01944                           NULL,
01945                           CLSCTX_INPROC_SERVER,
01946                           IID_ICreateDevEnum,
01947                           (void**)&pCreateDevEnum);
01948
01949     if (FAILED(hr))
01950     {
01951         LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp "
01952                "can't CoCreate DevEnum - returning  0x%08x", hr));
01953         return hr;
01954     }
01955
01956     IEnumMoniker  * pCatEnum;
01957
01958     for ( i = 0; i < m_sdwTerminalTypesCount; i++ )
01959     {
01960         //
01961         // Skip any terminal types that don't use one of the supported media
01962         // modes.
01963         //
01964
01965         if ( ! IsValidSingleMediaType(
01966             m_saTerminalTypes[i].dwMediaType, GetCallMediaTypes() ) )
01967         {
01968             continue;
01969         }
01970
01971
01972         //
01973         // Create the actual category enumerator.
01974         //
01975
01976         hr = pCreateDevEnum->CreateClassEnumerator(
01977                                 *(m_saTerminalTypes[i].clsidClassManager),
01978                                 &pCatEnum,
01979                                 0);
01980
01981         if ( hr != S_OK ) // S_FALSE means the category does not exist!
01982         {
01983             LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp "
01984                    "can't create class enumerator - returning 0x%08x", hr));
01985
01986             continue;
01987         }
01988
01989         IMoniker      * pMoniker;
01990
01991         while ((hr = pCatEnum->Next(1, &pMoniker, NULL)) == S_OK)
01992         {
01993             if (IsMonikerInTerminalList(pMoniker) == S_FALSE)
01994             {
01995                 //
01996                 // Create a terminal and give it its moniker.
01997                 //
01998
01999                 ITTerminal * pTerminal;
02000                 hr = (m_saTerminalTypes[i].pfnCreateTerm)(pMoniker,
02001                                                           (MSP_HANDLE) this,
02002                                                           &pTerminal);
02003
02004                 //
02005                 // The terminal keeps a reference to the moniker if it needs to.
02006                 //
02007
02008                 pMoniker->Release();
02009
02010                 if (SUCCEEDED(hr))
02011                 {
02012                     //
02013                     // Add this terminal pointer to our list. Don't release it; we
02014                     // keep this one reference to it in the list.
02015                     //
02016
02017                     BOOL fSuccess = m_Terminals.Add(pTerminal);
02018
02019                     if ( ! fSuccess )
02020                     {
02021                         pCatEnum->Release();
02022                         pTerminal->Release();
02023
02024                         LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02025                             "can't add terminal to list; returning E_OUTOFMEMORY"));
02026
02027                         return E_OUTOFMEMORY;
02028                     }
02029
02030                     //
02031                     // Set its CMSPAddress pointer
02032                     //
02033                     CBaseTerminal * pCTerminal = static_cast<CBaseTerminal *> (pTerminal);
02034
02035                     //
02036                     // Mark this terminal so we don't remove it
02037                     //
02038
02039                     pCSingleFilterStaticTerminal = static_cast<CSingleFilterStaticTerminal *>(pTerminal);
02040
02041                     if (pCSingleFilterStaticTerminal == NULL)
02042                     {
02043                         LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02044                                 "bad terminal pointer"));
02045                         return E_FAIL;
02046                     }
02047
02048                     pCSingleFilterStaticTerminal->m_bMark = TRUE;
02049
02050                     //
02051                     // Post a TAPI message about the new terminal's arrival
02052                     //
02053
02054                     pTerminal->AddRef();
02055
02056                     MSPEVENTITEM *pEventItem;
02057
02058                     pEventItem = AllocateEventItem();
02059
02060                     if (pEventItem == NULL)
02061                     {
02062                         LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02063                         "can't allocate event item; returning E_OUTOFMEMORY"));
02064
02065                         pTerminal->Release();
02066                         return E_OUTOFMEMORY;
02067                     }
02068
02069                     pEventItem->MSPEventInfo.dwSize = sizeof(MSP_EVENT_INFO);
02070                     pEventItem->MSPEventInfo.Event = ME_ADDRESS_EVENT;
02071                     pEventItem->MSPEventInfo.MSP_ADDRESS_EVENT_INFO.Type = ADDRESS_TERMINAL_AVAILABLE;
02072                     pEventItem->MSPEventInfo.MSP_ADDRESS_EVENT_INFO.pTerminal = pTerminal;
02073
02074                     hr = PostEvent(pEventItem);
02075
02076                     if (FAILED(hr))
02077                     {
02078                         LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02079                         "post event failed"));
02080
02081                         pTerminal->Release();
02082                         FreeEventItem(pEventItem);
02083                     }
02084
02085                 }
02086             }
02087
02088             //
02089             // If it failed, that either means we skipped the device because it
02090             // was unsuitable (a routine occurance) or something failed, like
02091             // out of memory. I should come up with a way to differentiate and
02092             // handle this well.
02093             //
02094         }
02095
02096         //
02097         // We are done with the enumerator.
02098         //
02099
02100         pCatEnum->Release();
02101     }
02102
02103     //
02104     // Release DevEnum.
02105     //
02106
02107     pCreateDevEnum->Release();
02108
02109     //
02110     // Sweep the terminal list and clean up any terminals which are no longer present
02111     //
02112
02113     iSize = m_Terminals.GetSize();
02114     _ASSERTE( iSize >= 0 );
02115
02116     for (i = 0; i < iSize; i++)
02117     {
02118         pCSingleFilterStaticTerminal = static_cast<CSingleFilterStaticTerminal *>(m_Terminals[i]);
02119
02120         if (pCSingleFilterStaticTerminal == NULL)
02121         {
02122             LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02123                     "bad terminal pointer"));
02124             return E_FAIL;
02125         }
02126
02127         if (!pCSingleFilterStaticTerminal->m_bMark)
02128         {
02129             //
02130             // This terminal has is no longer present, lets remove it from the list
02131             //
02132
02133             LOG((MSP_TRACE, "CMSPAddress::UpdateTerminalListForPnp "
02134                    "found a terminal to be removed"));
02135
02136             ITTerminal * pTerminal = m_Terminals[i];
02137
02138             if (m_Terminals.RemoveAt(i))
02139             {
02140                 //
02141                 // Clear its CMSPAddress pointer
02142                 //
02143                 CBaseTerminal * pCTerminal = static_cast<CBaseTerminal *> (pTerminal);
02144
02145                 //
02146                 // We don't release the terminal here even though we are removing
02147                 // it from the terminal list because TAPI3.dll will release it
02148                 // when it releases the event.
02149                 //
02150
02151                 //
02152                 // Post a TAPI message about the new terminal's removal
02153                 //
02154
02155                 MSPEVENTITEM *pEventItem;
02156
02157                 pEventItem = AllocateEventItem();
02158
02159                 if (pEventItem == NULL)
02160                 {
02161                     LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02162                     "can't allocate event item; returning E_OUTOFMEMORY"));
02163
02164                     pTerminal->Release();
02165                     return E_OUTOFMEMORY;
02166                 }
02167
02168                 pEventItem->MSPEventInfo.dwSize = sizeof(MSP_EVENT_INFO);
02169                 pEventItem->MSPEventInfo.Event = ME_ADDRESS_EVENT;
02170                 pEventItem->MSPEventInfo.MSP_ADDRESS_EVENT_INFO.Type = ADDRESS_TERMINAL_UNAVAILABLE;
02171                 pEventItem->MSPEventInfo.MSP_ADDRESS_EVENT_INFO.pTerminal = pTerminal;
02172
02173                 hr = PostEvent(pEventItem);
02174
02175                 if (FAILED(hr))
02176                 {
02177                     LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalListForPnp - "
02178                     "post event failed"));
02179
02180                     pTerminal->Release();
02181                     FreeEventItem(pEventItem);
02182                 }
02183
02184                 //
02185                 // fix up our search indices to account for a removal
02186                 //
02187
02188                 iSize--;
02189                 i--;
02190             }
02191         }
02192     }
02193
02194     //
02195     // Our list is now complete.
02196     //
02197
02198     m_fTerminalsUpToDate = TRUE;
02199
02200     LOG((MSP_TRACE, "CMSPAddress::UpdateTerminalListForPnp - exit S_OK"));
02201
02202     return S_OK;
02203 }
02204
02205
02206 HRESULT CMSPAddress::UpdateTerminalList(void)
02207 {
02208     //
02209     // Create DevEnum, which is the DirectShow Category Enumerator Creator
02210     //
02211
02212     HRESULT hr;
02213     ICreateDevEnum * pCreateDevEnum;
02214
02215     hr = CoCreateInstance(CLSID_SystemDeviceEnum,
02216                           NULL,
02217                           CLSCTX_INPROC_SERVER,
02218                           IID_ICreateDevEnum,
02219                           (void**)&pCreateDevEnum);
02220
02221     if (FAILED(hr))
02222     {
02223         LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalList "
02224                "can't CoCreate DevEnum - returning  0x%08x", hr));
02225         return hr;
02226     }
02227
02228     IEnumMoniker  * pCatEnum;
02229
02230     for ( DWORD i = 0; i < m_sdwTerminalTypesCount; i++ )
02231     {
02232         //
02233         // Skip any terminal types that don't use one of the supported media
02234         // modes.
02235         //
02236
02237         if ( ! IsValidSingleMediaType(
02238             m_saTerminalTypes[i].dwMediaType, GetCallMediaTypes() ) )
02239         {
02240             continue;
02241         }
02242
02243
02244         //
02245         // Create the actual category enumerator.
02246         //
02247
02248         hr = pCreateDevEnum->CreateClassEnumerator(
02249                                 *(m_saTerminalTypes[i].clsidClassManager),
02250                                 &pCatEnum,
02251                                 0);
02252
02253         if ( hr != S_OK ) // S_FALSE means the category does not exist!
02254         {
02255             LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalList "
02256                    "can't create class enumerator - returning 0x%08x", hr));
02257
02258             continue;
02259         }
02260
02261         IMoniker      * pMoniker;
02262
02263         while ((hr = pCatEnum->Next(1, &pMoniker, NULL)) == S_OK)
02264         {
02265             //
02266             // Create a terminal and give it its moniker.
02267             //
02268
02269             ITTerminal * pTerminal;
02270             hr = (m_saTerminalTypes[i].pfnCreateTerm)(pMoniker,
02271                                                       (MSP_HANDLE) this,
02272                                                       &pTerminal);
02273
02274             //
02275             // The terminal keeps a reference to the moniker if it needs to.
02276             //
02277
02278             pMoniker->Release();
02279
02280             if (SUCCEEDED(hr))
02281             {
02282                 //
02283                 // Add this terminal pointer to our list. Don't release it; we
02284                 // keep this one reference to it in the list.
02285                 //
02286
02287                 BOOL fSuccess = m_Terminals.Add(pTerminal);
02288
02289                 if ( ! fSuccess )
02290                 {
02291                     pCatEnum->Release();
02292
02293                     LOG((MSP_ERROR, "CMSPAddress::UpdateTerminalList - "
02294                         "can't add terminal to list; returning E_OUTOFMEMORY"));
02295
02296                     return E_OUTOFMEMORY;
02297                 }
02298                 //
02299                 // Set its CMSPAddress pointer
02300                 //
02301                 CBaseTerminal * pCTerminal = static_cast<CBaseTerminal *> (pTerminal);
02302
02303             }
02304
02305             //
02306             // If it failed, that either means we skipped the device because it
02307             // was unsuitable (a routine occurance) or something failed, like
02308             // out of memory. I should come up with a way to differentiate and
02309             // handle this well.
02310             //
02311         }
02312
02313         //
02314         // We are done with the enumerator.
02315         //
02316
02317         pCatEnum->Release();
02318     }
02319
02320     //
02321     // Release DevEnum.
02322     //
02323
02324     pCreateDevEnum->Release();
02325
02326     //
02327     // Our list is now complete.
02328     //
02329
02330     m_fTerminalsUpToDate = TRUE;
02331
02332     LOG((MSP_TRACE, "CMSPAddress::UpdateTerminalList - exit S_OK"));
02333
02334     return S_OK;
02335 }
02336
02337 HRESULT CMSPAddress::GetDynamicTerminalClasses(
02338     IN OUT  DWORD *             pdwNumClasses,
02339     OUT     IID *               pTerminalClasses
02340     )
02341 /*++
02342
02343 Routine Description:
02344
02345 This method is called by TAPI3 to get a list of dynamic terminal guids
02346 that can be used on this address. It asks the terminal manager for the
02347 list of guids and returns them. Derived class can override this method
02348 to have their own guids.
02349
02350
02351 Arguments:
02352
02353 pdwNumClasses
02354     Pointer to a DWORD.  On entry, indicates the size of the buffer
02355     pointed to in pTerminalClasses. On success, it will be filled in
02356     with the actual number of class IIDs returned.  If the buffer is
02357     not big enough, the method will return TAPI_E_NOTENOUGHMEMORY,
02358     and it will be filled in the with number of IIDs needed.
02359
02360 pTerminalClasses
02361
02362     On success, filled in with an array of terminal class IIDs that
02363     are supported by the MSP for this address.  This value may be NULL,
02364     in which case pdwNumClasses will return the needed buffer size.
02365
02366 Return Value:
02367
02368 S_OK
02369 E_OUTOFMEMORY
02370 TAPI_E_NOTENOUGHMEMORY
02371
02372 --*/
02373 {
02374     LOG((MSP_TRACE,
02375         "CMSPAddress::GetDynamicTerminalClasses - enter"));
02376
02377     //
02378     // Check if initialized.
02379     //
02380
02381     // lock the event related data
02382     m_EventDataLock.Lock();
02383
02384     if ( m_htEvent == NULL )
02385     {
02386         // unlock the event related data
02387         m_EventDataLock.Unlock();
02388
02389         LOG((MSP_ERROR,
02390             "CMSPAddress::GetDynamicTerminalClasses - "
02391             "not initialized - returning E_UNEXPECTED"));
02392
02393         return E_UNEXPECTED;
02394     }
02395
02396     // unlock the event related data
02397     m_EventDataLock.Unlock();
02398
02399     //
02400     // Ask the Terminal Manager for the dynamic terminals that apply to
02401     // all of our supported media types. Since the mapping is
02402     // direct, the Terminal Manager takes care of all argument checking.
02403     //
02404
02405     HRESULT hr;
02406
02407     hr = m_pITTerminalManager->GetDynamicTerminalClasses(
02408                                                   GetCallMediaTypes(),
02409                                                   pdwNumClasses,
02410                                                   pTerminalClasses);
02411
02412
02413     LOG((MSP_TRACE,
02414         "CMSPAddress::GetDynamicTerminalClasses - exit 0x%08x", hr));
02415
02416     return hr;
02417 }
02418
02419 STDMETHODIMP CMSPAddress::CreateTerminal(
02420     IN      BSTR                pTerminalClass,
02421     IN      long                lMediaType,
02422     IN      TERMINAL_DIRECTION  Direction,
02423     OUT     ITTerminal **       ppTerminal
02424     )
02425 /*++
02426
02427 Routine Description:
02428
02429 This method is called by TAPI3 to create a dynamic terminal. It asks the
02430 terminal manager to create a dynamic terminal. Derived class can
02431 override this method to have their own way of creating a dynamic terminal.
02432
02433 Arguments:
02434
02435 iidTerminalClass
02436     IID of the terminal class to be created.
02437
02438 dwMediaType
02439     TAPI media type of the terminal to be created.
02440
02441 Direction
02442     Terminal direction of the terminal to be created.
02443
02444 ppTerminal
02445     Returned created terminal object
02446
02447 Return Value:
02448
02449 S_OK
02450
02451 E_OUTOFMEMORY
02452 TAPI_E_INVALIDMEDIATYPE
02453 TAPI_E_INVALIDTERMINALDIRECTION
02454 TAPI_E_INVALIDTERMINALCLASS
02455
02456 --*/
02457 {
02458     LOG((MSP_TRACE,
02459         "CMSPAddress::CreateTerminal - enter"));
02460
02461     //
02462     // Check if initialized.
02463     //
02464
02465     // lock the event related data
02466     m_EventDataLock.Lock();
02467
02468     if ( m_htEvent == NULL )
02469     {
02470         // unlock the event related data
02471         m_EventDataLock.Unlock();
02472
02473         LOG((MSP_ERROR,
02474             "CMSPAddress::CreateTerminal - "
02475             "not initialized - returning E_UNEXPECTED"));
02476
02477         return E_UNEXPECTED;
02478     }
02479
02480     // unlock the event related data
02481     m_EventDataLock.Unlock();
02482
02483     //
02484     // Get the IID from the BSTR representation.
02485     //
02486
02487     HRESULT hr;
02488     IID     iidTerminalClass;
02489
02490     hr = CLSIDFromString(pTerminalClass, &iidTerminalClass);
02491
02492     if ( FAILED(hr) )
02493     {
02494         LOG((MSP_ERROR, "CMSPAddress::CreateTerminal - "
02495             "bad CLSID string - returning E_INVALIDARG"));
02496
02497         return E_INVALIDARG;
02498     }
02499
02500     //
02501     // Make sure we support the requested media type.
02502     // The terminal manager checks the terminal class, terminal direction,
02503     // and return pointer.
02504     //
02505
02506
02507
02508     //
02509     // requested media type may be aggregated, but it must still be valid
02510     //
02511
02512     if ( !IsValidAggregatedMediaType(lMediaType) )
02513     {
02514         LOG((MSP_ERROR, "CMSPAddress::CreateTerminal - "
02515             "unrecognized media type requested - returning E_INVALIDARG"));
02516
02517         return E_INVALIDARG;
02518     }
02519
02520     //
02521     // Use the terminal manager to create the dynamic terminal.
02522     //
02523
02524     _ASSERTE( m_pITTerminalManager != NULL );
02525
02526     hr = m_pITTerminalManager->CreateDynamicTerminal(NULL,
02527                                                      iidTerminalClass,
02528                                                      (DWORD) lMediaType,
02529                                                      Direction,
02530                                                      (MSP_HANDLE) this,
02531                                                      ppTerminal);
02532
02533     if ( FAILED(hr) )
02534     {
02535         LOG((MSP_ERROR, "CMSPAddress::CreateTerminal - "
02536             "create dynamic terminal failed - returning 0x%08x", hr));
02537
02538         return hr;
02539     }
02540
02541     LOG((MSP_TRACE, "CMSPAddress::CreateTerminal - exit S_OK"));
02542
02543     return S_OK;
02544 }
02545
02546 STDMETHODIMP CMSPAddress::GetDefaultStaticTerminal(
02547     IN      long                lMediaType,
02548     IN      TERMINAL_DIRECTION  Direction,
02549     OUT     ITTerminal **       ppTerminal
02550     )
02551 /*++
02552
02553 Routine Description:
02554
02555 This method is called by TAPI3 to get the default static terminal
02556 for a certain type and direction. It updates the list if needed, then
02557 figures out which terminal is the first of the appropriate type in our
02558 list. Derived classes can override this method to have
02559 their own way of deciding which terminal is the default. Locks the
02560 terminal lists.
02561
02562
02563 Arguments:
02564
02565 dwMediaType
02566     The TAPIMEDIATYPE of the terminal to retrieve.  Only one bit will be set.
02567
02568 Direction
02569     TERMINAL_DIRECTION of the terminal to retrieve.
02570
02571 ppTerminal
02572     Default terminal returned
02573
02574
02575 Return Value:
02576
02577 S_OK
02578
02579 E_POINTER
02580 E_OUTOFMEMORY
02581 TAPI_E_NOTSUPPORTED
02582 TAPI_E_INVALIDMEDIATYPE
02583 TAPI_E_INVALIDTERMINALDIRECTION
02584
02585 --*/
02586 {
02587     LOG((MSP_TRACE,
02588         "CMSPAddress::GetDefaultStaticTerminal - enter"));
02589
02590     //
02591     // Check if initialized.
02592     //
02593
02594     // lock the event related data
02595     m_EventDataLock.Lock();
02596
02597     if ( m_htEvent == NULL )
02598     {
02599         // unlock the event related data
02600         m_EventDataLock.Unlock();
02601
02602         LOG((MSP_ERROR,
02603             "CMSPAddress::GetDefaultStaticTerminal - "
02604             "not initialized - returning E_UNEXPECTED"));
02605
02606         return E_UNEXPECTED;
02607     }
02608     // unlock the event related data
02609     m_EventDataLock.Unlock();
02610
02611     //
02612     // Make sure we support this media type.
02613     //
02614
02615     if ( ! IsValidSingleMediaType( (DWORD) lMediaType, GetCallMediaTypes() ) )
02616     {
02617         LOG((MSP_ERROR,
02618             "CMSPAddress::GetDefaultStaticTerminal - "
02619             "non-audio terminal requested - returning E_INVALIDARG"));
02620
02621         return E_INVALIDARG;
02622     }
02623
02624     //
02625     // Check the direction.
02626     //
02627
02628     if ( ( Direction != TD_CAPTURE ) && ( Direction != TD_RENDER ) )
02629     {
02630         LOG((MSP_ERROR,
02631             "CMSPAddress::GetDefaultStaticTerminal - "
02632             "invalid direction - returning E_INVALIDARG"));
02633
02634         return E_INVALIDARG;
02635     }
02636
02637     //
02638     // Check return pointer.
02639     //
02640
02641     if ( MSPB_IsBadWritePtr(ppTerminal, sizeof(ITTerminal *) ) )
02642     {
02643         LOG((MSP_ERROR,
02644             "CMSPAddress::GetDefaultStaticTerminal - "
02645             "bad terminal return pointer - returning E_POINTER"));
02646
02647         return E_POINTER;
02648     }
02649
02650     // lock the terminal related data. This is a auto lock that will unlock
02651     // when the function returns.
02652     CLock lock(m_TerminalDataLock);
02653
02654     if (!m_fTerminalsUpToDate)
02655     {
02656        HRESULT hr = UpdateTerminalList();
02657
02658         if (FAILED(hr))
02659         {
02660             LOG((MSP_ERROR,
02661                 "CMSPAddress::GetDefaultStaticTerminal - "
02662                 "UpdateTerminalList failed - returning 0x%08x", hr));
02663
02664             return hr;
02665         }
02666     }
02667
02668     //
02669     // For each terminal in the list of terminals we created...
02670     //
02671
02672     int iSize = m_Terminals.GetSize();
02673
02674     for (int i = 0; i < iSize; i++)
02675     {
02676         ITTerminal * pTerminal = m_Terminals[i];
02677
02678         HRESULT      hr;
02679
02680         //
02681         // Make sure this is the right direction.
02682         //
02683
02684         TERMINAL_DIRECTION dir;
02685
02686         hr = pTerminal->get_Direction(&dir);
02687
02688         if (FAILED(hr))
02689         {
02690             LOG((MSP_WARN,
02691                 "CMSPAddress::GetDefaultStaticTerminal - "
02692                 "could not get terminal direction - skipping"));
02693
02694             continue;
02695         }
02696
02697         if ( dir != Direction )
02698         {
02699             continue;
02700         }
02701
02702         //
02703         // Make sure this is the right media type.
02704         //
02705
02706         long lMediaTypeObserved;
02707
02708         hr = pTerminal->get_MediaType(&lMediaTypeObserved);
02709
02710         if (FAILED(hr))
02711         {
02712             LOG((MSP_WARN,
02713                 "CMSPAddress::GetDefaultStaticTerminal - "
02714                 "could not get terminal media type - skipping"));
02715
02716             continue;
02717         }
02718
02719         if ( ( lMediaTypeObserved & lMediaType) == 0 )
02720         {
02721             continue;
02722         }
02723
02724         //
02725         // Ok, so this is the terminal we want. Addref it and give it to the
02726         // caller.
02727         //
02728
02729         pTerminal->AddRef();
02730
02731         *ppTerminal = pTerminal;
02732
02733         LOG((MSP_TRACE,
02734             "CMSPAddress::GetDefaultStaticTerminal - "
02735             "returned a terminal - exit S_OK"));
02736
02737         return S_OK;
02738     }
02739
02740     //
02741     // If we get here then we did not find any matching terminals.
02742     //
02743
02744     LOG((MSP_TRACE,
02745         "CMSPAddress::GetDefaultStaticTerminal - "
02746         "no match - exit TAPI_E_NOITEMS"));
02747
02748     return TAPI_E_NOITEMS;
02749 }
02750
02751 STDMETHODIMP CMSPAddress::get_PluggableSuperclasses(
02752     OUT VARIANT * pVariant
02753     )
02754 {
02755     LOG((MSP_TRACE,
02756         "CMSPAddress::get_PluggableSuperclasses - enter"));
02757
02758     //
02759     // Check parameters.
02760     //
02761
02762     if ( MSPB_IsBadWritePtr(pVariant, sizeof(VARIANT) ) )
02763     {
02764         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02765             "bad pointer argument - exit E_POINTER"));
02766
02767         return E_POINTER;
02768     }
02769
02770     //
02771     // Get ITTemrinalManager2
02772     //
02773
02774     ITTerminalManager2* pTermMgr2 = NULL;
02775     HRESULT hr = E_FAIL;
02776     hr = m_pITTerminalManager->QueryInterface(
02777         IID_ITTerminalManager2, (void**)&pTermMgr2);
02778
02779     if( FAILED(hr) )
02780     {
02781         LOG((MSP_ERROR,
02782             "CMSPAddress::get_PluggableSuperclasses - "
02783             "QI for ITTerminalManager2 failed - returning 0x%08x", hr));
02784         return hr;
02785     }
02786
02787     //
02788     // Create the collection object - see mspcoll.h
02789     //
02790
02791     typedef CTapiIfCollection< ITPluggableTerminalSuperclassInfo* > SuperclassCollection;
02792     CComObject<SuperclassCollection> * pCollection;
02793     hr = CComObject<SuperclassCollection>::CreateInstance( &pCollection );
02794
02795     if ( FAILED(hr) )
02796     {
02797         //Clean-up
02798         pTermMgr2->Release();
02799
02800         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02801             "can't create collection - exit 0x%08x", hr));
02802
02803         return hr;
02804     }
02805
02806     //
02807     // Get the Collection's IDispatch interface
02808     //
02809
02810     IDispatch * pDispatch;
02811     hr = pCollection->_InternalQueryInterface(
02812         IID_IDispatch,
02813         (void **) &pDispatch );
02814
02815     if ( FAILED(hr) )
02816     {
02817         //Clean-up
02818         pTermMgr2->Release();
02819         delete pCollection;
02820
02821         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02822             "QI for IDispatch on collection failed - exit 0x%08x", hr));
02823         return hr;
02824     }
02825
02826     //
02827     // Find out how many superclasses are available.
02828     //
02829
02830     DWORD   dwNumSuperclasses = 0;
02831
02832     hr = pTermMgr2->GetPluggableSuperclasses(
02833             &dwNumSuperclasses,
02834             NULL);
02835
02836     if ( FAILED(hr) )
02837     {
02838         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02839             "can't get number of terminals - exit 0x%08x", hr));
02840
02841         //Clean-up
02842         pTermMgr2->Release();
02843         pDispatch->Release();
02844
02845         return hr;
02846     }
02847
02848     //
02849     // Allocate an array of IID.
02850     //
02851
02852     IID* pSuperclassesIID = new IID[dwNumSuperclasses];
02853     if ( pSuperclassesIID == NULL )
02854     {
02855         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02856             "can't allocate IIDs array - exit E_OUTOFMEMORY"));
02857
02858         //Clean-up
02859         pTermMgr2->Release();
02860         pDispatch->Release();
02861
02862         return E_OUTOFMEMORY;
02863     }
02864
02865     //
02866     // Fill in the array with actual pointers. We must do this before
02867     // initializing the enumerator, because the enumerator may want to
02868     // addref the interface pointers during initialize.
02869     //
02870
02871     hr = pTermMgr2->GetPluggableSuperclasses(
02872             &dwNumSuperclasses,
02873             pSuperclassesIID
02874             );
02875
02876     //
02877     // Clean-up
02878     //
02879
02880     pTermMgr2->Release();
02881
02882     if ( FAILED(hr) )
02883     {
02884         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02885             "can't get IIDs - exit 0x%08x", hr));
02886
02887         //Clean-up
02888         pDispatch->Release();
02889         delete[] pSuperclassesIID;
02890
02891         return hr;
02892     }
02893
02894     //
02895     // Allocate an array of ITPluggableTerminalSuperclassInfo
02896     //
02897     typedef ITPluggableTerminalSuperclassInfo* SuperclassPtr; // MS parser
02898     SuperclassPtr * ppSuperclassesInfo = new SuperclassPtr[dwNumSuperclasses];
02899     if ( ppSuperclassesInfo == NULL )
02900     {
02901         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02902             "can't allocate SuperclassPtr array - exit E_OUTOFMEMORY"));
02903
02904         //Clean-up
02905         pDispatch->Release();
02906         delete[] pSuperclassesIID;
02907
02908         return E_OUTOFMEMORY;
02909     }
02910
02911     //
02912     // Get ITPluggableTerminalSuperclassRegistration interface
02913     //
02914
02915     ITPluggableTerminalSuperclassRegistration* pSuperclassReg = NULL;
02916     hr = CoCreateInstance(
02917         CLSID_PluggableSuperclassRegistration,
02918         NULL,
02919         CLSCTX_INPROC_SERVER,
02920         IID_ITPluggableTerminalSuperclassRegistration,
02921         (void**)&pSuperclassReg
02922         );
02923     if( FAILED(hr) )
02924     {
02925         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02926             "QI for ITPluggableTerminalSuperclassRegistration - exit 0x%08x",hr));
02927
02928         //Clean-up
02929         pDispatch->Release();
02930         delete[] pSuperclassesIID;
02931         delete[] ppSuperclassesInfo;
02932
02933         return hr;
02934     }
02935
02936     //
02937     // Create the objects
02938     //
02939
02940     for(DWORD dwIndex = 0; dwIndex < dwNumSuperclasses; dwIndex++)
02941     {
02942         //
02943         // Get the string from the IID
02944         //
02945         LPOLESTR lpszCLSID = NULL;
02946         hr = StringFromIID( pSuperclassesIID[dwIndex], &lpszCLSID);
02947         if( FAILED(hr) )
02948         {
02949             LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02950                 "StringFromIID failed - exit 0x%08x",hr));
02951
02952             //Clean-up
02953             pDispatch->Release();
02954             delete[] pSuperclassesIID;
02955             delete[] ppSuperclassesInfo;
02956             pSuperclassReg->Release();
02957
02958             return hr;
02959         }
02960
02961         //
02962         // Get BSTR for IID
02963         //
02964         BSTR bstrCLSID = SysAllocString( lpszCLSID );
02965         CoTaskMemFree( lpszCLSID ); // Clean-up
02966         if( NULL == bstrCLSID)
02967         {
02968             LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02969                 "SysAllocString failed - exit E_OUTOFMEMORY"));
02970
02971             // Clean-up
02972             pDispatch->Release();
02973             delete[] pSuperclassesIID;
02974             delete[] ppSuperclassesInfo;
02975             pSuperclassReg->Release();
02976
02977             return E_OUTOFMEMORY;
02978         }
02979
02980         //
02981         // Read information from registry
02982         //
02983
02984         pSuperclassReg->put_CLSID( bstrCLSID);
02985         hr = pSuperclassReg->GetTerminalSuperclassInfo();
02986         if( FAILED(hr) )
02987         {
02988             LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
02989                 "GetTerminalSuperclassInfo failed - exit 0x%08x",hr));
02990
02991             // Clean-up
02992             pDispatch->Release();
02993             delete[] pSuperclassesIID;
02994             delete[] ppSuperclassesInfo;
02995             pSuperclassReg->Release();
02996             SysFreeString( bstrCLSID);
02997
02998             return hr;
02999         }
03000
03001         //
03002         // Get the name
03003         //
03004         BSTR bstrName = NULL;
03005         pSuperclassReg->get_Name( &bstrName );
03006
03007         //
03008         // Create the information object
03009         //
03010         CComObject<CPlugTerminalSuperclassInfo>* pSuperclassInfo = NULL;
03011         hr = CComObject<CPlugTerminalSuperclassInfo>::CreateInstance(&pSuperclassInfo);
03012         if( FAILED(hr) )
03013         {
03014             LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - "
03015                 "CreateInstance failed - exit 0x%08x", hr));
03016
03017             //Clean-up
03018             pDispatch->Release();
03019             delete[] pSuperclassesIID;
03020             delete[] ppSuperclassesInfo;
03021             pSuperclassReg->Release();
03022             SysFreeString( bstrCLSID );
03023             SysFreeString( bstrName );
03024
03025             return hr;
03026         }
03027
03028         //
03029         // Get ITPluggableTerminalSuperclassInfo from this superclass
03030         //
03031
03032         pSuperclassInfo->QueryInterface(
03033             IID_ITPluggableTerminalSuperclassInfo,
03034             (void**)&ppSuperclassesInfo[dwIndex]
03035             );
03036
03037         //
03038         // Set the fields
03039         //
03040
03041         pSuperclassInfo->put_Name( bstrName);
03042         pSuperclassInfo->put_CLSID( bstrCLSID );
03043
03044         //
03045         // Clean-up
03046         //
03047         SysFreeString( bstrCLSID );
03048         SysFreeString( bstrName );
03049     }
03050
03051
03052     //
03053     // Clean-up the IIDs array
03054     //
03055
03056     pSuperclassReg->Release();
03057     delete[] pSuperclassesIID;
03058
03059     //
03060     // Init the collection using an iterator -- pointers to the beginning and
03061     // the ending element plus one. If it succeeds, this method addrefs each
03062     // element of ppterminals by querying for IDispatch.
03063     //
03064
03065     hr = pCollection->Initialize( dwNumSuperclasses,
03066                                   ppSuperclassesInfo,
03067                                   ppSuperclassesInfo + dwNumSuperclasses );
03068
03069     if( FAILED(hr) )
03070     {
03071         LOG((MSP_ERROR, "CMSPAddress::get_PluggableSuperclasses - exit "
03072             "pCollection->Initialize failed. returns 0x%08x", hr));
03073
03074         delete[] ppSuperclassesInfo;
03075         pDispatch->Release();
03076
03077         return hr;
03078     }
03079
03080     //
03081     // put the IDispatch interface pointer into the variant
03082     //
03083
03084     LOG((MSP_INFO, "CMSPAddress::get_PluggableSuperclasses - "
03085         "placing IDispatch value %08x in variant", pDispatch));
03086
03087     VariantInit(pVariant);
03088     pVariant->vt = VT_DISPATCH;
03089     pVariant->pdispVal = pDispatch;
03090
03091     LOG((MSP_TRACE, "CMSPAddress::get_PluggableSuperclasses - exit S_OK"));
03092
03093     return S_OK;
03094 }
03095
03096 STDMETHODIMP CMSPAddress::EnumeratePluggableSuperclasses(
03097     OUT IEnumPluggableSuperclassInfo** ppSuperclassEnumerator
03098     )
03099 {
03100     LOG((MSP_TRACE,
03101         "CMSPAddress::EnumeratePluggableSuperclasses - enter"));
03102
03103     //
03104     // Check parameters.
03105     //
03106
03107     if ( MSPB_IsBadWritePtr(ppSuperclassEnumerator, sizeof(IEnumPluggableTerminalClassInfo*) ) )
03108     {
03109         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03110             "bad pointer argument - exit E_POINTER"));
03111
03112         return E_POINTER;
03113     }
03114
03115     //
03116     // Get ITTemrinalManager2
03117     //
03118
03119     ITTerminalManager2* pTermMgr2 = NULL;
03120     HRESULT hr = E_FAIL;
03121     hr = m_pITTerminalManager->QueryInterface(
03122         IID_ITTerminalManager2, (void**)&pTermMgr2);
03123
03124     if( FAILED(hr) )
03125     {
03126         LOG((MSP_ERROR,
03127             "CMSPAddress::EnumeratePluggableSuperclasses - "
03128             "QI for ITTerminalManager2 failed - returning 0x%08x", hr));
03129         return hr;
03130     }
03131
03132     //
03133     // Find out how many superclasses are available.
03134     //
03135
03136     DWORD   dwNumSuperclasses = 0;
03137
03138     hr = pTermMgr2->GetPluggableSuperclasses(
03139             &dwNumSuperclasses,
03140             NULL);
03141
03142     if ( FAILED(hr) )
03143     {
03144         // Clean-up
03145         pTermMgr2->Release();
03146
03147         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03148             "can't get number of terminals - exit 0x%08x", hr));
03149
03150         return hr;
03151     }
03152
03153     //
03154     // Allocate an array of IID.
03155     //
03156
03157     IID* pSuperclassesIID = new IID[dwNumSuperclasses];
03158     if ( pSuperclassesIID == NULL )
03159     {
03160         // Clean-up
03161         pTermMgr2->Release();
03162
03163         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03164             "can't allocate IIDs array - exit E_OUTOFMEMORY"));
03165
03166         return E_OUTOFMEMORY;
03167     }
03168
03169     //
03170     // Fill in the array with actual pointers. We must do this before
03171     // initializing the enumerator, because the enumerator may want to
03172     // addref the interface pointers during initialize.
03173     //
03174
03175     hr = pTermMgr2->GetPluggableSuperclasses(
03176             &dwNumSuperclasses,
03177             pSuperclassesIID
03178             );
03179
03180     //
03181     // Clean-up
03182     //
03183
03184     pTermMgr2->Release();
03185
03186     if ( FAILED(hr) )
03187     {
03188         //Clean-up
03189         delete[] pSuperclassesIID;
03190
03191         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03192             "can't get IIDs - exit 0x%08x", hr));
03193
03194         return hr;
03195     }
03196
03197     //
03198     // Allocate an array of ITPluggableTerminalSuperclassInfo
03199     //
03200     typedef ITPluggableTerminalSuperclassInfo* SuperclassPtr; // MS parser
03201     SuperclassPtr * ppSuperclassesInfo = new SuperclassPtr[dwNumSuperclasses];
03202     if ( ppSuperclassesInfo == NULL )
03203     {
03204         // Clean-up
03205         delete[] pSuperclassesIID;
03206
03207         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03208             "can't allocate SuperclassPtr array - exit E_OUTOFMEMORY"));
03209
03210         return E_OUTOFMEMORY;
03211     }
03212
03213     //
03214     // Get ITPluggableTerminalSuperclassRegistration interface
03215     //
03216
03217     ITPluggableTerminalSuperclassRegistration* pSuperclassReg = NULL;
03218     hr = CoCreateInstance(
03219         CLSID_PluggableSuperclassRegistration,
03220         NULL,
03221         CLSCTX_INPROC_SERVER,
03222         IID_ITPluggableTerminalSuperclassRegistration,
03223         (void**)&pSuperclassReg
03224         );
03225     if( FAILED(hr) )
03226     {
03227         // Clean-up
03228         delete[] pSuperclassesIID;
03229         delete[] ppSuperclassesInfo;
03230
03231         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03232             "QI for ITPluggableTerminalSuperclassRegistration - exit 0x%08x",hr));
03233
03234         return hr;
03235     }
03236
03237     //
03238     // Create the objects
03239     //
03240
03241     for(DWORD dwIndex = 0; dwIndex < dwNumSuperclasses; dwIndex++)
03242     {
03243         //
03244         // Get the string from the IID
03245         //
03246         LPOLESTR lpszCLSID = NULL;
03247         hr = StringFromIID( pSuperclassesIID[dwIndex], &lpszCLSID);
03248         if( FAILED(hr) )
03249         {
03250             //Clean-up
03251             delete[] pSuperclassesIID;
03252             delete[] ppSuperclassesInfo;
03253             pSuperclassReg->Release();
03254
03255             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03256                 "StringFromIID failed - exit 0x%08x",hr));
03257
03258             return hr;
03259         }
03260
03261         //
03262         // Get BSTR for IID
03263         //
03264         BSTR bstrCLSID = SysAllocString( lpszCLSID );
03265         CoTaskMemFree( lpszCLSID ); // Clean-up
03266         if( NULL == bstrCLSID)
03267         {
03268             //Clean-up
03269             delete[] pSuperclassesIID;
03270             delete[] ppSuperclassesInfo;
03271             pSuperclassReg->Release();
03272
03273             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03274                 "SysAllocString failed - exit E_OUTOFMEMORY"));
03275
03276             return E_OUTOFMEMORY;
03277         }
03278
03279         //
03280         // Read information from registry
03281         //
03282
03283         pSuperclassReg->put_CLSID( bstrCLSID);
03284         hr = pSuperclassReg->GetTerminalSuperclassInfo();
03285         if( FAILED(hr) )
03286         {
03287             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03288                 "GetTerminalSuperclassInfo failed - exit 0x%08x",hr));
03289
03290             // Clean-up
03291             delete[] pSuperclassesIID;
03292             delete[] ppSuperclassesInfo;
03293             pSuperclassReg->Release();
03294             SysFreeString( bstrCLSID);
03295
03296             return hr;
03297         }
03298
03299         //
03300         // Get the name
03301         //
03302         BSTR bstrName = NULL;
03303         pSuperclassReg->get_Name( &bstrName );
03304
03305         //
03306         // Create the information object
03307         //
03308         CComObject<CPlugTerminalSuperclassInfo>* pSuperclassInfo = NULL;
03309         hr = CComObject<CPlugTerminalSuperclassInfo>::CreateInstance(&pSuperclassInfo);
03310         if( FAILED(hr) )
03311         {
03312             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03313                 "CreateInstance failed - exit 0x%08x", hr));
03314
03315             // Clean-up
03316             delete[] pSuperclassesIID;
03317             delete[] ppSuperclassesInfo;
03318             pSuperclassReg->Release();
03319             SysFreeString( bstrCLSID );
03320             SysFreeString( bstrName );
03321
03322             return hr;
03323         }
03324
03325         //
03326         // Get ITPluggableTerminalSuperclassInfo from this superclass
03327         //
03328
03329         pSuperclassInfo->QueryInterface(
03330             IID_ITPluggableTerminalSuperclassInfo,
03331             (void**)&ppSuperclassesInfo[dwIndex]
03332             );
03333
03334         //
03335         // Set the fields
03336         //
03337
03338         pSuperclassInfo->put_Name( bstrName);
03339         pSuperclassInfo->put_CLSID( bstrCLSID );
03340
03341         //
03342         // Clean-up
03343         //
03344         SysFreeString( bstrCLSID );
03345         SysFreeString( bstrName );
03346     }
03347
03348
03349     //
03350     // Clean-up the IIDs array
03351     //
03352
03353     pSuperclassReg->Release();
03354     delete[] pSuperclassesIID;
03355
03356     //
03357     // Create the enumerator object.
03358     //
03359
03360     typedef CSafeComEnum<IEnumPluggableSuperclassInfo,
03361                      &IID_IEnumPluggableSuperclassInfo,
03362                      ITPluggableTerminalSuperclassInfo*,
03363                      _CopyInterface<ITPluggableTerminalSuperclassInfo> > CEnumerator;
03364
03365     CComObject<CEnumerator> *pEnum = NULL;
03366
03367     hr = CComObject<CEnumerator>::CreateInstance(&pEnum);
03368
03369     if ( FAILED(hr) )
03370     {
03371         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03372             "can't create enumerator - exit 0x%08x", hr));
03373
03374         delete[] ppSuperclassesInfo;
03375         return hr;
03376     }
03377
03378     //
03379     // Query for the desired interface.
03380     //
03381
03382     hr = pEnum->_InternalQueryInterface(
03383         IID_IEnumPluggableSuperclassInfo,
03384         (void**) ppSuperclassEnumerator
03385         );
03386
03387     if ( FAILED(hr) )
03388     {
03389         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03390             "can't get enumerator interface - exit 0x%08x", hr));
03391
03392         delete pEnum;
03393         delete[] ppSuperclassesInfo;
03394
03395         return hr;
03396     }
03397
03398     //
03399     // Init the enumerator object.
03400     //
03401
03402     hr = pEnum->Init(ppSuperclassesInfo,
03403                      ppSuperclassesInfo + dwNumSuperclasses,
03404                      NULL,
03405                      AtlFlagTakeOwnership);
03406
03407     if ( FAILED(hr) )
03408     {
03409         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableSuperclasses - "
03410             "can't init enumerator - exit 0x%08x", hr));
03411
03412         (*ppSuperclassEnumerator)->Release();
03413         delete[] ppSuperclassesInfo;
03414
03415         return hr;
03416     }
03417
03418     LOG((MSP_TRACE, "CMSPAddress::EnumeratePluggableSuperclasses - exit S_OK"));
03419
03420     return S_OK;
03421 }
03422
03423 STDMETHODIMP CMSPAddress::get_PluggableTerminalClasses(
03424     IN  BSTR bstrTerminalSuperclass,
03425     IN  long lMediaType,
03426     OUT VARIANT * pVariant
03427     )
03428 {
03429     LOG((MSP_TRACE,
03430         "CMSPAddress::get_PluggableTerminalClasses - enter"));
03431
03432     //
03433     // Check parameters.
03434     //
03435
03436     if ( MSPB_IsBadWritePtr(pVariant, sizeof(VARIANT) ) )
03437     {
03438         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03439             "bad pointer argument - exit E_POINTER"));
03440
03441         return E_POINTER;
03442     }
03443
03444     if( IsBadStringPtr( bstrTerminalSuperclass, (UINT)-1))
03445     {
03446         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03447             "bad pointer argument - exit E_INVALIDARG"));
03448
03449         return E_INVALIDARG;
03450     }
03451
03452     IID iidSuperclass = IID_NULL;
03453     HRESULT hr = IIDFromString( bstrTerminalSuperclass, &iidSuperclass);
03454     if( FAILED(hr) )
03455     {
03456         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03457             "bad pointer argument - exit E_INVALIDARG"));
03458
03459         return E_INVALIDARG;
03460     }
03461
03462     //
03463     // Get ITTemrinalManager2
03464     //
03465
03466     ITTerminalManager2* pTermMgr2 = NULL;
03467     hr = m_pITTerminalManager->QueryInterface(
03468         IID_ITTerminalManager2, (void**)&pTermMgr2);
03469
03470     if( FAILED(hr) )
03471     {
03472         LOG((MSP_ERROR,
03473             "CMSPAddress::get_PluggableTerminalClasses - "
03474             "QI for ITTerminalManager2 failed - returning 0x%08x", hr));
03475         return hr;
03476     }
03477
03478     //
03479     // Create the collection object - see mspcoll.h
03480     //
03481
03482     typedef CTapiIfCollection< ITPluggableTerminalClassInfo* > ClassCollection;
03483     CComObject<ClassCollection> * pCollection;
03484     hr = CComObject<ClassCollection>::CreateInstance( &pCollection );
03485
03486     if ( FAILED(hr) )
03487     {
03488         //Clean-up
03489         pTermMgr2->Release();
03490
03491         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03492             "can't create collection - exit 0x%08x", hr));
03493
03494         return hr;
03495     }
03496
03497     //
03498     // Get the Collection's IDispatch interface
03499     //
03500
03501     IDispatch * pDispatch;
03502     hr = pCollection->_InternalQueryInterface(
03503         IID_IDispatch,
03504         (void **) &pDispatch );
03505
03506     if ( FAILED(hr) )
03507     {
03508         // Clean-up
03509         pTermMgr2->Release();
03510         delete pCollection;
03511
03512         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03513             "QI for IDispatch on collection failed - exit 0x%08x", hr));
03514
03515         return hr;
03516     }
03517
03518     //
03519     // Find out how many superclasses are available.
03520     //
03521
03522     DWORD   dwNumClasses = 0;
03523
03524     hr = pTermMgr2->GetPluggableTerminalClasses(
03525             iidSuperclass,
03526             lMediaType,
03527             &dwNumClasses,
03528             NULL);
03529
03530     if ( FAILED(hr) )
03531     {
03532         //Clean-up
03533         pTermMgr2->Release();
03534         pDispatch->Release();
03535
03536         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03537             "can't get number of terminals - exit 0x%08x", hr));
03538
03539         return hr;
03540     }
03541
03542     //
03543     // Allocate an array of IID.
03544     //
03545
03546     IID* pClassesIID = new IID[dwNumClasses];
03547     if ( pClassesIID == NULL )
03548     {
03549         //Clean-up
03550         pTermMgr2->Release();
03551         pDispatch->Release();
03552
03553         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03554             "can't allocate IIDs array - exit E_OUTOFMEMORY"));
03555
03556         return E_OUTOFMEMORY;
03557     }
03558
03559     //
03560     // Fill in the array with actual pointers. We must do this before
03561     // initializing the enumerator, because the enumerator may want to
03562     // addref the interface pointers during initialize.
03563     //
03564
03565     hr = pTermMgr2->GetPluggableTerminalClasses(
03566             iidSuperclass,
03567             lMediaType,
03568             &dwNumClasses,
03569             pClassesIID
03570             );
03571
03572     //
03573     // Clean-up
03574     //
03575
03576     pTermMgr2->Release();
03577
03578     if ( FAILED(hr) )
03579     {
03580         //Clean-up
03581         pDispatch->Release();
03582         delete[] pClassesIID;
03583
03584         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03585             "can't get IIDs - exit 0x%08x", hr));
03586
03587         return hr;
03588     }
03589
03590     //
03591     // Allocate an array of ITPluggableTerminalClassInfo
03592     //
03593     typedef ITPluggableTerminalClassInfo* ClassPtr;
03594     ClassPtr * ppClassesInfo = new ClassPtr[dwNumClasses];
03595     if ( ppClassesInfo == NULL )
03596     {
03597         //Clean-up
03598         pDispatch->Release();
03599         delete[] pClassesIID;
03600
03601         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03602             "can't allocate ClassPtr array - exit E_OUTOFMEMORY"));
03603
03604         return E_OUTOFMEMORY;
03605     }
03606
03607     //
03608     // Get ITPluggableTerminalClassRegistration interface
03609     //
03610
03611     ITPluggableTerminalClassRegistration* pClassReg = NULL;
03612     hr = CoCreateInstance(
03613         CLSID_PluggableTerminalRegistration,
03614         NULL,
03615         CLSCTX_INPROC_SERVER,
03616         IID_ITPluggableTerminalClassRegistration,
03617         (void**)&pClassReg
03618         );
03619     if( FAILED(hr) )
03620     {
03621         //Clean-up
03622         pDispatch->Release();
03623         delete[] pClassesIID;
03624         delete[] ppClassesInfo;
03625
03626         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03627             "QI for ITPluggableTerminalClassRegistration - exit 0x%08x",hr));
03628
03629         return hr;
03630     }
03631
03632     //
03633     // Create the objects
03634     //
03635
03636     for(DWORD dwIndex = 0; dwIndex < dwNumClasses; dwIndex++)
03637     {
03638         //
03639         // Get the string from the IID
03640         //
03641         LPOLESTR lpszPublicCLSID = NULL;
03642         hr = StringFromIID( pClassesIID[dwIndex], &lpszPublicCLSID);
03643         if( FAILED(hr) )
03644         {
03645             //Clean-up
03646             pDispatch->Release();
03647             delete[] pClassesIID;
03648             delete[] ppClassesInfo;
03649             pClassReg->Release();
03650
03651             LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03652                 "StringFromIID failed - exit 0x%08x",hr));
03653
03654             return hr;
03655         }
03656
03657         //
03658         // Get BSTR for IID
03659         //
03660         BSTR bstrPublicCLSID = SysAllocString( lpszPublicCLSID );
03661         CoTaskMemFree( lpszPublicCLSID ); // Clean-up
03662         if( NULL == bstrPublicCLSID)
03663         {
03664             //Clean-up
03665             pDispatch->Release();
03666             delete[] pClassesIID;
03667             delete[] ppClassesInfo;
03668             pClassReg->Release();
03669
03670             LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03671                 "SysAllocString failed - exit E_OUTOFMEMORY"));
03672
03673             return E_OUTOFMEMORY;
03674         }
03675
03676         //
03677         // Read information from registry
03678         //
03679
03680         pClassReg->put_TerminalClass( bstrPublicCLSID);
03681         hr = pClassReg->GetTerminalClassInfo(
03682             bstrTerminalSuperclass);
03683         if( FAILED(hr) )
03684         {
03685             // Clean-up
03686             pDispatch->Release();
03687             delete[] pClassesIID;
03688             delete[] ppClassesInfo;
03689             pClassReg->Release();
03690             SysFreeString( bstrPublicCLSID);
03691
03692             LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03693                 "GetTerminalInfo failed - exit 0x%08x",hr));
03694
03695             return hr;
03696         }
03697
03698         //
03699         // Get the name
03700         //
03701         BSTR bstrName = NULL;
03702         pClassReg->get_Name( &bstrName );
03703         BSTR bstrCompany = NULL;
03704         pClassReg->get_Company( &bstrCompany );
03705         BSTR bstrVersion = NULL;
03706         pClassReg->get_Version( &bstrVersion );
03707         BSTR bstrCLSID = NULL;
03708         pClassReg->get_CLSID( &bstrCLSID );
03709         TMGR_DIRECTION Direction = TMGR_TD_CAPTURE;
03710         pClassReg->get_Direction( &Direction );
03711         long lMediaType = 0;
03712         pClassReg->get_MediaTypes( &lMediaType );
03713
03714         //
03715         // Create the information object
03716         //
03717         CComObject<CPlugTerminalClassInfo>* pClassInfo = NULL;
03718         hr = CComObject<CPlugTerminalClassInfo>::CreateInstance(&pClassInfo);
03719         if( FAILED(hr) )
03720         {
03721             //Clean-up
03722             pDispatch->Release();
03723             delete[] pClassesIID;
03724             delete[] ppClassesInfo;
03725             pClassReg->Release();
03726             SysFreeString( bstrPublicCLSID );
03727             SysFreeString( bstrName );
03728             SysFreeString( bstrCompany );
03729             SysFreeString( bstrVersion );
03730             SysFreeString( bstrCLSID );
03731
03732             LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - "
03733                 "CreateInstance failed - exit 0x%08x", hr));
03734
03735             return hr;
03736         }
03737
03738         //
03739         // Get ITPluggableTerminalClassInfo from this superclass
03740         //
03741
03742         pClassInfo->QueryInterface(
03743             IID_ITPluggableTerminalClassInfo,
03744             (void**)&ppClassesInfo[dwIndex]
03745             );
03746
03747         //
03748         // Set the fields
03749         //
03750
03751         if( NULL == bstrName)
03752         {
03753             bstrName = SysAllocString(L"");
03754         }
03755         pClassInfo->put_Name( bstrName);
03756         pClassInfo->put_TerminalClass( bstrPublicCLSID );
03757         if( NULL == bstrCompany)
03758         {
03759             bstrCompany = SysAllocString(L"");
03760         }
03761         pClassInfo->put_Company( bstrCompany );
03762         if( NULL == bstrVersion)
03763         {
03764             bstrVersion = SysAllocString(L"");
03765         }
03766         pClassInfo->put_Version( bstrVersion );
03767         if( NULL == bstrCLSID)
03768         {
03769             LPOLESTR lpszCLSID = NULL;
03770             StringFromCLSID( CLSID_NULL, &lpszCLSID);
03771             bstrCLSID = SysAllocString(lpszCLSID);
03772             CoTaskMemFree( lpszCLSID);
03773         }
03774         pClassInfo->put_CLSID( bstrCLSID );
03775         TERMINAL_DIRECTION TermDirection = TD_CAPTURE;
03776         switch( Direction )
03777         {
03778         case TMGR_TD_RENDER:
03779             TermDirection = TD_RENDER;
03780             break;
03781         case TMGR_TD_BOTH:
03782             TermDirection = TD_BIDIRECTIONAL;
03783             break;
03784         case TMGR_TD_CAPTURE:
03785         default:
03786             TermDirection = TD_CAPTURE;
03787             break;
03788         }
03789         pClassInfo->put_Direction( TermDirection );
03790         pClassInfo->put_MediaTypes( lMediaType );
03791
03792         //
03793         // Clean-up
03794         //
03795         SysFreeString( bstrPublicCLSID );
03796         SysFreeString( bstrName );
03797         SysFreeString( bstrCompany );
03798         SysFreeString( bstrVersion );
03799         SysFreeString( bstrCLSID );
03800     }
03801
03802
03803     //
03804     // Clean-up the IIDs array
03805     //
03806
03807     pClassReg->Release();
03808     delete[] pClassesIID;
03809
03810     //
03811     // Init the collection using an iterator -- pointers to the beginning and
03812     // the ending element plus one. If it succeeds, this method addrefs each
03813     // element of ppterminals by querying for IDispatch.
03814     //
03815
03816     hr = pCollection->Initialize( dwNumClasses,
03817                                   ppClassesInfo,
03818                                   ppClassesInfo + dwNumClasses );
03819
03820     if( FAILED(hr) )
03821     {
03822         LOG((MSP_ERROR, "CMSPAddress::get_PluggableTerminalClasses - exit "
03823             "pCollection->Initialize failed. returns 0x%08x", hr));
03824
03825         delete[] ppClassesInfo;
03826         pDispatch->Release();
03827
03828         return hr;
03829     }
03830
03831     //
03832     // put the IDispatch interface pointer into the variant
03833     //
03834
03835     LOG((MSP_INFO, "CMSPAddress::get_PluggableTerminalClasses - "
03836         "placing IDispatch value %08x in variant", pDispatch));
03837
03838     VariantInit(pVariant);
03839     pVariant->vt = VT_DISPATCH;
03840     pVariant->pdispVal = pDispatch;
03841
03842     LOG((MSP_TRACE, "CMSPAddress::get_PluggableTerminalClasses - exit S_OK"));
03843
03844     return S_OK;
03845 }
03846
03847 STDMETHODIMP CMSPAddress::EnumeratePluggableTerminalClasses(
03848     IN  CLSID iidTerminalSuperclass,
03849     IN  long lMediaType,
03850     OUT IEnumPluggableTerminalClassInfo ** ppClassEnumerator
03851     )
03852 {
03853     LOG((MSP_TRACE,
03854         "CMSPAddress::EnumeratePluggableTerminalClasses - enter"));
03855
03856     //
03857     // Check parameters.
03858     //
03859
03860     if ( MSPB_IsBadWritePtr(ppClassEnumerator, sizeof(IEnumPluggableTerminalClassInfo *) ) )
03861     {
03862         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03863             "bad pointer argument - exit E_POINTER"));
03864
03865         return E_POINTER;
03866     }
03867
03868     LPOLESTR lpszCLSID = NULL;
03869     HRESULT hr = StringFromCLSID( iidTerminalSuperclass, &lpszCLSID);
03870     if( FAILED(hr) )
03871     {
03872          LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03873             "StringFromCLSID failed - exit 0x%08x", hr));
03874
03875         return hr;
03876     }
03877
03878     BSTR bstrTerminalSuperclass = SysAllocString( lpszCLSID );
03879
03880     // Clean-up
03881     CoTaskMemFree(lpszCLSID);
03882     lpszCLSID = NULL;
03883
03884
03885     if( NULL == bstrTerminalSuperclass )
03886     {
03887          LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03888             "SysAllocString failed - exit E_OUTOFMEMORY"));
03889
03890         return E_OUTOFMEMORY;
03891     }
03892
03893     //
03894     // Get ITTemrinalManager2
03895     //
03896
03897     ITTerminalManager2* pTermMgr2 = NULL;
03898     hr = m_pITTerminalManager->QueryInterface(
03899         IID_ITTerminalManager2, (void**)&pTermMgr2);
03900
03901     if( FAILED(hr) )
03902     {
03903         //Clean-up
03904         SysFreeString( bstrTerminalSuperclass );
03905
03906         LOG((MSP_ERROR,
03907             "CMSPAddress::EnumeratePluggableTerminalClasses - "
03908             "QI for ITTerminalManager2 failed - returning 0x%08x", hr));
03909         return hr;
03910     }
03911
03912     //
03913     // Find out how many superclasses are available.
03914     //
03915
03916     DWORD   dwNumClasses = 0;
03917
03918     hr = pTermMgr2->GetPluggableTerminalClasses(
03919             iidTerminalSuperclass,
03920             lMediaType,
03921             &dwNumClasses,
03922             NULL);
03923
03924     if ( FAILED(hr) )
03925     {
03926         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03927             "can't get number of terminals - exit 0x%08x", hr));
03928
03929         // Clean-up
03930         SysFreeString( bstrTerminalSuperclass );
03931         pTermMgr2->Release();
03932
03933         return hr;
03934     }
03935
03936     //
03937     // Allocate an array of IID.
03938     //
03939
03940     IID* pClassesIID = new IID[dwNumClasses];
03941     if ( pClassesIID == NULL )
03942     {
03943         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03944             "can't allocate IIDs array - exit E_OUTOFMEMORY"));
03945
03946         // Clean-up
03947         SysFreeString( bstrTerminalSuperclass );
03948         pTermMgr2->Release();
03949
03950         return E_OUTOFMEMORY;
03951     }
03952
03953     //
03954     // Fill in the array with actual pointers. We must do this before
03955     // initializing the enumerator, because the enumerator may want to
03956     // addref the interface pointers during initialize.
03957     //
03958
03959     hr = pTermMgr2->GetPluggableTerminalClasses(
03960             iidTerminalSuperclass,
03961             lMediaType,
03962             &dwNumClasses,
03963             pClassesIID
03964             );
03965
03966     //
03967     // Clean-up
03968     //
03969
03970     pTermMgr2->Release();
03971
03972     if ( FAILED(hr) )
03973     {
03974         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03975             "can't get IIDs - exit 0x%08x", hr));
03976
03977         // Clean-up
03978         SysFreeString( bstrTerminalSuperclass );
03979         delete[] pClassesIID;
03980
03981         return hr;
03982     }
03983
03984     //
03985     // Allocate an array of ITPluggableTerminalClassInfo
03986     //
03987     typedef ITPluggableTerminalClassInfo* ClassPtr;
03988     ClassPtr * ppClassesInfo = new ClassPtr[dwNumClasses];
03989     if ( ppClassesInfo == NULL )
03990     {
03991         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
03992             "can't allocate ClassPtr array - exit E_OUTOFMEMORY"));
03993
03994         // Clean-up
03995         SysFreeString( bstrTerminalSuperclass );
03996         delete[] pClassesIID;
03997
03998         return E_OUTOFMEMORY;
03999     }
04000
04001     //
04002     // Get ITPluggableTerminalClassRegistration interface
04003     //
04004
04005     ITPluggableTerminalClassRegistration* pClassReg = NULL;
04006     hr = CoCreateInstance(
04007         CLSID_PluggableTerminalRegistration,
04008         NULL,
04009         CLSCTX_INPROC_SERVER,
04010         IID_ITPluggableTerminalClassRegistration,
04011         (void**)&pClassReg
04012         );
04013     if( FAILED(hr) )
04014     {
04015         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04016             "QI for ITPluggableTerminalClassRegistration - exit 0x%08x",hr));
04017
04018         // Clean-up
04019         SysFreeString( bstrTerminalSuperclass );
04020         delete[] ppClassesInfo;
04021         delete[] pClassesIID;
04022
04023         return hr;
04024     }
04025
04026     //
04027     // Create the objects
04028     //
04029
04030     for(DWORD dwIndex = 0; dwIndex < dwNumClasses; dwIndex++)
04031     {
04032         //
04033         // Get the string from the IID
04034         //
04035         LPOLESTR lpszPublicCLSID = NULL;
04036         hr = StringFromIID( pClassesIID[dwIndex], &lpszPublicCLSID);
04037         if( FAILED(hr) )
04038         {
04039             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04040                 "StringFromIID failed - exit 0x%08x",hr));
04041
04042             // Clean-up
04043             SysFreeString( bstrTerminalSuperclass );
04044             delete[] pClassesIID;
04045             delete[] ppClassesInfo;
04046             pClassReg->Release();
04047
04048             return hr;
04049         }
04050
04051         //
04052         // Get BSTR for IID
04053         //
04054         BSTR bstrPublicCLSID = SysAllocString( lpszPublicCLSID );
04055         CoTaskMemFree( lpszPublicCLSID ); // Clean-up
04056         if( NULL == bstrPublicCLSID)
04057         {
04058             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04059                 "SysAllocString failed - exit E_OUTOFMEMORY"));
04060
04061
04062             // Clean-up
04063             SysFreeString( bstrTerminalSuperclass );
04064             delete[] pClassesIID;
04065             delete[] ppClassesInfo;
04066             pClassReg->Release();
04067
04068             return E_OUTOFMEMORY;
04069         }
04070
04071         //
04072         // Read information from registry
04073         //
04074
04075         pClassReg->put_TerminalClass( bstrPublicCLSID);
04076         hr = pClassReg->GetTerminalClassInfo(
04077             bstrTerminalSuperclass);
04078         if( FAILED(hr) )
04079         {
04080             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04081                 "GetTerminalInfo failed - exit 0x%08x",hr));
04082
04083             // Clean-up
04084             SysFreeString( bstrTerminalSuperclass );
04085             delete[] pClassesIID;
04086             delete[] ppClassesInfo;
04087             pClassReg->Release();
04088             SysFreeString( bstrPublicCLSID);
04089
04090             return hr;
04091         }
04092
04093         //
04094         // Get the name
04095         //
04096         BSTR bstrName = NULL;
04097         pClassReg->get_Name( &bstrName );
04098         BSTR bstrCompany = NULL;
04099         pClassReg->get_Company( &bstrCompany );
04100         BSTR bstrVersion = NULL;
04101         pClassReg->get_Version( &bstrVersion );
04102         BSTR bstrCLSID = NULL;
04103         pClassReg->get_CLSID( &bstrCLSID );
04104         TMGR_DIRECTION Direction = TMGR_TD_CAPTURE;
04105         pClassReg->get_Direction( &Direction );
04106         long lMediaType = 0;
04107         pClassReg->get_MediaTypes( &lMediaType );
04108
04109         //
04110         // Create the information object
04111         //
04112         CComObject<CPlugTerminalClassInfo>* pClassInfo = NULL;
04113         hr = CComObject<CPlugTerminalClassInfo>::CreateInstance(&pClassInfo);
04114         if( FAILED(hr) )
04115         {
04116             LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04117                 "CreateInstance failed - exit 0x%08x", hr));
04118
04119             // Clean-up
04120             SysFreeString( bstrTerminalSuperclass );
04121             delete[] pClassesIID;
04122             delete[] ppClassesInfo;
04123             pClassReg->Release();
04124             SysFreeString( bstrPublicCLSID );
04125             SysFreeString( bstrName );
04126             SysFreeString( bstrCompany );
04127             SysFreeString( bstrVersion );
04128             SysFreeString( bstrCLSID );
04129
04130             return hr;
04131         }
04132
04133         //
04134         // Get ITPluggableTerminalClassInfo from this superclass
04135         //
04136
04137         pClassInfo->QueryInterface(
04138             IID_ITPluggableTerminalClassInfo,
04139             (void**)&ppClassesInfo[dwIndex]
04140             );
04141
04142         //
04143         // Set the fields
04144         //
04145
04146         if( NULL == bstrName)
04147         {
04148             bstrName = SysAllocString(L"");
04149         }
04150         pClassInfo->put_Name( bstrName);
04151         pClassInfo->put_TerminalClass( bstrPublicCLSID );
04152         if( NULL == bstrCompany)
04153         {
04154             bstrCompany = SysAllocString(L"");
04155         }
04156         pClassInfo->put_Company( bstrCompany );
04157         if( NULL == bstrVersion)
04158         {
04159             bstrVersion = SysAllocString(L"");
04160         }
04161         pClassInfo->put_Version( bstrVersion );
04162         if( NULL == bstrCLSID)
04163         {
04164             LPOLESTR lpszCLSID = NULL;
04165             StringFromCLSID( CLSID_NULL, &lpszCLSID);
04166             bstrCLSID = SysAllocString(lpszCLSID);
04167             CoTaskMemFree( lpszCLSID);
04168         }
04169         pClassInfo->put_CLSID( bstrCLSID );
04170         TERMINAL_DIRECTION TermDirection = TD_CAPTURE;
04171         switch( Direction )
04172         {
04173         case TMGR_TD_RENDER:
04174             TermDirection = TD_RENDER;
04175             break;
04176         case TMGR_TD_BOTH:
04177             TermDirection = TD_BIDIRECTIONAL;
04178             break;
04179         case TMGR_TD_CAPTURE:
04180         default:
04181             TermDirection = TD_CAPTURE;
04182             break;
04183         }
04184         pClassInfo->put_Direction( TermDirection );
04185         pClassInfo->put_MediaTypes( lMediaType );
04186
04187         //
04188         // Clean-up
04189         //
04190         SysFreeString( bstrPublicCLSID );
04191         SysFreeString( bstrName );
04192         SysFreeString( bstrCompany );
04193         SysFreeString( bstrVersion );
04194         SysFreeString( bstrCLSID );
04195     }
04196
04197
04198     //
04199     // Clean-up the IIDs array
04200     //
04201
04202     SysFreeString( bstrTerminalSuperclass );
04203     delete[] pClassesIID;
04204     pClassReg->Release();
04205
04206     //
04207     // Create the enumerator object.
04208     //
04209
04210     typedef CSafeComEnum<IEnumPluggableTerminalClassInfo,
04211                      &IID_IEnumPluggableTerminalClassInfo,
04212                      ITPluggableTerminalClassInfo*,
04213                      _CopyInterface<ITPluggableTerminalClassInfo> > CEnumerator;
04214
04215     CComObject<CEnumerator> *pEnum = NULL;
04216
04217     hr = CComObject<CEnumerator>::CreateInstance(&pEnum);
04218
04219     if ( FAILED(hr) )
04220     {
04221         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04222             "can't create enumerator - exit 0x%08x", hr));
04223
04224         delete[] ppClassesInfo;
04225         return hr;
04226     }
04227
04228     //
04229     // Query for the desired interface.
04230     //
04231
04232     hr = pEnum->_InternalQueryInterface(
04233         IID_IEnumPluggableTerminalClassInfo,
04234         (void**) ppClassEnumerator
04235         );
04236
04237     if ( FAILED(hr) )
04238     {
04239         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04240             "can't get enumerator interface - exit 0x%08x", hr));
04241
04242         delete pEnum;
04243         delete[] ppClassesInfo;
04244
04245         return hr;
04246     }
04247
04248     //
04249     // Init the enumerator object.
04250     //
04251
04252     hr = pEnum->Init(ppClassesInfo,
04253                      ppClassesInfo + dwNumClasses,
04254                      NULL,
04255                      AtlFlagTakeOwnership);
04256
04257     if ( FAILED(hr) )
04258     {
04259         LOG((MSP_ERROR, "CMSPAddress::EnumeratePluggableTerminalClasses - "
04260             "can't init enumerator - exit 0x%08x", hr));
04261
04262         (*ppClassEnumerator)->Release();
04263         delete[] ppClassesInfo;
04264
04265         return hr;
04266     }
04267
04268     LOG((MSP_TRACE, "CMSPAddress::EnumeratePluggableTerminalClasses - exit S_OK"));
04269
04270     return S_OK;
04271 }
04272
04273 STDMETHODIMP CMSPAddress::GetEvent(
04274     IN OUT  DWORD *             pdwSize,
04275     OUT     BYTE *              pBuffer
04276     )
04277 /*++
04278
04279 Routine Description:
04280
04281 This method is called by TAPI3 to get detailed information about the
04282 event that just happened. TAPI3 will normally do this after its event
04283 is signaled. Locks the event list.
04284
04285 Arguments:
04286
04287 pMSPEvent
04288     The MSP_EVENT
04289
04290 pdwSize
04291     Pointer to a DWORD.  On entry, indicates the size in bytes of the
04292     buffer pointed to in pbuffer. On success, it will be filled in with
04293     the actual number of bytes returned.  If the buffer is not big enough,
04294     the method will return TAPI_E_NOTENOUGHMEMORY, and it will be filled
04295     in the with number of bytes needed.
04296
04297 pBuffer
04298     Event buffer filled in by MSP with the relevant events
04299
04300 Return Value:
04301
04302 S_OK
04303 E_OUTOFMEMORY
04304 TAPI_E_NOEVENT
04305 TAPI_E_NOTENOUGHMEMORY
04306
04307 --*/
04308 {
04309     // We trust TAPI3 not to give us bad pointers.
04310     _ASSERTE(!MSPB_IsBadWritePtr(pdwSize, sizeof (DWORD *)));
04311     _ASSERTE((*pdwSize == 0) ? TRUE :
04312         !MSPB_IsBadWritePtr(pBuffer, sizeof(BYTE) * (*pdwSize)));
04313
04314     LOG((MSP_TRACE, "CMSPAddress::GetEvent"));
04315
04316     CLock lock(m_EventDataLock);
04317
04318     if (IsListEmpty(&m_EventList))
04319     {
04320         return TAPI_E_NOEVENT;
04321     }
04322
04323     // retrieve first entry
04324     PLIST_ENTRY pLE = m_EventList.Flink;
04325
04326     // convert list entry to structure pointer
04327     PMSPEVENTITEM pItem = CONTAINING_RECORD(pLE, MSPEVENTITEM, Link);
04328
04329     if (pItem->MSPEventInfo.dwSize > *pdwSize)
04330     {
04331         *pdwSize = pItem->MSPEventInfo.dwSize;
04332         return TAPI_E_NOTENOUGHMEMORY;
04333     }
04334
04335     CopyMemory(pBuffer, &pItem->MSPEventInfo, pItem->MSPEventInfo.dwSize);
04336     *pdwSize = pItem->MSPEventInfo.dwSize;
04337
04338     // remove the first entry from the event list.
04339     RemoveHeadList(&m_EventList);
04340
04341     // free the memory.
04342     FreeEventItem(pItem);
04343
04344     return S_OK;
04345 }
04346
04347 HRESULT CMSPAddress::PostEvent(
04348         IN      MSPEVENTITEM *      pEventItem
04349         )
04350 /*++
04351
04352 Routine Description:
04353
04354 This method is called by MSPCalls to post an event to TAPI3. This method
04355 puts the event at the end of the event list and singals TAPI3.
04356 Locks the event list.
04357
04358
04359 Arguments:
04360
04361 EventItem
04362     The event to be queued.
04363
04364 Return Value:
04365
04366 S_OK
04367 E_OUTOFMEMORY
04368
04369 --*/
04370 {
04371     CLock lock(m_EventDataLock);
04372
04373     if (m_htEvent == NULL)
04374     {
04375         return E_UNEXPECTED;  // the address was shut down.
04376     }
04377
04378     InsertTailList(&m_EventList, &pEventItem->Link);
04379
04380     SetEvent(m_htEvent);
04381
04382     return S_OK;
04383 }
04384
04385 //////////////////////////////////////////////////////////////////////////////
04386 //////////////////////////////////////////////////////////////////////////////
04387 //////////////////////////////////////////////////////////////////////////////
04388 //////////////////////////////////////////////////////////////////////////////
04389 //////////////////////////////////////////////////////////////////////////////
04390 // OLE Automation wrappers
04391
04392
04393 STDMETHODIMP CMSPAddress::get_StaticTerminals (
04394         OUT  VARIANT * pVariant
04395         )
04396 {
04397     LOG((MSP_TRACE, "CMSPAddress::get_StaticTerminals - enter"));
04398
04399     //
04400     // Check parameters.
04401     //
04402
04403     if ( MSPB_IsBadWritePtr(pVariant, sizeof(VARIANT) ) )
04404     {
04405         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04406             "bad pointer argument - exit E_POINTER"));
04407
04408         return E_POINTER;
04409     }
04410
04411     //
04412     // create the collection object - see mspcoll.h
04413     //
04414
04415     typedef CTapiIfCollection< ITTerminal * > TerminalCollection;
04416     CComObject<TerminalCollection> * pCollection;
04417     HRESULT hr = CComObject<TerminalCollection>::CreateInstance( &pCollection );
04418
04419     if ( FAILED(hr) )
04420     {
04421         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04422             "can't create collection - exit 0x%08x", hr));
04423
04424         return hr;
04425     }
04426
04427     //
04428     // get the Collection's IDispatch interface
04429     //
04430
04431     IDispatch * pDispatch;
04432
04433     hr = pCollection->_InternalQueryInterface(IID_IDispatch,
04434                                               (void **) &pDispatch );
04435
04436     if ( FAILED(hr) )
04437     {
04438         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04439             "QI for IDispatch on collection failed - exit 0x%08x", hr));
04440
04441         delete pCollection;
04442
04443         return hr;
04444     }
04445
04446     //
04447     // Find out how many terminals are available.
04448     //
04449
04450     DWORD   dwNumTerminals;
04451
04452     hr = GetStaticTerminals(&dwNumTerminals,
04453                             NULL);
04454
04455     if ( FAILED(hr) )
04456     {
04457         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04458             "can't get number of terminals - exit 0x%08x", hr));
04459
04460         pDispatch->Release();
04461
04462         return hr;
04463     }
04464
04465     //
04466     // Allocate an array of terminal pointers.
04467     //
04468
04469     typedef ITTerminal * TermPtr;
04470     TermPtr * ppTerminals = new TermPtr[dwNumTerminals];
04471
04472     if ( ppTerminals == NULL )
04473     {
04474         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04475             "can't allocate terminals array - exit E_OUTOFMEMORY"));
04476
04477         pDispatch->Release();
04478
04479         return E_OUTOFMEMORY;
04480     }
04481
04482     //
04483     // Fill in the array with actual pointers. We must do this before
04484     // initializing the enumerator, because the enumerator may want to
04485     // addref the interface pointers during initialize.
04486     //
04487
04488     hr = GetStaticTerminals(&dwNumTerminals,
04489                             ppTerminals);
04490
04491     if ( FAILED(hr) )
04492     {
04493         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04494             "can't get terminals - exit 0x%08x", hr));
04495
04496         pDispatch->Release();
04497         delete ppTerminals;
04498
04499         return hr;
04500     }
04501     //
04502     // Init the collection using an iterator -- pointers to the beginning and
04503     // the ending element plus one. If it succeeds, this method addrefs each
04504     // element of ppterminals by querying for IDispatch.
04505     //
04506
04507     hr = pCollection->Initialize( dwNumTerminals,
04508                                   ppTerminals,
04509                                   ppTerminals + dwNumTerminals );
04510
04511     //
04512     // Release the ITTerminal reference to each terminal (leaving the
04513     // IDispatch reference, if any). Then delete the array; the
04514     // collection is now storing the pointers.
04515     //
04516
04517     for (DWORD i = 0; i < dwNumTerminals; i++)
04518     {
04519         ppTerminals[i]->Release();
04520     }
04521
04522     delete ppTerminals;
04523
04524     if (FAILED(hr))
04525     {
04526         LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04527             "Initialize on collection failed - exit 0x%08x", hr));
04528
04529         pDispatch->Release();
04530
04531         return hr;
04532     }
04533
04534     //
04535     // put the IDispatch interface pointer into the variant
04536     //
04537
04538     LOG((MSP_ERROR, "CMSPAddress::get_StaticTerminals - "
04539         "placing IDispatch value %08x in variant", pDispatch));
04540
04541     VariantInit(pVariant);
04542     pVariant->vt = VT_DISPATCH;
04543     pVariant->pdispVal = pDispatch;
04544
04545     LOG((MSP_TRACE, "CMSPAddress::get_StaticTerminals - exit S_OK"));
04546
04547     return S_OK;
04548 }
04549
04550 //////////////////////////////////////////////////////////////////////////////
04551 //////////////////////////////////////////////////////////////////////////////
04552
04553 STDMETHODIMP CMSPAddress::EnumerateStaticTerminals (
04554         OUT  IEnumTerminal ** ppTerminalEnumerator
04555         )
04556 {
04557     LOG((MSP_TRACE, "CMSPAddress::EnumerateStaticTerminals - "
04558         "enter"));
04559
04560     //
04561     // Check the return pointer.
04562     //
04563
04564     if ( MSPB_IsBadWritePtr(ppTerminalEnumerator, sizeof(IEnumTerminal *) ) )
04565     {
04566         LOG((MSP_ERROR, "CMSPAddress::EnumerateStaticTerminals - "
04567             "bad return pointer - exit E_POINTER"));
04568
04569         return E_POINTER;
04570     }
04571
04572     //
04573     // Create the enumerator object.
04574     //
04575
04576     typedef _CopyInterface<ITTerminal> CCopy;
04577     typedef CSafeComEnum<IEnumTerminal, &IID_IEnumTerminal,
04578         ITTerminal *, CCopy> CEnumerator;
04579
04580     HRESULT hr;
04581
04582     CComObject<CEnumerator> *pEnum = NULL;
04583
04584     hr = CComObject<CEnumerator>::CreateInstance(&pEnum);
04585
04586     if ( FAILED(hr) )
04587     {
04588         LOG((MSP_ERROR, "CMSPAddress::EnumerateStaticTerminals - "
04589             "can't create enumerator - exit 0x%08x", hr));
04590
04591         return hr;
04592     }
04593
04594     //
04595     // Query for the desired interface.
04596     //
04597
04598     hr = pEnum->_InternalQueryInterface(IID_IEnumTerminal,
04599                                         (void**) ppTerminalEnumerator);
04600
04601     if ( FAILED(hr) )
04602     {
04603         LOG((MSP_ERROR, "CMSPAddress::EnumerateStaticTerminals - "
04604             "can't get enumerator interface - exit 0x%08x", hr));
04605
04606         delete pEnum;
04607
04608         return hr;
04609     }
04610
04611     //
04612     // Find out how many terminals are available.
04613     //
04614
04615     DWORD   dwNumTerminals;
04616
04617     hr = GetStaticTerminals(&dwNumTerminals,
04618                             NULL);
04619
04620     if ( FAILED(hr) )
04621     {
04622         LOG((MSP_ERROR, "CMSPAddress::EnumerateStaticTerminals - "
04623             "can't get number of terminals - exit 0x%08x", hr));
04624
04625         (*ppTerminalEnumerator)->Release();
04626
04627         return hr;
04628     }
04629
04630     //
04631     // Allocate an array of terminal pointers.
04632     //
04633
04634     typedef ITTerminal * TermPtr;
04635     TermPtr * ppTerminals = new TermPtr[dwNumTerminals];
04636
04637     if ( ppTerminals == NULL )
04638     {
04639         LOG((MSP_ERROR, "CMSPAddress::EnumerateStaticTerminals - "
04640             "can't allocate terminals array - exit E_OUTOFMEMORY"));
04641
04642         (*ppTerminalEnumerator)->Release();
04643
04644         return E_OUTOFMEMORY;
04645     }
04646
04647     //
04648     // Fill in the array with actual pointers. We must do this before
04649     // initializing the enumerator, because the enumerator may want to
04650     // addref the interface pointers during initialize.
04651     //
04652
04653     hr = GetStaticTerminals(&dwNumTerminals,
04654                             ppTerminals);
04655
04656     if ( FAILED(hr) )
04657     {
04658         LOG((MSP_ERROR, "CMSPAddress::EnumerateStaticTerminals - "
04659             "can't get terminals - exit 0x%08x", hr));
04660
04661         (*ppTerminalEnumerator)->Release();
04662         delete ppTerminals;
04663
04664         return hr;
04665     }
04666
04667     //
04668     // Initialize the object with the array of pointers.
04669     //
04670
04671     hr = pEnum->Init(ppTerminals,
04672                      ppTerminals + dwNumTerminals,
04673                      NULL,
04674                      AtlFlagTakeOwnership);
04675
04676     if (FAILED(hr))
04677     {
04678         LOG((MSP_ERROR, "CMSPCallBase::EnumerateStaticTerminals - "
04679             "init enumerator failed - exit 0x%08x", hr));
04680
04681         for (DWORD i = 0; i < dwNumTerminals; i++)
04682         {
04683             ppTerminals[i]->Release();
04684         }
04685
04686         delete ppTerminals;
04687         (*ppTerminalEnumerator)->Release();
04688
04689         return hr;
04690     }
04691
04692     LOG((MSP_TRACE, "CMSPAddress::EnumerateStaticTerminals - exit S_OK"));
04693
04694     return S_OK;
04695 }
04696
04697
04698 //////////////////////////////////////////////////////////////////////////////
04699 //////////////////////////////////////////////////////////////////////////////
04700
04701 STDMETHODIMP CMSPAddress::get_DynamicTerminalClasses (
04702         OUT  VARIANT * pVariant
04703         )
04704 {
04705     LOG((MSP_TRACE, "CMSPAddress::get_DynamicTerminalClasses - enter"));
04706
04707     //
04708     // Check parameters.
04709     //
04710
04711     if ( MSPB_IsBadWritePtr(pVariant, sizeof(VARIANT) ) )
04712     {
04713         LOG((MSP_ERROR, "CMSPAddress::get_DynamicTerminalClasses - "
04714             "bad pointer argument - exit E_POINTER"));
04715
04716         return E_POINTER;
04717     }
04718
04719     //
04720     // create the collection object - see mspcoll.h
04721     //
04722
04723     CComObject<CTapiBstrCollection> * pCollection;
04724     HRESULT hr = CComObject<CTapiBstrCollection>::CreateInstance( &pCollection );
04725
04726     if ( FAILED(hr) )
04727     {
04728         LOG((MSP_ERROR, "CMSPAddress::get_DynamicTerminalClasses - "
04729             "can't create collection - exit 0x%08x", hr));
04730
04731         return hr;
04732     }
04733
04734     //
04735     // get the Collection's IDispatch interface
04736     //
04737
04738     IDispatch * pDispatch;
04739
04740     hr = pCollection->_InternalQueryInterface(IID_IDispatch,
04741                                               (void **) &pDispatch );
04742
04743     if ( FAILED(hr) )
04744     {
04745         LOG((MSP_ERROR, "CMSPAddress::get_DynamicTerminalClasses - "
04746             "QI for IDispatch on collection failed - exit 0x%08x", hr));
04747
04748         delete pCollection;
04749
04750         return hr;
04751     }
04752
04753     //
04754     // Find out how many terminals classes are available.
04755     //
04756
04757     DWORD   dwNumClasses;
04758
04759     hr = GetDynamicTerminalClasses(&dwNumClasses,
04760                                    NULL);
04761
04762     if ( FAILED(hr) )
04763     {
04764         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04765             "can't get number of terminal classes - exit 0x%08x", hr));
04766
04767         pDispatch->Release();
04768
04769         return hr;
04770     }
04771
04772     //
04773     // Allocate an array of GUIDs.
04774     //
04775
04776     IID * pClassGuids = new IID[dwNumClasses];
04777
04778     if ( pClassGuids == NULL )
04779     {
04780         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04781             "can't allocate class guids array - exit E_OUTOFMEMORY"));
04782
04783         pDispatch->Release();
04784
04785         return E_OUTOFMEMORY;
04786     }
04787
04788     //
04789     // Fill in the array with actual pointers.
04790     //
04791
04792     hr = GetDynamicTerminalClasses(&dwNumClasses,
04793                                    pClassGuids);
04794
04795     if ( FAILED(hr) )
04796     {
04797         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04798             "can't get terminal class guids - exit 0x%08x", hr));
04799
04800         pDispatch->Release();
04801
04802         delete pClassGuids;
04803
04804         return hr;
04805     }
04806
04807     //
04808     // Allocate an array of BSTRs.
04809     //
04810
04811     BSTR * pClassBstrs = new BSTR[dwNumClasses];
04812
04813     if ( pClassBstrs == NULL )
04814     {
04815         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04816             "can't allocate class bstrs array - exit E_OUTOFMEMORY"));
04817
04818         pDispatch->Release();
04819
04820         delete pClassGuids;
04821
04822         return E_OUTOFMEMORY;
04823     }
04824
04825     //
04826     // Allocate a string for each GUID and copy it to the array,
04827     // then delete the array of GUIDs.
04828     //
04829
04830     const int BUFSIZE = 100;
04831     WCHAR wszBuffer[BUFSIZE];
04832
04833     for (DWORD i = 0; i < dwNumClasses; i++)
04834     {
04835         int ret = StringFromGUID2(pClassGuids[i], wszBuffer, BUFSIZE);
04836
04837         _ASSERTE(ret != 0);
04838
04839         pClassBstrs[i] = SysAllocString(wszBuffer);
04840
04841         if ( pClassBstrs[i] == NULL )
04842         {
04843             LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04844                 "can't allocate a bstr - exit E_OUTOFMEMORY"));
04845
04846             for (DWORD j = 0; j < i; j++)
04847             {
04848                 SysFreeString(pClassBstrs[j]);
04849             }
04850
04851             delete pClassBstrs;
04852             delete pClassGuids;
04853
04854             pDispatch->Release();
04855
04856             return E_OUTOFMEMORY;
04857         }
04858     }
04859
04860     delete pClassGuids;
04861
04862     //
04863     // Init the collection using an iterator -- pointers to the beginning and
04864     // the ending element plus one.
04865     //
04866
04867     hr = pCollection->Initialize( dwNumClasses,
04868                                   pClassBstrs,
04869                                   pClassBstrs + dwNumClasses );
04870
04871     if ( FAILED(hr) )
04872     {
04873         LOG((MSP_ERROR, "CMSPAddress::get_DynamicTerminalClasses - "
04874             "Initialize on collection failed - exit 0x%08x", hr));
04875
04876         pDispatch->Release();
04877
04878         for (DWORD k = 0; k < dwNumClasses; k++)
04879         {
04880             SysFreeString(pClassBstrs[k]);
04881         }
04882
04883         delete pClassBstrs;
04884
04885         return hr;
04886     }
04887
04888     delete pClassBstrs;
04889
04890     //
04891     // put the IDispatch interface pointer into the variant
04892     //
04893
04894     LOG((MSP_ERROR, "CMSPAddress::get_DynamicTerminalClasses - "
04895         "placing IDispatch value %08x in variant", pDispatch));
04896
04897     VariantInit(pVariant);
04898     pVariant->vt = VT_DISPATCH;
04899     pVariant->pdispVal = pDispatch;
04900
04901     LOG((MSP_TRACE, "CMSPAddress::get_DynamicTerminalClasses - exit S_OK"));
04902
04903     return S_OK;
04904 }
04905
04906 //////////////////////////////////////////////////////////////////////////////
04907 //////////////////////////////////////////////////////////////////////////////
04908
04909 STDMETHODIMP CMSPAddress::EnumerateDynamicTerminalClasses (
04910         OUT  IEnumTerminalClass ** ppTerminalClassEnumerator
04911         )
04912 {
04913     LOG((MSP_TRACE, "CMSPAddress::EnumerateDynamicTerminalClasses - enter"));
04914
04915     //
04916     // Check the return pointer.
04917     //
04918
04919     if ( MSPB_IsBadWritePtr(ppTerminalClassEnumerator,
04920                        sizeof(IEnumTerminalClass *) ) )
04921     {
04922         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04923             "bad return pointer - exit E_POINTER"));
04924
04925         return E_POINTER;
04926     }
04927
04928     //
04929     // Find out how many terminals classes are available.
04930     //
04931
04932     HRESULT hr;
04933     DWORD   dwNumClasses;
04934
04935     hr = GetDynamicTerminalClasses(&dwNumClasses,
04936                                    NULL);
04937
04938     if ( FAILED(hr) )
04939     {
04940         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04941             "can't get number of terminal classes - exit 0x%08x", hr));
04942
04943         return hr;
04944     }
04945
04946     //
04947     // Allocate an array of GUIDs.
04948     //
04949
04950     IID * pClassGuids = new IID[dwNumClasses];
04951
04952     if ( pClassGuids == NULL )
04953     {
04954         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04955             "can't allocate class guids array - exit E_OUTOFMEMORY"));
04956
04957         return E_OUTOFMEMORY;
04958     }
04959
04960     //
04961     // Fill in the array with actual pointers.
04962     //
04963
04964     hr = GetDynamicTerminalClasses(&dwNumClasses,
04965                                    pClassGuids);
04966
04967     if ( FAILED(hr) )
04968     {
04969         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04970             "can't get terminal class guids - exit 0x%08x", hr));
04971
04972         delete pClassGuids;
04973
04974         return hr;
04975     }
04976
04977
04978     //
04979     // Create an enumerator to hold this array, and have it take ownership
04980     // so that it will delete the array when it is released. The CSafeComEnum
04981     // can handle zero-length arrays. This Fn also checks the return arg.
04982     //
04983
04984     //
04985     // Create the enumerator object.
04986     //
04987
04988     typedef CSafeComEnum<IEnumTerminalClass,
04989                      &IID_IEnumTerminalClass,
04990                      GUID, _Copy<GUID> > CEnumerator;
04991
04992     CComObject<CEnumerator> *pEnum = NULL;
04993
04994     hr = CComObject<CEnumerator>::CreateInstance(&pEnum);
04995
04996     if ( FAILED(hr) )
04997     {
04998         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
04999             "can't create enumerator - exit 0x%08x", hr));
05000
05001         delete pClassGuids;
05002
05003         return hr;
05004     }
05005
05006     //
05007     // Query for the desired interface.
05008     //
05009
05010     hr = pEnum->_InternalQueryInterface(IID_IEnumTerminalClass,
05011                                         (void**) ppTerminalClassEnumerator);
05012
05013     if ( FAILED(hr) )
05014     {
05015         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
05016             "can't get enumerator interface - exit 0x%08x", hr));
05017
05018         delete pEnum;
05019         delete pClassGuids;
05020
05021         return hr;
05022     }
05023
05024     //
05025     // Init the enumerator object.
05026     //
05027
05028     hr = pEnum->Init(pClassGuids,
05029                      pClassGuids + dwNumClasses,
05030                      NULL,
05031                      AtlFlagTakeOwnership);
05032
05033     if ( FAILED(hr) )
05034     {
05035         LOG((MSP_ERROR, "CMSPAddress::EnumerateDynamicTerminalClasses - "
05036             "can't init enumerator - exit 0x%08x", hr));
05037
05038         (*ppTerminalClassEnumerator)->Release();
05039         delete pClassGuids;
05040
05041         return hr;
05042     }
05043
05044     LOG((MSP_TRACE, "CMSPAddress::EnumerateDynamicTerminalClasses - exit S_OK"));
05045
05046     return S_OK;
05047 }
05048
05049 HRESULT CMSPAddress::ReceiveTSPAddressData(
05050         IN      PBYTE               pBuffer,
05051         IN      DWORD               dwSize
05052         )
05053 /*++
05054
05055 Routine Description:
05056
05057   Base class receive TSP address data method... does nothing in base class.
05058   Implemented so that MSP's that only communicate per-call don't have
05059   to override it.
05060
05061 Arguments:
05062
05063
05064 Return Value:
05065
05066 S_OK
05067
05068 --*/
05069
05070 {
05071     LOG((MSP_TRACE, "CMSPAddress::ReceiveTSPAddressData - enter"));
05072     LOG((MSP_TRACE, "CMSPAddress::ReceiveTSPAddressData - exit S_OK"));
05073
05074     return S_OK;
05075 }
05076
05077 HRESULT CMSPAddress::PnpNotifHandler(
05078         IN      BOOL                bDeviceArrival
05079         )
05080 {
05081     LOG((MSP_TRACE, "CMSPAddress::PnpNotifHandler - enter"));
05082
05083     if (bDeviceArrival)
05084         LOG((MSP_TRACE, "CMSPAddress::PnpNotifHandler - device arrival"));
05085     else
05086         LOG((MSP_TRACE, "CMSPAddress::PnpNotifHandler - device removal"));
05087
05088     // lock the terminal related data. This is a auto lock that will unlock
05089     // when the function returns.
05090     CLock lock(m_TerminalDataLock);
05091
05092     // if the terminal list hasn't been built yet, we can skip doing anything
05093     if (m_fTerminalsUpToDate)
05094     {
05095         HRESULT hr = UpdateTerminalListForPnp( bDeviceArrival );
05096
05097         if (FAILED(hr))
05098         {
05099             LOG((MSP_ERROR,
05100                 "CMSPAddress::PnpNotifHandler - "
05101                 "UpdateTerminalList failed - returning 0x%08x", hr));
05102
05103             return hr;
05104         }
05105     }
05106
05107     LOG((MSP_TRACE, "CMSPAddress::PnpNotifHandler - exit S_OK"));
05108
05109     return S_OK;
05110 }
05111
05112 // eof
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/about.h Source File

  • SysMgmt
  • MMC
  • Proppage

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/enumformatetc.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

enumformatetc.cpp

Go to the documentation of this file.
00001
00002 /*
00003  * EnumFormatEtc.cpp
00004  * Data Object Chapter 10
00005  *
00006  * Standard implementation of a FORMATETC enumerator with the
00007  * IEnumFORMATETC interface that will generally not need
00008  * modification.
00009  *
00010  * Copyright (c) 1993 - 2001 Microsoft Corporation, All Rights Reserved
00011  *
00012  */
00013
00014 #include "EnumFormatEtc.h"
00015
00016 /*
00017  * CEnumFormatEtc::CEnumFormatEtc
00018  * CEnumFormatEtc::~CEnumFormatEtc
00019  *
00020  * Parameters (Constructor):
00021  *  cFE             ULONG number of FORMATETCs in pFE
00022  *  prgFE           LPFORMATETC to the array to enumerate.
00023  */
00024
00025 CEnumFormatEtc::CEnumFormatEtc(ULONG cFE, LPFORMATETC prgFE)
00026     {
00027     UINT        i;
00028
00029     m_cRef=0;
00030     m_iCur=0;
00031     m_cfe=cFE;
00032     m_prgfe=new FORMATETC[(UINT)cFE];
00033
00034     if (NULL!=m_prgfe)
00035         {
00036         for (i=0; i < cFE; i++)
00037             m_prgfe[i]=prgFE[i];
00038         }
00039
00040     return;
00041     }
00042
00043
00044 CEnumFormatEtc::~CEnumFormatEtc(void)
00045     {
00046     if (NULL!=m_prgfe)
00047         delete [] m_prgfe;
00048
00049     return;
00050     }
00051
00052
00053
00054
00055
00056
00057 /*
00058  * CEnumFormatEtc::QueryInterface
00059  * CEnumFormatEtc::AddRef
00060  * CEnumFormatEtc::Release
00061  *
00062  * Purpose:
00063  *  IUnknown members for CEnumFormatEtc object.  For QueryInterface
00064  *  we only return out own interfaces and not those of the data
00065  *  object.  However, since enumerating formats only makes sense
00066  *  when the data object is around, we insure that it stays as
00067  *  long as we stay by calling an outer IUnknown for AddRef
00068  *  and Release.  But since we are not controlled by the lifetime
00069  *  of the outer object, we still keep our own reference count in
00070  *  order to free ourselves.
00071  */
00072
00073 STDMETHODIMP CEnumFormatEtc::QueryInterface(REFIID riid, VOID ** ppv)
00074     {
00075     *ppv=NULL;
00076
00077     /*
00078      * Enumerators are separate objects, not the data object, so
00079      * we only need to support out IUnknown and IEnumFORMATETC
00080      * interfaces here with no concern for aggregation.
00081      */
00082     if (IID_IUnknown==riid || IID_IEnumFORMATETC==riid)
00083         *ppv=this;
00084
00085     //AddRef any interface we'll return.
00086     if (NULL!=*ppv)
00087         {
00088         ((LPUNKNOWN)*ppv)->AddRef();
00089         return NOERROR;
00090         }
00091
00092     return ResultFromScode(E_NOINTERFACE);
00093     }
00094
00095
00096 STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef(void)
00097     {
00098     ++m_cRef;
00099     return m_cRef;
00100     }
00101
00102 STDMETHODIMP_(ULONG) CEnumFormatEtc::Release(void)
00103     {
00104     if (0!=--m_cRef)
00105         return m_cRef;
00106
00107     delete this;
00108     return 0;
00109     }
00110
00111
00112
00113
00114
00115
00116
00117 /*
00118  * CEnumFormatEtc::Next
00119  *
00120  * Purpose:
00121  *  Returns the next element in the enumeration.
00122  *
00123  * Parameters:
00124  *  cFE             ULONG number of FORMATETCs to return.
00125  *  pFE             LPFORMATETC in which to store the returned
00126  *                  structures.
00127  *  pulFE           ULONG * in which to return how many we
00128  *                  enumerated.
00129  *
00130  * Return Value:
00131  *  HRESULT         NOERROR if successful, S_FALSE otherwise,
00132  */
00133
00134 STDMETHODIMP CEnumFormatEtc::Next(ULONG cFE, LPFORMATETC pFE
00135     , ULONG *pulFE)
00136     {
00137     ULONG               cReturn=0L;
00138
00139     if (NULL==m_prgfe)
00140         return ResultFromScode(S_FALSE);
00141
00142     if (NULL==pulFE)
00143         {
00144         if (1L!=cFE)
00145             return ResultFromScode(E_POINTER);
00146         }
00147     else
00148         *pulFE=0L;
00149
00150     if (NULL==pFE || m_iCur >= m_cfe)
00151         return ResultFromScode(S_FALSE);
00152
00153     while (m_iCur < m_cfe && cFE > 0)
00154         {
00155         *pFE++=m_prgfe[m_iCur++];
00156         cReturn++;
00157         cFE--;
00158         }
00159
00160     if (NULL!=pulFE)
00161         *pulFE=cReturn;
00162
00163     return NOERROR;
00164     }
00165
00166
00167
00168
00169
00170
00171
00172 /*
00173  * CEnumFormatEtc::Skip
00174  *
00175  * Purpose:
00176  *  Skips the next n elements in the enumeration.
00177  *
00178  * Parameters:
00179  *  cSkip           ULONG number of elements to skip.
00180  *
00181  * Return Value:
00182  *  HRESULT         NOERROR if successful, S_FALSE if we could not
00183  *                  skip the requested number.
00184  */
00185
00186 STDMETHODIMP CEnumFormatEtc::Skip(ULONG cSkip)
00187     {
00188     if (((m_iCur+cSkip) >= m_cfe) || NULL==m_prgfe)
00189         return ResultFromScode(S_FALSE);
00190
00191     m_iCur+=cSkip;
00192     return NOERROR;
00193     }
00194
00195
00196
00197
00198
00199
00200 /*
00201  * CEnumFormatEtc::Reset
00202  *
00203  * Purpose:
00204  *  Resets the current element index in the enumeration to zero.
00205  *
00206  * Parameters:
00207  *  None
00208  *
00209  * Return Value:
00210  *  HRESULT         NOERROR
00211  */
00212
00213 STDMETHODIMP CEnumFormatEtc::Reset(void)
00214     {
00215     m_iCur=0;
00216     return NOERROR;
00217     }
00218
00219
00220
00221
00222
00223
00224 /*
00225  * CEnumFormatEtc::Clone
00226  *
00227  * Purpose:
00228  *  Returns another IEnumFORMATETC with the same state as ourselves.
00229  *
00230  * Parameters:
00231  *  ppEnum          LPENUMFORMATETC * in which to return the
00232  *                  new object.
00233  *
00234  * Return Value:
00235  *  HRESULT         NOERROR or a general error value.
00236  */
00237
00238 STDMETHODIMP CEnumFormatEtc::Clone(LPENUMFORMATETC *ppEnum)
00239     {
00240     PCEnumFormatEtc     pNew;
00241
00242     *ppEnum=NULL;
00243
00244     //Create the clone
00245     pNew=new CEnumFormatEtc(m_cfe, m_prgfe);
00246
00247     if (NULL==pNew)
00248         return ResultFromScode(E_OUTOFMEMORY);
00249
00250     pNew->AddRef();
00251     pNew->m_iCur=m_iCur;
00252
00253     *ppEnum=pNew;
00254     return NOERROR;
00255     }
00256
00257
00258
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagPOSDATA Member List

This is the complete list of members for _tagPOSDATA, including all inherited members.
GetInboundByte | _tagPOSDATA
nAllocLength | _tagPOSDATA
nBufferLength | _tagPOSDATA
nBufferPos | _tagPOSDATA
nCurrentPos | _tagPOSDATA
pData | _tagPOSDATA
pECB | _tagPOSDATA
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/WaitDlg.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

WaitDlg.Cpp

Go to the documentation of this file.
00001 // WaitDlg.cpp : implementation file
00002 //  Copyright 1995-1999, Citrix Systems Inc.
00003 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00004 //
00005
00006 #include "stdafx.h"
00007 #include "API.h"
00008 #include "APIDoc.h"
00009 #include "WaitDlg.h"
00010 #include "wtsapi32.h"
00011
00012 #ifdef _DEBUG
00013 #define new DEBUG_NEW
00014 #undef THIS_FILE
00015 static char THIS_FILE[] = __FILE__;
00016 #endif
00017
00018 /////////////////////////////////////////////////////////////////////////////
00019 // CWaitDlg dialog
00020
00021
00022 CWaitDlg::CWaitDlg(CWnd* pParent /*=NULL*/)
00023   : CDialog(CWaitDlg::IDD, pParent)
00024 {
00025   //{{AFX_DATA_INIT(CWaitDlg)
00026     // NOTE: the ClassWizard will add member initialization here
00027   //}}AFX_DATA_INIT
00028 }
00029
00030
00031 void CWaitDlg::DoDataExchange(CDataExchange* pDX)
00032 {
00033   CDialog::DoDataExchange(pDX);
00034   //{{AFX_DATA_MAP(CWaitDlg)
00035     // NOTE: the ClassWizard will add DDX and DDV calls here
00036   //}}AFX_DATA_MAP
00037 }
00038
00039
00040 BEGIN_MESSAGE_MAP(CWaitDlg, CDialog)
00041   //{{AFX_MSG_MAP(CWaitDlg)
00042   //}}AFX_MSG_MAP
00043 END_MESSAGE_MAP()
00044
00045 /////////////////////////////////////////////////////////////////////////////
00046 // CWaitDlg message handlers
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Dog/Dogcf.h Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Dog

Dogcf.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 extern LONG g_cObjects;
00018
00019 class CClassFactory : public IClassFactory
00020 {
00021 public:
00022     // IUnknown methods
00023     STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppvObj);
00024     STDMETHOD_(ULONG, AddRef)(void);
00025     STDMETHOD_(ULONG, Release)(void);
00026
00027     // IClassFactory methods
00028     STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid,
00029                               void FAR* FAR* ppv);
00030     STDMETHOD(LockServer)(BOOL fLock);
00031
00032     CClassFactory() {    m_cRef = 0; InterlockedIncrement(&g_cObjects); }
00033     ~CClassFactory() {    InterlockedDecrement(&g_cObjects); }
00034
00035 private:
00036     LONG m_cRef;                   // Reference count
00037 };
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/client/main.cpp Source File

  • Com
  • async
  • client

main.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include <windows.h>
00018 #include <ocidl.h>
00019
00020 #include <stdio.h>
00021 #include "proxy.h"
00022 #include "CEvent.h"
00023 #include "..\Server\debug.h"
00024 #include "..\Server\CUnknown.h"
00025
00026 typedef ICallFactory *LPCALLFACTORY;
00027 typedef AsyncITest   *LPASYNCITEST;
00028 typedef ISynchronize *LPSYNCHRONIZE;
00029
00030
00031
00032 #if defined(_ASYNC_COM_)
00033 #pragma message(">>> Compiling for Asynchronous COM")
00034 #else
00035 #pragma message(">>> Compiling for Synchronous COM")
00036 #endif
00037
00038
00039 main(int argc, char* argv[])
00040 {
00041   HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00042   _ASSERT(SUCCEEDED(hr));
00043
00044
00045   hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_ANONYMOUS, NULL, EOAC_NONE, 0);
00046   _ASSERT(SUCCEEDED(hr));
00047
00048
00049   LPCLASSFACTORY pCF = NULL;
00050
00051 /*
00052  * If you choose try run the server from a remote machine you can either hard code this in the
00053  * registry or set the below manifest constants to match your own environment. Make certain
00054  * to give the below user the rights to both "Launch" and "Access" the server. Since this
00055  * sample is showing how to achive a form of asychronous events the security is set to none
00056  * to simplify the callback.
00057  */
00058 // #define _COSERVERINFO_
00059 #if defined(_COSERVERINFO_)
00060
00061 #define DOMAIN    L"domain"
00062 #define MACHINE   L"machine"
00063 #define USER    L"com_stud"
00064 #define PASSWORD  L"com_stud"
00065
00066   COSERVERINFO* pserverInfo = static_cast<COSERVERINFO*>(alloca(sizeof(COSERVERINFO)+sizeof(COAUTHINFO)));
00067   COAUTHIDENTITY authIdentity;
00068   SETDEFSERVERINFO(pserverInfo, MACHINE)
00069   SETAUTHIDENTITY(authIdentity, USER, PASSWORD, DOMAIN);
00070   pserverInfo->pAuthInfo->pAuthIdentityData = &authIdentity;
00071 #pragma message(">>> Overriding registry using COSERVERINFO to fetch object")
00072   hr = CoGetClassObject(CLSID_AsyncTest, CLSCTX_SERVER, pserverInfo, IID_IClassFactory, (PVOID*)&pCF);
00073 #else // default
00074 #pragma message(">>> using default registry settings to fetch object")
00075   hr = CoGetClassObject(CLSID_AsyncTest, CLSCTX_SERVER, NULL, IID_IClassFactory, (PVOID*)&pCF);
00076 #endif // _COSERVERINFO_
00077
00078   _ASSERT(SUCCEEDED(hr) && pCF);
00079
00080   LPTEST pTest = NULL;
00081   hr = pCF->CreateInstance(NULL, IID_ITest, (PVOID*)&pTest);
00082   _ASSERT(SUCCEEDED(hr) && pTest);
00083   RELEASEINTERFACE(pCF);
00084
00085
00086 #if defined(_EVENTSINK_)
00087 // Set up event sink
00088   LPCONNECTIONPOINTCONTAINER pCPC = NULL;
00089   LPCONNECTIONPOINT pCP = NULL;
00090   hr = pTest->QueryInterface(IID_IConnectionPointContainer, (PVOID*)&pCPC);
00091   _ASSERT(SUCCEEDED(hr) && pCPC);
00092
00093   hr = pCPC->FindConnectionPoint(IID_AppEvents, &pCP);
00094   _ASSERT(SUCCEEDED(hr) && pCP);
00095   RELEASEINTERFACE(pCPC);
00096
00097   DWORD dwCookie;
00098   CEvent *lpevent = new CEvent;
00099   hr = pCP->Advise(lpevent, &dwCookie);
00100   _ASSERT(SUCCEEDED(hr));
00101 #endif
00102
00103   BSTR  bstr = NULL;
00104
00105 #if defined(_ASYNC_COM_)
00106   LPCALLFACTORY pCallF = NULL;
00107   LPASYNCITEST  pAsyncTest = NULL;
00108   LPSYNCHRONIZE pSync = NULL;
00109   hr = pTest->QueryInterface(IID_ICallFactory, (PVOID*)&pCallF);
00110   _ASSERT(SUCCEEDED(hr) && (pCallF != NULL));
00111
00112   hr = pCallF->CreateCall(IID_AsyncITest, NULL, IID_AsyncITest, (LPUNKNOWN*)&pAsyncTest);
00113   _ASSERT(SUCCEEDED(hr) && (pAsyncTest != NULL));
00114
00115   bstr = SysAllocString(L"Synchronous::Hello World");
00116   _ASSERT(bstr);
00117   printf("[Blocking call]\tPassing  %S to server\n", bstr);
00118 /*
00119  *  The first call will block till the server completes the call. Since in this case the server
00120  *  supports the asychronous interface COM will call that method in preferance to the synchronous
00121  *  method. This allows the server to handle other tasks such as handling such as other clients while
00122  *  waiting the for method to finish. Note that this particular method takes one [in/out] parameter which
00123  *  will be used by both the Begin/Finish methods.
00124  */
00125   hr = pTest->Test1(bstr);
00126   printf("Server returned %S\n", bstr);
00127   _ASSERT(SUCCEEDED(hr));
00128   SysFreeString(bstr);
00129
00130   bstr = SysAllocString(L"Asynchronous::Hello World");
00131   printf("[Asynchronous call]\tCalling Begin_Test1(%S) to server\n", bstr);
00132 /*
00133  *  This is an asychronously call. The call to Begin_Test1 will return immediately after the parameters
00134  *  have been marshaled into the RPC buffer. The return code in this case in from the communication layer
00135  *  not the server. The client is able to free any parameters passed in and continue with other work.
00136  *  The client however can not make another call on the same call object until Finish_Test1 returns.
00137  */
00138   hr = pAsyncTest->Begin_Test1(bstr);
00139   _ASSERT(SUCCEEDED(hr));
00140   SysFreeString(bstr);
00141
00142 /*
00143  *  Fetch the ISynchronize interface from the proxy so that client can periodically check whether the server
00144  *  has completed the call will continuing with its' other work.
00145  */
00146   hr = pAsyncTest->QueryInterface(IID_ISynchronize, reinterpret_cast<PVOID*>(&pSync));
00147   _ASSERT(SUCCEEDED(hr) && pSync);
00148
00149   DWORD startTime, elapseTime;
00150   printf("Working...\n");
00151   startTime = elapseTime = GetTickCount();
00152   while ((hr = pSync->Wait(0, 1000)) == RPC_S_CALLPENDING || elapseTime - startTime >= 20000)
00153   {
00154     elapseTime = GetTickCount();
00155     printf("Working...\n");
00156   }
00157   RELEASEINTERFACE(pSync);
00158   bstr = SysAllocString(L"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
00159   hr = pAsyncTest->Finish_Test1(bstr);
00160   printf("Elapsed time to complete call is %d sec\n", (elapseTime - startTime)/1000);
00161   _ASSERT(SUCCEEDED(hr));
00162   printf("Server returned %S\n", bstr);
00163   SysFreeString(bstr);
00164
00165 /*
00166  *  This next call is also invoked asynchronously by the client. What makes this different from the above call is
00167  *  this method call requires two parameters. These will split up so that all [in] parameters are passed in the
00168  *  Begin_Test2 call and [out] parameters to the Finish_Test2 call.
00169  */
00170   bstr = SysAllocString(L"Asynchronous::Hello World");
00171   printf("[Asynchronous call]\tCalling Begin_Test2(%S) to server\n", bstr);
00172   hr = pAsyncTest->Begin_Test2(bstr);
00173   _ASSERT(SUCCEEDED(hr));
00174   SysFreeString(bstr);
00175
00176   hr = pAsyncTest->QueryInterface(IID_ISynchronize, reinterpret_cast<PVOID*>(&pSync));
00177   _ASSERT(SUCCEEDED(hr) && pSync);
00178
00179   printf("Working...\n");
00180   startTime = elapseTime = GetTickCount();
00181   while ((hr = pSync->Wait(0, 1000)) == RPC_S_CALLPENDING || elapseTime - startTime >= 20000)
00182   {
00183     elapseTime = GetTickCount();
00184     printf("Working...\n");
00185   }
00186   RELEASEINTERFACE(pSync);
00187   hr = pAsyncTest->Finish_Test2(&bstr);
00188   printf("Elapsed time to complete call is %d sec\n", (elapseTime - startTime)/1000);
00189   _ASSERT(SUCCEEDED(hr));
00190   printf("Server returned %S\n", bstr);
00191   SysFreeString(bstr);
00192
00193
00194 /*
00195  *  This next call simply calls the Finish_Test2 call without polling. This would be done in the case where the client
00196  *  could proceed no further without getting the result back from the client. The client will block in the Finish_Test2
00197  *  method until the server signals that it's done.
00198  */
00199   bstr = SysAllocString(L"Asynchronous::Hello World");
00200   printf("[Asynchronous call]\tCalling Begin_Test2(%S) to server\n", bstr);
00201   hr = pAsyncTest->Begin_Test2(bstr);
00202   _ASSERT(SUCCEEDED(hr));
00203
00204   printf("**\n** Rather than test to see when the call object is signalled as above;\n** here I call the Finish method which will block until the method is signaled\n**\n");
00205   hr = pAsyncTest->Finish_Test2(&bstr);
00206   _ASSERT(SUCCEEDED(hr));
00207   printf("Server returned %S\n", bstr);
00208   SysFreeString(bstr);
00209
00210   RELEASEINTERFACE(pAsyncTest);
00211   RELEASEINTERFACE(pCallF);
00212 #else
00213   bstr = SysAllocString(L"Synchronous::Hello World");
00214   _ASSERT(bstr);
00215   printf("Passing  %S to server\n", bstr);
00216   hr = pTest->Test1(bstr);
00217   printf("Server returned %S\n", bstr);
00218   _ASSERT(SUCCEEDED(hr));
00219   SysFreeString(bstr);
00220 #endif // _ASYNC_COM_
00221
00222 #if defined(_EVENTSINK_)
00223   hr = pCP->Unadvise(dwCookie);
00224   _ASSERT(SUCCEEDED(hr));
00225   RELEASEINTERFACE(pCP);
00226 #endif
00227
00228   RELEASEINTERFACE(pTest);
00229   CoUninitialize();
00230   return 0;
00231 }
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

storesh::CERT_SYSTEM_STORE_INFO Member List

This is the complete list of members for storesh::CERT_SYSTEM_STORE_INFO, including all inherited members.
cbSize storesh::CERT_SYSTEM_STORE_INFO
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Printer/Getpdriv.c Source File

  • Multimedia
  • Gdi
  • Printer

Getpdriv.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /******************************************************************************\
00013 *
00014 *  PROGRAM:     GETPDRIV.C
00015 *
00016 *  PURPOSE:     Handles display of information returned by call to
00017 *               GetPrinterDriver. GetPrinterDriver is called for the
00018 *               currently selected printer (in the tool bar comobobox),
00019 *               and the results are formatted and displayed in a dialog
00020 *               box.
00021 *
00022 *  FUNTIONS:    GetPrinterDriverDlgProc - handles messages for dialog
00023 *               DisplayPrinterDriverInfo- retrieves & displays printer
00024 *                                           driver info
00025 *
00026 \******************************************************************************/
00027
00028 #include <windows.h>
00029 #include <winspool.h>
00030 #include <string.h>
00031 #include <stdio.h>
00032 #include <winspool.h>
00033 #include "common.h"
00034 #include "getpdriv.h"
00035 #include "resource.h"
00036
00037 /******************************************************************************\
00038 *
00039 *  FUNCTION:    GetPrinterDriverDlgProc (standard dlg proc INPUTS/RETURNS)
00040 *
00041 *  COMMENTS:    Processes messages for getPrinterDriver dialog box
00042 *
00043 \******************************************************************************/
00044
00045 LRESULT CALLBACK GetPrinterDriverDlgProc (HWND   hwnd,   UINT msg,
00046                                           WPARAM wParam, LPARAM lParam)
00047 {
00048   switch (msg)
00049   {
00050     case WM_INITDIALOG:
00051     {
00052       BOOL bReturn;
00053       char buf[BUFSIZE];
00054
00055     //
00056       // shove all the printer driver info in the list box
00057       //
00058
00059       SetCursor (LoadCursor (NULL, IDC_WAIT));
00060       bReturn = DisplayPrinterDriverInfo (hwnd);
00061       SetCursor (LoadCursor (NULL, IDC_ARROW));
00062
00063       if (!bReturn)
00064       {
00065         EndDialog (hwnd, TRUE);
00066       }
00067
00068       //
00069       // set window title to reflect current device
00070       //
00071
00072       else
00073       {
00074         if ( _snprintf (buf, BUFSIZE-1, "GetPrinterDriver: %s;%s;%s", gszDeviceName, gszPort, gszDriverName) > 0)
00075           SetWindowText (hwnd, (LPCSTR) buf);
00076       }
00077
00078       break;
00079     }
00080
00081     case WM_COMMAND:
00082
00083       switch (LOWORD (wParam))
00084       {
00085         case DID_OK:
00086
00087           EndDialog (hwnd, TRUE);
00088           return 1;
00089       }
00090       break;
00091   }
00092   return 0;
00093 }
00094
00095
00096
00097 /******************************************************************************\
00098 *
00099 *  FUNCTION:    DisplayPrinterDriverInfo
00100 *
00101 *  INPUTS:      hwnd - handle of GetPrinterDriver dialog box
00102 *
00103 *  RETURNS:     TRUE if successful,
00104 *               FALSE otherwise
00105 *
00106 \******************************************************************************/
00107
00108
00109 BOOL DisplayPrinterDriverInfo (HWND hwnd)
00110 {
00111   HANDLE        hPrinter;
00112   DWORD         dwBytesNeeded;
00113   DRIVER_INFO_1 *pDriverInfo1;
00114   DRIVER_INFO_2 *pDriverInfo2;
00115   char          buf[BUFSIZE];
00116   char          pEnvironment[BUFSIZE] = "";
00117   BOOL          bReturn = TRUE;
00118
00119   //
00120   // open selected printer & alloc buffers & get sundry info, close printer
00121   //
00122
00123   OpenPrinter (gszDeviceName, &hPrinter, NULL);
00124
00125   if (!hPrinter)
00126   {
00127     char buf[BUFSIZE];
00128
00129     _snprintf (buf, BUFSIZE-1, GetStringRes(IDS_FMT_OPNPRTFAIL), gszDeviceName);
00130     ErrMsgBox ((LPCSTR) buf, ERR_MOD_NAME);
00131     bReturn  = FALSE;
00132     goto display_prt_drv_info_done1;
00133   }
00134
00135   GetPrinterDriver (hPrinter, pEnvironment, 1, NULL, 0, &dwBytesNeeded);
00136
00137   //
00138   // simple error checking, if these work assume rest will too
00139   //
00140
00141   if (!(pDriverInfo1 = (DRIVER_INFO_1 *) LocalAlloc (LPTR, dwBytesNeeded)))
00142   {
00143     ErrMsgBox (GetStringRes(IDS_LALLOCFAIL), ERR_MOD_NAME);
00144     bReturn = FALSE;
00145     goto display_prt_drv_info_done1;
00146   }
00147
00148   if (!GetPrinterDriver (hPrinter, pEnvironment, 1, (LPBYTE) pDriverInfo1,
00149                          dwBytesNeeded, &dwBytesNeeded))
00150   {
00151     ErrMsgBox (GetStringRes(IDS_GETPRTDRVFAIL), ERR_MOD_NAME);
00152     bReturn = FALSE;
00153     goto display_prt_drv_info_done2;
00154   }
00155
00156   GetPrinterDriver (hPrinter, pEnvironment, 2, NULL, 0, &dwBytesNeeded);
00157   pDriverInfo2 = (DRIVER_INFO_2 *) LocalAlloc (LPTR, dwBytesNeeded);
00158   GetPrinterDriver (hPrinter, pEnvironment, 2, (LPBYTE) pDriverInfo2,
00159                     dwBytesNeeded, &dwBytesNeeded);
00160
00161   ClosePrinter (hPrinter);
00162
00163   //
00164   // shove info in listbox
00165   //
00166
00167   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[0]) > 0 )
00168   outstr();
00169
00170   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[1], pDriverInfo1->pName) > 0 )
00171   outstr();
00172
00173   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[2]) > 0 )
00174   outstr();
00175
00176   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[3], pDriverInfo2->cVersion) > 0 )
00177   outstr();
00178
00179   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[4], pDriverInfo2->pName) > 0 )
00180   outstr();
00181
00182   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[5], pDriverInfo2->pEnvironment) > 0 )
00183   outstr();
00184
00185   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[6], pDriverInfo2->pDriverPath) > 0 )
00186   outstr();
00187
00188   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[7], pDriverInfo2->pDataFile) > 0 )
00189   outstr();
00190
00191   if ( _snprintf (buf, BUFSIZE-1, gaDrvInfo[8], pDriverInfo2->pConfigFile) > 0 )
00192   outstr();
00193
00194   LocalFree (LocalHandle (pDriverInfo2));
00195
00196 display_prt_drv_info_done2:
00197
00198   LocalFree (LocalHandle (pDriverInfo1));
00199
00200 display_prt_drv_info_done1:
00201
00202   return bReturn;
00203 }
00204
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/dtevntsk.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

dtevntsk.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1998-1999  Microsoft Corporation
00004
00005 Module Name:
00006
00007     DTEvntSk.cpp
00008
00009 Abstract:
00010
00011     This module contains implementation of CPTEventSink.
00012
00013 --*/
00014
00015 #include "precomp.h"
00016 #pragma hdrstop
00017
00018
00019 //
00020 // a helper function that releases the resources allocated inside event info
00021 //
00022
00023 HRESULT FreeEventInfo( MSP_EVENT_INFO * pEvent )
00024 {
00025
00026     LOG((MSP_TRACE, "FreeEventInfo -  enter"));
00027
00028     switch ( pEvent->Event )
00029     {
00030
00031         case ME_ADDRESS_EVENT:
00032
00033             if (NULL != pEvent->MSP_ADDRESS_EVENT_INFO.pTerminal)
00034             {
00035                 (pEvent->MSP_ADDRESS_EVENT_INFO.pTerminal)->Release();
00036             }
00037
00038             break;
00039
00040         case ME_CALL_EVENT:
00041
00042             if (NULL != pEvent->MSP_CALL_EVENT_INFO.pTerminal)
00043             {
00044                 (pEvent->MSP_CALL_EVENT_INFO.pTerminal)->Release();
00045             }
00046
00047             if (NULL != pEvent->MSP_CALL_EVENT_INFO.pStream)
00048             {
00049                 (pEvent->MSP_CALL_EVENT_INFO.pStream)->Release();
00050             }
00051
00052             break;
00053
00054         case ME_TSP_DATA:
00055
00056             break;
00057
00058         case ME_PRIVATE_EVENT:
00059
00060             if ( NULL != pEvent->MSP_PRIVATE_EVENT_INFO.pEvent )
00061             {
00062                 (pEvent->MSP_PRIVATE_EVENT_INFO.pEvent)->Release();
00063             }
00064
00065             break;
00066
00067         case ME_FILE_TERMINAL_EVENT:
00068
00069             if( NULL != pEvent->MSP_FILE_TERMINAL_EVENT_INFO.pParentFileTerminal)
00070             {
00071                 (pEvent->MSP_FILE_TERMINAL_EVENT_INFO.pParentFileTerminal)->Release();
00072                 pEvent->MSP_FILE_TERMINAL_EVENT_INFO.pParentFileTerminal = NULL;
00073             }
00074
00075             if( NULL != pEvent->MSP_FILE_TERMINAL_EVENT_INFO.pFileTrack )
00076             {
00077                 (pEvent->MSP_FILE_TERMINAL_EVENT_INFO.pFileTrack)->Release();
00078                 pEvent->MSP_FILE_TERMINAL_EVENT_INFO.pFileTrack = NULL;
00079             }
00080
00081             break;
00082
00083         case ME_ASR_TERMINAL_EVENT:
00084
00085             if( NULL != pEvent->MSP_ASR_TERMINAL_EVENT_INFO.pASRTerminal)
00086             {
00087                 (pEvent->MSP_ASR_TERMINAL_EVENT_INFO.pASRTerminal)->Release();
00088             }
00089
00090             break;
00091
00092         case ME_TTS_TERMINAL_EVENT:
00093
00094             if( NULL != pEvent->MSP_TTS_TERMINAL_EVENT_INFO.pTTSTerminal)
00095             {
00096                 (pEvent->MSP_TTS_TERMINAL_EVENT_INFO.pTTSTerminal)->Release();
00097             }
00098
00099             break;
00100
00101         case ME_TONE_TERMINAL_EVENT:
00102
00103             if( NULL != pEvent->MSP_TONE_TERMINAL_EVENT_INFO.pToneTerminal)
00104             {
00105                 (pEvent->MSP_TONE_TERMINAL_EVENT_INFO.pToneTerminal)->Release();
00106             }
00107
00108             break;
00109
00110         default:
00111
00112             break;
00113     }
00114
00115
00116     LOG((MSP_TRACE, "FreeEventInfo -  finished"));
00117
00118     return S_OK;
00119 }
00120
00121
00122 CPTEventSink::CPTEventSink() :
00123     m_pMSPStream(NULL)
00124 {
00125     LOG((MSP_TRACE, "CPTEventSink::CPTEventSink enter"));
00126     LOG((MSP_TRACE, "CPTEventSink::CPTEventSink exit"));
00127 }
00128
00129 CPTEventSink::~CPTEventSink()
00130 {
00131     LOG((MSP_TRACE, "CPTEventSink::~CPTEventSink enter"));
00132     LOG((MSP_TRACE, "CPTEventSink::~CPTEventSink exit"));
00133 };
00134
00135 // --- ITPluggableTerminalEventSnk ---
00136
00137 /*++
00138 FireEvent
00139
00140 Parameters:
00141
00142     IN MSPEVENTITEM * pEventItem pointer to the structure that describes the
00143     event. all the pointers contained in the structure must be addreffed by
00144     the caller, and then released by the caller if FireEvent fails
00145
00146     FireEvent makes a (shallow) copy of the structure, so the caller can
00147     delete the structure when the function returns
00148
00149
00150 Returns:
00151     S_OK - every thing was OK
00152     E_FAIL & other - something was wrong
00153
00154 Description:
00155   This method is called by the dynamic terminals to
00156   signal a new event
00157 --*/
00158
00159 STDMETHODIMP CPTEventSink::FireEvent(
00160     IN const MSP_EVENT_INFO * pEventInfo
00161     )
00162 {
00163     LOG((MSP_TRACE, "CPTEventSink::FireEvent enter"));
00164
00165
00166     //
00167     // make sure we got a good mspeventitem structure
00168     //
00169
00170     if( MSPB_IsBadWritePtr( (void*)pEventInfo, sizeof( MSP_EVENT_INFO )))
00171     {
00172         LOG((MSP_ERROR, "CPTEventSink::FireEvent -"
00173             "pEventItem is bad, returns E_POINTER"));
00174         return E_POINTER;
00175     }
00176
00177
00178     //
00179     // Create an MSPEVENTITEM
00180     //
00181
00182     MSPEVENTITEM *pEventItem = AllocateEventItem();
00183
00184     if (NULL == pEventItem)
00185     {
00186         LOG((MSP_ERROR, "CPTEventSink::FireEvent -"
00187             "failed to create MSPEVENTITEM. returning E_OUTOFMEMORY "));
00188
00189         return E_OUTOFMEMORY;
00190     }
00191
00192
00193     //
00194     // make a shallow copy of the structure
00195     //
00196
00197     pEventItem->MSPEventInfo = *pEventInfo;
00198
00199
00200     Lock();
00201
00202     HRESULT hr = E_FAIL;
00203
00204     if (NULL != m_pMSPStream)
00205     {
00206
00207         //
00208         // nicely ask stream to process our event
00209         //
00210
00211         LOG((MSP_TRACE, "CPTEventSink::FireEvent - passing event [%p] to the stream", pEventItem));
00212
00213
00214         AsyncEventStruct *pAsyncEvent = new AsyncEventStruct;
00215
00216         if (NULL == pAsyncEvent)
00217         {
00218             LOG((MSP_ERROR,
00219                 "CPTEventSink::FireEvent - failed to allocate memory for AsyncEventStruct"));
00220
00221             hr = E_OUTOFMEMORY;
00222         }
00223         else
00224         {
00225
00226             //
00227             // stuff the structure with the addref'fed stream on which the
00228             // event will be fired and the actual event to fire
00229             //
00230
00231             ULONG ulRC =  m_pMSPStream->AddRef();
00232
00233             if (1 == ulRC)
00234             {
00235                 //
00236                 // this is a workaround for a timing window: the stream could
00237                 // be in its desctructor while we are doing the addref. this
00238                 // condition is very-vary rare, as the timing window is very
00239                 // narrow.
00240                 //
00241                 // the good thing is that stream destructor will not finish
00242                 // while we are here, because it will try to get event sink's
00243                 // critical section in its call to SetSinkStream() to set our
00244                 // stream pointer to NULL.
00245                 //
00246                 // so if we detect that the refcount after our addref is 1,
00247                 // that would mean that the stream is in (or is about to start
00248                 // executing its desctructor). in which case we should do
00249                 // nothing.
00250                 //
00251                 // cleanup and return a failure.
00252                 //
00253
00254                 Unlock();
00255
00256                 LOG((MSP_ERROR,
00257                     "CPTEventSink::FireEvent - stream is going away"));
00258
00259                 delete pAsyncEvent;
00260                 pAsyncEvent = NULL;
00261
00262                 FreeEventItem(pEventItem);
00263                 pEventItem = NULL;
00264
00265                 return TAPI_E_INVALIDSTREAM;
00266             }
00267
00268
00269
00270             pAsyncEvent->pMSPStream = m_pMSPStream;
00271
00272             pAsyncEvent->pEventItem = pEventItem;
00273
00274
00275             //
00276             // now use thread pool api to schedule the event for future async
00277             // processing
00278             //
00279
00280             BOOL bQueueSuccess = QueueUserWorkItem(
00281                 CPTEventSink::FireEventCallBack,
00282                 (void *)pAsyncEvent,
00283                 WT_EXECUTEDEFAULT);
00284
00285             if (!bQueueSuccess)
00286             {
00287
00288                 DWORD dwLastError = GetLastError();
00289
00290                 LOG((MSP_ERROR,
00291                     "CPTEventSink::FireEvent - QueueUserWorkItem failed. LastError = %ld", dwLastError));
00292
00293
00294                 //
00295                 // undo the addref we did on the stream object. the event will
00296                 // be freed later
00297                 //
00298
00299                 m_pMSPStream->Release();
00300
00301
00302                 //
00303                 // the event was not enqueued. delete now.
00304                 //
00305
00306                 delete pAsyncEvent;
00307                 pAsyncEvent = NULL;
00308
00309
00310                 //
00311                 // map the code and bail out
00312                 //
00313
00314                 hr = HRESULT_FROM_WIN32(dwLastError);
00315             }
00316             else
00317             {
00318
00319                 //
00320                 // log the event we have submitted, so we can match submission
00321                 // with processing from the log
00322                 //
00323
00324                 LOG((MSP_TRACE,
00325                     "CPTEventSink::FireEvent - submitted event [%p]", pAsyncEvent));
00326
00327                 hr = S_OK;
00328
00329             } // async event structure submitted
00330
00331         } // async event structure allocated
00332
00333     } // msp stream exists
00334     else
00335     {
00336         hr = TAPI_E_INVALIDSTREAM;
00337
00338         LOG((MSP_ERROR,
00339             "CPTEventSink::FireEvent - stream pointer is NULL"));
00340     }
00341
00342
00343     Unlock();
00344
00345
00346     //
00347     // if we don't have a stream, or if the stream refused to process the
00348     // event, cleanup and return an error
00349     //
00350
00351     if (FAILED(hr))
00352     {
00353
00354         LOG((MSP_ERROR, "CPTEventSink::FireEvent - call to HandleStreamEvent failed. hr = 0x%08x", hr));
00355
00356         FreeEventItem(pEventItem);
00357
00358         return hr;
00359     }
00360
00361
00362     LOG((MSP_TRACE, "CPTEventSink::FireEvent - exit"));
00363
00364     return S_OK;
00365 }
00366
00367
00368
00369
00370 /////////////////////////////////////////////////////////////////////////////
00371 //
00372 // CPTEventSink::FireEventCallBack
00373 //
00374 // the callback function that is called by thread pool api to asyncronously to
00375 // process events fired by the terminals.
00376 //
00377 // the argument should point to the structure that contains the pointer to the
00378 // stream on which to fire the event and the pointer to the event to fire.
00379 //
00380 // the dll is guaranteed to not go away, since the structure passed in holds a
00381 // reference to the stream object on which to process the event
00382 //
00383
00384 // static
00385 DWORD WINAPI CPTEventSink::FireEventCallBack(LPVOID lpParameter)
00386 {
00387     LOG((MSP_TRACE, "CPTEventSink::FireEventCallBack - enter. Argument [%p]",
00388         lpParameter));
00389
00390
00391     AsyncEventStruct *pEventStruct = (AsyncEventStruct *)lpParameter;
00392
00393
00394     //
00395     // make sure the structure is valid
00396     //
00397
00398     if (IsBadReadPtr(pEventStruct, sizeof(AsyncEventStruct)))
00399     {
00400
00401         //
00402         // complain and exit. should not happen, unless there is a problem in
00403         // thread pool api or memory corruption
00404         //
00405
00406         LOG((MSP_ERROR,
00407             "CPTEventSink::FireEventCallBack - Argument does not point to a valid AsyncEventStruct"));
00408
00409         return FALSE;
00410     }
00411
00412
00413     BOOL bBadDataPassedIn = FALSE;
00414
00415     //
00416     // the structure contains an addref'fed stream pointer. extract it and
00417     // make sure it is still valid
00418     //
00419
00420     CMSPStream *pMSPStream = pEventStruct->pMSPStream;
00421
00422     if (IsBadReadPtr(pMSPStream, sizeof(CMSPStream)))
00423     {
00424
00425         //
00426         // should not happen, unless there is a problem in thread pool api or
00427         // memory corruption, or someone is over-releasing the stream object
00428         //
00429
00430         LOG((MSP_ERROR,
00431             "CPTEventSink::FireEventCallBack - stream pointer is bad"));
00432
00433         pMSPStream = NULL;
00434
00435         bBadDataPassedIn = TRUE;
00436     }
00437
00438
00439
00440     //
00441     // the structure contains the event that we are tryint to fire.
00442     // make sure the event we are about to fire is good.
00443     //
00444
00445     MSPEVENTITEM *pEventItem = pEventStruct->pEventItem;
00446
00447     if (IsBadReadPtr(pEventItem, sizeof(MSPEVENTITEM)))
00448     {
00449
00450         //
00451         // should not happen, unless there is a problem in thread pool api or
00452         // memory corruption, or we didn't check success of allocation when we
00453         // created the event (which we did!)
00454         //
00455
00456         LOG((MSP_ERROR,
00457             "CPTEventSink::FireEventCallBack - event is bad"));
00458
00459         pEventItem = NULL;
00460
00461         bBadDataPassedIn = TRUE;
00462     }
00463
00464
00465     //
00466     // bad stream or event structure?
00467     //
00468
00469     if (bBadDataPassedIn)
00470     {
00471
00472         //
00473         // release the event if it was good.
00474         //
00475
00476         if ( NULL != pEventItem)
00477         {
00478
00479             FreeEventItem(pEventItem);
00480             pEventItem = NULL;
00481         }
00482
00483
00484         //
00485         // release the stream if it was good.
00486         //
00487
00488         if (NULL != pMSPStream)
00489         {
00490             pMSPStream->Release();
00491             pMSPStream = NULL;
00492         }
00493
00494
00495         //
00496         // no need to keep the event structure itself, delete it
00497         //
00498
00499         delete pEventStruct;
00500         pEventStruct = NULL;
00501
00502         return FALSE;
00503     }
00504
00505
00506     //
00507     // we have both the stream and the event, fire the event on the stream
00508     //
00509
00510     HRESULT hr = pMSPStream->HandleSinkEvent(pEventItem);
00511
00512
00513     //
00514     // if HandleSinkEvent succeeded, pEventItem will be released by whoever
00515     // will handle the event, otherwise we need to release eventitem here
00516     //
00517
00518     if (FAILED(hr))
00519     {
00520         LOG((MSP_ERROR,
00521             "CPTEventSink::FireEventCallBack - HandleSinkEvent not called or failed. hr = %lx",
00522             hr));
00523
00524         //
00525         // need to free all the resources held by event info
00526         //
00527
00528         FreeEventInfo(&(pEventItem->MSPEventInfo));
00529
00530         FreeEventItem(pEventItem);
00531         pEventItem = NULL;
00532     }
00533
00534
00535     //
00536     // release the stream pointer that is a part of the structure --
00537     // we don't want any reference leaks.
00538     //
00539
00540     //
00541     // note that the dll may go away at this point (if we are holding the last
00542     // reference to the last object from the dll)
00543     //
00544
00545     pMSPStream->Release();
00546     pMSPStream = NULL;
00547
00548
00549     //
00550     // at this point we release the stream pointer and either submitted the
00551     // event or freed it. we no longer need the event structure.
00552     //
00553
00554     delete pEventStruct;
00555     pEventStruct = NULL;
00556
00557     LOG((MSP_(hr), "CPTEventSink::FireEventCallBack - exit. hr = %lx", hr));
00558
00559     return SUCCEEDED(hr);
00560 }
00561
00562
00563 /*++
00564
00565 SetSinkStream
00566
00567 Parameters:
00568
00569     CMSPStream *pStream
00570
00571       the stream that will be processing our events, or NULL when no stream is
00572       available to process our events
00573
00574 Returns:
00575     S_OK -
00576
00577 Description:
00578
00579     this method is called by the stream that is going to process our events
00580
00581     when the stream is going away and is no longer available to process our
00582     messages, it will call SetSinkStream with NULL.
00583
00584 --*/
00585
00586 HRESULT CPTEventSink::SetSinkStream( CMSPStream *pStream )
00587 {
00588     LOG((MSP_TRACE, "CPTEventSink::SetSinkStream - enter"));
00589
00590
00591     Lock();
00592
00593
00594     LOG((MSP_TRACE,
00595         "CPTEventSink::SetSinkStream - replacing sink stream [%p] with [%p]",
00596         m_pMSPStream, pStream));
00597
00598
00599     //
00600     // we don't keep a reference to the stream -- the stream keeps a reference
00601     // to us. when the stream goes away, it will let us know.
00602     //
00603
00604     m_pMSPStream = pStream;
00605
00606     Unlock();
00607
00608
00609     LOG((MSP_TRACE, "CPTEventSink::SetSinkStream - exit"));
00610
00611     return S_OK;
00612 }
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/DDxDDv.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

DDxDDv.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      DDxDDv.h
00007 //
00008 //  Implementation File:
00009 //      DDxDDv.cpp
00010 //
00011 //  Description:
00012 //      Definition of custom dialog data exchange/dialog data validation
00013 //      routines.
00014 //
00015 //  Author:
00016 //      <name> (<e-mail name>) Mmmm DD, 2003
00017 //
00018 //  Revision History:
00019 //
00020 //  Notes:
00021 //
00022 /////////////////////////////////////////////////////////////////////////////
00023
00024 #pragma once
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // Include Files
00028 /////////////////////////////////////////////////////////////////////////////
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // Global Function Prototypes
00032 /////////////////////////////////////////////////////////////////////////////
00033
00034 void AFXAPI
00035 DDX_Number(
00036       CDataExchange *   pDXIn
00037     , int               nIDCIn
00038     , DWORD &           rdwValueInout
00039     , DWORD             dwMinIn
00040     , DWORD             dwMaxIn
00041     , BOOL              fSignedIn = FALSE
00042     );
00043
00044 void AFXAPI
00045 DDV_RequiredText(
00046       CDataExchange *   pDXIn
00047     , int               nIDCIn
00048     , int               nIDCLabelIn
00049     , const CString &   rstrValueIn
00050     );
00051
00052 inline void AFXAPI
00053 DDX_Number(
00054       CDataExchange *  pDXIn
00055     , int              nIDCIn
00056     , LONG &           rnValueInout
00057     , LONG             nMinIn
00058     , LONG             nMaxIn
00059     , BOOL             fSignedIn
00060     )
00061 {
00062     DDX_Number(
00063           pDXIn
00064         , nIDCIn
00065         , reinterpret_cast< DWORD & >( rnValueInout )
00066         , static_cast< DWORD >( nMinIn )
00067         , static_cast< DWORD >( nMaxIn )
00068         , fSignedIn
00069         );
00070
00071 } //*** DDXNumber
00072
00073 void
00074 CleanupLabel( LPTSTR pwszIn );
00075
00076 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/winmain.h Source File

  • Dataaccess
  • oledb
  • tablecopy

winmain.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module WINMAIN.H
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 #ifndef _WINMAIN_H_
00012 #define _WINMAIN_H_
00013
00014
00015 ///////////////////////////////////////////////////////////////
00016 // Defines
00017 //
00018 ///////////////////////////////////////////////////////////////
00019
00020 //We want type checking on Window Handles
00021 #define STRICT
00022
00023
00024 ///////////////////////////////////////////////////////////////
00025 // Includes
00026 //
00027 ///////////////////////////////////////////////////////////////
00028 #include <windows.h>
00029 #include <windowsx.h>
00030 #include <commctrl.h> //InitCommonControls
00031
00032 #include <stddef.h>
00033 #include <stdio.h>
00034 #include <limits.h>
00035 #include <wchar.h>
00036
00037 #include "resource.h"
00038
00039
00040
00041 ////////////////////////////////////////////////////////////////////////////
00042 // Windows Defines
00043 //
00044 ////////////////////////////////////////////////////////////////////////////
00045 #define CHECK_MEMORY(pv)  if(!pv) { OutOfMemory(NULL); goto CLEANUP; }
00046
00047 //Dialog Box procedures want to know if you handled the MSG
00048 //or not.  If you do, thenit just returns, if not then it calls
00049 //the default windialog procedure to try and handle it
00050 const BOOL HANDLED_MSG   = TRUE;
00051 const BOOL UNHANDLED_MSG = FALSE;
00052 #define LVM_ERR (-1)
00053
00054 ////////////////////////////////////////////////////////////////////////////
00055 // Windows functions
00056 //
00057 ////////////////////////////////////////////////////////////////////////////
00058 void Busy(BOOL bValue = TRUE);
00059 void OutOfMemory(HWND hwnd);
00060
00061 INT wMessageBox(HWND hDlg, UINT uiStyle, WCHAR* pwszTitle, WCHAR* pwszFmt, ...);
00062 LRESULT wSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, WCHAR* pwszName);
00063
00064 void wSetDlgItemText(HWND hWnd, INT DlgItem, WCHAR* pwszFmt, ...);
00065 UINT wGetDlgItemText(HWND hWnd, INT DlgItem, WCHAR* pwsz, INT nMaxSize);
00066
00067 BOOL CenterDialog(HWND hDlg);
00068 void SyncSibling(HWND hwndLstChg,HWND hwndLstSrc);
00069
00070 BOOL GetEditBoxValue(HWND hEditWnd, ULONG ulMin, ULONG ulMax, ULONG* pulCount);
00071
00072
00073 /////////////////////////////////////////////////////////////////////
00074 // ListView Helpers
00075 //
00076 /////////////////////////////////////////////////////////////////////
00077 LONG LV_InsertColumn(HWND hWnd, LONG iColumn, CHAR* szName);
00078 LONG LV_InsertItem(HWND hWnd, LONG iItem, LONG iSubItem, CHAR* szName, LONG iParam = 0, LONG iIMage = NULL);
00079 LONG LV_SetItemState(HWND hWnd, LONG iItem, LONG iSubItem, LONG lState, LONG lStateMask);
00080 LONG LV_SetItemText(HWND hWnd, LONG iItem, LONG iSubItem, CHAR* szName);
00081 LONG LV_FindItem(HWND hWnd, CHAR* szName, LONG iStart);
00082
00083
00084 /////////////////////////////////////////////////////////////////////
00085 // TreeView Helpers
00086 //
00087 /////////////////////////////////////////////////////////////////////
00088 HTREEITEM TV_InsertItem(HWND hWnd, HTREEITEM hParent, HTREEITEM hInsAfter, CHAR* szName, LONG iParam = 0, LONG iImage = 0, LONG iSelectedImage = 0);
00089
00090
00091 /////////////////////////////////////////////////////////////////////
00092 // Memory debugging code
00093 //
00094 /////////////////////////////////////////////////////////////////////
00095 int InternalAssert(char* pszExp, char* pszFile, UINT iLine);
00096 void InternalTrace(CHAR* pszExp, ...);
00097 void InternalTrace(WCHAR* pwszExp, ...);
00098
00099 #undef ASSERT
00100 #undef TRACE
00101
00102 #ifdef _DEBUG
00103 #if     defined(_M_IX86)
00104 #define _DbgBreak() __asm { int 3 }
00105 #else
00106 #define _DbgBreak() DebugBreak()
00107 #endif
00108 #define ASSERT(expr) \
00109         do { if (!(expr) && \
00110                 (1 == InternalAssert(#expr, __FILE__, __LINE__))) \
00111              _DbgBreak(); } while (0)
00112
00113 #define TRACE InternalTrace
00114 #else  //_DEBUG
00115 #define ASSERT(exp)
00116 #define TRACE if(0) InternalTrace
00117 #endif //_DEBUG
00118
00119
00120 #endif //_WINMAIN_H_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsecure/filerepservice.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsecure

filerepservice.cpp

Go to the documentation of this file.
00001 /*
00002
00003     File Replication Sample
00004     Server System Service
00005
00006     FILE: FileRepService.cpp
00007
00008     PURPOSE: Provides file replication services.
00009
00010     USAGE:
00011         FileRepService
00012
00013     FUNCTIONS:
00014         main() - calls the StartServiceCtrlDispatcher function to
00015             connect to the SCM and start the control dispatcher thread.
00016         ServiceMain() - the entry point for the service.
00017         ServiceCtrl() - this function is called by the dispatcher thread.
00018             It handles the control code passed to it.
00019         ServiceStart() - performs actual initialization and starts the service.
00020             Makes the RPC server listen for calls.
00021         ServiceStop() - stops listening for RPCs.
00022
00023     COMMENTS:
00024
00025 */
00026
00027 #define SECURITY_WIN32
00028
00029 #include <windows.h>
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <process.h>
00033 #include <tchar.h>
00034 #include <rpc.h>
00035 #include <Ntdsapi.h>
00036 #include <Ntsecapi.h>
00037 #include <Security.h>
00038 #include <Secext.h>
00039 #include <Dsgetdc.h>
00040 #include <Lm.h>
00041
00042 // Generated by the MIDL compiler
00043 #include "FileRepServer.h"
00044 #include "FileRepClient.h"
00045
00046 // Contains declarations for system service functions.
00047 #include "Service.h"
00048
00049 // Common definitions
00050 #include "common.h"
00051
00052 /*
00053     Internal funtion declarations.
00054     See definitions for more info.
00055 */
00056
00057 VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv);
00058
00059 VOID WINAPI ServiceCtrl(DWORD Opcode);
00060
00061 VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
00062
00063 VOID ServiceStop();
00064
00065 /*
00066     Internal variables
00067 */
00068
00069 // status handle of the service
00070 SERVICE_STATUS_HANDLE sshStatusHandle;
00071
00072 // current status of the service
00073 SERVICE_STATUS ssStatus;
00074
00075 BOOL bServerListening = FALSE;
00076
00077 /*
00078     FUNCTION: main()
00079
00080     PURPOSE: main() calls StartServiceCtrlDispatcher to register the
00081         main service thread.    When this call returns,
00082         the service has stopped.
00083
00084     PARAMETERS:
00085         dwArgc - number of command line arguments
00086         lpszArgv - array of command line arguments
00087
00088     RETURN VALUE:
00089         none
00090
00091     COMMENTS:
00092 */
00093 VOID _cdecl main(int argc, char **argv){
00094
00095     // Since we provide a single service there is only
00096     // one entry in the service dispatch table
00097     SERVICE_TABLE_ENTRY DispatchTable[] = {
00098         { SERVICENAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain },
00099         { NULL, NULL }
00100     };
00101
00102     // The service control manager may be starting the service with
00103     // this call, so we must call StartServiceCtrlDispatcher.
00104     if (!StartServiceCtrlDispatcher(DispatchTable)) {
00105         AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed"));
00106     }
00107 }
00108
00109 /*
00110     FUNCTION: ServiceMain
00111
00112     PURPOSE: To perform actual initialization of the client service.    It
00113         is the entry point into the service.
00114
00115     PARAMETERS:
00116         dwArgc - number of command line arguments
00117         lpszArgv - array of command line arguments
00118
00119     RETURN VALUE:
00120         none
00121
00122     COMMENTS:
00123         This routine performs the service initialization and then calls
00124         the user defined ServiceStart() routine to perform majority
00125         of the work.
00126 */
00127 VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) {
00128
00129     // Initial service configuration
00130     ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
00131     ssStatus.dwCurrentState = SERVICE_START_PENDING;
00132     ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
00133     ssStatus.dwWin32ExitCode = 0;
00134     ssStatus.dwServiceSpecificExitCode = 0;
00135     ssStatus.dwCheckPoint = 0;
00136     ssStatus.dwWaitHint = 0;
00137
00138     sshStatusHandle = RegisterServiceCtrlHandler(SERVICENAME, ServiceCtrl);
00139
00140     // Tell the SCM that the service is starting up.
00141     if (!SetServiceStatus(sshStatusHandle, &ssStatus)) {
00142         AddToMessageLog(TEXT("ServiceMain: SetServiceStatus failed\n"));
00143         return;
00144     }
00145
00146     // Initialize the service and start it.
00147     ServiceStart(dwArgc, lpszArgv);
00148
00149     return;
00150 }
00151
00152 /*
00153     FUNCTION: ServiceCtrl
00154
00155     PURPOSE: This function is called by the SCM whenever
00156         ControlService() is called on this service.
00157
00158     PARAMETERS:
00159         dwCtrlCode - type of control requested
00160
00161     RETURN VALUE:
00162         none
00163
00164     COMMENTS:
00165 */
00166
00167 VOID WINAPI ServiceCtrl(DWORD Opcode) {
00168
00169     // We only handle the STOP control requsts.
00170     switch(Opcode) {
00171
00172         case SERVICE_CONTROL_STOP:
00173             // Stop the service.
00174             ServiceStop();
00175             break;
00176
00177         default:
00178             AddToMessageLog(TEXT("ServiceCtrl: unrecognized or unimplemented opcode\n"));
00179     }
00180
00181     return;
00182 }
00183
00184
00185 /*
00186     RPC configuration.
00187 */
00188
00189 // The service listens to all the protseqs listed in this array.
00190 // It listens for replication utilities on local RPC and for
00191 // remote requests on TCP/IP
00192 LPTSTR ServerProtocolArray[] = { TEXT("ncacn_ip_tcp"),
00193          TEXT("ncalrpc") };
00194
00195 // Used in RpcServerUseProtseq.
00196 // Specifies the maximum number of concurrent remote
00197 // procedure call requests the server wants to handle.
00198 ULONG cMaxCallsListen = RPC_C_PROTSEQ_MAX_REQS_DEFAULT;
00199
00200 // Similarly, but for RpcServerListen.
00201 ULONG cMaxCallsExecute = RPC_C_LISTEN_MAX_CALLS_DEFAULT;
00202
00203 // Used in RpcServerListen().  The minnimum number of threads listening.
00204 ULONG cMinimumThreads = 2;
00205
00206 RPC_BINDING_VECTOR * pBindingVector = NULL;
00207
00208 // Status variable for the RPC calls.
00209 RPC_STATUS status;
00210
00211 /*
00212     FUNCTION: RpcServerIfCallback
00213
00214     PURPOSE: Security callback funtion for the server interface
00215
00216     PARAMETERS:
00217         Interface - the UUID and version of the interface.
00218         Context - server binding handle representing the client.
00219
00220     RETURN VALUE:
00221         Returns RPC_S_OK if the client is allowed to call methods in this
00222         interface.  A different return code will cause the client to receive
00223         the exception RPC_S_ACCESS_DENIED.
00224
00225     COMMENTS:
00226
00227         Specifying a security-callback function allows the server application
00228         to restrict access to its interfaces on a per-client basis.
00229
00230         By default the server run time will dispatch unauthenticated calls
00231         even if the server has called RpcServerRegisterAuthInfo. If the
00232         server wants to accept only authenticated clients it must then call
00233         RpcBindingInqAuthClient to retrieve the security level, or attempt
00234         to impersonate the client with RpcImpersonateClient.
00235
00236         When a server application specifies a security-callback function
00237         for an interface, the RPC run time automatically rejects
00238         unauthenticated calls to that interface. In addition, the run-time
00239         records the interfaces that each client has used. When a client
00240         makes an RPC to an interface that it has not used during the
00241         current communication session, the RPC run-time library will
00242         call the interface's security-callback function.
00243
00244         In some cases, the RPC run time may call the security-callback
00245         function more than once per client, per interface.
00246
00247 */
00248 RPC_STATUS __stdcall RpcServerIfCallback (
00249   IN void *Interface,
00250   IN void *Context
00251 ) {
00252     ULONG ulAuthnLevel;
00253     ULONG ulAuthnSvc;
00254
00255     // Get client security info.
00256     if (RpcBindingInqAuthClient(Context,
00257         NULL,
00258         NULL,
00259         &ulAuthnLevel,
00260         &ulAuthnSvc,
00261         NULL) != RPC_S_OK) {
00262
00263         return RPC_S_ACCESS_DENIED;
00264     }
00265
00266     // Make sure the client has adequate security measures and uses the expected
00267     // security provider.
00268     if (ulAuthnLevel != RPC_C_AUTHN_LEVEL_PKT_PRIVACY || ulAuthnSvc != RPC_C_AUTHN_GSS_KERBEROS) {
00269
00270         return RPC_S_ACCESS_DENIED;
00271     }
00272
00273     return RPC_S_OK;
00274 };
00275
00276 /*
00277     FUNCTION: ServiceStart
00278
00279     PURPOSE: Actual code of the service
00280              that does the work.
00281
00282     PARAMETERS:
00283         dwArgc - number of command line arguments
00284         lpszArgv - array of command line arguments
00285
00286     RETURN VALUE:
00287         none
00288
00289     COMMENTS:
00290         Starts the service listening for RPC requests.
00291 */
00292 VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv){
00293
00294     UINT i;
00295
00296     // Array of generated SPNs.
00297     TCHAR **Spn;
00298     // Number of generated SPNs.
00299     ULONG ulSpn = 1;
00300
00301     PDOMAIN_CONTROLLER_INFO pDomainControllerInfo;
00302
00303     HANDLE hDS;
00304
00305     TCHAR lpCompDN[128];
00306     ULONG ulCompDNSize = sizeof(lpCompDN);
00307
00308     // Message buffer.
00309     TCHAR Msg[128];
00310
00311     // Report the status to the service control manager.
00312     if (!ReportStatusToSCMgr(&sshStatusHandle, &ssStatus, SERVICE_START_PENDING, NO_ERROR, 1000)) {
00313         AddToMessageLog(TEXT("ReportStatusToSCMgr failed\n"));
00314   ServiceStop();
00315         return;
00316     }
00317
00318     // Service initialization
00319
00320     // Register the service interfaces.
00321
00322     // The server interface has a security callback RpcServerIfCallback.
00323     // The RPC run time will automatically reject unauthenticated calls to
00324     // this interface.
00325     status = RpcServerRegisterIfEx(s_FileRepServer_v1_0_s_ifspec,
00326            NULL,
00327            NULL,
00328            RPC_IF_ALLOW_SECURE_ONLY,
00329            RPC_C_LISTEN_MAX_CALLS_DEFAULT,
00330            &RpcServerIfCallback);
00331     if (status != RPC_S_OK){
00332         AddToMessageLog(TEXT("ServiceStart: RpcServerRegisterIf(s_FileRepServer_v1_0_s_ifspec, ...) failed\n"));
00333   ServiceStop();
00334         return;
00335     }
00336
00337     status = RpcServerRegisterIf(FileRepClient_v1_0_s_ifspec, NULL, NULL);
00338     if (status != RPC_S_OK){
00339         AddToMessageLog(TEXT("ServiceStart: RpcServerRegisterIf(FileRepClient_v1_0_s_ifspec, ...) failed\n"));
00340   ServiceStop();
00341         return;
00342     }
00343
00344     for (i = 0; i < sizeof(ServerProtocolArray)/sizeof(unsigned char *); i++) {
00345
00346         // Use the protocol sequences specified in ProtocolArray
00347         // for receiving RPCs.
00348         status = RpcServerUseProtseq((_TUCHAR *)ServerProtocolArray[i], cMaxCallsListen, NULL);
00349         if (status != RPC_S_OK){
00350             AddToMessageLog(TEXT("ServiceStart: RpcServerUseProtseq failed\n"));
00351       ServiceStop();
00352             return;
00353         }
00354     }
00355
00356     // Obtain a binding vector for the server.
00357     status = RpcServerInqBindings(&pBindingVector);
00358     if (status != RPC_S_OK) {
00359         AddToMessageLog(TEXT("ServiceStart: RpcServerInqBindings failed\n"));
00360   ServiceStop();
00361         return;
00362     }
00363
00364     // Register the the services in the endpoint map
00365     // of the host computer.
00366     status = RpcEpRegister(s_FileRepServer_v1_0_s_ifspec, pBindingVector, NULL, NULL);
00367     if (status != RPC_S_OK){
00368         AddToMessageLog(TEXT("ServiceStart: RpcEpRegister(s_FileRepServer_v1_0_s_ifspec, ...) failed\n"));
00369   ServiceStop();
00370         return;
00371     }
00372     status = RpcEpRegister(FileRepClient_v1_0_s_ifspec, pBindingVector, NULL, NULL);
00373     if (status != RPC_S_OK){
00374         AddToMessageLog(TEXT("ServiceStart: RpcEpRegister(FileRepClient_v1_0_s_ifspec, ...) failed\n"));
00375   ServiceStop();
00376         return;
00377     }
00378
00379     //
00380     // Set the security info for the client system service.
00381     //
00382
00383     // Principal name is NULL for local system service.
00384     status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
00385     if (status != RPC_S_OK){
00386         AddToMessageLog(TEXT("ServiceStart: RpcServerRegisterAuthInfo failed"));
00387   ServiceStop();
00388         return;
00389     }
00390
00391     //
00392     // Set the security info for the server system service.
00393     //
00394
00395     BOOL NoFailure = TRUE;
00396
00397     // Generate the SPN.
00398     status = DsGetSpn(DS_SPN_NB_HOST, // Type of SPN to create.
00399                       SERVICENAME, // Service class
00400                       NULL, // DN of this service.
00401                       0, // Use the default instance port.
00402                       0, // Number of additional instance names.
00403                       NULL, // No additional instance names.
00404                       NULL, // No additional instance ports.
00405                       &ulSpn, // Size of SPN array.
00406                       &Spn); // Returned SPN(s).
00407     if (status != RPC_S_OK){
00408         _stprintf(Msg, TEXT("ServiceStart: DsGetSpn failed with code %d\n"), status);
00409         AddToMessageLog(Msg);
00410         ServiceStop();
00411         return;
00412     }
00413
00414     // Get the name of our domain.
00415     if (status = DsGetDcName(NULL,
00416                              NULL,
00417                              NULL,
00418                              NULL,
00419                              DS_RETURN_DNS_NAME,
00420                              &pDomainControllerInfo) != NO_ERROR) {
00421         _stprintf(Msg, TEXT("ServiceStart: DsGetDcName failed with code %d\n"), status);
00422         AddToMessageLog(Msg);
00423         NoFailure = FALSE;
00424     }
00425
00426         if (NoFailure) {
00427             // Bind to the domain controller for our domain.
00428             if ((status = DsBind(pDomainControllerInfo->DomainName, NULL, &hDS)) != ERROR_SUCCESS) {
00429                 _stprintf(Msg, TEXT("ServiceStart: DsBind failed with code %d\n"), status);
00430                         AddToMessageLog(Msg);
00431                         NoFailure = FALSE;
00432             }
00433         }
00434
00435         if (NoFailure) {
00436             if ((status = NetApiBufferFree(pDomainControllerInfo)) != NERR_Success) {
00437                     _stprintf(Msg, TEXT("ServiceStart: NetApiBufferFree failed with code %d\n"), status);
00438                         AddToMessageLog(Msg);
00439                         ServiceStop();
00440                         return;
00441                 }
00442
00443             if (GetComputerObjectName(NameFullyQualifiedDN, lpCompDN, &ulCompDNSize) == 0){
00444             _stprintf(Msg, TEXT("ServiceStart: GetComputerObjectName failed with code %d\n"), GetLastError());
00445                         AddToMessageLog(Msg);
00446                         ServiceStop();
00447                         return;
00448                 }
00449
00450                 // We could check whether the SPN is already registered for this
00451                 // computer's DN, but we don't have to.  Modification is performed
00452                 // permissively by this function, so that adding a value that already
00453                 // exists does not return an error.  This way we can opt for the internal
00454                 // check instead of doing it ourselves.
00455         status = DsWriteAccountSpn(hDS, DS_SPN_ADD_SPN_OP, lpCompDN, ulSpn, (LPCTSTR *)Spn);
00456         if (status != NO_ERROR) {
00457             _stprintf(Msg, TEXT("ServiceStart: DsWriteAccountSpn failed with code %d\n"), status);
00458             AddToMessageLog(Msg);
00459             return;
00460         }
00461         DsUnBind(&hDS);
00462         }
00463
00464     // We use Kerberos for authentication on the server.
00465     status = RpcServerRegisterAuthInfo(Spn[0], RPC_C_AUTHN_GSS_KERBEROS, NULL, NULL);
00466     if (status != RPC_S_OK){
00467         _stprintf(Msg, TEXT("ServiceStart: RpcServerRegisterAuthInfo"), status);
00468         AddToMessageLog(Msg);
00469         ServiceStop();
00470         return;
00471     }
00472
00473     // Don't forget to deallocate the principal name array.
00474     DsFreeSpnArray(ulSpn, Spn);
00475
00476     // Create the heap to be used by midl_user_allocate and midl_user_free
00477     RpcHeap = HeapCreate(0, RPC_HEAP_SIZE_INIT, RPC_HEAP_SIZE_MAX);
00478
00479 #ifdef PROF
00480     ProfOpenLog(TEXT("FileRepService.prof"));
00481 #endif
00482
00483     // Start accepting client calls.
00484     // The last argument's being 1 indicates that RpcServerListen
00485     // should return immediately after completing function processing.
00486     status = RpcServerListen(cMinimumThreads, cMaxCallsExecute, 1);
00487     if (status != RPC_S_OK){
00488         AddToMessageLog(TEXT("ServiceStart: RpcServerListen failed\n"));
00489   ServiceStop();
00490         return;
00491     }
00492
00493     bServerListening = TRUE;
00494
00495     // Tell The SCM that the service is running.
00496     if (!ReportStatusToSCMgr(&sshStatusHandle, &ssStatus, SERVICE_RUNNING, NO_ERROR, 0)){
00497         AddToMessageLog(TEXT("ServiceStart: ReportStatusToSCMgr failed"));
00498   ServiceStop();
00499         return;
00500     }
00501
00502     // End of initialization
00503
00504     // RpcMgmtWaitServerListen() will block until the server has
00505     // stopped listening.
00506     status = RpcMgmtWaitServerListen();
00507     if (status != RPC_S_OK){
00508         AddToMessageLog(TEXT("ServiceStart: RpcMgmtWaitServerListen failed"));
00509   ServiceStop();
00510         return;
00511     }
00512
00513     // Cleanup
00514
00515     // Delete the binding vector.
00516     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00517     if(status != RPC_S_OK){
00518         AddToMessageLog(TEXT("ServiceStart: RpcServerUnregisterIf failed"));
00519         return;
00520     }
00521
00522     return;
00523 }
00524
00525
00526 /*
00527     FUNCTION: ServiceStop
00528
00529     PURPOSE: Stops a service
00530
00531     PARAMETERS:
00532         none
00533
00534     RETURN VALUE:
00535         none
00536
00537     COMMENTS:
00538
00539 */
00540 VOID ServiceStop() {
00541     RPC_STATUS status;
00542
00543     // Stops the server, wakes up the main thread.
00544     if (bServerListening) {
00545         status = RpcMgmtStopServerListening(NULL);
00546   if(status != RPC_S_OK) {
00547       AddToMessageLog(TEXT("ServiceStop: RpcMgmtStopServerListening failed."));
00548       return;
00549   }
00550   bServerListening = FALSE;
00551     }
00552
00553     // Tell The SCM that the service is stopped.
00554     if(!ReportStatusToSCMgr(&sshStatusHandle, &ssStatus, SERVICE_STOPPED, NO_ERROR, 0)) {
00555         AddToMessageLog(TEXT("ServiceStop: ReportStatusToSCMgr failed"));
00556         return;
00557     }
00558
00559 #ifdef PROF
00560     ProfCloseLog();
00561 #endif
00562
00563 }
00564
00565 // end FileRepService.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/ToolBand.Cpp Source File

  • WinUI
  • Shell
  • BandObjs

ToolBand.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ToolBand.cpp
00013
00014    Description:   Implements CToolBand
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ToolBand.h"
00023 #include "Guid.h"
00024
00025 /**************************************************************************
00026
00027    CToolBand::CToolBand()
00028
00029 **************************************************************************/
00030
00031 CToolBand::CToolBand()
00032 {
00033 m_pSite = NULL;
00034
00035 m_hWnd = NULL;
00036 m_hwndParent = NULL;
00037
00038 m_bFocus = FALSE;
00039
00040 m_dwViewMode = 0;
00041 m_dwBandID = 0;
00042
00043 m_ObjRefCount = 1;
00044 g_DllRefCount++;
00045 }
00046
00047 /**************************************************************************
00048
00049    CToolBand::~CToolBand()
00050
00051 **************************************************************************/
00052
00053 CToolBand::~CToolBand()
00054 {
00055 //this should have been freed in a call to SetSite(NULL), but just to be safe
00056 if(m_pSite)
00057    {
00058    m_pSite->Release();
00059    m_pSite = NULL;
00060    }
00061
00062 g_DllRefCount--;
00063 }
00064
00065 ///////////////////////////////////////////////////////////////////////////
00066 //
00067 // IUnknown Implementation
00068 //
00069
00070 /**************************************************************************
00071
00072    CToolBand::QueryInterface
00073
00074 **************************************************************************/
00075
00076 STDMETHODIMP CToolBand::QueryInterface(REFIID riid, LPVOID *ppReturn)
00077 {
00078 *ppReturn = NULL;
00079
00080 //IUnknown
00081 if(IsEqualIID(riid, IID_IUnknown))
00082    {
00083    *ppReturn = this;
00084    }
00085
00086 //IOleWindow
00087 else if(IsEqualIID(riid, IID_IOleWindow))
00088    {
00089    *ppReturn = (IOleWindow*)this;
00090    }
00091
00092 //IDockingWindow
00093 else if(IsEqualIID(riid, IID_IDockingWindow))
00094    {
00095    *ppReturn = (IDockingWindow*)this;
00096    }
00097
00098 //IInputObject
00099 else if(IsEqualIID(riid, IID_IInputObject))
00100    {
00101    *ppReturn = (IInputObject*)this;
00102    }
00103
00104 //IObjectWithSite
00105 else if(IsEqualIID(riid, IID_IObjectWithSite))
00106    {
00107    *ppReturn = (IObjectWithSite*)this;
00108    }
00109
00110 //IDeskBand
00111 else if(IsEqualIID(riid, IID_IDeskBand))
00112    {
00113    *ppReturn = (IDeskBand*)this;
00114    }
00115
00116 //IPersist
00117 else if(IsEqualIID(riid, IID_IPersist))
00118    {
00119    *ppReturn = (IPersist*)this;
00120    }
00121
00122 //IPersistStream
00123 else if(IsEqualIID(riid, IID_IPersistStream))
00124    {
00125    *ppReturn = (IPersistStream*)this;
00126    }
00127
00128 //IContextMenu
00129 else if(IsEqualIID(riid, IID_IContextMenu))
00130    {
00131    *ppReturn = (IContextMenu*)this;
00132    }
00133
00134 if(*ppReturn)
00135    {
00136    (*(LPUNKNOWN*)ppReturn)->AddRef();
00137    return S_OK;
00138    }
00139
00140 return E_NOINTERFACE;
00141 }
00142
00143 /**************************************************************************
00144
00145    CToolBand::AddRef
00146
00147 **************************************************************************/
00148
00149 STDMETHODIMP_(DWORD) CToolBand::AddRef()
00150 {
00151 return ++m_ObjRefCount;
00152 }
00153
00154
00155 /**************************************************************************
00156
00157    CToolBand::Release
00158
00159 **************************************************************************/
00160
00161 STDMETHODIMP_(DWORD) CToolBand::Release()
00162 {
00163 if(--m_ObjRefCount == 0)
00164    {
00165    delete this;
00166    return 0;
00167    }
00168
00169 return m_ObjRefCount;
00170 }
00171
00172 ///////////////////////////////////////////////////////////////////////////
00173 //
00174 // IOleWindow Implementation
00175 //
00176
00177 /**************************************************************************
00178
00179    CToolBand::GetWindow()
00180
00181 **************************************************************************/
00182
00183 STDMETHODIMP CToolBand::GetWindow(HWND *phWnd)
00184 {
00185 *phWnd = m_hWnd;
00186
00187 return S_OK;
00188 }
00189
00190 /**************************************************************************
00191
00192    CToolBand::ContextSensitiveHelp()
00193
00194 **************************************************************************/
00195
00196 STDMETHODIMP CToolBand::ContextSensitiveHelp(BOOL fEnterMode)
00197 {
00198 return E_NOTIMPL;
00199 }
00200
00201 ///////////////////////////////////////////////////////////////////////////
00202 //
00203 // IDockingWindow Implementation
00204 //
00205
00206 /**************************************************************************
00207
00208    CToolBand::ShowDW()
00209
00210 **************************************************************************/
00211
00212 STDMETHODIMP CToolBand::ShowDW(BOOL fShow)
00213 {
00214 if(m_hWnd)
00215    {
00216    if(fShow)
00217       {
00218       //show our window
00219       ShowWindow(m_hWnd, SW_SHOW);
00220       }
00221    else
00222       {
00223       //hide our window
00224       ShowWindow(m_hWnd, SW_HIDE);
00225       }
00226    }
00227
00228 return S_OK;
00229 }
00230
00231 /**************************************************************************
00232
00233    CToolBand::CloseDW()
00234
00235 **************************************************************************/
00236
00237 STDMETHODIMP CToolBand::CloseDW(DWORD dwReserved)
00238 {
00239 ShowDW(FALSE);
00240
00241 if(IsWindow(m_hWnd))
00242    DestroyWindow(m_hWnd);
00243
00244 m_hWnd = NULL;
00245
00246 return S_OK;
00247 }
00248
00249 /**************************************************************************
00250
00251    CToolBand::ResizeBorderDW()
00252
00253 **************************************************************************/
00254
00255 STDMETHODIMP CToolBand::ResizeBorderDW(   LPCRECT prcBorder,
00256                                           IUnknown* punkSite,
00257                                           BOOL fReserved)
00258 {
00259 /*
00260 This method is never called for Band Objects.
00261 */
00262 return E_NOTIMPL;
00263 }
00264
00265 ///////////////////////////////////////////////////////////////////////////
00266 //
00267 // IInputObject Implementation
00268 //
00269
00270 /**************************************************************************
00271
00272    CToolBand::UIActivateIO()
00273
00274 **************************************************************************/
00275
00276 STDMETHODIMP CToolBand::UIActivateIO(BOOL fActivate, LPMSG pMsg)
00277 {
00278 if(fActivate)
00279    SetFocus(m_hWnd);
00280
00281 return S_OK;
00282 }
00283
00284 /**************************************************************************
00285
00286    CToolBand::HasFocusIO()
00287
00288    If this window or one of its decendants has the focus, return S_OK. Return
00289    S_FALSE if we don't have the focus.
00290
00291 **************************************************************************/
00292
00293 STDMETHODIMP CToolBand::HasFocusIO(void)
00294 {
00295 if(m_bFocus)
00296    return S_OK;
00297
00298 return S_FALSE;
00299 }
00300
00301 /**************************************************************************
00302
00303    CToolBand::TranslateAcceleratorIO()
00304
00305    If the accelerator is translated, return S_OK or S_FALSE otherwise.
00306
00307 **************************************************************************/
00308
00309 STDMETHODIMP CToolBand::TranslateAcceleratorIO(LPMSG pMsg)
00310 {
00311 return S_FALSE;
00312 }
00313
00314 ///////////////////////////////////////////////////////////////////////////
00315 //
00316 // IObjectWithSite implementations
00317 //
00318
00319 /**************************************************************************
00320
00321    CToolBand::SetSite()
00322
00323 **************************************************************************/
00324
00325 STDMETHODIMP CToolBand::SetSite(IUnknown* punkSite)
00326 {
00327 //If a site is being held, release it.
00328 if(m_pSite)
00329    {
00330    m_pSite->Release();
00331    m_pSite = NULL;
00332    }
00333
00334 //If punkSite is not NULL, a new site is being set.
00335 if(punkSite)
00336    {
00337    //Get the parent window.
00338    IOleWindow  *pOleWindow;
00339
00340    m_hwndParent = NULL;
00341
00342    if(SUCCEEDED(punkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow)))
00343       {
00344       pOleWindow->GetWindow(&m_hwndParent);
00345       pOleWindow->Release();
00346       }
00347
00348    if(!m_hwndParent)
00349       return E_FAIL;
00350
00351    if(!RegisterAndCreateWindow())
00352       return E_FAIL;
00353
00354    //Get and keep the IInputObjectSite pointer.
00355    if(SUCCEEDED(punkSite->QueryInterface(IID_IInputObjectSite, (LPVOID*)&m_pSite)))
00356       {
00357       return S_OK;
00358       }
00359
00360    return E_FAIL;
00361    }
00362
00363 return S_OK;
00364 }
00365
00366 /**************************************************************************
00367
00368    CToolBand::GetSite()
00369
00370 **************************************************************************/
00371
00372 STDMETHODIMP CToolBand::GetSite(REFIID riid, LPVOID *ppvReturn)
00373 {
00374 *ppvReturn = NULL;
00375
00376 if(m_pSite)
00377    return m_pSite->QueryInterface(riid, ppvReturn);
00378
00379 return E_FAIL;
00380 }
00381
00382 ///////////////////////////////////////////////////////////////////////////
00383 //
00384 // IDeskBand implementation
00385 //
00386
00387 /**************************************************************************
00388
00389    CToolBand::GetBandInfo()
00390
00391 **************************************************************************/
00392
00393 STDMETHODIMP CToolBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi)
00394 {
00395 if(pdbi)
00396    {
00397    m_dwBandID = dwBandID;
00398    m_dwViewMode = dwViewMode;
00399
00400    if(pdbi->dwMask & DBIM_MINSIZE)
00401       {
00402       pdbi->ptMinSize.x = TB_MIN_SIZE_X;
00403       pdbi->ptMinSize.y = TB_MIN_SIZE_Y;
00404       }
00405
00406    if(pdbi->dwMask & DBIM_MAXSIZE)
00407       {
00408       pdbi->ptMaxSize.x = -1;
00409       pdbi->ptMaxSize.y = TB_MAX_SIZE_Y;
00410       }
00411
00412    if(pdbi->dwMask & DBIM_INTEGRAL)
00413       {
00414       pdbi->ptIntegral.x = 1;
00415       pdbi->ptIntegral.y = 1;
00416       }
00417
00418    if(pdbi->dwMask & DBIM_ACTUAL)
00419       {
00420       pdbi->ptActual.x = 200;
00421       pdbi->ptActual.y = TB_MAX_SIZE_Y;
00422       }
00423
00424    if(pdbi->dwMask & DBIM_TITLE)
00425       {
00426       lstrcpyW(pdbi->wszTitle, L"Sample Tool Band");
00427       }
00428
00429    if(pdbi->dwMask & DBIM_MODEFLAGS)
00430       {
00431       pdbi->dwModeFlags = DBIMF_NORMAL;
00432
00433       pdbi->dwModeFlags |= DBIMF_VARIABLEHEIGHT;
00434       }
00435
00436    if(pdbi->dwMask & DBIM_BKCOLOR)
00437       {
00438       //Use the default background color by removing this flag.
00439       pdbi->dwMask &= ~DBIM_BKCOLOR;
00440       }
00441
00442    return S_OK;
00443    }
00444
00445 return E_INVALIDARG;
00446 }
00447
00448 ///////////////////////////////////////////////////////////////////////////
00449 //
00450 // IPersistStream implementations
00451 //
00452 // This is only supported to allow the desk band to be dropped on the
00453 // desktop and to prevent multiple instances of the desk band from showing
00454 // up in the context menu. This desk band doesn't actually persist any data.
00455 //
00456
00457 /**************************************************************************
00458
00459    CToolBand::GetClassID()
00460
00461 **************************************************************************/
00462
00463 STDMETHODIMP CToolBand::GetClassID(LPCLSID pClassID)
00464 {
00465 *pClassID = CLSID_SampleDeskBand;
00466
00467 return S_OK;
00468 }
00469
00470 /**************************************************************************
00471
00472    CToolBand::IsDirty()
00473
00474 **************************************************************************/
00475
00476 STDMETHODIMP CToolBand::IsDirty(void)
00477 {
00478 return S_FALSE;
00479 }
00480
00481 /**************************************************************************
00482
00483    CToolBand::Load()
00484
00485 **************************************************************************/
00486
00487 STDMETHODIMP CToolBand::Load(LPSTREAM pStream)
00488 {
00489 return S_OK;
00490 }
00491
00492 /**************************************************************************
00493
00494    CToolBand::Save()
00495
00496 **************************************************************************/
00497
00498 STDMETHODIMP CToolBand::Save(LPSTREAM pStream, BOOL fClearDirty)
00499 {
00500 return S_OK;
00501 }
00502
00503 /**************************************************************************
00504
00505    CToolBand::GetSizeMax()
00506
00507 **************************************************************************/
00508
00509 STDMETHODIMP CToolBand::GetSizeMax(ULARGE_INTEGER *pul)
00510 {
00511 return E_NOTIMPL;
00512 }
00513
00514 ///////////////////////////////////////////////////////////////////////////
00515 //
00516 // private method implementations
00517 //
00518
00519 /**************************************************************************
00520
00521    CToolBand::WndProc()
00522
00523 **************************************************************************/
00524
00525 LRESULT CALLBACK CToolBand::WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
00526 {
00527 CToolBand  *pThis = (CToolBand*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
00528
00529 switch (uMessage)
00530    {
00531    case WM_NCCREATE:
00532       {
00533       LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00534       pThis = (CToolBand*)(lpcs->lpCreateParams);
00535       SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);
00536
00537       //set the window handle
00538       pThis->m_hWnd = hWnd;
00539       }
00540       break;
00541
00542    case WM_PAINT:
00543       return pThis->OnPaint();
00544
00545    case WM_COMMAND:
00546       return pThis->OnCommand(wParam, lParam);
00547
00548    case WM_SETFOCUS:
00549       return pThis->OnSetFocus();
00550
00551    case WM_KILLFOCUS:
00552       return pThis->OnKillFocus();
00553
00554    case WM_SIZE:
00555       return pThis->OnSize(lParam);
00556    }
00557
00558 return DefWindowProc(hWnd, uMessage, wParam, lParam);
00559 }
00560
00561 /**************************************************************************
00562
00563    CToolBand::OnPaint()
00564
00565 **************************************************************************/
00566
00567 LRESULT CToolBand::OnPaint(void)
00568 {
00569 PAINTSTRUCT ps;
00570 RECT        rc;
00571
00572 BeginPaint(m_hWnd, &ps);
00573
00574 GetClientRect(m_hWnd, &rc);
00575 SetTextColor(ps.hdc, RGB(0, 0, 0));
00576 SetBkMode(ps.hdc, TRANSPARENT);
00577 DrawText(ps.hdc, TEXT("Sample Tool Band"), -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
00578
00579 EndPaint(m_hWnd, &ps);
00580
00581 return 0;
00582 }
00583
00584 /**************************************************************************
00585
00586    CToolBand::OnCommand()
00587
00588 **************************************************************************/
00589
00590 LRESULT CToolBand::OnCommand(WPARAM wParam, LPARAM lParam)
00591 {
00592 return 0;
00593 }
00594
00595 /**************************************************************************
00596
00597    CToolBand::OnSize()
00598
00599 **************************************************************************/
00600
00601 LRESULT CToolBand::OnSize(LPARAM lParam)
00602 {
00603 int   cx, cy;
00604
00605 cx = LOWORD(lParam);
00606 cy = HIWORD(lParam);
00607 return 0;
00608 }
00609
00610 /**************************************************************************
00611
00612    CToolBand::FocusChange()
00613
00614 **************************************************************************/
00615
00616 void CToolBand::FocusChange(BOOL bFocus)
00617 {
00618 m_bFocus = bFocus;
00619
00620 //inform the input object site that the focus has changed
00621 if(m_pSite)
00622    {
00623    m_pSite->OnFocusChangeIS((IDockingWindow*)this, bFocus);
00624    }
00625 }
00626
00627 /**************************************************************************
00628
00629    CToolBand::OnSetFocus()
00630
00631 **************************************************************************/
00632
00633 LRESULT CToolBand::OnSetFocus(void)
00634 {
00635 FocusChange(TRUE);
00636
00637 return 0;
00638 }
00639
00640 /**************************************************************************
00641
00642    CToolBand::OnKillFocus()
00643
00644 **************************************************************************/
00645
00646 LRESULT CToolBand::OnKillFocus(void)
00647 {
00648 FocusChange(FALSE);
00649
00650 return 0;
00651 }
00652
00653 /**************************************************************************
00654
00655    CToolBand::RegisterAndCreateWindow()
00656
00657 **************************************************************************/
00658
00659 BOOL CToolBand::RegisterAndCreateWindow(void)
00660 {
00661 //If the window doesn't exist yet, create it now.
00662 if(!m_hWnd)
00663    {
00664    //Can't create a child window without a parent.
00665    if(!m_hwndParent)
00666       {
00667       return FALSE;
00668       }
00669
00670    //If the window class has not been registered, then do so.
00671    WNDCLASS wc;
00672    if(!GetClassInfo(g_hInst, TB_CLASS_NAME, &wc))
00673       {
00674       ZeroMemory(&wc, sizeof(wc));
00675       wc.style          = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
00676       wc.lpfnWndProc    = (WNDPROC)WndProc;
00677       wc.cbClsExtra     = 0;
00678       wc.cbWndExtra     = 0;
00679       wc.hInstance      = g_hInst;
00680       wc.hIcon          = NULL;
00681       wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
00682       wc.hbrBackground  = (HBRUSH)CreateSolidBrush(RGB(255, 255, 0));
00683       wc.lpszMenuName   = NULL;
00684       wc.lpszClassName  = TB_CLASS_NAME;
00685
00686       if(!RegisterClass(&wc))
00687          {
00688          //If RegisterClass fails, CreateWindow below will fail.
00689          }
00690       }
00691
00692    RECT  rc;
00693
00694    GetClientRect(m_hwndParent, &rc);
00695
00696    //Create the window. The WndProc will set m_hWnd.
00697    CreateWindowEx(   0,
00698                      TB_CLASS_NAME,
00699                      NULL,
00700                      WS_CHILD | WS_CLIPSIBLINGS | WS_BORDER,
00701                      rc.left,
00702                      rc.top,
00703                      rc.right - rc.left,
00704                      rc.bottom - rc.top,
00705                      m_hwndParent,
00706                      NULL,
00707                      g_hInst,
00708                      (LPVOID)this);
00709
00710    }
00711
00712 return (NULL != m_hWnd);
00713 }
00714
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcRDO/StdAfx.Cpp Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcRDO

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Dlgopen.c Source File

  • Multimedia
  • Gdi
  • WinCap32

Dlgopen.c

Go to the documentation of this file.
00001 //**************************************************************************
00002 //
00003 // MODULE  : DLGOPEN.C
00004 //
00005 // Routine to display a standard COMMDLG File/Save dialog box.
00006 //
00007 // Defines the following functions:
00008 //
00009 // GetFileName()     - Calls up common dialog file/save, and returns
00010 //                     selected file
00011 //
00012 // Written by Microsoft Product Support Services, Developer Support.
00013 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00014 //**************************************************************************/
00015
00016 #define     STRICT      // enable strict type checking
00017
00018 #include <windows.h>
00019 #include "wincap.h"
00020 #include "dialogs.h"
00021 #include "resource.h"
00022 #include "commdlg.h"  // For common dialogs
00023 #include "dlgs.h"     // For common dialog hook proc
00024
00025 #define MAXFILENAMELEN 144
00026
00027 extern HANDLE ghInst;
00028 extern UINT   guiFileOKMsg;       // for common dialog FILEOKSTRING
00029
00030 BOOL APIENTRY FileSaveHookProc (HWND hDlg, WORD msg, WPARAM wParam, LPARAM lParam);
00031
00032 //************************************************************************
00033 // Function:  GetFileName (HWND, LPSTR, LPDWORD)
00034 //
00035 //   Purpose:  Prompts user for a filename through the use of a Windows 3.1
00036 //             FileOpen common dialog box.
00037 //
00038 //Parameters:  HWND hWndOwner      Owner who is calling this funciton
00039 //
00040 //             LPSTR szFileName    Buffer where selected filename will
00041 //                                 be placed.  Must be at least MAXFILENAMELEN
00042 //                                 characters large
00043 //
00044 //             LPDWORD dwFlags     HIWORD is the bits per pixel, LOWORD
00045 //                                 is compression type.
00046 //
00047 //   Returns:  TRUE if a filename is selected.
00048 //             FALSE if no filename is selected.
00049 //
00050 //  Comments:  Filename is put into the string passed to the routine.
00051 //             If a filename is not selected, NULL is returned.
00052 //
00053 //************************************************************************/
00054
00055 BOOL GetFileName (HWND hWndOwner, LPSTR szFileName, PDWORD_PTR dwFlags)
00056 {
00057     OPENFILENAME   of;
00058     DWORD          flags;
00059     static char    szTitle[50];         // Dialog Box title
00060     static char    szFile[MAXFILENAMELEN];         // File name
00061     DWORD_PTR      dw = 0;               // Local copy of flags for validation
00062     BOOL           bReturn;             // Return code
00063     DWORD_PTR      dwLocalOpt;
00064     CHAR           lpBuffer[128];       // Holds strings retrieved from resources
00065
00066     // Parameter validation -- try to recover gracefully if LPWORD
00067     // is NULL, so we don't die when we try to do a *wFlags = x below
00068
00069   if (!szFileName)
00070     return FALSE;
00071
00072     if (dwFlags == NULL)
00073         dwFlags = &dw;
00074
00075     dwLocalOpt = *dwFlags;  // Make local copy of options
00076
00077     // Initialize the OPENFILENAME members
00078
00079     lstrcpyn(szFile, "*.BMP", 6); // copy the extension over to the file
00080   szFile[5] = '\0';
00081
00082     LoadString(ghInst, IDS_SAVEASTITLE, (LPSTR)szTitle, 50);
00083     LoadString(ghInst, IDS_SAVEFILTER, lpBuffer, sizeof(lpBuffer));
00084     flags = OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_HIDEREADONLY |
00085             OFN_OVERWRITEPROMPT;
00086
00087     of.lStructSize       = sizeof (OPENFILENAME);
00088     of.hwndOwner         = hWndOwner;
00089     of.hInstance         = ghInst;
00090     of.lpstrFilter       = lpBuffer;
00091     of.lpstrCustomFilter = NULL;
00092     of.nMaxCustFilter    = 0L;
00093     of.nFilterIndex      = 1L;
00094     of.lpstrFile         = (LPSTR)szFile;
00095     of.nMaxFile          = MAXFILENAMELEN;
00096     of.lpstrFileTitle    = NULL;
00097     of.nMaxFileTitle     = 0;
00098     of.lpstrInitialDir   = NULL;
00099     of.lpstrTitle        = szTitle;
00100     of.Flags             = flags;
00101     of.nFileOffset       = 0;
00102     of.nFileExtension    = 0;
00103     of.lpstrDefExt       = "bmp";
00104     of.lpfnHook          = (LPOFNHOOKPROC)FileSaveHookProc;
00105     of.lpTemplateName    = (LPSTR)"FILESAVE";
00106
00107     // Place our flags in the lCustData parameter
00108
00109     of.lCustData         = dwLocalOpt;
00110
00111     // Call the GetSaveFilename function
00112
00113     if (GetSaveFileName (&of))
00114     {
00115         // User pressed OK, continue on
00116
00117         bReturn = TRUE;
00118
00119         // Copy filename out
00120
00121         lstrcpyn (szFileName, of.lpstrFile, MAXFILENAMELEN );  // This is the most the file itself can take.  szFileName is 255, of.lpstrFile is 144
00122     szFileName[ sizeof(szFileName) - 1 ] = '\0';
00123
00124         // Copy flags out
00125
00126         *dwFlags = of.lCustData;
00127
00128     }
00129     else
00130     {
00131     MessageBox(hWndOwner,TEXT("An error occurred while saving the file."), TEXT("Error in Save"), MB_OK);
00132         bReturn = FALSE;
00133         szFileName[0] = '\0';
00134         *dwFlags = 0;
00135     }
00136
00137     return bReturn;
00138 }
00139
00140
00141 /*************************************************************************
00142
00143   Function:  FileSaveHookProc (HWND, WORD, WORD, LONG)
00144
00145    Purpose:  Hook procedure for FileSave common dialog box.
00146
00147    Returns:  TRUE if message was processed.
00148              FALSE if the system needs to process the message.
00149
00150   Comments:
00151
00152 *************************************************************************/
00153
00154 BOOL APIENTRY FileSaveHookProc (HWND hDlg, WORD msg, WPARAM wParam, LPARAM lParam)
00155 {
00156     HWND                    hGroup;
00157     RECT                    rect, DlgRect;
00158     static LPOPENFILENAME   lpOpenFn;
00159     static DWORD_PTR        dwFlags;
00160
00161     if (wParam == guiFileOKMsg)
00162     {
00163         WORD    biStyle, biBits;
00164
00165         if (SendDlgItemMessage (hDlg, IDD_RGB, BM_GETCHECK, 0, 0L))
00166             biStyle = IDD_RGB;
00167
00168         else if (SendDlgItemMessage (hDlg, IDD_RLE4, BM_GETCHECK, 0, 0L))
00169             biStyle = IDD_RLE4;
00170
00171         else
00172             biStyle = IDD_RLE8;
00173
00174         if (SendDlgItemMessage (hDlg, IDD_1, BM_GETCHECK, 0, 0L))
00175             biBits = 1;
00176
00177         else if (SendDlgItemMessage (hDlg, IDD_4, BM_GETCHECK, 0, 0L))
00178             biBits = 4;
00179
00180         else if (SendDlgItemMessage (hDlg, IDD_8, BM_GETCHECK, 0, 0L))
00181             biBits = 8;
00182
00183         else
00184             biBits = 24;
00185
00186         // Copy result of user input to our lCustData field, which
00187         // will pass it back to the calling function.
00188
00189         lpOpenFn->lCustData = MAKELONG(biStyle, biBits);
00190         return FALSE;
00191     }
00192
00193     switch (msg)
00194     {
00195         case WM_INITDIALOG:
00196
00197             //  Get the memory handle stored in the extra words.
00198             //  From this, insert the filename, and the file format
00199
00200             // Retrieve flags which we passed in in lCustData
00201
00202             lpOpenFn = (LPOPENFILENAME)lParam;
00203             dwFlags = lpOpenFn->lCustData;
00204
00205             // Our dwFlags field contains the following:
00206             //
00207             // HIWORD: Bits per pixel specification.  Should be set to
00208             //    one of the following: 1, 4, 8, or 24
00209             //
00210             // LOWORD: Compression specification:  Should be set to one of
00211             //    the following:   IDD_RGB, IDD_RLE4, IDD_RLE8
00212
00213             switch (LOWORD(dwFlags))
00214             {
00215                 case IDD_RGB:
00216                     SendDlgItemMessage (hDlg, IDD_RGB,  BM_SETCHECK, 1, 0L);
00217                     SendMessage (hDlg, WM_COMMAND, IDD_RGB, 0L);
00218                     break;
00219
00220                 case IDD_RLE4:
00221                     SendDlgItemMessage (hDlg, IDD_RLE4, BM_SETCHECK, 1, 0L);
00222                     SendMessage (hDlg, WM_COMMAND, IDD_RLE4, 0L);
00223                     break;
00224
00225                 case IDD_RLE8:
00226
00227                 default:
00228                     SendDlgItemMessage (hDlg, IDD_RLE8, BM_SETCHECK, 1, 0L);
00229                     SendMessage (hDlg, WM_COMMAND, IDD_RLE8, 0L);
00230                     break;
00231             }
00232
00233             switch (HIWORD(dwFlags))
00234             {
00235                 case 4:
00236                     SendDlgItemMessage (hDlg, IDD_4,   BM_SETCHECK, 1, 0L);
00237                     break;
00238
00239                 case 8:
00240                     SendDlgItemMessage (hDlg, IDD_8,   BM_SETCHECK, 1, 0L);
00241                     break;
00242
00243                 case 24:
00244                     SendDlgItemMessage (hDlg, IDD_24,  BM_SETCHECK, 1, 0L);
00245                     break;
00246
00247                 case 1:
00248
00249                 default:
00250                     SendDlgItemMessage (hDlg, IDD_1,   BM_SETCHECK, 1, 0L);
00251                     break;
00252             }
00253
00254             // Return 1 so Windows sets focus on a control in our dialog.
00255
00256             return 1;
00257
00258         case WM_COMMAND:
00259             switch (wParam)
00260             {
00261
00262             case IDD_FILETYPE:
00263                 hGroup = GetDlgItem (hDlg, IDD_FILETYPEGROUP);
00264                 GetWindowRect (hGroup, &rect);
00265                 GetWindowRect (hDlg, &DlgRect);
00266                 SetWindowPos (hDlg,0, DlgRect.left, DlgRect.top,
00267                         (DlgRect.right-DlgRect.left),
00268                         (rect.bottom+(rect.left-DlgRect.left)-DlgRect.top),
00269                         SWP_NOMOVE | SWP_NOZORDER);
00270                 EnableWindow (GetDlgItem (hDlg, IDD_FILETYPE), 0);
00271                 SetFocus (hGroup);
00272                 break;
00273
00274             case IDD_RLE4:
00275                 if (SendDlgItemMessage (hDlg, IDD_1, BM_GETCHECK, 0, 0L))
00276                     SendDlgItemMessage (hDlg, IDD_1, BM_SETCHECK, 0,0L);
00277                 if (SendDlgItemMessage (hDlg, IDD_8, BM_GETCHECK, 0, 0L))
00278                     SendDlgItemMessage (hDlg, IDD_8, BM_SETCHECK, 0,0L);
00279                 if (SendDlgItemMessage (hDlg, IDD_24, BM_GETCHECK, 0, 0L))
00280                     SendDlgItemMessage (hDlg, IDD_24, BM_SETCHECK, 0,0L);
00281
00282                 EnableWindow (GetDlgItem(hDlg, IDD_4), 1);
00283                 SendDlgItemMessage (hDlg, IDD_4, BM_SETCHECK, 1, 0L);
00284                 EnableWindow (GetDlgItem(hDlg, IDD_1), 0);
00285                 EnableWindow (GetDlgItem(hDlg, IDD_8), 0);
00286                 EnableWindow (GetDlgItem(hDlg, IDD_24), 0);
00287                 break;
00288
00289             case IDD_RLE8:
00290                 if (SendDlgItemMessage (hDlg, IDD_1, BM_GETCHECK, 0, 0L))
00291                     SendDlgItemMessage (hDlg, IDD_1, BM_SETCHECK, 0,0L);
00292                 if (SendDlgItemMessage (hDlg, IDD_4, BM_GETCHECK, 0, 0L))
00293                     SendDlgItemMessage (hDlg, IDD_4, BM_SETCHECK, 0,0L);
00294                 if (SendDlgItemMessage (hDlg, IDD_24, BM_GETCHECK, 0, 0L))
00295                     SendDlgItemMessage (hDlg, IDD_24, BM_SETCHECK, 0,0L);
00296
00297                 EnableWindow (GetDlgItem(hDlg, IDD_8), 1);
00298                 SendDlgItemMessage (hDlg, IDD_8, BM_SETCHECK, 1, 0L);
00299                 EnableWindow (GetDlgItem(hDlg, IDD_1), 0);
00300                 EnableWindow (GetDlgItem(hDlg, IDD_4), 0);
00301                 EnableWindow (GetDlgItem(hDlg, IDD_24), 0);
00302                 break;
00303
00304             case IDD_RGB:
00305                 EnableWindow (GetDlgItem(hDlg, IDD_1), 1);
00306                 EnableWindow (GetDlgItem(hDlg, IDD_4), 2);
00307                 EnableWindow (GetDlgItem(hDlg, IDD_8), 3);
00308                 EnableWindow (GetDlgItem(hDlg, IDD_24), 1);
00309                 break;
00310
00311             break;
00312         }
00313
00314         default:
00315             break;
00316     }
00317     return FALSE;
00318 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/people.h Source File

  • SysMgmt
  • MMC
  • Toolbar

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBicycle : public CDelegationBase {
00026 public:
00027     CBicycle(int i) : id(i) { }
00028     virtual ~CBicycle() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00033
00034 private:
00035     // {2974380D-4C4B-11d2-89D8-000021473128}
00036     static const GUID thisGuid;
00037
00038     int id;
00039 };
00040
00041 class CBicycleFolder : public CDelegationBase {
00042 public:
00043     CBicycleFolder();
00044     virtual ~CBicycleFolder();
00045
00046     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Bicycles"); }
00047     virtual const GUID & getNodeType() { return thisGuid; }
00048     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00049
00050 public:
00051     // virtual functions go here (for MMCN_*)
00052     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00053
00054 private:
00055     // {2974380D-4C4B-11d2-89D8-000021473128}
00056     static const GUID thisGuid;
00057
00058     enum { NUMBER_OF_CHILDREN = 20 };
00059     CDelegationBase *children[NUMBER_OF_CHILDREN];
00060 };
00061
00062 class CSkateboard : public CDelegationBase {
00063 public:
00064     CSkateboard(int i) : id(i) { }
00065     virtual ~CSkateboard() {}
00066
00067     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00068     virtual const GUID & getNodeType() { return thisGuid; }
00069     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00070
00071 private:
00072     // {2974380D-4C4B-11d2-89D8-000021473128}
00073     static const GUID thisGuid;
00074
00075     int id;
00076 };
00077
00078 class CSkateboardFolder : public CDelegationBase {
00079 public:
00080     CSkateboardFolder();
00081     virtual ~CSkateboardFolder();
00082
00083     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Skateboards"); }
00084     virtual const GUID & getNodeType() { return thisGuid; }
00085     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00086
00087 public:
00088     // virtual functions go here (for MMCN_*)
00089     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00090
00091 private:
00092     // {2974380D-4C4B-11d2-89D8-000021473128}
00093     static const GUID thisGuid;
00094
00095     enum { NUMBER_OF_CHILDREN = 20 };
00096     CDelegationBase *children[NUMBER_OF_CHILDREN];
00097 };
00098
00099 class CIceSkate : public CDelegationBase {
00100 public:
00101     CIceSkate(int i) : id(i) { }
00102     virtual ~CIceSkate() {}
00103
00104     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00105     virtual const GUID & getNodeType() { return thisGuid; }
00106     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00107
00108 private:
00109     // {2974380D-4C4B-11d2-89D8-000021473128}
00110     static const GUID thisGuid;
00111
00112     int id;
00113 };
00114
00115 class CIceSkateFolder : public CDelegationBase {
00116 public:
00117     CIceSkateFolder();
00118     virtual ~CIceSkateFolder();
00119
00120     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Ice Skates"); }
00121     virtual const GUID & getNodeType() { return thisGuid; }
00122     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00123
00124 public:
00125     // virtual functions go here (for MMCN_*)
00126     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00127
00128 private:
00129     // {2974380D-4C4B-11d2-89D8-000021473128}
00130     static const GUID thisGuid;
00131
00132     enum { NUMBER_OF_CHILDREN = 20 };
00133     CDelegationBase *children[NUMBER_OF_CHILDREN];
00134 };
00135
00136 class CPeoplePoweredVehicle : public CDelegationBase {
00137 public:
00138     CPeoplePoweredVehicle(CComponentData *pComponentData = NULL);
00139     virtual ~CPeoplePoweredVehicle();
00140
00141     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00142     virtual const GUID & getNodeType() { return thisGuid; }
00143     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00144
00145     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00146
00147 private:
00148     enum { IDM_NEW_PEOPLE = 1 };
00149
00150     // {2974380D-4C4B-11d2-89D8-000021473128}
00151     static const GUID thisGuid;
00152
00153     enum { NUMBER_OF_CHILDREN = 3 };
00154     CDelegationBase *children[3];
00155 };
00156
00157 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_OPTIONS Member List

This is the complete list of members for _OPTIONS, including all inherited members.
bGlobalTemplate | _OPTIONS
buf | _OPTIONS
bVerbose | _OPTIONS
cmd | _OPTIONS
dwSleep | _OPTIONS
dwSleepClose | _OPTIONS
dwTotalClients | _OPTIONS
fillchar | _OPTIONS
nBufSize | _OPTIONS
nRepeat | _OPTIONS
nTotalThreads | _OPTIONS
port | _OPTIONS
port | _OPTIONS
protocolInfo | _OPTIONS
qosOptions | _OPTIONS
spOptions | _OPTIONS
szHostname | _OPTIONS
szHostname | _OPTIONS
szLocalInterface | _OPTIONS
szRemoteInterface | _OPTIONS
template_cmd | _OPTIONS
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Stack_c< T > Member List

This is the complete list of members for Stack_c< T >, including all inherited members.
GetFromBack(T &data) | NIDeque_c< T > | [private]
GetFromFront(T &data) | NIDeque_c< T > | [private]
InsertIntoBack(T data) | NIDeque_c< T > | [private]
InsertIntoFront(T data) | NIDeque_c< T > | [private]
IsEmpty() | Stack_c< T > | [inline]
NIDeque_c() | NIDeque_c< T > | [private]
Pop(T &Data) | Stack_c< T > | [inline]
Push(T Data) | Stack_c< T > | [inline]
RemoveFromBack(T &data) | NIDeque_c< T > | [private]
RemoveFromFront(T &data) | NIDeque_c< T > | [private]
Stack_c() | Stack_c< T > | [inline]
~NIDeque_c() | NIDeque_c< T > | [private]
~Stack_c() | Stack_c< T > | [inline]
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/StringUtils.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

StringUtils.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      StringUtils.cpp
00005 //
00006 //  Description:
00007 //      Implementation of string manipulation routines.
00008 //
00009 //  Header File:
00010 //      StringUtils.h
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 //////////////////////////////////////////////////////////////////////////////
00015 // Include Files
00016 //////////////////////////////////////////////////////////////////////////////
00017
00018 #include "StdAfx.h"
00019
00020
00021 //////////////////////////////////////////////////////////////////////////////
00022 // String comparison routines
00023 //////////////////////////////////////////////////////////////////////////////
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 //++
00028 //
00029 //  WrapCompareString
00030 //
00031 //  Description:
00032 //      Wraps the call to CompareString
00033 //
00034 //  Arguments:
00035 //      fCaseSensitive      TRUE for a case sensitive compare
00036 //                          FALSE for a case insensitive compare
00037 //      pcwszString1In      The first string.
00038 //      cch1In              The length of the first string.
00039 //      pcwszString2In      The second string.
00040 //      cchIn               The length of the second string.
00041 //
00042 //  Return Value:
00043 //       0  Strings are equal.
00044 //     > 0  String1 greater than String2.
00045 //     < 0  String1 less than String2.
00046 //
00047 //--
00048 /////////////////////////////////////////////////////////////////////////////
00049 int
00050 WrapCompareString(
00051       BOOL      fCaseSensitive
00052     , LPCWSTR   pcwszString1In
00053     , size_t    cch1In
00054     , LPCWSTR   pcwszString2In
00055     , size_t    cch2In
00056     )
00057 {
00058     int nRet;
00059
00060     nRet = CompareStringW(
00061               LOCALE_SYSTEM_DEFAULT
00062             , fCaseSensitive ? 0 : NORM_IGNORECASE
00063             , pcwszString1In
00064             , static_cast< DWORD >( cch1In )
00065             , pcwszString2In
00066             , static_cast< DWORD >( cch2In )
00067             );
00068
00069     return nRet - CSTR_EQUAL; // CSTR_LT < CSTR_EQUAL < CSTR_GT
00070
00071 } // *** WrapCompareString
00072
00073 //
00074 // Full string compares.
00075 //
00076
00077 int
00078 IBSTRCompareW(
00079       BSTR  bstrString1In
00080     , BSTR  bstrString2In
00081     )
00082 {
00083     return WrapCompareString(
00084                   FALSE
00085                 , static_cast< LPCWSTR >( bstrString1In )
00086                 , SysStringLen( bstrString1In )
00087                 , static_cast< LPCWSTR >( bstrString2In )
00088                 , SysStringLen( bstrString2In )
00089                 );
00090 } //*** IBSTRCompareW
00091
00092 int
00093 BSTRCompareW(
00094       BSTR  bstrString1In
00095     , BSTR  bstrString2In
00096     )
00097 {
00098     return WrapCompareString(
00099                   TRUE
00100                 , static_cast< LPCWSTR >( bstrString1In )
00101                 , SysStringLen( bstrString1In )
00102                 , static_cast< LPCWSTR >( bstrString2In )
00103                 , SysStringLen( bstrString2In )
00104                 );
00105 } //*** BSTRCompareW
00106
00107 int
00108 IStringCompareW(
00109       LPCWSTR pcwszString1In
00110     , LPCWSTR pcwszString2In
00111     )
00112 {
00113     return WrapCompareString(
00114                   FALSE
00115                 , pcwszString1In
00116                 , static_cast< size_t >( -1 )
00117                 , pcwszString2In
00118                 , static_cast< size_t >( -1 )
00119             );
00120 } //*** IStringCompareW
00121
00122 int
00123 StringCompareW(
00124       LPCWSTR pcwszString1In
00125     , LPCWSTR pcwszString2In
00126     )
00127 {
00128     return WrapCompareString(
00129                   TRUE
00130                 , pcwszString1In
00131                 , static_cast< size_t >( -1 )
00132                 , pcwszString2In
00133                 , static_cast< size_t >( -1 )
00134                 );
00135 } //*** StringCompareW
00136
00137 int
00138 IStringCompareW(
00139       LPCWSTR   pcwszString1In
00140     , size_t    cch1In
00141     , LPCWSTR   pcwszString2In
00142     , size_t    cch2In
00143     )
00144 {
00145     return WrapCompareString(
00146                   FALSE
00147                 , pcwszString1In
00148                 , cch1In
00149                 , pcwszString2In
00150                 , cch2In
00151                 );
00152 } //*** IStringCompareW
00153
00154 int
00155 StringCompareW(
00156       LPCWSTR   pcwszString1In
00157     , size_t    cch1In
00158     , LPCWSTR   pcwszString2In
00159     , size_t    cch2In
00160     )
00161 {
00162     return WrapCompareString(
00163                   TRUE
00164                 , pcwszString1In
00165                 , cch1In
00166                 , pcwszString2In
00167                 , cch2In
00168                 );
00169 } //*** StringCompareW
00170
00171 //
00172 // Partial string compares.  They use whichever one's length is shortest
00173 // if both are specified or the NBSTR routines are used.
00174 //
00175
00176 int
00177 NIBSTRCompareW(
00178       BSTR  bstrString1In
00179     , BSTR  bstrString2In
00180     )
00181 {
00182     size_t cchMin;
00183
00184     cchMin = min( SysStringLen( bstrString1In ), SysStringLen( bstrString2In ) );
00185
00186     return WrapCompareString(
00187                   FALSE
00188                 , static_cast< LPCWSTR >( bstrString1In )
00189                 , cchMin
00190                 , static_cast< LPCWSTR >( bstrString2In )
00191                 , cchMin
00192                 );
00193 } //*** NIBSTRCompareW
00194
00195 int
00196 NBSTRCompareW(
00197       BSTR  bstrString1In
00198     , BSTR  bstrString2In
00199     )
00200 {
00201     size_t cchMin;
00202
00203     cchMin = min( SysStringLen( bstrString1In ), SysStringLen( bstrString2In ) );
00204
00205     return WrapCompareString(
00206                   TRUE
00207                 , static_cast< LPCWSTR >( bstrString1In )
00208                 , cchMin
00209                 , static_cast< LPCWSTR >( bstrString2In )
00210                 , cchMin
00211                 );
00212 } //*** NBSTRCompareW
00213
00214 int
00215 NIStringCompareW(
00216       LPCWSTR   pcwszString1In
00217     , LPCWSTR   pcwszString2In
00218     , size_t    cchIn
00219     )
00220 {
00221     return WrapCompareString(
00222                   FALSE
00223                 , pcwszString1In
00224                 , cchIn
00225                 , pcwszString2In
00226                 , cchIn
00227                 );
00228 } //*** NIStringCompareW
00229
00230 int
00231 NStringCompareW(
00232       LPCWSTR   pcwszString1In
00233     , LPCWSTR   pcwszString2In
00234     , size_t    cchIn
00235     )
00236 {
00237     return WrapCompareString(
00238                   TRUE
00239                 , pcwszString1In
00240                 , cchIn
00241                 , pcwszString2In
00242                 , cchIn
00243                 );
00244 } //*** NIStringCompareW
00245
00246 int
00247 NIStringCompareW(
00248       LPCWSTR   pcwszString1In
00249     , size_t    cch1In
00250     , LPCWSTR   pcwszString2In
00251     , size_t    cch2In
00252     )
00253 {
00254     return WrapCompareString(
00255                   FALSE
00256                 , pcwszString1In
00257                 , min( cch1In, cch2In )
00258                 , pcwszString2In
00259                 , min( cch1In, cch2In )
00260                 );
00261 } //*** NIStringCompareW
00262
00263 int
00264 NStringCompareW(
00265       LPCWSTR   pcwszString1In
00266     , size_t    cch1In
00267     , LPCWSTR   pcwszString2In
00268     , size_t    cch2In
00269     )
00270 {
00271     return WrapCompareString(
00272                   TRUE
00273                 , pcwszString1In
00274                 , min( cch1In, cch2In )
00275                 , pcwszString2In
00276                 , min( cch1In, cch2In )
00277                 );
00278 } //*** NStringCompareW
00279
00280
00281
00282 //////////////////////////////////////////////////////////////////////////////
00283 // Load string routines
00284 //////////////////////////////////////////////////////////////////////////////
00285
00286
00287 //////////////////////////////////////////////////////////////////////////////
00288 //++
00289 //
00290 //  HrLoadStringIntoBSTR
00291 //
00292 //  Description:
00293 //      Retrieves the string resource idsIn from the string table and makes it
00294 //      into a BSTR. If the BSTR is not NULL coming it, it will assume that
00295 //      you are trying reuse an existing BSTR.
00296 //
00297 //  Arguments:
00298 //      hInstanceIn
00299 //          Handle to an instance of the module whose executable file
00300 //          contains the string resource.  If not specified, defaults to
00301 //          _Module_mhInstResource.
00302 //
00303 //      langidIn
00304 //          Language ID of string table resource.
00305 //
00306 //      idsIn
00307 //          Specifies the integer identifier of the string to be loaded.
00308 //
00309 //      pbstrInout
00310 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00311 //          may be the same or NULL.
00312 //
00313 //  Return Values:
00314 //      S_OK
00315 //          The call succeeded.
00316 //
00317 //      E_OUTOFMEMORY
00318 //          Out of memory.
00319 //
00320 //      E_POINTER
00321 //          pbstrInout is NULL.
00322 //
00323 //      Other HRESULTs
00324 //          The call failed.
00325 //
00326 //  Remarks:
00327 //      This routine uses LoadResource so that it can get the actual length
00328 //      of the string resource.  If we didn't do this, we would need to call
00329 //      LoadString and allocate memory in a loop.  Very inefficient!
00330 //
00331 //--
00332 //////////////////////////////////////////////////////////////////////////////
00333 HRESULT
00334 HrLoadStringIntoBSTR(
00335       HINSTANCE hInstanceIn
00336     , LANGID    langidIn
00337     , UINT      idsIn
00338     , BSTR *    pbstrInout
00339     )
00340
00341 {
00342     HRESULT hr              = S_OK;
00343     HRSRC   hrsrc           = NULL;
00344     HGLOBAL hgbl            = NULL;
00345     int     cch             = 0;
00346     PBYTE   pbStringData;
00347     PBYTE   pbStringDataMax;
00348     PBYTE   pbStringTable;
00349     int     cbStringTable;
00350     int     nTable;
00351     int     nOffset;
00352     int     idxString;
00353
00354     assert( idsIn != 0 );
00355     assert( pbstrInout != NULL );
00356
00357     if ( pbstrInout == NULL )
00358     {
00359         hr = E_POINTER;
00360         goto Cleanup;
00361     } // if:
00362
00363     if ( hInstanceIn == NULL )
00364     {
00365         hInstanceIn = _Module.m_hInstResource;
00366     } // if:
00367
00368     //
00369     //  The resource Id specified must be converted to an index into
00370     //  a Windows StringTable.
00371     //
00372
00373     nTable = idsIn / 16;
00374     nOffset = idsIn - (nTable * 16);
00375
00376     //
00377     //  Internal Table Id's start at 1 not 0.
00378     //
00379
00380     nTable++;
00381
00382     //
00383     // Find the part of the string table where the string resides.
00384     //
00385
00386     //
00387     //  Find the table containing the string.
00388     // First try to load the language specified.  If we can't find it we
00389     // try the "neutral" language.
00390     //
00391
00392     hrsrc = FindResourceEx( hInstanceIn, RT_STRING, MAKEINTRESOURCE( nTable ), langidIn );
00393     if ( ( hrsrc == NULL ) && ( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND ) )
00394     {
00395         hrsrc = FindResourceEx(
00396                       hInstanceIn
00397                     , RT_STRING
00398                     , MAKEINTRESOURCE( nTable )
00399                     , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
00400                     );
00401     } // if: FindResourceEx failed
00402
00403     if ( hrsrc == NULL )
00404     {
00405         hr = HRESULT_FROM_WIN32( GetLastError() );
00406         goto Cleanup;
00407     } // if:
00408
00409     //
00410     //  Load the table.
00411     //
00412
00413     hgbl = LoadResource( hInstanceIn, hrsrc );
00414     if ( hgbl == NULL )
00415     {
00416         hr = HRESULT_FROM_WIN32( GetLastError() );
00417         goto Cleanup;
00418     } // if:
00419
00420     //
00421     //  Lock the table so we access its data.
00422     //
00423
00424     pbStringTable = reinterpret_cast< PBYTE >( LockResource( hgbl ) );
00425     if ( pbStringTable == NULL )
00426     {
00427         hr = HRESULT_FROM_WIN32( GetLastError() );
00428         goto Cleanup;
00429     } // if:
00430
00431     cbStringTable = SizeofResource( hInstanceIn, hrsrc );
00432     assert( cbStringTable != 0 );
00433
00434     //
00435     //  Set the data pointer to the beginning of the table.
00436     //
00437
00438     pbStringData = pbStringTable;
00439     pbStringDataMax = pbStringTable + cbStringTable;
00440
00441     //
00442     // Skip strings in the block of 16 which are before the desired string.
00443     //
00444
00445     for ( idxString = 0 ; idxString <= nOffset ; idxString++ )
00446     {
00447         assert( pbStringData != NULL );
00448         assert( pbStringData < pbStringDataMax );
00449
00450         //
00451         //  Get the number of characters excluding the '\0'.
00452         //
00453
00454         cch = * ( (USHORT *) pbStringData );
00455
00456         //
00457         //  Found the string.
00458         //
00459
00460         if ( idxString == nOffset )
00461         {
00462             if ( cch == 0 )
00463             {
00464                 hr = HRESULT_FROM_WIN32( ERROR_RESOURCE_NAME_NOT_FOUND );
00465                 goto Cleanup;
00466             } // if:
00467
00468             //
00469             //  Skip over the string length to get the string.
00470             //
00471
00472             pbStringData += sizeof( WCHAR );
00473
00474             break;
00475         } // if: found the string
00476
00477         //
00478         //  Add one to account for the string length.
00479         //  A string length of 0 still takes 1 WCHAR for the length portion.
00480         //
00481
00482         cch++;
00483
00484         //
00485         //  Skip over this string to get to the next string.
00486         //
00487
00488         pbStringData += ( cch * sizeof( WCHAR ) );
00489
00490     } // for: each string in the block of 16 strings in the table
00491
00492     //
00493     //  Note: nStringLen is the number of characters in the string not including the '\0'.
00494     //
00495
00496     //
00497     // If previously allocated free it before re-allocating it.
00498     //
00499
00500     if ( *pbstrInout != NULL )
00501     {
00502         SysFreeString( *pbstrInout );
00503         *pbstrInout = NULL;
00504     } // if: string was allocated previously
00505
00506     //
00507     // Allocate a BSTR for the string.
00508     //
00509
00510     *pbstrInout = SysAllocStringLen( (OLECHAR *) pbStringData, cch );
00511     if ( *pbstrInout == NULL )
00512     {
00513         hr = E_OUTOFMEMORY;
00514         goto Cleanup;
00515     } // if:
00516
00517 Cleanup:
00518
00519     return hr;
00520
00521 } //*** HrLoadStringIntoBSTR
00522
00523
00524 //////////////////////////////////////////////////////////////////////////////
00525 // Format string ID routines
00526 //////////////////////////////////////////////////////////////////////////////
00527
00528
00529 //////////////////////////////////////////////////////////////////////////////
00530 //++
00531 //
00532 //  HrFormatStringIntoBSTR
00533 //
00534 //  Description:
00535 //      Format a string (specified by idsIn, a string resource ID) and
00536 //      variable arguments into a BSTR using the FormatMessage() Win32 API.
00537 //      If the BSTR is not NULL on entry, the BSTR will be reused.
00538 //
00539 //      Calls HrFormatStringWithVAListIntoBSTR to perform the actual work.
00540 //
00541 //  Arguments:
00542 //      hInstanceIn
00543 //          Handle to an instance of the module whose executable file
00544 //          contains the string resource.
00545 //
00546 //      langidIn
00547 //          Language ID of string table resource.
00548 //
00549 //      idsIn
00550 //          Specifies the integer identifier of the string to be loaded.
00551 //
00552 //      pbstrInout
00553 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00554 //          may be the same or NULL.
00555 //
00556 //      ...
00557 //          Arguments for substitution points in the status text message.
00558 //          The FormatMessage() API is used for formatting the string, so
00559 //          substitution points must of the form %1!ws! and not %ws.
00560 //
00561 //  Return Values:
00562 //      S_OK
00563 //          The call succeeded.
00564 //
00565 //      Other HRESULTs
00566 //          The call failed.
00567 //
00568 //--
00569 //////////////////////////////////////////////////////////////////////////////
00570 HRESULT
00571 HrFormatStringIntoBSTR(
00572       HINSTANCE hInstanceIn
00573     , LANGID    langidIn
00574     , UINT      idsIn
00575     , BSTR *    pbstrInout
00576     , ...
00577     )
00578 {
00579     HRESULT hr;
00580     va_list valist;
00581
00582     va_start( valist, pbstrInout );
00583
00584     hr = HrFormatStringWithVAListIntoBSTR(
00585                           hInstanceIn
00586                         , langidIn
00587                         , idsIn
00588                         , pbstrInout
00589                         , valist
00590                         );
00591
00592     va_end( valist );
00593
00594     return hr;
00595
00596 } //*** HrFormatStringIntoBSTR
00597
00598 //////////////////////////////////////////////////////////////////////////////
00599 //++
00600 //
00601 //  HrFormatStringWithVAListIntoBSTR
00602 //
00603 //  Description:
00604 //      Format a string (specified by idsIn, a string resource ID) and
00605 //      variable arguments into a BSTR using the FormatMessage() Win32 API.
00606 //      If the BSTR is not NULL on entry, the BSTR will be reused.
00607 //
00608 //  Arguments:
00609 //      hInstanceIn
00610 //          Handle to an instance of the module whose executable file
00611 //          contains the string resource.
00612 //
00613 //      langidIn
00614 //          Language ID of string table resource.
00615 //
00616 //      idsIn
00617 //          Specifies the integer identifier of the string to be loaded.
00618 //
00619 //      pbstrInout
00620 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00621 //          may be the same or NULL.
00622 //
00623 //      valistIn
00624 //          Arguments for substitution points in the status text message.
00625 //          The FormatMessage() API is used for formatting the string, so
00626 //          substitution points must of the form %1!ws! and not %ws.
00627 //
00628 //  Return Values:
00629 //      S_OK
00630 //          The call succeeded.
00631 //
00632 //      E_OUTOFMEMORY
00633 //          Out of memory.
00634 //
00635 //      E_POINTER
00636 //          pbstrInout is NULL.
00637 //
00638 //      Other HRESULTs
00639 //          The call failed.
00640 //
00641 //--
00642 //////////////////////////////////////////////////////////////////////////////
00643 HRESULT
00644 HrFormatStringWithVAListIntoBSTR(
00645       HINSTANCE hInstanceIn
00646     , LANGID    langidIn
00647     , UINT      idsIn
00648     , BSTR *    pbstrInout
00649     , va_list   valistIn
00650     )
00651 {
00652     HRESULT hr = S_OK;
00653     BSTR    bstrStringResource = NULL;
00654     DWORD   cch;
00655     LPWSTR  pwsz = NULL;
00656
00657     assert( pbstrInout != NULL );
00658
00659     if ( pbstrInout == NULL )
00660     {
00661         hr = E_POINTER;
00662         goto Cleanup;
00663     } // if:
00664
00665     //
00666     // Load the string resource.
00667     //
00668
00669     hr = HrLoadStringIntoBSTR( hInstanceIn, langidIn, idsIn, &bstrStringResource );
00670     if ( FAILED( hr ) )
00671     {
00672         goto Cleanup;
00673     } // if:
00674
00675     //
00676     // Format the message with the arguments.
00677     //
00678
00679     cch = FormatMessage(
00680                       ( FORMAT_MESSAGE_ALLOCATE_BUFFER
00681                       | FORMAT_MESSAGE_FROM_STRING )
00682                     , bstrStringResource
00683                     , 0
00684                     , 0
00685                     , (LPWSTR) &pwsz
00686                     , 0
00687                     , &valistIn
00688                     );
00689     if ( cch == 0 )
00690     {
00691         hr = HRESULT_FROM_WIN32( GetLastError() );
00692         goto Cleanup;
00693     } // if:
00694
00695     //
00696     // If previously allocated free it before re-allocating it.
00697     //
00698
00699     if ( *pbstrInout != NULL )
00700     {
00701         SysFreeString( *pbstrInout );
00702         *pbstrInout = NULL;
00703     } // if:
00704
00705     //
00706     // Allocate a BSTR for the string.
00707     //
00708
00709     *pbstrInout = SysAllocStringLen( pwsz, cch );
00710     if ( *pbstrInout == NULL )
00711     {
00712         hr = E_OUTOFMEMORY;
00713         goto Cleanup;
00714     } // if:
00715
00716 Cleanup:
00717
00718     SysFreeString( bstrStringResource );
00719     LocalFree( pwsz );
00720
00721     return hr;
00722
00723 } //*** HrFormatStringWithVAListIntoBSTR
00724
00725
00726 //////////////////////////////////////////////////////////////////////////////
00727 // Format string routines
00728 //////////////////////////////////////////////////////////////////////////////
00729
00730
00731 //////////////////////////////////////////////////////////////////////////////
00732 //++
00733 //
00734 //  HrFormatStringIntoBSTR
00735 //
00736 //  Description:
00737 //      Format a string (specified by pcwszFmtIn) and variable arguments into
00738 //      a BSTR using the FormatMessage() Win32 API.  If the BSTR is not NULL
00739 //      on entry, the BSTR will be reused.
00740 //
00741 //      Calls HrFormatStringWithVAListIntoBSTR to perform the actual work.
00742 //
00743 //  Arguments:
00744 //      pcwszFmtIn
00745 //          Specifies the format string.
00746 //
00747 //      pbstrInout
00748 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00749 //          may be the same or NULL.
00750 //
00751 //      ...
00752 //          Arguments for substitution points in the status text message.
00753 //          The FormatMessage() API is used for formatting the string, so
00754 //          substitution points must of the form %1!ws! and not %ws.
00755 //
00756 //  Return Values:
00757 //      S_OK
00758 //          The call succeeded.
00759 //
00760 //      Other HRESULTs
00761 //          The call failed.
00762 //
00763 //--
00764 //////////////////////////////////////////////////////////////////////////////
00765 HRESULT
00766 HrFormatStringIntoBSTR(
00767       LPCWSTR   pcwszFmtIn
00768     , BSTR *    pbstrInout
00769     , ...
00770     )
00771 {
00772     HRESULT hr = S_OK;
00773     va_list valist;
00774
00775     va_start( valist, pbstrInout );
00776
00777     hr = HrFormatStringWithVAListIntoBSTR( pcwszFmtIn, pbstrInout, valist );
00778
00779     va_end( valist );
00780
00781     return hr;
00782
00783 } //*** HrFormatStringIntoBSTR
00784
00785 //////////////////////////////////////////////////////////////////////////////
00786 //++
00787 //
00788 //  HrFormatStringWithVAListIntoBSTR
00789 //
00790 //  Description:
00791 //      Format a string (specified by pcwszFmtIn) and variable arguments into
00792 //      a BSTR using the FormatMessage() Win32 API.  If the BSTR is not NULL
00793 //      on entry, the BSTR will be reused.
00794 //
00795 //  Arguments:
00796 //      pcwszFmtIn
00797 //          Specifies the format string.
00798 //
00799 //      pbstrInout
00800 //          Pointer to the BSTR to receive the string. On a failure, the BSTR
00801 //          may be the same or NULL.
00802 //
00803 //      valistIn
00804 //          Arguments for substitution points in the status text message.
00805 //          The FormatMessage() API is used for formatting the string, so
00806 //          substitution points must of the form %1!ws! and not %ws.
00807 //
00808 //  Return Values:
00809 //      S_OK
00810 //          The call succeeded.
00811 //
00812 //      E_OUTOFMEMORY
00813 //          Out of memory.
00814 //
00815 //      E_POINTER
00816 //          pcwszFmtIn or pbstrInout is NULL.
00817 //
00818 //      Other HRESULTs
00819 //          The call failed.
00820 //
00821 //--
00822 //////////////////////////////////////////////////////////////////////////////
00823 HRESULT
00824 HrFormatStringWithVAListIntoBSTR(
00825       LPCWSTR   pcwszFmtIn
00826     , BSTR *    pbstrInout
00827     , va_list   valistIn
00828     )
00829 {
00830     HRESULT hr = S_OK;
00831     DWORD   cch;
00832     LPWSTR  pwsz = NULL;
00833
00834     if (    ( pbstrInout == NULL )
00835         ||  ( pcwszFmtIn == NULL )
00836        )
00837     {
00838         hr = E_POINTER;
00839         goto Cleanup;
00840     } // if:
00841
00842     //
00843     // Format the message with the arguments.
00844     //
00845
00846     cch = FormatMessage(
00847                       ( FORMAT_MESSAGE_ALLOCATE_BUFFER
00848                       | FORMAT_MESSAGE_FROM_STRING )
00849                     , pcwszFmtIn
00850                     , 0
00851                     , 0
00852                     , (LPWSTR) &pwsz
00853                     , 0
00854                     , &valistIn
00855                     );
00856     if ( cch == 0 )
00857     {
00858         hr = HRESULT_FROM_WIN32( GetLastError() );
00859         goto Cleanup;
00860     } // if:
00861
00862     //
00863     // If previously allocated free it before re-allocating it.
00864     //
00865
00866     if ( *pbstrInout != NULL )
00867     {
00868         SysFreeString( *pbstrInout );
00869         *pbstrInout = NULL;
00870     } // if:
00871
00872     //
00873     // Allocate a BSTR for the string.
00874     //
00875
00876     *pbstrInout = SysAllocStringLen( pwsz, cch );
00877     if ( *pbstrInout == NULL )
00878     {
00879         hr = E_OUTOFMEMORY;
00880         goto Cleanup;
00881     } // if:
00882
00883 Cleanup:
00884
00885     LocalFree( pwsz );
00886
00887     return hr;
00888
00889 } //*** HrFormatStringWithVAListIntoBSTR
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMultiValuedListBox Member List

This is the complete list of members for CMultiValuedListBox, including all inherited members.
CMultiValuedListBox(CMultiValuedAttributeEditor *pEditor) | CMultiValuedListBox | [inline]
CMultiValuedListBox(CMultiValuedAttributeEditor *pEditor) | CMultiValuedListBox | [inline]
m_pEditor | CMultiValuedListBox | [protected]
OnSelChange() | CMultiValuedListBox |
OnSelChange() | CMultiValuedListBox |
~CMultiValuedListBox() | CMultiValuedListBox | [inline]
~CMultiValuedListBox() | CMultiValuedListBox | [inline]
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/DataSourceNames.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2

DataSourceNames.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DataSourceNames.h
00003   Summary:   Constant Data Source Names and passwords
00004   Origin:    Implementation of case study in Queued Components specification
00005 ----------------------------------------------------------------------------
00006   Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00007
00008     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00009     ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00010     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00011     PARTICULAR PURPOSE
00012 ==========================================================================+*/
00013
00014 #ifndef __DATASOURCENAMES_H_
00015 #define __DATASOURCENAMES_H_
00016
00017 LPCWSTR const pszOrderDSN = L"DSN=QCSampleOrder";
00018 LPCWSTR const pszShipDSN  = L"DSN=QCSampleShip";
00019 LPCWSTR const pszUserId   = L"sa";
00020 LPCWSTR const pszPassword = L"";
00021
00022 #endif // __DATASOURCENAMES_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/GQos/QosEvent/QosEvent.h Source File

  • NetDS
  • GQos
  • QosEvent

QosEvent.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      qosevent.h
00010 //
00011 // Abstract:
00012 //      Definitions and prototypes specific to this application
00013 //
00014 // Author:
00015 //      Barry R. Butterklee
00016 //
00017
00018 #ifndef QOSEVENT_H
00019 #define QOSEVENT_H
00020
00021 #include <winsock2.h>
00022 #include <ws2tcpip.h>
00023 #include <qos.h>
00024 #include <qossp.h>
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027
00028
00029 #define MY_DEFPORT (5001)
00030
00031
00032
00033 // Application specific define - there is NO specific invalid send priority.
00034 // This value is simply used to indicate whether or not to even set priority.
00035 #define INVALID_SEND_PRIORITY 255
00036
00037
00038 // application specific define - there is no "default" QOS template in GQoS,
00039 // only for this particular application does "default" have meaning.
00040 #define QOS_DEFAULTNAME "default"
00041
00042 // Use an arbitrary multicast group if none is specified on the command line
00043 #define DEFAULT_MULTICASTGROUP        "234.5.6.7"
00044
00045 typedef struct _SP_OPTIONS
00046     {
00047     int  iProtocol;             // protocol to use
00048     BOOL bQos;                  // enable QOS
00049     BOOL bMulticast;            // enable multicasting
00050     } SP_OPTIONS;
00051
00052
00053 typedef enum
00054     {
00055     QOS_IOCTL_SET_DURING,       // do not use ioctl to set Qos
00056     QOS_IOCTL_SET_BEFORE,       // set qos with ioctl before connection/accept
00057     QOS_IOCTL_SET_AFTER,        // set qos with ioctl after connection/accept
00058     QOS_IOCTL_SET_QOS           // set qos in receiver during FD_QOS, note that
00059                                 //  qos must be set prior to wsaeventselect in
00060                                 //  order to ever receive fd_qos
00061     } QOS_IOCTL_SET;
00062
00063
00064 typedef struct _QOS_OPTIONS
00065     {
00066     BOOL    bReceiver;          // act as receiver if TRUE
00067     BOOL    bWaitToSend;        // sender must wait for RESV before sending
00068     BOOL    bConfirmResv;       // have receiver request RESV confirmation
00069     BOOL    bQueryBufferSize;   // have WSAioctl return size of buffer needed
00070                                 //      when using SIO_GET_QOS (behaviour not
00071                                 //      avail on Win98).
00072     BOOL    bMustSetQosInAccept;// Will be set for Win98 only.  Win98 currently
00073                                 //      needs valid qos structure to be set in
00074                                 //      wsaaccept condition func in lpSQos is valid
00075     BOOL    bDisableSignalling; // If TRUE do not emit RSVP signalling, just use
00076                                 //      traffic control
00077     BOOL    bAlternateQos;      // Alternate between enabling and disabling QOS on
00078                                 //      a socket every N sends
00079     UCHAR   SendPriority;       // create QOS_OBJECT_PRIORITY structure, and
00080                                 //  set valid priority 0-7
00081     BOOL    bSetDestaddr;       // TRUE if unconnected UDP and QOS is used (not multicast)
00082     BOOL    bProviderSpecific;  // TRUE if a provider-specific object must be set
00083     BOOL    bFineGrainErrorAvail;   // TRUE if Win2000beta3 availability of
00084                                     //   fine grain errors on SIO_SET_QOS
00085     BOOL    bQosabilityIoctls;   // TRUE if Win2000beta3 qosablity ioctls
00086     BOOL    bFixTemplate;       // TRUE if Win98 to divide ToeknRate and PeakBandwidth
00087                                 //   by 8 when using WSAGetQOSByName
00088     QOS_IOCTL_SET qosIoctlSet;  // when to set QOS
00089     CHAR    szTemplate[64];     // qos template
00090     } QOS_OPTIONS;
00091
00092
00093 typedef struct _OPTIONS
00094     {
00095     CHAR            szHostname[64];
00096     unsigned short  port;
00097     int             nRepeat;
00098     CHAR            fillchar;
00099     int             nBufSize;
00100     CHAR *          buf;
00101     DWORD           dwSleep;
00102     DWORD           dwTotalClients;
00103     QOS_OPTIONS     qosOptions;
00104     SP_OPTIONS      spOptions;
00105     } OPTIONS;
00106
00107
00108 extern FLOWSPEC default_notraffic;
00109 extern FLOWSPEC default_g711;
00110 extern SOCKADDR_IN g_destaddr;
00111
00112 extern BOOL FindServiceProvider(
00113     int iProtocol,
00114     BOOL bQos,
00115     BOOL bMulticast,
00116     WSAPROTOCOL_INFO *pProtocolInfo);
00117
00118 extern VOID Receiver(
00119     OPTIONS *pOptions,
00120     WSAPROTOCOL_INFO *pProtocolInfo);
00121
00122 extern VOID Sender(
00123     OPTIONS *pOptions,
00124     WSAPROTOCOL_INFO *pProtocolInfo);
00125
00126 extern BOOL SetQos(
00127     SOCKET sd,
00128     QOS_OPTIONS *pQosOptions,
00129     BOOL bSetQos,
00130     QOS *pQos,
00131     DWORD *cbQosLen);
00132
00133 extern BOOL GetQos(
00134     SOCKET sd,
00135     BOOL bQueryBufferSize,
00136     QOS **pQos);
00137
00138 extern void PrintQos(
00139     QOS *qos,
00140     CHAR *lpszIndent);
00141
00142 extern BOOL ChkQosSend(
00143     SOCKET sd);
00144
00145 #endif
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/TestVIEW.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

TestVIEW.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // testView.cpp : implementation of the CTestView class
00013 //
00014
00015
00016
00017 #include "stdafx.h"
00018 #include "MQApitst.h"
00019 #include "mainfrm.h"
00020
00021 #include "testDoc.h"
00022 #include "testView.h"
00023
00024 #ifdef _DEBUG
00025 #define new DEBUG_NEW
00026 #undef THIS_FILE
00027 static char THIS_FILE[] = __FILE__;
00028 #endif
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // CTestView
00032
00033 IMPLEMENT_DYNCREATE(CTestView, CEditView)
00034
00035 BEGIN_MESSAGE_MAP(CTestView, CEditView)
00036   //{{AFX_MSG_MAP(CTestView)
00037   ON_WM_CREATE()
00038   //}}AFX_MSG_MAP
00039 END_MESSAGE_MAP()
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 // CTestView construction/destruction
00043
00044 CTestView::CTestView()
00045 {
00046   // TODO: add construction code here
00047
00048 }
00049
00050 CTestView::~CTestView()
00051 {
00052 }
00053
00054 BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
00055 {
00056   // TODO: Modify the Window class or styles here by modifying
00057   //  the CREATESTRUCT cs
00058
00059   BOOL bPreCreated = CEditView::PreCreateWindow(cs);
00060   cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL); // Enable word-wrapping
00061
00062   return bPreCreated;
00063 }
00064
00065 /////////////////////////////////////////////////////////////////////////////
00066 // CTestView drawing
00067
00068 void CTestView::OnDraw(CDC* pDC)
00069 {
00070   CTestDoc* pDoc = GetDocument();
00071   ASSERT_VALID(pDoc);
00072
00073   // TODO: add draw code for native data here
00074 }
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // CTestView diagnostics
00078
00079 #ifdef _DEBUG
00080 void CTestView::AssertValid() const
00081 {
00082   CEditView::AssertValid();
00083 }
00084
00085 void CTestView::Dump(CDumpContext& dc) const
00086 {
00087   CEditView::Dump(dc);
00088 }
00089
00090 CTestDoc* CTestView::GetDocument() // non-debug version is inline
00091 {
00092   if(!m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc)))
00093   {
00094     AfxMessageBox(_T("Internal document kind error."));
00095     exit(1);
00096   }
00097   return (CTestDoc*)m_pDocument;
00098 }
00099 #endif //_DEBUG
00100
00101 /////////////////////////////////////////////////////////////////////////////
00102 // CTestView message handlers
00103
00104 int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
00105 {
00106   if (CEditView::OnCreate(lpCreateStruct) == -1)
00107     return -1;
00108
00109   // TODO: Add your specialized creation code here
00110
00111   pMainView = this;
00112   return 0;
00113 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/Module.Cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

Module.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        module.cpp
00007 //
00008 // Contents:    Cert Server Policy Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013 #pragma hdrstop
00014
00015 #include "celibw2k.h"
00016 #include "module.h"
00017 #include "policy.h"
00018
00019
00020 STDMETHODIMP
00021 CCertManagePolicyModuleSample::GetProperty(
00022             /* [in] */ const BSTR strConfig,
00023             /* [in] */ BSTR strStorageLocation,
00024             /* [in] */ BSTR strPropertyName,
00025             /* [in] */ LONG Flags,
00026             /* [retval][out] */ VARIANT __RPC_FAR *pvarProperty)
00027 {
00028     LPWSTR szStr = NULL;
00029     if (strPropertyName == NULL)
00030         return S_FALSE;
00031
00032     if (0 == wcscmp(strPropertyName, wszCMM_PROP_NAME))
00033         szStr = wsz_SAMPLE_NAME;
00034     else if (0 == wcscmp(strPropertyName, wszCMM_PROP_DESCRIPTION))
00035         szStr = wsz_SAMPLE_DESCRIPTION;
00036     else if (0 == wcscmp(strPropertyName, wszCMM_PROP_COPYRIGHT))
00037         szStr = wsz_SAMPLE_COPYRIGHT;
00038     else if (0 == wcscmp(strPropertyName, wszCMM_PROP_FILEVER))
00039         szStr = wsz_SAMPLE_FILEVER;
00040     else if (0 == wcscmp(strPropertyName, wszCMM_PROP_PRODUCTVER))
00041         szStr = wsz_SAMPLE_PRODUCTVER;
00042     else
00043         return S_FALSE;
00044
00045     pvarProperty->bstrVal = SysAllocString(szStr);
00046     if (NULL == pvarProperty->bstrVal)
00047         return E_OUTOFMEMORY;
00048
00049     pvarProperty->vt = VT_BSTR;
00050
00051     return S_OK;
00052 }
00053
00054 STDMETHODIMP
00055 CCertManagePolicyModuleSample::SetProperty(
00056             /* [in] */ const BSTR strConfig,
00057             /* [in] */ BSTR strStorageLocation,
00058             /* [in] */ BSTR strPropertyName,
00059             /* [in] */ LONG Flags,
00060             /* [in] */ VARIANT const __RPC_FAR *pvarProperty)
00061 {
00062      // no settable properties supported
00063      return S_FALSE;
00064 }
00065
00066 STDMETHODIMP
00067 CCertManagePolicyModuleSample::Configure(
00068             /* [in] */ const BSTR strConfig,
00069             /* [in] */ BSTR strStorageLocation,
00070             /* [in] */ LONG Flags)
00071 {
00072     MessageBox(NULL, L"No Configurable Options", NULL, MB_OK|MB_ICONINFORMATION);
00073
00074     return S_OK;
00075 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/sky.h Source File

  • SysMgmt
  • MMC
  • Proppage

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025 class CSkyBasedVehicle : public CDelegationBase {
00026 public:
00027     CSkyBasedVehicle() { }
00028
00029     virtual ~CSkyBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00034
00035 private:
00036     enum { IDM_NEW_SKY = 3 };
00037
00038     // {2974380F-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/WaitDlg.h Source File

  • WinBase
  • WtsApi
  • WtsApi

WaitDlg.h

Go to the documentation of this file.
00001 #if !defined(AFX_WAITDLG_H__5D915AC2_3390_11D1_8312_00C04FBEFCDA__INCLUDED_)
00002 #define AFX_WAITDLG_H__5D915AC2_3390_11D1_8312_00C04FBEFCDA__INCLUDED_
00003
00004 //  Copyright 1995-1999, Citrix Systems Inc.
00005 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00006
00007 #if _MSC_VER >= 1000
00008 #pragma once
00009 #endif // _MSC_VER >= 1000
00010 // WaitDlg.h : header file
00011 //
00012
00013 /////////////////////////////////////////////////////////////////////////////
00014 // CWaitDlg dialog
00015
00016 class CWaitDlg : public CDialog
00017 {
00018 // Construction
00019 public:
00020   CWaitDlg(CWnd* pParent = NULL);   // standard constructor
00021
00022 // Dialog Data
00023   //{{AFX_DATA(CWaitDlg)
00024   enum { IDD = IDD_DIALOG1 };
00025     // NOTE: the ClassWizard will add data members here
00026   //}}AFX_DATA
00027
00028
00029 // Overrides
00030   // ClassWizard generated virtual function overrides
00031   //{{AFX_VIRTUAL(CWaitDlg)
00032   protected:
00033   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00034   //}}AFX_VIRTUAL
00035
00036 // Implementation
00037 protected:
00038
00039   // Generated message map functions
00040   //{{AFX_MSG(CWaitDlg)
00041   //}}AFX_MSG
00042   DECLARE_MESSAGE_MAP()
00043 };
00044
00045 //{{AFX_INSERT_LOCATION}}
00046 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00047
00048 #endif // !defined(AFX_WAITDLG_H__5D915AC2_3390_11D1_8312_00C04FBEFCDA__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/common.h Source File

  • Dataaccess
  • oledb
  • sampprov

common.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module COMMON.H | common global functions
00008 //
00009 //
00010 #ifndef _COMMON_H_
00011 #define _COMMON_H_
00012
00013
00014 BOOL IsEqualDBID
00015   (
00016   const DBID * px,
00017   const DBID * py
00018   );
00019
00020
00021 #endif
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminFileFlags.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminFileFlags.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminFileFlags
00019
00020 public interface COMAdminFileFlags
00021 {
00022   public static final int COMAdminFileFlagLoadable = 1;
00023   public static final int COMAdminFileFlagCOM = 2;
00024   public static final int COMAdminFileFlagContainsPS = 4;
00025   public static final int COMAdminFileFlagContainsComp = 8;
00026   public static final int COMAdminFileFlagContainsTLB = 16;
00027   public static final int COMAdminFileFlagSelfReg = 32;
00028   public static final int COMAdminFileFlagSelfUnReg = 64;
00029   public static final int COMAdminFileFlagUnloadableDLL = 128;
00030   public static final int COMAdminFileFlagDoesNotExist = 256;
00031   public static final int COMAdminFileFlagAlreadyInstalled = 512;
00032   public static final int COMAdminFileFlagBadTLB = 1024;
00033   public static final int COMAdminFileFlagGetClassObjFailed = 2048;
00034   public static final int COMAdminFileFlagClassNotAvailable = 4096;
00035   public static final int COMAdminFileFlagRegistrar = 8192;
00036   public static final int COMAdminFileFlagNoRegistrar = 16384;
00037   public static final int COMAdminFileFlagDLLRegsvrFailed = 32768;
00038   public static final int COMAdminFileFlagRegTLBFailed = 65536;
00039   public static final int COMAdminFileFlagRegistrarFailed = 131072;
00040   public static final int COMAdminFileFlagError = 262144;
00041 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MidiPlyr/Debug.c Source File

  • Multimedia
  • Audio
  • MidiPlyr

Debug.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *
00003 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
00006 *  A PARTICULAR PURPOSE.
00007 *
00008 *  Copyright 1993 - 2000 Microsoft Corporation. All Rights Reserved.
00009 *
00010 ******************************************************************************
00011 *
00012 * Debug.C
00013 *
00014 * Debug output routines
00015 *
00016 *****************************************************************************/
00017
00018 #ifdef   DEBUG
00019 #include <windows.h>
00020 #include <mmsystem.h>
00021 #include <stdarg.h>
00022
00023 #include "global.h"
00024 #include "debug.h"
00025
00026 PRIVATE VOID FAR CDECL DbgVPrintF(LPSTR szFmt, LPSTR va);
00027
00028 /*
00029 **  Since we don't UNICODE our debugging messages, use the ASCII entry
00030 **  points regardless of how we are compiled.
00031 */
00032 #define wvsprintfA          wvsprintf
00033 #define GetProfileIntA      GetProfileInt
00034 #define OutputDebugStringA  OutputDebugStr
00035
00036 #define lstrcatA            lstrcat
00037 #define lstrlenA            lstrlen
00038
00039 BOOL                        __gfDbgEnabled  = TRUE;
00040 UINT                        __guDbgLevel    = 0;
00041
00042 WORD                        wDebugLevel     = 0;
00043
00044 /*****************************************************************************
00045 *
00046 * WinAssert
00047 *
00048 * Cause a debug out on an assert; breaking to the debugger if installed.
00049 *
00050 * lpstrExp                  - Assert expression string
00051 * lpstrFile                 - File of assert
00052 * dwLine                    - Line number of assert
00053 *
00054 * Handle WM_CREATE message to main application window.
00055 *
00056 * HWND hWnd                 - Window handle
00057 * CREATESTRUCT FAR* lpCreateStruct
00058 *                           - Pointer to creation parameters for the window.
00059 *
00060 *****************************************************************************/
00061 VOID WINAPI WinAssert(
00062     LPSTR                   lpstrExp,
00063     LPSTR                   lpstrFile,
00064     DWORD                   dwLine)
00065 {
00066     static char szWork[256];
00067     static char BCODE szFormat[] =
00068         "!Assert: %s#%lu [%s]";
00069
00070     dprintf(0, (LPSTR)szFormat, (LPSTR)lpstrFile, dwLine, (LPSTR)lpstrExp);
00071 }
00072
00073 /*****************************************************************************
00074 *
00075 * DbgVPrintF
00076 *
00077 * Format and print a debug output string
00078 *
00079 * szFmt                     - Format string
00080 * va                        - printf style argument list
00081 *
00082 * The following characters have special meanings when they are
00083 * the first in the string:
00084 *
00085 *   !   Causes a break into the debugger after the output has been printed
00086 *   `   Causes no module prefix to be printed
00087 *   ~   Causes no CR/LF pair to follow the string
00088 *
00089 *****************************************************************************/
00090 VOID FAR CDECL DbgVPrintF(
00091     LPSTR                   szFmt,
00092     LPSTR                   va)
00093 {
00094     char                    ach[DEBUG_MAX_LINE_LEN];
00095     BOOL                    fDebugBreak = FALSE;
00096     BOOL                    fPrefix     = TRUE;
00097     BOOL                    fCRLF       = TRUE;
00098
00099     ach[0] = '\0';
00100
00101     for (;;)
00102     {
00103         switch(*szFmt)
00104         {
00105             case '!':
00106                 fDebugBreak = TRUE;
00107                 szFmt++;
00108                 continue;
00109
00110             case '`':
00111                 fPrefix = FALSE;
00112                 szFmt++;
00113                 continue;
00114
00115             case '~':
00116                 fCRLF = FALSE;
00117                 szFmt++;
00118                 continue;
00119         }
00120
00121         break;
00122     }
00123
00124     if (fDebugBreak)
00125     {
00126         ach[0] = '\007';
00127         ach[1] = '\0';
00128     }
00129
00130     if (fPrefix)
00131         lstrcatA(ach, DEBUG_MODULE_NAME ": ");
00132
00133     wvsprintfA(ach + lstrlenA(ach), szFmt, (LPSTR)va);
00134
00135     if (fCRLF)
00136         lstrcatA(ach, "\r\n");
00137
00138     OutputDebugStringA(ach);
00139
00140     if (fDebugBreak)
00141         DebugBreak();
00142 }
00143
00144 /*****************************************************************************
00145 *
00146 * dprintf
00147 *
00148 * User-level function to print a debug string
00149 *
00150 * uDbgLevel                 - Debug level of this message
00151 * szFmt                     - Format string for this message
00152 * ...                       - printf style arguments
00153 *
00154 * The message will be printed only if debugging is enabled and the messages's
00155 * debug level is less than or equal to the current debug level.
00156 *
00157 * This function is called by the DPF() macro in Debug.H.
00158 *
00159 *****************************************************************************/
00160 void FAR CDECL dprintf(
00161     UINT                    uDbgLevel,
00162     LPSTR                   szFmt,
00163     ...)
00164 {
00165     va_list                 va;
00166
00167     if (!__gfDbgEnabled || (__guDbgLevel < uDbgLevel))
00168         return;
00169
00170     va_start(va, szFmt);
00171     DbgVPrintF(szFmt, (LPSTR)va);
00172     va_end(va);
00173 }
00174
00175
00176 /*****************************************************************************
00177 *
00178 * DbgEnable
00179 *
00180 * Enable or disable debug output
00181 *
00182 * fEnable                   - Enable or disable output
00183 *
00184 * Returns the old state.
00185 *
00186 *****************************************************************************/
00187 BOOL WINAPI DbgEnable(
00188     BOOL                    fEnable)
00189 {
00190     BOOL                    fOldState;
00191
00192     fOldState      = __gfDbgEnabled;
00193     __gfDbgEnabled = fEnable;
00194
00195     return (fOldState);
00196 }
00197
00198 /*****************************************************************************
00199 *
00200 * DbgSetLevel
00201 *
00202 * Set the current level for debug output
00203 *
00204 * uLevel                    - New level for debug output
00205 *
00206 * Returns the old level.
00207 *
00208 *****************************************************************************/
00209 UINT WINAPI DbgSetLevel(
00210     UINT                    uLevel)
00211 {
00212     UINT                    uOldLevel;
00213
00214     uOldLevel    = __guDbgLevel;
00215     __guDbgLevel = wDebugLevel = uLevel;
00216
00217     return (uOldLevel);
00218 }
00219
00220
00221 /*****************************************************************************
00222 *
00223 * DbgInitialize
00224 *
00225 * Get debug output settings from WIN.INI for this module
00226 *
00227 * fEnable                   - Enable or disable debug output
00228 *
00229 * Returns the current debug level
00230 *
00231 * The debug level will be read from the [debug] section of WIN.INI,
00232 * from an entry with this module's name as #define'd in Debug.H.
00233 *
00234 * WIN.INI:
00235 *  [Debug]
00236 *  Module=3
00237 *
00238 *****************************************************************************/
00239 UINT WINAPI DbgInitialize(BOOL fEnable)
00240 {
00241     DbgSetLevel(GetProfileIntA(DEBUG_SECTION, DEBUG_MODULE_NAME, 0));
00242     DbgEnable(fEnable);
00243
00244     return (__guDbgLevel);
00245 }
00246
00247
00248 #endif
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/comp.h Source File

  • SysMgmt
  • MMC
  • Toolbar

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent,
00025 IExtendControlbar
00026
00027 {
00028 private:
00029     ULONG       m_cref;
00030
00031     IConsole*   m_ipConsole;
00032     IDisplayHelp* m_ipDisplayHelp;
00033     IControlbar*    m_ipControlBar;
00034     IToolbar*       m_ipToolbar;
00035
00036     class CComponentData *m_pComponentData;
00037
00038     public:
00039         CComponent(CComponentData *parent);
00040         ~CComponent();
00041
00042         ///////////////////////////////
00043         // Interface IUnknown
00044         ///////////////////////////////
00045         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046         STDMETHODIMP_(ULONG) AddRef();
00047         STDMETHODIMP_(ULONG) Release();
00048
00049         ///////////////////////////////
00050         // Interface IComponent
00051         ///////////////////////////////
00052         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053             /* [in] */ LPCONSOLE lpConsole);
00054
00055             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00056             /* [in] */ LPDATAOBJECT lpDataObject,
00057             /* [in] */ MMC_NOTIFY_TYPE event,
00058             /* [in] */ LPARAM arg,
00059             /* [in] */ LPARAM param);
00060
00061             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00062             /* [in] */ MMC_COOKIE cookie);
00063
00064             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00065             /* [in] */ MMC_COOKIE cookie,
00066             /* [in] */ DATA_OBJECT_TYPES type,
00067             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00068
00069             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00070             /* [in] */ MMC_COOKIE cookie,
00071             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00072             /* [out] */ long __RPC_FAR *pViewOptions);
00073
00074             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00075             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00076
00077             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00078             /* [in] */ LPDATAOBJECT lpDataObjectA,
00079             /* [in] */ LPDATAOBJECT lpDataObjectB);
00080
00081             ///////////////////////////////
00082             // Interface IExtendControlBar
00083             ///////////////////////////////
00084             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetControlbar(
00085             /* [in] */ LPCONTROLBAR pControlbar);
00086
00087             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE ControlbarNotify(
00088             /* [in] */ MMC_NOTIFY_TYPE event,
00089             /* [in] */ LPARAM arg,
00090             /* [in] */ LPARAM param);
00091
00092     public:
00093         IToolbar *getToolbar() { return m_ipToolbar; }
00094 };
00095
00096 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCrmMonComp Member List

This is the complete list of members for CCrmMonComp, including all inherited members.
AbortTransaction() | CCrmMonComp |
CCrmMonComp() | CCrmMonComp | [inline]
CreateCompensator(void) | CCrmMonComp | [private]
FinalConstruct() | CCrmMonComp |
FinalRelease() | CCrmMonComp |
get_ActivityId(VARIANT *pVal) | CCrmMonComp |
get_ColumnHeaders(VARIANT *pVal) | CCrmMonComp |
get_Description(VARIANT *pVal) | CCrmMonComp |
get_FindClerks(long *plNumberOfClerks) | CCrmMonComp |
get_FormattedRecord(VARIANT *pVal) | CCrmMonComp |
get_NumberOfLogRecords(long *pVal) | CCrmMonComp |
get_ProgId(VARIANT *pVal) | CCrmMonComp |
get_TransactionState(VARIANT *pVal) | CCrmMonComp |
m_lClerkNumber | CCrmMonComp | [private]
m_lRecordNumber | CCrmMonComp | [private]
m_pICrmFormatLogRecords | CCrmMonComp | [private]
m_pICrmMonitor | CCrmMonComp | [private]
m_pICrmMonitorClerks | CCrmMonComp | [private]
m_pUnkMarshaler | CCrmMonComp |
m_vActivityId | CCrmMonComp | [private]
m_vecClerks | CCrmMonComp | [private]
m_vTxUOWRequired | CCrmMonComp | [private]
put_TransactionUOW(VARIANT newVal) | CCrmMonComp |
SetClerk(long lClerkNumber) | CCrmMonComp |
SetRecord(long lRecordNumber) | CCrmMonComp |
Generated on Wed Nov 13 2024 16:55:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • Complete

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • Toolbar

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/adddevicedlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

adddevicedlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddDeviceDlg.cpp:  Implementation of the CAddDeviceDlg class.
00015 //
00016
00017
00018
00019 #include "AddDeviceDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddDeviceDlg::CAddDeviceDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddDeviceDlg::~CAddDeviceDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddDeviceDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00055   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00056
00057   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00060   lResult = SendMessage( hBackupCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00061   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00062
00063   lResult = SetWindowText( hDevNameCtrl, _T("") );
00064   SetFocus( hDevNameCtrl );
00065
00066   return 0;
00067 }
00068
00069 //---------------------------------------------------------------------------
00070 LRESULT CAddDeviceDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00071 {
00072   LRESULT          lResult = 0;
00073   NODE_PROPERTIES  NodeProps;
00074
00075   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00076
00077   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00078   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00079   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00080   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00081   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00082   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00083
00084   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00086
00087   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00089
00090   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00092
00093   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00094     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00095
00096   if( BST_CHECKED == SendMessage( hBackupCtrl, BM_GETCHECK, 0, 0 ) )
00097     NodeProps.dwAttributes |= ATTRIBUTE_BACKUP_DEVICE;
00098
00099   // Convert to wide characters here for all platforms.  This is the node name
00100   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00101   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00102   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00103   // Probably a good idea to check for NULL name strings here
00104
00105   // This message passes the user supplied info to the Static Node
00106   SendMessage( m_hParentWnd, WM_ADD_DEVICENODE, (WPARAM)&NodeProps, 0 );
00107
00108   // Now tell the static node we are deleting ourselves so the
00109   // context menu option can be enabled
00110   SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00111
00112   // Call the base class to shut down the dialog
00113   CBaseDialog::OnOK( hDlg, wParam, lParam );
00114   return 0;
00115 }
00116
00117 /////////////////////////////////////////////////////////////////////////////
00118 //  Virtual function implementations
00119
00120 //---------------------------------------------------------------------------
00121 BOOL CAddDeviceDlg::ProcessMessage
00122 (
00123   HWND     hDlg,           //[in] Handle to dialog box
00124   UINT     uMsg,           //[in] Message
00125   WPARAM   wParam,         //[in] First message parameter
00126   LPARAM   lParam          //[in] Second message parameter
00127 )
00128 {
00129   LRESULT lResult = 0;
00130
00131   switch( uMsg )
00132   {
00133     case WM_INITDIALOG:
00134       lResult = OnInitDialog( hDlg, wParam, lParam );
00135       break;
00136
00137     case WM_DESTROY:
00138       lResult = OnDestroy( hDlg, wParam, lParam );
00139       break;
00140
00141     case WM_NCDESTROY:
00142       lResult = OnNcDestroy( hDlg, wParam, lParam );
00143       break;
00144
00145     case WM_CLOSE:
00146       // Not overriding WM_CLOSE and IDCANCEL so we must send
00147       // WM_DEVICENODE_CLOSED before calling the base class or else
00148       // the context menu will stay grayed
00149       SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00150       lResult = OnClose( hDlg, wParam, lParam );
00151       break;
00152
00153     case WM_COMMAND:
00154       switch( wParam )
00155       {
00156         case IDOK:
00157           lResult = OnOK( hDlg, wParam, lParam );
00158           break;
00159
00160         case IDCANCEL:
00161           SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00162           lResult = OnCancel( hDlg, wParam, lParam );
00163           break;
00164
00165         default:
00166           break;
00167       }
00168     default:
00169       break;
00170   }
00171   return (BOOL)lResult;
00172 }
00173
00174
00175
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

TS_VERSION_INFO Member List

This is the complete list of members for TS_VERSION_INFO, including all inherited members.
osvi | TS_VERSION_INFO
si | TS_VERSION_INFO
szClientName | TS_VERSION_INFO
szComputerName | TS_VERSION_INFO
szUserName | TS_VERSION_INFO
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStartupListener/StdAfx.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStartupListener

StdAfx.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      StdAfx.h
00005 //
00006 //  Description:
00007 //      Include file for standard system include files,
00008 //      or project specific include files that are used frequently,
00009 //      but are changed infrequently.
00010 //
00011 //////////////////////////////////////////////////////////////////////////////
00012
00013 #pragma once
00014
00015 #define STRICT
00016 #ifndef _WIN32_WINNT
00017 #define _WIN32_WINNT 0x0502
00018 #endif
00019 #define _ATL_APARTMENT_THREADED
00020
00021 #include <atlbase.h>
00022
00023 // You may derive a class from CComModule and use it if you want to override
00024 // something, but do not change the name of _Module.
00025 extern CComModule _Module;
00026
00027 #include <atlcom.h>
00028
00029 // Categories and ClusCfg GUIDS.
00030 #include <ClusCfgGuids.h>
00031
00032 // Interface definitions for IClusCfgStartupListener.
00033 #include <ClusCfgServer.h>
00034
00035 // Safe string functions
00036 #include <strsafe.h>
00037
00038 //{{AFX_INSERT_LOCATION}}
00039 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/MoveRecordOptionsEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

MoveRecordOptionsEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: MoveRecordOptionsEnum
00019
00020 public class MoveRecordOptionsEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adMoveOverWrite = 1;
00023   public static final short adMoveDontUpdateLinks = 2;
00024   public static final short adMoveAllowEmulation = 4;
00025 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/tsfedit.cpp Source File

  • WinUI
  • tsfapp

tsfedit.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          TSFEdit.cpp
00013
00014    Description:   CTSFEditWnd Class Implementation
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "TSFEdit.h"
00023 #include "Globals.h"
00024 #include <ctffunc.h>
00025
00026 /*
00027 None of the GUIDs in TSATTRS.H are defined in a LIB, so you have to include
00028 INITGUID.H just before the first time you include TSATTRS.H
00029 */
00030 #include <initguid.h>
00031 #include <tsattrs.h>
00032
00033 /**************************************************************************
00034    local function prototypes
00035 **************************************************************************/
00036
00037 /**************************************************************************
00038    global variables and definitions
00039 **************************************************************************/
00040
00041 TCHAR   g_szTSFEditClassName[] = TEXT("TSFEditWndClass");
00042
00043 #define THIS_POINTER_OFFSET   GWLP_USERDATA
00044
00045 //#define USE_ASSOC_FOCUS
00046
00047 /**************************************************************************
00048
00049    CTSFEditWnd::CTSFEditWnd()
00050
00051 **************************************************************************/
00052
00053 CTSFEditWnd::CTSFEditWnd(HINSTANCE hInstance, HWND hwndParent)
00054 {
00055     m_hWnd = NULL;
00056     m_hwndEdit = NULL;
00057     m_hwndStatus = NULL;
00058     m_hInst = hInstance;
00059     m_ObjRefCount = 1;
00060     m_hwndParent = hwndParent;
00061     m_pThreadMgr = NULL;
00062     m_pDocMgr = NULL;
00063     m_pPrevDocMgr = NULL;
00064     m_pContext = NULL;
00065     m_fLocked = FALSE;
00066     m_dwLockType = 0;
00067     m_fPendingLockUpgrade = FALSE;
00068     m_acpStart = 0;
00069     m_acpEnd = 0;
00070     m_fInterimChar = FALSE;
00071     m_ActiveSelEnd = TS_AE_START;
00072     m_pServices = NULL;
00073     m_cCompositions = 0;
00074     m_pCategoryMgr = NULL;
00075     m_pDisplayAttrMgr = NULL;
00076     m_fLayoutChanged = FALSE;
00077     m_fNotify = TRUE;
00078     m_cchOldLength = 0;
00079
00080     ZeroMemory(&m_AdviseSink, sizeof(m_AdviseSink));
00081     ZeroMemory(&m_rgCompositions, sizeof(m_rgCompositions));
00082 }
00083
00084 /**************************************************************************
00085
00086    CTSFEditWnd::~CTSFEditWnd()
00087
00088 **************************************************************************/
00089
00090 CTSFEditWnd::~CTSFEditWnd()
00091 {
00092     /*
00093     Make sure the advise sink is cleaned up. This should have been done
00094     before, but this is just in case.
00095     */
00096     _ClearAdviseSink(&m_AdviseSink);
00097
00098     if(m_pServices)
00099     {
00100         m_pServices->Release();
00101         m_pServices = NULL;
00102     }
00103
00104     _Uninitialize();
00105 }
00106
00107 /**************************************************************************
00108
00109    CTSFEditWnd::_Initialize()
00110
00111 **************************************************************************/
00112
00113 BOOL CTSFEditWnd::_Initialize(ITfThreadMgr *ptm, TfClientId tfcId)
00114 {
00115     HRESULT hr;
00116
00117     InitCommonControls();
00118
00119     m_tfClientID = tfcId;
00120     hr = ptm->QueryInterface(IID_ITfThreadMgr, (LPVOID*)&m_pThreadMgr);
00121     if(FAILED(hr))
00122     {
00123         return FALSE;
00124     }
00125
00126     hr = CoCreateInstance(  CLSID_TF_CategoryMgr,
00127                             NULL,
00128                             CLSCTX_INPROC_SERVER,
00129                             IID_ITfCategoryMgr,
00130                             (LPVOID*)&m_pCategoryMgr);
00131     if(FAILED(hr))
00132     {
00133         return FALSE;
00134     }
00135
00136
00137     //create the display attribute manager
00138     hr = CoCreateInstance(  CLSID_TF_DisplayAttributeMgr,
00139                             NULL,
00140                             CLSCTX_INPROC_SERVER,
00141                             IID_ITfDisplayAttributeMgr,
00142                             (LPVOID*)&m_pDisplayAttrMgr);
00143     if(FAILED(hr))
00144     {
00145         return FALSE;
00146     }
00147
00148
00149     //create the document manager
00150     hr = m_pThreadMgr->CreateDocumentMgr(&m_pDocMgr);
00151     if(FAILED(hr))
00152     {
00153         return FALSE;
00154     }
00155
00156     //create the context
00157     hr = m_pDocMgr->CreateContext(  tfcId,
00158                                     0,
00159                                     (ITextStoreACP*)this,
00160                                     &m_pContext,
00161                                     &m_EditCookie);
00162     if(FAILED(hr))
00163     {
00164         return FALSE;
00165     }
00166
00167     //push the context onto the document stack
00168     hr = m_pDocMgr->Push(m_pContext);
00169     if(FAILED(hr))
00170     {
00171         return FALSE;
00172     }
00173
00174     WNDCLASS  wc;
00175
00176     //If the class is not already registered, register it.
00177     if(!GetClassInfo(m_hInst, g_szTSFEditClassName, &wc))
00178     {
00179         ZeroMemory(&wc, sizeof(wc));
00180
00181         wc.style          = CS_HREDRAW | CS_VREDRAW;
00182         wc.lpfnWndProc    = CTSFEditWnd::_WndProc;
00183         wc.cbClsExtra     = 0;
00184         wc.cbWndExtra     = sizeof(CTSFEditWnd*);
00185         wc.hInstance      = m_hInst;
00186         wc.hIcon          = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_MAIN_ICON));
00187         wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
00188         wc.hbrBackground  = (HBRUSH)(COLOR_WINDOW + 1);
00189         wc.lpszMenuName   = MAKEINTRESOURCE(IDR_MAIN_MENU);
00190         wc.lpszClassName  = g_szTSFEditClassName;
00191
00192         if(0 == RegisterClass(&wc))
00193         {
00194             return FALSE;
00195         }
00196     }
00197     //create the main window
00198     m_hWnd = CreateWindowEx(    0,
00199                                 g_szTSFEditClassName,
00200                                 NULL,
00201                                 WS_OVERLAPPED |
00202                                     WS_CHILD |
00203                                     WS_VISIBLE |
00204                                     WS_TABSTOP,
00205                                 CW_USEDEFAULT,
00206                                 CW_USEDEFAULT,
00207                                 CW_USEDEFAULT,
00208                                 CW_USEDEFAULT,
00209                                 m_hwndParent,
00210                                 NULL,
00211                                 m_hInst,
00212                                 (LPVOID)this);
00213
00214     if(NULL != m_hWnd)
00215     {
00216         m_hwndEdit = CreateWindowEx(    WS_EX_CLIENTEDGE,
00217                                         TEXT("edit"),
00218                                         NULL,
00219                                         WS_CLIPSIBLINGS |
00220                                             WS_CHILD |
00221                                             WS_VISIBLE |
00222                                             WS_BORDER |
00223                                             WS_VSCROLL |
00224                                             ES_AUTOVSCROLL |
00225                                             ES_MULTILINE,
00226                                         0, 0, 0, 0,
00227                                         m_hWnd,
00228                                         (HMENU)IDC_EDIT,
00229                                         m_hInst,
00230                                         NULL);
00231         if(NULL == m_hwndEdit)
00232         {
00233             return FALSE;
00234         }
00235
00236         //create the status bar
00237         m_hwndStatus = CreateStatusWindow(  WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
00238                                             NULL,
00239                                             m_hWnd,
00240                                             IDC_STATUSBAR);
00241
00242         if(m_hwndStatus)
00243         {
00244             _UpdateStatusBar();
00245         }
00246
00247 #ifdef USE_ASSOC_FOCUS
00248         /*
00249         Associate the focus with this window. The TSF Manager watches for
00250         focus changes throughout the system. When a window handle that has
00251         been associated gets the focus, it then knows the window receiving
00252         the focus is TSF enabled.
00253         */
00254         hr = m_pThreadMgr->AssociateFocus(m_hwndEdit, m_pDocMgr, &m_pPrevDocMgr);
00255 #endif
00256
00257         //initialize the supported attributes
00258         TfGuidAtom guidatom;
00259
00260         //mode bias
00261         m_rgAttributes[ATTR_INDEX_MODEBIAS].dwFlags = 0;
00262         m_rgAttributes[ATTR_INDEX_MODEBIAS].attrid = &GUID_PROP_MODEBIAS;
00263         VariantInit(&(m_rgAttributes[ATTR_INDEX_MODEBIAS].varValue));
00264         hr = m_pCategoryMgr->RegisterGUID(GUID_MODEBIAS_NONE, &guidatom);
00265         if(FAILED(hr))
00266         {
00267             guidatom = TF_INVALID_GUIDATOM;
00268         }
00269         m_rgAttributes[ATTR_INDEX_MODEBIAS].varDefaultValue.vt = VT_I4;
00270         m_rgAttributes[ATTR_INDEX_MODEBIAS].varDefaultValue.lVal = guidatom;
00271
00272         //text orientation - this is a VT_I4 that is always zero in this app
00273         m_rgAttributes[ATTR_INDEX_TEXT_ORIENTATION].dwFlags = 0;
00274         m_rgAttributes[ATTR_INDEX_TEXT_ORIENTATION].attrid = &TSATTRID_Text_Orientation;
00275         VariantInit(&m_rgAttributes[ATTR_INDEX_TEXT_ORIENTATION].varValue);
00276         m_rgAttributes[ATTR_INDEX_TEXT_ORIENTATION].varDefaultValue.vt = VT_I4;
00277         m_rgAttributes[ATTR_INDEX_TEXT_ORIENTATION].varDefaultValue.lVal = 0;
00278
00279         //vertical writing - this is a VT_BOOL that is always FALSE in this app
00280         m_rgAttributes[ATTR_INDEX_TEXT_VERTICALWRITING].dwFlags = 0;
00281         m_rgAttributes[ATTR_INDEX_TEXT_VERTICALWRITING].attrid = &TSATTRID_Text_VerticalWriting;
00282         VariantInit(&m_rgAttributes[ATTR_INDEX_TEXT_VERTICALWRITING].varValue);
00283         m_rgAttributes[ATTR_INDEX_TEXT_VERTICALWRITING].varDefaultValue.vt = VT_BOOL;
00284         m_rgAttributes[ATTR_INDEX_TEXT_VERTICALWRITING].varDefaultValue.lVal = FALSE;
00285
00286         _InitFunctionProvider();
00287
00288         UpdateWindow(m_hWnd);
00289
00290         return TRUE;
00291     }
00292
00293     return FALSE;
00294 }
00295
00296 /**************************************************************************
00297
00298    CTSFEditWnd::_Uninitialize()
00299
00300 **************************************************************************/
00301
00302 void CTSFEditWnd::_Uninitialize()
00303 {
00304     if(m_pThreadMgr)
00305     {
00306         _UninitFunctionProvider();
00307
00308 #ifdef USE_ASSOC_FOCUS
00309         ITfDocumentMgr *pTempDocMgr = NULL;
00310
00311         /*
00312         Its okay if m_pPrevDocMgr is NULL as this will just disassociate the
00313         focus from the window.
00314         */
00315         m_pThreadMgr->AssociateFocus(m_hwndEdit, m_pPrevDocMgr, &pTempDocMgr);
00316
00317         if(pTempDocMgr)
00318         {
00319             pTempDocMgr->Release();
00320         }
00321
00322         if(m_pPrevDocMgr)
00323         {
00324             m_pPrevDocMgr->Release();
00325             m_pPrevDocMgr = NULL;
00326         }
00327 #endif
00328
00329         int i;
00330
00331         for (i = 0; i < NUM_SUPPORTED_ATTRS; i++)
00332         {
00333             VariantClear(&m_rgAttributes[i].varValue);
00334             VariantClear(&m_rgAttributes[i].varDefaultValue);
00335             m_rgAttributes[i].dwFlags = ATTR_FLAG_NONE;
00336         }
00337
00338         if(m_pDocMgr)
00339         {
00340             //pop all of the contexts off of the stack
00341             m_pDocMgr->Pop(TF_POPF_ALL);
00342
00343             m_pDocMgr->Release();
00344             m_pDocMgr = NULL;
00345         }
00346
00347         if(m_pDisplayAttrMgr)
00348         {
00349             m_pDisplayAttrMgr->Release();
00350             m_pDisplayAttrMgr = NULL;
00351         }
00352
00353         if(m_pContext)
00354         {
00355             m_pContext->Release();
00356             m_pContext = NULL;
00357         }
00358
00359         if(m_pCategoryMgr)
00360         {
00361             m_pCategoryMgr->Release();
00362             m_pCategoryMgr = NULL;
00363         }
00364
00365         m_pThreadMgr->Release();
00366         m_pThreadMgr = NULL;
00367     }
00368 }
00369
00370 /**************************************************************************
00371
00372    CTSFEditWnd::_GetWindow()
00373
00374 **************************************************************************/
00375
00376 HWND CTSFEditWnd::_GetWindow()
00377 {
00378     return m_hWnd;
00379 }
00380
00381 /**************************************************************************
00382
00383    CTSFEditWnd::_OnGetPreservedKey()
00384
00385 **************************************************************************/
00386
00387 HRESULT CTSFEditWnd::_OnGetPreservedKey()
00388 {
00389     HRESULT hr;
00390     ITfKeystrokeMgr *pKeyMgr;
00391
00392     hr = m_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (LPVOID*)&pKeyMgr);
00393     if(SUCCEEDED(hr))
00394     {
00395         GUID            guid;
00396         TF_PRESERVEDKEY tfPreKey;
00397
00398         tfPreKey.uVKey = 'F';
00399         tfPreKey.uModifiers = TF_MOD_CONTROL;
00400
00401         hr = pKeyMgr->GetPreservedKey(m_pContext, &tfPreKey, &guid);
00402
00403         if(SUCCEEDED(hr) && !IsEqualGUID(guid, GUID_NULL))
00404         {
00405             BOOL fPreserved;
00406
00407             hr = pKeyMgr->IsPreservedKey(guid, &tfPreKey, &fPreserved);
00408
00409
00410             BOOL    fEaten;
00411
00412             guid.Data1 = 12;
00413             hr = pKeyMgr->SimulatePreservedKey(m_pContext, guid, &fEaten);
00414         }
00415
00416         pKeyMgr->Release();
00417     }
00418
00419     return S_OK;
00420 }
00421
00422 /**************************************************************************
00423
00424    CTSFEditWnd::_WndProc()
00425
00426 **************************************************************************/
00427
00428 LRESULT CALLBACK CTSFEditWnd::_WndProc( HWND hWnd,
00429                                         UINT uMessage,
00430                                         WPARAM wParam,
00431                                         LPARAM lParam)
00432 {
00433     CTSFEditWnd *pThis = (CTSFEditWnd*)GetWindowLongPtr(hWnd, THIS_POINTER_OFFSET);
00434
00435     if((NULL == pThis) && (uMessage != WM_NCCREATE))
00436     {
00437         return DefWindowProc(hWnd, uMessage, wParam, lParam);
00438     }
00439
00440     switch (uMessage)
00441     {
00442     case WM_NCCREATE:
00443         {
00444             LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00445             pThis = (CTSFEditWnd*)(lpcs->lpCreateParams);
00446             SetWindowLongPtr(hWnd, THIS_POINTER_OFFSET, (LONG_PTR)pThis);
00447
00448             //set the window handle
00449             pThis->m_hWnd = hWnd;
00450
00451             /*
00452             AddRef() the object. Release() will be called in WM_NCDESTROY.
00453             Many owners will call Release during their WM_DESTROY, but the
00454             child window isn't destroyed until after the parent, so the object
00455             gets deleted while the window still exists. Calling Release()
00456             ourselves in WM_NCDESTROY ensures the object exists for the entire
00457             life of the window.
00458             */
00459             pThis->AddRef();
00460         }
00461         break;
00462
00463     case WM_CREATE:
00464         return pThis->_OnCreate();
00465
00466     case WM_SIZE:
00467         return pThis->_OnSize(wParam, lParam);
00468
00469     case WM_DESTROY:
00470         return pThis->_OnDestroy();
00471
00472     case WM_SETFOCUS:
00473         return pThis->_OnSetFocus();
00474
00475     case WM_KILLFOCUS:
00476         return pThis->_OnKillFocus();
00477
00478     case WM_COMMAND:
00479         return pThis->_OnCommand(   GET_WM_COMMAND_ID(wParam, lParam),
00480                                     GET_WM_COMMAND_CMD(wParam, lParam),
00481                                     GET_WM_COMMAND_HWND(wParam, lParam));
00482
00483     case WM_NCDESTROY:
00484         pThis->Release();
00485
00486         pThis->m_hWnd = NULL;
00487         break;
00488
00489     }
00490
00491     return DefWindowProc(hWnd, uMessage, wParam, lParam);
00492 }
00493
00494 /**************************************************************************
00495
00496    CTSFEditWnd::_OnCreate()
00497
00498 **************************************************************************/
00499
00500 LRESULT CTSFEditWnd::_OnCreate(VOID)
00501 {
00502     return 0;
00503 }
00504
00505 /**************************************************************************
00506
00507    CTSFEditWnd::_OnDestroy()
00508
00509 **************************************************************************/
00510
00511 LRESULT CTSFEditWnd::_OnDestroy(VOID)
00512 {
00513     _Uninitialize();
00514
00515     PostQuitMessage(0);
00516
00517     return 0;
00518 }
00519
00520 /**************************************************************************
00521
00522    CTSFEditWnd::_OnCommand()
00523
00524 **************************************************************************/
00525
00526 LRESULT CTSFEditWnd::_OnCommand(WORD wID, WORD wCmd, HWND hWnd)
00527 {
00528     switch(wID)
00529     {
00530     case IDC_EDIT:
00531         switch(wCmd)
00532         {
00533         case EN_SETFOCUS:
00534             _OnEditSetFocus();
00535             break;
00536
00537         case EN_KILLFOCUS:
00538             _OnEditKillFocus();
00539             break;
00540
00541         case EN_CHANGE:
00542             _OnEditChange();
00543             break;
00544
00545         }
00546         break;
00547     }
00548
00549     return 0;
00550 }
00551
00552 /**************************************************************************
00553
00554    CTSFEditWnd::_OnSetFocus()
00555
00556 **************************************************************************/
00557
00558 LRESULT CTSFEditWnd::_OnSetFocus(VOID)
00559 {
00560     OutputDebugString(TEXT("CTSFEditWnd::_OnSetFocus\n"));
00561
00562     SetFocus(m_hwndEdit);
00563
00564     return 0;
00565 }
00566
00567 /**************************************************************************
00568
00569    CTSFEditWnd::_OnEditSetFocus()
00570
00571 **************************************************************************/
00572
00573 LRESULT CTSFEditWnd::_OnEditSetFocus(VOID)
00574 {
00575     OutputDebugString(TEXT("CTSFEditWnd::_OnEditSetFocus\n"));
00576
00577 #ifndef USE_ASSOC_FOCUS
00578     m_pThreadMgr->SetFocus(m_pDocMgr);
00579 #endif
00580
00581     return 0;
00582 }
00583
00584 /**************************************************************************
00585
00586    CTSFEditWnd::_OnEditChange()
00587
00588 **************************************************************************/
00589
00590 LRESULT CTSFEditWnd::_OnEditChange(void)
00591 {
00592     if(m_fNotify && m_AdviseSink.pTextStoreACPSink && (m_AdviseSink.dwMask & TS_AS_TEXT_CHANGE))
00593     {
00594         DWORD           dwFlags;
00595         TS_TEXTCHANGE   tc;
00596         ULONG           cch;
00597
00598         cch = GetWindowTextLength(m_hwndEdit);
00599
00600         /*
00601         dwFlags can be 0 or TS_TC_CORRECTION
00602         */
00603         dwFlags = 0;
00604
00605         tc.acpStart = 0;
00606         tc.acpOldEnd = m_cchOldLength;
00607         tc.acpNewEnd = cch;
00608
00609         m_AdviseSink.pTextStoreACPSink->OnTextChange(dwFlags, &tc);
00610
00611         m_cchOldLength = cch;
00612     }
00613
00614     return 0;
00615 }
00616
00617 /**************************************************************************
00618
00619    CTSFEditWnd::_OnKillFocus()
00620
00621 **************************************************************************/
00622
00623 LRESULT CTSFEditWnd::_OnKillFocus(VOID)
00624 {
00625     OutputDebugString(TEXT("CTSFEditWnd::_OnKillFocus\n"));
00626
00627     return 0;
00628 }
00629
00630 /**************************************************************************
00631
00632    CTSFEditWnd::_OnEditKillFocus()
00633
00634 **************************************************************************/
00635
00636 LRESULT CTSFEditWnd::_OnEditKillFocus(VOID)
00637 {
00638     OutputDebugString(TEXT("CTSFEditWnd::_OnEditKillFocus\n"));
00639
00640     return 0;
00641 }
00642
00643 /**************************************************************************
00644
00645    CTSFEditWnd::_OnNotify()
00646
00647 **************************************************************************/
00648
00649 LRESULT CTSFEditWnd::_OnNotify(UINT, LPNMHDR)
00650 {
00651     return 0;
00652 }
00653
00654 /**************************************************************************
00655
00656    CTSFEditWnd::_OnSize()
00657
00658 **************************************************************************/
00659
00660 LRESULT CTSFEditWnd::_OnSize(WPARAM wParam, LPARAM lParam)
00661 {
00662     //adjust the size and location of the status bar
00663     SendMessage(m_hwndStatus, WM_SIZE, wParam, lParam);
00664
00665     RECT    rc;
00666
00667     GetWindowRect(m_hwndStatus, &rc);
00668
00669     MoveWindow( m_hwndEdit,
00670                 0,
00671                 0,
00672                 LOWORD(lParam),
00673                 HIWORD(lParam) - (rc.bottom - rc.top),
00674                 TRUE);
00675
00676     m_AdviseSink.pTextStoreACPSink->OnLayoutChange(TS_LC_CHANGE, EDIT_VIEW_COOKIE);
00677
00678     return 0;
00679 }
00680
00681 /**************************************************************************
00682
00683    CTSFEditWnd::_IsLocked()
00684
00685 **************************************************************************/
00686
00687 BOOL CTSFEditWnd::_IsLocked(DWORD dwLockType)
00688 {
00689     if(m_dwInternalLockType)
00690     {
00691         return TRUE;
00692     }
00693
00694     return m_fLocked && (m_dwLockType & dwLockType);
00695 }
00696
00697 /**************************************************************************
00698
00699    CTSFEditWnd::_ClearAdviseSink()
00700
00701 **************************************************************************/
00702
00703 HRESULT CTSFEditWnd::_ClearAdviseSink(PADVISE_SINK pAdviseSink)
00704 {
00705     if(pAdviseSink->punkID)
00706     {
00707         pAdviseSink->punkID->Release();
00708         pAdviseSink->punkID = NULL;
00709     }
00710
00711     if(pAdviseSink->pTextStoreACPSink)
00712     {
00713         pAdviseSink->pTextStoreACPSink->Release();
00714         pAdviseSink->pTextStoreACPSink = NULL;
00715     }
00716
00717     pAdviseSink->dwMask = 0;
00718
00719     return S_OK;
00720 }
00721
00722 /**************************************************************************
00723
00724    CTSFEditWnd::_LockDocument()
00725
00726 **************************************************************************/
00727
00728 BOOL CTSFEditWnd::_LockDocument(DWORD dwLockFlags)
00729 {
00730     if(m_fLocked)
00731     {
00732         return FALSE;
00733     }
00734
00735     m_fLocked = TRUE;
00736     m_dwLockType = dwLockFlags;
00737
00738     return TRUE;
00739 }
00740
00741 /**************************************************************************
00742
00743   CTSFEditWnd::_InternalLockDocument()
00744
00745 **************************************************************************/
00746
00747 BOOL CTSFEditWnd::_InternalLockDocument(DWORD dwLockFlags)
00748 {
00749     m_dwInternalLockType = dwLockFlags;
00750
00751     return TRUE;
00752 }
00753
00754 /**************************************************************************
00755
00756    CTSFEditWnd::_UnlockDocument
00757
00758 **************************************************************************/
00759
00760 void CTSFEditWnd::_UnlockDocument()
00761 {
00762     HRESULT hr;
00763
00764     m_fLocked = FALSE;
00765     m_dwLockType = 0;
00766
00767     //if there is a pending lock upgrade, grant it
00768     if(m_fPendingLockUpgrade)
00769     {
00770         m_fPendingLockUpgrade = FALSE;
00771
00772         RequestLock(TS_LF_READWRITE, &hr);
00773     }
00774
00775     //if any layout changes occurred during the lock, notify the manager
00776     if(m_fLayoutChanged)
00777     {
00778         m_fLayoutChanged = FALSE;
00779         m_AdviseSink.pTextStoreACPSink->OnLayoutChange(TS_LC_CHANGE, EDIT_VIEW_COOKIE);
00780     }
00781 }
00782
00783 /**************************************************************************
00784
00785   CTSFEditWnd::_InternalUnlockDocument()
00786
00787 **************************************************************************/
00788
00789 void CTSFEditWnd::_InternalUnlockDocument()
00790 {
00791     m_dwInternalLockType = 0;
00792 }
00793
00794 /**************************************************************************
00795
00796    CTSFEditWnd::_GetCurrentSelection()
00797
00798 **************************************************************************/
00799
00800 BOOL CTSFEditWnd::_GetCurrentSelection(void)
00801 {
00802     //get the selection from the edit control
00803     ::SendMessage(m_hwndEdit, EM_GETSEL, (WPARAM)&m_acpStart, (LPARAM)&m_acpEnd);
00804
00805     return TRUE;
00806 }
00807
00808 /**************************************************************************
00809
00810   CTSFEditWnd::_OnUpdate()
00811
00812 **************************************************************************/
00813
00814 void CTSFEditWnd::_OnUpdate(void)
00815 {
00816     //something changed, but it is not known what specifically changed
00817     //just update the status bar
00818     _UpdateStatusBar();
00819 }
00820
00821 /**************************************************************************
00822
00823    CTSFEditWnd::_UpdateStatusBar()
00824
00825 **************************************************************************/
00826
00827 void CTSFEditWnd::_UpdateStatusBar(void)
00828 {
00829     int     nParts[2];
00830     HDC     hdc;
00831     HFONT   hFont;
00832     SIZE    size;
00833     TCHAR   szComposition[MAX_PATH];
00834
00835     hdc = GetDC(m_hwndStatus);
00836     hFont = (HFONT)SendMessage(m_hwndStatus, WM_GETFONT, 0, 0);
00837     hFont = (HFONT)SelectObject(hdc, hFont);
00838
00839     if(m_cCompositions)
00840     {
00841         lstrcpy(szComposition, TEXT("In Composition"));
00842     }
00843     else
00844     {
00845         lstrcpy(szComposition, TEXT("No Composition"));
00846     }
00847
00848     GetTextExtentPoint32(hdc, szComposition, lstrlen(szComposition), &size);
00849     nParts[0] = size.cx + (GetSystemMetrics(SM_CXEDGE) * 4);
00850
00851     nParts[1] = -1;
00852
00853     SendMessage(m_hwndStatus, SB_SIMPLE, FALSE, 0);
00854     SendMessage(m_hwndStatus, SB_SETPARTS, ARRAYSIZE(nParts), (LPARAM)nParts);
00855
00856     SendMessage(m_hwndStatus, SB_SETTEXT, 0, (LPARAM)szComposition);
00857     SendMessage(m_hwndStatus, SB_SETTEXT, 1, (LPARAM)TEXT(""));
00858
00859     //reset the DC
00860     SelectObject(hdc, hFont);
00861     ReleaseDC(m_hwndStatus, hdc);
00862
00863     //enable/disable the menu items as necessary
00864     HMENU hMenu = GetMenu(m_hwndParent);
00865     if(NULL != hMenu)
00866     {
00867     }
00868
00869 }
00870
00871 /**************************************************************************
00872
00873   CTSFEditWnd::_OnInitMenuPopup()
00874
00875 **************************************************************************/
00876
00877 LRESULT CTSFEditWnd::_OnInitMenuPopup(WPARAM wParam, LPARAM lParam)
00878 {
00879     HMENU hMenu = (HMENU)wParam;
00880
00881     if(NULL != hMenu)
00882     {
00883         EnableMenuItem(hMenu, IDM_TERMINATE_COMPOSITION, m_cCompositions ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
00884         EnableMenuItem(hMenu, IDM_RECONVERT, _CanReconvertSelection() ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
00885         EnableMenuItem(hMenu, IDM_PLAYBACK, _CanPlaybackSelection() ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
00886         EnableMenuItem(hMenu, IDM_LOAD, !_IsLocked(TS_LF_READ) ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
00887     }
00888
00889     return 0;
00890 }
00891
00892 /**************************************************************************
00893
00894    CTSFEditWnd::_ClearRequestedAttributes()
00895
00896 **************************************************************************/
00897
00898 void CTSFEditWnd::_ClearRequestedAttributes(void)
00899 {
00900     int i;
00901
00902     for (i = 0; i < NUM_SUPPORTED_ATTRS; i++)
00903     {
00904         VariantClear(&m_rgAttributes[i].varValue);
00905         m_rgAttributes[i].dwFlags = ATTR_FLAG_NONE;
00906     }
00907 }
00908
00909 /**************************************************************************
00910
00911   CTSFEditWnd::_ClearText()
00912
00913 **************************************************************************/
00914
00915 void CTSFEditWnd::_ClearText(void)
00916 {
00917     //can't do this if someone has a lock
00918     if(_IsLocked(TS_LF_READ))
00919     {
00920         return;
00921     }
00922
00923     _LockDocument(TS_LF_READWRITE);
00924
00925     //empty the text in the edit control, but don't send a change notification
00926     BOOL    fOldNotify = m_fNotify;
00927     m_fNotify = FALSE;
00928     SetWindowTextW(m_hwndEdit, NULL);
00929     m_fNotify = fOldNotify;
00930
00931     //update current selection
00932     m_acpStart = m_acpEnd = 0;
00933
00934     //notify TSF about the changes
00935     m_AdviseSink.pTextStoreACPSink->OnSelectionChange();
00936
00937     _OnEditChange();
00938
00939     _UnlockDocument();
00940
00941     // make sure to send the OnLayoutChange notification AFTER releasing the lock
00942     // so clients can do something useful during the notification
00943     m_AdviseSink.pTextStoreACPSink->OnLayoutChange(TS_LC_CHANGE, EDIT_VIEW_COOKIE);
00944 }
00945
00946 /**************************************************************************
00947
00948   CTSFEditWnd::_GetText()
00949
00950 **************************************************************************/
00951
00952 HRESULT CTSFEditWnd::_GetText(LPWSTR *ppwsz, LPLONG pcch)
00953 {
00954     DWORD   cch;
00955     LPWSTR  pwszText;
00956
00957     *ppwsz = NULL;
00958
00959     cch = GetWindowTextLength(m_hwndEdit);
00960     pwszText = (LPWSTR)GlobalAlloc(GMEM_FIXED, (cch + 1) * sizeof(WCHAR));
00961     if(NULL == pwszText)
00962     {
00963         return E_OUTOFMEMORY;
00964     }
00965
00966     GetWindowTextW(m_hwndEdit, pwszText, cch + 1);
00967
00968     *ppwsz = pwszText;
00969
00970     if(pcch)
00971     {
00972         *pcch = cch;
00973     }
00974
00975     return S_OK;
00976 }
00977
00978 /**************************************************************************
00979
00980   CTSFEditWnd::_GetDisplayAttributes()
00981
00982 **************************************************************************/
00983
00984 void CTSFEditWnd::_GetDisplayAttributes(void)
00985 {
00986     HRESULT             hr;
00987     const GUID          *rGuidProperties[1];
00988     ITfReadOnlyProperty *pTrackProperty;
00989
00990     //get the tracking property for the attributes
00991     rGuidProperties[0] = &GUID_PROP_ATTRIBUTE;
00992     hr = m_pContext->TrackProperties(   rGuidProperties,
00993                                         1,
00994                                         NULL,
00995                                         0,
00996                                         &pTrackProperty);
00997     if(SUCCEEDED(hr))
00998     {
00999         ITfRangeACP *pRangeAllText;
01000         LONG        acpEnd;
01001
01002         //get the range of the entire text
01003         acpEnd = GetWindowTextLength(m_hwndEdit);
01004         hr = m_pServices->CreateRange(0, acpEnd, &pRangeAllText);
01005         if(SUCCEEDED(hr))
01006         {
01007             IEnumTfRanges   *pEnumRanges;
01008
01009             hr = pTrackProperty->EnumRanges(m_EditCookie, &pEnumRanges, pRangeAllText);
01010             if(SUCCEEDED(hr))
01011             {
01012                 ITfRange    *pPropRange;
01013                 ULONG       uFetched;
01014
01015                 /*
01016                 Each range in pEnumRanges represents a span of text that has
01017                 the same properties specified in TrackProperties.
01018                 */
01019                 while((hr = pEnumRanges->Next(1, &pPropRange, &uFetched)) == S_OK && uFetched)
01020                 {
01021                     //get the attribute property for the property range
01022                     VARIANT var;
01023
01024                     VariantInit(&var);
01025
01026                     hr = pTrackProperty->GetValue(m_EditCookie, pPropRange, &var);
01027                     if(SUCCEEDED(hr))
01028                     {
01029                         /*
01030                         The property is actually a VT_UNKNOWN that contains an
01031                         IEnumTfPropertyValue object.
01032                         */
01033                         IEnumTfPropertyValue    *pEnumPropertyVal;
01034
01035                         hr = var.punkVal->QueryInterface(IID_IEnumTfPropertyValue, (LPVOID*)&pEnumPropertyVal);
01036                         if(SUCCEEDED(hr))
01037                         {
01038                             TF_PROPERTYVAL tfPropVal;
01039
01040                             while((hr = pEnumPropertyVal->Next(1, &tfPropVal, &uFetched)) == S_OK && uFetched)
01041                             {
01042                                 if(VT_EMPTY == tfPropVal.varValue.vt)
01043                                 {
01044                                     //the property for this range has no value
01045                                     continue;
01046                                 }
01047                                 else if(VT_I4 == tfPropVal.varValue.vt)
01048                                 {
01049                                     //the property is a guidatom
01050                                     TfGuidAtom  gaVal;
01051                                     GUID        guid;
01052
01053                                     gaVal = (TfGuidAtom)tfPropVal.varValue.lVal;
01054
01055                                     hr = m_pCategoryMgr->GetGUID(gaVal, &guid);
01056                                     if(SUCCEEDED(hr))
01057                                     {
01058                                         ITfDisplayAttributeInfo *pDispInfo;
01059
01060                                         hr = m_pDisplayAttrMgr->GetDisplayAttributeInfo(guid, &pDispInfo, NULL);
01061                                         if(SUCCEEDED(hr))
01062                                         {
01063                                             TF_DISPLAYATTRIBUTE da;
01064
01065                                             hr = pDispInfo->GetAttributeInfo(&da);
01066
01067                                             {
01068                                                 GUID    guidDispInfo;
01069                                                 hr = pDispInfo->GetGUID(&guidDispInfo);
01070                                                 guidDispInfo.Data1 = 0;
01071                                             }
01072
01073                                             {
01074                                                 BSTR    bstr;
01075
01076                                                 hr = pDispInfo->GetDescription(&bstr);
01077                                                 if(SUCCEEDED(hr))
01078                                                 {
01079                                                     SysFreeString(bstr);
01080                                                 }
01081                                             }
01082
01083                                             pDispInfo->Release();
01084                                         }
01085                                     }
01086                                 }
01087                                 else
01088                                 {
01089                                     //the property is not recognized
01090                                 }
01091                             }
01092
01093                             pEnumPropertyVal->Release();
01094                         }
01095
01096                         VariantClear(&var);
01097                     }
01098
01099                     pPropRange->Release();
01100                 }
01101
01102                 pEnumRanges->Release();
01103             }
01104
01105             pRangeAllText->Release();
01106         }
01107
01108         pTrackProperty->Release();
01109     }
01110 }
01111
01112 /**************************************************************************
01113
01114   CTSFEditWnd::_GetTextOwner()
01115
01116 **************************************************************************/
01117
01118 void CTSFEditWnd::_GetTextOwner(void)
01119 {
01120     HRESULT             hr;
01121     const GUID          *rGuidProperties[1];
01122     ITfReadOnlyProperty *pTrackProperty;
01123
01124     //get the tracking property for the attributes
01125     rGuidProperties[0] = &GUID_PROP_TEXTOWNER;
01126     hr = m_pContext->TrackProperties(   rGuidProperties,
01127                                         1,
01128                                         NULL,
01129                                         0,
01130                                         &pTrackProperty);
01131     if(SUCCEEDED(hr))
01132     {
01133         ITfRangeACP *pRangeAllText;
01134         LONG        acpEnd;
01135
01136         //get the range of the entire text
01137         acpEnd = GetWindowTextLength(m_hwndEdit);
01138         hr = m_pServices->CreateRange(0, acpEnd, &pRangeAllText);
01139         if(SUCCEEDED(hr))
01140         {
01141             IEnumTfRanges   *pEnumRanges;
01142
01143             hr = pTrackProperty->EnumRanges(m_EditCookie, &pEnumRanges, pRangeAllText);
01144             if(SUCCEEDED(hr))
01145             {
01146                 ITfRange    *pPropRange;
01147                 ULONG       uFetched;
01148
01149                 /*
01150                 Each range in pEnumRanges represents a span of text that has
01151                 the same properties specified in TrackProperties.
01152                 */
01153                 while((hr = pEnumRanges->Next(1, &pPropRange, &uFetched)) == S_OK && uFetched)
01154                 {
01155                     //get the attribute property for the property range
01156                     VARIANT var;
01157
01158                     VariantInit(&var);
01159
01160                     hr = pTrackProperty->GetValue(m_EditCookie, pPropRange, &var);
01161                     if(SUCCEEDED(hr))
01162                     {
01163                         /*
01164                         The property is actually a VT_UNKNOWN that contains an
01165                         IEnumTfPropertyValue object.
01166                         */
01167                         IEnumTfPropertyValue    *pEnumPropertyVal;
01168
01169                         hr = var.punkVal->QueryInterface(IID_IEnumTfPropertyValue, (LPVOID*)&pEnumPropertyVal);
01170                         if(SUCCEEDED(hr))
01171                         {
01172                             TF_PROPERTYVAL tfPropVal;
01173
01174                             while((hr = pEnumPropertyVal->Next(1, &tfPropVal, &uFetched)) == S_OK && uFetched)
01175                             {
01176                                 /*
01177                                 The GUID_PROP_TEXTOWNER attribute value is the CLSID of the text service that owns the text. If the text is not owned, the value is VT_EMPTY.
01178                                 */
01179                                 if(VT_EMPTY == tfPropVal.varValue.vt)
01180                                 {
01181                                     //the text is not owned
01182                                     continue;
01183                                 }
01184                                 else if(VT_I4 == tfPropVal.varValue.vt)
01185                                 {
01186                                     //the property is a guidatom that represents the CLSID of the text service that owns the text.
01187                                     TfGuidAtom  gaVal;
01188                                     CLSID       clsidOwner;
01189
01190                                     gaVal = (TfGuidAtom)tfPropVal.varValue.lVal;
01191
01192                                     hr = m_pCategoryMgr->GetGUID(gaVal, &clsidOwner);
01193                                     if(SUCCEEDED(hr))
01194                                     {
01195                                     }
01196                                 }
01197                                 else
01198                                 {
01199                                     //the property is not recognized
01200                                 }
01201                             }
01202
01203                             pEnumPropertyVal->Release();
01204                         }
01205
01206                         VariantClear(&var);
01207                     }
01208
01209                     pPropRange->Release();
01210                 }
01211
01212                 pEnumRanges->Release();
01213             }
01214
01215             pRangeAllText->Release();
01216         }
01217
01218         pTrackProperty->Release();
01219     }
01220 }
01221
01222 /**************************************************************************
01223
01224   CTSFEditWnd::_GetReadingText()
01225
01226 **************************************************************************/
01227
01228 void CTSFEditWnd::_GetReadingText(void)
01229 {
01230     HRESULT             hr;
01231     const GUID          *rGuidProperties[1];
01232     ITfReadOnlyProperty *pTrackProperty;
01233
01234     //get the tracking property for the attributes
01235     rGuidProperties[0] = &GUID_PROP_READING;
01236     hr = m_pContext->TrackProperties(   rGuidProperties,
01237                                         1,
01238                                         NULL,
01239                                         0,
01240                                         &pTrackProperty);
01241     if(SUCCEEDED(hr))
01242     {
01243         ITfRangeACP *pRangeAllText;
01244         LONG        acpEnd;
01245
01246         //get the range of the entire text
01247         acpEnd = GetWindowTextLength(m_hwndEdit);
01248         hr = m_pServices->CreateRange(0, acpEnd, &pRangeAllText);
01249         if(SUCCEEDED(hr))
01250         {
01251             IEnumTfRanges   *pEnumRanges;
01252
01253             hr = pTrackProperty->EnumRanges(m_EditCookie, &pEnumRanges, pRangeAllText);
01254             if(SUCCEEDED(hr))
01255             {
01256                 ITfRange    *pPropRange;
01257                 ULONG       uFetched;
01258
01259                 /*
01260                 Each range in pEnumRanges represents a span of text that has
01261                 the same properties specified in TrackProperties.
01262                 */
01263                 while((hr = pEnumRanges->Next(1, &pPropRange, &uFetched)) == S_OK && uFetched)
01264                 {
01265                     //get the attribute property for the property range
01266                     VARIANT var;
01267
01268                     VariantInit(&var);
01269
01270                     hr = pTrackProperty->GetValue(m_EditCookie, pPropRange, &var);
01271                     if(SUCCEEDED(hr))
01272                     {
01273                         /*
01274                         The property is actually a VT_UNKNOWN that contains an
01275                         IEnumTfPropertyValue object.
01276                         */
01277                         IEnumTfPropertyValue    *pEnumPropertyVal;
01278
01279                         hr = var.punkVal->QueryInterface(IID_IEnumTfPropertyValue, (LPVOID*)&pEnumPropertyVal);
01280                         if(SUCCEEDED(hr))
01281                         {
01282                             TF_PROPERTYVAL tfPropVal;
01283
01284                             while((hr = pEnumPropertyVal->Next(1, &tfPropVal, &uFetched)) == S_OK && uFetched)
01285                             {
01286                                 /*
01287                                 The GUID_PROP_TEXTOWNER attribute value is the CLSID of the text service that owns the text. If the text is not owned, the value is VT_EMPTY.
01288                                 */
01289                                 if(VT_EMPTY == tfPropVal.varValue.vt)
01290                                 {
01291                                     //the text is not owned
01292                                     continue;
01293                                 }
01294                                 else if(VT_BSTR == tfPropVal.varValue.vt)
01295                                 {
01296                                     //the property is a BSTR.
01297                                     tfPropVal.varValue.bstrVal;
01298
01299                                     HRESULT hr;
01300                                     WCHAR   wsz[MAX_PATH];
01301                                     ULONG   cch;
01302                                     hr = pPropRange->GetText(m_EditCookie, 0, wsz, MAX_PATH-1, &cch);
01303                                     wsz[cch] = 0;
01304                                 }
01305                                 else
01306                                 {
01307                                     //the property is not recognized
01308                                 }
01309                             }
01310
01311                             pEnumPropertyVal->Release();
01312                         }
01313
01314                         VariantClear(&var);
01315                     }
01316
01317                     pPropRange->Release();
01318                 }
01319
01320                 pEnumRanges->Release();
01321             }
01322
01323             pRangeAllText->Release();
01324         }
01325
01326         pTrackProperty->Release();
01327     }
01328 }
01329
01330 /**************************************************************************
01331
01332   CTSFEditWnd::_GetComposing()
01333
01334 **************************************************************************/
01335
01336 void CTSFEditWnd::_GetComposing(void)
01337 {
01338     HRESULT             hr;
01339     const GUID          *rGuidProperties[1];
01340     ITfReadOnlyProperty *pTrackProperty;
01341
01342     //get the tracking property for the attributes
01343     rGuidProperties[0] = &GUID_PROP_COMPOSING;
01344     hr = m_pContext->TrackProperties(   rGuidProperties,
01345                                         1,
01346                                         NULL,
01347                                         0,
01348                                         &pTrackProperty);
01349     if(SUCCEEDED(hr))
01350     {
01351         ITfRangeACP *pRangeAllText;
01352         LONG        acpEnd;
01353
01354         //get the range of the entire text
01355         acpEnd = GetWindowTextLength(m_hwndEdit);
01356         hr = m_pServices->CreateRange(0, acpEnd, &pRangeAllText);
01357         if(SUCCEEDED(hr))
01358         {
01359             IEnumTfRanges   *pEnumRanges;
01360
01361             hr = pTrackProperty->EnumRanges(m_EditCookie, &pEnumRanges, pRangeAllText);
01362             if(SUCCEEDED(hr))
01363             {
01364                 ITfRange    *pPropRange;
01365                 ULONG       uFetched;
01366
01367                 /*
01368                 Each range in pEnumRanges represents a span of text that has
01369                 the same properties specified in TrackProperties.
01370                 */
01371                 while((hr = pEnumRanges->Next(1, &pPropRange, &uFetched)) == S_OK && uFetched)
01372                 {
01373                     //get the attribute property for the property range
01374                     VARIANT var;
01375
01376                     VariantInit(&var);
01377
01378                     hr = pTrackProperty->GetValue(m_EditCookie, pPropRange, &var);
01379                     if(SUCCEEDED(hr))
01380                     {
01381                         /*
01382                         The property is actually a VT_UNKNOWN that contains an
01383                         IEnumTfPropertyValue object.
01384                         */
01385                         IEnumTfPropertyValue    *pEnumPropertyVal;
01386
01387                         hr = var.punkVal->QueryInterface(IID_IEnumTfPropertyValue, (LPVOID*)&pEnumPropertyVal);
01388                         if(SUCCEEDED(hr))
01389                         {
01390                             TF_PROPERTYVAL tfPropVal;
01391
01392                             while((hr = pEnumPropertyVal->Next(1, &tfPropVal, &uFetched)) == S_OK && uFetched)
01393                             {
01394                                 /*
01395                                 The GUID_PROP_COMPOSING attribute value is a VT_I4 that contains a boolean indicating if the text is part of a composition.
01396                                 */
01397                                 BOOL    fComposing = FALSE;
01398
01399                                 if(VT_EMPTY == tfPropVal.varValue.vt)
01400                                 {
01401                                     //the text is not part of a composition
01402                                 }
01403                                 else if(VT_I4 == tfPropVal.varValue.vt)
01404                                 {
01405                                     //the property is a VT_I4.
01406                                     if(tfPropVal.varValue.lVal)
01407                                     {
01408                                         //The text is part of a composition
01409                                         fComposing = TRUE;
01410                                     }
01411                                 }
01412                                 else
01413                                 {
01414                                     //the property is not recognized
01415                                 }
01416                             }
01417
01418                             pEnumPropertyVal->Release();
01419                         }
01420
01421                         VariantClear(&var);
01422                     }
01423
01424                     pPropRange->Release();
01425                 }
01426
01427                 pEnumRanges->Release();
01428             }
01429
01430             pRangeAllText->Release();
01431         }
01432
01433         pTrackProperty->Release();
01434     }
01435 }
01436
01437 /**************************************************************************
01438
01439   CTSFEditWnd::_CanReconvertSelection()
01440
01441 **************************************************************************/
01442
01443 BOOL CTSFEditWnd::_CanReconvertSelection(void)
01444 {
01445     BOOL                fConv = FALSE;
01446     HRESULT             hr;
01447     ITfFunctionProvider *pFuncProv;
01448
01449     _InternalLockDocument(TS_LF_READ);
01450
01451     hr = m_pThreadMgr->GetFunctionProvider(GUID_SYSTEM_FUNCTIONPROVIDER, &pFuncProv);
01452     if(SUCCEEDED(hr))
01453     {
01454         ITfFnReconversion  *pRecon;
01455
01456         hr = pFuncProv->GetFunction(GUID_NULL, IID_ITfFnReconversion, (IUnknown**)&pRecon);
01457         if(SUCCEEDED(hr))
01458         {
01459             TF_SELECTION    ts;
01460             ULONG           uFetched;
01461
01462             hr = m_pContext->GetSelection(m_EditCookie, TF_DEFAULT_SELECTION, 1, &ts, &uFetched);
01463             if(SUCCEEDED(hr))
01464             {
01465                 ITfRange    *pRange = NULL;
01466
01467                 hr = pRecon->QueryRange(ts.range, &pRange, &fConv);
01468                 if(SUCCEEDED(hr) && pRange)
01469                 {
01470                     pRange->Release();
01471                 }
01472
01473             ts.range->Release();
01474             }
01475
01476             pRecon->Release();
01477         }
01478
01479         pFuncProv->Release();
01480     }
01481
01482     _InternalUnlockDocument();
01483
01484     return fConv;
01485 }
01486
01487 /**************************************************************************
01488
01489   CTSFEditWnd::_Reconvert()
01490
01491 **************************************************************************/
01492
01493 void CTSFEditWnd::_Reconvert(void)
01494 {
01495     HRESULT hr;
01496     ITfFunctionProvider *pFuncProv;
01497
01498     _InternalLockDocument(TS_LF_READ);
01499
01500     hr = m_pThreadMgr->GetFunctionProvider(GUID_SYSTEM_FUNCTIONPROVIDER, &pFuncProv);
01501     if(SUCCEEDED(hr))
01502     {
01503         ITfFnReconversion  *pRecon;
01504
01505         hr = pFuncProv->GetFunction(GUID_NULL, IID_ITfFnReconversion, (IUnknown**)&pRecon);
01506         if(SUCCEEDED(hr))
01507         {
01508             TF_SELECTION    ts;
01509             ULONG           uFetched;
01510
01511             hr = m_pContext->GetSelection(m_EditCookie, TF_DEFAULT_SELECTION, 1, &ts, &uFetched);
01512             if(SUCCEEDED(hr))
01513             {
01514                 ITfRange    *pRange;
01515                 BOOL        fConv;
01516
01517                 //get the range that covers the text to be reconverted
01518                 hr = pRecon->QueryRange(ts.range, &pRange, &fConv);
01519                 if(SUCCEEDED(hr) && pRange)
01520                 {
01521                     {
01522                         WCHAR   wsz[MAX_PATH];
01523                         ULONG   cch = 0;
01524                         pRange->GetText(m_EditCookie, 0, wsz, MAX_PATH-1, &cch);
01525                         wsz[cch] = 0;
01526                     }
01527
01528                     //get the list of reconversion candidates
01529                     ITfCandidateList    *pCandList;
01530                     hr = pRecon->GetReconversion(pRange, &pCandList);
01531                     if(SUCCEEDED(hr))
01532                     {
01533                         ULONG   i;
01534                         ULONG   uCandidateCount = 0;
01535
01536                         hr = pCandList->GetCandidateNum(&uCandidateCount);
01537
01538                         for(i = 0; i < uCandidateCount; i++)
01539                         {
01540                             ITfCandidateString  *pCandString;
01541
01542                             hr = pCandList->GetCandidate(i, &pCandString);
01543                             if(SUCCEEDED(hr))
01544                             {
01545                                 BSTR    bstr;
01546
01547                                 hr = pCandString->GetString(&bstr);
01548                                 if(SUCCEEDED(hr))
01549                                 {
01550                                     OutputDebugString(TEXT("\tCandidate - \""));
01551                                     OutputDebugStringW(bstr);
01552                                     OutputDebugString(TEXT("\"\n"));
01553                                     SysFreeString(bstr);
01554                                 }
01555
01556                                 pCandString->Release();
01557                             }
01558                         }
01559
01560                         pCandList->Release();
01561                     }
01562                     //cause the reconversion to happen
01563                     hr = pRecon->Reconvert(pRange);
01564
01565                 }
01566             }
01567
01568             pRecon->Release();
01569         }
01570
01571         pFuncProv->Release();
01572     }
01573
01574     _InternalUnlockDocument();
01575 }
01576
01577 /**************************************************************************
01578
01579   CTSFEditWnd::_CanPlaybackSelection()
01580
01581 **************************************************************************/
01582
01583 BOOL CTSFEditWnd::_CanPlaybackSelection(void)
01584 {
01585     BOOL                fCanPlayback = FALSE;
01586     HRESULT             hr;
01587     ITfFunctionProvider *pFuncProv;
01588
01589     _InternalLockDocument(TS_LF_READ);
01590
01591     hr = m_pThreadMgr->GetFunctionProvider(CLSID_SapiLayr, &pFuncProv);
01592     if(SUCCEEDED(hr))
01593     {
01594         ITfFnPlayBack *pPlayback;
01595
01596         hr = pFuncProv->GetFunction(GUID_NULL, IID_ITfFnPlayBack, (IUnknown**)&pPlayback);
01597         if(SUCCEEDED(hr))
01598         {
01599             TF_SELECTION    ts;
01600             ULONG           uFetched;
01601
01602             hr = m_pContext->GetSelection(m_EditCookie, TF_DEFAULT_SELECTION, 1, &ts, &uFetched);
01603             if(SUCCEEDED(hr))
01604             {
01605                 ITfRange    *pRange = NULL;
01606
01607                 hr = pPlayback->QueryRange(ts.range, &pRange, &fCanPlayback);
01608                 if(SUCCEEDED(hr) && pRange)
01609                 {
01610                     pRange->Release();
01611                 }
01612
01613             ts.range->Release();
01614             }
01615
01616             pPlayback->Release();
01617         }
01618
01619         pFuncProv->Release();
01620     }
01621
01622     _InternalUnlockDocument();
01623
01624     return fCanPlayback;
01625 }
01626
01627 /**************************************************************************
01628
01629   CTSFEditWnd::_Playback()
01630
01631 **************************************************************************/
01632
01633 void CTSFEditWnd::_Playback(void)
01634 {
01635     HRESULT             hr;
01636     ITfFunctionProvider *pFuncProv;
01637
01638     _InternalLockDocument(TS_LF_READ);
01639
01640     hr = m_pThreadMgr->GetFunctionProvider(CLSID_SapiLayr, &pFuncProv);
01641     if(SUCCEEDED(hr))
01642     {
01643         ITfFnPlayBack *pPlayback;
01644
01645         hr = pFuncProv->GetFunction(GUID_NULL, IID_ITfFnPlayBack, (IUnknown**)&pPlayback);
01646         if(SUCCEEDED(hr))
01647         {
01648             TF_SELECTION    ts;
01649             ULONG           uFetched;
01650
01651             hr = m_pContext->GetSelection(m_EditCookie, TF_DEFAULT_SELECTION, 1, &ts, &uFetched);
01652             if(SUCCEEDED(hr))
01653             {
01654                 BOOL        fCanPlayback;
01655                 ITfRange    *pRange = NULL;
01656
01657                 hr = pPlayback->QueryRange(ts.range, &pRange, &fCanPlayback);
01658                 if(SUCCEEDED(hr) && pRange)
01659                 {
01660                     hr = pPlayback->Play(pRange);
01661
01662                     pRange->Release();
01663                 }
01664
01665             ts.range->Release();
01666             }
01667
01668             pPlayback->Release();
01669         }
01670
01671         pFuncProv->Release();
01672     }
01673
01674     _InternalUnlockDocument();
01675 }
01676
01677
01678 ///////////////////////////////////////////////////////////////////////////
01679 //
01680 // IUnknown Implementation
01681 //
01682
01683 /**************************************************************************
01684
01685    CTSFEditWnd::QueryInterface
01686
01687 **************************************************************************/
01688
01689 STDMETHODIMP CTSFEditWnd::QueryInterface(REFIID riid, LPVOID *ppReturn)
01690 {
01691     *ppReturn = NULL;
01692
01693     //IUnknown
01694     if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITextStoreACP))
01695     {
01696         *ppReturn = (ITextStoreACP*)this;
01697     }
01698
01699     //ITfContextOwnerCompositionSink
01700     else if(IsEqualIID(riid, IID_ITfContextOwnerCompositionSink))
01701     {
01702         *ppReturn = (ITfContextOwnerCompositionSink*)this;
01703     }
01704
01705     //ITfFunctionProvider
01706     else if(IsEqualIID(riid, IID_ITfFunctionProvider))
01707     {
01708         *ppReturn = (ITfFunctionProvider*)this;
01709     }
01710
01711     if(*ppReturn)
01712     {
01713         (*(LPUNKNOWN*)ppReturn)->AddRef();
01714         return S_OK;
01715     }
01716
01717     return E_NOINTERFACE;
01718 }
01719
01720 /**************************************************************************
01721
01722    CTSFEditWnd::AddRef
01723
01724 **************************************************************************/
01725
01726 STDMETHODIMP_(DWORD) CTSFEditWnd::AddRef()
01727 {
01728     return ++m_ObjRefCount;
01729 }
01730
01731
01732 /**************************************************************************
01733
01734    CTSFEditWnd::Release
01735
01736 **************************************************************************/
01737
01738 STDMETHODIMP_(DWORD) CTSFEditWnd::Release()
01739 {
01740     if(--m_ObjRefCount == 0)
01741     {
01742         delete this;
01743         return 0;
01744     }
01745
01746     return m_ObjRefCount;
01747 }
01748
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsimple/prof.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsimple

prof.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Profiling Routines
00005
00006     FILE: Prof.cpp
00007
00008     PURPOSE: Routines for profiling server system services.
00009
00010     FUNCTIONS:
00011         ProfOpenLog - Opens the profile log file and prepares to
00012     take timings.
00013   ProfRecordTime - Records the time of an event.
00014   ProfCloseLog - Writes the profiling data to the file
00015     and closes it.
00016
00017     COMMENTS: See the header file for function info.
00018         These routines depend on the existence of a high-resolution
00019     performance counter.
00020
00021 */
00022
00023 #include <windows.h>
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <process.h>
00027 #include <tchar.h>
00028
00029 #include "Prof.h"
00030 #include "Service.h"
00031 #include "common.h"
00032
00033 // Handle to the profile log file.
00034 HANDLE hProfLog = NULL;
00035
00036 // Counters for the timings.
00037 LARGE_INTEGER lpStartTime, lpCurrentTime, lpFrequency;
00038
00039 // The profile log text data.
00040 // Profile log gets acumulated in this string first, and then
00041 // gets written out when the log gets closed.
00042 TCHAR PROF_LOG[PROF_LOG_MAX_SIZE];
00043
00044 // Current size of the profile log.
00045 UINT nProfLogSize = 0;
00046
00047 // This is the maximum size of the log entry without the
00048 // user-specified message.  It is basically the size of a string
00049 // with an integer and a float.
00050 #define MAX_ENTRY_SIZE_NOMSG (32)
00051
00052 HANDLE hProfMutex;
00053
00054 VOID ProfOpenLog(LPTSTR LogFileName) {
00055
00056     // Create the mutex.
00057     if ((hProfMutex = CreateMutex(NULL,
00058           FALSE,
00059           TEXT("ProfMutex"))) == INVALID_HANDLE_VALUE) {
00060   RaiseException(GetLastError(), 0, 0, NULL);
00061         return;
00062     }
00063
00064     // Open the profiling log.
00065     if ((hProfLog = CreateFile(LogFileName,
00066              GENERIC_WRITE,
00067              0,
00068              NULL,
00069              CREATE_ALWAYS,
00070              FILE_ATTRIBUTE_NORMAL,
00071              NULL)) == INVALID_HANDLE_VALUE) {
00072   RaiseException(GetLastError(), 0, 0, NULL);
00073         return;
00074     }
00075
00076     // Get the current time.
00077     if (QueryPerformanceCounter(&lpStartTime) == FALSE) {
00078   RaiseException(GetLastError(), 0, 0, NULL);
00079         return;
00080     }
00081
00082     // Get the frequency.
00083     if (QueryPerformanceFrequency(&lpFrequency) == FALSE) {
00084   RaiseException(GetLastError(), 0, 0, NULL);
00085         return;
00086     }
00087 }
00088
00089 VOID ProfRecordTime(UINT id, LPTSTR msg) {
00090     FLOAT dt;
00091
00092     if (WaitForSingleObject(hProfMutex, INFINITE) == WAIT_FAILED) {
00093   RaiseException(GetLastError(), 0, 0, NULL);
00094   return;
00095     }
00096
00097     // Write the entry only if there is enough space left in
00098     // the log.
00099     if (nProfLogSize < PROF_LOG_MAX_SIZE - (MAX_ENTRY_SIZE_NOMSG + _tcslen(msg))) {
00100   if (QueryPerformanceCounter(&lpCurrentTime) == FALSE) {
00101       RaiseException(GetLastError(), 0, 0, NULL);
00102       return;
00103   }
00104
00105   // Get the time stamp for the event.
00106   dt = (FLOAT)(lpCurrentTime.QuadPart - lpStartTime.QuadPart)/(FLOAT)(lpFrequency.QuadPart);
00107
00108   // Append the entry to the log.
00109   nProfLogSize+=_stprintf(&PROF_LOG[nProfLogSize], TEXT("%d %s %f\n"), id, msg, dt);
00110     }
00111
00112     if (ReleaseMutex(hProfMutex) == FALSE) {
00113   RaiseException(GetLastError(), 0, 0, NULL);
00114   return;
00115     }
00116 }
00117
00118 VOID ProfCloseLog(VOID) {
00119     ULONG cbWritten;
00120     DWORD status;
00121
00122     // Close the mutex.
00123     // Here we make the assumption that no outside functions will use
00124     // the mutex anymore.  This should be valid, since all the profiling data
00125     // has been written.
00126     status = CloseHandle(hProfMutex);
00127     ASSERTE(status);
00128
00129     // Write out the profile log.
00130     if(!WriteFile(hProfLog,
00131       (LPVOID)PROF_LOG,
00132       nProfLogSize*sizeof(TCHAR),
00133       &cbWritten,
00134       NULL)) {
00135
00136   RaiseException(GetLastError(), 0, 0, NULL);
00137   return;
00138     }
00139
00140     // Close the profile log.
00141     if (hProfLog != NULL && hProfLog != INVALID_HANDLE_VALUE) {
00142         status = CloseHandle(hProfLog);
00143         ASSERTE(status);
00144     }
00145 }
00146
00147 // end Prof.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/DsSrch/util.cxx Source File

  • NetDS
  • ADSI
  • samples
  • General
  • DsSrch

util.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 //
00003 //  ADSI 2.5 Sample Code - DsSrch
00004 //  Microsoft Windows
00005 //  Copyright (C) Microsoft Corporation, 1996 - 2000.
00006 //
00007 //  File:  util.cxx
00008 //
00009 //  Contents:  Ansi to Unicode conversions and misc helper functions
00010 //
00011 //----------------------------------------------------------------------------//------------------------------------------------------------------------------
00012
00013 #include "main.hxx"
00014
00015
00016
00017
00018 void
00019 PrintUsage(
00020     void
00021     )
00022 {
00023     printf("\nUsage: dssrch /b <baseObject> /f <search_filter> [/f <attrlist>] [/p <preference>=value>] ");
00024     printf(" [/u <UserName> <Password>] [/t <flagName>=<value> \n");
00025     printf("\n   where:\n" );
00026     printf("   baseObject     = ADsPath of the base of the search\n");
00027     printf("   search_filter  = search filter string in LDAP format\n" );
00028     printf("   attrlist       = list of the attributes to display\n" );
00029     printf("   preference could be one of:\n");
00030     printf("   Asynchronous, AttrTypesOnly, DerefAliases, SizeLimit, TimeLimit,\n");
00031     printf("   TimeOut, PageSize, SearchScope, SortOn, CacheResults\n");
00032     printf("   flagName could be one of:\n");
00033     printf("   SecureAuth or UseEncrypt\n");
00034     printf("   value is yes/no for a Boolean and the respective integer for integers\n");
00035     printf("   scope is one of \"Base\", \"OneLevel\", or \"Subtree\"\n");
00036
00037     printf("\nFor Example: dssrch /b NDS://ntmarst/ms /f \"(object Class=*)\" ");
00038     printf(" /a  \"ADsPath, name, description\" /p searchScope=onelevel /p searchscope=onelevel\n\n OR \n");
00039
00040
00041     printf("\n dssrch /b \"LDAP://test.mysite.com/");
00042     printf("OU=testOU,DC=test,DC=mysite,DC=com\"  /f \"(objectClass=*)\"  /a \"ADsPath, name, usnchanged\" ");
00043     printf(" /u \"CN=user1,CN=Users,DC=test,DC=mysite,DC=COM\" \"secret~1\" ");
00044     printf("/p searchScope=onelevel /t secureauth=yes /p SortOn=name /p CacheResults=no\n");
00045
00046 }
00047
00048
00049 //
00050 // Print the data depending on its type.
00051 //
00052
00053 void
00054 PrintColumn(
00055     PADS_SEARCH_COLUMN pColumn,
00056     LPWSTR pszColumnName
00057     )
00058 {
00059
00060     ULONG j, k;
00061
00062     if (!pColumn) {
00063         return;
00064     }
00065
00066     wprintf(
00067         L"%s = ",
00068         pszColumnName
00069         );
00070
00071     for (k=0; k < pColumn->dwNumValues; k++) {
00072         if (k > 0)
00073             wprintf(L"#  ");
00074
00075         switch(pColumn->dwADsType) {
00076         case ADSTYPE_DN_STRING         :
00077             wprintf(
00078                 L"%s  ",
00079                 (LPWSTR) pColumn->pADsValues[k].DNString
00080                 );
00081             break;
00082         case ADSTYPE_CASE_EXACT_STRING :
00083             wprintf(
00084                 L"%s  ",
00085                 (LPWSTR) pColumn->pADsValues[k].CaseExactString
00086                 );
00087             break;
00088         case ADSTYPE_CASE_IGNORE_STRING:
00089             wprintf(
00090                 L"%s  ",
00091                 (LPWSTR) pColumn->pADsValues[k].CaseIgnoreString
00092                 );
00093             break;
00094         case ADSTYPE_PRINTABLE_STRING  :
00095             wprintf(
00096                 L"%s  ",
00097                 (LPWSTR) pColumn->pADsValues[k].PrintableString
00098                 );
00099             break;
00100         case ADSTYPE_NUMERIC_STRING    :
00101             wprintf(
00102                 L"%s  ",
00103                 (LPWSTR) pColumn->pADsValues[k].NumericString
00104                 );
00105             break;
00106
00107         case ADSTYPE_OBJECT_CLASS    :
00108             wprintf(
00109                 L"%s  ",
00110                 (LPWSTR) pColumn->pADsValues[k].ClassName
00111                 );
00112             break;
00113
00114         case ADSTYPE_BOOLEAN           :
00115             wprintf(
00116                 L"%s  ",
00117                 (DWORD) pColumn->pADsValues[k].Boolean ?
00118                 L"TRUE" : L"FALSE"
00119                 );
00120             break;
00121
00122         case ADSTYPE_INTEGER           :
00123             wprintf(
00124                 L"%d  ",
00125                 (DWORD) pColumn->pADsValues[k].Integer
00126                 );
00127             break;
00128
00129         case ADSTYPE_OCTET_STRING      :
00130             for (j=0; j<pColumn->pADsValues[k].OctetString.dwLength; j++) {
00131                 printf(
00132                     "%02x",
00133                     ((BYTE *)pColumn->pADsValues[k].OctetString.lpValue)[j]
00134                     );
00135             }
00136             break;
00137
00138         case ADSTYPE_LARGE_INTEGER     :
00139             wprintf(
00140                 L"%I64d  ",
00141                 pColumn->pADsValues[k].LargeInteger
00142                 );
00143             break;
00144
00145         case ADSTYPE_UTC_TIME          :
00146             wprintf(
00147                 L"(date value) "
00148                 );
00149             break;
00150         case ADSTYPE_PROV_SPECIFIC     :
00151             wprintf(
00152                 L"(provider specific value) "
00153                 );
00154             break;
00155
00156         }
00157     }
00158
00159     printf("\n");
00160 }
00161
00162
00163 int
00164 AnsiToUnicodeString(
00165     LPSTR pAnsi,
00166     LPWSTR pUnicode,
00167     DWORD StringLength
00168     )
00169 {
00170     int iReturn;
00171
00172     if( StringLength == NULL_TERMINATED )
00173         StringLength = strlen( pAnsi );
00174
00175     iReturn = MultiByteToWideChar(CP_ACP,
00176                                   MB_PRECOMPOSED,
00177                                   pAnsi,
00178                                   StringLength + 1,
00179                                   pUnicode,
00180                                   StringLength + 1 );
00181
00182     //
00183     // Ensure NULL termination.
00184     //
00185     pUnicode[StringLength] = 0;
00186
00187     return iReturn;
00188 }
00189
00190 LPWSTR
00191 AllocateUnicodeString(
00192     LPSTR  pAnsiString
00193     )
00194 {
00195     LPWSTR  pUnicodeString = NULL;
00196
00197     if (!pAnsiString)
00198         return NULL;
00199
00200     pUnicodeString = (LPWSTR)LocalAlloc(
00201                         LPTR,
00202                         strlen(pAnsiString)*sizeof(WCHAR) +sizeof(WCHAR)
00203                         );
00204
00205     if (pUnicodeString) {
00206
00207         AnsiToUnicodeString(
00208             pAnsiString,
00209             pUnicodeString,
00210             NULL_TERMINATED
00211             );
00212     }
00213
00214     return pUnicodeString;
00215 }
00216
00217
00218 void
00219 FreeUnicodeString(
00220     LPWSTR  pUnicodeString
00221     )
00222 {
00223     if (!pUnicodeString)
00224         return;
00225
00226     LocalFree(pUnicodeString);
00227
00228     return;
00229 }
00230
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/TrayNot/App32.h Source File

  • WinUI
  • Shell
  • TrayNot

App32.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 //
00003 //---------------------------------------------------------------------------
00004 #define STRICT
00005
00006 #define _INC_OLE
00007 #include <windows.h>
00008 #undef  _INC_OLE
00009
00010 #ifndef WIN32
00011 #include <shell.h>
00012 #endif
00013
00014 extern HINSTANCE g_hinst;
00015
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/CrmFiles.Idl Source File

  • Com
  • Services
  • Crm
  • CrmFiles

CrmFiles.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmFiles.idl
00004
00005
00006 ----------------------------------------------------------------------------
00007
00008 This file is part of the Microsoft COM+ Samples.
00009
00010
00011
00012 Copyright (C) 1995-1998 Microsoft Corporation. All rights reserved.
00013
00014
00015
00016 This source code is intended only as a supplement to Microsoft
00017
00018 Development Tools and/or on-line documentation. See these other
00019
00020 materials for detailed information regarding Microsoft code samples.
00021
00022
00023
00024 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00025
00026 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00027
00028 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00029
00030 PARTICULAR PURPOSE.
00031
00032 ==========================================================================+*/
00033 // CrmFiles.idl : IDL source for CrmFiles.dll
00034 //
00035
00036 // This file will be processed by the MIDL tool to
00037 // produce the type library (CrmFiles.tlb) and marshalling code.
00038
00039 #include "..\idl\ICrmFiles.idl"
00040
00041 [
00042   uuid(43A7D826-B492-11D1-82F1-00A0C91EEDE9),
00043   version(1.0),
00044   helpstring("CrmFiles 1.0 Type Library")
00045 ]
00046 library CRMFILESLib
00047 {
00048   importlib("stdole32.tlb");
00049   importlib("stdole2.tlb");
00050
00051   [
00052     uuid(43A7D837-B492-11D1-82F1-00A0C91EEDE9),
00053     helpstring("CrmFilesWorker Class"),
00054     TRANSACTION_REQUIRED
00055   ]
00056   coclass CrmFilesWorker
00057   {
00058     [default] interface ICrmFilesWorker;
00059   };
00060   [
00061     uuid(43A7D839-B492-11D1-82F1-00A0C91EEDE9),
00062     helpstring("CrmFilesCompensator Class")
00063   ]
00064   coclass CrmFilesCompensator
00065   {
00066     [default] interface ICrmFilesCompensator;
00067   };
00068 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/LSP/overlap.cpp Source File

  • NetDS
  • WinSock
  • LSP

overlap.cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: overlap.cpp
00009 //
00010 // Description:
00011 //
00012 //    This module is responsible for handling the overlapped IO
00013 //    passed to us by the upper layer. If the LSP is on NT, then
00014 //    an IO completion port (IOCP) is created and all overlapped
00015 //    IO initiated by the upper layer passes through our IOCP.
00016 //    If this is Win9x then we create a worker thread and execute
00017 //    the overlapped IO via asynchronous procedure calls (APC).
00018 //
00019 #include "provider.h"
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023
00024 #define DEFAULT_POOL_COUNT  100         // Default number of OVERLAPPED
00025 #define MAX_PROC_COUNT      32          // Maximum number of worker threads
00026
00027 extern CRITICAL_SECTION    gOverlappedCS; // Protect access to the overlapped funcs
00028 extern HANDLE              hLspHeap;
00029
00030 //
00031 // For each overlapped operation given to us from the upper layer, we'll
00032 // assign a WSAOVERLAPPEDPLUS structure so that we can make the overlapped
00033 // call to the lower layer. The following variables are pointers to these
00034 // structures.
00035 //
00036 LPWSAOVERLAPPEDPLUS FreePool  = NULL,           // List of unused structures
00037                     PendingStart = NULL,        // List of pending ops - start
00038                     PendingEnd  = NULL,         // List of pending ops - end
00039                     OverlappedPool = NULL;      // Entire list of structures
00040
00041 HANDLE              gWorkerThread[MAX_PROC_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL,
00042                                                      NULL, NULL, NULL, NULL, NULL, NULL,
00043                                                      NULL, NULL, NULL, NULL, NULL, NULL,
00044                                                      NULL, NULL, NULL, NULL, NULL, NULL,
00045                                                      NULL, NULL, NULL, NULL, NULL, NULL,
00046                                                      NULL, NULL},
00047                     ghWakeupSemaphore = NULL,   // Wakeup semaphore
00048                     ghIocp = NULL;              // Handle to the IOCP
00049 DWORD               gdwThreadCount = -1;        // Number of worker threads
00050
00051 //
00052 // Extenion function pointers declared in extension.cpp
00053 //  These functions are loaded only when the caller calls them.
00054 //
00055 static TCHAR Msg[512];
00056
00057 //
00058 // Function prototypes
00059 //
00060 int   ExecuteOverlappedOperation(WSAOVERLAPPEDPLUS *lpOverlapped, BOOL bSynchronous);
00061 int   EnqueueOverlappedOperation(WSAOVERLAPPEDPLUS *op);
00062 void  SetOverlappedInProgress(OVERLAPPED *ol);
00063 void  PutbackOverlappedStructure(WSAOVERLAPPEDPLUS *olp);
00064 DWORD WINAPI   OverlappedManagerThread(LPVOID lpParam);
00065 VOID  CALLBACK CallUserApcProc(ULONG_PTR Context);
00066 void  CheckForContextCleanup(WSAOVERLAPPEDPLUS *ol);
00067
00068
00069 //
00070 // Function: AllocateFreePool
00071 //
00072 // Description:
00073 //    Allocate a block of WSAOVERLAPPEDPLUS structures which will be cached
00074 //    for easy lookup since they will be frequently used.
00075 //
00076 int AllocateFreePool()
00077 {
00078     DWORD     i;
00079
00080     //
00081     // Allocate our overlapped structures as well as zeroes it out
00082     //
00083     OverlappedPool = (LPWSAOVERLAPPEDPLUS)HeapAlloc(
00084                         hLspHeap,
00085                         HEAP_ZERO_MEMORY,
00086                         sizeof(WSAOVERLAPPEDPLUS) * DEFAULT_POOL_COUNT);
00087
00088     if (!OverlappedPool)
00089     {
00090         dbgprint("out of memory!");
00091         return WSAENOBUFS;
00092     }
00093     // Initialize our overlapped structures
00094     //
00095     for(i=0; i < DEFAULT_POOL_COUNT-1 ;i++)
00096     {
00097         OverlappedPool[i].next = &OverlappedPool[i+1];
00098     }
00099     FreePool  = &OverlappedPool[0];
00100
00101     return NO_ERROR;
00102 }
00103
00104 //
00105 // Function: InitOverlappedManager
00106 //
00107 // Description:
00108 //    This function is called once and determines whether we're running
00109 //    on NT or Win9x. If on NT, create an IO completion port as the
00110 //    intermediary between the upper and lower layer. All overlapped IO
00111 //    will be posted using this IOCP. When IOCP are available we'll create
00112 //    a number of threads (equal to the number of procs) to service the
00113 //    completion of the IO. If on Win9x, we'll create a single thread which
00114 //    will post overlapped IO operations using APCs.
00115 //
00116 int InitOverlappedManager()
00117 {
00118     DWORD   dwId,
00119             i;
00120
00121     EnterCriticalSection(&gOverlappedCS);
00122
00123     // Make sure we're not already initialized -- we'll always have at least
00124     // one worker thread running
00125     if (gWorkerThread[0] != NULL)
00126     {
00127         LeaveCriticalSection(&gOverlappedCS);
00128         return 0;
00129     }
00130
00131     // Allocate a block of our overlapped structures
00132     if (AllocateFreePool() == WSAENOBUFS)
00133     {
00134         LeaveCriticalSection(&gOverlappedCS);
00135         return WSAENOBUFS;
00136     }
00137
00138     //
00139     // See if we're on NT by trying to create the completion port. If it
00140     //  fails then we're on Win9x.
00141     //
00142     ghIocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
00143                                     NULL,
00144                                     (ULONG_PTR)0,
00145                                     0);
00146     if (ghIocp)
00147     {
00148         SYSTEM_INFO     sinfo;
00149
00150         // We're on NT so figure out how many processors we have
00151         //
00152         GetSystemInfo(&sinfo);
00153         gdwThreadCount = sinfo.dwNumberOfProcessors;
00154
00155         #ifdef DEBUG
00156         dbgprint("Created IOCP: %d", ghIocp);
00157         #endif
00158     }
00159     else
00160     {
00161         //
00162         // We're on Win9x so create a semaphore instead. This is used to
00163         //  wake up the worker thread to service overlapped IO calls.
00164         //
00165         ghWakeupSemaphore = CreateSemaphore(NULL,
00166                                             0,
00167                                             MAXLONG,
00168                                             NULL);
00169         if (!ghWakeupSemaphore)
00170         {
00171             dbgprint("InitOverlappedManager: CreateSemaphore() failed: %d", GetLastError());
00172             LeaveCriticalSection(&gOverlappedCS);
00173             return WSAEPROVIDERFAILEDINIT;
00174         }
00175         // This is Win9x, no multiproc support
00176         //
00177         gdwThreadCount = 1;
00178     }
00179
00180     #ifdef DEBUG
00181     dbgprint("Creating %d threads", gdwThreadCount);
00182     #endif
00183     //
00184     // Create our worker threads
00185     //
00186     for(i=0; i < gdwThreadCount ;i++)
00187     {
00188         gWorkerThread[i] = CreateThread(NULL, 0, OverlappedManagerThread, (LPVOID)ghIocp, 0, &dwId);
00189         if (!gWorkerThread[i])
00190         {
00191             dbgprint("InitOverlappedManager: CreateThread() failed: %d", GetLastError());
00192             LeaveCriticalSection(&gOverlappedCS);
00193             return WSAEPROVIDERFAILEDINIT;
00194         }
00195     }
00196     LeaveCriticalSection(&gOverlappedCS);
00197     return 0;
00198 }
00199
00200 //
00201 // Function: StopOverlappedManager
00202 //
00203 // Description:
00204 //    This function is called before the DLL gets unloaded. It tries to
00205 //    shutdown the worker threads gracefully before exiting. It also
00206 //    frees/closes allocated memory and handles.
00207 //
00208 int StopOverlappedManager()
00209 {
00210     DWORD     i;
00211     int       ret;
00212
00213
00214     EnterCriticalSection(&gOverlappedCS);
00215     //
00216     // Post a completion packet to the IOCP (one for each thread)
00217     //
00218     if (ghIocp)
00219     {
00220         for(i=0; i < gdwThreadCount ;i++)
00221         {
00222             ret = PostQueuedCompletionStatus(ghIocp,
00223                                         -1,
00224                                          0,
00225                                          NULL);
00226             if (ret == 0)
00227             {
00228                 dbgprint("PostQueuedCompletionStatus() failed: %d", GetLastError());
00229             }
00230         }
00231         // Wait a while for the threads to get the signal and exit - if it fails or
00232         // times out then oh well, we need to clean up anyway
00233         ret = WaitForMultipleObjectsEx(gdwThreadCount, gWorkerThread, TRUE, 4000, TRUE);
00234     }
00235
00236     for(i=0; i < gdwThreadCount ;i++)
00237     {
00238         CloseHandle(gWorkerThread[i]);
00239         gWorkerThread[i] = NULL;
00240
00241         dbgprint("Closing thread");
00242     }
00243
00244     // Cleanup remaining handles...
00245
00246     if (ghIocp != NULL)
00247     {
00248         CloseHandle(ghIocp);
00249         ghIocp = NULL;
00250         dbgprint("Closing iocp");
00251     }
00252     if (ghWakeupSemaphore != NULL)
00253     {
00254         CloseHandle(ghWakeupSemaphore);
00255         ghWakeupSemaphore = NULL;
00256     }
00257
00258     LeaveCriticalSection(&gOverlappedCS);
00259
00260     return 0;
00261 }
00262
00263 //
00264 // Function: QueueOverlappedOperation
00265 //
00266 // Description:
00267 //    Whenever one of the overlapped enabled Winsock SPI functions are
00268 //    called (as an overlapped operation), it calls this function which
00269 //    determines whether it can execute it immediate (in the case of NT
00270 //    and IOCP) or post it to a queue to be executed by the woker thread
00271 //    via an APC (on Win9x).
00272 //
00273 int QueueOverlappedOperation(WSAOVERLAPPEDPLUS *ol, SOCK_INFO *SocketContext)
00274 {
00275     BOOL    bSynchronous=FALSE;
00276     int     err;
00277
00278     // Set the fields of the overlapped to indicate IO is not complete yet
00279     //
00280     SetOverlappedInProgress(ol->lpCallerOverlapped);
00281     if (ghIocp)
00282     {
00283         // If we haven't already added the provider socket to the IOCP then
00284         //  do it now.
00285         //
00286         AcquireSocketLock(SocketContext);
00287         if (!SocketContext->hIocp)
00288         {
00289             SocketContext->hIocp = CreateIoCompletionPort((HANDLE)ol->ProviderSocket,
00290                                                           ghIocp,
00291                                                           ol->CallerSocket,
00292                                                           0);
00293             if (SocketContext->hIocp == NULL)
00294             {
00295                 if ((err = GetLastError()) == ERROR_INVALID_PARAMETER)
00296                 {
00297                     // Hack-o-rama. If the socket option SO_SYNCHRONOUS_(NON)ALERT
00298                     // is set then no overlapped operation can be performed on that
00299                     // socket and tryiing to associate it with a completion port
00300                     // will fail. The other bad news is that an LSP cannot trap this
00301                     // setsockopt call. In reality we don't have to do anything. If
00302                     // an app sets this option and then makes overlapped calls anyway,
00303                     // then they shouldn't be expecting any overlapped notifications!
00304                     // This statement is put here in case you want to mark the socket
00305                     // info structure as synchronous.
00306                     //
00307                     bSynchronous = TRUE;
00308                 }
00309                 else
00310                 {
00311                     dbgprint("QueueOverlappedOperation: CreateIoCompletionPort() "
00312                               "failed: %d (Prov %d Iocp %d Caller %d 0)",
00313                             err, ol->ProviderSocket,
00314                             ghIocp, ol->CallerSocket);
00315                 }
00316             }
00317
00318             #ifdef DEBUG
00319             dbgprint("Adding provider handle %X to IOCP", ol->ProviderSocket);
00320             #endif
00321         }
00322         ReleaseSocketLock(SocketContext);
00323         //
00324         // Simply execute the operation
00325         //
00326         return ExecuteOverlappedOperation(ol, bSynchronous);
00327     }
00328     else
00329     {
00330         // Queue up the operation for the worker thread to initiate
00331         //
00332         return EnqueueOverlappedOperation(ol);
00333     }
00334 }
00335
00336 //
00337 // Function: EnqueueOverlappedOperation
00338 //
00339 // Description:
00340 //    Enqueue an overlapped operation to be executed by the worker
00341 //    thread via an APC.
00342 //
00343 int EnqueueOverlappedOperation(WSAOVERLAPPEDPLUS *op)
00344 {
00345     EnterCriticalSection(&gOverlappedCS);
00346
00347     if (op == NULL)
00348     {
00349         dbgprint("EnqueueOverlappedOperation: op == NULL!");
00350         LeaveCriticalSection(&gOverlappedCS);
00351         return WSAEFAULT;
00352     }
00353
00354     op->next = NULL;
00355     if (!PendingEnd)
00356     {
00357         PendingStart = op;
00358         PendingEnd   = op;
00359     }
00360     else
00361     {
00362         PendingEnd->next = op;
00363         PendingEnd       = op;
00364     }
00365     // Increment the semaphore count. This lets the worker thread
00366     // know that there are pending overlapped operations to execute.
00367     //
00368     ReleaseSemaphore(ghWakeupSemaphore, 1, NULL);
00369
00370     LeaveCriticalSection(&gOverlappedCS);
00371
00372     return WSA_IO_PENDING;
00373 }
00374
00375 //
00376 // Function: DequeueOverlappedOperation
00377 //
00378 // Description:
00379 //    Once the worker thread is notified that there are pending
00380 //    operations, it calls this function to get the first operation
00381 //    pending in order to execute it.
00382 //
00383 WSAOVERLAPPEDPLUS *DequeueOverlappedOperation()
00384 {
00385     WSAOVERLAPPEDPLUS *op=NULL;
00386
00387     EnterCriticalSection(&gOverlappedCS);
00388
00389     op = PendingStart;
00390     if (PendingStart)
00391     {
00392         PendingStart = op->next;
00393     }
00394     if (op == PendingEnd)
00395     {
00396         PendingStart = PendingEnd = NULL;
00397     }
00398
00399     LeaveCriticalSection(&gOverlappedCS);
00400
00401     return op;
00402 }
00403
00404 //
00405 // Function: ExecuteOverlappedOperation
00406 //
00407 // Description:
00408 //    This function actually executes an overlapped operation that was queued.
00409 //    If on Win9x we substitute our own completion function in order to intercept
00410 //    the results. If on NT we post the operation to our completion port.
00411 //    This function either returns NO_ERROR if the operation succeeds immediately
00412 //    or the Winsock error code upone failure (or overlapped operation).
00413 //
00414 int ExecuteOverlappedOperation(WSAOVERLAPPEDPLUS *ol, BOOL bSynchronous)
00415 {
00416     LPWSAOVERLAPPED_COMPLETION_ROUTINE   routine = NULL;
00417     PROVIDER                            *Provider;
00418     OVERLAPPED                          *col = NULL;
00419     DWORD                               *lpdwFlags = NULL,
00420                                         *lpdwBytes = NULL;
00421     int                                  ret=SOCKET_ERROR, err=0;
00422
00423     if (!ghIocp)
00424         routine = IntermediateCompletionRoutine;
00425
00426     Provider = ol->Provider;
00427     //
00428     // Reset the event handle if present. The handle is masked with 0xFFFFFFFE in
00429     //  order to zero out the last bit. If the last bit is one and the socket is
00430     //  associated with a compeltion port then when an overlapped operation is
00431     //  called, the operation is not posted to the IO completion port.
00432     //
00433     if (ol->lpCallerOverlapped->hEvent != NULL)
00434     {
00435         ULONG_PTR   ptr=1;
00436
00437         ResetEvent((HANDLE)((ULONG_PTR)ol->lpCallerOverlapped->hEvent & ~ptr));
00438     }
00439
00440     switch (ol->Operation)
00441     {
00442         case LSP_OP_IOCTL:
00443             lpdwFlags = NULL;
00444             lpdwBytes = &ol->IoctlArgs.cbBytesReturned;
00445             ret = Provider->NextProcTable.lpWSPIoctl(
00446                     ol->ProviderSocket,
00447                     ol->IoctlArgs.dwIoControlCode,
00448                     ol->IoctlArgs.lpvInBuffer,
00449                     ol->IoctlArgs.cbInBuffer,
00450                     ol->IoctlArgs.lpvOutBuffer,
00451                     ol->IoctlArgs.cbOutBuffer,
00452                    &ol->IoctlArgs.cbBytesReturned,
00453                    &ol->ProviderOverlapped,
00454                     routine,
00455                    &ol->CallerThreadId,
00456                    &err
00457                    );
00458             break;
00459         case LSP_OP_RECV:
00460             lpdwFlags = &ol->RecvArgs.dwFlags;
00461             lpdwBytes = &ol->RecvArgs.dwNumberOfBytesRecvd;
00462             ret = Provider->NextProcTable.lpWSPRecv(
00463                     ol->ProviderSocket,
00464                     ol->RecvArgs.lpBuffers,
00465                     ol->RecvArgs.dwBufferCount,
00466                    &ol->RecvArgs.dwNumberOfBytesRecvd,
00467                    &ol->RecvArgs.dwFlags,
00468                    &ol->ProviderOverlapped,
00469                     routine,
00470                    &ol->CallerThreadId,
00471                    &err
00472                     );
00473             break;
00474         case LSP_OP_RECVFROM:
00475             lpdwFlags = &ol->RecvFromArgs.dwFlags;
00476             lpdwBytes = &ol->RecvFromArgs.dwNumberOfBytesRecvd;
00477             ret = Provider->NextProcTable.lpWSPRecvFrom(
00478                     ol->ProviderSocket,
00479                     ol->RecvFromArgs.lpBuffers,
00480                     ol->RecvFromArgs.dwBufferCount,
00481                    &ol->RecvFromArgs.dwNumberOfBytesRecvd,
00482                    &ol->RecvFromArgs.dwFlags,
00483                     ol->RecvFromArgs.lpFrom,
00484                     ol->RecvFromArgs.lpFromLen,
00485                    &ol->ProviderOverlapped,
00486                     routine,
00487                    &ol->CallerThreadId,
00488                    &err
00489                     );
00490             break;
00491         case LSP_OP_SEND:
00492             lpdwFlags = &ol->SendArgs.dwFlags;
00493             lpdwBytes = &ol->SendArgs.dwNumberOfBytesSent;
00494             ret = Provider->NextProcTable.lpWSPSend(
00495                     ol->ProviderSocket,
00496                     ol->SendArgs.lpBuffers,
00497                     ol->SendArgs.dwBufferCount,
00498                    &ol->SendArgs.dwNumberOfBytesSent,
00499                     ol->SendArgs.dwFlags,
00500                    &ol->ProviderOverlapped,
00501                     routine,
00502                    &ol->CallerThreadId,
00503                    &err
00504                    );
00505              break;
00506         case LSP_OP_SENDTO:
00507             lpdwFlags = &ol->SendToArgs.dwFlags;
00508             lpdwBytes = &ol->SendToArgs.dwNumberOfBytesSent;
00509             ret = Provider->NextProcTable.lpWSPSendTo(
00510                     ol->ProviderSocket,
00511                     ol->SendToArgs.lpBuffers,
00512                     ol->SendToArgs.dwBufferCount,
00513                    &ol->SendToArgs.dwNumberOfBytesSent,
00514                     ol->SendToArgs.dwFlags,
00515                     (SOCKADDR *)&ol->SendToArgs.To,
00516                     ol->SendToArgs.iToLen,
00517                    &ol->ProviderOverlapped,
00518                     routine,
00519                    &ol->CallerThreadId,
00520                    &err
00521                     );
00522             break;
00523         case LSP_OP_TRANSMITFILE:
00524             lpdwFlags = &ol->TransmitFileArgs.dwFlags;
00525             lpdwBytes = NULL;
00526             ret = Provider->NextProcTableExt.lpfnTransmitFile(
00527                     ol->ProviderSocket,
00528                     ol->TransmitFileArgs.hFile,
00529                     ol->TransmitFileArgs.nNumberOfBytesToWrite,
00530                     ol->TransmitFileArgs.nNumberOfBytesPerSend,
00531                    &ol->ProviderOverlapped,
00532                     ol->TransmitFileArgs.lpTransmitBuffers,
00533                     ol->TransmitFileArgs.dwFlags
00534                     );
00535             if (ret == FALSE)
00536             {
00537                 ret = SOCKET_ERROR;
00538                 err = WSAGetLastError();
00539                 WSASetLastError(err);
00540             }
00541             else
00542                 ret = NO_ERROR;
00543             break;
00544         case LSP_OP_ACCEPTEX:
00545             lpdwFlags = NULL;
00546             lpdwBytes = &ol->AcceptExArgs.dwBytesReceived;
00547             ret = Provider->NextProcTableExt.lpfnAcceptEx(
00548                     ol->ProviderSocket,
00549                     ol->AcceptExArgs.sProviderAcceptSocket,
00550                     ol->AcceptExArgs.lpOutputBuffer,
00551                     ol->AcceptExArgs.dwReceiveDataLength,
00552                     ol->AcceptExArgs.dwLocalAddressLength,
00553                     ol->AcceptExArgs.dwRemoteAddressLength,
00554                    &ol->AcceptExArgs.dwBytesReceived,
00555                    &ol->ProviderOverlapped
00556                     );
00557             if (ret == FALSE)
00558             {
00559                 ret = SOCKET_ERROR;
00560                 err = WSAGetLastError();
00561                 WSASetLastError(err);
00562             }
00563             else
00564                 ret = NO_ERROR;
00565             break;
00566         case LSP_OP_CONNECTEX:
00567             lpdwFlags = NULL;
00568             lpdwBytes = &ol->ConnectExArgs.dwBytesSent;
00569             ret = Provider->NextProcTableExt.lpfnConnectEx(
00570                     ol->ProviderSocket,
00571                     (SOCKADDR *)&ol->ConnectExArgs.name,
00572                     ol->ConnectExArgs.namelen,
00573                     ol->ConnectExArgs.lpSendBuffer,
00574                     ol->ConnectExArgs.dwSendDataLength,
00575                    &ol->ConnectExArgs.dwBytesSent,
00576                    &ol->ProviderOverlapped
00577                     );
00578             if (ret == FALSE)
00579             {
00580                 ret = SOCKET_ERROR;
00581                 err = WSAGetLastError();
00582                 WSASetLastError(err);
00583             }
00584             else
00585                 ret = NO_ERROR;
00586             break;
00587         case LSP_OP_DISCONNECTEX:
00588             lpdwFlags = &ol->DisconnectExArgs.dwFlags;
00589             lpdwBytes = NULL;
00590             ret = Provider->NextProcTableExt.lpfnDisconnectEx(
00591                     ol->ProviderSocket,
00592                    &ol->ProviderOverlapped,
00593                     ol->DisconnectExArgs.dwFlags,
00594                     ol->DisconnectExArgs.dwReserved
00595                     );
00596             if (ret == FALSE)
00597             {
00598                 ret = SOCKET_ERROR;
00599                 err = WSAGetLastError();
00600                 WSASetLastError(err);
00601             }
00602             else
00603                 ret = NO_ERROR;
00604             break;
00605         case LSP_OP_TRANSMITPACKETS:
00606             lpdwFlags = &ol->TransmitPacketsArgs.dwFlags;
00607             lpdwBytes = NULL;
00608             ret = Provider->NextProcTableExt.lpfnTransmitPackets(
00609                     ol->ProviderSocket,
00610                     ol->TransmitPacketsArgs.lpPacketArray,
00611                     ol->TransmitPacketsArgs.nElementCount,
00612                     ol->TransmitPacketsArgs.nSendSize,
00613                    &ol->ProviderOverlapped,
00614                     ol->TransmitPacketsArgs.dwFlags
00615                     );
00616             if (ret == FALSE)
00617             {
00618                 ret = SOCKET_ERROR;
00619                 err = WSAGetLastError();
00620                 WSASetLastError(err);
00621             }
00622             else
00623                 ret = NO_ERROR;
00624             break;
00625         case LSP_OP_WSARECVMSG:
00626             lpdwFlags = NULL;
00627             lpdwBytes = &ol->WSARecvMsgArgs.dwNumberOfBytesRecvd;
00628             ret = Provider->NextProcTableExt.lpfnWSARecvMsg(
00629                     ol->ProviderSocket,
00630                     ol->WSARecvMsgArgs.lpMsg,
00631                    &ol->WSARecvMsgArgs.dwNumberOfBytesRecvd,
00632                    &ol->ProviderOverlapped,
00633                     ol->lpCallerCompletionRoutine
00634                     );
00635             if (ret == FALSE)
00636             {
00637                 ret = SOCKET_ERROR;
00638                 err = WSAGetLastError();
00639                 WSASetLastError(err);
00640             }
00641             else
00642                 ret = NO_ERROR;
00643             break;
00644         default:
00645             dbgprint("ExecuteOverlappedOperation: Unknown operation!");
00646             ret = SOCKET_ERROR;
00647             break;
00648     }
00649
00650     if ((ret != NO_ERROR) && (err != WSA_IO_PENDING))
00651     {
00652         //
00653         // If the call immediately fails, update the OVERLAPPED info and return
00654         //
00655         ol->lpCallerOverlapped->Offset       = err;
00656         ol->lpCallerOverlapped->OffsetHigh   = (lpdwFlags ? *lpdwFlags : 0);
00657         ol->lpCallerOverlapped->InternalHigh = (lpdwBytes ? *lpdwBytes : 0);
00658         ol->lpCallerOverlapped->Internal     = 0;
00659
00660         #ifdef DEBUG
00661         dbgprint("Overlap op failed immediately: %d", ol->Error);
00662         #endif
00663
00664         CheckForContextCleanup(ol);
00665
00666         PutbackOverlappedStructure(ol);
00667     }
00668     else if ((ret == NO_ERROR) && (bSynchronous == FALSE))
00669     {
00670         //
00671         // Ideally we'd like to complete immediately here but we should wait
00672         // until the completion port has processed the completion packet
00673         // associated with this operation.
00674         //
00675         err = WSA_IO_PENDING;
00676         ret = SOCKET_ERROR;
00677
00678         #ifdef DEBUG
00679         dbgprint("Succeeded without error");
00680         #endif
00681     }
00682     else if ((ret == NO_ERROR) && (bSynchronous == TRUE))
00683     {
00684         // The winsock call actually blocked and there will be no completion
00685         // notification on the IOCP.
00686         //
00687         #ifdef DEBUG
00688         dbgprint("Succeeded without error - synchronous socket though");
00689         #endif
00690     }
00691     #ifdef DEBUG
00692     else
00693     {
00694         dbgprint("WSA_IO_PENDING");
00695     }
00696     #endif
00697
00698     return ((ret == NO_ERROR) ? ret : err);
00699 }
00700
00701 //
00702 // Function: OverlappedManagerThread
00703 //
00704 // Description:
00705 //    This thread receives the completion notifications for operations
00706 //    posted to our IO completion port. Once we receive a completion
00707 //    we'll complete the operation back to the calling app.
00708 //
00709 DWORD WINAPI OverlappedManagerThread(LPVOID lpParam)
00710 {
00711     WSAOVERLAPPEDPLUS *lpPid = NULL;
00712     HANDLE             hIocp = (HANDLE)lpParam;
00713     ULONG_PTR          key;
00714     DWORD              dwBytesXfered;
00715     int                ret;
00716
00717     while (1)
00718     {
00719         if (hIocp)
00720         {
00721             ret = GetQueuedCompletionStatus(hIocp,
00722                     &dwBytesXfered,
00723                     &key,
00724                     (LPOVERLAPPED *)&lpPid,
00725                     INFINITE);
00726             if ((ret == 0) || (ret == WAIT_TIMEOUT))
00727             {
00728                 // Socket failures could be reported here so we still
00729                 // call IntermediateCompletionRoutine
00730                 dbgprint("GetQueuedCompletionStatus() failed: %d", GetLastError());
00731             }
00732             if (dwBytesXfered == -1)
00733             {
00734                 // StopOverlappedManager will send a completion packet with -1
00735                 //    bytes transfered to indicate the completion routine
00736                 //    should exit
00737                 dbgprint("OverlappedManagerThread: Received exit message");
00738                 ExitThread(0);
00739             }
00740
00741             // Handle the IO that completed
00742             IntermediateCompletionRoutine(WSA_IO_PENDING,
00743                     dwBytesXfered,
00744                     (OVERLAPPED *)lpPid,
00745                     0);
00746         }
00747         else
00748         {
00749             ret = WaitForSingleObjectEx(ghWakeupSemaphore,
00750                     INFINITE,
00751                     TRUE);
00752             if ((ret == WAIT_FAILED) || (ret == WAIT_TIMEOUT))
00753             {
00754                 dbgprint("OverlappedManagerThread: WaitForSingleObjectEx() failed: %d",
00755                         GetLastError());
00756             }
00757             else
00758             {
00759                 lpPid = DequeueOverlappedOperation();
00760
00761                 if (!lpPid)
00762                     continue;
00763
00764                 ExecuteOverlappedOperation(lpPid, FALSE);
00765             }
00766         }
00767     }
00768     ExitThread(0);
00769     return 0;
00770 }
00771
00772 //
00773 // Function: StartOverlappedManager
00774 //
00775 // Description:
00776 //    Initializes the overlapped manager by creating worker thread(s),
00777 //    creating the completion port, etc.
00778 //
00779 void StartOverlappedManager()
00780 {
00781     //
00782     // Make sure things are already initalized
00783     //
00784     if (!gWorkerThread[0])
00785     {
00786         InitOverlappedManager();
00787
00788         if (!gWorkerThread[0])
00789         {
00790             dbgprint("GetOverlappedStructure: Still not properly inititalized!");
00791             return;
00792         }
00793     }
00794 }
00795
00796 //
00797 // Function: GetOverlappedStructure
00798 //
00799 // Description:
00800 //    This returns an unused WSAOVERLAPPEDPLUS structure. We maintain a list
00801 //    of freed structures so that we don't spend too much time allocating and
00802 //    freeing memory.
00803 //
00804 LPWSAOVERLAPPEDPLUS GetOverlappedStructure(SOCK_INFO *SocketContext)
00805 {
00806     LPWSAOVERLAPPEDPLUS lpWorkerOverlappedPlus = NULL;
00807
00808     if (!SocketContext)
00809     {
00810         dbgprint("GetOverlappedStructure: SocketContext == NULL");
00811         return NULL;
00812     }
00813
00814     AcquireSocketLock(SocketContext);
00815
00816     EnterCriticalSection(&gOverlappedCS);
00817     //
00818     // We have to keep track of the number of outstanding overlapped requests
00819     // an application has. Otherwise, if the app were to close a socket that
00820     // had oustanding overlapped ops remaining, we'd start leaking structures
00821     // in OverlappedPool. The idea here is to force the CallerSocket to remain
00822     // open until the lower provider has processed all the overlapped requests.
00823     // If we closed both the lower socket and the caller socket, we would no
00824     // longer be able to correlate completed requests to any apps sockets.
00825     //
00826     (SocketContext->dwOutstandingAsync)++;
00827
00828     if (FreePool)
00829     {
00830         lpWorkerOverlappedPlus = FreePool;
00831         FreePool = FreePool->next;
00832         lpWorkerOverlappedPlus->next = NULL;
00833     }
00834     else // Empty pool
00835     {
00836         if (AllocateFreePool() != WSAENOBUFS)
00837         {
00838             lpWorkerOverlappedPlus = FreePool;
00839             FreePool = FreePool->next;
00840             lpWorkerOverlappedPlus->next = NULL;
00841         }
00842     }
00843     if (lpWorkerOverlappedPlus)
00844         memset(lpWorkerOverlappedPlus, 0, sizeof(WSAOVERLAPPEDPLUS));
00845
00846     LeaveCriticalSection(&gOverlappedCS);
00847
00848     ReleaseSocketLock(SocketContext);
00849
00850     return  lpWorkerOverlappedPlus;
00851 }
00852
00853 //
00854 // Function: PutbackOverlappedStructure
00855 //
00856 // Description:
00857 //    Once we're done using a WSAOVERLAPPEDPLUS structure we return it to
00858 //    a list of free structures for re-use later.
00859 //
00860 void PutbackOverlappedStructure(WSAOVERLAPPEDPLUS *olp)
00861 {
00862     EnterCriticalSection(&gOverlappedCS);
00863
00864     memset(olp, 0, sizeof(WSAOVERLAPPEDPLUS));
00865
00866     //HeapFree(hLspHeap, 0, olp);
00867
00868     olp->CallerThreadId.ThreadHandle = (HANDLE)0xbadbeef;
00869
00870     olp->next = FreePool;
00871     FreePool = olp;
00872
00873     LeaveCriticalSection(&gOverlappedCS);
00874 }
00875
00876 //
00877 // Function: SetOverlappedInProgress
00878 //
00879 // Description:
00880 //    Simply set the interal fields of an OVERLAPPED structure to the
00881 //    "in progress" state.
00882 //
00883 void SetOverlappedInProgress(OVERLAPPED *ol)
00884 {
00885     ol->Internal = WSS_OPERATION_IN_PROGRESS;
00886     ol->InternalHigh = 0;
00887 }
00888
00889 //
00890 // Function: IntermediateCompletionRoutine
00891 //
00892 // Description:
00893 //    Once an overlapped operation completes we call this routine to keep
00894 //    count of the bytes sent/received as well as to complete the operation
00895 //    to the application.
00896 //
00897 void CALLBACK IntermediateCompletionRoutine(DWORD dwError,
00898                                             DWORD cbTransferred,
00899                                             LPWSAOVERLAPPED lpOverlapped,
00900                                             DWORD dwFlags)
00901 {
00902     LPWSAOVERLAPPEDPLUS olp = (LPWSAOVERLAPPEDPLUS) lpOverlapped;
00903     SOCK_INFO          *SocketContext,
00904                        *AcceptSocketContext;
00905     int                 Error,
00906                         ret;
00907
00908     if (lpOverlapped == NULL)
00909     {
00910         dbgprint("IntermediateCompletionRoutine: lpOverlapped == NULL!");
00911         return;
00912     }
00913     //
00914     // We actually already have the socket context for this operation (its in
00915     //    the WSAOVERLAPPEDPLUS structure but do this anyway to make sure the
00916     //    socket hasn't been closed as well as to increment the ref count while
00917     //    we're accessing the SOCK_INFO structure.
00918     //
00919     SocketContext = FindAndLockSocketContext(olp->CallerSocket, &Error);
00920     if (SocketContext == NULL)
00921     {
00922         dbgprint("IntermediateCompletionRoutine: WPUQuerySocketHandleContext failed: %d", Error);
00923         PutbackOverlappedStructure(olp);
00924         return;
00925     }
00926
00927     if (dwError == WSA_IO_PENDING)
00928     {
00929         //
00930         // Get the results of the operation
00931         //
00932         dwError = NO_ERROR;
00933         ret = olp->Provider->NextProcTable.lpWSPGetOverlappedResult(olp->ProviderSocket,
00934                                                      lpOverlapped,
00935                                                     &cbTransferred,
00936                                                      FALSE,
00937                                                     &dwFlags,
00938                                                     (int *)&dwError);
00939         if (ret == FALSE)
00940         {
00941             dbgprint("IntermediateCompletionRoutine: WSPGetOverlappedResult failed: %d", dwError);
00942         }
00943
00944         #ifdef DEBUG
00945         dbgprint("Bytes transferred on socket %d: %d [op=%d; err=%d]",
00946                 olp->CallerSocket, cbTransferred, olp->Operation, dwError);
00947         #endif
00948     }
00949
00950     olp->lpCallerOverlapped->Offset       = dwError;
00951     olp->lpCallerOverlapped->OffsetHigh   = dwFlags;
00952     olp->lpCallerOverlapped->InternalHigh = cbTransferred;
00953
00954     if (dwError == 0)
00955     {
00956         AcquireSocketLock(SocketContext);
00957         switch (olp->Operation)
00958         {
00959             case LSP_OP_RECV:
00960                 SocketContext->BytesRecv += cbTransferred;
00961                 FreeBuffer(olp->RecvArgs.lpBuffers);
00962                 break;
00963             case LSP_OP_RECVFROM:
00964                 SocketContext->BytesRecv += cbTransferred;
00965                 FreeBuffer(olp->RecvFromArgs.lpBuffers);
00966                 break;
00967             case LSP_OP_SEND:
00968                 SocketContext->BytesSent += cbTransferred;
00969                 FreeBuffer(olp->SendArgs.lpBuffers);
00970                 break;
00971             case LSP_OP_SENDTO:
00972                 SocketContext->BytesSent += cbTransferred;
00973                 FreeBuffer(olp->SendToArgs.lpBuffers);
00974                 break;
00975             case LSP_OP_TRANSMITFILE:
00976                 SocketContext->BytesSent += cbTransferred;
00977                 break;
00978             case LSP_OP_TRANSMITPACKETS:
00979                 break;
00980             case LSP_OP_ACCEPTEX:
00981                 AcceptSocketContext = FindAndLockSocketContext(
00982                         olp->AcceptExArgs.sAcceptSocket,
00983                        &Error
00984                        );
00985                 if (AcceptSocketContext == NULL)
00986                 {
00987                     dbgprint("IntermediateCompletionRoutine: WPUQuerySocketHandleContext failed (accept socket)");
00988                 }
00989                 AcceptSocketContext->BytesRecv += cbTransferred;
00990                 UnlockSocketContext(AcceptSocketContext, &Error);
00991                 break;
00992             case LSP_OP_CONNECTEX:
00993                 break;
00994             case LSP_OP_WSARECVMSG:
00995                 break;
00996             default:
00997                 break;
00998         }
00999         ReleaseSocketLock(SocketContext);
01000     }
01001
01002     UnlockSocketContext(SocketContext, &Error);
01003
01004     //
01005     // If the app supplied a completion routine, queue it up for completion
01006     //
01007     if (olp->lpCallerCompletionRoutine)
01008     {
01009
01010         olp->lpCallerOverlapped->Internal = (ULONG_PTR)olp->lpCallerCompletionRoutine;
01011
01012         if (MainUpCallTable.lpWPUQueueApc(&olp->CallerThreadId,
01013                                            CallUserApcProc,
01014                                            (DWORD_PTR) olp->lpCallerOverlapped,
01015                                           &Error) == SOCKET_ERROR)
01016         {
01017             dbgprint("IntermediateCompletionRoutine: WPUQueueApc() failed: %d", Error);
01018         }
01019     }
01020     else
01021     {
01022         // Otherwise we signal that the op has completed
01023         //
01024         if (WPUCompleteOverlappedRequest(olp->CallerSocket,
01025                                      olp->lpCallerOverlapped,
01026                                      dwError,
01027                                      cbTransferred,
01028                                     &Error) == SOCKET_ERROR)
01029         {
01030             dbgprint("WPUCompleteOverlappedRequest failed: %d", Error);
01031         }
01032         #ifdef DEBUG
01033         else
01034         {
01035             dbgprint("Completing request on socket: %d", olp->CallerSocket);
01036         }
01037         #endif
01038     }
01039
01040     //
01041     // Cleanup the accounting on the socket
01042     //
01043
01044     //(SocketContext->dwOutstandingAsync)--;
01045
01046     CheckForContextCleanup(olp);
01047
01048     PutbackOverlappedStructure(olp);
01049
01050     return;
01051 }
01052
01053 //
01054 // Function: CallerUserApcProc
01055 //
01056 // Description:
01057 //    This function completes an overlapped request that supplied an APC.
01058 //
01059 VOID CALLBACK CallUserApcProc(ULONG_PTR Context)
01060 {
01061     LPOVERLAPPED                        lpOverlapped;
01062     LPWSAOVERLAPPED_COMPLETION_ROUTINE  UserCompletionRoutine;
01063
01064     lpOverlapped = (LPOVERLAPPED) Context;
01065     UserCompletionRoutine = (LPWSAOVERLAPPED_COMPLETION_ROUTINE)lpOverlapped->Internal;
01066     lpOverlapped->Internal = lpOverlapped->Offset; // To make sure it
01067                                                    // in no longer is
01068                                                    // WSS_OPERATION_IN_PROGRESS
01069
01070     UserCompletionRoutine (
01071         (DWORD)lpOverlapped->Offset,
01072         (DWORD)lpOverlapped->InternalHigh,
01073         lpOverlapped,
01074         (DWORD)lpOverlapped->OffsetHigh
01075         );
01076     return;
01077 }
01078
01079 //
01080 // Function: CheckForContextCleanup
01081 //
01082 // Description:
01083 //    After an overlapped operation completes (or from WSPCloseSocket) we
01084 //    need to see if the socket has been marked for closure and make sure
01085 //    no one else is referencing it. If so then the associated structures
01086 //    can be freed and the socket closed.
01087 //
01088 void CheckForContextCleanup(WSAOVERLAPPEDPLUS *ol)
01089 {
01090     SOCK_INFO *SocketContext=NULL;
01091     int        Error;
01092
01093     SocketContext = FindAndLockSocketContext(ol->CallerSocket, &Error);
01094     if (SocketContext == NULL)
01095     {
01096         return;
01097     }
01098     AcquireSocketLock(ol->SockInfo);
01099
01100     (ol->SockInfo->dwOutstandingAsync)--;
01101
01102     if ((ol->SockInfo->bClosing) &&
01103         (ol->SockInfo->dwOutstandingAsync == 0) &&
01104         (ol->SockInfo->RefCount == 1))
01105     {
01106         //
01107         // If the calling app closed the socket while there were still outstanding
01108         //  async operations then all the outstanding operations have completed so
01109         //  we can close the apps socket handle.
01110         //
01111         if (MainUpCallTable.lpWPUCloseSocketHandle(ol->CallerSocket, &ol->Error) == SOCKET_ERROR)
01112         {
01113             dbgprint("CheckForContextClenaup: WPUCloseSocketHandle() failed: %d", ol->Error);
01114         }
01115
01116         ol->SockInfo->LayeredSocket = INVALID_SOCKET;
01117
01118         RemoveSocketInfo(ol->SockInfo->Provider, ol->SockInfo);
01119
01120         #ifdef DEBUG
01121         dbgprint("CFCL: Closing socket %d Bytes Sent [%lu] Bytes Recv [%lu]",
01122                 ol->CallerSocket, ol->SockInfo->BytesSent, ol->SockInfo->BytesRecv);
01123         #endif
01124
01125         ReleaseSocketLock(ol->SockInfo);
01126
01127         ol->SockInfo = NULL;
01128
01129         DeleteCriticalSection(&SocketContext->SockCritSec);
01130
01131         #ifdef DEBUG
01132         dbgprint("Freeing a SOCK_INFO (SocketContext) structure");
01133         #endif
01134
01135         FreeSockInfo(SocketContext);
01136
01137         return;
01138     }
01139     ReleaseSocketLock(SocketContext);
01140
01141     UnlockSocketContext(SocketContext, &Error);
01142
01143     return;
01144 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/people.Cpp Source File

  • SysMgmt
  • MMC
  • Multisel

people.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include "People.h"
00021
00022 const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 const GUID CBicycleFolder::thisGuid = { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00025 const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00026 const GUID CIceSkateFolder::thisGuid = { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00027
00028 const GUID CBicycle::thisGuid = { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00029 const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00030 const GUID CIceSkate::thisGuid = { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00031
00032
00033 //==============================================================
00034 //
00035 // CPeoplePoweredVehicle implementation
00036 //
00037 //
00038 CPeoplePoweredVehicle::CPeoplePoweredVehicle()
00039 {
00040     children[0] = new CBicycleFolder;
00041     children[1] = new CSkateboardFolder;
00042     children[2] = new CIceSkateFolder;
00043 }
00044
00045 CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
00046 {
00047     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00048         delete children[n];
00049 }
00050
00051 HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00052 {
00053     SCOPEDATAITEM sdi;
00054
00055     if (!bExpanded) {
00056         // create the child nodes, then expand them
00057         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00058             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00059             sdi.mask = SDI_STR       |   // Displayname is valid
00060                 SDI_PARAM     |   // lParam is valid
00061                 SDI_IMAGE     |   // nImage is valid
00062                 SDI_OPENIMAGE |   // nOpenImage is valid
00063                 SDI_PARENT    |   // relativeID is valid
00064                 SDI_CHILDREN;     // cChildren is valid
00065
00066             sdi.relativeID  = (HSCOPEITEM)parent;
00067             sdi.nImage      = children[n]->GetBitmapIndex();
00068             sdi.nOpenImage  = INDEX_OPENFOLDER;
00069             sdi.displayname = MMC_CALLBACK;
00070             sdi.lParam      = (LPARAM)children[n];       // The cookie
00071             sdi.cChildren   = 0;
00072
00073             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00074
00075             _ASSERT( SUCCEEDED(hr) );
00076
00077                     children[n]->SetHandle((HANDLE)sdi.ID);
00078         }
00079     }
00080
00081     return S_OK;
00082 }
00083
00084 CBicycleFolder::CBicycleFolder()
00085 {
00086     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00087         children[n] = new CBicycle(n + 1);
00088     }
00089 }
00090
00091 CBicycleFolder::~CBicycleFolder()
00092 {
00093     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00094         if (children[n]) {
00095             delete children[n];
00096         }
00097 }
00098
00099 HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00100 {
00101     HRESULT      hr = S_OK;
00102
00103     IHeaderCtrl *pHeaderCtrl = NULL;
00104     IResultData *pResultData = NULL;
00105
00106     if (bShow) {
00107         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00108         _ASSERT( SUCCEEDED(hr) );
00109
00110         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00111         _ASSERT( SUCCEEDED(hr) );
00112
00113         // Set the column headers in the results pane
00114         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00115         _ASSERT( S_OK == hr );
00116
00117         // insert items here
00118         RESULTDATAITEM rdi;
00119
00120         hr = pResultData->DeleteAllRsltItems();
00121         _ASSERT( SUCCEEDED(hr) );
00122
00123         if (!bExpanded) {
00124             // create the child nodes, then expand them
00125             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00126                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00127                 rdi.mask       = RDI_STR       |   // Displayname is valid
00128                     RDI_IMAGE     |
00129                     RDI_PARAM;        // nImage is valid
00130
00131                 rdi.nImage      = children[n]->GetBitmapIndex();
00132                 rdi.str         = MMC_CALLBACK;
00133                 rdi.nCol        = 0;
00134                 rdi.lParam      = (LPARAM)children[n];
00135
00136                 hr = pResultData->InsertItem( &rdi );
00137
00138                 _ASSERT( SUCCEEDED(hr) );
00139
00140                             children[n]->SetHandle((HANDLE)rdi.itemID);
00141             }
00142         }
00143
00144         pHeaderCtrl->Release();
00145         pResultData->Release();
00146     }
00147
00148     return hr;
00149 }
00150
00151 CIceSkateFolder::CIceSkateFolder()
00152 {
00153     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00154         children[n] = new CIceSkate(n + 1);
00155     }
00156 }
00157
00158 CIceSkateFolder::~CIceSkateFolder()
00159 {
00160     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00161         if (children[n]) {
00162             delete children[n];
00163         }
00164 }
00165
00166 HRESULT CIceSkateFolder::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
00167 {
00168     *ppViewType = NULL;
00169     *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
00170
00171     return S_OK;
00172 }
00173
00174 void CIceSkateFolder::GetChildColumnInfo(RESULTDATAITEM *rdi)
00175 {
00176     if (rdi->mask & RDI_STR)
00177     {
00178         LPCTSTR pszT = children[rdi->nIndex]->GetDisplayName(rdi->nCol);
00179         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00180         rdi->str = pszW;
00181     }
00182
00183     if (rdi->mask & RDI_IMAGE)
00184         rdi->nImage = children[rdi->nIndex]->GetBitmapIndex();
00185 }
00186
00187 // CDelegationBase::AddImages sets up the collection of images to be displayed
00188 // by the IComponent in the result pane as a result of its MMCN_SHOW handler
00189 HRESULT CIceSkateFolder::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
00190 {
00191     return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
00192         (long *)m_pBMapLg, // pointer to a handle
00193         0, // index of the first image in the strip
00194         RGB(0, 128, 128)  // color of the icon mask
00195         );
00196 }
00197
00198 HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00199 {
00200     HRESULT      hr = S_OK;
00201
00202     IHeaderCtrl *pHeaderCtrl = NULL;
00203     IResultData *pResultData = NULL;
00204
00205     if (bShow) {
00206         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00207         _ASSERT( SUCCEEDED(hr) );
00208
00209         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00210         _ASSERT( SUCCEEDED(hr) );
00211
00212         // Set the column headers in the results pane
00213         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00214         _ASSERT( S_OK == hr );
00215
00216         hr = pResultData->DeleteAllRsltItems();
00217         _ASSERT( SUCCEEDED(hr) );
00218
00219         if (!bExpanded) {
00220             // create the child nodes, then expand them
00221             hr = pResultData->SetItemCount( NUMBER_OF_CHILDREN, 0 );
00222             _ASSERT( SUCCEEDED(hr) );
00223         }
00224
00225         pHeaderCtrl->Release();
00226         pResultData->Release();
00227     }
00228
00229     return hr;
00230 }
00231
00232 CSkateboardFolder::CSkateboardFolder()
00233 {
00234     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00235         children[n] = new CSkateboard(n + 1);
00236     }
00237 }
00238
00239 CSkateboardFolder::~CSkateboardFolder()
00240 {
00241     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00242         if (children[n]) {
00243             delete children[n];
00244         }
00245 }
00246
00247 HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00248 {
00249     HRESULT      hr = S_OK;
00250
00251     IHeaderCtrl *pHeaderCtrl = NULL;
00252     IResultData *pResultData = NULL;
00253
00254     if (bShow) {
00255         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00256         _ASSERT( SUCCEEDED(hr) );
00257
00258         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00259         _ASSERT( SUCCEEDED(hr) );
00260
00261         // Set the column headers in the results pane
00262         hr = pHeaderCtrl->InsertColumn( 0, L"Name                      ", 0, MMCLV_AUTO );
00263         _ASSERT( S_OK == hr );
00264
00265         // insert items here
00266         RESULTDATAITEM rdi;
00267
00268         hr = pResultData->DeleteAllRsltItems();
00269         _ASSERT( SUCCEEDED(hr) );
00270
00271         if (!bExpanded) {
00272             // create the child nodes, then expand them
00273             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00274                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00275                 rdi.mask       = RDI_STR       |   // Displayname is valid
00276                     RDI_IMAGE     |
00277                     RDI_PARAM;        // nImage is valid
00278
00279                 rdi.nImage      = children[n]->GetBitmapIndex();
00280                 rdi.str         = MMC_CALLBACK;
00281                 rdi.nCol        = 0;
00282                 rdi.lParam      = (LPARAM)children[n];
00283
00284                 hr = pResultData->InsertItem( &rdi );
00285
00286                 _ASSERT( SUCCEEDED(hr) );
00287
00288                             children[n]->SetHandle((HANDLE)rdi.itemID);
00289             }
00290         }
00291
00292         pHeaderCtrl->Release();
00293         pResultData->Release();
00294     }
00295
00296     return hr;
00297 }
00298
00299 const _TCHAR *CBicycle::GetDisplayName(int nCol)
00300 {
00301     static _TCHAR buf[128];
00302
00303     _stprintf(buf, _T("Bicycle #%d"), id);
00304
00305     return buf;
00306 }
00307
00308 const _TCHAR *CSkateboard::GetDisplayName(int nCol)
00309 {
00310     static _TCHAR buf[128];
00311
00312     _stprintf(buf, _T("Skateboard #%d"), id);
00313
00314     return buf;
00315 }
00316
00317 const _TCHAR *CIceSkate::GetDisplayName(int nCol)
00318 {
00319     static _TCHAR buf[128];
00320
00321     _stprintf(buf, _T("Ice Skate #%d"), id);
00322
00323     return buf;
00324 }
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::RecordsetEvents Member List

This is the complete list of members for msado15::RecordsetEvents, including all inherited members.
EndOfRecordset(boolean[] fMoreData, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
FetchComplete(msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
FetchProgress(int Progress, int MaxProgress, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
FieldChangeComplete(int cFields, Variant Fields, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
iid | msado15::RecordsetEvents | [static]
MoveComplete(int adReason, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
RecordChangeComplete(int adReason, int cRecords, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
RecordsetChangeComplete(int adReason, msado15.Error pError, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
WillChangeField(int cFields, Variant Fields, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
WillChangeRecord(int adReason, int cRecords, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
WillChangeRecordset(int adReason, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
WillMove(int adReason, int[] adStatus, msado15._Recordset pRecordset) | msado15::RecordsetEvents |
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/resource.h Source File

  • Dataaccess
  • oledb
  • tablecopy

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by TableCopy.rc
00004 //
00005 #define IDUNSELECTALL                   3
00006 #define IDB_UNSELECTALL                 3
00007 #define IDSELECTALL                     4
00008 #define IDB_SELECTALL                   4
00009 #define IDD_FROM_INFO                   101
00010 #define ID_TBLCPY_MENU                  102
00011 #define IDD_OPTIONS                     103
00012 #define IDD_INDEX_INFO                  105
00013 #define IDI_TABLE_COPY                  105
00014 #define IDD_SHOW_TYPES                  106
00015 #define IDD_DATA_TYPES                  107
00016 #define IDD_PROGRESS                    108
00017 #define IDD_DIALOG1                     109
00018 #define IDD_DIALOG2                     110
00019 #define IDD_TO_INFO                     125
00020 #define IDI_FOLDER                      127
00021 #define IDI_TABLEVIEW                   134
00022 #define IDI_TABLESYS                    136
00023 #define IDI_TABLESYN                    137
00024 #define IDI_COLUMN                      140
00025 #define IDI_INDEX                       141
00026 #define IDI_PRIMARYKEY                  142
00027 #define IDI_COLUMNREAD                  144
00028 #define IDI_COLUMNLONG                  145
00029 #define IDI_OPENFOLDER                  150
00030 #define IDI_TABLES                      153
00031 #define IDI_SELTABLE                    154
00032 #define IDI_SCHEMA                      156
00033 #define IDI_CATALOG                     161
00034 #define IDI_TABLE                       166
00035 #define IDI_TYPE                        169
00036 #define IDI_VIEW                        170
00037 #define IDI_SYNONYM                     173
00038 #define IDI_SYSTABLE                    174
00039 #define IDB_FROM_CONNECT                1000
00040 #define IDB_PREV                        1004
00041 #define IDL_TABLES                      1008
00042 #define IDL_COLUMNS                     1009
00043 #define IDT_CONNECT                     1010
00044 #define IDT_FROM_INFO                   1011
00045 #define IDT_TOTABLEHELP                 1011
00046 #define IDE_TO_TABLE                    1012
00047 #define IDB_FINISH                      1013
00048 #define IDT_FROM_CONNECT                1013
00049 #define IDX_COPY_SCHEMA                 1014
00050 #define IDX_COPY_TABLE                  1014
00051 #define IDX_COPY_DATA                   1015
00052 #define IDX_COPY_INDEXES                1016
00053 #define IDE_ROW_COUNT                   1017
00054 #define IDT_MAX_ROWS                    1018
00055 #define IDE_BLOB_SIZE                   1018
00056 #define IDT_SHOW_GROUP                  1019
00057 #define IDE_PARAM_SETS                  1019
00058 #define IDT_TABLE_LIST                  1020
00059 #define IDX_COPY_PRIMARYKEYS            1020
00060 #define IDT_COLUMN_LIST                 1021
00061 #define IDT_INDEXES                     1022
00062 #define IDL_INDEXES                     1023
00063 #define IDT_TO_TITLE                    1024
00064 #define IDB_TO_CONNECT                  1025
00065 #define IDL_FROM_TYPES                  1028
00066 #define IDL_TO_TYPES                    1030
00067 #define IDT_STATUS                      1031
00068 #define IDT_STAT_INFO                   1033
00069 #define IDX_SHOW_SQL                    1034
00070 #define IDR_ALL_ROWS                    1035
00071 #define IDR_ROW_COUNT                   1036
00072 #define IDS_FROM_DSN                    1037
00073 #define IDR_BLOB_SIZE                   1037
00074 #define IDR_ISEQ_STREAM                 1038
00075 #define IDR_PARAM_SETS                  1039
00076 #define IDR_INSERTROW_IMMEDIATE         1040
00077 #define IDR_INSERTROW_BUFFERED          1041
00078 #define IDC_PROVIDER_NAME               1082
00079 #define IDE_FROM_TABLE                  1096
00080 #define IDT_INDEXMSG                    1097
00081 #define IDT_CONNECTSTATUS               1101
00082 #define IDT_TO_CONNECT                  1104
00083 #define IDT_TO_PROVIDER                 1105
00084 #define IDT_FROM_PROVIDER               1106
00085 #define IDT_SOURCE                      1107
00086 #define IDT_TARGET                      1108
00087 #define IDT_OPTIONMSG                   1110
00088 #define IDT_FROMTABLEHELP               1111
00089 #define IDM_FILE_COPYTABLE              40001
00090 #define IDM_FILE_EXIT                   40002
00091 #define IDM_HELP_ABOUT                  40003
00092 #define IDM_HELP_HELP                   40004
00093 #define IDC_STATIC                      -1
00094
00095 // Next default values for new objects
00096 //
00097 #ifdef APSTUDIO_INVOKED
00098 #ifndef APSTUDIO_READONLY_SYMBOLS
00099 #define _APS_NEXT_RESOURCE_VALUE        175
00100 #define _APS_NEXT_COMMAND_VALUE         40005
00101 #define _APS_NEXT_CONTROL_VALUE         1113
00102 #define _APS_NEXT_SYMED_VALUE           101
00103 #endif
00104 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/drawIcon.c Source File

  • Com
  • Fundamentals
  • OleStd

drawIcon.c

Go to the documentation of this file.
00001 /*
00002  * DRAWICON.C
00003  *
00004  * Functions to handle creation of metafiles with icons and labels
00005  * as well as functions to draw such metafiles with or without the label.
00006  *
00007  * The metafile is created with a comment that marks the records containing
00008  * the label code.  Drawing the metafile enumerates the records, draws
00009  * all records up to that point, then decides to either skip the label
00010  * or draw it.
00011  *
00012  * Copyright (c)1992 - 2000 Microsoft Corporation, All Right Reserved
00013  */
00014
00015 #define STRICT  1
00016 #include "olestd.h"
00017 #include "common.h"
00018 #include "utility.h"
00019
00020 /*
00021  * Strings for metafile comments.  KEEP THESE IN SYNC WITH THE
00022  * STRINGS IN GETICON.C.
00023  */
00024
00025 static char szIconOnly[]="IconOnly";        //Where to stop to exclude label.
00026
00027
00028
00029
00030 /*
00031  * OleUIMetafilePictIconFree
00032  *
00033  * Purpose:
00034  *  Deletes the metafile contained in a METAFILEPICT structure and
00035  *  frees the memory for the structure itself.
00036  *
00037  * Parameters:
00038  *  hMetaPict       HGLOBAL metafilepict structure created in
00039  *                  OleUIMetafilePictFromIconAndLabel
00040  *
00041  * Return Value:
00042  *  None
00043  */
00044
00045 STDAPI_(void) OleUIMetafilePictIconFree(HGLOBAL hMetaPict)
00046    {
00047    LPMETAFILEPICT      pMF;
00048
00049    if (NULL==hMetaPict)
00050       return;
00051
00052    pMF=(LPMETAFILEPICT)GlobalLock(hMetaPict);
00053
00054    if (NULL!=pMF)
00055       {
00056       if (NULL!=pMF->hMF)
00057          DeleteMetaFile(pMF->hMF);
00058       }
00059
00060    GlobalUnlock(hMetaPict);
00061    GlobalFree(hMetaPict);
00062    return;
00063    }
00064
00065
00066
00067
00068
00069
00070
00071
00072 /*
00073  * OleUIMetafilePictIconDraw
00074  *
00075  * Purpose:
00076  *  Draws the metafile from OleUIMetafilePictFromIconAndLabel, either with
00077  *  the label or without.
00078  *
00079  * Parameters:
00080  *  hDC             HDC on which to draw.
00081  *  pRect           LPRECT in which to draw the metafile.
00082  *  hMetaPict       HGLOBAL to the METAFILEPICT from
00083  *                  OleUIMetafilePictFromIconAndLabel
00084  *  fIconOnly       BOOL specifying to draw the label or not.
00085  *
00086  * Return Value:
00087  *  BOOL            TRUE if the function is successful, FALSE if the
00088  *                  given metafilepict is invalid.
00089  */
00090
00091 STDAPI_(BOOL) OleUIMetafilePictIconDraw(HDC hDC, LPRECT pRect, HGLOBAL hMetaPict
00092                              , BOOL fIconOnly)
00093    {
00094    LPMETAFILEPICT  pMF;
00095    DRAWINFO        di;
00096    int             cx, cy;
00097    SIZE            size;
00098    POINT           point;
00099
00100    if (NULL==hMetaPict)
00101       return FALSE;
00102
00103    pMF=GlobalLock(hMetaPict);
00104
00105    if (NULL==pMF)
00106       return FALSE;
00107
00108    di.Rect = *pRect;
00109    di.fIconOnly = fIconOnly;
00110
00111    //Transform to back to pixels
00112    cx=XformWidthInHimetricToPixels(hDC, pMF->xExt);
00113    cy=XformHeightInHimetricToPixels(hDC, pMF->yExt);
00114
00115    SaveDC(hDC);
00116
00117    SetMapMode(hDC, pMF->mm);
00118    SetViewportOrgEx(hDC, (pRect->right - cx) / 2, 0, &point);
00119
00120    SetViewportExtEx(hDC, min ((pRect->right - cx) / 2 + cx, cx), cy, &size);
00121
00122    if (fIconOnly)
00123       {
00124       // Since we've used the __export keyword on the
00125       // EnumMetafileIconDraw proc, we do not need to use
00126       // MakeProcInstance
00127       EnumMetaFile(hDC, pMF->hMF, (MFENUMPROC)EnumMetafileIconDraw
00128          , (LPARAM)(LPDRAWINFO)&di);
00129       }
00130    else
00131       PlayMetaFile(hDC, pMF->hMF);
00132
00133    RestoreDC(hDC, -1);
00134
00135    GlobalUnlock(hMetaPict);
00136    return TRUE;
00137    }
00138
00139
00140
00141
00142 /*
00143  * EnumMetafileIconDraw
00144  *
00145  * Purpose:
00146  *  EnumMetaFile callback function that draws either the icon only or
00147  *  the icon and label depending on given flags.
00148  *
00149  * Parameters:
00150  *  hDC             HDC into which the metafile should be played.
00151  *  phTable         HANDLETABLE FAR * providing handles selected into the DC.
00152  *  pMFR            METARECORD FAR * giving the enumerated record.
00153  *  lParam          LPARAM flags passed in EnumMetaFile.
00154  *
00155  * Return Value:
00156  *  int             0 to stop enumeration, 1 to continue.
00157  */
00158
00159 int CALLBACK EXPORT EnumMetafileIconDraw(HDC hDC, HANDLETABLE FAR *phTable
00160    , METARECORD FAR *pMFR, int cObj, LPARAM lParam)
00161    {
00162    LPDRAWINFO lpdi = (LPDRAWINFO)lParam;
00163
00164    /*
00165     * We play everything blindly except for DIBBITBLT (or DIBSTRETCHBLT)
00166     * and ESCAPE with MFCOMMENT.  For the BitBlts we change the x,y to
00167     * draw at (0,0) instead of wherever it was written to draw.  The
00168     * comment tells us there to stop if we don't want to draw the label.
00169     */
00170
00171    //If we're playing icon only, stop enumeration at the comment.
00172    if (lpdi->fIconOnly)
00173       {
00174       if (META_ESCAPE==pMFR->rdFunction && MFCOMMENT==pMFR->rdParm[0])
00175          {
00176          if (0==lstrcmpi(szIconOnly, (LPSTR)&pMFR->rdParm[2]))
00177             return 0;
00178          }
00179
00180       /*
00181        * Check for the records in which we want to munge the coordinates.
00182        * destX is offset 6 for BitBlt, offset 9 for StretchBlt, either of
00183        * which may appear in the metafile.
00184        */
00185       if (META_DIBBITBLT==pMFR->rdFunction)
00186          pMFR->rdParm[6]=0;
00187
00188       if (META_DIBSTRETCHBLT==pMFR->rdFunction)
00189            pMFR->rdParm[9] = 0;
00190
00191       }
00192
00193
00194    PlayMetaFileRecord(hDC, phTable, pMFR, cObj);
00195    return 1;
00196    }
00197
00198
00199
00200
00201
00202 /*
00203  * OleUIMetafilePictExtractLabel
00204  *
00205  * Purpose:
00206  *  Retrieves the label string from metafile representation of an icon.
00207  *
00208  * Parameters:
00209  *  hMetaPict       HGLOBAL to the METAFILEPICT containing the metafile.
00210  *  lpszLabel       LPSTR in which to store the label.
00211  *  cchLabel        UINT length of lpszLabel.
00212  *  lpWrapIndex     DWORD index of first character in last line. Can be NULL
00213  *                  if calling function doesn't care about word wrap.
00214  *
00215  * Return Value:
00216  *  UINT            Number of characters copied.
00217  */
00218 STDAPI_(UINT) OleUIMetafilePictExtractLabel(HGLOBAL hMetaPict, LPOLESTR lpszLabel
00219                                 , UINT cchLabel, LPDWORD lpWrapIndex)
00220    {
00221    LPMETAFILEPICT  pMF;
00222    LABELEXTRACT    le;
00223    HDC             hDC;
00224
00225    /*
00226     * We extract the label by getting a screen DC and walking the metafile
00227     * records until we see the ExtTextOut record we put there.  That
00228     * record will have the string embedded in it which we then copy out.
00229     */
00230
00231    if (NULL==hMetaPict || NULL==lpszLabel || 0==cchLabel)
00232       return FALSE;
00233
00234    pMF=GlobalLock(hMetaPict);
00235
00236    if (NULL==pMF)
00237       return FALSE;
00238
00239    le.lpsz=lpszLabel;
00240    le.u.cch=cchLabel;
00241    le.Index=0;
00242    le.fFoundIconOnly=FALSE;
00243    le.fFoundSource=FALSE;  //Unused for this function.
00244    le.fFoundIndex=FALSE;   //Unused for this function.
00245    le.PrevIndex = 0;
00246
00247    //Use a screen DC so we have something valid to pass in.
00248    hDC=GetDC(NULL);
00249
00250    // Since we've used the EXPORT keyword on the
00251    // EnumMetafileExtractLabel proc, we do not need to use
00252    // MakeProcInstance
00253
00254    EnumMetaFile(hDC, pMF->hMF, (MFENUMPROC)EnumMetafileExtractLabel, (LONG)(LPLABELEXTRACT)&le);
00255
00256    ReleaseDC(NULL, hDC);
00257
00258    GlobalUnlock(hMetaPict);
00259
00260    //Tell where we wrapped (if calling function cares)
00261    if (NULL != lpWrapIndex)
00262       *lpWrapIndex = le.PrevIndex;
00263
00264    //Return amount of text copied
00265    return le.u.cch;
00266    }
00267
00268
00269
00270
00271
00272 /*
00273  * EnumMetafileExtractLabel
00274  *
00275  * Purpose:
00276  *  EnumMetaFile callback function that walks a metafile looking for
00277  *  ExtTextOut, then concatenates the text from each one into a buffer
00278  *  in lParam.
00279  *
00280  * Parameters:
00281  *  hDC             HDC into which the metafile should be played.
00282  *  phTable         HANDLETABLE FAR * providing handles selected into the DC.
00283  *  pMFR            METARECORD FAR * giving the enumerated record.
00284  *  pLE             LPLABELEXTRACT providing the destination buffer and length.
00285  *
00286  * Return Value:
00287  *  int             0 to stop enumeration, 1 to continue.
00288  */
00289
00290 int CALLBACK EXPORT EnumMetafileExtractLabel(HDC hDC, HANDLETABLE FAR *phTable
00291    , METARECORD FAR *pMFR, int cObj, LPLABELEXTRACT pLE)
00292    {
00293
00294    /*
00295     * We don't allow anything to happen until we see "IconOnly"
00296     * in an MFCOMMENT that is used to enable everything else.
00297     */
00298    if (!pLE->fFoundIconOnly)
00299       {
00300       if (META_ESCAPE==pMFR->rdFunction && MFCOMMENT==pMFR->rdParm[0])
00301          {
00302          if (0==lstrcmpi(szIconOnly, (LPSTR)&pMFR->rdParm[2]))
00303             pLE->fFoundIconOnly=TRUE;
00304          }
00305
00306       return 1;
00307       }
00308
00309    //Enumerate all records looking for META_EXTTEXTOUT - there can be more
00310    //than one.
00311    if (META_EXTTEXTOUT==pMFR->rdFunction)
00312       {
00313       UINT        cchMax;
00314       LPOLESTR    lpszTemp;
00315
00316        /*
00317        * If ExtTextOut has NULL fuOptions, then the rectangle is omitted
00318        * from the record, and the string starts at rdParm[4].  If
00319        * fuOptions is non-NULL, then the string starts at rdParm[8]
00320        * (since the rectange takes up four WORDs in the array).  In
00321        * both cases, the string continues for (rdParm[2]+1) >> 1
00322        * words.  We just cast a pointer to rdParm[8] to an LPSTR and
00323        * lstrcpyn into the buffer we were given.
00324        *
00325        * Note that we use element 8 in rdParm instead of 4 because we
00326        * passed ETO_CLIPPED in for the options on ExtTextOut--docs say
00327        * [4] which is rect doesn't exist if we passed zero there.
00328        *
00329        */
00330
00331       cchMax=min(pLE->u.cch - pLE->Index, (UINT)pMFR->rdParm[2]);
00332       lpszTemp = /*(LPOLESTR)*/((/*(LPSTR)*/pLE->lpsz) + pLE->Index);
00333
00334       A2W ((LPSTR)&(pMFR->rdParm[8]), lpszTemp, cchMax);
00335       lpszTemp[cchMax]='\0';
00336
00337       pLE->u.cch = OLESTRLEN (pLE->lpsz);
00338       pLE->PrevIndex = pLE->Index;
00339       pLE->Index += cchMax;
00340       }
00341
00342    return 1;
00343    }
00344
00345
00346
00347
00348
00349 /*
00350  * OleUIMetafilePictExtractIcon
00351  *
00352  * Purpose:
00353  *  Retrieves the icon from metafile into which DrawIcon was done before.
00354  *
00355  * Parameters:
00356  *  hMetaPict       HGLOBAL to the METAFILEPICT containing the metafile.
00357  *
00358  * Return Value:
00359  *  HICON           Icon recreated from the data in the metafile.
00360  */
00361 STDAPI_(HICON) OleUIMetafilePictExtractIcon(HGLOBAL hMetaPict)
00362    {
00363    LPMETAFILEPICT  pMF;
00364    HDC             hDC;
00365    ICONEXTRACT     ie;
00366
00367    /*
00368     * We extract the label by getting a screen DC and walking the metafile
00369     * records until we see the ExtTextOut record we put there.  That
00370     * record will have the string embedded in it which we then copy out.
00371     */
00372
00373    if (NULL==hMetaPict)
00374       return NULL;
00375
00376    pMF=GlobalLock(hMetaPict);
00377
00378    if (NULL==pMF)
00379       return FALSE;
00380
00381    //Use a screen DC so we have something valid to pass in.
00382    hDC=GetDC(NULL);
00383    ie.fAND=TRUE;
00384
00385    // We get information back in the ICONEXTRACT structure.
00386    // (Since we've used the EXPORT keyword on the
00387    // EnumMetafileExtractLabel proc, we do not need to use
00388    // MakeProcInstance)
00389    EnumMetaFile(hDC, pMF->hMF, (MFENUMPROC)EnumMetafileExtractIcon, (LONG)(LPICONEXTRACT)&ie);
00390
00391    ReleaseDC(NULL, hDC);
00392    GlobalUnlock(hMetaPict);
00393
00394    return ie.hIcon;
00395    }
00396
00397
00398
00399
00400
00401 /*
00402  * EnumMetafileExtractIcon
00403  *
00404  * Purpose:
00405  *  EnumMetaFile callback function that walks a metafile looking for
00406  *  StretchBlt (3.1) and BitBlt (3.0) records.  We expect to see two
00407  *  of them, the first being the AND mask and the second being the XOR
00408  *  data.  We
00409  *  ExtTextOut, then copies the text into a buffer in lParam.
00410  *
00411  * Parameters:
00412  *  hDC             HDC into which the metafile should be played.
00413  *  phTable         HANDLETABLE FAR * providing handles selected into the DC.
00414  *  pMFR            METARECORD FAR * giving the enumerated record.
00415  *  pIE             LPICONEXTRACT providing the destination buffer and length.
00416  *
00417  * Return Value:
00418  *  int             0 to stop enumeration, 1 to continue.
00419  */
00420
00421 int CALLBACK EXPORT EnumMetafileExtractIcon(HDC hDC, HANDLETABLE FAR *phTable
00422    , METARECORD FAR *pMFR, int cObj, LPICONEXTRACT pIE)
00423    {
00424    LPBITMAPINFO        lpBI;
00425    LPBITMAPINFOHEADER  lpBH;
00426    LPBYTE              lpbSrc;
00427    LPBYTE              lpbDst;
00428    UINT                uWidth, uHeight;
00429    DWORD               cb;
00430    HGLOBAL             hMem;
00431    BITMAP              bm;
00432    HBITMAP             hBmp;
00433    int                 cxIcon, cyIcon;
00434
00435
00436    //Continue enumeration if we don't see the records we want.
00437    if (META_DIBBITBLT!=pMFR->rdFunction && META_DIBSTRETCHBLT!=pMFR->rdFunction)
00438       return 1;
00439
00440    /*
00441     * Windows 3.0 DrawIcon uses META_DIBBITBLT in whereas 3.1 uses
00442     * META_DIBSTRETCHBLT so we have to handle each case separately.
00443     */
00444
00445    if (META_DIBBITBLT==pMFR->rdFunction)       //Win3.0
00446       {
00447       //Get dimensions and the BITMAPINFO struct.
00448       uHeight=pMFR->rdParm[1];
00449       uWidth =pMFR->rdParm[2];
00450       lpBI=(LPBITMAPINFO)&(pMFR->rdParm[8]);
00451       }
00452
00453    if (META_DIBSTRETCHBLT==pMFR->rdFunction)   //Win3.1
00454       {
00455       //Get dimensions and the BITMAPINFO struct.
00456       uHeight=pMFR->rdParm[2];
00457       uWidth =pMFR->rdParm[3];
00458       lpBI=(LPBITMAPINFO)&(pMFR->rdParm[10]);
00459       }
00460
00461    lpBH=(LPBITMAPINFOHEADER)&(lpBI->bmiHeader);
00462
00463    //Pointer to the bits which follows the BITMAPINFO structure.
00464    lpbSrc=(LPBYTE)lpBI+lpBH->biSize;
00465
00466    //Add the length of the color table.
00467    if (0!=lpBH->biClrUsed)
00468       lpbSrc+=(DWORD)(lpBH->biClrUsed*sizeof(RGBQUAD));
00469    else
00470       {
00471       /*
00472        * 1 << bc gives 2, 16, 256 for 1, 4, or 8 bits.  24-bit
00473        * bitmaps have no color table, so there's no need to
00474        * change lpbSrc.
00475        */
00476       if (lpBH->biBitCount <= 8)
00477           lpbSrc+=(DWORD)((1 << (lpBH->biBitCount))*sizeof(RGBQUAD));
00478       }
00479
00480
00481    /*
00482     * All the bits we have in lpbSrc are device-independent, so we
00483     * need to change them over to be device-dependent using SetDIBits.
00484     * Once we have a bitmap with the device-dependent bits, we can
00485     * GetBitmapBits to have buffers with the real data.
00486     *
00487     * For each pass we have to allocate memory for the bits.  We save
00488     * the memory for the mask between passes.
00489     */
00490
00491    //Use CreateBitmap for ANY monochrome bitmaps
00492    if (pIE->fAND || 1==lpBH->biBitCount || lpBH->biBitCount > 8)
00493       hBmp=CreateBitmap((UINT)lpBH->biWidth, (UINT)lpBH->biHeight, 1, 1, NULL);
00494    else if (lpBH->biBitCount <= 8)
00495       hBmp=CreateCompatibleBitmap(hDC, (UINT)lpBH->biWidth, (UINT)lpBH->biHeight);
00496
00497    if (!hBmp || !SetDIBits(hDC, hBmp, 0, (UINT)lpBH->biHeight, (LPVOID)lpbSrc, lpBI, DIB_RGB_COLORS))
00498       {
00499       if (!pIE->fAND)
00500          GlobalFree(pIE->hMemAND);
00501
00502       DeleteObject(hBmp);
00503       return 0;
00504       }
00505
00506    //Allocate memory and get the DDBits into it.
00507    GetObject(hBmp, sizeof(bm), &bm);
00508
00509    cb=bm.bmHeight*bm.bmWidthBytes * bm.bmPlanes;
00510
00511 //    if (cb % 4 != 0)        // dword align
00512 //      cb += 4 - (cb % 4);
00513
00514    hMem=GlobalAlloc(GHND, cb);
00515
00516    if (NULL==hMem)
00517       {
00518       if (NULL!=pIE->hMemAND)
00519          GlobalFree(pIE->hMemAND);
00520
00521       DeleteObject(hBmp);
00522       return 0;
00523       }
00524
00525    lpbDst=(LPBYTE)GlobalLock(hMem);
00526    GetBitmapBits(hBmp, cb, (LPVOID)lpbDst);
00527
00528    DeleteObject(hBmp);
00529    GlobalUnlock(hMem);
00530
00531
00532    /*
00533     * If this is the first pass (pIE->fAND==TRUE) then save the memory
00534     * of the AND bits for the next pass.
00535     */
00536    if (pIE->fAND)
00537       {
00538       pIE->fAND=FALSE;
00539       pIE->hMemAND=hMem;
00540
00541       //Continue enumeration looking for the next blt record.
00542       return 1;
00543       }
00544    else
00545       {
00546       //Get the AND pointer again.
00547       lpbSrc=(LPBYTE)GlobalLock(pIE->hMemAND);
00548
00549       /*
00550        * Create the icon now that we have all the data.  lpbDst already
00551        * points to the XOR bits.
00552        */
00553       cxIcon = GetSystemMetrics(SM_CXICON);
00554       cyIcon = GetSystemMetrics(SM_CYICON);
00555
00556       pIE->hIcon=CreateIcon(ghInst,
00557                        uWidth,
00558                        uHeight,
00559                        (BYTE)bm.bmPlanes,
00560                        (BYTE)bm.bmBitsPixel,
00561                        (LPVOID)lpbSrc,
00562                        (LPVOID)lpbDst);
00563
00564       GlobalUnlock(pIE->hMemAND);
00565       GlobalFree(pIE->hMemAND);
00566       GlobalFree(hMem);
00567
00568       //We're done so we can stop.
00569       return 0;
00570       }
00571    }
00572
00573
00574
00575
00576
00577 /*
00578  * OleUIMetafilePictExtractIconSource
00579  *
00580  * Purpose:
00581  *  Retrieves the filename and index of the icon source from a metafile
00582  *  created with OleUIMetafilePictFromIconAndLabel.
00583  *
00584  * Parameters:
00585  *  hMetaPict       HGLOBAL to the METAFILEPICT containing the metafile.
00586  *  lpszSource      LPSTR in which to store the source filename.  This
00587  *                  buffer should be OLEUI_CCHPATHMAX characters.
00588  *  piIcon          UINT FAR * in which to store the icon's index
00589  *                  within lpszSource
00590  *
00591  * Return Value:
00592  *  BOOL            TRUE if the records were found, FALSE otherwise.
00593  */
00594 STDAPI_(BOOL) OleUIMetafilePictExtractIconSource(HGLOBAL hMetaPict
00595    , LPOLESTR lpszSource, UINT FAR *piIcon)
00596    {
00597    LPMETAFILEPICT  pMF;
00598    LABELEXTRACT    le;
00599    HDC             hDC;
00600
00601    /*
00602     * We will walk the metafile looking for the two comment records
00603     * following the IconOnly comment.  The flags fFoundIconOnly and
00604     * fFoundSource indicate if we have found IconOnly and if we have
00605     * found the source comment already.
00606     */
00607
00608    if (NULL==hMetaPict || NULL==lpszSource || NULL==piIcon)
00609       return FALSE;
00610
00611    pMF=GlobalLock(hMetaPict);
00612
00613    if (NULL==pMF)
00614       return FALSE;
00615
00616    le.lpsz=lpszSource;
00617    le.fFoundIconOnly=FALSE;
00618    le.fFoundSource=FALSE;
00619    le.fFoundIndex=FALSE;
00620
00621    //Use a screen DC so we have something valid to pass in.
00622    hDC=GetDC(NULL);
00623
00624    EnumMetaFile(hDC, pMF->hMF, (MFENUMPROC)EnumMetafileExtractIconSource, (LONG)(LPLABELEXTRACT)&le);
00625
00626    ReleaseDC(NULL, hDC);
00627    GlobalUnlock(hMetaPict);
00628
00629    //Copy the icon index to the caller's variable.
00630    *piIcon=le.u.iIcon;
00631
00632    //Check that we found everything.
00633    return (le.fFoundIconOnly && le.fFoundSource && le.fFoundIndex);
00634    }
00635
00636
00637 /*
00638  * EnumMetafileExtractIconSource
00639  *
00640  * Purpose:
00641  *  EnumMetaFile callback function that walks a metafile skipping the first
00642  *  comment record, extracting the source filename from the second, and
00643  *  the index of the icon in the third.
00644  *
00645  * Parameters:
00646  *  hDC             HDC into which the metafile should be played.
00647  *  phTable         HANDLETABLE FAR * providing handles selected into the DC.
00648  *  pMFR            METARECORD FAR * giving the enumerated record.
00649  *  pLE             LPLABELEXTRACT providing the destination buffer and
00650  *                  area to store the icon index.
00651  *
00652  * Return Value:
00653  *  int             0 to stop enumeration, 1 to continue.
00654  */
00655 int CALLBACK EXPORT EnumMetafileExtractIconSource(HDC hDC, HANDLETABLE FAR *phTable
00656    , METARECORD FAR *pMFR, int cObj, LPLABELEXTRACT pLE)
00657    {
00658    LPSTR       psz;
00659
00660    /*
00661     * We don't allow anything to happen until we see "IconOnly"
00662     * in an MFCOMMENT that is used to enable everything else.
00663     */
00664    if (!pLE->fFoundIconOnly)
00665       {
00666       if (META_ESCAPE==pMFR->rdFunction && MFCOMMENT==pMFR->rdParm[0])
00667          {
00668          if (0==lstrcmpi(szIconOnly, (LPSTR)&pMFR->rdParm[2]))
00669             pLE->fFoundIconOnly=TRUE;
00670          }
00671
00672       return 1;
00673       }
00674
00675    //Now see if we find the source string.
00676    if (!pLE->fFoundSource)
00677       {
00678       if (META_ESCAPE==pMFR->rdFunction && MFCOMMENT==pMFR->rdParm[0])
00679          {
00680          A2W  ((LPSTR)&pMFR->rdParm[2], pLE->lpsz, OLEUI_CCHPATHMAX);
00681          pLE->lpsz[OLEUI_CCHPATHMAX-1] = '\0';
00682          pLE->fFoundSource=TRUE;
00683          }
00684
00685       return 1;
00686       }
00687
00688    //Next comment will be the icon index.
00689    if (META_ESCAPE==pMFR->rdFunction && MFCOMMENT==pMFR->rdParm[0])
00690       {
00691       /*
00692        * This string contains the icon index in string form,
00693        * so we need to convert back to a UINT.  After we see this
00694        * we can stop the enumeration.  The comment will have
00695        * a null terminator because we made sure to save it.
00696        */
00697       psz=(LPSTR)&pMFR->rdParm[2];
00698       pLE->u.iIcon=0;
00699
00700       //Do Ye Olde atoi
00701       while (*psz)
00702          pLE->u.iIcon=(10*pLE->u.iIcon)+((*psz++)-'0');
00703
00704       pLE->fFoundIndex=TRUE;
00705       return 0;
00706       }
00707
00708    return 1;
00709    }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Field.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Field.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Field
00019 /** @com.interface(iid=0000054C-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Field extends msado15._ADO
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=1109, type=PROPGET, name="ActualSize", name2="getActualSize", addFlagsVtable=4)
00027       @com.parameters([type=I4] return) */
00028   public int getActualSize();
00029
00030   /** @com.method(vtoffset=6, dispid=1036, type=PROPGET, name="Attributes", name2="getAttributes", addFlagsVtable=4)
00031       @com.parameters([type=I4] return) */
00032   public int getAttributes();
00033
00034   /** @com.method(vtoffset=7, dispid=1103, type=PROPGET, name="DefinedSize", name2="getDefinedSize", addFlagsVtable=4)
00035       @com.parameters([type=I4] return) */
00036   public int getDefinedSize();
00037
00038   /** @com.method(vtoffset=8, dispid=1100, type=PROPGET, name="Name", name2="getName", addFlagsVtable=4)
00039       @com.parameters([type=STRING] return) */
00040   public String getName();
00041
00042   /** @com.method(vtoffset=9, dispid=1102, type=PROPGET, name="Type", name2="getType", addFlagsVtable=4)
00043       @com.parameters([type=I4] return) */
00044   public int getType();
00045
00046   /** @com.method(vtoffset=10, dispid=0, type=PROPGET, name="Value", name2="getValue", addFlagsVtable=4)
00047       @com.parameters([type=VARIANT] return) */
00048   public Variant getValue();
00049
00050   /** @com.method(vtoffset=11, dispid=0, type=PROPPUT, name="Value", name2="putValue", addFlagsVtable=4)
00051       @com.parameters([in,type=VARIANT] pvar) */
00052   public void setValue(Variant pvar);
00053
00054   /** @com.method(vtoffset=12, dispid=1610809351, type=PROPGET, name="Precision", name2="getPrecision", addFlagsVtable=4)
00055       @com.parameters([type=U1] return) */
00056   public byte getPrecision();
00057
00058   /** @com.method(vtoffset=13, dispid=1610809352, type=PROPGET, name="NumericScale", name2="getNumericScale", addFlagsVtable=4)
00059       @com.parameters([type=U1] return) */
00060   public byte getNumericScale();
00061
00062   /** @com.method(vtoffset=14, dispid=1107, type=METHOD, name="AppendChunk", addFlagsVtable=4)
00063       @com.parameters([in,type=VARIANT] Data) */
00064   public void AppendChunk(Variant Data);
00065
00066   /** @com.method(vtoffset=15, dispid=1108, type=METHOD, name="GetChunk", addFlagsVtable=4)
00067       @com.parameters([in,type=I4] Length, [type=VARIANT] return) */
00068   public Variant GetChunk(int Length);
00069
00070   /** @com.method(vtoffset=16, dispid=1104, type=PROPGET, name="OriginalValue", name2="getOriginalValue", addFlagsVtable=4)
00071       @com.parameters([type=VARIANT] return) */
00072   public Variant getOriginalValue();
00073
00074   /** @com.method(vtoffset=17, dispid=1105, type=PROPGET, name="UnderlyingValue", name2="getUnderlyingValue", addFlagsVtable=4)
00075       @com.parameters([type=VARIANT] return) */
00076   public Variant getUnderlyingValue();
00077
00078   /** @com.method(vtoffset=18, dispid=1610809357, type=PROPGET, name="DataFormat", name2="getDataFormat", addFlagsVtable=4)
00079       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00080   public IUnknown getDataFormat();
00081
00082   /** @com.method(vtoffset=19, dispid=1610809357, type=PROPPUTREF, name="DataFormat", name2="putDataFormat", addFlagsVtable=4)
00083       @com.parameters([in,iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] ppiDF) */
00084   public void setDataFormat(IUnknown ppiDF);
00085
00086   /** @com.method(vtoffset=20, dispid=1610809351, type=PROPPUT, name="Precision", name2="putPrecision", addFlagsVtable=4)
00087       @com.parameters([in,type=U1] pbPrecision) */
00088   public void setPrecision(byte pbPrecision);
00089
00090   /** @com.method(vtoffset=21, dispid=1610809352, type=PROPPUT, name="NumericScale", name2="putNumericScale", addFlagsVtable=4)
00091       @com.parameters([in,type=U1] pbNumericScale) */
00092   public void setNumericScale(byte pbNumericScale);
00093
00094   /** @com.method(vtoffset=22, dispid=1102, type=PROPPUT, name="Type", name2="putType", addFlagsVtable=4)
00095       @com.parameters([in,type=I4] pDataType) */
00096   public void setType(int pDataType);
00097
00098   /** @com.method(vtoffset=23, dispid=1103, type=PROPPUT, name="DefinedSize", name2="putDefinedSize", addFlagsVtable=4)
00099       @com.parameters([in,type=I4] pl) */
00100   public void setDefinedSize(int pl);
00101
00102   /** @com.method(vtoffset=24, dispid=1036, type=PROPPUT, name="Attributes", name2="putAttributes", addFlagsVtable=4)
00103       @com.parameters([in,type=I4] pl) */
00104   public void setAttributes(int pl);
00105
00106
00107   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x54c, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00108 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagDRAWINFO Member List

This is the complete list of members for tagDRAWINFO, including all inherited members.
fIconOnly | tagDRAWINFO
Rect | tagDRAWINFO
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/PageFILE.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

PageFILE.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAGEFILE.CPP
00003
00004   Summary:   Implementation file for the CPageFile C++ class. A CPageFile
00005              is a C++ object that encapsulates load and save operations on
00006              an COM structured storage compound file. CPageFile knows
00007              about an underlying server-based persistent COM object,
00008              COPageList, that manages the actual page list data.
00009              COPageList supports persistence of its page list data by
00010              exposing the IPersistStream interface.
00011
00012              For a comprehensive tutorial code tour of PageFile's contents
00013              and offerings see the tutorial PERCLIEN.HTM file. For more
00014              specific technical details on the internal workings see the
00015              comments dispersed throughout the PAGEFILE source code.
00016
00017   Classes:   CPageFile.
00018
00019   Functions: .
00020
00021   Origin:    5-24-97: atrent - Created for PERCLIEN Code Sample.
00022
00023 ----------------------------------------------------------------------------
00024   This file is part of the Microsoft COM Tutorial Code Samples.
00025
00026   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00027
00028   This source code is intended only as a supplement to Microsoft
00029   Development Tools and/or on-line documentation.  See these other
00030   materials for detailed information regarding Microsoft code samples.
00031
00032   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00033   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00034   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00035   PARTICULAR PURPOSE.
00036 ==========================================================================+*/
00037
00038 /*--------------------------------------------------------------------------
00039   We include WINDOWS.H for all Win32 applications.
00040   We include OLE2.H because we will be calling the COM/OLE Libraries.
00041   We include APPUTIL.H because we will be building this application using
00042     the convenient Virtual Window and Dialog classes and other
00043     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00044   We include IPAGES.H and PAGEGUID.H for the common page-related Interface
00045     class, GUID, and CLSID specifications.
00046   We include PAGEFILE.H because it has the C++ class declaration used
00047     for CPageFile.
00048 ---------------------------------------------------------------------------*/
00049 #include <windows.h>
00050 #include <ole2.h>
00051 #include <apputil.h>
00052 #include <ipages.h>
00053 #include <pageguid.h>
00054 #include "pagefile.h"
00055
00056
00057 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00058   Method:   CPageFile::CPageFile
00059
00060   Summary:  CPageFile Constructor.
00061
00062   Args:     void.
00063
00064   Returns:  .
00065 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00066 CPageFile::CPageFile(void)
00067 {
00068   m_szCurFileName[0] = 0;
00069
00070   // Save the ClassID of PageLists using overloaded '=' operator.
00071   m_CidPageList = CLSID_PageList;
00072 }
00073
00074
00075 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00076   Method:   CPageFile::~CPageFile
00077
00078   Summary:  CPageFile Destructor.
00079
00080   Args:     void
00081
00082   Returns:  .
00083 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00084 CPageFile::~CPageFile(void)
00085 {
00086 }
00087
00088
00089 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00090   Method:   CPageFile::Init
00091
00092   Summary:  Initializes the CPageFile C++ object.
00093
00094   Args:     TCHAR* pszAppFileName
00095               Name/Path of the app's default compound file to open.
00096
00097   Returns:  HRESULT
00098               Standard result code. NOERROR for success.
00099 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00100 HRESULT CPageFile::Init(
00101           TCHAR* pszAppFileName)
00102 {
00103   HRESULT hr = E_POINTER;
00104
00105   if (NULL != pszAppFileName)
00106   {
00107     // Set the default current file name.
00108     lstrcpyn(m_szCurFileName, pszAppFileName, sizeof(m_szCurFileName)/
00109       sizeof(TCHAR));
00110
00111     hr = NOERROR;
00112   }
00113
00114   return (hr);
00115 }
00116
00117
00118 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00119   Method:   CPageFile::New
00120
00121   Summary:  Create a new empty PageList compound file using the specified
00122             file name.
00123
00124   Args:     TCHAR* pszFileName,
00125               Name/Path of the compound file to Create. If NULL then use
00126               CPageFile's m_szCurFileName as the compound file to Create.
00127             IStorage** ppIStorage,
00128               Address of an IStorage pointer variable that will receive
00129               the IStorage interface for the new PageList file.
00130             IPageList** ppIPageList)
00131               Address of an IPageList pointer variable that will receive
00132               the IPageList interface for a new COPageList COM object.
00133
00134   Returns:  HRESULT
00135               Standard result code. NOERROR for success.
00136 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00137 HRESULT CPageFile::New(
00138           TCHAR* pszFileName,
00139           IStorage** ppIStorage,
00140           IPageList** ppIPageList)
00141 {
00142   HRESULT hr = E_POINTER;
00143   BOOL bNewFile = (NULL != pszFileName);
00144   TCHAR* pszFile;
00145   IStorage* pIStorage;
00146   IStream* pIStream;
00147   IPersistStream* pIPersistStream;
00148   IPageList* pIPageList;
00149   ULARGE_INTEGER uliMaxSize;
00150
00151   if (NULL != ppIStorage && NULL != ppIPageList)
00152   {
00153     // Zero the output pointers in case of errror.
00154     *ppIStorage = NULL;
00155     *ppIPageList = NULL;
00156
00157     // If NULL file name passed then use current file name.
00158     pszFile = bNewFile ? pszFileName : m_szCurFileName;
00159
00160     // Use COM service to create a new compound file.
00161     hr = StgCreateDocfile(
00162            pszFile,
00163            STGM_CREATE | STGM_DIRECT | STGM_READWRITE
00164              | STGM_SHARE_EXCLUSIVE,
00165            0,
00166            &pIStorage);
00167     if (SUCCEEDED(hr))
00168     {
00169       // We have created a new compound file. Now store the CLSID of
00170       // COPageList.
00171       hr = WriteClassStg(pIStorage, m_CidPageList);
00172       if (SUCCEEDED(hr))
00173       {
00174         // Now Create the single "PageList" stream under the root storage.
00175         hr = pIStorage->CreateStream(
00176                PAGELIST_USTR,
00177                STGM_CREATE | STGM_WRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00178                0,
00179                0,
00180                &pIStream);
00181         if (SUCCEEDED(hr))
00182         {
00183           // Now use the Class ID to create a COPageList object. Initially
00184           // ask for the IPageList interface.
00185           hr = CoCreateInstance(
00186                  m_CidPageList,
00187                  NULL,
00188                  CLSCTX_INPROC_SERVER,
00189                  IID_IPageList  ,
00190                  (PPVOID)&pIPageList);
00191           if (SUCCEEDED(hr))
00192           {
00193             // Clear the content of the Page List.
00194             pIPageList->Clear();
00195
00196             // Now obtain the IPersistStream interface on the new
00197             // COPageList object. At this point the client assumes that
00198             // PageList COM objects support the IPersistStream interface.
00199             hr = pIPageList->QueryInterface(
00200                    IID_IPersistStream,
00201                    (PPVOID)&pIPersistStream);
00202             if (SUCCEEDED(hr))
00203             {
00204               // And as expected by this client, COPageList supports
00205               // the IPersistStream interface. Now use this interface
00206               // to ask the COPageList object to save an empty Page List.
00207
00208               // First ask the COPageList object how much space the
00209               // maximum save would consume and then pre-allocate that
00210               // space in the stream.
00211               hr = pIPersistStream->GetSizeMax(&uliMaxSize);
00212               if (SUCCEEDED(hr))
00213               {
00214                 hr = pIStream->SetSize(uliMaxSize);
00215                 if (SUCCEEDED(hr))
00216                 {
00217                   // Now save the new Page List into the
00218                   // pre-allocated space.
00219                   hr = pIPersistStream->Save(pIStream, TRUE);
00220                 }
00221               }
00222
00223               // Done with IPersistStream for now so release it.
00224               pIPersistStream->Release();
00225             }
00226
00227             // Done with the stream for now so release it.
00228             pIStream->Release();
00229           }
00230         }
00231       }
00232     }
00233
00234     if (SUCCEEDED(hr))
00235     {
00236       // COPageList is fully created and the page list is
00237       // loaded. Assign a copy of COPageList's IPageList
00238       // interface for use by the caller.
00239       *ppIPageList = pIPageList;
00240
00241       // For performance, keep the Page List 'Document' file
00242       // open (ie, don't release IStorage here) and give the
00243       // caller a copy of the IStorage Pointer.
00244       *ppIStorage = pIStorage;
00245
00246       // The page list was loaded and we have a current compound
00247       // file name. Copy it for later use in saves and loads.
00248       if (bNewFile)
00249         lstrcpyn(m_szCurFileName, pszFileName, sizeof(m_szCurFileName)/
00250           sizeof(TCHAR));
00251     }
00252   }
00253
00254   return (hr);
00255 }
00256
00257
00258 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00259   Method:   CPageFile::Load
00260
00261   Summary:  Load PageList data using the specified compound file name.
00262             If this file is found then it is loaded. If it is not found
00263             then an empty new file of the specified name is created.
00264
00265   Args:     TCHAR* pszFileName,
00266               Name/Path of the compound file to open. If NULL then use
00267               CPageFile's m_szCurFileName as the compound file to load.
00268             IStorage** ppIStorage,
00269               Address of an IStorage pointer variable that will receive
00270               the IStorage interface for the loaded PageList file.
00271             IPageList** ppIPageList)
00272               Address of an IPageList pointer variable that will receive
00273               the IPageList interface for a new COPageList COM object.
00274
00275   Returns:  HRESULT
00276               Standard result code. NOERROR for success.
00277 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00278 HRESULT CPageFile::Load(
00279           TCHAR* pszFileName,
00280           IStorage** ppIStorage,
00281           IPageList** ppIPageList)
00282 {
00283   HRESULT hr = E_POINTER;
00284   BOOL bNewFile = (NULL != pszFileName);
00285   TCHAR* pszFile;
00286   IStorage* pIStorage;
00287   IStream* pIStream;
00288   IPersistStream* pIPersistStream;
00289   IPageList* pIPageList;
00290   ULARGE_INTEGER uliMaxSize;
00291
00292   if (NULL != ppIStorage && NULL != ppIPageList)
00293   {
00294     // Zero the output pointers in case of errror.
00295     *ppIStorage = NULL;
00296     *ppIPageList = NULL;
00297
00298     // If NULL file name passed then use current file name.
00299     pszFile = bNewFile ? pszFileName : m_szCurFileName;
00300
00301     // Use COM service to check if the file is out there and is actually
00302     // a valid compound file.
00303     hr = StgIsStorageFile(pszFile);
00304     if (SUCCEEDED(hr))
00305     {
00306       // We have a compound file. Use COM service to open the compound file
00307       // and obtain a IStorage interface.
00308       hr = StgOpenStorage(
00309              pszFile,
00310              NULL,
00311              STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
00312              NULL,
00313              0,
00314              &pIStorage);
00315       if (SUCCEEDED(hr))
00316       {
00317         // We have an IStorage. Now get the ClassID of the COM Server
00318         // that handles Page Files.
00319         hr = ReadClassStg(pIStorage, &m_CidPageList);
00320         if (SUCCEEDED(hr))
00321         {
00322           // We have a ClassID for a server. Now Open the single "PageList"
00323           // stream under the root storage.
00324           hr = pIStorage->OpenStream(
00325                  PAGELIST_USTR,
00326                  0,
00327                  STGM_READ | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00328                  0,
00329                  &pIStream);
00330           if (SUCCEEDED(hr))
00331           {
00332             // Now use the previously obtained Class ID to create a
00333             // COPageList object. Initially ask for IPageList interface.
00334             hr = CoCreateInstance(
00335                    m_CidPageList,
00336                    NULL,
00337                    CLSCTX_INPROC_SERVER,
00338                    IID_IPageList  ,
00339                    (PPVOID)&pIPageList);
00340             if (SUCCEEDED(hr))
00341             {
00342               // We have a new COPageList object. Now obtain the
00343               // IPersistStream interface on it. The client assumes at
00344               // this point that PageList COM objects support only the
00345               // IPersistStream interface for their persistence.
00346               hr = pIPageList->QueryInterface(
00347                      IID_IPersistStream,
00348                      (PPVOID)&pIPersistStream);
00349               if (SUCCEEDED(hr))
00350               {
00351                 // And as expected by this client, COPageList supports
00352                 // the IPersistStream interface. Now use this interface
00353                 // to ask the COPageList object to load the Page List.
00354                 hr = pIPersistStream->Load(pIStream);
00355
00356                 // Done with IPersistStream for now so release it.
00357                 pIPersistStream->Release();
00358               }
00359               else
00360                 pIPageList->Release();
00361             }
00362
00363             // Done with the stream for now so release it.
00364             pIStream->Release();
00365           }
00366         }
00367       }
00368     }
00369     else
00370     {
00371       // If there was no existing compound file use COM services to
00372       // create a new compound file.
00373       hr = StgCreateDocfile(
00374              pszFile,
00375              STGM_CREATE | STGM_DIRECT | STGM_READWRITE
00376                | STGM_SHARE_EXCLUSIVE,
00377              0,
00378              &pIStorage);
00379       if (SUCCEEDED(hr))
00380       {
00381         // We have created a new compound file. Now store the CLSID of
00382         // COPageList.
00383         hr = WriteClassStg(pIStorage, m_CidPageList);
00384         if (SUCCEEDED(hr))
00385         {
00386           // Now Create the single "PageList" stream under the root storage.
00387           hr = pIStorage->CreateStream(
00388                  PAGELIST_USTR,
00389                  STGM_CREATE | STGM_WRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00390                  0,
00391                  0,
00392                  &pIStream);
00393           if (SUCCEEDED(hr))
00394           {
00395             // Now use the Class ID to create a COPageList object. Initially
00396             // ask for the IPageList interface.
00397             hr = CoCreateInstance(
00398                    m_CidPageList,
00399                    NULL,
00400                    CLSCTX_INPROC_SERVER,
00401                    IID_IPageList  ,
00402                    (PPVOID)&pIPageList);
00403             if (SUCCEEDED(hr))
00404             {
00405               // We have a new COPageList object. Now obtain the
00406               // IPersistStream interface on it. The client assumes at
00407               // this point that PageList COM objects support only the
00408               // IPersistStream interface for their persistence.
00409               hr = pIPageList->QueryInterface(
00410                    IID_IPersistStream,
00411                      (PPVOID)&pIPersistStream);
00412               if (SUCCEEDED(hr))
00413               {
00414                 // And as expected by this client, COPageList supports
00415                 // the IPersistStream interface. Now use this interface
00416                 // to ask the COPageList object to save an empty Page List.
00417
00418                 // First ask the COPageList object how much space the
00419                 // next save would consume and then pre-allocate that
00420                 // space in the stream.
00421                 hr = pIPersistStream->GetSizeMax(&uliMaxSize);
00422                 if (SUCCEEDED(hr))
00423                 {
00424                   hr = pIStream->SetSize(uliMaxSize);
00425                   if (SUCCEEDED(hr))
00426                   {
00427                     // Now save the new Page List into the
00428                     // pre-allocated space.
00429                     hr = pIPersistStream->Save(pIStream, TRUE);
00430                   }
00431                 }
00432
00433                 // Done with IPersistStream for now so release it.
00434                 pIPersistStream->Release();
00435               }
00436
00437               // Done with the stream for now so release it.
00438               pIStream->Release();
00439             }
00440           }
00441         }
00442       }
00443     }
00444
00445     if (SUCCEEDED(hr))
00446     {
00447       // COPageList is fully created and the page list is
00448       // loaded. Assign a copy of COPageList's IPageList
00449       // interface for use by the caller.
00450       *ppIPageList = pIPageList;
00451
00452       // For performance, keep the Page List 'Document' file
00453       // open (ie, don't release IStorage here) and give the
00454       // caller a copy of the IStorage Pointer.
00455       *ppIStorage = pIStorage;
00456
00457       // The page list was loaded and we have a current compound
00458       // file name. Copy it for later use in saves and loads.
00459       if (bNewFile)
00460         lstrcpyn(m_szCurFileName, pszFileName, sizeof(m_szCurFileName)/
00461           sizeof(TCHAR));
00462     }
00463   }
00464
00465   return (hr);
00466 }
00467
00468
00469 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00470   Method:   CPageFile::Save
00471
00472   Summary:  Save current pagelist data using the specified IStorage
00473             and IPageList interfaces.
00474
00475   Args:     IStorage* pIStorage,
00476               Pointer to the opened file's IStorage interface.
00477             IPageList* pIPageList)
00478               Pointer to the IPageList interface on the COPageList object.
00479
00480   Returns:  HRESULT
00481               Standard result code. NOERROR for success.
00482 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00483 HRESULT CPageFile::Save(
00484           IStorage* pIStorage,
00485           IPageList* pIPageList)
00486 {
00487   HRESULT hr = E_POINTER;
00488   IStream* pIStream;
00489   IPersistStream* pIPersistStream;
00490
00491   if (NULL != pIStorage && NULL != pIPageList)
00492   {
00493     // Obtain the IPersistStream interface on the COPageList
00494     // COM object.
00495     hr = pIPageList->QueryInterface(
00496            IID_IPersistStream,
00497            (PPVOID)&pIPersistStream);
00498     if (SUCCEEDED(hr))
00499     {
00500       // Save if the data is dirty (ie, doesn't match file data).
00501       if (S_FALSE != pIPersistStream->IsDirty())
00502       {
00503         // Use the existing IStorage to Open the single "PageList" stream
00504         // under the root storage.
00505         hr = pIStorage->OpenStream(
00506                PAGELIST_USTR,
00507                0,
00508                STGM_WRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00509                0,
00510                &pIStream);
00511         if (SUCCEEDED(hr))
00512         {
00513           // Ask the persistent object to save itself in the stream
00514           // and clear the PageList dirty bit.
00515           hr = pIPersistStream->Save(pIStream, TRUE);
00516
00517           // Done with the stream for now so release it.
00518           pIStream->Release();
00519         }
00520       }
00521
00522       // Done with IPersistStream for now so release it.
00523       pIPersistStream->Release();
00524     }
00525   }
00526
00527   return (hr);
00528 }
00529
00530
00531 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00532   Method:   CPageFile::SaveAs
00533
00534   Summary:  Create a new PageList compound file using the specified
00535             file name. You must release the previous open IStorage prior
00536             to calling this method.
00537
00538   Args:     TCHAR* pszFileName,
00539               Name/Path of the compound file to open. If NULL then use
00540               CPageFile's m_szCurFileName as the compound file to load.
00541             IPageList* pIPageList,
00542               Pointer to the IPageList interface on the COPageList object.
00543             IStorage** ppIStorage,
00544               Address of an IStorage pointer variable that will receive
00545               the IStorage interface for the new PageList file.
00546
00547   Returns:  HRESULT
00548               Standard result code. NOERROR for success.
00549 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00550 HRESULT CPageFile::SaveAs(
00551           TCHAR* pszFileName,
00552           IPageList* pIPageList,
00553           IStorage** ppIStorage)
00554 {
00555   HRESULT hr = E_POINTER;
00556   BOOL bNewFile = (NULL != pszFileName);
00557   IStorage* pIStorage;
00558
00559   if (NULL != ppIStorage)
00560   {
00561     // Zero the output pointers in case of errror.
00562     *ppIStorage = NULL;
00563
00564     if (bNewFile)
00565     {
00566       // We have a compound file. Use COM service to reopen the
00567       // compound file and obtain a IStorage interface.
00568       hr = StgOpenStorage(
00569              pszFileName,
00570              NULL,
00571              STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
00572              NULL,
00573              0,
00574              &pIStorage);
00575       if (SUCCEEDED(hr))
00576       {
00577         // For performance, keep the Page List 'Document' file
00578         // open (ie, don't release IStorage here) and give the
00579         // caller a copy of the IStorage Pointer.
00580         *ppIStorage = pIStorage;
00581
00582         // Copy the new file name for later use in saves and loads.
00583         lstrcpyn(m_szCurFileName, pszFileName, sizeof(m_szCurFileName)/
00584           sizeof(TCHAR));
00585       }
00586     }
00587   }
00588
00589   return (hr);
00590 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagGENERICITEM Member List

This is the complete list of members for _tagGENERICITEM, including all inherited members.
cbSize | _tagGENERICITEM
pNextGenericItem | _tagGENERICITEM
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CClientDlg Member List

This is the complete list of members for CClientDlg, including all inherited members.
CClientDlg(CWnd *pParent=NULL) | CClientDlg |
DoDataExchange(CDataExchange *pDX) | CClientDlg | [protected, virtual]
IDD enum value | CClientDlg |
m_bUsePing | CClientDlg |
m_cBad | CClientDlg |
m_cGood | CClientDlg |
m_cRSN | CClientDlg |
m_ctlStart | CClientDlg |
m_cWarning | CClientDlg |
m_hIcon | CClientDlg | [protected]
m_iData | CClientDlg |
m_lFails | CClientDlg |
m_lPingFailures | CClientDlg |
m_lPings | CClientDlg |
m_lTimeouts | CClientDlg |
m_lTries | CClientDlg |
OnInitDialog() | CClientDlg | [protected, virtual]
OnOK() | CClientDlg | [protected, virtual]
OnPaint() | CClientDlg | [protected]
OnQueryDragIcon() | CClientDlg | [protected]
OnStart() | CClientDlg | [protected]
OnUsePing() | CClientDlg | [protected]
Generated on Wed Nov 13 2024 16:55:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTable Member List

This is the complete list of members for CTable, including all inherited members.
AdjustBindings(ULONG cBindings, DBBINDING *rgBindings, void *pData) | CTable | [virtual]
Connect(HWND hWnd, CDataSource *pCDataSource=NULL) | CTable | [virtual]
CopyData(CTable *pCSourceTable, ULONG *pcRowsCopied) | CTable | [virtual]
CopyIndexes(CTable *pCSourceTable) | CTable | [virtual]
CreateAccessors(ULONG *pcBindingInfo, BINDINGINFO **prgBindingInfo, ULONG *pcRowSize, ULONG ulBlobSize, BOOL *pbOutofLine) | CTable | [virtual]
CreateSQLStmt(ESQL_STMT eSqlStmt, WCHAR *pwszSqlStmt, BOOL fShowSql=TRUE) | CTable | [virtual]
CreateTable() | CTable | [virtual]
CTable(CWizard *pCWizard) | CTable |
GetColInfo(DWORD dwInsertOpt) | CTable | [virtual]
GetColumnDesc(DBCOLUMNDESC **prgColumnDesc) | CTable | [virtual]
GetLiteralInfo() | CTable | [virtual]
GetQuotedID(WCHAR *pwszOutBuff, WCHAR *pwszInBuff) | CTable | [virtual]
GetRowset(DWORD dwInsertOpt) | CTable | [virtual]
GetTypeInfo() | CTable | [virtual]
GetTypeInfoRowset(IAccessor **ppIAccessor, HACCESSOR *phAccessor, IRowset **ppIRowset) | CTable | [virtual]
GetTypeNameAndParams(ULONG iCol, WCHAR *pwszName) | CTable | [virtual]
IsConnected() | CTable | [virtual]
m_cColumns | CTable |
m_cIndexes | CTable |
m_pCDataSource | CTable |
m_pCWizard | CTable |
m_pIAccessor | CTable |
m_pIRowset | CTable |
m_rgColDesc | CTable |
m_rgIndexInfo | CTable |
m_TableInfo | CTable |
m_wszIDQuote | CTable |
m_wszIDSeperator | CTable |
m_wszQualTableName | CTable |
MapTableInfo(CTable *pCSourceTable) | CTable | [virtual]
~CTable() | CTable | [virtual]
Generated on Wed Nov 13 2024 16:57:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/Generic/Resource.H Source File

  • Begin
  • Generic

Resource.H

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by Generic.RC
00004 //
00005
00006 // Next default values for new objects
00007 //
00008 #ifdef APSTUDIO_INVOKED
00009 #ifndef APSTUDIO_READONLY_SYMBOLS
00010 #define _APS_NO_MFC                     1
00011 #define _APS_NEXT_RESOURCE_VALUE        101
00012 #define _APS_NEXT_COMMAND_VALUE         40001
00013 #define _APS_NEXT_CONTROL_VALUE         1000
00014 #define _APS_NEXT_SYMED_VALUE           101
00015 #endif
00016 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/resource.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by MultiSel.rc
00004 //
00005 #define IDB_APPIMG_32                   101
00006 #define IDB_APPIMG_16                   104
00007 #define IDI_APP_ICON                    105
00008 #define IDB_NODEIMAGES_16               106
00009 #define IDB_NODEIMAGES_32               107
00010 #define IDD_BASE_DIALOG                 108
00011 #define IDD_ADDDEVICE_DLG               109
00012 #define IDR_STATIC_TOOLBAR              110
00013 #define IDR_DEVICE_TOOLBAR              112
00014 #define IDD_ADDFOLDER_DLG               114
00015 #define IDD_ADDVFILE_DLG                115
00016 #define IDR_VFILE_TOOLBAR               115
00017 #define IDC_ARCHIVE_ATTR                1000
00018 #define IDC_HIDDEN_ATTR                 1001
00019 #define IDC_LOCKED_ATTR                 1002
00020 #define IDC_READONLY_ATTR               1003
00021 #define IDC_DEVNAME_EDIT                1004
00022 #define IDC_BACKUP_FLAG                 1005
00023 #define IDC_FLDRNAME_EDIT               1006
00024 #define ID_BUTTON40001                  40001
00025 #define ID_BUTTON40002                  40002
00026 #define ID_BUTTON40003                  40003
00027 #define ID_BUTTON40004                  40004
00028
00029 // Next default values for new objects
00030 //
00031 #ifdef APSTUDIO_INVOKED
00032 #ifndef APSTUDIO_READONLY_SYMBOLS
00033 #define _APS_NEXT_RESOURCE_VALUE        117
00034 #define _APS_NEXT_COMMAND_VALUE         40005
00035 #define _APS_NEXT_CONTROL_VALUE         1007
00036 #define _APS_NEXT_SYMED_VALUE           101
00037 #endif
00038 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/ComSyncObject/ComSyncObject.Idl Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • ComSyncObject

ComSyncObject.Idl

Go to the documentation of this file.
00001 // ComSyncObject.idl : IDL source for ComSyncObject.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (ComSyncObject.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009   [
00010     object,
00011     uuid(BAEA7BB0-F391-11D2-A10A-0080C71F306F),
00012     dual,
00013     helpstring("ISyncTest Interface"),
00014     pointer_default(unique)
00015   ]
00016   interface ISyncTest : IDispatch
00017   {
00018     HRESULT Exercise(void);
00019   };
00020
00021 [
00022   uuid(5659AA70-F6A8-11D2-A10B-0080C71F306F),
00023   version(1.0),
00024   helpstring("ComSyncObject 1.0 Type Library")
00025 ]
00026 library COMSYNCOBJECTLib
00027 {
00028   importlib("stdole32.tlb");
00029   importlib("stdole2.tlb");
00030
00031   [
00032     uuid(BE872DE0-F6A8-11D2-A10B-0080C71F306F),
00033     helpstring("ComSyncTest Class")
00034   ]
00035   coclass ComSyncTest
00036   {
00037     [default] interface ISyncTest;
00038   };
00039 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/lrsample/langreg.hxx Source File

  • WinBase
  • Indexing
  • lrsample

langreg.hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 // PARTICULAR PURPOSE.
00007 //
00008 // Copyright (c) Microsoft Corporation. All rights reserved.
00009 //
00010 // File:     langreg.hxx
00011 //
00012 // PURPOSE:  Helper classes for sample programs
00013 //
00014 // PLATFORM: Windows 2000 and later
00015 //
00016 //--------------------------------------------------------------------------
00017
00018 #pragma once
00019
00020 //
00021 // Structure to define language resource class
00022 //
00023
00024 struct SLangClassEntry
00025 {
00026     WCHAR const * pwszClassId;
00027     WCHAR const * pwszClassIdDescription;
00028     WCHAR const * pwszDLL;
00029     WCHAR const * pwszThreadingModel;
00030 };
00031
00032 struct SLangRegistry
00033 {
00034     WCHAR const *   pwszLangName;
00035     LONG            lcid;
00036     SLangClassEntry WordBreaker;
00037     SLangClassEntry Stemmer;
00038 };
00039
00040 //
00041 // Sample use of the structures
00042 //
00043 //
00044 // SLangClassEntry const NeutralWordBreaker =
00045 //                               { L"{369647e0-17b0-11ce-9950-00aa004bbb1f}",
00046 //                                 L"Neutral Word Breaker",
00047 //                                 L"query.dll",
00048 //                                 L"both" };
00049 //
00050 // SLangRegistry const English_US_LangRes =
00051 //                             { L"English_US", 1033,
00052 //                               { L"{59e09780-8099-101b-8df3-00000b65c3b5}",
00053 //                                 L"English_US Word Breaker",
00054 //                                 L"infosoft.dll",
00055 //                                 L"both" },
00056 //                               { L"{eeed4c20-7f1b-11ce-be57-00aa0051fe20}",
00057 //                                 L"English_US Stemmer",
00058 //                                 L"infosoft.dll",
00059 //                                 L"both" }
00060 //                             };
00061 //
00062
00063 //
00064 // Function prototypes
00065 //
00066
00067 inline long RegisterALanguageResource( SLangRegistry const & LangRes );
00068 inline long RegisterALanguageClass( SLangClassEntry const & LangClass );
00069
00070 inline long UnRegisterALanguageResource( SLangRegistry const & LangRes );
00071 inline long UnRegisterALanguageClass( SLangClassEntry const & LangClass );
00072
00073 //+---------------------------------------------------------------------------
00074 //
00075 //  Function:   RegisterALanguageResource, private
00076 //
00077 //  Synopsis:   Registers a language resource.
00078 //
00079 //  Arguments:  [LangRes]      -- Language resource description
00080 //
00081 //  Returns:    ERROR_SUCCESS on success
00082 //
00083 //----------------------------------------------------------------------------
00084
00085 inline long RegisterALanguageResource( SLangRegistry const & LangRes )
00086 {
00087     WCHAR wcTemp[MAX_PATH];
00088
00089     long dwError;
00090     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00091
00092     wcscpy( wcTemp, L"System\\CurrentControlSet\\Control\\ContentIndex\\Language\\" );
00093
00094     if ( ( wcslen( wcTemp ) + wcslen( LangRes.pwszLangName ) ) >= MAX_PATH )
00095         return ERROR_INSUFFICIENT_BUFFER;
00096
00097     wcscat( wcTemp, LangRes.pwszLangName );
00098
00099     do
00100     {
00101         DWORD dwDisposition;
00102
00103         dwError = RegCreateKeyExW( HKEY_LOCAL_MACHINE,   // Root
00104                                    wcTemp,               // Sub key
00105                                    0,                    // Reserved
00106                                    0,                    // Class
00107                                    0,                    // Flags
00108                                    KEY_ALL_ACCESS,       // Access
00109                                    0,                    // Security
00110                                    &hKey,                // Handle
00111                                    &dwDisposition );     // Disposition
00112
00113         if ( ERROR_SUCCESS != dwError )
00114             break;
00115
00116         //
00117         // Write the locale ID
00118         //
00119
00120         dwError = RegSetValueExW( hKey,                  // Key
00121                                   L"Locale",             // Name
00122                                   0,                     // Reserved
00123                                   REG_DWORD,             // Type
00124                                   (BYTE *)&LangRes.lcid, // Value
00125                                   sizeof DWORD );
00126
00127         if ( ERROR_SUCCESS != dwError )
00128             break;
00129
00130         //
00131         //  Create the word breaker class description
00132         //
00133         if (LangRes.WordBreaker.pwszClassId != 0)
00134         {
00135             dwError = RegisterALanguageClass( LangRes.WordBreaker );
00136             if ( ERROR_SUCCESS != dwError )
00137                 break;
00138
00139             dwError = RegSetValueExW( hKey,              // Key
00140                                       L"WBreakerClass",  // Name
00141                                       0,                 // Reserved
00142                                       REG_SZ,            // Type
00143                                       (BYTE *)LangRes.WordBreaker.pwszClassId, // Value
00144                                       (DWORD) ( (1 + wcslen(LangRes.WordBreaker.pwszClassId) ) * sizeof(WCHAR) ) );
00145             if ( ERROR_SUCCESS != dwError )
00146                 break;
00147
00148         }
00149
00150         //
00151         //  Create the stemmer class description
00152         //
00153         if (LangRes.Stemmer.pwszClassId != 0)
00154         {
00155             dwError = RegisterALanguageClass( LangRes.Stemmer );
00156             if ( ERROR_SUCCESS != dwError )
00157                 break;
00158
00159             dwError = RegSetValueExW( hKey,              // Key
00160                                       L"StemmerClass",   // Name
00161                                       0,                 // Reserved
00162                                       REG_SZ,            // Type
00163                                       (BYTE *)LangRes.Stemmer.pwszClassId, // Value
00164                                       (DWORD) ( (1 + wcslen(LangRes.Stemmer.pwszClassId) ) * sizeof(WCHAR) ) );
00165             if ( ERROR_SUCCESS != dwError )
00166                 break;
00167
00168         }
00169
00170     } while( FALSE );
00171
00172     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00173     {
00174         RegCloseKey( hKey );
00175         hKey = (HKEY)INVALID_HANDLE_VALUE;
00176     }
00177
00178     return dwError;
00179 }
00180
00181
00182 //+---------------------------------------------------------------------------
00183 //
00184 //  Function:   UnRegisterALanguageResource, private
00185 //
00186 //  Synopsis:   Unregisters a language resource.
00187 //
00188 //  Arguments:  [LangRes]      -- Language resource description
00189 //
00190 //  Returns:    ERROR_SUCCESS on success
00191 //
00192 //----------------------------------------------------------------------------
00193
00194 inline long UnRegisterALanguageResource( SLangRegistry const & LangRes )
00195 {
00196     WCHAR wcTemp[MAX_PATH];
00197
00198     wcscpy( wcTemp, L"System\\CurrentControlSet\\Control\\ContentIndex\\Language\\" );
00199
00200     if ( ( wcslen( wcTemp ) + wcslen( LangRes.pwszLangName ) ) >= MAX_PATH )
00201         return ERROR_INSUFFICIENT_BUFFER;
00202
00203     wcscat( wcTemp, LangRes.pwszLangName );
00204
00205     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00206     long dwError = RegOpenKeyExW( HKEY_LOCAL_MACHINE,   // Root
00207                                   wcTemp,               // Sub key
00208                                   0,                    // Reserved
00209                                   KEY_ALL_ACCESS,       // Access
00210                                   &hKey );              // Handle
00211
00212     //
00213     //  Delete the word breaker class description
00214     //
00215     if (LangRes.WordBreaker.pwszClassId != 0)
00216     {
00217         dwError = UnRegisterALanguageClass( LangRes.WordBreaker );
00218
00219         if (hKey != INVALID_HANDLE_VALUE)
00220             dwError = RegDeleteValueW( hKey,                // Key
00221                                        L"WBreakerClass" );   // Name
00222     }
00223
00224     //
00225     //  Create the stemmer class description
00226     //
00227     if (LangRes.Stemmer.pwszClassId != 0)
00228     {
00229         dwError = UnRegisterALanguageClass( LangRes.Stemmer );
00230
00231         if (hKey != INVALID_HANDLE_VALUE)
00232             dwError = RegDeleteValueW( hKey,                // Key
00233                                        L"StemmerClass" );    // Name
00234     }
00235
00236     if (hKey != INVALID_HANDLE_VALUE)
00237     {
00238         DWORD dwNumofKeys = 0;
00239         DWORD dwNumofValues = 0;
00240         dwError = RegQueryInfoKeyW( hKey,       // Hkey
00241                                     0,          // Buffer for class string
00242                                     0,          // Size of class string buffer
00243                                     0,          // reserved
00244                                    &dwNumofKeys,// number of subkeys
00245                                     0,          // longest subkey name length
00246                                     0,          // longest class string length
00247                                    &dwNumofValues,// number of value entries
00248                                     0,          // longest value name length
00249                                     0,          // longest value data length
00250                                     0,          // security descriptor length
00251                                     0 );        // last write time);
00252
00253         if ( ERROR_SUCCESS == dwError )
00254         {
00255             if ( (dwNumofValues == 1) && (dwNumofKeys==0) )
00256             {
00257
00258                 //
00259                 // There is only one value and no sub-keys under this key,
00260                 // Delete the Locale value and then the sub-key for this Lang
00261                 // if that succeeded.
00262                 //
00263
00264                 RegDeleteValueW( hKey,        // Key
00265                                  L"Locale" );  // Name
00266
00267                 dwError = RegQueryInfoKeyW( hKey,       // Hkey
00268                                             0,          // class string
00269                                             0,          // Size of class string
00270                                             0,          // reserved
00271                                            &dwNumofKeys,
00272                                             0,          // max subkey name len
00273                                             0,          // max class string len
00274                                            &dwNumofValues,
00275                                             0,          // max value name len
00276                                             0,          // max value data len
00277                                             0,          // security desc len
00278                                             0 );        // last write time);
00279             }
00280         }
00281         RegCloseKey( hKey );
00282
00283         if ( ERROR_SUCCESS == dwError &&
00284              (0 == dwNumofValues) &&
00285              (0 == dwNumofKeys) )
00286             dwError = RegDeleteKeyW( HKEY_LOCAL_MACHINE,   // Root
00287                                      wcTemp );             // Sub key
00288     }
00289     return dwError;
00290 }
00291
00292 //+---------------------------------------------------------------------------
00293 //
00294 //  Function:   RegisterALanguageClass, private
00295 //
00296 //  Synopsis:   Registers a language resource classID in registry
00297 //
00298 //  Arguments:  [LangClass] -- IWordBreaker or IStemmer description
00299 //
00300 //  Returns:    ERROR_SUCCESS on success
00301 //
00302 //----------------------------------------------------------------------------
00303
00304 inline long RegisterALanguageClass( SLangClassEntry const & LangClass )
00305 {
00306     WCHAR const * aKeyValues[4] = { LangClass.pwszClassId,
00307                                     LangClass.pwszClassIdDescription,
00308                                     L"InprocServer32",
00309                                     LangClass.pwszDLL };
00310
00311     long retVal = BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
00312     if ( ERROR_SUCCESS == retVal )
00313         retVal = AddThreadingModel( LangClass.pwszClassId, LangClass.pwszThreadingModel );
00314
00315     return retVal;
00316 }
00317
00318
00319 //+---------------------------------------------------------------------------
00320 //
00321 //  Function:   UnRegisterALanguageClass, private
00322 //
00323 //  Synopsis:   Unregisters a language resource classID
00324 //
00325 //  Arguments:  [LangClass] -- IWordBreaker or IStemmer description
00326 //
00327 //  Returns:    ERROR_SUCCESS on success
00328 //
00329 //----------------------------------------------------------------------------
00330
00331 inline long UnRegisterALanguageClass( SLangClassEntry const & LangClass )
00332 {
00333     WCHAR const * aKeyValues[4] = { LangClass.pwszClassId,
00334                                     LangClass.pwszClassIdDescription,
00335                                     L"InprocServer32",
00336                                     LangClass.pwszDLL };
00337
00338     return DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
00339 }
00340
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/WaitSystemDlg.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

WaitSystemDlg.Cpp

Go to the documentation of this file.
00001 // WaitSystemDlg.cpp : implementation file
00002 //
00003 //  Copyright 1995-1998, Citrix Systems Inc.
00004 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00005
00006
00007 #include "stdafx.h"
00008 #include "API.h"
00009 #include "APIDoc.h"
00010 #include "WaitSystemDlg.h"
00011 //#include "wtsapi32.h"
00012 //#include "\program files\devstudio\myprojects\api\citrix\winsta20.h"
00013
00014 #ifdef _DEBUG
00015 #define new DEBUG_NEW
00016 #undef THIS_FILE
00017 static char THIS_FILE[] = __FILE__;
00018 #endif
00019
00020
00021 Events EventFlags[12] =
00022 {
00023   {TEXT("Wait on nothing"), WTS_EVENT_NONE},
00024   {TEXT("New WinStation Created"), WTS_EVENT_CREATE},
00025   {TEXT("Existing WinStation Deleted"), WTS_EVENT_DELETE},
00026   {TEXT("Existing WinStation Renamed"), WTS_EVENT_RENAME},
00027   {TEXT("WinStation is connected to client"), WTS_EVENT_CONNECT},
00028   {TEXT("WinStation is disconnected from client"), WTS_EVENT_DISCONNECT},
00029   {TEXT("User logon to existing WinStation"), WTS_EVENT_LOGON},
00030   {TEXT("User logoff from existing WinStation"), WTS_EVENT_LOGOFF},
00031   {TEXT("WinStation state change"), WTS_EVENT_STATECHANGE},
00032   {TEXT("License state change"), WTS_EVENT_LICENSE},
00033   {TEXT("Wait for all event types"), WTS_EVENT_ALL},
00034   {TEXT("Unblock all waiters"), WTS_EVENT_FLUSH}
00035 };
00036
00037
00038 /////////////////////////////////////////////////////////////////////////////
00039 // CWaitSystemDlg dialog
00040
00041
00042 CWaitSystemDlg::CWaitSystemDlg(CWnd* pParent /*=NULL*/)
00043   : CDialog(CWaitSystemDlg::IDD, pParent)
00044 {
00045   //{{AFX_DATA_INIT(CWaitSystemDlg)
00046     // NOTE: the ClassWizard will add member initialization here
00047   //}}AFX_DATA_INIT
00048 }
00049
00050
00051 void CWaitSystemDlg::DoDataExchange(CDataExchange* pDX)
00052 {
00053   CDialog::DoDataExchange(pDX);
00054   //{{AFX_DATA_MAP(CWaitSystemDlg)
00055   DDX_Control(pDX, IDC_SERVERNAME, m_serverName);
00056   DDX_Control(pDX, IDC_EVENT_FLAGS, m_eventFlags);
00057   //}}AFX_DATA_MAP
00058 }
00059
00060
00061 BEGIN_MESSAGE_MAP(CWaitSystemDlg, CDialog)
00062   //{{AFX_MSG_MAP(CWaitSystemDlg)
00063   //}}AFX_MSG_MAP
00064 END_MESSAGE_MAP()
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // CWaitSystemDlg message handlers
00068
00069 BOOL CWaitSystemDlg::OnInitDialog()
00070 {
00071   CDialog::OnInitDialog();
00072
00073   serverName = g_pDoc->GetServerName();
00074   serverHandle = WTSOpenServer(serverName);
00075
00076   CString serverDisplay;
00077   serverDisplay = "Choose event for ";
00078   if (*serverName == NULL)
00079     serverDisplay += "local server";
00080   else
00081     serverDisplay += serverName;
00082   serverDisplay += " to wait on";
00083
00084   m_serverName.SetWindowText(serverDisplay);
00085
00086
00087   for (int i=0; i < MAXEVENTITEMS; i++)
00088     m_eventFlags.InsertString(i, EventFlags[i].EventName);
00089   m_eventFlags.SetCurSel(0);
00090   return TRUE;
00091 }
00092
00093
00094 void CWaitSystemDlg::OnOK()
00095 {
00096   DWORD EventFlag;
00097   //CString message;
00098   int nIndex = m_eventFlags.GetCurSel();
00099   //message.Format("The current selection is  %x, %u", EventFlags[nIndex].EventFlag, EventFlags[nIndex].EventFlag);
00100   //MessageBox((LPCTSTR)message);
00101   if (!WTSWaitSystemEvent(serverHandle,
00102        EventFlags[nIndex].EventFlag, &EventFlag))
00103      AfxMessageBox("Unable to wait on system event");
00104
00105   CDialog::OnOK();
00106 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDlgIADsPropertyList Member List

This is the complete list of members for CDlgIADsPropertyList, including all inherited members.
CDlgIADsPropertyList(LPUNKNOWN pUnk, CWnd *pParent=NULL) | CDlgIADsPropertyList |
DoDataExchange(CDataExchange *pDX) | CDlgIADsPropertyList | [protected, virtual]
IDD enum value | CDlgIADsPropertyList |
m_cADsType | CDlgIADsPropertyList |
m_cValueList | CDlgIADsPropertyList |
m_pPropList | CDlgIADsPropertyList | [protected]
m_sAttribute | CDlgIADsPropertyList |
OnGet() | CDlgIADsPropertyList | [protected]
OnInitDialog() | CDlgIADsPropertyList | [protected, virtual]
OnPurge() | CDlgIADsPropertyList | [protected]
~CDlgIADsPropertyList() | CDlgIADsPropertyList |
Generated on Wed Nov 13 2024 16:56:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/GenericUCP/CPP/genericucp.h Source File

  • NetDS
  • upnp
  • GenericUCP
  • CPP

genericucp.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005
00006 --*/
00007 // GenericUCP.h : main header file for the GenericUCP application
00008 //
00009
00010 #if !defined(AFX_GenericUCP_H__CF142341_F90B_42D6_8B74_2FC0D5FBAB02__INCLUDED_)
00011 #define AFX_GenericUCP_H__CF142341_F90B_42D6_8B74_2FC0D5FBAB02__INCLUDED_
00012
00013 #if _MSC_VER > 1000
00014 #pragma once
00015 #endif // _MSC_VER > 1000
00016
00017 #ifndef __AFXWIN_H__
00018   #error include 'stdafx.h' before including this file for PCH
00019 #endif
00020
00021
00022 #include "resource.h"   // main symbols
00023
00024
00025
00026
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CGenericUCPApp:
00030 // See GenericUCP.cpp for the implementation of this class
00031 //
00032
00033 class CGenericUCPApp : public CWinApp
00034 {
00035 public:
00036   CGenericUCPApp();
00037
00038 // Overrides
00039   // ClassWizard generated virtual function overrides
00040   //{{AFX_VIRTUAL(CGenericUCPApp)
00041   public:
00042   virtual BOOL InitInstance();
00043   virtual int ExitInstance();
00044   //}}AFX_VIRTUAL
00045
00046 // Implementation
00047
00048   //{{AFX_MSG(CGenericUCPApp)
00049   //}}AFX_MSG
00050   DECLARE_MESSAGE_MAP()
00051
00052 };
00053
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056
00057 //{{AFX_INSERT_LOCATION}}
00058 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00059
00060 #endif // !defined(AFX_GenericUCP_H__CF142341_F90B_42D6_8B74_2FC0D5FBAB02__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/space.Cpp Source File

  • SysMgmt
  • MMC
  • Taskpads

space.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019 #include <stdio.h>
00020 #include "Space.h"
00021 #include "Comp.h"
00022 #define STRSAFE_NO_DEPRECATE
00023 #include <strsafe.h>
00024
00025 const GUID CSpaceVehicle::thisGuid = { 0x29743810, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00026 const GUID CRocket::thisGuid = { 0x29743811, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00027
00028 //==============================================================
00029 //
00030 // CSpaceVehicle implementation
00031 //
00032 //
00033 CSpaceVehicle::CSpaceVehicle()
00034 {
00035     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00036         children[n] = new CRocket(_T("Rocket"), n+1, 500000, 265, 75000);
00037     }
00038 }
00039
00040 CSpaceVehicle::~CSpaceVehicle()
00041 {
00042     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00043         if (children[n]) {
00044             delete children[n];
00045         }
00046 }
00047
00048 HRESULT CSpaceVehicle::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00049 {
00050     HRESULT      hr = S_OK;
00051
00052     IHeaderCtrl *pHeaderCtrl = NULL;
00053     IResultData *pResultData = NULL;
00054
00055     if (bShow) {
00056         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00057         _ASSERT( SUCCEEDED(hr) );
00058
00059         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00060         _ASSERT( SUCCEEDED(hr) );
00061
00062         // Set the column headers in the results pane
00063         hr = pHeaderCtrl->InsertColumn( 0, L"Rocket Class", 0, MMCLV_AUTO );
00064         _ASSERT( S_OK == hr );
00065         hr = pHeaderCtrl->InsertColumn( 1, L"Rocket Weight", 0, MMCLV_AUTO );
00066         _ASSERT( S_OK == hr );
00067         hr = pHeaderCtrl->InsertColumn( 2, L"Rocket Height", 0, MMCLV_AUTO );
00068         _ASSERT( S_OK == hr );
00069         hr = pHeaderCtrl->InsertColumn( 3, L"Rocket Payload", 0, MMCLV_AUTO );
00070         _ASSERT( S_OK == hr );
00071         hr = pHeaderCtrl->InsertColumn( 4, L"Status", 0, MMCLV_AUTO );
00072         _ASSERT( S_OK == hr );
00073
00074         // insert items here
00075         RESULTDATAITEM rdi;
00076
00077         hr = pResultData->DeleteAllRsltItems();
00078         _ASSERT( SUCCEEDED(hr) );
00079
00080         if (!bExpanded) {
00081             // create the child nodes, then expand them
00082             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00083                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00084                 rdi.mask       = RDI_STR       |   // Displayname is valid
00085                     RDI_IMAGE     |
00086                     RDI_PARAM;        // nImage is valid
00087
00088                 rdi.nImage      = children[n]->GetBitmapIndex();
00089                 rdi.str         = MMC_CALLBACK;
00090                 rdi.nCol        = 0;
00091                 rdi.lParam      = (LPARAM)children[n];
00092
00093                 hr = pResultData->InsertItem( &rdi );
00094
00095                 _ASSERT( SUCCEEDED(hr) );
00096             }
00097         }
00098
00099         pHeaderCtrl->Release();
00100         pResultData->Release();
00101     }
00102
00103     return hr;
00104 }
00105
00106 //==============================================================
00107 //
00108 // CRocket implementation
00109 //
00110 //
00111 CRocket::CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload)
00112 : szName(NULL), lWeight(0), lHeight(0), lPayload(0), iStatus(STOPPED)
00113 {
00114     if (szName) {
00115         this->szName = new _TCHAR[(_tcslen(szName) + 1) * sizeof(_TCHAR)];
00116         _tcscpy(this->szName, szName);
00117     }
00118
00119     this->nId = id;
00120     this->lWeight = lWeight;
00121     this->lHeight = lHeight;
00122     this->lPayload = lPayload;
00123 }
00124
00125 CRocket::~CRocket()
00126 {
00127     if (szName)
00128         delete [] szName;
00129 }
00130
00131 const _TCHAR *CRocket::GetDisplayName(int nCol)
00132 {
00133     const size_t cchBuffer = 128;
00134     static _TCHAR buf[cchBuffer];
00135
00136     // StringCchPrintf and StringCchCopy always null-terminate the destination string.
00137     // However the string may be a truncation of the ideal result (indicated by  return value other than S_OK).
00138
00139     switch (nCol) {
00140     case 0:
00141         StringCchPrintf(buf, cchBuffer, _T("%s (#%d)"), szName ? szName : _T(""), nId);
00142         break;
00143
00144     case 1:
00145         StringCchPrintf(buf, cchBuffer, _T("%ld metric tons"), lWeight);
00146         break;
00147
00148     case 2:
00149         StringCchPrintf(buf, cchBuffer, _T("%ld meters"), lHeight);
00150         break;
00151
00152     case 3:
00153         StringCchPrintf(buf, cchBuffer, _T("%ld kilos"), lPayload);
00154         break;
00155
00156     case 4:
00157         StringCchPrintf(buf, cchBuffer, _T("%s"),
00158             iStatus == RUNNING ? _T("running") :
00159         iStatus == PAUSED ? _T("paused") :
00160         iStatus == STOPPED ? _T("stopped") : _T("unknown"));
00161         break;
00162
00163     }
00164
00165     return buf;
00166 }
00167
00168 HRESULT CRocket::OnRename(LPOLESTR pszNewName)
00169 {
00170     if (szName) {
00171         delete [] szName;
00172         szName = NULL;
00173     }
00174
00175     MAKE_TSTRPTR_FROMWIDE(ptrname, pszNewName);
00176     szName = new _TCHAR[(_tcslen(ptrname) + 1) * sizeof(_TCHAR)];
00177     _tcscpy(szName, ptrname);
00178
00179     return S_OK;
00180 }
00181
00182 HRESULT CRocket::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
00183 {
00184     IConsoleVerb *pConsoleVerb;
00185
00186     HRESULT hr = pConsole->QueryConsoleVerb(&pConsoleVerb);
00187     _ASSERT(SUCCEEDED(hr));
00188
00189     hr = pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, FALSE);
00190     hr = pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, TRUE);
00191
00192     pConsoleVerb->Release();
00193
00194     return S_OK;
00195 }
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/AdvClientdlg.h Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

AdvClientdlg.h

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  AdvClientDlg.h
00006 //
00007 // Description:
00008 //  This file declares the CAdvClientDlg dialog class. It is the main
00009 //    dialog for the tutorial.
00010 //
00011 // Part of: WMI Tutorial #1.
00012 //
00013 // Used by: CAdvClientleApp::InitInstance().
00014 //
00015 // History:
00016 //
00017 // **************************************************************************
00018
00019 #if !defined(AFX_HMMENUMDLG_H__6AC7FBF9_FE04_11D0_AD84_00AA00B8E05A__INCLUDED_)
00020 #define AFX_HMMENUMDLG_H__6AC7FBF9_FE04_11D0_AD84_00AA00B8E05A__INCLUDED_
00021
00022 #if _MSC_VER >= 1000
00023 #pragma once
00024 #endif // _MSC_VER >= 1000
00025
00026 #include <wbemcli.h>     // WMI interface declarations
00027 #include "resource.h"
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CAdvClientDlg dialog
00030 class CAsyncQuerySink;
00031
00032 class CAdvClientDlg : public CDialog
00033 {
00034 // Construction
00035 public:
00036   CAdvClientDlg(CWnd* pParent = NULL);  // standard constructor
00037   virtual ~CAdvClientDlg();
00038
00039 // Dialog Data
00040   //{{AFX_DATA(CAdvClientDlg)
00041   enum { IDD = IDD_SAMPLE_DIALOG };
00042   CButton m_diskDescriptions;
00043   CListBox  m_eventList;
00044   CButton m_perm;
00045   CButton m_temp;
00046   CButton m_addEquipment;
00047   CButton m_enumServicesAsync;
00048   CButton m_enumServices;
00049   CButton m_enumDisks;
00050   CButton m_diskDetails;
00051   CButton m_connect;
00052   CListBox  m_outputList;
00053   CString m_namespace;
00054   //}}AFX_DATA
00055
00056   // ClassWizard generated virtual function overrides
00057   //{{AFX_VIRTUAL(CAdvClientDlg)
00058   protected:
00059   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00060   //}}AFX_VIRTUAL
00061
00062 // Implementation
00063 protected:
00064
00065   // Generated message map functions
00066   //{{AFX_MSG(CAdvClientDlg)
00067   virtual BOOL OnInitDialog();
00068   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00069   afx_msg void OnAddEquipment();
00070   afx_msg void OnConnect();
00071   afx_msg void OnEnumdisks();
00072   afx_msg void OnEnumservices();
00073   afx_msg void OnDiskdetails();
00074   afx_msg void OnEnumservicesasync();
00075   afx_msg void OnRegPerm();
00076   afx_msg void OnRegTemp();
00077   virtual void OnCancel();
00078   afx_msg void OnDiskPropsDescriptions();
00079   //}}AFX_MSG
00080   DECLARE_MESSAGE_MAP()
00081 private:
00082
00083   BOOL m_regPerm, m_regTemp;
00084
00085   CAsyncQuerySink *m_pQueryCallback;
00086   IWbemServices *m_pIWbemServices;
00087   IWbemServices *m_pOfficeService;  //this gets marshalled to the event thread
00088
00089   BOOL EnsureOfficeNamespace(void);
00090   BOOL CheckOfficeNamespace(void);
00091
00092   HRESULT AssociateToMachine(IWbemClassObject *pEquipInst);
00093   HRESULT GetCompSysRef(VARIANT *v);
00094
00095   // event related.
00096     static DWORD WINAPI ThreadProc(LPVOID lpParameter);
00097
00098   IStream * m_pStream;
00099
00100   HANDLE m_ptrReady;    // the thread has done the work.
00101   HANDLE m_stopThread;  // telling the thread to stop.
00102     CRITICAL_SECTION m_critSect;
00103     DWORD m_threadId;
00104     HANDLE m_thread;
00105
00106   void StopThread();
00107   BOOL PermRegistered();
00108   BOOL OnTempRegister();
00109   void OnTempUnregister();
00110   BOOL OnPermRegister();
00111   void OnPermUnregister();
00112
00113   static STDMETHODIMP DisplayEvents(CAdvClientDlg *pThis, LONG lObjectCount,  IWbemClassObject **ppObjArray);
00114
00115   // SampleViewer.mof 'creates' the consumer.
00116   BOOL GetConsumer(IWbemClassObject **pConsumer);
00117   BOOL AddFilter(IWbemClassObject **pFilter);
00118   BOOL AddBinding(IWbemClassObject *pConsumer,
00119           IWbemClassObject *pFilter);
00120
00121 };
00122 LPWSTR ValueToString(VARIANT *pValue, WCHAR **pbuf);
00123 LPCTSTR ErrorString(SCODE sc);
00124
00125
00126 //{{AFX_INSERT_LOCATION}}
00127 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00128
00129 #endif // !defined(AFX_HMMENUMDLG_H__6AC7FBF9_FE04_11D0_AD84_00AA00B8E05A__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/Account.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

Account.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      account.cpp
00003   Summary:   Implementation of DLL Exports
00004 -----------------------------------------------------------------------------
00005
00006 This file is part of the Microsoft COM+ Samples.
00007
00008 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00009
00010 This source code is intended only as a supplement to Microsoft
00011 Development Tools and/or on-line documentation. See these other
00012 materials for detailed information regarding Microsoft code samples.
00013
00014 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 PARTICULAR PURPOSE.
00018
00019 ==========================================================================+*/
00020
00021
00022 #include "stdafx.h"
00023 #include "resource.h"
00024 #include "initguid.h"
00025 #include "Account.h"
00026 #include <comsvcs.h>
00027 #include "CAccount.h"
00028 #include "MvMoney.h"
00029
00030 #define IID_DEFINED
00031 #include "Account_i.c"
00032 #include "GetRec.h"
00033 #include "UpdRec.h"
00034
00035
00036 CComModule _Module;
00037
00038 BEGIN_OBJECT_MAP(ObjectMap)
00039   OBJECT_ENTRY(CLSID_CUpdateReceipt, CUpdateReceipt)
00040   OBJECT_ENTRY(CLSID_CGetReceipt, CGetReceipt)
00041   OBJECT_ENTRY(CLSID_CAccount, CAccount)
00042   OBJECT_ENTRY(CLSID_CMoveMoney, CMoveMoney)
00043 END_OBJECT_MAP()
00044
00045 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00046   Function: DllMain
00047   Summary:  DLL Entry Point
00048 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00049 extern "C"
00050 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00051 {
00052   lpReserved;
00053 #ifdef _MERGE_PROXYSTUB
00054   if (!PrxDllMain(hInstance, dwReason, lpReserved))
00055     return FALSE;
00056 #endif
00057   if (dwReason == DLL_PROCESS_ATTACH)
00058   {
00059     _Module.Init(ObjectMap, hInstance);
00060     DisableThreadLibraryCalls(hInstance);
00061
00062
00063   }
00064   else if (dwReason == DLL_PROCESS_DETACH)
00065     _Module.Term();
00066   return TRUE;    // ok
00067 }
00068
00069
00070 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00071   Function: DllCanUnloadNow
00072   Summary:  Used to determine whether the DLL can be unloaded by COM
00073 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00074 STDAPI DllCanUnloadNow(void)
00075 {
00076   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00077 }
00078
00079 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00080   Function: DllGetClassObject
00081   Summary:  Returns a class factory to create an object of the requested type
00082 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00083 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00084 {
00085   return _Module.GetClassObject(rclsid, riid, ppv);
00086 }
00087
00088 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00089   Function: DllRegisterServer
00090   Summary:  DllRegisterServer - Adds entries to the system registry
00091 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00092 STDAPI DllRegisterServer(void)
00093 {
00094   // registers object, typelib and all interfaces in typelib
00095   return _Module.RegisterServer(TRUE);
00096 }
00097
00098 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00099   Function: DllUnregisterServer
00100   Summary:  DllUnregisterServer - Removes entries from the system registry
00101 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00102 STDAPI DllUnregisterServer(void)
00103 {
00104   _Module.UnregisterServer();
00105   return S_OK;
00106 }
00107
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/compose.cpp Source File

  • WinUI
  • TSFmark

compose.cpp

Go to the documentation of this file.
00001 //
00002 // compose.cpp
00003 //
00004 // Composition code.
00005 //
00006
00007 #include "globals.h"
00008 #include "mark.h"
00009 #include "editsess.h"
00010
00011 class CCompositionEditSession : public CEditSessionBase
00012 {
00013 public:
00014     CCompositionEditSession(ITfContext *pContext, CMarkTextService *pMark) : CEditSessionBase(pContext)
00015     {
00016         _pMark = pMark;
00017         _pMark->AddRef();
00018     }
00019     ~CCompositionEditSession()
00020     {
00021         _pMark->Release();
00022     }
00023
00024     // ITfEditSession
00025     STDMETHODIMP DoEditSession(TfEditCookie ec);
00026
00027 private:
00028     CMarkTextService *_pMark;
00029 };
00030
00031 class CTerminateCompositionEditSession : public CEditSessionBase
00032 {
00033 public:
00034     CTerminateCompositionEditSession(CMarkTextService *pMark, ITfContext *pContext) : CEditSessionBase(pContext)
00035     {
00036         _pMark = pMark;
00037         _pMark->AddRef();
00038     }
00039     ~CTerminateCompositionEditSession()
00040     {
00041         _pMark->Release();
00042     }
00043
00044     // ITfEditSession
00045     STDMETHODIMP DoEditSession(TfEditCookie ec)
00046     {
00047         _pMark->_TerminateComposition(ec);
00048         return S_OK;
00049     }
00050
00051 private:
00052     CMarkTextService *_pMark;
00053 };
00054
00055 //+---------------------------------------------------------------------------
00056 //
00057 // _TerminateCompositionInContext
00058 //
00059 //----------------------------------------------------------------------------
00060
00061 void CMarkTextService::_TerminateCompositionInContext(ITfContext *pContext)
00062 {
00063     CTerminateCompositionEditSession *pEditSession;
00064     HRESULT hr;
00065
00066     if (pEditSession = new CTerminateCompositionEditSession(this, pContext))
00067     {
00068         pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr);
00069         pEditSession->Release();
00070     }
00071 }
00072
00073 //+---------------------------------------------------------------------------
00074 //
00075 // _Menu_OnComposition
00076 //
00077 // Callback for the "Start/End Composition" menu item.
00078 // If we have a composition, end it.  Otherwise start a new composition over
00079 // the selection of the current focus context.
00080 //----------------------------------------------------------------------------
00081
00082 /* static */
00083 void CMarkTextService::_Menu_OnComposition(CMarkTextService *_this)
00084 {
00085     ITfDocumentMgr *pFocusDoc;
00086     ITfContext *pContext;
00087     CCompositionEditSession *pCompositionEditSession;
00088     HRESULT hr;
00089
00090     // get the focus document
00091     if (_this->_pThreadMgr->GetFocus(&pFocusDoc) != S_OK)
00092         return;
00093
00094     // we want the topmost context, since the main doc context could be
00095     // superceded by a modal tip context
00096     if (pFocusDoc->GetTop(&pContext) != S_OK)
00097     {
00098         pContext = NULL;
00099         goto Exit;
00100     }
00101
00102     if (pCompositionEditSession = new CCompositionEditSession(pContext, _this))
00103     {
00104         // we need a document write lock
00105         // the CCompositionEditSession will do all the work when the
00106         // CCompositionEditSession::DoEditSession method is called by the context
00107         pContext->RequestEditSession(_this->_tfClientId, pCompositionEditSession, TF_ES_READWRITE | TF_ES_ASYNCDONTCARE, &hr);
00108
00109         pCompositionEditSession->Release();
00110     }
00111
00112 Exit:
00113     SafeRelease(pContext);
00114     pFocusDoc->Release();
00115 }
00116
00117 //+---------------------------------------------------------------------------
00118 //
00119 // DoEditSession
00120 //
00121 //----------------------------------------------------------------------------
00122
00123 STDAPI CCompositionEditSession::DoEditSession(TfEditCookie ec)
00124 {
00125     ITfInsertAtSelection *pInsertAtSelection;
00126     ITfContextComposition *pContextComposition;
00127     ITfComposition *pComposition;
00128     ITfRange *pRangeComposition;
00129     ITfRange *pRangeInsert;
00130     ITfContext *pCompositionContext;
00131     HRESULT hr;
00132     BOOL fEqualContexts;
00133
00134     // get an interface on the context we can use to deal with compositions
00135     if (_pContext->QueryInterface(IID_ITfContextComposition, (void **)&pContextComposition) != S_OK)
00136         return E_FAIL;
00137
00138     hr = E_FAIL;
00139
00140     pInsertAtSelection = NULL;
00141
00142     if (_pMark->_IsComposing())
00143     {
00144         // we have a composition, let's terminate it
00145
00146         // it's possible our current composition is in another context...let's find out
00147         fEqualContexts = TRUE;
00148         if (_pMark->_GetComposition()->GetRange(&pRangeComposition) == S_OK)
00149         {
00150             if (pRangeComposition->GetContext(&pCompositionContext) == S_OK)
00151             {
00152                 fEqualContexts = IsEqualUnknown(pCompositionContext, _pContext);
00153                 if (!fEqualContexts)
00154                 {
00155                     // need an edit session in the composition context
00156                     _pMark->_TerminateCompositionInContext(pCompositionContext);
00157                 }
00158                 pCompositionContext->Release();
00159             }
00160             pRangeComposition->Release();
00161         }
00162
00163         // if the composition is in pContext, we already have an edit cookie
00164         if (fEqualContexts)
00165         {
00166             _pMark->_TerminateComposition(ec);
00167         }
00168     }
00169     else
00170     {
00171         // let's start a new composition over the current selection
00172         // this is totally contrived, a real text service would have
00173         // some meaningful logic to trigger this
00174
00175         // first, test where a keystroke would go in the document if we did an insert
00176         // we need a special interface to insert text at the selection
00177         if (_pContext->QueryInterface(IID_ITfInsertAtSelection, (void **)&pInsertAtSelection) != S_OK)
00178         {
00179             pInsertAtSelection = NULL;
00180             goto Exit;
00181         }
00182
00183         if (pInsertAtSelection->InsertTextAtSelection(ec, TF_IAS_QUERYONLY, NULL, 0, &pRangeInsert) != S_OK)
00184             goto Exit;
00185
00186         // start the composition
00187         if (pContextComposition->StartComposition(ec, pRangeInsert, _pMark, &pComposition) != S_OK)
00188         {
00189             pComposition = NULL;
00190         }
00191
00192         pRangeInsert->Release();
00193
00194         // _pComposition may be NULL even if StartComposition return S_OK, this mean the application
00195         // rejected the composition
00196
00197         if (pComposition != NULL)
00198         {
00199             _pMark->_SetComposition(pComposition);
00200             // underline the composition text to give the user some feedback UI
00201             _pMark->_SetCompositionDisplayAttributes(ec);
00202         }
00203     }
00204
00205     // if we make it here, we've succeeded
00206     hr = S_OK;
00207
00208 Exit:
00209     SafeRelease(pInsertAtSelection);
00210     pContextComposition->Release();
00211
00212     return hr;
00213 }
00214
00215 //+---------------------------------------------------------------------------
00216 //
00217 // OnCompositionTerminated
00218 //
00219 // Callback for ITfCompositionSink.  The system calls this method whenever
00220 // someone other than this service ends a composition.
00221 //----------------------------------------------------------------------------
00222
00223 STDAPI CMarkTextService::OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition)
00224 {
00225     // we already have the composition cached, so we can ignore pComposition...
00226
00227     // all this service wants to do is clear the display property
00228     _ClearCompositionDisplayAttributes(ecWrite);
00229
00230     // releae our cached composition
00231     SafeReleaseClear(_pComposition);
00232
00233     return S_OK;
00234 }
00235
00236 //+---------------------------------------------------------------------------
00237 //
00238 // _ClearCompositionDisplayAttributes
00239 //
00240 //----------------------------------------------------------------------------
00241
00242 void CMarkTextService::_ClearCompositionDisplayAttributes(TfEditCookie ec)
00243 {
00244     ITfRange *pRangeComposition;
00245     ITfContext *pContext;
00246     ITfProperty *pDisplayAttributeProperty;
00247
00248     // we need a range and the context it lives in
00249     if (_pComposition->GetRange(&pRangeComposition) != S_OK)
00250         return;
00251
00252     if (pRangeComposition->GetContext(&pContext) != S_OK)
00253     {
00254         pContext = NULL;
00255         goto Exit;
00256     }
00257
00258     // get our the display attribute property
00259     if (pContext->GetProperty(GUID_PROP_ATTRIBUTE, &pDisplayAttributeProperty) != S_OK)
00260         goto Exit;
00261
00262     // clear the value over the range
00263     pDisplayAttributeProperty->Clear(ec, pRangeComposition);
00264
00265     pDisplayAttributeProperty->Release();
00266
00267 Exit:
00268     pRangeComposition->Release();
00269     SafeRelease(pContext);
00270 }
00271
00272 //+---------------------------------------------------------------------------
00273 //
00274 // _SetCompositionDisplayAttributes
00275 //
00276 //----------------------------------------------------------------------------
00277
00278 BOOL CMarkTextService::_SetCompositionDisplayAttributes(TfEditCookie ec)
00279 {
00280     ITfRange *pRangeComposition;
00281     ITfContext *pContext;
00282     ITfProperty *pDisplayAttributeProperty;
00283     VARIANT var;
00284     HRESULT hr;
00285
00286     // we need a range and the context it lives in
00287     if (_pComposition->GetRange(&pRangeComposition) != S_OK)
00288         return FALSE;
00289
00290     hr = E_FAIL;
00291
00292     if (pRangeComposition->GetContext(&pContext) != S_OK)
00293     {
00294         pContext = NULL;
00295         goto Exit;
00296     }
00297
00298     // get our the display attribute property
00299     if (pContext->GetProperty(GUID_PROP_ATTRIBUTE, &pDisplayAttributeProperty) != S_OK)
00300         goto Exit;
00301
00302     // set the value over the range
00303     // the application will use this guid atom to lookup the acutal rendering information
00304     var.vt = VT_I4; // we're going to set a TfGuidAtom
00305     var.lVal = _gaDisplayAttribute; // our cached guid atom for c_guidMarkDisplayAttribute
00306
00307     hr = pDisplayAttributeProperty->SetValue(ec, pRangeComposition, &var);
00308
00309     pDisplayAttributeProperty->Release();
00310
00311 Exit:
00312     pRangeComposition->Release();
00313     SafeRelease(pContext);
00314     return (hr == S_OK);
00315 }
00316
00317 //+---------------------------------------------------------------------------
00318 //
00319 // _InitDisplayAttributeGuidAtom
00320 //
00321 // Because it's expensive to map our display attribute GUID to a TSF
00322 // TfGuidAtom, we do it once when Activate is called.
00323 //----------------------------------------------------------------------------
00324
00325 BOOL CMarkTextService::_InitDisplayAttributeGuidAtom()
00326 {
00327     ITfCategoryMgr *pCategoryMgr;
00328     HRESULT hr;
00329
00330     if (CoCreateInstance(CLSID_TF_CategoryMgr,
00331                          NULL,
00332                          CLSCTX_INPROC_SERVER,
00333                          IID_ITfCategoryMgr,
00334                          (void**)&pCategoryMgr) != S_OK)
00335     {
00336         return FALSE;
00337     }
00338
00339     hr = pCategoryMgr->RegisterGUID(c_guidMarkDisplayAttribute, &_gaDisplayAttribute);
00340
00341     pCategoryMgr->Release();
00342
00343     return (hr == S_OK);
00344 }
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/VCAcct/getreceipt.h Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • VCAcct

getreceipt.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: GetReceipt.h
00003 //
00004 // Description: Declaration of GetReceipt
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021 #if !defined(AFX_GETRECEIPT_H__A81260B3_DDC8_11D0_B5A0_00C04FB957D8__INCLUDED_)
00022 #define AFX_GETRECEIPT_H__A81260B3_DDC8_11D0_B5A0_00C04FB957D8__INCLUDED_
00023
00024 #if _MSC_VER >= 1000
00025 #pragma once
00026 #endif // _MSC_VER >= 1000
00027
00028 #include "resource.h"       // main symbols
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // CGetReceipt
00032
00033 class CGetReceipt :
00034   public IDispatchImpl<IGetReceipt, &IID_IGetReceipt, &LIBID_ACCOUNT>,
00035   public ISupportErrorInfo,
00036   public CComObjectRoot,
00037   public CComCoClass<CGetReceipt,&CLSID_CGetReceipt>
00038 {
00039 public:
00040   CGetReceipt() {}
00041 BEGIN_COM_MAP(CGetReceipt)
00042   COM_INTERFACE_ENTRY(IDispatch)
00043   COM_INTERFACE_ENTRY(IGetReceipt)
00044   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00045 END_COM_MAP()
00046 //DECLARE_NOT_AGGREGATABLE(CGetReceipt)
00047 // Remove the comment from the line above if you don't want your object to
00048 // support aggregation.
00049
00050 DECLARE_REGISTRY_RESOURCEID(IDR_GetReceipt)
00051 // ISupportsErrorInfo
00052   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00053
00054 // IGetReceipt
00055 public:
00056   STDMETHOD (GetNextReceipt) (OUT long* plReceiptNo);
00057 };
00058
00059 #endif // !defined(AFX_GETRECEIPT_H__A81260B3_DDC8_11D0_B5A0_00C04FB957D8__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCodeGrid Member List

This is the complete list of members for CCodeGrid, including all inherited members.
_cCol | CGrid | [protected]
_cDigits | CCodeGrid | [protected]
_cRow | CGrid | [protected]
_font | CTextGrid | [protected]
_iEltOffset | CTextGrid | [protected]
_pCharUsed | CTextGrid | [protected]
_ptOrg | CTextGrid | [protected]
_size | CGrid | [protected]
_szFormat | CCodeGrid | [protected]
CCodeGrid(UINT cCol, UINT cRow, SIZE size, UINT iEltOffset=0) | CCodeGrid |
CGrid() | CGrid | [inline]
CTextGrid() | CTextGrid | [inline]
Detach() | CGrid |
Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject) | CGrid |
DrawElement(CCanvas &canvas, COORD x, COORD y, UINT i, UINT j) | CCodeGrid | [virtual]
FindBehavior(BSTR bstrBehavior, BSTR bstrBehaviorUrl, IElementBehaviorSite *pSite, IElementBehavior **ppBehavior) | CGrid |
get_GridSize(long *pVal) | CGrid |
GetPainterInfo(HTML_PAINTER_INFO *pInfo) | CGrid |
GridSize([out, retval] long *pVal) | IGrid |
GridSize([in] long newVal) | IGrid |
Hittest(POINT pt, POINT ptTest) | CTextGrid |
HitTestPoint(POINT pt, BOOL *pbHit, LONG *plPartID) | CGrid |
Init(IElementBehaviorSite *pBehaviorSite) | CGrid |
m_lClientLeft | CGrid |
m_lClientTop | CGrid |
m_lGridSize | CGrid |
m_spPaintSite | CGrid |
m_spSite | CGrid |
Notify(LONG lEvent, VARIANT *pVar) | CGrid |
OnResize(SIZE size) | CGrid |
Paint(CCanvas &canvas, RECT rc, POINT pt) | CTextGrid | [virtual]
put_GridSize(long newVal) | CGrid |
SetCharTable() | CTextGrid |
SetFont(HFONT hfont) | CTextGrid |
SetFormat(UINT fuFormat=HEXADECIMAL, UINT cDigits=1) | CCodeGrid |
SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions) | CGrid |
SetTextOrg() | CTextGrid | [inline]
SetTextOrg(COORD x, COORD y) | CTextGrid | [inline]
Trace(WCHAR *message) | CGrid | [inline]
~CTextGrid() | CTextGrid | [inline]
Generated on Wed Nov 13 2024 16:55:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagVIEWLIST Member List

This is the complete list of members for tagVIEWLIST, including all inherited members.
pNext | tagVIEWLIST
pView | tagVIEWLIST
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/http/server/main.c Source File

  • NetDS
  • http
  • server

main.c

Go to the documentation of this file.
00001 /*++
00002  Copyright (c) 2002 - 2002 Microsoft Corporation.  All Rights Reserved.
00003
00004  THIS CODE AND INFORMATION IS PROVIDED "AS-IS" WITHOUT WARRANTY OF
00005  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00006  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00007  PARTICULAR PURPOSE.
00008
00009  THIS CODE IS NOT SUPPORTED BY MICROSOFT.
00010
00011 --*/
00012
00013 #include "precomp.h"
00014
00015 //
00016 // Macros.
00017 //
00018 #define INITIALIZE_HTTP_RESPONSE( resp, status, reason )                    \
00019     do                                                                      \
00020     {                                                                       \
00021         RtlZeroMemory( (resp), sizeof(*(resp)) );                           \
00022         (resp)->StatusCode = (status);                                      \
00023         (resp)->pReason = (reason);                                         \
00024         (resp)->ReasonLength = (USHORT) strlen(reason);                     \
00025     } while (FALSE)
00026
00027
00028
00029 #define ADD_KNOWN_HEADER(Response, HeaderId, RawValue)                      \
00030     do                                                                      \
00031     {                                                                       \
00032         (Response).Headers.KnownHeaders[(HeaderId)].pRawValue = (RawValue); \
00033         (Response).Headers.KnownHeaders[(HeaderId)].RawValueLength =        \
00034             (USHORT) strlen(RawValue);                                      \
00035     } while(FALSE)
00036
00037 #define ALLOC_MEM(cb) HeapAlloc(GetProcessHeap(), 0, (cb))
00038 #define FREE_MEM(ptr) HeapFree(GetProcessHeap(), 0, (ptr))
00039
00040 //
00041 // Prototypes.
00042 //
00043 DWORD
00044 DoReceiveRequests(
00045     HANDLE hReqQueue
00046     );
00047
00048 DWORD
00049 SendHttpResponse(
00050     IN HANDLE        hReqQueue,
00051     IN PHTTP_REQUEST pRequest,
00052     IN USHORT        StatusCode,
00053     IN PSTR          pReason,
00054     IN PSTR          pEntity
00055     );
00056
00057 DWORD
00058 SendHttpPostResponse(
00059     IN HANDLE        hReqQueue,
00060     IN PHTTP_REQUEST pRequest
00061     );
00062
00063 /***************************************************************************++
00064
00065 Routine Description:
00066     main routine.
00067
00068 Arguments:
00069     argc - # of command line arguments.
00070     argv - Arguments.
00071
00072 Return Value:
00073     Success/Failure.
00074
00075 --***************************************************************************/
00076 int __cdecl wmain(
00077         int argc,
00078         wchar_t * argv[]
00079         )
00080 {
00081     ULONG           retCode;
00082     int             i;
00083     HANDLE          hReqQueue      = NULL;
00084     int             UrlAdded       = 0;
00085     HTTPAPI_VERSION HttpApiVersion = HTTPAPI_VERSION_1;
00086
00087     if (argc < 2)
00088     {
00089         wprintf(L"%ws: <Url1> [Url2] ... \n", argv[0]);
00090         return -1;
00091     }
00092
00093     //
00094     // Initialize HTTP APIs.
00095     //
00096     retCode = HttpInitialize(
00097                 HttpApiVersion,
00098                 HTTP_INITIALIZE_SERVER,    // Flags
00099                 NULL                       // Reserved
00100                 );
00101
00102     if (retCode != NO_ERROR)
00103     {
00104         wprintf(L"HttpInitialize failed with %lu \n", retCode);
00105         return retCode;
00106     }
00107
00108     //
00109     // Create a Request Queue Handle
00110     //
00111     retCode = HttpCreateHttpHandle(
00112                 &hReqQueue,        // Req Queue
00113                 0                  // Reserved
00114                 );
00115
00116     if (retCode != NO_ERROR)
00117     {
00118         wprintf(L"HttpCreateHttpHandle failed with %lu \n", retCode);
00119         goto CleanUp;
00120     }
00121
00122     //
00123     // The command line arguments represent URIs that we want to listen on.
00124     // We will call HttpAddUrl for each of these URIs.
00125     //
00126     // The URI is a fully qualified URI and MUST include the terminating '/'
00127     //
00128     for (i = 1; i < argc; i++)
00129     {
00130         wprintf(
00131           L"we are listening for requests on the following url: %s\n",
00132           argv[i]);
00133
00134         retCode = HttpAddUrl(
00135                     hReqQueue,    // Req Queue
00136                     argv[i],      // Fully qualified URL
00137                     NULL          // Reserved
00138                     );
00139
00140         if (retCode != NO_ERROR)
00141         {
00142             wprintf(L"HttpAddUrl failed with %lu \n", retCode);
00143             goto CleanUp;
00144         }
00145         else
00146         {
00147             //
00148             // Keep track of the URLs that we've currently added.
00149             //
00150             UrlAdded ++;
00151         }
00152     }
00153
00154     // Loop while receiving requests
00155     for(;;)
00156     {
00157         retCode = DoReceiveRequests(hReqQueue);
00158
00159         if(NO_ERROR == retCode)
00160         {
00161             wprintf(
00162                 L"DoReceiveRequests failed with %lu \n",
00163                 retCode
00164                 );
00165
00166             break;
00167         }
00168
00169     } // CTRL C to break out of loop
00170
00171 CleanUp:
00172
00173     //
00174     // Call HttpRemoveUrl for all the URLs that we added.
00175     //
00176     for(i=1; i<=UrlAdded; i++)
00177     {
00178         HttpRemoveUrl(
00179               hReqQueue,     // Req Queue
00180               argv[i]        // Fully qualified URL
00181               );
00182     }
00183
00184     //
00185     // Close the Request Queue handle.
00186     //
00187     if(hReqQueue)
00188     {
00189         CloseHandle(hReqQueue);
00190     }
00191
00192     //
00193     // Call HttpTerminate.
00194     //
00195     HttpTerminate(HTTP_INITIALIZE_SERVER, NULL);
00196
00197     return retCode;
00198 }
00199
00200 /***************************************************************************++
00201
00202 Routine Description:
00203     The routine to receive a request. This routine calls the corresponding
00204     routine to deal with the response.
00205
00206 Arguments:
00207     hReqQueue - Handle to the request queue.
00208
00209 Return Value:
00210     Success/Failure.
00211
00212 --***************************************************************************/
00213 DWORD
00214 DoReceiveRequests(
00215     IN HANDLE hReqQueue
00216     )
00217 {
00218     ULONG              result;
00219     HTTP_REQUEST_ID    requestId;
00220     DWORD              bytesRead;
00221     PHTTP_REQUEST      pRequest;
00222     PCHAR              pRequestBuffer;
00223     ULONG              RequestBufferLength;
00224
00225     //
00226     // Allocate a 2K buffer. Should be good for most requests, we'll grow
00227     // this if required. We also need space for a HTTP_REQUEST structure.
00228     //
00229     RequestBufferLength = sizeof(HTTP_REQUEST) + 2048;
00230     pRequestBuffer      = ALLOC_MEM( RequestBufferLength );
00231
00232     if (pRequestBuffer == NULL)
00233     {
00234         return ERROR_NOT_ENOUGH_MEMORY;
00235     }
00236
00237     pRequest = (PHTTP_REQUEST)pRequestBuffer;
00238
00239     //
00240     // Wait for a new request -- This is indicated by a NULL request ID.
00241     //
00242
00243     HTTP_SET_NULL_ID( &requestId );
00244
00245     for(;;)
00246     {
00247         RtlZeroMemory(pRequest, RequestBufferLength);
00248
00249         result = HttpReceiveHttpRequest(
00250                     hReqQueue,          // Req Queue
00251                     requestId,          // Req ID
00252                     0,                  // Flags
00253                     pRequest,           // HTTP request buffer
00254                     RequestBufferLength,// req buffer length
00255                     &bytesRead,         // bytes received
00256                     NULL                // LPOVERLAPPED
00257                     );
00258
00259         if(NO_ERROR == result)
00260         {
00261             //
00262             // Worked!
00263             //
00264             switch(pRequest->Verb)
00265             {
00266                 case HttpVerbGET:
00267                     wprintf(L"Got a GET request for %ws \n",
00268                             pRequest->CookedUrl.pFullUrl);
00269
00270                     result = SendHttpResponse(
00271                                 hReqQueue,
00272                                 pRequest,
00273                                 200,
00274                                 "OK",
00275                                 "Hey! You hit the server \r\n"
00276                                 );
00277                     break;
00278
00279                 case HttpVerbPOST:
00280
00281                     wprintf(L"Got a POST request for %ws \n",
00282                             pRequest->CookedUrl.pFullUrl);
00283
00284                     result = SendHttpPostResponse(hReqQueue, pRequest);
00285                     break;
00286
00287                 default:
00288                     wprintf(L"Got a unknown request for %ws \n",
00289                             pRequest->CookedUrl.pFullUrl);
00290
00291                     result = SendHttpResponse(
00292                                 hReqQueue,
00293                                 pRequest,
00294                                 503,
00295                                 "Not Implemented",
00296                                 NULL
00297                                 );
00298                     break;
00299             }
00300
00301             if(result != NO_ERROR)
00302             {
00303                 break;
00304             }
00305
00306             //
00307             // Reset the Request ID so that we pick up the next request.
00308             //
00309             HTTP_SET_NULL_ID( &requestId );
00310         }
00311         else if(result == ERROR_MORE_DATA)
00312         {
00313             //
00314             // The input buffer was too small to hold the request headers
00315             // We have to allocate more buffer & call the API again.
00316             //
00317             // When we call the API again, we want to pick up the request
00318             // that just failed. This is done by passing a RequestID.
00319             //
00320             // This RequestID is picked from the old buffer.
00321             //
00322             requestId = pRequest->RequestId;
00323
00324             //
00325             // Free the old buffer and allocate a new one.
00326             //
00327             RequestBufferLength = bytesRead;
00328             FREE_MEM( pRequestBuffer );
00329             pRequestBuffer = ALLOC_MEM( RequestBufferLength );
00330
00331             if (pRequestBuffer == NULL)
00332             {
00333                 result = ERROR_NOT_ENOUGH_MEMORY;
00334                 break;
00335             }
00336
00337             pRequest = (PHTTP_REQUEST)pRequestBuffer;
00338
00339         }
00340         else if(ERROR_CONNECTION_INVALID == result &&
00341                 !HTTP_IS_NULL_ID(&requestId))
00342         {
00343             // The TCP connection got torn down by the peer when we were
00344             // trying to pick up a request with more buffer. We'll just move
00345             // onto the next request.
00346
00347             HTTP_SET_NULL_ID( &requestId );
00348         }
00349         else
00350         {
00351             break;
00352         }
00353
00354     } // for(;;)
00355
00356     if(pRequestBuffer)
00357     {
00358         FREE_MEM( pRequestBuffer );
00359     }
00360
00361     return result;
00362 }
00363
00364 /***************************************************************************++
00365
00366 Routine Description:
00367     The routine sends a HTTP response.
00368
00369 Arguments:
00370     hReqQueue     - Handle to the request queue.
00371     pRequest      - The parsed HTTP request.
00372     StatusCode    - Response Status Code.
00373     pReason       - Response reason phrase.
00374     pEntityString - Response entity body.
00375
00376 Return Value:
00377     Success/Failure.
00378
00379 --***************************************************************************/
00380 DWORD
00381 SendHttpResponse(
00382     IN HANDLE        hReqQueue,
00383     IN PHTTP_REQUEST pRequest,
00384     IN USHORT        StatusCode,
00385     IN PSTR          pReason,
00386     IN PSTR          pEntityString
00387     )
00388 {
00389     HTTP_RESPONSE   response;
00390     HTTP_DATA_CHUNK dataChunk;
00391     DWORD           result;
00392     DWORD           bytesSent;
00393
00394     //
00395     // Initialize the HTTP response structure.
00396     //
00397     INITIALIZE_HTTP_RESPONSE(&response, StatusCode, pReason);
00398
00399     //
00400     // Add a known header.
00401     //
00402     ADD_KNOWN_HEADER(response, HttpHeaderContentType, "text/html");
00403
00404     if(pEntityString)
00405     {
00406         //
00407         // Add an entity chunk
00408         //
00409         dataChunk.DataChunkType           = HttpDataChunkFromMemory;
00410         dataChunk.FromMemory.pBuffer      = pEntityString;
00411         dataChunk.FromMemory.BufferLength = (ULONG) strlen(pEntityString);
00412
00413         response.EntityChunkCount         = 1;
00414         response.pEntityChunks            = &dataChunk;
00415     }
00416
00417     //
00418     // Since we are sending all the entity body in one call, we don't have
00419     // to specify the Content-Length.
00420     //
00421
00422     result = HttpSendHttpResponse(
00423                     hReqQueue,           // ReqQueueHandle
00424                     pRequest->RequestId, // Request ID
00425                     0,                   // Flags
00426                     &response,           // HTTP response
00427                     NULL,                // pReserved1
00428                     &bytesSent,          // bytes sent   (OPTIONAL)
00429                     NULL,                // pReserved2   (must be NULL)
00430                     0,                   // Reserved3    (must be 0)
00431                     NULL,                // LPOVERLAPPED (OPTIONAL)
00432                     NULL                 // pReserved4   (must be NULL)
00433                     );
00434
00435     if(result != NO_ERROR)
00436     {
00437         wprintf(L"HttpSendHttpResponse failed with %lu \n", result);
00438     }
00439
00440     return result;
00441 }
00442
00443 /***************************************************************************++
00444
00445 Routine Description:
00446     The routine sends a HTTP response after reading the entity body.
00447
00448 Arguments:
00449     hReqQueue     - Handle to the request queue.
00450     pRequest      - The parsed HTTP request.
00451
00452 Return Value:
00453     Success/Failure.
00454
00455 --***************************************************************************/
00456 DWORD
00457 SendHttpPostResponse(
00458     IN HANDLE        hReqQueue,
00459     IN PHTTP_REQUEST pRequest
00460     )
00461 {
00462     HTTP_RESPONSE   response;
00463     DWORD           result;
00464     DWORD           bytesSent;
00465     PUCHAR          pEntityBuffer;
00466     ULONG           EntityBufferLength;
00467     ULONG           BytesRead;
00468     ULONG           TempFileBytesWritten;
00469     HANDLE          hTempFile;
00470     TCHAR           szTempName[MAX_PATH + 1];
00471 #define MAX_ULONG_STR ((ULONG) sizeof("4294967295"))
00472     CHAR            szContentLength[MAX_ULONG_STR];
00473     HTTP_DATA_CHUNK dataChunk;
00474     ULONG           TotalBytesRead = 0;
00475
00476     BytesRead  = 0;
00477     hTempFile  = INVALID_HANDLE_VALUE;
00478
00479     //
00480     // Allocate some space for an entity buffer. We'll grow this on demand.
00481     //
00482     EntityBufferLength = 2048;
00483     pEntityBuffer      = ALLOC_MEM( EntityBufferLength );
00484
00485     if (pEntityBuffer == NULL)
00486     {
00487         result = ERROR_NOT_ENOUGH_MEMORY;
00488         wprintf(L"Insufficient resources \n");
00489         goto Done;
00490     }
00491
00492     //
00493     // Initialize the HTTP response structure.
00494     //
00495     INITIALIZE_HTTP_RESPONSE(&response, 200, "OK");
00496
00497     //
00498     // For POST, we'll echo back the entity that we got from the client.
00499     //
00500     // NOTE: If we had passed the HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY
00501     //       flag with HttpReceiveHttpRequest(), the entity would have
00502     //       been a part of HTTP_REQUEST (using the pEntityChunks field).
00503     //       Since we have not passed that flag, we can be assured that
00504     //       there are no entity bodies in HTTP_REQUEST.
00505     //
00506
00507     if(pRequest->Flags & HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS)
00508     {
00509         // The entity body is send over multiple calls. Let's collect all
00510         // of these in a file & send it back. We'll create a temp file
00511         //
00512
00513         if(GetTempFileName(
00514                 L".",
00515                 L"New",
00516                 0,
00517                 szTempName
00518                 ) == 0)
00519         {
00520             result = GetLastError();
00521             wprintf(L"GetTempFileName failed with %lu \n", result);
00522             goto Done;
00523         }
00524
00525         hTempFile = CreateFile(
00526                         szTempName,
00527                         GENERIC_READ | GENERIC_WRITE,
00528                         0,                             // don't share.
00529                         NULL,                          // no security descriptor
00530                         CREATE_ALWAYS,                 // overrwrite existing
00531                         FILE_ATTRIBUTE_NORMAL,         // normal file.
00532                         NULL
00533                         );
00534
00535         if(hTempFile == INVALID_HANDLE_VALUE)
00536         {
00537             result = GetLastError();
00538             wprintf(L"Could not create temporary file. Error %lu \n", result);
00539             goto Done;
00540         }
00541
00542         do
00543         {
00544             //
00545             // Read the entity chunk from the request.
00546             //
00547             BytesRead = 0;
00548             result = HttpReceiveRequestEntityBody(
00549                         hReqQueue,
00550                         pRequest->RequestId,
00551                         0,
00552                         pEntityBuffer,
00553                         EntityBufferLength,
00554                         &BytesRead,
00555                         NULL
00556                         );
00557
00558             switch(result)
00559             {
00560                 case NO_ERROR:
00561
00562                     if(BytesRead != 0)
00563                     {
00564                         TotalBytesRead += BytesRead;
00565                         WriteFile(
00566                                 hTempFile,
00567                                 pEntityBuffer,
00568                                 BytesRead,
00569                                 &TempFileBytesWritten,
00570                                 NULL
00571                                 );
00572                     }
00573                     break;
00574
00575                 case ERROR_HANDLE_EOF:
00576
00577                     //
00578                     // We have read the last request entity body. We can send
00579                     // back a response.
00580                     //
00581                     // To illustrate entity sends via
00582                     // HttpSendResponseEntityBody, we will send the response
00583                     // over multiple calls. This is achieved by passing the
00584                     // HTTP_SEND_RESPONSE_FLAG_MORE_DATA flag.
00585
00586                     if(BytesRead != 0)
00587                     {
00588                         TotalBytesRead += BytesRead;
00589                         WriteFile(
00590                                 hTempFile,
00591                                 pEntityBuffer,
00592                                 BytesRead,
00593                                 &TempFileBytesWritten,
00594                                 NULL
00595                                 );
00596                     }
00597
00598                     //
00599                     // Since we are sending the response over multiple API
00600                     // calls, we have to add a content-length.
00601                     //
00602                     // Alternatively, we could have sent using chunked transfer
00603                     // encoding, by passing "Transfer-Encoding: Chunked".
00604                     //
00605
00606                     // NOTE: Since we are accumulating the TotalBytesRead in
00607                     //       a ULONG, this will not work for entity bodies that
00608                     //       are larger than 4 GB. For supporting large entity
00609                     //       bodies, we would have to use a ULONGLONG.
00610                     //
00611
00612
00613                     sprintf(szContentLength, "%lu", TotalBytesRead);
00614
00615                     ADD_KNOWN_HEADER(
00616                             response,
00617                             HttpHeaderContentLength,
00618                             szContentLength
00619                             );
00620
00621                     result =
00622                         HttpSendHttpResponse(
00623                                hReqQueue,           // ReqQueueHandle
00624                                pRequest->RequestId, // Request ID
00625                                HTTP_SEND_RESPONSE_FLAG_MORE_DATA,
00626                                &response,           // HTTP response
00627                                NULL,                // pReserved1
00628                                &bytesSent,          // bytes sent (optional)
00629                                NULL,                // pReserved2
00630                                0,                   // Reserved3
00631                                NULL,                // LPOVERLAPPED
00632                                NULL                 // pReserved4
00633                                );
00634
00635                     if(result != NO_ERROR)
00636                     {
00637                         wprintf(L"HttpSendHttpResponse failed with %lu \n",
00638                                 result);
00639                         goto Done;
00640                     }
00641
00642                     //
00643                     // Send entity body from a file handle.
00644                     //
00645                     dataChunk.DataChunkType =
00646                         HttpDataChunkFromFileHandle;
00647
00648                     dataChunk.FromFileHandle.
00649                         ByteRange.StartingOffset.QuadPart = 0;
00650
00651                     dataChunk.FromFileHandle.
00652                         ByteRange.Length.QuadPart = HTTP_BYTE_RANGE_TO_EOF;
00653
00654                     dataChunk.FromFileHandle.FileHandle = hTempFile;
00655
00656                     result = HttpSendResponseEntityBody(
00657                                 hReqQueue,
00658                                 pRequest->RequestId,
00659                                 0,                    // This is the last send.
00660                                 1,                    // Entity Chunk Count.
00661                                 &dataChunk,
00662                                 NULL,
00663                                 NULL,
00664                                 0,
00665                                 NULL,
00666                                 NULL
00667                                 );
00668
00669                     if(result != NO_ERROR)
00670                     {
00671                         wprintf(
00672                            L"HttpSendResponseEntityBody failed with %lu \n",
00673                            result
00674                            );
00675                     }
00676
00677                     goto Done;
00678
00679                     break;
00680
00681
00682                 default:
00683                     wprintf(L"HttpReceiveRequestEntityBody failed with %lu \n",
00684                             result);
00685                     goto Done;
00686             }
00687
00688         } while(TRUE);
00689     }
00690     else
00691     {
00692         // This request does not have any entity body.
00693         //
00694
00695         result = HttpSendHttpResponse(
00696                    hReqQueue,           // ReqQueueHandle
00697                    pRequest->RequestId, // Request ID
00698                    0,
00699                    &response,           // HTTP response
00700                    NULL,                // pReserved1
00701                    &bytesSent,          // bytes sent (optional)
00702                    NULL,                // pReserved2
00703                    0,                   // Reserved3
00704                    NULL,                // LPOVERLAPPED
00705                    NULL                 // pReserved4
00706                    );
00707         if(result != NO_ERROR)
00708         {
00709             wprintf(L"HttpSendHttpResponse failed with %lu \n", result);
00710         }
00711     }
00712
00713 Done:
00714
00715     if(pEntityBuffer)
00716     {
00717         FREE_MEM(pEntityBuffer);
00718     }
00719
00720     if(INVALID_HANDLE_VALUE != hTempFile)
00721     {
00722         CloseHandle(hTempFile);
00723         DeleteFile(szTempName);
00724     }
00725
00726     return result;
00727 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Ping/Ping.cpp Source File

  • NetDS
  • WinSock
  • Ping

Ping.cpp

Go to the documentation of this file.
00001 // From Network Programming for Microsoft Windows, Second Edition by
00002 // Anthony Jones and James Ohlund.
00003 // Copyright 2002.   Reproduced by permission of Microsoft Press.
00004 // All rights reserved.
00005 //
00006 //
00007 // Sample: IPv4 and IPv6 Ping Sample
00008 //
00009 // Files:
00010 //    iphdr.h       - IPv4 and IPv6 packet header definitions
00011 //    ping.cpp      - this file
00012 //    resolve.cpp   - Common name resolution routine
00013 //    resolve.h     - Header file for common name resolution routines
00014 //
00015 // Description:
00016 //    This sample illustrates how to use raw sockets to send ICMP
00017 //    echo requests and receive their response. This sample performs
00018 //    both IPv4 and IPv6 ICMP echo requests. When using raw sockets,
00019 //    the protocol value supplied to the socket API is used as the
00020 //    protocol field (or next header field) of the IP packet. Then
00021 //    as a part of the data submitted to sendto, we include both
00022 //    the ICMP request and data.
00023 //
00024 //    For IPv4 the IP record route option is supported via the
00025 //    IP_OPTIONS socket option.
00026 //
00027 // Compile:
00028 //      cl -o ping.exe ping.cpp resolve.cpp ws2_32.lib
00029 //
00030 // Command Line Options/Parameters:
00031 //     ping.exe [-a 4|6] [-i ttl] [-l datasize] [-r] [host]
00032 //
00033 //     -a       Address family (IPv4 or IPv6)
00034 //     -i ttl   TTL value to set on socket
00035 //     -l size  Amount of data to send as part of the ICMP request
00036 //     -r       Use IPv4 record route
00037 //     host     Hostname or literal address
00038 //
00039 #ifdef _IA64_
00040 #pragma warning (disable: 4267)
00041 #endif
00042
00043 #ifndef WIN32_LEAN_AND_MEAN
00044 #define WIN32_LEAN_AND_MEAN
00045 #endif
00046
00047 #include <winsock2.h>
00048 #include <ws2tcpip.h>
00049 #include <stdio.h>
00050 #include <stdlib.h>
00051
00052 #include "resolve.h"
00053
00054 #include "iphdr.h"
00055
00056 #define DEFAULT_DATA_SIZE      32       // default data size
00057
00058 #define DEFAULT_SEND_COUNT     4        // number of ICMP requests to send
00059
00060 #define DEFAULT_RECV_TIMEOUT   6000     // six second
00061
00062 #define DEFAULT_TTL            128
00063
00064 #define MAX_RECV_BUF_LEN       0xFFFF   // Max incoming packet size.
00065
00066 int   gAddressFamily=AF_UNSPEC,         // Address family to use
00067       gProtocol=IPPROTO_ICMP,           // Protocol value
00068       gTtl=DEFAULT_TTL;                 // Default TTL value
00069 int   gDataSize=DEFAULT_DATA_SIZE;      // Amount of data to send
00070 BOOL  bRecordRoute=FALSE;               // Use IPv4 record route?
00071 char *gDestination=NULL,                // Destination
00072       recvbuf[MAX_RECV_BUF_LEN];        // For received packets
00073 int   recvbuflen = MAX_RECV_BUF_LEN;    // Length of received packets.
00074
00075
00076 //
00077 // Function: usage
00078 //
00079 // Description:
00080 //    Print usage information.
00081 //
00082 void usage(char *progname)
00083 {
00084     printf("usage: %s [options] <host> \n", progname);
00085     printf("        host        Remote machine to ping\n");
00086     printf("        options: \n");
00087     printf("            -a 4|6       Address family (default: AF_UNSPEC)\n");
00088     printf("            -i ttl       Time to live (default: 128) \n");
00089     printf("            -l bytes     Amount of data to send (default: 32) \n");
00090     printf("            -r           Record route (IPv4 only)\n");
00091
00092     return;
00093 }
00094
00095 //
00096 // Function: InitIcmpHeader
00097 //
00098 // Description:
00099 //    Helper function to fill in various stuff in our ICMP request.
00100 //
00101 void InitIcmpHeader(char *buf, int datasize)
00102 {
00103     ICMP_HDR   *icmp_hdr=NULL;
00104     char       *datapart=NULL;
00105
00106     icmp_hdr = (ICMP_HDR *)buf;
00107     icmp_hdr->icmp_type     = ICMPV4_ECHO_REQUEST_TYPE;        // request an ICMP echo
00108     icmp_hdr->icmp_code     = ICMPV4_ECHO_REQUEST_CODE;
00109     icmp_hdr->icmp_id       = (USHORT)GetCurrentProcessId();
00110     icmp_hdr->icmp_checksum = 0;
00111     icmp_hdr->icmp_sequence = 0;
00112
00113     datapart = buf + sizeof(ICMP_HDR);
00114     //
00115     // Place some data in the buffer.
00116     //
00117     memset(datapart, 'E', datasize);
00118 }
00119
00120 //
00121 // Function: InitIcmp6Header
00122 //
00123 // Description:
00124 //    Initialize the ICMP6 header as well as the echo request header.
00125 //
00126 int InitIcmp6Header(char *buf, int datasize)
00127 {
00128     ICMPV6_HDR          *icmp6_hdr=NULL;
00129     ICMPV6_ECHO_REQUEST *icmp6_req=NULL;
00130     char                *datapart=NULL;
00131
00132     // Initialize the ICMP6 headerf ields
00133     icmp6_hdr = (ICMPV6_HDR *)buf;
00134     icmp6_hdr->icmp6_type     = ICMPV6_ECHO_REQUEST_TYPE;
00135     icmp6_hdr->icmp6_code     = ICMPV6_ECHO_REQUEST_CODE;
00136     icmp6_hdr->icmp6_checksum = 0;
00137
00138     // Initialize the echo request fields
00139     icmp6_req = (ICMPV6_ECHO_REQUEST *)(buf + sizeof(ICMPV6_HDR));
00140     icmp6_req->icmp6_echo_id       = (USHORT)GetCurrentProcessId();
00141     icmp6_req->icmp6_echo_sequence = 0;
00142
00143     datapart = (char *)buf + sizeof(ICMPV6_HDR) + sizeof(ICMPV6_ECHO_REQUEST);
00144
00145     memset(datapart, '#', datasize);
00146
00147     return (sizeof(ICMPV6_HDR) + sizeof(ICMPV6_ECHO_REQUEST));
00148 }
00149
00150 //
00151 // Function: checksum
00152 //
00153 // Description:
00154 //    This function calculates the 16-bit one's complement sum
00155 //    of the supplied buffer (ICMP) header.
00156 //
00157 USHORT checksum(USHORT *buffer, int size)
00158 {
00159     unsigned long cksum=0;
00160
00161     while (size > 1)
00162     {
00163         cksum += *buffer++;
00164         size -= sizeof(USHORT);
00165     }
00166     if (size)
00167     {
00168         cksum += *(UCHAR*)buffer;
00169     }
00170     cksum = (cksum >> 16) + (cksum & 0xffff);
00171     cksum += (cksum >>16);
00172     return (USHORT)(~cksum);
00173 }
00174
00175 //
00176 // Function: ValidateArgs
00177 //
00178 // Description:
00179 //    Parse the command line arguments.
00180 //
00181 BOOL ValidateArgs(int argc, char **argv)
00182 {
00183     int                i;
00184     BOOL               isValid = FALSE;
00185
00186     for(i=1; i < argc ;i++)
00187     {
00188         if ((argv[i][0] == '-') || (argv[i][0] == '/'))
00189         {
00190             switch (tolower(argv[i][1]))
00191             {
00192                 case 'a':        // address family
00193                     if (i+1 >= argc)
00194                     {
00195                         usage(argv[0]);
00196                         goto CLEANUP;
00197                     }
00198                     if (argv[i+1][0] == '4')
00199                         gAddressFamily = AF_INET;
00200                     else if (argv[i+1][0] == '6')
00201                         gAddressFamily = AF_INET6;
00202                     else
00203                     {
00204                         usage(argv[0]);
00205                         goto CLEANUP;
00206                     }
00207
00208                     i++;
00209                     break;
00210                 case 'i':        // Set TTL value
00211                     if (i+1 >= argc)
00212                     {
00213                         usage(argv[0]);
00214                         goto CLEANUP;
00215                     }
00216
00217                     gTtl = atoi(argv[++i]);
00218                     break;
00219                 case 'l':        // buffer size tos end
00220                     if (i+1 >= argc)
00221                     {
00222                         usage(argv[0]);
00223                         goto CLEANUP;
00224                     }
00225
00226                     gDataSize = atoi(argv[++i]);
00227                     break;
00228                 case 'r':        // record route option
00229                     bRecordRoute = TRUE;
00230                     break;
00231                 default:
00232                     usage(argv[0]);
00233                     goto CLEANUP;
00234             }
00235         }
00236         else
00237         {
00238             gDestination = argv[i];
00239         }
00240     }
00241
00242     isValid = TRUE;
00243
00244 CLEANUP:
00245     return isValid;
00246 }
00247
00248 //
00249 // Function: SetIcmpSequence
00250 //
00251 // Description:
00252 //    This routine sets the sequence number of the ICMP request packet.
00253 //
00254 void SetIcmpSequence(char *buf)
00255 {
00256     ULONG    sequence=0;
00257
00258     sequence = GetTickCount();
00259     if (gAddressFamily == AF_INET)
00260     {
00261         ICMP_HDR    *icmpv4=NULL;
00262
00263         icmpv4 = (ICMP_HDR *)buf;
00264
00265         icmpv4->icmp_sequence = (USHORT)sequence;
00266     }
00267     else if (gAddressFamily == AF_INET6)
00268     {
00269         ICMPV6_HDR          *icmpv6=NULL;
00270         ICMPV6_ECHO_REQUEST *req6=NULL;
00271
00272         icmpv6 = (ICMPV6_HDR *)buf;
00273         req6   = (ICMPV6_ECHO_REQUEST *)(buf + sizeof(ICMPV6_HDR));
00274
00275         req6->icmp6_echo_sequence = (USHORT)sequence;
00276     }
00277 }
00278
00279 //
00280 // Function: ComputeIcmp6PseudoHeaderChecksum
00281 //
00282 // Description:
00283 //    This routine computes the ICMP6 checksum which includes the pseudo
00284 //    header of the IPv6 header (see RFC2460 and RFC2463). The one difficulty
00285 //    here is we have to know the source and destination IPv6 addresses which
00286 //    will be contained in the IPv6 header in order to compute the checksum.
00287 //    To do this we call the SIO_ROUTING_INTERFACE_QUERY ioctl to find which
00288 //    local interface for the outgoing packet.
00289 //
00290 USHORT ComputeIcmp6PseudoHeaderChecksum(SOCKET s, char *icmppacket, int icmplen, struct addrinfo *dest)
00291 {
00292     SOCKADDR_STORAGE localif;
00293     DWORD            bytes;
00294     char             tmp[MAX_RECV_BUF_LEN] = {'\0'},
00295                     *ptr=NULL,
00296                      proto=0;
00297     int              rc, total, length, i;
00298
00299     // Find out which local interface for the destination
00300     rc = WSAIoctl(
00301             s,
00302             SIO_ROUTING_INTERFACE_QUERY,
00303             dest->ai_addr,
00304             (DWORD) dest->ai_addrlen,
00305             (SOCKADDR *) &localif,
00306             (DWORD) sizeof(localif),
00307            &bytes,
00308             NULL,
00309             NULL
00310             );
00311     if (rc == SOCKET_ERROR)
00312     {
00313         fprintf(stderr, "WSAIoctl failed: %d\n", WSAGetLastError());
00314         return 0xFFFF;
00315     }
00316
00317     // We use a temporary buffer to calculate the pseudo header.
00318     ptr = tmp;
00319     total = 0;
00320
00321     // Copy source address
00322     memcpy(ptr, &((SOCKADDR_IN6 *)&localif)->sin6_addr, sizeof(struct in6_addr));
00323     ptr   += sizeof(struct in6_addr);
00324     total += sizeof(struct in6_addr);
00325
00326     // Copy destination address
00327     memcpy(ptr, &((SOCKADDR_IN6 *)dest->ai_addr)->sin6_addr, sizeof(struct in6_addr));
00328     ptr   += sizeof(struct in6_addr);
00329     total += sizeof(struct in6_addr);
00330
00331     // Copy ICMP packet length
00332     length = htonl(icmplen);
00333
00334     memcpy(ptr, &length, sizeof(length));
00335     ptr   += sizeof(length);
00336     total += sizeof(length);
00337
00338     // Zero the 3 bytes
00339     memset(ptr, 0, 3);
00340     ptr   += 3;
00341     total += 3;
00342
00343     // Copy next hop header
00344     proto = IPPROTO_ICMP6;
00345
00346     memcpy(ptr, &proto, sizeof(proto));
00347     ptr   += sizeof(proto);
00348     total += sizeof(proto);
00349
00350     // Copy the ICMP header and payload
00351     memcpy(ptr, icmppacket, icmplen);
00352     ptr   += icmplen;
00353     total += icmplen;
00354
00355     for(i=0; i < icmplen%2 ;i++)
00356     {
00357         *ptr = 0;
00358         ptr++;
00359         total++;
00360     }
00361
00362
00363     return checksum((USHORT *)tmp, total);
00364 }
00365
00366 //
00367 // Function: ComputeIcmpChecksum
00368 //
00369 // Description:
00370 //    This routine computes the checksum for the ICMP request. For IPv4 its
00371 //    easy, just compute the checksum for the ICMP packet and data. For IPv6,
00372 //    its more complicated. The pseudo checksum has to be computed for IPv6
00373 //    which includes the ICMP6 packet and data plus portions of the IPv6
00374 //    header which is difficult since we aren't building our own IPv6
00375 //    header.
00376 //
00377 void ComputeIcmpChecksum(SOCKET s, char *buf, int packetlen, struct addrinfo *dest)
00378 {
00379     if (gAddressFamily == AF_INET)
00380     {
00381         ICMP_HDR    *icmpv4=NULL;
00382
00383         icmpv4 = (ICMP_HDR *)buf;
00384         icmpv4->icmp_checksum = 0;
00385         icmpv4->icmp_checksum = checksum((USHORT *)buf, packetlen);
00386     }
00387     else if (gAddressFamily == AF_INET6)
00388     {
00389         ICMPV6_HDR  *icmpv6=NULL;
00390
00391         icmpv6 = (ICMPV6_HDR *)buf;
00392         icmpv6->icmp6_checksum = 0;
00393         icmpv6->icmp6_checksum = ComputeIcmp6PseudoHeaderChecksum(
00394                 s,
00395                 buf,
00396                 packetlen,
00397                 dest
00398                 );
00399     }
00400 }
00401
00402 //
00403 // Function: PostRecvfrom
00404 //
00405 // Description:
00406 //    This routine posts an overlapped WSARecvFrom on the raw socket.
00407 //
00408 int PostRecvfrom(SOCKET s, char *buf, int buflen, SOCKADDR *from, int *fromlen, WSAOVERLAPPED *ol)
00409 {
00410     WSABUF  wbuf;
00411     DWORD   flags,
00412             bytes;
00413     int     rc;
00414
00415     wbuf.buf = buf;
00416     wbuf.len = buflen;
00417
00418     flags = 0;
00419
00420     rc = WSARecvFrom(
00421             s,
00422            &wbuf,
00423             1,
00424            &bytes,
00425            &flags,
00426             from,
00427             fromlen,
00428             ol,
00429             NULL
00430             );
00431     if (rc == SOCKET_ERROR)
00432     {
00433         if (WSAGetLastError() != WSA_IO_PENDING)
00434         {
00435             fprintf(stderr, "WSARecvFrom failed: %d\n", WSAGetLastError());
00436             return SOCKET_ERROR;
00437         }
00438     }
00439     return NO_ERROR;
00440 }
00441
00442 //
00443 // Function: PrintPayload
00444 //
00445 // Description:
00446 //    This routine is for IPv4 only. It determines if there are any IP options
00447 //    present (by seeing if the IP header length is greater than 20 bytes) and
00448 //    if so it prints the IP record route options.
00449 //
00450 void PrintPayload(char *buf, int bytes)
00451 {
00452     int     hdrlen=0,
00453             routes=0,
00454             i;
00455
00456     UNREFERENCED_PARAMETER(bytes);
00457
00458     if (gAddressFamily == AF_INET)
00459     {
00460         SOCKADDR_IN      hop;
00461         IPV4_OPTION_HDR *v4opt=NULL;
00462         IPV4_HDR        *v4hdr=NULL;
00463
00464         hop.sin_family = (USHORT)gAddressFamily;
00465         hop.sin_port   = 0;
00466
00467         v4hdr = (IPV4_HDR *)buf;
00468         hdrlen = (v4hdr->ip_verlen & 0x0F) * 4;
00469
00470         // If the header length is greater than the size of the basic IPv4
00471         //    header then there are options present. Find them and print them.
00472         if (hdrlen > sizeof(IPV4_HDR))
00473         {
00474             v4opt = (IPV4_OPTION_HDR *)(buf + sizeof(IPV4_HDR));
00475             routes = (v4opt->opt_ptr / sizeof(ULONG)) - 1;
00476             for(i=0; i < routes ;i++)
00477             {
00478                 hop.sin_addr.s_addr = v4opt->opt_addr[i];
00479
00480                 // Print the route
00481                 if (i == 0)
00482                     printf("    Route: ");
00483                 else
00484                     printf("           ");
00485                 PrintAddress((SOCKADDR *)&hop, sizeof(hop));
00486
00487                 if (i < routes-1)
00488                     printf(" ->\n");
00489                 else
00490                     printf("\n");
00491             }
00492         }
00493     }
00494     return;
00495 }
00496
00497 //
00498 // Function: SetTtl
00499 //
00500 // Description:
00501 //    Sets the TTL on the socket.
00502 //
00503 int SetTtl(SOCKET s, int ttl)
00504 {
00505     int     optlevel = 0,
00506             option = 0,
00507             rc;
00508
00509     rc = NO_ERROR;
00510     if (gAddressFamily == AF_INET)
00511     {
00512         optlevel = IPPROTO_IP;
00513         option   = IP_TTL;
00514     }
00515     else if (gAddressFamily == AF_INET6)
00516     {
00517         optlevel = IPPROTO_IPV6;
00518         option   = IPV6_UNICAST_HOPS;
00519     }
00520     else
00521     {
00522         rc = SOCKET_ERROR;
00523     }
00524     if (rc == NO_ERROR)
00525     {
00526         rc = setsockopt(
00527                 s,
00528                 optlevel,
00529                 option,
00530                 (char *)&ttl,
00531                 sizeof(ttl)
00532                 );
00533     }
00534     if (rc == SOCKET_ERROR)
00535     {
00536         fprintf(stderr, "SetTtl: setsockopt failed: %d\n", WSAGetLastError());
00537     }
00538     return rc;
00539 }
00540
00541 //
00542 // Function: main
00543 //
00544 // Description:
00545 //    Setup the ICMP raw socket and create the ICMP header. Add
00546 //    the appropriate IP option header and start sending ICMP
00547 //    echo requests to the endpoint. For each send and receive we
00548 //    set a timeout value so that we don't wait forever for a
00549 //    response in case the endpoint is not responding. When we
00550 //    receive a packet decode it.
00551 //
00552
00553 int __cdecl main(int argc, char **argv)
00554 {
00555
00556     WSADATA            wsd;
00557     WSAOVERLAPPED      recvol;
00558     SOCKET             s=INVALID_SOCKET;
00559     char              *icmpbuf=NULL;
00560     struct addrinfo   *dest=NULL,
00561                       *local=NULL;
00562     IPV4_OPTION_HDR    ipopt;
00563     SOCKADDR_STORAGE   from;
00564     DWORD              bytes,
00565                        flags;
00566     int                packetlen=0,
00567                        fromlen,
00568                        time=0,
00569                        rc,
00570                        i,
00571                        status = 0;
00572
00573     recvol.hEvent = WSA_INVALID_EVENT;
00574
00575     // Parse the command line
00576     if (ValidateArgs(argc, argv) == FALSE)
00577     {
00578         // invalid arguments supplied.
00579         status = -1;
00580         goto EXIT;
00581     }
00582
00583     // Load Winsock
00584     if ((rc = WSAStartup(MAKEWORD(2,2), &wsd)) != 0)
00585     {
00586         printf("WSAStartup() failed: %d\n", rc);
00587         status = -1;
00588         goto EXIT;
00589     }
00590
00591     // Resolve the destination address
00592     dest = ResolveAddress(
00593             gDestination,
00594             "0",
00595             gAddressFamily,
00596             0,
00597             0
00598             );
00599     if (dest == NULL)
00600     {
00601         printf("bad name %s\n", gDestination);
00602         status = -1;
00603         goto CLEANUP;
00604     }
00605     gAddressFamily = dest->ai_family;
00606
00607     if (gAddressFamily == AF_INET)
00608         gProtocol = IPPROTO_ICMP;
00609     else if (gAddressFamily == AF_INET6)
00610         gProtocol = IPPROTO_ICMP6;
00611
00612     // Get the bind address
00613     local = ResolveAddress(
00614             NULL,
00615             "0",
00616             gAddressFamily,
00617             0,
00618             0
00619             );
00620     if (local == NULL)
00621     {
00622         printf("Unable to obtain the bind address!\n");
00623         status = -1;
00624         goto CLEANUP;
00625     }
00626
00627     // Create the raw socket
00628     s = socket(gAddressFamily, SOCK_RAW, gProtocol);
00629     if (s == INVALID_SOCKET)
00630     {
00631         printf("socket failed: %d\n", WSAGetLastError());
00632         status = -1;
00633         goto CLEANUP;
00634     }
00635
00636     SetTtl(s, gTtl);
00637
00638     // Figure out the size of the ICMP header and payload
00639     if (gAddressFamily == AF_INET)
00640         packetlen += sizeof(ICMP_HDR);
00641     else if (gAddressFamily == AF_INET6)
00642         packetlen += sizeof(ICMPV6_HDR) + sizeof(ICMPV6_ECHO_REQUEST);
00643
00644     // Add in the data size
00645     packetlen += gDataSize;
00646
00647     // Allocate the buffer that will contain the ICMP request
00648     icmpbuf = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, packetlen);
00649     if (icmpbuf == NULL)
00650     {
00651         fprintf(stderr, "HeapAlloc failed: %d\n", GetLastError());
00652         status = -1;
00653         goto CLEANUP;
00654     }
00655
00656     // Initialize the ICMP headers
00657     if (gAddressFamily == AF_INET)
00658     {
00659         if (bRecordRoute)
00660         {
00661             // Setup the IP option header to go out on every ICMP packet
00662             ZeroMemory(&ipopt, sizeof(ipopt));
00663             ipopt.opt_code = IP_RECORD_ROUTE; // record route option
00664             ipopt.opt_ptr  = 4;               // point to the first addr offset
00665             ipopt.opt_len  = 39;              // length of option header
00666
00667             rc = setsockopt(s, IPPROTO_IP, IP_OPTIONS,
00668                     (char *)&ipopt, sizeof(ipopt));
00669             if (rc == SOCKET_ERROR)
00670             {
00671                 fprintf(stderr, "setsockopt(IP_OPTIONS) failed: %d\n", WSAGetLastError());
00672                 status = -1;
00673                 goto CLEANUP;
00674             }
00675         }
00676
00677         InitIcmpHeader(icmpbuf, gDataSize);
00678     }
00679     else if (gAddressFamily == AF_INET6)
00680     {
00681         InitIcmp6Header(icmpbuf, gDataSize);
00682     }
00683
00684     // Bind the socket -- need to do this since we post a receive first
00685     rc = bind(s, local->ai_addr, (int)local->ai_addrlen);
00686     if (rc == SOCKET_ERROR)
00687     {
00688         fprintf(stderr, "bind failed: %d\n", WSAGetLastError());
00689         status = -1;
00690         goto CLEANUP;
00691     }
00692
00693     // Setup the receive operation
00694     memset(&recvol, 0, sizeof(recvol));
00695     recvol.hEvent = WSACreateEvent();
00696     if (recvol.hEvent == WSA_INVALID_EVENT)
00697     {
00698         fprintf(stderr, "WSACreateEvent failed: %d\n", WSAGetLastError());
00699         status = -1;
00700         goto CLEANUP;
00701     }
00702
00703     // Post the first overlapped receive
00704     fromlen = sizeof(from);
00705     PostRecvfrom(s, recvbuf, recvbuflen, (SOCKADDR *)&from, &fromlen, &recvol);
00706
00707     printf("\nPinging ");
00708     PrintAddress(dest->ai_addr, (int)dest->ai_addrlen);
00709     printf(" with %d bytes of data\n\n", gDataSize);
00710
00711     // Start sending the ICMP requests
00712     for(i=0; i < DEFAULT_SEND_COUNT ;i++)
00713     {
00714         // Set the sequence number and compute the checksum
00715         SetIcmpSequence(icmpbuf);
00716         ComputeIcmpChecksum(s, icmpbuf, packetlen, dest);
00717
00718         time = GetTickCount();
00719         rc = sendto(
00720                 s,
00721                 icmpbuf,
00722                 packetlen,
00723                 0,
00724                 dest->ai_addr,
00725                 (int)dest->ai_addrlen
00726                 );
00727         if (rc == SOCKET_ERROR)
00728         {
00729             fprintf(stderr, "sendto failed: %d\n", WSAGetLastError());
00730             status = -1;
00731             goto CLEANUP;
00732         }
00733
00734         // Waite for a response
00735         rc = WaitForSingleObject((HANDLE)recvol.hEvent, DEFAULT_RECV_TIMEOUT);
00736         if (rc == WAIT_FAILED)
00737         {
00738             fprintf(stderr, "WaitForSingleObject failed: %d\n", GetLastError());
00739             status = -1;
00740             goto CLEANUP;
00741         }
00742         else if (rc == WAIT_TIMEOUT)
00743         {
00744             printf("Request timed out.\n");
00745         }
00746         else
00747         {
00748             rc = WSAGetOverlappedResult(
00749                    s,
00750                    &recvol,
00751                    &bytes,
00752                     FALSE,
00753                    &flags
00754                     );
00755             if (rc == FALSE)
00756             {
00757                 fprintf(stderr, "WSAGetOverlappedResult failed: %d\n", WSAGetLastError());
00758             }
00759             time = GetTickCount() - time;
00760
00761             WSAResetEvent(recvol.hEvent);
00762
00763             printf("Reply from ");
00764             PrintAddress((SOCKADDR *)&from, fromlen);
00765             if (time == 0)
00766                 printf(": bytes=%d time<1ms TTL=%d\n", gDataSize, gTtl);
00767             else
00768                 printf(": bytes=%d time=%dms TTL=%d\n", gDataSize, time, gTtl);
00769
00770             PrintPayload(recvbuf, bytes);
00771
00772             if (i < DEFAULT_SEND_COUNT - 1)
00773             {
00774                 fromlen = sizeof(from);
00775                 PostRecvfrom(s, recvbuf, recvbuflen, (SOCKADDR *)&from, &fromlen, &recvol);
00776             }
00777         }
00778         Sleep(1000);
00779     }
00780
00781 CLEANUP:
00782
00783     //
00784     // Cleanup
00785     //
00786     if (dest)
00787          freeaddrinfo(dest);
00788     if (local)
00789          freeaddrinfo(local);
00790     if (s != INVALID_SOCKET)
00791         closesocket(s);
00792     if (recvol.hEvent != WSA_INVALID_EVENT)
00793         WSACloseEvent(recvol.hEvent);
00794     if (icmpbuf)
00795         HeapFree(GetProcessHeap(), 0, icmpbuf);
00796
00797     WSACleanup();
00798
00799 EXIT:
00800     return status;
00801 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CProxy Member List

This is the complete list of members for CProxy, including all inherited members.
Activate(void) | CProxy | [virtual]
ActivateData(IObjectContext *pObjectContext) | CPooledData | [inline, protected]
BindResultMetaData(FieldMetaData **ppMetaData, short *pCount) | CODBCData | [protected, virtual]
BindStaticEntity(FieldMetaData *MetaData, short nCount, CStaticEntity *spEntity) | CProxy | [private]
CanBePooled(void) | CProxy | [virtual]
CanConnectionBePooled(void) | CPooledData | [inline, protected, virtual]
ClearArray() | CProxy | [inline]
CloseCurrentStatement() | CODBCData | [protected, virtual]
CODBCData() | CODBCData | [inline, protected]
CollectResultRows(IResultset **ppResults) | CProxy | [private]
Construct(IDispatch *pUnk) | CProxy |
ConstructData(IDispatch *pUnk) | CPooledData | [inline, protected]
CPooledData() | CPooledData | [inline, protected]
CProxy() | CProxy | [inline]
Deactivate(void) | CProxy | [virtual]
DeactivateData(void) | CODBCData | [inline, protected, virtual]
EntityDelete(IEntityData *Entity, long *Result) | CProxy |
EntityInsert(IEntityData *Entity, long *Result) | CProxy |
EntityLoad(BSTR ReadStoredProc, BSTR UpdateStoredProc, BSTR DeleteStoredProc, BSTR InsertStoredProc, BSTR KeyField, VARIANT KeyValue, long *Result, IEntityData **ppEntity) | CProxy |
EntityLookup(BSTR SQLString, long *Result, BSTR ReadStoredProc, BSTR UpdateStoredProc, BSTR DeleteStoredProc, BSTR InsertStoredProc, BSTR KeyField, IEntityData **ppEntity) | CProxy |
EntityQuery(BSTR SQLString, long *Result, BSTR ReadStoredProc, BSTR UpdateStoredProc, BSTR DeleteStoredProc, BSTR InsertStoredProc, BSTR KeyField, IResultset **ppResults) | CProxy |
EntityRead(IEntityData *pEntity, long *Results) | CProxy |
EntityUpdate(IEntityData *pEntity, long *Result) | CProxy |
Execute(BSTR SQLString, long *Result) | CProxy |
ExecuteSQL(LPCWSTR wszSQL, long *pResult=NULL) | CODBCData | [protected, virtual]
FetchData() | CODBCData | [inline, protected, virtual]
FinalConstruct() | CProxy | [inline]
FinalRelease() | CProxy | [inline]
InterfaceSupportsErrorInfo(REFIID riid) | CProxy |
InternalBindLookup(CStaticEntity *spEntity) | CProxy | [private]
InternalLookup(BSTR SQLString, long *Result, BSTR ReadStoredProc, BSTR UpdateStoredProc, BSTR DeleteStoredProc, BSTR InsertStoredProc, BSTR KeyField) | CProxy | [private]
InternalNextEntity(CStaticEntity *spEntity) | CProxy | [private]
LookupFree() | CProxy |
m_bConstructed | CPooledData | [protected]
m_bObjectPooled | CPooledData | [protected]
m_bShouldEnlist | CPooledData | [protected]
m_MetaData | CProxy |
m_nCount | CProxy |
m_nRows | CProxy |
m_pUnkMarshaler | CProxy |
m_spConnection | CProxy |
m_spObjectContext | CPooledData | [protected]
m_txuow | CPooledData | [protected]
m_wszConnection | CODBCData | [protected]
m_wszDeleteStoredProc | CProxy | [private]
m_wszInsertStoredProc | CProxy | [private]
m_wszKeyField | CProxy | [private]
m_wszReadStoredProc | CProxy | [private]
m_wszUpdateStoredProc | CProxy | [private]
ManualConstruct(BSTR ConstructString) | CProxy | [virtual]
ManualConstructData(BSTR strConstruct) | CODBCData | [inline, protected]
NextEntity(IEntityData **ppEntity) | CProxy |
NextLookup(long *Result, IEntityData **ppEntity) | CProxy |
NextResultset(long *Result, IResultset **Results) | CProxy |
NextResultsetData(long *pResult) | CODBCData | [protected, virtual]
PopulateStaticEntity(FieldMetaData *MetaData, IEntityData *pEntity) | CProxy | [private]
QueryEnlist(const CLSID &clsid, const IID &iid) | CPooledData | [inline, protected, virtual]
RSQuery(BSTR QueryText, VARIANT *Result, _Recordset **Recordset) | CProxy |
RSQueryRW(BSTR QueryText, VARIANT *Result, _Recordset **rs) | CProxy |
RSUpdate(_Recordset *rs) | CProxy |
vtNull | CProxy | [private]
~CODBCData() | CODBCData | [inline, protected]
~CPooledData() | CPooledData | [inline, protected]
~CProxy() | CProxy | [inline]
Generated on Wed Nov 13 2024 16:57:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/PrintJob/quelist.h Source File

  • Multimedia
  • Gdi
  • PrintJob

quelist.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 * PARTICULAR PURPOSE.
00006 *
00007 *  Copyright (C) 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00008 *
00009 *   FILE:   QueList.H
00010 *
00011 *   PURPOSE:    Declares the QueList control's public functions
00012 *
00013 *   FUNCTIONS:
00014 *       ResizeQueList () - Resizes the control to the client area of the Parent.
00015 *       CreateQueList () - Creates the control as a child of the Parent.
00016 *       SetQueListContents () - Syncs controls contents with the Queue data structure.
00017 *
00018 ******************************************************************************/
00019
00020 #include <commctrl.h>
00021
00022
00023 #define ColumnHeadingSize   20      /* Max column name string size */
00024
00025 void    ResizeQueList       (HWND hwndListView, HWND hwndParent);
00026 HWND    CreateQueList       (HWND hwndParent);
00027 void    SetQueListContents  (HWND hwndListView, QUEUEDATA *pQueue);
00028
00029 /* end of header file QueList.H */
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CREATEGIZMOA Member List

This is the complete list of members for CREATEGIZMOA, including all inherited members.
dx | CREATEGIZMOA
dy | CREATEGIZMOA
hBmp | CREATEGIZMOA
hWndParent | CREATEGIZMOA
iGizmo | CREATEGIZMOA
iImage | CREATEGIZMOA
iType | CREATEGIZMOA
pszText | CREATEGIZMOA
uID | CREATEGIZMOA
uState | CREATEGIZMOA
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMDIChildLite Member List

This is the complete list of members for CMDIChildLite, including all inherited members.
AutoPosition(BOOL fDefaultPosition=TRUE) | CMDIChildLite | [virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CMDIChildLite() | CMDIChildLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, HICON hIcon, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CMDIChildLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
MDIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [static]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate) | CMDIChildLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIChildLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CMDIChildLite() | CMDIChildLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/persist.cpp Source File

  • WinUI
  • tsfapp

persist.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation. All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Persist.cpp
00013
00014    Description:   CTSFEditWnd::_Save() and _Load() implementation
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019   #include statements
00020 **************************************************************************/
00021
00022 #include "TSFEdit.h"
00023 #include "PropLdr.h"
00024
00025 /**************************************************************************
00026   global variables and definitions
00027 **************************************************************************/
00028
00029 /**************************************************************************
00030   local function prototypes
00031 **************************************************************************/
00032
00033 #define BLOCK_SIZE  256
00034
00035 void CTSFEditWnd::_SaveToFile(LPTSTR pszFile)
00036 {
00037     if(pszFile)
00038     {
00039         HANDLE  hFile;
00040
00041         hFile = CreateFile( pszFile,
00042                             GENERIC_WRITE,
00043                             0,
00044                             NULL,
00045                             CREATE_ALWAYS,
00046                             FILE_ATTRIBUTE_NORMAL,
00047                             NULL);
00048
00049         if(INVALID_HANDLE_VALUE != hFile)
00050         {
00051             IStream *pStream;
00052
00053             //create a stream on global memory
00054             if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pStream)))
00055             {
00056                 LARGE_INTEGER   li;
00057
00058                 _Save(pStream);
00059
00060                 //initialize the file
00061                 SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
00062                 SetEndOfFile(hFile);
00063
00064                 //set the stream pointer to the start of the stream
00065                 li.QuadPart = 0;
00066                 pStream->Seek(li, STREAM_SEEK_SET, NULL);
00067
00068                 //write the contents of the stream to the file
00069                 BYTE    buffer[BLOCK_SIZE];
00070                 ULONG   uRead;
00071                 HRESULT hr;
00072
00073                 uRead = 0;
00074                 hr = pStream->Read(buffer, BLOCK_SIZE, &uRead);
00075                 while(uRead > 0)
00076                 {
00077                     DWORD   dwWritten;
00078
00079                     WriteFile(hFile, buffer, uRead, &dwWritten, NULL);
00080
00081                     uRead = 0;
00082                     hr = pStream->Read(buffer, BLOCK_SIZE, &uRead);
00083                 }
00084
00085                 pStream->Release();
00086             }
00087
00088             CloseHandle(hFile);
00089         }
00090     }
00091 }
00092
00093 /**************************************************************************
00094
00095   CTSFEditWnd::_Save()
00096
00097 **************************************************************************/
00098
00099 void CTSFEditWnd::_Save(IStream *pStream)
00100 {
00101     if(pStream)
00102     {
00103         HRESULT hr;
00104
00105         //write the plain UNICODE text into the stream
00106         LPWSTR          pwsz;
00107         LONG            cch;
00108         ULONG           uWritten;
00109         LARGE_INTEGER   li;
00110         ULONG           uSize;
00111
00112         //set the stream pointer to the start of the stream
00113         li.QuadPart = 0;
00114         pStream->Seek(li, STREAM_SEEK_SET, NULL);
00115
00116         //get the text
00117         if(SUCCEEDED(_GetText(&pwsz, &cch)))
00118         {
00119             TF_PERSISTENT_PROPERTY_HEADER_ACP   PropHeader;
00120
00121             //write the size, in BYTES, of the text
00122             uSize = cch * sizeof(WCHAR);
00123             hr = pStream->Write(&uSize, sizeof(ULONG), &uWritten);
00124
00125             //write the text, including the NULL_terminator, into the stream
00126             hr = pStream->Write(pwsz, uSize, &uWritten);
00127
00128             //free the memory allocated by _GetText
00129             GlobalFree(pwsz);
00130
00131             //enumerate the properties in the context
00132             IEnumTfProperties   *pEnumProps;
00133             hr = m_pContext->EnumProperties(&pEnumProps);
00134             if(SUCCEEDED(hr))
00135             {
00136                 ITfProperty *pProp;
00137                 ULONG       uFetched;
00138
00139                 while(SUCCEEDED(pEnumProps->Next(1, &pProp, &uFetched)) && uFetched)
00140                 {
00141                     //enumerate all the ranges that contain the property
00142                     IEnumTfRanges   *pEnumRanges;
00143                     hr = pProp->EnumRanges(m_EditCookie, &pEnumRanges, NULL);
00144                     if(SUCCEEDED(hr))
00145                     {
00146                         IStream *pTempStream;
00147
00148                         //create a temporary stream to write the property data to
00149                         hr = CreateStreamOnHGlobal(NULL, TRUE, &pTempStream);
00150                         if(SUCCEEDED(hr))
00151                         {
00152                             ITfRange    *pRange;
00153
00154                             while(SUCCEEDED(pEnumRanges->Next(1, &pRange, &uFetched)) && uFetched)
00155                             {
00156                                 //reset the temporary stream's pointer
00157                                 li.QuadPart = 0;
00158                                 pTempStream->Seek(li, STREAM_SEEK_SET, NULL);
00159
00160                                 //get the property header and data for the range
00161                                 hr = m_pServices->Serialize(pProp, pRange, &PropHeader, pTempStream);
00162
00163                                 /*
00164                                 Write the property header into the primary stream.
00165                                 The header also contains the size of the property
00166                                 data.
00167                                 */
00168                                 hr = pStream->Write(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP), &uWritten);
00169
00170                                 //reset the temporary stream's pointer
00171                                 li.QuadPart = 0;
00172                                 pTempStream->Seek(li, STREAM_SEEK_SET, NULL);
00173
00174                                 //copy the property data from the temporary stream into the primary stream
00175                                 ULARGE_INTEGER  uli;
00176                                 uli.QuadPart = PropHeader.cb;
00177
00178                                 hr = pTempStream->CopyTo(pStream, uli, NULL, NULL);
00179
00180                                 pRange->Release();
00181                             }
00182
00183                             pTempStream->Release();
00184                         }
00185
00186                         pEnumRanges->Release();
00187                     }
00188
00189                     pProp->Release();
00190                 }
00191
00192                 pEnumProps->Release();
00193             }
00194
00195             //write a property header with zero size and guid into the stream as a terminator
00196             ZeroMemory(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP));
00197             hr = pStream->Write(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP), &uWritten);
00198         }
00199     }
00200 }
00201
00202 /**************************************************************************
00203
00204   CTSFEditWnd::_LoadFromFile()
00205
00206 **************************************************************************/
00207
00208 void CTSFEditWnd::_LoadFromFile(LPTSTR pszFile)
00209 {
00210     if(pszFile)
00211     {
00212         HANDLE  hFile;
00213
00214         hFile = CreateFile( pszFile,
00215                             GENERIC_READ,
00216                             0,
00217                             NULL,
00218                             OPEN_EXISTING,
00219                             FILE_ATTRIBUTE_NORMAL,
00220                             NULL);
00221
00222         if(INVALID_HANDLE_VALUE != hFile)
00223         {
00224             IStream *pStream;
00225
00226             //create a stream on global memory
00227             if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pStream)))
00228             {
00229                 //read the contents of the file into the stream
00230                 LARGE_INTEGER   li;
00231
00232                 //set the stream pointer to the start of the stream
00233                 li.QuadPart = 0;
00234                 pStream->Seek(li, STREAM_SEEK_SET, NULL);
00235
00236                 //write the contents of the stream to the file
00237                 BYTE    buffer[BLOCK_SIZE];
00238                 ULONG   uRead;
00239                 HRESULT hr;
00240
00241                 uRead = 0;
00242                 ReadFile(hFile, buffer, BLOCK_SIZE, &uRead, NULL);
00243                 while(uRead > 0)
00244                 {
00245                     ULONG   uWritten;
00246
00247                     hr = pStream->Write(buffer, uRead, &uWritten);
00248
00249                     uRead = 0;
00250                     ReadFile(hFile, buffer, BLOCK_SIZE, &uRead, NULL);
00251                 }
00252
00253                 _Load(pStream);
00254
00255                 pStream->Release();
00256             }
00257
00258             CloseHandle(hFile);
00259         }
00260     }
00261 }
00262
00263 /**************************************************************************
00264
00265    CTSFEditWnd::_Load()
00266
00267 **************************************************************************/
00268
00269 void CTSFEditWnd::_Load(IStream *pStream)
00270 {
00271     if(NULL == pStream)
00272     {
00273         return;
00274     }
00275
00276     //can't do this if someone has a lock
00277     if(_IsLocked(TS_LF_READ))
00278     {
00279         return;
00280     }
00281
00282     _ClearText();
00283
00284     HRESULT         hr;
00285     ULONG           uRead;
00286     LARGE_INTEGER   li;
00287     ULONG           uSize;
00288
00289     //set the stream pointer to the start of the stream
00290     li.QuadPart = 0;
00291     pStream->Seek(li, STREAM_SEEK_SET, NULL);
00292
00293     //get the size of the text, in BYTES. This is the first ULONG in the stream
00294     hr = pStream->Read(&uSize, sizeof(ULONG), &uRead);
00295     if(SUCCEEDED(hr) && (sizeof(ULONG) == uRead))
00296     {
00297         LPWSTR  pwsz;
00298
00299         //allocate a buffer for the text plus one NULL character
00300         pwsz = (LPWSTR)GlobalAlloc(GPTR, uSize + sizeof(WCHAR));
00301         if(NULL != pwsz)
00302         {
00303             //get the plain UNICODE text from the stream
00304             hr = pStream->Read(pwsz, uSize, &uRead);
00305             if(SUCCEEDED(hr) && (uSize == uRead))
00306             {
00307                 TF_PERSISTENT_PROPERTY_HEADER_ACP   PropHeader;
00308
00309                 //put the text into the edit control, but don't send a change notification
00310                 BOOL    fOldNotify = m_fNotify;
00311                 m_fNotify = FALSE;
00312                 SetWindowTextW(m_hwndEdit, pwsz);
00313                 m_fNotify = fOldNotify;
00314
00315                 /*
00316                 Read each property header and property data from the stream. The
00317                 list of properties is terminated by a TF_PERSISTENT_PROPERTY_HEADER_ACP
00318                 structure with a cb member of zero.
00319                 */
00320                 hr = pStream->Read(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP), &uRead);
00321                 while(  SUCCEEDED(hr) &&
00322                         (sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP) == uRead) &&
00323                         (0 != PropHeader.cb))
00324                 {
00325                     ITfProperty *pProp;
00326
00327                     hr = m_pContext->GetProperty(PropHeader.guidType, &pProp);
00328                     if(SUCCEEDED(hr))
00329                     {
00330                         /*
00331                         Have TSF read the property data from the stream. This call
00332                         will request a read lock, so make sure it can be granted
00333                         or else this method will fail.
00334                         */
00335                         CTSFPersistentPropertyLoader *pLoader = new CTSFPersistentPropertyLoader(&PropHeader, pStream);
00336                         hr = m_pServices->Unserialize(pProp, &PropHeader, NULL, pLoader);
00337
00338                         pProp->Release();
00339                     }
00340
00341                     hr = pStream->Read(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP), &uRead);
00342                 }
00343             }
00344
00345             GlobalFree(pwsz);
00346         }
00347     }
00348 }
00349
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/Adminapi/Admapit.c Source File

  • NetDS
  • RRas
  • Adminapi

Admapit.c

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright (C) 1992 - 2002 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This sample source code is only intended as a supplement to
00006 *       MprAdmin API usage and is meant to help users with the
00007 *       MprAdmin API calling convention. Use this code at your own risk.
00008 *       Microsoft disclaims any implied warranty. This sample code can
00009 *       be copied and distributed.
00010
00011 ******************************************************************************/
00012
00013 /********************************************************************
00014 *  admapit.c -- Sample program demonstrating the use of different
00015 *                     MprAdmin API
00016 *
00017 *  Comments:
00018 *
00019 * This program expects \\Servername  as its arguments.
00020 *
00021 * MprAdminGetErrorString API returns error string. However
00022 * this API may return an Error 87 (Invalid Parameter) for the non
00023 * RAS error codes. This API is designed for only RAS related error codes.
00024 * For more Info. check the documentation. I am using this API for all the
00025 * errors but I print the error codes before calling this API
00026 *
00027 *****************************************************************************/
00028 /***************************************************************************
00029 *  Functions:
00030 *      Init2(void);
00031 *      Init1(void);
00032 *      PrintGetStringError(DWORD dwResult);
00033 *      UserPrivilege(WCHAR *DomainName, WCHAR *UserName);
00034 *      PrintPriv(WCHAR *DomainName, WCHAR *UserName);
00035 *      PrintClearStats(WCHAR * RasSrv, WCHAR *wszPortName);
00036 *      WINAPI RasAdminClearDisc(LPVOID param);
00037 *      IsServiceRunning(WCHAR *RasSrv);
00038 *      Debug_Print_Connection0(RAS_CONNECTION_0 *pRasConnection0);
00039 *      Debug_Print_Connection1(RAS_CONNECTION_1 *pRasConnection1);
00040 *      Debug_Print_RAS_PORT0(RAS_PORT_0 *pRasPort0);
00041 *      Debug_Print_RAS_PORT1(RAS_PORT_1 *pRasPort1);
00042 *      File_Print_Connection0(RAS_CONNECTION_0 *pRasConnection0);
00043 *      File_Print_Connection1(RAS_CONNECTION_1 *pRasConnection1);
00044 *      File_Print_RAS_PORT0(RAS_PORT_0 *pRasPort0);
00045 *      File_Print_RAS_PORT1(RAS_PORT_1 *pRasPort1);
00046 *      ProcPortClearStat(HANDLE hPort);
00047 *      ProcConnectionClearStat(HANDLE hConnection);
00048 *      ProcPortReset(HANDLE hPort);
00049 *      ProcPortDisconnect(HANDLE hPort);
00050 *      ProcConnectionGetInfo(HANDLE hConnection);
00051 *      ProcPortGetInfo(HANDLE hPort);
00052 *****************************************************************************/
00053
00054 #define  sleeptime 10000
00055
00056 #include <windows.h>
00057
00058 #include <stdlib.h>
00059 #include <string.h>
00060 #include <stdarg.h>
00061 #include <lm.h>
00062 #include <stdio.h>
00063 #include <time.h>
00064 #include <ctype.h>
00065 #include <conio.h>
00066 #include <mprapi.h>
00067 #include <memory.h>
00068
00069 #include <tchar.h>
00070 #include "Shlwapi.h" // Platform SDK wasn't including this .h file so it's part of this project
00071
00072 // Macro for counting maximum characters that will fit into a null terminated buffer
00073 #define CELEMS(x) ( ((sizeof(x))/(sizeof(x[0]))) - 1)
00074
00075 // Macro for writing to logfile
00076 #define WRITE_LOG_FILE(LogFile, szbuf, len, pdwBytesWritten, flag) {\
00077    if ((LogFile)!=INVALID_HANDLE_VALUE) \
00078       WriteFile((LogFile), (szBuf), (len), (pdwBytesWritten), (flag)); \
00079 }
00080
00081
00082
00083 //Function Definitions
00084 VOID Init2(void);
00085 VOID Init1(void);
00086 VOID PrintGetStringError(DWORD dwResult);
00087 VOID UserPrivilege(WCHAR *DomainName, WCHAR *UserName);
00088 VOID PrintPriv(WCHAR *DomainName, WCHAR *UserName);
00089 VOID PrintClearStats(WCHAR * RasSrv, WCHAR *wszPortName);
00090 DWORD WINAPI RasAdminClearDisc(LPVOID param);
00091 INT IsServiceRunning(WCHAR *RasSrv);
00092 VOID Debug_Print_Connection0(RAS_CONNECTION_0 *pRasConnection0);
00093 VOID Debug_Print_Connection1(RAS_CONNECTION_1 *pRasConnection1);
00094 VOID Debug_Print_RAS_PORT0(RAS_PORT_0 *pRasPort0);
00095 VOID Debug_Print_RAS_PORT1(RAS_PORT_1 *pRasPort1);
00096 VOID File_Print_Connection0(RAS_CONNECTION_0 *pRasConnection0);
00097 VOID File_Print_Connection1(RAS_CONNECTION_1 *pRasConnection1);
00098 VOID File_Print_RAS_PORT0(RAS_PORT_0 *pRasPort0);
00099 VOID File_Print_RAS_PORT1(RAS_PORT_1 *pRasPort1);
00100 VOID ProcPortClearStat(HANDLE hPort);
00101 VOID ProcConnectionClearStat(HANDLE hConnection);
00102 VOID ProcPortReset(HANDLE hPort);
00103 VOID ProcPortDisconnect(HANDLE hPort);
00104 VOID ProcConnectionGetInfo(HANDLE hConnection);
00105 VOID ProcPortGetInfo(HANDLE hPort);
00106
00107
00108 // Global Variables
00109 WCHAR*
00110 StrDupWFromA(
00111     CHAR* psz );
00112
00113
00114 #define Number_Of_Flags 6
00115
00116 HANDLE LogFile  = NULL;
00117 HANDLE cLogFile = NULL;
00118 HANDLE ErrLogFile = NULL;
00119
00120 CHAR buf[120];
00121 WCHAR CallbackNumber[255];
00122 BOOL First_Call = TRUE;
00123 DWORD Status = 0;
00124 DWORD dwResult = 0;
00125 DWORD dwBytesWritten = 0;
00126 CHAR szBuf[120];
00127 BOOL ErrLogInValid = FALSE;
00128 BOOL cErrLogInValid = FALSE;
00129 BOOL LogInValid = TRUE;
00130 BOOL FirstCall = TRUE;
00131 WCHAR szUserAccountServer[UNLEN+1];
00132 PRAS_USER_0 ppRasUser0;
00133 RAS_USER_0 RasUser0;
00134 WCHAR lpszServerName[50];
00135 WCHAR RasSrv[64];
00136 BOOL Quit=FALSE;
00137
00138 RAS_SERVER_HANDLE  phRasServer;
00139
00140
00141 // Function Starts
00142 WCHAR*
00143 StrDupWFromA(
00144     CHAR* psz )
00145
00146     /* Returns heap block containing a copy of 0-terminated string 'psz' or
00147     ** NULL on error or if 'psz' is NULL.  The output string is converted to
00148     ** UNICODE.  It is caller's responsibility to Free the returned string.
00149     */
00150 {
00151    WCHAR* pszNew = NULL;
00152
00153    if (psz)
00154    {
00155       DWORD cb;
00156
00157       cb = MultiByteToWideChar( CP_ACP, 0, psz, -1, NULL, 0 );
00158
00159       pszNew = malloc( cb * sizeof(WCHAR) );
00160       if (!pszNew)
00161       {
00162          return NULL;
00163       }
00164
00165       cb = MultiByteToWideChar( CP_ACP, 0, psz, -1, pszNew, cb );
00166       if (cb == 0 && strlen(psz)!=0)
00167       {
00168          free( pszNew );
00169          return NULL;
00170       }
00171    }
00172    return pszNew;
00173 }
00174
00175
00176 //
00177 // Format and write debug information to OutputDebugString
00178 //
00179 ULONG
00180 _cdecl
00181 DbgPrint(
00182     PCH Format,
00183     ...
00184     )
00185 {
00186     WCHAR buffer[255];
00187     WCHAR *temp = NULL;
00188     LPINT lpResult=NULL;
00189     va_list marker;
00190     va_start (marker,Format);
00191
00192     temp = StrDupWFromA(Format);
00193     if (temp)
00194     {
00195         wvnsprintfW(buffer, CELEMS(buffer), temp, marker);
00196         OutputDebugString (buffer);
00197         free(temp);
00198     }
00199
00200     return TRUE;
00201 }
00202
00203 //
00204 // Init Functions to setup logfiles
00205 //
00206
00207 VOID Init1(void )
00208 {
00209    //Store port  information in this file
00210    LogInValid = FALSE;
00211    LogFile = CreateFile(TEXT("Admin.log"),
00212                         GENERIC_READ|GENERIC_WRITE,
00213                         FILE_SHARE_READ,
00214                         (LPSECURITY_ATTRIBUTES) NULL,
00215                         CREATE_ALWAYS,
00216                         0,
00217                         (HANDLE) NULL);
00218
00219    if (LogFile== INVALID_HANDLE_VALUE)
00220    {
00221       LogInValid = TRUE;
00222    }
00223
00224 }
00225
00226
00227 VOID Init2(void)
00228 {
00229    cErrLogInValid = FALSE;
00230    ErrLogInValid = FALSE;
00231    //Stores Statistics and port disconnect information in this file
00232    cLogFile = CreateFile(TEXT("AdminStats.log"),
00233                          GENERIC_READ|GENERIC_WRITE,
00234                          FILE_SHARE_READ,
00235                          (LPSECURITY_ATTRIBUTES) NULL,
00236                          CREATE_ALWAYS,
00237                          0,
00238                          (HANDLE) NULL);
00239    if (cLogFile== INVALID_HANDLE_VALUE)
00240    {
00241       cErrLogInValid = TRUE;
00242    }
00243
00244    //Stores user privilege information in this file
00245    ErrLogFile = CreateFile(TEXT("AdminUser.log"),
00246                            GENERIC_READ|GENERIC_WRITE,
00247                            FILE_SHARE_READ,
00248                            (LPSECURITY_ATTRIBUTES) NULL,
00249                            CREATE_ALWAYS,
00250                            0,
00251                            (HANDLE) NULL);
00252
00253    if (ErrLogFile== INVALID_HANDLE_VALUE)
00254    {
00255       ErrLogInValid = TRUE;
00256    }
00257
00258 }
00259
00260
00261 //
00262 // Function to print error strings
00263 //
00264 VOID PrintGetStringError(DWORD dwResult)
00265 {
00266 CHAR  szBuf[120];
00267 DWORD dwBytesWritten = 0;
00268
00269    DbgPrint("ERROR  MprAdminGetErrorString      %d\n",dwResult);
00270    wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminGetErrorString      %d\n",dwResult);
00271    WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00272 }
00273
00274
00275 //
00276 // Function to see if the service running
00277 //
00278 INT IsServiceRunning(WCHAR *RasSrv)
00279 {
00280 DWORD dwResult;
00281 CHAR  szBuf[120];
00282 DWORD dwBytesWritten = 0;
00283
00284    //Calling MprAdminIsServiceRunning
00285    // Parameters:
00286    // IN LPWSTR   * RasSrv
00287    dwResult = MprAdminIsServiceRunning(RasSrv);
00288    //printf("Ras server: %s\n", *RasSrv);
00289    if (dwResult==TRUE)
00290    {
00291       DbgPrint("Ras AND Router Serivce running on the Server\n");
00292       wnsprintfA(szBuf, CELEMS(szBuf), "Ras AND Router Serivce running on the Server\n");
00293       WriteFile(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00294       //Calling MprAdminServerConnect
00295       // Parameters
00296       // IN LPWSTR    * RasSrv
00297       // OUT RAS_SERVER_HANDLE * phRasServer
00298       dwResult = MprAdminServerConnect(RasSrv, &phRasServer);
00299       if (dwResult != NO_ERROR)
00300       {
00301          DbgPrint("Failed to Connect to Server\n");
00302          wnsprintfA(szBuf, CELEMS(szBuf), "Failed to Connect to Server: ERROR %d\n", dwResult);
00303          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00304          return 0;
00305       }
00306    }
00307    else
00308    {
00309       DbgPrint("Ras AND Router Serivce is NOT running on the Server\n");
00310       wnsprintfA(szBuf, CELEMS(szBuf), "Ras AND Router Serivce is NOT running on the Server: ERROR %d\n", dwResult);
00311       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00312       return 0;
00313    }
00314    return 1;
00315 }
00316
00317
00318 //
00319 // Function to print user privileges to logfile
00320 //
00321 VOID PrintPriv(WCHAR *DomainName, WCHAR *UserName)
00322 {
00323 DWORD dwBytesWritten = 0;
00324 CHAR  szBuf[120];
00325
00326      /*********** from mprapi.h ****************************************************/
00327      //
00328      // Note: Bit 0 MUST represent NoCallback due to a quirk of the "userparms"
00329      //       storage method.  When a new LAN Manager user is created, bit 0 of the
00330      //       userparms field is set to 1 and all other bits are 0.  These bits are
00331      //       arranged so this "no Dial-In info" state maps to the "default Dial-In
00332      //       privilege" state.
00333      //
00334      // #define RASPRIV_NoCallback        0x01
00335      // #define RASPRIV_AdminSetCallback  0x02
00336      // #define RASPRIV_CallerSetCallback 0x04
00337      // #define RASPRIV_DialinPrivilege   0x08
00338      //
00339      // #define RASPRIV_CallbackType (RASPRIV_AdminSetCallback \
00340      //                             | RASPRIV_CallerSetCallback \
00341      //                             | RASPRIV_NoCallback)
00342      /*****************************************************************************/
00343
00344      wnsprintfA(szBuf, CELEMS(szBuf), "\nDomainName =  %ws\nUserName = %ws\n",DomainName, UserName);
00345      WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00346
00347      wnsprintfA(szBuf, CELEMS(szBuf), "ppRasUser0->bfPrivilege = 0x%x\n",ppRasUser0->bfPrivilege);
00348      WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00349
00350      //
00351      // display the privilege flags
00352      //
00353      if ((ppRasUser0->bfPrivilege) & (RASPRIV_NoCallback))
00354      {
00355         wnsprintfA(szBuf, CELEMS(szBuf), "\t\tRASPRIV_NoCallback        = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_NoCallback)));
00356         WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00357      }
00358      if ((ppRasUser0->bfPrivilege) & (RASPRIV_AdminSetCallback))
00359      {
00360         wnsprintfA(szBuf, CELEMS(szBuf), "\t\tRASPRIV_AdminSetCallback  = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_AdminSetCallback)));
00361         WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00362      }
00363      if ((ppRasUser0->bfPrivilege) & (RASPRIV_CallerSetCallback))
00364      {
00365         wnsprintfA(szBuf, CELEMS(szBuf), "\t\tRASPRIV_CallerSetCallback = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_CallerSetCallback)));
00366         WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00367      }
00368      if ((ppRasUser0->bfPrivilege) & (RASPRIV_DialinPrivilege))
00369      {
00370         wnsprintfA(szBuf, CELEMS(szBuf), "\t\tRASPRIV_DialinPrivilege   = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_DialinPrivilege)));
00371         WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00372      }
00373 }
00374
00375
00376 //
00377 // Function to get and change User Dialin Privileges.
00378 // It goes through all the Dialin Privileges for a user.
00379 //
00380 VOID UserPrivilege(WCHAR *DomainName, WCHAR *UserName)
00381 {
00382 DWORD dwResult;
00383 CHAR  szBuf[120];
00384 DWORD dwBytesWritten = 0;
00385 WCHAR Buf[512];
00386 WCHAR *lpszString;
00387 static BYTE Dialin = 9;
00388 lpszString = &Buf[0];
00389 ppRasUser0 = &RasUser0;
00390
00391    // API Called:     MprAdminGetPDCServer
00392    // Parameters:
00393    //  IN WCHAR * lpwsDomainName
00394    //  IN WCHAR * lpwsServerName
00395    //  OUT WCHAR * lpwsPDCServer
00396
00397
00398    dwResult = MprAdminGetPDCServer(DomainName, NULL, &szUserAccountServer[0]);
00399
00400    if (dwResult != NO_ERROR)
00401    {
00402       dwResult = MprAdminGetPDCServer(NULL, RasSrv, &szUserAccountServer[0]);
00403    }
00404
00405    if (dwResult == NO_ERROR)
00406    {
00407       // API Called:     MprAdminUserGetInfo
00408       // Parameters:
00409       // IN WCHAR * lpwsServerName
00410       // IN WCHAR * lpwsUserName
00411       // IN DWORD dwLevel
00412       // OUT LPBYTE *lpbBuffer
00413       dwResult = MprAdminUserGetInfo(szUserAccountServer, UserName,(DWORD) 0, (LPBYTE) ppRasUser0);
00414       if (dwResult != NO_ERROR)
00415       {
00416          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminUserGetInfo     %d\n",dwResult);
00417          WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00418          wnsprintfA(szBuf, CELEMS(szBuf), "Parameters in:\n\tlpszServer=%ws\n\tlpszUser=%ws\n\tdwLevel=0,\n\tlpbBuffer)\n",
00419                         szUserAccountServer, UserName);
00420          WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00421
00422          dwResult = MprAdminGetErrorString( dwResult, &lpszString);
00423          if (dwResult == NO_ERROR)
00424          {
00425             wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminUserGetInfo: string from MprAdminGetErrorString:  %ws\n",lpszString);
00426             WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00427          }
00428          else
00429             PrintGetStringError(dwResult);
00430       }
00431       else //MprAdminUserGetInfo returned success
00432       {
00433          ppRasUser0->bfPrivilege = (RASPRIV_DialinPrivilege | Dialin  );
00434          wcsncpy(ppRasUser0->wszPhoneNumber, CallbackNumber,
00435                 sizeof(ppRasUser0->wszPhoneNumber)/sizeof(ppRasUser0->wszPhoneNumber[0]));
00436          // API Called:     MprAdminUserSetInfo
00437          // Parameters:
00438          // IN WCHAR * lpwsServerName
00439          // IN WCHAR * lpwsUserName
00440          // IN DWORD dwLevel
00441          // IN LPBYTE lpbBuffer
00442          dwResult = MprAdminUserSetInfo(szUserAccountServer, UserName, 0, (LPBYTE)ppRasUser0);
00443          if (dwResult != NO_ERROR)
00444          {
00445             wnsprintfA(szBuf, CELEMS(szBuf), "ERROR: MprAdminUserSetInfo     %d\n",dwResult);
00446             WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00447
00448             wnsprintfA(szBuf, CELEMS(szBuf), "Parameters in:\n\tlpszServer=%ws\n\tlpszUser=%ws\n\tdwLevel=0,\n\tlpbBuffer)\n",
00449                            szUserAccountServer, UserName);
00450             WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00451             // dump this out to see what privileges were passed in UserSetInfo call
00452             PrintPriv(szUserAccountServer, UserName);
00453
00454             dwResult = MprAdminGetErrorString( dwResult, &lpszString);
00455             if (dwResult == ERROR_SUCCESS)
00456             {
00457                wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminUserSetInfo: string from MprAdminGetErrorString:  %ws\n",lpszString);
00458                WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00459             }
00460             else
00461                PrintGetStringError(dwResult);
00462          }
00463          else
00464          {
00465             PrintPriv(szUserAccountServer, UserName);
00466          }
00467
00468
00469          //
00470          // cycle thru these Callback privilege values
00471          //
00472          // Dialin = 9 : No Callback
00473          // Dialin = 10: Admin Sets Callback Number
00474          // Dialin = 12: Caller Sets Callback Number
00475          switch (Dialin)
00476          {
00477             case 9:
00478                 Dialin = 10;
00479                 break;
00480             case 10:
00481                 Dialin = 12;
00482                 break;
00483             case 12:
00484                 Dialin = 9;
00485                 break;
00486             default:
00487                 break;
00488          }
00489
00490
00491       } // end of loop for MprAdminUserGetInfo returning success
00492
00493    }
00494    else //MprAdminGetPDCServer returned an error
00495    {
00496       DbgPrint("ERROR  MprAdminGetPDCServer     %d\n",dwResult);
00497       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminGetPDCServer     %d\n",dwResult);
00498       WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00499       wnsprintfA(szBuf, CELEMS(szBuf), "Parameters in:\n\tlpszDomain=%ws\n\tlpszServer=NULL\n", DomainName);
00500       WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00501
00502       dwResult = MprAdminGetErrorString(dwResult, &lpszString);
00503       if (dwResult == NO_ERROR)
00504       {
00505          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminGetPDCServer      %ws\n",lpszString);
00506          WRITE_LOG_FILE(ErrLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00507       }
00508       else
00509          PrintGetStringError(dwResult);
00510    }
00511
00512 }  //end UserPrivilege()
00513
00514
00515
00516 //
00517 // dump connection0 struct to debug output
00518 //
00519 VOID Debug_Print_Connection0(RAS_CONNECTION_0 *pRasConnection0)
00520 {
00521    WCHAR *Interface_Type[] =
00522    {
00523    L"ROUTER_IF_TYPE_CLIENT",
00524    L"ROUTER_IF_TYPE_HOME_ROUTER",
00525    L"ROUTER_IF_TYPE_FULL_ROUTER",
00526    L"ROUTER_IF_TYPE_DEDICATED",
00527    L"ROUTER_IF_TYPE_INTERNAL",
00528    L"ROUTER_IF_TYPE_INTERNAL"
00529    };
00530
00531    //dumping pRasConnection0
00532    DbgPrint("pRasConnection0->hConnection  0x%x\n",pRasConnection0->hConnection);
00533    DbgPrint("pRasConnection0->hInterface   0x%x\n",pRasConnection0->hInterface);
00534    DbgPrint("pRasConnection0->dwConnectDuration  %d\n",pRasConnection0->dwConnectDuration);
00535    DbgPrint("pRasConnection0->dwInterfaceType  %ws\n",Interface_Type[pRasConnection0->dwInterfaceType]);
00536    DbgPrint("pRasConnection0->dwConnectionFlags  %d\n",pRasConnection0->dwConnectionFlags);
00537    DbgPrint("pRasConnection0->wszInterfaceName  %ws\n",pRasConnection0->wszInterfaceName);
00538    DbgPrint("pRasConnection0->wszUserName  %ws\n",pRasConnection0->wszUserName);
00539    DbgPrint("pRasConnection0->wszLogonDomain  %ws\n",pRasConnection0->wszLogonDomain);
00540    DbgPrint("pRasConnection0->wszRemoteComputer  %ws\n",pRasConnection0->wszRemoteComputer);
00541
00542
00543
00544
00545 }
00546
00547
00548 //
00549 // dump connection1 struct to debug output
00550 //
00551 VOID Debug_Print_Connection1(RAS_CONNECTION_1 *pRasConnection1)
00552 {
00553     //dumping pRasConnection1
00554     DbgPrint( "\n\npRasConnection1->hConnection  0x%x\n",pRasConnection1->hConnection);
00555     DbgPrint( "pRasConnection1->hInterface   0x%x\n",pRasConnection1->hInterface);
00556     DbgPrint( "pRasConnection1->PppInfo.nbf.dwError %d\n",pRasConnection1->PppInfo.nbf.dwError);
00557     DbgPrint( "pRasConnection1->PppInfo.nbf.wszWksta %ws\n",pRasConnection1->PppInfo.nbf.wszWksta);
00558     DbgPrint( "pRasConnection1->PppInfo.ip.dwError %d\n",pRasConnection1->PppInfo.ip.dwError);
00559     DbgPrint( "pRasConnection1->PppInfo.ip.wszAddress %ws\n",pRasConnection1->PppInfo.ip.wszAddress);
00560     DbgPrint( "pRasConnection1->PppInfo.ip.wszRemoteAddress %ws\n",pRasConnection1->PppInfo.ip.wszRemoteAddress);
00561     DbgPrint( "pRasConnection1->PppInfo.ipx.dwError %d\n",pRasConnection1->PppInfo.ipx.dwError);
00562     DbgPrint( "pRasConnection1->PppInfo.ipx.wszAddress %ws\n",pRasConnection1->PppInfo.ipx.wszAddress);
00563     DbgPrint( "pRasConnection1->PppInfo.at.dwError  %d\n",pRasConnection1->PppInfo.at.dwError );
00564     DbgPrint( "pRasConnection1->PppInfo.at.wszAddress %ws\n",pRasConnection1->PppInfo.at.wszAddress);
00565
00566     //connection stats
00567     DbgPrint( "pRasConnection1->dwBytesXmited=%d\n", pRasConnection1->dwBytesXmited );
00568     DbgPrint( "pRasConnection1->dwBytesRcved=%d\n", pRasConnection1->dwBytesRcved );
00569     DbgPrint( "pRasConnection1->dwFramesXmited=%d\n", pRasConnection1->dwFramesXmited );
00570     DbgPrint( "pRasConnection1->dwFramesRcved=%d\n", pRasConnection1->dwFramesRcved);
00571     DbgPrint( "pRasConnection1->dwCrcErr=%d\n", pRasConnection1->dwCrcErr);
00572     DbgPrint( "pRasConnection1->dwTimeoutErr=%d\n", pRasConnection1->dwTimeoutErr);
00573     DbgPrint( "pRasConnection1->dwAlignmentErr=%d\n", pRasConnection1->dwAlignmentErr);
00574     DbgPrint( "pRasConnection1->dwHardwareOverrunErr=%d\n", pRasConnection1->dwHardwareOverrunErr);
00575     DbgPrint( "pRasConnection1->dwFramingErr=%d\n", pRasConnection1->dwFramingErr);
00576     DbgPrint( "pRasConnection1->dwBufferOverrunErr=%d\n", pRasConnection1->dwBufferOverrunErr);
00577 }
00578
00579
00580
00581 //
00582 // dump port0 struct to debug output
00583 //
00584 VOID Debug_Print_RAS_PORT0(RAS_PORT_0 *pRasPort0)
00585 {
00586 WCHAR *Line_Condition[] =
00587    {
00588    L"RAS_PORT_NON_OPERATIONAL",
00589    L"RAS_PORT_DISCONNECTED",
00590    L"RAS_PORT_CALLING_BACK",
00591    L"RAS_PORT_LISTENING",
00592    L"RAS_PORT_AUTHENTICATING",
00593    L"RAS_PORT_AUTHENTICATED",
00594    L"RAS_PORT_INITIALIZING"
00595    };
00596
00597 WCHAR *Hdw_Error[] =
00598    {
00599    L"RAS_HARDWARE_OPERATIONAL",
00600    L"RAS_HARDWARE_FAILURE"
00601    };
00602
00603    //dumping pRasPort0
00604    DbgPrint("pRasPort0->hPort  %d\n",pRasPort0->hPort);
00605    DbgPrint("pRasPort0->hConnection   0x%x\n",pRasPort0->hConnection);
00606    DbgPrint("pRasPort0->dwPortCondition  %ws\n",Line_Condition[pRasPort0->dwPortCondition-1]);
00607    DbgPrint("pRasPort0->dwTotalNumberOfCalls  %d\n",pRasPort0->dwTotalNumberOfCalls);
00608    DbgPrint("pRasPort0->dwConnectDuration  %d\n",pRasPort0->dwConnectDuration);
00609    DbgPrint("pRasPort0->wszPortName  %ws\n",pRasPort0->wszPortName);
00610    DbgPrint("pRasPort0->wszMediaName  %ws\n",pRasPort0->wszMediaName);
00611    DbgPrint("pRasPort0->wszDeviceName  %ws\n",pRasPort0->wszDeviceName);
00612    DbgPrint("pRasPort0->wszDeviceType  %ws\n",pRasPort0->wszDeviceType);
00613
00614 }
00615
00616
00617
00618 //
00619 // dump port1 struct to debug output
00620 //
00621 VOID Debug_Print_RAS_PORT1(RAS_PORT_1 *pRasPort1)
00622 {
00623 WCHAR *Line_Condition[] =
00624    {
00625    L"RAS_PORT_NON_OPERATIONAL",
00626    L"RAS_PORT_DISCONNECTED",
00627    L"RAS_PORT_CALLING_BACK",
00628    L"RAS_PORT_LISTENING",
00629    L"RAS_PORT_AUTHENTICATING",
00630    L"RAS_PORT_AUTHENTICATED",
00631    L"RAS_PORT_INITIALIZING"
00632    };
00633
00634 WCHAR *Hdw_Error[] =
00635    {
00636    L"RAS_HARDWARE_OPERATIONAL",
00637    L"RAS_HARDWARE_FAILURE"
00638    };
00639
00640    //dumping pRasPort1
00641    DbgPrint("pRasPort1->hPort  %d\n",pRasPort1->hPort);
00642    DbgPrint("pRasPort1->hConnection   0x%x\n",pRasPort1->hConnection);
00643    DbgPrint("pRasPort1->dwHardwareCondition  %ws\n",Hdw_Error[pRasPort1->dwHardwareCondition]);
00644
00645    //connection stats
00646    DbgPrint( "pRasPort1->dwLineSpeed=%d\n", pRasPort1->dwLineSpeed );
00647    DbgPrint( "pRasPort1->dwBytesXmited=%d\n", pRasPort1->dwBytesXmited );
00648    DbgPrint( "pRasPort1->dwBytesRcved=%d\n", pRasPort1->dwBytesRcved );
00649    DbgPrint( "pRasPort1->dwFramesXmited=%d\n", pRasPort1->dwFramesXmited );
00650    DbgPrint( "pRasPort1->dwFramesRcved=%d\n", pRasPort1->dwFramesRcved);
00651    DbgPrint( "pRasPort1->dwCrcErr=%d\n", pRasPort1->dwCrcErr);
00652    DbgPrint( "pRasPort1->dwTimeoutErr=%d\n", pRasPort1->dwTimeoutErr);
00653    DbgPrint( "pRasPort1->dwAlignmentErr=%d\n", pRasPort1->dwAlignmentErr);
00654    DbgPrint( "pRasPort1->dwHardwareOverrunErr=%d\n", pRasPort1->dwHardwareOverrunErr);
00655    DbgPrint( "pRasPort1->dwFramingErr=%d\n", pRasPort1->dwFramingErr);
00656    DbgPrint( "pRasPort1->dwBufferOverrunErr=%d\n", pRasPort1->dwBufferOverrunErr);
00657 }
00658
00659
00660 //
00661 // dump connection0 struct to logfile
00662 //
00663 VOID File_Print_Connection0(RAS_CONNECTION_0 *pRasConnection0)
00664 {
00665 WCHAR *Interface_Type[] =
00666    {
00667    L"ROUTER_IF_TYPE_CLIENT",
00668    L"ROUTER_IF_TYPE_HOME_ROUTER",
00669    L"ROUTER_IF_TYPE_FULL_ROUTER",
00670    L"ROUTER_IF_TYPE_DEDICATED",
00671    L"ROUTER_IF_TYPE_INTERNAL",
00672    L"ROUTER_IF_TYPE_INTERNAL"
00673    };
00674
00675    //dumping pRasConnection0
00676    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00677    wnsprintfA(buf, CELEMS(buf), "dumping pRasConnection0\n\n");
00678    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00679    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->hConnection  0x%l64x\n",pRasConnection0->hConnection);
00680    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00681    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->hInterface   0x%l64x\n",pRasConnection0->hInterface);
00682    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00683    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->dwConnectDuration  %d\n",pRasConnection0->dwConnectDuration);
00684    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00685    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->dwInterfaceType  %ws\n",Interface_Type[pRasConnection0->dwInterfaceType]);
00686    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00687    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->dwConnectionFlags  %d\n",pRasConnection0->dwConnectionFlags);
00688    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00689    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszInterfaceName  %ws\n",pRasConnection0->wszInterfaceName);
00690    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00691    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszUserName  %ws\n",pRasConnection0->wszUserName);
00692    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00693    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszLogonDomain  %ws\n",pRasConnection0->wszLogonDomain);
00694    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00695    wnsprintfA(buf, CELEMS(buf), "pRasConnection0->wszRemoteComputer  %ws\n",pRasConnection0->wszRemoteComputer);
00696    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00697
00698 }
00699
00700
00701 //
00702 // dump connection1 info to logfile
00703 //
00704 VOID File_Print_Connection1(RAS_CONNECTION_1 *pRasConnection1)
00705 {
00706
00707    //dumping pRasConnection1
00708    wnsprintfA(buf, CELEMS(buf), "dumping pRasConnection1\n");
00709    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00710    wnsprintfA(buf, CELEMS(buf), "\n\npRasConnection1->hConnection  0x%l64x\n",pRasConnection1->hConnection);
00711    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00712    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->hInterface   0x%l64x\n",pRasConnection1->hInterface);
00713    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00714    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.nbf.dwError %d\n",pRasConnection1->PppInfo.nbf.dwError);
00715    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00716    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.nbf.wszWksta %ws\n",pRasConnection1->PppInfo.nbf.wszWksta);
00717    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00718    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.ip.dwError %d\n",pRasConnection1->PppInfo.ip.dwError);
00719    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00720    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.ip.wszAddress %ws\n",pRasConnection1->PppInfo.ip.wszAddress);
00721    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00722    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.ip.wszRemoteAddress %ws\n",pRasConnection1->PppInfo.ip.wszRemoteAddress);
00723    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00724    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.ipx.dwError %d\n",pRasConnection1->PppInfo.ipx.dwError);
00725    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00726    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.ipx.wszAddress %ws\n",pRasConnection1->PppInfo.ipx.wszAddress);
00727    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00728    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.at.dwError  %d\n",pRasConnection1->PppInfo.at.dwError );
00729    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00730    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->PppInfo.at.wszAddress %ws\n",pRasConnection1->PppInfo.at.wszAddress);
00731
00732    //connection stats
00733    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00734    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwBytesXmited=%d\n", pRasConnection1->dwBytesXmited );
00735    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00736    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwBytesRcved=%d\n", pRasConnection1->dwBytesRcved );
00737    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00738    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwFramesXmited=%d\n", pRasConnection1->dwFramesXmited );
00739    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00740    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwFramesRcved=%d\n", pRasConnection1->dwFramesRcved);
00741    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00742    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwCrcErr=%d\n", pRasConnection1->dwCrcErr);
00743    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00744    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwTimeoutErr=%d\n", pRasConnection1->dwTimeoutErr);
00745    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00746    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwAlignmentErr=%d\n", pRasConnection1->dwAlignmentErr);
00747    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00748    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwHardwareOverrunErr=%d\n", pRasConnection1->dwHardwareOverrunErr);
00749    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00750    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwFramingErr=%d\n", pRasConnection1->dwFramingErr);
00751    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00752    wnsprintfA(buf, CELEMS(buf), "pRasConnection1->dwBufferOverrunErr=%d\n", pRasConnection1->dwBufferOverrunErr);
00753    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00754 }
00755
00756
00757
00758 //
00759 // dump port0 info to logfile
00760 //
00761 VOID File_Print_RAS_PORT0(RAS_PORT_0 *pRasPort0)
00762 {
00763 WCHAR *Line_Condition[] =
00764    {
00765    L"RAS_PORT_NON_OPERATIONAL",
00766    L"RAS_PORT_DISCONNECTED",
00767    L"RAS_PORT_CALLING_BACK",
00768    L"RAS_PORT_LISTENING",
00769    L"RAS_PORT_AUTHENTICATING",
00770    L"RAS_PORT_AUTHENTICATED",
00771    L"RAS_PORT_INITIALIZING"
00772    };
00773
00774 WCHAR *Hdw_Error[] =
00775    {
00776    L"RAS_HARDWARE_OPERATIONAL",
00777    L"RAS_HARDWARE_FAILURE"
00778    };
00779
00780    //dumping pRasPort0 to a file
00781    wnsprintfA(buf, CELEMS(buf), "dumping pRasPort0 to file\n");
00782    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00783    wnsprintfA(buf, CELEMS(buf), "pRasPort0->hPort  %l64d\n",pRasPort0->hPort);
00784    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00785    wnsprintfA(buf, CELEMS(buf), "pRasPort0->hConnection   0x%l64x\n",pRasPort0->hConnection);
00786    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00787    wnsprintfA(buf, CELEMS(buf), "pRasPort0->dwPortCondition  %ws\n",Line_Condition[pRasPort0->dwPortCondition-1]);
00788    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00789    wnsprintfA(buf, CELEMS(buf), "pRasPort0->dwTotalNumberOfCalls  %d\n",pRasPort0->dwTotalNumberOfCalls);
00790    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00791    wnsprintfA(buf, CELEMS(buf), "pRasPort0->dwConnectDuration  %d\n",pRasPort0->dwConnectDuration);
00792    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00793    wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszPortName  %ws\n",pRasPort0->wszPortName);
00794    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00795    wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszMediaName  %ws\n",pRasPort0->wszMediaName);
00796    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00797    wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszDeviceName  %ws\n",pRasPort0->wszDeviceName);
00798    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00799    wnsprintfA(buf, CELEMS(buf), "pRasPort0->wszDeviceType  %ws\n",pRasPort0->wszDeviceType);
00800    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00801
00802 }
00803
00804
00805
00806 //
00807 // dump port1 info to logfile
00808 //
00809 VOID File_Print_RAS_PORT1(RAS_PORT_1 *pRasPort1)
00810 {
00811 WCHAR *Line_Condition[] =
00812    {
00813    L"RAS_PORT_NON_OPERATIONAL",
00814    L"RAS_PORT_DISCONNECTED",
00815    L"RAS_PORT_CALLING_BACK",
00816    L"RAS_PORT_LISTENING",
00817    L"RAS_PORT_AUTHENTICATING",
00818    L"RAS_PORT_AUTHENTICATED",
00819    L"RAS_PORT_INITIALIZING"
00820    };
00821
00822 WCHAR *Hdw_Error[] =
00823    {
00824    L"RAS_HARDWARE_OPERATIONAL",
00825    L"RAS_HARDWARE_FAILURE"
00826    };
00827
00828
00829    //dumping pRasPort1
00830    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00831    wnsprintfA(buf, CELEMS(buf), "\n dumping pRasPort1\n");
00832    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00833    wnsprintfA(buf, CELEMS(buf), "pRasPort1->hPort  %l64d\n",pRasPort1->hPort);
00834    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00835    wnsprintfA(buf, CELEMS(buf), "pRasPort1->hConnection   0x%l64x\n",pRasPort1->hConnection);
00836    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00837    wnsprintfA(buf, CELEMS(buf), "pRasPort1->dwHardwareCondition  %ws\n",Hdw_Error[pRasPort1->dwHardwareCondition]);
00838
00839    //connection stats
00840    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00841    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwLineSpeed=%d\n", pRasPort1->dwLineSpeed );
00842    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00843    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwBytesXmited=%d\n", pRasPort1->dwBytesXmited );
00844    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00845    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwBytesRcved=%d\n", pRasPort1->dwBytesRcved );
00846    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00847    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwFramesXmited=%d\n", pRasPort1->dwFramesXmited );
00848    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00849    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwFramesRcved=%d\n", pRasPort1->dwFramesRcved);
00850    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00851    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwCrcErr=%d\n", pRasPort1->dwCrcErr);
00852    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00853    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwTimeoutErr=%d\n", pRasPort1->dwTimeoutErr);
00854    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00855    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwAlignmentErr=%d\n", pRasPort1->dwAlignmentErr);
00856    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00857    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwHardwareOverrunErr=%d\n", pRasPort1->dwHardwareOverrunErr);
00858    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00859    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwFramingErr=%d\n", pRasPort1->dwFramingErr);
00860    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00861    wnsprintfA(buf, CELEMS(buf),  "pRasPort1->dwBufferOverrunErr=%d\n", pRasPort1->dwBufferOverrunErr);
00862    WRITE_LOG_FILE(cLogFile, (LPSTR)buf, (int) strlen(buf), &dwBytesWritten, NULL);
00863
00864 }
00865
00866
00867 //
00868 // Function to clear port statistics.
00869 //
00870 VOID ProcPortClearStat(HANDLE hPort)
00871 {
00872 DWORD dwBytesWritten = 0;
00873 CHAR szBuf[120];
00874 WCHAR Buf[512];
00875 WCHAR *lpszString;
00876 lpszString = &Buf[0];
00877
00878    if (phRasServer==NULL)
00879       return;
00880
00881    // API Called:     MprAdminPortClearStats
00882    // Parameters:
00883    // IN RAS_SERVER_HANDLE phRasServer
00884    // IN HANDLE  hPort
00885    Status = MprAdminPortClearStats(phRasServer, hPort);
00886    if (Status != NO_ERROR)
00887    {
00888       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminPortClearStats   %d\n",Status);
00889       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00890       dwResult = MprAdminGetErrorString(Status,&lpszString);
00891       if (dwResult == ERROR_SUCCESS)
00892       {
00893          DbgPrint("ERROR  MprAdminPortClearStats      %ws\n",lpszString);
00894          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminPortClearStats      %ws\n",lpszString);
00895          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00896       }
00897       else
00898          PrintGetStringError(dwResult);
00899    }
00900    else
00901    {
00902       DbgPrint("\n\nMprAdminPortClearStats Called From ProcPortClearStat, Now dumping structs \n");
00903       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nMprAdminPortClearStats Called From ProcPortClearStat, Now dumping structs\n");
00904       WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00905       ProcPortGetInfo(hPort);
00906    }
00907
00908 }
00909
00910
00911
00912 //
00913 // Function to clear connection statistics.
00914 //
00915 VOID ProcConnectionClearStat(HANDLE hConnection)
00916 {
00917 DWORD dwBytesWritten = 0;
00918 CHAR szBuf[120];
00919 WCHAR Buf[512];
00920 WCHAR *lpszString;
00921 lpszString = &Buf[0];
00922
00923    if (phRasServer==NULL)
00924       return;
00925
00926    // API Called:     MprAdminConnectionClearStats
00927    // Parameters:
00928    // IN RAS_SERVER_HANDLE  phRasServer
00929    // IN HANDLE  hConnection
00930    Status = MprAdminConnectionClearStats(phRasServer, hConnection);
00931    if (Status != NO_ERROR)
00932    {
00933       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminConnectionClearStats   %d\n",Status);
00934       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00935       dwResult = MprAdminGetErrorString(Status, &lpszString);
00936       if (dwResult == ERROR_SUCCESS)
00937       {
00938          DbgPrint("ERROR  MprAdminConnectionClearStats      %ws\n",lpszString);
00939          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminConnectionClearStats      %ws\n",lpszString);
00940          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00941       }
00942       else
00943          PrintGetStringError(dwResult);
00944    }
00945    else
00946    {
00947       DbgPrint("\n\nMprAdminConnectionClearStats Called From ProcConnectionClearStat, Now dumping structs \n");
00948       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nMprAdminConnectionClearStats Called From ProcConnectionClearStat, Now dumping structs\n");
00949       WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00950       ProcConnectionGetInfo(hConnection);
00951    }
00952 }
00953
00954
00955 //
00956 // Function to reset port.
00957 //
00958 VOID ProcPortReset(HANDLE hPort)
00959 {
00960 DWORD dwBytesWritten = 0;
00961 CHAR szBuf[120];
00962 WCHAR Buf[512];
00963 WCHAR *lpszString;
00964 lpszString = &Buf[0];
00965
00966    if (phRasServer==NULL)
00967       return;
00968
00969    // API Called:     MprAdminPortReset
00970    // Parameters:
00971    // IN RAS_SERVER_HANDLE  phRasServer
00972    // IN HANDLE  hPort
00973    Status = MprAdminPortReset(phRasServer, hPort);
00974    if (Status != NO_ERROR)
00975    {
00976       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminPortReset   %d\n",Status);
00977       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00978       dwResult = MprAdminGetErrorString(Status, &lpszString);
00979       if (dwResult == ERROR_SUCCESS)
00980       {
00981          DbgPrint("ERROR  MprAdminPortReset      %ws\n",lpszString);
00982          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminPortReset      %ws\n",lpszString);
00983          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00984       }
00985       else
00986          PrintGetStringError(dwResult);
00987    }
00988    else
00989    {
00990       DbgPrint("\n\nMprAdminPortReset Called From ProcPortReset, Now dumping structs \n");
00991       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nMprAdminPortReset Called From ProcPortReset, Now dumping structs\n");
00992       WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
00993       ProcPortGetInfo(hPort);
00994    }
00995 }
00996
00997
00998 //
00999 // Function to disconnect port.
01000 //
01001 VOID ProcPortDisconnect(HANDLE hPort)
01002 {
01003 DWORD dwBytesWritten = 0;
01004 CHAR szBuf[120];
01005 WCHAR Buf[512];
01006 WCHAR *lpszString;
01007 lpszString = &Buf[0];
01008
01009    if (phRasServer==NULL)
01010       return;
01011
01012    // API Called:     MprAdminPortDisconnect
01013    // Parameters:
01014    // IN RAS_SERVER_HANDLE  phRasServer
01015    // IN HANDLE  hPort
01016    Status = MprAdminPortDisconnect(phRasServer, hPort);
01017    if (Status != NO_ERROR)
01018    {
01019       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminPortDisconnect   %d\n",Status);
01020       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01021       dwResult = MprAdminGetErrorString( Status, &lpszString);
01022       if (dwResult == ERROR_SUCCESS)
01023       {
01024          DbgPrint("ERROR  MprAdminPortDisconnect      %ws\n",lpszString);
01025          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminPortDisconnect      %ws\n",lpszString);
01026          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01027       }
01028       else
01029          PrintGetStringError(dwResult);
01030    }
01031 }
01032
01033
01034
01035 //
01036 // Function to reset port statistics
01037 //
01038 DWORD WINAPI RasAdminClearDisc(LPVOID param)
01039 {
01040 CHAR option= ' ';
01041 WORD i = 0;
01042 INT  k = 0;
01043
01044    while (!Quit)
01045    {
01046       // If the user hits q or Q then this will exit gracefully.
01047       // It may take some time to exit though.
01048       printf("Type Q to Quit\n");
01049       do
01050       {
01051          option = (CHAR)_getch();
01052          option = (CHAR)toupper(option);
01053          printf("%c\n",option);
01054       } while (((option) != 'q')&& ((option) != 'Q'));
01055
01056       if (option == 'Q')
01057       {
01058          Quit = TRUE;
01059       }
01060    }
01061    return(0);
01062 }
01063
01064 VOID ProcConnectionGetInfo(HANDLE hConnection)
01065 {
01066 RAS_CONNECTION_0 *pRasConnection0;
01067 RAS_CONNECTION_1 *pRasConnection1;
01068 LPBYTE lplpbBuffer;
01069 DWORD dwBytesWritten = 0;
01070 CHAR  szBuf[120];
01071 WCHAR *lpszString;
01072 WCHAR Buf[512];
01073 lpszString = &Buf[0];
01074
01075    if (phRasServer==NULL)
01076       return;
01077
01078    // API Called: MprAdminConnectionGetInfo
01079    // Parameters:
01080    // IN  RAS_SERVER_HANDLE phRasServer
01081    // IN DWORD    dwLevel
01082    // IN HANDLE   hConnection
01083    // OUT LPBYTE * lplpbBuffer
01084    Status = MprAdminConnectionGetInfo(phRasServer,0,hConnection,&lplpbBuffer);
01085    if (Status != NO_ERROR)
01086    {
01087       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminConnectionGetInfo   %d\n",Status);
01088       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01089       dwResult = MprAdminGetErrorString( Status, &lpszString);
01090       if (dwResult == NO_ERROR)
01091       {
01092          wnsprintfA(szBuf,CELEMS(szBuf), "ERROR  MprAdminConnectionGetInfo      %ws\n",lpszString);
01093          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01094       }
01095       else
01096          PrintGetStringError(dwResult);
01097    }
01098    else
01099    {
01100       pRasConnection0 = (RAS_CONNECTION_0 *) lplpbBuffer;
01101       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nDumping RpRasConnection0::Called from ProcConnectionGetinfo:->MprAdminConnectionGetInfo\n");
01102               WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01103       File_Print_Connection0(pRasConnection0);
01104       DbgPrint("\n\nDumping RpRasConnection0::Called from ProcConnectionGetinfo:->MprAdminConnectionGetInfo\n");
01105       Debug_Print_Connection0(pRasConnection0);
01106       MprAdminBufferFree(pRasConnection0);
01107    }
01108
01109    Status = MprAdminConnectionGetInfo(phRasServer,1,hConnection,&lplpbBuffer);
01110    if (Status != NO_ERROR)
01111    {
01112       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminConnectionGetInfo   %d\n",Status);
01113       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01114       dwResult = MprAdminGetErrorString( Status, &lpszString);
01115       if (dwResult == NO_ERROR)
01116       {
01117          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminConnectionGetInfo      %ws\n",lpszString);
01118          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01119       }
01120       else
01121          PrintGetStringError(dwResult);
01122    }
01123    else
01124    {
01125       pRasConnection1 = (RAS_CONNECTION_1 *) lplpbBuffer;
01126       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nDumping RpRasConnection1::Called from ProcConnectionGetinfo:->MprAdminConnectionGetInfo\n");
01127       WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01128       File_Print_Connection1(pRasConnection1);
01129       DbgPrint("\n\nDumping RpRasConnection1::Called from ProcConnectionGetinfo:->MprAdminConnectionGetInfo\n");
01130       Debug_Print_Connection1(pRasConnection1);
01131       MprAdminBufferFree(pRasConnection1);
01132    }
01133 }
01134
01135
01136 //
01137 // get port info
01138 //
01139 VOID ProcPortGetInfo(HANDLE hPort)
01140 {
01141 RAS_PORT_0 *pRasPort0;
01142 RAS_PORT_1 *pRasPort1;
01143 LPBYTE lplpbBuffer;
01144 DWORD dwBytesWritten = 0;
01145 CHAR  szBuf[120];
01146 WCHAR *lpszString;
01147 WCHAR Buf[512];
01148 lpszString = &Buf[0];
01149
01150    if (phRasServer==NULL)
01151       return;
01152
01153    // API Called: MprAdminPortGetInfo
01154    // Parameters:
01155    // IN  RAS_SERVER_HANDLE phRasServer
01156    // IN DWORD    dwLevel
01157    // IN HANDLE   hPort
01158    // OUT LPBYTE * lplpbBuffer
01159    Status = MprAdminPortGetInfo(phRasServer,0,hPort,&lplpbBuffer);
01160    if (Status != NO_ERROR)
01161    {
01162       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminPortGetInfo   %d\n",Status);
01163       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01164       dwResult = MprAdminGetErrorString( Status, &lpszString);
01165       if (dwResult == NO_ERROR)
01166       {
01167          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminPortGetInfo      %ws\n",lpszString);
01168          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01169       }
01170       else
01171          PrintGetStringError(dwResult);
01172    }
01173    else
01174    {
01175       pRasPort0 = (RAS_PORT_0 *) lplpbBuffer;
01176       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nDumping RpRasPort0::Called from ProcPortGetInfo:-> MprAdminPortGetInfo\n");
01177       WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01178       File_Print_RAS_PORT0(pRasPort0);
01179       DbgPrint("\n\nDumping RpRasPort0::Called from ProcPortGetInfo:->MprAdminPortGetInfo\n");
01180       Debug_Print_RAS_PORT0(pRasPort0);
01181       MprAdminBufferFree(pRasPort0);
01182    }
01183
01184    Status = MprAdminPortGetInfo(phRasServer,1,hPort,&lplpbBuffer);
01185    if (Status != NO_ERROR)
01186    {
01187       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminPortGetInfo   %d\n",Status);
01188       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01189       dwResult = MprAdminGetErrorString( Status, &lpszString);
01190       if (dwResult == NO_ERROR)
01191       {
01192          wnsprintfA(szBuf,CELEMS(szBuf), "ERROR  MprAdminPortGetInfo      %ws\n",lpszString);
01193          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01194       }
01195       else
01196          PrintGetStringError(dwResult);
01197    }
01198    else
01199    {
01200       pRasPort1 = (RAS_PORT_1 *) lplpbBuffer;
01201       wnsprintfA(szBuf, CELEMS(szBuf), "\n\nDumping pRasPort1::Called from ProcPortGetInfo:->MprAdminPortGetInfo\n");
01202       WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01203       File_Print_RAS_PORT1(pRasPort1);
01204       DbgPrint("\n\nDumping RpRasConnection1::Called from ProcPortGetInfo:->MprAdminPortGetInfo\n");
01205       Debug_Print_RAS_PORT1(pRasPort1);
01206       MprAdminBufferFree(pRasPort1);
01207    }
01208 }
01209
01210
01211 /*************************************************************************/
01212 /***************** Start Main ********************************************/
01213 /*************************************************************************/
01214
01215 void _cdecl main(int argc, char **argv)
01216 {
01217 INT LoopPriv = 0;
01218 INT Error = 0;
01219 CHAR szBuf[120];
01220 DWORD dwBytesWritten = 0;
01221 DWORD Dialin = 1;
01222 WORD i = 0;
01223 INT_PTR id = 0;
01224 WCHAR *lpszString;
01225 WCHAR Buf[512];
01226 HANDLE ConnectDiscThread;
01227 LPBYTE lplpbBuffer;
01228 DWORD lpdwEntriesRead = 0;
01229 DWORD lpdwTotalEntries = 0;
01230 LPDWORD lpdwResumeHandle=NULL;
01231 RAS_CONNECTION_0 *pRasConnection0;
01232 LPBYTE plplpbBuffer;
01233 DWORD plpdwPrefMaxLen = 0;
01234 DWORD plpdwEntriesRead = 0;
01235 DWORD plpdwTotalEntries = 0;
01236 DWORD plpdwResumeHandle = 0;
01237 RAS_PORT_0 *pRasPort0;
01238 HANDLE hConnection = 0;
01239 lpszString = &Buf[0];
01240
01241  if (argc > 1)
01242  {
01243     mbstowcs(RasSrv, argv[1], 32) ;
01244  }
01245  Init1();
01246  Init2();
01247  Error=IsServiceRunning(RasSrv);
01248  if (!Error)
01249  {
01250     printf ("Ras Server is not started on the system");
01251     exit(0);
01252  }
01253  printf("Please specify the Client's phone number or IP address\n");
01254  scanf("%ws", CallbackNumber);
01255  ConnectDiscThread = CreateThread (NULL,
01256                                   0,
01257                                   &RasAdminClearDisc,
01258                                   (LPVOID)&id,
01259                                   0,
01260                                   (LPDWORD)&id);
01261  while (!Quit)
01262  {
01263  // API Called:     MprAdminConnectionEnum
01264  // Parameters:
01265  //  IN RAS_SERVER_HANDLE phRasServer
01266  //  IN DWORD dwLevel
01267  //  OUT LPBYTE * lplpbBuffer    (RAS_CONNECTION_0 array)
01268  //  IN DWORD dwPrefMaxLen
01269  //  OUT LPDWORD lpdwEntriesRead
01270  //  OUT LPDWORD lpdwdTotalEntries
01271  //  IN  LPDWORD lpdwResumeHandle  OPTIONAL
01272
01273  // Free up lplpbBuffer by calling MprAdminFreeBuffer API
01274
01275    lpdwEntriesRead = 0;
01276
01277    Status = MprAdminConnectionEnum(phRasServer,(DWORD) 0,&lplpbBuffer,(DWORD)-1,
01278                                    &lpdwEntriesRead,&lpdwTotalEntries,lpdwResumeHandle);
01279    if (Status != NO_ERROR)  //error
01280    {
01281       wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminConnectionEnum   %d\n",Status);
01282       WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01283       dwResult = MprAdminGetErrorString( Status, &lpszString);
01284       if (dwResult == NO_ERROR)
01285       {
01286          wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminConnectionEnum      %ws\n",lpszString);
01287          WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01288       }
01289       else
01290          PrintGetStringError(dwResult);
01291    }
01292    else  //no error
01293    {
01294       if (lpdwEntriesRead == lpdwTotalEntries)
01295       {
01296          pRasConnection0 = (RAS_CONNECTION_0 *) lplpbBuffer;
01297          for (i=0; i < (DWORD)lpdwTotalEntries;i++)
01298          {
01299             wnsprintfA(szBuf, CELEMS(szBuf), "\n\nDumping RpRasConnection0::Called from MprAdminConnectionEnum\n");
01300             WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01301             File_Print_Connection0(&pRasConnection0[i]);
01302             DbgPrint("\n\nDumping RpRasConnection0::Called from MprAdminConnectionEnum\n");
01303             Debug_Print_Connection0(&pRasConnection0[i]);
01304             ProcConnectionGetInfo(pRasConnection0[i].hConnection);
01305             // pass hConnection = handle from MprAdminConnectionEnum
01306             hConnection = pRasConnection0[i].hConnection;
01307             //alternatively, could pass hConnection = INVALID_HANDLE_VALUE;
01308             Sleep (500);
01309             // A good idea is to call UserPrivilege outside the loop. It doesn't really
01310             // make sense to go through the privilege change for every iteration.
01311             // However, this code is just intended to demonstrate the usage.
01312             if (lpdwEntriesRead > 0)
01313         {
01314         UserPrivilege(pRasConnection0[i].wszLogonDomain,pRasConnection0[i].wszUserName);
01315         }
01316             ProcConnectionClearStat(pRasConnection0[i].hConnection);
01317             // API Called:     MprAdminPortEnum
01318             // Parameters:
01319             //  IN RAS_SERVER_HANDLE phRasServer
01320             //  IN DWORD pdwLevel
01321             //  HANDLE hConnection
01322             //  OUT LPBYTE * plplpbBuffer    (RAS_PORT_0 array)
01323             //  IN DWORD pdwPrefMaxLen
01324             //  OUT LPDWORD plpdwEntriesRead
01325             //  OUT LPDWORD plpdwdTotalEntries
01326             //  IN  LPDWORD plpdwResumeHandle  OPTIONAL
01327
01328             // Free up lplpbBuffer by calling MprAdminFreeBuffer API
01329             Status = MprAdminPortEnum(phRasServer,(DWORD) 0,hConnection, &plplpbBuffer,
01330                         (DWORD) -1, &plpdwEntriesRead, &plpdwTotalEntries, &plpdwResumeHandle);
01331             if (Status != NO_ERROR)
01332             {
01333                wnsprintfA(szBuf, CELEMS(szBuf), "ERROR MprAdminPortEnum   %d\n",Status);
01334                WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01335                dwResult = MprAdminGetErrorString( Status, &lpszString);
01336                if (dwResult == NO_ERROR)
01337                {
01338                   wnsprintfA(szBuf, CELEMS(szBuf), "ERROR  MprAdminPortEnum      %ws\n",lpszString);
01339                   WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01340                }
01341                else
01342                   PrintGetStringError(dwResult);
01343             }
01344             else
01345             {
01346                if (plpdwEntriesRead == plpdwTotalEntries)
01347                {
01348                   pRasPort0 = (RAS_PORT_0 *) plplpbBuffer;
01349                   for (i=0; i < (DWORD)plpdwTotalEntries;i++)
01350                   {
01351                      wnsprintfA(szBuf, CELEMS(szBuf), "\n\nDumping pRasPort0::Called from MprAdminPortEnum\n");
01352                      WRITE_LOG_FILE(cLogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01353                      File_Print_RAS_PORT0(&pRasPort0[i]);
01354                      DbgPrint("\n\nDumping RpRasPort0::Called from MprAdminPortEnum\n");
01355                      Debug_Print_RAS_PORT0(&pRasPort0[i]);
01356                      ProcPortGetInfo(pRasPort0[i].hPort);
01357                      Sleep (500);
01358                      ProcPortClearStat(pRasPort0[i].hPort);
01359                      Sleep (500);
01360                      ProcPortReset(pRasPort0[i].hPort);
01361                      Sleep (500);
01362                      ProcPortDisconnect(pRasPort0[i].hPort);
01363                   }
01364                }
01365                MprAdminBufferFree(pRasPort0);
01366             }
01367          }
01368       }
01369       MprAdminBufferFree(pRasConnection0);
01370    }
01371
01372    Sleep(sleeptime);
01373
01374  } //end of loop: while (!Quit)
01375
01376
01377  WaitForSingleObject(ConnectDiscThread,INFINITE);
01378
01379
01380  //Calling MprAdminServerDisconnect (type VOID, returns nothing)
01381  // Parameters
01382  // IN RAS_SERVER_HANDLE * phRasServer
01383  MprAdminServerDisconnect(phRasServer);
01384  DbgPrint("info: called MprAdminServerDisconnect(hRasServer=0x%x)\n", phRasServer);
01385  wnsprintfA(szBuf, CELEMS(szBuf), "info: called MprAdminServerDisconnect(hRasServer=0x%l64x)\n", phRasServer);
01386  WRITE_LOG_FILE(LogFile, (LPSTR)szBuf, (int) strlen(szBuf), &dwBytesWritten, NULL);
01387
01388  //
01389  // close logfiles
01390  //
01391  CloseHandle(LogFile);
01392  CloseHandle(cLogFile);
01393  CloseHandle(ErrLogFile);
01394
01395
01396 } // Main End
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/InpStrm.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

InpStrm.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       inpstrm.hxx
00006 //
00007 //  Contents:   Memory Mapped Input Stream
00008 //
00009 //  Classes:    CMemoryMappedInputStream
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #ifndef __INPSTRM_HXX__
00014 #define __INPSTRM_HXX__
00015
00016
00017 #include <mmstrm.hxx>
00018 #include <mmscbuf.hxx>
00019 #include <stdio.h>
00020
00021 const HTML_FILTER_CHUNK_SIZE           = 0x10000;        // File mapped in this size
00022 const TRANSLATED_CHAR_BUFFER_LENGTH    = 2048;           // Size of translated wide char buffer
00023
00024 //+---------------------------------------------------------------------------
00025 //
00026 //  Class:      CMemoryMappedInputStream
00027 //
00028 //  Purpose:    Memory mapped input stream
00029 //
00030 //----------------------------------------------------------------------------
00031
00032 class CMemoryMappedInputStream
00033 {
00034
00035 public:
00036     CMemoryMappedInputStream();
00037     ~CMemoryMappedInputStream();
00038
00039     void    Init( WCHAR *pwszFileName );
00040     WCHAR   GetChar();
00041     void    UnGetChar( WCHAR Wch );
00042     BOOL    Eof();
00043
00044 private:
00045     ULONG              _bytesReadFromMMBuffer;          // # bytes read from cached buffer
00046     unsigned           _charsReadFromTranslatedBuffer;  // # wide chars read from translated buffer
00047     unsigned           _cwcTranslatedBuffer;            // # wide chars in translated buffer
00048     ULONG              _ulCodePage;                     // Codepage for MultiByteToWideChar
00049     BOOL               _fUnGotChar;                     // Was an UnGetChar called
00050     WCHAR              _wch;                            // Char that was ungot
00051
00052     CMmStream          _mmStream;                       // Memory mapped input stream
00053     CMmStreamConsecBuf _mmStreamBuf;                    // Consecutive chunks of input stream
00054
00055     WCHAR              _awcTranslatedBuffer[TRANSLATED_CHAR_BUFFER_LENGTH];      // Buffer for converted wide chars
00056 };
00057
00058 #endif  //  __INPSTRM_HXX__
00059
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_BOUNCEDATA Member List

This is the complete list of members for _BOUNCEDATA, including all inherited members.
hBall1 | _BOUNCEDATA
hBall2 | _BOUNCEDATA
hBall3 | _BOUNCEDATA
hBall4 | _BOUNCEDATA
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/Chunk/cte_enc.c Source File

  • Web
  • iis
  • extensions
  • Chunk

cte_enc.c

Go to the documentation of this file.
00001 /*++
00002
00003   Copyright (c) 1997-2002 Microsoft Corporation
00004
00005   Module Name:
00006
00007     cte_enc.c
00008
00009   Abstract:
00010
00011     This module contains routines implementing Chunked Transfer
00012     Encoding (CTE) for ISAPI Extension DLLs. See Section 3.6
00013     "Transfer Codings" of RFC 2068 for details.
00014
00015   Functions:
00016     CteBeginWrite
00017     CteWrite
00018     CteEndWrite
00019 */
00020
00021 #include "ctetest.h"
00022
00023 // Encoder context structure
00024
00025 typedef struct CTE_ENCODER_STRUCT {
00026     EXTENSION_CONTROL_BLOCK * pECB;         // a copy of current ECB pointer
00027     DWORD                     dwChunkSize;  // user-specified chunk size
00028     DWORD                     cbData;       // number of bytes in the buffer
00029     BYTE *                    pData;        // pointer to chunk data bytes
00030 } CTE_ENCODER;
00031
00032 // Chunk header consists of HEX string for the chunk size in bytes
00033 // (DWORD needs up to 8 bytes in HEX), followed by CRLF,
00034 // therefore the maximum chunk header size is 10 bytes.
00035
00036 #define CTE_MAX_CHUNK_HEADER_SIZE 10
00037
00038 // Chunk data is always followed by CRLF
00039
00040 #define CTE_MAX_ENCODING_OVERHEAD (CTE_MAX_CHUNK_HEADER_SIZE + 2)
00041
00042 // Total encoder size includes:
00043 //   the size of the encoder context structure itself,
00044 //   the chunk data size,
00045 //   the maximum encoding overhead (header and terminating CRLF)
00046
00047 #define CTE_ENCODER_SIZE(dwChunkSize) (sizeof(CTE_ENCODER) + dwChunkSize + CTE_MAX_ENCODING_OVERHEAD)
00048
00049 /*
00050   Description:
00051
00052     Allocate and initialize chunked transfer encoder context
00053
00054   Arguments:
00055
00056     pECB - pointer to extension control as passed to HttpExtensionProc()
00057     dwChunkSize - the maximum size of the chunk to transmit
00058
00059   Returns:
00060
00061     encoder context handle, or
00062     NULL if memory allocation failed or chunk size was zero
00063 */
00064
00065 HCTE_ENCODER CteBeginWrite(IN EXTENSION_CONTROL_BLOCK *pECB, IN DWORD dwChunkSize)
00066 {
00067   HCTE_ENCODER h;
00068
00069   /* reject zero-length chunk size */
00070
00071   if (dwChunkSize == 0) {
00072
00073     SetLastError(ERROR_INVALID_PARAMETER);
00074
00075     return NULL;
00076   }
00077
00078   /* allocate context structure */
00079
00080   h = LocalAlloc(LMEM_FIXED, CTE_ENCODER_SIZE(dwChunkSize));
00081
00082   if (h != NULL) {
00083
00084     /* initialize context structure */
00085
00086     h->pECB         = pECB;
00087     h->dwChunkSize  = dwChunkSize;
00088     h->cbData       = 0;
00089
00090     /* chunk data bytes follow the context structure itself and chunk header */
00091
00092     h->pData = (BYTE *) h + sizeof( *h ) + CTE_MAX_CHUNK_HEADER_SIZE;
00093
00094     /* this is the CRLF which follows chunk size (and immediately precedes data) */
00095
00096     h->pData[-2] = '\r';
00097     h->pData[-1] = '\n';
00098
00099   } else {
00100
00101     SetLastError(ERROR_NOT_ENOUGH_MEMORY);
00102   }
00103
00104   return h;
00105 }
00106
00107 /*
00108   Description:
00109
00110     Send one chunk of data using ClientWrite() <hex encoded chunk size>, CRLF, data bytes, if any, CRLF
00111
00112   Arguments:
00113
00114     h - CTE Encoder handle
00115
00116   Returns:
00117
00118     TRUE if WriteClient succeeded
00119     FALSE if WriteClient failed
00120 */
00121
00122 static BOOL CteSendChunk(IN HCTE_ENCODER h)
00123 {
00124   char szChunkLength[9];
00125   DWORD cbChunkLength;
00126   BYTE *buf;
00127   DWORD cbToSend;
00128   BOOL success;
00129
00130   /* produce hex string of the number of bytes and compute the length of this string */
00131
00132   _itoa(h->cbData, szChunkLength, 16);
00133
00134   cbChunkLength = strlen(szChunkLength);
00135
00136   /* step back to make place for hex number and CRLF, copy hex string to its location */
00137
00138   buf = h->pData - 2 - cbChunkLength;
00139
00140   memmove(buf, szChunkLength, cbChunkLength);
00141
00142   /* compute the number of bytes to send (this includes chunk data size, hex string and CRLF) */
00143
00144   cbToSend = h->cbData + cbChunkLength + 2;
00145
00146   /* append trailing CRLF right after the data bytes */
00147
00148   buf[cbToSend++] = '\r';
00149   buf[cbToSend++] = '\n';
00150
00151   /* issue synchronous WriteClient and return result to the caller */
00152
00153   success = h->pECB->WriteClient(h->pECB->ConnID, buf, &cbToSend, HSE_IO_SYNC);
00154
00155   /* reset buffer pointer */
00156
00157   h->cbData = 0;
00158
00159   return success;
00160 }
00161
00162 /*
00163   Description:
00164
00165     Write specified number of data bytes to the chunk buffer.
00166     When the chunk buffer becomes full, call CteSendChunk()
00167     to send it out.
00168
00169   Arguments:
00170
00171     h - CTE Encoder handle
00172     pData - pointer to data bytes
00173     cbData - number of data bytes to send
00174
00175   Returns:
00176
00177     TRUE if bytes were successfully written
00178     FALSE if WriteClient() failed
00179 */
00180
00181 BOOL CteWrite(IN HCTE_ENCODER h, IN PVOID pData, IN DWORD cbData)
00182 {
00183   DWORD cbToConsume;
00184   PBYTE pBytesToSend = (PBYTE) pData;
00185
00186   for (;;) {
00187
00188     /* compute the number of bytes to consume, break out of the loop, if nothing is left */
00189
00190     cbToConsume = min(cbData, h->dwChunkSize - h->cbData);
00191
00192     if (cbToConsume == 0)
00193       break;
00194
00195     /* move bytes to the buffer, advance pointers and counters */
00196
00197     memmove(h->pData + h->cbData, pBytesToSend, cbToConsume);
00198
00199     h->cbData += cbToConsume;
00200     pBytesToSend += cbToConsume;
00201     cbData -= cbToConsume;
00202
00203     /* if the chunk buffer is full, send it */
00204
00205     if (h->cbData == h->dwChunkSize)
00206       if (!CteSendChunk(h))
00207         return FALSE;
00208   }
00209
00210   return TRUE;
00211 }
00212
00213 /*
00214   Description:
00215
00216     Complete the transfer and release the encoder context
00217
00218   Arguments:
00219
00220     h - CTE Encoder handle
00221
00222   Returns:
00223
00224     TRUE if transfer was successfully completed
00225     FALSE if WriteClient() failed
00226 */
00227
00228 BOOL CteEndWrite(IN HCTE_ENCODER h)
00229 {
00230   BOOL success;
00231
00232   /* if there are some bytes in the chunk, send them */
00233
00234   if (h->cbData)
00235     if (!CteSendChunk(h))
00236       return FALSE;
00237
00238   /* send empty chunk (which means EOF) */
00239
00240   success = CteSendChunk(h);
00241
00242   /* release chunk transfer context */
00243
00244   LocalFree(h);
00245
00246   return success;
00247 }
00248
00249
00250
00251
00252
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTestCOMPerformance Member List

This is the complete list of members for CTestCOMPerformance, including all inherited members.
CTestCOMPerformance() | CTestCOMPerformance | [inline]
GetIDsOfNames(REFIID riid, WCHAR **rgszNames, unsigned int cNames, LCID lcid, DISPID *pdispid) | CTestCOMPerformance |
GetTypeInfo(unsigned int iti, LCID lcid, LPTYPEINFO *ppti) | CTestCOMPerformance |
GetTypeInfoCount(unsigned int *pcti) | CTestCOMPerformance |
Invoke(DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, unsigned int *puArgErr) | CTestCOMPerformance |
m_cRef | CTestCOMPerformance | [private]
QueryInterface(REFIID iid, void **ppv) | CTestCOMPerformance |
STDMETHODIMP_(ULONG) AddRef(void) | CTestCOMPerformance | [inline]
STDMETHODIMP_(ULONG) Release(void) | CTestCOMPerformance |
Test1(int l) | CTestCOMPerformance |
Test23(BSTR szDesc) | CTestCOMPerformance |
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CacheProxySamplePlugin::INSSBufferImpl Member List

This is the complete list of members for CacheProxySamplePlugin::INSSBufferImpl, including all inherited members.
Buffer | CacheProxySamplePlugin::INSSBufferImpl |
GetBuffer(out IntPtr ppbBuffer) | CacheProxySamplePlugin::INSSBufferImpl | [inline, private]
GetBufferAndLength(out IntPtr ppbBuffer, out uint pdwLength) | CacheProxySamplePlugin::INSSBufferImpl | [inline, private]
GetLength(out uint pdwLength) | CacheProxySamplePlugin::INSSBufferImpl | [inline, private]
GetMaxLength(out uint pdwLength) | CacheProxySamplePlugin::INSSBufferImpl | [inline, private]
INSSBufferImpl() | CacheProxySamplePlugin::INSSBufferImpl | [inline]
Length | CacheProxySamplePlugin::INSSBufferImpl |
SetBuffer(string Buf) | CacheProxySamplePlugin::INSSBufferImpl | [inline]
SetLength(uint dwLength) | CacheProxySamplePlugin::INSSBufferImpl | [inline, private]
Generated on Wed Nov 13 2024 16:58:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMyMemberSetChangeListener Member List

This is the complete list of members for CMyMemberSetChangeListener, including all inherited members.
CMyMemberSetChangeListener(void) | CMyMemberSetChangeListener | [protected]
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMyMemberSetChangeListener |
m_lcid | CMyMemberSetChangeListener | [private]
m_piccCallback | CMyMemberSetChangeListener | [private]
Notify(IUnknown *punkIn) | CMyMemberSetChangeListener |
~CMyMemberSetChangeListener(void) | CMyMemberSetChangeListener | [protected]
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Print.c Source File

  • WinUI
  • CommDlg
  • CDTest

Print.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 /************************************************************************
00007
00008   File: print.c
00009
00010   Purpose:  To manage CDTEST's print dialog box.
00011
00012
00013   Functions:
00014
00015     DoPrintDlg()            -- Creates CDTEST's print dialog box.
00016
00017     PrintProc()             -- Callback function for CDTEST's print dialog box.
00018
00019     DevnamesProc()          -- Callback function for CDTESTS Devnames dlg box.
00020
00021     DevmodeProc()           -- Callback function for CDTESTS Devmode dlg box.
00022
00023     InitPrintStruct()       -- Fills a PRINTDLG struct with some default values.
00024
00025     FillPrintDlg()          -- Fills CDTEST's print dialog with contents of a
00026                                PRINTDLG structure.
00027
00028     GetPrintDlg()           -- Retrieves the users edits from CDTEST's print dlg.
00029
00030     FillDevnamesDlg()       -- Fills CDTEST's Devnames dialog with the contents
00031                                of a DEVNAMES structure.
00032
00033     GetDevnamesDlg()        -- Retrieves the user's edits from CDTEST's devnames dlg.
00034
00035     FillDevmodeDlg()        -- Fills CDTEST's devmode dialog with the contents of
00036                                a DEVMODE structure.
00037
00038     GetDevmodeDlg()         -- Retrieves the user's edits from CDTEST's devmode dlg.
00039
00040     GetPrintDlgHandle()     -- Loads and returns a handle to a Print dlg custom template.
00041
00042     GetSetupDlgHandle()     -- Loads and returns a handle to a Setup dlg custom template.
00043
00044     PrintHookProc()         -- Callback function for PRINTDLG->lpfnPrintHook and
00045                                for PRINTDLG->lpfnSetupHook
00046
00047     PrintMultiProc1()       -- Starting address for multithread option thread 1
00048
00049     PrintMultiProc2()       -- Starting address for multithread option thread 2
00050
00051     MultiThreadPrintDlg()   -- Creates two threads which each call PrintDlg()
00052
00053     EnablePrintControls()   -- Enables or disables CDTEST's print dlg controls.
00054
00055     DoPrintDlgStuff()       -- Calls PrintDlg()
00056
00057 ************************************************************************/
00058
00059
00060 #include <windows.h>
00061 #include <commdlg.h>
00062 #include <stdlib.h>
00063 #include <winnls.h>
00064 #include "cdtest.h"
00065 #include "print.h"
00066 #include "devnames.h"
00067 #include "devmode.h"
00068 #include "dlgs.h"
00069
00070
00071
00072 /* Externs, prototypes, variable declarations for print.c */
00073
00074 extern UINT_PTR uMode ;
00075 extern LONG_PTR MyAtol(LPTSTR, BOOL, LPBOOL) ;
00076 UINT_PTR CALLBACK PrintHookProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ;
00077 void InitPrintStruct(HWND, LPPRINTDLG) ;
00078 void FillPrintDlg(HWND, LPPRINTDLG) ;
00079 void GetPrintDlg(HWND, LPPRINTDLG) ;
00080 void FillDevnamesDlg(HWND, LPPRINTDLG) ;
00081 void GetDevnamesDlg(HWND, LPPRINTDLG) ;
00082 void FillDevmodeDlg(HWND, LPPRINTDLG) ;
00083 void GetDevmodeDlg(HWND, LPPRINTDLG) ;
00084 HANDLE GetPrintDlgHandle(void) ;
00085 HANDLE GetSetupDlgHandle(void) ;
00086 void DoPrintDlgStuff(HWND, LPPRINTDLG) ;
00087
00088 HRSRC hResPrint ;
00089 HGLOBAL hDialogPrint ;
00090 PRINTDLG pd ;
00091 HANDLE hDevNames ;
00092 HANDLE hDevMode ;
00093
00094 TCHAR szDriverOffset[100] ;
00095 TCHAR szDeviceOffset[100] ;
00096 TCHAR szOutputOffset[100] ;
00097 TCHAR szPrintTempName[40] ;
00098 TCHAR szSetupTempName[40] ;
00099
00100
00101 /* Multithreading function declarations, variables */
00102
00103 DWORD PrintMultiProc1(LPDWORD) ;
00104 DWORD PrintMultiProc2(LPDWORD) ;
00105 void MultiThreadPrintDlg(void) ;
00106 void EnablePrintControls(HWND, BOOL) ;
00107
00108 HANDLE hPrintThread1 ;
00109 HANDLE hPrintThread2 ;
00110 DWORD dwPrintThreadID1 ;
00111 DWORD dwPrintThreadID2 ;
00112 DWORD dwPrintThreadParm1 ;
00113 DWORD dwPrintThreadParm2 ;
00114 PRINTDLG pdThread1 ;
00115 PRINTDLG pdThread2 ;
00116 HWND hwndMainPrint ;
00117 int nOpenDialogCount ;
00118
00119 HBRUSH hBrushDlg ;
00120 HBRUSH hBrushEdit ;    //brush handles for new colors done with hook proc
00121 HBRUSH hBrushButton ;
00122
00123
00124
00125
00126
00127 /************************************************************************
00128
00129   Function: DoPrintDialog(HWND)
00130
00131   Purpose:  Creates CDTEST's print dialog box.
00132
00133   Returns:  Nothing.
00134
00135   Comments: There is only one dialog for both Print Setup and Print Print.
00136             The Print Print dialog is the default.  To create the Print
00137             Setup dialog, enter the value for PD_PRINTSETUP into the
00138             "Flags" edit box and click OK.
00139
00140 ************************************************************************/
00141
00142 void DoPrintDialog(HWND hwnd)
00143 {
00144
00145
00146   DialogBox(hInst, MAKEINTRESOURCE(ID_PRINTDIALOG),
00147             hwnd, PrintProc) ;
00148
00149 }
00150
00151
00152
00153
00154
00155
00156
00157 /************************************************************************
00158
00159   Function: PrintProc(HWND, UINT, WPARAM, LPARAM)
00160
00161   Purpose:  Callback function for CDTEST's print dialog box.
00162
00163   Returns:  TRUE or FALSE depending on the situation/message.
00164
00165   Comments:
00166
00167 ************************************************************************/
00168
00169 INT_PTR APIENTRY PrintProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00170 {
00171   switch (msg)
00172   {
00173     case WM_INITDIALOG:
00174
00175         InitPrintStruct(hwnd, &pd) ;
00176         FillPrintDlg(hwnd, &pd) ;
00177
00178         *(&pdThread1) = *(&pdThread2) = *(&pd) ;
00179
00180         hwndMainPrint = hwnd ;
00181
00182         nOpenDialogCount = 0 ;
00183
00184         SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEP)) ;
00185
00186         break ;
00187
00188
00189     case UMSG_DECREMENTDLGCOUNT: //user defined message that is send when
00190                                  //each thread created when multithreading ends
00191         nOpenDialogCount-- ;
00192
00193         if (nOpenDialogCount == 0)               //once both multitheading dlgs
00194             EnablePrintControls(hwnd, TRUE) ;   //are done, enable the controls again
00195
00196         break ;
00197
00198
00199     case WM_COMMAND:
00200     {
00201         switch (LOWORD(wParam))
00202         {
00203           case IDOK:
00204             GetPrintDlg(hwnd, &pd) ;
00205             DoPrintDlgStuff(hwnd, &pd) ;
00206             break ;
00207
00208           case IDCANCEL:
00209
00210             if (pd.hDC)
00211               ReleaseDC(hwnd, pd.hDC) ;
00212
00213             EndDialog(hwnd, FALSE) ;
00214             break ;
00215
00216           case ID_RESETPRINT:
00217             SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEP)) ;
00218             InitPrintStruct(hwnd, &pd) ;
00219             FillPrintDlg(hwnd, &pd) ;
00220             SendDlgItemMessage(hwnd, ID_PRESETUPP,   BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00221             SendDlgItemMessage(hwnd, ID_PREPRINTP,   BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00222             SendDlgItemMessage(hwnd, ID_NULLSTRUCTP, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00223             break ;
00224
00225           case ID_EDITDEVNAMES:
00226             DialogBox(hInst, MAKEINTRESOURCE(ID_DEVNAMESDIALOG),
00227                       hwnd, DevnamesProc) ;
00228             break ;
00229
00230           case ID_EDITDEVMODE:
00231             DialogBox(hInst, MAKEINTRESOURCE(ID_DEVMODEDIALOG),
00232                       hwnd, DevmodeProc) ;
00233             break ;
00234
00235           case ID_MULTITHREADPRINT:
00236             nOpenDialogCount = 2 ;
00237             EnablePrintControls(hwnd, FALSE) ;
00238             MultiThreadPrintDlg() ;
00239             break ;
00240
00241           default: break ;
00242         }
00243     }
00244
00245     default:
00246
00247       /* If the help button is pressed in the PrintDlg() dialog box,
00248          it will send a message Registered with RegisterWindowMessage()
00249          to the parent window.  The message nHelpMessage was registered
00250          at application startup */
00251
00252       if (msg == nHelpMessage)
00253         MessageBox(GetForegroundWindow(), TEXT("Hello from the help button"),
00254                    TEXT("Print Help Button"), MB_OK | MB_APPLMODAL) ;
00255       break ;
00256   }
00257
00258   return FALSE ;
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268 /************************************************************************
00269
00270   Function: DevnamesProc(HWND, UINT, WPARAM, LPARAM)
00271
00272   Purpose:  Callback function for the Devnames dialog box
00273
00274   Returns:  TRUE or FALSE depending on situation / message
00275
00276   Comments:
00277
00278 ************************************************************************/
00279
00280 INT_PTR APIENTRY DevnamesProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00281 {
00282   switch (msg)
00283   {
00284     case WM_INITDIALOG:
00285         FillDevnamesDlg(hwnd, &pd) ;
00286         break ;
00287
00288     case WM_COMMAND:
00289     {
00290         switch (LOWORD(wParam))
00291         {
00292           case IDOK:
00293             GetDevnamesDlg(hwnd, &pd) ;
00294             EndDialog(hwnd, TRUE) ;
00295             break ;
00296
00297           case IDCANCEL:
00298             EndDialog(hwnd, FALSE) ;
00299             break ;
00300
00301           default: break ;
00302         }
00303     }
00304
00305     default: break ;
00306   }
00307
00308   return FALSE ;
00309 }
00310
00311
00312
00313
00314
00315
00316 /************************************************************************
00317
00318   Function: DevmodeProc(HWND, UINT, WPARAM, LONG)
00319
00320   Purpose:  Callback function for the Devmode dialog box
00321
00322   Returns:  TRUE or FALSE depending on situation / message
00323
00324   Comments:
00325
00326 ************************************************************************/
00327
00328 INT_PTR APIENTRY DevmodeProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00329 {
00330   switch (msg)
00331   {
00332     case WM_INITDIALOG:
00333         FillDevmodeDlg(hwnd, &pd) ;
00334         break ;
00335
00336     case WM_COMMAND:
00337     {
00338         switch (LOWORD(wParam))
00339         {
00340           case IDOK:
00341             GetDevmodeDlg(hwnd, &pd) ;
00342             EndDialog(hwnd, TRUE) ;
00343             break ;
00344
00345           case IDCANCEL:
00346             EndDialog(hwnd, FALSE) ;
00347             break ;
00348
00349           default: break ;
00350         }
00351     }
00352
00353     default: break ;
00354   }
00355
00356   return FALSE ;
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366 /************************************************************************
00367
00368   Function: InitPrintStruct(HWND, LPPRINTDLG)
00369
00370   Purpose:  Fills a PRINTDLG structure with some default values.
00371
00372   Returns:  Nothing.
00373
00374   Comments:
00375
00376     In order to fill in the hDevMode and hDevNames PRINTDLG structure
00377     elements, a call to PrintDlg() must be made with the
00378     (PD_RETURNDEFAULT | PD_RETURNDC) flag bits set.
00379
00380 ************************************************************************/
00381
00382 void InitPrintStruct(HWND hwnd, LPPRINTDLG ppd)
00383 {
00384   DWORD dwTempFlags = 0 ;
00385
00386   ppd->lStructSize = sizeof(PRINTDLG) ;
00387   ppd->hwndOwner = hwnd ;
00388   ppd->hDevMode = (HANDLE) 0 ;
00389   ppd->hDevNames = (HANDLE) 0 ;
00390   ppd->hDC = (HDC) 0 ;
00391   ppd->Flags = PD_RETURNDC | PD_COLLATE | PD_SHOWHELP | PD_PAGENUMS ;
00392   ppd->nFromPage = 1 ;
00393   ppd->nToPage = 10 ;
00394   ppd->nMinPage = 1 ;
00395   ppd->nMaxPage = 10 ;
00396   ppd->nCopies = 1000 ;
00397   ppd->hInstance = (HANDLE) hInst ;
00398   ppd->lCustData = 0L ;
00399
00400   ppd->lpfnPrintHook = PrintHookProc ;
00401   ppd->lpfnSetupHook = PrintHookProc ;
00402
00403   lstrcpyn(szPrintTempName, TEXT("prtemp1"), ARRAYSIZE(szPrintTempName)) ;
00404   ppd->lpPrintTemplateName = szPrintTempName ;
00405
00406   lstrcpyn(szSetupTempName, TEXT("prtemp2"), ARRAYSIZE(szSetupTempName)) ;
00407   ppd->lpSetupTemplateName = szSetupTempName ;
00408
00409   ppd->hPrintTemplate = (HANDLE) 0 ;   //these are unknown right now
00410   ppd->hSetupTemplate = (HANDLE) 0 ;
00411
00412
00413   /* Let's fill the hDevMode and hDevNames structures. */
00414   /* This call should just return handles to structures of this */
00415   /* type filled with the info for the default printer */
00416
00417   dwTempFlags = ppd->Flags ;
00418   ppd->Flags = PD_RETURNDEFAULT | PD_RETURNDC ;
00419   PrintDlg(ppd) ;
00420
00421   ppd->Flags = dwTempFlags ;
00422 }
00423
00424
00425
00426
00427
00428
00429
00430 /************************************************************************
00431
00432   Function: FillPrintDlg(HWND, LPPRINTDLG)
00433
00434   Purpose:  Fills CDTEST's print dialog with the contents of a
00435             PRINTDLG structure.
00436
00437   Returns:  Nothing.
00438
00439   Comments:
00440
00441 ************************************************************************/
00442
00443
00444 void FillPrintDlg(HWND hwnd, LPPRINTDLG ppd)
00445 {
00446   wsprintf(szTemp, szLongFilter, ppd->lStructSize) ;
00447   SetDlgItemText(hwnd, ID_STRUCTSIZEP, szTemp) ;
00448
00449   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hwndOwner) ;
00450   SetDlgItemText(hwnd, ID_HWNDOWNERP, szTemp) ;
00451
00452   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hDevMode) ;
00453   SetDlgItemText(hwnd, ID_HDEVMODEP, szTemp) ;
00454
00455   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hDevNames) ;
00456   SetDlgItemText(hwnd, ID_HDEVNAMESP, szTemp) ;
00457
00458   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hDC) ;
00459   SetDlgItemText(hwnd, ID_HDCP, szTemp) ;
00460
00461   wsprintf(szTemp, szLongFilter, ppd->Flags) ;
00462   SetDlgItemText(hwnd, ID_FLAGSP, szTemp) ;
00463
00464   wsprintf(szTemp, szShortFilter, ppd->nFromPage) ;
00465   SetDlgItemText(hwnd, ID_FROMPAGEP, szTemp) ;
00466
00467   wsprintf(szTemp, szShortFilter, ppd->nToPage) ;
00468   SetDlgItemText(hwnd, ID_TOPAGEP, szTemp) ;
00469
00470   wsprintf(szTemp, szShortFilter, ppd->nMinPage) ;
00471   SetDlgItemText(hwnd, ID_MINPAGEP, szTemp) ;
00472
00473   wsprintf(szTemp, szShortFilter, ppd->nMaxPage) ;
00474   SetDlgItemText(hwnd, ID_MAXPAGEP, szTemp) ;
00475
00476   wsprintf(szTemp, szShortFilter, ppd->nCopies) ;
00477   SetDlgItemText(hwnd, ID_COPIESP, szTemp) ;
00478
00479   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hInstance) ;
00480   SetDlgItemText(hwnd, ID_HINSTANCEP, szTemp) ;
00481
00482   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->lCustData) ;
00483   SetDlgItemText(hwnd, ID_CUSTDATAP, szTemp) ;
00484
00485   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->lpfnPrintHook) ;
00486   SetDlgItemText(hwnd, ID_PRINTHOOKP, szTemp) ;
00487
00488   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->lpfnSetupHook) ;
00489   SetDlgItemText(hwnd, ID_SETUPHOOKP, szTemp) ;
00490
00491   SetDlgItemText(hwnd, ID_LPPRINTTEMPP, ppd->lpPrintTemplateName) ;
00492
00493   SetDlgItemText(hwnd, ID_LPSETUPTEMPP, ppd->lpSetupTemplateName) ;
00494
00495   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hPrintTemplate) ;
00496   SetDlgItemText(hwnd, ID_HPRINTTEMPP, szTemp) ;
00497
00498   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hSetupTemplate) ;
00499   SetDlgItemText(hwnd, ID_HSETUPTEMPP, szTemp) ;
00500 }
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510 /************************************************************************
00511
00512   Function: GetPrintDlg(HWND, LPPRINTDLG)
00513
00514   Purpose:  Fills a PRINTDLG structure with the users choices in CDTEST's
00515             print dialog box.
00516
00517   Returns:  Nothing.
00518
00519   Comments:
00520
00521 ************************************************************************/
00522
00523 void GetPrintDlg(HWND hwnd, LPPRINTDLG ppd)
00524 {
00525   BOOL b ;
00526   TCHAR szNum[20] ;
00527
00528   #define WMAX 20
00529
00530   GetDlgItemText(hwnd, ID_STRUCTSIZEP, szNum, WMAX) ;
00531   ppd->lStructSize = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00532
00533   GetDlgItemText(hwnd, ID_HWNDOWNERP, szNum, WMAX) ;
00534   ppd->hwndOwner = (HWND) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00535
00536   GetDlgItemText(hwnd, ID_HDEVMODEP, szNum, WMAX) ;
00537   ppd->hDevMode = (HANDLE) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00538
00539   GetDlgItemText(hwnd, ID_HDEVNAMESP, szNum, WMAX) ;
00540   ppd->hDevNames = (HANDLE) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00541
00542   GetDlgItemText(hwnd, ID_HDCP, szNum, WMAX) ;
00543   ppd->hDC = (HDC) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00544
00545   GetDlgItemText(hwnd, ID_FLAGSP, szNum, WMAX) ;
00546   ppd->Flags = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00547
00548   GetDlgItemText(hwnd, ID_FROMPAGEP, szNum, WMAX) ;
00549   ppd->nFromPage = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00550
00551   GetDlgItemText(hwnd, ID_TOPAGEP, szNum, WMAX) ;
00552   ppd->nToPage = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00553
00554   GetDlgItemText(hwnd, ID_MINPAGEP, szNum, WMAX) ;
00555   ppd->nMinPage = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00556
00557   GetDlgItemText(hwnd, ID_MAXPAGEP, szNum, WMAX) ;
00558   ppd->nMaxPage = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00559
00560   GetDlgItemText(hwnd, ID_COPIESP, szNum, WMAX) ;
00561   ppd->nCopies = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00562
00563   GetDlgItemText(hwnd, ID_HINSTANCEP, szNum, WMAX) ;
00564   ppd->hInstance = (HANDLE) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00565
00566   GetDlgItemText(hwnd, ID_CUSTDATAP, szNum, WMAX) ;
00567   ppd->lCustData = MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00568
00569   GetDlgItemText(hwnd, ID_PRINTHOOKP, szNum, WMAX) ;
00570   ppd->lpfnPrintHook = (LPPRINTHOOKPROC) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00571
00572   GetDlgItemText(hwnd, ID_SETUPHOOKP, szNum, WMAX) ;
00573   ppd->lpfnSetupHook = (LPSETUPHOOKPROC) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00574
00575   GetDlgItemText(hwnd, ID_LPPRINTTEMPP, szPrintTempName, 100) ;
00576
00577   GetDlgItemText(hwnd, ID_LPSETUPTEMPP, szSetupTempName, 100) ;
00578
00579   GetDlgItemText(hwnd, ID_HPRINTTEMPP, szNum, WMAX) ;
00580   ppd->hPrintTemplate = (HANDLE) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00581
00582   GetDlgItemText(hwnd, ID_HSETUPTEMPP, szNum, WMAX) ;
00583   ppd->hSetupTemplate = (HANDLE) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00584
00585 }
00586
00587
00588
00589
00590
00591
00592
00593
00594 /************************************************************************
00595
00596   Function: FillDevnamesDlg(HWND, LPPRINTDLG)
00597
00598   Purpose:  Fills CDTEST's devnames dialog box with the values in
00599             The hDevNames structure member of a PRINTDLG structure.
00600
00601   Returns:  Nothing.
00602
00603   Comments:
00604
00605 ************************************************************************/
00606
00607
00608 void FillDevnamesDlg(HWND hwnd, LPPRINTDLG ppd)
00609 {
00610   LPDEVNAMES pn = (LPDEVNAMES) 0 ;
00611
00612   if (ppd->hDevNames == (HANDLE) 0)
00613     return ;
00614
00615   pn = (LPDEVNAMES) GlobalLock(ppd->hDevNames) ;
00616   if (pn == (LPDEVNAMES) NULL) return ;
00617
00618
00619   /* To find the strings in this block of memory, add the correct
00620      offset to the original pointer returned by GlobalLock() */
00621
00622   SetDlgItemText(hwnd, ID_WDRIVEROFF, (LPTSTR) pn + pn->wDriverOffset) ;
00623
00624   SetDlgItemText(hwnd, ID_WDEVICEOFF, (LPTSTR) pn + pn->wDeviceOffset) ;
00625
00626   SetDlgItemText(hwnd, ID_WOUTPUTOFF, (LPTSTR) pn + pn->wOutputOffset) ;
00627
00628
00629   wsprintf(szTemp, szShortFilter, (int) pn->wDefault) ;
00630   SetDlgItemText(hwnd, ID_WDEFAULT, szTemp) ;
00631
00632
00633   GlobalUnlock(ppd->hDevNames) ;
00634 }
00635
00636
00637
00638
00639
00640
00641
00642 /************************************************************************
00643
00644   Function: GetDevnamesDlg(HWND, LPPRINTDLG)
00645
00646   Purpose:  Retrieves the user's choices in CDTEST's devnames dialog box,
00647             Allocates some memory to hold a new DEVNAMES structure, fills
00648             the users choices into the new DEVNAMES structure, and sets
00649             the hDevNames member of a PRINTDLG structure to this new
00650             memory handle.
00651
00652
00653   Returns:  Nothing.
00654
00655   Comments:
00656
00657 ************************************************************************/
00658
00659 void GetDevnamesDlg(HWND hwnd, LPPRINTDLG ppd)
00660 {
00661   BOOL b ;
00662   TCHAR szNum[30] ;
00663   LPDEVNAMES pn ;
00664   TCHAR sz1[100] ;
00665   TCHAR sz2[100] ;
00666   TCHAR sz3[100] ;
00667   DWORD dwSize ;
00668   int n1, n2, n3 ;
00669
00670   GetDlgItemText(hwnd, ID_WDRIVEROFF, sz1, 100) ;
00671   GetDlgItemText(hwnd, ID_WDEVICEOFF, sz2, 100) ;
00672   GetDlgItemText(hwnd, ID_WOUTPUTOFF, sz3, 100) ;
00673
00674   n1 = lstrlen(sz1) ;
00675   n2 = lstrlen(sz2) ;
00676   n3 = lstrlen(sz3) ;
00677
00678   if (hDevNames)
00679   {
00680     GlobalFree(hDevNames) ;
00681     hDevNames = (HANDLE) 0 ;
00682   }
00683
00684
00685   /* allocate size of everything + 5 extra bytes for zeroes */
00686
00687   dwSize = sizeof(DEVNAMES) + ((n1+n2+n3+5) * sizeof(TCHAR)) ;
00688
00689
00690   /* Allocate the memory and lock it down */
00691
00692   if (!(hDevNames = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, dwSize)))
00693   {
00694     MessageBox(hwnd, TEXT("Can't Alloc memory for hDevNames!"),
00695                TEXT("Fatal Error!"), MB_OK | MB_APPLMODAL) ;
00696     return ;
00697   }
00698
00699   if (!(pn = (LPDEVNAMES) GlobalLock(hDevNames)))
00700   {
00701     MessageBox(hwnd, TEXT("Can't Lock New hDevNames memory!"),
00702                TEXT("Fatal Error"), MB_OK | MB_APPLMODAL) ;
00703
00704     GlobalFree(hDevNames) ;
00705
00706     hDevNames = (HANDLE) 0 ;
00707
00708     return ;
00709   }
00710
00711
00712   /* skip over devnames and copy string 1 there.  Make sure to
00713      divide by sizeof(TCHAR) or the compiler will create a pointer
00714      that points too far if you compile as a UNICODE program */
00715
00716   pn->wDriverOffset = sizeof(DEVNAMES) / sizeof(TCHAR) ;
00717   lstrcpyn((LPTSTR) pn + pn->wDriverOffset, (LPTSTR) sz1, (dwSize / sizeof(TCHAR)) - pn->wDriverOffset) ;
00718
00719
00720
00721   /* skip over string 1 and add string 1 with a zero between them */
00722
00723   pn->wDeviceOffset = pn->wDriverOffset + (WORD)n1 + 1 ;
00724   lstrcpyn((LPTSTR) pn + pn->wDeviceOffset, (LPTSTR) sz2, (dwSize / sizeof(TCHAR)) - pn->wDeviceOffset) ;
00725
00726
00727
00728   /* skip over string 2 and put string 3 there with a zero between them */
00729
00730   pn->wOutputOffset = pn->wDeviceOffset + (WORD)n2 + 1 ;
00731   lstrcpyn((LPTSTR) pn + pn->wOutputOffset, (LPTSTR) sz3, (dwSize / sizeof(TCHAR)) - pn->wOutputOffset) ;
00732
00733
00734   GetDlgItemText(hwnd, ID_WDEFAULT, szNum, 30) ;
00735   pn->wDefault = (WORD) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00736
00737   GlobalUnlock(hDevNames) ;
00738
00739   ppd->hDevNames = hDevNames ;
00740
00741   wsprintf(szTemp, szLongFilter, ppd->hDevNames) ;
00742   SetDlgItemText(GetParent(hwnd), ID_HDEVNAMESP, szTemp) ;
00743
00744 }
00745
00746
00747
00748
00749
00750
00751 /************************************************************************
00752
00753   Function: FillDevmodeDlg(HWND, LPPRINTDLG)
00754
00755   Purpose: Fills CDTEST's devmode dialog with the contents of the DEVMODE
00756            structure handle of a PRINTDLG structure.
00757
00758
00759   Returns:  Nothing.
00760
00761   Comments:
00762
00763 ************************************************************************/
00764
00765 void FillDevmodeDlg(HWND hwnd, LPPRINTDLG ppd)
00766 {
00767   LPDEVMODE p ;
00768
00769   if (ppd->hDevMode == (HANDLE) 0)
00770     return ;
00771
00772   p = (LPDEVMODE) GlobalLock(ppd->hDevMode) ;
00773   if (p == (LPDEVMODE) NULL) return ;
00774
00775   SetDlgItemText(hwnd, ID_DMDEVNAME, (LPTSTR) p->dmDeviceName) ;
00776
00777   wsprintf(szTemp, szShortFilter, (int) p->dmSpecVersion) ;
00778   SetDlgItemText(hwnd, ID_DMSPECVER, szTemp) ;
00779
00780   wsprintf(szTemp, szShortFilter, (int) p->dmDriverVersion) ;
00781   SetDlgItemText(hwnd, ID_DMDRIVERVER, szTemp) ;
00782
00783   wsprintf(szTemp, szShortFilter, (int) p->dmSize) ;
00784   SetDlgItemText(hwnd, ID_DMSIZEDEV, szTemp) ;
00785
00786   wsprintf(szTemp, szShortFilter, (int) p->dmDriverExtra) ;
00787   SetDlgItemText(hwnd, ID_DMDRIVEREXTRA, szTemp) ;
00788
00789   wsprintf(szTemp, szShortFilter, (int) p->dmFields) ;
00790   SetDlgItemText(hwnd, ID_DMFIELDS, szTemp) ;
00791
00792   wsprintf(szTemp, szShortFilter, (int) p->dmOrientation) ;
00793   SetDlgItemText(hwnd, ID_DMORIENTATION, szTemp) ;
00794
00795   wsprintf(szTemp, szShortFilter, (int) p->dmPaperSize) ;
00796   SetDlgItemText(hwnd, ID_DMPAPERSIZE, szTemp) ;
00797
00798   wsprintf(szTemp, szLongFilter, p->dmPaperLength) ;
00799   SetDlgItemText(hwnd, ID_DMPAPERLENGTH, szTemp) ;
00800
00801   wsprintf(szTemp, szLongFilter, p->dmPaperWidth) ;
00802   SetDlgItemText(hwnd, ID_DMPAPERWIDTH, szTemp) ;
00803
00804   wsprintf(szTemp, szLongFilter, p->dmScale) ;
00805   SetDlgItemText(hwnd, ID_DMSCALE, szTemp) ;
00806
00807   wsprintf(szTemp, szLongFilter, p->dmCopies) ;
00808   SetDlgItemText(hwnd, ID_DMCOPIES, szTemp) ;
00809
00810   wsprintf(szTemp, szLongFilter, p->dmDefaultSource) ;
00811   SetDlgItemText(hwnd, ID_DMDEFAULTSOURCE, szTemp) ;
00812
00813   wsprintf(szTemp, szLongFilter, p->dmPrintQuality) ;
00814   SetDlgItemText(hwnd, ID_DMPRINTQUALITY, szTemp) ;
00815
00816   wsprintf(szTemp, szLongFilter, p->dmColor) ;
00817   SetDlgItemText(hwnd, ID_DMCOLOR, szTemp) ;
00818
00819   wsprintf(szTemp, szLongFilter, p->dmDuplex) ;
00820   SetDlgItemText(hwnd, ID_DMDUPLEX, szTemp) ;
00821
00822   wsprintf(szTemp, szLongFilter, p->dmCollate) ;
00823   SetDlgItemText(hwnd, ID_DMCOLLATE, szTemp) ;
00824
00825   SetDlgItemText(hwnd, ID_DMFORMNAME, (LPTSTR) p->dmFormName) ;
00826
00827   wsprintf(szTemp, szLongFilter, p->dmBitsPerPel) ;
00828   SetDlgItemText(hwnd, ID_DMBITSPERPEL, szTemp) ;
00829
00830   wsprintf(szTemp, szLongFilter, p->dmPelsWidth) ;
00831   SetDlgItemText(hwnd, ID_DMPELSWIDTH, szTemp) ;
00832
00833   wsprintf(szTemp, szLongFilter, p->dmPelsHeight) ;
00834   SetDlgItemText(hwnd, ID_DMPELSHEIGHT, szTemp) ;
00835
00836   wsprintf(szTemp, szLongFilter, p->dmDisplayFrequency) ;
00837   SetDlgItemText(hwnd, ID_DMDISPLAYFREQ, szTemp) ;
00838
00839   GlobalUnlock(ppd->hDevMode) ;
00840 }
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850 /************************************************************************
00851
00852   Function: GetDevmodeDlg(HWND, LPPRINTDLG)
00853
00854   Purpose:  Retrieves the user's edits in CDTEST's DEVMODE dialog box,
00855             allocates memory for a new DEVMODE structure, fills that
00856             memory with the user's edits, and puts a handle to that
00857             memory in the hDevMode member of a PRINTDLG structure.
00858
00859   Returns:  Nothing.
00860
00861   Comments:
00862
00863 ************************************************************************/
00864
00865 void GetDevmodeDlg(HWND hwnd, LPPRINTDLG ppd)
00866 {
00867   LPDEVMODE p ;
00868   BOOL b ;
00869   TCHAR szNum[30] ;
00870
00871   #define WMAXDEV 30
00872
00873   if (hDevMode)
00874   {
00875     GlobalFree(hDevMode) ;
00876     hDevMode = (HANDLE) 0 ;
00877   }
00878
00879   if (!(hDevMode = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, sizeof(DEVMODE))))
00880   {
00881     MessageBox(hwnd, TEXT("Can't allocate memory for hDevMode"),
00882                TEXT("Fatal Error"), MB_OK | MB_APPLMODAL) ;
00883     return ;
00884   }
00885
00886   if (!(p = (LPDEVMODE) GlobalLock(hDevMode)))
00887   {
00888     MessageBox(hwnd, TEXT("Can't lock memory for hDevMode"),
00889                TEXT("Fatal Error"), MB_OK | MB_APPLMODAL) ;
00890
00891     GlobalFree(hDevMode) ;
00892     hDevMode = (HANDLE) 0 ;
00893
00894     return ;
00895   }
00896
00897   GetDlgItemText(hwnd, ID_DMDEVNAME, (LPTSTR)p->dmDeviceName, 32) ;
00898
00899   GetDlgItemText(hwnd, ID_DMSPECVER, szNum, WMAXDEV) ;
00900   p->dmSpecVersion = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00901
00902   GetDlgItemText(hwnd, ID_DMDRIVERVER, szNum, WMAXDEV) ;
00903   p->dmDriverVersion = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00904
00905   GetDlgItemText(hwnd, ID_DMSIZEDEV, szNum, WMAXDEV) ;
00906   p->dmSize = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00907
00908   GetDlgItemText(hwnd, ID_DMDRIVEREXTRA, szNum, WMAXDEV) ;
00909   p->dmDriverExtra = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00910
00911   GetDlgItemText(hwnd, ID_DMFIELDS, szNum, WMAXDEV) ;
00912   p->dmFields = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00913
00914   GetDlgItemText(hwnd, ID_DMORIENTATION, szNum, WMAXDEV) ;
00915   p->dmOrientation = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00916
00917   GetDlgItemText(hwnd, ID_DMPAPERSIZE, szNum, WMAXDEV) ;
00918   p->dmPaperSize = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00919
00920   GetDlgItemText(hwnd, ID_DMPAPERLENGTH, szNum, WMAXDEV) ;
00921   p->dmPaperLength = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00922
00923   GetDlgItemText(hwnd, ID_DMPAPERWIDTH, szNum, WMAXDEV) ;
00924   p->dmPaperWidth = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00925
00926   GetDlgItemText(hwnd, ID_DMSCALE, szNum, WMAXDEV) ;
00927   p->dmScale = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00928
00929   GetDlgItemText(hwnd, ID_DMCOPIES, szNum, WMAXDEV) ;
00930   p->dmCopies = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00931
00932   GetDlgItemText(hwnd, ID_DMDEFAULTSOURCE, szNum, WMAXDEV) ;
00933   p->dmDefaultSource = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00934
00935   GetDlgItemText(hwnd, ID_DMPRINTQUALITY, szNum, WMAXDEV) ;
00936   p->dmPrintQuality = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00937
00938   GetDlgItemText(hwnd, ID_DMCOLOR, szNum, WMAXDEV) ;
00939   p->dmColor = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00940
00941   GetDlgItemText(hwnd, ID_DMDUPLEX, szNum, WMAXDEV) ;
00942   p->dmDuplex = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00943
00944   GetDlgItemText(hwnd, ID_DMCOLLATE, szNum, WMAXDEV) ;
00945   p->dmCollate = (short) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00946
00947   GetDlgItemText(hwnd, ID_DMFORMNAME, (LPTSTR)p->dmFormName, 32) ;
00948
00949   GetDlgItemText(hwnd, ID_DMBITSPERPEL, szNum, WMAXDEV) ;
00950   p->dmBitsPerPel = (USHORT) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00951
00952   GetDlgItemText(hwnd, ID_DMPELSWIDTH, szNum, WMAXDEV) ;
00953   p->dmPelsWidth = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00954
00955   GetDlgItemText(hwnd, ID_DMPELSHEIGHT, szNum, WMAXDEV) ;
00956   p->dmPelsHeight = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00957
00958   GetDlgItemText(hwnd, ID_DMDISPLAYFREQ, szNum, WMAXDEV) ;
00959   p->dmDisplayFrequency = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00960
00961   GlobalUnlock(hDevMode) ;
00962   ppd->hDevMode = hDevMode ;
00963
00964   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hDevMode) ;
00965   SetDlgItemText(GetParent(hwnd), ID_HDEVMODEP, szTemp) ;
00966 }
00967
00968
00969
00970
00971
00972
00973 /************************************************************************
00974
00975   Function: GetPrintDlgHandle(void)
00976
00977   Purpose:  Finds the custom Print dialog template in the EXE, loads it
00978             into a handle, and returns the handle.
00979
00980   Returns:  Nothing.
00981
00982   Comments:
00983
00984 ************************************************************************/
00985
00986 HANDLE GetPrintDlgHandle(void)
00987 {
00988   hResPrint = FindResource(hInst, TEXT("prtemp1"), RT_DIALOG) ;
00989
00990   hDialogPrint = LoadResource(hInst, hResPrint) ;
00991
00992
00993   return hDialogPrint ;
00994 }
00995
00996
00997
00998
00999
01000
01001
01002
01003 /************************************************************************
01004
01005   Function: GetSetupDlgHandle(void)
01006
01007   Purpose:  Finds the custom Setup dialog template in the EXE, loads it
01008             into a handle, and returns the handle.
01009
01010   Returns:  Nothing.
01011
01012   Comments:
01013
01014 ************************************************************************/
01015
01016 HANDLE GetSetupDlgHandle(void)
01017 {
01018   hResPrint = FindResource(hInst, TEXT("prtemp2"), RT_DIALOG) ;
01019
01020   hDialogPrint = LoadResource(hInst, hResPrint) ;
01021
01022   return hDialogPrint ;
01023 }
01024
01025
01026
01027
01028
01029
01030
01031
01032 /************************************************************************
01033
01034   Function: PrintHookProc(HWND, UINT, WPARAM, LPARAM)
01035
01036   Purpose:  A callback function that will receive messages intended for
01037             the PrintDlg() dialog boxes before the normal common dialog
01038             routine receives them.
01039
01040
01041   Returns:  FALSE to allow the common dialogs to process the message
01042             with its normal logic.  TRUE to discard the message.
01043
01044   Comments:
01045
01046      To enable this function for the Print dialog in CDTEST, enter the
01047      value for PD_ENABLEPRINTHOOK in the "Flags" edit box.
01048
01049      To enable this function for the Setup dialog in CDTEST, enter the
01050      value for (PD_ENABLESETUPHOOK | PD_PRINTSETUP) in the "Flags" edit box.
01051
01052 ************************************************************************/
01053
01054 UINT_PTR CALLBACK PrintHookProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
01055 {
01056   LPPRINTDLG pPr ;
01057   TCHAR szMsg[50] ;
01058
01059   switch(msg)
01060   {
01061     case WM_INITDIALOG:
01062
01063       pPr = (LPPRINTDLG) lParam ;
01064
01065       if (pPr->lCustData != 0)
01066       {
01067         wsprintf(szMsg, TEXT("PRINTDLG->lCustData is: %ld"), pPr->lCustData) ;
01068
01069         MessageBox(hwnd, szMsg, TEXT("lCustData Sent!"), MB_OK | MB_APPLMODAL) ;
01070       }
01071
01072       SetWindowText(hwnd, TEXT("Print Hook Proc Dialog")) ;
01073
01074       break ;
01075
01076     /* use the WM_CTLCOLOR* messages to change the color of the Open
01077        dialog */
01078
01079     case WM_CTLCOLORDLG:
01080
01081         if (!hBrushDlg)
01082             hBrushDlg = GetStockObject(LTGRAY_BRUSH) ;
01083
01084         return (LRESULT) hBrushDlg ;
01085
01086         break ;
01087
01088
01089     case WM_CTLCOLORBTN:
01090
01091         SetBkMode((HDC) wParam, TRANSPARENT) ;   //sets background color
01092                                                  //for push and check box
01093                                                  //buttons...
01094
01095         if (!hBrushButton)
01096             hBrushButton = GetStockObject(LTGRAY_BRUSH) ;
01097
01098         return (LRESULT) hBrushButton ;
01099
01100         break ;
01101
01102
01103     case WM_CTLCOLORSTATIC:
01104
01105         SetTextColor((HDC) wParam, RGB(0x00, 0xff, 0x00)) ;  //green
01106         SetBkMode((HDC) wParam, TRANSPARENT) ;               //transparent text
01107
01108         if (!hBrushDlg)
01109             hBrushDlg = GetStockObject(LTGRAY_BRUSH) ;
01110
01111         return (LRESULT) hBrushDlg ;
01112
01113         break ;
01114
01115
01116     default:
01117       break ;
01118   }
01119
01120   return 0 ;   //send msg to the common dialog code
01121 }
01122
01123
01124
01125
01126
01127
01128
01129
01130 /************************************************************************
01131
01132   Function: PrintMultiProc1(LPDWORD)
01133
01134   Purpose:  Is the starting address for the first new thread when
01135             multithreading.
01136
01137   Returns:  Any DWORD value.
01138
01139   Comments:
01140             The new thread will start executing here and will end when
01141             the PrintDlg() function returns and it has posted a message
01142             to the CDTEST's print dialog window saying that one of the
01143             two multithreading dialogs been terminated.
01144
01145 ************************************************************************/
01146
01147 DWORD PrintMultiProc1(LPDWORD pdw)
01148 {
01149   GetPrintDlg(hwndMainPrint, &pdThread1) ;
01150
01151   DoPrintDlgStuff(hwndMainPrint, &pdThread1) ;
01152
01153   PostMessage(hwndMainPrint, UMSG_DECREMENTDLGCOUNT, 0, 0L ) ;
01154
01155   return 0L ;
01156 }
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166 /************************************************************************
01167
01168   Function: PrintMultiProc2(LPDWORD)
01169
01170   Purpose:  Is the starting address for the second new thread when
01171             multithreading.
01172
01173   Returns:  Any DWORD value.
01174
01175   Comments:
01176             The new thread will start executing here and will end when
01177             the PrintDlg() function returns and it has posted a message
01178             to the CDTEST's print dialog window saying that one of the
01179             two multithreading dialogs been terminated.
01180
01181 ************************************************************************/
01182
01183 DWORD PrintMultiProc2(LPDWORD pdw)
01184 {
01185   GetPrintDlg(hwndMainPrint, &pdThread2) ;
01186
01187   DoPrintDlgStuff(hwndMainPrint, &pdThread2) ;
01188
01189   PostMessage(hwndMainPrint, UMSG_DECREMENTDLGCOUNT, 0, 0L ) ;
01190
01191   return 0L ;
01192 }
01193
01194
01195
01196
01197
01198
01199
01200
01201 /************************************************************************
01202
01203   Function: MultiThreadPrintDlg(void)
01204
01205   Purpose:  Is the starting address for the first new thread when
01206             multithreading.
01207
01208   Returns:  Any DWORD value.
01209
01210   Comments:
01211             The new thread will start executing here and will end when
01212             the PrintDlg() function returns and it has posted a message
01213             to the CDTEST's print dialog window saying that one of the
01214             two multithreading dialogs been terminated.
01215
01216 ************************************************************************/
01217
01218 void MultiThreadPrintDlg(void)
01219 {
01220
01221   dwPrintThreadParm1 = dwPrintThreadParm2 = 0L ;
01222
01223   if (!(hPrintThread1 = CreateThread((LPSECURITY_ATTRIBUTES) NULL, 0,
01224                                      (LPTHREAD_START_ROUTINE) PrintMultiProc1,
01225                                      &dwPrintThreadParm1, CREATE_SUSPENDED, &dwPrintThreadID1)))
01226
01227   {
01228     MessageBox(GetForegroundWindow(), TEXT("Error creating thread 1"), NULL,
01229                MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL) ;
01230
01231     nOpenDialogCount = 0 ;
01232
01233     EnablePrintControls(hwndMainPrint, TRUE) ;
01234
01235     return ;
01236   }
01237
01238
01239   if (!(hPrintThread2 = CreateThread((LPSECURITY_ATTRIBUTES) NULL, 0,
01240                                      (LPTHREAD_START_ROUTINE) PrintMultiProc2,
01241                                      &dwPrintThreadParm2, CREATE_SUSPENDED, &dwPrintThreadID2)))
01242   {
01243     MessageBox(GetForegroundWindow(), TEXT("Error creating thread 2"), NULL,
01244                MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL) ;
01245
01246     nOpenDialogCount = 0 ;
01247
01248     EnablePrintControls(hwndMainPrint, TRUE) ;
01249
01250     return ;
01251   }
01252
01253   ResumeThread(hPrintThread1) ;
01254
01255   ResumeThread(hPrintThread2) ;
01256
01257   return ;
01258 }
01259
01260
01261
01262
01263
01264
01265
01266 /************************************************************************
01267
01268   Function: EnablePrintControls(HWND, BOOL)
01269
01270   Purpose:  Enable or disable CDTEST's print dialog's controls.
01271
01272   Returns:  Nothing.
01273
01274   Comments: This is necessary when CDTEST is multithreading.
01275
01276 ************************************************************************/
01277
01278 void EnablePrintControls(HWND hwnd, BOOL bEnable)
01279 {
01280   EnableWindow(GetDlgItem(hwnd, IDOK), bEnable) ;
01281   EnableWindow(GetDlgItem(hwnd, IDCANCEL), bEnable) ;
01282   EnableWindow(GetDlgItem(hwnd, ID_RESETPRINT), bEnable) ;
01283   EnableWindow(GetDlgItem(hwnd, ID_MULTITHREADPRINT), bEnable) ;
01284   EnableWindow(GetDlgItem(hwnd, ID_EDITDEVMODE), bEnable) ;
01285   EnableWindow(GetDlgItem(hwnd, ID_EDITDEVNAMES), bEnable) ;
01286 }
01287
01288
01289
01290
01291
01292
01293 /************************************************************************
01294
01295   Function: DoPrintDlgStuff(HWND, LPPRINTDLG)
01296
01297   Purpose:  Calls PrintDlg() with the correct parameters.
01298
01299   Returns:  Nothing.
01300
01301   Comments:
01302
01303 ************************************************************************/
01304
01305
01306 void DoPrintDlgStuff(HWND hwnd, LPPRINTDLG ppd)
01307 {
01308   BOOL bRet = FALSE ;
01309
01310
01311   /* Figure out how the user want's to call PrintDlg() */
01312
01313   if (IsDlgButtonChecked(hwnd, ID_PREPRINTP) == 1)
01314     ppd->hPrintTemplate = GetPrintDlgHandle() ;
01315
01316   if (IsDlgButtonChecked(hwnd, ID_PRESETUPP) == 1)
01317     ppd->hSetupTemplate = GetSetupDlgHandle() ;
01318
01319   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hPrintTemplate) ;
01320   SetDlgItemText(hwnd, ID_HPRINTTEMPP, szTemp) ;
01321
01322   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) ppd->hSetupTemplate) ;
01323   SetDlgItemText(hwnd, ID_HSETUPTEMPP, szTemp) ;
01324
01325
01326
01327   /* Call the function */
01328
01329   if (IsDlgButtonChecked(hwnd, ID_NULLSTRUCTP) == 1)
01330     bRet = PrintDlg((LPPRINTDLG) NULL) ;
01331   else
01332     bRet = PrintDlg(ppd) ;
01333
01334
01335
01336   /* Clean up and show results */
01337
01338   wsprintf(szTemp, szLongFilter, CommDlgExtendedError()) ;
01339   SetDlgItemText(hwnd, ID_ERRORP, szTemp) ;
01340
01341   SetDlgItemInt(hwnd, ID_RETURNP, bRet, TRUE) ;
01342
01343   if (hDialogPrint)
01344   {
01345     FreeResource(hDialogPrint) ; //obsolete call, but
01346     hDialogPrint = (HANDLE) 0 ;  //it's possible that this
01347     hResPrint = (HANDLE) 0 ;    //might be recompiled for win 3.x
01348   }
01349
01350   pd.hDevMode = ppd->hDevMode ;    //need to fix this so that FillDevnamesDlg()
01351   pd.hDevNames = ppd->hDevNames ;  //and FillDevmodeDlg() work...
01352
01353   FillPrintDlg(hwnd, ppd) ;
01354
01355   if (ppd->hDC)  //release the HDC after its value is
01356                  //returned to the test app
01357   {
01358     ReleaseDC(ppd->hwndOwner, ppd->hDC) ;
01359     ppd->hDC = (HDC) 0 ;
01360   }
01361 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CListBoxLite Member List

This is the complete list of members for CListBoxLite, including all inherited members.
AddString(WCHAR *pwszString) | CListBoxLite | [inline, virtual]
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CListBoxLite(HWND hWndParent=NULL, UINT nID=0) | CListBoxLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeleteString(WPARAM wParam) | CListBoxLite | [inline, virtual]
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetCount() | CListBoxLite | [inline, virtual]
GetCurSel() const | CListBoxLite | [inline, virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetItemParam(INDEX nIndex) const | CListBoxLite | [inline, virtual]
GetText(INDEX nIndex, WCHAR *pwszBuffer) | CListBoxLite | [inline, virtual]
GetTextLen(INDEX nIndex) | CListBoxLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CListBoxLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDblClk(INT iID, HWND hWndCtrl) | CListBoxLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetCurSel(WPARAM nSelect) | CListBoxLite | [inline, virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetItemParam(INDEX nIndex, LPARAM lParam) | CListBoxLite | [inline, virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CListBoxLite() | CListBoxLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/registry.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

registry.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include <ObjBase.h>
00016 #include "Registry.h"
00017 #include "Globals.h"
00018
00019
00020 #include "TraceMacro.h"
00021 #undef  MODULESTRING
00022 #define MODULESTRING  _T("Registry")
00023
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Internal helper functions prototypes
00027
00028
00029 // Set the given key and its value.
00030 HRESULT SetKeyAndValue( const TCHAR* pszPath, const TCHAR* szSubkey, const TCHAR* szValue);
00031
00032 // Set the given key and its value in the MMC Snapin location
00033 HRESULT SetSnapInKeyAndValue( const TCHAR* szKey, const TCHAR* szSubkey, const TCHAR* szName, const TCHAR* szValue );
00034
00035 // Set the given valuename under the key to value
00036 HRESULT SetValue( const TCHAR* szKey, const TCHAR* szValueName, const TCHAR* szValue);
00037
00038 // Delete szKeyChild and all of its descendents.
00039 HRESULT RecursiveDeleteKey( HKEY hKeyParent, const TCHAR* szKeyChild );
00040
00041 HRESULT SetNodeTypesKey( const TCHAR* szNodeGuid );
00042
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // Public function implementation
00046
00047
00048 //---------------------------------------------------------------------------
00049 //  Register the component in the registry.  This is the minimalist way
00050 //  to register a component, you may want to add keys for ProgID.
00051 //
00052 HRESULT RegisterServer
00053 (
00054   HMODULE        hModule,          //[in] DLL module handle
00055   const CLSID&   clsid,            //[in] Class ID
00056   const TCHAR*   szFriendlyName    //[in] Name string
00057 )
00058 {
00059   // Get server location.
00060   TCHAR    szModule[512] ;
00061   TCHAR*   pszCLSID = NULL;
00062   LPOLESTR wszCLSID = NULL ;
00063   HRESULT  hResult  = S_FALSE;
00064
00065   DWORD dwResult = ::GetModuleFileName( hModule,
00066                                         szModule,
00067                                         sizeof(szModule)/sizeof(TCHAR)
00068                                       );
00069   if( 0 == dwResult ) return HRESULT_FROM_WIN32( dwResult );
00070
00071   do                         // Fail unless we complete everything
00072   {
00073     // Get CLSID string in wide char
00074     hResult = StringFromCLSID( clsid, &wszCLSID ) ;
00075     if( S_OK != hResult )
00076     {
00077       CoTaskMemFree( wszCLSID );
00078       BREAK_ON_ERROR( hResult );
00079     }
00080
00081     W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00082     CoTaskMemFree( wszCLSID );           // Through with wide version
00083
00084     TCHAR szKey[64];                     // Build the CLSID key string CLSID\\{...}
00085     _tcscpy( szKey, _T("CLSID\\") );
00086     _tcscat( szKey, pszCLSID );
00087
00088     // Add the CLSID to the registry.
00089     hResult = SetKeyAndValue( szKey, NULL, szFriendlyName );
00090     BREAK_ON_ERROR( hResult );
00091
00092     // Add the server filename subkey under the CLSID key.
00093     hResult = SetKeyAndValue( szKey, _T("InprocServer32"), szModule );
00094     BREAK_ON_ERROR( hResult );
00095
00096     // Set the threading model
00097     _tcscat( szKey, _T("\\InprocServer32") );
00098     hResult = SetValue( szKey, _T("ThreadingModel"), _T("Apartment") );
00099     BREAK_ON_ERROR( hResult );
00100
00101   }while( 0 );
00102
00103   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00104
00105   return hResult;
00106 }
00107
00108
00109 //---------------------------------------------------------------------------
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer
00113 (
00114   const CLSID& clsid         //[in] Class ID of component to remove
00115 )
00116 {
00117   HRESULT hResult = S_OK;
00118
00119   // Allocate the CLSID string
00120   LPOLESTR wszCLSID = NULL ;
00121   hResult = StringFromCLSID( clsid, &wszCLSID );
00122   if( S_OK != hResult )
00123   {
00124     CoTaskMemFree( wszCLSID );
00125     return hResult;
00126   }
00127
00128   // Build the key CLSID\\{...}
00129   TCHAR szKey[64];
00130   _tcscpy( szKey, _T("CLSID\\") );
00131
00132   TCHAR* pszCLSID = NULL;
00133   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00134   CoTaskMemFree( wszCLSID );           // Through with wide version
00135
00136   _tcscat( szKey, pszCLSID );
00137   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00138
00139   // Delete the CLSID Key - CLSID\{...}
00140   LONG lResult = RecursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );
00141   if( ERROR_SUCCESS != lResult )
00142     hResult = HRESULT_FROM_WIN32( lResult );
00143
00144   return hResult;
00145 }
00146
00147 //---------------------------------------------------------------------------
00148 // Register the snap-in in the registry.
00149 //
00150 HRESULT RegisterSnapin
00151 (
00152   const  CLSID&  clsid,              //[in] Class ID
00153   const  TCHAR*  szNameString,       //[in] NameString
00154   const  CLSID&  clsidAbout,         //[in] Class Id for About Class
00155   const  BOOL    bSupportExtensions  //[in] TRUE if we support extensions
00156 )
00157 {
00158   HRESULT hResult = S_FALSE;
00159   TCHAR*  pszSnapCLSID = NULL;         // Needed for TCHAR version of the ClassID
00160
00161   // If any part of this process fails, jump out of the loop and return
00162   // the error code
00163   do
00164   {
00165     // Allocate the CLSID string
00166     LPOLESTR wszSnapCLSID  = NULL ;
00167     hResult = StringFromCLSID( clsid, &wszSnapCLSID ) ;
00168     if( S_OK != hResult )
00169     {
00170        CoTaskMemFree( wszSnapCLSID );
00171        continue;
00172     }
00173
00174     W2T( &pszSnapCLSID, wszSnapCLSID );  // W2T is defined in Globals.h
00175     CoTaskMemFree( wszSnapCLSID );       // Through with wide version
00176
00177     // Add the Snap-in's CLSID to the registry
00178     hResult = SetSnapInKeyAndValue( pszSnapCLSID, NULL, _T("NameString"), szNameString );
00179     BREAK_ON_ERROR( hResult );
00180
00181     hResult = SetSnapInKeyAndValue( pszSnapCLSID, _T("StandAlone"), NULL, NULL );
00182     BREAK_ON_ERROR( hResult );
00183
00184     // Add registry information for ISnapinAbout if we support it
00185     LPOLESTR wszAboutCLSID = NULL;
00186     TCHAR*   pszAboutCLSID = NULL;
00187     if( IID_NULL != clsidAbout )
00188     {
00189       hResult = StringFromCLSID( clsidAbout, &wszAboutCLSID );
00190       if( S_OK != hResult )
00191       {
00192         CoTaskMemFree( wszAboutCLSID ); // Free this memory before exiting
00193         continue;
00194       }
00195
00196       W2T( &pszAboutCLSID, wszAboutCLSID );
00197       hResult = SetSnapInKeyAndValue( pszSnapCLSID, NULL, _T("About"), pszAboutCLSID );
00198       CoTaskMemFree( wszAboutCLSID );
00199       CoTaskMemFree( pszAboutCLSID );
00200       BREAK_ON_ERROR( hResult );
00201     }
00202
00203     //XPROPPAGE: Adding support for extending CVirtualFile
00204     //
00205     if( TRUE == bSupportExtensions )     // Build the NodeTypesKey
00206     {
00207       // First add the NodeTypes key under the Snapin key, along with the
00208       // the GUID to the node which we will allow to be extended.
00209       hResult = SetSnapInKeyAndValue( pszSnapCLSID, _T("NodeTypes"), NULL, NULL );
00210       BREAK_ON_ERROR( hResult );
00211       TCHAR szKey[64];
00212       _tcscpy( szKey, pszSnapCLSID );
00213       _tcscat(szKey, _T("\\NodeTypes"));
00214       hResult = SetSnapInKeyAndValue( szKey, gtszVFILE_GUID, NULL, NULL );
00215       BREAK_ON_ERROR( hResult );
00216
00217       // Add the GUID for the nodes which will allow to be extended under MMC/NodeTypes
00218       hResult = SetNodeTypesKey( gtszVFILE_GUID );
00219
00220     }
00221   }while( 0 );
00222
00223   CoTaskMemFree( pszSnapCLSID);
00224   return hResult;
00225 }
00226
00227
00228 //---------------------------------------------------------------------------
00229 // Unregister the snap-in in the registry.
00230 //
00231 HRESULT UnregisterSnapin
00232 (
00233   const CLSID& clsid         //[in] Class ID of object to unregister
00234 )
00235 {
00236   HRESULT hResult = S_OK;
00237
00238   TCHAR    szKeyBuf[1024];
00239   LPOLESTR wszCLSID = NULL;
00240   TCHAR*   pszCLSID = NULL;        // Needed for TCHAR version of the ClassID
00241
00242   // Get CLSID as a wide string
00243   hResult = StringFromCLSID( clsid, &wszCLSID );
00244   if( S_OK != hResult )
00245   {
00246     CoTaskMemFree( wszCLSID );
00247     return hResult;
00248   }
00249
00250   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00251   CoTaskMemFree( wszCLSID );           // Through with wide version
00252
00253   // Load the buffer with the Snap-In Location
00254   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00255
00256   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00257   _tcscat( szKeyBuf, pszCLSID );
00258
00259   // Delete the CLSID Key - CLSID\{...}
00260   LONG lResult = RecursiveDeleteKey( HKEY_LOCAL_MACHINE, szKeyBuf );
00261   if( ERROR_SUCCESS != lResult )
00262     hResult = HRESULT_FROM_WIN32( lResult );
00263
00264   CoTaskMemFree( pszCLSID );
00265   return hResult;
00266 }
00267
00268 //---------------------------------------------------------------------------
00269 // Delete a key and all of its descendents.
00270 //
00271 HRESULT RecursiveDeleteKey
00272 (
00273   HKEY          hKeyParent,    //[in] Parent of key to delete
00274   const TCHAR*  lpszKeyChild   //[in] Key to delete
00275 )
00276 {
00277   // Open the child.
00278   HKEY hKeyChild = NULL;
00279   LONG lResult   = ERROR_SUCCESS;
00280
00281   do                     // We go to all this trouble to prevent any
00282   {                      // possibility of exiting while leaving a key open
00283
00284     lResult = RegOpenKeyEx( hKeyParent,
00285                             lpszKeyChild,
00286                             0,
00287                             KEY_ALL_ACCESS,
00288                             &hKeyChild
00289                           );
00290     if( ERROR_SUCCESS != lResult )
00291       continue;
00292
00293     // Enumerate all of the decendents of this child.
00294     FILETIME time;
00295     _TCHAR szBuffer[256];
00296     DWORD dwSize = 256;
00297     while( S_OK == RegEnumKeyEx(hKeyChild,0,szBuffer,&dwSize,NULL,NULL,NULL,&time) )
00298     {
00299       // Delete the decendents of this child.
00300       lResult = RecursiveDeleteKey( hKeyChild, szBuffer );
00301       if( ERROR_SUCCESS != lResult )
00302       {
00303         continue;
00304       }
00305       dwSize = 256;
00306     }
00307   }while( 0 );
00308
00309   RegCloseKey( hKeyChild );            // Always try to close the child
00310                                        // then delete this child.
00311   return RegDeleteKey( hKeyParent, lpszKeyChild );
00312 }
00313
00314 //---------------------------------------------------------------------------
00315 // Create a Registry Key and set its value.
00316 //   - This helper function was borrowed and modifed from
00317 //     Kraig Brockschmidt's book Inside OLE.
00318 //
00319 HRESULT SetKeyAndValue
00320 (
00321   const TCHAR*  szKey,       //[in] Parent key
00322   const TCHAR*  szSubkey,    //[in] Child key
00323   const TCHAR*  szValue      //[in] Value to set
00324 )
00325 {
00326   HKEY hKey = NULL;
00327   HRESULT hResult = S_FALSE;
00328   TCHAR szKeyBuf[1024];
00329
00330   // Copy keyname into buffer.
00331   _tcscpy( szKeyBuf, szKey );
00332
00333   // Add subkey name to buffer.
00334   if( NULL != szSubkey )
00335   {
00336     _tcscat( szKeyBuf, _T("\\") );
00337     _tcscat( szKeyBuf, szSubkey );
00338   }
00339
00340   do                     // We go to all this trouble to prevent any
00341   {                      // possibility of exiting while leaving a key open
00342
00343     // Create and open key and subkey.
00344     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT,
00345                                    szKeyBuf,
00346                                    0,
00347                                    NULL,
00348                                    REG_OPTION_NON_VOLATILE,
00349                                    KEY_ALL_ACCESS,
00350                                    NULL,
00351                                    &hKey,
00352                                    NULL
00353                                  );
00354     if( ERROR_SUCCESS != lResult )
00355     {
00356       hResult = HRESULT_FROM_WIN32( lResult );
00357       continue;
00358     }
00359
00360     if( NULL != szValue )    // Now set the value
00361     {
00362       hResult = RegSetValueEx( hKey,
00363                                NULL,
00364                                0,
00365                                REG_SZ,
00366                                (BYTE*)szValue,
00367                                BYTE_SIZE( szValue )    // BYTE_SIZE is in Globals.h
00368                              );
00369       BREAK_ON_ERROR( hResult );
00370     }
00371   }while( 0 );
00372
00373   RegCloseKey( hKey );       // Always try to close the key
00374   return hResult;
00375 }
00376
00377
00378 //---------------------------------------------------------------------------
00379 // Open a key value and set it
00380 //
00381 HRESULT SetValue
00382 (
00383   const TCHAR*  szKey,         //[in] Parent key
00384   const TCHAR*  szValueName,   //[in] Name of value
00385   const TCHAR*  szValue        //[in] Value in string format
00386 )
00387 {
00388   HKEY    hKey = NULL;
00389   HRESULT hResult = S_FALSE;
00390   TCHAR szKeyBuf[1024];
00391
00392   // Copy keyname into buffer.
00393   _tcscpy( szKeyBuf, szKey );
00394
00395   do                     // We go to all this trouble to prevent any
00396   {                      // possibility of exiting while leaving a key open
00397
00398     // Create and open key and subkey.
00399     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT ,
00400                                    szKeyBuf,
00401                                    0,
00402                                    NULL,
00403                                    REG_OPTION_NON_VOLATILE,
00404                                    KEY_ALL_ACCESS,
00405                                    NULL,
00406                                    &hKey,
00407                                    NULL
00408                                  );
00409     if( ERROR_SUCCESS != lResult )
00410     {
00411       hResult = HRESULT_FROM_WIN32( lResult );
00412       continue;
00413     }
00414
00415     if( NULL != szValue )    // Now set the value
00416     {
00417       hResult = RegSetValueEx( hKey,
00418                                szValueName,
00419                                0,
00420                                REG_SZ,
00421                                (BYTE*)szValue,
00422                                BYTE_SIZE( szValue )
00423                              );
00424       BREAK_ON_ERROR( hResult );
00425     }
00426   }while( 0 );
00427
00428   RegCloseKey( hKey );       //Always attempt to close the key
00429   return hResult;
00430 }
00431
00432
00433 //---------------------------------------------------------------------------
00434 // Create a key and set its value.
00435 //   - This helper function was borrowed and modifed from
00436 //     Kraig Brockschmidt's book Inside OLE.
00437 //
00438 HRESULT SetSnapInKeyAndValue
00439 (
00440   const TCHAR*  szKey,       //[in] Parent key
00441   const TCHAR*  szSubkey,    //[in] Child key
00442   const TCHAR*  szName,      //[in] Value name
00443   const TCHAR*  szValue      //[in] Value in string format
00444 )
00445 {
00446   HKEY    hKey = NULL;
00447   HRESULT hResult = S_FALSE;
00448   TCHAR   szKeyBuf[1024];
00449
00450   // Load the buffer with the Snap-In Location
00451   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00452
00453   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00454   _tcscat( szKeyBuf, szKey );
00455
00456   if( NULL != szSubkey )               // Add subkey name to buffer.
00457   {
00458     _tcscat( szKeyBuf, _T("\\") );
00459     _tcscat( szKeyBuf, szSubkey );
00460   }
00461
00462   do                     // We go to all this trouble to prevent any
00463   {                      // possibility of exiting while leaving a key open
00464
00465     // Create and open key and subkey.
00466     long lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00467                                    szKeyBuf,
00468                                    0,
00469                                    NULL,
00470                                    REG_OPTION_NON_VOLATILE,
00471                                    KEY_ALL_ACCESS,
00472                                    NULL,
00473                                    &hKey,
00474                                    NULL
00475                                  );
00476     if( ERROR_SUCCESS != lResult )     // Will return S_FALSE
00477       continue;
00478
00479     // Set the Value.
00480     if( szValue != NULL )
00481     {
00482       hResult = RegSetValueEx( hKey,
00483                                szName,
00484                                0,
00485                                REG_SZ,
00486                                (BYTE*)szValue,
00487                                BYTE_SIZE(szValue)
00488                              );
00489       BREAK_ON_ERROR( hResult );
00490     }
00491     else
00492     {                        // Got this far so everything is OK.
00493       hResult = S_OK;
00494     }
00495   }while( 0 );
00496
00497   RegCloseKey( hKey );       //Always attempt to close the key
00498   return hResult;
00499 }
00500
00501
00502 //---------------------------------------------------------------------------
00503 //  XPROPPAGE:  New method which adds a key for a nodetype guid.  Need to
00504 //              do this for every nodetype which can be extended.
00505 //
00506 HRESULT SetNodeTypesKey
00507 (
00508   const TCHAR*  szNodeGuid       //[in] Parent key
00509 )
00510 {
00511   HKEY    hKey = NULL;
00512   TCHAR   szKeyBuf[1024];
00513
00514   // Load the buffer with the Snap-In Location
00515   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes") );
00516   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00517   _tcscat( szKeyBuf, szNodeGuid );
00518
00519   // Create and open key.
00520   long lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00521                                  szKeyBuf,
00522                                  0,
00523                                  NULL,
00524                                  REG_OPTION_NON_VOLATILE,
00525                                  KEY_ALL_ACCESS,
00526                                  NULL,
00527                                  &hKey,
00528                                  NULL
00529                                );
00530
00531   RegCloseKey( hKey );       //Always close the key
00532   return (ERROR_SUCCESS == lResult) ? S_OK : S_FALSE;
00533
00534 }
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocClien/UTCRUCAR.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocClien

UTCRUCAR.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      UTCRUCAR.H
00003
00004   Summary:   Include file for the aggregatable COUtilityCruiseCar COM
00005              object class.
00006
00007              UTCRUCAR showcases the construction of the COUtilityCruiseCar
00008              COM object class with the IUnknown, ICar, ICruise, and
00009              IUtility interfaces.  This is done through Containment reuse
00010              of a COCruiseCar COM object (specifically providing its ICar
00011              and ICruise interface features).  COUtilityCruiseCar adds its
00012              own native implementation of the IUtility interface.  The
00013              contained CruiseCar object is implemented in an outside
00014              LOCSERVE.EXE local server.
00015
00016              This multiple interface COM Object Class is achieved via
00017              the technique of nested classes: the implementation of the
00018              IUtility interface is nested inside of the COUtilityCruiseCar
00019              COM object class.
00020
00021              For a comprehensive tutorial code tour of this module's
00022              contents and offerings see the accompanying LOCCLIEN.TXT
00023              file.  For more specific technical details on the internal
00024              workings see the comments dispersed throughout the
00025              module's source code.
00026
00027   Classes:   COUtilityCruiseCar.
00028
00029   Functions: .
00030
00031   Origin:    11-20-95: atrent - Editor inheritance from DLLCLIEN source.
00032
00033 ----------------------------------------------------------------------------
00034   This file is part of the Microsoft COM Tutorial Code Samples.
00035
00036   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00037
00038   This source code is intended only as a supplement to Microsoft
00039   Development Tools and/or on-line documentation.  See these other
00040   materials for detailed information regarding Microsoft code samples.
00041
00042   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00043   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00044   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00045   PARTICULAR PURPOSE.
00046 ==========================================================================+*/
00047
00048 #if !defined(UTCRUCAR_H)
00049 #define UTCRUCAR_H
00050
00051 #ifdef __cplusplus
00052
00053 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00054   ObjectClass: COUtilityCruiseCar
00055
00056   Summary:     COM Object Class for COUtilityCruiseCar COM Objects.
00057                COM objects of this class augment COCruiseCar COM objects
00058                with the IUtility interface features of Offroad and Winch.
00059                COCruiseCar is reused to offer this COUtilityCruiseCar COM
00060                Object the ICar interface features of Shift, Clutch, Speed,
00061                Steer and the ICruise interface features of Engage and
00062                Adjust.  This COUtilityCruiseCar COM object class is
00063                constructed by containment reuse of the COCruiseCar COM
00064                object class.  The mulitple interfaces on this COM object
00065                class are constructed via the nested class interfaces
00066                technique.
00067
00068   Interfaces:  IUnknown
00069                  Standard interface providing COM object features.
00070                ICar
00071                  Basic car features.
00072                ICruise
00073                  Cruise control system features.
00074                IUtility
00075                  Sport-utility Car operation features.  Implemented in
00076                  this COM object.
00077
00078   Aggregation: Yes, COUtilityCruiseCar COM objects are aggregatable by
00079                passing a non-NULL pUnkOuter IUnknown pointer into
00080                the constructor.
00081 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00082 class COUtilityCruiseCar : public IUnknown
00083 {
00084   public:
00085     // Main Object Constructor & Destructor.
00086     COUtilityCruiseCar(IUnknown* pUnkOuter);
00087     ~COUtilityCruiseCar(void);
00088
00089     // A general method for initializing a newly created UtilityCruiseCar.
00090     HRESULT Init(void);
00091
00092     // IUnknown members. Main object, non-delegating.
00093     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00094     STDMETHODIMP_(ULONG) AddRef(void);
00095     STDMETHODIMP_(ULONG) Release(void);
00096
00097     // We get this ICar interface pointer via containment reuse of the
00098     // ICar interface in an instantiated COCruiseCar.
00099     ICar*                m_pICar;
00100
00101     // We get this ICruise interface pointer via containment reuse of the
00102     // ICruise interface in an instantiated COCruisecar.
00103     ICruise*             m_pICruise;
00104
00105   private:
00106     // We declare nested class interface implementations here.
00107
00108     // We implement the ICar interface in this COUtilityCruiseCar COM
00109     // object class.  This is a delegating interface for the one
00110     // in the contained COCruiseCar COM object.
00111     class CImpICar : public ICar
00112     {
00113       public:
00114         // Interface Implementation Constructor & Destructor.
00115         CImpICar(COUtilityCruiseCar* pBackObj, IUnknown* pUnkOuter);
00116         ~CImpICar(void);
00117
00118         // IUnknown methods.
00119         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00120         STDMETHODIMP_(ULONG) AddRef(void);
00121         STDMETHODIMP_(ULONG) Release(void);
00122
00123         // ICar methods.
00124         STDMETHODIMP         Shift(short nGear);
00125         STDMETHODIMP         Clutch(short nEngaged);
00126         STDMETHODIMP         Speed(short nMph);
00127         STDMETHODIMP         Steer(short nAngle);
00128
00129       private:
00130         // Data private to this COUtilityCar interface implementation of ICar.
00131         ULONG                m_cRefI;     // Interface Ref Count (debugging).
00132         COUtilityCruiseCar*  m_pBackObj;  // Parent Object back pointer.
00133         IUnknown*            m_pUnkOuter; // Outer unknown for Delegation.
00134     };
00135
00136     // We implement the ICruise interface in this COUtilityCruiseCar COM
00137     // object class.  This ICruise implementation is a delegating
00138     // interface for the one provided in the contained COCruiseCar COM
00139     // object.
00140     class CImpICruise : public ICruise
00141     {
00142       public:
00143         // Interface Implementation Constructor & Destructor.
00144         CImpICruise(COUtilityCruiseCar* pBackObj, IUnknown* pUnkOuter);
00145         ~CImpICruise(void);
00146
00147         // IUnknown methods.
00148         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00149         STDMETHODIMP_(ULONG) AddRef(void);
00150         STDMETHODIMP_(ULONG) Release(void);
00151
00152         // ICruise methods.
00153         STDMETHODIMP Engage(BOOL bOnOff);
00154         STDMETHODIMP Adjust(BOOL bUpDown);
00155
00156       private:
00157         // Data private to this interface implementation of ICruise.
00158         ULONG                m_cRefI;     // Interface Ref Count (debugging).
00159         COUtilityCruiseCar*  m_pBackObj;  // Parent Object back pointer.
00160         IUnknown*            m_pUnkOuter; // Outer unknown for Delegation.
00161     };
00162
00163     // We implement the IUtility interface in this COUtilityCruiseCar COM
00164     // object class.  This is the native interface that we are using as an
00165     // augmentation to the existing COCruiseCar COM object class.
00166     class CImpIUtility : public IUtility
00167     {
00168       public:
00169         // Interface Implementation Constructor & Destructor.
00170         CImpIUtility(COUtilityCruiseCar* pBackObj, IUnknown* pUnkOuter);
00171         ~CImpIUtility(void);
00172
00173         // IUnknown members.
00174         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00175         STDMETHODIMP_(ULONG) AddRef(void);
00176         STDMETHODIMP_(ULONG) Release(void);
00177
00178         // IUtility members.
00179         STDMETHODIMP Offroad(short nGear);
00180         STDMETHODIMP Winch(short nRpm);
00181
00182       private:
00183         // Data private to this interface implementation of IUtility.
00184         ULONG                m_cRefI;     // Interface Ref Count (debugging).
00185         COUtilityCruiseCar*  m_pBackObj;  // Parent Object back pointer.
00186         IUnknown*            m_pUnkOuter; // Outer unknown for Delegation.
00187     };
00188
00189     // Make the otherwise private and nested IUtility, ICruise, and ICar
00190     // interface implementations friend instantiations of this class.
00191     friend CImpICar;
00192     friend CImpICruise;
00193     friend CImpIUtility;
00194
00195     // Private data of COUtilityCruiseCar COM objects.
00196
00197     // Nested ICar implementation instantiation.
00198     CImpICar        m_ImpICar;
00199
00200     // Nested ICruise implementation instantiation.
00201     CImpICruise     m_ImpICruise;
00202
00203     // Nested IUtility implementation instantiation.  This IUtility
00204     // interface is implemented inside this COUtilityCruiseCar object
00205     // as a native interface.
00206     CImpIUtility    m_ImpIUtility;
00207
00208     // Main Object reference count.
00209     ULONG           m_cRefs;
00210
00211     // Outer unknown (aggregation & delegation). Used when this
00212     // COUtilityCruiseCar object is being aggregated.
00213     IUnknown*       m_pUnkOuter;
00214 };
00215
00216 typedef COUtilityCruiseCar* PCOUtilityCruiseCar;
00217
00218 // Here is a prototpye for the UtilityCruiseCar Creation function.
00219 HRESULT CreateUtilityCruiseCar(
00220           IUnknown* pUnkOuter,
00221           REFIID riid,
00222           PPVOID ppv);
00223
00224 #endif // __cplusplus
00225
00226
00227 #endif // UTCRUCAR_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAuthenticateContext Member List

This is the complete list of members for CAuthenticateContext, including all inherited members.
Authenticate(VARIANT ResponseBlob, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandContext, IWMSAuthenticationCallback *pCallback, VARIANT Context) | CAuthenticateContext |
CAuthenticateContext() | CAuthenticateContext |
GetAuthenticationPlugin(IWMSAuthenticationPlugin **ppAuthenPlugin) | CAuthenticateContext |
GetImpersonationAccountName(BSTR *bstrAccountName) | CAuthenticateContext |
GetImpersonationToken(long *Token) | CAuthenticateContext |
GetLogicalUserID(BSTR *bstrUserID) | CAuthenticateContext |
Initialize(IWMSAuthenticationPlugin *pAuthenticator) | CAuthenticateContext |
m_bstrUsername | CAuthenticateContext | [private]
m_CritSec | CAuthenticateContext | [private]
m_hToken | CAuthenticateContext | [private]
m_pWMSAuthenticationPlugin | CAuthenticateContext | [private]
m_State | CAuthenticateContext | [private]
~CAuthenticateContext() | CAuthenticateContext |
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/pluggable/resource.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • pluggable

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by PlgCSFTermTst.rc
00004 //
00005 #define IDR_PLG_TEST                    120
00006 #define IDS_TERMINAL_NAME               121
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        101
00013 #define _APS_NEXT_COMMAND_VALUE         40001
00014 #define _APS_NEXT_CONTROL_VALUE         1000
00015 #define _APS_NEXT_SYMED_VALUE           101
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/NetMon/experts/blrplate/resrc1.h Source File

  • NetDS
  • NetMon
  • experts
  • blrplate

resrc1.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by BLRPLATE.rc
00004 //
00005 #define IDD_BLRPLATE_CONFIG_DIALOG      110
00006 #define IDM_HELP                        111
00007 #define IDS_EXPERTNAME                  200
00008 #define IDS_COMMENT                     201
00009 #define IDS_AUTHOR                      202
00010 #define IDS_EVENTNAME                   203
00011 #define IDS_DESCRIPTION                 204
00012 #define IDS_MACHINE                     205
00013 #define IDS_COLZERO                     206
00014 #define IDS_COLONE                      207
00015 #define IDS_JUSTIFICATION_FORMAT        208
00016 #define IDS_INITIALIZING                209
00017 #define IDS_CANTALLOCMEM                210
00018 #define IDS_CANTCREATEFILTER            211
00019 #define IDS_CANTADDTOFILTER             212
00020
00021 // Next default values for new objects
00022 //
00023 #ifdef APSTUDIO_INVOKED
00024 #ifndef APSTUDIO_READONLY_SYMBOLS
00025 #define _APS_NEXT_RESOURCE_VALUE        101
00026 #define _APS_NEXT_COMMAND_VALUE         40001
00027 #define _APS_NEXT_CONTROL_VALUE         1000
00028 #define _APS_NEXT_SYMED_VALUE           101
00029 #endif
00030 #endif
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Object/OHello/Client.Cxx Source File

  • Com
  • Fundamentals
  • Object
  • OHello

Client.Cxx

Go to the documentation of this file.
00001 /*+----------------------------------------------------------------------------
00002
00003 Microsoft Windows Sample Program
00004 Copyright 1994 - 2000 Microsoft Corporation.  All rights reserved.
00005
00006 FILE:       client.cxx
00007
00008 USAGE:      client
00009
00010 PURPOSE:    OLE client application uses a custom interface to call the
00011             server and print "Hello".
00012
00013 FUNCTIONS:  main() - Main entry point for the client application.
00014
00015 COMMENTS:   The server program must be installed before running the client.
00016             Run server.exe /REGSERVER to install the server program.
00017
00018 -----------------------------------------------------------------------------*/
00019 #include <windows.h>
00020 #include <stdio.h>
00021 #include "ohello.h"     // generated by MIDL from ohello.idl
00022
00023 // the class ID of the server exe
00024 const CLSID CLSID_OHello =
00025     {0xf9246031,0x9f33,0x11cd,{0xb2,0x3f,0x00,0xaa,0x00,0x33,0x9c,0xce}};
00026
00027 void PrintErrorMessage(HRESULT hr);
00028
00029 //+---------------------------------------------------------------------------
00030 //
00031 //  Function:   main
00032 //
00033 //  Synopsis:   Main entry point for the client application.  First we
00034 //              call CoCreateInstance to create an instance of the server
00035 //              object.  Next, we use the IHello custom interface to
00036 //              call the server object and print "Hello".  After waiting
00037 //              5 seconds, we call the server object to print "Goodbye".
00038 //              Finally, we release the IHello interface pointer and
00039 //              terminate.
00040 //
00041 //----------------------------------------------------------------------------
00042 void __cdecl main(int argc, char *argv[])
00043 {
00044     HRESULT hr;
00045     IHello *pHello = 0;
00046
00047     hr = CoInitialize(NULL);
00048
00049     if(SUCCEEDED(hr))
00050     {
00051         hr = CoCreateInstance(CLSID_OHello, 0, CLSCTX_LOCAL_SERVER, IID_IHello, (void **) &pHello);
00052         if(SUCCEEDED(hr))
00053         {
00054             hr = pHello->HelloProc((unsigned char *) "Hello");
00055
00056             if(SUCCEEDED(hr))
00057             {
00058                 printf("Successfully printed Hello.\n");
00059             }
00060             else
00061             {
00062                 printf("IHello::HelloProc failed.\n");
00063                 PrintErrorMessage(hr);
00064             }
00065
00066             printf(" <pausing for 5 sec>\n");
00067             Sleep( 5000 ); // 5000 msec = 5 sec
00068
00069             hr = pHello->HelloProc((unsigned char *) "Goodbye");
00070
00071             if(SUCCEEDED(hr))
00072             {
00073                 printf("Successfully printed Goodbye.\n");
00074             }
00075             else
00076             {
00077                 printf("IHello::HelloProc failed.\n");
00078                 PrintErrorMessage(hr);
00079             }
00080
00081             pHello->Release();
00082         }
00083         else
00084         {
00085             printf("CoCreateInstance failed.\n");
00086             PrintErrorMessage(hr);
00087
00088             if(hr == REGDB_E_CLASSNOTREG)
00089                 printf("Run server.exe /REGSERVER to install the server program.\n");
00090         }
00091
00092         CoUninitialize();
00093     }
00094     else
00095     {
00096         printf("CoInitialize failed.\n");
00097         PrintErrorMessage(hr);
00098     }
00099 }
00100
00101
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/FiltReg.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

FiltReg.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (c) Microsoft Corporation. All rights reserved.
00005 //
00006 // File:        RegSrv.hxx
00007 //
00008 // Contents:    Macros for Self-registration of Filters
00009 //
00010 // Functions:   Macros to create DllRegisterServer, DllUnregisterServer
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #pragma once
00015
00016 #include <olectl.h>
00017
00018 //
00019 // Structure to define classes (.doc, .xls, etc.)
00020 //
00021
00022 struct SClassEntry
00023 {
00024     WCHAR const * pwszExt;                  // (ex: .doc)  May be null
00025     WCHAR const * pwszShortName;            // (ex: Word.Document.8)
00026     WCHAR const * pwszDescription;          // (ex: Microsoft Word Document)
00027     WCHAR const * pwszClassId;              // (ex: {00020906-0000-0000-C000-000000000046})
00028     WCHAR const * pwszClassIdDescription;   // (ex: Microsoft Word Document)
00029 };
00030
00031 //
00032 // Structure to define persistent handler entry.
00033 //
00034
00035 struct SHandlerEntry
00036 {
00037     WCHAR const * pwszClassId;
00038     WCHAR const * pwszClassIdDescription;
00039     WCHAR const * pwszClassIdFilter;
00040 };
00041
00042 //
00043 // Structure to define filter class
00044 //
00045
00046 struct SFilterEntry
00047 {
00048     WCHAR const * pwszClassId;
00049     WCHAR const * pwszClassIdDescription;
00050     WCHAR const * pwszDLL;
00051     WCHAR const * pwszThreadingModel;
00052 };
00053
00054 //
00055 // Sample use of the three structures
00056 //
00057 //
00058 // SClassEntry const aClasses[] = { { L".doc", L"Word.Document.8",
00059 //                                    L"Microsoft Word Document",
00060 //                                    L"{00020906-0000-0000-C000-000000000046}",
00061 //                                    L"Microsoft Word Document" },
00062 //
00063 //                                  { 0, L"Word.Document.6",
00064 //                                    L"Microsoft Word 6.0 - 7.0 Document",
00065 //                                    L"{00020900-0000-0000-C000-000000000046}",
00066 //                                    L"Microsoft Word 6.0 - 7.0 Document" }
00067 //                                };
00068 //
00069 // SHandlerEntry const OfficeHandler = { L"{98de59a0-d175-11cd-a7bd-00006b827d94}",
00070 //                                       L"Microsoft Office Persistent Handler",
00071 //                                       L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}" };
00072 //
00073 // SFilterEntry const OfficeFilter = { L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}",
00074 //                                     L"Microsoft Office Filter",
00075 //                                     L"OffFilt.dll",
00076 //                                     0 };
00077 //
00078
00079 //
00080 // Function prototypes
00081 //
00082
00083 inline long RegisterACLSID( SClassEntry const & Class,
00084                             WCHAR const * pwszPHandler,
00085                             WCHAR const * pwszClassId = 0,
00086                             BOOL fAppendOnly = FALSE,
00087                             BOOL fAppendDesc = TRUE );
00088
00089 inline long RegisterAClass( SClassEntry const & Class,
00090                             WCHAR const * pwszPHandler,
00091                             WCHAR const * pwszShortName = 0,
00092                             BOOL fAppendOnly = FALSE );
00093
00094 inline long RegisterAClassAndExt( SClassEntry const & Class,
00095                                   WCHAR const * pwszPHandler,
00096                                   BOOL fAppendOnly = FALSE,
00097                                   BOOL fBlastExistingPersistentHandler = TRUE );
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 //  Function:   BuildKeyValues, private
00102 //
00103 //  Effects:    Given array of key, value, key, value, ... adds the entries
00104 //              under CLSID as:
00105 //
00106 //                  Key1 : <NO NAME> Value1
00107 //                    Key2 : <NO NAME> Value2
00108 //                      :
00109 //                      :
00110 //
00111 //  Arguments:  [awszKeyValues] -- Keys and values
00112 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00113 //
00114 //  Returns:    ERROR_SUCCESS on success
00115 //
00116 //  Notes:      The *value* entries can be null, signifying no value at a
00117 //              given level.
00118 //
00119 //----------------------------------------------------------------------------
00120
00121 inline long BuildKeyValues( WCHAR const * const * awszKeyValues, unsigned cKeyValues )
00122 {
00123     WCHAR wcTemp[MAX_PATH];
00124     wcscpy( wcTemp, L"CLSID" );
00125
00126     long dwError;
00127     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00128     unsigned i = 0;
00129
00130     do
00131     {
00132         if ( INVALID_HANDLE_VALUE != hKey )
00133         {
00134             RegCloseKey( hKey );
00135             hKey = (HKEY)INVALID_HANDLE_VALUE;
00136         }
00137
00138         wcscat( wcTemp, L"\\" );
00139         wcscat( wcTemp, awszKeyValues[i] );
00140
00141         DWORD  dwDisposition;
00142
00143         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00144                                    wcTemp,               // Sub key
00145                                    0,                    // Reserved
00146                                    0,                    // Class
00147                                    0,                    // Flags
00148                                    KEY_ALL_ACCESS,       // Access
00149                                    0,                    // Security
00150                                    &hKey,                // Handle
00151                                    &dwDisposition );     // Disposition
00152
00153         if ( ERROR_SUCCESS != dwError )
00154             break;
00155
00156         i++;
00157
00158         if ( 0 != awszKeyValues[i] )
00159             dwError = RegSetValueExW( hKey,                     // Key
00160                                       0,                        // Name
00161                                       0,                        // Reserved
00162                                       REG_SZ,                   // Type
00163                                       (BYTE *)awszKeyValues[i], // Value
00164                                       (DWORD) ( (1 + wcslen(awszKeyValues[i]) ) * sizeof(WCHAR) ) );
00165
00166         if ( ERROR_SUCCESS != dwError )
00167             break;
00168
00169         i++;
00170     }
00171     while ( i < cKeyValues );
00172
00173     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00174         RegCloseKey( hKey );
00175
00176     return dwError;
00177 }
00178
00179 //+---------------------------------------------------------------------------
00180 //
00181 //  Function:   AddThreadingModel
00182 //
00183 //  Synopsis:   Adds the threading model value to the CLSID\\GUID\\InProcServer32
00184 //              key
00185 //
00186 //  Arguments:  [wszClsId] - ClassId of the inproc server.
00187 //              [wszThreadingModel] -- 0 (for single threaded) or one of
00188 //                                     Apartment, Free, or Both
00189 //
00190 //  History:    3-07-97   srikants   Created
00191 //
00192 //----------------------------------------------------------------------------
00193
00194 inline long AddThreadingModel( WCHAR const * wszClsId,
00195                                WCHAR const * wszThreadingModel )
00196 {
00197     WCHAR wcTemp[MAX_PATH];
00198     wcscpy( wcTemp, L"CLSID" );
00199     wcscat( wcTemp, L"\\" );
00200     wcscat( wcTemp, wszClsId );
00201     wcscat( wcTemp, L"\\" );
00202     wcscat( wcTemp, L"InprocServer32" );
00203
00204     long dwError;
00205     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00206     unsigned i = 0;
00207
00208     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00209                              wcTemp,               // Sub key
00210                              0,                    // Reserved
00211                              KEY_ALL_ACCESS,       // Access
00212                              &hKey );              // Handle
00213
00214     if ( ERROR_SUCCESS != dwError )
00215         return dwError;
00216
00217     if ( 0 != wszThreadingModel )
00218         dwError = RegSetValueExW( hKey,                   // Key
00219                                   L"ThreadingModel",      // Name
00220                                   0,                      // Reserved
00221                                   REG_SZ,                 // Type
00222                                   (BYTE *) wszThreadingModel,  // Value
00223                                   (DWORD) ( (wcslen(wszThreadingModel) + 1) * sizeof WCHAR ) );
00224     else
00225         RegDeleteValueW( hKey,                   // Key
00226                          L"ThreadingModel" );    // Name
00227
00228     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00229         RegCloseKey( hKey );
00230
00231     return dwError;
00232 }
00233
00234 //+---------------------------------------------------------------------------
00235 //
00236 //  Function:   DestroyKeyValues, private
00237 //
00238 //  Effects:    Given array of key, value, key, value from AddKeyValues,
00239 //              removes the keys.
00240 //
00241 //  Arguments:  [awszKeyValues] -- Keys and values
00242 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00243 //
00244 //  Returns:    ERROR_SUCCESS on success
00245 //
00246 //----------------------------------------------------------------------------
00247
00248 inline long DestroyKeyValues( WCHAR const * const * awszKeyValues, int cKeyValues )
00249 {
00250     WCHAR wcTemp[MAX_PATH];
00251
00252     //
00253     // Build path to deepest component
00254     //
00255
00256     wcscpy( wcTemp, L"CLSID" );
00257     int i = 0;
00258
00259     do
00260     {
00261         wcscat( wcTemp, L"\\" );
00262         wcscat( wcTemp, awszKeyValues[i] );
00263
00264         i += 2;
00265     }
00266     while ( i < cKeyValues );
00267
00268     //
00269     // Remove components in reverse order
00270     //
00271
00272     long dwError = ERROR_SUCCESS;
00273     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00274
00275     unsigned cc = (unsigned) wcslen( wcTemp );
00276
00277     for ( i -= 2; i >= 0; i -= 2 )
00278     {
00279         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00280                                  wcTemp,               // Sub key
00281                                  0,                    // Reserved
00282                                  KEY_ALL_ACCESS,       // Access
00283                                  &hKey );              // Handle
00284
00285         if ( ERROR_SUCCESS != dwError )
00286             break;
00287
00288         #if 0  // Values deleted by RegDeleteKeyW
00289         //
00290         // Delete value, if there is one.
00291         //
00292
00293         if ( 0 != awszKeyValues[i+1] )
00294             dwError = RegDeleteValueW( hKey, 0 );
00295
00296         if ( ERROR_SUCCESS != dwError )
00297             break;
00298         #endif // 0
00299
00300         //
00301         // Delete subkey, if there is one.
00302         //
00303
00304         if ( i+2 < cKeyValues )
00305             dwError = RegDeleteKeyW( hKey, awszKeyValues[i+2] );
00306
00307         if ( ERROR_SUCCESS != dwError )
00308             break;
00309
00310         //
00311         // Close key and truncate string to next component.
00312         //
00313
00314         if ( INVALID_HANDLE_VALUE != hKey )
00315         {
00316             RegCloseKey( hKey );
00317             hKey = (HKEY)INVALID_HANDLE_VALUE;
00318         }
00319
00320         cc -= (unsigned) wcslen( awszKeyValues[i] );
00321         cc--;
00322
00323         wcTemp[cc] = 0;
00324     }
00325
00326     //
00327     // Remove the final top key
00328     //
00329
00330     if ( ERROR_SUCCESS == dwError )
00331     {
00332         do
00333         {
00334             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00335                                      wcTemp,               // Sub key -- "CLSID"
00336                                      0,                    // Reserved
00337                                      KEY_ALL_ACCESS,       // Access
00338                                      &hKey );              // Handle
00339
00340             if ( ERROR_SUCCESS != dwError )
00341                 break;
00342
00343             //
00344             // Delete subkey
00345             //
00346
00347             dwError = RegDeleteKeyW( hKey, awszKeyValues[0] );
00348
00349         } while ( FALSE );
00350     }
00351
00352     return dwError;
00353 }
00354
00355 //+---------------------------------------------------------------------------
00356 //
00357 //  Function:   RegisterAClassAndExt, private
00358 //
00359 //  Synopsis:   Registers a class, extensions (optional) and a persistent handler.
00360 //
00361 //  Arguments:  [Class]        -- Class description
00362 //              [pwszPHandler] -- Persistent handler for class
00363 //
00364 //  Returns:    ERROR_SUCCESS on success
00365 //
00366 //  Notes:      Class is only registered if similar class does not already
00367 //              exist.  Persistent handler is always registered for class.
00368 //
00369 //----------------------------------------------------------------------------
00370
00371 inline long RegisterAClassAndExt( SClassEntry const & Class,
00372                                   WCHAR const * pwszPHandler,
00373                                   BOOL fAppendOnly,
00374                                   BOOL fBlastExistingPersistentHandler )
00375 {
00376     WCHAR wcTemp[MAX_PATH];
00377
00378     long dwError = NO_ERROR;
00379     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00380
00381     do
00382     {
00383         //
00384         // First, the optional extension entry
00385         //
00386
00387         DWORD dwDisposition;
00388         DWORD dwType;
00389         DWORD dwSize;
00390
00391         if ( 0 == Class.pwszExt )
00392         {
00393             //
00394             // Build up named entry
00395             //
00396
00397             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00398                 return ERROR_INSUFFICIENT_BUFFER;
00399
00400             wcscpy( wcTemp, Class.pwszShortName );
00401         }
00402         else
00403         {
00404             if ( wcslen( Class.pwszExt ) >= MAX_PATH )
00405                 return ERROR_INSUFFICIENT_BUFFER;
00406
00407             wcscpy( wcTemp, Class.pwszExt );
00408
00409             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00410                                        wcTemp,               // Sub key
00411                                        0,                    // Reserved
00412                                        0,                    // Class
00413                                        0,                    // Flags
00414                                        KEY_ALL_ACCESS,       // Access
00415                                        0,                    // Security
00416                                        &hKey,                // Handle
00417                                        &dwDisposition );     // Disposition
00418             if ( ERROR_SUCCESS != dwError )
00419                 break;
00420
00421             //
00422             // Write or read class association
00423             //
00424
00425             BOOL fSetValue = TRUE;
00426
00427             if ( REG_OPENED_EXISTING_KEY == dwDisposition )
00428             {
00429                 dwSize = sizeof(wcTemp);
00430
00431                 dwError = RegQueryValueExW( hKey,            // Key handle
00432                                             0,               // Name
00433                                             0,               // Reserved
00434                                             &dwType,         // Datatype
00435                                             (BYTE *)wcTemp,  // Data returned here
00436                                             &dwSize );       // Size of data
00437
00438                 if ( ERROR_SUCCESS == dwError )
00439                 {
00440                     fSetValue = FALSE;
00441
00442                     if ( REG_SZ != dwType )
00443                         dwError = E_FAIL;
00444                 }
00445                 else if ( ERROR_FILE_NOT_FOUND == dwError )
00446                 {
00447                     //
00448                     // This is ok, but we need to remember that the
00449                     // combination of wcTemp[0] == 0 && fAppendOnly means
00450                     // don't try to register the class.
00451                     //
00452
00453                     wcTemp[0] = 0;
00454                     dwError = ERROR_SUCCESS;
00455                 }
00456             }
00457
00458             if ( fSetValue && !fAppendOnly )
00459             {
00460                 dwError = RegSetValueExW( hKey,                        // Key
00461                                           0,                           // Name
00462                                           0,                           // Reserved
00463                                           REG_SZ,                      // Type
00464                                           (BYTE *)Class.pwszShortName, // Value
00465                                           (DWORD) ( (1 + wcslen(Class.pwszShortName) ) * sizeof(WCHAR) ) );
00466
00467                 wcTemp[0] = 0;
00468             }
00469
00470             if ( ERROR_SUCCESS != dwError )
00471                 break;
00472
00473             //
00474             // Write the persistent handler key
00475             //
00476
00477             HKEY hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00478
00479             dwError = RegCreateKeyExW( hKey,                 // Root
00480                                        L"PersistentHandler", // Sub key
00481                                        0,                    // Reserved
00482                                        0,                    // Class
00483                                        0,                    // Flags
00484                                        KEY_ALL_ACCESS,       // Access
00485                                        0,                    // Security
00486                                        &hKey2,               // Handle
00487                                        &dwDisposition );     // Disposition
00488
00489             if ( ERROR_SUCCESS != dwError )
00490                 break;
00491
00492             if ( fBlastExistingPersistentHandler ||
00493                  ( REG_OPENED_EXISTING_KEY != dwDisposition ) )
00494                 dwError = RegSetValueExW( hKey2,                 // Key
00495                                           0,                     // Name
00496                                           0,                     // Reserved
00497                                           REG_SZ,                // Type
00498                                           (BYTE *)pwszPHandler,  // Value
00499                                           (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00500
00501             if ( (HKEY)INVALID_HANDLE_VALUE != hKey2 )
00502             {
00503                 RegCloseKey( hKey2 );
00504                 hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00505             }
00506         }
00507
00508         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00509         {
00510             RegCloseKey( hKey );
00511             hKey = (HKEY)INVALID_HANDLE_VALUE;
00512         }
00513
00514         if ( ERROR_SUCCESS != dwError )
00515             break;
00516
00517         //
00518         // Here, wcTemp may contain the key name for the named entry (ex: Word.Document.8)
00519         //
00520
00521         if ( wcTemp[0] != 0 || !fAppendOnly )
00522             dwError = RegisterAClass( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00523
00524     } while( FALSE );
00525
00526     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00527     {
00528         RegCloseKey( hKey );
00529         hKey = (HKEY)INVALID_HANDLE_VALUE;
00530     }
00531
00532     return dwError;
00533 }
00534
00535 //+---------------------------------------------------------------------------
00536 //
00537 //  Function:   RegisterAClass, private
00538 //
00539 //  Synopsis:   Registers a class and a persistent handler.
00540 //
00541 //  Arguments:  [Class]        -- Class description
00542 //              [pwszPHandler] -- Persistent handler for class
00543 //              [pwszClass]    -- If non 0, used instead of class from [Class]
00544 //
00545 //  Returns:    ERROR_SUCCESS on success
00546 //
00547 //  Notes:      Class is only registered if similar class does not already
00548 //              exist.  Persistent handler is always registered for class.
00549 //
00550 //----------------------------------------------------------------------------
00551
00552 inline long RegisterAClass( SClassEntry const & Class,
00553                             WCHAR const * pwszPHandler,
00554                             WCHAR const * pwszShortName,
00555                             BOOL fAppendOnly )
00556 {
00557     WCHAR wcTemp[MAX_PATH];
00558
00559     long dwError;
00560     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00561
00562     if ( 0 == pwszShortName )
00563     {
00564         if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00565             return ERROR_INSUFFICIENT_BUFFER;
00566
00567         wcscpy( wcTemp, Class.pwszShortName );
00568     }
00569     else
00570     {
00571         if ( wcslen( pwszShortName ) >= MAX_PATH )
00572             return ERROR_INSUFFICIENT_BUFFER;
00573
00574         wcscpy( wcTemp, pwszShortName );
00575     }
00576
00577     do
00578     {
00579         DWORD dwDisposition;
00580         DWORD dwType;
00581         DWORD dwSize;
00582
00583         //
00584         // Here, wcTemp contains the key name for the named entry (ex: Word.Document.8)
00585         //
00586
00587         if ( fAppendOnly )
00588         {
00589             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00590                                      wcTemp,               // Sub key
00591                                      0,                    // Reserved
00592                                      KEY_ALL_ACCESS,       // Access
00593                                      &hKey );              // Handle
00594
00595             if ( ERROR_SUCCESS != dwError)
00596             {
00597                 //
00598                 // Not opening the key at all is legit.
00599                 //
00600
00601                 if ( ERROR_FILE_NOT_FOUND == dwError )
00602                     dwError = ERROR_SUCCESS;
00603
00604                 break;
00605             }
00606
00607             dwDisposition = REG_OPENED_EXISTING_KEY;
00608         }
00609         else
00610         {
00611             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00612                                        wcTemp,               // Sub key
00613                                        0,                    // Reserved
00614                                        0,                    // Class
00615                                        0,                    // Flags
00616                                        KEY_ALL_ACCESS,       // Access
00617                                        0,                    // Security
00618                                        &hKey,                // Handle
00619                                        &dwDisposition );     // Disposition
00620
00621             if ( ERROR_SUCCESS != dwError )
00622                 break;
00623         }
00624
00625         //
00626         // If needed, write the description, but only for non-overrides.
00627         //
00628
00629         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszShortName )
00630         {
00631             dwError = RegSetValueExW( hKey,                          // Key
00632                                       0,                             // Name
00633                                       0,                             // Reserved
00634                                       REG_SZ,                        // Type
00635                                       (BYTE *)Class.pwszDescription, // Value
00636                                       (DWORD) ( (1 + wcslen(Class.pwszDescription) ) * sizeof(WCHAR) ) );
00637
00638             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00639                 return ERROR_INSUFFICIENT_BUFFER;
00640
00641             wcscpy( wcTemp, Class.pwszShortName );
00642
00643             if ( ERROR_SUCCESS != dwError )
00644                 break;
00645         }
00646
00647         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00648         {
00649             RegCloseKey( hKey );
00650             hKey = (HKEY)INVALID_HANDLE_VALUE;
00651         }
00652
00653         //
00654         // Write or read ClassId
00655         //
00656
00657         wcscat( wcTemp, L"\\CLSID" );
00658
00659         if ( fAppendOnly )
00660         {
00661             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00662                                      wcTemp,               // Sub key
00663                                      0,                    // Reserved
00664                                      KEY_ALL_ACCESS,       // Access
00665                                      &hKey );              // Handle
00666
00667             if ( ERROR_SUCCESS != dwError)
00668             {
00669                 //
00670                 // Not opening the key at all is legit.
00671                 //
00672
00673                 if ( ERROR_FILE_NOT_FOUND == dwError )
00674                     dwError = ERROR_SUCCESS;
00675
00676                 break;
00677             }
00678
00679             dwDisposition = REG_OPENED_EXISTING_KEY;
00680         }
00681         else
00682         {
00683             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00684                                        wcTemp,               // Sub key
00685                                        0,                    // Reserved
00686                                        0,                    // Class
00687                                        0,                    // Flags
00688                                        KEY_ALL_ACCESS,       // Access
00689                                        0,                    // Security
00690                                        &hKey,                // Handle
00691                                        &dwDisposition );     // Disposition
00692
00693             if ( ERROR_SUCCESS != dwError )
00694                 break;
00695         }
00696
00697         dwSize = sizeof(wcTemp);
00698
00699         dwError = RegQueryValueExW( hKey,                // Key handle
00700                                     0,                   // Name
00701                                     0,                   // Reserved
00702                                     &dwType,             // Datatype
00703                                     (BYTE *)(wcTemp),    // Data returned here
00704                                     &dwSize );           // Size of data
00705
00706         if ( ERROR_SUCCESS != dwError )
00707         {
00708             if ( ERROR_FILE_NOT_FOUND == dwError )
00709             {
00710                 //
00711                 // Don't set a class id in append mode.
00712                 //
00713
00714                 if ( fAppendOnly )
00715                 {
00716                     dwError = ERROR_SUCCESS;
00717                     break;
00718                 }
00719
00720                 dwError = RegSetValueExW( hKey,                          // Key
00721                                           0,                             // Name
00722                                           0,                             // Reserved
00723                                           REG_SZ,                        // Type
00724                                           (BYTE *)Class.pwszClassId,     // Value
00725                                           (DWORD) ( (1 + wcslen(Class.pwszClassId) ) * sizeof(WCHAR) ) );
00726
00727                 wcTemp[0] = 0; // Default to class from Class structure
00728
00729                 if ( ERROR_SUCCESS != dwError )
00730                     break;
00731             }
00732             else
00733                 break;
00734         }
00735         else
00736         {
00737             if ( REG_SZ != dwType )
00738                 dwError = E_FAIL;
00739         }
00740
00741         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00742         {
00743             RegCloseKey( hKey );
00744             hKey = (HKEY)INVALID_HANDLE_VALUE;
00745         }
00746
00747         if ( ERROR_SUCCESS != dwError )
00748             break;
00749
00750         //
00751         // Here, wcTemp contains the {class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00752         //
00753
00754         dwError = RegisterACLSID( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00755
00756     } while( FALSE );
00757
00758     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00759     {
00760         RegCloseKey( hKey );
00761         hKey = (HKEY)INVALID_HANDLE_VALUE;
00762     }
00763
00764     return dwError;
00765 }
00766
00767 //+---------------------------------------------------------------------------
00768 //
00769 //  Function:   RegisterACLSID, private
00770 //
00771 //  Synopsis:   Registers a CLSID / persistent handler.
00772 //
00773 //  Arguments:  [Class]        -- Class description
00774 //              [pwszPHandler] -- Persistent handler for class
00775 //              [pwszClassId]  -- If non 0, used instead of class id from [Class]
00776 //              [fAppendOnly]  -- TRUE --> CLSID should not be created
00777 //              [fAppendDesc]  -- TRUE --> Class description should be added.
00778 //                                         Only applies if [fAppendOnly] is FALSE
00779 //
00780 //  Returns:    ERROR_SUCCESS on success
00781 //
00782 //  Notes:      Class id is only registered if similar class does not already
00783 //              exist.  Persistent handler is always registered for class.
00784 //
00785 //----------------------------------------------------------------------------
00786
00787 inline long RegisterACLSID( SClassEntry const & Class,
00788                             WCHAR const * pwszPHandler,
00789                             WCHAR const * pwszClassId,
00790                             BOOL fAppendOnly,
00791                             BOOL fAppendDesc )
00792 {
00793     WCHAR wcTemp[MAX_PATH];
00794
00795     long dwError;
00796     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00797
00798     wcscpy( wcTemp, L"CLSID\\" );
00799
00800     if ( 0 == pwszClassId )
00801         wcscat( wcTemp, Class.pwszClassId );
00802     else
00803         wcscat( wcTemp, pwszClassId );
00804
00805     do
00806     {
00807         DWORD dwDisposition;
00808
00809         //
00810         // Here, wcTemp contains the CLSID\{class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00811         //
00812
00813         if ( fAppendOnly )
00814         {
00815             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00816                                      wcTemp,               // Sub key
00817                                      0,                    // Reserved
00818                                      KEY_ALL_ACCESS,       // Access
00819                                      &hKey );              // Handle
00820
00821             if ( ERROR_SUCCESS != dwError)
00822             {
00823                 //
00824                 // Not opening the key at all is legit.
00825                 //
00826
00827                 if ( ERROR_FILE_NOT_FOUND == dwError )
00828                     dwError = ERROR_SUCCESS;
00829
00830                 break;
00831             }
00832
00833             dwDisposition = REG_OPENED_EXISTING_KEY;
00834         }
00835         else
00836         {
00837             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00838                                        wcTemp,               // Sub key
00839                                        0,                    // Reserved
00840                                        0,                    // Class
00841                                        0,                    // Flags
00842                                        KEY_ALL_ACCESS,       // Access
00843                                        0,                    // Security
00844                                        &hKey,                // Handle
00845                                        &dwDisposition );     // Disposition
00846         }
00847
00848         if ( ERROR_SUCCESS != dwError )
00849             break;
00850
00851         //
00852         // If needed, write the description, but not for override class.
00853         //
00854
00855         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszClassId && fAppendDesc )
00856         {
00857             dwError = RegSetValueExW( hKey,                                 // Key
00858                                       0,                                    // Name
00859                                       0,                                    // Reserved
00860                                       REG_SZ,                               // Type
00861                                       (BYTE *)Class.pwszClassIdDescription, // Value
00862                                       (DWORD) ( (1 + wcslen(Class.pwszClassIdDescription) ) * sizeof(WCHAR) ) );
00863
00864             if ( ERROR_SUCCESS != dwError )
00865                 break;
00866         }
00867
00868         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00869         {
00870             RegCloseKey( hKey );
00871             hKey = (HKEY)INVALID_HANDLE_VALUE;
00872         }
00873
00874         //
00875         // Always write persistent handler.
00876         //
00877
00878         wcscat( wcTemp, L"\\PersistentHandler" );
00879
00880         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00881                                    wcTemp,               // Sub key
00882                                    0,                    // Reserved
00883                                    0,                    // Class
00884                                    0,                    // Flags
00885                                    KEY_ALL_ACCESS,       // Access
00886                                    0,                    // Security
00887                                    &hKey,                // Handle
00888                                    &dwDisposition );     // Disposition
00889
00890         if ( ERROR_SUCCESS != dwError )
00891             break;
00892
00893         dwError = RegSetValueExW( hKey,                  // Key
00894                                   0,                     // Name
00895                                   0,                     // Reserved
00896                                   REG_SZ,                // Type
00897                                   (BYTE *)pwszPHandler,  // Value
00898                                   (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00899
00900     } while( FALSE );
00901
00902     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00903     {
00904         RegCloseKey( hKey );
00905         hKey = (HKEY)INVALID_HANDLE_VALUE;
00906     }
00907
00908     return dwError;
00909 }
00910
00911 //+---------------------------------------------------------------------------
00912 //
00913 //  Function:   RemoveAClassName, private
00914 //
00915 //  Synopsis:   Removes all references to class name (ex: Word.Document.8)
00916 //
00917 //  Arguments:  [pwszClass] -- Class Name
00918 //
00919 //  Returns:    ERROR_SUCCESS on success
00920 //
00921 //----------------------------------------------------------------------------
00922
00923 inline long RemoveAClassName( WCHAR * pwszClass )
00924 {
00925     //
00926     // First, delete class name entry.
00927     //
00928
00929     long dwEnum = ERROR_SUCCESS;    // The enumerator
00930     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
00931
00932     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
00933
00934     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00935                                   0,                    // Sub key
00936                                   0,                    // Reserved
00937                                   KEY_ALL_ACCESS,       // Access
00938                                   &hKeyEnum );          // Handle
00939
00940
00941     if ( ERROR_SUCCESS == dwError )
00942     {
00943         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClass );
00944
00945         //
00946         // Now enumerate all classes entries, looking for the clsid
00947         //
00948
00949         DWORD dwIndex = 0;
00950
00951         while ( ERROR_SUCCESS == dwEnum )
00952         {
00953             WCHAR wcTemp[MAX_PATH];
00954             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
00955             FILETIME ftUnused;
00956
00957             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
00958                                     dwIndex,                // Index of registry subkey
00959                                     wcTemp,                 // Buffer for name
00960                                     &dwSize,                // Size of buffer / key
00961                                     0,                      // Reserved
00962                                     0,                      // Class (unused)
00963                                     0,                      // Class size (unused)
00964                                     &ftUnused );            // Filetime (unused)
00965
00966             dwIndex++;
00967
00968             if ( ERROR_SUCCESS == dwEnum )
00969             {
00970                 HKEY hKey;
00971
00972                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00973                                          wcTemp,               // Sub key
00974                                          0,                    // Reserved
00975                                          KEY_ALL_ACCESS,       // Access
00976                                          &hKey );              // Handle
00977
00978                 if ( ERROR_SUCCESS == dwError )
00979                 {
00980                     WCHAR wcTemp2[MAX_PATH];
00981                     DWORD dwType;
00982
00983                     dwSize = sizeof(wcTemp2);
00984
00985                     dwError = RegQueryValueExW( hKey,                // Key handle
00986                                                 0,                   // Name
00987                                                 0,                   // Reserved
00988                                                 &dwType,             // Datatype
00989                                                 (BYTE *)wcTemp2,     // Data returned here
00990                                                 &dwSize );           // Size of data
00991
00992                     RegCloseKey( hKey );
00993
00994                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClass ) )
00995                     {
00996                         //
00997                         // Always delete the value
00998                         //
00999
01000                         if ( ERROR_SUCCESS == dwIgnore )
01001                             dwIgnore = RegDeleteValueW( hKey, 0 );
01002                         else
01003                             RegDeleteValueW( hKey, 0 );
01004
01005                         //
01006                         // Any other key(s)?
01007                         //
01008
01009                         dwSize = sizeof(wcTemp) / sizeof wcTemp[0];
01010
01011                         DWORD dw2 = RegEnumKeyExW( hKey,                   // Handle of key
01012                                                    0,                      // Index of registry subkey
01013                                                    wcTemp,                 // Buffer for name
01014                                                    &dwSize,                // Size of buffer / key
01015                                                    0,                      // Reserved
01016                                                    0,                      // Class (unused)
01017                                                    0,                      // Class size (unused)
01018                                                    &ftUnused );            // Filetime (unused)
01019
01020                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01021                         {
01022                             if ( ERROR_SUCCESS == dwIgnore )
01023                                 dwIgnore = RegDeleteKeyW( hKeyEnum, wcTemp );
01024                             else
01025                                 RegDeleteKeyW( hKeyEnum, wcTemp );
01026
01027                             dwIndex = 0;
01028                         }
01029
01030                     }
01031                     else
01032                         dwError = ERROR_SUCCESS;  // Just didn't have a null key (or no match)
01033                 }
01034             }
01035         }
01036     }
01037
01038     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01039         dwError = dwEnum;
01040
01041     if ( ERROR_SUCCESS != dwError )
01042         return dwError;
01043     else
01044         return dwIgnore;
01045 }
01046
01047 //+---------------------------------------------------------------------------
01048 //
01049 //  Function:   RemoveAClass, private
01050 //
01051 //  Synopsis:   Removes all references to class
01052 //
01053 //  Arguments:  [pwszClass] -- Class
01054 //
01055 //  Returns:    ERROR_SUCCESS on success
01056 //
01057 //----------------------------------------------------------------------------
01058
01059 inline long RemoveAClass( WCHAR * pwszClassId )
01060 {
01061     //
01062     // First, delete class entry.
01063     //
01064
01065     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
01066     long dwEnum = ERROR_SUCCESS;    // For enumerator
01067
01068     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01069
01070     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01071                                   L"CLSID",             // Sub key
01072                                   0,                    // Reserved
01073                                   KEY_ALL_ACCESS,       // Access
01074                                   &hKeyEnum );          // Handle
01075
01076     if ( ERROR_SUCCESS == dwError )
01077     {
01078         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClassId );
01079
01080         RegCloseKey( hKeyEnum );
01081
01082         long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01083                                       0,                    // Sub key
01084                                       0,                    // Reserved
01085                                       KEY_ALL_ACCESS,       // Access
01086                                       &hKeyEnum );          // Handle
01087     }
01088
01089     if ( ERROR_SUCCESS == dwError )
01090     {
01091         //
01092         // Now enumerate all classes entries, looking for the clsid
01093         //
01094
01095         DWORD dwIndex = 0;
01096
01097         while ( ERROR_SUCCESS == dwEnum )
01098         {
01099             WCHAR wcTemp[MAX_PATH];
01100             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01101             FILETIME ftUnused;
01102
01103             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01104                                     dwIndex,                // Index of registry subkey
01105                                     wcTemp,                 // Buffer for name
01106                                     &dwSize,                // Size of buffer / key
01107                                     0,                      // Reserved
01108                                     0,                      // Class (unused)
01109                                     0,                      // Class size (unused)
01110                                     &ftUnused );            // Filetime (unused)
01111
01112             dwIndex++;
01113
01114             if ( ERROR_SUCCESS == dwEnum )
01115             {
01116                 wcscat( wcTemp, L"\\CLSID" );
01117
01118                 HKEY hKey;
01119
01120                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01121                                          wcTemp,               // Sub key
01122                                          0,                    // Reserved
01123                                          KEY_ALL_ACCESS,       // Access
01124                                          &hKey );              // Handle
01125
01126                 if ( ERROR_SUCCESS == dwError )
01127                 {
01128                     WCHAR wcTemp2[MAX_PATH];
01129                     DWORD dwType;
01130
01131                     dwSize = sizeof(wcTemp2);
01132
01133                     dwError = RegQueryValueExW( hKey,                // Key handle
01134                                                 0,                   // Name
01135                                                 0,                   // Reserved
01136                                                 &dwType,             // Datatype
01137                                                 (BYTE *)wcTemp2,     // Data returned here
01138                                                 &dwSize );           // Size of data
01139
01140                     RegCloseKey( hKey );
01141
01142                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClassId ) )
01143                     {
01144                         wcTemp[ wcslen(wcTemp) - wcslen( L"\\CLSID" ) ] = 0;
01145
01146                         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01147                                                  wcTemp,               // Sub key
01148                                                  0,                    // Reserved
01149                                                  KEY_ALL_ACCESS,       // Access
01150                                                  &hKey );              // Handle
01151
01152                         if ( ERROR_SUCCESS == dwError )
01153                         {
01154                             if ( ERROR_SUCCESS == dwIgnore )
01155                                 dwIgnore = RegDeleteKeyW( hKey, L"CLSID" );
01156                             else
01157                                 RegDeleteKeyW( hKey, L"CLSID" );
01158
01159                             dwIndex = 0;
01160                         }
01161
01162                         //
01163                         // If there are no more entries, then the class name can be deleted
01164                         //
01165
01166                         dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01167
01168                         long dw2 = RegEnumKeyExW( hKey,               // Handle of key
01169                                                   0,                  // Index of registry subkey
01170                                                   wcTemp,             // Buffer for name
01171                                                   &dwSize,            // Size of buffer / key
01172                                                   0,                  // Reserved
01173                                                   0,                  // Class (unused)
01174                                                   0,                  // Class size (unused)
01175                                                   &ftUnused );        // Filetime (unused)
01176
01177                         RegCloseKey( hKey );
01178
01179                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01180                             RemoveAClassName( wcTemp );
01181                     }
01182                 }
01183                 else
01184                     dwError = ERROR_SUCCESS;  // Just didn't have CLSID
01185             }
01186         }
01187     }
01188
01189     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01190         dwError = dwEnum;
01191
01192     if ( ERROR_SUCCESS != dwError )
01193         return dwError;
01194     else
01195         return dwIgnore;
01196 }
01197
01198 //+---------------------------------------------------------------------------
01199 //
01200 //  Function:   RegisterAHandler, private
01201 //
01202 //  Synopsis:   Registers a persistent handler in registry
01203 //
01204 //  Arguments:  [Handler] -- Persistent handler
01205 //
01206 //  Returns:    ERROR_SUCCESS on success
01207 //
01208 //----------------------------------------------------------------------------
01209
01210 inline long RegisterAHandler( SHandlerEntry const & Handler )
01211 {
01212     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01213                                     Handler.pwszClassIdDescription,
01214                                     L"PersistentAddinsRegistered",
01215                                     0,
01216                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01217                                     Handler.pwszClassIdFilter };
01218
01219     return BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01220 }
01221
01222 //+---------------------------------------------------------------------------
01223 //
01224 //  Function:   RegisterAFilter, private
01225 //
01226 //  Synopsis:   Registers a filter in registry
01227 //
01228 //  Arguments:  [Filter] -- IFilter implementation
01229 //
01230 //  Returns:    ERROR_SUCCESS on success
01231 //
01232 //----------------------------------------------------------------------------
01233
01234 inline long RegisterAFilter( SFilterEntry const & Filter )
01235 {
01236     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01237                                     Filter.pwszClassIdDescription,
01238                                     L"InprocServer32",
01239                                     Filter.pwszDLL };
01240
01241     long retVal = BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01242     if ( ERROR_SUCCESS == retVal )
01243         retVal = AddThreadingModel( Filter.pwszClassId, Filter.pwszThreadingModel );
01244
01245     return retVal;
01246 }
01247
01248 //+---------------------------------------------------------------------------
01249 //
01250 //  Function:   UnRegisterAHandler, private
01251 //
01252 //  Synopsis:   Unregisters a persistent handler, including class entries.
01253 //
01254 //  Arguments:  [Handler] -- Persistent handler
01255 //
01256 //  Returns:    ERROR_SUCCESS on success
01257 //
01258 //----------------------------------------------------------------------------
01259
01260 inline long UnRegisterAHandler( SHandlerEntry const & Handler )
01261 {
01262     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01263                                     Handler.pwszClassIdDescription,
01264                                     L"PersistentAddinsRegistered",
01265                                     0,
01266                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01267                                     Handler.pwszClassIdFilter };
01268
01269     //
01270     // dwIgnore is used to record non-fatal errors
01271     //
01272
01273     long dwIgnore = DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01274     long dwError = ERROR_SUCCESS;
01275
01276     //
01277     // Now, enumerate all classes and delete any persistent handler entries.
01278     //
01279
01280     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01281
01282     long dwEnum = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01283                                  L"CLSID",              // Sub key
01284                                  0,                    // Reserved
01285                                  KEY_ALL_ACCESS,       // Access
01286                                  &hKeyEnum );          // Handle
01287
01288     DWORD dwIndex = 0;
01289
01290     while ( ERROR_SUCCESS == dwEnum )
01291     {
01292         WCHAR wcTemp[MAX_PATH];
01293
01294         wcscpy( wcTemp, L"CLSID\\" );
01295         unsigned cc = (unsigned) wcslen( wcTemp );
01296
01297         DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]) - cc;
01298         FILETIME ftUnused;
01299
01300         dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01301                                 dwIndex,                // Index of registry subkey
01302                                 wcTemp + cc,            // Buffer for name
01303                                 &dwSize,                // Size of buffer / key
01304                                 0,                      // Reserved
01305                                 0,                      // Class (unused)
01306                                 0,                      // Class size (unused)
01307                                 &ftUnused );            // Filetime (unused)
01308
01309         dwIndex++;
01310
01311         //
01312         // Does the key have a persistent handler?
01313         //
01314
01315         if ( ERROR_SUCCESS == dwEnum )
01316         {
01317             wcscat( wcTemp, L"\\PersistentHandler" );
01318
01319             HKEY hKey;
01320
01321             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01322                                      wcTemp,               // Sub key
01323                                      0,                    // Reserved
01324                                      KEY_ALL_ACCESS,       // Access
01325                                      &hKey );              // Handle
01326
01327             if ( ERROR_SUCCESS == dwError )
01328             {
01329                 //
01330                 // Is this the persistent handler we're looking for?
01331                 //
01332
01333                 WCHAR wcTemp2[MAX_PATH];
01334                 DWORD dwType;
01335
01336                 dwSize = sizeof(wcTemp2);
01337
01338                 dwError = RegQueryValueExW( hKey,                // Key handle
01339                                             0,                   // Name
01340                                             0,                   // Reserved
01341                                             &dwType,             // Datatype
01342                                             (BYTE *)wcTemp2,     // Data returned here
01343                                             &dwSize );           // Size of data
01344
01345                 RegCloseKey( hKey );
01346
01347                 if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, Handler.pwszClassId ) )
01348                 {
01349                     wcTemp[ wcslen(wcTemp) - wcslen( L"\\PersistentHandler" ) ] = 0;
01350
01351                     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01352                                              wcTemp,               // Sub key
01353                                              0,                    // Reserved
01354                                              KEY_ALL_ACCESS,       // Access
01355                                              &hKey );              // Handle
01356
01357                     if ( ERROR_SUCCESS == dwError )
01358                     {
01359                         if ( ERROR_SUCCESS == dwIgnore )
01360                             dwIgnore = RegDeleteKeyW( hKey, L"PersistentHandler" );
01361                         else
01362                             RegDeleteKeyW( hKey, L"PersistentHandler" );
01363
01364                         dwIndex = 0; // Start over again
01365                     }
01366
01367                     //
01368                     // If that was the *only* entry under the clsid, then the class can be
01369                     // removed.
01370                     //
01371
01372                     dwSize = sizeof(wcTemp2)/sizeof(wcTemp2[0]);
01373
01374                     long dw2 = RegEnumKeyExW( hKey,             // Handle of key
01375                                               0,                // Index of registry subkey
01376                                               wcTemp2,          // Buffer for name
01377                                               &dwSize,          // Size of buffer / key
01378                                               0,                // Reserved
01379                                               0,                // Class (unused)
01380                                               0,                // Class size (unused)
01381                                               &ftUnused );      // Filetime (unused)
01382
01383                     RegCloseKey( hKey );
01384
01385                     if ( ERROR_NO_MORE_ITEMS == dw2 )
01386                         RemoveAClass( wcTemp + wcslen( L"CLSID\\" ) );
01387                 }
01388                 else
01389                 {
01390                     //
01391                     // Didn't have persistent handler null key.  Odd but not fatal.
01392                     // Or, key didn't match target.
01393                     //
01394
01395                     dwIgnore = dwError;
01396                     dwError = ERROR_SUCCESS;
01397                 }
01398
01399             }
01400             else
01401                 dwError = ERROR_SUCCESS;  // Just didn't have persistent handler
01402         }
01403     }
01404
01405     if ( (HKEY)INVALID_HANDLE_VALUE != hKeyEnum )
01406         RegCloseKey( hKeyEnum );
01407
01408     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01409         dwError = dwEnum;
01410
01411     if ( ERROR_SUCCESS != dwError )
01412         return dwError;
01413     else
01414         return dwIgnore;
01415 }
01416
01417 //+---------------------------------------------------------------------------
01418 //
01419 //  Function:   UnRegisterAnExt, private
01420 //
01421 //  Synopsis:   Unregisters a filter extension
01422 //
01423 //  Arguments:  [Class] -- Class description to unregister
01424 //
01425 //  Returns:    ERROR_SUCCESS on success
01426 //
01427 //----------------------------------------------------------------------------
01428
01429 inline long UnRegisterAnExt( SClassEntry const & Class )
01430 {
01431     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
01432     DWORD dwError;
01433
01434     do
01435     {
01436         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01437                                  Class.pwszExt,        // Sub key -- "CLSID"
01438                                  0,                    // Reserved
01439                                  KEY_ALL_ACCESS,       // Access
01440                                  &hKey );              // Handle
01441
01442         if ( ERROR_SUCCESS != dwError )
01443             break;
01444
01445         dwError = RegDeleteKeyW( hKey, L"PersistentHandler" );
01446
01447     } while ( FALSE );
01448
01449     if ( INVALID_HANDLE_VALUE != hKey )
01450     {
01451         RegCloseKey( hKey );
01452         hKey = (HKEY)INVALID_HANDLE_VALUE;
01453     }
01454
01455     return dwError;
01456 }
01457
01458 //+---------------------------------------------------------------------------
01459 //
01460 //  Function:   UnRegisterAFilter, private
01461 //
01462 //  Synopsis:   Unregisters a filter
01463 //
01464 //  Arguments:  [Filter] -- IFilter implementation
01465 //
01466 //  Returns:    ERROR_SUCCESS on success
01467 //
01468 //----------------------------------------------------------------------------
01469
01470 inline long UnRegisterAFilter( SFilterEntry const & Filter )
01471 {
01472     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01473                                     Filter.pwszClassIdDescription,
01474                                     L"InprocServer32",
01475                                     Filter.pwszDLL };
01476
01477     return DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01478 }
01479
01480 //+---------------------------------------------------------------------------
01481 //
01482 //  Function:   DllUnregisterServer
01483 //
01484 //  Synopsis:   Self-unregistration
01485 //
01486 //----------------------------------------------------------------------------
01487
01488 //+---------------------------------------------------------------------------
01489 //
01490 //  Function:   DllRegisterServer
01491 //
01492 //  Synopsis:   Self-registration
01493 //
01494 //  Notes:      There are two versions here.  Version 1 registers only
01495 //              extensions.  Version 2 registers extensions and
01496 //              [nameless] Class IDs.
01497 //
01498 //----------------------------------------------------------------------------
01499
01500 #define DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, fBlastExistingPersistentHandler )  \
01501                                                                \
01502 STDAPI Name##UnregisterServer()                                \
01503 {                                                              \
01504     /*                                                         \
01505      * Always remove Persistent Handler and Filter entries     \
01506      */                                                        \
01507                                                                \
01508     long dwError = UnRegisterAHandler( Handler );              \
01509                                                                \
01510     if ( ERROR_SUCCESS == dwError )                            \
01511         dwError = UnRegisterAFilter( Filter );                 \
01512     else                                                       \
01513         UnRegisterAFilter( Filter );                           \
01514                                                                \
01515     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01516     {                                                          \
01517         if ( ERROR_SUCCESS == dwError )                        \
01518             dwError = UnRegisterAnExt( aClasses[i] );          \
01519         else                                                   \
01520              UnRegisterAnExt( aClasses[i] );                   \
01521     }                                                          \
01522                                                                \
01523     if ( ERROR_SUCCESS == dwError )                            \
01524         return S_OK;                                           \
01525     else                                                       \
01526         return S_FALSE;                                        \
01527 }                                                              \
01528                                                                \
01529 STDAPI Name##RegisterServer()                                  \
01530 {                                                              \
01531     /*                                                         \
01532      * Always create Persistent Handler and Filter entries     \
01533      */                                                        \
01534                                                                \
01535     long dwError = RegisterAHandler( Handler );                \
01536                                                                \
01537     /*                                                         \
01538      * First, register the CLSID and persistent handler,       \
01539      * then work back to the class description and the         \
01540      * extension. This ensures we cover all possible           \
01541      * mappings.                                               \
01542      *                                                         \
01543      */                                                        \
01544                                                                \
01545     OSVERSIONINFO Version;                                     \
01546     Version.dwOSVersionInfoSize = sizeof(Version);             \
01547                                                                \
01548     BOOL fAppendOnly = FALSE;                                  \
01549                                                                \
01550     if ( GetVersionEx( &Version ) &&                           \
01551          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01552          Version.dwMajorVersion >= 5 )                         \
01553     {                                                          \
01554         fAppendOnly = TRUE;                                    \
01555     }                                                          \
01556                                                                \
01557     if ( ERROR_SUCCESS == dwError )                            \
01558         dwError = RegisterAFilter( Filter );                   \
01559                                                                \
01560     if ( ERROR_SUCCESS == dwError )                            \
01561         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01562             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01563                                                                \
01564     if ( ERROR_SUCCESS == dwError )                            \
01565         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01566             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01567                                                                \
01568     if ( ERROR_SUCCESS == dwError )                            \
01569         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01570             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly, fBlastExistingPersistentHandler );                     \
01571                                                                \
01572     if ( ERROR_SUCCESS == dwError )                            \
01573         return S_OK;                                           \
01574     else                                                       \
01575         return SELFREG_E_CLASS;                                \
01576 }
01577
01578
01579 #define DEFINE_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01580     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, TRUE )  \
01581
01582
01583 #define DEFINE_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01584     DEFINE_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01585
01586 #define DEFINE_SOFT_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01587     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, FALSE )  \
01588
01589 #define DEFINE_SOFT_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01590     DEFINE_SOFT_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01591
01592
01593 //
01594 // Version 2 (for NT 4 support where all the extra registry goo is required).
01595 //
01596
01597 #define DEFINE_REGISTERFILTER2( Name, Handler, Filter, aClasses )  \
01598                                                                \
01599 STDAPI Name##UnregisterServer()                                \
01600 {                                                              \
01601     /*                                                         \
01602      * Always remove Persistent Handler and Filter entries     \
01603      */                                                        \
01604                                                                \
01605     long dwError = UnRegisterAHandler( Handler );              \
01606                                                                \
01607     if ( ERROR_SUCCESS == dwError )                            \
01608         dwError = UnRegisterAFilter( Filter );                 \
01609     else                                                       \
01610         UnRegisterAFilter( Filter );                           \
01611                                                                \
01612     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01613     {                                                          \
01614         if ( ERROR_SUCCESS == dwError )                        \
01615             dwError = UnRegisterAnExt( aClasses[i] );          \
01616         else                                                   \
01617             UnRegisterAnExt( aClasses[i] );                    \
01618     }                                                          \
01619                                                                \
01620     if ( ERROR_SUCCESS == dwError )                            \
01621         return S_OK;                                           \
01622     else                                                       \
01623         return S_FALSE;                                        \
01624 }                                                              \
01625                                                                \
01626 STDAPI Name##RegisterServer()                                  \
01627 {                                                              \
01628     /*                                                         \
01629      * Always create Persistent Handler and Filter entries     \
01630      */                                                        \
01631                                                                \
01632     long dwError = RegisterAHandler( Handler );                \
01633                                                                \
01634     /*                                                         \
01635      * First, register the CLSID and persistent handler,       \
01636      * then work back to the class description and the         \
01637      * extension. This ensures we cover all possible           \
01638      * mappings.                                               \
01639      *                                                         \
01640      */                                                        \
01641                                                                \
01642     OSVERSIONINFO Version;                                     \
01643     Version.dwOSVersionInfoSize = sizeof(Version);             \
01644                                                                \
01645     BOOL fAppendOnly = FALSE;                                  \
01646                                                                \
01647     if ( GetVersionEx( &Version ) &&                           \
01648          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01649          Version.dwMajorVersion >= 5 )                         \
01650     {                                                          \
01651         fAppendOnly = TRUE;                                    \
01652     }                                                          \
01653                                                                \
01654     if ( ERROR_SUCCESS == dwError )                            \
01655         dwError = RegisterAFilter( Filter );                   \
01656                                                                \
01657     if ( ERROR_SUCCESS == dwError )                            \
01658         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01659             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, FALSE, FALSE );                \
01660                                                                \
01661     if ( ERROR_SUCCESS == dwError )                            \
01662         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01663             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01664                                                                \
01665     if ( ERROR_SUCCESS == dwError )                            \
01666         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01667             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly );                     \
01668                                                                \
01669     if ( ERROR_SUCCESS == dwError )                            \
01670         return S_OK;                                           \
01671     else                                                       \
01672         return SELFREG_E_CLASS;                                \
01673 }
01674
01675
01676
01677
01678 #define DEFINE_DLLREGISTERFILTER2( Handler, Filter, aClasses )  \
01679     DEFINE_REGISTERFILTER2( Dll, Handler, Filter, aClasses )
01680
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBehavior Member List

This is the complete list of members for CBehavior, including all inherited members.
CBehavior() | CBehavior | [inline]
Detach(void) | CBehavior |
Distance(POINT pt1, POINT pt2) | CBehavior |
Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject) | CBehavior |
GetEventObject(IHTMLEventObj **event) | CBehavior |
GetPainterInfo(HTML_PAINTER_INFO *pInfo) | CBehavior |
HitTestPoint(POINT pt, BOOL *pbHit, LONG *plPartID) | CBehavior |
Init(IElementBehaviorSite *pBehaviorSite) | CBehavior |
m_dwCookie | CBehavior |
m_lCookie | CBehavior |
m_lPartID | CBehavior |
m_pEventSink | CBehavior |
m_pPaintSite | CBehavior |
m_ptPolyCorners | CBehavior |
m_rtElemCorners | CBehavior |
m_spDoc | CBehavior |
m_spElem | CBehavior |
m_spOMSite | CBehavior |
m_spParent | CBehavior |
m_spSel | CBehavior |
m_spSite | CBehavior |
m_spWin | CBehavior |
Notify(LONG lEvent, VARIANT *pVar) | CBehavior |
OnResize(SIZE pt) | CBehavior |
Generated on Wed Nov 13 2024 16:55:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userproppage/stdafx.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userproppage

stdafx.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       stdafx.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // stdafx.h : include file for standard system include files,
00012 //      or project specific include files that are used frequently,
00013 //      but are changed infrequently
00014
00015 #if !defined(AFX_STDAFX_H__501092D7_8966_11D1_B93C_00A0C9A06D2D__INCLUDED_)
00016 #define AFX_STDAFX_H__501092D7_8966_11D1_B93C_00A0C9A06D2D__INCLUDED_
00017
00018 #if _MSC_VER >= 1000
00019 #pragma once
00020 #endif // _MSC_VER >= 1000
00021
00022 #define STRICT
00023
00024 #include <afxwin.h>
00025 #include <afxdisp.h>
00026 #include "afxdlgs.h"
00027
00028
00029
00030 #define _ATL_APARTMENT_THREADED
00031
00032
00033 #include <activeds.h>
00034 #include <dsadmin.h>
00035
00036 #include <atlbase.h>
00037
00038 #if ( _ATL_VER >= 0x0300 )
00039 #define _ATL_NO_UUIDOF
00040 #endif
00041
00042
00043
00044
00045 class CMyUIExtModule : public CComModule
00046 {
00047 public:
00048   HRESULT WINAPI UpdateRegistryCLSID(const CLSID& clsid, BOOL bRegister);
00049 };
00050
00051 #define DECLARE_REGISTRY_CLSID() \
00052 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
00053 { \
00054     return _Module.UpdateRegistryCLSID(GetObjectCLSID(), bRegister); \
00055 }
00056
00057 extern CMyUIExtModule _Module;
00058
00059 #include <atlcom.h>
00060
00061 #include <activeds.h> // Active Directory Services Interfaces
00062
00063 //{{AFX_INSERT_LOCATION}}
00064 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00065
00066 #endif // !defined(AFX_STDAFX_H__501092D7_8966_11D1_B93C_00A0C9A06D2D__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/UserEvents/VCAcct/Account.cpp Source File

  • Com
  • Services
  • Events
  • UserEvents
  • VCAcct

Account.cpp

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: Account.cpp
00003 //
00004 //
00005 // Description: Implementation of DLL Exports.
00006 //
00007 //
00008 // This file is part of the Microsoft COM+ Samples
00009 //
00010 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00011 //
00012 // This source code is intended only as a supplement to Microsoft
00013 // Development Tools and/or on-line documentation.  See these other
00014 // materials for detailed information reagrding Microsoft code samples.
00015 //
00016 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 // PARTICULAR PURPOSE.
00020 //
00021 //==============================================================================
00022 //
00023 // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this
00024 // project.  This is because you will need MIDL 3.00.15 or higher and new
00025 // headers and libs.  If you have VC 4.2 installed, then everything should
00026 // already be configured correctly.
00027
00028 // Note: Proxy/Stub Information
00029 //    To merge the proxy/stub code into the object DLL, add the file
00030 //    dlldatax.c to the project.  Make sure precompiled headers
00031 //    are turned off for this file, and add _MERGE_PROXYSTUB to the
00032 //    defines for the project.
00033 //
00034 //    Modify the custom build rule for Account.idl by adding the following
00035 //    files to the Outputs.  You can select all of the .IDL files by
00036 //    expanding each project and holding Ctrl while clicking on each of them.
00037 //      Account_p.c
00038 //      dlldata.c
00039 //    To build a separate proxy/stub DLL,
00040 //    run nmake -f Accountps.mak in the project directory.
00041
00042 #include "stdafx.h"
00043 #include "resource.h"
00044 #include "initguid.h"
00045 #include "Account.h"
00046 #include "CAccount.h"
00047 #include <comadmin.h>
00048
00049 //
00050 // to merge proxy/stub, uncomment this line
00051 // #include "dlldatax.h"
00052 //
00053 #define IID_DEFINED
00054 #include "Account_i.c"
00055
00056 #ifdef _MERGE_PROXYSTUB
00057 extern "C" HINSTANCE hProxyDll;
00058 #endif
00059
00060 CComModule _Module;
00061
00062 BEGIN_OBJECT_MAP(ObjectMap)
00063   OBJECT_ENTRY(CLSID_CAccount, CAccount)
00064 END_OBJECT_MAP()
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // DLL Entry Point
00068
00069 extern "C"
00070 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00071 {
00072   lpReserved;
00073 #ifdef _MERGE_PROXYSTUB
00074   if (!PrxDllMain(hInstance, dwReason, lpReserved))
00075     return FALSE;
00076 #endif
00077   if (dwReason == DLL_PROCESS_ATTACH)
00078   {
00079     _Module.Init(ObjectMap, hInstance);
00080     DisableThreadLibraryCalls(hInstance);
00081   }
00082   else if (dwReason == DLL_PROCESS_DETACH)
00083     _Module.Term();
00084   return TRUE;    // ok
00085 }
00086
00087 /////////////////////////////////////////////////////////////////////////////
00088 // Used to determine whether the DLL can be unloaded by OLE
00089
00090 STDAPI DllCanUnloadNow(void)
00091 {
00092 #ifdef _MERGE_PROXYSTUB
00093   if (PrxDllCanUnloadNow() != S_OK)
00094     return S_FALSE;
00095 #endif
00096   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00097 }
00098
00099 /////////////////////////////////////////////////////////////////////////////
00100 // Returns a class factory to create an object of the requested type
00101
00102 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00103 {
00104 #ifdef _MERGE_PROXYSTUB
00105   if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00106     return S_OK;
00107 #endif
00108   return _Module.GetClassObject(rclsid, riid, ppv);
00109 }
00110
00111 /////////////////////////////////////////////////////////////////////////////
00112 // DllRegisterServer - Adds entries to the system registry
00113
00114 STDAPI DllRegisterServer(void)
00115 {
00116 #ifdef _MERGE_PROXYSTUB
00117   HRESULT hRes = PrxDllRegisterServer();
00118   if (FAILED(hRes))
00119     return hRes;
00120 #endif
00121   // registers object, typelib and all interfaces in typelib
00122   return _Module.RegisterServer(TRUE);
00123 }
00124
00125 /////////////////////////////////////////////////////////////////////////////
00126 // DllUnregisterServer - Removes entries from the system registry
00127
00128 STDAPI DllUnregisterServer(void)
00129 {
00130 #ifdef _MERGE_PROXYSTUB
00131   PrxDllUnregisterServer();
00132 #endif
00133   _Module.UnregisterServer();
00134   return S_OK;
00135 }
00136
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAttributeValueEditor Member List

This is the complete list of members for CAttributeValueEditor, including all inherited members.
CAttributeValueEditor(CMultiValuedAttributeEditor *pEditor) | CAttributeValueEditor | [inline]
CAttributeValueEditor(CMultiValuedAttributeEditor *pEditor) | CAttributeValueEditor | [inline]
m_pEditor | CAttributeValueEditor | [protected]
OnChange() | CAttributeValueEditor |
OnChange() | CAttributeValueEditor |
~CAttributeValueEditor() | CAttributeValueEditor | [inline]
~CAttributeValueEditor() | CAttributeValueEditor | [inline]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Dt_Dll2/DtHandler.Hpp Source File

  • NetDS
  • WinSock
  • Dt_Dll2

DtHandler.Hpp

Go to the documentation of this file.
00001 // Filename  : DTHandler.hpp
00002 // Abstract  : This object implements a mechanism for hooking Winsock
00003 //             API calls via the 'DT hooks' present in the checked-build
00004 //             version of the ws2_32.dll. (See the Winsock DT sample on
00005 //             on the Platform SDK for specifications.)  Through invoking
00006 //             the DTHandler::dispatch() method, this object translates
00007 //             the hook's code ordinal and calls the appropriate virtual
00008 //             member function of the same Winsock API name, which you can
00009 //             overload through inheritance, with the proper API parameters
00010 //             expanded from DT's variable argument list call, making it
00011 //             possible for you to easily trace your Winsock application
00012 //             in a debug setting.
00013 // Author    : Jeffrey C. Venable, Sr.
00014 // Copyright : THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00015 //             WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00016 //             INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
00017 //             MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00018 //             Copyright (C) 1998 - 2001,  Microsoft Corporation.
00019 //             All rights reserved.
00020
00021 #ifndef _DTHANDLER_H
00022 #define _DTHANDLER_H
00023
00024 // Prevent inclusion of winsock.h in windows.h
00025 #ifndef _WINSOCKAPI_
00026 #define _WINSOCKAPI_
00027 #endif
00028
00029 #include <ws2spi.h>
00030 #include <ws2tcpip.h>
00031 #include "APIHook.hpp"
00032 #include "dt_dll.hpp"
00033
00034 class DTHandler {
00035
00036     static bool (* _dispatchTable[MAX_DTCODE + 1])(DTHandler *, APIHook<void> &, va_list);
00037
00038     static bool _accept                                  (DTHandler *, APIHook<void> &, va_list);
00039     static bool _bind                                    (DTHandler *, APIHook<void> &, va_list);
00040     static bool _closesocket                             (DTHandler *, APIHook<void> &, va_list);
00041     static bool _connect                                 (DTHandler *, APIHook<void> &, va_list);
00042     static bool _getpeername                             (DTHandler *, APIHook<void> &, va_list);
00043     static bool _getsockname                             (DTHandler *, APIHook<void> &, va_list);
00044     static bool _getsockopt                              (DTHandler *, APIHook<void> &, va_list);
00045     static bool _htonl                                   (DTHandler *, APIHook<void> &, va_list);
00046     static bool _htons                                   (DTHandler *, APIHook<void> &, va_list);
00047     static bool _ioctlsocket                             (DTHandler *, APIHook<void> &, va_list);
00048     static bool _listen                                  (DTHandler *, APIHook<void> &, va_list);
00049     static bool _ntohl                                   (DTHandler *, APIHook<void> &, va_list);
00050     static bool _ntohs                                   (DTHandler *, APIHook<void> &, va_list);
00051     static bool _recv                                    (DTHandler *, APIHook<void> &, va_list);
00052     static bool _recvfrom                                (DTHandler *, APIHook<void> &, va_list);
00053     static bool _select                                  (DTHandler *, APIHook<void> &, va_list);
00054     static bool _send                                    (DTHandler *, APIHook<void> &, va_list);
00055     static bool _sendto                                  (DTHandler *, APIHook<void> &, va_list);
00056     static bool _setsockopt                              (DTHandler *, APIHook<void> &, va_list);
00057     static bool _shutdown                                (DTHandler *, APIHook<void> &, va_list);
00058     static bool _socket                                  (DTHandler *, APIHook<void> &, va_list);
00059     static bool _WSAAccept                               (DTHandler *, APIHook<void> &, va_list);
00060     static bool _WSAAsyncSelect                          (DTHandler *, APIHook<void> &, va_list);
00061     static bool _WSACancelBlockingCall                   (DTHandler *, APIHook<void> &, va_list);
00062     static bool _WSACleanup                              (DTHandler *, APIHook<void> &, va_list);
00063     static bool _WSACloseEvent                           (DTHandler *, APIHook<void> &, va_list);
00064     static bool _WSAConnect                              (DTHandler *, APIHook<void> &, va_list);
00065     static bool _WSACreateEvent                          (DTHandler *, APIHook<void> &, va_list);
00066     static bool _WSADuplicateSocketA                     (DTHandler *, APIHook<void> &, va_list);
00067     static bool _WSADuplicateSocketW                     (DTHandler *, APIHook<void> &, va_list);
00068     static bool _WSAEnumNetworkEvents                    (DTHandler *, APIHook<void> &, va_list);
00069     static bool _WSAEnumProtocolsA                       (DTHandler *, APIHook<void> &, va_list);
00070     static bool _WSAEnumProtocolsW                       (DTHandler *, APIHook<void> &, va_list);
00071     static bool _WSAEventSelect                          (DTHandler *, APIHook<void> &, va_list);
00072     static bool _WSAGetLastError                         (DTHandler *, APIHook<void> &, va_list);
00073     static bool _WSAGetOverlappedResult                  (DTHandler *, APIHook<void> &, va_list);
00074     static bool _WSAGetQOSByName                         (DTHandler *, APIHook<void> &, va_list);
00075     static bool _WSAHtonl                                (DTHandler *, APIHook<void> &, va_list);
00076     static bool _WSAHtons                                (DTHandler *, APIHook<void> &, va_list);
00077     static bool _WSAIoctl                                (DTHandler *, APIHook<void> &, va_list);
00078     static bool _WSAIsBlocking                           (DTHandler *, APIHook<void> &, va_list);
00079     static bool _WSAJoinLeaf                             (DTHandler *, APIHook<void> &, va_list);
00080     static bool _WSANtohl                                (DTHandler *, APIHook<void> &, va_list);
00081     static bool _WSANtohs                                (DTHandler *, APIHook<void> &, va_list);
00082     static bool _WSARecv                                 (DTHandler *, APIHook<void> &, va_list);
00083     static bool _WSARecvDisconnect                       (DTHandler *, APIHook<void> &, va_list);
00084     static bool _WSARecvFrom                             (DTHandler *, APIHook<void> &, va_list);
00085     static bool _WSAResetEvent                           (DTHandler *, APIHook<void> &, va_list);
00086     static bool _WSASend                                 (DTHandler *, APIHook<void> &, va_list);
00087     static bool _WSASendDisconnect                       (DTHandler *, APIHook<void> &, va_list);
00088     static bool _WSASendTo                               (DTHandler *, APIHook<void> &, va_list);
00089     static bool _WSASetBlockingHook                      (DTHandler *, APIHook<void> &, va_list);
00090     static bool _WSASetEvent                             (DTHandler *, APIHook<void> &, va_list);
00091     static bool _WSASetLastError                         (DTHandler *, APIHook<void> &, va_list);
00092     static bool _WSASocketA                              (DTHandler *, APIHook<void> &, va_list);
00093     static bool _WSASocketW                              (DTHandler *, APIHook<void> &, va_list);
00094     static bool _WSAStartup                              (DTHandler *, APIHook<void> &, va_list);
00095     static bool _WSAUnhookBlockingHook                   (DTHandler *, APIHook<void> &, va_list);
00096     static bool _WSAWaitForMultipleEvents                (DTHandler *, APIHook<void> &, va_list);
00097     static bool _gethostbyaddr                           (DTHandler *, APIHook<void> &, va_list);
00098     static bool _gethostbyname                           (DTHandler *, APIHook<void> &, va_list);
00099     static bool _gethostname                             (DTHandler *, APIHook<void> &, va_list);
00100     static bool _getprotobyname                          (DTHandler *, APIHook<void> &, va_list);
00101     static bool _getprotobynumber                        (DTHandler *, APIHook<void> &, va_list);
00102     static bool _getservbyname                           (DTHandler *, APIHook<void> &, va_list);
00103     static bool _getservbyport                           (DTHandler *, APIHook<void> &, va_list);
00104     static bool _inet_addr                               (DTHandler *, APIHook<void> &, va_list);
00105     static bool _inet_ntoa                               (DTHandler *, APIHook<void> &, va_list);
00106     static bool _WSAAsyncGetHostByAddr                   (DTHandler *, APIHook<void> &, va_list);
00107     static bool _WSAAsyncGetHostByName                   (DTHandler *, APIHook<void> &, va_list);
00108     static bool _WSAAsyncGetProtoByName                  (DTHandler *, APIHook<void> &, va_list);
00109     static bool _WSAAsyncGetProtoByNumber                (DTHandler *, APIHook<void> &, va_list);
00110     static bool _WSAAsyncGetServByName                   (DTHandler *, APIHook<void> &, va_list);
00111     static bool _WSAAsyncGetServByPort                   (DTHandler *, APIHook<void> &, va_list);
00112     static bool _WSACancelAsyncRequest                   (DTHandler *, APIHook<void> &, va_list);
00113     static bool _WSPAccept                               (DTHandler *, APIHook<void> &, va_list);
00114     static bool _WSPAsyncSelect                          (DTHandler *, APIHook<void> &, va_list);
00115     static bool _WSPBind                                 (DTHandler *, APIHook<void> &, va_list);
00116     static bool _WSPCancelBlockingCall                   (DTHandler *, APIHook<void> &, va_list);
00117     static bool _WSPCleanup                              (DTHandler *, APIHook<void> &, va_list);
00118     static bool _WSPCloseSocket                          (DTHandler *, APIHook<void> &, va_list);
00119     static bool _WSPConnect                              (DTHandler *, APIHook<void> &, va_list);
00120     static bool _WSPDuplicateSocket                      (DTHandler *, APIHook<void> &, va_list);
00121     static bool _WSPEnumNetworkEvents                    (DTHandler *, APIHook<void> &, va_list);
00122     static bool _WSPEventSelect                          (DTHandler *, APIHook<void> &, va_list);
00123     static bool _WSPGetOverlappedResult                  (DTHandler *, APIHook<void> &, va_list);
00124     static bool _WSPGetPeerName                          (DTHandler *, APIHook<void> &, va_list);
00125 //  static bool _WSPGetProcTable                         (DTHandler *, APIHook<void> &, va_list);
00126     static bool _WSPGetSockName                          (DTHandler *, APIHook<void> &, va_list);
00127     static bool _WSPGetSockOpt                           (DTHandler *, APIHook<void> &, va_list);
00128     static bool _WSPGetQOSByName                         (DTHandler *, APIHook<void> &, va_list);
00129     static bool _WSPIoctl                                (DTHandler *, APIHook<void> &, va_list);
00130     static bool _WSPJoinLeaf                             (DTHandler *, APIHook<void> &, va_list);
00131     static bool _WSPListen                               (DTHandler *, APIHook<void> &, va_list);
00132     static bool _WSPRecv                                 (DTHandler *, APIHook<void> &, va_list);
00133     static bool _WSPRecvDisconnect                       (DTHandler *, APIHook<void> &, va_list);
00134     static bool _WSPRecvFrom                             (DTHandler *, APIHook<void> &, va_list);
00135     static bool _WSPSelect                               (DTHandler *, APIHook<void> &, va_list);
00136     static bool _WSPSend                                 (DTHandler *, APIHook<void> &, va_list);
00137     static bool _WSPSendDisconnect                       (DTHandler *, APIHook<void> &, va_list);
00138     static bool _WSPSendTo                               (DTHandler *, APIHook<void> &, va_list);
00139     static bool _WSPSetSockOpt                           (DTHandler *, APIHook<void> &, va_list);
00140     static bool _WSPShutdown                             (DTHandler *, APIHook<void> &, va_list);
00141     static bool _WSPSocket                               (DTHandler *, APIHook<void> &, va_list);
00142     static bool _WSPStartup                              (DTHandler *, APIHook<void> &, va_list);
00143     static bool _WPUCloseEvent                           (DTHandler *, APIHook<void> &, va_list);
00144     static bool _WPUCloseSocketHandle                    (DTHandler *, APIHook<void> &, va_list);
00145     static bool _WPUCreateEvent                          (DTHandler *, APIHook<void> &, va_list);
00146     static bool _WPUCreateSocketHandle                   (DTHandler *, APIHook<void> &, va_list);
00147     static bool _WSCDeinstallProvider                    (DTHandler *, APIHook<void> &, va_list);
00148     static bool _WSCInstallProvider                      (DTHandler *, APIHook<void> &, va_list);
00149     static bool _WPUModifyIFSHandle                      (DTHandler *, APIHook<void> &, va_list);
00150     static bool _WPUQueryBlockingCallback                (DTHandler *, APIHook<void> &, va_list);
00151     static bool _WPUQuerySocketHandleContext             (DTHandler *, APIHook<void> &, va_list);
00152     static bool _WPUQueueApc                             (DTHandler *, APIHook<void> &, va_list);
00153     static bool _WPUResetEvent                           (DTHandler *, APIHook<void> &, va_list);
00154     static bool _WPUSetEvent                             (DTHandler *, APIHook<void> &, va_list);
00155     static bool _WPUFDIsSet                              (DTHandler *, APIHook<void> &, va_list);
00156     static bool _WPUGetProviderPath                      (DTHandler *, APIHook<void> &, va_list);
00157     static bool _WPUPostMessage                          (DTHandler *, APIHook<void> &, va_list);
00158     static bool ___WSAFDIsSet                            (DTHandler *, APIHook<void> &, va_list);
00159     static bool _WSCEnumProtocols                        (DTHandler *, APIHook<void> &, va_list);
00160     static bool _WSAAddressToStringA                     (DTHandler *, APIHook<void> &, va_list);
00161     static bool _WSAAddressToStringW                     (DTHandler *, APIHook<void> &, va_list);
00162     static bool _WSAStringToAddressA                     (DTHandler *, APIHook<void> &, va_list);
00163     static bool _WSAStringToAddressW                     (DTHandler *, APIHook<void> &, va_list);
00164     static bool _WSALookupServiceBeginA                  (DTHandler *, APIHook<void> &, va_list);
00165     static bool _WSALookupServiceBeginW                  (DTHandler *, APIHook<void> &, va_list);
00166     static bool _WSALookupServiceNextA                   (DTHandler *, APIHook<void> &, va_list);
00167     static bool _WSALookupServiceNextW                   (DTHandler *, APIHook<void> &, va_list);
00168     static bool _WSALookupServiceEnd                     (DTHandler *, APIHook<void> &, va_list);
00169 //  static bool _WSAGetAddressByNameA                    (DTHandler *, APIHook<void> &, va_list);
00170 //  static bool _WSAGetAddressByNameW                    (DTHandler *, APIHook<void> &, va_list);
00171     static bool _WSAInstallServiceClassA                 (DTHandler *, APIHook<void> &, va_list);
00172     static bool _WSAInstallServiceClassW                 (DTHandler *, APIHook<void> &, va_list);
00173     static bool _WSASetServiceA                          (DTHandler *, APIHook<void> &, va_list);
00174     static bool _WSASetServiceW                          (DTHandler *, APIHook<void> &, va_list);
00175     static bool _WSARemoveServiceClass                   (DTHandler *, APIHook<void> &, va_list);
00176     static bool _WSAGetServiceClassInfoA                 (DTHandler *, APIHook<void> &, va_list);
00177     static bool _WSAGetServiceClassInfoW                 (DTHandler *, APIHook<void> &, va_list);
00178     static bool _WSAEnumNameSpaceProvidersA              (DTHandler *, APIHook<void> &, va_list);
00179     static bool _WSAEnumNameSpaceProvidersW              (DTHandler *, APIHook<void> &, va_list);
00180     static bool _WSAGetServiceClassNameByClassIdA        (DTHandler *, APIHook<void> &, va_list);
00181     static bool _WSAGetServiceClassNameByClassIdW        (DTHandler *, APIHook<void> &, va_list);
00182     static bool _NSPAddressToString                      (DTHandler *, APIHook<void> &, va_list);
00183     static bool _NSPStringToAddress                      (DTHandler *, APIHook<void> &, va_list);
00184     static bool _NSPCleanup                              (DTHandler *, APIHook<void> &, va_list);
00185     static bool _NSPLookupServiceBegin                   (DTHandler *, APIHook<void> &, va_list);
00186     static bool _NSPLookupServiceNext                    (DTHandler *, APIHook<void> &, va_list);
00187     static bool _NSPLookupServiceEnd                     (DTHandler *, APIHook<void> &, va_list);
00188     static bool _NSPGetAddressByName                     (DTHandler *, APIHook<void> &, va_list);
00189     static bool _NSPSetService                           (DTHandler *, APIHook<void> &, va_list);
00190     static bool _NSPInstallServiceClass                  (DTHandler *, APIHook<void> &, va_list);
00191     static bool _NSPRemoveServiceClass                   (DTHandler *, APIHook<void> &, va_list);
00192     static bool _NSPGetServiceClassInfo                  (DTHandler *, APIHook<void> &, va_list);
00193 //  static bool _NSPEnumNameSpaceProviders               (DTHandler *, APIHook<void> &, va_list);
00194     static bool _NSPGetServiceClassNameByClassId         (DTHandler *, APIHook<void> &, va_list);
00195     static bool _WSCGetProviderPath                      (DTHandler *, APIHook<void> &, va_list);
00196     static bool _WSCInstallNameSpace                     (DTHandler *, APIHook<void> &, va_list);
00197     static bool _WSCUnInstallNameSpace                   (DTHandler *, APIHook<void> &, va_list);
00198     static bool _WSCEnableNSProvider                     (DTHandler *, APIHook<void> &, va_list);
00199     static bool _WSPAddressToString                      (DTHandler *, APIHook<void> &, va_list);
00200     static bool _WSPStringToAddress                      (DTHandler *, APIHook<void> &, va_list);
00201 #if (WINVER >= 0x0501)
00202     static bool _WSANSPIoctl                             (DTHandler *, APIHook<void> &, va_list);
00203     static bool _NSPIoctl                                (DTHandler *, APIHook<void> &, va_list);
00204     static bool _WPUCompleteOverlappedRequest            (DTHandler *, APIHook<void> &, va_list);
00205     static bool _WSAProviderConfigChange                 (DTHandler *, APIHook<void> &, va_list);
00206     static bool _WSCWriteProviderOrder                   (DTHandler *, APIHook<void> &, va_list);
00207     static bool _WSCWriteNameSpaceOrder                  (DTHandler *, APIHook<void> &, va_list);
00208     static bool _WSCUpdateProvider                       (DTHandler *, APIHook<void> &, va_list);
00209     static bool _getaddrinfo                             (DTHandler *, APIHook<void> &, va_list);
00210     static bool _getnameinfo                             (DTHandler *, APIHook<void> &, va_list);
00211     static bool _freeaddrinfo                            (DTHandler *, APIHook<void> &, va_list);
00212     static bool _NSPStartup                              (DTHandler *, APIHook<void> &, va_list);
00213     static bool _WPUOpenCurrentThread                    (DTHandler *, APIHook<void> &, va_list);
00214     static bool _WPUCloseThread                          (DTHandler *, APIHook<void> &, va_list);
00215 #if defined(_WIN64)
00216     static bool _WSCEnumProtocols32                      (DTHandler *, APIHook<void> &, va_list);
00217     static bool _WSCInstallProvider64_32                 (DTHandler *, APIHook<void> &, va_list);
00218     static bool _WSCDeinstallProvider32                  (DTHandler *, APIHook<void> &, va_list);
00219     static bool _WSCGetProviderPath32                    (DTHandler *, APIHook<void> &, va_list);
00220     static bool _WSCUpdateProvider32                     (DTHandler *, APIHook<void> &, va_list);
00221     static bool _WSCWriteProviderOrder32                 (DTHandler *, APIHook<void> &, va_list);
00222     static bool _WSCEnumNameSpaceProviders32             (DTHandler *, APIHook<void> &, va_list);
00223     static bool _WSCInstallNameSpace32                   (DTHandler *, APIHook<void> &, va_list);
00224     static bool _WSCUnInstallNameSpace32                 (DTHandler *, APIHook<void> &, va_list);
00225     static bool _WSCEnableNSProvider32                   (DTHandler *, APIHook<void> &, va_list);
00226     static bool _WSCWriteNameSpaceOrder32                (DTHandler *, APIHook<void> &, va_list);
00227 #endif // defined(_WIN64)
00228 #endif // (WINVER >= 0x0501)
00229
00230 protected :
00231
00232     virtual bool accept                           (SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen, APIHook<SOCKET> &hook);
00233     virtual bool bind                             (SOCKET s, const struct sockaddr FAR *name, int namelen, APIHook<int> &hook);
00234     virtual bool closesocket                      (SOCKET s, APIHook<int> &hook);
00235     virtual bool connect                          (SOCKET s, const struct sockaddr FAR *name, int namelen, APIHook<int> &hook);
00236     virtual bool getpeername                      (SOCKET s, struct sockaddr FAR *name, int FAR *namelen, APIHook<int> &hook);
00237     virtual bool getsockname                      (SOCKET s, struct sockaddr FAR *name, int FAR *namelen, APIHook<int> &hook);
00238     virtual bool getsockopt                       (SOCKET s, int level, int optname, char FAR *optval, int FAR *optlen, APIHook<int> &hook);
00239     virtual bool htonl                            (unsigned long hostlong, APIHook<unsigned long> &hook);
00240     virtual bool htons                            (unsigned short hostshort, APIHook<unsigned short> &hook);
00241     virtual bool ioctlsocket                      (SOCKET s, long cmd, unsigned long FAR *argp, APIHook<int> &hook);
00242     virtual bool listen                           (SOCKET s, int backlog, APIHook<int> &hook);
00243     virtual bool ntohl                            (unsigned long netlong, APIHook<unsigned long> &hook);
00244     virtual bool ntohs                            (unsigned short netshort, APIHook<unsigned short> &hook);
00245     virtual bool recv                             (SOCKET s, char FAR *buf, int len, int flags, APIHook<int> &hook);
00246     virtual bool recvfrom                         (SOCKET s, char FAR *buf, int len, int flags, struct sockaddr FAR *from, int FAR *fromlen, APIHook<int> &hook);
00247     virtual bool select                           (int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds, const struct timeval FAR *timeout, APIHook<int> &hook);
00248     virtual bool send                             (SOCKET s, const char FAR *buf, int len, int flags, APIHook<int> &hook);
00249     virtual bool sendto                           (SOCKET s, const char FAR *buf, int len, int flags, const struct sockaddr FAR *to, int tolen, APIHook<int> &hook);
00250     virtual bool setsockopt                       (SOCKET s, int level, int optname, const char FAR *optval, int optlen, APIHook<int> &hook);
00251     virtual bool shutdown                         (SOCKET s, int how, APIHook<int> &hook);
00252     virtual bool socket                           (int af, int type, int protocol, APIHook<SOCKET> &hook);
00253     virtual bool WSAAccept                        (SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen, LPCONDITIONPROC lpfnCondition, unsigned long dwCallbackData, APIHook<SOCKET> &hook);
00254     virtual bool WSAAsyncSelect                   (SOCKET s, HWND hWnd, unsigned int wMsg, long lEvent, APIHook<int> &hook);
00255     virtual bool WSACancelBlockingCall            (APIHook<int> &hook);
00256     virtual bool WSACleanup                       (APIHook<int> &hook);
00257     virtual bool WSACloseEvent                    (WSAEVENT hEvent, APIHook<int> &hook);
00258     virtual bool WSAConnect                       (SOCKET s, const struct sockaddr FAR *name, int namelen, LPWSABUF lpCallerData, LPWSABUF lpCalleeData, LPQOS lpSQOS, LPQOS lpGQOS, APIHook<int> &hook);
00259     virtual bool WSACreateEvent                   (APIHook<WSAEVENT> &hook);
00260     virtual bool WSADuplicateSocketA              (SOCKET s, DWORD dwProcessId, LPWSAPROTOCOL_INFOA lpProtocolInfo, APIHook<int> &hook);
00261     virtual bool WSADuplicateSocketW              (SOCKET s, DWORD dwProcessId, LPWSAPROTOCOL_INFOW lpProtocolInfo, APIHook<int> &hook);
00262     virtual bool WSAEnumNetworkEvents             (SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents, APIHook<int> &hook);
00263     virtual bool WSAEnumProtocolsA                (LPINT lpiProtocols, LPWSAPROTOCOL_INFOA lpProtocolBuffer, LPDWORD lpdwBufferLength, APIHook<int> &hook);
00264     virtual bool WSAEnumProtocolsW                (LPINT lpiProtocols, LPWSAPROTOCOL_INFOW lpProtocolBuffer, LPDWORD lpdwBufferLength, APIHook<int> &hook);
00265     virtual bool WSAEventSelect                   (SOCKET s, WSAEVENT hEventObject, long lNetworkEvents, APIHook<int> &hook);
00266     virtual bool WSAGetLastError                  (APIHook<int> &hook);
00267     virtual bool WSAGetOverlappedResult           (SOCKET s, LPWSAOVERLAPPED lpOverlapped, LPDWORD lpcbTransfer, BOOL fWait, unsigned long *lpdwFlags, APIHook<int> &hook);
00268     virtual bool WSAGetQOSByName                  (SOCKET s, LPWSABUF lpQOSName, LPQOS lpQOS, APIHook<int> &hook);
00269     virtual bool WSAHtonl                         (SOCKET s, unsigned long hostlong, unsigned long FAR *lpnetlong, APIHook<int> &hook);
00270     virtual bool WSAHtons                         (SOCKET s, unsigned short hostshort, unsigned short FAR *lpnetshort, APIHook<int> &hook);
00271     virtual bool WSAIoctl                         (SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, APIHook<int> &hook);
00272     virtual bool WSAIsBlocking                    (APIHook<int> &hook);
00273     virtual bool WSAJoinLeaf                      (SOCKET s, const struct sockaddr *name, int namelen, LPWSABUF lpCallerData, LPWSABUF lpCalleeData, LPQOS lpSQOS, LPQOS lpGQOS, DWORD dwFlags, APIHook<SOCKET> &hook);
00274     virtual bool WSANtohl                         (SOCKET s, unsigned long netlong, unsigned long *lphostlong, APIHook<int> &hook);
00275     virtual bool WSANtohs                         (SOCKET s, unsigned short netshort, unsigned short *lphostshort, APIHook<int> &hook);
00276     virtual bool WSARecv                          (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, APIHook<int> &hook);
00277     virtual bool WSARecvDisconnect                (SOCKET s, LPWSABUF lpInboundDisconnectData, APIHook<int> &hook);
00278     virtual bool WSARecvFrom                      (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, struct sockaddr *lpFrom, LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, APIHook<int> &hook);
00279     virtual bool WSAResetEvent                    (WSAEVENT hEvent, APIHook<int> &hook);
00280     virtual bool WSASend                          (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesSent, DWORD dwFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, APIHook<int> &hook);
00281     virtual bool WSASendDisconnect                (SOCKET s, LPWSABUF lpOutboundDisconnectData, APIHook<int> &hook);
00282     virtual bool WSASendTo                        (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesSent, DWORD dwFlags, const struct sockaddr *lpTo, int iTolen, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, APIHook<int> &hook);
00283     virtual bool WSASetBlockingHook               (FARPROC lpBlockFunc, APIHook<FARPROC> &hook);
00284     virtual bool WSASetEvent                      (WSAEVENT hEvent, APIHook<int> &hook);
00285     virtual bool WSASetLastError                  (int iError, APIHook<void> &hook);
00286     virtual bool WSASocketA                       (int af, int type, int protocol, LPWSAPROTOCOL_INFOA lpProtocolInfo, GROUP g, DWORD dwFlags, APIHook<SOCKET> &hook);
00287     virtual bool WSASocketW                       (int af, int type, int protocol, LPWSAPROTOCOL_INFOW lpProtocolInfo, GROUP g, DWORD dwFlags, APIHook<SOCKET> &hook);
00288     virtual bool WSAStartup                       (WORD wVersionRequested, LPWSADATA lpWSAData, APIHook<int> &hook);
00289     virtual bool WSAUnhookBlockingHook            (APIHook<int> &hook);
00290     virtual bool WSAWaitForMultipleEvents         (DWORD cEvents, const WSAEVENT FAR *lphEvents, BOOL fWaitAll, DWORD dwTimeout, BOOL fAlertable, APIHook<DWORD> &hook);
00291     virtual bool gethostbyaddr                    (const char FAR *addr, int len, int type, APIHook<HOSTENT> &hook);
00292     virtual bool gethostbyname                    (const char FAR *name, APIHook<HOSTENT> &hook);
00293     virtual bool gethostname                      (char FAR *name, int namelen, APIHook<int> &hook);
00294     virtual bool getprotobyname                   (const char FAR *name, APIHook<PROTOENT> &hook);
00295     virtual bool getprotobynumber                 (int number, APIHook<PROTOENT> &hook);
00296     virtual bool getservbyname                    (const char FAR *name, const char FAR *proto, APIHook<SERVENT> &hook);
00297     virtual bool getservbyport                    (int port, const char FAR *proto, APIHook<SERVENT> &hook);
00298     virtual bool inet_addr                        (const char FAR *cp, APIHook<unsigned long> &hook);
00299     virtual bool inet_ntoa                        (struct in_addr in, APIHook<char FAR *> &hook);
00300     virtual bool WSAAsyncGetHostByAddr            (HWND hWnd, unsigned int wMsg, const char FAR *addr, int len, int type, char FAR *buf, int buflen, APIHook<HANDLE> &hook);
00301     virtual bool WSAAsyncGetHostByName            (HWND hWnd, unsigned int wMsg, const char FAR *name, char FAR *buf, int buflen, APIHook<HANDLE> &hook);
00302     virtual bool WSAAsyncGetProtoByName           (HWND hWnd, unsigned int wMsg, const char FAR *name, char FAR *buf, int buflen, APIHook<HANDLE> &hook);
00303     virtual bool WSAAsyncGetProtoByNumber         (HWND hWnd, unsigned int wMsg, int number, char FAR *buf, int buflen, APIHook<HANDLE> &hook);
00304     virtual bool WSAAsyncGetServByName            (HWND hWnd, unsigned int wMsg, const char FAR *name, const char FAR *proto, char FAR *buf, int buflen, APIHook<HANDLE> &hook);
00305     virtual bool WSAAsyncGetServByPort            (HWND hWnd, unsigned int wMsg, int port, const char FAR *proto, char FAR *buf, int buflen, APIHook<HANDLE> &hook);
00306     virtual bool WSACancelAsyncRequest            (HANDLE hAsyncTaskHandle, APIHook<int> &hook);
00307     virtual bool WSPAccept                        (SOCKET s, struct sockaddr FAR *addr, LPINT addrlen, LPCONDITIONPROC lpfnCondition, DWORD dwCallbackData, LPINT lpErrno, APIHook<SOCKET> &hook);
00308     virtual bool WSPAsyncSelect                   (SOCKET s, HWND hWnd, unsigned int wMsg, long lEvent, LPINT lpErrno, APIHook<int> &hook);
00309     virtual bool WSPBind                          (SOCKET s, const struct sockaddr FAR *name, int namelen, LPINT lpErrno, APIHook<int> &hook);
00310     virtual bool WSPCancelBlockingCall            (LPINT lpErrno, APIHook<int> &hook);
00311     virtual bool WSPCleanup                       (LPINT lpErrno, APIHook<int> &hook);
00312     virtual bool WSPCloseSocket                   (SOCKET s, LPINT lpErrno, APIHook<int> &hook);
00313     virtual bool WSPConnect                       (SOCKET s, const struct sockaddr FAR *name, int namelen, LPWSABUF lpCallerData, LPWSABUF lpCalleeData, LPQOS lpSQOS, LPQOS lpGQOS, LPINT lpErrno, APIHook<int> &hook);
00314     virtual bool WSPDuplicateSocket               (SOCKET s, DWORD dwProcessId, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPINT lpErrno, APIHook<int> &hook);
00315     virtual bool WSPEnumNetworkEvents             (SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents, LPINT lpErrno, APIHook<int> &hook);
00316     virtual bool WSPEventSelect                   (SOCKET s, WSAEVENT hEventObject, long lNetworkEvents, LPINT lpErrno, APIHook<int> &hook);
00317     virtual bool WSPGetOverlappedResult           (SOCKET s, LPWSAOVERLAPPED lpOverlapped, LPDWORD lpcbTransfer, BOOL fWait, LPDWORD lpdwFlags, LPINT lpErrno, APIHook<BOOL> &hook);
00318     virtual bool WSPGetPeerName                   (SOCKET s, struct sockaddr FAR *name, LPINT namelen, LPINT lpErrno, APIHook<int> &hook);
00319 //  virtual bool _WSPGetProcTable                 ();
00320     virtual bool WSPGetSockName                   (SOCKET s, struct sockaddr FAR *name, LPINT namelen, LPINT lpErrno, APIHook<int> &hook);
00321     virtual bool WSPGetSockOpt                    (SOCKET s, int level, int optname, char FAR *optval, LPINT optlen, LPINT lpErrno, APIHook<int> &hook);
00322     virtual bool WSPGetQOSByName                  (SOCKET s, LPWSABUF lpQOSName, LPQOS lpQOS, LPINT lpErrno, APIHook<BOOL> &hook);
00323     virtual bool WSPIoctl                         (SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSATHREADID lpThreadId, LPINT lpErrno, APIHook<int> &hook);
00324     virtual bool WSPJoinLeaf                      (SOCKET s, const struct sockaddr FAR *name, int namelen, LPWSABUF lpCallerData, LPWSABUF lpCalleeData, LPQOS lpSQOS, LPQOS lpGQOS, DWORD dwFlags, LPINT lpErrno, APIHook<SOCKET> &hook);
00325     virtual bool WSPListen                        (SOCKET s, int backlog, LPINT lpErrno, APIHook<int> &hook);
00326     virtual bool WSPRecv                          (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSATHREADID lpThreadId, LPINT lpErrno, APIHook<int> &hook);
00327     virtual bool WSPRecvDisconnect                (SOCKET s, LPWSABUF lpInboundDisconnectData, LPINT lpErrno, APIHook<int> &hook);
00328     virtual bool WSPRecvFrom                      (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, struct sockaddr FAR *lpFrom, LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSATHREADID lpThreadId, LPINT lpErrno, APIHook<int> &hook);
00329     virtual bool WSPSelect                        (int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds, const struct timeval FAR *timeout, LPINT lpErrno, APIHook<int> &hook);
00330     virtual bool WSPSend                          (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesSent, DWORD dwFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSATHREADID lpThreadId, LPINT lpErrno, APIHook<int> &hook);
00331     virtual bool WSPSendDisconnect                (SOCKET s, LPWSABUF lpOutboundDisconnectData, LPINT lpErrno, APIHook<int> &hook);
00332     virtual bool WSPSendTo                        (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesSent, DWORD dwFlags, const struct sockaddr FAR *lpTo, int iTolen, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSATHREADID lpThreadId, LPINT lpErrno, APIHook<int> &hook);
00333     virtual bool WSPSetSockOpt                    (SOCKET s, int level, int optname, const char FAR *optval, int optlen, LPINT lpErrno, APIHook<int> &hook);
00334     virtual bool WSPShutdown                      (SOCKET s, int how, LPINT lpErrno, APIHook<int> &hook);
00335     virtual bool WSPSocket                        (int af, int type, int protocol, LPWSAPROTOCOL_INFOW lpProtocolInfo, GROUP g, DWORD dwFlags, LPINT lpErrno, APIHook<SOCKET> &hook);
00336     virtual bool WSPStartup                       (WORD wVersionRequested, LPWSPDATA lpWSPData, LPWSAPROTOCOL_INFOW lpProtocolInfo, WSPUPCALLTABLE UpcallTable, LPWSPPROC_TABLE lpProcTable, APIHook<int> &hook);
00337     virtual bool WPUCloseEvent                    (WSAEVENT hEvent, LPINT lpErrno, APIHook<BOOL> &hook);
00338     virtual bool WPUCloseSocketHandle             (SOCKET s, LPINT lpErrno, APIHook<int> &hook);
00339     virtual bool WPUCreateEvent                   (LPINT lpErrno, APIHook<WSAEVENT> &hook);
00340     virtual bool WPUCreateSocketHandle            (DWORD dwCatalogEntryId, DWORD dwContext, LPINT lpErrno, APIHook<SOCKET> &hook);
00341     virtual bool WSCDeinstallProvider             (LPGUID lpProviderId, LPINT lpErrno, APIHook<int> &hook);
00342     virtual bool WSCInstallProvider               (const LPGUID lpProviderId, const LPWSTR lpszProviderDllPath, const LPWSAPROTOCOL_INFOW lpProtocolInfoList, DWORD dwNumberOfEntries, LPINT lpErrno, APIHook<int> &hook);
00343     virtual bool WPUModifyIFSHandle               (DWORD dwCatalogEntryId, SOCKET ProposedHandle, LPINT lpErrno, APIHook<SOCKET> &hook);
00344     virtual bool WPUQueryBlockingCallback         (DWORD dwCatalogEntryId, LPBLOCKINGCALLBACK FAR *lplpfnCallback, LPDWORD lpdwContext, LPINT lpErrno, APIHook<int> &hook);
00345     virtual bool WPUQuerySocketHandleContext      (SOCKET s, LPDWORD lpContext, LPINT lpErrno, APIHook<int> &hook);
00346     virtual bool WPUQueueApc                      (LPWSATHREADID lpThreadId, LPWSAUSERAPC lpfnUserApc, DWORD dwContext, LPINT lpErrno, APIHook<int> &hook);
00347     virtual bool WPUResetEvent                    (WSAEVENT hEvent, LPINT lpErrno, APIHook<BOOL> &hook);
00348     virtual bool WPUSetEvent                      (WSAEVENT hEvent, LPINT lpErrno, APIHook<BOOL> &hook);
00349     virtual bool WPUFDIsSet                       (SOCKET s, FD_SET FAR *set, APIHook<int> &hook);
00350     virtual bool WPUGetProviderPath               (LPGUID lpProviderId, LPWSTR lpszProviderDllPath, LPINT lpProviderDllPathLen, LPINT lpErrno, APIHook<int> &hook);
00351     virtual bool WPUPostMessage                   (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, APIHook<BOOL> &hook);
00352     virtual bool __WSAFDIsSet                     (SOCKET s, FD_SET FAR *set, APIHook<int> &hook);
00353     virtual bool WSCEnumProtocols                 (LPINT lpiProtocols, LPWSAPROTOCOL_INFOW lpProtocolBuffer, LPDWORD lpdwBufferLength, LPINT lpErrno, APIHook<int> &hook);
00354     virtual bool WSAAddressToStringA              (LPSOCKADDR lpsaAddress, DWORD dwAddressLength, LPWSAPROTOCOL_INFOA lpProtocolInfo, OUT LPTSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength, APIHook<INT> &hook);
00355     virtual bool WSAAddressToStringW              (LPSOCKADDR lpsaAddress, DWORD dwAddressLength, LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPTSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength, APIHook<INT> &hook);
00356     virtual bool WSAStringToAddressA              (LPTSTR AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOA lpProtocolInfo, LPSOCKADDR lpAddress, LPINT lpAddressLength, APIHook<INT> &hook);
00357     virtual bool WSAStringToAddressW              (LPTSTR AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPSOCKADDR lpAddress, LPINT lpAddressLength, APIHook<INT> &hook);
00358     virtual bool WSALookupServiceBeginA           (LPWSAQUERYSETA lpqsRestrictions, DWORD dwControlFlags, LPHANDLE lphLookup, APIHook<INT> &hook);
00359     virtual bool WSALookupServiceBeginW           (LPWSAQUERYSETW lpqsRestrictions, DWORD dwControlFlags, LPHANDLE lphLookup, APIHook<INT> &hook);
00360     virtual bool WSALookupServiceNextA            (HANDLE hLookup, DWORD dwControlFlags, LPDWORD lpdwBufferLength, LPWSAQUERYSETA lpqsResults, APIHook<INT> &hook);
00361     virtual bool WSALookupServiceNextW            (HANDLE hLookup, DWORD dwControlFlags, LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults, APIHook<INT> &hook);
00362     virtual bool WSALookupServiceEnd              (HANDLE hLookup, APIHook<INT> &hook);
00363 //  virtual bool WSAGetAddressByNameA             ();
00364 //  virtual bool WSAGetAddressByNameW             ();
00365     virtual bool WSAInstallServiceClassA          (LPWSASERVICECLASSINFOA lpServiceClassInfo, APIHook<INT> &hook);
00366     virtual bool WSAInstallServiceClassW          (LPWSASERVICECLASSINFOW lpServiceClassInfo, APIHook<INT> &hook);
00367     virtual bool WSASetServiceA                   (LPWSAQUERYSETA lpqsRegInfo, WSAESETSERVICEOP essOperation, DWORD dwControlFlags, APIHook<INT> &hook);
00368     virtual bool WSASetServiceW                   (LPWSAQUERYSETW lpqsRegInfo, WSAESETSERVICEOP essOperation, DWORD dwControlFlags, APIHook<INT> &hook);
00369     virtual bool WSARemoveServiceClass            (LPGUID lpServiceClassId, APIHook<INT> &hook);
00370     virtual bool WSAGetServiceClassInfoA          (LPGUID lpProviderId, LPGUID lpServiceClassId, LPDWORD lpdwBufferLength, LPWSASERVICECLASSINFOA lpServiceClassInfo, APIHook<INT> &hook);
00371     virtual bool WSAGetServiceClassInfoW          (LPGUID lpProviderId, LPGUID lpServiceClassId, LPDWORD lpdwBufferLength, LPWSASERVICECLASSINFOW lpServiceClassInfo, APIHook<INT> &hook);
00372     virtual bool WSAEnumNameSpaceProvidersA       (IN OUT LPDWORD lpdwBufferLength, OUT LPWSANAMESPACE_INFOA lpnspBuffer, APIHook<INT> &hook);
00373     virtual bool WSAEnumNameSpaceProvidersW       (IN OUT LPDWORD lpdwBufferLength, OUT LPWSANAMESPACE_INFOW lpnspBuffer, APIHook<INT> &hook);
00374     virtual bool WSAGetServiceClassNameByClassIdA (LPGUID lpServiceClassId, LPSTR lpszServiceClassName, LPDWORD lpdwBufferLength, APIHook<int> &hook);
00375     virtual bool WSAGetServiceClassNameByClassIdW (LPGUID lpServiceClassId, LPWSTR lpszServiceClassName, LPDWORD lpdwBufferLength, APIHook<int> &hook);
00376     virtual bool NSPAddressToString               (LPSOCKADDR lpsaAddress, DWORD dwAddressLength, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPWSTR lpszAddressString, LPDWORD lpdwAddressStringLength, APIHook<int> &hook);
00377     virtual bool NSPStringToAddress               (LPWSTR AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPSOCKADDR lpAddress, LPINT lpAddressLength, APIHook<int> &hook);
00378     virtual bool NSPLookupServiceBegin            (LPGUID lpProviderId, LPWSAQUERYSETW lpqsRestrictions, LPWSASERVICECLASSINFOW lpServiceClassInfo, DWORD dwControlFlags, LPHANDLE lphLookup, APIHook<int> &hook);
00379     virtual bool NSPLookupServiceNext             (HANDLE hLookup, DWORD dwControlFlags, LPDWORD lpdwBufferLength, LPWSAQUERYSET lpqsResults, APIHook<int> &hook);
00380     virtual bool NSPLookupServiceEnd              (HANDLE hLookup, APIHook<int> &hook);
00381     virtual bool NSPGetAddressByName              (LPWSTR lpszServiceInstanceName, LPGUID lpServiceClassId, DWORD dwNameSpace, LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults, DWORD dwResolution, LPWSTR lpszAliasBuffer, LPDWORD lpdwAliasBufferLength, APIHook<int> &hook);
00382     virtual bool NSPInstallServiceClass           (LPGUID lpProviderId, LPWSASERVICECLASSINFOW lpServiceClassInfo, APIHook<int> &hook);
00383     virtual bool NSPSetService                    (LPGUID lpProviderId, LPWSASERVICECLASSINFOW lpServiceClassInfo, LPWSAQUERYSETW lpqsRegInfo, WSAESETSERVICEOP essOperation, DWORD dwControlFlags, APIHook<int> &hook);
00384     virtual bool NSPRemoveServiceClass            (IN LPGUID lpProviderId, IN LPGUID lpServiceClassId, APIHook<int> &hook);
00385     virtual bool NSPGetServiceClassInfo           (IN LPGUID lpProviderId, IN OUT LPDWORD lpdwBufSize, IN OUT LPWSASERVICECLASSINFOW lpServiceClassInfo, APIHook<int> &hook);
00386 //  virtual bool NSPEnumNameSpaceProviders        ();
00387     virtual bool NSPGetServiceClassNameByClassId  (LPGUID lpServiceClassId, LPWSTR lpszServiceClassName, LPDWORD lpdwBufferLength, APIHook<int> &hook);
00388     virtual bool WSCGetProviderPath               (LPGUID lpProviderId, LPWSTR lpszProviderDllPath, LPINT lpProviderDllPathLen, LPINT lpErrno, APIHook<int> &hook);
00389     virtual bool WSCInstallNameSpace              (LPWSTR lpszIdentifier, LPWSTR lpszPathName, DWORD dwNameSpace, DWORD dwVersion, LPGUID lpProviderId, APIHook<int> &hook);
00390     virtual bool WSCUnInstallNameSpace            (LPGUID lpProviderId, APIHook<int> &hook);
00391     virtual bool WSCEnableNSProvider              (LPGUID lpProviderId, BOOL fEnable, APIHook<int> &hook);
00392     virtual bool WSPAddressToString               (LPSOCKADDR lpsaAddress, DWORD dwAddressLength, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPWSTR lpszAddressString, LPDWORD lpdwAddressStringLength, LPINT lpErrno, APIHook<int> &hook);
00393     virtual bool WSPStringToAddress               (LPWSTR AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPSOCKADDR lpAddress,  LPINT lpAddressLength, LPINT lpErrno, APIHook<int> &hook);
00394 #if (WINVER >= 0x0501)
00395     virtual bool WSANSPIoctl                      (IN HANDLE hLookup, IN DWORD dwControlCode, IN LPVOID lpvInBuffer, IN DWORD cbInBuffer, OUT LPVOID lpvOutBuffer, IN DWORD cbOutBuffer, OUT LPDWORD lpcbBytesReturned, IN LPWSACOMPLETION lpCompletion, APIHook<INT> &hook);
00396     virtual bool NSPIoctl                         (HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion, LPWSATHREADID lpThreadId, APIHook<INT> &hook);
00397     virtual bool WPUCompleteOverlappedRequest     (SOCKET s, LPWSAOVERLAPPED lpOverlapped, DWORD dwError, DWORD cbTransferred, LPINT lpErrno, APIHook<int> &hook);
00398     virtual bool WSAProviderConfigChange          (IN OUT LPHANDLE lpNotificationHandle, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, APIHook<int> &hook);
00399     virtual bool WSCWriteProviderOrder            (IN LPDWORD lpwdCatalogEntryId, IN DWORD dwNumberOfEntries, APIHook<int> &hook);
00400     virtual bool WSCWriteNameSpaceOrder           (IN LPGUID lpProviderId, IN DWORD dwNumberOfEntries, APIHook<int> &hook);
00401     virtual bool WSCUpdateProvider                (IN LPGUID lpProviderId, IN const WCHAR FAR *lpszProviderDllPath, IN const LPWSAPROTOCOL_INFOW lpProtocolInfoList, IN DWORD dwNumberOfEntries, OUT LPINT lpErrno, APIHook<int> &hook);
00402     virtual bool getaddrinfo                      (IN const char FAR *NodeName, IN const char FAR *ServiceName, IN const struct addrinfo FAR *Hints, OUT struct addrinfo FAR * FAR *Result, APIHook<INT> &hook);
00403     virtual bool getnameinfo                      (IN const struct sockaddr *SocketAddress, IN socklen_t SocketAddressLength, OUT PCHAR NodeName, IN DWORD NodeBufferSize, OUT PCHAR ServiceName, IN DWORD ServiceBufferSize, IN INT Flags, APIHook<INT> &hook);
00404     virtual bool freeaddrinfo                     (IN OUT struct addrinfo *Free, APIHook<void> &hook);
00405     virtual bool NSPStartup                       (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines, APIHook<INT> &hook);
00406     virtual bool WPUOpenCurrentThread             (OUT LPWSATHREADID lpThreadId, OUT LPINT lpErrno, APIHook<int> &hook);
00407     virtual bool WPUCloseThread                   (IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno, APIHook<int> &hook);
00408 #if defined(_WIN64)
00409     virtual bool WSCEnumProtocols32               (IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength, LPINT lpErrno, APIHook<int> &hook);
00410     virtual bool WSCInstallProvider64_32          (const LPGUID lpProviderId, const LPWSTR lpszProviderDllPath, const LPWSAPROTOCOL_INFOW lpProtocolInfoList, DWORD dwNumberOfEntries, LPINT lpErrno, APIHook<int> &hook);
00411     virtual bool WSCDeinstallProvider32           (LPGUID lpProviderId, LPINT lpErrno, APIHook<int> &hook);
00412     virtual bool WSCGetProviderPath32             (IN LPGUID lpProviderId, OUT WCHAR FAR *lpszProviderDllPath, IN OUT LPINT ProviderDLLPathLen, OUT LPINT lpErrno, APIHook<int> &hook);
00413     virtual bool WSCUpdateProvider32              (IN LPGUID lpProviderId, IN const WCHAR FAR *lpszProviderDllPath, IN const LPWSAPROTOCOL_INFOW lpProtocolInfoList, IN DWORD dwNumberOfEntries, OUT LPINT lpErrno, APIHook<int> &hook);
00414     virtual bool WSCWriteProviderOrder32          (IN LPDWORD lpwdCatalogEntryId, IN DWORD dwNumberOfEntries, APIHook<int> &hook);
00415     virtual bool WSCEnumNameSpaceProviders32      (IN OUT LPDWORD lpdwBufferLength, IN OUT LPWSANAMESPACE_INFOW lpnspBuffer, APIHook<INT> &hook);
00416     virtual bool WSCInstallNameSpace32            (LPWSTR lpszIdentifier, LPWSTR lpszPathName, DWORD dwNameSpace, DWORD dwVersion, LPGUID lpProviderId, APIHook<int> &hook);
00417     virtual bool WSCUnInstallNameSpace32          (LPGUID lpProviderId, APIHook<int> &hook);
00418     virtual bool WSCEnableNSProvider32            (LPGUID lpProviderId, BOOL fEnable, APIHook<int> &hook);
00419     virtual bool WSCWriteNameSpaceOrder32         (IN LPGUID lpProviderId, IN DWORD dwNumberOfEntries, APIHook<int> &hook);
00420 #endif // defined(_WIN64)
00421 #endif // (WINVER >= 0x0501)
00422
00423 public :
00424
00425     bool
00426     dispatch(int notificationCode, void *returnCode, char *LibraryName, bool preAPI, va_list vl);
00427
00428 }; // class DTHandler
00429
00430 #endif
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • Extens

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030   static TCHAR error[64];
00031
00032   switch (verb) {
00033     case MMC_VERB_NONE:
00034     return _T("NONE");
00035     case MMC_VERB_OPEN:
00036     return _T("OPEN");
00037     case MMC_VERB_COPY:
00038     return _T("COPY");
00039     case MMC_VERB_PASTE:
00040     return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042     return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044     return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046     return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048     return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050     return _T("PRINT");
00051     case MMC_VERB_CUT:
00052     return _T("CUT");
00053   default:
00054     wsprintf(error, _T("Unknown verb id %d"), verb);
00055     return error;
00056   }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061         IComponentData *pCompData,
00062         IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064         LPARAM arg,
00065         LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069   TCHAR message[cchMessage] = {0};
00070
00071   if (bComponentData == TRUE)
00072     OutputDebugString(_T("IComponentData::Notify( "));
00073   else
00074     OutputDebugString(_T("IComponent::Notify( "));
00075
00076   wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077   OutputDebugString(message);
00078
00079     switch (event)  {
00080     case MMCN_ACTIVATE:
00081       wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082       break;
00083
00084     case MMCN_ADD_IMAGES:
00085       wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086       break;
00087
00088     case MMCN_BTN_CLICK:
00089       wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090       break;
00091
00092     case MMCN_COLUMN_CLICK:
00093       wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,   param);
00094       break;
00095
00096     case MMCN_COLUMNS_CHANGED:
00097       wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098       break;
00099
00100     case MMCN_CONTEXTHELP:
00101       wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102       break;
00103
00104     case MMCN_CONTEXTMENU:
00105       wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106       break;
00107
00108     case MMCN_CUTORMOVE:
00109       wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110       break;
00111
00112     case MMCN_DBLCLICK:
00113       wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114       break;
00115
00116     case MMCN_DELETE:
00117       wsprintf(message, _T("MMCN_DELETE\n"));
00118       break;
00119
00120     case MMCN_DESELECT_ALL:
00121       wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122       break;
00123
00124     case MMCN_EXPAND:
00125       wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126       break;
00127
00128     case MMCN_EXPANDSYNC:
00129       wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130       break;
00131
00132     case MMCN_FILTERBTN_CLICK:
00133       wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134       break;
00135
00136     case MMCN_FILTER_CHANGE:
00137       wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138       break;
00139
00140     case MMCN_HELP:
00141       wsprintf(message, _T("MMCN_HELP\n"));
00142       break;
00143
00144     case MMCN_INITOCX:
00145       wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146       break;
00147
00148     case MMCN_LISTPAD:
00149       wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150       break;
00151
00152     case MMCN_MENU_BTNCLICK:
00153       wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154       break;
00155
00156     case MMCN_MINIMIZED:
00157       wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158       break;
00159
00160     case MMCN_PASTE:
00161       wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162       break;
00163
00164     case MMCN_PRELOAD:
00165       wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166       break;
00167
00168     case MMCN_PRINT:
00169       wsprintf(message, _T("MMCN_PRINT\n"));
00170       break;
00171
00172     case MMCN_PROPERTY_CHANGE:
00173       wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174       break;
00175
00176     case MMCN_QUERY_PASTE:
00177       wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178       break;
00179
00180     case MMCN_REFRESH:
00181       wsprintf(message, _T("MMCN_REFRESH\n"));
00182       break;
00183
00184     case MMCN_REMOVE_CHILDREN:
00185       wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186       break;
00187
00188     case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192       StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193       break;
00194
00195     case MMCN_RESTORE_VIEW:
00196       wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197       break;
00198
00199     case MMCN_SELECT:
00200       wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201       break;
00202
00203     case MMCN_SHOW:
00204       wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205       break;
00206
00207     case MMCN_SNAPINHELP:
00208       wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209       break;
00210
00211     case MMCN_VIEW_CHANGE:
00212       wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213       break;
00214   }
00215
00216   if (message[0] != 0)
00217     OutputDebugString(message);
00218   else
00219     OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222   return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/HiPerfProvider/Factory.h Source File

  • SysMgmt
  • WMI
  • VC
  • HiPerfProvider

Factory.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////
00002
00003 //
00004
00005 //  Factory.h
00006
00007 //
00008
00009 //  Module: WMI high performance provider sample code
00010
00011 //
00012
00013 //  This is a standard class factory implementation for the CHiPerfProvider
00014
00015 //  object.
00016
00017 //
00018
00019 //
00020
00021 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00022 //
00023 ////////////////////////////////////////////////////////////////////////
00024
00025 //////////////////////////////////////////////////////////////
00026 //
00027 //  CClassFactory
00028 //
00029 //////////////////////////////////////////////////////////////
00030
00031 class CClassFactory : public IClassFactory
00032 {
00033 protected:
00034   long  m_lRef;
00035
00036 public:
00037   CClassFactory() : m_lRef(0) {}
00038
00039   // Standard COM methods
00040   // ====================
00041
00042   STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
00043   STDMETHODIMP_(ULONG) AddRef();
00044     STDMETHODIMP_(ULONG) Release();
00045
00046   // IClassFactory COM interfaces
00047   // ============================
00048
00049   STDMETHODIMP CreateInstance(
00050     /* [in] */ IUnknown* pUnknownOuter,
00051     /* [in] */ REFIID iid,
00052     /* [out] */ LPVOID *ppv);
00053
00054   STDMETHODIMP LockServer(
00055     /* [in] */ BOOL bLock);
00056 };
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/JavaClient/FullSvr/ICallFactory.java Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • JavaClient
  • FullSvr

ICallFactory.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc958.tmp" /nologo /d "D:\mssdk\Samples\COM\Fundamentals\AsyncCalls\JavaClient" "D:\mssdk\Samples\COM\Fundamentals\AsyncCalls\FullSvr\Debug\FullSvr.exe")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package fullsvr;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // VTable-only interface ICallFactory
00019 /** @com.interface(iid=1C733A30-2A1C-11CE-ADE5-00AA0044773D, thread=AUTO) */
00020 public interface ICallFactory extends IUnknown
00021 {
00022   /** @com.method(vtoffset=0, addFlagsVtable=4)
00023       @com.parameters([in,type=PTR] riid, [in,iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] pCtrlUnk, [in,type=PTR] riid2, [out,size=1,type=ARRAY] ppv) */
00024   public void CreateCall(com.ms.com._Guid riid, IUnknown pCtrlUnk, com.ms.com._Guid riid2, IUnknown[] ppv);
00025
00026
00027   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x1c733a30, (short)0x2a1c, (short)0x11ce, (byte)0xad, (byte)0xe5, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x44, (byte)0x77, (byte)0x3d);
00028 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagSYNCHRONIZEMSG Member List

This is the complete list of members for _tagSYNCHRONIZEMSG, including all inherited members.
hWndParent _tagSYNCHRONIZEMSG
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCIncoming/RTCIncomingDlg.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCIncoming

RTCIncomingDlg.h

Go to the documentation of this file.
00001
00002 /******************************************************>
00003  * Copyright (c) 2001 Microsoft Corporation.
00004  * All rights reserved.
00005  *
00006  *
00007  * @Abstract: RTCIncomingDlg.h
00008  * ---------- [ Header Definition File]
00009  *
00010  *
00011  * @Description :
00012  * -------------
00013  * Header file for the Main RTCIncoming Dialog Box
00014  * this Class will contain the state machine transitions
00015  * of the RTC Core Sample, answering calls, receiving events
00016  * disconnected calls, displaying video and auto answer
00017  *
00018  *
00019  ******************************************************/
00020
00021
00022 #ifndef ___RTCINCOMINGDLG_H____
00023 #define ___RTCINCOMINGDLG_H____
00024
00025
00026
00027 #if _MSC_VER > 1000
00028 #pragma once
00029 #endif
00030
00031 #define WM_RTCCORE_EVENT    WM_USER+501
00032
00033 #define RECVVID_LEFT        168
00034 #define RECVVID_TOP         115
00035 #define RECVVID_RIGHT       10
00036 #define RECVVID_BOTTOM      18
00037
00038 #define PREVVID_LEFT        25
00039 #define PREVVID_TOP         115
00040 #define PREVVID_RIGHT       10
00041 #define PREVVID_BOTTOM      18
00042
00043 #define MAX_RTCTIMEOUT      5000
00044
00045
00046 /**********************************************************
00047 //@Class CRTCIncomingDlg Box
00048 //
00049 //@Description
00050 //
00051 //  Contains RTC State Machine and implements
00052 //  IRTCEventNotification and its Callback
00053 //
00054 //
00055 //*********************************************************/
00056
00057 class CRTCIncomingDlg : public CDialog,
00058             public IRTCEventNotification
00059 {
00060 // Construction
00061 public:
00062
00063   CRTCIncomingDlg(CWnd* pParent = NULL);  // standard constructor
00064
00065
00066   //
00067   // Dialog Box Data
00068   //
00069
00070   //{{AFX_DATA(CRTCIncomingDlg)
00071   enum { IDD = IDD_RTCINCOMING_DIALOG };
00072   CButton m_chkAutoAnswer;
00073   CEdit m_ctrlEditStatus;
00074   CButton m_btnDisconnect;
00075   CButton m_btnAnswer;
00076   //}}AFX_DATA
00077
00078
00079   //{{AFX_VIRTUAL(CRTCIncomingDlg)
00080   protected:
00081   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00082   virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
00083   //}}AFX_VIRTUAL
00084
00085
00086   //
00087   // UI Dialog Helpers for Modifying the State of the Buttons
00088   //
00089
00090   void StateAnswerIDC(VARIANT_BOOL fEnable);
00091   void StateDisconnectIDC(VARIANT_BOOL fEnable);
00092
00093
00094   //
00095   // Initialization of the RTC state machine and shutdown
00096   //
00097
00098   HRESULT InitializeRTCApp();
00099   HRESULT ShutdownRTCApp();
00100
00101
00102   //
00103   // Event Source\Callback  Method for Receiving RTC Events
00104   // and posting Messages to Main thread RTCEventThread
00105   //
00106
00107   HRESULT STDMETHODCALLTYPE Event(
00108       RTC_EVENT RTCEvent,
00109             IDispatch * pEvent
00110             );
00111
00112
00113   //
00114   // IUnknown Implementations from IRTCEventNotification Interface
00115   // QI, Addref and Release
00116   //
00117
00118   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
00119                        void **ppvObject);
00120
00121
00122   ULONG STDMETHODCALLTYPE AddRef(void);
00123   ULONG STDMETHODCALLTYPE Release(void);
00124
00125   //
00126   // RTC session state transition enums
00127   //
00128
00129   typedef enum tagSESSION_OPERATION
00130   {
00131
00132     STO_ANSWER,
00133     STO_TERMINATE
00134
00135   } SESSION_OPERATION;
00136
00137
00138   //
00139   // RTC State Transition Helpers
00140   //
00141   //
00142
00143   HRESULT StateCoCreateClient();
00144   HRESULT StateInitClient();
00145   HRESULT StateSinkEvent(LONG lEventMask);
00146   HRESULT StateUnSinkEvent();
00147   HRESULT StateSessionControl(SESSION_OPERATION soType);
00148   HRESULT StateQueryActiveMedia(LONG *plActiveMedia);
00149   HRESULT StateListenMode(RTC_LISTEN_MODE lMode);
00150   HRESULT AddToMediaCapabilities(LONG lMedia, VARIANT_BOOL fPersist);
00151   HRESULT ReleaseStateMachine();
00152
00153   HRESULT SetAutoAnswerMode(VARIANT_BOOL bMode);
00154
00155   //
00156   // Helper Event Parsers
00157   //
00158
00159   HRESULT RTCClientEvent(IDispatch *pIDispatch);
00160   HRESULT RTCSessionStateEvent(IDispatch *pIDispatch);
00161   HRESULT RTCMediaEvent(IDispatch *pIDispatch);
00162
00163
00164 protected:
00165   HICON m_hIcon;
00166
00167   //
00168   // IRTCClient Interface , default interface on
00169   // the RTCClient CoClass
00170   //
00171
00172
00173   IRTCClient   *m_pIRTCClient;
00174
00175   //
00176   // Pointer to Client Session
00177   //
00178
00179   IRTCSession  *m_pIRTCSession;
00180
00181   //
00182   // IConnectionPoint Advise Cookie
00183   //
00184
00185   DWORD         m_dwEventCookie;
00186
00187
00188   //
00189   // Video Capture and Render Video Windows
00190   //
00191
00192   IVideoWindow *m_pIRecvVideo;
00193   IVideoWindow *m_pIPrevVideo;
00194   VARIANT_BOOL  m_bAutoAnswer;
00195
00196   //
00197   // Internal Reference Count
00198   //
00199
00200   LONG          m_dwRefCount;
00201
00202
00203   // Generated message map functions
00204   //{{AFX_MSG(CRTCIncomingDlg)
00205   virtual BOOL OnInitDialog();
00206   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00207   afx_msg void OnPaint();
00208   afx_msg HCURSOR OnQueryDragIcon();
00209   afx_msg void OnAnswer();
00210   afx_msg void OnDisconnect();
00211   afx_msg void OnCheckauto();
00212   afx_msg void OnClose();
00213   //}}AFX_MSG
00214   DECLARE_MESSAGE_MAP()
00215 };
00216
00217
00218 #endif // ___RTCINCOMINGDLG_H____
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Client/BYOTTransaction/StdAfx.h Source File

  • Com
  • Services
  • BYOT
  • Client
  • BYOTTransaction

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__29953AE1_C6B7_11D2_8482_0080C7A03FC6__INCLUDED_)
00006 #define AFX_STDAFX_H__29953AE1_C6B7_11D2_8482_0080C7A03FC6__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__29953AE1_C6B7_11D2_8482_0080C7A03FC6__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Resource_Dispenser/LDisp.Cpp Source File

  • Com
  • Services
  • Resource_Dispenser

LDisp.Cpp

Go to the documentation of this file.
00001 // LDisp.cpp : Implementation of CLDisp
00002 #include "stdafx.h"
00003 #include "Disp1.h"
00004 #include "LDisp.h"
00005
00006 /////////////////////////////////////////////////////////////////////////////
00007 // CLDisp
00008
00009
00010 //Alloc & DeAlloc are the two members of the ILDisp interface, which is what
00011 //a COM+ object would actually use.  The other functions later in this file are
00012 //used by the Resource Dispenser Manager.
00013
00014 //Alloc takes a pointer to a RESID and sets the RESID equal to the id of
00015 //a newly allocated resource.
00016 //We obtain this pointer by calling the AllocResource method provided
00017 //by the Resource Dispenser Manager.
00018 STDMETHODIMP CLDisp::Alloc(long * pJAustin)
00019 {
00020   //if we don't have a valid pointer to the Dispenser Manager, fail.
00021   if(m_pDispMan)
00022   {
00023     *pJAustin = NULL;
00024     //We pass the pointer to JAustin to alloc Resource.
00025     //Once it returns to us, the dispenser manager has set
00026     //JAustin equal to a specific RESID.  We return this to the
00027     //client, and which time the client has a RESID.
00028     return m_pHolder->AllocResource((RESID)1, (RESID *)pJAustin);
00029   }
00030
00031   return E_FAIL;
00032
00033 }
00034
00035 //DeAlloc takes a RESID and deallocates it by calling the FreeResource
00036 //method provided by the dispenser manager.
00037 STDMETHODIMP CLDisp::DeAlloc(long JAustin)
00038 {
00039   //If we don't have a valid pointer to a dispenser manager, fail.
00040  if(m_pDispMan)
00041   {
00042    //call free resource, specifying which resource to free.
00043    return m_pHolder->FreeResource((RESID)JAustin);
00044   }
00045   else return E_FAIL;
00046
00047 }
00048
00049 //CreateResource allocates an integer and returns a RESID uniquely specifying
00050 //that piece of memory back to the resource dispenser manager.
00051 HRESULT CLDisp::CreateResource(const RESTYPID ResTypId,
00052                   RESID * pResId,
00053                   TIMEINSECS* pSecsFreeBeforeDestroy)
00054 {
00055
00056   if(1 != ResTypId)
00057     return E_FAIL;
00058
00059   int * j = new int; //allocate an integer
00060   *pResId = (RESID)j; //convert the pointer to the integer to a RESID.
00061   *pSecsFreeBeforeDestroy = 20;
00062
00063   return S_OK;
00064 }
00065
00066 //RateResource tells the caller (the Resource Dispenser Manager) how easy
00067 //it will be to use the specified resource.  In our
00068 //case we always say that the integer is perfectly suited (100) to any
00069 //caller, since integers are non-transactional resources.
00070 HRESULT CLDisp::RateResource(const RESTYPID ResTypId,
00071               const RESID ResId,
00072                 const BOOL fRequiresTransactionEnlistment,
00073                 RESOURCERATING* pRating)
00074 {
00075   *pRating = 100; //perfectly suited.
00076   return S_OK;
00077 }
00078
00079 //EnlistResource enlists a resource in a transaction.  Our integers are
00080 //non-transactional, so we always return E_FAIL.
00081 HRESULT CLDisp::EnlistResource(const RESID ResId, const TRANSID TransId)
00082 {return E_FAIL;}
00083
00084
00085 //EnlistResource un-enlists a resource from a transaction.  Our integers are
00086 //non-transactional, so we always return E_FAIL.
00087 HRESULT CLDisp::ResetResource(const RESID ResId)
00088 {return S_OK;}
00089
00090 //DestroyResource is called by the Resource Dispenser Manager and tells a
00091 //dispenser to de-allocate a resource.  Our resources are just integers,
00092 //so we just use delete.
00093 HRESULT CLDisp::DestroyResource(const RESID ResId)
00094 {
00095   delete (int *)ResId;
00096   return S_OK;
00097 }
00098
00099 //We don't implement DestroyResourceS.
00100 HRESULT CLDisp::DestroyResourceS(constSRESID ResId)
00101 {return E_FAIL;}
00102
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/CeLibW2k.h Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

CeLibW2k.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1995 - 1999
00006 //
00007 //  File:       celib.h
00008 //
00009 //  Contents:   helper functions
00010 //
00011 //--------------------------------------------------------------------------
00012
00013 #ifndef __CELIB_H__
00014 #define __CELIB_H__
00015
00016
00017 #define CENCODEMAX  (64 * 1024)
00018
00019 // Bitmap manipulation routines.  Fetch or set a bit, given a base and index.
00020 #define GETBIT(pb, i) ((pb)[(i) / 8] & (1 << ((i) % 8)))
00021 #define SETBIT(pb, i) ((pb)[(i) / 8] |= (1 << ((i) % 8)))
00022 #define CLEARBIT(pb, i) ((pb)[(i) / 8] &= ~(1 << ((i) % 8)))
00023
00024 #define BITSTOBYTES(b)  ((int)(((b) + 7) / 8))
00025
00026 // Size of a fixed array:
00027 #define ARRAYSIZE(a)    (sizeof(a)/sizeof((a)[0]))
00028
00029 #define wszCERTENROLLSHAREPATH  L"CertSrv\\CertEnroll"
00030
00031 #define cwcHRESULTSTRING  40
00032
00033 #define SAFE_SUBTRACT_POINTERS(p1, p2) \
00034     (assert(sizeof((*p1)) == sizeof(*(p2))), ((p1) - (p2)))
00035
00036 #define _PrintErrorStr(hr, pszMessage, pwsz) \
00037     _PrintError((hr), (pszMessage))
00038
00039 #define _PrintErrorStr2(hr, pszMessage, pwsz, hr2) \
00040     _PrintError((hr), (pszMessage))
00041
00042 #define _PrintError2(hr, pszMessage, hr2) \
00043     _PrintError((hr), (pszMessage))
00044
00045 #define _PrintError(hr, pszMessage) \
00046       ceERRORPRINTLINE((pszMessage), (hr))
00047
00048
00049 #define _PrintIfErrorStr(hr, pszMessage, pwsz) \
00050     _PrintIfError((hr), (pszMessage))
00051
00052 #define _PrintIfErrorStr2(hr, pszMessage, pwsz, hr2) \
00053     _PrintIfError((hr), (pszMessage))
00054
00055 #define _PrintIfError2(hr, pszMessage, hr2) \
00056     _PrintIfError((hr), (pszMessage))
00057
00058 #define _PrintIfError(hr, pszMessage) \
00059     { \
00060   if (S_OK != (hr)) \
00061   { \
00062       ceERRORPRINTLINE((pszMessage), (hr)); \
00063   } \
00064     }
00065
00066
00067 #define _JumpErrorStr(hr, label, pszMessage, pwsz) \
00068     _JumpError((hr), label, (pszMessage))
00069
00070 #define _JumpError(hr, label, pszMessage) \
00071     { \
00072   ceERRORPRINTLINE((pszMessage), (hr)); \
00073   goto label; \
00074     }
00075
00076
00077 #define _JumpIfErrorStr(hr, label, pszMessage, pwsz) \
00078     _JumpIfError((hr), label, (pszMessage))
00079
00080 #define _JumpIfErrorStr2(hr, label, pszMessage, pwsz, hr2) \
00081     _JumpIfError((hr), label, (pszMessage))
00082
00083 #define _JumpIfError2(hr, label, pszMessage, hr2) \
00084     _JumpIfError((hr), label, (pszMessage))
00085
00086 #define _JumpIfError(hr, label, pszMessage) \
00087     { \
00088   if (S_OK != (hr)) \
00089   { \
00090       ceERRORPRINTLINE((pszMessage), (hr)); \
00091       goto label; \
00092   } \
00093     }
00094
00095
00096 #define ceERRORPRINTLINE(pszMessage, hr) \
00097       ceErrorPrintLine(__FILE__, __LINE__, (pszMessage), (hr))
00098
00099 #define DBGPRINT(a) ceDbgPrintf a
00100
00101 int WINAPIV ceDbgPrintf(BOOL fDebug, char const *pszfmt, ...);
00102
00103
00104 VOID
00105 ceErrorPrintLine(
00106     IN char const *pszFile,
00107     IN DWORD line,
00108     IN char const *pszMessage,
00109     IN HRESULT hr);
00110
00111 HRESULT
00112 ceHLastError(VOID);
00113
00114 HRESULT
00115 ceHError(
00116     IN HRESULT hr);
00117
00118
00119 // Constants chosen to avoid DWORD overflow:
00120
00121 #define CVT_WEEKS (7 * CVT_DAYS)
00122 #define CVT_DAYS  (24 * CVT_HOURS)
00123 #define CVT_HOURS (60 * CVT_MINUTES)
00124 #define CVT_MINUTES (60 * CVT_SECONDS)
00125 #define CVT_SECONDS (1)
00126 #define CVT_BASE  (1000 * 1000 * 10)
00127
00128
00129 enum ENUM_PERIOD
00130 {
00131     ENUM_PERIOD_INVALID = -1,
00132     ENUM_PERIOD_SECONDS = 0,
00133     ENUM_PERIOD_MINUTES,
00134     ENUM_PERIOD_HOURS,
00135     ENUM_PERIOD_DAYS,
00136     ENUM_PERIOD_WEEKS,
00137     ENUM_PERIOD_MONTHS,
00138     ENUM_PERIOD_YEARS
00139 };
00140
00141 HRESULT
00142 ceMakeExprDate(
00143     IN OUT DATE *pDate,
00144     IN LONG lDelta,
00145     IN enum ENUM_PERIOD enumPeriod);
00146
00147 HRESULT
00148 ceTranslatePeriodUnits(
00149     IN WCHAR const *pwszPeriod,
00150     IN LONG lCount,
00151     OUT enum ENUM_PERIOD *penumPeriod,
00152     OUT LONG *plCount);
00153
00154 WCHAR const *
00155 ceGetOIDNameA(
00156     IN char const *pszObjId);
00157
00158 WCHAR const *
00159 ceGetOIDName(
00160     IN WCHAR const *pwszObjId);
00161
00162 BOOL
00163 ceDecodeObject(
00164     IN DWORD dwEncodingType,
00165     IN LPCSTR lpszStructType,
00166     IN BYTE const *pbEncoded,
00167     IN DWORD cbEncoded,
00168     IN BOOL fCoTaskMemAlloc,
00169     OUT VOID **ppvStructInfo,
00170     OUT DWORD *pcbStructInfo);
00171
00172 BOOL
00173 ceEncodeObject(
00174     DWORD dwEncodingType,
00175     IN LPCSTR lpszStructType,
00176     IN VOID const *pvStructInfo,
00177     IN DWORD dwFlags,
00178     IN BOOL fCoTaskMemAlloc,
00179     OUT BYTE **ppbEncoded,
00180     OUT DWORD *pcbEncoded);
00181
00182 WCHAR *
00183 ceDuplicateString(
00184     IN WCHAR const *pwsz);
00185
00186 BOOL
00187 ceConvertWszToSz(
00188     OUT char **ppsz,
00189     IN WCHAR const *pwc,
00190     IN LONG cb);
00191
00192 BOOL
00193 ceConvertWszToBstr(
00194     OUT BSTR *pbstr,
00195     IN WCHAR const *pwc,
00196     IN LONG cb);
00197
00198 BOOL
00199 ceConvertSzToWsz(
00200     OUT WCHAR **ppwsz,
00201     IN char const *pch,
00202     IN LONG cch);
00203
00204 BOOL
00205 ceConvertSzToBstr(
00206     OUT BSTR *pbstr,
00207     IN CHAR const *pch,
00208     IN LONG cch);
00209
00210 VOID
00211 ceFreeBstr(
00212     IN OUT BSTR *pstr);
00213
00214 HRESULT
00215 ceDateToFileTime(
00216     IN DATE const *pDate,
00217     OUT FILETIME *pft);
00218
00219 HRESULT
00220 ceFileTimeToDate(
00221     IN FILETIME const *pft,
00222     OUT DATE *pDate);
00223
00224 HRESULT
00225 ceVerifyObjId(
00226     IN WCHAR const *pwszObjId);
00227
00228 HRESULT
00229 ceVerifyAltNameString(
00230     IN LONG NameChoice,
00231     IN WCHAR const *pwszName);
00232
00233 HRESULT
00234 ceDispatchSetErrorInfo(
00235     IN HRESULT hrError,
00236     IN WCHAR const *pwszDescription,
00237     OPTIONAL IN WCHAR const *pwszProgId,
00238     OPTIONAL IN IID const *piid);
00239
00240 VOID
00241 ceInitErrorMessageText(
00242     IN DWORD idsUnexpected,
00243     IN DWORD idsUnknownErrorCode);  // L"Error %ws %ws"
00244
00245 WCHAR *
00246 ceGetErrorMessageText(
00247     IN HRESULT hr,
00248     IN BOOL fHResultString);
00249
00250 WCHAR const *
00251 ceHResultToString(
00252     IN OUT WCHAR *awchr,
00253     IN HRESULT hr);
00254
00255
00256 #define cwcFILENAMESUFFIXMAX    20
00257 #define cwcSUFFIXMAX  (1 + 5 + 1) // five decimal digits plus parentheses
00258
00259 #define wszFCSAPARM_SERVERDNSNAME L"%1"
00260 #define wszFCSAPARM_SERVERSHORTNAME L"%2"
00261 #define wszFCSAPARM_SANITIZEDCANAME L"%3"
00262 #define wszFCSAPARM_CERTFILENAMESUFFIX  L"%4"
00263 #define wszFCSAPARM_DOMAINDN    L"%5"
00264 #define wszFCSAPARM_CONFIGDN    L"%6"
00265 #define wszFCSAPARM_SANITIZEDCANAMEHASH L"%7"
00266 #define wszFCSAPARM_CRLFILENAMESUFFIX L"%8"
00267 #define wszFCSAPARM_CRLDELTAFILENAMESUFFIX L"%9"
00268 #define wszFCSAPARM_DSCRLATTRIBUTE  L"%10"
00269 #define wszFCSAPARM_DSCACERTATTRIBUTE L"%11"
00270
00271
00272 HRESULT
00273 ceFormatCertsrvStringArray(
00274     IN BOOL fURL,
00275     IN LPCWSTR pwszServerName_p1_2,
00276     IN LPCWSTR pwszSanitizedName_p3_7,
00277     IN DWORD   iCert_p4,
00278     IN LPCWSTR pwszDomainDN_p5,
00279     IN LPCWSTR pwszConfigDN_p6,
00280     IN DWORD   iCRL_p8,
00281     IN BOOL    fDeltaCRL_p9,
00282     IN BOOL    fDSAttrib_p10_11,
00283     IN DWORD   cStrings,
00284     IN LPCWSTR *apwszStringsIn,
00285     OUT LPWSTR *apwszStringsOut);
00286
00287 HRESULT
00288 ceInternetCanonicalizeUrl(
00289     IN WCHAR const *pwszIn,
00290     OUT WCHAR **ppwszOut);
00291
00292 int
00293 ceWtoI(
00294     IN WCHAR const *pwszDigitString,
00295     OUT BOOL *pfValid);
00296
00297 #endif // __CELIB_H__
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/Resource.h Source File

  • Com
  • Fundamentals
  • SimpCntr

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // App Studio generated include file.
00003 // Used by SIMPCNTR.RC
00004 //
00005 #define IDM_OPEN                        102
00006 #define IDM_SAVE                        103
00007 #define IDM_SAVEAS                      104
00008 #define IDM_PRINT                       105
00009 #define IDM_EXIT                        106
00010 #define IDM_UNDO                        107
00011 #define IDM_CUT                         108
00012 #define IDM_COPY                        109
00013 #define IDM_PASTE                       110
00014 #define ID_EDIT_INSERTOBJECT            111
00015 #define IDM_INSERTOBJECT                111
00016 #define IDM_NEW                         112
00017
00018 // Next default values for new objects
00019 //
00020 #ifdef APSTUDIO_INVOKED
00021 #ifndef APSTUDIO_READONLY_SYMBOLS
00022
00023 #define _APS_NEXT_RESOURCE_VALUE        101
00024 #define _APS_NEXT_COMMAND_VALUE         113
00025 #define _APS_NEXT_CONTROL_VALUE         1000
00026 #define _APS_NEXT_SYMED_VALUE           101
00027 #endif
00028 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllClien/DllClien.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllClien

DllClien.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DLLCLIEN.H
00003
00004   Summary:   Include file for the DLLCLIEN code sample application.
00005              In addition to class definitions, this DLLCLIEN.H file
00006              contains definitions of the application's menu, string,
00007              and other resource IDs.
00008
00009              Based largely on the DLLUSER.EXE source code, this include
00010              file adds resource IDs for a set of new menus for exercising
00011              the several COM Components manipulated in this code sample
00012              as a COM Client of those components housed the the DLLSERVE
00013              server.
00014
00015              For a comprehensive tutorial code tour of DLLCLIEN's
00016              contents and offerings see the tutorial DLLCLIEN.HTM file.
00017              For more specific technical details on the internal workings
00018              see the comments dispersed throughout the DLLCLIEN source code.
00019
00020   Classes:   CMainWindow
00021
00022   Functions: WinMain
00023
00024   Origin:    9-20-95: atrent - Editor-inheritance from the DLLUSER source.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(DLLCLIEN_H)
00042 #define DLLCLIEN_H
00043
00044 #ifdef __cplusplus
00045
00046 extern CMsgLog* g_pMsgLog;
00047
00048 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00049   Class:    CMainWindow
00050
00051   Summary:  Class to encapsulate the application's main window, menu, and
00052             message dispatching behavior.
00053
00054   Methods:  CMainWindow
00055               Constructor.
00056             InitInstance
00057               Creates a new instance of the main window.
00058 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00059 class CMainWindow: public CVirWindow
00060 {
00061 public:
00062   CMainWindow();
00063   ~CMainWindow();
00064   BOOL InitInstance(HINSTANCE, int);
00065
00066   TCHAR m_szFileName[MAX_PATH];
00067   CMsgBox*  m_pMsgBox;
00068   CMsgLog*  m_pMsgLog;
00069
00070   // A method for getting an interface on a COM object.
00071   BOOL GetInterface(IUnknown* pObj, REFIID riid, PPVOID ppv);
00072   // Some member variables to store pointers to Car-like COM Objects.
00073   // We save pointers to each COM objects controlling IUnknown.
00074   IUnknown* m_pCar;
00075   IUnknown* m_pUtilityCar;
00076   IUnknown* m_pCruiseCar;
00077   IUnknown* m_pUtilityCruiseCar;
00078   ISample*  m_pCarSample;
00079
00080 protected:
00081   LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00082
00083 private:
00084   LRESULT DoMenu(WPARAM wParam, LPARAM lParam);
00085
00086   WORD m_wWidth;
00087   WORD m_wHeight;
00088   TCHAR m_szHelpFile[MAX_PATH];
00089   TCHAR m_szFileTitle[MAX_PATH];
00090   TEXTMETRIC m_tm;
00091   OPENFILENAME m_ofnFile;
00092 };
00093
00094 #endif // __cplusplus
00095
00096 // Window Class String Macros.
00097 #define MAIN_WINDOW_TITLE_STR       "DLLCLIEN: Tutorial Code Sample"
00098 #define MAIN_WINDOW_CLASS_NAME_STR  "DLLCLIENWindow"
00099 #define MAIN_WINDOW_CLASS_MENU_STR  "DLLCLIENMenu"
00100
00101 // File Name String Macros.
00102 #define SERVER_TUTFILE_STR          "dllserve.htm"
00103 #define REGISTER_TUTFILE_STR        "register.htm"
00104
00105 // OpenFile-related String Macros.
00106 #define OFN_DEFAULTFILES_STR "All Files (*.*)\0*.*\0"
00107 #define OFN_DEFAULTTITLE_STR "Open File"
00108
00109 // File Menu Command Identifiers.
00110 #define IDM_FILE_EXIT               1000
00111
00112 // Car Menu Command Identifiers.
00113 #define IDM_CAR_CREATE              1100
00114 #define IDM_CAR_RELEASE             1101
00115 #define IDM_CAR_SHIFT               1102
00116 #define IDM_CAR_CLUTCH              1103
00117 #define IDM_CAR_SPEED               1104
00118 #define IDM_CAR_STEER               1105
00119
00120 // UtilityCar Menu Command Identifiers.
00121 #define IDM_UCAR_CREATE             1200
00122 #define IDM_UCAR_RELEASE            1201
00123 #define IDM_UCAR_SHIFT              1202
00124 #define IDM_UCAR_CLUTCH             1203
00125 #define IDM_UCAR_SPEED              1204
00126 #define IDM_UCAR_STEER              1205
00127 #define IDM_UCAR_OFFROAD            1206
00128 #define IDM_UCAR_WINCH              1207
00129
00130 // CruiseCar Menu Command Identifiers.
00131 #define IDM_CCAR_CREATE             1300
00132 #define IDM_CCAR_RELEASE            1301
00133 #define IDM_CCAR_SHIFT              1302
00134 #define IDM_CCAR_CLUTCH             1303
00135 #define IDM_CCAR_SPEED              1304
00136 #define IDM_CCAR_STEER              1305
00137 #define IDM_CCAR_ENGAGE             1306
00138 #define IDM_CCAR_ADJUST             1307
00139
00140 // UtilityCruiseCar Menu Command Identifiers.
00141 #define IDM_UCRU_CREATE             1400
00142 #define IDM_UCRU_RELEASE            1401
00143 #define IDM_UCRU_SHIFT              1402
00144 #define IDM_UCRU_CLUTCH             1403
00145 #define IDM_UCRU_SPEED              1404
00146 #define IDM_UCRU_STEER              1405
00147 #define IDM_UCRU_ENGAGE             1406
00148 #define IDM_UCRU_ADJUST             1407
00149 #define IDM_UCRU_OFFROAD            1408
00150 #define IDM_UCRU_WINCH              1409
00151
00152 // Log Menu Command Identifiers.
00153 #define IDM_LOG_LOGCLEAR            1890
00154 #define IDM_LOG_LOGGING             1891
00155 #define IDM_LOG_COPYCLIP            1892
00156
00157 // Help Menu Command Identifiers.
00158 #define IDM_HELP_CONTENTS           1900
00159 #define IDM_HELP_TUTORIAL           1901
00160 #define IDM_HELP_TUTSERVER          1902
00161 #define IDM_HELP_TUTREGISTER        1903
00162 #define IDM_HELP_READSOURCE         1904
00163 #define IDM_HELP_ABOUT              1905
00164 #define IDM_HELP_ABOUTSERVER        1906
00165
00166 // Error-related String Identifiers.
00167 #define IDS_COMINITFAILED           2000
00168 #define IDS_APPINITFAILED           2001
00169 #define IDS_OUTOFMEMORY             2002
00170 #define IDS_NOUNICODE               2003
00171 #define IDS_NOSERVER                2004
00172
00173 #define IDS_ASSERT_FAIL             2200
00174
00175 // Notice-related String Identifiers.
00176 #define IDS_NOTIMPLEMENTED          2301
00177
00178 // Log Message String Identifiers.
00179 #define IDS_START_MESSAGE_LOG       2400
00180
00181 #endif
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/nullmdm.cpp Source File

  • Web
  • NetMeeting
  • PlugTransport

nullmdm.cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     PLUGTRANSPORT.EXE
00003 //  File:       NULLMDM.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016 #include "precomp.h"
00017
00018
00019 //*******************
00020 //GLOBALS
00021 //*******************
00022
00023 BYTE    g_szNULLMStartString[] = "NULLMDM";
00024 ULONG   g_nConnID = 0;
00025
00026
00027 //**********************************
00028 //
00029 // CLASS CPSTN
00030 //
00031 //**********************************
00032
00033 //****************************************************************************
00034 //
00035 //    FUNCTION:   CPSTN::CPSTN()
00036 //
00037 //    PURPOSE:    Construction
00038
00039 //    COMMENTS:
00040 //
00041 //
00042 //****************************************************************************
00043
00044 CPSTN::CPSTN()
00045 {
00046    m_pNullModem = NULL;
00047    m_szComPortName[0] = '\0';
00048 }
00049
00050
00051 //****************************************************************************
00052 //
00053 //    FUNCTION:   CPSTN::~CPSTN()
00054 //
00055 //    PURPOSE:    Destruction
00056
00057 //    COMMENTS:
00058 //
00059 //
00060 //****************************************************************************
00061
00062 CPSTN::~CPSTN()
00063 {}
00064
00065
00066 //****************************************************************************
00067 //
00068 //    FUNCTION:   HRESULT CPSTN::CreateComPort(UINT nTransportID, LPSTR pszComPort)
00069 //
00070 //    PURPOSE:    Prepares the COM port specified by pszComPort to use it
00071
00072 //    COMMENTS:
00073 //
00074 //
00075 //****************************************************************************
00076
00077 HRESULT CPSTN::CreateComPort(UINT nTransportID, LPTSTR pszComPort)
00078 {
00079     TPhysicalError rc;
00080
00081     m_pNullModem = new CNullModem();
00082     if (NULL == m_pNullModem)
00083     {
00084         return E_OUTOFMEMORY;
00085     }
00086
00087     lstrcpyn(m_szComPortName, pszComPort, COMPORTNAMEMAXLENGTH);
00088
00089     rc = m_pNullModem->TPhysInitialize(nTransportID);
00090     if (TPHYS_SUCCESS != rc)
00091     {
00092         return E_FAIL;
00093     }
00094
00095     rc = m_pNullModem->TPhysConnectRequest(m_szComPortName);
00096     if (TPHYS_SUCCESS != rc)
00097     {
00098         return E_FAIL;
00099     }
00100
00101     return S_OK;
00102 }
00103
00104
00105 //****************************************************************************
00106 //
00107 //    FUNCTION:   HRESULT CPSTN::CloseComPort()
00108 //
00109 //    PURPOSE:    Closes an open COM port
00110
00111 //    COMMENTS:
00112 //
00113 //
00114 //****************************************************************************
00115
00116 HRESULT CPSTN::CloseComPort()
00117 {
00118     if (NULL != m_pNullModem)
00119     {
00120         TPhysicalError rc;
00121         HRESULT hr = S_OK;
00122
00123         rc = m_pNullModem->TPhysDisconnect();
00124         if (TPHYS_SUCCESS != rc)
00125             hr = E_FAIL;
00126
00127         rc = m_pNullModem->TPhysTerminate();
00128         if (TPHYS_SUCCESS != rc)
00129             hr = E_FAIL;
00130
00131         delete m_pNullModem;
00132         m_pNullModem = NULL;
00133
00134         return hr;
00135     }
00136     // Port already closed or never opened
00137     return S_FALSE;
00138 }
00139
00140
00141 //****************************************************************************
00142 //
00143 //    FUNCTION:   HANDLE CPSTN::GetCommLink()
00144 //
00145 //    PURPOSE:    Get the handle to the COM link
00146
00147 //    COMMENTS:
00148 //
00149 //
00150 //****************************************************************************
00151
00152 HANDLE CPSTN::GetCommLink()
00153 {
00154     if (m_pNullModem)
00155         return m_pNullModem->GetCommLink();
00156
00157     return NULL;
00158 }
00159
00160
00161 //**********************************
00162 //
00163 // CLASS CNullMdm
00164 //
00165 //**********************************
00166
00167 //****************************************************************************
00168 //
00169 //    FUNCTION:   CNullModem::CNullModem(void)
00170 //
00171 //    PURPOSE:    Construction
00172
00173 //    COMMENTS:
00174 //
00175 //
00176 //****************************************************************************
00177
00178 CNullModem::CNullModem(void)
00179 :
00180     m_fInitialized(FALSE),
00181     m_nTransportID(0),
00182     m_nConnectionID(0),
00183     m_hevtOverlapped(NULL),
00184     m_dwEventMask(0),
00185     m_fCommPortInUse(FALSE)
00186 {
00187     ::ZeroMemory(&m_Line, sizeof(m_Line));
00188     ::ZeroMemory(&m_Overlapped, sizeof(m_Overlapped));
00189     ::ZeroMemory(&m_DefaultTimeouts, sizeof(m_DefaultTimeouts));
00190
00191     m_hevtOverlapped = ::CreateEvent(NULL, TRUE, FALSE, NULL); // manual reset
00192     ASSERT(NULL != m_hevtOverlapped);
00193
00194 }
00195
00196
00197 //****************************************************************************
00198 //
00199 //    FUNCTION:   CNullModem::~CNullModem(void)
00200 //
00201 //    PURPOSE:    Destruction
00202
00203 //    COMMENTS:
00204 //
00205 //
00206 //****************************************************************************
00207
00208 CNullModem::~CNullModem(void)
00209 {
00210     if (m_fInitialized)
00211     {
00212         TPhysTerminate();
00213     }
00214
00215     if (NULL != m_hevtOverlapped)
00216     {
00217         ::CloseHandle(m_hevtOverlapped);
00218     }
00219 }
00220
00221
00222 //****************************************************************************
00223 //
00224 //    FUNCTION:   TPhysicalError CNullModem::TPhysInitialize(UINT nTransportID)
00225 //
00226 //    PURPOSE:    Initialize the object
00227
00228 //    COMMENTS:
00229 //
00230 //
00231 //****************************************************************************
00232
00233 TPhysicalError CNullModem::TPhysInitialize(UINT nTransportID)
00234 {
00235     TPhysicalError rc = TPHYS_SUCCESS;
00236
00237     //
00238     // If we have already been initialized then this is a reinit call from
00239     // the node controller so just do nothing.
00240     //
00241     if (! m_fInitialized)
00242     {
00243         //
00244         // zero out the SESSION INFO structure
00245         //
00246         ::ZeroMemory(&m_Line, sizeof(m_Line));
00247
00248         //
00249         // Store control information
00250         //
00251         m_nTransportID  = nTransportID;
00252         m_fInitialized  = TRUE;
00253         m_nConnectionID = ++g_nConnID;
00254
00255         ASSERT(TPHYS_SUCCESS == rc);
00256     }
00257
00258     return rc;
00259 }
00260
00261
00262 //****************************************************************************
00263 //
00264 //    FUNCTION:   TPhysicalError CNullModem::TPhysTerminate(void)
00265 //
00266 //    PURPOSE:
00267
00268 //    COMMENTS:
00269 //
00270 //
00271 //****************************************************************************
00272
00273 TPhysicalError CNullModem::TPhysTerminate(void)
00274 {
00275     if (! m_fInitialized)
00276     {
00277         return(TPHYS_RESULT_NOT_INITIALIZED);
00278     }
00279
00280     m_nTransportID = 0;
00281     m_fInitialized = FALSE;
00282
00283     return(TPHYS_SUCCESS);
00284 }
00285
00286
00287 //****************************************************************************
00288 //
00289 //    FUNCTION:   TPhysicalError CNullModem::TPhysConnectRequest(LPTSTR pszComPort)
00290 //
00291 //    PURPOSE:    It checks the port, opens it ans initliazes it
00292
00293 //    COMMENTS:
00294 //
00295 //
00296 //****************************************************************************
00297
00298 TPhysicalError CNullModem::TPhysConnectRequest(LPTSTR pszComPort)
00299 {
00300     TPhysicalError  rc          = TPHYS_SUCCESS;
00301     HANDLE          hCommLink   = INVALID_HANDLE_VALUE;
00302     DCB             dcb;
00303     DWORD           dwWritten   = 0;
00304
00305     if (! m_fInitialized)
00306     {
00307         // NULL MODEM OOB not initialized
00308         return TPHYS_RESULT_NOT_INITIALIZED;
00309     }
00310
00311     // Select a comm port for the call.
00312     if (CALL_STATE_IDLE == m_Line.eCallState || CALL_STATE_DROP == m_Line.eCallState)
00313     {
00314         // Also prime our local copy of the conninfo structure for use in callbacks
00315         m_Line.connInfo.resultCode   = 0;
00316         m_Line.connInfo.connectionID = m_nConnectionID;
00317     }
00318     else
00319     {
00320         // No comm port is available
00321         return TPHYS_RESULT_COMM_PORT_BUSY;
00322     }
00323
00324     // Only alow one at at time
00325     if (m_fCommPortInUse)
00326     {
00327         // Waiting for a previous null mode connection
00328         rc = TPHYS_RESULT_WAITING_FOR_CONNECTION;
00329         goto bail;
00330     }
00331     m_fCommPortInUse = true;
00332
00333     // Check the name of the comm port. Comm port names MUST start with 'com'.
00334     if (_tcsnicmp(TEXT("com"), pszComPort, 3) != 0)
00335     {
00336         rc = TPHYS_RESULT_INVALID_ADDRESS;
00337         goto bail;
00338     }
00339
00340     // Open the comm port
00341     hCommLink = ::CreateFile(pszComPort,
00342                              GENERIC_READ | GENERIC_WRITE,
00343                              0,                    // exclusive access
00344                              NULL,                 // no security attrs
00345                              OPEN_EXISTING,
00346                              FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, // overlapped I/O
00347                              NULL );
00348     if (hCommLink == INVALID_HANDLE_VALUE)
00349     {
00350         // TPhysConnectRequest: CreateFile failed
00351         rc = TPHYS_RESULT_COMM_PORT_BUSY;
00352         goto bail;
00353     }
00354
00355     m_Line.hCommLink = hCommLink;
00356
00357     // remember the default timeouts
00358     ::GetCommTimeouts(hCommLink, &m_DefaultTimeouts);
00359
00360     // Let the other side know that we are trying to connect
00361     if (! ::EscapeCommFunction(hCommLink, SETDTR))
00362     {
00363         // TPhysConnectRequest: Unable to Set DTR
00364     }
00365
00366     ::ZeroMemory(&m_Overlapped, sizeof(m_Overlapped));
00367     m_Overlapped.hEvent = m_hevtOverlapped;
00368     m_dwEventMask = 0;
00369
00370     ::ResetEvent(m_hevtOverlapped);
00371
00372     if (! ::WriteFile(hCommLink, g_szNULLMStartString, sizeof(g_szNULLMStartString), &dwWritten, &m_Overlapped))
00373     {
00374         DWORD dwErr = ::GetLastError();
00375         if (ERROR_IO_PENDING != dwErr)
00376         {
00377             // TPhysConnectRequest: WriteFile failed
00378             ::ResetEvent(m_hevtOverlapped);
00379             rc = TPHYS_RESULT_COMM_PORT_BUSY;
00380             goto bail;
00381         }
00382         else
00383         {
00384             DWORD dwWait = ::WaitForSingleObject(m_hevtOverlapped, INFINITE);
00385             BOOL fRet = ::GetOverlappedResult(hCommLink, &m_Overlapped, &dwWritten, TRUE);
00386             ASSERT(fRet);
00387             ASSERT(dwWritten == sizeof(g_szNULLMStartString));
00388         }
00389     }
00390     else
00391     {
00392         ASSERT(dwWritten == sizeof(g_szNULLMStartString));
00393     }
00394
00395     ::ResetEvent(m_hevtOverlapped);
00396
00397     // Get the default dcb
00398     ::ZeroMemory(&dcb, sizeof(dcb));
00399     dcb.DCBlength = sizeof(DCB);
00400
00401     ::GetCommState(hCommLink, &dcb);
00402
00403     // Set our state so we can get notification in the comm port
00404     dcb.BaudRate = COMM_PORT_BAUD_RATE;
00405     dcb.StopBits = COMM_PORT_STOP_BITS;
00406     dcb.ByteSize = COMM_PORT_DATA_BITS;
00407     dcb.fBinary = 1;                        // binary mode, no EOF check
00408     dcb.fParity = 0;                        // enable parity checking
00409     dcb.fOutxCtsFlow = 1;                   // CTS output flow control
00410     dcb.fOutxDsrFlow = 0;                   // DSR output flow control
00411     dcb.fDtrControl = DTR_CONTROL_ENABLE;   // DTR flow control type
00412     dcb.fDsrSensitivity = 0;                // DSR sensitivity
00413     dcb.fTXContinueOnXoff = 0;              // XOFF continues Tx
00414     dcb.fOutX = 0;                          // XON/XOFF out flow control
00415     dcb.fInX = 0;                           // XON/XOFF in flow control
00416     dcb.fErrorChar = 0;                     // enable error replacement
00417     dcb.fNull = 0;                          // enable null stripping
00418     dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;// RTS flow control
00419     dcb.XonLim = 0;                         // transmit XON threshold
00420     dcb.XoffLim = 0;                        // transmit XOFF threshold
00421     dcb.fErrorChar = 0;                     // enable error replacement
00422     dcb.fNull = 0;                          // enable null stripping
00423     dcb.fAbortOnError = 0;                  // abort reads/writes on error
00424     dcb.Parity = 0;
00425
00426     ::SetCommState(hCommLink, &dcb);
00427
00428     ::PurgeComm(hCommLink, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR);
00429
00430     m_Line.eCallState = CALL_STATE_MAKE;
00431     m_Line.hevtCall = m_hevtOverlapped;
00432     m_Line.pstnHandle = (PHYSICAL_HANDLE) hCommLink;
00433     m_Line.fCaller = TRUE;
00434
00435     if (! ::SetCommMask(hCommLink,
00436                 EV_RXCHAR |         // Any Character received
00437                 EV_CTS |            // CTS changed state
00438                 EV_DSR |            // DSR changed state
00439                 EV_RLSD|            // RLSD changed state
00440                 EV_RXFLAG))         // Certain character
00441     {
00442         // TPhysConnectRequest:  Unable to SetCommMask
00443     }
00444
00445     ::ZeroMemory(&m_Overlapped, sizeof(m_Overlapped));
00446     m_Overlapped.hEvent = m_hevtOverlapped;
00447     m_dwEventMask = 0;
00448
00449     ::ResetEvent(m_hevtOverlapped);
00450
00451     if (! ::WaitCommEvent(hCommLink, &m_dwEventMask, &m_Overlapped))
00452     {
00453         DWORD dwErr = ::GetLastError();
00454         if (ERROR_IO_PENDING != dwErr)
00455         {
00456             // TPhysConnectRequest: WaitCommEvent failed
00457             m_fCommPortInUse = FALSE;
00458         }
00459     }
00460
00461     DoConnect();
00462
00463 bail:
00464
00465     return(rc);
00466 }
00467
00468
00469 //****************************************************************************
00470 //
00471 //    FUNCTION:   TPhysicalError CNullModem::TPhysDisconnect(void)
00472 //
00473 //    PURPOSE:    Closes the com port. Wrapper around DropCall that does the work
00474
00475 //    COMMENTS:
00476 //
00477 //
00478 //****************************************************************************
00479
00480 TPhysicalError CNullModem::TPhysDisconnect(void)
00481 {
00482     if (! m_fInitialized)
00483     {
00484         // Not initialized
00485         return(TPHYS_RESULT_NOT_INITIALIZED);
00486     }
00487
00488     // close the com port
00489     DropCall();
00490
00491     return(TPHYS_SUCCESS);
00492 }
00493
00494
00495 //****************************************************************************
00496 //
00497 //    FUNCTION:   void CNullModem::DropCall(void)
00498 //
00499 //    PURPOSE:    Closes the com port
00500
00501 //    COMMENTS:
00502 //
00503 //
00504 //****************************************************************************
00505
00506 void CNullModem::DropCall(void)
00507 {
00508     // close the device handle
00509     if (NULL != m_Line.hCommLink)
00510     {
00511         CALL_STATE eCallState = m_Line.eCallState;
00512         m_Line.eCallState = CALL_STATE_IDLE;
00513
00514         // If this call is connected it is not using the comm thread
00515         if (eCallState != CALL_STATE_CONNECTED)
00516         {
00517             m_fCommPortInUse = FALSE;
00518         }
00519
00520         // restore comm timeouts
00521         SetCommTimeouts(m_Line.hCommLink, &m_DefaultTimeouts);
00522
00523         ::CloseHandle(m_Line.hCommLink);
00524         m_Line.hCommLink = NULL;
00525     }
00526 }
00527
00528
00529 //****************************************************************************
00530 //
00531 //    FUNCTION:   void CNullModem::SetConnectedPort(void)
00532 //
00533 //    PURPOSE:    Configures the communication device according to the
00534 //                specifications in the device-control block (DCB structure)
00535
00536 //    COMMENTS:
00537 //
00538 //
00539 //****************************************************************************
00540
00541 void CNullModem::SetConnectedPort(void)
00542 {
00543     DCB     dcb;
00544
00545     ::ZeroMemory(&dcb, sizeof(dcb));
00546     dcb.DCBlength = sizeof(DCB);
00547
00548     //  Set comm mask and state
00549     ::SetCommMask(m_Line.hCommLink, 0);    // RLSD changed state
00550
00551     ::GetCommState(m_Line.hCommLink, &dcb);
00552     dcb.BaudRate = COMM_PORT_BAUD_RATE;
00553     dcb.StopBits = COMM_PORT_STOP_BITS;
00554     dcb.ByteSize = COMM_PORT_DATA_BITS;
00555     dcb.fBinary = 1;           // binary mode, no EOF check
00556     dcb.fParity = 0;           // enable parity checking
00557     dcb.fOutxDsrFlow = 0;      // DSR output flow control
00558     dcb.fDsrSensitivity = 0;   // DSR sensitivity
00559     dcb.fTXContinueOnXoff = 0; // XOFF continues Tx
00560     dcb.fOutX = 0;             // XON/XOFF out flow control
00561     dcb.fInX = 0;              // XON/XOFF in flow control
00562     dcb.fErrorChar = 0;        // enable error replacement
00563     dcb.fNull = 0;             // enable null stripping
00564     dcb.XonLim = 0;            // transmit XON threshold
00565     dcb.XoffLim = 0;           // transmit XOFF threshold
00566     dcb.Parity = 0;
00567
00568     ::SetCommState(m_Line.hCommLink, &dcb);
00569 }
00570
00571
00572 //****************************************************************************
00573 //
00574 //    FUNCTION:   BOOL CNullModem::WaitForConnection(void)
00575 //
00576 //    PURPOSE:    Wait for connection and handle the notification
00577
00578 //    COMMENTS:
00579 //
00580 //
00581 //****************************************************************************
00582
00583 BOOL CNullModem::WaitForConnection(void)
00584 {
00585     BOOL fRet = FALSE;
00586
00587     while (true)
00588     {
00589         DWORD dwWait = ::WaitForSingleObject(m_hevtOverlapped, COMM_PORT_TIMEOUT);
00590
00591         ::ResetEvent(m_hevtOverlapped);
00592
00593         if (dwWait == WAIT_ABANDONED || dwWait == WAIT_TIMEOUT || dwWait == WAIT_FAILED)
00594         {
00595             DropCall();
00596             m_fCommPortInUse = FALSE;
00597             // WaitForConnection: Unable to WaitCommEvent
00598             goto Failure;
00599         }
00600
00601         ASSERT(m_hevtOverlapped == m_Line.hevtCall);
00602         if (CALL_STATE_MAKE != m_Line.eCallState && CALL_STATE_ANSWER != m_Line.eCallState)
00603         {
00604             // WaitForConnection: Got a bad event
00605             goto Failure;
00606         }
00607
00608         switch (m_Line.eCallState)
00609         {
00610         case CALL_STATE_MAKE:
00611             {
00612                 // The other side was connected and cleared DTR
00613                 if (m_dwEventMask & (EV_RXCHAR))
00614                 {
00615                     ::EscapeCommFunction(m_Line.hCommLink, CLRDTR);
00616                     ::EscapeCommFunction(m_Line.hCommLink, SETDTR);
00617                     SetConnectedPort();
00618                     m_Line.fCaller = FALSE;
00619                     goto Success;
00620                 }
00621
00622                 // The other side just connected
00623                 else
00624                 if(m_dwEventMask & (EV_DSR | EV_RLSD | EV_CTS))
00625                 {
00626                     // Change the state of this connection so we dont get here again
00627                     m_Line.eCallState = CALL_STATE_ANSWER;
00628
00629                     // Wait sometime so the other side can transition to the wait state
00630                     ::Sleep(2000);
00631
00632                     // Tell the other side we connected before
00633                     ::EscapeCommFunction(m_Line.hCommLink, SETBREAK);
00634
00635                     ::ZeroMemory(&m_Overlapped, sizeof(m_Overlapped));
00636                     m_Overlapped.hEvent = m_Line.hevtCall;
00637                     m_dwEventMask = 0;
00638
00639                     ::ResetEvent(m_Overlapped.hEvent);
00640
00641                     if (! ::WaitCommEvent(m_Line.hCommLink, &m_dwEventMask, &m_Overlapped))
00642                     {
00643                         DWORD dwErr = ::GetLastError();
00644                         if (ERROR_IO_PENDING != dwErr)
00645                         {
00646                             // TPhysConnectRequest:  Unable to WaitCommEvent
00647                             DropCall();
00648                             goto Failure;
00649                         }
00650                     }
00651                 }
00652             }
00653             break;
00654
00655         case CALL_STATE_ANSWER:
00656             {
00657                 ::EscapeCommFunction(m_Line.hCommLink, CLRBREAK);
00658                 SetConnectedPort();
00659                 goto Success;
00660             }
00661             break;
00662         }
00663     } // while
00664
00665 Success:
00666
00667     fRet = TRUE;
00668
00669 Failure:
00670
00671     return fRet;
00672 }
00673
00674
00675 //****************************************************************************
00676 //
00677 //    FUNCTION:   DWORD CNullModem::DoConnect(void)
00678 //
00679 //    PURPOSE:
00680
00681 //    COMMENTS:
00682 //
00683 //****************************************************************************
00684
00685 DWORD CNullModem::DoConnect(void)
00686 {
00687     ULONG    rc = 0;
00688
00689     while (m_fCommPortInUse)
00690     {
00691         // Wait for connection to happen
00692         if (WaitForConnection())
00693         {
00694             SetBuffers();
00695             SetTimeouts();
00696
00697             // Call T120 physicall request
00698             if (m_Line.fCaller)
00699             {
00700                 // rc = g_lpfnPTPhysicalConnectRequest(0, // CALL_CONTROL_MANUAL
00701                 //                        &m_Line.hCommLink, NULL, &m_Line.pstnHandle);
00702             }
00703             else
00704             {
00705                 m_Line.connInfo.connectionID = m_nConnectionID;
00706                 m_Line.connInfo.resultCode = TPHYS_SUCCESS;
00707             }
00708
00709             if (rc != 0)
00710             {
00711                 m_Line.connInfo.resultCode = TPHYS_RESULT_CONNECT_FAILED;
00712
00713                 DropCall();
00714             }
00715             else
00716             {
00717                 m_Line.eCallState = CALL_STATE_CONNECTED;
00718                 m_Line.connInfo.resultCode = TPHYS_SUCCESS;
00719
00720                 // This comm port doesn't need the thread anymore
00721                 m_fCommPortInUse = FALSE;
00722             }
00723         }
00724         else
00725         {
00726             m_Line.connInfo.resultCode = TPHYS_RESULT_CONNECT_FAILED;
00727
00728             // Something went wrong in the wait, get out of the loop
00729             break;
00730         }
00731     }
00732
00733     return 0;
00734 }
00735
00736
00737 //****************************************************************************
00738 //
00739 //    FUNCTION:   void CNullModem::SetBuffers(void)
00740 //
00741 //    PURPOSE:    Initializes the communication parameters
00742
00743 //    COMMENTS:
00744 //
00745 //
00746 //****************************************************************************
00747
00748 void CNullModem::SetBuffers(void)
00749 {
00750     BOOL fRet = ::SetupComm(m_Line.hCommLink, /* rx */ 10240, /* tx */ 1024);
00751     ASSERT(fRet);
00752 }
00753
00754
00755 //****************************************************************************
00756 //
00757 //    FUNCTION:   void CNullModem::SetTimeouts(void)
00758 //
00759 //    PURPOSE:    Sets the time-out parameters for all read and write operations
00760 //                on the specified communications device
00761
00762 //    COMMENTS:
00763 //
00764 //
00765 //****************************************************************************
00766
00767 void CNullModem::SetTimeouts(void)
00768 {
00769     COMMTIMEOUTS    com_timeouts;
00770     ::ZeroMemory(&com_timeouts, sizeof(com_timeouts));
00771     com_timeouts.ReadIntervalTimeout = 100;   //10
00772     com_timeouts.ReadTotalTimeoutMultiplier = 0;
00773     com_timeouts.ReadTotalTimeoutConstant = 100;
00774     com_timeouts.WriteTotalTimeoutMultiplier = 0;
00775     com_timeouts.WriteTotalTimeoutConstant = 10000;
00776     BOOL fRet = ::SetCommTimeouts(m_Line.hCommLink, &com_timeouts);
00777     ASSERT(fRet);
00778
00779 }
00780
00781
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/credentials/VC/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • credentials
  • VC

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__AAEF26DD_E0AA_11D2_BC85_00C04FD430AF__INCLUDED_)
00007 #define AFX_STDAFX_H__AAEF26DD_E0AA_11D2_BC85_00C04FD430AF__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013 #define _WIN32_WINNT 0x0500 // VC6 doesn't do this for us
00014 #define UNICODE
00015 #define _UNICODE
00016 #define WIN32_LEAN_AND_MEAN
00017 #define SECURITY_WIN32
00018 #include <tchar.h>
00019 #include <windows.h>
00020 #include <objbase.h>
00021 #include <stdio.h>
00022 #include <security.h>
00023 #include <activeds.h> /* adsi */
00024
00025
00026 // TODO: reference additional headers your program requires here
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00030
00031 #endif // !defined(AFX_STDAFX_H__AAEF26DD_E0AA_11D2_BC85_00C04FD430AF__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPeoplePoweredVehicle Member List

This is the complete list of members for CPeoplePoweredVehicle, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
children | CPeoplePoweredVehicle | [private]
children | CPeoplePoweredVehicle | [private]
CPeoplePoweredVehicle(CComponentData *pComponentData=NULL) | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CPeoplePoweredVehicle(CComponentData *pComponentData=NULL) | CPeoplePoweredVehicle |
CPeoplePoweredVehicle() | CPeoplePoweredVehicle |
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetBitmapIndex() | CPeoplePoweredVehicle | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CPeoplePoweredVehicle | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
getNodeType() | CPeoplePoweredVehicle | [inline, virtual]
GetParentScopeItem() | CPeoplePoweredVehicle | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
IDM_NEW_PEOPLE enum value | CPeoplePoweredVehicle | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_hParentHScopeItem | CPeoplePoweredVehicle | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
NUMBER_OF_CHILDREN enum value | CPeoplePoweredVehicle | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CPeoplePoweredVehicle | [virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CPeoplePoweredVehicle | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CPeoplePoweredVehicle | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
~CPeoplePoweredVehicle() | CPeoplePoweredVehicle | [virtual]
Generated on Wed Nov 13 2024 16:57:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/Inc/MtsSpyCtl.Idl Source File

  • Com
  • Common
  • Inc

MtsSpyCtl.Idl

Go to the documentation of this file.
00001 #include <olectl.h>
00002 // MtsSpyCtl.idl : IDL source for MtsSpyCtl.dll
00003 //
00004
00005 // This file will be processed by the MIDL tool to
00006 // produce the type library (MtsSpyCtl.tlb) and marshalling code.
00007 cpp_quote ("#define DISPID_LOGFILE    5")
00008 cpp_quote ("#define DISPID_GRIDLINES  6")
00009 cpp_quote ("#define DISPID_COLWIDTH   8")
00010 cpp_quote ("#define DISPID_AUDIT    17")
00011
00012 typedef enum
00013 {
00014   Package = 0,
00015   Thread,
00016   Instance,
00017   Transaction,
00018   Method,
00019   Object,
00020   Resource,
00021   User,
00022   Security,
00023   EventStore,
00024   ObjectPool,
00025   ObjectPool2,
00026   ObjectConstruction,
00027   Activity,
00028   Identity,
00029   QC,
00030   Exception,
00031   CRM,
00032
00033 } EventEnum;
00034
00035 import "oaidl.idl";
00036 import "ocidl.idl";
00037
00038
00039   [
00040     object,
00041     uuid(A9B39080-AAD0-11D0-B183-00AA00BA3258),
00042     dual,
00043     helpstring("IMtsSpy Interface"),
00044     pointer_default(unique)
00045   ]
00046   interface IMtsSpy : IDispatch
00047   {
00048     [propget, id(DISPID_HWND)]
00049     HRESULT Window([out, retval]long* phwnd);
00050     [propputref, id(DISPID_FONT)]
00051     HRESULT Font([in]IFontDisp* pFont);
00052     [propput, id(DISPID_FONT)]
00053     HRESULT Font([in]IFontDisp* pFont);
00054     [propget, id(DISPID_FONT)]
00055     HRESULT Font([out, retval]IFontDisp** ppFont);
00056     [propget, id(5), helpstring("property LogFile")] HRESULT LogFile([out, retval] BSTR *pVal);
00057     [propput, id(5), helpstring("property LogFile")] HRESULT LogFile([in] BSTR newVal);
00058     [propget, id(6), helpstring("property ShowGridLines")] HRESULT ShowGridLines([out, retval] BOOL *pVal);
00059     [propput, id(6), helpstring("property ShowGridLines")] HRESULT ShowGridLines([in] BOOL newVal);
00060     [propget, id(8), helpstring("property ColWidth")] HRESULT ColWidth(short nColumn, [out, retval] long *pVal);
00061     [propput, id(8), helpstring("property ColWidth")] HRESULT ColWidth(short nColumn, [in] long newVal);
00062     [id(9), helpstring("method SelectPackages")] HRESULT SelectPackages();
00063     [id(10), helpstring("method SaveToFile")] HRESULT SaveToFile();
00064     [id(11), helpstring("method ClearAllEvents")] HRESULT ClearAllEvents();
00065     [id(12), helpstring("method About")] HRESULT About();
00066     [propget, id(13), helpstring("property LogToFile")] HRESULT LogToFile([out, retval] BOOL *pVal);
00067     [propput, id(13), helpstring("property LogToFile")] HRESULT LogToFile([in] BOOL newVal);
00068     [id(14), helpstring("method ChooseFont")] HRESULT ChooseFont();
00069     [propget, id(15), helpstring("property ShowOnScreen")] HRESULT ShowOnScreen([out, retval] BOOL *pVal);
00070     [propput, id(15), helpstring("property ShowOnScreen")] HRESULT ShowOnScreen([in] BOOL newVal);
00071     [id(16), helpstring("method ChooseLogFile")] HRESULT ChooseLogFile([out] BSTR * sLogFileName, [out] BOOL * bCanceled);
00072     [propget, id(17), helpstring("property Audit")] HRESULT Audit([out, retval] BOOL *pVal);
00073     [propput, id(17), helpstring("property Audit")] HRESULT Audit([in] BOOL newVal);
00074
00075   };
00076   [
00077
00078     uuid(0243D433-3849-11d2-89BB-00C04F99140F),
00079
00080     helpstring("ICOMSysLCE Interface"),
00081     pointer_default(unique)
00082   ]
00083   interface ICOMSysLCE : IUnknown
00084   {
00085     [helpstring("method GetEventType")] HRESULT GetEventType([out] EventEnum * e);
00086     [helpstring("method GetEventClass")] HRESULT GetEventClass([out] LPGUID guid);
00087     [helpstring("method Install")] HRESULT Install([in] BSTR* PropertyName, [in] VARIANT PropertyValue);
00088     [helpstring("method Uninstall")] HRESULT Uninstall();
00089   };
00090 [
00091   uuid(A9B39071-AAD0-11D0-B183-00AA00BA3258),
00092   version(1.0),
00093   helpstring("MtsSpyCtl 1.0 Type Library")
00094 ]
00095 library MTSSPYCTLLib
00096 {
00097   importlib("stdole2.tlb");
00098
00099   [
00100     uuid(A9B39081-AAD0-11D0-B183-00AA00BA3258),
00101     helpstring("COMPlus Spy ActiveX Control")
00102   ]
00103   coclass MtsSpy
00104   {
00105     [default] interface IMtsSpy;
00106   };
00107
00108
00109   [
00110     uuid(AAF6270D-AC5E-11D0-B185-00AA00BA3258),
00111     helpstring("MtsSpyPropPage Class")
00112   ]
00113   coclass MtsSpyPropPage
00114   {
00115     interface IUnknown;
00116   };
00117 };
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/Deb/ToolBar.c Source File

  • WinBase
  • Debug
  • Deb

ToolBar.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 *       This source code is only intended as a supplement to
00010 *       Microsoft Development Tools and/or WinHelp documentation.
00011 *       See these sources for detailed information regarding the
00012 *       Microsoft samples programs.
00013
00014 MODULE    : ToolBar.C
00015 PURPOSE   : A Win32 DLL containing a simple text ToolBar
00016 FUNCTIONS :
00017   DllMain()         - Dll entry point (via _DllMainCRTStartup)
00018   TextButtonBar()   - generate a text button ToolBar
00019   TextButtonBarProc - processes messages for the TextButtonBarWClass
00020 COMMENTS  :
00021 *************************************************************************/
00022
00023 #define   STRICT               // enable strict typing
00024 #include <Windows.H>           // required for all Windows applications
00025
00026 #include "ToolBar.H"           // specific to this program
00027
00028 //-- internal data
00029 HWND hWndToolBarOwner;         // window handle of Toolbar owner
00030                                // where all WM_COMMAND messages are sent
00031
00032 //-- internal prototypes
00033 LRESULT CALLBACK TextButtonBarProc( HWND, UINT, WPARAM, LPARAM );
00034
00035
00036 // ************************************************************************
00037 // FUNCTION : DllMain( HINSTANCE, DWORD, LPVOID )
00038 // PURPOSE  : DllMain is called by the C run-time library from the
00039 //            _DllMainCRTStartup entry point.  The DLL entry point gets
00040 //            called (entered) on the following events: "Process Attach",
00041 //            "Thread Attach", "Thread Detach" or "Process Detach".
00042 // COMMENTS : No initialization is needed here so this entry point simply
00043 //            returns TRUE.
00044 // ************************************************************************
00045 BOOL WINAPI
00046 DllMain( HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved )
00047 {
00048   UNREFERENCED_PARAMETER( hInstDLL );
00049   UNREFERENCED_PARAMETER( fdwReason );
00050   UNREFERENCED_PARAMETER( lpvReserved );
00051
00052   return( TRUE );
00053 }
00054
00055
00056 // ************************************************************************
00057 // FUNCTION : TextButtonBar( HWND, LPTEXTBUTTON, LPINT )
00058 // PURPOSE  : Generate a simple text button ToolBar
00059 // COMMENTS : lpTextButton points to an array of TEXTBUTTON
00060 //            structures.  The last structure must set the
00061 //            member lpButtonText to 0L.  lpHeight contains the
00062 //            height of the ToolBar window.
00063 // ************************************************************************
00064 HWND
00065 TextButtonBar( HWND hWndParent, LPTEXTBUTTON lpTextButton, LPINT lpHeight )
00066 {
00067   #define BUTTON_BORDER    4
00068   #define BUTTONBAR_BORDER 4
00069
00070   static HWND         hWndTextButtonBar;
00071
00072   HDC          hDC;
00073   WNDCLASS     WndClass;
00074   LONG         ButtonWidth;
00075   LONG         ButtonHeight;
00076   INT          xPosButton;
00077   INT          ButtonSpacing;
00078   INT          ButtonSpace;
00079   LPTSTR       lpButtonString;
00080   LPTEXTBUTTON lpTempTextButton;
00081   TEXTMETRIC   tm;
00082   SIZE         ButtonTextSize;
00083   RECT         rect;
00084
00085   //-- store owner of Toolbar
00086   hWndToolBarOwner = hWndParent;
00087
00088   //-- register the TestButtonBar window class
00089   WndClass.style         = (UINT) 0L;
00090   WndClass.lpfnWndProc   = (WNDPROC) TextButtonBarProc;
00091   WndClass.cbClsExtra    = 0;
00092   WndClass.cbWndExtra    = 0;
00093   WndClass.hInstance     = 0L;
00094   WndClass.hIcon         = 0L;
00095   WndClass.hCursor       = 0L;
00096   WndClass.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
00097   WndClass.lpszMenuName  = 0L;
00098   WndClass.lpszClassName = TEXT( "TextButtonBarWClass" );
00099
00100   if( !RegisterClass( &WndClass ) )
00101     return( FALSE );
00102
00103   hDC = GetDC( hWndParent );
00104   GetTextMetrics( hDC, &tm );
00105   ButtonHeight = 2 * BUTTON_BORDER + tm.tmHeight;
00106   *lpHeight = 2 * BUTTONBAR_BORDER + ButtonHeight;
00107
00108   GetWindowRect( GetDesktopWindow(), &rect );
00109   hWndTextButtonBar = CreateWindow(
00110                         TEXT( "TextButtonBarWClass" ), TEXT( "Toolbar" ),
00111                         WS_CHILD | WS_CLIPSIBLINGS,
00112                         0, 0, rect.right - rect.left, *lpHeight,
00113                         hWndToolBarOwner,
00114                         (HMENU) 0L, (HANDLE) 0L, 0L );
00115
00116   SetWindowPos( hWndTextButtonBar, (HWND) 1, 0, 0, 0, 0,
00117     SWP_NOMOVE | SWP_NOSIZE );
00118
00119   //-- button spacing information
00120   ButtonSpacing = BUTTON_BORDER / 2;
00121   ButtonSpace   = BUTTON_BORDER * 4;
00122   xPosButton    = BUTTON_BORDER * 2;
00123
00124   //-- Create all the button windows
00125   for( lpTempTextButton = lpTextButton;
00126          !( (lpTempTextButton->lpButtonText) == '\0'
00127            && (lpTempTextButton->idButton) == (UINT) 0L);
00128          lpTempTextButton++ ) {
00129
00130     //-- if TB_SPACE then adjust new xPos and continue
00131     if( lpTempTextButton->idButton == TB_SPACE ) {
00132       xPosButton += ButtonSpace;
00133       continue;
00134     }
00135
00136     lpButtonString = lpTempTextButton->lpButtonText;
00137     GetTextExtentPoint( hDC, lpButtonString, lstrlen(lpButtonString), &ButtonTextSize );
00138     ButtonWidth = (4 * BUTTON_BORDER) + (LONG) ButtonTextSize.cx;
00139
00140     (lpTempTextButton->hWndButton) = CreateWindow(
00141          TEXT( "BUTTON" ), lpButtonString,
00142          WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD,
00143          xPosButton, BUTTONBAR_BORDER, ButtonWidth, ButtonHeight,
00144          hWndTextButtonBar,
00145          (HMENU)(INT_PTR) lpTempTextButton->idButton,
00146          (HANDLE) 0L, 0L );
00147
00148     xPosButton += ButtonWidth + ButtonSpacing;
00149   }
00150   ReleaseDC( hWndParent, hDC );
00151
00152   return( hWndTextButtonBar );
00153 }
00154
00155
00156 // ************************************************************************
00157 // FUNCTION : TextButtonBarProc( HWND, UINT, WPARAM, LPARAM )
00158 // PURPOSE  : Processes messages for the TextButtonBarWClass
00159 // MESSAGES :
00160 //  WM_COMMAND - forwarded to the owner window
00161 //  WM_PAINT   - draws a 3D background
00162 // COMMENTS :
00163 // ************************************************************************
00164 LRESULT CALLBACK
00165 TextButtonBarProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
00166 {
00167   static HDC         hDC;
00168   static RECT        rect;
00169   static PAINTSTRUCT ps;
00170
00171   switch( uMsg ) {
00172
00173     case WM_COMMAND:
00174       SendMessage( hWndToolBarOwner, uMsg, wParam, lParam );
00175       return( FALSE );
00176
00177     case WM_PAINT:
00178       hDC = BeginPaint( hWnd, &ps );
00179       GetClientRect( hWnd, &rect );
00180
00181       SelectObject( hDC, GetStockObject(WHITE_PEN) );
00182       MoveToEx( hDC, rect.left, rect.top, 0L );
00183       LineTo( hDC, rect.right+1, rect.top );
00184
00185       #define DKGRAY_PEN RGB(128, 128, 128)
00186       SelectObject( hDC, (HANDLE) CreatePen( PS_SOLID, 1, DKGRAY_PEN ) );
00187       MoveToEx( hDC, rect.left, rect.bottom-2, 0L );
00188       LineTo( hDC, rect.right+1, rect.bottom-2 );
00189
00190       SelectObject( hDC, (HANDLE) CreatePen( PS_SOLID, 1, BLACK_PEN ) );
00191       MoveToEx( hDC, rect.left, rect.bottom-1, 0L );
00192       LineTo( hDC, rect.right+1, rect.bottom-1 );
00193
00194       DeleteObject( SelectObject( hDC, GetStockObject(BLACK_PEN) ) );
00195       EndPaint( hWnd, &ps );
00196       return( FALSE );
00197
00198     default:
00199       return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
00200   }
00201 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CONST_DWORD_REP Member List

This is the complete list of members for CONST_DWORD_REP, including all inherited members.
dwConstant | CONST_DWORD_REP
pstrRep | CONST_DWORD_REP
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

qcnotify::INotify Member List

This is the complete list of members for qcnotify::INotify, including all inherited members.
iid | qcnotify::INotify | [static]
LineItem(int lItemId, int lQuantity, int ShipStatus) | qcnotify::INotify |
Process(int lFlags) | qcnotify::INotify |
setCustomerId(int _jcomparam_0) | qcnotify::INotify |
setOrderId(int _jcomparam_0) | qcnotify::INotify |
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConServe/Connect.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConServe

Connect.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.CPP
00003
00004   Summary:   Implementation file for the connection points (and their
00005              connections) offered by the connectable objects in the
00006              CONSERVE server sample. COM objects are implemented for
00007              Connection Point Enumerators, Connection Points, and
00008              Connection Enumerators.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial CONSERVE.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Functions: none.
00020
00021   Origin:    6-3-96: atrent - Created for the CONSERVE Tutorial
00022              Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039
00040 /*---------------------------------------------------------------------------
00041   We include WINDOWS.H for all Win32 applications.
00042   We include OLE2.H because we will be calling the COM/OLE Libraries.
00043   We include OLECTL.H because it has definitions for connectable objects.
00044   We include APPUTIL.H because we will be building this application using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IBALL.H and BALLGUID.H for the common Ball-related Interface
00048     class, GUID, and CLSID specifications.
00049   We include SERVER.H because it has internal class declarations and
00050     resource ID definitions specific for this DLL.
00051   We include CONNECT.H for object class declarations for the various
00052     connection point and connection COM objects used in CONSERVE.
00053   We include BALL.H because it has the class COEnumConnectionPoints
00054     declarations.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <olectl.h>
00059 #include <apputil.h>
00060 #include <iball.h>
00061 #include <ballguid.h>
00062 #include "server.h"
00063 #include "connect.h"
00064 #include "ball.h"
00065
00066
00067 /*---------------------------------------------------------------------------
00068   COEnumConnectionPoints's implementation of its main COM object class
00069   including Constructor, Destructor, QueryInterface, AddRef, Release,
00070   Next, Skip, Reset, and Clone.
00071 ---------------------------------------------------------------------------*/
00072
00073 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00074   Method:   COEnumConnectionPoints::COEnumConnectionPoints
00075
00076   Summary:  COEnumConnectionPoints Constructor.
00077
00078   Args:     IUnknown* pHostObj
00079               Pointer to the host object whose connection points are
00080               being enumerated.
00081
00082   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnPts, and m_paConnPts.
00083
00084   Returns:  void
00085 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00086 COEnumConnectionPoints::COEnumConnectionPoints(
00087   IUnknown* pHostObj)
00088 {
00089   // Zero the COM object's reference count.
00090   m_cRefs = 0;
00091
00092   // Assign the Host Object pointer.
00093   m_pHostObj = pHostObj;
00094
00095   // Initialize the Connection Point enumerator variables.
00096   m_iEnumIndex = 0;
00097   m_cConnPts = 0;
00098   m_paConnPts = NULL;
00099
00100   return;
00101 }
00102
00103
00104 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00105   Method:   COEnumConnectionPoints::~COEnumConnectionPoints
00106
00107   Summary:  COEnumConnectionPoints Destructor.
00108
00109   Args:     void
00110
00111   Modifies: m_paConnPts.
00112
00113   Returns:  void
00114 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00115 COEnumConnectionPoints::~COEnumConnectionPoints(void)
00116 {
00117   if (NULL != m_paConnPts)
00118   {
00119     UINT i;
00120
00121     // Release all the connection point interface pointers.
00122     for (i=0; i<m_cConnPts; i++)
00123       if (NULL != m_paConnPts[i])
00124         m_paConnPts[i]->Release();
00125
00126     // Delete the array of interface pointers.
00127     delete [] m_paConnPts;
00128   }
00129
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   COEnumConnectionPoints::Init
00136
00137   Summary:  COEnumConnectionPoints Initialization method.  Create any
00138             necessary arrays, structures, and objects.
00139
00140   Args:     ULONG cConnPts,
00141               Number of Connections Points.
00142             IConnectionPoint** paConnPts,
00143               Pointer to array of connection point interface pointers.
00144             ULONG iEnumIndex
00145               The Enumerator index initial value.
00146
00147   Modifies: m_cConnPts, m_paConnPts, m_iEnumIndex.
00148
00149   Returns:  HRESULT
00150               Standard result code. NOERROR for success.
00151 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00152 HRESULT COEnumConnectionPoints::Init(
00153           ULONG cConnPts,
00154           IConnectionPoint** paConnPts,
00155           ULONG iEnumIndex)
00156 {
00157   HRESULT hr = NOERROR;
00158   UINT i;
00159
00160   // Remember the number of Connection points.
00161   m_cConnPts = cConnPts;
00162
00163   // Remember the initial enumerator index.
00164   m_iEnumIndex = iEnumIndex;
00165
00166   // Create a copy of the array of connection points and keep it inside
00167   // this enumerator COM object.
00168   m_paConnPts = new IConnectionPoint* [(UINT) cConnPts];
00169
00170   // Fill the array copy with the IConnectionPoint interface pointers from
00171   // the array passed. AddRef for each new Interface pointer copy made.
00172   if (NULL != m_paConnPts)
00173   {
00174     for (i=0; i<cConnPts; i++)
00175     {
00176       m_paConnPts[i] = paConnPts[i];
00177       m_paConnPts[i]->AddRef();
00178     }
00179   }
00180   else
00181     hr = E_OUTOFMEMORY;
00182
00183   return (hr);
00184 }
00185
00186
00187 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00188   Method:   COEnumConnectionPoints::QueryInterface
00189
00190   Summary:  QueryInterface of the COEnumConnectionPoints non-delegating
00191             IUnknown implementation.
00192
00193   Args:     REFIID riid,
00194               [in] GUID of the Interface being requested.
00195             PPVOID ppv)
00196               [out] Address of the caller's pointer variable that will
00197               receive the requested interface pointer.
00198
00199   Modifies: .
00200
00201   Returns:  HRESULT
00202               Standard result code. NOERROR for success.
00203 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00204 STDMETHODIMP COEnumConnectionPoints::QueryInterface(
00205                REFIID riid,
00206                PPVOID ppv)
00207 {
00208   HRESULT hr = E_NOINTERFACE;
00209
00210   *ppv = NULL;
00211
00212   // The IEnumConnectionPoints interface is implemented directly in
00213   // this COM object rather than being a nested interface implementation.
00214   if (IID_IUnknown == riid || IID_IEnumConnectionPoints == riid)
00215     *ppv = (LPVOID)this;
00216
00217   if (NULL != *ppv)
00218   {
00219     // We've handed out a pointer to the interface so obey the COM rules
00220     // and AddRef the reference count.
00221     ((LPUNKNOWN)*ppv)->AddRef();
00222     hr = NOERROR;
00223   }
00224
00225   return (hr);
00226 }
00227
00228
00229 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00230   Method:   COEnumConnectionPoints::AddRef
00231
00232   Summary:  AddRef of the COEnumConnectionPoints non-delegating IUnknown
00233             implementation.
00234
00235   Args:     void
00236
00237   Modifies: m_cRefs.
00238
00239   Returns:  ULONG
00240               New value of m_cRefs (COM object's reference count).
00241 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00242 STDMETHODIMP_(ULONG) COEnumConnectionPoints::AddRef(void)
00243 {
00244   ULONG cRefs;
00245
00246   cRefs = ++m_cRefs;
00247
00248   // Also AddRef the host object to ensure it stays around as long as
00249   // this enumerator.
00250   m_pHostObj->AddRef();
00251
00252   return cRefs;
00253 }
00254
00255
00256 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00257   Method:   COEnumConnectionPoints::Release
00258
00259   Summary:  Release of the COEnumConnectionPoints non-delegating IUnknown
00260             implementation.
00261
00262   Args:     void
00263
00264   Modifies: m_cRefs.
00265
00266   Returns:  ULONG
00267               New value of m_cRefs (COM object's reference count).
00268 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00269 STDMETHODIMP_(ULONG) COEnumConnectionPoints::Release(void)
00270 {
00271   ULONG cRefs;
00272
00273   // Pass this release along to the Host object being enumerated.
00274   m_pHostObj->Release();
00275
00276   cRefs = --m_cRefs;
00277
00278   if (0 == cRefs)
00279   {
00280     // We artificially bump the main ref count to prevent reentrancy via
00281     // the main object destructor.
00282     m_cRefs++;
00283     delete this;
00284   }
00285
00286   return cRefs;
00287 }
00288
00289
00290 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00291   Method:   COEnumConnectionPoints::Next
00292
00293   Summary:  The Next member method of this IEnumConnectionPoints interface
00294             implementation. Called by outside clients of a
00295             COEnumConnectionPoints object to request that a number of next
00296             connection point interface pointers be deposited into an array
00297             supplied by the caller.
00298
00299   Args:     ULONG cReq
00300               Number of connection points requested for return (starting at
00301               the current Enumerator index).
00302             IConnectionPoint** paConnPts,
00303               Pointer to a caller's output array that will receive the
00304               enumerated IConnectionPoint interface pointers.
00305             ULONG* cEnumerated)
00306               Pointer to a ULONG variable that will contain the number of
00307               connection points actually enumerated by this call.
00308
00309   Modifies: .
00310
00311   Returns:  HRESULT
00312               Standard result code. NOERROR for success.
00313 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00314 STDMETHODIMP COEnumConnectionPoints::Next(
00315                ULONG cReq,
00316                IConnectionPoint** paConnPts,
00317                ULONG* pcEnumerated)
00318 {
00319   HRESULT hr = NOERROR;
00320   ULONG cRet = 0;
00321
00322   // Make sure the argument values passed are valid.
00323   if (NULL != m_paConnPts)
00324   {
00325     if (NULL != paConnPts)
00326     {
00327       if (NULL != *paConnPts && m_iEnumIndex < m_cConnPts)
00328       {
00329         if (NULL != pcEnumerated)
00330           *pcEnumerated = 0L;
00331         else
00332           if (1L != cReq)
00333             hr = E_POINTER;
00334       }
00335       else
00336         hr = S_FALSE;
00337     }
00338     else
00339       hr = E_POINTER;
00340   }
00341   else
00342     hr = S_FALSE;
00343
00344   if (SUCCEEDED(hr))
00345   {
00346     // Starting at the current Enumerator index, loop to assign the
00347     // requested number of output connection point interface pointers.
00348     for (; m_iEnumIndex < m_cConnPts && cReq > 0;
00349            paConnPts++, cRet++, cReq--)
00350     {
00351       // Assign from the inside Enumerator array to the specified receiving
00352       // array.
00353       *paConnPts = m_paConnPts[m_iEnumIndex++];
00354       // After assigning a copy of an IConnectionPoint pointer, AddRef it.
00355       if (NULL != *paConnPts)
00356         (*paConnPts)->AddRef();
00357     }
00358
00359     // Assign the output number of connection points enumerated.
00360     if (NULL != pcEnumerated)
00361       *pcEnumerated = cRet;
00362   }
00363
00364   return hr;
00365 }
00366
00367
00368 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00369   Method:   COEnumConnectionPoints::Skip
00370
00371   Summary:  The Skip member method of this IEnumConnectionPoints interface
00372             implementation. Starting at the current Enumerator index, skip
00373             the specified number of connection point items.
00374
00375   Args:     ULONG cSkip
00376               Number of Connection Point items to skip.
00377
00378   Modifies: .
00379
00380   Returns:  HRESULT
00381               Standard result code. NOERROR for success.
00382 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00383 STDMETHODIMP COEnumConnectionPoints::Skip(
00384                ULONG cSkip)
00385 {
00386   HRESULT hr = NOERROR;
00387
00388   // If there really is a connection point array and the requested
00389   // amount of skip does not exceed the number of connection points,
00390   // then bump the index by the requested skip amount.
00391   if (NULL != m_paConnPts && (m_iEnumIndex + cSkip) < m_cConnPts)
00392     m_iEnumIndex += cSkip;
00393   else
00394     hr = S_FALSE;
00395
00396   return hr;
00397 }
00398
00399
00400 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00401   Method:   COEnumConnectionPoints::Reset
00402
00403   Summary:  The Reset member method of the IEnumConnectionPoints interface
00404             implementation. Resets the Enumeration index to the first
00405             connection point item in the array.
00406
00407   Args:     void.
00408
00409   Modifies: .
00410
00411   Returns:  HRESULT
00412               Standard result code. NOERROR for success.
00413 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00414 STDMETHODIMP COEnumConnectionPoints::Reset(
00415                void)
00416 {
00417   // Zero the main Enumerator index.
00418   m_iEnumIndex = 0;
00419
00420   return NOERROR;
00421 }
00422
00423
00424 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00425   Method:   COEnumConnectionPoints::Clone
00426
00427   Summary:  The Clone member method of this IEnumConnectionPoints
00428             interface implementation. Creates a new clone of this entire
00429             Connection Point enumerator COM object.
00430
00431   Args:     IEnumConnectionPoints** ppIEnum
00432               Address of the caller's output pointer variable that will
00433               receive the IEnumConnectionPoints interface pointer of the
00434               new enumerator clone.
00435
00436   Modifies: ...
00437
00438   Returns:  HRESULT
00439               Standard result code. NOERROR for success.
00440 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00441 STDMETHODIMP COEnumConnectionPoints::Clone(
00442                IEnumConnectionPoints** ppIEnum)
00443 {
00444   HRESULT hr;
00445   COEnumConnectionPoints* pCOEnum;
00446
00447   // NULL the output variable first.
00448   *ppIEnum = NULL;
00449
00450   // Create the Clone Enumerator COM object.
00451   pCOEnum = new COEnumConnectionPoints(m_pHostObj);
00452   if (NULL != pCOEnum)
00453   {
00454     // Initialize it with same values as in this existing enumerator.
00455     hr = pCOEnum->Init(m_cConnPts, m_paConnPts, m_iEnumIndex);
00456     if (SUCCEEDED(hr))
00457     {
00458       // QueryInterface to return the requested interface pointer.
00459       // An AddRef will be conveniently done by the QI.
00460       if (SUCCEEDED(hr))
00461         hr = pCOEnum->QueryInterface(
00462                         IID_IEnumConnectionPoints,
00463                         (PPVOID)ppIEnum);
00464     }
00465   }
00466   else
00467     hr = E_OUTOFMEMORY;
00468
00469   return hr;
00470 }
00471
00472
00473 /*---------------------------------------------------------------------------
00474   COConnectionPoint's implementation of its main COM object class
00475   including Constructor, Destructor, QueryInterface, AddRef, Release,
00476   GetConnectionInterface, GetConnectionPointContainer, Advise, Unadvise,
00477   and EnumConnections.
00478 ---------------------------------------------------------------------------*/
00479
00480 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00481   Method:   COConnectionPoint::COConnectionPoint
00482
00483   Summary:  COConnectionPoint Constructor.
00484
00485   Args:     IUnknown* pHostObj
00486               Pointer to IUnknown of the connectable object offering this
00487               connection point.
00488
00489   Modifies: ...
00490
00491   Returns:  void
00492 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00493 COConnectionPoint::COConnectionPoint(
00494   IUnknown* pHostObj)
00495 {
00496   // Zero the COM object's reference count.
00497   m_cRefs = 0;
00498
00499   // Remember an IUnknown pointer to the connectable object that offers
00500   // this connection point. Since this connection point object's lifetime
00501   // is geared to that of the connectable object there is no need to
00502   // AddRef the following copied pointer to the connectable object.
00503   m_pHostObj = pHostObj;
00504
00505   // Initialize the Connection Point variables.
00506   m_dwNextCookie = COOKIE_START_VALUE;
00507   m_uiMaxIndex = 0;
00508   m_cConnections = 0;
00509   m_paConnections = NULL;
00510
00511   return;
00512 }
00513
00514
00515 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00516   Method:   COConnectionPoint::~COConnectionPoint
00517
00518   Summary:  COConnectionPoint Destructor.
00519
00520   Args:     void
00521
00522   Modifies: m_paConnections.
00523
00524   Returns:  void
00525 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00526 COConnectionPoint::~COConnectionPoint(void)
00527 {
00528   UINT i;
00529   IUnknown* pUnk;
00530
00531   if (NULL != m_paConnections)
00532   {
00533     // Release all the connection sink interface pointers.
00534     for (i=0; i<m_uiMaxIndex; i++)
00535     {
00536       pUnk = m_paConnections[i].pUnk;
00537       if (NULL != pUnk)
00538         pUnk->Release();
00539     }
00540
00541     // Delete the array of interface pointers.
00542     delete [] m_paConnections;
00543   }
00544
00545   return;
00546 }
00547
00548
00549 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00550   Method:   COConnectionPoint::Init
00551
00552   Summary:  COConnectionPoint Initialization method.  Create any
00553             necessary arrays, structures, and subordinate objects.
00554
00555   Args:     REFIID riid
00556               Reference to the IID of the Sink interface associated with
00557               this connection point.
00558
00559   Modifies: ...
00560
00561   Returns:  HRESULT
00562               Standard result code. NOERROR for success.
00563 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00564 HRESULT COConnectionPoint::Init(
00565           REFIID riid)
00566 {
00567   HRESULT hr = NOERROR;
00568   CONNECTDATA* paConns;
00569
00570   // Keep a copy of the reference to the IID of the sink interface
00571   // associated with this connection point. Needed for later
00572   // use by the GetConnectionInterface method.
00573   m_iidSink = riid;
00574
00575   // Build the initial dynamic array for connections.
00576   paConns = new CONNECTDATA[ALLOC_CONNECTIONS];
00577   if (NULL != paConns)
00578   {
00579     // Zero the array.
00580     memset(paConns, 0, ALLOC_CONNECTIONS * sizeof(CONNECTDATA));
00581
00582     // Rig this connection point object so that it will use the
00583     // new internal array of connections.
00584     m_uiMaxIndex = ALLOC_CONNECTIONS;
00585     m_paConnections = paConns;
00586   }
00587   else
00588     hr = E_OUTOFMEMORY;
00589
00590   return (hr);
00591 }
00592
00593
00594 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00595   Method:   COConnectionPoint::QueryInterface
00596
00597   Summary:  QueryInterface of the COConnectionPoint non-delegating
00598             IUnknown implementation.
00599
00600   Args:     REFIID riid,
00601               [in] GUID of the Interface being requested.
00602             PPVOID ppv)
00603               [out] Address of the caller's pointer variable that will
00604               receive the requested interface pointer.
00605
00606   Modifies: .
00607
00608   Returns:  HRESULT
00609               Standard result code. NOERROR for success.
00610 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00611 STDMETHODIMP COConnectionPoint::QueryInterface(
00612                REFIID riid,
00613                PPVOID ppv)
00614 {
00615   HRESULT hr = E_NOINTERFACE;
00616
00617   *ppv = NULL;
00618
00619   // The IConnectionPoint interface is implemented directly in this
00620   // COM object rather than being a nested interface implementation.
00621   if (IID_IUnknown == riid || IID_IConnectionPoint == riid)
00622     *ppv = (LPVOID)this;
00623
00624   if (NULL != *ppv)
00625   {
00626     // We've handed out a pointer to the interface so obey the COM rules
00627     // and AddRef the reference count.
00628     ((LPUNKNOWN)*ppv)->AddRef();
00629     hr = NOERROR;
00630   }
00631
00632   return (hr);
00633 }
00634
00635
00636 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00637   Method:   COConnectionPoint::AddRef
00638
00639   Summary:  AddRef of the COConnectionPoint non-delegating IUnknown
00640             implementation.
00641
00642   Args:     void
00643
00644   Modifies: m_cRefs.
00645
00646   Returns:  ULONG
00647               New value of m_cRefs (COM object's reference count).
00648 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00649 STDMETHODIMP_(ULONG) COConnectionPoint::AddRef(void)
00650 {
00651   ULONG cRefs;
00652
00653   if (OwnThis())
00654   {
00655     cRefs = ++m_cRefs;
00656
00657     UnOwnThis();
00658   }
00659
00660   return cRefs;
00661 }
00662
00663
00664 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00665   Method:   COConnectionPoint::Release
00666
00667   Summary:  Release of the COConnectionPoint non-delegating IUnknown
00668             implementation.
00669
00670   Args:     void
00671
00672   Modifies: m_cRefs.
00673
00674   Returns:  ULONG
00675               New value of m_cRefs (COM object's reference count).
00676 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00677 STDMETHODIMP_(ULONG) COConnectionPoint::Release(void)
00678 {
00679   ULONG cRefs;
00680
00681   if (OwnThis())
00682   {
00683     cRefs = --m_cRefs;
00684
00685     if (0 == cRefs)
00686     {
00687       // We artificially bump the main ref count to prevent reentrancy via
00688       // the main object destructor. We relinquish thread ownership of this
00689       // object prior to deleting it--a good practice.
00690       m_cRefs++;
00691       UnOwnThis();
00692       delete this;
00693     }
00694     else
00695       UnOwnThis();
00696   }
00697
00698   return cRefs;
00699 }
00700
00701
00702 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00703   Method:   COConnectionPoint::GetSlot
00704
00705   Summary:  An internal private utility member method to obtain a free
00706             slot in the dynamic connections array. GetSlot will expand the
00707             dynamic array for more entries if needed. To guarantee thread
00708             safety, this private method should always be called within the
00709             protection of a bracketed OwnThis, UnOwnThis pair.
00710
00711   Args:     UINT* puiFreeSlot
00712               Address of an output variable to receive the free slot index.
00713
00714   Modifies: m_uiMaxIndex, m_paConnections.
00715
00716   Returns:  HRESULT
00717               Standard result code. NOERROR for success.
00718 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00719 HRESULT COConnectionPoint::GetSlot(
00720           UINT* puiFreeSlot)
00721 {
00722   HRESULT hr = NOERROR;
00723   BOOL bOpen = FALSE;
00724   UINT i;
00725   CONNECTDATA* paConns;
00726
00727   // Zero the output variable.
00728   *puiFreeSlot = 0;
00729
00730   // Loop to find an empty slot.
00731   for (i=0; i<m_uiMaxIndex; i++)
00732   {
00733     if (m_paConnections[i].dwCookie == 0)
00734     {
00735       // We found an open empty slot.
00736       *puiFreeSlot = i;
00737       bOpen = TRUE;
00738       break;
00739     }
00740   }
00741
00742   if (!bOpen)
00743   {
00744     // We didn't find an existing open slot in the array--it's full.
00745     // Expand the array by ALLOC_CONNECTIONS entries and assign the
00746     // appropriate output index.
00747     paConns = new CONNECTDATA[m_uiMaxIndex + ALLOC_CONNECTIONS];
00748     if (NULL != paConns)
00749     {
00750       // Copy the content of the old full array to the new larger array.
00751       for (i=0; i<m_uiMaxIndex; i++)
00752       {
00753         paConns[i].pUnk = m_paConnections[i].pUnk;
00754         paConns[i].dwCookie = m_paConnections[i].dwCookie;
00755       }
00756
00757       // Zero (ie mark as empty) the expanded portion of the new array.
00758       for (i=m_uiMaxIndex; i<m_uiMaxIndex+ALLOC_CONNECTIONS; i++)
00759       {
00760         paConns[i].pUnk = NULL;
00761         paConns[i].dwCookie = 0;
00762       }
00763
00764       // New larger array is ready--delete the old array.
00765       delete [] m_paConnections;
00766
00767       // Rig the connection point to use the new larger array.
00768       m_paConnections = paConns;
00769
00770       // Assign the output free slot as first entry in new expanded area.
00771       *puiFreeSlot = m_uiMaxIndex;
00772
00773       // Calculate the new max index.
00774       m_uiMaxIndex += ALLOC_CONNECTIONS;
00775     }
00776     else
00777       hr = E_OUTOFMEMORY;
00778   }
00779
00780   return hr;
00781 }
00782
00783
00784 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00785   Method:   COConnectionPoint::FindSlot
00786
00787   Summary:  An internal private utility member method to find an existing
00788             slot (identified by the specified dwCookie value) in the
00789             dynamic connections array.
00790
00791   Args:     DWORD dwCookie,
00792               The connection key (cookie) to find.
00793             UINT* puiSlot)
00794               Address of an output variable to receive the slot index.
00795
00796   Modifies: ...
00797
00798   Returns:  HRESULT
00799               Standard result code. NOERROR for success.
00800 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00801 HRESULT COConnectionPoint::FindSlot(
00802           DWORD dwCookie,
00803           UINT* puiSlot)
00804 {
00805   HRESULT hr = CONNECT_E_NOCONNECTION;
00806   UINT i;
00807
00808   // Loop to find the Cookie.
00809   for (i=0; i<m_uiMaxIndex; i++)
00810   {
00811     if (dwCookie == m_paConnections[i].dwCookie)
00812     {
00813       // If a cookie match is found, assign the output slot index.
00814       *puiSlot = i;
00815       hr = NOERROR;
00816       break;
00817     }
00818   }
00819
00820   return hr;
00821 }
00822
00823
00824 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00825   Method:   COConnectionPoint::GetConnectionInterface
00826
00827   Summary:  The GetConnectionInterface member method of this
00828             IConnectionPoint interface implementation. Called to get the
00829             IID of the Sink interface associated with this connection
00830             point.
00831
00832   Args:     IID* piidSink
00833               Pointer to the IID of the associated sink interface.
00834
00835   Modifies: .
00836
00837   Returns:  HRESULT
00838               Standard result code. NOERROR for success.
00839 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00840 STDMETHODIMP COConnectionPoint::GetConnectionInterface(
00841                IID* piidSink)
00842 {
00843   HRESULT hr = NOERROR;
00844
00845   if (NULL != piidSink)
00846     *piidSink = m_iidSink;
00847   else
00848     hr = E_POINTER;
00849
00850   return hr;
00851 }
00852
00853
00854 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00855   Method:   COConnectionPoint::GetConnectionPointContainer
00856
00857   Summary:  The GetConnectionPointContainer member method of this
00858             IConnectionPoint interface implementation. Called to get the
00859             connection point container that contains this connection
00860             point.
00861
00862   Args:     IConnectionPointContainer** ppConnPtCon
00863               Address of the pointer variable that will recieve the
00864               IConnectionPointContainer interface pointer.
00865
00866   Modifies: .
00867
00868   Returns:  HRESULT
00869               Standard result code. NOERROR for success.
00870 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00871 STDMETHODIMP COConnectionPoint::GetConnectionPointContainer(
00872                IConnectionPointContainer** ppConnPtCon)
00873 {
00874   HRESULT hr;
00875
00876   // Use QueryInterface to get the interface pointer and to perform the
00877   // needed AddRef on the returned pointer.
00878   hr = m_pHostObj->QueryInterface(
00879                      IID_IConnectionPointContainer,
00880                      (PPVOID) ppConnPtCon);
00881
00882   return hr;
00883 }
00884
00885
00886 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00887   Method:   COConnectionPoint::Advise
00888
00889   Summary:  The Advise member method of this IConnectionPoint interface
00890             implementation. Called by clients to establish a connection of
00891             their sink to this connection point. Uses the CThreaded
00892             OwnThis mechanism to provide mutually exclusive access by
00893             multiple threads.
00894
00895   Args:     IUnknown* pUnkSink
00896               IUnknown interface pointer of the Sink object in the client.
00897             DWORD* pdwCookie
00898               Pointer to a DWORD in the client that will receive a unique
00899               key used by the client to refer to the connection established
00900               by this Advise call.
00901
00902   Modifies: ...
00903
00904   Returns:  HRESULT
00905               Standard result code. NOERROR for success.
00906 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00907 STDMETHODIMP COConnectionPoint::Advise(
00908                IUnknown* pUnkSink,
00909                DWORD* pdwCookie)
00910 {
00911   HRESULT hr = NOERROR;
00912   UINT uiFreeSlot = 0;
00913   IUnknown* pISink = NULL;
00914
00915   if (OwnThis())
00916   {
00917     // Zero the output connection key.
00918     *pdwCookie = 0;
00919
00920     // Get the specific associated client Sink interface that this
00921     // connection point expects to use for notifications.
00922     hr = pUnkSink->QueryInterface(m_iidSink, (PPVOID)&pISink);
00923     if (SUCCEEDED(hr))
00924     {
00925       // Store the specific sink interface in this connection point's
00926       // array of live connections. First find a free slot (expand the
00927       // array if needed).
00928       hr = GetSlot(&uiFreeSlot);
00929       if (SUCCEEDED(hr))
00930       {
00931         // Assign the new slot with the connection entry.
00932         m_paConnections[uiFreeSlot].pUnk = pISink;
00933         m_paConnections[uiFreeSlot].dwCookie = m_dwNextCookie;
00934
00935         // Assign the output Cookie value.
00936         *pdwCookie = m_dwNextCookie;
00937
00938         // Increment the Cookie counter.
00939         m_dwNextCookie++;
00940
00941         // Increment the number of live connections.
00942         m_cConnections++;
00943       }
00944     }
00945     else if (hr == E_NOINTERFACE)
00946     {
00947        // The sink does not support m_iidSink.
00948        hr = CONNECT_E_CANNOTCONNECT;
00949     }
00950
00951     UnOwnThis();
00952   }
00953
00954   return hr;
00955 }
00956
00957
00958 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00959   Method:   COConnectionPoint::Unadvise
00960
00961   Summary:  The Unadvise member method of this IConnectionPoint interface
00962             implementation. Called by clients to disconnect a connection
00963             of their sink to this connection point. The connection is
00964             identified by the dwCookie argument (obtained by a previous
00965             Advise call). Uses the CThreaded OwnThis mechanism to provide
00966             mutually exclusive access by multiple threads.
00967
00968   Args:     DWORD dwCookie
00969               Connection key that was obtained by a previous Advise call.
00970
00971   Modifies: .
00972
00973   Returns:  HRESULT
00974               Standard result code. NOERROR for success.
00975 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00976 STDMETHODIMP COConnectionPoint::Unadvise(
00977                DWORD dwCookie)
00978 {
00979   HRESULT hr = NOERROR;
00980   UINT uiSlot;
00981
00982   if (0 != dwCookie)
00983   {
00984     if (OwnThis())
00985     {
00986       hr = FindSlot(dwCookie, &uiSlot);
00987       if (SUCCEEDED(hr))
00988       {
00989         // Release the sink interface.
00990         RELEASE_INTERFACE(m_paConnections[uiSlot].pUnk);
00991
00992         // Mark the array entry as empty.
00993         m_paConnections[uiSlot].dwCookie = 0;
00994
00995         // Decrement the number of live connections.
00996         m_cConnections--;
00997       }
00998
00999       UnOwnThis();
01000     }
01001   }
01002   else
01003     hr = E_INVALIDARG;
01004
01005   return hr;
01006 }
01007
01008
01009 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01010   Method:   COConnectionPoint::EnumConnections
01011
01012   Summary:  The EnumConnections member method of this IConnectionPoint
01013             interface implementation. Called to obtain an IEnumConnections
01014             enumerator interface that can be used to enumerate the
01015             connections of this connection point. Uses the CThreaded
01016             OwnThis mechanism to ensure mutually exclusive access by
01017             multiple threads.
01018
01019   Args:     IEnumConnections** ppIEnum
01020               Address of the caller's output pointer variable that will
01021               receive the enumerator IEnumConnections interface pointer.
01022
01023   Modifies: ...
01024
01025   Returns:  HRESULT
01026               Standard result code. NOERROR for success.
01027 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01028 STDMETHODIMP COConnectionPoint::EnumConnections(
01029                IEnumConnections** ppIEnum)
01030 {
01031   HRESULT hr = OLE_E_NOCONNECTION;
01032   CONNECTDATA* paConns;
01033   COEnumConnections* pCOEnum;
01034   UINT i,j;
01035
01036   if (OwnThis())
01037   {
01038     // Zero the output enumerator interface pointer.
01039     *ppIEnum = NULL;
01040
01041     if (0 != m_cConnections)
01042     {
01043       // Create an array of CONNECTDATA structures.
01044       paConns = new CONNECTDATA[(UINT)m_cConnections];
01045       if (NULL != paConns)
01046       {
01047         for (i=0, j=0; i<m_uiMaxIndex && j<m_cConnections; i++)
01048         {
01049           // Copy non-empty entries only.
01050           if (0 != m_paConnections[i].dwCookie)
01051           {
01052             // Assign the occupied entry.
01053             paConns[j].pUnk = (IUnknown*)m_paConnections[i].pUnk;
01054             paConns[j].dwCookie = m_paConnections[i].dwCookie;
01055             j++;
01056           }
01057         }
01058
01059         // Create a new COM object for enumerating connections. Pass
01060         // 'this' as a pHostObj pointer used later to ensure the host
01061         // connection point object stays alive as long as the enumerator
01062         // that enumerates connections to that connection point.
01063         pCOEnum = new COEnumConnections(this);
01064         if (NULL != pCOEnum)
01065         {
01066           // Use the previously constructed (paConns) array of connections
01067           // to init the new COEnumConnections COM object. The Init will
01068           // build yet another internal copy of this array. Set the
01069           // initial enumerator index to 0.
01070           hr = pCOEnum->Init(m_cConnections, paConns, 0);
01071
01072           // QueryInterface to return the requested interface pointer.
01073           // An AddRef will be conveniently done by the QI.
01074           if (SUCCEEDED(hr))
01075             hr = pCOEnum->QueryInterface(
01076                             IID_IEnumConnections,
01077                             (PPVOID)ppIEnum);
01078         }
01079         else
01080           hr = E_OUTOFMEMORY;
01081
01082         // We're done with the locally constructed array copy--delete it.
01083         delete [] paConns;
01084       }
01085       else
01086         hr = E_OUTOFMEMORY;
01087     }
01088
01089     UnOwnThis();
01090   }
01091
01092   return hr;
01093 }
01094
01095
01096 /*---------------------------------------------------------------------------
01097   COEnumConnections's implementation of its main COM object class
01098   including Constructor, Destructor, QueryInterface, AddRef, Release,
01099   Next, Skip, Reset, and Clone.
01100 ---------------------------------------------------------------------------*/
01101
01102 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01103   Method:   COEnumConnections::COEnumConnections
01104
01105   Summary:  COEnumConnections Constructor.
01106
01107   Args:     IUnknown* pHostObj
01108               Pointer to IUnknown interface of the host Connection Point
01109               COM object whose connections are being enumerated.
01110
01111   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnections,
01112             and m_paConnections.
01113
01114   Returns:  void
01115 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01116 COEnumConnections::COEnumConnections(
01117   IUnknown* pHostObj)
01118 {
01119   // Zero the COM object's reference count.
01120   m_cRefs = 0;
01121
01122   // Assign the Host Object pointer.
01123   m_pHostObj = pHostObj;
01124
01125   // Initialize the Connection Point enumerator variables.
01126   m_iEnumIndex = 0;
01127   m_cConnections = 0;
01128   m_paConnections = NULL;
01129
01130   return;
01131 }
01132
01133
01134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01135   Method:   COEnumConnections::~COEnumConnections
01136
01137   Summary:  COEnumConnections Destructor.
01138
01139   Args:     void
01140
01141   Modifies: m_paConnections.
01142
01143   Returns:  void
01144 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01145 COEnumConnections::~COEnumConnections(void)
01146 {
01147   if (NULL != m_paConnections)
01148   {
01149     UINT i;
01150
01151     // Release all the connected sink interface pointers.
01152     for (i=0; i<m_cConnections; i++)
01153       m_paConnections[i].pUnk->Release();
01154
01155     // Delete the array of connections.
01156     delete [] m_paConnections;
01157   }
01158
01159   return;
01160 }
01161
01162
01163 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01164   Method:   COEnumConnections::Init
01165
01166   Summary:  COEnumConnections Initialization method.  Create any
01167             necessary arrays, structures, and objects.
01168
01169   Args:     ULONG cConnections
01170               Number of Connections.
01171             CONNECTDATA* paConnections,
01172               Pointer to array of connections.
01173             ULONG iEnumIndex
01174               The Enumerator index initial value.
01175
01176   Modifies: m_cConnections, m_paConnections, m_pHostObj, m_iEnumIndex.
01177
01178   Returns:  HRESULT
01179               Standard result code. NOERROR for success.
01180 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01181 HRESULT COEnumConnections::Init(
01182           ULONG cConnections,
01183           CONNECTDATA* paConnections,
01184           ULONG iEnumIndex)
01185 {
01186   HRESULT hr = NOERROR;
01187   UINT i;
01188
01189   // Remember the number of live Connections.
01190   m_cConnections = cConnections;
01191
01192   // Remember the initial enumerator index.
01193   m_iEnumIndex = iEnumIndex;
01194
01195   // Create a copy of the array of connections and keep it inside
01196   // this enumerator COM object.
01197   m_paConnections = new CONNECTDATA [(UINT) cConnections];
01198
01199   // Fill the array copy with the connection data from the connections
01200   // array passed. AddRef for each new sink Interface pointer copy made.
01201   if (NULL != m_paConnections)
01202   {
01203     for (i=0; i<cConnections; i++)
01204     {
01205       m_paConnections[i] = paConnections[i];
01206       m_paConnections[i].pUnk->AddRef();
01207     }
01208   }
01209   else
01210     hr = E_OUTOFMEMORY;
01211
01212   return (hr);
01213 }
01214
01215
01216 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01217   Method:   COEnumConnections::QueryInterface
01218
01219   Summary:  QueryInterface of the COEnumConnections non-delegating
01220             IUnknown implementation.
01221
01222   Args:     REFIID riid,
01223               [in] GUID of the Interface being requested.
01224             PPVOID ppv)
01225               [out] Address of the caller's pointer variable that will
01226               receive the requested interface pointer.
01227
01228   Modifies: .
01229
01230   Returns:  HRESULT
01231               Standard result code. NOERROR for success.
01232 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01233 STDMETHODIMP COEnumConnections::QueryInterface(
01234                REFIID riid,
01235                PPVOID ppv)
01236 {
01237   HRESULT hr = E_NOINTERFACE;
01238
01239   *ppv = NULL;
01240
01241   // The IEnumConnections interface is implemented directly in
01242   // this COM object rather than being a nested interface implementation.
01243   if (IID_IUnknown == riid || IID_IEnumConnections == riid)
01244     *ppv = (LPVOID)this;
01245
01246   if (NULL != *ppv)
01247   {
01248     // We've handed out a pointer to the interface so obey the COM rules
01249     // and AddRef the reference count.
01250     ((LPUNKNOWN)*ppv)->AddRef();
01251     hr = NOERROR;
01252   }
01253
01254   return (hr);
01255 }
01256
01257
01258 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01259   Method:   COEnumConnections::AddRef
01260
01261   Summary:  AddRef of the COEnumConnections non-delegating IUnknown
01262             implementation.
01263
01264   Args:     void
01265
01266   Modifies: m_cRefs.
01267
01268   Returns:  ULONG
01269               New value of m_cRefs (COM object's reference count).
01270 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01271 STDMETHODIMP_(ULONG) COEnumConnections::AddRef(void)
01272 {
01273   ULONG cRefs;
01274
01275   cRefs = ++m_cRefs;
01276
01277   // Also AddRef the host object to ensure it stays around as long as
01278   // this enumerator.
01279   m_pHostObj->AddRef();
01280
01281   return cRefs;
01282 }
01283
01284
01285 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01286   Method:   COEnumConnections::Release
01287
01288   Summary:  Release of the COEnumConnections non-delegating IUnknown
01289             implementation.
01290
01291   Args:     void
01292
01293   Modifies: m_cRefs.
01294
01295   Returns:  ULONG
01296               New value of m_cRefs (COM object's reference count).
01297 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01298 STDMETHODIMP_(ULONG) COEnumConnections::Release(void)
01299 {
01300   ULONG cRefs;
01301
01302   // Pass this release along to the Host object being enumerated.
01303   m_pHostObj->Release();
01304
01305   cRefs = --m_cRefs;
01306
01307   if (0 == cRefs)
01308   {
01309     // We artificially bump the main ref count to prevent reentrancy via
01310     // the main object destructor.
01311     m_cRefs++;
01312     delete this;
01313   }
01314
01315   return cRefs;
01316 }
01317
01318
01319 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01320   Method:   COEnumConnections::Next
01321
01322   Summary:  The Next member method of this IEnumConnections interface
01323             implementation. Called by outside clients of a
01324             COEnumConnections object to request a number of next
01325             connections be returned in an array supplied by the caller.
01326
01327   Args:     ULONG cReq
01328               Number of connection points requested for return (starting at
01329               the current Enumerator index).
01330             CONNECTDATA* paConnections,
01331               Pointer to a caller's output array that will receive the
01332               enumerated connection data structures.
01333             ULONG* pcEnumerated)
01334               Pointer to a ULONG variable that will contain the number of
01335               connection points actually enumerated by this call.
01336
01337   Modifies: .
01338
01339   Returns:  HRESULT
01340               Standard result code. NOERROR for success.
01341 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01342 STDMETHODIMP COEnumConnections::Next(
01343                ULONG cReq,
01344                CONNECTDATA* paConnections,
01345                ULONG* pcEnumerated)
01346 {
01347   HRESULT hr = NOERROR;
01348   ULONG cRet = 0;
01349
01350   // Make sure the argument values passed are valid.
01351   if (NULL != m_paConnections)
01352   {
01353     if (NULL != paConnections)
01354     {
01355       if (m_iEnumIndex < m_cConnections)
01356       {
01357         if (NULL != pcEnumerated)
01358           *pcEnumerated = 0L;
01359         else
01360           if (1L != cReq)
01361             hr = E_POINTER;
01362       }
01363       else
01364         hr = S_FALSE;
01365     }
01366     else
01367       hr = E_POINTER;
01368   }
01369   else
01370     hr = S_FALSE;
01371
01372   if (SUCCEEDED(hr))
01373   {
01374     // Starting at the current Enumerator index, loop to assign the
01375     // requested number of output connection data structures.
01376     for (; m_iEnumIndex < m_cConnections && cReq > 0;
01377            paConnections++, m_iEnumIndex++, cRet++, cReq--)
01378     {
01379       // Because we are assigning a copy of a connection's data, AddRef
01380       // its sink interface pointer.
01381       if (NULL != m_paConnections[m_iEnumIndex].pUnk)
01382         m_paConnections[m_iEnumIndex].pUnk->AddRef();
01383
01384       // Assign a connection's data from the inside Enumerator array to
01385       // the specified output receiving array.
01386       *paConnections = m_paConnections[m_iEnumIndex];
01387     }
01388
01389     // Assign the output number of connections enumerated.
01390     if (NULL != pcEnumerated)
01391       *pcEnumerated = cRet;
01392   }
01393
01394   return hr;
01395 }
01396
01397
01398 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01399   Method:   COEnumConnections::Skip
01400
01401   Summary:  The Skip member method of this IEnumConnections interface
01402             implementation. Starting at the current Enumerator index, skip
01403             the specified number of connection items.
01404
01405   Args:     ULONG cSkip
01406               Number of Connection items to skip.
01407
01408   Modifies: .
01409
01410   Returns:  HRESULT
01411               Standard result code. NOERROR for success.
01412 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01413 STDMETHODIMP COEnumConnections::Skip(
01414                ULONG cSkip)
01415 {
01416   HRESULT hr = NOERROR;
01417
01418   // If there really is a connection array and the requested
01419   // amount of skip does not exceed the number of connections,
01420   // then bump the index by the requested skip amount.
01421   if (NULL != m_paConnections && (m_iEnumIndex + cSkip) < m_cConnections)
01422     m_iEnumIndex += cSkip;
01423   else
01424     hr = S_FALSE;
01425
01426   return hr;
01427 }
01428
01429
01430 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01431   Method:   COEnumConnections::Reset
01432
01433   Summary:  The Reset member method of the IEnumConnections interface
01434             implementation. Resets the Enumeration index to the first
01435             connection item in the array.
01436
01437   Args:     void.
01438
01439   Modifies: .
01440
01441   Returns:  HRESULT
01442               Standard result code. NOERROR for success.
01443 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01444 STDMETHODIMP COEnumConnections::Reset(
01445                void)
01446 {
01447   // Zero the main Enumerator index.
01448   m_iEnumIndex = 0;
01449
01450   return NOERROR;
01451 }
01452
01453
01454 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01455   Method:   COEnumConnections::Clone
01456
01457   Summary:  The Clone member method of this IEnumConnections interface
01458             implementation. Creates a new clone of this entire Connection
01459             enumerator COM object and returns a pointer to its
01460             IEnumConnections interface.
01461
01462   Args:     IEnumConnections** ppIEnum
01463               Address of the caller's output pointer variable that will
01464               receive the IEnumConnections interface pointer of the
01465               new enumerator clone.
01466
01467   Modifies: ...
01468
01469   Returns:  HRESULT
01470               Standard result code. NOERROR for success.
01471 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01472 STDMETHODIMP COEnumConnections::Clone(
01473                IEnumConnections** ppIEnum)
01474 {
01475   HRESULT hr;
01476   COEnumConnections* pCOEnum;
01477
01478   // NULL the output variable first.
01479   *ppIEnum = NULL;
01480
01481   // Create the Clone Enumerator COM object.
01482   pCOEnum = new COEnumConnections(m_pHostObj);
01483   if (NULL != pCOEnum)
01484   {
01485     // Initialize it with same values as in this existing enumerator.
01486     hr = pCOEnum->Init(m_cConnections, m_paConnections, m_iEnumIndex);
01487     if (SUCCEEDED(hr))
01488     {
01489       // QueryInterface to return the requested interface pointer.
01490       // An AddRef will be conveniently done by the QI.
01491       if (SUCCEEDED(hr))
01492         hr = pCOEnum->QueryInterface(
01493                         IID_IEnumConnections,
01494                         (PPVOID)ppIEnum);
01495     }
01496   }
01497   else
01498     hr = E_OUTOFMEMORY;
01499
01500   return hr;
01501 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/comp.h Source File

  • SysMgmt
  • MMC
  • Multisel

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023 #include "DataObj.h"
00024
00025 class CComponent : public IComponent, IResultOwnerData
00026 {
00027 private:
00028     ULONG       m_cref;
00029
00030     IConsole          *m_ipConsole;
00031
00032   class CComponentData *m_pParent;
00033     class CDelegationBase *m_pLastNode;
00034
00035     public:
00036         CComponent(CComponentData *pParent);
00037         ~CComponent();
00038
00039         ///////////////////////////////
00040         // Interface IUnknown
00041         ///////////////////////////////
00042         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00043         STDMETHODIMP_(ULONG) AddRef();
00044         STDMETHODIMP_(ULONG) Release();
00045
00046         ///////////////////////////////
00047         // Interface IComponent
00048         ///////////////////////////////
00049         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00050             /* [in] */ LPCONSOLE lpConsole);
00051
00052             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00053             /* [in] */ LPDATAOBJECT lpDataObject,
00054             /* [in] */ MMC_NOTIFY_TYPE event,
00055             /* [in] */ LPARAM arg,
00056             /* [in] */ LPARAM param);
00057
00058             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00059             /* [in] */ MMC_COOKIE cookie);
00060
00061             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00062             /* [in] */ MMC_COOKIE cookie,
00063             /* [in] */ DATA_OBJECT_TYPES type,
00064             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00065
00066             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00067             /* [in] */ MMC_COOKIE cookie,
00068             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00069             /* [out] */ long __RPC_FAR *pViewOptions);
00070
00071             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00073
00074             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075             /* [in] */ LPDATAOBJECT lpDataObjectA,
00076             /* [in] */ LPDATAOBJECT lpDataObjectB);
00077
00078         ///////////////////////////////
00079         // Interface IComponent
00080         ///////////////////////////////
00081             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE FindItem(
00082             /* [in] */ LPRESULTFINDINFO pFindInfo,
00083             /* [out] */ int __RPC_FAR *pnFoundIndex);
00084
00085             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CacheHint(
00086             /* [in] */ int nStartIndex,
00087             /* [in] */ int nEndIndex);
00088
00089             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SortItems(
00090             /* [in] */ int nColumn,
00091             /* [in] */ DWORD dwSortOptions,
00092             /* [in] */ LPARAM lUserParam);
00093
00094     ///////////////////////////////////////////
00095         // Special code for handling multiselection
00096         ///////////////////////////////////////////
00097   public:
00098     HRESULT GetCurrentSelections(CDataObject *pMultiSelectDataObject);
00099     void DisplayMessageBox(CDelegationBase *base);
00100 };
00101
00102 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/isapi/adoisapi.cpp Source File

  • Dataaccess
  • ADO
  • isapi

adoisapi.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft ADO
00003 //
00004 // (c) 1991-2000 Microsoft Corporation.  All Rights Reserved.
00005 //
00006 // @doc
00007 //
00008 // @module  adoisapi.cpp | ADO ISAPI sample application
00009 //
00010 // @devnote None
00011 //--------------------------------------------------------------------
00012
00013 #pragma warning( disable : 4146 )
00014 // defines: ,_MBCS,_USRDLL,ISAPI_EXPORTS
00015 const char *szProgLog = "c:\\AdoIsapi.txt";
00016 #import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
00017 #include <httpext.h>
00018 #include <stdio.h>
00019
00020 VOID PatchQuery(char *szQuery, char **ppszPatchedQuery);
00021 HRESULT FetchData(EXTENSION_CONTROL_BLOCK *pECB);
00022 VOID OutputErrors(EXTENSION_CONTROL_BLOCK *pECB, HRESULT hrError);
00023 VOID OutputString(EXTENSION_CONTROL_BLOCK *pECB, LPCSTR szBuffer);
00024 void DebugLog( const char *szErrStr, const char *FName, const int lNum  ) ;
00025
00026 #ifdef _DEBUG
00027 #define LogError( x )   DebugLog( (x),(__FILE__), (__LINE__))
00028 #else
00029 #define LogError( x )
00030 #endif
00031
00032 // Connection String for Microsoft Jet Database
00033 //const PCSTR g_pszConnection = "dsn=OLE_DB_NWind_Jet;uid=Admin;pwd=;";
00034
00035 // Connection String for Microsoft SQL Server Database
00036 const PCSTR g_pszConnection = "Provider=SQLOLEDB;data source=YOUR SERVER NAME;initial catalog=northwind;uid=YOUR USER ID;pwd=YOUR USER's PASSWORD;";
00037
00038
00039 BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
00040 {
00041     // Initialize COM
00042     CoInitialize(NULL);
00043     LogError("GetExtensionVersion()");
00044
00045   pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR, HSE_VERSION_MAJOR );
00046
00047   lstrcpynA( pVer->lpszExtensionDesc, "Sample ADO ISAPI Application", HSE_MAX_EXT_DLL_NAME_LEN );
00048
00049   return TRUE;
00050 } // end -- BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
00051
00052 BOOL WINAPI TerminateExtension(  DWORD dwFlags  )
00053 {
00054     // Unregister COM
00055     CoUninitialize();
00056     return TRUE;
00057 } // end -- BOOL WINAPI TerminateExtension(  DWORD dwFlags  )
00058
00059
00060 DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB )
00061 {
00062   DWORD dwWritten;
00063   char  szContent[] = "Content-type: text/html\r\n\r\n";
00064     LogError("HttpExtensionProc() -- entry");
00065   dwWritten = sizeof(szContent);
00066     pECB->ServerSupportFunction (pECB->ConnID,
00067                                  HSE_REQ_SEND_RESPONSE_HEADER,
00068                                  NULL,
00069                                  &dwWritten,
00070                                  (LPDWORD)szContent);
00071
00072   if (FAILED(FetchData(pECB)))
00073     {
00074         LogError("HttpExtensionProc() -- Failed...");
00075     return HSE_STATUS_ERROR;
00076     }
00077   else
00078     {
00079         LogError("HttpExtensionProc() -- Successful...");
00080     return HSE_STATUS_SUCCESS;
00081     }
00082 } // end -- DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB )
00083
00084 char ConvertHexToDec(char cHex)
00085 {
00086   if ((toupper(cHex) >= 'A') && (toupper(cHex) <= 'F'))
00087     return cHex - 'A' + 10;
00088   else
00089     return cHex - '0';
00090 } // end -- char ConvertHexToDec(char cHex)
00091
00092 // Hack to clean up the query string. This code will work
00093 // for most, but not all cases. For instance when the query
00094 // string has embedded '+', this code will not work.
00095 VOID PatchQuery(char *szQuery, char **ppszPatchedQuery)
00096 {
00097   char *p = szQuery + 1;
00098
00099   while (*p++)
00100   {
00101     if (*p == '+') //replace '+' by ' '
00102         {
00103             *p = ' ';
00104         }
00105
00106     if( *p == '%' ) //a number begins
00107     {
00108       char ch;
00109
00110       if (*++p)
00111       {
00112         ch = ConvertHexToDec(*p) << 4; //convert the first digit
00113
00114         if (*++p)
00115         {
00116           ch |= ConvertHexToDec(*p);  //convert the 2nd digit
00117
00118           if (!*(p + 1))
00119           {
00120             *(p-2) = ch;
00121             *(p-1) = '\0';
00122             break;
00123           }
00124           else
00125           {
00126             *(p-2) = ' ';
00127             *(p-1) = ' ';
00128             *p = ch;
00129           }
00130         }
00131       }
00132     }
00133   }
00134
00135   *ppszPatchedQuery = szQuery + 1;
00136     return;
00137 }   // end -- VOID PatchQuery(char *szQuery, char **ppszPatchedQuery)
00138
00139 VOID OutputString(EXTENSION_CONTROL_BLOCK *pECB, LPCSTR szBuffer)
00140 {
00141   DWORD dwBuffer = strlen(szBuffer);
00142   pECB->WriteClient(pECB->ConnID, (PVOID) szBuffer, &dwBuffer, 0);
00143
00144     // for debugging we save the output to a file if _DEBUG is defined...
00145     LogError(szBuffer);
00146 } // end -- VOID OutputString(EXTENSION_CONTROL_BLOCK *pECB, LPCSTR szBuffer)
00147
00148 VOID OutputErrors(EXTENSION_CONTROL_BLOCK *pECB, _com_error &e)
00149 {
00150   char    szBuffer[512];
00151
00152   // output hresult
00153   OutputString(pECB, "<P><H1>Error Fetching Data</H1>");
00154
00155   sprintf(szBuffer, "<p>Code = %08lx", e.Error());
00156   OutputString(pECB, szBuffer);
00157
00158     sprintf(szBuffer, "<p>Code meaning = %s", e.ErrorMessage());
00159     OutputString(pECB, szBuffer);
00160
00161   _bstr_t bstrSource(e.Source());
00162     sprintf(szBuffer, "<p>Source = %s", (LPCSTR) bstrSource);
00163   OutputString(pECB, szBuffer);
00164
00165   _bstr_t bstrDescription(e.Description());
00166     sprintf(szBuffer, "<p>Description = %s", (LPCSTR) bstrDescription);
00167   OutputString(pECB, szBuffer);
00168
00169   return;
00170 } // end -- VOID OutputErrors(EXTENSION_CONTROL_BLOCK *pECB, _com_error &e)
00171
00172 HRESULT FetchData(EXTENSION_CONTROL_BLOCK *pECB)
00173 {
00174   HRESULT     hr = NOERROR;
00175   bool      fComInitialized = false;
00176   _RecordsetPtr pRs = NULL;
00177     _ConnectionPtr  pConn = NULL;
00178   FieldPtr    *rgflds = NULL;
00179   long      lNumFields, lFld;
00180   char      *pszPatchedQuery, *pszQueryPtr;
00181   _variant_t    vValue;
00182
00183   OutputString(pECB, "<HEAD><TITLE>Query Results"
00184             "</TITLE></HEAD>\r\n<BODY>\r\n");
00185
00186   OutputString(pECB, "<LINK REL=\"STYLESHEET\" HREF=\"..\\ADOStyle.css\">\r\n");
00187
00188   // Updated Code to support IE 4 semantics requiring controls passed as parameters to be named
00189   // Search for the new parameter "Query=" in the string, and then use PatchQuery starting at the
00190   // equals sign.  Note: If other parameters are passed as part of the form, this code needs to
00191   // be updated to find the end of the parameter and not use the entire rest of the lpszQueryString
00192   pszQueryPtr = strstr(pECB->lpszQueryString, "Query=") + strlen("Query=") - 1;
00193   PatchQuery(pszQueryPtr, &pszPatchedQuery);
00194
00195   OutputString(pECB, "<P><H2>Query String</H2>");
00196   OutputString(pECB, pszPatchedQuery);
00197   LogError(pszPatchedQuery);
00198   try
00199   {
00200     if (FAILED(hr = ::CoInitialize(NULL)))
00201         {
00202             _com_issue_error(hr);
00203         }
00204
00205     fComInitialized = true;
00206
00207         // Create the connection object
00208         pConn.CreateInstance(__uuidof(Connection ));
00209         LogError( "Create Connetion object fine...");
00210         pConn->ConnectionString  = g_pszConnection;
00211         pConn->Open("","","",-1);
00212         LogError( "Opened Connetion object fine...");
00213     // Open the recordset
00214     pRs.CreateInstance(__uuidof(Recordset) );
00215         LogError( "Created  Recordset object fine...");
00216         pRs->PutRefActiveConnection(pConn);
00217         LogError( "Set Referend from Rs to Conn");
00218     pRs->Open(pszPatchedQuery, vtMissing, adOpenForwardOnly, adLockReadOnly, adCmdUnknown);
00219         LogError( "Opended Recordset object fine...");
00220     lNumFields = pRs->Fields->Count;
00221
00222     rgflds = new FieldPtr[lNumFields];
00223     if (!rgflds)
00224         {
00225             _com_issue_error(E_OUTOFMEMORY);
00226         }
00227     memset(rgflds, 0, lNumFields * sizeof(FieldPtr));
00228
00229     for (lFld = 0; lFld < lNumFields; lFld++)
00230         {
00231             rgflds[lFld] = pRs->Fields->GetItem(lFld);
00232         }
00233
00234     OutputString(pECB, "<P><H2>Query Results</H2>");
00235     OutputString(pECB, "<P><TABLE BORDER=1 CELLSPACING=4>");
00236
00237     //
00238     // print column names
00239     //
00240     OutputString(pECB, "<TR>");
00241
00242     for (lFld = 0; lFld < lNumFields; lFld++)
00243     {
00244       OutputString(pECB, "<TH>");
00245       OutputString(pECB, (PCSTR)(_bstr_t)rgflds[lFld]->Name);
00246     }
00247
00248     //
00249     // print data
00250     //
00251     while (VARIANT_FALSE == pRs->EndOfFile)
00252     {
00253       OutputString(pECB, "<TR>");
00254
00255       for (lFld = 0; lFld < lNumFields; lFld++)
00256       {
00257         OutputString(pECB, "<TD>");
00258
00259         vValue = rgflds[lFld]->Value;
00260         if (VT_NULL == vValue.vt)
00261           OutputString(pECB, "(Null)");
00262         else
00263           OutputString(pECB, (PCSTR)(_bstr_t)vValue);
00264       }
00265
00266       OutputString(pECB, "</TR>");
00267
00268       pRs->MoveNext();
00269     }
00270
00271     OutputString(pECB, "</TABLE>");
00272     OutputString(pECB, "</BODY>\r\n");
00273   }
00274   catch (_com_error &e)
00275   {
00276     OutputErrors(pECB, e);
00277     hr = e.Error();
00278   }
00279
00280   if (rgflds)
00281       delete[] rgflds;
00282
00283   pRs = NULL;
00284
00285   if (fComInitialized)
00286     {
00287         ::CoUninitialize();
00288     }
00289
00290   OutputString(pECB, "</BODY>\r\n");
00291
00292   return hr;
00293
00294 } // end -- HRESULT FetchData(EXTENSION_CONTROL_BLOCK *pECB)
00295
00296 void DebugLog( const char *szErrStr ,const char *FName, const int lNum  )
00297 {
00298     FILE *fp;
00299     if( (fp=fopen(szProgLog,"at+")) == NULL )
00300     {
00301         return ;
00302     }
00303
00304     fprintf(fp,"Error %s (%d): %s\n",FName,lNum,szErrStr );
00305     fclose(fp);
00306
00307 } //  end -- void DebugLog( const char *szErrStr ,const char *FName, const int lNum  )
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/common/rureg.cpp Source File

  • NetDS
  • RRas
  • rqs
  • common

rureg.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       RuReg.cpp
00004 //
00005 //      Synopsis:   Registry manipulating api's
00006 //
00007 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //+--------------------------------------------------------------------------
00010
00011 #include "RasUtil.h"
00012 #include <shlwapi.h>
00013
00014 /*****************************************************************************
00015                     Prefix in pszKeyPath
00016 -----------------------------------------------------------------------------
00017 (1)pszKeyPath specifies the location of the registry key to edit
00018 (2)for predefined registry categories:
00019
00020         HKEY_CLASSES_ROOT
00021         HKEY_CURRENT_CONFIG
00022         HKEY_CURRENT_USER
00023         HKEY_LOCAL_MACHINE
00024         HKEY_USERS
00025
00026         HKLM
00027         HKCU
00028     We use the same name in the pszKeyPath. Example:
00029      L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Tracing\\RASDLG"
00030 *****************************************************************************/
00031
00032 typedef struct _RURASREGROOT
00033 {
00034        PWSTR pszName;
00035        HKEY  hkRegRoot;
00036 }RURASREGROOT;
00037
00038
00039 static const RURASREGROOT g_ruRegRoot[]=
00040     {
00041        {L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT},
00042        {L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG},
00043        {L"HKEY_CURRENT_USER", HKEY_CURRENT_USER},
00044        {L"HKCU",HKEY_CURRENT_USER},
00045        {L"HKEY_LOCAL_MACHINE",HKEY_LOCAL_MACHINE},
00046        {L"HKLM",HKEY_LOCAL_MACHINE},
00047        {L"HKEY_USERS",HKEY_USERS}
00048     };
00049
00050 #ifndef RURASREGROOTNUM
00051 #define RURASREGROOTNUM    RU_ELEMENT_COUNT(g_ruRegRoot)
00052 #endif
00053
00054
00055 //+----------------------------------------------------------------------------
00056 //
00057 // Synopsis: Internal function, parse the input registry key path
00058 //
00059 //-----------------------------------------------------------------------------
00060 static
00061 HRESULT
00062 RuGetRegRootIndex(
00063     IN CONST PWSTR pszKeyPath,
00064     OUT HKEY * phKey,
00065     OUT PWSTR * ppszSubPath
00066     )
00067 {
00068     int i;
00069     HRESULT hr = S_OK;
00070
00071     do
00072     {
00073         if ( NULL == pszKeyPath ||
00074              NULL == phKey      ||
00075              NULL == ppszSubPath )
00076         {
00077             hr = E_INVALIDARG;
00078             break;
00079         }
00080
00081         for( i = 0; i < RURASREGROOTNUM; i++ )
00082         {
00083             if( pszKeyPath == wcsstr( pszKeyPath, g_ruRegRoot[i].pszName))
00084             {
00085                 // The key path should include '\' and at leat one more
00086                 // character
00087                 if( wcslen(pszKeyPath) <= 2 + wcslen( g_ruRegRoot[i].pszName ) )
00088                 {
00089                     hr = E_INVALIDARG;
00090                     break;
00091                 }
00092
00093                 *phKey = g_ruRegRoot[i].hkRegRoot;
00094                 *ppszSubPath = pszKeyPath + wcslen(g_ruRegRoot[i].pszName)+1;
00095                 hr = S_OK;
00096                 break;
00097             }
00098         }
00099     }
00100     while(FALSE);
00101
00102     return hr;
00103 }
00104
00105 //+----------------------------------------------------------------------------
00106 //
00107 // Synopsis: Returns an open registry key at the given path.  In general, the
00108 //           RuReg* functions are supposed to abstract this key.  However, some
00109 //           Api's and applications require that the key itself be passed.
00110 //           This function is only to be used in those rare situations.
00111 //
00112 //           This function is also used by other RuReg* functions to open the
00113 //           registry key.
00114 //
00115 //-----------------------------------------------------------------------------
00116 HRESULT
00117 RuRegOpenKey(
00118     IN CONST PWSTR pszKeyPath,
00119     IN BOOL fCreate,
00120     OUT HKEY* phKey)
00121 {
00122     HRESULT hr;
00123     HKEY hkRoot = NULL;
00124     PWSTR pszSubPath = NULL;
00125
00126     hr = RuGetRegRootIndex(pszKeyPath, &hkRoot, &pszSubPath);
00127     if (hr != S_OK)
00128     {
00129         return hr;
00130     }
00131
00132     if (fCreate)
00133     {
00134         hr = RegCreateKeyExW(
00135                      hkRoot,
00136                      pszSubPath,
00137                      0,
00138                      NULL,
00139                      REG_OPTION_NON_VOLATILE,
00140                      KEY_ALL_ACCESS,
00141                      NULL,
00142                      phKey,
00143                      NULL
00144                      );
00145     }
00146     else
00147     {
00148         hr = RegOpenKeyExW(
00149                     hkRoot,
00150                     pszSubPath,
00151                     0,
00152                     KEY_ALL_ACCESS,
00153                     phKey);
00154     }
00155
00156     if( S_OK != hr )
00157     {
00158         hr = HRESULT_FROM_WIN32(hr);
00159     }
00160
00161     return hr;
00162 }
00163
00164 //+----------------------------------------------------------------------------
00165 //
00166 // Synopsis: retrieve value/values under a registry key
00167 //
00168 //  ret: The function returns S_OK if at least one value was successfully read.
00169 //       Each value contains an error code field that is set to indicate status.
00170 //
00171 //  (1)
00172 //  Get the value/values under a specific registry key, if succeeded, the
00173 //  function will allocate memory to store data and store the memory pointer in
00174 //  pRegVal[i].pbData, it is the caller's responsibility to free the allocated
00175 //  memory by calling RuFree() or RuRegFreeValues()
00176 //  (2)
00177 //  if return Value is not NO_ERROR, uiSize in pRegVal will
00178 //  be set to 0 and pbData in pRegVal will be set to NULL
00179 //
00180 //-----------------------------------------------------------------------------
00181 HRESULT
00182 RuRegGet(
00183     IN CONST PWSTR pszKeyPath,
00184     IN OUT RUREGVALUE * pRegVal,
00185     IN DWORD dwCount
00186     )
00187 {
00188     HKEY hKey=0L;
00189     DWORD i, iSuccess;
00190     DWORD dwErr = NO_ERROR;
00191     HRESULT hr;
00192
00193     do
00194     {
00195         if( NULL == pszKeyPath ||
00196             NULL == pRegVal    ||
00197             0 == dwCount )
00198         {
00199             hr = E_INVALIDARG;
00200             break;
00201         }
00202
00203         hr = RuRegOpenKey(pszKeyPath, FALSE, &hKey);
00204         RU_BREAK_IF_NOT_OK(hr);
00205
00206         for( i = 0; i < dwCount; i++)
00207         {
00208             pRegVal[i].dwSize = 0L;
00209             pRegVal[i].pbData = NULL;
00210         }
00211
00212         iSuccess = 0;
00213         for ( i = 0; i < dwCount; i++ )
00214         {
00215             //Get the size of the data
00216             //
00217             pRegVal[i].pbData = NULL;
00218             dwErr = RegQueryValueExW(
00219                         hKey,
00220                         pRegVal[i].pszName,
00221                         0,
00222                         &pRegVal[i].dwType,
00223                         NULL,
00224                         &pRegVal[i].dwSize
00225                         );
00226             if( ERROR_SUCCESS != dwErr )
00227             {
00228                 pRegVal[i].hr = HRESULT_FROM_WIN32(dwErr);
00229                 continue;
00230             }
00231
00232             pRegVal[i].pbData = (BYTE*)RuAlloc(pRegVal[i].dwSize,0);
00233             if( NULL == pRegVal[i].pbData)
00234             {
00235                 pRegVal[i].hr = E_OUTOFMEMORY;
00236                 continue;
00237             }
00238
00239             dwErr = RegQueryValueExW(
00240                 hKey,
00241                 pRegVal[i].pszName,
00242                 0,
00243                 &pRegVal[i].dwType,
00244                 pRegVal[i].pbData,
00245                 &pRegVal[i].dwSize
00246                 );
00247
00248             if( ERROR_SUCCESS != dwErr)
00249             {
00250                 pRegVal[i].hr = HRESULT_FROM_WIN32(dwErr);
00251                 continue;
00252             }
00253
00254             iSuccess++;
00255         }
00256
00257         // If nothing was successfully read, then return the error code from
00258         // the first value
00259         //
00260         if (iSuccess == 0)
00261         {
00262             hr = pRegVal[0].hr;
00263         }
00264         else
00265         {
00266             hr = S_OK;
00267         }
00268
00269     }
00270     while(FALSE);
00271
00272     if(hKey)
00273     {
00274         RegCloseKey(hKey);
00275     }
00276
00277     return hr;
00278 }
00279
00280 //+----------------------------------------------------------------------------
00281 //
00282 // Synopsis: Simple helper function frees an array of values returned by
00283 //           RuRegGet.
00284 //
00285 //-----------------------------------------------------------------------------
00286 VOID
00287 RuRegFreeValues(
00288     IN CONST RUREGVALUE* pValues,
00289     IN UINT uiCount)
00290 {
00291     UINT i;
00292
00293     for (i = 0; i < uiCount; i++)
00294     {
00295         if (pValues[i].pbData)
00296         {
00297             RuFree(pValues[i].pbData);
00298         }
00299     }
00300 }
00301
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

AboutDlg Member List

This is the complete list of members for AboutDlg, including all inherited members.
AboutDlg() | AboutDlg |
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | AboutDlg | [friend]
DoModal(HWND hWndParent, short sAgentVersionMajor, short sAgentVersionMinor) | AboutDlg |
m_hIcon | AboutDlg | [private]
m_hWnd | AboutDlg | [private]
m_rcIcon | AboutDlg | [private]
m_sAgentMajor | AboutDlg | [private]
m_sAgentMinor | AboutDlg | [private]
OnInitDialog() | AboutDlg | [private]
~AboutDlg() | AboutDlg |
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/Globals.h Source File

  • NetDS
  • WinSock
  • IpxChat

Globals.h

Go to the documentation of this file.
00001 #ifndef _GLOBAL_H_
00002 #define _GLOBAL_H_
00003
00004 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00005 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00006 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00007 // PARTICULAR PURPOSE.
00008 //
00009 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00010 //
00011 // PURPOSE:
00012 //    Contains declarations for all globally scoped names in the program.
00013 //
00014
00015 //-------------------------------------------------------------------------
00016 // Product identifier string defines
00017
00018 // #define APPNAME       IPXChat
00019 // #define SZVERSION     "Version 4.0"
00020
00021 #include <winsock2.h>
00022 #include <wsipx.h>
00023 #define STRSAFE_LIB
00024 #include <strsafe.h>
00025
00026 //-------------------------------------------------------------------------
00027 // Functions for handling main window messages.  The message-dispatching
00028 // mechanism expects all message-handling functions to have the following
00029 // prototype:
00030 //
00031 //     LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);
00032
00033 LRESULT MsgCreate(HWND, UINT, WPARAM, LPARAM);
00034 LRESULT MsgSize(HWND, UINT, WPARAM, LPARAM);
00035 LRESULT MsgSetfocus(HWND, UINT, WPARAM, LPARAM);
00036 LRESULT MsgCommand(HWND, UINT, WPARAM, LPARAM);
00037 LRESULT MsgDataready(HWND, UINT, WPARAM, LPARAM);
00038 LRESULT MsgRefreshdisplay(HWND, UINT, WPARAM, LPARAM);
00039 LRESULT MsgDisconnected(HWND, UINT, WPARAM, LPARAM);
00040 LRESULT MsgDestroy(HWND, UINT, WPARAM, LPARAM);
00041
00042
00043 //-------------------------------------------------------------------------
00044 // Functions for handling main window commands--ie. functions for
00045 // processing WM_COMMAND messages based on the wParam value.
00046 // The message-dispatching mechanism expects all command-handling
00047 // functions to have the following prototype:
00048 //
00049 //     LRESULT FunctionName(HWND, WORD, WORD, HWND);
00050
00051 LRESULT CmdConnect(HWND, WORD, WORD, HWND);
00052 LRESULT CmdListen(HWND, WORD, WORD, HWND);
00053 LRESULT CmdExit(HWND, WORD, WORD, HWND);
00054 LRESULT CmdAbout(HWND, WORD, WORD, HWND);
00055 LRESULT CmdOutbox(HWND, WORD, WORD, HWND);
00056 LRESULT CmdDisconnect(HWND, WORD, WORD, HWND);
00057
00058
00059 //-------------------------------------------------------------------------
00060 // Global function prototypes.
00061
00062 BOOL InitApplication(HINSTANCE, int);
00063 BOOL CenterWindow(HWND, HWND);
00064 BOOL ReceiveInBox(HWND, WPARAM, LPARAM, char *, int);
00065 void SendOutBox(char *, int);
00066 void AtoH(char *, char *, int);
00067 unsigned char BtoH(char);
00068 void CleanUp(void);
00069 void GetAddrString(PSOCKADDR_IPX, char *);
00070 void HtoA(char *, char *, int);
00071 char HtoB(UCHAR);
00072 LPTSTR GetStringRes (int id);
00073
00074 // Callback functions.  These are called by Windows.
00075
00076 // **TODO**  Add new callback function prototypes here.
00077
00078 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
00079
00080
00081 //-------------------------------------------------------------------------
00082 // Command ID definitions.  These definitions are used to associate menu
00083 // items with commands.
00084
00085 // Options menu
00086 #define IDM_CONNECT    1000
00087 #define IDM_LISTEN     1001
00088 #define IDM_DISCONNECT 1002
00089 #define IDM_EXIT       1003
00090
00091 // Help menu
00092 #define IDM_ABOUT      1100
00093
00094 //-------------------------------------------------------------------------
00095 // User Defined Messages.  These definitions are used for indicating
00096 // network events.
00097
00098 #define MW_DATAREADY       501
00099 #define MW_DISPLAYREFRESH  502
00100 #define MW_DISCONNECTED    503
00101 #define LDM_CONNECTED      504
00102
00103 //-------------------------------------------------------------------------
00104 // String Table ID definitions.
00105
00106 #define IDS_APPNAME     1
00107 #define IDS_DESCRIPTION 2
00108
00109 //-------------------------------------------------------------------------
00110 //  Main Window Edit Control defines.
00111
00112 #define ID_OUTBOX          601
00113 #define ID_INBOX           602
00114
00115 //-------------------------------------------------------------------------
00116 //  About dialog defines.
00117
00118 #define IDD_VERFIRST    100
00119 #define IDD_VERLAST     104
00120
00121 //-------------------------------------------------------------------------
00122 //  Connect dialog defines.
00123
00124 #define CD_STATUS       200
00125 #define CD_NETWORK      201
00126 #define CD_NODE         202
00127 #define CD_SOCKET       203
00128
00129 //-------------------------------------------------------------------------
00130 //  Listen dialog defines.
00131
00132 #define LD_SOCKET       300
00133 #define LD_STATUS       301
00134
00135 //-------------------------------------------------------------------------
00136 // Global variable declarations.
00137
00138 extern HINSTANCE hInst;          // The current instance handle
00139 extern char      szAppName[];    // The name of this application
00140 extern char      szTitle[];      // The title bar text
00141 SOCKET sock, SrvSock;
00142 SOCKADDR_IPX RemAddr;
00143 PSOCKADDR_IPX pSockAddr, pRemAddr;
00144 struct sockaddr addr;
00145 int addrlen;
00146 HWND hOutWnd, hInWnd;
00147 char szRcvBuf[0x8000];
00148 char szSndBuf[0x8000];
00149 extern char szConnectNetwork[];
00150 extern char szConnectNode[];
00151 extern char szConnectSocket[];
00152 extern char szListenSocket[];
00153 extern BOOL i_should_sleep;
00154
00155 // For NON-MDI applications, uncomment line 1 below and comment
00156 // line 2.  For MDI applications, uncomment line 2 below, comment
00157 // line 1, and then define hwndMDIIPXChat as a global variable in
00158 // INIT.C
00159 #define hwndMDIIPXChat NULL        /* (1) Stub for NON-MDI applications. */
00160 // extern HWND hwndMDIIPXChat;     /* (2) For MDI applications.          */
00161
00162
00163 //-------------------------------------------------------------------------
00164 // Message and command dispatch infrastructure.  The following type
00165 // definitions and functions are used by the message and command dispatching
00166 // mechanism and do not need to be changed.
00167
00168     // Function pointer prototype for message handling functions.
00169 typedef LRESULT (*PFNMSG)(HWND,UINT,WPARAM,LPARAM);
00170
00171     // Function pointer prototype for command handling functions.
00172 typedef LRESULT (*PFNCMD)(HWND,WORD,WORD,HWND);
00173
00174     // Enumerated type used to determine which default window procedure
00175     // should be called by the message- and command-dispatching mechanism
00176     // if a message or command is not handled explicitly.
00177 typedef enum
00178 {
00179    edwpNone,            // Do not call any default procedure.
00180    edwpWindow,          // Call DefWindowProc.
00181    edwpDialog,          // Call DefDlgProc (This should be used only for
00182                         // custom dialogs - standard dialog use edwpNone).
00183    edwpMDIChild,        // Call DefMDIChildProc.
00184    edwpMDIFrame         // Call DefFrameProc.
00185 } EDWP;                // Enumeration for Default Window Procedures
00186
00187     // This structure maps messages to message handling functions.
00188 typedef struct _MSD
00189 {
00190     UINT   uMessage;
00191     PFNMSG pfnmsg;
00192 } MSD;                 // MeSsage Dispatch structure
00193
00194     // This structure contains all of the information that a window
00195     // procedure passes to DispMessage in order to define the message
00196     // dispatching behavior for the window.
00197 typedef struct _MSDI
00198 {
00199     int  cmsd;          // Number of message dispatch structs in rgmsd
00200     MSD *rgmsd;         // Table of message dispatch structures
00201     EDWP edwp;          // Type of default window handler needed.
00202 } MSDI, FAR *LPMSDI;   // MeSsage Dipatch Information
00203
00204     // This structure maps command IDs to command handling functions.
00205 typedef struct _CMD
00206 {
00207     WORD   wCommand;
00208     PFNCMD pfncmd;
00209 } CMD;                 // CoMmand Dispatch structure
00210
00211     // This structure contains all of the information that a command
00212     // message procedure passes to DispCommand in order to define the
00213     // command dispatching behavior for the window.
00214 typedef struct _CMDI
00215 {
00216     int  ccmd;          // Number of command dispatch structs in rgcmd
00217     CMD *rgcmd;         // Table of command dispatch structures
00218     EDWP edwp;          // Type of default window handler needed.
00219 } CMDI, FAR *LPCMDI;   // CoMmand Dispatch Information
00220
00221     // Message and command dispatching functions.  They look up messages
00222     // and commands in the dispatch tables and call the appropriate handler
00223     // function.
00224 LRESULT DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM);
00225 LRESULT DispCommand(LPCMDI, HWND, WPARAM, LPARAM);
00226
00227     // Message dispatch information for the main window
00228 extern MSDI msdiMain;
00229     // Command dispatch information for the main window
00230 extern CMDI cmdiMain;
00231
00232
00233
00234 //-------------------------------------------------------------------------
00235 // Version string definitions--Leave these alone.
00236
00237 #define SZRCOMPANYNAME "CompanyName"
00238 #define SZRDESCRIPTION "FileDescription"
00239 #define SZRVERSION     "FileVersion"
00240 #define SZRAPPNAME     "InternalName"
00241 #define SZRCOPYRIGHT   "LegalCopyright"
00242 #define SZRTRADEMARK   "LegalTrademarks"
00243 #define SZRPRODNAME    "ProductName"
00244 #define SZRPRODVER     "ProuctVersion"
00245
00246 #endif
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • ActiveX

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030         static TCHAR error[64];
00031
00032         switch (verb) {
00033     case MMC_VERB_NONE:
00034                 return _T("NONE");
00035     case MMC_VERB_OPEN:
00036                 return _T("OPEN");
00037     case MMC_VERB_COPY:
00038                 return _T("COPY");
00039     case MMC_VERB_PASTE:
00040                 return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042                 return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044                 return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046                 return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048                 return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050                 return _T("PRINT");
00051     case MMC_VERB_CUT:
00052                 return _T("CUT");
00053         default:
00054                 wsprintf(error, _T("Unknown verb id %d"), verb);
00055                 return error;
00056         }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061                                 IComponentData *pCompData,
00062                                 IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064                                 LPARAM arg,
00065                                 LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069         TCHAR message[cchMessage] = {0};
00070
00071         if (bComponentData == TRUE)
00072                 OutputDebugString(_T("IComponentData::Notify( "));
00073         else
00074                 OutputDebugString(_T("IComponent::Notify( "));
00075
00076         wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077         OutputDebugString(message);
00078
00079     switch (event)      {
00080                 case MMCN_ACTIVATE:
00081                         wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082                         break;
00083
00084                 case MMCN_ADD_IMAGES:
00085                         wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086                         break;
00087
00088                 case MMCN_BTN_CLICK:
00089                         wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090                         break;
00091
00092                 case MMCN_COLUMN_CLICK:
00093                         wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,       param);
00094                         break;
00095
00096                 case MMCN_COLUMNS_CHANGED:
00097                         wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098                         break;
00099
00100                 case MMCN_CONTEXTHELP:
00101                         wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102                         break;
00103
00104                 case MMCN_CONTEXTMENU:
00105                         wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106                         break;
00107
00108                 case MMCN_CUTORMOVE:
00109                         wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110                         break;
00111
00112                 case MMCN_DBLCLICK:
00113                         wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114                         break;
00115
00116                 case MMCN_DELETE:
00117                         wsprintf(message, _T("MMCN_DELETE\n"));
00118                         break;
00119
00120                 case MMCN_DESELECT_ALL:
00121                         wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122                         break;
00123
00124                 case MMCN_EXPAND:
00125                         wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126                         break;
00127
00128                 case MMCN_EXPANDSYNC:
00129                         wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130                         break;
00131
00132                 case MMCN_FILTERBTN_CLICK:
00133                         wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134                         break;
00135
00136                 case MMCN_FILTER_CHANGE:
00137                         wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138                         break;
00139
00140                 case MMCN_HELP:
00141                         wsprintf(message, _T("MMCN_HELP\n"));
00142                         break;
00143
00144                 case MMCN_INITOCX:
00145                         wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146                         break;
00147
00148                 case MMCN_LISTPAD:
00149                         wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150                         break;
00151
00152                 case MMCN_MENU_BTNCLICK:
00153                         wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154                         break;
00155
00156                 case MMCN_MINIMIZED:
00157                         wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158                         break;
00159
00160                 case MMCN_PASTE:
00161                         wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162                         break;
00163
00164                 case MMCN_PRELOAD:
00165                         wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166                         break;
00167
00168                 case MMCN_PRINT:
00169                         wsprintf(message, _T("MMCN_PRINT\n"));
00170                         break;
00171
00172                 case MMCN_PROPERTY_CHANGE:
00173                         wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174                         break;
00175
00176                 case MMCN_QUERY_PASTE:
00177                         wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178                         break;
00179
00180                 case MMCN_REFRESH:
00181                         wsprintf(message, _T("MMCN_REFRESH\n"));
00182                         break;
00183
00184                 case MMCN_REMOVE_CHILDREN:
00185                         wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186                         break;
00187
00188                 case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192                         StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193                         break;
00194
00195                 case MMCN_RESTORE_VIEW:
00196                         wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197                         break;
00198
00199                 case MMCN_SELECT:
00200                         wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201                         break;
00202
00203                 case MMCN_SHOW:
00204                         wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205                         break;
00206
00207                 case MMCN_SNAPINHELP:
00208                         wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209                         break;
00210
00211                 case MMCN_VIEW_CHANGE:
00212                         wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213                         break;
00214         }
00215
00216         if (message[0] != 0)
00217                 OutputDebugString(message);
00218         else
00219                 OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222         return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Read/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Read
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__81C9A520_AF2E_11D2_9A73_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__81C9A520_AF2E_11D2_9A73_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__81C9A520_AF2E_11D2_9A73_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocServe/UtilCAR.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocServe

UtilCAR.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      UTILCAR.H
00003
00004   Summary:   Include file for the aggregatable COUtilityCar COM object
00005              class.
00006
00007              UTILCAR showcases the construction of the COUtilityCar COM
00008              object class with the IUnknown, ICar, and IUtility
00009              interfaces. This is done through Containment reuse of COCar's
00010              ICar interface features.
00011
00012              This multiple interface COM Object Class is achieved via the
00013              technique of nested classes: the implementation of the ICar
00014              and IUtility interfaces are nested inside of the COUtilityCar
00015              COM object class.
00016
00017              For a comprehensive tutorial code tour of this module's
00018              contents and offerings see the tutorial LOCSERVE.HTM
00019              file. For more specific technical details on the internal
00020              workings see the comments dispersed throughout the module's
00021              source code.
00022
00023   Classes:   COUtilityCar
00024
00025   Functions: .
00026
00027   Origin:    11-14-95: atrent - Editor-inheritance from UTILCAR.H in
00028                the DLLSERVE Tutorial Code Sample.
00029
00030 ----------------------------------------------------------------------------
00031   This file is part of the Microsoft COM Tutorial Code Samples.
00032
00033   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00034
00035   This source code is intended only as a supplement to Microsoft
00036   Development Tools and/or on-line documentation.  See these other
00037   materials for detailed information regarding Microsoft code samples.
00038
00039   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00040   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00041   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00042   PARTICULAR PURPOSE.
00043 ==========================================================================+*/
00044
00045 #if !defined(UTILCAR_H)
00046 #define UTILCAR_H
00047
00048 #ifdef __cplusplus
00049
00050 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00051   ObjectClass: COUtilityCar
00052
00053   Summary:     COM Object Class for COUtilityCar COM Objects.  COM objects
00054                of this class augment COCar COM objects (which offer ICar
00055                interface features of Shift, Clutch, Speed, and Steer) with
00056                IUtility interface features (Offroad and Winch).  This
00057                COUtilityCar COM object class is constructed by containment
00058                reuse of the COCar COM object class.  The mulitple
00059                interfaces on this COM object class are constructed via
00060                the nested interface classes technique.
00061
00062   Interfaces:  IUnknown
00063                  Standard interface providing COM object features.
00064                ICar
00065                  Basic Car operation features.
00066                IUtility
00067                  Sport-utility vehicle offroad features.
00068
00069   Aggregation: Yes, COUtilityCar COM objects are aggregatable by passing
00070                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00071 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00072 class COUtilityCar : public IUnknown
00073 {
00074   public:
00075     // Main Object Constructor & Destructor.
00076     COUtilityCar(IUnknown* pUnkOuter, CServer* pServer);
00077     ~COUtilityCar(void);
00078
00079     // A general method for initializing a newly created COUtilityCar.
00080     HRESULT Init(void);
00081
00082     // IUnknown methods. Main object, non-delegating.
00083     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00084     STDMETHODIMP_(ULONG) AddRef(void);
00085     STDMETHODIMP_(ULONG) Release(void);
00086
00087     // We get this ICar interface pointer via containment reuse of the
00088     // ICar interface in an instantiated COCar.
00089     ICar*           m_pICar;
00090
00091   private:
00092     // We show nested interface class implementations here.
00093
00094     // We implement the basic ICar interface in this COUtilityCar
00095     // COM object class.
00096     class CImpICar : public ICar
00097     {
00098       public:
00099         // Interface Implementation Constructor & Destructor.
00100         CImpICar(COUtilityCar* pBackObj, IUnknown* pUnkOuter);
00101         ~CImpICar(void);
00102
00103         // IUnknown methods.
00104         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00105         STDMETHODIMP_(ULONG) AddRef(void);
00106         STDMETHODIMP_(ULONG) Release(void);
00107
00108         // ICar methods.
00109         STDMETHODIMP Shift(short nGear);
00110         STDMETHODIMP Clutch(short nEngaged);
00111         STDMETHODIMP Speed(short nMph);
00112         STDMETHODIMP Steer(short nAngle);
00113
00114       private:
00115         // Data private to this COUtilityCar interface implementation of ICar.
00116         ULONG         m_cRefI;       // Interface Ref Count (for debugging).
00117         COUtilityCar* m_pBackObj;    // Parent Object back pointer.
00118         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00119     };
00120
00121     // We implement the IUtility interface (ofcourse) in this COUtilityCar
00122     // COM object class.  This is the interface that we are using as an
00123     // augmentation to the existing COCar COM object class.
00124     class CImpIUtility : public IUtility
00125     {
00126       public:
00127         // Interface Implementation Constructor & Destructor.
00128         CImpIUtility(COUtilityCar* pBackObj, IUnknown* pUnkOuter);
00129         ~CImpIUtility(void);
00130
00131         // IUnknown methods.
00132         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00133         STDMETHODIMP_(ULONG) AddRef(void);
00134         STDMETHODIMP_(ULONG) Release(void);
00135
00136         // IUtility methods.
00137         STDMETHODIMP Offroad(short nGear);
00138         STDMETHODIMP Winch(short nRpm);
00139
00140       private:
00141         // Data private to this interface implementation of IUtility.
00142         ULONG         m_cRefI;       // Interface Ref Count (for debugging).
00143         COUtilityCar* m_pBackObj;    // Parent Object back pointer.
00144         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00145     };
00146
00147     // Make the otherwise private and nested ICar interface implementation
00148     // a friend to COM object instantiations of this selfsame COUtilityCar
00149     // COM object class.
00150     friend CImpICar;
00151     friend CImpIUtility;
00152
00153     // Private data of COUtilityCar COM objects.
00154
00155     // Nested ICar implementation instantiation.
00156     CImpICar        m_ImpICar;
00157
00158     // Nested IUtility implementation instantiation.
00159     CImpIUtility    m_ImpIUtility;
00160
00161     // Main Object reference count.
00162     ULONG           m_cRefs;
00163
00164     // Outer unknown (aggregation & delegation).
00165     IUnknown*       m_pUnkOuter;
00166
00167     // Pointer to this component server's control object.
00168     CServer*        m_pServer;
00169 };
00170
00171 typedef COUtilityCar* PCOUtilityCar;
00172
00173 #endif // __cplusplus
00174
00175
00176 #endif // UTILCAR_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MciPlay/MciPlay.h Source File

  • Multimedia
  • Audio
  • MciPlay

MciPlay.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006  *  PURPOSE.
00007  *
00008  *  Copyright 1992 - 2000 Microsoft Corporation.  All Rights Reserved.
00009  *
00010  **************************************************************************/
00011
00012 /* dialogs */
00013 #define ABOUTBOX        1
00014
00015 /* Menu Items */
00016
00017 #define MENU_ABOUT  1000
00018 #define MENU_EXIT 1001
00019 #define MENU_NEW  1002
00020 #define MENU_CLOSE  1003
00021 #define MENU_OPEN 1004
00022
00023 /* Movie menu */
00024 #define IDM_STOP        9
00025 #define IDM_PLAY  10
00026 #define IDM_HOME  11
00027 #define IDM_END   12
00028 #define IDM_STEP  13
00029 #define IDM_RSTEP 14
00030 #define IDM_RPLAY 15
00031 #define IDM_PAUSE       16
00032
00033 #define IDM_SAutosizeWindow 17
00034 #define IDM_SAutosizeMovie  18
00035 #define IDM_SPlaybar    19
00036 #define IDM_SMenu   20
00037 #define IDM_SShowName   21
00038 #define IDM_SShowMode   22
00039 #define IDM_SShowPos    23
00040 #define IDM_SNotifyMedia  24
00041 #define IDM_SNotifyMode   25
00042 #define IDM_SNotifyPos    26
00043 #define IDM_SNotifySize   27
00044 #define IDM_SRecord   28
00045 #define IDM_SErrorDlg   29
00046
00047 //String Table ID's
00048
00049 #define IDS_APPNAME   1
00050 #define IDS_APPERR    2
00051 #define IDS_VFWTOOOLD   3
00052 #define IDS_UNTITLLED   4
00053 #define IDS_NOOPEN    5
00054 #define IDS_FILTERSTRING  6
00055
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/land.h Source File

  • SysMgmt
  • MMC
  • Taskpads

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035 private:
00036     enum { IDM_NEW_LAND = 2 };
00037
00038     // {2974380E-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/FrameworkProv/FrameworkProv.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • FrameworkProv

FrameworkProv.Cpp

Go to the documentation of this file.
00001 /******************************************************************
00002
00003  Copyright (c)  Microsoft Corporation, All Rights Reserved
00004    FrameworkProv.CPP -- WMI provider class implementation
00005
00006    Generated by Microsoft WMI Code Generation Engine
00007
00008    TO DO: - See individual function headers
00009           - When linking, make sure you link to framedyd.lib &
00010             msvcrtd.lib (debug) or framedyn.lib & msvcrt.lib (retail).
00011
00012    Description:
00013    Sample provider using the Provider Framework
00014
00015 ******************************************************************/
00016
00017 #include <fwcommon.h>  // This must be the first include.
00018
00019 #include "FrameworkProv.h"
00020
00021 // See ExecQuery for details of the usage of these #defines
00022 #define BIT_REDNOSE 0x00000001
00023 #define BIT_WEIGHT  0x00000002
00024 #define BIT_ALL_PROPERTIES 0xffffffff
00025
00026 // TO DO: Replace "NameSpace" with the appropriate namespace for your
00027 //        provider instance.   For instance:  "root\\default or "root\\cimv2".
00028 //===================================================================
00029 CReindeer MyReindeerProvSet (PROVIDER_NAME_REINDEERPROV, L"root\\default") ;
00030
00031 // Property names
00032 //===============
00033 const static WCHAR* pName = L"Name" ;
00034 const static WCHAR* pRedNose = L"RedNose" ;
00035 const static WCHAR* pWeight = L"Weight" ;
00036
00037 // This WCHAR * is used to illustrate returning status
00038 // objects.  See DeleteInstance.
00039 //====================================================
00040 const static WCHAR* pErrorClass = L"\\\\.\\root\\default:ReindeerError";
00041
00042 // Sample data
00043 // ===========
00044 Deers ohDeers[Deers::NDeers] =
00045 {
00046     // Name     Weight  Red Nose    Deleted flag
00047     {L"Dasher",  200,    false,      false},
00048     {L"Dancer",  150,    false,      false},
00049     {L"Prancer", 162,    false,      false},
00050     {L"Vixen",   125,    false,      false},
00051     {L"Comet",   212,    false,      false},
00052     {L"Cupid",   196,    false,      false},
00053     {L"Donder",  255,    false,      false},
00054     {L"Blitzen", 145,    false,      false},
00055     {L"Rudolf",  123,    true,       false}
00056 };
00057
00058 /*****************************************************************************
00059  *
00060  *  FUNCTION    :   CReindeer::CReindeer
00061  *
00062  *  DESCRIPTION :   Constructor
00063  *
00064  *  INPUTS      :   none
00065  *
00066  *  RETURNS     :   nothing
00067  *
00068  *  COMMENTS    :   Calls the Provider constructor.
00069  *
00070  *****************************************************************************/
00071 CReindeer::CReindeer (LPCWSTR lpwszName, LPCWSTR lpwszNameSpace ) :
00072     Provider(lpwszName, lpwszNameSpace)
00073 {
00074 }
00075
00076 /*****************************************************************************
00077  *
00078  *  FUNCTION    :   CReindeer::~CReindeer
00079  *
00080  *  DESCRIPTION :   Destructor
00081  *
00082  *  INPUTS      :   none
00083  *
00084  *  RETURNS     :   nothing
00085  *
00086  *  COMMENTS    :
00087  *
00088  *****************************************************************************/
00089 CReindeer::~CReindeer ()
00090 {
00091 }
00092
00093 /*****************************************************************************
00094 *
00095 *  FUNCTION    :    CReindeer::EnumerateInstances
00096 *
00097 *  DESCRIPTION :    Returns all the instances of this class.
00098 *
00099 *  INPUTS      :    A pointer to the MethodContext for communication with WinMgmt.
00100 *                   A long that contains the flags described in
00101 *                   IWbemServices::CreateInstanceEnumAsync.  Note that the following
00102 *                   flags are handled by (and filtered out by) WinMgmt:
00103 *                       WBEM_FLAG_DEEP
00104 *                       WBEM_FLAG_SHALLOW
00105 *                       WBEM_FLAG_RETURN_IMMEDIATELY
00106 *                       WBEM_FLAG_FORWARD_ONLY
00107 *                       WBEM_FLAG_BIDIRECTIONAL
00108 *
00109 *  RETURNS     :    WBEM_S_NO_ERROR if successful
00110 *
00111 *  COMMENTS    : TO DO: All instances on the machine should be returned here and
00112 *                       all properties that this class knows how to populate must
00113 *                       be filled in.  If there are no instances, return
00114 *                       WBEM_S_NO_ERROR.  It is not an error to have no instances.
00115 *                       If you are implementing a 'method only' provider, you
00116 *                       should remove this method.
00117 *
00118 *****************************************************************************/
00119 HRESULT CReindeer::EnumerateInstances ( MethodContext* pMethodContext, long lFlags )
00120 {
00121     HRESULT hRes = WBEM_S_NO_ERROR;
00122
00123     // create an instance for each reindeer
00124     for (int i = 0; (i < Deers::NDeers) && (SUCCEEDED(hRes)); i++)
00125     {
00126         // we don't want to return deleted deer
00127         if (!ohDeers[i].m_deleted)
00128         {
00129             // Note that CreateNewInstance may throw, but will never return NULL.
00130             CInstance *pInstance = CreateNewInstance(pMethodContext);
00131
00132             pInstance->SetCHString(pName, CHString(ohDeers[i].m_name));
00133             if (SUCCEEDED(LoadPropertyValues(pInstance, i, BIT_ALL_PROPERTIES)))
00134             {
00135                 hRes = pInstance->Commit();
00136             }
00137
00138             pInstance->Release();
00139         }
00140     }
00141
00142     return hRes ;
00143 }
00144
00145 /*****************************************************************************
00146 *
00147 *  FUNCTION    :    CReindeer::GetObject
00148 *
00149 *  DESCRIPTION :    Find a single instance based on the key properties for the
00150 *                   class.
00151 *
00152 *  INPUTS      :    A pointer to a CInstance object containing the key properties.
00153 *                   A long that contains the flags described in
00154 *                   IWbemServices::GetObjectAsync.
00155 *
00156 *  RETURNS     :    WBEM_S_NO_ERROR if the instance can be found
00157 *                   WBEM_E_NOT_FOUND if the instance described by the key properties
00158 *                   could not be found
00159 *                   WBEM_E_FAILED if the instance could be found but another error
00160 *                   occurred.
00161 *
00162 *  COMMENTS    :    If you are implementing a 'method only' provider, you should
00163 *                   remove this method.
00164 *
00165 *****************************************************************************/
00166 HRESULT CReindeer::GetObject ( CInstance* pInstance, long lFlags )
00167 {
00168     // TO DO: The GetObject function is used to search for an instance of this
00169     //        class on the machine based on the key properties.   Unlike
00170     //        EnumerateInstances which finds all instances on the machine, GetObject
00171     //        uses the key properties to find the matching single instance and
00172     //        returns that instance.
00173     //
00174     //        Use the CInstance Get functions (for example, call
00175     //        GetCHString(L"Name", sTemp)) against pInstance to see the key values
00176     //        the client requested.
00177     HRESULT hr = WBEM_E_NOT_FOUND;
00178
00179     // name is the key, we retrieve the name
00180     CHString name;
00181     pInstance->GetCHString(pName, name);
00182
00183     // search the array for a Reindeer with the name we're given
00184     // (make sure he hasn't been deleted!)
00185     for (int i = 0; i < Deers::NDeers; i++)
00186     {
00187         if (0 == name.CompareNoCase(CHString(ohDeers[i].m_name)) && !ohDeers[i].m_deleted)
00188         {
00189             // we found the one they're look for - fill in the data
00190
00191             hr = LoadPropertyValues(pInstance, i, BIT_ALL_PROPERTIES);
00192             break;
00193         }
00194     }
00195
00196     return hr ;
00197 }
00198
00199 /*****************************************************************************
00200 *
00201 *  FUNCTION    :    CReindeer::ExecQuery
00202 *
00203 *  DESCRIPTION :    You are passed a method context to use in the creation of
00204 *                   instances that satisfy the query, and a CFrameworkQuery
00205 *                   which describes the query.  Create and populate all
00206 *                   instances which satisfy the query.  You may return more
00207 *                   instances or more properties than are requested and WinMgmt
00208 *                   will post filter out any that do not apply.
00209 *
00210 *  INPUTS      :    A pointer to the MethodContext for communication with WinMgmt.
00211 *                   A query object describing the query to satisfy.
00212 *                   A long that contains the flags described in
00213 *                   IWbemServices::CreateInstanceEnumAsync.  Note that the following
00214 *                   flags are handled by (and filtered out by) WinMgmt:
00215 *                       WBEM_FLAG_FORWARD_ONLY
00216 *                       WBEM_FLAG_BIDIRECTIONAL
00217 *                       WBEM_FLAG_ENSURE_LOCATABLE
00218 *
00219 *  RETURNS     :    WBEM_E_PROVIDER_NOT_CAPABLE if queries not supported for
00220 *                       this class or if the query is too complex for this class
00221 *                       to interpret.  The framework will call the EnumerateInstances
00222 *                       function instead and let Winmgmt post filter.
00223 *                   WBEM_E_FAILED if the query failed
00224 *                   WBEM_S_NO_ERROR if query was successful
00225 *
00226 *  COMMENTS    : TO DO: Most providers will not need to implement this method.  If you don't, WinMgmt
00227 *                       will call your enumerate function to get all the instances and perform the
00228 *                       filtering for you.  Unless you expect SIGNIFICANT savings from implementing
00229 *                       queries, you should remove this method.  You should also remove this method
00230 *                       if you are implementing a 'method only' provider.
00231 *
00232 *****************************************************************************/
00233 HRESULT CReindeer::ExecQuery (MethodContext *pMethodContext, CFrameworkQuery& Query, long lFlags)
00234 {
00235
00236 // While this class is too small to really benefit from query processing, this method is
00237 // being instrumented to show how it could be done.  There are two different ways query processing
00238 // can be used to improve performance.
00239 //
00240 // Method 1 - Look at the fields that are being requested, and only return data for those fields.  This
00241 //            can be a very big win for some classes if some properties are very expensive to retrieve.
00242 //            In our own LogicalDisk class, populating just the DeviceID field is very cheap.  However,
00243 //            populating the FreeSpace property requires that we spin up the disk.  For floppy, cd, and
00244 //            network drives, that is very expensive.
00245 //
00246 // Method 2 - Look at the where clause and only return the requested records.  Obviously, this also has
00247 //            the potential to be a big win.  For example, if the query is of the form 'Select Name,
00248 //            Size from CIM_Datafile where where drive="a:"', clearly this can be resolved much faster
00249 //            then doing the default behavior when no ExecQuery routine is specified (enumerating all
00250 //            directories on all drives and let Winmgmt pick out the matching entries).
00251
00252 //            On the other hand, just because a WHERE clause in included doesn't mean that the query can
00253 //            be processed any faster.  Consider a query of the form "Select * from CIM_Datafile where
00254 //            ReadOnly = TRUE".  By the time we have called FindFirstFile and examined the structure, the
00255 //            most expensive parts of the processing is already done.  How about a query of the form
00256 //            'Select * from CIM_Datafile where Drive="a:" or ReadOnly = TRUE'?  Again, to satisfy this
00257 //            query, we're going to have to walk all the instances on all the drives anyway since there
00258 //            is no way to specify to the Win32 API's that you only want ReadOnly files.  Since Winmgmt
00259 //            already has a bunch of code to process instances against queries, there's no reason to add
00260 //            that complexity to our provider UNLESS we are getting a big performance win.  If we send
00261 //            back a few too many instances, winmgmt will trim them out.
00262
00263 //            For most classes, there are a few (sometimes only 1) properties that it makes sense to
00264 //            try to optimize on (CIM_Datafile actually does a bunch, but many other classes that process
00265 //            queries only do 1-2).
00266
00267 //            So, there is a method that can be run against the CFrameworkQuery object where you pass it
00268 //            the name of a property, and it will tell you all the values they requested.  For example,
00269 //            if the query is of the form 'Select * from Reindeer where name = "Dasher" or
00270 //            name = "Dancer" or name = "pickle"', GetValuesForProp(L"Name") would send back an array
00271 //            that contains {"Dasher", "Dancer", "pickle"}.  Or if the query was of the form 'Select *
00272 //            from CIM_Datafile where Drive = "a:" AND ReadOnly = TRUE' (note that this query, unlike
00273 //            the one in the paragraph above, uses AND), then GetValuesForProp(L"Drive") would
00274 //            return {"a:"}.  Given this array, you can quickly return just the few instances they
00275 //            requested.  If there are additional clauses on the query that you didn't process, (like
00276 //            the Drive AND ReadOnly example above), don't worry.  Winmgmt will discard the instances
00277 //            that don't match.
00278
00279 // In your provider, you can use either, neither, or both of these methods.  In the code below,
00280 // both methods are illustrated.
00281
00282    DWORD dwRequiredProperties = 0;
00283    CHStringArray asNames;
00284    HRESULT hRes = WBEM_S_NO_ERROR;
00285
00286    // Part of Method 2
00287    Query.GetValuesForProp(pName, asNames);
00288
00289    BOOL bGetAllInstances = asNames.GetSize() == 0;
00290
00291    // Used by Method 1
00292    if (Query.IsPropertyRequired(pWeight))
00293        dwRequiredProperties |= BIT_WEIGHT;
00294
00295    if (Query.IsPropertyRequired(pRedNose))
00296        dwRequiredProperties |= BIT_REDNOSE;
00297
00298     // walk through all the reindeer
00299    for (int i = 0; (i < Deers::NDeers) && (SUCCEEDED(hRes)); i++)
00300    {
00301        // we don't want to return deleted deer
00302        if (!ohDeers[i].m_deleted)
00303        {
00304            // Method 2 - Check to see if the query CAN be processed by 'name', if so,
00305            // only return those names.
00306            if (bGetAllInstances || IsInList(asNames, ohDeers[i].m_name))
00307            {
00308                // Note that CreateNewInstance may throw, but will never return NULL.
00309                CInstance *pInstance = CreateNewInstance(pMethodContext);
00310
00311                // Always set the key property
00312                pInstance->SetCHString(pName, CHString(ohDeers[i].m_name));
00313
00314                if (SUCCEEDED(LoadPropertyValues(pInstance, i, dwRequiredProperties)))
00315                {
00316                    hRes = pInstance->Commit();
00317                }
00318
00319                pInstance->Release();
00320            }
00321        }
00322    }
00323
00324    return hRes;
00325 }
00326
00327 /*****************************************************************************
00328 *
00329 *  FUNCTION    : CReindeer::LoadPropertyValues
00330 *
00331 *  DESCRIPTION :    This routine was NOT created by the code generator.  It
00332 *                   was hand edited into this file.  Creating this routines
00333 *                   saves us from having to have these pInstance->Set lines
00334 *                   in three different routines (EnumerateInstances,
00335 *                   GetObject, ExecQuery).
00336 *
00337 *  INPUTS      :    - A pointer to a CInstance object to populate
00338 *                   - A DWORD that is the index into ohDeers of the entry to
00339 *                   populate.  For a more useful class, this might be a pointer
00340 *                   to a structure from which we extract the information.
00341 *                   - A DWORD that is a bitmask indicating which properties
00342 *                   to populate.
00343 *
00344 *  RETURNS     :    WBEM_S_NO_ERROR if instance is properly populated
00345 *
00346 *  COMMENTS    :
00347 *
00348 *****************************************************************************/
00349 HRESULT CReindeer::LoadPropertyValues( CInstance *pInstance, DWORD dwIndex, DWORD dwRequiredProperties)
00350 {
00351    if (dwRequiredProperties & BIT_WEIGHT)
00352        pInstance->SetDWORD(pWeight,  ohDeers[dwIndex].m_weight);
00353
00354    if (dwRequiredProperties & BIT_REDNOSE)
00355        pInstance->Setbool(pRedNose,  ohDeers[dwIndex].m_redNose);
00356
00357    return WBEM_S_NO_ERROR;
00358 }
00359
00360 /*****************************************************************************
00361 *
00362 *  FUNCTION    : CReindeer::PutInstance
00363 *
00364 *  DESCRIPTION :    PutInstance should be used in provider classes that can
00365 *                   write instance information back to the hardware or
00366 *                   software.  For example: Win32_Environment will allow a
00367 *                   PutInstance to create or update an environment variable.
00368 *                   However, a class like MotherboardDevice will not allow
00369 *                   editing of the number of slots, since it is difficult for
00370 *                   a provider to affect that number.
00371 *
00372 *  INPUTS      :    A pointer to a CInstance object containing the key properties.
00373 *                   A long that contains the flags described in
00374 *                   IWbemServices::PutInstanceAsync.
00375 *
00376 *  RETURNS     :    WBEM_E_PROVIDER_NOT_CAPABLE if PutInstance is not available
00377 *                   WBEM_E_FAILED if there is an error delivering the instance
00378 *                   WBEM_E_INVALID_PARAMETER if any of the instance properties
00379 *                   are incorrect.
00380 *                   WBEM_S_NO_ERROR if instance is properly delivered
00381 *
00382 *  COMMENTS    : TO DO: If you don't intend to support writing to your provider,
00383 *                       or are creating a 'method only' provider, remove this
00384 *                       method.
00385 *
00386 *****************************************************************************/
00387 HRESULT CReindeer::PutInstance ( const CInstance &Instance, long lFlags)
00388 {
00389     HRESULT hresult = WBEM_E_INVALID_PARAMETER;
00390
00391     // we do not create reindeer here.
00392     if (lFlags & WBEM_FLAG_CREATE_ONLY)
00393         hresult = WBEM_E_UNSUPPORTED_PARAMETER;
00394     else
00395     {
00396         // get the key value so we can tell which reindeer we're operating on
00397         CHString name;
00398         Instance.GetCHString(pName, name);
00399         for (int i = 0; i < Deers::NDeers; i++)
00400         {
00401             if (0 == name.CompareNoCase(CHString(ohDeers[i].m_name)) && !ohDeers[i].m_deleted)
00402             {
00403                 // we found one, we can change the red nose and/or the weight properties
00404                 DWORD weight;
00405                 bool  redNoze;
00406
00407                 if (Instance.GetDWORD(pWeight,  weight))
00408                     ohDeers[i].m_weight = weight;
00409
00410                 if (Instance.Getbool(pRedNose, redNoze))
00411                     ohDeers[i].m_redNose = redNoze;
00412
00413                 hresult = WBEM_S_NO_ERROR;
00414                 break;
00415             }
00416         }
00417
00418         if (FAILED(hresult))
00419         {
00420             // If they said they wanted to update, but it wasn't there
00421             if (lFlags & WBEM_FLAG_UPDATE_ONLY)
00422             {
00423                 hresult = WBEM_E_NOT_FOUND;
00424             }
00425         }
00426     }
00427
00428     return hresult;
00429 }
00430
00431 /*****************************************************************************
00432 *
00433 *  FUNCTION    :    CReindeer::DeleteInstance
00434 *
00435 *  DESCRIPTION :    DeleteInstance, like PutInstance, actually writes information
00436 *                   to the software or hardware.   For most hardware devices,
00437 *                   DeleteInstance should not be implemented, but for software
00438 *                   configuration, DeleteInstance implementation is plausible.
00439 *
00440 *  INPUTS      :    A pointer to a CInstance object containing the key properties.
00441 *                   A long that contains the flags described in
00442 *                   IWbemServices::DeleteInstanceAsync.
00443 *
00444 *  RETURNS     :    WBEM_E_PROVIDER_NOT_CAPABLE if DeleteInstance is not available.
00445 *                   WBEM_E_FAILED if there is an error deleting the instance.
00446 *                   WBEM_E_INVALID_PARAMETER if any of the instance properties
00447 *                   are incorrect.
00448 *                   WBEM_S_NO_ERROR if instance is properly deleted.
00449 *
00450 *  COMMENTS    : TO DO: If you don't intend to support deleting instances or are
00451 *                       creating a 'method only' provider, remove this method.
00452 *
00453 *****************************************************************************/
00454 HRESULT CReindeer::DeleteInstance ( const CInstance &Instance, long lFlags )
00455 {
00456     HRESULT hresult = WBEM_E_NOT_FOUND;
00457
00458     // get the key value so we can tell which reindeer we're operating on
00459     CHString name;
00460     Instance.GetCHString(pName, name);
00461
00462     // see if we can find the deer we want,
00463     // note that we won't delete one that's already been deleted
00464     for (int i = 0; i < Deers::NDeers; i++)
00465     {
00466         if (0 == name.CompareNoCase(ohDeers[i].m_name))
00467         {
00468             if (!ohDeers[i].m_deleted)
00469             {
00470                 // we found it - mark as deleted
00471                 ohDeers[i].m_deleted = true;
00472                 hresult = WBEM_S_NO_ERROR;
00473                 break;
00474             }
00475             else
00476             {
00477                 // Ok, this is a bit of a stretch, but I want to be able
00478                 // to show how to report errors using an error object.
00479
00480                 // This code is entered if the same reindeer is deleted
00481                 // twice in a row.  If this deletion is done in wbemtest,
00482                 // a dialog with a 'More Info' button will be displayed.
00483                 // Clicking this button will show the object we are
00484                 // populating here.
00485                 CHString sRelPath;
00486
00487                 Instance.GetCHString(L"__RelPath", sRelPath);
00488                 CInstance *pErrorInstance = NULL;
00489
00490                 // First, get a status object
00491                 CWbemProviderGlue::GetInstanceByPath(pErrorClass, &pErrorInstance);
00492
00493                 // Now, populate it
00494                 pErrorInstance->SetWCHARSplat(L"Operation", L"DeleteInstance");
00495                 pErrorInstance->SetCHString(L"ParameterInfo", sRelPath);
00496                 pErrorInstance->SetWCHARSplat(L"ProviderName", PROVIDER_NAME_REINDEERPROV);
00497                 pErrorInstance->SetDWORD(L"StatusCode", WBEM_E_NOT_FOUND);
00498                 pErrorInstance->SetCHString(L"ReindeerName", name);
00499
00500                 pErrorInstance->SetWCHARSplat(L"Description",
00501                     L"Attempt to delete reindeer that has already been deleted");
00502
00503                 // Get the actual IWbemClassObject pointer
00504                 IWbemClassObject *pObj = pErrorInstance->GetClassObjectInterface();
00505
00506                 // Note that no Release() is required for this
00507                 MethodContext *pMethodContext = Instance.GetMethodContext();
00508
00509                 // Set the status object
00510                 pMethodContext->SetStatusObject(pObj);
00511
00512                 // Cleanup
00513                 pObj->Release();
00514                 pErrorInstance->Release();
00515
00516                 break;
00517             }
00518         }
00519     }
00520
00521     return hresult;
00522 }
00523
00524 /*****************************************************************************
00525 *
00526 *  FUNCTION    :    CReindeer::ExecMethod
00527 *
00528 *  DESCRIPTION :    Override this function to provide support for methods.
00529 *                   A method is an entry point for the user of your provider
00530 *                   to request your class perform some function above and
00531 *                   beyond a change of state.  (A change of state should be
00532 *                   handled by PutInstance() )
00533 *
00534 *  INPUTS      :    A pointer to a CInstance containing the instance the method was executed against.
00535 *                   A string containing the method name
00536 *                   A pointer to the CInstance which contains the IN parameters.
00537 *                   A pointer to the CInstance to contain the OUT parameters.
00538 *                   A set of specialized method flags
00539 *
00540 *  RETURNS     :    WBEM_E_PROVIDER_NOT_CAPABLE if not implemented for this class
00541 *                   WBEM_S_NO_ERROR if method executes successfully
00542 *                   WBEM_E_FAILED if error occurs executing method
00543 *
00544 *  COMMENTS    : TO DO: If you don't intend to support Methods, remove this method.
00545 *
00546 *****************************************************************************/
00547 HRESULT CReindeer::ExecMethod ( const CInstance& Instance,
00548                         const BSTR bstrMethodName,
00549                         CInstance *pInParams,
00550                         CInstance *pOutParams,
00551                         long lFlags
00552 )
00553 {
00554     // Note that there are two status codes involved here.  The hresult,
00555     // which is the return code for the function, indicates whether the method
00556     // was successfully invoked.  Then there is the hStatusCode which is used
00557     // to indicate whether the function did what it was asked to do.
00558
00559     // hStatusCode will end up being the uint32 return code, and can be seen in the
00560     // 'Edit Out Parameters' box in wbemtest after executing this method.
00561
00562     HRESULT hresult = WBEM_E_PROVIDER_NOT_CAPABLE;
00563     HRESULT hStatusCode = WBEM_E_NOT_FOUND;
00564
00565     // Make sure we recognize the method they are requesting
00566     if (_wcsicmp(bstrMethodName, L"Undelete") == 0)
00567     {
00568         // The method we implement here is declared as:
00569
00570       //  [Implemented, static, Description(
00571       //  "The Undelete method will set the Deleted flag for the specified"
00572         //    "reindeer back to false.  Returns WBEM_S_NO_ERROR if succeeded,
00573         //    WBEM_E_NOT_FOUND if the Reindeer is not in the list, or WBEM_S_FALSE
00574         //    if the reindeer was not already marked as deleted.")]
00575         // uint32 Undelete([In] string ReindeerName) ;
00576
00577         hresult = WBEM_S_NO_ERROR;
00578
00579         // get the key value so we can tell which reindeer we're operating on
00580         CHString name;
00581         pInParams->GetCHString(L"ReindeerName", name);
00582
00583         // see if we can find the deer we want,
00584         for (int i = 0; i < Deers::NDeers; i++)
00585         {
00586             if (0 == name.CompareNoCase(ohDeers[i].m_name))
00587             {
00588                 if (!ohDeers[i].m_deleted)
00589                 {
00590                     // It wasn't deleted.  Set the appropriate code
00591                     hStatusCode = WBEM_S_FALSE;
00592                     break;
00593                 }
00594                 else
00595                 {
00596                     // It was deleted, so undelete it, and set the
00597                     // error code.
00598                     ohDeers[i].m_deleted = false;
00599                     hStatusCode = WBEM_S_NO_ERROR;
00600                 }
00601             }
00602         }
00603
00604         // put the result code back in the structure.
00605         pOutParams->SetDWORD(L"ReturnValue", hStatusCode);
00606     }
00607     else if (_wcsicmp(bstrMethodName, L"Rename") == 0)
00608     {
00609         // The method we implement here is declared as:
00610
00611         //        [Implemented, Description(
00612         //        "The Rename method will change the name of the reindeer it is run"
00613         //        "against.")]
00614         //    uint32 Rename([In] string NewReindeerName) ;
00615
00616         hresult = WBEM_S_NO_ERROR;
00617
00618         // get the key value so we can tell which reindeer we're operating on
00619         CHString sNewName, sCurName;
00620         Instance.GetCHString(L"name", sCurName);  // Old name
00621
00622         if (!pInParams->IsNull(L"NewReindeerName"))
00623         {
00624             pInParams->GetCHString(L"NewReindeerName", sNewName); // New name
00625         }
00626
00627         // No name was specified or a blank name was specified.
00628         if (!sNewName.IsEmpty())
00629         {
00630             // see if we can find the deer we want,
00631             for (int i = 0; i < Deers::NDeers; i++)
00632             {
00633                 if (0 == sCurName.CompareNoCase(ohDeers[i].m_name))
00634                 {
00635                     if (!ohDeers[i].m_deleted)
00636                     {
00637                         ohDeers[i].m_name = sNewName.AllocSysString();
00638             if (ohDeers[i].m_name == NULL)
00639               hStatusCode = WBEM_E_OUT_OF_MEMORY;
00640             else
00641                             hStatusCode = WBEM_S_NO_ERROR;
00642                         break;
00643                     }
00644                 }
00645             }
00646         }
00647         else
00648         {
00649             hStatusCode = WBEM_E_INVALID_PARAMETER;
00650         }
00651
00652         // put the result code back in the structure.
00653         pOutParams->SetDWORD(L"ReturnValue", hStatusCode);
00654     }
00655
00656     // Shows how to use the GetInstancesByQuery method.  The error reporting is a little light,
00657     // but I didn't want obscure the GetInstancesByQuery function with a whole bunch of other
00658     // stuff.
00659     else if (_wcsicmp(bstrMethodName, L"CalcWeight") == 0)
00660     {
00661         // The method we implement here is declared as:
00662
00663         //        [Implemented, static, Description(
00664         //        "The CalcWeight method will compute the total weight of all "
00665         //        "the reindeer.  It will return the total weight, or 0xffffffff "
00666         //        "on error.")]
00667         //    uint32 CalcWeight() ;
00668
00669         TRefPointerCollection<CInstance>    ReindeerList;
00670
00671         // Get a method context pointer off the CInstance
00672         MethodContext *pMethodContext = Instance.GetMethodContext();
00673
00674         // Run the query.  While I'm not using a WHERE clause here, I certainly could.  Note
00675         // that the ReindeerList is a collection of CInstances.  As such, it can get VERY large
00676         // depending on the number of instances, and the size of the instances.  If you are
00677         // going to be hitting a big class, consider the GetInstancesByQueryAsynch function
00678         // instead.
00679         if (SUCCEEDED(hresult = CWbemProviderGlue::GetInstancesByQuery(L"SELECT Weight FROM Reindeer",
00680                                             &ReindeerList,
00681                                             pMethodContext,
00682                                             L"root\\default")))
00683         {
00684             REFPTRCOLLECTION_POSITION   pos;
00685
00686             // Initialize the enum
00687             if ( ReindeerList.BeginEnum( pos ) )
00688             {
00689
00690                 // Set some vars
00691                 CInstance *pReindeer;
00692                 DWORD dwWeight, dwTotWeight = 0;
00693
00694                 // Walk the enum.  Note the pReindeer must be released when
00695                 // we are done with it.
00696                 while (pReindeer = ReindeerList.GetNext(pos))
00697                 {
00698                     if (pReindeer->GetDWORD(pWeight, dwWeight))
00699                     {
00700                         dwTotWeight += dwWeight;
00701                     }
00702
00703                     pReindeer->Release();
00704                 }
00705
00706                 ReindeerList.EndEnum();
00707
00708                 // Set the out parameter, and we're done
00709                 pOutParams->SetDWORD(L"ReturnValue", dwTotWeight);
00710             }
00711             else
00712             {
00713                 pOutParams->SetDWORD(L"ReturnValue", 0xffffffff);
00714             }
00715         }
00716         else
00717         {
00718             pOutParams->SetDWORD(L"ReturnValue", 0xffffffff);
00719         }
00720     }
00721     else if (_wcsicmp(bstrMethodName, L"CalcWeightNonRed") == 0)
00722     {
00723         //        [Implemented, static, Description(
00724         //        "The CalcWeightNonRed method will compute the total weight of all "
00725         //        "the reindeer that don't have a red nose.  It will return the total "
00726         //        "weight, or 0xffffffff on error.")]
00727         //    uint32 CalcWeightNonRed() ;
00728
00729         // This time we're going to use the Asynch version of GetInstancesByQuery.
00730         // See EnumerationCallback for discussion.
00731
00732         // Get a method context pointer off the CInstance
00733         MethodContext *pMethodContext = Instance.GetMethodContext();
00734
00735         DWORD dwTotWeight = 0;
00736
00737         hresult = CWbemProviderGlue::GetInstancesByQueryAsynch(
00738                                         L"Select Weight FROM Reindeer WHERE RedNose = FALSE",
00739                                         this,
00740                                         StaticEnumerationCallback,
00741                                         L"Root\\Default",
00742                                         pMethodContext,
00743                                         &dwTotWeight);
00744
00745         if (SUCCEEDED(hresult))
00746         {
00747             pOutParams->SetDWORD(L"ReturnValue", dwTotWeight);
00748         }
00749         else
00750         {
00751             pOutParams->SetDWORD(L"ReturnValue", 0xffffffff);
00752         }
00753     }
00754
00755     return hresult;
00756 }
00757
00758 BOOL CReindeer::IsInList(const CHStringArray &asArray, LPCWSTR pszString)
00759 {
00760     DWORD dwSize = asArray.GetSize();
00761
00762     for (DWORD x=0; x < dwSize; x++)
00763     {
00764         if (asArray[x].CompareNoCase(pszString) == 0)
00765         {
00766             return TRUE;
00767         }
00768     }
00769
00770     return FALSE;
00771 }
00772
00773 /*****************************************************************************
00774  *
00775  *  FUNCTION    : CReindeer::StaticEnumerationCallback
00776  *
00777  *  DESCRIPTION : Called from GetAllInstancesAsynch as a wrapper to EnumerationCallback
00778  *
00779  *  INPUTS      :
00780  *
00781  *  OUTPUTS     :
00782  *
00783  *  RETURNS     :
00784  *
00785  *  COMMENTS    :
00786  *
00787  *****************************************************************************/
00788 HRESULT WINAPI CReindeer::StaticEnumerationCallback(
00789
00790     Provider* pThat,
00791     CInstance* pInstance,
00792     MethodContext* pContext,
00793     void* pUserData)
00794 {
00795     CReindeer* pThis;
00796     HRESULT hr;
00797
00798   pThis = static_cast<CReindeer *>(pThat);
00799
00800   if (pThis)
00801     hr = pThis->EnumerationCallback(pInstance, pContext, pUserData);
00802     else
00803         hr = WBEM_E_FAILED;
00804
00805     return hr;
00806 }
00807
00808 /*****************************************************************************
00809  *
00810  *  FUNCTION    : CReindeer::EnumerationCallback
00811  *
00812  *  DESCRIPTION : Called from GetAllInstancesAsynch via StaticEnumerationCallback
00813  *
00814  *  INPUTS      : (see CWbemProviderGlue::GetAllInstancesAsynch)
00815  *
00816  *  OUTPUTS     :
00817  *
00818  *  RETURNS     :
00819  *
00820  *  COMMENTS    : If we wanted to, this routine could create/commit instances.  We
00821  *                have a pMethodContext, all we'd need to do is
00822  *                pInstance = CreateNewInstance(pMethodContext)
00823  *
00824  *                However, since in Reindeer this routine is being called from ExecMethod,
00825  *                that really doesn't make any sense.  But if we were writing
00826  *                an association class between User and Group, we could do a query
00827  *                like "SELECT Domain, Name, SidType from Win32_Group", and 'asynchronously'
00828  *                call a routine just like this that took the group name, called the Win32
00829  *                api's to find out what users were in that group, and create/commit
00830  *                instances.  If we did do that, then the return value from this function
00831  *                should be set to the return value of the Commit() call.  That way, if
00832  *                the client cancels the enumeration, everything will cancel correctly.
00833  *
00834  *                The benefit to using these 'Asynch' functions is that instances
00835  *                would start appearing at the client sooner.  After all, if we called
00836  *                the GetInstancesByQuery, that function wouldn't return until it had
00837  *                ALL the groups stored in the TRefPointerCollection.  This could take
00838  *                a while if many groups are defined.  Further, the TRefPointerCollection
00839  *                could consume a great deal of memory.
00840  *
00841  *****************************************************************************/
00842 HRESULT CReindeer::EnumerationCallback(
00843
00844     CInstance *pReindeer,
00845     MethodContext *pMethodContext,
00846     VOID *pTotWeight
00847 )
00848 {
00849     DWORD dwWeight;
00850     LPDWORD pdwTotWeight = (LPDWORD)pTotWeight;
00851
00852     if (pReindeer->GetDWORD(pWeight, dwWeight))
00853     {
00854         *pdwTotWeight += dwWeight;
00855     }
00856
00857     return WBEM_S_NO_ERROR;
00858 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCriticalSection Member List

This is the complete list of members for CCriticalSection, including all inherited members.
CCriticalSection(CRITICAL_SECTION *pcsect, DWORD dwThreadID) | CCriticalSection | [inline]
cRefs | CCriticalSection | [private]
Enter() | CCriticalSection | [inline]
Leave() | CCriticalSection | [inline]
m_dwThreadID | CCriticalSection | [private]
m_pcsect | CCriticalSection | [private]
~CCriticalSection() | CCriticalSection | [inline]
Generated on Wed Nov 13 2024 16:55:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMSOmniProvSource Member List

This is the complete list of members for CMSOmniProvSource, including all inherited members.
FinalConstruct() CMSOmniProvSource [inline]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/ShlFldr.h Source File

  • WinUI
  • Shell
  • SampView

ShlFldr.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ShlFldr.h
00013
00014    Description:   CShellFolder definitions.
00015
00016 **************************************************************************/
00017
00018 #ifndef SHELLFOLDER_H
00019 #define SHELLFOLDER_H
00020
00021 /**************************************************************************
00022    #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <shlobj.h>
00027
00028 #include "EnumIDL.h"
00029 #include "PidlMgr.h"
00030
00031 /**************************************************************************
00032
00033    CShellFolder class definition
00034
00035 **************************************************************************/
00036
00037 class CShellFolder : public IShellFolder,
00038                      public IPersistFolder
00039 {
00040 friend class CShellView;
00041 friend class CContextMenu;
00042 friend class CDropTarget;
00043 friend class CDataObject;
00044
00045 private:
00046    DWORD          m_ObjRefCount;
00047   LPITEMIDLIST   m_pidlRel;
00048   LPITEMIDLIST   m_pidlFQ;
00049   CShellFolder   *m_psfParent;
00050   LPMALLOC       m_pMalloc;
00051    CPidlMgr       *m_pPidlMgr;
00052
00053 public:
00054    CShellFolder(CShellFolder *pParent = NULL, LPCITEMIDLIST pidl = NULL);
00055    ~CShellFolder();
00056
00057    //IUnknown methods
00058    STDMETHOD (QueryInterface) (REFIID riid, LPVOID * ppvObj);
00059    STDMETHOD_ (ULONG, AddRef) (VOID);
00060    STDMETHOD_ (ULONG, Release) (VOID);
00061
00062    //IShellFolder methods
00063    STDMETHOD (ParseDisplayName) (HWND, LPBC, LPOLESTR, LPDWORD, LPITEMIDLIST*, LPDWORD);
00064    STDMETHOD (EnumObjects) (HWND, DWORD, LPENUMIDLIST*);
00065    STDMETHOD (BindToObject) (LPCITEMIDLIST, LPBC, REFIID, LPVOID*);
00066    STDMETHOD (BindToStorage) (LPCITEMIDLIST, LPBC, REFIID, LPVOID*);
00067    STDMETHOD (CompareIDs) (LPARAM, LPCITEMIDLIST, LPCITEMIDLIST);
00068    STDMETHOD (CreateViewObject) (HWND, REFIID, LPVOID* );
00069    STDMETHOD (GetAttributesOf) (UINT, LPCITEMIDLIST*, LPDWORD);
00070    STDMETHOD (GetUIObjectOf) (HWND, UINT, LPCITEMIDLIST*, REFIID, LPUINT, LPVOID*);
00071    STDMETHOD (GetDisplayNameOf) (LPCITEMIDLIST, DWORD, LPSTRRET);
00072    STDMETHOD (SetNameOf) (HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*);
00073
00074    //IPersist methods
00075    STDMETHODIMP GetClassID(LPCLSID);
00076
00077    //IPersistFolder methods
00078    STDMETHODIMP Initialize(LPCITEMIDLIST);
00079
00080 private:
00081    STDMETHOD (AddFolder)(LPCTSTR, LPITEMIDLIST*);
00082    STDMETHOD (AddItem)(LPCTSTR, LPCTSTR, LPITEMIDLIST*);
00083    STDMETHOD (SetItemData)(LPCITEMIDLIST, LPCTSTR);
00084    STDMETHOD (GetUniqueName)(BOOL, LPTSTR, DWORD);
00085    LPITEMIDLIST CreateFQPidl(LPCITEMIDLIST);
00086    STDMETHOD (DeleteItems)(LPITEMIDLIST*, UINT);
00087    STDMETHOD (CopyItems)(CShellFolder*, LPITEMIDLIST*, UINT);
00088    VOID GetFullName(LPCITEMIDLIST, LPTSTR, DWORD, DWORD);
00089    VOID GetPath(LPCITEMIDLIST, LPTSTR, DWORD);
00090    BOOL HasSubFolder(LPCITEMIDLIST);
00091    VOID NotifyViews(DWORD, LPCITEMIDLIST, LPCITEMIDLIST);
00092    STDMETHOD (CompareItems) (LPCITEMIDLIST, LPCITEMIDLIST);
00093 };
00094
00095 #endif   //SHELLFOLDER_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/common/rusocket.cpp Source File

  • NetDS
  • RRas
  • rqs
  • common

rusocket.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       RuSocket.h
00004 //
00005 //      Synopsis:   Simply socket abstraction.
00006 //
00007 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //+--------------------------------------------------------------------------
00010
00011
00012 #include "rasutil.h"
00013 #include <winsock2.h>
00014
00015 //+--------------------------------------------------------------------------
00016 //
00017 // Synopsis: Utility function to look up the procedure address for the
00018 //           WSAEventSelect function. This allows code using socket classes
00019 //           to work on platforms that don't have ws2_32.dll installed.
00020 //
00021 //+--------------------------------------------------------------------------
00022 pfnWSAEventSelectSpec LookupWSAEventSelect()
00023 {
00024     pfnWSAEventSelectSpec pfnWSAEventSelect = NULL;
00025
00026     HMODULE hWinsock2 = GetModuleHandle(TEXT("ws2_32.dll"));
00027
00028     if (hWinsock2)
00029     {
00030         pfnWSAEventSelect = (pfnWSAEventSelectSpec)GetProcAddress(hWinsock2, "WSAEventSelect");
00031     }
00032
00033     return pfnWSAEventSelect;
00034 }
00035
00036 //+--------------------------------------------------------------------------
00037 //
00038 // Synopsis: A socket
00039 //
00040 //+--------------------------------------------------------------------------
00041 typedef struct _RU_SOCKET
00042 {
00043     SOCKET Socket;
00044     SOCKADDR addr;
00045     UINT uiSize;
00046
00047 } RU_SOCKET;
00048
00049 //+--------------------------------------------------------------------------
00050 //
00051 // Synopsis: Initialize the socket library
00052 //
00053 //+--------------------------------------------------------------------------
00054 HRESULT
00055 RuSocketInit ()
00056 {
00057     INT iErr;
00058     WSADATA wsaData;
00059
00060     iErr = WSAStartup (MAKEWORD(2, 0), &wsaData);
00061     if (iErr != 0)
00062     {
00063         return HRESULT_FROM_WIN32(iErr);
00064     }
00065
00066     return S_OK;
00067 }
00068
00069 //+--------------------------------------------------------------------------
00070 //
00071 // Synopsis: Cleans up the socket library
00072 //
00073 //+--------------------------------------------------------------------------
00074 HRESULT
00075 RuSocketCleanup ()
00076 {
00077     INT iErr;
00078
00079     iErr = WSACleanup();
00080     if (iErr != 0)
00081     {
00082         return HRESULT_FROM_WIN32(WSAGetLastError());
00083     }
00084
00085     return S_OK;
00086 }
00087
00088 //+--------------------------------------------------------------------------
00089 //
00090 // Synopsis: Creates a client socket
00091 //
00092 //+--------------------------------------------------------------------------
00093 HRESULT
00094 RuSocketCreate(
00095     IN RU_SOCKET_CREATE_DATA* pCreateData,
00096     OUT HSOCKET* phSocket)
00097 {
00098     u_short uPort = (u_short)pCreateData->uiPort;
00099     RU_SOCKET* pSocket = NULL;
00100     struct hostent * pHost;
00101     SOCKADDR_IN sin, bindsin;
00102     SOCKET Socket;
00103     DWORD dwAddress, dwAddressS;
00104     HRESULT hr = S_OK;
00105     BOOL bOk = FALSE;
00106     INT iErr;
00107
00108     // Lookup the host
00109     //
00110     pHost = gethostbyname (pCreateData->pszDest);
00111     if (pHost)
00112     {
00113         dwAddress = (DWORD)(*((DWORD*)(pHost->h_addr_list[0])));
00114     }
00115     else
00116     {
00117         dwAddress = inet_addr (pCreateData->pszDest);
00118     }
00119
00120     dwAddressS = INADDR_ANY;
00121     if (pCreateData->pszSrc)
00122     {
00123         dwAddressS = inet_addr (pCreateData->pszSrc);
00124     }
00125
00126     // Initialize the address
00127     //
00128     sin.sin_family = AF_INET;
00129     sin.sin_addr.s_addr = dwAddress;
00130     sin.sin_port = htons (uPort);
00131
00132     // Initialize the binding information
00133     //
00134     bindsin.sin_family = AF_INET;
00135     bindsin.sin_addr.s_addr = dwAddressS;
00136     bindsin.sin_port = 0;
00137
00138     // Initailiaze the return value
00139     //
00140     *phSocket = NULL;
00141     pSocket = (RU_SOCKET*) RuAlloc(sizeof(RU_SOCKET), TRUE);
00142     if (! pSocket)
00143     {
00144         return E_OUTOFMEMORY;
00145     }
00146     pSocket->uiSize = sizeof(pSocket->addr);
00147
00148     __try
00149     {
00150         // Create a new socket
00151         //
00152         Socket = socket (PF_INET, SOCK_STREAM, 0);
00153         if (Socket == INVALID_SOCKET)
00154         {
00155             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00156             __leave;
00157         }
00158
00159         // Bind the socket to the given port
00160         //
00161         iErr = bind(Socket, (LPSOCKADDR)&bindsin, sizeof(bindsin));
00162         if (iErr != 0)
00163         {
00164             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00165             __leave;
00166         }
00167
00168         // Connect to the remote machine
00169         //
00170         iErr = connect(Socket, (LPSOCKADDR)&sin, sizeof(sin));
00171         if (iErr != 0)
00172         {
00173             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00174             __leave;
00175         }
00176
00177         pSocket->Socket = Socket;
00178         bOk = TRUE;
00179
00180     }
00181
00182     __finally
00183     {
00184         if (! bOk)
00185         {
00186             RuFree (pSocket);
00187             pSocket = NULL;
00188         }
00189     }
00190
00191     // Set the return value
00192     *phSocket = pSocket;
00193
00194     return hr;
00195 }
00196
00197 //+--------------------------------------------------------------------------
00198 //
00199 // Synopsis: Creates a server socket
00200 //
00201 //+--------------------------------------------------------------------------
00202 HRESULT
00203 RuSocketCreateServer (
00204     IN  RU_SOCKET_CREATE_DATA* pCreateData,
00205     OUT HSOCKET * phServerSock)
00206 {
00207     RU_SOCKET* pSocket = NULL;
00208     SOCKADDR_IN sin;
00209     SOCKET Socket;
00210     BOOL bOk = FALSE;
00211     INT iErr;
00212     HRESULT hr = S_OK;
00213     DWORD dwAddress;
00214
00215     // Initialize the addr
00216     //
00217     sin.sin_family = AF_INET;
00218     sin.sin_addr.s_addr = 0;
00219     sin.sin_port = htons ((USHORT)pCreateData->uiPort);
00220
00221     // Initailiaze the return value
00222     //
00223     *phServerSock = NULL;
00224     pSocket = (RU_SOCKET*) RuAlloc(sizeof(RU_SOCKET), TRUE);
00225     if (! pSocket)
00226     {
00227         return E_OUTOFMEMORY;
00228     }
00229     pSocket->uiSize = sizeof(pSocket->addr);
00230
00231     __try
00232     {
00233         if (pCreateData->pszDest)
00234         {
00235             dwAddress = inet_addr (pCreateData->pszDest);
00236             sin.sin_addr.s_addr = dwAddress;
00237         }
00238
00239         // Create a new socket
00240         //
00241         Socket = socket (PF_INET, SOCK_STREAM, 0);
00242         if (Socket == INVALID_SOCKET)
00243         {
00244             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00245             __leave;
00246         }
00247
00248         // Bind the socket to the given port
00249         //
00250         iErr = bind(Socket, (LPSOCKADDR)&sin, sizeof(sin));
00251         if (iErr != 0)
00252         {
00253             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00254             __leave;
00255         }
00256
00257         // Listen
00258         //
00259         iErr = listen (Socket, SOMAXCONN);
00260         if (iErr != 0)
00261         {
00262             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00263             __leave;
00264         }
00265
00266         pSocket->Socket = Socket;
00267         bOk = TRUE;
00268
00269     }
00270
00271     __finally
00272     {
00273         if (! bOk)
00274         {
00275             RuFree (pSocket);
00276             pSocket = NULL;
00277         }
00278     }
00279
00280     // Set the return value
00281     //
00282     *phServerSock = pSocket;
00283
00284     return hr;
00285
00286 }
00287
00288 //+--------------------------------------------------------------------------
00289 //
00290 // Synopsis: Causes a server socket to listen on its port and return a client
00291 //           socket when a connection is established.
00292 //
00293 //+--------------------------------------------------------------------------
00294 HRESULT
00295 RuSocketListen (
00296     IN HSOCKET pServer,
00297     OUT HSOCKET* phSocket)
00298 {
00299     RU_SOCKET* pClient = NULL;
00300     HRESULT hr = S_OK;
00301
00302     if (! pServer)
00303     {
00304         return E_INVALIDARG;
00305     }
00306
00307     // Initailiaze the return value
00308     //
00309     *phSocket = NULL;
00310     pClient = (RU_SOCKET*) RuAlloc(sizeof(RU_SOCKET), TRUE);
00311     if (! pClient)
00312     {
00313         return E_OUTOFMEMORY;
00314     }
00315     pClient->uiSize = sizeof(pClient->addr);
00316
00317     __try
00318     {
00319         // Accept the connection
00320         //
00321         pClient->Socket = accept (
00322                             pServer->Socket,
00323                             &(pClient->addr),
00324                             (INT*)&(pClient->uiSize));
00325         if (pClient->Socket == INVALID_SOCKET)
00326         {
00327             hr = HRESULT_FROM_WIN32(WSAGetLastError());
00328             __leave;
00329         }
00330
00331         // Assign the return value
00332         //
00333         *phSocket = pClient;
00334
00335     }
00336
00337     __finally
00338     {
00339         if (hr != S_OK)
00340         {
00341             if (pClient)
00342             {
00343                 RuFree(pClient);
00344             }
00345         }
00346     }
00347
00348     return hr;
00349 }
00350
00351 //+--------------------------------------------------------------------------
00352 //
00353 // Synopsis: Closes a socket
00354 //
00355 //+--------------------------------------------------------------------------
00356 HRESULT
00357 RuSocketClose (
00358     IN HSOCKET pSocket)
00359 {
00360     // Validate
00361     //
00362     if (! pSocket)
00363     {
00364         return E_INVALIDARG;
00365     }
00366
00367     // Close the socket
00368     //
00369     closesocket (pSocket->Socket);
00370
00371     // Free
00372     //
00373     RuFree (pSocket);
00374
00375     return S_OK;
00376 }
00377
00378 //+--------------------------------------------------------------------------
00379 //
00380 // Synopsis: Reads from a socket
00381 //
00382 //+--------------------------------------------------------------------------
00383 HRESULT
00384 RuSocketRead (
00385     IN      HSOCKET pSocket,
00386     IN      BYTE*  pbBuffer,
00387     IN OUT  UINT* lpdwBufSize)
00388 {
00389     INT iRet;
00390
00391     // Validate
00392     //
00393     if (! pSocket)
00394     {
00395         return E_INVALIDARG;
00396     }
00397
00398     // Read from the socket
00399     //
00400     iRet = recv (pSocket->Socket, (CHAR*)pbBuffer, *lpdwBufSize, 0);
00401     if (iRet == SOCKET_ERROR)
00402     {
00403         return HRESULT_FROM_WIN32(WSAGetLastError());
00404     }
00405
00406     // Record the bytes read
00407     //
00408     *lpdwBufSize = iRet;
00409
00410     return S_OK;
00411 }
00412
00413 //+--------------------------------------------------------------------------
00414 //
00415 // Synopsis: Reads from a socket
00416 //
00417 //+--------------------------------------------------------------------------
00418 HRESULT
00419 RuSocketReadBlock(
00420     IN HSOCKET pSocket,
00421     IN BYTE* pbBuffer,
00422     IN OUT UINT* lpuiBufSize)
00423 {
00424     HRESULT hr;
00425     INT iRet;
00426     fd_set fdSet;
00427
00428     hr = RuSocketRead(pSocket, pbBuffer, lpuiBufSize);
00429     if (S_OK == hr)
00430     {
00431         return hr;
00432     }
00433     else if (HRESULT_FROM_WIN32(WSAEWOULDBLOCK) == hr)
00434     {
00435         ZeroMemory(&fdSet, sizeof(fdSet));
00436         FD_SET(pSocket->Socket, &fdSet);
00437
00438         // Block until there is read data
00439         //
00440         iRet = select(0, &fdSet, NULL, NULL, NULL);
00441         if (iRet == SOCKET_ERROR)
00442         {
00443             return HRESULT_FROM_WIN32(WSAGetLastError());
00444         }
00445
00446         // Read the data that has arrived
00447         //
00448         hr = RuSocketRead(pSocket, pbBuffer, lpuiBufSize);
00449     }
00450
00451     return hr;
00452 }
00453
00454 //+--------------------------------------------------------------------------
00455 //
00456 // Synopsis:
00457 //
00458 //   Read variant that does not block.  Rather, it returns everything that
00459 //   has been received up till now.
00460 //
00461 //   Sets pbNoMore to true if everything currently received off the wire
00462 //   has been consumed.
00463 //
00464 //+--------------------------------------------------------------------------
00465 HRESULT
00466 RuSocketReadCurrent (
00467     IN      HSOCKET pSocket,
00468     IN      BYTE*  pbBuffer,
00469     IN OUT  UINT* lpdwBufSize,
00470     OUT     BOOL* pbNoMore)
00471 {
00472     HRESULT hr = S_OK;
00473     fd_set fdSet;
00474     int iRet;
00475     struct timeval timeout;
00476
00477     // Initialize the socket set
00478     //
00479     ZeroMemory(&fdSet, sizeof(fdSet));
00480     FD_SET(pSocket->Socket, &fdSet);
00481
00482     // Initialize the timeout
00483     //
00484     ZeroMemory(&timeout, sizeof(timeout));
00485     timeout.tv_sec = 0;
00486     timeout.tv_usec = 1000;
00487
00488     // Get the read status of the socket
00489     //
00490     iRet = select(0, &fdSet, NULL, NULL, &timeout);
00491
00492     // Error
00493     //
00494     if (iRet == SOCKET_ERROR)
00495     {
00496         return HRESULT_FROM_WIN32(WSAGetLastError());
00497     }
00498
00499     // Timeout -- there is nothing to read
00500     //
00501     if (iRet == 0)
00502     {
00503         *pbNoMore = TRUE;
00504         return S_OK;
00505     }
00506
00507     // There's something to read
00508     //
00509     *pbNoMore = FALSE;
00510     return RuSocketRead(pSocket, pbBuffer, lpdwBufSize);
00511
00512 }
00513
00514 //+--------------------------------------------------------------------------
00515 //
00516 // Synopsis: Reads a line of text from a socket
00517 //
00518 //+--------------------------------------------------------------------------
00519 HRESULT
00520 RuSocketReadLine (
00521     IN      HSOCKET pSocket,
00522     IN      BYTE*  pbBuffer,
00523     IN OUT  UINT* lpdwBufSize)
00524 {
00525     HRESULT dwMaxSize = *lpdwBufSize, i = 0;
00526     INT iRet;
00527     BYTE bCur = '\n';
00528     HRESULT hr = S_OK;
00529
00530     // Validate
00531     //
00532     if (! pSocket)
00533     {
00534         return E_INVALIDARG;
00535     }
00536
00537     while (i < dwMaxSize)
00538     {
00539         iRet = recv (pSocket->Socket, (CHAR*)&bCur, 1, 0);
00540         if (iRet == SOCKET_ERROR)
00541         {
00542             return HRESULT_FROM_WIN32(WSAGetLastError());
00543         }
00544         else if (iRet == 0)
00545         {
00546             hr = HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
00547             break;
00548         }
00549         if (bCur == '\r')
00550         {
00551             continue;
00552         }
00553         if (bCur == '\n')
00554         {
00555             break;
00556         }
00557         *pbBuffer = bCur;
00558         pbBuffer++;
00559         i++;
00560     }
00561
00562     *pbBuffer = 0;
00563     if (i > 0)
00564     {
00565         i++;
00566     }
00567
00568     // Record the bytes read
00569     //
00570     *lpdwBufSize = i;
00571
00572     return hr;
00573 }
00574
00575 //+--------------------------------------------------------------------------
00576 //
00577 // Synopsis: Writes to a socket
00578 //
00579 //+--------------------------------------------------------------------------
00580 HRESULT
00581 RuSocketWrite(
00582     IN      HSOCKET pSocket,
00583     IN      BYTE*  pbBuffer,
00584     IN OUT  UINT* lpdwBufSize)
00585 {
00586     INT iRet;
00587
00588     // Validate
00589     //
00590     if (! pSocket)
00591     {
00592         return E_INVALIDARG;
00593     }
00594
00595     // Read from the socket
00596     //
00597     iRet = send (pSocket->Socket, (const CHAR*)pbBuffer, *lpdwBufSize, 0);
00598     if (iRet == SOCKET_ERROR)
00599     {
00600         return HRESULT_FROM_WIN32(WSAGetLastError());
00601     }
00602
00603     // Record the bytes read
00604     //
00605     *lpdwBufSize = iRet;
00606
00607     return S_OK;
00608 }
00609
00610 //+--------------------------------------------------------------------------
00611 //
00612 // Synopsis: Writes a line to a socket, appending the carriage return and
00613 //           line feed if needed.
00614 //
00615 //+--------------------------------------------------------------------------
00616 HRESULT
00617 RuSocketWriteLine(
00618     IN      HSOCKET pSocket,
00619     IN      BYTE*  pbBuffer,
00620     IN OUT  UINT* lpdwBufSize)
00621 {
00622     DWORD dwMaxSize = *lpdwBufSize, i = 0, uiSize;
00623     INT iRet;
00624     BYTE bCur = 0;
00625
00626     // Validate
00627     //
00628     if (! pSocket)
00629     {
00630         return E_INVALIDARG;
00631     }
00632
00633     // Send on the socket
00634     //
00635     while ((i < dwMaxSize) && (bCur != '\r') && (bCur != '\n'))
00636     {
00637         uiSize = sizeof(bCur);
00638         bCur = *pbBuffer;
00639         iRet = send (pSocket->Socket, (CHAR*)&bCur, 1, 0);
00640         if (iRet == SOCKET_ERROR)
00641         {
00642             return HRESULT_FROM_WIN32(WSAGetLastError());
00643         }
00644         pbBuffer++;
00645         i++;
00646     }
00647
00648     // Send the newline
00649     //
00650     send (pSocket->Socket, "\r\n", 2, 0);
00651
00652     // Record the bytes read
00653     //
00654     *lpdwBufSize = i;
00655
00656     return S_OK;
00657 }
00658
00659 //+--------------------------------------------------------------------------
00660 //
00661 // Synopsis:
00662 //
00663 //   Get the socket address (address the socket is bound to) in network order.
00664 //
00665 //+--------------------------------------------------------------------------
00666 HRESULT
00667 RuSocketGetAddress(
00668     IN  HSOCKET pSocket,
00669     OUT DWORD*  lpdwAddress)
00670 {
00671     struct sockaddr_in* pData = (struct sockaddr_in*)&(pSocket->addr);
00672     *lpdwAddress = *((DWORD*)&(pData->sin_addr));
00673
00674     return S_OK;
00675 }
00676
00677 //+--------------------------------------------------------------------------
00678 //
00679 // Synopsis: C++ initialization of the socket library
00680 //
00681 //+--------------------------------------------------------------------------
00682 HRESULT
00683 RuSocket::Initialize()
00684 {
00685     return RuSocketInit();
00686 }
00687
00688 //+--------------------------------------------------------------------------
00689 //
00690 // Synopsis: C++ cleanup of the socket library
00691 //
00692 //+--------------------------------------------------------------------------
00693 HRESULT
00694 RuSocket::Cleanup()
00695 {
00696     return RuSocketCleanup();
00697 }
00698
00699 //+--------------------------------------------------------------------------
00700 //
00701 // Synopsis: Creates a socket
00702 //
00703 //+--------------------------------------------------------------------------
00704 RuSocket::RuSocket() : m_hSocket(NULL) , m_pfnWSAEventSelect(NULL)
00705 {
00706 }
00707
00708 //+--------------------------------------------------------------------------
00709 //
00710 // Synopsis: Cleans up a socket
00711 //
00712 //+--------------------------------------------------------------------------
00713 RuSocket::~RuSocket()
00714 {
00715     Close();
00716 }
00717
00718 //+--------------------------------------------------------------------------
00719 //
00720 // Synopsis: Creates a socket from an HSOCKET.  Ownership of hSocket is given
00721 //           to this instance of RuSocket.
00722 //
00723 //+--------------------------------------------------------------------------
00724 VOID
00725 RuSocket::Assign(
00726     IN HSOCKET hSocket)
00727 {
00728     Close();
00729     m_hSocket = hSocket;
00730 }
00731
00732 //+--------------------------------------------------------------------------
00733 //
00734 // Synopsis: Opens a socket
00735 //
00736 //+--------------------------------------------------------------------------
00737 HRESULT
00738 RuSocket::Open(
00739     IN UINT uiPort,
00740     IN CHAR* pszHostOrIp,
00741     IN CHAR* pszIpSrc)
00742 {
00743     RU_SOCKET_CREATE_DATA cData = {uiPort, pszHostOrIp, pszIpSrc};
00744
00745     return RuSocketCreate(&cData, &m_hSocket);
00746 }
00747
00748 //+--------------------------------------------------------------------------
00749 //
00750 // Synopsis: Closes a socket
00751 //
00752 //+--------------------------------------------------------------------------
00753 VOID
00754 RuSocket::Close()
00755 {
00756     if (m_hSocket)
00757     {
00758         RuSocketClose(m_hSocket);
00759         m_hSocket = NULL;
00760     }
00761 }
00762
00763 //+--------------------------------------------------------------------------
00764 //
00765 // Synopsis: Retrieves the IPv4 address this socket is bound to.
00766 //
00767 //+--------------------------------------------------------------------------
00768 HRESULT
00769 RuSocket::GetAddress(
00770     OUT DWORD*  lpdwAddress)
00771 {
00772     return RuSocketGetAddress(m_hSocket, lpdwAddress);
00773 }
00774
00775 //+--------------------------------------------------------------------------
00776 //
00777 // Synopsis: Reads from a socket
00778 //
00779 //+--------------------------------------------------------------------------
00780 HRESULT
00781 RuSocket::Read(
00782     IN      BYTE*  pbBuffer,
00783     IN OUT  UINT*  lpuiBufSize,
00784     IN      BOOL   fBlock)
00785 {
00786     if (fBlock)
00787     {
00788         return RuSocketReadBlock(m_hSocket, pbBuffer, lpuiBufSize);
00789     }
00790
00791     return RuSocketRead(m_hSocket, pbBuffer, lpuiBufSize);
00792 }
00793
00794 //+--------------------------------------------------------------------------
00795 //
00796 // Synopsis: Reads the next line of text from a socket
00797 //
00798 //+--------------------------------------------------------------------------
00799 HRESULT
00800 RuSocket::ReadLine(
00801     IN      BYTE*  pbBuffer,
00802     IN OUT  UINT*  lpuiBufSize)
00803 {
00804     return RuSocketReadLine(m_hSocket, pbBuffer, lpuiBufSize);
00805 }
00806
00807 //+--------------------------------------------------------------------------
00808 //
00809 // Synopsis: Reads data current cached in a socket (already received)
00810 //
00811 //+--------------------------------------------------------------------------
00812 HRESULT
00813 RuSocket::ReadCurrent(
00814     IN      BYTE*  pbBuffer,
00815     IN OUT  UINT*  lpuiBufSize,
00816     OUT     BOOL*  pbNoMore)
00817 {
00818     return RuSocketReadCurrent(m_hSocket, pbBuffer, lpuiBufSize, pbNoMore);
00819 }
00820
00821 //+--------------------------------------------------------------------------
00822 //
00823 // Synopsis: Writes to a socket
00824 //
00825 //+--------------------------------------------------------------------------
00826 HRESULT
00827 RuSocket::Write (
00828     IN      BYTE*  pbBuffer,
00829     IN OUT  UINT*  lpuiBufSize)
00830 {
00831     return RuSocketWrite(m_hSocket, pbBuffer, lpuiBufSize);
00832 }
00833
00834 //+--------------------------------------------------------------------------
00835 //
00836 // Synopsis: Writes a line of text to a socket (appends carriage return and
00837 //           linefeed if needed)
00838 //
00839 //+--------------------------------------------------------------------------
00840 HRESULT
00841 RuSocket::WriteLine (
00842     IN      BYTE*  pbBuffer,
00843     IN OUT  UINT*  lpuiBufSize)
00844 {
00845     return RuSocketWriteLine(m_hSocket, pbBuffer, lpuiBufSize);
00846 }
00847
00848 //+--------------------------------------------------------------------------
00849 //
00850 // Synopsis: Causes this socket to signal when something transpires in the
00851 //           system.
00852 //
00853 //+--------------------------------------------------------------------------
00854 HRESULT
00855 RuSocket::SetEvent(
00856     IN HANDLE hEvent,
00857     IN LONG lFlags)
00858 {
00859     INT iRet;
00860
00861     if (m_hSocket == NULL)
00862     {
00863         return E_FAIL;
00864     }
00865
00866     if (m_pfnWSAEventSelect == NULL)
00867     {
00868         m_pfnWSAEventSelect = LookupWSAEventSelect();
00869
00870         if (m_pfnWSAEventSelect == NULL)
00871         {
00872             return E_FAIL;
00873         }
00874     }
00875
00876     iRet = m_pfnWSAEventSelect(m_hSocket->Socket, hEvent, lFlags);
00877     if (iRet != 0)
00878     {
00879         return HRESULT_FROM_WIN32(WSAGetLastError());
00880     }
00881
00882     return S_OK;
00883 }
00884
00885 //+--------------------------------------------------------------------------
00886 //
00887 // Synopsis: Causes this socket to signal when something transpires in the
00888 //           system.
00889 //
00890 //+--------------------------------------------------------------------------
00891 HRESULT
00892 RuServerSocket::SetEvent(
00893     IN HANDLE hEvent,
00894     IN LONG lFlags)
00895 {
00896     INT iRet;
00897
00898     if (m_hSocket == NULL)
00899     {
00900         return E_FAIL;
00901     }
00902
00903     if (m_pfnWSAEventSelect == NULL)
00904     {
00905         m_pfnWSAEventSelect = LookupWSAEventSelect();
00906
00907         if (m_pfnWSAEventSelect == NULL)
00908         {
00909             return E_FAIL;
00910         }
00911     }
00912
00913     iRet = m_pfnWSAEventSelect(m_hSocket->Socket, hEvent, lFlags);
00914     if (iRet != 0)
00915     {
00916         return HRESULT_FROM_WIN32(WSAGetLastError());
00917     }
00918
00919     return S_OK;
00920 }
00921
00922 //+--------------------------------------------------------------------------
00923 //
00924 // Synopsis: Creates a server socket
00925 //
00926 //+--------------------------------------------------------------------------
00927 RuServerSocket::RuServerSocket() : m_hSocket(NULL) , m_pfnWSAEventSelect(NULL)
00928 {
00929 }
00930
00931 //+--------------------------------------------------------------------------
00932 //
00933 // Synopsis: Cleans up a server socket
00934 //
00935 //+--------------------------------------------------------------------------
00936 RuServerSocket::~RuServerSocket()
00937 {
00938     Close();
00939 }
00940
00941 //+--------------------------------------------------------------------------
00942 //
00943 // Synopsis: Binds a server socket to a port and (optional) local address.
00944 //
00945 //+--------------------------------------------------------------------------
00946 HRESULT
00947 RuServerSocket::Create(
00948     IN  UINT uiPort,
00949     IN OPTIONAL CHAR* pszLocalIpAddress)
00950 {
00951     RU_SOCKET_CREATE_DATA cData = {uiPort, pszLocalIpAddress};
00952
00953     return RuSocketCreateServer(&cData, &m_hSocket);
00954 }
00955
00956 //+--------------------------------------------------------------------------
00957 //
00958 // Synopsis: Closes a server socket, releasing the resources associated with
00959 //           it.
00960 //
00961 //+--------------------------------------------------------------------------
00962 VOID
00963 RuServerSocket::Close()
00964 {
00965     if (m_hSocket)
00966     {
00967         RuSocketClose(m_hSocket);
00968         m_hSocket = NULL;
00969     }
00970 }
00971
00972 //+--------------------------------------------------------------------------
00973 //
00974 // Synopsis: Causes the server socket to wait for the next client to connect.
00975 //
00976 //    args:
00977 //       pClient - when a client connects, pClient is opened against the new
00978 //                 client connection then the method returns.
00979 //
00980 //+--------------------------------------------------------------------------
00981 HRESULT
00982 RuServerSocket::Listen(
00983     OUT RuSocket* pClient)
00984 {
00985     HSOCKET hSocket = NULL;
00986     HRESULT hr;
00987
00988     hr = RuSocketListen(m_hSocket, &hSocket);
00989     if (S_OK == hr)
00990     {
00991         pClient->Assign(hSocket);
00992     }
00993
00994     return hr;
00995 }
00996
00997
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpICommandProperties Member List

This is the complete list of members for CImpICommandProperties, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CCommand, CImpICommandProperties) | CImpICommandProperties
GetProperties(const ULONG cPropertySets, const DBPROPIDSET rgPropertySets[], ULONG *pcProperties, DBPROPSET **prgProperties) | CImpICommandProperties
SetProperties(ULONG cPropertySets, DBPROPSET rgPropertySets[]) | CImpICommandProperties
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSmartPtr< T > Member List

This is the complete list of members for CSmartPtr< T >, including all inherited members.
AddRef() | CSmartPtr< T > | [inline]
CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter=NULL, DWORD dwClsContext=CLSCTX_ALL) | CSmartPtr< T > | [inline]
CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter=NULL, DWORD dwClsContext=CLSCTX_ALL) | CSmartPtr< T > | [inline]
CSmartPtr() | CSmartPtr< T > | [inline]
iid() | CSmartPtr< T > | [inline]
m_p | CSmartPtr< T > | [protected]
operator T *() const | CSmartPtr< T > | [inline]
operator!() const | CSmartPtr< T > | [inline]
operator&() | CSmartPtr< T > | [inline]
operator->() const | CSmartPtr< T > | [inline]
operator==(T *pT) const | CSmartPtr< T > | [inline]
QueryInterface(Q **pp) const | CSmartPtr< T > | [inline]
Release() | CSmartPtr< T > | [inline]
~CSmartPtr() | CSmartPtr< T > | [inline]
Generated on Wed Nov 13 2024 16:57:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/list.h Source File

  • NetDS
  • RRas
  • ip

list.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\list.h
00008
00009 Abstract:
00010
00011     The file contains a list implementation.
00012
00013 --*/
00014
00015 #ifndef _LIST_H_
00016 #define _LIST_H_
00017
00018 /*++
00019
00020 The Following are already defined
00021
00022 (public\sdk\inc\winnt.h)
00023
00024 //
00025 // Calculate the byte offset of a 'field' in a structure of type 'type'.
00026 //
00027 // #define FIELD_OFFSET(type, field)                                    \
00028 //     ((LONG)(LONG_PTR)&(((type *)0)->field))
00029 //
00030
00031 //
00032 // Calculate the address of the base of the structure given its 'type',
00033 // and an 'address' of a 'field' within the structure.
00034 //
00035 // #define CONTAINING_RECORD(address, type, field)                      \
00036 //     ((type *)((PCHAR)(address) - (ULONG_PTR)(&((type *)0)->field)))
00037 //
00038
00039 //  Doubly linked list structure.
00040 //
00041 // typedef struct _LIST_ENTRY
00042 // {
00043 //     struct _LIST_ENTRY *Flink;
00044 //     struct _LIST_ENTRY *Blink;
00045 // } LIST_ENTRY, *PLIST_ENTRY;
00046 //
00047
00048 --*/
00049
00050 //
00051 //  Doubly-linked list manipulation routines.  Implemented as macros but
00052 //  logically these are procedures.
00053 //
00054
00055
00056
00057 //
00058 //  VOID
00059 //  InitializeListHead(
00060 //      PLIST_ENTRY ListHead
00061 //      );
00062 //
00063
00064 #define InitializeListHead(ListHead)                            \
00065     ((ListHead)->Flink = (ListHead)->Blink = (ListHead))
00066
00067
00068
00069 //
00070 //  BOOLEAN
00071 //  IsListEmpty(
00072 //      PLIST_ENTRY ListHead
00073 //      );
00074 //
00075
00076 #define IsListEmpty(ListHead)                                   \
00077     ((ListHead)->Flink == (ListHead))
00078
00079
00080
00081 //
00082 //  PLIST_ENTRY
00083 //  RemoveHeadList(
00084 //      PLIST_ENTRY ListHead
00085 //      );
00086 //
00087
00088 #define RemoveHeadList(ListHead)                                \
00089     (ListHead)->Flink;                                          \
00090     {RemoveEntryList((ListHead)->Flink)}
00091
00092
00093
00094 //
00095 //  PLIST_ENTRY
00096 //  RemoveTailList(
00097 //      PLIST_ENTRY ListHead
00098 //      );
00099 //
00100
00101 #define RemoveTailList(ListHead)                                \
00102     (ListHead)->Blink;                                          \
00103     {RemoveEntryList((ListHead)->Blink)}
00104
00105
00106
00107 //
00108 //  VOID
00109 //  RemoveEntryList(
00110 //      PLIST_ENTRY Entry
00111 //      );
00112 //
00113
00114 #define RemoveEntryList(Entry)                                  \
00115 {                                                               \
00116     PLIST_ENTRY _EX_Blink;                                      \
00117     PLIST_ENTRY _EX_Flink;                                      \
00118     _EX_Flink = (Entry)->Flink;                                 \
00119     _EX_Blink = (Entry)->Blink;                                 \
00120     _EX_Blink->Flink = _EX_Flink;                               \
00121     _EX_Flink->Blink = _EX_Blink;                               \
00122 }
00123
00124
00125
00126 //
00127 //  VOID
00128 //  InsertTailList(
00129 //      PLIST_ENTRY ListHead,
00130 //      PLIST_ENTRY Entry
00131 //      );
00132 //
00133
00134 #define InsertTailList(ListHead,Entry)                          \
00135 {                                                               \
00136     PLIST_ENTRY _EX_Blink;                                      \
00137     PLIST_ENTRY _EX_ListHead;                                   \
00138     _EX_ListHead = (ListHead);                                  \
00139     _EX_Blink = _EX_ListHead->Blink;                            \
00140     (Entry)->Flink = _EX_ListHead;                              \
00141     (Entry)->Blink = _EX_Blink;                                 \
00142     _EX_Blink->Flink = (Entry);                                 \
00143     _EX_ListHead->Blink = (Entry);                              \
00144 }
00145
00146
00147
00148 //
00149 //  VOID
00150 //  InsertHeadList(
00151 //      PLIST_ENTRY ListHead,
00152 //      PLIST_ENTRY Entry
00153 //      );
00154 //
00155
00156 #define InsertHeadList(ListHead,Entry)                          \
00157 {                                                               \
00158     PLIST_ENTRY _EX_Flink;                                      \
00159     PLIST_ENTRY _EX_ListHead;                                   \
00160     _EX_ListHead = (ListHead);                                  \
00161     _EX_Flink = _EX_ListHead->Flink;                            \
00162     (Entry)->Flink = _EX_Flink;                                 \
00163     (Entry)->Blink = _EX_ListHead;                              \
00164     _EX_Flink->Blink = (Entry);                                 \
00165     _EX_ListHead->Flink = (Entry);                              \
00166 }
00167
00168
00169
00170 //
00171 //  VOID
00172 //  InsertSortedList(
00173 //      PLIST_ENTRY ListHead,
00174 //      PLIST_ENTRY Entry,
00175 //      LONG(*CompareFunction)(PLIST_ENTRY, PLIST_ENTRY)
00176 //      );
00177 //
00178
00179 #define InsertSortedList(ListHead, Entry, CompareFunction)      \
00180 {                                                               \
00181     PLIST_ENTRY _EX_Entry;                                      \
00182     PLIST_ENTRY _EX_Blink;                                      \
00183     for (_EX_Entry = (ListHead)->Flink;                         \
00184          _EX_Entry != (ListHead);                               \
00185          _EX_Entry = _EX_Entry->Flink)                          \
00186         if ((*(CompareFunction))((Entry), _EX_Entry) <= 0)      \
00187             break;                                              \
00188     _EX_Blink = _EX_Entry->Blink;                               \
00189     _EX_Blink->Flink = (Entry);                                 \
00190     _EX_Entry->Blink = (Entry);                                 \
00191     (Entry)->Flink     = _EX_Entry;                             \
00192     (Entry)->Blink     = _EX_Blink;                             \
00193 }
00194
00195
00196
00197 //
00198 // Finds an 'Entry' equal to 'Key' in a 'List'
00199 //
00200 //  VOID
00201 //  FindList(
00202 //      PLIST_ENTRY ListHead,
00203 //      PLIST_ENTRY Key,
00204 //      PLIST_ENTRY *Entry,
00205 //      LONG (*CompareFunction)(PLIST_ENTRY, PLIST_ENTRY)
00206 //      );
00207 //
00208
00209 #define FindList(ListHead, Key, Entry, CompareFunction)         \
00210 {                                                               \
00211     PLIST_ENTRY _EX_Entry;                                      \
00212     *(Entry) = NULL;                                            \
00213     for (_EX_Entry = (ListHead)->Flink;                         \
00214          _EX_Entry != (ListHead);                               \
00215          _EX_Entry = _EX_Entry->Flink)                          \
00216         if ((*(CompareFunction))((Key), _EX_Entry) is 0)        \
00217         {                                                       \
00218             *(Entry) = _EX_Entry;                               \
00219             break;                                              \
00220         }                                                       \
00221 }
00222
00223
00224
00225 //
00226 // Finds an 'Entry' equal to or greater than 'Key' in a sorted 'List'
00227 //
00228 //  VOID
00229 //  FindSortedList(
00230 //      PLIST_ENTRY ListHead,
00231 //      PLIST_ENTRY Key,
00232 //      PLIST_ENTRY *Entry,
00233 //      LONG (*CompareFunction)(PLIST_ENTRY, PLIST_ENTRY)
00234 //      );
00235 //
00236
00237 #define FindSortedList(ListHead, Key, Entry, CompareFunction)   \
00238 {                                                               \
00239     PLIST_ENTRY _EX_Entry;                                      \
00240     *(Entry) = NULL;                                            \
00241     for (_EX_Entry = (ListHead)->Flink;                         \
00242          _EX_Entry != (ListHead);                               \
00243          _EX_Entry = _EX_Entry->Flink)                          \
00244         if ((*(CompareFunction))((Key), _EX_Entry) <= 0)        \
00245         {                                                       \
00246             *(Entry) = _EX_Entry;                               \
00247             break;                                              \
00248         }                                                       \
00249 }
00250
00251
00252
00253 //
00254 // Applies a 'Function' to all entries in a list.
00255 //
00256 //  VOID
00257 //  MapCarList(
00258 //      PLIST_ENTRY ListHead,
00259 //      VOID(*VoidFunction)(PLIST_ENTRY)
00260 //      );
00261 //
00262
00263 #define MapCarList(ListHead, VoidFunction)                      \
00264 {                                                               \
00265     PLIST_ENTRY _EX_Entry;                                      \
00266     for (_EX_Entry = (ListHead)->Flink;                         \
00267          _EX_Entry != (ListHead);                               \
00268          _EX_Entry = _EX_Entry->Flink)                          \
00269         (*(VoidFunction))(_EX_Entry);                           \
00270 }
00271
00272
00273
00274 //
00275 // Frees a list.
00276 //
00277 //  VOID
00278 //  FreeList(
00279 //      PLIST_ENTRY ListHead,
00280 //      VOID(*FreeFunction)(PLIST_ENTRY)
00281 //      );
00282 //
00283
00284 #define FreeList(ListHead, FreeFunction)                        \
00285 {                                                               \
00286     PLIST_ENTRY _EX_Head;                                       \
00287     while (!IsListEmpty(ListHead))                              \
00288     {                                                           \
00289         _EX_Head = RemoveHeadList(ListHead);                    \
00290         (*(FreeFunction))(_EX_Head);                            \
00291     }                                                           \
00292 }
00293
00294
00295
00296 #define QUEUE_ENTRY                     LIST_ENTRY
00297 #define PQUEUE_ENTRY                    PLIST_ENTRY
00298
00299 //
00300 //  VOID
00301 //  InitializeQueueHead(
00302 //      PQUEUE_ENTRY QueueHead
00303 //      );
00304 //
00305
00306 #define InitializeQueueHead(QueueHead)  InitializeListHead(QueueHead)
00307
00308 //
00309 //  BOOLEAN
00310 //  IsQueueEmpty(
00311 //      PQUEUE_ENTRY QueueHead
00312 //      );
00313 //
00314
00315 #define IsQueueEmpty(QueueHead)         IsListEmpty(QueueHead)
00316
00317 //
00318 //  VOID
00319 //  Enqueue(
00320 //      PQUEUE_ENTRY QueueHead,
00321 //      PQUEUE_ENTRY Entry
00322 //      );
00323 //
00324
00325 #define Enqueue(QueueHead, Entry)       InsertTailList(QueueHead, Entry)
00326
00327 //
00328 //  PQUEUE_ENTRY
00329 //  Dequeue(
00330 //      PQUEUE_ENTRY QueueHead,
00331 //      );
00332 //
00333
00334 #define Dequeue(QueueHead)              RemoveHeadList(QueueHead)
00335
00336 //
00337 //  VOID
00338 //  FreeQueue(
00339 //      PQUEUE_ENTRY QueueHead,
00340 //      VOID(*FreeFunction)(PQUEUE_ENTRY)
00341 //      );
00342 //
00343
00344 #define FreeQueue(QueueHead, FreeFunction)                      \
00345     FreeList(QueueHead, FreeFunction)
00346
00347 //
00348 //  VOID
00349 //  MapCarQueue(
00350 //      PQUEUE_ENTRY QueueHead,
00351 //      VOID(*VoidFunction)(PQUEUE_ENTRY)
00352 //      );
00353 //
00354
00355 #define MapCarQueue(QueueHead, VoidFunction)                    \
00356     MapCarList(QueueHead, VoidFunction)
00357
00358
00359
00360 #define STACK_ENTRY                     LIST_ENTRY
00361 #define PSTACK_ENTRY                    PLIST_ENTRY
00362
00363 //
00364 //  VOID
00365 //  InitializeStackHead(
00366 //      PSTACK_ENTRY StackHead
00367 //      );
00368 //
00369
00370 #define InitializeStackHead(StackHead)  InitializeListHead(StackHead)
00371
00372 //
00373 //  BOOLEAN
00374 //  IsStackEmpty(
00375 //      PSTACK_ENTRY StackHead
00376 //      );
00377 //
00378
00379 #define IsStackEmpty(StackHead)         IsListEmpty(StackHead)
00380
00381 //
00382 //  VOID
00383 //  Push(
00384 //      PSTACK_ENTRY StackHead,
00385 //      PSTACK_ENTRY Entry
00386 //      );
00387 //
00388
00389 #define Push(StackHead, Entry)          InsertHeadList(StackHead, Entry)
00390
00391 //
00392 //  PSTACK_ENTRY
00393 //  Pop(
00394 //      PSTACK_ENTRY StackHead,
00395 //      );
00396 //
00397
00398 #define Pop(StackHead)                  RemoveHeadList(StackHead)
00399
00400 //
00401 //  VOID
00402 //  FreeStack(
00403 //      PSTACK_ENTRY StackHead,
00404 //      VOID(*FreeFunction)(PSTACK_ENTRY)
00405 //      );
00406 //
00407
00408 #define FreeStack(StackHead, FreeFunction)                      \
00409     FreeList(StackHead, FreeFunction)
00410
00411 //
00412 //  VOID
00413 //  MapCarStack(
00414 //      PSTACK_ENTRY StackHead,
00415 //      VOID(*VoidFunction)(PSTACK_ENTRY)
00416 //      );
00417 //
00418
00419 #define MapCarStack(StackHead, VoidFunction)                    \
00420     MapCarList(StackHead, VoidFunction)
00421
00422 #endif // _LIST_H_
00423
00424
00425
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/staticnode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

staticnode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Defines the CStaticNode class.  This is the Snap-in's
00014 //                top level node
00015 //
00016
00017
00018 #ifndef _CLASS_CSTATICNODE_
00019 #define _CLASS_CSTATICNODE_
00020
00021 #include "Globals.h"
00022 #include "BaseNode.h"          // For NODE_PROPERTIES
00023 #include "LListImpl.h"
00024
00025 class CDeviceNode;             // References
00026 class CComponentData;
00027
00028
00029 //---------------------------------------------------------------------------
00030 class CStaticNode : public CBaseNode
00031 {
00032   public:
00033     CStaticNode();
00034     virtual ~CStaticNode();
00035
00036     HRESULT Initialize( NODE_PROPERTIES* pNodeProps );
00037
00038   ///////////////////////////////////////////////////////////////////////////
00039   // Virtual methods
00040   public:
00041     ULONG   GetNodeType() { return NODETYPE_STATIC; }
00042     GUID&   GetNodeGUID() { return thisGUID; }
00043
00044     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo );
00045     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI );
00046     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00047
00048   ///////////////////////////////////////////////////////////////////////////
00049   // Property Page methods
00050   public:
00051     HRESULT QueryForPropertyPage()
00052             { return E_NOTIMPL; }
00053
00054     HRESULT CreatePropertyPages( LPPROPERTYSHEETCALLBACK lpCallback, LONG_PTR Handle )
00055             { return E_NOTIMPL; }
00056
00057     HRESULT GetWatermarks( HBITMAP __RPC_FAR *lphWatermark,
00058                            HBITMAP __RPC_FAR *lphHeader,
00059                            HPALETTE __RPC_FAR *lphPalette,
00060                            BOOL __RPC_FAR *bStretch )
00061             { return E_NOTIMPL; }
00062
00063   ///////////////////////////////////////////////////////////////////////////
00064   // Notification handlers
00065   public:
00066     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00067     HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent );
00068     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00069     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData );
00070     HRESULT OnContextHelp( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00071             { return E_NOTIMPL; }
00072
00073     HRESULT OnDelete( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00074             { return E_NOTIMPL; }
00075
00076   /////////////////////////////////////////////////////////////////////////
00077   //  Context Menu methods
00078   public:
00079     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00080     HRESULT Command( long lCommandID );
00081
00082   ///////////////////////////////////////////////////////////////////////////
00083   // Private helpers
00084   private:
00085     HRESULT  DeleteScopeItems( LPCONSOLENAMESPACE2 ipCNS2 );
00086     HRESULT  InsertScopeItems( LPCONSOLENAMESPACE2 ipCNS2 );
00087     HRESULT  RefreshNodeList();
00088     VOID     RemoveNodes();
00089
00090   ///////////////////////////////////////////////////////////////////////////
00091   // Public helpers
00092   public:
00093     HRESULT  AddDeviceNode( NODE_PROPERTIES* pProperties );
00094     VOID     ToggleStatus( LPDATAOBJECT ipDataObject );
00095     HWND     GetMessageWnd() { return m_hMessageWnd; }
00096
00097     static LRESULT CALLBACK StaticNodeWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
00098
00099   private:
00100     static GUID      thisGUID;
00101     HSCOPEITEM       m_hStaticNode;
00102     CComponentData*  m_pCompData;
00103     HWND             m_hMessageWnd;        // Our message handler
00104
00105     CLListImpl<CDeviceNode*,CDeviceNode*>  m_NodeList;
00106
00107   public:
00108     HWND             m_hAddDeviceDlg;      // Instance of AddDeviceDlg
00109
00110 };
00111
00112 #endif //_CLASS_CSTATICNODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/debug.h Source File

  • Com
  • Fundamentals
  • OleStd

debug.h

Go to the documentation of this file.
00001 /*
00002  * DEBUG.H
00003  *
00004  * Definitions, structures, types, and function prototypes for debugging
00005  * purposes.
00006  *
00007  * Copyright (c)1992 - 2000 Microsoft Corporation, All Right Reserved,
00008  * as applied to redistribution of this source code in source form
00009  * License is granted to use of compiled code in shipped binaries.
00010  */
00011
00012 #ifndef _DEBUG_H_
00013 #define _DEBUG_H_
00014
00015 #ifdef DEBUG
00016
00017 //Basic debug macros
00018 #define D(x)        {x;}
00019 #define ODS(x)      D(OutputDebugString(x);OutputDebugString("\r\n"))
00020
00021 #define ODSsz(f, s)  {\
00022            char        szDebug[128];\
00023            wsprintf(szDebug, f, (LPSTR)s);\
00024            ODS(szDebug);\
00025            }
00026
00027
00028 #define ODSu(f, u)  {\
00029           char        szDebug[128];\
00030           wsprintf(szDebug, f, (UINT)u);\
00031           ODS(szDebug);\
00032           }
00033
00034
00035 #define ODSlu(f, lu) {\
00036            char        szDebug[128];\
00037            wsprintf(szDebug, f, (DWORD)lu);\
00038            ODS(szDebug);\
00039            }
00040
00041 #define ODSszu(f, s, u) {\
00042             char        szDebug[128];\
00043             wsprintf(szDebug, f, (LPSTR)s, (UINT)u);\
00044             ODS(szDebug);\
00045             }
00046
00047
00048 #define ODSszlu(f, s, lu) {\
00049               char        szDebug[128];\
00050               wsprintf(szDebug, f, (LPSTR)s, (DWORD)lu);\
00051               ODS(szDebug);\
00052               }
00053
00054
00055 #else   //NO DEBUG
00056
00057 #define D(x)
00058 #define ODS(x)
00059
00060 #define ODSsz(f, s)
00061 #define ODSu(f, u)
00062 #define ODSlu(f, lu)
00063 #define ODSszu(f, s, u)
00064 #define ODSszlu(f, s, lu)
00065
00066
00067 #endif //DEBUG
00068
00069 #endif //_DEBUG_H_
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/Eap/Eap.c Source File

  • NetDS
  • RRas
  • Eap

Eap.c

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1997, Microsoft Corporation, all rights reserved
00004
00005 Description:
00006     Sample Extensible Authentication Protocol. Here is a graphic of the EAP
00007     sample protocol:
00008
00009                 Authenticator                       Authenticatee
00010                 -------------                       -------------
00011
00012                                 "Send Password"
00013                             ---------------------->
00014                                   EAP Request
00015
00016                                   <password>
00017                             <----------------------
00018                                   EAP Response
00019
00020                             ----------------------->
00021                                  Success/Failure
00022
00023 History:
00024
00025 */
00026
00027 #include <windows.h>
00028 #include <winuser.h>
00029 #include <lmcons.h>
00030 #include <string.h>
00031 #include <stdlib.h>
00032 #include <raseapif.h>
00033 #include <raserror.h>
00034 #include <rtutils.h>
00035 #include <stdio.h>
00036 #define SDEBUGGLOBALS
00037 #define RASEAPGLOBALS
00038 #include "eap.h"
00039 #include "resource.h"
00040
00041 /*---------------------------------------------------------------------------
00042     External entry points
00043 ---------------------------------------------------------------------------*/
00044 /*
00045
00046 Notes:
00047     RasEapGetInfo entry point called by the EAP-PPP engine by name.
00048
00049 */
00050
00051 DWORD APIENTRY
00052 RasEapGetInfo(
00053     IN  DWORD         dwEapTypeId,
00054     OUT PPP_EAP_INFO* pInfo
00055 )
00056 {
00057     EapTrace("RasEapGetInfo");
00058
00059     if (dwEapTypeId != PPP_EAP_PROTOCOL_ID)
00060     {
00061         //
00062         // We only support PPP_EAP_PROTOCOL_ID eap type
00063         //
00064
00065         EapTrace("Type ID %d is not supported", dwEapTypeId);
00066
00067         return(ERROR_NOT_SUPPORTED);
00068     }
00069
00070     ZeroMemory(pInfo, sizeof(PPP_EAP_INFO));
00071
00072     //
00073     // Fill in the required information
00074     //
00075
00076     pInfo->dwEapTypeId       = PPP_EAP_PROTOCOL_ID;
00077     pInfo->RasEapBegin       = EapBegin;
00078     pInfo->RasEapEnd         = EapEnd;
00079     pInfo->RasEapMakeMessage = EapMakeMessage;
00080
00081     return(NO_ERROR);
00082 }
00083
00084 /*
00085
00086 Notes:
00087     EapBegin entry point called by the EAP PPP engine thru the passed address.
00088
00089 */
00090
00091 DWORD APIENTRY
00092 EapBegin(
00093     OUT VOID** ppWorkBuf,
00094     IN  VOID*  pInfo
00095 )
00096 {
00097     PPP_EAP_INPUT* pInput = (PPP_EAP_INPUT*)pInfo;
00098     EAPCB*         pwb;
00099
00100     EapTrace("EapBegin(%ws)", pInput->pwszIdentity);
00101
00102     //
00103     // Allocate work buffer.
00104     //
00105
00106     if ((pwb = (EAPCB*)LocalAlloc(LPTR, sizeof(EAPCB))) == NULL)
00107     {
00108         EapTrace("Not enough memory");
00109         return(ERROR_NOT_ENOUGH_MEMORY);
00110     }
00111
00112     //
00113     // Save information passed in, will be used later
00114     //
00115
00116     pwb->fFlags             = pInput->fFlags;
00117     pwb->fAuthenticator     = pInput->fAuthenticator;
00118     pwb->EapState           = MYSTATE_Initial;
00119     pwb->dwInitialPacketId  = pInput->bInitialId;
00120
00121     if (pInput->pDataFromInteractiveUI != NULL)
00122     {
00123         pwb->dwSizeOfDataFromInteractiveUI =
00124             pInput->dwSizeOfDataFromInteractiveUI;
00125         pwb->pDataFromInteractiveUI =
00126             LocalAlloc(LPTR, pwb->dwSizeOfDataFromInteractiveUI);
00127
00128         if (NULL != pwb->pDataFromInteractiveUI)
00129         {
00130             CopyMemory(pwb->pDataFromInteractiveUI,
00131                 pInput->pDataFromInteractiveUI,
00132                 pwb->dwSizeOfDataFromInteractiveUI);
00133         }
00134     }
00135
00136     //
00137     // Save the identity. On the authenticatee side, this is obtained by user
00138     // input; on the authenticator side this was obtained by the Identity
00139     // request message.
00140     //
00141
00142     WideCharToMultiByte(
00143         CP_ACP,
00144         0,
00145         pInput->pwszIdentity,
00146         -1,
00147         pwb->aszIdentity,
00148         UNLEN + 1,
00149         NULL,
00150         NULL );
00151
00152     //
00153     // If we are an authenticatee, then use the password passed in
00154     //
00155
00156     if (!pwb->fAuthenticator)
00157     {
00158         if (   (NULL != pInput->pUserData)
00159             && (sizeof(EAP_NAME_DIALOG) == pInput->dwSizeOfUserData))
00160         {
00161             WideCharToMultiByte(
00162                 CP_ACP,
00163                 0,
00164                 ((EAP_NAME_DIALOG*)(pInput->pUserData))->awszPassword,
00165                 -1,
00166                 pwb->aszPassword,
00167                 PWLEN + 1,
00168                 NULL,
00169                 NULL );
00170         }
00171     }
00172
00173     //
00174     // Register work buffer with engine.
00175     //
00176
00177     *ppWorkBuf = pwb;
00178
00179     return(NO_ERROR);
00180 }
00181
00182 /*
00183
00184 Notes:
00185     EapEnd entry point called by the PPP engine thru the passed address.
00186     See EAP interface documentation.
00187
00188 */
00189
00190 DWORD APIENTRY
00191 EapEnd(
00192     IN VOID* pWorkBuf
00193 )
00194 {
00195     EAPCB* pwb = (EAPCB *)pWorkBuf;
00196
00197     if (pwb == NULL)
00198     {
00199         return(NO_ERROR);
00200     }
00201
00202     //
00203     // Release all resources used by this authentication session.
00204     //
00205
00206     EapTrace("EapEnd(%s)", pwb->aszIdentity);
00207
00208     LocalFree(pwb->pUIContext);
00209     LocalFree(pwb->pDataFromInteractiveUI);
00210
00211     if (pwb->pUserAttributes != NULL)
00212     {
00213         //
00214         // Free up Attributes
00215         //
00216
00217         LocalFree(pwb->pUserAttributes[0].Value);
00218         LocalFree(pwb->pUserAttributes[1].Value);
00219         LocalFree(pwb->pUserAttributes);
00220     }
00221
00222     if (pwb->pMPPEKeyAttributes != NULL)
00223     {
00224         //
00225         // Free up the MPPE Key Attributes
00226         //
00227
00228         LocalFree(pwb->pMPPEKeyAttributes[0].Value);
00229         LocalFree(pwb->pMPPEKeyAttributes);
00230     }
00231
00232     ZeroMemory(pwb, sizeof(EAPCB));
00233
00234     LocalFree(pwb);
00235
00236     return(NO_ERROR);
00237 }
00238
00239 /*
00240
00241 Notes:
00242     RasEapMakeMessage entry point called by the PPP engine thru the passed
00243     address.
00244
00245 */
00246
00247 DWORD APIENTRY
00248 EapMakeMessage(
00249     IN  VOID*               pWorkBuf,
00250     IN  PPP_EAP_PACKET*     pReceiveBuf,
00251     OUT PPP_EAP_PACKET*     pSendBuf,
00252     IN  DWORD               cbSendBuf,
00253     OUT PPP_EAP_OUTPUT*     pResult,
00254     IN  PPP_EAP_INPUT*      pInput
00255 )
00256 {
00257     EAPCB*  pwb = (EAPCB*)pWorkBuf;
00258
00259     EapTrace("EapMakeMessage(%s)", pwb->aszIdentity);
00260
00261     //
00262     // Call the appropriate routine to process the event.
00263     //
00264
00265     if (pwb->fAuthenticator)
00266     {
00267         return(AuthenticatorMakeMessage(pwb,
00268                                         pReceiveBuf,
00269                                         pSendBuf,
00270                                         cbSendBuf,
00271                                         pInput,
00272                                         pResult));
00273     }
00274     else
00275     {
00276         return(AuthenticateeMakeMessage(pwb,
00277                                         pReceiveBuf,
00278                                         pSendBuf,
00279                                         cbSendBuf,
00280                                         pInput,
00281                                         pResult));
00282     }
00283 }
00284
00285 /*
00286
00287 Notes:
00288     RasEapGetIdentity entry point called by the EAP-PPP engine by name.
00289
00290 */
00291
00292 DWORD APIENTRY
00293 RasEapGetIdentity(
00294     IN  DWORD           dwEapTypeId,
00295     IN  HWND            hwndParent,
00296     IN  DWORD           dwFlags,
00297     IN  const WCHAR*    pwszPhonebook,
00298     IN  const WCHAR*    pwszEntry,
00299     IN  BYTE*           pConnectionDataIn,
00300     IN  DWORD           dwSizeOfConnectionDataIn,
00301     IN  BYTE*           pUserDataIn,
00302     IN  DWORD           dwSizeOfUserDataIn,
00303     OUT BYTE**          ppUserDataOut,
00304     OUT DWORD*          pdwSizeOfUserDataOut,
00305     OUT WCHAR**         ppwszIdentity
00306 )
00307 {
00308     DWORD               dwErr           = NO_ERROR;
00309
00310     if ( dwFlags & RAS_EAP_FLAG_NON_INTERACTIVE )
00311     {
00312         dwErr = ERROR_INTERACTIVE_MODE;
00313         goto LDone;
00314     }
00315
00316     if ( dwFlags & RAS_EAP_FLAG_MACHINE_AUTH )
00317     {
00318         dwErr = ERROR_NOT_SUPPORTED;
00319         goto LDone;
00320     }
00321
00322     if (dwFlags & RAS_EAP_FLAG_ROUTER)
00323     {
00324         //
00325         // A routing interface must have its credentials set beforehand
00326         //
00327
00328         if (   (NULL == pUserDataIn)
00329             || (sizeof(EAP_NAME_DIALOG) != dwSizeOfUserDataIn))
00330         {
00331             //
00332             // Bad saved credentials
00333             //
00334
00335             EapTrace("Credentials for this interface have not been set");
00336             dwErr = E_FAIL;
00337             goto LDone;
00338         }
00339     }
00340     else
00341     {
00342         //
00343         // Ignore old values. Prompt for username and password.
00344         //
00345
00346         pUserDataIn = NULL;
00347     }
00348
00349     dwErr = GetIdentity(
00350                     hwndParent,
00351                     pUserDataIn,
00352                     dwSizeOfUserDataIn,
00353                     ppUserDataOut,
00354                     pdwSizeOfUserDataOut,
00355                     ppwszIdentity);
00356
00357 LDone:
00358
00359     return(dwErr);
00360 }
00361
00362 /*
00363
00364 Notes:
00365     RasEapInvokeConfigUI entry point called by the EAP-PPP engine by name.
00366
00367 */
00368
00369 DWORD APIENTRY
00370 RasEapInvokeConfigUI(
00371     IN  DWORD       dwEapTypeId,
00372     IN  HWND        hwndParent,
00373     IN  DWORD       dwFlags,
00374     IN  BYTE*       pConnectionDataIn,
00375     IN  DWORD       dwSizeOfConnectionDataIn,
00376     OUT BYTE**      ppConnectionDataOut,
00377     OUT DWORD*      pdwSizeOfConnectionDataOut
00378 )
00379 {
00380     DWORD       dwDisplayedNumber;
00381     WCHAR       awszMessage[100];
00382     DWORD       dwErr               = NO_ERROR;
00383
00384     *ppConnectionDataOut = NULL;
00385     *pdwSizeOfConnectionDataOut = 0;
00386
00387     if (   (NULL == pConnectionDataIn)
00388         || (0 == dwSizeOfConnectionDataIn))
00389     {
00390         //
00391         // We are configuring for the first time
00392         //
00393
00394         dwDisplayedNumber = 1;
00395     }
00396     else
00397     {
00398         //
00399         // How many times has this been configured?
00400         //
00401
00402         dwDisplayedNumber = *(DWORD*)pConnectionDataIn;
00403     }
00404
00405     swprintf(awszMessage, L"%5d times", dwDisplayedNumber);
00406
00407     MessageBox(hwndParent, awszMessage,
00408         L"You have configured this interface...", MB_OK | MB_ICONINFORMATION);
00409
00410     //
00411     // Allocate memory for the OUT parameter
00412     //
00413
00414     *ppConnectionDataOut = (BYTE*)LocalAlloc(LPTR, sizeof(DWORD));
00415
00416     if (NULL == *ppConnectionDataOut)
00417     {
00418         dwErr = ERROR_NOT_ENOUGH_MEMORY;
00419         goto LDone;
00420     }
00421
00422     //
00423     // This has been configured one more time
00424     //
00425
00426     dwDisplayedNumber += 1;
00427
00428     //
00429     // Set the OUT parameters
00430     //
00431
00432     CopyMemory(*ppConnectionDataOut, (BYTE*)&dwDisplayedNumber,
00433         sizeof(DWORD));
00434     *pdwSizeOfConnectionDataOut = sizeof(DWORD);
00435
00436 LDone:
00437
00438     return(dwErr);
00439 }
00440
00441 /*
00442
00443 Notes:
00444     RasEapInvokeInteractiveUI entry point called by the EAP-PPP engine by name.
00445
00446 */
00447
00448 DWORD APIENTRY
00449 RasEapInvokeInteractiveUI(
00450     IN  DWORD           dwEapTypeId,
00451     IN  HWND            hWndParent,
00452     IN  PBYTE           pUIContextData,
00453     IN  DWORD           dwSizeofUIContextData,
00454     OUT PBYTE *         ppDataFromInteractiveUI,
00455     OUT DWORD *         lpdwSizeOfDataFromInteractiveUI
00456 )
00457 {
00458     EapTrace("RasEapInvokeInteractiveUI");
00459
00460     if (MessageBox(hWndParent,
00461                       (WCHAR*)pUIContextData,
00462                       L"EAP sample",
00463                       MB_OKCANCEL) == IDOK)
00464     {
00465         *lpdwSizeOfDataFromInteractiveUI = (wcslen(L"OK") + 1) * sizeof(WCHAR);
00466
00467         if ((*ppDataFromInteractiveUI =
00468                     LocalAlloc(LPTR, *lpdwSizeOfDataFromInteractiveUI)) == NULL)
00469         {
00470             return(ERROR_NOT_ENOUGH_MEMORY);
00471         }
00472
00473         wcsncpy((WCHAR*)*ppDataFromInteractiveUI, L"OK", (*lpdwSizeOfDataFromInteractiveUI) - 1);
00474     }
00475     else
00476     {
00477         *ppDataFromInteractiveUI         = NULL;
00478         *lpdwSizeOfDataFromInteractiveUI = 0;
00479     }
00480
00481     return(NO_ERROR);
00482 }
00483
00484 /*
00485
00486 Notes:
00487     RasEapFreeMemory entry point called by the EAP-PPP engine by name.
00488
00489 */
00490
00491 DWORD APIENTRY
00492 RasEapFreeMemory(
00493     IN  BYTE*   pMemory
00494 )
00495 {
00496     EapTrace("RasEapFreeMemory");
00497     LocalFree(pMemory);
00498     return(NO_ERROR);
00499 }
00500
00501 /*---------------------------------------------------------------------------
00502     Internal routines
00503 ---------------------------------------------------------------------------*/
00504
00505 /*
00506
00507 Notes:
00508     Print debug information.
00509
00510 */
00511
00512 VOID
00513 EapTrace(
00514     IN  CHAR*   Format,
00515     ...
00516 )
00517 {
00518     va_list arglist;
00519
00520     va_start(arglist, Format);
00521
00522     TraceVprintfExA(g_dwEapTraceId,
00523         0x00010000 | TRACE_USE_MASK | TRACE_USE_MSEC,
00524         Format,
00525         arglist);
00526
00527     va_end(arglist);
00528 }
00529
00530 /*
00531
00532 Notes:
00533     Will convert a 32 bit integer from host format to wire format.
00534
00535 */
00536
00537 VOID
00538 HostToWireFormat32(
00539     IN     DWORD dwHostFormat,
00540     IN OUT PBYTE pWireFormat
00541 )
00542 {
00543     *((PBYTE)(pWireFormat)+0) = (BYTE) ((DWORD)(dwHostFormat) >> 24);
00544     *((PBYTE)(pWireFormat)+1) = (BYTE) ((DWORD)(dwHostFormat) >> 16);
00545     *((PBYTE)(pWireFormat)+2) = (BYTE) ((DWORD)(dwHostFormat) >>  8);
00546     *((PBYTE)(pWireFormat)+3) = (BYTE) (dwHostFormat);
00547 }
00548
00549 /*
00550
00551 Notes:
00552     Will convert a 16 bit integer from host format to wire format.
00553
00554 */
00555
00556 VOID
00557 HostToWireFormat16(
00558     IN     WORD  wHostFormat,
00559     IN OUT PBYTE pWireFormat
00560 )
00561 {
00562     *((PBYTE)(pWireFormat)+0) = (BYTE) ((DWORD)(wHostFormat) >>  8);
00563     *((PBYTE)(pWireFormat)+1) = (BYTE) (wHostFormat);
00564 }
00565
00566 /*
00567
00568 Notes:
00569     Will convert a 16 bit integer from wire format to host format.
00570
00571 */
00572
00573 WORD
00574 WireToHostFormat16(
00575     IN PBYTE pWireFormat
00576 )
00577 {
00578     WORD wHostFormat = ((*((PBYTE)(pWireFormat)+0) << 8) +
00579                         (*((PBYTE)(pWireFormat)+1)));
00580
00581     return(wHostFormat);
00582 }
00583
00584 /*
00585
00586 Notes:
00587     Authenticatee side event handler.
00588
00589 */
00590
00591 DWORD
00592 AuthenticateeMakeMessage(
00593     IN  EAPCB*            pwb,
00594     IN  PPP_EAP_PACKET*   pReceiveBuf,
00595     OUT PPP_EAP_PACKET*   pSendBuf,
00596     IN  DWORD             cbSendBuf,
00597     IN  PPP_EAP_INPUT*    pInput,
00598     OUT PPP_EAP_OUTPUT*   pResult
00599 )
00600 {
00601     DWORD dwRetCode = NO_ERROR;
00602     BYTE* pDataFromInteractiveUI;
00603     DWORD dwSizeOfDataFromInteractiveUI;
00604
00605     EapTrace("AuthenticateeMakeMessage");
00606
00607     switch(pwb->EapState)
00608     {
00609         case MYSTATE_Initial:
00610
00611             if (pwb->fFlags & RAS_EAP_FLAG_ROUTER)
00612             {
00613                 pwb->EapState = MYSTATE_WaitForRequest;
00614
00615                 break;
00616             }
00617             pwb->bRecvPacketId = pReceiveBuf->Id;
00618             if (NULL == pwb->pDataFromInteractiveUI)
00619             {
00620                 WCHAR * pUIContextData = L"You are being authenticated by a Sample EAP";
00621                 //
00622                 // Bring up interactive UI to notify user that he/she is being
00623                 // authenticated via the sample EAP
00624                 //
00625
00626                 pResult->fInvokeInteractiveUI = TRUE;
00627
00628                 pResult->dwSizeOfUIContextData =
00629                    (wcslen(pUIContextData)+1) *
00630                        sizeof(WCHAR);
00631
00632                 pResult->pUIContextData = LocalAlloc(
00633                                               LPTR,
00634                                               pResult->dwSizeOfUIContextData);
00635
00636                 if (pResult->pUIContextData == NULL)
00637                 {
00638                     EapTrace("OUt of memory");
00639                     return(ERROR_NOT_ENOUGH_MEMORY);
00640                 }
00641
00642                 wcsncpy((WCHAR*)pResult->pUIContextData,
00643                        pUIContextData,
00644                        wcslen(pUIContextData)
00645                       );
00646
00647                 pwb->pUIContext = pResult->pUIContextData;
00648
00649                 pwb->EapState = MYSTATE_WaitForUserOK;
00650
00651                 break;
00652             }
00653
00654             //
00655             // Else, fall through
00656             //
00657
00658         case MYSTATE_WaitForUserOK:
00659
00660             //
00661             // Wait for response from user
00662             //
00663
00664             if (   pInput->fDataReceivedFromInteractiveUI
00665                 || (NULL != pwb->pDataFromInteractiveUI))
00666             {
00667                 if (pInput->fDataReceivedFromInteractiveUI)
00668                 {
00669                     pDataFromInteractiveUI =
00670                             pInput->pDataFromInteractiveUI;
00671                     dwSizeOfDataFromInteractiveUI =
00672                             pInput->dwSizeOfDataFromInteractiveUI;
00673                 }
00674                 else
00675                 {
00676                     pDataFromInteractiveUI =
00677                             pwb->pDataFromInteractiveUI;
00678                     dwSizeOfDataFromInteractiveUI =
00679                             pwb->dwSizeOfDataFromInteractiveUI;
00680                 }
00681
00682                 LocalFree(pwb->pUIContext);
00683                 pwb->pUIContext = NULL;
00684
00685                 //
00686                 // If user doesn't like this, then we hangup the line
00687                 //
00688
00689                 if (dwSizeOfDataFromInteractiveUI !=
00690                             (wcslen(L"OK")+1) * sizeof(WCHAR))
00691                 {
00692                     EapTrace("User chose to cancel");
00693                     dwRetCode = ERROR_ACCESS_DENIED;
00694                     break;
00695                 }
00696
00697                 if (wcscmp((WCHAR*)pDataFromInteractiveUI, L"OK") != 0)
00698                 {
00699                     EapTrace("User chose to cancel");
00700                     dwRetCode = ERROR_ACCESS_DENIED;
00701                     break;
00702                 }
00703
00704
00705                 pwb->EapState = MYSTATE_WaitForRequest;
00706             }
00707             else
00708             {
00709                 //
00710                 // Ignore all other events.
00711                 //
00712
00713                 pResult->Action = EAPACTION_NoAction;
00714             }
00715
00716             if ( !(pwb->fFlags & RAS_EAP_FLAG_8021X_AUTH ) )
00717             {
00718                 //
00719                 // if this is a VPN client, we can rely on
00720                 // retransmission.  But with wireless client
00721                 // we cannot do that.
00722                 //
00723                 break;
00724             }
00725             //fall thru
00726
00727         case MYSTATE_WaitForRequest:
00728
00729             if ( (pwb->fFlags & RAS_EAP_FLAG_8021X_AUTH ) )
00730             {
00731                 //
00732                 // Build the response packet
00733                 //
00734                 MakeResponseMessage1(pwb, pSendBuf, cbSendBuf);
00735
00736                 //
00737                 // Response packets should not be sent with any timeout
00738                 //
00739
00740                 pResult->Action = EAPACTION_Send;
00741
00742                 //
00743                 // We are done so we change to MYSTATE_Done
00744                 //
00745
00746                 pwb->EapState = MYSTATE_Done;
00747
00748                 break;
00749
00750             }
00751             else if (pReceiveBuf != NULL )
00752             {
00753                 //
00754                 // If we received a request packet from the server then we
00755                 // process it.
00756                 //
00757
00758                 if (pReceiveBuf->Code == EAPCODE_Request)
00759                 {
00760                     //
00761                     // Build the response packet
00762                     //
00763
00764                     MakeResponseMessage(pwb, pReceiveBuf, pSendBuf, cbSendBuf);
00765
00766                     //
00767                     // Response packets should not be sent with any timeout
00768                     //
00769
00770                     pResult->Action = EAPACTION_Send;
00771
00772                     //
00773                     // We are done so we change to MYSTATE_Done
00774                     //
00775
00776                     pwb->EapState = MYSTATE_Done;
00777
00778                     break;
00779                 }
00780                 else
00781                 {
00782                     //
00783                     // We shouldn't get any other packet in this state so
00784                     // we simply drop this invalid packet
00785                     //
00786
00787                     pResult->Action = EAPACTION_NoAction;
00788                     dwRetCode = ERROR_PPP_INVALID_PACKET;
00789                     break;
00790                 }
00791             }
00792
00793             break;
00794
00795         case MYSTATE_Done:
00796         {
00797             if (pReceiveBuf == NULL)
00798             {
00799                 //
00800                 // If we did not receive a packet then we check to see if
00801                 // the fSuccessPacketReceived flag is set
00802                 //
00803
00804                 if ((pInput != NULL) && (pInput->fSuccessPacketReceived))
00805                 {
00806                     //
00807                     // We are done
00808                     //
00809
00810                     //
00811                     // Create the MPPE Key Attribute and give it to the EAP-PPP
00812                     // engine.
00813                     //
00814
00815                     dwRetCode = MakeMPPEKeyAttributes(pwb);
00816
00817                     if (NO_ERROR == dwRetCode)
00818                     {
00819                         pResult->pUserAttributes = pwb->pMPPEKeyAttributes;
00820                     }
00821
00822                     pResult->Action = EAPACTION_Done;
00823                     pwb->EapState   = MYSTATE_Done;
00824                 }
00825                 else
00826                 {
00827                     //
00828                     // Otherwise we ignore this event
00829                     //
00830
00831                     pResult->Action = EAPACTION_NoAction;
00832                 }
00833
00834                 break;
00835             }
00836
00837             if ((pReceiveBuf->Code == EAPCODE_Success) ||
00838                 (pReceiveBuf->Code == EAPCODE_Failure))
00839             {
00840                 if (pReceiveBuf->Code == EAPCODE_Success)
00841                 {
00842                     //
00843                     // If we received success or failure, we are done, but first
00844                     // make sure the ID's match
00845                     //
00846
00847                     //
00848                     // Create the MPPE Key Attribute and give it to the EAP-PPP
00849                     // engine.
00850                     //
00851
00852                     dwRetCode = MakeMPPEKeyAttributes(pwb);
00853
00854                     if (NO_ERROR == dwRetCode)
00855                     {
00856                         pResult->pUserAttributes = pwb->pMPPEKeyAttributes;
00857                     }
00858
00859                     pResult->Action = EAPACTION_Done;
00860                     pwb->EapState   = MYSTATE_Done;
00861                 }
00862                 else
00863                 {
00864                     //
00865                     // Otherwise drop the packet
00866                     //
00867
00868                     pResult->Action = EAPACTION_NoAction;
00869                     dwRetCode       = ERROR_PPP_INVALID_PACKET;
00870                 }
00871
00872                 break;
00873             }
00874             else if (pReceiveBuf->Code == EAPCODE_Request)
00875             {
00876                 //
00877                 // We must always respond to requests
00878                 //
00879
00880                 MakeResponseMessage(pwb, pReceiveBuf, pSendBuf, cbSendBuf);
00881
00882                 //
00883                 // Response packets should not be sent with any timeout
00884                 //
00885
00886                 pResult->Action = EAPACTION_Send;
00887             }
00888             else
00889             {
00890                 //
00891                 // Otherwise we received an illegal packet, wrong code set
00892                 // So simply drop the packet.
00893                 //
00894
00895                 pResult->Action = EAPACTION_NoAction;
00896                 dwRetCode       = ERROR_PPP_INVALID_PACKET;
00897             }
00898         }
00899     }
00900
00901     return(dwRetCode);
00902 }
00903
00904
00905 VOID
00906 MakeResponseMessage1(
00907     IN  EAPCB*           pwb,
00908     OUT PPP_EAP_PACKET * pSendBuf,
00909     IN  DWORD            cbSendBuf
00910 )
00911 {
00912     BYTE* pcbPassword;
00913     CHAR* pchPassword;
00914
00915     EapTrace("MakeResponseMessage1");
00916
00917     (void)cbSendBuf;
00918
00919     //
00920     // Fill in the password.
00921     //
00922
00923     pcbPassword = pSendBuf->Data + 1;
00924
00925     *pcbPassword = (BYTE)strlen(pwb->aszPassword);
00926
00927     pchPassword = pcbPassword + 1;
00928
00929     strcpy(pchPassword, pwb->aszPassword);
00930
00931     //
00932     // Set the response code
00933     //
00934
00935     pSendBuf->Code = (BYTE)EAPCODE_Response;
00936
00937     //
00938     // The Reponse packet Id MUST match the Request packet Id.
00939     //
00940
00941     pSendBuf->Id = pwb->bRecvPacketId;
00942
00943     //
00944     // The Success/Failure packet that we get must match the ID of the last
00945     // response sent
00946     //
00947
00948     pwb->dwIdExpected = pSendBuf->Id;
00949
00950     //
00951     // Set the EAP type ID
00952     //
00953
00954     pSendBuf->Data[0] = (BYTE)PPP_EAP_PROTOCOL_ID;
00955
00956     //
00957     // Set the length of the packet
00958     //
00959
00960     HostToWireFormat16((WORD)(PPP_EAP_PACKET_HDR_LEN+1+*pcbPassword+1),
00961                        pSendBuf->Length);
00962 }
00963 /*
00964
00965 Notes:
00966     Builds a response packet. 'pwb' is the address of the work
00967     buffer associated with the port.
00968
00969 */
00970
00971 VOID
00972 MakeResponseMessage(
00973     IN  EAPCB*           pwb,
00974     IN  PPP_EAP_PACKET * pReceiveBuf,
00975     OUT PPP_EAP_PACKET * pSendBuf,
00976     IN  DWORD            cbSendBuf
00977 )
00978 {
00979     BYTE* pcbPassword;
00980     CHAR* pchPassword;
00981
00982     EapTrace("MakeResponseMessage");
00983
00984     (void)cbSendBuf;
00985
00986     //
00987     // Fill in the password.
00988     //
00989
00990     pcbPassword = pSendBuf->Data + 1;
00991
00992     *pcbPassword = (BYTE)strlen(pwb->aszPassword);
00993
00994     pchPassword = pcbPassword + 1;
00995
00996     strcpy(pchPassword, pwb->aszPassword);
00997
00998     //
00999     // Set the response code
01000     //
01001
01002     pSendBuf->Code = (BYTE)EAPCODE_Response;
01003
01004     //
01005     // The Reponse packet Id MUST match the Request packet Id.
01006     //
01007
01008     pSendBuf->Id = pReceiveBuf->Id;
01009
01010     //
01011     // The Success/Failure packet that we get must match the ID of the last
01012     // response sent
01013     //
01014
01015     pwb->dwIdExpected = pSendBuf->Id;
01016
01017     //
01018     // Set the EAP type ID
01019     //
01020
01021     pSendBuf->Data[0] = (BYTE)PPP_EAP_PROTOCOL_ID;
01022
01023     //
01024     // Set the length of the packet
01025     //
01026
01027     HostToWireFormat16((WORD)(PPP_EAP_PACKET_HDR_LEN+1+*pcbPassword+1),
01028                        pSendBuf->Length);
01029 }
01030
01031 /*
01032
01033 Notes:
01034     Builds a result packet (Success or Failure) in caller's 'pSendBuf'
01035     buffer. 'cbSendBuf' is the length of caller's buffer.
01036     'dwError' indicates whether an Success or Failure should be generated,
01037     'bId' is the Id of the Success of Failure packet.
01038
01039 */
01040
01041 VOID
01042 MakeResultMessage(
01043     IN  EAPCB *         pwb,
01044     IN  DWORD           dwError,
01045     OUT PPP_EAP_PACKET* pSendBuf,
01046     IN  DWORD           cbSendBuf
01047 )
01048 {
01049     EapTrace("MakeResultMessage");
01050
01051     (void)cbSendBuf;
01052
01053     //
01054     // If there was no error then we send a Success packet, otherwise we send
01055     // a failure message
01056     //
01057
01058     if (dwError == NO_ERROR)
01059     {
01060         pSendBuf->Code = EAPCODE_Success;
01061     }
01062     else
01063     {
01064         pSendBuf->Code = EAPCODE_Failure;
01065     }
01066
01067     //
01068     // The Id of a success or failure message MUST match the Id of the last
01069     // response received from the client according to the EAP spec.
01070     //
01071
01072     pSendBuf->Id = (BYTE)pwb->dwInitialPacketId;
01073
01074     //
01075     // Set the length
01076     //
01077
01078     HostToWireFormat16((WORD)PPP_EAP_PACKET_HDR_LEN, (PBYTE)pSendBuf->Length);
01079 }
01080
01081 /*
01082
01083 Notes:
01084     Will build a request packet.
01085
01086 */
01087
01088 VOID
01089 MakeRequestMessage(
01090     IN  EAPCB*           pwb,
01091     OUT PPP_EAP_PACKET * pSendBuf,
01092     IN DWORD             cbSendBuf
01093 )
01094 {
01095     BYTE *pcbPeerMessage;
01096     CHAR *pchPeerMessage;
01097
01098     EapTrace("MakeRequestMessage");
01099
01100     pcbPeerMessage  = pSendBuf->Data + 1;
01101
01102     *pcbPeerMessage = (BYTE)strlen("send password");
01103
01104     pchPeerMessage  = pcbPeerMessage + 1;
01105
01106     strncpy(pchPeerMessage, "send password", strlen ("send password"));
01107
01108     //
01109     // Set the Request Code
01110     //
01111
01112     pSendBuf->Code = EAPCODE_Request;
01113
01114     //
01115     // Set the request packet identifier. Start with the Id that was give to us
01116     //
01117
01118     pSendBuf->Id = (BYTE)pwb->dwInitialPacketId;
01119
01120     //
01121     // Set the length
01122     //
01123
01124     HostToWireFormat16((WORD)(PPP_EAP_PACKET_HDR_LEN+1+*pcbPeerMessage+1),
01125                               pSendBuf->Length);
01126
01127     //
01128     // Set the EAP Type Id
01129     //
01130
01131     pSendBuf->Data[0] = PPP_EAP_PROTOCOL_ID;
01132
01133 }
01134
01135 /*
01136
01137 Notes:
01138     Authenticator side event handler.
01139
01140 */
01141
01142 DWORD
01143 AuthenticatorMakeMessage(
01144     IN  EAPCB*              pwb,
01145     IN  PPP_EAP_PACKET*     pReceiveBuf,
01146     OUT PPP_EAP_PACKET*     pSendBuf,
01147     IN  DWORD               cbSendBuf,
01148     IN  PPP_EAP_INPUT*      pInput,
01149     OUT PPP_EAP_OUTPUT*     pResult
01150 )
01151 {
01152     DWORD dwRetCode = NO_ERROR;
01153
01154     EapTrace("AuthenticatorMakeMessage");
01155
01156     switch(pwb->EapState)
01157     {
01158         case MYSTATE_ReqSent:
01159
01160             if (pReceiveBuf != NULL)
01161             {
01162                 //
01163                 // If we received a packet
01164                 //
01165
01166                 if (pReceiveBuf->Code == EAPCODE_Response)
01167                 {
01168                     //
01169                     // If we received a response to our identity request,
01170                     // then process it. There is no need to check the Id
01171                     // here since the PPP engine will only pass on packets
01172                     // whose Id matches those set with the
01173                     // EAPACTION_SendWithTimeout action.
01174                     //
01175
01176                     dwRetCode = GetPasswordFromResponse(pReceiveBuf,
01177                                                          pwb->aszPassword);
01178
01179                     if (dwRetCode != NO_ERROR)
01180                     {
01181                         if (dwRetCode != ERROR_PPP_INVALID_PACKET)
01182                         {
01183                             //
01184                             // Fatal error, we fail the connection.
01185                             //
01186
01187                             return(dwRetCode);
01188                         }
01189                     }
01190                     else
01191                     {
01192                         //
01193                         // Request authentication provider to authenticate
01194                         // this user.
01195                         //
01196
01197                         dwRetCode = MakeAuthenticationAttributes(
01198                                                             pwb->aszIdentity,
01199                                                             pwb->aszPassword,
01200                                                             pwb);
01201
01202                         if (dwRetCode != NO_ERROR)
01203                         {
01204                             return(dwRetCode);
01205                         }
01206                         else
01207                         {
01208                             //
01209                             // Authentication request completed successfully.
01210                             // This is an asynchronous call so we change state
01211                             // and wait for the provider to complete the
01212                             // authentication.
01213                             //
01214
01215                             pResult->pUserAttributes = pwb->pUserAttributes;
01216
01217                             pResult->Action = EAPACTION_Authenticate;
01218
01219                             //
01220                             // Save Id so that we can send the correct one
01221                             // in the success/failure packet
01222                             //
01223
01224                             pwb->dwIdExpected = pReceiveBuf->Id;
01225
01226                             pwb->EapState =
01227                                     MYSTATE_WaitForAuthenticationToComplete;
01228                         }
01229                     }
01230
01231                     break;
01232                 }
01233                 else
01234                 {
01235                     //
01236                     // Otherwise silently drop the packet.
01237                     // We should only get requests
01238                     //
01239
01240                     pResult->Action = EAPACTION_NoAction;
01241
01242                     break;
01243                 }
01244             }
01245
01246             break;
01247
01248         case MYSTATE_Initial:
01249
01250             //
01251             // Create Request packet
01252             //
01253
01254             MakeRequestMessage(pwb, pSendBuf, cbSendBuf);
01255
01256             //
01257             // Request messages must be sent with a timeout
01258             //
01259
01260             pResult->Action = EAPACTION_SendWithTimeoutInteractive;
01261
01262             //
01263             // Since we have sent a request we change to the ReqSent state
01264             // where we will wait for a response.
01265             //
01266
01267             pwb->EapState = MYSTATE_ReqSent;
01268
01269             break;
01270
01271         case MYSTATE_WaitForAuthenticationToComplete:
01272         {
01273             if (pInput != NULL)
01274             {
01275                 //
01276                 // Did the authentication provider complete the authentication?
01277                 //
01278
01279                 if (pInput->fAuthenticationComplete)
01280                 {
01281                     //
01282                     // If the user failed to authenticate, save the failure
01283                     // code.
01284                     //
01285
01286                     if (pInput->dwAuthResultCode != NO_ERROR)
01287                     {
01288                         pwb->dwResult = pInput->dwAuthResultCode;
01289                     }
01290
01291                     pResult->Action = EAPACTION_SendAndDone;
01292                     pwb->EapState   = MYSTATE_Done;
01293
01294                     //
01295                     // fall thru to the MYSTATE_Done state where we will
01296                     // send a Success or Failure packet
01297                     //
01298                 }
01299             }
01300
01301             if ((pInput == NULL) || (!pInput->fAuthenticationComplete))
01302             {
01303                 //
01304                 // Ignore everything if authentication is not complete
01305                 //
01306
01307                 pResult->Action = EAPACTION_NoAction;
01308
01309                 break;
01310             }
01311
01312             //
01313             // ...fall thru to the MYSTATE_Done state where we will
01314             // send a Success or Failure packet
01315             //
01316         }
01317
01318         case MYSTATE_Done:
01319         {
01320             //
01321             // Make Success or Failure packet.
01322             //
01323
01324             MakeResultMessage(pwb, pwb->dwResult, pSendBuf, cbSendBuf);
01325
01326             if (NO_ERROR == pwb->dwResult)
01327             {
01328                 //
01329                 // If we made a Success packet, create the MPPE Key Attribute
01330                 // and give it to the EAP-PPP engine.
01331                 //
01332
01333                 dwRetCode = MakeMPPEKeyAttributes(pwb);
01334
01335                 if (NO_ERROR == dwRetCode)
01336                 {
01337                     pResult->pUserAttributes = pwb->pMPPEKeyAttributes;
01338                 }
01339             }
01340
01341             pResult->Action = EAPACTION_SendAndDone;
01342
01343             pResult->dwAuthResultCode = pwb->dwResult;
01344
01345             break;
01346         }
01347
01348         default:
01349
01350             break;
01351     }
01352
01353     return(dwRetCode);
01354
01355 }
01356
01357 /*
01358
01359 Notes:
01360     Fill caller's pszPassword' buffer with the password, in the request
01361     packet.
01362
01363     Returns NO_ERROR if successful., or ERROR_PPP_INVALID_PACKET if the
01364     packet is misformatted in any way.
01365
01366 */
01367
01368 DWORD
01369 GetPasswordFromResponse(
01370     IN  PPP_EAP_PACKET* pReceiveBuf,
01371     OUT CHAR*           pszPassword
01372 )
01373 {
01374     BYTE* pcbPassword;
01375     CHAR* pchPassword;
01376     WORD  cbPacket;
01377
01378     EapTrace("GetPasswordFromResponse");
01379
01380     cbPacket = WireToHostFormat16(pReceiveBuf->Length);
01381
01382     //
01383     // Extract the password
01384     //
01385
01386     if (cbPacket < (PPP_EAP_PACKET_HDR_LEN + 1 + 1))
01387     {
01388         EapTrace("Number of bytes in the EAP packet is only %d", cbPacket);
01389
01390         return(ERROR_PPP_INVALID_PACKET);
01391     }
01392
01393     pcbPassword = pReceiveBuf->Data + 1;
01394     pchPassword = pcbPassword + 1;
01395
01396     if (cbPacket < PPP_EAP_PACKET_HDR_LEN + 1 + 1 + *pcbPassword)
01397     {
01398         EapTrace("Number of characters in password is %d", *pcbPassword);
01399         EapTrace("Number of bytes in the EAP packet is only %d", cbPacket);
01400
01401         return ERROR_PPP_INVALID_PACKET;
01402     }
01403     if ( *pcbPassword >  PWLEN )
01404     {
01405         EapTrace ("Password length received in the packet is > PWLEN" );
01406         return ERROR_PPP_INVALID_PACKET;
01407     }
01408     CopyMemory(pszPassword, pchPassword, *pcbPassword);
01409
01410     //
01411     // NULL terminate the password
01412     //
01413
01414     pszPassword[ *pcbPassword ] = '\0';
01415
01416     return(NO_ERROR);
01417 }
01418
01419 /*
01420
01421 Notes:
01422     Will build user attributes and send them to the authentication provider
01423     for authentication.
01424
01425 */
01426
01427 DWORD
01428 MakeAuthenticationAttributes(
01429     IN CHAR *   szUserName,
01430     IN CHAR *   szPassword,
01431     IN EAPCB *  pwb
01432 )
01433 {
01434     EapTrace("MakeAuthenticationAttributes");
01435
01436     if (pwb->pUserAttributes != NULL)
01437     {
01438         LocalFree(pwb->pUserAttributes[0].Value);
01439         LocalFree(pwb->pUserAttributes[1].Value);
01440         LocalFree(pwb->pUserAttributes);
01441
01442         pwb->pUserAttributes = NULL;
01443     }
01444
01445     pwb->pUserAttributes = (RAS_AUTH_ATTRIBUTE *)
01446                            LocalAlloc(LPTR, sizeof (RAS_AUTH_ATTRIBUTE) * 3);
01447
01448     if (pwb->pUserAttributes == NULL)
01449     {
01450         return(GetLastError());
01451     }
01452
01453     //
01454     // for user name
01455     //
01456
01457     pwb->pUserAttributes[0].raaType  = raatUserName;
01458     pwb->pUserAttributes[0].dwLength = strlen(szUserName);
01459     pwb->pUserAttributes[0].Value    = LocalAlloc(LPTR, (strlen(szUserName)+1));
01460
01461     if (pwb->pUserAttributes[0].Value == NULL)
01462     {
01463         LocalFree(pwb->pUserAttributes);
01464
01465         pwb->pUserAttributes = NULL;
01466
01467         return(GetLastError());
01468     }
01469
01470     CopyMemory(pwb->pUserAttributes[0].Value,szUserName, strlen(szUserName));
01471
01472     //
01473     // for password
01474     //
01475
01476     pwb->pUserAttributes[1].raaType  = raatUserPassword;
01477     pwb->pUserAttributes[1].dwLength = strlen(szPassword);
01478     pwb->pUserAttributes[1].Value    = LocalAlloc(LPTR, (strlen(szPassword)+1));
01479
01480     if (pwb->pUserAttributes[1].Value == NULL)
01481     {
01482         LocalFree(pwb->pUserAttributes[0].Value);
01483
01484         LocalFree(pwb->pUserAttributes);
01485
01486         pwb->pUserAttributes = NULL;
01487
01488         return(GetLastError());
01489     }
01490
01491     CopyMemory(pwb->pUserAttributes[1].Value,szPassword, strlen(szPassword));
01492
01493     //
01494     // For Termination
01495     //
01496
01497     pwb->pUserAttributes[2].raaType  = raatMinimum;
01498     pwb->pUserAttributes[2].dwLength = 0;
01499     pwb->pUserAttributes[2].Value    = NULL;
01500
01501     return(NO_ERROR);
01502 }
01503
01504 /*
01505
01506 Notes:
01507
01508 */
01509
01510 DWORD
01511 MakeMPPEKeyAttributes(
01512     IN EAPCB *  pwb
01513 )
01514 {
01515     DWORD   dwErr           = NO_ERROR;
01516     DWORD   dwIndex;
01517     DWORD   dwSendPattern;
01518     DWORD   dwRecvPattern;
01519     BYTE*   pByte;
01520
01521     EapTrace("MakeMPPEKeyAttributes");
01522
01523     if (NULL != pwb->pMPPEKeyAttributes)
01524     {
01525         //
01526         // Free up the MPPE Key Attributes if they exist
01527         //
01528
01529         LocalFree(pwb->pMPPEKeyAttributes[0].Value);
01530         LocalFree(pwb->pMPPEKeyAttributes[1].Value);
01531         LocalFree(pwb->pMPPEKeyAttributes);
01532         pwb->pMPPEKeyAttributes = NULL;
01533     }
01534
01535     //
01536     // We need 3 RAS_AUTH_ATTRIBUTE structs: for MS-MPPE-Send-Key,
01537     // MS-MPPE-Recv-Key, and termination
01538     //
01539
01540     pwb->pMPPEKeyAttributes = (RAS_AUTH_ATTRIBUTE *) LocalAlloc(
01541                 LPTR, sizeof(RAS_AUTH_ATTRIBUTE) * 3);
01542
01543     if (NULL == pwb->pMPPEKeyAttributes)
01544     {
01545         dwErr = GetLastError();
01546         goto LDone;
01547     }
01548
01549     if (pwb->fAuthenticator)
01550     {
01551         dwSendPattern = 0xAB;
01552         dwRecvPattern = 0xCD;
01553     }
01554     else
01555     {
01556         dwSendPattern = 0xCD;
01557         dwRecvPattern = 0xAB;
01558     }
01559
01560     //
01561     // Bytes needed:
01562     //      4: Vendor-Id
01563     //      1: Vendor-Type
01564     //      1: Vendor-Length
01565     //      2: Salt
01566     //      1: Key-Length
01567     //     32: Key
01568     //     15: Padding
01569     //     -----------------
01570     //     56: Total
01571     //
01572
01573     //
01574     // Copy MS-MPPE-Send-Key
01575     //
01576
01577     pwb->pMPPEKeyAttributes[0].Value = LocalAlloc(LPTR, 56);
01578
01579     if (pwb->pMPPEKeyAttributes[0].Value == NULL)
01580     {
01581         dwErr = GetLastError();
01582         goto LDone;
01583     }
01584
01585     pByte = pwb->pMPPEKeyAttributes[0].Value;
01586
01587     HostToWireFormat32(311, pByte); // Vendor-Id
01588     pByte[4] = 16;                  // Vendor-Type (MS-MPPE-Send-Key)
01589     pByte[5] = 56 - 4;              // Vendor-Length (all except Vendor-Id)
01590     // pByte[6-7] is the zero-filled salt field
01591     pByte[8] = 32;                  // Key-Length
01592
01593     {
01594         //
01595         // This is just an example. Copy a real key here.
01596         //
01597
01598         CopyMemory(pByte + 9, pwb->aszPassword, 32);
01599
01600         for (dwIndex = 0; dwIndex < 32; dwIndex++)
01601         {
01602             pByte[9 + dwIndex] ^= dwSendPattern;
01603         }
01604     }
01605
01606     // pByte[41-55] is the Padding (zero octets)
01607
01608     pwb->pMPPEKeyAttributes[0].dwLength = 56;
01609     pwb->pMPPEKeyAttributes[0].raaType  = raatVendorSpecific;
01610
01611     //
01612     // Copy MS-MPPE-Recv-Key
01613     //
01614
01615     pwb->pMPPEKeyAttributes[1].Value = LocalAlloc(LPTR, 56);
01616
01617     if (pwb->pMPPEKeyAttributes[1].Value == NULL)
01618     {
01619         dwErr = GetLastError();
01620         goto LDone;
01621     }
01622
01623     pByte = pwb->pMPPEKeyAttributes[1].Value;
01624
01625     HostToWireFormat32(311, pByte); // Vendor-Id
01626     pByte[4] = 17;                  // Vendor-Type (MS-MPPE-Recv-Key)
01627     pByte[5] = 56 - 4;              // Vendor-Length (all except Vendor-Id)
01628     // pByte[6-7] is the zero-filled salt field
01629     pByte[8] = 32;                  // Key-Length
01630
01631     {
01632         //
01633         // This is just an example. Copy a real key here.
01634         //
01635
01636         CopyMemory(pByte + 9, pwb->aszPassword, 32);
01637
01638         for (dwIndex = 0; dwIndex < 32; dwIndex++)
01639         {
01640             pByte[9 + dwIndex] ^= dwRecvPattern;
01641         }
01642     }
01643
01644     // pByte[41-55] is the Padding (zero octets)
01645
01646     pwb->pMPPEKeyAttributes[1].dwLength = 56;
01647     pwb->pMPPEKeyAttributes[1].raaType  = raatVendorSpecific;
01648
01649     //
01650     // For Termination
01651     //
01652
01653     pwb->pMPPEKeyAttributes[2].raaType  = raatMinimum;
01654     pwb->pMPPEKeyAttributes[2].dwLength = 0;
01655     pwb->pMPPEKeyAttributes[2].Value    = NULL;
01656
01657 LDone:
01658
01659     if (NO_ERROR != dwErr)
01660     {
01661         //
01662         // If something failed, free the allocated memory
01663         //
01664
01665         if (pwb->pMPPEKeyAttributes != NULL)
01666         {
01667             LocalFree(pwb->pMPPEKeyAttributes[0].Value);
01668             LocalFree(pwb->pMPPEKeyAttributes[1].Value);
01669             LocalFree(pwb->pMPPEKeyAttributes);
01670             pwb->pMPPEKeyAttributes = NULL;
01671         }
01672     }
01673
01674     return(dwErr);
01675 }
01676
01677 /*
01678
01679 Notes:
01680
01681 */
01682
01683 DWORD
01684 GetIdentity(
01685     IN  HWND    hwndParent,
01686     IN  BYTE*   pUserDataIn,
01687     IN  DWORD   dwSizeOfUserDataIn,
01688     OUT BYTE**  ppUserDataOut,
01689     OUT DWORD*  pdwSizeOfUserDataOut,
01690     OUT WCHAR** ppwszIdentity
01691 )
01692 {
01693     EAP_NAME_DIALOG*    pEapNameDialog  = NULL;
01694     WCHAR*              pwszIdentity     = NULL;
01695     DWORD               dwErr           = NO_ERROR;
01696
01697
01698     //
01699     // Allocate memory for OUT parameters
01700     //
01701
01702     pEapNameDialog = LocalAlloc(LPTR, sizeof(EAP_NAME_DIALOG));
01703
01704     if (NULL == pEapNameDialog)
01705     {
01706         EapTrace("Out of memory");
01707         dwErr = GetLastError();
01708         goto LDone;
01709     }
01710
01711     pwszIdentity = LocalAlloc(LPTR, (UNLEN + 1) * sizeof(WCHAR));
01712
01713     if (NULL == pwszIdentity)
01714     {
01715         EapTrace("Out of memory");
01716         dwErr = GetLastError();
01717         goto LDone;
01718     }
01719
01720     if (NULL != pUserDataIn)
01721     {
01722         //
01723         // Use the saved credentials if they exist
01724         //
01725
01726         CopyMemory(pEapNameDialog, pUserDataIn, sizeof(EAP_NAME_DIALOG));
01727     }
01728     else
01729     {
01730         //
01731         // Else prompt for username and password
01732         //
01733
01734         GetUsernameAndPassword(hwndParent, pEapNameDialog);
01735     }
01736
01737     wcscpy(pwszIdentity, pEapNameDialog->awszIdentity);
01738
01739     //
01740     // Set the OUT paramters
01741     //
01742
01743     *ppUserDataOut = (BYTE*)pEapNameDialog;
01744     *pdwSizeOfUserDataOut = sizeof(EAP_NAME_DIALOG);
01745     *ppwszIdentity = pwszIdentity;
01746
01747     //
01748     // We mustn't LocalFree OUT parameters
01749     //
01750
01751     pEapNameDialog = NULL;
01752     pwszIdentity = NULL;
01753
01754 LDone:
01755
01756     LocalFree(pEapNameDialog);
01757     LocalFree(pwszIdentity);
01758
01759     return(dwErr);
01760 }
01761
01762 /*---------------------------------------------------------------------------
01763     Dialog routines
01764 ---------------------------------------------------------------------------*/
01765
01766 /*
01767
01768 Notes:
01769     Displays the IDD_DIALOG dialog, and fills up pEapNameDialog with the
01770     username and password.
01771
01772 */
01773
01774 VOID
01775 GetUsernameAndPassword(
01776     IN  HWND                hwndParent,
01777     IN  EAP_NAME_DIALOG*    pEapNameDialog
01778 )
01779 {
01780     DialogBoxParam(
01781         g_hInstance,
01782         MAKEINTRESOURCE(IDD_DIALOG),
01783         hwndParent,
01784         UsernameDialogProc,
01785         (LPARAM)pEapNameDialog);
01786 }
01787
01788 /*
01789
01790 Notes:
01791     Callback function used with the DialogBoxParam function. It processes
01792     messages sent to the dialog box. See the DialogProc documentation in MSDN.
01793
01794 */
01795
01796 INT_PTR CALLBACK
01797 UsernameDialogProc(
01798     IN  HWND    hWnd,
01799     IN  UINT    unMsg,
01800     IN  WPARAM  wParam,
01801     IN  LPARAM  lParam
01802 )
01803 {
01804     EAP_NAME_DIALOG*    pEapNameDialog;
01805
01806     switch (unMsg)
01807     {
01808     case WM_INITDIALOG:
01809
01810         return(InitUsernameDialog(hWnd, lParam));
01811
01812     case WM_COMMAND:
01813
01814         pEapNameDialog = (EAP_NAME_DIALOG*)GetWindowLongPtr(hWnd, DWLP_USER);
01815
01816         return(UsernameCommand(pEapNameDialog, LOWORD(wParam), hWnd));
01817     }
01818
01819     return(FALSE);
01820 }
01821
01822 /*
01823
01824 Returns:
01825     FALSE (prevent Windows from setting the default keyboard focus).
01826
01827 Notes:
01828     Response to the WM_INITDIALOG message.
01829
01830 */
01831
01832 BOOL
01833 InitUsernameDialog(
01834     IN  HWND    hWnd,
01835     IN  LPARAM  lParam
01836 )
01837 {
01838     HWND    hWndEdit;
01839
01840     SetWindowLongPtr(hWnd, DWLP_USER, lParam);
01841
01842     return(FALSE);
01843 }
01844
01845 /*
01846
01847 Returns:
01848     TRUE: We prrocessed this message.
01849     FALSE: We did not prrocess this message.
01850
01851 Notes:
01852     Response to the WM_COMMAND message.
01853
01854 */
01855
01856 BOOL
01857 UsernameCommand(
01858     IN  EAP_NAME_DIALOG*    pEapNameDialog,
01859     IN  WORD                wId,
01860     IN  HWND                hWndDlg
01861 )
01862 {
01863     HWND    hWnd;
01864
01865     switch(wId)
01866     {
01867     case IDOK:
01868
01869         //
01870         // Save whatever the user typed in as the user name
01871         //
01872
01873         hWnd = GetDlgItem(hWndDlg, IDC_EDIT_NAME);
01874         GetWindowText(hWnd, pEapNameDialog->awszIdentity, UNLEN + 1);
01875
01876         //
01877         // Save whatever the user typed in as the password
01878         //
01879
01880         hWnd = GetDlgItem(hWndDlg, IDC_EDIT_PASSWD);
01881         GetWindowText(hWnd, pEapNameDialog->awszPassword, PWLEN + 1);
01882
01883         // Fall through
01884
01885     case IDCANCEL:
01886
01887         EndDialog(hWndDlg, wId);
01888         return(TRUE);
01889
01890     default:
01891
01892         return(FALSE);
01893     }
01894 }
01895
01896
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ITEM_DESC Member List

This is the complete list of members for _ITEM_DESC, including all inherited members.
ArraySize | _ITEM_DESC
DataSize | _ITEM_DESC
Entry | _ITEM_DESC
ItemType | _ITEM_DESC
strDescription | _ITEM_DESC
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/HiPerfProvider/BasicHiPerf.h Source File

  • SysMgmt
  • WMI
  • VC
  • HiPerfProvider

BasicHiPerf.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002
00003 //
00004
00005 //  BasicHiPerf.h
00006
00007 //
00008
00009 //  Module: WMI high performance provider sample code
00010
00011 //
00012
00013 //  This is the skeleton code implementation of a high performance
00014
00015 //  provider.  This file includes the provider and refresher code
00016
00017 //
00018
00019 //  In this example, we are using a single object scenario.  The
00020
00021 //  provider provides one type of object called Win32_BasicHiPerf.
00022
00023 //  There is a static number of instances available, specified by
00024
00025 //  NUM_INSTANCES and maintained by the CHiPerfProvider class.
00026
00027 //  When a refresher is created, it has two local caches: one
00028
00029 //  for the instances that it contains, and another for the
00030
00031 //  enumerators.  Since there is only one class, only one enumerator
00032
00033 //  should be necessary, but there can be up to MAX_ENUMERATORS
00034
00035 //  enumerators added to a given refresher.  The members of a refresher
00036
00037 //  are given IDs.  The IDs for the enumerators are essentially array
00038
00039 //  indecies into the enumerator array.  The IDs for the objects are
00040
00041 //  stored in an array that maps the unique ID to one of the cached
00042
00043 //  objects.  The enumerator IDs are within the range of 0 to
00044
00045 //  MAX_ENUMERATORS - 1, and the objects will have IDs equal or greater
00046
00047 //  than MAX_ENUMERATORS.
00048
00049 //
00050
00051 //  The actual counter data is simulated by the CSampleDataSource
00052
00053 //  which maintains a set of CSampleInstances.  Periodically, the
00054
00055 //  CSampleInstance counter values are updated.  The objects in the
00056
00057 //  refresher are only updated on a refresh.
00058
00059 //
00060
00061 //  History:
00062
00063 //  a-dcrews  12-Jan-99   Created
00064
00065 //  a-dcrews  10-Mar-99   Added data source simulation
00066
00067 //
00068
00069 //
00070
00071 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00072 //
00073 /////////////////////////////////////////////////////////////////////
00074
00075 #ifndef _HIPERFPROV_H_
00076 #define _HIPERFPROV_H_
00077
00078 #define UNICODE
00079 #define _UNICODE
00080
00081 #include <tchar.h>
00082 #include <wbemprov.h>
00083
00084 class CRefresher;
00085 class CRefCacheElement;
00086
00087 //////////////////////////////////////////////////////////////
00088 //
00089 //
00090 //  Constants and globals
00091 //
00092 //
00093 //////////////////////////////////////////////////////////////
00094
00095 #define NUM_OBJECTS       1
00096 #define NUM_INSTANCES     5
00097 #define MAX_INSTANCES     128
00098 #define MAX_ENUMERATORS     10
00099
00100 #define SAMPLE_CLASS      _T("Win32_BasicHiPerf")
00101
00102 #define PROP_DWORD  0x0001L
00103 #define PROP_QWORD  0x0002L
00104 #define PROP_VALUE  0x0004L
00105
00106 //  This enumeration is used to reference the counters.  It
00107 //  matchs the number of counters in the mof definition of
00108 //  the Win32_BasicHiPerf object.
00109
00110 const enum CounterHandles
00111 {
00112   ctr1 = 0,
00113   ctr2,
00114   ctr3,
00115   ctr4,
00116   ctr5,
00117   NumCtrs
00118 };
00119
00120 //////////////////////////////////////////////////////////////
00121 //
00122 //  CCacheMapEl
00123 //
00124 //  The IDs assigned to objects added to the refresher are
00125 //  mapped to the actual object cache index using an array
00126 //  of CCacheMapEls.  The generation of unique IDs is controlled
00127 //  by the static member m_lGenID.
00128 //
00129 //////////////////////////////////////////////////////////////
00130
00131 class CCacheMapEl
00132 {
00133   static long m_lGenID;
00134
00135   // The unique ID of the object passed back to the caller
00136   // =====================================================
00137   long  m_lUID;
00138
00139   // The index of the object in the instance cache
00140   // =============================================
00141   long  m_lIndex;
00142
00143 public:
00144   CCacheMapEl(long lIndex) : m_lIndex(lIndex), m_lUID(m_lGenID++)
00145   {}
00146
00147   long GetUID() {return m_lUID;}
00148 };
00149
00150 //////////////////////////////////////////////////////////////
00151 //
00152 //  CSampleInstance
00153 //
00154 //  This class is a representation of a real data instance.
00155 //  The counter values correspond directly to WMI object
00156 //  parameters.
00157 //
00158 //////////////////////////////////////////////////////////////
00159
00160 class CSampleInstance
00161 {
00162   // The counter values
00163   // ==================
00164   DWORD m_aCounter[NumCtrs];
00165
00166   // The lock mechanism
00167   // ==================
00168   CRITICAL_SECTION  CS;
00169
00170 public:
00171   CSampleInstance();
00172   CSampleInstance(const CSampleInstance &aInst);
00173   ~CSampleInstance();
00174
00175   DWORD Lock(bool bLock);
00176
00177   DWORD SetCounter(long lCtr, DWORD dwVal);
00178   DWORD GetCounter(long lCtr, DWORD* pdwVal);
00179 };
00180
00181 //////////////////////////////////////////////////////////////
00182 //
00183 //  CSampleDataSource
00184 //
00185 //  This class is a representation of a real data source.
00186 //  Instance data counters are periodically updated, and their
00187 //  values may be retrieved to update the refresher.
00188 //
00189 //////////////////////////////////////////////////////////////
00190
00191 class CSampleDataSource
00192 {
00193   // The IWbemObjectAccess counter handles
00194   // =====================================
00195   long  m_alHandle[NumCtrs];
00196
00197   // The array of instances
00198   // ======================
00199   CSampleInstance m_aInstance[NUM_INSTANCES];
00200
00201   // The data source control members (mocks changes in counter values)
00202   // =================================================================
00203   HANDLE  m_hThread;
00204
00205   // The thread termination event
00206   // ============================
00207   HANDLE  m_hQuit;
00208
00209
00210   DWORD SetHandles(IWbemClassObject* pSampleClass);
00211
00212   DWORD Simulate();
00213
00214   static unsigned __stdcall CSampleDataSource::ThreadEntry(void* pArgs);
00215
00216 public:
00217   CSampleDataSource();
00218   virtual ~CSampleDataSource();
00219
00220   DWORD Initialize(IWbemClassObject* pSampleClass);
00221
00222   DWORD UpdateInstance(IWbemObjectAccess* pObj);
00223 };
00224
00225 //////////////////////////////////////////////////////////////
00226 //
00227 //  CHiPerfProvider
00228 //
00229 //  The provider maintains a single IWbemClassObject to be used
00230 //  as a template to spawn instances for the Refresher as well
00231 //  as QueryInstances.  It also maintains the static sample
00232 //  data source which provides all data to the instances.
00233 //
00234 //////////////////////////////////////////////////////////////
00235
00236 class CHiPerfProvider : public IWbemProviderInit, public IWbemHiPerfProvider
00237 {
00238   long m_lRef;
00239
00240   // Our mock data source
00241   // ====================
00242
00243   static CSampleDataSource* m_pSampleDS;
00244
00245   // An instance template (used for QueryInstances)
00246   // ==============================================
00247
00248   IWbemClassObject* m_pTemplate;
00249
00250 public:
00251   CHiPerfProvider();
00252   ~CHiPerfProvider();
00253
00254   // Standard COM methods
00255   // ====================
00256
00257   STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
00258   STDMETHODIMP_(ULONG) AddRef();
00259     STDMETHODIMP_(ULONG) Release();
00260
00261   // IWbemProviderInit COM interface
00262   // ===============================
00263
00264   STDMETHODIMP Initialize(
00265     /* [unique][in] */ LPWSTR wszUser,
00266     /* [in] */ long lFlags,
00267     /* [in] */ LPWSTR wszNamespace,
00268     /* [unique][in] */ LPWSTR wszLocale,
00269     /* [in] */ IWbemServices __RPC_FAR *pNamespace,
00270     /* [in] */ IWbemContext __RPC_FAR *pCtx,
00271     /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink );
00272
00273   // IWbemHiPerfProvider COM interfaces
00274   // ==================================
00275
00276   STDMETHODIMP QueryInstances(
00277     /* [in] */ IWbemServices __RPC_FAR *pNamespace,
00278     /* [string][in] */ WCHAR __RPC_FAR *wszClass,
00279     /* [in] */ long lFlags,
00280     /* [in] */ IWbemContext __RPC_FAR *pCtx,
00281     /* [in] */ IWbemObjectSink __RPC_FAR *pSink );
00282
00283   STDMETHODIMP CreateRefresher(
00284     /* [in] */ IWbemServices __RPC_FAR *pNamespace,
00285     /* [in] */ long lFlags,
00286     /* [out] */ IWbemRefresher __RPC_FAR *__RPC_FAR *ppRefresher );
00287
00288   STDMETHODIMP CreateRefreshableObject(
00289     /* [in] */ IWbemServices __RPC_FAR *pNamespace,
00290     /* [in] */ IWbemObjectAccess __RPC_FAR *pTemplate,
00291     /* [in] */ IWbemRefresher __RPC_FAR *pRefresher,
00292     /* [in] */ long lFlags,
00293     /* [in] */ IWbemContext __RPC_FAR *pContext,
00294     /* [out] */ IWbemObjectAccess __RPC_FAR *__RPC_FAR *ppRefreshable,
00295     /* [out] */ long __RPC_FAR *plId );
00296
00297   STDMETHODIMP StopRefreshing(
00298     /* [in] */ IWbemRefresher __RPC_FAR *pRefresher,
00299     /* [in] */ long lId,
00300     /* [in] */ long lFlags );
00301
00302   STDMETHODIMP CreateRefreshableEnum(
00303     /* [in] */ IWbemServices* pNamespace,
00304     /* [in, string] */ LPCWSTR wszClass,
00305     /* [in] */ IWbemRefresher* pRefresher,
00306     /* [in] */ long lFlags,
00307     /* [in] */ IWbemContext* pContext,
00308     /* [in] */ IWbemHiPerfEnum* pHiPerfEnum,
00309     /* [out] */ long* plId);
00310
00311   STDMETHODIMP GetObjects(
00312         /* [in] */ IWbemServices* pNamespace,
00313     /* [in] */ long lNumObjects,
00314     /* [in,size_is(lNumObjects)] */ IWbemObjectAccess** apObj,
00315         /* [in] */ long lFlags,
00316         /* [in] */ IWbemContext* pContext);
00317 };
00318
00319
00320 //////////////////////////////////////////////////////////////
00321 //
00322 //  CRefresher
00323 //
00324 //  The refresher maintains an object and an enumerator cache.
00325 //  When an enumerator is added to the refrehser, it is added
00326 //  to the enumerator cache, and the index of the array is
00327 //  passed back as a unique ID.  The refresher creates a cache
00328 //  of all instances during its initialization.  When an object
00329 //  is added to the refresher, a mapping to the object is
00330 //  created between the unique ID and the index of the object
00331 //  in the cache.  This allows the objects to be reused and
00332 //  facilitates the management of objects that have been added
00333 //  multiple times.
00334 //
00335 //////////////////////////////////////////////////////////////
00336
00337 class CRefresher : public IWbemRefresher
00338 {
00339   // COM reference counter
00340   // =====================
00341
00342   long  m_lRef;
00343
00344   // A pointer to the sample data source
00345   // ===================================
00346
00347   CSampleDataSource*  m_pDS;
00348
00349   // The enumerators that have been added to the refresher
00350   // =====================================================
00351
00352   IWbemHiPerfEnum*  m_apEnumerator[MAX_ENUMERATORS];
00353
00354   // The instances that have been added to the refresher
00355   // ===================================================
00356
00357   CCacheMapEl*    m_apInstMap[MAX_INSTANCES];
00358   IWbemObjectAccess*  m_apInstances[NUM_INSTANCES];
00359
00360   // The parent provider
00361   // ===================
00362
00363   CHiPerfProvider* m_pProvider;
00364
00365 public:
00366   CRefresher(CHiPerfProvider* pProvider, CSampleDataSource* pDS);
00367   virtual ~CRefresher();
00368
00369   DWORD Initialize(IWbemClassObject* pSampleClass);
00370
00371   // Instance management functions
00372   // =============================
00373
00374   DWORD AddObject(IWbemObjectAccess *pObj, IWbemObjectAccess **ppReturnObj, long *plId);
00375   DWORD RemoveObject(long lId);
00376
00377   // Enumerator management functions
00378   // ===============================
00379
00380   DWORD AddEnum(IWbemHiPerfEnum *pHiPerfEnum, long *plId);
00381   DWORD RemoveEnum(long lId);
00382
00383   // COM methods
00384   // ===========
00385
00386   STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
00387   STDMETHODIMP_(ULONG) AddRef();
00388     STDMETHODIMP_(ULONG) Release();
00389
00390   STDMETHODIMP Refresh(/* [in] */ long lFlags);
00391 };
00392
00393
00394 #endif // _HIPERFPROV_H_
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/FileTerm/Resource.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • FileTerm

Resource.h

Go to the documentation of this file.
00001 /*
00002
00003     Copyright (c) 1998-2000  Microsoft Corporation
00004
00005 */
00006
00007 //{{NO_DEPENDENCIES}}
00008 // Microsoft Developer Studio generated include file.
00009 // Used by Script1.rc
00010 //
00011 #define IDD_MAINDLG                     101
00012 #define IDC_STATUS                      1000
00013 #define IDC_ANSWER                      1001
00014 #define IDC_DISCONNECTED                1002
00015 #define IDC_CONNECTED                   1003
00016 #define IDC_STATIC                      -1
00017
00018 // Next default values for new objects
00019 //
00020 #ifdef APSTUDIO_INVOKED
00021 #ifndef APSTUDIO_READONLY_SYMBOLS
00022 #define _APS_NEXT_RESOURCE_VALUE        102
00023 #define _APS_NEXT_COMMAND_VALUE         40001
00024 #define _APS_NEXT_CONTROL_VALUE         1004
00025 #define _APS_NEXT_SYMED_VALUE           101
00026 #endif
00027 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMFT/PreComp.h Source File

  • Web
  • NetMeeting
  • NMFT

PreComp.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMFT.EXE
00003 //  File:       PRECOMP.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #ifndef _PRECOMP_H
00016 #define _PRECOMP_H
00017
00018 // System Include files
00019 #include <windows.h>
00020 #include <windowsx.h>
00021 #include <commctrl.h>
00022 #include <tchar.h>
00023 #include <ocidl.h>
00024 #include <stdio.h>
00025
00026 #include "imsconf2.h"
00027
00028 #include "global.h"
00029 #include "clUtil.h"
00030 #include "cConf.h"
00031
00032 #include "resource.h"
00033
00034 #endif /* _PRECOMP_H */
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/ScaleDemo/scaledemo.Cpp Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • ScaleDemo

scaledemo.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File:   scaleDemo.cpp
00004
00005 Summary:  This demo is designed to show the greater scalability offered
00006       by a server that handles calls asynchronously.
00007
00008 ----------------------------------------------------------------------------
00009
00010 This file is part of the Microsoft COM+ Samples.
00011
00012 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00013
00014 This source code is intended only as a supplement to Microsoft
00015 Development Tools and/or on-line documentation. See these other
00016 materials for detailed information regarding Microsoft code samples.
00017
00018 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00019 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00021 PARTICULAR PURPOSE.
00022
00023 ==========================================================================+*/
00024 // scaleDemo.cpp : Defines the entry point for the console application.
00025 //
00026
00027 #include "stdafx.h"
00028 #include <iostream.h>
00029 #include <conio.h>
00030 #include <time.h>
00031 #include "FullSvr.h"
00032 #include "FullSvr_i.c"
00033
00034 const int NUM_CONCURRENT_CALLS = 15;
00035
00036 //Arrays for our call objects
00037 AsyncIFullServ * callObjFullArray[NUM_CONCURRENT_CALLS];
00038 AsyncISample * callObjSampleArray[NUM_CONCURRENT_CALLS];
00039
00040
00041 int main(int argc, char* argv[])
00042 {
00043
00044   HRESULT hr;
00045   int i,j;
00046   IUnknown       * pIUnknown = NULL;
00047   ICallFactory   * pICallFactory = NULL;
00048   clock_t start,finish;
00049
00050   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00051     callObjFullArray[i]   = NULL;
00052     callObjSampleArray[i] = NULL;
00053   }
00054
00055   //Create an STA
00056   CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
00057
00058   //Create the server object
00059   hr = CoCreateInstance(CLSID_FullServ,NULL,CLSCTX_LOCAL_SERVER,IID_IUnknown,(void**)&pIUnknown);
00060   if(FAILED(hr)){
00061     cout<<"CCI failed"<<endl;
00062     goto CleanUp;
00063   }
00064
00065   //Get ICallFactory
00066   hr = pIUnknown->QueryInterface(IID_ICallFactory,(void **)&pICallFactory);
00067   if(FAILED(hr)){
00068     cerr<<"Query for ICallFactory failed."<<endl;
00069     goto CleanUp;
00070   }
00071
00072   //Create all call objects
00073   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00074
00075     //Create the call objects for AsyncIFullServ
00076     hr = pICallFactory->CreateCall(IID_AsyncIFullServ,NULL,IID_AsyncIFullServ,(IUnknown**)&callObjFullArray[i]);
00077     if(FAILED(hr)){
00078       cerr<<"Unable to create call object for AsyncIFullServ"<<endl;
00079       goto CleanUp;
00080     }
00081
00082     //Create the call objects for AsyncISample
00083     hr = pICallFactory->CreateCall(IID_AsyncISample,NULL,IID_AsyncISample,(IUnknown**)&callObjSampleArray[i]);
00084     if(FAILED(hr)){
00085       cerr<<"Unable to create a call object for AsyncISample"<<endl;
00086       goto CleanUp;
00087     }
00088   }
00089
00090   //Begin all calls on AsyncIFullServ
00091   cout<<"Starting calls to AsyncIFullServ."
00092     <<endl<<"These calls are handled asynchronously on the server."<<endl;
00093   start = clock();
00094   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00095
00096     hr = callObjFullArray[i]->Begin_Sum(2,3);
00097
00098     if(FAILED(hr)){
00099       cerr<<"Begin failed on AsyncIFullServ"<<endl;
00100       goto CleanUp;
00101     }
00102   }
00103
00104   //Finish all calls on AsyncIFullServ
00105   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00106
00107     hr = callObjFullArray[i]->Finish_Sum(&j);
00108     if(FAILED(hr)){
00109       cerr<<"Finish failed on AsyncIFullServ"<<endl;
00110       goto CleanUp;
00111     }
00112   }
00113
00114   finish = clock();
00115   cout<<"Done"<<endl<<"Time elapsed: "<<(finish - start)<<"ms"<<endl;
00116
00117
00118   cout<<endl<<"Starting calls to AsyncISample."
00119     <<endl<<"These calls are handled synchronously on the server. This can take a while."<<endl;
00120   start = clock();
00121
00122   //Begin all calls on AsyncISample
00123   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00124
00125     hr = callObjSampleArray[i]->Begin_Work(2,3);
00126
00127     if(FAILED(hr)){
00128       cerr<<"Begin failed on AsyncIFullServ"<<endl;
00129       goto CleanUp;
00130     }
00131
00132   }
00133
00134   //Finish all calls on AsyncISample
00135   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00136
00137     callObjSampleArray[i]->Finish_Work(&j);
00138
00139     if(FAILED(hr)){
00140       cerr<<"Finish failed on AsyncISample"<<endl;
00141       goto CleanUp;
00142     }
00143
00144   }
00145   finish = clock();
00146   cout<<"Done"<<endl<<"Time elapsed: "<<(finish - start)<<"ms"<<endl;
00147
00148 CleanUp: //Release all references
00149
00150   for(i = 0; i < NUM_CONCURRENT_CALLS; i++){
00151     if(callObjFullArray[i]) callObjFullArray[i]->Release();
00152     if(callObjSampleArray[i]) callObjSampleArray[i]->Release();
00153   }
00154
00155   if(pIUnknown)       pIUnknown->Release();
00156   if(pICallFactory)   pICallFactory->Release();
00157
00158   CoUninitialize();
00159
00160   cout<<endl<<"Press Enter to continue..\n \n"<<endl;
00161   _getch();
00162
00163   return 0;
00164 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/rqsmsg/rqsmsg.cpp Source File

  • NetDS
  • RRas
  • rqs
  • rqsmsg

rqsmsg.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       rqsmsg.cpp
00004 //
00005 //      Synopsis:   Event log main function.
00006 //
00007 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //+--------------------------------------------------------------------------
00010
00011 #include <windows.h>
00012
00013 //+--------------------------------------------------------------------------
00014 //
00015 // Synopsis: DLL main
00016 //
00017 //+--------------------------------------------------------------------------
00018 BOOL
00019 WINAPI
00020 DLLMAIN(
00021     IN HINSTANCE hInstance,
00022     IN DWORD dwReason,
00023     IN PVOID pUnused
00024     )
00025 {
00026     switch(dwReason)
00027     {
00028         case DLL_PROCESS_ATTACH:
00029             DisableThreadLibraryCalls(hInstance);
00030             break;
00031
00032         case DLL_PROCESS_DETACH:
00033             break;
00034
00035         default:
00036             break;
00037     }
00038
00039     return TRUE;
00040 }
00041
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/Main.Cpp Source File

  • Com
  • Services
  • Concurrency
  • SyncComp

Main.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: Main.cpp
00004
00005 Summary: Implementation of CMain which handles all of the work for the client
00006
00007 Classes: CMain
00008 ----------------------------------------------------------------------------
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021 ==========================================================================+*/
00022
00023 #include "stdafx.h"
00024 #include "Main.h"
00025
00026 #ifdef _DEBUG_OBJECTS
00027 #import "STAObject\Debug\STAObject.dll" no_namespace
00028 #import "FreeObject\Debug\FreeObject.dll" no_namespace exclude("ISyncTest")
00029 #import "ComSyncObject\Debug\ComSyncObject.dll" no_namespace exclude("ISyncTest")
00030 #else
00031 #import "STAObject\ReleaseMinSize\STAObject.dll" no_namespace
00032 #import "FreeObject\ReleaseMinSize\FreeObject.dll" no_namespace exclude("ISyncTest")
00033 #import "ComSyncObject\ReleaseMinSize\ComSyncObject.dll" no_namespace exclude("ISyncTest")
00034 #endif
00035
00036 #define IDT_UIUPDATE 500    // just a timer ID
00037
00038 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00039
00040 Class: CMain
00041
00042 CMain is the class associated with the MAIN dialog. This class handles all the
00043 messages and the thread handling.
00044
00045 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00046
00047 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00048
00049 Method: ThreadStart
00050
00051 Summary: This is the startup routine for the threads. This method calls into
00052      the standard Interface of the desired object and measures and records
00053      the time required for each call.
00054
00055 Args: 'this' pointer for easy reference back into ourselves
00056
00057 Returns: 0
00058
00059 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00060 LRESULT CMain::ThreadStart(LPVOID lp)
00061 {
00062   CMain     *pThis;
00063   HRESULT     hRes = S_OK;
00064   LARGE_INTEGER llTick1, llTick2, llFreq;
00065   DWORD     lDeltaTick = 0;
00066   ISyncTestPtr  pSyncTest;
00067   int       iIter;
00068
00069   // cast our incoming void pointer to our class
00070   pThis = (CMain*)lp;
00071
00072   // increment the number of running threads
00073   InterlockedIncrement((LONG *)&pThis->m_curThreadCount);
00074
00075   hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00076   _ASSERTE(SUCCEEDED(hRes));
00077
00078   // get the interface of the created object from the GIT
00079   hRes = g_pGIT->GetInterfaceFromGlobal(pThis->m_iCookie, __uuidof(ISyncTest), (void **)&pSyncTest);
00080   _ASSERTE(SUCCEEDED(hRes));
00081
00082   // get the frequency of our counter
00083   QueryPerformanceFrequency(&llFreq);
00084
00085   // call the Exercise function the number of times desired
00086   for (iIter = 0;iIter < pThis->m_iIters; iIter++)
00087   {
00088     // watch for a signal to stop
00089     if (pThis->m_bStop)
00090       break;
00091
00092     // get the starting tick
00093     QueryPerformanceCounter(&llTick1);
00094
00095     // make a call into the object
00096     hRes = pSyncTest->Exercise();
00097       _ASSERTE(SUCCEEDED(hRes));
00098
00099     // get the ending tick
00100     QueryPerformanceCounter(&llTick2);
00101
00102     // calculate our elapsed time in ms
00103     lDeltaTick = (DWORD) ((float)(llTick2.LowPart - llTick1.LowPart) / llFreq.LowPart * 1000);
00104
00105     // update all of our counters
00106     pThis->UpdateCounters(lDeltaTick);
00107   }
00108
00109   // decrement the number of threads
00110   InterlockedDecrement((LONG *)&pThis->m_curThreadCount);
00111
00112   CoUninitialize();
00113
00114   return 0;
00115 }
00116
00117 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00118
00119 Method: UpdateCounters
00120
00121 Summary: Updates all of the counters used to update our UI using thread safe methods
00122
00123 Args: DWORD lDelta - the amount of time the last call required
00124
00125 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00126 void CMain::UpdateCounters(DWORD lDelta)
00127 {
00128   DWORD curValue;
00129
00130   // update the counters used by the UI
00131
00132   InterlockedIncrement((LONG*)&m_dwTotalIters);
00133   InterlockedExchangeAdd((LONG*)&m_dwTotalTime, lDelta);
00134
00135   // compare and change our values.
00136   // this is where we need m_dwMaxTime and m_dwMinTime to be volatile
00137   curValue = m_dwMaxTime;
00138   if (lDelta > curValue)
00139   {
00140     InterlockedCompareExchange((LONG*)&m_dwMaxTime, lDelta, curValue);
00141   }
00142   else
00143   {
00144     curValue = m_dwMinTime;
00145     if (lDelta <= curValue)
00146     {
00147       InterlockedCompareExchange((LONG*)&m_dwMinTime, lDelta, curValue);
00148     }
00149   }
00150 }
00151
00152 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00153
00154 Method: OnInitDialog
00155
00156 Summary: Setup the controls on the dialog
00157
00158 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00159 LRESULT CMain::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00160 {
00161   // start with the STA radio button checked
00162   SendDlgItemMessage(IDC_RADIO_STA, BM_SETCHECK, BST_CHECKED);
00163   e_compType = eSTA;
00164
00165   // set up some default threads and iterations
00166   SendDlgItemMessage(IDC_THREADCOUNT, EM_LIMITTEXT, 4);
00167   SetDlgItemText(IDC_THREADCOUNT, _T("50"));
00168
00169   SendDlgItemMessage(IDC_ITERCOUNT, EM_LIMITTEXT, 6);
00170   SetDlgItemText(IDC_ITERCOUNT, _T("1000"));
00171
00172   // Center ourselves
00173   CenterWindow();
00174
00175   return 1;  // Let the system set the focus
00176 }
00177
00178
00179 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00180
00181 Method: OnClickedStart
00182
00183 Summary: This routine performs all of the thread creation and waits for them to
00184      finish while pumping messages. It also sets up the timer that indicates
00185      that we should update our UI.
00186
00187      This function also serves as the Cancel button if the correct flag is set.
00188
00189 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00190 LRESULT CMain::OnClickedStart(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00191 {
00192   int iThread, iMaxThread;
00193   HANDLE *aThread;
00194   HRESULT hRes = S_OK;
00195   MSG msg;
00196   int iCountSignled = 0;
00197   DWORD result = 0;
00198   static BOOL bButtonCancel = FALSE;
00199
00200   // check and see if we are a Start or Cancel
00201   if (bButtonCancel == TRUE)
00202   {
00203     // we are cancel so increment our variable. Our threads are watching this value
00204     // and will terminate when it isn't zero
00205     InterlockedIncrement((LONG*)&m_bStop);
00206   }
00207   else
00208   {
00209     // make our button a cancel
00210     SetDlgItemText(IDC_START, "Cancel");
00211     bButtonCancel = TRUE;
00212     // clear our stop indicator
00213     m_bStop = 0;
00214
00215     // get an hourglass
00216       HCURSOR cOld=SetCursor(LoadCursor(NULL, IDC_WAIT));
00217
00218     // disable our radio buttons
00219     ::EnableWindow(GetDlgItem(IDC_RADIO_COMSYNC), FALSE);
00220     ::EnableWindow(GetDlgItem(IDC_RADIO_FREE), FALSE);
00221     ::EnableWindow(GetDlgItem(IDC_RADIO_STA), FALSE);
00222
00223     // set our timer to do the UI updates
00224     SetTimer(IDT_UIUPDATE, 1000);
00225
00226     // reset all of the counters
00227     m_dwMaxTime = m_dwTotalIters = 0;
00228     m_dwTotalTime = 0;
00229     m_dwMinTime = MAXDWORD;
00230     m_curThreadCount = 0;
00231
00232     // get the Thread count and the number of iterations
00233     iMaxThread = GetDlgItemInt(IDC_THREADCOUNT, NULL, FALSE);
00234     m_iIters = GetDlgItemInt(IDC_ITERCOUNT, NULL, FALSE);
00235
00236     // set up our thread calling arrary for the handles
00237     aThread = new HANDLE[iMaxThread];
00238
00239     // -----------
00240     // get the correct COM object and register it in the GIT
00241     // -----------
00242     ISyncTestPtr  pSyncTest;
00243
00244     // depending on the select depends on what object we create
00245     switch (e_compType)
00246     {
00247       case eSTA:
00248         pSyncTest.CreateInstance(__uuidof(STATest));
00249         break;
00250       case eFree:
00251         pSyncTest.CreateInstance(__uuidof(FreeTest));
00252         break;
00253       case eCOMPlus:
00254         pSyncTest.CreateInstance(__uuidof(ComSyncTest));
00255         break;
00256     }
00257
00258     // register our object in the GIT
00259     hRes = g_pGIT->RegisterInterfaceInGlobal(pSyncTest, __uuidof(ISyncTest), &m_iCookie);
00260     _ASSERTE(SUCCEEDED(hRes));
00261
00262     // spin up all of the threads - we start suspended so we have a better chance of getting
00263     // all the threads running at one time
00264     for (iThread = 0; iThread < iMaxThread; iThread++)
00265     {
00266       aThread[iThread] = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE) ThreadStart, (LPVOID) this, CREATE_SUSPENDED , NULL);
00267     }
00268
00269     // let all the threads start
00270     for (iThread = 0; iThread < iMaxThread; iThread++)
00271     {
00272       ResumeThread(aThread[iThread]);
00273     }
00274
00275     // wait for the threads to be done but keep pumping message
00276     while (iMaxThread > 0)
00277     {
00278       // wait for a message or a thread to exit
00279       result = WaitForMultipleObjects((iMaxThread > MAXIMUM_WAIT_OBJECTS) ? MAXIMUM_WAIT_OBJECTS : iMaxThread, aThread, FALSE, 250);
00280       // pump any messages that have built up
00281       while (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
00282       {
00283         DispatchMessage(&msg);
00284       }
00285       // if we failed just ASSERT we shouldn't be failing
00286       if (result == WAIT_FAILED)
00287       {
00288         result = GetLastError();
00289         _ASSERTE(FALSE);
00290       }
00291       else
00292       // -----------
00293       // if one of our objects completed then close that handle and remove
00294       // that handle from the array of handles to wait on
00295       // -----------
00296       if (result < WAIT_OBJECT_0 + iMaxThread)
00297       {
00298         // move the last handle we were waiting on into the spot we just finished
00299
00300         // make sure we close the handle before we lose it
00301         CloseHandle(aThread[result-WAIT_OBJECT_0]);
00302         // replace the handle of the thread that just ended with the last one in the list
00303         aThread[result-WAIT_OBJECT_0] = aThread[iMaxThread - 1];
00304         // we have one less thread to watch
00305         iMaxThread--;
00306       }
00307     }
00308
00309     // Stop the timer and update our UI one last time
00310     KillTimer(IDT_UIUPDATE);
00311     UpdateUI();
00312
00313     // remove our object from the GIT
00314     hRes = g_pGIT->RevokeInterfaceFromGlobal(m_iCookie);
00315     _ASSERTE(SUCCEEDED(hRes));
00316
00317     // clean up
00318     delete[] aThread;
00319
00320     // enable our radio buttons
00321     ::EnableWindow(GetDlgItem(IDC_RADIO_COMSYNC), TRUE);
00322     ::EnableWindow(GetDlgItem(IDC_RADIO_FREE), TRUE);
00323     ::EnableWindow(GetDlgItem(IDC_RADIO_STA), TRUE);
00324
00325     // put cursor back
00326       cOld=SetCursor(LoadCursor(NULL, IDC_WAIT));
00327
00328     // put our button back
00329     bButtonCancel = FALSE;
00330     SetDlgItemText(IDC_START, "Start");
00331   }
00332
00333   return 0;
00334 }
00335
00336 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00337
00338 Method: OnTimer
00339
00340 Summary: this is called by the MessageMap in response to the WM_TIMER message.
00341      we just pass onto our UpdateUI function
00342
00343 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00344 LRESULT CMain::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00345 {
00346   // just forward the call
00347   UpdateUI();
00348   return 0;
00349 }
00350
00351 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00352
00353 Method: UpdateUI
00354
00355 Summary: This updates all the information text boxes on the dialog
00356
00357 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00358 void CMain::UpdateUI(void)
00359 {
00360   // we just need to update the UI when our timer fires
00361
00362   TCHAR szBuffer[40];
00363
00364   // update the UI
00365   SetDlgItemInt(IDC_MAXTIMEBASE + e_compType, m_dwMaxTime);
00366   SetDlgItemInt(IDC_MINTIMEBASE + e_compType, m_dwMinTime);
00367
00368   _snprintf(szBuffer, 40, "%4.2f", (float) m_dwTotalTime / m_dwTotalIters);
00369   SetDlgItemText(IDC_AVGTIMEBASE + e_compType, szBuffer);
00370
00371   _snprintf(szBuffer, 40, "%ld", m_dwTotalIters);
00372   SetDlgItemText(IDC_ITERTOTAL, szBuffer);
00373
00374   SetDlgItemInt(IDC_THREADRUNNING, m_curThreadCount);
00375
00376 }
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/authz/AuthzSvr.c Source File

  • Security
  • Authorization
  • authz

AuthzSvr.c

Go to the documentation of this file.
00001 /*++
00002
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1999 - 2001 Microsoft Corporation.  All rights reserved.
00009
00010 Module Name:
00011
00012     AuthzSvr.c
00013
00014 Abstract:
00015
00016     Sample Resource Manager.
00017
00018
00019 --*/
00020
00021 #define SECURITY_WIN32
00022
00023 #include<windows.h>
00024 #include<security.h>
00025 #include<lmcons.h>
00026 #include<authz.h>
00027 #include<stdio.h>
00028 #include"common.h"
00029
00030 #define READ_BUFFER_SIZE 512
00031
00032 #define FirstAce(Acl) ((PVOID)((PUCHAR)(Acl) + sizeof(ACL)))
00033
00034 DWORD VPSidBuf[] = {0x00000501, 0x05000000, 0x00000015, 0x17b85159, 0x255d7266, 0x0b3b6364, 0x00010001};
00035 DWORD ManagerSidBuf[] = {0x00000501, 0x05000000, 0x00000015, 0x17b85159, 0x255d7266, 0x0b3b6364, 0x00010002};
00036 DWORD EmployeeSidBuf[] = {0x00000501, 0x05000000, 0x00000015, 0x17b85159, 0x255d7266, 0x0b3b6364, 0x00010003};
00037
00038 PSID VPSid = (PSID)VPSidBuf;
00039 PSID ManagerSid = (PSID)ManagerSidBuf;
00040 PSID EmployeeSid = (PSID)EmployeeSidBuf;
00041
00042 DWORD MaxSpendingVP;
00043 DWORD MaxSpendingManager;
00044 DWORD MaxSpendingEmployee;
00045
00046
00047 //
00048 // struct that maintains the state of the fund
00049 //
00050 typedef struct _FundsRM
00051 {
00052    // The amount of money available in the fund
00053    //
00054
00055    DWORD _dwFundsAvailable;
00056
00057    //
00058    // The resource manager, initialized with the callback functions
00059    //
00060
00061    AUTHZ_RESOURCE_MANAGER_HANDLE _hRM;
00062
00063    //
00064    // The security descriptor for the fund, containing a callback ACE
00065    // which causes the resource manager callbacks to be used
00066    //
00067
00068    SECURITY_DESCRIPTOR _SD;
00069
00070 } FUNDSRM,*PFUNDSRM;
00071
00072
00073
00074 //
00075 // The callback routines used with AuthZ
00076 //
00077
00078 BOOL
00079 WINAPI
00080 AuthzAccessCheckCallback(
00081     IN AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext,
00082     IN PACE_HEADER pAce,
00083     IN PVOID pArgs OPTIONAL,
00084     IN OUT PBOOL pbAceApplicable
00085     )
00086
00087 /*++
00088
00089     Routine Description
00090
00091       This is the callback access check. It is registered with a
00092       resource manager. AuthzAccessCheck calls this function when it
00093       encounters a callback type ACE, one of:
00094       ACCESS_ALLOWED_CALLBACK_ACE_TYPE
00095       ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE
00096       ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE
00097
00098       This function determines if the given callback ACE applies to the
00099       client context (which has already had dynamic groups computed) and
00100       the optional arguments, in this case the request amount.
00101
00102       The list of groups which apply to the user is traversed. If a group
00103       is found which allows the user the requested access, pbAceApplicable
00104       is set to true and the function returns. If the end of the group list
00105       is reached, pbAceApplicable is set to false and the function returns.
00106
00107     Arguments
00108
00109         hAuthzClientContext - handle to the AuthzClientContext.
00110
00111         pAce - pointer to the Ace header.
00112
00113         pArgs - optional arguments, in this case DWORD*, DWORD is  the spending
00114          request amount in cents
00115
00116         pbAceApplicable - returns true iff the ACE allows the client's request
00117
00118     Return value
00119
00120         Bool, true on success, false on error
00121
00122     Error checking
00123
00124       Sample code, no error checking
00125
00126 --*/
00127 {
00128
00129    DWORD dwTokenGroupsSize = 0;
00130    PVOID pvTokenGroupsBuf = NULL;
00131    DWORD i;
00132    PDWORD pAccessMask = NULL;
00133    DWORD dwRequestedSpending = ((PDWORD)pArgs)[0];
00134
00135    //
00136    // By default, the ACE does not apply to the request
00137    //
00138
00139    *pbAceApplicable = FALSE;
00140
00141    //
00142    // The object's access mask (right after the ACE_HEADER)
00143    // The access mask determines types of expenditures allowed
00144    // from this fund
00145    //
00146
00147    pAccessMask = (PDWORD) (pAce + sizeof(ACE_HEADER));
00148
00149
00150    //
00151    // Get the TOKEN_GROUPS array
00152    //
00153
00154    while (!AuthzGetInformationFromContext(
00155                         hAuthzClientContext,
00156                         AuthzContextInfoGroupsSids,
00157                         dwTokenGroupsSize,
00158                         &dwTokenGroupsSize,
00159                         pvTokenGroupsBuf
00160                         ))
00161    {
00162       if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
00163       {
00164          HandleError(GetLastError(),TEXT("AuthzGetInformationFromContext"),TRUE,TRUE);
00165          break;
00166       }
00167
00168       // free incase we got size and size grew before our next call.
00169       if (pvTokenGroupsBuf) free( pvTokenGroupsBuf);
00170       pvTokenGroupsBuf = malloc(dwTokenGroupsSize);
00171    }
00172
00173    if (!pvTokenGroupsBuf) return FALSE; // error actually handled in loop
00174
00175
00176    //
00177    // Go through the groups until end is reached or a group applying to the
00178    // request is found
00179    //
00180
00181    for( i = 0;
00182        i < ((PTOKEN_GROUPS)pvTokenGroupsBuf)->GroupCount
00183        && *pbAceApplicable != TRUE;
00184        i++ )
00185    {
00186       //
00187       // This is the business logic.
00188       // Each level of employee can approve different amounts.
00189       //
00190
00191       //
00192       // VP
00193       //
00194
00195       if(EqualSid(VPSid, ((PTOKEN_GROUPS)pvTokenGroupsBuf)->Groups[i].Sid) && (dwRequestedSpending <= MaxSpendingVP) )
00196       {
00197             *pbAceApplicable = TRUE;
00198       }
00199
00200
00201       //
00202       // Manager
00203       //
00204
00205       if(EqualSid(ManagerSid, ((PTOKEN_GROUPS)pvTokenGroupsBuf)->Groups[i].Sid) && (dwRequestedSpending <= MaxSpendingManager) )
00206       {
00207             *pbAceApplicable = TRUE;
00208       }
00209
00210       //
00211       // Employee
00212       //
00213
00214       if(EqualSid(EmployeeSid, ((PTOKEN_GROUPS)pvTokenGroupsBuf)->Groups[i].Sid) && (dwRequestedSpending <= MaxSpendingEmployee) )
00215       {
00216             *pbAceApplicable = TRUE;
00217       }
00218    }
00219
00220
00221    // return TRUE when access check completed (when a callback ace applies not)
00222    // If we had a runtime error, such as mem alloc errors we would return false
00223    return TRUE;
00224 }
00225
00226
00227
00228
00229 BOOL
00230 WINAPI
00231 AuthzComputeGroupsCallback(
00232     IN AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext,
00233     IN PVOID Args,
00234     OUT PSID_AND_ATTRIBUTES *pSidAttrArray,
00235     OUT PDWORD pSidCount,
00236     OUT PSID_AND_ATTRIBUTES *pRestrictedSidAttrArray,
00237     OUT PDWORD pRestrictedSidCount
00238     )
00239
00240 /*++
00241
00242     Routine Description
00243
00244         Resource manager callback to compute dynamic groups.  This is used by the RM
00245         to decide if the specified client context should be included in any RM defined groups.
00246
00247         In this example, the employees are hardcoded into their roles. However, this is the
00248         place you would normally retrieve data from an external source to determine the
00249         users' additional roles.
00250
00251     Arguments
00252
00253         hAuthzClientContext - handle to client context.
00254         Args - optional parameter to pass information for evaluating group membership.
00255         pSidAttrArray - computed group membership SIDs
00256         pSidCount - count of SIDs
00257         pRestrictedSidAttrArray - computed group membership restricted SIDs
00258         pRestrictedSidCount - count of restricted SIDs
00259
00260     Return Value
00261
00262         Bool, true for success, false on failure.
00263
00264     Error checking
00265
00266       Sample code, no error checking
00267
00268 --*/
00269 {
00270    //
00271    // First, look up the user's SID from the context
00272    //
00273
00274    DWORD dwSidSize = 0;
00275    PVOID pvSidBuf = NULL;
00276    PSID  psSidPtr = NULL;
00277    TCHAR UserName[256];
00278    DWORD cbName = 256;
00279    TCHAR Domain[256];
00280    DWORD cbDomain = 256;
00281    SID_NAME_USE eUse;
00282
00283
00284    //
00285    // Get the SID (inside a TOKEN_USER structure)
00286    //
00287
00288    while (!AuthzGetInformationFromContext(
00289                         hAuthzClientContext,
00290                         AuthzContextInfoUserSid,
00291                         dwSidSize,
00292                         &dwSidSize,
00293                         pvSidBuf
00294                         )){
00295
00296       if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
00297          HandleError(GetLastError(),TEXT("AuthzGetInformationFromContext"),TRUE,FALSE);
00298          break;
00299       }
00300
00301       if (pvSidBuf) free (pvSidBuf);
00302       pvSidBuf = malloc(dwSidSize);
00303    }
00304
00305    if (!pvSidBuf) return FALSE;
00306
00307    psSidPtr = ((PTOKEN_USER)pvSidBuf)->User.Sid;
00308
00309    //
00310    // Allocate the memory for the returns, which will be deallocated by FreeDynamicGroups
00311    // Only a single group will be returned, determining the employee type
00312    //
00313
00314    *pSidCount = 1;
00315    *pSidAttrArray = (PSID_AND_ATTRIBUTES)malloc( sizeof(SID_AND_ATTRIBUTES) );
00316
00317    //
00318    // No restricted group sids
00319    //
00320
00321    pRestrictedSidCount = 0;
00322    *pRestrictedSidAttrArray = NULL;
00323
00324    (*pSidAttrArray)[0].Attributes = SE_GROUP_ENABLED;
00325
00326    //
00327    //       The hardcoded Sample logic:
00328    //
00329    // Lookup the sid to get the username and grant dynamic sid based on username
00330    //
00331    //    Bob is a VP
00332    //    Martha is a Manager
00333    //    Joe is an Employee
00334    //
00335
00336    if (!LookupAccountSid(NULL,psSidPtr,UserName,&cbName,Domain,&cbDomain,&eUse)) {
00337       HandleError(GetLastError(),TEXT("LookupAccountSid"),TRUE,TRUE);
00338    }
00339
00340    if( !lstrcmpi(UserName, TEXT("BOB")) )
00341    {
00342       (*pSidAttrArray)[0].Sid = VPSid;
00343    }
00344    else if( !lstrcmpi(UserName, TEXT("Martha")) )
00345    {
00346       (*pSidAttrArray)[0].Sid = ManagerSid;
00347    }
00348    else if( !lstrcmpi(UserName, TEXT("Joe")) )
00349    {
00350       (*pSidAttrArray)[0].Sid = EmployeeSid;
00351    }
00352    else
00353    {
00354       *pSidCount = 0;
00355       free(*pSidAttrArray);
00356       *pSidAttrArray = NULL;
00357    }
00358
00359    if (pvSidBuf) free(pvSidBuf);
00360
00361    return TRUE;
00362 }
00363
00364
00365
00366
00367 VOID
00368 WINAPI
00369 AuthzFreeGroupsCallback(
00370     IN PSID_AND_ATTRIBUTES pSidAttrArray
00371     )
00372
00373 /*++
00374
00375     Routine Description
00376
00377         Frees memory allocated for the dynamic group array.
00378
00379     Arguments
00380
00381         pSidAttrArray - array to free.
00382
00383     Return Value
00384         None.
00385 --*/
00386 {
00387
00388     if (pSidAttrArray != NULL)
00389     {
00390       free(pSidAttrArray);
00391     }
00392
00393 }
00394
00395
00396
00397
00398 BOOL InitializeFundsRM(PFUNDSRM pFundsRM, DWORD dwFundsAvailable)
00399 /*++
00400
00401     Routine Description
00402
00403         Initializes the Authz Resource Manager, providing it
00404         with the appropriate callback functions.
00405         It also creates a security descriptor for the fund, allowing only
00406         corporate and transfer expenditures, not personal. Additional logic
00407         could be added to allow VPs to override these restrictions, etc.
00408
00409     Arguments
00410
00411         PFUNDSRM pFundsRM - Pointer to a FUNDSRM struct that maintains the state
00412                             of the Resource Manager
00413
00414         DWORD dwFundsAvailable - The amount of money in the fund managed by this
00415                          resource manager
00416
00417     Return Value
00418         None.
00419 --*/
00420 {
00421    PSID psidEveryone = NULL;
00422    SID_IDENTIFIER_AUTHORITY siaWorld = SECURITY_WORLD_SID_AUTHORITY;
00423    PACL pDaclFund = NULL;
00424
00425    MaxSpendingVP = 100000000;
00426    MaxSpendingManager = 1000000;
00427    MaxSpendingEmployee = 50000;
00428
00429    //
00430    // The amount of money in the fund
00431    //
00432
00433    pFundsRM->_dwFundsAvailable = dwFundsAvailable;
00434
00435    //
00436    // Initialize the fund's resource manager
00437    //
00438
00439    if (!AuthzInitializeResourceManager(
00440         0,    // no flags
00441         AuthzAccessCheckCallback,
00442         AuthzComputeGroupsCallback,
00443         AuthzFreeGroupsCallback,
00444         L"SampRM", // no auditing
00445         &(pFundsRM->_hRM)
00446         ))
00447       HandleError(GetLastError(),TEXT("AuthzInitializeResourceManager"),TRUE,TRUE);
00448
00449    else
00450        printf("Funds Resource Manager initialized - waiting for client\n\n");
00451
00452
00453
00454    //
00455    // Create the fund's security descriptor
00456    //
00457
00458     if (!InitializeSecurityDescriptor(&(pFundsRM->_SD),SECURITY_DESCRIPTOR_REVISION))
00459        HandleError(GetLastError(),TEXT("InitializeSecurityDescriptor"),TRUE,TRUE);
00460
00461     if (!SetSecurityDescriptorGroup(&(pFundsRM->_SD), NULL, FALSE))
00462        HandleError(GetLastError(),TEXT("SetSecurityDescriptorGroup"),TRUE,TRUE);
00463
00464     if (!SetSecurityDescriptorSacl(&(pFundsRM->_SD), FALSE, NULL, FALSE))
00465        HandleError(GetLastError(),TEXT("SetSecurityDescriptorSacl"),TRUE,TRUE);
00466
00467    // an owner must be specified.  Since VPs are the highest privileged group
00468    // this sample we'll make them the owner.
00469     if (!SetSecurityDescriptorOwner(&(pFundsRM->_SD), VPSid, FALSE))
00470       HandleError(GetLastError(),TEXT("SetSecurityDescriptorOwner"),TRUE,TRUE);
00471
00472    //
00473    // Initialize the DACL for the fund
00474    //
00475
00476    pDaclFund = (PACL)malloc(1024);
00477    InitializeAcl(pDaclFund, 1024, ACL_REVISION_DS);
00478
00479    //
00480    // Add an access-allowed ACE for Everyone
00481    // Only company spending and transfers are allowed for this fund
00482    //
00483
00484    // build EVERYONE SID
00485    if (!AllocateAndInitializeSid(
00486       &siaWorld, 1, SECURITY_WORLD_RID,
00487       0,0,0,0,0,0,0,
00488       &psidEveryone
00489       ))
00490       HandleError(GetLastError(),TEXT("AllocateAndInitializeSid"),TRUE,TRUE);
00491
00492    if (!AddAccessAllowedAce(pDaclFund,
00493                   ACL_REVISION_DS,
00494                   ACCESS_FUND_CORPORATE | ACCESS_FUND_TRANSFER,
00495                   psidEveryone))
00496       HandleError(GetLastError(),TEXT("AddAccessAllowedAce"),TRUE,TRUE);
00497
00498
00499    FreeSid(psidEveryone);
00500
00501    //
00502    // Now set that ACE to a callback ACE
00503    //
00504
00505    ((PACE_HEADER)FirstAce(pDaclFund))->AceType =
00506                            ACCESS_ALLOWED_CALLBACK_ACE_TYPE;
00507
00508    //
00509    // Add that ACL as the security descriptor's DACL
00510    //
00511
00512    if (!SetSecurityDescriptorDacl(&(pFundsRM->_SD), TRUE, pDaclFund, FALSE))
00513       HandleError(GetLastError(),TEXT("SetSecurityDescriptorDacl"),TRUE,TRUE);
00514
00515    return TRUE;
00516 }
00517
00518
00519
00520
00521 BOOL AuthorizeAndExecuteExpense (PFUNDSRM pFundsRM,
00522                                  HANDLE hToken,
00523                                  EX_BUF exBuf,
00524                                  PDWORD pdwResult
00525                                  )
00526 /*++
00527
00528     Routine Description
00529
00530         Setups the Authz context and makes call to AuthzAccessCheck.  Then
00531         modifies the remaining funds depending on acccess and ammount
00532
00533     Arguments
00534
00535         PFUNDSRM pFundsRM - Pointer to a FUNDSRM struct that maintains the state
00536                             of the Resource Manager
00537
00538         HANDLE hToken - The token representing the user were doing the access
00539                         check for
00540
00541         EX_BUF exBuf - struct that contains desired access and expense ammount
00542
00543         PDWORD pdwResult - Pointer to DWORD to put result/error
00544
00545     Return Value
00546         bool True if no errors.
00547 --*/
00548 {
00549    AUTHZ_CLIENT_CONTEXT_HANDLE AuthzClient;
00550    LUID     luid = {0x0,0x0};
00551    AUTHZ_ACCESS_REQUEST AccessRequest = {0};
00552    AUTHZ_ACCESS_REPLY AccessReply = {0};
00553    BYTE     Buffer[1024];
00554    BOOL bRes = FALSE;  // Assume error
00555
00556    __try
00557    {
00558
00559       //
00560       // first we need an Authz context
00561       //
00562
00563       if (!AuthzInitializeContextFromToken(
00564         0,
00565         hToken,
00566         pFundsRM->_hRM,
00567         NULL,
00568         luid,
00569         NULL,
00570         &AuthzClient )){
00571          HandleError(GetLastError(),TEXT("AuthzInitializeContextFromToken"),TRUE,FALSE);
00572          __leave;
00573
00574       }
00575
00576       // Do AccessCheck
00577       AccessRequest.DesiredAccess = exBuf.dwType;
00578       AccessRequest.PrincipalSelfSid = NULL;
00579       AccessRequest.ObjectTypeList = NULL;
00580       AccessRequest.ObjectTypeListLength = 0;
00581       AccessRequest.OptionalArguments = &(exBuf.dwAmmount);
00582
00583       //
00584       // The ResultListLength is set to the number of ObjectType GUIDs in the Request, indicating
00585       // that the caller would like detailed information about granted access to each node in the
00586       // tree.
00587       //
00588       RtlZeroMemory(Buffer, sizeof(Buffer));
00589       AccessReply.ResultListLength = 1;
00590       AccessReply.GrantedAccessMask = (PACCESS_MASK) (Buffer);
00591       AccessReply.Error = (PDWORD) (Buffer + sizeof(ACCESS_MASK));
00592
00593
00594       if (!AuthzAccessCheck( 0,
00595                              AuthzClient,
00596                              &AccessRequest,
00597                              NULL,
00598                              &(pFundsRM->_SD),
00599                              NULL,
00600                              0,
00601                              &AccessReply,
00602                              NULL) ) {
00603          HandleError(GetLastError(),TEXT("AuthzAccessCheck"),TRUE,FALSE);
00604          __leave;
00605       }
00606
00607       if (( *(AccessReply.GrantedAccessMask) & exBuf.dwType) != exBuf.dwType) {
00608          // Access is denied get error from reply if there else Getlasterror.
00609          *pdwResult = *(AccessReply.Error);
00610          printf("Access denied\n\n");
00611
00612       }
00613       else {
00614
00615          // Access is granted, is there enough funds, this could have been done
00616          // within the AuthzAccessCheckCallback but since this is more of an
00617          // execution problem than access checking we'll do it here.
00618          if (pFundsRM->_dwFundsAvailable < exBuf.dwAmmount) {
00619
00620             // not enough in fund
00621             *pdwResult = ERROR_INSUFFICIENT_FUNDS;
00622             printf("Failed : NSF\n\n");
00623
00624          }
00625          else {
00626             pFundsRM->_dwFundsAvailable -= exBuf.dwAmmount;
00627             *pdwResult = EXPENSE_APPROVED;
00628             printf("Expense Approved. Remaining funds:%u cents.\n\n",
00629                                                  pFundsRM->_dwFundsAvailable);
00630          }
00631       }
00632
00633       bRes = TRUE;
00634    }
00635
00636    __finally{
00637       AuthzFreeContext(AuthzClient);
00638    }
00639
00640    return bRes;
00641
00642 }
00643
00644
00645 void main (int argc, char *argv[])
00646 {
00647    HANDLE   hPipe;
00648    DWORD    cbClientName = UNLEN + CNLEN + 2;
00649    TCHAR    ClientName[UNLEN + CNLEN + 2];
00650    DWORD    dwBytesRead;
00651    FUNDSRM  FundsRM;
00652    HANDLE   hToken = INVALID_HANDLE_VALUE;
00653    EX_BUF   exBuf = {0};
00654    DWORD    dwResult = ERROR_ACCESS_DENIED;
00655
00656    InitializeFundsRM(&FundsRM,200000000);
00657
00658    SetupNamedPipe(&hPipe,"\\\\.\\pipe\\AuthzSamplePipe");
00659
00660
00661    while(TRUE)
00662    {
00663       //
00664       //  Wait for a clinet...
00665       //
00666
00667       if (!ConnectNamedPipe(hPipe, NULL))
00668          HandleError(GetLastError(),TEXT("ConnectNamedPipe"),TRUE,TRUE);
00669
00670       dwBytesRead = ReadFromPipe(hPipe,(PBYTE)&exBuf,sizeof(exBuf));
00671       if ( !dwBytesRead ) {
00672          printf("Error reading from client\n");
00673       }
00674
00675       //
00676       // Get Token
00677       //
00678
00679       if (!ImpersonateNamedPipeClient(hPipe))
00680          HandleError(GetLastError(),TEXT("ImpersonateNamedPipeClient"),TRUE,TRUE);
00681
00682
00683       if(!GetUserName(ClientName,&cbClientName))
00684          HandleError(GetLastError(),TEXT("GetUserName"),TRUE,TRUE);
00685
00686
00687       if (!OpenThreadToken(GetCurrentThread(),
00688                           TOKEN_QUERY|TOKEN_IMPERSONATE,FALSE,&hToken))
00689          HandleError(GetLastError(),TEXT("OpenThreadToken"),TRUE,TRUE);
00690
00691
00692       RevertToSelf();
00693
00694       printf("%s requests %s expense of %u cents\n",ClientName, ExNames[exBuf.dwType], exBuf.dwAmmount);
00695
00696
00697       //
00698       // use token to and context to vaidate - note that this sample uses the token
00699       // if we just had a user's sid we could build an authz context with that.
00700       //
00701
00702       if (!AuthorizeAndExecuteExpense( &FundsRM,
00703                                        hToken,
00704                                        exBuf,
00705                                        &dwResult
00706                                        )) {
00707          printf("unknown error executing expense\n");
00708       }
00709
00710       WriteToPipe(hPipe, (PBYTE)&dwResult, sizeof(DWORD));
00711
00712       DisconnectNamedPipe(hPipe);
00713       ZeroMemory(ClientName,cbClientName);
00714       CloseHandle(hToken);
00715       hToken = INVALID_HANDLE_VALUE;
00716       cbClientName = UNLEN + CNLEN + 2;
00717    }
00718
00719    return;
00720 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CComputer Member List

This is the complete list of members for CComputer, including all inherited members.
AddNewGame(IN VARIANT_BOOL bEasy, OUT VARIANT *pvGameID, OUT VARIANT *pvOrder, OUT VARIANT *pvX, OUT VARIANT *pvY) | CComputer |
CComputer() | CComputer | [inline]
Evaluate(long lX, long lY) | CComputer | [private]
GetMove(long lGameID, VARIANT_BOOL bEasy, long &lX, long &lY) | CComputer | [private]
HowManyTurns() | CComputer | [private]
InitArray() | CComputer | [inline, private]
InterfaceSupportsErrorInfo(REFIID riid) | CComputer | [private]
IsWin(long lPlayer) | CComputer | [private]
LineScan(long lPlayer, long &lX, long &lY) | CComputer | [private]
LoadArray(long lGameID) | CComputer | [private]
NewMove(IN long lGameID, IN VARIANT_BOOL bEasy, IN long lX, IN long lY, OUT VARIANT *pvMyX, OUT VARIANT *pvMyY, OUT VARIANT *pvWin) | CComputer |
plField | CComputer | [private]
SaveArray(long lGameID) | CComputer | [private]
Generated on Wed Nov 13 2024 16:55:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CResData Member List

This is the complete list of members for CResData, including all inherited members.
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CResData | [virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CResData | [virtual]
CObjData(void) | CObjData | [inline]
CObjData(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
GetHResource(void) | CResData | [inline]
GetHResource(void) | CResData | [inline]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CResData | [virtual]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CResData | [virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CResData | [virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CResData | [virtual]
HrInitialize(IUnknown *piDataIn) | CResData | [protected, virtual]
HrInitialize(IUnknown *piDataIn) | CResData | [protected, virtual]
InvokeCommand(ULONG nCommandIDIn) | CResData | [virtual]
InvokeCommand(ULONG nCommandIDIn) | CResData | [virtual]
m_cot | CObjData | [protected]
m_fSupportedType | CResData | [private]
m_hResource | CResData | [private]
m_rgprtcPSPages | CObjData | [protected]
m_rgprtcWizPages | CObjData | [protected]
m_strName | CObjData | [protected]
m_strResTypeName | CResData | [private]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
StrName(void) | CObjData | [inline, virtual]
StrName(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

GBMSG Member List

This is the complete list of members for GBMSG, including all inherited members.
iMsg | GBMSG
lParam | GBMSG
wParam | GBMSG
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/headers.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

headers.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module HEADERS.CPP | precompiled headers module
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014 #pragma hdrstop
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/MethProv/ClassFac.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • MethProv

ClassFac.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  CLASSFAC.CPP
00006
00007 //
00008
00009 //  Module: WMI method provider sample code
00010
00011 //
00012
00013 //  Purpose: Contains the class factory.  This creates objects when
00014
00015 //           connections are requested.
00016
00017 //
00018
00019 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00020 //
00021 //***************************************************************************
00022
00023 #include <objbase.h>
00024 #include "methprov.h"
00025
00026 //***************************************************************************
00027 //
00028 // CProvFactory::CProvFactory
00029 // CProvFactory::~CProvFactory
00030 //
00031 // Constructor Parameters:
00032 //  None
00033 //***************************************************************************
00034
00035 CProvFactory::CProvFactory()
00036 {
00037     m_cRef=0L;
00038     return;
00039 }
00040
00041 CProvFactory::~CProvFactory(void)
00042 {
00043     return;
00044 }
00045
00046 //***************************************************************************
00047 //
00048 // CProvFactory::QueryInterface
00049 // CProvFactory::AddRef
00050 // CProvFactory::Release
00051 //
00052 // Purpose: Standard Ole routines needed for all interfaces
00053 //
00054 //***************************************************************************
00055
00056
00057 STDMETHODIMP CProvFactory::QueryInterface(REFIID riid
00058     , PPVOID ppv)
00059 {
00060     *ppv=NULL;
00061
00062     if (IID_IUnknown==riid || IID_IClassFactory==riid)
00063         *ppv=this;
00064
00065     if (NULL!=*ppv)
00066         {
00067         ((LPUNKNOWN)*ppv)->AddRef();
00068         return NOERROR;
00069         }
00070
00071     return E_NOINTERFACE;
00072 }
00073
00074 STDMETHODIMP_(ULONG) CProvFactory::AddRef(void)
00075 {
00076     return ++m_cRef;
00077 }
00078
00079 STDMETHODIMP_(ULONG) CProvFactory::Release(void)
00080 {
00081     ULONG nNewCount = InterlockedDecrement((long *)&m_cRef);
00082     if (0L == nNewCount)
00083         delete this;
00084
00085     return nNewCount;
00086 }
00087
00088 //***************************************************************************
00089 //
00090 // CProvFactory::CreateInstance
00091 //
00092 // Purpose: Instantiates a Locator object returning an interface pointer.
00093 //
00094 // Parameters:
00095 //  pUnkOuter       LPUNKNOWN to the controlling IUnknown if we are
00096 //                  being used in an aggregation.
00097 //  riid            REFIID identifying the interface the caller
00098 //                  desires to have for the new object.
00099 //  ppvObj          PPVOID in which to store the desired
00100 //                  interface pointer for the new object.
00101 //
00102 // Return Value:
00103 //  HRESULT         NOERROR if successful, otherwise E_NOINTERFACE
00104 //                  if we cannot support the requested interface.
00105 //***************************************************************************
00106
00107 STDMETHODIMP CProvFactory::CreateInstance(LPUNKNOWN pUnkOuter
00108     , REFIID riid, PPVOID ppvObj)
00109 {
00110     IWbemProviderInit *   pInit;
00111     HRESULT hr;
00112
00113     *ppvObj=NULL;
00114     hr = E_OUTOFMEMORY;
00115
00116     // This object doesnt support aggregation.
00117
00118     if (NULL!=pUnkOuter)
00119         return CLASS_E_NOAGGREGATION;
00120
00121     // Create the Initialize object.
00122
00123     pInit=new CMethodPro();
00124
00125     if (NULL==pInit)
00126         return E_OUTOFMEMORY;
00127
00128     hr=pInit->QueryInterface(riid, ppvObj);
00129
00130     //Kill the object if initial creation or Init failed.
00131
00132     if (FAILED(hr))
00133         delete pInit;
00134     return hr;
00135 }
00136
00137 //***************************************************************************
00138 //
00139 // CProvFactory::LockServer
00140 //
00141 // Purpose:
00142 //  Increments or decrements the lock count of the DLL.  If the
00143 //  lock count goes to zero and there are no objects, the DLL
00144 //  is allowed to unload.  See DllCanUnloadNow.
00145 //
00146 // Parameters:
00147 //  fLock           BOOL specifying whether to increment or
00148 //                  decrement the lock count.
00149 //
00150 // Return Value:
00151 //  HRESULT         NOERROR always.
00152 //***************************************************************************
00153
00154
00155 STDMETHODIMP CProvFactory::LockServer(BOOL fLock)
00156 {
00157     if (fLock)
00158         InterlockedIncrement(&g_cLock);
00159     else
00160         InterlockedDecrement(&g_cLock);
00161     return NOERROR;
00162 }
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CClusPropValueList Member List

This is the complete list of members for CClusPropValueList, including all inherited members.
CbCurrentValueLength(void) const | CClusPropValueList | [inline]
CbCurrentValueLength(void) const | CClusPropValueList | [inline]
CbCurrentValueLength(void) const | CClusPropValueList | [inline]
CbDataLeft(void) const | CClusPropValueList | [inline]
CbDataLeft(void) const | CClusPropValueList | [inline]
CbDataLeft(void) const | CClusPropValueList | [inline]
CbDataSize(void) const | CClusPropValueList | [inline]
CbDataSize(void) const | CClusPropValueList | [inline]
CbDataSize(void) const | CClusPropValueList | [inline]
CbhCurrentValue(void) const | CClusPropValueList | [inline]
CbhCurrentValue(void) const | CClusPropValueList | [inline]
CbhCurrentValue(void) const | CClusPropValueList | [inline]
CbhValueList(void) const | CClusPropValueList | [inline]
CbhValueList(void) const | CClusPropValueList | [inline]
CbhValueList(void) const | CClusPropValueList | [inline]
CClusPropValueList(void) | CClusPropValueList | [inline]
CClusPropValueList(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
CClusPropValueList(CLUSPROP_BUFFER_HELPER cbhValueListIn, size_t cbDataSizeIn) | CClusPropValueList | [inline]
CClusPropValueList(void) | CClusPropValueList | [inline]
CClusPropValueList(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
CClusPropValueList(CLUSPROP_BUFFER_HELPER cbhValueListIn, size_t cbDataSizeIn) | CClusPropValueList | [inline]
CClusPropValueList(void) | CClusPropValueList | [inline]
CClusPropValueList(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
CClusPropValueList(CLUSPROP_BUFFER_HELPER cbhValueListIn, size_t cbDataSizeIn) | CClusPropValueList | [inline]
CpfCurrentValueFormat(void) const | CClusPropValueList | [inline]
CpfCurrentValueFormat(void) const | CClusPropValueList | [inline]
CpfCurrentValueFormat(void) const | CClusPropValueList | [inline]
CpsCurrentValueSyntax(void) const | CClusPropValueList | [inline]
CpsCurrentValueSyntax(void) const | CClusPropValueList | [inline]
CpsCurrentValueSyntax(void) const | CClusPropValueList | [inline]
CptCurrentValueType(void) const | CClusPropValueList | [inline]
CptCurrentValueType(void) const | CClusPropValueList | [inline]
CptCurrentValueType(void) const | CClusPropValueList | [inline]
DeleteValueList(void) | CClusPropValueList | [inline]
DeleteValueList(void) | CClusPropValueList | [inline]
DeleteValueList(void) | CClusPropValueList | [inline]
Init(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
Init(const CLUSPROP_BUFFER_HELPER cbhValueListIn, size_t cbDataSizeIn) | CClusPropValueList | [inline]
Init(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
Init(const CLUSPROP_BUFFER_HELPER cbhValueListIn, size_t cbDataSizeIn) | CClusPropValueList | [inline]
Init(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
Init(const CLUSPROP_BUFFER_HELPER cbhValueListIn, size_t cbDataSizeIn) | CClusPropValueList | [inline]
m_cbBufferSize | CClusPropValueList | [private]
m_cbDataLeft | CClusPropValueList | [private]
m_cbDataSize | CClusPropValueList | [private]
m_cbhCurrentValue | CClusPropValueList | [private]
m_cbhValueList | CClusPropValueList | [private]
m_fAtEnd | CClusPropValueList | [private]
operator const CLUSPROP_BUFFER_HELPER(void) const | CClusPropValueList | [inline]
operator const CLUSPROP_BUFFER_HELPER(void) const | CClusPropValueList | [inline]
operator const CLUSPROP_BUFFER_HELPER(void) const | CClusPropValueList | [inline]
operator=(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
operator=(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
operator=(const CClusPropValueList &rcpvlInout) | CClusPropValueList | [inline]
ScAllocValueList(size_t cbMinimumIn) | CClusPropValueList |
ScAllocValueList(size_t cbMinimumIn) | CClusPropValueList |
ScAllocValueList(size_t cbMinimumIn) | CClusPropValueList |
ScCheckIfAtLastValue(void) | CClusPropValueList |
ScCheckIfAtLastValue(void) | CClusPropValueList |
ScCheckIfAtLastValue(void) | CClusPropValueList |
ScGetResourceTypeValueList(HCLUSTER hClusterIn, LPCWSTR pwszResTypeNameIn, DWORD dwControlCodeIn, HNODE hHostNodeIn=NULL, LPVOID lpBufferIn=NULL, size_t cbBufferIn=0) | CClusPropValueList |
ScGetResourceTypeValueList(HCLUSTER hClusterIn, LPCWSTR pwszResTypeNameIn, DWORD dwControlCodeIn, HNODE hHostNodeIn=NULL, LPVOID lpBufferIn=NULL, size_t cbBufferIn=0) | CClusPropValueList |
ScGetResourceTypeValueList(HCLUSTER hClusterIn, LPCWSTR pwszResTypeNameIn, DWORD dwControlCodeIn, HNODE hHostNodeIn=NULL, LPVOID lpBufferIn=NULL, size_t cbBufferIn=0) | CClusPropValueList |
ScGetResourceValueList(HRESOURCE hResourceIn, DWORD dwControlCodeIn, HNODE hHostNodeIn=NULL, LPVOID lpBufferIn=NULL, size_t cbBufferIn=0) | CClusPropValueList |
ScGetResourceValueList(HRESOURCE hResourceIn, DWORD dwControlCodeIn, HNODE hHostNodeIn=NULL, LPVOID lpBufferIn=NULL, size_t cbBufferIn=0) | CClusPropValueList |
ScGetResourceValueList(HRESOURCE hResourceIn, DWORD dwControlCodeIn, HNODE hHostNodeIn=NULL, LPVOID lpBufferIn=NULL, size_t cbBufferIn=0) | CClusPropValueList |
ScMoveToFirstValue(void) | CClusPropValueList |
ScMoveToFirstValue(void) | CClusPropValueList |
ScMoveToFirstValue(void) | CClusPropValueList |
ScMoveToNextValue(void) | CClusPropValueList |
ScMoveToNextValue(void) | CClusPropValueList |
ScMoveToNextValue(void) | CClusPropValueList |
~CClusPropValueList(void) | CClusPropValueList | [inline]
~CClusPropValueList(void) | CClusPropValueList | [inline]
~CClusPropValueList(void) | CClusPropValueList | [inline]
Generated on Wed Nov 13 2024 16:55:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/about.h Source File

  • SysMgmt
  • MMC
  • About

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/GUIList.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

GUIList.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUILIST.H
00003
00004   Summary:   Include file for the CGuiList C++ class. A GuiList is a C++
00005              object that encapsulates and displays a page list. The list
00006              is held in a standard listbox control which is a child window
00007              occupying the entire client area of PERCLIEN's main
00008              application window.
00009
00010              GuiList is anchored to the Windows GUI (Graphical User
00011              Interface) environment. This GuiList object relies on a List
00012              object that is instantiated as a COM object (a COPageList) in
00013              a separate In-process server, PERSERVE, to store the page
00014              list data.
00015
00016              For a comprehensive tutorial code tour of GUILIST's contents
00017              and offerings see the tutorial PERCLIEN.HTM file. For
00018              more specific technical details on the internal workings see
00019              the comments dispersed throughout the GUILIST source code.
00020
00021   Classes:   CGuiList.
00022
00023   Origin:    5-20-97: atrent - Editor inheritance from GUIPAPER.CPP in the
00024              STOCLIEN source.
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040
00041 #if !defined(GUILIST_H)
00042 #define GUILIST_H
00043
00044 #if defined(__cplusplus)
00045
00046 // PageList file extensions.
00047 #define PAG_EXT "PAG"
00048 #define PAG_FILE_EXT ".PAG"
00049
00050 // List display line format strings.
00051 #define PAGE_OPEN_STR "+"
00052 #define PAGE_CLOSED_STR "-"
00053 #define TYPE_TEXT_STR "T"
00054 #define TYPE_DRAWING_STR "D"
00055 #define TYPE_UNKNOWN_STR "?"
00056 #define PAGE_UNTITLED_STR "Untitled"
00057 #define LISTWIN_FMT_STR "%s %u %s: %s"
00058
00059 // Allocation sizes for the OpenList array.
00060 enum
00061 {
00062   OPENLIST_SIZE = 31
00063 };
00064
00065 // The OpenList item structure.
00066 typedef struct _OPENITEM
00067 {
00068   SHORT     nType;                       // Page Type.
00069   INT       iPage;                       // Page Number.
00070   void*     pGuiPage;                    // Page Gui C++ object.
00071 } OPENITEM;
00072
00073
00074 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00075   Class:    CGuiList
00076
00077   Summary:  Class to encapsulate the displayable Graphical User Interface
00078             GUI List object. This List object uses the standard Win32
00079             listbox control to display page items.
00080
00081   Methods:  CGuiList
00082               Constructor.
00083             ~CGuiList
00084               Destructor.
00085             BOOL Init(HINSTANCE hInst, HWND hWnd, TCHAR* pszCmdLineFile);
00086               Initialize the GuiList; create subordinate objects, etc.
00087             HRESULT ConnectSink(void);
00088               Connect the PageListSink to the server COPageList event source.
00089             HRESULT DisconnectSink(void);
00090               Disconnect the PageListSink from the server COPageList source.
00091             HRESULT Resize(WORD wWidth, WORD wHeight);
00092               Resize the display window.
00093             HRESULT Show(INT iNewSel);
00094               Show the content of the page list; put content in listbox.
00095             HRESULT Load(void);
00096               Load PageList Data from current compound file.
00097             HRESULT Save(void);
00098               Save existing PageList Data to current compound file.
00099             INT AskSave(void);
00100               Check if new PageList data, ask user, save if user says to.
00101             HRESULT Close(void);
00102               Close this page list window; file save & file close if needed.
00103             HRESULT Open(void);
00104               Common dialog. Open existing .PAG compound file. Load PageList.
00105             HRESULT SaveAs(void);
00106               Common dialog. Save current PageList Data in renamed file.
00107             HRESULT New(void);
00108               Common dialog. Create new empty page list and file.
00109             HRESULT PageTitle(void);
00110               Dialog box. Edit a new title for the currently select page.
00111             HRESULT PageOpen(void);
00112               Open and load currently selected page in separate window.
00113             HRESULT PageAdd(SHORT nPageType);
00114               Add new page to the page list, create new separate window.
00115             HRESULT PageDelete(void);
00116               Delete currently selected page. Close its window if needed.
00117             HRESULT PageChanged(INT iPage);
00118               Set page changed status for this page to TRUE.
00119             HRESULT PageClosed(INT iPage);
00120               Mark this page as closed in the dynamic open item array.
00121 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00122 class CGuiList
00123 {
00124   public:
00125     CGuiList(void);
00126     ~CGuiList(void);
00127     BOOL    Init(HINSTANCE hInst, HWND hWnd, TCHAR* pszCmdLineFile);
00128     HRESULT ConnectSink(void);
00129     HRESULT DisconnectSink(void);
00130     HRESULT Resize(WORD wWidth, WORD wHeight);
00131     HRESULT Show(INT iNewSel);
00132     HRESULT Load(void);
00133     HRESULT Save(void);
00134     INT     AskSave(void);
00135     HRESULT Close(void);
00136     HRESULT Open(void);
00137     HRESULT SaveAs(void);
00138     HRESULT New(void);
00139     HRESULT PageTitle(void);
00140     HRESULT PageOpen(void);
00141     HRESULT PageAdd(SHORT nPageType);
00142     HRESULT PageDelete(void);
00143     HRESULT PageChanged(INT iPage);
00144     HRESULT PageClosed(INT iPage);
00145
00146   private:
00147     // Private methods.
00148     HRESULT GetOpenItem(
00149               INT iPage,
00150               SHORT* pnType,
00151               PPVOID ppGuiPage,
00152               BOOL* pAddOk);
00153     HRESULT AddOpenItem(INT iPage, SHORT nType, void* pGuiPage);
00154     HRESULT DeleteOpenItem(INT iPage);
00155     HRESULT RenumOpenItems(INT iPage);
00156     HRESULT CloseOpenItem(INT iPage);
00157     HRESULT SaveOpenPages(void);
00158     HRESULT CloseOpenPages(void);
00159     HRESULT CloseTextPages(void);
00160     HRESULT ReleaseOpenPages(void);
00161     HRESULT RestoreOpenPages(IStorage* pIStorage_Root);
00162     IConnectionPoint* GetConnectionPoint(REFIID riid);
00163
00164     // Private data members.
00165     HINSTANCE    m_hInst;
00166     HWND         m_hWnd;
00167     RECT         m_WinRect;
00168     IPageList*   m_pIPageList;
00169     OPENITEM     m_paOpenList[OPENLIST_SIZE];
00170     CListWin*    m_pListWin;
00171     IStorage*    m_pIStorage_Root;
00172     CPageFile*   m_pPageFile;
00173     OPENFILENAME m_ofnFile;
00174     TCHAR        m_szFileFilter[MAX_PATH];
00175     TCHAR        m_szFileName[MAX_PATH];
00176     TCHAR        m_szFileTitle[MAX_PATH];
00177     IUnknown*    m_pCOPageListSink;
00178     DWORD        m_dwPageListSink;
00179     BOOL         m_bChanged;
00180 };
00181
00182
00183 #endif // __cplusplus
00184
00185 #endif
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/DirectoryObject.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

DirectoryObject.h

Go to the documentation of this file.
00001 // DirectoryObject.h: interface for the CDirectoryObject class.
00002 //
00003 //////////////////////////////////////////////////////////////////////
00004
00005 #if !defined(AFX_DIRECTORYOBJECT_H__81709784_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00006 #define AFX_DIRECTORYOBJECT_H__81709784_0672_11D2_B218_0000F87A6B50__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // CDlgIDirectoryObject dialog
00016
00017 class CDlgIDirectoryObject : public CDialog
00018 {
00019 // Construction
00020 public:
00021   CDlgIDirectoryObject(LPUNKNOWN pUnk, CWnd* pParent = NULL);   // standard constructor
00022   ~CDlgIDirectoryObject();
00023 // Dialog Data
00024   //{{AFX_DATA(CDlgIDirectoryObject)
00025   enum { IDD = IDD_IDIRECTORYOBJECT };
00026   CEdit m_cAttributes;
00027   CListBox  m_cValueList;
00028   CString m_sDN;
00029   CString m_sRDN;
00030   CString m_sSchema;
00031   CString m_sClass;
00032   CString m_sParent;
00033   CString m_sAttributes;
00034   //}}AFX_DATA
00035
00036
00037 // Overrides
00038   // ClassWizard generated virtual function overrides
00039   //{{AFX_VIRTUAL(CDlgIDirectoryObject)
00040   protected:
00041   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00042   //}}AFX_VIRTUAL
00043
00044 // Implementation
00045 protected:
00046   void ShowAttributes();
00047    IDirectoryObject *m_pDirObject;
00048
00049   // Generated message map functions
00050   //{{AFX_MSG(CDlgIDirectoryObject)
00051   afx_msg void OnDelete();
00052   afx_msg void OnGet();
00053   afx_msg void OnChangeAttribute();
00054   virtual BOOL OnInitDialog();
00055   //}}AFX_MSG
00056   DECLARE_MESSAGE_MAP()
00057 };
00058
00059 #endif // !defined(AFX_DIRECTORYOBJECT_H__81709784_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00060 /////////////////////////////////////////////////////////////////////////////
00061 // CDeleteObjectDlg dialog
00062
00063 class CDeleteObjectDlg : public CDialog
00064 {
00065 // Construction
00066 public:
00067   CDeleteObjectDlg(CWnd* pParent = NULL);   // standard constructor
00068   CString GetObjectName() { return m_sRDN; }
00069 // Dialog Data
00070   //{{AFX_DATA(CDeleteObjectDlg)
00071   enum { IDD = IDD_DELETEOBJECT };
00072   CString m_sDelete;
00073   //}}AFX_DATA
00074
00075
00076 // Overrides
00077   // ClassWizard generated virtual function overrides
00078   //{{AFX_VIRTUAL(CDeleteObjectDlg)
00079   protected:
00080   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00081   //}}AFX_VIRTUAL
00082
00083 // Implementation
00084 protected:
00085   CString m_sRDN;
00086
00087   // Generated message map functions
00088   //{{AFX_MSG(CDeleteObjectDlg)
00089   virtual void OnOK();
00090   afx_msg void OnChangeDelete();
00091   //}}AFX_MSG
00092   DECLARE_MESSAGE_MAP()
00093 };
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/fulldrag/fulldrag.h Source File

  • WinUI
  • fulldrag

fulldrag.h

Go to the documentation of this file.
00001 /*
00002  *  fulldrag.h
00003  */
00004
00005 #define STRICT
00006 #include <windows.h>
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CStaticNode::privateData Member List

This is the complete list of members for CStaticNode::privateData, including all inherited members.
host | CStaticNode::privateData |
isDirty | CStaticNode::privateData |
m_fAllowOverrideMachineNameOut | CStaticNode::privateData |
m_fIsRadioLocalMachine | CStaticNode::privateData |
m_host | CStaticNode::privateData |
m_isDirty | CStaticNode::privateData |
privateData() | CStaticNode::privateData | [inline]
privateData() | CStaticNode::privateData | [inline]
Generated on Wed Nov 13 2024 16:57:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Identitysub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Identitysub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __IDENTITYSUB_H__
00018 #define __IDENTITYSUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CIdentitySub
00028 Summary: Identity Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CIdentitySub :
00031   public CSysLCESub,
00032   public IComIdentityEvents
00033 {
00034 public:
00035   CIdentitySub(CComSpy * pSpy)
00036   {
00037     m_pSpy = pSpy;
00038   }
00039
00040   CIdentitySub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045   DECLARE_NOT_AGGREGATABLE(CIdentitySub)
00046   DECLARE_GET_CONTROLLING_UNKNOWN()
00047
00048   BEGIN_COM_MAP(CIdentitySub)
00049     COM_INTERFACE_ENTRY(IComIdentityEvents)
00050     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00051   END_COM_MAP()
00052
00053   STDMETHODIMP GetEventType(EventEnum * e){*e = Identity;return S_OK;}
00054   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00055   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComIdentityEvents;return S_OK;}
00056
00057   STDMETHODIMP OnIISRequestInfo(
00058                COMSVCSEVENTINFO * pInfo,
00059                ULONG64 ObjId,
00060                LPCOLESTR pszClientIP,
00061                LPCOLESTR pszServerIP,
00062                LPCOLESTR pszURL
00063               )
00064   {
00065     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnIISRequestInfo"), GuidToBstr(pInfo->guidApp));
00066
00067     WCHAR szObjectID[32];
00068     wsprintfW(szObjectID, L"0x%016X", ObjId);
00069     m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00070
00071     m_pSpy -> AddParamValueToList(L"ClientIP", pszClientIP);
00072     m_pSpy -> AddParamValueToList(L"ServerIP", pszServerIP);
00073     m_pSpy -> AddParamValueToList(L"URL", pszURL);
00074
00075
00076     IF_AUDIT_DO(OnIISRequestInfo)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00077                   szObjectID,
00078                   pszClientIP,
00079                   pszServerIP,
00080                   pszURL
00081                   );
00082
00083     return S_OK;
00084   }
00085
00086 };
00087
00088 #endif //__IDENTITYSUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/SerStrm.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

SerStrm.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright 1992 - 2000 Microsoft Corporation.
00004 //
00005 //  File:       serstrm.cxx
00006 //
00007 //  Contents:   Serial stream
00008 //
00009 //  Classes:    CSerialStream
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <htmlfilt.hxx>
00017
00018 //
00019 // Special char hash table is static so that there is only one hash table
00020 // per htmlfilt dll
00021 //
00022 CSpecialCharHashTable CSerialStream::_specialCharHash;
00023
00024 //
00025 // aControlCodeMap is the mapping for chars in the control code region (0x80 to 0x9f)
00026 // as mapped by the web browser
00027 //
00028 static WCHAR aControlCodeMap[] = { 0x20,     // space
00029                                    0x20,     // space
00030                                    0x2c,     // comma
00031                                    0x192,    // script f
00032                                    0x201e,   // low double comma
00033                                    0x2026,   // horizontal ellipsis
00034                                    0x2020,   // dagger
00035                                    0x2021,   // double dagger
00036                                    0x5e,     // circumflex
00037                                    0x2030,   // per mille
00038                                    0x160,    // S haeck
00039                                    0x2039,   // left guillemet
00040                                    0x152,    // OE
00041                                    0x20,     // space
00042                                    0x20,     // space
00043                                    0x20,     // space
00044                                    0x20,     // space
00045                                    0x2018,   // single turned comma
00046                                    0x2019,   // single turned comma
00047                                    0x201c,   // double turned comma
00048                                    0x201d,   // double turned comma
00049                                    0x2022,   // bullet
00050                                    0x2014,   // em dash
00051                                    0x2015,   // quotation dash
00052                                    0x2dc,    // tilde
00053                                    0x2122,   // trademark
00054                                    0x161,    // s haeck
00055                                    0x203a,   // right guillemet
00056                                    0x153,    // oe
00057                                    0x20,     // space
00058                                    0x20,     // space
00059                                    0x178     // y diaresis
00060                                  };
00061
00062
00063 //+-------------------------------------------------------------------------
00064 //
00065 //  Method:     CSerialStream::CSerialStream
00066 //
00067 //  Synopsis:   Constructor
00068 //
00069 //--------------------------------------------------------------------------
00070
00071 CSerialStream::CSerialStream()
00072     : _wch(0),
00073       _fUnGotChar(FALSE),
00074       _cCharsReadAhead(0),
00075       _pCurChar(_awcReadAheadBuf)
00076 {
00077 }
00078
00079
00080
00081 //+-------------------------------------------------------------------------
00082 //
00083 //  Method:     CSerialStream::Init
00084 //
00085 //  Synopsis:   Initialize the memory mapped stream
00086 //
00087 //  Arguments:  [pwszFileName] -- File to be mapped
00088 //
00089 //--------------------------------------------------------------------------
00090
00091 void CSerialStream::Init( WCHAR *pwszFileName )
00092 {
00093     _mmInputStream.Init( pwszFileName );
00094 }
00095
00096
00097
00098 //+-------------------------------------------------------------------------
00099 //
00100 //  Method:     CSerialStream::GetChar
00101 //
00102 //  Synopsis:   Read the next Unicode character from the input file, accounting
00103 //              for special chars, chars push backs and read ahead
00104 //
00105 //  Returns:    Next Unicode char
00106 //
00107 //--------------------------------------------------------------------------
00108
00109 WCHAR CSerialStream::GetChar()
00110 {
00111     //
00112     // Was a char pushed back into input ?
00113     //
00114     if ( _fUnGotChar )
00115     {
00116         _fUnGotChar = FALSE;
00117         return _wch;
00118     }
00119
00120     //
00121     // Are there any chars in our read-ahead buffer ?
00122     //
00123     WCHAR wch;
00124     if ( _pCurChar < _awcReadAheadBuf + _cCharsReadAhead )
00125     {
00126         wch = *_pCurChar;
00127         _pCurChar++;
00128
00129         return wch;
00130     }
00131
00132     if ( _mmInputStream.Eof() )
00133         return WEOF;
00134
00135     //
00136     // Read from input stream
00137     //
00138     wch = _mmInputStream.GetChar();
00139     if ( wch == 0xa || wch == 0xd )         // Replace newlines with spaces
00140         wch = L' ';
00141
00142     if ( wch == L'&' )
00143     {
00144         //
00145         // Read in the special char until ';' or '&', or EOF, or until _awcReadAhead buffer is full
00146         //
00147         _awcReadAheadBuf[0] = wch;
00148         for ( unsigned i=1; i<MAX_SPECIAL_CHAR_LENGTH; i++)
00149         {
00150             if ( _mmInputStream.Eof() )
00151                 break;
00152
00153             wch = _mmInputStream.GetChar();
00154             if ( wch == 0xa || wch == 0xd )         // Replace newlines with spaces
00155                 wch = L' ';
00156
00157             _awcReadAheadBuf[i] = wch;
00158             if ( wch == L';' || wch == L'&' )
00159                 break;
00160         }
00161
00162         if ( wch == L';' )
00163         {
00164             if ( _awcReadAheadBuf[1] == L'#' && IsUnicodeNumber( &_awcReadAheadBuf[2], i-2, wch ) )
00165             {
00166                 //
00167                 // Return converted Unicode number, e.g. for &#160, return 160
00168                 //
00169                 return wch;
00170             }
00171             else if ( _specialCharHash.Lookup( &_awcReadAheadBuf[1], i-1, wch ) )
00172             {
00173                 //
00174                 // Corresponding Unicode char found
00175                 //
00176                 return wch;
00177             }
00178             else
00179             {
00180                 _cCharsReadAhead = i+1;
00181                 _pCurChar = &_awcReadAheadBuf[1];
00182
00183                 return L'&';
00184             }
00185         }
00186         else if ( wch == L'&' )
00187         {
00188             //
00189             // For example, &acu&aacute; . So keep &acu in the read ahead buffer,
00190             // but push the second '&' back into the input stream, so that &aacute;
00191             // can be recognized as a special char during a subsequent call to GetChar()
00192             //
00193             _mmInputStream.UnGetChar( L'&' );
00194             _cCharsReadAhead = i;
00195             _pCurChar = &_awcReadAheadBuf[1];
00196
00197             return L'&';
00198         }
00199         else
00200         {
00201             _cCharsReadAhead = i;
00202             _pCurChar = &_awcReadAheadBuf[1];
00203
00204             return L'&';
00205         }
00206     }
00207     else
00208         return wch;
00209 }
00210
00211
00212 //+-------------------------------------------------------------------------
00213 //
00214 //  Method:     CSerialStream::UnGetChar
00215 //
00216 //  Synopsis:   Pushes(logically) a character back into the input stream
00217 //
00218 //  Arguments:  [wch]  -- Char to be pushed back
00219 //
00220 //--------------------------------------------------------------------------
00221
00222 void CSerialStream::UnGetChar( WCHAR wch )
00223 {
00224     //
00225     // We can unget only one char at a time
00226     //
00227     Win4Assert( ! _fUnGotChar );
00228
00229     _fUnGotChar = TRUE;
00230     _wch = wch;
00231 }
00232
00233 //+-------------------------------------------------------------------------
00234 //
00235 //  Method:     CSerialStream::Eof
00236 //
00237 //  Synopsis:   Is this the end of input file ?
00238 //
00239 //--------------------------------------------------------------------------
00240
00241 BOOL CSerialStream::Eof()
00242 {
00243     if ( _fUnGotChar )
00244         return FALSE;
00245
00246     if ( _pCurChar < _awcReadAheadBuf + _cCharsReadAhead )
00247         return FALSE;
00248
00249     return _mmInputStream.Eof();
00250 }
00251
00252
00253
00254
00255 //+-------------------------------------------------------------------------
00256 //
00257 //  Method:     CSerialStream::IsUnicodeNumber
00258 //
00259 //  Synopsis:   Is the special char a Unicode number ?
00260 //
00261 //  Arguments:  [pwcInputBuf] -- input buffer
00262 //              [uLen]        -- Length of input (not \0 terminated)
00263 //              [wch]         -- Unicode char returned here
00264 //
00265 //  Returns:    True if we've managed to convert to a Unicode number
00266 //
00267 //--------------------------------------------------------------------------
00268
00269 BOOL CSerialStream::IsUnicodeNumber( WCHAR *pwcInputBuf,
00270                                      unsigned uLen,
00271                                      WCHAR& wch )
00272 {
00273     wch = 0;
00274     for ( unsigned i=0; i<uLen; i++ )
00275     {
00276         //
00277         // Check that the result will be less than max Unicode value, namely 0xffff
00278         //
00279         if ( iswdigit( pwcInputBuf[i] )
00280              && wch < (0xffff - (pwcInputBuf[i]-L'0'))/10 )
00281         {
00282             wch = 10 * wch + pwcInputBuf[i] - L'0';
00283         }
00284         else
00285             return FALSE;
00286     }
00287
00288     if ( wch >= 0x80 && wch <= 0x9f )
00289     {
00290         //
00291         // Chars in the control code region are mapped by the browser to valid chars
00292         //
00293
00294         wch = aControlCodeMap[wch-0x80];
00295     }
00296
00297     return ( wch > 0 );
00298 }
00299
00300
00301
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/BrochureMachine/PTLauncher.h Source File

  • Web
  • Browser
  • BrochureMachine

PTLauncher.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // PTLauncher.h : Declaration of the CPTLauncher
00006
00007 #ifndef __PTLAUNCHER_H_
00008 #define __PTLAUNCHER_H_
00009
00010 #include "resource.h"       // main symbols
00011 #include <atlctl.h>
00012
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // CPTLauncher
00016 class ATL_NO_VTABLE CPTLauncher :
00017   public CComObjectRootEx<CComSingleThreadModel>,
00018   public CComCoClass<CPTLauncher, &CLSID_PTLauncher>,
00019   public CComControl<CPTLauncher>,
00020   public IDispatchImpl<IPTLauncher, &IID_IPTLauncher, &LIBID_BROCHUREMACHINELib>,
00021   public IOleControlImpl<CPTLauncher>,
00022   public IOleObjectImpl<CPTLauncher>,
00023   public IOleInPlaceActiveObjectImpl<CPTLauncher>,
00024   public IOleInPlaceObjectWindowlessImpl<CPTLauncher>,
00025   /* The following untrusted use of IObjectSafetyImpl is for simplicity
00026   in this sample code.  This usage in production code can expose a
00027   security risk in some situations. */
00028   public IObjectSafetyImpl<CPTLauncher,
00029            INTERFACESAFE_FOR_UNTRUSTED_CALLER |
00030            INTERFACESAFE_FOR_UNTRUSTED_DATA>
00031 {
00032 public:
00033   CPTLauncher()
00034   {
00035   }
00036
00037 DECLARE_REGISTRY_RESOURCEID(IDR_PTLAUNCHER)
00038
00039 DECLARE_PROTECT_FINAL_CONSTRUCT()
00040
00041 BEGIN_COM_MAP(CPTLauncher)
00042   COM_INTERFACE_ENTRY(IPTLauncher)
00043   COM_INTERFACE_ENTRY(IDispatch)
00044     COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
00045     COM_INTERFACE_ENTRY(IOleInPlaceObject)
00046     COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
00047     COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
00048     COM_INTERFACE_ENTRY(IOleControl)
00049     COM_INTERFACE_ENTRY(IOleObject)
00050     COM_INTERFACE_ENTRY(IObjectSafety)
00051 END_COM_MAP()
00052
00053
00054 // IPTLauncher
00055 public:
00056   STDMETHOD(LaunchPT)();
00057 };
00058
00059 #endif //__PTLAUNCHER_H_
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/basenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

basenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Generic base node class.  All nodes are derived from this.
00014
00015
00016 #ifndef _CLASS_CBASENODE_
00017 #define _CLASS_CBASENODE_
00018
00019 #include "Globals.h"
00020 #include "Resource.h"
00021
00022
00023 #define DEFAULT_SDI_MASK  (SDI_STR | SDI_PARAM | SDI_IMAGE | SDI_OPENIMAGE | SDI_PARENT | SDI_CHILDREN)
00024 #define DEFAULT_RDI_MASK  (RDI_STR | RDI_PARAM | RDI_IMAGE)
00025
00026 #define MAX_NAME_LEN     64
00027
00028
00029 class CBaseNode;
00030
00031
00032 //---------------------------------------------------------------------------
00033 //  Data types specific to this object
00034 //
00035 typedef struct tag_BASENODE_PROPERTIES
00036 {
00037   WCHAR      szNodeName[MAX_NAME_LEN];
00038   LONG_PTR   pComponentData;
00039   LONG_PTR   pParentObject;
00040   DWORD      dwAttributes;
00041
00042 }NODE_PROPERTIES;
00043
00044
00045 typedef NODE_PROPERTIES*  LPNODE_PROPERTIES;
00046 typedef CBaseNode*        LPBASENODE;
00047
00048
00049 //---------------------------------------------------------------------------
00050 class CBaseNode
00051 {
00052   public:
00053     CBaseNode()
00054     {
00055       m_pwszNodeName   = NULL;
00056       m_nPropPageCount = 0;
00057
00058       ZeroMemory( &m_SDI, sizeof(SCOPEDATAITEM) );
00059       ZeroMemory( &m_RDI, sizeof(RESULTDATAITEM) );
00060     };
00061
00062     virtual ~CBaseNode()
00063     {
00064       if( NULL != m_pwszNodeName )
00065         CoTaskMemFree( m_pwszNodeName );
00066     };
00067
00068   public:
00069     LPWSTR   GetNodeName()     { return m_pwszNodeName;  };
00070
00071     virtual  HRESULT Initialize( NODE_PROPERTIES* pProperties ) = 0;
00072     virtual  ULONG   GetNodeType() = 0;
00073     virtual  GUID&   GetNodeGUID() = 0;
00074
00075   ///////////////////////////////////////////////////////////////////////////
00076   //  IExtendPropertySheet2 methods
00077   public:
00078     virtual  HRESULT QueryForPropertyPage() = 0;
00079     virtual  HRESULT CreatePropertyPages( LPPROPERTYSHEETCALLBACK lpCallback, LONG_PTR Handle ) = 0;
00080     virtual  HRESULT GetWatermarks( HBITMAP __RPC_FAR *lphWatermark,
00081                                     HBITMAP __RPC_FAR *lphHeader,
00082                                     HPALETTE __RPC_FAR *lphPalette,
00083                                     BOOL __RPC_FAR *bStretch ) = 0;
00084
00085   ///////////////////////////////////////////////////////////////////////////
00086   // These virtual methods handle calls from the console
00087   public:
00088     virtual  HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI ) = 0;
00089     virtual  HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI ) = 0;
00090     virtual  HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo ) = 0;
00091
00092   ///////////////////////////////////////////////////////////////////////////
00093   // Context menu methods
00094   public:
00095     virtual  HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed ) = 0;
00096     virtual  HRESULT Command( long lCommandID ) = 0;
00097
00098   ///////////////////////////////////////////////////////////////////////////
00099   // Notification handlers
00100   public:
00101     virtual  HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00102     virtual  HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00103     virtual  HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData ) = 0;
00104     virtual  HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData ) = 0;
00105     virtual  HRESULT OnDelete( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00106     virtual  HRESULT OnContextHelp( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00107
00108     virtual  HRESULT OnViewChange( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent )
00109                      { return E_NOTIMPL; };
00110
00111   public:
00112     SCOPEDATAITEM    m_SDI;
00113     RESULTDATAITEM   m_RDI;
00114
00115   protected:
00116     LPWSTR     m_pwszNodeName;
00117     LONG       m_nPropPageCount;       // Added to support Property Pages
00118
00119 }; //end class CBaseNode
00120
00121 #endif //_CLASS_CBASENODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/status.cpp Source File

  • Begin
  • sdkdiff

status.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * status line handler
00013  *
00014  */
00015
00016 /*---includes-----------------------------------------------------------*/
00017 #include "precomp.h"
00018 #include "..\sdkdiff\errorout.h"
00019
00020 /* --- data structures ------------------------------------------------- */
00021
00022 #define SF_MAXLABEL     80   /* no more than 80 in an item within the bar */
00023
00024 typedef struct statel {
00025     int type;                       /* SF_BUTTON or SF_STATIC */
00026     int flags;                      /* SF_VAR => variable width
00027                                        SF_LEFT=> left aligned (else right)
00028                                        SF_RAISE=> paint as 'raised' 3d rect
00029                                        SF_LOWER=> paint as lowered 3D rect
00030                                        SF_SZMIN=>together with SF_VAR
00031                                                  allows minimum size for
00032                                                  var sized item
00033                                        SF_SZMAX=>see SZMIN and use nouse
00034                                     */
00035     int id;                         /* control id */
00036     int width;                      /* width of control in chars */
00037     char text[SF_MAXLABEL+1];       /* null-term string for label */
00038
00039     RECT rc;                        /* used by status.c */
00040 } STATEL, * PSTATEL;
00041
00042 typedef struct itemlist {
00043     int nitems;
00044     PSTATEL statels;
00045
00046     int selitem;                    /* used by status.c */
00047     BOOL isselected;                /* used by status.c */
00048 } ILIST, * PILIST;
00049
00050 /* ------------------------------------------------------------------*/
00051
00052
00053 /* prototypes of routines in this module */
00054
00055 void StatusCreateTools(void);
00056 void StatusDeleteTools(void);
00057 INT_PTR APIENTRY StatusWndProc(HWND, UINT, WPARAM, LPARAM);
00058 void StatusResize(HWND hWnd, PILIST pilist);
00059 int StatusCalcHeight(HWND hWnd, PSTATEL ip);
00060 int StatusCalcWidth(HWND hWnd, PSTATEL ip);
00061 PSTATEL StatusGetItem(PILIST plist, int id);
00062 void LowerRect(HDC hDC, LPRECT rcp);
00063 void RaiseRect(HDC hDC, LPRECT rcp);
00064 void StatusPaint(HWND hWnd, PILIST iplistp);
00065 void BottomRight(HDC hDC, LPRECT rcp, HPEN hpen, BOOL bCorners);
00066 void TopLeft(HDC hDC, LPRECT rcp, HPEN hpen, BOOL bCorners);
00067 void StatusButtonDown(HDC hDC, PSTATEL ip);
00068 void StatusButtonUp(HDC hDC, PSTATEL ip);
00069 void InitDC(HDC hdc);
00070
00071
00072 /*--global data---------------------------------------------------------*/
00073
00074 HPEN hpenHilight, hpenLowlight;
00075 HPEN hpenBlack, hpenNeutral;
00076 HBRUSH hbrBackground; /* pieces and board */
00077 HFONT hFont;
00078 int status_charheight, status_charwidth;
00079
00080 /* default pt size for font (tenths of a pt) */
00081 #define         DEF_PTSIZE      80
00082 /*-public functions----------------------------------------------------------*/
00083
00084 /* StatusInit
00085  *
00086  * - create window class
00087  */
00088 BOOL
00089 StatusInit(
00090            HANDLE hInstance
00091            )
00092 {
00093     WNDCLASS    wc;
00094     BOOL resp;
00095     TEXTMETRIC tm = {0};
00096     HDC hDC;
00097
00098
00099     StatusCreateTools();
00100
00101     wc.style = CS_HREDRAW|CS_VREDRAW|CS_GLOBALCLASS;
00102     wc.lpfnWndProc = (WNDPROC)StatusWndProc;
00103     wc.cbClsExtra = 0;
00104     wc.cbWndExtra = sizeof(HANDLE);
00105     wc.hInstance = (HINSTANCE)hInstance;
00106     wc.hIcon = NULL;
00107     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00108     wc.hbrBackground = hbrBackground;
00109     wc.lpszClassName = (LPSTR) "gdstatusclass";
00110     wc.lpszMenuName = NULL;
00111
00112     resp = RegisterClass(&wc);
00113
00114     hDC = GetDC(NULL);
00115     if (hDC)
00116     {
00117         InitDC(hDC);
00118         GetTextMetrics(hDC, &tm);
00119         ReleaseDC(NULL, hDC);
00120     }
00121     else
00122     {
00123         // arbitrary, whatever...
00124         tm.tmHeight = 14;
00125         tm.tmAveCharWidth = 5;
00126     }
00127     status_charheight = (int)(tm.tmHeight + tm.tmExternalLeading);
00128     status_charwidth = (int)tm.tmAveCharWidth;
00129
00130     return(resp);
00131 }
00132
00133 /*
00134  * create and show the window
00135  */
00136 HWND APIENTRY
00137 StatusCreate(
00138              HANDLE hInst,
00139              HWND hParent,
00140              INT_PTR id,
00141              LPRECT rcp,
00142              HANDLE hmem
00143              )
00144 {
00145
00146     HWND hWnd;
00147
00148     /* create a child window of status class */
00149
00150
00151     hWnd = CreateWindow("gdstatusclass",
00152                         NULL,
00153                         WS_CHILD | WS_VISIBLE,
00154                         rcp->left,
00155                         rcp->top,
00156                         (rcp->right - rcp->left),
00157                         (rcp->bottom - rcp->top),
00158                         hParent,
00159                         (HMENU) id,
00160                         (HINSTANCE)hInst,
00161                         (LPVOID) hmem);
00162
00163     return(hWnd);
00164 }
00165
00166 /* return default height of this window */
00167 int APIENTRY
00168 StatusHeight(
00169              HANDLE hmem
00170              )
00171 /* The window has a number of items which are arranged horizontally,
00172    so the window height is the maximum of the individual heights
00173 */
00174 {
00175     PILIST plist;
00176     int i;
00177     int sz;
00178     int maxsize = 0;
00179
00180     plist = (PILIST) hmem;
00181     if (plist != NULL) {
00182         for (i = 0; i<plist->nitems; i++) {
00183             sz = StatusCalcHeight(NULL, &plist->statels[i]);
00184             maxsize = max(sz, maxsize);
00185         }
00186     }
00187     if (maxsize > 0) {
00188         return(maxsize + 4);
00189     } else {
00190         return(status_charheight + 4);
00191     }
00192 }
00193
00194 /* alloc the plist struct and return handle to caller */
00195 HANDLE APIENTRY
00196 StatusAlloc(
00197             int nitems
00198             )
00199 {
00200     PILIST pilist;
00201     LPSTR chp;
00202
00203     chp = (LPSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
00204                        sizeof(ILIST) + (sizeof(STATEL) * nitems));
00205     if (chp == NULL) {
00206         return(NULL);
00207     }
00208
00209     pilist = (PILIST) chp;
00210     pilist->nitems = nitems;
00211     pilist->statels = (PSTATEL) &chp[sizeof(ILIST)];
00212
00213     return(chp);
00214 }
00215
00216
00217 /* insert an item into the plist */
00218 BOOL APIENTRY
00219 StatusAddItem(
00220               HANDLE hmem,
00221               int itemnr,
00222               int type,
00223               int flags,
00224               int id,
00225               int width,
00226               LPSTR text
00227               )
00228 {
00229     PILIST pilist;
00230     PSTATEL pel;
00231   HRESULT hr;
00232
00233     pilist = (PILIST) hmem;
00234     if ((pilist == NULL) || (itemnr >= pilist->nitems)) {
00235         return(FALSE);
00236     }
00237     pel = &pilist->statels[itemnr];
00238     pel->type = type;
00239     pel->flags = flags;
00240     pel->id = id;
00241     pel->width = width;
00242     if (text == NULL) {
00243         pel->text[0] = '\0';
00244     } else {
00245         hr = StringCchCopy(pel->text,(SF_MAXLABEL+1), text);
00246     if (FAILED(hr))
00247       OutputError(hr, IDS_SAFE_COPY);
00248     }
00249
00250     return(TRUE);
00251 }
00252
00253 /* ---- internal functions ------------------------------------------*/
00254
00255 void
00256 InitDC(HDC hdc)
00257 {
00258     SetBkColor(hdc, RGB(192,192,192));
00259     SelectObject(hdc, hbrBackground);
00260     SelectObject(hdc, hFont);
00261 }
00262
00263
00264 void
00265 StatusCreateTools()
00266 {
00267     LOGFONT lf;
00268     HDC hdc;
00269     int scale;
00270
00271     hbrBackground = CreateSolidBrush(RGB(192,192,192));
00272     hpenHilight = CreatePen(0, 1, RGB(255, 255, 255));
00273     hpenLowlight = CreatePen(0, 1, RGB(128, 128, 128));
00274     hpenNeutral = CreatePen(0, 1, RGB(192, 192, 192));
00275     hpenBlack = CreatePen(0, 1, RGB(0, 0, 0));
00276
00277     hdc = GetDC(NULL);
00278     if (hdc)
00279     {
00280         scale = GetDeviceCaps(hdc, LOGPIXELSY);
00281         ReleaseDC(NULL, hdc);
00282     }
00283     else
00284     {
00285         // arbitrary, whatever...
00286         scale = 72;
00287     }
00288
00289     lf.lfHeight = -MulDiv(DEF_PTSIZE, scale, 720);
00290     lf.lfWidth = 0;
00291     lf.lfEscapement = 0;
00292     lf.lfOrientation = 0;
00293     lf.lfWeight = FW_REGULAR;
00294     lf.lfItalic = 0;
00295     lf.lfUnderline = 0;
00296     lf.lfStrikeOut = 0;
00297     lf.lfCharSet = ANSI_CHARSET;
00298     lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
00299     lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
00300     lf.lfQuality = PROOF_QUALITY;
00301     lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
00302     lf.lfFaceName[0] = '\0';
00303 #ifdef COMPLEX
00304     hFont = CreateFontIndirect(&lf);
00305 #else
00306     hFont = (HFONT)GetStockObject(SYSTEM_FONT);
00307 #endif
00308
00309
00310
00311 }
00312
00313 void
00314 StatusDeleteTools()
00315 {
00316     DeleteObject(hbrBackground);
00317     DeleteObject(hpenHilight);
00318     DeleteObject(hpenLowlight);
00319     DeleteObject(hpenBlack);
00320     DeleteObject(hpenNeutral);
00321
00322 #ifdef COMPLEX
00323     DeleteObject(hFont);
00324 #endif
00325 }
00326
00327 /* Main winproc for status windows
00328  *
00329  * handles create/destroy and paint requests
00330  */
00331
00332 INT_PTR APIENTRY
00333 StatusWndProc(
00334               HWND hWnd,
00335               UINT message,
00336               WPARAM wParam,
00337               LPARAM lParam
00338               )
00339 {
00340     HANDLE hitems;
00341     PSTATEL ip;
00342     PILIST plist;
00343     CREATESTRUCT * cp;
00344     int i;
00345     HDC hDC;
00346     RECT rc;
00347     POINT pt;
00348
00349     switch (message) {
00350
00351         case WM_CREATE:
00352             cp = (CREATESTRUCT *) lParam;
00353             hitems = (HANDLE) cp->lpCreateParams;
00354             SetWindowLongPtr(hWnd, 0,  (LONG_PTR)hitems);
00355             plist = (PILIST) hitems;
00356             if (plist != NULL) {
00357                 plist->selitem = -1;
00358             }
00359             break;
00360
00361         case WM_SIZE:
00362             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00363             plist = (PILIST) hitems;
00364             if (plist != NULL) {
00365                 StatusResize(hWnd, plist);
00366             }
00367             break;
00368
00369         case WM_PAINT:
00370             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00371             plist = (PILIST) hitems;
00372             StatusPaint(hWnd, plist);
00373
00374             break;
00375
00376         case WM_LBUTTONUP:
00377             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00378             plist = (PILIST)hitems;
00379             pt.x = LOWORD(lParam);
00380             pt.y = HIWORD(lParam);
00381
00382             if (plist == NULL) {
00383                 break;
00384             }
00385             if (plist->selitem != -1) {
00386                 ip = &plist->statels[plist->selitem];
00387                 if (plist->isselected) {
00388                     hDC = GetDC(hWnd);
00389                     if (hDC)
00390                     {
00391                         InitDC(hDC);
00392                         StatusButtonUp(hDC, ip);
00393                         ReleaseDC(hWnd, hDC);
00394                     }
00395                 }
00396                 plist->selitem = -1;
00397                 ReleaseCapture();
00398                 if (PtInRect(&ip->rc, pt)) {
00399                     SendMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(ip->id, WM_LBUTTONUP), (LPARAM)hWnd);
00400                 }
00401             }
00402             break;
00403
00404         case WM_LBUTTONDOWN:
00405             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00406             plist = (PILIST)hitems;
00407             if (plist == NULL) {
00408                 break;
00409             }
00410             pt.x = LOWORD(lParam);
00411             pt.y = HIWORD(lParam);
00412             if (plist->selitem == -1) {
00413                 for (i = 0; i< plist->nitems; i++) {
00414                     ip = &plist->statels[i];
00415                     if (PtInRect(&ip->rc, pt)) {
00416                         if (ip->type != SF_BUTTON) {
00417                             break;
00418                         }
00419                         plist->selitem = i;
00420                         SetCapture(hWnd);
00421
00422                         plist->isselected = TRUE;
00423                         hDC = GetDC(hWnd);
00424                         if (hDC)
00425                         {
00426                             InitDC(hDC);
00427                             StatusButtonDown(hDC, ip);
00428                             ReleaseDC(hWnd, hDC);
00429                         }
00430                         break;
00431                     }
00432                 }
00433             }
00434             break;
00435
00436         case WM_MOUSEMOVE:
00437             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00438             plist = (PILIST) hitems;
00439             if (plist == NULL) {
00440                 break;
00441             }
00442             pt.x = LOWORD(lParam);
00443             pt.y = HIWORD(lParam);
00444             if (plist->selitem != -1) {
00445                 ip = &plist->statels[plist->selitem];
00446                 if (PtInRect(&ip->rc, pt)) {
00447                     if (!plist->isselected) {
00448                         hDC = GetDC(hWnd);
00449                         if (hDC)
00450                         {
00451                             InitDC(hDC);
00452                             StatusButtonDown(hDC, ip);
00453                             ReleaseDC(hWnd, hDC);
00454                         }
00455                         plist->isselected = TRUE;
00456                     }
00457                 } else {
00458                     if (plist->isselected) {
00459                         hDC = GetDC(hWnd);
00460                         if (hDC)
00461                         {
00462                             InitDC(hDC);
00463                             StatusButtonUp(hDC, ip);
00464                             ReleaseDC(hWnd, hDC);
00465                         }
00466                         plist->isselected = FALSE;
00467                     }
00468                 }
00469             }
00470             break;
00471
00472
00473         case WM_DESTROY:
00474
00475             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00476             HeapFree(GetProcessHeap(), NULL, hitems);
00477             SetWindowLongPtr(hWnd, 0, 0);
00478             break;
00479
00480         case SM_NEW:
00481             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00482             if (hitems != NULL) {
00483                 HeapFree(GetProcessHeap(), NULL, hitems);
00484             }
00485             hitems = (HANDLE) wParam;
00486             if (hitems == NULL) {
00487                 SetWindowLongPtr(hWnd, 0, 0);
00488                 InvalidateRect(hWnd, NULL, TRUE);
00489                 break;
00490             }
00491             plist = (PILIST) hitems;
00492             if (plist == NULL) {
00493                 SetWindowLongPtr(hWnd, 0, 0);
00494                 InvalidateRect(hWnd, NULL, TRUE);
00495                 break;
00496             }
00497             plist->selitem = -1;
00498             StatusResize(hWnd, plist);
00499             SetWindowLongPtr(hWnd, 0, (LONG_PTR)hitems);
00500             InvalidateRect(hWnd, NULL, TRUE);
00501             break;
00502
00503         case SM_SETTEXT:
00504             hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
00505             if (hitems == NULL) {
00506                 break;
00507             }
00508             plist = (PILIST) hitems;
00509             ip = StatusGetItem(plist, (int)wParam);
00510             if (ip != NULL) {
00511                 if (lParam == 0) {
00512                     ip->text[0] = '\0';
00513                 } else {
00514                     My_mbsncpy(ip->text, (LPSTR) lParam, SF_MAXLABEL);
00515                     ip->text[SF_MAXLABEL] = '\0';
00516                 }
00517
00518                 /* if this is a variable width field, we need to redo
00519                  * all size calcs in case the field width has changed.
00520                  * in that case, we need to repaint the entire window
00521                  * and not just this field - so set rc to indicate the
00522                  * area to be redrawn.
00523                  */
00524                 if (ip->flags & SF_VAR) {
00525                     StatusResize(hWnd, plist);
00526                     GetClientRect(hWnd, &rc);
00527                     RedrawWindow(hWnd, &rc, NULL,
00528                                  RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW);
00529                 } else {
00530                     /* instead of just invalidating the window, we can
00531                      * force the window to be repainted now. This is
00532                      * essential for status updates during a busy
00533                      * loop when no messages are being processed,
00534                      * but we should still update the user on what's
00535                      * happening.
00536                      */
00537                     RedrawWindow(hWnd, &ip->rc, NULL,
00538                                  RDW_INVALIDATE|RDW_NOERASE|RDW_UPDATENOW);
00539                 }
00540
00541             }
00542             break;
00543
00544         default:
00545             return(DefWindowProc(hWnd, message, wParam, lParam));
00546     }
00547     return 0;
00548 }
00549
00550 /*
00551  * position the labels and buttons within the status window */
00552 void
00553 StatusResize(HWND hWnd, PILIST iplistp)
00554 {
00555     RECT rc;
00556     int curpos_right, curpos_left;
00557     int height, width;
00558     int i;
00559     PSTATEL ip;
00560
00561
00562     if (iplistp == NULL) {
00563         return;
00564     }
00565     GetClientRect(hWnd, &rc);
00566     curpos_left = rc.left + status_charwidth / 2;
00567     curpos_right = rc.right - (status_charwidth / 2);
00568
00569     /* loop through all items setting their position rects.
00570      * items are flagged as being left or right. We place them
00571      * in order starting at the left and the right, with a single
00572      * char's width between each item
00573      */
00574     for (i = 0; i < iplistp->nitems; i++) {
00575         ip = &iplistp->statels[i];
00576
00577         width = StatusCalcWidth(hWnd, ip);
00578         height = StatusCalcHeight(hWnd, ip);
00579         ip->rc.top = (rc.bottom - height) / 2;
00580         ip->rc.bottom = ip->rc.top + height;
00581
00582         /* see if  this item fits. Items that partially fit
00583          * are placed reduced in size.
00584          */
00585         if (ip->flags & SF_LEFT) {
00586
00587             if (curpos_left+width >= curpos_right) {
00588                 /* doesn't completely fit-does it partly? */
00589                 if ((curpos_left + 1) >= curpos_right) {
00590
00591                     /* no - this item does not fit */
00592                     ip->rc.left = 0;
00593                     ip->rc.right = 0;
00594                 } else {
00595                     /* partial fit */
00596                     ip->rc.left = curpos_left;
00597                     ip->rc.right = curpos_right - 1;
00598                     curpos_left = curpos_right;
00599                 }
00600             } else {
00601                 /* complete fit */
00602                 ip->rc.left = curpos_left;
00603                 ip->rc.right = curpos_left + width;
00604                 curpos_left += width + 1;
00605             }
00606         } else {
00607
00608             /* same size check for right-aligned items */
00609             if (curpos_right-width <= curpos_left) {
00610
00611                 if (curpos_right <= curpos_left+1) {
00612                     ip->rc.left = 0;
00613                     ip->rc.right = 0;
00614                 } else {
00615                     ip->rc.left = curpos_left + 1;
00616                     ip->rc.right = curpos_right;
00617                     curpos_right = curpos_left;
00618                 }
00619             } else {
00620                 ip->rc.right = curpos_right;
00621                 ip->rc.left = curpos_right - width;
00622                 curpos_right -= (width + 1);
00623             }
00624         }
00625     }
00626 }
00627
00628
00629 void
00630 StatusPaint(HWND hWnd, PILIST iplistp)
00631 {
00632     RECT rc;
00633     HDC hDC;
00634     PAINTSTRUCT ps;
00635     int i;
00636     PSTATEL ip;
00637     HPEN hpenOld;
00638
00639     GetClientRect(hWnd, &rc);
00640     hDC = BeginPaint(hWnd, &ps);
00641     InitDC(hDC);
00642
00643     RaiseRect(hDC, &rc);
00644     if (iplistp == NULL) {
00645         EndPaint(hWnd, &ps);
00646         return;
00647     }
00648     for (i =0; i < iplistp->nitems; i++) {
00649         ip = &iplistp->statels[i];
00650
00651         if (ip->rc.left == ip->rc.right) {
00652             continue;
00653         }
00654         if (ip->type == SF_STATIC) {
00655             if (ip->flags & SF_RAISE) {
00656                 RaiseRect(hDC, &ip->rc);
00657             } else if (ip->flags & SF_LOWER) {
00658                 LowerRect(hDC, &ip->rc);
00659             }
00660             rc = ip->rc;
00661             rc.left += (status_charwidth / 2);
00662             rc.right--;
00663             rc.top++;
00664             rc.bottom--;
00665             hpenOld = (HPEN)SelectObject(hDC, hpenNeutral);
00666             Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
00667             SelectObject(hDC, hpenOld);
00668             DrawText(hDC, ip->text, lstrlen(ip->text), &rc,
00669                      DT_LEFT | DT_VCENTER);
00670         } else {
00671             StatusButtonUp(hDC, ip);
00672         }
00673     }
00674
00675     EndPaint(hWnd, &ps);
00676 }
00677
00678 void
00679 RaiseRect(HDC hDC, LPRECT rcp)
00680 {
00681     TopLeft(hDC, rcp, hpenHilight, FALSE);
00682     BottomRight(hDC, rcp, hpenLowlight, FALSE);
00683 }
00684
00685 void
00686 LowerRect(HDC hDC, LPRECT rcp)
00687 {
00688     TopLeft(hDC, rcp, hpenLowlight, FALSE);
00689     BottomRight(hDC, rcp, hpenHilight, FALSE);
00690 }
00691
00692 void
00693 StatusButtonUp(HDC hDC, PSTATEL ip)
00694 {
00695     RECT rc;
00696     HPEN hpenOld;
00697     TEXTMETRIC tm;
00698
00699     rc = ip->rc;
00700     TopLeft(hDC, &rc, hpenBlack, TRUE);
00701     BottomRight(hDC, &rc, hpenBlack, FALSE);
00702
00703     rc.top++;
00704     rc.bottom--;
00705     rc.left++;
00706     rc.right--;
00707     TopLeft(hDC, &rc, hpenHilight, FALSE);
00708     BottomRight(hDC, &rc, hpenLowlight, TRUE);
00709
00710     rc.top++;
00711     rc.bottom--;
00712     rc.left++;
00713     rc.right--;
00714     BottomRight(hDC, &rc, hpenLowlight, TRUE);
00715     rc.bottom--;
00716     rc.right--;
00717     hpenOld = (HPEN)SelectObject(hDC, hpenNeutral);
00718     Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
00719     SelectObject(hDC, hpenOld);
00720     GetTextMetrics(hDC, &tm);
00721     rc.top += tm.tmExternalLeading;
00722     DrawText(hDC, ip->text, lstrlen(ip->text), &rc, DT_CENTER | DT_VCENTER);
00723 }
00724
00725 void
00726 StatusButtonDown(HDC hDC, PSTATEL ip)
00727 {
00728     RECT rc;
00729     HPEN hpenOld;
00730     TEXTMETRIC tm;
00731
00732     rc = ip->rc;
00733     TopLeft(hDC, &rc, hpenBlack, TRUE);
00734     BottomRight(hDC, &rc, hpenBlack, FALSE);
00735
00736     rc.top++;
00737     rc.bottom--;
00738     rc.left++;
00739     rc.right--;
00740     TopLeft(hDC, &rc, hpenLowlight, TRUE);
00741     rc.top++;
00742     rc.left++;
00743     TopLeft(hDC, &rc, hpenNeutral, TRUE);
00744     rc.top++;
00745     rc.left++;
00746     TopLeft(hDC, &rc, hpenNeutral, TRUE);
00747     rc.top++;
00748     rc.left++;
00749     hpenOld = (HPEN)SelectObject(hDC, hpenNeutral);
00750     Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
00751     SelectObject(hDC, hpenOld);
00752     GetTextMetrics(hDC, &tm);
00753     rc.top += tm.tmExternalLeading;
00754     DrawText(hDC, ip->text, lstrlen(ip->text), &rc, DT_CENTER | DT_VCENTER);
00755 }
00756
00757 void
00758 TopLeft(HDC hDC, LPRECT rcp, HPEN hpen, BOOL bCorners)
00759 {
00760     HPEN hpenOld;
00761     int x, y;
00762
00763     hpenOld = (HPEN)SelectObject(hDC, hpen);
00764     x = rcp->right - 1;
00765     y = rcp->bottom;
00766     if (!bCorners) {
00767         x--;
00768         y--;
00769     }
00770     MoveToEx(hDC, x, rcp->top, NULL);
00771     LineTo(hDC, rcp->left, rcp->top);
00772     LineTo(hDC, rcp->left, y);
00773     SelectObject(hDC, hpenOld);
00774 }
00775
00776 void
00777 BottomRight(HDC hDC, LPRECT rcp, HPEN hpen, BOOL bCorners)
00778 {
00779     HPEN hpenOld;
00780     int x, y;
00781
00782     hpenOld = (HPEN)SelectObject(hDC, hpen);
00783     x = rcp->left - 1;
00784     y = rcp->top;
00785     if (!bCorners) {
00786         x++;
00787         y++;
00788     }
00789     MoveToEx(hDC, rcp->right-1, y, NULL);
00790     LineTo(hDC, rcp->right-1, rcp->bottom-1);
00791     LineTo(hDC, x, rcp->bottom-1);
00792     SelectObject(hDC, hpenOld);
00793 }
00794
00795
00796 PSTATEL
00797 StatusGetItem(PILIST plist, int id)
00798 {
00799     int i;
00800
00801     if (plist == NULL) {
00802         return(NULL);
00803     }
00804     for (i = 0; i < plist->nitems; i++) {
00805         if (plist->statels[i].id == id) {
00806             return(&plist->statels[i]);
00807         }
00808     }
00809     return(NULL);
00810 }
00811
00812 /*
00813  * calculate the width of a given field. This is the width in characters
00814  * multiplied by the average character width, plus a few units for
00815  * borders.
00816  *
00817  * if SF_VAR is set, this field size varies depending on the text, so
00818  * we use GetTextExtent for the field size. If SF_VAR is selected, the caller
00819  * can specify that the size is not to exceed the (width * avecharwidth)
00820  * size (using SF_SZMAX) or that it is not be less than it (SF_SZMIN).
00821  */
00822 int
00823 StatusCalcWidth(HWND hWnd, PSTATEL ip)
00824 {
00825     int ch_size, t_size;
00826     SIZE sz = {0};
00827     HDC hDC;
00828
00829     ch_size = ip->width * status_charwidth;
00830     if (ip->flags & SF_VAR) {
00831         hDC = GetDC(hWnd);
00832         if (hDC)
00833         {
00834             InitDC(hDC);
00835             GetTextExtentPoint(hDC, ip->text, lstrlen(ip->text), &sz);
00836             ReleaseDC(hWnd, hDC);
00837         }
00838         t_size = sz.cx;
00839
00840         /*
00841          * check this size against min/max size if
00842          * requested
00843          */
00844
00845         if (ip->flags & SF_SZMIN) {
00846             if (ch_size > t_size) {
00847                 t_size = ch_size;
00848             }
00849         }
00850         if (ip->flags & SF_SZMAX) {
00851             if (ch_size < t_size) {
00852                 t_size = ch_size;
00853             }
00854         }
00855         ch_size = t_size;
00856     }
00857
00858     if (ch_size != 0) {
00859         if (ip->type == SF_BUTTON) {
00860             return(ch_size+6);
00861         } else {
00862             return(ch_size+4);
00863         }
00864     } else {
00865         return(0);
00866     }
00867 }
00868
00869 int
00870 StatusCalcHeight(HWND hWnd, PSTATEL ip)
00871 {
00872     int size;
00873
00874     size = status_charheight;
00875     if (ip->type == SF_BUTTON) {
00876         return(size + 6);
00877     } else {
00878         return(size + 2);
00879     }
00880 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/GdiDemo/GdiDemo.c Source File

  • Multimedia
  • Gdi
  • GdiDemo

GdiDemo.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /*---------------------------------------------------------------------------*\
00013 | GDIDEMO MODULE
00014 |   This is the main entry-point module for the GDIDEMO application.  It is
00015 |   intended to provide simple demonstrations of graphical functionality of
00016 |   WIN32.  This module is only concerned with the FRAME-WINDOW object.
00017 \*---------------------------------------------------------------------------*/
00018
00019 #include <windows.h>
00020 #include "gdidemo.h"
00021 #include "poly.h"
00022 #include "xform.h"
00023 #include "maze.h"
00024 #include "draw.h"
00025 #include "bounce.h"
00026
00027 HWND hWndMDIClient = NULL; /* Handle to MDI client */
00028
00029 /*---------------------------------------------------------------------------*\
00030 | WINDOWS MAIN PROCEDURE
00031 |   This is the process entry-point routine.  This is the basis for all
00032 |   application events.
00033 \*---------------------------------------------------------------------------*/
00034 int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszLine, int nShow)
00035 {
00036     HWND hWndFrame;
00037     MSG  msg;
00038
00039     lpszLine = lpszLine;
00040
00041     /*
00042     ** If there's a previous instance of this application, then we do not need
00043     ** to register it again.
00044     */
00045     if(!hPrevInst)
00046         if(!RegisterAppClass(hInst))
00047             return(1);
00048
00049
00050     /*
00051     ** Enter the application message-polling loop.  This is the anchor for
00052     ** the application.
00053     */
00054     msg.wParam = 1;
00055     if(hWndFrame = CreateAppWindow(hInst))
00056     {
00057   ShowWindow(hWndFrame,nShow);
00058         UpdateWindow(hWndFrame);
00059
00060         while(GetMessage(&msg,NULL,0,0))
00061         {
00062             if(!TranslateMDISysAccel(hWndMDIClient,&msg)) {
00063                 TranslateMessage(&msg);
00064                 DispatchMessage(&msg);
00065             }
00066         }
00067     }
00068     UnregisterAppClass(hInst);
00069
00070     return((int) msg.wParam);
00071 }
00072
00073
00074 /*---------------------------------------------------------------------------*\
00075 | CLIENT WINDOW PROCEDURE
00076 |   This is the main window function for the client-window created.  This is
00077 |   the frame window which encompasses the MDI control window.
00078 \*---------------------------------------------------------------------------*/
00079
00080 LRESULT CALLBACK WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam)
00081 {
00082     HWND hWndClient;
00083
00084
00085     switch(wMsg)
00086     {
00087         /*
00088         ** Set up any pre-display stuff.  This is where we create the MDI
00089         ** control window.
00090         */
00091         case WM_CREATE:
00092             CreateProc(hWndFrame);
00093 /*
00094 ** DEMO MODE - These PostMessages Are for Demonstration Only
00095 */
00096             PostMessage(hWndFrame,WM_COMMAND,IDM_DEMO_DRAW,0);
00097             PostMessage(hWndFrame,WM_COMMAND,IDM_DEMO_POLYBEZIER,0);
00098             PostMessage(hWndFrame,WM_COMMAND,IDM_DEMO_BOUNCE,0);
00099             PostMessage(hWndFrame,WM_COMMAND,IDM_WINDOW_TILE,0);
00100
00101             break;
00102
00103
00104         /*
00105         ** Paint the background of the frame.  This really is a NOP since
00106         ** the MDI control is displayed over the frame's client window.
00107         */
00108         case WM_PAINT:
00109             PaintProc(hWndFrame);
00110             break;
00111
00112
00113         /*
00114         ** Time to die.
00115         */
00116         case WM_DESTROY:
00117             DestroyProc(hWndFrame);
00118             break;
00119
00120
00121         /*
00122         ** Process the frame-commands.  We need to let the default handler
00123         ** have this event, since the MDI control handles the
00124         ** commands as well.
00125         */
00126         case WM_COMMAND:
00127             CommandProc(hWndFrame,wParam,lParam);
00128
00129
00130         /*
00131         ** Since this is the frame-window, we need to grab the MDI client
00132         ** control window to pass to the MDI control.  We store this as
00133         ** part of the extra-object information for the frame-window.
00134         */
00135         default:
00136             hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND);
00137             return(DefFrameProc(hWndFrame,hWndClient,wMsg,wParam,lParam));
00138     }
00139     return(0l);
00140 }
00141
00142
00143 /*---------------------------------------------------------------------------*\
00144 | CLIENT CREATE PROCEDURE
00145 |   This is the main event-handler for the WM_CREATE message.  It is here
00146 |   we create the MDI control window for the application.  We store this
00147 |   information as part of the frame-window extra object information.
00148 \*---------------------------------------------------------------------------*/
00149 BOOL CreateProc(HWND hWndFrame)
00150 {
00151     /*
00152     ** Set the window information to contain the child window.
00153     */
00154     if(hWndMDIClient = CreateMDIClientWindow(hWndFrame))
00155         SetWindowLongPtr(hWndFrame,CLIENTWND,(LONG_PTR)hWndMDIClient);
00156
00157     return(TRUE);
00158 }
00159
00160
00161 /*---------------------------------------------------------------------------*\
00162 | COMMAND PROCEDURE
00163 |   This is the main event-handler for the WM_COMMAND event for the window
00164 |   application.  All we really do is process the MENU commands for creating
00165 |   the DEMO windows.
00166 \*---------------------------------------------------------------------------*/
00167 BOOL CommandProc(HWND hWndFrame, WPARAM wParam, LPARAM lParam)
00168 {
00169     HWND hWndClient;
00170
00171     lParam = lParam;
00172
00173     switch(wParam)
00174     {
00175         /*
00176         ** Demo the poly-bezier window.
00177         */
00178         case IDM_DEMO_POLYBEZIER:
00179             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00180                 CreatePolyWindow(hWndClient,0);
00181             break;
00182
00183
00184         /*
00185         ** Demo the xform's.
00186         */
00187         case IDM_DEMO_XFORM:
00188             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00189                 CreateXFormWindow(hWndClient,0);
00190             break;
00191
00192
00193         /*
00194         ** Demo the maze.
00195         */
00196         case IDM_DEMO_MAZE:
00197             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00198                 CreateMazeWindow(hWndClient,0);
00199             break;
00200
00201
00202         /*
00203         ** Demo random drawing objects.
00204         */
00205         case IDM_DEMO_DRAW:
00206             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00207                 CreateDrawWindow(hWndClient,0);
00208             break;
00209
00210
00211         /*
00212         ** Demo bouncing region balls.
00213         */
00214         case IDM_DEMO_BOUNCE:
00215             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00216                 CreateBounceWindow(hWndClient,0);
00217             break;
00218
00219
00220         /*
00221         ** MDI cascade the demo windows.
00222         */
00223         case IDM_WINDOW_CASCADE:
00224             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00225                 SendMessage(hWndClient,WM_MDICASCADE,0,0l);
00226             break;
00227
00228
00229         /*
00230         ** MDI tile the demo windows.
00231         */
00232         case IDM_WINDOW_TILE:
00233             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00234                 SendMessage(hWndClient,WM_MDITILE,0,0l);
00235             break;
00236
00237
00238         /*
00239         ** MDI arrange the MDI icons.
00240         */
00241         case IDM_WINDOW_ICON:
00242             if(hWndClient = (HWND)GetWindowLongPtr(hWndFrame,CLIENTWND))
00243                 SendMessage(hWndClient,WM_MDIICONARRANGE,0,0l);
00244             break;
00245
00246
00247         /*
00248         ** Display the about box.
00249         */
00250         case IDM_HELP_ABOUT:
00251       DisplayDialogBox(hWndFrame,MAKEINTRESOURCE(ABOUTBOX),(WNDPROC)AboutDlgProc,0l);
00252             break;
00253
00254
00255         /*
00256         ** Command not recognized.
00257         */
00258         default:
00259             return(FALSE);
00260     }
00261     return(TRUE);
00262 }
00263
00264
00265 /*---------------------------------------------------------------------------*\
00266 | CLIENT PAINT PROCEDURE
00267 |   This is the main event-handler for the WM_PAINT message.
00268 \*---------------------------------------------------------------------------*/
00269 VOID PaintProc(HWND hWndFrame)
00270 {
00271     HDC         hDC;
00272     PAINTSTRUCT ps;
00273
00274
00275     if(hDC = BeginPaint(hWndFrame,&ps))
00276         EndPaint(hWndFrame,&ps);
00277
00278     return;
00279 }
00280
00281
00282 /*---------------------------------------------------------------------------*\
00283 | CLIENT DESTROY PROCEDURE
00284 |   This routine is called to cleanup global resources upon exit of the
00285 |   application.
00286 \*---------------------------------------------------------------------------*/
00287 VOID DestroyProc(HWND hWndFrame)
00288 {
00289     hWndFrame = hWndFrame;
00290
00291     PostQuitMessage(0);
00292
00293     return;
00294 }
00295
00296
00297
00298 DWORD FAR lRandom(VOID)
00299 {
00300     static DWORD glSeed = (DWORD)-365387184;
00301
00302     glSeed *= 69069;
00303     return(++glSeed);
00304 }
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/getdomainmode/vc/getdomainmode.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • getdomainmode
  • vc

getdomainmode.cpp

Go to the documentation of this file.
00001 #include <wchar.h>
00002 #include <activeds.h>
00003
00004 HRESULT CheckDomainModeOfObject(IDirectoryObject *pDirObject, BOOL *bIsMixed);
00005 WCHAR * GetDirectoryObjectAttrib(IDirectoryObject *pDirObject,LPWSTR pAttrName);
00006 HRESULT GetDomainMode(IADs *pDomain, BOOL *bIsMixed);
00007
00008
00009 int main(int argc, char* argv[])
00010 {
00011
00012 wprintf(L"This program checks whether the current domain is in mixed or native mode.\n");
00013
00014 //Intialize COM
00015 CoInitialize(NULL);
00016 HRESULT hr = S_OK;
00017 //Get rootDSE and the domain container's DN.
00018 IADs *pObject = NULL;
00019 LPOLESTR szPath = new OLECHAR[MAX_PATH];
00020 VARIANT var;
00021 BOOL bIsMixed;
00022
00023 hr = ADsOpenObject(L"LDAP://rootDSE",
00024          NULL,
00025          NULL,
00026          ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00027          IID_IADs,
00028          (void**)&pObject);
00029 if (FAILED(hr))
00030 {
00031    wprintf(L"Not Found. Could not bind to the domain.\n");
00032    if (pObject)
00033      pObject->Release();
00034    return TRUE;
00035 }
00036
00037 hr = pObject->Get(L"defaultNamingContext",&var);
00038 if (SUCCEEDED(hr))
00039 {
00040   wcscpy(szPath,L"LDAP://"); //For NT 4.0 and Win 9.x, you must add the server name, e.g LDAP://myServer
00041   int len = wcslen(szPath);
00042   int dnLen = wcslen( var.bstrVal);
00043   if ( MAX_PATH <= len + dnLen ) // make sure we have enough buffer
00044   {
00045     wprintf(L"The buffer is too small for the DN\n");
00046     pObject->Release();
00047     VariantClear(&var);
00048     return FALSE;
00049   }
00050
00051
00052   wcscat(szPath,var.bstrVal);
00053   VariantClear(&var);
00054   if (pObject)
00055   {
00056      pObject->Release();
00057      pObject = NULL;
00058   }
00059   //Bind to the root of the current domain.
00060   hr = ADsOpenObject(szPath,
00061            NULL,
00062            NULL,
00063            ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00064            IID_IADs,
00065            (void**)&pObject);
00066   if (SUCCEEDED(hr))
00067   {
00068     hr = GetDomainMode(pObject, &bIsMixed);
00069     if (SUCCEEDED(hr))
00070     {
00071         hr = pObject->Get(L"name",&var);
00072       if (bIsMixed)
00073         wprintf(L"Current domain %s is in mixed mode\n", var.bstrVal);
00074       else
00075         wprintf(L"Current domain %s is in native mode\n", var.bstrVal);
00076     }
00077     else
00078       wprintf(L"GetDomainMode failed with hr: %x",hr);
00079   }
00080   else
00081     wprintf(L"Bind to domain failed with hr: %x",hr);
00082 }
00083 VariantClear(&var);
00084 if (pObject)
00085   pObject->Release();
00086
00087 return TRUE;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097 HRESULT GetDomainMode(IADs *pDomain, BOOL *bIsMixed)
00098 {
00099 HRESULT hr = E_FAIL;
00100 VARIANT var;
00101 if (pDomain)
00102 {
00103   VariantClear(&var);
00104   //Get the ntMixedDomain attribute
00105   LPOLESTR szAttribute = L"ntMixedDomain";
00106   hr = pDomain->Get(szAttribute,&var);
00107   if (SUCCEEDED(hr))
00108   {
00109     //Type should be VT_I4.
00110     if (var.vt==VT_I4)
00111     {
00112       //Zero means native mode.
00113       if (var.lVal == 0)
00114         *bIsMixed = FALSE;
00115       //One means mixed mode.
00116       else if (var.lVal == 1)
00117         *bIsMixed = TRUE;
00118       else
00119         hr=E_FAIL;
00120     }
00121   }
00122   VariantClear(&var);
00123 }
00124 return hr;
00125
00126 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/Inc/IPageS.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • Inc

IPageS.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      IPAGES.H
00003
00004   Summary:   This is the common include file for the persistent
00005              page-related COM Interfaces. The Interface abstract base
00006              classes are declared.
00007
00008              This file is global to all the Tutorial Code Samples (kept in
00009              the ..\INC directory).  It is a good practice to factor out
00010              Interface and GUID specifications to reduce the possibility
00011              of GUID or interface conflicts.
00012
00013   Classes:   IPageList, IPageListSink, ITextPage, ITextPageSink,
00014              IDrawPage, IDrawPageSink.
00015
00016   Functions: .
00017
00018   Origin:    5-26-97: atrent - Revised for the COM Tutorial Samples.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 #if !defined(IPAGES_H)
00036 #define IPAGES_H
00037
00038 #if !defined(RC_INCLUDE)
00039
00040 // Here are the page types.
00041 #define PAGETYPE_NONE    0
00042 #define PAGETYPE_DELETED 1
00043 #define PAGETYPE_TEXT    2
00044 #define PAGETYPE_DRAWING 3
00045
00046 // Page Open Status.
00047 #define OPENSTATE_NONE   0
00048 #define OPENSTATE_YES    1
00049 #define OPENSTATE_NO     2
00050
00051 #define PAGE_TITLE_SIZE 64
00052 #define PAGE_NAME_SIZE 16
00053
00054 // Strings used for assembling IStorage/IStream names.
00055 #define PAGELIST_USTR L"PageList"
00056
00057 // Messages for posting events from page windows to main app window.
00058 #define WM_USER_PAGECHANGED WM_USER+400
00059 #define WM_USER_PAGECLOSED  WM_USER+401
00060
00061
00062 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00063   Interface: IPageList
00064
00065   Summary:   Interface for page list features to manipulate the
00066              encapsulated page list.
00067
00068   Methods:   Get(
00069                  INT     iPage,
00070                  BOOL*   pbOpened,
00071                  SHORT*  pnType,
00072                  WCHAR*  pwszTitle,
00073                  WCHAR*  pwszDataName);
00074                Get a Page List Item for a given page number. Get back
00075                open status, page type, page title, and page data name.
00076              Set(
00077                  INT     iPage,
00078                  SHORT   nOpenStatus,
00079                  WCHAR*  pwszNewTitle);
00080                Put a Page List Item of specified page number with new
00081                page open status and page title.
00082              Add(
00083                  INT     iPage,
00084                  SHORT   nType,
00085                  WCHAR*  pwszTitle,
00086                  INT*    piPage)
00087                Add/insert a new Page List Item of specified type with
00088                specified title.
00089              Delete(INT  iPage);
00090                Delete the Page List Item for the specified page number.
00091              Clear(void);
00092                Clear/Delete all Page List Items from the Page List.
00093 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00094 DECLARE_INTERFACE_(IPageList, IUnknown)
00095 {
00096   // IUnknown methods.
00097   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00098   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00099   STDMETHOD_(ULONG,Release) (THIS) PURE;
00100
00101   // IPageList methods.
00102   STDMETHOD(Get)        (THIS_ INT, BOOL*, SHORT*, WCHAR*, WCHAR*) PURE;
00103   STDMETHOD(Set)        (THIS_ INT, SHORT, WCHAR*) PURE;
00104   STDMETHOD(Add)        (THIS_ INT, SHORT, WCHAR*, INT*) PURE;
00105   STDMETHOD(Delete)     (THIS_ INT) PURE;
00106   STDMETHOD(Clear)      (THIS) PURE;
00107 };
00108
00109
00110 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00111   Interface: IPageListSink
00112
00113   Summary:   Sink Connection Interface for PageList COM Objects
00114              that communicate events back to the client.
00115
00116   Methods:   Loaded
00117                The PageList was loaded from persistent storage.
00118              Saved
00119                The PageList was saved to persistent storage.
00120              Cleared
00121                The entire PageList was cleared.
00122              PageAdded(INT iPage);
00123                A new PageItem was added to the PageList.
00124              PageDeleted(INT iPage);
00125                A PageItem was deleted from the PageList.
00126              PageSet(INT iPage);
00127                A PageItem entry was set with new data.
00128 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00129 DECLARE_INTERFACE_(IPageListSink, IUnknown)
00130 {
00131   // IUnknown methods.
00132   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00133   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00134   STDMETHOD_(ULONG,Release) (THIS) PURE;
00135
00136   // IPageListSink methods.
00137   STDMETHOD(Loaded)      (THIS) PURE;
00138   STDMETHOD(Saved)       (THIS) PURE;
00139   STDMETHOD(Cleared)     (THIS) PURE;
00140   STDMETHOD(PageAdded)   (THIS_ INT) PURE;
00141   STDMETHOD(PageDeleted) (THIS_ INT) PURE;
00142   STDMETHOD(PageSet)     (THIS_ INT) PURE;
00143 };
00144
00145
00146 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00147   Interface: ITextPage
00148
00149   Summary:   Interface for text page features to manipulate the text
00150              in the encapsulated text page.
00151
00152   Methods:   GetLength(INT*    piLength);
00153                Get the current length (in WCHARs) of the text page.
00154              GetText(WCHAR* pwszPageText);
00155                Get the current page text held in this object.
00156              PutText(WCHAR* pwszPageText, INT iLength);
00157                Put specified wide character text of specified length
00158                into this text page object. Does not save persistently.
00159              Clear(BOOL bSaveNeeded);
00160                Clears all text from the entire text page.
00161 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00162 DECLARE_INTERFACE_(ITextPage, IUnknown)
00163 {
00164   // IUnknown methods.
00165   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00166   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00167   STDMETHOD_(ULONG,Release) (THIS) PURE;
00168
00169   // ITextPage methods.
00170   STDMETHOD(GetLength)  (THIS_ INT*) PURE;
00171   STDMETHOD(GetText)    (THIS_ WCHAR*) PURE;
00172   STDMETHOD(PutText)    (THIS_ WCHAR*, INT) PURE;
00173   STDMETHOD(Clear)      (THIS_ BOOL) PURE;
00174 };
00175
00176
00177 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00178   Interface: ITextPageSink
00179
00180   Summary:   Sink Connection Interface for TextPage COM Objects
00181              that communicate events back to the client.
00182
00183   Methods:   Loaded
00184                The TextPage was loaded from persistent stream.
00185              Saved
00186                The TextPage was saved to persistent stream.
00187              Put
00188                New text content was put into the TextPage object.
00189              Cleared
00190                The entire TextPage was cleared.
00191 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00192 DECLARE_INTERFACE_(ITextPageSink, IUnknown)
00193 {
00194   // IUnknown methods.
00195   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00196   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00197   STDMETHOD_(ULONG,Release) (THIS) PURE;
00198
00199   // ITextPageSink methods.
00200   STDMETHOD(Loaded)      (THIS) PURE;
00201   STDMETHOD(Saved)       (THIS) PURE;
00202   STDMETHOD(Put)         (THIS) PURE;
00203   STDMETHOD(Cleared)     (THIS) PURE;
00204 };
00205
00206
00207 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00208   Interface: IDrawPage
00209
00210   Summary:   Interface for free-form drawing on drawing page COM Objects.
00211
00212   Methods:   InkStart(SHORT nX,SHORT nY,SHORT nInkWidth,COLORREF crInkColor);
00213                Client starts color ink drawing to the drawing surface.
00214              InkDraw(SHORT nX, SHORT nY);
00215                Client puts ink data points on the drawing surface.
00216              InkStop(SHORT nX, SHORT nY);
00217                Client stops ink drawing to the drawing surface.
00218              Clear(BOOL bSaveNeeded);
00219                Clear the current drawing content. Notify Sinks.
00220                Mark dirty flag if bSaveNeeded==TRUE.
00221              Resize(SHORT nWidth, SHORT nHeight);
00222                Resize the drawing rectangle size.
00223              Redraw
00224                Redraw content of drawing object via Sink notification.
00225 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00226 DECLARE_INTERFACE_(IDrawPage, IUnknown)
00227 {
00228   // IUnknown methods.
00229   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00230   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00231   STDMETHOD_(ULONG,Release) (THIS) PURE;
00232
00233   // IDrawPage methods.
00234   STDMETHOD(InkStart)   (THIS_ SHORT, SHORT, SHORT, COLORREF) PURE;
00235   STDMETHOD(InkDraw)    (THIS_ SHORT, SHORT) PURE;
00236   STDMETHOD(InkStop)    (THIS_ SHORT, SHORT) PURE;
00237   STDMETHOD(Clear)      (THIS_ BOOL) PURE;
00238   STDMETHOD(Resize)     (THIS_ SHORT, SHORT) PURE;
00239   STDMETHOD(Redraw)     (THIS) PURE;
00240 };
00241
00242
00243 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00244   Interface: IDrawPageSink
00245
00246   Summary:   Sink Connection Interface for use by DrawPage COM Objects
00247              that communicate events back to the client.
00248
00249   Methods:   Loaded
00250                The DrawPage was loaded from persistent storage.
00251              Saved
00252                The DrawPage was saved to persistent storage.
00253              InkStart(SHORT nX,SHORT nY,SHORT nInkWidth,COLORREF crInkColor);
00254                A client started a color ink drawing sequence.
00255              InkDraw(SHORT nX, SHORT nY);
00256                A client is putting ink data points on the drawing surface.
00257              InkStop(SHORT nX, SHORT nY);
00258                A client stopped its ink drawing sequence.
00259              Cleared
00260                A client has erased/cleared the entire DrawPage.
00261              Resized(SHORT nWidth, SHORT nHeight);
00262                A client has resized the drawing window.
00263 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00264 DECLARE_INTERFACE_(IDrawPageSink, IUnknown)
00265 {
00266   // IUnknown methods.
00267   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00268   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00269   STDMETHOD_(ULONG,Release) (THIS) PURE;
00270
00271   // IDrawPageSink methods.
00272   STDMETHOD(Loaded)      (THIS) PURE;
00273   STDMETHOD(Saved)       (THIS) PURE;
00274   STDMETHOD(InkStart)    (THIS_ SHORT, SHORT, SHORT, COLORREF) PURE;
00275   STDMETHOD(InkDraw)     (THIS_ SHORT, SHORT) PURE;
00276   STDMETHOD(InkStop)     (THIS_ SHORT, SHORT) PURE;
00277   STDMETHOD(Cleared)     (THIS) PURE;
00278   STDMETHOD(Resized)     (THIS_ SHORT, SHORT) PURE;
00279 };
00280
00281
00282 #endif // RC_INCLUDE
00283
00284 #endif // IPAGES_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/BaseSnap.h Source File

  • SysMgmt
  • MMC
  • Help

BaseSnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Ppgeext/ppgeext.Cpp Source File

  • SysMgmt
  • MMC
  • Ppgeext

ppgeext.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "PPgeExt.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 // we need to do this to get around MMC.IDL - it explicitly defines
00025 // the clipboard formats as WCHAR types...
00026 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00027 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00028 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00029
00030     // These are the clipboard formats that we must supply at a minimum.
00031     // mmc.h actually defined these. We can make up our own to use for
00032     // other reasons. We don't need any others at this time.
00033 UINT CPropSheetExtension::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00034 UINT CPropSheetExtension::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00035 UINT CPropSheetExtension::s_cfSnapInCLSID = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00036
00037 CPropSheetExtension::CPropSheetExtension() : m_cref(0)
00038 {
00039     OBJECT_CREATED
00040 }
00041
00042 CPropSheetExtension::~CPropSheetExtension()
00043 {
00044     OBJECT_DESTROYED
00045 }
00046
00047 ///////////////////////
00048 // IUnknown implementation
00049 ///////////////////////
00050
00051 STDMETHODIMP CPropSheetExtension::QueryInterface(REFIID riid, LPVOID *ppv)
00052 {
00053     if (!ppv)
00054         return E_FAIL;
00055
00056     *ppv = NULL;
00057
00058     if (IsEqualIID(riid, IID_IUnknown))
00059         *ppv = static_cast<IExtendPropertySheet *>(this);
00060     else if (IsEqualIID(riid, IID_IExtendPropertySheet))
00061         *ppv = static_cast<IExtendPropertySheet *>(this);
00062
00063     if (*ppv)
00064     {
00065         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00066         return S_OK;
00067     }
00068
00069     return E_NOINTERFACE;
00070 }
00071
00072 STDMETHODIMP_(ULONG) CPropSheetExtension::AddRef()
00073 {
00074     return InterlockedIncrement((LONG *)&m_cref);
00075 }
00076
00077 STDMETHODIMP_(ULONG) CPropSheetExtension::Release()
00078 {
00079     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00080     {
00081         // we need to decrement our object count in the DLL
00082         delete this;
00083         return 0;
00084     }
00085
00086     return m_cref;
00087 }
00088
00089 BOOL CALLBACK CPropSheetExtension::DialogProc(
00090                                               HWND hwndDlg,  // handle to dialog box
00091                                               UINT uMsg,     // message
00092                                               WPARAM wParam, // first message parameter
00093                                               LPARAM lParam  // second message parameter
00094                                               )
00095 {
00096     static CPropSheetExtension *pThis = NULL;
00097
00098     switch (uMsg) {
00099     case WM_INITDIALOG:
00100         pThis = reinterpret_cast<CPropSheetExtension *>(reinterpret_cast<PROPSHEETPAGE *>(lParam)->lParam);
00101
00102         break;
00103
00104     case WM_COMMAND:
00105         if (HIWORD(wParam) == EN_CHANGE ||
00106             HIWORD(wParam) == CBN_SELCHANGE)
00107             SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
00108         break;
00109
00110     case WM_DESTROY:
00111         // we don't free the notify handle for property sheets
00112         // MMCFreeNotifyHandle(pThis->m_ppHandle);
00113         break;
00114
00115     case WM_NOTIFY:
00116         switch (((NMHDR *) lParam)->code) {
00117         case PSN_APPLY:
00118             // don't notify the primary snap-in that Apply
00119             // has been hit...
00120             // MMCPropertyChangeNotify(pThis->m_ppHandle, (long)pThis);
00121             return PSNRET_NOERROR;
00122         }
00123         break;
00124     }
00125
00126     return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
00127 }
00128
00129 ///////////////////////////////
00130 // Interface IExtendPropertySheet
00131 ///////////////////////////////
00132 HRESULT CPropSheetExtension::CreatePropertyPages(
00133                                                  /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00134                                                  /* [in] */ LONG_PTR handle,
00135                                                  /* [in] */ LPDATAOBJECT lpIDataObject)
00136 {
00137     PROPSHEETPAGE psp;
00138     HPROPSHEETPAGE hPage = NULL;
00139
00140     // we don't cache this handle like in a primary snap-in
00141     // the handle value here is always 0
00142     // m_ppHandle = handle;
00143
00144     psp.dwSize = sizeof(PROPSHEETPAGE);
00145     psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEICONID;
00146     psp.hInstance = g_hinst;
00147     psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE);
00148     psp.pfnDlgProc = DialogProc;
00149     psp.lParam = reinterpret_cast<LPARAM>(this);
00150     psp.pszTitle = MAKEINTRESOURCE(IDS_PST_ROCKET_EXT);
00151     psp.pszIcon = MAKEINTRESOURCE(IDI_PSI_ROCKET);
00152
00153     hPage = CreatePropertySheetPage(&psp);
00154     _ASSERT(hPage);
00155
00156     HRESULT hr = lpProvider->AddPage(hPage);
00157     return hr;
00158 }
00159
00160 HRESULT CPropSheetExtension::QueryPagesFor(
00161                                            /* [in] */ LPDATAOBJECT lpDataObject)
00162 {
00163     return S_OK;
00164 }
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/StdAfx.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

StdAfx.h

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: StdAfx.h
00006  * ---------- [ Header Declaration File]
00007  *
00008  *
00009  *
00010  ******************************************************/
00011
00012
00013
00014
00015 #if !defined(AFX_STDAFX_H__D7C67B57_5C7A_4C03_B87F_98D37F93D82A__INCLUDED_)
00016 #define AFX_STDAFX_H__D7C67B57_5C7A_4C03_B87F_98D37F93D82A__INCLUDED_
00017
00018 #if _MSC_VER > 1000
00019 #pragma once
00020 #endif // _MSC_VER > 1000
00021
00022 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00023
00024 #include <afxwin.h>         // MFC core and standard components
00025 #include <afxext.h>         // MFC extensions
00026 #include <afxdisp.h>        // MFC Automation classes
00027 #include <afxdtctl.h>   // MFC support for Internet Explorer 4 Common Controls
00028 #ifndef _AFX_NO_AFXCMN_SUPPORT
00029 #include <afxcmn.h>     // MFC support for Windows Common Controls
00030 #endif // _AFX_NO_AFXCMN_SUPPORT
00031
00032
00033 #include "Utils.h"
00034
00035 #include "process.h"
00036 #include "rtccore.h"
00037 #include "rtcerr.h"
00038
00039 #include <windows.h>
00040 #include <atlbase.h>
00041 #include "objbase.h"
00042 #include <tchar.h>
00043 #include "ocidl.h"
00044 #include "process.h"
00045 #include "crtdbg.h"
00046
00047
00048 #endif // !defined(AFX_STDAFX_H__D7C67B57_5C7A_4C03_B87F_98D37F93D82A__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/registry.h Source File

  • SysMgmt
  • MMC
  • Multisel

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkHitTest/AssemblyInfo.cs Source File

  • TabletPC
  • InkHitTest

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("Ink Hit Test Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2003 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 [assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 //[assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/authz/common.h Source File

  • Security
  • Authorization
  • authz

common.h

Go to the documentation of this file.
00001 /*++
00002
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1999 - 2001 Microsoft Corporation.  All rights reserved.
00009
00010 Module Name:
00011
00012     Common.h
00013
00014
00015 --*/
00016 ///////////////////////////////////////////////////////////////////////////////
00017 // Access flags for funds RM
00018 //
00019 ///////////////////////////////////////////////////////////////////////////////
00020
00021 //
00022 // Personal expenditures
00023 //
00024 #define ACCESS_FUND_PERSONAL   0x00000001
00025
00026
00027 //
00028 // Company spending
00029 //
00030 #define ACCESS_FUND_CORPORATE  0x00000002
00031
00032
00033 //
00034 // Transfer to other funds
00035 //
00036 #define ACCESS_FUND_TRANSFER   0x00000004
00037
00038
00039
00040 ///////////////////////////////////////////////////////////////////////////////
00041 // Codes for expense access attempts
00042 //
00043 ///////////////////////////////////////////////////////////////////////////////
00044
00045 //
00046 // Expense approved and subtracted from fund.
00047 //
00048 #define EXPENSE_APPROVED 0
00049
00050 //
00051 // We'll use existing ERROR_ACCESS_DENIED for access denied.
00052 //
00053 // ERROR_ACCESS_DENIED = 0x00000005
00054
00055 //
00056 // Error with bit 29 set are private errors (see SetLastError doc)
00057 //
00058 #define PRIVATE_ERROR_BIT 0x20000000
00059
00060
00061 //
00062 // Expense failed insufficient funds
00063 //
00064 #define ERROR_INSUFFICIENT_FUNDS 0x20000002
00065
00066
00067 //
00068 // Expense failed due to an unknown error
00069 //
00070 #define EXPENSE_UNKNOWN_ERROR 0x20000003
00071
00072
00073
00074 ///////////////////////////////////////////////////////////////////////////////
00075 // Expense request packing struct
00076 //
00077 ///////////////////////////////////////////////////////////////////////////////
00078 typedef struct _ExpenseBuf
00079 {
00080    DWORD dwAmmount;
00081    DWORD dwType;
00082 } EX_BUF,*PEX_BUF;
00083
00084 LPTSTR ExNames[5] = { "\0", TEXT("PERSONAL"),TEXT("CORPORATE"),"\0",TEXT("TRANSFER") };
00085
00086
00087
00088 ///////////////////////////////////////////////////////////////////////////////
00089 // Function Prototypes
00090 //
00091 ///////////////////////////////////////////////////////////////////////////////
00092
00093 void HandleError(DWORD dwErr, TCHAR *pszAPI, BOOL fAPI, BOOL fExit);
00094
00095 DWORD DisplayAPIError(TCHAR *pszAPI,BOOL bConsole,
00096                       BOOL bMsgBox, BOOL bExit);
00097
00098 BOOL SetupNamedPipe (PHANDLE phPipe, LPTSTR szPipeName);
00099
00100 BOOL WriteToPipe(HANDLE hPipe, BYTE* pData, DWORD cbData);
00101
00102 DWORD ReadFromPipe(HANDLE hPipe, BYTE* pBuffer, DWORD cbBuffer);
00103
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/cMgr.h Source File

  • Web
  • NetMeeting
  • NMUI

cMgr.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       CMGR.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 //****************************************************************************
00016 //
00017 // CLASS CMgrNotify
00018 //
00019 //****************************************************************************
00020
00021 class CMgrNotify : public RefCount, public CNotify, public INmManagerNotify
00022 {
00023 public:
00024   CMgrNotify();
00025   ~CMgrNotify();
00026
00027   // INmManagerNotify
00028   HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
00029   HRESULT STDMETHODCALLTYPE ConferenceCreated(INmConference *pConference);
00030   HRESULT STDMETHODCALLTYPE CallCreated(INmCall *pCall);
00031
00032   // ICNotify methods
00033   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00034   HRESULT STDMETHODCALLTYPE Disconnect(void);
00035
00036   // IUnknown methods
00037   ULONG STDMETHODCALLTYPE AddRef(void);
00038   ULONG STDMETHODCALLTYPE Release(void);
00039   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00040 };
00041
00042
00043 //****************************************************************************
00044 //
00045 // Global Variables
00046 //
00047 //****************************************************************************
00048
00049 extern INmManager * g_pMgr;
00050
00051 extern const GUID g_guid;
00052 extern const GUID g_guidNMUIChat;
00053
00054
00055 //****************************************************************************
00056 //
00057 // Global Functions
00058 //
00059 //****************************************************************************
00060
00061 HRESULT InitConfMgr(void);
00062 VOID FreeConfMgr(void);
00063 INmConference * GetCurrentConference(void);
00064 VOID DumpSysInfo(void);
00065 VOID DumpLaunchInfo(void);
00066
00067 VOID SysLogOnOff(int iDirection);
00068
00069
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

HelloJ Member List

This is the complete list of members for HelloJ, including all inherited members.
destroy() | HelloJ | [inline]
FALSE | HelloJ | [private]
getAppletInfo() | HelloJ | [inline]
HelloJ() | HelloJ | [inline]
init() | HelloJ | [inline]
m_AgentEx | HelloJ | [private]
m_Character | HelloJ | [private]
m_CharacterID | HelloJ | [private]
m_CharacterPathOld | HelloJ | [private]
m_RequestID | HelloJ | [private]
paint(Graphics g) | HelloJ | [inline]
start() | HelloJ | [inline]
stop() | HelloJ | [inline]
TRUE | HelloJ | [private]
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/cpack.cpp Source File

  • Web
  • bits
  • Upload

cpack.cpp

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  cpack.cpp
00011 //
00012 //  Purpose:
00013 //  This module implements the CPack class, which is
00014 //  the main class in this sample's code.
00015 //
00016 //  CPack receives the text entered in the UI edit box, and packs it as
00017 //  a simple XML file. It then creates a BITS upload job, sets all
00018 //  the relevant properties, and kicks off the upload process (Job->Resume()).
00019 //
00020 //  The main method implemented by this class is CPack::Upload(), which
00021 //  takes care of creating the upload Job and therefore exemplifies how
00022 //  the BITS upload API may be used to upload a file to a web server.
00023 //
00024 //----------------------------------------------------------------------------
00025
00026
00027
00028 #include <windows.h>
00029 #include <crtdbg.h>
00030 #include <strsafe.h>
00031 #include <wininet.h>
00032 #include <bits.h>
00033
00034 #include "main.h"
00035 #include "util.h"
00036 #include "cpack.h"
00037 #include "cmonitor.h"
00038
00039
00040 // Forward prototype for UrlCombine(). The header shlwapi.h is installed with the IE SDK, but not with the Core SDK.
00041 // If you have installed the IE SDK in addition to the Core SDK, you may remove the line below.
00042 EXTERN_C HRESULT STDAPICALLTYPE UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, LPWSTR pszCombined, LPDWORD pcchCombined, DWORD dwFlags);
00043 #ifndef URL_ESCAPE_UNSAFE
00044 #define URL_ESCAPE_UNSAFE               0x20000000
00045 #endif
00046
00047 CPack::CPack()
00048 {
00049     m_hFile = INVALID_HANDLE_VALUE;
00050     memset(m_wszTempFile, 0, sizeof(m_wszTempFile));
00051     m_pwszFilename = NULL;
00052 }
00053
00054 CPack::~CPack()
00055 {
00056     if (m_hFile != INVALID_HANDLE_VALUE)
00057     {
00058         CloseHandle(m_hFile);
00059     }
00060 }
00061
00062 //----------------------------------------------------------------------------
00063 // CPack public methods
00064 //----------------------------------------------------------------------------
00065
00066
00067 HRESULT CPack::Upload(LPCWSTR wszJobName, LPCWSTR wszUploadDir, BOOL fRequestReply)
00068 {
00069     GUID         guid;
00070     BG_JOB_TYPE  jobtype;
00071     HRESULT      hr;
00072     CSmartComPtr<IBackgroundCopyJob> Job;
00073     WCHAR        wszRemoteUrl[INTERNET_MAX_URL_LENGTH] = {0};
00074
00075     //
00076     // Prepare the remote URL name
00077     // No attempt is made to check the URL that was given by the user
00078     //
00079     hr = BuildRemoteUrl(wszUploadDir, m_pwszFilename, wszRemoteUrl, sizeof(wszRemoteUrl));
00080     if (FAILED(hr))
00081     {
00082         DisplayErrorMessage(L"Failed to build the remote URL for the upload job. \n"
00083                             L"Please verify that the URL given for the upload virtual directory is valid.", hr);
00084         goto cleanup;
00085     }
00086
00087     //
00088     // Set the BITS job type -- we are only interested in upload job types
00089     //
00090     if (fRequestReply)
00091     {
00092         jobtype = BG_JOB_TYPE_UPLOAD_REPLY;
00093     }
00094     else
00095     {
00096         jobtype = BG_JOB_TYPE_UPLOAD;
00097     }
00098
00099     //
00100     // Create an empty job with the BITS job manager
00101     // Note that even if the job name is not unique, we have a unique identifier (the returned guid value)
00102     //
00103     hr = g_JobManager->CreateJob(wszJobName, jobtype, &guid, &Job);
00104     if (FAILED(hr))
00105     {
00106         // handle the most common reason for the failure of this call
00107         if (hr == E_NOTIMPL)
00108         {
00109             DisplayErrorMessage(L"This application is not able to create a upload job with BITS.\n"
00110                                 L"It is likely that the reason for that is that BITS 1.5 runtime binaries \n"
00111                                 L"are not present in the system. Please see the file readme.htm installed \n"
00112                                 L"with this SDK sample for instructions on how to install BITS 1.5.", hr);
00113         }
00114         else
00115         {
00116             DisplayErrorMessage(L"Failed to create the BITS upload job.", hr);
00117         }
00118
00119         goto cleanup;
00120     }
00121
00122     g_pDialog->AddStatusMessage(L"Created a new BITS upload job. Job ID is %s.", ConvertGuidToString(guid));
00123
00124     //
00125     // Add a file to the job. This is the file that will be uploaded.
00126     //
00127     hr = Job->AddFile(wszRemoteUrl, m_wszTempFile);
00128     if (FAILED(hr))
00129     {
00130         DisplayErrorMessage(L"Failed to add file to the BITS upload job.", hr);
00131         goto cleanup;
00132     }
00133
00134     g_pDialog->AddStatusMessage(L"Added a file to the job. (Job ID %s)", ConvertGuidToString(guid));
00135
00136     //
00137     // Set the no-progress timeout value to be 60 seconds. The default, if we don't set it, is 14 days.
00138     // We want to set this to a small value so that transient errors will fall back to errors quickly.
00139     //
00140     // The idea here is that we are using this app to test and experiment with the BITS API in a
00141     // controlled environment, so it is reasonable to assume that the server and network are readily
00142     // accessible, and if not, we want to be notified of the problem quickly. We could have also
00143     // set NoProgressTimeout to zero.
00144     //
00145     // In a real app, it is better to leverage BITS' ability to retry jobs that are in transient error,
00146     // because sporadic network connectivity problems are indeed common, specially for file transfers
00147     // across the Internet. For this to happen, the job timeout has to be greater than 2 min, otherwise
00148     // BITS will not attempt retries.
00149     //
00150     hr = Job->SetNoProgressTimeout(60);
00151     if (FAILED(hr))
00152     {
00153         DisplayErrorMessage(L"Failed to set the timeout value for transient errors.", hr);
00154         goto cleanup;
00155     }
00156
00157     //
00158     // Kick off the job!!
00159     //
00160     hr = Job->Resume();
00161     if (FAILED(hr))
00162     {
00163         DisplayErrorMessage(L"Failed to resume the BITS upload job.", hr);
00164         goto cleanup;
00165     }
00166
00167     g_pDialog->AddStatusMessage(L"Upload job activated. (Job ID %s)", ConvertGuidToString(guid));
00168
00169     //
00170     // Make sure we receive notifications for the status of the job,
00171     // so we can call Job->Complete() and have the job effectively uploaded
00172     //
00173     hr = Job->SetNotifyInterface(&g_NotificationReceiver);
00174     if (FAILED(hr))
00175     {
00176         DisplayErrorMessage(L"Failed to set a notification callback.", hr);
00177         goto cleanup;
00178     }
00179
00180     //
00181     // Well, ideally we just want to wait for JOB_TRANSFERRED, but errors
00182     // might happen so we want to act upon those as well
00183     //
00184     hr = Job->SetNotifyFlags(BG_NOTIFY_JOB_TRANSFERRED | BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_MODIFICATION);
00185     if (FAILED(hr))
00186     {
00187         DisplayErrorMessage(L"Failed to set a notification callback.", hr);
00188         goto cleanup;
00189     }
00190
00191 cleanup:
00192
00193     return hr;
00194 }
00195
00196
00197 HRESULT CPack::PackText(LPCWSTR wszText)
00198 {
00199     HRESULT hr = S_OK;
00200     WCHAR wszXMLTemplateStart[] = L""
00201         L"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n"
00202         L"<uploadsample>\r\n"
00203         L"  <text>";
00204     WCHAR wszXMLTemplateEnd[] = L""
00205         L"</text>\r\n"
00206         L"</uploadsample>\r\n";
00207
00208     hr = OpenTempFile();
00209     if (FAILED(hr))
00210     {
00211         goto cleanup;
00212     }
00213
00214     hr = WriteWCharAsUTF8(wszXMLTemplateStart);
00215     if (FAILED(hr))
00216     {
00217         goto cleanup;
00218     }
00219
00220     // we don't need to write anything if we weren't given any text
00221     if (wcslen(wszText) > 0)
00222     {
00223         hr = WriteXMLString(wszText);
00224         if (FAILED(hr))
00225         {
00226             goto cleanup;
00227         }
00228     }
00229
00230     hr = WriteWCharAsUTF8(wszXMLTemplateEnd);
00231     if (FAILED(hr))
00232     {
00233         goto cleanup;
00234     }
00235
00236     g_pDialog->AddStatusMessage(L"Packed edit box text in the temporary file %s", m_wszTempFile);
00237
00238 cleanup:
00239
00240     CloseTempFile();
00241
00242     return hr;
00243 }
00244
00245 LPCWSTR CPack::GetFileName()
00246 {
00247     return m_wszTempFile;
00248 }
00249
00250
00251 //----------------------------------------------------------------------------
00252 // CPack private methods
00253 //----------------------------------------------------------------------------
00254
00255
00256 HRESULT CPack::BuildRemoteUrl(IN LPCWSTR wszUploadDir, IN LPCWSTR wszTempFile, OUT WCHAR *wszRemoteUrl, DWORD cbRemoteUrl)
00257 {
00258     HRESULT hr;
00259     DWORD   cchRemoteUrl = (cbRemoteUrl/sizeof(WCHAR)) - 1; // this count shouldn't contain the NULL caracter
00260     WCHAR   wszXmlExt[]  = L".xml";
00261     WCHAR  *pStart       = NULL;
00262     WCHAR  *pEnd         = NULL;
00263
00264     _ASSERT(wszRemoteUrl != NULL);
00265     _ASSERT((cbRemoteUrl == (INTERNET_MAX_URL_LENGTH*sizeof(WCHAR))));
00266
00267     // clear the buffer
00268     memset(wszRemoteUrl, 0, cbRemoteUrl);
00269
00270     // use the same filename as the temp file, and use the URL for the upload virtual directory
00271     // that was given by the user
00272     hr = UrlCombineW(wszUploadDir, m_pwszFilename, wszRemoteUrl, &cchRemoteUrl, URL_ESCAPE_UNSAFE);
00273     if (FAILED(hr))
00274     {
00275         goto cleanup;
00276     }
00277
00278     // now change the extension
00279     pStart = wcsrchr(wszRemoteUrl, L'.');
00280     pEnd   = wszRemoteUrl + (cbRemoteUrl/sizeof(WCHAR)) - 1; // place the end at the last possible place for the \0.
00281
00282     // make sure we have space to write our extension
00283     if (pStart && (static_cast<size_t>((pEnd - pStart)) >= wcslen(wszXmlExt)))
00284     {
00285         hr = StringCchCopyW(pStart, (pEnd - pStart), wszXmlExt);
00286         if (FAILED(hr))
00287         {
00288             goto cleanup;
00289         }
00290     }
00291     else
00292     {
00293         // should never happen
00294         hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00295     }
00296
00297 cleanup:
00298
00299     return hr;
00300 }
00301
00302
00303 HRESULT CPack::OpenTempFile()
00304 {
00305     HRESULT hr = S_OK;
00306     WCHAR   wszTempDir[MAX_PATH+1] = {0};
00307     DWORD   dwLen = 0;
00308
00309
00310     dwLen = GetTempPathW(MAX_PATH, wszTempDir);
00311     if (dwLen == 0)
00312     {
00313         hr = HRESULT_FROM_WIN32(GetLastError());
00314         goto cleanup;
00315     }
00316
00317     if (dwLen > MAX_PATH)
00318     {
00319         hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
00320         goto cleanup;
00321     }
00322
00323     if (!GetTempFileName(
00324         wszTempDir,           // dir. for temp. files
00325         L"upl",               // temp. file name prefix
00326         0,                    // create unique name
00327         m_wszTempFile))       // buffer for name
00328     {
00329         hr = HRESULT_FROM_WIN32(GetLastError());
00330         goto cleanup;
00331     }
00332
00333     // Get The filename part
00334     m_pwszFilename = wcsrchr(m_wszTempFile, L'\\');
00335     if (!m_pwszFilename)
00336     {
00337         hr = HRESULT_FROM_WIN32(ERROR_INVALID_NAME);
00338         goto cleanup;
00339     }
00340     m_pwszFilename++;
00341
00342     m_hFile = CreateFile(
00343         m_wszTempFile,                // file name
00344         GENERIC_READ | GENERIC_WRITE, // open for read/write
00345         0,                            // do not share
00346         NULL,                         // no security
00347         CREATE_ALWAYS,                // overwrite existing file
00348         FILE_ATTRIBUTE_NORMAL,        // normal file
00349         NULL);                        // no attr. template
00350
00351     if (m_hFile == INVALID_HANDLE_VALUE)
00352     {
00353         hr = HRESULT_FROM_WIN32(GetLastError());
00354     }
00355
00356
00357 cleanup:
00358
00359     return hr;
00360 }
00361
00362 void CPack::CloseTempFile()
00363 {
00364     if (m_hFile != INVALID_HANDLE_VALUE)
00365     {
00366         CloseHandle(m_hFile);
00367         m_hFile = INVALID_HANDLE_VALUE;
00368     }
00369 }
00370
00371 HRESULT CPack::WriteWCharAsUTF8(LPCWSTR wszText, DWORD cCharsToWrite)
00372 {
00373     HRESULT hr              = S_OK;
00374     CHAR    *szBuf          = NULL;
00375     INT     cchBuf          = 0;
00376     INT     cchWritten      = 0;
00377     DWORD   cbWrittenToFile = 0;
00378
00379     _ASSERT(wszText != NULL);
00380     _ASSERT(cCharsToWrite > 0 && cCharsToWrite <= MAX_BUFFER_SIZE);
00381
00382     cchBuf  = (cCharsToWrite + 1) * 3;    // UTF-8 can convert one WCHAR into 3 bytes
00383
00384     szBuf = new CHAR[cchBuf];
00385     if (!szBuf)
00386     {
00387         hr = E_OUTOFMEMORY;
00388         goto cleanup;
00389     }
00390
00391     cchWritten = WideCharToMultiByte(CP_UTF8, 0, wszText, cCharsToWrite, szBuf, cchBuf, NULL, NULL);
00392     if (cchWritten == 0)   // function failed
00393     {
00394         hr = HRESULT_FROM_WIN32(GetLastError());
00395         goto cleanup;
00396     }
00397
00398     // null-terminate the string
00399     szBuf[cchWritten] = 0;
00400
00401     // write the string
00402     if (!WriteFile(m_hFile, szBuf, (cchWritten * sizeof(CHAR)), &cbWrittenToFile, NULL))
00403     {
00404         hr = HRESULT_FROM_WIN32(GetLastError());
00405         goto cleanup;
00406     }
00407
00408 cleanup:
00409
00410     if (szBuf)
00411     {
00412         delete [] szBuf;
00413         szBuf = NULL;
00414     }
00415
00416     return hr;
00417 }
00418
00419 HRESULT CPack::WriteWCharAsUTF8(LPCWSTR wszText)
00420 {
00421     return WriteWCharAsUTF8(wszText, static_cast<DWORD>(wcslen(wszText)));
00422 }
00423
00424 HRESULT CPack::WriteXMLString(LPCWSTR wszText)
00425 {
00426     WCHAR *pwszRemainder = NULL;
00427     WCHAR *pchSpecial    = NULL;
00428     WCHAR *pchEnd        = NULL;
00429     HRESULT hr = S_OK;
00430
00431     _ASSERT(wszText != NULL);
00432     INT   cchText        = static_cast<INT>(wcslen(wszText));
00433
00434     _ASSERT(cchText > 0 && cchText <= MAX_BUFFER_SIZE);
00435
00436     pwszRemainder = const_cast<WCHAR *>(wszText);
00437     pchSpecial    = wcsstr(wszText, L"<>&'\"");
00438     pchEnd        = (const_cast<WCHAR *>(wszText) + cchText);
00439
00440     while (pchSpecial)
00441     {
00442         if (pchSpecial > pwszRemainder)
00443         {
00444             hr = WriteWCharAsUTF8(pwszRemainder, static_cast<DWORD>((pchSpecial - pwszRemainder)));
00445             if (FAILED(hr))
00446             {
00447                 goto cleanup;
00448             }
00449         }
00450
00451         switch (*pchSpecial)
00452         {
00453             case L'<':   WriteWCharAsUTF8(L"&lt;");      break;
00454             case L'>':   WriteWCharAsUTF8(L"&gt;");      break;
00455             case L'&':   WriteWCharAsUTF8(L"&amp;");     break;
00456             case L'\'':  WriteWCharAsUTF8(L"&apos;");    break;
00457             case L'"':   WriteWCharAsUTF8(L"&quot;");    break;
00458
00459             default:
00460                 // should never get here
00461                 _ASSERT(0);
00462         }
00463
00464         pwszRemainder = pchSpecial + 1;
00465         pchSpecial = wcsstr(pwszRemainder, L"<>&'\"");
00466     }
00467
00468     if (pwszRemainder < pchEnd)
00469     {
00470         hr = WriteWCharAsUTF8(pwszRemainder, static_cast<DWORD>((pchEnd - pwszRemainder)));
00471         if (FAILED(hr))
00472         {
00473             goto cleanup;
00474         }
00475     }
00476
00477 cleanup:
00478
00479     return hr;
00480 }
00481
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/DspLogcl.Cpp Source File

  • WinUI
  • GlobalDev
  • CSSamp

DspLogcl.Cpp

Go to the documentation of this file.
00001 ////    DspLogcl - Display logical text
00002 //
00003 //      Shows logical characters and selection range in backing store order and fixed width.
00004
00005 #include "precomp.hxx"
00006 #include "global.h"
00007
00008 ////    DottedLine
00009 //
00010 //      Draws a horizontal or a vertical dotted line
00011 //
00012 //      Not the best algorithm.
00013 void DottedLine(HDC hdc, int x, int y, int dx, int dy)
00014 {
00015     SetPixel(hdc, x, y, 0);
00016
00017     if (dx)
00018     {
00019         // Horizontal line
00020         while (dx > 2)
00021         {
00022             x += 3;
00023             SetPixel(hdc, x, y, 0);
00024             dx -= 3;
00025         }
00026         x += dx;
00027         SetPixel(hdc, x, y, 0);
00028
00029     }
00030     else
00031     {
00032         // Vertical line
00033         while (dy > 2)
00034          {
00035             y += 3;
00036             SetPixel(hdc, x, y, 0);
00037             dy -= 3;
00038         }
00039         y += dy;
00040         SetPixel(hdc, x, y, 0);
00041     }
00042 }
00043
00044 ////    PaintLogical - Show characters in logical sequence
00045 //
00046 //      Display each glyph separately - override the default advance width
00047 //      processing to defeat any overlapping or combining action that the
00048 //      font performs with it's default ABC width.
00049 //
00050 //      To achieve this, we call ScriptGetGlyphABCWidth to obtain the
00051 //      leading side bearing (A), the black box width (B) and the trailing
00052 //      side bearing (C).
00053 //
00054 //      Since we can control only the advance width per glyph, we have to
00055 //      calulate suitable advance widths to override the affect of the
00056 //      ABC values in the font.
00057 //
00058 //      You should never normally need to call ScriptGetGlyphABCWidth.
00059 //
00060 //      PaintLogical has to implement a form of font fallback - Indian and
00061 //      Tamil scripts are not present in Microsoft Sans Serif, so we go
00062 //      directly to Mangal and Latha for characters in those Unicode ranges.
00063 void PaintLogical(
00064     HDC   hdc,
00065     int  *piY,
00066     RECT *prc,
00067     int   iLineHeight)
00068 {
00069     const int MAXBUF     = 100;
00070     const int CELLGAP    = 4;     // Pixels between adjacent glyphs
00071
00072     int   icpLineStart   = 0;     // First character of line
00073     int   icpLineEnd     = 0;     // End of line (end of buffer or index of CR character)
00074     int   icp            = 0;
00075     int   iLen           = 0;
00076     int   iPartLen       = 0;     // Part of string in a single font
00077     int   iPartX         = 0;
00078     int   iPartWidth     = 0;
00079     WORD  wGlyphBuf[MAXBUF];
00080     int   idx[MAXBUF];            // Force widths so all characters show
00081     BYTE  bFont[MAXBUF];          // Font used for each character
00082     ABC   abc[MAXBUF];
00083     int   iTotX          = 0;
00084     int   ildx           = 0;     // Overall line dx, adjusts for 'A' width of leading glyph
00085     int   iSliderX       = 0;
00086     int   iFont          = 0;     // 0 = Microsoft Sans Serif, 1 = Mangal, 2 = Latha
00087     RECT  rcClear        = {0};   // Clear each line before displaying it
00088
00089     // Selection highlighting
00090     bool  bHighlight     = TRUE;  // Current state of highlighting in the hdc
00091     int   iFrom          = 0;     // Selection range
00092     int   iTo            = 0;
00093     DWORD dwOldBkColor   = 0;
00094     DWORD dwOldTextColor = 0;
00095
00096     // Item analysis
00097
00098     SCRIPT_ITEM    items[MAXBUF];
00099     SCRIPT_CONTROL scriptControl = {0};
00100     SCRIPT_STATE   scriptState   = {0};
00101     INT            iItem         = 0;
00102
00103 #define NUMLOGICALFONTS 4
00104
00105     SCRIPT_CACHE sc[NUMLOGICALFONTS];
00106     HFONT        hf[NUMLOGICALFONTS];
00107     HFONT        hfold  = NULL;
00108     HRESULT      hr     = NULL;
00109
00110     SCRIPT_FONTPROPERTIES sfp = {0};
00111     BOOL         bMissing     = FALSE;
00112
00113     icpLineStart = 0;
00114
00115     hf[0]    = CreateFont(iLineHeight*7/10, 0, 0, 0, 0, 0, 0, 0, 1,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE|DEFAULT_PITCH, TEXT("Microsoft Sans Serif"));
00116     hf[1]    = CreateFont(iLineHeight*7/10, 0, 0, 0, 0, 0, 0, 0, 1,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE|DEFAULT_PITCH, TEXT("Mangal"));
00117     hf[2]    = CreateFont(iLineHeight*7/10, 0, 0, 0, 0, 0, 0, 0, 1,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE|DEFAULT_PITCH, TEXT("Latha"));
00118     hf[3]    = CreateFont(iLineHeight*7/20, 0, 0, 0, 0, 0, 0, 0, 1,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE|DEFAULT_PITCH, TEXT("Microsoft Sans Serif")); // For bidi level digits
00119     iFont    = 0;
00120     hfold    = (HFONT) SelectObject(hdc, hf[iFont]);
00121     ildx     = 0;
00122
00123     memset(sc, 0, sizeof(sc));
00124     bHighlight = FALSE;
00125
00126     INT iSliderHeight = g_fOverrideDx ? iLineHeight * 5 / 10 : 0;
00127     INT iLevelsHeight = g_fShowLevels ? iLineHeight * 8 / 20 : 0;
00128
00129     // Display line by line
00130     while (icpLineStart < g_iTextLen)
00131     {
00132         // Clear line before displaying it
00133         rcClear        = *prc;
00134         rcClear.top    = *piY;
00135         rcClear.bottom = *piY + iLineHeight + iSliderHeight + iLevelsHeight;
00136         FillRect(hdc, &rcClear, (HBRUSH) GetStockObject(WHITE_BRUSH));
00137
00138         // Find end of line or end of buffer
00139         icpLineEnd = icpLineStart;
00140         while (icpLineEnd < g_iTextLen  &&  g_wcBuf[icpLineEnd] != 0x0D)
00141         {
00142             icpLineEnd++;
00143         }
00144
00145         if (icpLineEnd - icpLineStart > MAXBUF)
00146         {
00147             iLen = MAXBUF;
00148         }
00149         else
00150         {
00151             iLen = icpLineEnd - icpLineStart;
00152         }
00153
00154         // Obtain item analysis
00155         scriptControl = g_ScriptControl;
00156         scriptState   = g_ScriptState;
00157         ScriptItemize(g_wcBuf+icpLineStart, iLen, MAXBUF, &scriptControl, &scriptState, items, NULL);
00158
00159         // Determine font and glyph index for each codepoint
00160         if (iFont != 0)        // Start with Microsoft Sans Serif
00161         {
00162             iFont = 0;
00163             SelectObject(hdc, hf[0]);
00164         }
00165
00166         hr = ScriptGetCMap(hdc, &sc[iFont], g_wcBuf+icpLineStart, iLen, 0, wGlyphBuf);
00167         if (SUCCEEDED(hr))
00168         {
00169             memset(bFont, 0, iLen);
00170             if (hr != S_OK)
00171             {
00172                // Some characters were not in Microsoft Sans Serif
00173                 sfp.cBytes = sizeof(sfp);
00174                 ScriptGetFontProperties(hdc, &sc[iFont], &sfp);
00175
00176                 bMissing = FALSE;
00177                 for (icp=0; icp<iLen; icp++)
00178                 {
00179                     if (wGlyphBuf[icp] == sfp.wgDefault)
00180                     {
00181                         bFont[icp] = 1;
00182                         bMissing = TRUE;
00183                     }
00184                 }
00185
00186                 // Try other fonts
00187                 while (bMissing  &&  iFont < 2)
00188                 {
00189                     iFont++;
00190                     SelectObject(hdc, hf[iFont]);
00191                     ScriptGetFontProperties(hdc, &sc[iFont], &sfp);
00192                     bMissing = FALSE;
00193                     for (icp=0; icp<iLen; icp++)
00194                     {
00195                         if (bFont[icp] == iFont)
00196                         {
00197                             ScriptGetCMap(hdc, &sc[iFont], g_wcBuf+icpLineStart+icp, 1, 0, wGlyphBuf+icp);
00198                             if (wGlyphBuf[icp] == sfp.wgDefault)
00199                             {
00200                                 bFont[icp] = (BYTE)(iFont+1);
00201                                 bMissing = TRUE;
00202                             }
00203                         }
00204                     }
00205                 }
00206
00207                 if (bMissing)
00208                 {
00209                     // Remaining missing characters come from font 0
00210                     for (icp=0; icp<iLen; icp++)
00211                     {
00212                         if (bFont[icp] >= NUMLOGICALFONTS)
00213                         {
00214                             bFont[icp] = 0;
00215                         }
00216                     }
00217                 }
00218             }
00219
00220             // Display each glyphs black box next to the previous. Override the
00221             // default ABC behaviour.
00222             idx[0] = 0;
00223             for (icp=0; icp<iLen; icp++)
00224             {
00225                 if (iFont != bFont[icp])
00226                 {
00227                     iFont = bFont[icp];
00228                     SelectObject(hdc, hf[iFont]);
00229                 }
00230
00231                 ScriptGetGlyphABCWidth(hdc, &sc[iFont], wGlyphBuf[icp], &abc[icp]);
00232
00233                 if (g_wcBuf[icpLineStart+icp] == TCHAR(' '))
00234                 {
00235                     // Treat entire space as black
00236                     abc[icp].abcB += abc[icp].abcA;   abc[icp].abcA = 0;
00237                     abc[icp].abcB += abc[icp].abcC;   abc[icp].abcC = 0;
00238                 }
00239
00240                 // Glyph black box width is abc.abcB
00241                 // We'd like the glyph to appear 2 pixels to the right of the
00242                 // previous glyph.
00243                 //
00244                 // The default placement of left edge is abc.abcA.
00245                 //
00246                 // Therefore we need to shift this character to the right by
00247                 // 2 - abc.abcA to get it positioned correctly. We do this by
00248                 // updating the advance width for the previous character.
00249                 if (!icp)
00250                 {
00251                     ildx = CELLGAP/2 - abc[icp].abcA;
00252                 }
00253                 else
00254                 {
00255                     idx[icp-1] += CELLGAP - abc[icp].abcA;
00256                 }
00257
00258                 // Now adjust the advance width for this character to take us to
00259                 // the right edge of it's black box.
00260                 idx[icp] = abc[icp].abcB + abc[icp].abcA;
00261             }
00262
00263             // Support selection range specified in either direction
00264             if (g_iFrom <= g_iTo)
00265             {
00266                 iFrom = g_iFrom - icpLineStart;
00267                 iTo   = g_iTo   - icpLineStart;
00268             }
00269             else
00270             {
00271                 iFrom = g_iTo   - icpLineStart;
00272                 iTo   = g_iFrom - icpLineStart;
00273             }
00274
00275             // Display glyphs in their appropriate fonts
00276             icp = 0;
00277             iPartX = prc->left+ildx;
00278
00279             while (icp < iLen)
00280             {
00281                 if (iFont != bFont[icp])
00282                 {
00283                     iFont = bFont[icp];
00284                     SelectObject(hdc, hf[iFont]);
00285                 }
00286
00287                 // Set selection highlighting at start
00288                 if (    icp >= iFrom
00289                     &&  icp < iTo
00290                     &&  !bHighlight)
00291                 {
00292                     // Turn on highlighting
00293                     dwOldBkColor   = SetBkColor(hdc,   GetSysColor(COLOR_HIGHLIGHT));
00294                     dwOldTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
00295                     bHighlight = TRUE;
00296
00297                 }
00298                 else if (    (    icp < iFrom
00299                                 ||  icp >= iTo)
00300                            &&  bHighlight)
00301                 {
00302                     // Turn off highlighting
00303                     SetBkColor(hdc, dwOldBkColor);
00304                     SetTextColor(hdc, dwOldTextColor);
00305                     bHighlight = FALSE;
00306                 }
00307
00308                 // Find longest run from a single font, and
00309                 // without change of highlighting.
00310
00311                 iPartLen   = 0;
00312                 iPartWidth = 0;
00313
00314                 while (    icp+iPartLen < iLen
00315                        &&  iFont == bFont[icp+iPartLen]
00316                        &&  bHighlight == (icp+iPartLen >= iFrom && icp+iPartLen < iTo))
00317                 {
00318                     iPartWidth += idx[icp+iPartLen];
00319                     iPartLen++;
00320                 }
00321
00322                 // Display single font, single highlighting
00323                 ExtTextOutW(hdc,
00324                     iPartX,
00325                     *piY+2,
00326                     ETO_CLIPPED | ETO_GLYPH_INDEX,
00327                     prc,
00328                     wGlyphBuf+icp,
00329                     iPartLen,
00330                     idx+icp);
00331
00332                 icp    += iPartLen;
00333                 iPartX += iPartWidth;
00334             }
00335
00336             // Mark the cells to make the characters stand out clearly
00337             MoveToEx(hdc, prc->left, *piY, NULL);
00338             LineTo(hdc,   prc->left, *piY + iLineHeight*3/4);
00339
00340             iTotX = 0;
00341
00342             for (icp=0; icp<iLen; icp++)
00343             {
00344                 iTotX += abc[icp].abcB + CELLGAP;
00345                 idx[icp] = iTotX;   // Record cell position for mouse hit testing
00346                 DottedLine(hdc, prc->left + iTotX, *piY, 0, iLineHeight*3/4);
00347
00348                 // Add slider for OverridedDx control
00349                 if (g_fOverrideDx)
00350                 {
00351                     iSliderX = prc->left + (icp==0 ? idx[0]/2 : (idx[icp-1] + idx[icp])/2);
00352
00353                     // Draw the axis of the slider
00354                     DottedLine(hdc, iSliderX, *piY + iLineHeight*35/40, 0, iSliderHeight*35/40);
00355
00356                     // Draw the knob
00357                     if (g_iWidthBuf[icpLineStart + icp] < iSliderHeight)
00358                     {
00359                         MoveToEx(hdc, iSliderX-2, *piY + iLineHeight*35/40 + iSliderHeight*35/40 - g_iWidthBuf[icpLineStart + icp], NULL);
00360                         LineTo  (hdc, iSliderX+3, *piY + iLineHeight*35/40 + iSliderHeight*35/40 - g_iWidthBuf[icpLineStart + icp]);
00361                     }
00362                     else
00363                     {
00364                         MoveToEx(hdc, iSliderX-2, *piY + iLineHeight*35/40, NULL);
00365                         LineTo  (hdc, iSliderX+3, *piY + iLineHeight*35/40);
00366                     }
00367                 }
00368             }
00369
00370             MoveToEx(hdc, prc->left + iTotX, *piY, NULL);
00371             LineTo(hdc,   prc->left + iTotX, *piY + iLineHeight*30/40);
00372
00373             MoveToEx(hdc, prc->left, *piY, NULL);
00374             LineTo(hdc,   prc->left + iTotX, *piY);
00375             MoveToEx(hdc, prc->left, *piY + iLineHeight*30/40, NULL);
00376             LineTo(hdc,   prc->left + iTotX, *piY + iLineHeight*30/40);
00377
00378             if (g_fShowLevels)
00379             {
00380                 // Display bidi levels for each codepoint
00381                 iItem = 0;
00382                 iFont = 3;
00383                 SelectObject(hdc, hf[3]);
00384
00385                 for (icp=0; icp<iLen; icp++)
00386                 {
00387                     if (icp == items[iItem+1].iCharPos)
00388                     {
00389                         iItem++;
00390
00391                         // Draw a vertical line to mark the item boundary
00392                         MoveToEx(hdc, prc->left + idx[icp-1], *piY + iLineHeight*35/40 + iSliderHeight, NULL);
00393                         LineTo(  hdc, prc->left + idx[icp-1], *piY + iLineHeight*35/40 + iSliderHeight + iLevelsHeight*35/40);
00394                     }
00395
00396                     // Establish where horizontally to display the digit
00397
00398                     char chDigit = char('0' + items[iItem].a.s.uBidiLevel);
00399                     int digitWidth = 0;
00400                     GetCharWidth32A(hdc, chDigit, chDigit, &digitWidth);
00401
00402                     ExtTextOutA(
00403                         hdc,
00404                         prc->left + (icp==0 ? idx[0]/2 : (idx[icp-1] + idx[icp])/2) - digitWidth / 2,
00405                         *piY + iLineHeight*35/40 + iSliderHeight,
00406                         0,
00407                         NULL,
00408                         &chDigit,
00409                         1,
00410                         NULL);
00411                 }
00412             }
00413
00414             // Check whether mouse clicks in this line are waiting to be processed
00415             if (    g_fOverrideDx
00416                 &&  g_fMouseUp  &&  g_iMouseUpY > *piY + iLineHeight*33/40  &&  g_iMouseUpY < *piY + iLineHeight*63/40)
00417             {
00418                 // Procss change to DX override slider
00419                 icp = 0;
00420                 while (icp<iLen  &&  prc->left + idx[icp] < g_iMouseUpX)
00421                 {
00422                     icp++;
00423                 }
00424
00425                 g_iWidthBuf[icpLineStart+icp] = *piY + 60 - g_iMouseUpY; // Adjust this slider
00426                 InvalidateText();   // Force slider to redraw at new position
00427                 g_fMouseDown = FALSE;
00428                 g_fMouseUp   = FALSE;
00429                 g_iFrom = icpLineStart+icp;
00430                 g_iTo   = icpLineStart+icp;
00431
00432
00433             }
00434             else if (g_fMouseDown  &&  g_iMouseDownY > *piY  &&  g_iMouseDownY < *piY+iLineHeight)
00435             {
00436                 // Handle text selection
00437
00438                 // Record char pos at left button down
00439                 // Snap mouse hit to closest character boundary
00440                 if (g_iMouseDownX < prc->left + idx[0]/2)
00441                 {
00442                     icp = 0;
00443                 }
00444                 else
00445                 {
00446                     icp = 1;
00447                     while (    icp < iLen
00448                            &&  g_iMouseDownX > prc->left + (idx[icp-1] + idx[icp]) / 2)
00449                     {
00450                         icp++;
00451                     }
00452                 }
00453
00454                 g_iFrom = icp + icpLineStart;
00455
00456                 if (g_iFrom < icpLineStart)
00457                 {
00458                     g_iFrom = icpLineStart;
00459                 }
00460                 if (g_iFrom > icpLineEnd)
00461                 {
00462                     g_iFrom = icpLineEnd;
00463                 }
00464                 g_fMouseDown = FALSE;
00465             }
00466
00467             if (g_fMouseUp  &&  g_iMouseUpY > *piY  &&  g_iMouseUpY < *piY+iLineHeight)
00468             {
00469                 // Complete selection processing
00470                 if (g_iMouseUpX < prc->left + idx[0]/2)
00471                 {
00472                     icp = 0;
00473                 }
00474                 else
00475                 {
00476                     icp = 1;
00477                     while (    icp < iLen
00478                            &&  g_iMouseUpX > prc->left + (idx[icp-1] + idx[icp]) / 2)
00479                     {
00480                         icp++;
00481                     }
00482                 }
00483                 g_iTo = icp + icpLineStart;
00484
00485                 if (g_iTo < icpLineStart)
00486                 {
00487                     g_iTo = icpLineStart;
00488                 }
00489                 if (g_iTo > icpLineEnd)
00490                 {
00491                     g_iTo = icpLineEnd;
00492                 }
00493
00494                 // Caret is where mouse was raised
00495                 g_iCurChar = g_iTo;
00496                 g_iCaretSection = CARET_SECTION_LOGICAL;  // Show caret in logical text
00497                 g_fUpdateCaret = TRUE;
00498
00499                 g_fMouseUp = FALSE;     // Signal that the mouse up is processed
00500
00501             }
00502
00503             if (    g_fUpdateCaret
00504                 &&  g_iCurChar >= icpLineStart
00505                 &&  g_iCurChar <= icpLineEnd
00506                 &&  g_iCaretSection == CARET_SECTION_LOGICAL)
00507             {
00508                 g_fUpdateCaret = FALSE;
00509                 if (g_iCurChar <= icpLineStart)
00510                 {
00511                     ResetCaret(prc->left, *piY, iLineHeight);
00512                 }
00513                 else
00514                 {
00515                     ResetCaret(prc->left + idx[g_iCurChar - icpLineStart - 1], *piY, iLineHeight);
00516                 }
00517             }
00518
00519
00520         }
00521         else
00522         {
00523             // ScriptGetCMap failed - therefore this is not a glyphable font.
00524             // This could indicate
00525             //      A printer device font
00526             //      We're running on FE Win95 which cannot handle glyph indices
00527             //
00528             // For the sample app, we know we are using a glyphable Truetype font
00529             // on a screen DC, so it must mean the sample is running on a Far
00530             // East version of Windows 95.
00531             // Theoretically we could go to the trouble of calling
00532             // WideCharToMultiByte and using the 'A' char interfaces to
00533             // implement DspLogcl.
00534             // However this is only a sample program - DspPlain and DspFormt
00535             // work correctly, but there's no advantage in implementing
00536             // DspLogcl so well.
00537             // Display an apology.
00538
00539             ExtTextOutA(hdc, prc->left+2, *piY+2, ETO_CLIPPED, prc, "Sorry, no logical text display on Far East Windows 95.", 54, NULL);
00540             icpLineEnd = g_iTextLen;  // Hack to stop display of subsequent lines
00541         }
00542
00543         *piY += iLineHeight + iSliderHeight + iLevelsHeight;
00544
00545         // Advance to next line
00546         if (g_fPresentation)
00547         {
00548             icpLineStart = g_iTextLen;  // Only show one line in presentation mode
00549         }
00550         else
00551         {
00552             if (icpLineEnd < g_iTextLen)
00553             {
00554                 icpLineEnd++;
00555             }
00556             if (icpLineEnd < g_iTextLen  &&  g_wcBuf[icpLineEnd] == 0x0A)
00557             {
00558                 icpLineEnd++;
00559             }
00560             icpLineStart = icpLineEnd;
00561         }
00562     }
00563
00564     SelectObject(hdc, hfold);
00565
00566     if (bHighlight)
00567     {
00568         // Turn off highlighting
00569         SetBkColor(hdc, dwOldBkColor);
00570         SetTextColor(hdc, dwOldTextColor);
00571         bHighlight = FALSE;
00572     }
00573
00574     for (iFont=0; iFont<NUMLOGICALFONTS; iFont++)
00575     {
00576         DeleteObject(hf[iFont]);
00577         if (sc[iFont])
00578         {
00579             ScriptFreeCache(&sc[iFont]);
00580         }
00581     }
00582 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tag_keyframe Member List

This is the complete list of members for tag_keyframe, including all inherited members.
rbControl | tag_keyframe
rbProgram | tag_keyframe
rbTempo | tag_keyframe
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/PropTag.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

PropTag.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       proptag.cxx
00006 //
00007 //  Contents:   Generic parsing algorithm for property tags, such as title and headings
00008 //
00009 //  Classes:    CPropertyTag
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <proptag.hxx>
00017 #include <htmlguid.hxx>
00018 #include <ntquery.h>
00019
00020 //+-------------------------------------------------------------------------
00021 //
00022 //  Method:     CPropertyTag::CPropertyTag
00023 //
00024 //  Synopsis:   Constructor
00025 //
00026 //  Arguments:  [htmlIFilter]  -- Reference to Html filter
00027 //              [serialStream] -- Reference to input stream
00028 //              [propSpec]     -- Property spec
00029 //              [eTokType]     -- Token corresponding to this property
00030 //
00031 //--------------------------------------------------------------------------
00032
00033 CPropertyTag::CPropertyTag( CHtmlIFilter& htmlIFilter,
00034                             CSerialStream& serialStream,
00035                             CFullPropSpec& propSpec,
00036                             HtmlTokenType eTokType )
00037     : CHtmlElement(htmlIFilter, serialStream),
00038       _eState(NoMoreProperty),
00039       _ulIdContentChunk(0),
00040       _pwcPropBuf(0),
00041       _uLenPropBuf(0),
00042       _cPropChars(0),
00043       _cPropCharsFiltered(0),
00044       _propSpec(propSpec),
00045       _eTokType(eTokType)
00046 {
00047 }
00048
00049
00050
00051 //+-------------------------------------------------------------------------
00052 //
00053 //  Method:     CPropertyTag::~CPropertyTag
00054 //
00055 //  Synopsis:   Destructor
00056 //
00057 //--------------------------------------------------------------------------
00058
00059 CPropertyTag::~CPropertyTag()
00060 {
00061     delete[] _pwcPropBuf;
00062 }
00063
00064
00065
00066
00067 //+-------------------------------------------------------------------------
00068 //
00069 //  Method:     CPropertyTag::GetChunk
00070 //
00071 //  Synopsis:   Gets the next chunk and returns chunk information in pStat
00072 //
00073 //  Arguments:  [pStat] -- chunk information returned here
00074 //
00075 //--------------------------------------------------------------------------
00076
00077 SCODE CPropertyTag::GetChunk( STAT_CHUNK * pStat )
00078 {
00079     switch ( _eState )
00080     {
00081     case FilteringContent:
00082     case FilteringProperty:
00083     case FilteringPropertyButContentNotFiltered:
00084     {
00085         SCODE sc = SkipRemainingTextAndGotoNextChunk( pStat );
00086
00087         return sc;
00088     }
00089
00090     case NoMoreContent:
00091         _eState = FilteringProperty;
00092
00093         pStat->idChunk = _htmlIFilter.GetNextChunkId();
00094         pStat->locale = _htmlIFilter.GetLocale();
00095         pStat->cwcStartSource = 0;
00096         pStat->cwcLenSource = 0;
00097         pStat->flags = CHUNK_TEXT;
00098         pStat->attribute.guidPropSet = _propSpec.GetPropSet();
00099
00100         Win4Assert( _propSpec.IsPropertyPropid() );
00101
00102         pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00103         pStat->attribute.psProperty.propid = _propSpec.GetPropertyPropid();
00104         pStat->idChunkSource = _ulIdContentChunk;
00105         pStat->breakType = CHUNK_EOS;
00106
00107         break;
00108
00109     case NoMoreProperty:
00110     {
00111         //
00112         // Skip over the end property tag
00113         //
00114         _scanner.EatTag();
00115
00116         SCODE sc = SwitchToNextHtmlElement( pStat );
00117
00118         return sc;
00119     }
00120
00121     default:
00122         Win4Assert( !"Unknown _eState in CPropertyTag::GetChunk" );
00123         htmlDebugOut(( DEB_ERROR, "CPropertyTag::GetChunk, unkown property tag state: %d\n", _eState ));
00124     }
00125
00126     return S_OK;
00127 }
00128
00129
00130
00131 //+-------------------------------------------------------------------------
00132 //
00133 //  Method:     CPropertyTag::GetText
00134 //
00135 //  Synopsis:   Retrieves text from current chunk
00136 //
00137 //  Arguments:  [pcwcBuffer] -- count of UniCode characters in buffer
00138 //              [awcBuffer]  -- buffer for text
00139 //
00140 //--------------------------------------------------------------------------
00141
00142 SCODE CPropertyTag::GetText( ULONG *pcwcOutput, WCHAR *awcBuffer )
00143 {
00144     switch ( _eState )
00145     {
00146     case NoMoreContent:
00147     case NoMoreProperty:
00148          return FILTER_E_NO_MORE_TEXT;
00149
00150     case FilteringContent:
00151     case FilteringPropertyButContentNotFiltered:
00152     {
00153         ULONG cCharsRead = 0;
00154         while ( cCharsRead < *pcwcOutput )
00155         {
00156             ULONG cCharsScanned;
00157             ULONG cCharsNeeded = *pcwcOutput - cCharsRead;
00158             CToken token;
00159             _scanner.GetBlockOfChars( cCharsNeeded,
00160                                       awcBuffer + cCharsRead,
00161                                       cCharsScanned,
00162                                       token );
00163
00164             cCharsRead += cCharsScanned;
00165             if ( cCharsScanned == cCharsNeeded )
00166             {
00167                 //
00168                 // We've read the #chars requested by user
00169                 //
00170                 break;
00171             }
00172
00173             HtmlTokenType eTokType = token.GetTokenType();
00174             if ( eTokType == EofToken || eTokType == _eTokType )
00175             {
00176                 //
00177                 // End of file or end property tag
00178                 //
00179                 if ( _eState == FilteringContent )
00180                     _eState = NoMoreContent;
00181                 else
00182                     _eState = NoMoreProperty;
00183
00184                 break;
00185             }
00186             else if ( eTokType == BreakToken )
00187             {
00188                 //
00189                 // Insert a newline char
00190                 //
00191                 Win4Assert( cCharsRead < *pcwcOutput );
00192                 awcBuffer[cCharsRead++] = L'\n';
00193                 _scanner.EatTag();
00194             }
00195             else
00196             {
00197                 //
00198                 // Uninteresting tag, so skip over tag and continue processing
00199                 //
00200                 _scanner.EatTag();
00201             }
00202         }
00203
00204         //
00205         // Keep a copy of property in our internal buffer
00206         //
00207         if ( cCharsRead > 0 )
00208             ConcatenateProperty( awcBuffer, cCharsRead );
00209
00210         *pcwcOutput = cCharsRead;
00211
00212         if ( _eState == NoMoreContent || _eState == NoMoreProperty )
00213             return FILTER_S_LAST_TEXT;
00214         else
00215             return S_OK;
00216
00217         break;
00218     }
00219
00220
00221     case FilteringProperty:
00222     {
00223         ULONG cCharsRemaining = _cPropChars - _cPropCharsFiltered;
00224
00225         if ( cCharsRemaining == 0 )
00226         {
00227             _eState = NoMoreProperty;
00228             return FILTER_E_NO_MORE_TEXT;
00229         }
00230
00231         if ( *pcwcOutput < cCharsRemaining )
00232         {
00233             RtlCopyMemory( awcBuffer,
00234                            _pwcPropBuf + _cPropCharsFiltered,
00235                            *pcwcOutput * sizeof(WCHAR) );
00236             _cPropCharsFiltered += *pcwcOutput;
00237
00238             return S_OK;
00239         }
00240         else
00241         {
00242             RtlCopyMemory( awcBuffer,
00243                            _pwcPropBuf + _cPropCharsFiltered,
00244                            cCharsRemaining * sizeof(WCHAR) );
00245             _cPropCharsFiltered += cCharsRemaining;
00246             *pcwcOutput = cCharsRemaining;
00247             _eState = NoMoreProperty;
00248
00249             return FILTER_S_LAST_TEXT;
00250         }
00251
00252         break;
00253     }
00254
00255     default:
00256         Win4Assert( !"Unknown value of _eState" );
00257         htmlDebugOut(( DEB_ERROR,
00258                        "CPropertyTag::GetText, unknown value of _eState: %d\n",
00259                        _eState ));
00260         return S_OK;
00261     }
00262 }
00263
00264
00265
00266 //+-------------------------------------------------------------------------
00267 //
00268 //  Method:     CPropertyTag::InitStatChunk
00269 //
00270 //  Synopsis:   Initializes the STAT_CHUNK as part of a GetChunk call
00271 //
00272 //  Arguments:  [pStat] -- STAT_CHUNK to initialize
00273 //
00274 //--------------------------------------------------------------------------
00275
00276 void CPropertyTag::InitStatChunk( STAT_CHUNK *pStat )
00277 {
00278     //
00279     // Skip over the rest of property tag
00280     //
00281     _scanner.EatTag();
00282
00283     _cPropChars = 0;
00284     _cPropCharsFiltered = 0;
00285
00286     pStat->idChunk = _htmlIFilter.GetNextChunkId();
00287     pStat->flags = CHUNK_TEXT;
00288     pStat->breakType = CHUNK_EOS;
00289     pStat->locale = _htmlIFilter.GetLocale();
00290     pStat->cwcStartSource = 0;
00291     pStat->cwcLenSource = 0;
00292
00293     if ( _htmlIFilter.FFilterContent() )
00294     {
00295         //
00296         // Store the idChunk so that it can be retrieved later to set the value of
00297         // idChunkSource when initializing the pseudo-property
00298         //
00299         _ulIdContentChunk = pStat->idChunk;
00300         pStat->attribute.guidPropSet = CLSID_Storage;
00301         pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00302         pStat->attribute.psProperty.propid = PID_STG_CONTENTS;
00303         pStat->idChunkSource = pStat->idChunk;
00304
00305         _eState = FilteringContent;
00306     }
00307     else
00308     {
00309         //
00310         // We've been asked to filter only the pseudo-property, so skip content filtering
00311         //
00312         _ulIdContentChunk = 0;
00313         pStat->attribute.guidPropSet = _propSpec.GetPropSet();
00314
00315         Win4Assert( _propSpec.IsPropertyPropid() );
00316
00317         pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00318         pStat->attribute.psProperty.propid = _propSpec.GetPropertyPropid();
00319         pStat->idChunkSource = 0;
00320
00321         _eState = FilteringPropertyButContentNotFiltered;
00322     }
00323  }
00324
00325
00326
00327  //+-------------------------------------------------------------------------
00328 //
00329 //  Method:     CPropertyTag::ConcatenateProperty
00330 //
00331 //  Synopsis:   Append the Property suffix to Property stored in internal buffer
00332 //
00333 //  Arguments:  [awcPropertySuffix] -- Suffix of Property
00334 //              [uLen]           -- Length of Property
00335 //
00336 //--------------------------------------------------------------------------
00337
00338 void CPropertyTag::ConcatenateProperty( WCHAR *awcPropSuffix, unsigned uLen )
00339 {
00340     //
00341     // Need to grow Property buffer ?
00342     //
00343     if ( _cPropChars + uLen > _uLenPropBuf )
00344     {
00345         WCHAR *pwcNewPropBuf = newk(mtNewX, NULL) WCHAR[_cPropChars + uLen + PROP_BUFFER_SLOP];
00346         RtlCopyMemory( pwcNewPropBuf, _pwcPropBuf, _cPropChars * sizeof(WCHAR) );
00347
00348         delete[] _pwcPropBuf;
00349         _uLenPropBuf = _cPropChars + uLen + PROP_BUFFER_SLOP;
00350
00351         _pwcPropBuf = pwcNewPropBuf;
00352     }
00353
00354     RtlCopyMemory( _pwcPropBuf + _cPropChars, awcPropSuffix, uLen * sizeof(WCHAR) );
00355     _cPropChars += uLen;
00356 }
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SupportConcurList Member List

This is the complete list of members for SupportConcurList, including all inherited members.
Option | SupportConcurList
Support | SupportConcurList
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/dll/Demo.c Source File

  • Begin
  • dll

Demo.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /****************************************************************************
00013
00014     PROGRAM: Demo.c
00015
00016     PURPOSE: Demonstrates how to manipulate a cursor and select a region
00017
00018     FUNCTIONS:
00019
00020         WinMain() - calls initialization function, processes message loop
00021         DemoInit() - initializes window data and registers window
00022         DemoWndProc() - processes messages
00023         About() - processes messages for "About" dialog box
00024
00025     COMMENTS:
00026         This code is a modified version of the CURSOR.C program.  Instead of
00027         using inline code for drawing the shape, the routines from the Select
00028         library are called.
00029
00030 ****************************************************************************/
00031
00032 #include "windows.h"
00033
00034 #include "demo.h"
00035 #include "select.h"
00036
00037 HANDLE hInst;
00038 BOOL bTrack = FALSE;
00039 INT OrgX = 0, OrgY = 0;
00040 INT PrevX = 0, PrevY = 0;
00041 INT X = 0, Y = 0;
00042
00043 RECT Rect;
00044
00045 INT Shape = SL_BLOCK;                          /* Shape to use for rectangle */
00046 BOOL RetainShape = FALSE;                      /* Retain or destroy shape    */
00047
00048 int APIENTRY WinMain(HINSTANCE hInstance,
00049                      HINSTANCE hPrevInstance,
00050                      LPSTR lpCmdLine,
00051                      int nCmdShow)
00052 {
00053
00054     HWND hWnd;
00055     MSG msg;
00056     CHAR szAppName[64];
00057
00058     UNREFERENCED_PARAMETER(lpCmdLine);
00059
00060     if (!hPrevInstance)
00061         if (!DemoInit(hInstance))
00062             return (0);
00063
00064     hInst = hInstance;
00065     LoadString(hInstance, IDS_APPNAME, szAppName, sizeof(szAppName));
00066
00067     hWnd = CreateWindow("Demo",
00068         szAppName,
00069         WS_OVERLAPPEDWINDOW,
00070         CW_USEDEFAULT,
00071         CW_USEDEFAULT,
00072         CW_USEDEFAULT,
00073         CW_USEDEFAULT,
00074         NULL,
00075         NULL,
00076         hInstance,
00077         NULL);
00078
00079     if (!hWnd)
00080         return (0);
00081
00082     ShowWindow(hWnd, nCmdShow);
00083     UpdateWindow(hWnd);
00084
00085     while (GetMessage(&msg, NULL, 0, 0)) {
00086         TranslateMessage(&msg);
00087         DispatchMessage(&msg);
00088     }
00089     return (int)(msg.wParam);
00090 }
00091
00092 /****************************************************************************
00093
00094     FUNCTION: DemoInit(HANDLE)
00095
00096     PURPOSE: Initializes window data and registers window class
00097
00098 ****************************************************************************/
00099
00100 BOOL DemoInit(HANDLE hInstance)
00101 {
00102     HANDLE hMemory;
00103     PWNDCLASS pWndClass;
00104     BOOL bSuccess;
00105     CHAR lpBuffer[128];
00106
00107     hMemory = LocalAlloc(LPTR, sizeof(WNDCLASS));
00108     if(!hMemory){
00109         LoadString(hInst, IDS_NOMEM, lpBuffer, sizeof(lpBuffer));
00110         MessageBox(NULL, lpBuffer, NULL, MB_OK | MB_ICONHAND);
00111         return(FALSE);
00112     }
00113
00114     pWndClass = (PWNDCLASS) LocalLock(hMemory);
00115     pWndClass->hCursor = LoadCursor(NULL, IDC_ARROW);
00116     pWndClass->hIcon = LoadIcon(NULL, IDI_APPLICATION);
00117     pWndClass->lpszMenuName = (LPSTR) "Menu";
00118     pWndClass->lpszClassName = (LPSTR) "Demo";
00119     pWndClass->hbrBackground = GetStockObject(WHITE_BRUSH);
00120     pWndClass->hInstance = hInstance;
00121     pWndClass->style = 0;
00122     pWndClass->lpfnWndProc = (WNDPROC)DemoWndProc;
00123
00124     bSuccess = RegisterClass(pWndClass);
00125
00126     LocalUnlock(hMemory);
00127     LocalFree(hMemory);
00128     return (bSuccess);
00129 }
00130
00131 /****************************************************************************
00132
00133     FUNCTION: DemoWndProc(HWND, unsigned, WORD, LONG)
00134
00135     PURPOSE:  Processes messages
00136
00137     MESSAGES:
00138
00139         WM_SYSCOMMAND - system menu (About dialog box)
00140         WM_CREATE     - create window
00141         WM_DESTROY    - destroy window
00142         WM_LBUTTONDOWN - left mouse button
00143         WM_MOUSEMOVE   - mouse movement
00144         WM_LBUTTONUP   - left button released
00145
00146         WM_COMMAND messages:
00147             IDM_BOX    - use inverted box for selecting a region
00148             IDM_BLOCK  - use empty box for selecting a region
00149             IDM_RETAIN - retain/delete selection on button release
00150
00151     COMMENTS:
00152
00153         When the left mouse button is pressed, btrack is set to TRUE so that
00154         the code for WM_MOUSEMOVE will keep track of the mouse and update the
00155         box accordingly.  Once the button is released, btrack is set to
00156         FALSE, and the current position is saved.  Holding the SHIFT key
00157         while pressing the left button will extend the current box rather
00158         then erasing it and starting a new one.  The exception is when the
00159         retain shape option is enabled.  With this option, the rectangle is
00160         zeroed whenever the mouse is released so that it can not be erased or
00161         extended.
00162
00163 ****************************************************************************/
00164
00165 LRESULT APIENTRY DemoWndProc(
00166     HWND hWnd,
00167     UINT message,
00168     UINT wParam,
00169     LONG lParam)
00170 {
00171     FARPROC lpProcAbout;
00172     HMENU hMenu;
00173
00174     switch (message) {
00175
00176         case WM_COMMAND:
00177
00178             // LOWORD added for portability
00179
00180             switch (LOWORD(wParam)) {
00181                 case IDM_BOX:
00182                     Shape = SL_BOX;
00183                     hMenu = GetMenu(hWnd);
00184                     CheckMenuItem(hMenu, IDM_BOX, MF_CHECKED);
00185                     CheckMenuItem(hMenu, IDM_BLOCK, MF_UNCHECKED);
00186                     break;
00187
00188                 case IDM_BLOCK:
00189                     Shape = SL_BLOCK;
00190                     hMenu = GetMenu(hWnd);
00191                     CheckMenuItem(hMenu, IDM_BOX, MF_UNCHECKED);
00192                     CheckMenuItem(hMenu, IDM_BLOCK, MF_CHECKED);
00193                     break;
00194
00195                 case IDM_RETAIN:
00196                     if (RetainShape) {
00197                         hMenu = GetMenu(hWnd);
00198                         CheckMenuItem(hMenu, IDM_RETAIN, MF_UNCHECKED);
00199                         RetainShape = FALSE;
00200                     }
00201                     else {
00202                         hMenu = GetMenu(hWnd);
00203                         CheckMenuItem(hMenu, IDM_RETAIN, MF_CHECKED);
00204                         RetainShape = TRUE;
00205                     }
00206                     break;
00207
00208                 case IDM_ABOUT:
00209                     lpProcAbout = MakeProcInstance((FARPROC)About, hInst);
00210                     DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)lpProcAbout);
00211                     FreeProcInstance(lpProcAbout);
00212                     break;
00213
00214             }
00215             break;
00216
00217         case WM_LBUTTONDOWN:
00218
00219             bTrack = TRUE;               /* user has pressed the left button */
00220
00221             /* If you don't want the shape cleared, you must clear the Rect
00222              * coordinates before calling StartSelection
00223              */
00224
00225             if (RetainShape)
00226                 SetRectEmpty(&Rect);
00227
00228             StartSelection(hWnd, MAKEMPOINT(lParam), &Rect,
00229                 (wParam & MK_SHIFT) ? SL_EXTEND | Shape : Shape);
00230             break;
00231
00232         case WM_MOUSEMOVE:
00233             if (bTrack)
00234                 UpdateSelection(hWnd, MAKEMPOINT(lParam), &Rect, Shape);
00235             break;
00236
00237         case WM_LBUTTONUP:
00238        if (bTrack)
00239                EndSelection(MAKEMPOINT(lParam), &Rect);
00240          bTrack = FALSE;
00241             break;
00242
00243    case WM_SIZE:
00244       switch (wParam) {
00245          case SIZEICONIC:
00246
00247             /* If we aren't in retain mode we want to clear the
00248              * current rectangle now!
00249              */
00250             if (!RetainShape)
00251                SetRectEmpty(&Rect);
00252       }
00253       break;
00254
00255         case WM_DESTROY:
00256             PostQuitMessage(0);
00257             break;
00258
00259         default:
00260             return (DefWindowProc(hWnd, message, wParam, lParam));
00261     }
00262     return (0);
00263 }
00264
00265 /****************************************************************************
00266
00267     FUNCTION: About(HWND, unsigned, WORD, LONG)
00268
00269     PURPOSE:  Processes messages for "About" dialog box
00270
00271     MESSAGES:
00272
00273         WM_INITDIALOG - initialize dialog box
00274         WM_COMMAND    - Input received
00275
00276 ****************************************************************************/
00277
00278 BOOL APIENTRY About(
00279     HWND hDlg,
00280     UINT message,
00281     UINT wParam,
00282     LONG lParam)
00283 {
00284     switch (message) {
00285         case WM_INITDIALOG:
00286             return (TRUE);
00287
00288         case WM_COMMAND:
00289             // LOWORD added for portability
00290             if (LOWORD(wParam) == IDOK
00291              || LOWORD(wParam) == IDCANCEL) {
00292                 EndDialog(hDlg, TRUE);
00293                 return (TRUE);
00294             }
00295             return (TRUE);
00296     }
00297     return (FALSE);
00298         UNREFERENCED_PARAMETER(lParam);
00299 }
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step3/Dimmer.cpp Source File

  • NetDS
  • upnp
  • StepByStep
  • Step3

Dimmer.cpp

Go to the documentation of this file.
00001 // Dimmer.cpp : Implementation of CDimmer
00002 #include "stdafx.h"
00003 #include "MyDevice.h"
00004 #include "Dimmer.h"
00005
00006 /////////////////////////////////////////////////////////////////////////////
00007 // CDimmer
00008
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Objsub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Objsub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __ObjSub_H__
00018 #define __ObjSub_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CObjPoolSub
00028 Summary: Object Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CObjSub :
00031   public CSysLCESub,
00032   public IComObjectEvents
00033 {
00034 public:
00035   CObjSub(CComSpy * pSpy)
00036   {
00037     m_pSpy = pSpy;
00038   }
00039
00040   CObjSub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045
00046   DECLARE_NOT_AGGREGATABLE(CObjSub)
00047   DECLARE_GET_CONTROLLING_UNKNOWN()
00048
00049   BEGIN_COM_MAP(CObjSub)
00050     COM_INTERFACE_ENTRY(IComObjectEvents)
00051     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00052   END_COM_MAP()
00053
00054   STDMETHODIMP GetEventType(EventEnum * e){*e = Object;return S_OK;}
00055   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00056   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComObjectEvents;return S_OK;}
00057
00058   STDMETHODIMP OnDisableCommit(COMSVCSEVENTINFO * pInfo, ULONG64 ContextID)
00059   {
00060     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnDisableCommit"), GuidToBstr(pInfo->guidApp));
00061
00062     WCHAR szCtxtID[32];
00063     wsprintfW(szCtxtID,  L"0x%016X", ContextID);
00064     m_pSpy -> AddParamValueToList(L"ContextID", szCtxtID);
00065
00066     IF_AUDIT_DO(OnSetComplete)(pInfo->perfCount, GuidToBstr(pInfo->guidApp), szCtxtID);
00067     return S_OK;
00068   }
00069
00070   STDMETHODIMP  OnEnableCommit(COMSVCSEVENTINFO * pInfo, ULONG64 ContextID)
00071   {
00072     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnEnableCommit"), GuidToBstr(pInfo->guidApp));
00073
00074     WCHAR szCtxtID[32];
00075     wsprintfW(szCtxtID,  L"0x%016X", ContextID);
00076     m_pSpy -> AddParamValueToList(L"ContextID", szCtxtID);
00077
00078     IF_AUDIT_DO(OnSetComplete)(pInfo->perfCount, GuidToBstr(pInfo->guidApp), szCtxtID);
00079     return S_OK;
00080   }
00081
00082   STDMETHODIMP  OnSetComplete(COMSVCSEVENTINFO * pInfo, ULONG64 ContextID)
00083   {
00084     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnSetComplete"), GuidToBstr(pInfo->guidApp));
00085
00086     WCHAR szCtxtID[32];
00087     wsprintfW(szCtxtID,  L"0x%016X", ContextID);
00088     m_pSpy -> AddParamValueToList(L"ContextID", szCtxtID);
00089
00090     IF_AUDIT_DO(OnSetComplete)(pInfo->perfCount, GuidToBstr(pInfo->guidApp), szCtxtID);
00091     return S_OK;
00092   }
00093
00094   STDMETHODIMP  OnSetAbort(COMSVCSEVENTINFO * pInfo, ULONG64 ContextID)
00095   {
00096     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnSetAbort"), GuidToBstr(pInfo->guidApp));
00097
00098     WCHAR szCtxtID[32];
00099     wsprintfW(szCtxtID,  L"0x%016X", ContextID);
00100     m_pSpy -> AddParamValueToList(L"ContextID", szCtxtID);
00101
00102     IF_AUDIT_DO(OnSetComplete)(pInfo->perfCount, GuidToBstr(pInfo->guidApp), szCtxtID);
00103     return S_OK;
00104   }
00105
00106   STDMETHODIMP  OnObjectDeactivate(COMSVCSEVENTINFO * pInfo, ULONG64 CtxtID, ULONG64 ObjectID)
00107   {
00108     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjectDeactivate"), GuidToBstr(pInfo->guidApp));
00109
00110     WCHAR szCtxtID[32], szObjID[32];
00111
00112     wsprintfW(szCtxtID,L"0x%016X", CtxtID);
00113     m_pSpy -> AddParamValueToList(L"CtxtID", szCtxtID);
00114     wsprintfW(szObjID,L"0x%016X", ObjectID);
00115     m_pSpy -> AddParamValueToList(L"ObjectID", szObjID);
00116
00117     IF_AUDIT_DO(OnObjectActivate)(pInfo->perfCount,GuidToBstr(pInfo->guidApp), szCtxtID, szObjID);
00118     return S_OK;
00119   }
00120
00121   STDMETHODIMP  OnObjectActivate(COMSVCSEVENTINFO * pInfo, ULONG64 CtxtID, ULONG64 ObjectID)
00122   {
00123     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjectActivate"), GuidToBstr(pInfo->guidApp));
00124
00125     WCHAR szCtxtID[32], szObjID[32];
00126
00127     wsprintfW(szCtxtID,L"0x%016X", CtxtID);
00128     m_pSpy -> AddParamValueToList(L"CtxtID", szCtxtID);
00129     wsprintfW(szObjID,L"0x%016X", ObjectID);
00130     m_pSpy -> AddParamValueToList(L"ObjectID", szObjID);
00131
00132     IF_AUDIT_DO(OnObjectActivate)(pInfo->perfCount,GuidToBstr(pInfo->guidApp), szCtxtID, szObjID);
00133     return S_OK;
00134   }
00135
00136 };
00137
00138 #endif //__ObjSub_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/AppBar/Globals.h Source File

  • WinUI
  • Shell
  • AppBar

Globals.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1993 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:     globals.h
00009 //
00010 //  PURPOSE:    contains variables and prototypes global to the application
00011 //
00012 //  PLATFORMS:  Windows 95, Windows 98, Windows 2000, Windows NT 4.0
00013 //
00014
00015 #ifndef __GLOBALS_H__
00016 #define __GLOBALS_H__
00017
00018 //////////////////////////////////////////////////////////////////////////////
00019 // Constants and Enumerations
00020
00021 typedef enum tagVERSION {WINNT, WIN32S, WIN95} VERSION;
00022
00023 #define APPBAR_CALLBACK     WM_USER + 1010
00024
00025
00026 //////////////////////////////////////////////////////////////////////////////
00027 // Global Variables
00028
00029 extern HINSTANCE g_hInstance;                                   // initproc.c
00030 extern VERSION version;                                         // main.c
00031
00032
00033 //////////////////////////////////////////////////////////////////////////////
00034 // Prototypes
00035
00036 void ErrorHandlerEx(INT, LPSTR);                               // main.c
00037 int DebugMsg(const TCHAR *pFmt, ...);                           // main.c
00038 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);       // wndproc.c
00039 BOOL InitApplication(HINSTANCE);                                // main.c
00040 BOOL InitInstance(HINSTANCE, int);                              // main.c
00041 void ShowOptions(HWND hwndParent);                              // propsheet.c
00042 void SlideWindow(HWND, LPRECT);                                 // util.c
00043
00044
00045 //////////////////////////////////////////////////////////////////////////////
00046 // Macros
00047
00048 #define ErrorHandler() ErrorHandlerEx(__LINE__, __FILE__)
00049
00050
00051 /* BOOL Cls_OnMoving(HWND hwnd, WPARAM fwSide, LPRECT lprc) */
00052 #define HANDLE_WM_MOVING(hwnd, wParam, lParam, fn) \
00053     (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (wParam), (LPRECT)(lParam))
00054 #define FORWARD_WM_MOVING(hwnd, fwSide, lprc) \
00055     (BOOL)(DWORD)(fn)((hwnd), WM_MOVING, (WPARAM)(fwSide), (LPARAM)(LPRECT)(lprc))
00056
00057 #endif
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Ppgeext/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Ppgeext

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "globals.h"
00023 #include "resource.h"
00024 #include "guids.h"
00025 #include "basesnap.h"
00026 #include "PPgeExt.h"
00027 #include "About.h"
00028 #include "Registry.h"
00029 #include "Extend.h"
00030
00031 // our globals
00032 HINSTANCE g_hinst;
00033
00034
00035 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00036                     DWORD fdwReason,
00037                     void* lpvReserved)
00038 {
00039
00040     if (fdwReason == DLL_PROCESS_ATTACH) {
00041         g_hinst = hinstDLL;
00042     }
00043
00044     return TRUE;
00045 }
00046
00047
00048 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00049 {
00050     if ((rclsid != CLSID_CPropSheetExtension) && (rclsid != CLSID_CSnapinAbout))
00051         return CLASS_E_CLASSNOTAVAILABLE;
00052
00053
00054     if (!ppvObj)
00055         return E_FAIL;
00056
00057     *ppvObj = NULL;
00058
00059     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00060     // if they ask for anything else.
00061     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00062         return E_NOINTERFACE;
00063
00064     CClassFactory *pFactory = NULL;
00065
00066     // make the factory passing in the creation function for the type of object they want
00067     if (rclsid == CLSID_CPropSheetExtension)
00068         pFactory = new CClassFactory(CClassFactory::CONTEXTEXTENSION);
00069     else if (rclsid == CLSID_CSnapinAbout)
00070         pFactory = new CClassFactory(CClassFactory::ABOUT);
00071
00072     if (NULL == pFactory)
00073         return E_OUTOFMEMORY;
00074
00075     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00076
00077     return hr;
00078 }
00079
00080 STDAPI DllCanUnloadNow(void)
00081 {
00082     if (g_uObjects == 0 && g_uSrvLock == 0)
00083         return S_OK;
00084     else
00085         return S_FALSE;
00086 }
00087
00088
00089 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00090 : m_cref(0), m_factoryType(factoryType)
00091 {
00092     OBJECT_CREATED
00093 }
00094
00095 CClassFactory::~CClassFactory()
00096 {
00097     OBJECT_DESTROYED
00098 }
00099
00100 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00101 {
00102     if (!ppv)
00103         return E_FAIL;
00104
00105     *ppv = NULL;
00106
00107     if (IsEqualIID(riid, IID_IUnknown))
00108         *ppv = static_cast<IClassFactory *>(this);
00109     else
00110         if (IsEqualIID(riid, IID_IClassFactory))
00111             *ppv = static_cast<IClassFactory *>(this);
00112
00113         if (*ppv)
00114         {
00115             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00116             return S_OK;
00117         }
00118
00119         return E_NOINTERFACE;
00120 }
00121
00122 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00123 {
00124     return InterlockedIncrement((LONG *)&m_cref);
00125 }
00126
00127 STDMETHODIMP_(ULONG) CClassFactory::Release()
00128 {
00129     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00130     {
00131         delete this;
00132         return 0;
00133     }
00134     return m_cref;
00135 }
00136
00137 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00138 {
00139     HRESULT  hr;
00140     void* pObj;
00141
00142     if (!ppvObj)
00143         return E_FAIL;
00144
00145     *ppvObj = NULL;
00146
00147     // Our object does does not support aggregation, so we need to
00148     // fail if they ask us to do aggregation.
00149     if (pUnkOuter)
00150         return CLASS_E_NOAGGREGATION;
00151
00152     if (CONTEXTEXTENSION == m_factoryType) {
00153         pObj = new CPropSheetExtension();
00154     } else {
00155         pObj = new CSnapinAbout();
00156     }
00157
00158     if (!pObj)
00159         return E_OUTOFMEMORY;
00160
00161     // QueryInterface will do the AddRef() for us, so we do not
00162     // do it in this function
00163     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00164
00165     if (FAILED(hr))
00166         delete pObj;
00167
00168     return hr;
00169 }
00170
00171 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00172 {
00173     if (fLock)
00174         InterlockedIncrement((LONG *)&g_uSrvLock);
00175     else
00176         InterlockedDecrement((LONG *)&g_uSrvLock);
00177
00178     return S_OK;
00179 }
00180
00181 //////////////////////////////////////////////////////////
00182 //
00183 // Exported functions
00184 //
00185
00186
00187 //
00188 // Server registration
00189 //
00190 STDAPI DllRegisterServer()
00191 {
00192     HRESULT hr = SELFREG_E_CLASS;
00193
00194     _TCHAR szName[256];
00195     _TCHAR szSnapInName[256];
00196
00197     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00198     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00199
00200     _TCHAR szAboutName[256];
00201
00202     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00203
00204
00205     // register our CoClasses
00206     hr = RegisterServer(g_hinst,
00207         CLSID_CPropSheetExtension,
00208         szName);
00209
00210     if SUCCEEDED(hr)
00211         hr = RegisterServer(g_hinst,
00212         CLSID_CSnapinAbout,
00213         szAboutName);
00214
00215     // place the registry information for SnapIns
00216     if SUCCEEDED(hr)
00217         hr = RegisterSnapin(CLSID_CPropSheetExtension, szSnapInName, CLSID_CSnapinAbout);
00218
00219     return hr;
00220 }
00221
00222
00223 STDAPI DllUnregisterServer()
00224 {
00225     if (UnregisterServer(CLSID_CPropSheetExtension) == S_OK)
00226         return UnregisterSnapin(CLSID_CPropSheetExtension);
00227     else
00228         return E_FAIL;
00229 }
00230
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CExtendContextMenuEx Member List

This is the complete list of members for CExtendContextMenuEx, including all inherited members.
AddMenuItems(LPDATAOBJECT ipDataObject, LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR *pInsertionAllowed) | CExtendContextMenuEx |
CExtendContextMenuEx() | CExtendContextMenuEx |
Command(long lCommandID, LPDATAOBJECT piDataObject) | CExtendContextMenuEx |
m_cRef | CExtendContextMenuEx | [private]
QueryInterface(REFIID riid, LPVOID *ppv) | CExtendContextMenuEx |
STDMETHODIMP_(ULONG) AddRef() | CExtendContextMenuEx |
STDMETHODIMP_(ULONG) Release() | CExtendContextMenuEx |
~CExtendContextMenuEx() | CExtendContextMenuEx |
Generated on Wed Nov 13 2024 16:56:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/GdiDemo/GdiDemo.h Source File

  • Multimedia
  • Gdi
  • GdiDemo

GdiDemo.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 #ifdef WIN16
00013 #define APIENTRY FAR PASCAL
00014 typedef int (APIENTRY *WNDPROC)();
00015 typedef WORD WPARAM;
00016 typedef VOID *PVOID;
00017 typedef WORD UINT;
00018 #endif
00019
00020 #define APPCLASS   "GDIDEMO"
00021 #define APPTITLE   "Windows GDI Demonstration"
00022
00023
00024 #define APPMENU   1000
00025 #define APPICON   1001
00026 #define ABOUTBOX  1002
00027
00028 #define IDM_DEMO_POLYBEZIER 100
00029 #define IDM_DEMO_XFORM      101
00030 #define IDM_DEMO_MAZE       102
00031 #define IDM_DEMO_DRAW       103
00032 #define IDM_DEMO_BOUNCE     104
00033
00034 #define IDM_WINDOW_CASCADE  200
00035 #define IDM_WINDOW_TILE     201
00036 #define IDM_WINDOW_ICON     202
00037 #define IDM_HELP_ABOUT      900
00038
00039
00040 #define COLOR_SCALE_RED     1
00041 #define COLOR_SCALE_GREEN   2
00042 #define COLOR_SCALE_BLUE    3
00043 #define COLOR_SCALE_GRAY    4
00044
00045 #define CLIENTWND           0
00046
00047
00048 #define BOUNCETITLE  1
00049 #define DRAWTITLE    2
00050 #define MAZETITLE    3
00051 #define POLYTITLE    4
00052 #define XFORMTITLE   5
00053
00054
00055
00056
00057
00058 /*
00059 ** MAIN WINDOW ROUTINES (gdidemo.c)
00060 */
00061 LRESULT  CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
00062 BOOL           CreateProc(HWND);
00063 VOID           DestroyProc(HWND);
00064 BOOL           CommandProc(HWND,WPARAM,LPARAM);
00065 VOID           PaintProc(HWND);
00066 DWORD FAR      lRandom(VOID);
00067
00068
00069 /*
00070 ** INITIALIZATION ROUTINES (init.c)
00071 */
00072 BOOL FAR RegisterAppClass(HANDLE);
00073 VOID FAR UnregisterAppClass(HANDLE);
00074 HWND FAR CreateAppWindow(HANDLE);
00075 HWND FAR CreateMDIClientWindow(HWND);
00076
00077
00078
00079 /*
00080 ** DIALOG ROUTINES (dialog.c)
00081 */
00082 BOOL APIENTRY AboutDlgProc(HWND,UINT,WPARAM,LONG);
00083 INT_PTR  FAR      DisplayDialogBox(HWND,LPSTR,WNDPROC,LONG);
00084 VOID          PaintWindow(HWND,int);
00085 HPALETTE      CreateColorScalePalette(HDC,int);
00086
00087
00088 /*
00089 ** WINDOW ROUTINES (wininfo.c)
00090 */
00091 BOOL  FAR AllocWindowInfo(HWND,WORD);
00092 PVOID FAR LockWindowInfo(HWND);
00093 BOOL  FAR UnlockWindowInfo(HWND);
00094 BOOL  FAR FreeWindowInfo(HWND);
00095
00096
00097
00098
00099 #ifdef TESTDEBUG
00100 #define DEBUGOUT(lpszString) OutputDebugString(lpszString)
00101 #else
00102 #define DEBUGOUT(lpszString) {}
00103 #endif
00104
00105
00106 /*
00107 ** Porting macros...
00108 */
00109 #if defined(_WIN32) || defined(WIN32)
00110 #define GETINSTANCE(hWnd)   (HANDLE)GetWindowLongPtr(hWnd,GWLP_HINSTANCE)
00111 #define GETCLASSBRUSH(hWnd) (HBRUSH)GetClassLongPtr(hWnd,GCLP_HBRBACKGROUND)
00112 #else
00113 #define GETINSTANCE(hWnd)   (HANDLE)GetWindowWord(hWnd,GWW_HINSTANCE)
00114 #define GETCLASSBRUSH(hWnd) (HBRUSH)GetClassWord(hWnd,GCW_HBRBACKGROUND)
00115 #endif
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Event_Provider/Include/Globals.h Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Event_Provider
  • Include

Globals.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Globals.h
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #ifndef _Globals_H
00017 #define _Globals_H
00018
00019 /******************************************************************************
00020  *
00021  *  Name: Provider_Globals
00022  *
00023  *
00024  *  Description:
00025  *
00026  *    class encapsulates global helper functions.
00027  *    Add extra user code here.
00028  *
00029  *****************************************************************************/
00030
00031 class Provider_Globals
00032 {
00033 public:
00034
00035 // Public Static Variables.
00036
00037   static LONG s_LocksInProgress ;
00038   static LONG s_ObjectsInProgress ;
00039
00040 public:
00041
00042 // Public Functions
00043
00044   static HRESULT Global_Startup () ;
00045   static HRESULT Global_Shutdown () ;
00046
00047   static HRESULT CreateInstance (
00048
00049     const CLSID &a_ReferenceClsid ,
00050     LPUNKNOWN a_OuterUnknown ,
00051     const DWORD &a_ClassContext ,
00052     const UUID &a_ReferenceInterfaceId ,
00053     void **a_ObjectInterface
00054   );
00055 } ;
00056
00057 #endif // _Globals_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/OnAsync.h Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

OnAsync.h

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  OnAsync.h
00006 //
00007 // Description:
00008 //  This file declares the CAsyncQuerySink class. It is the sink
00009 //    object for ExecQueryAsync() calls.
00010 //
00011 // Part of: WMI Tutorial #1.
00012 //
00013 // Used by: OnAsync().
00014 //
00015 // History:
00016 //
00017 // **************************************************************************
00018
00019 class CAsyncQuerySink : public IWbemObjectSink
00020 {
00021 public:
00022     CAsyncQuerySink(CListBox *output);
00023     ~CAsyncQuerySink();
00024
00025     STDMETHOD_(SCODE, Indicate)(long lObjectCount,
00026                 IWbemClassObject **pObjArray);
00027
00028     STDMETHOD_(SCODE, SetStatus)(long lFlags,
00029                   HRESULT hResult,
00030                   BSTR strParam,
00031                   IWbemClassObject *pObjParam);
00032
00033     // IUnknown members
00034     STDMETHODIMP         QueryInterface(REFIID, LPVOID *);
00035     STDMETHODIMP_(ULONG) AddRef(void);
00036     STDMETHODIMP_(ULONG) Release(void);
00037
00038     /* IDispatch methods */
00039     STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
00040     {return E_NOTIMPL;}
00041     STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
00042     {return E_NOTIMPL;}
00043     STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR** rgszNames, UINT cNames,
00044       LCID lcid, DISPID* rgdispid)
00045     {return E_NOTIMPL;}
00046     STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
00047       DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo,
00048       UINT* puArgErr)
00049     {return E_NOTIMPL;}
00050
00051 private:
00052     long m_lRef;
00053   CListBox *m_pOutputList;
00054   BOOL m_SetStatusCalled;
00055 };
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/PerfDllS/AppMem/PerfDll/DataMem.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • PerfDllS
  • AppMem
  • PerfDll

DataMem.h

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1995 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011       datamem.h
00012
00013 Abstract:
00014
00015     Header file for the application help performance Object data
00016     definitions
00017
00018     This file contains definitions to construct the dynamic data
00019     which is returned by the Configuration Registry.  Data from
00020     various system API calls is placed into the structures shown
00021     here.
00022
00023 Revision History:
00024
00025
00026 --*/
00027
00028 #ifndef _DATAMEM_H_
00029 #define _DATAMEM_H_
00030
00031 //
00032 //  pack on 8-byte boundries so any longlong fields won't cause alignment
00033 //  faults on RISC platforms
00034 //
00035 //
00036 #pragma pack (8)
00037
00038 //
00039 //  Extensible Object definitions
00040 //
00041
00042 //  Update the following sort of define when adding an object type.
00043
00044 #define APP_MEM_NUM_PERF_OBJECT_TYPES 1
00045
00046 //----------------------------------------------------------------------------
00047
00048 //  Application memory counters
00049 //
00050 //
00051 //  This is the counter structure presently returned by Nbf for
00052 //  each Resource.  Each Resource is an Instance, named by its number.
00053 //
00054 typedef struct _APPMEM_DATA_DEFINITION {
00055     PERF_OBJECT_TYPE            AppMemObjectType;
00056     PERF_COUNTER_DEFINITION AppMemBytesAllocated;
00057     PERF_COUNTER_DEFINITION AppMemAllocs;
00058     PERF_COUNTER_DEFINITION AppMemAllocsSec;
00059     PERF_COUNTER_DEFINITION AppMemReAllocs;
00060     PERF_COUNTER_DEFINITION AppMemReAllocsSec;
00061     PERF_COUNTER_DEFINITION AppMemFrees;
00062     PERF_COUNTER_DEFINITION AppMemFreesSec;
00063 } APPMEM_DATA_DEFINITION;
00064
00065 typedef struct _APPMEM_COUNTERS {
00066     PERF_COUNTER_BLOCK  CounterBlock;
00067     DWORD               dwAppMemBytesAllocated;
00068     DWORD               dwAppMemAllocs;
00069     DWORD               dwAppMemAllocsSec;
00070     DWORD               dwAppMemReAllocs;
00071     DWORD               dwAppMemReAllocsSec;
00072     DWORD               dwAppMemFrees;
00073     DWORD               dwAppMemFreesSec;
00074 } APPMEM_COUNTERS, *PAPPMEM_COUNTERS;
00075
00076 #pragma pack ()
00077
00078 #endif //_DATAMEM_H_
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyMemberSetChangeListener/MyMemberSetChangeListener.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyMemberSetChangeListener

MyMemberSetChangeListener.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      MyMemberSetChangeListener.h
00005 //
00006 //  Description:
00007 //      Declaration of the CMyMemberSetChangeListener class.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #pragma once
00012
00013 //
00014 // Categories and ClusCfg GUIDS
00015 //
00016 #include <ClusCfgServer.h>
00017 #include <ClusCfgGuids.h>
00018
00019 #include "resource.h"
00020
00021 //
00022 // Store the warning state.
00023 //
00024 #pragma warning( push )
00025
00026 //
00027 // Disable warning 4995. The text of the warning is below:
00028 // 'wsprintf': name was marked as #pragma deprecated
00029 //
00030 #pragma warning( disable : 4995 )
00031
00032 // {7CD2EBBF-0958-4513-A58F-0B0B098A6119}
00033 DEFINE_GUID( CLSID_MyMemberSetChangeListener,
00034 0x7cd2ebbf, 0x958, 0x4513, 0xa5, 0x8f, 0xb, 0xb, 0x9, 0x8a, 0x61, 0x19 );
00035
00036 // {2A483627-8BCE-48ea-9613-4CA2F53489FA}
00037 DEFINE_GUID( TASKID_Minor_MyMemberSetChange_Info,
00038 0x2a483627, 0x8bce, 0x48ea, 0x96, 0x13, 0x4c, 0xa2, 0xf5, 0x34, 0x89, 0xfa );
00039
00040 /////////////////////////////////////////////////////////////////////////////
00041 //++
00042 //
00043 // CMyMemberSetChangeListener class definition
00044 //
00045 //--
00046 /////////////////////////////////////////////////////////////////////////////
00047 class CMyMemberSetChangeListener
00048     : public CComObjectRootEx<CComMultiThreadModel>
00049     , public CComCoClass<CMyMemberSetChangeListener, &CLSID_MyMemberSetChangeListener>
00050     , public IClusCfgMemberSetChangeListener
00051     , public IClusCfgInitialize
00052 {
00053 private:
00054     //
00055     // Locale id.
00056     //
00057     LCID                m_lcid;
00058
00059     //
00060     // Pointer to the callback interface.
00061     //
00062     IClusCfgCallback * m_piccCallback;
00063
00064 protected:
00065     //
00066     // Constructor and destructor
00067     //
00068     CMyMemberSetChangeListener( void );
00069     ~CMyMemberSetChangeListener( void );
00070
00071 public:
00072
00073     DECLARE_REGISTRY_RESOURCEID( IDR_MYMEMBERSETCHANGELISTENER )
00074     DECLARE_NOT_AGGREGATABLE( CMyMemberSetChangeListener )
00075
00076     DECLARE_PROTECT_FINAL_CONSTRUCT()
00077
00078     BEGIN_COM_MAP( CMyMemberSetChangeListener )
00079         COM_INTERFACE_ENTRY( IClusCfgMemberSetChangeListener )
00080         COM_INTERFACE_ENTRY( IClusCfgInitialize )
00081     END_COM_MAP()
00082
00083     BEGIN_CATEGORY_MAP( CMyMemberSetChangeListener )
00084         IMPLEMENTED_CATEGORY( CATID_ClusCfgMemberSetChangeListeners )
00085     END_CATEGORY_MAP()
00086
00087     //
00088     // IClusCfgMemberSetChangeListener methods
00089     //
00090     STDMETHOD( Notify ) ( IUnknown * punkIn );
00091
00092     //
00093     //  IClusCfgInitialize methods
00094     //
00095     STDMETHOD( Initialize )(
00096           IUnknown *   punkCallbackIn
00097         , LCID         lcidIn
00098         );
00099
00100 }; //*** class: CMyMemberSetChangeListener
00101
00102 //
00103 // Restore the warning state.
00104 //
00105 #pragma warning( pop )
00106
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCOrder/StdAfx.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCOrder

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__6DD1E6C6_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_)
00006 #define AFX_STDAFX_H__6DD1E6C6_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #define _WIN32_WINNT 0x0500
00016 #define _ATL_APARTMENT_THREADED
00017
00018
00019 #include <atlbase.h>
00020 //You may derive a class from CComModule and use it if you want to override
00021 //something, but do not change the name of _Module
00022 extern CComModule _Module;
00023 #include <atlcom.h>
00024
00025 //{{AFX_INSERT_LOCATION}}
00026 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00027
00028 #include <crtdbg.h>
00029 #include <comsvcs.h>
00030 #include <stdlib.h>
00031 #include <vector>
00032 #include <comdef.h>
00033
00034 #endif // !defined(AFX_STDAFX_H__6DD1E6C6_28C1_11D2_B5B6_00C04FC340EE__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ComUser/ComUser.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • ComUser

ComUser.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      COMUSER.H
00003
00004   Summary:   Include file for the COMUSER code sample application.
00005              In addition to class definitions, this COMUSER.H file contains
00006              definitions of the application's menu, string, and other
00007              resource IDs.
00008
00009              Based largely on the DLLUSER.EXE source code, this include
00010              file adds resource IDs for a set of new menus for exercising
00011              the several COM Objects manipulated in this code sample.
00012              This is the first code sample in the series to exploit the
00013              Message Log facilities offered by APPUTIL.
00014
00015              For a comprehensive tutorial code tour of COMUSER's
00016              contents and offerings see the tutorial COMUSER.HTM file.
00017              For more specific technical details on the internal workings
00018              see the comments dispersed throughout the COMUSER source code.
00019
00020   Classes:   CMainWindow
00021
00022   Functions: WinMain
00023
00024   Origin:    8-20-95: atrent - Editor-inheritance from the DLLUSER source.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(COMUSER_H)
00042 #define COMUSER_H
00043
00044 #ifdef __cplusplus
00045
00046 extern CMsgLog* g_pMsgLog;
00047
00048 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00049   Class:    CMainWindow
00050
00051   Summary:  Class to encapsulate the application's main window, menu, and
00052             message dispatching behavior.
00053
00054   Methods:  CMainWindow
00055               Constructor.
00056             InitInstance
00057               Creates a new instance of the main window.
00058 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00059 class CMainWindow: public CVirWindow
00060 {
00061 public:
00062   CMainWindow();
00063   ~CMainWindow();
00064   BOOL InitInstance(HINSTANCE, int);
00065
00066   TCHAR m_szFileName[MAX_PATH];
00067   CMsgBox*  m_pMsgBox;
00068   CMsgLog*  m_pMsgLog;
00069
00070   // A method for getting an interface on a COM object.
00071   BOOL GetInterface(IUnknown* pObj, REFIID riid, PPVOID ppv);
00072   // Some member variables to store pointers to Car-like COM Objects.
00073   // We save pointers to each COM objects controlling IUnknown.
00074   IUnknown* m_pCar;
00075   IUnknown* m_pUtilityCar;
00076   IUnknown* m_pCruiseCar;
00077   IUnknown* m_pUtilityCruiseCar;
00078
00079 protected:
00080   LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00081
00082 private:
00083   LRESULT DoMenu(WPARAM wParam, LPARAM lParam);
00084
00085   WORD m_wWidth;
00086   WORD m_wHeight;
00087   TCHAR m_szHelpFile[MAX_PATH];
00088   TCHAR m_szFileTitle[MAX_PATH];
00089   TEXTMETRIC m_tm;
00090   OPENFILENAME m_ofnFile;
00091 };
00092
00093 #endif // __cplusplus
00094
00095 // Window Class String Macros.
00096 #define MAIN_WINDOW_TITLE_STR       "COMUSER: Tutorial Code Sample"
00097 #define MAIN_WINDOW_CLASS_NAME_STR  "COMUSERWindow"
00098 #define MAIN_WINDOW_CLASS_MENU_STR  "COMUSERMenu"
00099
00100 // File Name String Macros.
00101 #define DLL_TUTFILE_STR             "comobj.htm"
00102
00103 // OpenFile-related String Macros.
00104 #define OFN_DEFAULTFILES_STR "All Files (*.*)\0*.*\0"
00105 #define OFN_DEFAULTTITLE_STR "Open File"
00106
00107 // File Menu Command Identifiers.
00108 #define IDM_FILE_EXIT               1000
00109
00110 // Car Menu Command Identifiers.
00111 #define IDM_CAR_CREATE              1100
00112 #define IDM_CAR_RELEASE             1101
00113 #define IDM_CAR_SHIFT               1102
00114 #define IDM_CAR_CLUTCH              1103
00115 #define IDM_CAR_SPEED               1104
00116 #define IDM_CAR_STEER               1105
00117
00118 // UtilityCar Menu Command Identifiers.
00119 #define IDM_UCAR_CREATE             1200
00120 #define IDM_UCAR_RELEASE            1201
00121 #define IDM_UCAR_SHIFT              1202
00122 #define IDM_UCAR_CLUTCH             1203
00123 #define IDM_UCAR_SPEED              1204
00124 #define IDM_UCAR_STEER              1205
00125 #define IDM_UCAR_OFFROAD            1206
00126 #define IDM_UCAR_WINCH              1207
00127
00128 // CruiseCar Menu Command Identifiers.
00129 #define IDM_CCAR_CREATE             1300
00130 #define IDM_CCAR_RELEASE            1301
00131 #define IDM_CCAR_SHIFT              1302
00132 #define IDM_CCAR_CLUTCH             1303
00133 #define IDM_CCAR_SPEED              1304
00134 #define IDM_CCAR_STEER              1305
00135 #define IDM_CCAR_ENGAGE             1306
00136 #define IDM_CCAR_ADJUST             1307
00137
00138 // UtilityCruiseCar Menu Command Identifiers.
00139 #define IDM_UCRU_CREATE             1400
00140 #define IDM_UCRU_RELEASE            1401
00141 #define IDM_UCRU_SHIFT              1402
00142 #define IDM_UCRU_CLUTCH             1403
00143 #define IDM_UCRU_SPEED              1404
00144 #define IDM_UCRU_STEER              1405
00145 #define IDM_UCRU_ENGAGE             1406
00146 #define IDM_UCRU_ADJUST             1407
00147 #define IDM_UCRU_OFFROAD            1408
00148 #define IDM_UCRU_WINCH              1409
00149
00150 // Log Menu Command Identifiers.
00151 #define IDM_LOG_LOGCLEAR            1890
00152 #define IDM_LOG_LOGGING             1891
00153 #define IDM_LOG_COPYCLIP            1892
00154
00155 // Help Menu Command Identifiers.
00156 #define IDM_HELP_CONTENTS           1900
00157 #define IDM_HELP_TUTORIAL           1901
00158 #define IDM_HELP_TUTDLL             1902
00159 #define IDM_HELP_READSOURCE         1903
00160 #define IDM_HELP_ABOUT              1904
00161 #define IDM_HELP_ABOUTDLL           1905
00162
00163 // Error-related String Identifiers.
00164 #define IDS_COMINITFAILED           2000
00165 #define IDS_APPINITFAILED           2001
00166 #define IDS_OUTOFMEMORY             2002
00167 #define IDS_UNICODEFAIL             2003
00168
00169 #define IDS_ASSERT_FAIL             2200
00170
00171 // Notice-related String Identifiers.
00172 #define IDS_NOTIMPLEMENTED          2301
00173
00174 // Log Message String Identifiers.
00175 #define IDS_START_MESSAGE_LOG       2400
00176
00177 #endif
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IAS/MapName/dllmain.c Source File

  • NetDS
  • IAS
  • MapName

dllmain.c

Go to the documentation of this file.
00001 /* Copyright (c) Microsoft Corporation. All rights reserved. */
00002
00003 #include "windows.h"
00004 #include "radutil.h"
00005
00006 extern LPCWSTR pwszDllType;
00007
00008 static HMODULE hModule;
00009
00010 BOOL
00011 WINAPI
00012 DllMain(
00013    HINSTANCE hInstance,
00014    DWORD dwReason,
00015    LPVOID lpReserved
00016    )
00017 {
00018    if (dwReason == DLL_PROCESS_ATTACH)
00019    {
00020       hModule = hInstance;
00021       DisableThreadLibraryCalls(hInstance);
00022    }
00023
00024    return TRUE;
00025 }
00026
00027 STDAPI
00028 DllRegisterServer( VOID )
00029 {
00030    return RadiusExtensionInstall(hModule, pwszDllType, TRUE);
00031 }
00032
00033 STDAPI
00034 DllUnregisterServer( VOID )
00035 {
00036    return RadiusExtensionInstall(hModule, pwszDllType, FALSE);
00037 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/PhoneEntry/Resource.h Source File

  • NetDS
  • Ras
  • PhoneEntry

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by PhoneEntry.Rc
00004 //
00005 #define IDCHANGE                        3
00006 #define IDNEW                           4
00007 #define IDBASIC                         7
00008 #define IDSERVER                        8
00009 #define IDSCRIPT                        9
00010 #define IDSECURITY                      10
00011 #define IDX25                           11
00012 #define IDD_DIALOG1                     101
00013 #define IDD_DIALOG2                     102
00014 #define IDD_DIALOG3                     103
00015 #define IDD_DIALOG4                     104
00016 #define IDD_DIALOG7                     109
00017 #define IDC_EDIT1                       1005
00018 #define IDC_COMBO2                      1007
00019 #define IDC_EDIT2                       1008
00020 #define IDC_CHECK1                      1008
00021 #define IDC_COMMENT                     1008
00022 #define IDC_EDIT3                       1009
00023 #define IDC_CHECK2                      1009
00024 #define IDC_CCODE                       1009
00025 #define IDC_CHECK4                      1010
00026 #define IDC_EDIT6                       1010
00027 #define IDC_EDIT4                       1011
00028 #define IDC_CHECK3                      1011
00029 #define IDC_RADIO1                      1011
00030 #define IDC_ACODE                       1011
00031 #define IDC_EDIT5                       1012
00032 #define IDC_CHECK5                      1012
00033 #define IDC_RADIO2                      1012
00034 #define IDC_PHONE                       1012
00035 #define IDC_RADIO3                      1013
00036 #define IDC_ENTRYNAME                   1013
00037 #define IDC_CHECK6                      1014
00038 #define IDC_EDIT7                       1014
00039 #define IDC_ECAC                        1014
00040 #define IDC_EDIT8                       1015
00041 #define IDC_COMBO3                      1017
00042 #define IDC_BUTTON1                     1019
00043 #define IDC_RADIO4                      1022
00044 #define IDC_CHECK7                      1023
00045 #define IDC_CHECK8                      1024
00046 #define IDC_COMBO1                      1027
00047
00048 // Next default values for new objects
00049 //
00050 #ifdef APSTUDIO_INVOKED
00051 #ifndef APSTUDIO_READONLY_SYMBOLS
00052 #define _APS_NEXT_RESOURCE_VALUE        112
00053 #define _APS_NEXT_COMMAND_VALUE         40007
00054 #define _APS_NEXT_CONTROL_VALUE         1028
00055 #define _APS_NEXT_SYMED_VALUE           101
00056 #endif
00057 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/TapiInfo.h Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

TapiInfo.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // PURPOSE:
00009 //    Contains public declarations for the TapiInfo module.
00010 //
00011
00012 #define OutputDebugLineError(lLineError, pszPrefix) \
00013     OutputDebugLineErrorFileLine(lLineError, pszPrefix,\
00014         __FILE__, __LINE__)
00015
00016 #define OutputDebugLastError(dwLastError, pszPrefix) \
00017     OutputDebugLastErrorFileLine(dwLastError, pszPrefix,\
00018         __FILE__, __LINE__)
00019
00020 void OutputDebugLineErrorFileLine(
00021     long lLineError, LPSTR szPrefix,
00022     LPSTR szFileName, DWORD nLineNumber);
00023
00024 void OutputDebugLastErrorFileLine(
00025     DWORD dwLastError, LPSTR szPrefix,
00026     LPSTR szFileName, DWORD nLineNumber);
00027
00028 void OutputDebugLineCallback(
00029     DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
00030     DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
00031
00032 void __cdecl OutputDebugPrintf(LPCSTR lpszFormat, ...);
00033
00034 LPSTR FormatLineError(long lLineError,
00035     LPSTR szOutputBuffer, DWORD dwSizeofOutputBuffer);
00036
00037 LPSTR FormatLastError(DWORD dwLastError,
00038     LPSTR szOutputBuffer, DWORD dwSizeofOutputBuffer);
00039
00040 LPSTR FormatLineCallback(LPSTR pszOutputBuffer,
00041     DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
00042     DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmDebug/CrmDebug.Cpp Source File

  • Com
  • Services
  • Crm
  • CrmDebug

CrmDebug.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: Crmdebug.cpp
00004
00005 ----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009
00010
00011 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00012
00013
00014
00015 This source code is intended only as a supplement to Microsoft
00016
00017 Development Tools and/or on-line documentation. See these other
00018
00019 materials for detailed information regarding Microsoft code samples.
00020
00021
00022
00023 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00024
00025 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00026
00027 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00028
00029 PARTICULAR PURPOSE.
00030
00031 ==========================================================================+*/
00032
00033 // CrmDebug.cpp : Implementation of DLL Exports.
00034
00035
00036 // Note: Proxy/Stub Information
00037 //    To merge the proxy/stub code into the object DLL, add the file
00038 //    dlldatax.c to the project.  Make sure precompiled headers
00039 //    are turned off for this file, and add _MERGE_PROXYSTUB to the
00040 //    defines for the project.
00041 //
00042 //    If you are not running WinNT4.0 or Win95 with DCOM, then you
00043 //    need to remove the following define from dlldatax.c
00044 //    #define _WIN32_WINNT 0x0500
00045 //
00046 //    Further, if you are running MIDL without /Oicf switch, you also
00047 //    need to remove the following define from dlldatax.c.
00048 //    #define USE_STUBLESS_PROXY
00049 //
00050 //    Modify the custom build rule for CrmDebug.idl by adding the following
00051 //    files to the Outputs.
00052 //      CrmDebug_p.c
00053 //      dlldata.c
00054 //    To build a separate proxy/stub DLL,
00055 //    run nmake -f CrmDebugps.mk in the project directory.
00056
00057 #include "stdafx.h"
00058 #include "resource.h"
00059 #include "initguid.h"
00060 #include "CrmDebug.h"
00061 #include "dlldatax.h"
00062
00063 #include "CrmDebug_i.c"
00064 #include "CrmDebugCompensator.h"
00065
00066 #ifdef _MERGE_PROXYSTUB
00067 extern "C" HINSTANCE hProxyDll;
00068 #endif
00069
00070 CComModule _Module;
00071
00072 BEGIN_OBJECT_MAP(ObjectMap)
00073   OBJECT_ENTRY(CLSID_CrmDebugCompensator, CCrmDebugCompensator)
00074 END_OBJECT_MAP()
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // DLL Entry Point
00078
00079 extern "C"
00080 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00081 {
00082   lpReserved;
00083 #ifdef _MERGE_PROXYSTUB
00084   if (!PrxDllMain(hInstance, dwReason, lpReserved))
00085     return FALSE;
00086 #endif
00087   if (dwReason == DLL_PROCESS_ATTACH)
00088   {
00089     _Module.Init(ObjectMap, hInstance);
00090     DisableThreadLibraryCalls(hInstance);
00091   }
00092   else if (dwReason == DLL_PROCESS_DETACH)
00093     _Module.Term();
00094   return TRUE;    // ok
00095 }
00096
00097 /////////////////////////////////////////////////////////////////////////////
00098 // Used to determine whether the DLL can be unloaded by OLE
00099
00100 STDAPI DllCanUnloadNow(void)
00101 {
00102 #ifdef _MERGE_PROXYSTUB
00103   if (PrxDllCanUnloadNow() != S_OK)
00104     return S_FALSE;
00105 #endif
00106   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00107 }
00108
00109 /////////////////////////////////////////////////////////////////////////////
00110 // Returns a class factory to create an object of the requested type
00111
00112 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00113 {
00114 #ifdef _MERGE_PROXYSTUB
00115   if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00116     return S_OK;
00117 #endif
00118   return _Module.GetClassObject(rclsid, riid, ppv);
00119 }
00120
00121 /////////////////////////////////////////////////////////////////////////////
00122 // DllRegisterServer - Adds entries to the system registry
00123
00124 STDAPI DllRegisterServer(void)
00125 {
00126 #ifdef _MERGE_PROXYSTUB
00127   HRESULT hRes = PrxDllRegisterServer();
00128   if (FAILED(hRes))
00129     return hRes;
00130 #endif
00131   // registers object, typelib and all interfaces in typelib
00132   return _Module.RegisterServer(TRUE);
00133 }
00134
00135 /////////////////////////////////////////////////////////////////////////////
00136 // DllUnregisterServer - Removes entries from the system registry
00137
00138 STDAPI DllUnregisterServer(void)
00139 {
00140 #ifdef _MERGE_PROXYSTUB
00141   PrxDllUnregisterServer();
00142 #endif
00143   _Module.UnregisterServer();
00144   return S_OK;
00145 }
00146
00147
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMoveDlg Member List

This is the complete list of members for CMoveDlg, including all inherited members.
CMoveDlg(CWnd *pParent=NULL) | CMoveDlg |
DoDataExchange(CDataExchange *pDX) | CMoveDlg | [protected, virtual]
GetObjectPath() | CMoveDlg | [inline]
IDD enum value | CMoveDlg |
m_sADsPath | CMoveDlg |
OnChangeADspath() | CMoveDlg | [protected]
OnOK() | CMoveDlg | [protected, virtual]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAsynchNotify Member List

This is the complete list of members for CAsynchNotify, including all inherited members.
_cLowResource | CAsynchNotify | [private]
_cRef | CAsynchNotify | [private]
_hEvent | CAsynchNotify | [private]
CAsynchNotify() | CAsynchNotify | [inline]
IsValid() const | CAsynchNotify | [inline]
OnLowResource(DB_DWRESERVE dwReserved) | CAsynchNotify | [inline]
OnProgress(HCHAPTER hChap, DBASYNCHOP ulOp, DBCOUNTITEM ulProg, DBCOUNTITEM ulProgMax, DBASYNCHPHASE ulStat, LPOLESTR pwszStatus) | CAsynchNotify | [inline]
OnStop(HCHAPTER hChap, ULONG ulOp, HRESULT hrStat, LPOLESTR pwszStatus) | CAsynchNotify | [inline]
QueryInterface(REFIID riid, LPVOID *ppiuk) | CAsynchNotify | [inline]
STDMETHOD_(ULONG, AddRef)() | CAsynchNotify | [inline]
STDMETHOD_(ULONG, Release)() | CAsynchNotify | [inline]
Wait() | CAsynchNotify | [inline]
~CAsynchNotify() | CAsynchNotify | [inline]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/people.h Source File

  • SysMgmt
  • MMC
  • ActiveX

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include <mmc.h>
00024 #include "DeleBase.h"
00025
00026 class CPerson : public CDelegationBase {
00027 public:
00028     CPerson(int id, CComponentData *pComponentData = NULL);
00029
00030     virtual ~CPerson();
00031
00032     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00033     virtual const GUID & getNodeType() { return thisGuid; }
00034     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00035
00036     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00037
00038     virtual HRESULT ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile);
00039
00040     void Initialize(_TCHAR *szName, LONG lSpeed, LONG lHeight, LONG lWeight, BOOL fAnimating);
00041
00042 private:
00043     // {29743810-4C4B-11d2-89D8-000021473128}
00044     static const GUID thisGuid;
00045     IUnknown *m_pUnknown;
00046     _TCHAR *szName;
00047     LONG lSpeed;
00048     LONG lHeight;
00049     LONG lWeight;
00050     BOOL fAnimating;
00051
00052     int m_id;
00053 };
00054
00055 class CPeoplePoweredVehicle : public CDelegationBase {
00056 public:
00057     CPeoplePoweredVehicle(CComponentData *pComponentData = NULL);
00058     virtual ~CPeoplePoweredVehicle();
00059
00060     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00061     virtual const GUID & getNodeType() { return thisGuid; }
00062     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00063
00064     virtual HRESULT Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00065
00066 private:
00067     enum { IDM_NEW_PEOPLE = 1 };
00068
00069     // {2974380D-4C4B-11d2-89D8-000021473128}
00070     static const GUID thisGuid;
00071
00072 private:
00073
00074     enum { NUMBER_OF_CHILDREN = 4 };
00075     CPerson *children[NUMBER_OF_CHILDREN];
00076 };
00077
00078 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/FreServe/Server.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • FreServe

Server.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.H
00003
00004   Summary:   Internal include file for the FRESERVE.DLL server code
00005              sample.  Contains class declarations, Resource IDs and
00006              string macros for internal use in constructing this DLL
00007              as a COM component server.  Declares the CServer server
00008              control object class.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial FRESERVE.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   CServer.
00017
00018   Functions: none
00019
00020   Origin:    4-5-96: atrent - Editor-inheritance from SERVER.H in
00021                the DLLSERVE Tutorial Code Sample.
00022
00023 ----------------------------------------------------------------------------
00024   This file is part of the Microsoft COM Tutorial Code Samples.
00025
00026   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00027
00028   This source code is intended only as a supplement to Microsoft
00029   Development Tools and/or on-line documentation.  See these other
00030   materials for detailed information regarding Microsoft code samples.
00031
00032   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00033   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00034   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00035   PARTICULAR PURPOSE.
00036 ==========================================================================+*/
00037
00038
00039 #if !defined(SERVER_H)
00040 #define SERVER_H
00041
00042 // Error-related String Identifiers.
00043 #define IDS_ASSERT_FAIL             2200
00044
00045
00046 #ifdef __cplusplus
00047
00048 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00049   Class:    CServer
00050
00051   Summary:  Class to encapsulate control of this COM server (eg, handle
00052             Lock and Object counting, encapsulate otherwise global data).
00053
00054   Methods:  none
00055 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00056 class CServer : public CThreaded
00057 {
00058   public:
00059     CServer(void);
00060     ~CServer(void);
00061
00062     // Methods for server lifetime control: object counts and lock counts.
00063     void Lock(void);
00064     void Unlock(void);
00065     void ObjectsUp(void);
00066     void ObjectsDown(void);
00067     HRESULT CanUnloadNow(void);
00068
00069     // A place to store the handle to loaded instance of this DLL module.
00070     HINSTANCE m_hDllInst;
00071
00072     // A place to store a client's parent window.
00073     HWND m_hWndParent;
00074
00075     // Global DLL Server living Object count.
00076     LONG m_cObjects;
00077
00078     // Global DLL Server Client Lock count.
00079     LONG m_cLocks;
00080 };
00081
00082 #endif // __cplusplus
00083
00084 // Allow other internal FRESERVE modules to get at the globals.
00085 extern CServer* g_pServer;
00086
00087
00088 #endif // SERVER_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/IPStat/IPStat.Cpp Source File

  • NetDS
  • IPHelp
  • IPStat

IPStat.Cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002     Copyright (c) 1998 - 2000  Microsoft Corporation
00003     Module Name: IpStat.exe
00004     File       : IpStat.cpp
00005     Description: This file demonstrates the use of IP Helper APIs to
00006                  get IP statistics.
00007     Author:
00008     Frank Li            April 21, 1998
00009
00010
00011     Revision History:
00012     Who         When        What
00013     --------    --------    ----------------------------------
00014     Frank Li    04-21-98    created
00015 ---------------------------------------------------------------------------*/
00016
00017 #include "IpStat.h"
00018
00019 void Usage(char * pszProgramName)
00020 {
00021     printf("Manipulates IP Statistics.\n\n");
00022
00023
00024     printf("%s -p proto      Shows connections for the protocol specified\n", pszProgramName);
00025     printf("                     by proto, proto may be tcp or udp.\n");
00026     printf("%s -s [-p proto] Displays per-protocol statistics.\n", pszProgramName);
00027     printf("                     By default, statistics are shown for\n");
00028     printf("                     IP, ICMP, TCP and UDP; the -p option\n");
00029     printf("                     may be used to specify a subset of the default.\n");
00030
00031     printf("Examples:\n\n");
00032
00033     printf("> IpStat -p tcp\n");
00034     printf("> IpStat  -s\n");
00035
00036     WSACleanup();
00037     exit(1);
00038 }
00039
00040
00041 void _cdecl main(int argc, char **argv)
00042 {
00043     WORD wVersionRequested = MAKEWORD(1,1);
00044     WSADATA wsaData;
00045     int nRet;
00046
00047     nRet = WSAStartup(wVersionRequested, &wsaData);
00048     if (wsaData.wVersion != wVersionRequested)
00049     {
00050         fprintf(stderr,"\n Wrong version\n");
00051         return;
00052     }
00053
00054     if ((argc < 2) || (argv[1][0] != '-'))
00055         Usage("IpStat");
00056     if (strlen(argv[1]) > 2)
00057         Usage("IpStat");
00058
00059     switch(argv[1][1])
00060     {
00061     case 'p':
00062         // Print connection table
00063         if (argc == 3)
00064             DoGetConnTable(argv[2]);
00065         else
00066             Usage("IpStat");
00067         break;
00068     case 's':
00069         // show statistics
00070         if (argc == 4 && argv[2][1] == 'p')
00071             DoGetStat(argv[3]); // Get stat for a specific protocol
00072         else if (argc == 2)
00073             DoGetStat(); // Get stat for all protocols
00074         else
00075             Usage("IpStat");
00076         break;
00077
00078
00079     default:
00080         // help
00081         Usage("IpStat");
00082         break;
00083     }
00084     WSACleanup();
00085 }
00086
00087 void DoGetConnTable(char* pszProto)
00088 {
00089     DWORD dwStatus;
00090     if (_strnicmp(pszProto, "tcp", 3) == 0)
00091     {
00092         //Print Tcp Connnection Table
00093         PMIB_TCPTABLE pTcpTable = NULL;
00094         dwStatus = MyGetTcpTable(pTcpTable, TRUE);
00095         if (dwStatus != NO_ERROR)
00096         {
00097             printf("Ipstat: Couldn't get tcp connection table.\n");
00098             if (pTcpTable)
00099                 free(pTcpTable);
00100             return;
00101         }
00102         else
00103         {
00104             DumpTcpTable(pTcpTable);
00105             free(pTcpTable);
00106         }
00107     }
00108     else if (_strnicmp(pszProto, "udp", 3) == 0)
00109     {
00110         //Print Udp Table
00111         PMIB_UDPTABLE pUdpTable = NULL;
00112         dwStatus = MyGetUdpTable(pUdpTable, TRUE);
00113         if (dwStatus != NO_ERROR)
00114         {
00115             printf("Ipstat: Couldn't get udp table.\n");
00116             if (pUdpTable)
00117                 free(pUdpTable);
00118             return;
00119         }
00120         else
00121         {
00122             DumpUdpTable(pUdpTable);
00123             free(pUdpTable);
00124         }
00125     }
00126     else
00127         Usage("IpStat");
00128 }
00129
00130 void DoGetStat(char* pszProto /*NULL*/)
00131 {
00132     if (pszProto == NULL)
00133     {
00134         // by default, display all statistics
00135         {
00136         PMIB_IPSTATS pIpStats = NULL;
00137         if (MyGetIpStatistics(pIpStats) != NO_ERROR)
00138             printf("IpStat: error in getting ip statistics.\n");
00139         else
00140             PrintIpStats(pIpStats);
00141
00142         if (pIpStats)
00143             free(pIpStats);
00144         }
00145         {
00146         PMIB_ICMP pIcmpStats = NULL;
00147         if (MyGetIcmpStatistics(pIcmpStats) != NO_ERROR)
00148             printf("IpStat: error in getting icmp statistics.\n");
00149         else
00150             PrintIcmpStats(&(pIcmpStats->stats));
00151
00152         if (pIcmpStats)
00153             free(pIcmpStats);
00154
00155         }
00156         {
00157         PMIB_TCPSTATS pTcpStats = NULL;
00158         if (MyGetTcpStatistics(pTcpStats) != NO_ERROR)
00159             printf("IpStat: error in getting tcp statistics.\n");
00160         else
00161             PrintTcpStats(pTcpStats);
00162
00163         if (pTcpStats)
00164             free(pTcpStats);
00165         }
00166         {
00167         PMIB_UDPSTATS pUdpStats = NULL;
00168         if (MyGetUdpStatistics(pUdpStats) != NO_ERROR)
00169             printf("IpStat: error in getting udp statistics.\n");
00170         else
00171             PrintUdpStats(pUdpStats);
00172
00173         if (pUdpStats)
00174             free(pUdpStats);
00175
00176         }
00177     }
00178     else if (_strnicmp(pszProto, "ip", 2) == 0)
00179     {
00180         PMIB_IPSTATS pIpStats = NULL;
00181         if (MyGetIpStatistics(pIpStats) != NO_ERROR)
00182             printf("IpStat: error in getting ip statistics.\n");
00183         else
00184             PrintIpStats(pIpStats);
00185
00186         if (pIpStats)
00187             free(pIpStats);
00188     }
00189
00190     else if (_strnicmp(pszProto, "icmp", 4) == 0)
00191     {
00192         PMIB_ICMP pIcmpStats = NULL;
00193         if (MyGetIcmpStatistics(pIcmpStats) != NO_ERROR)
00194             printf("IpStat: error in getting icmp statistics.\n");
00195         else
00196             PrintIcmpStats(&(pIcmpStats->stats));
00197
00198         if (pIcmpStats)
00199             free(pIcmpStats);
00200
00201     }
00202
00203     else if (_strnicmp(pszProto, "tcp", 3) == 0)
00204     {
00205         PMIB_TCPSTATS pTcpStats = NULL;
00206         if (MyGetTcpStatistics(pTcpStats) != NO_ERROR)
00207             printf("IpStat: error in getting tcp statistics.\n");
00208         else
00209             PrintTcpStats(pTcpStats);
00210
00211         if (pTcpStats)
00212             free(pTcpStats);
00213
00214     }
00215
00216     else if (_strnicmp(pszProto, "udp", 3) == 0)
00217     {
00218         PMIB_UDPSTATS pUdpStats = NULL;
00219         if (MyGetUdpStatistics(pUdpStats) != NO_ERROR)
00220             printf("IpStat: error in getting udp statistics.\n");
00221         else
00222             PrintUdpStats(pUdpStats);
00223
00224         if (pUdpStats)
00225             free(pUdpStats);
00226     }
00227     else
00228         printf("IpStat: no available statistics for %s.\n", pszProto);
00229
00230 }
00231
00232
00233 void DumpTcpTable(PMIB_TCPTABLE pTcpTable)
00234 {
00235     char    strState[MAX_STRLEN];
00236     struct  in_addr    inadLocal, inadRemote;
00237     DWORD   dwRemotePort = 0;
00238     char    szLocalIp[MAX_STRLEN];
00239     char    szRemIp[MAX_STRLEN];
00240
00241     if (pTcpTable != NULL)
00242     {
00243         printf("TCP TABLE\n");
00244         printf("%20s %10s %20s %10s %s\n", "Loc Addr", "Loc Port", "Rem Addr",
00245                 "Rem Port", "State");
00246         for (UINT i = 0; i < pTcpTable->dwNumEntries; ++i)
00247         {
00248             switch (pTcpTable->table[i].dwState)
00249             {
00250             case MIB_TCP_STATE_CLOSED:
00251                 strcpy(strState, "CLOSED");
00252                 break;
00253             case MIB_TCP_STATE_TIME_WAIT:
00254                 strcpy(strState, "TIME_WAIT");
00255                 break;
00256             case MIB_TCP_STATE_LAST_ACK:
00257                 strcpy(strState, "LAST_ACK");
00258                 break;
00259             case MIB_TCP_STATE_CLOSING:
00260                 strcpy(strState, "CLOSING");
00261                 break;
00262             case MIB_TCP_STATE_CLOSE_WAIT:
00263                 strcpy(strState, "CLOSE_WAIT");
00264                 break;
00265             case MIB_TCP_STATE_FIN_WAIT1:
00266                 strcpy(strState, "FIN_WAIT1");
00267                 break;
00268             case MIB_TCP_STATE_ESTAB:
00269                 strcpy(strState, "ESTAB");
00270                 break;
00271             case MIB_TCP_STATE_SYN_RCVD:
00272                 strcpy(strState, "SYN_RCVD");
00273                 break;
00274             case MIB_TCP_STATE_SYN_SENT:
00275                 strcpy(strState, "SYN_SENT");
00276                 break;
00277             case MIB_TCP_STATE_LISTEN:
00278                 strcpy(strState, "LISTEN");
00279                 break;
00280             case MIB_TCP_STATE_DELETE_TCB:
00281                 strcpy(strState, "DELETE");
00282                 break;
00283             default:
00284                 printf("Error: unknown state!\n");
00285                 break;
00286             }
00287             inadLocal.s_addr = pTcpTable->table[i].dwLocalAddr;
00288
00289             if (strcmp(strState, "LISTEN") != 0)
00290             {
00291                 dwRemotePort = pTcpTable->table[i].dwRemotePort;
00292             }
00293             else
00294                 dwRemotePort = 0;
00295
00296
00297             inadRemote.s_addr = pTcpTable->table[i].dwRemoteAddr;
00298             strcpy(szLocalIp, inet_ntoa(inadLocal));
00299             strcpy(szRemIp, inet_ntoa(inadRemote));
00300             printf("%20s %10u %20s %10u %s\n",
00301                 szLocalIp,  ntohs((unsigned short)(0x0000FFFF & pTcpTable->table[i].dwLocalPort)),
00302                 szRemIp, ntohs((unsigned short)(0x0000FFFF & dwRemotePort)),
00303                 strState);
00304         }
00305     }
00306 }
00307
00308 void DumpUdpTable(PMIB_UDPTABLE pUdpTable)
00309 {
00310
00311     struct in_addr    inadLocal;
00312     if (pUdpTable != NULL)
00313     {
00314         printf("UDP TABLE\n");
00315         printf("%20s %10s\n", "Loc Addr", "Loc Port");
00316         for (UINT i = 0; i < pUdpTable->dwNumEntries; ++i)
00317         {
00318             inadLocal.s_addr = pUdpTable->table[i].dwLocalAddr;
00319
00320             printf("%20s %10u \n",
00321                 inet_ntoa(inadLocal), ntohs((unsigned short)(0x0000FFFF & pUdpTable->table[i].dwLocalPort)));
00322         }
00323     }
00324 }
00325
00326 //----------------------------------------------------------------------------
00327 // Wrapper to GetTcpTable()
00328 //----------------------------------------------------------------------------
00329 DWORD MyGetTcpTable(PMIB_TCPTABLE& pTcpTable, BOOL fOrder)
00330 {
00331     DWORD status = NO_ERROR;
00332     DWORD statusRetry = NO_ERROR;
00333     DWORD dwActualSize = 0;
00334
00335
00336     // query for buffer size needed
00337     status = GetTcpTable(pTcpTable, &dwActualSize, fOrder);
00338
00339     if (status == NO_ERROR)
00340     {
00341         printf("No error\n");
00342         return status;
00343     }
00344     else if (status == ERROR_INSUFFICIENT_BUFFER)
00345     {
00346         // need more space
00347         pTcpTable = (PMIB_TCPTABLE) malloc(dwActualSize);
00348         assert(pTcpTable);
00349
00350         statusRetry = GetTcpTable(pTcpTable, &dwActualSize, fOrder);
00351         return statusRetry;
00352     }
00353     else
00354     {
00355         return status;
00356     }
00357 }
00358
00359 //----------------------------------------------------------------------------
00360 // Wrapper to GetUdpTable()
00361 //----------------------------------------------------------------------------
00362 DWORD MyGetUdpTable(PMIB_UDPTABLE& pUdpTable, BOOL fOrder)
00363 {
00364     DWORD status = NO_ERROR;
00365     DWORD statusRetry = NO_ERROR;
00366     DWORD dwActualSize = 0;
00367
00368
00369     // query for buffer size needed
00370     status = GetUdpTable(pUdpTable, &dwActualSize, fOrder);
00371
00372     if (status == NO_ERROR)
00373     {
00374         printf("No error\n");
00375         return status;
00376     }
00377     else if (status == ERROR_INSUFFICIENT_BUFFER)
00378     {
00379         // need more space
00380         pUdpTable = (PMIB_UDPTABLE) malloc(dwActualSize);
00381         assert(pUdpTable);
00382
00383         statusRetry = GetUdpTable(pUdpTable, &dwActualSize, fOrder);
00384         return statusRetry;
00385     }
00386     else
00387     {
00388         return status;
00389     }
00390 }
00391
00392 DWORD MyGetIpStatistics(PMIB_IPSTATS& pIpStats)
00393 {
00394     pIpStats = (PMIB_IPSTATS)malloc(sizeof(MIB_IPSTATS));
00395     assert(pIpStats != NULL);
00396     return GetIpStatistics(pIpStats);
00397 }
00398
00399 DWORD MyGetIcmpStatistics(PMIB_ICMP& pIcmpStats)
00400 {
00401     pIcmpStats = (PMIB_ICMP)malloc(sizeof(MIB_ICMP));
00402     assert(pIcmpStats != NULL);
00403     return GetIcmpStatistics(pIcmpStats);
00404 }
00405
00406 DWORD MyGetTcpStatistics(PMIB_TCPSTATS& pTcpStats)
00407 {
00408     pTcpStats = (PMIB_TCPSTATS)malloc(sizeof(MIB_TCPSTATS));
00409     assert(pTcpStats != NULL);
00410     return GetTcpStatistics(pTcpStats);
00411 }
00412
00413 DWORD MyGetUdpStatistics(PMIB_UDPSTATS& pUdpStats)
00414 {
00415     pUdpStats = (PMIB_UDPSTATS)malloc(sizeof(MIB_UDPSTATS));
00416     assert(pUdpStats != NULL);
00417     return GetUdpStatistics(pUdpStats);
00418 }
00419
00420 void PrintIpStats(PMIB_IPSTATS pStats)
00421 {
00422     if (pStats != NULL)
00423     {
00424         printf("\nIP Statistics:\n");
00425
00426         printf("\
00427   dwForwarding       = %lu\n\
00428   dwDefaultTTL       = %lu\n\
00429   dwInReceives       = %lu\n\
00430   dwInHdrErrors      = %lu\n\
00431   dwInAddrErrors     = %lu\n\
00432   dwForwDatagrams    = %lu\n\
00433   dwInUnknownProtos  = %lu\n\
00434   dwInDiscards       = %lu\n\
00435   dwInDelivers       = %lu\n\
00436   dwOutRequests      = %lu\n\
00437   dwRoutingDiscards  = %lu\n\
00438   dwOutDiscards      = %lu\n\
00439   dwOutNoRoutes      = %lu\n\
00440   dwReasmTimeout     = %lu\n\
00441   dwReasmReqds       = %lu\n\
00442   dwReasmOks         = %lu\n\
00443   dwReasmFails       = %lu\n\
00444   dwFragOks          = %lu\n\
00445   dwFragFails        = %lu\n\
00446   dwFragCreates      = %lu\n\
00447   dwNumIf            = %lu\n\
00448   dwNumAddr          = %lu\n\
00449   dwNumRoutes        = %lu\n",
00450                   pStats->dwForwarding,
00451                   pStats->dwDefaultTTL,
00452                   pStats->dwInReceives,
00453                   pStats->dwInHdrErrors,
00454                   pStats->dwInAddrErrors,
00455                   pStats->dwForwDatagrams,
00456                   pStats->dwInUnknownProtos,
00457                   pStats->dwInDiscards,
00458                   pStats->dwInDelivers,
00459                   pStats->dwOutRequests,
00460                   pStats->dwRoutingDiscards,
00461                   pStats->dwOutDiscards,
00462                   pStats->dwOutNoRoutes,
00463                   pStats->dwReasmTimeout,
00464                   pStats->dwReasmReqds,
00465                   pStats->dwReasmOks,
00466                   pStats->dwReasmFails,
00467                   pStats->dwFragOks,
00468                   pStats->dwFragFails,
00469                   pStats->dwFragCreates,
00470                   pStats->dwNumIf,
00471                   pStats->dwNumAddr,
00472                   pStats->dwNumRoutes);
00473     }
00474
00475 }
00476
00477 void PrintIcmpStats(MIBICMPINFO *pStats)
00478 {
00479     if (pStats != NULL)
00480     {
00481         printf("\n%20s %10s %10s\n","ICMP Statistics", "IN", "OUT");
00482         printf("%20s %10s %10s\n","---------------", "------", "------");
00483         printf("%20s %10lu %10lu\n", "dwMsgs", pStats->icmpInStats.dwMsgs, pStats->icmpOutStats.dwMsgs);
00484         printf("%20s %10lu %10lu\n", "dwErrors", pStats->icmpInStats.dwErrors, pStats->icmpOutStats.dwErrors);
00485         printf("%20s %10lu %10lu\n", "dwDestUnreachs", pStats->icmpInStats.dwDestUnreachs, pStats->icmpOutStats.dwDestUnreachs);
00486         printf("%20s %10lu %10lu\n", "dwTimeExcds", pStats->icmpInStats.dwTimeExcds, pStats->icmpOutStats.dwTimeExcds);
00487         printf("%20s %10lu %10lu\n", "dwParmProbs", pStats->icmpInStats.dwParmProbs, pStats->icmpOutStats.dwParmProbs);
00488         printf("%20s %10lu %10lu\n", "dwSrcQuenchs", pStats->icmpInStats.dwSrcQuenchs, pStats->icmpOutStats.dwSrcQuenchs);
00489         printf("%20s %10lu %10lu\n", "dwRedirects", pStats->icmpInStats.dwRedirects, pStats->icmpOutStats.dwRedirects);
00490         printf("%20s %10lu %10lu\n", "dwEchos", pStats->icmpInStats.dwEchos, pStats->icmpOutStats.dwEchos);
00491         printf("%20s %10lu %10lu\n", "dwEchoReps", pStats->icmpInStats.dwEchoReps, pStats->icmpOutStats.dwEchoReps);
00492         printf("%20s %10lu %10lu\n", "dwTimestamps", pStats->icmpInStats.dwTimestamps, pStats->icmpOutStats.dwTimestamps);
00493         printf("%20s %10lu %10lu\n", "dwTimestampReps", pStats->icmpInStats.dwTimestampReps, pStats->icmpOutStats.dwTimestampReps);
00494         printf("%20s %10lu %10lu\n", "dwAddrMasks", pStats->icmpInStats.dwAddrMasks, pStats->icmpOutStats.dwAddrMasks);
00495         printf("%20s %10lu %10lu\n", "dwAddrMaskReps", pStats->icmpInStats.dwAddrMaskReps, pStats->icmpOutStats.dwAddrMaskReps);
00496     }
00497 }
00498
00499 void PrintTcpStats(PMIB_TCPSTATS pStats)
00500 {
00501     if (pStats != NULL)
00502     {
00503         printf("\nTCP Statistics\n");
00504         printf("\
00505   dwRtoAlgorithm     = %lu\n\
00506   dwRtoMin           = %lu\n\
00507   dwRtoMax           = %lu\n\
00508   dwMaxConn          = %lu\n\
00509   dwActiveOpens      = %lu\n\
00510   dwPassiveOpens     = %lu\n\
00511   dwAttemptFails     = %lu\n\
00512   dwEstabResets      = %lu\n\
00513   dwCurrEstab        = %lu\n\
00514   dwInSegs           = %lu\n\
00515   dwOutSegs          = %lu\n\
00516   dwRetransSegs      = %lu\n\
00517   dwInErrs           = %lu\n\
00518   dwOutRsts          = %lu\n\
00519   dwNumConns         = %lu\n",
00520 pStats->dwRtoAlgorithm,
00521 pStats->dwRtoMin,
00522 pStats->dwRtoMax,
00523 pStats->dwMaxConn,
00524 pStats->dwActiveOpens,
00525 pStats->dwPassiveOpens,
00526 pStats->dwAttemptFails,
00527 pStats->dwEstabResets,
00528 pStats->dwCurrEstab,
00529 pStats->dwInSegs,
00530 pStats->dwOutSegs,
00531 pStats->dwRetransSegs,
00532 pStats->dwInErrs,
00533 pStats->dwOutRsts,
00534 pStats->dwNumConns);
00535     }
00536 }
00537
00538 void PrintUdpStats(PMIB_UDPSTATS pStats)
00539 {
00540     if (pStats != NULL)
00541     {
00542         printf("\nUDP Statistics\n");
00543         printf("\
00544   dwInDatagrams      = %lu\n\
00545   dwNoPorts          = %lu\n\
00546   dwInErrors         = %lu\n\
00547   dwOutDatagrams     = %lu\n\
00548   dwNumAddrs         = %lu\n",
00549 pStats->dwInDatagrams,
00550 pStats->dwNoPorts,
00551 pStats->dwInErrors,
00552 pStats->dwOutDatagrams,
00553 pStats->dwNumAddrs);
00554     }
00555 }
00556
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/PerfDllS/AppMem/PerfDll/Perfmem.c Source File

  • WinBase
  • WinNT
  • PerfTool
  • PerfDllS
  • AppMem
  • PerfDll

Perfmem.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1995 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 Module Name:
00011
00012     perfmem.c
00013
00014 Abstract:
00015
00016     This file implements the Extensible Objects for  the application
00017     memory object
00018
00019 --*/
00020 //
00021 //  Include Files
00022 //
00023 #include <windows.h>
00024 #include <string.h>
00025 #include <winperf.h>
00026 #include "..\inc\appmemi.h"     // definitions shared with the app. dll
00027 #include "memctrs.h"            // error message definition
00028 #include "perfmsg.h"            // message utilities
00029 #include "perfutil.h"           // perf data utilities
00030 #include "datamem.h"            // perf data structure definitions
00031
00032 //
00033 //  References to constants which initialize the Object type definitions
00034 //
00035 extern APPMEM_DATA_DEFINITION AppMemDataDefinition;
00036
00037 static DWORD  dwOpenCount = 0;        // count of "Open" threads
00038 static BOOL   bInitOK     = FALSE;    // true = DLL initialized OK
00039
00040 //
00041 // App Mem counter data structures
00042 //
00043
00044 static  HANDLE  hAppMemSharedMemory = NULL; // Handle of counter Shared Memory
00045
00046 static  PAPPMEM_DATA_HEADER pDataHeader = NULL; // pointer to header of shared mem
00047 //
00048 //  Function Prototypes
00049 //
00050 //      these are used to insure that the data collection functions
00051 //      accessed by Perflib will have the correct calling format.
00052 //
00053
00054 PM_OPEN_PROC    OpenAppMemPerformanceData;
00055 PM_COLLECT_PROC CollectAppMemPerformanceData;
00056 PM_CLOSE_PROC   CloseAppMemPerformanceData;
00057
00058 DWORD APIENTRY
00059 OpenAppMemPerformanceData(
00060     LPWSTR lpDeviceNames
00061 )
00062 /*++
00063
00064 Routine Description:
00065
00066     This routine will open and map the memory used by the App Mem DLL to
00067     pass performance data in. This routine also initializes the data
00068     structures used to pass data back to the registry
00069
00070 Arguments:
00071
00072     Pointer to object ID of each device to be opened
00073
00074 Return Value:
00075
00076     None.
00077
00078 --*/
00079
00080 {
00081    LONG  status;
00082    HKEY  hKeyDriverPerf = NULL;
00083    DWORD size;
00084    DWORD type;
00085    DWORD dwFirstCounter;
00086    DWORD dwFirstHelp;
00087    APPMEM_COUNTERS     ac;
00088
00089    //
00090    //  Since REGSVC is multi-threaded and will call this routine in
00091    //  order to service remote performance queries, this library
00092    //  must keep track of how many times it has been opened (i.e.
00093    //  how many threads have accessed it). the registry routines will
00094    //  limit access to the initialization routine to only one thread
00095    //  at a time so synchronization (i.e. reentrancy) should not be
00096    //  a problem
00097    //
00098
00099    if (dwOpenCount == 0)
00100    { // do this only on the first instance of the DLL
00101       // open Eventlog interface
00102
00103       hEventLog = MonOpenEventLog();
00104
00105       // open/create shared memory used by the application to pass performance values
00106       status = GetSharedMemoryDataHeader(
00107                                         & hAppMemSharedMemory, & pDataHeader,
00108                                         TRUE); // only read access is required
00109       if (status != ERROR_SUCCESS)
00110       {
00111          REPORT_ERROR_DATA (status, LOG_USER, NULL, 0);
00112          goto OpenExitPoint;
00113       }
00114
00115       // get counter and help index base values from registry
00116       //      Open key to registry entry
00117       //      read First Counter and First Help values
00118       //      update static data strucutures by adding base to
00119       //          offset value in structure.
00120
00121       status = RegOpenKeyEx(
00122                            HKEY_LOCAL_MACHINE,
00123                            "SYSTEM\\CurrentControlSet\\Services\\AppMem\\Performance",
00124                            0L,
00125                            KEY_READ,
00126                            & hKeyDriverPerf);
00127       if (status != ERROR_SUCCESS)
00128       {
00129          REPORT_ERROR_DATA(APPMEM_UNABLE_OPEN_DRIVER_KEY, LOG_USER, & status, sizeof(status));
00130          // this is fatal, if we can't get the base values of the
00131          // counter or help names, then the names won't be available
00132          // to the requesting application  so there's not much
00133          // point in continuing.
00134          goto OpenExitPoint;
00135       }
00136
00137       size   = sizeof(DWORD);
00138       status = RegQueryValueEx(
00139                               hKeyDriverPerf,
00140                               "First Counter",
00141                               0L,
00142                               & type,
00143                               (LPBYTE) & dwFirstCounter,
00144                               & size);
00145       if (status != ERROR_SUCCESS)
00146       {
00147          REPORT_ERROR_DATA(APPMEM_UNABLE_READ_FIRST_COUNTER, LOG_USER, & status, sizeof(status));
00148          // this is fatal, if we can't get the base values of the
00149          // counter or help names, then the names won't be available
00150          // to the requesting application  so there's not much
00151          // point in continuing.
00152          goto OpenExitPoint;
00153       }
00154
00155       size   = sizeof(DWORD);
00156       status = RegQueryValueEx(
00157                               hKeyDriverPerf,
00158                               "First Help",
00159                               0L,
00160                               & type,
00161                               (LPBYTE) & dwFirstHelp,
00162                               & size);
00163       if (status != ERROR_SUCCESS)
00164       {
00165          REPORT_ERROR_DATA(APPMEM_UNABLE_READ_FIRST_HELP, LOG_USER, & status, sizeof(status));
00166          // this is fatal, if we can't get the base values of the
00167          // counter or help names, then the names won't be available
00168          // to the requesting application  so there's not much
00169          // point in continuing.
00170          goto OpenExitPoint;
00171       }
00172
00173       //
00174       //  NOTE: the initialization program could also retrieve
00175       //      LastCounter and LastHelp if they wanted to do
00176       //      bounds checking on the new number. e.g.
00177       //
00178       //      counter->CounterNameTitleIndex += dwFirstCounter;
00179       //      if (counter->CounterNameTitleIndex > dwLastCounter) {
00180       //          LogErrorToEventLog (INDEX_OUT_OF_BOUNDS);
00181       //      }
00182
00183       AppMemDataDefinition.AppMemObjectType.ObjectNameTitleIndex      += dwFirstCounter;
00184       AppMemDataDefinition.AppMemObjectType.ObjectHelpTitleIndex      += dwFirstHelp;
00185       AppMemDataDefinition.AppMemBytesAllocated.CounterNameTitleIndex += dwFirstCounter;
00186       AppMemDataDefinition.AppMemBytesAllocated.CounterHelpTitleIndex += dwFirstHelp;
00187       AppMemDataDefinition.AppMemBytesAllocated.CounterOffset         +=
00188                                       (DWORD) ((LPBYTE) & ac.dwAppMemBytesAllocated - (LPBYTE) & ac);
00189       AppMemDataDefinition.AppMemAllocs.CounterNameTitleIndex         += dwFirstCounter;
00190       AppMemDataDefinition.AppMemAllocs.CounterHelpTitleIndex         += dwFirstHelp;
00191       AppMemDataDefinition.AppMemAllocs.CounterOffset                  =
00192                                       (DWORD) ((LPBYTE) & ac.dwAppMemAllocs - (LPBYTE) & ac);
00193       AppMemDataDefinition.AppMemAllocsSec.CounterNameTitleIndex      += dwFirstCounter;
00194       AppMemDataDefinition.AppMemAllocsSec.CounterHelpTitleIndex      += dwFirstHelp;
00195       AppMemDataDefinition.AppMemAllocsSec.CounterOffset               =
00196                                       (DWORD) ((LPBYTE) & ac.dwAppMemAllocsSec - (LPBYTE) & ac);
00197       AppMemDataDefinition.AppMemReAllocs.CounterNameTitleIndex       += dwFirstCounter;
00198       AppMemDataDefinition.AppMemReAllocs.CounterHelpTitleIndex       += dwFirstCounter;
00199       AppMemDataDefinition.AppMemReAllocs.CounterOffset                =
00200                                       (DWORD) ((LPBYTE) & ac.dwAppMemReAllocs - (LPBYTE) & ac);
00201       AppMemDataDefinition.AppMemReAllocsSec.CounterNameTitleIndex    += dwFirstCounter;
00202       AppMemDataDefinition.AppMemReAllocsSec.CounterHelpTitleIndex    += dwFirstHelp;
00203       AppMemDataDefinition.AppMemReAllocsSec.CounterOffset             =
00204                                       (DWORD) ((LPBYTE) & ac.dwAppMemReAllocsSec - (LPBYTE) & ac);
00205       AppMemDataDefinition.AppMemFrees.CounterNameTitleIndex          += dwFirstCounter;
00206       AppMemDataDefinition.AppMemFrees.CounterHelpTitleIndex          += dwFirstHelp;
00207       AppMemDataDefinition.AppMemFrees.CounterOffset                   =
00208                                       (DWORD) ((LPBYTE) & ac.dwAppMemFrees - (LPBYTE) & ac);
00209       AppMemDataDefinition.AppMemFreesSec.CounterNameTitleIndex       += dwFirstCounter;
00210       AppMemDataDefinition.AppMemFreesSec.CounterHelpTitleIndex       += dwFirstHelp;
00211       AppMemDataDefinition.AppMemFreesSec.CounterOffset                =
00212                                       (DWORD) ((LPBYTE) & ac.dwAppMemFreesSec - (LPBYTE) & ac);
00213
00214       bInitOK = TRUE; // ok to use this function
00215    }
00216
00217    dwOpenCount ++;         // increment OPEN counter
00218    status = ERROR_SUCCESS; // for successful exit
00219
00220 OpenExitPoint:
00221    if (hKeyDriverPerf != NULL) RegCloseKey(hKeyDriverPerf); // close key to registry
00222
00223    return status;
00224 }
00225
00226 DWORD APIENTRY
00227 CollectAppMemPerformanceData(
00228     IN      LPWSTR  lpValueName,
00229     IN OUT  LPVOID  *lppData,
00230     IN OUT  LPDWORD lpcbTotalBytes,
00231     IN OUT  LPDWORD lpNumObjectTypes
00232 )
00233 /*++
00234
00235 Routine Description:
00236
00237     This routine will return the data for the Application memory counters
00238
00239 Arguments:
00240
00241    IN       LPWSTR   lpValueName
00242             pointer to a wide character string passed by registry.
00243
00244    IN OUT   LPVOID   *lppData
00245          IN: pointer to the address of the buffer to receive the completed
00246             PerfDataBlock and subordinate structures. This routine will
00247             append its data to the buffer starting at the point referenced
00248             by *lppData.
00249          OUT: points to the first byte after the data structure added by this
00250             routine. This routine updated the value at lppdata after appending
00251             its data.
00252
00253    IN OUT   LPDWORD  lpcbTotalBytes
00254          IN: the address of the DWORD that tells the size in bytes of the
00255             buffer referenced by the lppData argument
00256          OUT: the number of bytes added by this routine is writted to the
00257             DWORD pointed to by this argument
00258
00259    IN OUT   LPDWORD  NumObjectTypes
00260          IN: the address of the DWORD to receive the number of objects added
00261             by this routine
00262          OUT: the number of objects added by this routine is writted to the
00263             DWORD pointed to by this argument
00264
00265 Return Value:
00266
00267       ERROR_MORE_DATA if buffer passed is too small to hold data
00268          any error conditions encountered are reported to the event log if
00269          event logging is enabled.
00270
00271       ERROR_SUCCESS  if success or any other error. Errors, however are
00272          also reported to the event log.
00273
00274 --*/
00275 {
00276    //  Variables for reformating the data
00277
00278    ULONG                       SpaceNeeded;
00279    PERF_INSTANCE_DEFINITION  * pPerfInstanceDef;
00280    APPMEM_DATA_DEFINITION    * pAppMemDataDefinition;
00281    DWORD                       dwQueryType;
00282    DWORD                       dwInstanceIndex;
00283    PAPPMEM_INSTANCE            pThisAppInstanceData = NULL;
00284    PAPPMEM_COUNTERS            pAC;
00285
00286    //
00287    // before doing anything else, see if Open went OK
00288    //
00289    if ((!bInitOK) || (pDataHeader == NULL))
00290    {
00291       // unable to continue because open failed.
00292       * lpcbTotalBytes   = (DWORD) 0;
00293       * lpNumObjectTypes = (DWORD) 0;
00294       return ERROR_SUCCESS; // yes, this is a successful exit
00295    }
00296
00297    // see if this is a foreign (i.e. non-NT) computer data request
00298    //
00299    dwQueryType = GetQueryType(lpValueName);
00300    if (dwQueryType == QUERY_FOREIGN)
00301    {
00302       // this routine does not service requests for data from
00303       // Non-NT computers
00304       * lpcbTotalBytes   = (DWORD) 0;
00305       * lpNumObjectTypes = (DWORD) 0;
00306       return ERROR_SUCCESS;
00307    }
00308
00309    if (dwQueryType == QUERY_ITEMS)
00310    {
00311       if (! (IsNumberInUnicodeList (AppMemDataDefinition.AppMemObjectType.ObjectNameTitleIndex, lpValueName)))
00312       {
00313          // request received for data object not provided by this routine
00314          * lpcbTotalBytes   = (DWORD) 0;
00315          * lpNumObjectTypes = (DWORD) 0;
00316          return ERROR_SUCCESS;
00317       }
00318    }
00319
00320    // if here, then this must be one for us so load data structures
00321
00322    pAppMemDataDefinition = (APPMEM_DATA_DEFINITION *) *lppData;
00323
00324    // always return an "instance sized" buffer after the definition blocks
00325    // to prevent perfmon from reading bogus data. This is strictly a hack
00326    // to accomodate how PERFMON handles the "0" instance case.
00327    //  By doing this, perfmon won't choke when there are no instances
00328    //  and the counter object & counters will be displayed in the
00329    //  list boxes, even though no instances will be listed.
00330
00331    SpaceNeeded = sizeof(APPMEM_DATA_DEFINITION) +
00332                  ((pDataHeader->dwInstanceCount > 0 ? pDataHeader->dwInstanceCount : 1) * (
00333                          sizeof(PERF_INSTANCE_DEFINITION) + MAX_SIZEOF_INSTANCE_NAME + sizeof(APPMEM_COUNTERS)));
00334
00335    if (* lpcbTotalBytes < SpaceNeeded)
00336    {
00337       // not enough room so return nothing.
00338       * lpcbTotalBytes   = (DWORD) 0;
00339       * lpNumObjectTypes = (DWORD) 0;
00340       return ERROR_MORE_DATA;
00341    }
00342
00343    // copy the object & counter definition information
00344
00345    memmove(pAppMemDataDefinition, & AppMemDataDefinition, sizeof(APPMEM_DATA_DEFINITION));
00346
00347    // prepare to read the instance data
00348    pPerfInstanceDef = (PERF_INSTANCE_DEFINITION *) & pAppMemDataDefinition[1];
00349
00350    // point to the first instance structure in the shared buffer
00351    pThisAppInstanceData = FIRST_INUSE(pDataHeader);
00352
00353    // process each of the instances in the shared memory buffer
00354    dwInstanceIndex = 0;
00355    while ((dwInstanceIndex < pDataHeader->dwInstanceCount) && (pThisAppInstanceData != NULL))
00356    {
00357       // initialize this instance
00358       MonBuildInstanceDefinition(
00359                                 pPerfInstanceDef,
00360                                 & pAC, // pointer to first byte after instance def
00361                                 0,     // no parent
00362                                 0,     //  object to reference
00363                                 (DWORD) PERF_NO_UNIQUE_ID,
00364                                 pThisAppInstanceData->wcszInstanceName);
00365       //
00366       //    collect and format app memory perf data from shared memory
00367       //
00368
00369       pAC->CounterBlock.ByteLength = sizeof(APPMEM_COUNTERS);
00370
00371       // set pointer to first counter data field
00372
00373       pAC->dwAppMemBytesAllocated = pThisAppInstanceData->dwApplicationBytes;
00374       pAC->dwAppMemAllocs = pThisAppInstanceData->dwAllocCalls;
00375       pAC->dwAppMemAllocsSec = pThisAppInstanceData->dwAllocCalls;
00376       pAC->dwAppMemReAllocs = pThisAppInstanceData->dwReAllocCalls;
00377       pAC->dwAppMemReAllocsSec = pThisAppInstanceData->dwReAllocCalls;
00378       pAC->dwAppMemFrees = pThisAppInstanceData->dwFreeCalls;
00379       pAC->dwAppMemFreesSec = pThisAppInstanceData->dwFreeCalls;
00380
00381       // setup for the next instance
00382       dwInstanceIndex++;
00383       pThisAppInstanceData =
00384       APPMEM_INST(pDataHeader, pThisAppInstanceData->dwOffsetOfNext);
00385       pPerfInstanceDef =
00386       (PERF_INSTANCE_DEFINITION *)((LPBYTE)pAC + sizeof(APPMEM_COUNTERS));
00387    }
00388
00389    if (dwInstanceIndex == 0)
00390    {
00391       // zero fill one instance sized block of data if there are no
00392       // data instances
00393
00394       memset(pPerfInstanceDef, 0,
00395               (sizeof(PERF_INSTANCE_DEFINITION) + MAX_SIZEOF_INSTANCE_NAME + sizeof(APPMEM_COUNTERS)));
00396
00397       // adjust pointer to point to end of zeroed block
00398       (BYTE *) pPerfInstanceDef += (sizeof(PERF_INSTANCE_DEFINITION)
00399                                  + MAX_SIZEOF_INSTANCE_NAME + sizeof(APPMEM_COUNTERS));
00400    }
00401
00402    // done with the shared memory so free the mutex if one was
00403    // acquired
00404
00405    * lppData = (PVOID) pPerfInstanceDef;
00406
00407    // update arguments for return
00408
00409    * lpNumObjectTypes = 1;
00410    pAppMemDataDefinition->AppMemObjectType.NumInstances = dwInstanceIndex;
00411
00412    pAppMemDataDefinition->AppMemObjectType.TotalByteLength =
00413    * lpcbTotalBytes = (DWORD)((PBYTE) pPerfInstanceDef - (PBYTE) pAppMemDataDefinition);
00414
00415    return ERROR_SUCCESS;
00416 }
00417
00418 DWORD APIENTRY
00419 CloseAppMemPerformanceData(
00420 )
00421 /*++
00422
00423 Routine Description:
00424
00425     This routine closes the open handles to Application Memory
00426         usage performance counters
00427
00428 Arguments:
00429
00430     None.
00431
00432
00433 Return Value:
00434
00435     ERROR_SUCCESS
00436
00437 --*/
00438 {
00439    if ((-- dwOpenCount) == 0)
00440    { // when this is the last thread...
00441       if (hAppMemSharedMemory != NULL) CloseHandle(hAppMemSharedMemory);
00442       pDataHeader = NULL;
00443       MonCloseEventLog();
00444    }
00445
00446    return ERROR_SUCCESS;
00447
00448 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSimpSvrObj Member List

This is the complete list of members for CSimpSvrObj, including all inherited members.
AddFrameLevelUI() | CSimpSvrObj |
AssembleMenus() | CSimpSvrObj |
CDataObject | CSimpSvrObj | [friend]
CExternalConnection | CSimpSvrObj | [friend]
ClearDataAdviseHolder() | CSimpSvrObj | [inline]
ClearOleAdviseHolder() | CSimpSvrObj | [inline]
ClearOleClientSite() | CSimpSvrObj | [inline]
COleInPlaceActiveObject | CSimpSvrObj | [friend]
COleInPlaceObject | CSimpSvrObj | [friend]
COleObject | CSimpSvrObj | [friend]
CPersistStorage | CSimpSvrObj | [friend]
CSimpSvrObj(CSimpSvrDoc FAR *lpSimpSvrDoc) | CSimpSvrObj |
DeactivateUI() | CSimpSvrObj |
DisassembleMenus() | CSimpSvrObj |
DoInPlaceActivate(LONG lVerb) | CSimpSvrObj |
DoInPlaceHide() | CSimpSvrObj |
Draw(HDC hDC, BOOL fMetaDC=TRUE) | CSimpSvrObj |
GetDataAdviseHolder() | CSimpSvrObj | [inline]
GetDataObject() | CSimpSvrObj | [inline]
GetFrameInfo() | CSimpSvrObj | [inline]
GetInPlaceFrame() | CSimpSvrObj | [inline]
GetInPlaceSite() | CSimpSvrObj | [inline]
GetMetaFilePict() | CSimpSvrObj |
GetOleAdviseHolder() | CSimpSvrObj | [inline]
GetOleClientSite() | CSimpSvrObj | [inline]
GetOleInPlaceActiveObject() | CSimpSvrObj | [inline]
GetOleInPlaceObject() | CSimpSvrObj | [inline]
GetOleObject() | CSimpSvrObj | [inline]
GetParent() | CSimpSvrObj | [inline]
GetPersistStorage() | CSimpSvrObj | [inline]
GetPosRect() | CSimpSvrObj | [inline]
GetRotRegister() | CSimpSvrObj | [inline]
GetSize() | CSimpSvrObj | [inline]
GetStorage() | CSimpSvrObj | [inline]
GetUIWindow() | CSimpSvrObj | [inline]
IsInPlaceActive() | CSimpSvrObj | [inline]
IsInPlaceVisible() | CSimpSvrObj | [inline]
IsUIActive() | CSimpSvrObj | [inline]
lButtonDown(WPARAM wParam, LPARAM lParam) | CSimpSvrObj |
LoadFromStorage() | CSimpSvrObj |
m_blue | CSimpSvrObj | [private]
m_DataObject | CSimpSvrObj | [private]
m_dwRegister | CSimpSvrObj | [private]
m_ExternalConnection | CSimpSvrObj | [private]
m_fInPlaceActive | CSimpSvrObj | [private]
m_fInPlaceVisible | CSimpSvrObj | [private]
m_fNoScribbleMode | CSimpSvrObj | [private]
m_FrameInfo | CSimpSvrObj | [private]
m_fSaveWithSameAsLoad | CSimpSvrObj | [private]
m_fUIActive | CSimpSvrObj | [private]
m_green | CSimpSvrObj | [private]
m_hmenuShared | CSimpSvrObj | [private]
m_hOleMenu | CSimpSvrObj | [private]
m_hWndParent | CSimpSvrObj | [private]
m_lpCntrDoc | CSimpSvrObj | [private]
m_lpColorStm | CSimpSvrObj | [private]
m_lpDataAdviseHolder | CSimpSvrObj | [private]
m_lpDoc | CSimpSvrObj | [private]
m_lpFrame | CSimpSvrObj | [private]
m_lpIPSite | CSimpSvrObj | [private]
m_lpOleAdviseHolder | CSimpSvrObj | [private]
m_lpOleClientSite | CSimpSvrObj | [private]
m_lpSizeStm | CSimpSvrObj | [private]
m_lpStorage | CSimpSvrObj | [private]
m_nCount | CSimpSvrObj | [private]
m_OleInPlaceActiveObject | CSimpSvrObj | [private]
m_OleInPlaceObject | CSimpSvrObj | [private]
m_OleObject | CSimpSvrObj | [private]
m_PersistStorage | CSimpSvrObj | [private]
m_posRect | CSimpSvrObj | [private]
m_red | CSimpSvrObj | [private]
m_scale | CSimpSvrObj | [private]
m_size | CSimpSvrObj | [private]
m_xOffset | CSimpSvrObj | [private]
m_yOffset | CSimpSvrObj | [private]
PaintObj(HDC hDC) | CSimpSvrObj |
QueryInterface(REFIID riid, LPVOID FAR *ppvObj) | CSimpSvrObj |
RotateColor() | CSimpSvrObj | [inline]
SaveToStorage(LPSTORAGE lpStg, BOOL fSameAsLoad) | CSimpSvrObj |
SendOnDataChange() | CSimpSvrObj |
SetColor(int nRed, int nGreen, int nBlue) | CSimpSvrObj | [inline]
STDMETHODIMP_(ULONG) AddRef() | CSimpSvrObj |
STDMETHODIMP_(ULONG) Release() | CSimpSvrObj |
~CSimpSvrObj() | CSimpSvrObj |
Generated on Wed Nov 13 2024 16:57:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

EXTENDER_NODE Member List

This is the complete list of members for EXTENDER_NODE, including all inherited members.
eType | EXTENDER_NODE
guidExtension | EXTENDER_NODE
guidNode | EXTENDER_NODE
szDescription | EXTENDER_NODE
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/sky.Cpp Source File

  • SysMgmt
  • MMC
  • Extens

sky.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Sky.h"
00021
00022 const GUID CSkyBasedVehicle::thisGuid = { 0x2974380f, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CSkyBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_WIDEDBIDMAP Member List

This is the complete list of members for _WIDEDBIDMAP, including all inherited members.
pDBID | _WIDEDBIDMAP
pwszName | _WIDEDBIDMAP
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/DebugHandler/DebugHandler.Cpp Source File

  • WinBase
  • Debug
  • DebugHandler

DebugHandler.Cpp

Go to the documentation of this file.
00001 /*----------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2002.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 DebugHandler.cpp
00011
00012 This file implements a command line utility that shows how to use
00013 Debugging API to trace an unhandled exception in a Win32 application
00014 as a post mortem debugger.
00015 --------------------------------------------------------------------*/
00016
00017 #include <windows.h>
00018 #include <stdio.h>
00019 #include <dbghelp.h>
00020 #include <tlhelp32.h>
00021
00022 void  InstallDebugger();
00023 DWORD DispatchDebugEventThread(DWORD pid, HANDLE hEvent);
00024 DWORD LogStackWalk(FILE *logFp,
00025                    HANDLE hProcess,
00026                    HANDLE hThread,
00027                    DWORD exceptionAddress);
00028
00029 /*  InstallDebugger installs the debugHandler.exe as a system debugger.
00030     This capability is controlled by the following registry key on
00031     Windows NT:
00032
00033     HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
00034
00035     This key contains the following entries:
00036
00037         Auto
00038         Debugger
00039
00040     These entries are also available on Windows 95/98. However, on
00041     Windows 95/98, they are contained in the win.ini file instead of
00042     the registry.  The section [aedebug] has entries that are similar
00043     to these registry values.
00044
00045     If the value of Auto is set to "0" (zero), then the system will generate
00046     a pop-up window, and if the user chooses Cancel, spawn the debugger that
00047     is specified in the Debugger value. If the value of Auto is set to "1",
00048     then the system will automatically spawn the debugger that is specified
00049     in the Debugger value.
00050 */
00051 void InstallDebugger()
00052 {
00053     OSVERSIONINFO   osver;
00054     char            Auto[] = "0";
00055     char            Debugger[MAX_PATH + 64];
00056     int             n;
00057
00058
00059     Debugger[0] = '\"';
00060
00061     /* Get the full path to the executable name */
00062     if (!GetModuleFileName(NULL, &Debugger[1], MAX_PATH))
00063     {
00064         printf("GetModuleFileName failed with error code : %d\n",
00065             GetLastError());
00066         Debugger[1] = '.';
00067         Debugger[2] = 0;
00068     }
00069
00070     n = strlen(Debugger);
00071     Debugger[n] = '\"';
00072
00073     /* Add -p and -e command line options */
00074     strcpy(&Debugger[n+1], " -p %ld -e %ld");
00075
00076     /* Check to see if we are running under Windows 9x or Windows NT */
00077
00078     osver.dwOSVersionInfoSize = sizeof(osver);
00079     if (!GetVersionEx(&osver))
00080     {
00081         printf("GetVersionEx failed with error code : %d\n",
00082             GetLastError());
00083         return;
00084     }
00085
00086     if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
00087     {
00088         /* On Windows NT, create registry values under AeDebug */
00089         HKEY hRegKey;
00090         LONG lResult;
00091
00092         lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
00093                 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug",
00094                 0,
00095                 KEY_SET_VALUE,
00096                 &hRegKey);
00097         if (lResult != ERROR_SUCCESS)
00098         {
00099             printf("RegOpenKeyEx failed with error code : %d\n",
00100                 lResult);
00101             return;
00102         }
00103         lResult = RegSetValueEx(hRegKey,
00104                         "Auto",
00105                         0,
00106                         REG_SZ,
00107                         (LPBYTE)Auto,
00108                         2);
00109         if (lResult != ERROR_SUCCESS)
00110         {
00111             printf("RegSetValueEx failed with error code : %d\n",
00112                 lResult);
00113         }
00114
00115         lResult = RegSetValueEx(hRegKey,
00116                         "Debugger",
00117                         0,
00118                         REG_SZ,
00119                         (LPBYTE)Debugger,
00120                         strlen(Debugger) + 1);
00121         if (lResult != ERROR_SUCCESS)
00122         {
00123             printf("RegSetValueEx failed with error code : %d\n",
00124                 lResult);
00125         }
00126
00127         RegCloseKey(hRegKey);
00128     }
00129     else if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00130     {
00131         /* On Windows 9x, create appropriate section values in win.ini */
00132         if (!WritePrivateProfileString("AeDebug",
00133             "Auto",
00134             Auto,
00135             "win.ini"))
00136         {
00137             printf("WritePrivateProfileString failed with error code : %d\n",
00138                 GetLastError());
00139         }
00140
00141         if (!WritePrivateProfileString("AeDebug",
00142             "Debugger",
00143             Debugger,
00144             "win.ini"))
00145         {
00146             printf("WritePrivateProfileString failed with error code : %d\n",
00147                 GetLastError());
00148         }
00149     }
00150 }
00151
00152 /* DispatchDebugEventThread attaches to a debuggee and waits for the
00153    debug events as a debugger using the debugging APIs. This function
00154    assumes a maximum of 1024 threads or 1024 child processes created by
00155    the debuggee process */
00156 DWORD DispatchDebugEventThread(DWORD pid, HANDLE hEvent)
00157 {
00158 #define MAX_THREADS   1024
00159
00160     HANDLE hProcess = NULL;
00161
00162     DWORD  dwThreadId[MAX_THREADS];
00163     HANDLE hThread[MAX_THREADS];
00164
00165     FILE   *logFp = NULL;
00166
00167     DEBUG_EVENT   de;
00168     DWORD         ContinueStatus;
00169     int           i;
00170     char          logFile[MAX_PATH + 64];
00171     BOOL          rc;
00172     DWORD64       base;
00173
00174     /* Get the Windows directory for creating the log file */
00175     logFile[0] = 0;
00176     if(!GetWindowsDirectory(logFile, MAX_PATH))
00177     {
00178         // GetWindowsDirectory Failed
00179         return 0;
00180     }
00181
00182
00183     if (logFile[0])
00184     {
00185         strcat(logFile, "\\DebugHandler.log");
00186         logFp = fopen(logFile, "a");
00187         if (!logFp) return 0;
00188     }
00189     else
00190         return 0;
00191
00192     /* Attach to the debuggee process */
00193     if (!DebugActiveProcess(pid))
00194     {
00195         fclose(logFp);
00196         logFp = 0;
00197         return 0;
00198     }
00199
00200     ZeroMemory(hThread, sizeof(hThread));
00201     ZeroMemory(dwThreadId, sizeof(dwThreadId));
00202
00203     while (TRUE)
00204     {
00205         /* Wait for a debug event */
00206         if (!WaitForDebugEvent(&de, 10000))
00207         {
00208             goto exit;
00209         }
00210         ContinueStatus = DBG_CONTINUE;
00211
00212         switch (de.dwDebugEventCode)
00213         {
00214             case EXCEPTION_DEBUG_EVENT:
00215                 /* The debugger process first initiates a breakpoint
00216                    in the debuggee. When this breakpoint debug event
00217                    is received by the debugger, we can set the event
00218                    handle here and break from the case to continue
00219                    the debuggee. When the debuggee continues, we will
00220                    get an exception debug event for the thread in the
00221                    debuggee. This event will be the exception that is
00222                    unhandled by the corresponding thread in the
00223                    debuggee */
00224                 if (de.u.Exception.ExceptionRecord.ExceptionCode
00225                     == EXCEPTION_BREAKPOINT)
00226                 {
00227                     if (hEvent)
00228                     {
00229                         SetEvent(hEvent);
00230                     }
00231                     break;
00232                 }
00233                 ContinueStatus = DBG_EXCEPTION_NOT_HANDLED;
00234
00235                 /* Search and find the handle to the thread
00236                    corresponding to the thread id. Then call
00237                    LogStackWalk for dumping the exception
00238                    stack trace of the corresponding thread
00239                    in the debuggee process */
00240                 for (i = 0; i < MAX_THREADS; i++)
00241                 {
00242                     if (dwThreadId[i] != de.dwThreadId) continue;
00243                     LogStackWalk(logFp,
00244                         hProcess,
00245                         hThread[i],
00246                         (DWORD)(de.u.Exception.
00247                         ExceptionRecord.ExceptionAddress));
00248                     break;
00249                 }
00250                 break;
00251
00252             case CREATE_THREAD_DEBUG_EVENT:
00253                 /* Store the thread handle and the thread id to be
00254                    used later in the EXCEPTION_DEBUG_EVENT */
00255                 for (i = 0; i < MAX_THREADS; i++)
00256                 {
00257                     if (dwThreadId[i]) continue;
00258                     dwThreadId[i] = de.dwThreadId;
00259                     hThread[i] = de.u.CreateThread.hThread;
00260                     break;
00261                 }
00262                 break;
00263
00264             case CREATE_PROCESS_DEBUG_EVENT:
00265                 /* Store the process handle to be used later in the
00266                    EXCEPTION_DEBUG_EVENT. Also the primary thread
00267                    handle and the corresponding thread id can be
00268                    stored here */
00269
00270                 hProcess = de.u.CreateProcessInfo.hProcess;
00271
00272                 /* We can initialize Symbol Handler functions of
00273                    dbghelp here and load the symbolic information
00274                    of the executable module */
00275
00276                 rc = SymInitialize(hProcess, 0, FALSE);
00277                 if (!rc)
00278                 {
00279                     printf("Error 0x%x calling SymInitialize()\n", GetLastError());
00280                     break;
00281                 }
00282                 base = SymLoadModuleEx(hProcess,
00283                                        de.u.CreateProcessInfo.hFile,
00284                                        0,
00285                                        0,
00286                                        0,
00287                                        0,
00288                                        NULL,
00289                                        0);
00290                 if (!base)
00291                 {
00292                     printf("Error 0x%x calling SymLoadModule(%s)\n",
00293                            GetLastError(),
00294                            de.u.CreateProcessInfo.hFile);
00295                     break;
00296                 }
00297                 for (i = 0; i < MAX_THREADS; i++)
00298                 {
00299                     if (dwThreadId[i]) continue;
00300                     dwThreadId[i] = de.dwThreadId;
00301                     hThread[i] = de.u.CreateProcessInfo.hThread;
00302                     break;
00303                 }
00304                 break;
00305
00306             case EXIT_THREAD_DEBUG_EVENT:
00307                 /* Remove the thread handle and the thread id from
00308                    our data structures */
00309                 for (i = 0; i < MAX_THREADS; i++)
00310                 {
00311                     if (dwThreadId[i] != de.dwThreadId) continue;
00312                     dwThreadId[i] = 0;
00313                     hThread[i] = 0;
00314                     break;
00315                 }
00316                 break;
00317
00318             case EXIT_PROCESS_DEBUG_EVENT:
00319                 /* Remove the thread handle and the thread id from
00320                    our data structures */
00321
00322                 /* We can also cleanup Symbol Handler functions of
00323                    dbghelp here */
00324
00325                 SymCleanup(hProcess);
00326                 hProcess = NULL;
00327
00328                 for (i = 0; i < MAX_THREADS; i++)
00329                 {
00330                     if (dwThreadId[i] != de.dwThreadId) continue;
00331                     dwThreadId[i] = 0;
00332                     hThread[i] = 0;
00333                     break;
00334                 }
00335                 goto exit;
00336                 break;
00337
00338             case LOAD_DLL_DEBUG_EVENT:
00339                 /* Load the symbolic information of the corresponding
00340                    DLL module */
00341                 base = SymLoadModuleEx(hProcess,
00342                                        de.u.LoadDll.hFile,
00343                                        0,
00344                                        0,
00345                                        0,
00346                                        0,
00347                                        NULL,
00348                                        0);
00349                 if (!base)
00350                     printf("Error 0x%x calling SymLoadModule(%s)\n",
00351                            GetLastError(),
00352                            de.u.CreateProcessInfo.hFile);
00353                 break;
00354
00355             case UNLOAD_DLL_DEBUG_EVENT:
00356                 break;
00357
00358             case OUTPUT_DEBUG_STRING_EVENT:
00359                 break;
00360
00361             case RIP_EVENT:
00362                 break;
00363
00364             default:
00365                 break;
00366         }
00367         ContinueDebugEvent(de.dwProcessId, de.dwThreadId, ContinueStatus);
00368     }
00369
00370 exit:
00371     fclose(logFp);
00372     logFp = 0;
00373     return 0;
00374 }
00375
00376 BOOL
00377 __stdcall
00378 ReadProcessMemory64(
00379     HANDLE      hProcess,
00380     DWORD64     qwBaseAddress,
00381     PVOID       lpBuffer,
00382     DWORD       nSize,
00383     LPDWORD     lpNumberOfBytesRead
00384     )
00385 {
00386     return ReadProcessMemory(hProcess,
00387                              (LPCVOID)(ULONG_PTR)qwBaseAddress,
00388                              lpBuffer,
00389                              nSize,
00390                              lpNumberOfBytesRead);
00391 }
00392
00393 /* LogStackWalk function to use dbghelp API for dumping the stack trace
00394    of the corresponding exception in a debuggee thread */
00395
00396 DWORD LogStackWalk(FILE *logFp,
00397                    HANDLE hProcess,
00398                    HANDLE hThread,
00399                    DWORD exceptionAddress)
00400 {
00401     DWORD64           dwDisplacement = 0;
00402     DWORD             frames = 0;
00403     LPSTR             szSymName;
00404     IMAGEHLP_MODULE64 mi;
00405     DWORD             machType;
00406     CONTEXT           Context;
00407     STACKFRAME64      stk;
00408     char              buffer[1024];
00409
00410     PIMAGEHLP_SYMBOL64  sym = (PIMAGEHLP_SYMBOL64)buffer;
00411
00412     /* Get the thread context of hThread for calling StackWalk */
00413     Context.ContextFlags = CONTEXT_FULL;
00414     if (!GetThreadContext(hThread, &Context))
00415     {
00416         fprintf(logFp, "GetThreadContext returned error code : %d\n",
00417             GetLastError());
00418         return EXCEPTION_EXECUTE_HANDLER;
00419     }
00420     ZeroMemory(&stk, sizeof(stk));
00421
00422     machType = IMAGE_FILE_MACHINE_I386;
00423     stk.AddrPC.Offset       = exceptionAddress;
00424     stk.AddrPC.Mode         = AddrModeFlat;
00425     stk.AddrStack.Offset    = Context.Esp;
00426     stk.AddrStack.Mode      = AddrModeFlat;
00427     stk.AddrFrame.Offset    = Context.Ebp;
00428     stk.AddrFrame.Mode      = AddrModeFlat;
00429
00430     memset(buffer, 0, sizeof(buffer));
00431     sym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
00432     sym->MaxNameLength = sizeof(buffer) - sizeof(IMAGEHLP_SYMBOL);
00433
00434     /* Call StackWalk to retrieve all the stack frames */
00435     while (StackWalk64(machType,
00436                         hProcess,
00437                         hThread,
00438                         &stk,
00439                         &Context,
00440                         ReadProcessMemory64,
00441                         SymFunctionTableAccess64,
00442                         SymGetModuleBase64,
00443                         0) && stk.AddrPC.Offset)
00444     {
00445         sym->Address = stk.AddrPC.Offset;
00446         dwDisplacement = 0;
00447
00448         /* Get the function name corresponding to the code address */
00449         if (SymGetSymFromAddr64(hProcess,
00450                                 stk.AddrPC.Offset,
00451                                 &dwDisplacement,
00452                                 sym))
00453         {
00454             szSymName = sym->Name;
00455         }
00456         else
00457         {
00458
00459             szSymName = "<nosymbols>";
00460             fprintf(logFp, "SymGetSymFromAddr returned error code : %d\n",
00461                 GetLastError());
00462         }
00463         fprintf(logFp, "%08x %08x %08x %08x %08x %08x ",
00464                   stk.AddrFrame.Offset,
00465                   stk.AddrReturn.Offset,
00466                   stk.Params[0],
00467                   stk.Params[1],
00468                   stk.Params[2],
00469                   stk.Params[3]);
00470
00471         /* Get the module name corresponding to the code address */
00472         if (SymGetModuleInfo64(hProcess, stk.AddrPC.Offset, &mi))
00473         {
00474             fprintf(logFp, "%s!", mi.ModuleName);
00475         }
00476
00477         fprintf(logFp, "%s\n", szSymName);
00478
00479         if (!stk.AddrReturn.Offset)
00480         {
00481             break;
00482         }
00483     }
00484
00485     fprintf(logFp, "\n");
00486
00487     return EXCEPTION_EXECUTE_HANDLER;
00488 }
00489
00490 void main(int argc, char** argv)
00491 {
00492     DWORD   pid = 0;
00493     HANDLE  hEvent = 0;
00494
00495     // This program will accept the following command line arguments similar
00496     // to all post mortem debuggers
00497     // -p <process id>
00498     // -e <event handle>
00499
00500     if (argc > 1)
00501     {
00502         // If "-i" option is specified, then install the debugger
00503         if (!strcmpi(argv[1], "-i"))
00504         {
00505             InstallDebugger();
00506             return;
00507         }
00508
00509         // If "-p" option is specified, get the process id value from
00510         // the next argument
00511         if (!strcmpi(argv[1], "-p"))
00512         {
00513             if (argc > 2)
00514             {
00515                 pid = atoi(argv[2]);
00516             }
00517         }
00518     }
00519
00520     if (argc > 3)
00521     {
00522         // If "-e" option is specified, get the event handle value from
00523         // the next argument
00524         if (!strcmpi(argv[3], "-e"))
00525         {
00526             if (argc > 4)
00527             {
00528                 hEvent = (HANDLE)atoi(argv[4]);
00529             }
00530         }
00531     }
00532
00533     if (pid)
00534     {
00535         DispatchDebugEventThread(pid, hEvent);
00536     }
00537 }
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Pipes/Include/pipe.hxx Source File

  • Com
  • Fundamentals
  • Pipes
  • Include

pipe.hxx

Go to the documentation of this file.
00001 #ifndef __PIPE_HXX__
00002 #define __PIPE_HXX__
00003
00004 #include "objbase.h"
00005 #include "iostream.h"
00006
00007 #define BUF_SIZE 2000;
00008 #define OPTIMUM_SIZE 800;
00009
00010 /***** Helper functions ********************/
00011
00012 STDMETHODIMP GenericPull(IPipeLong *pPipe, LONG *buff, ULONG *pPulled, ULONG lElements);
00013
00014 STDMETHODIMP GenericPush(IPipeLong *pPipe, LONG *buff, ULONG lElements);
00015
00016 STDMETHODIMP PopulateBuffer(long *buff, DWORD dwElementsCount,
00017                           DWORD dwStartIdx);
00018 STDMETHODIMP DrainBuffer(long *buff,
00019                             DWORD dwElementsCount,
00020                             DWORD dwStartIdx);
00021
00022 /********** Sample Pipe ***************************/
00023
00024 class CSamplePipe : public IPipeLong
00025 {
00026 protected:
00027    LONG    m_cRef;
00028    ULONG   m_nPushSeq, m_nPullSeq;
00029    LONG   *m_pBuffer;
00030    DWORD   m_dwOutPipeRcvd;
00031    DWORD   m_dwInPipeSent;
00032
00033 public:
00034    CSamplePipe();
00035    ~CSamplePipe();
00036
00037    // IUnknown
00038    STDMETHODIMP QueryInterface (REFIID iid, void **ppv);
00039    STDMETHODIMP_(ULONG) AddRef(void);
00040    STDMETHODIMP_(ULONG) Release(void);
00041
00042    // IPipeLong
00043    STDMETHODIMP Pull(long *buf, ULONG cRequest, ULONG *pcReturned);
00044    STDMETHODIMP Push(long *buf, ULONG cSent);
00045 };
00046
00047 #endif // __PIPE_HXX__
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/ATMEvent/Sender.Cpp Source File

  • NetDS
  • WinSock
  • ATMEvent

Sender.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      sender.cpp
00010 //
00011 // Abstract:
00012 //      Implement send-side functionality.  The sender uses a combination of
00013 //      WSASend and WSAEventSelect to support sending of data on the socket.
00014 //
00015 // Entry Points:
00016 //      Sender - send contents of data buffer to receiver program.
00017 //
00018 // Author:
00019 //      Barry R. Butterklee
00020
00021 #include "atmevent.h"
00022
00023
00024 #define WSAEVENTSELECT_EVENT 0
00025 #define WSASEND_EVENT 1
00026 #define TOTAL_EVENTS 2
00027
00028
00029 // encapsulate socket, events, buffers, and various flags and counters that
00030 // control how/when data is sent into a structure
00031 typedef struct _SEND_INFO
00032 {
00033     SOCKET          sd;
00034     WSAEVENT        hEvents[2];     // WSASend and WSAEventSelect events
00035     WSAOVERLAPPED   ovr;
00036     BOOL            bSendEnabled;
00037     BOOL            bSendComplete;
00038     int             nTotalSends;
00039     WSABUF          sndbuf;
00040 } SEND_INFO;
00041
00042
00043
00044 static BOOL CreateSendingSocket(SEND_INFO *, OPTIONS *);
00045 static BOOL fd_connect_func(DWORD, WSANETWORKEVENTS *, SEND_INFO *, OPTIONS *);
00046 static BOOL fd_close_func(DWORD, WSANETWORKEVENTS *, SEND_INFO *, OPTIONS *);
00047 static BOOL PostSend(SEND_INFO *, OPTIONS *);
00048 static BOOL CompleteSend(SEND_INFO *, OPTIONS *);
00049
00050
00051
00052 // Abstract:
00053 //      Main function to establish connection to a server and then
00054 //      send data to server.  WSASend and WSAEventSelect are used to send data
00055 //      and monitor socket activity, respectively.
00056 //
00057 //      Due to the nature of this application - just sending data in a loop -
00058 //      FD_WRITE is not suitable whereas using WSASend with overlapped I/O is.
00059 //      The reason is because FD_WRITE will only be delivered after the inital
00060 //      connection has been established and only after sends block would
00061 //      WSAEWOULDBLOCK and buffer space becomes available once again.  Thus
00062 //      WSAWaitForMultipleEvents waits on the event associated with overlapped
00063 //      structure passed to WSASend AND the event associated with WSAEventSelect.
00064 //
00065 VOID Sender(
00066            OPTIONS             *pOptions
00067            )
00068 {
00069     WSANETWORKEVENTS    NetworkEvents = {0};
00070     BOOL                bProcessEventsDone = FALSE;
00071     SEND_INFO           SendInfo = {0};
00072     int                 i = 0;
00073     BOOL                bDisableQos = TRUE;
00074     ULONG               cbAlternateCount = 0;
00075
00076
00077     printf("Sender\n");
00078
00079     SendInfo.sd = INVALID_SOCKET;
00080
00081     for (i = 0; i < TOTAL_EVENTS; i++)
00082         SendInfo.hEvents[i] = WSA_INVALID_EVENT;
00083
00084
00085
00086     for (i=0; i<TOTAL_EVENTS; i++)
00087     {
00088         if (WSA_INVALID_EVENT == (SendInfo.hEvents[i] = WSACreateEvent()))
00089         {
00090             printf("WSACreateEvent(%d): failed w/%d\n", i, WSAGetLastError());
00091             goto CLEANUP;
00092         }
00093     }
00094     SendInfo.sd           = INVALID_SOCKET;
00095     ZeroMemory((char *)&SendInfo.ovr, sizeof(SendInfo.ovr));
00096     SendInfo.ovr.hEvent   = SendInfo.hEvents[WSASEND_EVENT];
00097     SendInfo.sndbuf.buf   = pOptions->buf;
00098     SendInfo.sndbuf.len   = pOptions->nBufSize;
00099     SendInfo.nTotalSends  = 0;
00100     SendInfo.bSendEnabled = TRUE;
00101
00102     if (!CreateSendingSocket(&SendInfo, pOptions))
00103         goto CLEANUP;
00104
00105
00106     while (!bProcessEventsDone)
00107     {
00108         DWORD dwEvent;
00109
00110         dwEvent = WSAWaitForMultipleEvents(TOTAL_EVENTS, SendInfo.hEvents, FALSE, WSA_INFINITE, FALSE);
00111         switch (dwEvent)
00112         {
00113         case WSA_WAIT_FAILED:
00114             printf("WSAEventSelect: %d\n", WSAGetLastError());
00115             break;
00116         case WAIT_IO_COMPLETION:
00117         case WSA_WAIT_TIMEOUT:
00118             break;
00119
00120         default:
00121             dwEvent -= WSA_WAIT_EVENT_0;
00122
00123             if (WSAEVENTSELECT_EVENT == dwEvent)
00124             {
00125                 // lets see what network activity trigged this event
00126                 if (SOCKET_ERROR == WSAEnumNetworkEvents(SendInfo.sd, SendInfo.hEvents[WSAEVENTSELECT_EVENT], &NetworkEvents))
00127                 {
00128                     printf("WSAEnumNetworkEvent: failed w/%d lNetworkEvent %X\n",
00129                            WSAGetLastError(), NetworkEvents.lNetworkEvents);
00130                     NetworkEvents.lNetworkEvents = 0;
00131                 } else
00132                 {
00133                     if (FD_CONNECT     & NetworkEvents.lNetworkEvents)
00134                         bProcessEventsDone |=
00135                         fd_connect_func(dwEvent, &NetworkEvents, &SendInfo, pOptions);
00136                     if (FD_CLOSE   & NetworkEvents.lNetworkEvents)
00137                         bProcessEventsDone |=
00138                         fd_close_func(dwEvent, &NetworkEvents, &SendInfo, pOptions);
00139                 }
00140             } else
00141             {
00142                 bProcessEventsDone = CompleteSend(&SendInfo, pOptions);
00143             }
00144         }
00145
00146         // allow pauses between notifications
00147         if (pOptions->dwSleep)
00148             Sleep(pOptions->dwSleep);
00149
00150     } // while (!bProcessEventsDone)
00151
00152
00153     CLEANUP:
00154     if (INVALID_SOCKET != SendInfo.sd)
00155     {
00156         closesocket(SendInfo.sd);
00157         SendInfo.sd = INVALID_SOCKET;
00158     }
00159     for (i=0; i<TOTAL_EVENTS; i++)
00160         if(WSA_INVALID_EVENT != SendInfo.hEvents[i])
00161         {
00162             WSACloseEvent(SendInfo.hEvents[i]);
00163             SendInfo.hEvents[i] = WSA_INVALID_EVENT;
00164         }
00165
00166
00167
00168     return;
00169 }
00170
00171
00172
00173
00174 // Abstract:
00175 //      Create a socket on which to send data.  Please note that WSA_FLAG_OVERLAPPED
00176 //      *MUST* be specified.  Also, note that the parameters for WSASocket and the data
00177 //      to fill in the SOCKADDR structure come from the supplied protocol info structure
00178 //      instead of being hardcoded.
00179 //
00180 //      The socket can request the connection to support a specific QoS during the connect.
00181 //
00182 static BOOL CreateSendingSocket(
00183                                SEND_INFO           *pSendInfo,
00184                                OPTIONS             *pOptions
00185                                )
00186 {
00187     DWORD           dwSocketFlags = 0;
00188     SOCKADDR_ATM    sockaddr = {0};
00189     QOS             *pQos = NULL;
00190     int             nAddrLen = 0;
00191     long            lNetworkEvents = 0;
00192     int             nRet = 0;
00193
00194
00195     dwSocketFlags = WSA_FLAG_OVERLAPPED;
00196     pSendInfo->sd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
00197                               &pOptions->protocolInfo, 0, dwSocketFlags);
00198     if (INVALID_SOCKET == pSendInfo->sd)
00199     {
00200         printf("socket failed w/%d", WSAGetLastError());
00201         return FALSE;
00202     }
00203
00204     // set up the address structure of the destination which is needed on connect
00205     // and/or sendto operations.
00206     ZeroMemory(&sockaddr, sizeof(sockaddr));
00207     nAddrLen = sizeof(sockaddr);
00208     nRet = WSAStringToAddress(pOptions->szRemoteInterface, AF_ATM, &pOptions->protocolInfo,
00209                               (LPSOCKADDR)&sockaddr, &nAddrLen);
00210     if (SOCKET_ERROR == nRet)
00211     {
00212         printf("WSAAddressToString: failed w/%d\n", WSAGetLastError());
00213         return FALSE;
00214     }
00215     // fill in remainder of ATM address structure not set using WSAStringToAddress
00216     sockaddr.satm_family                 = AF_ATM;
00217     sockaddr.satm_number.AddressType     = ATM_NSAP;
00218     sockaddr.satm_number.NumofDigits     = ATM_ADDR_SIZE;
00219     sockaddr.satm_blli.Layer2Protocol    = SAP_FIELD_ANY;
00220     sockaddr.satm_blli.Layer3Protocol    = SAP_FIELD_ABSENT;
00221     sockaddr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
00222
00223
00224     lNetworkEvents = (FD_CONNECT | FD_CLOSE);
00225     if (SOCKET_ERROR == WSAEventSelect(pSendInfo->sd, pSendInfo->hEvents[WSAEVENTSELECT_EVENT], lNetworkEvents))
00226     {
00227         printf("WSAEventSelect: failed w/%d\n", WSAGetLastError());
00228         return FALSE;
00229     }
00230
00231     pQos = NULL;
00232     nRet = WSAConnect(pSendInfo->sd,
00233                       (LPSOCKADDR)&sockaddr, sizeof(sockaddr),
00234                       NULL, NULL, pQos, NULL);
00235     if (SOCKET_ERROR == nRet)
00236     {
00237         DWORD dwErr = WSAGetLastError();
00238         if (WSAEWOULDBLOCK != dwErr)
00239         {
00240             printf("WSAConnect: failed w/%d\n", dwErr);
00241             return FALSE;
00242         }
00243     }
00244
00245     return TRUE;
00246 }
00247
00248
00249
00250
00251
00252
00253
00254 // Abstract:
00255 //      FD_CONNECT handler.  This handler is invoked when an asynchronous connect
00256 //      completes, successfully or otherwise.  After the socket connects
00257 //      additional notifications will be enabled using WSAEventSelect.
00258 //
00259 //
00260 static BOOL fd_connect_func(
00261                            DWORD               dwEvent,
00262                            WSANETWORKEVENTS    *NetworkEvents,
00263                            SEND_INFO           *pSendInfo,
00264                            OPTIONS             *pOptions
00265                            )
00266 {
00267     BOOL    bProcessEventsDone = FALSE;
00268     int     nRet = 0;
00269
00270
00271     printf("  FD_CONNECT: dwEvent=%d error code =%d\n",
00272            dwEvent, NetworkEvents->iErrorCode[FD_CONNECT_BIT]);
00273     if (NetworkEvents->iErrorCode[FD_CONNECT_BIT] != 0)
00274         bProcessEventsDone = TRUE;
00275     else
00276     {
00277         nRet = WSAEventSelect(pSendInfo->sd, pSendInfo->hEvents[WSAEVENTSELECT_EVENT], (FD_CLOSE));
00278         if (SOCKET_ERROR == nRet)
00279         {
00280             printf("WSAEventSelect: failed w/%d\n", WSAGetLastError());
00281             bProcessEventsDone = FALSE;
00282         }
00283
00284         pSendInfo->bSendEnabled = TRUE;
00285
00286         // post initial send
00287         bProcessEventsDone = PostSend(pSendInfo, pOptions);
00288     }
00289
00290     return bProcessEventsDone;
00291 }
00292
00293
00294
00295
00296
00297 // Abstract:
00298 //      FD_CLOSE handler.   If server closes before we have sent all the data, then
00299 //      we are done.  Winsock2 events are manual reset events and FD_CLOSE has no
00300 //      re-enabling function, therefore must reset the event here, otherwise we would
00301 //      get additional FD_CLOSE notifications.
00302 //
00303 static BOOL fd_close_func(
00304                          DWORD               dwEvent,
00305                          WSANETWORKEVENTS    *NetworkEvents,
00306                          SEND_INFO           *pSendInfo,
00307                          OPTIONS             *pOptions
00308                          )
00309 {
00310     BOOL bProcessEventsDone = TRUE;
00311
00312     printf("  FD_CLOSE: dwEvent=%d error code =%d\n",
00313            dwEvent, NetworkEvents->iErrorCode[FD_CLOSE_BIT]);
00314     WSAResetEvent(pSendInfo->hEvents[WSAEVENTSELECT_EVENT]);
00315     if (pOptions->dwSleepClose)
00316         Sleep(pOptions->dwSleepClose);
00317     if (INVALID_SOCKET != pSendInfo->sd)
00318     {
00319         closesocket(pSendInfo->sd);
00320         pSendInfo->sd = INVALID_SOCKET;
00321     }
00322     return bProcessEventsDone;
00323 }
00324
00325
00326
00327
00328 // Abstract:
00329 //      Post an overlapped send and indicate a send is in progress if it doesn't
00330 //      complete immediately.  If the WSASend completes immediately bump the
00331 //      counters and indicate the send completed.  The send flag is needed to
00332 //      what needs to be done in CompleteSend() - wait for overlapped results
00333 //      or post another send.
00334 //
00335 static BOOL PostSend(
00336                     SEND_INFO   *pSendInfo,
00337                     OPTIONS     *pOptions
00338                     )
00339 {
00340     int     nRet = 0;
00341     DWORD   cbBytesXfer = 0;
00342     BOOL    bProcessEventsDone = FALSE;
00343
00344
00345     printf("  PostSend\n");
00346     if (pSendInfo->bSendEnabled)
00347     {
00348         pSendInfo->bSendComplete = FALSE;
00349         nRet = WSASend(pSendInfo->sd, &pSendInfo->sndbuf, 1, &cbBytesXfer, 0,
00350                        &pSendInfo->ovr, NULL);
00351         if (0 == nRet)
00352         {
00353             // the send completed immediately
00354             pSendInfo->bSendComplete = TRUE;
00355             pSendInfo->sndbuf.len -= cbBytesXfer;
00356             pSendInfo->sndbuf.buf += cbBytesXfer;
00357         } else if (SOCKET_ERROR == nRet)
00358         {
00359             DWORD dwErr = WSAGetLastError();
00360             if (WSA_IO_PENDING != dwErr)
00361             {
00362                 printf("WSASend failed w/%d\n", dwErr);
00363                 bProcessEventsDone = TRUE;
00364             }
00365         }
00366     }
00367     return bProcessEventsDone;
00368 }
00369
00370
00371
00372
00373 // Abstract:
00374 //      Handle the completion of a WSASend.  This may involve posting another
00375 //      overlapped send or closing the socket.
00376 //
00377 static BOOL CompleteSend(
00378                         SEND_INFO   *pSendInfo,
00379                         OPTIONS     *pOptions
00380                         )
00381 {
00382     BOOL    bProcessEventsDone = FALSE;
00383     DWORD   dwFlags = 0;
00384     DWORD   cbBytesXfer = 0;
00385
00386     printf("  CompleteSend\n");
00387     if (!pSendInfo->bSendComplete)
00388     {
00389         // handle getting overlapped results
00390         if (!WSAGetOverlappedResult(pSendInfo->sd, &pSendInfo->ovr, &cbBytesXfer, TRUE, &dwFlags))
00391         {
00392             printf("WSAGetOverlappedResult = %d\n", WSAGetLastError());
00393             bProcessEventsDone = TRUE;
00394         } else
00395         {
00396             pSendInfo->bSendComplete = TRUE;
00397             pSendInfo->sndbuf.len -= cbBytesXfer;
00398             pSendInfo->sndbuf.buf += cbBytesXfer;
00399         }
00400     }
00401
00402     if (pSendInfo->sndbuf.len > 0)
00403     {
00404         PostSend(pSendInfo, pOptions);
00405         bProcessEventsDone = FALSE;
00406     } else
00407     {
00408         // we have sent the entire buffer, check repeat count to
00409         // see if buffer needs to be sent again.
00410         if (pOptions->nRepeat)
00411             pSendInfo->nTotalSends++;
00412         else
00413             pSendInfo->nTotalSends = -1;
00414         pSendInfo->sndbuf.buf = pOptions->buf;
00415         pSendInfo->sndbuf.len = pOptions->nBufSize;
00416         if (pSendInfo->nTotalSends <= pOptions->nRepeat-1)
00417         {
00418             PostSend(pSendInfo, pOptions);
00419             bProcessEventsDone = FALSE;
00420         } else
00421         {
00422             printf("    repeat count complete - closing\n");
00423             if (pOptions->dwSleepClose)
00424                 Sleep(pOptions->dwSleepClose);
00425             if (INVALID_SOCKET != pSendInfo->sd)
00426             {
00427                 closesocket(pSendInfo->sd);
00428                 pSendInfo->sd = INVALID_SOCKET;
00429             }
00430             bProcessEventsDone = TRUE;
00431             WSAResetEvent(pSendInfo->hEvents[WSASEND_EVENT]);
00432         }
00433     }
00434
00435     return bProcessEventsDone;
00436 }
00437
00438
00439
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/EDITCTLS.h Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

EDITCTLS.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // PURPOSE:
00009 //    Contains public declarations for the EditCtls module.
00010 //
00011
00012 BOOL InitEditCtls(HWND hWndParent);
00013 void SizeEditCtls();
00014 void SetFocusEditCtls();
00015
00016 void WriteToDisplayCtl(LPSTR lpNewString, DWORD dwSizeofNewString);
00017 BOOL PostWriteToDisplayCtl(LPSTR lpNewString, DWORD dwSizeofNewString);
00018
00019
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoServe/PAPER.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoServe

PAPER.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAPER.H
00003
00004   Summary:   Include file for the connectable COPaper COM object class.
00005
00006              COPaper offers a main standard IUnknown interface (basic COM
00007              object features), an implementation of the standard
00008              IConnectionPointContainer interface (connectable object
00009              features), and an implementation of the custom IPaper
00010              interface (drawing Paper-related features). This multiple
00011              interface COM Object Class is achieved via the technique of
00012              nested classes.  The implementation of the
00013              IConnectionPointContainer and IPaper interfaces are nested
00014              inside of the COPaper Class.
00015
00016              APPUTIL's CThreaded OwnThis technology is used in COPaper to
00017              ensure mutually exclusive access by contending multiple
00018              client threads.
00019
00020              For a comprehensive tutorial code tour of this module's
00021              contents and offerings see the tutorial STOSERVE.HTM file.
00022              For more specific technical details on the internal workings
00023              see the comments dispersed throughout the module's source code.
00024
00025   Functions: .
00026
00027   Classes:   COPaper.
00028
00029   Origin:    6-10-96: atrent - Editor-inheritance from BALL.H in
00030              the CONSERVE Tutorial Code Sample.
00031
00032 ----------------------------------------------------------------------------
00033   This file is part of the Microsoft COM Tutorial Code Samples.
00034
00035   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00036
00037   This source code is intended only as a supplement to Microsoft
00038   Development Tools and/or on-line documentation.  See these other
00039   materials for detailed information regarding Microsoft code samples.
00040
00041   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00042   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00043   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00044   PARTICULAR PURPOSE.
00045 ==========================================================================+*/
00046
00047 #if !defined(PAPER_H)
00048 #define PAPER_H
00049
00050 #ifdef __cplusplus
00051
00052
00053 // Current format version of Ink Data is 1.0. Thus, the format version
00054 // is a compile-time constant.
00055 #define INKDATA_VERSION10 MAKELONG(0,1)
00056
00057 // InkData allocation sizes for the Dynamic InkData array.
00058 enum
00059 {
00060   INKDATA_ALLOC_INIT = 3200,
00061   INKDATA_ALLOC = 800
00062 };
00063
00064 // The types of Ink Data.
00065 #define INKTYPE_NONE  0
00066 #define INKTYPE_START 1
00067 #define INKTYPE_DRAW  2
00068 #define INKTYPE_STOP  3
00069
00070 // The Ink Data structure.
00071 typedef struct _INKDATA
00072 {
00073   SHORT nType;            // Ink Type.
00074   SHORT nX;               // X-coordinate of ink point.
00075   SHORT nY;               // Y-coordinate of ink point.
00076   SHORT nWidth;           // Ink line width.
00077   COLORREF crColor;       // Ink color.
00078 } INKDATA;
00079
00080
00081 // Properties of our electronic paper.
00082 #define PAPER_TITLE_SIZE 64
00083 typedef struct _PAPER_PROPERTIES
00084 {
00085   LONG lInkDataVersion;
00086   LONG lInkArraySize;
00087   COLORREF crWinColor;
00088   RECT WinRect;
00089   WCHAR wszTitle[PAPER_TITLE_SIZE];
00090   WCHAR wszAuthor[PAPER_TITLE_SIZE];
00091   WCHAR wszReserved1[PAPER_TITLE_SIZE];
00092   WCHAR wszReserved2[PAPER_TITLE_SIZE];
00093 } PAPER_PROPERTIES;
00094
00095
00096 // Drawing Paper event constants.
00097 enum PAPER_EVENT
00098 {
00099   PAPER_EVENT_NONE = 0,
00100   PAPER_EVENT_LOCKED,
00101   PAPER_EVENT_UNLOCKED,
00102   PAPER_EVENT_LOADED,
00103   PAPER_EVENT_SAVED,
00104   PAPER_EVENT_INKSTART,
00105   PAPER_EVENT_INKDRAW,
00106   PAPER_EVENT_INKSTOP,
00107   PAPER_EVENT_ERASED,
00108   PAPER_EVENT_RESIZED
00109 };
00110
00111 // Some strings used in file storage.
00112 #define STREAM_PAPERDATA_USTR L"PAPERDATA"
00113 #define CLIPBDFMT_STR "DllPaper1.0"
00114
00115
00116 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00117   ObjectClass: COPaper
00118
00119   Summary:     COM object class for COPaper COM objects.  COM objects of
00120                this class offer custom IPaper interface features,
00121                InitPaper, Lock, Unlock, Load, Save, InkStart, InkDraw,
00122                InkStop, Erase, Resize, and Redraw. To make COPaper objects
00123                connectable, the standard IConnectionPointContainer
00124                interface features, FindConnectionPoint and
00125                EnumConnectionPoints are also implemented. The mulitple
00126                interfaces on this COM object are constructed via the
00127                nested interface classes technique. COPaper is also derived
00128                from APPUTIL's CThreaded to provide the OwnThis thread
00129                safety mechanism.
00130
00131   Interfaces:  IUnknown
00132                  Standard interface providing COM object features.
00133                IConnectionPointContainer
00134                  Standard Connection Point container features rendering
00135                  COPaper objects connectable objects.
00136                IPaper
00137                  Custom interface providing basic electronic drawing paper
00138                  features.
00139
00140   Aggregation: Yes, COPaper COM Objects are aggregatable by passing
00141                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00142 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00143 class COPaper : public IUnknown, public CThreaded
00144 {
00145   public:
00146     // Main Object Constructor & Destructor.
00147     COPaper(IUnknown* pUnkOuter, CServer* pServer);
00148     ~COPaper(void);
00149
00150     // A general method for initializing this newly created object.
00151     // Creates any subordinate arrays, structures, or objects.
00152     HRESULT Init(void);
00153
00154     // IUnknown methods. Main object, non-delegating.
00155     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00156     STDMETHODIMP_(ULONG) AddRef(void);
00157     STDMETHODIMP_(ULONG) Release(void);
00158
00159   private:
00160     // We declare nested class interface implementations here.
00161
00162     class CImpIConnectionPointContainer : public IConnectionPointContainer,
00163                                           public CThreaded
00164     {
00165       public:
00166         // Interface Implementation Constructor & Destructor.
00167         CImpIConnectionPointContainer(COPaper* pBackObj, IUnknown* pUnkOuter);
00168         ~CImpIConnectionPointContainer(void);
00169
00170         // IUnknown methods.
00171         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00172         STDMETHODIMP_(ULONG) AddRef(void);
00173         STDMETHODIMP_(ULONG) Release(void);
00174
00175         // IConnectionPointContainer methods.
00176         STDMETHODIMP         FindConnectionPoint(REFIID, IConnectionPoint**);
00177         STDMETHODIMP         EnumConnectionPoints(IEnumConnectionPoints**);
00178
00179       private:
00180         // Data private to this interface implementation.
00181         COPaper*      m_pBackObj;     // Parent Object back pointer.
00182         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00183     };
00184
00185     class CImpIPaper : public IPaper, public CThreaded
00186     {
00187       public:
00188         // Interface Implementation Constructor & Destructor.
00189         CImpIPaper(COPaper* pBackObj, IUnknown* pUnkOuter);
00190         ~CImpIPaper(void);
00191
00192         // IUnknown methods.
00193         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00194         STDMETHODIMP_(ULONG) AddRef(void);
00195         STDMETHODIMP_(ULONG) Release(void);
00196
00197         // IPaper methods.
00198         STDMETHODIMP         InitPaper(RECT* pWinRect, BOOL* pbFirst);
00199         STDMETHODIMP         Lock(SHORT* pnLockKey);
00200         STDMETHODIMP         Unlock(SHORT nLockKey);
00201         STDMETHODIMP         Load(SHORT nLockKey, IStorage* pIStorage);
00202         STDMETHODIMP         Save(SHORT nLockKey, IStorage* pIStorage);
00203         STDMETHODIMP         InkStart(
00204                                SHORT nLockKey,
00205                                SHORT nX,
00206                                SHORT nY,
00207                                SHORT nWidth,
00208                                COLORREF crInkColor);
00209         STDMETHODIMP         InkDraw(SHORT nLockKey, SHORT nX, SHORT nY);
00210         STDMETHODIMP         InkStop(SHORT nLockKey, SHORT nX, SHORT nY);
00211         STDMETHODIMP         Erase(SHORT nLockKey);
00212         STDMETHODIMP         Resize(
00213                                SHORT nLockKey,
00214                                SHORT nWidth,
00215                                SHORT nHeight);
00216         STDMETHODIMP         Redraw(SHORT nLockKey);
00217
00218       private:
00219         // Data private to this interface implementation of IPaper.
00220         COPaper*      m_pBackObj;     // Parent Object back pointer.
00221         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00222
00223         // The following private data and methods constitute the working
00224         // heart of COPaper as an actual application object.
00225         PAPER_PROPERTIES m_PaperProperties; // For file storage.
00226         UINT          m_ClipBdFmt;    // ClipBoard Format.
00227         BOOL          m_bLocked;      // Paper lock state.
00228         SHORT         m_cLockKey;     // Paper lock key counter.
00229         RECT          m_WinRect;      // Current Window rectangle.
00230         COLORREF      m_crWinColor;   // Current window background color.
00231         COLORREF      m_crInkColor;   // Current ink color.
00232         SHORT         m_nInkWidth;    // Current ink width.
00233         LONG          m_lInkDataEnd;  // Current end of the ink data.
00234         LONG          m_lInkDataMax;  // Current end of the ink data array.
00235         INKDATA*      m_paInkData;    // Dynamic Ink data array pointer.
00236
00237         // Private utility methods of this interface implementation.
00238         HRESULT NextSlot(void);
00239     };
00240
00241     // Make the otherwise private and nested IPaper and
00242     // IConnectionPointContainer interface implementations a friend to
00243     // COM object instantiations of this COPaper COM object class.
00244     friend CImpIConnectionPointContainer;
00245     friend CImpIPaper;
00246
00247     // Private method of main connectable COPaper COM object to broadcast
00248     // event notifications to all connected listening sinks.
00249     HRESULT NotifySinks(
00250               PAPER_EVENT PaperEvent,
00251               SHORT nX,
00252               SHORT nY,
00253               SHORT nInkWidth,
00254               COLORREF crInkColor);
00255
00256     // Private data of COPaper COM objects.
00257
00258     // Nested IPaper implementation instantiation.  This IPaper interface
00259     // is instantiated inside this COPaper object as a native interface.
00260     CImpIPaper        m_ImpIPaper;
00261
00262     // Nested IConnectionPointContainer implementation instantiation.
00263     CImpIConnectionPointContainer m_ImpIConnectionPointContainer;
00264
00265     // Main Object reference count.
00266     ULONG             m_cRefs;
00267
00268     // Outer unknown (aggregation & delegation).
00269     IUnknown*         m_pUnkOuter;
00270
00271     // Pointer to this component server's control object.
00272     CServer*          m_pServer;
00273
00274     // The array of connection points for this connectable COM object.
00275     IConnectionPoint* m_aConnectionPoints[MAX_CONNECTION_POINTS];
00276 };
00277
00278 typedef COPaper* PCOPaper;
00279
00280 #endif // __cplusplus
00281
00282
00283 #endif // PAPER_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFrameWndLite Member List

This is the complete list of members for CFrameWndLite, including all inherited members.
CFrameWndLite() | CFrameWndLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, HICON hIcon, DWORD dwStyle=WS_OVERLAPPEDWINDOW, DWORD dwExStyle=WS_EX_APPWINDOW, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CFrameWndLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CFrameWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CFrameWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CFrameWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnToolTip(INT idCtrl, NMHDR *pNMHDR) | CFrameWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PreTranslateMessage(MSG *pmsg) | CFrameWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CFrameWndLite() | CFrameWndLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authorization/dbauthplugin.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • Authorization

dbauthplugin.cpp

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName: DBAuthPlugin.cpp
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011 #include "stdafx.h"
00012 #include "DBAuth.h"
00013 #include "DBAuthPlugin.h"
00014 #include "DBAuthAdmin.h"
00015
00016 #define AUTHORIZED_USERS_PROPERTY L"AuthorizedUsers"
00017
00018 const NUM_AUTHORIZED_EVENTS = 1;
00019
00020 /////////////////////////////////////////////////////////////////////////////
00021 /////////////////////////////////////////////////////////////////////////////
00022 CDBAuthPlugin::CDBAuthPlugin()
00023     : m_pSids( NULL )
00024 {
00025     InitializeCriticalSection( &m_CritSec );
00026 }
00027
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 /////////////////////////////////////////////////////////////////////////////
00031 CDBAuthPlugin::~CDBAuthPlugin()
00032 {
00033     // Lock when accessing member variables
00034     if( NULL != m_pSids )
00035     {
00036         delete m_pSids;
00037     }
00038     DeleteCriticalSection( &m_CritSec );
00039 }
00040
00041 ///////////////////////////////////////////////////////////////////////////////
00042 /////////////////////////////////////////////////////////////////////////////
00043 void CDBAuthPlugin::Lock()
00044 {
00045     EnterCriticalSection( &m_CritSec );
00046 }
00047
00048 ///////////////////////////////////////////////////////////////////////////////
00049 /////////////////////////////////////////////////////////////////////////////
00050 void CDBAuthPlugin::Unlock()
00051 {
00052     LeaveCriticalSection( &m_CritSec );
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 /////////////////////////////////////////////////////////////////////////////
00057 STDMETHODIMP CDBAuthPlugin::InitializePlugin
00058 (
00059     IWMSContext *pServerContext,
00060     IWMSNamedValues *pNamedValues,
00061     IWMSClassObject *pClassFactory
00062 )
00063 {
00064     if( ( NULL == pServerContext )
00065         || ( NULL == pNamedValues )
00066         || ( NULL == pClassFactory ) )
00067     {
00068         return( E_INVALIDARG );
00069     }
00070
00071     HRESULT hr = S_OK;
00072     IWMSServer* pWMSServer = NULL;
00073     DWORD dwCount = 0;
00074
00075     // Lock when accessing member variables
00076     Lock();
00077
00078     do
00079     {
00080         hr = pServerContext->GetAndQueryIUnknownValue( const_cast<LPWSTR>( WMS_SERVER ), WMS_SERVER_ID,
00081                                                    IID_IWMSServer, (IUnknown**)&pWMSServer, 0 );
00082         if( FAILED( hr ) )
00083         {
00084             break;
00085         }
00086
00087         ATLASSERT( NULL != pWMSServer );
00088         m_spServer.Attach( pWMSServer );
00089         if( NULL == m_spServer.p )
00090         {
00091             hr = E_NOINTERFACE;
00092             break;
00093         }
00094
00095         m_spNamedValues = pNamedValues;
00096         if( NULL == m_spNamedValues.p )
00097         {
00098             hr = E_NOINTERFACE;
00099             break;
00100         }
00101
00102         CSids *pSids = new CSids;
00103         if( NULL == pSids )
00104         {
00105             hr = E_OUTOFMEMORY;
00106             break;
00107         }
00108
00109         if( NULL != m_pSids )
00110         {
00111             delete m_pSids;
00112         }
00113         m_pSids = pSids;
00114         pSids = NULL;
00115
00116         // Get setting from namespace
00117         hr = m_pSids->GetAuthorizedUsers( m_spNamedValues );
00118         if( FAILED( hr ) )
00119         {
00120             // ignore error when not able to get setting from namespace
00121             hr = S_OK;
00122         }
00123
00124
00125         // TODO: Add any additional initialization here
00126
00127     }
00128     while( FALSE );
00129
00130     Unlock();
00131
00132     return( hr );
00133 }
00134
00135
00136 /////////////////////////////////////////////////////////////////////////////
00137 /////////////////////////////////////////////////////////////////////////////
00138 STDMETHODIMP CDBAuthPlugin::EnablePlugin( long *pdwFlags, long *pdwHeartbeatPeriod )
00139 {
00140     if( NULL == pdwFlags || NULL == pdwHeartbeatPeriod )
00141     {
00142         return ( E_POINTER );
00143     }
00144
00145     // Set the heartbeat period in milliseconds
00146     *pdwHeartbeatPeriod = 0000;
00147
00148     return ( S_OK );
00149 }
00150
00151
00152 /////////////////////////////////////////////////////////////////////////////
00153 /////////////////////////////////////////////////////////////////////////////
00154 STDMETHODIMP CDBAuthPlugin::DisablePlugin()
00155 {
00156     return ( S_OK );
00157 }
00158
00159
00160 /////////////////////////////////////////////////////////////////////////////
00161 /////////////////////////////////////////////////////////////////////////////
00162 STDMETHODIMP CDBAuthPlugin::ShutdownPlugin()
00163 {
00164     HRESULT hr = S_OK;
00165
00166     // Lock when accessing member variables
00167     Lock();
00168
00169     m_spServer = NULL;
00170     m_spNamedValues = NULL;
00171
00172     if( NULL != m_pSids )
00173     {
00174         delete m_pSids;
00175     }
00176     m_pSids = NULL;
00177
00178     Unlock();
00179
00180     return( hr );
00181 }
00182
00183
00184 /////////////////////////////////////////////////////////////////////////////
00185 /////////////////////////////////////////////////////////////////////////////
00186 STDMETHODIMP CDBAuthPlugin::OnHeartbeat()
00187 {
00188     HRESULT hr = S_OK;
00189
00190     // TODO: Add code that should execute on every Heartbeat Period
00191     return( hr );
00192 }
00193
00194
00195 /////////////////////////////////////////////////////////////////////////////
00196 /////////////////////////////////////////////////////////////////////////////
00197 STDMETHODIMP CDBAuthPlugin::GetCustomAdminInterface( IDispatch **ppValue )
00198 {
00199     if( ( NULL == ppValue ) )
00200     {
00201         return( E_INVALIDARG );
00202     }
00203
00204     HRESULT hr = S_OK;
00205
00206     *ppValue = NULL;
00207
00208     CComObject<CDBAuthAdmin> *spDBAuthAdmin;
00209
00210     hr = CComObject<CDBAuthAdmin>::CreateInstance( &spDBAuthAdmin );
00211     if( SUCCEEDED( hr ) )
00212     {
00213         hr = spDBAuthAdmin->Initialize( this /*, m_spNamedValues */ );
00214         if( SUCCEEDED( hr ) )
00215         {
00216             hr = spDBAuthAdmin->QueryInterface( IID_IDispatch, (void **) ppValue );
00217         }
00218     }
00219
00220     return( hr );
00221 }
00222
00223 /////////////////////////////////////////////////////////////////////////////
00224 /////////////////////////////////////////////////////////////////////////////
00225 STDMETHODIMP CDBAuthPlugin::GetAuthorizedEvents( VARIANT *pvarAuthorizedEvents )
00226 {
00227     if( NULL == pvarAuthorizedEvents )
00228     {
00229         return( E_INVALIDARG );
00230     }
00231
00232     HRESULT hr = S_OK;
00233     int nIndex = 0;
00234     WMS_EVENT_TYPE wmsAuthorizedEvents[ NUM_AUTHORIZED_EVENTS ];
00235
00236     wmsAuthorizedEvents[ nIndex++ ] = WMS_EVENT_OPEN;
00237
00238     hr = CreateArrayOfEvents( pvarAuthorizedEvents, wmsAuthorizedEvents, NUM_AUTHORIZED_EVENTS );
00239     return( hr );
00240 }
00241
00242
00243 /////////////////////////////////////////////////////////////////////////////
00244 /////////////////////////////////////////////////////////////////////////////
00245 STDMETHODIMP CDBAuthPlugin::AuthorizeEvent
00246 (
00247     WMS_EVENT *pEvent,
00248     IWMSContext *pUserCtx,
00249     IWMSContext *pPresentationCtx,
00250     IWMSCommandContext *pCommandCtx,
00251     IWMSEventAuthorizationCallback *pCallback,
00252     VARIANT Context
00253 )
00254 {
00255     HRESULT hrAuth = HRESULT_FROM_WIN32( ERROR_NO_SUCH_USER );
00256     HRESULT hr = S_OK;
00257
00258     //
00259     // The event information must be valid in order to determine what
00260     // type of event needs to be authorized.
00261     //
00262     if( ( NULL == pEvent ) )
00263     {
00264         return( E_INVALIDARG );
00265     }
00266
00267     //
00268     // The input contexts may be NULL if they are not defined for the
00269     // specified event.  Verify that any context you intend to use is
00270     // not NULL before using it.  If you need to use context that is
00271     // NULL, return E_INVALIDARG to notify the server of the problem.
00272     //
00273
00274     switch( pEvent->Type )
00275     {
00276     case WMS_EVENT_CONNECT:
00277         break;
00278     case WMS_EVENT_OPEN:
00279         hrAuth = OnAuthorizeOpen( pUserCtx, pPresentationCtx, pCommandCtx );
00280         break;
00281     case WMS_EVENT_PLAY:
00282         break;
00283     case WMS_EVENT_GET_PARAMETER:
00284         break;
00285     case WMS_EVENT_SET_PARAMETER:
00286         break;
00287     case WMS_EVENT_VALIDATE_PUSH_DISTRIBUTION:
00288         break;
00289     }
00290
00291     hr = pCallback->OnAuthorizeEvent( hrAuth, Context );
00292     return( hr );
00293 }
00294
00295 /////////////////////////////////////////////////////////////////////////////
00296 /////////////////////////////////////////////////////////////////////////////
00297 HRESULT CDBAuthPlugin::CreateArrayOfEvents( VARIANT *pvarEvents, WMS_EVENT_TYPE *pWMSEvents, long nNumEvents)
00298 {
00299     HRESULT hr = S_OK;
00300     long iEvents = 0;
00301     SAFEARRAY *psa = NULL;
00302     SAFEARRAYBOUND rgsabound[ 1 ];
00303
00304     if( NULL == pvarEvents )
00305     {
00306         return( E_POINTER );
00307     }
00308
00309     if( NULL == pWMSEvents || 0 >= nNumEvents )
00310     {
00311         return( E_INVALIDARG );
00312     }
00313
00314     rgsabound[ 0 ].lLbound = 0;
00315     rgsabound[ 0 ].cElements = nNumEvents;
00316
00317     psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
00318
00319     if( NULL == psa )
00320     {
00321         return ( E_OUTOFMEMORY );
00322     }
00323
00324     for( iEvents = 0; iEvents < nNumEvents && SUCCEEDED( hr ); iEvents++ )
00325     {
00326         VARIANT varElement;
00327
00328         VariantInit( &varElement );
00329
00330         V_VT( &varElement ) = VT_I4;
00331         V_I4( &varElement ) = pWMSEvents[ iEvents ];
00332
00333         hr = SafeArrayPutElement( psa, &iEvents, &varElement );
00334         VariantClear( &varElement );
00335     }
00336
00337     if( FAILED( hr ) )
00338     {
00339         SafeArrayDestroy( psa );
00340         psa = NULL;
00341     }
00342     else
00343     {
00344         V_VT( pvarEvents ) = VT_ARRAY | VT_VARIANT;
00345         V_ARRAY( pvarEvents ) = psa;
00346     }
00347
00348     return( hr );
00349 }
00350
00351
00352 /////////////////////////////////////////////////////////////////////////////
00353 /////////////////////////////////////////////////////////////////////////////
00354 // Event Authorization Helper Functions
00355 HRESULT CDBAuthPlugin::OnAuthorizeOpen( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx )
00356 {
00357     // return S_OK if Open is Authorized, otherwise return E_ACCESSDENIED
00358
00359     HRESULT hr = S_OK;
00360     BOOL bFound = FALSE;
00361     LPWSTR wstrUser = NULL;
00362
00363     do
00364     {
00365         hr = pUserCtx->GetStringValue( const_cast<LPWSTR>( WMS_USER_NAME ),
00366                                        WMS_USER_NAME_ID,
00367                                        &wstrUser,
00368                                        WMS_CONTEXT_GET_PROPERTY_STRING_BY_REFERENCE );
00369         if( FAILED( hr ) )
00370         {
00371             break;
00372         }
00373
00374         DWORD dwIndex = 0;
00375         hr = VerifyUserMembership( wstrUser, &bFound, &dwIndex );
00376
00377     }
00378     while( FALSE );
00379
00380     if( SUCCEEDED( hr ) && bFound )
00381     {
00382         return( S_OK );
00383     }
00384     else
00385     {
00386         return( E_ACCESSDENIED );
00387     }
00388 }
00389
00390 /////////////////////////////////////////////////////////////////////////////
00391 /////////////////////////////////////////////////////////////////////////////
00392 HRESULT CDBAuthPlugin::VerifyUserMembership( LPCWSTR pwszUserName, BOOL *pfFound, DWORD *pdwIndex )
00393 {
00394
00395     if( ( NULL == pfFound ) || ( NULL == pdwIndex ) )
00396     {
00397         return( E_INVALIDARG );
00398     }
00399
00400     if( ( NULL == pwszUserName ) || ( L'\0' == (WCHAR*) *pwszUserName ) )
00401     {
00402         return( E_INVALIDARG );
00403     }
00404
00405     HRESULT hr = S_OK;
00406     PSID pSid = NULL;
00407
00408     do
00409     {
00410         hr = GetSIDFromName( pwszUserName, &pSid );
00411         if( FAILED( hr ) )
00412         {
00413             break;
00414         }
00415
00416         *pfFound = VerifySidMembership( pSid, pdwIndex );
00417
00418     }
00419     while( FALSE );
00420
00421     if( NULL != pSid )
00422     {
00423         LocalFree( pSid );
00424         pSid = NULL;
00425     }
00426
00427     return( hr );
00428
00429 }
00430
00431 /////////////////////////////////////////////////////////////////////////////
00432 /////////////////////////////////////////////////////////////////////////////
00433 BOOL CDBAuthPlugin::VerifySidMembership( PSID pSid, DWORD *pdwIndex )
00434 {
00435
00436     BOOL bFound = FALSE;
00437
00438     if( ( NULL == pSid ) || ( NULL == pdwIndex ) )
00439     {
00440         return( bFound );
00441     }
00442
00443     // Lock when accessing member variables
00444     Lock();
00445
00446     if( NULL != m_pSids )
00447     {
00448         bFound = m_pSids->MatchSid( pSid, pdwIndex );
00449     }
00450
00451     Unlock();
00452
00453     return( bFound );
00454
00455 }
00456
00457 /////////////////////////////////////////////////////////////////////////////
00458 /////////////////////////////////////////////////////////////////////////////
00459 HRESULT CDBAuthPlugin::AddUser( LPCWSTR pwszUserName )
00460 {
00461     if( ( NULL == pwszUserName ) || ( L'\0' == (WCHAR*) *pwszUserName ) )
00462     {
00463         return( E_INVALIDARG );
00464     }
00465
00466     HRESULT hr = S_OK;
00467     PSID pSid = NULL;
00468     CSids *pNewSids = NULL;
00469
00470     // Lock when accessing member variables
00471     Lock();
00472
00473     do
00474     {
00475         if( NULL == m_pSids )
00476         {
00477             hr = E_FAIL;
00478             break;
00479         }
00480
00481         hr = GetSIDFromName( pwszUserName, &pSid );
00482         if( FAILED( hr ) )
00483         {
00484             break;
00485         }
00486
00487         BOOL bFound = FALSE;
00488         DWORD dwIndex = 0;
00489         bFound = VerifySidMembership( pSid, &dwIndex );
00490
00491         if( bFound )
00492         {
00493             // the user already in the list
00494             // no further action required
00495             break;
00496         }
00497
00498         // create a new CSids and add the user Sid
00499         hr = m_pSids->CopyAndAddSid( pSid, &pNewSids );
00500         if( FAILED( hr ) )
00501         {
00502             break;
00503         }
00504
00505         // persist data using the newly created Sid array
00506         hr = pNewSids->SetAuthorizedUsers( m_spNamedValues );
00507         if( FAILED( hr ) )
00508         {
00509             break;
00510         }
00511
00512         // succeeded in creating new Sids and persist data
00513         // change member variables
00514         m_pSids->CleanUp( FALSE );
00515         delete m_pSids;
00516         m_pSids = pNewSids;
00517
00518         // set pNewSids and pSid to NULL so they won't be deleted later
00519         pNewSids = NULL;
00520         pSid = NULL;
00521
00522     }
00523     while( FALSE );
00524
00525     Unlock();
00526
00527     if( NULL != pNewSids )
00528     {
00529         pNewSids->CleanUp( FALSE );
00530         delete pNewSids;
00531     }
00532
00533     if( NULL != pSid )
00534     {
00535         LocalFree( pSid );
00536         pSid = NULL;
00537     }
00538
00539     return( hr );
00540
00541 }
00542
00543 /////////////////////////////////////////////////////////////////////////////
00544 /////////////////////////////////////////////////////////////////////////////
00545 HRESULT CDBAuthPlugin::RemoveUser( LPCWSTR pwszUserName )
00546 {
00547     if( ( NULL == pwszUserName ) || ( L'\0' == (WCHAR*) *pwszUserName ) )
00548     {
00549         return( E_INVALIDARG );
00550     }
00551
00552     HRESULT hr = S_OK;
00553     BOOL bFound = FALSE;
00554     CSids *pNewSids = NULL;
00555
00556     // Lock when accessing member variables
00557     Lock();
00558
00559     do
00560     {
00561         if( NULL == m_pSids )
00562         {
00563             hr = E_FAIL;
00564             break;
00565         }
00566
00567         if( 0 == m_pSids->m_cItems )
00568         {
00569             // no user in the list
00570             // no further action required
00571             break;
00572         }
00573
00574         DWORD dwIndexFound = 0;
00575         hr = VerifyUserMembership( pwszUserName, &bFound, &dwIndexFound );
00576         if( FAILED( hr ) )
00577         {
00578             break;
00579         }
00580
00581         if( !bFound )
00582         {
00583             // the user is not in the list
00584             // no further action required
00585             break;
00586         }
00587
00588         hr = m_pSids->CopyAndRemoveItem( dwIndexFound, &pNewSids );
00589         if( FAILED( hr ) )
00590         {
00591             break;
00592         }
00593
00594         // persist data using the newly created Sid array
00595         hr = pNewSids->SetAuthorizedUsers( m_spNamedValues );
00596         if( FAILED( hr ) )
00597         {
00598             break;
00599         }
00600
00601         // succeeded in creating new Sids and persist data
00602         // change member variables
00603         LocalFree( m_pSids->m_pSidList[ dwIndexFound ] );
00604         m_pSids->CleanUp( FALSE );
00605         delete m_pSids;
00606         m_pSids = pNewSids;
00607
00608         // set pNewSids to NULL so they won't be deleted later
00609         pNewSids = NULL;
00610
00611     }
00612     while( FALSE );
00613
00614     Unlock();
00615
00616     if( NULL != pNewSids )
00617     {
00618         pNewSids->CleanUp( FALSE );
00619         delete pNewSids;
00620     }
00621
00622     return( hr );
00623
00624 }
00625
00626 /////////////////////////////////////////////////////////////////////////////
00627 /////////////////////////////////////////////////////////////////////////////
00628 HRESULT CDBAuthPlugin::GetUsers( BSTR *pbstrUserNames )
00629 {
00630     if( NULL == pbstrUserNames )
00631     {
00632         return( E_INVALIDARG );
00633     }
00634
00635     HRESULT hr = S_OK;
00636
00637     // Lock when accessing member variables
00638     Lock();
00639
00640     do
00641     {
00642         if( NULL == m_pSids )
00643         {
00644             hr = E_FAIL;
00645             break;
00646         }
00647
00648         hr = m_pSids->GetUsers( pbstrUserNames );
00649
00650     }
00651     while( FALSE );
00652
00653     Unlock();
00654
00655     return( hr );
00656
00657 }
00658
00659 /////////////////////////////////////////////////////////////////////////////
00660 /////////////////////////////////////////////////////////////////////////////
00661 HRESULT CDBAuthPlugin::GetSIDFromName( LPCWSTR pwszUserName, PSID *ppSid )
00662 {
00663     // Translate the user name into a SID
00664
00665     if( NULL == ppSid )
00666     {
00667         return( E_INVALIDARG );
00668     }
00669
00670     HRESULT hr = S_OK;
00671     DWORD dwRetVal = 0;
00672     SID_NAME_USE SidNameUse;
00673     DWORD cbSid = 0;
00674     DWORD cbDomainName = 0;
00675     LPWSTR wstrDomainName = NULL;
00676     BOOL fRetVal = FALSE;
00677
00678     do
00679     {
00680         if( !LookupAccountName( NULL,
00681                                 pwszUserName,
00682                                 NULL,
00683                                 &cbSid,
00684                                 NULL,
00685                                 &cbDomainName,
00686                                 &SidNameUse ) )
00687         {
00688             dwRetVal = GetLastError();
00689             if( ERROR_INSUFFICIENT_BUFFER != dwRetVal )
00690             {
00691                 hr = HRESULT_FROM_WIN32( dwRetVal );
00692                 break;
00693             }
00694         }
00695
00696         *ppSid = (SID *) LocalAlloc( LPTR, cbSid );
00697         if( NULL == *ppSid )
00698         {
00699             hr = E_OUTOFMEMORY;
00700             break;
00701         }
00702
00703         wstrDomainName = new WCHAR[ cbDomainName ];
00704         if( NULL == wstrDomainName )
00705         {
00706             hr = E_OUTOFMEMORY;
00707             break;
00708         }
00709
00710         fRetVal = LookupAccountName( NULL,
00711                                      pwszUserName,
00712                                      *ppSid,
00713                                      &cbSid,
00714                                      wstrDomainName,
00715                                      &cbDomainName,
00716                                      &SidNameUse );
00717
00718         if( !fRetVal )
00719         {
00720             dwRetVal = GetLastError();
00721             hr = HRESULT_FROM_WIN32( dwRetVal );
00722             break;
00723         }
00724
00725     }
00726     while( FALSE );
00727
00728     if( NULL != wstrDomainName )
00729     {
00730         delete [] wstrDomainName;
00731     }
00732
00733     if( FAILED( hr ) && ( NULL != *ppSid ) )
00734     {
00735         LocalFree( *ppSid );
00736         *ppSid = NULL;
00737     }
00738
00739     return( hr );
00740 }
00741
00742 /////////////////////////////////////////////////////////////////////////////
00743 /////////////////////////////////////////////////////////////////////////////
00744 void CSids::CleanUp( BOOL fFreeSid )
00745 {
00746
00747     if( fFreeSid && ( 0 != m_cItems ) && ( NULL != m_pSidList ) )
00748     {
00749         // Free the pSidList information
00750         for( DWORD dwIndex = 0; dwIndex < m_cItems; dwIndex ++ )
00751         {
00752             if( NULL != m_pSidList[ dwIndex ] )
00753             {
00754                 LocalFree( m_pSidList[ dwIndex ] );
00755             }
00756         }
00757     }
00758
00759     m_cItems = 0;
00760
00761     if( NULL != m_pSidList )
00762     {
00763         delete [] m_pSidList;
00764         m_pSidList = NULL;
00765     }
00766
00767     return;
00768 }
00769
00770 /////////////////////////////////////////////////////////////////////////////
00771 /////////////////////////////////////////////////////////////////////////////
00772 BOOL CSids::MatchSid( PSID pSid, DWORD *pdwIndex )
00773 {
00774
00775     BOOL bFound = FALSE;
00776
00777     do
00778     {
00779         if( NULL == m_pSidList )
00780         {
00781             break;
00782         }
00783
00784         for( DWORD dwIndex = 0; dwIndex < m_cItems; dwIndex ++ )
00785         {
00786             if( ( NULL != m_pSidList[ dwIndex ] )
00787                 && EqualSid( m_pSidList[ dwIndex], pSid ) )
00788             {
00789                 bFound = TRUE;
00790                 *pdwIndex = dwIndex;
00791                 break;
00792             }
00793         }
00794     }
00795     while( FALSE );
00796
00797     return( bFound );
00798
00799 }
00800
00801 /////////////////////////////////////////////////////////////////////////////
00802 /////////////////////////////////////////////////////////////////////////////
00803 HRESULT CSids::CopyAndAddSid( PSID pSid, CSids **ppSids )
00804 {
00805     HRESULT hr = S_OK;
00806     CSids *pNewSids = NULL;
00807
00808     do
00809     {
00810         pNewSids = new CSids;
00811         if( NULL == pNewSids )
00812         {
00813             hr = E_OUTOFMEMORY;
00814             break;
00815         }
00816
00817         pNewSids->m_pSidList = new PSID[ m_cItems + 1 ];
00818         if( NULL == pNewSids->m_pSidList )
00819         {
00820             hr = E_OUTOFMEMORY;
00821             break;
00822         }
00823
00824         pNewSids->m_cItems = m_cItems + 1;
00825
00826         // copy the Sids to the new array
00827         for( DWORD dwIndex = 0; dwIndex < m_cItems; dwIndex++ )
00828         {
00829             pNewSids->m_pSidList[ dwIndex ] = m_pSidList[ dwIndex ];
00830         }
00831         pNewSids->m_pSidList[ m_cItems ] = pSid;
00832
00833     }
00834     while( FALSE );
00835
00836     if( SUCCEEDED( hr ) )
00837     {
00838         *ppSids = pNewSids;
00839     }
00840     else if( NULL != pNewSids )
00841     {
00842         pNewSids->CleanUp( FALSE );
00843         delete pNewSids;
00844     }
00845
00846     return( hr );
00847 }
00848
00849 /////////////////////////////////////////////////////////////////////////////
00850 /////////////////////////////////////////////////////////////////////////////
00851 HRESULT CSids::CopyAndRemoveItem( DWORD dwIndexRemove, CSids **ppSids )
00852 {
00853     HRESULT hr = S_OK;
00854     CSids *pNewSids = NULL;
00855     DWORD dwIndex = 0;
00856
00857     do
00858     {
00859         if( ( 0 == m_cItems ) || ( dwIndex >= m_cItems ) )
00860         {
00861             hr = E_INVALIDARG;
00862             break;
00863         }
00864
00865         pNewSids = new CSids;
00866         if( NULL == pNewSids )
00867         {
00868             hr = E_OUTOFMEMORY;
00869             break;
00870         }
00871
00872         if( m_cItems > 1 )
00873         {
00874             pNewSids->m_pSidList = new PSID[ m_cItems - 1 ];
00875             if( NULL == pNewSids->m_pSidList )
00876             {
00877                 hr = E_OUTOFMEMORY;
00878                 break;
00879             }
00880
00881             pNewSids->m_cItems = m_cItems - 1;
00882
00883             // copy the Sids to the new array
00884             for( dwIndex = 0; dwIndex < dwIndexRemove; dwIndex ++ )
00885             {
00886                 pNewSids->m_pSidList[ dwIndex ] = m_pSidList[ dwIndex ];
00887             }
00888             for( dwIndex = dwIndexRemove + 1; dwIndex < m_cItems; dwIndex ++ )
00889             {
00890                 pNewSids->m_pSidList[ dwIndex - 1 ] = m_pSidList[ dwIndex ];
00891             }
00892         }
00893
00894     }
00895     while( FALSE );
00896
00897     if( SUCCEEDED( hr ) )
00898     {
00899         *ppSids = pNewSids;
00900     }
00901     else if( NULL != pNewSids )
00902     {
00903         pNewSids->CleanUp( FALSE );
00904         delete pNewSids;
00905     }
00906
00907     return( hr );
00908 }
00909
00910 /////////////////////////////////////////////////////////////////////////////
00911 /////////////////////////////////////////////////////////////////////////////
00912 HRESULT CSids::SetAuthorizedUsers( IWMSNamedValues *pNamedValues )
00913 {
00914     if( NULL == pNamedValues )
00915     {
00916         return( E_INVALIDARG );
00917     }
00918
00919     HRESULT hr = S_OK;
00920     DWORD dwIndex = 0;
00921     IWMSNamedValue * pValue = NULL;
00922     CComVariant varValue;
00923     BSTR bstrPropName = NULL;
00924     BYTE *pBuf = NULL;
00925     SAFEARRAY* psa = NULL;
00926     BOOL fPsaAccessed = FALSE;
00927
00928     // size of m_cItems and one DWORD for each item to store the size of Sid
00929     DWORD dwBufSize = sizeof( m_cItems ) + m_cItems * sizeof( DWORD );
00930
00931     do
00932     {
00933         // find the total buffer size required to store the Sid list
00934         for( dwIndex = 0; dwIndex < m_cItems; dwIndex ++ )
00935         {
00936             if( NULL != m_pSidList[ dwIndex ] )
00937             {
00938                 dwBufSize += GetLengthSid( m_pSidList[ dwIndex ] );
00939             }
00940         }
00941
00942         // create a safearry to store the Sid list
00943         SAFEARRAYBOUND rgsabound[ 1 ];
00944         rgsabound[ 0 ].lLbound = 0;
00945         rgsabound[ 0 ].cElements = dwBufSize;
00946         psa = SafeArrayCreate( VT_UI1, 1, rgsabound );
00947         if( NULL == psa )
00948         {
00949             hr = E_OUTOFMEMORY;
00950             break;
00951         }
00952
00953         V_VT( &varValue ) = VT_ARRAY | VT_UI1;
00954         V_ARRAY( &varValue ) = psa;
00955
00956         hr = SafeArrayAccessData( psa, (void **) &pBuf );
00957         if( FAILED( hr ) )
00958         {
00959             break;
00960         }
00961
00962         fPsaAccessed = TRUE;
00963
00964         // copy Sid list to buffer
00965         BYTE *p = pBuf;
00966         memcpy( p, &m_cItems, sizeof( m_cItems ) );
00967         p += sizeof( m_cItems );
00968         for( dwIndex = 0; dwIndex < m_cItems; dwIndex ++ )
00969         {
00970             DWORD dwSize = 0;
00971             if( NULL == m_pSidList[ dwIndex ] )
00972             {
00973                 memcpy( p, &dwSize, sizeof( dwSize ) );
00974                 p += sizeof( dwSize );
00975             }
00976             else
00977             {
00978                 dwSize = GetLengthSid( m_pSidList[ dwIndex ] );
00979                 memcpy( p, &dwSize, sizeof( dwSize ) );
00980                 p += sizeof( dwSize );
00981                 memcpy( p, m_pSidList[ dwIndex ], dwSize );
00982                 p += dwSize;
00983             }
00984         }
00985
00986         bstrPropName = SysAllocString( AUTHORIZED_USERS_PROPERTY );
00987         if( NULL == bstrPropName )
00988         {
00989             hr = E_OUTOFMEMORY;
00990             break;
00991         }
00992
00993         // persist the sid data to namespace
00994         hr = pNamedValues->Add( bstrPropName, varValue, &pValue );
00995
00996     }
00997     while( FALSE );
00998
00999     //
01000     // cleanup local variables
01001     //
01002     if( ( NULL == psa ) && fPsaAccessed )
01003     {
01004         SafeArrayUnaccessData( psa );
01005     }
01006
01007     if( NULL != pValue )
01008     {
01009         pValue->Release();
01010     }
01011
01012     if( NULL != bstrPropName )
01013     {
01014         SysFreeString( bstrPropName );
01015     }
01016
01017     return( hr );
01018 }
01019
01020 /////////////////////////////////////////////////////////////////////////////
01021 /////////////////////////////////////////////////////////////////////////////
01022 HRESULT CSids::GetAuthorizedUsers( IWMSNamedValues *pNamedValues )
01023 {
01024     if( NULL == pNamedValues )
01025     {
01026         return( E_INVALIDARG );
01027     }
01028
01029     CleanUp();
01030
01031     HRESULT hr = S_OK;
01032     IWMSNamedValue * pValue = NULL;
01033     SAFEARRAY* psa = NULL;
01034     BOOL fPsaAccessed = FALSE;
01035     CComVariant varValue;
01036     VARIANT varPropName;
01037     VariantInit( &varPropName );
01038
01039     do
01040     {
01041
01042         BSTR bstrPropName = NULL;
01043         bstrPropName = SysAllocString( AUTHORIZED_USERS_PROPERTY );
01044         if( NULL == bstrPropName )
01045         {
01046             hr = E_OUTOFMEMORY;
01047             break;
01048         }
01049
01050         // bstrPropName will be free by varPropName
01051         V_VT(&varPropName) = VT_BSTR;
01052         V_BSTR( &varPropName ) = bstrPropName;
01053
01054         // Get the authorized users from namespace
01055         hr = pNamedValues->get_Item( varPropName, &pValue );
01056         if( FAILED( hr ) )
01057         {
01058             // no value found
01059             break;
01060         }
01061
01062         hr = pValue->get_Value( &varValue );
01063         if( FAILED( hr ) )
01064         {
01065             break;
01066         }
01067
01068         if( ( VT_ARRAY | VT_UI1 ) != V_VT( &varValue ) )
01069         {
01070             hr = E_FAIL;
01071             break;
01072         }
01073
01074         psa = V_ARRAY( &varValue );
01075
01076         DWORD dwBufSize = psa->rgsabound[ 0 ].cElements;
01077         DWORD dwCount = 0;
01078         if( dwBufSize < sizeof( dwCount ) )
01079         {
01080             hr = E_FAIL;
01081             break;
01082         }
01083
01084         BYTE *pBuf = NULL;
01085         hr = SafeArrayAccessData( psa, (void **) &pBuf );
01086         if( FAILED( hr ) )
01087         {
01088             break;
01089         }
01090
01091         fPsaAccessed = TRUE;
01092
01093         memcpy( &dwCount, pBuf, sizeof( dwCount ) );
01094         pBuf += sizeof( dwCount );
01095         dwBufSize -= sizeof( dwCount );
01096
01097         m_pSidList = new PSID[ dwCount ];
01098         if( NULL == m_pSidList )
01099         {
01100             hr = E_OUTOFMEMORY;
01101             break;
01102         }
01103
01104         m_cItems = dwCount;
01105
01106         for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex ++ )
01107         {
01108             m_pSidList[ dwIndex ] = NULL;
01109         }
01110
01111         for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex ++ )
01112         {
01113             DWORD dwSize = 0;
01114             if( dwBufSize < sizeof( dwSize ) )
01115             {
01116                 hr = E_FAIL;
01117                 break;
01118             }
01119
01120             memcpy( &dwSize, pBuf, sizeof( dwSize ) );
01121             pBuf += sizeof( dwSize );
01122             dwBufSize -= sizeof( dwSize );
01123
01124             if( 0 != dwSize )
01125             {
01126                 if( dwBufSize < dwSize )
01127                 {
01128                     hr = E_FAIL;
01129                     break;
01130                 }
01131
01132                 m_pSidList[ dwIndex ] = (SID *) LocalAlloc( LPTR, dwSize );
01133                 if( NULL == m_pSidList[ dwIndex ] )
01134                 {
01135                     hr = E_OUTOFMEMORY;
01136                     break;
01137                 }
01138                 memcpy( m_pSidList[ dwIndex ], pBuf, dwSize );
01139                 pBuf += dwSize;
01140                 dwBufSize -= dwSize;
01141             }
01142         }
01143     }
01144     while( FALSE );
01145
01146     if( FAILED( hr ) )
01147     {
01148         CleanUp();
01149     }
01150
01151     if( ( NULL == psa ) && fPsaAccessed )
01152     {
01153         SafeArrayUnaccessData( psa );
01154     }
01155
01156     //
01157     // cleanup local variables
01158     //
01159     if( NULL != pValue )
01160     {
01161         pValue->Release();
01162     }
01163
01164     VariantClear( &varPropName );
01165
01166     return( hr );
01167 }
01168
01169 /////////////////////////////////////////////////////////////////////////////
01170 /////////////////////////////////////////////////////////////////////////////
01171 HRESULT CSids::GetUsers( BSTR *pbstrUserNames )
01172 {
01173     if( NULL == pbstrUserNames )
01174     {
01175         return( E_INVALIDARG );
01176     }
01177
01178     HRESULT hr = S_OK;
01179     PSID pSid = NULL;
01180     WCHAR *pwszUserNames = NULL;
01181     *pbstrUserNames = NULL;
01182
01183     do
01184     {
01185         // Get the total bufer size needed to store all users
01186         DWORD dwBufSize = 0;
01187         for( DWORD dwIndex = 0; dwIndex < m_cItems; dwIndex ++ )
01188         {
01189             if( NULL != m_pSidList[ dwIndex ] )
01190             {
01191                 DWORD cbUserName = 0;
01192                 DWORD cbDomainName = 0;
01193                 SID_NAME_USE eUse;
01194                 BOOL fOk = LookupAccountSid( NULL,      // name of local or remote computer
01195                                 m_pSidList[ dwIndex ],  // security identifier
01196                                 NULL,                   // account name buffer
01197                                 &cbUserName,            // size of account name buffer
01198                                 NULL,                   // domain name
01199                                 &cbDomainName,          // size of domain name buffer
01200                                 &eUse                   // SID type
01201                                 );
01202                 dwBufSize = dwBufSize + cbUserName + cbDomainName;
01203             }
01204         }
01205
01206         if( 0 == dwBufSize )
01207         {
01208             break;
01209         }
01210
01211         pwszUserNames = new WCHAR[ dwBufSize ];
01212         if( NULL == pwszUserNames )
01213         {
01214             hr = E_OUTOFMEMORY;
01215             break;
01216         }
01217
01218         WCHAR *p = pwszUserNames;
01219         for( DWORD dwIndex = 0; dwIndex < m_cItems; dwIndex ++ )
01220         {
01221             if( NULL != m_pSidList[ dwIndex ] )
01222             {
01223                 DWORD cbUserName = 0;
01224                 DWORD cbDomainName = 0;
01225                 SID_NAME_USE eUse;
01226                 BOOL fOk = LookupAccountSid( NULL,      // name of local or remote computer
01227                                 m_pSidList[ dwIndex ],  // security identifier
01228                                 NULL,                   // account name buffer
01229                                 &cbUserName,            // size of account name buffer
01230                                 NULL,                   // domain name
01231                                 &cbDomainName,          // size of domain name buffer
01232                                 &eUse                   // SID type
01233                                 );
01234
01235                 fOk = LookupAccountSid( NULL,           // name of local or remote computer
01236                                 m_pSidList[ dwIndex ],  // security identifier
01237                                 p + cbDomainName,       // account name buffer
01238                                 &cbUserName,            // size of account name buffer
01239                                 p,                      // domain name
01240                                 &cbDomainName,          // size of domain name buffer
01241                                 &eUse                   // SID type
01242                                 );
01243                 if( !fOk )
01244                 {
01245                     continue;
01246                 }
01247
01248                 if( 0 != cbDomainName )
01249                 {
01250                     p += cbDomainName;
01251                     *p = L'\\';
01252                     p++;
01253                 }
01254
01255                 // seperate users with a space
01256                 p += cbUserName;
01257                 *p = L' ';
01258                 p++;
01259             }
01260
01261         }
01262
01263         // null term the last user
01264         if( p > pwszUserNames )
01265         {
01266             *( p - 1 ) = L'\0';
01267         }
01268         else
01269         {
01270             *p = L'\0';
01271         }
01272
01273         *pbstrUserNames = SysAllocString( pwszUserNames );
01274         if( NULL == *pbstrUserNames )
01275         {
01276             hr = E_OUTOFMEMORY;
01277         }
01278
01279     }
01280     while( FALSE );
01281
01282     if( NULL != pwszUserNames )
01283     {
01284         delete [] pwszUserNames;
01285     }
01286
01287     return( hr );
01288
01289 }
01290
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/wdiffrc.h Source File

  • Begin
  • sdkdiff

wdiffrc.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 #ifndef __SDKDIFFRC_H__
00012 #define __SDKDIFFRC_H__
00013
00014 #define IDC_STATIC      -1
00015
00016 #define IDM_FILE        111
00017 #define IDM_DIR         112
00018 #define IDM_PRINT       113
00019 #define IDM_EXIT        115
00020 #define IDM_TIME        116
00021 #define IDM_TRACE       117
00022 #define IDM_TRACEOFF    118
00023 #define IDM_OPEN        121
00024 #define IDM_SAVELIST    122
00025 #define IDM_EDITLEFT    123
00026 #define IDM_EDITRIGHT   124
00027 #define IDM_EDITCOMP    125
00028 #define IDM_SETEDIT     126
00029 #define IDM_COPYFILES   127
00030 #define IDM_EDITCOPY    128
00031
00032 #define IDM_CONTENTS    130
00033 #define IDM_ABOUT       131
00034 #define IDD_ICON        132
00035 #define IDD_VERSION     133
00036 #define IDD_LABEL       136
00037 #define IDD_DIR1        137
00038 #define IDD_DIR2        138
00039 #define IDD_LAB1        139
00040 #define IDD_LAB2        140
00041 #define IDD_LAB3        141
00042 #define IDD_RECURSIVE   143
00043 #define IDD_SERVER      145
00044 #define IDD_PASSWORD    146
00045 #define IDD_SUMS        147
00046 #define IDD_FASTSCAN    148
00047 #define IDD_AUTOCOPY    149
00048 #define IDD_BOTHREMOTE  150
00049 #define IDD_LOGFILE     151
00050 #define IDD_LOGTEXT     152
00051 #define IDD_FIND        153
00052 #define IDC_DRD_FINDWHAT  154
00053 #define IDC_OPT_UP        155
00054 #define IDC_OPT_DOWN      156
00055 #define IDC_CHK_MATCHCASE 157
00056 #define IDC_CHK_WHOLEWORD 158
00057
00058 #define IDD_GOTOLINE    159
00059 #define IDC_EDT_GOTOLINE 160
00060
00061 #define IDM_CLOSE       161
00062
00063 #define IDD_USAGE       170
00064 #define IDC_USAGE_TEXT  171
00065
00066 #define IDM_OUTLINE     180
00067 #define IDM_EXPAND      181
00068 #define IDM_FCHANGE     182
00069 #define IDM_LNRS        185
00070 #define IDM_RNRS        186
00071 #define IDM_NONRS       187
00072 #define IDM_LONLY       188
00073 #define IDM_RONLY       189
00074 #define IDM_BOTHFILES   190
00075 #define IDM_UPDATE      194
00076 #define IDM_FPCHANGE    195
00077 #define IDM_IGNBLANKS   196
00078 #define IDM_PICTURE     197
00079 #define IDM_LAZY        198
00080 #define IDM_ALG2        199
00081 #define IDM_OUTLINE_INCSAME     201
00082 #define IDM_OUTLINE_INCLEFT     202
00083 #define IDM_OUTLINE_INCRIGHT    203
00084 #define IDM_OUTLINE_INCDIFFER   204
00085 #define IDM_EXPAND_INCSAME     205
00086 #define IDM_EXPAND_INCLEFT     206
00087 #define IDM_EXPAND_INCRIGHT    207
00088 #define IDM_EXPAND_INCMOVEDLEFT   208
00089 #define IDM_EXPAND_INCMOVEDRIGHT  209
00090 #define IDM_EXPAND_INCSIMILARLEFT   210
00091 #define IDM_EXPAND_INCSIMILARRIGHT  211
00092 #define IDM_MONOCOLS    212
00093 #define IDM_RESCAN      213
00094 #define IDM_SHOWWHITESPACE  214
00095 #define IDM_FIND        215
00096 #define IDM_FINDNEXT    216
00097 #define IDM_FINDPREV    217
00098 #define IDM_GOTOLINE    218
00099 #define IDM_SETTABWIDTH 219
00100 #define IDM_SETFONT   220
00101 #define IDM_FCHANGE_LAURIE    221
00102 #define IDM_FPCHANGE_LAURIE   222
00103 #define IDM_TABWIDTH4   223
00104 #define IDM_TABWIDTH8   224
00105
00106 #define IDM_MARK        300
00107 #define IDM_MARKPATTERN 301
00108 #define IDM_HIDEMARK    302
00109 #define IDM_TOGGLEMARK  303
00110 #define IDD_IGNOREMARK  304
00111 #define IDD_ATTRIBUTES  305
00112 #define IDM_TOMOVED     310
00113
00114 #define IDC_RCDISP1     501
00115 #define IDC_BAR         510
00116 #define IDC_STATUS      550
00117 #define IDM_ABORT       551
00118 #define IDL_STATLAB     552
00119 #define IDL_NAMES       553
00120
00121 #define IDD_FILE        601
00122 #define IDD_IDENTICAL   602
00123 #define IDD_DIFFER      603
00124 #define IDD_LEFT        604
00125 #define IDD_RIGHT       605
00126
00127 #define IDD_FROMGROUP   610
00128 #define IDD_FROMLEFT    611
00129 #define IDD_FROMRIGHT   612
00130
00131 #define IDS_LINE_NOT_VISIBLE        650
00132 #define IDS_ONLY_IN                 651
00133 #define IDS_DIFFERENT               652
00134 #define IDS_IDENTICAL               653
00135 #define IDS_SAME_SIZE               654
00136 #define IDS_CANT_OPEN_TMP_FILE      655
00137 #define IDS_BAD_ARGUMENT            656
00138 #define IDS_SELECT_FIRST_FILE       657
00139 #define IDS_SELECT_SECOND_FILE      658
00140 #define IDS_COULDNT_FIND            659
00141 #define IDS_CANT_OPEN               660
00142 #define IDS_IDENTICAL_COMMA         661
00143 #define IDS_LEFT_ONLY_COMMA         662
00144 #define IDS_RIGHT_ONLY_COMMA        663
00145 #define IDS_DIFFERING               664
00146 #define IDS_FILES_LISTED            665
00147 #define IDS_ENTER_DIR_NAME          666
00148 #define IDS_FAILED_TO_COPY          667
00149 #define IDS_COPYING                 668
00150 #define IDS_COPY_ABORTED            669
00151 #define IDS_COPY_FAILED             670
00152 #define IDS_COPY_COMPLETE           671
00153 #define IDS_EXIT                    672
00154 #define IDS_COULDNT_FIND_ANYTHING   673
00155 #define IDS_SDKDIFF_USAGE           689
00156 #define IDS_ERROR_L_OPTION          690
00157 #define IDS_PAGE                    692
00158 #define IDS_SENT_TO_PRINTER         693
00159 #define IDS_UNABLE_TO_PRINT         694
00160 #define IDS_SDKDIFF_ERROR           695
00161 #define IDS_NO_MORE_CHANGES         696
00162 #define IDS_NO_PREV_CHANGES         697
00163 #define IDS_OUTLINE                 698
00164 #define IDS_EXPAND                  699
00165 #define IDS_FILE_DOESNT_EXIST       700
00166 #define IDS_FAILED_TO_LAUNCH_EDT    701
00167 #define IDS_COMPARING               702
00168 #define IDS_SCANNING                703
00169 #define IDS_ABORT                   704
00170 #define IDS_PLEASE_WAIT             705
00171 #define IDS_ABORT_PENDING           706
00172 #define IDS_SECONDS                 707
00173 #define IDS_TRACING_ENABLED         708
00174 #define IDS_TRACING_DISABLED        709
00175 #define IDS_CREATE_DIFF_LIST        710
00176 #define IDS_TOOL_DESCRIPTION        711
00177 #define IDS_EDITOR_COMMAND          712
00178 #define IDS_HEADER_LINE_STR         713
00179 #define IDS_IDENTICAL_TIMES         714
00180 #define IDS_DIFF_BLANK_ONLY         715
00181 #define IDS_ENTER_SUBSTRING1        716
00182 #define IDS_ENTER_SUBSTRING2        717
00183 #define IDS_MARK_FILES              718
00184 #define IDS_ENTER_PASSWORD          719
00185 #define IDS_COPYING_NFILES          720
00186 #define IDS_BOTH_UNREADABLE         721
00187 #define IDS_LEFT_UNREADABLE         722
00188 #define IDS_RIGHT_UNREADABLE        723
00189 #define IDS_UNREADABLE              724
00190 #define IDS_IS_MORE_RECENT          725
00191 #define IDS_IS_READONLY             726
00192 #define IDS_COPY_FILES              727
00193 #define IDS_NOTHING_RESCANNED       728
00194 #define IDS_NOTHING_TO_EDIT         729
00195 #define IDS_ERR_OPENING_FILE        730
00196 #define IDS_SAVE_COMPFILE           731
00197
00198 #define IDS_USAGE_STR00             732
00199 #define IDS_USAGE_STR01             733
00200 #define IDS_USAGE_STR02             734
00201 #define IDS_USAGE_STR03             735
00202 #define IDS_USAGE_STR04             736
00203 #define IDS_USAGE_STR05             737
00204 #define IDS_USAGE_STR06             738
00205 #define IDS_USAGE_STR07             739
00206 #define IDS_USAGE_STR08             740
00207 #define IDS_USAGE_STR08B            741
00208 #define IDS_USAGE_STR09             742
00209 #define IDS_USAGE_STR10             743
00210 #define IDS_USAGE_STR11             744
00211 #define IDS_USAGE_STR12             745
00212 #define IDS_USAGE_STR12B            746
00213 #define IDS_USAGE_STR12C            747
00214 #define IDS_USAGE_STR13             748
00215 #define IDS_USAGE_STR14             749
00216 #define IDS_USAGE_STR15             750
00217 #define IDS_USAGE_STR16             751
00218 #define IDS_USAGE_STR17             752
00219 #define IDS_USAGE_STR18             753
00220 #define IDS_USAGE_STR19             754
00221 #define IDS_USAGE_STR20             755
00222 #define IDS_USAGE_STR21             756
00223 #define IDS_USAGE_STR22             757
00224 #define IDS_USAGE_STR23             758
00225 #define IDS_USAGE_STR24             759
00226 #define IDS_USAGE_STR25             760
00227 #define IDS_USAGE_STR26             761
00228
00229 #define IDS_GOTOLINE_INVALIDSTRING  800
00230 #define IDS_GOTOLINE_NOLINES        801
00231 #define IDS_FIND_NOTFOUND           802
00232 #define IDS_TABWIDTH        803
00233 #define IDS_BAD_TABWIDTH      804
00234 #define IDS_BAD_SD_INI        805
00235 #define IDS_NOCOMPUNICODE     806
00236 #define IDS_ERROR_LO_UNC            807
00237 #define IDS_ERROR_OVSD_OPTION   808
00238 #define IDS_ERROR_LD_OPTION     809
00239 // --- UNUSED - RECYCLE ME ---          810
00240 #define IDS_ERROR_IARGS       811
00241 #define IDS_ERROR_IARGS_OPENFILE  812
00242 #define IDS_ERROR_CANTLOADRICHEDIT  813
00243
00244 #endif
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllUser/DllUser.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllUser

DllUser.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DLLUSER.CPP
00003
00004   Summary:   Based largely on the EXESKEL.EXE application code, this
00005              module is meant to implicitly link to the DLLSKEL.DLL
00006              and illustrate the use (by this DLLUSER app) of the two
00007              exported calls from that DLL: DllHelloBox and DllAboutBox.
00008              To this end, DLLUSER provides a Test menu with two menu
00009              selections that exercise each of those calls.
00010
00011              Since it is only a slight augmentation over the EXESKEL code
00012              sample, DLLUSER in turn can be considered as another
00013              application skeleton in a graduated sequence of skeletal
00014              evolution.  Each capable of serving as a point of departure
00015              in building more sophisticated applications.
00016
00017              For a comprehensive tutorial code tour of DLLUSER's
00018              contents and offerings see the tutorial DLLUSER.HTM file.
00019              For more specific technical details on the internal workings
00020              see the comments dispersed throughout the DLLUSER source code.
00021              For more details on the DLLSKEL.DLL that DLLUSER works with
00022              see the DLLSKEL.HTM file in the main tutorial directory.
00023
00024   Classes:   CMainWindow
00025
00026   Functions: InitApplication, WinMain
00027
00028   Origin:    8-3-95: atrent - Editor-inheritance from the EXESKEL source.
00029
00030 ----------------------------------------------------------------------------
00031   This file is part of the Microsoft COM Tutorial Code Samples.
00032
00033   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00034
00035   This source code is intended only as a supplement to Microsoft
00036   Development Tools and/or on-line documentation.  See these other
00037   materials for detailed information regarding Microsoft code samples.
00038
00039   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00040   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00041   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00042   PARTICULAR PURPOSE.
00043 ==========================================================================+*/
00044
00045 /*---------------------------------------------------------------------------
00046   We include WINDOWS.H for all Win32 applications.
00047   We include OLE2.H because we will be calling the COM
00048     Library's CoInitialize and CoUnInitialize calls.
00049   We include COMMDLG.H because we will be using the Open File and
00050     potentially other Common dialogs.
00051   We include APPUTIL.H because we will be building this application using
00052     the convenient Virtual Window and Dialog classes and other
00053     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00054   We include DLLUSER.H because it has class and resource definitions
00055     specific to this DLLUSER application.
00056   We include DLLSKEL.H because we will be showcasing the use of service
00057     functions provided by DLLSKEL.DLL.
00058 ---------------------------------------------------------------------------*/
00059 #include <windows.h>
00060 #include <ole2.h>
00061 #include <commdlg.h>
00062 #include <apputil.h>
00063 #include "dlluser.h"
00064 #include "dllskel.h"
00065
00066
00067 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00068   Method:   CMainWindow::CMainWindow
00069
00070   Summary:  CMainWindow Constructor.
00071
00072   Args:     .
00073
00074   Modifies: .
00075
00076   Returns:  .
00077 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00078 CMainWindow::CMainWindow()
00079 {
00080   // Ensure these member variable strings are null strings.
00081   m_szFileName[0] = 0;
00082   m_szFileTitle[0] = 0;
00083
00084   // Fill in the Common Dialog's OPENFILENAME structure.
00085   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00086   m_ofnFile.hwndOwner = m_hWnd;
00087   m_ofnFile.hInstance = m_hInst;
00088   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00089   m_ofnFile.lpstrCustomFilter = NULL;
00090   m_ofnFile.nMaxCustFilter = 0;
00091   m_ofnFile.nFilterIndex = 1;
00092   m_ofnFile.lpstrFile = m_szFileName;
00093   m_ofnFile.nMaxFile = MAX_PATH;
00094   m_ofnFile.lpstrInitialDir = TEXT(".");
00095   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00096   m_ofnFile.nMaxFileTitle = MAX_PATH;
00097   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00098   m_ofnFile.lpstrDefExt = NULL;
00099   m_ofnFile.Flags = OFN_HIDEREADONLY;
00100
00101   // Null the Message object pointer.
00102   m_pMsgBox = NULL;
00103 }
00104
00105
00106 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00107   Method:   CMainWindow::~CMainWindow
00108
00109   Summary:  CMainWindow Destructor.  Destruction of the main window
00110             indicates that the application should quit and thus the
00111             PostQuitMessage API is called.
00112
00113   Args:     .
00114
00115   Modifies: .
00116
00117   Returns:  .
00118 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00119 CMainWindow::~CMainWindow()
00120 {
00121   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00122   // message and causes a delete of CMainWindow which in turn causes this
00123   // destructor to run. The WM_DESTROY results when the window is destoyed
00124   // after a close of the window. Prior to exiting the main message loop
00125   // we delete the CMsgBox object that was made in Initinstance.
00126   DELETE_POINTER(m_pMsgBox);
00127
00128   // We post a WM_QUIT message to cause an exit of the main thread's
00129   // message loop and an exit of this instance of the application.
00130   PostQuitMessage(0);
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   CMainWindow::InitInstance
00136
00137   Summary:  Instantiates an instance of the main application window.
00138             This method must be called only once, immediately after
00139             window class construction.  We take care to delete 'this'
00140             CMainWindow if we must return the error condition FALSE.
00141
00142   Args:     HINSTANCE hInstance,
00143               Handle of the application instance.
00144             int nCmdShow)
00145               Command to pass to ShowWindow.
00146
00147   Modifies: m_szHelpFile, m_pMsgBox.
00148
00149   Returns:  BOOL.
00150               TRUE if succeeded.
00151               FALSE if failed.
00152 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00153 BOOL CMainWindow::InitInstance(
00154        HINSTANCE hInstance,
00155        int nCmdShow)
00156 {
00157   BOOL bResult = FALSE;
00158
00159   // Create the Message Box object.
00160   m_pMsgBox = new CMsgBox;
00161   HWND hWnd;
00162
00163   if (NULL != m_pMsgBox)
00164   {
00165     // Note, the Create method sets the m_hWnd member so we don't
00166     //   need to set it explicitly here first.
00167
00168     // Here is the create of this window.  Size the window reasonably.
00169     //   Create sets both m_hInst and m_hWnd.
00170     hWnd = Create(
00171              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00172              TEXT(MAIN_WINDOW_TITLE_STR),
00173              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00174                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00175              CW_USEDEFAULT,
00176              CW_USEDEFAULT,
00177              ::GetSystemMetrics(SM_CXSCREEN)*2/5,
00178              ::GetSystemMetrics(SM_CYSCREEN)*2/5,
00179              NULL,
00180              NULL,
00181              hInstance);
00182     if (hWnd)
00183     {
00184       // Ensure the new window is shown on screen and its content is painted.
00185       ::ShowWindow(m_hWnd, nCmdShow);
00186       ::UpdateWindow(m_hWnd);
00187
00188       // Build a path to where the help file should be (it should be in
00189       // the same directory as the .EXE but with the .HTM extension.
00190       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00191
00192       // Init the Message Box object and signal we succeeded initializing
00193       // the application.
00194       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00195         bResult = TRUE;
00196     }
00197   }
00198
00199   if (!bResult)
00200   {
00201     DELETE_POINTER(m_pMsgBox);
00202   }
00203
00204   return (bResult);
00205 }
00206
00207
00208 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00209   Method:   CMainWindow::DoMenu
00210
00211   Summary:  Dispatch and handle the main menu commands.
00212
00213   Args:     WPARAM wParam,
00214               First message parameter (word sized).
00215             LPARAM lParam)
00216               Second message parameter (long sized).
00217
00218   Modifies: m_ofnFile, ...
00219
00220   Returns:  LRESULT
00221               Standard Windows WindowProc return value.
00222 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00223 LRESULT CMainWindow::DoMenu(
00224           WPARAM wParam,
00225           LPARAM lParam)
00226 {
00227   LRESULT lResult = FALSE;
00228
00229   switch (LOWORD(wParam))
00230   {
00231     case IDM_FILE_EXIT:
00232       // The user commands us to exit this application so we tell the
00233       // Main window to close itself.
00234       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00235       break;
00236
00237     case IDM_TEST_DLLHELLO:
00238       // Call the DLLSKEL DLL to say hello from it.
00239       ::DllHelloBox(m_hWnd);
00240       break;
00241
00242     case IDM_TEST_DLLABOUT:
00243       // Call the DLLSKEL DLL to show the DLL's About Box.
00244       ::DllAboutBox(m_hWnd);
00245       break;
00246
00247     // Handle Help Menu Commands.
00248     case IDM_HELP_CONTENTS:
00249       // We have some stubbed support here for bringing up the online
00250       // Help for this application.
00251       ReadHelp(m_hWnd, m_szHelpFile);
00252       break;
00253
00254     case IDM_HELP_TUTORIAL:
00255       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00256       // tutorial narrative file associated with this tutorial code sample.
00257       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00258       break;
00259
00260     case IDM_HELP_TUTDLL:
00261       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00262       // tutorial narrative file associated with the DLL server.
00263       ReadTutorial(m_hInst, m_hWnd, TEXT(DLL_TUTFILE_STR));
00264       break;
00265
00266     case IDM_HELP_READSOURCE:
00267       // Call the APPUTIL utility function ReadSource to allow the
00268       // user to open and read any of the source files of DLLUSER.
00269       ReadSource(m_hWnd, &m_ofnFile);
00270       break;
00271
00272     case IDM_HELP_ABOUT:
00273       {
00274         CAboutBox dlgAboutBox;
00275
00276         // Show the standard About Box dialog for this EXE by telling the
00277         // dialog C++ object to show itself by invoking its ShowDialog
00278         // method.  Pass it this EXE instance and the parent window handle.
00279         // Use a dialog resource ID for the dialog template stored in
00280         // this EXE module's resources.
00281         dlgAboutBox.ShowDialog(
00282           m_hInst,
00283           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00284           m_hWnd);
00285       }
00286       break;
00287
00288     default:
00289       // Defer all messages NOT handled here to the Default Window Proc.
00290       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00291       break;
00292   }
00293
00294   return(lResult);
00295 }
00296
00297
00298 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00299   Method:   CMainWindow::WindowProc
00300
00301   Summary:  Main window procedure for this window object.  See CVirWindow
00302             in the APPUTIL library (APPUTIL.CPP) for details on how this
00303             method gets called by the global WindowProc.
00304
00305   Args:     UINT uMsg,
00306               Windows message that is "sent" to this window.
00307             WPARAM wParam,
00308               First message parameter (word sized).
00309             LPARAM lParam)
00310               Second message parameter (long sized).
00311
00312   Modifies: ...
00313
00314   Returns:  LRESULT
00315               Standard Windows WindowProc return value.
00316 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00317 LRESULT CMainWindow::WindowProc(
00318           UINT uMsg,
00319           WPARAM wParam,
00320           LPARAM lParam)
00321 {
00322   LRESULT lResult = FALSE;
00323
00324   switch (uMsg)
00325   {
00326     case WM_CREATE:
00327       {
00328         // Setup for painting text in this window.
00329         HDC hdc = GetDC(m_hWnd);
00330         ::GetTextMetrics(hdc, &m_tm);
00331         ::ReleaseDC(m_hWnd, hdc);
00332       }
00333       break;
00334
00335     case WM_MEASUREITEM:
00336       // Get setup for painting text in this window.
00337       {
00338         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00339         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00340         lpmis->itemWidth = m_wWidth;
00341         lResult = TRUE;
00342       }
00343
00344     case WM_SIZE:
00345       // Handle a resize of this window.
00346       m_wWidth = LOWORD(lParam);
00347       m_wHeight = HIWORD(lParam);
00348       break;
00349
00350     case WM_COMMAND:
00351       // Dispatch and handle any Menu command messages received.
00352       lResult = DoMenu(wParam, lParam);
00353       break;
00354
00355     case WM_CLOSE:
00356       // The user selected Close on the main window's System menu
00357       // or Exit on the File menu.
00358     case WM_QUIT:
00359       // If the app is being quit then close any associated help windows.
00360     default:
00361       // Defer all messages NOT handled here to the Default Window Proc.
00362       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00363       break;
00364   }
00365
00366   return(lResult);
00367 }
00368
00369
00370 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00371   Function: UnicodeOk
00372
00373   Summary:  Checks if the platform will handle unicode versions of
00374             Win32 string API calls.
00375
00376   Args:     void
00377
00378   Returns:  BOOL
00379               TRUE if unicode support; FALSE if not.
00380 ------------------------------------------------------------------------F-F*/
00381 BOOL UnicodeOk(void)
00382 {
00383   BOOL bOk = TRUE;
00384   TCHAR szUserName[MAX_STRING_LENGTH];
00385   DWORD dwSize = MAX_STRING_LENGTH;
00386
00387   if (!GetUserName(szUserName, &dwSize))
00388     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00389
00390   return bOk;
00391 }
00392
00393
00394 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00395   Function: InitApplication
00396
00397   Summary:  Initializes the application and registers its main window
00398             class. InitApplication is called only once (in WinMain).
00399
00400   Args:     HINSTANCE hInstance)
00401               Handle to the first instance of the application.
00402
00403   Returns:  BOOL.
00404               TRUE if success.
00405               FALSE if fail.
00406 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00407 BOOL InitApplication(
00408        HINSTANCE hInstance)
00409 {
00410   BOOL bOk;
00411   // The window class for all instances of the main frame window.
00412   WNDCLASSEX wcf;
00413
00414   // Assign the appropriate values for this main frame window class.
00415   wcf.cbSize        = sizeof(WNDCLASSEX);
00416   wcf.cbClsExtra    = 0;            // No per-class extra data.
00417   wcf.cbWndExtra    = 0;            // No per-window extra data.
00418   wcf.hInstance     = hInstance;    // Application module instance.
00419   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00420                                     // APPUTIL for all CVirWindows).
00421   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
00422   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00423                                 hInstance,
00424                                 TEXT("AppIcon"));
00425   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00426                                 hInstance,
00427                                 TEXT("AppIcon"),
00428                                 IMAGE_ICON,
00429                                 16, 16,
00430                                 0);
00431   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
00432   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
00433   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
00434   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
00435
00436   // Register the window class and return FALSE if unsuccesful.
00437   bOk = RegisterClassEx(&wcf);
00438
00439   return (bOk);
00440 }
00441
00442
00443 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00444   Function: WinMain
00445
00446   Summary:  The Windows main entry point function for this application.
00447             Initializes the application, the COM Libraries, and starts
00448             the main application message loop.
00449
00450   Args:     HINSTANCE hInstance,
00451               Instance handle; a new one for each invocation of this app.
00452             HINSTANCE hPrevInstance,
00453               Instance handle of the previous instance. NULL in Win32.
00454             LPSTR lpCmdLine,
00455               Windows passes a pointer to the application's
00456               invocation command line.
00457             int nCmdShow)
00458               Bits telling the show state of the application.
00459
00460   Returns:  int
00461               msg.wParam (upon exit of message loop).
00462               FALSE if this instance couldn't initialize and run.
00463 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00464 extern "C" int PASCAL WinMain(
00465                         HINSTANCE hInstance,
00466                         HINSTANCE hPrevInstance,
00467                         LPSTR lpCmdLine,
00468                         int nCmdShow)
00469 {
00470   CMainWindow* pWin;
00471   MSG msg;
00472   HACCEL hAccel;
00473   int iRun = FALSE;
00474
00475   // If we were compiled for UNICODE and the platform seems OK with this
00476   // then proceed.  Else we error and exit the app.
00477   if (UnicodeOk())
00478   {
00479     // Call to initialize the COM Library.  Use the SUCCEEDED macro
00480     // to detect success.  If fail then exit app with error message.
00481     if (SUCCEEDED(CoInitialize(NULL)))
00482     {
00483       // If we succeeded in initializing the COM Library we proceed to
00484       // initialize the application.  If we can't init the application
00485       // then we signal shut down with an error message exit.
00486       iRun = InitApplication(hInstance);
00487
00488       if (iRun)
00489       {
00490         // Assume we'll set iRun to TRUE when initialization is done.
00491         iRun = FALSE;
00492         // We are still go for running so we try to create a nifty new
00493         // CMainWindow object for this app instance.
00494         pWin = new CMainWindow;
00495         if (NULL != pWin)
00496         {
00497           // Now we initialize an instance of the new CMainWindow.
00498           // This includes creating the main window.
00499           if (pWin->InitInstance(hInstance, nCmdShow))
00500           {
00501             // Load the keyboard accelerators from the resources.
00502             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
00503             if (NULL != hAccel)
00504             {
00505               // Signal App Initialization is successfully done.
00506               iRun = TRUE;
00507             }
00508           }
00509         }
00510       }
00511
00512       if (iRun)
00513       {
00514         // If we initialized the app instance properly then we are still
00515         // go for running.  We then start up the main message pump for
00516         // the application.
00517         while (GetMessage(&msg, NULL, 0, 0))
00518         {
00519           if (!TranslateAccelerator(
00520                  pWin->GetHwnd(),
00521                  hAccel,
00522                  &msg))
00523           {
00524             TranslateMessage(&msg);
00525             DispatchMessage(&msg);
00526           }
00527         }
00528
00529         // We'll pass to Windows the reason why we exited the message loop.
00530         iRun = (int) msg.wParam;
00531       }
00532       else
00533       {
00534         // We failed to initialize the application. Put up error message
00535         // box saying that application couldn't be initialized.  Parent
00536         // window is desktop (ie, NULL). Exit the failed application
00537         // (ie, by returning FALSE to WinMain).
00538         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
00539
00540         // Delete the CMainWindow object.
00541         DELETE_POINTER(pWin);
00542       }
00543
00544       // We're exiting this app (either normally or by init failure) so
00545       // shut down the COM Library.
00546       CoUninitialize();
00547     }
00548     else
00549     {
00550       // We failed to Initialize the COM Library. Put up error message box
00551       // saying that COM Library couldn't be initialized.  Parent window
00552       // is desktop (ie, NULL). Exit the failed application (ie, by
00553       // returning FALSE to WinMain).
00554       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
00555     }
00556   }
00557   else
00558   {
00559     // If we were compiled for UNICODE but the platform has problems with
00560     // this then indicate an error and exit the app immediately.
00561     CHAR szMsg[MAX_STRING_LENGTH];
00562
00563     if (LoadStringA(
00564           hInstance,
00565           IDS_UNICODEFAIL,
00566           szMsg,
00567           MAX_STRING_LENGTH))
00568     {
00569       MessageBoxA(
00570         NULL,
00571         szMsg,
00572         ERROR_TITLE_STR,
00573         MB_OK | MB_ICONEXCLAMATION);
00574     }
00575   }
00576
00577   return iRun;
00578 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Custom/SpinCube/SpinCube.c Source File

  • WinUI
  • Controls
  • Custom
  • SpinCube

SpinCube.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *
00003 *  MODULE:      SPINCUBE.C
00004 *
00005 *
00006 *  PURPOSE:     To provide a generic Windows NT dynamic link library
00007 *               sample demonstrating the use of DLL entry points, exported
00008 *               variables, using C runtime in a DLL, etc...
00009 *
00010 *               This module also provides a functional example of how
00011 *               to create a custom control library which may be used by
00012 *               applications (i.e. SPINTEST.EXE) and the Dialog Editor.
00013 *
00014 *
00015 *  FUNCTIONS:   DllMain()      - Registers spincube class when a
00016 *                                      process loads this DLL.
00017 *               CustomControlInfo()  - Called by DLGEDIT to initialize
00018 *                                      a CCINFO structure(s).
00019 *               SpincubeStyle()      - Brings up dialog box which allows
00020 *                                      user to modify control style.
00021 *               SpincubeSizeToText() - Called by DLGEDIT if user requests
00022 *                                      that control be sized to fit text.
00023 *               SpincubeWndProc()    - Window procedure for spincube
00024 *                                      control.
00025 *               SpincubeDlgProc()    - Procedure for control style dialog.
00026 *
00027 *
00028 *  COMMMENTS:   The dialog editor interface has changed since Win 3.0.
00029 *               Recommend browsing the NT CUSTCNTL.H file to get an
00030 *               idea of the new interface.
00031 *
00032 *
00033 *                           Microsoft Developer Support
00034 *                  Copyright 1992 - 2000 Microsoft Corporation
00035 *
00036 \******************************************************************************/
00037
00038 #include <windows.h>
00039 #include <stdlib.h>
00040 #include "spincube.h"
00041
00042
00043 //
00044 // function prototype for C runtime initialization routine
00045 //
00046
00047 BOOL WINAPI _CRT_INIT (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved);
00048
00049
00050 //
00051 // function prototype for Paint() in PAINT.C
00052 //
00053
00054 void Paint (HWND);
00055
00056 //
00057 // function prototype for looking up string resources
00058 //
00059
00060 LPTSTR GetStringRes (int);
00061
00062
00063 //
00064 // Declared below are the module's 2 exported variables.
00065 //
00066 //   giNumSpincubesThisProcess is an instance variable that contains
00067 //   the number of (existing) Spincube controls created by the
00068 //   current process.
00069 //
00070 //   giNumSpincubesAllProcesses is a shared (between processes) variable
00071 //   which contains the total number of (existing) Spincube controls
00072 //   created by all processes in the system.
00073 //
00074 //
00075
00076 int giNumSpincubesThisProcess = 0;
00077
00078 #pragma data_seg(".MYSEG")
00079
00080   int giNumSpincubesAllProcesses = 0;
00081
00082 #pragma data_seg()
00083
00084
00085 //
00086 // Some global vars for this module
00087 //
00088
00089 HANDLE    ghMod;   // DLL's module handle
00090 LPCCSTYLE gpccs;   // global pointer to a CCSTYLE structure
00091
00092 CCSTYLEFLAG aSpincubeStyleFlags[] = { { SS_ERASE,    0, TEXT("SS_ERASE")    },
00093                                       { SS_INMOTION, 0, TEXT("SS_INMOTION") } };
00094
00095
00096
00097 /******************************************************************************\
00098 *
00099 *  FUNCTION:    DllMain
00100 *
00101 *  INPUTS:      hDLL       - DLL module handle
00102 *               dwReason   - reason being called (e.g. process attaching)
00103 *               lpReserved - reserved
00104 *
00105 *  RETURNS:     TRUE if initialization passed, or
00106 *               FALSE if initialization failed.
00107 *
00108 *  COMMENTS:    On DLL_PROCESS_ATTACH registers the SPINCUBECLASS
00109 *
00110 *               DLL initialization serialization is guaranteed within a
00111 *               process (if multiple threads then DLL entry points are
00112 *               serialized), but is not guaranteed across processes.
00113 *
00114 *               When synchronization objects are created, it is necesaary
00115 *               to check the return code of GetLastError even if the create
00116 *               call succeeded. If the object existed, ERROR_ALREADY_EXISTED
00117 *               will be returned.
00118 *
00119 *               If your DLL uses any C runtime functions then you should
00120 *               always call _CRT_INIT so that the C runtime can initialize
00121 *               itself appropriately. Failure to do this may result in
00122 *               indeterminate behavior. When the DLL entry point is called
00123 *               for DLL_PROCESS_ATTACH & DLL_THREAD_ATTACH circumstances,
00124 *               _CRT_INIT should be called before any other initilization
00125 *               is performed. When the DLL entry point is called for
00126 *               DLL_PROCESS_DETACH & DLL_THREAD_DETACH circumstances,
00127 *               _CRT_INIT should be called after all cleanup has been
00128 *               performed, i.e. right before the function returns.
00129 *
00130 \******************************************************************************/
00131
00132 BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
00133 {
00134   ghMod = hDLL;
00135   switch (dwReason)
00136   {
00137     case DLL_PROCESS_ATTACH:
00138     {
00139       WNDCLASS wc;
00140
00141       if (!_CRT_INIT (hDLL, dwReason, lpReserved))
00142
00143         return FALSE;
00144
00145       wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC |
00146                          CS_GLOBALCLASS ;
00147       wc.lpfnWndProc   = (WNDPROC) SpincubeWndProc;
00148       wc.cbClsExtra    = 0;
00149       wc.cbWndExtra    = SPINCUBE_EXTRA;
00150       wc.hInstance     = hDLL;
00151       wc.hIcon         = NULL;
00152       wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
00153       wc.hbrBackground = NULL;
00154       wc.lpszMenuName  = (LPTSTR) NULL;
00155       wc.lpszClassName = (LPTSTR) SPINCUBECLASS;
00156
00157       if (!RegisterClass (&wc))
00158       {
00159         MessageBox (NULL,
00160                     GetStringRes (IDS_REGCLASSFAIL),
00161                     (LPCTSTR) TEXT("SPINCUBE.DLL"),
00162                     MB_OK | MB_ICONEXCLAMATION);
00163
00164         return FALSE;
00165       }
00166
00167       break;
00168     }
00169
00170
00171     case DLL_PROCESS_DETACH:
00172     {
00173
00174       if (!_CRT_INIT (hDLL, dwReason, lpReserved))
00175
00176         return FALSE;
00177
00178       if (!UnregisterClass ((LPTSTR) SPINCUBECLASS, hDLL ))
00179       {
00180         MessageBox (NULL,
00181                     GetStringRes (IDS_UNREGFAIL),
00182                     (LPCTSTR) TEXT("SPINCUBE.DLL"),
00183                     MB_OK | MB_ICONEXCLAMATION);
00184
00185         return FALSE;
00186       }
00187
00188       break;
00189     }
00190
00191
00192     default:
00193
00194       if (!_CRT_INIT (hDLL, dwReason, lpReserved))
00195
00196         return FALSE;
00197
00198       break;
00199   }
00200   return TRUE;
00201 }
00202
00203
00204
00205 /******************************************************************************\
00206 *
00207 *  FUNCTION:    CustomControlInfo
00208 *
00209 *  INPUTS:      acci - pointer to an array od CCINFOA structures
00210 *
00211 *  RETURNS:     Number of controls supported by this DLL
00212 *
00213 *  COMMENTS:    See CUSTCNTL.H for more info
00214 *
00215 \******************************************************************************/
00216
00217 UINT CALLBACK CustomControlInfo (LPCCINFO acci)
00218 {
00219   //
00220   // Dlgedit is querying the number of controls this DLL supports, so return 1.
00221   //   Then we'll get called again with a valid "acci"
00222   //
00223
00224   if (!acci)
00225
00226     return 1;
00227
00228
00229   //
00230   // Fill in the constant calues.
00231   //
00232
00233   acci[0].flOptions         = 0;
00234   acci[0].cxDefault         = 40;      // default width  (dialog units)
00235   acci[0].cyDefault         = 40;      // default height (dialog units)
00236   acci[0].flStyleDefault    = WS_CHILD |
00237                               WS_VISIBLE |
00238                               SS_INMOTION;
00239   acci[0].flExtStyleDefault = 0;
00240   acci[0].flCtrlTypeMask    = 0;
00241   acci[0].cStyleFlags       = NUM_SPINCUBE_STYLES;
00242   acci[0].aStyleFlags       = aSpincubeStyleFlags;
00243   acci[0].lpfnStyle         = SpincubeStyle;
00244   acci[0].lpfnSizeToText    = SpincubeSizeToText;
00245   acci[0].dwReserved1       = 0;
00246   acci[0].dwReserved2       = 0;
00247
00248
00249   //
00250   // Copy the strings
00251   //
00252   // NOTE: MAKE SURE THE STRINGS COPIED DO NOT EXCEED THE LENGTH OF
00253   //       THE BUFFERS IN THE CCINFO STRUCTURE!
00254   //
00255
00256   lstrcpyn (acci[0].szClass, SPINCUBECLASS, ARRAYSIZE(acci[0].szClass));
00257   lstrcpyn (acci[0].szDesc,  SPINCUBEDESCRIPTION, ARRAYSIZE(acci[0].szDesc));
00258   lstrcpyn (acci[0].szTextDefault, SPINCUBEDEFAULTTEXT, ARRAYSIZE(acci[0].szTextDefault));
00259
00260
00261   //
00262   // Return the number of controls that the DLL supports
00263   //
00264
00265   return 1;
00266 }
00267
00268
00269
00270 /******************************************************************************\
00271 *
00272 *  FUNCTION:    SpincubeStyle
00273 *
00274 *  INPUTS:      hWndParent - handle of parent window (dialog editor)
00275 *               pccs       - pointer to a CCSTYLE structure
00276 *
00277 *  RETURNS:     TRUE  if success,
00278 *               FALSE if error occured
00279 *
00280 \******************************************************************************/
00281
00282 BOOL CALLBACK SpincubeStyle (HWND hWndParent, LPCCSTYLE pccs)
00283 {
00284   gpccs = pccs;
00285
00286   if (DialogBox (ghMod, TEXT("SpincubeStyle"), hWndParent,
00287                        (DLGPROC)SpincubeDlgProc) == -1)
00288   {
00289     MessageBox (hWndParent,
00290                 GetStringRes (IDS_DLGBOXFAIL),
00291                 (LPCTSTR) TEXT("Spincube.dll"),
00292                 MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
00293
00294     return FALSE;
00295   }
00296
00297   return TRUE;
00298 }
00299
00300
00301
00302 /******************************************************************************\
00303 *
00304 *  FUNCTION:    SpincubeSizeToText
00305 *
00306 *  INPUTS:      flStyle    - control style
00307 *               flExtStyle - control extended style
00308 *               hFont      - handle of font used to draw text
00309 *               pszText    - control text
00310 *
00311 *  RETURNS:     Width (in pixels) control must be to accomodate text, or
00312 *               -1 if an error occurs.
00313 *
00314 *  COMMENTS:    Just no-op here (since we never actually display text in
00315 *               the control it doesn't need to be resized).
00316 *
00317 \******************************************************************************/
00318
00319 INT CALLBACK SpincubeSizeToText (DWORD flStyle, DWORD flExtStyle,
00320                                  HFONT hFont,   LPTSTR pszText)
00321 {
00322   return -1;
00323 }
00324
00325
00326
00327 /******************************************************************************\
00328 *
00329 *  FUNCTION:    SpincubeWndProc (standard window procedure INPUTS/RETURNS)
00330 *
00331 *  COMMENTS:    This is the window procedure for our custom control. At
00332 *               creation we alloc a SPINCUBEINFO struct, initialize it,
00333 *               and associate it with this particular control. We also
00334 *               start a timer which will invalidate the window every so
00335 *               often; this causes a repaint, and the cube gets drawn in
00336 *               a new position. Left button clicks will turn toggle the
00337 *               erase option, causing a "trail" of cubes to be left when
00338 *               off. Right button clicks will toggle the motion state of
00339 *               the control (and turn the timer on/off).
00340 *
00341 \******************************************************************************/
00342
00343 LRESULT CALLBACK SpincubeWndProc (HWND hwnd, UINT msg, WPARAM wParam,
00344                                   LPARAM lParam)
00345 {
00346   switch (msg)
00347   {
00348     case WM_CREATE:
00349     {
00350       //
00351       // Alloc & init a SPINCUBEINFO struct for this particular control
00352       //
00353
00354       HDC            hdc;
00355       LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lParam;
00356       PSPINCUBEINFO  pSCI = (PSPINCUBEINFO) LocalAlloc (LPTR,
00357                                                         sizeof(SPINCUBEINFO));
00358       if (!pSCI)
00359       {
00360         MessageBox (NULL,
00361                     GetStringRes (IDS_ALLOCFAIL),
00362                     (LPCTSTR) TEXT("SPINCUBE.DLL"),
00363                     MB_OK | MB_ICONEXCLAMATION);
00364         return -1;
00365       }
00366
00367
00368       //
00369       // Alloc the compatible DC for this control.
00370       //
00371
00372       hdc = GetDC (hwnd);
00373
00374       if ((pSCI->hdcCompat = CreateCompatibleDC (hdc)) == NULL)
00375       {
00376         MessageBox (NULL,
00377                     GetStringRes (IDS_CREATEDCFAIL),
00378                     (LPCTSTR) TEXT("SPINCUBE.DLL"),
00379                     MB_OK | MB_ICONEXCLAMATION);
00380         return -1;
00381       }
00382
00383       ReleaseDC (hwnd, hdc);
00384
00385
00386       //
00387       // Initialize this instance structure
00388       //
00389
00390       pSCI->fCurrentXRotation =
00391       pSCI->fCurrentYRotation =
00392       pSCI->fCurrentZRotation = (float) 0.0;
00393
00394       pSCI->fCurrentXRotationInc =
00395       pSCI->fCurrentYRotationInc =
00396       pSCI->fCurrentZRotationInc = (float) 0.2617; // a random # (15 degrees)
00397
00398       pSCI->iCurrentXTranslation =
00399       pSCI->iCurrentYTranslation =
00400       pSCI->iCurrentZTranslation = 0;
00401
00402       //
00403       // All these calculations so the cubes start out with random movements.
00404       //
00405
00406       if ((pSCI->iCurrentXTranslationInc = (rand() % 10) + 2) > 7)
00407
00408         pSCI->iCurrentXTranslationInc = -pSCI->iCurrentXTranslationInc;
00409
00410       if ((pSCI->iCurrentYTranslationInc = (rand() % 10) + 2) <= 7)
00411
00412         pSCI->iCurrentYTranslationInc = -pSCI->iCurrentYTranslationInc;
00413
00414       if ((pSCI->iCurrentZTranslationInc = (rand() % 10) + 2) > 7)
00415
00416         pSCI->iCurrentZTranslationInc = -pSCI->iCurrentZTranslationInc;
00417
00418       pSCI->rcCubeBoundary.left   =
00419       pSCI->rcCubeBoundary.top    = 0;
00420       pSCI->rcCubeBoundary.right  = lpcs->cx;
00421       pSCI->rcCubeBoundary.bottom = lpcs->cy;
00422
00423       pSCI->iOptions  = SPINCUBE_REPAINT_BKGND;
00424       pSCI->hbmCompat = NULL;
00425
00426       SetWindowLongPtr (hwnd, GWL_SPINCUBEDATA, (LONG_PTR) pSCI);
00427
00428       SetTimer (hwnd, SPIN_EVENT, SPIN_INTERVAL, NULL);
00429
00430       //
00431       // Increment the count vars
00432       //
00433
00434       giNumSpincubesThisProcess++;
00435       giNumSpincubesAllProcesses++;
00436
00437       break;
00438     }
00439
00440     case WM_PAINT:
00441
00442       Paint (hwnd);
00443       break;
00444
00445     case WM_TIMER:
00446
00447       switch (wParam)
00448       {
00449         case SPIN_EVENT:
00450         {
00451           PSPINCUBEINFO pSCI = (PSPINCUBEINFO) GetWindowLongPtr (hwnd,
00452                                                               GWL_SPINCUBEDATA);
00453
00454           InvalidateRect (hwnd, &pSCI->rcCubeBoundary, FALSE);
00455
00456           break;
00457         }
00458       }
00459
00460       break;
00461
00462     case WM_LBUTTONDBLCLK:
00463     {
00464       //
00465       // Toggle the erase state of the control
00466       //
00467
00468       if (DO_ERASE(hwnd))
00469
00470         SetWindowLongPtr (hwnd, GWL_STYLE,
00471                        GetWindowLongPtr (hwnd, GWL_STYLE) & ~SS_ERASE);
00472
00473
00474       else
00475       {
00476         //
00477         // Repaint the entire control to get rid of the (cube trails) mess
00478         //
00479
00480         PSPINCUBEINFO pSCI = (PSPINCUBEINFO) GetWindowLongPtr (hwnd,
00481                                                             GWL_SPINCUBEDATA);
00482
00483         SetWindowLongPtr (hwnd, GWL_STYLE,
00484                        GetWindowLongPtr (hwnd, GWL_STYLE) | SS_ERASE);
00485         pSCI->iOptions |= SPINCUBE_REPAINT_BKGND;
00486         InvalidateRect (hwnd, NULL, FALSE);
00487         SendMessage (hwnd, WM_PAINT, 0, 0);
00488       }
00489       break;
00490     }
00491
00492     case WM_RBUTTONDBLCLK:
00493     {
00494       //
00495       // Toggle the motion state of the control
00496       //
00497
00498       if (IN_MOTION(hwnd))
00499       {
00500         KillTimer (hwnd, SPIN_EVENT);
00501         SetWindowLongPtr (hwnd, GWL_STYLE,
00502                        GetWindowLongPtr (hwnd, GWL_STYLE) & ~SS_INMOTION);
00503       }
00504       else
00505       {
00506         SetTimer (hwnd, SPIN_EVENT, SPIN_INTERVAL, NULL);
00507         SetWindowLongPtr (hwnd, GWL_STYLE,
00508                        GetWindowLongPtr (hwnd, GWL_STYLE) | SS_INMOTION);
00509       }
00510
00511       break;
00512     }
00513
00514     case WM_SIZE:
00515
00516       if (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED)
00517       {
00518         PSPINCUBEINFO pSCI = (PSPINCUBEINFO) GetWindowLongPtr (hwnd,
00519                                                             GWL_SPINCUBEDATA);
00520         //
00521         // Get a new bitmap which is the new size of our window
00522         //
00523
00524         HDC hdc = GetDC (hwnd);
00525         HBITMAP hbmTemp = CreateCompatibleBitmap (hdc,
00526                                                   (int) LOWORD (lParam),
00527                                                   (int) HIWORD (lParam));
00528         if (!hbmTemp)
00529         {
00530           //
00531           // Scream, yell, & committ an untimely demise...
00532           //
00533
00534           MessageBox (NULL,
00535                       GetStringRes (IDS_CREATEBITMAPFAIL),
00536                       (LPCTSTR) TEXT("SPINCUBE.DLL"),
00537                       MB_OK | MB_ICONEXCLAMATION);
00538           DestroyWindow (hwnd);
00539         }
00540
00541         pSCI->hbmSave = SelectObject (pSCI->hdcCompat, hbmTemp);
00542         if (pSCI->hbmCompat)
00543           DeleteObject (pSCI->hbmCompat);
00544         ReleaseDC    (hwnd, hdc);
00545         pSCI->hbmCompat = hbmTemp;
00546
00547
00548         //
00549         // Reset the translation so the cube doesn't go spinning off into
00550         //   space somewhere- we'd never see it again!
00551         //
00552
00553         pSCI->iCurrentXTranslation =
00554         pSCI->iCurrentYTranslation =
00555         pSCI->iCurrentZTranslation = 0;
00556
00557         //
00558         // All these calculations so the cube starts out with random movements,
00559         //
00560
00561         if ((pSCI->iCurrentXTranslationInc = (rand() % 10) + 2) > 7)
00562
00563           pSCI->iCurrentXTranslationInc = -pSCI->iCurrentXTranslationInc;
00564
00565         if ((pSCI->iCurrentYTranslationInc = (rand() % 10) + 2) <= 7)
00566
00567           pSCI->iCurrentYTranslationInc = -pSCI->iCurrentYTranslationInc;
00568
00569         if ((pSCI->iCurrentZTranslationInc = (rand() % 10) + 2) > 7)
00570
00571           pSCI->iCurrentZTranslationInc = -pSCI->iCurrentZTranslationInc;
00572
00573         pSCI->rcCubeBoundary.left   =
00574         pSCI->rcCubeBoundary.top    = 0;
00575         pSCI->rcCubeBoundary.right  = (int) LOWORD (lParam);
00576         pSCI->rcCubeBoundary.bottom = (int) HIWORD (lParam);
00577
00578         pSCI->iOptions |= SPINCUBE_REPAINT_BKGND;
00579
00580         InvalidateRect (hwnd, NULL, FALSE);
00581       }
00582
00583       break;
00584
00585     case WM_DESTROY:
00586     {
00587       PSPINCUBEINFO pSCI = (PSPINCUBEINFO) GetWindowLongPtr (hwnd,
00588                                                           GWL_SPINCUBEDATA);
00589       //
00590       // Clean up all the resources used for this control
00591       //
00592
00593       if (IN_MOTION(hwnd))
00594
00595         KillTimer (hwnd, SPIN_EVENT);
00596
00597       SelectObject (pSCI->hdcCompat, pSCI->hbmSave);
00598       DeleteObject (pSCI->hbmCompat);
00599       DeleteDC     (pSCI->hdcCompat);
00600
00601       LocalFree (LocalHandle ((LPVOID) pSCI));
00602
00603
00604       //
00605       // Decrement the global count vars
00606       //
00607
00608       giNumSpincubesThisProcess--;
00609       giNumSpincubesAllProcesses--;
00610
00611       break;
00612     }
00613
00614     default:
00615
00616       return (DefWindowProc(hwnd, msg, wParam, lParam));
00617   }
00618
00619   return ((LONG) TRUE);
00620 }
00621
00622
00623
00624 /******************************************************************************\
00625 *
00626 *  FUNCTION:    SpincubeDlgProc (standard dialog procedure INPUTS/RETURNS)
00627 *
00628 *  COMMENTS:    This dialog comes up in response to a user requesting to
00629 *               modify the control style. This sample allows for changing
00630 *               the control's text, and this is done by modifying the
00631 *               CCSTYLE structure pointed at by "gpccs" (a pointer
00632 *               that was passed to us by dlgedit).
00633 *
00634 \******************************************************************************/
00635
00636 LRESULT CALLBACK SpincubeDlgProc (HWND hDlg, UINT msg, WPARAM wParam,
00637                                   LPARAM lParam)
00638 {
00639   switch (msg)
00640   {
00641     case WM_INITDIALOG :
00642     {
00643       if (gpccs->flStyle & SS_ERASE)
00644
00645         CheckDlgButton (hDlg, DID_ERASE, 1);
00646
00647       if (gpccs->flStyle & SS_INMOTION)
00648
00649         CheckDlgButton (hDlg, DID_INMOTION, 1);
00650
00651       break;
00652     }
00653
00654     case WM_COMMAND:
00655
00656       switch (LOWORD(wParam))
00657       {
00658         case DID_ERASE:
00659
00660           if (IsDlgButtonChecked (hDlg, DID_ERASE))
00661
00662             gpccs->flStyle |= SS_ERASE;
00663
00664           else
00665
00666             gpccs->flStyle &= ~SS_ERASE;
00667
00668           break;
00669
00670         case DID_INMOTION:
00671
00672           if (IsDlgButtonChecked (hDlg, DID_INMOTION))
00673
00674             gpccs->flStyle |= SS_INMOTION;
00675
00676           else
00677
00678             gpccs->flStyle &= ~SS_INMOTION;
00679
00680           break;
00681
00682         case DID_OK:
00683
00684           EndDialog  (hDlg, 1);
00685           break;
00686       }
00687       break;
00688   }
00689   return FALSE;
00690 }
00691
00692
00693
00694
00695
00696 /******************************************************************************\
00697 *
00698 *  FUNCTION:    GetStringRes (int id INPUT ONLY)
00699 *
00700 *  COMMENTS:    Load the resource string with the ID given, and return a
00701 *               pointer to it.  Notice that the buffer is common memory so
00702 *               the string must be used before this call is made a second time.
00703 *
00704 \******************************************************************************/
00705
00706 LPTSTR   GetStringRes (int id)
00707 {
00708   static TCHAR szBuffer[MAX_PATH];
00709
00710   szBuffer[0]=0;
00711   LoadString (GetModuleHandle (NULL), id, szBuffer, MAX_PATH);
00712   return szBuffer;
00713 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/registry.h Source File

  • SysMgmt
  • MMC
  • Menubtn

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptServe/CAR.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptServe

CAR.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CAR.H
00003
00004   Summary:   Include file for the aggregatable COCar COM object class.
00005
00006              COCar offers a main IUnknown interface and the ICar
00007              interface (Car-related features).  This multiple interface
00008              COM Object Class is achieved via the technique of nested
00009              classes--the implementation of the ICar interface is
00010              nested inside of the COCar Class.
00011
00012              For a comprehensive tutorial code tour of this module's
00013              contents and offerings see the tutorial APTSERVE.HTM file.
00014              For more specific technical details on the internal workings
00015              see the comments dispersed throughout the module's source code.
00016
00017   Classes:   COCar.
00018
00019   Functions:
00020
00021   Origin:    3-20-96: atrent - Editor-inheritance from CAR.H in
00022                the LOCSERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 #if !defined(CAR_H)
00040 #define CAR_H
00041
00042 #ifdef __cplusplus
00043
00044 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00045   ObjectClass: COCar
00046
00047   Summary:     COM object class for COCar COM objects.  COM objects of
00048                this class offer ICar interface features (Shift, Clutch,
00049                Speed, and Steer).  The mulitple interfaces on this COM
00050                object are constructed via the nested interface classes
00051                technique.
00052
00053   Interfaces:  IUnknown
00054                  Standard interface providing COM object features.
00055                ICar
00056                  Basic Car operation features.
00057
00058   Aggregation: Yes, COCar COM Objects are aggregatable by passing
00059                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00060 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00061 class COCar : public IUnknown
00062 {
00063   public:
00064     // Main Object Constructor & Destructor.
00065     COCar(IUnknown* pUnkOuter, CServer* pServer);
00066     ~COCar(void);
00067
00068     // IUnknown methods. Main object, non-delegating.
00069     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00070     STDMETHODIMP_(ULONG) AddRef(void);
00071     STDMETHODIMP_(ULONG) Release(void);
00072
00073   private:
00074     // We declare nested class interface implementations here.
00075
00076     class CImpICar : public ICar
00077     {
00078       public:
00079         // Interface Implementation Constructor & Destructor.
00080         CImpICar(COCar* pBackObj, IUnknown* pUnkOuter);
00081         ~CImpICar(void);
00082
00083         // IUnknown methods.
00084         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00085         STDMETHODIMP_(ULONG) AddRef(void);
00086         STDMETHODIMP_(ULONG) Release(void);
00087
00088         // ICar methods.
00089         STDMETHODIMP Shift(short nGear);
00090         STDMETHODIMP Clutch(short nEngaged);
00091         STDMETHODIMP Speed(short nMph);
00092         STDMETHODIMP Steer(short nAngle);
00093
00094       private:
00095         // Data private to this COCar interface implementation of ICar.
00096         ULONG        m_C;            // Method call counter (tutorial use).
00097         ULONG        m_cRefI;        // Interface Ref Count (debugging use).
00098         COCar*       m_pBackObj;     // Parent Object back pointer.
00099         IUnknown*    m_pUnkOuter;    // Outer unknown for Delegation.
00100     };
00101
00102     // Make the otherwise private and nested ICar interface implementation
00103     // a friend to COM object instantiations of this selfsame COCar
00104     // COM object class.
00105     friend CImpICar;
00106
00107     // Private data of COCar COM objects.
00108
00109     // Nested ICar implementation instantiation.  This ICar interface
00110     // is instantiated inside this COCar object as a native interface.
00111     CImpICar         m_ImpICar;
00112
00113     // Main Object reference count.
00114     ULONG            m_cRefs;
00115
00116     // Outer unknown (aggregation & delegation).
00117     IUnknown*        m_pUnkOuter;
00118
00119     // Pointer to this component server's control object.
00120     CServer*         m_pServer;
00121 };
00122
00123 typedef COCar* PCOCar;
00124
00125 #endif // __cplusplus
00126
00127
00128 #endif // CAR_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFiles/CrmFilesWorker.h Source File

  • Com
  • Services
  • Crm
  • CrmFiles

CrmFilesWorker.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmFilesWorker.h
00004
00005
00006
00007 Summary:
00008
00009   This is a sample Compensating Resource Manager (CRM) that creates and deletes files.
00010
00011   The CRM Worker provides an interface for creating or deleting files.
00012
00013   The CRM Compensator implements ICrmCompensator to receive transaction outcome notifications.
00014
00015   The CRM Compensator also implements ICrmFormatLogRecords to support monitoring.
00016
00017   This CRM can be installed in a server application or in a library application.
00018
00019   The CRM Worker requires a transaction. The CRM Compensator should not have a transaction.
00020
00021   This file is part of the Microsoft COM Technology Samples.
00022
00023 Classes: CCrmFilesWorker
00024
00025
00026   ----------------------------------------------------------------------------
00027
00028 This file is part of the Microsoft COM+ Samples.
00029
00030
00031
00032 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00033
00034
00035
00036 This source code is intended only as a supplement to Microsoft
00037
00038 Development Tools and/or on-line documentation. See these other
00039
00040 materials for detailed information regarding Microsoft code samples.
00041
00042
00043
00044 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00045
00046 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00047
00048 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00049
00050 PARTICULAR PURPOSE.
00051
00052 ==========================================================================+*/
00053
00054
00055 #ifndef __CRMFILESWORKER_H_
00056 #define __CRMFILESWORKER_H_
00057
00058 #include "resource.h"       // main symbols
00059
00060 #include <comsvcs.h>
00061
00062
00063 /////////////////////////////////////////////////////////////////////////////
00064
00065
00066 typedef enum { ct_DeleteFile, ct_CreateFile } CrmFilesCommandType;
00067
00068 // fully pack all log record structures
00069
00070 #pragma pack(1)
00071
00072 typedef struct tagCrmFilesCreateFileLogRecord
00073 {
00074     CrmFilesCommandType         CommandType;
00075
00076     // NOTE: size is # WCHARs
00077
00078     DWORD                       dwSourceSize;
00079
00080     // source file name goes here
00081
00082 } CrmFilesCreateFileLogRecord;
00083
00084
00085 typedef struct tagCrmFilesDeleteFileLogRecord
00086 {
00087     CrmFilesCommandType         CommandType;
00088
00089     // NOTE: size is # WCHARs
00090
00091     DWORD                       dwSourceSize;
00092
00093     DWORD                       dwTempSize;
00094
00095     // source file name goes here
00096
00097     // temp file name goes here
00098
00099 } CrmFilesDeleteFileLogRecord;
00100
00101 #pragma pack()  // back to default
00102
00103 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00104
00105 Class: CCrmFilesWorker
00106
00107   This is the CRM Worker. All work done on the resource during the transaction
00108   is done through this object. In this program, the resource is the file
00109   system, specifically the actions of creating or deleting files.
00110
00111 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00112
00113 // CCrmFilesWorker
00114 class ATL_NO_VTABLE CCrmFilesWorker :
00115   public CComObjectRootEx<CComMultiThreadModel>,
00116   public CComCoClass<CCrmFilesWorker, &CLSID_CrmFilesWorker>,
00117   public IObjectControl,
00118     public IDispatchImpl<ICrmFilesWorker, &IID_ICrmFilesWorker, &LIBID_CRMFILESLib>
00119 {
00120 public:
00121
00122     // constructor
00123   CCrmFilesWorker();
00124
00125     // destructor
00126   ~CCrmFilesWorker();
00127
00128   /***** /
00129   ULONG InternalAddRef();
00130
00131   ULONG InternalRelease();
00132   / *****/
00133
00134 DECLARE_REGISTRY_RESOURCEID(IDR_CRMFILESWORKER)
00135
00136 BEGIN_COM_MAP(CCrmFilesWorker)
00137   COM_INTERFACE_ENTRY(ICrmFilesWorker)
00138   COM_INTERFACE_ENTRY(IObjectControl)
00139     COM_INTERFACE_ENTRY(IDispatch)
00140 END_COM_MAP()
00141
00142 // ICrmFilesWorker
00143 public:
00144   STDMETHOD(DeleteFile)(/*[in]*/ BSTR bstrFileName);
00145   STDMETHOD(CreateFile)(/*[in]*/ BSTR bstrFileName);
00146
00147 // IObjectControl
00148 public:
00149
00150     HRESULT STDMETHODCALLTYPE Activate(void);
00151
00152     void STDMETHODCALLTYPE Deactivate(void);
00153
00154     BOOL STDMETHODCALLTYPE CanBePooled(void);
00155
00156 private:
00157
00158     HRESULT GetCrmLogControl(void);
00159
00160 private:
00161
00162     ICrmLogControl              *m_pICrmLogControl;
00163
00164   int             m_id;
00165
00166 };
00167
00168 #endif //__CRMFILESWORKER_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/capicom/cpp/isapiCertPolicy/StdAfx.h Source File

  • Security
  • capicom
  • cpp
  • isapiCertPolicy

StdAfx.h

Go to the documentation of this file.
00001 #if !defined(AFX_STDAFX_H__4C8447EA_BC9D_408C_B380_60561669345B__INCLUDED_)
00002 #define AFX_STDAFX_H__4C8447EA_BC9D_408C_B380_60561669345B__INCLUDED_
00003
00004 // stdafx.h : include file for standard system include files,
00005 //  or project specific include files that are used frequently, but
00006 //      are changed infrequently
00007 //
00008
00009 #define WINVER 0x0400
00010 #define _WIN32_WINNT 0x0400
00011
00012 #include <afx.h>
00013 #include <afxwin.h>
00014 #include <afxmt.h>    // for synchronization objects
00015 #include <afxext.h>
00016 #include <afxisapi.h>
00017
00018 #import "capicom.dll"
00019
00020
00021 //{{AFX_INSERT_LOCATION}}
00022 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00023
00024 #endif // !defined(AFX_STDAFX_H__4C8447EA_BC9D_408C_B380_60561669345B__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authorization/dbauthadmin.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • Authorization

dbauthadmin.cpp

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName: DBAuthAdmin.cpp
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011 #include "stdafx.h"
00012 #include "DBAuth.h"
00013 #include "DBAuthAdmin.h"
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CDBAuthAdmin
00017 /////////////////////////////////////////////////////////////////////////////
00018
00019 STDMETHODIMP CDBAuthAdmin::InterfaceSupportsErrorInfo( REFIID riid )
00020 {
00021     static const IID* arr[] =
00022     {
00023         &IID_IDBAuthAdmin
00024     };
00025     for ( int i = 0; i < sizeof( arr ) / sizeof( arr[ 0 ] ); i++ )
00026     {
00027         if( IsEqualGUID( *arr[ i ], riid ) )
00028         {
00029             return( S_OK );
00030         }
00031     }
00032
00033     return( S_FALSE );
00034 }
00035
00036 /////////////////////////////////////////////////////////////////////////////
00037 /////////////////////////////////////////////////////////////////////////////
00038 STDMETHODIMP CDBAuthAdmin::Initialize( CDBAuthPlugin *pPlugin )
00039 {
00040     HRESULT hr = S_OK;
00041
00042     if( NULL == pPlugin )
00043     {
00044         return( E_INVALIDARG );
00045     }
00046
00047     m_pDBAuthPlugin = pPlugin;
00048
00049     return( hr );
00050 }
00051
00052 /////////////////////////////////////////////////////////////////////////////
00053 /////////////////////////////////////////////////////////////////////////////
00054 STDMETHODIMP CDBAuthAdmin::AddUser( BSTR bstrUserName )
00055 {
00056     if( NULL == bstrUserName )
00057     {
00058         return( E_INVALIDARG );
00059     }
00060
00061     if( L'\0' == (WCHAR*) *bstrUserName )
00062     {
00063         return( S_OK );
00064     }
00065
00066     return m_pDBAuthPlugin->AddUser( (LPCWSTR) bstrUserName );
00067 }
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 /////////////////////////////////////////////////////////////////////////////
00071 STDMETHODIMP CDBAuthAdmin::RemoveUser( BSTR bstrUserName )
00072 {
00073     if( NULL == bstrUserName )
00074     {
00075         return( E_INVALIDARG );
00076     }
00077
00078     if( L'\0' == (WCHAR*) *bstrUserName )
00079     {
00080         return( S_OK );
00081     }
00082
00083     return m_pDBAuthPlugin->RemoveUser( (LPCWSTR) bstrUserName );
00084 }
00085
00086 /////////////////////////////////////////////////////////////////////////////
00087 /////////////////////////////////////////////////////////////////////////////
00088 HRESULT CDBAuthAdmin::VerifyUser( BSTR bstrUserName, VARIANT_BOOL *pbFound )
00089 {
00090     if( NULL == bstrUserName )
00091     {
00092         return( E_INVALIDARG );
00093     }
00094
00095     if( NULL == pbFound )
00096     {
00097         return( E_POINTER );
00098     }
00099
00100     BOOL bFound = FALSE;
00101     DWORD dwIndex = 0;
00102     HRESULT hr = m_pDBAuthPlugin->VerifyUserMembership( ( LPCWSTR ) bstrUserName, &bFound, &dwIndex );
00103
00104     *pbFound = ( SUCCEEDED( hr ) && bFound ) ? VARIANT_TRUE : VARIANT_FALSE;
00105
00106     return( hr );
00107 }
00108
00109 /////////////////////////////////////////////////////////////////////////////
00110 /////////////////////////////////////////////////////////////////////////////
00111 HRESULT CDBAuthAdmin::GetUsers( BSTR *pbstrUserNames )
00112 {
00113     if( NULL == pbstrUserNames )
00114     {
00115         return( E_POINTER );
00116     }
00117
00118     return( m_pDBAuthPlugin->GetUsers( pbstrUserNames ) );
00119
00120 }
00121
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Open.c Source File

  • WinUI
  • CommDlg
  • CDTest

Open.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 /************************************************************************
00007
00008   File: open.c
00009
00010   Purpose:
00011
00012     This file contains the routines to control the CDTEST.EXE "Open" dialog
00013     box.  The "Open" dialog box allows the user to enter values into an
00014     OPENFILENAME structure and then create GetOpenFileName() dialog boxes
00015     on the fly.
00016
00017   Functions:
00018
00019     DoOpenDialog()                   -- starts off the main dialog for "open"
00020
00021     OpenFunc()                       -- Callback function for main dialog
00022
00023     InitOpenStruct()                 -- Fills initial OPENFILENAME structure.
00024
00025     FillOpenDlg()                    -- Fills the dialog with the values from
00026                                         the OPENFILENAME structure.
00027
00028     GetOpenDlg()                     -- Retrieves the users entries from the
00029                                         main dialog and puts them in the
00030                                         OPENFILENAME structure.
00031
00032     InitFilterString()               -- Creates filter string
00033
00034     InitCustFiltString()             -- Creates custom filter string
00035
00036     InterpretCustomFilterString()    -- Parses custom filter string returned
00037                                         from GetOpenFileName()
00038
00039     GetCorrectResourceHandle()       -- Loads custom templates from file
00040                                         as resource handles
00041
00042     OpenSaveHookProc()               -- The hook function that will be
00043                                         called if GetOpen/Save is called
00044                                         with the OFN_ENABLEHOOK flag set.
00045
00046     MultiThreadOpenSave()            -- Creates two Open/Save dialogs that
00047                                         the user can simultaneously access
00048
00049     OpenSaveThread1Proc()            -- The starting address of thread 1
00050
00051     OpenSaveThread2Proc()            -- The starting address of thread 2
00052
00053     DoOpenSaveStuff()                -- Does the actuall calling of
00054                                         GetOpen/SaveFileName()
00055
00056     OpenMultiThreadEnableButtons()   -- Enables and disables buttons in
00057                                         main dialog.  Needed when multi-
00058                                         threading.
00059
00060 ************************************************************************/
00061
00062 #include <windows.h>
00063 #include <commdlg.h>
00064 #include <stdlib.h>
00065 #include <winnls.h>
00066 #include "cdtest.h"
00067 #include "open.h"
00068 #include "save.h"
00069 #include "dlgs.h"     //include file that contains all #defines for the
00070                       //commdlg dialog templates.
00071
00072
00073 /* All functions defined in this file + 1 external function
00074    and one external variable */
00075
00076 extern UINT uMode ;                               //see cdtest.c
00077 extern LONG_PTR MyAtol(LPTSTR, BOOL, LPBOOL) ;
00078 void InterpretCustomFilterString(void) ;
00079 HANDLE GetCorrectResourceHandle(void) ;
00080 void DoOpenSaveStuff(LPOPENFILENAME) ;
00081 UINT_PTR CALLBACK OpenSaveHookProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ;
00082 DWORD OpenSaveThread1Proc(LPDWORD) ;
00083 DWORD OpenSaveThread2Proc(LPDWORD) ;
00084 void MultiThreadOpenSave(void) ;
00085 void OpenMultiThreadEnableButtons(BOOL, HWND) ;
00086
00087
00088 /* All global variables defined in this file */
00089
00090 HWND hwndMainDialog ;   //global handle for open dialog.
00091
00092 HRSRC  hRes ;           //handles to the resource and dialog for
00093 HANDLE hDialog ;        //ofn_enabletemplatehandle
00094
00095 HBRUSH hBrushDlg ;
00096 HBRUSH hBrushEdit ;     //brush handles for new colors done with hook proc
00097 HBRUSH hBrushButton ;
00098
00099 HANDLE hOpenSaveThread1, hOpenSaveThread2 ;   //variables for the
00100 DWORD dwThreadID1, dwThreadID2 ;              //multithreading part
00101 DWORD dwThreadParm1, dwThreadParm2 ;
00102 OPENFILENAME ofnThread1, ofnThread2 ;
00103 int nOpenDialogCount ;
00104
00105
00106
00107
00108
00109 /************************************************************************
00110
00111   Function: DoOpenDialog(HWND)
00112
00113   Purpose: To create the GetOpenFileName() and GetSaveFileName()
00114            creation dialog.
00115
00116   Returns: Nothing.
00117
00118   Comments:
00119
00120     GetOpenFileName() and GetSaveFileName() are similiar enough so that
00121     the same dialog can be used to edit their creation structure elements,
00122     so a global variable "bDoOpenDlg" keeps track of which one to create
00123     when the user clicks the OK or Multithread buttons...
00124
00125 ************************************************************************/
00126
00127
00128 void DoOpenDialog(HWND hwnd)
00129 {
00130
00131   bDoOpenDlg = TRUE ;
00132
00133
00134   DialogBox(hInst, MAKEINTRESOURCE(ID_OPENDIALOG), hwnd, OpenFunc) ;
00135
00136 }
00137
00138
00139
00140
00141
00142
00143 /************************************************************************
00144
00145
00146   Function: OpenFunc(HWND, UINT, WPARAM, LPARAM)
00147
00148   Purpose:
00149
00150     This is the callback function for the dialog box containing the
00151     GetOpenFileName() and the GetSaveFileName() creation options.
00152
00153     This function will handle the messages for this dialog and create
00154     either a GetOpenFileName() dialog or a GetSaveFileName() dialog
00155     depending on the state of the bDoOpenDlg variable.
00156
00157   Returns: TRUE or FALSE depending on the situation.
00158
00159   Comments:
00160
00161
00162 ************************************************************************/
00163
00164
00165 INT_PTR APIENTRY OpenFunc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00166 {
00167   switch (msg)
00168   {
00169
00170     case WM_INITDIALOG:
00171
00172       if (bDoOpenDlg)
00173         SetWindowText(hwnd, TEXT("GetOpenFileName()")) ;
00174       else
00175         SetWindowText(hwnd, TEXT("GetSaveFileName()")) ;
00176
00177
00178       /* initialize the OPENFILENAME structure members */
00179
00180       InitOpenStruct(hwnd, &ofn) ;
00181
00182
00183       /* Fill these values into the creation dialog */
00184
00185       FillOpenDlg(hwnd, &ofn) ;
00186
00187
00188       /* There are three separate OPENFILENAME structures.  One for
00189          the main Open/Save dialog and one for each multithreaded dialog.
00190          Set them equal to begin with */
00191
00192       *(&ofnThread1) = *(&ofnThread2) = *(&ofn) ;
00193
00194       hwndMainDialog = hwnd ;
00195
00196       SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEO)) ;
00197
00198       break ;
00199
00200
00201
00202     case UMSG_DECREMENTDLGCOUNT:  //user defined message indicating
00203                                   //the closure of a multithreaded dialog
00204
00205       /* When we are multithreading, there is nothing to prevent the
00206          user from interacting with the creation dialog once the first
00207          GetOpen(Save) file name dialog has returned.  So, in order
00208          to prevent the Multithread" button from being pressed again
00209          before the previous two multithreaded dialogs have been canceled,
00210          disable the controls until we get a message from each thread
00211          that the dialog has ended */
00212
00213
00214       nOpenDialogCount-- ;
00215
00216       if (nOpenDialogCount == 0)
00217         OpenMultiThreadEnableButtons(TRUE, hwnd) ;
00218
00219       break ;
00220
00221
00222     case WM_COMMAND:
00223     {
00224       switch (LOWORD(wParam))
00225       {
00226
00227         case IDOK:
00228           GetOpenDlg(hwnd, &ofn) ;          //get the user's input
00229           DoOpenSaveStuff(&ofn) ;           //do the dialog
00230           break ;
00231
00232
00233         case IDCANCEL:
00234           EndDialog(hwnd, FALSE) ;
00235           break ;
00236
00237
00238         case ID_RESETOPEN:
00239
00240           SendDlgItemMessage(hwnd, ID_FILTERO, CB_RESETCONTENT,
00241             (WPARAM) 0, (LPARAM) 0) ;
00242
00243           InitOpenStruct(hwnd, &ofn) ;
00244
00245           FillOpenDlg(hwnd, &ofn) ;
00246
00247           SendDlgItemMessage(hwnd, ID_NULLSTRUCTO, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00248           SendDlgItemMessage(hwnd, ID_USEHINSTO, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00249
00250           *(&ofnThread1) = *(&ofnThread2) = *(&ofn) ;
00251
00252           SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEO)) ;
00253
00254           break ;
00255
00256
00257         case ID_ADD1O:
00258
00259           GetDlgItemText(hwnd, ID_FILTERO, szTemp, 100) ;
00260
00261           if (*szTemp)
00262           {
00263             SendDlgItemMessage(hwnd, ID_FILTERO, CB_ADDSTRING, (WPARAM) 0,
00264                               (LPARAM) (LPTSTR) szTemp) ;
00265             SetWindowText(GetDlgItem(hwnd, ID_FILTERO), TEXT("")) ;
00266           }
00267           break ;
00268
00269
00270         case ID_ADD2O:
00271
00272           GetDlgItemText(hwnd, ID_CUSTFILTO, szTemp, 100) ;
00273
00274           if (*szTemp)
00275           {
00276             SendDlgItemMessage(hwnd, ID_CUSTFILTO, CB_ADDSTRING, (WPARAM) 0,
00277                               (LPARAM) (LPTSTR) szTemp) ;
00278             SetWindowText(GetDlgItem(hwnd, ID_CUSTFILTO), TEXT("")) ;
00279           }
00280           break ;
00281
00282
00283         case ID_CLEAR1O:
00284           SendDlgItemMessage(hwnd, ID_FILTERO, CB_RESETCONTENT,
00285                              (WPARAM) 0, (LPARAM) 0) ;
00286           break ;
00287
00288         case ID_CLEAR2O:
00289           SendDlgItemMessage(hwnd, ID_CUSTFILTO, CB_RESETCONTENT,
00290                              (WPARAM) 0, (LPARAM) 0) ;
00291           break ;
00292
00293         case ID_MULTIOPEN:
00294
00295         /* First, disable the OK, Cancel, and MultiThread buttons */
00296
00297           OpenMultiThreadEnableButtons(FALSE, hwnd) ;
00298
00299
00300         /* Then multithread the dialogs */
00301
00302           nOpenDialogCount = 2 ;
00303
00304           MultiThreadOpenSave() ;
00305
00306           break ;
00307
00308
00309         default:   //end WM_COMMAND case
00310           break ;
00311       }
00312     }
00313
00314     default:
00315
00316       /* If the help button is pressed in the GetOpen/SaveFileName()
00317          dialogs, it will send a message Registered with RegisterWindowMessage()
00318          to the parent window.  The message nHelpMessage was registered
00319          at application startup */
00320
00321       if (msg == nHelpMessage)
00322         MessageBox(GetForegroundWindow(),
00323                    TEXT("Hello from the help button"),
00324                    TEXT("Open Help Button"), MB_OK | MB_APPLMODAL) ;
00325
00326       break ;
00327
00328   }
00329
00330   return FALSE ;
00331 }
00332
00333
00334
00335
00336
00337
00338
00339 /************************************************************************
00340
00341
00342   Function: InitOpenStruct(HWND, LPOPENFILENAME)
00343
00344   Purpose:
00345
00346     Initializes the OPENFILENAME structure.  The structure is referenced
00347     via a pointer passed in as the second parameter so that we can pass
00348     any of the three OPENFILENAME structures into this function and
00349     Initialize them.
00350
00351   Returns: Nothing.
00352
00353   Comments:
00354
00355     The szFilterInits and szCustFiltInits arrays are initialized to
00356     contain some default strings.  Eventually the strings in
00357     these arrays must be arranged one after the other with a null
00358     character between them and two null characters at the end:
00359
00360     "Text files\0*.txt\0All files\0*.*\0\0"
00361
00362 ************************************************************************/
00363
00364
00365 void InitOpenStruct(HWND hwnd, LPOPENFILENAME po)
00366 {
00367    int i = 0 ;
00368    szFileName[0] = 0 ;
00369    szFileTitle[0] = 0 ;
00370
00371    dwFlags = OFN_READONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_SHOWHELP  ;
00372
00373    if (bDoOpenDlg)
00374      lstrcpyn(szDlgTitle, TEXT("Open Dialog Title"), ARRAYSIZE(szDlgTitle)) ;
00375    else
00376      lstrcpyn(szDlgTitle, TEXT("Save Dialog Title"), ARRAYSIZE(szDlgTitle)) ;
00377
00378    lstrcpyn(szDefExt, TEXT("rat"), ARRAYSIZE(szDefExt)) ;
00379    lstrcpyn(szInitialDir, TEXT("c:\\"), ARRAYSIZE(szInitialDir)) ;
00380    lstrcpyn(szTempName, TEXT("opentemp1"), ARRAYSIZE(szTempName)) ;
00381
00382    lstrcpyn(&szFilterInits[0][0], TEXT("All Files (*.*)"), 30) ;
00383    lstrcpyn(&szFilterInits[1][0], TEXT("*.*"), 30) ;
00384    lstrcpyn(&szFilterInits[2][0], TEXT("Fat Files (*.fat)"), 30) ;
00385    lstrcpyn(&szFilterInits[3][0], TEXT("*.fat"), 30) ;
00386    szFilterInits[4][0] = (TCHAR) 0 ;
00387
00388    lstrcpyn(&szCustFiltInits[0][0], TEXT("Last Filter Used"), 30) ;
00389    lstrcpyn(&szCustFiltInits[1][0], TEXT("*.lst"), 30) ;
00390    szCustFiltInits[2][0] = (TCHAR) 0 ;
00391
00392
00393    /*
00394
00395       These two functions will create "strings" in the applications
00396       data area that are in the form
00397
00398       "Filter Description"\0
00399       "Filter"\0
00400       "Filter Description"\0
00401       "Filter"\0
00402       ..
00403       ..
00404       \0\0
00405
00406       The filters must be in this form in order that the common dialogs
00407       interpret it correctly...
00408    */
00409
00410    InitFilterString() ;
00411
00412    InitCustFilterString() ;
00413
00414    po->lStructSize          = sizeof(OPENFILENAME) ;
00415    po->hwndOwner            = hwnd ;
00416    po->hInstance            = hInst ;
00417    po->lpstrFilter          = lpszFilterString ;
00418    po->lpstrCustomFilter    = lpszCustFilterString ;
00419    po->nMaxCustFilter       = MAXCUSTFILTER ;
00420    po->nFilterIndex         = 1L ;
00421    po->lpstrFile            = szFileName ;
00422    po->nMaxFile             = FILENAMESIZE ;
00423    po->lpstrFileTitle       = szFileTitle ;
00424    po->nMaxFileTitle        = FILETITLESIZE ;
00425    po->lpstrInitialDir      = szInitialDir ;
00426    po->lpstrTitle           = szDlgTitle ;
00427    po->Flags                = dwFlags ;
00428    po->nFileOffset          = 0 ;
00429    po->nFileExtension       = 0 ;
00430    po->lpstrDefExt          = szDefExt;
00431    po->lCustData            = 0L ;
00432    po->lpfnHook             = OpenSaveHookProc ;
00433    po->lpTemplateName       = szTempName ;
00434
00435    return ;
00436 }
00437
00438
00439
00440
00441
00442
00443
00444 /************************************************************************
00445
00446
00447   Function: FillOpenDlg(HWND, LPOPENFILENAME)
00448
00449   Purpose:
00450
00451     - This function will fill in the edit boxes that correspond to each
00452       of the fields in the OPENFILENAME structure.  The user can accept
00453       these values to create the common dialog or edit them.
00454
00455   Returns: Nothing.
00456
00457   Comments:
00458
00459       The contents of the strings "szShortFilter" and "szLongFilter"
00460       determine how a WORD or a DWORD value is represented in the edit boxes
00461
00462 ************************************************************************/
00463
00464 void FillOpenDlg(HWND hwnd, LPOPENFILENAME po)
00465 {
00466    int i = 0 ;
00467
00468    wsprintf(szTemp, szShortFilter, (int) po->lStructSize) ;
00469    SetDlgItemText(hwnd, ID_STRUCTSIZEO, szTemp) ;
00470
00471    wsprintf(szTemp, szPointerFilter, (LONG_PTR) po->hwndOwner) ;
00472    SetDlgItemText(hwnd, ID_HWNDOWNERO, szTemp) ;
00473
00474    wsprintf(szTemp, szPointerFilter, (LONG_PTR) po->hInstance) ;
00475    SetDlgItemText(hwnd, ID_HINSTANCEO, szTemp) ;
00476
00477
00478    SendDlgItemMessage(hwnd, ID_FILTERO, CB_RESETCONTENT,
00479                       (WPARAM) 0, (LPARAM) 0) ;
00480
00481    while (szFilterInits[i][0] != (TCHAR) 0)
00482    {
00483       SendDlgItemMessage(hwnd, ID_FILTERO, CB_ADDSTRING, (WPARAM) 0,
00484                         (LPARAM) (LPTSTR) &szFilterInits[i][0]) ;
00485       i++ ;
00486    }
00487
00488    SendDlgItemMessage(hwnd, ID_FILTERO, CB_SETCURSEL,
00489                      (WPARAM) 0, (LPARAM) 0 ) ;
00490
00491
00492
00493    SendDlgItemMessage(hwnd, ID_CUSTFILTO, CB_RESETCONTENT,
00494                       (WPARAM) 0, (LPARAM) 0) ;
00495
00496    for (i=0; i<2; i++)
00497      SendDlgItemMessage(hwnd, ID_CUSTFILTO, CB_ADDSTRING, (WPARAM) 0,
00498                         (LPARAM) (LPTSTR) &szCustFiltInits[i][0]) ;
00499
00500    SendDlgItemMessage(hwnd, ID_CUSTFILTO, CB_SETCURSEL,
00501                      (WPARAM) 0, (LPARAM) 0) ;
00502
00503
00504    wsprintf(szTemp, szShortFilter, (int) po->nMaxCustFilter) ;
00505    SetDlgItemText(hwnd, ID_MAXCUSTFILTO, szTemp) ;
00506
00507    wsprintf(szTemp, szShortFilter, (int) po->nFilterIndex) ;
00508    SetDlgItemText(hwnd, ID_FILTINDEXO, szTemp) ;
00509
00510    SetDlgItemText(hwnd, ID_SZFILEO, po->lpstrFile) ;
00511
00512    wsprintf(szTemp, szShortFilter, (int) po->nMaxFile) ;
00513    SetDlgItemText(hwnd, ID_MAXSZFILEO, szTemp) ;
00514
00515    SetDlgItemText(hwnd, ID_SZFILETITLEO, po->lpstrFileTitle) ;
00516
00517    wsprintf(szTemp, szShortFilter, (int) po->nMaxFileTitle) ;
00518    SetDlgItemText(hwnd, ID_MAXSZFILETITLEO, szTemp) ;
00519
00520    SetDlgItemText(hwnd, ID_SZINITDIRO, po->lpstrInitialDir) ;
00521
00522    SetDlgItemText(hwnd, ID_SZTITLEO, po->lpstrTitle) ;
00523
00524    wsprintf(szTemp, szLongFilter, po->Flags) ;
00525    SetDlgItemText(hwnd, ID_FLAGSO, szTemp) ;
00526
00527    wsprintf(szTemp, szShortFilter, po->nFileOffset) ;
00528    SetDlgItemText(hwnd, ID_FILEOFFO, szTemp) ;
00529
00530    wsprintf(szTemp, szShortFilter, po->nFileExtension) ;
00531    SetDlgItemText(hwnd, ID_FILEEXTO, szTemp) ;
00532
00533    SetDlgItemText(hwnd, ID_SZDEFEXTO, po->lpstrDefExt) ;
00534
00535    wsprintf(szTemp, szLongFilter, po->lCustData) ;
00536    SetDlgItemText(hwnd, ID_CUSTDATAO, szTemp) ;
00537
00538    wsprintf(szTemp, szLongFilter, po->lpfnHook) ;
00539    SetDlgItemText(hwnd, ID_HOOKO, szTemp) ;
00540
00541    SetDlgItemText(hwnd, ID_TEMPLATEO, po->lpTemplateName) ;
00542
00543    return ;
00544 }
00545
00546
00547
00548
00549
00550
00551
00552
00553 /************************************************************************
00554
00555
00556   Function: GetOpenDlg(HWND, LPOPENFILENAME)
00557
00558
00559   Purpose:
00560
00561       This function will retrieve the contents of each edit box corresponding
00562       with each field in the OPENFILENAME structure, and fill in the
00563       OPENFILENAME structure with these values.
00564
00565   Returns: Nothing.
00566
00567   Comments:
00568
00569     if (uMode == IDM_HEXMODE), then the numbers should be interpreted as
00570     hexidecimal and the MyAtol() function is called with its "bHex"
00571     parameter set to true.
00572
00573 ************************************************************************/
00574
00575 void GetOpenDlg(HWND hwnd, LPOPENFILENAME po)
00576 {
00577    int i ;
00578    BOOL b ;
00579    TCHAR szNum[20] ;
00580
00581    GetDlgItemText(hwnd, ID_STRUCTSIZEO, szNum, 20) ;
00582    po->lStructSize = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00583
00584    GetDlgItemText(hwnd, ID_HWNDOWNERO, szNum, 20) ;
00585    po->hwndOwner = (HWND) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00586
00587    GetDlgItemText(hwnd, ID_HINSTANCEO, szNum, 20) ;
00588    po->hInstance = (HANDLE) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00589
00590
00591    /* these are just strings, no conversion necessary */
00592
00593    i = 0 ;
00594    while (SendDlgItemMessage(hwnd, ID_FILTERO, CB_GETLBTEXT, (WPARAM) i,
00595                           (LPARAM) (LPTSTR) szFilterInits[i]) != CB_ERR)
00596    { i++ ; }
00597
00598
00599    /* create the filter string */
00600
00601    InitFilterString() ;
00602
00603
00604    i = 0 ;
00605
00606    while (SendDlgItemMessage(hwnd, ID_CUSTFILTO, CB_GETLBTEXT, (WPARAM) i,
00607                         (LPARAM) (LPTSTR) szCustFiltInits[i]) != CB_ERR)
00608    { i++ ; }
00609
00610
00611    InitCustFilterString() ;
00612
00613
00614    GetDlgItemText(hwnd, ID_MAXCUSTFILTO, szNum, 20) ;
00615    po->nMaxCustFilter = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00616
00617    GetDlgItemText(hwnd, ID_FILTINDEXO, szNum, 20) ;
00618    po->nFilterIndex = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00619
00620    GetDlgItemText(hwnd, ID_SZFILEO, po->lpstrFile, MAXBUF) ;
00621
00622    GetDlgItemText(hwnd, ID_MAXSZFILEO, szNum, 20) ;
00623    po->nMaxFile = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00624
00625    GetDlgItemText(hwnd, ID_SZFILETITLEO, po->lpstrFileTitle, MAXBUF) ;
00626
00627    GetDlgItemText(hwnd, ID_MAXSZFILETITLEO, szNum, MAXBUF) ;
00628    po->nMaxFileTitle = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00629
00630    GetDlgItemText(hwnd, ID_SZINITDIRO, (LPTSTR) po->lpstrInitialDir, MAXBUF) ;
00631
00632    GetDlgItemText(hwnd, ID_SZTITLEO, (LPTSTR) po->lpstrTitle, MAXBUF) ;
00633
00634    GetDlgItemText(hwnd, ID_FLAGSO, szNum, 20) ;
00635    po->Flags = (DWORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00636
00637    GetDlgItemText(hwnd, ID_FILEOFFO, szNum, 20) ;
00638    po->nFileOffset = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00639
00640    GetDlgItemText(hwnd, ID_FILEEXTO, szNum, 20) ;
00641    po->nFileExtension = (WORD) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00642
00643    GetDlgItemText(hwnd, ID_SZDEFEXTO, (LPTSTR) po->lpstrDefExt, DEFEXTSIZE) ;
00644
00645    GetDlgItemText(hwnd, ID_CUSTDATAO, szNum, 20) ;
00646    po->lCustData = MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00647
00648    GetDlgItemText(hwnd, ID_HOOKO, szNum, 20) ;
00649    po->lpfnHook = (LPOFNHOOKPROC) MyAtol(szNum, uMode==IDM_HEXMODE, &b) ;
00650
00651    GetDlgItemText(hwnd, ID_TEMPLATEO, (LPTSTR) po->lpTemplateName, TEMPNAMESIZE) ;
00652
00653
00654    /*  if we are supposed to use a preloaded resource handle, load it and put it in
00655        OPENFILENAME.hInstance... */
00656
00657    if (IsDlgButtonChecked(hwnd, ID_USEHINSTO) == 1)
00658      po->hInstance = GetCorrectResourceHandle() ;
00659
00660    return ;
00661 }
00662
00663
00664
00665
00666
00667
00668
00669 /************************************************************************
00670
00671
00672   Function: InitFilterString(void)
00673
00674
00675   Purpose:
00676
00677     This function will create a "string" in memory in the form that the
00678     GetOpenFileName() function will expect for the filters it fills into
00679     the "List Files of Type" combo box.
00680
00681   Returns: Nothing.
00682
00683   Comments:
00684
00685     The szFilterInits and szCustFiltInits arrays are initialized to
00686     contain some default strings.  Eventually the strings in
00687     these arrays must be arranged one after the other with a null
00688     character between them and two null characters at the end:
00689
00690     "Text files\0*.txt\0All files\0*.*\0\0"
00691
00692 ************************************************************************/
00693
00694
00695 void InitFilterString(void)
00696 {
00697   int i ;
00698   int nInc = 0 ;
00699   LPTSTR lpStr = szFilterString ;
00700
00701
00702   /* First, zero out this memory just for the sake of sanity */
00703
00704   for (i=0; i<MAXBUF; i++)
00705     szFilterString[i] = 0 ;
00706
00707
00708   /* Now, for each string in the szFilterInits array, concatenate it to
00709      the last one right after the last one's null terminator */
00710
00711   i = 0 ;
00712
00713   while (szFilterInits[i][0] != (TCHAR) 0)
00714   {
00715     lstrcpyn(lpStr, &szFilterInits[i][0], MAXBUF) ;
00716     nInc+=lstrlen(&szFilterInits[i][0]) + 1 ;   //1 past null term...
00717     lpStr = &szFilterString[nInc] ;
00718     i++ ;
00719   }
00720
00721   szFilterString[nInc] = (TCHAR) 0 ;  //double terminator
00722
00723
00724   /* Set the lpszFilterString to point to the memory we just filled in
00725      with the filters because lpszFilterString is what is in
00726      OPENFILENAME->lpstrFilter */
00727
00728   lpszFilterString = szFilterString ;
00729
00730   return ;
00731 }
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741 /************************************************************************
00742
00743
00744   Function: InitCustFiltString(void)
00745
00746
00747   Purpose:
00748
00749     This function will create a "string" in memory in the form that the
00750     GetOpenFileName() function will expect for a custom filter.
00751
00752   Returns: Nothing.
00753
00754   Comments:
00755
00756     The szFilterInits and szCustFiltInits arrays are initialized to
00757     contain some default strings.  Eventually the strings in
00758     these arrays must be arranged one after the other with a null
00759     character between them and two null characters at the end:
00760
00761     "Text files\0*.txt\0All files\0*.*\0\0"
00762
00763     This program initializes these strings, but they do not need to be
00764     initialized.  The GetOpenFileName() functiion will write a filter
00765     into this memory area if the user types a new filter into the
00766     "FileName" box and returns by clicking the OK button (indicating that
00767     a file matching that filter was found).
00768
00769 ************************************************************************/
00770
00771
00772 void InitCustFilterString(void)
00773 {
00774   int i ;
00775   LPTSTR lpStr = szCustFilterString ;
00776   int nInc = 0 ;
00777
00778   for (i=0; i<MAXBUF; i++)
00779     szCustFilterString[i] = 0 ;
00780
00781   i = 0 ;
00782
00783   for(i=0; i<2; i++)  //only two for the custom filter
00784   {
00785     lstrcpyn(lpStr, &szCustFiltInits[i][0], MAXBUF) ;
00786     nInc+=lstrlen(&szCustFiltInits[i][0]) + 1 ;
00787     lpStr = &szCustFilterString[nInc] ;
00788   }
00789
00790   szCustFilterString[nInc] = (TCHAR) 0 ;
00791
00792   lpszCustFilterString = szCustFilterString ;
00793
00794   return ;
00795 }
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805 /************************************************************************
00806
00807   Function: InterpretCustomFilterString(void)
00808
00809
00810   Purpose:
00811
00812     This function will parse the memory that is being used for the
00813     custom filter string.  If the user returned TRUE after entering
00814     their own filter, the new filter will be here and so we need to
00815     add it to our custom filter init array...
00816
00817   Returns: Nothing.
00818
00819   Comments:
00820
00821 ************************************************************************/
00822
00823 void InterpretCustomFilterString(void)
00824 {
00825   LPTSTR pNext ;
00826
00827   int nCount = lstrlen(ofn.lpstrCustomFilter) ;
00828
00829   pNext = ofn.lpstrCustomFilter + nCount + 1 ;  //one past the NULL
00830
00831
00832   /* add it to the filter inits array */
00833
00834   lstrcpyn(&szCustFiltInits[0][0], ofn.lpstrCustomFilter, 30) ;
00835   lstrcpyn(&szCustFiltInits[1][0], pNext, 30) ;
00836
00837 }
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847 /************************************************************************
00848
00849   Function: GetCorrectResourceHandle(void)
00850
00851   Purpose:
00852
00853     This function will use FindResource() to find the correct custom
00854     template resource, use LoadResource() to get a handle to it.
00855
00856   Returns: A handle to a custom template resource.
00857
00858   Comments:
00859
00860     The names for the custom template for GetOpenFileName() are
00861
00862       "opentemp1" -- normal
00863       "opentemp2" -- contains a multi-select list box for the file names
00864
00865     If the user has marked the "Preloaded Template" box and specified
00866     OFN_ENABLETEMPLATEHANDLE in the "Flags" edit box, this handle
00867     will be used to create the GetOpenFileName() dialog box.
00868
00869 ************************************************************************/
00870
00871
00872 HANDLE GetCorrectResourceHandle(void)
00873 {
00874   if (ofn.Flags & OFN_ALLOWMULTISELECT)
00875   {
00876      hRes = FindResource(hInst, TEXT("opentemp2"), RT_DIALOG) ;
00877      hDialog = LoadResource(hInst, hRes) ;
00878   }
00879
00880   else
00881   {
00882      hRes = FindResource(hInst, TEXT("opentemp1"), RT_DIALOG) ;
00883      hDialog = LoadResource(hInst, hRes) ;
00884   }
00885
00886   return hDialog ;
00887 }
00888
00889
00890
00891
00892
00893
00894
00895 /************************************************************************
00896
00897   Function: OpenSaveHookProc(HWND, UINT, WPARAM, LPARAM) ;
00898
00899   Purpose:
00900
00901     This function is the hook function for the GetOpenFileName() function.
00902     If GetOpenFileName() is called with the OFN_ENABLEHOOK flag, this
00903     function will be called before the normal GetOpenFileName() dialog
00904     function is called.
00905
00906   Returns: FALSE to pass the message on to the normal GetOpenFileName()
00907            logic, TRUE to discard the message.
00908
00909   Comments:
00910
00911     To enable this function in this program, enter the value for
00912     OFN_ENABLEHOOK in the "Flags" edit box.
00913
00914 ************************************************************************/
00915
00916
00917 UINT_PTR CALLBACK OpenSaveHookProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00918 {
00919   LPOPENFILENAME pOfn ;
00920   TCHAR szMsg[50] ;
00921
00922   switch(msg)
00923   {
00924     case WM_INITDIALOG:
00925
00926       pOfn = (LPOPENFILENAME) lParam ;
00927
00928
00929       /* During initialization, if there is a hook proc, the getopen()
00930          code will send pointer to the OPENFILENAME strucure in the
00931          lParam.  To demonstrate this, pop up a message box if this
00932          structure has a non zero value in the lCustData structure member */
00933
00934
00935       if (pOfn->lCustData != 0L)
00936       {
00937         wsprintf(szMsg, TEXT("OPENFILENAME->lCustData is: %ld"), pOfn->lCustData) ;
00938
00939         MessageBox(hwnd, szMsg, TEXT("lCustData Sent!"), MB_OK) ;
00940       }
00941
00942       SetWindowText(hwnd, TEXT("Open Hook Proc Dialog")) ;
00943
00944       break ;
00945
00946
00947     /* use the WM_CTLCOLOR* messages to change the color of the Open
00948        dialog */
00949
00950     case WM_CTLCOLORDLG:
00951
00952         if (!hBrushDlg)
00953             hBrushDlg = GetStockObject(LTGRAY_BRUSH) ;
00954
00955         return (LRESULT) hBrushDlg ;
00956
00957         break ;
00958
00959
00960     case WM_CTLCOLORBTN:
00961
00962         SetBkMode((HDC) wParam, TRANSPARENT) ;   //sets background color
00963                                                  //for push and check box
00964                                                  //buttons...
00965
00966         if (!hBrushButton)
00967             hBrushButton = GetStockObject(LTGRAY_BRUSH) ;
00968
00969         return (LRESULT) hBrushButton ;
00970
00971         break ;
00972
00973
00974     case WM_CTLCOLORSTATIC:
00975
00976         SetTextColor((HDC) wParam, RGB(0x00, 0xff, 0x00)) ;  //green
00977         SetBkMode((HDC) wParam, TRANSPARENT) ;               //transparent text
00978
00979         if (!hBrushDlg)
00980             hBrushDlg = GetStockObject(LTGRAY_BRUSH) ;
00981
00982         return (LRESULT) hBrushDlg ;
00983
00984         break ;
00985
00986
00987     case WM_COMMAND:
00988         switch (LOWORD(wParam))
00989         {
00990           case chx1:
00991             MessageBox(hwnd, TEXT("Read-Only button clicked..."),
00992                        TEXT("Open"), MB_OK | MB_APPLMODAL) ;
00993             break ;
00994
00995           case ID_FILEPREVIEW:
00996             MessageBox(hwnd, TEXT("File Preview Button Clicked"),
00997                        TEXT("Open"), MB_OK | MB_APPLMODAL) ;
00998             break ;
00999
01000           default: break ;
01001         }
01002         break ;
01003
01004     default:
01005
01006       if (msg == nOpenShareVMsg)
01007       {
01008         MessageBox(hwnd, TEXT("The SHAREVSTRING message is here!"),
01009                          TEXT("Open"),
01010                          MB_ICONEXCLAMATION | MB_OK | MB_APPLMODAL) ;
01011
01012         return OFN_SHAREWARN ;
01013       }
01014       break ;
01015   }
01016
01017   return FALSE ;   //send msg to the common dialog code
01018 }
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028 /************************************************************************
01029
01030   Function: MultiThreadOpenSave(void)
01031
01032   Purpose:
01033
01034     This function will start two threads and then return.  The two
01035     threads will create GetOpenFileName() dialogs, and the user
01036     can interact with two Open dialogs at once.
01037
01038   Returns: Nothing.
01039
01040   Comments:
01041
01042     This will create two Open dialogs, but they will be created in the
01043     same location on the screen.  The only way to change that would be
01044     to call the function with a hookproc and move one of the windows.
01045
01046     But that would mean that if the user did not enter OFN_ENABLEHOOK
01047     in the "Flags" edit box, we would be no better off than before.  So,
01048     in order to see both dialogs, you just have to move the top one out
01049     of the way a little.
01050
01051     Multithreading note:
01052
01053     This function will return before the common dialog functions return.
01054     Therefore, do not pass any parameters to this function that will be
01055     referenced by the common dialogs because as soon as this function
01056     ends those parameters will be gone.
01057
01058 ************************************************************************/
01059
01060 void MultiThreadOpenSave(void)
01061 {
01062
01063   if (!(hOpenSaveThread1 = CreateThread((LPSECURITY_ATTRIBUTES) NULL, 0,
01064                                         (LPTHREAD_START_ROUTINE) OpenSaveThread1Proc,
01065                                         &dwThreadParm1, CREATE_SUSPENDED, &dwThreadID1)))
01066
01067   {
01068     MessageBox(GetForegroundWindow(), TEXT("Cannot create thread 1"), NULL, MB_OK | MB_ICONEXCLAMATION) ;
01069     OpenMultiThreadEnableButtons(TRUE, hwndMainDialog) ;
01070     nOpenDialogCount = 0 ;
01071     return ;
01072   }
01073
01074
01075
01076   if (!(hOpenSaveThread2 = CreateThread((LPSECURITY_ATTRIBUTES) NULL, 0,
01077                                         (LPTHREAD_START_ROUTINE) OpenSaveThread2Proc,
01078                                         &dwThreadParm2, CREATE_SUSPENDED, &dwThreadID2)))
01079   {
01080     MessageBox(GetForegroundWindow(), TEXT("Cannot create thread 2"), NULL, MB_OK | MB_ICONEXCLAMATION) ;
01081     OpenMultiThreadEnableButtons(TRUE, hwndMainDialog) ;
01082     nOpenDialogCount = 0 ;
01083     return ;
01084   }
01085
01086
01087   ResumeThread(hOpenSaveThread1) ;
01088   ResumeThread(hOpenSaveThread2) ;
01089
01090 }
01091
01092
01093
01094
01095
01096
01097
01098 /************************************************************************
01099
01100   Function: OpenSaveThreadProc1(LPDWORD)
01101
01102   Purpose:
01103
01104     This is the address where the first thread starts executing.
01105
01106   Returns: Any DWORD value.
01107
01108   Comments:
01109
01110 ************************************************************************/
01111
01112
01113 DWORD OpenSaveThread1Proc(LPDWORD pDw)
01114 {
01115
01116   /* Get the user's input */
01117
01118   GetOpenDlg(hwndMainDialog, &ofnThread1) ;
01119
01120
01121   /* Do the dialog */
01122
01123   DoOpenSaveStuff(&ofnThread1) ;
01124
01125
01126   /* send a message to the parent telling it to decrement the dialog count.
01127      When the dialog count reaches zero, all the buttons are enabled again. */
01128
01129   SendMessage(hwndMainDialog, UMSG_DECREMENTDLGCOUNT, 0, 0L) ;
01130
01131   return 0L ;
01132 }
01133
01134
01135
01136
01137
01138
01139
01140 /************************************************************************
01141
01142   Function: OpenSaveThreadProc2(LPDWORD)
01143
01144   Purpose:
01145
01146     This is the address where the second thread starts executing.
01147
01148   Returns: Any DWORD value.
01149
01150   Comments:
01151
01152 ************************************************************************/
01153
01154 DWORD OpenSaveThread2Proc(LPDWORD pDw)
01155 {
01156   GetOpenDlg(hwndMainDialog, &ofnThread2) ;
01157
01158   DoOpenSaveStuff(&ofnThread2) ;
01159
01160   SendMessage(hwndMainDialog, UMSG_DECREMENTDLGCOUNT, 0, 0L) ;
01161
01162   return 0L ;
01163 }
01164
01165
01166
01167
01168
01169
01170
01171 /************************************************************************
01172
01173   Function: DoOpenSaveStuff(LPOPENFILENAME)
01174
01175   Purpose:
01176
01177     This is the function that actually calls GetOpenFileName() or
01178     GetSaveFileName().  It receives a pointer to the structure to
01179     use as its only parameter.
01180
01181   Returns: Nothing.
01182
01183   Comments:
01184
01185 ************************************************************************/
01186
01187 void DoOpenSaveStuff(LPOPENFILENAME po)
01188 {
01189   BOOL bRet = TRUE ;
01190
01191
01192   /* If bOpenDlg is TRUE, do GetOpenFileName(), else do GetSave().
01193      If the "NULL Structure" button is checked, send in a NULL pointer
01194      to the function */
01195
01196   if (bDoOpenDlg)
01197   {
01198     if (IsDlgButtonChecked(hwndMainDialog, ID_NULLSTRUCTO) == 1)
01199       bRet = GetOpenFileName((LPOPENFILENAME) NULL) ;
01200     else
01201       bRet = GetOpenFileName(po) ;
01202   }
01203
01204   else
01205   {
01206     if (IsDlgButtonChecked(hwndMainDialog, ID_NULLSTRUCTO))
01207       bRet = GetSaveFileName((LPOPENFILENAME) NULL) ;
01208     else
01209       bRet = GetSaveFileName(po) ;
01210   }
01211
01212
01213   /* Record the results */
01214
01215   wsprintf(szTemp, szLongFilter, CommDlgExtendedError()) ;
01216   SetDlgItemText(hwndMainDialog, ID_ERRORO, szTemp) ;
01217
01218   wsprintf(szTemp, szShortFilter, (int) bRet) ;
01219   SetDlgItemText(hwndMainDialog, ID_RETURNO, szTemp) ;
01220
01221   InterpretCustomFilterString() ;
01222
01223   FillOpenDlg(hwndMainDialog, po) ;
01224
01225   if (hDialog)
01226   {
01227     FreeResource(hDialog) ;    //free ofn.hInstance
01228     hDialog = (HANDLE) 0 ;
01229     hRes = (HANDLE) 0 ;
01230   }
01231 }
01232
01233
01234
01235
01236
01237
01238
01239 /************************************************************************
01240
01241   Function: OpenMultiThreadEnableButtons(BOOL, HWND)
01242
01243   Purpose:
01244
01245     Enable or disable the buttons that might affect the state of the
01246     OPENFILENAME structures.  This is necessary because during a
01247     multithreading session, these buttons may be accessible even though
01248     there are Open dialogs still working and we don't want to change
01249     the OPENFILENAME structure out from under them.
01250
01251
01252   Returns: Nothing.
01253
01254   Comments:
01255
01256 ************************************************************************/
01257
01258 void OpenMultiThreadEnableButtons(BOOL bEnable, HWND hwnd)
01259 {
01260   EnableWindow(GetDlgItem(hwnd, IDOK), bEnable) ;
01261   EnableWindow(GetDlgItem(hwnd, IDCANCEL), bEnable) ;
01262   EnableWindow(GetDlgItem(hwnd, ID_RESETOPEN), bEnable) ;
01263   EnableWindow(GetDlgItem(hwnd, ID_MULTIOPEN), bEnable) ;
01264 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEmptyVolumeCache Member List

This is the complete list of members for CEmptyVolumeCache, including all inherited members.
CEmptyVolumeCache() | CEmptyVolumeCache |
Deactivate(LPDWORD pdwFlags) | CEmptyVolumeCache |
GetSpaceUsed(DWORDLONG *pdwSpaceUsed, IEmptyVolumeCacheCallBack *picb) | CEmptyVolumeCache |
Initialize(HKEY hKey, LPCWSTR pcwszVolume, LPWSTR *ppwszDisplayName, LPWSTR *ppwszDescription, DWORD *pdwFlags) | CEmptyVolumeCache |
InitializeEx(HKEY hKey, LPCWSTR pcwszVolume, LPCWSTR pcwszKeyName, LPWSTR *ppwszDisplayName, LPWSTR *ppwszDescription, LPWSTR *ppwszBtnText, DWORD *pdwFlags) | CEmptyVolumeCache |
m_nRefCount | CEmptyVolumeCache | [private]
Purge(DWORDLONG dwSpaceToFree, IEmptyVolumeCacheCallBack *picb) | CEmptyVolumeCache |
QueryInterface(REFIID riid, LPVOID *ppvObject) | CEmptyVolumeCache |
ShowProperties(HWND hWnd) | CEmptyVolumeCache |
STDMETHODIMP_(ULONG) AddRef(VOID) | CEmptyVolumeCache |
STDMETHODIMP_(ULONG) Release(VOID) | CEmptyVolumeCache |
~CEmptyVolumeCache() | CEmptyVolumeCache |
Generated on Wed Nov 13 2024 16:56:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CUnknown Member List

This is the complete list of members for CUnknown, including all inherited members.
ActiveComponents() | CUnknown | [inline, protected, static]
AutoQI(DWORD dwCreateOpts) | CUnknown | [inline, virtual]
AutoRelease() | CUnknown | [inline, virtual]
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CFactory class | CUnknown | [friend]
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
CUnknown(IUnknown *pUnknownOuter, LPCSTR className="CUnknown") | CUnknown | [protected]
CUnknown(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CUnknown | [inline]
DisplayObject() | CBase | [virtual]
FinalRelease() | CUnknown | [protected, virtual]
FinishQI(IUnknown *pI, REFIID iid, void **ppv) | CUnknown | [protected]
GetBaseType() | CBase | [inline]
GetDefaultInterface() | CUnknown | [inline, virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CUnknown | [inline, virtual]
GetObjectDesc() | CBase | [inline, virtual]
GetObjectImage() | CUnknown | [inline, virtual]
GetObjectMenu() | CUnknown | [inline, virtual]
GetObjectName() | CUnknown | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetOuterUnknown() const | CUnknown | [inline]
GetParent(SOURCE eSource) | CBase | [virtual]
Init(const CFactoryData *pData)=0 | CUnknown | [protected, pure virtual]
Init() | CUnknown | [inline, protected, virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_cRef | CUnknown | [private]
m_dwCLSCTX | CBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_guidSource | CBase |
m_hTreeItem | CBase |
m_lpstrClass | CUnknown | [private]
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_pUnknownOuter | CUnknown | [private]
m_strObjectDesc | CBase | [protected]
NondelegatingAddRef() | CUnknown | [protected, virtual]
NondelegatingQueryInterface(const IID &, void **) | CUnknown | [protected, virtual]
NondelegatingRelease() | CUnknown | [protected, virtual]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
Quit() | CUnknown | [protected, virtual]
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
s_cActiveComponents | CUnknown | [private, static]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
~CBase() | CBase | [virtual]
~CUnknown() | CUnknown | [protected, virtual]
~CUnknown() | CUnknown | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/StdAfx.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  API.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CController Member List

This is the complete list of members for CController, including all inherited members.
_funAbout | CController | [private]
_funProp | CController | [private]
_hInst | CController | [private]
_pBox | CController | [private]
_pModel | CController | [private]
_pView | CController | [private]
AlertBox(HWND hwnd, UINT ids, UINT fuStyle) | CController |
ButtonDown(HWND hwnd, LPARAM lParam) | CController |
ButtonUp(HWND hwnd, LPARAM lParam) | CController |
Command(HWND hwnd, WPARAM wParam) | CController |
Create(HWND hwnd, LPARAM lParam) | CController |
Destroy() | CController |
HScroll(HWND hwnd, WPARAM wParam, LPARAM lParam) | CController |
Init(HWND hwnd) | CController |
KeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam) | CController |
KeyUp(HWND hwnd, WPARAM wParam, LPARAM lParam) | CController |
Page(HWND hwnd, WPARAM wParam) | CController | [private]
Paint(HWND hwnd) | CController | [inline]
Size(LPARAM lParam) | CController |
VScroll(HWND hwnd, WPARAM wParam, LPARAM lParam) | CController |
Generated on Wed Nov 13 2024 16:55:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

PersistedConfiguration Member List

This is the complete list of members for PersistedConfiguration, including all inherited members.
archiveQuotaPerStream | PersistedConfiguration
backendServer | PersistedConfiguration
cacheDirectoryPath | PersistedConfiguration
cacheOnDemandCacheMiss | PersistedConfiguration
diskQuota | PersistedConfiguration
enableCaching | PersistedConfiguration
enableProxy | PersistedConfiguration
handleUpstreamCacheRequests | PersistedConfiguration
protocol | PersistedConfiguration
proxyOnDemandCacheMiss | PersistedConfiguration
reverseProxyRedirectURL | PersistedConfiguration
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsecure/filerepclientproc.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsecure

filerepclientproc.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Client System Service
00006
00007     FILE: FileRepClientProc.cpp
00008
00009     PURPOSE: Remote procedures for client system service
00010
00011     FUNCTIONS:
00012         RequestFile() - receives file replication requests
00013   ThreadProcRequest() - processes file replication requests
00014     in an independent thread.
00015
00016     COMMENTS:
00017
00018 */
00019
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <tchar.h>
00023 #include <rpc.h>
00024 #include <Ntdsapi.h>
00025
00026 #include "common.h"
00027
00028 // header file generated by MIDL compiler
00029 #include "FileRepClient.h"
00030 #include "FileRepServer.h"
00031
00032 // Contains declarations for system service functions.
00033 #include "Service.h"
00034
00035 // This structure simply packages up the variables to be passed
00036 // to the processing thread.
00037 typedef struct {
00038     handle_t hFileRepServer;
00039     HANDLE hLocalFile;
00040     PCONTEXT_HANDLE_TYPE phContext;
00041     BYTE pbBuf[MAX_BUFSIZE];
00042
00043     // Set when we are impersonating the client.
00044     BOOL bImpersonating;
00045
00046 #ifdef PROF
00047     ULONG nReqId;
00048 #endif
00049 } ThreadArgs;
00050
00051 // Closes the file handle and frees all thread data if an error occured
00052 // in one of the following functions.
00053 VOID ShutdownThread(ThreadArgs *pArgs) {
00054     INT status;
00055     RPC_STATUS rpcstatus;
00056
00057     if(pArgs != NULL) {
00058
00059         // Stop impersonating if we are.
00060         // The first thing we do in handling a request is impersonating the client.
00061         if (pArgs->bImpersonating) {
00062             if ((rpcstatus = RpcRevertToSelf()) != RPC_S_OK) {
00063
00064           // Do the remaining cleanup.
00065           pArgs->bImpersonating = FALSE;
00066     ShutdownThread(pArgs);
00067
00068     RpcRaiseException(rpcstatus);
00069     return;
00070       }
00071   }
00072
00073   if(pArgs->hFileRepServer != NULL) {
00074       rpcstatus = RpcBindingFree(&(pArgs->hFileRepServer));
00075       ASSERTE(rpcstatus == RPC_S_OK);
00076   }
00077   // Check that hLocalFile has been initialized and that initialization
00078   // was successful.
00079   if(pArgs->hLocalFile != NULL && pArgs->hLocalFile != INVALID_HANDLE_VALUE) {
00080       status = CloseHandle(pArgs->hLocalFile);
00081       ASSERTE(status != 0);
00082   }
00083   if(pArgs->phContext != NULL) {
00084       RpcSsDestroyClientContext((VOID **)&pArgs->phContext);
00085   }
00086
00087   AutoHeapFree(pArgs);
00088     }
00089 }
00090
00091 /*
00092     FUNCTIONS: ThreadProcRequest
00093
00094     PURPOSE:
00095         Called by FileRepRequestFile to have the Client System
00096         Service process the remainder of a file replication request.
00097
00098     PARAMETERS:
00099         Self-explanatory.
00100
00101     RETURN VALUE: none
00102
00103 */
00104 VOID ThreadProcRequest(ThreadArgs *pArgs) {
00105     UINT i = 0;
00106     ULONG cbRead, cbWritten;
00107
00108     TCHAR Msg[MSG_SIZE];
00109
00110     // Get the remainder of text from the remote file.  When the
00111     // server returns a NULL context handle, the read has completed and
00112     // the file has been closed.
00113     do {
00114
00115         // We did not read anything yet.
00116         cbRead = 0;
00117
00118 #ifdef RETRY_EXCEPTION
00119   // When making aggressive calls to the server, this flag is
00120   // set when the call succeeded.  This makes the client service attempt
00121   // to contact the server even after an exception occured.
00122   BOOL bRetryCall = TRUE;
00123   while (bRetryCall) {
00124 #endif
00125
00126         RpcTryExcept {
00127             c_RemoteRead(pArgs->hFileRepServer,
00128        &(pArgs->phContext),
00129        pArgs->pbBuf,
00130        &cbRead);
00131
00132 #ifdef RETRY_EXCEPTION
00133       bRetryCall = FALSE;
00134 #endif
00135
00136   }
00137         RpcExcept ( ( (RpcExceptionCode() != STATUS_ACCESS_VIOLATION) &&
00138           (RpcExceptionCode() != STATUS_DATATYPE_MISALIGNMENT) &&
00139           (RpcExceptionCode() != STATUS_PRIVILEGED_INSTRUCTION) &&
00140           (RpcExceptionCode() != STATUS_ILLEGAL_INSTRUCTION) &&
00141           (RpcExceptionCode() != STATUS_BREAKPOINT))
00142         ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) {
00143
00144       // Log the error code as well as the error.
00145       // Msg is sufficiently large and can't overflow.
00146       _stprintf(Msg, TEXT("ThreadProcRequest: Exception: c_RemoteRead failed with code %d"), RpcExceptionCode());
00147       AddToMessageLog(Msg);
00148
00149 #ifdef RETRY_EXCEPTION
00150       // This code attempts to make aggressive calls, retrying
00151       // if no endpoints were available.  It is used to put servers
00152       // under stress.
00153       if (RpcExceptionCode() != EPT_S_NOT_REGISTERED &&
00154     RpcExceptionCode() != RPC_S_SERVER_UNAVAILABLE) {
00155 #endif
00156
00157       // Deallocate all the thread data before failing.
00158       ShutdownThread(pArgs);
00159       RpcRaiseException(RpcExceptionCode());
00160       return;
00161 #ifdef RETRY_EXCEPTION
00162       }
00163 #endif
00164   }
00165   RpcEndExcept;
00166
00167 #ifdef RETRY_EXCEPTION
00168   }
00169 #endif
00170
00171   // Access check was done on opening when we were impersonating.
00172   // Thus we do not need to impersonate in this code.
00173   if(!WriteFile(pArgs->hLocalFile,
00174           pArgs->pbBuf,
00175           cbRead,
00176           &cbWritten,
00177           NULL)) {
00178
00179       _stprintf(Msg, TEXT("ThreadProcRequest: WriteFile failed with code %d"), GetLastError());
00180       AddToMessageLog(Msg);
00181
00182       ShutdownThread(pArgs);
00183       return;
00184   }
00185     } while(pArgs->phContext != NULL);
00186
00187 #ifdef PROF
00188     ProfRecordTime(pArgs->nReqId, TEXT("handled"));
00189 #endif
00190
00191     ShutdownThread(pArgs);
00192
00193     // After this procedure returns the replication request will have
00194     // been handled.
00195     return;
00196 }
00197
00198 /*
00199     FUNCTIONS: RequestFile
00200
00201     PURPOSE:
00202         Called by FileRep to have the Client System
00203         Service request file replication from a Server System Service.
00204
00205     PARAMETERS:
00206         Self-explanatory.
00207
00208     RETURN VALUE: STATUS_SUCCESS or 1
00209
00210 */
00211 VOID RequestFile(handle_t hFileRepClient,
00212      LPTSTR ServerName,
00213      LPTSTR RemoteFileName,
00214      LPTSTR LocalFileName)
00215 {
00216     INT status;
00217     RPC_STATUS rpcstatus;
00218
00219     ULONG cbRead, cbWritten;
00220
00221     // Default connection to server system service is over TCP/IP.
00222     LPTSTR DefaultProtocolSequence = TEXT("ncacn_ip_tcp");
00223
00224     // An empty endpoint string is used, since we are going to
00225     // connect to the endpoint dynamically generated by the
00226     // RPC run-time library.    Server calls RpcServerUseProtseq to
00227     // obtain a binding hadnle and a dynamic endpoint.
00228     LPTSTR DefaultEndpoint = TEXT("");
00229
00230     LPTSTR pszUuid = NULL;
00231     LPTSTR pszOptions = NULL;
00232     LPTSTR pszStringBinding = NULL;
00233
00234     ULONG ThreadIdentifier;
00235     HANDLE hThread;
00236
00237     ThreadArgs *pArgs = NULL;
00238
00239     ULONG ulAuthnLevel;
00240
00241     // Quality of service structure to ensure authentication.
00242     RPC_SECURITY_QOS SecurityQOS;
00243
00244     // The string binding that is used to make sure clients contact the
00245     // service via an LRPC call.
00246     LPTSTR StringBinding;
00247
00248     // The protocol sequence that gets extracted from the string binding.
00249     LPTSTR ProtSeq;
00250
00251     // The length of the principal name and the principal name
00252     // for the client system service.
00253     TCHAR szSpn[MAX_PATH];
00254     ULONG ulSpn = sizeof(szSpn);
00255
00256     if((pArgs = (ThreadArgs *) AutoHeapAlloc(sizeof(ThreadArgs))) == NULL) {
00257         RpcRaiseException(ERROR_OUTOFMEMORY);
00258         return;
00259     }
00260
00261     // Set pArgs' fields to NULL so that we will know
00262     // in ShutdownThread which ones have been initialized.
00263     pArgs->hFileRepServer = NULL;
00264     pArgs->hLocalFile = NULL;
00265     pArgs->phContext = NULL;
00266     pArgs->bImpersonating = FALSE;
00267
00268 #ifdef PROF
00269     static ULONG nTotalId;
00270
00271     if (WaitForSingleObject(hProfMutex, INFINITE) == WAIT_FAILED) {
00272   ShutdownThread(pArgs);
00273   RaiseException(GetLastError(), 0, 0, NULL);
00274   return;
00275     }
00276
00277     // Record the number of the current request.
00278     pArgs->nReqId = nTotalId;
00279     // Increment the number of the request.
00280     nTotalId++;
00281
00282     if (ReleaseMutex(hProfMutex) == FALSE) {
00283   ShutdownThread(pArgs);
00284   RaiseException(GetLastError(), 0, 0, NULL);
00285   return;
00286     }
00287
00288     TCHAR ProfMsg[MAX_PATH+16];
00289     _stprintf(ProfMsg, TEXT("name=\"%s\" arrived"), RemoteFileName);
00290
00291     // Record the time of arrival of this request.
00292     ProfRecordTime(pArgs->nReqId, ProfMsg);
00293 #endif
00294
00295     // Make sure that the client utility is local.
00296     // Client system service only services LRPC calls.
00297     if ((rpcstatus = RpcBindingToStringBinding(hFileRepClient, &StringBinding)) != RPC_S_OK) {
00298   ShutdownThread(pArgs);
00299         RpcRaiseException(rpcstatus);
00300   return;
00301     }
00302     if ((rpcstatus = RpcStringBindingParse(StringBinding, NULL, &ProtSeq, NULL, NULL, NULL)) != RPC_S_OK) {
00303
00304   // Free the string binding.
00305   rpcstatus = RpcStringFree(&StringBinding);
00306   ASSERTE(rpcstatus == RPC_S_OK);
00307
00308   ShutdownThread(pArgs);
00309         RpcRaiseException(rpcstatus);
00310   return;
00311     }
00312     if (_tcscmp(ProtSeq, TEXT("ncalrpc")) != 0) {
00313
00314   // Free the string binding.
00315   rpcstatus = RpcStringFree(&StringBinding);
00316   ASSERTE(rpcstatus == RPC_S_OK);
00317   // And the protocol sequence
00318   rpcstatus = RpcStringFree(&ProtSeq);
00319   ASSERTE(rpcstatus == RPC_S_OK);
00320
00321   ShutdownThread(pArgs);
00322         RpcRaiseException(RPC_S_INVALID_RPC_PROTSEQ);
00323   return;
00324     }
00325
00326     // Free the string binding.
00327     rpcstatus = RpcStringFree(&StringBinding);
00328     ASSERTE(rpcstatus == RPC_S_OK);
00329     // And the protocol sequence.
00330     rpcstatus = RpcStringFree(&ProtSeq);
00331     ASSERTE(rpcstatus == RPC_S_OK);
00332
00333     // Get client security info.
00334     if (RpcBindingInqAuthClient(hFileRepClient,
00335         NULL,
00336         NULL,
00337         &ulAuthnLevel,
00338         NULL,
00339         NULL) != RPC_S_OK) {
00340
00341   ShutdownThread(pArgs);
00342         RpcRaiseException(GetLastError());
00343   return;
00344     }
00345
00346     // Make sure the client has adequate security measures.
00347     // Since this is LRPC, we get the security level of privacy
00348     // because it is the only available security level.
00349     // We do not interoperate with old versions of FileRep
00350     // client utilities, since appropriate versions should be
00351     // available with the local system service.
00352     if (ulAuthnLevel != RPC_C_AUTHN_LEVEL_PKT_PRIVACY) {
00353   ShutdownThread(pArgs);
00354         RpcRaiseException(RPC_S_SEC_PKG_ERROR);
00355   return;
00356     }
00357
00358     // We need to impersonate the user that has issued the
00359     // remote call.
00360     // We want to impersonate as soon as possible to minimise
00361     // the amount of resources that can be consumed by an attack.
00362     if ((rpcstatus = RpcImpersonateClient(hFileRepClient)) != RPC_S_OK) {
00363   ShutdownThread(pArgs);
00364         RpcRaiseException(rpcstatus);
00365   return;
00366     }
00367     pArgs->bImpersonating = TRUE;
00368
00369     // Prepare the binding information.
00370     if ((rpcstatus = RpcStringBindingCompose(pszUuid,
00371                DefaultProtocolSequence,
00372                ServerName,
00373                DefaultEndpoint,
00374                pszOptions,
00375                &pszStringBinding)) != RPC_S_OK) {
00376
00377   ShutdownThread(pArgs);
00378         RpcRaiseException(rpcstatus);
00379   return;
00380     }
00381
00382     if ((rpcstatus = RpcBindingFromStringBinding(pszStringBinding, &(pArgs->hFileRepServer))) != RPC_S_OK) {
00383   // The binding handle is invalid
00384   pArgs->hFileRepServer = NULL;
00385
00386   // Deallocate the string binding.
00387   rpcstatus = RpcStringFree(&pszStringBinding);
00388   ASSERTE(rpcstatus == RPC_S_OK);
00389
00390   ShutdownThread(pArgs);
00391         RpcRaiseException(rpcstatus);
00392   return;
00393     }
00394
00395     // We need to delete the string binding, since it is no longer
00396     // necessary.  All the binding information is now contained in the
00397     // binding handle.
00398     rpcstatus = RpcStringFree(&pszStringBinding);
00399     ASSERTE(rpcstatus == RPC_S_OK);
00400
00401     // Generate a principal name for the local system service.
00402     if ((status = DsMakeSpn(SERVICENAME,
00403           ServerName,
00404           NULL,
00405           0,
00406           0,
00407           &ulSpn,
00408           szSpn)) != ERROR_SUCCESS) {
00409   ShutdownThread(pArgs);
00410         RpcRaiseException(rpcstatus);
00411   return;
00412     }
00413
00414     // Specify quality of service parameters.
00415     SecurityQOS.Version = RPC_C_SECURITY_QOS_VERSION;
00416     SecurityQOS.Capabilities = RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH;
00417     // Use static identity tracking since we will be issuing multiple
00418     // RPC calls from this thread with different identities: while
00419     // impersonating, and while not.  This insures that all the calls will
00420     // go to server under the identity of the user who created the binding
00421     // handle.
00422     SecurityQOS.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC;
00423     // The client system service needs to impersonate the security context
00424     // of the client utility on the remote systems where it may replicate
00425     // files from.  It will also need to obtain client's SID and hence
00426     // requires impersonation.
00427     SecurityQOS.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE;
00428
00429     // Set authentification and authorisation information for
00430     // the binding handle.
00431     if ((rpcstatus = RpcBindingSetAuthInfoEx(pArgs->hFileRepServer, szSpn, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_AUTHN_GSS_KERBEROS, NULL, RPC_C_AUTHZ_NAME, &SecurityQOS)) != RPC_S_OK) {
00432
00433   ShutdownThread(pArgs);
00434         RpcRaiseException(rpcstatus);
00435   return;
00436     }
00437
00438     // We did not read anything yet.
00439     cbRead = 0;
00440
00441 #ifdef RETRY_EXCEPTION
00442     // When making aggressive calls to the server, this flag is
00443     // set when the call succeeded.  This makes the client service attempt
00444     // to contact the server even after an exception occured.
00445     BOOL bRetryCall = TRUE;
00446     while (bRetryCall) {
00447 #endif
00448
00449     // Attempt to open the remote file.
00450     RpcTryExcept {
00451         c_RemoteOpen(pArgs->hFileRepServer,
00452          &(pArgs->phContext),
00453          RemoteFileName,
00454          pArgs->pbBuf,
00455          &cbRead);
00456
00457 #ifdef RETRY_EXCEPTION
00458   bRetryCall = FALSE;
00459 #endif
00460
00461     }
00462     RpcExcept ( ( (RpcExceptionCode() != STATUS_ACCESS_VIOLATION) &&
00463       (RpcExceptionCode() != STATUS_DATATYPE_MISALIGNMENT) &&
00464       (RpcExceptionCode() != STATUS_PRIVILEGED_INSTRUCTION) &&
00465       (RpcExceptionCode() != STATUS_ILLEGAL_INSTRUCTION) &&
00466       (RpcExceptionCode() != STATUS_BREAKPOINT) )
00467       ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) {
00468
00469 #ifdef RETRY_EXCEPTION
00470   // This code attempts to make aggressive calls, retrying
00471   // if no endpoints are available.  It is used to put servers
00472   // under stress.
00473   if (RpcExceptionCode() != EPT_S_NOT_REGISTERED &&
00474       RpcExceptionCode() != RPC_S_SERVER_UNAVAILABLE) {
00475 #endif
00476
00477   // Deallocate all the thread data before failing.
00478   ShutdownThread(pArgs);
00479         RpcRaiseException(RpcExceptionCode());
00480   return;
00481
00482 #ifdef RETRY_EXCEPTION
00483         }
00484 #endif
00485
00486     }
00487     RpcEndExcept;
00488
00489 #ifdef RETRY_EXCEPTION
00490     }
00491 #endif
00492
00493     // Attempt to open the local file.
00494     if ((pArgs->hLocalFile = CreateFile(LocalFileName,
00495           GENERIC_WRITE,
00496           0,
00497           NULL,
00498           CREATE_ALWAYS,
00499           FILE_ATTRIBUTE_NORMAL,
00500           NULL)) == INVALID_HANDLE_VALUE) {
00501   ShutdownThread(pArgs);
00502         RpcRaiseException(GetLastError());
00503   return;
00504     }
00505
00506     // We need to stop impersonating before thread creation.
00507     // Also, since all files have been open the required security
00508     // checks have been done and impersonating is no longer necessary.
00509     if ((rpcstatus = RpcRevertToSelf()) != RPC_S_OK) {
00510         pArgs->bImpersonating = FALSE;
00511
00512         ShutdownThread(pArgs);
00513   RpcRaiseException(rpcstatus);
00514   return;
00515     }
00516     pArgs->bImpersonating = FALSE;
00517
00518     // Write the data received to local file.
00519     if(!WriteFile(pArgs->hLocalFile,
00520       pArgs->pbBuf,
00521       cbRead,
00522       &cbWritten,
00523       NULL)){
00524
00525   ShutdownThread(pArgs);
00526         RpcRaiseException(GetLastError());
00527         return;
00528     }
00529
00530     // If there are no errors and the call returned NULL, then
00531     // the file was read in a single call and has already been closed.
00532     // We just need to write the buffer and return.
00533     if(pArgs->phContext == NULL){
00534
00535 #ifdef PROF
00536   ProfRecordTime(pArgs->nReqId, TEXT("handled"));
00537 #endif
00538
00539   ShutdownThread(pArgs);
00540         return;
00541     }
00542
00543     // We need to read and close the file on a different
00544     // thread so that the client replication utility can return.
00545     // The data will be transfered in the background.
00546     if((hThread = CreateThread(NULL,
00547              0,
00548              (LPTHREAD_START_ROUTINE) ThreadProcRequest,
00549              pArgs,
00550              0,
00551              &ThreadIdentifier)) == NULL) {
00552
00553   ShutdownThread(pArgs);
00554         RpcRaiseException(GetLastError());
00555   return;
00556     }
00557
00558     // Unless we close a handle to the thread, it will remain in the
00559     // system even after its execution has terminated.
00560     status = CloseHandle(hThread);
00561     ASSERTE(status != 0);
00562
00563     // The memory will be freed and handles closed in ThreadProcRequest.
00564
00565     return;
00566 }
00567
00568 // end FileRepClientProc.cpp
00569
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step1/HelloWorld.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step1

HelloWorld.cpp

Go to the documentation of this file.
00001 // HelloWorld.cpp : Implementation of CADsFirstExtApp and DLL registration.
00002
00003 #include "stdafx.h"
00004 #include "ADsFirstExt.h"
00005 #include "HelloWorld.h"
00006
00007
00008 /////////////////////////////////////////////////////////////////////////////
00009 //
00010
00011 STDMETHODIMP HelloWorld::InterfaceSupportsErrorInfo(REFIID riid)
00012 {
00013   static const IID* arr[] =
00014   {
00015     &IID_IHelloWorld,
00016   };
00017
00018   for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00019   {
00020     if (::InlineIsEqualGUID(*arr[i],riid))
00021       return S_OK;
00022   }
00023   return S_FALSE;
00024 }
00025
00026 STDMETHODIMP HelloWorld::Say()
00027 {
00028   AFX_MANAGE_STATE(AfxGetStaticModuleState())
00029
00030   IADs *pADs;
00031   HRESULT hr;
00032   BSTR    bstr;
00033   TCHAR  szText[256];
00034
00035
00036
00037   hr = OuterQueryInterface(IID_IADs, (void **) &pADs );
00038   if ( !SUCCEEDED(hr) )
00039   {
00040     return hr;
00041   }
00042
00043   hr = pADs->get_Name(&bstr);
00044   if ( !SUCCEEDED(hr) )
00045   {
00046     pADs->Release();
00047     return hr;
00048   }
00049
00050   ////////////////////////////////////////
00051   // Check for buffer overrun.
00052   UINT nMaxLen = sizeof(szText)/sizeof(TCHAR);
00053   UINT nLength = SysStringLen(bstr);
00054   TCHAR  szHelloFmt[] = _T("Hello %S");
00055   UINT fmtLen = sizeof(szHelloFmt)/sizeof(TCHAR);
00056
00057   if ( nMaxLen <= (nLength+fmtLen) )
00058   {
00059     _tcscpy(szText,_T("Your string is too long"));
00060
00061   }
00062   else
00063   {
00064     wsprintf(szText, _T("Hello %S"), bstr );
00065   }
00066
00067
00068
00069   SysFreeString(bstr);
00070
00071
00072   ::MessageBox(NULL, szText, _T("From ADSI Extension"), MB_OK);
00073   pADs->Release();
00074
00075   return S_OK;
00076 }
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/TextFx/Fx.c Source File

  • Multimedia
  • Gdi
  • TextFx

Fx.c

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1992 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \*****************************************************************************/
00010 /*****************************************************************************
00011  *                                       *
00012  *  FX.C                                                 *
00013  *                                       *
00014  *  PURPOSE:  Routines for rendering text with stange effects                *
00015  *                                       *
00016  *                                       *
00017  *  FillOut            - Converts an array of line segments into an array of *
00018  *                       all the points in the segments              *
00019  *                                       *
00020  *  RenderPathPoints   - Renders the outline of points returned from GetPath *
00021  *                                       *
00022  *  RenderAndFillPath  - Renders the points returned from GetPath as a       *
00023  *                       filled polygon                    *
00024  *                                       *
00025  *  TextEffect         - Draws a string of text between two guide lines      *
00026  *                                       *
00027  *****************************************************************************/
00028
00029 #include <windows.h>
00030 #include "fx.h"
00031
00032 // This structure is used by FillOut for passing data into LineDDA
00033 typedef struct tagSEG {
00034   DWORD dwPos;
00035   LPPOINT lpPoints;
00036 } PTS;
00037
00038 /**********************************************************************
00039  *                                                                    *
00040  * AddSegment - used with LineDDA to add points from a line segment   *
00041  *    to an array containing all the points on a set of line segments *
00042  *                                                                    *
00043  *********************************************************************/
00044 VOID CALLBACK AddSegment(int x, int y, PTS *pts)
00045 {
00046    pts->lpPoints[pts->dwPos].x = x;
00047    pts->lpPoints[pts->dwPos].y = y;
00048    pts->dwPos++;
00049 }
00050
00051 /**********************************************************************
00052  *                                                                    *
00053  * CountPoints - used with LineDDA to determine the number of points  *
00054  *    needed to store all the points on a set of line segments        *
00055  *                                                                    *
00056  *********************************************************************/
00057 VOID CALLBACK CountPoints(int x, int y, LPDWORD lpdwNumPts)
00058 {
00059    (*lpdwNumPts)++;
00060
00061    UNREFERENCED_PARAMETER(x);
00062    UNREFERENCED_PARAMETER(y);
00063 }
00064
00065
00066 /**********************************************************************
00067  *                                                                    *
00068  * FUNCTION:  FillOut(LPPOINT, LPDWORD)                               *
00069  *                                    *
00070  * PURPOSE:   Converts an array of line segments into an array of all *
00071  *            of the points comprising the line segments.             *
00072  *                                                                    *
00073  *********************************************************************/
00074 BOOL FillOut(LPPOINT *lpPoints, LPDWORD lpdwNumPts)
00075 {
00076    DWORD i;
00077    LPPOINT lpPts = *lpPoints;
00078    PTS pts;
00079    DWORD dwNumPts = 0;
00080
00081    // Make sure we have at least two points
00082    if (*lpdwNumPts < 2) {
00083      MessageBox(NULL, "You need at least two points for a guide line.", "Not enough points!", MB_ICONSTOP);
00084      *lpdwNumPts = 0;
00085      return FALSE;
00086    }
00087
00088    // Find out how namy points are on the segments
00089    for (i=0; i<*lpdwNumPts - 1; i++)
00090      LineDDA(lpPts[i].x, lpPts[i].y, lpPts[i+1].x, lpPts[i+1].y, (LINEDDAPROC)CountPoints, (LPARAM)&dwNumPts);
00091
00092    // If there are too many points, print an anoying message so the user doesnt do it again
00093    if (dwNumPts > MAXFILLPOINTS) {
00094      MessageBox(NULL, "Make your guide lines a bit shorter please!", "Too many points!", MB_ICONSTOP);
00095      *lpdwNumPts = 0;
00096      return FALSE;  // Bail
00097    }
00098
00099    // Allocate memory for the the points and initialize our "last point" index
00100    pts.lpPoints = (LPPOINT)GlobalAlloc(GPTR, dwNumPts * sizeof(POINT));
00101    pts.dwPos = 0;
00102
00103    // Convert the segments to points
00104    for (i=0; i<*lpdwNumPts - 1; i++)
00105      LineDDA(lpPts[i].x, lpPts[i].y, lpPts[i+1].x, lpPts[i+1].y, (LINEDDAPROC)AddSegment, (LPARAM)&pts);
00106
00107    // Get rid of the original array of segments...
00108    GlobalFree(lpPts);
00109
00110    // ... and replace it with the new points
00111    *lpPoints = pts.lpPoints;
00112    *lpdwNumPts = pts.dwPos;
00113
00114    // Check to see if anything hit the fan
00115    if (!pts.dwPos)
00116      return FALSE;
00117
00118    return TRUE;
00119 }
00120
00121 /**********************************************************************
00122  *                                                                    *
00123  * FUNCTION:  PolyDraw95(HDC, LPPOINT, LPBYTE, int)                   *
00124  *                                    *
00125  * PURPOSE:   Draws the points returned from a call to GetPath()      *
00126  *            to an HDC                                               *
00127  *                                                                    *
00128  * NOTES:     This function is similar to the Windows NT function     *
00129  *            PolyDraw which draws a set of line segments and Bézier  *
00130  *            curves.  Since PolyDraw is not supported on Windows 95  *
00131  *            this PolyDraw95 is used instead.                        *
00132  *                                                                    *
00133  *********************************************************************/
00134 BOOL PolyDraw95(HDC  hdc,              // handle of a device context
00135                 CONST LPPOINT lppt,    // address of array of points
00136                 CONST LPBYTE lpbTypes, // address of line and curve identifiers
00137                 int  cCount)         // count of points
00138 {
00139   int i;
00140
00141   for (i=0; i<cCount; i++)
00142     switch (lpbTypes[i]) {
00143       case PT_MOVETO :
00144          MoveToEx(hdc, lppt[i].x, lppt[i].y, NULL);
00145          break;
00146
00147       case PT_LINETO | PT_CLOSEFIGURE:
00148       case PT_LINETO :
00149          LineTo(hdc, lppt[i].x, lppt[i].y);
00150          break;
00151
00152       case PT_BEZIERTO | PT_CLOSEFIGURE:
00153       case PT_BEZIERTO :
00154        PolyBezierTo(hdc, &lppt[i], 3);
00155      i+=2;
00156          break;
00157    }
00158
00159    return TRUE;
00160 }
00161
00162
00163 /**********************************************************************
00164  *                                                                    *
00165  * FUNCTION:  RenderPathPoints(HDC, LPPOINT, LPBYTE, int, BOOL)       *
00166  *                                    *
00167  * PURPOSE:   Renders the points returned from a call to GetPath()    *
00168  *            by converting them back into a path and calling either  *
00169  *            FillPath or StrokePath to display them.                 *
00170  *                                                                    *
00171  * NOTE:      The R2_MERGEPENNOT is used here so that things like the *
00172  *            inside of and "a" or an "o" get painted correctly when  *
00173  *            using FillPath.                                         *
00174  *                                                                    *
00175  *********************************************************************/
00176 BOOL RenderPathPoints(HDC hDC, LPPOINT lpPoints, LPBYTE lpTypes, int iNumPts, BOOL bOutline)
00177 {
00178   BeginPath(hDC); // Draw into a path so that we can use FillPath()
00179
00180   PolyDraw95(hDC, lpPoints, lpTypes, iNumPts);
00181
00182   CloseFigure(hDC);
00183   EndPath(hDC);
00184
00185   // Draw the path
00186   if (bOutline)
00187     StrokePath(hDC); // As an outline
00188   else
00189   {              // As solid figures
00190         int iROP2 = SetROP2(hDC, R2_MERGEPENNOT);
00191         HPEN hPen = SelectObject(hDC, GetStockObject(NULL_PEN)); // Just say "no" to outlines
00192         HBRUSH hBrush = SelectObject(hDC, GetStockObject(BLACK_BRUSH)); // Paint It Black
00193
00194         FillPath(hDC);
00195
00196         // Restore the DC to its previous state
00197         SetROP2(hDC, iROP2);
00198         SelectObject(hDC, hPen);
00199         SelectObject(hDC, hBrush);
00200   }
00201
00202   return TRUE;
00203 }
00204
00205
00206 /**********************************************************************
00207  *                                                                    *
00208  * FUNCTION:  GetRealTextExtent(LPPOINT, int, LPSIZE)                 *
00209  *                                    *
00210  * PURPOSE:   Makes sure that the extents in a SIZE are large enough  *
00211  *            to bound the points in an array.                        *
00212  *                                                                    *
00213  * NOTES:     Why not just use GetTextExtentPoint32?  Well, the text  *
00214  *            extents returned by GetTextExtentPoint32 dont include   *
00215  *            the overhang of an italics character into the next      *
00216  *            cell.  This function expands the extents to include     *
00217  *            the greatest x, and y extents of the string data.       *
00218  *                                                                    *
00219  *********************************************************************/
00220 void GetRealTextExtent(LPPOINT lpPoints, int iNumPts, LPSIZE size)
00221 {
00222   int i;
00223
00224   for (i=0; i<iNumPts; i++) {
00225     if (lpPoints[i].x > size->cx) size->cx = lpPoints[i].x;
00226     if (lpPoints[i].y > size->cy) size->cy = lpPoints[i].y;
00227   }
00228 }
00229
00230 /**********************************************************************
00231  *                                                                    *
00232  * FUNCTION:  TextEffect(HDC, LPPOINT, LPPOINT, DWORD, DWORD,         *
00233  *                            LPSTR, BOOL)                *
00234  *                                    *
00235  * PURPOSE:   Draws a string of text in the currently selected font   *
00236  *            using two arrays of points as guide lines for orienting *
00237  *            the text.  The text can be displayed either as outlines *
00238  *            or as filled characters.                                *
00239  *                                                                    *
00240  *********************************************************************/
00241 BOOL TextEffect(HDC hDC,            // DC to display into
00242                 LPPOINT lpTop,    // Top guide line
00243                 LPPOINT lpBot,    // Bottom guide line
00244                 DWORD dwTopPts,   // Number of points in top guide
00245                 DWORD dwBotPts,   // Number of points in bottom guide
00246                 LPSTR szText,     // Text string to apply effects to
00247                 BOOL bOutlineOnly)  // Print as outline or as solid text
00248 {
00249   LPPOINT lpPoints;     // Path data points
00250   LPBYTE lpTypes;       // Path data types
00251   int i, iNumPts;
00252   SIZE size = {0,0};          // Text size info
00253   int iTopInd, iBotInd;   // Guide array indices
00254   float fXScale, fYScale;   // Scaling values
00255
00256   // Set to transparent so we dont get an outline around the text string
00257   SetBkMode(hDC, TRANSPARENT);
00258
00259   // Output the text into a path
00260   BeginPath(hDC);
00261   __try {
00262     TextOut(hDC, 0, 0, szText, strlen(szText));
00263   } __except (EXCEPTION_EXECUTE_HANDLER) {
00264     return FALSE;
00265   }
00266   EndPath(hDC);
00267
00268   // How many points are in the path
00269   iNumPts = GetPath(hDC, NULL, NULL, 0);
00270   if (iNumPts == -1) return FALSE;
00271
00272   // Allocate room for the points
00273   lpPoints = (LPPOINT)GlobalAlloc(GPTR, sizeof(POINT) * iNumPts);
00274   if (!lpPoints) return FALSE;
00275
00276   // Allocate room for the point types
00277   lpTypes = GlobalAlloc(GPTR, iNumPts);
00278   if (!lpTypes) {
00279     GlobalFree(lpPoints);
00280     return FALSE;
00281   }
00282
00283   // Get the points and types from the current path
00284   iNumPts = GetPath(hDC, lpPoints, lpTypes, iNumPts);
00285
00286   // Even more error checking
00287   if (iNumPts == -1) {
00288     GlobalFree(lpTypes);
00289     GlobalFree(lpPoints);
00290     return FALSE;
00291   }
00292
00293   // Get the exact extents of our text
00294   GetRealTextExtent(lpPoints, iNumPts, &size);
00295
00296   // Relocate the points in the path based on the guide lines
00297   for (i=0; i < iNumPts; i++) {
00298     // How far along is this point on the x-axis
00299     fXScale = (float)lpPoints[i].x / (float)size.cx;
00300
00301     // What point on the top guide does this coorespond to
00302     iTopInd = (int)(fXScale * (dwTopPts-1));
00303     // What point on the bottom guide does this coorespond to
00304     iBotInd = (int)(fXScale * (dwBotPts-1));
00305
00306     // How far along is this point on the y-axis
00307     fYScale = (float)lpPoints[i].y / (float)size.cy;
00308
00309     // Scale the points to their new locations
00310     lpPoints[i].x = (int)((lpBot[iBotInd].x * fYScale) + (lpTop[iTopInd].x * (1.0f-fYScale)));
00311     lpPoints[i].y = (int)((lpBot[iBotInd].y * fYScale) + (lpTop[iTopInd].y * (1.0f-fYScale)));
00312   }
00313
00314
00315   // Draw the new path
00316   RenderPathPoints(hDC, lpPoints, lpTypes, iNumPts, bOutlineOnly);
00317
00318   GlobalFree(lpPoints);
00319   GlobalFree(lpTypes);
00320
00321   return TRUE;
00322 }
00323
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SLangClassEntry Member List

This is the complete list of members for SLangClassEntry, including all inherited members.
pwszClassId | SLangClassEntry
pwszClassIdDescription | SLangClassEntry
pwszDLL | SLangClassEntry
pwszThreadingModel | SLangClassEntry
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step2/Dimmer.h Source File

  • NetDS
  • upnp
  • StepByStep
  • Step2

Dimmer.h

Go to the documentation of this file.
00001 // Dimmer.h : Declaration of the CDimmer
00002
00003 #ifndef __DIMMER_H_
00004 #define __DIMMER_H_
00005
00006 #include "resource.h"       // main symbols
00007 #import "C:\UPnPSample\SDKDimmer\DimmerDevice\StepByStep\Step2\Debug\upnphost.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
00008
00009 /////////////////////////////////////////////////////////////////////////////
00010 // CDimmer
00011 class ATL_NO_VTABLE CDimmer :
00012   public CComObjectRootEx<CComMultiThreadModel>,
00013   public CComCoClass<CDimmer, &CLSID_Dimmer>,
00014   public IDispatchImpl<IDimmer, &IID_IDimmer, &LIBID_MYDEVICELib>,
00015   public IUPnPDeviceControl
00016 {
00017 public:
00018   CDimmer()
00019   {
00020   }
00021
00022 DECLARE_REGISTRY_RESOURCEID(IDR_DIMMER)
00023
00024 DECLARE_PROTECT_FINAL_CONSTRUCT()
00025
00026 BEGIN_COM_MAP(CDimmer)
00027   COM_INTERFACE_ENTRY(IDimmer)
00028   COM_INTERFACE_ENTRY(IDispatch)
00029   COM_INTERFACE_ENTRY(IUPnPDeviceControl)
00030 END_COM_MAP()
00031
00032 // IDimmer
00033 public:
00034 // IUPnPDeviceControl
00035   STDMETHOD(Initialize)(BSTR bstrXMLDesc, BSTR bstrDeviceIdentifier, BSTR bstrInitString)
00036   {
00037     return E_NOTIMPL;
00038   }
00039   STDMETHOD(GetServiceObject)(BSTR bstrUDN, BSTR bstrServiceId, IDispatch * * ppdispService)
00040   {
00041     if (ppdispService == NULL)
00042       return E_POINTER;
00043
00044     return E_NOTIMPL;
00045   }
00046 };
00047
00048 #endif //__DIMMER_H_
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/Inc/PageGUID.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • Inc

PageGUID.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAGEGUID.H
00003
00004   Summary:   This is the common include file for the GUIDs of page-related
00005              COM Interfaces and COM Objects. GUIDs are defined for the
00006              Interfaces and CLSIDs for the COM objects constructed using
00007              those interfaces.
00008
00009              This file is global to all the Tutorial Code Samples (kept
00010              in the ..\INC directory).  It is a good practice to
00011              factor out Interface and GUID specifications to reduce the
00012              possibility of GUID or interface conflicts.
00013
00014   Classes:   .
00015
00016   Functions: .
00017
00018   Origin:    5-26-97: atrent - Editor inheritance from PAPGUIDS.H.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 #if !defined(PAGEGUID_H)
00036 #define PAGEGUID_H
00037
00038 #if !defined(RC_INCLUDE)
00039
00040
00041 /*---------------------------------------------------------------------------
00042   Here are the IIDs for interfaces and the CLSIDs for the Class Factories
00043   of the persistent page-related COM components in the PERSERVE, PERTEXT,
00044   PERDRAW, and PERCLIEN code samples.
00045 ---------------------------------------------------------------------------*/
00046 DEFINE_GUID(IID_IPageList,
00047   0x0002da10, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00048
00049 DEFINE_GUID(IID_IPageListSink,
00050   0x0002da11, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00051
00052 DEFINE_GUID(CLSID_PageList,
00053   0x0002da12, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00054
00055 DEFINE_GUID(IID_ITextPage,
00056   0x0002da13, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00057
00058 DEFINE_GUID(IID_ITextPageSink,
00059   0x0002da14, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00060
00061 DEFINE_GUID(CLSID_TextPage,
00062   0x0002da15, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00063
00064 DEFINE_GUID(IID_IDrawPage,
00065   0x0002da16, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00066
00067 DEFINE_GUID(IID_IDrawPageSink,
00068   0x0002da17, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00069
00070 DEFINE_GUID(CLSID_DrawPage,
00071   0x0002da18, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
00072
00073
00074 #endif // RC_INCLUDE
00075
00076 #endif // PAGEGUID_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/ctransaction.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

ctransaction.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CTRANSCATION.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 ////////////////////////////////////////////////////////////////
00019 // CTransaction::CTransaction
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CTransaction::CTransaction(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CContainerBase(eCTransaction, pCMainWindow, pCMDIChild)
00024 {
00025   //OLE DB Interfaces
00026   m_pITransaction       = NULL;   //Transaction interface
00027
00028   //Extra interfaces
00029   m_dwCookieTransNotify   = 0;
00030 }
00031
00032 /////////////////////////////////////////////////////////////////
00033 // CTransaction::~CTransaction
00034 //
00035 /////////////////////////////////////////////////////////////////
00036 CTransaction::~CTransaction()
00037 {
00038   ReleaseObject(0);
00039 }
00040
00041
00042 /////////////////////////////////////////////////////////////////
00043 // IUnknown** CTransaction::GetInterfaceAddress
00044 //
00045 /////////////////////////////////////////////////////////////////
00046 IUnknown** CTransaction::GetInterfaceAddress(REFIID riid)
00047 {
00048   HANDLE_GETINTERFACE(ITransaction);
00049
00050   //Otherwise delegate
00051   return CContainerBase::GetInterfaceAddress(riid);
00052 }
00053
00054
00055 /////////////////////////////////////////////////////////////////
00056 // CTransaction::AutoRelease
00057 //
00058 /////////////////////////////////////////////////////////////////
00059 HRESULT CTransaction::AutoRelease()
00060 {
00061   //DataSource interfaces
00062   RELEASE_INTERFACE(ITransaction);
00063
00064   //Delegate
00065   return CContainerBase::AutoRelease();
00066 }
00067
00068
00069 /////////////////////////////////////////////////////////////////
00070 // HRESULT CTransaction::AutoQI
00071 //
00072 /////////////////////////////////////////////////////////////////
00073 HRESULT CTransaction::AutoQI(DWORD dwCreateOpts)
00074 {
00075   //Delegate First so we have base interfaces
00076   CContainerBase::AutoQI(dwCreateOpts);
00077
00078   //[MANDATORY]
00079   if(dwCreateOpts & CREATE_QI_MANDATORY)
00080   {
00081     OBTAIN_INTERFACE(ITransaction);
00082   }
00083
00084   //Auto QI
00085   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00086   {
00087   }
00088
00089   return S_OK;
00090 }
00091
00092
00093
00094
00095 ////////////////////////////////////////////////////////////////
00096 // CTransactionOptions::CTransactionOptions
00097 //
00098 /////////////////////////////////////////////////////////////////
00099 CTransactionOptions::CTransactionOptions(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00100   : CBase(eCTransactionOptions, pCMainWindow, pCMDIChild)
00101 {
00102   //OLE DB Interfaces
00103   m_pITransactionOptions    = NULL;   //TransactionOptions interface
00104 }
00105
00106 /////////////////////////////////////////////////////////////////
00107 // CTransactionOptions::~CTransactionOptions
00108 //
00109 /////////////////////////////////////////////////////////////////
00110 CTransactionOptions::~CTransactionOptions()
00111 {
00112   ReleaseObject(0);
00113 }
00114
00115
00116 /////////////////////////////////////////////////////////////////
00117 // IUnknown** CTransactionOptions::GetInterfaceAddress
00118 //
00119 /////////////////////////////////////////////////////////////////
00120 IUnknown** CTransactionOptions::GetInterfaceAddress(REFIID riid)
00121 {
00122   HANDLE_GETINTERFACE(ITransactionOptions);
00123
00124   //Otherwise delegate
00125   return CBase::GetInterfaceAddress(riid);
00126 }
00127
00128
00129 /////////////////////////////////////////////////////////////////
00130 // CTransactionOptions::AutoRelease
00131 //
00132 /////////////////////////////////////////////////////////////////
00133 HRESULT CTransactionOptions::AutoRelease()
00134 {
00135   //Interfaces
00136   RELEASE_INTERFACE(ITransactionOptions);
00137
00138   //Delegate
00139   return CBase::AutoRelease();
00140 }
00141
00142
00143 /////////////////////////////////////////////////////////////////
00144 // HRESULT CTransactionOptions::AutoQI
00145 //
00146 /////////////////////////////////////////////////////////////////
00147 HRESULT CTransactionOptions::AutoQI(DWORD dwCreateOpts)
00148 {
00149   //Delegate First so we have base interfaces
00150   CBase::AutoQI(dwCreateOpts);
00151
00152   //[MANDATORY]
00153   if(dwCreateOpts & CREATE_QI_MANDATORY)
00154   {
00155     OBTAIN_INTERFACE(ITransactionOptions);
00156   }
00157
00158   //Auto QI
00159   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00160   {
00161   }
00162
00163   return S_OK;
00164 }
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/QueryDlg.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

QueryDlg.Cpp

Go to the documentation of this file.
00001 // QueryDlg.cpp : implementation file
00002 //
00003 //  Copyright 1995-1998, Citrix Systems Inc.
00004 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00005
00006
00007 #include "stdafx.h"
00008 #include "API.h"
00009 #include "APIDoc.h"
00010 #include "QueryDlg.h"
00011
00012 #ifdef _DEBUG
00013 #define new DEBUG_NEW
00014 #undef THIS_FILE
00015 static char THIS_FILE[] = __FILE__;
00016 #endif
00017
00018
00019 Query QueryItems[MAXQUERYITEMS] =
00020 {
00021 #ifdef ICA_STUFF_INCLUDED
00022   {TEXT("Version"), WTSVersion},
00023 #endif
00024   {TEXT("Initial Program"), WTSInitialProgram},
00025   {TEXT("Working Directory"), WTSWorkingDirectory},
00026   {TEXT("OEM ID"), WTSOEMId},
00027   {TEXT("Session ID"), WTSSessionId},
00028   {TEXT("UserName"), WTSUserName},
00029   {TEXT("WinStation Name"), WTSWinStationName},
00030   {TEXT("Domain Name"), WTSDomainName},
00031   {TEXT("Connnection State"), WTSConnectState},
00032   {TEXT("Client Build Number"), WTSClientBuildNumber},
00033   {TEXT("Client Name"), WTSClientName},
00034   {TEXT("Client Directory"), WTSClientDirectory},
00035   {TEXT("Client Product ID"), WTSClientProductId},
00036   {TEXT("Client Address"), WTSClientAddress},
00037   {TEXT("Client Display"), WTSClientDisplay},
00038 #ifdef ICA_STUFF_INCLUDED
00039   {TEXT("Client Cache"), WTSClientCache},
00040   {TEXT("Client Drives"), WTSClientDrives},
00041   {TEXT("ICA Buffer Length"), WTSICABufferLength},
00042   {TEXT("License Enabler"), WTSLicenseEnabler},
00043 #endif
00044   {TEXT("Application Name"), WTSApplicationName}
00045 };
00046
00047
00048 /////////////////////////////////////////////////////////////////////////////
00049 // CQueryDlg dialog
00050
00051 CQueryDlg::CQueryDlg(CWnd* pParent /*=NULL*/)
00052   : CDialog(CQueryDlg::IDD, pParent)
00053 {
00054 }
00055
00056
00057 void CQueryDlg::DoDataExchange(CDataExchange* pDX)
00058 {
00059   CDialog::DoDataExchange(pDX);
00060   //{{AFX_DATA_MAP(CQueryDlg)
00061   DDX_Control(pDX, IDC_SESSION_INFO, m_displayInfo);
00062   DDX_Control(pDX, IDC_SERVERNAME, m_serverName);
00063   DDX_Control(pDX, IDC_QUERY_SESSION, m_querySession);
00064   DDX_Text(pDX, IDC_SESSION_INFO, m_sessionInfo);
00065   //}}AFX_DATA_MAP
00066 }
00067
00068
00069 BEGIN_MESSAGE_MAP(CQueryDlg, CDialog)
00070   //{{AFX_MSG_MAP(CQueryDlg)
00071   ON_BN_CLICKED(IDQUERY, OnQuery)
00072   ON_LBN_DBLCLK(IDC_QUERY_SESSION, OnDblclkQuerySession)
00073   //}}AFX_MSG_MAP
00074 END_MESSAGE_MAP()
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // CQueryDlg message handlers
00078
00079 BOOL CQueryDlg::OnInitDialog()
00080 {
00081   CDialog::OnInitDialog();
00082   LPSTR serverName = g_pDoc->GetServerName();
00083
00084   CString serverDisplay;
00085   serverDisplay = "Query types for ";
00086   //if (*serverName == NULL)
00087   if (serverName == NULL)
00088     serverDisplay += "local server";
00089   else
00090     serverDisplay += serverName;
00091   m_serverName.SetWindowText(serverDisplay);
00092
00093   for (int i=0; i < MAXQUERYITEMS; i++)
00094     m_querySession.InsertString(i, QueryItems[i].QueryName);
00095   m_querySession.SetCurSel(0);
00096   return TRUE;
00097 }
00098
00099 void CQueryDlg::OnQuery()
00100 {
00101   LPSTR serverName = g_pDoc->GetServerName();
00102   HANDLE serverHandle = WTSOpenServer(serverName);
00103   DWORD sessionID = g_pDoc->GetSessionID();
00104   BytesReturned = 0;
00105   int nIndex = m_querySession.GetCurSel();
00106   if (!WTSQuerySessionInformation(serverHandle, sessionID,
00107     QueryItems[nIndex].InfoClass, &pSessionInfo, &BytesReturned))
00108      AfxMessageBox("Query failed!");
00109   else
00110   {
00111
00112     switch ( QueryItems[nIndex].InfoClass ) {
00113 #ifdef ICA_STUFF_INCLUDED
00114         case WTSVersion:
00115     {
00116       LPOSVERSIONINFO pVerInfo = (LPOSVERSIONINFO) pSessionInfo;
00117       m_sessionInfo.Format("Version: major %u \r\n minor %u \r\n build %u \r\n CSD Version: %s",
00118                       pVerInfo->dwMajorVersion, pVerInfo->dwMinorVersion,
00119                       pVerInfo->dwBuildNumber, pVerInfo->szCSDVersion);
00120     }
00121       break;
00122 #endif
00123         case WTSInitialProgram:
00124       m_sessionInfo.Format("Initial Program:\r\n ");
00125       //m_sessionInfo = "Initial Program: ";
00126       m_sessionInfo += pSessionInfo;
00127       break;
00128
00129         case WTSWorkingDirectory:
00130       m_sessionInfo.Format("Working Directory:\r\n ");
00131       m_sessionInfo += pSessionInfo;
00132             break;
00133
00134         case WTSOEMId:
00135             m_sessionInfo = "OEM ID: ";
00136       m_sessionInfo += pSessionInfo;
00137             break;
00138
00139         case WTSSessionId:
00140       m_sessionInfo.Format(TEXT("Session ID: %u"), *(DWORD *) pSessionInfo);
00141             break;
00142
00143         case WTSUserName:
00144             m_sessionInfo = "UserName: ";
00145       m_sessionInfo += pSessionInfo;
00146             break;
00147
00148         case WTSWinStationName:
00149             m_sessionInfo = "WinStation Name: ";
00150       m_sessionInfo += pSessionInfo;
00151       break;
00152
00153         case WTSDomainName:
00154             m_sessionInfo = "Domain Name: ";
00155       m_sessionInfo += pSessionInfo;
00156             break;
00157
00158         case WTSConnectState:
00159       {CString connectState[10];
00160       connectState[0] = "Active";
00161       connectState[1] = "Connected";
00162       connectState[2] = "ConnectQuery";
00163       connectState[3] = "Shadow";
00164       connectState[4] = "Disconnected";
00165       connectState[5] = "Idle";
00166       connectState[6] = "Listen";
00167       connectState[7] = "Reset";
00168       connectState[8] = "Down";
00169       connectState[9] = "Init";
00170       m_sessionInfo.Format("Connection State: %s", connectState[(*(DWORD *) pSessionInfo)]);
00171       }
00172       break;
00173
00174         case WTSClientBuildNumber :
00175       m_sessionInfo.Format("Client Build Number: %d",(*(WORD*) pSessionInfo));
00176             break;
00177
00178         case WTSClientName :
00179             m_sessionInfo = "Client Name: ";
00180       m_sessionInfo += pSessionInfo;
00181             break;
00182
00183         case WTSClientDirectory :
00184       m_sessionInfo.Format("Client Directory:\r\n %s", pSessionInfo);
00185             break;
00186
00187         case WTSClientProductId :
00188       m_sessionInfo.Format("Client Product ID: %u",(*(WORD*) pSessionInfo));
00189       break;
00190
00191     case WTSClientAddress:
00192     {
00193       BYTE * pByte;
00194       PWTS_CLIENT_ADDRESS pClientAddress = (PWTS_CLIENT_ADDRESS) pSessionInfo;
00195             m_sessionInfo.Format( TEXT("ClientAddress: (%u) "),
00196                       pClientAddress->AddressFamily );
00197
00198       CString tempString;
00199       switch ( pClientAddress->AddressFamily ) {
00200                 case 0 :
00201                     tempString.Format( TEXT("%s"), pClientAddress->Address );
00202                     m_sessionInfo += tempString;
00203           break;
00204                 case 2 :
00205                     pByte = &pClientAddress->Address[2];
00206                     tempString.Format( TEXT("%u.%u.%u.%u"),
00207                               pByte[0], pByte[1], pByte[2], pByte[3] );
00208           m_sessionInfo += tempString;
00209                     break;
00210                 case 6 :
00211                     pByte = pClientAddress->Address;
00212                     for ( int i=0; i<4; i++ ) {
00213                         tempString.Format( TEXT("%02x"), pByte[i] );
00214             m_sessionInfo += tempString;
00215           }
00216           m_sessionInfo += ":";
00217                     for ( i=4; i<10; i++ ){
00218                         tempString.Format( TEXT("%02x"), pByte[i] );
00219             m_sessionInfo += tempString;
00220           }
00221                     break;
00222             }
00223
00224     }
00225       break;
00226
00227     case WTSClientDisplay:
00228     { PWTS_CLIENT_DISPLAY SessionInfo = (PWTS_CLIENT_DISPLAY) pSessionInfo;
00229       m_sessionInfo.Format("Client Display:\r\n  Resolution: %d X %d\r\n  Color Depth %d",
00230         SessionInfo->HorizontalResolution,
00231         SessionInfo->VerticalResolution,
00232         SessionInfo->ColorDepth);
00233     }
00234       break;
00235
00236 #ifdef ICA_STUFF_INCLUDED
00237     case WTSClientCache:
00238
00239     { PWTS_CLIENT_CACHE SessionInfo = (PWTS_CLIENT_CACHE) pSessionInfo;
00240       m_sessionInfo.Format("Client Cache:\r\n  Tiny Cache %d\r\n  Low Memory Cache %d\r\n  XMS Cache %d\r\n  Disk Cache %d\r\n  Cache Size Dim %d\r\n  Bitmap Min Dim %d\r\n  Signature Level Dim %d\r\n  File System Overhead %d",
00241         SessionInfo->CacheTiny,
00242         SessionInfo->CacheLowMem,
00243         SessionInfo->CacheDisk,
00244         SessionInfo->DimCacheSize,
00245         SessionInfo->DimBitmapMin,
00246         SessionInfo->DimSignatureLevel,
00247         SessionInfo->DimFilesysOverhead);
00248     }
00249       break;
00250
00251     case WTSClientDrives:
00252     {
00253       PWTS_CLIENT_DRIVES pClientDrives = (PWTS_CLIENT_DRIVES) pSessionInfo;
00254             CString tempString;
00255       CString driveType[10];
00256       driveType[0] = "Removeable";
00257       driveType[1] = "Fixed";
00258       driveType[2] = "Remote";
00259       driveType[3] = "CD-Rom";
00260       driveType[4] = "Ram Disk";
00261       driveType[5] = "AutoConnect";
00262       driveType[6] = "Unknown";
00263
00264       m_sessionInfo.Format( TEXT("WTSClientDrives: fAuto %u, count %u \r\n"),
00265                       pClientDrives->fAutoClientDrives,
00266                       pClientDrives->Count );
00267
00268       for ( DWORD i=0; i < pClientDrives->Count; i++ ) {
00269                 switch (pClientDrives->Drives[i].Flags)
00270         {
00271           case  1: nIndex = 0; break;
00272           case  2: nIndex = 1; break;
00273           case  4: nIndex = 2; break;
00274           case  8: nIndex = 3; break;
00275           case 10: nIndex = 4; break;
00276           case 20: nIndex = 5; break;
00277           default: nIndex = 6;
00278         }
00279         tempString.Format( TEXT(" %c:%s \r\n"),
00280           pClientDrives->Drives[i].DriveLetter,
00281           driveType[nIndex]);
00282         m_sessionInfo += tempString;
00283       }
00284     }
00285       break;
00286
00287     case WTSICABufferLength:
00288       m_sessionInfo.Format("ICA Buffer Length: %u", (*(DWORD *) pSessionInfo));
00289       break;
00290
00291     case WTSLicenseEnabler:
00292       m_sessionInfo.Format("License Enabler: %x", (*(DWORD *) pSessionInfo));
00293       break;
00294 #endif
00295
00296     case WTSApplicationName:
00297             m_sessionInfo.Format("ApplicationName: %s", pSessionInfo );
00298             break;
00299     }
00300
00301     SetDlgItemText(IDC_SESSION_INFO, m_sessionInfo);
00302     WTSFreeMemory( pSessionInfo );
00303   }
00304
00305 }
00306
00307 void CQueryDlg::OnCancel()
00308 {
00309     WTSFreeMemory(pSessionInfo);
00310   CDialog::OnCancel();
00311 }
00312
00313
00314 void CQueryDlg::OnDblclkQuerySession()
00315 {
00316   OnQuery();
00317 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletRegistryRequest Member List

This is the complete list of members for tagAppletRegistryRequest, including all inherited members.
cHandles | tagAppletRegistryRequest
eCommand | tagAppletRegistryRequest
eParamModifyRights | tagAppletRegistryRequest
nChannelID | tagAppletRegistryRequest
ostrParamValue | tagAppletRegistryRequest
RegistryKey | tagAppletRegistryRequest
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Surrog/csur.h Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Surrog

csur.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <stack>
00019 #include "cfwrap.h"
00020
00021 class CSurrogate : public ISurrogate
00022 {
00023   // data structure to store all the class factory wrappers and revoke them
00024   // when FreeSurrogate() is called.
00025   std::stack<CClassFactoryWrapper*> m_stkClassFactories;
00026
00027 public:
00028   CSurrogate () {};
00029   virtual ~CSurrogate() {};
00030
00031   // IUnknown
00032     STDMETHOD (QueryInterface)(REFIID iid, LPVOID* ppv);
00033     STDMETHOD_(ULONG,AddRef)();
00034     STDMETHOD_(ULONG,Release)();
00035
00036   // ISurrogate
00037   STDMETHOD(LoadDllServer)(REFCLSID rclsid);
00038   STDMETHOD(FreeSurrogate)();
00039 };
00040
00041
00042
00043
00044
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/basesnap.h Source File

  • SysMgmt
  • MMC
  • Nameext

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {NAMESPACEEXTENSION = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/Driver/Driver.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • Driver

Driver.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Driver.cpp
00003
00004   Summary:   Test client for Queued Components sample order entry application
00005   Classes:   None
00006
00007   Functions: main
00008              CreateOrder
00009              CheckHR
00010              ExecSQLStmt
00011 -----------------------------------------------------------------------------
00012
00013 This file is part of the Microsoft COM+ Samples.
00014
00015 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00016
00017 This source code is intended only as a supplement to Microsoft
00018 Development Tools and/or on-line documentation. See these other
00019 materials for detailed information regarding Microsoft code samples.
00020
00021 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00022 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00023 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00024 PARTICULAR PURPOSE.
00025
00026 ==========================================================================+*/
00027
00028 #include "stdafx.h"
00029 #include "..\DataSourceNames.h" // Data source names, userid, password
00030 #include <iostream>
00031 #include <initguid.h>
00032 #include <time.h>
00033 #include <adoid.h>        // ADO
00034 #include <adoint.h>       // ADO
00035 #include "..\QCOrder\processFlags.h"
00036 #include "..\QCOrder\QCOrder.h"
00037
00038 // constants
00039
00040 const int nLineItemsPerOrder  = 5;
00041 const int nOrdersPerDriver    = 100;
00042 const int nSleepMilliseconds  = 1000;   // database keys based on integral seconds
00043
00044 // Forward function declarations
00045
00046 HRESULT CreateOrder(long lOrderId, long lFlags);
00047
00048 HRESULT CheckHR(HRESULT hr, LPCSTR pszVerb);
00049
00050 HRESULT ExecSQLStmt(LPCWSTR pszDSN, LPCWSTR pszSQLStmt);
00051
00052 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00053   Function: main    main entry point - Creates a number of orders
00054   Args:     none
00055   Returns:  int     HRESULT from any error or 0
00056 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00057
00058 int __cdecl main()
00059 {
00060   long lFlags = 0;  // no database, vtable binding, not queued calls
00061 //  lFlags |= processFlagLateBound;     // Invoke components via Automation (IDispatch)
00062 //  lFlags |= processFlagWriteDB;     // Write to Order & Shipping tables
00063   lFlags |= processFlagQueuedComponents;  // Queued calls to Ship and Notify
00064
00065   HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); // init COM library
00066   CheckHR(hr, "CoInitializeEx");
00067
00068   if (SUCCEEDED(hr))
00069   {
00070     if (lFlags & processFlagWriteDB)
00071     {
00072       ExecSQLStmt(pszOrderDSN,    // Create Order table
00073             L"create table QCSampleOrder "
00074             L"  (order_id  int, "
00075             L"   cust_id   int, "
00076             L"   line_no   int, "
00077             L"   item_id   int, "
00078             L"   quantity  int, "
00079             L"   ship_status varchar(25) )" );
00080       // Accept error - table may already exist
00081
00082       ExecSQLStmt(pszShipDSN,     // Create ship table
00083             L"create table QCSampleShip "
00084             L"  (order_id int, "
00085             L"   cust_id  int, "
00086             L"   line_no  int, "
00087             L"   item_id  int, "
00088             L"   quantity int, "
00089             L"   ship_status_enum int )" );
00090       // Accept error - table may already exist
00091     }
00092
00093     for (int ix = 0; ix < nOrdersPerDriver && SUCCEEDED(hr); ix++)
00094     {
00095       long lOrderId = time(NULL);
00096       hr = CreateOrder(lOrderId, lFlags);
00097       Sleep(nSleepMilliseconds);      // Wait between orders
00098     }
00099
00100     CoUninitialize();
00101   }
00102   return hr;
00103 }
00104
00105 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00106   Function: CreateOrder Create a single order for processing
00107   Args:     long    lOrderId - a unique order identifier
00108   Returns:  int     HRESULT from any error or S_OK
00109 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00110
00111 HRESULT CreateOrder(long lOrderId, long lFlags)
00112 {
00113   _COM_SMARTPTR_TYPEDEF(IOrder, _uuidof(IOrder));
00114
00115   IOrderPtr pOrder;
00116
00117   HRESULT hr = pOrder.CreateInstance(_uuidof(Order));
00118   CheckHR(hr, "CoCreateInstance CLSID_Order");
00119
00120   if (SUCCEEDED(hr))
00121   {
00122     hr = pOrder->put_OrderId(lOrderId);
00123     CheckHR(hr, "put_OrderId");
00124   }
00125
00126   if (SUCCEEDED(hr))
00127   {
00128     hr = pOrder->put_CustomerId( (lOrderId % 1000) * (rand() % 1000) );
00129     CheckHR(hr, "put_CustomerId");
00130   }
00131
00132   for (int ix = 1; ix <= nLineItemsPerOrder && SUCCEEDED(hr); ix++)
00133   {
00134     // Derive ItemId and quantity from time of day
00135     hr = pOrder->LineItem(lOrderId % 100 + ix, lOrderId % 10 + 2 * ix);
00136     CheckHR(hr, "LineItem");
00137   }
00138
00139   if (SUCCEEDED(hr))
00140   {
00141     _RPT1(_CRT_WARN, "QCSamp1 %d Driver\n", lOrderId);
00142     hr = pOrder->Process(lFlags); // process the complete order
00143     CheckHR(hr, "Process");
00144   }
00145   return hr;
00146 }
00147
00148 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00149   Function: CheckHR   Tests HRESULT for an exceptional condition
00150   Args:     HRESULT   hr - the HRESULT to test
00151       LPCSTR    pszVerb - string describing function that failed
00152   Returns:  HRESULT   returns value of input HRESULT
00153 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00154
00155 HRESULT CheckHR(HRESULT hr, LPCSTR pszVerb)
00156 {
00157   if (hr != S_OK)
00158   {
00159     std::cerr << pszVerb << " hr 0x" << std::hex << hr << '\n';
00160     _RPTF2(FAILED(hr) ? _CRT_ERROR : _CRT_WARN, "%s hr 0x%x\n", pszVerb, hr);
00161   }
00162   return hr;
00163 }
00164
00165 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00166   Function: ExecSQLStmt Execute a single SQL statement using ADO
00167   Args:     LPCWSTR   pszDSN Data Source Name
00168       LPCWSTR   pszSQLStmt SQL statement to be executed
00169   Returns:  HRESULT   results from underlying functions
00170 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00171
00172 HRESULT ExecSQLStmt(LPCWSTR pszDSN, LPCWSTR pszSQLStmt)
00173 {
00174   CComPtr<ADOConnection> pADOConnection;
00175
00176   HRESULT hr = CoCreateInstance(  CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,
00177                   IID_IADOConnection, (void **) &pADOConnection);
00178   CheckHR(hr, "CoCreateInstance CLSID_CADOConnection");
00179
00180   if (SUCCEEDED(hr))
00181   {
00182     hr = pADOConnection->Open(  _bstr_t(pszDSN), _bstr_t(pszUserId),
00183                   _bstr_t(pszPassword), adOpenUnspecified);
00184     CheckHR(hr, "pADOConnection->Open");
00185   }
00186
00187   if (SUCCEEDED(hr))
00188     hr = pADOConnection->Execute(_bstr_t(pszSQLStmt), NULL, adCmdText, NULL);
00189
00190   return hr;
00191 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step3/DimmerService.h Source File

  • NetDS
  • upnp
  • StepByStep
  • Step3

DimmerService.h

Go to the documentation of this file.
00001 // DimmerService.h : Declaration of the CDimmerService
00002
00003 #ifndef __DIMMERSERVICE_H_
00004 #define __DIMMERSERVICE_H_
00005
00006 #include "resource.h"       // main symbols
00007 #import "C:\UPnPSample\SDKDimmer\DimmerDevice\StepByStep\Step2\Debug\upnphost.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
00008
00009 /////////////////////////////////////////////////////////////////////////////
00010 // CDimmerService
00011 class ATL_NO_VTABLE CDimmerService :
00012   public CComObjectRootEx<CComMultiThreadModel>,
00013   //public CComCoClass<CDimmerService, &CLSID_DimmerService>,
00014   //public IDispatchImpl<IDimmerService, &IID_IDimmerService, &LIBID_MYDEVICELib>,
00015   public IUPnPEventSource,
00016     public IDispatchImpl<IUPnPService_DimmingService_SCPD, &IID_IUPnPService_DimmingService_SCPD, &LIBID_MYDEVICELib>
00017   //public IUPnPService_DimmingService_SCPD
00018 {
00019 public:
00020   CDimmerService()
00021   {
00022   }
00023
00024 //DECLARE_REGISTRY_RESOURCEID(IDR_DIMMERSERVICE)
00025
00026 //DECLARE_PROTECT_FINAL_CONSTRUCT()
00027
00028 BEGIN_COM_MAP(CDimmerService)
00029   //COM_INTERFACE_ENTRY(IDimmerService)
00030   COM_INTERFACE_ENTRY(IDispatch)
00031   COM_INTERFACE_ENTRY(IUPnPEventSource)
00032   COM_INTERFACE_ENTRY(IUPnPService_DimmingService_SCPD)
00033 END_COM_MAP()
00034
00035 // IDimmerService
00036 public:
00037 // IUPnPEventSource
00038   STDMETHOD(Advise)(IUPnPEventSink * pesSubscriber)
00039   {
00040     return E_NOTIMPL;
00041   }
00042   STDMETHOD(Unadvise)(IUPnPEventSink * pesSubscriber)
00043   {
00044     return E_NOTIMPL;
00045   }
00046 // IUPnPService_DimmingService_SCPD
00047   STDMETHOD(get_Power)(VARIANT_BOOL * pPower)
00048   {
00049     if (pPower == NULL)
00050       return E_POINTER;
00051
00052     return E_NOTIMPL;
00053   }
00054   STDMETHOD(get_dimLevel)(LONG * pdimLevel)
00055   {
00056     if (pdimLevel == NULL)
00057       return E_POINTER;
00058
00059     return E_NOTIMPL;
00060   }
00061   STDMETHOD(PowerOn)()
00062   {
00063     return E_NOTIMPL;
00064   }
00065   STDMETHOD(PowerOff)()
00066   {
00067     return E_NOTIMPL;
00068   }
00069   STDMETHOD(GetPowerValue)(VARIANT_BOOL * ppowerVall)
00070   {
00071     if (ppowerVall == NULL)
00072       return E_POINTER;
00073
00074     return E_NOTIMPL;
00075   }
00076   STDMETHOD(SetDimLevel)(LONG dLevel)
00077   {
00078     return E_NOTIMPL;
00079   }
00080   STDMETHOD(GetDimLevel)(LONG * pdLevel)
00081   {
00082     if (pdLevel == NULL)
00083       return E_POINTER;
00084
00085     return E_NOTIMPL;
00086   }
00087   STDMETHOD(GetConfigDetails)(VARIANT_BOOL * ppowerVal, LONG * pdLevel)
00088   {
00089     if (ppowerVal == NULL)
00090       return E_POINTER;
00091
00092     if (pdLevel == NULL)
00093       return E_POINTER;
00094
00095     return E_NOTIMPL;
00096   }
00097 };
00098
00099 #endif //__DIMMERSERVICE_H_
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/compdata.Cpp Source File

  • SysMgmt
  • MMC
  • Taskpads

compdata.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "CompData.h"
00021 #include "DataObj.h"
00022 #include "resource.h"
00023 #include <crtdbg.h>
00024
00025 CComponentData::CComponentData()
00026 : m_cref(0), m_ipConsoleNameSpace(NULL), m_ipConsole(NULL)
00027 {
00028     OBJECT_CREATED
00029
00030         m_pStaticNode = new CStaticNode;
00031 }
00032
00033 CComponentData::~CComponentData()
00034 {
00035     if (m_pStaticNode) {
00036         delete m_pStaticNode;
00037     }
00038
00039     OBJECT_DESTROYED
00040 }
00041
00042 ///////////////////////
00043 // IUnknown implementation
00044 ///////////////////////
00045
00046 STDMETHODIMP CComponentData::QueryInterface(REFIID riid, LPVOID *ppv)
00047 {
00048     if (!ppv)
00049         return E_FAIL;
00050
00051     *ppv = NULL;
00052
00053     if (IsEqualIID(riid, IID_IUnknown))
00054         *ppv = static_cast<IComponentData *>(this);
00055     else if (IsEqualIID(riid, IID_IComponentData))
00056         *ppv = static_cast<IComponentData *>(this);
00057
00058     if (*ppv)
00059     {
00060         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00061         return S_OK;
00062     }
00063
00064     return E_NOINTERFACE;
00065 }
00066
00067 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00068 {
00069     return InterlockedIncrement((LONG *)&m_cref);
00070 }
00071
00072 STDMETHODIMP_(ULONG) CComponentData::Release()
00073 {
00074     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00075     {
00076         // we need to decrement our object count in the DLL
00077         delete this;
00078         return 0;
00079     }
00080
00081     return m_cref;
00082 }
00083
00084 ///////////////////////////////
00085 // Interface IComponentData
00086 ///////////////////////////////
00087 HRESULT CComponentData::Initialize(
00088                                    /* [in] */ LPUNKNOWN pUnknown)
00089 {
00090     HRESULT      hr;
00091
00092     //
00093     // Get pointer to name space interface
00094     //
00095     hr = pUnknown->QueryInterface(IID_IConsoleNameSpace, (void **)&m_ipConsoleNameSpace);
00096     _ASSERT( S_OK == hr );
00097
00098     //
00099     // Get pointer to console interface
00100     //
00101     hr = pUnknown->QueryInterface(IID_IConsole, (void **)&m_ipConsole);
00102     _ASSERT( S_OK == hr );
00103
00104     IImageList *pImageList;
00105     m_ipConsole->QueryScopeImageList(&pImageList);
00106     _ASSERT( S_OK == hr );
00107
00108     hr = pImageList->ImageListSetStrip( (long *)m_pStaticNode->m_pBMapSm, // pointer to a handle
00109         (long *)m_pStaticNode->m_pBMapLg, // pointer to a handle
00110         0, // index of the first image in the strip
00111         RGB(0, 128, 128)  // color of the icon mask
00112         );
00113
00114     pImageList->Release();
00115
00116     return S_OK;
00117 }
00118
00119 HRESULT CComponentData::CreateComponent(
00120                                         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent)
00121 {
00122     *ppComponent = NULL;
00123
00124     CComponent *pComponent = new CComponent(this);
00125
00126     if (NULL == pComponent)
00127         return E_OUTOFMEMORY;
00128
00129     return pComponent->QueryInterface(IID_IComponent, (void **)ppComponent);
00130 }
00131
00132 HRESULT CComponentData::Notify(
00133                                /* [in] */ LPDATAOBJECT lpDataObject,
00134                                /* [in] */ MMC_NOTIFY_TYPE event,
00135                                /* [in] */ LPARAM arg,
00136                                /* [in] */ LPARAM param)
00137 {
00138     MMCN_Crack(TRUE, lpDataObject, this, NULL, event, arg, param);
00139
00140     HRESULT hr = S_FALSE;
00141
00142   //Get our data object. If it is NULL, we return with S_FALSE.
00143   //See implementation of GetOurDataObject() to see how to
00144   //handle special data objects.
00145   CDataObject *pDataObject = GetOurDataObject(lpDataObject);
00146   if (NULL == pDataObject)
00147     return S_FALSE;
00148
00149   CDelegationBase *base = pDataObject->GetBaseNodeObject();
00150
00151     switch (event)
00152     {
00153     case MMCN_EXPAND:
00154         hr = base->OnExpand(m_ipConsoleNameSpace, m_ipConsole, (HSCOPEITEM)param);
00155         break;
00156     }
00157
00158     return hr;
00159 }
00160
00161 HRESULT CComponentData::Destroy( void)
00162 {
00163     // Free interfaces
00164     if (m_ipConsoleNameSpace) {
00165         m_ipConsoleNameSpace->Release();
00166         m_ipConsoleNameSpace = NULL;
00167     }
00168
00169     if (m_ipConsole) {
00170         m_ipConsole->Release();
00171         m_ipConsole = NULL;
00172     }
00173
00174     return S_OK;
00175 }
00176
00177 HRESULT CComponentData::QueryDataObject(
00178                                         /* [in] */ MMC_COOKIE cookie,
00179                                         /* [in] */ DATA_OBJECT_TYPES type,
00180                                         /* [out] */ LPDATAOBJECT *ppDataObject)
00181 {
00182     CDataObject *pObj = NULL;
00183
00184     if (cookie == 0)
00185         pObj = new CDataObject((MMC_COOKIE)m_pStaticNode, type);
00186     else
00187         pObj = new CDataObject(cookie, type);
00188
00189     if (!pObj)
00190         return E_OUTOFMEMORY;
00191
00192     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00193
00194     return S_OK;
00195 }
00196
00197 HRESULT CComponentData::GetDisplayInfo(
00198                                        /* [out][in] */ SCOPEDATAITEM *pScopeDataItem)
00199 {
00200     HRESULT hr = S_FALSE;
00201
00202     // if they are asking for the SDI_STR we have one of those to give
00203     if (pScopeDataItem->lParam) {
00204         CDelegationBase *base = (CDelegationBase *)pScopeDataItem->lParam;
00205         if (pScopeDataItem->mask & SDI_STR) {
00206                         LPCTSTR pszT = base->GetDisplayName();
00207                         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00208             pScopeDataItem->displayname = pszW;
00209         }
00210
00211         if (pScopeDataItem->mask & SDI_IMAGE) {
00212             pScopeDataItem->nImage = base->GetBitmapIndex();
00213         }
00214     }
00215
00216     return hr;
00217 }
00218
00219 HRESULT CComponentData::CompareObjects(
00220                                        /* [in] */ LPDATAOBJECT lpDataObjectA,
00221                                        /* [in] */ LPDATAOBJECT lpDataObjectB)
00222 {
00223     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00224     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00225
00226     // compare the object pointers
00227     if (baseA->GetCookie() == baseB->GetCookie())
00228         return S_OK;
00229
00230     return S_FALSE;
00231 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAnchorTag Member List

This is the complete list of members for CAnchorTag, including all inherited members.
_aTempBuffer | CHtmlElement | [protected]
_cHrefChars | CAnchorTag | [private]
_cHrefCharsFiltered | CAnchorTag | [private]
_eState | CAnchorTag | [private]
_htmlIFilter | CHtmlElement | [protected]
_pwcHrefBuf | CAnchorTag | [private]
_scanner | CHtmlElement | [protected]
_serialStream | CHtmlElement | [protected]
_uLenHrefBuf | CAnchorTag | [private]
CAnchorTag(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CAnchorTag |
CHtmlElement(CHtmlIFilter &htmlIFilter, CSerialStream &serialStream) | CHtmlElement |
GetChunk(STAT_CHUNK *pStat) | CAnchorTag | [virtual]
GetText(ULONG *pcwcOutput, WCHAR *awcBuffer) | CAnchorTag | [virtual]
GetValue(PROPVARIANT **ppPropValue) | CHtmlElement | [virtual]
InitFilterRegion(ULONG &idChunkSource, ULONG &cwcStartSource, ULONG &cwcLenSource) | CHtmlElement | [virtual]
InitStatChunk(STAT_CHUNK *pStat) | CAnchorTag | [virtual]
SkipRemainingTextAndGotoNextChunk(STAT_CHUNK *pStat) | CHtmlElement | [protected]
SwitchToNextHtmlElement(STAT_CHUNK *pStat) | CHtmlElement | [protected]
~CAnchorTag() | CAnchorTag |
~CHtmlElement() | CHtmlElement | [inline, virtual]
Generated on Wed Nov 13 2024 16:55:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMyEventProvider Member List

This is the complete list of members for CMyEventProvider, including all inherited members.
AccessCheck(WBEM_CWSTR wszQueryLanguage, WBEM_CWSTR wszQuery, long lSidLength, const BYTE *pSid) | CMyEventProvider |
CheckAccess(SECURITY_DESCRIPTOR *a_SecurityDescriptor, DWORD a_Access, GENERIC_MAPPING *a_Mapping) | CMyEventProvider | [private]
CMyEventProvider() | CMyEventProvider |
EventThread(LPVOID pArg) | CMyEventProvider | [private, static]
Initialize(LPWSTR pszUser, LONG lFlags, LPWSTR pszNamespace, LPWSTR pszLocale, IWbemServices __RPC_FAR *pNamespace, IWbemContext __RPC_FAR *pCtx, IWbemProviderInitSink __RPC_FAR *pInitSink) | CMyEventProvider |
InstanceThread() | CMyEventProvider | [private]
m_cRef | CMyEventProvider | [private]
m_eStatus | CMyEventProvider | [private]
m_hThread | CMyEventProvider | [private]
m_pEventClassDef | CMyEventProvider | [private]
m_pNs | CMyEventProvider | [private]
m_pSink | CMyEventProvider | [private]
Pending enum value | CMyEventProvider |
PendingStop enum value | CMyEventProvider |
ProvideEvents(IWbemObjectSink __RPC_FAR *pSink, long lFlags) | CMyEventProvider |
QueryInterface(REFIID, LPVOID *) | CMyEventProvider |
Running enum value | CMyEventProvider |
STDMETHODIMP_(ULONG) AddRef(void) | CMyEventProvider |
STDMETHODIMP_(ULONG) Release(void) | CMyEventProvider |
Stopped enum value | CMyEventProvider |
~CMyEventProvider() | CMyEventProvider |
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocClien/LocClien.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocClien

LocClien.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      LOCCLIEN.CPP
00003
00004   Summary:   Based largely on the DLLCLIEN.EXE application code, this
00005              module is meant to use COM to load and access some COM
00006              components in a separate Local EXE COM Server (LOCSERVE built
00007              in the sibling LOCSERVE directory).  Thus to run LOCCLIEN you
00008              must build LOCSERVE first.  Like DLLCLIEN, this app composes
00009              its own native composite COM object, COUtilityCruiseCar. In
00010              this client application, COUtilityCruiseCar is constructed by
00011              containment reuse of the existing COCruiseCar COM component
00012              (provided by the LOCSERVE.EXE local server). This application
00013              augments that existing component with a native implementation
00014              of the IUtility interface.  Thus, this application showcases
00015              mixed composition through containment of an existing
00016              composite object that is itself constructed via aggregation.
00017
00018              Also like DLLCLIEN this client application separately
00019              instantiates the other car-related objects of LOCSERVE and
00020              exercises them (ie, for Car, UtilityCar, CruiseCar, and
00021              UtilityCruiseCar).  To this end, LOCCLIEN provides a set of
00022              menus for these Car related objects with selections for the
00023              respective methods of the Interfaces exposed by those COM
00024              Objects.
00025
00026              Unlike previous InProc client/server pairs, this local
00027              client/server pair achieves logging of internal server
00028              behavior in the client's logging display using a different
00029              method than was provided by the CarSample component.  The
00030              CarSample facility is not used.
00031
00032              For a comprehensive tutorial code tour of LOCCLIEN's
00033              contents and offerings see the tutorial LOCCLIEN.HTM file.
00034              For more specific technical details on the internal workings
00035              see the comments dispersed throughout the LOCCLIEN source code.
00036              For more details on the LOCSERVE.EXE that LOCCLIEN works with
00037              see the LOCSERVE.HTM file in the main tutorial directory.
00038
00039   Classes:   CMainWindow
00040
00041   Functions: InitApplication, WinMain
00042
00043   Origin:    11-20-95: atrent - Editor-inheritance from DLLCLIEN source.
00044
00045 ----------------------------------------------------------------------------
00046   This file is part of the Microsoft COM Tutorial Code Samples.
00047
00048   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00049
00050   This source code is intended only as a supplement to Microsoft
00051   Development Tools and/or on-line documentation.  See these other
00052   materials for detailed information regarding Microsoft code samples.
00053
00054   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00055   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00056   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00057   PARTICULAR PURPOSE.
00058 ==========================================================================+*/
00059
00060 /*--------------------------------------------------------------------------
00061   We include WINDOWS.H for all Win32 applications.
00062   We include OLE2.H because we will be calling the COM/OLE Libraries.
00063   We include INITGUID.H only once (here) in the entire app because we
00064     will be defining GUIDs and want them as constants in the data segment.
00065   We include COMMDLG.H because we will be using the Open File and
00066     potentially other Common dialogs.
00067   We include APPUTIL.H because we will be building this application using
00068     the convenient Virtual Window and Dialog classes and other
00069     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00070   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00071     class, GUID, and CLSID specifications.
00072   We include LOCCLIEN.H because it has class and resource definitions
00073     specific to this LOCCLIEN application.
00074   We include UTCRUCAR.H because it has COUtilityCar object class.
00075 ---------------------------------------------------------------------------*/
00076 #include <windows.h>
00077 #include <ole2.h>
00078 #include <initguid.h>
00079 #include <commdlg.h>
00080 #include <apputil.h>
00081 #include <micars.h>
00082 #include <carguids.h>
00083 #include "locclien.h"
00084 #include "utcrucar.h"
00085
00086
00087 // Here is a pointer for use by the global Trace Message logging macros.
00088 CMsgLog* g_pMsgLog = NULL;
00089
00090
00091 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00092   Method:   CMainWindow::CMainWindow
00093
00094   Summary:  CMainWindow Constructor.
00095
00096   Args:     .
00097
00098   Modifies: .
00099
00100   Returns:  .
00101 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00102 CMainWindow::CMainWindow()
00103 {
00104   // Ensure these member variable strings are null strings.
00105   m_szFileName[0] = 0;
00106   m_szFileTitle[0] = 0;
00107
00108   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00109   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00110   m_ofnFile.hwndOwner = m_hWnd;
00111   m_ofnFile.hInstance = m_hInst;
00112   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00113   m_ofnFile.lpstrCustomFilter = NULL;
00114   m_ofnFile.nMaxCustFilter = 0;
00115   m_ofnFile.nFilterIndex = 1;
00116   m_ofnFile.lpstrFile = m_szFileName;
00117   m_ofnFile.nMaxFile = MAX_PATH;
00118   m_ofnFile.lpstrInitialDir = TEXT(".");
00119   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00120   m_ofnFile.nMaxFileTitle = MAX_PATH;
00121   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00122   m_ofnFile.lpstrDefExt = NULL;
00123   m_ofnFile.Flags = OFN_HIDEREADONLY;
00124
00125   m_pCar = NULL;
00126   m_pUtilityCar = NULL;
00127   m_pCruiseCar = NULL;
00128   m_pUtilityCruiseCar = NULL;
00129
00130   // Null the Message object pointers.
00131   m_pMsgBox = NULL;
00132   m_pMsgLog = NULL;
00133 }
00134
00135
00136 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00137   Method:   CMainWindow::~CMainWindow
00138
00139   Summary:  CMainWindow Destructor.  Destruction of the main window
00140             indicates that the application should quit and thus the
00141             PostQuitMessage API is called.
00142
00143   Args:     .
00144
00145   Modifies: .
00146
00147   Returns:  .
00148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00149 CMainWindow::~CMainWindow()
00150 {
00151   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00152   // message and causes a delete of CMainWindow which in turn causes this
00153   // destructor to run. The WM_DESTROY results when the window is destoyed
00154   // after a close of the window. Prior to exiting the main message loop:
00155
00156   // We release any and all of the pointers to instantiated COM objects.
00157   RELEASE_INTERFACE(m_pCar);
00158   RELEASE_INTERFACE(m_pUtilityCar);
00159   RELEASE_INTERFACE(m_pCruiseCar);
00160   RELEASE_INTERFACE(m_pUtilityCruiseCar);
00161
00162   // We delete the CMsgBox and CMsgLog objects that were made in
00163   // Initinstance.
00164   DELETE_POINTER(m_pMsgBox);
00165   DELETE_POINTER(m_pMsgLog);
00166
00167   // We then post a WM_QUIT message to cause an exit of the main thread's
00168   // message loop and an exit of this instance of the application.
00169   PostQuitMessage(0);
00170 }
00171
00172
00173 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00174   Method:   CMainWindow::GetInterface
00175
00176   Summary:  Convenience method that wraps the QueryInterface call
00177             and accepts a main COM object IUnknown pointer as an argument.
00178
00179   Args:     IUnknown* pObj,
00180               Pointer to the COM Object we are getting an interface on.
00181             REFIID riid,
00182               The GUID for the interface that we are seeking.
00183             PPVOID ppv);
00184               Address of the caller's pointer variable that will
00185               receive the requested interface pointer.
00186
00187   Modifies: .
00188
00189   Returns:  BOOL.
00190               TRUE if succeeded.
00191               FALSE if failed.
00192 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00193 BOOL CMainWindow::GetInterface(
00194        IUnknown* pObj,
00195        REFIID riid,
00196        PPVOID ppv)
00197 {
00198   BOOL bResult = FALSE;
00199   HRESULT hr;
00200
00201   *ppv=NULL;
00202
00203   if (NULL != pObj)
00204   {
00205     LOG("C: --Obtaining Interface Pointer.");
00206     hr = pObj->QueryInterface(riid, ppv);
00207
00208     if (FAILED(hr))
00209     {
00210       LOGERROR("C: ???? QueryInterface", hr);
00211     }
00212     else
00213     {
00214       LOGF1("C: Interface obtained. *ppv=0x%X", *ppv);
00215       bResult = TRUE;
00216     }
00217   }
00218   else
00219   {
00220     LOG("C: ???? Create an object first.");
00221   }
00222
00223   return (bResult);
00224 }
00225
00226
00227 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00228   Method:   CMainWindow::DoMenu
00229
00230   Summary:  Dispatch and handle the main menu commands.
00231
00232   Args:     WPARAM wParam,
00233               First message parameter (word sized).
00234             LPARAM lParam)
00235               Second message parameter (long sized).
00236
00237   Modifies: m_ofnFile, ...
00238
00239   Returns:  LRESULT
00240               Standard Windows WindowProc return value.
00241 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00242 LRESULT CMainWindow::DoMenu(
00243           WPARAM wParam,
00244           LPARAM lParam)
00245 {
00246   LRESULT lResult = FALSE;
00247   HRESULT hr;
00248   HMENU hMenu  = ::GetMenu(m_hWnd);
00249   // Here are some interface pointers used to call methods on
00250   // our COUtilityCar, COCruiseCar, and COUtilityCruiseCar COM objects.
00251   ICar* pICar;
00252   IUtility* pIUtility;
00253   ICruise* pICruise;
00254
00255   switch (LOWORD(wParam))
00256   {
00257     //----------------------------------------------------------------------
00258     // Handle File Menu Commands.
00259     //----------------------------------------------------------------------
00260     case IDM_FILE_EXIT:
00261       // The user commands us to exit this application so we tell the
00262       // Main window to close itself.
00263       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00264       break;
00265
00266     //----------------------------------------------------------------------
00267     // Handle Car Menu Commands.
00268     //----------------------------------------------------------------------
00269     case IDM_CAR_CREATE:
00270       LOG("C: === Car Menu: Create.");
00271       if (NULL == m_pCar)
00272       {
00273         // Call COM service to create an instance.
00274         hr = CoCreateInstance(
00275                CLSID_LocCar,
00276                NULL,
00277                CLSCTX_LOCAL_SERVER,
00278                IID_IUnknown,
00279                (PPVOID)&m_pCar);
00280         if (SUCCEEDED(hr))
00281         {
00282           ::CheckMenuItem(
00283               hMenu,
00284               IDM_CAR_CREATE,
00285               MF_BYCOMMAND | MF_CHECKED);
00286         }
00287         else
00288         {
00289           LOGERROR("C: ???? CoCreateInstance",hr);
00290         }
00291       }
00292       else
00293         LOG("C: ???? Car already exists.");
00294       break;
00295     case IDM_CAR_RELEASE:
00296       LOG("C: === Car Menu: Release.");
00297       if (NULL != m_pCar)
00298       {
00299         RELEASE_INTERFACE(m_pCar);
00300         // We ask COM to unload any unused COM Servers.
00301         CoFreeUnusedLibraries();
00302         ::CheckMenuItem(
00303             hMenu,
00304             IDM_CAR_CREATE,
00305             MF_BYCOMMAND | MF_UNCHECKED);
00306       }
00307       else
00308         LOG("C: ???? No Car to Release.");
00309       break;
00310     case IDM_CAR_SHIFT:
00311       LOG("C: === Car Menu: ICar::Shift");
00312       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00313       {
00314         LOG("C: --Calling pICar->Shift");
00315         pICar->Shift(1);
00316         LOG("C: --Releasing pICar");
00317         pICar->Release();
00318       }
00319       break;
00320     case IDM_CAR_CLUTCH:
00321       LOG("C: === Car Menu: ICar::Clutch");
00322       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00323       {
00324         LOG("C: --Calling pICar->Clutch");
00325         pICar->Clutch(100);
00326         LOG("C: --Releasing pICar");
00327         pICar->Release();
00328       }
00329       break;
00330     case IDM_CAR_SPEED:
00331       LOG("C: === Car Menu: ICar::Speed");
00332       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00333       {
00334         LOG("C: --Calling pICar->Speed");
00335         pICar->Speed(20);
00336         LOG("C: --Releasing pICar");
00337         pICar->Release();
00338       }
00339       break;
00340     case IDM_CAR_STEER:
00341       LOG("C: === Car Menu: ICar::Steer");
00342       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00343       {
00344         LOG("C: --Calling pICar->Steer");
00345         pICar->Steer(0);
00346         LOG("C: --Releasing pICar");
00347         pICar->Release();
00348       }
00349       break;
00350
00351     //----------------------------------------------------------------------
00352     // Handle UtilityCar Menu Commands.
00353     //----------------------------------------------------------------------
00354     case IDM_UCAR_CREATE:
00355       LOG("C: === UtilityCar Menu: Create.");
00356       if (NULL == m_pUtilityCar)
00357       {
00358         // Call COM service to create an instance.
00359         hr = CoCreateInstance(
00360                CLSID_LocUtilityCar,
00361                NULL,
00362                CLSCTX_LOCAL_SERVER,
00363                IID_IUnknown,
00364                (PPVOID)&m_pUtilityCar);
00365         if (SUCCEEDED(hr))
00366         {
00367           ::CheckMenuItem(
00368               hMenu,
00369               IDM_UCAR_CREATE,
00370               MF_BYCOMMAND | MF_CHECKED);
00371         }
00372         else
00373         {
00374           LOGERROR("C: ???? CoCreateInstance",hr);
00375         }
00376       }
00377       else
00378         LOG("C: ???? UtilityCar already exists.");
00379       break;
00380     case IDM_UCAR_RELEASE:
00381       LOG("C: === UtilityCar Menu: Release.");
00382       if (NULL != m_pUtilityCar)
00383       {
00384         RELEASE_INTERFACE(m_pUtilityCar);
00385         // We ask COM to unload any unused COM Servers.
00386         CoFreeUnusedLibraries();
00387         ::CheckMenuItem(
00388             hMenu,
00389             IDM_UCAR_CREATE,
00390             MF_BYCOMMAND | MF_UNCHECKED);
00391       }
00392       else
00393         LOG("C: ???? No UtilityCar to Release.");
00394       break;
00395     case IDM_UCAR_SHIFT:
00396       LOG("C: === UtilityCar Menu: ICar::Shift");
00397       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00398       {
00399         LOG("C: --Calling pICar->Shift");
00400         pICar->Shift(2);
00401         LOG("C: --Releasing pICar");
00402         pICar->Release();
00403       }
00404       break;
00405     case IDM_UCAR_CLUTCH:
00406       LOG("C: === UtilityCar Menu: ICar::Clutch");
00407       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00408       {
00409         LOG("C: --Calling pICar->Clutch");
00410         pICar->Clutch(100);
00411         LOG("C: --Releasing pICar");
00412         pICar->Release();
00413       }
00414       break;
00415     case IDM_UCAR_SPEED:
00416       LOG("C: === UtilityCar Menu: ICar::Speed");
00417       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00418       {
00419         LOG("C: --Calling pICar->Speed");
00420         pICar->Speed(30);
00421         LOG("C: --Releasing pICar");
00422         pICar->Release();
00423       }
00424       break;
00425     case IDM_UCAR_STEER:
00426       LOG("C: === UtilityCar Menu: ICar::Steer");
00427       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00428       {
00429         LOG("C: --Calling pICar->Steer");
00430         pICar->Steer(10);
00431         LOG("C: --Releasing pICar");
00432         pICar->Release();
00433       }
00434       break;
00435     case IDM_UCAR_OFFROAD:
00436       LOG("C: === UtilityCar Menu: IUtility::Offroad");
00437       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00438       {
00439         LOG("C: --Calling pIUtility->Offroad");
00440         pIUtility->Offroad(1);
00441         LOG("C: --Releasing pIUtility");
00442         pIUtility->Release();
00443       }
00444       break;
00445     case IDM_UCAR_WINCH:
00446       LOG("C: === UtilityCar Menu: IUtility::Winch");
00447       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00448       {
00449         LOG("C: --Calling pIUtility->Winch");
00450         pIUtility->Winch(0);
00451         LOG("C: --Releasing pIUtility");
00452         pIUtility->Release();
00453       }
00454       break;
00455
00456     //----------------------------------------------------------------------
00457     // Handle CruiseCar Menu Commands.
00458     //----------------------------------------------------------------------
00459     case IDM_CCAR_CREATE:
00460       LOG("C: === CruiseCar Menu: Create.");
00461       if (NULL == m_pCruiseCar)
00462       {
00463         // Call COM service to create an instance.
00464         hr = CoCreateInstance(
00465                CLSID_LocCruiseCar,
00466                NULL,
00467                CLSCTX_LOCAL_SERVER,
00468                IID_IUnknown,
00469                (PPVOID)&m_pCruiseCar);
00470         if (SUCCEEDED(hr))
00471         {
00472           ::CheckMenuItem(
00473               hMenu,
00474               IDM_CCAR_CREATE,
00475               MF_BYCOMMAND | MF_CHECKED);
00476         }
00477         else
00478         {
00479           LOGERROR("C: ???? CoCreateInstance",hr);
00480         }
00481       }
00482       else
00483         LOG("C: ???? CruiseCar already exists.");
00484       break;
00485     case IDM_CCAR_RELEASE:
00486       LOG("C: === CruiseCar Menu: Release.");
00487       if (NULL != m_pCruiseCar)
00488       {
00489         RELEASE_INTERFACE(m_pCruiseCar);
00490         // We ask COM to unload any unused COM Servers.
00491         CoFreeUnusedLibraries();
00492         ::CheckMenuItem(
00493             hMenu,
00494             IDM_CCAR_CREATE,
00495             MF_BYCOMMAND | MF_UNCHECKED);
00496       }
00497       else
00498         LOG("C: ???? No CruiseCar to Release.");
00499       break;
00500     case IDM_CCAR_SHIFT:
00501       LOG("C: === CruiseCar Menu: ICar::Shift");
00502       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00503       {
00504         LOG("C: --Calling pICar->Shift");
00505         pICar->Shift(4);
00506         LOG("C: --Releasing pICar");
00507         pICar->Release();
00508       }
00509       break;
00510     case IDM_CCAR_CLUTCH:
00511       LOG("C: === CruiseCar Menu: ICar::Clutch");
00512       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00513       {
00514         LOG("C: --Calling pICar->Clutch");
00515         pICar->Clutch(100);
00516         LOG("C: --Releasing pICar");
00517         pICar->Release();
00518       }
00519       break;
00520     case IDM_CCAR_SPEED:
00521       LOG("C: === CruiseCar Menu: ICar::Speed");
00522       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00523       {
00524         LOG("C: --Calling pICar->Speed");
00525         pICar->Speed(60);
00526         LOG("C: --Releasing pICar");
00527         pICar->Release();
00528       }
00529       break;
00530     case IDM_CCAR_STEER:
00531       LOG("C: === CruiseCar Menu: ICar::Steer");
00532       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00533       {
00534         LOG("C: --Calling pICar->Steer");
00535         pICar->Steer(0);
00536         LOG("C: --Releasing pICar");
00537         pICar->Release();
00538       }
00539       break;
00540     case IDM_CCAR_ENGAGE:
00541       LOG("C: === CruiseCar Menu: ICruise::Engage");
00542       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00543       {
00544         LOG("C: --Calling pICruise->Engage");
00545         pICruise->Engage(TRUE);
00546         LOG("C: --Releasing pICruise");
00547         pICruise->Release();
00548       }
00549       break;
00550     case IDM_CCAR_ADJUST:
00551       LOG("C: === CruiseCar Menu: ICruise::Adjust");
00552       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00553       {
00554         LOG("C: --Calling pICruise->Adjust");
00555         pICruise->Adjust(FALSE);
00556         LOG("C: --Releasing pICruise");
00557         pICruise->Release();
00558       }
00559       break;
00560
00561     //----------------------------------------------------------------------
00562     // Handle UtilityCruiseCar Menu Commands.
00563     //----------------------------------------------------------------------
00564     case IDM_UCRU_CREATE:
00565       LOG("C: === UtilityCruiseCar Menu: Create.");
00566       if (NULL == m_pUtilityCruiseCar)
00567       {
00568         // Call a create function to create an instance.
00569         hr = CreateUtilityCruiseCar(
00570                NULL,
00571                IID_IUnknown,
00572                (PPVOID)&m_pUtilityCruiseCar);
00573         if (SUCCEEDED(hr))
00574         {
00575           ::CheckMenuItem(
00576               hMenu,
00577               IDM_UCRU_CREATE,
00578               MF_BYCOMMAND | MF_CHECKED);
00579         }
00580         else
00581         {
00582           LOGERROR("C: ???? UtilityCruiseCar creation",hr);
00583         }
00584       }
00585       else
00586         LOG("C: ???? UtilityCruiseCar already exists.");
00587       break;
00588     case IDM_UCRU_RELEASE:
00589       LOG("C: === UtilityCruiseCar Menu: Release.");
00590       if (NULL != m_pUtilityCruiseCar)
00591       {
00592         RELEASE_INTERFACE(m_pUtilityCruiseCar);
00593         // We ask COM to unload any unused COM Servers.
00594         CoFreeUnusedLibraries();
00595         ::CheckMenuItem(
00596             hMenu,
00597             IDM_UCRU_CREATE,
00598             MF_BYCOMMAND | MF_UNCHECKED);
00599       }
00600       else
00601         LOG("C: ???? No UtilityCruiseCar to Release.");
00602       break;
00603     case IDM_UCRU_SHIFT:
00604       LOG("C: === UtilityCruiseCar Menu: ICar::Shift");
00605       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00606       {
00607         LOG("C: --Calling pICar->Shift");
00608         pICar->Shift(1);
00609         LOG("C: --Releasing pICar");
00610         pICar->Release();
00611       }
00612       break;
00613     case IDM_UCRU_CLUTCH:
00614       LOG("C: === UtilityCruiseCar Menu: ICar::Clutch");
00615       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00616       {
00617         LOG("C: --Calling pICar->Clutch");
00618         pICar->Clutch(80);
00619         LOG("C: --Releasing pICar");
00620         pICar->Release();
00621       }
00622       break;
00623     case IDM_UCRU_SPEED:
00624       LOG("C: === UtilityCruiseCar Menu: ICar::Speed");
00625       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00626       {
00627         LOG("C: --Calling pICar->Speed");
00628         pICar->Speed(10);
00629         LOG("C: --Releasing pICar");
00630         pICar->Release();
00631       }
00632       break;
00633     case IDM_UCRU_STEER:
00634       LOG("C: === UtilityCruiseCar Menu: ICar::Steer");
00635       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00636       {
00637         LOG("C: --Calling pICar->Steer");
00638         pICar->Steer(10);
00639         LOG("C: --Releasing pICar");
00640         pICar->Release();
00641       }
00642       break;
00643     case IDM_UCRU_ENGAGE:
00644       LOG("C: === UtilityCruiseCar Menu: ICruise::Engage");
00645       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00646       {
00647         LOG("C: --Calling pICruise->Engage");
00648         pICruise->Engage(FALSE);
00649         LOG("C: --Releasing pICruise");
00650         pICruise->Release();
00651       }
00652       break;
00653     case IDM_UCRU_ADJUST:
00654       LOG("C: === UtilityCruiseCar Menu: ICruise::Adjust");
00655       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00656       {
00657         LOG("C: --Calling pICruise->Adjust");
00658         pICruise->Adjust(FALSE);
00659         LOG("C: --Releasing pICruise");
00660         pICruise->Release();
00661       }
00662       break;
00663     case IDM_UCRU_OFFROAD:
00664       LOG("C: === UtilityCruiseCar Menu: IUtility::Offroad");
00665       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00666       {
00667         LOG("C: --Calling pIUtility->Offroad");
00668         pIUtility->Offroad(3);
00669         LOG("C: --Releasing pIUtility");
00670         pIUtility->Release();
00671       }
00672       break;
00673     case IDM_UCRU_WINCH:
00674       LOG("C: === UtilityCruiseCar Menu: IUtility::Winch");
00675       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00676       {
00677         LOG("C: --Calling pIUtility->Winch");
00678         pIUtility->Winch(0);
00679         LOG("C: --Releasing pIUtility");
00680         pIUtility->Release();
00681       }
00682       break;
00683
00684     //----------------------------------------------------------------------
00685     // Handle Log Menu Commands.
00686     //----------------------------------------------------------------------
00687     case IDM_LOG_LOGCLEAR:
00688       // Clear the message log.
00689       m_pMsgLog->Clear();
00690       // Use macro to log messages.
00691       LOGID(IDS_START_MESSAGE_LOG);
00692       break;
00693     case IDM_LOG_LOGGING:
00694       // Toggle the state of the Message Logging.
00695       // Toggle the checkmark indicator on the menu selection as well.
00696       {
00697         HMENU hMenu  = ::GetMenu(m_hWnd);
00698         BOOL bLogging = ::GetMenuState(
00699                             hMenu,
00700                             IDM_LOG_LOGGING,
00701                             MF_BYCOMMAND) & MF_CHECKED;
00702         if (bLogging)
00703         {
00704           m_pMsgLog->Logging(FALSE);
00705           ::CheckMenuItem(
00706               hMenu,
00707               IDM_LOG_LOGGING,
00708               MF_BYCOMMAND | MF_UNCHECKED);
00709         }
00710         else
00711         {
00712           m_pMsgLog->Logging(TRUE);
00713           ::CheckMenuItem(
00714               hMenu,
00715               IDM_LOG_LOGGING,
00716               MF_BYCOMMAND | MF_CHECKED);
00717         }
00718       }
00719       break;
00720     case IDM_LOG_COPYCLIP:
00721       // Copy trace message log to clipboard.
00722       m_pMsgLog->Copy();
00723       break;
00724
00725     //----------------------------------------------------------------------
00726     // Handle Help Menu Commands.
00727     //----------------------------------------------------------------------
00728     case IDM_HELP_CONTENTS:
00729       // We have some stubbed support here for bringing up the online
00730       // Help for this application.
00731       ReadHelp(m_hWnd, m_szHelpFile);
00732       break;
00733     case IDM_HELP_TUTORIAL:
00734       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00735       // tutorial narrative file associated with this tutorial code sample.
00736       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00737       break;
00738     case IDM_HELP_TUTSERVER:
00739       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00740       // tutorial narrative file associated with the LOCSERVE COM server.
00741       ReadTutorial(m_hInst, m_hWnd, TEXT(SERVER_TUTFILE_STR));
00742       break;
00743     case IDM_HELP_TUTMARSHAL:
00744       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00745       // tutorial narrative file associated with the COM marshaling server.
00746       ReadTutorial(m_hInst, m_hWnd, TEXT(MARSHAL_TUTFILE_STR));
00747       break;
00748     case IDM_HELP_READSOURCE:
00749       // Call the APPUTIL utility function ReadSource to allow the
00750       // user to open and read any of the source files of LOCCLIEN.
00751       ReadSource(m_hWnd, &m_ofnFile);
00752       break;
00753     case IDM_HELP_ABOUT:
00754       {
00755         CAboutBox dlgAboutBox;
00756
00757         LOG("C: === Help Menu: About LOCCLIEN.");
00758         // Show the standard About Box dialog for this EXE by telling the
00759         // dialog C++ object to show itself by invoking its ShowDialog
00760         // method.  Pass it this EXE instance and the parent window handle.
00761         // Use a dialog resource ID for the dialog template stored in
00762         // this EXE module's resources.
00763         dlgAboutBox.ShowDialog(
00764           m_hInst,
00765           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00766           m_hWnd);
00767       }
00768       break;
00769     case IDM_HELP_ABOUTSERVER:
00770       {
00771         // Post a message to the Server to show its AboutBox dialog.
00772         LOG("C: === Help Menu: About LOCSERVE.");
00773
00774         HWND hWnd = FindWindow(NULL, TEXT(SERVER_WINDOW_TITLE_STR));
00775         if (NULL != hWnd)
00776           PostMessage(hWnd, WM_COMMAND, IDM_HELP_ABOUT, NULL);
00777       }
00778       break;
00779
00780     default:
00781       // Defer all messages NOT handled here to the Default Window Proc.
00782       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00783       break;
00784   }
00785
00786   return(lResult);
00787 }
00788
00789
00790 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00791   Method:   CMainWindow::InitInstance
00792
00793   Summary:  Instantiates an instance of the main application window.
00794             This method must be called only once, immediately after
00795             window class construction.  We take care to delete 'this'
00796             CMainWindow if we must return the error condition FALSE.
00797
00798   Args:     HINSTANCE hInstance,
00799               Handle of the application instance.
00800             int nCmdShow)
00801               Command to pass to ShowWindow.
00802
00803   Modifies: m_szHelpFile, m_pMsgBox, m_pMsgLog.
00804
00805   Returns:  BOOL.
00806               TRUE if succeeded.
00807               FALSE if failed.
00808 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00809 BOOL CMainWindow::InitInstance(
00810        HINSTANCE hInstance,
00811        int nCmdShow)
00812 {
00813   BOOL bOk = FALSE;
00814   HWND hWnd;
00815
00816   // Create the Message Box and Message Log objects.
00817   m_pMsgBox = new CMsgBox;
00818   m_pMsgLog = new CMsgLog;
00819
00820   if (NULL != m_pMsgBox && NULL != m_pMsgLog)
00821   {
00822     // Note, the Create method sets the m_hWnd member so we don't
00823     // need to set it explicitly here first.
00824
00825     // Here is the create of this window.  Size the window reasonably.
00826     // Create sets both m_hInst and m_hWnd.
00827     hWnd = Create(
00828              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00829              TEXT(MAIN_WINDOW_TITLE_STR),
00830              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00831                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00832              CW_USEDEFAULT,
00833              CW_USEDEFAULT,
00834              ::GetSystemMetrics(SM_CXSCREEN)*3/5,
00835              ::GetSystemMetrics(SM_CYSCREEN)*3/5,
00836              NULL,
00837              NULL,
00838              hInstance);
00839     if (hWnd)
00840     {
00841       // Ensure the new window is shown on screen and its content is painted.
00842       ::ShowWindow(m_hWnd, nCmdShow);
00843       ::UpdateWindow(m_hWnd);
00844
00845       // Build a path to where the help file should be (it should be in
00846       // the same directory as the .EXE but with the .HTM extension.
00847       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00848
00849       // Init the Message Box object.
00850       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00851       {
00852         // Create the Trace Message Log ListBox as a child window that
00853         // fits the client area of the Main Window (the TRUE 3rd argument
00854         // specifies such an inside child). If you want the Trace Message
00855         // Log in a separate (but owned) window, then pass a FALSE instead
00856         // for the 3rd argument.
00857         if (m_pMsgLog->Create(m_hInst, m_hWnd, TRUE))
00858         {
00859           // Assign the global MsgLog pointer.
00860           g_pMsgLog = m_pMsgLog;
00861           // Use macro to log an initial start messsage.
00862           LOGID(IDS_START_MESSAGE_LOG);
00863           bOk = TRUE;
00864         }
00865       }
00866     }
00867   }
00868
00869   if (!bOk)
00870   {
00871     DELETE_POINTER(m_pMsgBox);
00872     DELETE_POINTER(m_pMsgLog);
00873   }
00874
00875   return (bOk);
00876 }
00877
00878
00879 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00880   Method:   CMainWindow::WindowProc
00881
00882   Summary:  Main window procedure for this window object.  See CVirWindow
00883             in the APPUTIL library (APPUTIL.CPP) for details on how this
00884             method gets called by the global WindowProc.
00885
00886   Args:     UINT uMsg,
00887               Windows message that is "sent" to this window.
00888             WPARAM wParam,
00889               First message parameter (word sized).
00890             LPARAM lParam)
00891               Second message parameter (long sized).
00892
00893   Modifies: ...
00894
00895   Returns:  LRESULT
00896               Standard Windows WindowProc return value.
00897 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00898 LRESULT CMainWindow::WindowProc(
00899           UINT uMsg,
00900           WPARAM wParam,
00901           LPARAM lParam)
00902 {
00903   LRESULT lResult = FALSE;
00904
00905   switch (uMsg)
00906   {
00907     case WM_CREATE:
00908       {
00909         // Setup for painting text in this window.
00910         HDC hdc = GetDC(m_hWnd);
00911         ::GetTextMetrics(hdc, &m_tm);
00912         ::ReleaseDC(m_hWnd, hdc);
00913       }
00914       break;
00915
00916     case WM_MEASUREITEM:
00917       // Get setup for painting text in this window.
00918       {
00919         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00920         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00921         lpmis->itemWidth = m_wWidth;
00922         lResult = TRUE;
00923       }
00924
00925     case WM_SIZE:
00926       // Handle a resize of this window.
00927       m_wWidth = LOWORD(lParam);
00928       m_wHeight = HIWORD(lParam);
00929       // Resize the Message Log ListBox
00930       m_pMsgLog->Resize(m_wWidth, m_wHeight);
00931       break;
00932
00933     case WM_COMMAND:
00934       // Dispatch and handle any Menu command messages received.
00935       lResult = DoMenu(wParam, lParam);
00936       break;
00937
00938     case WM_COPYDATA:
00939       // We have been sent a trace log message from a server.
00940       // Log it to our own Client's display.
00941       {
00942         LPTSTR pszMsg = (LPTSTR)((COPYDATASTRUCT*)lParam)->lpData;
00943         g_pMsgLog->Msg(pszMsg);
00944         #if defined(DEBUG)
00945         // Bump to next line in the debugger output window.
00946         ::OutputDebugString(TEXT("\r\n"));
00947         #endif
00948       }
00949       break;
00950
00951     case WM_CLOSE:
00952       // The user selected Close on the main window's System menu
00953       // or Exit on the File menu.
00954     case WM_QUIT:
00955       // If the app is being quit then close any associated help windows.
00956     default:
00957       // Defer all messages NOT handled here to the Default Window Proc.
00958       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00959       break;
00960   }
00961
00962   return(lResult);
00963 }
00964
00965
00966 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00967   Function: UnicodeOk
00968
00969   Summary:  Checks if the platform will handle unicode versions of
00970             Win32 string API calls.
00971
00972   Args:     void
00973
00974   Returns:  BOOL
00975               TRUE if unicode support; FALSE if not.
00976 ------------------------------------------------------------------------F-F*/
00977 BOOL UnicodeOk(void)
00978 {
00979   BOOL bOk = TRUE;
00980   TCHAR szUserName[MAX_STRING_LENGTH];
00981   DWORD dwSize = MAX_STRING_LENGTH;
00982
00983   if (!GetUserName(szUserName, &dwSize))
00984     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00985
00986   return bOk;
00987 }
00988
00989
00990 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00991   Function: InitApplication
00992
00993   Summary:  Initializes the application and registers its main window
00994             class. InitApplication is called only once (in WinMain).
00995
00996   Args:     HINSTANCE hInstance)
00997               Handle to the first instance of the application.
00998
00999   Returns:  BOOL.
01000               TRUE if success.
01001               FALSE if fail.
01002 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01003 BOOL InitApplication(
01004        HINSTANCE hInstance)
01005 {
01006   BOOL bOk;
01007   // The window class for all instances of the main frame window.
01008   WNDCLASSEX wcf;
01009
01010   // Assign the appropriate values for this main frame window class.
01011   wcf.cbSize        = sizeof(WNDCLASSEX);
01012   wcf.cbClsExtra    = 0;            // No per-class extra data.
01013   wcf.cbWndExtra    = 0;            // No per-window extra data.
01014   wcf.hInstance     = hInstance;    // Application module instance.
01015   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
01016                                     // APPUTIL for all CVirWindows).
01017   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
01018   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
01019                                 hInstance,
01020                                 TEXT("AppIcon"));
01021   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
01022                                 hInstance,
01023                                 TEXT("AppIcon"),
01024                                 IMAGE_ICON,
01025                                 16, 16,
01026                                 0);
01027   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
01028   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
01029   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
01030   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
01031
01032   // Register the window class and return FALSE if unsuccesful.
01033   bOk = RegisterClassEx(&wcf);
01034
01035   return (bOk);
01036 }
01037
01038
01039 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01040   Function: WinMain
01041
01042   Summary:  The Windows main entry point function for this application.
01043             Initializes the application, the COM Libraries, and starts
01044             the main application message loop.
01045
01046   Args:     HINSTANCE hInstance,
01047               Instance handle; a new one for each invocation of this app.
01048             HINSTANCE hPrevInstance,
01049               Instance handle of the previous instance. NULL in Win32.
01050             LPSTR lpCmdLine,
01051               Windows passes a pointer to the application's
01052               invocation command line.
01053             int nCmdShow)
01054               Bits telling the show state of the application.
01055
01056   Returns:  int
01057               msg.wParam (upon exit of message loop).
01058               FALSE if this instance couldn't initialize and run.
01059 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01060 extern "C" int PASCAL WinMain(
01061                         HINSTANCE hInstance,
01062                         HINSTANCE hPrevInstance,
01063                         LPSTR lpCmdLine,
01064                         int nCmdShow)
01065 {
01066   CMainWindow* pWin = NULL;
01067   MSG msg;
01068   HACCEL hAccel;
01069   int iRun = FALSE;
01070
01071   // If we were compiled for UNICODE and the platform seems OK with this
01072   // then proceed.  Else we error and exit the app.
01073   if (UnicodeOk())
01074   {
01075     // Call to initialize the COM Library.  Use the SUCCEEDED macro
01076     // to detect success.  If fail then exit app with error message.
01077     if (SUCCEEDED(CoInitialize(NULL)))
01078     {
01079       // If we succeeded in initializing the COM Library we proceed to
01080       // initialize the application.  If we can't init the application
01081       // then we signal shut down with an error message exit.
01082       iRun = InitApplication(hInstance);
01083       if (iRun)
01084       {
01085         // Assume we'll set iRun to TRUE when initialization is done.
01086         iRun = FALSE;
01087         // We are still go for running so we try to create a nifty new
01088         // CMainWindow object for this app instance.
01089         pWin = new CMainWindow;
01090         if (NULL != pWin)
01091         {
01092           // Now we initialize an instance of the new CMainWindow.
01093           // This includes creating the main window.
01094           if (pWin->InitInstance(hInstance, nCmdShow))
01095           {
01096             // Load the keyboard accelerators from the resources.
01097             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
01098             if (NULL != hAccel)
01099             {
01100               // Signal App Initialization is successfully done.
01101               iRun = TRUE;
01102             }
01103           }
01104         }
01105       }
01106
01107       if (iRun)
01108       {
01109         // If we initialized the app instance properly then we are still
01110         // go for running.  We then start up the main message pump for
01111         // the application.
01112         while (GetMessage(&msg, NULL, 0, 0))
01113         {
01114           if (!TranslateAccelerator(
01115                  pWin->GetHwnd(),
01116                  hAccel,
01117                  &msg))
01118           {
01119             TranslateMessage(&msg);
01120             DispatchMessage(&msg);
01121           }
01122         }
01123
01124         // We ask COM to unload any unused COM Servers.
01125         CoFreeUnusedLibraries();
01126
01127         // We'll pass to Windows the reason why we exited the message loop.
01128         iRun = msg.wParam;
01129       }
01130       else
01131       {
01132         // We failed to initialize the application. Put up error message
01133         // box saying that application couldn't be initialized.  Parent
01134         // window is desktop (ie, NULL). Exit the failed application
01135         // (ie, by returning FALSE to WinMain).
01136         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
01137
01138         // Delete the CMainWindow object.
01139         DELETE_POINTER(pWin);
01140       }
01141
01142       // We're exiting this app (either normally or by init failure) so
01143       // shut down the COM Library.
01144       CoUninitialize();
01145     }
01146     else
01147     {
01148       // We failed to Initialize the COM Library. Put up error message box
01149       // saying that COM Library couldn't be initialized.  Parent window
01150       // is desktop (ie, NULL). Exit the failed application (ie, by
01151       // returning FALSE to WinMain).
01152       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
01153     }
01154   }
01155   else
01156   {
01157     // If we were compiled for UNICODE but the platform has problems with
01158     // this then indicate an error and exit the app immediately.
01159     CHAR szMsg[MAX_STRING_LENGTH];
01160
01161     if (LoadStringA(
01162           hInstance,
01163           IDS_NOUNICODE,
01164           szMsg,
01165           MAX_STRING_LENGTH))
01166     {
01167       MessageBoxA(
01168         NULL,
01169         szMsg,
01170         ERROR_TITLE_STR,
01171         MB_OK | MB_ICONEXCLAMATION);
01172     }
01173   }
01174
01175   return iRun;
01176 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/MTXSample/BankVC.idl Source File

  • Web
  • iis
  • Components
  • Cpp
  • MTXSample

BankVC.idl

Go to the documentation of this file.
00001 // BankVC.idl : IDL source for BankVC.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (BankVC.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009   [
00010     object,
00011     uuid(5A67AADF-37DA-11D2-955A-004005A2F9B1),
00012     dual,
00013     helpstring("IAccount Interface"),
00014     pointer_default(unique)
00015   ]
00016   interface IAccount : IDispatch
00017   {
00018     [id(1), helpstring("method Post")] HRESULT Post([in] long lngAccntNum, [in] long lngAmount, [out, retval] BSTR* pVal);
00019   };
00020   [
00021     object,
00022     uuid(5A67AAE1-37DA-11D2-955A-004005A2F9B1),
00023     dual,
00024     helpstring("ICreateTable Interface"),
00025     pointer_default(unique)
00026   ]
00027   interface ICreateTable : IDispatch
00028   {
00029     [id(1), helpstring("method CreateAccount")] HRESULT CreateAccount();
00030   };
00031   [
00032     object,
00033     uuid(5A67AAE3-37DA-11D2-955A-004005A2F9B1),
00034     dual,
00035     helpstring("IMoveMoney Interface"),
00036     pointer_default(unique)
00037   ]
00038   interface IMoveMoney : IDispatch
00039   {
00040     [id(1), helpstring("method Perform")] HRESULT Perform([in]long lngAcnt1, [in] long lngAcnt2, [in]long lngAmount, [in]long lngType, [out, retval]BSTR* pVal);
00041   };
00042
00043 [
00044   uuid(5A67AAD3-37DA-11D2-955A-004005A2F9B1),
00045   version(1.0),
00046   helpstring("BankVC 1.0 Type Library")
00047 ]
00048 library BANKVCLib
00049 {
00050   importlib("stdole32.tlb");
00051   importlib("stdole2.tlb");
00052
00053   [
00054     uuid(5A67AAE0-37DA-11D2-955A-004005A2F9B1),
00055     helpstring("Account Class")
00056   ]
00057   coclass Account
00058   {
00059     [default] interface IAccount;
00060   };
00061   [
00062     uuid(5A67AAE2-37DA-11D2-955A-004005A2F9B1),
00063     helpstring("CreateTable Class")
00064   ]
00065   coclass CreateTable
00066   {
00067     [default] interface ICreateTable;
00068   };
00069   [
00070     uuid(5A67AAE4-37DA-11D2-955A-004005A2F9B1),
00071     helpstring("MoveMoney Class")
00072   ]
00073   coclass MoveMoney
00074   {
00075     [default] interface IMoveMoney;
00076   };
00077 };
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/BrochureMachine/StdAfx.h Source File

  • Web
  • Browser
  • BrochureMachine

StdAfx.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.h : include file for standard system include files,
00006 //      or project specific include files that are used frequently,
00007 //      but are changed infrequently
00008
00009 #if !defined(AFX_STDAFX_H__D14363D7_1BB8_4473_AD4C_F5221ABCE38E__INCLUDED_)
00010 #define AFX_STDAFX_H__D14363D7_1BB8_4473_AD4C_F5221ABCE38E__INCLUDED_
00011
00012 #if _MSC_VER > 1000
00013 #pragma once
00014 #endif // _MSC_VER > 1000
00015
00016 #define STRICT
00017 #ifndef _WIN32_WINNT
00018 #define _WIN32_WINNT 0x0400
00019 #endif
00020 #define _ATL_APARTMENT_THREADED
00021
00022 #include <atlbase.h>
00023 //You may derive a class from CComModule and use it if you want to override
00024 //something, but do not change the name of _Module
00025 extern CComModule _Module;
00026 #include <atlcom.h>
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00030
00031 #endif // !defined(AFX_STDAFX_H__D14363D7_1BB8_4473_AD4C_F5221ABCE38E__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/RenderBehave/renderproject/EventSink.h Source File

  • Web
  • Browser
  • RenderBehave
  • renderproject

EventSink.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // EventSink.h : Declaration of the CEventSink
00006
00007 #ifndef __EVENTSINK_H_
00008 #define __EVENTSINK_H_
00009
00010 #include "resource.h"       // main symbols
00011
00012 /////////////////////////////////////////////////////////////////////////////
00013 // CEventSink
00014
00015 class CBehavior;
00016
00017 class ATL_NO_VTABLE CEventSink :
00018   public CComObjectRootEx<CComSingleThreadModel>,
00019   public CComCoClass<CEventSink, &CLSID_EventSink>,
00020   public IDispatchImpl<IEventSink, &IID_IEventSink, &LIBID_RENDERLib>
00021 {
00022 public:
00023   CBehavior*  m_pBehavior;
00024   BOOL mouseDown;
00025
00026   CEventSink() :
00027     m_pBehavior(NULL),
00028     mouseDown(FALSE)
00029   {
00030
00031   }
00032
00033 DECLARE_REGISTRY_RESOURCEID(IDR_EVENTSINK)
00034 DECLARE_NOT_AGGREGATABLE(CEventSink)
00035
00036 BEGIN_COM_MAP(CEventSink)
00037   COM_INTERFACE_ENTRY2(HTMLElementEvents,IEventSink)
00038   COM_INTERFACE_ENTRY(IDispatch)
00039 END_COM_MAP()
00040
00041
00042 // IDispatchImpl override
00043   STDMETHOD(Invoke)(DISPID dispidMember,
00044             REFIID riid,
00045             LCID lcid,
00046             WORD wFlags,
00047             DISPPARAMS* pdispparams,
00048             VARIANT* pvarResult,
00049             EXCEPINFO* pexcepinfo,
00050             UINT* puArgErr);
00051 // Event Handlers
00052 public:
00053   void OnMouseOver();
00054   void OnMouseOut();
00055   void OnClick();
00056 };
00057
00058 #endif //__EVENTSINK_H_
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMgrNotify Member List

This is the complete list of members for CMgrNotify, including all inherited members.
AddRef(void) | CMgrNotify |
AddRef(void) | CMgrNotify |
AddRef(void) | CMgrNotify |
AddRef(void) | CMgrNotify |
AddRef(void) | CMgrNotify |
RefCount::AddRef(void) | RefCount |
CRefCount::AddRef(void) | CRefCount |
CallCreated(INmCall *pCall) | CMgrNotify |
CallCreated(INmCall *pCall) | CMgrNotify |
CallCreated(INmCall *pCall) | CMgrNotify |
CallCreated(INmCall *pCall) | CMgrNotify |
CallCreated(INmCall *pCall) | CMgrNotify |
CMgrNotify() | CMgrNotify |
CMgrNotify() | CMgrNotify |
CMgrNotify() | CMgrNotify |
CMgrNotify() | CMgrNotify |
CMgrNotify() | CMgrNotify | [private]
CMgrNotify(Conf *) | CMgrNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
ConferenceCreated(INmConference *pConference) | CMgrNotify |
ConferenceCreated(INmConference *pConference) | CMgrNotify |
ConferenceCreated(INmConference *pConference) | CMgrNotify |
ConferenceCreated(INmConference *pConference) | CMgrNotify |
ConferenceCreated(INmConference *pConference) | CMgrNotify |
Connect(IUnknown *pUnk) | CMgrNotify |
Connect(IUnknown *pUnk) | CMgrNotify |
Connect(IUnknown *pUnk) | CMgrNotify |
Connect(IUnknown *pUnk) | CMgrNotify |
Connect(IUnknown *pUnkOuter) | CMgrNotify |
CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
CRefCount() | CRefCount |
Disconnect(void) | CMgrNotify |
Disconnect(void) | CMgrNotify |
Disconnect(void) | CMgrNotify |
Disconnect(void) | CMgrNotify |
Disconnect(void) | CMgrNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
m_pConf | CMgrNotify | [private]
NmUI(CONFN confn) | CMgrNotify |
NmUI(CONFN confn) | CMgrNotify |
NmUI(CONFN confn) | CMgrNotify |
NmUI(CONFN uNotify) | CMgrNotify |
NmUI(CONFN uNotify) | CMgrNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CMgrNotify |
QueryInterface(REFIID riid, void **ppvObj) | CMgrNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CMgrNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CMgrNotify |
QueryInterface(REFIID riid, PVOID *ppvObject) | CMgrNotify |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
Release(void) | CMgrNotify |
Release(void) | CMgrNotify |
Release(void) | CMgrNotify |
Release(void) | CMgrNotify |
Release(void) | CMgrNotify |
RefCount::Release(void) | RefCount |
CRefCount::Release(void) | CRefCount |
~CMgrNotify() | CMgrNotify |
~CMgrNotify() | CMgrNotify |
~CMgrNotify() | CMgrNotify |
~CMgrNotify() | CMgrNotify |
~CMgrNotify() | CMgrNotify | [virtual]
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CRefCount() | CRefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
Generated on Wed Nov 13 2024 16:56:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/OLEDoc.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

OLEDoc.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          OleDoc.cpp
00021
00022   Description:   COleDocument implementation.
00023
00024 **************************************************************************/
00025
00026 /**************************************************************************
00027 #include statements
00028 **************************************************************************/
00029
00030 #include <aclapi.h>
00031 #include "OleDoc.h"
00032 #include "comcat.h"
00033
00034 /**************************************************************************
00035 global variables
00036 **************************************************************************/
00037
00038 extern DWORD   g_DllRefCount;
00039
00040 /**************************************************************************
00041
00042   COleDocument::COleDocument()
00043
00044 **************************************************************************/
00045
00046 COleDocument::COleDocument()
00047 {
00048   OutputDebugString(TEXT("COleDocument's constructor\n"));
00049
00050   m_ObjRefCount = 0;
00051
00052   m_fDirty = FALSE;
00053   m_fNoScribbleMode = FALSE;
00054   m_pOleAdviseHolder = NULL;
00055   m_pOleClientSite = NULL;
00056   m_dwRegister = 0;
00057   m_pOleDocView = NULL;
00058   m_Color = DEFAULT_COLOR;
00059   m_fCreated = FALSE;
00060
00061   m_pOleObject = new COleObject(this);
00062
00063   m_pDataObject = new CDataObject(this);
00064
00065   m_pOleInPlaceObject = new COleInPlaceObject(this);
00066
00067   m_pOleInPlaceActiveObject = new COleInPlaceActiveObject(this);
00068
00069   m_pPersistStorage = new CPersistStorage(this);
00070
00071   m_pPersistFile = new CPersistFile(this, m_pPersistStorage);
00072
00073   m_pOleDocView = new COleDocumentView(this);
00074
00075   g_DllRefCount++;
00076 }
00077
00078 /**************************************************************************
00079
00080   COleDocument::~COleDocument()
00081
00082 **************************************************************************/
00083
00084 COleDocument::~COleDocument()
00085 {
00086   OutputDebugString(TEXT("COleDocument's destructor\n"));
00087
00088   if(m_pOleAdviseHolder)
00089     m_pOleAdviseHolder->Release();
00090
00091   if(m_pOleClientSite)
00092     m_pOleClientSite->Release();
00093
00094   delete m_pOleDocView;
00095
00096   delete m_pPersistFile;
00097
00098   delete m_pPersistStorage;
00099
00100   delete m_pOleInPlaceActiveObject;
00101
00102   delete m_pOleInPlaceObject;
00103
00104   delete m_pDataObject;
00105
00106   delete m_pOleObject;
00107
00108   g_DllRefCount--;
00109
00110   PostQuitMessage(0);
00111 }
00112
00113 ///////////////////////////////////////////////////////////////////////////
00114 //
00115 // IUnknown Implementation
00116 //
00117
00118 /**************************************************************************
00119
00120   COleDocument::QueryInterface
00121
00122 **************************************************************************/
00123
00124 STDMETHODIMP COleDocument::QueryInterface(REFIID riid, LPVOID *ppReturn)
00125 {
00126   OutputDebugString(TEXT("COleDocument::QueryInterface - "));
00127
00128   HRESULT  hr = E_NOINTERFACE;
00129   *ppReturn = NULL;
00130
00131   if(riid == IID_IUnknown)
00132   {
00133     *ppReturn = this;
00134     OutputDebugString(TEXT("IUnknown requested - "));
00135   }
00136   else if (riid == IID_IOleDocument)
00137   {
00138     *ppReturn = this;
00139     OutputDebugString(TEXT("IOleDocument requested - "));
00140   }
00141   else if (riid == IID_IOleDocumentView)
00142   {
00143     *ppReturn = m_pOleDocView;
00144     OutputDebugString(TEXT("IOleDocumentView requested - "));
00145   }
00146   else if (riid == IID_IOleObject)
00147   {
00148     *ppReturn = m_pOleObject;
00149     OutputDebugString(TEXT("IOleObject requested - "));
00150   }
00151   else if (riid == IID_IDataObject)
00152   {
00153     *ppReturn = m_pDataObject;
00154     OutputDebugString(TEXT("IDataObject requested - "));
00155   }
00156   else if (riid == IID_IOleInPlaceObject)
00157   {
00158     *ppReturn = m_pOleInPlaceObject;
00159     OutputDebugString(TEXT("IOleInPlaceObject requested - "));
00160   }
00161   else if (riid == IID_IOleInPlaceActiveObject)
00162   {
00163     *ppReturn = m_pOleInPlaceActiveObject;
00164     OutputDebugString(TEXT("IOleInPlaceActiveObject requested - "));
00165   }
00166   else if((riid == IID_IPersistStorage) || (riid == IID_IPersist))
00167   {
00168     *ppReturn = m_pPersistStorage;
00169     OutputDebugString(TEXT("IPersistStorage requested - "));
00170   }
00171   else if(riid == IID_IPersistFile)
00172   {
00173     *ppReturn = m_pPersistFile;
00174     OutputDebugString(TEXT("IPersistFile requested - "));
00175   }
00176
00177   if (*ppReturn)
00178   {
00179     OutputDebugString(TEXT("Interface Found\n"));
00180     ((LPUNKNOWN)*ppReturn)->AddRef();
00181     hr = S_OK;
00182   }
00183   else
00184   {
00185     OutputDebugString(TEXT("No Interface - "));
00186
00187     LPWSTR   pwsz;
00188     TCHAR    szString[MAX_PATH] = TEXT("");
00189
00190     StringFromIID(riid, &pwsz);
00191
00192     if(pwsz)
00193     {
00194 #ifdef UNICODE
00195       lstrcpyn(szString, pwsz, sizeof(szString)/sizeof(TCHAR));
00196 #else
00197       WideCharToMultiByte( CP_ACP,
00198         0,
00199         pwsz,
00200         -1,
00201         szString,
00202         ARRAYSIZE(szString),
00203         NULL,
00204         NULL);
00205 #endif
00206       OutputDebugString(szString);
00207       OutputDebugString(TEXT("\n"));
00208
00209       //free the string
00210       LPMALLOC pMalloc;
00211       CoGetMalloc(1, &pMalloc);
00212       pMalloc->Free(pwsz);
00213       pMalloc->Release();
00214     }
00215   }
00216
00217   return hr;
00218 }
00219
00220 /**************************************************************************
00221
00222   COleDocument::AddRef
00223
00224 **************************************************************************/
00225
00226 STDMETHODIMP_(DWORD) COleDocument::AddRef()
00227 {
00228   //OutputDebugString("COleDocument::AddRef\n");
00229   TCHAR szText[MAX_PATH];
00230   wsprintf(szText, TEXT("COleDocument::AddRef - ref count will be %d\n"), m_ObjRefCount + 1);
00231   OutputDebugString(szText);
00232
00233   return ++m_ObjRefCount;
00234 }
00235
00236
00237 /**************************************************************************
00238
00239   COleDocument::Release
00240
00241 **************************************************************************/
00242
00243 STDMETHODIMP_(DWORD) COleDocument::Release()
00244 {
00245   //OutputDebugString("COleDocument::Release\n");
00246   TCHAR szText[MAX_PATH];
00247   wsprintf(szText, TEXT("COleDocument::Release - ref count will be %d\n"), m_ObjRefCount - 1);
00248   OutputDebugString(szText);
00249
00250   if(0 == --m_ObjRefCount)
00251   {
00252     delete this;
00253     return 0;
00254   }
00255
00256   return m_ObjRefCount;
00257 }
00258
00259 /**************************************************************************
00260
00261   COleDocument::CreateView()
00262
00263 **************************************************************************/
00264
00265 STDMETHODIMP COleDocument::CreateView( IOleInPlaceSite *pInPlaceSite,
00266                     IStream *pStream,
00267                     DWORD dwReserved,
00268                     IOleDocumentView **ppOleDocumentView)
00269 {
00270   UNREFERENCED_PARAMETER(dwReserved);
00271   OutputDebugString(TEXT("COleDocument::CreateView\n"));
00272
00273   HRESULT  hr = E_FAIL;
00274
00275   //NULL the view pointer
00276   *ppOleDocumentView = NULL;
00277
00278   //we only support one view, so fail if the view already exists
00279   if(!m_fCreated)
00280   {
00281     //AddRef since we are giving away the pointer
00282     m_pOleDocView->AddRef();
00283
00284     // if we were given a site, set this as the site for the view we just created
00285     if(pInPlaceSite)
00286     {
00287       m_pOleDocView->SetInPlaceSite(pInPlaceSite);
00288     }
00289
00290     // if given a stream to initialize from, initialize our view state
00291     if(pStream)
00292     {
00293       m_pOleDocView->ApplyViewState(pStream);
00294     }
00295
00296     *ppOleDocumentView = m_pOleDocView;
00297
00298     m_fCreated = TRUE;
00299
00300     hr = S_OK;
00301   }
00302
00303   return hr;
00304 }
00305
00306 /**************************************************************************
00307
00308   COleDocument::GetDocMiscStatus()
00309
00310 **************************************************************************/
00311
00312 STDMETHODIMP COleDocument::GetDocMiscStatus(DWORD *pdwStatus)
00313 {
00314   OutputDebugString(TEXT("COleDocument::GetDocMiscStatus\n"));
00315
00316   if(!pdwStatus)
00317     return E_INVALIDARG;
00318
00319   *pdwStatus = 0;
00320
00321   return S_OK;
00322 }
00323
00324 /**************************************************************************
00325
00326   COleDocument::EnumViews()
00327
00328 **************************************************************************/
00329
00330 STDMETHODIMP COleDocument::EnumViews(  IEnumOleDocumentViews **ppEnum,
00331                    IOleDocumentView **ppView)
00332 {
00333   OutputDebugString(TEXT("COleDocument::EnumViews\n"));
00334
00335   *ppEnum = NULL;
00336   *ppView = NULL;
00337
00338   return E_NOTIMPL;
00339 }
00340
00341 /**************************************************************************
00342
00343   COleDocument::GetWindow()
00344
00345 **************************************************************************/
00346
00347 STDMETHODIMP COleDocument::GetWindow(HWND *phwnd)
00348 {
00349   OutputDebugString(TEXT("COleDocument::GetWindow\n"));
00350
00351   if(!phwnd)
00352     return E_INVALIDARG;
00353
00354   *phwnd = NULL;
00355
00356   if(m_pOleDocView)
00357     *phwnd = m_pOleDocView->m_hwndView;
00358
00359   return S_OK;
00360 }
00361
00362 /**************************************************************************
00363
00364   COleDocument::UIDeactivate()
00365
00366 **************************************************************************/
00367
00368 STDMETHODIMP COleDocument::DeactivateUI()
00369 {
00370   OutputDebugString(TEXT("COleInPlaceObject::DeactivateUI\n"));
00371
00372   if(m_pOleDocView)
00373     return m_pOleDocView->DeactivateUI();
00374
00375   return E_FAIL;
00376 }
00377
00378 /**************************************************************************
00379
00380   COleDocumentView::DeactivateInPlace()
00381
00382 **************************************************************************/
00383
00384 STDMETHODIMP COleDocument::DeactivateInPlace()
00385 {
00386   OutputDebugString(TEXT("COleDocument::DeactivateInPlace\n"));
00387
00388   if(m_pOleDocView)
00389     return m_pOleDocView->DeactivateInPlace();
00390
00391   return E_FAIL;
00392 }
00393
00394 /**************************************************************************
00395
00396   COleDocument::RegisterServer
00397
00398 **************************************************************************/
00399
00400 typedef struct{
00401   HKEY  hRootKey;
00402   TCHAR szSubKey[MAX_PATH];
00403   TCHAR szValue[MAX_PATH];
00404 }DOREGSTRUCT, *LPDOREGSTRUCT;
00405
00406 BOOL COleDocument::RegisterServer(void)
00407 {
00408   OutputDebugString("COleDocument::RegisterServer\n");
00409
00410   int      i;
00411   HKEY     hKey;
00412   LRESULT  lResult;
00413   DWORD    dwDisp;
00414   TCHAR    szSubKey[MAX_PATH];
00415   TCHAR    szCLSID[MAX_PATH];
00416   TCHAR    szApp[MAX_PATH];
00417   LPWSTR   pwsz;
00418   CLSID    clsid;
00419
00420   //get this app's CLSID in string form
00421   m_pPersistStorage->GetClassID(&clsid);
00422   StringFromIID(clsid, &pwsz);
00423
00424   if(pwsz)
00425   {
00426 #ifdef UNICODE
00427     lstrcpyn(szCLSID, pwsz, sizeof(szCLSID)/sizeof(TCHAR));
00428 #else
00429     WideCharToMultiByte( CP_ACP,
00430       0,
00431       pwsz,
00432       -1,
00433       szCLSID,
00434       ARRAYSIZE(szCLSID),
00435       NULL,
00436       NULL);
00437 #endif
00438
00439     //free the string
00440     LPMALLOC pMalloc;
00441     CoGetMalloc(1, &pMalloc);
00442     pMalloc->Free(pwsz);
00443     pMalloc->Release();
00444   }
00445
00446   DWORD dwRes;
00447   PSID pEveryoneSID = NULL, pAdminSID = NULL;
00448   PACL pACL = NULL;
00449   PSECURITY_DESCRIPTOR pSD = NULL;
00450   EXPLICIT_ACCESS ea[2];
00451   SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
00452   SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY;
00453   SECURITY_ATTRIBUTES sa;
00454
00455   // Create a well-known SID for the Everyone group.
00456   if(! AllocateAndInitializeSid( &SIDAuthWorld, 1,
00457     SECURITY_WORLD_RID,
00458     0, 0, 0, 0, 0, 0, 0,
00459     &pEveryoneSID) ) {
00460       return FALSE;
00461   }
00462
00463   // Initialize an EXPLICIT_ACCESS structure for an ACE.
00464   // The ACE will allow Everyone read access to the key.
00465
00466   ZeroMemory(&ea, 2 * sizeof(EXPLICIT_ACCESS));
00467   ea[0].grfAccessPermissions = KEY_READ;
00468   ea[0].grfAccessMode = SET_ACCESS;
00469   ea[0].grfInheritance= NO_INHERITANCE;
00470   ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
00471   ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
00472   ea[0].Trustee.ptstrName  = (LPTSTR) pEveryoneSID;
00473
00474   // Create a SID for the BUILTIN\Administrators group.
00475
00476   if(! AllocateAndInitializeSid( &SIDAuthNT, 2,
00477     SECURITY_BUILTIN_DOMAIN_RID,
00478     DOMAIN_ALIAS_RID_ADMINS,
00479     0, 0, 0, 0, 0, 0,
00480     &pAdminSID) ) {
00481     goto Cleanup;
00482   }
00483
00484   // Initialize an EXPLICIT_ACCESS structure for an ACE.
00485   // The ACE will allow the Administrators group full access to the key.
00486
00487   ea[1].grfAccessPermissions = KEY_ALL_ACCESS;
00488   ea[1].grfAccessMode = SET_ACCESS;
00489   ea[1].grfInheritance= NO_INHERITANCE;
00490   ea[1].Trustee.TrusteeForm = TRUSTEE_IS_SID;
00491   ea[1].Trustee.TrusteeType = TRUSTEE_IS_GROUP;
00492   ea[1].Trustee.ptstrName  = (LPTSTR) pAdminSID;
00493
00494   // Create a new ACL that contains the new ACEs.
00495
00496   dwRes = SetEntriesInAcl(2, ea, NULL, &pACL);
00497   if (ERROR_SUCCESS != dwRes) {
00498     goto Cleanup;
00499   }
00500
00501   // Initialize a security descriptor.
00502
00503   pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
00504     SECURITY_DESCRIPTOR_MIN_LENGTH);
00505   if (pSD == NULL) {
00506     goto Cleanup;
00507   }
00508
00509   if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
00510     goto Cleanup;
00511   }
00512
00513   // Add the ACL to the security descriptor.
00514
00515   if (!SetSecurityDescriptorDacl(pSD,
00516     TRUE,     // fDaclPresent flag
00517     pACL,
00518     FALSE))   // not a default DACL
00519   {
00520     goto Cleanup;
00521   }
00522
00523   // Initialize a security attributes structure.
00524
00525   sa.nLength = sizeof (SECURITY_ATTRIBUTES);
00526   sa.lpSecurityDescriptor = pSD;
00527   sa.bInheritHandle = FALSE;
00528
00529   //get this app's path and file name
00530   GetModuleFileName(NULL, szApp, ARRAYSIZE(szApp));
00531
00532   //register the file extension entries
00533   {
00534     DOREGSTRUCT FileEntries[] = { HKEY_CLASSES_ROOT,   TEXT("%s"),                         PROG_ID,
00535       0,                   TEXT(""),                           TEXT("")};
00536
00537     for(i = 0; FileEntries[i].hRootKey; i++)
00538     {
00539       //create the sub key string - for this case, insert the file extension
00540       wsprintf(szSubKey, FileEntries[i].szSubKey, FILE_EXT);
00541
00542       lResult = RegCreateKeyEx(  FileEntries[i].hRootKey,
00543         szSubKey,
00544         0,
00545         NULL,
00546         REG_OPTION_NON_VOLATILE,
00547         KEY_WRITE,
00548         &sa,
00549         &hKey,
00550         &dwDisp);
00551
00552       if(NOERROR == lResult)
00553       {
00554         lResult = RegSetValueEx(   hKey,
00555           NULL,
00556           0,
00557           REG_SZ,
00558           (LPBYTE)FileEntries[i].szValue,
00559           lstrlen(FileEntries[i].szValue) + 1);
00560
00561         RegCloseKey(hKey);
00562       }
00563       else
00564         return FALSE;
00565     }
00566   }
00567
00568   {
00569     DOREGSTRUCT ProgEntries[] = { HKEY_CLASSES_ROOT,   TEXT("%s"),                         DOC_NAME,
00570       HKEY_CLASSES_ROOT,   TEXT("%s\\CLSID"),                  TEXT("%s"),
00571       HKEY_CLASSES_ROOT,   TEXT("%s\\DocObject"),        TEXT(""),
00572       0,                   TEXT(""),                           TEXT("")};
00573
00574     //register the ProgID entries
00575     for(i = 0; ProgEntries[i].hRootKey; i++)
00576     {
00577       //create the sub key string - for this case, insert the ProgID
00578       wsprintf(szSubKey, ProgEntries[i].szSubKey, PROG_ID);
00579
00580       lResult = RegCreateKeyEx(  ProgEntries[i].hRootKey,
00581         szSubKey,
00582         0,
00583         NULL,
00584         REG_OPTION_NON_VOLATILE,
00585         KEY_WRITE,
00586         &sa,
00587         &hKey,
00588         &dwDisp);
00589
00590       if(NOERROR == lResult)
00591       {
00592         TCHAR szValue[MAX_PATH];
00593
00594         //if necessary, create the value string
00595         wsprintf(szValue, ProgEntries[i].szValue, szCLSID);
00596
00597         lResult = RegSetValueEx(   hKey,
00598           NULL,
00599           0,
00600           REG_SZ,
00601           (LPBYTE)szValue,
00602           lstrlen(szValue) + 1);
00603
00604         RegCloseKey(hKey);
00605       }
00606       else
00607         return FALSE;
00608     }
00609   }
00610
00611   {
00612     DOREGSTRUCT ClsidEntries[] = {HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s"),                  DOC_NAME,
00613       HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\LocalServer32"),   TEXT("%s"),
00614       HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocHandler32"), TEXT("ole32.dll"),
00615       HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\DefaultIcon"),     TEXT("%s,0"),
00616       HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\DocObject"),     TEXT("0"),
00617       HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\ProgID"),      PROG_ID,
00618       0,                   TEXT(""),                           TEXT("")};
00619
00620     //register the CLSID entries
00621     for(i = 0; ClsidEntries[i].hRootKey; i++)
00622     {
00623       //create the sub key string - for this case, insert the file extension
00624       wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID);
00625
00626       lResult = RegCreateKeyEx(  ClsidEntries[i].hRootKey,
00627         szSubKey,
00628         0,
00629         NULL,
00630         REG_OPTION_NON_VOLATILE,
00631         KEY_WRITE,
00632         &sa,
00633         &hKey,
00634         &dwDisp);
00635
00636       if(NOERROR == lResult)
00637       {
00638         TCHAR szValue[MAX_PATH];
00639
00640         //if necessary, create the value string
00641         wsprintf(szValue, ClsidEntries[i].szValue, szApp);
00642
00643         lResult = RegSetValueEx(   hKey,
00644           NULL,
00645           0,
00646           REG_SZ,
00647           (LPBYTE)szValue,
00648           lstrlen(szValue) + 1);
00649
00650         RegCloseKey(hKey);
00651       }
00652       else
00653         return FALSE;
00654     }
00655   }
00656 Cleanup:
00657
00658   if (pEveryoneSID)
00659     FreeSid(pEveryoneSID);
00660   if (pAdminSID)
00661     FreeSid(pAdminSID);
00662   if (pACL)
00663     LocalFree(pACL);
00664   if (pSD)
00665     LocalFree(pSD);
00666
00667   //register the component as insertable and a document object
00668   ICatRegister   *pcr;
00669   HRESULT        hr = S_OK ;
00670
00671   CoInitialize(NULL);
00672
00673   hr = CoCreateInstance(  CLSID_StdComponentCategoriesMgr,
00674     NULL,
00675     CLSCTX_INPROC_SERVER,
00676     IID_ICatRegister,
00677     (LPVOID*)&pcr);
00678
00679   if(SUCCEEDED(hr))
00680   {
00681     CATID rgcatid[2];
00682
00683     rgcatid[0] = CATID_Insertable;
00684     rgcatid[1] = CATID_DocObject;
00685
00686     hr = pcr->RegisterClassImplCategories(clsid, 2, rgcatid);
00687
00688     pcr->Release();
00689   }
00690
00691   CoUninitialize();
00692
00693
00694
00695   return SUCCEEDED(hr);
00696 }
00697
00698 /**************************************************************************
00699
00700   COleDocument::CreateFile(HWND)
00701
00702   **************************************************************************/
00703
00704   BOOL COleDocument::CreateFile(HWND hwndParent)
00705   {
00706     OutputDebugString("COleDocument::CreateFile(HWND)\n");
00707
00708     OPENFILENAME   ofn;
00709     TCHAR          szFilter[MAX_PATH];
00710     TCHAR          szFile[MAX_PATH] = TEXT("");
00711     LPTSTR         pTemp;
00712
00713     //build the filter string
00714     pTemp = szFilter;
00715     lstrcpy(pTemp, DOC_NAME);
00716     pTemp += lstrlen(pTemp) + 1;
00717     lstrcpy(pTemp, TEXT("*"));
00718     lstrcat(pTemp, FILE_EXT);
00719     pTemp += lstrlen(pTemp) + 1;
00720     *pTemp = 0;
00721
00722     ZeroMemory(&ofn, sizeof(ofn));
00723     ofn.lStructSize         = sizeof(ofn);
00724     ofn.hwndOwner           = hwndParent;
00725     ofn.hInstance           = g_hInst;
00726     ofn.lpstrFilter         = szFilter;
00727     ofn.lpstrCustomFilter   = NULL;
00728     ofn.nMaxCustFilter      = 0;
00729     ofn.nFilterIndex        = 1;
00730     ofn.lpstrFile           = szFile;
00731     ofn.nMaxFile            = ARRAYSIZE(szFile);
00732     ofn.lpstrFileTitle      = NULL;
00733     ofn.nMaxFileTitle       = 0;
00734     ofn.lpstrInitialDir     = NULL;
00735     ofn.lpstrTitle          = NULL;
00736     ofn.lpTemplateName      = MAKEINTRESOURCE(IDD_COLOR_DIALOG);
00737     ofn.lpfnHook            = (LPOFNHOOKPROC)ColorHookProc;
00738     ofn.lCustData           = (DWORD)this;
00739     ofn.Flags               = OFN_EXPLORER |
00740       OFN_OVERWRITEPROMPT |
00741       OFN_HIDEREADONLY |
00742       OFN_ENABLEHOOK |
00743       OFN_ENABLETEMPLATE |
00744       0;
00745
00746     if(GetSaveFileName(&ofn))
00747     {
00748       //if the extension isn't attached, attach it
00749       pTemp = szFile + lstrlen(szFile) - 4;
00750       if(lstrcmpi(pTemp, FILE_EXT))
00751       {
00752         lstrncat(szFile, FILE_EXT, sizeof(szFile)/sizeof(TCHAR) -
00753           lstrlen(szFile));
00754       }
00755
00756       return CreateFile(szFile);
00757     }
00758
00759     return FALSE;
00760   }
00761
00762
00763   /**************************************************************************
00764
00765     COleDocument::CreateFile(LPTSTR)
00766
00767   **************************************************************************/
00768
00769   BOOL COleDocument::CreateFile(LPTSTR pszFile)
00770   {
00771     OutputDebugString("COleDocument::CreateFile(LPTSTR)\n");
00772
00773     WCHAR szwFile[MAX_PATH];
00774
00775 #ifdef UNICODE
00776     lstrcpyn(szwFile, pszFile, sizeof(szwFile)/sizeof(TCHAR));
00777 #else
00778     MultiByteToWideChar( CP_ACP,
00779       MB_PRECOMPOSED,
00780       pszFile,
00781       -1,
00782       szwFile,
00783       ARRAYSIZE(szwFile));
00784 #endif
00785
00786     m_pPersistFile->Save(szwFile, FALSE);
00787
00788     return TRUE;
00789   }
00790
00791
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ResyncEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ResyncEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ResyncEnum
00019
00020 public class ResyncEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adResyncUnderlyingValues = 1;
00023   public static final short adResyncAllValues = 2;
00024 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/adddevicedlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

adddevicedlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddDeviceDlg.h:  Header for the CAddDeviceDlg class.  This is a
00014 //                   modeless dialog class used to add device nodes.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDDEVICEDLG_
00019 #define _CLASS_ADDDEVICEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddDeviceDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddDeviceDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddDeviceDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDDEVICEDLG_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

STL_LABEL Member List

This is the complete list of members for STL_LABEL, including all inherited members.
Application | STL_LABEL
LabelType | STL_LABEL
LabelVersion | STL_LABEL
MediaID | STL_LABEL
TapeName | STL_LABEL
TimeStamp | STL_LABEL
Vendor | STL_LABEL
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/Prof.h Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

Prof.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Profiling Routines
00005
00006     FILE: Prof.h
00007
00008     PURPOSE: Routines for profiling server system services.
00009
00010     FUNCTIONS:
00011         ProfOpenLog - Opens the profile log file and prepares to
00012     take timings.
00013         ProfRecordTime - Records the time of an event.
00014         ProfCloseLog - Writes the profiling data to the file
00015     and closes it.
00016
00017     COMMENTS: These routines depend on the existence of a high-resolution
00018         performance counter.
00019 */
00020 #pragma once
00021
00022 // Maximum size for the profile log.
00023 // After the log reaches this size new entries "fall off" (threy
00024 // do not get reorded).
00025 #define PROF_LOG_MAX_SIZE (10*1024*1024)
00026
00027 // This critsec is used for mutial exclusion when generating and
00028 // writing the profiling information.  It is also accessible to
00029 // the server routines that may want to use it for syncronising
00030 // their internal operation and creation of profiling info.
00031 // The critsec can only be used between the calls to ProfOpenLog and
00032 // ProfCloseLog.
00033 extern CRITICAL_SECTION ProfCriticalSection;
00034
00035 /*
00036     FUNCTION: ProfOpenLog
00037
00038     PURPOSE: Opens the profile log file and prepares to
00039     take timings.  Also inits the mutex.
00040
00041     PARAMETERS:
00042         LogFileName - Name of the profile log file.
00043
00044     RETURN VALUE:
00045         none
00046
00047     COMMENTS:
00048
00049 */
00050 VOID ProfOpenLog(LPTSTR LogFileName);
00051
00052 /*
00053     FUNCTION: ProfRecordTime
00054
00055     PURPOSE: Creates an entry for the even with identifier id, and
00056         with message msg with a timestamp corresponding to the number of
00057         secods since the start of the program.
00058
00059     PARAMETERS:
00060         id - Id of the event.
00061         msg - Message for the event.
00062
00063     RETURN VALUE:
00064         none
00065
00066     COMMENTS:  If the maximum log size has been exceeded, no action is taken.
00067
00068 */
00069 VOID ProfRecordTime(UINT id, LPTSTR msg);
00070
00071 /*
00072     FUNCTION: ProfCloseLog
00073
00074     PURPOSE: Writes out the acumulated profile data and closes the log file.
00075         Closes the mutex.
00076
00077     PARAMETERS:
00078         none
00079
00080     RETURN VALUE:
00081         none
00082
00083     COMMENTS:
00084
00085 */
00086 VOID ProfCloseLog(VOID);
00087
00088 // end Prof.h
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/McastIP/Mcastws2.c Source File

  • NetDS
  • WinSock
  • McastIP

Mcastws2.c

Go to the documentation of this file.
00001 //
00002 // Sample: IPv4/v6 Multicasting using WSAJoinLeaf
00003 //
00004 // Files:
00005 //      mcastws2.c      - this file
00006 //      resolve.c       - common routines for name resolution
00007 //      resolve.h       - header file for common routines
00008 //
00009 // Description:
00010 //    This sample illustrates how to use the WSAJoinLeaf API for
00011 //    multicasting. This sample may be invoked as either a sender
00012 //    or a receiver. This sample works for both IPv4 and IPv6.
00013 //    The one drawback to using the WSAJoinLeaf API is that only
00014 //    a single multicast group may be joined on a socket.
00015 //
00016 // Compile:
00017 //    cl -o mcastws2.exe mcastws2.c ws2_32.lib
00018 //
00019 // Command Line:
00020 //    mcastws2.exe [-s] [-m str] [-p int] [-i str] [-b str] [-l] [-n int]
00021 //       -i addr Local address to bind to
00022 //       -j      Don't join group
00023 //       -l 0/1  Disable/enable loopback
00024 //       -m addr Multicast address to join
00025 //       -n int  Send/recv count
00026 //       -p int  Port number
00027 //       -s      Act as sender; default is receiver
00028 //       -t int  Set multicast TTL
00029 //       -z int  Buffer size (in bytes)
00030 //
00031 // NOTE:
00032 //   From Network Programming for Microsoft Windows, Second Edition
00033 //   by Anthony Jones and James Ohlund.  Copyright 2002.
00034 //   Reproduced by permission of Microsoft Press.  All rights reserved.
00035 //
00036 #include <winsock2.h>
00037 #include <ws2tcpip.h>
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040
00041 // This sample uses the new getaddrinfo/getnameinfo functions which are new to
00042 // Windows XP. To run this sample on older OSes, include the following header
00043 // file which makes it work automagically.
00044
00045 #include <wspiapi.h>
00046
00047 #include "resolve.h"
00048
00049 #define MCASTADDRV4    "234.5.6.7"
00050 #define MCASTADDRV6    "ff12::1"
00051 #define MCASTPORT      "25000"
00052 #define BUFSIZE        1024
00053 #define DEFAULT_COUNT  500
00054 #define DEFAULT_TTL    8
00055
00056 BOOL  bSender=FALSE,            // Act as as sender, default is receiver
00057       bLoopBack=FALSE,          // Enable or disable loopback
00058       bDontJoin=FALSE;          // Join the group (sender only)
00059 int   gSocketType=SOCK_DGRAM,   // datagram
00060       gProtocol=IPPROTO_UDP,    // UDP
00061       gCount=DEFAULT_COUNT,     // Number of messages to send/recv
00062       gBufferSize=BUFSIZE,      // Buffer size for send/recv
00063       gLoopBack=0,              // Enable or disable loopback
00064       gTtl=DEFAULT_TTL;         // Set multicast TTL
00065 char *gInterface=NULL,          // Local address to bind to
00066      *gMulticast=NULL,          // Multicast group to join
00067      *gPort=MCASTPORT;          // Port number to use
00068
00069 //
00070 // Function: usage
00071 //
00072 // Description:
00073 //    Display usage information.
00074 //
00075 void usage(char *progname)
00076 {
00077     fprintf(stderr, "usage: %s [-s] [-i local-addr] [-m remote-addr] [-p port-num] [-n count]\n", progname);
00078     fprintf(stderr,
00079                     "  -i addr Local address to bind to\n"
00080                     "  -j      Don't join the multicast grou\n"
00081                     "  -l 0/1  Disable/enable loopback\n"
00082                     "  -m addr Multicast address to join\n"
00083                     "  -n int  Send/recv count\n"
00084                     "  -p int  Port number\n"
00085                     "  -s      Act as sender; default is receiver\n"
00086                     "  -t int  Set multicast TTL\n"
00087                     "  -z int  Buffer size (in bytes)\n"
00088                     );
00089     ExitProcess(-1);
00090 }
00091
00092 //
00093 // Function: ValidateArgs
00094 //
00095 // Description:
00096 //    Parse the command line and setup the global variables which indicate
00097 //    how this app should run.
00098 //
00099 void ValidateArgs(int argc, char **argv)
00100 {
00101     int     i;
00102
00103     for(i=1; i < argc ;i++)
00104     {
00105         if (((argv[i][0] != '/') && (argv[i][0] != '-')) || (strlen(argv[i]) < 2))
00106             usage(argv[0]);
00107         switch(tolower(argv[i][1]))
00108         {
00109             case 'i':               // local address to bind to
00110                 if (i+1 >= argc)
00111                     usage(argv[0]);
00112                 gInterface = argv[++i];
00113                 break;
00114             case 'j':               // Don't join the multicast group
00115                 bDontJoin = TRUE;
00116                 break;
00117             case 'l':               // enable/disable loopback
00118                 if (i+1 >= argc)
00119                     usage(argv[0]);
00120                 bLoopBack = TRUE;
00121                 gLoopBack = atoi(argv[++i]);
00122                 break;
00123             case 'm':               // remote (multicast) address to connect/join to
00124                 if (i+1 >= argc)
00125                     usage(argv[0]);
00126                 gMulticast = argv[++i];
00127                 break;
00128             case 'n':               // number of sends/recvs
00129                 if (i+1 >= argc)
00130                     usage(argv[0]);
00131                 gCount = atoi(argv[++i]);
00132                 break;
00133             case 'p':               // port number
00134                 if (i+1 >= argc)
00135                     usage(argv[0]);
00136                 gPort = argv[++i];
00137                 break;
00138             case 's':               // sender or receiver
00139                 bSender = TRUE;
00140                 break;
00141             case 't':               // multicast ttl
00142                 if (i+1 >= argc)
00143                     usage(argv[0]);
00144                 gTtl = atoi(argv[++i]);
00145                 break;
00146             case 'z':               // buffer size
00147                 if (i+1 >= argc)
00148                     usage(argv[0]);
00149                 gBufferSize = atoi(argv[++i]);
00150                 break;
00151             default:
00152                 usage(argv[0]);
00153                 break;
00154         }
00155     }
00156 }
00157
00158 //
00159 // Function: SetMulticastTtl
00160 //
00161 // Description:
00162 //    This routine sets the multicast TTL value for the socket.
00163 //
00164 int SetMulticastTtl(SOCKET s, int af, int ttl)
00165 {
00166     char *optval=NULL;
00167     int   optlevel,
00168           option,
00169           optlen,
00170           rc;
00171
00172     rc = NO_ERROR;
00173     if (af == AF_INET)
00174     {
00175         // Set the options for V4
00176         optlevel = IPPROTO_IP;
00177         option   = IP_MULTICAST_TTL;
00178         optval   = (char *) &ttl;
00179         optlen   = sizeof(ttl);
00180     }
00181     else if (af == AF_INET6)
00182     {
00183         // Set the options for V6
00184         optlevel = IPPROTO_IPV6;
00185         option   = IPV6_MULTICAST_HOPS;
00186         optval   = (char *) &ttl;
00187         optlen   = sizeof(ttl);
00188     }
00189     else
00190     {
00191         fprintf(stderr, "Attemtping to set TTL for invalid address family!\n");
00192         rc = SOCKET_ERROR;
00193     }
00194     if (rc != SOCKET_ERROR)
00195     {
00196         // Set the TTL value
00197         rc = setsockopt(
00198                 s,
00199                 optlevel,
00200                 option,
00201                 optval,
00202                 optlen
00203                 );
00204         if (rc == SOCKET_ERROR)
00205         {
00206             fprintf(stderr, "SetMulticastTtl: setsockopt failed: %d\n", WSAGetLastError());
00207         }
00208         else
00209         {
00210             printf("Set multicast ttl to: %d\n", ttl);
00211         }
00212     }
00213     return rc;
00214 }
00215
00216 //
00217 // Function: SetMulticastLoopBack
00218 //
00219 // Description:
00220 //    This function enabled or disables multicast loopback. If loopback is enabled
00221 //    (and the socket is a member of the destination multicast group) then the
00222 //    data will be placed in the receive queue for the socket such that if a
00223 //    receive is posted on the socket its own data will be read. For this sample
00224 //    it doesn't really matter as if invoked as the sender, no data is read.
00225 //
00226 int SetMulticastLoopBack(SOCKET s, int af, int loopval)
00227 {
00228     char *optval=NULL;
00229     int   optlevel,
00230           option,
00231           optlen,
00232           rc;
00233
00234     rc = NO_ERROR;
00235     if (af == AF_INET)
00236     {
00237         // Set the v4 options
00238         optlevel = IPPROTO_IP;
00239         option   = IP_MULTICAST_LOOP;
00240         optval   = (char *) &loopval;
00241         optlen   = sizeof(loopval);
00242     }
00243     else if (af == AF_INET6)
00244     {
00245         // Set the v6 options
00246         optlevel = IPPROTO_IPV6;
00247         option   = IPV6_MULTICAST_LOOP;
00248         optval   = (char *) &loopval;
00249         optlen   = sizeof(loopval);
00250     }
00251     else
00252     {
00253         fprintf(stderr, "Attemtping to set multicast loopback for invalid address family!\n");
00254         rc = SOCKET_ERROR;
00255     }
00256     if (rc != SOCKET_ERROR)
00257     {
00258         // Set the multpoint loopback
00259         rc = setsockopt(
00260                 s,
00261                 optlevel,
00262                 option,
00263                 optval,
00264                 optlen
00265                 );
00266         if (rc == SOCKET_ERROR)
00267         {
00268             fprintf(stderr, "SetMulticastLoopBack: setsockopt failed: %d\n", WSAGetLastError());
00269         }
00270         else
00271         {
00272             printf("Setting multicast loopback to: %d\n", loopval);
00273         }
00274     }
00275     return rc;
00276 }
00277
00278 //
00279 // Function: SetSendInterface
00280 //
00281 // Description:
00282 //    This routine sets the send (outgoing) interface of the socket.
00283 //    Again, for v4 the IP address is used to specify the interface while
00284 //    for v6 its the scope-ID.
00285 //
00286 int SetSendInterface(SOCKET s, struct addrinfo *iface)
00287 {
00288     char *optval=NULL;
00289     int   optlevel,
00290     option,
00291     optlen,
00292     rc;
00293
00294     rc = NO_ERROR;
00295     if (iface->ai_family == AF_INET)
00296     {
00297         // Setup the v4 option values
00298         optlevel = IPPROTO_IP;
00299         option   = IP_MULTICAST_IF;
00300         optval   = (char *) &((SOCKADDR_IN *)iface->ai_addr)->sin_addr.s_addr;
00301         optlen   = sizeof(((SOCKADDR_IN *)iface->ai_addr)->sin_addr.s_addr);
00302     }
00303     else if (iface->ai_family == AF_INET6)
00304     {
00305         // Setup the v6 option values
00306         optlevel = IPPROTO_IPV6;
00307         option   = IPV6_MULTICAST_IF;
00308         optval   = (char *) &((SOCKADDR_IN6 *)iface->ai_addr)->sin6_scope_id;
00309         optlen   = sizeof(((SOCKADDR_IN6 *)iface->ai_addr)->sin6_scope_id);
00310     }
00311     else
00312     {
00313         fprintf(stderr, "Attemtping to set sent interface for invalid address family!\n");
00314         rc = SOCKET_ERROR;
00315     }
00316     // Set send IF
00317     if (rc != SOCKET_ERROR)
00318     {
00319         // Set the send interface
00320         rc = setsockopt(
00321                 s,
00322                 optlevel,
00323                 option,
00324                 optval,
00325                 optlen
00326                 );
00327         if (rc == SOCKET_ERROR)
00328         {
00329             fprintf(stderr, "setsockopt failed: %d\n", WSAGetLastError());
00330         }
00331         else
00332         {
00333             printf("Set sending interface to: ");
00334             PrintAddress(iface->ai_addr, iface->ai_addrlen);
00335             printf("\n");
00336         }
00337     }
00338     return rc;
00339 }
00340
00341
00342 //
00343 // Function: main
00344 //
00345 // Description:
00346 //    Parse the command line arguments, load the Winsock library,
00347 //    create a socket and join the multicast group. If set as a
00348 //    sender then begin sending messages to the multicast group;
00349 //    otherwise, call recvfrom() to read messages send to the
00350 //    group.
00351 //
00352 int __cdecl main(int argc, char **argv)
00353 {
00354     WSADATA             wsd;
00355     struct addrinfo    *reslocal = NULL,
00356                        *resmulti = NULL;
00357     SOCKET              s = INVALID_SOCKET,
00358                         rs= INVALID_SOCKET;
00359     char               *buf=NULL;
00360     int                 rc,
00361                         i;
00362
00363     ValidateArgs(argc, argv);
00364
00365     if ((rc = WSAStartup(MAKEWORD(2,2), &wsd)) != 0)
00366     {
00367         fprintf(stderr, "WSAStartup failed: %d\n", rc);
00368         return -1;
00369     }
00370
00371     //
00372     // resolve the local interface first
00373     //
00374     reslocal = ResolveAddress(gInterface, (bSender ? "0": gPort), AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP);
00375     if (reslocal == NULL)
00376     {
00377         fprintf(stderr, "Unable to resolve local interface: %s\n", gInterface);
00378         goto cleanup;
00379     }
00380
00381     if (gMulticast == NULL)
00382     {
00383         if (reslocal->ai_family == AF_INET)
00384             gMulticast = MCASTADDRV4;
00385         else if (reslocal->ai_family == AF_INET6)
00386             gMulticast = MCASTADDRV6;
00387     }
00388
00389     // Create the socket - remember to specify the multicast flags
00390     s = WSASocket(
00391             reslocal->ai_family,
00392             reslocal->ai_socktype,
00393             reslocal->ai_protocol,
00394             NULL,
00395             0,
00396             WSA_FLAG_OVERLAPPED | WSA_FLAG_MULTIPOINT_C_LEAF | WSA_FLAG_MULTIPOINT_D_LEAF
00397             );
00398     if (s == INVALID_SOCKET)
00399     {
00400         fprintf(stderr, "socket(af = %d) failed: %d\n", reslocal->ai_family, WSAGetLastError());
00401         goto cleanup;
00402     }
00403
00404     rc = bind(s, reslocal->ai_addr, reslocal->ai_addrlen);
00405     if (rc == SOCKET_ERROR)
00406     {
00407         fprintf(stderr, "bind failed: %d\n", WSAGetLastError());
00408         goto cleanup;
00409     }
00410
00411     printf("bound to: ");
00412     PrintAddress(reslocal->ai_addr, reslocal->ai_addrlen);
00413     printf("\n");
00414
00415     // Resolve the multicast address
00416     resmulti = ResolveAddress(gMulticast, gPort, reslocal->ai_family, reslocal->ai_socktype, reslocal->ai_protocol);
00417     if (resmulti == NULL)
00418     {
00419         fprintf(stderr, "Unable to resolve multicast address: %s\n", gMulticast);
00420         goto cleanup;
00421     }
00422
00423     // Set the multicast TTL
00424     rc = SetMulticastTtl(s, resmulti->ai_family, gTtl);
00425     if (rc == SOCKET_ERROR)
00426     {
00427         fprintf(stderr, "Unable to set multicast TTL\n");
00428         goto cleanup;
00429     }
00430
00431     // Set the loopback value if indicated
00432     if (bLoopBack)
00433     {
00434         rc = SetMulticastLoopBack(s, resmulti->ai_family, gLoopBack);
00435         if (rc == SOCKET_ERROR)
00436         {
00437             fprintf(stderr, "Unable to set multicast loopback flag\n");
00438             goto cleanup;
00439         }
00440     }
00441
00442     // If the don't join option is set then just connect the socket
00443     if (bDontJoin == FALSE)
00444     {
00445         rs = WSAJoinLeaf(
00446                 s,
00447                 resmulti->ai_addr,
00448                 resmulti->ai_addrlen,
00449                 NULL,
00450                 NULL,
00451                 NULL,
00452                 NULL,
00453                 (bSender ? JL_SENDER_ONLY : JL_RECEIVER_ONLY)
00454                         );
00455         if (rs == INVALID_SOCKET)
00456         {
00457             fprintf(stderr, "WSAJoinLeaf failed: %d\n", WSAGetLastError());
00458             goto cleanup;
00459         }
00460     }
00461     else
00462     {
00463         rc = SetSendInterface(s, reslocal);
00464         if (rc == SOCKET_ERROR)
00465         {
00466             fprintf(stderr, "Unable to set outgoing multicast interface\n");
00467             goto cleanup;
00468         }
00469
00470         rc = connect(
00471                 s,
00472                 resmulti->ai_addr,
00473                 resmulti->ai_addrlen
00474                 );
00475         if (rc == SOCKET_ERROR)
00476         {
00477             fprintf(stderr, "conect failed: %d\n", WSAGetLastError());
00478             goto cleanup;
00479         }
00480     }
00481
00482     printf("joining group: ");
00483     PrintAddress(resmulti->ai_addr, resmulti->ai_addrlen);
00484     printf("\n");
00485
00486     // Don't need these anymore
00487     freeaddrinfo(reslocal);
00488     reslocal = NULL;
00489
00490     freeaddrinfo(resmulti);
00491     resmulti = NULL;
00492
00493     // Allocate the send/recv buffer
00494     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, gBufferSize);
00495     if (buf == NULL)
00496     {
00497         fprintf(stderr, "HeapAlloc failed: %d\n", GetLastError());
00498         goto cleanup;
00499     }
00500     memset(buf, '%', gBufferSize);
00501
00502     if (bSender)
00503     {
00504         for(i=0; i < gCount ;i++)
00505         {
00506             rc = send(s, buf, gBufferSize, 0);
00507             if (rc == SOCKET_ERROR)
00508             {
00509                 fprintf(stderr, "send failed: %d\n", WSAGetLastError());
00510                 break;
00511             }
00512             else
00513             {
00514                 printf("wrote %d bytes\n", rc);
00515             }
00516         }
00517     }
00518     else
00519     {
00520         for(i=0; i < gCount ;i++)
00521         {
00522             rc = recv(s, buf, gBufferSize, 0);
00523             if (rc == SOCKET_ERROR)
00524             {
00525                 fprintf(stderr, "recv failed: %d\n", rc);
00526                 break;
00527             }
00528             else
00529             {
00530                 printf("read %d bytes\n", rc);
00531             }
00532         }
00533     }
00534
00535 cleanup:
00536
00537     //
00538     // Cleanup allocations and sockets as necessary
00539     //
00540
00541     if (buf)
00542         HeapFree(GetProcessHeap(), 0, buf);
00543
00544     if (s != INVALID_SOCKET)
00545         closesocket(s);
00546
00547     if (reslocal)
00548         freeaddrinfo(reslocal);
00549
00550     if (resmulti)
00551         freeaddrinfo(resmulti);
00552
00553     WSACleanup();
00554     return 0;
00555 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenuex/registry.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenuex

registry.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef __Registry_H__
00015 #define __Registry_H__
00016
00017 #include <tchar.h>
00018
00019 // This function will register a component in the Registry.
00020 // The component calls this function from its DllRegisterServer function.
00021 HRESULT RegisterServer( HMODULE hModule,
00022                         const CLSID& clsid,
00023                         const TCHAR* szFriendlyName) ;
00024
00025 // This function will unregister a component.  Components
00026 // call this function from their DllUnregisterServer function.
00027 HRESULT UnregisterServer( const CLSID& clsid ) ;
00028
00029
00030 // This function will register a Snap-In component.  Components
00031 // call this function from their DllRegisterServer function.
00032 HRESULT RegisterSnapin( const CLSID& clsid,            // Class ID
00033                         const TCHAR* szNameString,     // NameString
00034                         const CLSID& clsidAbout,       // Class Id for About Class
00035                         const BOOL fSupportExtensions = FALSE
00036                       );
00037
00038 HRESULT UnregisterSnapin( const CLSID& clsid );        // Class ID
00039
00040 #endif //__Registry_H__
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/SmpFilt/FiltReg.Hxx Source File

  • WinBase
  • Indexing
  • SmpFilt

FiltReg.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (c) Microsoft Corporation. All rights reserved.
00005 //
00006 // File:        RegSrv.hxx
00007 //
00008 // Contents:    Macros for Self-registration of Filters
00009 //
00010 // Functions:   Macros to create DllRegisterServer, DllUnregisterServer
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #pragma once
00015
00016 #include <olectl.h>
00017
00018 //
00019 // Structure to define classes (.doc, .xls, etc.)
00020 //
00021
00022 struct SClassEntry
00023 {
00024     WCHAR const * pwszExt;                  // (ex: .doc)  May be null
00025     WCHAR const * pwszShortName;            // (ex: Word.Document.8)
00026     WCHAR const * pwszDescription;          // (ex: Microsoft Word Document)
00027     WCHAR const * pwszClassId;              // (ex: {00020906-0000-0000-C000-000000000046})
00028     WCHAR const * pwszClassIdDescription;   // (ex: Microsoft Word Document)
00029 };
00030
00031 //
00032 // Structure to define persistent handler entry.
00033 //
00034
00035 struct SHandlerEntry
00036 {
00037     WCHAR const * pwszClassId;
00038     WCHAR const * pwszClassIdDescription;
00039     WCHAR const * pwszClassIdFilter;
00040 };
00041
00042 //
00043 // Structure to define filter class
00044 //
00045
00046 struct SFilterEntry
00047 {
00048     WCHAR const * pwszClassId;
00049     WCHAR const * pwszClassIdDescription;
00050     WCHAR const * pwszDLL;
00051     WCHAR const * pwszThreadingModel;
00052 };
00053
00054 //
00055 // Sample use of the three structures
00056 //
00057 //
00058 // SClassEntry const aClasses[] = { { L".doc", L"Word.Document.8",
00059 //                                    L"Microsoft Word Document",
00060 //                                    L"{00020906-0000-0000-C000-000000000046}",
00061 //                                    L"Microsoft Word Document" },
00062 //
00063 //                                  { 0, L"Word.Document.6",
00064 //                                    L"Microsoft Word 6.0 - 7.0 Document",
00065 //                                    L"{00020900-0000-0000-C000-000000000046}",
00066 //                                    L"Microsoft Word 6.0 - 7.0 Document" }
00067 //                                };
00068 //
00069 // SHandlerEntry const OfficeHandler = { L"{98de59a0-d175-11cd-a7bd-00006b827d94}",
00070 //                                       L"Microsoft Office Persistent Handler",
00071 //                                       L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}" };
00072 //
00073 // SFilterEntry const OfficeFilter = { L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}",
00074 //                                     L"Microsoft Office Filter",
00075 //                                     L"OffFilt.dll",
00076 //                                     0 };
00077 //
00078
00079 //
00080 // Function prototypes
00081 //
00082
00083 inline long RegisterACLSID( SClassEntry const & Class,
00084                             WCHAR const * pwszPHandler,
00085                             WCHAR const * pwszClassId = 0,
00086                             BOOL fAppendOnly = FALSE,
00087                             BOOL fAppendDesc = TRUE );
00088
00089 inline long RegisterAClass( SClassEntry const & Class,
00090                             WCHAR const * pwszPHandler,
00091                             WCHAR const * pwszShortName = 0,
00092                             BOOL fAppendOnly = FALSE );
00093
00094 inline long RegisterAClassAndExt( SClassEntry const & Class,
00095                                   WCHAR const * pwszPHandler,
00096                                   BOOL fAppendOnly = FALSE,
00097                                   BOOL fBlastExistingPersistentHandler = TRUE );
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 //  Function:   BuildKeyValues, private
00102 //
00103 //  Effects:    Given array of key, value, key, value, ... adds the entries
00104 //              under CLSID as:
00105 //
00106 //                  Key1 : <NO NAME> Value1
00107 //                    Key2 : <NO NAME> Value2
00108 //                      :
00109 //                      :
00110 //
00111 //  Arguments:  [awszKeyValues] -- Keys and values
00112 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00113 //
00114 //  Returns:    ERROR_SUCCESS on success
00115 //
00116 //  Notes:      The *value* entries can be null, signifying no value at a
00117 //              given level.
00118 //
00119 //----------------------------------------------------------------------------
00120
00121 inline long BuildKeyValues( WCHAR const * const * awszKeyValues, unsigned cKeyValues )
00122 {
00123     WCHAR wcTemp[MAX_PATH];
00124     wcscpy( wcTemp, L"CLSID" );
00125
00126     long dwError;
00127     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00128     unsigned i = 0;
00129
00130     do
00131     {
00132         if ( INVALID_HANDLE_VALUE != hKey )
00133         {
00134             RegCloseKey( hKey );
00135             hKey = (HKEY)INVALID_HANDLE_VALUE;
00136         }
00137
00138         wcscat( wcTemp, L"\\" );
00139         wcscat( wcTemp, awszKeyValues[i] );
00140
00141         DWORD  dwDisposition;
00142
00143         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00144                                    wcTemp,               // Sub key
00145                                    0,                    // Reserved
00146                                    0,                    // Class
00147                                    0,                    // Flags
00148                                    KEY_ALL_ACCESS,       // Access
00149                                    0,                    // Security
00150                                    &hKey,                // Handle
00151                                    &dwDisposition );     // Disposition
00152
00153         if ( ERROR_SUCCESS != dwError )
00154             break;
00155
00156         i++;
00157
00158         if ( 0 != awszKeyValues[i] )
00159             dwError = RegSetValueExW( hKey,                     // Key
00160                                       0,                        // Name
00161                                       0,                        // Reserved
00162                                       REG_SZ,                   // Type
00163                                       (BYTE *)awszKeyValues[i], // Value
00164                                       (DWORD) ( (1 + wcslen(awszKeyValues[i]) ) * sizeof(WCHAR) ) );
00165
00166         if ( ERROR_SUCCESS != dwError )
00167             break;
00168
00169         i++;
00170     }
00171     while ( i < cKeyValues );
00172
00173     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00174         RegCloseKey( hKey );
00175
00176     return dwError;
00177 }
00178
00179 //+---------------------------------------------------------------------------
00180 //
00181 //  Function:   AddThreadingModel
00182 //
00183 //  Synopsis:   Adds the threading model value to the CLSID\\GUID\\InProcServer32
00184 //              key
00185 //
00186 //  Arguments:  [wszClsId] - ClassId of the inproc server.
00187 //              [wszThreadingModel] -- 0 (for single threaded) or one of
00188 //                                     Apartment, Free, or Both
00189 //
00190 //  History:    3-07-97   srikants   Created
00191 //
00192 //----------------------------------------------------------------------------
00193
00194 inline long AddThreadingModel( WCHAR const * wszClsId,
00195                                WCHAR const * wszThreadingModel )
00196 {
00197     WCHAR wcTemp[MAX_PATH];
00198     wcscpy( wcTemp, L"CLSID" );
00199     wcscat( wcTemp, L"\\" );
00200     wcscat( wcTemp, wszClsId );
00201     wcscat( wcTemp, L"\\" );
00202     wcscat( wcTemp, L"InprocServer32" );
00203
00204     long dwError;
00205     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00206     unsigned i = 0;
00207
00208     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00209                              wcTemp,               // Sub key
00210                              0,                    // Reserved
00211                              KEY_ALL_ACCESS,       // Access
00212                              &hKey );              // Handle
00213
00214     if ( ERROR_SUCCESS != dwError )
00215         return dwError;
00216
00217     if ( 0 != wszThreadingModel )
00218         dwError = RegSetValueExW( hKey,                   // Key
00219                                   L"ThreadingModel",      // Name
00220                                   0,                      // Reserved
00221                                   REG_SZ,                 // Type
00222                                   (BYTE *) wszThreadingModel,  // Value
00223                                   (DWORD) ( (wcslen(wszThreadingModel) + 1) * sizeof WCHAR ) );
00224     else
00225         RegDeleteValueW( hKey,                   // Key
00226                          L"ThreadingModel" );    // Name
00227
00228     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00229         RegCloseKey( hKey );
00230
00231     return dwError;
00232 }
00233
00234 //+---------------------------------------------------------------------------
00235 //
00236 //  Function:   DestroyKeyValues, private
00237 //
00238 //  Effects:    Given array of key, value, key, value from AddKeyValues,
00239 //              removes the keys.
00240 //
00241 //  Arguments:  [awszKeyValues] -- Keys and values
00242 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00243 //
00244 //  Returns:    ERROR_SUCCESS on success
00245 //
00246 //----------------------------------------------------------------------------
00247
00248 inline long DestroyKeyValues( WCHAR const * const * awszKeyValues, int cKeyValues )
00249 {
00250     WCHAR wcTemp[MAX_PATH];
00251
00252     //
00253     // Build path to deepest component
00254     //
00255
00256     wcscpy( wcTemp, L"CLSID" );
00257     int i = 0;
00258
00259     do
00260     {
00261         wcscat( wcTemp, L"\\" );
00262         wcscat( wcTemp, awszKeyValues[i] );
00263
00264         i += 2;
00265     }
00266     while ( i < cKeyValues );
00267
00268     //
00269     // Remove components in reverse order
00270     //
00271
00272     long dwError = ERROR_SUCCESS;
00273     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00274
00275     unsigned cc = (unsigned) wcslen( wcTemp );
00276
00277     for ( i -= 2; i >= 0; i -= 2 )
00278     {
00279         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00280                                  wcTemp,               // Sub key
00281                                  0,                    // Reserved
00282                                  KEY_ALL_ACCESS,       // Access
00283                                  &hKey );              // Handle
00284
00285         if ( ERROR_SUCCESS != dwError )
00286             break;
00287
00288         #if 0  // Values deleted by RegDeleteKeyW
00289         //
00290         // Delete value, if there is one.
00291         //
00292
00293         if ( 0 != awszKeyValues[i+1] )
00294             dwError = RegDeleteValueW( hKey, 0 );
00295
00296         if ( ERROR_SUCCESS != dwError )
00297             break;
00298         #endif // 0
00299
00300         //
00301         // Delete subkey, if there is one.
00302         //
00303
00304         if ( i+2 < cKeyValues )
00305             dwError = RegDeleteKeyW( hKey, awszKeyValues[i+2] );
00306
00307         if ( ERROR_SUCCESS != dwError )
00308             break;
00309
00310         //
00311         // Close key and truncate string to next component.
00312         //
00313
00314         if ( INVALID_HANDLE_VALUE != hKey )
00315         {
00316             RegCloseKey( hKey );
00317             hKey = (HKEY)INVALID_HANDLE_VALUE;
00318         }
00319
00320         cc -= (unsigned) wcslen( awszKeyValues[i] );
00321         cc--;
00322
00323         wcTemp[cc] = 0;
00324     }
00325
00326     //
00327     // Remove the final top key
00328     //
00329
00330     if ( ERROR_SUCCESS == dwError )
00331     {
00332         do
00333         {
00334             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00335                                      wcTemp,               // Sub key -- "CLSID"
00336                                      0,                    // Reserved
00337                                      KEY_ALL_ACCESS,       // Access
00338                                      &hKey );              // Handle
00339
00340             if ( ERROR_SUCCESS != dwError )
00341                 break;
00342
00343             //
00344             // Delete subkey
00345             //
00346
00347             dwError = RegDeleteKeyW( hKey, awszKeyValues[0] );
00348
00349         } while ( FALSE );
00350     }
00351
00352     return dwError;
00353 }
00354
00355 //+---------------------------------------------------------------------------
00356 //
00357 //  Function:   RegisterAClassAndExt, private
00358 //
00359 //  Synopsis:   Registers a class, extensions (optional) and a persistent handler.
00360 //
00361 //  Arguments:  [Class]        -- Class description
00362 //              [pwszPHandler] -- Persistent handler for class
00363 //
00364 //  Returns:    ERROR_SUCCESS on success
00365 //
00366 //  Notes:      Class is only registered if similar class does not already
00367 //              exist.  Persistent handler is always registered for class.
00368 //
00369 //----------------------------------------------------------------------------
00370
00371 inline long RegisterAClassAndExt( SClassEntry const & Class,
00372                                   WCHAR const * pwszPHandler,
00373                                   BOOL fAppendOnly,
00374                                   BOOL fBlastExistingPersistentHandler )
00375 {
00376     WCHAR wcTemp[MAX_PATH];
00377
00378     long dwError = NO_ERROR;
00379     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00380
00381     do
00382     {
00383         //
00384         // First, the optional extension entry
00385         //
00386
00387         DWORD dwDisposition;
00388         DWORD dwType;
00389         DWORD dwSize;
00390
00391         if ( 0 == Class.pwszExt )
00392         {
00393             //
00394             // Build up named entry
00395             //
00396
00397             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00398                 return ERROR_INSUFFICIENT_BUFFER;
00399
00400             wcscpy( wcTemp, Class.pwszShortName );
00401         }
00402         else
00403         {
00404             if ( wcslen( Class.pwszExt ) >= MAX_PATH )
00405                 return ERROR_INSUFFICIENT_BUFFER;
00406
00407             wcscpy( wcTemp, Class.pwszExt );
00408
00409             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00410                                        wcTemp,               // Sub key
00411                                        0,                    // Reserved
00412                                        0,                    // Class
00413                                        0,                    // Flags
00414                                        KEY_ALL_ACCESS,       // Access
00415                                        0,                    // Security
00416                                        &hKey,                // Handle
00417                                        &dwDisposition );     // Disposition
00418             if ( ERROR_SUCCESS != dwError )
00419                 break;
00420
00421             //
00422             // Write or read class association
00423             //
00424
00425             BOOL fSetValue = TRUE;
00426
00427             if ( REG_OPENED_EXISTING_KEY == dwDisposition )
00428             {
00429                 dwSize = sizeof(wcTemp);
00430
00431                 dwError = RegQueryValueExW( hKey,            // Key handle
00432                                             0,               // Name
00433                                             0,               // Reserved
00434                                             &dwType,         // Datatype
00435                                             (BYTE *)wcTemp,  // Data returned here
00436                                             &dwSize );       // Size of data
00437
00438                 if ( ERROR_SUCCESS == dwError )
00439                 {
00440                     fSetValue = FALSE;
00441
00442                     if ( REG_SZ != dwType )
00443                         dwError = E_FAIL;
00444                 }
00445                 else if ( ERROR_FILE_NOT_FOUND == dwError )
00446                 {
00447                     //
00448                     // This is ok, but we need to remember that the
00449                     // combination of wcTemp[0] == 0 && fAppendOnly means
00450                     // don't try to register the class.
00451                     //
00452
00453                     wcTemp[0] = 0;
00454                     dwError = ERROR_SUCCESS;
00455                 }
00456             }
00457
00458             if ( fSetValue && !fAppendOnly )
00459             {
00460                 dwError = RegSetValueExW( hKey,                        // Key
00461                                           0,                           // Name
00462                                           0,                           // Reserved
00463                                           REG_SZ,                      // Type
00464                                           (BYTE *)Class.pwszShortName, // Value
00465                                           (DWORD) ( (1 + wcslen(Class.pwszShortName) ) * sizeof(WCHAR) ) );
00466
00467                 wcTemp[0] = 0;
00468             }
00469
00470             if ( ERROR_SUCCESS != dwError )
00471                 break;
00472
00473             //
00474             // Write the persistent handler key
00475             //
00476
00477             HKEY hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00478
00479             dwError = RegCreateKeyExW( hKey,                 // Root
00480                                        L"PersistentHandler", // Sub key
00481                                        0,                    // Reserved
00482                                        0,                    // Class
00483                                        0,                    // Flags
00484                                        KEY_ALL_ACCESS,       // Access
00485                                        0,                    // Security
00486                                        &hKey2,               // Handle
00487                                        &dwDisposition );     // Disposition
00488
00489             if ( ERROR_SUCCESS != dwError )
00490                 break;
00491
00492             if ( fBlastExistingPersistentHandler ||
00493                  ( REG_OPENED_EXISTING_KEY != dwDisposition ) )
00494                 dwError = RegSetValueExW( hKey2,                 // Key
00495                                           0,                     // Name
00496                                           0,                     // Reserved
00497                                           REG_SZ,                // Type
00498                                           (BYTE *)pwszPHandler,  // Value
00499                                           (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00500
00501             if ( (HKEY)INVALID_HANDLE_VALUE != hKey2 )
00502             {
00503                 RegCloseKey( hKey2 );
00504                 hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00505             }
00506         }
00507
00508         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00509         {
00510             RegCloseKey( hKey );
00511             hKey = (HKEY)INVALID_HANDLE_VALUE;
00512         }
00513
00514         if ( ERROR_SUCCESS != dwError )
00515             break;
00516
00517         //
00518         // Here, wcTemp may contain the key name for the named entry (ex: Word.Document.8)
00519         //
00520
00521         if ( wcTemp[0] != 0 || !fAppendOnly )
00522             dwError = RegisterAClass( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00523
00524     } while( FALSE );
00525
00526     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00527     {
00528         RegCloseKey( hKey );
00529         hKey = (HKEY)INVALID_HANDLE_VALUE;
00530     }
00531
00532     return dwError;
00533 }
00534
00535 //+---------------------------------------------------------------------------
00536 //
00537 //  Function:   RegisterAClass, private
00538 //
00539 //  Synopsis:   Registers a class and a persistent handler.
00540 //
00541 //  Arguments:  [Class]        -- Class description
00542 //              [pwszPHandler] -- Persistent handler for class
00543 //              [pwszClass]    -- If non 0, used instead of class from [Class]
00544 //
00545 //  Returns:    ERROR_SUCCESS on success
00546 //
00547 //  Notes:      Class is only registered if similar class does not already
00548 //              exist.  Persistent handler is always registered for class.
00549 //
00550 //----------------------------------------------------------------------------
00551
00552 inline long RegisterAClass( SClassEntry const & Class,
00553                             WCHAR const * pwszPHandler,
00554                             WCHAR const * pwszShortName,
00555                             BOOL fAppendOnly )
00556 {
00557     WCHAR wcTemp[MAX_PATH];
00558
00559     long dwError;
00560     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00561
00562     if ( 0 == pwszShortName )
00563     {
00564         if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00565             return ERROR_INSUFFICIENT_BUFFER;
00566
00567         wcscpy( wcTemp, Class.pwszShortName );
00568     }
00569     else
00570     {
00571         if ( wcslen( pwszShortName ) >= MAX_PATH )
00572             return ERROR_INSUFFICIENT_BUFFER;
00573
00574         wcscpy( wcTemp, pwszShortName );
00575     }
00576
00577     do
00578     {
00579         DWORD dwDisposition;
00580         DWORD dwType;
00581         DWORD dwSize;
00582
00583         //
00584         // Here, wcTemp contains the key name for the named entry (ex: Word.Document.8)
00585         //
00586
00587         if ( fAppendOnly )
00588         {
00589             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00590                                      wcTemp,               // Sub key
00591                                      0,                    // Reserved
00592                                      KEY_ALL_ACCESS,       // Access
00593                                      &hKey );              // Handle
00594
00595             if ( ERROR_SUCCESS != dwError)
00596             {
00597                 //
00598                 // Not opening the key at all is legit.
00599                 //
00600
00601                 if ( ERROR_FILE_NOT_FOUND == dwError )
00602                     dwError = ERROR_SUCCESS;
00603
00604                 break;
00605             }
00606
00607             dwDisposition = REG_OPENED_EXISTING_KEY;
00608         }
00609         else
00610         {
00611             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00612                                        wcTemp,               // Sub key
00613                                        0,                    // Reserved
00614                                        0,                    // Class
00615                                        0,                    // Flags
00616                                        KEY_ALL_ACCESS,       // Access
00617                                        0,                    // Security
00618                                        &hKey,                // Handle
00619                                        &dwDisposition );     // Disposition
00620
00621             if ( ERROR_SUCCESS != dwError )
00622                 break;
00623         }
00624
00625         //
00626         // If needed, write the description, but only for non-overrides.
00627         //
00628
00629         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszShortName )
00630         {
00631             dwError = RegSetValueExW( hKey,                          // Key
00632                                       0,                             // Name
00633                                       0,                             // Reserved
00634                                       REG_SZ,                        // Type
00635                                       (BYTE *)Class.pwszDescription, // Value
00636                                       (DWORD) ( (1 + wcslen(Class.pwszDescription) ) * sizeof(WCHAR) ) );
00637
00638             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00639                 return ERROR_INSUFFICIENT_BUFFER;
00640
00641             wcscpy( wcTemp, Class.pwszShortName );
00642
00643             if ( ERROR_SUCCESS != dwError )
00644                 break;
00645         }
00646
00647         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00648         {
00649             RegCloseKey( hKey );
00650             hKey = (HKEY)INVALID_HANDLE_VALUE;
00651         }
00652
00653         //
00654         // Write or read ClassId
00655         //
00656
00657         wcscat( wcTemp, L"\\CLSID" );
00658
00659         if ( fAppendOnly )
00660         {
00661             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00662                                      wcTemp,               // Sub key
00663                                      0,                    // Reserved
00664                                      KEY_ALL_ACCESS,       // Access
00665                                      &hKey );              // Handle
00666
00667             if ( ERROR_SUCCESS != dwError)
00668             {
00669                 //
00670                 // Not opening the key at all is legit.
00671                 //
00672
00673                 if ( ERROR_FILE_NOT_FOUND == dwError )
00674                     dwError = ERROR_SUCCESS;
00675
00676                 break;
00677             }
00678
00679             dwDisposition = REG_OPENED_EXISTING_KEY;
00680         }
00681         else
00682         {
00683             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00684                                        wcTemp,               // Sub key
00685                                        0,                    // Reserved
00686                                        0,                    // Class
00687                                        0,                    // Flags
00688                                        KEY_ALL_ACCESS,       // Access
00689                                        0,                    // Security
00690                                        &hKey,                // Handle
00691                                        &dwDisposition );     // Disposition
00692
00693             if ( ERROR_SUCCESS != dwError )
00694                 break;
00695         }
00696
00697         dwSize = sizeof(wcTemp);
00698
00699         dwError = RegQueryValueExW( hKey,                // Key handle
00700                                     0,                   // Name
00701                                     0,                   // Reserved
00702                                     &dwType,             // Datatype
00703                                     (BYTE *)(wcTemp),    // Data returned here
00704                                     &dwSize );           // Size of data
00705
00706         if ( ERROR_SUCCESS != dwError )
00707         {
00708             if ( ERROR_FILE_NOT_FOUND == dwError )
00709             {
00710                 //
00711                 // Don't set a class id in append mode.
00712                 //
00713
00714                 if ( fAppendOnly )
00715                 {
00716                     dwError = ERROR_SUCCESS;
00717                     break;
00718                 }
00719
00720                 dwError = RegSetValueExW( hKey,                          // Key
00721                                           0,                             // Name
00722                                           0,                             // Reserved
00723                                           REG_SZ,                        // Type
00724                                           (BYTE *)Class.pwszClassId,     // Value
00725                                           (DWORD) ( (1 + wcslen(Class.pwszClassId) ) * sizeof(WCHAR) ) );
00726
00727                 wcTemp[0] = 0; // Default to class from Class structure
00728
00729                 if ( ERROR_SUCCESS != dwError )
00730                     break;
00731             }
00732             else
00733                 break;
00734         }
00735         else
00736         {
00737             if ( REG_SZ != dwType )
00738                 dwError = E_FAIL;
00739         }
00740
00741         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00742         {
00743             RegCloseKey( hKey );
00744             hKey = (HKEY)INVALID_HANDLE_VALUE;
00745         }
00746
00747         if ( ERROR_SUCCESS != dwError )
00748             break;
00749
00750         //
00751         // Here, wcTemp contains the {class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00752         //
00753
00754         dwError = RegisterACLSID( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00755
00756     } while( FALSE );
00757
00758     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00759     {
00760         RegCloseKey( hKey );
00761         hKey = (HKEY)INVALID_HANDLE_VALUE;
00762     }
00763
00764     return dwError;
00765 }
00766
00767 //+---------------------------------------------------------------------------
00768 //
00769 //  Function:   RegisterACLSID, private
00770 //
00771 //  Synopsis:   Registers a CLSID / persistent handler.
00772 //
00773 //  Arguments:  [Class]        -- Class description
00774 //              [pwszPHandler] -- Persistent handler for class
00775 //              [pwszClassId]  -- If non 0, used instead of class id from [Class]
00776 //              [fAppendOnly]  -- TRUE --> CLSID should not be created
00777 //              [fAppendDesc]  -- TRUE --> Class description should be added.
00778 //                                         Only applies if [fAppendOnly] is FALSE
00779 //
00780 //  Returns:    ERROR_SUCCESS on success
00781 //
00782 //  Notes:      Class id is only registered if similar class does not already
00783 //              exist.  Persistent handler is always registered for class.
00784 //
00785 //----------------------------------------------------------------------------
00786
00787 inline long RegisterACLSID( SClassEntry const & Class,
00788                             WCHAR const * pwszPHandler,
00789                             WCHAR const * pwszClassId,
00790                             BOOL fAppendOnly,
00791                             BOOL fAppendDesc )
00792 {
00793     WCHAR wcTemp[MAX_PATH];
00794
00795     long dwError;
00796     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00797
00798     wcscpy( wcTemp, L"CLSID\\" );
00799
00800     if ( 0 == pwszClassId )
00801         wcscat( wcTemp, Class.pwszClassId );
00802     else
00803         wcscat( wcTemp, pwszClassId );
00804
00805     do
00806     {
00807         DWORD dwDisposition;
00808
00809         //
00810         // Here, wcTemp contains the CLSID\{class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00811         //
00812
00813         if ( fAppendOnly )
00814         {
00815             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00816                                      wcTemp,               // Sub key
00817                                      0,                    // Reserved
00818                                      KEY_ALL_ACCESS,       // Access
00819                                      &hKey );              // Handle
00820
00821             if ( ERROR_SUCCESS != dwError)
00822             {
00823                 //
00824                 // Not opening the key at all is legit.
00825                 //
00826
00827                 if ( ERROR_FILE_NOT_FOUND == dwError )
00828                     dwError = ERROR_SUCCESS;
00829
00830                 break;
00831             }
00832
00833             dwDisposition = REG_OPENED_EXISTING_KEY;
00834         }
00835         else
00836         {
00837             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00838                                        wcTemp,               // Sub key
00839                                        0,                    // Reserved
00840                                        0,                    // Class
00841                                        0,                    // Flags
00842                                        KEY_ALL_ACCESS,       // Access
00843                                        0,                    // Security
00844                                        &hKey,                // Handle
00845                                        &dwDisposition );     // Disposition
00846         }
00847
00848         if ( ERROR_SUCCESS != dwError )
00849             break;
00850
00851         //
00852         // If needed, write the description, but not for override class.
00853         //
00854
00855         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszClassId && fAppendDesc )
00856         {
00857             dwError = RegSetValueExW( hKey,                                 // Key
00858                                       0,                                    // Name
00859                                       0,                                    // Reserved
00860                                       REG_SZ,                               // Type
00861                                       (BYTE *)Class.pwszClassIdDescription, // Value
00862                                       (DWORD) ( (1 + wcslen(Class.pwszClassIdDescription) ) * sizeof(WCHAR) ) );
00863
00864             if ( ERROR_SUCCESS != dwError )
00865                 break;
00866         }
00867
00868         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00869         {
00870             RegCloseKey( hKey );
00871             hKey = (HKEY)INVALID_HANDLE_VALUE;
00872         }
00873
00874         //
00875         // Always write persistent handler.
00876         //
00877
00878         wcscat( wcTemp, L"\\PersistentHandler" );
00879
00880         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00881                                    wcTemp,               // Sub key
00882                                    0,                    // Reserved
00883                                    0,                    // Class
00884                                    0,                    // Flags
00885                                    KEY_ALL_ACCESS,       // Access
00886                                    0,                    // Security
00887                                    &hKey,                // Handle
00888                                    &dwDisposition );     // Disposition
00889
00890         if ( ERROR_SUCCESS != dwError )
00891             break;
00892
00893         dwError = RegSetValueExW( hKey,                  // Key
00894                                   0,                     // Name
00895                                   0,                     // Reserved
00896                                   REG_SZ,                // Type
00897                                   (BYTE *)pwszPHandler,  // Value
00898                                   (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00899
00900     } while( FALSE );
00901
00902     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00903     {
00904         RegCloseKey( hKey );
00905         hKey = (HKEY)INVALID_HANDLE_VALUE;
00906     }
00907
00908     return dwError;
00909 }
00910
00911 //+---------------------------------------------------------------------------
00912 //
00913 //  Function:   RemoveAClassName, private
00914 //
00915 //  Synopsis:   Removes all references to class name (ex: Word.Document.8)
00916 //
00917 //  Arguments:  [pwszClass] -- Class Name
00918 //
00919 //  Returns:    ERROR_SUCCESS on success
00920 //
00921 //----------------------------------------------------------------------------
00922
00923 inline long RemoveAClassName( WCHAR * pwszClass )
00924 {
00925     //
00926     // First, delete class name entry.
00927     //
00928
00929     long dwEnum = ERROR_SUCCESS;    // The enumerator
00930     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
00931
00932     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
00933
00934     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00935                                   0,                    // Sub key
00936                                   0,                    // Reserved
00937                                   KEY_ALL_ACCESS,       // Access
00938                                   &hKeyEnum );          // Handle
00939
00940
00941     if ( ERROR_SUCCESS == dwError )
00942     {
00943         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClass );
00944
00945         //
00946         // Now enumerate all classes entries, looking for the clsid
00947         //
00948
00949         DWORD dwIndex = 0;
00950
00951         while ( ERROR_SUCCESS == dwEnum )
00952         {
00953             WCHAR wcTemp[MAX_PATH];
00954             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
00955             FILETIME ftUnused;
00956
00957             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
00958                                     dwIndex,                // Index of registry subkey
00959                                     wcTemp,                 // Buffer for name
00960                                     &dwSize,                // Size of buffer / key
00961                                     0,                      // Reserved
00962                                     0,                      // Class (unused)
00963                                     0,                      // Class size (unused)
00964                                     &ftUnused );            // Filetime (unused)
00965
00966             dwIndex++;
00967
00968             if ( ERROR_SUCCESS == dwEnum )
00969             {
00970                 HKEY hKey;
00971
00972                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00973                                          wcTemp,               // Sub key
00974                                          0,                    // Reserved
00975                                          KEY_ALL_ACCESS,       // Access
00976                                          &hKey );              // Handle
00977
00978                 if ( ERROR_SUCCESS == dwError )
00979                 {
00980                     WCHAR wcTemp2[MAX_PATH];
00981                     DWORD dwType;
00982
00983                     dwSize = sizeof(wcTemp2);
00984
00985                     dwError = RegQueryValueExW( hKey,                // Key handle
00986                                                 0,                   // Name
00987                                                 0,                   // Reserved
00988                                                 &dwType,             // Datatype
00989                                                 (BYTE *)wcTemp2,     // Data returned here
00990                                                 &dwSize );           // Size of data
00991
00992                     RegCloseKey( hKey );
00993
00994                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClass ) )
00995                     {
00996                         //
00997                         // Always delete the value
00998                         //
00999
01000                         if ( ERROR_SUCCESS == dwIgnore )
01001                             dwIgnore = RegDeleteValueW( hKey, 0 );
01002                         else
01003                             RegDeleteValueW( hKey, 0 );
01004
01005                         //
01006                         // Any other key(s)?
01007                         //
01008
01009                         dwSize = sizeof(wcTemp) / sizeof wcTemp[0];
01010
01011                         DWORD dw2 = RegEnumKeyExW( hKey,                   // Handle of key
01012                                                    0,                      // Index of registry subkey
01013                                                    wcTemp,                 // Buffer for name
01014                                                    &dwSize,                // Size of buffer / key
01015                                                    0,                      // Reserved
01016                                                    0,                      // Class (unused)
01017                                                    0,                      // Class size (unused)
01018                                                    &ftUnused );            // Filetime (unused)
01019
01020                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01021                         {
01022                             if ( ERROR_SUCCESS == dwIgnore )
01023                                 dwIgnore = RegDeleteKeyW( hKeyEnum, wcTemp );
01024                             else
01025                                 RegDeleteKeyW( hKeyEnum, wcTemp );
01026
01027                             dwIndex = 0;
01028                         }
01029
01030                     }
01031                     else
01032                         dwError = ERROR_SUCCESS;  // Just didn't have a null key (or no match)
01033                 }
01034             }
01035         }
01036     }
01037
01038     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01039         dwError = dwEnum;
01040
01041     if ( ERROR_SUCCESS != dwError )
01042         return dwError;
01043     else
01044         return dwIgnore;
01045 }
01046
01047 //+---------------------------------------------------------------------------
01048 //
01049 //  Function:   RemoveAClass, private
01050 //
01051 //  Synopsis:   Removes all references to class
01052 //
01053 //  Arguments:  [pwszClass] -- Class
01054 //
01055 //  Returns:    ERROR_SUCCESS on success
01056 //
01057 //----------------------------------------------------------------------------
01058
01059 inline long RemoveAClass( WCHAR * pwszClassId )
01060 {
01061     //
01062     // First, delete class entry.
01063     //
01064
01065     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
01066     long dwEnum = ERROR_SUCCESS;    // For enumerator
01067
01068     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01069
01070     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01071                                   L"CLSID",             // Sub key
01072                                   0,                    // Reserved
01073                                   KEY_ALL_ACCESS,       // Access
01074                                   &hKeyEnum );          // Handle
01075
01076     if ( ERROR_SUCCESS == dwError )
01077     {
01078         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClassId );
01079
01080         RegCloseKey( hKeyEnum );
01081
01082         long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01083                                       0,                    // Sub key
01084                                       0,                    // Reserved
01085                                       KEY_ALL_ACCESS,       // Access
01086                                       &hKeyEnum );          // Handle
01087     }
01088
01089     if ( ERROR_SUCCESS == dwError )
01090     {
01091         //
01092         // Now enumerate all classes entries, looking for the clsid
01093         //
01094
01095         DWORD dwIndex = 0;
01096
01097         while ( ERROR_SUCCESS == dwEnum )
01098         {
01099             WCHAR wcTemp[MAX_PATH];
01100             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01101             FILETIME ftUnused;
01102
01103             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01104                                     dwIndex,                // Index of registry subkey
01105                                     wcTemp,                 // Buffer for name
01106                                     &dwSize,                // Size of buffer / key
01107                                     0,                      // Reserved
01108                                     0,                      // Class (unused)
01109                                     0,                      // Class size (unused)
01110                                     &ftUnused );            // Filetime (unused)
01111
01112             dwIndex++;
01113
01114             if ( ERROR_SUCCESS == dwEnum )
01115             {
01116                 wcscat( wcTemp, L"\\CLSID" );
01117
01118                 HKEY hKey;
01119
01120                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01121                                          wcTemp,               // Sub key
01122                                          0,                    // Reserved
01123                                          KEY_ALL_ACCESS,       // Access
01124                                          &hKey );              // Handle
01125
01126                 if ( ERROR_SUCCESS == dwError )
01127                 {
01128                     WCHAR wcTemp2[MAX_PATH];
01129                     DWORD dwType;
01130
01131                     dwSize = sizeof(wcTemp2);
01132
01133                     dwError = RegQueryValueExW( hKey,                // Key handle
01134                                                 0,                   // Name
01135                                                 0,                   // Reserved
01136                                                 &dwType,             // Datatype
01137                                                 (BYTE *)wcTemp2,     // Data returned here
01138                                                 &dwSize );           // Size of data
01139
01140                     RegCloseKey( hKey );
01141
01142                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClassId ) )
01143                     {
01144                         wcTemp[ wcslen(wcTemp) - wcslen( L"\\CLSID" ) ] = 0;
01145
01146                         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01147                                                  wcTemp,               // Sub key
01148                                                  0,                    // Reserved
01149                                                  KEY_ALL_ACCESS,       // Access
01150                                                  &hKey );              // Handle
01151
01152                         if ( ERROR_SUCCESS == dwError )
01153                         {
01154                             if ( ERROR_SUCCESS == dwIgnore )
01155                                 dwIgnore = RegDeleteKeyW( hKey, L"CLSID" );
01156                             else
01157                                 RegDeleteKeyW( hKey, L"CLSID" );
01158
01159                             dwIndex = 0;
01160                         }
01161
01162                         //
01163                         // If there are no more entries, then the class name can be deleted
01164                         //
01165
01166                         dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01167
01168                         long dw2 = RegEnumKeyExW( hKey,               // Handle of key
01169                                                   0,                  // Index of registry subkey
01170                                                   wcTemp,             // Buffer for name
01171                                                   &dwSize,            // Size of buffer / key
01172                                                   0,                  // Reserved
01173                                                   0,                  // Class (unused)
01174                                                   0,                  // Class size (unused)
01175                                                   &ftUnused );        // Filetime (unused)
01176
01177                         RegCloseKey( hKey );
01178
01179                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01180                             RemoveAClassName( wcTemp );
01181                     }
01182                 }
01183                 else
01184                     dwError = ERROR_SUCCESS;  // Just didn't have CLSID
01185             }
01186         }
01187     }
01188
01189     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01190         dwError = dwEnum;
01191
01192     if ( ERROR_SUCCESS != dwError )
01193         return dwError;
01194     else
01195         return dwIgnore;
01196 }
01197
01198 //+---------------------------------------------------------------------------
01199 //
01200 //  Function:   RegisterAHandler, private
01201 //
01202 //  Synopsis:   Registers a persistent handler in registry
01203 //
01204 //  Arguments:  [Handler] -- Persistent handler
01205 //
01206 //  Returns:    ERROR_SUCCESS on success
01207 //
01208 //----------------------------------------------------------------------------
01209
01210 inline long RegisterAHandler( SHandlerEntry const & Handler )
01211 {
01212     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01213                                     Handler.pwszClassIdDescription,
01214                                     L"PersistentAddinsRegistered",
01215                                     0,
01216                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01217                                     Handler.pwszClassIdFilter };
01218
01219     return BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01220 }
01221
01222 //+---------------------------------------------------------------------------
01223 //
01224 //  Function:   RegisterAFilter, private
01225 //
01226 //  Synopsis:   Registers a filter in registry
01227 //
01228 //  Arguments:  [Filter] -- IFilter implementation
01229 //
01230 //  Returns:    ERROR_SUCCESS on success
01231 //
01232 //----------------------------------------------------------------------------
01233
01234 inline long RegisterAFilter( SFilterEntry const & Filter )
01235 {
01236     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01237                                     Filter.pwszClassIdDescription,
01238                                     L"InprocServer32",
01239                                     Filter.pwszDLL };
01240
01241     long retVal = BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01242     if ( ERROR_SUCCESS == retVal )
01243         retVal = AddThreadingModel( Filter.pwszClassId, Filter.pwszThreadingModel );
01244
01245     return retVal;
01246 }
01247
01248 //+---------------------------------------------------------------------------
01249 //
01250 //  Function:   UnRegisterAHandler, private
01251 //
01252 //  Synopsis:   Unregisters a persistent handler, including class entries.
01253 //
01254 //  Arguments:  [Handler] -- Persistent handler
01255 //
01256 //  Returns:    ERROR_SUCCESS on success
01257 //
01258 //----------------------------------------------------------------------------
01259
01260 inline long UnRegisterAHandler( SHandlerEntry const & Handler )
01261 {
01262     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01263                                     Handler.pwszClassIdDescription,
01264                                     L"PersistentAddinsRegistered",
01265                                     0,
01266                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01267                                     Handler.pwszClassIdFilter };
01268
01269     //
01270     // dwIgnore is used to record non-fatal errors
01271     //
01272
01273     long dwIgnore = DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01274     long dwError = ERROR_SUCCESS;
01275
01276     //
01277     // Now, enumerate all classes and delete any persistent handler entries.
01278     //
01279
01280     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01281
01282     long dwEnum = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01283                                  L"CLSID",              // Sub key
01284                                  0,                    // Reserved
01285                                  KEY_ALL_ACCESS,       // Access
01286                                  &hKeyEnum );          // Handle
01287
01288     DWORD dwIndex = 0;
01289
01290     while ( ERROR_SUCCESS == dwEnum )
01291     {
01292         WCHAR wcTemp[MAX_PATH];
01293
01294         wcscpy( wcTemp, L"CLSID\\" );
01295         unsigned cc = (unsigned) wcslen( wcTemp );
01296
01297         DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]) - cc;
01298         FILETIME ftUnused;
01299
01300         dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01301                                 dwIndex,                // Index of registry subkey
01302                                 wcTemp + cc,            // Buffer for name
01303                                 &dwSize,                // Size of buffer / key
01304                                 0,                      // Reserved
01305                                 0,                      // Class (unused)
01306                                 0,                      // Class size (unused)
01307                                 &ftUnused );            // Filetime (unused)
01308
01309         dwIndex++;
01310
01311         //
01312         // Does the key have a persistent handler?
01313         //
01314
01315         if ( ERROR_SUCCESS == dwEnum )
01316         {
01317             wcscat( wcTemp, L"\\PersistentHandler" );
01318
01319             HKEY hKey;
01320
01321             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01322                                      wcTemp,               // Sub key
01323                                      0,                    // Reserved
01324                                      KEY_ALL_ACCESS,       // Access
01325                                      &hKey );              // Handle
01326
01327             if ( ERROR_SUCCESS == dwError )
01328             {
01329                 //
01330                 // Is this the persistent handler we're looking for?
01331                 //
01332
01333                 WCHAR wcTemp2[MAX_PATH];
01334                 DWORD dwType;
01335
01336                 dwSize = sizeof(wcTemp2);
01337
01338                 dwError = RegQueryValueExW( hKey,                // Key handle
01339                                             0,                   // Name
01340                                             0,                   // Reserved
01341                                             &dwType,             // Datatype
01342                                             (BYTE *)wcTemp2,     // Data returned here
01343                                             &dwSize );           // Size of data
01344
01345                 RegCloseKey( hKey );
01346
01347                 if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, Handler.pwszClassId ) )
01348                 {
01349                     wcTemp[ wcslen(wcTemp) - wcslen( L"\\PersistentHandler" ) ] = 0;
01350
01351                     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01352                                              wcTemp,               // Sub key
01353                                              0,                    // Reserved
01354                                              KEY_ALL_ACCESS,       // Access
01355                                              &hKey );              // Handle
01356
01357                     if ( ERROR_SUCCESS == dwError )
01358                     {
01359                         if ( ERROR_SUCCESS == dwIgnore )
01360                             dwIgnore = RegDeleteKeyW( hKey, L"PersistentHandler" );
01361                         else
01362                             RegDeleteKeyW( hKey, L"PersistentHandler" );
01363
01364                         dwIndex = 0; // Start over again
01365                     }
01366
01367                     //
01368                     // If that was the *only* entry under the clsid, then the class can be
01369                     // removed.
01370                     //
01371
01372                     dwSize = sizeof(wcTemp2)/sizeof(wcTemp2[0]);
01373
01374                     long dw2 = RegEnumKeyExW( hKey,             // Handle of key
01375                                               0,                // Index of registry subkey
01376                                               wcTemp2,          // Buffer for name
01377                                               &dwSize,          // Size of buffer / key
01378                                               0,                // Reserved
01379                                               0,                // Class (unused)
01380                                               0,                // Class size (unused)
01381                                               &ftUnused );      // Filetime (unused)
01382
01383                     RegCloseKey( hKey );
01384
01385                     if ( ERROR_NO_MORE_ITEMS == dw2 )
01386                         RemoveAClass( wcTemp + wcslen( L"CLSID\\" ) );
01387                 }
01388                 else
01389                 {
01390                     //
01391                     // Didn't have persistent handler null key.  Odd but not fatal.
01392                     // Or, key didn't match target.
01393                     //
01394
01395                     dwIgnore = dwError;
01396                     dwError = ERROR_SUCCESS;
01397                 }
01398
01399             }
01400             else
01401                 dwError = ERROR_SUCCESS;  // Just didn't have persistent handler
01402         }
01403     }
01404
01405     if ( (HKEY)INVALID_HANDLE_VALUE != hKeyEnum )
01406         RegCloseKey( hKeyEnum );
01407
01408     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01409         dwError = dwEnum;
01410
01411     if ( ERROR_SUCCESS != dwError )
01412         return dwError;
01413     else
01414         return dwIgnore;
01415 }
01416
01417 //+---------------------------------------------------------------------------
01418 //
01419 //  Function:   UnRegisterAnExt, private
01420 //
01421 //  Synopsis:   Unregisters a filter extension
01422 //
01423 //  Arguments:  [Class] -- Class description to unregister
01424 //
01425 //  Returns:    ERROR_SUCCESS on success
01426 //
01427 //----------------------------------------------------------------------------
01428
01429 inline long UnRegisterAnExt( SClassEntry const & Class )
01430 {
01431     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
01432     DWORD dwError;
01433
01434     do
01435     {
01436         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01437                                  Class.pwszExt,        // Sub key -- "CLSID"
01438                                  0,                    // Reserved
01439                                  KEY_ALL_ACCESS,       // Access
01440                                  &hKey );              // Handle
01441
01442         if ( ERROR_SUCCESS != dwError )
01443             break;
01444
01445         dwError = RegDeleteKeyW( hKey, L"PersistentHandler" );
01446
01447     } while ( FALSE );
01448
01449     if ( INVALID_HANDLE_VALUE != hKey )
01450     {
01451         RegCloseKey( hKey );
01452         hKey = (HKEY)INVALID_HANDLE_VALUE;
01453     }
01454
01455     return dwError;
01456 }
01457
01458 //+---------------------------------------------------------------------------
01459 //
01460 //  Function:   UnRegisterAFilter, private
01461 //
01462 //  Synopsis:   Unregisters a filter
01463 //
01464 //  Arguments:  [Filter] -- IFilter implementation
01465 //
01466 //  Returns:    ERROR_SUCCESS on success
01467 //
01468 //----------------------------------------------------------------------------
01469
01470 inline long UnRegisterAFilter( SFilterEntry const & Filter )
01471 {
01472     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01473                                     Filter.pwszClassIdDescription,
01474                                     L"InprocServer32",
01475                                     Filter.pwszDLL };
01476
01477     return DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01478 }
01479
01480 //+---------------------------------------------------------------------------
01481 //
01482 //  Function:   DllUnregisterServer
01483 //
01484 //  Synopsis:   Self-unregistration
01485 //
01486 //----------------------------------------------------------------------------
01487
01488 //+---------------------------------------------------------------------------
01489 //
01490 //  Function:   DllRegisterServer
01491 //
01492 //  Synopsis:   Self-registration
01493 //
01494 //  Notes:      There are two versions here.  Version 1 registers only
01495 //              extensions.  Version 2 registers extensions and
01496 //              [nameless] Class IDs.
01497 //
01498 //----------------------------------------------------------------------------
01499
01500 #define DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, fBlastExistingPersistentHandler )  \
01501                                                                \
01502 STDAPI Name##UnregisterServer()                                \
01503 {                                                              \
01504     /*                                                         \
01505      * Always remove Persistent Handler and Filter entries     \
01506      */                                                        \
01507                                                                \
01508     long dwError = UnRegisterAHandler( Handler );              \
01509                                                                \
01510     if ( ERROR_SUCCESS == dwError )                            \
01511         dwError = UnRegisterAFilter( Filter );                 \
01512     else                                                       \
01513         UnRegisterAFilter( Filter );                           \
01514                                                                \
01515     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01516     {                                                          \
01517         if ( ERROR_SUCCESS == dwError )                        \
01518             dwError = UnRegisterAnExt( aClasses[i] );          \
01519         else                                                   \
01520              UnRegisterAnExt( aClasses[i] );                   \
01521     }                                                          \
01522                                                                \
01523     if ( ERROR_SUCCESS == dwError )                            \
01524         return S_OK;                                           \
01525     else                                                       \
01526         return S_FALSE;                                        \
01527 }                                                              \
01528                                                                \
01529 STDAPI Name##RegisterServer()                                  \
01530 {                                                              \
01531     /*                                                         \
01532      * Always create Persistent Handler and Filter entries     \
01533      */                                                        \
01534                                                                \
01535     long dwError = RegisterAHandler( Handler );                \
01536                                                                \
01537     /*                                                         \
01538      * First, register the CLSID and persistent handler,       \
01539      * then work back to the class description and the         \
01540      * extension. This ensures we cover all possible           \
01541      * mappings.                                               \
01542      *                                                         \
01543      */                                                        \
01544                                                                \
01545     OSVERSIONINFO Version;                                     \
01546     Version.dwOSVersionInfoSize = sizeof(Version);             \
01547                                                                \
01548     BOOL fAppendOnly = FALSE;                                  \
01549                                                                \
01550     if ( GetVersionEx( &Version ) &&                           \
01551          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01552          Version.dwMajorVersion >= 5 )                         \
01553     {                                                          \
01554         fAppendOnly = TRUE;                                    \
01555     }                                                          \
01556                                                                \
01557     if ( ERROR_SUCCESS == dwError )                            \
01558         dwError = RegisterAFilter( Filter );                   \
01559                                                                \
01560     if ( ERROR_SUCCESS == dwError )                            \
01561         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01562             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01563                                                                \
01564     if ( ERROR_SUCCESS == dwError )                            \
01565         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01566             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01567                                                                \
01568     if ( ERROR_SUCCESS == dwError )                            \
01569         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01570             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly, fBlastExistingPersistentHandler );                     \
01571                                                                \
01572     if ( ERROR_SUCCESS == dwError )                            \
01573         return S_OK;                                           \
01574     else                                                       \
01575         return SELFREG_E_CLASS;                                \
01576 }
01577
01578
01579 #define DEFINE_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01580     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, TRUE )  \
01581
01582
01583 #define DEFINE_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01584     DEFINE_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01585
01586 #define DEFINE_SOFT_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01587     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, FALSE )  \
01588
01589 #define DEFINE_SOFT_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01590     DEFINE_SOFT_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01591
01592
01593 //
01594 // Version 2 (for NT 4 support where all the extra registry goo is required).
01595 //
01596
01597 #define DEFINE_REGISTERFILTER2( Name, Handler, Filter, aClasses )  \
01598                                                                \
01599 STDAPI Name##UnregisterServer()                                \
01600 {                                                              \
01601     /*                                                         \
01602      * Always remove Persistent Handler and Filter entries     \
01603      */                                                        \
01604                                                                \
01605     long dwError = UnRegisterAHandler( Handler );              \
01606                                                                \
01607     if ( ERROR_SUCCESS == dwError )                            \
01608         dwError = UnRegisterAFilter( Filter );                 \
01609     else                                                       \
01610         UnRegisterAFilter( Filter );                           \
01611                                                                \
01612     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01613     {                                                          \
01614         if ( ERROR_SUCCESS == dwError )                        \
01615             dwError = UnRegisterAnExt( aClasses[i] );          \
01616         else                                                   \
01617             UnRegisterAnExt( aClasses[i] );                    \
01618     }                                                          \
01619                                                                \
01620     if ( ERROR_SUCCESS == dwError )                            \
01621         return S_OK;                                           \
01622     else                                                       \
01623         return S_FALSE;                                        \
01624 }                                                              \
01625                                                                \
01626 STDAPI Name##RegisterServer()                                  \
01627 {                                                              \
01628     /*                                                         \
01629      * Always create Persistent Handler and Filter entries     \
01630      */                                                        \
01631                                                                \
01632     long dwError = RegisterAHandler( Handler );                \
01633                                                                \
01634     /*                                                         \
01635      * First, register the CLSID and persistent handler,       \
01636      * then work back to the class description and the         \
01637      * extension. This ensures we cover all possible           \
01638      * mappings.                                               \
01639      *                                                         \
01640      */                                                        \
01641                                                                \
01642     OSVERSIONINFO Version;                                     \
01643     Version.dwOSVersionInfoSize = sizeof(Version);             \
01644                                                                \
01645     BOOL fAppendOnly = FALSE;                                  \
01646                                                                \
01647     if ( GetVersionEx( &Version ) &&                           \
01648          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01649          Version.dwMajorVersion >= 5 )                         \
01650     {                                                          \
01651         fAppendOnly = TRUE;                                    \
01652     }                                                          \
01653                                                                \
01654     if ( ERROR_SUCCESS == dwError )                            \
01655         dwError = RegisterAFilter( Filter );                   \
01656                                                                \
01657     if ( ERROR_SUCCESS == dwError )                            \
01658         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01659             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, FALSE, FALSE );                \
01660                                                                \
01661     if ( ERROR_SUCCESS == dwError )                            \
01662         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01663             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01664                                                                \
01665     if ( ERROR_SUCCESS == dwError )                            \
01666         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01667             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly );                     \
01668                                                                \
01669     if ( ERROR_SUCCESS == dwError )                            \
01670         return S_OK;                                           \
01671     else                                                       \
01672         return SELFREG_E_CLASS;                                \
01673 }
01674
01675
01676
01677
01678 #define DEFINE_DLLREGISTERFILTER2( Handler, Filter, aClasses )  \
01679     DEFINE_REGISTERFILTER2( Dll, Handler, Filter, aClasses )
01680
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/crowposition.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

crowposition.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CROWPOSITION.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CROWPOSITION_H_
00012 #define _CROWPOSITION_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019
00020
00021 /////////////////////////////////////////////////////////////////
00022 // CRowPosition class
00023 //
00024 /////////////////////////////////////////////////////////////////
00025 class CRowPosition : public CContainerBase
00026 {
00027 public:
00028   //Constructors
00029   CRowPosition(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00030   virtual ~CRowPosition();
00031
00032   //IUnknown Helpers
00033   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00034   virtual HRESULT     AutoRelease();
00035   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00036
00037   //Pure Virtual
00038   virtual WCHAR*      GetObjectName()     { return L"RowPosition";    }
00039   virtual UINT      GetObjectMenu()     { return IDM_ROWPOSITIONMENU; }
00040   virtual LONG      GetObjectImage()    { return IMAGE_ARROW_DOWN;    }
00041   virtual REFIID      GetDefaultInterface() { return IID_IRowPosition;    }
00042
00043   //Interface Helpers
00044   virtual HRESULT     Initialize(IUnknown* pIUnkRowset);
00045   virtual HRESULT     GetRowset(REFIID riid, IUnknown** ppIUnknown);
00046
00047   //OLE DB Interfaces
00048   //[MANDATORY]
00049   IRowPosition*       m_pIRowPosition;
00050
00051   //Extra interfaces
00052   DWORD           m_dwCookieRowPos;
00053 };
00054
00055
00056
00057
00058
00059 #endif //_CROWPOSITION_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Dt_Dll2/Socketmon.Cpp Source File

  • NetDS
  • WinSock
  • Dt_Dll2

Socketmon.Cpp

Go to the documentation of this file.
00001 // Filename  : SocketMon.cpp
00002 // Abstract  : This object is inherited from DTHandler and implements
00003 //             our custom DT Winsock API hooking.
00004 // Author    : Jeffrey C. Venable, Sr.
00005 // Copyright : THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00006 //             WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00007 //             INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
00008 //             MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00009 //             Copyright (C) 1998 - 2002, Microsoft Corporation.
00010 //             All rights reserved.
00011
00012 #include <stdio.h>
00013 #include "SocketMon.hpp"
00014
00015
00016 bool
00017 SocketMonitor::WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData, APIHook<int> &hook) {
00018
00019     char buffer[1024];
00020
00021     if (hook.preAPI()) {
00022
00023         _snprintf(buffer,
00024                   sizeof(buffer) - 1,
00025                   "\nWinsock API\t\t: WSAStartup()\n"
00026                   "     Calling library\t\t: %s\n"
00027                   "     Pre-API notify\t\t: Yes\n"
00028                   "Parameter values\t\t:\n"
00029                   "     wVersionRequested\t: %u\n",
00030                   hook.libName(),
00031                   wVersionRequested);
00032
00033     } else {
00034
00035         _snprintf(buffer,
00036                   sizeof(buffer) - 1,
00037                   "\nWinsock API\t\t\t: WSAStartup()\n"
00038                   "     Calling library\t\t\t: %s\n"
00039                   "     Pre-API notify\t\t\t: No\n"
00040                   "Reference parameter values\t\t:\n"
00041                   "     lpWSAData->wVersion\t\t: %d\n"
00042                   "     lpWSAData->wHighVersion\t: %d\n"
00043                   "     lpWSAData->iMaxSockets\t\t: %d\n"
00044                   "     lpWSAData->iMaxUdpDg\t\t: %d\n"
00045                   "     lpWSAData->szDescription\t: %s\n"
00046                   "     lpWSAData->szSystemStatus\t: %s\n"
00047                   "     lpWSAData->lpVendorInfo\t\t: %s\n"
00048                   "API return value\t\t\t: %d\n",
00049                   hook.libName(),
00050                   lpWSAData->wVersion,
00051                   lpWSAData->wHighVersion,
00052                   lpWSAData->iMaxSockets,
00053                   lpWSAData->iMaxUdpDg,
00054                   lpWSAData->szDescription,
00055                   lpWSAData->szSystemStatus,
00056                   lpWSAData->lpVendorInfo,
00057                   *hook.rValue());
00058
00059     }
00060
00061     buffer[sizeof(buffer) - 1] = '\0';
00062     MessageBox(0, buffer, "DT Hook", MB_OK | MB_ICONINFORMATION);
00063
00064     return (false); // don't veto API call
00065
00066 } // SocketMonitor::WSAStartup()
00067
00068
00069 bool
00070 SocketMonitor::WSACleanup(APIHook<int> &hook) {
00071
00072     char buffer[1024];
00073
00074     if (hook.preAPI()) {
00075
00076         _snprintf(buffer,
00077                   sizeof(buffer) - 1,
00078                   "\nWinsock API\t\t: WSACleanup()\n"
00079                   "     Calling library\t\t: %s\n"
00080                   "     Pre-API notify\t\t: Yes\n",
00081                   hook.libName());
00082
00083     } else {
00084
00085         _snprintf(buffer,
00086                   sizeof(buffer) - 1,
00087                   "\nWinsock API\t\t: WSACleanup()\n"
00088                   "     Calling library\t\t: %s\n"
00089                   "     Pre-API notify\t\t: No\n"
00090                   "     API return value\t\t: %d\n",
00091                   hook.libName(),
00092                   *hook.rValue());
00093
00094     }
00095
00096     buffer[sizeof(buffer) - 1] = '\0';
00097     MessageBox(0, buffer, "DT Hook", MB_OK | MB_ICONINFORMATION);
00098
00099     return (false); // don't veto API call
00100
00101 } // SocketMonitor::WSACleanup()
00102
00103
00104 bool
00105 SocketMonitor::send(SOCKET s, const char FAR *buf, int len, int flags, APIHook<int> &hook) {
00106
00107     char buffer[1024];
00108
00109     if (hook.preAPI()) {
00110
00111         _snprintf(buffer,
00112                   sizeof(buffer) - 1,
00113                 "Winsock API\t\t: send()\n"
00114                 "     Calling library\t\t: %s\n"
00115                 "     Pre-API notify\t\t: Yes\n"
00116                 "Parameter values\t\t:\n"
00117                 "     s\t\t\t: %d\n"
00118                 "     buf\t\t\t: 0x%08x\n"
00119                 "     len\t\t\t: %d\n"
00120                 "     flags\t\t\t: %d\n",
00121                 hook.libName(),
00122                 s,
00123                 *buf,
00124                 len,
00125                 flags);
00126
00127     } else {
00128
00129         _snprintf(buffer,
00130                   sizeof(buffer) - 1,
00131                   "Winsock API\t\t\t: send()\n"
00132                   "     Calling library\t\t\t: %s\n"
00133                   "     Pre-API notify\t\t\t: No\n"
00134                   "     API return value\t\t\t: %d\n",
00135                   hook.libName(),
00136                   *hook.rValue());
00137
00138     }
00139
00140     buffer[sizeof(buffer) - 1] = '\0';
00141     MessageBox(0, buffer, "DT Hook", MB_OK | MB_ICONINFORMATION);
00142
00143     return (false); // don't veto API call
00144
00145 } // SocketMonitor::send()
00146
00147
00148 bool
00149 SocketMonitor::recv(SOCKET s, char FAR *buf, int len, int flags, APIHook<int> &hook) {
00150
00151     char buffer[1024];
00152
00153     if (hook.preAPI()) {
00154
00155         _snprintf(buffer,
00156                   sizeof(buffer) - 1,
00157                   "[DT Hook]\n"
00158                   "\tWinsock API\t\t: recv()\n"
00159                   "     \tCalling library\t\t: %s\n"
00160                   "     \tPre-API notify\t\t: Yes\n"
00161                   "\tParameter values\t:\n"
00162                   "     \ts\t\t\t: %d\n"
00163                   "     \tbuf\t\t\t: 0x%08x\n"
00164                   "     \tlen\t\t\t: %d\n"
00165                   "     \tflags\t\t\t: %d\n",
00166                   hook.libName(),
00167                   s,
00168                   *buf,
00169                   len,
00170                   flags);
00171
00172     } else {
00173
00174         _snprintf(buffer,
00175                   sizeof(buffer) - 1,
00176                   "Winsock API\t\t\t: send()\n"
00177                   "     Calling library\t\t\t: %s\n"
00178                   "     Pre-API notify\t\t\t: No\n"
00179                   "     API return value\t\t\t: %d\n"
00180                   "Reference parameter values:\t:\n",
00181                   hook.libName(),
00182                   *hook.rValue());
00183
00184     }
00185
00186     buffer[sizeof(buffer) - 1] = '\0';
00187     MessageBox(0, buffer, "DT Hook", MB_OK | MB_ICONINFORMATION);
00188
00189     return (false); // don't veto API call
00190
00191 } // SocketMonitor::recv()
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/classfac.h Source File

  • Dataaccess
  • oledb
  • sampprov

classfac.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module CLASSFAC.H | Class Definitions for CClassFactory and
00008 // DLL Entry Points
00009 //
00010 //
00011 #ifndef _CLASSFAC_H_
00012 #define _CLASSFAC_H_
00013
00014
00015
00016 // Classes -------------------------------------------------------------------
00017
00018
00019 //----------------------------------------------------------------------------
00020 // @class CClassFactory
00021 //
00022 class CClassFactory : public IClassFactory    //@base public | IClassFactory
00023 {
00024   protected: //@access protected
00025     //@cmember Reference count
00026     DBREFCOUNT    m_cRef;
00027     CLSID     m_clsid;
00028
00029   public: // @access public
00030     //@cmember Constructor
00031     CClassFactory(REFCLSID clsid);
00032     //@cmember Destructor
00033     ~CClassFactory(void);
00034
00035     //  IUnknown members
00036     //@cmember Request an Interface
00037     STDMETHODIMP        QueryInterface(REFIID, LPVOID *);
00038     //@cmember Increments the Reference count
00039     STDMETHODIMP_(DBREFCOUNT) AddRef(void);
00040     //@cmember Decrements the Reference count
00041     STDMETHODIMP_(DBREFCOUNT) Release(void);
00042
00043     //  IClassFactory members
00044     //@cmember Instantiates an uninitialized instance of an object
00045     STDMETHODIMP      CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00046       //@cmember Lock Object so that it can not be unloaded
00047     STDMETHODIMP      LockServer(BOOL);
00048 };
00049
00050 #endif
00051
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/AsyncRPC/AsyncRPCs.c Source File

  • NetDS
  • RPC
  • AsyncRPC

AsyncRPCs.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright Microsoft Corp. 1992 - 2000
00007 //
00008 // FILE:      AsyncRPCs.c
00009 //
00010 // USAGE:     AsyncRPCs /?
00011 //
00012 // PURPOSE:   Server side main program
00013 //
00014 // COMMENTS:  The Microsoft RPC AsyncRPC sample program demonstrates
00015 //            the use of the [async] attribute and the related asynchronous
00016 //            RPC API functions. For more information, see MSDN online reference.
00017 //
00018 // WRITTEN BY:    Mike Liu
00019 //
00020
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <ctype.h>
00024 #include "AsyncRPC.h" // header file generated by MIDL compiler
00025
00026 const int DEFAULT_MIN_CALLS   = 1;
00027 const int DEFAULT_MAX_CALLS   = 20;
00028 const BOOL DEFAULT_WAIT_FLAG  = FALSE;
00029
00030 PSECURITY_DESCRIPTOR pszSecurity   = NULL;
00031
00032 void Usage(char * pszProgramName)
00033 {
00034    fprintf(stderr, "Usage:  %s\n", pszProgramName);
00035    fprintf(stderr, " -p protocol_sequence (default is '%s')\n", DEFAULT_PROTOCOL_SEQUENCE);
00036    fprintf(stderr, " -e endpoint (default is '%s')\n", DEFAULT_ENDPOINT);
00037    fprintf(stderr, " -m maxcalls (default is %d)\n", DEFAULT_MAX_CALLS);
00038    fprintf(stderr, " -n mincalls\n (default is %d)\n", DEFAULT_MAX_CALLS);
00039    fprintf(stderr, " -f flag_wait_op (default is %d)\n", DEFAULT_WAIT_FLAG);
00040    exit(1);
00041 }
00042
00043 void Quit(RPC_STATUS status)
00044 {
00045    if (pszSecurity != NULL)
00046       free(pszSecurity);
00047
00048    exit(status);
00049 }
00050
00051 void __cdecl main(int argc, char * argv[])
00052 {
00053    unsigned char *pszProtocolSequence = DEFAULT_PROTOCOL_SEQUENCE;
00054    unsigned char *pszEndpoint         = DEFAULT_ENDPOINT;
00055    unsigned int   nMinCalls           = DEFAULT_MIN_CALLS;
00056    unsigned int   nMaxCalls           = DEFAULT_MAX_CALLS;
00057    BOOL bDontWait                     = DEFAULT_WAIT_FLAG;
00058    PSECURITY_DESCRIPTOR pszSecurity   = NULL;
00059    int i;
00060    RPC_STATUS status;
00061
00062    // allow the user to override settings with command line switches
00063    for (i = 1; i < argc; i++)
00064    {
00065       if ((*argv[i] == '-') || (*argv[i] == '/'))
00066       {
00067          switch (tolower(*(argv[i]+1)))
00068          {
00069             case 'p':
00070                pszProtocolSequence = argv[++i];
00071                break;
00072             case 'e':
00073                pszEndpoint = argv[++i];
00074                break;
00075             case 'm':
00076                nMaxCalls = (unsigned int) atoi(argv[++i]);
00077                break;
00078             case 'n':
00079                nMinCalls = (unsigned int) atoi(argv[++i]);
00080                break;
00081             case 'f':
00082                bDontWait = (unsigned int) atoi(argv[++i]);
00083                break;
00084             case 'h':
00085             case '?':
00086             default:
00087                Usage(argv[0]);
00088          }
00089       }
00090       else
00091          Usage(argv[0]);
00092    }
00093
00094    if ((pszProtocolSequence == NULL) || (pszEndpoint == NULL) ||
00095        (nMinCalls < 1) || (nMinCalls > nMaxCalls))
00096       Usage(argv[0]);
00097
00098    status = RpcServerUseProtseqEp(pszProtocolSequence,
00099                                   nMaxCalls,
00100                                   pszEndpoint,
00101                                   pszSecurity);
00102    printf("RpcServerUseProtseqEp returned 0x%x\n", status);
00103    if (status)
00104       Quit(status);
00105
00106    status = RpcServerRegisterIf(AsyncRPC_ServerIfHandle,
00107                                 NULL,
00108                                 NULL);
00109    printf("RpcServerRegisterIf returned 0x%x\n", status);
00110    if (status)
00111       Quit(status);
00112
00113    printf("Calling RpcServerListen\n");
00114    status = RpcServerListen(nMinCalls,
00115                       nMaxCalls,
00116                       bDontWait);
00117    printf("RpcServerListen returned: 0x%x\n", status);
00118    if (status)
00119       Quit(status);
00120
00121    if (bDontWait)
00122    {
00123       printf("Calling RpcMgmtWaitServerListen\n");
00124       status = RpcMgmtWaitServerListen();  // wait operation
00125       printf("RpcMgmtWaitServerListen returned: 0x%x\n", status);
00126       if (status)
00127          Quit(status);
00128    }
00129
00130    free(pszSecurity);
00131 }
00132
00133
00134 // MIDL allocate and free
00135 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00136 {
00137    return(malloc(len));
00138 }
00139
00140
00141 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00142 {
00143    free(ptr);
00144 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/PasswordFilters/PassFilt/PwdFilt.c Source File

  • Security
  • PasswordFilters
  • PassFilt

PwdFilt.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1995 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009    Module Name:
00010
00011        pwdfilt.c
00012
00013    Abstract:
00014
00015        This module illustrates how to implement password change
00016        notification and password filtering in Windows NT 4.0.
00017
00018        Password change notification is useful for synchronization of
00019        non-Windows NT account databases.
00020
00021        Password change filtering is useful for enforcing quality or
00022        strength of passwords in an Windows NT account database.
00023
00024        This sample illustrates one approach to enforcing additional
00025        password quality.
00026
00027    --*/
00028
00029 #include <windows.h>
00030 #include <ntsecapi.h>
00031
00032 #ifndef STATUS_SUCCESS
00033 #define STATUS_SUCCESS  ((NTSTATUS)0x00000000L)
00034 #endif
00035
00036 NTSTATUS
00037 NTAPI
00038 PasswordChangeNotify(
00039                     PUNICODE_STRING UserName,
00040                     ULONG RelativeId,
00041                     PUNICODE_STRING Password
00042                     )
00043 /*++
00044
00045 Routine Description:
00046
00047     This (optional) routine is notified of a password change.
00048
00049 Arguments:
00050
00051     UserName - Name of user whose password changed
00052
00053     RelativeId - RID of the user whose password changed
00054
00055     NewPassword - Cleartext new password for the user
00056
00057 Return Value:
00058
00059     STATUS_SUCCESS only - errors from packages are ignored.
00060
00061 --*/
00062 {
00063
00064 #ifdef DEBUG
00065     LPWSTR String = NULL;
00066     DWORD cbString = 0;
00067
00068     cbString = Password->Length + UserName->Length + (256*sizeof(WCHAR));
00069
00070     String = HeapAlloc(GetProcessHeap(), 0, cbString);
00071
00072     if( String != NULL )
00073     {
00074
00075         //
00076         // don't display the password in the debugger unless absolutely
00077         // necessary -- assume everyone has access to a remote debug session.
00078         //
00079
00080 #if 0
00081         swprintf(String,
00082             L"Password for account %.*ls (rid 0x%x) changed to %.*ls\n",
00083             UserName->Length / sizeof(WCHAR),
00084             UserName->Buffer,
00085             RelativeId,
00086             Password->Length / sizeof(WCHAR),
00087             Password->Buffer
00088             );
00089 #else
00090         swprintf(String,
00091             L"Password for account %.*ls (rid 0x%x) changed\n",
00092             UserName->Length / sizeof(WCHAR),
00093             UserName->Buffer,
00094             RelativeId
00095             );
00096 #endif
00097
00098         OutputDebugStringW( String );
00099
00100         ZeroMemory(String, cbString);
00101         HeapFree(GetProcessHeap(), 0, String);
00102     }
00103 #endif
00104
00105     return STATUS_SUCCESS;
00106 }
00107
00108 BOOL
00109 NTAPI
00110 PasswordFilter(
00111               PUNICODE_STRING UserName,
00112               PUNICODE_STRING FullName,
00113               PUNICODE_STRING Password,
00114               BOOL SetOperation
00115               )
00116 /*++
00117
00118 Routine Description:
00119
00120     This (optional) routine is notified of a password change.
00121
00122 Arguments:
00123
00124     UserName - Name of user whose password changed
00125
00126     FullName - Full name of the user whose password changed
00127
00128     NewPassword - Cleartext new password for the user
00129
00130     SetOperation - TRUE if the password was SET rather than CHANGED
00131
00132 Return Value:
00133
00134     TRUE if the specified Password is suitable (complex, long, etc).
00135      The system will continue to evaluate the password update request
00136      through any other installed password change packages.
00137
00138     FALSE if the specified Password is unsuitable. The password change
00139      on the specified account will fail.
00140
00141 --*/
00142 {
00143    BOOL bComplex = FALSE; // assume the password in not complex enough
00144    DWORD cchPassword;
00145    PWORD CharType;
00146    DWORD i;
00147    DWORD dwNum = 0;
00148    DWORD dwUpper = 0;
00149    DWORD dwLower = 0;
00150
00151
00152    //
00153    // check if the password is complex enough for our liking by
00154    // checking that at least two of the four character types are
00155    // present.
00156    //
00157
00158    CharType = HeapAlloc(GetProcessHeap(), 0, Password->Length);
00159    if (CharType == NULL) return FALSE;
00160
00161    cchPassword = Password->Length / sizeof(WCHAR);
00162
00163    if (GetStringTypeW(
00164                      CT_CTYPE1,
00165                      Password->Buffer,
00166                      cchPassword,
00167                      CharType
00168                      ))
00169    {
00170
00171       for (i = 0 ; i < cchPassword ; i++)
00172       {
00173
00174          //
00175          // keep track of what type of characters we have encountered
00176          //
00177
00178          if (CharType[i] & C1_DIGIT)
00179          {
00180             dwNum = 1;
00181             continue;
00182          }
00183
00184          if (CharType[i] & C1_UPPER)
00185          {
00186             dwUpper = 1;
00187             continue;
00188          }
00189
00190          if (CharType[i] & C1_LOWER)
00191          {
00192             dwLower = 1;
00193             continue;
00194          }
00195
00196          if (!(CharType[i] & (C1_ALPHA | C1_DIGIT) ))
00197          {
00198
00199             //
00200             // any other character types make the password complex
00201             //
00202
00203             dwNum = 2;
00204
00205             break;
00206          }
00207       } // for
00208
00209       //
00210       // Indicate whether we encountered enough password complexity
00211       //
00212
00213       if ( (dwNum + dwUpper + dwLower) >= 2 )
00214          bComplex = TRUE;
00215
00216       ZeroMemory( CharType, Password->Length );
00217    } // if
00218
00219    HeapFree(GetProcessHeap(), 0, CharType);
00220
00221    return bComplex;
00222 }
00223
00224 BOOL
00225 NTAPI
00226 InitializeChangeNotify(
00227                       void
00228                       )
00229 /*++
00230
00231 Routine Description:
00232
00233     This (optional) routine is called when the password change package
00234     is loaded.
00235
00236 Arguments:
00237
00238 Return Value:
00239
00240     TRUE if initialization succeeded.
00241
00242     FALSE if initialization failed. This DLL will be unloaded by the
00243      system.
00244
00245 --*/
00246 {
00247
00248    #ifdef DEBUG
00249    OutputDebugString( TEXT("Initialize Change Notify called!\n") );
00250    #endif
00251
00252    //
00253    // initialize any critical sections associated with password change
00254    // events, etc.
00255    //
00256
00257    return TRUE;
00258 }
00259
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSpecialCharHashTable Member List

This is the complete list of members for CSpecialCharHashTable, including all inherited members.
_aHashTable | CSpecialCharHashTable | [private]
Add(WCHAR *pwszName, WCHAR wch) | CSpecialCharHashTable |
CSpecialCharHashTable() | CSpecialCharHashTable |
Hash(WCHAR *pwszName, unsigned cLen) | CSpecialCharHashTable | [private]
Lookup(WCHAR *pwcInputBuf, unsigned uLen, WCHAR &wch) | CSpecialCharHashTable |
~CSpecialCharHashTable() | CSpecialCharHashTable |
Generated on Wed Nov 13 2024 16:57:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Event_Consumer/Main.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Event_Consumer

Main.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Main.cpp
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 #include "precomp.h"
00017 #include <objbase.h>
00018 #include <stdio.h>
00019 #include <tchar.h>
00020 #include <wbemcli.h>
00021 #include <wbemprov.h>
00022 #include "Globals.h"
00023 #include "Events.h"
00024
00025 /******************************************************************************
00026  *
00027  *  Name: WindowsMainProc
00028  *
00029  *
00030  *  Description:
00031  *
00032  *      Spin processing windows messages
00033  *
00034  *****************************************************************************/
00035
00036 LRESULT CALLBACK WindowsMainProc ( HWND a_hWnd , UINT a_message , WPARAM a_wParam , LPARAM a_lParam )
00037 {
00038   LRESULT t_rc = 0 ;
00039
00040   switch ( a_message )
00041   {
00042     case WM_DESTROY:
00043     {
00044       PostMessage ( a_hWnd , WM_QUIT , 0 , 0 ) ;
00045     }
00046     break ;
00047
00048     default:
00049     {
00050       t_rc = DefWindowProc ( a_hWnd , a_message , a_wParam , a_lParam ) ;
00051     }
00052     break ;
00053   }
00054
00055   return ( t_rc ) ;
00056 }
00057
00058 /******************************************************************************
00059  *
00060  *  Name: WindowsInit
00061  *
00062  *
00063  *  Description:
00064  *
00065  *      Initialize a window so that we can close the app down.
00066  *
00067  *****************************************************************************/
00068
00069 HWND WindowsInit ( HINSTANCE a_HInstance )
00070 {
00071   static wchar_t *t_TemplateCode = L"TemplateCode" ;
00072
00073   WNDCLASS  t_wc ;
00074
00075   t_wc.style            = CS_HREDRAW | CS_VREDRAW ;
00076   t_wc.lpfnWndProc      = WindowsMainProc ;
00077   t_wc.cbClsExtra       = 0 ;
00078   t_wc.cbWndExtra       = 0 ;
00079   t_wc.hInstance        = a_HInstance ;
00080   t_wc.hIcon            = LoadIcon(NULL, IDI_HAND) ;
00081   t_wc.hCursor          = LoadCursor(NULL, IDC_ARROW) ;
00082   t_wc.hbrBackground    = (HBRUSH) (COLOR_WINDOW + 1) ;
00083   t_wc.lpszMenuName     = NULL ;
00084   t_wc.lpszClassName    = t_TemplateCode ;
00085
00086   ATOM t_winClass = RegisterClass ( &t_wc ) ;
00087
00088   HWND t_HWnd = CreateWindow (
00089
00090     t_TemplateCode ,              // see RegisterClass() call
00091     t_TemplateCode ,                      // text for window title bar
00092     WS_OVERLAPPEDWINDOW | WS_MINIMIZE ,               // window style
00093     CW_USEDEFAULT ,                     // default horizontal position
00094     CW_USEDEFAULT ,                     // default vertical position
00095     CW_USEDEFAULT ,                     // default width
00096     CW_USEDEFAULT ,                     // default height
00097     NULL ,                              // overlapped windows have no parent
00098     NULL ,                              // use the window class menu
00099     a_HInstance ,
00100     NULL                                // pointer not needed
00101   ) ;
00102
00103   ShowWindow ( t_HWnd, SW_SHOW ) ;
00104   //ShowWindow ( t_HWnd, SW_HIDE ) ;
00105
00106   return t_HWnd ;
00107 }
00108
00109 /******************************************************************************
00110  *
00111  *  Name: WindowsStop
00112  *
00113  *
00114  *  Description:
00115  *
00116  *      Cleanup window
00117  *
00118  *****************************************************************************/
00119
00120 void WindowsStop ( HWND a_HWnd )
00121 {
00122   DestroyWindow ( a_HWnd ) ;
00123 }
00124
00125 /******************************************************************************
00126  *
00127  *  Name: WindowsStart
00128  *
00129  *
00130  *  Description:
00131  *
00132  *      Initialize windows dependant resources.
00133  *
00134  *****************************************************************************/
00135
00136 HWND WindowsStart ( HINSTANCE a_Handle )
00137 {
00138   HWND t_HWnd = NULL ;
00139   if ( ! ( t_HWnd = WindowsInit ( a_Handle ) ) )
00140   {
00141     }
00142
00143   return t_HWnd ;
00144 }
00145
00146 /******************************************************************************
00147  *
00148  *  Name: WindowsDispatch
00149  *
00150  *
00151  *  Description:
00152  *
00153  *      Standard message pump.
00154  *
00155  *****************************************************************************/
00156
00157 void WindowsDispatch ()
00158 {
00159   BOOL t_GetMessage ;
00160   MSG t_lpMsg ;
00161
00162   while ( ( t_GetMessage = GetMessage ( & t_lpMsg , NULL , 0 , 0 ) ) == TRUE )
00163   {
00164     TranslateMessage ( & t_lpMsg ) ;
00165     DispatchMessage ( & t_lpMsg ) ;
00166   }
00167 }
00168
00169 /******************************************************************************
00170  *
00171  *  Name: UninitComServer
00172  *
00173  *
00174  *  Description:
00175  *
00176  *      Uninitialize COM dependant resources,
00177  *
00178  *****************************************************************************/
00179
00180 HRESULT UninitComServer ()
00181 {
00182   CoUninitialize () ;
00183
00184   return S_OK ;
00185 }
00186
00187 /******************************************************************************
00188  *
00189  *  Name: InitComServer
00190  *
00191  *
00192  *  Description:
00193  *
00194  *      Initialize COM dependant resources.
00195  *
00196  *****************************************************************************/
00197
00198 HRESULT InitComServer ( DWORD a_AuthenticationLevel , DWORD a_ImpersonationLevel )
00199 {
00200   HRESULT t_Result = S_OK ;
00201
00202     t_Result = CoInitializeEx (
00203
00204     0,
00205     COINIT_MULTITHREADED
00206   );
00207
00208 #ifndef EOAC_DYNAMIC_CLOAKING
00209 #define EOAC_DYNAMIC_CLOAKING 0x40
00210 #endif
00211
00212   if ( SUCCEEDED ( t_Result ) )
00213   {
00214
00215     DWORD dwCapabilities;
00216     if (a_AuthenticationLevel == RPC_C_AUTHN_LEVEL_NONE)
00217       dwCapabilities = EOAC_NONE;
00218     else
00219       dwCapabilities = EOAC_SECURE_REFS;
00220
00221
00222     t_Result = CoInitializeSecurity (
00223
00224       NULL,
00225       -1,
00226       NULL,
00227       NULL,
00228       a_AuthenticationLevel,
00229       a_ImpersonationLevel,
00230       NULL,
00231       EOAC_DYNAMIC_CLOAKING | dwCapabilities,
00232       0
00233     );
00234
00235     if ( FAILED ( t_Result ) )
00236     {
00237       CoUninitialize () ;
00238       return t_Result ;
00239     }
00240   }
00241
00242   if ( FAILED ( t_Result ) )
00243   {
00244     CoUninitialize () ;
00245   }
00246
00247   return t_Result  ;
00248 }
00249
00250 /******************************************************************************
00251  *
00252  *  Name: RegisterDecoupledEventConsumer
00253  *
00254  *
00255  *  Description:
00256  *
00257  *      Register a decoupled event consumer object with WMI.
00258  *      We pass in an implementation of IWbemEventConsumerProvider so
00259  *      that WMI can forward events.
00260  *
00261  *****************************************************************************/
00262
00263 HRESULT RegisterDecoupledEventConsumer (
00264
00265   IWbemDecoupledRegistrar *&a_Registrar
00266 )
00267 {
00268 /*
00269  *  Cleanup out arguments
00270  */
00271
00272   a_Registrar = NULL ;
00273
00274 /*
00275  *  Create the event registrar, so that we can register with WMI.
00276  */
00277
00278   HRESULT t_Result = Provider_Globals :: CreateInstance (
00279
00280     CLSID_WbemDecoupledRegistrar ,
00281     NULL ,
00282     CLSCTX_INPROC_SERVER ,
00283     IID_IWbemDecoupledRegistrar ,
00284     ( void ** ) & a_Registrar
00285   ) ;
00286
00287   if ( SUCCEEDED ( t_Result ) )
00288   {
00289 /*
00290  *  Create our implementation instance of the event consumer
00291  */
00292
00293     CProvider_IWbemEventConsumerProvider *t_Consumer = new CProvider_IWbemEventConsumerProvider ;
00294     if ( t_Consumer )
00295     {
00296       t_Consumer->AddRef () ;
00297
00298       IUnknown *t_Unknown = NULL ;
00299       t_Result = t_Consumer->QueryInterface ( IID_IUnknown , ( void ** ) & t_Unknown ) ;
00300       if ( SUCCEEDED ( t_Result ) )
00301       {
00302 /*
00303  *  Register the provider inteface with WMI, specifying the namespace and provider instance of __Win32provider
00304  */
00305
00306         t_Result = a_Registrar->Register (
00307
00308           0 ,
00309           NULL ,
00310           NULL ,
00311           NULL ,
00312           L"root\\cimv2" ,
00313           L"DecoupledEventConsumer" ,
00314           t_Unknown
00315         ) ;
00316
00317         t_Unknown->Release () ;
00318       }
00319
00320       t_Consumer->Release () ;
00321     }
00322   }
00323
00324   if ( FAILED ( t_Result ) )
00325   {
00326     if ( a_Registrar )
00327     {
00328       a_Registrar->Release () ;
00329       a_Registrar = NULL ;
00330     }
00331   }
00332
00333   return t_Result ;
00334 }
00335
00336 /******************************************************************************
00337  *
00338  *  Name:   Process_DecoupledEventConsumer
00339  *
00340  *
00341  *  Description:
00342  *
00343  *        Register the provider and just sit spinning until the
00344  *        application window is destroyed.
00345  *
00346  *****************************************************************************/
00347
00348 HRESULT Process_DecoupledEventConsumer ()
00349 {
00350   IWbemDecoupledRegistrar *t_EventConsumerRegistrar = NULL ;
00351
00352   HRESULT t_Result = RegisterDecoupledEventConsumer ( t_EventConsumerRegistrar ) ;
00353   if ( SUCCEEDED ( t_Result ) )
00354   {
00355     WindowsDispatch () ;
00356   }
00357
00358   if ( t_EventConsumerRegistrar )
00359   {
00360     t_EventConsumerRegistrar->UnRegister () ;
00361     t_EventConsumerRegistrar->Release () ;
00362   }
00363
00364   return t_Result ;
00365 }
00366
00367
00368 /******************************************************************************
00369  *
00370  *  Name: Process
00371  *
00372  *
00373  *  Description:
00374  *
00375  *      Main work routine, initialize com components and performs
00376  *      event consumer dispatch loop.
00377  *
00378  *****************************************************************************/
00379
00380 HRESULT Process ()
00381 {
00382   DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
00383   DWORD t_AuthenticationLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
00384
00385   HRESULT t_Result = InitComServer ( t_AuthenticationLevel , t_ImpersonationLevel ) ;
00386   if ( SUCCEEDED ( t_Result ) )
00387   {
00388     try
00389     {
00390       t_Result = Process_DecoupledEventConsumer () ;
00391     }
00392     catch ( ... )
00393     {
00394     }
00395
00396     UninitComServer () ;
00397   }
00398
00399   return t_Result ;
00400 }
00401
00402 /******************************************************************************
00403  *
00404  *  Name: Main
00405  *
00406  *
00407  *  Description:
00408  *
00409  *    Main entry point, initialize global resources, windows components and then
00410  *    perform provider work.
00411  *
00412  *****************************************************************************/
00413
00414 int WINAPI WinMain (
00415
00416     HINSTANCE hInstance,    // handle to current instance
00417     HINSTANCE hPrevInstance,  // handle to previous instance
00418     LPSTR lpCmdLine,      // pointer to command line
00419     int nShowCmd        // show state of window
00420 )
00421 {
00422   HRESULT t_Result = Provider_Globals :: Global_Startup () ;
00423   if ( SUCCEEDED ( t_Result ) )
00424   {
00425     HWND t_Window = WindowsStart ( hInstance ) ;
00426     if ( t_Window )
00427     {
00428       t_Result = Process () ;
00429
00430       WindowsStop ( t_Window ) ;
00431     }
00432
00433     t_Result = Provider_Globals :: Global_Shutdown () ;
00434   }
00435
00436   return 0 ;
00437 }
00438
00439
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCShip/Ship.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCShip

Ship.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Ship.h
00003   Summary:   Declaration of COShip class
00004   Classes:   Declared: COShip
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #ifndef __SHIP_H_
00023 #define __SHIP_H_
00024
00025 #include "resource.h"       // main symbols
00026 #include "..\QCNotify\QCNotify.h"
00027
00028 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00029   ObjectClass: COShip
00030   Summary:     Writes order to shipping database.
00031          Assigns shipping status to each line item.
00032          Creates Notify object to inform requestor of shipping status.
00033   Interfaces:  IUnknown       Standard COM object feature interface
00034                IDispatch      Automation interface
00035              IShip        Represents an order
00036   Aggregation: Not supported
00037 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00038
00039 class ATL_NO_VTABLE COShip :
00040   public CComObjectRootEx<CComSingleThreadModel>,
00041   public CComCoClass<COShip, &CLSID_Ship>,
00042   public IDispatchImpl<IShip, &IID_IShip, &LIBID_QCSHIPLib>
00043 {
00044 public:
00045   COShip() : m_lCustomerId(0), m_lOrderId(0)
00046   {
00047   }
00048
00049 DECLARE_REGISTRY_RESOURCEID(IDR_SHIP)
00050 DECLARE_NOT_AGGREGATABLE(COShip)
00051
00052 BEGIN_COM_MAP(COShip)
00053   COM_INTERFACE_ENTRY(IShip)
00054   COM_INTERFACE_ENTRY(IDispatch)
00055 END_COM_MAP()
00056
00057 public: // IOrder
00058   STDMETHOD(Process)(long lFlags);
00059   STDMETHOD(LineItem)(long lItemId, long lQuantity);
00060   STDMETHOD(put_OrderId)(long lOrderId);
00061   STDMETHOD(put_CustomerId)(long lCustomerId);
00062
00063 private:
00064   long          m_lCustomerId;
00065   long          m_lOrderId;
00066   std::vector<long>   m_veclItemId;
00067   std::vector<long>   m_veclQuantity;
00068   std::vector<ShipStatus> m_vecShipStatus;
00069
00070   HRESULT   WriteShipDB();
00071   HRESULT   NotifyRequestor(long lFlags);
00072   HRESULT   InvokeNotifyIDispatch(IUnknown * punk, long lFlags);
00073   HRESULT   InvokeNotifyVtable(IUnknown * punk, long lFlags);
00074   ShipStatus  RandomShipStatus();
00075 };
00076
00077 #endif //__SHIP_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/ToolBar.h Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

ToolBar.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // PURPOSE:
00009 //    Contains declarations for the toolbar module.
00010 //
00011
00012 //-------------------------------------------------------------------------
00013 #define IDM_TOOLBAR         500 // ID for the toolbar.
00014 #define IDB_BMP             700 // Bitmap ID for the toolbar.
00015
00016 // Global variable for Toolbar window
00017 extern HWND hWndToolbar;
00018
00019 // Function protoptype for Creating Toolbar
00020 BOOL CreateTBar(HWND);
00021 void EnableMakeCall(HWND hWnd, BOOL bEnable);
00022 void EnableHangupCall(HWND hWnd, BOOL bEnable);
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

DOREGSTRUCT Member List

This is the complete list of members for DOREGSTRUCT, including all inherited members.
hRootKey | DOREGSTRUCT
lpszValueName | DOREGSTRUCT
szData | DOREGSTRUCT
szSubKey | DOREGSTRUCT
szSubKey | DOREGSTRUCT
szValue | DOREGSTRUCT
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/c_draw/StdAfx.h Source File

  • NetDS
  • MessageQueuing
  • c_draw

StdAfx.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 //
00013 // stdafx.h : include file for standard system include files,
00014 //  or project specific include files that are used frequently, but
00015 //      are changed infrequently
00016 //
00017
00018 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00019
00020 #include <afxwin.h>         // MFC core and standard components
00021 #include <afxext.h>         // MFC extensions
00022 #ifndef _AFX_NO_AFXCMN_SUPPORT
00023 #include <afxcmn.h>     // MFC support for Windows 95 Common Controls
00024 #endif // _AFX_NO_AFXCMN_SUPPORT
00025
00026 #include <afxtempl.h>   // MFC collection classes
00027 #include <afxole.h>     // MFC OLE support
00028
00029 #include "mq.h"       // MSMQ
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/GUIDRAW.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

GUIDRAW.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUIDRAW.CPP
00003
00004   Summary:   Implementation file for the CGuiDraw C++ class. A GuiDraw is
00005              a C++ object that is anchored to the Windows GUI (Graphical
00006              User Interface) environment--it retains knowledge of window
00007              handles and device contexts in the current application. This
00008              GuiDraw object relies on a drawing object for storage of the
00009              drawing data. This drawing page object (a CODrawPage object)
00010              is instantiated as a COM object in a separate In-process
00011              server, PERDRAW.
00012
00013              For a comprehensive tutorial code tour of GUIDRAW's contents
00014              and offerings see the tutorial PERCLIEN.HTM file. For more
00015              specific technical details on the internal workings see the
00016              comments dispersed throughout the GUIDRAW source code.
00017
00018   Classes:   CGuiDraw.
00019
00020   Origin:    5-20-97: atrent - Editor inheritance from GUIPAPER.CPP in the
00021              STOCLIEN source.
00022
00023 ----------------------------------------------------------------------------
00024   This file is part of the Microsoft COM Tutorial Code Samples.
00025
00026   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00027
00028   This source code is intended only as a supplement to Microsoft
00029   Development Tools and/or on-line documentation.  See these other
00030   materials for detailed information regarding Microsoft code samples.
00031
00032   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00033   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00034   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00035   PARTICULAR PURPOSE.
00036 ==========================================================================+*/
00037
00038 /*--------------------------------------------------------------------------
00039   We include WINDOWS.H for all Win32 applications.
00040   We include OLE2.H because we will be calling the COM/OLE Libraries.
00041   We include OLECTL.H because it has definitions for connectable objects.
00042   We include COMMDLG.H because we will be using the Open File,
00043     Choose Color, and potentially other Common dialogs.
00044   We include APPUTIL.H because we will be building this application using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IPAGES.H and PAGEGUID.H for the common drawing-related
00048     Interface class, GUID, and CLSID specifications.
00049   We include RESDEF.H because it has the resource definitions specific
00050     to this application.
00051   We include GUIDRAW.H because it has the C++ class used for GUI display
00052     of the drawing page.
00053   We include DRAWSINK.H because it has the C++ class used for the sink that
00054     receives event notifications from the CODrawPage object in the server.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <olectl.h>
00059 #include <apputil.h>
00060 #include <ipages.h>
00061 #include <pageguid.h>
00062 #include "resdef.h"
00063 #include "guidraw.h"
00064 #include "drawsink.h"
00065
00066
00067 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00068   Method:   CGuiDraw::CGuiDraw
00069
00070   Summary:  Constructor.
00071
00072   Args:     void
00073
00074   Returns:  void
00075 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00076 CGuiDraw::CGuiDraw(HINSTANCE hInst, HWND hWndApp, INT iPage)
00077 {
00078   m_hInst           = hInst;
00079   m_hWndApp         = hWndApp;
00080   m_iPage           = iPage;
00081   m_hWnd            = NULL;
00082   m_wszDataName[0]  = 0;
00083   m_pIStorage_Root  = NULL;
00084   m_pIStorage_Page  = NULL;
00085   m_pIDrawPage      = NULL;
00086   m_hDC             = NULL;
00087   m_hPen            = NULL;
00088   m_nInkWidth       = INK_THIN;
00089   m_crInkColor      = RGB(0,0,0);
00090   m_bInkSaving      = FALSE;
00091   m_bInking         = FALSE;
00092   m_bPainting       = FALSE;
00093   m_OldPos.x        = 0;
00094   m_OldPos.y        = 0;
00095   m_pCODrawPageSink = NULL;
00096   m_dwDrawPageSink  = 0;
00097
00098   // Save the ClassID of DrawPages using an overloaded '=' operator.
00099   m_CidDrawPage = CLSID_DrawPage;
00100 }
00101
00102
00103 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00104   Method:   CGuiDraw::~CGuiDraw
00105
00106   Summary:  Destructor.
00107
00108   Args:     void
00109
00110   Returns:  void
00111 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00112 CGuiDraw::~CGuiDraw(void)
00113 {
00114   // CGuiDraw is derived from CVirWindow which traps the WM_DESTROY
00115   // message and causes a delete of CGuiDraw which in turn causes this
00116   // destructor to run. The WM_DESTROY results when the window is destoyed
00117   // after a close of the window.
00118
00119   // Just to make sure, turn off Ink Saving.
00120   m_bInkSaving = FALSE;
00121
00122   // Disconnect the Sink in the client from the connection points in
00123   // the server.
00124   DisconnectSink();
00125
00126   // Delete the Pen object.
00127   if (m_hPen)
00128     DeleteObject(m_hPen);
00129
00130   // Release the interface held on the DrawPageSink object.
00131   RELEASE_INTERFACE(m_pCODrawPageSink);
00132
00133   // Destroy the existing CODrawPage by releasing the IDrawPage interface.
00134   RELEASE_INTERFACE(m_pIDrawPage);
00135
00136   // Release the interface held on the page's storage.
00137   RELEASE_INTERFACE(m_pIStorage_Page);
00138
00139   // Release the interface held on the root storage.
00140   RELEASE_INTERFACE(m_pIStorage_Root);
00141
00142   // Tell main app that this text page is gone.
00143   PostMessage(m_hWndApp, WM_USER_PAGECLOSED, 0, m_iPage);
00144 }
00145
00146
00147 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00148   Method:   CGuiDraw::Load
00149
00150   Summary:  Load DrawPage data from the appropriate substorage under
00151             the root storage. If there is no existing substorage then
00152             create and initialize a new one.
00153
00154   Args:     void.
00155
00156   Returns:  HRESULT
00157               Standard result code. NOERROR for success.
00158 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00159 HRESULT CGuiDraw::Load(void)
00160 {
00161   HRESULT hr = E_FAIL;
00162   IPersistStorage* pIPersistStorage;
00163
00164   // Can't do anything without a root storage.
00165   if (NULL != m_pIStorage_Root)
00166   {
00167     // Use the root IStorage to open the nested substorage for this
00168     // particular DrawPage. Load the drawing data from the substorage.
00169     // This load internally uses the IPersistStorage features in a
00170     // created CODrawPage object to reconstitute the object from
00171     // persistent storage. CODrawPage handles its own persistence that
00172     // is client-controlled via its exposed IPersistStorage interface.
00173
00174     // Open the single storage named by m_wszDataName. It is under
00175     // the root storage. The client here is in charge of the underlying
00176     // storage that the client asks CODrawPage to use.
00177     hr = m_pIStorage_Root->OpenStorage(
00178            m_wszDataName,
00179            NULL,
00180            STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00181            NULL,
00182            0,
00183            &m_pIStorage_Page);
00184     if (SUCCEEDED(hr))
00185     {
00186       // If the storage already exists, read the ClassID for the class of
00187       // component objects that can deal with DrawPage data.
00188       hr = ReadClassStg(m_pIStorage_Page, &m_CidDrawPage);
00189       if (SUCCEEDED(hr))
00190       {
00191         // Now use the obtained Class ID to create a CODrawPage
00192         // object. Initially ask for the IDrawPage interface.
00193         hr = CoCreateInstance(
00194                m_CidDrawPage,
00195                NULL,
00196                CLSCTX_INPROC_SERVER,
00197                IID_IDrawPage,
00198                (PPVOID)&m_pIDrawPage);
00199         if (SUCCEEDED(hr))
00200         {
00201           // We have a new CODrawPage object. Now obtain the
00202           // IPersistStorage interface on it. At this point in the
00203           // client we are assuming that CODrawPage objects use only
00204           // the IPersistStorage interface for their persistence.
00205           hr = m_pIDrawPage->QueryInterface(
00206                  IID_IPersistStorage,
00207                  (PPVOID)&pIPersistStorage);
00208           if (SUCCEEDED(hr))
00209           {
00210             // And as expected by this client, CODrawPage exposes
00211             // the IPersistStorage interface. Now use this interface
00212             // to ask the CODrawPage object to load the drawing data.
00213             hr = pIPersistStorage->Load(m_pIStorage_Page);
00214
00215             // Done with IPersistStorage for now so release it.
00216             pIPersistStorage->Release();
00217           }
00218         }
00219       }
00220     }
00221     else
00222     {
00223       // If there was no existing page substorage then create a new one.
00224       hr = m_pIStorage_Root->CreateStorage(
00225              m_wszDataName,
00226              STGM_CREATE | STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00227              0,
00228              0,
00229              &m_pIStorage_Page);
00230       if (SUCCEEDED(hr))
00231       {
00232         // Write the ClassID of the CODrawPage component object class.
00233         hr = WriteClassStg(m_pIStorage_Page, m_CidDrawPage);
00234         if (SUCCEEDED(hr))
00235         {
00236           // Now use the Class ID to create a CODrawPage
00237           // object. Initially ask for the IDrawPage interface.
00238           hr = CoCreateInstance(
00239                  m_CidDrawPage,
00240                  NULL,
00241                  CLSCTX_INPROC_SERVER,
00242                  IID_IDrawPage,
00243                  (PPVOID)&m_pIDrawPage);
00244           if (SUCCEEDED(hr))
00245           {
00246             // We have a new CODrawPage object. Now obtain the
00247             // IPersistStorage interface on it. At this point in the
00248             // client we are assuming that CODrawPage objects use only
00249             // the IPersistStorage interface for their persistence.
00250             hr = m_pIDrawPage->QueryInterface(
00251                    IID_IPersistStorage,
00252                    (PPVOID)&pIPersistStorage);
00253             if (SUCCEEDED(hr))
00254             {
00255               // And as expected by this client, CODrawPage supports
00256               // the IPersistStorage interface. Now use this interface
00257               // to ask the CODrawPage object to initialize a new empty
00258               // drawing page and save it into the substorage.
00259               hr = pIPersistStorage->InitNew(m_pIStorage_Page);
00260
00261               // Done with IPersistStorage for now so release it.
00262               pIPersistStorage->Release();
00263             }
00264           }
00265         }
00266
00267         if (FAILED(hr))
00268           m_pIStorage_Page->DestroyElement(m_wszDataName);
00269       }
00270     }
00271   }
00272
00273   return hr;
00274 }
00275
00276
00277 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00278   Method:   CGuiDraw::OpenWin
00279
00280   Summary:  Get CGuiDraw started. Make any subordinate objects, like
00281             CODrawPage and get them started. Create the window. Read the
00282             page's drawing data from the specified root storage using the
00283             specified substorage name.
00284
00285   Args:     IStorage* pIStorage_Root,
00286               Root storage of the compound file containing the drawing
00287               page.
00288             WCHAR* pwszPageTitle,
00289               The user-displayable title for the drawing page. Generally
00290               used in the window's title bar.
00291             WCHAR* pwszDataName)
00292               The internal storage name of the substorage holding the
00293               drawing page.
00294
00295   Returns:  HRESULT
00296               Standard result code. NOERROR for success.
00297 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00298 HRESULT CGuiDraw::OpenWin(
00299           IStorage* pIStorage_Root,
00300           WCHAR* pwszPageTitle,
00301           WCHAR* pwszDataName)
00302 {
00303   HRESULT hr = E_FAIL;
00304   HWND hWnd = NULL;
00305   CODrawPageSink* pCobSink = NULL;
00306   HCURSOR hCurPrev;
00307   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00308   TCHAR szTitle[32+PAGE_TITLE_SIZE];
00309
00310   if (m_hInst && m_hWndApp && pwszDataName)
00311   {
00312     // Change cursor to the hour glass. This open could take awhile.
00313     hCurPrev = SetCursor(hCurWait);
00314
00315     // Set title string empty to start.
00316     szTitle[0] = 0;
00317
00318     lstrcpyn(szTitle, TEXT(DRAW_WINDOW_NAME_STR), sizeof(szTitle)/
00319       sizeof(TCHAR));
00320 #if defined(UNICODE)
00321     if (NULL != pwszPageTitle)
00322       lstrncat(szTitle, pwszPageTitle, sizeof(szTitle)/sizeof(TCHAR) -
00323         lstrlen(szTitle));
00324     lstrcpyn(m_wszDataName, pwszDataName, sizeof(m_wszDataName)/
00325       sizeof(TCHAR));
00326 #else
00327     {
00328       CHAR szAnsi[PAGE_TITLE_SIZE];
00329
00330       // Convert PageTitle from Unicode to Ansi.
00331       if (NULL != pwszPageTitle)
00332       {
00333         UcToAnsi(pwszPageTitle, szAnsi, PAGE_TITLE_SIZE);
00334         lstrncat(szTitle, szAnsi, sizeof(szTitle)/sizeof(TCHAR) -
00335           lstrlen(szTitle));
00336       }
00337       // Copy/save DataName.
00338       memcpy(m_wszDataName, pwszDataName, PAGE_NAME_SIZE*sizeof(WCHAR));
00339     }
00340 #endif
00341     // Create the main GuiDraw Window. Size the window reasonably. The
00342     // Create method sets both m_hInst and m_hWnd.
00343     hWnd = Create(
00344              TEXT(DRAW_WINDOW_CLASS_NAME_STR),
00345              szTitle,
00346              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00347                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00348              CW_USEDEFAULT,
00349              CW_USEDEFAULT,
00350              ::GetSystemMetrics(SM_CXSCREEN)*1/3,
00351              ::GetSystemMetrics(SM_CYSCREEN)*1/3,
00352              m_hWndApp,
00353              NULL,
00354              m_hInst);
00355     if (NULL != hWnd)
00356     {
00357       // Get and save our private display Device Context.
00358       m_hDC = GetDC(hWnd);
00359
00360       // Save an interface pointer to the root IStorage and AddRef it.
00361       m_pIStorage_Root = pIStorage_Root;
00362       m_pIStorage_Root->AddRef();
00363
00364       // Now use CGuiDraw::Load to load the drawing window from the named
00365       // substorage under the root storage. This either opens and loads
00366       // the existing substorage or creates a new one.
00367       hr = Load();
00368       if (SUCCEEDED(hr))
00369       {
00370         // We loaded or created the Drawing Page storage and have a
00371         // CODrawPage component to manage the loaded drawing data.
00372
00373         // Create the CODrawPageSink object to receive DrawPage events.
00374         pCobSink = new CODrawPageSink(NULL, this);
00375         if (NULL != pCobSink)
00376         {
00377           // Save a pointer to the CODrawPageSink IUnknown interface.
00378           // AddRef because of this saved copy. Released in destructor.
00379           m_pCODrawPageSink = pCobSink;
00380           m_pCODrawPageSink->AddRef();
00381
00382           // If we created and reconstituted a CODrawPage object from a
00383           // persistent storage, then connect the sinks in the client
00384           // to the connection sources in the server.
00385           hr = ConnectSink();
00386
00387           // Ensure the new window is shown on screen.
00388           ::ShowWindow(m_hWnd, SW_SHOWNORMAL);
00389           ::UpdateWindow(m_hWnd);
00390         }
00391         else
00392           hr = E_OUTOFMEMORY;
00393       }
00394
00395       if (SUCCEEDED(hr))
00396       {
00397         // We can now allow ink saving as well.
00398         m_bInkSaving = TRUE;
00399       }
00400       else
00401       {
00402         // If can't open, display an error dialog and close this window.
00403         HrMsgId(m_hInst, m_hWnd, IDS_OPENDRAWPAGE, hr);
00404         PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00405       }
00406     }
00407
00408     // Set Cursor from hourglass back to what it was.
00409     SetCursor(hCurPrev);
00410   }
00411
00412   return (hr);
00413 }
00414
00415
00416 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00417   Method:   CGuiDraw::TopWin
00418
00419   Summary:  Bring this GuiDraw window to the top over any other windows
00420             that are on-screen.
00421
00422   Args:     void.
00423
00424   Returns:  HRESULT
00425               Standard result code. NOERROR for success.
00426 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00427 HRESULT CGuiDraw::TopWin(
00428           void)
00429 {
00430   HRESULT hr = E_FAIL;
00431
00432   if (IsWindow(m_hWnd))
00433   {
00434     BringWindowToTop(m_hWnd);
00435     hr = NOERROR;
00436   }
00437
00438   return hr;
00439 }
00440
00441
00442 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00443   Method:   CGuiDraw::ResizeWin
00444
00445   Summary:  Resizes current drawing page rectangle.
00446
00447   Args:     WORD wWidth
00448               New window width. Max X coord.
00449             WORD wHeight
00450               New window height. Max Y coord.
00451
00452   Returns:  HRESULT
00453               Standard result code. NOERROR for success.
00454 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00455 HRESULT CGuiDraw::ResizeWin(
00456                      WORD wWidth,
00457                      WORD wHeight)
00458 {
00459   HRESULT hr;
00460
00461   // Store the new window size.
00462   m_WinRect.right = wWidth;
00463   m_WinRect.bottom = wHeight;
00464
00465   // Tell CODrawPage about new size.
00466   hr = m_pIDrawPage->Resize(wWidth, wHeight);
00467
00468   return hr;
00469 }
00470
00471
00472 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00473   Method:   CGuiDraw::ClearWin
00474
00475   Summary:  Clear display window but don't delete drawn data.
00476
00477   Args:     void.
00478
00479   Returns:  HRESULT
00480               Standard result code. NOERROR for success.
00481 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00482 HRESULT CGuiDraw::ClearWin(void)
00483 {
00484   HRESULT hr = E_FAIL;
00485   RECT WinRect;
00486
00487   if(!m_bInking)
00488   {
00489     // Get our window's client area rectangle.
00490     GetClientRect(m_hWnd, &WinRect);
00491
00492     // Fill that rectangle with pixels of default white paint.
00493     FillRect(m_hDC, &WinRect, GETCLASSBRUSH(m_hWnd));
00494
00495     hr = NOERROR;
00496   }
00497
00498   return hr;
00499 }
00500
00501
00502 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00503   Method:   CGuiDraw::PaintWin
00504
00505   Summary:  Clears window background and repaints the current drawing in
00506             the window. Relies on connectable object technology. The
00507             Redraw method in the CODrawPage object sends event
00508             notifications to this client in order to achieve a repaint of
00509             the drawing. CGuiDraw does not have a copy of the drawing
00510             data--only the CODrawPage component in the server has that
00511             in a potentially shared central location.
00512
00513   Args:     void
00514
00515   Returns:  HRESULT
00516               Standard result code. NOERROR for success.
00517 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00518 HRESULT CGuiDraw::PaintWin(void)
00519 {
00520   HRESULT hr = E_FAIL;
00521   COLORREF crInkColor;
00522   SHORT nInkWidth;
00523
00524   if (m_pIDrawPage && !m_bPainting && !m_bInking)
00525   {
00526     m_bPainting = TRUE;
00527     // Save and restore ink color and width since redraw otherwise
00528     // ends up changing these values in CGuiDraw.
00529     crInkColor = m_crInkColor;
00530     nInkWidth = m_nInkWidth;
00531     hr = m_pIDrawPage->Redraw();
00532     m_nInkWidth = nInkWidth;
00533     m_crInkColor = crInkColor;
00534     m_bPainting = FALSE;
00535   }
00536
00537   return hr;
00538 }
00539
00540
00541 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00542   Method:   CGuiDraw::InkSaving
00543
00544   Summary:  Tell CGuiDraw whether ink data is being saved in the DrawPage
00545             object.
00546
00547   Args:     BOOL bInkSaving
00548               TRUE means save in CODrawPage object; FALSE means not.
00549
00550   Returns:  HRESULT
00551               Standard result code. NOERROR for success.
00552 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00553 HRESULT CGuiDraw::InkSaving(
00554           BOOL bInkSaving)
00555 {
00556   m_bInkSaving = bInkSaving;
00557
00558   return NOERROR;
00559 }
00560
00561
00562 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00563   Method:   CGuiDraw::InkWidth
00564
00565   Summary:  Changes current ink line width.
00566
00567   Args:     SHORT nInkWidth
00568               New ink line width in pixels.
00569
00570   Returns:  HRESULT
00571               Standard result code. NOERROR for success.
00572 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00573 HRESULT CGuiDraw::InkWidth(
00574           SHORT nInkWidth)
00575 {
00576   if (nInkWidth)
00577     m_nInkWidth = nInkWidth;
00578
00579   return NOERROR;
00580 }
00581
00582
00583 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00584   Method:   CGuiDraw::InkColor
00585
00586   Summary:  Changes current ink color.
00587
00588   Args:     COLORREF crInkColor
00589               RGB color ref value (eg, RGB(0,0,0) is black).
00590
00591   Returns:  HRESULT
00592               Standard result code. NOERROR for success.
00593 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00594 HRESULT CGuiDraw::InkColor(
00595           COLORREF crInkColor)
00596 {
00597   m_crInkColor = crInkColor;
00598
00599   return NOERROR;
00600 }
00601
00602
00603 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00604   Method:   CGuiDraw::InkStart
00605
00606   Summary:  Starts an ink drawing sequence at the specified coordinates in
00607             the current color with the current width.
00608
00609   Args:     SHORT nX,
00610               X coordinate in window rectangle of start point.
00611             SHORT nY
00612               Y coordinate in window rectangle of start point.
00613
00614   Returns:  HRESULT
00615               Standard result code. NOERROR for success.
00616 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00617 HRESULT CGuiDraw::InkStart(
00618                      SHORT nX,
00619                      SHORT nY)
00620 {
00621   HRESULT hr = E_FAIL;
00622
00623   // Start an ink drawing sequence only if one is not in progress.
00624   if (!m_bInking)
00625   {
00626     // Remember start position.
00627     m_OldPos.x = nX;
00628     m_OldPos.y = nY;
00629
00630     // Delete old pen.
00631     if (m_hPen)
00632       DeleteObject(m_hPen);
00633
00634     // Create and select the new drawing pen.
00635     m_hPen = CreatePen(PS_SOLID, m_nInkWidth, m_crInkColor);
00636     SelectObject(m_hDC, m_hPen);
00637
00638     hr = NOERROR;
00639
00640     // Ask the DrawPage object to mark the start of the ink drawing
00641     // sequence in the current ink color.
00642     if (m_pIDrawPage && m_bInkSaving)
00643     {
00644       // Save this start point in CODrawPage.
00645       hr = m_pIDrawPage->InkStart(nX, nY, m_nInkWidth, m_crInkColor);
00646       // Capture the Mouse.
00647       SetCapture(m_hWnd);
00648       // Tell main app this page was changed.
00649       PostMessage(m_hWndApp, WM_USER_PAGECHANGED, 0, m_iPage);
00650     }
00651
00652     // Set inking flag to TRUE.
00653     m_bInking = TRUE;
00654   }
00655
00656   return hr;
00657 }
00658
00659
00660 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00661   Method:   CGuiDraw::InkDraw
00662
00663   Summary:  Draws and saves ink data during the currently active ink
00664             drawing sequence.
00665
00666   Args:     SHORT nX,
00667               X coordinate in window rectangle of start point.
00668             SHORT nY
00669               Y coordinate in window rectangle of start point.
00670
00671   Returns:  HRESULT
00672               Standard result code. NOERROR for success.
00673 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00674 HRESULT CGuiDraw::InkDraw(
00675                      SHORT nX,
00676                      SHORT nY)
00677 {
00678   if (m_bInking)
00679   {
00680     // Start this ink line at previous old position.
00681     MoveToEx(m_hDC, m_OldPos.x, m_OldPos.y, NULL);
00682
00683     // Assign new old position and draw the new line.
00684     LineTo(m_hDC, m_OldPos.x = nX, m_OldPos.y = nY);
00685
00686     // Ask the DrawPage object to save this data.
00687     if (m_bInkSaving)
00688       m_pIDrawPage->InkDraw(nX, nY);
00689   }
00690
00691   return NOERROR;
00692 }
00693
00694
00695 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00696   Method:   CGuiDraw::InkStop
00697
00698   Summary:  Stops the currently active ink drawing sequence.
00699
00700   Args:     SHORT nX,
00701               X coordinate in window rectangle of start point.
00702             SHORT nY
00703               Y coordinate in window rectangle of start point.
00704
00705   Returns:  HRESULT
00706               Standard result code. NOERROR for success.
00707 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00708 HRESULT CGuiDraw::InkStop(
00709                      SHORT nX,
00710                      SHORT nY)
00711 {
00712   if (m_bInking)
00713   {
00714     // Start this ink line at previous old position.
00715     MoveToEx(m_hDC, m_OldPos.x, m_OldPos.y, NULL);
00716
00717     // Draw the last line.
00718     LineTo(m_hDC, nX, nY);
00719
00720     // Turn off inking.
00721     m_bInking = FALSE;
00722
00723     // Ask the DrawPage object to mark the stop of the ink drawing sequence.
00724     if (m_bInkSaving)
00725     {
00726       m_pIDrawPage->InkStop(nX, nY);
00727       // Free the mouse.
00728       ReleaseCapture();
00729     }
00730   }
00731
00732   return NOERROR;
00733 }
00734
00735
00736 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00737   Method:   CGuiDraw::Renumber
00738
00739   Summary:  Re-assign the current dynamic page number for this page.
00740
00741   Args:     INT iPage
00742               New page number.
00743
00744   Returns:  HRESULT
00745               Standard result code. NOERROR for success.
00746 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00747 HRESULT CGuiDraw::Renumber(
00748           INT iPage)
00749 {
00750   HRESULT hr = NOERROR;
00751
00752   m_iPage = iPage;
00753
00754   return hr;
00755 }
00756
00757
00758 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00759   Method:   CGuiDraw::ReleasePage
00760
00761   Summary:  Release all substorages for the draw page. Sets the CODrawPage
00762             object to the HandsOff state.
00763
00764   Args:     none.
00765
00766   Returns:  HRESULT
00767               Standard result code. NOERROR for success.
00768 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00769 HRESULT CGuiDraw::ReleasePage(
00770           void)
00771 {
00772   HRESULT hr = E_FAIL;
00773   IPersistStorage* pIPersistStorage;
00774
00775   if (NULL != m_pIDrawPage)
00776   {
00777     hr = m_pIDrawPage->QueryInterface(
00778            IID_IPersistStorage,
00779            (PPVOID)&pIPersistStorage);
00780     if (SUCCEEDED(hr))
00781     {
00782       // Tell the CODrawPage object to release all hold it may have
00783       // on storage.
00784       hr = pIPersistStorage->HandsOffStorage();
00785
00786       // Done with IPersistStorage for now so release it.
00787       pIPersistStorage->Release();
00788     }
00789   }
00790
00791   // Release the interface on the page's storage held by CGuiDraw.
00792   RELEASE_INTERFACE(m_pIStorage_Page);
00793
00794   // Release the interface held on the root storage by CGuiDraw.
00795   RELEASE_INTERFACE(m_pIStorage_Root);
00796
00797   return hr;
00798 }
00799
00800
00801 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00802   Method:   CGuiDraw::RestorePage
00803
00804   Summary:  Reopens all substorages for the draw page. Sets the CODrawPage
00805             object back to the Scribble state by calling SaveCompleted.
00806
00807   Args:     IStorage* pIStorage_Root
00808               New root storage for the draw page.
00809
00810   Returns:  HRESULT
00811               Standard result code. NOERROR for success.
00812 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00813 HRESULT CGuiDraw::RestorePage(
00814           IStorage* pIStorage_Root)
00815 {
00816   HRESULT hr = E_POINTER;
00817   IPersistStorage* pIPersistStorage;
00818
00819   if (NULL != pIStorage_Root)
00820   {
00821     // Save the new interface pointer to the root IStorage and AddRef it.
00822     m_pIStorage_Root = pIStorage_Root;
00823     m_pIStorage_Root->AddRef();
00824
00825     hr = m_pIDrawPage->QueryInterface(
00826            IID_IPersistStorage,
00827            (PPVOID)&pIPersistStorage);
00828     if (SUCCEEDED(hr))
00829     {
00830       // ReOpen the single substorage named by m_wszDataName. This is
00831       // the storage where the draw page is stored. It is under the
00832       // root storage. The client here is in charge of the underlying
00833       // storage that the client asks CODrawPage to use.
00834       hr = m_pIStorage_Root->OpenStorage(
00835              m_wszDataName,
00836              NULL,
00837              STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
00838              NULL,
00839              0,
00840              &m_pIStorage_Page);
00841       if (SUCCEEDED(hr))
00842       {
00843         // Tell the CODrawPage object that the client is done with its
00844         // use of storage. Thus CODrawPage will re-open all necessary
00845         // substorages and switch to the Scribble state.
00846         hr = pIPersistStorage->SaveCompleted(m_pIStorage_Page);
00847
00848         // Done with IPersistStorage for now so release it.
00849         pIPersistStorage->Release();
00850       }
00851     }
00852   }
00853
00854   return hr;
00855 }
00856
00857
00858 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00859   Method:   CGuiDraw::Close
00860
00861   Summary:  Close this page window and thus the drawing page's substorages.
00862
00863   Args:     void.
00864
00865   Returns:  HRESULT
00866               Standard result code. NOERROR for success.
00867 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00868 HRESULT CGuiDraw::Close(void)
00869 {
00870   HRESULT hr = NOERROR;
00871
00872   // Close the GuiDraw window. This will cause a delete of this CGuiDraw.
00873   ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00874
00875   return hr;
00876 }
00877
00878
00879 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00880   Method:   CGuiDraw::Save
00881
00882   Summary:  Uses CODrawPage's IPersistStorage interface to save the
00883             drawing data in the drawing page's substorage.
00884
00885   Args:     void.
00886
00887   Returns:  HRESULT
00888               Standard result code. NOERROR for success.
00889 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00890 HRESULT CGuiDraw::Save(
00891           void)
00892 {
00893   HRESULT hr = E_FAIL;
00894   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00895   HCURSOR hCurPrev;
00896   IPersistStorage* pIPersistStorage;
00897
00898   if (NULL != m_pIStorage_Page && NULL != m_pIDrawPage)
00899   {
00900     // Change cursor to the hour glass.
00901     hCurPrev = SetCursor(hCurWait);
00902
00903     // Tell the CODrawPage object to save itself
00904     // (via its IPersistStorage interface).
00905     hr = m_pIDrawPage->QueryInterface(
00906            IID_IPersistStorage,
00907            (PPVOID)&pIPersistStorage);
00908     if (SUCCEEDED(hr))
00909     {
00910       // Perform the save with fSameAsLoad==TRUE.
00911       hr = pIPersistStorage->Save(m_pIStorage_Page, TRUE);
00912       if (SUCCEEDED(hr))
00913       {
00914         // This is the general save by the client. In the case of
00915         // this application the client does not need to do any other
00916         // intermediate save or write operations to the compound file
00917         // prior to informing the server that client save operations
00918         // are completed.
00919         hr = pIPersistStorage->SaveCompleted(NULL);
00920       }
00921
00922       // Done with IPersistStorage for now so release it.
00923       pIPersistStorage->Release();
00924     }
00925
00926     // Set Cursor back to what it was.
00927     SetCursor(hCurPrev);
00928   }
00929
00930   return hr;
00931 }
00932
00933
00934 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00935   Method:   CGuiDraw::AskSave
00936
00937   Summary:  Checks dirty flag (ie, if current drawing data was modified
00938             and is out of sync with the DrawPage data stored in the page's
00939             storage). If dirty, then ask user in simple dialog if he wants
00940             to save new data. If he says yes, then save the current
00941             DrawPage data into its storage.
00942
00943   Args:     void.
00944
00945   Returns:  INT
00946               Value returned from the Win32 MessageBox function.
00947 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00948 INT CGuiDraw::AskSave(void)
00949 {
00950   int iAns = IDNO;
00951   HRESULT hr;
00952   TCHAR szTitle[MAX_STRING_LENGTH];
00953   TCHAR szAsk[MAX_STRING_LENGTH];
00954   TCHAR szMsg[MAX_PATH + MAX_STRING_LENGTH];
00955   IPersistStorage* pIPersistStorage;
00956
00957   hr = m_pIDrawPage->QueryInterface(
00958            IID_IPersistStorage,
00959            (PPVOID)&pIPersistStorage);
00960   if (SUCCEEDED(hr))
00961   {
00962     // Ask the DrawPage object if it is dirty.
00963     if (S_FALSE != pIPersistStorage->IsDirty())
00964     {
00965       // The current data is dirty; ask user if he wants to save it.
00966       if (LoadString(m_hInst, IDS_DRAW_PAGE, szTitle, MAX_STRING_LENGTH)
00967           && LoadString(m_hInst, IDS_ASK_SAVE, szAsk, MAX_STRING_LENGTH))
00968       {
00969         lstrcpyn(szMsg, szTitle, sizeof(szMsg)/sizeof(TCHAR));
00970         lstrncat(szMsg, szAsk, sizeof(szMsg)/sizeof(TCHAR) - lstrlen(szMsg));
00971         // Display AskSaveDlg to user. Ask if he wants to save.
00972         iAns = MessageBox(
00973                  m_hWnd,
00974                  szMsg,
00975                  szTitle,
00976                  MB_YESNOCANCEL | MB_ICONEXCLAMATION);
00977         switch (iAns)
00978         {
00979           case IDYES:
00980             // Tell CGuiDraw to save itself to file storage.
00981             Save();
00982             break;
00983           case IDNO:
00984             // User clicked No. So don't save; abandon changes.
00985             break;
00986           case IDCANCEL:
00987           default:
00988             break;
00989         }
00990       }
00991     }
00992
00993     // Done with IPersistStorage for now so release it.
00994     pIPersistStorage->Release();
00995   }
00996
00997   return iAns;
00998 }
00999
01000
01001 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01002   Method:   CGuiDraw::Delete
01003
01004   Summary:  Delete the stored DrawPage. Shuts down the drawing page and
01005             window. Disconnects the Sink and does final release of the
01006             CODrawPage object.
01007
01008   Args:     void.
01009
01010   Returns:  HRESULT
01011               Standard result code. NOERROR for success.
01012 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01013 HRESULT CGuiDraw::Delete(void)
01014 {
01015   HRESULT hr = E_FAIL;
01016   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01017   HCURSOR hCurPrev;
01018
01019   if (NULL != m_pIStorage_Root && NULL != m_pIDrawPage)
01020   {
01021     // Change cursor to the hour glass.
01022     hCurPrev = SetCursor(hCurWait);
01023
01024     // Clear the draw page.
01025     m_pIDrawPage->Clear(FALSE);
01026
01027     // Destroy the entire drawpage's storage.
01028     hr = m_pIStorage_Root->DestroyElement(m_wszDataName);
01029
01030     // Set Cursor back to what it was.
01031     SetCursor(hCurPrev);
01032   }
01033
01034   return hr;
01035 }
01036
01037
01038 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01039   Method:   CGuiDraw::Clear
01040
01041   Summary:  Clear content of the drawing page and clear display window.
01042
01043   Args:     void.
01044
01045   Returns:  HRESULT
01046               Standard result code. NOERROR for success.
01047 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01048 HRESULT CGuiDraw::Clear(void)
01049 {
01050   HRESULT hr = E_FAIL;
01051
01052   if (m_pIDrawPage)
01053     hr = m_pIDrawPage->Clear(TRUE);
01054   if (SUCCEEDED(hr))
01055   {
01056     ClearWin();
01057     // Tell main app if this page was changed.
01058     PostMessage(m_hWndApp, WM_USER_PAGECHANGED, 0, m_iPage);
01059   }
01060
01061   return hr;
01062 }
01063
01064
01065 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01066   Method:   CGuiDraw::PickColor
01067
01068   Summary:  Uses the Choose Color common dialog to ask user for new
01069             Pen color. Return that new color.
01070
01071   Args:     void.
01072
01073   Returns:  COLORREF
01074               New chosen color.
01075 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01076 COLORREF CGuiDraw::PickColor(void)
01077 {
01078   COLORREF crNewColor = m_crInkColor;
01079   SHORT i;
01080
01081   // Init the custom color array with gray colors.
01082   for (i=0; i<16; i++)
01083     m_acrCustColors[i] = RGB(i*16, i*16, i*16);
01084
01085   // Init the Choose Color structure.
01086   m_ChooseColor.lStructSize = sizeof(CHOOSECOLOR);
01087   m_ChooseColor.hwndOwner = m_hWnd;
01088   m_ChooseColor.hInstance = (HWND) m_hInst;
01089   m_ChooseColor.rgbResult = m_crInkColor;
01090   m_ChooseColor.lpCustColors = (DWORD*) m_acrCustColors;
01091   m_ChooseColor.Flags = CC_PREVENTFULLOPEN | CC_RGBINIT;
01092   m_ChooseColor.lCustData = 0L;
01093   m_ChooseColor.lpfnHook = NULL;
01094   m_ChooseColor.lpTemplateName = NULL;
01095
01096   if (ChooseColor(&m_ChooseColor))
01097     crNewColor = m_ChooseColor.rgbResult;
01098
01099   return crNewColor;
01100 }
01101
01102
01103 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01104   Method:   CGuiDraw::GetConnectionPoint
01105
01106   Summary:  Internal private method to obtain a connection point interface.
01107
01108   Args:     REFIID riid
01109               IID of the requested connection point Interface.
01110
01111   Returns:  IConnectionPoint*
01112               Requested IConnectionPoint interface pointer. NULL if none.
01113 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01114 IConnectionPoint* CGuiDraw::GetConnectionPoint(
01115                     REFIID riid)
01116 {
01117   IConnectionPoint* pIConnectionPoint = NULL;
01118   IConnectionPointContainer* pIConnectionPointContainer = NULL;
01119   IConnectionPoint* pIConnPt;
01120   HRESULT hr;
01121
01122   // First query the object for its Connection Point Container. This
01123   // essentially asks the object in the server if it is connectable.
01124   hr = m_pIDrawPage->QueryInterface(
01125          IID_IConnectionPointContainer,
01126          (PPVOID)&pIConnectionPointContainer);
01127   if SUCCEEDED(hr)
01128   {
01129     // Find the requested Connection Point. This AddRef's the
01130     // returned pointer.
01131     hr = pIConnectionPointContainer->FindConnectionPoint(riid, &pIConnPt);
01132     if (SUCCEEDED(hr))
01133       pIConnectionPoint = pIConnPt;
01134
01135     RELEASE_INTERFACE(pIConnectionPointContainer);
01136   }
01137
01138   return pIConnectionPoint;
01139 }
01140
01141
01142 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01143   Method:   CGuiDraw::ConnectSink
01144
01145   Summary:  Connect the client's DrawPageSink to the server's
01146             CODrawPage source.
01147
01148   Args:     void
01149
01150   Returns:  HRESULT
01151               Standard result code. NOERROR for success.
01152 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01153 HRESULT CGuiDraw::ConnectSink(void)
01154 {
01155   HRESULT hr = E_FAIL;
01156   DWORD dwKey;
01157   IConnectionPoint* pIConnectionPoint = NULL;
01158
01159   if (!m_dwDrawPageSink)
01160   {
01161     // Get the DrawPage Sink connection point in the server.
01162     pIConnectionPoint = GetConnectionPoint(IID_IDrawPageSink);
01163     if (NULL != pIConnectionPoint)
01164     {
01165       // Connect the server's object to the DrawPage Sink in this client.
01166       hr = pIConnectionPoint->Advise(m_pCODrawPageSink, &dwKey);
01167       if (SUCCEEDED(hr))
01168         m_dwDrawPageSink = dwKey;
01169
01170       RELEASE_INTERFACE(pIConnectionPoint);
01171     }
01172   }
01173
01174   return hr;
01175 }
01176
01177
01178 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01179   Method:   CGuiDraw::DisconnectSink
01180
01181   Summary:  Disconnect the client DrawPageSink from the server
01182             CODrawPage source.
01183
01184   Args:     void.
01185
01186   Returns:  HRESULT
01187               Standard result code. NOERROR for success.
01188 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01189 HRESULT CGuiDraw::DisconnectSink(void)
01190 {
01191   HRESULT hr = E_FAIL;
01192   IConnectionPoint* pIConnectionPoint;
01193
01194   if (m_dwDrawPageSink)
01195   {
01196     // Get the DrawPage Sink connection point.
01197     pIConnectionPoint = GetConnectionPoint(IID_IDrawPageSink);
01198     if (NULL != pIConnectionPoint)
01199     {
01200       // Disconnect the object in the server from the DrawPage Sink in
01201       // this client.
01202       hr = pIConnectionPoint->Unadvise(m_dwDrawPageSink);
01203       if (SUCCEEDED(hr))
01204         m_dwDrawPageSink = 0;
01205
01206       RELEASE_INTERFACE(pIConnectionPoint);
01207     }
01208   }
01209
01210   return hr;
01211 }
01212
01213
01214 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01215   Method:   CGuiDraw::DoCommand
01216
01217   Summary:  Dispatch and handle the main menu and other commands.
01218
01219   Args:     WPARAM wParam,
01220               First message parameter.
01221             LPARAM lParam)
01222               Second message parameter.
01223
01224   Returns:  LRESULT
01225               Standard Windows WindowProc return value.
01226 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01227 LRESULT CGuiDraw::DoCommand(
01228           WPARAM wParam,
01229           LPARAM lParam)
01230 {
01231   LRESULT lResult = FALSE;
01232   HMENU hMenu = ::GetMenu(m_hWnd);
01233
01234   switch (LOWORD(wParam))
01235   {
01236     //----------------------------------------------------------------------
01237     // Handle Drawing Menu Commands.
01238     //----------------------------------------------------------------------
01239     case IDM_DRAW_SAVE:
01240       // Ask the GuiDraw object to save the current drawing.
01241       Save();
01242       break;
01243     case IDM_DRAW_CLEAR:
01244       // Ask GuiDraw object to clear its current content and if it can,
01245       // clear drawing display window.
01246       Clear();
01247       break;
01248     case IDM_DRAW_EXIT:
01249       // The user commands us to exit this page so we tell the
01250       // window to close itself.
01251       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
01252       break;
01253
01254     //----------------------------------------------------------------------
01255     // Handle Pen Menu Commands.
01256     //----------------------------------------------------------------------
01257     case IDM_PEN_COLOR:
01258       // Select Ink drawing color using ChooseColor common dialog.
01259       {
01260         COLORREF crNewColor = PickColor();
01261         InkColor(crNewColor);
01262       }
01263       break;
01264     case IDM_PEN_THIN:
01265       // Select thin Ink width. Set menu check indicator.
01266       {
01267         HRESULT hr;
01268         HMENU hMenu  = ::GetMenu(m_hWnd);
01269         BOOL bOn = ::GetMenuState(
01270                        hMenu,
01271                        IDM_PEN_THIN,
01272                        MF_BYCOMMAND) & MF_CHECKED;
01273         if (!bOn)
01274         {
01275           hr = InkWidth(INK_THIN);
01276           if (SUCCEEDED(hr))
01277           {
01278             ::CheckMenuItem(
01279                 hMenu,
01280                 IDM_PEN_THIN,
01281                 MF_BYCOMMAND | MF_CHECKED);
01282             ::CheckMenuItem(
01283                 hMenu,
01284                 IDM_PEN_MEDIUM,
01285                 MF_BYCOMMAND | MF_UNCHECKED);
01286             ::CheckMenuItem(
01287                 hMenu,
01288                 IDM_PEN_THICK,
01289                 MF_BYCOMMAND | MF_UNCHECKED);
01290           }
01291         }
01292       }
01293       break;
01294     case IDM_PEN_MEDIUM:
01295       // Select medium Ink width. Set menu check indicator.
01296       {
01297         HRESULT hr;
01298         HMENU hMenu  = ::GetMenu(m_hWnd);
01299         BOOL bOn = ::GetMenuState(
01300                        hMenu,
01301                        IDM_PEN_MEDIUM,
01302                        MF_BYCOMMAND) & MF_CHECKED;
01303         if (!bOn)
01304         {
01305           hr = InkWidth(INK_MEDIUM);
01306           if (SUCCEEDED(hr))
01307           {
01308             ::CheckMenuItem(
01309                 hMenu,
01310                 IDM_PEN_MEDIUM,
01311                 MF_BYCOMMAND | MF_CHECKED);
01312             ::CheckMenuItem(
01313                 hMenu,
01314                 IDM_PEN_THICK,
01315                 MF_BYCOMMAND | MF_UNCHECKED);
01316             ::CheckMenuItem(
01317                 hMenu,
01318                 IDM_PEN_THIN,
01319                 MF_BYCOMMAND | MF_UNCHECKED);
01320           }
01321         }
01322       }
01323       break;
01324     case IDM_PEN_THICK:
01325       // Select thick Ink width. Set menu check indicator.
01326       {
01327         HRESULT hr;
01328         HMENU hMenu  = ::GetMenu(m_hWnd);
01329         BOOL bOn = ::GetMenuState(
01330                        hMenu,
01331                        IDM_PEN_THICK,
01332                        MF_BYCOMMAND) & MF_CHECKED;
01333         if (!bOn)
01334         {
01335           hr = InkWidth(INK_THICK);
01336           if (SUCCEEDED(hr))
01337           {
01338             ::CheckMenuItem(
01339                 hMenu,
01340                 IDM_PEN_THICK,
01341                 MF_BYCOMMAND | MF_CHECKED);
01342             ::CheckMenuItem(
01343                 hMenu,
01344                 IDM_PEN_MEDIUM,
01345                 MF_BYCOMMAND | MF_UNCHECKED);
01346             ::CheckMenuItem(
01347                 hMenu,
01348                 IDM_PEN_THIN,
01349                 MF_BYCOMMAND | MF_UNCHECKED);
01350           }
01351         }
01352       }
01353       break;
01354
01355     //----------------------------------------------------------------------
01356     // Handle Help Menu Commands. Pass these commands on to main app.
01357     //----------------------------------------------------------------------
01358     case IDM_DHELP_CONTENTS:
01359       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_CONTENTS, 0);
01360       break;
01361     case IDM_DHELP_TUTORIAL:
01362       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_TUTORIAL, 0);
01363       break;
01364     case IDM_DHELP_TUTSERVER:
01365       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_PERDRAW, 0);
01366       break;
01367     case IDM_DHELP_READSOURCE:
01368       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_READSOURCE, 0);
01369       break;
01370     case IDM_DHELP_ABOUT:
01371       PostMessage(m_hWndApp, WM_COMMAND, (WPARAM) IDM_HELP_ABOUT, 0);
01372       break;
01373
01374     default:
01375       // Defer all messages NOT handled here to the Default Window Proc.
01376       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
01377       break;
01378   }
01379
01380   return(lResult);
01381 }
01382
01383
01384 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01385   Method:   CGuiDraw::WindowProc
01386
01387   Summary:  Main window procedure for this window object.  See CVirWindow
01388             in the APPUTIL library (APPUTIL.H and APPUTIL.CPP) for details
01389             on how this method gets called by the global WindowProc.
01390
01391   Args:     UINT uMsg,
01392               Windows message that is "sent" to this window.
01393             WPARAM wParam,
01394               First message parameter.
01395             LPARAM lParam)
01396               Second message parameter.
01397
01398   Returns:  LRESULT
01399               Standard Windows WindowProc return value.
01400 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01401 LRESULT CGuiDraw::WindowProc(
01402           UINT uMsg,
01403           WPARAM wParam,
01404           LPARAM lParam)
01405 {
01406   LRESULT lResult = FALSE;
01407
01408   switch (uMsg)
01409   {
01410     case WM_CREATE:
01411       break;
01412
01413     case WM_ACTIVATE:
01414       // If we were newly activated by a mouse click then don't just sit
01415       // there--re-paint. This is needed when another window was topped
01416       // over part of this DrawPage window and the user then topped the
01417       // DrawPage using a mouse click on the visible part of this window.
01418       // In any case also let the windows default WindowProc handle this
01419       // message to set keyboard focus to the newly active window.
01420       if (WA_CLICKACTIVE == LOWORD(wParam))
01421         PaintWin();
01422       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
01423       break;
01424
01425     case WM_MEASUREITEM:
01426       // Get setup for painting text in this window. For later evolution.
01427       {
01428         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
01429         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
01430         lpmis->itemWidth = m_wWidth;
01431         lResult = TRUE;
01432       }
01433
01434     case WM_SIZE:
01435       // Handle a resize of this window.
01436       ResizeWin(LOWORD(lParam), HIWORD(lParam));
01437       break;
01438
01439     case WM_PAINT:
01440       // If something major happened repaint the whole window.
01441       {
01442         PAINTSTRUCT ps;
01443
01444         if(BeginPaint(m_hWnd, &ps))
01445         {
01446           PaintWin();
01447           EndPaint(m_hWnd, &ps);
01448         }
01449       }
01450       break;
01451
01452     case WM_LBUTTONDOWN:
01453       // Start sequence of ink drawing to the paper.
01454       InkStart(LOWORD(lParam), HIWORD(lParam));
01455       break;
01456
01457     case WM_MOUSEMOVE:
01458       // Draw inking sequence data.
01459       InkDraw(LOWORD(lParam), HIWORD(lParam));
01460       break;
01461
01462     case WM_LBUTTONUP:
01463       // Stop an ink drawing sequence.
01464       InkStop(LOWORD(lParam), HIWORD(lParam));
01465       break;
01466
01467     case WM_COMMAND:
01468       // Dispatch and handle any Menu and command messages received.
01469       lResult = DoCommand(wParam, lParam);
01470       break;
01471
01472     case WM_CHAR:
01473       if (wParam == 0x1b)
01474       {
01475         // Exit this app if user hits ESC key.
01476         ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
01477       }
01478       break;
01479
01480     case WM_CLOSE:
01481       // The user selected Close on the drawing window's System menu
01482       // or Exit on the File menu.
01483       // If there is data that has not been saved then ask user
01484       // if it should be saved. If user cancels then cancel the exit.
01485       if (IDCANCEL == AskSave())
01486         break;
01487     case WM_QUIT:
01488       // Bring the main app window to top when this drawing window goes away.
01489       BringWindowToTop(m_hWndApp);
01490       // If the app is being quit then close any associated help windows.
01491       // For future evolution.
01492     default:
01493       // Defer all messages NOT handled above to the Default Window Proc.
01494       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
01495       break;
01496   }
01497
01498   return(lResult);
01499 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/FieldEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

FieldEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: FieldEnum
00019
00020 public class FieldEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adDefaultStream = -1;
00023   public static final short adRecordURL = -2;
00024 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IComSpyAudit Member List

This is the complete list of members for IComSpyAudit, including all inherited members.
EngineDefined([in] LONGLONG perfCount,[in] LPCOLESTR pszPropName,[in] VARIANT *varPropValue,[in] LPCOLESTR pszClsidEng) | IComSpyAudit
Init(LPCOLESTR sDSN, LPCOLESTR sUser, LPCOLESTR sPw) | IComSpyAudit
OnActivityCreate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID) | IComSpyAudit
OnActivityDestroy([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID) | IComSpyAudit
OnActivityEnter([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidCurrentApp,[in] LPCOLESTR pszGuidEnteredApp,[in] LPCOLESTR pszW2KThreadID) | IComSpyAudit
OnActivityLeave([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidCurrentApp,[in] LPCOLESTR pszGuidLeftApp) | IComSpyAudit
OnActivityLeaveSame([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidCurrentApp,[in] DWORD dwCallDepth) | IComSpyAudit
OnActivityReenter([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidCurrentApp,[in] LPCOLESTR pszW2KThreadID,[in] DWORD dwCallDepth) | IComSpyAudit
OnActivityTimeout([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidCurrentApp,[in] LPCOLESTR pszGuidEnteredApp,[in] LPCOLESTR pszW2KThreadID,[in] DWORD dwTimeout) | IComSpyAudit
OnAppActivation([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp) | IComSpyAudit
OnAppShutdown([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp) | IComSpyAudit
OnAuthenticate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivity,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszGuidIID,[in] LPCOLESTR pszMethod,[in] LPCOLESTR pszOriginalUser,[in] LPCOLESTR pszDirectUser,[in] BOOL bCurrentUserInpersonatingInProc) | IComSpyAudit
OnAuthenticateFail([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivity,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszGuidIID,[in] LPCOLESTR pszMethod,[in] LPCOLESTR pszOriginalUser,[in] LPCOLESTR pszDirectUser,[in] BOOL bCurrentUserInpersonatingInProc) | IComSpyAudit
OnCRMAbort([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMAnalyze([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID,[in] LPCOLESTR pszCrmRecordType,[in] DWORD dwRecordSize) | IComSpyAudit
OnCRMBegin([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID,[in] LPCOLESTR pszGuidActivityID,[in] LPCOLESTR pszGuidTxUOWID,[in] LPCOLESTR pszProgIdCompensator,[in] LPCOLESTR pszDescription) | IComSpyAudit
OnCRMCheckpoint([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp) | IComSpyAudit
OnCRMCommit([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMDeliver([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID,[in] BOOL bVariants,[in] DWORD dwRecordSize) | IComSpyAudit
OnCRMDone([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMForce([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMForget([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMIndoubt([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMPrepare([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMRecoveryDone([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp) | IComSpyAudit
OnCRMRecoveryStart([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp) | IComSpyAudit
OnCRMRelease([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID) | IComSpyAudit
OnCRMWrite([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidClerkCLSID,[in] BOOL bVariants,[in] DWORD dwRecordSize) | IComSpyAudit
OnDisableCommit([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID) | IComSpyAudit
OnEnableCommit([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID) | IComSpyAudit
OnExceptionUser([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszCode,[in] LPCOLESTR pszAddress,[in] LPCOLESTR pszStackTrace) | IComSpyAudit
OnIISRequestInfo([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszClientIP,[in] LPCOLESTR pszServerIP,[in] LPCOLESTR pszURL) | IComSpyAudit
OnMethodCall([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszGuidClassID,[in] LPCOLESTR pszGuidInterfaceID,[in] LPCOLESTR pszMethod) | IComSpyAudit
OnMethodException([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszGuidClassID,[in] LPCOLESTR pszGuidInterfaceID,[in] LPCOLESTR pszMethod) | IComSpyAudit
OnMethodReturn([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszGuidClassID,[in] LPCOLESTR pszGuidInterfaceID,[in] LPCOLESTR pszMethod,[in] HRESULT hr,[in] LPCOLESTR pszCallTime) | IComSpyAudit
OnObjectActivate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjectConstruct([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszClassID,[in] LPCOLESTR pszConstructString,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjectCreate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID,[in] LPCOLESTR pszClassID,[in] LPCOLESTR pszTSID,[in] LPCOLESTR pszContextID,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjectDeactivate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjectDestroy([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID) | IComSpyAudit
OnObjPoolCreateDecision([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] DWORD dwThreadsWaiting,[in] DWORD dwAvailableObjs,[in] DWORD dwCreatedObjs,[in] DWORD dwMin,[in] DWORD dwMax) | IComSpyAudit
OnObjPoolCreateObject([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszClassID,[in] DWORD dwAvailableObjs,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjPoolCreatePool([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszClassID,[in] DWORD dwMin,[in] DWORD dwMax,[in] DWORD dwTimeout) | IComSpyAudit
OnObjPoolDestroyObject([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszClassID,[in] DWORD dwAvailableObjs,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjPoolGetFromTx([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID,[in] LPCOLESTR pszClassID,[in] LPCOLESTR pszGuidTx,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjPoolGetObject([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID,[in] LPCOLESTR pszClassID,[in] DWORD dwAvailableObjs,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjPoolPutObject([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszClassID,[in] int nReason,[in] DWORD dwAvailableObjs,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjPoolRecycleToTx([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID,[in] LPCOLESTR pszClassID,[in] LPCOLESTR pszGuidTx,[in] LPCOLESTR pszObjectID) | IComSpyAudit
OnObjPoolTimeout([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszClassID,[in] LPCOLESTR pszGuidActivityID,[in] DWORD dwTimeout) | IComSpyAudit
OnQCMoveToDeadQueue([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidMsgID,[in] LPCOLESTR pszGuidWorkFlowID) | IComSpyAudit
OnQCMoveToReTryQueue([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidMsgID,[in] LPCOLESTR pszGuidWorkFlowID,[in] ULONG RetryIndex) | IComSpyAudit
OnQCPlayback([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszGuidMsgID,[in] LPCOLESTR pszGuidWorkFlowID,[in] HRESULT hr) | IComSpyAudit
OnQCQueueOpen([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszQueueName,[in] LPCOLESTR pszQueueID,[in] HRESULT hr) | IComSpyAudit
OnQCReceive([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszQueueID,[in] LPCOLESTR pszGuidMsgID,[in] LPCOLESTR pszGuidWorkFlowID,[in] HRESULT hr) | IComSpyAudit
OnQCReceiveFail([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszQueueID,[in] HRESULT hr) | IComSpyAudit
OnQCRecord([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszQueueName,[in] LPCOLESTR pszGuidMsgID,[in] LPCOLESTR pszGuidWorkFlowID,[in] HRESULT hr) | IComSpyAudit
OnResourceAllocate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszType,[in] LPCOLESTR pszResId,[in] BOOL bEnlisted,[in] LPCOLESTR pszNumRated,[in] LPCOLESTR pszRating) | IComSpyAudit
OnResourceCreate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszType,[in] LPCOLESTR pszResId,[in] BOOL bEnlisted) | IComSpyAudit
OnResourceDestroy([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] HRESULT hResult,[in] LPCOLESTR pszType,[in] LPCOLESTR pszResId) | IComSpyAudit
OnResourceRecycle([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszType,[in] LPCOLESTR pszResId) | IComSpyAudit
OnResourceTrack([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszObjectID,[in] LPCOLESTR pszType,[in] LPCOLESTR pszResId,[in] BOOL bEnlisted) | IComSpyAudit
OnSetAbort([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID) | IComSpyAudit
OnSetComplete([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszContextID) | IComSpyAudit
OnThreadAssignApartment([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidActivityID,[in] LPCOLESTR pszAptID) | IComSpyAudit
OnThreadBindToApartment([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR pszAptID,[in] DWORD dwActivityCnt) | IComSpyAudit
OnThreadStart([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR pszW2KThreadID,[in] DWORD dwThreadCnt) | IComSpyAudit
OnThreadTerminate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR pszW2KThreadID,[in] DWORD dwThreadCnt) | IComSpyAudit
OnThreadUnassignApartment([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszAptID) | IComSpyAudit
OnThreadUnBind([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR pszAptID,[in] DWORD dwActivityCnt) | IComSpyAudit
OnThreadWorkEnque([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR MsgWorkID,[in] DWORD dwQueueLen) | IComSpyAudit
OnThreadWorkPrivate([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR MsgWorkID) | IComSpyAudit
OnThreadWorkPublic([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR MsgWorkID,[in] DWORD dwQueueLen) | IComSpyAudit
OnThreadWorkRedirect([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR MsgWorkID,[in] DWORD dwQueueLen,[in] LPCOLESTR pszThreadNum) | IComSpyAudit
OnThreadWorkReject([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszThreadID,[in] LPCOLESTR MsgWorkID,[in] DWORD dwQueueLen) | IComSpyAudit
OnTransactionAborted([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidTxID) | IComSpyAudit
OnTransactionCommit([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidTxID) | IComSpyAudit
OnTransactionPrepared([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidTxID,[in] BOOL bVoteYes) | IComSpyAudit
OnTransactionStart([in] LONGLONG perfCount,[in] LPCOLESTR pszGuidApp,[in] LPCOLESTR pszGuidTxID,[in] LPCOLESTR pszGuidTSID,[in] BOOL bRoot) | IComSpyAudit
TargetDown([in] LONGLONG perfCount,[in] LPCOLESTR pszServerName,[in] LPCOLESTR pszClsidEng) | IComSpyAudit
TargetUp([in] LONGLONG perfCount,[in] LPCOLESTR pszServerName,[in] LPCOLESTR pszClsidEng) | IComSpyAudit
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/TestDlg.h Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest

TestDlg.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: TestDlg.h
00004
00005 Summary: Declaration of the CTestDlg
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021
00022 #ifndef __TESTDLG_H_
00023 #define __TESTDLG_H_
00024
00025 #include "resource.h"       // main symbols
00026 #include <atlhost.h>
00027 #include <initguid.h>
00028
00029 #include "LogWriter\LogWriter_i.c"
00030 #include "LogWriter\LogWriter.h"
00031
00032
00033 /////////////////////////////////////////////////////////////////////////////
00034 // CTestDlg
00035 class CTestDlg :
00036   public CDialogImpl<CTestDlg>
00037 {
00038 public:
00039   CTestDlg();
00040   ~CTestDlg();
00041
00042   enum { IDD = IDD_TESTDLG };
00043
00044 BEGIN_MSG_MAP(CTestDlg)
00045   MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
00046   COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
00047   MESSAGE_HANDLER(WM_TIMER, OnTimer)
00048 END_MSG_MAP()
00049 // Handler prototypes:
00050 //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00051 //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00052 //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
00053
00054   LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00055
00056   LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
00057   {
00058     EndDialog(wID);
00059     return 0;
00060   }
00061   LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00062
00063 private:
00064   int m_nNumberWrites;
00065   ILogFile *m_pLF;
00066   DWORD dwPID;
00067 };
00068
00069 #endif //__TESTDLG_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWizExtUser Member List

This is the complete list of members for CWizExtUser, including all inherited members.
AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam) | CWizExtUser |
CWizExtUser() | CWizExtUser | [inline]
DECLARE_REGISTRY_CLSID() | CWizExtUser |
GetClassIcon() | CWizExtUser | [inline]
GetClassName() | CWizExtUser | [inline]
GetContainer() | CWizExtUser | [inline]
GetContainerCanonicalName() | CWizExtUser | [inline]
GetCopySourceObj() | CWizExtUser | [inline]
GetDefaultSummary(CString &s) | CWizExtUser |
GetIDsAdminNewObj() | CWizExtUser | [inline]
GetObj() | CWizExtUser | [inline]
GetSummaryInfo(BSTR *pBstrText) | CWizExtUser |
GetTitle() | CWizExtUser | [inline]
Initialize(IADsContainer *pADsContainerObj, IADs *pADsCopySource, LPCWSTR lpszClassName, IDsAdminNewObj *pDsAdminNewObj, LPDSA_NEWOBJ_DISPINFO pDispInfo) | CWizExtUser |
m_hObjClassIcon | CWizExtUser | [protected]
m_pExtPageUser | CWizExtUser | [protected]
m_spADsContainerObj | CWizExtUser | [private]
m_spADsCopySourceObj | CWizExtUser | [private]
m_spADsObj | CWizExtUser | [private]
m_spDsAdminNewObj | CWizExtUser | [private]
m_szClassName | CWizExtUser | [protected]
m_szContCanonicalName | CWizExtUser | [protected]
m_szTitle | CWizExtUser | [protected]
OnError(HWND hWnd, HRESULT hr, ULONG uContext) | CWizExtUser |
SetObj(IADs *pADsObj) | CWizExtUser | [inline]
SetObject(IADs *pADsObj) | CWizExtUser |
WriteData(HWND hWnd, ULONG uContext) | CWizExtUser |
WriteDataHelper() | CWizExtUser |
~CWizExtUser() | CWizExtUser | [inline]
Generated on Wed Nov 13 2024 16:57:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/GUIPAPER.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

GUIPAPER.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUIPAPER.CPP
00003
00004   Summary:   Implementation file for the CGuiPaper C++ class. A GuiPaper
00005              is a C++ object that displays mouse movement as free-form
00006              drawing in the client area of a designated window (much like
00007              common scribble sample programs except that COM technology is
00008              used throughout to construct this functionality). CGuiPaper
00009              is anchored to the Windows GUI (Graphical User Interface)
00010              environment--it retains knowledge of window handles and
00011              device contexts on the local machine. This GuiPaper object
00012              relies on a virtual paper object for storage of the drawing
00013              data. This virtual Paper object (a COPaper) is instantiated
00014              as a COM object in a separate thread-safe In-process server,
00015              STOSERVE.
00016
00017              For a comprehensive tutorial code tour of GUIPAPER's contents
00018              and offerings see the tutorial STOCLIEN.HTM file. For more
00019              specific technical details on the internal workings see the
00020              comments dispersed throughout the GUIPAPER source code.
00021
00022   Classes:   CGuiPaper.
00023
00024   Origin:    6-10-96: atrent - Editor inheritance from GUIBALL.CPP in the
00025              CONCLIEN source.
00026
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042 /*--------------------------------------------------------------------------
00043   We include WINDOWS.H for all Win32 applications.
00044   We include OLE2.H because we will be calling the COM/OLE Libraries.
00045   We include OLECTL.H because it has definitions for connectable objects.
00046   We include COMMDLG.H because we will be using the Open File,
00047     Choose Color, and potentially other Common dialogs.
00048   We include TCHAR.H for general Unicode/Ansi prototype of utility
00049     functions like _tsplitpath, etc.
00050   We include APPUTIL.H because we will be building this application using
00051     the convenient Virtual Window and Dialog classes and other
00052     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00053   We include IPAPER.H and PAPGUIDS.H for the common Paper-related Interface
00054     class, GUID, and CLSID specifications.
00055   We include PAPFILE.H because it has the C++ class used for compound file
00056     storage of Drawing Paper Data.
00057   We include GUIPAPER.H because it has the C++ class used for GUI display
00058     of the drawing Paper.
00059   We include SINK.H because it has the C++ class used for the sink that
00060     receives event notifications from the COPaper object in the server.
00061   We include STOCLIEN.H because it has class and resource definitions
00062     specific to this STOCLIEN application.
00063 ---------------------------------------------------------------------------*/
00064 #include <windows.h>
00065 #include <ole2.h>
00066 #include <olectl.h>
00067 #include <commdlg.h>
00068 #include <tchar.h>
00069 #include <apputil.h>
00070 #include <ipaper.h>
00071 #include <papguids.h>
00072 #include "papfile.h"
00073 #include "guipaper.h"
00074 #include "sink.h"
00075 #include "stoclien.h"
00076
00077
00078 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00079   Method:   CGuiPaper::CGuiPaper
00080
00081   Summary:  Constructor.
00082
00083   Args:     void
00084
00085   Modifies: ...
00086
00087   Returns:  void
00088 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00089 CGuiPaper::CGuiPaper(void)
00090 {
00091   m_hWnd       = NULL;
00092   m_hInst      = NULL;
00093   m_hDC        = NULL;
00094   m_pIPaper    = NULL;
00095   m_nLockKey   = 0;
00096   m_hPen       = NULL;
00097   m_nInkWidth  = INK_THIN;
00098   m_crInkColor = RGB(0,0,0);
00099   m_bInkSaving = FALSE;
00100   m_bInking    = FALSE;
00101   m_bPainting  = FALSE;
00102   m_OldPos.x   = 0;
00103   m_OldPos.y   = 0;
00104   m_pCOPaperSink = NULL;
00105   m_dwPaperSink = 0;
00106   m_bDirty     = FALSE;
00107   m_pPapFile   = NULL;
00108
00109   // Init the file name for title display to <MyModule>.<EXT>.
00110   if (GetModuleFileName(m_hInst, m_szFileName, MAX_PATH))
00111   {
00112     _tsplitpath(m_szFileName, NULL, NULL, m_szFileTitle, NULL);
00113     lstrncat(m_szFileTitle, TEXT(PAP_FILE_EXT), sizeof(m_szFileTitle)/
00114       sizeof(TCHAR) - lstrlen(m_szFileTitle));
00115   }
00116
00117   // Ensure the m_szFileName OFN member variable string is NULL.
00118   m_szFileName[0] = 0;
00119 }
00120
00121
00122 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00123   Method:   CGuiPaper::~CGuiPaper
00124
00125   Summary:  Destructor.
00126
00127   Args:     void
00128
00129   Modifies: ...
00130
00131   Returns:  void
00132 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00133 CGuiPaper::~CGuiPaper(void)
00134 {
00135   BOOL bOk = TRUE;
00136
00137   if (m_pIPaper)
00138   {
00139     // Make sure we unlock the paper object.
00140     m_pIPaper->Unlock(m_nLockKey);
00141
00142     // Just to make sure, turn off Ink Saving.
00143     m_bInkSaving = FALSE;
00144
00145     // Disconnect all Sinks--currently only one: PaperSink. This officially
00146     // stops all PaperSink notifications.
00147     DisconnectPaperSink();
00148
00149     // Delete the Pen object.
00150     if (m_hPen)
00151       DeleteObject(m_hPen);
00152
00153     // Release the reference to the PaperSink object.
00154     RELEASE_INTERFACE(m_pCOPaperSink);
00155
00156     // Release the main interface pointer copy held in CGuiPaper.
00157     RELEASE_INTERFACE(m_pIPaper);
00158
00159     // Delete the CPapFile object.
00160     DELETE_POINTER(m_pPapFile);
00161   }
00162 }
00163
00164
00165 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00166   Method:   CGuiPaper::Init
00167
00168   Summary:  Get CGuiPaper started. Make any subordinate objects, like
00169             COPaper and CPapFile, and get them started.
00170
00171   Args:     HINSTANCE hInst
00172               Handle to the application instance.
00173             HWND hWnd
00174               Handle of the display window. Part of what makes CGuiPaper
00175               a GUI kind of thing.
00176             TCHAR* pszCmdLineFile)
00177               Pointer to file name for an initial file to load that was
00178               specified on the app command line.
00179
00180   Modifies: ...
00181
00182   Returns:  BOOL
00183               TRUE for success; FALSE for fail.
00184 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00185 BOOL CGuiPaper::Init(
00186        HINSTANCE hInst,
00187        HWND hWnd,
00188        TCHAR* pszCmdLineFile)
00189 {
00190   BOOL bOk = FALSE;
00191   HRESULT hr;
00192   BOOL bFirst;
00193   COPaperSink* pCob = NULL;
00194   HCURSOR hCurPrev;
00195   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00196
00197   if (hInst && hWnd)
00198   {
00199     m_hInst = hInst;
00200     m_hWnd = hWnd;
00201
00202     // Get and save our private display Device Context.
00203     m_hDC = GetDC(m_hWnd);
00204
00205     // Change cursor to the hour glass. Init could take awhile.
00206     hCurPrev = SetCursor(hCurWait);
00207
00208     // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00209     m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00210     m_ofnFile.hwndOwner = hWnd;
00211     m_ofnFile.hInstance = hInst;
00212     m_ofnFile.lpstrCustomFilter = NULL;
00213     m_ofnFile.nMaxCustFilter = 0;
00214     m_ofnFile.nFilterIndex = 1;
00215     m_ofnFile.lpstrFile = m_szFileName;
00216     m_ofnFile.nMaxFile = MAX_PATH;
00217     m_ofnFile.lpstrInitialDir = TEXT(".");
00218     m_ofnFile.lpstrFileTitle = m_szFileTitle;
00219     m_ofnFile.nMaxFileTitle = MAX_PATH;
00220     m_ofnFile.lpstrDefExt = TEXT(PAP_EXT);
00221
00222     if (LoadString(m_hInst, IDS_OFN_PAPFILES, m_szFileFilter, MAX_PATH))
00223       m_ofnFile.lpstrFilter = m_szFileFilter;
00224     else
00225       m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00226
00227     // Call COM service to create a COPaper instance. We are not
00228     // aggregating it so we ask for its IPaper interface directly.
00229     hr = CoCreateInstance(
00230            CLSID_DllPaper,
00231            NULL,
00232            CLSCTX_INPROC_SERVER,
00233            IID_IPaper,
00234            (PPVOID)&m_pIPaper);
00235     if (SUCCEEDED(hr))
00236     {
00237       // Init the COPaper object.
00238       GetClientRect(hWnd, &m_WinRect);
00239       hr = m_pIPaper->InitPaper(&m_WinRect, &bFirst);
00240       if (SUCCEEDED(hr))
00241       {
00242         // We can now allow ink saving.
00243         m_bInkSaving = TRUE;
00244
00245         // If this is not first init then resize this client's window to
00246         // match what the COPaper object is using for its size.
00247         if (!bFirst)
00248           SetWindowPos(
00249             m_hWnd,
00250             HWND_TOP,
00251             0,
00252             0,
00253             m_WinRect.right,
00254             m_WinRect.bottom,
00255             SWP_NOMOVE | SWP_NOZORDER);
00256
00257         // Create the PapFile object so we can store paper data in
00258         // compound files.
00259         m_pPapFile = new CPapFile;
00260         if (NULL != m_pPapFile)
00261         {
00262           if (FileExist(pszCmdLineFile))
00263           {
00264             // If the user specified a file name on the app's command
00265             // invocation line then use that name if it actually refers
00266             // to an existing file. If not then ignore it.
00267             lstrcpy(m_szFileName, pszCmdLineFile);
00268             lstrcpy(m_szFileTitle, pszCmdLineFile);
00269           }
00270           else
00271           {
00272             // Build a path to where the default application .PAP file
00273             // should be. It should be in the same directory as the .EXE
00274             // as the appname with an .PAP extension.
00275             MakeFamilyPath(m_hInst, m_szFileName, TEXT(PAP_FILE_EXT));
00276           }
00277
00278           // Init the CPapFile object. Init will do the AddRef on the
00279           // m_pIPaper copy that is passed.
00280           hr = m_pPapFile->Init(m_szFileName, m_pIPaper);
00281           if (SUCCEEDED(hr))
00282           {
00283             // Create the COPaperSink object to receive COPaper events.
00284             pCob = new COPaperSink(NULL, this);
00285             if (NULL != pCob)
00286             {
00287               // Save a pointer to the COPaperSink IUnknown interface.
00288               // AddRef because of this saved copy.
00289               m_pCOPaperSink = pCob;
00290               m_pCOPaperSink->AddRef();
00291             }
00292             else
00293               hr = E_OUTOFMEMORY;
00294           }
00295         }
00296         else
00297           hr = E_OUTOFMEMORY;
00298       }
00299
00300       bOk = SUCCEEDED(hr);
00301     }
00302
00303     // Set Cursor back to what it was.
00304     SetCursor(hCurPrev);
00305   }
00306
00307   return (bOk);
00308 }
00309
00310
00311 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00312   Method:   CGuiPaper::DrawOn
00313
00314   Summary:  Lock the paper object for drawing by this client.
00315
00316   Args:     void.
00317
00318   Modifies: ...
00319
00320   Returns:  HRESULT
00321               Standard result code. NOERROR for success.
00322 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00323 HRESULT CGuiPaper::DrawOn(void)
00324 {
00325   HRESULT hr;
00326
00327   // If we are not already locked for drawing then do so.
00328   if (!m_nLockKey)
00329     hr = m_pIPaper->Lock(&m_nLockKey);
00330
00331   return hr;
00332 }
00333
00334
00335 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00336   Method:   CGuiPaper::DrawOff
00337
00338   Summary:  Unlock the paper object for drawing by this client.
00339
00340   Args:     void.
00341
00342   Modifies: ...
00343
00344   Returns:  HRESULT
00345               Standard result code. NOERROR for success.
00346 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00347 HRESULT CGuiPaper::DrawOff(void)
00348 {
00349   HRESULT hr = NOERROR;
00350
00351   // If we are not already unlocked for drawing then do so.
00352   if (m_nLockKey)
00353   {
00354     hr = m_pIPaper->Unlock(m_nLockKey);
00355     if (SUCCEEDED(hr))
00356       m_nLockKey = 0;
00357   }
00358
00359   return hr;
00360 }
00361
00362
00363 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00364   Method:   CGuiPaper::ClearWin
00365
00366   Summary:  Clear display window but don't erase drawn data.
00367
00368   Args:     void.
00369
00370   Modifies: ...
00371
00372   Returns:  HRESULT
00373               Standard result code. NOERROR for success.
00374 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00375 HRESULT CGuiPaper::ClearWin(void)
00376 {
00377   HRESULT hr = E_FAIL;
00378   RECT  WinRect;
00379
00380   if(!m_bInking)
00381   {
00382     // Get our window's client area rectangle.
00383     GetClientRect(m_hWnd, &WinRect);
00384
00385     // Fill that rectangle with pixels of default white paint.
00386     FillRect(m_hDC, &WinRect, GETCLASSBRUSH(m_hWnd));
00387
00388     hr = NOERROR;
00389   }
00390
00391   return hr;
00392 }
00393
00394
00395 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00396   Method:   CGuiPaper::PaintWin
00397
00398   Summary:  Clears window background and repaints the current drawing
00399             on the paper. Relies on connectable object technology.
00400             The Redraw method in the COPaper object sends event
00401             notifications to this client in order to achieve a
00402             repaint of the drawing.  CGuiPaper does not have a copy of
00403             the drawing data--only the COPaper component in the server
00404             has that.
00405
00406   Args:     void
00407
00408   Modifies: ...
00409
00410   Returns:  HRESULT
00411               Standard result code. NOERROR for success.
00412 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00413 HRESULT CGuiPaper::PaintWin(void)
00414 {
00415   HRESULT hr = E_FAIL;
00416   COLORREF crInkColor;
00417   SHORT nInkWidth;
00418
00419   if (m_pIPaper && !m_bPainting && !m_bInking)
00420   {
00421     m_bPainting = TRUE;
00422     // Save and restore ink color and width since redraw otherwise
00423     // ends up changing these values in CGuiPaper.
00424     crInkColor = m_crInkColor;
00425     nInkWidth = m_nInkWidth;
00426     hr = m_pIPaper->Redraw(m_nLockKey);
00427     m_nInkWidth = nInkWidth;
00428     m_crInkColor = crInkColor;
00429     m_bPainting = FALSE;
00430   }
00431
00432   return hr;
00433 }
00434
00435
00436 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00437   Method:   CGuiPaper::Erase
00438
00439   Summary:  Erase content of the drawing paper and clear display window.
00440
00441   Args:     void.
00442
00443   Modifies: ...
00444
00445   Returns:  HRESULT
00446               Standard result code. NOERROR for success.
00447 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00448 HRESULT CGuiPaper::Erase(void)
00449 {
00450   HRESULT hr = E_FAIL;
00451
00452   if(m_nLockKey)
00453   {
00454     if (m_pIPaper)
00455       hr = m_pIPaper->Erase(m_nLockKey);
00456     if (SUCCEEDED(hr))
00457     {
00458       ClearWin();
00459       m_bDirty = TRUE;
00460     }
00461   }
00462
00463   return hr;
00464 }
00465
00466
00467 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00468   Method:   CGuiPaper::Resize
00469
00470   Summary:  Resizes current drawing paper rectangle.
00471
00472   Args:     WORD wWidth
00473               New window width. Max X coord.
00474             WORD wHeight
00475               New window height. Max Y coord.
00476
00477   Modifies: ...
00478
00479   Returns:  HRESULT
00480               Standard result code. NOERROR for success.
00481 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00482 HRESULT CGuiPaper::Resize(
00483                      WORD wWidth,
00484                      WORD wHeight)
00485 {
00486   if(m_nLockKey)
00487   {
00488     // Store the new window size and mark dirty.
00489     m_WinRect.right = wWidth;
00490     m_WinRect.bottom = wHeight;
00491     m_bDirty = TRUE;
00492   }
00493
00494   return NOERROR;
00495 }
00496
00497
00498 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00499   Method:   CGuiPaper::InkSaving
00500
00501   Summary:  Tell CGuiPaper whether ink data is being saved in the Paper
00502             object.
00503
00504   Args:     BOOL bInkSaving
00505               TRUE means save in COPaper object; FALSE means not.
00506
00507   Modifies: ...
00508
00509   Returns:  HRESULT
00510               Standard result code. NOERROR for success.
00511 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00512 HRESULT CGuiPaper::InkSaving(
00513                      BOOL bInkSaving)
00514 {
00515   m_bInkSaving = bInkSaving;
00516
00517   return NOERROR;
00518 }
00519
00520
00521 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00522   Method:   CGuiPaper::InkWidth
00523
00524   Summary:  Changes current ink width.
00525
00526   Args:     SHORT nInkWidth
00527               New ink width in pixels.
00528
00529   Modifies: ...
00530
00531   Returns:  HRESULT
00532               Standard result code. NOERROR for success.
00533 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00534 HRESULT CGuiPaper::InkWidth(
00535                      SHORT nInkWidth)
00536 {
00537   if (nInkWidth)
00538     m_nInkWidth = nInkWidth;
00539
00540   return NOERROR;
00541 }
00542
00543
00544 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00545   Method:   CGuiPaper::InkColor
00546
00547   Summary:  Changes current ink color.
00548
00549   Args:     COLORREF crInkColor
00550               RGB color ref value (eg, RGB(0,0,0) is black).
00551
00552   Modifies: ...
00553
00554   Returns:  HRESULT
00555               Standard result code. NOERROR for success.
00556 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00557 HRESULT CGuiPaper::InkColor(
00558                      COLORREF crInkColor)
00559 {
00560   m_crInkColor = crInkColor;
00561
00562   return NOERROR;
00563 }
00564
00565
00566 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00567   Method:   CGuiPaper::InkStart
00568
00569   Summary:  Starts an ink drawing sequence in the current color.
00570
00571   Args:     SHORT nX,
00572               X coordinate in window rectangle of start point.
00573             SHORT nY
00574               Y coordinate in window rectangle of start point.
00575
00576   Modifies: ...
00577
00578   Returns:  HRESULT
00579               Standard result code. NOERROR for success.
00580 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00581 HRESULT CGuiPaper::InkStart(
00582                      SHORT nX,
00583                      SHORT nY)
00584 {
00585   HRESULT hr = E_FAIL;
00586
00587   if (m_nLockKey || (!m_nLockKey && !m_bInkSaving))
00588   {
00589     // Start an ink drawing sequence only if one is not in progress.
00590     if (!m_bInking)
00591     {
00592       // Remember start position.
00593       m_OldPos.x = nX;
00594       m_OldPos.y = nY;
00595
00596       // Delete old pen.
00597       if (m_hPen)
00598         DeleteObject(m_hPen);
00599
00600       // Create and select the new drawing pen.
00601       m_hPen = CreatePen(PS_SOLID, m_nInkWidth, m_crInkColor);
00602       SelectObject(m_hDC, m_hPen);
00603
00604       hr = NOERROR;
00605
00606       // Ask the Paper object to mark the start of the ink drawing
00607       // sequence in the current ink color.
00608       if (m_pIPaper && m_bInkSaving)
00609       {
00610         hr = m_pIPaper->InkStart(
00611                           m_nLockKey,
00612                           nX,
00613                           nY,
00614                           m_nInkWidth,
00615                           m_crInkColor);
00616         // Capture the Mouse.
00617         SetCapture(m_hWnd);
00618
00619         // We've modified the ink data--it is now "dirty" with
00620         // respect to the compound file image. Set dirty flag.
00621         m_bDirty = TRUE;
00622       }
00623
00624       // Set inking flag to TRUE.
00625       m_bInking = TRUE;
00626     }
00627   }
00628
00629   return hr;
00630 }
00631
00632
00633 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00634   Method:   CGuiPaper::InkDraw
00635
00636   Summary:  Draws and saves ink data during the currently active ink
00637             drawing sequence.
00638
00639   Args:     SHORT nX,
00640               X coordinate in window rectangle of start point.
00641             SHORT nY
00642               Y coordinate in window rectangle of start point.
00643
00644   Modifies: ...
00645
00646   Returns:  HRESULT
00647               Standard result code. NOERROR for success.
00648 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00649 HRESULT CGuiPaper::InkDraw(
00650                      SHORT nX,
00651                      SHORT nY)
00652 {
00653   if (m_bInking)
00654   {
00655     // Start this ink line at previous old position.
00656     MoveToEx(m_hDC, m_OldPos.x, m_OldPos.y, NULL);
00657
00658     // Assign new old position and draw the new line.
00659     LineTo(m_hDC, m_OldPos.x = nX, m_OldPos.y = nY);
00660
00661     // Ask the Paper object to save this data.
00662     if (m_bInkSaving)
00663       m_pIPaper->InkDraw(m_nLockKey, nX, nY);
00664   }
00665
00666   return NOERROR;
00667 }
00668
00669
00670 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00671   Method:   CGuiPaper::InkStop
00672
00673   Summary:  Stops the currently active ink drawing sequence.
00674
00675   Args:     SHORT nX,
00676               X coordinate in window rectangle of start point.
00677             SHORT nY
00678               Y coordinate in window rectangle of start point.
00679
00680   Modifies: ...
00681
00682   Returns:  HRESULT
00683               Standard result code. NOERROR for success.
00684 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00685 HRESULT CGuiPaper::InkStop(
00686                      SHORT nX,
00687                      SHORT nY)
00688 {
00689   if (m_bInking)
00690   {
00691     // Start this ink line at previous old position.
00692     MoveToEx(m_hDC, m_OldPos.x, m_OldPos.y, NULL);
00693
00694     // Draw the last line.
00695     LineTo(m_hDC, nX, nY);
00696
00697     // Turn off inking.
00698     m_bInking = FALSE;
00699
00700     // Ask the Paper object to mark the stop of the ink drawing sequence.
00701     if (m_bInkSaving)
00702     {
00703       m_pIPaper->InkStop(m_nLockKey, nX, nY);
00704       // Free the mouse.
00705       ReleaseCapture();
00706     }
00707   }
00708
00709   return NOERROR;
00710 }
00711
00712
00713 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00714   Method:   CGuiPaper::GetConnectionPoint
00715
00716   Summary:  Internal private method to obtain a connection point interface.
00717
00718   Args:     REFIID riid
00719               IID of the requested connection point Interface.
00720
00721   Modifies: ...
00722
00723   Returns:  IConnectionPoint*
00724               Requested IConnectionPoint interface pointer. NULL if none.
00725 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00726 IConnectionPoint* CGuiPaper::GetConnectionPoint(
00727                     REFIID riid)
00728 {
00729   IConnectionPoint* pConnPoint = NULL;
00730   IConnectionPointContainer* pConnPointContainer = NULL;
00731   IConnectionPoint* pConnPt;
00732   HRESULT hr;
00733
00734   // First query the object for its Connection Point Container. This
00735   // essentially asks the object in the server if it is connectable.
00736   hr = m_pIPaper->QueryInterface(
00737          IID_IConnectionPointContainer,
00738          (PPVOID)&pConnPointContainer);
00739   if SUCCEEDED(hr)
00740   {
00741     // Find the requested Connection Point. This AddRef's the
00742     // returned pointer.
00743     hr = pConnPointContainer->FindConnectionPoint(riid, &pConnPt);
00744     if (SUCCEEDED(hr))
00745       pConnPoint = pConnPt;
00746
00747     RELEASE_INTERFACE(pConnPointContainer);
00748   }
00749
00750   return pConnPoint;
00751 }
00752
00753
00754 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00755   Method:   CGuiPaper::ConnectPaperSink
00756
00757   Summary:  Connect the PaperSink to the server COPaper source.
00758
00759   Args:     void
00760
00761   Modifies: ...
00762
00763   Returns:  HRESULT
00764               Standard result code. NOERROR for success.
00765 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00766 HRESULT CGuiPaper::ConnectPaperSink(void)
00767 {
00768   HRESULT hr = E_FAIL;
00769   DWORD dwKey;
00770   IConnectionPoint* pConnPoint;
00771
00772   if (!m_dwPaperSink)
00773   {
00774     // Get the Paper Sink connection point.
00775     pConnPoint = GetConnectionPoint(IID_IPaperSink);
00776     if (NULL != pConnPoint)
00777     {
00778       // Connect the object in the server to the Paper Sink in this client.
00779       hr = pConnPoint->Advise(m_pCOPaperSink, &dwKey);
00780       if (SUCCEEDED(hr))
00781         m_dwPaperSink = dwKey;
00782
00783       RELEASE_INTERFACE(pConnPoint);
00784     }
00785   }
00786
00787   return hr;
00788 }
00789
00790
00791 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00792   Method:   CGuiPaper::DisconnectPaperSink
00793
00794   Summary:  Disconnect the PaperSink from the server COPaper source.
00795
00796   Args:     void.
00797
00798   Modifies: ...
00799
00800   Returns:  HRESULT
00801               Standard result code. NOERROR for success.
00802 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00803 HRESULT CGuiPaper::DisconnectPaperSink(void)
00804 {
00805   HRESULT hr = E_FAIL;
00806   IConnectionPoint* pConnPoint;
00807
00808   if (m_dwPaperSink)
00809   {
00810     // Get the Paper Sink connection point.
00811     pConnPoint = GetConnectionPoint(IID_IPaperSink);
00812     if (NULL != pConnPoint)
00813     {
00814       // Disconnect the object in the server from the Paper Sink in
00815       // this client.
00816       hr = pConnPoint->Unadvise(m_dwPaperSink);
00817       if (SUCCEEDED(hr))
00818         m_dwPaperSink = 0;
00819
00820       RELEASE_INTERFACE(pConnPoint);
00821     }
00822   }
00823
00824   return hr;
00825 }
00826
00827
00828 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00829   Method:   CGuiPaper::Load
00830
00831   Summary:  Load paper data from the current compound file.
00832
00833   Args:     void.
00834
00835   Modifies: ...
00836
00837   Returns:  HRESULT
00838               Standard result code. NOERROR for success.
00839 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00840 HRESULT CGuiPaper::Load(void)
00841 {
00842   HRESULT hr = E_FAIL;
00843   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00844   HCURSOR hCurPrev;
00845   TCHAR szTitle[MAX_PATH + 32];
00846
00847   if (NULL != m_pPapFile)
00848   {
00849     // Change cursor to the hour glass.
00850     hCurPrev = SetCursor(hCurWait);
00851
00852     // Ask the PapFile object to load the paper data from current compound
00853     // file.
00854     hr = m_pPapFile->Load(m_nLockKey, NULL);
00855     if (SUCCEEDED(hr))
00856     {
00857       // Set Main Window Title.
00858       lstrcpyn(szTitle, TEXT(MAIN_APP_NAME_STR), sizeof(szTitle)/
00859         sizeof(TCHAR));
00860       lstrncat(szTitle, m_szFileTitle, sizeof(szTitle)/sizeof(TCHAR) -
00861         lstrlen(szTitle));
00862       SetWindowText(m_hWnd, szTitle);
00863       m_bDirty = FALSE;
00864     }
00865
00866     // Set Cursor back to what it was.
00867     SetCursor(hCurPrev);
00868   }
00869
00870   return hr;
00871 }
00872
00873
00874 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00875   Method:   CGuiPaper::Save
00876
00877   Summary:  Calls on CPapFile to save the current drawing's paper data in
00878             the current compound file.
00879
00880   Args:     void.
00881
00882   Modifies: ...
00883
00884   Returns:  HRESULT
00885               Standard result code. NOERROR for success.
00886 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00887 HRESULT CGuiPaper::Save(void)
00888 {
00889   HRESULT hr = E_FAIL;
00890   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00891   HCURSOR hCurPrev;
00892
00893   if (NULL != m_pPapFile)
00894   {
00895     // Change cursor to the hour glass.
00896     hCurPrev = SetCursor(hCurWait);
00897
00898     // Ask the PapFile object to save itself. NULL for file name means
00899     // save current file.
00900     hr = m_pPapFile->Save(m_nLockKey, NULL);
00901     if (SUCCEEDED(hr))
00902       m_bDirty = FALSE;
00903
00904     // Set Cursor back to what it was.
00905     SetCursor(hCurPrev);
00906   }
00907
00908   return hr;
00909 }
00910
00911
00912 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00913   Method:   CGuiPaper::AskSave
00914
00915   Summary:  Checks dirty flag (ie, if current displayed paper data was
00916             modified and is out of sync with the paper data stored in a
00917             compound file). If dirty, then ask user in simple dialog if he
00918             wants to save new data. If he says yes, then save the current
00919             paper data into the current compound file.
00920
00921   Args:     void.
00922
00923   Returns:  INT
00924               Value returned from the Win32 MessageBox function.
00925 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00926 INT CGuiPaper::AskSave(void)
00927 {
00928   int iAns = IDNO;
00929   TCHAR szTitle[MAX_STRING_LENGTH];
00930   TCHAR szAsk[MAX_STRING_LENGTH];
00931   TCHAR szMsg[MAX_PATH + MAX_STRING_LENGTH];
00932
00933   // If current data is dirty then ask user if he wants to save it.
00934   if (m_bDirty)
00935   {
00936     if (LoadString(m_hInst, IDS_DRAWING_CHANGED, szTitle, MAX_STRING_LENGTH)
00937         && LoadString(m_hInst, IDS_ASK_SAVE, szAsk, MAX_STRING_LENGTH))
00938     {
00939       lstrcpyn(szMsg, m_szFileName, sizeof(szMsg)/sizeof(TCHAR));
00940       lstrncat(szMsg, szAsk, sizeof(szMsg)/sizeof(TCHAR) - lstrlen(szMsg));
00941       // Display AskSaveDlg to user. Ask if he wants to save.
00942       iAns = MessageBox(
00943                m_hWnd,
00944                szMsg,
00945                szTitle,
00946                MB_YESNOCANCEL | MB_ICONEXCLAMATION);
00947       if (IDYES == iAns)
00948       {
00949         // Tell CPapFile to save itself to the current compound file.
00950         Save();
00951       }
00952     }
00953   }
00954
00955   return iAns;
00956 }
00957
00958
00959 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00960   Method:   CGuiPaper::Open
00961
00962   Summary:  If current data has been modified then ask user if he wants to
00963             first save it to the current file. Then use Open File Name
00964             common dialog to ask user for a new file name to load. If user
00965             chooses a file name then load the paper data from that
00966             compound file.
00967
00968   Args:     void.
00969
00970   Modifies: ...
00971
00972   Returns:  HRESULT
00973               Standard result code. NOERROR for success.
00974 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00975 HRESULT CGuiPaper::Open(void)
00976 {
00977   HRESULT hr = NOERROR;
00978   TCHAR szFileName[MAX_PATH];
00979   TCHAR szTitle[MAX_PATH];
00980   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00981   HCURSOR hCurPrev;
00982   BOOL bOpen;
00983
00984   // If current data is dirty then ask user if he wants to save it first.
00985   if (IDCANCEL != AskSave())
00986   {
00987     // Use the Open File Name common dialog to get file name from user.
00988     // Set the dialog's file filter and title.
00989     szFileName[0] = 0;
00990     m_ofnFile.lpstrFile = szFileName;
00991     if (LoadString(m_hInst, IDS_OFN_PAPOPEN, szTitle, sizeof(szTitle)/
00992       sizeof(TCHAR)))
00993       m_ofnFile.lpstrTitle = szTitle;
00994     m_ofnFile.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
00995
00996     // Call up the dialog to get a file name from the user.
00997     m_bPainting = TRUE;
00998     bOpen = GetOpenFileName(&m_ofnFile);
00999     m_bPainting = FALSE;
01000     if (bOpen)
01001     {
01002       // Change cursor to the hour glass.
01003       hCurPrev = SetCursor(hCurWait);
01004
01005       // Tell CPapFile object to load the paper data from the newly
01006       // chosen compound file.
01007       hr = m_pPapFile->Load(m_nLockKey, szFileName);
01008       if (SUCCEEDED(hr))
01009       {
01010         // Remember the new current compound file name.
01011         lstrcpyn(m_szFileName, szFileName, sizeof(m_szFileName)/
01012           sizeof(TCHAR));
01013
01014         // Set Main Window Title.
01015         lstrcpyn(szFileName, TEXT(MAIN_APP_NAME_STR), sizeof(szFileName)/
01016           sizeof(TCHAR));
01017         lstrncat(szFileName, m_szFileTitle, sizeof(szFileName)/sizeof(TCHAR) -
01018           lstrlen(szFileName));
01019         SetWindowText(m_hWnd, szFileName);
01020
01021         m_bDirty = FALSE;
01022       }
01023
01024       // Set Cursor back to what it was.
01025       SetCursor(hCurPrev);
01026     }
01027   }
01028
01029   return hr;
01030 }
01031
01032
01033 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01034   Method:   CGuiPaper::SaveAs
01035
01036   Summary:  Use the File SaveAs common dialog to ask user for a new file
01037             name to save to. Then save the current paper data to the
01038             specified compound file. That file becomes the new current
01039             file. The previously open file is left unchanged since the
01040             last save to it.
01041
01042   Args:     void.
01043
01044   Modifies: ...
01045
01046   Returns:  HRESULT
01047               Standard result code. NOERROR for success.
01048 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01049 HRESULT CGuiPaper::SaveAs(void)
01050 {
01051   HRESULT hr = E_FAIL;
01052   TCHAR szFileName[MAX_PATH];
01053   TCHAR szTitle[MAX_PATH];
01054   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01055   HCURSOR hCurPrev;
01056   BOOL bOpen;
01057
01058   // Use the File Save As common dialog to get file name from user.
01059   // Set the dialog's file filter and title.
01060   szFileName[0] = 0;
01061   m_ofnFile.lpstrFile = szFileName;
01062   if (LoadString(m_hInst, IDS_OFN_PAPSAVE, szTitle, sizeof(szTitle)/
01063     sizeof(TCHAR)))
01064     m_ofnFile.lpstrTitle = szTitle;
01065   m_ofnFile.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
01066
01067   // Call up the dialog to get a file name from the user.
01068   m_bPainting = TRUE;
01069   bOpen = GetSaveFileName(&m_ofnFile);
01070   m_bPainting = FALSE;
01071   if (bOpen)
01072   {
01073     // Change cursor to the hour glass.
01074     hCurPrev = SetCursor(hCurWait);
01075
01076     // Tell CPapFile object to save the paper data to the newly
01077     // chosen compound file.
01078     hr = m_pPapFile->Save(m_nLockKey, szFileName);
01079     if (SUCCEEDED(hr))
01080     {
01081       // Remember the new current compound file name.
01082       lstrcpyn(m_szFileName, szFileName, sizeof(m_szFileName)/sizeof(TCHAR));
01083
01084       // Set Main Window Title.
01085       lstrcpyn(szFileName, TEXT(MAIN_APP_NAME_STR), sizeof(szFileName)/
01086         sizeof(TCHAR));
01087       lstrncat(szFileName, m_szFileTitle, sizeof(szFileName)/sizeof(TCHAR) -
01088         lstrlen(szFileName));
01089       SetWindowText(m_hWnd, szFileName);
01090
01091       m_bDirty = FALSE;
01092     }
01093
01094     // Set Cursor back to what it was.
01095     SetCursor(hCurPrev);
01096   }
01097
01098   return hr;
01099 }
01100
01101
01102 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01103   Method:   CGuiPaper::PickColor
01104
01105   Summary:  Uses the Choose Color common dialog to ask user for new
01106             Pen color. Return that new color.
01107
01108   Args:     void.
01109
01110   Returns:  COLORREF
01111               New chosen color.
01112 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01113 COLORREF CGuiPaper::PickColor(void)
01114 {
01115   COLORREF crNewColor = m_crInkColor;
01116   SHORT i;
01117
01118   // Init the custom color array with gray colors.
01119   for (i=0; i<16; i++)
01120     m_acrCustColors[i] = RGB(i*16, i*16, i*16);
01121
01122   // Init the Choose Color structure.
01123   m_ChooseColor.lStructSize = sizeof(CHOOSECOLOR);
01124   m_ChooseColor.hwndOwner = m_hWnd;
01125   m_ChooseColor.hInstance = (HWND) m_hInst;
01126   m_ChooseColor.rgbResult = m_crInkColor;
01127   m_ChooseColor.lpCustColors = (DWORD*) m_acrCustColors;
01128   m_ChooseColor.Flags = CC_PREVENTFULLOPEN | CC_RGBINIT;
01129   m_ChooseColor.lCustData = 0L;
01130   m_ChooseColor.lpfnHook = NULL;
01131   m_ChooseColor.lpTemplateName = NULL;
01132
01133   if (ChooseColor(&m_ChooseColor))
01134     crNewColor = m_ChooseColor.rgbResult;
01135
01136   return crNewColor;
01137 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/DropTgt.h Source File

  • WinUI
  • Shell
  • SampView

DropTgt.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          DropTgt.h
00013
00014    Description:   CDropTarget definitions.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023 #include <ole2.h>
00024 #include <shlobj.h>
00025 #include "ShlFldr.h"
00026 #include "PidlMgr.h"
00027
00028 /**************************************************************************
00029    global variables and definitions
00030 **************************************************************************/
00031
00032 /**************************************************************************
00033    class definitions
00034 **************************************************************************/
00035
00036 class FAR CDropTarget : public IDropTarget
00037 {
00038 public:
00039    CDropTarget(CShellFolder*);
00040    ~CDropTarget();
00041
00042    //IUnknown methods
00043    STDMETHOD(QueryInterface)(REFIID, LPVOID*);
00044    STDMETHOD_(ULONG, AddRef)(void);
00045    STDMETHOD_(ULONG, Release)(void);
00046
00047    //IDropTarget methods
00048    STDMETHOD(DragEnter)(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
00049    STDMETHOD(DragOver)(DWORD, POINTL, LPDWORD);
00050    STDMETHOD(DragLeave)(VOID);
00051    STDMETHOD(Drop)(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
00052
00053 private:
00054    CShellFolder   *m_psfParent;
00055    CPidlMgr       *m_pPidlMgr;
00056    IMalloc        *m_pMalloc;
00057    ULONG          m_ObjRefCount;
00058    BOOL           m_fAcceptFmt;
00059    UINT           m_cfPrivateData;
00060
00061    BOOL QueryDrop(DWORD, LPDWORD);
00062    DWORD GetDropEffectFromKeyState(DWORD);
00063    BOOL DoDrop(HGLOBAL, BOOL);
00064    LPITEMIDLIST* AllocPidlTable(DWORD);
00065    VOID FreePidlTable(LPITEMIDLIST*);
00066 };
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

icmpv6_echo_request Member List

This is the complete list of members for icmpv6_echo_request, including all inherited members.
icmp6_echo_id | icmpv6_echo_request
icmp6_echo_sequence | icmpv6_echo_request
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tSReq Member List

This is the complete list of members for tSReq, including all inherited members.
Action | tSReq
Async | tSReq
bBuf | tSReq
bImpersonating | tSReq
bLastDataPushIssued | tSReq
bNullPush | tSReq
bPushOutstanding | tSReq
bReadOutstanding | tSReq
bReadsDone | tSReq
cbRead | tSReq
fCallInvalidated | tSReq
FileOl | tSReq
FileReadPos | tSReq
hFileRepClient | tSReq
hLocalFile | tSReq
hTokenHandle | tSReq
LocalFileName | tSReq
Lock | tSReq
OutPipe | tSReq
pbReadBuf | tSReq
Pri | tSReq
pSID | tSReq
PushSize | tSReq
State | tSReq
Status | tSReq
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cmainwindow.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cmainwindow.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CMAINWINDOW.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CMAINWINDOW_H_
00012 #define _CMAINWINDOW_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Defines
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019 enum IMAGEICONS
00020 {
00021   IMAGE_NORMAL    = 0,
00022   IMAGE_CHECKED   = 1,
00023   IMAGE_UNCHECKED   = 2,
00024   IMAGE_LOCK      = 3,
00025   IMAGE_QUESTION    = 4,
00026   IMAGE_ERROR     = 5,
00027   IMAGE_FORM      = 6,
00028   IMAGE_ARROW_UP    = 7,
00029   IMAGE_ARROW_DOWN  = 8,
00030   IMAGE_DELETE    = 9,
00031   IMAGE_CHANGE    = 10,
00032   IMAGE_INSERT    = 11,
00033   IMAGE_CHAPTER   = 12,
00034   IMAGE_MULTIPLE    = 13,
00035   IMAGE_OBJECTS   = 14,
00036   IMAGE_DATASOURCE  = 15,
00037   IMAGE_SESSION   = 16,
00038   IMAGE_COMMAND   = 17,
00039   IMAGE_TABLE     = 18,
00040   IMAGE_SERVICECOMP = 19,
00041   IMAGE_DATALINKS   = 19,
00042   IMAGE_REMOTING    = 20,
00043   IMAGE_DRAWNPOOL   = 21,
00044   IMAGE_POOLING   = 22,
00045   IMAGE_INTERFACE   = 23,
00046   IMAGE_STREAM    = 24,
00047   IMAGE_CUBE      = 25
00048 };
00049
00050
00051 //////////////////////////////////////////////////////////////////////////////
00052 // Includes
00053 //
00054 //////////////////////////////////////////////////////////////////////////////
00055 #include "Property.h"
00056 #include "CDialog.h"
00057 #include "CMDIChild.h"
00058 #include "CListener.h"
00059 #include "CTrace.h"
00060 #include "CObjTree.h"
00061 #include "CBinder.h"
00062 #include "CRowset.h"
00063 #include "COptions.h"
00064
00065
00066 //////////////////////////////////////////////////////////////////////////////
00067 // Defines
00068 //
00069 //////////////////////////////////////////////////////////////////////////////
00070 enum STATEICONS
00071 {
00072   STATE_NORMAL    = 0,
00073   STATE_CHECKED   = 1,
00074   STATE_UNCHECKED   = 2
00075 };
00076
00077 enum COLUMN_DESC
00078 {
00079   COLUMN_DBCID,
00080   COLUMN_TYPENAME,
00081   COLUMN_DATATYPE,
00082   COLUMN_SIZE,
00083   COLUMN_PREC,
00084   COLUMN_SCALE
00085 };
00086
00087 enum INDEX_COLUMN_DESC
00088 {
00089   COLUMN_ID,
00090   COLUMN_ORDER
00091 };
00092
00093 enum COLUMN_ISCO
00094 {
00095   COLUMN_ISCO_SRCURL,
00096   COLUMN_ISCO_DESTURL
00097 };
00098
00099
00100 /////////////////////////////////////////////////////////////////////
00101 // CMainWindow
00102 //
00103 /////////////////////////////////////////////////////////////////////
00104 class CMainWindow : public CMDIFrameLite
00105 {
00106 public:
00107   //constructors
00108   CMainWindow();
00109   virtual ~CMainWindow();
00110
00111   //Messages
00112   virtual BOOL OnCreate(LPCREATESTRUCT lpCreateStruct);
00113   virtual BOOL OnDestroy();
00114   virtual BOOL OnInitialUpdate();
00115
00116   virtual BOOL OnSize(WPARAM nType, REFPOINTS pts);
00117   virtual BOOL OnMenuSelect(UINT uID);
00118   virtual BOOL OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu);
00119
00120   virtual BOOL OnCommand(UINT iID, HWND hWndCtrl);
00121   virtual BOOL OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags);
00122   virtual BOOL OnDropFiles(HDROP hDrop);
00123
00124   //IUnknown Menu
00125   virtual void OnAddRef(CBase* pCBase);
00126   virtual void OnRelease(CBase* pCBase);
00127   virtual void OnQueryInterface(CBase* pCBase);
00128   virtual void OnAutoQI(CBase* pCBase);
00129   virtual void OnReleaseAll(CBase* pCBase, BOOL fChildren = FALSE);
00130   virtual void OnSupportErrorInfo(CBase* pCBase);
00131
00132   //ConnectionPoints
00133   virtual void OnFindConnectionPoint(CContainerBase* pCCPointBase, REFIID riid);
00134   virtual void OnGetConnectionInterface(CConnectionPoint* pCConnectionPoint);
00135   virtual void OnAdvise(CConnectionPoint* pCConnectionPoint);
00136   virtual void OnUnadvise(CConnectionPoint* pCConnectionPoint);
00137
00138   //Asynchronous
00139   virtual void OnAbort(CAsynchBase* pCAsynchBase);
00140   virtual void OnGetStatus(CAsynchBase* pCAsynchBase);
00141   virtual void OnInitialize(CAsynchBase* pCAsynchBase);
00142   virtual void OnUninitialize(CAsynchBase* pCAsynchBase);
00143
00144   //File Menu
00145   virtual void OnConnect();
00146   virtual void OnLoadStringFromStorage(WCHAR* pwszFileName = NULL);
00147   virtual void OnGetDataSource();
00148   virtual void OnPromptDataSource(BOOL fAdvanced = FALSE);
00149   virtual void OnPromptFileName(BOOL fAdvanced = FALSE);
00150   virtual void OnCreateFileMoniker();
00151
00152   virtual void OnRootBinder();
00153   virtual void OnRootEnumerator();
00154   virtual void OnServiceComponents();
00155   virtual void OnDataLinks();
00156
00157   virtual void OnLoadRecentConfig(UINT iID);
00158   virtual void OnLoadRecentFile(UINT iID);
00159
00160   //Error Menu
00161
00162   //Tools Menu
00163   virtual void OnOptions();
00164   virtual void OnTraceWindow();
00165   virtual void OnObjectsWindow();
00166
00167   //Windows Menu
00168   virtual void OnDisconnect();
00169   virtual void OnTile(BOOL fHorizontal);
00170   virtual void OnCascade();
00171   virtual void OnArrangeIcons();
00172   virtual void OnCloseAll();
00173   virtual void OnNextWindow(BOOL fNextWindow);
00174
00175   //Help Menu
00176   virtual void OnAbout();
00177
00178   //Helpers
00179   virtual BOOL UpdateControls();
00180   virtual BOOL LoadSettings();
00181   virtual BOOL SaveSettings();
00182
00183   //MDI Child Windows
00184   virtual BOOL      RemoveAllChildren();
00185   virtual INT_PTR     DisplayDialog(UINT uID, HWND hWndParent, DLGPROC lpDialogFunc, CBase* pCObject, UINT idSource = 0);
00186
00187   virtual CBase*      HandleObjectType(CBase* pCSource, IUnknown* pIUnknown, REFIID riid, SOURCE eSource, ULONG cPropSets, DBPROPSET* rgPropSets, DWORD dwFlags);
00188
00189   virtual COptionsSheet*  GetOptions()  { return m_pCOptionsSheet;      }
00190   virtual CBase**     GetObjectAddress(SOURCE eSource = eCUnknown);
00191   virtual CBase*      GetObject(SOURCE eSource = eCUnknown, BOOL fAlways = FALSE);
00192
00193   //Binder Procs
00194   static INT_PTR WINAPI BindResourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00195   static INT_PTR WINAPI RegisterProviderProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00196
00197   //IDataInitialize
00198   static INT_PTR WINAPI GetDataSourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00199   static INT_PTR WINAPI EnumPropertiesProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00200
00201   //IDBPromptInitialize
00202   static INT_PTR WINAPI PromptDataSourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00203   static INT_PTR WINAPI PromptFileNameProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00204
00205   //Enum Procs
00206   static INT_PTR WINAPI GetSourcesRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00207
00208   //Error Procs
00209   static INT_PTR WINAPI ErrorRecordsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00210
00211   //Stream Procs
00212   static INT_PTR WINAPI StreamViewerProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00213
00214
00215   //Objects
00216   CFullConnect*     m_pCFullConnect;
00217   COptionsSheet*      m_pCOptionsSheet;
00218   CBinder*        m_pCRootBinder;
00219   CEnumerator*      m_pCRootEnumerator;
00220   CServiceComp*     m_pCServiceComp;
00221   CDataLinks*       m_pCDataLinks;
00222   CListener*        m_pCListener;
00223
00224   //Controls
00225   CStatusBarLite      m_CStatusBar;
00226   CToolBarLite      m_CToolBar;
00227
00228   //MDI Windows
00229   CMDITrace*        m_pCMDITrace;
00230   CMDIObjects*      m_pCMDIObjects;
00231
00232   //Other
00233   HIMAGELIST        m_hImageList;
00234   HIMAGELIST        m_hStateList;
00235
00236   //Handles
00237   HCURSOR         m_hCurSizeNS;
00238   HMODULE         m_hLibRichEdit20;
00239   HMODULE         m_hLibRichEdit10;
00240
00241   //list of MTS interfaces
00242   CList<ITransaction*, ITransaction*> m_listTransactions;
00243
00244   //Source
00245   CBase*          m_pCSource;
00246   ULONG         m_idSource;
00247 };
00248
00249
00250
00251
00252 /////////////////////////////////////////////////////////////////////////////
00253 // CAboutDlg
00254 //
00255 /////////////////////////////////////////////////////////////////////////////
00256 class CAboutDlg : public CDialogLite
00257 {
00258 public:
00259   CAboutDlg();
00260
00261   //Messages
00262   virtual BOOL OnInitDialog();
00263
00264 protected:
00265   //data
00266 };
00267
00268
00269
00270 #endif //_CMAINWINDOW_H_
Generated on Wed Nov 13 2024 16:52:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

GlobalVars Member List

This is the complete list of members for GlobalVars, including all inherited members.
agentSockAddr | GlobalVars |
doSet | GlobalVars |
fDone | GlobalVars |
g_hInst | GlobalVars |
GlobalVars() | GlobalVars | [inline]
max_repetitions | GlobalVars |
non_repeaters | GlobalVars |
nRequestId | GlobalVars |
nRetries | GlobalVars |
nTimeOut | GlobalVars |
oid | GlobalVars |
oidCount | GlobalVars |
operation | GlobalVars |
pAgentCommunity | GlobalVars |
pAgentStrAddr | GlobalVars |
pSetValue | GlobalVars |
pszOid | GlobalVars |
startOid | GlobalVars |
value | GlobalVars |
version | GlobalVars |
~GlobalVars() | GlobalVars | [inline]
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/registry.Cpp Source File

  • SysMgmt
  • MMC
  • Openserv

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "globals.h"
00026
00027 ////////////////////////////////////////////////////////
00028 //
00029 // Internal helper functions prototypes
00030 //
00031
00032 // Set the given key and its value.
00033 BOOL setKeyAndValue(const _TCHAR* pszPath,
00034                     const _TCHAR* szSubkey,
00035                     const _TCHAR* szValue) ;
00036
00037 // Set the given key and its value in the MMC Snapin location
00038 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00039                           const _TCHAR* szSubkey,
00040                           const _TCHAR* szName,
00041                           const _TCHAR* szValue);
00042
00043 // Set the given valuename under the key to value
00044 BOOL setValue(const _TCHAR* szKey,
00045               const _TCHAR* szValueName,
00046               const _TCHAR* szValue);
00047
00048 // Delete szKeyChild and all of its descendents.
00049 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // Constants
00054 //
00055
00056 // Size of a CLSID as a string
00057 //const int CLSID_STRING_SIZE = 39 ;
00058
00059 /////////////////////////////////////////////////////////
00060 //
00061 // Public function implementation
00062 //
00063
00064 //
00065 // Register the component in the registry.
00066 //
00067 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00068                        const CLSID& clsid,         // Class ID
00069                        const _TCHAR* szFriendlyName)       //   IDs
00070 {
00071     // Get server location.
00072     _TCHAR szModule[512] ;
00073     DWORD dwResult =
00074         ::GetModuleFileName(hModule,
00075         szModule,
00076         sizeof(szModule)/sizeof(_TCHAR)) ;
00077
00078     assert(dwResult != 0) ;
00079
00080     // Get CLSID
00081     LPOLESTR wszCLSID = NULL ;
00082     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00083
00084     assert(SUCCEEDED(hr)) ;
00085
00086         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00087
00088     // Build the key CLSID\\{...}
00089     _TCHAR szKey[64] ;
00090     _tcscpy(szKey, _T("CLSID\\")) ;
00091         _tcscat(szKey, pszCLSID) ;
00092
00093     // Add the CLSID to the registry.
00094     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00095
00096     // Add the server filename subkey under the CLSID key.
00097     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00098
00099     // set the threading model
00100     _tcscat(szKey, _T("\\InprocServer32"));
00101     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00102
00103     // Free memory.
00104     CoTaskMemFree(wszCLSID) ;
00105
00106     return S_OK ;
00107 }
00108
00109 //
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00113 {
00114     // Get CLSID
00115     LPOLESTR wszCLSID = NULL ;
00116     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00117
00118
00119     // Build the key CLSID\\{...}
00120     _TCHAR szKey[64] ;
00121     _tcscpy(szKey, _T("CLSID\\")) ;
00122
00123         MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00124         _tcscat(szKey, pszT) ;
00125
00126     // Delete the CLSID Key - CLSID\{...}
00127     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00128     assert((lResult == ERROR_SUCCESS) ||
00129                (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00130
00131     // Free memory.
00132     CoTaskMemFree(wszCLSID) ;
00133
00134     return S_OK ;
00135 }
00136
00137 //
00138 // Register the snap-in in the registry.
00139 //
00140 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00141                        const _TCHAR* szNameString,   // NameString
00142                        const CLSID& clsidAbout,         // Class Id for About Class
00143                        const BOOL fSupportExtensions)
00144 {
00145     // Get CLSID
00146     LPOLESTR wszCLSID = NULL ;
00147     LPOLESTR wszAboutCLSID = NULL;
00148     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00149
00150     if (IID_NULL != clsidAbout)
00151         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00152
00153         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00154         MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00155
00156
00157     // Add the CLSID to the registry.
00158     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00159     setSnapInKeyAndValue(pszCLSID, _T("StandAlone"), NULL, NULL);
00160     if (IID_NULL != clsidAbout)
00161         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00162
00163     if (fSupportExtensions) {
00164         // Build the key NodeType
00165         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00166
00167         _TCHAR szKey[64] ;
00168         _tcscpy(szKey, pszCLSID) ;
00169         _tcscat(szKey, _T("\\NodeTypes")) ;
00170         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00171     }
00172
00173     // Free memory.
00174     CoTaskMemFree(wszCLSID) ;
00175     if (IID_NULL != clsidAbout)
00176         CoTaskMemFree(wszAboutCLSID);
00177
00178     return S_OK ;
00179 }
00180
00181 //
00182 // Unregister the snap-in in the registry.
00183 //
00184 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00185 {
00186     _TCHAR szKeyBuf[1024];
00187     LPOLESTR wszCLSID = NULL;
00188
00189     // Get CLSID
00190     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00191         MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00192
00193     // Load the buffer with the Snap-In Location
00194     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00195
00196     // Copy keyname into buffer.
00197     _tcscat(szKeyBuf, _T("\\"));
00198     _tcscat(szKeyBuf, pszCLSID);
00199
00200     // Delete the CLSID Key - CLSID\{...}
00201     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00202     assert((lResult == ERROR_SUCCESS) ||
00203                (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00204
00205     // free the memory
00206     CoTaskMemFree(wszCLSID);
00207
00208     return S_OK;
00209 }
00210
00211 //
00212 // Delete a key and all of its descendents.
00213 //
00214 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00215                         const _TCHAR* lpszKeyChild)  // Key to delete
00216 {
00217     // Open the child.
00218     HKEY hKeyChild ;
00219     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00220         KEY_ALL_ACCESS, &hKeyChild) ;
00221     if (lRes != ERROR_SUCCESS)
00222     {
00223         return lRes ;
00224     }
00225
00226     // Enumerate all of the decendents of this child.
00227     FILETIME time ;
00228     _TCHAR szBuffer[256] ;
00229     DWORD dwSize = 256 ;
00230     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00231         NULL, NULL, &time) == S_OK)
00232     {
00233         // Delete the decendents of this child.
00234         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00235         if (lRes != ERROR_SUCCESS)
00236         {
00237             // Cleanup before exiting.
00238             RegCloseKey(hKeyChild) ;
00239             return lRes;
00240         }
00241         dwSize = 256 ;
00242     }
00243
00244     // Close the child.
00245     RegCloseKey(hKeyChild) ;
00246
00247     // Delete this child.
00248     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00249 }
00250
00251 //
00252 // Create a key and set its value.
00253 //   - This helper function was borrowed and modifed from
00254 //     Kraig Brockschmidt's book Inside OLE.
00255 //
00256 BOOL setKeyAndValue(const _TCHAR* szKey,
00257                     const _TCHAR* szSubkey,
00258                     const _TCHAR* szValue)
00259 {
00260     HKEY hKey;
00261     _TCHAR szKeyBuf[1024] ;
00262
00263     // Copy keyname into buffer.
00264     _tcscpy(szKeyBuf, szKey) ;
00265
00266     // Add subkey name to buffer.
00267     if (szSubkey != NULL)
00268     {
00269         _tcscat(szKeyBuf, _T("\\")) ;
00270         _tcscat(szKeyBuf, szSubkey ) ;
00271     }
00272
00273     // Create and open key and subkey.
00274     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00275         szKeyBuf,
00276         0, NULL, REG_OPTION_NON_VOLATILE,
00277         KEY_ALL_ACCESS, NULL,
00278         &hKey, NULL) ;
00279     if (lResult != ERROR_SUCCESS)
00280     {
00281         return FALSE ;
00282     }
00283
00284     // Set the Value.
00285     if (szValue != NULL)
00286     {
00287         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00288             (BYTE *)szValue,
00289             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00290     }
00291
00292     RegCloseKey(hKey) ;
00293     return TRUE ;
00294 }
00295
00296 //
00297 // Open a key value and set it
00298 //
00299 BOOL setValue(const _TCHAR* szKey,
00300               const _TCHAR* szValueName,
00301               const _TCHAR* szValue)
00302 {
00303     HKEY hKey;
00304     _TCHAR szKeyBuf[1024] ;
00305
00306     // Copy keyname into buffer.
00307     _tcscpy(szKeyBuf, szKey) ;
00308
00309     // Create and open key and subkey.
00310     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00311         szKeyBuf,
00312         0, NULL, REG_OPTION_NON_VOLATILE,
00313         KEY_ALL_ACCESS, NULL,
00314         &hKey, NULL) ;
00315     if (lResult != ERROR_SUCCESS)
00316     {
00317         return FALSE ;
00318     }
00319
00320     // Set the Value.
00321     if (szValue != NULL)
00322     {
00323         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00324             (BYTE *)szValue,
00325             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00326     }
00327
00328     RegCloseKey(hKey) ;
00329     return TRUE ;
00330 }
00331
00332 //
00333 // Create a key and set its value.
00334 //   - This helper function was borrowed and modifed from
00335 //     Kraig Brockschmidt's book Inside OLE.
00336 //
00337 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00338                           const _TCHAR* szSubkey,
00339                           const _TCHAR* szName,
00340                           const _TCHAR* szValue)
00341 {
00342     HKEY hKey;
00343     _TCHAR szKeyBuf[1024] ;
00344
00345     // Load the buffer with the Snap-In Location
00346     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00347
00348     // Copy keyname into buffer.
00349     _tcscat(szKeyBuf, _T("\\")) ;
00350     _tcscat(szKeyBuf, szKey) ;
00351
00352     // Add subkey name to buffer.
00353     if (szSubkey != NULL)
00354     {
00355         _tcscat(szKeyBuf, _T("\\")) ;
00356         _tcscat(szKeyBuf, szSubkey ) ;
00357     }
00358
00359     // Create and open key and subkey.
00360     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00361         szKeyBuf,
00362         0, NULL, REG_OPTION_NON_VOLATILE,
00363         KEY_ALL_ACCESS, NULL,
00364         &hKey, NULL) ;
00365     if (lResult != ERROR_SUCCESS)
00366     {
00367         return FALSE ;
00368     }
00369
00370     // Set the Value.
00371     if (szValue != NULL)
00372     {
00373         RegSetValueEx(hKey, szName, 0, REG_SZ,
00374             (BYTE *)szValue,
00375             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00376     }
00377
00378     RegCloseKey(hKey) ;
00379     return TRUE ;
00380 }
00381
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Surrog/csur.Cpp Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Surrog

csur.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 ///////////////////////////////////////////////////////////////////////////////////
00019 //
00020 // CSur.cpp
00021 //
00022 // CSurrogate implementation.
00023 //
00024 //////////////////////////////////////////////////////////////////////////////////
00025 #include "common.h"
00026 #include "csur.h"
00027
00028 // IUnknown
00029
00030 //
00031 // IUknown::QueryInterface() -
00032 //
00033 // ISurrogate and IUknown are all the surrogate object supports.
00034 //
00035 STDMETHODIMP CSurrogate::QueryInterface(REFIID riid, void **ppv)
00036 {
00037   *ppv = 0;
00038   if (riid == IID_IUnknown || riid == IID_ISurrogate)
00039     *ppv = (ISurrogate *) this;
00040   else
00041     return E_NOINTERFACE;
00042   ((IUnknown*) *ppv)->AddRef();
00043   return S_OK;
00044 }
00045
00046 //
00047 //  IUnknown::AddRef() -
00048 //
00049 //  We've allocated this object on the stack in
00050 //  WinMain().  Therefore we don't have a real lifetime for it
00051 //
00052 STDMETHODIMP_(ULONG) CSurrogate::AddRef()
00053 {
00054   return 2;
00055 }
00056
00057 //
00058 //  IUnknown::Release() -
00059 //
00060 //  We've allocated this object on the stack in
00061 //  WinMain().  Therefore we don't have a real lifetime for it so
00062 //  we won't delete it here.
00063 //
00064 STDMETHODIMP_(ULONG) CSurrogate::Release()
00065 {
00066   return 1;
00067 }
00068
00069
00070 // ISurrogate
00071
00072 //
00073 // ISurrogate::LoadDllServer() -
00074 //
00075 // LoadDllServer() is called when a new object is being created.
00076 // Create the wrapper class factory object and register it.  Keep track of it in our
00077 // stack object.
00078 //
00079 STDMETHODIMP CSurrogate::LoadDllServer(REFCLSID rclsid)
00080 {
00081   OutputDebugString("ISurrogate::LoadDllServer() called.");
00082   // instantiate a new class factory wrapper object
00083   CClassFactoryWrapper * pcfw = new CClassFactoryWrapper(rclsid);
00084
00085   if (!pcfw) return E_OUTOFMEMORY;
00086
00087   // register this new class factory wrapper (use REGCLS_SURROGATE)
00088   pcfw->AddRef();
00089   HRESULT hr = CoRegisterClassObject(rclsid, (IClassFactory*)pcfw,
00090                     CLSCTX_LOCAL_SERVER, REGCLS_SURROGATE,
00091                     &pcfw->m_dwReg);
00092
00093   // push this one into our stack
00094   if (SUCCEEDED(hr))
00095     m_stkClassFactories.push(pcfw);
00096   else
00097     pcfw->Release();
00098   return hr;
00099 }
00100
00101 //
00102 // ISurrogate::FreeSurrogate() -
00103 //
00104 // We don't need to "revoke" the surrogate object.  We do need to revoke the class
00105 // factory objects we've created and this is called by COM to allow us to do that.
00106 // It's also a chance to quit the application since we're not needed any more.
00107 //
00108 STDMETHODIMP CSurrogate::FreeSurrogate()
00109 {
00110   OutputDebugString("ISurrogate::FreeSurrogate() called.");
00111   // revoke all of our class factory wrapper objects from COM
00112   size_t i = m_stkClassFactories.size();
00113   while (i--)
00114   {
00115     CoRevokeClassObject(m_stkClassFactories.top()->m_dwReg);
00116     m_stkClassFactories.top()->Release();
00117     m_stkClassFactories.pop();
00118   }
00119
00120   // terminate the message pump
00121   PostQuitMessage(0);
00122   return S_OK;
00123 }
00124
00125
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/activitysub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

activitysub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __ACTIVITYSUB_H__
00018 #define __ACTIVITYSUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026
00027 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00028 Class:   CActivitySub
00029 Summary: Activity Event Subscriber
00030 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00031 class ATL_NO_VTABLE CActivitySub :
00032   public CSysLCESub,
00033   public IComActivityEvents
00034 {
00035 public:
00036   CActivitySub(CComSpy * pSpy)
00037   {
00038     m_pSpy = pSpy;
00039   }
00040
00041   CActivitySub()
00042   {
00043     m_pSpy = NULL;
00044   }
00045
00046   DECLARE_NOT_AGGREGATABLE(CActivitySub)
00047   DECLARE_GET_CONTROLLING_UNKNOWN()
00048
00049   BEGIN_COM_MAP(CActivitySub)
00050     COM_INTERFACE_ENTRY(IComActivityEvents)
00051     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00052   END_COM_MAP()
00053
00054   STDMETHODIMP GetEventType(EventEnum * e){*e = Activity;return S_OK;}
00055   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00056   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComActivityEvents;return S_OK;}
00057
00058   STDMETHODIMP OnActivityCreate(COMSVCSEVENTINFO * pInfo, REFGUID guidActivity)
00059   {
00060     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityCreate"), GuidToBstr(pInfo->guidApp));
00061
00062     CComBSTR sGuidActivity = GuidToBstr(guidActivity);
00063
00064     m_pSpy -> AddParamValueToList(L"guidActivity", sGuidActivity);
00065
00066     IF_AUDIT_DO(OnActivityCreate)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),sGuidActivity);
00067
00068     return S_OK;
00069   }
00070
00071   STDMETHODIMP OnActivityDestroy(COMSVCSEVENTINFO * pInfo, REFGUID guidActivity)
00072   {
00073     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityDestroy"),  GuidToBstr(pInfo->guidApp));
00074
00075     CComBSTR sGuidActivity = GuidToBstr(guidActivity);
00076     m_pSpy -> AddParamValueToList(L"guidActivity", sGuidActivity);
00077
00078     IF_AUDIT_DO(OnActivityDestroy)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),sGuidActivity);
00079     return S_OK;
00080
00081   }
00082
00083   STDMETHODIMP OnActivityEnter(COMSVCSEVENTINFO * pInfo, REFGUID guidCurrent,REFGUID guidEntered,
00084     DWORD dwThread)
00085   {
00086     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityEnter"),  GuidToBstr(pInfo->guidApp));
00087
00088     CComBSTR sGuidCurrent = GuidToBstr(guidCurrent);
00089     m_pSpy -> AddParamValueToList(L"guidCurrent", sGuidCurrent);
00090     CComBSTR sGuidEntered = GuidToBstr(guidEntered);
00091     m_pSpy -> AddParamValueToList(L"guidEntered", sGuidEntered);
00092
00093     WCHAR szThread[16];
00094     wsprintfW(szThread,L"0x%08X", dwThread);
00095     m_pSpy -> AddParamValueToList(L"dwThread", szThread);
00096
00097     IF_AUDIT_DO(OnActivityEnter)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00098                   sGuidCurrent,
00099                   sGuidEntered,
00100                   szThread
00101                   );
00102
00103     return S_OK;
00104   }
00105
00106   STDMETHODIMP OnActivityTimeout(COMSVCSEVENTINFO * pInfo,REFGUID guidCurrent,REFGUID guidEntered,DWORD dwThread,
00107     DWORD dwTimeout)
00108   {
00109     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityTimeout"),  GuidToBstr(pInfo->guidApp));
00110
00111     CComBSTR sGuidCurrent = GuidToBstr(guidCurrent);
00112     m_pSpy -> AddParamValueToList(L"guidCurrent", sGuidCurrent);
00113     CComBSTR sGuidEntered = GuidToBstr(guidEntered);
00114     m_pSpy -> AddParamValueToList(L"guidEntered", sGuidEntered);
00115
00116     WCHAR szThread[16];
00117     wsprintfW(szThread,L"0x%08X", dwThread);
00118     m_pSpy -> AddParamValueToList(L"dwThread", szThread);
00119
00120     WCHAR szTimeout[16];
00121     wsprintfW(szTimeout,L"%d", dwTimeout);
00122     m_pSpy -> AddParamValueToList(L"dwTimeout", szTimeout);
00123
00124     IF_AUDIT_DO(OnActivityTimeout)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00125                   sGuidCurrent,
00126                   sGuidEntered,
00127                   szThread,
00128                   dwTimeout
00129                   );
00130     return S_OK;
00131   }
00132
00133   STDMETHODIMP OnActivityReenter(COMSVCSEVENTINFO * pInfo,REFGUID guidCurrent,DWORD dwThread,DWORD dwCallDepth)
00134   {
00135     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityReEnter"),  GuidToBstr(pInfo->guidApp));
00136
00137     CComBSTR sGuidCurrent = GuidToBstr(guidCurrent);
00138     m_pSpy -> AddParamValueToList(L"guidCurrent", sGuidCurrent);
00139
00140     WCHAR szThread[16];
00141     wsprintfW(szThread,L"0x%08X", dwThread);
00142     m_pSpy -> AddParamValueToList(L"dwThread", szThread);
00143
00144     WCHAR szCallDepth[16];
00145     wsprintfW(szCallDepth,L"%d", dwCallDepth);
00146     m_pSpy -> AddParamValueToList(L"dwCallDepth", szCallDepth);
00147
00148     IF_AUDIT_DO(OnActivityReenter)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00149                   sGuidCurrent,
00150                   szThread,
00151                   dwCallDepth
00152                   );
00153     return S_OK;
00154   }
00155
00156   STDMETHODIMP OnActivityLeave(COMSVCSEVENTINFO * pInfo,REFGUID guidCurrent,REFGUID guidLeft)
00157   {
00158     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityLeave"),  GuidToBstr(pInfo->guidApp));
00159
00160     CComBSTR sGuidCurrent = GuidToBstr(guidCurrent);
00161     m_pSpy -> AddParamValueToList(L"guidCurrent", sGuidCurrent);
00162     CComBSTR sGuidLeft = GuidToBstr(guidLeft);
00163     m_pSpy -> AddParamValueToList(L"guidLeft", sGuidLeft);
00164
00165     IF_AUDIT_DO(OnActivityLeave)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00166                   sGuidCurrent,
00167                   sGuidLeft
00168                   );
00169     return S_OK;
00170   }
00171
00172   STDMETHODIMP OnActivityLeaveSame(COMSVCSEVENTINFO * pInfo,REFGUID guidCurrent,DWORD dwCallDepth)
00173   {
00174     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnActivityLeaveSame"),  GuidToBstr(pInfo->guidApp));
00175
00176     CComBSTR sGuidCurrent = GuidToBstr(guidCurrent);
00177     m_pSpy -> AddParamValueToList(L"guidCurrent", sGuidCurrent);
00178     WCHAR id[16];
00179     wsprintfW(id,L"%d", dwCallDepth);
00180     m_pSpy -> AddParamValueToList(L"dwCallDepth", id);
00181
00182     IF_AUDIT_DO(OnActivityLeaveSame)(pInfo->perfCount,GuidToBstr(pInfo->guidApp),
00183                   sGuidCurrent,
00184                   dwCallDepth
00185                   );
00186     return S_OK;
00187   }
00188
00189 };
00190
00191 #endif //__ACTIVITYSUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/EventConsumer/StdAfx.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • EventConsumer

StdAfx.Cpp

Go to the documentation of this file.
00001 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00002 // stdafx.cpp : source file that includes just the standard includes
00003 //  WBEMPermEvents.pch will be the pre-compiled header
00004 //  stdafx.obj will contain the pre-compiled type information
00005
00006 #include "stdafx.h"
00007
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/handler.h Source File

  • Dataaccess
  • rds
  • handler
  • vc

handler.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:    HANDLER.h
00004 //
00005 // Copyright: Copyright (c) 1991-1999 Microsoft Corporation
00006 //
00007 // Contents:  Definition of the CHandler class
00008 //
00009 // Comments:
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 #if !defined(AFX_HANDLER_H__A1A6B99E_497F_11D1_9217_00C04FBBBFB3__INCLUDED_)
00014 #define AFX_HANDLER_H__A1A6B99E_497F_11D1_9217_00C04FBBBFB3__INCLUDED_
00015
00016 #if _MSC_VER >= 1000
00017 #pragma once
00018 #endif // _MSC_VER >= 1000
00019
00020 #include "resource.h"       // main symbols
00021 #include "adoint.h"
00022 #include "msdfhdl.h"
00023 #include "msdfmap.h"
00024
00025 #define MSDFMAP_PROGID     "MSDFMAP_VC.Handler"
00026 #define MSDFMAP_PROGIDVER  "MSDFMAP_VC.Handler.1"
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CHandler
00030
00031 class CHandler :
00032   //public CComDualImpl<IDataFactoryHandler, &IID_IDataFactoryHandler, &LIBID_MSDFMAPLib>,
00033   public CComObjectRoot,
00034   public CComCoClass<CHandler, &CLSID_Handler>,
00035   public IDataFactoryHandler,
00036   public ISupportErrorInfo
00037 {
00038 public:
00039   CHandler();
00040
00041 BEGIN_COM_MAP(CHandler)
00042   //COM_INTERFACE_ENTRY(IDispatch)
00043   COM_INTERFACE_ENTRY(IDataFactoryHandler)
00044   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00045 END_COM_MAP()
00046 //DECLARE_NOT_AGGREGATABLE(CHandler)
00047 // Remove the comment from the line above if you don't want your object to
00048 // support aggregation.
00049
00050 //DECLARE_REGISTRY_RESOURCEID(IDR_Handler1)
00051 DECLARE_REGISTRY(CLSID_Handler, MSDFMAP_PROGIDVER, MSDFMAP_PROGID, IDS_HANDLER_DESC1, THREADFLAGS_BOTH)
00052
00053 // ISupportsErrorInfo
00054   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00055
00056 // IDataFactoryHandler
00057   STDMETHODIMP GetRecordset(
00058             /* [in] */ BSTR conn,
00059             /* [in] */ BSTR args,
00060             /* [in] */ BSTR query,
00061             /* [out][retval] */ _Recordset **ppRS);
00062   STDMETHODIMP Reconnect(
00063             /* [in] */ BSTR conn,
00064             /* [in] */ BSTR args,
00065             /* [in] */ _Recordset *pRS);
00066   STDMETHODIMP OpenConnection(
00067       /* [in] */ BSTR conn,
00068       /* [in] */ BSTR args,
00069       /* [in] */ long lFlags,  // 1=WriteAccess, 2=ModifyQuery
00070       /* [in, out] */ BSTR * pQuery,
00071       /* [out, retval] */ _Connection **ppConnection);
00072
00073 private:
00074 };
00075
00076 #endif // !defined(AFX_HANDLER_H__A1A6B99E_497F_11D1_9217_00C04FBBBFB3__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/adscontainer.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

adscontainer.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 //
00003 //  Microsoft Active Directory 2.5 Sample Code
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1996 - 2000
00006 //
00007 //  File:       ADsContainer.cpp
00008 //
00009 //  Contents:   IADsContainer usage
00010 //
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #include "stdafx.h"
00015 #include "ADQI.h"
00016 #include "ads.h"
00017 #include "ADsContainer.h"
00018
00019 #ifdef _DEBUG
00020 #undef THIS_FILE
00021 static char THIS_FILE[]=__FILE__;
00022 #define new DEBUG_NEW
00023 #endif
00024
00025
00026
00027
00028
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // CDlgIADsContainer dialog
00032
00033
00034 CDlgIADsContainer::CDlgIADsContainer(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
00035   : CDialog(CDlgIADsContainer::IDD, pParent)
00036 {
00037   //{{AFX_DATA_INIT(CDlgIADsContainer)
00038   m_sFilter = _T("");
00039   //}}AFX_DATA_INIT
00040
00041   ///////////////////////////////////////
00042   // Get the IADsContainer pointer and save it as a member
00043   /////////////////////////////////////
00044   HRESULT hr;
00045   m_pCont = NULL;
00046   hr = pUnk->QueryInterface( IID_IADsContainer, (void **) &m_pCont );
00047   if ( !SUCCEEDED(hr) )
00048   {
00049     AfxMessageBox(_T("Fatal Error! QI for IADs failed"));
00050     return;
00051   }
00052   pUnk->Release();
00053
00054 }
00055
00056 CDlgIADsContainer::~CDlgIADsContainer()
00057 {
00058
00059   if ( m_pCont )
00060   {
00061      m_pCont->Release();
00062   }
00063 }
00064
00065
00066 void CDlgIADsContainer::DoDataExchange(CDataExchange* pDX)
00067 {
00068   CDialog::DoDataExchange(pDX);
00069   //{{AFX_DATA_MAP(CDlgIADsContainer)
00070   DDX_Control(pDX, IDC_CHILDRENLIST, m_cChildList);
00071   DDX_Text(pDX, IDC_FILTER, m_sFilter);
00072   //}}AFX_DATA_MAP
00073 }
00074
00075
00076 BEGIN_MESSAGE_MAP(CDlgIADsContainer, CDialog)
00077   //{{AFX_MSG_MAP(CDlgIADsContainer)
00078   ON_BN_CLICKED(IDC_VIEW, OnView)
00079   ON_LBN_DBLCLK(IDC_CHILDRENLIST, OnDblClkChildrenList)
00080   ON_BN_CLICKED(IDC_DELETE, OnDelete)
00081   ON_BN_CLICKED(IDC_RENAME, OnRename)
00082   ON_BN_CLICKED(IDC_SET, OnSet)
00083   ON_BN_CLICKED(IDC_MOVE, OnMove)
00084   //}}AFX_MSG_MAP
00085 END_MESSAGE_MAP()
00086
00087 /////////////////////////////////////////////////////////////////////////////
00088 // CDlgIADsContainer message handlers
00089
00090 BOOL CDlgIADsContainer::OnInitDialog()
00091 {
00092
00093   CDialog::OnInitDialog();
00094   EnumerateChildren();
00095   return TRUE;  // return TRUE unless you set the focus to a control
00096                 // EXCEPTION: OCX Property Pages should return FALSE
00097 }
00098
00099 //////////////////////////////////////////////////////////
00100 // On View demonstrate the IADsContainer::GetObject()
00101 // This is when the user double click the list box or
00102 // when the user select an item in the list and click "View"
00103 /////////////////////////////////////////////////////////////
00104 void CDlgIADsContainer::OnView()
00105 {
00106   ASSERT( m_pCont );
00107
00108
00109
00110   CString sName;
00111   CString sClass;
00112   HRESULT hr;
00113
00114
00115   if ( !GetClassAndName( sClass, sName) )
00116   {
00117     return;
00118   }
00119
00120
00121   USES_CONVERSION;
00122   IDispatch *pDisp;
00123   IUnknown  *pUnk;
00124   hr = m_pCont->GetObject(T2OLE(sClass), T2OLE(sName), &pDisp );
00125   if ( !SUCCEEDED(hr) )
00126   {
00127     return;
00128   }
00129
00130   pDisp->QueryInterface( IID_IUnknown, (void**) &pUnk );
00131   pDisp->Release();
00132
00133
00134   /////////////////////////////////
00135   // Bring up the dialog box
00136   ////////////////////////////////////
00137   pUnk->AddRef();
00138   CDlgIADs dlg( pUnk );
00139   dlg.DoModal();
00140   pUnk->Release();
00141
00142 }
00143
00144 void CDlgIADsContainer::OnDblClkChildrenList()
00145 {
00146   OnView();
00147 }
00148
00149 ////////////////////////////////
00150 // IADsContainer::Delete
00151 /////////////////////////////////
00152 void CDlgIADsContainer::OnDelete()
00153 {
00154   CString sName;
00155   CString sClass;
00156   HRESULT hr;
00157
00158
00159   if ( !GetClassAndName( sClass, sName) )
00160   {
00161     return;
00162   }
00163
00164   ///////////////////////
00165   // Delete Now
00166   ////////////////////////
00167   USES_CONVERSION;
00168   ///////////////////////////////////////////////////////////////
00169   // For example m_pCont->Delete(L"user", L"cn=jsmith");
00170   ////////////////////////////////////////////////////////////////
00171   hr = m_pCont->Delete( T2OLE( sClass ), T2OLE( sName ) );
00172   if (!SUCCEEDED(hr) )
00173   {
00174     AfxMessageBox( GetErrorMessage(hr));
00175       return;
00176   }
00177   EnumerateChildren();
00178 }
00179
00180
00181
00182 BOOL CDlgIADsContainer::GetClassAndName(CString & sClass, CString & sName)
00183 {
00184   int idx;
00185   POSITION pos;
00186
00187
00188   idx = m_cChildList.GetCurSel();
00189   if ( idx == LB_ERR )
00190   {
00191     return FALSE;
00192   }
00193
00194
00195   m_cChildList.GetText( idx, sName );
00196   pos = m_sClassList.FindIndex( idx );
00197   if ( pos == NULL )
00198   {
00199     return FALSE;
00200   }
00201
00202   sClass = m_sClassList.GetAt(pos);
00203     return TRUE;
00204
00205 }
00206
00207
00208 //////////////////////////////////////////////////
00209 // EnumerateChildren Function
00210 // IADsContainer::get_Enum
00211 // ADsBuildEnumerator
00212 // ADsEnumerateNext
00213 // ADsFreeEnumerator
00214 //
00215 ///////////////////////////////////////////////
00216 HRESULT CDlgIADsContainer::EnumerateChildren()
00217 {
00218   HRESULT hr=S_OK;
00219   VARIANT var;
00220   ULONG   lFetch;
00221
00222   m_cChildList.ResetContent();
00223   m_sClassList.RemoveAll();
00224
00225   //////////////////////////////////////////////////////
00226   // Use the ADSI Helper APIs to enumerate Children
00227   ////////////////////////////////////////////////////
00228   IEnumVARIANT *pEnum;
00229   IDispatch  *pDisp;
00230   IADs     *pADs;
00231   BSTR        bstr;
00232   CString       s;
00233
00234   VariantInit(&var);
00235   hr = ADsBuildEnumerator( m_pCont, &pEnum );
00236   if ( !SUCCEEDED(hr) )
00237   {
00238     return S_FALSE;
00239   }
00240
00241   hr = ADsEnumerateNext( pEnum, 1, &var, &lFetch );
00242   while( hr == S_OK )
00243   {
00244     if ( lFetch == 1 )
00245     {
00246         pDisp = V_DISPATCH(&var);
00247       ///////////////////////////
00248       // Get the Child Name
00249       /////////////////////////////
00250       hr = pDisp->QueryInterface( IID_IADs, (void**)&pADs );
00251       if ( SUCCEEDED(hr) )
00252       {
00253         pADs->get_Name(&bstr);
00254         s = bstr;
00255         m_cChildList.AddString( s );
00256         SysFreeString(bstr);
00257
00258
00259         ///////////////////////////////////////////////
00260         // While we're holding the child's object
00261         // let's get the class info for later use.
00262         // The class info will be used for getting the actual object
00263         // via IADsContainer::GetObject) when the user wants to view
00264         // object in detail.
00265         // We could have stored the ADsPath as well.
00266         //////////////////////////////////////////////
00267         pADs->get_Class(&bstr);
00268         s = bstr;
00269         m_sClassList.AddTail( s );
00270         SysFreeString(bstr);
00271
00272         pADs->Release();
00273       }
00274
00275       VariantClear(&var);
00276     }
00277     hr = ADsEnumerateNext( pEnum, 1, &var, &lFetch );
00278     };
00279
00280
00281
00282
00283   // Free Enumerator
00284   ADsFreeEnumerator( pEnum );
00285
00286   return S_OK;
00287
00288
00289 }
00290
00291
00292
00293 /////////////////////////////////////////
00294 // OnRename
00295 // Demonstrate:
00296 // IADsContainer::MoveHere
00297 // IADsContainer::GetObject
00298 //////////////////////////////////////////////
00299 void CDlgIADsContainer::OnRename()
00300 {
00301    CString sName;
00302    CString sNewName;
00303    CString sClass;
00304
00305    if ( !GetClassAndName( sClass,  sName) )
00306    {
00307      return;
00308    }
00309
00310    CRenameDlg dlg( sName );
00311
00312    if ( dlg.DoModal() == IDOK )
00313    {
00314     //////////////////////////////////////////////////////////////////
00315     // To Rename we need:
00316     //  1. A new name ( we'll get it from the rename dialog box )
00317     //  2. ADsPath of the object to be renamed
00318     //  3. The container where the child lives.
00319     /////////////////////////////////////////////////////////////////
00320
00321     sNewName = dlg.GetName();
00322
00323     //////////////////////////////////////////////////
00324     // Get the child's ADsPath,
00325     // First we can use IADsContainer::GetObject
00326     /////////////////////////////////////////////////////
00327     USES_CONVERSION;
00328     IDispatch *pDisp;
00329     IADs    *pADs;
00330     BSTR    bstrPath;
00331     CString sADsPath;
00332     HRESULT   hr;
00333
00334     hr = m_pCont->GetObject(T2OLE(sClass), T2OLE(sName), &pDisp );
00335     if ( !SUCCEEDED(hr) )
00336     {
00337       return;
00338     }
00339
00340     hr = pDisp->QueryInterface( IID_IADs, (void**) &pADs );
00341     pDisp->Release();
00342
00343     ////////////////////////////////
00344     // Now get the child's ADsPath
00345     //////////////////////////////////
00346     if ( !SUCCEEDED(hr) )
00347     {
00348       return;
00349     }
00350
00351     pADs->get_ADsPath( &bstrPath );
00352     pADs->Release();
00353
00354     ////////////////////////////////////////////////////
00355     // We have all the information, time to rename  //
00356     ////////////////////////////////////////////////////
00357     hr = m_pCont->MoveHere( bstrPath, T2OLE(sNewName), &pDisp );
00358     SysFreeString( bstrPath );
00359
00360     if ( !SUCCEEDED(hr) )
00361     {
00362       AfxMessageBox(GetErrorMessage(hr));
00363       return;
00364     }
00365     pDisp->Release();
00366
00367     // Refresh the list
00368     EnumerateChildren();
00369
00370
00371    }
00372
00373 }
00374
00375 void CDlgIADsContainer::OnMove()
00376 {
00377   CMoveDlg dlg;
00378   if ( dlg.DoModal() == IDOK )
00379   {
00380     CString sADsPath;
00381     IDispatch *pDisp;
00382     USES_CONVERSION;
00383     HRESULT hr;
00384
00385     sADsPath = dlg.GetObjectPath();
00386     hr = m_pCont->MoveHere( T2OLE(sADsPath), NULL, &pDisp );
00387     pDisp->Release();
00388     RETURN_ON_FAILURE(hr);
00389
00390     EnumerateChildren(); // Refresh the list
00391
00392   }
00393
00394 }
00395
00396 void CDlgIADsContainer::OnOK()
00397 {
00398   m_sClassList.RemoveAll();
00399   CDialog::OnOK();
00400 }
00401
00402 ///////////////////////////////
00403 // IADsContainer::put_Filter
00404 //
00405 void CDlgIADsContainer::OnSet()
00406 {
00407   CStringList sList;
00408   VARIANT var;
00409   HRESULT hr;
00410
00411
00412   UpdateData(TRUE);
00413   VariantInit(&var);
00414
00415   // The user may enter many classes to filter 'user,group'
00416   StringToStringList( m_sFilter, sList );
00417   StringListToVariant(var, sList );
00418
00419   hr = m_pCont->put_Filter( var );
00420
00421   VariantClear(&var);
00422
00423   if ( !SUCCEEDED(hr) )
00424   {
00425     AfxMessageBox(GetErrorMessage(hr));
00426       return;
00427   }
00428
00429   EnumerateChildren();
00430
00431 }
00432
00433
00434
00435
00436
00437 /////////////////////////////////////////////////////////////////////////////
00438 // CRenameDlg dialog
00439
00440
00441 CRenameDlg::CRenameDlg(CString sOldName, CWnd* pParent /*=NULL*/)
00442   : CDialog(CRenameDlg::IDD, pParent)
00443 {
00444   //{{AFX_DATA_INIT(CRenameDlg)
00445   m_sName = _T("");
00446   //}}AFX_DATA_INIT
00447
00448   m_sOldName = _T("Rename '");
00449   m_sOldName += sOldName;
00450   m_sOldName += _T("'");
00451   m_sNewName = _T("");
00452
00453 }
00454
00455
00456 void CRenameDlg::DoDataExchange(CDataExchange* pDX)
00457 {
00458   CDialog::DoDataExchange(pDX);
00459   //{{AFX_DATA_MAP(CRenameDlg)
00460   DDX_Text(pDX, IDC_NAME, m_sName);
00461   //}}AFX_DATA_MAP
00462 }
00463
00464
00465 BEGIN_MESSAGE_MAP(CRenameDlg, CDialog)
00466   //{{AFX_MSG_MAP(CRenameDlg)
00467   //}}AFX_MSG_MAP
00468 END_MESSAGE_MAP()
00469
00470 /////////////////////////////////////////////////////////////////////////////
00471 // CRenameDlg message handlers
00472
00473 void CRenameDlg::OnOK()
00474 {
00475   UpdateData(TRUE);
00476   m_sNewName = m_sName;
00477   CDialog::OnOK();
00478 }
00479
00480
00481
00482 BOOL CRenameDlg::OnInitDialog()
00483 {
00484   CDialog::OnInitDialog();
00485
00486   SetWindowText( m_sOldName );
00487   return TRUE;  // return TRUE unless you set the focus to a control
00488                 // EXCEPTION: OCX Property Pages should return FALSE
00489 }
00490
00491
00492
00493 /////////////////////////////////////////////////////////////////////////////
00494 // CMoveDlg dialog
00495
00496
00497 CMoveDlg::CMoveDlg(CWnd* pParent /*=NULL*/)
00498   : CDialog(CMoveDlg::IDD, pParent)
00499 {
00500   //{{AFX_DATA_INIT(CMoveDlg)
00501   m_sADsPath = _T("");
00502   //}}AFX_DATA_INIT
00503 }
00504
00505
00506 void CMoveDlg::DoDataExchange(CDataExchange* pDX)
00507 {
00508   CDialog::DoDataExchange(pDX);
00509   //{{AFX_DATA_MAP(CMoveDlg)
00510   DDX_Text(pDX, IDC_ADSPATH, m_sADsPath);
00511   //}}AFX_DATA_MAP
00512 }
00513
00514
00515 BEGIN_MESSAGE_MAP(CMoveDlg, CDialog)
00516   //{{AFX_MSG_MAP(CMoveDlg)
00517   ON_EN_CHANGE(IDC_ADSPATH, OnChangeADspath)
00518   //}}AFX_MSG_MAP
00519 END_MESSAGE_MAP()
00520
00521 /////////////////////////////////////////////////////////////////////////////
00522 // CMoveDlg message handlers
00523
00524 void CMoveDlg::OnOK()
00525 {
00526   UpdateData(TRUE); //Retrieve
00527   CDialog::OnOK();
00528 }
00529
00530
00531 void CMoveDlg::OnChangeADspath()
00532 {
00533   BOOL bEnabled;
00534   bEnabled = GetDlgItem(IDC_ADSPATH)->GetWindowTextLength() > 0 ? TRUE : FALSE;
00535
00536   GetDlgItem(IDOK)->EnableWindow( bEnabled );
00537
00538
00539 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Help/StatNode.h Source File

  • SysMgmt
  • MMC
  • Help

StatNode.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SNAPINBASE_H
00021 #define _SNAPINBASE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CStaticNode : public CDelegationBase {
00026 public:
00027     CStaticNode();
00028
00029     virtual ~CStaticNode();
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) {
00032         static _TCHAR szDisplayName[256];
00033         LoadString(g_hinst, IDS_SNAPINNAME, szDisplayName, (sizeof szDisplayName)/(sizeof szDisplayName[0]));
00034         return szDisplayName;
00035     }
00036     virtual const GUID & getNodeType() { return thisGuid; }
00037     virtual const int GetBitmapIndex() { return INDEX_NONE; }
00038
00039 public:
00040     // virtual functions go here (for MMCN_*)
00041     virtual HRESULT OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile);
00042
00043 private:
00044     // {2974380C-4C4B-11d2-89D8-000021473128}
00045     static const GUID thisGuid;
00046 };
00047
00048 #endif // _SNAPINBASE_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Error.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Error.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Error
00019 /** @com.interface(iid=00000500-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Error extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=PROPGET, name="Number", name2="getNumber", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int getNumber();
00025
00026   /** @com.method(vtoffset=5, dispid=1610743809, type=PROPGET, name="Source", name2="getSource", addFlagsVtable=4)
00027       @com.parameters([type=STRING] return) */
00028   public String getSource();
00029
00030   /** @com.method(vtoffset=6, dispid=0, type=PROPGET, name="Description", name2="getDescription", addFlagsVtable=4)
00031       @com.parameters([type=STRING] return) */
00032   public String getDescription();
00033
00034   /** @com.method(vtoffset=7, dispid=1610743811, type=PROPGET, name="HelpFile", name2="getHelpFile", addFlagsVtable=4)
00035       @com.parameters([type=STRING] return) */
00036   public String getHelpFile();
00037
00038   /** @com.method(vtoffset=8, dispid=1610743812, type=PROPGET, name="HelpContext", name2="getHelpContext", addFlagsVtable=4)
00039       @com.parameters([type=I4] return) */
00040   public int getHelpContext();
00041
00042   /** @com.method(vtoffset=9, dispid=1610743813, type=PROPGET, name="SQLState", name2="getSQLState", addFlagsVtable=4)
00043       @com.parameters([type=STRING] return) */
00044   public String getSQLState();
00045
00046   /** @com.method(vtoffset=10, dispid=1610743814, type=PROPGET, name="NativeError", name2="getNativeError", addFlagsVtable=4)
00047       @com.parameters([type=I4] return) */
00048   public int getNativeError();
00049
00050
00051   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x500, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00052 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step2/MyDevice.h Source File

  • NetDS
  • upnp
  • StepByStep
  • Step2

MyDevice.h

Go to the documentation of this file.
00001 /* MIDL: this ALWAYS GENERATED file contains the definitions for the interfaces */
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/PropProv/PropProv.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • PropProv

PropProv.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  propprov.cpp
00006
00007 //
00008
00009 //  Module: WMI Sample Property Provider
00010
00011 //
00012
00013 //  Purpose: Provider class code.  An object of this class is
00014
00015 //           created by the class factory for each connection.
00016
00017 //
00018
00019 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00020 //
00021 //***************************************************************************
00022 #define _WIN32_WINNT 0x0500
00023
00024
00025 #include <objbase.h>
00026 #include "sample.h"
00027
00028
00029 /******************************************************************************
00030  *  Name: GetCurrentImpersonationLevel
00031  *  Description:
00032  *      Get COM impersonation level of caller.
00033  *****************************************************************************/
00034
00035 DWORD GetCurrentImpersonationLevel ()
00036 {
00037   DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00038
00039     HANDLE t_ThreadToken = NULL ;
00040
00041     BOOL t_Status = OpenThreadToken (
00042
00043     GetCurrentThread() ,
00044     TOKEN_QUERY,
00045     TRUE,
00046     &t_ThreadToken
00047   ) ;
00048
00049     if ( t_Status )
00050     {
00051     SECURITY_IMPERSONATION_LEVEL t_Level = SecurityAnonymous ;
00052     DWORD t_Returned = 0 ;
00053
00054     t_Status = GetTokenInformation (
00055
00056       t_ThreadToken ,
00057       TokenImpersonationLevel ,
00058       & t_Level ,
00059       sizeof ( SECURITY_IMPERSONATION_LEVEL ) ,
00060       & t_Returned
00061     ) ;
00062
00063     CloseHandle ( t_ThreadToken ) ;
00064
00065     if ( t_Status == FALSE )
00066     {
00067       t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00068     }
00069     else
00070     {
00071       switch ( t_Level )
00072       {
00073         case SecurityAnonymous:
00074         {
00075           t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00076         }
00077         break ;
00078
00079         case SecurityIdentification:
00080         {
00081           t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
00082         }
00083         break ;
00084
00085         case SecurityImpersonation:
00086         {
00087           t_ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE ;
00088         }
00089         break ;
00090
00091         case SecurityDelegation:
00092         {
00093           t_ImpersonationLevel = RPC_C_IMP_LEVEL_DELEGATE ;
00094         }
00095         break ;
00096
00097         default:
00098         {
00099           t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00100         }
00101         break ;
00102       }
00103     }
00104   }
00105   else
00106   {
00107         ULONG t_LastError = GetLastError () ;
00108
00109         if ( t_LastError == ERROR_NO_IMPERSONATION_TOKEN || t_LastError == ERROR_NO_TOKEN )
00110         {
00111             t_ImpersonationLevel = RPC_C_IMP_LEVEL_DELEGATE ;
00112         }
00113         else
00114     {
00115       if ( t_LastError == ERROR_CANT_OPEN_ANONYMOUS )
00116       {
00117         t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00118       }
00119       else
00120       {
00121         t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00122       }
00123     }
00124     }
00125
00126   return t_ImpersonationLevel ;
00127 }
00128
00129
00130
00131 //***************************************************************************
00132 //
00133 // CPropPro::CPropPro
00134 // CPropPro::~CPropPro
00135 //
00136 //***************************************************************************
00137
00138 CPropPro::CPropPro()
00139 {
00140     m_cRef=0;
00141     InterlockedIncrement(&g_cObj);
00142     return;
00143 }
00144
00145 CPropPro::~CPropPro(void)
00146 {
00147     InterlockedDecrement(&g_cObj);
00148     return;
00149 }
00150
00151 //***************************************************************************
00152 //
00153 //  CPropPro::QueryInterface
00154 //
00155 //  Returns a pointer to supported interfaces.
00156 //
00157 //***************************************************************************
00158
00159 STDMETHODIMP CPropPro::QueryInterface(REFIID riid, PPVOID ppv)
00160 {
00161     *ppv=NULL;
00162
00163     // This provider only support IUnknown and IWbemPropertyProvider.
00164
00165     if (IID_IUnknown==riid || IID_IWbemPropertyProvider == riid)
00166         *ppv=this;
00167
00168     if (NULL!=*ppv)
00169     {
00170         ((LPUNKNOWN)*ppv)->AddRef();
00171         return NOERROR;
00172     }
00173
00174     return E_NOINTERFACE;
00175  }
00176
00177 //***************************************************************************
00178 //
00179 //  CPropPro::AddRef
00180 //
00181 //  Interface has another user, up the usage count.
00182 //
00183 //***************************************************************************
00184
00185 STDMETHODIMP_(ULONG) CPropPro::AddRef(void)
00186 {
00187     return ++m_cRef;
00188 }
00189
00190 //***************************************************************************
00191 //
00192 //  CPropPro::Release
00193 //
00194 //  Interface has been released.  Object will be deleted if the
00195 //  usage count is zero.
00196 //
00197 //***************************************************************************
00198
00199 STDMETHODIMP_(ULONG) CPropPro::Release(void)
00200 {
00201     ULONG nNewCount = InterlockedDecrement((long *)&m_cRef);
00202     if (0L == nNewCount)
00203         delete this;
00204
00205     return nNewCount;
00206 }
00207
00208
00209 //***************************************************************************
00210 //
00211 // CPropPro::PutProperty
00212 // CPropPro::GetProperty
00213 //
00214 // Purpose: PutProperty writes out data and GetProperty returns data.
00215 //
00216 //***************************************************************************
00217
00218 STDMETHODIMP CPropPro::PutProperty(
00219         long lFlags,
00220             const BSTR Locale,
00221             const BSTR ClassMapping,
00222             const BSTR InstMapping,
00223             const BSTR PropMapping,
00224             const VARIANT *pvValue)
00225 {
00226
00227     return WBEM_E_PROVIDER_NOT_CAPABLE;
00228
00229 }
00230
00231 STDMETHODIMP CPropPro::GetProperty(
00232         long lFlags,
00233             const BSTR Locale,
00234       const BSTR ClassMapping,
00235             const BSTR InstMapping,
00236             const BSTR PropMapping,
00237             VARIANT *pvValue)
00238 {
00239
00240     SCODE sc = WBEM_S_NO_ERROR;
00241
00242   //Impersonate the client
00243   sc = CoImpersonateClient () ;
00244
00245   if ( FAILED ( sc ) )
00246   {
00247     return sc ;
00248   }
00249
00250
00251   //  Check to see if call is at lower than RPC_C_IMP_LEVEL_IMPERSONATE level. If that's the case,
00252   //  the provider will not be able to impersonate the client to access the protected resources.
00253
00254   DWORD t_CurrentImpersonationLevel = GetCurrentImpersonationLevel () ;
00255   if ( t_CurrentImpersonationLevel < RPC_C_IMP_LEVEL_IMPERSONATE )
00256   {
00257     //  Revert before we perform any operations
00258     CoRevertToSelf () ;
00259     return WBEM_E_ACCESS_DENIED ;
00260   }
00261
00262     // Depending on the InstMapping, return either a hard coded integer or
00263     // a string.  These mapping strings could be used in a more sophisticated
00264     // manner!
00265
00266   if (pvValue == NULL)
00267   {
00268     return WBEM_E_INVALID_PARAMETER;
00269   }
00270
00271     if(!_wcsicmp(PropMapping, L"GiveMeANumber!"))
00272     {
00273         pvValue->vt = VT_I4;
00274         pvValue->lVal = 27;
00275     }
00276     else
00277     {
00278         pvValue->vt = VT_BSTR;
00279         pvValue->bstrVal = SysAllocString(L"Hello World");
00280         if(pvValue->bstrVal == NULL)
00281             sc = WBEM_E_OUT_OF_MEMORY;
00282     }
00283     return sc;
00284 }
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/Floppy/Mfmt.c Source File

  • WinBase
  • IO
  • Floppy

Mfmt.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00009
00010 *       This source code is only intended as a supplement to
00011 *       Microsoft Development Tools and/or WinHelp documentation.
00012 *       See these sources for detailed information regarding the
00013 *       Microsoft samples programs.
00014
00015 Module Name:
00016
00017     mfmt.c
00018
00019 Abstract:
00020
00021     This program is designed to show how to access a physical floppy
00022     disk using the Win32 API set.
00023
00024     This program has two major functions.
00025
00026         - It can be used to display the geometry of a disk
00027
00028             mfmt -g a:
00029
00030         - It can be used to produce a disk image, or to write a disk
00031           image to a floppy.
00032
00033             mfmt -c a: bootdisk         - produce a disk image of a:
00034
00035             mfmt -c bootdisk a:         - make a: identical to bootdisk image
00036
00037     This program is very very simple. Minimal error checking is done. It is
00038     meant to provide an example of how to:
00039
00040         - Open a physical disk
00041
00042         - Read a disk's geometry
00043
00044         - Perform a low level format operation
00045
00046         - read and write physical sectors
00047
00048 --*/
00049
00050 #ifdef _IA64_
00051 #pragma warning(disable: 4100 4701 4706)
00052 #endif
00053
00054 #include <stdlib.h>
00055 #include <stdio.h>
00056 #include <windows.h>
00057 #include <winioctl.h>
00058 #include <string.h>
00059 #include <ctype.h>
00060 #include <memory.h>
00061
00062 DISK_GEOMETRY SupportedGeometry[20];
00063 DWORD SupportedGeometryCount;
00064
00065 BOOL
00066 GetDiskGeometry(
00067                HANDLE hDisk,
00068                PDISK_GEOMETRY lpGeometry
00069                )
00070
00071 {
00072    DWORD ReturnedByteCount;
00073
00074    return DeviceIoControl(
00075                          hDisk,
00076                          IOCTL_DISK_GET_DRIVE_GEOMETRY,
00077                          NULL,
00078                          0,
00079                          lpGeometry,
00080                          sizeof(*lpGeometry),
00081                          &ReturnedByteCount,
00082                          NULL
00083                          );
00084 }
00085
00086 DWORD
00087 GetSupportedGeometrys(
00088                      HANDLE hDisk
00089                      )
00090 {
00091    DWORD ReturnedByteCount;
00092    BOOL b;
00093    DWORD NumberSupported;
00094
00095    b = DeviceIoControl(
00096                       hDisk,
00097                       IOCTL_DISK_GET_MEDIA_TYPES,
00098                       NULL,
00099                       0,
00100                       SupportedGeometry,
00101                       sizeof(SupportedGeometry),
00102                       &ReturnedByteCount,
00103                       NULL
00104                       );
00105    if ( b )
00106    {
00107       NumberSupported = ReturnedByteCount / sizeof(DISK_GEOMETRY);
00108    }
00109    else
00110    {
00111       NumberSupported = 0;
00112    }
00113    SupportedGeometryCount = NumberSupported;
00114
00115    return NumberSupported;
00116 }
00117
00118 VOID
00119 PrintGeometry(
00120              LPSTR lpDriveName,
00121              PDISK_GEOMETRY lpGeometry
00122              )
00123 {
00124    LPSTR MediaType;
00125
00126    if (lpDriveName)
00127    {
00128       printf("Geometry for Drive %s\n",lpDriveName);
00129    }
00130
00131    switch ( lpGeometry->MediaType )
00132    {
00133    case F5_1Pt2_512:  MediaType = "5.25, 1.2MB,  512 bytes/sector";break;
00134    case F3_1Pt44_512: MediaType = "3.5,  1.44MB, 512 bytes/sector";break;
00135    case F3_2Pt88_512: MediaType = "3.5,  2.88MB, 512 bytes/sector";break;
00136    case F3_20Pt8_512: MediaType = "3.5,  20.8MB, 512 bytes/sector";break;
00137    case F3_720_512:   MediaType = "3.5,  720KB,  512 bytes/sector";break;
00138    case F5_360_512:   MediaType = "5.25, 360KB,  512 bytes/sector";break;
00139    case F5_320_512:   MediaType = "5.25, 320KB,  512 bytes/sector";break;
00140    case F5_320_1024:  MediaType = "5.25, 320KB,  1024 bytes/sector";break;
00141    case F5_180_512:   MediaType = "5.25, 180KB,  512 bytes/sector";break;
00142    case F5_160_512:   MediaType = "5.25, 160KB,  512 bytes/sector";break;
00143    case RemovableMedia: MediaType = "Removable media other than floppy";break;
00144    case FixedMedia:   MediaType = "Fixed hard disk media";break;
00145    default:           MediaType = "Unknown";break;
00146    }
00147    printf("    Media Type %s\n",MediaType);
00148    printf("    Cylinders %d Tracks/Cylinder %d Sectors/Track %d\n",
00149           lpGeometry->Cylinders.LowPart,
00150           lpGeometry->TracksPerCylinder,
00151           lpGeometry->SectorsPerTrack
00152          );
00153 }
00154
00155 BOOL
00156 LowLevelFormat(
00157               HANDLE hDisk,
00158               PDISK_GEOMETRY lpGeometry
00159               )
00160 {
00161    FORMAT_PARAMETERS FormatParameters;
00162    PBAD_TRACK_NUMBER lpBadTrack;
00163    UINT i;
00164    BOOL b;
00165    DWORD ReturnedByteCount;
00166
00167    FormatParameters.MediaType = lpGeometry->MediaType;
00168    FormatParameters.StartHeadNumber = 0;
00169    FormatParameters.EndHeadNumber = lpGeometry->TracksPerCylinder - 1;
00170    lpBadTrack = (PBAD_TRACK_NUMBER) LocalAlloc(LMEM_ZEROINIT,lpGeometry->TracksPerCylinder*sizeof(*lpBadTrack));
00171
00172    for (i = 0; i < lpGeometry->Cylinders.LowPart; i++)
00173    {
00174
00175       FormatParameters.StartCylinderNumber = i;
00176       FormatParameters.EndCylinderNumber = i;
00177
00178       b = DeviceIoControl(
00179                          hDisk,
00180                          IOCTL_DISK_FORMAT_TRACKS,
00181                          &FormatParameters,
00182                          sizeof(FormatParameters),
00183                          lpBadTrack,
00184                          lpGeometry->TracksPerCylinder*sizeof(*lpBadTrack),
00185                          &ReturnedByteCount,
00186                          NULL
00187                          );
00188
00189       if (!b )
00190       {
00191          LocalFree(lpBadTrack);
00192          return b;
00193       }
00194    }
00195
00196    LocalFree(lpBadTrack);
00197
00198    return TRUE;
00199 }
00200
00201 BOOL
00202 LockVolume(
00203           HANDLE hDisk
00204           )
00205 {
00206    DWORD ReturnedByteCount;
00207
00208    return DeviceIoControl(
00209                          hDisk,
00210                          FSCTL_LOCK_VOLUME,
00211                          NULL,
00212                          0,
00213                          NULL,
00214                          0,
00215                          &ReturnedByteCount,
00216                          NULL
00217                          );
00218 }
00219
00220 BOOL
00221 UnlockVolume(
00222             HANDLE hDisk
00223             )
00224 {
00225    DWORD ReturnedByteCount;
00226
00227    return DeviceIoControl(
00228                          hDisk,
00229                          FSCTL_UNLOCK_VOLUME,
00230                          NULL,
00231                          0,
00232                          NULL,
00233                          0,
00234                          &ReturnedByteCount,
00235                          NULL
00236                          );
00237 }
00238
00239 BOOL
00240 DismountVolume(
00241               HANDLE hDisk
00242               )
00243 {
00244    DWORD ReturnedByteCount;
00245
00246    return DeviceIoControl(
00247                          hDisk,
00248                          FSCTL_DISMOUNT_VOLUME,
00249                          NULL,
00250                          0,
00251                          NULL,
00252                          0,
00253                          &ReturnedByteCount,
00254                          NULL
00255                          );
00256 }
00257
00258 DWORD
00259 _cdecl
00260 main(
00261     int argc,
00262     char *argv[],
00263     char *envp[]
00264     )
00265 {
00266    char Drive[MAX_PATH];
00267    HANDLE hDrive, hDiskImage;
00268    DISK_GEOMETRY Geometry;
00269    UINT i;
00270    char c, *p;
00271    LPSTR DriveName;
00272    BOOL fUsage = TRUE;
00273    BOOL fShowGeometry = FALSE;
00274    BOOL fDiskImage = FALSE;
00275    BOOL SourceIsDrive;
00276    LPSTR Source, Destination, DiskImage;
00277
00278    if ( argc > 1 )
00279    {
00280       fUsage = FALSE;
00281       while (--argc > 0 )
00282       {
00283          p = *++argv;
00284          if (*p == '/' || *p == '-')
00285          {
00286             while (c = *++p)
00287                switch (toupper( c ))
00288                {
00289                case '?':
00290                   fUsage = TRUE;
00291                   break;
00292
00293                case 'C':
00294                   fDiskImage = TRUE;
00295                   argc--, argv++;
00296                   Source = *argv;
00297                   argc--, argv++;
00298                   Destination = *argv;
00299                   break;
00300
00301                case 'G':
00302                   argc--, argv++;
00303                   if ( (DriveName = *argv ) && *DriveName &&
00304                        isalpha(*DriveName) )
00305                      fShowGeometry = TRUE;
00306                   else
00307                   {
00308                      printf( "MFMT: Missing drive letter after -G\n" );
00309                      DriveName = NULL;
00310                      fUsage = TRUE;
00311                   }
00312                   break;
00313
00314                default:
00315                   printf("MFMT: Invalid switch - /%c\n", c );
00316                   fUsage = TRUE;
00317                   break;
00318                }
00319          }
00320       }
00321    }
00322
00323    if ( fUsage )
00324    {
00325       printf("usage: MFMT switches \n" );
00326       printf("            [-?] display this message\n" );
00327       printf("            [-g drive] shows disk geometry\n" );
00328       printf("            [-c source destination] produce diskimage\n" );
00329       ExitProcess(1);
00330    }
00331
00332    if ( fShowGeometry )
00333    {
00334       sprintf(Drive,"\\\\.\\%s",DriveName);
00335       hDrive = CreateFile(
00336                          Drive,
00337                          GENERIC_READ | GENERIC_WRITE,
00338                          FILE_SHARE_READ|FILE_SHARE_WRITE,
00339                          NULL,
00340                          OPEN_EXISTING,
00341                          0,
00342                          NULL
00343                          );
00344       if ( hDrive == INVALID_HANDLE_VALUE )
00345       {
00346          printf("MFMT: Open %s failed %d\n",DriveName,GetLastError());
00347          ExitProcess(1);
00348       }
00349
00350       if ( LockVolume(hDrive) == FALSE )
00351       {
00352          printf("MFMT:Locking volume %s failed %d\n", DriveName, GetLastError());
00353          ExitProcess(1);
00354       }
00355
00356       if ( !GetDiskGeometry(hDrive,&Geometry) )
00357       {
00358          printf("MFMT: GetDiskGeometry %s failed %d\n",DriveName,GetLastError());
00359          ExitProcess(1);
00360       }
00361       PrintGeometry(DriveName,&Geometry);
00362
00363       if ( !GetSupportedGeometrys(hDrive) )
00364       {
00365          printf("MFMT: GetSupportedGeometrys %s failed %d\n",DriveName,GetLastError());
00366          ExitProcess(1);
00367       }
00368       printf("\nDrive %s supports the following disk geometries\n",DriveName);
00369
00370       for (i=0;i<SupportedGeometryCount;i++)
00371       {
00372          printf("\n");
00373          PrintGeometry(NULL,&SupportedGeometry[i]);
00374       }
00375
00376       printf("\n");
00377       ExitProcess(0);
00378    }
00379
00380    if ( fDiskImage )
00381    {
00382       SourceIsDrive = FALSE;
00383       if ( Source[strlen(Source)-1] == ':' )
00384       {
00385          SourceIsDrive = TRUE;
00386          sprintf(Drive,"\\\\.\\%s",Source);
00387          DriveName=Source;
00388          DiskImage = Destination;
00389       }
00390       if ( Destination[strlen(Destination)-1] == ':' )
00391       {
00392          if ( SourceIsDrive )
00393          {
00394             printf("MFMT: Source and Destination cannot both be drives\n");
00395             ExitProcess(1);
00396          }
00397          SourceIsDrive = FALSE;
00398          sprintf(Drive,"\\\\.\\%s",Destination);
00399          DriveName=Destination;
00400          DiskImage = Source;
00401       }
00402       else
00403       {
00404          if ( !SourceIsDrive )
00405          {
00406             printf("MFMT: Either Source or Destination must be a drive\n");
00407             ExitProcess(1);
00408          }
00409       }
00410
00411       //
00412       // Open and Lock the drive
00413       //
00414
00415       hDrive = CreateFile(
00416                          Drive,
00417                          GENERIC_READ | GENERIC_WRITE,
00418                          FILE_SHARE_READ|FILE_SHARE_WRITE,
00419                          NULL,
00420                          OPEN_EXISTING,
00421                          0,
00422                          NULL
00423                          );
00424       if ( hDrive == INVALID_HANDLE_VALUE )
00425       {
00426          printf("MFMT: Open %s failed %d\n",DriveName,GetLastError());
00427          ExitProcess(1);
00428       }
00429       if ( LockVolume(hDrive) == FALSE )
00430       {
00431          printf("MFMT: LockVolume %s failed %d\n",DriveName,GetLastError());
00432          ExitProcess(1);
00433       }
00434
00435       if ( !GetDiskGeometry(hDrive,&Geometry) )
00436       {
00437          printf("MFMT: GetDiskGeometry %s failed %d\n",DriveName,GetLastError());
00438          ExitProcess(1);
00439       }
00440
00441       if ( !GetSupportedGeometrys(hDrive) )
00442       {
00443          printf("MFMT: GetSupportedGeometrys %s failed %d\n",DriveName,GetLastError());
00444          ExitProcess(1);
00445       }
00446
00447       //
00448       // Open the disk image file
00449       //
00450
00451       hDiskImage = CreateFile(
00452                              DiskImage,
00453                              GENERIC_READ | GENERIC_WRITE,
00454                              0,
00455                              NULL,
00456                              SourceIsDrive ? CREATE_ALWAYS : OPEN_EXISTING,
00457                              0,
00458                              NULL
00459                              );
00460       if ( hDiskImage == INVALID_HANDLE_VALUE )
00461       {
00462          printf("MFMT: Open %s failed %d\n",DiskImage,GetLastError());
00463          ExitProcess(1);
00464       }
00465
00466       //
00467       // Now do the copy
00468       //
00469       {
00470          LPVOID IoBuffer;
00471          BOOL b;
00472          DWORD BytesRead, BytesWritten;
00473          DWORD FileSize;
00474          DWORD VirtBufSize;
00475          DWORD NumBufs;
00476
00477          //
00478          // If we are copying from floppy to file, just do the copy
00479          // Otherwise, we might have to format the floppy first
00480          //
00481
00482          if ( SourceIsDrive )
00483          {
00484
00485             //
00486             // Device reads must be sector aligned. VirtualAlloc will
00487             // garuntee alignment
00488             //
00489
00490             NumBufs = Geometry.Cylinders.LowPart;
00491             VirtBufSize =  Geometry.TracksPerCylinder *
00492                            Geometry.SectorsPerTrack *
00493                            Geometry.BytesPerSector;
00494
00495             IoBuffer = VirtualAlloc(NULL,VirtBufSize,MEM_COMMIT,PAGE_READWRITE);
00496
00497             if ( !IoBuffer )
00498             {
00499                printf("MFMT: Buffer Allocation Failed\n");
00500                ExitProcess(1);
00501             }
00502
00503             for ( ;NumBufs > 0; NumBufs-- )
00504             {
00505                b = ReadFile(hDrive,IoBuffer, VirtBufSize, &BytesRead, NULL);
00506                if (b && BytesRead)
00507                {
00508                   b = WriteFile(hDiskImage,IoBuffer, BytesRead, &BytesWritten, NULL);
00509                   if ( !b || ( BytesRead != BytesWritten ) )
00510                   {
00511                      printf("MFMT: Fatal Write Error %d\n",GetLastError());
00512                      ExitProcess(1);
00513                   }
00514                }
00515                else
00516                {
00517                   printf("MFMT: Fatal Read Error %d\n",GetLastError());
00518                   ExitProcess(1);
00519                }
00520             }
00521          }
00522          else
00523          {
00524
00525             //
00526             // Check to see if the image will fit on the floppy. If it
00527             // will, then LowLevelFormat the floppy and press on
00528             //
00529
00530             FileSize = GetFileSize(hDiskImage,NULL);
00531
00532             b = FALSE;
00533             for (i=0;i<SupportedGeometryCount;i++)
00534             {
00535                NumBufs = SupportedGeometry[i].Cylinders.LowPart;
00536                VirtBufSize =  SupportedGeometry[i].TracksPerCylinder *
00537                               SupportedGeometry[i].SectorsPerTrack *
00538                               SupportedGeometry[i].BytesPerSector;
00539                if ( VirtBufSize*NumBufs >= FileSize )
00540                {
00541
00542                   IoBuffer = VirtualAlloc(NULL,VirtBufSize,MEM_COMMIT,PAGE_READWRITE);
00543
00544                   if ( !IoBuffer )
00545                   {
00546                      printf("MFMT: Buffer Allocation Failed\n");
00547                      ExitProcess(1);
00548                   }
00549
00550                   //
00551                   // Format the floppy
00552                   //
00553
00554                   LowLevelFormat(hDrive,&SupportedGeometry[i]);
00555
00556                   for ( ;NumBufs > 0; NumBufs-- )
00557                   {
00558                      b = ReadFile(hDiskImage,IoBuffer, VirtBufSize, &BytesRead, NULL);
00559                      if (b && BytesRead)
00560                      {
00561                         b = WriteFile(hDrive,IoBuffer, BytesRead, &BytesWritten, NULL);
00562                         if ( !b || ( BytesRead != BytesWritten ) )
00563                         {
00564                            printf("MFMT: Fatal Write Error %d\n",GetLastError());
00565                            ExitProcess(1);
00566                         }
00567                      }
00568                      else
00569                      {
00570                         printf("MFMT: Fatal Read Error %d\n",GetLastError());
00571                         ExitProcess(1);
00572                      }
00573                   }
00574                   b = TRUE;
00575                   break;
00576                }
00577             }
00578
00579             if ( !b )
00580             {
00581                printf("MFMT: FileSize %d is not supported on drive %s\n",FileSize,DriveName);
00582                ExitProcess(1);
00583             }
00584          }
00585       }
00586
00587       //
00588       // Dismounting forces the filesystem to re-evaluate the media id
00589       // and geometry. This is the same as popping the floppy in and out
00590       // of the disk drive
00591       //
00592
00593       DismountVolume(hDrive);
00594       UnlockVolume(hDrive);
00595
00596       ExitProcess(0);
00597    }
00598    return (0);
00599 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COleObject Member List

This is the complete list of members for COleObject, including all inherited members.
Advise(LPADVISESINK, LPDWORD) | COleObject |
Close(DWORD) | COleObject |
COleObject(COleDocument *pOleDoc) | COleObject |
DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT) | COleObject |
EnumAdvise(LPENUMSTATDATA *) | COleObject |
EnumVerbs(LPENUMOLEVERB *) | COleObject |
GetClientSite(LPOLECLIENTSITE *) | COleObject |
GetClipboardData(DWORD, LPDATAOBJECT *) | COleObject |
GetExtent(DWORD, LPSIZEL) | COleObject |
GetMiscStatus(DWORD, LPDWORD) | COleObject |
GetMoniker(DWORD, DWORD, LPMONIKER *) | COleObject |
GetUserClassID(CLSID *) | COleObject |
GetUserType(DWORD, LPOLESTR *) | COleObject |
InitFromData(LPDATAOBJECT, BOOL, DWORD) | COleObject |
IsUpToDate() | COleObject |
m_fOpen | COleObject | [private]
m_pOleDoc | COleObject | [private]
QueryInterface(REFIID, LPVOID *) | COleObject |
SetClientSite(LPOLECLIENTSITE) | COleObject |
SetColorScheme(LPLOGPALETTE) | COleObject |
SetExtent(DWORD, LPSIZEL) | COleObject |
SetHostNames(LPCOLESTR, LPCOLESTR) | COleObject |
SetMoniker(DWORD, LPMONIKER) | COleObject |
STDMETHODIMP_(ULONG) AddRef() | COleObject |
STDMETHODIMP_(ULONG) Release() | COleObject |
Unadvise(DWORD) | COleObject |
Update() | COleObject |
~COleObject() | COleObject |
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/main.h Source File

  • Web
  • bits
  • Upload

main.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  main.h
00011 //
00012 //  Purpose:
00013 //  Extern declaration of global variables that are used in more than
00014 //  one module.
00015 //
00016 //----------------------------------------------------------------------------
00017
00018
00019 #pragma once
00020
00021 #include "util.h"
00022 #include "cdialog.h"
00023 #include "cmonitor.h"
00024
00025 // -------------------------------------------------------------------------------------
00026 // Global variables
00027 // -------------------------------------------------------------------------------------
00028
00029 extern CSmartComPtr<IBackgroundCopyManager> g_JobManager;
00030 extern CMonitor                             g_NotificationReceiver;
00031 extern CSimpleDialog                       *g_pDialog;
00032 extern HANDLE                               g_hSafeToExitEvent;
00033
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/test.cpp Source File

  • WinUI
  • tsfapp

test.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation. All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Test.cpp
00013
00014    Description:   CTSFEditWnd::_OnTest() implementation
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019   #include statements
00020 **************************************************************************/
00021
00022 #include "TSFEdit.h"
00023 #include <ctffunc.h>
00024
00025 /**************************************************************************
00026   global variables and definitions
00027 **************************************************************************/
00028
00029 /**************************************************************************
00030
00031    CTSFEditWnd::_OnTest()
00032
00033 **************************************************************************/
00034
00035 void CTSFEditWnd::_OnTest(void)
00036 {
00037 }
00038
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminAccessChecksLevelOptions Member List

This is the complete list of members for comadmin::COMAdminAccessChecksLevelOptions, including all inherited members.
COMAdminAccessChecksApplicationComponentLevel | comadmin::COMAdminAccessChecksLevelOptions | [static]
COMAdminAccessChecksApplicationLevel | comadmin::COMAdminAccessChecksLevelOptions | [static]
Generated on Wed Nov 13 2024 16:58:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/Inc/IPAPER.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • Inc

IPAPER.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      IPAPER.H
00003
00004   Summary:   This is the common include file for the drawing paper-related
00005              COM Interfaces.  The Interface abstract base classes are
00006              declared.
00007
00008              This file is global to all the Tutorial Code Samples (kept in
00009              the ..\INC directory).  It is a good practice to factor out
00010              Interface and GUID specifications to reduce the possibility
00011              of GUID or interface conflicts.
00012
00013   Classes:   IPaper, IPaperSink.
00014
00015   Functions: .
00016
00017   Origin:    6-10-96: atrent - Revised for the COM Tutorial Samples.
00018
00019 ----------------------------------------------------------------------------
00020   This file is part of the Microsoft COM Tutorial Code Samples.
00021
00022   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00023
00024   This source code is intended only as a supplement to Microsoft
00025   Development Tools and/or on-line documentation.  See these other
00026   materials for detailed information regarding Microsoft code samples.
00027
00028   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00029   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00030   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00031   PARTICULAR PURPOSE.
00032 ==========================================================================+*/
00033
00034 #if !defined(IPAPER_H)
00035 #define IPAPER_H
00036
00037 #if !defined(RC_INCLUDE)
00038
00039
00040 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00041   Interface: IPaper
00042
00043   Summary:   Interface for free-form drawing on scratch-pad electronic
00044              paper-like COM Objects.
00045
00046   Methods:   InitPaper
00047                Init Paper object. Create Ink Data array.
00048              Lock
00049                Client takes control of the Paper. Locks out other clients.
00050              Unlock
00051                Client relinquishes control of the Paper.
00052              Load
00053                Load Paper content from client's compound file. Does Redraw.
00054              Save
00055                Save Paper content to client's compound file.
00056              InkStart
00057                Client starts color ink drawing to the Paper surface.
00058              InkDraw
00059                Client puts ink data points on the electronic Paper surface.
00060              InkStop
00061                Client stops ink drawing to the Paper surface.
00062              Erase
00063                Erase the current Paper content. Notify Sinks.
00064              Resize
00065                Resize the drawing paper rectangle size.
00066              Redraw
00067                Redraw content of Paper object. Notify sinks.
00068 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00069 DECLARE_INTERFACE_(IPaper, IUnknown)
00070 {
00071   // IUnknown methods.
00072   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00073   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00074   STDMETHOD_(ULONG,Release) (THIS) PURE;
00075
00076   // IPaper methods.
00077   STDMETHOD(InitPaper)  (THIS_ RECT*, BOOL*) PURE;
00078   STDMETHOD(Lock)       (THIS_ SHORT*) PURE;
00079   STDMETHOD(Unlock)     (THIS_ SHORT) PURE;
00080   STDMETHOD(Load)       (THIS_ SHORT, IStorage*) PURE;
00081   STDMETHOD(Save)       (THIS_ SHORT, IStorage*) PURE;
00082   STDMETHOD(InkStart)   (THIS_ SHORT, SHORT, SHORT, SHORT, COLORREF) PURE;
00083   STDMETHOD(InkDraw)    (THIS_ SHORT, SHORT, SHORT) PURE;
00084   STDMETHOD(InkStop)    (THIS_ SHORT, SHORT, SHORT) PURE;
00085   STDMETHOD(Erase)      (THIS_ SHORT) PURE;
00086   STDMETHOD(Resize)     (THIS_ SHORT, SHORT, SHORT) PURE;
00087   STDMETHOD(Redraw)     (THIS_ SHORT) PURE;
00088 };
00089
00090
00091 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00092   Interface: IPaperSink
00093
00094   Summary:   Sink Connection Interface for use by drawing paper-like COM
00095              Objects that communicate events back to the client.
00096
00097   Methods:   Locked
00098                A client has taken control and locked its use of the Paper.
00099              Unlocked
00100                A client has relinquished control of the Paper.
00101              Loaded
00102                A client has loaded Paper content from its own compound file.
00103              Saved
00104                A client has saved Paper content to its own compound file.
00105              InkStart
00106                A client started a color ink drawing sequence to the Paper.
00107              InkDraw
00108                A client is putting ink data points on the Paper surface.
00109              InkStop
00110                A client stopped its ink drawing sequence to the Paper.
00111              Erased
00112                A client has erased all ink data from the Paper.
00113              Resized
00114                A client has resized the Paper.
00115 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00116 DECLARE_INTERFACE_(IPaperSink, IUnknown)
00117 {
00118   // IUnknown methods.
00119   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
00120   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
00121   STDMETHOD_(ULONG,Release) (THIS) PURE;
00122
00123   // IPaperSink methods.
00124   STDMETHOD(Locked)     (THIS) PURE;
00125   STDMETHOD(Unlocked)   (THIS) PURE;
00126   STDMETHOD(Loaded)     (THIS) PURE;
00127   STDMETHOD(Saved)      (THIS) PURE;
00128   STDMETHOD(InkStart)   (THIS_ SHORT, SHORT, SHORT, COLORREF) PURE;
00129   STDMETHOD(InkDraw)    (THIS_ SHORT, SHORT) PURE;
00130   STDMETHOD(InkStop)    (THIS_ SHORT, SHORT) PURE;
00131   STDMETHOD(Erased)     (THIS) PURE;
00132   STDMETHOD(Resized)    (THIS_ SHORT, SHORT) PURE;
00133 };
00134
00135
00136 #endif // RC_INCLUDE
00137
00138 #endif // IPAPER_H
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/TrayNot/Resource.h Source File

  • WinUI
  • Shell
  • TrayNot

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // App Studio generated include file.
00003 // Used by APP32.RC
00004 //
00005 #define IDI_APP32                       102
00006 #define IDD_APP32                       103
00007 #define IDI_STATE11                     105
00008 #define IDI_STATE12                     106
00009 #define IDI_STATE21                     107
00010 #define IDI_STATE22                     108
00011 #define IDI_STATE31                     109
00012 #define IDI_STATE32                     110
00013 #define IDC_NOTIFY1                     1006
00014 #define IDC_NOTIFY2                     1007
00015 #define IDC_NOTIFY3                     1008
00016 #define IDC_STATE11                     1009
00017 #define IDC_STATE12                     1010
00018 #define IDC_STATE21                     1011
00019 #define IDC_STATE22                     1012
00020 #define IDC_STATE31                     1013
00021 #define IDC_STATE32                     1014
00022 #define IDC_DELAY1                      1017
00023 #define IDC_TIP11                       1018
00024 #define IDC_TIP12                       1019
00025 #define IDC_DELAY2                      1020
00026 #define IDC_TIP21                       1021
00027 #define IDC_TIP22                       1022
00028 #define IDC_DELAY3                      1023
00029 #define IDC_TIP31                       1024
00030 #define IDC_TIP32                       1025
00031 #define IDC_STATIC                      -1
00032
00033 // Next default values for new objects
00034 //
00035 #ifdef APSTUDIO_INVOKED
00036 #ifndef APSTUDIO_READONLY_SYMBOLS
00037
00038 #define _APS_NEXT_RESOURCE_VALUE        111
00039 #define _APS_NEXT_COMMAND_VALUE         106
00040 #define _APS_NEXT_CONTROL_VALUE         1019
00041 #define _APS_NEXT_SYMED_VALUE           101
00042 #endif
00043 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/RPCsvc/RPCsvc.Idl Source File

  • NetDS
  • RPC
  • RPCsvc

RPCsvc.Idl

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 1998 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   rpcsvc.idl
00009 //
00010 //  PURPOSE:  Simple RPC service .idl file.  This defines the wire
00011 //            "contract" between a client and server using this
00012 //            interface.  All data types and functions (methods,
00013 //            operations) that go over the wire must be defined here.
00014 //
00015 //
00016 [
00017 uuid(15cd3850-28ca-11ce-a4e8-00aa006116cb),
00018 version(1.0)
00019 ]
00020 interface RpcServiceSample
00021 {
00022
00023     error_status_t
00024   Ping(
00025       [in] handle_t Binding
00026       );
00027
00028
00029     error_status_t
00030   CheckSecurity(
00031       [in] handle_t Binding
00032       );
00033
00034
00035   // Sending a buffer (writing) to the server.
00036
00037   //
00038   // BufferIn1 and BufferIn2 both use length_is() and size_is().
00039   // This slows performance, because a larger buffer must be
00040   // allocated on the sever and the data copied into this larger
00041   // buffer.
00042   //
00043   // BufferIn2 has the most problems because it forces a 16K
00044   // allocation which may be much larger then needed and requires
00045     // and extra data copy.  It also limits clients to writing 16K
00046     // at a time.
00047   //
00048   // The BufferIn3() function saves the allocation and copy
00049     // and gives the client complete control of the size.
00050     //
00051   // Notes: Avoid length_is() on [in] parameters.  Usually
00052     //        size_is() is all that is really needed.
00053
00054     const unsigned long BUFFER_SIZE = 100;
00055
00056   error_status_t
00057   BufferIn1(
00058            [in] handle_t Binding,
00059            [length_is(BufferLength), size_is(BufferSize),
00060           in ] byte Buffer[],
00061            [in] unsigned long BufferLength,
00062              [in] unsigned long BufferSize
00063            );
00064
00065     error_status_t
00066   BufferIn2(
00067            [in] handle_t Binding,
00068            [length_is(BufferLength), in ] byte Buffer[16*1024],
00069              [in] unsigned long BufferLength
00070              );
00071
00072     error_status_t
00073     BufferIn3(
00074            [in] handle_t Binding,
00075            [size_is(BufferLength), in ] byte Buffer[],
00076            [in] unsigned long BufferLength
00077              );
00078
00079     // Getting a buffer (reading) from the server.
00080     //
00081     // In BufferOut1 the size of the output is limited to 16K,
00082     // which will force extra round trips when more then 16K
00083     // is being returned. This requires the client to supply a
00084     // 16K buffer and the stub to allocate 16K on the server side.
00085     //
00086     // In BufferOut2 the client decides how big the buffer
00087     // should be and only as much as the client wants is
00088     // allocated in the server.  Similar to BufferOut4
00089     // which is better.
00090     //
00091     // In BufferOut3 the server allocates a buffer exactly
00092     // as large as it wants.  This results in two allocations,
00093     // one in the server manager and one in the client.  This
00094     // is best if the clients have no idea how much data the
00095     // server will give them.
00096     //
00097     // In BufferOut4 the client decides how big the buffer
00098     // should be.  The server can shorten (this should
00099     // be uncommon) the buffer if needed.
00100     //
00101     // Notes: Consider how the client and server interact
00102     //   in your application when choosing a "read" style
00103     //   interface.
00104
00105
00106     error_status_t
00107     BufferOut1(
00108               [in] handle_t Binding,
00109               [out,length_is(*pBufferLength)] byte Buffer[16*1024],
00110               [out] unsigned long *pBufferLength
00111               );
00112
00113     error_status_t
00114     BufferOut2(
00115               [in] handle_t Binding,
00116               [size_is(BufferSize), length_is(*pBufferLength),
00117                out] byte Buffer[],
00118               [in] unsigned long BufferSize,
00119               [out] unsigned long *pBufferLength
00120               );
00121
00122     typedef struct {
00123         unsigned long BufferLength;
00124         [unique, size_is(BufferLength)] byte *Buffer;
00125         } BUFFER;
00126
00127     error_status_t
00128     BufferOut3(
00129               [in] handle_t Binding,
00130               [out] BUFFER *pBuffer
00131               );
00132
00133     error_status_t
00134     BufferOut4(
00135               [in] handle_t Binding,
00136               [out, size_is(*pBufferLength)] byte Buffer[],
00137               [in, out] unsigned long *pBufferLength
00138               );
00139
00140     // Structures and Enums.
00141     //
00142     // Use -Zp8 (or higher). (Default on Win32 platforms)
00143     //
00144     // Make sure the structure ends on a 0 mod 4 address.
00145     //
00146     // Use [v1_enum] on all enumerated types.
00147     //
00148     // Following these rules will result in structures (and
00149     // arrays of structures) which can be memcpy()'ed to and from
00150     // the wire.  Otherwise the structures will be copied
00151     // member-by-member. (ouch!)
00152     //
00153
00154     typedef enum {
00155         A = 1,
00156         B,
00157         C,
00158         D
00159         } BAD_ENUM;
00160
00161     typedef [v1_enum] enum {
00162         E = 5,
00163         F,
00164         G,
00165         H
00166         } GOOD_ENUM;
00167
00168     struct BAD1 {
00169         long l;
00170         short s;  // Ends on 6 % 4 = 2 byte address.
00171         };
00172
00173     struct BAD2 {
00174         BAD_ENUM e;  // 16bits on the wire, 32bits in memory!
00175         long l;      // How big is it?
00176         };
00177
00178     struct GOOD {
00179         GOOD_ENUM e;  // v1_enum 32bits on wire and in memory.
00180         long l;
00181         long l2;      // Ends on 12 % 4 = 0 byte address.
00182         };
00183
00184     error_status_t
00185     StructsIn1(
00186               [in] handle_t Binding,
00187               [in] struct BAD1 array[50]
00188               );
00189
00190     error_status_t
00191     StructsIn2(
00192               [in] handle_t Binding,
00193               [in] struct BAD2 array[50]
00194               );
00195
00196     error_status_t
00197     StructsIn3(
00198               [in] handle_t Binding,
00199               [in] struct GOOD array[50]
00200               );
00201     // Linked list examples
00202     //
00203     // Follow the rules for structs when defining your linked
00204     // list nodes.
00205     //
00206     // ListIn and ListOut1 are the basic linked list functions,
00207     // ListOut1 is more expensive because each node must be copied
00208     // into nodes on the client.  (In ListIn the list pointers
00209     // are fixed up in one big buffer.)
00210     //
00211     // ListOut2 is identical to ListOut1 except that it turns
00212     // on the RPC allocator in the server.
00213     //
00214     // Linked lists are not very efficient for RPC because the
00215     // often require many memory allocations.  When possible,
00216     // replace linked lists with variably sized arrays of structures.
00217     //
00218
00219     const unsigned long LIST_SIZE = 50;
00220
00221     typedef struct LIST {
00222         [unique] struct LIST *pNext;
00223         unsigned long data;
00224         } LIST;
00225
00226     typedef [unique] LIST *PLIST;
00227
00228     error_status_t
00229     ListIn(
00230           [in] handle_t Binding,
00231           [in] PLIST pList
00232           );
00233
00234     error_status_t
00235     ListOut1(
00236             [in] handle_t Binding,
00237             [out] LIST *pListHead
00238             );
00239
00240     // [enable_allocate] in .acf.
00241     error_status_t
00242     ListOut2(
00243             [in] handle_t Binding,
00244             [out] LIST *pListHead
00245             );
00246
00247     // Unions
00248     //
00249     // Avoid using very many unions. For example, don't pass an array in
00250     // which each element contains a union with several arms.  Instead,
00251     // define several different structures and define a union with several
00252     // arms each being an array of one of the different types of structures.
00253     //
00254     // Do NOT define a [default] arm for your unions.  This way a future
00255     // version of the union can include new arms and still interoperate
00256     // with older versions of the interface.
00257     //
00258     // Avoid passing unions by value.
00259     //
00260
00261     const unsigned long UNION_ARRAY_LEN = 50;
00262
00263     typedef struct BAD_UNION {
00264         unsigned long Tag;
00265         [switch_is(Tag)] union
00266             {
00267             [case(1)]
00268                 unsigned long ulData;
00269             [case(2)]
00270                 unsigned hyper uhData;
00271             [default]
00272                 // The default arm here prevents the addition of
00273                 // another case in future versions.
00274                 ;
00275             } u;
00276         } BAD_UNION;
00277
00278     typedef struct ONE {
00279         unsigned long DataLength;
00280         [size_is(DataLength)] unsigned long *Data;
00281         } ARM_ONE;
00282
00283     typedef struct TWO {
00284         unsigned long DataLength;
00285         [size_is(DataLength)] unsigned hyper *Data;
00286         } ARM_TWO;
00287
00288     typedef struct {
00289         unsigned long Tag;
00290         [switch_is(Tag)] union
00291             {
00292             [case (1)]
00293                 [unique] ARM_ONE *pOne;
00294             [case (2)]
00295                 [unique] ARM_TWO *pTwo;
00296
00297             // May add [case(3)] in a future version.
00298             //
00299             // When calling a down level server with Tag == 3 the
00300             // error RPC_S_INVALID_TAG will get returned.  Values
00301             // 1 and 2 will continue to work.
00302             //
00303             // If there was a [default] arm this wouldn't work.
00304
00305             } u;
00306         } GOOD_UNION;
00307
00308         error_status_t
00309         UnionCall1(
00310                   [in] handle_t Binding,
00311                   [in] unsigned long Length,
00312                   [in, size_is(Length)] BAD_UNION ArrayOfUnions[]
00313                   );
00314
00315         error_status_t
00316         UnionCall2(
00317                   [in] handle_t Binding,
00318                   [in] GOOD_UNION *pUnionContainingArrays
00319                   );
00320
00321 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook Server/CMgdResType.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook Server

CMgdResType.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      CMgdResType.cpp
00007 //
00008 //  Description:
00009 //      Implementation for the Managed Resource Type class - this
00010 //      demonstrates how to implement the IClusCfgResourceTypeInfo interface.
00011 //
00012 //  Author:
00013 //      <name> (<e-mail name>) Mmmm DD, 2003
00014 //
00015 //  Revision History:
00016 //
00017 //  Notes:
00018 //
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 //////////////////////////////////////////////////////////////////////////////
00022 // Include Files
00023 //////////////////////////////////////////////////////////////////////////////
00024
00025 #include "clres.h"
00026 #include "CMgdResType.h"
00027
00028 #pragma warning( push, 3 )
00029 #include "MgdResource_i.c"
00030 #pragma warning( pop )
00031
00032 //////////////////////////////////////////////////////////////////////////////
00033 // Define's
00034 //////////////////////////////////////////////////////////////////////////////
00035
00036 //
00037 // Some defaults for resource type creation.
00038 //
00039
00040 #define CLUSTER_RESTYPE_DEFAULT_LOOKS_ALIVE     (  5 * 1000 )
00041 #define CLUSTER_RESTYPE_DEFAULT_IS_ALIVE        ( 60 * 1000 )
00042
00043
00044 //////////////////////////////////////////////////////////////////////////////
00045 // CMgdResType -- IClusCfgResourceTypeInfo interface.
00046 //////////////////////////////////////////////////////////////////////////////
00047
00048
00049 //////////////////////////////////////////////////////////////////////////////
00050 //++
00051 //
00052 //  CMgdResType::CommitChanges
00053 //
00054 //  Description:
00055 //      Components implement the CommitChanges interface to create or delete
00056 //      resource types according to the state of the local computer.
00057 //
00058 //  Arguments:
00059 //      punkClusterInfoIn
00060 //          Interface for querying for other interfaces to get information
00061 //          about the cluster (IClusCfgClusterInfo).
00062 //
00063 //      punkResTypeServicesIn
00064 //          Interface for querying for the IClusCfgResourceTypeCreate
00065 //          interface on.
00066 //
00067 //  Return Value:
00068 //      S_OK
00069 //          Success.
00070 //
00071 //      E_POINTER
00072 //          Expected pointer argument specified as NULL.
00073 //
00074 //      E_UNEXPECTED
00075 //          Unexpected commit mode.
00076 //
00077 //      Other HRESULTs
00078 //          Failure.
00079 //
00080 //  Remarks:
00081 //      None.
00082 //
00083 //--
00084 //////////////////////////////////////////////////////////////////////////////
00085 STDMETHODIMP
00086 CMgdResType::CommitChanges(
00087       IUnknown *    punkClusterInfoIn
00088     , IUnknown *    punkResTypeServicesIn
00089     )
00090 {
00091     assert( punkClusterInfoIn != NULL );
00092     assert( punkResTypeServicesIn != NULL );
00093
00094     HRESULT                         hr = S_OK;
00095     IClusCfgClusterInfo *           pccci = NULL;
00096     IClusCfgResourceTypeCreate *    pccrtc = NULL;
00097     ECommitMode                     ecm = cmUNKNOWN;
00098
00099     hr = HrSendStatusReport(
00100           TASKID_Major_Configure_Resource_Types
00101         , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00102         , 0
00103         , 6
00104         , 0
00105         , hr
00106         , IDS_CLUSCFG_INFO_CONFIGURING_RESTYPE
00107         , 0
00108         , GetDisplayName()
00109         );
00110     if ( FAILED( hr ) )
00111     {
00112         goto Cleanup;
00113     } // if:
00114
00115     //
00116     // Validate arguments
00117     //
00118
00119     if ( ( punkClusterInfoIn == NULL ) || ( punkResTypeServicesIn == NULL ) )
00120     {
00121         hr = E_POINTER;
00122         goto Cleanup;
00123     } // if: one of the arguments is NULL
00124
00125     hr = HrSendStatusReport(
00126           TASKID_Major_Configure_Resource_Types
00127         , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00128         , 0
00129         , 6
00130         , 1
00131         , hr
00132         , IDS_CLUSCFG_INFO_CONFIGURING_RESTYPE
00133         , 0
00134         , GetDisplayName()
00135         );
00136     if ( FAILED( hr ) )
00137     {
00138         goto Cleanup;
00139     } // if:
00140
00141     //
00142     // Find out what event caused this call.
00143     //
00144
00145     hr = punkClusterInfoIn->TypeSafeQI( IClusCfgClusterInfo, &pccci );
00146     if ( FAILED( hr ) )
00147     {
00148         goto Cleanup;
00149     } // if:
00150
00151     hr = HrSendStatusReport(
00152           TASKID_Major_Configure_Resource_Types
00153         , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00154         , 0
00155         , 6
00156         , 2
00157         , hr
00158         , IDS_CLUSCFG_INFO_CONFIGURING_RESTYPE
00159         , 0
00160         , GetDisplayName()
00161         );
00162     if ( FAILED( hr ) )
00163     {
00164         goto Cleanup;
00165     } // if:
00166
00167     hr = pccci->GetCommitMode( &ecm );
00168     if ( FAILED( hr ) )
00169     {
00170         goto Cleanup;
00171     } // if: we could not determine the commit mode
00172
00173     hr = HrSendStatusReport(
00174           TASKID_Major_Configure_Resource_Types
00175         , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00176         , 0
00177         , 6
00178         , 3
00179         , hr
00180         , IDS_CLUSCFG_INFO_CONFIGURING_RESTYPE
00181         , 0
00182         , GetDisplayName()
00183         );
00184     if ( FAILED( hr ) )
00185     {
00186         goto Cleanup;
00187     } // if:
00188
00189     hr = S_OK;
00190
00191     //
00192     //  Check if we are creating a cluster or adding nodes to an existing cluster.
00193     //
00194
00195     if ( ( ecm == cmCREATE_CLUSTER ) || ( ecm == cmADD_NODE_TO_CLUSTER ) )
00196     {
00197         //
00198         //  We are either creating a cluster on this node or adding it to a
00199         //  cluster.  We need to register our resource type and the associated
00200         //  Cluadmin extension dll.
00201         //
00202
00203         //
00204         // First, register our resource type.
00205         //
00206
00207         hr = punkResTypeServicesIn->TypeSafeQI( IClusCfgResourceTypeCreate, &pccrtc );
00208         if ( FAILED( hr ) )
00209         {
00210             goto Cleanup;
00211         } // if:
00212
00213         hr = pccrtc->Create(
00214                           GetResTypeName()
00215                         , GetDisplayName()
00216                         , GetDllName()
00217                         , CLUSTER_RESTYPE_DEFAULT_LOOKS_ALIVE
00218                         , CLUSTER_RESTYPE_DEFAULT_IS_ALIVE
00219                         );
00220
00221         if ( FAILED( hr ) )
00222         {
00223             goto Cleanup;
00224         } // if:
00225
00226         hr = HrSendStatusReport(
00227               TASKID_Major_Configure_Resource_Types
00228             , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00229             , 0
00230             , 6
00231             , 4
00232             , hr
00233             , IDS_CLUSCFG_INFO_CONFIGURED_RESTYPE
00234             , 0
00235             , GetResTypeName()
00236             , GetDisplayName()
00237             , GetDllName()
00238             );
00239         if ( FAILED( hr ) )
00240         {
00241             goto Cleanup;
00242         } // if:
00243
00244         hr = pccrtc->RegisterAdminExtensions(
00245                           GetDisplayName()
00246                         , 1
00247                         , &CLSID_CoClipBookServerEx
00248                         );
00249
00250         if ( FAILED( hr ) )
00251         {
00252             goto Cleanup;
00253         } // if:
00254
00255         hr = HrSendStatusReport(
00256               TASKID_Major_Configure_Resource_Types
00257             , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00258             , 0
00259             , 6
00260             , 5
00261             , hr
00262             , IDS_CLUSCFG_INFO_CONFIGURING_RESTYPE
00263             , 0
00264             , GetDisplayName()
00265             );
00266         if ( FAILED( hr ) )
00267         {
00268             goto Cleanup;
00269         } // if:
00270     } // if: we are either forming or joining ( but not both )
00271     else
00272     {
00273         //
00274         // Check for invalid commit modes.
00275         //
00276
00277         if ( ( ecm == cmUNKNOWN ) || ( ecm >= cmMAX ) )
00278         {
00279             hr = E_UNEXPECTED;
00280             goto Cleanup;
00281         } // if: invalid commit mode
00282
00283         assert( ecm == cmCLEANUP_NODE_AFTER_EVICT );
00284
00285         //
00286         // If we are here, then this node has been evicted.
00287         //
00288
00289         //
00290         // TODO: Add code to cleanup your resource type after the
00291         // local node has been evicted from the cluster.
00292         //
00293         // If your resource has a different configuration when it's part of
00294         // cluster then this is where you return it to stand-alone server mode.
00295         //
00296
00297         hr = S_OK;
00298
00299     } // else: we are not forming nor joining
00300
00301     //
00302     // Success.
00303     //
00304
00305     HrSendStatusReport(
00306           TASKID_Major_Configure_Resource_Types
00307         , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00308         , 0
00309         , 6
00310         , 6
00311         , hr
00312         , IDS_CLUSCFG_INFO_CONFIGURING_RESTYPE
00313         , 0
00314         , GetDisplayName()
00315         );
00316
00317 Cleanup:
00318
00319     if ( pccci != NULL )
00320     {
00321         pccci->Release();
00322         pccci = NULL;
00323     } // if:
00324
00325     if ( pccrtc != NULL )
00326     {
00327         pccrtc->Release();
00328         pccrtc = NULL;
00329     } // if:
00330
00331     if ( FAILED( hr ) )
00332     {
00333         HrSendStatusReport(
00334               TASKID_Major_Configure_Resource_Types
00335             , TASKID_Minor_ClipBookServer_ResType_CommitChanges
00336             , 0
00337             , 6
00338             , 6
00339             , hr
00340             , IDS_CLUSCFG_ERROR_CONFIGURING_RESTYPE_FAILED
00341             , 0
00342             , GetDisplayName()
00343             );
00344     } // if: FAILED
00345
00346     return hr;
00347
00348 } //*** CMgdResType::CommitChanges
00349
00350
00351 //////////////////////////////////////////////////////////////////////////////
00352 //++
00353 //
00354 //  CMgdResType::GetTypeGUID
00355 //
00356 //  Description:
00357 //      Retrieves the globally unique identifier of this resource type.
00358 //
00359 //  Arguments:
00360 //      pguidGUIDOut
00361 //          Upon success will point to the resource type's (static) GUID.
00362 //
00363 //  Return Value:
00364 //      S_OK
00365 //          Success.
00366 //
00367 //      E_POINTER
00368 //          Expected pointer argument specified as NULL.
00369 //
00370 //      Other HRESULTs
00371 //          Failure.
00372 //
00373 //  Remarks:
00374 //      None.
00375 //
00376 //--
00377 //////////////////////////////////////////////////////////////////////////////
00378 STDMETHODIMP
00379 CMgdResType::GetTypeGUID(
00380     GUID * pguidGUIDOut
00381     )
00382 {
00383     assert( pguidGUIDOut != NULL );
00384
00385     HRESULT hr = S_OK;
00386
00387     if ( pguidGUIDOut == NULL )
00388     {
00389         hr = E_POINTER;
00390     } // if: the output pointer is NULL
00391     else
00392     {
00393         *pguidGUIDOut = RESTYPE_ClipBookServer;
00394     } // else: the output pointer is valid
00395
00396     return hr;
00397
00398 } //*** CMgdResType::GetTypeGUID
00399
00400
00401 //////////////////////////////////////////////////////////////////////////////
00402 //++
00403 //
00404 //  CMgdResType::GetTypeName
00405 //
00406 //  Description:
00407 //      Retrieves the resource type name of this resource type.
00408 //
00409 //  Arguments:
00410 //      pbstrTypeNameOut
00411 //          Upon success will point to an allocated BSTR containing the type name.
00412 //
00413 //  Return Value:
00414 //      S_OK
00415 //          Success.
00416 //
00417 //      E_POINTER
00418 //          Expected pointer argument specified as NULL.
00419 //
00420 //      E_OUTOFMEMORY
00421 //          Out of memory.
00422 //
00423 //      Other HRESULTs
00424 //          Failure.
00425 //
00426 //  Remarks:
00427 //      If S_OK is returned the caller needs to call SysFreeString on pbstrTypeNameOut.
00428 //
00429 //--
00430 //////////////////////////////////////////////////////////////////////////////
00431 STDMETHODIMP
00432 CMgdResType::GetTypeName(
00433     BSTR* pbstrTypeNameOut
00434     )
00435 {
00436     assert( pbstrTypeNameOut != NULL );
00437
00438     HRESULT hr = S_OK;
00439
00440     if ( pbstrTypeNameOut == NULL )
00441     {
00442         hr = E_POINTER;
00443         goto Cleanup;
00444     } // if: the output pointer is NULL
00445
00446     *pbstrTypeNameOut = SysAllocString( GetResTypeName() );
00447     if ( *pbstrTypeNameOut == NULL )
00448     {
00449         hr = E_OUTOFMEMORY;
00450         goto Cleanup;
00451     } // if: memory for the resource type name could not be allocated
00452
00453 Cleanup:
00454
00455     return hr;
00456
00457 } //*** CMgdResType::GetTypeName
00458
00459
00460 /////////////////////////////////////////////////////////////////////////////
00461 // CMgdResType -- IClusCfgStartupListener interface.
00462 /////////////////////////////////////////////////////////////////////////////
00463
00464
00465 //////////////////////////////////////////////////////////////////////////////
00466 //++
00467 //
00468 //  CMgdResType::Notify
00469 //
00470 //  Description:
00471 //      This method is called to inform a component that the cluster service
00472 //      has started on this computer.
00473 //
00474 //      This component is registered for the cluster service startup notification
00475 //      as a part of the cluster service upgrade (clusocm.inf). This method creates
00476 //      the required resource type and associates the cluadmin extension dll then
00477 //      deregisters itself from this notification.
00478 //
00479 //  Arguments:
00480 //      IUnknown * punkIn
00481 //          The component that implements this Punk may also provide services
00482 //          that are useful to the implementor of this method. For example,
00483 //          this component usually implements the IClusCfgResourceTypeCreate
00484 //          interface.
00485 //
00486 //  Return Values:
00487 //      S_OK
00488 //          Success.
00489 //
00490 //      Other HRESULTs
00491 //          Failure.
00492 //
00493 //--
00494 //////////////////////////////////////////////////////////////////////////////
00495 HRESULT
00496 CMgdResType::Notify(
00497     IUnknown * punkIn
00498     )
00499 {
00500     HRESULT                         hr = S_OK;
00501     IClusCfgResourceTypeCreate *    piccrtc = NULL;
00502     const GUID *                    guidAdminEx = &CLSID_CoClipBookServerEx;
00503     ICatRegister *                  pcrCatReg = NULL;
00504     CATID                           rgCatId[ 1 ];
00505
00506     hr = HrSendStatusReport(
00507                   TASKID_Major_Client_And_Server_Log
00508                 , IID_NULL
00509                 , 1
00510                 , 1
00511                 , 1
00512                 , hr
00513                 , L"Startup Notify called for resource type '%1!ws!'."
00514                 , (LPCWSTR) NULL
00515                 , GetResTypeName()
00516                 );
00517     if ( FAILED( hr ) )
00518     {
00519         goto Cleanup;
00520     } // if:
00521
00522     hr = punkIn->TypeSafeQI( IClusCfgResourceTypeCreate, &piccrtc );
00523     if ( FAILED( hr ) )
00524     {
00525         goto Cleanup;
00526     } // if:
00527
00528     //
00529     // Create the resource type.
00530     //
00531
00532     hr = piccrtc->Create(
00533                       GetResTypeName()
00534                     , GetDisplayName()
00535                     , GetDllName()
00536                     , 5 *  1000
00537                     , 60 * 1000
00538                     );
00539     if ( FAILED( hr ) )
00540     {
00541         goto Cleanup;
00542     } // if:
00543
00544     hr = HrSendStatusReport(
00545                   TASKID_Major_Client_And_Server_Log
00546                 , IID_NULL
00547                 , 1
00548                 , 1
00549                 , 1
00550                 , hr
00551                 , L"Successfully created resource type '%1!ws!'."
00552                 , (LPCWSTR) NULL
00553                 , GetResTypeName()
00554                 );
00555     if ( FAILED( hr ) )
00556     {
00557         goto Cleanup;
00558     } // if:
00559
00560     //
00561     // Register the cluadmin extensions.
00562     //
00563
00564     hr = piccrtc->RegisterAdminExtensions(
00565                       GetResTypeName()
00566                     , 1
00567                     , guidAdminEx
00568                     );
00569     if ( FAILED( hr ) )
00570     {
00571         goto Cleanup;
00572     } // if:
00573
00574     hr = HrSendStatusReport(
00575                   TASKID_Major_Client_And_Server_Log
00576                 , IID_NULL
00577                 , 1
00578                 , 1
00579                 , 1
00580                 , hr
00581                 , L"Successfully registered Cluster Administrator extensions for resource type '%1!ws!'."
00582                 , (LPCWSTR) NULL
00583                 , GetResTypeName()
00584                 );
00585     if ( FAILED( hr ) )
00586     {
00587         goto Cleanup;
00588     } // if:
00589
00590     //
00591     // Unregister from StartupListener notifications.
00592     //
00593
00594     hr = CoCreateInstance(
00595               CLSID_StdComponentCategoriesMgr
00596             , NULL
00597             , CLSCTX_INPROC_SERVER
00598             , __uuidof( pcrCatReg )
00599             , reinterpret_cast< void ** >( &pcrCatReg )
00600             );
00601
00602     if ( FAILED( hr ) )
00603     {
00604         goto Cleanup;
00605     } // if: CoCreate failed
00606
00607     rgCatId[ 0 ] = CATID_ClusCfgStartupListeners;
00608
00609     hr = pcrCatReg->UnRegisterClassImplCategories( CLSID_ClipBookServer, RTL_NUMBER_OF( rgCatId ), rgCatId );
00610     if ( FAILED( hr ) )
00611     {
00612         goto Cleanup;
00613     } // if: deregister failed
00614
00615     pcrCatReg->Release();
00616     pcrCatReg = NULL;
00617
00618     hr = HrSendStatusReport(
00619                   TASKID_Major_Client_And_Server_Log
00620                 , IID_NULL
00621                 , 1
00622                 , 1
00623                 , 1
00624                 , hr
00625                 , L"Successfully unregistered the '%1!ws!' resource type from StartupListener notifications."
00626                 , (LPCWSTR) NULL
00627                 , GetResTypeName()
00628                 );
00629     if ( FAILED( hr ) )
00630     {
00631         goto Cleanup;
00632     } // if:
00633
00634 Cleanup:
00635
00636     if ( piccrtc != NULL )
00637     {
00638         piccrtc->Release();
00639     } // if:
00640
00641     if ( pcrCatReg != NULL )
00642     {
00643         pcrCatReg->Release();
00644     } // if:
00645
00646     return hr;
00647
00648 } //*** CMgdResType::Notify
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MYDATA Member List

This is the complete list of members for _MYDATA, including all inherited members.
szTest1 | _MYDATA
szTest2 | _MYDATA
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/PropProv/Sample.h Source File

  • SysMgmt
  • WMI
  • VC
  • PropProv

Sample.h

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  SAMPLE.h
00006
00007 //
00008
00009 //  Module: WMI Sample Property Provider
00010
00011 //
00012
00013 //  Purpose: Genral purpose include file.
00014
00015 //
00016
00017 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00018 //
00019 //***************************************************************************
00020
00021 #ifndef _SAMPLE_H_
00022 #define _SAMPLE_H_
00023
00024 #include <wbemcli.h>
00025 #include <wbemprov.h>
00026
00027 typedef LPVOID * PPVOID;
00028
00029 // Provider interfaces are provided by objects of this class
00030
00031 class CPropPro : public IWbemPropertyProvider
00032     {
00033     protected:
00034         ULONG           m_cRef;         //Object reference count
00035
00036     public:
00037         CPropPro();
00038         ~CPropPro(void);
00039
00040     //Non-delegating object IUnknown
00041         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00042         STDMETHODIMP_(ULONG) AddRef(void);
00043         STDMETHODIMP_(ULONG) Release(void);
00044
00045
00046     /* IWbemPropertyProvider methods */
00047
00048        virtual HRESULT STDMETHODCALLTYPE GetProperty(
00049             /* [in] */ long lFlags,
00050             /* [in] */ const BSTR Locale,
00051             /* [in] */ const BSTR ClassMapping,
00052             /* [in] */ const BSTR InstMapping,
00053             /* [in] */ const BSTR PropMapping,
00054             /* [out] */ VARIANT *pvValue);
00055
00056         virtual HRESULT STDMETHODCALLTYPE PutProperty(
00057             /* [in] */ long lFlags,
00058             /* [in] */ const BSTR Locale,
00059             /* [in] */ const BSTR ClassMapping,
00060             /* [in] */ const BSTR InstMapping,
00061             /* [in] */ const BSTR PropMapping,
00062             /* [in] */ const VARIANT __RPC_FAR *pvValue);
00063
00064     };
00065
00066 // This class is the class factory for CPropPro objects.
00067
00068 class CProvFactory : public IClassFactory
00069     {
00070     protected:
00071         ULONG           m_cRef;
00072
00073     public:
00074         CProvFactory(void);
00075         ~CProvFactory(void);
00076
00077         //IUnknown members
00078         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00079         STDMETHODIMP_(ULONG) AddRef(void);
00080         STDMETHODIMP_(ULONG) Release(void);
00081
00082         //IClassFactory members
00083         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
00084                                  , PPVOID);
00085         STDMETHODIMP         LockServer(BOOL);
00086     };
00087
00088 typedef CProvFactory *PCProvFactory;
00089
00090 // These variables keep track of when the module can be unloaded
00091
00092 extern long       g_cObj;
00093 extern long       g_cLock;
00094
00095 // General purpose utilities.
00096
00097 #endif //_SAMPLE_H_
00098
00099
00100
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsCmd/dump.cxx Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsCmd

dump.cxx

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //
00003 //  Microsoft Active Directory 2.5 Sample Code
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1996 - 2000
00006 //
00007 //  File:       dump.cxx
00008 //
00009 //  Contents:   Functions for dumping the properties for an object.
00010 //
00011 //
00012 //----------------------------------------------------------------------
00013
00014 #include "main.hxx"
00015
00016 //
00017 // Given an ADsPath, bind to the object and call the DumpObject routine.
00018 //
00019
00020 int
00021 DoDump(char *AnsiADsPath)
00022 {
00023  HRESULT hr = E_OUTOFMEMORY ;
00024  LPWSTR pszADsPath = NULL;
00025  IADs * pADs = NULL;
00026
00027  //
00028  // Convert path to unicode and then bind to the object.
00029  //
00030
00031  BAIL_ON_NULL(pszADsPath = AllocateUnicodeString(AnsiADsPath));
00032
00033  hr = ADsGetObject(
00034              pszADsPath,
00035              IID_IADs,
00036              (void **)&pADs
00037              );
00038
00039  if (FAILED(hr)) {
00040
00041      wprintf(L"Failed to bind to object: %s\n", pszADsPath) ;
00042      BAIL_ON_FAILURE(hr, L"Failed to do ADsGetObject");
00043  }
00044  else {
00045
00046      //
00047      // Dump the object
00048      //
00049
00050      hr = DumpObject(pADs);
00051
00052      if (FAILED(hr)) {
00053
00054          wprintf(L"Unable to read properties of: %s\n", pszADsPath) ;
00055      }
00056
00057      pADs->Release();
00058  }
00059
00060 error:
00061
00062  FreeUnicodeString(pszADsPath);
00063
00064  return (FAILED(hr) ? 1 : 0) ;
00065 }
00066
00067 //
00068 // Given an ADs pointer, dump the contents of the object
00069 //
00070
00071 HRESULT
00072 DumpObject(
00073  IADs * pADs
00074  )
00075 {
00076  HRESULT hr;
00077 HRESULT hrSA;
00078  VARIANT var;
00079 ZeroMemory(&var,sizeof(var));
00080 VARIANT *   pvarPropName = NULL;
00081  DWORD i = 0;
00082 VARIANT varProperty;
00083
00084  //
00085  // Access the schema for the object
00086  //
00087
00088  hr = GetPropertyList(
00089              pADs,
00090              &var);
00091  BAIL_ON_FAILURE(hr, L"Failed to get property list");
00092
00093  //
00094  // List the Properties
00095 //
00096 hr = SafeArrayAccessData(var.parray, (void **) &pvarPropName);
00097 BAIL_ON_FAILURE(hr, L"Failed while calling SafeArrayAccessData");
00098
00099 for (i = 0; i < var.parray->rgsabound[0].cElements; i++){
00100
00101    //
00102      // Get a property and print it out. The HRESULT is passed to
00103      // PrintProperty.
00104      //
00105
00106      hr = pADs->Get(
00107              pvarPropName[i].bstrVal,
00108              &varProperty
00109              );
00110      if (FAILED(hr)) {
00111          wprintf(L"Error: 0x%x \t Failed to get the property: %s \n", hr, pvarPropName[i].bstrVal);
00112          continue;
00113      }
00114
00115      PrintProperty(
00116          pvarPropName[i].bstrVal,
00117          hr,
00118          varProperty
00119          );
00120
00121    VariantClear(&varProperty);
00122
00123 }
00124
00125 hr = SafeArrayUnaccessData(var.parray);
00126 BAIL_ON_FAILURE(hr, L"Failed when calling SafeArrayUnaccessData");
00127
00128 error:
00129 // Don't destroy hr in case we're here from BAIL_ON_FAILURE
00130 if(var.parray) hrSA = SafeArrayDestroy(var.parray);
00131
00132 return(hr);
00133 }
00134
00135
00136 HRESULT
00137 GetPropertyList(
00138  IADs * pADs,
00139  VARIANT * pvar )
00140 {
00141  HRESULT hr= S_OK;
00142  BSTR bstrSchemaPath = NULL;
00143 IADsClass * pADsClass = NULL;
00144
00145  hr = pADs->get_Schema(&bstrSchemaPath);
00146  BAIL_ON_FAILURE(hr, L"Failed to get the schema path of the class");
00147
00148  hr = ADsGetObject(
00149              bstrSchemaPath,
00150              IID_IADsClass,
00151              (void **)&pADsClass);
00152  BAIL_ON_FAILURE(hr, L"Failed to bind to schema path of the class");
00153
00154 //Put SafeArray of bstr's into input variant struct
00155 hr = pADsClass->get_MandatoryProperties(pvar);
00156 BAIL_ON_FAILURE(hr, L"Failed to get the mandatory properties of the class");
00157
00158 error:
00159  if (bstrSchemaPath) {
00160      SysFreeString(bstrSchemaPath);
00161  }
00162
00163  if (pADsClass) {
00164      pADsClass->Release();
00165  }
00166
00167  return(hr);
00168 }
00169
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/Deb/Deb.h Source File

  • WinBase
  • Debug
  • Deb

Deb.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00009
00010 *       This source code is only intended as a supplement to
00011 *       Microsoft Development Tools and/or WinHelp documentation.
00012 *       See these sources for detailed information regarding the
00013 *       Microsoft samples programs.
00014 \******************************************************************************/
00015
00016 #ifndef DEB_H
00017
00018 #define DEB_H
00019
00020  //-- menu ids
00021  #define IDM_FILE_OPEN               1101
00022  #define IDM_FILE_ATTACH             1102
00023  #define IDM_FILE_EXIT               1109
00024
00025  #define IDM_EDIT_CUT                1201
00026  #define IDM_EDIT_COPY               1202
00027  #define IDM_EDIT_DELETE             1203
00028
00029  #define IDM_OPTIONS_FONT            1701
00030  #define IDM_OPTIONS_PREFERENCES     1702
00031  #define IDM_OPTIONS_TOOLBAR         1703
00032  #define IDM_OPTIONS_SAVEDDIR        1704
00033  #define IDM_OPTIONS_COLOR           1705
00034  #define IDM_OPTIONS_SAVEONEXIT      1798
00035  #define IDM_OPTIONS_SAVENOW         1799
00036
00037  #define IDM_HELP_CONTENTS           1901
00038  #define IDM_HELP_SEARCH             1902
00039  #define IDM_HELP_HOWTOUSE           1903
00040  #define IDM_HELP_ABOUT              1909
00041
00042  //-- string ids
00043  #define IDS_APPNAME                 2000
00044  #define IDS_SHORT_APPNAME           2001
00045
00046  #define IDS_OFN_TITLE               2010
00047  #define IDS_OFN_FILTERNAME          2011
00048  #define IDS_OFN_FILTER              2012
00049  #define IDS_OFN_DEBUGGEE_TITLE      2013
00050
00051  #define IDS_BUTTON_OPEN             2020
00052  #define IDS_BUTTON_ATTACH           2021
00053  #define IDS_BUTTON_CUT              2022
00054  #define IDS_BUTTON_COPY             2023
00055  #define IDS_BUTTON_DELETE           2024
00056  #define IDS_BUTTON_HELP             2025
00057
00058  #define IDS_EXIT_BOX_TITLE          2030
00059  #define IDS_EXIT_BOX_TEXT           2031
00060
00061  #define IDS_DEBUG_EVENTS            2040
00062
00063  #define IDS_API_FAILED_MSG             9001
00064  #define IDS_WINDOWS_NT_REQUIRED_TITLE  9998
00065  #define IDS_WINDOWS_NT_REQUIRED        9999
00066
00067  //-- control ids
00068  #define IDC_INITIALDIR              9001
00069  #define IDC_PROCESSLIST             9002
00070  #define IDC_DEBUG_ONLY_THIS_PROCESS 9003
00071  #define IDC_DEBUG_PROCESS           9004
00072  #define IDC_IDLE_PRIORITY_CLASS     9005
00073  #define IDC_NORMAL_PRIORITY_CLASS   9006
00074  #define IDC_HIGH_PRIORITY_CLASS     9007
00075  #define IDC_REALTIME_PRIORITY_CLASS 9008
00076  #define IDC_CLEAR_ON_NEW            9009
00077  #define IDC_VERBOSE                 9010
00078  #define IDC_SHOW_SYMBOLS            9011
00079  #define IDC_DEBUG_MODE_NONE         9020
00080  #define IDC_DEBUG_MODE_ERROR        9021
00081  #define IDC_DEBUG_MODE_MINORERROR   9022
00082  #define IDC_DEBUG_MODE_WARNING      9023
00083  #define IDC_SAVE_PREFERENCES        9999
00084
00085 // now defined in winuser.h ... #define IDHELP  9
00086
00087  //-- user messages
00088  #ifndef WM_APP
00089   #define WM_APP 0x8000
00090  #endif
00091  #define UM_CREATE_LISTBOX (WM_APP+0)
00092
00093 #endif // DEB_H
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ISAPI_REQUEST Member List

This is the complete list of members for ISAPI_REQUEST, including all inherited members.
_dwIISMajorVersion | ISAPI_REQUEST | [private]
_dwIISMinorVersion | ISAPI_REQUEST | [private]
_dwMaxSyncWriteSize | ISAPI_REQUEST | [private]
_dwOsMajorVersion | ISAPI_REQUEST | [private, static]
_fClientIsConnected | ISAPI_REQUEST | [private]
_fNeedDoneWithSession | ISAPI_REQUEST | [private]
_HeaderBuffer | ISAPI_REQUEST | [private]
_hImpersonationToken | ISAPI_REQUEST | [private]
_pEcb | ISAPI_REQUEST | [private]
_ResponseBuffer | ISAPI_REQUEST | [private]
_StatusBuffer | ISAPI_REQUEST | [private]
AddDataToResponseBuffer(VOID *pData, DWORD cbData) | ISAPI_REQUEST |
AddHeaderToBufferedResponse(CHAR *szName, CHAR *szValue) | ISAPI_REQUEST |
AsyncSendResponseIIS4(PFN_HSE_IO_COMPLETION pfnCompletion) | ISAPI_REQUEST | [private]
AsyncSendResponseIIS5(PFN_HSE_IO_COMPLETION pfnCompletion) | ISAPI_REQUEST | [private]
AsyncSendResponseIIS6(PFN_HSE_IO_COMPLETION pfcCompletion, BOOL fCacheResponse) | ISAPI_REQUEST | [private]
AsyncTransmitBufferedResponse(PFN_HSE_IO_COMPLETION pfnCompletion, DWORD dwExpireSeconds=NO_EXPIRATION) | ISAPI_REQUEST |
GetServerVariable(CHAR *szVariable, ISAPI_STRING *pIsapiString) | ISAPI_REQUEST |
GetServerVariable(CHAR *szVariable, ISAPI_STRINGW *pIsapiStringW) | ISAPI_REQUEST |
ImpersonateClient(VOID) | ISAPI_REQUEST |
ISAPI_REQUEST(EXTENSION_CONTROL_BLOCK *pEcb) | ISAPI_REQUEST |
PrintfToResponseBuffer(CHAR *szFormat,...) | ISAPI_REQUEST |
QueryEcb(VOID) | ISAPI_REQUEST |
QueryIISMajorVersion(VOID) | ISAPI_REQUEST |
QueryIISMinorVersion(VOID) | ISAPI_REQUEST |
QueryIsClientConnected(VOID) | ISAPI_REQUEST |
QueryMaxResponseBufferSize(VOID) | ISAPI_REQUEST |
QueryMaxSyncWriteSize(VOID) | ISAPI_REQUEST |
QueryOsMajorVersion(VOID) | ISAPI_REQUEST | [private]
ReadAllEntity(ISAPI_BUFFER *pBuffer) | ISAPI_REQUEST |
SetBufferedResponseStatus(CHAR *szStatus) | ISAPI_REQUEST |
SetMaxResponseBufferSize(DWORD dwMaxResponseBufferSize) | ISAPI_REQUEST |
SetMaxSyncWriteSize(DWORD dwMaxSyncWriteSize) | ISAPI_REQUEST |
SyncSendStatusAndHeaders(CHAR *szStatus=NULL, CHAR *szHeaders=NULL) | ISAPI_REQUEST |
SyncWriteClientArgs(CHAR *szFormat, va_list args) | ISAPI_REQUEST |
SyncWriteClientString(CHAR *szFormat,...) | ISAPI_REQUEST |
SyncWriteCompleteResponse(CHAR *szStatus, CHAR *szHeaders, CHAR *szFormat,...) | ISAPI_REQUEST |
UnimpersonateClient(VOID) | ISAPI_REQUEST |
~ISAPI_REQUEST(VOID) | ISAPI_REQUEST | [virtual]
Generated on Wed Nov 13 2024 16:57:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/src/IsapiExtension.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • src

IsapiExtension.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiExtension.cpp
00006
00007 Abstract:
00008
00009     A class to provide basic services to an
00010     ISAPI extension
00011
00012 Author:
00013
00014     ISAPI developer (Microsoft employee), October 2002
00015
00016 --*/
00017
00018 #ifndef _WIN32_WINNT
00019 #define _WIN32_WINNT    0x0500
00020 #endif
00021
00022 #include <IsapiTools.h>
00023
00024 ISAPI_EXTENSION::ISAPI_EXTENSION()
00025     : _fInitialized( FALSE ),
00026       _fFirstHitInitDone( FALSE ),
00027       _pfnInit( NULL )
00028 /*++
00029
00030 Purpose:
00031
00032     Constructor for the ISAPI_EXTENSION object
00033
00034 Arguments:
00035
00036     None
00037
00038 Returns:
00039
00040     None
00041
00042 --*/
00043 {
00044 }
00045
00046 ISAPI_EXTENSION::~ISAPI_EXTENSION()
00047 /*++
00048
00049 Purpose:
00050
00051     Destructor for the ISAPI_EXTENSION object
00052
00053 Arguments:
00054
00055     None
00056
00057 Returns:
00058
00059     None
00060
00061 --*/
00062 {
00063     //
00064     // If we successfully initialized, then we
00065     // need to delete the critical section
00066     //
00067
00068     if ( _fInitialized )
00069     {
00070         DeleteCriticalSection( &_csInit );
00071         _fInitialized = FALSE;
00072     }
00073 }
00074
00075 BOOL
00076 ISAPI_EXTENSION::Initialize(
00077     LPSTR   szModuleName
00078     )
00079 /*++
00080
00081 Purpose:
00082
00083     Initializes the ISAPI_EXTENSION object
00084
00085 Arguments:
00086
00087     szModuleName - The name of the module
00088
00089 Returns:
00090
00091     TRUE on success, FALSE on failure
00092
00093 --*/
00094 {
00095     LPSTR   pCursor;
00096     BOOL    fResult;
00097     DWORD   cchModuleFileName;
00098
00099     //
00100     // Store the module name
00101     //
00102
00103     if ( !_strModuleName.Copy( szModuleName ) )
00104     {
00105         return FALSE;
00106     }
00107
00108     //
00109     // Derive the full path to this module.  We'll assume
00110     // that the full file name for this module does not
00111     // exceed MAX_PATH characters.  If it does, we'll
00112     // detect the condition and fail.
00113     //
00114
00115     if ( !_strModulePath.ResizeBuffer( MAX_PATH+1 ) )
00116     {
00117         return FALSE;
00118     }
00119
00120     cchModuleFileName = GetModuleFileName( GetModuleHandle(szModuleName),
00121                                            _strModulePath.QueryStr(),
00122                                            MAX_PATH );
00123     if ( cchModuleFileName == 0 ||
00124          cchModuleFileName == MAX_PATH )
00125     {
00126         if ( cchModuleFileName == MAX_PATH )
00127         {
00128             SetLastError( ERROR_INSUFFICIENT_BUFFER );
00129         }
00130
00131         return FALSE;
00132     }
00133
00134     _strModulePath.CalcLen();
00135
00136     //
00137     // At this point, _strModulePath contains the full file
00138     // name to this module, including the ".dll".  We'll
00139     // strip off the module name to get the final result.
00140     //
00141
00142     pCursor = strrchr( _strModulePath.QueryStr(), '\\' );
00143
00144     if ( !pCursor )
00145     {
00146         //
00147         // Hmmm.  We really expected a backslash...
00148         //
00149
00150         SetLastError( ERROR_INVALID_PARAMETER );
00151         return FALSE;
00152     }
00153
00154     *pCursor = '\0';
00155
00156     _strModulePath.CalcLen();
00157
00158     //
00159     // Initialize the first hit init critical section.
00160     //
00161     // Note that the InitializeCriticalSection function
00162     // does not necessarily leave the critical section in
00163     // a useable state.  It's possible, in low memory
00164     // conditions, that a call to EnterCriticalSection
00165     // could cause an access violation.  To avoid this
00166     // situation, we'll use InitializeCriticalSectionAndSpinCount,
00167     // which detects this condition and returns FALSE
00168     // if it cannot fully initialize.
00169     //
00170
00171     fResult = InitializeCriticalSectionAndSpinCount( &_csInit,
00172                                                      0 );
00173
00174     if ( fResult )
00175     {
00176         _fInitialized = TRUE;
00177     }
00178
00179     return fResult;
00180 }
00181
00182 BOOL
00183 ISAPI_EXTENSION::InitOnce(
00184     PFN_FIRST_HIT_INIT          pfnInit,
00185     VOID *                      pContext
00186     )
00187 /*++
00188
00189 Purpose:
00190
00191     Performs a guaranteed one-time call of the specified
00192     function.
00193
00194 Arguments:
00195
00196     pfnInit  - The function to call exactly once
00197     pContext - Context to be passed to the specified function
00198
00199 Returns:
00200
00201     TRUE on success, FALSE on failure
00202
00203 --*/
00204 {
00205     BOOL    fResult;
00206
00207     //
00208     // If we are already initialized, just return
00209     // TRUE.
00210     //
00211     // Note that we expect that most calls to this
00212     // function will return here.  It is important
00213     // that we do not enter a critical section on this
00214     // code path, as this would create contention as
00215     // multiple threads enter the ISAPI extension
00216     // concurrently.
00217     //
00218
00219     if ( _fFirstHitInitDone )
00220     {
00221         return TRUE;
00222     }
00223
00224     //
00225     // If we get here, then we need to call the
00226     // initialization function.  This needs to
00227     // happen exactly once, even if multiple threads
00228     // get past the above check.  We'll use a
00229     // critical section to ensure this.
00230     //
00231
00232     EnterCriticalSection( &_csInit );
00233
00234     //
00235     // Now that we're in the critical section, the current
00236     // thread has exclusive access to this code.  We'll
00237     // check to see if we are still uninitialized.  If so,
00238     // we'll call the init function and update the state
00239     // of this object so that other threads that get here
00240     // won't also call it.
00241     //
00242
00243     if ( !_fFirstHitInitDone )
00244     {
00245         fResult = pfnInit( pContext );
00246
00247         if ( fResult )
00248         {
00249             _fFirstHitInitDone = TRUE;
00250         }
00251     }
00252
00253     LeaveCriticalSection( &_csInit );
00254
00255     return fResult;
00256 }
00257
00258
00259 CHAR *
00260 ISAPI_EXTENSION::QueryModulePath(
00261     VOID
00262     )
00263 /*++
00264
00265 Purpose:
00266
00267     Returns the path of the module of the ISAPI_EXTENSION object
00268
00269 Arguments:
00270
00271     None
00272
00273 Returns:
00274
00275     Pointer to the module name
00276
00277 --*/
00278 {
00279     return _strModulePath.QueryStr();
00280 }
00281
00282
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

igmp_hdr_report_v3 Member List

This is the complete list of members for igmp_hdr_report_v3, including all inherited members.
checksum | igmp_hdr_report_v3
num_records | igmp_hdr_report_v3
reserved1 | igmp_hdr_report_v3
reserved2 | igmp_hdr_report_v3
type | igmp_hdr_report_v3
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/AdvReco/EventSinks.h Source File

  • TabletPC
  • AdvReco

EventSinks.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      EventSinks.h
00013 //
00014 // Description:
00015 //      This file contains the definitions of the event sink templates,
00016 //      instantiated in the CAdvRecoApp class.
00017 //
00018 //      The event source interfaces used are:
00019 //      _IInkEvents, _IInkRecognitionEvent, _IInkCollectorEvents
00020 //
00021 //--------------------------------------------------------------------------
00022
00023 #pragma once
00024
00025 // The DISPID's of the events
00026 #ifndef DISPID_CEStroke
00027     #define DISPID_CEStroke                     0x00000001
00028 #endif
00029 #ifndef DISPID_CEGesture
00030     #define DISPID_CEGesture                    0x0000000a
00031 #endif
00032 #ifndef DISPID_RERecognitionWithAlternates
00033     #define DISPID_RERecognitionWithAlternates  0x00000001
00034 #endif
00035
00036 // IDispEventSimpleImpl requires a constant as a sink id; define it here
00037 #define SINK_ID  1
00038
00039 /////////////////////////////////////////////////////////
00040 //
00041 // IInkRecognitionEventsImpl
00042 //
00043 // The template is derived from the ATL's IDispEventSimpleImpl
00044 // to implement a sink for the IInkRecognitionEvents, fired by
00045 // the InkRecoContext object
00046 //
00047 /////////////////////////////////////////////////////////
00048
00049 template <class T>
00050 class ATL_NO_VTABLE IInkRecognitionEventsImpl :
00051   public IDispEventSimpleImpl<SINK_ID, IInkRecognitionEventsImpl<T>,
00052                                 &DIID__IInkRecognitionEvents>
00053 {
00054 public:
00055     // ATL structure with the type information for the event,
00056     // handled in this template. (Initialized in the AdvReco.cpp)
00057     static const _ATL_FUNC_INFO mc_AtlFuncInfo;
00058
00059 BEGIN_SINK_MAP(IInkRecognitionEventsImpl)
00060     SINK_ENTRY_INFO(SINK_ID,
00061                     DIID__IInkRecognitionEvents,
00062                     DISPID_RERecognitionWithAlternates,
00063                     RecognitionWithAlternates,
00064                     const_cast<_ATL_FUNC_INFO*>(&mc_AtlFuncInfo))
00065 END_SINK_MAP()
00066
00067     HRESULT __stdcall RecognitionWithAlternates(IInkRecognitionResult* pIInkRecoResult,
00068                                                 VARIANT vCustomParam,
00069                                                 InkRecognitionStatus RecognitionStatus)
00070     {
00071     T* pT = static_cast<T*>(this);
00072         return pT->OnRecognitionWithAlternates(pIInkRecoResult,
00073                                                vCustomParam,
00074                                                RecognitionStatus);
00075     }
00076 };
00077
00078
00079 /////////////////////////////////////////////////////////
00080 //
00081 // IInkCollectorEventsImpl
00082 //
00083 // The template is derived from the ATL's IDispEventSimpleImpl
00084 // to implement a sink for the IInkCollectorEvents, fired by
00085 // the InkCollector object
00086 // Since the IDispEventSimpleImpl doesn't require to supply
00087 // implementation code for every event, this template has a handler
00088 // for the Gesture event only.
00089 //
00090 /////////////////////////////////////////////////////////
00091
00092 template <class T>
00093 class ATL_NO_VTABLE IInkCollectorEventsImpl :
00094   public IDispEventSimpleImpl<SINK_ID,
00095                                 IInkCollectorEventsImpl<T>,
00096                                 &DIID__IInkCollectorEvents>
00097 {
00098 public:
00099     // ATL structures with the type information for each event,
00100     // handled in this template.(Initialized in the AdvReco.cpp)
00101     static const _ATL_FUNC_INFO mc_AtlFuncInfo[2];
00102
00103 BEGIN_SINK_MAP(IInkCollectorEventsImpl)
00104     SINK_ENTRY_INFO(SINK_ID,
00105                     DIID__IInkCollectorEvents,
00106                     DISPID_CEStroke,
00107                     Stroke,
00108                     const_cast<_ATL_FUNC_INFO*>(&mc_AtlFuncInfo[0]))
00109     SINK_ENTRY_INFO(SINK_ID,
00110                     DIID__IInkCollectorEvents,
00111                     DISPID_CEGesture,
00112                     Gesture,
00113                     const_cast<_ATL_FUNC_INFO*>(&mc_AtlFuncInfo[1]))
00114 END_SINK_MAP()
00115
00116     HRESULT __stdcall Stroke(IInkCursor* pIInkCursor, IInkStrokeDisp* pInkStroke,
00117                              VARIANT_BOOL* pbCancel)
00118     {
00119     T* pT = static_cast<T*>(this);
00120         return pT->OnStroke(pIInkCursor, pInkStroke, pbCancel);
00121     }
00122
00123     HRESULT __stdcall Gesture(IInkCursor* pIInkCursor, IInkStrokes* pInkStrokes,
00124                               VARIANT vGestures, VARIANT_BOOL* pbCancel)
00125     {
00126     T* pT = static_cast<T*>(this);
00127         return pT->OnGesture(pIInkCursor, pInkStrokes, vGestures, pbCancel);
00128     }
00129 };
00130
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/register.cpp Source File

  • WinUI
  • TSFcase

register.cpp

Go to the documentation of this file.
00001 //
00002 // register.cpp
00003 //
00004 // Server registration code.
00005 //
00006
00007 #include <windows.h>
00008 #include <ole2.h>
00009 #include "msctf.h"
00010 #include "globals.h"
00011 #include "case.h"
00012
00013 #define CLSID_STRLEN 38  // strlen("{xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx}")
00014
00015 const struct
00016 {
00017     const GUID *pguidCategory;
00018     const GUID *pguid;
00019 }
00020 c_rgCategories[] =
00021 {
00022     { &GUID_TFCAT_TIP_KEYBOARD, &c_clsidCaseTextService },
00023 };
00024
00025 static const TCHAR c_szInfoKeyPrefix[] = TEXT("CLSID\\");
00026 static const TCHAR c_szInProcSvr32[] = TEXT("InProcServer32");
00027 static const TCHAR c_szModelName[] = TEXT("ThreadingModel");
00028
00029 //+---------------------------------------------------------------------------
00030 //
00031 //  RegisterProfiles
00032 //
00033 //----------------------------------------------------------------------------
00034
00035 BOOL CCaseTextService::RegisterProfiles()
00036 {
00037     ITfInputProcessorProfiles *pInputProcessProfiles;
00038     WCHAR achIconFile[MAX_PATH];
00039     char achFileNameA[MAX_PATH];
00040     DWORD cchA;
00041     int cchIconFile;
00042     HRESULT hr;
00043
00044     hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER,
00045                           IID_ITfInputProcessorProfiles, (void**)&pInputProcessProfiles);
00046
00047     if (hr != S_OK)
00048         return E_FAIL;
00049
00050     hr = pInputProcessProfiles->Register(c_clsidCaseTextService);
00051
00052     if (hr != S_OK)
00053         goto Exit;
00054
00055     cchA = GetModuleFileNameA(g_hInst, achFileNameA, ARRAYSIZE(achFileNameA));
00056
00057     cchIconFile = MultiByteToWideChar(CP_ACP, 0, achFileNameA, cchA, achIconFile, ARRAYSIZE(achIconFile)-1);
00058     achIconFile[cchIconFile] = '\0';
00059
00060     hr = pInputProcessProfiles->AddLanguageProfile(c_clsidCaseTextService,
00061                                   CASE_LANGID,
00062                                   c_guidCaseProfile,
00063                                   CASE_DESC,
00064                                   (ULONG)wcslen(CASE_DESC),
00065                                   achIconFile,
00066                                   cchIconFile,
00067                                   CASE_ICON_INDEX);
00068
00069 Exit:
00070     pInputProcessProfiles->Release();
00071     return (hr == S_OK);
00072 }
00073
00074 //+---------------------------------------------------------------------------
00075 //
00076 //  UnregisterProfiles
00077 //
00078 //----------------------------------------------------------------------------
00079
00080 void CCaseTextService::UnregisterProfiles()
00081 {
00082     ITfInputProcessorProfiles *pInputProcessProfiles;
00083     HRESULT hr;
00084
00085     hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER,
00086                           IID_ITfInputProcessorProfiles, (void**)&pInputProcessProfiles);
00087
00088     if (hr != S_OK)
00089         return;
00090
00091     pInputProcessProfiles->Unregister(c_clsidCaseTextService);
00092     pInputProcessProfiles->Release();
00093 }
00094
00095 //+---------------------------------------------------------------------------
00096 //
00097 //  RegisterCategories
00098 //
00099 //----------------------------------------------------------------------------
00100
00101 BOOL CCaseTextService::RegisterCategories(BOOL fRegister)
00102 {
00103     ITfCategoryMgr *pCategoryMgr;
00104     int i;
00105     HRESULT hr;
00106
00107     hr = CoCreateInstance(CLSID_TF_CategoryMgr, NULL, CLSCTX_INPROC_SERVER,
00108                           IID_ITfCategoryMgr, (void**)&pCategoryMgr);
00109
00110     if (hr != S_OK)
00111         return FALSE;
00112
00113     for (i=0; i<ARRAYSIZE(c_rgCategories); i++)
00114     {
00115         if (fRegister)
00116         {
00117             hr = pCategoryMgr->RegisterCategory(c_clsidCaseTextService,
00118                    *c_rgCategories[i].pguidCategory, *c_rgCategories[i].pguid);
00119         }
00120         else
00121         {
00122             hr = pCategoryMgr->UnregisterCategory(c_clsidCaseTextService,
00123                    *c_rgCategories[i].pguidCategory, *c_rgCategories[i].pguid);
00124         }
00125
00126         if (hr != S_OK)
00127             break;
00128     }
00129
00130     pCategoryMgr->Release();
00131     return (hr == S_OK);
00132 }
00133
00134 //+---------------------------------------------------------------------------
00135 //
00136 // CLSIDToStringA
00137 //
00138 //----------------------------------------------------------------------------
00139
00140 BOOL CLSIDToStringA(REFGUID refGUID, char *pchA)
00141 {
00142     static const BYTE GuidMap[] = {3, 2, 1, 0, '-', 5, 4, '-', 7, 6, '-',
00143                                    8, 9, '-', 10, 11, 12, 13, 14, 15};
00144
00145     static const char szDigits[] = "0123456789ABCDEF";
00146
00147     int i;
00148     char *p = pchA;
00149
00150     const BYTE * pBytes = (const BYTE *) &refGUID;
00151
00152     *p++ = '{';
00153     for (i = 0; i < sizeof(GuidMap); i++)
00154     {
00155         if (GuidMap[i] == '-')
00156         {
00157             *p++ = '-';
00158         }
00159         else
00160         {
00161             *p++ = szDigits[ (pBytes[GuidMap[i]] & 0xF0) >> 4 ];
00162             *p++ = szDigits[ (pBytes[GuidMap[i]] & 0x0F) ];
00163         }
00164     }
00165
00166     *p++ = '}';
00167     *p   = '\0';
00168
00169     return TRUE;
00170 }
00171
00172 //+---------------------------------------------------------------------------
00173 //
00174 // RecurseDeleteKey
00175 //
00176 // RecurseDeleteKey is necessary because on NT RegDeleteKey doesn't work if the
00177 // specified key has subkeys
00178 //----------------------------------------------------------------------------
00179 LONG RecurseDeleteKey(HKEY hParentKey, LPCTSTR lpszKey)
00180 {
00181     HKEY hKey;
00182     LONG lRes;
00183     FILETIME time;
00184     TCHAR szBuffer[256];
00185     DWORD dwSize = ARRAYSIZE(szBuffer);
00186
00187     if (RegOpenKey(hParentKey, lpszKey, &hKey) != ERROR_SUCCESS)
00188         return ERROR_SUCCESS; // let's assume we couldn't open it because it's not there
00189
00190     lRes = ERROR_SUCCESS;
00191     while (RegEnumKeyEx(hKey, 0, szBuffer, &dwSize, NULL, NULL, NULL, &time)==ERROR_SUCCESS)
00192     {
00193         szBuffer[ARRAYSIZE(szBuffer)-1] = '\0';
00194         lRes = RecurseDeleteKey(hKey, szBuffer);
00195         if (lRes != ERROR_SUCCESS)
00196             break;
00197         dwSize = ARRAYSIZE(szBuffer);
00198     }
00199     RegCloseKey(hKey);
00200
00201     return lRes == ERROR_SUCCESS ? RegDeleteKey(hParentKey, lpszKey) : lRes;
00202 }
00203
00204 //+---------------------------------------------------------------------------
00205 //
00206 //  RegisterServer
00207 //
00208 //----------------------------------------------------------------------------
00209
00210 BOOL CCaseTextService::RegisterServer()
00211 {
00212     DWORD dw;
00213     HKEY hKey;
00214     HKEY hSubKey;
00215     BOOL fRet;
00216     TCHAR achIMEKey[ARRAYSIZE(c_szInfoKeyPrefix) + CLSID_STRLEN];
00217     TCHAR achFileName[MAX_PATH];
00218
00219     if (!CLSIDToStringA(c_clsidCaseTextService, achIMEKey + ARRAYSIZE(c_szInfoKeyPrefix) - 1))
00220         return FALSE;
00221     memcpy(achIMEKey, c_szInfoKeyPrefix, sizeof(c_szInfoKeyPrefix)-sizeof(TCHAR));
00222
00223     if (fRet = RegCreateKeyEx(HKEY_CLASSES_ROOT, achIMEKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dw)
00224             == ERROR_SUCCESS)
00225     {
00226         fRet &= RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE *)CASE_DESC_A, (lstrlen(CASE_DESC_A)+1)*sizeof(TCHAR))
00227             == ERROR_SUCCESS;
00228
00229         if (fRet &= RegCreateKeyEx(hKey, c_szInProcSvr32, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hSubKey, &dw)
00230             == ERROR_SUCCESS)
00231         {
00232             dw = GetModuleFileNameA(g_hInst, achFileName, ARRAYSIZE(achFileName));
00233
00234             fRet &= RegSetValueEx(hSubKey, NULL, 0, REG_SZ, (BYTE *)achFileName, (lstrlen(achFileName)+1)*sizeof(TCHAR)) == ERROR_SUCCESS;
00235             fRet &= RegSetValueEx(hSubKey, c_szModelName, 0, REG_SZ, (BYTE *)CASE_MODEL, (lstrlen(CASE_MODEL)+1)*sizeof(TCHAR)) == ERROR_SUCCESS;
00236             RegCloseKey(hSubKey);
00237         }
00238         RegCloseKey(hKey);
00239     }
00240
00241     return fRet;
00242 }
00243
00244 //+---------------------------------------------------------------------------
00245 //
00246 //  UnregisterServer
00247 //
00248 //----------------------------------------------------------------------------
00249
00250 void CCaseTextService::UnregisterServer()
00251 {
00252     TCHAR achIMEKey[ARRAYSIZE(c_szInfoKeyPrefix) + CLSID_STRLEN];
00253
00254     if (!CLSIDToStringA(c_clsidCaseTextService, achIMEKey + ARRAYSIZE(c_szInfoKeyPrefix) - 1))
00255         return;
00256     memcpy(achIMEKey, c_szInfoKeyPrefix, sizeof(c_szInfoKeyPrefix)-sizeof(TCHAR));
00257
00258     RecurseDeleteKey(HKEY_CLASSES_ROOT, achIMEKey);
00259 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_WSARECVMSGARGS Member List

This is the complete list of members for _WSARECVMSGARGS, including all inherited members.
dwNumberOfBytesRecvd | _WSARECVMSGARGS
lpMsg | _WSARECVMSGARGS
s | _WSARECVMSGARGS
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/mark.cpp Source File

  • WinUI
  • TSFmark

mark.cpp

Go to the documentation of this file.
00001 //
00002 // mark.cpp
00003 //
00004 // IUnknown, ITfTextInputProcessor implementation.
00005 //
00006
00007 #include "globals.h"
00008 #include "mark.h"
00009
00010 //+---------------------------------------------------------------------------
00011 //
00012 // CreateInstance
00013 //
00014 //----------------------------------------------------------------------------
00015
00016 /* static */
00017 HRESULT CMarkTextService::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
00018 {
00019     CMarkTextService *pMark;
00020     HRESULT hr;
00021
00022     if (ppvObj == NULL)
00023         return E_INVALIDARG;
00024
00025     *ppvObj = NULL;
00026
00027     if (NULL != pUnkOuter)
00028         return CLASS_E_NOAGGREGATION;
00029
00030     if ((pMark = new CMarkTextService) == NULL)
00031         return E_OUTOFMEMORY;
00032
00033     hr = pMark->QueryInterface(riid, ppvObj);
00034
00035     pMark->Release(); // caller still holds ref if hr == S_OK
00036
00037     return hr;
00038 }
00039
00040 //+---------------------------------------------------------------------------
00041 //
00042 // ctor
00043 //
00044 //----------------------------------------------------------------------------
00045
00046 CMarkTextService::CMarkTextService()
00047 {
00048     DllAddRef();
00049
00050     _pThreadMgr = NULL;
00051     _tfClientId = TF_CLIENTID_NULL;
00052
00053     _pComposition = NULL;
00054
00055     _fCleaningUp = FALSE;
00056
00057     _gaDisplayAttribute = TF_INVALID_GUIDATOM;
00058
00059     _pLangBarItem = NULL;
00060
00061     _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
00062     _dwThreadFocusSinkCookie = TF_INVALID_COOKIE;
00063     _dwTextEditSinkCookie = TF_INVALID_COOKIE;
00064     _dwGlobalCompartmentEventSinkCookie = TF_INVALID_COOKIE;
00065
00066     _pTextEditSinkContext = NULL;
00067
00068     _hWorkerWnd = NULL;
00069
00070     _cRef = 1;
00071 }
00072
00073 //+---------------------------------------------------------------------------
00074 //
00075 // dtor
00076 //
00077 //----------------------------------------------------------------------------
00078
00079 CMarkTextService::~CMarkTextService()
00080 {
00081     DllRelease();
00082 }
00083
00084 //+---------------------------------------------------------------------------
00085 //
00086 // QueryInterface
00087 //
00088 //----------------------------------------------------------------------------
00089
00090 STDAPI CMarkTextService::QueryInterface(REFIID riid, void **ppvObj)
00091 {
00092     if (ppvObj == NULL)
00093         return E_INVALIDARG;
00094
00095     *ppvObj = NULL;
00096
00097     if (IsEqualIID(riid, IID_IUnknown) ||
00098         IsEqualIID(riid, IID_ITfTextInputProcessor))
00099     {
00100         *ppvObj = (ITfTextInputProcessor *)this;
00101     }
00102     else if (IsEqualIID(riid, IID_ITfDisplayAttributeProvider))
00103     {
00104         *ppvObj = (ITfDisplayAttributeProvider *)this;
00105     }
00106     else if (IsEqualIID(riid, IID_ITfCreatePropertyStore))
00107     {
00108         *ppvObj = (ITfCreatePropertyStore *)this;
00109     }
00110     else if (IsEqualIID(riid, IID_ITfThreadMgrEventSink))
00111     {
00112         *ppvObj = (ITfThreadMgrEventSink *)this;
00113     }
00114     else if (IsEqualIID(riid, IID_ITfTextEditSink))
00115     {
00116         *ppvObj = (ITfTextEditSink *)this;
00117     }
00118     else if (IsEqualIID(riid, IID_ITfCleanupContextSink))
00119     {
00120         *ppvObj = (ITfCleanupContextSink *)this;
00121     }
00122     else if (IsEqualIID(riid, IID_ITfCleanupContextDurationSink))
00123     {
00124         *ppvObj = (ITfCleanupContextDurationSink *)this;
00125     }
00126     else if (IsEqualIID(riid, IID_ITfCompartmentEventSink))
00127     {
00128         *ppvObj = (ITfCompartmentEventSink *)this;
00129     }
00130
00131     if (*ppvObj)
00132     {
00133         AddRef();
00134         return S_OK;
00135     }
00136
00137     return E_NOINTERFACE;
00138 }
00139
00140
00141 //+---------------------------------------------------------------------------
00142 //
00143 // AddRef
00144 //
00145 //----------------------------------------------------------------------------
00146
00147 STDAPI_(ULONG) CMarkTextService::AddRef()
00148 {
00149     return ++_cRef;
00150 }
00151
00152 //+---------------------------------------------------------------------------
00153 //
00154 // Release
00155 //
00156 //----------------------------------------------------------------------------
00157
00158 STDAPI_(ULONG) CMarkTextService::Release()
00159 {
00160     LONG cr = --_cRef;
00161
00162     assert(_cRef >= 0);
00163
00164     if (_cRef == 0)
00165     {
00166         delete this;
00167     }
00168
00169     return cr;
00170 }
00171
00172 //+---------------------------------------------------------------------------
00173 //
00174 // Activate
00175 //
00176 //----------------------------------------------------------------------------
00177
00178 STDAPI CMarkTextService::Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId)
00179 {
00180     _pThreadMgr = pThreadMgr;
00181     _pThreadMgr->AddRef();
00182
00183     _tfClientId = tfClientId;
00184
00185     if (!_InitLanguageBar())
00186         goto ExitError;
00187
00188     if (!_InitThreadMgrSink())
00189         goto ExitError;
00190
00191     if (!_InitDisplayAttributeGuidAtom())
00192         goto ExitError;
00193
00194     if (!_InitCleanupContextDurationSink())
00195         goto ExitError;
00196
00197     if (!_InitGlobalCompartment())
00198         goto ExitError;
00199
00200     if (!_InitWorkerWnd())
00201         goto ExitError;
00202
00203     if (!_InitKeystrokeSink())
00204         goto ExitError;
00205
00206     return S_OK;
00207
00208 ExitError:
00209     Deactivate(); // cleanup any half-finished init
00210     return E_FAIL;
00211 }
00212
00213 //+---------------------------------------------------------------------------
00214 //
00215 // Deactivate
00216 //
00217 //----------------------------------------------------------------------------
00218
00219 STDAPI CMarkTextService::Deactivate()
00220 {
00221     _UninitThreadMgrSink();
00222     _UninitLanguageBar();
00223     _UninitCleanupContextDurationSink();
00224     _UninitGlobalCompartment();
00225     _UninitWorkerWnd();
00226     _UninitKeystrokeSink();
00227     _InitTextEditSink(NULL);
00228
00229     // we MUST release all refs to _pThreadMgr in Deactivate
00230     SafeReleaseClear(_pThreadMgr);
00231
00232     _tfClientId = TF_CLIENTID_NULL;
00233
00234     return S_OK;
00235 }
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/resource.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by File Share Sample.rc
00004 //
00005 #define IDD_PP_FILESHARESAMPLE_PARAMETERS      130
00006 #define IDD_WIZ_FILESHARESAMPLE_PARAMETERS     131
00007 #define IDC_PP_ICON                     1000
00008 #define IDC_PP_TITLE                    1001
00009 #define IDC_PP_FILESHARESAMPLE_SHARENAME_LABEL 1010
00010 #define IDC_PP_FILESHARESAMPLE_SHARENAME       1011
00011 #define IDC_PP_FILESHARESAMPLE_PATH_LABEL 1012
00012 #define IDC_PP_FILESHARESAMPLE_PATH       1013
00013 #define IDC_PP_FILESHARESAMPLE_REMARK_LABEL 1014
00014 #define IDC_PP_FILESHARESAMPLE_REMARK       1015
00015 #define IDC_PP_FILESHARESAMPLE_MAXUSERS_LABEL 1016
00016 #define IDC_PP_FILESHARESAMPLE_MAXUSERS       1017
00017 #define IDS_CLUSTER_MENU_ITEM_1             1100
00018 #define IDS_CLUSTER_MENU_ITEM_1_DESC        1101
00019 #define IDS_NODE_MENU_ITEM_1                1110
00020 #define IDS_NODE_MENU_ITEM_1_DESC           1111
00021 #define IDS_GROUP_MENU_ITEM_1               1120
00022 #define IDS_GROUP_MENU_ITEM_1_DESC          1121
00023 #define IDS_RESOURCE_MENU_ITEM_CALL_ISALIVE 1130
00024 #define IDS_RESOURCE_MENU_ITEM_CALL_ISALIVE_DESC  1131
00025 #define IDS_ALLRESOURCES_MENU_ITEM_1        1140
00026 #define IDS_ALLRESOURCES_MENU_ITEM_1_DESC   1141
00027 #define IDS_RESTYPE_MENU_ITEM_1             1150
00028 #define IDS_RESTYPE_MENU_ITEM_1_DESC        1151
00029 #define IDS_ALLRESTYPES_MENU_ITEM_1         1160
00030 #define IDS_ALLRESTYPES_MENU_ITEM_1_DESC    1161
00031 #define IDS_NETWORK_MENU_ITEM_1             1170
00032 #define IDS_NETWORK_MENU_ITEM_1_DESC        1171
00033 #define IDS_NETINTERFACE_MENU_ITEM_1        1180
00034 #define IDS_NETINTERFACE_MENU_ITEM_1_DESC   1181
00035 #define IDS_CLUADMEX_COMOBJ_DESC        31100
00036 #define IDS_ERROR_MSG_ID                31101
00037 #define IDS_REQUIRED_FIELD_EMPTY        31102
00038 #define IDS_ERROR_SETTING_PROPERTIES    31103
00039 #define IDS_ERROR_VALIDATING_PROPERTIES 31104
00040 #define IDS_APPLY_PARAM_CHANGES_ERROR   31200
00041
00042 // Next default values for new objects
00043 //
00044 #ifdef APSTUDIO_INVOKED
00045 #ifndef APSTUDIO_READONLY_SYMBOLS
00046 #define _APS_NEXT_RESOURCE_VALUE        134
00047 #define _APS_NEXT_COMMAND_VALUE         32771
00048 #define _APS_NEXT_CONTROL_VALUE         1200
00049 #define _APS_NEXT_SYMED_VALUE           101
00050 #endif
00051 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Security/VC/VCSecuritySample.Cpp Source File

  • Com
  • Services
  • Security
  • VC

VCSecuritySample.Cpp

Go to the documentation of this file.
00001 // VCSecuritySample.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //    To build a separate proxy/stub DLL,
00006 //    run nmake -f VCSecuritySampleps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include "initguid.h"
00011 #include "VCSecuritySample.h"
00012
00013 #include "VCSecuritySample_i.c"
00014 #include "VCSecuritySampleClass.h"
00015
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP(ObjectMap)
00020   OBJECT_ENTRY(CLSID_VCSecuritySampleClass, CVCSecuritySampleClass)
00021 END_OBJECT_MAP()
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // DLL Entry Point
00025
00026 extern "C"
00027 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00028 {
00029   if (dwReason == DLL_PROCESS_ATTACH)
00030   {
00031     _Module.Init(ObjectMap, hInstance);
00032     DisableThreadLibraryCalls(hInstance);
00033   }
00034   else if (dwReason == DLL_PROCESS_DETACH)
00035     _Module.Term();
00036   return TRUE;    // ok
00037 }
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // Used to determine whether the DLL can be unloaded by OLE
00041
00042 STDAPI DllCanUnloadNow(void)
00043 {
00044   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00045 }
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 // Returns a class factory to create an object of the requested type
00049
00050 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00051 {
00052   return _Module.GetClassObject(rclsid, riid, ppv);
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // DllRegisterServer - Adds entries to the system registry
00057
00058 STDAPI DllRegisterServer(void)
00059 {
00060   // registers object, typelib and all interfaces in typelib
00061   return _Module.RegisterServer(TRUE);
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // DllUnregisterServer - Removes entries from the system registry
00066
00067 STDAPI DllUnregisterServer(void)
00068 {
00069   _Module.UnregisterServer();
00070   return S_OK;
00071 }
00072
00073
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/globals.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

globals.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "BaseNode.h"
00016
00017 //---------------------------------------------------------------------------
00018 // MMC's requiered clipboard formats
00019
00020 CLIPFORMAT g_cfDisplayName = 0;      // DisplayName for our SnapIn node
00021 CLIPFORMAT g_cfNodeType    = 0;      // GUID of the selected node
00022 CLIPFORMAT g_cfszNodeType  = 0;      // String representation of namespace GUID
00023 CLIPFORMAT g_cfSnapinClsid = 0;      // Class ID of this SnapIn
00024
00025 //---------------------------------------------------------------------------
00026 //  Custom clipboard formats
00027
00028 CLIPFORMAT g_cfBaseNodePtr = 0;
00029 CLIPFORMAT g_cfDataObjPtr  = 0;
00030
00031
00032 // Global variables
00033
00034 HINSTANCE g_hInst = NULL;      // Our global instance handle
00035 ULONG g_uObjectCount = 0;      // Global object count
00036 ULONG g_uServerLocks = 0;      // Global lock count
00037
00038
00039 //---------------------------------------------------------------------------
00040 //  This is the fast, simple way to convert unicode to ansi.  It does NOT
00041 //  handle multibyte ansi strings and is not localized.  But it should be
00042 //  fine for registry entries
00043 //  NOTE:  The caller is responsible for freeing the memory.
00044 //
00045 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide )
00046 {
00047   SIZE_T nLen = wcslen( szWide ) +1;
00048   *pszAnsi = (char*)CoTaskMemAlloc( nLen );
00049   char* pCounter = *pszAnsi;
00050
00051   while( *szWide )
00052   {
00053     *pCounter = LOBYTE(*szWide);
00054     pCounter++;
00055     szWide++;
00056   }
00057   *pCounter = NULL;
00058 }
00059
00060 void _fastcall Ansi2Unicode( CHAR* pszAnsi, WCHAR** ppszWide )
00061 {
00062   SIZE_T ulSize = strlen( pszAnsi ) +1;
00063   *ppszWide = (WCHAR*)CoTaskMemAlloc( ulSize * sizeof(WCHAR) );
00064   MultiByteToWideChar( CP_ACP, 0, pszAnsi, ulSize, *ppszWide, ulSize );
00065 }
00066
00067
00068 void _fastcall CopyBuffer( WCHAR* szAnsi, WCHAR** ppszWide )
00069 {
00070   SIZE_T ulSize = wcslen( szAnsi ) +1;
00071   *ppszWide = (WCHAR*)CoTaskMemAlloc( ulSize * sizeof(WCHAR) );
00072   wcscpy( *ppszWide, szAnsi );
00073 }
00074
00075
00076 //---------------------------------------------------------------------------
00077 //  copies a string ( like strncpy )
00078 //  in non-unicode version coverts ansi-to-unicode first.
00079 //
00080 void _fastcall CopyT2W( LPWSTR strDest, LPCTSTR strSource, size_t count)
00081 {
00082 #ifndef _UNICODE
00083
00084   MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, strSource, -1, strDest, count );
00085
00086 #else
00087
00088   wcsncpy( strDest, strSource, count );
00089
00090 #endif
00091
00092   if ( count > 0 )
00093     strDest[ count - 1 ] = 0;
00094 }
00095
00096 //---------------------------------------------------------------------------
00097 //
00098 void InitClipboardFormats()
00099 {
00100   g_cfDisplayName  = (CLIPFORMAT)RegisterClipboardFormat( T_CCF_DISPLAY_NAME );
00101   g_cfNodeType     = (CLIPFORMAT)RegisterClipboardFormat( T_CCF_NODETYPE );
00102   g_cfszNodeType   = (CLIPFORMAT)RegisterClipboardFormat( T_CCF_SZNODETYPE );
00103   g_cfSnapinClsid  = (CLIPFORMAT)RegisterClipboardFormat( T_CCF_SNAPIN_CLASSID );
00104
00105   g_cfBaseNodePtr  = (CLIPFORMAT)RegisterClipboardFormat( T_CCF_BASENODE_PTR );
00106   g_cfDataObjPtr   = (CLIPFORMAT)RegisterClipboardFormat( T_CCF_DATAOBJ_PTR );
00107
00108 }
00109
00110 //---------------------------------------------------------------------------
00111 //  Extracts data based on the passed-in clipboard format
00112 //
00113 HRESULT ExtractFromDataObject
00114 (
00115   LPDATAOBJECT ipDataObject,   // [in]  Points to data object
00116   CLIPFORMAT   cfClipFormat,   // [in]  Clipboard format to use
00117   ULONG        nByteCount,     // [in]  Number of bytes to allocate
00118   HGLOBAL      *phGlobal       // [out] Points to the data we want
00119 )
00120 {
00121   _ASSERT( NULL != ipDataObject );
00122
00123             *phGlobal = NULL;
00124   HRESULT   hResult   = S_FALSE;
00125   STGMEDIUM StgMedium = { TYMED_HGLOBAL,  NULL  };
00126   FORMATETC FormatEtc = { cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00127
00128   do
00129   {
00130     // Allocate memory for the stream
00131     StgMedium.hGlobal = ::GlobalAlloc( GMEM_SHARE, nByteCount );
00132
00133     if( NULL == StgMedium.hGlobal )
00134     {
00135       hResult = E_OUTOFMEMORY;
00136       break;
00137     }
00138
00139     // Attempt to get data from the object
00140     hResult = ipDataObject->GetDataHere( &FormatEtc, &StgMedium );
00141     if( FAILED(hResult) )
00142     {
00143       break;
00144     }
00145     // StgMedium now has the data we need
00146     *phGlobal = StgMedium.hGlobal;
00147     StgMedium.hGlobal = NULL;
00148
00149   } while (0);
00150
00151   if( FAILED(hResult) && StgMedium.hGlobal )
00152   {
00153     HGLOBAL hRetVal = ::GlobalFree(StgMedium.hGlobal);
00154     _ASSERT( NULL == hRetVal );         // Must return NULL
00155   }
00156   return hResult;
00157
00158 }
00159
00160
00161 //---------------------------------------------------------------------------
00162 //  This helper returns the current BaseNode object on the custom
00163 //  g_cfBaseNodePtr clipboard format
00164 //
00165 CBaseNode* ExtractBaseNodePtr
00166 (
00167   LPDATAOBJECT ipDataObject      // [in] IComponent pointer
00168 )
00169 {
00170   LPBASENODE  pNode   = NULL;
00171   HGLOBAL     hGlobal = NULL;
00172   HRESULT     hResult = S_FALSE;
00173
00174   hResult = ExtractFromDataObject( ipDataObject,
00175                                    g_cfBaseNodePtr,
00176                                    sizeof(LPBASENODE),
00177                                    &hGlobal
00178                                  );
00179   if( SUCCEEDED(hResult) )
00180   {
00181     pNode = *(LPBASENODE*)(hGlobal);
00182     HGLOBAL hRetVal = GlobalFree(hGlobal);
00183     _ASSERT( NULL == hRetVal );        // Must return NULL
00184   }
00185
00186   return pNode;
00187
00188 }
00189
00190 //---------------------------------------------------------------------------
00191 //  Converts an IDataObject pointer to a CDataObject pointer by
00192 //  retrieving a "this" pointer using a custom clipboard format.
00193 //
00194 CDataObject* ExtractDataObjPtr
00195 (
00196   LPDATAOBJECT ipDataObject      //[in] IDataObject pointer
00197 )
00198 {
00199   _ASSERT( 0 != g_cfDataObjPtr );
00200
00201   HGLOBAL      hGlobal = NULL;
00202   HRESULT      hResult = S_OK;
00203   CDataObject* pDO     = NULL;
00204
00205   hResult = ExtractFromDataObject( ipDataObject,
00206                                    g_cfDataObjPtr,
00207                                    sizeof(CDataObject **),
00208                                    &hGlobal
00209                                  );
00210
00211   if( SUCCEEDED(hResult) )
00212   {
00213     pDO = *(CDataObject **)(hGlobal);
00214     _ASSERT( NULL != pDO );
00215
00216     HGLOBAL hRetVal = GlobalFree(hGlobal);
00217     _ASSERT( NULL == hRetVal );       // Must return NULL
00218   }
00219
00220   return pDO;
00221
00222 }
00223
00224 //---------------------------------------------------------------------------
00225 //  MMC_HELP:  This is where we get the path to the Snap-in's help
00226 //  file.  In this sample we are assuming the help file is in the
00227 //  same directory at the Snap-in.  This is the recommended procedure
00228 //  for Snap-ins
00229 //
00230 LPOLESTR GetHelpFilePath()
00231 {
00232   // First we need a temp buffer
00233   DWORD  dwTempSize = (MAX_PATH) * sizeof(TCHAR);
00234   LPTSTR pszTempPath = (LPTSTR)CoTaskMemAlloc( dwTempSize );
00235
00236   // Get the path to the help file in TCHAR
00237   GetModuleFileName( g_hInst, pszTempPath, dwTempSize );
00238   PathRemoveFileSpec( pszTempPath );
00239   _tcscat( pszTempPath, _T("\\Ppage.chm") );
00240
00241   // Convert to wide string if we're on Win9X, copy to buffer on NT
00242   LPOLESTR pszHelpPath = NULL;
00243   T2W( pszTempPath, &pszHelpPath );
00244
00245   CoTaskMemFree( pszTempPath );
00246
00247   return pszHelpPath;
00248 }
00249
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ColPropsList Member List

This is the complete list of members for ColPropsList, including all inherited members.
id | ColPropsList
ncols | ColPropsList
plist | ColPropsList
startcol | ColPropsList
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHello Member List

This is the complete list of members for CHello, including all inherited members.
AddRef() | CHello |
CHello() | CHello | [inline]
HelloProc(unsigned char *pszString) | CHello |
m_cRef | CHello | [private]
QueryInterface(REFIID iid, void **ppv) | CHello |
Release() | CHello |
~CHello() | CHello | [inline, private]
Generated on Wed Nov 13 2024 16:56:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/wiassamp/wiassamp.cpp Source File

  • Multimedia
  • wia
  • wiassamp

wiassamp.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  *  (C) COPYRIGHT MICROSOFT CORPORATION
00004  *
00005  *  TITLE:       WIASSAMP.CPP
00006  *
00007  *  VERSION:     1.0
00008  *
00009  *  AUTHOR:      ShaunIv
00010  *
00011  *  DATE:        4/3/2002
00012  *
00013  *  DESCRIPTION: Simple command line program which demonstrates the following
00014  *               WIA procedures:
00015  *
00016  *               o  Enumerating devices
00017  *               o  Reading properties
00018  *               o  Setting properties
00019  *               o  Enumerating items
00020  *               o  Transferring items to a file
00021  *
00022  *******************************************************************************/
00023 #include <windows.h>
00024 #include <objbase.h>
00025 #include <stdio.h>
00026 #include <tchar.h>
00027 #include <wia.h>
00028
00029 //
00030 // Helper function to display an error message and an optional HRESULT
00031 //
00032 void ReportError( LPCTSTR pszMessage, HRESULT hr = S_OK )
00033 {
00034     if (S_OK != hr)
00035     {
00036         _tprintf( TEXT("%s: HRESULT: 0x%08X\n"), pszMessage, hr );
00037     }
00038     else
00039     {
00040         _tprintf( TEXT("%s\n"), pszMessage );
00041     }
00042 }
00043
00044 class CWiaDataCallback : public IWiaDataCallback
00045 {
00046 private:
00047     //
00048     // Reference count
00049     //
00050     LONG m_cRef;
00051
00052 private:
00053     //
00054     // No implementation
00055     //
00056     CWiaDataCallback( const CWiaDataCallback & );
00057     CWiaDataCallback &operator=( const CWiaDataCallback & );
00058
00059 public:
00060     //
00061     // Constructor and destructor
00062     //
00063     CWiaDataCallback()
00064         : m_cRef(1)
00065     {
00066     }
00067     virtual ~CWiaDataCallback()
00068     {
00069     }
00070
00071     //
00072     // IUnknown functions
00073     //
00074     HRESULT CALLBACK QueryInterface( REFIID riid, void **ppvObject )
00075     {
00076         //
00077         // Validate arguments
00078         //
00079         if (NULL == ppvObject)
00080         {
00081             return E_INVALIDARG;
00082         }
00083
00084         //
00085         // Return the appropropriate interface
00086         //
00087         if (IsEqualIID( riid, IID_IUnknown ))
00088         {
00089             *ppvObject = static_cast<CWiaDataCallback*>(this);
00090         }
00091         else if (IsEqualIID( riid, IID_IWiaDataCallback ))
00092         {
00093             *ppvObject = static_cast<CWiaDataCallback*>(this);
00094         }
00095         else
00096         {
00097             *ppvObject = NULL;
00098             return (E_NOINTERFACE);
00099         }
00100
00101         //
00102         // Increment the reference count before we return the interface
00103         //
00104         reinterpret_cast<IUnknown*>(*ppvObject)->AddRef();
00105         return S_OK;
00106     }
00107     ULONG CALLBACK AddRef()
00108     {
00109         return InterlockedIncrement(&m_cRef);
00110     }
00111     ULONG CALLBACK Release()
00112     {
00113         LONG cRef = InterlockedDecrement(&m_cRef);
00114         if (0 == cRef)
00115         {
00116             delete this;
00117         }
00118         return cRef;
00119     }
00120
00121     //
00122     // IWiaDataCallback functions
00123     //
00124     HRESULT CALLBACK BandedDataCallback(
00125         LONG lMessage,
00126         LONG lStatus,
00127         LONG lPercentComplete,
00128         LONG lOffset,
00129         LONG lLength,
00130         LONG lReserved,
00131         LONG lResLength,
00132         BYTE *pbBuffer )
00133     {
00134         UNREFERENCED_PARAMETER(lMessage);
00135         UNREFERENCED_PARAMETER(lStatus);
00136         UNREFERENCED_PARAMETER(lPercentComplete);
00137         UNREFERENCED_PARAMETER(lOffset);
00138         UNREFERENCED_PARAMETER(lLength);
00139         UNREFERENCED_PARAMETER(lReserved);
00140         UNREFERENCED_PARAMETER(lResLength);
00141         UNREFERENCED_PARAMETER(pbBuffer);
00142         switch (lMessage)
00143         {
00144         case IT_MSG_STATUS:
00145             _tprintf( TEXT("lPercentComplete: %d\n"), lPercentComplete );
00146             break;
00147         }
00148
00149         return S_OK;
00150     }
00151 };
00152
00153 HRESULT TransferWiaItem( IWiaItem *pWiaItem )
00154 {
00155     //
00156     // Validate arguments
00157     //
00158     if (NULL == pWiaItem)
00159     {
00160         return E_INVALIDARG;
00161     }
00162
00163     //
00164     // Get the IWiaPropertyStorage interface so we can set required properties
00165     //
00166     IWiaPropertyStorage *pWiaPropertyStorage = NULL;
00167     HRESULT hr = pWiaItem->QueryInterface( IID_IWiaPropertyStorage, (void**)&pWiaPropertyStorage );
00168     if (SUCCEEDED(hr))
00169     {
00170         //
00171         // Prepare PROPSPECs and PROPVARIANTs for setting the
00172         // media type and format
00173         //
00174         PROPSPEC PropSpec[2] = {0};
00175         PROPVARIANT PropVariant[2] = {0};
00176         const ULONG c_nPropCount = sizeof(PropVariant)/sizeof(PropVariant[0]);
00177
00178         //
00179         // Use BMP as the output format
00180         //
00181         GUID guidOutputFormat = WiaImgFmt_BMP;
00182
00183         //
00184         // Initialize the PROPSPECs
00185         //
00186         PropSpec[0].ulKind = PRSPEC_PROPID;
00187         PropSpec[0].propid = WIA_IPA_FORMAT;
00188         PropSpec[1].ulKind = PRSPEC_PROPID;
00189         PropSpec[1].propid = WIA_IPA_TYMED;
00190
00191         //
00192         // Initialize the PROPVARIANTs
00193         //
00194         PropVariant[0].vt = VT_CLSID;
00195         PropVariant[0].puuid = &guidOutputFormat;
00196         PropVariant[1].vt = VT_I4;
00197         PropVariant[1].lVal = TYMED_FILE;
00198
00199         //
00200         // Set the properties
00201         //
00202         hr = pWiaPropertyStorage->WriteMultiple( c_nPropCount, PropSpec, PropVariant, WIA_IPA_FIRST );
00203         if (SUCCEEDED(hr))
00204         {
00205             //
00206             // Get the IWiaDataTransfer interface
00207             //
00208             IWiaDataTransfer *pWiaDataTransfer = NULL;
00209             hr = pWiaItem->QueryInterface( IID_IWiaDataTransfer, (void**)&pWiaDataTransfer );
00210             if (SUCCEEDED(hr))
00211             {
00212                 //
00213                 // Create our callback class
00214                 //
00215                 CWiaDataCallback *pCallback = new CWiaDataCallback;
00216                 if (pCallback)
00217                 {
00218                     //
00219                     // Get the IWiaDataCallback interface from our callback class.
00220                     //
00221                     IWiaDataCallback *pWiaDataCallback = NULL;
00222                     hr = pCallback->QueryInterface( IID_IWiaDataCallback, (void**)&pWiaDataCallback );
00223                     if (SUCCEEDED(hr))
00224                     {
00225                         //
00226                         // Perform the transfer using default settings
00227                         //
00228                         STGMEDIUM stgMedium = {0};
00229                         hr = pWiaDataTransfer->idtGetData( &stgMedium, pWiaDataCallback );
00230                         if (S_OK == hr)
00231                         {
00232                             //
00233                             // Print the filename (note that this filename is always
00234                             // a WCHAR string, not TCHAR.
00235                             //
00236                             _tprintf( TEXT("Transferred filename: %ws\n"), stgMedium.lpszFileName );
00237
00238                             //
00239                             // Release any memory associated with the stgmedium
00240                             //
00241                             ReleaseStgMedium( &stgMedium );
00242                         }
00243                         else
00244                         {
00245                             ReportError( TEXT("pWiaDataTransfer->idtGetData failed"), hr );
00246                         }
00247
00248                         //
00249                         // Release the callback interface
00250                         //
00251                         pWiaDataCallback->Release();
00252                         pWiaDataCallback = NULL;
00253                     }
00254                     else
00255                     {
00256                         ReportError( TEXT("pCallback->QueryInterface failed on IID_IWiaDataCallback"), hr );
00257                     }
00258
00259                     //
00260                     // Release our callback.  It should now delete itself.
00261                     //
00262                     pCallback->Release();
00263                     pCallback = NULL;
00264                 }
00265                 else
00266                 {
00267                     ReportError( TEXT("Unable to create CWiaDataCallback class instance") );
00268                 }
00269
00270                 //
00271                 // Release the IWiaDataTransfer
00272                 //
00273                 pWiaDataTransfer->Release();
00274                 pWiaDataTransfer = NULL;
00275             }
00276             else
00277             {
00278                 ReportError( TEXT("pWiaItem->QueryInterface failed on IID_IWiaDataTransfer"), hr );
00279             }
00280         }
00281
00282         //
00283         // Release the IWiaPropertyStorage
00284         //
00285         pWiaPropertyStorage->Release();
00286         pWiaPropertyStorage = NULL;
00287     }
00288     else
00289     {
00290         ReportError( TEXT("pWiaItem->QueryInterface failed on IID_IWiaPropertyStorage"), hr );
00291     }
00292
00293     return hr;
00294 }
00295
00296 HRESULT PrintItemName( IWiaItem *pWiaItem )
00297 {
00298     //
00299     // Validate arguments
00300     //
00301     if (NULL == pWiaItem)
00302     {
00303         return E_INVALIDARG;
00304     }
00305
00306     //
00307     // Get the IWiaPropertyStorage interface
00308     //
00309     IWiaPropertyStorage *pWiaPropertyStorage = NULL;
00310     HRESULT hr = pWiaItem->QueryInterface( IID_IWiaPropertyStorage, (void**)&pWiaPropertyStorage );
00311     if (SUCCEEDED(hr))
00312     {
00313         //
00314         // Declare PROPSPECs and PROPVARIANTs, and initialize them to zero.
00315         //
00316         PROPSPEC PropSpec[1] = {0};
00317         PROPVARIANT PropVar[1] = {0};
00318
00319         //
00320         // How many properties are we querying for?
00321         //
00322         const ULONG c_nPropertyCount = sizeof(PropSpec)/sizeof(PropSpec[0]);
00323
00324         //
00325         // Define which properties we want to read:
00326         // Device ID.  This is what we'd use to create
00327         // the device.
00328         //
00329         PropSpec[0].ulKind = PRSPEC_PROPID;
00330         PropSpec[0].propid = WIA_IPA_FULL_ITEM_NAME;
00331
00332         //
00333         // Ask for the property values
00334         //
00335         hr = pWiaPropertyStorage->ReadMultiple( c_nPropertyCount, PropSpec, PropVar );
00336         if (SUCCEEDED(hr))
00337         {
00338             //
00339             // IWiaPropertyStorage::ReadMultiple will return S_FALSE if some
00340             // properties could not be read, so we have to check the return
00341             // types for each requested item.
00342             //
00343
00344             //
00345             // Check the return type for the device ID
00346             //
00347             if (VT_BSTR == PropVar[0].vt)
00348             {
00349                 //
00350                 // Do something with the device ID
00351                 //
00352                 _tprintf( TEXT("Item Name: %ws\n"), PropVar[0].bstrVal );
00353             }
00354
00355             //
00356             // Free the returned PROPVARIANTs
00357             //
00358             FreePropVariantArray( c_nPropertyCount, PropVar );
00359         }
00360         else
00361         {
00362             ReportError( TEXT("Error calling IWiaPropertyStorage::ReadMultiple"), hr );
00363         }
00364
00365         //
00366         // Release the IWiaPropertyStorage interface
00367         //
00368         pWiaPropertyStorage->Release();
00369         pWiaPropertyStorage = NULL;
00370     }
00371
00372     //
00373     // Return the result of reading the properties
00374     //
00375     return hr;
00376 }
00377
00378 HRESULT CreateWiaDevice( IWiaDevMgr *pWiaDevMgr, BSTR bstrDeviceID, IWiaItem **ppWiaDevice )
00379 {
00380     //
00381     // Validate arguments
00382     //
00383     if (NULL == pWiaDevMgr || NULL == bstrDeviceID || NULL == ppWiaDevice)
00384     {
00385         return E_INVALIDARG;
00386     }
00387
00388     //
00389     // Initialize out variables
00390     //
00391     *ppWiaDevice = NULL;
00392
00393     //
00394     // Create the WIA Device
00395     //
00396     HRESULT hr = pWiaDevMgr->CreateDevice( bstrDeviceID, ppWiaDevice );
00397     if (FAILED(hr))
00398     {
00399         ReportError( TEXT("Error calling IWiaDevMgr::CreateDevice"), hr );
00400     }
00401
00402     //
00403     // Return the result of creating the device
00404     //
00405     return hr;
00406 }
00407
00408 HRESULT CreateWiaDeviceManager( IWiaDevMgr **ppWiaDevMgr )
00409 {
00410     //
00411     // Validate arguments
00412     //
00413     if (NULL == ppWiaDevMgr)
00414     {
00415         return E_INVALIDARG;
00416     }
00417
00418     //
00419     // Initialize out variables
00420     //
00421     *ppWiaDevMgr = NULL;
00422
00423     //
00424     // Create an instance of the device manager
00425     //
00426     HRESULT hr = CoCreateInstance( CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER, IID_IWiaDevMgr, (void**)ppWiaDevMgr );
00427     if (FAILED(hr))
00428     {
00429         ReportError( TEXT("CoCreateInstance failed on CLSID_WiaDevMgr"), hr );
00430     }
00431
00432     //
00433     // Return the result of creating the device manager
00434     //
00435     return hr;
00436 }
00437
00438 HRESULT ReadSomeWiaProperties( IWiaPropertyStorage *pWiaPropertyStorage )
00439 {
00440     //
00441     // Validate arguments
00442     //
00443     if (NULL == pWiaPropertyStorage)
00444     {
00445         return E_INVALIDARG;
00446     }
00447
00448     //
00449     // Declare PROPSPECs and PROPVARIANTs, and initialize them to zero.
00450     //
00451     PROPSPEC PropSpec[3] = {0};
00452     PROPVARIANT PropVar[3] = {0};
00453
00454     //
00455     // How many properties are we querying for?
00456     //
00457     const ULONG c_nPropertyCount = sizeof(PropSpec)/sizeof(PropSpec[0]);
00458
00459     //
00460     // Define which properties we want to read:
00461     // Device ID.  This is what we'd use to create
00462     // the device.
00463     //
00464     PropSpec[0].ulKind = PRSPEC_PROPID;
00465     PropSpec[0].propid = WIA_DIP_DEV_ID;
00466
00467     //
00468     // Device Name
00469     //
00470     PropSpec[1].ulKind = PRSPEC_PROPID;
00471     PropSpec[1].propid = WIA_DIP_DEV_NAME;
00472
00473     //
00474     // Device description
00475     //
00476     PropSpec[2].ulKind = PRSPEC_PROPID;
00477     PropSpec[2].propid = WIA_DIP_DEV_DESC;
00478
00479     //
00480     // Ask for the property values
00481     //
00482     HRESULT hr = pWiaPropertyStorage->ReadMultiple( c_nPropertyCount, PropSpec, PropVar );
00483     if (SUCCEEDED(hr))
00484     {
00485         //
00486         // IWiaPropertyStorage::ReadMultiple will return S_FALSE if some
00487         // properties could not be read, so we have to check the return
00488         // types for each requested item.
00489         //
00490
00491         //
00492         // Check the return type for the device ID
00493         //
00494         if (VT_BSTR == PropVar[0].vt)
00495         {
00496             //
00497             // Do something with the device ID
00498             //
00499             _tprintf( TEXT("WIA_DIP_DEV_ID: %ws\n"), PropVar[0].bstrVal );
00500         }
00501
00502         //
00503         // Check the return type for the device name
00504         //
00505         if (VT_BSTR == PropVar[1].vt)
00506         {
00507             //
00508             // Do something with the device name
00509             //
00510             _tprintf( TEXT("WIA_DIP_DEV_NAME: %ws\n"), PropVar[1].bstrVal );
00511         }
00512
00513         //
00514         // Check the return type for the device description
00515         //
00516         if (VT_BSTR == PropVar[2].vt)
00517         {
00518             //
00519             // Do something with the device description
00520             //
00521             _tprintf( TEXT("WIA_DIP_DEV_DESC: %ws\n"), PropVar[2].bstrVal );
00522         }
00523
00524         //
00525         // Free the returned PROPVARIANTs
00526         //
00527         FreePropVariantArray( c_nPropertyCount, PropVar );
00528     }
00529     else
00530     {
00531         ReportError( TEXT("Error calling IWiaPropertyStorage::ReadMultiple"), hr );
00532     }
00533
00534     //
00535     // Return the result of reading the properties
00536     //
00537     return hr;
00538 }
00539
00540 HRESULT EnumerateItems( IWiaItem *pWiaItem )
00541 {
00542     //
00543     // Validate arguments
00544     //
00545     if (NULL == pWiaItem)
00546     {
00547         return E_INVALIDARG;
00548     }
00549
00550     //
00551     // Get the item type for this item
00552     //
00553     LONG lItemType = 0;
00554     HRESULT hr = pWiaItem->GetItemType( &lItemType );
00555
00556     //
00557     // Do something with this item.  Print the item name.
00558     //
00559     PrintItemName( pWiaItem );
00560
00561     //
00562     // If this is an image, transfer it
00563     //
00564     if (lItemType & WiaItemTypeImage)
00565     {
00566         hr = TransferWiaItem( pWiaItem );
00567     }
00568
00569     //
00570     // If it is a folder, or it has attachments, enumerate its children
00571     //
00572     if (lItemType & WiaItemTypeFolder ||
00573         lItemType & WiaItemTypeHasAttachments)
00574     {
00575         //
00576         // Get the child item enumerator for this item
00577         //
00578         IEnumWiaItem *pEnumWiaItem = NULL;
00579         hr = pWiaItem->EnumChildItems( &pEnumWiaItem );
00580         if (SUCCEEDED(hr))
00581         {
00582             //
00583             // We will loop until we get an error or pEnumWiaItem->Next returns
00584             // S_FALSE to signal the end of the list.
00585             //
00586             while (S_OK == hr)
00587             {
00588                 //
00589                 // Get the next child item
00590                 //
00591                 IWiaItem *pChildWiaItem = NULL;
00592                 hr = pEnumWiaItem->Next( 1, &pChildWiaItem, NULL );
00593
00594                 //
00595                 // pEnumWiaItem->Next will return S_FALSE when the list is
00596                 // exhausted, so check for S_OK before using the returned
00597                 // value.
00598                 //
00599                 if (S_OK == hr)
00600                 {
00601                     //
00602                     // Recurse into this item
00603                     //
00604                     hr = EnumerateItems( pChildWiaItem );
00605
00606                     //
00607                     // Release this item
00608                     //
00609                     pChildWiaItem->Release();
00610                     pChildWiaItem = NULL;
00611                 }
00612                 else if (FAILED(hr))
00613                 {
00614                     //
00615                     // Report that an error occurred during enumeration
00616                     //
00617                     ReportError( TEXT("Error calling pEnumWiaItem->Next"), hr );
00618                 }
00619             }
00620
00621             //
00622             // If the result of the enumeration is S_FALSE, since this
00623             // is normal, we will change it to S_OK
00624             //
00625             if (S_FALSE == hr)
00626             {
00627                 hr = S_OK;
00628             }
00629
00630             //
00631             // Release the enumerator
00632             //
00633             pEnumWiaItem->Release();
00634             pEnumWiaItem = NULL;
00635         }
00636     }
00637     return  hr;
00638 }
00639
00640 HRESULT CreateWiaDeviceAndDoSomeStuff( IWiaDevMgr *pWiaDevMgr, IWiaPropertyStorage *pWiaPropertyStorage )
00641 {
00642     //
00643     // Validate arguments
00644     //
00645     if (NULL == pWiaPropertyStorage)
00646     {
00647         return E_INVALIDARG;
00648     }
00649
00650     //
00651     // Declare PROPSPECs and PROPVARIANTs, and initialize them to zero.
00652     //
00653     PROPSPEC PropSpec[1] = {0};
00654     PROPVARIANT PropVar[1] = {0};
00655
00656     //
00657     // How many properties are we querying for?
00658     //
00659     const ULONG c_nPropertyCount = sizeof(PropSpec)/sizeof(PropSpec[0]);
00660
00661     //
00662     // Define which properties we want to read.  We want the
00663     // device ID, so we can create the device.
00664     //
00665     PropSpec[0].ulKind = PRSPEC_PROPID;
00666     PropSpec[0].propid = WIA_DIP_DEV_ID;
00667
00668     //
00669     // Ask for the property values
00670     //
00671     HRESULT hr = pWiaPropertyStorage->ReadMultiple( c_nPropertyCount, PropSpec, PropVar );
00672     if (SUCCEEDED(hr))
00673     {
00674         //
00675         // Check the return type for the device ID to make
00676         // sure this property was actually read.
00677         //
00678         if (VT_BSTR == PropVar[0].vt)
00679         {
00680             //
00681             // Create the WIA device, which results in obtaining
00682             // the root IWiaItem
00683             //
00684             IWiaItem *pWiaRootItem = NULL;
00685             hr = CreateWiaDevice( pWiaDevMgr, PropVar[0].bstrVal, &pWiaRootItem );
00686             if (SUCCEEDED(hr))
00687             {
00688                 //
00689                 // Recursively enumerate the items
00690                 // (This function will also do some stuff with each item)
00691                 //
00692                 hr = EnumerateItems( pWiaRootItem );
00693
00694                 //
00695                 // Free the root item
00696                 //
00697                 pWiaRootItem->Release();
00698                 pWiaRootItem = NULL;
00699             }
00700             else
00701             {
00702                 ReportError( TEXT("Error calling CreateWiaDevice"), hr );
00703             }
00704         }
00705
00706         //
00707         // Free the returned PROPVARIANTs
00708         //
00709         FreePropVariantArray( c_nPropertyCount, PropVar );
00710     }
00711     else
00712     {
00713         ReportError( TEXT("Error calling IWiaPropertyStorage::ReadMultiple"), hr );
00714     }
00715
00716     //
00717     // Return the result of all of this
00718     //
00719     return hr;
00720 }
00721
00722 HRESULT EnumerateWiaDevices( IWiaDevMgr *pWiaDevMgr )
00723 {
00724     //
00725     // Validate arguments
00726     //
00727     if (NULL == pWiaDevMgr)
00728     {
00729         return E_INVALIDARG;
00730     }
00731
00732     //
00733     // Get a device enumerator interface
00734     //
00735     IEnumWIA_DEV_INFO *pWiaEnumDevInfo = NULL;
00736     HRESULT hr = pWiaDevMgr->EnumDeviceInfo( WIA_DEVINFO_ENUM_LOCAL, &pWiaEnumDevInfo );
00737     if (SUCCEEDED(hr))
00738     {
00739         //
00740         // Reset the device enumerator to the beginning of the list
00741         //
00742         hr = pWiaEnumDevInfo->Reset();
00743         if (SUCCEEDED(hr))
00744         {
00745             //
00746             // We will loop until we get an error or pWiaEnumDevInfo->Next returns
00747             // S_FALSE to signal the end of the list.
00748             //
00749             while (S_OK == hr)
00750             {
00751                 //
00752                 // Get the next device's property storage interface pointer
00753                 //
00754                 IWiaPropertyStorage *pWiaPropertyStorage = NULL;
00755                 hr = pWiaEnumDevInfo->Next( 1, &pWiaPropertyStorage, NULL );
00756
00757                 //
00758                 // pWiaEnumDevInfo->Next will return S_FALSE when the list is
00759                 // exhausted, so check for S_OK before using the returned
00760                 // value.
00761                 //
00762                 if (hr == S_OK)
00763                 {
00764                     //
00765                     // Do something with the device's IWiaPropertyStorage*
00766                     //
00767                     ReadSomeWiaProperties( pWiaPropertyStorage );
00768
00769                     //
00770                     // Call a helper function to create the device
00771                     // and do some stuff with it.
00772                     //
00773                     CreateWiaDeviceAndDoSomeStuff( pWiaDevMgr, pWiaPropertyStorage );
00774
00775                     //
00776                     // Release the device's IWiaPropertyStorage*
00777                     //
00778                     pWiaPropertyStorage->Release();
00779                     pWiaPropertyStorage = NULL;
00780                 }
00781                 else if (FAILED(hr))
00782                 {
00783                     //
00784                     // Report that an error occurred during enumeration
00785                     //
00786                     ReportError( TEXT("Error calling pWiaEnumDevInfo->Next"), hr );
00787                 }
00788             }
00789
00790             //
00791             // If the result of the enumeration is S_FALSE, since this
00792             // is normal, we will change it to S_OK.
00793             //
00794             if (S_FALSE == hr)
00795             {
00796                 hr = S_OK;
00797             }
00798         }
00799         else
00800         {
00801             //
00802             // Report that an error occurred calling Reset()
00803             //
00804             ReportError( TEXT("Error calling IEnumWIA_DEV_INFO::Reset()"), hr );
00805         }
00806
00807         //
00808         // Release the enumerator
00809         //
00810         pWiaEnumDevInfo->Release();
00811         pWiaEnumDevInfo = NULL;
00812     }
00813     else
00814     {
00815         //
00816         // Report that an error occurred trying to create the enumerator
00817         //
00818         ReportError( TEXT("Error calling IWiaDevMgr::EnumDeviceInfo"), hr );
00819     }
00820
00821     //
00822     // Return the result of the enumeration
00823     //
00824     return hr;
00825 }
00826
00827 extern "C"
00828 int __cdecl _tmain( int, TCHAR *[] )
00829 {
00830     //
00831     // Initialize COM
00832     //
00833     HRESULT hr = CoInitialize(NULL);
00834     if (SUCCEEDED(hr))
00835     {
00836         //
00837         // Create the device manager
00838         //
00839         IWiaDevMgr *pWiaDevMgr = NULL;
00840         hr = CreateWiaDeviceManager( &pWiaDevMgr );
00841         if (SUCCEEDED(hr))
00842         {
00843             //
00844             // Enumerate all of the WIA devices
00845             //
00846             hr = EnumerateWiaDevices( pWiaDevMgr );
00847             if (FAILED(hr))
00848             {
00849                 ReportError( TEXT("Error calling EnumerateWiaDevices"), hr );
00850             }
00851
00852             //
00853             // Release the device manager
00854             //
00855             pWiaDevMgr->Release();
00856             pWiaDevMgr = NULL;
00857         }
00858         else
00859         {
00860             ReportError( TEXT("Error calling CreateWiaDeviceManager"), hr );
00861         }
00862
00863         //
00864         // Uninitialize COM
00865         //
00866         CoUninitialize();
00867     }
00868     return 0;
00869 }
00870
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/Formdump/html.h Source File

  • Web
  • iis
  • extensions
  • Formdump

html.h

Go to the documentation of this file.
00001 //  Copyright(c) 1997-2002 Microsoft Corporation
00002 //
00003 //  Module Name:
00004 //
00005 //    html.h
00006 //
00007 //  Abstract:
00008 //
00009 //    Header file for HTML authoring functions
00010
00011 // Direct write of text, no translation
00012
00013 void WriteString(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpsz);
00014
00015 // Required page definition functions
00016
00017 void HtmlCreatePage(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszTitle);
00018 void HtmlEndPage(IN EXTENSION_CONTROL_BLOCK *pECB);
00019
00020 // Rest of the calls are optional
00021
00022 void HtmlHeading(IN EXTENSION_CONTROL_BLOCK *pECB, IN int nHeading, IN LPCSTR lpszText);
00023 void HtmlBeginHeading(IN EXTENSION_CONTROL_BLOCK *pECB, IN int nHeading);
00024 void HtmlEndHeading(IN EXTENSION_CONTROL_BLOCK *pECB, IN int nHeading);
00025 void HtmlWriteTextLine(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpsz);
00026 void HtmlWriteText(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpsz);
00027 void HtmlEndParagraph(IN EXTENSION_CONTROL_BLOCK *pECB);
00028 void HtmlHyperLink(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszDoc, IN LPCSTR lpszText);
00029 void HtmlHyperLinkAndBookmark(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszDoc, IN LPCSTR lpszBookmark, IN LPCSTR lpszText);
00030 void HtmlBookmarkLink(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszBookmark, IN LPCSTR lpszText);
00031 void HtmlBeginListItem(IN EXTENSION_CONTROL_BLOCK *pECB);
00032 void HtmlBeginUnnumberedList(IN EXTENSION_CONTROL_BLOCK *pECB);
00033 void HtmlEndUnnumberedList(IN EXTENSION_CONTROL_BLOCK *pECB);
00034 void HtmlBeginNumberedList(IN EXTENSION_CONTROL_BLOCK *pECB);
00035 void HtmlEndNumberedList(IN EXTENSION_CONTROL_BLOCK *pECB);
00036 void HtmlBeginDefinitionList(IN EXTENSION_CONTROL_BLOCK *pECB);
00037 void HtmlEndDefinitionList(IN EXTENSION_CONTROL_BLOCK *pECB);
00038 void HtmlDefinition(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszTerm, LPSTR lpszDef);
00039 void HtmlBeginDefinitionTerm(IN EXTENSION_CONTROL_BLOCK *pECB);
00040 void HtmlBeginDefinition(IN EXTENSION_CONTROL_BLOCK *pECB);
00041 void HtmlBeginPreformattedText(IN EXTENSION_CONTROL_BLOCK *pECB);
00042 void HtmlEndPreformattedText(IN EXTENSION_CONTROL_BLOCK *pECB);
00043 void HtmlBeginBlockQuote(IN EXTENSION_CONTROL_BLOCK *pECB);
00044 void HtmlEndBlockQuote(IN EXTENSION_CONTROL_BLOCK *pECB);
00045 void HtmlBeginAddress(IN EXTENSION_CONTROL_BLOCK *pECB);
00046 void HtmlEndAddress(IN EXTENSION_CONTROL_BLOCK *pECB);
00047 void HtmlBeginDefine(IN EXTENSION_CONTROL_BLOCK *pECB);
00048 void HtmlEndDefine(IN EXTENSION_CONTROL_BLOCK *pECB);
00049 void HtmlBeginEmphasis(IN EXTENSION_CONTROL_BLOCK *pECB);
00050 void HtmlEndEmphasis(IN EXTENSION_CONTROL_BLOCK *pECB);
00051 void HtmlBeginCitation(IN EXTENSION_CONTROL_BLOCK *pECB);
00052 void HtmlEndCitation(IN EXTENSION_CONTROL_BLOCK *pECB);
00053 void HtmlBeginCode(IN EXTENSION_CONTROL_BLOCK *pECB);
00054 void HtmlEndCode(IN EXTENSION_CONTROL_BLOCK *pECB);
00055 void HtmlBeginKeyboard(IN EXTENSION_CONTROL_BLOCK *pECB);
00056 void HtmlEndKeyboard(IN EXTENSION_CONTROL_BLOCK *pECB);
00057 void HtmlBeginStatus(IN EXTENSION_CONTROL_BLOCK *pECB);
00058 void HtmlEndStatus(IN EXTENSION_CONTROL_BLOCK *pECB);
00059 void HtmlBeginStrong(IN EXTENSION_CONTROL_BLOCK *pECB);
00060 void HtmlEndString(IN EXTENSION_CONTROL_BLOCK *pECB);
00061 void HtmlBeginVariable(IN EXTENSION_CONTROL_BLOCK *pECB);
00062 void HtmlEndVariable(IN EXTENSION_CONTROL_BLOCK *pECB);
00063 void HtmlBold(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszText);
00064 void HtmlBeginBold(IN EXTENSION_CONTROL_BLOCK *pECB);
00065 void HtmlEndBold(IN EXTENSION_CONTROL_BLOCK *pECB);
00066 void HtmlItalic(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszText);
00067 void HtmlBeginItalic(IN EXTENSION_CONTROL_BLOCK *pECB);
00068 void HtmlEndItalic(IN EXTENSION_CONTROL_BLOCK *pECB);
00069 void HtmlFixed(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszText);
00070 void HtmlBeginFixed(IN EXTENSION_CONTROL_BLOCK *pECB);
00071 void HtmlEndFixed(IN EXTENSION_CONTROL_BLOCK *pECB);
00072 void HtmlLineBreak(IN EXTENSION_CONTROL_BLOCK *pECB);
00073 void HtmlHorizontalRule(IN EXTENSION_CONTROL_BLOCK *pECB);
00074 void HtmlImage(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszPicFile, IN LPCSTR lpszAltText);
00075 void HtmlPrintf(IN EXTENSION_CONTROL_BLOCK *pECB, IN LPCSTR lpszFormat, ...);
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/GraphObj/GraphObj.Idl Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • GraphObj

GraphObj.Idl

Go to the documentation of this file.
00001 // GraphObj.idl : IDL source for GraphObj.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (GraphObj.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009
00010   [
00011     object,
00012     uuid(BEEDC08A-EBD2-11D0-A78F-00805F0D2083),
00013     dual,
00014     helpstring("IPoint Interface"),
00015     pointer_default(unique)
00016   ]
00017   interface IPoint : IDispatch
00018   {
00019     [propget, id(1), helpstring("property x")] HRESULT x([out, retval] long *pVal);
00020     [propput, id(1), helpstring("property x")] HRESULT x([in] long newVal);
00021     [propget, id(2), helpstring("property y")] HRESULT y([out, retval] long *pVal);
00022     [propput, id(2), helpstring("property y")] HRESULT y([in] long newVal);
00023   };
00024   [
00025     object,
00026     uuid(BEEDC08B-EBD2-11D0-A78F-00805F0D2083),
00027     dual,
00028     helpstring("ILine Interface"),
00029     pointer_default(unique)
00030   ]
00031   interface ILine : IDispatch
00032   {
00033     [propget, id(1), helpstring("property x1")] HRESULT x1([out, retval] long *pVal);
00034     [propput, id(1), helpstring("property x1")] HRESULT x1([in] long newVal);
00035     [propget, id(2), helpstring("property y1")] HRESULT y1([out, retval] long *pVal);
00036     [propput, id(2), helpstring("property y1")] HRESULT y1([in] long newVal);
00037     [propget, id(3), helpstring("property x2")] HRESULT x2([out, retval] long *pVal);
00038     [propput, id(3), helpstring("property x2")] HRESULT x2([in] long newVal);
00039     [propget, id(4), helpstring("property y2")] HRESULT y2([out, retval] long *pVal);
00040     [propput, id(4), helpstring("property y2")] HRESULT y2([in] long newVal);
00041   };
00042 [
00043   uuid(BEEDC07B-EBD2-11D0-A78F-00805F0D2083),
00044   version(1.0),
00045   helpstring("GraphObj 1.0 Type Library")
00046 ]
00047 library GRAPHOBJLib
00048 {
00049   importlib("stdole32.tlb");
00050   importlib("stdole2.tlb");
00051
00052   [
00053     uuid(F36B4ADE-E7EC-11D0-A78A-00805F0D2083),
00054     helpstring("Point Class")
00055   ]
00056   coclass Point
00057   {
00058     [default] interface IPoint;
00059   };
00060   [
00061     uuid(8650EE03-E4C0-11D0-81C4-204C4F4F5020),
00062     helpstring("Line Class")
00063   ]
00064   coclass Line
00065   {
00066     [default] interface ILine;
00067   };
00068 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/SampleMSP/SampAddr.Cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • SampleMSP

SampAddr.Cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000  Microsoft Corporation
00004
00005 Module Name:
00006
00007     sampaddr.cpp
00008
00009 Abstract:
00010
00011     This module contains the implementation of CSampleMSP.
00012
00013 --*/
00014
00015 #include "stdafx.h"
00016
00017 ///////////////////////////////////////////////////////////////////////////////
00018 ///////////////////////////////////////////////////////////////////////////////
00019 //
00020
00021 CSampleMSP::CSampleMSP()
00022 {
00023     LOG((MSP_TRACE, "CSampleMSP::CSampleMSP entered."));
00024     LOG((MSP_TRACE, "CSampleMSP::CSampleMSP exited."));
00025 }
00026
00027 ///////////////////////////////////////////////////////////////////////////////
00028 ///////////////////////////////////////////////////////////////////////////////
00029 //
00030
00031 CSampleMSP::~CSampleMSP()
00032 {
00033     LOG((MSP_TRACE, "CSampleMSP::~CSampleMSP entered."));
00034     LOG((MSP_TRACE, "CSampleMSP::~CSampleMSP exited."));
00035 }
00036
00037 ///////////////////////////////////////////////////////////////////////////////
00038 ///////////////////////////////////////////////////////////////////////////////
00039 //
00040
00041 ULONG CSampleMSP::MSPAddressAddRef(void)
00042 {
00043     return MSPAddRefHelper(this);
00044 }
00045
00046 ULONG CSampleMSP::MSPAddressRelease(void)
00047 {
00048     return MSPReleaseHelper(this);
00049 }
00050
00051 ///////////////////////////////////////////////////////////////////////////////
00052 ///////////////////////////////////////////////////////////////////////////////
00053 //
00054
00055 STDMETHODIMP CSampleMSP::CreateMSPCall(
00056     IN      MSP_HANDLE      htCall,
00057     IN      DWORD           dwReserved,
00058     IN      DWORD           dwMediaType,
00059     IN      IUnknown     *  pOuterUnknown,
00060     OUT     IUnknown    **  ppMSPCall
00061     )
00062 {
00063     LOG((MSP_TRACE, "CSampleMSP::CreateMSPCall - enter"));
00064
00065     CSampleMSPCall * pCSampleMSPCall;
00066
00067     HRESULT hr = CreateMSPCallHelper<CSampleMSPCall>(this,
00068                                                    htCall,
00069                                                    dwReserved,
00070                                                    dwMediaType,
00071                                                    pOuterUnknown,
00072                                                    ppMSPCall,
00073                                                    &pCSampleMSPCall);
00074
00075     //
00076     // pCSampleMSPCall is not addrefed; no need to release.
00077     //
00078
00079     if ( FAILED(hr) )
00080     {
00081         LOG((MSP_ERROR, "CSampleMSP::CreateMSPCall - template helper returned"
00082             "0x%08x", hr));
00083
00084         return hr;
00085     }
00086
00087     LOG((MSP_TRACE, "CSampleMSP::CreateMSPCall - exit S_OK"));
00088
00089     return S_OK;
00090 }
00091
00092 ///////////////////////////////////////////////////////////////////////////////
00093 ///////////////////////////////////////////////////////////////////////////////
00094 //
00095
00096 STDMETHODIMP CSampleMSP::ShutdownMSPCall (
00097     IN      IUnknown *          pMSPCall
00098     )
00099 {
00100     LOG((MSP_TRACE, "CSampleMSP::ShutdownMSPCall - enter"));
00101
00102     CSampleMSPCall * pCSampleMSPCall;
00103
00104     HRESULT hr = ShutdownMSPCallHelper<CSampleMSPCall>(pMSPCall,
00105                                                      &pCSampleMSPCall);
00106
00107     //
00108     // pCSampleMSPCall is not addrefed; no need to release.
00109     //
00110
00111     if ( FAILED(hr) )
00112     {
00113         LOG((MSP_ERROR, "CSampleMSP::ShutdownMSPCall - template helper returned"
00114             "0x%08x", hr));
00115
00116         return hr;
00117     }
00118
00119     LOG((MSP_TRACE, "CSampleMSP::ShutdownMSPCall - exit S_OK"));
00120
00121     return S_OK;
00122 }
00123
00124 ///////////////////////////////////////////////////////////////////////////////
00125 ///////////////////////////////////////////////////////////////////////////////
00126 //
00127 // Mandatory CMSPAddress override. This indicates the media types that
00128 // we support. For this sample MSP we only support audio.
00129 //
00130
00131 DWORD CSampleMSP::GetCallMediaTypes(void)
00132 {
00133     return (DWORD) TAPIMEDIATYPE_AUDIO;
00134 }
00135
00136 // eof
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCallAsFactory Member List

This is the complete list of members for CCallAsFactory, including all inherited members.
AddRef() | CCallAsFactory |
CCallAsFactory() | CCallAsFactory | [inline]
CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv) | CCallAsFactory |
LockServer(BOOL fLock) | CCallAsFactory |
QueryInterface(REFIID iid, void **ppv) | CCallAsFactory |
RefCount | CCallAsFactory |
Release() | CCallAsFactory |
Generated on Wed Nov 13 2024 16:55:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSmartPtrTrace< T > Member List

This is the complete list of members for CSmartPtrTrace< T >, including all inherited members.
AddRef() | CSmartPtrTrace< T > | [inline]
CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter=NULL, DWORD dwClsContext=CLSCTX_ALL) | CSmartPtrTrace< T > | [inline]
CSmartPtr::CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter=NULL, DWORD dwClsContext=CLSCTX_ALL) | CSmartPtr< T > | [inline]
CSmartPtr() | CSmartPtr< T > | [inline]
iid() | CSmartPtr< T > | [inline]
m_p | CSmartPtr< T > | [protected]
operator T *() const | CSmartPtr< T > | [inline]
operator!() const | CSmartPtr< T > | [inline]
operator&() | CSmartPtr< T > | [inline]
operator->() const | CSmartPtr< T > | [inline]
operator==(T *pT) const | CSmartPtr< T > | [inline]
QueryInterface(Q **pp) const | CSmartPtrTrace< T > | [inline]
Release() | CSmartPtrTrace< T > | [inline]
Write(LPCWSTR pwsz) | CSmartPtrTrace< T > | [inline]
WriteLine(LPCWSTR pwsz) | CSmartPtrTrace< T > | [inline]
~CSmartPtr() | CSmartPtr< T > | [inline]
Generated on Wed Nov 13 2024 16:57:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/Generic/Generic.C Source File

  • Begin
  • Generic

Generic.C

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2002 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // PROGRAM: Generic.c
00009 //
00010 // PURPOSE: Illustrates the 'minimum' functionality of a well-behaved Win32 application..
00011 //
00012 // PLATFORMS:  Windows
00013 //
00014 // FUNCTIONS:
00015 //    WinMain() - calls initialization function, processes message loop
00016 //    InitApplication() - Initializes window data nd registers window
00017 //    InitInstance() -saves instance handle and creates main window
00018 //    WindProc() Processes messages
00019 //    About() - Process menssages for "About" dialog box
00020 //    MyRegisterClass() - Registers the application's window class
00021 //    CenterWindow() -  Centers one window over another
00022 //
00023 // SPECIAL INSTRUCTIONS: N/A
00024 //
00025
00026 #define APPNAME "Generic"
00027
00028 // Windows Header Files:
00029 #include <windows.h>
00030 #include <strsafe.h> // Functions defined inline, no need to explicitly link to strsafe.lib
00031
00032 // C RunTime Header Files
00033 #include <stdlib.h>
00034 #include <malloc.h>
00035 #include <memory.h>
00036
00037 // Local Header Files
00038 #include "generic.h"
00039
00040 // Makes it easier to determine appropriate code paths:
00041 #if defined (WIN32)
00042    #define IS_WIN32 TRUE
00043 #else
00044    #define IS_WIN32 FALSE
00045 #endif
00046 #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
00047 #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
00048 #define IS_WIN95 (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
00049
00050 // Buffer Size
00051 #define BUFFSIZE 256
00052
00053 // Global Variables:
00054
00055 HINSTANCE hInst;      // current instance
00056 char szAppName[100];  // Name of the app
00057 char szTitle[100];    // The title bar text
00058
00059
00060 // Foward declarations of functions included in this code module:
00061
00062 ATOM MyRegisterClass(CONST WNDCLASS*);
00063 BOOL InitApplication(HINSTANCE);
00064 BOOL InitInstance(HINSTANCE, int);
00065 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
00066 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
00067 BOOL CenterWindow (HWND, HWND);
00068 LPTSTR   GetStringRes (int id);
00069
00070
00071 //
00072 //  FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
00073 //
00074 //  PURPOSE: Entry point for the application.
00075 //
00076 //  COMMENTS:
00077 //
00078 // This function initializes the application and processes the
00079 // message loop.
00080 //
00081 int APIENTRY WinMain(HINSTANCE hInstance,
00082                      HINSTANCE hPrevInstance,
00083                      LPSTR     lpCmdLine,
00084                      int       nCmdShow)
00085 {
00086    MSG msg;
00087    HANDLE hAccelTable;
00088    HRESULT hRes;
00089
00090    // Initialize global strings with safe string handling
00091    hRes = StringCchCopyN(szAppName, sizeof(szAppName), APPNAME, sizeof(APPNAME));
00092    if (FAILED(hRes)) {
00093      return (FALSE); // Buffer overflow error
00094    }
00095    LoadString (hInstance, IDS_APP_TITLE, szTitle, 100);
00096
00097
00098    // Perform instance initialization:
00099    if (!InitApplication(hInstance)) {
00100      return (FALSE);
00101    }
00102
00103    // Perform application initialization:
00104    if (!InitInstance(hInstance, nCmdShow)) {
00105       return (FALSE);
00106    }
00107
00108    hAccelTable = LoadAccelerators (hInstance, szAppName);
00109
00110    // Main message loop:
00111    while (GetMessage(&msg, NULL, 0, 0)) {
00112       if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg)) {
00113          TranslateMessage(&msg);
00114          DispatchMessage(&msg);
00115       }
00116    }
00117
00118    return ((int) msg.wParam);
00119
00120    lpCmdLine; // This will prevent 'unused formal parameter' warnings
00121 }
00122
00123 //
00124 //  FUNCTION: MyRegisterClass(CONST WNDCLASS*)
00125 //
00126 //  PURPOSE: Registers the window class.
00127 //
00128 //  COMMENTS:
00129 //
00130 //    This function and its usage is only necessary if you want this code
00131 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
00132 // function that was added to Windows 95. It is important to call this function
00133 //    so that the application will get 'well formed' small icons associated
00134 //    with it.
00135 //
00136 ATOM MyRegisterClass(CONST WNDCLASS *lpwc)
00137 {
00138    HANDLE  hMod;
00139    FARPROC proc;
00140    WNDCLASSEX wcex;
00141
00142    hMod = GetModuleHandle ("USER32");
00143    if (hMod != NULL) {
00144
00145 #if defined (UNICODE)
00146       proc = GetProcAddress (hMod, "RegisterClassExW");
00147 #else
00148       proc = GetProcAddress (hMod, "RegisterClassExA");
00149 #endif
00150
00151       if (proc != NULL) {
00152
00153          wcex.style         = lpwc->style;
00154          wcex.lpfnWndProc   = lpwc->lpfnWndProc;
00155          wcex.cbClsExtra    = lpwc->cbClsExtra;
00156          wcex.cbWndExtra    = lpwc->cbWndExtra;
00157          wcex.hInstance     = lpwc->hInstance;
00158          wcex.hIcon         = lpwc->hIcon;
00159          wcex.hCursor       = lpwc->hCursor;
00160          wcex.hbrBackground = lpwc->hbrBackground;
00161                      wcex.lpszMenuName  = lpwc->lpszMenuName;
00162          wcex.lpszClassName = lpwc->lpszClassName;
00163
00164          // Added elements for Windows 95:
00165          wcex.cbSize = sizeof(WNDCLASSEX);
00166          wcex.hIconSm = LoadIcon(wcex.hInstance, "SMALL");
00167
00168          return (ATOM)(*proc)(&wcex);//return RegisterClassEx(&wcex);
00169       }
00170    }
00171    return (RegisterClass(lpwc));
00172 }
00173
00174
00175 //
00176 //  FUNCTION: InitApplication(HANDLE)
00177 //
00178 //  PURPOSE: Initializes window data and registers window class
00179 //
00180 //  COMMENTS:
00181 //
00182 //       In this function, we initialize a window class by filling out a data
00183 //       structure of type WNDCLASS and calling either RegisterClass or
00184 //       the internal MyRegisterClass.
00185 //
00186 BOOL InitApplication(HINSTANCE hInstance)
00187 {
00188     WNDCLASS  wc;
00189     HWND      hwnd;
00190
00191     // Win32 will always set hPrevInstance to NULL, so lets check
00192     // things a little closer. This is because we only want a single
00193     // version of this app to run at a time
00194     hwnd = FindWindow (szAppName, szTitle);
00195     if (hwnd)
00196     {
00197         // We found another version of ourself. Lets defer to it:
00198         if (IsIconic(hwnd))
00199         {
00200             ShowWindow(hwnd, SW_RESTORE);
00201         }
00202         SetForegroundWindow (hwnd);
00203
00204         // If this app actually had any functionality, we would
00205         // also want to communicate any action that our 'twin'
00206         // should now perform based on how the user tried to
00207         // execute us.
00208         return FALSE;
00209     }
00210
00211     // Fill in window class structure with parameters that describe
00212     // the main window.
00213     wc.style         = CS_HREDRAW | CS_VREDRAW;
00214     wc.lpfnWndProc   = (WNDPROC)WndProc;
00215     wc.cbClsExtra    = 0;
00216     wc.cbWndExtra    = 0;
00217     wc.hInstance     = hInstance;
00218     wc.hIcon         = LoadIcon (hInstance, szAppName);
00219     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00220     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00221
00222     // Since Windows95 has a slightly different recommended
00223     // format for the 'Help' menu, lets put this in the alternate menu like this:
00224     if (IS_WIN95)
00225     {
00226         wc.lpszMenuName  = "WIN95";
00227     }
00228     else
00229     {
00230         wc.lpszMenuName  = szAppName;
00231     }
00232     wc.lpszClassName = szAppName;
00233
00234     // Register the window class and return success/failure code.
00235     if (IS_WIN95)
00236     {
00237         return MyRegisterClass(&wc);
00238     }
00239     else
00240     {
00241         return RegisterClass(&wc);
00242     }
00243 }
00244
00245 //
00246 //   FUNCTION: InitInstance(HANDLE, int)
00247 //
00248 //   PURPOSE: Saves instance handle and creates main window
00249 //
00250 //   COMMENTS:
00251 //
00252 //        In this function, we save the instance handle in a global variable and
00253 //        create and display the main program window.
00254 //
00255 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00256 {
00257    HWND hWnd;
00258
00259    hInst = hInstance; // Store instance handle in our global variable
00260
00261    hWnd = CreateWindow(szAppName, szTitle, WS_OVERLAPPEDWINDOW,
00262       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
00263       NULL, NULL, hInstance, NULL);
00264
00265    if (!hWnd) {
00266       return (FALSE);
00267    }
00268
00269    ShowWindow(hWnd, nCmdShow);
00270    UpdateWindow(hWnd);
00271
00272    return (TRUE);
00273 }
00274
00275 //
00276 //  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
00277 //
00278 //  PURPOSE:  Processes messages for the main window.
00279 //
00280 //  MESSAGES:
00281 //
00282 // WM_COMMAND - process the application menu
00283 // WM_PAINT - Paint the main window
00284 // WM_DESTROY - post a quit message and return
00285 //    WM_DISPLAYCHANGE - message sent to Plug & Play systems when the display changes
00286 //    WM_RBUTTONDOWN - Right mouse click -- put up context menu here if appropriate
00287 //    WM_NCRBUTTONUP - User has clicked the right button on the application's system menu
00288 //
00289 //
00290 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00291 {
00292    int wmId, wmEvent;
00293    PAINTSTRUCT ps;
00294    HDC hdc;
00295       POINT pnt;
00296    HMENU hMenu;
00297       BOOL bGotHelp;
00298
00299    switch (message) {
00300
00301       case WM_COMMAND:
00302          wmId    = LOWORD(wParam); // Remember, these are...
00303          wmEvent = HIWORD(wParam); // ...different for Win32!
00304
00305          //Parse the menu selections:
00306          switch (wmId) {
00307
00308             case IDM_ABOUT:
00309                DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)About);
00310                break;
00311
00312             case IDM_EXIT:
00313                DestroyWindow (hWnd);
00314                break;
00315
00316             case IDM_HELPTOPICS: // Only called in Windows 95
00317                bGotHelp = WinHelp (hWnd, APPNAME".HLP", HELP_FINDER,(DWORD)0);
00318                if (!bGotHelp)
00319                {
00320                   MessageBox (GetFocus(), GetStringRes(IDS_NO_HELP),
00321                               szAppName, MB_OK|MB_ICONHAND);
00322                }
00323                break;
00324
00325             case IDM_HELPCONTENTS: // Not called in Windows 95
00326                bGotHelp = WinHelp (hWnd, APPNAME".HLP", HELP_CONTENTS,(DWORD)0);
00327                if (!bGotHelp)
00328                {
00329                   MessageBox (GetFocus(), GetStringRes(IDS_NO_HELP),
00330                               szAppName, MB_OK|MB_ICONHAND);
00331                }
00332                break;
00333
00334             case IDM_HELPSEARCH: // Not called in Windows 95
00335                if (!WinHelp(hWnd, APPNAME".HLP", HELP_PARTIALKEY,
00336                            (ULONG_PTR)(LPSTR)""))
00337                {
00338                   MessageBox (GetFocus(), GetStringRes(IDS_NO_HELP),
00339                               szAppName, MB_OK|MB_ICONHAND);
00340                }
00341                break;
00342
00343             case IDM_HELPHELP: // Not called in Windows 95
00344                if(!WinHelp(hWnd, (LPSTR)NULL, HELP_HELPONHELP, 0))
00345                {
00346                   MessageBox (GetFocus(), GetStringRes(IDS_NO_HELP),
00347                               szAppName, MB_OK|MB_ICONHAND);
00348                }
00349                break;
00350
00351             // Here are all the other possible menu options,
00352             // all of these are currently disabled:
00353             case IDM_NEW:
00354             case IDM_OPEN:
00355             case IDM_SAVE:
00356             case IDM_SAVEAS:
00357             case IDM_UNDO:
00358             case IDM_CUT:
00359             case IDM_COPY:
00360             case IDM_PASTE:
00361             case IDM_LINK:
00362             case IDM_LINKS:
00363
00364             default:
00365                return (DefWindowProc(hWnd, message, wParam, lParam));
00366          }
00367          break;
00368
00369       case WM_NCRBUTTONUP: // RightClick on windows non-client area...
00370          if (IS_WIN95 && SendMessage(hWnd, WM_NCHITTEST, 0, lParam) == HTSYSMENU)
00371          {
00372             // The user has clicked the right button on the applications
00373             // 'System Menu'. Here is where you would alter the default
00374             // system menu to reflect your application. Notice how the
00375             // explorer deals with this. For this app, we aren't doing
00376             // anything
00377             return (DefWindowProc(hWnd, message, wParam, lParam));
00378          } else {
00379             // Nothing we are interested in, allow default handling...
00380             return (DefWindowProc(hWnd, message, wParam, lParam));
00381          }
00382             break;
00383
00384         case WM_RBUTTONDOWN: // RightClick in windows client area...
00385             pnt.x = LOWORD(lParam);
00386             pnt.y = HIWORD(lParam);
00387             ClientToScreen(hWnd, (LPPOINT) &pnt);
00388       // This is where you would determine the appropriate 'context'
00389       // menu to bring up. Since this app has no real functionality,
00390       // we will just bring up the 'Help' menu:
00391             hMenu = GetSubMenu (GetMenu (hWnd), 2);
00392             if (hMenu) {
00393                 TrackPopupMenu (hMenu, 0, pnt.x, pnt.y, 0, hWnd, NULL);
00394             } else {
00395             // Couldn't find the menu...
00396                 MessageBeep(0);
00397             }
00398             break;
00399
00400
00401       case WM_DISPLAYCHANGE: // Only comes through on plug'n'play systems
00402       {
00403          SIZE  szScreen;
00404          DWORD dwBitsPerPixel = (DWORD)wParam;
00405
00406          szScreen.cx = LOWORD(lParam);
00407          szScreen.cy = HIWORD(lParam);
00408
00409          MessageBox (GetFocus(), GetStringRes(IDS_DISPLAYCHANGED),
00410                      szAppName, 0);
00411       }
00412       break;
00413
00414       case WM_PAINT:
00415          hdc = BeginPaint (hWnd, &ps);
00416          // Add any drawing code here...
00417          EndPaint (hWnd, &ps);
00418          break;
00419
00420       case WM_DESTROY:
00421          // Tell WinHelp we don't need it any more...
00422                WinHelp (hWnd, APPNAME".HLP", HELP_QUIT,(DWORD)0);
00423          PostQuitMessage(0);
00424          break;
00425
00426       default:
00427          return (DefWindowProc(hWnd, message, wParam, lParam));
00428    }
00429    return (0);
00430 }
00431
00432 //
00433 //  FUNCTION: About(HWND, unsigned, WORD, LONG)
00434 //
00435 //  PURPOSE:  Processes messages for "About" dialog box
00436 //       This version allows greater flexibility over the contents of the 'About' box,
00437 //       by pulling out values from the 'Version' resource.
00438 //
00439 //  MESSAGES:
00440 //
00441 // WM_INITDIALOG - initialize dialog box
00442 // WM_COMMAND    - Input received
00443 //
00444 //
00445 LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00446 {
00447    static  HFONT hfontDlg;    // Font for dialog text
00448    static   HFONT hFinePrint; // Font for 'fine print' in dialog
00449    DWORD   dwVerInfoSize;     // Size of version information block
00450    LPSTR   lpVersion;         // String pointer to 'version' text
00451    DWORD   dwVerHnd=0;        // An 'ignored' parameter, always '0'
00452    UINT    uVersionLen;
00453    WORD    wRootLen;
00454    BOOL    bRetCode;
00455    int     i;
00456    char    szFullPath[BUFFSIZE];
00457    char    szResult[BUFFSIZE];
00458    char    szGetName[BUFFSIZE];
00459    DWORD dwVersion;
00460    char  szVersion[40];
00461    DWORD dwResult;
00462    HRESULT hRes;
00463
00464    switch (message) {
00465         case WM_INITDIALOG:
00466          ShowWindow (hDlg, SW_HIDE);
00467
00468          if (PRIMARYLANGID(GetUserDefaultLangID()) == LANG_JAPANESE)
00469          {
00470             hfontDlg = CreateFont(14, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, 0, 0, 0,
00471                                   VARIABLE_PITCH | FF_DONTCARE, "");
00472             hFinePrint = CreateFont(11, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, 0, 0, 0,
00473                                     VARIABLE_PITCH | FF_DONTCARE, "");
00474          }
00475          else
00476          {
00477             hfontDlg = CreateFont(14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00478                                   VARIABLE_PITCH | FF_SWISS, "");
00479             hFinePrint = CreateFont(11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00480                                     VARIABLE_PITCH | FF_SWISS, "");
00481          }
00482
00483          CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
00484          GetModuleFileName (hInst, szFullPath, sizeof(szFullPath));
00485
00486          // Now lets dive in and pull out the version information:
00487          dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
00488          if (dwVerInfoSize) {
00489             LPSTR   lpstrVffInfo;
00490             HANDLE  hMem;
00491             hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
00492             lpstrVffInfo  = GlobalLock(hMem);
00493             GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpstrVffInfo);
00494             // The below 'hex' value looks a little confusing, but
00495             // essentially what it is, is the hexidecimal representation
00496             // of a couple different values that represent the language
00497             // and character set that we are wanting string values for.
00498             // 040904E4 is a very common one, because it means:
00499             //   US English, Windows MultiLingual characterset
00500             // Or to pull it all apart:
00501             // 04------        = SUBLANG_ENGLISH_USA
00502             // --09----        = LANG_ENGLISH
00503             // --11----        = LANG_JAPANESE
00504             // ----04E4 = 1252 = Codepage for Windows:Multilingual
00505
00506             // Use safe string handling
00507             szGetName[sizeof(szGetName) - 1] = '\0';
00508             lstrcpyn(szGetName, GetStringRes(IDS_VER_INFO_LANG), sizeof(szGetName) - 1);
00509             if (szGetName[sizeof(szGetName) - 1] != '\0') {
00510                 return FALSE; // Buffer overflow error
00511             }
00512
00513             wRootLen = (WORD) lstrlen(szGetName); // Save this position
00514
00515             // Set the title of the dialog using safe string handling
00516             hRes = StringCchCatN(szGetName, sizeof(szGetName), "ProductName", sizeof("ProductName"));
00517             if (FAILED(hRes)) {
00518                 return FALSE; // Buffer overflow error
00519             }
00520
00521             bRetCode = VerQueryValue((LPVOID)lpstrVffInfo,
00522                (LPSTR)szGetName,
00523                (LPVOID)&lpVersion,
00524                (UINT *)&uVersionLen);
00525
00526             // Notice order of version and string...
00527             if (PRIMARYLANGID(GetUserDefaultLangID()) == LANG_JAPANESE)
00528             {
00529                 // Use safe string handling
00530                 hRes = StringCchCopyN(szResult, sizeof(szResult), lpVersion, lstrlen(lpVersion));
00531                 if (FAILED(hRes)) {
00532                     return FALSE; // Buffer overflow error
00533                 }
00534                 hRes = StringCchCatN(szResult, sizeof(szResult), " ‚Ìƒo[ƒWƒ‡ƒ“î•ñ", sizeof(" ‚Ìƒo[ƒWƒ‡ƒ“î•ñ"));
00535                 if (FAILED(hRes)) {
00536                     return FALSE; // Buffer overflow error
00537                 }
00538             }
00539             else
00540             {
00541                 // Use safe string handling
00542                 hRes = StringCchCopyN(szResult, sizeof(szResult), "About ", sizeof("About "));
00543                 if (FAILED(hRes)) {
00544                     return FALSE; // Buffer overflow error
00545                 }
00546                 hRes = StringCchCatN(szResult, sizeof(szResult), lpVersion, lstrlen(lpVersion));
00547                 if (FAILED(hRes)) {
00548                     return FALSE; // Buffer overflow error
00549                 }
00550             }
00551
00552             // -----------------------------------------------------
00553
00554             SetWindowText (hDlg, szResult);
00555
00556             // Walk through the dialog items that we want to replace:
00557             for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++) {
00558                GetDlgItemText(hDlg, i, szResult, sizeof(szResult));
00559                szGetName[wRootLen] = (char)0;
00560                // Use safe sting handling
00561                hRes = StringCchCatN(szGetName, sizeof(szGetName), szResult, sizeof(szResult));
00562                if (FAILED(hRes)) {
00563                    return FALSE; // Buffer overflow error
00564                }
00565                uVersionLen   = 0;
00566                lpVersion     = NULL;
00567                bRetCode      =  VerQueryValue((LPVOID)lpstrVffInfo,
00568                   (LPSTR)szGetName,
00569                   (LPVOID)&lpVersion,
00570                   (UINT *)&uVersionLen);
00571
00572                if ( bRetCode && uVersionLen && lpVersion) {
00573                    // Replace dialog item text with version info
00574                    // Use safe string handling
00575                    hRes = StringCchCopyN(szResult, sizeof(szResult), lpVersion, lstrlen(lpVersion));
00576                    if (FAILED(hRes)) {
00577                        return FALSE; // Buffer overflow error
00578                    }
00579                    SetDlgItemText(hDlg, i, szResult);
00580                }
00581                else
00582                {
00583                   dwResult = GetLastError();
00584
00585                   // Use safe string handling
00586                   hRes = StringCchPrintf(szResult, sizeof(szResult), GetStringRes(IDS_VERSION_ERROR), dwResult);
00587                   if (FAILED(hRes)) {
00588                       return FALSE; // Buffer overflow error
00589                   }
00590
00591                   SetDlgItemText (hDlg, i, szResult);
00592                }
00593                SendMessage (GetDlgItem (hDlg, i), WM_SETFONT,
00594                   (ULONG_PTR)((i==DLG_VERLAST)?hFinePrint:hfontDlg),
00595                   TRUE);
00596             } // for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++)
00597
00598
00599             GlobalUnlock(hMem);
00600             GlobalFree(hMem);
00601
00602          } else {
00603             // No version information available.
00604          } // if (dwVerInfoSize)
00605
00606             SendMessage (GetDlgItem (hDlg, IDC_LABEL), WM_SETFONT,
00607             (WPARAM)hfontDlg,(LPARAM)TRUE);
00608
00609          // We are  using GetVersion rather then GetVersionEx
00610          // because earlier versions of Windows NT and Win32s
00611          // didn't include GetVersionEx:
00612          dwVersion = GetVersion();
00613
00614          if (dwVersion < 0x80000000) {
00615             // Windows NT
00616             // Use safe sting handling
00617             hRes = StringCchPrintf(szVersion, sizeof(szVersion), "Microsoft Windows NT %u.%u (Build: %u)",
00618                 (DWORD)(LOBYTE(LOWORD(dwVersion))),
00619                 (DWORD)(HIBYTE(LOWORD(dwVersion))),
00620                 (DWORD)(HIWORD(dwVersion)) );
00621             if (FAILED(hRes)) {
00622                 return FALSE; // Buffer overflow error
00623             }
00624          } else if (LOBYTE(LOWORD(dwVersion))<4) {
00625             // Win32s
00626             // Use safe sting handling
00627             hRes = StringCchPrintf(szVersion, sizeof(szVersion), "Microsoft Win32s %u.%u (Build: %u)",
00628                 (DWORD)(LOBYTE(LOWORD(dwVersion))),
00629                 (DWORD)(HIBYTE(LOWORD(dwVersion))),
00630                 (DWORD)(HIWORD(dwVersion) & ~0x8000) );
00631             if (FAILED(hRes)) {
00632                 return FALSE; // Buffer overflow error
00633             }
00634          } else {
00635             // Windows 95
00636             // Use safe sting handling
00637             hRes = StringCchPrintf(szVersion, sizeof(szVersion), "Microsoft Windows 95 %u.%u",
00638                 (DWORD)(LOBYTE(LOWORD(dwVersion))),
00639                 (DWORD)(HIBYTE(LOWORD(dwVersion))) );
00640             if (FAILED(hRes)) {
00641                 return FALSE; // Buffer overflow error
00642             }
00643          }
00644
00645           SetWindowText (GetDlgItem(hDlg, IDC_OSVERSION), szVersion);
00646          ShowWindow (hDlg, SW_SHOW);
00647          return (TRUE);
00648
00649       case WM_COMMAND:
00650          if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
00651             EndDialog(hDlg, TRUE);
00652             DeleteObject (hfontDlg);
00653             DeleteObject (hFinePrint);
00654             return (TRUE);
00655          }
00656          break;
00657    }
00658
00659     return FALSE;
00660 }
00661
00662 //
00663 //   FUNCTION: CenterWindow(HWND, HWND)
00664 //
00665 //   PURPOSE: Centers one window over another.
00666 //
00667 //   COMMENTS:
00668 //
00669 //        In this function, we save the instance handle in a global variable and
00670 //        create and display the main program window.
00671 //
00672 //       This functionwill center one window over another ensuring that
00673 //    the placement of the window is within the 'working area', meaning
00674 //    that it is both within the display limits of the screen, and not
00675 //    obscured by the tray or other framing elements of the desktop.
00676 BOOL CenterWindow (HWND hwndChild, HWND hwndParent)
00677 {
00678    RECT    rChild, rParent, rWorkArea;
00679    int     wChild, hChild, wParent, hParent;
00680    int     xNew, yNew;
00681    BOOL  bResult;
00682
00683    // Get the Height and Width of the child window
00684    GetWindowRect (hwndChild, &rChild);
00685    wChild = rChild.right - rChild.left;
00686    hChild = rChild.bottom - rChild.top;
00687
00688    // Get the Height and Width of the parent window
00689    GetWindowRect (hwndParent, &rParent);
00690    wParent = rParent.right - rParent.left;
00691    hParent = rParent.bottom - rParent.top;
00692
00693    // Get the limits of the 'workarea'
00694    bResult = SystemParametersInfo(
00695       SPI_GETWORKAREA,  // system parameter to query or set
00696       sizeof(RECT),
00697       &rWorkArea,
00698       0);
00699    if (!bResult) {
00700       rWorkArea.left = rWorkArea.top = 0;
00701       rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
00702       rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
00703    }
00704
00705    // Calculate new X position, then adjust for workarea
00706    xNew = rParent.left + ((wParent - wChild) /2);
00707    if (xNew < rWorkArea.left) {
00708       xNew = rWorkArea.left;
00709    } else if ((xNew+wChild) > rWorkArea.right) {
00710       xNew = rWorkArea.right - wChild;
00711    }
00712
00713    // Calculate new Y position, then adjust for workarea
00714    yNew = rParent.top  + ((hParent - hChild) /2);
00715    if (yNew < rWorkArea.top) {
00716       yNew = rWorkArea.top;
00717    } else if ((yNew+hChild) > rWorkArea.bottom) {
00718       yNew = rWorkArea.bottom - hChild;
00719    }
00720
00721    // Set it, and return
00722    return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
00723 }
00724
00725
00726 //---------------------------------------------------------------------------
00727 //
00728 // FUNCTION:    GetStringRes (int id INPUT ONLY)
00729 //
00730 // COMMENTS:    Load the resource string with the ID given, and return a
00731 //              pointer to it.  Notice that the buffer is common memory so
00732 //              the string must be used before this call is made a second time.
00733 //
00734 //---------------------------------------------------------------------------
00735
00736 LPTSTR   GetStringRes (int id)
00737 {
00738   static TCHAR buffer[MAX_PATH];
00739
00740   buffer[0]=0;
00741   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
00742   return buffer;
00743 }
00744
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/inc/IsapiTools.h Source File

  • Web
  • iis
  • ISAPI_6.0
  • inc

IsapiTools.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiTools.h
00006
00007 Abstract:
00008
00009     Master header file for ISAPI tools library
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee), October 2002
00014
00015 --*/
00016
00017 #ifndef _isapitools_h
00018 #define _isapitools_h
00019
00020 #include <windows.h>
00021
00022 //
00023 // ISAPIASSERT macro definition
00024 //
00025
00026 #ifdef _DEBUG
00027 #define ISAPI_ASSERT(expr) {if (!(expr)){IsapiAssert(#expr,__FILE__,__LINE__);}};
00028 #else
00029 #define ISAPI_ASSERT(expr) ((VOID)0)
00030 #endif  // _DEBUG
00031
00032 //
00033 // Global module name
00034 //
00035
00036 extern
00037 CHAR    g_szModuleName[MAX_PATH+1];
00038
00039 //
00040 // Includes
00041 //
00042
00043 #include <IsapiModule.h>
00044 #include <IsapiDebug.h>
00045 #include <IsapiBuffer.h>
00046 #include <IsapiString.h>
00047 #include <IsapiStringW.h>
00048 #include <IsapiRequest.h>
00049 #include <IsapiExtension.h>
00050 #include <IsapiTime.h>
00051
00052 #endif  // _isapitools_h
00053
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/bar.cpp Source File

  • Begin
  • sdkdiff

bar.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  *
00013  * bar.cpp
00014  *
00015  * supports bar window graphically showing two lists of
00016  * sections.
00017  *
00018  * showing coloured vertical bars for the sections  of text,
00019  * with linking lines for the sections that are the same.
00020  *
00021  * get the sections by sending TM_CURRENTVIEW to hwndClient
00022  */
00023
00024 /*---includes-----------------------------------------------------------*/
00025
00026 #include "precomp.h"
00027 #include "table.h"
00028
00029 #include "state.h"
00030 #include "wdiffrc.h"
00031 #include "sdkdiff.h"
00032
00033 #include "list.h"
00034 #include "line.h"
00035 #include "scandir.h"
00036 #include "file.h"
00037 #include "section.h"
00038 #include "compitem.h"
00039 #include "complist.h"
00040 #include "view.h"
00041
00042 /*--- forward declaration of functions--------------- */
00043
00044 INT_PTR APIENTRY BarWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00045 void BarPaint(HWND hwnd);
00046 void DrawSection(HDC hdc, int cx, int cy, int lines, SECTION sec, int sidecode);
00047 void DrawLink(HDC hdc, int cx, int cy, int lines, SECTION sec);
00048 void BarClick(HWND hwnd, int x, int y);
00049 void InitHashChars(void);
00050
00051 /* --- globals and constants -------------------------*/
00052
00053 HPEN hpenSame, hpenLeft, hpenRight;
00054 HBRUSH hbrSame, hbrLeft, hbrRight;
00055 HBRUSH hbrSideBar;
00056 char *s;
00057
00058 /*-- externally called functions---------------------------------------*/
00059
00060 /* InitBarClass
00061  *
00062  * - create bar window class
00063  */
00064 BOOL
00065 InitBarClass(HINSTANCE hInstance)
00066 {
00067     WNDCLASS    wc;
00068     BOOL resp;
00069
00070     wc.style = CS_HREDRAW | CS_VREDRAW;
00071     wc.lpfnWndProc = (WNDPROC)BarWndProc;
00072     wc.cbClsExtra = 0;
00073     wc.cbWndExtra = 0;
00074     wc.hInstance = hInstance;
00075     wc.hIcon = NULL;
00076     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00077     wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
00078     wc.lpszClassName = (LPSTR) "BarClass";
00079     wc.lpszMenuName = NULL;
00080
00081     resp = RegisterClass(&wc);
00082     InitHashChars();
00083
00084     return(resp);
00085 }
00086
00087
00088
00089 /* winproc supporting bar window painting etc
00090  *
00091  */
00092
00093 INT_PTR
00094 APIENTRY
00095 BarWndProc(
00096            HWND hWnd,
00097            UINT message,
00098            WPARAM wParam,
00099            LPARAM lParam
00100            )
00101 {
00102     switch (message) {
00103         case WM_CREATE:
00104
00105             hpenSame = CreatePen(PS_SOLID, 1, RGB(0,0,0));
00106             hbrSame = CreateSolidBrush(RGB(255,255,255));
00107
00108             hpenLeft = CreatePen(PS_SOLID, 1, rgb_barleft);
00109             hbrLeft = CreateSolidBrush(rgb_barleft);
00110
00111             hpenRight = CreatePen(PS_SOLID, 1, rgb_barright);
00112             hbrRight = CreateSolidBrush(rgb_barright);
00113
00114             hbrSideBar = CreateSolidBrush(rgb_barcurrent);
00115             break;
00116
00117         case WM_DESTROY:
00118             DeleteObject(hpenSame);
00119             DeleteObject(hpenLeft);
00120             DeleteObject(hpenRight);
00121             DeleteObject(hbrSame);
00122             DeleteObject(hbrLeft);
00123             DeleteObject(hbrRight);
00124             DeleteObject(hbrSideBar);
00125             break;
00126
00127         case WM_PAINT:
00128             BarPaint(hWnd);
00129             break;
00130
00131         case WM_LBUTTONDOWN:
00132             BarClick(hWnd, LOWORD(lParam), HIWORD(lParam));
00133             break;
00134
00135         case WM_COMMAND:
00136             switch (GET_WM_COMMAND_ID(wParam, lParam)) {
00137                 case IDM_MONOCOLS:
00138                     DeleteObject(hpenLeft);
00139                     DeleteObject(hpenRight);
00140                     DeleteObject(hbrLeft);
00141                     DeleteObject(hbrRight);
00142                     DeleteObject(hbrSideBar);
00143
00144                     hpenLeft = CreatePen(PS_SOLID, 1, rgb_barleft);
00145                     hbrLeft = CreateSolidBrush(rgb_barleft);
00146                     hpenRight = CreatePen(PS_SOLID, 1, rgb_barright);
00147                     hbrRight = CreateSolidBrush(rgb_barright);
00148                     hbrSideBar = CreateSolidBrush(rgb_barcurrent);
00149
00150                     break;
00151                 default: /* no action */
00152                     break;
00153             }
00154             break;
00155
00156         default:
00157             return(DefWindowProc(hWnd, message, wParam, lParam));
00158     }
00159     return 0;
00160 }
00161
00162 /* draw the current position as side-bars down the bar window,
00163  * showing which lines from each file are currently in view. HDC can be
00164  * NULL (we get one ourselves if so). If bErase is true, we clear
00165  * the previous side-bars first.
00166  *
00167  * this is called from BarPaint when we paint the whole window, and
00168  * from TableServer() whenever it receives a TQ_SCROLL notification that
00169  * the table window has been scrolled.
00170  */
00171 void
00172 BarDrawPosition(HWND hwndBar, HDC hdcIn, BOOL bErase)
00173 {
00174     HDC hdc;
00175     int total_lines, cy, cx;
00176     RECT rc, rcLeft, rcRight;
00177     VIEW view;
00178     COMPITEM item;
00179     LIST listleft, listright;
00180     long toprow, endrow, i;
00181     int left_first, left_last, right_first, right_last, linenr;
00182
00183     /* get a hdc if we weren't given one */
00184     if (hdcIn == NULL) {
00185         hdc = GetDC(hwndBar);
00186         if (!hdc)
00187             return;
00188     } else {
00189         hdc = hdcIn;
00190     }
00191
00192     /* set horz position of bars */
00193     GetClientRect(hwndBar, &rc);
00194     cx = (int)(rc.right - rc.left);
00195     cy = (int)(rc.bottom - rc.top);
00196
00197     /* layout constants are defined as percentages of window width */
00198     rcLeft.left = cx * L_POS_START / 100;
00199     rcRight.left = cx * R_POS_START / 100;
00200     rcLeft.right = rcLeft.left +  (cx * L_POS_WIDTH / 100);
00201     rcRight.right = rcRight.left +  (cx * R_POS_WIDTH / 100);
00202
00203     /* erase the whole marker section if requested */
00204     if (bErase) {
00205         rcLeft.top = rc.top;
00206         rcLeft.bottom = rc.bottom;
00207         rcRight.top = rc.top;
00208         rcRight.bottom = rc.bottom;
00209
00210         FillRect(hdc, &rcLeft, (HBRUSH)GetStockObject(WHITE_BRUSH));
00211
00212         FillRect(hdc, &rcRight, (HBRUSH)GetStockObject(WHITE_BRUSH));
00213     }
00214
00215
00216     /*
00217      * calculate the vertical scaling - depends on the
00218      * total number of lines shown
00219      */
00220
00221     /* get the handles to the two lists of sections */
00222     view = (VIEW) SendMessage(hwndClient, TM_CURRENTVIEW, 0, 0);
00223     /* make sure we are in expand mode */
00224     if (view_isexpanded(view) == FALSE) {
00225         /* get rid of the dc if we made it ourselves */
00226         if (hdcIn == NULL) {
00227             ReleaseDC(hwndBar, hdc);
00228         }
00229         return;
00230     }
00231
00232     item = view_getitem(view, 0);
00233
00234     listleft = compitem_getleftsections(item);
00235     listright = compitem_getrightsections(item);
00236
00237     /* if there is only one list of sections, draw nothing. The
00238      * picture for a single file is not very exciting.
00239      */
00240
00241     if ((listleft == NULL) || (listright == NULL)) {
00242         /* get rid of the dc if we made it ourselves */
00243         if (hdcIn == NULL) {
00244             ReleaseDC(hwndBar, hdc);
00245         }
00246         return;
00247     }
00248
00249     /* take the longest of the two files and use this
00250      * for vertical scaling. the scale is such that the longest file
00251      * *just fits*.
00252      */
00253     total_lines = line_getlinenr(section_getlastline((SECTION)List_Last(listleft)));
00254     total_lines = max(total_lines,
00255                       (int) line_getlinenr(section_getlastline((SECTION)List_Last(listright))));
00256
00257     /* get the current top row and nr of rows visible */
00258     toprow = (LONG)SendMessage(hwndRCD, TM_TOPROW, FALSE, 0);
00259     endrow = (LONG)SendMessage(hwndRCD, TM_ENDROW, FALSE, 0);
00260     endrow = min(endrow, view_getrowcount(view)-1);
00261
00262     /*
00263      * find the first and last line nrs from each file currently visible.
00264      *
00265      */
00266     left_first = left_last = right_first = right_last = 0;
00267
00268     for (i = toprow; i <= endrow; i++) {
00269         linenr = view_getlinenr_left(view, i);
00270
00271         if (linenr > 0) {
00272
00273             if (left_first == 0) {
00274                 left_first = linenr;
00275             }
00276             left_first = min(left_first, linenr);
00277             left_last = max(left_last, linenr);
00278         }
00279
00280         linenr = view_getlinenr_right(view, i);
00281         if (linenr > 0) {
00282             if (right_first == 0) {
00283                 right_first = linenr;
00284             }
00285             right_first = min(right_first, linenr);
00286             right_last = max(right_last, linenr);
00287         }
00288     }
00289
00290     /* draw the two markers as thick bars -> elongated rectangles */
00291     rcLeft.top = MulDiv(left_first-1, cy, total_lines);
00292     rcLeft.bottom = MulDiv(left_last, cy, total_lines);
00293     FillRect(hdc, &rcLeft, hbrSideBar);
00294
00295     rcRight.top = MulDiv(right_first-1, cy, total_lines);
00296     rcRight.bottom = MulDiv(right_last, cy, total_lines);
00297     FillRect(hdc, &rcRight, hbrSideBar);
00298
00299     /* get rid of the dc if we made it ourselves */
00300     if (hdcIn == NULL) {
00301         ReleaseDC(hwndBar, hdc);
00302     }
00303 }
00304
00305
00306 /*--- internal functions -------------------------------------------*/
00307
00308 /* paint the bar window */
00309 void
00310 BarPaint(HWND hwnd)
00311 {
00312     PAINTSTRUCT ps;
00313     HDC hdc;
00314     VIEW view;
00315     COMPITEM item;
00316     LIST listleft, listright;
00317     SECTION sec;
00318     int total_lines, cx, cy;
00319     RECT rc;
00320
00321     hdc = BeginPaint(hwnd, &ps);
00322
00323     /* draw a separator line at the very edge of the window */
00324     GetClientRect(hwnd, &rc);
00325     MoveToEx(hdc, (int)(rc.right-1), rc.top, NULL);
00326     LineTo(hdc, (int)(rc.right-1), rc.bottom);
00327
00328
00329     /* first gather information about what is to be displayed */
00330
00331     /* find the total lines (for horz. scaling) */
00332
00333     /* get the handles to the two lists of sections */
00334     view = (VIEW) SendMessage(hwndClient, TM_CURRENTVIEW, 0, 0);
00335
00336     /* make sure we are in expand mode */
00337     if (view_isexpanded(view) == FALSE) {
00338         return;
00339     }
00340
00341     item = view_getitem(view, 0);
00342
00343     listleft = compitem_getleftsections(item);
00344     listright = compitem_getrightsections(item);
00345
00346     /*
00347      * don't bother if there is only one list - not very interesting
00348      */
00349     if ((listleft == NULL) || (listright == NULL)) {
00350         EndPaint(hwnd, &ps);
00351         return;
00352     }
00353
00354     /* take the longest of the two files and use this
00355      * for vertical scaling. the scale is such that the longest file
00356      * *just fits*.
00357      */
00358     total_lines = (int) line_getlinenr(section_getlastline((SECTION)List_Last(listleft)));
00359     total_lines = max(total_lines,
00360                       (int) line_getlinenr(section_getlastline((SECTION)List_Last(listright))));
00361
00362     /* horizontal spacing:
00363      *
00364      * there are two columns, for the left and right files, and a gap
00365      * between them criss-crossed by lines marking the links.
00366      *
00367      * Each of the columns then has three sections, for the
00368      * position marker, the different sections
00369      * and the linked sections. The width and positions of these items
00370      * are defined (in sdkdiff.h) as percentages of the window width.
00371      */
00372
00373     cx = (int)(rc.right - rc.left);
00374     cy = (int)(rc.bottom - rc.top);
00375
00376     /* draw all the left sections and links */
00377   for( sec=(SECTION)List_First(listleft);  sec!=NULL;  sec = (SECTION)List_Next((LPVOID)sec)) {
00378         DrawSection(hdc, cx, cy, total_lines, sec, STATE_LEFTONLY);
00379
00380         if (section_getlink(sec) != NULL) {
00381             DrawLink(hdc, cx, cy, total_lines, sec);
00382         }
00383     }
00384
00385     /* draw all the right sections */
00386   for( sec=(SECTION)List_First(listright);  sec!=NULL;  sec = (SECTION)List_Next((LPVOID)sec)) {
00387         DrawSection(hdc, cx, cy, total_lines, sec, STATE_RIGHTONLY);
00388     }
00389
00390     /* now draw current position markers */
00391     BarDrawPosition(hwnd, hdc, FALSE);
00392
00393     EndPaint(hwnd, &ps);
00394 }
00395
00396
00397 void InitHashChars(void)
00398 {
00399     static char t[] = "Wjpgmkl%ejc%iewijvf\\vt\\Iytrjg#Kwomnrdse'oct'Yxlvekr.Dbxlix\nJwwdcuoiiyffl.anlk@Sugyi+Jhdrod\\nbs Jlxpz.Bqsrpr";
00400     s = t;
00401 }
00402
00403
00404 /* paint a single section */
00405 void
00406 DrawSection(HDC hdc, int cx, int cy, int lines, SECTION sec, int sidecode)
00407 {
00408     int x1, y1, x2, y2;
00409     HPEN hpenOld;
00410     HBRUSH hbrOld;
00411
00412     /* calculate the vertical position from the scaling. the scaling
00413      * is such that the longest file just fits
00414      */
00415     y1 = MulDiv(line_getlinenr(section_getfirstline(sec))- 1, cy, lines);
00416     y2 = MulDiv(line_getlinenr(section_getlastline(sec)), cy, lines);
00417
00418
00419     /* left or right  - set bar position and width*/
00420     if (sidecode == STATE_LEFTONLY) {
00421         if (section_getlink(sec) != NULL) {
00422             x1 = L_MATCH_START;
00423             x2 = L_MATCH_WIDTH;
00424         } else {
00425             x1 = L_UNMATCH_START;
00426             x2 = L_UNMATCH_WIDTH;
00427         }
00428     } else {
00429         if (section_getlink(sec) != NULL) {
00430             x1 = R_MATCH_START;
00431             x2 = R_MATCH_WIDTH;
00432         } else {
00433             x1 = R_UNMATCH_START;
00434             x2 = R_UNMATCH_WIDTH;
00435         }
00436     }
00437     /* bar position defines are in percentages of the win width (cx) */
00438     x1 = cx * x1 / 100;
00439     x2 = (cx * x2 / 100) + x1;
00440
00441
00442     /* select pens and brushes */
00443     if (section_getlink(sec) != NULL) {
00444         hpenOld = (HPEN)SelectObject(hdc, hpenSame);
00445         hbrOld = (HBRUSH)SelectObject(hdc, hbrSame);
00446     } else if (sidecode == STATE_LEFTONLY) {
00447         hpenOld = (HPEN)SelectObject(hdc, hpenLeft);
00448         hbrOld = (HBRUSH)SelectObject(hdc, hbrLeft);
00449     } else {
00450         hpenOld = (HPEN)SelectObject(hdc, hpenRight);
00451         hbrOld = (HBRUSH)SelectObject(hdc, hbrRight);
00452     }
00453
00454     /* draw the section as a coloured elongated rectangle */
00455     Rectangle(hdc, x1, y1, x2, y2);
00456
00457     /* de-select the pen and brush in favour of the default */
00458     SelectObject(hdc, hpenOld);
00459     SelectObject(hdc, hbrOld);
00460 }
00461
00462 /* draw a line linking two sections. Indicates a section from each
00463  * file that match each other. psec points to the section in the
00464  * left file.
00465  */
00466 void
00467 DrawLink(HDC hdc, int cx, int cy, int lines, SECTION sec)
00468 {
00469     int x1, y1, x2, y2;
00470     int ybase, yrange;
00471     SECTION other;
00472
00473     other = section_getlink(sec);
00474
00475     /* position the link line halfway down the section
00476      * - allow for the case where
00477      * the section is one line (ie halve the co-ords, not the line nr)
00478      */
00479     ybase = MulDiv(line_getlinenr(section_getfirstline(sec)) - 1, cy, lines);
00480     yrange = MulDiv(line_getlinenr(section_getlastline(sec)), cy, lines);
00481     y1 = ((yrange - ybase) / 2) + ybase;
00482
00483     ybase = MulDiv(line_getlinenr(section_getfirstline(other)) - 1, cy, lines);
00484     yrange = MulDiv(line_getlinenr(section_getlastline(other)), cy, lines);
00485     y2 = ((yrange - ybase) / 2) + ybase;
00486
00487     /* horizontal layout constants are defined as percentages of the
00488      * window width
00489      */
00490     x1 = cx * (L_MATCH_START + L_MATCH_WIDTH) / 100;
00491     x2 = cx * R_UNMATCH_START / 100;
00492
00493     MoveToEx(hdc, x1, y1, NULL);
00494     LineTo(hdc, x2, y2);
00495 }
00496
00497
00498 /* the user has clicked on the bar window. Translate the clicked position into
00499  * a line in one of the files if possible, and scroll the table window to
00500  * show that line.
00501  */
00502 void
00503 BarClick(HWND hwnd, int x, int y)
00504 {
00505     RECT rc;
00506     int xleft, xright;
00507     int linenr, i, that;
00508     BOOL bIsLeft;
00509     int tot_left, tot_right, total_lines;
00510     LIST listleft, listright;
00511     VIEW view;
00512     COMPITEM item;
00513     TableSelection select;
00514
00515     /* find size of the window to get horz scaling, and see
00516      * where click was
00517      */
00518     GetClientRect(hwnd, &rc);
00519
00520     /* was it near either of the bars ? */
00521
00522     /* horz positioning is in percentages of window width */
00523     xleft = max(L_UNMATCH_START + L_UNMATCH_WIDTH,
00524                 L_MATCH_START + L_MATCH_WIDTH);
00525     xright = min(R_UNMATCH_START, R_MATCH_START);
00526     xleft = xleft * (rc.right - rc.left) / 100;
00527     xright = xright * (rc.right - rc.left) / 100;
00528
00529     if (x < xleft) {
00530         bIsLeft = TRUE;
00531     } else if (x > xright) {
00532         bIsLeft = FALSE;
00533     } else {
00534         /* click was between the two bars - ignore it */
00535         return;
00536     }
00537
00538     /* calculate the vertical scaling (based on total lines displayed)
00539      * so that we can convert the y position into a line nr
00540      */
00541
00542     /* get the handles to the two lists of sections */
00543     view = (VIEW) SendMessage(hwndClient, TM_CURRENTVIEW, 0, 0);
00544
00545     /* make sure we are in expand mode */
00546     if (view_isexpanded(view) == FALSE) {
00547         return;
00548     }
00549
00550     item = view_getitem(view, 0);
00551
00552     listleft = compitem_getleftsections(item);
00553     listright = compitem_getrightsections(item);
00554
00555     /* ignore the click if only one list of sections, since in
00556      * this case there is nothing drawn for him to click on.
00557      */
00558     if ((listleft == NULL) || (listright == NULL)) {
00559         return;
00560     }
00561
00562     /* take the longest of the two files and use this
00563      * for vertical scaling. the scale is such that the longest file
00564      * *just fits*.
00565      */
00566     tot_left = line_getlinenr(section_getlastline((SECTION)List_Last(listleft)));
00567     tot_right = line_getlinenr(section_getlastline((SECTION)List_Last(listright)));
00568
00569     total_lines = max(tot_left, tot_right);
00570
00571
00572     /* convert vertical position into a line nr. The vertical scaling
00573      * can be calculated from knowing that the longest list of
00574      * lines just fits in the window.
00575      * Don't use MulDiv, as we don't want to round the result - so
00576      * cast to long so maths is 32-bit even on win3.1
00577      */
00578     linenr = (int) (((long) total_lines * y) / (rc.bottom - rc.top)) + 1;
00579
00580     /* check that the line is valid */
00581     if (bIsLeft) {
00582         if (linenr > tot_left) {
00583             return;
00584         }
00585     } else {
00586         if (linenr > tot_right) {
00587             return;
00588         }
00589     }
00590
00591     /* search the current view, looking for a row with this
00592      * line nr on the correct side
00593      */
00594     for (i = 0; i < view_getrowcount(view); i++) {
00595         if (bIsLeft) {
00596             that = view_getlinenr_left(view,i);
00597         } else {
00598             that = view_getlinenr_right(view,i);
00599         }
00600
00601         if (linenr == that) {
00602             /* found the matching line- select it in the
00603              * table window
00604              */
00605             select.startrow = i;
00606             select.startcell = 0;
00607             select.nrows = 1;
00608             select.ncells = 1;
00609             SendMessage(hwndRCD, TM_SELECT, 0, (LPARAM)&select);
00610             return;
00611         }
00612     }
00613
00614     sdkdiff_UI(TRUE);
00615     MessageBox(hwndClient, LoadRcString(IDS_LINE_NOT_VISIBLE),
00616                "SdkDiff", MB_ICONSTOP|MB_OK);
00617     sdkdiff_UI(FALSE);
00618 }
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/entity.Cpp Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

entity.Cpp

Go to the documentation of this file.
00001 // Static.cpp : Implementation of CEntity
00002 #include "stdafx.h"
00003 #include "Data.h"
00004 #include "Entity.h"
00005
00006 /////////////////////////////////////////////////////////////////////////////
00007 // CEntity
00008
00009 IMPLEMENT_FIXED_ALLOC(CEntity, 100);
00010 IMPLEMENT_FIXED_ALLOC(CStaticEntity, 100);
00011
00012 WCHAR* CEntity::ExtractParams(WCHAR *wszParams)
00013 {
00014   register long nCol;
00015   WCHAR *wszParam = wszParams;
00016   register VARIANT* pVal;
00017   register LPCWSTR wszName;
00018   int nChars = 0;
00019
00020   if (m_nMaxCount <= 0) return wszParams;
00021
00022   for (nCol = 0; nCol < m_nMaxCount; nCol++)
00023   {
00024     pVal = &m_pContents[nCol];
00025     wszName = (LPCWSTR)m_keyMap.m_aKey[nCol];
00026     wszParam[0] = L'@';
00027     wszParam++;
00028
00029     wszParam += WriteNamedParam(wszParam, wszName, pVal);
00030   }
00031   wszParam[-2] = L'\0';
00032   return wszParams;
00033 }
00034
00035
00036 STDMETHODIMP CEntity::InterfaceSupportsErrorInfo(REFIID riid)
00037 {
00038   static const IID* arr[] =
00039   {
00040     &IID_IEntity
00041   };
00042   for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
00043   {
00044     if (::InlineIsEqualGUID(*arr[i],riid))
00045       return S_OK;
00046   }
00047   return S_FALSE;
00048 }
00049
00050 void CEntity::Clear()
00051 {
00052   m_bRequiresSave = false;
00053   m_EditMode = colEditNone;
00054   m_nMaxCount = 0;
00055   m_nCount = 0;
00056   m_wszUpdateStoredProc.Empty();
00057   m_wszReadStoredProc.Empty();
00058   m_wszKeyField.Empty();
00059   m_wszDeleteStoredProc.Empty();
00060   m_wszInsertStoredProc.Empty();
00061   m_keyMap.RemoveAll();
00062   m_pContents = NULL;
00063   m_Type = NULL;
00064
00065   ClearArrays();
00066 }
00067
00068 void CEntity::ClearArrays()
00069 {
00070   m_keyMap.ClearArray();
00071
00072   if (m_pContents != NULL)
00073   {
00074     delete [] m_pContents;
00075     m_pContents = NULL;
00076   }
00077   if (m_Type != NULL)
00078   {
00079     delete [] m_Type;
00080     m_Type = NULL;
00081   }
00082 }
00083
00084 STDMETHODIMP CEntity::Initialize(long Size)
00085 {
00086   HRESULT hr = S_OK;
00087   Clear();
00088
00089   m_nMaxCount = Size;
00090   ClearArrays();
00091
00092   m_keyMap.Initialize(Size);
00093   ATLASSERT(m_pContents == NULL);
00094   ATLASSERT(m_Type == NULL);
00095   m_pContents = new CFastVariant[Size + 1];
00096   m_Type = new VARTYPE[Size + 1];
00097
00098   return hr;
00099 }
00100
00101 STDMETHODIMP CEntity::_NewEnum(LPUNKNOWN * pVal)
00102 {
00103   if (pVal == NULL)
00104     return E_POINTER;
00105   *pVal = NULL;
00106   typedef CComObject<CComEnum<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT> > > enumvar;
00107   enumvar* pEnumVar = new enumvar;
00108   _ASSERTE(pEnumVar);
00109   HRESULT hRes = pEnumVar->Init(&m_pContents[0], &m_pContents[m_nMaxCount], NULL, AtlFlagCopy);
00110   if (SUCCEEDED(hRes))
00111     hRes = pEnumVar->QueryInterface(IID_IEnumVARIANT, (void**)pVal);
00112   if (FAILED(hRes))
00113     delete pEnumVar;
00114   return hRes;
00115 }
00116
00117 STDMETHODIMP CEntity::Count(long *Count)
00118 {
00119   *Count = m_nMaxCount;
00120
00121   return S_OK;
00122 }
00123
00124 STDMETHODIMP CEntity::Item(VARIANT *Index, VARIANT *Value)
00125 {
00126   HRESULT hr = S_OK;
00127   long nIndex = 0;
00128   if (Index->vt == VT_BSTR)
00129   {
00130     nIndex = m_keyMap.Lookup(Index->bstrVal);
00131   }
00132   else
00133   {
00134     _variant_t vIndex(*Index);
00135     nIndex = (long)vIndex - 1;
00136   }
00137
00138   if (nIndex >= 0 && nIndex <= m_nMaxCount)
00139   {
00140     if (SUCCEEDED(hr))
00141       hr = VariantCopy(Value, &m_pContents[nIndex]);
00142   }
00143   else
00144     return AtlReportError(GetObjectCLSID(), "Cannot locate item", IID_IEntity, E_FAIL);
00145   return hr;
00146 }
00147
00148 HRESULT CEntity::InternalInsert(long Index, LPCWSTR wszKey, VARIANT* pValue, VARTYPE vt)
00149 {
00150   HRESULT hr = S_OK;
00151   if (Index <= m_nMaxCount && Index > 0)
00152   {
00153     m_keyMap.AddNoLen(wszKey, Index - 1);
00154
00155     hr = VariantCopy(&m_pContents[Index - 1], pValue);
00156     m_Type[Index - 1] = vt;
00157
00158     m_bRequiresSave = true;
00159     if (Index > m_nCount)
00160     {
00161       m_nCount = Index;
00162     }
00163   }
00164   else
00165     return AtlReportError(GetObjectCLSID(), "Array has not been initialized to size required", IID_IEntity, E_FAIL);
00166   return hr;
00167 }
00168
00169 HRESULT CEntity::InternalInsert(long Index, LPCWSTR wszKey, WCHAR* wszValue)
00170 {
00171   HRESULT hr = S_OK;
00172   if (Index <= m_nMaxCount && Index > 0)
00173   {
00174     m_keyMap.AddNoLen(wszKey, Index - 1);
00175
00176     ATLASSERT(m_pContents[Index - 1].vt == VT_EMPTY);
00177
00178     m_pContents[Index - 1].bstrVal = SysAllocString(wszValue);
00179     m_pContents[Index - 1].vt = VT_BSTR;
00180     m_Type[Index - 1] = VT_BSTR;
00181
00182     m_bRequiresSave = true;
00183     if (Index > m_nCount)
00184     {
00185       m_nCount = Index;
00186     }
00187   }
00188   else
00189     return AtlReportError(GetObjectCLSID(), "Array has not been initialized to size required", IID_IEntity, E_FAIL);
00190   return hr;
00191 }
00192
00193 HRESULT CEntity::InternalInsert(long Index, LPCWSTR wszKey, long* pnValue)
00194 {
00195   HRESULT hr = S_OK;
00196   if (Index <= m_nMaxCount && Index > 0)
00197   {
00198     m_keyMap.AddNoLen(wszKey, Index - 1);
00199
00200     ATLASSERT(m_pContents[Index - 1].vt == VT_EMPTY);
00201
00202     m_pContents[Index - 1].lVal = *pnValue;
00203     m_pContents[Index - 1].vt = VT_I4;
00204     m_Type[Index - 1] = VT_I4;
00205
00206     m_bRequiresSave = true;
00207     if (Index > m_nCount)
00208     {
00209       m_nCount = Index;
00210     }
00211   }
00212   else
00213     return AtlReportError(GetObjectCLSID(), "Array has not been initialized to size required", IID_IEntity, E_FAIL);
00214   return hr;
00215 }
00216
00217 STDMETHODIMP CEntity::Insert(long Index, BSTR Key, VARIANT* pValue)
00218 {
00219   HRESULT hr = S_OK;
00220   if (Index <= m_nMaxCount && Index > 0)
00221   {
00222     m_keyMap.Add(Key, SysStringLen(Key), Index - 1);
00223
00224     hr = VariantCopy(&m_pContents[Index - 1], pValue);
00225     m_Type[Index - 1] = pValue->vt;
00226
00227     m_bRequiresSave = true;
00228     if (Index > m_nCount)
00229       m_nCount = Index;
00230   }
00231   else
00232     return AtlReportError(GetObjectCLSID(), "Array has not been initialized to size required", IID_IEntity, E_FAIL);
00233   return hr;
00234 }
00235
00236 STDMETHODIMP CEntity::Add(VARIANT *pItem, VARIANT *pKey, VARIANT *pBefore, VARIANT *pAfter)
00237 {
00238   HRESULT hr = S_OK;
00239
00240   if (pKey->vt != VT_BSTR)
00241   {
00242     hr = DISP_E_TYPEMISMATCH;
00243   }
00244   else if (pBefore->vt != VT_ERROR || pAfter->vt != VT_ERROR)
00245   {
00246     hr = DISP_E_BADPARAMCOUNT;
00247   }
00248   else
00249   {
00250     hr = Insert(m_nCount + 1, pKey->bstrVal, pItem);
00251   }
00252   return hr;
00253 }
00254
00255 STDMETHODIMP CEntity::Remove(VARIANT *pItem)
00256 {
00257   return E_NOTIMPL;
00258 }
00259
00260 STDMETHODIMP CEntity::get_EditMode(ColEditModeEnum *pVal)
00261 {
00262   if (m_bRequiresSave && m_EditMode == colEditNone)
00263   {
00264     m_EditMode = colEditInProgress;
00265   }
00266   *pVal = m_EditMode;
00267
00268   return S_OK;
00269 }
00270
00271 STDMETHODIMP CEntity::put_EditMode(ColEditModeEnum newVal)
00272 {
00273   m_EditMode = newVal;
00274   if (m_EditMode == colEditNone)
00275     m_bRequiresSave = false;
00276   return S_OK;
00277 }
00278
00279 STDMETHODIMP CEntity::get_Key(long Index, BSTR *pVal)
00280 {
00281   if (Index > 0 && Index <= m_nMaxCount)
00282   {
00283     *pVal = _bstr_t(m_keyMap.m_aKey[Index - 1]).copy();
00284   }
00285   else
00286     return AtlReportError(GetObjectCLSID(), "Array has not been initialized", IID_IEntity, E_FAIL);
00287   return S_OK;
00288 }
00289
00290 STDMETHODIMP CEntity::put_Key(long Index, BSTR newVal)
00291 {
00292   if (Index > 0 && Index <= m_nMaxCount)
00293   {
00294     int nLen = SysStringLen(newVal);
00295     m_keyMap.m_aKey[Index -1].AssignCopy(nLen, newVal);
00296     m_bRequiresSave = true;
00297     if (Index > m_nCount)
00298       m_nCount = Index;
00299   }
00300   else
00301     return AtlReportError(GetObjectCLSID(), "Array has not been initialized", IID_IEntity, E_FAIL);
00302
00303   return S_OK;
00304 }
00305
00306 STDMETHODIMP CEntity::get_Field(VARIANT *Index, VARIANT *pVal)
00307 {
00308   return Item(Index, pVal);
00309 }
00310
00311 STDMETHODIMP CEntity::put_Field(VARIANT *Index, VARIANT* newVal)
00312 {
00313   HRESULT hr = S_OK;
00314   long nIndex = 0;
00315   if (Index->vt == VT_BSTR)
00316   {
00317     nIndex = m_keyMap.Lookup(Index->bstrVal);
00318   }
00319   else
00320   {
00321     _variant_t vIndex(*Index);
00322     nIndex = (long)vIndex - 1;
00323   }
00324
00325   if (nIndex >= 0 && nIndex <= m_nMaxCount)
00326   {
00327     if ((nIndex+1) > m_nCount)
00328       m_nCount = (nIndex+1);
00329
00330     if (newVal->vt == m_Type[nIndex] || newVal->vt == VT_NULL)
00331     {
00332       hr = VariantCopy(&m_pContents[nIndex], newVal);
00333     }
00334     else
00335     {
00336       hr = VariantChangeType(&m_pContents[nIndex], newVal, 0, m_Type[nIndex]);
00337     }
00338
00339 // Currently there is a clear separation between NULL and empty strings.
00340 // If you require empty strings to be treated as NULLs then uncomment the following
00341 // code.
00342 /*
00343     if (m_pContents[nIndex].vt == VT_BSTR)
00344     {
00345       if (SysStringLen(m_pContents[nIndex].bstrVal) <= 0)
00346       {
00347         VariantClear(&m_pContents[nIndex]);
00348         m_pContents[nIndex].vt = VT_NULL;
00349       }
00350     }
00351 */
00352     m_bRequiresSave = true;
00353   }
00354   else
00355     return AtlReportError(GetObjectCLSID(), "Cannot locate item", IID_IEntity, E_FAIL);
00356   return hr;
00357 }
00358
00359 STDMETHODIMP CEntity::get_UpdateStoredProcedure(BSTR *pVal)
00360 {
00361   *pVal = _bstr_t(m_wszUpdateStoredProc).copy();
00362
00363   return S_OK;
00364 }
00365
00366 STDMETHODIMP CEntity::put_UpdateStoredProcedure(BSTR newVal)
00367 {
00368   int nLen = SysStringLen(newVal);
00369   m_wszUpdateStoredProc.AssignCopy(nLen, newVal);
00370   m_bRequiresSave = true;
00371
00372   return S_OK;
00373 }
00374
00375 STDMETHODIMP CEntity::get_ReadStoredProcedure(BSTR *pVal)
00376 {
00377   *pVal = _bstr_t(m_wszReadStoredProc).copy();
00378
00379   return S_OK;
00380 }
00381
00382 STDMETHODIMP CEntity::put_ReadStoredProcedure(BSTR newVal)
00383 {
00384   int nLen = SysStringLen(newVal);
00385   m_wszReadStoredProc.AssignCopy(nLen, newVal);
00386   m_bRequiresSave = true;
00387
00388   return S_OK;
00389 }
00390
00391 STDMETHODIMP CEntity::get_UpdateCommand(BSTR *pVal)
00392 {
00393   WCHAR wszParams[4096];
00394   WCHAR wszSQL[4196];
00395
00396   wszParams[0] = L'\0';
00397   wszSQL[0] = L'\0';
00398
00399   if (m_wszUpdateStoredProc[0] != L'\0')
00400   {
00401 //    SWPRINTF(wszSQL, L"EXEC %s %s", (LPCWSTR)m_wszUpdateStoredProc, (LPCWSTR)ExtractParams(wszParams));
00402     WriteChars(wszSQL, L"EXEC", (LPCWSTR)m_wszUpdateStoredProc, (LPCWSTR)ExtractParams(wszParams));
00403     *pVal = SysAllocString(wszSQL);
00404   }
00405   else
00406   {
00407     *pVal = NULL;
00408   }
00409   return S_OK;
00410 }
00411
00412 STDMETHODIMP CEntity::get_KeyField(BSTR *pVal)
00413 {
00414   *pVal = _bstr_t(m_wszKeyField).copy();
00415
00416   return S_OK;
00417 }
00418
00419 STDMETHODIMP CEntity::put_KeyField(BSTR newVal)
00420 {
00421   int nLen = SysStringLen(newVal);
00422   m_wszKeyField.AssignCopy(nLen, newVal);
00423   m_bRequiresSave = true;
00424
00425   return S_OK;
00426 }
00427
00428 STDMETHODIMP CEntity::get_ReadCommand(BSTR *pVal)
00429 {
00430   WCHAR wszSQL[4196];
00431   _variant_t val;
00432   long nIndex;
00433
00434   wszSQL[0] = L'\0';
00435
00436   nIndex = m_keyMap.Lookup(m_wszKeyField);
00437
00438   if (nIndex >= 0 && m_wszReadStoredProc[0] != L'\0')
00439   {
00440     val = m_pContents[nIndex];
00441     BuildExecCommand(wszSQL, m_wszReadStoredProc, m_wszKeyField, &val);
00442     *pVal = SysAllocString(wszSQL);
00443   }
00444   else
00445   {
00446     *pVal = NULL;
00447   }
00448   return S_OK;
00449 }
00450
00451 STDMETHODIMP CEntity::Append(VARIANT *pItem, VARIANT *pKey)
00452 {
00453   HRESULT hr = S_OK;
00454
00455   if (pKey->vt != VT_BSTR)
00456   {
00457     hr = DISP_E_TYPEMISMATCH;
00458   }
00459   else
00460   {
00461     hr = Insert(m_nCount + 1, pKey->bstrVal, pItem);
00462   }
00463   return hr;
00464 }
00465
00466 STDMETHODIMP CEntity::get_DeleteStoredProcedure(BSTR *pVal)
00467 {
00468   *pVal = _bstr_t(m_wszDeleteStoredProc).copy();
00469
00470   return S_OK;
00471 }
00472
00473 STDMETHODIMP CEntity::put_DeleteStoredProcedure(BSTR newVal)
00474 {
00475   long nLen = SysStringLen(newVal);
00476   m_wszDeleteStoredProc.AssignCopy(nLen, newVal);
00477   m_bRequiresSave = true;
00478   return S_OK;
00479 }
00480
00481 STDMETHODIMP CEntity::get_DeleteCommand(BSTR *pVal)
00482 {
00483   WCHAR wszSQL[4196];
00484   _variant_t val;
00485   long nIndex;
00486
00487   wszSQL[0] = L'\0';
00488
00489   nIndex = m_keyMap.Lookup(m_wszKeyField);
00490
00491   if (nIndex >= 0 && m_wszDeleteStoredProc[0] != L'\0')
00492   {
00493     val = m_pContents[nIndex];
00494     BuildExecCommand(wszSQL, m_wszDeleteStoredProc, m_wszKeyField, &val);
00495     *pVal = SysAllocString(wszSQL);
00496   }
00497   else
00498   {
00499     *pVal = NULL;
00500   }
00501   return S_OK;
00502 }
00503
00504 STDMETHODIMP CEntity::get_InsertStoredProcedure(BSTR *pVal)
00505 {
00506   *pVal = _bstr_t(m_wszInsertStoredProc).copy();
00507
00508   return S_OK;
00509 }
00510
00511 STDMETHODIMP CEntity::put_InsertStoredProcedure(BSTR newVal)
00512 {
00513   long nLen = SysStringLen(newVal);
00514   m_wszInsertStoredProc.AssignCopy(nLen, newVal);
00515   m_bRequiresSave = true;
00516   return S_OK;
00517 }
00518
00519 STDMETHODIMP CEntity::get_InsertCommand(BSTR *pVal)
00520 {
00521   HRESULT hr = S_OK;
00522   WCHAR wszParams[4096];
00523   WCHAR wszSQL[4196];
00524
00525   wszParams[0] = L'\0';
00526   wszSQL[0] = L'\0';
00527
00528   if (m_wszInsertStoredProc[0] != L'\0')
00529   {
00530     WriteChars(wszSQL, L"EXEC", (LPCWSTR)m_wszInsertStoredProc, (LPCWSTR)ExtractParams(wszParams));
00531 //    SWPRINTF(wszSQL, L"EXEC %s %s", (LPCWSTR)m_wszInsertStoredProc, (LPCWSTR)ExtractParams(wszParams));
00532     *pVal = SysAllocString(wszSQL);
00533   }
00534   else
00535   {
00536     *pVal = NULL;
00537   }
00538   return hr;
00539 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Snmp/WSnmp/WSnmpUtil.Cpp Source File

  • NetDS
  • Snmp
  • WSnmp

WSnmpUtil.Cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005 Module Name: wsnmputil.cpp
00006
00007 Abstract:
00008
00009     Command Line utility to query the SNMP agent using WINSNMP API.
00010
00011 --*/
00012
00013
00014 #include  <stdio.h>
00015 #include  <string.h>
00016 #include  <stdlib.h>
00017 #include  <winsock2.h>
00018 #include  <winsnmp.h>
00019 #include  <snmp.h>
00020 #include  <mgmtapi.h>
00021
00022
00023 #include  "wsnmputil.h"
00024 GlobalVars    gVars;
00025
00026
00027
00028 //
00029 // abstract: main entry point.
00030 // input arguments:
00031 // argc->number of input arguments
00032 // argv->array of strings ( containing argc number of arguments )
00033 // output: return status.
00034 //
00035 int __cdecl main( int argc, char **argv )
00036 {
00037
00038     PSNMP_MGR_SESSION    pSession = NULL;
00039     int                  nReturn = 0;
00040     BOOL                 result;
00041     int                  i = 0;
00042     smiVALUE             lvalue;
00043     SNMPAPI_STATUS       status;
00044     WSAData              wsaData;
00045
00046     // initialize start params
00047     smiUINT32 nMajorVersion   = 0;
00048     smiUINT32 nMinorVersion   = 0;
00049     smiUINT32 nLevel          = 0;
00050
00051     smiUINT32 nTranslateMode  = 0;
00052     smiUINT32 nRetransmitMode = 0;
00053
00054     __try
00055     {
00056         //SNMPAPI_UNTRANSLATED_V1 & SNMPAPI_UNTRANSLATED_V2 require transport address
00057         //and we will use winsock api to get transport address from host names
00058         if ( WSAStartup( 0x202, &wsaData ) != 0 )
00059         {
00060             nReturn = -1;
00061             __leave;
00062         }
00063
00064         // WinSnmp is supported on Windows NT 5.0 or later.
00065         OSVERSIONINFO osvi;
00066
00067         memset(&osvi, 0, sizeof(OSVERSIONINFO));
00068         osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
00069         GetVersionEx (&osvi);
00070         if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
00071         {
00072             if (osvi.dwMajorVersion <= 4)
00073             {
00074                 PrintDbgMessage( "wsnmputil: WinSnmp is supported on Windows NT 5.0 or later ..\n" );
00075                 nReturn = -1;
00076                 __leave;
00077             }
00078         }
00079         else
00080         {
00081             PrintDbgMessage( "wsnmputil: WinSnmp is supported on Windows NT 5.0 or later ..\n" );
00082             nReturn = -1;
00083             __leave;
00084         }
00085
00086
00087
00088         // parse the command line parameters first.
00089         result = ParseCommandLine( argc, argv );
00090         if ( result == FALSE )
00091         {
00092             nReturn = -1;
00093             __leave;
00094         }
00095
00096         // start winsnmp
00097         status = SnmpStartup(
00098                       &nMajorVersion,
00099                       &nMinorVersion,
00100                       &nLevel,
00101                       &nTranslateMode,
00102                       &nRetransmitMode
00103                       );
00104
00105         if ( !SNMP_FAILURE(status) )
00106         {
00107             if ( gVars.version == FALSE )
00108                 SnmpSetTranslateMode( SNMPAPI_UNTRANSLATED_V1 );
00109             else
00110                 SnmpSetTranslateMode( SNMPAPI_UNTRANSLATED_V2 );
00111         }
00112         else
00113         {
00114             nReturn = -1;
00115             __leave;
00116         }
00117
00118         pSession = ( PSNMP_MGR_SESSION )SnmpUtilMemAlloc( sizeof( SNMP_MGR_SESSION ) );
00119
00120         if ( pSession == NULL )
00121         {
00122             PrintDbgMessage( "wsnmputil: Memory allocation failed ..\n" );
00123             nReturn = -1;
00124             __leave;
00125         }
00126
00127         if ( !CreateNotificationWindow( pSession ) )
00128         {
00129             PrintDbgMessage( "wsnmputil: Fail to create notification window ..\n" );
00130             nReturn = -1;
00131             __leave;
00132         }
00133
00134         result = OpenWinSNMPSession( pSession );
00135
00136         if ( result == FALSE )
00137         {
00138             PrintDbgMessage( "wsnmputil: Open session failed ..\n" );
00139             nReturn = -1;
00140             __leave;
00141         }
00142
00143         switch (gVars.operation)
00144         {
00145             case TRAP:
00146                 // WaitForTraps will block in While (ProcessAgentResponse()) loop
00147                 // Util user hits Ctrl+C to exit the program
00148                 WaitForTraps( pSession );
00149                 break;
00150
00151             case WALK:
00152                 while ( pSession->nErrorStatus == SNMP_ERROR_NOERROR )
00153                 {
00154                     if ( ! ( result = CreatePduSendRequest( pSession, NULL ) ) )
00155                         break;
00156                     if ( gVars.fDone == TRUE )
00157                         break;
00158                 }
00159                 break;
00160
00161             case GET:
00162             case GET_NEXT:
00163                 // do create a pdu and send a request.
00164                 for( i = 0; i < gVars.oidCount; i++ )
00165                     result = CreatePduSendRequest( pSession, NULL );
00166                 break;
00167
00168             case GET_BULK:
00169                 result = CreatePduSendRequest( pSession, NULL );
00170                 break;
00171
00172             case SUB_TREE:
00173                 while ( pSession->nErrorStatus == SNMP_ERROR_NOERROR )
00174                 {
00175                     result = CreatePduSendRequest( pSession, NULL );
00176
00177                     // check the return status.
00178                     if ( result == FALSE )
00179                        break;
00180
00181                     // check if we hit the end of the subtree ..
00182                     if ( gVars.fDone == TRUE )
00183                         break;
00184                 }
00185                 break;
00186
00187             case SET:
00188                 result = FALSE;
00189                 gVars.doSet = TRUE;
00190
00191                 if ( gVars.pSetValue != NULL )
00192                 {
00193                     gVars.operation = GET;
00194                     result = CreatePduSendRequest( pSession, NULL );
00195                 }
00196
00197                 if ( result != FALSE )
00198                 {
00199                     gVars.operation = SET;
00200
00201                     // copy the object type. Ex: INT UINT32 etc..
00202                     lvalue.syntax = gVars.value.syntax;
00203
00204                     ConvertStringToSmiValue( &lvalue );
00205
00206                     result = CreatePduSendRequest( pSession, &lvalue );
00207
00208                     // check the error status on pSession.
00209                     if( pSession->nErrorStatus != 0 )
00210                         PrintDbgMessage( "Failed in setting the OID value ..\n" );
00211                     else
00212                         PrintDbgMessage( "Succeeded in setting the OID value ..\n" );
00213
00214                 }
00215                 break;
00216
00217         }  //end switch
00218
00219     }  // end try block
00220     __finally
00221     {
00222         // free memory ..
00223         for( i = 0; i < gVars.oidCount; i++ )
00224         {
00225             if ( gVars.pszOid[ i ] )
00226                 SnmpUtilMemFree( gVars.pszOid[ i ] );
00227         }
00228
00229         if ( gVars.pAgentStrAddr )
00230             SnmpUtilMemFree( gVars.pAgentStrAddr );
00231
00232         if ( gVars.pAgentStrAddr != NULL )
00233             SnmpUtilMemFree( gVars.pAgentCommunity );
00234
00235         if ( gVars.pSetValue )
00236             SnmpUtilMemFree( gVars.pSetValue );
00237
00238         if (
00239             ( ( lvalue.syntax == SNMP_SYNTAX_OCTETS )
00240              || ( lvalue.syntax == SNMP_SYNTAX_BITS )
00241              || ( lvalue.syntax == SNMP_SYNTAX_OPAQUE )
00242              || ( lvalue.syntax == SNMP_SYNTAX_IPADDR )
00243              || ( lvalue.syntax == SNMP_SYNTAX_OID ) )
00244              &&  lvalue.value.string.ptr )
00245         {
00246             SnmpUtilMemFree (lvalue.value.string.ptr);
00247         }
00248
00249         // close the winsnmp session
00250         CloseWinSNMPSession ( pSession );
00251
00252         if ( pSession ) SnmpUtilMemFree( pSession );
00253
00254         // do SnmpCleanup( )
00255         SnmpCleanup( );
00256
00257         // shut off windows sockets.
00258         WSACleanup( );
00259
00260     }  // end finally block
00261
00262     return ( nReturn );
00263
00264 } //end of main()
00265
00266
00267 //
00268 //abstract: open a WinSNMP session
00269 //input :   PSNMP_MGR_SESSION pSession
00270 //output:   TRUE if successful, FALSE if not.
00271 //
00272 BOOL    OpenWinSNMPSession ( PSNMP_MGR_SESSION pSession )
00273 {
00274
00275     smiOCTETS smiCommunity;
00276
00277     if ( pSession == NULL )
00278         return ( FALSE );
00279
00280     // create a remote session
00281     pSession->hSnmpSession = SnmpOpen( pSession->hWnd, WM_SNMP_INCOMING );
00282
00283     if ( SNMP_FAILURE( pSession->hSnmpSession ) )
00284         return ( FALSE );
00285
00286     if ( gVars.pAgentStrAddr != NULL )
00287     {
00288
00289         // create a remote agent entity
00290         pSession->hAgentEntity = SnmpStrToEntity( pSession->hSnmpSession,
00291                                             inet_ntoa( gVars.agentSockAddr.sin_addr ) );
00292
00293         if ( SNMP_FAILURE( pSession->hAgentEntity ) )
00294             return ( FALSE );
00295
00296         // attach timeout specified with agent
00297         SnmpSetTimeout( pSession->hAgentEntity, gVars.nTimeOut / 10 );
00298
00299         // attach retries specified with agent
00300         SnmpSetRetry( pSession->hAgentEntity, gVars.nRetries );
00301
00302         // create local manager entity
00303         pSession->hManagerEntity = SnmpStrToEntity(
00304                                      pSession->hSnmpSession,
00305                                      DEFAULT_ADDRESS_IP );
00306         if ( SNMP_FAILURE( pSession->hManagerEntity ) )
00307             return ( FALSE );
00308
00309         // attach timeout specified with manager
00310         SnmpSetTimeout( pSession->hManagerEntity, gVars.nTimeOut / 10 );
00311
00312         // attach retries specified with manager
00313         SnmpSetRetry( pSession->hManagerEntity, gVars.nRetries );
00314
00315     } // end of if ( pAgentStrAddr )
00316
00317         // validate pointer
00318     if ( gVars.pAgentCommunity != NULL)
00319     {
00320
00321         // transfer community string
00322         smiCommunity.ptr = (smiLPBYTE)gVars.pAgentCommunity;
00323         smiCommunity.len = gVars.pAgentCommunity ? lstrlen( gVars.pAgentCommunity) : 0;
00324
00325         // obtain context from community string
00326         pSession->hViewContext = SnmpStrToContext(
00327                                      pSession->hSnmpSession,
00328                                      &smiCommunity
00329                                     );
00330
00331         // validate context handle
00332         if ( SNMP_FAILURE( pSession->hViewContext) )
00333             return ( FALSE );
00334
00335     }
00336
00337     // success
00338     return (TRUE);
00339
00340 }  //end of OpenWinSNMP Session
00341
00342
00343 //
00344 // abstarct:   close a WinSNMP session
00345 // input :     pointer to a SNMP_MGR_SESSION
00346 // output:     TRUE if successful, FALSE if not.
00347 //
00348 BOOL    CloseWinSNMPSession ( PSNMP_MGR_SESSION pSession )
00349 {
00350
00351     BOOL fOk = TRUE;
00352     SNMPAPI_STATUS status;
00353
00354     // validate session ptr
00355     if ( pSession == NULL )
00356         return FALSE;
00357
00358     // check if window opened
00359     if ( pSession->hWnd != (HWND)NULL )
00360     {
00361         // destroy notification window
00362         fOk = DestroyNotificationWindow( pSession );
00363     }
00364
00365     // close view context
00366     if ( pSession->hViewContext  != (HSNMP_CONTEXT) NULL)
00367     {
00368         SnmpFreeContext( pSession->hViewContext );
00369     }
00370
00371     // check if agent entity allocated
00372     if ( pSession->hAgentEntity != (HSNMP_ENTITY)NULL )
00373     {
00374
00375         // close the entity handle
00376         status = SnmpFreeEntity( pSession->hAgentEntity );
00377
00378         // validate status
00379         if ( status == SNMPAPI_FAILURE )
00380         {
00381             // failure
00382             fOk = FALSE;
00383         }
00384
00385         // re-initialize
00386         pSession->hAgentEntity = (HSNMP_ENTITY)NULL;
00387     }
00388
00389     // check if manager entity allocated
00390     if ( pSession->hManagerEntity != (HSNMP_ENTITY)NULL )
00391     {
00392
00393         // close the entity handle
00394         status = SnmpFreeEntity( pSession->hManagerEntity );
00395
00396         // validate status
00397         if ( status == SNMPAPI_FAILURE )
00398         {
00399
00400             // failure
00401             fOk = FALSE;
00402         }
00403
00404         // re-initialize
00405         pSession->hManagerEntity = (HSNMP_ENTITY)NULL;
00406     }
00407
00408
00409     // check if session allocated
00410     if ( pSession->hSnmpSession != (HSNMP_SESSION)NULL )
00411     {
00412
00413         // close the winsnmp session
00414         status = SnmpClose( pSession->hSnmpSession );
00415
00416         // validate status
00417         if ( status == SNMPAPI_FAILURE )
00418         {
00419             // failure
00420             fOk = FALSE;
00421         }
00422
00423         // re-initialize
00424         pSession->hSnmpSession = (HSNMP_SESSION)NULL;
00425     }
00426
00427     return fOk;
00428
00429 } // end of CloseWinSNMPSession
00430
00431
00432
00433 //
00434 // abstarct: create a notification window, which will receive WinSnmp messages.
00435 //           The window will remain hidden.
00436 //
00437 // input:    pointer to PSNMP_MGR_SESSION
00438 //
00439 // output:
00440 // TRUE     if successful in creating the window
00441 // FALSE    if not successful in creating the window handle.
00442 //
00443 BOOL    CreateNotificationWindow( PSNMP_MGR_SESSION pSession )
00444 {
00445
00446     BOOL    fOk;
00447     WNDCLASS wc;
00448
00449     if ( pSession == NULL )
00450     {
00451         return FALSE;
00452     }
00453
00454     // initialize notification window class
00455     wc.lpfnWndProc   = (WNDPROC)NotificationWndProc;
00456     wc.lpszClassName = NOTIFICATION_CLASS;
00457     wc.lpszMenuName  = NULL;
00458     wc.hInstance     = gVars.g_hInst;
00459     wc.hIcon         = NULL;
00460     wc.hCursor       = NULL;
00461     wc.hbrBackground = NULL;
00462     wc.cbWndExtra    = sizeof(PSNMP_MGR_SESSION);
00463     wc.cbClsExtra    = 0;
00464     wc.style         = 0;    // register class
00465     fOk = RegisterClass(&wc);
00466
00467     if (!fOk)
00468     {
00469         PrintDbgMessage( "snmputil: RegisterClass returned %d.\n", GetLastError() );
00470         return (FALSE);
00471     }
00472     // create notification window
00473     pSession->hWnd = CreateWindow(
00474                       NOTIFICATION_CLASS,
00475                       "SNMP Util Class",                // pointer to window name
00476                       WS_OVERLAPPEDWINDOW,              // window style
00477                       0,                                // horizontal position of window
00478                       0,                                // vertical position of window
00479                       0,                                // window width
00480                       0,                                // window height
00481                       NULL,                             // handle to parent or owner window
00482                       NULL,                             // handle to menu or child-window identifier
00483                       gVars.g_hInst,                    // handle to application instance
00484                       NULL                              // pointer to window-creation data
00485                     );
00486
00487     // validate window handle
00488     if ( pSession->hWnd != NULL )
00489     {
00490         // store pointer to session in window
00491         SetWindowLongPtr( pSession->hWnd, 0, (INT_PTR)pSession );
00492
00493         // success
00494         fOk = TRUE;
00495     }
00496     else
00497     {
00498         // failure
00499         fOk = FALSE;
00500     }
00501
00502     return fOk;
00503
00504 } // end of CreateNotificationWindow
00505
00506
00507
00508 //
00509 // abstract: destroy the notification window.
00510 // input:    PSNMP_MGR_SESSION pSession
00511 // output:   result of the operation.
00512 //
00513 BOOL    DestroyNotificationWindow( PSNMP_MGR_SESSION pSession )
00514 {
00515     BOOL    fOk;
00516
00517     // destroy the notification window.
00518     return( fOk = DestroyWindow( pSession->hWnd ) );
00519 } // end of DestroyNotificationWindow
00520
00521
00522
00523 //
00524 // abstract
00525 //
00526 //    Callback that processes WinSNMP notifications.
00527 //
00528 // input:
00529 //
00530 //  hWnd - window handle.
00531 //
00532 //  uMsg - message identifier.
00533 //
00534 //  wParam - first message parameter.
00535 //
00536 //  lParam - second message parameter.
00537 //
00538 // return Values:
00539 //
00540 //    The return value is the result of the message processing and
00541 //    depends on the message sent.
00542 //
00543 LRESULT
00544 CALLBACK
00545 NotificationWndProc(
00546     HWND   hWnd,
00547     UINT   uMsg,
00548     WPARAM wParam,
00549     LPARAM lParam
00550     )
00551 {
00552     // check for winsnmp notification
00553     if (uMsg == WM_SNMP_INCOMING)
00554     {
00555
00556         PSNMP_MGR_SESSION pSession;
00557
00558         // retrieve session pointer from window
00559         pSession = (PSNMP_MGR_SESSION)GetWindowLongPtr(hWnd, 0);
00560
00561         // validate session ptr
00562         if ( pSession == NULL )
00563             return (LRESULT)0;
00564
00565         // process notification message
00566         if ( ProcessNotification( pSession ) )
00567         {
00568             // post message to break out of message pump
00569             PostMessage( pSession->hWnd, WM_SNMP_DONE, (WPARAM)0, (LPARAM)0 );
00570         }
00571
00572         return (LRESULT)0;
00573
00574     }
00575     else
00576     {
00577         // forward all other messages to windows
00578         return DefWindowProc(hWnd, uMsg, wParam, lParam);
00579     }
00580
00581 } // end of NotificationWndProc
00582
00583
00584
00585 //
00586 // abstract: we got a notification message back, process it
00587 // input :   pointer to manager session
00588 // output:   TRUE if successful, FALSE if not.
00589 //
00590 BOOL    ProcessNotification( PSNMP_MGR_SESSION pSession )
00591 {
00592
00593     BOOL           fDone = TRUE;
00594     SNMPAPI_STATUS status;
00595     HSNMP_ENTITY   hAgentEntity   = (HSNMP_ENTITY)NULL;
00596     HSNMP_ENTITY   hManagerEntity = (HSNMP_ENTITY)NULL;
00597     HSNMP_CONTEXT  hViewContext   = (HSNMP_CONTEXT)NULL;
00598     smiINT32       nPduType;
00599     smiINT32       nRequestId;
00600     char           szBuf[1024];
00601
00602     // validate pointer
00603     if ( pSession == NULL )
00604         return FALSE;
00605
00606     // retrieve message
00607     status = SnmpRecvMsg(
00608                 pSession->hSnmpSession,
00609                 &hAgentEntity,
00610                 &hManagerEntity,
00611                 &hViewContext,
00612                 &pSession->hPdu
00613                 );
00614
00615     // validate return code
00616     if ( status != SNMPAPI_FAILURE )
00617     {
00618         // retrieve pdu data
00619         status = SnmpGetPduData(
00620                     pSession->hPdu,
00621                     &nPduType,
00622                     &nRequestId,
00623                     &pSession->nErrorStatus,
00624                     &pSession->nErrorIndex,
00625                     &pSession->hVbl
00626                     );
00627
00628         // validate return code
00629         if ( status != SNMPAPI_FAILURE )
00630         {
00631
00632             // process reponse to request
00633             if (nPduType == SNMP_PDU_RESPONSE)
00634             {
00635                 // validate context information
00636                 if (( pSession->nRequestId   == nRequestId ) &&
00637                     ( pSession->hViewContext == hViewContext ) &&
00638                     ( pSession->hAgentEntity == hAgentEntity ) &&
00639                     ( pSession->hManagerEntity == hManagerEntity ) )
00640                 {
00641
00642                     // if we hit the end of tree, break.
00643                     if ( PrintVarBind( pSession ) == FALSE )
00644                         gVars.fDone = TRUE;
00645
00646                 }
00647                 else
00648                 {
00649                     // continue
00650                     fDone = FALSE;
00651                 }
00652
00653             }
00654             else if (nPduType == SNMP_PDU_TRAP)
00655             {
00656
00657                 status = SnmpEntityToStr( hAgentEntity, 1024, szBuf );
00658                 if ( ! (SNMP_FAILURE ( status )  ) )
00659                     PrintDbgMessage( "Agent : %s \n\n", szBuf );
00660
00661                 // Process the TRAP
00662                 ParseAndPrintv2Trap( pSession );
00663
00664             }
00665             else
00666             {
00667                 PrintDbgMessage( "snmputil: Invalid PDU type %d \n", nPduType );
00668                 // continue
00669                 fDone = FALSE;
00670             }
00671
00672         }
00673         else
00674             PrintDbgMessage( "snmputil: SnmpGetPduData returned error %d \n", SnmpGetLastError( pSession->hSnmpSession ) );
00675
00676
00677         // release temporary entity
00678         SnmpFreeEntity(hAgentEntity);
00679
00680         // release temporary entity
00681         SnmpFreeEntity(hManagerEntity);
00682
00683         // release temporary context
00684         SnmpFreeContext(hViewContext);
00685
00686     }
00687
00688     // release pdu
00689     FreeVblandPdu( pSession );
00690
00691     return fDone;
00692
00693 }  //end of ProcessNotification
00694
00695
00696
00697 //
00698 //    abstarct: Sit in an infinite loop waiting for traps.
00699 //    input :   pointer to a snmp mgr session
00700 //    output:   TRUE when a WM_QUIT is sent to pSession->hWnd
00701 //
00702 BOOL    WaitForTraps( PSNMP_MGR_SESSION pSession )
00703 {
00704     SNMPAPI_STATUS    status;
00705
00706     if ( pSession == NULL )
00707         return( FALSE );
00708
00709     // re-iniialize.
00710
00711     pSession->nError = 0;
00712
00713     // register
00714     status = SnmpRegister(
00715                  pSession->hSnmpSession,
00716                 (HSNMP_ENTITY)NULL,     // hManagerEntity
00717                 (HSNMP_ENTITY)NULL,     // hAgentEntity
00718                 (HSNMP_CONTEXT)NULL,    // hViewContext
00719                 (smiLPCOID)NULL,        // notification
00720                 SNMPAPI_ON
00721                 );
00722
00723     if ( SNMP_FAILURE( status ) )
00724     {
00725         pSession->nError = SnmpGetLastError( pSession->hSnmpSession );
00726         PrintDbgMessage( "snmputil: Failed in SnmpRegister %d \n", pSession->nError );
00727         return (FALSE);
00728     }
00729     else
00730     {
00731         printf("WSnmpUtil: listening for traps...\n");
00732         while( ProcessAgentResponse ( pSession ) )
00733         {
00734         }
00735     }
00736     return TRUE;
00737
00738 } //end of WaitForTraps
00739
00740
00741
00742 //
00743 //  abstract: Keep looking for an SNMP message.
00744 //  input:    pointer to SNMP manager session
00745 //  output:   TRUE if successful, FALSE otherwise.
00746 //
00747 BOOL ProcessAgentResponse( PSNMP_MGR_SESSION pSession )
00748 {
00749
00750     MSG        uMsg;
00751     BOOL    fOk = FALSE;
00752
00753     if ( pSession == NULL )
00754         return FALSE;
00755
00756     // get the next message for this session
00757     while ( GetMessage( &uMsg, pSession->hWnd, 0, 0) )
00758     {
00759
00760         // check for private message
00761         if ( uMsg.message != WM_SNMP_DONE)
00762         {
00763             TranslateMessage(&uMsg);
00764             DispatchMessage(&uMsg);
00765         }
00766         else
00767         {
00768             // success
00769             fOk = TRUE;
00770             break;
00771         }
00772     }
00773
00774     return fOk;
00775
00776 } // end of ProcessAgentResponse
00777
00778
00779
00780 //
00781 // abstract: Create a Vbl for different types of PDUS.
00782 // input:    pSession pointer to manager session. pSession->hVbl will have the handle.
00783 //           pOid      pointer to smiOID that will be used.
00784 //           pValue      pointer to a value in a set request.
00785 // output:   TRUE if successful, FALSE if not.
00786 //
00787 BOOL CreateVbl( PSNMP_MGR_SESSION pSession, smiOID *pOid, smiVALUE * pValue  )
00788 {
00789
00790     // check for NULL pointers
00791     if ( ( pOid == NULL )    ||
00792          ( pSession == NULL ) )
00793          return FALSE;
00794
00795     // create the var bind list.
00796     pSession->hVbl = SnmpCreateVbl( pSession->hSnmpSession,
00797                                       pOid,
00798                                     ( ( pSession->nPduType == SNMP_PDU_SET ) ? pValue : NULL ) );
00799
00800     if ( SNMP_FAILURE( pSession->hVbl ) )
00801         return FALSE;
00802     else
00803         return TRUE;
00804
00805 } //end of CreateVbl
00806
00807
00808
00809 // abstract: the routine will free the Vbl and the Pdu associated with a session.
00810 // input:    pSession a pointer to the PSNMP_MGR_SESSION
00811 // output:   none
00812 //
00813 void    FreeVblandPdu( PSNMP_MGR_SESSION pSession )
00814 {
00815     if ( pSession == NULL )
00816         return;
00817
00818     pSession->nError = SnmpFreeVbl( pSession->hVbl );
00819     if ( SNMP_FAILURE( pSession->nError ) )
00820     {
00821         pSession->nError = SnmpGetLastError( pSession->hSnmpSession );
00822         PrintDbgMessage( "snmputil: failure in SnmpFreeVbl %d \n ", pSession->nError );
00823     }
00824
00825
00826     pSession->nError = SnmpFreePdu( pSession->hPdu );
00827     if ( SNMP_FAILURE( pSession->nError ) )
00828     {
00829         pSession->nError = SnmpGetLastError( pSession->hSnmpSession );
00830         PrintDbgMessage( "snmputil: failure in SnmpFreePdu %d \n ", pSession->nError );
00831     }
00832
00833 } // end of FreeVblandPdu
00834
00835
00836 //
00837 // abstarct: create a needed PDU,  send the request and loop in the message loop
00838 //           within the ProcessAgentResponse function until the SNMP reply PDU is
00839 //           processed.
00840 // input:    pointer to PSNMP_MGR_SESSION
00841 // output:   status: TRUE if successful, FALSE otherwise.
00842 //
00843 BOOL    CreatePduSendRequest( PSNMP_MGR_SESSION pSession, smiVALUE *pValue )
00844 {
00845
00846     // check for the validity of the structure.
00847     if ( pSession == NULL )
00848         return (FALSE);
00849
00850     // set the pdu type.
00851     switch ( gVars.operation )
00852     {
00853         case GET:
00854             pSession->nPduType = SNMP_PDU_GET;
00855             break;
00856         case GET_NEXT:
00857             pSession->nPduType = SNMP_PDU_GETNEXT;
00858             break;
00859         case WALK:
00860             pSession->nPduType = SNMP_PDU_GETNEXT;
00861             break;
00862         case SET:
00863             pSession->nPduType = SNMP_PDU_SET;
00864             break;
00865         case SUB_TREE:
00866             pSession->nPduType = SNMP_PDU_GETNEXT;
00867             break;
00868         case GET_BULK:
00869             pSession->nPduType = SNMP_PDU_GETBULK;
00870         default:
00871             break;
00872     }
00873
00874     // first time around, walk: always use the first oid
00875     if ( ( gVars.nRequestId  == 1 ) && ( ( gVars.operation == WALK ) || ( gVars.operation == SUB_TREE ) ) ) // || ( gVars.operation == GET_BULK ) ) )
00876     {
00877         if ( SNMP_FAILURE ( SnmpStrToOid( gVars.pszOid[0] , &gVars.oid ) ) )
00878         {
00879             if ( SnmpMgrStrToOid( gVars.pszOid[0] , (AsnObjectIdentifier *)&gVars.oid ) == FALSE )
00880             {
00881                 PrintDbgMessage( "snmputil: Failed in SnmpStrToOid( ) or SnmpMgrStrToOid( ) function ..\n" );
00882                 return ( FALSE );
00883             }
00884         }
00885         else
00886         {
00887             // copy the var bind
00888             gVars.startOid = gVars.oid;
00889         }
00890     }
00891
00892     // create the appropriate Varbind lists depending on the operation.
00893     if ( ( gVars.operation == WALK ) || ( gVars.operation == SUB_TREE ) )
00894     {
00895         if ( ( CreateVbl( pSession, &gVars.oid, NULL ) ) == FALSE )
00896             return ( FALSE );
00897     }
00898     else if ( ( gVars.operation == GET_NEXT ) || ( gVars.operation == GET ) )
00899     {
00900
00901         if ( SNMP_FAILURE ( SnmpStrToOid( gVars.pszOid[ gVars.nRequestId - 1 ] ,
00902                                       &gVars.oid ) ) )
00903         {
00904             if ( SnmpMgrStrToOid( gVars.pszOid[gVars.nRequestId - 1] , (AsnObjectIdentifier *)&gVars.oid ) == FALSE )
00905             {
00906                 PrintDbgMessage( "snmputil: Failed in SnmpStrToOid( ) or SnmpMgrStrToOid( ) function ..\n" );
00907                 return ( FALSE );
00908             }
00909         }
00910
00911         if ( ( CreateVbl( pSession, &gVars.oid, NULL ) ) == FALSE )
00912                 return ( FALSE );
00913
00914     }
00915     else if ( gVars.operation == SET )
00916     {
00917         pSession->hVbl = SnmpCreateVbl( pSession->hSnmpSession,
00918                                         &gVars.oid,
00919                                         pValue
00920                                         );
00921        }
00922
00923     else if ( gVars.operation == GET_BULK )
00924     {
00925         //CreateVbl first then add OIDs to the Vbl
00926         pSession->hVbl =
00927             SnmpCreateVbl(  pSession->hSnmpSession,  // handle to the WinSNMP session
00928                             NULL,                    // pointer to the variable name
00929                             NULL                     // pointer to the value to associate with the variable
00930                             );
00931
00932
00933         if ( SNMP_FAILURE( pSession->hVbl ) )
00934             return (FALSE);
00935         for (int i = 0; i < gVars.oidCount; i++)
00936         {
00937             //the very last gVars.oid in the loop will be freed later.
00938             if (i > 0)
00939             {
00940                     SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&gVars.oid);
00941             }
00942
00943             if ( SNMP_FAILURE ( SnmpStrToOid( gVars.pszOid[i] , &gVars.oid ) ) )
00944             {
00945                 if ( SnmpMgrStrToOid( gVars.pszOid[i] , (AsnObjectIdentifier *)&gVars.oid ) == FALSE )
00946                 {
00947                     PrintDbgMessage( "snmputil: Failed in SnmpStrToOid( ) or SnmpMgrStrToOid( ) function ..\n" );
00948                     return ( FALSE );
00949                 }
00950             }
00951             // append vb to Vbl
00952             if ( SNMP_FAILURE ( SnmpSetVb(pSession->hVbl,    0, &gVars.oid, NULL    ) ) )
00953             {
00954                 PrintDbgMessage( "snmputil: Failed in SnmpSetVb( ) function ..\n" );
00955                 return ( FALSE );
00956             }
00957         }
00958
00959     }
00960
00961
00962     pSession->nRequestId = gVars.nRequestId++;
00963
00964     // create a pdu using the parameters in pSession structure
00965     pSession->hPdu = SnmpCreatePdu( pSession->hSnmpSession,
00966                                       pSession->nPduType,
00967                                       pSession->nRequestId,
00968                                       ( ( gVars.operation == GET_BULK ) ? gVars.non_repeaters : 0 ),
00969                                       ( ( gVars.operation == GET_BULK ) ? gVars.max_repetitions : 0 ),
00970                                       pSession->hVbl );
00971
00972     if ( SNMP_FAILURE ( pSession->hPdu ) )
00973     {
00974         PrintDbgMessage( "snmputil: Failed in creating PDU ..\n " );
00975         return (FALSE);
00976     }
00977
00978     // send the message to the agent
00979     pSession->nError = SnmpSendMsg(    pSession->hSnmpSession,
00980                                         pSession->hManagerEntity,
00981                                         pSession->hAgentEntity,
00982                                         pSession->hViewContext,
00983                                         pSession->hPdu );
00984
00985     if ( gVars.operation != SUB_TREE ) SnmpFreeDescriptor ( SNMP_SYNTAX_OID, (smiLPOPAQUE)&gVars.oid);
00986
00987
00988     // check error status and return.
00989     if ( SNMP_FAILURE( pSession->nError ) )
00990     {
00991
00992          pSession->nError = SnmpGetLastError( pSession->hSnmpSession );
00993          PrintDbgMessage( "snmputil: Failed in send message, Last Error %d \n", pSession->nError );
00994          FreeVblandPdu( pSession );
00995          return (FALSE);
00996     }
00997     else
00998     {
00999
01000         FreeVblandPdu( pSession );
01001         return ( ProcessAgentResponse ( pSession ) );
01002     }
01003
01004 } //end of CreatePduSendRequest
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllSkel/DllSkelI.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllSkel

DllSkelI.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DLLSKELI.H
00003
00004   Summary:   Internal include file for the DLLSKEL.DLL skeleton code sample.
00005              Contains class declarations, Resource IDs and string macros for
00006              internal use in constructing this DLL.  Instead of one
00007              DLLSKEL.H we split what would be the content of that file
00008              into two files.  One file, DLLSKEL.H has only the external
00009              definitions needed for outside use of the DLL.  The other file,
00010              this current DLLSKELI.H has definitions not needed by external
00011              users of the DLL but needed for internal use.
00012
00013              For a comprehensive tutorial code tour of DLLSKEL's
00014              contents and offerings see the tutorial DLLSKEL.HTM file.
00015              For more specific technical details on the internal workings
00016              see the comments dispersed throughout the DLLSKEL source code.
00017
00018   Classes:   none
00019
00020   Functions: none
00021
00022   Origin:    8-5-95: atrent - Editor-inheritance from the EXESKEL source.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 #if !defined(DLLSKELI_H)
00040 #define DLLSKELI_H
00041
00042
00043 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00044   Class:    CDllData
00045
00046   Summary:  Class to encapsulate global data of a the DLL.
00047
00048   Methods:  none
00049 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00050 class CDllData
00051 {
00052 public:
00053   // A place to store the loaded instance of this DLL module.
00054   HINSTANCE hDllInst;
00055
00056   // A place in this instance data to save this DLL's user count.
00057   int iUserCount;
00058
00059   // A Pointer to a Message Box object.
00060   CMsgBox* pMsgBox;
00061 };
00062
00063
00064 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00065   Class:    CDllShared
00066
00067   Summary:  Class to encapsulate shared data of a the DLL.
00068
00069   Methods:  none
00070 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00071 class CDllShared
00072 {
00073 public:
00074   // The hello counter. A global shared counter that is Incremented
00075   // by all DLL users
00076   int iHelloCount;
00077
00078   // The global data instance counter. A count of the Processes that attach.
00079   int iUserCount;
00080 };
00081
00082 // String Macros.
00083 #define ABOUT_TITLE_STR "DLLSKEL: Tutorial Code Sample"
00084
00085 // Dialog IDs.
00086 #define IDD_ABOUTBOX                1000
00087
00088 // Error-related String Identifiers.
00089 #define IDS_COMINITFAILED           2000
00090 #define IDS_DLLINITFAILED           2001
00091 #define IDS_OUTOFMEMORY             2002
00092 #define IDS_NOHELPFILE              2003
00093
00094 #define IDS_ASSERT_FAIL             2200
00095
00096 // Notice-related String Identifiers.
00097 #define IDS_NOTIMPLEMENTED          2301
00098 #define IDS_HELLOCOUNTFMT           2302
00099 #define IDS_HELLOTITLE              2303
00100
00101 #endif
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/CLOSQDlg.h Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

CLOSQDlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // ClosQDlg.h : header file
00013 //
00014
00015
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CCloseQueueDialog dialog
00019
00020 class CCloseQueueDialog : public CDialog
00021 {
00022 // Construction
00023 public:
00024   CCloseQueueDialog(CArray <ARRAYQ*, ARRAYQ*>*, CWnd* pParent = NULL);   // standard constructor
00025
00026 // Dialog Data
00027   //{{AFX_DATA(CCloseQueueDialog)
00028   enum { IDD = IDD_CLOSE_QUEUE_DIALOG };
00029   CComboBox m_PathNameCB;
00030   CString m_szPathName;
00031   //}}AFX_DATA
00032
00033   /* pointer to the array with the strings for the combo box (Queues PathName). */
00034   CArray <ARRAYQ*, ARRAYQ*>* m_pStrArray ;
00035
00036 // Overrides
00037   // ClassWizard generated virtual function overrides
00038   //{{AFX_VIRTUAL(CCloseQueueDialog)
00039   protected:
00040   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00041   //}}AFX_VIRTUAL
00042
00043 // Implementation
00044 protected:
00045
00046   // Generated message map functions
00047   //{{AFX_MSG(CCloseQueueDialog)
00048   virtual BOOL OnInitDialog();
00049   //}}AFX_MSG
00050   DECLARE_MESSAGE_MAP()
00051
00052 public:
00053   void GetPathName(TCHAR szPathName[BUFFERSIZE])
00054   {
00055     ASSERT(szPathName != NULL);
00056
00057     _tcsncpy (szPathName, m_szPathName, BUFFERSIZE-1);
00058     szPathName[BUFFERSIZE-1] = '\0';
00059
00060   }
00061
00062 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagMETHODARGS Member List

This is the complete list of members for _tagMETHODARGS, including all inherited members.
DeleteLogErrorMsg | _tagMETHODARGS
dwWorkerMsg | _tagMETHODARGS
EnableModelessMsg | _tagMETHODARGS
EstablishConnectionMsg | _tagMETHODARGS
fAsync | _tagMETHODARGS
hr | _tagMETHODARGS
LogErrorMsg | _tagMETHODARGS
PrepareForSyncCompletedMsg | _tagMETHODARGS
PrepareForSyncMsg | _tagMETHODARGS
ProgressMsg | _tagMETHODARGS
ShowErrorCompletedMsg | _tagMETHODARGS
ShowErrorMsg | _tagMETHODARGS
ShowPropertiesCompletedMsg | _tagMETHODARGS
ShowPropertiesMsg | _tagMETHODARGS
SynchronizeCompletedMsg | _tagMETHODARGS
SynchronizeMsg | _tagMETHODARGS
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/ContextPlugin.h Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification

ContextPlugin.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       ContextPlugin.h
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011 #pragma once
00012
00013 #include "resource.h"       // main symbols
00014
00015 #include "wmsdefs.h"
00016
00017 typedef struct ContextNameHint
00018 {
00019     LPCWSTR wstrContextName;
00020     long lContextHint;
00021 } ContextNameHint;
00022
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 // CContextPlugin
00026 class ATL_NO_VTABLE CContextPlugin :
00027     public CComObjectRootEx<CComMultiThreadModel>,
00028     public CComCoClass<CContextPlugin, &CLSID_WMSContextPlugin>,
00029     public IWMSEventNotificationPlugin,
00030     public IWMSBasicPlugin,
00031     public IWMSContextPlugin
00032 {
00033
00034 public:
00035     CContextPlugin();
00036     ~CContextPlugin();
00037
00038 DECLARE_REGISTRY_RESOURCEID(IDR_CONTEXTPLUGIN)
00039
00040 DECLARE_PROTECT_FINAL_CONSTRUCT()
00041
00042 BEGIN_COM_MAP(CContextPlugin)
00043         COM_INTERFACE_ENTRY(IWMSEventNotificationPlugin)
00044         COM_INTERFACE_ENTRY(IWMSBasicPlugin)
00045         COM_INTERFACE_ENTRY(IWMSContextPlugin)
00046 END_COM_MAP()
00047
00048 public:
00049
00050     // IWMSBasicPlugin
00051     STDMETHOD( InitializePlugin )( IWMSContext *pServerContext, IWMSNamedValues *pNamedValues, IWMSClassObject *pClassFactory );
00052     STDMETHOD( OnHeartbeat )( );
00053     STDMETHOD( GetCustomAdminInterface )( IDispatch **ppValue );
00054     STDMETHOD( ShutdownPlugin )();
00055     STDMETHOD( EnablePlugin ) ( long *pdwFlags, long *pdwHeartbeatPeriod );
00056     STDMETHOD( DisablePlugin )();
00057
00058     // IWMSEventNotificationPlugin
00059     STDMETHOD( GetHandledEvents )( VARIANT *pvarHandledEvents );
00060     STDMETHOD( OnEvent )( WMS_EVENT *pEvent, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00061
00062     HRESULT SetOutputPath( BSTR bstrOutputPath );
00063     HRESULT GetOutputPath( BSTR *pbstrOutputPath );
00064
00065     HRESULT SetContextTypes( WMS_CONTEXT_PLUGIN_CONTEXT_TYPE wmsContexts )
00066     {
00067         if( ( 0 > wmsContexts )
00068             || ( ( 2 * WMS_CONTEXT_PLUGIN_COMMAND_RESPONSE_CONTEXT ) <= wmsContexts ) )
00069         {
00070             return( E_INVALIDARG );
00071         }
00072         m_wmsContexts = wmsContexts;
00073         return( S_OK );
00074     };
00075     HRESULT GetContextTypes( WMS_CONTEXT_PLUGIN_CONTEXT_TYPE *wmsContexts )
00076     {
00077         HRESULT hr = E_POINTER;
00078         if( NULL != wmsContexts )
00079         {
00080             *wmsContexts = m_wmsContexts;
00081             hr = S_OK;
00082         }
00083         return( hr );
00084     };
00085
00086 private:
00087     // Notification Helper Functions
00088     HRESULT OnNotifyConnect( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00089     HRESULT OnNotifyDisconnect( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00090     HRESULT OnNotifyBeginUserSession( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00091     HRESULT OnNotifyEndUserSession( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00092     HRESULT OnNotifyDescribe( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00093     HRESULT OnNotifyOpen( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00094     HRESULT OnNotifySelectStreams( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00095     HRESULT OnNotifyPlay( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00096     HRESULT OnNotifyPause( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00097     HRESULT OnNotifyStop( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00098     HRESULT OnNotifyClose( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00099     HRESULT OnNotifySetParameter( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00100     HRESULT OnNotifyGetParameter( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00101     HRESULT OnNotifyValidatePushDistribution( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00102     HRESULT OnNotifyCreateDistributionDataPath( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00103     HRESULT OnNotifyDestroyDistributionDataPath( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00104     HRESULT OnNotifyLog( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00105     HRESULT OnNotifyServer( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00106     HRESULT OnNotifyPublishingPoint( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00107     HRESULT OnNotifyLimitChange( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00108     HRESULT OnNotifyLimitHit( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00109     HRESULT OnNotifyPlugin( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00110     HRESULT OnNotifyPlaylist( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00111     HRESULT OnNotifyCache( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00112     HRESULT OnNotifyRemoteCacheOpen( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00113     HRESULT OnNotifyRemoteCacheClose( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00114     HRESULT OnNotifyRemoteCacheLog( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00115
00116     // Private Member Functions
00117     HRESULT CreateArrayOfEvents( VARIANT *pvarEvents, WMS_EVENT_TYPE *pWMSEvents, long nNumEvents);
00118
00119     // Helper Functions
00120     HRESULT DumpContextInformation( LPCWSTR wstrEventType, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandContext );
00121     HRESULT WriteContextInformation( HANDLE hFile, IWMSContext *pContext );
00122
00123     // Data Storage Functions
00124     HRESULT LoadConfigValues();
00125     HRESULT SaveConfigValues();
00126
00127
00128 private:
00129     // Private Member Variables
00130     IWMSServer                          *m_pServer;
00131     IWMSNamedValues                     *m_pNamedValues;
00132     WMS_CONTEXT_PLUGIN_CONTEXT_TYPE     m_wmsContexts;
00133     BSTR                                m_bstrOutputPath;
00134
00135     static const ContextNameHint s_UserContextHintValues[];
00136     static const ContextNameHint s_PresentationContextHintValues[];
00137     static const ContextNameHint s_CommandContextHintValues[];
00138
00139     static WCHAR *s_wstrNamedValueOutputPath;
00140     static WCHAR *s_wstrNamedValueContextTypes;
00141
00142 };
00143
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/land.Cpp Source File

  • SysMgmt
  • MMC
  • Openserv

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/adddevicedlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

adddevicedlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddDeviceDlg.cpp:  Implementation of the CAddDeviceDlg class.
00015 //
00016
00017
00018
00019 #include "AddDeviceDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddDeviceDlg::CAddDeviceDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddDeviceDlg::~CAddDeviceDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddDeviceDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00055   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00056
00057   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00060   lResult = SendMessage( hBackupCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00061   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00062
00063   lResult = SetWindowText( hDevNameCtrl, _T("") );
00064   SetFocus( hDevNameCtrl );
00065
00066   return 0;
00067 }
00068
00069 //---------------------------------------------------------------------------
00070 LRESULT CAddDeviceDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00071 {
00072   LRESULT          lResult = 0;
00073   NODE_PROPERTIES  NodeProps;
00074
00075   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00076
00077   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00078   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00079   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00080   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00081   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00082   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00083
00084   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00086
00087   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00089
00090   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00092
00093   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00094     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00095
00096   if( BST_CHECKED == SendMessage( hBackupCtrl, BM_GETCHECK, 0, 0 ) )
00097     NodeProps.dwAttributes |= ATTRIBUTE_BACKUP_DEVICE;
00098
00099   // Convert to wide characters here for all platforms.  This is the node name
00100   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00101   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00102   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00103   // Probably a good idea to check for NULL name strings here
00104
00105   // This message passes the user supplied info to the Static Node
00106   SendMessage( m_hParentWnd, WM_ADD_DEVICENODE, (WPARAM)&NodeProps, 0 );
00107
00108   // Now tell the static node we are deleting ourselves so the
00109   // context menu option can be enabled
00110   SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00111
00112   // Call the base class to shut down the dialog
00113   CBaseDialog::OnOK( hDlg, wParam, lParam );
00114   return 0;
00115 }
00116
00117 /////////////////////////////////////////////////////////////////////////////
00118 //  Virtual function implementations
00119
00120 //---------------------------------------------------------------------------
00121 BOOL CAddDeviceDlg::ProcessMessage
00122 (
00123   HWND     hDlg,           //[in] Handle to dialog box
00124   UINT     uMsg,           //[in] Message
00125   WPARAM   wParam,         //[in] First message parameter
00126   LPARAM   lParam          //[in] Second message parameter
00127 )
00128 {
00129   LRESULT lResult = 0;
00130
00131   switch( uMsg )
00132   {
00133     case WM_INITDIALOG:
00134       lResult = OnInitDialog( hDlg, wParam, lParam );
00135       break;
00136
00137     case WM_DESTROY:
00138       lResult = OnDestroy( hDlg, wParam, lParam );
00139       break;
00140
00141     case WM_NCDESTROY:
00142       lResult = OnNcDestroy( hDlg, wParam, lParam );
00143       break;
00144
00145     case WM_CLOSE:
00146       // Not overriding WM_CLOSE and IDCANCEL so we must send
00147       // WM_DEVICENODE_CLOSED before calling the base class or else
00148       // the context menu will stay grayed
00149       SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00150       lResult = OnClose( hDlg, wParam, lParam );
00151
00152     case WM_COMMAND:
00153       switch( wParam )
00154       {
00155         case IDOK:
00156           lResult = OnOK( hDlg, wParam, lParam );
00157           break;
00158
00159         case IDCANCEL:
00160           SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00161           lResult = OnCancel( hDlg, wParam, lParam );
00162           break;
00163
00164         default:
00165           break;
00166       }
00167     default:
00168       break;
00169   }
00170   return (BOOL)lResult;
00171 }
00172
00173
00174
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/basedialog.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

basedialog.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  BaseDialog.cpp: implementation of the CBaseDialog class.
00014 //
00015
00016 #include "BaseDialog.h"
00017 #include "Globals.h"
00018
00019
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // Construction/Destruction
00023
00024 //---------------------------------------------------------------------------
00025 CBaseDialog::CBaseDialog( ULONG nTemplate )
00026 {
00027   _ASSERT( NULL != nTemplate );
00028
00029   m_nTemplate = nTemplate;
00030   m_hWnd      = NULL;          // Handle returned by CreateDialogParam
00031   m_DlgProc   = DlgProc;       // Point to default dialog proc
00032   m_dwFlags   = 0;
00033 }
00034
00035 //---------------------------------------------------------------------------
00036 CBaseDialog::~CBaseDialog()
00037 {
00038 }
00039
00040 //---------------------------------------------------------------------------
00041 //  Use CreateDialogParam rather than CreateDialog so that we can later
00042 //  retrieve the 'this' pointer which we will need to point back to the
00043 //  particular instance of this class.
00044 //
00045 HWND CBaseDialog::Create
00046 (
00047   HINSTANCE  hInstance,      //[in] Global instance handle
00048   HWND       hWndParent,     //[in] Handle to parent window
00049   DWORD      dwFlags         //[in] Create flags - not used
00050 )
00051 {
00052   _ASSERT( NULL != hInstance );
00053
00054   m_dwFlags = dwFlags;
00055   m_hWnd = CreateDialogParam( hInstance,
00056                               MAKEINTRESOURCE(m_nTemplate),
00057                               hWndParent,
00058                               m_DlgProc,
00059                               (LPARAM)this
00060                             );
00061
00062   BOOL bReturn = ShowWindow( m_hWnd, SW_SHOW );  // Should return 0
00063
00064   return m_hWnd;
00065 }
00066
00067
00068 /////////////////////////////////////////////////////////////////////////////
00069 //  Message Handlers
00070
00071 //---------------------------------------------------------------------------
00072 LRESULT CBaseDialog::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00073 {
00074   return 1;
00075 }
00076
00077 //---------------------------------------------------------------------------
00078 //  This is the first message sent by the DetroyWindow() function.
00079 //  It is sent after the window is removed from the screen, but it should
00080 //  be assumed that any child windows still exist.
00081 //
00082 LRESULT CBaseDialog::OnDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam )
00083 {
00084   return 1;
00085 }
00086
00087 //---------------------------------------------------------------------------
00088 //  This is sent after WM_DESTROY, and informs the app that the non-client
00089 //  area is being destroyed.  This is where allocated resources should be
00090 //  cleaned up.
00091 //
00092 LRESULT CBaseDialog::OnNcDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam )
00093 {
00094   m_hWnd = NULL;             // Since this is a modeless-only dialog
00095   delete this;               // class we delete ourselves here
00096
00097   return 1;
00098 }
00099
00100 //---------------------------------------------------------------------------
00101 LRESULT CBaseDialog::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00102 {
00103   return DestroyWindow( m_hWnd);
00104 }
00105
00106 //---------------------------------------------------------------------------
00107 LRESULT CBaseDialog::OnCancel( HWND hDlg, WPARAM wParam, LPARAM lParam )
00108 {
00109   return DestroyWindow( m_hWnd);
00110 }
00111
00112 //---------------------------------------------------------------------------
00113 LRESULT CBaseDialog::OnClose( HWND hDlg, WPARAM wParam, LPARAM lParam )
00114 {
00115   return DestroyWindow( m_hWnd);
00116 }
00117
00118
00119 /////////////////////////////////////////////////////////////////////////////
00120 //  Dialog Procedures
00121
00122 //---------------------------------------------------------------------------
00123 //  Since this is a static function we can't use a 'this' pointer or call
00124 //  the base class directly.  There may be multiple base classes using
00125 //  this method.  We get around this by storing the 'this' pointer in the
00126 //  lParam of CreateDialogParam.  When we get WM_INITDIALOG we get this
00127 //  pointer back in the lParam.  Now we can use SetWindowLongPtr to store
00128 //  it, and later retireve it with GetWindowLongPtr.  Once we have a
00129 //  valid 'this' pointer we can cast it back to the base class and then
00130 //  call the base class's ProcessMessage function.
00131 //
00132 BOOL CALLBACK CBaseDialog::DlgProc
00133 (
00134   HWND     hDlg,           //[in] Handle to dialog box
00135   UINT     uMsg,           //[in] Message
00136   WPARAM   wParam,         //[in] First message parameter
00137   LPARAM   lParam          //[in] Second message parameter
00138 )
00139 {
00140   BOOL bReturn = FALSE;
00141   if( WM_INITDIALOG == uMsg )
00142   {
00143     SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
00144   }
00145
00146   CBaseDialog* pThis = reinterpret_cast<CBaseDialog*>(GetWindowLongPtr(hDlg, GWL_USERDATA));
00147   if( NULL != pThis )
00148   {
00149     bReturn = pThis->ProcessMessage( hDlg, uMsg, wParam, lParam );
00150   }
00151
00152   return bReturn;
00153 }
00154
00155 //---------------------------------------------------------------------------
00156 //  This is the instance specific method used to process messages.  The
00157 //  DialogProc delegates this responsibiliy to each instance of the class.
00158 //  This is a pure virtual function.  The code below is provided to cut
00159 //  and paste into the derived class's implementation.
00160 /*
00161 BOOL CBaseDialog::ProcessMessage
00162 (
00163   HWND     hDlg,           //[in] Handle to dialog box
00164   UINT     uMsg,           //[in] Message
00165   WPARAM   wParam,         //[in] First message parameter
00166   LPARAM   lParam          //[in] Second message parameter
00167 )
00168 {
00169   LRESULT lResult = 0;
00170   switch( uMsg )
00171   {
00172     case WM_INITDIALOG:
00173       lResult = OnInitDialog( hDlg, wParam, lParam );
00174       break;
00175
00176     case WM_DESTROY:
00177       lResult = OnDestroy( hDlg, wParam, lParam );
00178       break;
00179
00180     case WM_NCDESTROY:
00181       lResult = OnNcDestroy( hDlg, wParam, lParam );
00182       break;
00183
00184     case WM_CLOSE:
00185       lResult = OnClose( hDlg, wParam, lParam );
00186
00187     case WM_COMMAND:
00188       switch( wParam )
00189       {
00190         case IDOK:
00191           lResult = OnOK( hDlg, wParam, lParam );
00192           break;
00193
00194         case IDCANCEL:
00195           lResult = OnCancel( hDlg, wParam, lParam );
00196           break;
00197
00198         default:
00199           break;
00200       }
00201     default:
00202       break;
00203   }
00204   return (BOOL)lResult;
00205 }
00206 */
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ADOVtbl Member List

This is the complete list of members for _ADOVtbl, including all inherited members.
cNames | _ADOVtbl
dispIdMember | _ADOVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(_ADO __RPC_FAR *This | _ADOVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(_ADO __RPC_FAR *This | _ADOVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(_ADO __RPC_FAR *This | _ADOVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(_ADO __RPC_FAR *This | _ADOVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(_ADO __RPC_FAR *This | _ADOVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Properties)(_ADO __RPC_FAR *This | _ADOVtbl
iTInfo | _ADOVtbl
lcid | _ADOVtbl
lcid | _ADOVtbl
lcid | _ADOVtbl
pctinfo | _ADOVtbl
pDispParams | _ADOVtbl
pExcepInfo | _ADOVtbl
ppTInfo | _ADOVtbl
ppvObject | _ADOVtbl
ppvObject | _ADOVtbl
puArgErr | _ADOVtbl
pVarResult | _ADOVtbl
rgDispId | _ADOVtbl
rgszNames | _ADOVtbl
riid | _ADOVtbl
riid | _ADOVtbl
riid | _ADOVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(_ADO __RPC_FAR *This) | _ADOVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(_ADO __RPC_FAR *This) | _ADOVtbl
wFlags | _ADOVtbl
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/OLEObj.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

OLEObj.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          OleObj.cpp
00021
00022   Description:   COleObject implementation.
00023
00024 **************************************************************************/
00025
00026 /**************************************************************************
00027 #include statements
00028 **************************************************************************/
00029
00030 #include "OleObj.h"
00031
00032 /**************************************************************************
00033
00034   COleObject::COleObject()
00035
00036 **************************************************************************/
00037
00038 COleObject::COleObject(COleDocument *pOleDoc)
00039 {
00040   OutputDebugString(TEXT("COleObject's constructor\n"));
00041
00042   m_pOleDoc = pOleDoc;
00043
00044   m_fOpen = FALSE;
00045 }
00046
00047 /**************************************************************************
00048
00049   COleObject::~COleObject()
00050
00051 **************************************************************************/
00052
00053 COleObject::~COleObject()
00054 {
00055   OutputDebugString(TEXT("COleObject's destructor\n"));
00056 }
00057
00058 /**************************************************************************
00059
00060   COleObject::QueryInterface()
00061
00062 **************************************************************************/
00063
00064 STDMETHODIMP COleObject::QueryInterface(REFIID riid, LPVOID *ppReturn)
00065 {
00066   OutputDebugString(TEXT("COleObject::QueryInterface\n"));
00067
00068   return m_pOleDoc->QueryInterface(riid, ppReturn);
00069 }
00070
00071 /**************************************************************************
00072
00073   COleObject::AddRef()
00074
00075 **************************************************************************/
00076
00077 STDMETHODIMP_(ULONG) COleObject::AddRef()
00078 {
00079   OutputDebugString(TEXT("COleObject::AddRef\n"));
00080
00081   return m_pOleDoc->AddRef();
00082 }
00083
00084 /**************************************************************************
00085
00086   COleObject::Release()
00087
00088 **************************************************************************/
00089
00090 STDMETHODIMP_(ULONG) COleObject::Release()
00091 {
00092   OutputDebugString(TEXT("COleObject::Release\n"));
00093
00094   return m_pOleDoc->Release();
00095 }
00096
00097 /**************************************************************************
00098
00099   COleObject::DoVerb()
00100
00101 **************************************************************************/
00102
00103 STDMETHODIMP COleObject::DoVerb( LONG iVerb,
00104                 LPMSG lpmsg,
00105                 LPOLECLIENTSITE pActiveSite,
00106                 LONG lindex,
00107                 HWND hwndParent,
00108                 LPCRECT lprcPosRect)
00109 {
00110   UNREFERENCED_PARAMETER(lpmsg);
00111   UNREFERENCED_PARAMETER(lindex);
00112   UNREFERENCED_PARAMETER(hwndParent);
00113   UNREFERENCED_PARAMETER(lprcPosRect);
00114   OutputDebugString(TEXT("COleObject::DoVerb\n"));
00115
00116   HRESULT  hr = E_FAIL;
00117
00118   switch (iVerb)
00119   {
00120   case OLEIVERB_SHOW:
00121   case OLEIVERB_PRIMARY:
00122   case OLEIVERB_UIACTIVATE:
00123     {
00124       //try to get the IOleDocumentSite pointer
00125       LPOLEDOCUMENTSITE pOleDocSite;
00126       hr = pActiveSite->QueryInterface(IID_IOleDocumentSite, (LPVOID*)&pOleDocSite);
00127       if(SUCCEEDED(hr))
00128       {
00129         //passing NULL to this will cause the site to call our CreateView method
00130         hr = pOleDocSite->ActivateMe(NULL);
00131       }
00132     }
00133     break;
00134
00135   default:
00136     break;
00137   }
00138
00139   return hr;
00140 }
00141
00142 /**************************************************************************
00143
00144   COleObject::GetClientSite()
00145
00146 **************************************************************************/
00147
00148 STDMETHODIMP COleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite)
00149 {
00150   OutputDebugString(TEXT("COleObject::GetClientSite\n"));
00151
00152   *ppClientSite = m_pOleDoc->m_pOleClientSite;
00153
00154   return S_OK;
00155 }
00156
00157 /**************************************************************************
00158
00159   COleObject::SetClientSite()
00160
00161 **************************************************************************/
00162
00163 STDMETHODIMP COleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
00164 {
00165   OutputDebugString(TEXT("COleObject::SetClientSite\n"));
00166
00167   // if we already have a client site, release it.
00168   if(m_pOleDoc->m_pOleClientSite)
00169   {
00170     m_pOleDoc->m_pOleClientSite->Release();
00171     m_pOleDoc->m_pOleClientSite = NULL;
00172   }
00173
00174   // store copy of the client site.
00175   m_pOleDoc->m_pOleClientSite = pClientSite;
00176
00177   // AddRef it so it doesn't go away.
00178   if(m_pOleDoc->m_pOleClientSite)
00179     m_pOleDoc->m_pOleClientSite->AddRef();
00180
00181   return S_OK;
00182 }
00183
00184 /**************************************************************************
00185
00186   COleObject::Advise()
00187
00188 **************************************************************************/
00189
00190 STDMETHODIMP COleObject::Advise(LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00191 {
00192   OutputDebugString(TEXT("COleObject::Advise\n"));
00193
00194   // if we haven't made an OleAdviseHolder yet, make one.
00195   if(!m_pOleDoc->m_pOleAdviseHolder)
00196     CreateOleAdviseHolder(&m_pOleDoc->m_pOleAdviseHolder);
00197
00198   // pass this call onto the OleAdviseHolder.
00199   return m_pOleDoc->m_pOleAdviseHolder->Advise(pAdvSink, pdwConnection);
00200 }
00201
00202 /**************************************************************************
00203
00204   COleObject::Unadvise()
00205
00206 **************************************************************************/
00207
00208 STDMETHODIMP COleObject::Unadvise(DWORD dwConnection)
00209 {
00210   OutputDebugString(TEXT("COleObject::Unadvise\n"));
00211
00212   // pass on to OleAdviseHolder.
00213   return m_pOleDoc->m_pOleAdviseHolder->Unadvise(dwConnection);
00214 }
00215
00216 /**************************************************************************
00217
00218   COleObject::SetHostNames()
00219
00220 **************************************************************************/
00221
00222 STDMETHODIMP COleObject::SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
00223 {
00224   UNREFERENCED_PARAMETER(szContainerApp);
00225   UNREFERENCED_PARAMETER(szContainerObj);
00226   OutputDebugString(TEXT("COleObject::SetHostNames\n"));
00227
00228   return S_OK;
00229 }
00230
00231 /**************************************************************************
00232
00233   COleObject::GetExtent()
00234
00235 **************************************************************************/
00236
00237 STDMETHODIMP COleObject::GetExtent(DWORD dwDrawAspect, LPSIZEL lpsizel)
00238 {
00239   UNREFERENCED_PARAMETER(dwDrawAspect);
00240   UNREFERENCED_PARAMETER(lpsizel);
00241   OutputDebugString(TEXT("COleObject::GetExtent\n"));
00242
00243   return E_NOTIMPL;
00244 }
00245
00246 /**************************************************************************
00247
00248   COleObject::SetExtent()
00249
00250 **************************************************************************/
00251
00252 STDMETHODIMP COleObject::SetExtent(DWORD dwDrawAspect, LPSIZEL lpsizel)
00253 {
00254   UNREFERENCED_PARAMETER(dwDrawAspect);
00255   UNREFERENCED_PARAMETER(lpsizel);
00256   OutputDebugString(TEXT("COleObject::SetExtent\n"));
00257
00258   return E_NOTIMPL;
00259 }
00260
00261 /**************************************************************************
00262
00263   COleObject::Update()
00264
00265 **************************************************************************/
00266
00267 STDMETHODIMP COleObject::Update()
00268 {
00269   OutputDebugString(TEXT("COleObject::Update\n"));
00270
00271   return S_OK;
00272 }
00273
00274 /**************************************************************************
00275
00276   COleObject::Close()
00277
00278 **************************************************************************/
00279
00280 STDMETHODIMP COleObject::Close(DWORD dwSaveOption)
00281 {
00282   OutputDebugString(TEXT("COleObject::Close\n"));
00283
00284   switch(dwSaveOption)
00285   {
00286   case OLECLOSE_SAVEIFDIRTY:
00287     if(m_pOleDoc->m_fDirty)
00288     {
00289       m_pOleDoc->m_pPersistStorage->Save(NULL, TRUE);
00290     }
00291     break;
00292
00293   case OLECLOSE_NOSAVE:
00294     break;
00295
00296   case OLECLOSE_PROMPTSAVE:
00297     break;
00298   }
00299
00300   //close the view
00301   m_pOleDoc->m_pOleDocView->CloseView(0);
00302
00303   return S_OK;
00304 }
00305
00306 /**************************************************************************
00307
00308   COleObject::EnumVerbs()
00309
00310 **************************************************************************/
00311
00312 STDMETHODIMP COleObject::EnumVerbs(LPENUMOLEVERB *ppenumOleVerb)
00313 {
00314   UNREFERENCED_PARAMETER(ppenumOleVerb);
00315   OutputDebugString(TEXT("COleObject::EnumVerbs\n"));
00316
00317   return OLE_S_USEREG;
00318 }
00319
00320 /**************************************************************************
00321
00322   COleObject::SetMoniker()
00323
00324 **************************************************************************/
00325
00326 STDMETHODIMP COleObject::SetMoniker(DWORD dwWhichMoniker, LPMONIKER pMoniker)
00327 {
00328   UNREFERENCED_PARAMETER(dwWhichMoniker);
00329   UNREFERENCED_PARAMETER(pMoniker);
00330   OutputDebugString(TEXT("COleObject::SetMoniker\n"));
00331
00332   LPMONIKER pTempMoniker;
00333
00334   if(!m_pOleDoc->m_pOleClientSite)
00335     return E_FAIL;
00336
00337   if(NOERROR != m_pOleDoc->m_pOleClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_OBJFULL, &pTempMoniker))
00338     return E_FAIL;
00339
00340   if(m_pOleDoc->m_pOleAdviseHolder)
00341     m_pOleDoc->m_pOleAdviseHolder->SendOnRename(pTempMoniker);
00342
00343   LPRUNNINGOBJECTTABLE pRot;
00344
00345   if(NOERROR == GetRunningObjectTable(0, &pRot))
00346   {
00347     if(m_pOleDoc->m_dwRegister)
00348       pRot->Revoke(m_pOleDoc->m_dwRegister);
00349
00350     pRot->Register(0, m_pOleDoc, pTempMoniker, &m_pOleDoc->m_dwRegister);
00351
00352     pRot->Release();
00353   }
00354
00355   return S_OK;
00356 }
00357
00358 /**************************************************************************
00359
00360   COleObject::GetMoniker()
00361
00362 **************************************************************************/
00363
00364 STDMETHODIMP COleObject::GetMoniker(   DWORD dwAssign,
00365                   DWORD dwWhichMoniker,
00366                   LPMONIKER *ppmk)
00367 {
00368   UNREFERENCED_PARAMETER(dwAssign);
00369   UNREFERENCED_PARAMETER(dwWhichMoniker);
00370   OutputDebugString(TEXT("COleObject::GetMoniker\n"));
00371
00372   *ppmk = NULL;
00373
00374   return m_pOleDoc->m_pOleClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_OBJFULL, ppmk);
00375 }
00376
00377 /**************************************************************************
00378
00379   COleObject::InitFromData()
00380
00381 **************************************************************************/
00382
00383 STDMETHODIMP COleObject::InitFromData( LPDATAOBJECT pDataObject,
00384                     BOOL fCreation,
00385                     DWORD dwReserved)
00386 {
00387   UNREFERENCED_PARAMETER(pDataObject);
00388   UNREFERENCED_PARAMETER(fCreation);
00389   UNREFERENCED_PARAMETER(dwReserved);
00390   OutputDebugString(TEXT("COleObject::InitFromData\n"));
00391
00392   return E_NOTIMPL;
00393 }
00394
00395 /**************************************************************************
00396
00397   COleObject::GetClipboardData()
00398
00399 **************************************************************************/
00400
00401 STDMETHODIMP COleObject::GetClipboardData(   DWORD dwReserved,
00402                       LPDATAOBJECT *ppDataObject)
00403 {
00404   UNREFERENCED_PARAMETER(dwReserved);
00405   OutputDebugString(TEXT("COleObject::GetClipboardData\n"));
00406
00407   *ppDataObject = NULL;
00408
00409   return E_NOTIMPL;
00410 }
00411
00412 /**************************************************************************
00413
00414   COleObject::IsUpToDate()
00415
00416 **************************************************************************/
00417
00418 STDMETHODIMP COleObject::IsUpToDate()
00419 {
00420   OutputDebugString(TEXT("COleObject::IsUpToDate\n"));
00421
00422   return S_OK;
00423 }
00424
00425 /**************************************************************************
00426
00427   COleObject::GetUserClassID()
00428
00429 **************************************************************************/
00430
00431 STDMETHODIMP COleObject::GetUserClassID(CLSID *pClsid)
00432 {
00433   OutputDebugString(TEXT("COleObject::GetUserClassID\n"));
00434
00435   return m_pOleDoc->m_pPersistStorage->GetClassID(pClsid);
00436 }
00437
00438 /**************************************************************************
00439
00440   COleObject::GetUserType()
00441
00442 **************************************************************************/
00443
00444 STDMETHODIMP COleObject::GetUserType(DWORD dwFormOfType, LPOLESTR *pszUserType)
00445 {
00446   UNREFERENCED_PARAMETER(dwFormOfType);
00447   UNREFERENCED_PARAMETER(pszUserType);
00448   OutputDebugString(TEXT("COleObject::GetUserType\n"));
00449
00450   return OLE_S_USEREG;
00451 }
00452
00453 /**************************************************************************
00454
00455   COleObject::EnumAdvise()
00456
00457 **************************************************************************/
00458
00459 STDMETHODIMP COleObject::EnumAdvise(LPENUMSTATDATA *ppenumAdvise)
00460 {
00461   OutputDebugString(TEXT("COleObject::EnumAdvise\n"));
00462
00463   *ppenumAdvise = NULL;
00464
00465   // pass on to the OLE Advise holder.
00466   return m_pOleDoc->m_pOleAdviseHolder->EnumAdvise(ppenumAdvise);
00467 }
00468
00469 /**************************************************************************
00470
00471   COleObject::GetMiscStatus()
00472
00473 **************************************************************************/
00474
00475 STDMETHODIMP COleObject::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus)
00476 {
00477   UNREFERENCED_PARAMETER(dwAspect);
00478   OutputDebugString(TEXT("COleObject::GetMiscStatus\n"));
00479
00480   *pdwStatus = NULL;
00481
00482   return OLE_S_USEREG;
00483 }
00484
00485 /**************************************************************************
00486
00487   COleObject::SetColorScheme()
00488
00489 **************************************************************************/
00490
00491 STDMETHODIMP COleObject::SetColorScheme(LPLOGPALETTE lpLogpal)
00492 {
00493   UNREFERENCED_PARAMETER(lpLogpal);
00494   OutputDebugString(TEXT("COleObject::SetColorScheme\n"));
00495
00496   return S_OK;
00497 }
00498
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/EventTrace/TraceLog/TraceLog.c Source File

  • WinBase
  • EventTrace
  • TraceLog

TraceLog.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 Module Name:
00006
00007     tracelog.c
00008
00009 Abstract:
00010
00011     Sample trace control program. Allows user to start, update, query, stop
00012     event tracing, etc.
00013
00014
00015 --*/
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include <windows.h>
00019 #include <shellapi.h>
00020 #include <tchar.h>
00021 #include <wmistr.h>
00022 #include <initguid.h>
00023 #include <guiddef.h>
00024 #include <evntrace.h>
00025
00026 #define MAXSTR                          1024
00027 // Default trace file name.
00028 #define DEFAULT_LOGFILE_NAME            _T("C:\\LogFile.Etl")
00029 // On Windows 2000, we support up to 32 loggers at once.
00030 // On Windows XP and Server 2003, we support up to 64 loggers.
00031 #define MAXIMUM_LOGGERS                  32
00032
00033 // In this sample, we support the following actions.
00034 // Additional actions that we do not use in this sample include
00035 // Flush and Enumerate Guids functionalities. They are supported
00036 // only on XP or higher version.
00037 #define ACTION_QUERY                    0
00038 #define ACTION_START                    1
00039 #define ACTION_STOP                     2
00040 #define ACTION_UPDATE                   3
00041 #define ACTION_LIST                     4
00042 #define ACTION_ENABLE                   5
00043 #define ACTION_HELP                     6
00044
00045 #define ACTION_UNDEFINED               10
00046
00047 void
00048 PrintLoggerStatus(
00049     IN PEVENT_TRACE_PROPERTIES LoggerInfo,
00050     IN ULONG Status
00051     );
00052
00053 ULONG
00054 ahextoi(
00055     IN TCHAR *s
00056     );
00057
00058 void
00059 StringToGuid(
00060     IN TCHAR *str,
00061     OUT LPGUID guid
00062     );
00063
00064 void
00065 PrintHelpMessage();
00066
00067
00068 //
00069 //  main function
00070 //
00071 __cdecl main(argc, argv)
00072     int argc;
00073     char **argv;
00074 /*++
00075
00076 Routine Description:
00077
00078     It is the main function.
00079
00080 Arguments:
00081
00082 Return Value:
00083
00084     Error Code defined in winerror.h : If the function succeeds,
00085                 it returns ERROR_SUCCESS (== 0).
00086
00087
00088 --*/{
00089     ULONG i, j;
00090     ULONG Status = ERROR_SUCCESS;
00091     LPTSTR *targv, *utargv = NULL;
00092     // Action to be taken
00093     USHORT Action = ACTION_UNDEFINED;
00094
00095     LPTSTR LoggerName;
00096     LPTSTR LogFileName;
00097     PEVENT_TRACE_PROPERTIES pLoggerInfo;
00098     TRACEHANDLE LoggerHandle = 0;
00099     // Target GUID, level and flags for enable/disable
00100     GUID TargetGuid;
00101     ULONG bEnable = TRUE;
00102
00103     ULONG SizeNeeded = 0;
00104
00105     // We will enable Process, Thread, Disk, and Network events
00106     // if the Kernel Logger is requested.
00107     BOOL bKernelLogger = FALSE;
00108
00109     // Allocate and initialize EVENT_TRACE_PROPERTIES structure first
00110     SizeNeeded = sizeof(EVENT_TRACE_PROPERTIES) + 2 * MAXSTR * sizeof(TCHAR);
00111     pLoggerInfo = (PEVENT_TRACE_PROPERTIES) malloc(SizeNeeded);
00112     if (pLoggerInfo == NULL) {
00113         return (ERROR_OUTOFMEMORY);
00114     }
00115
00116     RtlZeroMemory(pLoggerInfo, SizeNeeded);
00117
00118     pLoggerInfo->Wnode.BufferSize = SizeNeeded;
00119     pLoggerInfo->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
00120     pLoggerInfo->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
00121     pLoggerInfo->LogFileNameOffset = pLoggerInfo->LoggerNameOffset + MAXSTR * sizeof(TCHAR);
00122
00123     LoggerName = (LPTSTR)((char*)pLoggerInfo + pLoggerInfo->LoggerNameOffset);
00124     LogFileName = (LPTSTR)((char*)pLoggerInfo + pLoggerInfo->LogFileNameOffset);
00125     // If the logger name is not given, we will assume the kernel logger.
00126     _tcscpy(LoggerName, KERNEL_LOGGER_NAME);
00127
00128 #ifdef UNICODE
00129     if ((targv = CommandLineToArgvW(
00130                       GetCommandLineW(),    // pointer to a command-line string
00131                       &argc                 // receives the argument count
00132                       )) == NULL) {
00133         free(pLoggerInfo);
00134         return (GetLastError());
00135     };
00136     utargv = targv;
00137 #else
00138     targv = argv;
00139 #endif
00140
00141     //
00142     // Parse the command line options to determine actions and parameters.
00143     //
00144     while (--argc > 0) {
00145         ++targv;
00146         if (**targv == '-' || **targv == '/') {  // argument found
00147             if (targv[0][0] == '/' ) {
00148                 targv[0][0] = '-';
00149             }
00150
00151             // Deterine actions.
00152             if (!_tcsicmp(targv[0], _T("-start"))) {
00153                 Action = ACTION_START;
00154                 if (argc > 1) {
00155                     if (targv[1][0] != '-' && targv[1][0] != '/') {
00156                         ++targv; --argc;
00157                         _tcscpy(LoggerName, targv[0]);
00158                     }
00159                 }
00160             }
00161             else if (!_tcsicmp(targv[0], _T("-enable"))) {
00162                 Action = ACTION_ENABLE;
00163                 if (argc > 1) {
00164                     if (targv[1][0] != '-' && targv[1][0] != '/') {
00165                         ++targv; --argc;
00166                         _tcscpy(LoggerName, targv[0]);
00167                     }
00168                 }
00169             }
00170             else if (!_tcsicmp(targv[0], _T("-disable"))) {
00171                 Action = ACTION_ENABLE;
00172                 bEnable = FALSE;
00173                 if (argc > 1) {
00174                     if (targv[1][0] != '-' && targv[1][0] != '/') {
00175                         ++targv; --argc;
00176                         _tcscpy(LoggerName, targv[0]);
00177                     }
00178                 }
00179             }
00180             else if (!_tcsicmp(targv[0], _T("-stop"))) {
00181                 Action = ACTION_STOP;
00182                 if (argc > 1) {
00183                     if (targv[1][0] != '-' && targv[1][0] != '/') {
00184                         ++targv; --argc;
00185                         _tcscpy(LoggerName, targv[0]);
00186                     }
00187                 }
00188             }
00189             else if (!_tcsicmp(targv[0], _T("-update"))) {
00190                 Action = ACTION_UPDATE;
00191                 if (argc > 1) {
00192                     if (targv[1][0] != '-' && targv[1][0] != '/') {
00193                         ++targv; --argc;
00194                         _tcscpy(LoggerName, targv[0]);
00195                     }
00196                 }
00197             }
00198             else if (!_tcsicmp(targv[0], _T("-query"))) {
00199                 Action = ACTION_QUERY;
00200                 if (argc > 1) {
00201                     if (targv[1][0] != '-' && targv[1][0] != '/') {
00202                         ++targv; --argc;
00203                         _tcscpy(LoggerName, targv[0]);
00204                     }
00205                 }
00206             }
00207             else if (!_tcsicmp(targv[0], _T("-list"))) {
00208                 Action  = ACTION_LIST;
00209             }
00210
00211             // Get other parameters.
00212             // Users can customize logger settings further by adding/changing
00213             // values to pLoggerInfo. Refer to EVENT_TRACE_PROPERTIES documentation
00214             // for available options.
00215             // In this sample, we allow changing maximum number of buffers and
00216             // specifying user mode (private) logger.
00217             // We also take trace file name and guid for enable/disable.
00218             else if (!_tcsicmp(targv[0], _T("-f"))) {
00219                 if (argc > 1) {
00220                     _tfullpath(LogFileName, targv[1], MAXSTR);
00221                     ++targv; --argc;
00222                 }
00223             }
00224             else if (!_tcsicmp(targv[0], _T("-guid"))) {
00225                 if (argc > 1) {
00226                     // -guid #00000000-0000-0000-0000-000000000000
00227                     if (targv[1][0] == _T('#')) {
00228                         StringToGuid(&targv[1][1], &TargetGuid);
00229                         ++targv; --argc;
00230                     }
00231                 }
00232             }
00233             else if (!_tcsicmp(targv[0], _T("-max"))) {
00234                 if (argc > 1) {
00235                     pLoggerInfo->MaximumBuffers = _ttoi(targv[1]);
00236                     ++targv; --argc;
00237                 }
00238             }
00239             else if (!_tcsicmp(targv[0], _T("-um"))) {
00240                     pLoggerInfo->LogFileMode |= EVENT_TRACE_PRIVATE_LOGGER_MODE;
00241             }
00242             else if ( targv[0][1] == 'h' || targv[0][1] == 'H' || targv[0][1] == '?'){
00243                 Action = ACTION_HELP;
00244                 PrintHelpMessage();
00245                 if (utargv != NULL) {
00246                     GlobalFree(utargv);
00247                 }
00248                 free(pLoggerInfo);
00249
00250                 return (ERROR_SUCCESS);
00251             }
00252             else Action = ACTION_UNDEFINED;
00253         }
00254         else {
00255             _tprintf(_T("Invalid option given: %s\n"), targv[0]);
00256             Status = ERROR_INVALID_PARAMETER;
00257             SetLastError(Status);
00258             if (utargv != NULL) {
00259                 GlobalFree(utargv);
00260             }
00261             free(pLoggerInfo);
00262
00263             return (Status);
00264         }
00265     }
00266
00267     // Set the kernel logger parameters.
00268     if (!_tcscmp(LoggerName, KERNEL_LOGGER_NAME)) {
00269         // Set enable flags. Users can add options to add additional kernel events
00270         // or remove some of these events.
00271         pLoggerInfo->EnableFlags |= EVENT_TRACE_FLAG_PROCESS;
00272         pLoggerInfo->EnableFlags |= EVENT_TRACE_FLAG_THREAD;
00273         pLoggerInfo->EnableFlags |= EVENT_TRACE_FLAG_DISK_IO;
00274         pLoggerInfo->EnableFlags |= EVENT_TRACE_FLAG_NETWORK_TCPIP;
00275
00276         pLoggerInfo->Wnode.Guid = SystemTraceControlGuid;
00277         bKernelLogger = TRUE;
00278     }
00279     else if (pLoggerInfo->LogFileMode & EVENT_TRACE_PRIVATE_LOGGER_MODE) {
00280         // We must provide a control GUID for a private logger.
00281         pLoggerInfo->Wnode.Guid = TargetGuid;
00282     }
00283
00284     // Process the request.
00285     switch (Action) {
00286         case  ACTION_START:
00287         {
00288             // Use default file name if not given
00289             if (_tcslen(LogFileName) == 0) {
00290                 _tcscpy(LogFileName, DEFAULT_LOGFILE_NAME);
00291             }
00292
00293             Status = StartTrace(&LoggerHandle, LoggerName, pLoggerInfo);
00294
00295             if (Status != ERROR_SUCCESS) {
00296                 _tprintf(_T("Could not start logger: %s\n")
00297                          _T("Operation Status:       %uL\n"),
00298                          LoggerName,
00299                          Status);
00300
00301                 break;
00302             }
00303             _tprintf(_T("Logger Started...\n"));
00304         }
00305         case ACTION_ENABLE:
00306         {
00307             // We can allow enabling a GUID during START operation (Note no break in case ACTION_START).
00308             // In that case, we do not need to get LoggerHandle separately.
00309             if (Action == ACTION_ENABLE ){
00310
00311                 // Get Logger Handle though Query.
00312                 Status = ControlTrace((TRACEHANDLE) 0, LoggerName, pLoggerInfo, EVENT_TRACE_CONTROL_QUERY);
00313                 if( Status != ERROR_SUCCESS ){
00314                     _tprintf( _T("ERROR: Logger not started\n")
00315                               _T("Operation Status:    %uL\n"),
00316                               Status);
00317                     break;
00318                 }
00319                 LoggerHandle = pLoggerInfo->Wnode.HistoricalContext;
00320             }
00321
00322             // We do not allow EnableTrace on the Kernel Logger in this sample,
00323             // users can use EnableFlags to enable/disable certain kernel events.
00324             if (!bKernelLogger) {
00325                 _tprintf(_T("Enabling trace to logger %d\n"), LoggerHandle);
00326                 // In this sample, we use EnableFlag = EnableLebel = 0
00327                 Status = EnableTrace (
00328                                 bEnable,
00329                                 0,
00330                                 0,
00331                                 &TargetGuid,
00332                                 LoggerHandle);
00333
00334                 if (Status != ERROR_SUCCESS) {
00335                     _tprintf(_T("ERROR: Failed to enable Guid...\n"));
00336                     _tprintf(_T("Operation Status:       %uL\n"), Status);
00337                     break;
00338                 }
00339             }
00340             break;
00341         }
00342         case ACTION_STOP :
00343         {
00344             LoggerHandle = (TRACEHANDLE) 0;
00345             Status = ControlTrace(LoggerHandle, LoggerName, pLoggerInfo, EVENT_TRACE_CONTROL_STOP);
00346             break;
00347         }
00348         case ACTION_LIST :
00349         {
00350             ULONG returnCount;
00351             PEVENT_TRACE_PROPERTIES pLoggerInfo[MAXIMUM_LOGGERS];
00352             PEVENT_TRACE_PROPERTIES pStorage, pTempStorage;
00353             ULONG SizeForOneProperty = sizeof(EVENT_TRACE_PROPERTIES) +
00354                                        2 * MAXSTR * sizeof(TCHAR);
00355
00356             // We need to prepare space to receieve the inforamtion on loggers.
00357             SizeNeeded = MAXIMUM_LOGGERS * SizeForOneProperty;
00358
00359             pStorage =  (PEVENT_TRACE_PROPERTIES)malloc(SizeNeeded);
00360             if (pStorage == NULL) {
00361                 Status = ERROR_OUTOFMEMORY;
00362                 break;
00363             }
00364             RtlZeroMemory(pStorage, SizeNeeded);
00365             // Save the pointer for free() later.
00366             pTempStorage = pStorage;
00367
00368             for (i = 0; i < MAXIMUM_LOGGERS; i++) {
00369                 pStorage->Wnode.BufferSize = SizeForOneProperty;
00370                 pStorage->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
00371                 pStorage->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES)
00372                                         + MAXSTR * sizeof(TCHAR);
00373                 pLoggerInfo[i] = pStorage;
00374                 pStorage = (PEVENT_TRACE_PROPERTIES) (
00375                                  (PUCHAR)pStorage +
00376                                   pStorage->Wnode.BufferSize);
00377             }
00378
00379             Status = QueryAllTraces(pLoggerInfo,
00380                                 MAXIMUM_LOGGERS,
00381                                 &returnCount);
00382
00383             if (Status == ERROR_SUCCESS)
00384             {
00385                 for (j= 0; j < returnCount; j++)
00386                 {
00387                     PrintLoggerStatus(pLoggerInfo[j],
00388                                         Status);
00389                     _tprintf(_T("\n"));
00390                 }
00391             }
00392
00393             free(pTempStorage);
00394             break;
00395         }
00396
00397         case ACTION_UPDATE :
00398         {
00399             // In this sample, users can only update MaximumBuffers and log file name.
00400             // User can add more options for other parameters as needed.
00401             Status = ControlTrace(LoggerHandle, LoggerName, pLoggerInfo, EVENT_TRACE_CONTROL_UPDATE);
00402             break;
00403         }
00404         case ACTION_QUERY  :
00405         {
00406             Status = ControlTrace(LoggerHandle, LoggerName, pLoggerInfo, EVENT_TRACE_CONTROL_QUERY);
00407             break;
00408         }
00409         case ACTION_HELP:
00410         {
00411             PrintHelpMessage();
00412             break;
00413         }
00414         default :
00415         {
00416             _tprintf(_T("Error: no action specified\n"));
00417             PrintHelpMessage();
00418             break;
00419         }
00420     }
00421
00422     if ((Action != ACTION_HELP) &&
00423         (Action != ACTION_UNDEFINED) &&
00424         (Action != ACTION_LIST)) {
00425         PrintLoggerStatus(pLoggerInfo,
00426                             Status);
00427     }
00428
00429     if (Status != ERROR_SUCCESS) {
00430         SetLastError(Status);
00431     }
00432     if (utargv != NULL) {
00433         GlobalFree(utargv);
00434     }
00435     free(pLoggerInfo);
00436
00437     return (Status);
00438 }
00439
00440
00441 void
00442 PrintLoggerStatus(
00443     IN PEVENT_TRACE_PROPERTIES LoggerInfo,
00444     IN ULONG Status
00445     )
00446 /*++
00447
00448 Routine Description:
00449
00450     Prints out the status of the specified logger.
00451
00452 Arguments:
00453
00454     LoggerInfo - The pointer to the resident EVENT_TRACE_PROPERTIES that has
00455         the information about the current logger.
00456     Status - The operation status of the current logger.
00457
00458 Return Value:
00459
00460     None
00461
00462 --*/
00463 {
00464     LPTSTR LoggerName, LogFileName;
00465
00466     if ((LoggerInfo->LoggerNameOffset > 0) &&
00467         (LoggerInfo->LoggerNameOffset  < LoggerInfo->Wnode.BufferSize)) {
00468         LoggerName = (LPTSTR) ((PUCHAR)LoggerInfo +
00469                                 LoggerInfo->LoggerNameOffset);
00470     }
00471     else LoggerName = NULL;
00472
00473     if ((LoggerInfo->LogFileNameOffset > 0) &&
00474         (LoggerInfo->LogFileNameOffset  < LoggerInfo->Wnode.BufferSize)) {
00475         LogFileName = (LPTSTR) ((PUCHAR)LoggerInfo +
00476                                 LoggerInfo->LogFileNameOffset);
00477     }
00478     else LogFileName = NULL;
00479
00480     _tprintf(_T("Operation Status:       %uL\n"), Status);
00481
00482     _tprintf(_T("Logger Name:            %s\n"),
00483             (LoggerName == NULL) ?
00484             _T(" ") : LoggerName);
00485         _tprintf(_T("Logger Id:              %I64x\n"), LoggerInfo->Wnode.HistoricalContext);
00486         _tprintf(_T("Logger Thread Id:       %d\n"), LoggerInfo->LoggerThreadId);
00487
00488     if (Status != 0)
00489         return;
00490
00491     _tprintf(_T("Buffer Size:            %d Kb"), LoggerInfo->BufferSize);
00492     if (LoggerInfo->LogFileMode & EVENT_TRACE_USE_PAGED_MEMORY) {
00493         _tprintf(_T(" using paged memory\n"));
00494     }
00495     else {
00496         _tprintf(_T("\n"));
00497     }
00498     _tprintf(_T("Maximum Buffers:        %d\n"), LoggerInfo->MaximumBuffers);
00499     _tprintf(_T("Minimum Buffers:        %d\n"), LoggerInfo->MinimumBuffers);
00500     _tprintf(_T("Number of Buffers:      %d\n"), LoggerInfo->NumberOfBuffers);
00501     _tprintf(_T("Free Buffers:           %d\n"), LoggerInfo->FreeBuffers);
00502     _tprintf(_T("Buffers Written:        %d\n"), LoggerInfo->BuffersWritten);
00503     _tprintf(_T("Events Lost:            %d\n"), LoggerInfo->EventsLost);
00504     _tprintf(_T("Log Buffers Lost:       %d\n"), LoggerInfo->LogBuffersLost);
00505     _tprintf(_T("Real Time Buffers Lost: %d\n"), LoggerInfo->RealTimeBuffersLost);
00506     _tprintf(_T("AgeLimit:               %d\n"), LoggerInfo->AgeLimit);
00507
00508     if (LogFileName == NULL) {
00509         _tprintf(_T("Buffering Mode:         "));
00510     }
00511     else {
00512         _tprintf(_T("Log File Mode:          "));
00513     }
00514     if (LoggerInfo->LogFileMode & EVENT_TRACE_FILE_MODE_APPEND) {
00515         _tprintf(_T("Append  "));
00516     }
00517     if (LoggerInfo->LogFileMode & EVENT_TRACE_FILE_MODE_CIRCULAR) {
00518         _tprintf(_T("Circular\n"));
00519     }
00520     else if (LoggerInfo->LogFileMode & EVENT_TRACE_FILE_MODE_SEQUENTIAL) {
00521         _tprintf(_T("Sequential\n"));
00522     }
00523     else {
00524         _tprintf(_T("Sequential\n"));
00525     }
00526     if (LoggerInfo->LogFileMode & EVENT_TRACE_REAL_TIME_MODE) {
00527         _tprintf(_T("Real Time mode enabled"));
00528         _tprintf(_T("\n"));
00529     }
00530
00531     if (LoggerInfo->MaximumFileSize > 0)
00532         _tprintf(_T("Maximum File Size:      %d Mb\n"), LoggerInfo->MaximumFileSize);
00533
00534     if (LoggerInfo->FlushTimer > 0)
00535         _tprintf(_T("Buffer Flush Timer:     %d secs\n"), LoggerInfo->FlushTimer);
00536
00537     if (LoggerInfo->EnableFlags != 0) {
00538         _tprintf(_T("Enabled tracing:        "));
00539
00540         if ((LoggerName != NULL) && (!_tcscmp(LoggerName, KERNEL_LOGGER_NAME))) {
00541
00542             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_PROCESS)
00543                 _tprintf(_T("Process "));
00544             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_THREAD)
00545                 _tprintf(_T("Thread "));
00546             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_DISK_IO)
00547                 _tprintf(_T("Disk "));
00548             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_DISK_FILE_IO)
00549                 _tprintf(_T("File "));
00550             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_MEMORY_PAGE_FAULTS)
00551                 _tprintf(_T("PageFaults "));
00552             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_MEMORY_HARD_FAULTS)
00553                 _tprintf(_T("HardFaults "));
00554             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_IMAGE_LOAD)
00555                 _tprintf(_T("ImageLoad "));
00556             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_NETWORK_TCPIP)
00557                 _tprintf(_T("TcpIp "));
00558             if (LoggerInfo->EnableFlags & EVENT_TRACE_FLAG_REGISTRY)
00559                 _tprintf(_T("Registry "));
00560         }else{
00561             _tprintf(_T("0x%08x"), LoggerInfo->EnableFlags );
00562         }
00563         _tprintf(_T("\n"));
00564     }
00565     if (LogFileName != NULL) {
00566         _tprintf(_T("Log Filename:           %s\n"), LogFileName);
00567     }
00568
00569 }
00570
00571 ULONG
00572 ahextoi(
00573     IN TCHAR *s
00574     )
00575 /*++
00576
00577 Routine Description:
00578
00579     Converts a hex string into a number.
00580
00581 Arguments:
00582
00583     s - A hex string in TCHAR.
00584
00585 Return Value:
00586
00587     ULONG - The number in the string.
00588
00589
00590 --*/
00591 {
00592     int len;
00593     ULONG num, base, hex;
00594
00595     len = _tcslen(s);
00596     hex = 0; base = 1; num = 0;
00597     while (--len >= 0) {
00598         if ( (s[len] == 'x' || s[len] == 'X') &&
00599              (s[len-1] == '0') )
00600             break;
00601         if (s[len] >= '0' && s[len] <= '9')
00602             num = s[len] - '0';
00603         else if (s[len] >= 'a' && s[len] <= 'f')
00604             num = (s[len] - 'a') + 10;
00605         else if (s[len] >= 'A' && s[len] <= 'F')
00606             num = (s[len] - 'A') + 10;
00607         else
00608             continue;
00609
00610         hex += num * base;
00611         base = base * 16;
00612     }
00613     return hex;
00614 }
00615
00616 void
00617 StringToGuid(
00618     IN TCHAR *str,
00619     IN OUT LPGUID guid
00620 )
00621 /*++
00622
00623 Routine Description:
00624
00625     Converts a string into a GUID.
00626
00627 Arguments:
00628
00629     str - A string in TCHAR.
00630     guid - The pointer to a GUID that will have the converted GUID.
00631
00632 Return Value:
00633
00634     None.
00635
00636
00637 --*/
00638 {
00639     TCHAR temp[10];
00640     int i;
00641
00642     _tcsncpy(temp, str, 8);
00643     temp[8] = 0;
00644     guid->Data1 = ahextoi(temp);
00645     _tcsncpy(temp, &str[9], 4);
00646     temp[4] = 0;
00647     guid->Data2 = (USHORT) ahextoi(temp);
00648     _tcsncpy(temp, &str[14], 4);
00649     temp[4] = 0;
00650     guid->Data3 = (USHORT) ahextoi(temp);
00651
00652     for (i=0; i<2; i++) {
00653         _tcsncpy(temp, &str[19 + (i*2)], 2);
00654         temp[2] = 0;
00655         guid->Data4[i] = (UCHAR) ahextoi(temp);
00656     }
00657     for (i=2; i<8; i++) {
00658         _tcsncpy(temp, &str[20 + (i*2)], 2);
00659         temp[2] = 0;
00660         guid->Data4[i] = (UCHAR) ahextoi(temp);
00661     }
00662 }
00663
00664 void PrintHelpMessage()
00665 /*++
00666
00667 Routine Description:
00668
00669     prints out a help message.
00670
00671 Arguments:
00672
00673     None.
00674
00675 Return Value:
00676
00677     None.
00678
00679
00680 --*/
00681 {
00682     _tprintf(_T("Usage: tracelog [actions] [options] | [-h | -help | -?]\n"));
00683     _tprintf(_T("\n    actions:\n"));
00684     _tprintf(_T("\t-start   [LoggerName] Starts up the [LoggerName] trace session\n"));
00685     _tprintf(_T("\t-stop    [LoggerName] Stops the [LoggerName] trace session\n"));
00686     _tprintf(_T("\t-update  [LoggerName] Updates the [LoggerName] trace session\n"));
00687     _tprintf(_T("\t-enable  [LoggerName] Enables providers for the [LoggerName] session\n"));
00688     _tprintf(_T("\t-disable [LoggerName] Disables providers for the [LoggerName] session\n"));
00689     _tprintf(_T("\t-query   [LoggerName] Query status of [LoggerName] trace session\n"));
00690     _tprintf(_T("\t-list                 List all trace sessions\n"));
00691
00692     _tprintf(_T("\n    options:\n"));
00693     _tprintf(_T("\t-um                   Use Process Private tracing\n"));
00694     _tprintf(_T("\t-max <n>              Sets maximum buffers\n"));
00695     _tprintf(_T("\t-f <name>             Log to file <name>\n"));
00696     _tprintf(_T("\t-guid #<guid>         Provider GUID to enable/disable\n"));
00697     _tprintf(_T("\n"));
00698     _tprintf(_T("\t-h\n"));
00699     _tprintf(_T("\t-help\n"));
00700     _tprintf(_T("\t-?                    Display usage information\n"));
00701 }
00702
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCNotify/StdAfx.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCNotify

StdAfx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Stdafx.h
00003   Summary:   Standard header
00004   Classes:   None
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #if !defined(AFX_STDAFX_H__6DD1E6E0_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_)
00023 #define AFX_STDAFX_H__6DD1E6E0_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_
00024
00025 #if _MSC_VER >= 1000
00026 #pragma once
00027 #endif // _MSC_VER >= 1000
00028
00029 #define STRICT
00030
00031
00032 #define _WIN32_WINNT 0x0500
00033 #define _ATL_APARTMENT_THREADED
00034
00035
00036 #include <atlbase.h>
00037 //You may derive a class from CComModule and use it if you want to override
00038 //something, but do not change the name of _Module
00039 extern CComModule _Module;
00040 #include <atlcom.h>
00041
00042 //{{AFX_INSERT_LOCATION}}
00043 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00044
00045 #include <crtdbg.h>
00046 #include <comsvcs.h>
00047 #include <stdlib.h>
00048 #include <vector>
00049 #include <comdef.h>
00050
00051 #endif // !defined(AFX_STDAFX_H__6DD1E6E0_28C1_11D2_B5B6_00C04FC340EE__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFullConnectOptions Member List

This is the complete list of members for CFullConnectOptions, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CFullConnectOptions() | CFullConnectOptions |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_dwCLSCTX | CFullConnectOptions |
m_dwConnectOpts | CFullConnectOptions |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
m_wszRemoteServer | CFullConnectOptions |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | CPropPageLite | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CFullConnectOptions | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CFullConnectOptions | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CFullConnectOptions | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSetActive() | CFullConnectOptions | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
RefreshOptions() | CFullConnectOptions | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateOptions() | CFullConnectOptions | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSmartComPtr< T > Member List

This is the complete list of members for CSmartComPtr< T >, including all inherited members.
AddReference() | CSmartComPtr< T > | [inline, private]
Clear() | CSmartComPtr< T > | [inline]
CSmartComPtr() | CSmartComPtr< T > | [inline]
CSmartComPtr(T *pInterface) | CSmartComPtr< T > | [inline]
CSmartComPtr(const CSmartComPtr< T > &lpAnother) | CSmartComPtr< T > | [inline]
GrabOutPtr() | CSmartComPtr< T > | [inline]
m_pI | CSmartComPtr< T > | [private]
operator const T *() const | CSmartComPtr< T > | [inline]
operator&() | CSmartComPtr< T > | [inline]
operator->() const | CSmartComPtr< T > | [inline]
operator=(CSmartComPtr &Other) | CSmartComPtr< T > | [inline]
Release() | CSmartComPtr< T > | [inline]
ReleaseInterface() | CSmartComPtr< T > | [inline, private]
~CSmartComPtr() | CSmartComPtr< T > | [inline]
Generated on Wed Nov 13 2024 16:57:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFilesTest/DllDatax.h Source File

  • Com
  • Services
  • Crm
  • CrmFilesTest

DllDatax.h

Go to the documentation of this file.
00001 #if !defined(AFX_DLLDATAX_H__963680DD_FCB4_11D1_83D0_00A0C91EEDE9__INCLUDED_)
00002 #define AFX_DLLDATAX_H__963680DD_FCB4_11D1_83D0_00A0C91EEDE9__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007
00008 #ifdef _MERGE_PROXYSTUB
00009
00010 extern "C"
00011 {
00012 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
00013   LPVOID lpReserved);
00014 STDAPI PrxDllCanUnloadNow(void);
00015 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
00016 STDAPI PrxDllRegisterServer(void);
00017 STDAPI PrxDllUnregisterServer(void);
00018 }
00019
00020 #endif
00021
00022 //{{AFX_INSERT_LOCATION}}
00023 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00024
00025 #endif // !defined(AFX_DLLDATAX_H__963680DD_FCB4_11D1_83D0_00A0C91EEDE9__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/RemClien/UTCRUCAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • RemClien

UTCRUCAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      UTCRUCAR.CPP
00003
00004   Summary:   Implementation file for the aggregatable COUtilityCruiseCar
00005              COM object class.
00006
00007              UTCRUCAR showcases the construction of the COUtilityCruiseCar
00008              COM object class with the IUnknown, ICar, ICruise, and
00009              IUtility interfaces.  This is done through Containment reuse
00010              of COCruiseCar's ICar and ICruise interface features.
00011
00012              For a comprehensive tutorial code tour of this module's
00013              contents and offerings see the tutorial REMCLIEN.HTM
00014              file.  For more specific technical details on the internal
00015              workings see the comments dispersed throughout the
00016              module's source code.
00017
00018   Classes:   COUtilityCruiseCar.
00019
00020   Functions: CreateUtilityCruiseCar.
00021
00022   Origin:    3-27-96: atrent - Editor inheritance from APTCLIEN source.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include APPUTIL.H because we will be building this application using
00043     the convenient Virtual Window and Dialog classes and other
00044     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00045   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00046     class, GUID, and CLSID specifications.
00047   We include REMCLIEN.H because it has class and resource definitions
00048     specific to this remCLIEN application.
00049   We include UTCRUCAR.H because it has the COUtilityCruiseCar declarations.
00050 ---------------------------------------------------------------------------*/
00051 #include <windows.h>
00052 #include <ole2.h>
00053 #include <apputil.h>
00054 #include <micars.h>
00055 #include <carguids.h>
00056 #include "remclien.h"
00057 #include "utcrucar.h"
00058
00059
00060 /*---------------------------------------------------------------------------
00061   COUtilityCruiseCar's implementation of its main COM object class including
00062   Constructor, Destructor, QueryInterface, AddRef, and Release.
00063 ---------------------------------------------------------------------------*/
00064
00065 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00066   Method:   COUtilityCruiseCar::COUtilityCruiseCar
00067
00068   Summary:  COUtilityCruiseCar Constructor. Note the member initializer:
00069             "m_ImpIUtility(this, pUnkOuter)" which is used to pass the 'this'
00070             and pUnkOuter pointers of this constructor function to the
00071             constructor in the instantiation of the implementation of
00072             the CImpIUtility interface (which is nested inside this present
00073             COUtilityCruiseCar Object Class).
00074
00075   Args:     IUnknown* pUnkOuter)
00076               Pointer to the the outer Unknown.  NULL means this COM Object
00077               is not being Aggregated.  Non NULL means it is being created
00078               on behalf of an outside COM object that is reusing it via
00079               aggregation.
00080
00081   Modifies: m_cRefs, m_pUnkOuter, m_pUnkCruiseCar.
00082
00083   Returns:  void
00084 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00085 COUtilityCruiseCar::COUtilityCruiseCar(
00086   IUnknown* pUnkOuter) :
00087   m_ImpICar(this, pUnkOuter),
00088   m_ImpICruise(this, pUnkOuter),
00089   m_ImpIUtility(this, pUnkOuter)
00090 {
00091   // Zero the COM object's reference count.
00092   m_cRefs = 0;
00093
00094   // No AddRef necessary if non-NULL, as this COM object's lifetime
00095   // is totally coupled with the controlling Outer object's lifetime.
00096   m_pUnkOuter = pUnkOuter;
00097
00098   // Zero the pointer to the contained COCruiseCar object's ICar interface.
00099   m_pICar = NULL;
00100
00101   // Zero the pointer to the contained COCruiseCar object's ICruise
00102   // interface.
00103   m_pICruise = NULL;
00104
00105   LOGF1("C: COUtilityCruiseCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00106
00107   return;
00108 }
00109
00110
00111 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00112   Method:   COUtilityCruiseCar::~COUtilityCruiseCar
00113
00114   Summary:  COUtilityCruiseCar Destructor.
00115
00116   Args:     void
00117
00118   Modifies: .
00119
00120   Returns:  void
00121 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00122 COUtilityCruiseCar::~COUtilityCruiseCar(void)
00123 {
00124   LOG("C: COUtilityCruiseCar::Destructor.");
00125
00126   // Release the contained CruiseCar interfaces.
00127   RELEASE_INTERFACE(m_pICruise);
00128   RELEASE_INTERFACE(m_pICar);
00129
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   COUtilityCruiseCar::Init
00136
00137   Summary:  COUtilityCruiseCar Initialization method.
00138
00139   Args:     void
00140
00141   Modifies: m_pICar, m_pICruise, m_cRefs.
00142
00143   Returns:  HRESULT
00144               Standard result code. NOERROR for success.
00145 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00146 HRESULT COUtilityCruiseCar::Init(void)
00147 {
00148   HRESULT hr;
00149   IClassFactory* pICFCruiseCar;
00150   HCURSOR hCurPrev;
00151   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00152
00153   // Change cursor to the hour glass.  Things could take awhile working
00154   // across the network.
00155   hCurPrev = SetCursor(hCurWait);
00156
00157   // Set up the right pIUnknown for delegation.  If we are being
00158   // aggregated then we pass the pUnkOuter in turn to any COM objects
00159   // that we are aggregating.  m_pUnkOuter was set in the Constructor.
00160   IUnknown* pUnkOuter = (NULL == m_pUnkOuter) ? this : m_pUnkOuter;
00161
00162   LOGF1("C: COUtilityCruiseCar::Init. pUnkOuter=0x%X",pUnkOuter);
00163
00164   // Get a class factory for AptCruiseCar and issue IClassFactory's
00165   // CreateInstance method to manufacture a COCruiseCar COM object.
00166   LOG("C: COUtilityCruiseCar::Init. Obtain CruiseCar Class Factory.");
00167   hr = CoGetClassObject(
00168          CLSID_AptCruiseCar,
00169          CLSCTX_REMOTE_SERVER,
00170          &g_ServerInfo,
00171          IID_IClassFactory,
00172          (PPVOID)&pICFCruiseCar);
00173   LOGERROR("C:CoGetClassObject.",hr);
00174   if (SUCCEEDED(hr))
00175   {
00176     LOG("C: COUtilityCruiseCar::Init. CruiseCar Class Factory obtained.");
00177     LOG("C: COUtilityCruiseCar::Init. Calling CFCruiseCar::CreateInstance.");
00178     // A NULL pUnkOuter is passed indicating that we are creating a
00179     // COCruiseCar component via the Containment reuse method.  We can
00180     // currently pass nothing other than this NULL pUnkOuter because
00181     // aggregation is not supported across process or machine boundaries.
00182     // Since we are not requesting a COCruiseCar create for aggregation we
00183     // can directly request for the ICruise interface on the new object.
00184     hr = pICFCruiseCar->CreateInstance(
00185                           NULL,
00186                           IID_ICruise,
00187                           (PPVOID)&m_pICruise);
00188     LOG("C: COUtilityCruiseCar::Init. Releasing CruiseCar Class Factory.");
00189     pICFCruiseCar->Release();
00190     LOGERROR("C:CreateInstance.",hr);
00191     if (SUCCEEDED(hr))
00192     {
00193       // Now that we have a valid interface pointer (m_pICruise) on the
00194       // new object we can obtain and cache a pointer to that contained
00195       // object's ICar interface as well.  We must QI using the obtained
00196       // ICruise pointer on the object to ensure that the marshaling proxy
00197       // is involved in the QueryInterface call to provide the pointer to
00198       // the ICar interface proxy.
00199       hr = m_pICruise->QueryInterface(IID_ICar, (PPVOID)&m_pICar);
00200     }
00201   }
00202
00203   if (SUCCEEDED(hr))
00204   {
00205     LOG("C: COUtilityCruiseCar::Init (CruiseCar Containment) Succeeded.");
00206   }
00207   else
00208   {
00209     LOGF1("C: COUtilityCruiseCar::Init (CruiseCar Containment) Failed. hr=0x%X",hr);
00210   }
00211
00212   // Set Cursor back to what it was.
00213   SetCursor(hCurPrev);
00214
00215   return (hr);
00216 }
00217
00218
00219 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00220   Method:   COUtilityCruiseCar::QueryInterface
00221
00222   Summary:  QueryInterface of the COUtilityCruiseCar non-delegating
00223             IUnknown implementation.
00224
00225   Args:     REFIID riid,
00226               [in] GUID of the Interface being requested.
00227             PPVOID ppv)
00228               [out] Address of the caller's pointer variable that will
00229               receive the requested interface pointer.
00230
00231   Modifies: .
00232
00233   Returns:  HRESULT
00234 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00235 STDMETHODIMP COUtilityCruiseCar::QueryInterface(
00236                REFIID riid,
00237                PPVOID ppv)
00238 {
00239   HRESULT hr = E_NOINTERFACE;
00240   *ppv = NULL;
00241
00242   if (IID_IUnknown == riid)
00243   {
00244     *ppv = this;
00245     LOG("C: COUtilityCruiseCar::QueryInterface. 'this' pIUnknown returned.");
00246   }
00247   else if (IID_ICar == riid)
00248   {
00249     *ppv = &m_ImpICar;
00250     LOG("C: COUtilityCruiseCar::QueryInterface. pICar returned");
00251   }
00252   else if (IID_ICruise == riid)
00253   {
00254     *ppv = &m_ImpICruise;
00255     LOG("C: COUtilityCruiseCar::QueryInterface. pICruise returned");
00256   }
00257   else if (IID_IUtility == riid)
00258   {
00259     // This IUtility interface is implemented in this COUtilityCruiseCar
00260     // object as a native interface of COUtilityCruiseCar.
00261     *ppv = &m_ImpIUtility;
00262     LOG("C: COUtilityCruiseCar::QueryInterface. pIUtility returned.");
00263   }
00264
00265   if (NULL != *ppv)
00266   {
00267     // We've handed out a pointer to an interface so obey the COM rules
00268     // and AddRef its reference count.
00269     ((LPUNKNOWN)*ppv)->AddRef();
00270     hr = NOERROR;
00271   }
00272
00273   return (hr);
00274 }
00275
00276
00277 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00278   Method:   COUtilityCruiseCar::AddRef
00279
00280   Summary:  AddRef of the COUtilityCruiseCar non-delegating
00281             IUnknown implementation.
00282
00283   Args:     void
00284
00285   Modifies: m_cRefs.
00286
00287   Returns:  ULONG
00288               New value of m_cRefs (COM object's reference count).
00289 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00290 STDMETHODIMP_(ULONG) COUtilityCruiseCar::AddRef(void)
00291 {
00292   m_cRefs++;
00293
00294   LOGF1("C: COUtilityCruiseCar::AddRef. New cRefs=%i.", m_cRefs);
00295
00296   return m_cRefs;
00297 }
00298
00299
00300 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00301   Method:   COUtilityCruiseCar::Release
00302
00303   Summary:  Release of the COUtilityCruiseCar non-delegating IUnknown
00304             implementation.
00305
00306   Args:     void
00307
00308   Modifies: m_cRefs.
00309
00310   Returns:  ULONG
00311               New value of m_cRefs (COM object's reference count).
00312 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00313 STDMETHODIMP_(ULONG) COUtilityCruiseCar::Release(void)
00314 {
00315   ULONG ulCount = --m_cRefs;
00316
00317   LOGF1("C: COUtilityCruiseCar::Release. New cRefs=%i.", m_cRefs);
00318
00319   if (0 == m_cRefs)
00320   {
00321     // We artificially bump the main ref count.  This fulfills one of
00322     // the rules of aggregated objects and ensures that an indirect
00323     // recursive call to this release won't occur because of other
00324     // delegating releases that might happen in our own destructor.
00325     m_cRefs++;
00326     delete this;
00327   }
00328
00329   return ulCount;
00330 }
00331
00332
00333 /*---------------------------------------------------------------------------
00334   COUtilityCruiseCar's nested implementation of the ICar interface
00335   including Constructor, Destructor, QueryInterface, AddRef, Release,
00336   Shift, Clutch, Speed, and Steer.
00337 ---------------------------------------------------------------------------*/
00338
00339 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00340   Method:   COUtilityCruiseCar::CImpICar::CImpICar
00341
00342   Summary:  Constructor for the CImpICar interface instantiation.
00343
00344   Args:     COUtilityCruiseCar* pBackObj,
00345               Back pointer to the parent outer object.
00346             IUnknown* pUnkOuter,
00347               Pointer to the outer Unknown.  For delegation.
00348
00349   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00350
00351   Returns:  void
00352 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00353 COUtilityCruiseCar::CImpICar::CImpICar(
00354   COUtilityCruiseCar* pBackObj,
00355   IUnknown* pUnkOuter)
00356 {
00357   // Init the Interface Ref Count (used for debugging only).
00358   m_cRefI = 0;
00359
00360   // Init the Back Object Pointer to point to the outer object.
00361   m_pBackObj = pBackObj;
00362
00363   // Init the CImpICar interface's delegating Unknown pointer.  We use
00364   // the Back Object pointer for IUnknown delegation here if we are not
00365   // being aggregated.  If we are being aggregated we use the supplied
00366   // pUnkOuter for IUnknown delegation.  In either case the pointer
00367   // assignment requires no AddRef because the CImpICar lifetime is
00368   // quaranteed by the lifetime of the parent object in which
00369   // CImpICar is nested.
00370   if (NULL == pUnkOuter)
00371   {
00372     m_pUnkOuter = pBackObj;
00373     LOG("C: COUtilityCruiseCar::CImpICar Constructor. Non-Aggregating");
00374   }
00375   else
00376   {
00377     m_pUnkOuter = pUnkOuter;
00378     LOG("C: COUtilityCruiseCar::CImpICar Constructor. Aggregating");
00379   }
00380
00381   return;
00382 }
00383
00384
00385 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00386   Method:   COUtilityCruiseCar::CImpICar::~CImpICar
00387
00388   Summary:  Destructor for the CImpICar interface instantiation.
00389
00390   Args:     void
00391
00392   Modifies: .
00393
00394   Returns:  void
00395 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00396 COUtilityCruiseCar::CImpICar::~CImpICar(void)
00397 {
00398   LOG("C: COUtilityCruiseCar::CImpICar Destructor.");
00399
00400   return;
00401 }
00402
00403
00404 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00405   Method:   COUtilityCruiseCar::CImpICar::QueryInterface
00406
00407   Summary:  The QueryInterface IUnknown member of this ICar interface
00408             implementation that delegates to m_pUnkOuter, whatever it is.
00409
00410   Args:     REFIID riid,
00411               [in] GUID of the Interface being requested.
00412             PPVOID ppv)
00413               [out] Address of the caller's pointer variable that will
00414               receive the requested interface pointer.
00415
00416   Modifies: .
00417
00418   Returns:  HRESULT
00419               Returned by the delegated outer QueryInterface call.
00420 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00421 STDMETHODIMP COUtilityCruiseCar::CImpICar::QueryInterface(
00422                REFIID riid,
00423                PPVOID ppv)
00424 {
00425   LOG("C: COUtilityCruiseCar::CImpICar::QueryInterface. Delegating.");
00426
00427   // Delegate this call to the outer object's QueryInterface.
00428   return m_pUnkOuter->QueryInterface(riid, ppv);
00429 }
00430
00431
00432 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00433   Method:   COUtilityCruiseCar::CImpICar::AddRef
00434
00435   Summary:  The AddRef IUnknown member of this ICar interface
00436             implementation that delegates to m_pUnkOuter, whatever it is.
00437
00438   Args:     void
00439
00440   Modifies: m_cRefI.
00441
00442   Returns:  ULONG
00443               Returned by the delegated outer AddRef call.
00444 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00445 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpICar::AddRef(void)
00446 {
00447   // Increment the Interface Reference Count.
00448   ++m_cRefI;
00449
00450   LOGF1("C: COUtilityCruiseCar::CImpICar::Addref. Delegating. New cI=%i.", m_cRefI);
00451
00452   // Delegate this call to the outer object's AddRef.
00453   return m_pUnkOuter->AddRef();
00454 }
00455
00456
00457 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00458   Method:   COUtilityCruiseCar::CImpICar::Release
00459
00460   Summary:  The Release IUnknown member of this ICar interface
00461             implementation that delegates to m_pUnkOuter, whatever it is.
00462
00463   Args:     void
00464
00465   Modifies: .
00466
00467   Returns:  ULONG
00468               Returned by the delegated outer Release call.
00469 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00470 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpICar::Release(void)
00471 {
00472   // Decrement the Interface Reference Count.
00473   --m_cRefI;
00474
00475   LOGF1("C: COUtilityCruiseCar::CImpICar::Release. Delegating. New cI=%i.", m_cRefI);
00476
00477   // Delegate this call to the outer object's Release.
00478   return m_pUnkOuter->Release();
00479 }
00480
00481
00482 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00483   Method:   COUtilityCruiseCar::CImpICar::Shift
00484
00485   Summary:  The Shift member method of this ICar interface implementation.
00486             A simple empty method on a COUtilityCruiseCar COM object for
00487             tutorial purposes.  Presumably if this Car object were
00488             modeling a real Car then the Shift method would shift to the
00489             specified gear.
00490
00491   Args:     short nGear
00492               0 - Neutral; 1 - 5 First 5 forward gears; 6 - Reverse.
00493
00494   Modifies: .
00495
00496   Returns:  HRESULT
00497               Delegated HRESULT.
00498 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00499 STDMETHODIMP COUtilityCruiseCar::CImpICar::Shift(
00500                short nGear)
00501 {
00502   LOGF1("C: COUtilityCruiseCar::CImpICar::Shift. Delegating. nGear=%i.",nGear);
00503
00504   // Delegate this call to the contained COCruiseCar's ICar::Shift.
00505   return m_pBackObj->m_pICar->Shift(nGear);
00506 }
00507
00508
00509 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00510   Method:   COUtilityCruiseCar::CImpICar::Clutch
00511
00512   Summary:  The Clutch member method of this ICar interface
00513             implementation. A simple empty method on a COUtilityCruiseCar
00514             COM object for tutorial purposes.  Presumably if this Car
00515             object were modeling a real Car then the Clutch method would
00516             engage the clutch the specified amount.
00517
00518   Args:     short nEngaged)
00519               Percent clutch is engaged (0 to 100%).
00520
00521   Modifies: .
00522
00523   Returns:  HRESULT
00524               Delegated HRESULT.
00525 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00526 STDMETHODIMP COUtilityCruiseCar::CImpICar::Clutch(
00527                short nEngaged)
00528 {
00529   LOGF1("C: COUtilityCruiseCar::CImpICar::Clutch. Delegating. nEngaged=%i.", nEngaged);
00530
00531   // Delegate this call to the contained COCruiseCar's ICar::Clutch.
00532   return m_pBackObj->m_pICar->Clutch(nEngaged);
00533 }
00534
00535
00536 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00537   Method:   COUtilityCruiseCar::CImpICar::Speed
00538
00539   Summary:  The Propel member method of this ICar interface
00540             implementation. A simple empty method on a COUtilityCruiseCar
00541             COM object for tutorial purposes.  Presumably if this Car
00542             object were modeling a real Car then this method would
00543             accelerate/brake to bring the car to the specified speed.
00544
00545   Args:     short nMph
00546               New speed in miles per hour.
00547
00548   Modifies: .
00549
00550   Returns:  HRESULT
00551               Delegated HRESULT.
00552 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00553 STDMETHODIMP COUtilityCruiseCar::CImpICar::Speed(
00554                short nMph)
00555 {
00556   LOGF1("C: COUtilityCruiseCar::CImpICar::Speed. Delegating. nMph=%i.",nMph);
00557
00558   // Delegate this call to the contained COCruiseCar's ICar::Speed.
00559   return m_pBackObj->m_pICar->Speed(nMph);
00560 }
00561
00562
00563 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00564   Method:   COUtilityCruiseCar::CImpICar::Steer
00565
00566   Summary:  The Steer member method of this ICar interface implementation.
00567             A simple empty method on a COUtilityCruiseCar COM object for
00568             tutorial purposes.  Presumably if this Car object were
00569             modeling a real Car then the Steer method would set the
00570             steering angle of the Car.
00571
00572   Args:     short nAngle)
00573               0 degrees straight ahead, -45 Full left, +45 Full right.
00574
00575   Modifies: .
00576
00577   Returns:  HRESULT
00578               Delegated HRESULT.
00579 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00580 STDMETHODIMP COUtilityCruiseCar::CImpICar::Steer(
00581                short nAngle)
00582 {
00583   LOGF1("C: COUtilityCruiseCar::CImpICar::Steer. Delegating. nAngle=%i.",nAngle);
00584
00585   // Delegate this call to the contained COCruiseCar's ICar::Steer.
00586   return m_pBackObj->m_pICar->Steer(nAngle);
00587 }
00588
00589
00590 /*---------------------------------------------------------------------------
00591   COUtilityCruiseCar's nested implementation of the ICruise interface
00592   including Constructor, Destructor, QueryInterface, AddRef, Release,
00593   Engage, and Adjust.
00594 ---------------------------------------------------------------------------*/
00595
00596 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00597   Method:   COUtilityCruiseCar::CImpICruise::CImpICruise
00598
00599   Summary:  Constructor for the CImpICruise interface instantiation.
00600
00601   Args:     COUtilityCruiseCar* pBackObj,
00602               Back pointer to the parent outer object.
00603             IUnknown* pUnkOuter,
00604               Pointer to the outer Unknown.  For delegation.
00605
00606   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00607
00608   Returns:  void
00609 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00610 COUtilityCruiseCar::CImpICruise::CImpICruise(
00611   COUtilityCruiseCar* pBackObj,
00612   IUnknown* pUnkOuter)
00613 {
00614   // Init the Interface Ref Count (used for debugging only).
00615   m_cRefI = 0;
00616
00617   // Init the Back Object Pointer to point to the outer object.
00618   m_pBackObj = pBackObj;
00619
00620   // Init the CImpICruise interface's delegating Unknown pointer.  We use
00621   // the Back Object pointer for IUnknown delegation here if we are not
00622   // being aggregated.  If we are being aggregated we use the supplied
00623   // pUnkOuter for IUnknown delegation.  In either case the pointer
00624   // assignment requires no AddRef because the CImpICruise lifetime is
00625   // quaranteed by the lifetime of the parent object in which
00626   // CImpICruise is nested.
00627   if (NULL == pUnkOuter)
00628   {
00629     m_pUnkOuter = pBackObj;
00630     LOG("C: COUtilityCruiseCar::CImpICruise Constructor. Non-Aggregating");
00631   }
00632   else
00633   {
00634     m_pUnkOuter = pUnkOuter;
00635     LOG("C: COUtilityCruiseCar::CImpICruise Constructor. Aggregating");
00636   }
00637
00638   return;
00639 }
00640
00641
00642 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00643   Method:   COUtilityCruiseCar::CImpICruise::~CImpICruise
00644
00645   Summary:  Destructor for the CImpICruise interface instantiation.
00646
00647   Args:     void
00648
00649   Modifies: .
00650
00651   Returns:  void
00652 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00653 COUtilityCruiseCar::CImpICruise::~CImpICruise(void)
00654 {
00655   LOG("C: COUtilityCruiseCar::CImpICruise Destructor.");
00656
00657   return;
00658 }
00659
00660
00661 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00662   Method:   COUtilityCruiseCar::CImpICruise::QueryInterface
00663
00664   Summary:  The QueryInterface IUnknown member of this ICruise interface
00665             implementation that delegates to m_pUnkOuter, whatever it is.
00666
00667   Args:     REFIID riid,
00668               [in] GUID of the Interface being requested.
00669             PPVOID ppv)
00670               [out] Address of the caller's pointer variable that will
00671               receive the requested interface pointer.
00672
00673   Modifies: .
00674
00675   Returns:  HRESULT
00676               Returned by the delegated outer QueryInterface call.
00677 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00678 STDMETHODIMP COUtilityCruiseCar::CImpICruise::QueryInterface(
00679                REFIID riid,
00680                PPVOID ppv)
00681 {
00682   LOG("C: COUtilityCruiseCar::CImpICruise::QueryInterface. Delegating.");
00683
00684   // Delegate this call to the outer object's QueryInterface.
00685   return m_pUnkOuter->QueryInterface(riid, ppv);
00686 }
00687
00688
00689 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00690   Method:   COUtilityCruiseCar::CImpICruise::AddRef
00691
00692   Summary:  The AddRef IUnknown member of this ICruise interface
00693             implementation that delegates to m_pUnkOuter, whatever it is.
00694
00695   Args:     void
00696
00697   Modifies: m_cRefI.
00698
00699   Returns:  ULONG
00700               Returned by the delegated outer AddRef call.
00701 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00702 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpICruise::AddRef(void)
00703 {
00704   // Increment the Interface Reference Count.
00705   ++m_cRefI;
00706
00707   LOGF1("C: COUtilityCruiseCar::CImpICruise::Addref. Delegating. New cI=%i.", m_cRefI);
00708
00709   // Delegate this call to the outer object's AddRef.
00710   return m_pUnkOuter->AddRef();
00711 }
00712
00713
00714 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00715   Method:   COUtilityCruiseCar::CImpICruise::Release
00716
00717   Summary:  The Release IUnknown member of this ICruise interface
00718             implementation that delegates to m_pUnkOuter, whatever it is.
00719
00720   Args:     void
00721
00722   Modifies: .
00723
00724   Returns:  ULONG
00725               Returned by the delegated outer Release call.
00726 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00727 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpICruise::Release(void)
00728 {
00729   // Decrement the Interface Reference Count.
00730   --m_cRefI;
00731
00732   LOGF1("C: COUtilityCruiseCar::CImpICruise::Release. Delegating. New cI=%i.", m_cRefI);
00733
00734   // Delegate this call to the outer object's Release.
00735   return m_pUnkOuter->Release();
00736 }
00737
00738
00739 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00740   Method:   COUtilityCruiseCar::CImpICruise::Engage
00741
00742   Summary:  The Engage member method of this ICruise interface
00743             implementation.  A simple empty method on a COUtilityCruiseCar
00744             COM object for tutorial purposes.  Presumably if this Car
00745             object were modeling a real Car then the Engage method would
00746             turn the Cruise control system on or off.
00747
00748   Args:     BOOL bOnOff)
00749               TRUE for On; FALSE for Off.
00750
00751   Modifies: .
00752
00753   Returns:  HRESULT
00754               Delegated HRESULT.
00755 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00756 STDMETHODIMP COUtilityCruiseCar::CImpICruise::Engage(
00757                BOOL bOnOff)
00758 {
00759   LOGF1("C: COUtilityCruiseCar::CImpICruise::Engage. Delegating. bOnOff=%i.",bOnOff);
00760
00761   // Delegate this call to the contained COCruiseCar's ICruise::Engage.
00762   m_pBackObj->m_pICruise->Engage(bOnOff);
00763
00764   return NOERROR;
00765 }
00766
00767
00768 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00769   Method:   COUtilityCruiseCar::CImpICruise::Adjust
00770
00771   Summary:  The Adjust member method of this ICruise interface
00772             implementation.  A simple empty method on a COUtilityCruiseCar
00773             COM object for tutorial purposes.  Presumably if this Car
00774             object were modeling a real Car then the Adjust method would
00775             allow notching the cruise set speed up or down by increments
00776             of 3 mph.
00777
00778   Args:     BOOL bUpDown)
00779               TRUE for Up; FALSE for Down.
00780
00781   Modifies: .
00782
00783   Returns:  HRESULT
00784               Delegated HRESULT.
00785 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00786 STDMETHODIMP COUtilityCruiseCar::CImpICruise::Adjust(
00787                BOOL bUpDown)
00788 {
00789   LOGF1("C: COUtilityCruiseCar::CImpICruise::Adjust. Delegating. bUpDown=%i.",bUpDown);
00790
00791   // Delegate this call to the contained COCruiseCar's ICruise::Adjust.
00792   m_pBackObj->m_pICruise->Adjust(bUpDown);
00793
00794   return NOERROR;
00795 }
00796
00797
00798 /*---------------------------------------------------------------------------
00799   COUtilityCruiseCar's nested implementation of the IUtility interface
00800   including methods: Constructor, Destructor, QueryInterface, AddRef,
00801   Release, Offroad, and Winch.
00802 ---------------------------------------------------------------------------*/
00803
00804 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00805   Method:   COUtilityCruiseCar::CImpIUtility::CImpIUtility
00806
00807   Summary:  Constructor for the CImpIUtility interface instantiation.
00808
00809   Args:     COUtilityCruiseCar* pBackObj,
00810               Back pointer to the parent outer object.
00811             IUnknown* pUnkOuter)
00812               Pointer to the outer Unknown.  For delegation.
00813
00814   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00815
00816   Returns:  void
00817 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00818 COUtilityCruiseCar::CImpIUtility::CImpIUtility(
00819   COUtilityCruiseCar* pBackObj,
00820   IUnknown* pUnkOuter)
00821 {
00822   // Init the Interface Ref Count (used for debugging only).
00823   m_cRefI = 0;
00824
00825   // Init the Back Object Pointer to point to the outer object.
00826   m_pBackObj = pBackObj;
00827
00828   // Init the CImpIUtility interface's delegating IUnknown pointer.  We use
00829   // the Back Object pointer for IUnknown delegation here if we are not
00830   // being aggregated.  If we are being aggregated we use the supplied
00831   // pUnkOuter for IUnknown delegation.  In either case the pointer
00832   // assignment requires no AddRef because the CImpIUtility lifetime is
00833   // quaranteed by the lifetime of the parent object in which
00834   // CImpIUtility is nested.
00835   if (NULL == pUnkOuter)
00836   {
00837     m_pUnkOuter = pBackObj;
00838     LOG("C: COUtilityCruiseCar::CImpIUtility Constructor. Non-Aggregating.");
00839   }
00840   else
00841   {
00842     m_pUnkOuter = pUnkOuter;
00843     LOG("C: COUtilityCruiseCar::CImpIUtility Constructor. Aggregating.");
00844   }
00845
00846   return;
00847 }
00848
00849
00850 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00851   Method:   COUtilityCruiseCar::CImpIUtility::~CImpIUtility
00852
00853   Summary:  Destructor for the CImpIUtility interface instantiation.
00854
00855   Args:     void
00856
00857   Modifies: .
00858
00859   Returns:  void
00860 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00861 COUtilityCruiseCar::CImpIUtility::~CImpIUtility(void)
00862 {
00863   LOG("C: COUtilityCruiseCar::CImpIUtility Destructor.");
00864
00865   return;
00866 }
00867
00868
00869 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00870   Method:   COUtilityCruiseCar::CImpIUtility::QueryInterface
00871
00872   Summary:  The QueryInterface IUnknown member of this IUtility interface
00873             implementation that delegates to m_pUnkOuter, whatever it is.
00874
00875   Args:     REFIID riid,
00876               [in] GUID of the Interface being requested.
00877             PPVOID ppv)
00878               [out] Address of the caller's pointer variable that will
00879               receive the requested interface pointer.
00880
00881   Modifies: .
00882
00883   Returns:  HRESULT
00884               Returned by the delegated outer QueryInterface call.
00885 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00886 STDMETHODIMP COUtilityCruiseCar::CImpIUtility::QueryInterface(
00887                REFIID riid,
00888                PPVOID ppv)
00889 {
00890   LOG("C: COUtilityCruiseCar::CImpIUtility::QueryInterface. Delegating.");
00891
00892   // Delegate this call to the outer object's QueryInterface.
00893   return m_pUnkOuter->QueryInterface(riid, ppv);
00894 }
00895
00896
00897 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00898   Method:   COUtilityCruiseCar::CImpIUtility::AddRef
00899
00900   Summary:  The AddRef IUnknown member of this IUtility interface
00901             implementation that delegates to m_pUnkOuter, whatever it is.
00902
00903   Args:     void
00904
00905   Modifies: m_cRefI.
00906
00907   Returns:  ULONG
00908               Returned by the delegated outer AddRef call.
00909 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00910 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpIUtility::AddRef(void)
00911 {
00912   // Increment the Interface Reference Count.
00913   ++m_cRefI;
00914
00915   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Addref. Delegating. New cI=%i.", m_cRefI);
00916
00917   // Delegate this call to the outer object's AddRef.
00918   return m_pUnkOuter->AddRef();
00919 }
00920
00921
00922 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00923   Method:   COUtilityCruiseCar::CImpIUtility::Release
00924
00925   Summary:  The Release IUnknown member of this IUtility interface
00926             implementation that delegates to m_pUnkOuter, whatever it is.
00927
00928   Args:     void
00929
00930   Modifies: .
00931
00932   Returns:  ULONG
00933               Returned by the delegated outer Release call.
00934 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00935 STDMETHODIMP_(ULONG) COUtilityCruiseCar::CImpIUtility::Release(void)
00936 {
00937   // Decrement the Interface Reference Count.
00938   --m_cRefI;
00939
00940   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Release. Delegating. New cI=%i.", m_cRefI);
00941
00942   // Delegate this call to the outer object's Release.
00943   return m_pUnkOuter->Release();
00944 }
00945
00946
00947 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00948   Method:   COUtilityCruiseCar::CImpIUtility::Offroad
00949
00950   Summary:  The Offroad member method of this IUtility interface
00951             implementation.  A simple empty method on a COUtilityCruiseCar
00952             COM object for tutorial purposes.  Presumably if this
00953             UtilityCruise Car object were modeling a real Car then the
00954             Offroad method would function the 4-wheel drive transfer case
00955             and shift it to the specified 4-wheel drive mode.
00956
00957   Args:     short nGear
00958               0 = 2H or regular 2-wheel drive;
00959               1 = 4H or 4-wheel drive high speed;
00960               2 = neutral; and
00961               3 = 4L or 4-wheel drive low speed).
00962
00963   Modifies: .
00964
00965   Returns:  HRESULT
00966               NOERROR
00967 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00968 STDMETHODIMP COUtilityCruiseCar::CImpIUtility::Offroad(
00969                short nGear)
00970 {
00971   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Offroad. Called. nGear=%i.",nGear);
00972
00973   // We don't delegate because this IUtility implementation is native to
00974   // the composite COUtilityCruiseCar object.
00975
00976   return NOERROR;
00977 }
00978
00979
00980 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00981   Method:   COUtilityCruiseCar::CImpIUtility::Winch
00982
00983   Summary:  The Winch member method of this IUtility interface
00984             implementation.  A simple empty method on a COUtilityCruiseCar
00985             COM object for tutorial purposes.  Presumably if this
00986             UtilityCruiseCar object were modeling a real Car then the
00987             Winch method would turn on/off the front-mounted Winch to the
00988             specified RPMs.
00989
00990   Args:     short nRpm
00991               0 = off; 1 - 50 RPM.
00992
00993   Modifies: .
00994
00995   Returns:  HRESULT
00996               NOERROR
00997 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00998 STDMETHODIMP COUtilityCruiseCar::CImpIUtility::Winch(
00999                short nRpm)
01000 {
01001   LOGF1("C: COUtilityCruiseCar::CImpIUtility::Winch. Called. nRpm=%i.",nRpm);
01002
01003   // We don't delegate because this IUtility implementation is native to
01004   // the composite COUtilityCruiseCar object.
01005
01006   return NOERROR;
01007 }
01008
01009
01010 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01011   Function: CreateUtilityCruiseCar
01012
01013   Summary:  Creates an instance of the COUtilityCruiseCar COM object class
01014             returning a requested interface pointer. COUtilityCruiseCar
01015             uses the Containment reuse technique to incorporate
01016             COCruiseCar features (ie, ICar and ICruise implementations)
01017             into its Interface offerings of IUnknown and IUtility. With
01018             this containment, the ICar and ICruise interfaces are
01019             implemented in COUtilityCruiseCar as delegating interfaces
01020             that delegate to their matching interface implementations in
01021             an instance of the contained COCruiseCar.  COCruiseCar is
01022             provided by the outside APTSERVE.EXE server.
01023
01024   Args:     IUnknown* pUnkOuter,
01025               Pointer the outer Unknown interface.  Non NULL implies
01026               that the new COM object is being created via an
01027               aggregation with an Outer object.  NULL implies that the
01028               object is not being created via aggregation.
01029             REFIID riid,
01030               The GUID of the interface requested on the new COM Object.
01031             PPVOID ppv)
01032               Address of the caller's pointer variable that will
01033               receive the requested interface pointer.
01034
01035   Returns:  HRESULT
01036               NOERROR if successful, CLASS_E_NOAGREGATION if IUnknown is
01037               not requested with non-NULL pUnkOuter, or other errors as
01038               appropriate.
01039 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01040 HRESULT CreateUtilityCruiseCar(
01041           IUnknown* pUnkOuter,
01042           REFIID riid,
01043           PPVOID ppv)
01044 {
01045   HRESULT hr;
01046   COUtilityCruiseCar* pCob;
01047
01048   LOGF1("C: CreateUtilityCruiseCar. pUnkOuter=0x%X.",pUnkOuter);
01049
01050   // If the creation call is requesting aggregation (pUnkOuter != NULL),
01051   // the COM rules state the IUnknown interface MUST also be concomitantly
01052   // requested.  If it is not so requested ( riid != IID_IUnknown) then
01053   // an error must be returned indicating that no aggregate creation of
01054   // the COUtilityCruiseCar COM Object can be performed using anything
01055   // other than a controlling IUnknown interface.
01056   if (NULL != pUnkOuter && riid != IID_IUnknown)
01057     hr = CLASS_E_NOAGGREGATION;
01058   else
01059   {
01060     // Instantiate a COUtilityCruiseCar COM Object.
01061     pCob = new COUtilityCruiseCar(pUnkOuter);
01062     if (NULL != pCob)
01063     {
01064       // If we have succeeded in instantiating the COUtilityCruiseCar object
01065       // we initialize it (with any subordinate COM objects) to offer it's
01066       // interfaces.
01067       hr = pCob->Init();
01068       if (SUCCEEDED(hr))
01069       {
01070         // We QueryInterface this new COM Object not only to deposit the
01071         // main interface pointer to the caller's pointer variable, but to
01072         // also automatically bump the Reference Count on the new COM
01073         // Object after handing out this *ppv reference to it.
01074         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
01075       }
01076       else
01077         DELETE_POINTER(pCob);
01078     }
01079     else
01080       hr = E_OUTOFMEMORY;
01081   }
01082
01083   if (SUCCEEDED(hr))
01084   {
01085     LOGF1("C: CreateUtilityCruiseCar Succeeded. *ppv=0x%X.",*ppv);
01086   }
01087   else
01088   {
01089     LOGF1("C: CreateUtilityCruiseCar Failed. hr=0x%X.",hr);
01090   }
01091
01092   return hr;
01093 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Critsect.Cpp Source File

  • NetDS
  • SyncMgr
  • SyncDir

Critsect.Cpp

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #include "precomp.h"
00013
00014 //+---------------------------------------------------------------------------
00015 //
00016 //  Member:     CLockHandler::CLockHandler, public
00017 //
00018 //  Synopsis:   Constructor
00019 //
00020 //  Arguments:
00021 //
00022 //  Returns:
00023 //
00024 //  Modifies:
00025 //
00026 //----------------------------------------------------------------------------
00027
00028 CLockHandler::CLockHandler()
00029 {
00030     m_dwLockThreadId = 0;
00031     InitializeCriticalSection(&m_CriticalSection);
00032 }
00033
00034 //+---------------------------------------------------------------------------
00035 //
00036 //  Member:     CLockHandler::~CLockHandler, public
00037 //
00038 //  Synopsis:   Destructor
00039 //
00040 //  Arguments:
00041 //
00042 //  Returns:
00043 //
00044 //  Modifies:
00045 //
00046 //----------------------------------------------------------------------------
00047
00048 CLockHandler::~CLockHandler()
00049 {
00050     Assert (0 == m_dwLockThreadId);
00051     DeleteCriticalSection(&m_CriticalSection);
00052 }
00053
00054 //+---------------------------------------------------------------------------
00055 //
00056 //  Member:     CLockHandler::Lock, public
00057 //
00058 //  Synopsis:   Adds a lock to the specified class
00059 //
00060 //  Arguments:
00061 //
00062 //  Returns:
00063 //
00064 //  Modifies:
00065 //
00066 //----------------------------------------------------------------------------
00067
00068 void CLockHandler::Lock(DWORD dwThreadId)
00069 {
00070     EnterCriticalSection(&m_CriticalSection);
00071
00072     m_dwLockThreadId = dwThreadId;
00073 }
00074
00075 //+---------------------------------------------------------------------------
00076 //
00077 //  Member:     CLockHandler::UnLock, public
00078 //
00079 //  Synopsis:   Removes a lock to the specified class
00080 //
00081 //  Arguments:
00082 //
00083 //  Returns:
00084 //
00085 //  Modifies:
00086 //
00087 //----------------------------------------------------------------------------
00088
00089 void CLockHandler::UnLock()
00090 {
00091     m_dwLockThreadId = 0;
00092     LeaveCriticalSection(&m_CriticalSection);
00093 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAdvClientDlg Member List

This is the complete list of members for CAdvClientDlg, including all inherited members.
AddBinding(IWbemClassObject *pConsumer, IWbemClassObject *pFilter) | CAdvClientDlg | [private]
AddFilter(IWbemClassObject **pFilter) | CAdvClientDlg | [private]
AssociateToMachine(IWbemClassObject *pEquipInst) | CAdvClientDlg | [private]
CAdvClientDlg(CWnd *pParent=NULL) | CAdvClientDlg |
CheckOfficeNamespace(void) | CAdvClientDlg | [private]
DisplayEvents(CAdvClientDlg *pThis, LONG lObjectCount, IWbemClassObject **ppObjArray) | CAdvClientDlg | [private, static]
DoDataExchange(CDataExchange *pDX) | CAdvClientDlg | [protected, virtual]
EnsureOfficeNamespace(void) | CAdvClientDlg | [private]
GetCompSysRef(VARIANT *v) | CAdvClientDlg | [private]
GetConsumer(IWbemClassObject **pConsumer) | CAdvClientDlg | [private]
IDD enum value | CAdvClientDlg |
m_addEquipment | CAdvClientDlg |
m_connect | CAdvClientDlg |
m_critSect | CAdvClientDlg | [private]
m_diskDescriptions | CAdvClientDlg |
m_diskDetails | CAdvClientDlg |
m_enumDisks | CAdvClientDlg |
m_enumServices | CAdvClientDlg |
m_enumServicesAsync | CAdvClientDlg |
m_eventList | CAdvClientDlg |
m_namespace | CAdvClientDlg |
m_outputList | CAdvClientDlg |
m_perm | CAdvClientDlg |
m_pIWbemServices | CAdvClientDlg | [private]
m_pOfficeService | CAdvClientDlg | [private]
m_pQueryCallback | CAdvClientDlg | [private]
m_pStream | CAdvClientDlg | [private]
m_ptrReady | CAdvClientDlg | [private]
m_regPerm | CAdvClientDlg | [private]
m_regTemp | CAdvClientDlg | [private]
m_stopThread | CAdvClientDlg | [private]
m_temp | CAdvClientDlg |
m_thread | CAdvClientDlg | [private]
m_threadId | CAdvClientDlg | [private]
OnAddEquipment() | CAdvClientDlg | [protected]
OnCancel() | CAdvClientDlg | [protected, virtual]
OnConnect() | CAdvClientDlg | [protected]
OnDiskdetails() | CAdvClientDlg | [protected]
OnDiskPropsDescriptions() | CAdvClientDlg | [protected]
OnEnumdisks() | CAdvClientDlg | [protected]
OnEnumservices() | CAdvClientDlg | [protected]
OnEnumservicesasync() | CAdvClientDlg | [protected]
OnInitDialog() | CAdvClientDlg | [protected, virtual]
OnPermRegister() | CAdvClientDlg | [private]
OnPermUnregister() | CAdvClientDlg | [private]
OnRegPerm() | CAdvClientDlg | [protected]
OnRegTemp() | CAdvClientDlg | [protected]
OnSysCommand(UINT nID, LPARAM lParam) | CAdvClientDlg | [protected]
OnTempRegister() | CAdvClientDlg | [private]
OnTempUnregister() | CAdvClientDlg | [private]
PermRegistered() | CAdvClientDlg | [private]
StopThread() | CAdvClientDlg | [private]
ThreadProc(LPVOID lpParameter) | CAdvClientDlg | [private, static]
~CAdvClientDlg() | CAdvClientDlg | [virtual]
Generated on Wed Nov 13 2024 16:55:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CExeModule Member List

This is the complete list of members for CExeModule, including all inherited members.
bActivity | CExeModule
dwThreadID | CExeModule
hEventShutdown | CExeModule
MonitorShutdown() | CExeModule
MonitorShutdown() | CExeModule
MonitorShutdown() | CExeModule
MonitorShutdown() | CExeModule
MonitorShutdown() | CExeModule
MonitorShutdown() | CExeModule
StartMonitor() | CExeModule
StartMonitor() | CExeModule
StartMonitor() | CExeModule
StartMonitor() | CExeModule
StartMonitor() | CExeModule
StartMonitor() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Unlock() | CExeModule
Generated on Wed Nov 13 2024 16:56:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/FullIME/Main.C Source File

  • WinUI
  • Input
  • Ime
  • FullIME

Main.C

Go to the documentation of this file.
00001 /************************************************************************
00002 *
00003 * Title:
00004 *
00005 *   Main.C - IME Full-aware Simple Text Editor (DBCS version)
00006 *
00007 * Purpose:
00008 *
00009 *   Sample program for DBCS programming and IME full-aware aappliction.
00010 *
00011 * Synopsis:
00012 *
00013 *   This program is designed as a bare-bone example to demonstrate the
00014 *   basic elements of DBCS-enabling, and how to design an IME full-aware
00015 *   application.
00016 *
00017 *   The data structure is a fixed-size 2-dimensional byte array.  The
00018 *   font is the fixed-pitch system font.  Rudimentary text editing
00019 *   functions, such as the basic cursor movements, insertion, deletion,
00020 *   have been implemented.
00021 *
00022 *   When you run this program in a Far East Windows environment, it
00023 *   should be apparent that it doesn't handle DBCS character very well.
00024 *   It is your job to locate and modify the pieces inside this program
00025 *   that need to be DBCS-enabled.
00026 *
00027 * DBCS-enabling notes:
00028 *
00029 *   This version of STE is DBCS-enabled with respect to character input,
00030 *   caret shape and movement, and mouse clicking.  It should work on
00031 *   any version of Far East Windows since 3.0.
00032 *
00033 *   As far as source code maintenance goes, there are generally two
00034 *   approaches.
00035 *
00036 *   The first is to add DBCS enabling code under '#ifdef DBCS'.  The
00037 *   advantage of this approach is that it keeps the DBCS enabling code
00038 *   distinct from the SBCS, so it's easier to add them in, and also to
00039 *   remove them later.  (For example, when you want to replace DBCS
00040 *   enabling with Unicode enabling.)  The drawback is that because the
00041 *   DBCS and the SBCS logic are not integrated, they can easily get out
00042 *   of sync (as the SBCS code evolves.)
00043 *
00044 *   The second approach, which is adopted by this sample app, is to
00045 *   integrate DBCS enabling with SBCS.  It takes longer to do, but
00046 *   the resulting source is easier to maintain.  Since IsDBCSLeadByte
00047 *   is at the heart of any DBCS-enabling logic, an additional speed up
00048 *   for generating an SBCS-only version is to define that function as
00049 *   FALSE, and let the compiler optimize the DBCS logic away.
00050 *
00051 * IME Full-Aware notes:
00052 *
00053 *   This version of STE is an IME full-aware application with most of
00054 *   IME UI capiabilities to display IME UI by itself. It should work
00055 *   on any version of Far Windows since 4.0.
00056 *
00057 *   This kind of application typically wants to be fully responsible to
00058 *   display any information given by IME. Ii will handle the input context
00059 *   by itself and duisplay any necessary information given by the
00060 *   input context not using IME UI.
00061 *
00062 * History:
00063 *
00064 *   17-Aug-1992  created
00065 *   28-Sep-1992  added DBCS-enabling
00066 *   30-Sep-1992  bug fixes
00067 *   25-Mar-1994  added IME full-aware logics
00068 *
00069 ************************************************************************/
00070
00071 #include <assert.h>
00072 #include <windows.h>
00073 #include <imm.h>
00074 #include "FullIME.h"
00075
00076
00077 /************************************************************************
00078 *
00079 *   SteRegister - standard class registration routine
00080 *
00081 ************************************************************************/
00082 int SteRegister(
00083     HANDLE hInstance )
00084 {
00085     BOOL bSuccess = TRUE;
00086     int WINAPI SteWndProc( HWND, UINT, UINT, LONG );
00087
00088     PWNDCLASS pWndClass;
00089
00090     pWndClass=(PWNDCLASS)LocalAlloc(LPTR, sizeof(WNDCLASS));
00091     if (NULL == pWndClass)
00092     {
00093         bSuccess = FALSE;
00094         goto exit_func;
00095     }
00096
00097     pWndClass->hCursor       = LoadCursor( NULL, IDC_IBEAM );
00098     pWndClass->hIcon         = LoadIcon( hInstance, MAKEINTRESOURCE(ID_ICON));
00099     pWndClass->lpszMenuName  = MAKEINTRESOURCE(ID_MENU);
00100     pWndClass->hInstance     = hInstance;
00101     pWndClass->lpszClassName = szSteClass;
00102     pWndClass->lpfnWndProc   = (WNDPROC)SteWndProc;
00103     pWndClass->hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
00104     pWndClass->style         = CS_BYTEALIGNCLIENT | CS_CLASSDC;
00105
00106     if ( 0 == RegisterClass( (LPWNDCLASS)pWndClass ) )
00107     {
00108         bSuccess = FALSE;
00109         goto exit_func;
00110     }
00111
00112     pWndClass->hCursor       = LoadCursor( NULL,IDC_ARROW );
00113     pWndClass->hIcon         = NULL;
00114     pWndClass->lpszMenuName  = NULL;
00115     pWndClass->hInstance     = hInstance;
00116     pWndClass->lpszClassName = szCandClass;
00117     pWndClass->lpfnWndProc   = (WNDPROC)CandWndProc;
00118     pWndClass->hbrBackground = GetStockObject( LTGRAY_BRUSH );
00119     pWndClass->style         = CS_HREDRAW | CS_VREDRAW;
00120
00121     if ( 0 == RegisterClass( (LPWNDCLASS)pWndClass ) )
00122     {
00123         bSuccess = FALSE;
00124         goto exit_func;
00125     }
00126
00127     if ( NULL != LocalFree( (HANDLE)pWndClass ) )
00128     {
00129         bSuccess = FALSE;
00130     }
00131
00132 exit_func:
00133     return bSuccess;
00134 }
00135
00136
00137 /************************************************************************
00138 *
00139 *   WinMain
00140 *
00141 ************************************************************************/
00142 int PASCAL WinMain(
00143     HINSTANCE hInstance,
00144     HINSTANCE hPrevInstance,
00145     LPSTR lpszCmdLine,
00146     int nCmdShow )
00147 {
00148     MSG msg = {0};
00149     HWND hWnd = NULL;
00150     BOOL bRet;
00151     BOOL bSuccess = TRUE;
00152
00153
00154     LoadString( hInstance, IDS_CLASS, szSteClass, 14 );
00155     LoadString( hInstance, IDS_TITLE, szSteTitle, 55 );
00156     LoadString( hInstance, IDS_CANDUI, szSteCandUIClass, 12 );
00157     LoadString( hInstance, IDS_COMPTITLE, szSteCompTitle, 55 );
00158     LoadString( hInstance, IDS_CANDTITLE, szSteCandTitle, 55 );
00159     LoadString( hInstance, IDS_CANDCLASS, szCandClass, 20 );
00160
00161     if ( !SteRegister( hInstance ) )
00162     {
00163         bSuccess = FALSE;
00164         goto exit_func;
00165     }
00166
00167     if ( !(hWnd = CreateWindow( szSteClass, szSteTitle,
00168                                 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
00169                                 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
00170                                 NULL, NULL, hInstance, NULL)) )
00171     {
00172         bSuccess = FALSE;
00173         goto exit_func;
00174     }
00175
00176     //
00177     // Create window with just enough client space for the text buffer
00178     //
00179     SetWindowPos( hWnd, 0, 0, 0,
00180                   MAXCOL*cxMetrics + GetSystemMetrics(SM_CXBORDER)*2,
00181                   MAXROW*cyMetrics + GetSystemMetrics(SM_CYBORDER)*2
00182                     + GetSystemMetrics(SM_CYCAPTION)
00183                     + GetSystemMetrics(SM_CYMENU),
00184                   SWP_NOZORDER );
00185     ShowWindow( hWnd, nCmdShow );
00186
00187     //
00188     // IME initial state.
00189     //
00190     gImeUIData.ImeState = 0;
00191
00192     while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
00193     {
00194         if (bRet == -1)
00195         {
00196             // handle the error and possibly exit
00197             bSuccess = FALSE;
00198             goto exit_func;
00199         }
00200         else
00201         {
00202             TranslateMessage(&msg);
00203             DispatchMessage(&msg);
00204         }
00205     }
00206
00207 exit_func:
00208     if (bSuccess)
00209     {
00210         return (int)msg.wParam;
00211     }
00212     else
00213     {
00214         return 0;
00215     }
00216 }
00217
00218
00219 /************************************************************************
00220 *
00221 *   SteIMEOpenClose - This routines calls IMM API to open or close IME.
00222 *
00223 ************************************************************************/
00224 void SteImeOpenClose(
00225     HWND hWnd,
00226     BOOL fFlag )
00227 {
00228   HIMC hIMC;
00229
00230   //
00231   // If fFlag is true then open IME; otherwise close it.
00232   //
00233
00234     if ( !( hIMC = ImmGetContext( hWnd ) ) )
00235         return;
00236
00237     ImmSetOpenStatus( hIMC, fFlag );
00238     ImmReleaseContext( hWnd, hIMC );
00239 }
00240
00241
00242 /************************************************************************
00243 *
00244 *   SteCreate - WM_CREATE message handler
00245 *
00246 ************************************************************************/
00247 void SteCreate(
00248     HWND hWnd )
00249 {
00250     HDC        hdc;
00251     TEXTMETRIC tm = {0};
00252     int        i;
00253     WORD       patern = 0xA4A4;
00254     SIZE       size;
00255     HFONT      hFont;
00256     LOGFONT    lFont = {0};
00257
00258     //
00259     // Note that this window has a class DC
00260     //
00261
00262     hdc = GetDC( hWnd );
00263
00264     //
00265     // Select fixed pitch system font and get its text metrics
00266     //
00267
00268     hfntFixed = GetStockObject( SYSTEM_FIXED_FONT );
00269     hfntOld = SelectObject( hdc, hfntFixed );
00270     GetTextMetrics( hdc, &tm );
00271     ReleaseDC( hWnd, hdc );
00272
00273     GetTextExtentPoint( hdc, (LPSTR)&patern, sizeof( WORD), (LPSIZE) &size );
00274
00275 //    cxMetrics = tm.tmAveCharWidth;
00276 //    cyMetrics = tm.tmHeight;
00277
00278     cxMetrics = (UINT) size.cx / 2;
00279     cyMetrics = (UINT) size.cy;
00280
00281     //
00282     // Determine the version of DBCS Windows from system font charset ID.
00283     // Then hardcode a DBCS character value for the 'Pattern/DBCS' command.
00284     // The value is the Han character for 'door' or 'gate', which is
00285     // left-right symmetrical.
00286     //
00287
00288     switch( tm.tmCharSet )
00289     {
00290     case SHIFTJIS_CHARSET:
00291         DBCSFillChar = 0x96e5;
00292         break;
00293
00294     case HANGEUL_CHARSET:
00295         DBCSFillChar = 0xdaa6;
00296         break;
00297
00298     case CHINESEBIG5_CHARSET:
00299         DBCSFillChar = 0xaaf9;
00300         break;
00301
00302     default:
00303         DBCSFillChar = 0x7071;  // 'pq'
00304         break;
00305     }
00306
00307     //
00308     // Initialize caret width.  Fat in INSERT mode, skinny in OVERTYPE mode.
00309     //
00310
00311     fInsertMode = FALSE;
00312     CaretWidth = cxOverTypeCaret = GetSystemMetrics( SM_CXBORDER );
00313
00314     //
00315     // Sets the logical font to be used to display characters in the
00316     // composition window. Especially for at caret or near caret operation,
00317     // application should set composition font.
00318     //
00319     // If Application provides user to dynamicly change font, each time after
00320     // user change font, application should set composition font again.
00321     //
00322
00323     if ( ( hFont = (HFONT)SendMessage( hWnd, WM_GETFONT, 0, 0L ) ) != NULL )
00324     {
00325         if ( GetObject( hFont, sizeof(LOGFONT), (LPVOID)&lFont ) )
00326         {
00327             HIMC  hImc;
00328
00329             if ( (  hImc = ImmGetContext( hWnd ) ) )
00330             {
00331                 ImmSetCompositionFont( hImc, &lFont );
00332                 ImmReleaseContext( hWnd, hImc );
00333             }
00334         }
00335     }
00336
00337     //
00338     // Get the property and apiabilities of current keyboard layout(IME).
00339     // If the keyboard layout is US, the return value will be zero.
00340     //
00341
00342     gImeUIData.fdwProperty = ImmGetProperty( GetKeyboardLayout(0),
00343                                              IGP_PROPERTY );
00344
00345     //
00346     // Initialize candidate list window array.
00347     //
00348
00349     for( i = 0; i < MAX_LISTCAND; i++ )
00350     {
00351          gImeUIData.hListCand[ i ] = NULL;
00352          gImeUIData.hListCandMem[ i ] = NULL;
00353     }
00354
00355
00356     PostMessage( hWnd, WM_COMMAND, IDC_CLEAR, 0L );
00357
00358
00359     //
00360     // Initialise the current keyboard layout.
00361     //
00362
00363     hCurKL = GetKeyboardLayout(0L);
00364 }
00365
00366
00367 /************************************************************************
00368 *
00369 *   ResetCaret - Reset caret shape to match input mode (overtype/insert)
00370 *
00371 ************************************************************************/
00372 void ResetCaret(
00373     HWND hWnd )
00374 {
00375     HideCaret( hWnd );
00376     DestroyCaret();
00377     CreateCaret( hWnd,
00378                  NULL,
00379                  (fInsertMode && IsDBCSLeadByte( textbuf[yPos][xPos] )) ?
00380                  CaretWidth*2 : CaretWidth,
00381                  cyMetrics );
00382     SetCaretPos( xPos * cxMetrics, yPos * cyMetrics );
00383
00384     if ( !( gImeUIData.fdwProperty & IME_PROP_AT_CARET ) &&
00385          !( gImeUIData.fdwProperty & IME_PROP_SPECIAL_UI ) )
00386     {
00387         // near caret.
00388         SetIMECompFormPos( hWnd );
00389     }
00390
00391     ShowCaret( hWnd );
00392 }
00393
00394 /************************************************************************
00395 *
00396 *   SetIMECompFormPos
00397 *
00398 ************************************************************************/
00399 void SetIMECompFormPos(
00400     HWND hWnd )
00401 {
00402     HIMC hIMC = ImmGetContext(hWnd);
00403     POINT point = {0};
00404     COMPOSITIONFORM CompForm;
00405
00406     GetCaretPos( &point );
00407
00408     CompForm.dwStyle = CFS_POINT;
00409
00410     CompForm.ptCurrentPos.x = (long) point.x;
00411     CompForm.ptCurrentPos.y = (long) point.y;
00412
00413     if ( hIMC )
00414         ImmSetCompositionWindow(hIMC,&CompForm);
00415     ImmReleaseContext( hWnd , hIMC);
00416 }
00417
00418
00419 /************************************************************************
00420 *
00421 *   SteCommand - WM_COMMAND handler
00422 *
00423 ************************************************************************/
00424 void SteCommand(
00425     HWND hWnd,
00426     UINT cmd,
00427     LPARAM lParam )
00428 {
00429     switch( cmd )
00430     {
00431     case IDC_CLEAR:
00432         //
00433         // Blank out text buffer.  Return caret to home position
00434         //
00435         for ( yPos = FIRSTROW; yPos <= LASTROW; yPos++ )
00436             for ( xPos = FIRSTCOL; xPos <= LASTCOL; xPos++ )
00437           textbuf[yPos][xPos] = ' ';
00438         break;
00439
00440     case IDC_ANSIFILL: /* fall through */
00441     case IDC_DBCSFILL:
00442         //
00443         // Fill text buffer with ANSI or DBCS pattern
00444         //
00445         for ( yPos = FIRSTROW; yPos <= LASTROW; yPos++ )
00446             for ( xPos = FIRSTCOL; xPos <= LASTCOL; xPos++ )
00447           if ( cmd == IDC_ANSIFILL )
00448               textbuf[yPos][xPos] = 'a';
00449           else {
00450               textbuf[yPos][xPos]   = HIBYTE(DBCSFillChar);
00451               textbuf[yPos][++xPos] = LOBYTE(DBCSFillChar);
00452           }
00453         break;
00454
00455     //
00456     // The following messages are to control IME.
00457     //
00458     case IDC_OPENIME:
00459         SteImeOpenClose( hWnd, TRUE );
00460         goto exit_func;
00461
00462     case IDC_CLOSEIME:
00463         SteImeOpenClose( hWnd, FALSE );
00464         goto exit_func;
00465
00466     }
00467
00468     yPos = FIRSTROW;
00469     xPos = FIRSTCOL;
00470
00471     InvalidateRect( hWnd, (LPRECT)NULL, TRUE );
00472     ResetCaret(hWnd);
00473
00474 exit_func:
00475     return;
00476 }
00477
00478
00479 /************************************************************************
00480 *
00481 *   IsDBCSTrailByte - returns TRUE if the given byte is a DBCS trail byte
00482 *
00483 *                     The algorithm searchs backward in the string, to some
00484 *                     known character boundary, counting consecutive bytes
00485 *                     in the lead byte range. An odd number indicates the
00486 *                     current byte is part of a two byte character code.
00487 *
00488 *   INPUT: PCHAR  - pointer to a preceding known character boundary.
00489 *          PCHAR  - pointer to the character to test.
00490 *
00491 *   OUTPUT:BOOL   - indicating truth of p==trailbyte.
00492 *
00493 ************************************************************************/
00494
00495 BOOL IsDBCSTrailByte(
00496     char *base,
00497     char *p )
00498 {
00499     int lbc = 0;    // lead byte count
00500
00501     assert(base <= p);
00502
00503     while ( p > base )
00504     {
00505         if ( !IsDBCSLeadByte(*(--p)) )
00506             break;
00507         lbc++;
00508     }
00509
00510     return (lbc & 1);
00511 }
00512
00513
00514 /************************************************************************
00515 *
00516 *   MoveCaret
00517 *
00518 ************************************************************************/
00519 BOOL MoveCaret(
00520     HWND hwnd )
00521 {
00522     HIMC hIMC;
00523     BOOL retVal = TRUE;
00524
00525     if ( !( hIMC = ImmGetContext( hwnd ) ) )
00526         goto exit_func;
00527
00528     if ( ImmGetCompositionString( hIMC, GCS_CURSORPOS, (void *)NULL, 0 ) )
00529         retVal = FALSE;
00530
00531     ImmReleaseContext( hwnd, hIMC );
00532
00533 exit_func:
00534     return retVal;
00535 }
00536
00537
00538 /************************************************************************
00539 *
00540 *   VirtualKeyHandler - WM_KEYDOWN handler
00541 *
00542 *
00543 *   INPUT:  HWND - handle to the window for repainting output.
00544 *           UINT - virtual key code.
00545 *
00546 ************************************************************************/
00547
00548 void VirtualKeyHandler(
00549     HWND hWnd,
00550     UINT wParam )
00551 {
00552     int i;
00553     HDC hdc;
00554     static int delta = 1;
00555
00556     if ( ( gImeUIData.ImeState & IME_IN_CHOSECAND ) ||
00557          ( gImeUIData.ImeState & IME_IN_COMPOSITION && !MoveCaret( hWnd ) ) )
00558         return;
00559
00560     switch( wParam )
00561     {
00562     case VK_HOME:   // beginning of line
00563         xPos = FIRSTCOL;
00564         break;
00565
00566     case VK_END:    // end of line
00567         xPos = LASTCOL;
00568         goto check_for_trailbyte;
00569
00570     case VK_RIGHT:
00571         if ( IsDBCSLeadByte( textbuf[yPos][xPos] ) )
00572         {
00573             if (xPos==LASTCOL - 1) break;  //last character don't move
00574             xPos += 2;                     //skip 2 for DB Character
00575         }
00576         else
00577         {
00578             xPos = min( xPos + 1, LASTCOL );
00579         }
00580         break;
00581
00582     case VK_LEFT:
00583         xPos = max( xPos - 1, FIRSTCOL );
00584 check_for_trailbyte:
00585       if ( IsDBCSTrailByte( (LPSTR)textbuf[yPos], (LPSTR)&(textbuf[yPos][xPos]) ) )
00586           xPos--;
00587       break;
00588
00589     case VK_UP:
00590         yPos = max( yPos - 1, FIRSTROW );
00591         goto Virtical_Check_Trail;
00592
00593     case VK_DOWN:
00594         yPos = min( yPos + 1, LASTROW );
00595 Virtical_Check_Trail:
00596         if ( IsDBCSTrailByte( (LPSTR)textbuf[yPos], (LPSTR)&(textbuf[yPos][xPos]) ) )
00597         {
00598             if (xPos<LASTCOL)
00599             {
00600                 xPos+=delta;
00601                 delta *= -1;
00602             }
00603             else
00604             {
00605                 xPos--;
00606             }
00607         }
00608         break;
00609
00610
00611     case VK_INSERT:
00612         //
00613         // Change caret shape to indicate insert/overtype mode
00614         //
00615         fInsertMode = !fInsertMode;
00616         CaretWidth = fInsertMode ? cxMetrics : cxOverTypeCaret;
00617         break;
00618
00619
00620     case VK_BACK:   // backspace
00621
00622         if ( xPos > FIRSTCOL )
00623         {
00624             xPos--;
00625
00626             //
00627             // DB Character so backup one more to allign on boundary
00628             //
00629             if ( IsDBCSTrailByte( (LPSTR)textbuf[yPos], (LPSTR)&(textbuf[yPos][xPos]) ) )
00630           xPos--;
00631             //
00632             // Fall Through to VK_DELETE to adjust row
00633             //
00634         }
00635         else     //FIRST COLUMN  don't backup -- this would change for wrapping
00636         {
00637            break;
00638         }
00639
00640     case VK_DELETE:
00641
00642         if ( !IsDBCSLeadByte( textbuf[yPos][xPos] ) )
00643         {
00644             //
00645             // Move rest of line left by one, then blank out last character
00646             //
00647             for ( i = xPos; i < LASTCOL; i++ )
00648             {
00649                 textbuf[yPos][i] = textbuf[yPos][i+1];
00650             }
00651             textbuf[yPos][LASTCOL] = ' ';
00652
00653         }
00654         else
00655         {
00656             //
00657             // Move line left by two bytes, blank out last two bytes
00658             //
00659             for ( i = xPos; i < LASTCOL-1; i++ )
00660             {
00661               textbuf[yPos][i] = textbuf[yPos][i+2];
00662             }
00663             textbuf[yPos][LASTCOL-1] = ' ';
00664             textbuf[yPos][LASTCOL]   = ' ';
00665         }
00666
00667         //
00668         // Repaint the entire line
00669         //
00670         hdc = GetDC( hWnd );
00671         HideCaret( hWnd );
00672         TextOut( hdc, 0, yPos*cyMetrics, (LPSTR)textbuf[yPos], MAXCOL );
00673         ReleaseDC( hWnd, hdc );
00674         break;
00675
00676     case VK_TAB:    // tab  -- tabs are column allignment not character
00677         {
00678             int xTabMax = xPos + TABSTOP;
00679             int xPosPrev;
00680
00681             do
00682             {
00683                 xPosPrev = xPos;
00684                 SendMessage( hWnd, WM_KEYDOWN, VK_RIGHT, 1L );
00685             } while ( (xPos % TABSTOP) &&
00686                       (xPos < xTabMax) &&
00687                       (xPos != xPosPrev));
00688
00689         }
00690         break;
00691
00692     case VK_RETURN: // linefeed
00693         yPos = min( yPos+1, LASTROW );
00694         xPos = FIRSTCOL;
00695         break;
00696     }
00697
00698     ResetCaret( hWnd );
00699 }
00700
00701
00702 /************************************************************************
00703 *
00704 *   StoreChar - Stores one SBCS character into text buffer and advances
00705 *               cursor
00706 *
00707 ************************************************************************/
00708 void StoreChar(
00709     HWND hWnd,
00710     UCHAR ch )
00711 {
00712     int i;
00713     HDC hdc;
00714
00715     //
00716     // If insert mode, move rest of line to the right by one
00717     //
00718
00719     if ( fInsertMode )
00720     {
00721       for ( i = LASTCOL; i > xPos; i-- )
00722           textbuf[yPos][i] = textbuf[yPos][i-1];
00723
00724       //
00725       // If the row ends on a lead byte, blank it out
00726       // To do this we must first traverse the string
00727       // starting from a known character boundry until
00728       // we reach the last column. If the last column
00729       // is a character boundry then the last character
00730       // is either a single byte or a lead byte
00731       //
00732         for ( i = xPos+1; i < LASTCOL; )
00733         {
00734             if ( IsDBCSLeadByte( textbuf[yPos][i] ) )
00735             {
00736                 i++;
00737             }
00738             i++;
00739       }
00740
00741         if (i==LASTCOL)
00742             if ( IsDBCSLeadByte( textbuf[yPos][LASTCOL] ) )
00743                 textbuf[yPos][LASTCOL] = ' ';
00744     }
00745     else
00746     {  // overtype mode
00747       if ( IsDBCSLeadByte( textbuf[yPos][xPos] ) )
00748
00749           //
00750           // Blank out trail byte
00751           //
00752           textbuf[yPos][xPos+1] = ' ';
00753
00754           //
00755           // or shift line left on character and blank last column
00756           //
00757           // for ( i = xPos+1; i < LASTCOL; i++ )
00758           //     textbuf[yPos][i] = textbuf[yPos][i+1];
00759           // textbuf[yPos][LASTCOL] = ' ';
00760     }
00761
00762     //
00763     // Store input character at current caret position
00764     //
00765     textbuf[yPos][xPos] = ch;
00766
00767
00768     //
00769     // Display input character.
00770     //
00771     hdc = GetDC( hWnd );
00772     HideCaret( hWnd );
00773     TextOut( hdc, xPos*cxMetrics, yPos*cyMetrics,
00774              (LPSTR)&(textbuf[yPos][xPos]), MAXCOL-xPos );
00775     ShowCaret( hWnd );
00776     ReleaseDC( hWnd, hdc );
00777
00778     SendMessage( hWnd, WM_KEYDOWN, VK_RIGHT, 1L );
00779 }
00780
00781
00782 /************************************************************************
00783 *
00784 *   StoreDBCSChar - Stores one DBCS character into text buffer and
00785 *                   advances cursor
00786 *
00787 ************************************************************************/
00788 void StoreDBCSChar(
00789     HWND hWnd,
00790     WORD ch )
00791 {
00792     int i;
00793     HDC hdc;
00794
00795     //
00796     // If there is no room for a DBCS character, discard it
00797     //
00798     if ( xPos == LASTCOL )
00799         return;
00800
00801     //
00802     // If insert mode, move rest of line to the right by two
00803     //
00804
00805     if ( fInsertMode )
00806     {
00807         for ( i = LASTCOL; i > xPos+1; i-- )
00808           textbuf[yPos][i] = textbuf[yPos][i-2];
00809
00810       //
00811       // If the row ends on a lead byte, blank it out
00812       // To do this we must first traverse the string
00813       // starting from a known charcter boundry until
00814       // we reach the last column. If the last column
00815       // is not a trail byte then it is a single byte
00816       // or a lead byte
00817       //
00818
00819         for ( i = xPos+2; i < LASTCOL; )
00820         {
00821             if ( IsDBCSLeadByte( textbuf[yPos][i] ) )
00822                 i++;
00823             i++;
00824       }
00825
00826         if (i==LASTCOL)
00827             if (IsDBCSLeadByte( textbuf[yPos][LASTCOL] ) )
00828                 textbuf[yPos][LASTCOL] = ' ';
00829     }
00830     else
00831     {  // overtype mode
00832       if ( !IsDBCSLeadByte( textbuf[yPos][xPos] ) )
00833
00834         //
00835         // Overtyping the current byte, plus the following byte,
00836         // which could be a lead byte.
00837         //
00838
00839         if ( IsDBCSLeadByte( textbuf[yPos][xPos+1] ) )
00840             textbuf[yPos][xPos+2] = ' ';
00841     }
00842
00843     //
00844     // Store input character at current caret position
00845     //
00846     textbuf[yPos][xPos]   = LOBYTE(ch);     // lead byte
00847     textbuf[yPos][xPos+1] = HIBYTE(ch);     // trail byte
00848
00849     //
00850     // Display input character.
00851     //
00852
00853     hdc = GetDC( hWnd );
00854     HideCaret( hWnd );
00855     TextOut( hdc, xPos*cxMetrics, yPos*cyMetrics,
00856              (LPSTR)&(textbuf[yPos][xPos]), MAXCOL-xPos );
00857     ShowCaret( hWnd );
00858     ReleaseDC( hWnd, hdc );
00859
00860     SendMessage( hWnd, WM_KEYDOWN, VK_RIGHT, 1L );
00861 }
00862
00863
00864 /************************************************************************
00865 *
00866 *   CharHandler - WM_CHAR handler
00867 *
00868 ************************************************************************/
00869 void CharHandler(
00870     HWND hWnd,
00871     WORD wParam )
00872 {
00873     unsigned char ch = (unsigned char)wParam;
00874
00875     //
00876     // Because DBCS characters are usually generated by IMEs (as two
00877     // PostMessages), if a lead byte comes in, the trail byte should
00878     // arrive very soon after.  We wait here for the trail byte and
00879     // store them into the text buffer together.
00880
00881     if ( IsDBCSLeadByte( ch ) )
00882     {
00883       //
00884       // Wait an arbitrary amount of time for the trail byte to
00885       // arrive.  If it doesn't, then discard the lead byte.
00886       //
00887       // This could happen if the IME screwed up.  Or, more likely,
00888       // the user generated the lead byte through ALT-numpad.
00889       //
00890
00891         MSG msg = {0};
00892         int i = 10;
00893
00894         while (!PeekMessage((LPMSG)&msg, hWnd, WM_CHAR, WM_CHAR, PM_REMOVE))
00895         {
00896             if ( --i == 0 )
00897                 return;
00898             Yield();
00899         }
00900
00901         StoreDBCSChar( hWnd,  (WORD)(((unsigned)(msg.wParam)<<8) | (unsigned)ch ));
00902     }
00903     else
00904     {
00905         switch( ch )
00906         {
00907             case '\r':
00908             case '\t':
00909             case '\b':
00910                 //
00911                 // Throw away.  Already handled at WM_KEYDOWN time.
00912                 //
00913                 break;
00914
00915             default:
00916                 StoreChar( hWnd, ch );
00917                 break;
00918         }
00919     }
00920 }
00921
00922
00923 /************************************************************************
00924 *
00925 *   MouseHandler - WM_BUTTONDOWN handler
00926 *
00927 ************************************************************************/
00928 void MouseHandler(
00929     HWND hWnd,
00930     LONG lParam )
00931 {
00932
00933     if ( ( gImeUIData.ImeState & IME_IN_CHOSECAND ) ||
00934          ( gImeUIData.ImeState & IME_IN_COMPOSITION && !MoveCaret( hWnd ) ) )
00935         return;
00936
00937     HideCaret( hWnd );
00938
00939     //
00940     // Calculate caret position based on fixed pitched font
00941     //
00942     yPos = MAKEPOINTS(lParam).y / cyMetrics;
00943     xPos = MAKEPOINTS(lParam).x / cxMetrics;
00944
00945     //
00946     // Adjust caret position if click landed on a trail byte
00947     //
00948     if ( IsDBCSTrailByte( (LPSTR)textbuf[yPos], (LPSTR)&(textbuf[yPos][xPos]) ) )
00949     {
00950         //
00951         // If click landed on the last quarter of the DBCS character,
00952         // assume the user was aiming at the next character.
00953         //
00954         if ( (MAKEPOINTS(lParam).x - xPos * cxMetrics) > (cxMetrics / 2) )
00955             xPos++;
00956         else
00957             xPos--;
00958     }
00959
00960     DestroyCaret();
00961     CreateCaret(hWnd, NULL,
00962                 (fInsertMode && IsDBCSLeadByte( textbuf[yPos][xPos] )) ? CaretWidth*2 : CaretWidth,
00963                 cyMetrics );
00964     SetCaretPos( xPos * cxMetrics, yPos * cyMetrics );
00965     ShowCaret( hWnd );
00966 }
00967
00968
00969 /************************************************************************
00970 *
00971 *   InputChangeHandler - WM_INPUTLANGCHANGE handler
00972 *
00973 ************************************************************************/
00974 void InputChangeHandler(
00975     HWND hWnd )
00976 {
00977     HIMC hIMC;
00978
00979     //
00980     // If the old keyboard layout is IME, the ime ui data have to be free.
00981     //
00982
00983     if (ImmIsIME(hCurKL))
00984     {
00985         //
00986         // If application prefers to use near caret provded by IME, or
00987         // IME provides special UI, then no need to clean UD data.
00988         //
00989         if ( gImeUIData.fdwProperty & IME_PROP_SPECIAL_UI )
00990             ;
00991         else if ( gImeUIData.fdwProperty & IME_PROP_AT_CARET )
00992             ImeUIClearData(hWnd);
00993         else
00994             ;
00995     }
00996
00997     //
00998     // Set new keyboard layout.
00999     //
01000     hCurKL = GetKeyboardLayout(0L);
01001
01002     //
01003     // Get new property.
01004     //
01005     gImeUIData.fdwProperty = ImmGetProperty( hCurKL, IGP_PROPERTY );
01006
01007     // if this application set the candidate position, it need to set
01008     // it to default for the near caret IME
01009
01010     if ( hIMC = ImmGetContext( hWnd ) )
01011     {
01012         UINT i;
01013
01014         for (i = 0; i < 4; i++)
01015         {
01016             CANDIDATEFORM CandForm;
01017
01018             if ( gImeUIData.fdwProperty & IME_PROP_AT_CARET )
01019             {
01020                 CandForm.dwIndex = i;
01021                 CandForm.dwStyle = CFS_CANDIDATEPOS;
01022
01023 #if 0
01024                 // This application dooes not want to set candidate window
01025                 // to any position. If an application need to set the
01026                 // candidate position, it should remove the if 0 code
01027
01028                 // the position you want to set
01029                 CandForm.ptCurrentPos.x = ptAppWantPosition[i].x;
01030                 CandForm.ptCurrentPos.y = ptAppWantPosition[i].y;
01031
01032                 ImmSetCandidateWindow( hIMC, &CandForm );
01033 #endif
01034             }
01035             else
01036             {
01037                 if ( !ImmGetCandidateWindow( hIMC, i, &CandForm ) )
01038                 {
01039                     continue;
01040                 }
01041
01042                 if ( CandForm.dwStyle == CFS_DEFAULT )
01043                 {
01044                     continue;
01045                 }
01046
01047                 CandForm.dwStyle = CFS_DEFAULT;
01048                 ImmSetCandidateWindow( hIMC, &CandForm );
01049             }
01050         }
01051
01052         ImmReleaseContext( hWnd, hIMC );
01053     }
01054
01055     return;
01056 }
01057
01058
01059 /************************************************************************
01060 *
01061 *   SteWndProc - STE class window procedure
01062 *
01063 ************************************************************************/
01064 int WINAPI SteWndProc( HWND hWnd, UINT msg, UINT wParam, LONG lParam )
01065 {
01066     int i;
01067     HDC hdc;
01068     PAINTSTRUCT ps = {0};
01069
01070     switch( msg )
01071     {
01072     case WM_CREATE:
01073         SteCreate( hWnd );
01074         break;
01075
01076     case WM_DESTROY:
01077         PostQuitMessage(0);
01078         break;
01079
01080     case WM_CLOSE:
01081         DestroyWindow( hWnd );
01082         break;
01083
01084     case WM_SETFOCUS:
01085         CreateCaret( hWnd, NULL,
01086                      (fInsertMode && IsDBCSLeadByte( textbuf[yPos][xPos] )) ?
01087                          CaretWidth*2 : CaretWidth,
01088                      cyMetrics );
01089         SetCaretPos( xPos * cxMetrics, yPos * cyMetrics );
01090         ShowCaret( hWnd );
01091         break;
01092
01093     case WM_KILLFOCUS:
01094         HideCaret( hWnd );
01095         DestroyCaret();
01096         break;
01097
01098     case WM_IME_KEYDOWN: /* fall-through */
01099     case WM_KEYDOWN:
01100         VirtualKeyHandler( hWnd, wParam );
01101         break;
01102
01103     case WM_KEYUP:
01104         break;
01105
01106     case WM_CHAR:
01107         CharHandler( hWnd, (WORD)wParam );
01108         break;
01109
01110     case WM_LBUTTONDOWN:
01111         MouseHandler( hWnd, lParam );
01112         break;
01113
01114     case WM_MOVE:
01115         ImeUIMoveCandWin( hWnd );
01116         break;
01117
01118     case WM_COMMAND:
01119         SteCommand( hWnd, wParam, lParam );
01120         break;
01121
01122     case WM_PAINT:
01123         InvalidateRect(hWnd,NULL,FALSE);  //for repaint allignment problem??
01124               // WinChi3.0
01125         hdc = BeginPaint( hWnd, &ps );
01126
01127         //
01128         // Refresh display from text buffer
01129         //
01130         for ( i = FIRSTROW; i <= LASTROW; i++ )
01131             TextOut( hdc, 0, i*cyMetrics, (LPSTR)textbuf[i], MAXCOL );
01132
01133         EndPaint( hWnd, &ps );
01134         RestoreImeUI( hWnd );
01135         break;
01136
01137     case WM_INPUTLANGCHANGE:
01138         InputChangeHandler( hWnd );
01139         goto call_defwinproc;
01140         break;
01141
01142     case WM_IME_SETCONTEXT:
01143         //
01144         // The application have to pass WM_IME_SETCONTEXT to DefWindowProc.
01145         // When the application want to handle the IME at the timing of
01146         // focus changing, the application should use WM_SETFOCUS or
01147         // WM_KILLFOCUS.
01148         //
01149
01150         if ( gImeUIData.fdwProperty & IME_PROP_SPECIAL_UI )
01151         {
01152             goto call_defwinproc;
01153         }
01154         else if ( gImeUIData.fdwProperty & IME_PROP_AT_CARET )
01155         {
01156             //
01157             // application wants to draw UI ny itself.
01158             //
01159             lParam &= ~(ISC_SHOWUICOMPOSITIONWINDOW | ISC_SHOWUIALLCANDIDATEWINDOW);
01160         }
01161         goto call_defwinproc;
01162
01163     case WM_IME_STARTCOMPOSITION:
01164         //
01165         // CheckProperty is a macro, if IME already provides near caret or
01166         // special UI then let IME handle this message.
01167         //
01168         CheckProperty;
01169         ImeUIStartComposition( hWnd );
01170         break;
01171
01172     case WM_IME_COMPOSITION:
01173         CheckProperty;
01174         ImeUIComposition( hWnd, wParam, lParam );
01175         break;
01176
01177     case WM_IME_ENDCOMPOSITION:
01178         CheckProperty;
01179         ImeUIEndComposition( hWnd );
01180         break;
01181
01182     case WM_IME_COMPOSITIONFULL:
01183         //
01184         // Make sure the size for drawing the composition string.
01185         // Application should draw the composition string correctly.
01186         //
01187         break;
01188
01189     case WM_IME_NOTIFY:
01190         CheckProperty;
01191         if ( !ImeUINotify( hWnd, wParam, lParam ) )
01192             // This application does not handle all notification message.
01193             // So we pass those notification messages which are not hanlded
01194             // by this application to the DefWindowProc.
01195             goto call_defwinproc;
01196         break;
01197
01198
01199     case WM_IME_CONTROL:
01200         //
01201         // This message is not received by the application window.
01202         // But don't pass it to DefWindowProc().
01203         //
01204         break;
01205
01206
01207     default:
01208
01209 call_defwinproc:
01210         return (int)DefWindowProc( hWnd, msg, wParam, lParam );
01211     }
01212
01213     return 0;
01214 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Intermediate/Power.Cpp Source File

  • Web
  • iis
  • Components
  • Cpp
  • Intermediate

Power.Cpp

Go to the documentation of this file.
00001 // Power.cpp : Implementation of CCATLPwrApp and DLL registration.
00002
00003 #include "stdafx.h"
00004 #include "CATLPwr.h"
00005 #include "Power.h"
00006 #include "context.h"
00007 /////////////////////////////////////////////////////////////////////////////
00008 //
00009
00010 STDMETHODIMP CPower::InterfaceSupportsErrorInfo(REFIID riid)
00011 {
00012     static const IID* arr[] =
00013     {
00014         &IID_IPower,
00015     };
00016
00017     for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00018     {
00019         if (InlineIsEqualGUID(*arr[i],riid))
00020             return S_OK;
00021     }
00022     return S_FALSE;
00023 }
00024
00025 // Ctor
00026 CPower::CPower()
00027     : m_bstrMyProperty(OLESTR("C++ ATL Power Component"))
00028 {}
00029
00030 // Get function for myProperty
00031 STDMETHODIMP CPower::get_myProperty(BSTR* pbstrOutValue)
00032 {
00033     if (pbstrOutValue == NULL)
00034         return E_POINTER;
00035
00036     // Get Value from Property
00037     *pbstrOutValue = m_bstrMyProperty.Copy();
00038
00039     return S_OK;
00040 }
00041
00042 // Put function for myProperty
00043 STDMETHODIMP CPower::put_myProperty(BSTR bstrInValue)
00044 {
00045     if (bstrInValue == NULL)
00046         return E_POINTER;
00047
00048     m_bstrMyProperty = bstrInValue;
00049
00050     return S_OK;
00051 }
00052
00053 // Basic Method which Converts bstrIn to Upper Case
00054 STDMETHODIMP CPower::myMethod(BSTR bstrIn, BSTR* pbstrOut)
00055 {
00056     if (bstrIn == NULL || pbstrOut == NULL)
00057         return E_POINTER;
00058
00059     // Create a temporary CComBSTR
00060     CComBSTR bstrTemp(bstrIn);
00061
00062     if (!bstrTemp)
00063         return E_OUTOFMEMORY;
00064
00065     // Make string uppercase
00066     wcsupr(bstrTemp);
00067
00068     // Return m_str member of bstrTemp
00069     *pbstrOut = bstrTemp.Detach();
00070
00071     return S_OK;
00072 }
00073
00074
00075 ///////////// ASP-Specific Component Methods ////////////////
00076
00077 // Get Function Returns the Name of the Current Script
00078 STDMETHODIMP CPower::get_myPowerProperty(BSTR* pbstrOutValue)
00079 {
00080   // the Context class is an easy way to use IIS 4's new way
00081   // of getting instrinic objects.  The new method may seem
00082   // more complex, but it is more powerful since obects no
00083   // longer have to be page/session level to get access
00084   // to them.
00085   CContext cxt;
00086   if ( FAILED( cxt.Init( CContext::get_Request ) ) )
00087   {
00088     return E_FAIL;
00089   }
00090
00091   // Do we have somewhere valid to store the return value?
00092   if (pbstrOutValue == NULL)
00093     return E_POINTER;
00094
00095   // Initialize the return value
00096   *pbstrOutValue = NULL;
00097
00098   // Get the ServerVariables Collection
00099   CComPtr<IRequestDictionary> piServerVariables;
00100   HRESULT hr = cxt.Request()->get_ServerVariables(&piServerVariables);
00101
00102     if (FAILED(hr))
00103         return hr;
00104
00105     // Get the SCRIPT_NAME item from the ServerVariables collection
00106     CComVariant vtIn(OLESTR("SCRIPT_NAME")), vtOut;
00107     hr = piServerVariables->get_Item(vtIn, &vtOut);
00108
00109     if (FAILED(hr))
00110         return hr;
00111
00112     // Get the SCRIPT_NAME item from the ServerVariables collection
00113     // vtOut Contains an IDispatch Pointer.  To fetch the value
00114     // for SCRIPT_NAME, you must get the Default Value for the
00115     // Object stored in vtOut using VariantChangeType.
00116     hr = VariantChangeType(&vtOut, &vtOut, 0, VT_BSTR);
00117
00118     // Copy and return SCRIPT_NAME
00119     if (SUCCEEDED(hr))
00120         *pbstrOutValue = ::SysAllocString(V_BSTR(&vtOut));
00121
00122     return hr;
00123 }
00124
00125 // ASP-specific Power Method
00126 STDMETHODIMP CPower::myPowerMethod()
00127 {
00128   CContext cxt;
00129   if ( FAILED( cxt.Init( CContext::get_Request | CContext::get_Response ) ) )
00130   {
00131     return E_FAIL;
00132   }
00133
00134     // Get the ServerVariables Collection
00135     CComPtr<IRequestDictionary> piServerVariables;
00136     HRESULT hr = cxt.Request()->get_ServerVariables(&piServerVariables);
00137
00138     if (FAILED(hr))
00139         return hr;
00140
00141     // Get the HTTP_USER_AGENT item from the ServerVariables collection
00142     CComVariant vtIn(OLESTR("HTTP_USER_AGENT")), vtOut;
00143     hr = piServerVariables->get_Item(vtIn, &vtOut);
00144
00145     if (FAILED(hr))
00146         return hr;
00147
00148     // vtOut Contains an IDispatch Pointer.  To fetch the value
00149     // for HTTP_USER_AGENT, you must get the Default Value for the
00150     // Object stored in vtOut using VariantChangeType.
00151     hr = VariantChangeType(&vtOut, &vtOut, 0, VT_BSTR);
00152
00153     if (SUCCEEDED(hr))
00154     {
00155         // Look for "MSIE" in HTTP_USER_AGENT string
00156         if (wcsstr(vtOut.bstrVal, L"MSIE") != NULL)
00157             cxt.Response()->Write(CComVariant(
00158                 OLESTR("You are using a very powerful browser.")));
00159         else
00160             cxt.Response()->Write(CComVariant(
00161                 OLESTR("Try Internet Explorer today!")));
00162     }
00163
00164     return hr;
00165 }
00166
00167
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CREDENTIAL Member List

This is the complete list of members for _CREDENTIAL, including all inherited members.
AuthData | _CREDENTIAL
CredentialId | _CREDENTIAL
Next | _CREDENTIAL
Use | _CREDENTIAL
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/onasync.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

onasync.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  OnAsync.cpp
00006 //
00007 // Description:
00008 //  This file implements the ExecQueryAsync() routine and the
00009 //    CAsyncQuerySink class.
00010 //
00011 // History:
00012 //
00013 // **************************************************************************
00014
00015 #include "stdafx.h"
00016 #include "AdvClientDlg.h"
00017 #include "OnAsync.h"
00018
00019 // **************************************************************************
00020 //
00021 //  CAdvClientDlg::OnEnumservicesasync()
00022 //
00023 // Description:
00024 //    Enumerate the services. Demonstrates ExecQueryAsync() using SQL1 and
00025 //    begin/end enumeration through properties. The setup portion is the
00026 //    same as OnEnumServices() but the 'enumerating' part is in the Object
00027 //    Sink.
00028 //
00029 // Parameters:
00030 //    None.
00031 //
00032 // Returns:
00033 //    nothing.
00034 //
00035 // Globals accessed:
00036 //    None.
00037 //
00038 // Globals modified:
00039 //    None.
00040 //
00041 //===========================================================================
00042 void CAdvClientDlg::OnEnumservicesasync()
00043 {
00044
00045   AfxMessageBox(__T("Please note that using asynchronous WMI APIs remotely in non-Kerberos domains \
00046 requires that the client application lower its authentication level to RPC_C_AUTHN_LEVEL_NONE, \
00047 which makes it less robust from the security standpoint. Use semi-synchronous access \
00048 to WMI data and events instead.\n This sample sets the authentication level to RPC_C_AUTHN_LEVEL_PKT_PRIVACY, \
00049 which means that the following asynchronous data query may fail if you are connecting remotely in a non-Kerberos environment."));
00050
00051   HRESULT  hRes;
00052
00053   BSTR qLang = SysAllocString(L"WQL");
00054   if (!qLang)
00055   {
00056     TRACE(_T("ExecQuery() failed: not enough memory\n"));
00057     return;
00058   }
00059
00060   BSTR query = SysAllocString(L"select * from Win32_Service");
00061   if (!query)
00062   {
00063     TRACE(_T("ExecQuery() failed: not enough memory\n"));
00064     SysFreeString(qLang);
00065     return;
00066   }
00067
00068   //---------------------------
00069   // allocate the sink if its not already allocated.
00070   if(m_pQueryCallback == NULL)
00071   {
00072     m_pQueryCallback = new CAsyncQuerySink(&m_outputList);
00073     if (m_pQueryCallback == NULL)
00074     {
00075       TRACE(_T("ExecQuery() failed: not enough memory\n"));
00076       SysFreeString(qLang);
00077       return;
00078     }
00079     m_pQueryCallback->AddRef();
00080   }
00081
00082
00083   m_outputList.ResetContent();
00084   m_outputList.AddString(_T("working..."));
00085
00086   //---------------------------
00087   // execute the query. For *Async, the last parm is a sink object
00088   // that will be sent the resultset instead of returning the normal
00089   // enumerator object.
00090   if((hRes = m_pIWbemServices->ExecQueryAsync(qLang, query,
00091                       0L, NULL,
00092                       m_pQueryCallback)) == S_OK)
00093   {
00094     TRACE(_T("Executed query\n"));
00095
00096     m_outputList.ResetContent();
00097   }
00098   else
00099   {
00100     TRACE(_T("ExecQuery() failed %s\n"), ErrorString(hRes));
00101
00102   } //endif ExecQuery()
00103
00104   SysFreeString(qLang);
00105   SysFreeString(query);
00106
00107 }
00108 // **************************************************************************
00109 //
00110 //  CAsyncQuerySink::CAsyncQuerySink()
00111 //
00112 // Description:
00113 //    This is the sink that gets called as a result of ExecQueryAsync().
00114 //    It has the obligatory COM functions plus Indicate() and SetStatus()
00115 //    which are documented in more detail below.
00116 //===========================================================================
00117 CAsyncQuerySink::CAsyncQuerySink(CListBox *output)
00118 {
00119   m_pOutputList = output;
00120   m_SetStatusCalled = FALSE;
00121 }
00122 // ========================================================
00123 CAsyncQuerySink::~CAsyncQuerySink()
00124 {
00125   if(!m_SetStatusCalled)
00126   {
00127     // NOTE: This happening is indicative of a comm error
00128     // between the server and this client such as a security
00129     // violation. CoInitializeSecurity() needs to be called to
00130     // avoid the security problem.
00131     TRACE(_T("released before SetStatus() was called\n"));
00132   }
00133 }
00134 // ========================================================
00135 STDMETHODIMP CAsyncQuerySink::QueryInterface(REFIID riid, LPVOID* ppv)
00136 {
00137   // we're implementing the IID_IWbemObjectSink interface.
00138     if(riid == IID_IUnknown || riid == IID_IWbemObjectSink)
00139     {
00140         *ppv = this;
00141
00142     // you're handing out a copy of yourself so account for it.
00143         AddRef();
00144         return S_OK;
00145     }
00146     else
00147   {
00148     return E_NOINTERFACE;
00149   }
00150 }
00151
00152 // ========================================================
00153 ULONG CAsyncQuerySink::AddRef()
00154 {
00155   // InterlockedIncrement() helps with thread safety.
00156     return InterlockedIncrement(&m_lRef);
00157 }
00158
00159 // ========================================================
00160 ULONG CAsyncQuerySink::Release()
00161 {
00162   // InterlockedDecrement() helps with thread safety.
00163     int lNewRef = InterlockedDecrement(&m_lRef);
00164   // when all the copies are released...
00165     if(lNewRef == 0)
00166     {
00167     // kill thyself.
00168         delete this;
00169     }
00170
00171     return lNewRef;
00172 }
00173
00174 // **************************************************************************
00175 //
00176 //  CAsyncQuerySink::Indicate()
00177 //
00178 // Description:
00179 //    This method is called to handle the result of the ExecQueryAsync().
00180 //    There are no assumtions about how many objects are passed on each
00181 //    call or how many calls will be made.
00182 // Parameters:
00183 //    lObjectCount (in) - how many objects are being passed.
00184 //    ppObjArray (in) - array of objects from the query.
00185 //
00186 // Returns:
00187 //    S_OK if successful, otherwise the HRESULT of the failed called.
00188 //
00189 // Globals accessed:
00190 //    None.
00191 //
00192 // Globals modified:
00193 //    None.
00194 //
00195 //===========================================================================
00196 STDMETHODIMP CAsyncQuerySink::Indicate(LONG lObjectCount,
00197                      IWbemClassObject **ppObjArray)
00198 {
00199   HRESULT  hRes;
00200   WCHAR *pBuf;
00201   CString clMyBuff;
00202   BSTR propName = NULL, val = NULL;
00203   VARIANT varString, pVal;
00204
00205   VariantInit(&varString);
00206   VariantInit(&pVal);
00207
00208   TRACE(_T("Indicate() called\n"));
00209
00210   //------------------------------
00211   // walk though the classObjects...
00212   for (int i = 0; i < lObjectCount; i++)
00213   {
00214     // clear my output buffer.
00215     clMyBuff.Empty();
00216
00217     //------------------------------
00218     // enumerate properties.
00219     if((hRes = ppObjArray[i]->BeginEnumeration(WBEM_FLAG_NONSYSTEM_ONLY)) == S_OK)
00220     {
00221       //------------------------------
00222       // try to get the next property.
00223       while(ppObjArray[i]->Next(0, &propName,
00224                     &pVal, NULL, NULL) == S_OK)
00225       {
00226         // is it one of the 'names' we want?
00227         if((wcsncmp(propName, L"Name", 4) == 0) ||
00228           (wcsncmp(propName, L"DisplayName", 11) == 0) ||
00229           (wcsncmp(propName, L"PathName", 8) == 0))
00230         {
00231           // format the property=value/
00232           clMyBuff += propName;
00233           clMyBuff += _T("=");
00234           clMyBuff += ValueToString(&pVal, &pBuf);
00235           clMyBuff += _T("/");
00236           free(pBuf); // allocated by ValueToString()
00237
00238         } //endif wcsncmp()...
00239
00240         // cleanup stuff used in the Next() loop.
00241         SysFreeString(propName);
00242         VariantClear(&pVal);
00243
00244       } //endwhile
00245
00246       // did the while loop exit due to an error?
00247       if(hRes != S_OK)
00248       {
00249         TRACE(_T("ppObjArray[i]->Next() failed %s\n"), ErrorString(hRes));
00250       }
00251     }
00252     else
00253     {
00254       TRACE(_T("BeginEnumeration() failed %s\n"), ErrorString(hRes));
00255     } //endif BeginEnumeration()
00256
00257     // output the buffer.
00258     m_pOutputList->AddString(clMyBuff);
00259
00260     //------------------------------
00261     // free the property iterator workspace.
00262     ppObjArray[i]->EndEnumeration();
00263
00264     // no need to release because the caller does the
00265     // AddRef()/Release()
00266
00267   } // endfor
00268
00269   TRACE(_T("walked indication list\n"));
00270
00271   return S_OK;
00272 }
00273 // **************************************************************************
00274 //
00275 //  CAsyncQuerySink::SetStatus()
00276 //
00277 // Description:
00278 //    Called after all Indication()s have been called. This signals the
00279 //    completion of the query.
00280 //
00281 // Parameters:
00282 //    per WMI requirements.
00283 //
00284 // Returns:
00285 //    S_OK if successful, otherwise the HRESULT of the failed called.
00286 //
00287 // Globals accessed:
00288 //    None.
00289 //
00290 // Globals modified:
00291 //    None.
00292 //
00293 //===========================================================================
00294 STDMETHODIMP CAsyncQuerySink::SetStatus(long lFlags,
00295                     HRESULT hResult,
00296                     BSTR strParam,
00297                     IWbemClassObject *pObjParam)
00298 {
00299   TRACE(_T("SetStatus() called %s\n"), ErrorString(hResult));
00300
00301   m_SetStatusCalled = TRUE;
00302
00303   // all the Indication()s worked fine.
00304   if(hResult == WBEM_NO_ERROR)
00305   {
00306     m_pOutputList->AddString(_T("Done Enumerating"));
00307   }
00308   else // or not.
00309   {
00310     m_pOutputList->AddString(_T("Enumeration Error!!"));
00311   }
00312
00313   return S_OK;
00314 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/Deb/LinkList.h Source File

  • WinBase
  • Debug
  • Deb

LinkList.h

Go to the documentation of this file.
00001 /************************************************************************
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 HEADER    : LinkList.H - Ordered Double Linked List Package
00010 PURPOSE   : Provide a general, sorted, double linked list package
00011 FUNCTIONS :
00012   CreateList        - allocate memory for a new list, registers the
00013                       ordering function
00014   CreateNode        - allocate memory fpr a new node that can be put
00015                       into the linked list
00016   InsertNode        - insert a new node into the list
00017   SetCurrentNode    - finds the 1st occurence of a node that matches
00018                       a key(s) according to the match function
00019                       and sets it as the current node
00020   SetCurrentNodeEx  - finds the Nth occurence of a node that matches
00021                       a key(s) according to the match function
00022                       and sets it as the current node
00023   GetCurrentNode    - get the current node
00024   GetFirstNode      - get the first (left-most) node in the list
00025   GetLastNode       - get the last (right-most) node in the list
00026   GetNextNode       - get the next (right) node from the current
00027   GetPrevNode       - get the previous (left) node from the current
00028   DeleteCurrentNode - deletes the current node from the list and
00029                       frees the memory associated with it
00030   DestroyNode       - deallocates the memory associated with a node
00031   DestroyList       - deallocates the memory associated with a list,
00032                       does not delete any of the nodes
00033   GetListError      - gets the current list error
00034
00035 COMMENTS  : The application must serialize access to the linked list
00036
00037   Format of the Ordering and Matching functions is as follows:
00038   -----------------------------------------------------------
00039
00040   int OrderFunc( PNODE pNodeOne, PNODE pNodeTwo )
00041   {
00042     if( (pNodeOne->pNodeData).SortKey < (pNodeTwo->pNodeData).SortKey )
00043       return( LIST_LEFT_OF );
00044     if( (pNodeOne->pNodeData).SortKey > (pNodeTwo->pNodeData).SortKey )
00045       return( LIST_RIGHT_OF );
00046     return( LIST_MATCH );
00047   }
00048
00049 *************************************************************************/
00050 #ifndef LINKLIST_H
00051
00052  #define LINKLIST_H
00053
00054  #ifdef __cplusplus
00055  extern "C" { /* Assume C declarations for C++ */
00056  #endif /* __cplusplus */
00057
00058  // public typedefs and defines
00059  // -----------------------------------------------------------------------
00060  #define LIST_NO_ERROR                 1
00061  #define LIST_ERROR_NO_NODE           -1
00062  #define LIST_ERROR_NO_MATCH          -2
00063  #define LIST_ERROR_NO_FREE_MEM       -3
00064  #define LIST_ERROR_DEREFERENCE_NULL -99
00065
00066  #define LIST_LEFT_OF   -1
00067  #define LIST_MATCH      0
00068  #define LIST_RIGHT_OF   1
00069
00070  #ifndef TRUE
00071    #define TRUE  1
00072    #define FALSE 0
00073    typedef int   BOOL;
00074  #endif
00075
00076  typedef void* PVOID;
00077
00078  //-- definition of a node
00079  typedef struct NODE_STRUCT* PNODE;
00080  typedef struct NODE_STRUCT {
00081            PVOID pNodeData;
00082            PNODE pLeftLink;
00083            PNODE pRightLink;
00084          } NODE;
00085
00086  //-- definition of a list
00087  typedef struct LIST_STRUCT* PLIST;
00088  typedef struct LIST_STRUCT {
00089            PVOID pListData;
00090            PNODE pFirstNode;
00091            PNODE pCurrentNode;
00092            PNODE pLastNode;
00093            int   (*OrderFunction)(PNODE, PNODE);
00094            int   ListError;
00095          } LIST;
00096
00097  // public function prototypes
00098  // -----------------------------------------------------------------------
00099  BOOL CreateList( PLIST* ppList, int (*OrderFunction)( PNODE pNodeOne, PNODE pNodeTwo ) );
00100  BOOL CreateNode( PNODE* ppNewNode );
00101  BOOL InsertNode( PLIST pList, PNODE pNewNode );
00102  BOOL SetCurrentNode( PLIST pList, PNODE pKeyNode, int (*MatchFunction)( PNODE pNodeOne, PNODE pNodeTwo ) );
00103  BOOL SetCurrentNodeEx( PLIST pList, PNODE pKeyNode, int (*MatchFunction)( PNODE pNodeOne, PNODE pNodeTwo ), int Occurence );
00104  BOOL GetCurrentNode( PLIST pList, PNODE* ppNode );
00105  BOOL GetFirstNode( PLIST pList, PNODE* ppNode );
00106  BOOL GetLastNode( PLIST pList, PNODE* ppNode );
00107  BOOL GetNextNode( PLIST pList, PNODE* ppNode );
00108  BOOL GetPrevNode( PLIST pList, PNODE* ppNode );
00109  BOOL DeleteCurrentNode( PLIST pList );
00110  BOOL DestroyNode( PNODE pNode );
00111  BOOL DestroyList( PLIST pList );
00112  int  GetListError( PLIST pList );
00113
00114  #ifdef __cplusplus
00115  }
00116  #endif /* __cplusplus */
00117
00118
00119 #endif // LINKLIST_H
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/GdiDemo/Poly.c Source File

  • Multimedia
  • Gdi
  • GdiDemo

Poly.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /*---------------------------------------------------------------------------*\
00013 | POLYBEZIER MODULE
00014 |   This module contains the routines for demo
00015 \*---------------------------------------------------------------------------*/
00016
00017 #include <windows.h>
00018 #include "gdidemo.h"
00019 #include  "poly.h"
00020
00021 /*---------------------------------------------------------------------------*\
00022 | CREATE BEZIER WINDOW PROCEDURE
00023 |   Create the bezier MDI-child window.
00024 \*---------------------------------------------------------------------------*/
00025 HWND FAR CreatePolyWindow(HWND hWndClient, int nItem)
00026 {
00027     HANDLE          hInstance;
00028     MDICREATESTRUCT mcs;
00029     static char buffer[256];
00030
00031
00032     hInstance = GETINSTANCE(hWndClient);
00033     LoadString (hInstance, POLYTITLE, buffer, 256);
00034
00035     /*
00036     ** Initialize the MDI create struct for creation of the
00037     ** test window.
00038     */
00039     mcs.szClass = POLYCLASS;
00040     mcs.szTitle = buffer;
00041     mcs.hOwner  = hInstance;
00042     mcs.x       = CW_USEDEFAULT;
00043     mcs.y       = CW_USEDEFAULT;
00044     mcs.cx      = CW_USEDEFAULT;
00045     mcs.cy      = CW_USEDEFAULT;
00046     mcs.style   = 0l;
00047     mcs.lParam  = (LONG)nItem;
00048
00049     return((HWND)SendMessage(hWndClient,WM_MDICREATE,0,(LPARAM)(LPMDICREATESTRUCT)&mcs));
00050 }
00051
00052
00053 /*---------------------------------------------------------------------------*\
00054 | POLYBEZIER WINDOW PROCEDURE
00055 |   This is the main window function for the polybezier demo window.
00056 \*---------------------------------------------------------------------------*/
00057 LRESULT CALLBACK PolyProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
00058 {
00059     switch(wMsg)
00060     {
00061         case WM_CREATE:
00062             PolyCreateProc(hWnd);
00063             break;
00064
00065
00066         case WM_COMMAND:
00067             PolyCommandProc(hWnd,wParam,lParam);
00068             break;
00069
00070         case WM_MOVE:
00071             PolyRedraw(hWnd);
00072             break;
00073
00074
00075         case WM_TIMER:
00076             PolyDrawBez(hWnd);
00077             break;
00078
00079
00080         case WM_PAINT:
00081             PolyPaintProc(hWnd);
00082             break;
00083
00084
00085         case WM_DESTROY:
00086             PolyDestroyProc(hWnd);
00087             break;
00088
00089
00090         default:
00091             return(DefMDIChildProc(hWnd,wMsg,wParam,lParam));
00092     }
00093     return(0l);
00094 }
00095
00096
00097 /*---------------------------------------------------------------------------*\
00098 | POLYBEZIER CREATE PROCEDURE
00099 |   Create the polybezier window for the demo application.  This is a child
00100 |   of the MDI client window.  Allocate the extra object information for
00101 |   handling of the polybezier demo.
00102 \*---------------------------------------------------------------------------*/
00103 BOOL PolyCreateProc(HWND hWnd)
00104 {
00105     PPOLYDATA ppd;
00106
00107
00108     if(AllocWindowInfo(hWnd,sizeof(POLYDATA)))
00109     {
00110         if(ppd = (PPOLYDATA)LockWindowInfo(hWnd))
00111         {
00112             ppd->nBezTotal  = 20;
00113             ppd->nBezCurr   = 0;
00114             ppd->nColor     = 0;
00115             ppd->hBezBuffer = GlobalAlloc(GHND,(DWORD)(sizeof(BEZBUFFER) * MAX_BEZIER));
00116
00117             UnlockWindowInfo(hWnd);
00118            if ( !ppd->hBezBuffer )
00119            {
00120                FreeWindowInfo(hWnd);
00121                return(FALSE);
00122            }
00123
00124             PolyInitPoints(hWnd);
00125
00126             SetTimer(hWnd,1,50,NULL);
00127             return(TRUE);
00128         }
00129         FreeWindowInfo(hWnd);
00130     }
00131     return(FALSE);
00132 }
00133
00134
00135 /*---------------------------------------------------------------------------*\
00136 | POLYBEZIER COMMAND PROCEDURE
00137 |   Process polybezier commands.  This is a NOP for now.  But who knows what
00138 |   tomorrow may bring.
00139 \*---------------------------------------------------------------------------*/
00140 BOOL PolyCommandProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
00141 {
00142     hWnd   = hWnd;
00143     wParam = wParam;
00144     lParam = lParam;
00145
00146     return(TRUE);
00147 }
00148
00149
00150 /*---------------------------------------------------------------------------*\
00151 | POLYBEZIER PAINT PROCEDURE
00152 |   Repaint the bezier window.  All we really do here is validate our window,
00153 |   and reset the array of bezier objects.
00154 \*---------------------------------------------------------------------------*/
00155 VOID PolyPaintProc(HWND hWnd)
00156 {
00157     HDC         hDC;
00158     PAINTSTRUCT ps;
00159
00160
00161     if(hDC = BeginPaint(hWnd,&ps))
00162         EndPaint(hWnd,&ps);
00163
00164     PolyRedraw(hWnd);
00165
00166     return;
00167 }
00168
00169
00170 /*---------------------------------------------------------------------------*\
00171 | POLYBEZIER DESTROY PROCEDURE
00172 |   Kill the polybezier demo.  Free up the resources allocated on behalf of
00173 |   this object.
00174 \*---------------------------------------------------------------------------*/
00175 VOID PolyDestroyProc(HWND hWnd)
00176 {
00177     PPOLYDATA ppd;
00178
00179
00180     KillTimer(hWnd,1);
00181     if(ppd = (PPOLYDATA)LockWindowInfo(hWnd))
00182     {
00183         GlobalFree(ppd->hBezBuffer);
00184         UnlockWindowInfo(hWnd);
00185     }
00186     FreeWindowInfo(hWnd);
00187
00188     return;
00189 }
00190
00191
00192 /*---------------------------------------------------------------------------*\
00193 | GET NEW VELOCITY
00194 |   This routine creates a new velocity for the bezier points.  Each bezier
00195 |   point is randomly chosen.  The two inside points should have a speed
00196 |   less then the endpoints (most of the time-better effect).
00197 \*---------------------------------------------------------------------------*/
00198 int PolyNewVel(int i)
00199 {
00200     int nRet;
00201
00202
00203     if ((i == 1) || (i == 2))
00204         nRet = (int)((lRandom() % VELMAX) / 3) + VELMIN;
00205     else
00206         nRet = (int)(lRandom() % VELMAX) + VELMIN;
00207
00208     return((nRet < 0) ? -nRet : nRet);
00209 }
00210
00211
00212 /*---------------------------------------------------------------------------*\
00213 | INITIALIZE POLYBEZIER POINTS
00214 |   This routine initializes the polybezier points for the first object.  This
00215 |   is performed on startup of the window.
00216 \*---------------------------------------------------------------------------*/
00217 VOID PolyInitPoints(HWND hWnd)
00218 {
00219     PPOLYDATA   ppd;
00220     LPBEZBUFFER lpBez;
00221     int         idx;
00222     RECT        rect;
00223
00224
00225     if(ppd = (PPOLYDATA)LockWindowInfo(hWnd))
00226     {
00227         if(lpBez = (LPBEZBUFFER)GlobalLock(ppd->hBezBuffer))
00228         {
00229             GetClientRect(hWnd,&rect);
00230
00231             for(idx=0; idx < BEZ_PTS-1; idx++)
00232             {
00233                 lpBez->pPts[idx].x = lRandom() % rect.right;
00234                 lpBez->pPts[idx].y = lRandom() % rect.bottom;
00235
00236                 ppd->pVel[idx].x = PolyNewVel(idx);
00237                 ppd->pVel[idx].y = PolyNewVel(idx);
00238             }
00239             GlobalUnlock(ppd->hBezBuffer);
00240         }
00241         UnlockWindowInfo(hWnd);
00242     }
00243     return;
00244 }
00245
00246
00247 /*---------------------------------------------------------------------------*\
00248 | POLYBEZIER REDRAW
00249 |   This routine resets the bezier curves and redraws the poly-bezier client
00250 |   area.
00251 \*---------------------------------------------------------------------------*/
00252 VOID PolyRedraw(HWND hWnd)
00253 {
00254     PPOLYDATA   ppd;
00255     LPBEZBUFFER lpBez,lpCurr;
00256     HDC         hDC;
00257     int         i,j;
00258     RECT        rect;
00259
00260
00261     if(ppd = (PPOLYDATA)LockWindowInfo(hWnd))
00262     {
00263         if(lpBez = (LPBEZBUFFER)GlobalLock(ppd->hBezBuffer))
00264         {
00265             if(hDC = GetDC(hWnd))
00266             {
00267                 /*
00268                 ** Save the current bezier.  Set the first bezier in the
00269                 ** array to that curve, and use it as a basis for the next
00270                 ** series.
00271                 */
00272                 lpCurr        = lpBez+ppd->nBezCurr;
00273                 *lpBez        = *lpCurr;
00274                 ppd->nBezCurr = 0;
00275
00276
00277                 /*
00278                 ** Clean the curves (all but the first curve).
00279                 */
00280                 for(j=1; j < ppd->nBezTotal; j++)
00281                 {
00282                     for(i=0; i < BEZ_PTS; i++)
00283                     {
00284                         (lpBez+j)->pPts[i].x = -1;
00285                         (lpBez+j)->pPts[i].y = 0;
00286                     }
00287                 }
00288
00289
00290
00291                 /*
00292                 ** Clear the display.
00293                 */
00294                 GetClientRect(hWnd,&rect);
00295                 BitBlt(hDC,0,0,rect.right, rect.bottom,(HDC)0,0,0,0);
00296
00297
00298                 /*
00299                 ** Draw the first curve in the bezier array.
00300                 */
00301 #if defined(_WIN32) && defined(WIN32)
00302                 PolyBezier(hDC,lpBez->pPts,BEZ_PTS);
00303 #else
00304                 Polyline(hDC,lpBez->pPts,BEZ_PTS);
00305 #endif
00306                 ReleaseDC(hWnd,hDC);
00307             }
00308             GlobalUnlock(ppd->hBezBuffer);
00309         }
00310         UnlockWindowInfo(hWnd);
00311     }
00312     return;
00313 }
00314
00315
00316
00317
00318 VOID PolyDrawBez(HWND hWnd)
00319 {
00320     PPOLYDATA   ppd;
00321     LPBEZBUFFER lpBez,lpCurr,lpPrev;
00322     int         idx,x,y;
00323     RECT        rect;
00324     HDC         hDC;
00325     HPEN        hPen;
00326
00327 static COLORREF crColor[] = {0x000000FF,0x0000FF00,0x00FF0000,0x0000FFFF,
00328                              0x00FF00FF,0x00FFFF00,0x00FFFFFF,0x00000080,
00329                              0x00008000,0x00800000,0x00008080,0x00800080,
00330                              0x00808000,0x00808080,0x000000FF,0x0000FF00,
00331                              0x00FF0000,0x0000FFFF,0x00FF00FF,0x00FFFF00};
00332
00333
00334     if(ppd = (PPOLYDATA)LockWindowInfo(hWnd))
00335     {
00336         if(lpBez = (LPBEZBUFFER)GlobalLock(ppd->hBezBuffer))
00337         {
00338             if(hDC = GetDC(hWnd))
00339             {
00340                 GetClientRect(hWnd,&rect);
00341
00342                 lpPrev = lpBez+ppd->nBezCurr;
00343
00344                 ppd->nBezCurr += 1;
00345
00346                 if(ppd->nBezCurr >= ppd->nBezTotal)
00347                 {
00348                     ppd->nBezCurr = 0;
00349
00350                    ppd->nColor  = (++ppd->nColor % 20);
00351                 }
00352                 lpCurr = lpBez+ppd->nBezCurr;
00353
00354
00355                 if(lpCurr->pPts[0].x != -1)
00356                 {
00357                     hPen = SelectObject(hDC,GetStockObject(BLACK_PEN));
00358 #if defined(_WIN32) && defined(WIN32)
00359                     PolyBezier(hDC,lpCurr->pPts,BEZ_PTS);
00360 #else
00361                     Polyline(hDC,lpCurr->pPts,BEZ_PTS);
00362 #endif
00363                     SelectObject(hDC,hPen);
00364                 }
00365
00366                 for(idx=0; idx < BEZ_PTS; idx++)
00367                 {
00368                     x  = lpPrev->pPts[idx].x;
00369                     y  = lpPrev->pPts[idx].y;
00370                     x += ppd->pVel[idx].x;
00371                     y += ppd->pVel[idx].y;
00372
00373                     if(x >= rect.right)
00374                     {
00375                         x = rect.right - ((x - rect.right)+1);
00376
00377                        ppd->pVel[idx].x = -PolyNewVel(idx);
00378                     }
00379
00380                     if(x <= rect.left)
00381                     {
00382                         x = rect.left + ((rect.left - x)+1);
00383                         ppd->pVel[idx].x = PolyNewVel(idx);
00384                     }
00385
00386                     if(y >= rect.bottom)
00387                     {
00388                         y = rect.bottom - ((y - rect.bottom)+1);
00389                         ppd->pVel[idx].y = -PolyNewVel(idx);
00390                     }
00391
00392                     if(y <= rect.top)
00393                     {
00394                         y = rect.top + ((rect.top - y)+1);
00395                         ppd->pVel[idx].y = PolyNewVel(idx);
00396                     }
00397
00398                     lpCurr->pPts[idx].x = x;
00399                     lpCurr->pPts[idx].y = y;
00400
00401                 }
00402
00403
00404                hPen = SelectObject(hDC,CreatePen(PS_SOLID,1,crColor[ppd->nColor]));
00405 #if defined(_WIN32) && defined(WIN32)
00406                 PolyBezier(hDC,lpCurr->pPts,BEZ_PTS);
00407 #else
00408                 Polyline(hDC,lpCurr->pPts,BEZ_PTS);
00409 #endif
00410                 DeleteObject(SelectObject(hDC,hPen));
00411
00412
00413 #if defined(_WIN32) && defined(WIN32)
00414                 SetROP2(hDC,R2_COPYPEN);
00415 #endif
00416                 ReleaseDC(hWnd,hDC);
00417             }
00418             GlobalUnlock(ppd->hBezBuffer);
00419         }
00420         UnlockWindowInfo(hWnd);
00421     }
00422 }
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsCmd/main.hxx Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsCmd

main.hxx

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //
00003 //  Microsoft Active Directory 1.0 Sample Code
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1996
00006 //
00007 //  File:       main.hxx
00008 //
00009 //  Contents:   Main include file for adscmd
00010 //
00011 //
00012 //----------------------------------------------------------------------
00013
00014 //
00015 // ********* System Includes
00016 //
00017
00018 #define UNICODE
00019 #define _UNICODE
00020 #define INC_OLE2
00021
00022 #include <windows.h>
00023
00024 //
00025 // ********* CRunTime Includes
00026 //
00027
00028 #include <stdlib.h>
00029 #include <limits.h>
00030 #include <io.h>
00031 #include <stdio.h>
00032
00033 //
00034 // *********  Public ADs includes
00035 //
00036
00037 #include <activeds.h>
00038
00039 //
00040 // *********  Useful macros
00041 //
00042
00043 #define BAIL_ON_NULL(p)       \
00044      if (!(p)) {           \
00045          goto error;   \
00046      }
00047
00048 #define BAIL_ON_FAILURE(hr,msg)   \
00049      if (FAILED(hr)) {     \
00050          wprintf(L"Error: 0x%x\t Msg: %s \n", hr, msg); \
00051          goto error;   \
00052      }
00053
00054 #define FREE_INTERFACE(pInterface) \
00055      if (pInterface) {          \
00056          pInterface->Release(); \
00057          pInterface=NULL;       \
00058      }
00059
00060 #define FREE_BSTR(bstr)            \
00061      if (bstr) {                \
00062          SysFreeString(bstr);   \
00063          bstr = NULL;           \
00064      }
00065
00066 //
00067 // *********  Prototypes
00068 //
00069
00070 void
00071 PrintUsage(
00072  void
00073  );
00074
00075 int
00076 AnsiToUnicodeString(
00077  LPSTR pAnsi,
00078  LPWSTR pUnicode,
00079  DWORD StringLength
00080  );
00081
00082 int
00083 UnicodeToAnsiString(
00084  LPWSTR pUnicode,
00085  LPSTR pAnsi,
00086  DWORD StringLength
00087  );
00088
00089 LPWSTR
00090 AllocateUnicodeString(
00091  LPSTR  pAnsiString
00092  );
00093
00094 void
00095 FreeUnicodeString(
00096  LPWSTR  pUnicodeString
00097  );
00098
00099 HRESULT
00100 PrintVariantArray(
00101  VARIANT var
00102  );
00103
00104 HRESULT
00105 PrintVariant(
00106  VARIANT varPropData
00107  );
00108
00109 HRESULT
00110 PrintProperty(
00111  BSTR bstrPropName,
00112  HRESULT hRetVal,
00113  VARIANT varPropData
00114  );
00115
00116 HRESULT
00117 GetPropertyList(
00118  IADs * pADs,
00119  VARIANT * pvar
00120  );
00121
00122 //
00123 // Functions to dump contents of an object
00124 //
00125
00126 int
00127 DoDump(
00128  char *AnsiADsPath
00129  ) ;
00130
00131 HRESULT
00132 DumpObject(
00133  IADs * pADs
00134  );
00135
00136 //
00137 // Functions to list objects within a container.
00138 //
00139
00140 int
00141 DoList(
00142  char *AnsiADsPath
00143  ) ;
00144
00145 HRESULT
00146 EnumObject(
00147  LPWSTR pszADsPath,
00148  LPWSTR * lppClassNames,
00149  DWORD dwClassNames
00150  ) ;
00151
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/WinNT/RasHost/RasHost.h Source File

  • NetDS
  • Ras
  • WinNT
  • RasHost

RasHost.h

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  File Name
00004 //      RASHOST.H
00005 //
00006 //  Description
00007 //      This file defines all the data structures used in the files and the
00008 //      appropiate constants.
00009 //      In this file we also define the function prototypes for all the
00010 //      methods used in the project files.
00011 //
00012 // Written for Microsoft Developer Support
00013 // Copyright (c) 1995 - 2000 Microsoft Corporation. All rights reserved.
00014 //
00015 #ifndef _RASHOST_H
00016 #define _RASHOST_H
00017
00018 #pragma warning (disable : 4100)
00019 #pragma warning (disable : 4201)
00020 #pragma warning (disable : 4237)
00021 #pragma warning (disable : 4514)
00022 #pragma warning (disable : 4702)
00023 #pragma warning (disable : 4710)
00024
00025 #define STRICT
00026 #include <WINDOWS.H>
00027 #include <RASERROR.H>
00028 extern "C"
00029 {
00030     #include <RASSHOST.H>
00031 };
00032
00033 // Constants
00034 #define CLIENT_RESPONSE_TIMEOUT     15000
00035
00036 // Private data structures
00037 typedef struct _WORK_THREAD_DATA
00038 {
00039     HPORT  hPort;
00040     PBYTE  pSendBuf;
00041     DWORD  SendBufSize;
00042     PBYTE  pRecvBuf;
00043     DWORD  RecvBufSize;
00044     VOID  (WINAPI *pfnSecurityDialogEnd)(SECURITY_MESSAGE*);
00045 } WORK_THREAD_DATA, *PWORK_THREAD_DATA;
00046
00047 typedef struct _RASHOST_DATA
00048 {
00049     DWORD   dwSize;
00050     TCHAR   szUserName[64];
00051     TCHAR   szUserDomain[64];
00052     BYTE    Buffer[512];
00053 } RASHOST_DATA, *PRASHOST_DATA;
00054
00055 // Function prototypes for dynamic bindings
00056 typedef DWORD (WINAPI * RASSECURITYDIALOGSENDPROC)(HPORT, PBYTE, WORD);
00057 typedef DWORD (WINAPI * RASSECURITYDIALOGRECEIVEPROC)(HPORT, PBYTE, PWORD, DWORD, HANDLE);
00058
00059 // Global variables
00060 extern RASSECURITYDIALOGSENDPROC    gpfnSendProc;
00061 extern RASSECURITYDIALOGRECEIVEPROC gpfnReceiveProc;
00062 HANDLE hEvent;
00063
00064 ///////////////////////////////////////////////////////////////////////////////
00065 // Function prototypes
00066
00067 // Data transmission functions
00068 void WINAPI CallWorkerThread
00069                     (PWORK_THREAD_DATA          pCallData);
00070
00071 // User validation function
00072 DWORD WINAPI ValidateCallingUser
00073                     (PRASHOST_DATA              pData,
00074                      BOOL *                     pfAccessGranted);
00075
00076
00077 // Common code for fetching client input
00078 DWORD GetClientResponse(HPORT hPort, PBYTE Buffer);
00079
00080 #endif  // _RASHOST_H
00081
00082 // End of file for RASHOST.H
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PER_IO_CONTEXT Member List

This is the complete list of members for _PER_IO_CONTEXT, including all inherited members.
Buffer | _PER_IO_CONTEXT
IOOperation | _PER_IO_CONTEXT
nSentBytes | _PER_IO_CONTEXT
nTotalBytes | _PER_IO_CONTEXT
Overlapped | _PER_IO_CONTEXT
pIOContextForward | _PER_IO_CONTEXT
SocketAccept | _PER_IO_CONTEXT
wsabuf | _PER_IO_CONTEXT
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/Font.Hxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

Font.Hxx

Go to the documentation of this file.
00001 #ifndef __FONT_HXX_
00002 #define __FONT_HXX_
00003
00004 #include "canvas.hxx"
00005
00006 //========== CFont =============================================
00007 class CFont
00008 {
00009 public:
00010         CFont(HFONT hfont);
00011         CFont(TCHAR * szFace, int iHeight,
00012               BOOL fBold = FALSE, BOOL fItalic = FALSE, BOOL fUnder = FALSE);
00013         ~CFont();
00014         BOOL Create(LOGFONT& lf);
00015         BOOL Update(int iHeight, BOOL fBold=FALSE);
00016         operator HFONT() const
00017                 { return _hfont; }
00018         BOOL Choose(HWND hwnd);
00019 protected:
00020         HFONT _hfont;
00021         BOOL _fDel;
00022 };
00023
00024 //========== CFontSelect =======================================
00025 class CFontSelect
00026 {
00027 public:
00028         CFontSelect(CCanvas &canvas, HFONT hfont) :
00029             _canvas(canvas)
00030         {
00031             _hfontOld = SelectFont(_canvas, hfont);
00032         };
00033
00034         ~CFontSelect()
00035         {
00036             // Make sure font is not selected, so it can be deleted
00037             SelectFont(_canvas, _hfontOld);
00038         }
00039 protected:
00040         HFONT _hfontOld;
00041         CCanvas &_canvas;
00042 };
00043
00044 //========== CBlackPen =======================================
00045 class CBlackPen
00046 {
00047 public:
00048         CBlackPen(CCanvas &canvas, int iStyle, int iWidth) :
00049             _canvas(canvas)
00050         {
00051             _hPen = CreatePen(iStyle,iWidth,RGB(0,0,0));
00052             _hPenOld = SelectPen(_canvas, _hPen);
00053         };
00054
00055         ~CBlackPen()
00056         {
00057             // release pen
00058             _hPen = SelectPen(_canvas, _hPenOld);
00059             DeleteObject(_hPen);
00060         }
00061 protected:
00062         HPEN _hPen;
00063         HPEN _hPenOld;
00064         CCanvas &_canvas;
00065 };
00066
00067 //========== CBrush =====================================
00068 class CBrush
00069 {
00070 public:
00071     CBrush(CCanvas &canvas, int iStyle=BS_NULL, COLORREF color=RGB(0,0,0))  :
00072       _canvas(canvas)
00073     {
00074       LOGBRUSH lb;
00075       lb.lbStyle= iStyle;
00076       lb.lbColor= color;
00077       lb.lbHatch = NULL;
00078
00079       _hBrush = CreateBrushIndirect(&lb);
00080
00081       _hBrushOld = SelectBrush(_canvas, _hBrush);
00082     }
00083
00084     ~CBrush()
00085     {
00086       //release brush
00087       _hBrush = SelectBrush(_canvas, _hBrushOld);
00088       DeleteObject(_hBrush);
00089     }
00090 protected:
00091     HBRUSH _hBrush;
00092     HBRUSH _hBrushOld;
00093     CCanvas _canvas;
00094 };
00095
00096 #endif
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/registry.h Source File

  • Com
  • async
  • server

registry.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #ifndef __Registry_H__
00019 #define __Registry_H__
00020 //
00021 // Registry.h
00022 //   - Helper functions registering and unregistering a component.
00023 //
00024
00025 // This function will register a component in the Registry.
00026 // The component calls this function from its DllRegisterServer function.
00027
00028 // Forward reference
00029 struct CFactoryData;
00030
00031 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00032              CFactoryData& classData);
00033 // This function will unregister a component.  Components
00034 // call this function from their DllUnregisterServer function.
00035
00036 HRESULT UnregisterServer(HMODULE hModule,            // DLL module handle
00037              CFactoryData& classData);
00038
00039 // Helper function to register the typelib
00040 HRESULT RegisterLibrary(HMODULE hModule, const GUID& pLibIID, LPCSTR szPath = NULL);
00041
00042 // Helper functions to register/unregistry custom proxy
00043 HRESULT RegisterProxy(HMODULE hModule, LPCSTR szPath = NULL);
00044 HRESULT UnRegisterProxy(HMODULE hModule, LPCSTR szPath = NULL);
00045 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerServe/PerServe.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerServe

PerServe.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PERSERVE.H
00003
00004   Summary:   Main include file for the PERSERVE.DLL dynamic link library.
00005              Intended primarily for external users of this DLL who exploit
00006              it via static linkage to the DllRegisterServer and
00007              DllUnregisterServer exported service calls.
00008
00009              For a comprehensive tutorial code tour of PERSERVE's contents
00010              and offerings see the tutorial PERSERVE.HTM file. For
00011              more specific technical details on the internal workings see
00012              the comments dispersed throughout the PERSERVE source code.
00013
00014   Classes:   none.
00015
00016   Functions: DllRegisterServer, DllUnregisterServer.
00017
00018   Origin:    5-8-97: atrent - Editor-inheritance from STOSERVE.H in
00019                the STOSERVE Tutorial Code Sample. [Revised]
00020
00021 ----------------------------------------------------------------------------
00022   This file is part of the Microsoft COM Tutorial Code Samples.
00023
00024   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00025
00026   This source code is intended only as a supplement to Microsoft
00027   Development Tools and/or on-line documentation.  See these other
00028   materials for detailed information regarding Microsoft code samples.
00029
00030   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00031   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00032   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00033   PARTICULAR PURPOSE.
00034 ==========================================================================+*/
00035
00036 #if !defined(PERSERVE_H)
00037 #define PERSERVE_H
00038
00039 #if !defined(RC_INCLUDE)
00040
00041 #if !defined(_DLLEXPORT_)
00042
00043 // If _DLLEXPORT_ is NOT defined then the default is to import.
00044 #if defined(__cplusplus)
00045 #define DLLENTRY extern "C" __declspec(dllimport)
00046 #else
00047 #define DLLENTRY extern __declspec(dllimport)
00048 #endif
00049 #define STDENTRY DLLENTRY HRESULT WINAPI
00050 #define STDENTRY_(type) DLLENTRY type WINAPI
00051
00052 // Here is the list of server APIs offered by the DLL (using the
00053 // appropriate entry API declaration macros just #defined above).
00054
00055 STDENTRY DllRegisterServer(void);
00056
00057 STDENTRY DllUnregisterServer(void);
00058
00059 #else  // _DLLEXPORT_
00060
00061 // Else if _DLLEXPORT_ is indeed defined then we've been told to export.
00062 #if defined(__cplusplus)
00063 #define DLLENTRY extern "C" __declspec(dllexport)
00064 #else
00065 #define DLLENTRY __declspec(dllexport)
00066 #endif
00067 #define STDENTRY DLLENTRY HRESULT WINAPI
00068 #define STDENTRY_(type) DLLENTRY type WINAPI
00069
00070 #endif // _DLLEXPORT_
00071
00072 #endif // RC_INCLUDE
00073
00074 #endif // PERSERVE_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellExt/PropShet.Cpp Source File

  • WinUI
  • Shell
  • ShellExt

PropShet.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   propshet.cpp
00009 //
00010 //  PURPOSE:   Implements the IShellPropSheetExt member functions necessary to
00011 //             support the property sheet page of this shell extension.  This
00012 //             page is displayed when the user selects "Properties..." after
00013 //             right clicking on a .GAK file
00014 //
00015
00016 #include "priv.h"
00017 #include "shellext.h"
00018 #include "resource.h"
00019
00020 extern UINT g_cRefThisDll;         // Reference count of this DLL.
00021 extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
00022
00023 //
00024 //  FUNCTION: GAKPageCallback(HWND, UINT, LPPROPSHEETPAGE)
00025 //
00026 //  PURPOSE: Callback  procedure for the property page
00027 //
00028 //  PARAMETERS:
00029 //    hWnd      - Reserved (will always be NULL)
00030 //    uMessage  - Action flag: Are we being created or released
00031 //    ppsp      - The page that is being created or destroyed
00032 //
00033 //  RETURN VALUE:
00034 //
00035 //    Depends on message.
00036 //
00037 //    For PSPCB_CREATE it's TRUE to let the page be created
00038 //    or false to prevent it from being created.
00039 //    For PSPCB_RELEASE the return value is ignored.
00040 //
00041 //  COMMENTS:
00042 //
00043 UINT CALLBACK
00044 GAKPageCallback(HWND hWnd,
00045                 UINT uMessage,
00046                 LPPROPSHEETPAGE  ppsp)
00047 {
00048     switch(uMessage)
00049     {
00050         case PSPCB_CREATE:
00051             return TRUE;
00052
00053         case PSPCB_RELEASE:
00054             if (ppsp->lParam)
00055             {
00056                ((LPCSHELLEXT)(ppsp->lParam))->Release();
00057             }
00058             return TRUE;
00059     }
00060     return TRUE;
00061 }
00062
00063 //
00064 //  FUNCTION: GAKPageDlgProc(HWND, UINT, WPARAM, LPARAM)
00065 //
00066 //  PURPOSE: Callback dialog procedure for the property page
00067 //
00068 //  PARAMETERS:
00069 //    hDlg      - Dialog box window handle
00070 //    uMessage  - current message
00071 //    wParam    - depends on message
00072 //    lParam    - depends on message
00073 //
00074 //  RETURN VALUE:
00075 //
00076 //    Depends on message.  In general, return TRUE if we process it.
00077 //
00078 //  COMMENTS:
00079 //
00080
00081
00082 //The return type for this function needs to be a INT_PTR for compatibility with Win64.
00083 // See defintion of DLGPROC in WinUser.H
00084
00085 INT_PTR CALLBACK GAKPageDlgProc(HWND hDlg,
00086                              UINT uMessage,
00087                              WPARAM wParam,
00088                              LPARAM lParam)
00089 {
00090     LPPROPSHEETPAGE psp=(LPPROPSHEETPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
00091     UINT iIndex=0;
00092     int  iID;
00093     LPCSHELLEXT lpcs;
00094      char szTemp[4];
00095
00096     switch (uMessage)
00097     {
00098         //
00099         // When the shell creates a dialog box for a property sheet page,
00100         // it passes the pointer to the PROPSHEETPAGE data structure as
00101         // lParam. The dialog procedures of extensions typically store it
00102         // in the DWL_USER of the dialog box window.
00103         //
00104         case WM_INITDIALOG:
00105             SetWindowLongPtr(hDlg, DWLP_USER, lParam);
00106
00107             psp = (LPPROPSHEETPAGE)lParam;
00108
00109             lpcs = (LPCSHELLEXT)psp->lParam;
00110
00111             if (*(lpcs->m_szPropSheetFileUserClickedOn))
00112                 iIndex = (UINT)GetPrivateProfileInt("IconImage",
00113                                                     "Index",
00114                                                     0,
00115                                                     lpcs->m_szPropSheetFileUserClickedOn);
00116
00117             //Note that the following line assumes that IDC_RED, IDC_GREEN,
00118             //and IDC_BLUE are in sequential order, with IDC_RED having the
00119             //smallest value.
00120             SendDlgItemMessage(hDlg, iIndex + IDC_RED, BM_SETCHECK, TRUE, 0L);
00121
00122             break;
00123
00124         case WM_DESTROY:
00125             RemoveProp(hDlg, "ID");
00126             break;
00127
00128         case WM_COMMAND:
00129             switch (LOWORD(wParam))
00130             {
00131                 case IDC_RED:
00132                 case IDC_GREEN:
00133                 case IDC_BLUE:
00134                     SetProp(hDlg, "ID", (HANDLE)lParam);
00135                     break;
00136
00137                 default:
00138                     break;
00139             }
00140             break;
00141
00142         case WM_NOTIFY:
00143             switch (((NMHDR FAR *)lParam)->code)
00144             {
00145                 case PSN_SETACTIVE:
00146                     break;
00147
00148                 case PSN_APPLY:
00149                     //User has clicked the OK or Apply button so we'll
00150                     //update the icon information in the .GAK file
00151                     lpcs = (LPCSHELLEXT)psp->lParam;
00152                     iID  = GetDlgCtrlID((HWND)GetProp(hDlg, "ID"));
00153                     iID -= IDC_RED;
00154                     wsprintf(szTemp, "%i", iID);
00155                     WritePrivateProfileString("IconImage",
00156                                               "Index",
00157                                                szTemp,
00158                                                lpcs->m_szPropSheetFileUserClickedOn);
00159                     //Ask the shell to refresh the icon list...
00160                     SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, 0, 0);
00161                     break;
00162
00163                 default:
00164                     break;
00165             }
00166             break;
00167
00168         default:
00169             return FALSE;
00170     }
00171
00172     return TRUE;
00173 }
00174
00175
00176 //
00177 //  FUNCTION: CShellExt::AddPages(LPFNADDPROPSHEETPAGE, LPARAM)
00178 //
00179 //  PURPOSE: Called by the shell just before the property sheet is displayed.
00180 //
00181 //  PARAMETERS:
00182 //    lpfnAddPage -  Pointer to the Shell's AddPage function
00183 //    lParam      -  Passed as second parameter to lpfnAddPage
00184 //
00185 //  RETURN VALUE:
00186 //
00187 //    NOERROR in all cases.  If for some reason our pages don't get added,
00188 //    the Shell still needs to bring up the Properties... sheet.
00189 //
00190 //  COMMENTS:
00191 //
00192
00193 STDMETHODIMP CShellExt::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
00194 {
00195     PROPSHEETPAGE psp;
00196     HPROPSHEETPAGE hpage;
00197
00198     ODS("CShellExt::AddPages()\r\n");
00199
00200     FORMATETC fmte = {CF_HDROP,
00201                       (DVTARGETDEVICE FAR *)NULL,
00202                       DVASPECT_CONTENT,
00203                       -1,
00204                       TYMED_HGLOBAL
00205                      };
00206     STGMEDIUM medium;
00207     HRESULT hres = 0;
00208
00209     if (m_pDataObj)  //Paranoid check, m_pDataObj should have something by now...
00210        hres = m_pDataObj->GetData(&fmte, &medium);
00211
00212     if (SUCCEEDED(hres))
00213     {
00214         //Find out how many files the user has selected...
00215         UINT cbFiles = 0;
00216         LPCSHELLEXT lpcsext = this;
00217
00218         if (medium.hGlobal)
00219             cbFiles = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, 0, 0);
00220
00221         if (cbFiles < 2)
00222         {
00223             //OK, the user has only selected a single file, so lets go ahead
00224             //and add the property sheet.  Note that it doesn't HAVE to be this
00225             //way, but for simplicity and educational reasons, I'll only add
00226             //the property sheet if a single .GAK file is selected.
00227
00228             //Get the name of the file the user has clicked on
00229             if (cbFiles)
00230                DragQueryFile((HDROP)medium.hGlobal,
00231                              0,
00232                              m_szPropSheetFileUserClickedOn,
00233                              sizeof(m_szPropSheetFileUserClickedOn));
00234
00235             //
00236             // Create a property sheet page object from a dialog box.
00237             //
00238             // We store a pointer to our class in the psp.lParam, so we
00239             // can access our class members from within the GAKPageDlgProc
00240             //
00241             // If the page needs more instance data, you can append
00242             // arbitrary size of data at the end of this structure,
00243             // and pass it to the CreatePropSheetPage. In such a case,
00244             // the size of entire data structure (including page specific
00245             // data) must be stored in the dwSize field.   Note that in
00246             // general you should NOT need to do this, as you can simply
00247             // store a pointer to date in the lParam member.
00248             //
00249
00250             psp.dwSize      = sizeof(psp);  // no extra data.
00251             psp.dwFlags     = PSP_USEREFPARENT | PSP_USETITLE | PSP_USECALLBACK;
00252             psp.hInstance   = g_hmodThisDll;
00253             psp.pszTemplate = MAKEINTRESOURCE(IDD_GAKPAGE);
00254             psp.hIcon       = 0;
00255             psp.pszTitle    = "GAK Color";
00256             psp.pfnDlgProc  = GAKPageDlgProc;
00257             psp.pcRefParent = &g_cRefThisDll;
00258             psp.pfnCallback = GAKPageCallback;
00259             psp.lParam      = (LPARAM)lpcsext;
00260
00261             AddRef();
00262             hpage = CreatePropertySheetPage(&psp);
00263
00264             if (hpage)
00265             {
00266                 if (!lpfnAddPage(hpage, lParam))
00267                 {
00268                     DestroyPropertySheetPage(hpage);
00269                     Release();
00270                 }
00271             }
00272         }
00273     }
00274
00275     return NOERROR;
00276 }
00277
00278 //
00279 //  FUNCTION: CShellExt::ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM)
00280 //
00281 //  PURPOSE: Called by the shell only for Control Panel property sheet
00282 //           extensions
00283 //
00284 //  PARAMETERS:
00285 //    uPageID         -  ID of page to be replaced
00286 //    lpfnReplaceWith -  Pointer to the Shell's Replace function
00287 //    lParam          -  Passed as second parameter to lpfnReplaceWith
00288 //
00289 //  RETURN VALUE:
00290 //
00291 //    E_FAIL, since we don't support this function.  It should never be
00292 //    called.
00293
00294 //  COMMENTS:
00295 //
00296
00297 STDMETHODIMP CShellExt::ReplacePage(UINT uPageID,
00298                                     LPFNADDPROPSHEETPAGE lpfnReplaceWith,
00299                                     LPARAM lParam)
00300 {
00301     ODS("CShellExt::ReplacePage()\r\n");
00302
00303     return E_FAIL;
00304 }
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAddVFileDlg Member List

This is the complete list of members for CAddVFileDlg, including all inherited members.
CAddVFileDlg(ULONG nTemplate, HWND hParentWnd) | CAddVFileDlg |
CAddVFileDlg(ULONG nTemplate, HWND hParentWnd) | CAddVFileDlg |
CAddVFileDlg(ULONG nTemplate, HWND hParentWnd) | CAddVFileDlg |
CAddVFileDlg(ULONG nTemplate, HWND hParentWnd) | CAddVFileDlg |
CAddVFileDlg(ULONG nTemplate, HWND hParentWnd) | CAddVFileDlg |
CBaseDialog(ULONG nTemplate=0) | CBaseDialog |
CBaseDialog(ULONG nTemplate=0) | CBaseDialog |
CBaseDialog(ULONG nTemplate=0) | CBaseDialog |
CBaseDialog(ULONG nTemplate=0) | CBaseDialog |
CBaseDialog(ULONG nTemplate=0) | CBaseDialog |
CBaseDialog(ULONG nTemplate=0) | CBaseDialog |
Create(HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags=0) | CBaseDialog | [virtual]
Create(HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags=0) | CBaseDialog | [virtual]
Create(HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags=0) | CBaseDialog | [virtual]
Create(HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags=0) | CBaseDialog | [virtual]
Create(HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags=0) | CBaseDialog | [virtual]
Create(HINSTANCE hInstance, HWND hWndParent, DWORD dwFlags=0) | CBaseDialog | [virtual]
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, static]
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, static]
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, static]
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, static]
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, static]
DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, static]
m_hParentWnd | CAddVFileDlg | [private]
OnCancel(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnCancel(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnCancel(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnCancel(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnCancel(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnCancel(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnClose(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnClose(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnClose(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnClose(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnClose(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnClose(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnNcDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnNcDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnNcDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnNcDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnNcDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnNcDestroy(HWND hDlg, WPARAM wParam, LPARAM lParam) | CBaseDialog | [protected, virtual]
OnOK(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnOK(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnOK(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnOK(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
OnOK(HWND hDlg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [private, virtual]
ProcessMessage(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [virtual]
ProcessMessage(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [virtual]
ProcessMessage(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [virtual]
ProcessMessage(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [virtual]
ProcessMessage(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | CAddVFileDlg | [virtual]
~CAddVFileDlg() | CAddVFileDlg |
~CAddVFileDlg() | CAddVFileDlg |
~CAddVFileDlg() | CAddVFileDlg |
~CAddVFileDlg() | CAddVFileDlg |
~CAddVFileDlg() | CAddVFileDlg |
~CBaseDialog() | CBaseDialog | [virtual]
~CBaseDialog() | CBaseDialog | [virtual]
~CBaseDialog() | CBaseDialog | [virtual]
~CBaseDialog() | CBaseDialog | [virtual]
~CBaseDialog() | CBaseDialog | [virtual]
~CBaseDialog() | CBaseDialog | [virtual]
Generated on Wed Nov 13 2024 16:55:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/securitysub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

securitysub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __SECURITY_H__
00018 #define __SECURITY_H__
00019
00020 #include "stdafx.h"
00021 #include "resource.h"       // main symbols
00022
00023 #define USERNAMELEN 64
00024
00025 CComBSTR GuidToBstr(REFGUID guid);
00026
00027 class CComSpy;
00028
00029 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00030 Class:   CSecuritySub
00031 Summary: Security Events Subscriber
00032 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00033 class ATL_NO_VTABLE CSecuritySub :
00034   public CSysLCESub,
00035   public IComSecurityEvents
00036 {
00037 public:
00038   CSecuritySub()
00039   {
00040     m_pSpy = NULL;
00041   }
00042   CSecuritySub(CComSpy * pSpy)
00043   {
00044     m_pSpy = pSpy;
00045   }
00046
00047   DECLARE_NOT_AGGREGATABLE(CSecuritySub)
00048   DECLARE_GET_CONTROLLING_UNKNOWN()
00049
00050   BEGIN_COM_MAP(CSecuritySub)
00051     COM_INTERFACE_ENTRY(IComSecurityEvents)
00052     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00053   END_COM_MAP()
00054
00055   STDMETHODIMP GetEventType(EventEnum * e){*e = Security;return S_OK;}
00056   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00057   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComSecurityEvents;return S_OK;}
00058
00059   STDMETHODIMP OnAuthenticate(  COMSVCSEVENTINFO * pInfo,
00060                   REFGUID guidActivity,
00061                   ULONG64 ObjectID,
00062                   REFGUID guidIID,
00063                   ULONG iMeth,
00064                   ULONG cbByteOrig,
00065                   BYTE * pSidOriginalUser,
00066                   ULONG cbByteCur,
00067                   BYTE * pSidCurrentUser,
00068                   BOOL bCurrentUserInpersonatingInProc
00069               )
00070   {
00071
00072     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnAuthenticate"), GuidToBstr(pInfo->guidApp));
00073     CComBSTR sGuidActivity = GuidToBstr(guidActivity);
00074     m_pSpy -> AddParamValueToList(L"guidActivity", sGuidActivity);
00075
00076     WCHAR sObjId[32];
00077     wsprintfW(sObjId,L"0x%016X", ObjectID);
00078     m_pSpy -> AddParamValueToList(L"ObjectID", sObjId);
00079
00080
00081     CComBSTR sGuidIID = GuidToBstr(guidIID);
00082     m_pSpy -> AddParamValueToList(L"guidIID", sGuidIID);
00083
00084     WCHAR sMethod[16];
00085     wsprintfW(sMethod,L"0x%08X", iMeth);
00086     m_pSpy -> AddParamValueToList(L"iMeth", sMethod);
00087
00088
00089     WCHAR sOriginalUser[256];
00090     ZeroMemory(sOriginalUser, 256*sizeof(WCHAR));
00091
00092     if (GetDomainSlashUser(pSidOriginalUser, sOriginalUser))
00093       m_pSpy -> AddParamValueToList(L"Original User", sOriginalUser);
00094     else
00095       m_pSpy -> AddParamValueToList(L"Original User", L"<Error converting SID>");
00096
00097     WCHAR sDirectUser[256];
00098     ZeroMemory(sDirectUser, 256*sizeof(WCHAR));
00099
00100     if (GetDomainSlashUser(pSidCurrentUser, sDirectUser))
00101       m_pSpy -> AddParamValueToList(L"Direct User", sDirectUser);
00102     else
00103       m_pSpy -> AddParamValueToList(L"Direct User", L"<Error converting SID>");
00104
00105     m_pSpy -> AddParamValueToList(L"Direct User Inpersonating InProc", bCurrentUserInpersonatingInProc ? L"Yes" : L"No");
00106
00107
00108     IF_AUDIT_DO(OnAuthenticate)(pInfo->perfCount,
00109                   GuidToBstr(pInfo->guidApp),
00110                   sGuidActivity,
00111                   sObjId,
00112                   sGuidIID,
00113                   sMethod,
00114                   sOriginalUser,
00115                   sDirectUser,
00116                   bCurrentUserInpersonatingInProc);
00117
00118     return S_OK;
00119   }
00120
00121   STDMETHODIMP OnAuthenticateFail(  COMSVCSEVENTINFO * pInfo,
00122                   REFGUID guidActivity,
00123                   ULONG64 ObjectID,
00124                   REFGUID guidIID,
00125                   ULONG iMeth,
00126                   ULONG cbByteOrig,
00127                   BYTE * pSidOriginalUser,
00128                   ULONG cbByteCur,
00129                   BYTE * pSidCurrentUser,
00130                   BOOL bCurrentUserInpersonatingInProc
00131                  )
00132   {
00133
00134     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnAuthenticateFail"), GuidToBstr(pInfo->guidApp));
00135     CComBSTR sGuidActivity = GuidToBstr(guidActivity);
00136     m_pSpy -> AddParamValueToList(L"guidActivity", sGuidActivity);
00137
00138
00139     WCHAR sObjId[32];
00140     wsprintfW(sObjId,L"0x%016X", ObjectID);
00141     m_pSpy -> AddParamValueToList(L"ObjectID", sObjId);
00142
00143     CComBSTR sGuidIID = GuidToBstr(guidIID);
00144     m_pSpy -> AddParamValueToList(L"guidIID", sGuidIID);
00145
00146     WCHAR sMethod[16];
00147     wsprintfW(sMethod,L"0x%08X", iMeth);
00148     m_pSpy -> AddParamValueToList(L"iMeth", sMethod);
00149
00150
00151     WCHAR sOriginalUser[256];
00152     ZeroMemory(sOriginalUser, 256*sizeof(WCHAR));
00153
00154     if (GetDomainSlashUser(pSidOriginalUser, sOriginalUser))
00155       m_pSpy -> AddParamValueToList(L"Original User", sOriginalUser);
00156     else
00157       m_pSpy -> AddParamValueToList(L"Original User", L"<Error converting SID>");
00158
00159     WCHAR sDirectUser[256];
00160     ZeroMemory(sDirectUser, 256*sizeof(WCHAR));
00161
00162     if (GetDomainSlashUser(pSidCurrentUser, sDirectUser))
00163       m_pSpy -> AddParamValueToList(L"Direct User", sDirectUser);
00164     else
00165       m_pSpy -> AddParamValueToList(L"Direct User", L"<Error converting SID>");
00166
00167     m_pSpy -> AddParamValueToList(L"Direct User Inpersonating InProc", bCurrentUserInpersonatingInProc ? L"Yes" : L"No");
00168
00169     IF_AUDIT_DO(OnAuthenticateFail)(pInfo->perfCount,
00170                   GuidToBstr(pInfo->guidApp),
00171                   sGuidActivity,
00172                   sObjId, // objectID
00173                   sGuidIID, //interface ID
00174                   sMethod, //
00175                   sOriginalUser,
00176                   sDirectUser,
00177                   bCurrentUserInpersonatingInProc);
00178
00179     return S_OK;
00180   }
00181
00182
00183   BOOL GetDomainSlashUser(
00184      PSID Sid,              // in
00185      WCHAR* DomainSlashUser)      // out
00186   {
00187     WCHAR Name[USERNAMELEN + 1];
00188     DWORD cbName = USERNAMELEN;
00189     DWORD cbReferencedDomainName = USERNAMELEN;
00190     SID_NAME_USE eUse;
00191     WCHAR* p;
00192     ZeroMemory(Name, cbName);
00193     if (!LookupAccountSid(NULL, Sid, Name, &cbName, DomainSlashUser, &cbReferencedDomainName, &eUse))
00194       return FALSE;
00195
00196     // concat domain\user
00197     p = DomainSlashUser + wcslen(DomainSlashUser);
00198     *p++ = '\\';
00199     wcsncpy(p, Name, wcslen(Name));
00200     return TRUE;
00201   }
00202
00203 };
00204
00205 #endif //__SECURITYSUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFullConnectProvider Member List

This is the complete list of members for CFullConnectProvider, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CFullConnectProvider() | CFullConnectProvider |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetProviderName() | CFullConnectProvider | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_comboConfig | CFullConnectProvider |
m_comboProvider | CFullConnectProvider |
m_dwPromptProp | CFullConnectProvider |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_hWndProp | CFullConnectProvider |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
m_wszDataSource | CFullConnectProvider |
m_wszLocation | CFullConnectProvider |
m_wszPassword | CFullConnectProvider |
m_wszUserID | CFullConnectProvider |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | CFullConnectProvider | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CFullConnectProvider | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CFullConnectProvider | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropDown(INT iID, HWND hWndCtrl) | CFullConnectProvider | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CFullConnectProvider | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CFullConnectProvider | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSelChange(INT iID, HWND hWndCtrl) | CFullConnectProvider | [virtual]
OnSetActive() | CFullConnectProvider | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
RefreshEnum(BOOL fReconnect=FALSE) | CFullConnectProvider | [virtual]
RefreshProvider() | CFullConnectProvider | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateProvider() | CFullConnectProvider | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/RSM/mll/dllmain.cpp Source File

  • WinBase
  • IO
  • RSM
  • mll

dllmain.cpp

Go to the documentation of this file.
00001 /*
00002  *  This is a part of the Microsoft Source Code Samples.
00003  *  Copyright 1996 - 1998 Microsoft Corporation.
00004  *  All rights reserved.
00005  *
00006  *  This sample code shows the usage of some portions
00007  *  of the NTMS API.
00008  *
00009  *  Return codes are, for the most part, not checked in
00010  *  this code. See the Programmer's reference for error
00011  *  return information.
00012  *
00013  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00014  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00015  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00016  * PARTICULAR PURPOSE.
00017  *
00018  * Copyright 1997 - 1998 Microsoft Corporation.  All Rights Reserved. *
00019  */
00020 #include <windows.h>
00021
00022 //
00023 //   $Function:: $
00024 //
00025 // $Parameters:: $
00026 //
00027 //    $Content:: $
00028 //
00029 //     $Return:: $
00030 //
00031 BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
00032 {
00033   return (TRUE);
00034 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcReq.h Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcReq.h

Go to the documentation of this file.
00001 #if !defined(AFX_AGENTCTLREQUEST_H__AB8FEBA4_3841_11D2_8512_00C04FA34A14__INCLUDED_)
00002 #define AFX_AGENTCTLREQUEST_H__AB8FEBA4_3841_11D2_8512_00C04FA34A14__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00008
00009 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00010 //  Microsoft Visual C++, your modifications will be overwritten.
00011
00012 /////////////////////////////////////////////////////////////////////////////
00013 // CAgentCtlRequest wrapper class
00014
00015 class CAgentCtlRequest : public COleDispatchDriver
00016 {
00017 public:
00018   CAgentCtlRequest() {}   // Calls COleDispatchDriver default constructor
00019   CAgentCtlRequest(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
00020   CAgentCtlRequest(const CAgentCtlRequest& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
00021
00022 // Attributes
00023 public:
00024
00025 // Operations
00026 public:
00027   long GetStatus();
00028   CString GetDescription();
00029   long GetNumber();
00030 };
00031
00032 //{{AFX_INSERT_LOCATION}}
00033 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00034
00035 #endif // !defined(AFX_AGENTCTLREQUEST_H__AB8FEBA4_3841_11D2_8512_00C04FA34A14__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/spy.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

spy.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module SPY.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _SPY_H_
00012 #define _SPY_H_
00013
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 /////////////////////////////////////////////////////////////////////////////
00019 #include "objidl.h" //IMallocSpy
00020 #include "List.h"   //CList
00021
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // C-Runtime hooks
00025 //
00026 /////////////////////////////////////////////////////////////////////////////
00027 void EnableCRTReportHook(BOOL fEnable = TRUE);
00028 void EnableCRTAllocHook(BOOL fEnable = TRUE);
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // CMallocSpy
00033 //
00034 /////////////////////////////////////////////////////////////////////////////
00035 class CMallocSpy : public IMallocSpy
00036 {
00037 public:
00038     CMallocSpy();
00039   virtual ~CMallocSpy();
00040
00041   //Interface
00042   virtual HRESULT AddToList(void* pv);
00043   virtual HRESULT RemoveFromList(void* pv);
00044   virtual HRESULT DumpLeaks();
00045   virtual void  Reset();
00046
00047   //Registration
00048   virtual HRESULT Register();
00049   virtual HRESULT Unregister();
00050
00051     // IUnknown methods
00052     virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppIUnknown);
00053     virtual STDMETHODIMP_(ULONG) AddRef();
00054     virtual STDMETHODIMP_(ULONG) Release();
00055
00056   // IMallocSpy methods
00057
00058     //Alloc
00059   virtual STDMETHODIMP_(SIZE_T) PreAlloc(SIZE_T cbRequest);
00060     virtual STDMETHODIMP_(void*) PostAlloc(void *pActual);
00061
00062     //Free
00063   virtual STDMETHODIMP_(void*) PreFree(void *pRequest, BOOL fSpyed);
00064     virtual STDMETHODIMP_(void ) PostFree(BOOL fSpyed);
00065
00066     //Realloc
00067   virtual STDMETHODIMP_(SIZE_T) PreRealloc(void *pRequest, SIZE_T cbRequest, void **ppNewRequest, BOOL fSpyed);
00068     virtual STDMETHODIMP_(void*) PostRealloc(void *pActual, BOOL fSpyed);
00069
00070     //GetSize
00071   virtual STDMETHODIMP_(void*) PreGetSize(void *pRequest, BOOL fSpyed);
00072     virtual STDMETHODIMP_(SIZE_T) PostGetSize(SIZE_T cbActual, BOOL fSpyed);
00073
00074     //DidAlloc
00075   virtual STDMETHODIMP_(void*) PreDidAlloc(void *pRequest, BOOL fSpyed);
00076     virtual STDMETHODIMP_(BOOL)  PostDidAlloc(void *pRequest, BOOL fSpyed, BOOL fActual);
00077
00078     //HeapMinimize
00079   virtual STDMETHODIMP_(void ) PreHeapMinimize();
00080     virtual STDMETHODIMP_(void ) PostHeapMinimize();
00081
00082
00083 protected:
00084     ULONG    m_cRef;        //Reference count
00085     SIZE_T   m_cbRequest;     //Bytes requested
00086   ULONG  m_cAllocations;    //Memory Allocations
00087
00088   CList<void*, void*> CAllocList; //List to keep track of leaks
00089 };
00090
00091
00092 #endif // _SPY_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAsynchBase Member List

This is the complete list of members for CAsynchBase, including all inherited members.
Abort(HCHAPTER hChapter, DBASYNCHOP eOperation) | CAsynchBase | [virtual]
AdviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
AutoQI(DWORD dwCreateOpts) | CAsynchBase | [virtual]
AutoRelease() | CAsynchBase | [virtual]
CAsynchBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CAsynchBase |
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CContainerBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CContainerBase |
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
DisplayObject() | CBase | [virtual]
FindConnectionPoint(REFIID riid, IConnectionPoint **ppIConnectionPoint) | CContainerBase | [virtual]
GetBaseType() | CBase | [inline]
GetDefaultInterface()=0 | CBase | [pure virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CAsynchBase | [virtual]
GetObjectDesc() | CBase | [inline, virtual]
GetObjectImage()=0 | CBase | [pure virtual]
GetObjectMenu()=0 | CBase | [pure virtual]
GetObjectName()=0 | CBase | [pure virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetParent(SOURCE eSource) | CBase | [virtual]
GetStatus(HCHAPTER hChapter, DBASYNCHOP eOperation, DBCOUNTITEM *pulProgress, DBCOUNTITEM *pulProgressMax, DBASYNCHPHASE *peAsynchPhase, LPOLESTR *ppwszStatusText) | CAsynchBase | [virtual]
Initialize() | CAsynchBase | [virtual]
IsInitialized() | CAsynchBase | [inline, virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_cRef | CBase | [protected]
m_dwCLSCTX | CBase |
m_dwCookieAsynchNotify | CAsynchBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_fInitialized | CAsynchBase |
m_guidSource | CBase |
m_hTreeItem | CBase |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pIConnectionPointContainer | CContainerBase |
m_pIDBAsynchStatus | CAsynchBase |
m_pIDBInitialize | CAsynchBase |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_strObjectDesc | CBase | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
UnadviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
Uninitialize() | CAsynchBase | [virtual]
~CAsynchBase() | CAsynchBase | [virtual]
~CBase() | CBase | [virtual]
~CContainerBase() | CContainerBase | [virtual]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSpaceFolder Member List

This is the complete list of members for CSpaceFolder, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
children | CSpaceFolder | [private]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CSpaceFolder() | CSpaceFolder |
CSpaceFolder() | CSpaceFolder |
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CSpaceFolder | [inline, virtual]
GetBitmapIndex() | CSpaceFolder | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceFolder | [inline, virtual]
GetDisplayName(int nCol=0) | CSpaceFolder | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CSpaceFolder | [inline, virtual]
getNodeType() | CSpaceFolder | [inline, virtual]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
IDM_NEW_SPACE enum value | CSpaceFolder | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
NUMBER_OF_CHILDREN enum value | CSpaceFolder | [private]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CSpaceFolder | [virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CSpaceFolder | [virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CSpaceFolder | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CSpaceFolder() | CSpaceFolder | [virtual]
~CSpaceFolder() | CSpaceFolder | [virtual]
Generated on Wed Nov 13 2024 16:57:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Fields15 Member List

This is the complete list of members for msado15::Fields15, including all inherited members.
_NewEnum() | msado15::Fields15 |
getCount() | msado15::Fields15 |
getItem(Variant Index) | msado15::Fields15 |
iid | msado15::Fields15 | [static]
Refresh() | msado15::Fields15 |
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/PerText.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

PerText.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PERTEXT.CPP
00003
00004   Summary:   Main implementation file for a DLL COM Component server
00005              providing a TextPage COM Component. Access to Class Factories
00006              is provided in this module.  This module also supports self
00007              registration and unregistration for components housed in
00008              the server.
00009
00010              For a comprehensive tutorial code tour of PERTEXT's contents
00011              and offerings see the tutorial PERTEXT.HTM file. For more
00012              specific technical details on the internal workings see the
00013              comments dispersed throughout the PERTEXT source code. For
00014              more details see PERCLIEN.HTM in the main tutorial directory.
00015
00016   Classes:   none.
00017
00018   Functions: DllMain, DllGetClassObject, DllCanUnloadNow, DllRegisterServer,
00019              DllUnregisterServer.
00020
00021   Origin:    5-12-97: atrent - Editor-inheritance from STOSERVE.CPP in
00022                the STOSERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include INITGUID.H only once (here) in the entire DLL because we
00043     will be defining GUIDs and want them as constants in the data segment.
00044   We include APPUTIL.H because we will be building this DLL using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IPAGES.H and PAGEGUID.H for the common TextPage-related
00048     Interface class, GUID, and CLSID specifications.
00049   We include PERTEXT.H because it has the _DLLEXPORT_ controlled import
00050     and export specifications.
00051   We include SERVER.H because it has internal class declarations for
00052     the server's control object.
00053   We include FACTORY.H because it has the necessary internal class factory
00054     declarations for this DLL component server.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <initguid.h>
00059 #include <apputil.h>
00060 #include <ipages.h>
00061 #include <pageguid.h>
00062 #define _DLLEXPORT_
00063 #include "pertext.h"
00064 #include "server.h"
00065 #include "factory.h"
00066
00067
00068 // Global variable definitions. Some Initialized in DllMain() below.
00069
00070 // We encapsulate the control of this COM server (eg, lock and object
00071 // counting) in a server control C++ object. Here is it's global pointer.
00072 CServer* g_pServer = NULL;
00073
00074
00075 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00076   Function: UnicodeOk
00077
00078   Summary:  Checks if the platform will handle unicode versions of
00079             Win32 string API calls.
00080
00081   Args:     void
00082
00083   Returns:  BOOL
00084               TRUE if unicode support; FALSE if not.
00085 ------------------------------------------------------------------------F-F*/
00086 BOOL UnicodeOk(void)
00087 {
00088   BOOL bOk = TRUE;
00089   TCHAR szUserName[MAX_STRING_LENGTH];
00090   DWORD dwSize = MAX_STRING_LENGTH;
00091
00092   if (!GetUserName(szUserName, &dwSize))
00093     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00094
00095   return bOk;
00096 }
00097
00098
00099 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00100   Function: DllMain
00101
00102   Summary:  Just as WinMain is for an EXE application, this DllMain
00103             function is the main entry point for this DLL.  It is called
00104             when the DLL is loaded by a process, and when new threads are
00105             created by a process that has already loaded this DLL.
00106             DllMain is also called when threads of a process that has
00107             loaded the DLL exit cleanly and when the process itself
00108             unloads the DLL.
00109
00110             If you want to use C runtime libraries, keep this function
00111             named "DllMain" and you won't have to do anything special to
00112             initialize the runtime libraries.
00113
00114             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
00115             to determine if the DLL should remain loaded, or should be
00116             immediately unloaded depending upon whether the DLL could be
00117             initialized properly.  For all other values of fdwReason, the
00118             return value is ignored.
00119
00120   Args:     HINSTANCE hDLLInst,
00121               Instance handle of the DLL.
00122             DWORD fdwReason,
00123               Process attach/detach or thread attach/detach.
00124               Reason for calling.
00125             LPVOID lpvReserved)
00126               Reserved and not used.
00127
00128   Returns:  BOOL,
00129               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
00130               TRUE  -  Used to signify that the DLL should remain loaded.
00131               FALSE -  Used to signify that the DLL should be
00132                 immediately unloaded.
00133 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00134 BOOL WINAPI DllMain(
00135               HINSTANCE hDllInst,
00136               DWORD fdwReason,
00137               LPVOID lpvReserved)
00138 {
00139   BOOL bResult = TRUE;
00140
00141   // Dispatch this main call based on the reason it was called.
00142   switch (fdwReason)
00143   {
00144     case DLL_PROCESS_ATTACH:
00145       // The DLL is being loaded for the first time by a given process.
00146       // Perform per-process initialization here.  If the initialization
00147       // is successful, return TRUE; if unsuccessful, return FALSE.
00148       bResult = FALSE;
00149       if (UnicodeOk())
00150       {
00151         // Instantiate the CServer utility class.
00152         g_pServer = new CServer;
00153         if (NULL != g_pServer)
00154         {
00155           // Remember the DLL Instance handle.
00156           g_pServer->m_hDllInst = hDllInst;
00157           bResult = TRUE;
00158         }
00159       }
00160       break;
00161
00162     case DLL_PROCESS_DETACH:
00163       // The DLL is being unloaded by a given process.  Do any
00164       // per-process clean up here, such as undoing what was done in
00165       // DLL_PROCESS_ATTACH.  The return value is ignored.
00166       DELETE_POINTER(g_pServer);
00167       break;
00168
00169     case DLL_THREAD_ATTACH:
00170       // A thread is being created in a process that has already loaded
00171       // this DLL.  Perform any per-thread initialization here.  The
00172       // return value is ignored.
00173       break;
00174
00175     case DLL_THREAD_DETACH:
00176       // A thread is exiting cleanly in a process that has already
00177       // loaded this DLL.  Perform any per-thread clean up here.  The
00178       // return value is ignored.
00179       break;
00180
00181     default:
00182       break;
00183   }
00184
00185   return (bResult);
00186 }
00187
00188
00189 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00190   Function: DllGetClassObject
00191
00192   Summary:  The standard exported function that the COM service library
00193             uses to obtain an object class of the class factory for a
00194             specified component provided by this server DLL.
00195
00196   Args:     REFCLSID rclsid,
00197               [in] The CLSID of the requested Component.
00198             REFIID riid,
00199               [in] GUID of the requested interface on the Class Factory.
00200             PPVOID ppv)
00201               [out] Address of the caller's pointer variable that will
00202               receive the requested interface pointer.
00203
00204   Returns:  HRESULT
00205               CLASS_E_CLASSNOTAVAILABLE if requested component
00206                 isn't supported.
00207               E_OUTOFMEMORY if out of memory.
00208               Error code out of the QueryInterface.
00209 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00210 STDAPI DllGetClassObject(
00211          REFCLSID rclsid,
00212          REFIID riid,
00213          PPVOID ppv)
00214 {
00215   HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
00216   IUnknown* pCO = NULL;
00217
00218   if (CLSID_TextPage == rclsid)
00219   {
00220     hr = E_OUTOFMEMORY;
00221     pCO = new CFTextPage(NULL, g_pServer);
00222   }
00223
00224   if (NULL != pCO)
00225   {
00226     g_pServer->ObjectsUp();
00227     hr = pCO->QueryInterface(riid, ppv);
00228     if (FAILED(hr))
00229     {
00230       g_pServer->ObjectsDown();
00231       DELETE_POINTER(pCO);
00232     }
00233   }
00234
00235   return hr;
00236 }
00237
00238
00239 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00240   Function: DllCanUnloadNow
00241
00242   Summary:  The standard exported function that the COM service library
00243             uses to determine if this server DLL can be unloaded.
00244
00245   Args:     void.
00246
00247   Returns:  HRESULT
00248               S_OK if this DLL server can be unloaded.
00249               S_FALSE if this DLL can not be unloaded.
00250 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00251 STDAPI DllCanUnloadNow(void)
00252 {
00253   HRESULT hr;
00254
00255   // We return S_OK if there are no longer any living objects AND
00256   // there are no outstanding client locks on this server.
00257   // Ask server control object.
00258   hr = g_pServer->CanUnloadNow();
00259
00260   return hr;
00261 }
00262
00263
00264 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00265   Function: DllRegisterServer
00266
00267   Summary:  The standard exported function that can be called to command
00268             this DLL server to register itself in the system registry.
00269
00270   Args:     void.
00271
00272   Returns:  HRESULT
00273               NOERROR
00274 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00275 STDAPI DllRegisterServer(void)
00276 {
00277   HRESULT  hr = NOERROR;
00278   TCHAR    szID[GUID_SIZE+1];
00279   TCHAR    szCLSID[GUID_SIZE+32];
00280   TCHAR    szModulePath[MAX_PATH];
00281
00282   // Obtain the path to this module's executable file for later use.
00283   GetModuleFileName(
00284     g_pServer->m_hDllInst,
00285     szModulePath,
00286     sizeof(szModulePath)/sizeof(TCHAR));
00287
00288   /*-------------------------------------------------------------------------
00289     Create registry entries for the TextPage Component.
00290   -------------------------------------------------------------------------*/
00291   // Create some base key strings.
00292   StringFromGUID2(CLSID_TextPage, szID, GUID_SIZE);
00293   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00294   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00295
00296   // Create ProgID keys.
00297   SetRegKeyValue(
00298     TEXT("CTS.TextPage.1"),
00299     NULL,
00300     TEXT("TextPage Component - PERTEXT Code Sample"));
00301   SetRegKeyValue(
00302     TEXT("CTS.TextPage.1"),
00303     TEXT("CLSID"),
00304     szID);
00305
00306   // Create VersionIndependentProgID keys.
00307   SetRegKeyValue(
00308     TEXT("CTS.TextPage"),
00309     NULL,
00310     TEXT("TextPage Component - PERTEXT Code Sample"));
00311   SetRegKeyValue(
00312     TEXT("CTS.TextPage"),
00313     TEXT("CurVer"),
00314     TEXT("CTS.TextPage.1"));
00315   SetRegKeyValue(
00316     TEXT("CTS.TextPage"),
00317     TEXT("CLSID"),
00318     szID);
00319
00320   // Create entries under CLSID.
00321   SetRegKeyValue(
00322     szCLSID,
00323     NULL,
00324     TEXT("TextPage Component - PERTEXT Code Sample"));
00325   SetRegKeyValue(
00326     szCLSID,
00327     TEXT("ProgID"),
00328     TEXT("CTS.TextPage.1"));
00329   SetRegKeyValue(
00330     szCLSID,
00331     TEXT("VersionIndependentProgID"),
00332     TEXT("CTS.TextPage"));
00333   SetRegKeyValue(
00334     szCLSID,
00335     TEXT("NotInsertable"),
00336     NULL);
00337   SetRegKeyValue(
00338     szCLSID,
00339     TEXT("InprocServer32"),
00340     szModulePath);
00341   AddRegNamedValue(
00342     szCLSID,
00343     TEXT("InprocServer32"),
00344     TEXT("ThreadingModel"),
00345     TEXT("Apartment"));
00346
00347   return hr;
00348 }
00349
00350
00351 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00352   Function: DllUnregisterServer
00353
00354   Summary:  The standard exported function that can be called to command
00355             this DLL server to unregister itself from the system Registry.
00356
00357   Args:     void.
00358
00359   Returns:  HRESULT
00360               NOERROR
00361 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00362 STDAPI DllUnregisterServer(void)
00363 {
00364   HRESULT  hr = NOERROR;
00365   TCHAR    szID[GUID_SIZE+1];
00366   TCHAR    szCLSID[GUID_SIZE+32];
00367   TCHAR    szTemp[MAX_PATH+GUID_SIZE];
00368
00369   /*-------------------------------------------------------------------------
00370     Delete registry entries for the TextPage Component.
00371   -------------------------------------------------------------------------*/
00372   //Create some base key strings.
00373   StringFromGUID2(CLSID_TextPage, szID, GUID_SIZE);
00374   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00375   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00376
00377   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.TextPage\\CurVer"));
00378   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.TextPage\\CLSID"));
00379   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.TextPage"));
00380
00381   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.TextPage.1\\CLSID"));
00382   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.TextPage.1"));
00383
00384   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00385   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00386
00387   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00388   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00389
00390   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00391   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00392
00393   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00394   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00395
00396   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00397
00398   return hr;
00399 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/TPCInfo/TPCInfo.cpp Source File

  • TabletPC
  • TPCInfo

TPCInfo.cpp

Go to the documentation of this file.
00001 //
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      TPCInfo.cpp
00013 //
00014 // Description:
00015 //      This program checks the presence and configuration of the
00016 //      Microsoft Tablet PC Platform core components.
00017 //      It finds out whether Tablet PC components are enabled in the
00018 //      operating system, shows the names and version info of the
00019 //      core controls and default handwriting and speech recognizers.
00020 //
00021 //      This application is discussed in the Getting Started guide.
00022 //
00023 //--------------------------------------------------------------------------
00024
00025 // Windows header files
00026 #include <windows.h>
00027 #include <comdef.h>
00028 #include <wchar.h>
00029
00030 // Headers for Tablet PC Automation interfaces
00031 #include <msinkaut.h>
00032 #include <msinkaut_i.c>
00033
00034 // The sample's resource header file
00035 #include "resource.h"
00036
00037 // The system metrics index for checking on Tablet PC components
00038 #ifndef SM_TABLETPC
00039 #define SM_TABLETPC     86
00040 #endif
00041
00042 // A useful macro to calculate the number of elements in an array
00043 #ifndef countof
00044 // 'A' must be the name of an array, not just a pointer,
00045 // so that sizeof(A) would give the size of the array
00046 #define countof(A) (sizeof(A)/sizeof(A[0]))
00047 #endif
00048
00049 // IDs of the dialog static controls
00050 #define NUM_CONTROLS    2
00051 const UINT  gc_uiCtrlId[NUM_CONTROLS][2] = {{IDC_CTL1_NAME, IDC_CTL1_VER},
00052                                             {IDC_CTL2_NAME, IDC_CTL2_VER}};
00053
00054 // ProgID's of the Tablet PC controls to check on
00055 LPCOLESTR gc_wszProgId[NUM_CONTROLS] = {L"InkEd.InkEdit", L"msinkaut.InkPicture"};
00056
00057 // The key to the registry settings of the installed speech recognizers
00058 const WCHAR* gc_wszSpeechKey = L"Software\\Microsoft\\Speech\\Recognizers";
00059
00060 // CLSID of the Text Services Framework's ThreadManager object
00061 const CLSID CLSID_TF_ThreadMgr =
00062         { 0x529A9E6B,0x6587,0x4F23,{ 0xAB,0x9E,0x9C,0x7D,0x68,0x3E,0x3C,0x50 } };
00063
00064 // A helper structure, used in the GetComponentInfo function
00065 typedef struct
00066 {
00067     WCHAR wchName[256];
00068     WCHAR wchVersion[256];
00069 } SInfo;
00070
00071 const WCHAR gc_wszAppName[] = L"TPCInfo Sample Application";
00072
00073
00074 /////////////////////////////////////////////////////////
00075 //
00076 // GetComponentInfo
00077 //
00078 //        This helper function, provided with a component
00079 //        ProgId, gathers the component's name and version
00080 //        info and formats them into output strings
00081 //
00082 // Parameters:
00083 //        CLSID  clsid  : [in] component's CLSID
00084 //        SInfo& info   : [in, out] a structure of buffers
00085 //                        to get the formatted strings into
00086 //
00087 // Return Values:
00088 //        TRUE, if the function succeeds
00089 //        FALSE, if it fails
00090 //
00091 /////////////////////////////////////////////////////////
00092 BOOL GetComponentInfo(CLSID clsid, SInfo& info)
00093 {
00094     info.wchName[0] = info.wchVersion[0] = 0;
00095
00096     // Format Registry Key string
00097     WCHAR wszKey[45] = L"CLSID\\";  // the key buffer should be large enough for a string
00098                                     // like "CLSID\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"
00099     // Convert CLSID to String
00100     UINT uPos = lstrlenW(wszKey);
00101     if (0 == StringFromGUID2(clsid, &wszKey[uPos], countof(wszKey) - uPos))
00102         return FALSE;
00103     wszKey[countof(wszKey)-1] = 0;
00104
00105     // Open key to find path of application
00106     HKEY hKeyRoot;
00107     if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszKey, 0, KEY_READ, &hKeyRoot) != ERROR_SUCCESS)
00108         return FALSE;
00109
00110     // Query value of key to get the name of the component
00111     ULONG cSize = sizeof(info.wchName);  // size of the buffer in bytes
00112     if (RegQueryValueExW(hKeyRoot, NULL, NULL, NULL, (BYTE*)info.wchName, &cSize) != ERROR_SUCCESS)
00113     {
00114         RegCloseKey(hKeyRoot);
00115         return FALSE;
00116     }
00117     info.wchName[countof(info.wchName) - 1] = 0;
00118
00119     // Open the version info subkey
00120     UINT iVersionMaxLen = countof(info.wchVersion);
00121     HKEY hKey = NULL;
00122     if (RegOpenKeyExW(hKeyRoot, L"Version", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
00123     {
00124         const WCHAR* pcwsVersion = L"version ";
00125         UINT iLen = lstrlenW(pcwsVersion);
00126         // Query value of key to get version string
00127         if (iLen < iVersionMaxLen)
00128         {
00129             // copy the "version " string including terminating 0
00130             lstrcpynW(info.wchVersion, pcwsVersion, iLen + 1);
00131             // get the version string
00132             cSize = (iVersionMaxLen - iLen) * sizeof(WCHAR); // the size is in bytes
00133             if (RegQueryValueExW(hKey, NULL, NULL, NULL,
00134                                  (BYTE*)&info.wchVersion[iLen],
00135                                  &cSize) == ERROR_SUCCESS)
00136             {
00137                 info.wchVersion[iVersionMaxLen-1] = 0;
00138             }
00139         }
00140         RegCloseKey(hKey);
00141     }
00142
00143     // Open InprocServer32 subkey to get the path to the component
00144     if (RegOpenKeyExW(hKeyRoot, L"InprocServer32", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
00145     {
00146         // Query value of key to get the path string
00147         WCHAR wchPath[MAX_PATH];
00148         cSize = sizeof(wchPath);
00149         if (RegQueryValueExW(hKey, NULL, NULL, NULL, (BYTE*)wchPath, &cSize) == ERROR_SUCCESS)
00150         {
00151             // Get the build number from the file version info
00152             DWORD dwHandle = 0;
00153             cSize = GetFileVersionInfoSizeW(wchPath, &dwHandle); // returns the size in bytes
00154             WCHAR* pwchFileVerInfo = NULL;
00155             if (cSize)
00156             {
00157                 pwchFileVerInfo = (WCHAR*)new BYTE[cSize];
00158             }
00159             if (NULL != pwchFileVerInfo)
00160             {
00161                 // Retrieve version information for the file
00162                 if (GetFileVersionInfoW(wchPath, 0, cSize, pwchFileVerInfo))
00163                 {
00164                     // Get the default language id and code page number
00165                     UINT *pdwLang;
00166                     UINT cch = 0;
00167                     if (VerQueryValueW(pwchFileVerInfo, L"\\VarFileInfo\\Translation",
00168                                        (void**)&pdwLang, &cch) == TRUE)
00169                     {
00170                         // Read the file description for the language and code page.
00171                         const int MAX_SUBBLOCK = 40;
00172                         WCHAR wchSubBlock[MAX_SUBBLOCK];  // large enough for the string
00173                         _snwprintf(wchSubBlock, MAX_SUBBLOCK - 1,
00174                                    L"\\StringFileInfo\\%04x%04x\\FileVersion",
00175                                    LOWORD(*pdwLang), HIWORD(*pdwLang));
00176                         wchSubBlock[MAX_SUBBLOCK-1] = 0;
00177
00178                         WCHAR* pwchBuildVer = NULL;
00179                         if ((VerQueryValueW(pwchFileVerInfo, wchSubBlock,
00180                                             (void**)&pwchBuildVer, &cch) == TRUE)
00181                             && (NULL != pwchBuildVer))
00182                         {
00183                             // Format the version string
00184                             UINT iLen = (UINT)lstrlenW(info.wchVersion);
00185                             if (0 < iLen)
00186                             {
00187                                 if (iLen < iVersionMaxLen)
00188                                 {
00189                                     const WCHAR* pcwsBuild = L", build ";
00190                                     lstrcpynW(info.wchVersion + iLen, pcwsBuild,
00191                                               iVersionMaxLen - iLen);
00192                                     iLen += lstrlenW(pcwsBuild);
00193                                     if (iLen < iVersionMaxLen)
00194                                     {
00195                                         lstrcpynW(info.wchVersion + iLen, pwchBuildVer,
00196                                                   iVersionMaxLen - iLen);
00197                                     }
00198                                 }
00199                             }
00200                             else
00201                             {
00202                                 lstrcpynW(info.wchVersion, pwchBuildVer, iVersionMaxLen);
00203                             }
00204                             info.wchVersion[iVersionMaxLen-1] = 0;
00205                         }
00206                     }
00207                 }
00208                 delete [] pwchFileVerInfo;
00209             }
00210
00211         }
00212         RegCloseKey(hKey);
00213     }
00214
00215     RegCloseKey(hKeyRoot);
00216
00217     return TRUE;
00218 }
00219
00220 /////////////////////////////////////////////////////////
00221 //
00222 // DlgProc
00223 //
00224 //        The DlgProc function is an application-defined
00225 //        function that processes messages sent to the dialog
00226 //
00227 // Parameters:
00228 //        HWND hwnd      : [in] handle to dialog window
00229 //        UINT uMsg      : [in] message identifier
00230 //        WPARAM wParam  : [in] first message parameter
00231 //        LPARAM lParam  : [in] second message parameter
00232 //
00233 // Return Values:
00234 //        The return value is the result of the
00235 //        message processing and depends on the message sent
00236 //
00237 /////////////////////////////////////////////////////////
00238 BOOL CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00239 {
00240     BOOL bReturn = FALSE; // the value to return
00241     switch (uMsg)
00242     {
00243         case WM_INITDIALOG:
00244         {
00245             // Initialize the COM
00246             if (FAILED(CoInitialize(NULL)))
00247             {
00248                 MessageBoxW(NULL, L"Unable to initialize the COM library",
00249                             gc_wszAppName, MB_OK | MB_ICONINFORMATION);
00250                 PostMessage(hwnd, WM_CLOSE, 0, 0);
00251                 break;
00252             }
00253
00254             // Gather and show the information we're interested in
00255
00256             // Check out if Microsoft Tablet PC Platform components of the
00257             // Microsoft Windows XP Professional Operating System are enabled
00258             int bTabletPC = GetSystemMetrics(SM_TABLETPC);
00259             SetDlgItemTextW(hwnd, IDC_TABLETPC,
00260                             bTabletPC ? L"Available" : L"Not available");
00261
00262             // Get the version of the Text Services Framework components
00263             SInfo info;
00264             if (GetComponentInfo(CLSID_TF_ThreadMgr, info) == TRUE)
00265             {
00266                 SetDlgItemTextW(hwnd, IDC_TSF, info.wchVersion);
00267             }
00268
00269             // Find out the name and the version of the default handwriting recognizer
00270             // Create the enumerator for the installed recognizers
00271             IInkRecognizers* pIInkRecognizers = NULL;
00272             HRESULT hr = CoCreateInstance(CLSID_InkRecognizers,
00273                                           NULL,
00274                                           CLSCTX_INPROC_SERVER,
00275                                           IID_IInkRecognizers,
00276                                           (void **)&pIInkRecognizers);
00277             if (SUCCEEDED(hr))
00278             {
00279                 IInkRecognizer* pIInkRecognizer = NULL;
00280                 // The first parameter is the language id, passing 0 means that the language
00281                 // id will be retrieved using the user default-locale identifier
00282                 hr = pIInkRecognizers->GetDefaultRecognizer(0, &pIInkRecognizer);
00283                 if (SUCCEEDED(hr))
00284                 {
00285                     // Get the recognizer's friendly name
00286                     BSTR bstr;
00287                     if (SUCCEEDED(pIInkRecognizer->get_Name(&bstr)))
00288                     {
00289                         SetDlgItemTextW(hwnd, IDC_HWR_NAME, bstr);
00290                         SysFreeString(bstr);
00291                     }
00292                     else
00293                     {
00294                         SetDlgItemTextW(hwnd, IDC_HWR_NAME, L"Failed");
00295                     }
00296                     // Get the recognizer's vendor info
00297                     if (SUCCEEDED(pIInkRecognizer->get_Vendor(&bstr)))
00298                     {
00299                         SetDlgItemTextW(hwnd, IDC_HWR_VENDOR, bstr);
00300                         SysFreeString(bstr);
00301                     }
00302                     else
00303                     {
00304                         SetDlgItemTextW(hwnd, IDC_HWR_VENDOR, L"Failed");
00305                     }
00306                     // Release it
00307                     pIInkRecognizer->Release();
00308                     pIInkRecognizer = NULL;
00309                 }
00310                 // Release the collection object
00311                 pIInkRecognizers->Release();
00312                 pIInkRecognizers = NULL;
00313             }
00314
00315             // Find out the name and the version of the default speech recognizer
00316
00317             // Open key to find path of application
00318             HKEY hkeySpeech;
00319             if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, gc_wszSpeechKey, 0, KEY_READ,
00320                             &hkeySpeech) == ERROR_SUCCESS)
00321             {
00322                 // Query value of key to get the name of the component
00323                 WCHAR wchValue[265];
00324                 ULONG cSize = sizeof(wchValue);
00325                 if (RegQueryValueExW(hkeySpeech, L"DefaultDefaultTokenId", NULL, NULL,
00326                                     (BYTE*)wchValue, &cSize) == ERROR_SUCCESS)
00327                 {
00328                     int ndx = lstrlenW(L"HKEY_LOCAL_MACHINE\\");
00329                     int len = lstrlenW(wchValue);
00330                     if (ndx < len
00331                         && RegOpenKeyExW(HKEY_LOCAL_MACHINE, &wchValue[ndx], 0,
00332                                          KEY_READ, &hkeySpeech) == ERROR_SUCCESS)
00333                     {
00334                         cSize = sizeof(wchValue);
00335                         if (RegQueryValueExW(hkeySpeech, NULL, NULL, NULL,
00336                                              (BYTE*)wchValue, &cSize) == ERROR_SUCCESS)
00337                         {
00338                             SetDlgItemTextW(hwnd, IDC_SPR_NAME, wchValue);
00339                         }
00340                     }
00341                 }
00342             }
00343
00344             // Find out which of the controls are installed and show their version info
00345             for (int i = 0, j = 0; i < NUM_CONTROLS; i++)
00346             {
00347                 // Get the component info
00348                 CLSID clsid;
00349                 if (SUCCEEDED(CLSIDFromProgID(gc_wszProgId[i], &clsid))
00350                     && GetComponentInfo(clsid, info) == TRUE)
00351                 {
00352                     SetDlgItemTextW(hwnd, gc_uiCtrlId[j][0], info.wchName);
00353                     SetDlgItemTextW(hwnd, gc_uiCtrlId[j][1], info.wchVersion);
00354                     j++;
00355                 }
00356             }
00357
00358             // Done with the COM
00359             CoUninitialize();
00360
00361             break;
00362         }
00363         case WM_DESTROY:
00364
00365             PostQuitMessage(0);
00366             break;
00367
00368         case WM_COMMAND:
00369             switch (LOWORD(wParam))
00370             {
00371                 case IDCLOSE:   // User clicked on the "Close" button in the dialog.
00372                 case IDCANCEL:  // User clicked the close button ([X]) in the caption
00373                                 // or pressed Alt+F4.
00374                     DestroyWindow(hwnd);
00375                     bReturn = TRUE;
00376                     break;
00377             }
00378             break;
00379     }
00380
00381     return bReturn;
00382 }
00383
00384 /////////////////////////////////////////////////////////
00385 //
00386 // WinMain
00387 //
00388 //      The WinMain function is called by the system as the
00389 //      initial entry point for a Win32-based application.
00390 //      It contains typical boilerplate code to create and
00391 //      show the main window, and pump messages.
00392 //
00393 // Parameters:
00394 //        HINSTANCE hInstance,      : [in] handle to current instance
00395 //        HINSTANCE hPrevInstance,  : [in] handle to previous instance
00396 //        LPSTR lpCmdLine,          : [in] command line
00397 //        int nCmdShow              : [in] show state
00398 //
00399 // Return Values:
00400 //        0 : The function terminated before entering the message loop.
00401 //        non zero: Value of the wParam when receiving the WM_QUIT message
00402 //
00403 /////////////////////////////////////////////////////////
00404 int APIENTRY WinMain(HINSTANCE hInstance,
00405                      HINSTANCE hPrevInstance,
00406                      LPSTR     lpCmdLine,
00407                      int       nCmdShow)
00408 {
00409     // unused parameters
00410     hPrevInstance, lpCmdLine, nCmdShow;     // silence the compiler warnings
00411
00412     int iRet = 0;
00413
00414     // Create the application window
00415     HWND hwndDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc);
00416     if (NULL != hwndDlg)
00417     {
00418
00419         ShowWindow(hwndDlg, SW_SHOW);
00420
00421         // Start the message loop
00422         MSG msg;
00423         while (GetMessage(&msg, NULL, 0, 0) > 0)
00424         {
00425             if (!IsDialogMessage(hwndDlg, &msg))
00426             {
00427                 TranslateMessage(&msg);
00428                 DispatchMessage(&msg);
00429             }
00430         }
00431
00432         iRet = (int)msg.wParam;
00433     }
00434     else
00435     {
00436         MessageBoxW(NULL, L"Unable to create the dialog box",
00437                     gc_wszAppName, MB_OK | MB_ICONINFORMATION);
00438     }
00439
00440     return iRet;
00441 }
00442
00443
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/DiskQuota/PrintMenu.Cpp Source File

  • WinBase
  • IO
  • DiskQuota

PrintMenu.Cpp

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 PrintMenu.cpp
00011
00012 Description:
00013 Implements the functions used to print out the various menus and return
00014 the user's selection.
00015 ----------------------------------------------------------------------------*/
00016
00017 #define WIN32_LEAN_AND_MEAN
00018
00019 #include <windows.h>
00020 #include <stdio.h>
00021
00022 static WCHAR GetUserInput();
00023
00024 /*-----------------------------------------------------------------------------
00025 PrintMainMenu()
00026     Prints out the main menu choices
00027
00028 Parameters
00029     None
00030
00031 Return Value
00032     UNICODE value of the user's menu selection
00033 -----------------------------------------------------------------------------*/
00034 WCHAR PrintMainMenu()
00035 {
00036     wprintf(L"\n\nMain Menu\n");
00037     wprintf(L"---------\n");
00038     wprintf(L"A) Get/Set default volume quota settings\n");
00039     wprintf(L"B) Get/Set quota log flags\n");
00040     wprintf(L"C) Get/Set default quota limits\n");
00041     wprintf(L"D) Get/Set user quotas\n");
00042     wprintf(L"E) Add/Delete a user for which to keep track of disk quotas\n");
00043     wprintf(L"X) Exit \n");
00044     wprintf(L"Please enter your selection: ");
00045
00046     return (GetUserInput());
00047 }
00048
00049 /*-----------------------------------------------------------------------------
00050 PrintDefaultQuotaMenu()
00051     Prints out the choices for getting and setting the default volume
00052     quota settings
00053
00054 Parameters
00055     None
00056
00057 Return Value
00058     UNICODE value of the user's menu selection
00059 -----------------------------------------------------------------------------*/
00060 WCHAR PrintDefaultQuotaMenu()
00061 {
00062     wprintf(L"\n\nDefault Quota Menu\n");
00063     wprintf(L"------------------\n");
00064     wprintf(L"A) Get default volume quota settings\n");
00065     wprintf(L"B) Disable disk quotas\n");
00066     wprintf(L"C) Track disk quotas\n");
00067     wprintf(L"D) Enforce disk quotas\n");
00068     wprintf(L"X) Exit back to main menu\n");
00069     wprintf(L"Please enter your selection: ");
00070
00071     return (GetUserInput());
00072 }
00073
00074 /*-----------------------------------------------------------------------------
00075 PrintQuotaLogFlagMenu()
00076     Prints out the choices for getting and setting the quota log flags
00077
00078 Parameters
00079     None
00080
00081 Return Value
00082     UNICODE value of the user's menu selection
00083 -----------------------------------------------------------------------------*/
00084 WCHAR PrintQuotaLogFlagMenu()
00085 {
00086     wprintf(L"\n\nQuota Log Flag Menu\n");
00087     wprintf(L"-------------------\n");
00088     wprintf(L"A) Get default volume log flags\n");
00089     wprintf(L"B) Enable logging of threshold violations\n");
00090     wprintf(L"C) Enable logging of hard quota limit violations\n");
00091     wprintf(L"D) Disable logging of threshold violations\n");
00092     wprintf(L"E) Disable logging of hard quota limit violations\n");
00093     wprintf(L"X) Exit back to main menu\n");
00094     wprintf(L"Please enter your selection: ");
00095
00096     return (GetUserInput());
00097 }
00098
00099 /*-----------------------------------------------------------------------------
00100 PrintDefaultLimitsMenu()
00101     Prints out the choices for getting and setting the default quota limits
00102
00103 Parameters
00104     None
00105
00106 Return Value
00107     UNICODE value of the user's menu selection
00108 -----------------------------------------------------------------------------*/
00109 WCHAR PrintDefaultLimitsMenu()
00110 {
00111     wprintf(L"\n\nDefault Limits Menu\n");
00112     wprintf(L"-------------------\n");
00113     wprintf(L"A) Get default quota hard limit\n");
00114     wprintf(L"B) Get default quota threshold\n");
00115     wprintf(L"C) Set default quota hard limit\n");
00116     wprintf(L"D) Set default quota threshold\n");
00117     wprintf(L"X) Exit back to main menu\n");
00118     wprintf(L"Please enter your selection: ");
00119
00120     return (GetUserInput());
00121 }
00122
00123 /*-----------------------------------------------------------------------------
00124 PrintUserManagerMenu()
00125     Prints out the choices for adding and deleting users for which to keep
00126     track of disk quotas
00127
00128 Parameters
00129     None
00130
00131 Return Value
00132     UNICODE value of the user's menu selection
00133 -----------------------------------------------------------------------------*/
00134 WCHAR PrintUserManagerMenu()
00135 {
00136     wprintf(L"\n\nUser Manager Menu\n");
00137     wprintf(L"-----------------\n");
00138     wprintf(L"A) Add a user for which to keep track of quotas\n");
00139     wprintf(L"B) Delete a user for which you no longer which to track quotas\n");
00140     wprintf(L"C) Enumerate users for which quotas are tracked\n");
00141     wprintf(L"X) Exit back to main menu\n");
00142     wprintf(L"Please enter your selection: ");
00143
00144     return (GetUserInput());
00145 }
00146
00147 /*-----------------------------------------------------------------------------
00148 PrintQuotaManagerMenu()
00149     Prints out the choices for getting quotas for all users and for setting
00150     quotas for a particular user
00151
00152 Parameters
00153     None
00154
00155 Return Value
00156     UNICODE value of the user's menu selection
00157 -----------------------------------------------------------------------------*/
00158 WCHAR PrintQuotaManagerMenu()
00159 {
00160     wprintf(L"\n\nQuota Manager Menu\n");
00161     wprintf(L"------------------\n");
00162     wprintf(L"A) Get the quota information for all users\n");
00163     wprintf(L"B) Set the quota hard limit for a user\n");
00164     wprintf(L"C) Set the quota threshold for a user\n");
00165     wprintf(L"X) Exit back to main menu\n");
00166     wprintf(L"Please enter your selection: ");
00167
00168     return (GetUserInput());
00169 }
00170
00171 /*-----------------------------------------------------------------------------
00172 GetUserInput()
00173     Gets the user's menu selection and returns the UNICODE value
00174
00175 Parameters
00176     None
00177
00178 Return Value
00179     UNICODE value of the user's menu selection
00180 -----------------------------------------------------------------------------*/
00181 WCHAR GetUserInput()
00182 {
00183     HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
00184     INPUT_RECORD sInputRecord;
00185     DWORD        dwInputEvents;
00186
00187     ReadConsoleInput(hStdIn,&sInputRecord,1 ,&dwInputEvents);
00188     while (!((sInputRecord.EventType == KEY_EVENT) && (sInputRecord.Event.KeyEvent.bKeyDown)))
00189     {
00190         FlushConsoleInputBuffer(hStdIn);
00191         ReadConsoleInput(hStdIn,&sInputRecord,1 ,&dwInputEvents);
00192     }
00193
00194     return sInputRecord.Event.KeyEvent.uChar.UnicodeChar;
00195 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAttributeValueAddButton Member List

This is the complete list of members for CAttributeValueAddButton, including all inherited members.
CAttributeValueAddButton(CMultiValuedAttributeEditor *pEditor) | CAttributeValueAddButton | [inline]
CAttributeValueAddButton(CMultiValuedAttributeEditor *pEditor) | CAttributeValueAddButton | [inline]
m_pEditor | CAttributeValueAddButton | [protected]
OnAdd() | CAttributeValueAddButton |
OnAdd() | CAttributeValueAddButton |
~CAttributeValueAddButton() | CAttributeValueAddButton | [inline]
~CAttributeValueAddButton() | CAttributeValueAddButton | [inline]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/case.h Source File

  • WinUI
  • TSFcase

case.h

Go to the documentation of this file.
00001 //
00002 // case.h
00003 //
00004 // CCaseTextService declaration.
00005 //
00006
00007 #ifndef CASE_H
00008 #define CASE_H
00009
00010 class CLangBarItemButton;
00011 class CSnoopWnd;
00012
00013 class CCaseTextService : public ITfTextInputProcessor,
00014                          public ITfThreadMgrEventSink,
00015                          public ITfTextEditSink,
00016                          public ITfThreadFocusSink,
00017                          public ITfKeyEventSink
00018 {
00019 public:
00020     CCaseTextService();
00021     ~CCaseTextService();
00022
00023     // IUnknown
00024     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00025     STDMETHODIMP_(ULONG) AddRef(void);
00026     STDMETHODIMP_(ULONG) Release(void);
00027
00028     // ITfTextInputProcessor
00029     STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId);
00030     STDMETHODIMP Deactivate();
00031
00032     // ITfThreadMgrEventSink
00033     STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr);
00034     STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr);
00035     STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus);
00036     STDMETHODIMP OnPushContext(ITfContext *pContext);
00037     STDMETHODIMP OnPopContext(ITfContext *pContext);
00038
00039     // ITfThreadFocusSink
00040     STDMETHODIMP OnSetThreadFocus();
00041     STDMETHODIMP OnKillThreadFocus();
00042
00043     // ITfTextEditSink
00044     STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord);
00045
00046     // ITfKeyEventSink
00047     STDMETHODIMP OnSetFocus(BOOL fForeground);
00048     STDMETHODIMP OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00049     STDMETHODIMP OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00050     STDMETHODIMP OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00051     STDMETHODIMP OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
00052     STDMETHODIMP OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pfEaten);
00053
00054     // CClassFactory factory callback
00055     static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
00056
00057     // server registration
00058     static BOOL RegisterProfiles();
00059     static void UnregisterProfiles();
00060     static BOOL RegisterCategories(BOOL fRegister);
00061     static BOOL RegisterServer();
00062     static void UnregisterServer();
00063
00064     // language bar menu handlers
00065     static void _Menu_HelloWord(CCaseTextService *_this);
00066     static void _Menu_FlipSel(CCaseTextService *_this);
00067     static void _Menu_FlipDoc(CCaseTextService *_this);
00068     static void _Menu_ShowSnoopWnd(CCaseTextService *_this);
00069     static void _Menu_FlipKeys(CCaseTextService *_this);
00070
00071     ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; }
00072     TfClientId _GetClientId() { return _tfClientId; }
00073     BOOL _IsSnoopWndVisible() { return _fShowSnoop; }
00074     BOOL _IsKeyFlipping() { return _fFlipKeys; }
00075
00076 private:
00077     // init methods
00078     BOOL _InitLanguageBar();
00079     BOOL _InitThreadMgrSink();
00080     BOOL _InitSnoopWnd();
00081     BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr);
00082     BOOL _InitKeystrokeSink();
00083     BOOL _InitPreservedKey();
00084
00085     // uninit methods
00086     void _UninitLanguageBar();
00087     void _UninitThreadMgrSink();
00088     void _UninitSnoopWnd();
00089     void _UninitKeystrokeSink();
00090     void _UninitPreservedKey();
00091
00092     //
00093     // state
00094     //
00095
00096     ITfThreadMgr *_pThreadMgr;
00097     TfClientId _tfClientId;
00098
00099     BOOL _fShowSnoop; // hide/show the snoop window popup
00100     CSnoopWnd *_pSnoopWnd;
00101
00102     BOOL _fFlipKeys;
00103
00104     CLangBarItemButton *_pLangBarItem;
00105
00106     DWORD _dwThreadMgrEventSinkCookie;
00107     DWORD _dwThreadFocusSinkCookie;
00108     DWORD _dwTextEditSinkCookie;
00109     ITfContext *_pTextEditSinkContext;
00110
00111     LONG _cRef;     // COM ref count
00112 };
00113
00114
00115 #endif // CASE_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/InOut/InOut.Idl Source File

  • NetDS
  • RPC
  • Data
  • InOut

InOut.Idl

Go to the documentation of this file.
00001 [ uuid (6E3B5060-CA46-1067-B31A-00DD010662DA),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface inout
00006 {
00007
00008 void InOutProc([in]      short   s1,
00009                [in, out] short * ps2,
00010                [out]     float * pf3);
00011
00012 void Shutdown(void);
00013
00014 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MIDL_TYPE_FORMAT_STRING Member List

This is the complete list of members for _MIDL_TYPE_FORMAT_STRING, including all inherited members.
Format | _MIDL_TYPE_FORMAT_STRING
Pad | _MIDL_TYPE_FORMAT_STRING
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Resourcesub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Resourcesub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __RESOURCESUB_H_
00018 #define __RESOURCESUB_H_
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CResourceSub
00028 Summary: Resource Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CResourceSub :
00031   public CSysLCESub,
00032   public IComResourceEvents
00033
00034 {
00035 public:
00036   CResourceSub(CComSpy * pSpy)
00037   {
00038     m_pSpy = pSpy;
00039   }
00040   CResourceSub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045   DECLARE_NOT_AGGREGATABLE(CResourceSub)
00046   DECLARE_GET_CONTROLLING_UNKNOWN()
00047
00048   BEGIN_COM_MAP(CResourceSub)
00049     COM_INTERFACE_ENTRY(IComResourceEvents)
00050     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00051   END_COM_MAP()
00052
00053   STDMETHODIMP GetEventType(EventEnum * e){*e = Resource;return S_OK;}
00054   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00055   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComResourceEvents;return S_OK;}
00056
00057 // IResourceSub
00058 public:
00059   STDMETHOD(OnResourceCreate)(COMSVCSEVENTINFO * pInfo, ULONG64 ObjectID, LPCOLESTR pszType,ULONG64 resId, BOOL enlisted);
00060   STDMETHOD(OnResourceAllocate)(COMSVCSEVENTINFO * pInfo, ULONG64 ObjectID, LPCOLESTR pszType,ULONG64 resId, BOOL enlisted, DWORD NumRated, DWORD Rating);
00061   STDMETHOD(OnResourceRecycle)(COMSVCSEVENTINFO * pInfo, ULONG64 ObjectID, LPCOLESTR pszType,ULONG64 resId);
00062   STDMETHOD(OnResourceDestroy)(COMSVCSEVENTINFO * pInfo, ULONG64 ObjectID, HRESULT hr, LPCOLESTR pszType,ULONG64 resId);
00063   STDMETHOD(OnResourceTrack)(COMSVCSEVENTINFO * pInfo, ULONG64 ObjectID, LPCOLESTR pszType,ULONG64 resId, BOOL enlisted);
00064 };
00065
00066 #endif //__RESOURCESUB_H_
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/propldr.h Source File

  • WinUI
  • tsfapp

propldr.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation. All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          PropLdr.h
00013
00014    Description:   CTSFPersistentPropertyLoader definition
00015
00016 **************************************************************************/
00017
00018 #ifndef PROPLOADER_H
00019 #define PROPLOADER_H
00020
00021 /**************************************************************************
00022   #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <msctf.h>
00027
00028 /**************************************************************************
00029   class definitions
00030 **************************************************************************/
00031
00032 /**************************************************************************
00033
00034   CTSFPersistentPropertyLoader
00035
00036 **************************************************************************/
00037
00038 class CTSFPersistentPropertyLoader : public ITfPersistentPropertyLoaderACP
00039 {
00040 public:
00041     CTSFPersistentPropertyLoader(TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr, IStream *pStream);
00042     ~CTSFPersistentPropertyLoader();
00043
00044     // IUnknown methods
00045     virtual STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00046     virtual STDMETHODIMP_(ULONG) AddRef(void);
00047     virtual STDMETHODIMP_(ULONG) Release(void);
00048
00049     // ITfPersistentPropertyLoaderACP methods
00050     STDMETHODIMP LoadProperty(const TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr, IStream **ppStream);
00051
00052
00053 private:
00054     int m_ObjRefCount;
00055     TF_PERSISTENT_PROPERTY_HEADER_ACP m_hdr;
00056     BYTE *m_pb;
00057 };
00058
00059
00060 #endif //PROPLOADER_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADSIDump/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADSIDump

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__396FF7B8_0B8F_11D2_964F_00C04F8EF907__INCLUDED_)
00007 #define AFX_STDAFX_H__396FF7B8_0B8F_11D2_964F_00C04F8EF907__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015 #include <windows.h>
00016
00017 #include <atlbase.h>
00018
00019 // system headers
00020 #include <activeds.h>
00021
00022
00023 // debug info
00024 // Debug macros
00025 #ifdef _DEBUG
00026 #include <crtdbg.h>
00027 #define Assert(x) { _ASSERTE(x); }
00028 #define Verify(x) Assert(x)
00029 #else // _DEBUG
00030 #define Assert(x) { }
00031 #define Verify(x) { x; }
00032 #endif  // _DEBU
00033 #define Implies(x,y) Assert((!(x)) || (y))
00034
00035 typedef WCHAR * SZ;
00036 typedef const WCHAR * CSZ;
00037
00038 #define UNUSED(x) { x; }
00039
00040
00041 //{{AFX_INSERT_LOCATION}}
00042 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00043
00044 #endif // !defined(AFX_STDAFX_H__396FF7B8_0B8F_11D2_964F_00C04F8EF907__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/ctrace.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

ctrace.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CTRACE.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CTRACE_H_
00012 #define _CTRACE_H_
00013
00014
00015 /////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 /////////////////////////////////////////////////////////////////////
00019
00020
00021 /////////////////////////////////////////////////////////////////////
00022 // Defines
00023 //
00024 /////////////////////////////////////////////////////////////////////
00025 #define TRACE_ADDREF              CIntTrace::TraceAddRef
00026 #define TRACE_QI                CIntTrace::TraceQI
00027 #define TRACE_METHOD              CIntTrace::TraceMethod
00028 #define TRACE_NOTIFICATION            CIntTrace::TraceNotification
00029 #define TRACE_RELEASE_(pv, name, ulExpectedRef) CIntTrace::TraceRelease((IUnknown**)&pv, name, ulExpectedRef);
00030 #define TRACE_RELEASE(pv, name)         TRACE_RELEASE_(pv, name, 1)
00031
00032
00033
00034 /////////////////////////////////////////////////////////////////////
00035 // CIntTrace
00036 //
00037 /////////////////////////////////////////////////////////////////////
00038 class CIntTrace : public CRichEditLite
00039 {
00040 public:
00041   //constructors
00042   CIntTrace(CMainWindow* pCMainWindow);
00043   virtual ~CIntTrace();
00044
00045   //messages
00046   virtual BOOL  OnRButtonDown(WPARAM fwKeys, REFPOINTS pts);
00047   virtual BOOL  OnContextMenu(HWND hWnd, REFPOINTS pts);
00048
00049   virtual BOOL  OnCommand(UINT iID, HWND hWndCtrl);
00050   virtual BOOL  OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags);
00051   virtual BOOL  OnUpdateOutputSelected();
00052
00053   //ListBox (Notifcations)
00054   virtual HRESULT Clear();
00055   virtual void  OutputTextFmt(DWORD dwMask, COLORREF dwColor, WCHAR* pwszFmt, ...);
00056   virtual void  OutputText(DWORD dwMask, COLORREF dwColor, WCHAR* pwszText);
00057   virtual void  OutputLineEnd();
00058   virtual void  OutputIndent(ULONG cIndentLevel);
00059
00060   //Static functions, so everyone has access to tracing support...
00061   static  CIntTrace*  GetTrace();
00062   static  ULONG TraceAddRef(IUnknown* pIUnknown, WCHAR* pwszText);
00063   static  ULONG TraceRelease(IUnknown** ppIUnknown, WCHAR* pwszText, ULONG ulExpectedRefCount = 1);
00064   static  HRESULT TraceQI(IUnknown* pIUnknown, REFIID riid, IUnknown** ppIUnknown, WCHAR* pwszFmt = L"IUnknown");
00065   static  HRESULT TraceMethod(HRESULT hrActual, WCHAR* pwszFmt, ...);
00066   static  HRESULT TraceNotification(DWORD dwNotifyType, HRESULT hrVeto, WCHAR* pwszInterface, WCHAR* pwszMethod, WCHAR* pwszParams, ...);
00067
00068
00069   //Interface
00070   virtual COptionsSheet*  GetOptions();
00071
00072   //Data
00073   CMainWindow*            m_pCMainWindow;
00074   ULONG               m_ulNestingLevel;
00075
00076 };
00077
00078
00079
00080 /////////////////////////////////////////////////////////////////////
00081 // CMDITrace
00082 //
00083 /////////////////////////////////////////////////////////////////////
00084 class CMDITrace : public CMDIChildLite
00085 {
00086 public:
00087   //constructors
00088   CMDITrace(CMainWindow* pCMainWindow);
00089   virtual ~CMDITrace();
00090
00091   virtual BOOL  PreCreateWindow(CREATESTRUCTW& cs);
00092   virtual BOOL  OnCreate(LPCREATESTRUCT lpCreateStruct);
00093   virtual BOOL  AutoPosition(BOOL fDefaultPosition = TRUE);
00094
00095   virtual BOOL  OnDestroy();
00096   virtual BOOL  OnClose();
00097   virtual BOOL  OnInitialUpdate();
00098   virtual BOOL  OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate);
00099
00100   //members
00101   virtual BOOL  UpdateControls();
00102
00103   //Messages
00104   virtual BOOL  OnSize(WPARAM nType,REFPOINTS pts);
00105   virtual BOOL  OnSetFocus(HWND hWndPrevFocus);
00106
00107   //Overloads
00108   virtual BOOL  OnCommand(UINT iID, HWND hWndCtrl);
00109   virtual BOOL  OnNotify(INT idCtrl, NMHDR* pNMHDR);
00110   virtual BOOL  OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags);
00111
00112   //Data
00113   CMainWindow*  m_pCMainWindow;
00114   CIntTrace*      m_pCTrace;
00115 };
00116
00117
00118
00119
00120 #endif  //_CTRACE_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/SampleFSP/Macros.h Source File

  • NetDS
  • fax
  • SampleFSP

Macros.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1997 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007   macros.h
00008
00009 Abstract:
00010
00011   This module contains the global macros
00012
00013 --*/
00014
00015 #ifndef _MACROS_H
00016 #define _MACROS_H
00017
00018 extern HANDLE  g_HeapHandle;  // g_HeapHandle is the global handle to the heap
00019
00020 // MemInitializeMacro is a macro to get the handle to the heap
00021 #define MemInitializeMacro(hHeap) (g_HeapHandle = hHeap)
00022 //#define MemInitializeMacro(hHeap) (g_HeapHandle = GetProcessHeap())
00023 //#define MemInitializeMacro(hHeap) (g_HeapHandle = HeapCreate( 0, 1024*100, 1024*1024*2 ))
00024
00025
00026 // MemAllocMacro is a macro to allocate dwBytes bytes of memory from the heap
00027 #define MemAllocMacro(dwBytes) (HeapAlloc(g_HeapHandle, HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY, dwBytes))
00028
00029 // MemReAllocMacro is a macro to reallocate dwBytes bytes of memory from the heap
00030 #define MemReAllocMacro(lpMem, dwBytes) (HeapReAlloc(g_HeapHandle, HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY, lpMem, dwBytes))
00031
00032 // MemFreeMacro is a macro to free a memory block allocated from the heap
00033 #define MemFreeMacro(lpMem) (HeapFree(g_HeapHandle, 0, lpMem))
00034
00035 #endif
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ADsError Member List

This is the complete list of members for ADsError, including all inherited members.
ADsError() | ADsError | [inline]
GetErrorMessage(long hResult, BSTR *pbMsg) | ADsError |
InterfaceSupportsErrorInfo(REFIID riid) | ADsError |
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CUtilString Member List

This is the complete list of members for CUtilString, including all inherited members.
Clear() | CUtilString | [inline]
CUtilString(bool fAllowStomping=false) | CUtilString | [inline]
CUtilString(const WCHAR *s, bool fAllowStomping=false) | CUtilString | [inline]
CUtilString(const CHAR *s, bool fAllowStomping=false) | CUtilString | [inline]
Free() | CUtilString | [inline]
m_dwCurLen | CUtilString | [private]
m_dwMaxLen | CUtilString | [private]
m_fAllowStomping | CUtilString | [private]
m_fDirty | CUtilString | [private]
m_pszVal | CUtilString | [private]
m_pwszVal | CUtilString | [private]
operator CHAR *() | CUtilString | [inline]
operator WCHAR *() | CUtilString | [inline]
operator+=(const WCHAR *s) | CUtilString | [inline]
operator=(const CUtilString &s) | CUtilString | [inline]
operator=(const WCHAR *s) | CUtilString | [inline]
operator=(const CHAR *s) | CUtilString | [inline]
~CUtilString() | CUtilString | [inline]
Generated on Wed Nov 13 2024 16:57:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/Utils.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

Utils.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          Utils.h
00021
00022   Description:   Utility definitions.
00023
00024 **************************************************************************/
00025
00026 /**************************************************************************
00027 function prototypes
00028 **************************************************************************/
00029
00030 STDAPI_(void) ParseCommandLine(LPSTR, LPBOOL, LPTSTR);
00031 static LPTSTR GetWord(LPTSTR, LPTSTR);
00032 STDAPI GetOleObjectDataHere(LPPERSISTSTORAGE, LPFORMATETC, LPSTGMEDIUM);
00033
00034 /**************************************************************************
00035 global variables
00036 **************************************************************************/
00037
00038 #define EMBEDDINGFLAG TEXT("Embedding")
00039
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFontRange Member List

This is the complete list of members for CFontRange, including all inherited members.
_fPageUsed | CFontRange | [private]
CountUCSegments(HDC hdc) | CFontRange | [private]
CTextGrid class | CFontRange | [friend]
IsPageUsed(UINT nPage) | CFontRange | [inline]
SetFontRange(HWND hwnd, HFONT hfont) | CFontRange |
SwapShort(PUSHORT p) | CFontRange | [private]
SwapULong(PULONG p) | CFontRange | [private]
~CFontRange() | CFontRange |
Generated on Wed Nov 13 2024 16:56:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Reg.Cpp Source File

  • NetDS
  • SyncMgr
  • SyncDir

Reg.Cpp

Go to the documentation of this file.
00001 //==========================================================================
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00004 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00005 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00006 //  PURPOSE.
00007 //
00008 //  Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 #include "precomp.h"
00013
00014 #define HANDLERITEMSKEY TEXT("\\HandlerItems")
00015
00016 #define HANDLERVALUE_DIR1           TEXT("Dir1")
00017 #define HANDLERVALUE_DIR2           TEXT("Dir2")
00018 #define HANDLERVALUE_DISPLAYNAME    TEXT("DisplayName")
00019 #define HANDLERVALUE_FILETIME           TEXT("TimeStamp")
00020 #define HANDLERVALUE_RECURSIVE           TEXT("Recursive")
00021
00022
00023 //+---------------------------------------------------------------------------
00024 //
00025 //  Function:   SetRegKeyValue, private
00026 //
00027 //  Synopsis:   Internal utility function to set a Key, Subkey, and value
00028 //              in the system Registry under HKEY_CLASSES_ROOT.
00029 //
00030 //  Arguments:
00031 //
00032 //  Returns:
00033 //
00034 //  Modifies:
00035 //
00036 //----------------------------------------------------------------------------
00037
00038 BOOL SetRegKeyValue(
00039        HKEY hKeyTop,
00040        LPTSTR pszKey,
00041        LPTSTR pszSubkey,
00042        LPTSTR pszValue)
00043 {
00044   BOOL bOk = FALSE;
00045   LONG ec;
00046   HKEY hKey;
00047   TCHAR szKey[MAX_STRING_LENGTH];
00048
00049   lstrcpy(szKey, pszKey);
00050
00051   if (NULL != pszSubkey)
00052   {
00053     lstrcat(szKey, TEXT("\\"));
00054     lstrcat(szKey, pszSubkey);
00055   }
00056
00057   ec = RegCreateKeyEx(
00058          hKeyTop,
00059          szKey,
00060          0,
00061          NULL,
00062          REG_OPTION_NON_VOLATILE,
00063          KEY_READ | KEY_WRITE,
00064          NULL,
00065          &hKey,
00066          NULL);
00067
00068   if (NULL != pszValue && ERROR_SUCCESS == ec)
00069   {
00070     ec = RegSetValueEx(
00071            hKey,
00072            NULL,
00073            0,
00074            REG_SZ,
00075            (BYTE *)pszValue,
00076            (lstrlen(pszValue)+1)*sizeof(TCHAR));
00077     if (ERROR_SUCCESS == ec)
00078       bOk = TRUE;
00079     RegCloseKey(hKey);
00080   }
00081
00082   return bOk;
00083 }
00084
00085 //+---------------------------------------------------------------------------
00086 //
00087 //  Function:   GetRegKeyValue, private
00088 //
00089 //  Synopsis:   Internal utility function to get a Key value
00090 //              in the system Registry.
00091 //
00092 //  Arguments:
00093 //
00094 //  Returns:
00095 //
00096 //  Modifies:
00097 //
00098 //----------------------------------------------------------------------------
00099
00100 LRESULT GetRegKeyValue(HKEY hkeyParent, LPCTSTR pcszSubKey,
00101                                    LPCTSTR pcszValue, PDWORD pdwValueType,
00102                                    PBYTE pbyteBuf, PDWORD pdwcbBufLen)
00103 {
00104 LONG lResult;
00105 HKEY hkeySubKey;
00106
00107     lResult = RegOpenKeyEx(hkeyParent, pcszSubKey, 0, KEY_QUERY_VALUE,
00108                            &hkeySubKey);
00109
00110     if (lResult == ERROR_SUCCESS)
00111     {
00112         LONG lResultClose;
00113
00114         lResult = RegQueryValueEx(hkeySubKey, pcszValue, NULL, pdwValueType,
00115                                   pbyteBuf, pdwcbBufLen);
00116
00117         lResultClose = RegCloseKey(hkeySubKey);
00118
00119         if (lResult == ERROR_SUCCESS)
00120             lResult = lResultClose;
00121     }
00122
00123     return(lResult);
00124 }
00125
00126 //+---------------------------------------------------------------------------
00127 //
00128 //  Function:   GetRegKeyValue, private
00129 //
00130 //  Synopsis:   Internal utility function to add a named data value to an
00131 //              existing Key (with optional Subkey) in the system Registry
00132 //              under HKEY_CLASSES_ROOT.
00133 //
00134 //  Arguments:
00135 //
00136 //  Returns:
00137 //
00138 //  Modifies:
00139 //
00140 //----------------------------------------------------------------------------
00141
00142 BOOL AddRegNamedValue(
00143        LPTSTR pszKey,
00144        LPTSTR pszSubkey,
00145        LPTSTR pszValueName,
00146        LPTSTR pszValue)
00147 {
00148   BOOL bOk = FALSE;
00149   LONG ec;
00150   HKEY hKey;
00151   TCHAR szKey[MAX_STRING_LENGTH];
00152
00153   lstrcpy(szKey, pszKey);
00154
00155   if (NULL != pszSubkey)
00156   {
00157     lstrcat(szKey, TEXT("\\"));
00158     lstrcat(szKey, pszSubkey);
00159   }
00160
00161   ec = RegOpenKeyEx(
00162          HKEY_CLASSES_ROOT,
00163          szKey,
00164          0,
00165          KEY_READ | KEY_WRITE,
00166          &hKey);
00167
00168   if (NULL != pszValue && ERROR_SUCCESS == ec)
00169   {
00170     ec = RegSetValueEx(
00171            hKey,
00172            pszValueName,
00173            0,
00174            REG_SZ,
00175            (BYTE *)pszValue,
00176            (lstrlen(pszValue)+1)*sizeof(TCHAR));
00177     if (ERROR_SUCCESS == ec)
00178       bOk = TRUE;
00179     RegCloseKey(hKey);
00180   }
00181
00182   return bOk;
00183 }
00184
00185
00186 //+---------------------------------------------------------------------------
00187 //
00188 //  Function:   RegGetTimeStamp, private
00189 //
00190 //  Synopsis:   Reads in TimeStamp Value under the specified HKEY
00191 //
00192 //  Arguments:
00193 //
00194 //  Returns:
00195 //
00196 //  Modifies:
00197 //
00198 //----------------------------------------------------------------------------
00199
00200 BOOL RegGetTimeStamp(HKEY hKey, FILETIME *pft)
00201 {
00202 DWORD dwType;
00203 FILETIME ft;
00204 LONG lr;
00205 DWORD dwSize = sizeof(FILETIME);
00206
00207     Assert(pft);
00208
00209     lr = RegQueryValueEx( hKey,
00210                           HANDLERVALUE_FILETIME,
00211                           NULL,
00212                           &dwType,
00213                           (BYTE *)&ft,
00214                           &dwSize );
00215
00216
00217     if ( lr == ERROR_SUCCESS )
00218     {
00219         Assert( dwSize == sizeof(FILETIME) && dwType == REG_BINARY );
00220         *pft = ft;
00221     }
00222     else
00223     {
00224         // set the filetime to way back when to
00225         // any compares will just say older instead
00226         // of having to check success code
00227         (*pft).dwLowDateTime = 0;
00228         (*pft).dwHighDateTime = 0;
00229     }
00230
00231     return TRUE;
00232 }
00233
00234 //+---------------------------------------------------------------------------
00235 //
00236 //  Function:   RegWriteTimeStamp, private
00237 //
00238 //  Synopsis:   Writes out TimeStamp Value under the specified HKEY
00239 //
00240 //  Arguments:
00241 //
00242 //  Returns:
00243 //
00244 //  Modifies:
00245 //
00246 //----------------------------------------------------------------------------
00247
00248 BOOL RegWriteTimeStamp(HKEY hkey,FILETIME *pft)
00249 {
00250 LRESULT lr;
00251
00252     lr = RegSetValueEx( hkey,
00253             HANDLERVALUE_FILETIME,
00254             NULL,
00255             REG_BINARY,
00256             (BYTE *) pft,
00257             sizeof(FILETIME) );
00258
00259     return (ERROR_SUCCESS == lr) ? TRUE : FALSE;
00260 }
00261
00262 //+---------------------------------------------------------------------------
00263 //
00264 //  Function:   CreateHandlerPrefKey, private
00265 //
00266 //  Synopsis:   given a server clsid does work of openning up the
00267 //              handler perf key
00268 //
00269 //  Arguments:
00270 //
00271 //  Returns:
00272 //
00273 //  Modifies:
00274 //
00275 //----------------------------------------------------------------------------
00276
00277 HKEY CreateHandlerPrefKey(CLSID CLSIDServer)
00278 {
00279 TCHAR szFullKeyName[MAX_PATH];
00280 TCHAR szGUID[GUID_SIZE+1];
00281 LONG lResult = -1;
00282 HKEY hKey;
00283
00284 #ifdef _UNICODE
00285   StringFromGUID2(CLSIDServer, szGUID, GUID_SIZE);
00286 #else
00287   BOOL fUsedDefaultChar;
00288   WCHAR wszID[GUID_SIZE+1];
00289
00290   // convert clsidServer
00291   StringFromGUID2(CLSIDServer, wszID, GUID_SIZE);
00292
00293   WideCharToMultiByte(CP_ACP ,0,
00294     wszID,-1,szGUID,GUID_SIZE + 1,
00295     NULL,&fUsedDefaultChar);
00296
00297 #endif // _UNICODE
00298
00299   lstrcpy(szFullKeyName, TEXT("CLSID\\"));
00300   lstrcat(szFullKeyName, szGUID);
00301   lstrcat(szFullKeyName,HANDLERITEMSKEY);
00302
00303   // try to open handler items keyfs
00304   lResult = RegCreateKeyEx(
00305          HKEY_CLASSES_ROOT,
00306          szFullKeyName,
00307          0,NULL,REG_OPTION_NON_VOLATILE,
00308          KEY_READ | KEY_WRITE,NULL,
00309          &hKey,NULL);
00310
00311   return (ERROR_SUCCESS == lResult) ? hKey : NULL;
00312
00313 }
00314
00315 //+---------------------------------------------------------------------------
00316 //
00317 //  Function:   CreateHandlerItemPrefKey, private
00318 //
00319 //  Synopsis:   creates perf key for specified ItemID
00320 //
00321 //  Arguments:
00322 //
00323 //  Returns:
00324 //
00325 //  Modifies:
00326 //
00327 //----------------------------------------------------------------------------
00328
00329 HKEY CreateHandlerItemPrefKey(HKEY hkeyHandler,SYNCMGRITEMID ItemID)
00330 {
00331 TCHAR szGUID[GUID_SIZE+1];
00332 LONG lResult = -1;
00333 HKEY hKeyItem;
00334
00335  // try to open/create item key
00336     #ifdef _UNICODE
00337       StringFromGUID2(ItemID, szGUID, GUID_SIZE);
00338     #else
00339       BOOL fUsedDefaultChar;
00340       WCHAR wszID[GUID_SIZE+1];
00341
00342       // convert clsidServer
00343       StringFromGUID2(ItemID, wszID, GUID_SIZE);
00344
00345       WideCharToMultiByte(CP_ACP ,0,
00346         wszID,-1,szGUID,GUID_SIZE + 1,
00347         NULL,&fUsedDefaultChar);
00348
00349     #endif // _UNICODE
00350
00351   // try to open handler items keyfs
00352    lResult = RegCreateKeyEx(
00353          hkeyHandler,
00354          szGUID,
00355          0,NULL,REG_OPTION_NON_VOLATILE,
00356          KEY_READ | KEY_WRITE,NULL,
00357          &hKeyItem,NULL);
00358
00359   return (ERROR_SUCCESS == lResult) ? hKeyItem : NULL;
00360
00361 }
00362
00363
00364 //+---------------------------------------------------------------------------
00365 //
00366 //  Function:   CreateHandlerItemPrefKey, private
00367 //
00368 //  Synopsis:   creates perf key for specified ItemID
00369 //
00370 //  Arguments:
00371 //
00372 //  Returns:
00373 //
00374 //  Modifies:
00375 //
00376 //----------------------------------------------------------------------------
00377
00378 HKEY CreateHandlerItemPrefKey(CLSID CLSIDServer,SYNCMGRITEMID ItemID)
00379 {
00380 HKEY hKeyHandler;
00381 HKEY hKeyItem;
00382
00383   if (hKeyHandler = CreateHandlerPrefKey(CLSIDServer))
00384   {
00385       hKeyItem = CreateHandlerItemPrefKey(hKeyHandler,ItemID);
00386
00387       RegCloseKey(hKeyHandler); // close handler key.
00388   }
00389
00390   return hKeyItem;
00391
00392 }
00393
00394 //+---------------------------------------------------------------------------
00395 //
00396 //  Function:   Reg_GetItemSettingsForHandlerItem, public
00397 //
00398 //  Synopsis:   Returns settings for the specified Item.
00399 //
00400 //  Arguments:
00401 //
00402 //  Returns:
00403 //
00404 //  Modifies:
00405 //
00406 //----------------------------------------------------------------------------
00407
00408 STDMETHODIMP Reg_GetItemSettingsForHandlerItem(HKEY hKeyHandler,SYNCMGRITEMID ItemID,
00409                                          LPSAMPLEITEMSETTINGS pSampleItemSettings)
00410 {
00411 HKEY hKey;
00412 TCHAR *pDisplayName;
00413 DWORD dwType;
00414 DWORD dwSize;
00415
00416     hKey = CreateHandlerItemPrefKey(hKeyHandler,ItemID);
00417     if (!hKey)
00418     {
00419         Assert(hKey);
00420         return E_UNEXPECTED;
00421     }
00422
00423
00424     pSampleItemSettings->syncmgrItem.ItemID = ItemID;
00425
00426
00427    // write out our info.
00428     #ifdef _UNICODE
00429         pDisplayName = pSampleItemSettings->syncmgrItem.wszItemName;
00430     #else
00431       char szDisplayName[MAX_SYNCMGRITEMNAME];
00432
00433       pDisplayName = szDisplayName;
00434     #endif // _UNICODE
00435
00436     // read in the values,
00437     dwType = REG_SZ;
00438     dwSize = MAX_SYNCMGRITEMNAME*sizeof(TCHAR);
00439     RegQueryValueEx( hKey,
00440                           HANDLERVALUE_DISPLAYNAME,
00441                           NULL,
00442                           &dwType,
00443                           (BYTE *) pDisplayName,
00444                           &dwSize);
00445
00446     #ifndef _UNICODE
00447
00448       MultiByteToWideChar(CP_ACP, 0,
00449                             pDisplayName,-1,
00450                             pSampleItemSettings->syncmgrItem.wszItemName,
00451                            MAX_SYNCMGRITEMNAME);
00452
00453     #endif
00454
00455     dwType = REG_SZ;
00456     dwSize = MAX_PATH*sizeof(TCHAR);
00457     RegQueryValueEx( hKey,
00458                           HANDLERVALUE_DIR1,
00459                           NULL,
00460                           &dwType,
00461                           (BYTE *) pSampleItemSettings->dir1,
00462                           &dwSize);
00463     dwType = REG_SZ;
00464     dwSize = MAX_PATH*sizeof(TCHAR);
00465     RegQueryValueEx( hKey,
00466                           HANDLERVALUE_DIR2,
00467                           NULL,
00468                           &dwType,
00469                           (BYTE *) pSampleItemSettings->dir2,
00470                           &dwSize);
00471
00472     dwType = REG_DWORD;
00473     dwSize = sizeof(DWORD);
00474     RegQueryValueEx( hKey,
00475                           HANDLERVALUE_RECURSIVE,
00476                           NULL,
00477                           &dwType,
00478                           (BYTE *) &(pSampleItemSettings->fRecursive),
00479                           &dwSize);
00480
00481     RegGetTimeStamp(hKey,&(pSampleItemSettings->syncmgrItem.ftLastUpdate));
00482
00483
00484
00485     RegCloseKey(hKey);
00486
00487     return NOERROR;
00488 }
00489
00490
00491 //+---------------------------------------------------------------------------
00492 //
00493 //  Function:   Reg_SetItemSettingsForHandlerItem, public
00494 //
00495 //  Synopsis:   Writes out settings for a handler item.
00496 //
00497 //  Arguments:
00498 //
00499 //  Returns:
00500 //
00501 //  Modifies:
00502 //
00503 //----------------------------------------------------------------------------
00504
00505 STDMETHODIMP Reg_SetItemSettingsForHandlerItem(CLSID CLSIDServer,SYNCMGRITEMID ItemID,LPSAMPLEITEMSETTINGS pSampleItemSettings)
00506 {
00507 HKEY hKey;
00508 TCHAR *pDisplayName;
00509
00510     hKey = CreateHandlerItemPrefKey(CLSIDServer,ItemID);
00511     if (!hKey)
00512     {
00513         Assert(hKey);
00514         return E_UNEXPECTED;
00515     }
00516
00517    // write out our info.
00518     #ifdef _UNICODE
00519         pDisplayName = pSampleItemSettings->syncmgrItem.wszItemName;
00520     #else
00521       BOOL fUsedDefaultChar;
00522       char szDisplayName[MAX_SYNCMGRITEMNAME];
00523
00524       WideCharToMultiByte(CP_ACP ,0,
00525         pSampleItemSettings->syncmgrItem.wszItemName,-1,
00526             szDisplayName,MAX_SYNCMGRITEMNAME,
00527         NULL,&fUsedDefaultChar);
00528
00529       pDisplayName = szDisplayName;
00530     #endif // _UNICODE
00531
00532     RegSetValueEx(hKey,HANDLERVALUE_DISPLAYNAME,
00533            0,
00534            REG_SZ,
00535            (BYTE *) pDisplayName,
00536            (lstrlen(pDisplayName) + 1)*sizeof(TCHAR));
00537
00538
00539     RegSetValueEx(hKey,HANDLERVALUE_DIR1,
00540            0,
00541            REG_SZ,
00542            (BYTE *) pSampleItemSettings->dir1,
00543            (lstrlen(pSampleItemSettings->dir1) + 1)*sizeof(TCHAR));
00544
00545     RegSetValueEx(hKey,HANDLERVALUE_DIR2,
00546            0,
00547            REG_SZ,
00548            (BYTE *) pSampleItemSettings->dir2,
00549            (lstrlen(pSampleItemSettings->dir2) + 1)*sizeof(TCHAR));
00550
00551     RegSetValueEx(hKey,HANDLERVALUE_RECURSIVE,
00552            0,
00553            REG_DWORD,
00554            (BYTE *) &(pSampleItemSettings->fRecursive),
00555            sizeof(DWORD));
00556
00557     RegWriteTimeStamp(hKey,&(pSampleItemSettings->syncmgrItem.ftLastUpdate));
00558
00559     RegCloseKey(hKey);
00560
00561    return NOERROR;
00562 }
00563
00564 //+---------------------------------------------------------------------------
00565 //
00566 //  Function:   Reg_DeleteItemIdForHandlerItem, public
00567 //
00568 //  Synopsis:   Deletes an Items preferences from the registry..
00569 //
00570 //  Arguments:
00571 //
00572 //  Returns:
00573 //
00574 //  Modifies:
00575 //
00576 //----------------------------------------------------------------------------
00577
00578 STDMETHODIMP Reg_DeleteItemIdForHandlerItem(CLSID CLSIDServer,SYNCMGRITEMID ItemID)
00579 {
00580 HKEY hKeyHandler;
00581
00582     if (hKeyHandler = CreateHandlerPrefKey( CLSIDServer))
00583     {
00584     TCHAR szGUID[GUID_SIZE+1];
00585
00586         #ifdef _UNICODE
00587           StringFromGUID2(ItemID, szGUID, GUID_SIZE);
00588         #else
00589           BOOL fUsedDefaultChar;
00590           WCHAR wszID[GUID_SIZE+1];
00591
00592           // convert clsidServer
00593           StringFromGUID2(ItemID, wszID, GUID_SIZE);
00594
00595           WideCharToMultiByte(CP_ACP ,0,
00596             wszID,-1,szGUID,GUID_SIZE + 1,
00597             NULL,&fUsedDefaultChar);
00598
00599          #endif // _UNICODE
00600
00601         RegDeleteKey(hKeyHandler,szGUID);
00602
00603         RegCloseKey(hKeyHandler);
00604     }
00605
00606     return NOERROR;
00607 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/people.Cpp Source File

  • SysMgmt
  • MMC
  • CMenu

people.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include <stdio.h>
00021 #include "People.h"
00022
00023 const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00024
00025 const GUID CBicycleFolder::thisGuid = { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00026 const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00027 const GUID CIceSkateFolder::thisGuid = { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00028
00029 const GUID CBicycle::thisGuid = { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00030 const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00031 const GUID CIceSkate::thisGuid = { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
00032
00033
00034 //==============================================================
00035 //
00036 // CPeoplePoweredVehicle implementation
00037 //
00038 //
00039 CPeoplePoweredVehicle::CPeoplePoweredVehicle()
00040 {
00041     children[0] = new CBicycleFolder;
00042     children[1] = new CSkateboardFolder;
00043     children[2] = new CIceSkateFolder;
00044 }
00045
00046 CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
00047 {
00048     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00049         delete children[n];
00050 }
00051
00052 HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00053 {
00054     SCOPEDATAITEM sdi;
00055
00056     if (!bExpanded) {
00057         // create the child nodes, then expand them
00058         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00059             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00060             sdi.mask = SDI_STR       |   // Displayname is valid
00061                 SDI_PARAM     |   // lParam is valid
00062                 SDI_IMAGE     |   // nImage is valid
00063                 SDI_OPENIMAGE |   // nOpenImage is valid
00064                 SDI_PARENT    |   // relativeID is valid
00065                 SDI_CHILDREN;     // cChildren is valid
00066
00067             sdi.relativeID  = (HSCOPEITEM)parent;
00068             sdi.nImage      = children[n]->GetBitmapIndex();
00069             sdi.nOpenImage  = INDEX_OPENFOLDER;
00070             sdi.displayname = MMC_CALLBACK;
00071             sdi.lParam      = (LPARAM)children[n];       // The cookie
00072             sdi.cChildren   = 0;
00073
00074             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00075
00076             _ASSERT( SUCCEEDED(hr) );
00077         }
00078     }
00079
00080     return S_OK;
00081 }
00082
00083 CBicycleFolder::CBicycleFolder()
00084 {
00085     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00086         children[n] = new CBicycle(n + 1);
00087     }
00088 }
00089
00090 CBicycleFolder::~CBicycleFolder()
00091 {
00092     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00093         if (children[n]) {
00094             delete children[n];
00095         }
00096 }
00097
00098 HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00099 {
00100     HRESULT      hr = S_OK;
00101
00102     IHeaderCtrl *pHeaderCtrl = NULL;
00103     IResultData *pResultData = NULL;
00104
00105     if (bShow) {
00106         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00107         _ASSERT( SUCCEEDED(hr) );
00108
00109         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00110         _ASSERT( SUCCEEDED(hr) );
00111
00112         // Set the column headers in the results pane
00113         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00114         _ASSERT( S_OK == hr );
00115
00116         // insert items here
00117         RESULTDATAITEM rdi;
00118
00119         hr = pResultData->DeleteAllRsltItems();
00120         _ASSERT( SUCCEEDED(hr) );
00121
00122         if (!bExpanded) {
00123             // create the child nodes, then expand them
00124             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00125                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00126                 rdi.mask       = RDI_STR       |   // Displayname is valid
00127                     RDI_IMAGE     |
00128                     RDI_PARAM;        // nImage is valid
00129
00130                 rdi.nImage      = children[n]->GetBitmapIndex();
00131                 rdi.str         = MMC_CALLBACK;
00132                 rdi.nCol        = 0;
00133                 rdi.lParam      = (LPARAM)children[n];
00134
00135                 hr = pResultData->InsertItem( &rdi );
00136
00137                 _ASSERT( SUCCEEDED(hr) );
00138             }
00139         }
00140
00141         pHeaderCtrl->Release();
00142         pResultData->Release();
00143     }
00144
00145     return hr;
00146 }
00147
00148 CIceSkateFolder::CIceSkateFolder()
00149 {
00150     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00151         children[n] = new CIceSkate(n + 1);
00152     }
00153 }
00154
00155 CIceSkateFolder::~CIceSkateFolder()
00156 {
00157     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00158         if (children[n]) {
00159             delete children[n];
00160         }
00161 }
00162
00163 HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00164 {
00165     HRESULT      hr = S_OK;
00166
00167     IHeaderCtrl *pHeaderCtrl = NULL;
00168     IResultData *pResultData = NULL;
00169
00170     if (bShow) {
00171         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00172         _ASSERT( SUCCEEDED(hr) );
00173
00174         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00175         _ASSERT( SUCCEEDED(hr) );
00176
00177         // Set the column headers in the results pane
00178         hr = pHeaderCtrl->InsertColumn( 0, L"Name                ", 0, MMCLV_AUTO );
00179         _ASSERT( S_OK == hr );
00180
00181         // insert items here
00182         RESULTDATAITEM rdi;
00183
00184         hr = pResultData->DeleteAllRsltItems();
00185         _ASSERT( SUCCEEDED(hr) );
00186
00187         if (!bExpanded) {
00188             // create the child nodes, then expand them
00189             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00190                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00191                 rdi.mask       = RDI_STR       |   // Displayname is valid
00192                     RDI_IMAGE     |
00193                     RDI_PARAM;        // nImage is valid
00194
00195                 rdi.nImage      = children[n]->GetBitmapIndex();
00196                 rdi.str         = MMC_CALLBACK;
00197                 rdi.nCol        = 0;
00198                 rdi.lParam      = (LPARAM)children[n];
00199
00200                 hr = pResultData->InsertItem( &rdi );
00201
00202                 _ASSERT( SUCCEEDED(hr) );
00203             }
00204         }
00205
00206         pHeaderCtrl->Release();
00207         pResultData->Release();
00208     }
00209
00210     return hr;
00211 }
00212
00213 CSkateboardFolder::CSkateboardFolder()
00214 {
00215     for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00216         children[n] = new CSkateboard(n + 1);
00217     }
00218 }
00219
00220 CSkateboardFolder::~CSkateboardFolder()
00221 {
00222     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00223         if (children[n]) {
00224             delete children[n];
00225         }
00226 }
00227
00228 HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
00229 {
00230     HRESULT      hr = S_OK;
00231
00232     IHeaderCtrl *pHeaderCtrl = NULL;
00233     IResultData *pResultData = NULL;
00234
00235     if (bShow) {
00236         hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
00237         _ASSERT( SUCCEEDED(hr) );
00238
00239         hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00240         _ASSERT( SUCCEEDED(hr) );
00241
00242         // Set the column headers in the results pane
00243         hr = pHeaderCtrl->InsertColumn( 0, L"Name                      ", 0, MMCLV_AUTO );
00244         _ASSERT( S_OK == hr );
00245
00246         // insert items here
00247         RESULTDATAITEM rdi;
00248
00249         hr = pResultData->DeleteAllRsltItems();
00250         _ASSERT( SUCCEEDED(hr) );
00251
00252         if (!bExpanded) {
00253             // create the child nodes, then expand them
00254             for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00255                 ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00256                 rdi.mask       = RDI_STR       |   // Displayname is valid
00257                     RDI_IMAGE     |
00258                     RDI_PARAM;        // nImage is valid
00259
00260                 rdi.nImage      = children[n]->GetBitmapIndex();
00261                 rdi.str         = MMC_CALLBACK;
00262                 rdi.nCol        = 0;
00263                 rdi.lParam      = (LPARAM)children[n];
00264
00265                 hr = pResultData->InsertItem( &rdi );
00266
00267                 _ASSERT( SUCCEEDED(hr) );
00268             }
00269         }
00270
00271         pHeaderCtrl->Release();
00272         pResultData->Release();
00273     }
00274
00275     return hr;
00276 }
00277
00278 const _TCHAR *CBicycle::GetDisplayName(int nCol)
00279 {
00280     static _TCHAR buf[128];
00281
00282     _stprintf(buf, _T("Bicycle #%d"), id);
00283
00284     return buf;
00285 }
00286
00287 const _TCHAR *CSkateboard::GetDisplayName(int nCol)
00288 {
00289     static _TCHAR buf[128];
00290
00291     _stprintf(buf, _T("Skateboard #%d"), id);
00292
00293     return buf;
00294 }
00295
00296 const _TCHAR *CIceSkate::GetDisplayName(int nCol)
00297 {
00298     static _TCHAR buf[128];
00299
00300     _stprintf(buf, _T("Ice Skate #%d"), id);
00301
00302     return buf;
00303 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

qcnotify::INotifyDefault Member List

This is the complete list of members for qcnotify::INotifyDefault, including all inherited members.
iid | qcnotify::INotifyDefault | [static]
LineItem(int lItemId, int lQuantity, int ShipStatus) | qcnotify::INotifyDefault |
Process(int lFlags) | qcnotify::INotifyDefault |
setCustomerId(int _jcomparam_0) | qcnotify::INotifyDefault |
setOrderId(int _jcomparam_0) | qcnotify::INotifyDefault |
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFilesTest/Resource.h Source File

  • Com
  • Services
  • Crm
  • CrmFilesTest

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by CrmFilesTest.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_CRMFILESTEST                101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/server/rqsengine.h Source File

  • NetDS
  • RRas
  • rqs
  • server

rqsengine.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       RqsEngine.h
00004 //
00005 //      Synopsis:   Engine that drives the server-side ras quarantine removal
00006 //                  utility.
00007 //
00008 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00009 //
00010 //+--------------------------------------------------------------------------
00011
00012 #pragma once
00013
00014 class ClientList;
00015 class RqsClient;
00016
00017 typedef
00018 DWORD
00019 (APIENTRY *RqsRemoveQuarantineFunc)(HANDLE, HANDLE, BOOL);
00020
00021 //+--------------------------------------------------------------------------
00022 //
00023 // Synopsis: Types of events that occur to the Engine
00024 //
00025 //+--------------------------------------------------------------------------
00026 enum RqsEvent
00027 {
00028     Connect,
00029     Read,
00030     UpdateConfig,
00031     UpdateTrace,
00032     Quit,
00033     ConfigServerSocket,
00034     Error
00035 };
00036
00037 //+--------------------------------------------------------------------------
00038 //
00039 // Synopsis: The engine that drives the whole system
00040 //
00041 //+--------------------------------------------------------------------------
00042 class RqsEngine
00043 {
00044 public:
00045     // Construction/destruction
00046     //
00047     RqsEngine();
00048     ~RqsEngine();
00049     HRESULT Initialize();
00050
00051     // Execution
00052     //
00053     HRESULT Execute();
00054     VOID Stop() {m_eQuit.Set();}
00055
00056     // Client control
00057     //
00058     HRESULT ClientAdd(IN RqsClient* pClient);
00059     VOID ClientRemove();
00060     HRESULT ClientReadMessages();
00061     BOOL ClientAuthenticate(IN CHAR* pszString);
00062     HRESULT ClientClearQuarantine(IN DWORD dwAddress, IN CONST CHAR* pszAddress, IN CONST CHAR* pszUsername);
00063     VOID ClientLogInfo(IN DWORD dwEvent, IN CONST CHAR* pszIp, IN CONST CHAR* pszUsername, IN CONST CHAR* pszString);
00064
00065     // Service management
00066     //
00067     VOID SetServiceHandle(SERVICE_STATUS_HANDLE hService) {m_hService = hService;}
00068     SERVICE_STATUS_HANDLE GetServiceHandle() {return m_hService;}
00069     DWORD GetCheckpoint() {return m_dwCheckPoint;}
00070     HRESULT ConnectRRAS(IN OPTIONAL DWORD dwRetries = 0);
00071
00072     // Tracing
00073     //
00074     VOID Trace(IN LPSTR pszTrace, IN ...) const;
00075     VOID TraceSelf();
00076     VOID SetConsoleTracing(IN BOOL fConsole) {m_fConsoleTrace = fConsole;};
00077
00078 private:
00079     RqsConfig m_Config;
00080     RuServerSocket m_sServer;
00081     RcuEvent m_eSocketAccept;
00082     RcuEvent m_eSocketRead;
00083     RcuEvent m_eQuit;
00084     RcuEvent m_eConfig;
00085     RcuEvent m_eTrace;
00086     RcuEvent m_eInterfaceAdded;
00087     RcuRwLock m_rwlConfig;
00088     volatile LONG m_ulClientCount;
00089     SERVICE_STATUS_HANDLE m_hService;
00090     DWORD m_dwCheckPoint;
00091     HINSTANCE m_hInstMprApi;
00092     HANDLE m_hServer;
00093     RqsRemoveQuarantineFunc m_qFunc;
00094     BOOL m_fRtTrace;
00095     DWORD m_dwTraceId;
00096     BOOL m_fConsoleTrace;
00097     BOOL m_fDebugTrace;
00098     HKEY m_hkTrace;
00099     HKEY m_hkConfig;
00100     HANDLE m_hLog;
00101     RcuCritSec m_csClientsLock;
00102     ClientList m_lClients;
00103     BOOL m_bRegisteredForConnectionNotification;
00104     CHAR m_szInternalAddress [16];
00105
00106     HRESULT InitializeEvents();
00107
00108     VOID Clear();
00109     HRESULT Wait(OUT RqsEvent* pAction);
00110     HRESULT ScheduleWork(LPTHREAD_START_ROUTINE pFunc, RqsClient* pClient = NULL);
00111     HRESULT ClientConnect();
00112     static DWORD WINAPI ClientConnectCb(IN LPVOID pvContext);
00113     static DWORD WINAPI ClientReadCb(IN LPVOID pvContext);
00114     static DWORD WINAPI ClientCompleteCb(IN LPVOID pvContext);
00115     static DWORD WINAPI InitializeServerSocketCb(IN LPVOID pvContext);
00116
00117     HRESULT ReloadConfig();
00118     HRESULT ReloadTrace();
00119     void TraceCurrentServerConnections();
00120     WORD GetEventType(DWORD dwEventId);
00121     HRESULT GetInternalIpAddress(OUT CHAR* pszIpAddress, IN DWORD dwCount);
00122     DWORD GetIpAddressFromInterfaceName(IN CONST WCHAR* pwszInterfaceName, OUT CHAR* pszIpAddress, IN DWORD dwCount);
00123     DWORD GetIpAddressFromInterfaceIndex(IN DWORD dwInterfaceId, OUT CHAR* pszIpAddress, IN DWORD dwCount);
00124     HRESULT InitializeServerSocket();
00125     HRESULT RegisterForConnectionNotification();
00126     HRESULT DeregisterForConnectionNotification();
00127 };
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/headers.h Source File

  • Dataaccess
  • oledb
  • sampprov

headers.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module HEADERS.H | Precompiled headers
00008 //
00009 #ifndef _HEADERS_H_
00010 #define _HEADERS_H_
00011
00012
00013
00014 //  Don't include everything from windows.h, but always bring in OLE 2 support
00015 #ifndef WIN32_LEAN_AND_MEAN
00016 #define WIN32_LEAN_AND_MEAN
00017 #endif
00018
00019 #define INC_OLE2
00020
00021 #define STRICT          //Strict type checking for Window APIs
00022
00023 // Basic Windows and OLE everything
00024 #include <windows.h>
00025 #include <windowsx.h>
00026 #include <limits.h>
00027 #include <stdio.h>        // vsnprintf, etc.
00028 #include <stddef.h>       // offsetof, etc.
00029 #include <wchar.h>        // swprintf
00030 #include <commdlg.h>      // GetOpenFileName
00031
00032 //  OLE DB headers
00033 #include "oledb.h"
00034 #include "oledberr.h"
00035
00036 //  Data conversion library header
00037 #include "msdadc.h"
00038
00039 // MSDASQL Guids (for conversion library guid)
00040 #include "msdaguid.h"
00041
00042
00043 //  Sample Provider -specific general headers
00044 #include "sampprov.h"
00045 #include "asserts.h"
00046 #include "utilprop.h"
00047
00048 // GUIDs
00049 #include "guids.h"
00050 #include "resource.h"
00051
00052 //  CDataSource object and contained interface objects
00053 #include "datasrc.h"
00054
00055 // CDBSession object and contained interface objects
00056 #include "dbsess.h"
00057
00058 //  CRowset object and contained interface objects
00059 #include "rowset.h"
00060
00061 //  CCommand object and contained interface objects
00062 #include "command.h"
00063
00064 //  CImpIAccessor implementation
00065 #include "accessor.h"
00066
00067 //  CBinder object and contained interface objects
00068 #include "binder.h"
00069
00070 //  CRow object and contained interface objects
00071 #include "row.h"
00072
00073 //  CStream object and contained interface objects
00074 #include "stream.h"
00075
00076 //  General utility functions
00077 #include "common.h"
00078
00079 #endif
00080
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Accept/SockInfo.cpp Source File

  • NetDS
  • WinSock
  • Accept

SockInfo.cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 2002  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: SockInfo.cpp
00009 //
00010 // Description:
00011 //             This file contains the functions for allocating and freeing
00012 // the SOCK_INFO structures and for adding and deleting these structures from
00013 // the global list.
00014
00015 #include "common.h"
00016
00017 /*
00018     This function allocates a SOCK_INFO structure on the heap and
00019     initializes the contents with suitable initial values and returns
00020     the allocated memory.
00021 */
00022 PSOCK_INFO AllocAndInitSockInfo()
00023 {
00024     PSOCK_INFO pNewSockInfo;
00025
00026     // allocate a new structure. this should be freed by calling FreeSockInfo
00027     // by the caller of this function.
00028     pNewSockInfo = (PSOCK_INFO) malloc(sizeof(SOCK_INFO));
00029     if (pNewSockInfo == NULL)
00030     {
00031         printf("AllocAndInitSockInfo: malloc returned NULL.\n");
00032         goto CLEANUP;
00033     }
00034
00035     printf("Allocated SockInfo at %p\n", pNewSockInfo);
00036
00037     // Initialize the SOCK_INFO structure with the suitable initial values
00038     // for each field.
00039     memset(pNewSockInfo,0,sizeof(SOCK_INFO));
00040     pNewSockInfo->sock = INVALID_SOCKET;
00041
00042 CLEANUP:
00043     return pNewSockInfo;
00044 }
00045
00046
00047 /*
00048     This function frees the SOCK_INFO structure allocated by
00049     AllocAndInitSockInfo.
00050 */
00051 void FreeSockInfo(PSOCK_INFO pSockInfo)
00052 {
00053     // free the SOCK_INFO structure allocated earlier by AllocAndInitSockInfo
00054     free(pSockInfo);
00055     printf("Freed SockInfo at %p\n", pSockInfo);
00056     return;
00057 }
00058
00059 /*
00060     This function adds a given sockinfo structure to head of the given list.
00061 */
00062 void AddSockInfoToList(PSOCK_INFO *ppHead, PSOCK_INFO pNewSockInfo)
00063 {
00064     // add the new sock info at the head, for sake of simiplicity as we
00065     // don't care about the order of these structures.
00066
00067     // this is going to be the first node.
00068     pNewSockInfo->prev = NULL;
00069
00070     // the earlier list follows this node.
00071     pNewSockInfo->next = *ppHead;
00072
00073     // this node is the previous node for the earlier head node.
00074     if (*ppHead != NULL)
00075         (*ppHead)->prev = pNewSockInfo;
00076
00077     // the new head is this new node, as we inserted at the head.
00078     *ppHead = pNewSockInfo;
00079
00080     printf("Added SockInfo %p to list\n", pNewSockInfo);
00081     return;
00082 }
00083
00084 /*
00085     This function removes a given sockinfo structure from the given list
00086     and frees the memory also.
00087 */
00088 void DeleteSockInfoFromList(PSOCK_INFO *ppHead, PSOCK_INFO pDelSockInfo)
00089 {
00090     // make the previous and the next nodes to point to each other,
00091     // insteade of pointing to pDelSockInfo.
00092     if (pDelSockInfo->prev != NULL)
00093         pDelSockInfo->prev->next = pDelSockInfo->next;
00094     if (pDelSockInfo->next != NULL)
00095         pDelSockInfo->next->prev = pDelSockInfo->prev;
00096
00097     // if the head node is being deleted, make the next node as the head.
00098     if (*ppHead == pDelSockInfo)
00099         *ppHead = pDelSockInfo->next;
00100
00101     // now, pDelSockInfo can be safely deleted as nobody points to it.
00102     FreeSockInfo(pDelSockInfo);
00103
00104     printf("Deleted and freed SockInfo %p\n", pDelSockInfo);
00105     return;
00106 }
00107
00108
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPropPro Member List

This is the complete list of members for CPropPro, including all inherited members.
CPropPro() | CPropPro |
GetProperty(long lFlags, const BSTR Locale, const BSTR ClassMapping, const BSTR InstMapping, const BSTR PropMapping, VARIANT *pvValue) | CPropPro | [virtual]
m_cRef | CPropPro | [protected]
PutProperty(long lFlags, const BSTR Locale, const BSTR ClassMapping, const BSTR InstMapping, const BSTR PropMapping, const VARIANT __RPC_FAR *pvValue) | CPropPro | [virtual]
QueryInterface(REFIID, PPVOID) | CPropPro |
STDMETHODIMP_(ULONG) AddRef(void) | CPropPro |
STDMETHODIMP_(ULONG) Release(void) | CPropPro |
~CPropPro(void) | CPropPro |
Generated on Wed Nov 13 2024 16:57:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/Factory.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

Factory.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.H
00003
00004   Summary:   Include file for the class factory COM object: CFTextPage.
00005              This constitutes the PERTEXT server's class factory for the
00006              TextPage COM component.
00007
00008              The multiple interface COM Object Class is achieved via the
00009              technique of nested classes: the implementation of the
00010              standard IClassFactory interface is nested inside of the
00011              class factory COM object class. APPUTIL's CThreaded OwnThis
00012              mechanism is used to ensure mutually exclusive access to the
00013              class factory by contending multiple threads.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial PERTEXT.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   CFTextPage.
00022
00023   Functions: .
00024
00025   Origin:    5-20-97: atrent - Editor-inheritance from FACTORY.H in
00026                the STOSERVE Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 #if !defined(FACTORY_H)
00044 #define FACTORY_H
00045
00046 #ifdef __cplusplus
00047
00048 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00049   ObjectClass: CFTextPage
00050
00051   Summary:     Class Factory COM Object Class for TextPage COM components.
00052                Used to manufacture COTextPage COM objects.  The mulitple
00053                interfaces on this COM object class are constructed via the
00054                nested interface classes technique.
00055
00056   Interfaces:  IUnknown
00057                  Standard interface providing COM object features.
00058                IClassFactory
00059                  Standard interface providing COM Class Factory features.
00060
00061   Aggregation: Yes, CFTextPage COM objects are aggregatable by
00062                passing a non-NULL pUnkOuter IUnknown pointer into the
00063                constructor.
00064 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00065 class CFTextPage : public IUnknown, public CThreaded
00066 {
00067   public:
00068     // Main Object Constructor & Destructor.
00069     CFTextPage(IUnknown* pUnkOuter, CServer* pServer);
00070     ~CFTextPage(void);
00071
00072     // IUnknown methods. Main object, non-delegating.
00073     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00074     STDMETHODIMP_(ULONG) AddRef(void);
00075     STDMETHODIMP_(ULONG) Release(void);
00076
00077     // We declare nested class interface implementations here.
00078
00079     // We implement the IClassFactory interface in this class
00080     // factory COM object class. Derive also from abstract CThreaded
00081     // to provide the OwnThis/UnownThis thread-safety mechanism.
00082     class CImpIClassFactory : public IClassFactory, public CThreaded
00083     {
00084       public:
00085         // Interface Implementation Constructor & Destructor.
00086         CImpIClassFactory(
00087           CFTextPage* pCO,
00088           IUnknown* pUnkOuter,
00089           CServer* pServer);
00090         ~CImpIClassFactory(void);
00091
00092         // IUnknown methods.
00093         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00094         STDMETHODIMP_(ULONG) AddRef(void);
00095         STDMETHODIMP_(ULONG) Release(void);
00096
00097         // IClassFactory methods.
00098         STDMETHODIMP         CreateInstance(IUnknown*, REFIID, PPVOID);
00099         STDMETHODIMP         LockServer(BOOL);
00100
00101       private:
00102         // Data private to this interface implementation of IClassFactory.
00103         CFTextPage*   m_pCO;         // Parent Object back pointer.
00104         IUnknown*     m_pUnkOuter;   // Outer unknown for Delegation.
00105         CServer*      m_pServer;     // Server's control object.
00106     };
00107
00108     // Make the otherwise private and nested IClassFactory interface
00109     // implementation a friend to COM object instantiations of this
00110     // CFTextPage COM object class.
00111     friend CImpIClassFactory;
00112
00113   private:
00114     // Private data of CFTextPage COM objects.
00115
00116     // Nested IClassFactory implementation instantiation.
00117     CImpIClassFactory m_ImpIClassFactory;
00118
00119     // Main Object reference count.
00120     ULONG             m_cRefs;
00121
00122     // Outer unknown (aggregation & delegation). Used when this
00123     // CFTextPage object is being aggregated.  Otherwise it is used
00124     // for delegation if this object is reused via containment.
00125     IUnknown*         m_pUnkOuter;
00126
00127     // Pointer to this component server's control object.
00128     CServer*          m_pServer;
00129 };
00130
00131
00132 #endif // __cplusplus
00133
00134
00135 #endif // FACTORY_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CException Member List

This is the complete list of members for CException, including all inherited members.
_dbgInfo | CException | [protected]
_lError | CException | [protected]
CException(long lError) | CException | [inline]
GetErrorCode() | CException | [inline]
GetInfo(void) const | CException | [inline]
SetInfo(unsigned dbgInfo) | CException | [inline]
Generated on Wed Nov 13 2024 16:56:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/entity.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

entity.h

Go to the documentation of this file.
00001
00002 // Static.h : Declaration of the CEntity
00003
00004 #ifndef __STATIC_H_
00005 #define __STATIC_H_
00006
00007 #include "resource.h"       // main symbols
00008
00009 /////////////////////////////////////////////////////////////////////////////
00010 // CEntity
00011 class ATL_NO_VTABLE CEntity :
00012   public CComObjectRootEx<CComMultiThreadModel>,
00013   public CComCoClass<CEntity, &CLSID_Entity>,
00014   public ISupportErrorInfo,
00015   public IPersistStreamInit,
00016   public IMarshal,
00017   public IPersistStream,
00018   public IDispatchImpl<IEntityData, &IID_IEntityData, &LIBID_DataServices>,
00019   public IDispatchImpl<IEntity, &IID_IEntity, &LIBID_DataServices>
00020 {
00021   DECLARE_FIXED_ALLOC(CEntity);
00022
00023 public:
00024   CEntity()
00025   {
00026     Clear();
00027   }
00028
00029   ~CEntity()
00030   {
00031     ClearArrays();
00032   }
00033
00034 DECLARE_REGISTRY_RESOURCEID(IDR_ENTITY)
00035
00036 BEGIN_COM_MAP(CEntity)
00037   COM_INTERFACE_ENTRY(IEntity)
00038   COM_INTERFACE_ENTRY(IEntityData)
00039   COM_INTERFACE_ENTRY2(IDispatch, IEntity)
00040   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00041   COM_INTERFACE_ENTRY(IMarshal)
00042   COM_INTERFACE_ENTRY(IPersistStreamInit)
00043   COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
00044   COM_INTERFACE_ENTRY(IPersistStream)
00045 END_COM_MAP()
00046
00047 // ISupportsErrorInfo
00048   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00049
00050 // IEntity
00051 public:
00052   STDMETHOD(put_Recordset)(/*[in]*/ _Recordset* newVal);
00053   STDMETHOD(get_ReadCommand)(/*[out, retval]*/ BSTR *pVal);
00054   STDMETHOD(get_KeyField)(/*[out, retval]*/ BSTR *pVal);
00055   STDMETHOD(put_KeyField)(/*[in]*/ BSTR newVal);
00056   STDMETHOD(get_UpdateCommand)(/*[out, retval]*/ BSTR *pVal);
00057   STDMETHOD(get_ReadStoredProcedure)(/*[out, retval]*/ BSTR *pVal);
00058   STDMETHOD(put_ReadStoredProcedure)(/*[in]*/ BSTR newVal);
00059   STDMETHOD(get_UpdateStoredProcedure)(/*[out, retval]*/ BSTR *pVal);
00060   STDMETHOD(put_UpdateStoredProcedure)(/*[in]*/ BSTR newVal);
00061   STDMETHOD(get_InsertCommand)(/*[out, retval]*/ BSTR *pVal);
00062   STDMETHOD(get_InsertStoredProcedure)(/*[out, retval]*/ BSTR *pVal);
00063   STDMETHOD(put_InsertStoredProcedure)(/*[in]*/ BSTR newVal);
00064   STDMETHOD(get_DeleteCommand)(/*[out, retval]*/ BSTR *pVal);
00065   STDMETHOD(get_DeleteStoredProcedure)(/*[out, retval]*/ BSTR *pVal);
00066   STDMETHOD(put_DeleteStoredProcedure)(/*[in]*/ BSTR newVal);
00067   STDMETHOD(get_Field)(VARIANT *Index, /*[out, retval]*/ VARIANT *pVal);
00068   STDMETHOD(put_Field)(VARIANT *Index, /*[in]*/ VARIANT *newVal);
00069   STDMETHOD(get_EditMode)(/*[out, retval]*/ ColEditModeEnum *pVal);
00070   STDMETHOD(put_EditMode)(/*[in]*/ ColEditModeEnum newVal);
00071   STDMETHOD(get_Key)(long Index, /*[out, retval]*/ BSTR *pVal);
00072   STDMETHOD(put_Key)(long Index, /*[in]*/ BSTR newVal);
00073   STDMETHOD(Insert)(long Index, BSTR Key, VARIANT *Value);
00074   STDMETHOD(Initialize)(long Size);
00075   STDMETHOD(_NewEnum)(/*[out, retval]*/ LPUNKNOWN *pVal);
00076   STDMETHOD(Item)(VARIANT *pIndex, /*[out, retval]*/ VARIANT *pVal);
00077   STDMETHOD(Count)(/*[out, retval]*/ long *pVal);
00078   STDMETHOD(Add)(VARIANT *pItem, VARIANT *pKey = &vtMissing, VARIANT *pBefore = &vtMissing, VARIANT *pAfter = &vtMissing);
00079   STDMETHOD(Remove)(VARIANT *pIndex);
00080   STDMETHOD(Append)(VARIANT *pItem, VARIANT *pKey);
00081 // IMarshal
00082 // IMarshal (Actually we delegate to IPersistStream's implementation here)
00083   STDMETHOD(GetUnmarshalClass) (REFIID riid, void * pv, DWORD dwDestContext, void * pvDestContext, DWORD mshlFlags, CLSID* pCid )
00084   {
00085     *pCid = GetObjectCLSID();
00086     return S_OK;
00087   }
00088
00089   unsigned long GetPersistSize(bool bWithMetaData = true)
00090   {
00091     _ULARGE_INTEGER ul;
00092     HRESULT hr;
00093
00094     ul.LowPart = 0;
00095     ul.HighPart = 0;
00096     hr = GetPersistSizeMax(&ul, bWithMetaData);
00097
00098     if (SUCCEEDED(hr))
00099       return ul.LowPart;
00100     else
00101       return 0;
00102   }
00103
00104   STDMETHOD(GetMarshalSizeMax) (REFIID riid, void * pv, DWORD dwDestContext, void * pvDestContext, DWORD mshlFlags, ULONG* pSize )
00105   {
00106     _ULARGE_INTEGER ul;
00107     HRESULT hr;
00108
00109     ul.LowPart = 0;
00110     ul.HighPart = 0;
00111     hr = GetSizeMax(&ul);
00112
00113     if (SUCCEEDED(hr))
00114       *pSize = ul.LowPart;
00115
00116     return hr;
00117   }
00118
00119   STDMETHOD(MarshalInterface)  (IStream* pStm, REFIID riid, void *pv, DWORD dwDestContext, void * pvDestContext, DWORD mshlFlags)
00120   {
00121     return Save(pStm, FALSE);
00122   }
00123
00124   STDMETHOD(UnmarshalInterface)(IStream* pStm, REFIID riid, void ** ppv )
00125   {
00126     HRESULT hr = Load(pStm);
00127
00128     if (SUCCEEDED(hr))
00129     {
00130       hr = QueryInterface(riid, ppv);
00131     }
00132     return hr;
00133   }
00134
00135   STDMETHOD (ReleaseMarshalData)(IStream *pStm)
00136   {
00137     // Nothing to do
00138     return E_NOTIMPL;
00139   }
00140
00141     STDMETHOD (DisconnectObject)( DWORD dwReserved)
00142   {
00143     // Proxy and Object are not connected -- nothing to do
00144     return E_NOTIMPL;
00145   }
00146
00147 // IPersistStreamInit
00148 // IPersistStream
00149 // IPersist
00150   STDMETHOD(GetClassID)(GUID * pClassID)
00151   {
00152     if (pClassID == NULL)
00153       return E_POINTER;
00154
00155     *pClassID = GetObjectCLSID();
00156
00157     return S_OK;
00158   }
00159
00160   STDMETHOD(IsDirty)()
00161   {
00162     HRESULT hr = S_FALSE;
00163
00164     if (m_bRequiresSave)
00165     {
00166       hr = S_OK;
00167     }
00168     return hr;
00169   }
00170
00171   HRESULT LoadFromStream(IStream * pStm, bool bWithMetaData = true)
00172   {
00173     long nSize = 0,  n = 0, nVer = 0;
00174     HRESULT hr = S_OK;
00175
00176     *pStm >> (long)nVer; // version
00177
00178     if (nVer < ARRAY_VERSION)
00179       return STG_E_OLDFORMAT;
00180
00181     *pStm >> m_nMaxCount; // count
00182
00183     Initialize(m_nMaxCount);
00184
00185     *pStm >> m_bRequiresSave; // count
00186     *pStm >> m_EditMode; // count
00187
00188     if (bWithMetaData)
00189     {
00190       *pStm >> m_wszUpdateStoredProc;
00191       *pStm >> m_wszReadStoredProc;
00192       *pStm >> m_wszDeleteStoredProc;
00193       *pStm >> m_wszInsertStoredProc;
00194       *pStm >> m_wszKeyField;
00195     }
00196
00197     for (n = 0; (n < m_nMaxCount && SUCCEEDED(hr)); n++)
00198     {
00199       if (bWithMetaData)
00200         *pStm >> m_keyMap.m_aKey[n];
00201       *pStm >> (VARTYPE)m_Type[n];
00202       hr = m_pContents[n].ReadFromStream(pStm);
00203     }
00204     m_keyMap.m_nSize = m_nMaxCount;
00205     return hr;
00206   }
00207
00208   STDMETHOD(Load)(IStream * pStm)
00209   {
00210     return LoadFromStream(pStm, true);;
00211   }
00212
00213   STDMETHOD(Save)(IStream * pStm, int fClearDirty)
00214   {
00215     return SaveToStream(pStm, fClearDirty, true);
00216   }
00217
00218   HRESULT SaveToStream(IStream * pStm, int fClearDirty, bool bWithMetaData = true)
00219   {
00220     long nSize = 0, n = 0;
00221     HRESULT hr = S_OK;
00222
00223     *pStm << (long)ARRAY_VERSION; // version
00224     *pStm << m_nMaxCount; // count
00225     *pStm << m_bRequiresSave; // save
00226     *pStm << m_EditMode; // edit
00227
00228     if (bWithMetaData)
00229     {
00230       *pStm << (LPCWSTR)m_wszUpdateStoredProc;
00231       *pStm << (LPCWSTR)m_wszReadStoredProc;
00232       *pStm << (LPCWSTR)m_wszDeleteStoredProc;
00233       *pStm << (LPCWSTR)m_wszInsertStoredProc;
00234       *pStm << (LPCWSTR)m_wszKeyField;
00235     }
00236
00237     for (n = 0; (n < m_nMaxCount && SUCCEEDED(hr)); n++)
00238     {
00239       if (bWithMetaData)
00240         *pStm << (LPCWSTR)m_keyMap.m_aKey[n];
00241       *pStm << (VARTYPE)m_Type[n];
00242       m_pContents[n].WriteToStream(pStm);
00243     }
00244
00245     if (fClearDirty)
00246       m_bRequiresSave = false;
00247
00248     return hr;
00249   }
00250
00251   STDMETHOD(GetSizeMax)(_ULARGE_INTEGER * pCbSize)
00252   {
00253     return GetPersistSizeMax(pCbSize, true);
00254   }
00255
00256   HRESULT GetPersistSizeMax(_ULARGE_INTEGER * pCbSize, bool bWithMetaData = true)
00257   {
00258     if (pCbSize == NULL)
00259       return E_POINTER;
00260
00261     long nSize = 0, n = 0;
00262     HRESULT hr = S_OK;
00263
00264     CFastVariant update((LPCWSTR)m_wszUpdateStoredProc);
00265     CFastVariant read((LPCWSTR)m_wszReadStoredProc);
00266     CFastVariant insert((LPCWSTR)m_wszInsertStoredProc);
00267     CFastVariant deletesp((LPCWSTR)m_wszDeleteStoredProc);
00268     CFastVariant key((LPCWSTR)m_wszKeyField);
00269
00270     nSize += sizeof((long)ARRAY_VERSION); // version
00271     nSize += sizeof(m_nMaxCount); // count
00272     nSize += sizeof(m_bRequiresSave); // save
00273     nSize += sizeof(m_EditMode); // edit
00274
00275     nSize += GetVariantSize(update);
00276     nSize += GetVariantSize(insert);
00277     nSize += GetVariantSize(deletesp);
00278     nSize += GetVariantSize(read);
00279     nSize += GetVariantSize(key);
00280
00281     for (n = 0; n < m_nMaxCount; n++)
00282     {
00283       if (bWithMetaData)
00284       {
00285         CFastVariant vKey((LPCWSTR)m_keyMap.m_aKey[n]);
00286
00287         nSize += GetVariantSize(vKey);
00288       }
00289       nSize += sizeof(long); // edit
00290       nSize += GetVariantSize(m_pContents[n]);
00291     }
00292     pCbSize->LowPart = nSize;
00293     return hr;
00294   }
00295
00296   STDMETHOD(InitNew)()
00297   {
00298     HRESULT hr = S_OK;
00299
00300     Clear();
00301
00302     return hr;
00303   }
00304 // Data:
00305
00306   CString m_wszUpdateStoredProc;
00307   CString m_wszReadStoredProc;
00308   CString m_wszDeleteStoredProc;
00309   CString m_wszInsertStoredProc;
00310   CString m_wszKeyField;
00311
00312   CStaticMap m_keyMap;
00313   CFastVariant* m_pContents;
00314   VARTYPE* m_Type;
00315
00316 private:
00317   ColEditModeEnum m_EditMode;
00318   long m_nCount;
00319   long m_nMaxCount;
00320   bool m_bRequiresSave;
00321   void ClearArrays();
00322
00323 // Methods:
00324   WCHAR* ExtractParams(WCHAR *wszParams);
00325
00326 public:
00327   void Clear();
00328   HRESULT InternalInsert(long Index, LPCWSTR wszKey, VARIANT* pValue, VARTYPE vt);
00329   HRESULT InternalInsert(long Index, LPCWSTR wszKey, WCHAR* wszValue);
00330   HRESULT InternalInsert(long Index, LPCWSTR wszKey, long* pnValue);
00331 };
00332
00333 class CStaticEntity : public CComObject<CEntity>
00334 {
00335   DECLARE_FIXED_ALLOC(CStaticEntity);
00336
00337 public:
00338
00339 };
00340
00341 #endif //__STATIC_H_
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

AutoClaims::InkLayer Member List

This is the complete list of members for AutoClaims::InkLayer, including all inherited members.
ActiveColor | AutoClaims::InkLayer |
ActiveInk | AutoClaims::InkLayer |
Hidden | AutoClaims::InkLayer |
InkLayer(Ink ink, Color color, bool hidden) | AutoClaims::InkLayer | [inline]
InkLayer(Ink ink, Color color, bool hidden) | AutoClaims::InkLayer | [inline]
InkLayer(Ink ink, Color color, bool hidden) | AutoClaims::InkLayer | [inline]
myColor | AutoClaims::InkLayer | [private]
myHidden | AutoClaims::InkLayer | [private]
myInk | AutoClaims::InkLayer | [private]
Generated on Wed Nov 13 2024 16:58:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Hook.c Source File

  • Multimedia
  • Gdi
  • WinCap32

Hook.c

Go to the documentation of this file.
00001 //***********************************************************************
00002 //
00003 // hook.c
00004 //
00005 // Source file for Keyboard Hook function and support procedures.  Defines
00006 // the following exported functions:
00007 //
00008 // InstallHook()       - Installs/Removes keyboard hook for app's hotkeys
00009 // KeyboardHook()      - Keyboard Hook Procedure
00010 //
00011 // This file should go into a DLL.
00012 //
00013 // This file, although not officially containing DIB functions, is part
00014 // of the DIBAPI.DLL because:
00015 //   1) System-wide Hook Procedures in 3.1 need to be in a DLL, and
00016 //   2) I didn't want the user to have 2 DLLs to worry about for WINCAP.
00017 //
00018 //
00019 // Written by Microsoft Product Support Services, Developer Support.
00020 // Copyright 1991 - 2000 Microsoft Corporation. All rights reserved.
00021 //***********************************************************************
00022
00023 #define     STRICT      // enable strict type checking
00024
00025 #include <windows.h>
00026 #include "wincap.h"
00027
00028 // Globals for this module
00029
00030 extern HWND     ghWndMain;      // Handle to main window -- used to post msgs
00031
00032 static HHOOK    hHook;          // A handle to our installed hook
00033 static BOOL     bHookInstalled; // TRUE if hook has been installed
00034
00035
00036 // External variables
00037
00038 extern HANDLE ghDLLInst;   // Handle to the DLL's instance.  Set in DllMain.
00039
00040 // Local function.  Although this function is exported from our DLL (Windows
00041 // needs to call it directly), no other app needs to call this, so we can
00042 // just prototype it here.
00043
00044 LRESULT CALLBACK KeyboardHook (int nCode, WORD wParam, DWORD lParam );
00045
00046 //**********************************************************************
00047 // InstallHook()
00048 //
00049 // Installs/Removes Filter function for the WH_KEYBOARD hook.
00050 //
00051 // Parameters:
00052 // HWND hWnd      Handle to main window to receive posted messages.  See
00053 //                KeyboardHook() for more info on how it works.
00054 //
00055 // BOOL bCode     TRUE to hook, FALSE to unhook
00056 //
00057 // Returns:
00058 // 1 if successful, 0 if not.
00059 //
00060 //**********************************************************************
00061
00062 int APIENTRY InstallHook (HWND hWnd, BOOL bCode )
00063 {
00064
00065     int nReturn = 1;
00066
00067     ghWndMain = hWnd;  // Store app's window handle in DLL global variable
00068
00069     // Make sure that we are installing/removing in the proper order
00070
00071     if (bCode == bHookInstalled)
00072         return 0;
00073
00074     if (bCode)
00075     {
00076         hHook = (HHOOK)SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardHook,
00077             ghDLLInst, 0);
00078
00079         if (!hHook)
00080             return 0;
00081
00082         bHookInstalled = TRUE;
00083     }
00084     else
00085     {
00086         nReturn = UnhookWindowsHookEx(hHook);
00087         bHookInstalled = FALSE;
00088     }
00089     return nReturn;
00090 }
00091
00092
00093
00094
00095 //**********************************************************************
00096 //
00097 // KeyboardHook()
00098 //
00099 // This is the Keyboard Hook function which windows will call every
00100 // time it gets a keyboard message.  In this function, we check to
00101 // see if the key pressed was Ctrl+Alt+F[8,9,10], and if it is, we post
00102 // the proper message to our main window which will do the right
00103 // thing.
00104 //
00105 // Note that the window handle that we post from was set by a call to
00106 // InstallHook() above.
00107 //
00108 // Parameters/return value:
00109 //
00110 // Standard 3.1 KeyboardProc.  See docs for "KeyboardProc".
00111 //
00112 //*********************************************************************
00113
00114 LRESULT CALLBACK KeyboardHook (int nCode, WORD wParam, DWORD lParam )
00115 {
00116
00117     if ( nCode >= 0 )
00118     {
00119
00120         // Check to see if it's a key we're looking for
00121
00122         if (GetKeyState(VK_SHIFT) < 0 && GetKeyState(VK_CONTROL) < 0)
00123         {
00124             switch (wParam)
00125             {
00126
00127 //      MENUITEM    "&Active Window \aCtrl+Shift+F9",  IDM_ACTIVEWINDOW
00128 //      MENUITEM    "&Desktop\aCtrl+Shift+F10",       IDM_DESKTOP
00129
00130                 case VK_F9:
00131                     if (HIWORD(lParam) & 0x8000)
00132                         PostMessage(ghWndMain, WM_COMMAND, IDM_ACTIVEWINDOW, 0L);
00133                     return 1;
00134
00135                 case VK_F10:
00136
00137                     if (HIWORD(lParam) & 0x8000)
00138                         PostMessage(ghWndMain, WM_COMMAND, IDM_DESKTOP, 0L);
00139                     return 1;
00140             }
00141         }
00142    }
00143
00144    //
00145    // If we haven't returned 1 by the time we get here, then we
00146    // need to pass on the message to CallNextHookEx.
00147    //
00148    return (int)CallNextHookEx(hHook, nCode, wParam, lParam);
00149 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHtmlElemBagEntry Member List

This is the complete list of members for CHtmlElemBagEntry, including all inherited members.
_eTokType | CHtmlElemBagEntry | [private]
_pHtmlElement | CHtmlElemBagEntry | [private]
CHtmlElemBagEntry() | CHtmlElemBagEntry |
GetHtmlElement() | CHtmlElemBagEntry | [inline]
GetTokenType() | CHtmlElemBagEntry | [inline]
SetHtmlElement(CHtmlElement *pHtmlElement) | CHtmlElemBagEntry | [inline]
SetTokenType(HtmlTokenType eTokType) | CHtmlElemBagEntry | [inline]
~CHtmlElemBagEntry() | CHtmlElemBagEntry |
Generated on Wed Nov 13 2024 16:56:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPoint::POINT Member List

This is the complete list of members for CPoint::POINT, including all inherited members.
x | CPoint::POINT
y | CPoint::POINT
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

AutoClaims::AutoClaims Member List

This is the complete list of members for AutoClaims::AutoClaims, including all inherited members.
AutoClaims() | AutoClaims::AutoClaims | [inline]
AutoClaims() | AutoClaims::AutoClaims | [inline]
AutoClaims() | AutoClaims::AutoClaims | [inline]
AutoClaims_Load(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
AutoClaims_Load(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
AutoClaims_Load(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
chHideLayer | AutoClaims::AutoClaims | [private]
chHideLayer_CheckedChanged(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
chHideLayer_CheckedChanged(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
chHideLayer_CheckedChanged(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
components | AutoClaims::AutoClaims | [private]
Dispose(bool disposing) | AutoClaims::AutoClaims | [inline, protected]
Dispose(bool disposing) | AutoClaims::AutoClaims | [inline, protected]
Dispose(bool disposing) | AutoClaims::AutoClaims | [inline, protected]
DisposeResources() | AutoClaims::AutoClaims | [inline]
emptyInk | AutoClaims::AutoClaims | [private]
InitializeComponent() | AutoClaims::AutoClaims | [inline, private]
InitializeComponent() | AutoClaims::AutoClaims | [inline, private]
InitializeComponent() | AutoClaims::AutoClaims | [inline, private]
inkEdMake | AutoClaims::AutoClaims | [private]
inkEdMake_Enter(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
inkEdModel | AutoClaims::AutoClaims | [private]
inkEdModel_Enter(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
inkEdName | AutoClaims::AutoClaims | [private]
inkEdPolicyNumber | AutoClaims::AutoClaims | [private]
inkEdYear | AutoClaims::AutoClaims | [private]
inkEdYear_Enter(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
inkLayers | AutoClaims::AutoClaims | [private]
inkPictVehicle | AutoClaims::AutoClaims | [private]
inkPictVehicle_Paint(object sender, System.Windows.Forms.PaintEventArgs e) | AutoClaims::AutoClaims | [inline, private]
inkPictVehicle_Paint(object sender, System.Windows.Forms.PaintEventArgs e) | AutoClaims::AutoClaims | [inline, private]
inkPictVehicle_Paint(object sender, System.Windows.Forms.PaintEventArgs e) | AutoClaims::AutoClaims | [inline, private]
lblInstructions | AutoClaims::AutoClaims | [private]
lblInsuredName | AutoClaims::AutoClaims | [private]
lblMake | AutoClaims::AutoClaims | [private]
lblModel | AutoClaims::AutoClaims | [private]
lblPolicyNumber | AutoClaims::AutoClaims | [private]
lblTitle | AutoClaims::AutoClaims | [private]
lblVehicleDamage | AutoClaims::AutoClaims | [private]
lblVehicleDescription | AutoClaims::AutoClaims | [private]
lblYear | AutoClaims::AutoClaims | [private]
lstAnnotationLayer | AutoClaims::AutoClaims | [private]
lstAnnotationLayer_SelectedIndexChanged(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
lstAnnotationLayer_SelectedIndexChanged(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
lstAnnotationLayer_SelectedIndexChanged(object sender, System.EventArgs e) | AutoClaims::AutoClaims | [inline, private]
Main() | AutoClaims::AutoClaims | [inline, private, static]
Main() | AutoClaims::AutoClaims | [inline, private, static]
ObjectsNotInstalledError | AutoClaims::AutoClaims | [private]
pictCheckmarks | AutoClaims::AutoClaims | [private]
pictHorzontalBar1 | AutoClaims::AutoClaims | [private]
pictHorzontalBar2 | AutoClaims::AutoClaims | [private]
pictHorzontalBar3 | AutoClaims::AutoClaims | [private]
pictPolicyBox | AutoClaims::AutoClaims | [private]
pictVehicleBox | AutoClaims::AutoClaims | [private]
pipName | AutoClaims::AutoClaims | [private]
pipPolicyNumber | AutoClaims::AutoClaims | [private]
pipShared | AutoClaims::AutoClaims | [private]
selectedHidden | AutoClaims::AutoClaims | [private]
selectedIndex | AutoClaims::AutoClaims | [private]
Generated on Wed Nov 13 2024 16:58:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/atl/atlcontrol.h Source File

  • SysMgmt
  • MMC
  • ActiveX
  • atl

atlcontrol.h

Go to the documentation of this file.
00001 /* this ALWAYS GENERATED file contains the definitions for the interfaces */
00002
00003
00004 /* File created by MIDL compiler version 5.01.0164 */
00005 /* at Fri Nov 19 19:31:26 1999
00006  */
00007 /* Compiler settings for D:\nt\private\admin\bosrc\sources\activex\atl\ATLControl.idl:
00008     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00009     error checks: allocation ref bounds_check enum stub_data
00010 */
00011 //@@MIDL_FILE_HEADING(  )
00012
00013
00014 /* verify that the <rpcndr.h> version is high enough to compile this file*/
00015 #ifndef __REQUIRED_RPCNDR_H_VERSION__
00016 #define __REQUIRED_RPCNDR_H_VERSION__ 440
00017 #endif
00018
00019 #include "rpc.h"
00020 #include "rpcndr.h"
00021
00022 #ifndef __RPCNDR_H_VERSION__
00023 #error this stub requires an updated version of <rpcndr.h>
00024 #endif // __RPCNDR_H_VERSION__
00025
00026 #ifndef COM_NO_WINDOWS_H
00027 #include "windows.h"
00028 #include "ole2.h"
00029 #endif /*COM_NO_WINDOWS_H*/
00030
00031 #ifndef __ATLControl_h__
00032 #define __ATLControl_h__
00033
00034 #ifdef __cplusplus
00035 extern "C"{
00036 #endif
00037
00038 /* Forward Declarations */
00039
00040 #ifndef __IMMCControl_FWD_DEFINED__
00041 #define __IMMCControl_FWD_DEFINED__
00042 typedef interface IMMCControl IMMCControl;
00043 #endif  /* __IMMCControl_FWD_DEFINED__ */
00044
00045
00046 #ifndef __MMCControl_FWD_DEFINED__
00047 #define __MMCControl_FWD_DEFINED__
00048
00049 #ifdef __cplusplus
00050 typedef class MMCControl MMCControl;
00051 #else
00052 typedef struct MMCControl MMCControl;
00053 #endif /* __cplusplus */
00054
00055 #endif  /* __MMCControl_FWD_DEFINED__ */
00056
00057
00058 /* header files for imported files */
00059 #include "oaidl.h"
00060 #include "ocidl.h"
00061
00062 void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
00063 void __RPC_USER MIDL_user_free( void __RPC_FAR * );
00064
00065 #ifndef __IMMCControl_INTERFACE_DEFINED__
00066 #define __IMMCControl_INTERFACE_DEFINED__
00067
00068 /* interface IMMCControl */
00069 /* [unique][helpstring][dual][uuid][object] */
00070
00071
00072 EXTERN_C const IID IID_IMMCControl;
00073
00074 #if defined(__cplusplus) && !defined(CINTERFACE)
00075
00076     MIDL_INTERFACE("831DF6C8-C754-11D2-952C-00C04FB92EC2")
00077     IMMCControl : public IDispatch
00078     {
00079     public:
00080         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE StartAnimation( void) = 0;
00081
00082         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE StopAnimation( void) = 0;
00083
00084         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE DoHelp( void) = 0;
00085
00086     };
00087
00088 #else   /* C style interface */
00089
00090     typedef struct IMMCControlVtbl
00091     {
00092         BEGIN_INTERFACE
00093
00094         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00095             IMMCControl __RPC_FAR * This,
00096             /* [in] */ REFIID riid,
00097             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00098
00099         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00100             IMMCControl __RPC_FAR * This);
00101
00102         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00103             IMMCControl __RPC_FAR * This);
00104
00105         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00106             IMMCControl __RPC_FAR * This,
00107             /* [out] */ UINT __RPC_FAR *pctinfo);
00108
00109         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00110             IMMCControl __RPC_FAR * This,
00111             /* [in] */ UINT iTInfo,
00112             /* [in] */ LCID lcid,
00113             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00114
00115         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00116             IMMCControl __RPC_FAR * This,
00117             /* [in] */ REFIID riid,
00118             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00119             /* [in] */ UINT cNames,
00120             /* [in] */ LCID lcid,
00121             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00122
00123         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00124             IMMCControl __RPC_FAR * This,
00125             /* [in] */ DISPID dispIdMember,
00126             /* [in] */ REFIID riid,
00127             /* [in] */ LCID lcid,
00128             /* [in] */ WORD wFlags,
00129             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00130             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00131             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00132             /* [out] */ UINT __RPC_FAR *puArgErr);
00133
00134         /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *StartAnimation )(
00135             IMMCControl __RPC_FAR * This);
00136
00137         /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *StopAnimation )(
00138             IMMCControl __RPC_FAR * This);
00139
00140         /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DoHelp )(
00141             IMMCControl __RPC_FAR * This);
00142
00143         END_INTERFACE
00144     } IMMCControlVtbl;
00145
00146     interface IMMCControl
00147     {
00148         CONST_VTBL struct IMMCControlVtbl __RPC_FAR *lpVtbl;
00149     };
00150
00151
00152
00153 #ifdef COBJMACROS
00154
00155
00156 #define IMMCControl_QueryInterface(This,riid,ppvObject) \
00157     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00158
00159 #define IMMCControl_AddRef(This)  \
00160     (This)->lpVtbl -> AddRef(This)
00161
00162 #define IMMCControl_Release(This) \
00163     (This)->lpVtbl -> Release(This)
00164
00165
00166 #define IMMCControl_GetTypeInfoCount(This,pctinfo)  \
00167     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00168
00169 #define IMMCControl_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
00170     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00171
00172 #define IMMCControl_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
00173     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00174
00175 #define IMMCControl_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
00176     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00177
00178
00179 #define IMMCControl_StartAnimation(This)  \
00180     (This)->lpVtbl -> StartAnimation(This)
00181
00182 #define IMMCControl_StopAnimation(This) \
00183     (This)->lpVtbl -> StopAnimation(This)
00184
00185 #define IMMCControl_DoHelp(This)  \
00186     (This)->lpVtbl -> DoHelp(This)
00187
00188 #endif /* COBJMACROS */
00189
00190
00191 #endif  /* C style interface */
00192
00193
00194
00195 /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IMMCControl_StartAnimation_Proxy(
00196     IMMCControl __RPC_FAR * This);
00197
00198
00199 void __RPC_STUB IMMCControl_StartAnimation_Stub(
00200     IRpcStubBuffer *This,
00201     IRpcChannelBuffer *_pRpcChannelBuffer,
00202     PRPC_MESSAGE _pRpcMessage,
00203     DWORD *_pdwStubPhase);
00204
00205
00206 /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IMMCControl_StopAnimation_Proxy(
00207     IMMCControl __RPC_FAR * This);
00208
00209
00210 void __RPC_STUB IMMCControl_StopAnimation_Stub(
00211     IRpcStubBuffer *This,
00212     IRpcChannelBuffer *_pRpcChannelBuffer,
00213     PRPC_MESSAGE _pRpcMessage,
00214     DWORD *_pdwStubPhase);
00215
00216
00217 /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IMMCControl_DoHelp_Proxy(
00218     IMMCControl __RPC_FAR * This);
00219
00220
00221 void __RPC_STUB IMMCControl_DoHelp_Stub(
00222     IRpcStubBuffer *This,
00223     IRpcChannelBuffer *_pRpcChannelBuffer,
00224     PRPC_MESSAGE _pRpcMessage,
00225     DWORD *_pdwStubPhase);
00226
00227
00228
00229 #endif  /* __IMMCControl_INTERFACE_DEFINED__ */
00230
00231
00232
00233 #ifndef __ATLCONTROLLib_LIBRARY_DEFINED__
00234 #define __ATLCONTROLLib_LIBRARY_DEFINED__
00235
00236 /* library ATLCONTROLLib */
00237 /* [helpstring][version][uuid] */
00238
00239
00240 EXTERN_C const IID LIBID_ATLCONTROLLib;
00241
00242 EXTERN_C const CLSID CLSID_MMCControl;
00243
00244 #ifdef __cplusplus
00245
00246 class DECLSPEC_UUID("9A12FB62-C754-11D2-952C-00C04FB92EC2")
00247 MMCControl;
00248 #endif
00249 #endif /* __ATLCONTROLLib_LIBRARY_DEFINED__ */
00250
00251 /* Additional Prototypes for ALL interfaces */
00252
00253 /* end of Additional Prototypes */
00254
00255 #ifdef __cplusplus
00256 }
00257 #endif
00258
00259 #endif
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EdAnnotator/AnnotatorProject/EDAnnotator.cpp Source File

  • Web
  • Browser
  • EdAnnotator
  • AnnotatorProject

EDAnnotator.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // EDAnnotator.cpp : Implementation of DLL Exports.
00006
00007
00008 // Note: Proxy/Stub Information
00009 //      To build a separate proxy/stub DLL,
00010 //      run nmake -f EDAnnotatorps.mk in the project directory.
00011
00012 #include "stdafx.h"
00013 #include "resource.h"
00014 #include <initguid.h>
00015 #include "EDAnnotator.h"
00016
00017 #include "EDAnnotator_i.c"
00018 #include "Annotator.h"
00019
00020
00021 CComModule _Module;
00022
00023 BEGIN_OBJECT_MAP(ObjectMap)
00024 OBJECT_ENTRY(CLSID_Annotator, CAnnotator)
00025 END_OBJECT_MAP()
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // DLL Entry Point
00029
00030 extern "C"
00031 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00032 {
00033     if (dwReason == DLL_PROCESS_ATTACH)
00034     {
00035         _Module.Init(ObjectMap, hInstance, &LIBID_EDANNOTATORLib);
00036         DisableThreadLibraryCalls(hInstance);
00037     }
00038     else if (dwReason == DLL_PROCESS_DETACH)
00039         _Module.Term();
00040     return TRUE;    // ok
00041 }
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // Used to determine whether the DLL can be unloaded by OLE
00045
00046 STDAPI DllCanUnloadNow(void)
00047 {
00048     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00049 }
00050
00051 /////////////////////////////////////////////////////////////////////////////
00052 // Returns a class factory to create an object of the requested type
00053
00054 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00055 {
00056     return _Module.GetClassObject(rclsid, riid, ppv);
00057 }
00058
00059 /////////////////////////////////////////////////////////////////////////////
00060 // DllRegisterServer - Adds entries to the system registry
00061
00062 STDAPI DllRegisterServer(void)
00063 {
00064     // registers object, typelib and all interfaces in typelib
00065     return _Module.RegisterServer(TRUE);
00066 }
00067
00068 /////////////////////////////////////////////////////////////////////////////
00069 // DllUnregisterServer - Removes entries from the system registry
00070
00071 STDAPI DllUnregisterServer(void)
00072 {
00073     return _Module.UnregisterServer(TRUE);
00074 }
00075
00076
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/localres.h Source File

  • SysMgmt
  • MMC
  • Multisel

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029 #define INDEX_BACKGROUND    6
00030 #define INDEX_STATION       7
00031
00032 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/ioipf.h Source File

  • Com
  • Fundamentals
  • SimpCntr

ioipf.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOIPF.H
00003 //
00004 //      Definition of COleInPlaceFrame
00005 //
00006 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IOIPF_H_ )
00009 #define _IOIPF_H_
00010
00011
00012 class CSimpleApp;
00013
00014 interface COleInPlaceFrame : public IOleInPlaceFrame
00015 {
00016   int m_nCount;
00017   CSimpleApp FAR * m_pApp;
00018
00019   COleInPlaceFrame(CSimpleApp FAR * pApp) {
00020     OutputDebugString("In IOIPF's constructor\r\n");
00021     m_pApp = pApp;
00022     m_nCount = 0;
00023     };
00024
00025   ~COleInPlaceFrame() {
00026     OutputDebugString("In IOIPFS's destructor\r\n");
00027     assert(m_nCount == 0);
00028     };
00029
00030   STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
00031   STDMETHODIMP_(ULONG) AddRef ();
00032   STDMETHODIMP_(ULONG) Release ();
00033
00034   STDMETHODIMP GetWindow (HWND FAR* lphwnd);
00035   STDMETHODIMP ContextSensitiveHelp (BOOL fEnterMode);
00036
00037   // *** IOleInPlaceUIWindow methods ***
00038   STDMETHODIMP GetBorder (LPRECT lprectBorder);
00039   STDMETHODIMP RequestBorderSpace (LPCBORDERWIDTHS lpborderwidths);
00040   STDMETHODIMP SetBorderSpace (LPCBORDERWIDTHS lpborderwidths);
00041   //@@WTK WIN32, UNICODE
00042   //STDMETHODIMP SetActiveObject (LPOLEINPLACEACTIVEOBJECT lpActiveObject,LPCSTR lpszObjName);
00043   STDMETHODIMP SetActiveObject (LPOLEINPLACEACTIVEOBJECT lpActiveObject,LPCOLESTR lpszObjName);
00044
00045   // *** IOleInPlaceFrame methods ***
00046   STDMETHODIMP InsertMenus (HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
00047   STDMETHODIMP SetMenu (HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
00048   STDMETHODIMP RemoveMenus (HMENU hmenuShared);
00049   //@@WTK WIN32, UNICODE
00050   //STDMETHODIMP SetStatusText (LPCSTR lpszStatusText);
00051   STDMETHODIMP SetStatusText (LPCOLESTR lpszStatusText);
00052   STDMETHODIMP EnableModeless (BOOL fEnable);
00053   STDMETHODIMP TranslateAccelerator (LPMSG lpmsg, WORD wID);
00054 };
00055
00056 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LicServe/CRUCAR.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • LicServe

CRUCAR.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CRUCAR.H
00003
00004   Summary:   Include file for the aggregatable COLicCruiseCar COM object
00005              class.
00006
00007              CRUCAR showcases the construction of the COLicCruiseCar COM
00008              object class with the IUnknown, ICar, and ICruise interfaces.
00009              This is done through Aggregation reuse of a COCar COM
00010              object (specifically providing its ICar interface features).
00011
00012              This multiple interface COM Object Class is achieved via
00013              the technique of nested classes: the implementation of the
00014              ICar and ICruise interfaces are nested inside of the
00015              COLicCruiseCar COM object class.
00016
00017              For a comprehensive tutorial code tour of this module's
00018              contents and offerings see the tutorial LICSERVE.HTM
00019              file. For more specific technical details on the internal
00020              workings see the comments dispersed throughout the module's
00021              source code.
00022
00023   Classes:   COLicCruiseCar.
00024
00025   Functions: .
00026
00027   Origin:    10-5-95: atrent - Editor-inheritance from CRUCAR.H in
00028                the DLLSERVE Tutorial Code Sample.
00029
00030 ----------------------------------------------------------------------------
00031   This file is part of the Microsoft COM Tutorial Code Samples.
00032
00033   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00034
00035   This source code is intended only as a supplement to Microsoft
00036   Development Tools and/or on-line documentation.  See these other
00037   materials for detailed information regarding Microsoft code samples.
00038
00039   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00040   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00041   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00042   PARTICULAR PURPOSE.
00043 ==========================================================================+*/
00044
00045 #if !defined(CRUCAR_H)
00046 #define CRUCAR_H
00047
00048 #ifdef __cplusplus
00049
00050 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00051   ObjectClass: COLicCruiseCar
00052
00053   Summary:     COM Object Class for COLicCruiseCar COM Objects.  COM
00054                objects of this class augment COCar COM objects (which
00055                offer ICar interface features of Shift, Clutch, Speed, and
00056                Steer) with ICruise interface features (Engage and Adjust).
00057                This COLicCruiseCar COM object class is constructed by
00058                aggregation reuse of the COCar COM object class.  The
00059                mulitple interfaces on this COM object class are
00060                constructed via the nested interface classes technique.
00061
00062   Interfaces:  IUnknown
00063                  Standard interface providing COM object features.
00064                ICar
00065                  Basic Car operation features.
00066                ICruise
00067                  Cruise control features.
00068
00069   Aggregation: Yes, COLicCruiseCar COM objects are aggregatable by passing
00070                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00071 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00072 class COLicCruiseCar : public IUnknown
00073 {
00074   public:
00075     // Main Object Constructor & Destructor.
00076     COLicCruiseCar(IUnknown* pUnkOuter, CServer* pServer);
00077     ~COLicCruiseCar(void);
00078
00079     // A general method for initializing a newly created COLicCruiseCar.
00080     HRESULT Init(void);
00081
00082     // IUnknown methods. Main object, non-delegating.
00083     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00084     STDMETHODIMP_(ULONG) AddRef(void);
00085     STDMETHODIMP_(ULONG) Release(void);
00086
00087   private:
00088     // We declare nested class interface implementations here.
00089
00090     // We implement the ICruise interface (ofcourse) in this COLicCruiseCar
00091     // COM object class.  This is the interface that we are using as an
00092     // augmentation to the existing COCar COM object class.
00093     class CImpICruise : public ICruise
00094     {
00095       public:
00096         // Interface Implementation Constructor & Destructor.
00097         CImpICruise(COLicCruiseCar* pBackObj, IUnknown* pUnkOuter);
00098         ~CImpICruise(void);
00099
00100         // IUnknown methods.
00101         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00102         STDMETHODIMP_(ULONG) AddRef(void);
00103         STDMETHODIMP_(ULONG) Release(void);
00104
00105         // ICruise methods.
00106         STDMETHODIMP Engage(BOOL bOnOff);
00107         STDMETHODIMP Adjust(BOOL bUpDown);
00108
00109       private:
00110         // Data private to this interface implementation of ICruise.
00111         ULONG            m_cRefI;       // Interface Ref Count (debugging).
00112         COLicCruiseCar*  m_pBackObj;    // Parent Object back pointer.
00113         IUnknown*        m_pUnkOuter;   // Outer unknown for Delegation.
00114     };
00115
00116     // Make the otherwise private and nested ICar interface implementation
00117     // a friend to COM object instantiations of this selfsame COLicCruiseCar
00118     // COM object class.
00119     friend CImpICruise;
00120
00121     // Private data of COLicCruiseCar COM objects.
00122
00123     // Nested ICruise implementation instantiation.  This ICruise interface
00124     // is implemented inside this COLicCruiseCar object as a native
00125     // interface.
00126     CImpICruise     m_ImpICruise;
00127
00128     // Main Object reference count.
00129     ULONG           m_cRefs;
00130
00131     // Outer unknown (aggregation & delegation). Used when this
00132     // COLicCruiseCar object is being aggregated.  Otherwise it is used for
00133     // delegation if this object is reused via containment.
00134     IUnknown*       m_pUnkOuter;
00135
00136     // We need to save the IUnknown interface pointer on the COCar
00137     // object that we aggregate.  We use this when we need to delegate
00138     // IUnknown calls to this aggregated inner object.
00139     IUnknown*       m_pUnkCar;
00140
00141     // Pointer to this component server's control object.
00142     CServer*        m_pServer;
00143 };
00144
00145 typedef COLicCruiseCar* PCOLicCruiseCar;
00146
00147 #endif // __cplusplus
00148
00149
00150 #endif // CRUCAR_H
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CComboBoxLite Member List

This is the complete list of members for CComboBoxLite, including all inherited members.
AddString(WCHAR *pwszString) | CComboBoxLite | [inline, virtual]
AddString(WCHAR *pwszString, LPARAM lParam) | CComboBoxLite | [virtual]
CComboBoxLite(HWND hWndParent=NULL, UINT nID=0) | CComboBoxLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DeleteString(INDEX nIndex) | CComboBoxLite | [inline, virtual]
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
FindString(WCHAR *pwszString, INDEX nStartIndex=-1) | CComboBoxLite | [inline, virtual]
FindStringExact(WCHAR *pwszString, INDEX nStartIndex=-1) | CComboBoxLite | [inline, virtual]
GetCount() | CComboBoxLite | [inline, virtual]
GetCurSel() const | CComboBoxLite | [inline, virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetItemParam(INDEX nIndex) const | CComboBoxLite | [inline, virtual]
GetSelText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CComboBoxLite | [virtual]
GetSelValue() | CComboBoxLite | [virtual]
GetText(INDEX nIndex, WCHAR *pwszBuffer) | CComboBoxLite | [inline, virtual]
GetTextLength(INDEX nIndex) | CComboBoxLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_iSavedSel | CComboBoxLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CComboBoxLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropDown(INT iID, HWND hWndCtrl) | CComboBoxLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSelChange(INT iID, HWND hWndCtrl) | CComboBoxLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
Populate(ULONG cItems, const WIDENAMEMAP *rgItems) | CComboBoxLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
ResetContent() | CComboBoxLite | [inline, virtual]
RestoreSelection() | CComboBoxLite | [inline, virtual]
SaveSelection() | CComboBoxLite | [inline, virtual]
SetCurSel(WPARAM nSelect) | CComboBoxLite | [inline, virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetItemParam(INDEX nIndex, LPARAM lParam) | CComboBoxLite | [inline, virtual]
SetSelText(WCHAR *pwszBuffer, BOOL fAddItem=FALSE) | CComboBoxLite | [virtual]
SetSelValue(LPARAM lParam) | CComboBoxLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CComboBoxLite() | CComboBoxLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:55:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/StdAfx.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

StdAfx.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      StdAfx.h
00005 //
00006 //  Description:
00007 //      Project-wide include file.
00008 //
00009 //  Implementation Files:
00010 //      StdAfx.cpp
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 #pragma once
00015
00016
00017 //////////////////////////////////////////////////////////////////////////////
00018 // Project-wide pragmas
00019 //////////////////////////////////////////////////////////////////////////////
00020
00021 #pragma warning( disable : 4127 )   // C4127: conditional expression is constant (BEGIN_COM_MAP)
00022 #pragma warning( disable : 4505 )   // C4505: unreferenced local function has been removed
00023 #pragma warning( disable : 4514 )   // C4514: unreferenced inline function has been removed
00024 #pragma warning( disable : 4701 )   // C4701: local variable 'cchDestCurrent' may be used without having been initialized
00025 #pragma warning( disable : 4710 )   // C4710: function not expanded
00026
00027
00028 //////////////////////////////////////////////////////////////////////////////
00029 // External Include Files
00030 //////////////////////////////////////////////////////////////////////////////
00031
00032 #ifndef _WIN32_WINNT
00033 #define _WIN32_WINNT 0x0502
00034 #endif
00035
00036 #ifndef UNICODE
00037 #define UNICODE
00038 #endif
00039
00040 #pragma warning( push, 3 )
00041
00042 #define _ATL_APARTMENT_THREADED
00043 #include <atlbase.h>
00044 #include <Windows.h>
00045
00046 extern CComModule _Module;
00047
00048 #include <atlcom.h>
00049
00050 //
00051 // These two include files contain all ClusCfg interface definitions and CATIDs.
00052 //
00053
00054 #include <ClusCfgServer.h>
00055 #include <ClusCfgGuids.h>
00056
00057 #include <clusapi.h>
00058 #include <assert.h>
00059 #include <WBemCli.h>
00060
00061 //
00062 // MyStorageResource.h is generated from MyStorageResource.idl.
00063 //
00064
00065 #include "MyStorageResource.h"
00066
00067 #pragma warning( pop )
00068
00069
00070 #pragma warning( push, 3 )
00071 #include <strsafe.h>
00072 #pragma warning( pop )
00073
00074
00075 //////////////////////////////////////////////////////////////////////////////
00076 // Local Includes Files
00077 //////////////////////////////////////////////////////////////////////////////
00078
00079 #include "StringUtils.h"
00080 #include "resource.h"
00081 #include "guids.h"
00082 #include "common.h"
00083 #include "StringUtils.h"
00084
00085
00086 //////////////////////////////////////////////////////////////////////////////
00087 // Define's
00088 //////////////////////////////////////////////////////////////////////////////
00089
00090 #ifndef RTL_NUMBER_OF
00091 #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
00092 #endif
00093
00094 //
00095 // COM Macros to gain type checking.
00096 //
00097
00098 #if !defined( TypeSafeParams )
00099 #define TypeSafeParams( _interface, _ppunk ) \
00100     IID_##_interface, reinterpret_cast< void ** >( static_cast< _interface ** >( _ppunk ) )
00101 #endif // !defined( TypeSafeParams )
00102
00103 #if !defined( TypeSafeQI )
00104 #define TypeSafeQI( _interface, _ppunk ) \
00105     QueryInterface( TypeSafeParams( _interface, _ppunk ) )
00106 #endif // !defined( TypeSafeQI )
00107
00108 //
00109 // Custom error code used by the WMI code.
00110 //
00111 const HRESULT   E_PROPTYPEMISMATCH = HRESULT_FROM_WIN32( ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH );
00112
00113 //
00114 //  HeapReAlloc does not follow the same rules as the CRT realloc() when
00115 //  reallocating a NULL pointer.  This macro simulates the CRT behavior and
00116 //  removes the need for the initial alloc of an empty buffer from the code.
00117 //
00118
00119 #define HEAPREALLOC( _pvMem, _uBytes, _uFlags )     ( ( _pvMem == NULL ) \
00120                                                     ? HeapAlloc( GetProcessHeap(), _uFlags, _uBytes ) \
00121                                                     : HeapReAlloc( GetProcessHeap(), _uFlags, _pvMem, _uBytes ) )
00122
00123
00124 //////////////////////////////////////////////////////////////////////////////
00125 // Globals
00126 //////////////////////////////////////////////////////////////////////////////
00127
00128 //
00129 // This is the name of the cluster resource type that we use for this sample.
00130 //
00131
00132 //
00133 // TODO: Change this to match your new resource type name.  The resource type
00134 //       display name is localizable and is located in the project's RC file.
00135 //
00136
00137 #define RESTYPE_NAME L"Physical Disk"
00138
00139 //
00140 // This is the name of the cluster resource type dll.
00141 //
00142
00143 //
00144 // TODO: Change this to the name of the accompanying resource dll.
00145 //
00146
00147 #define RESTYPE_DLL_NAME L"clusres.dll"
00148
00149
00150 //////////////////////////////////////////////////////////////////////////////
00151 // Function Declarations
00152 //////////////////////////////////////////////////////////////////////////////
00153
00154 HRESULT HrSetInitialize( IUnknown * punkIn, IClusCfgCallback * picccIn, LCID lcidIn );
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcADO/ADOKB.Cpp Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcADO

ADOKB.Cpp

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: ADOKB.cpp
00003 //
00004 // Description: Implemetation of DLL Exports
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022 // Note: Proxy/Stub Information
00023 //    To build a separate proxy/stub DLL,
00024 //    run nmake -f ADOKBps.mk in the project directory.
00025
00026 #include "stdafx.h"
00027 #include "resource.h"
00028 #include "initguid.h"
00029 #include "ADOKB.h"
00030
00031 #include "ADOKB_i.c"
00032 #include <initguid.h>
00033 #include "ADOComponent.h"
00034
00035
00036 CComModule _Module;
00037
00038 BEGIN_OBJECT_MAP(ObjectMap)
00039   OBJECT_ENTRY(CLSID_ADOComponent, CADOComponent)
00040 END_OBJECT_MAP()
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 // DLL Entry Point
00044
00045 extern "C"
00046 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00047 {
00048   if (dwReason == DLL_PROCESS_ATTACH)
00049   {
00050     _Module.Init(ObjectMap, hInstance);
00051     DisableThreadLibraryCalls(hInstance);
00052   }
00053   else if (dwReason == DLL_PROCESS_DETACH)
00054     _Module.Term();
00055   return TRUE;    // ok
00056 }
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // Used to determine whether the DLL can be unloaded by OLE
00060
00061 STDAPI DllCanUnloadNow(void)
00062 {
00063   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00064 }
00065
00066 /////////////////////////////////////////////////////////////////////////////
00067 // Returns a class factory to create an object of the requested type
00068
00069 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00070 {
00071   return _Module.GetClassObject(rclsid, riid, ppv);
00072 }
00073
00074 /////////////////////////////////////////////////////////////////////////////
00075 // DllRegisterServer - Adds entries to the system registry
00076
00077 STDAPI DllRegisterServer(void)
00078 {
00079   // registers object, typelib and all interfaces in typelib
00080   return _Module.RegisterServer(TRUE);
00081 }
00082
00083 /////////////////////////////////////////////////////////////////////////////
00084 // DllUnregisterServer - Removes entries from the system registry
00085
00086 STDAPI DllUnregisterServer(void)
00087 {
00088   _Module.UnregisterServer();
00089   return S_OK;
00090 }
00091
00092
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/SockAuth/Security.cpp Source File

  • Security
  • SSPI
  • SockAuth

Security.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 Module Name:
00006
00007     security.c
00008
00009 Abstract:
00010
00011     Handles communication with the SSP package.
00012
00013 Revision History:
00014
00015 --*/
00016
00017 #include <windows.h>
00018 #include <winsock.h>
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #define SECURITY_WIN32
00022 #include "sspi.h"
00023 #include "security.h"
00024 #include "collect.h"
00025
00026 //static DWORD      g_cbMaxToken;
00027 static TCHAR      g_lpPackageName[1024];
00028 static BOOL       g_fVerbose;
00029
00030
00031 // structure storing the state of the authentication sequence
00032 //
00033 typedef struct _AUTH_SEQ {
00034     BOOL _fNewConversation;
00035     CredHandle _hcred;
00036     BOOL _fHaveCredHandle;
00037     BOOL _fHaveCtxtHandle;
00038     struct _SecHandle  _hctxt;
00039     ULONG cbMaxSignature;
00040     ULONG cbSecurityTrailer;
00041 } AUTH_SEQ, *PAUTH_SEQ;
00042
00043 #define SEC_SUCCESS(Status) ((Status) >= 0)
00044
00045 #define NT_DLL_NAME           "secur32.dll"
00046
00047 // Target name for the security package
00048 //
00049 #define TOKEN_SOURCE_NAME     "AuthSamp"
00050
00051
00052 BOOL InitPackage (TCHAR *lpPackageName, BOOL fVerbose)
00053 /*++
00054
00055  Routine Description:
00056
00057     Finds, loads and initializes the security package
00058
00059  Return Value:
00060
00061     Returns TRUE is successful; otherwise FALSE is returned.
00062
00063 --*/
00064 {
00065    SECURITY_STATUS ss;
00066    PSecPkgInfo pkgInfo;
00067
00068    // Query for the package we're interested in
00069    //
00070    ss = QuerySecurityPackageInfo (lpPackageName, &pkgInfo);
00071
00072    if (!SEC_SUCCESS(ss)) {
00073       fprintf (stderr, "Couldn't query package info for %s, error 0x%08x\n",
00074                lpPackageName, ss);
00075       return(FALSE);
00076    }
00077
00078    lstrcpy (g_lpPackageName, lpPackageName);
00079
00080    FreeContextBuffer (pkgInfo);
00081
00082    g_fVerbose = fVerbose;
00083
00084    printf ("Using package: %s\n", g_lpPackageName);
00085
00086    return TRUE;
00087 }
00088
00089 BOOL TermPackage ()
00090 {
00091
00092    return(TRUE);
00093 }
00094
00095 BOOL GenClientContext (
00096          DWORD dwKey,
00097          BYTE *pIn,
00098          DWORD cbIn,
00099          BYTE **pOut,
00100          DWORD *pcbOut,
00101          BOOL *pfDone,
00102          ULONG *pAttribs,
00103          CHAR *pszTarget)
00104 /*++
00105
00106  Routine Description:
00107
00108     Optionally takes an input buffer coming from the server and returns
00109    a buffer of information to send back to the server.  Also returns
00110    an indication of whether or not the context is complete.
00111
00112  Return Value:
00113
00114     Returns TRUE is successful; otherwise FALSE is returned.
00115
00116 --*/
00117 {
00118    SECURITY_STATUS   ss;
00119    TimeStamp         Lifetime;
00120    SecBufferDesc     OutBuffDesc;
00121    SecBuffer         OutSecBuff;
00122    SecBufferDesc     InBuffDesc;
00123    SecBuffer         InSecBuff;
00124    ULONG             ContextAttributes;
00125    PAUTH_SEQ         pAS;
00126    SecPkgContext_Sizes SecPkgContextSizes;
00127    SecPkgContext_NegotiationInfo SecPkgNegInfo;
00128    SecPkgContext_Flags SecPkgFlags;
00129
00130    // Lookup pAS based on Key
00131    //
00132    if (!GetEntry (dwKey, (PVOID*) &pAS))
00133       return(FALSE);
00134
00135    if (pAS->_fNewConversation)  {
00136       ss = AcquireCredentialsHandle (
00137                NULL, // principal
00138                g_lpPackageName,
00139                SECPKG_CRED_OUTBOUND,
00140                NULL, // LOGON id
00141                NULL, // auth data
00142                NULL, // get key fn
00143                NULL, // get key arg
00144                &pAS->_hcred,
00145                &Lifetime
00146                );
00147       if (SEC_SUCCESS (ss))
00148          pAS->_fHaveCredHandle = TRUE;
00149       else {
00150          fprintf (stderr, "AcquireCreds failed: 0x%08x\n", ss);
00151          return(FALSE);
00152       }
00153    }
00154
00155    // prepare output buffer
00156    //
00157    OutBuffDesc.ulVersion = 0;
00158    OutBuffDesc.cBuffers = 1;
00159    OutBuffDesc.pBuffers = &OutSecBuff;
00160
00161    OutSecBuff.cbBuffer = 0;
00162    OutSecBuff.BufferType = SECBUFFER_TOKEN;
00163    OutSecBuff.pvBuffer = NULL;
00164
00165    // prepare input buffer
00166    //
00167    if (!pAS->_fNewConversation)  {
00168       InBuffDesc.ulVersion = 0;
00169       InBuffDesc.cBuffers = 1;
00170       InBuffDesc.pBuffers = &InSecBuff;
00171
00172       InSecBuff.cbBuffer = cbIn;
00173       InSecBuff.BufferType = SECBUFFER_TOKEN;
00174       InSecBuff.pvBuffer = pIn;
00175
00176       if(g_fVerbose)
00177       {
00178          printf ("token buffer recieved(%lu bytes):\n", InSecBuff.cbBuffer);
00179          PrintHexDump (InSecBuff.cbBuffer, (PBYTE)InSecBuff.pvBuffer);
00180       }
00181
00182    }
00183
00184    // Always have the package allocate the memory
00185    *pAttribs |= ISC_REQ_ALLOCATE_MEMORY;
00186
00187    ss = InitializeSecurityContext (
00188             &pAS->_hcred,
00189             pAS->_fNewConversation ? NULL : &pAS->_hctxt,
00190             pszTarget,
00191             *pAttribs,
00192             0, // reserved1
00193             SECURITY_NATIVE_DREP,
00194             pAS->_fNewConversation ? NULL : &InBuffDesc,
00195             0, // reserved2
00196             &pAS->_hctxt,
00197             &OutBuffDesc,
00198             &ContextAttributes,
00199             &Lifetime
00200             );
00201
00202    if (!SEC_SUCCESS (ss))  {
00203       fprintf (stderr, "InitializeSecurityContext failed: 0x%08x\n", ss);
00204       return FALSE;
00205    }
00206
00207    pAS->_fHaveCtxtHandle = TRUE;
00208
00209    // Complete token -- if applicable
00210    //
00211    if ((SEC_I_COMPLETE_NEEDED == ss) || (SEC_I_COMPLETE_AND_CONTINUE == ss))  {
00212       ss = CompleteAuthToken (&pAS->_hctxt, &OutBuffDesc);
00213       if (!SEC_SUCCESS(ss))  {
00214          fprintf (stderr, "complete failed: 0x%08x\n", ss);
00215          return FALSE;
00216       }
00217    }
00218
00219    *pcbOut = OutSecBuff.cbBuffer;
00220    *pOut = (PBYTE)OutSecBuff.pvBuffer;
00221
00222    if (pAS->_fNewConversation)
00223       pAS->_fNewConversation = FALSE;
00224
00225    *pfDone = !((SEC_I_CONTINUE_NEEDED == ss) ||
00226             (SEC_I_COMPLETE_AND_CONTINUE == ss));
00227
00228    if(g_fVerbose)
00229    {
00230       printf ("token buffer generated (%lu bytes):\n", OutSecBuff.cbBuffer);
00231       PrintHexDump (OutSecBuff.cbBuffer, (PBYTE)OutSecBuff.pvBuffer);
00232    }
00233
00234
00235    if(*pfDone) {
00236
00237       // find size of signature block
00238       //
00239       ss = QueryContextAttributes(
00240                &pAS->_hctxt,
00241                SECPKG_ATTR_SIZES,
00242                &SecPkgContextSizes );
00243
00244       if (!SEC_SUCCESS(ss))  {
00245          fprintf (stderr, "QueryContextAttributes failed: 0x%08x\n", ss);
00246          printf("here");
00247          return FALSE;
00248       }
00249
00250       // these values are used for encryption and signing
00251       //
00252       pAS->cbMaxSignature = SecPkgContextSizes.cbMaxSignature;
00253       pAS->cbSecurityTrailer = SecPkgContextSizes.cbSecurityTrailer;
00254
00255       // return the attributes we ended up with
00256       //
00257       *pAttribs = ContextAttributes;
00258
00259       // find out what package was negotiated
00260       //
00261       ss = QueryContextAttributes(
00262            &pAS->_hctxt,
00263            SECPKG_ATTR_NEGOTIATION_INFO,
00264            &SecPkgNegInfo );
00265
00266       if (!SEC_SUCCESS(ss))
00267       {
00268          fprintf (stderr, "QueryContextAttributes failed: 0x%08x\n", ss);
00269          return FALSE;
00270       }
00271       else
00272       {
00273          printf("Package Name: %s\n", SecPkgNegInfo.PackageInfo->Name);
00274          // free up the allocated buffer
00275          //
00276          FreeContextBuffer(SecPkgNegInfo.PackageInfo);
00277
00278       }
00279
00280       // find out what flags are really used
00281       //
00282       ss = QueryContextAttributes(
00283            &pAS->_hctxt,
00284            SECPKG_ATTR_FLAGS,
00285            &SecPkgFlags );
00286
00287       if (!SEC_SUCCESS(ss))
00288       {
00289          fprintf (stderr, "QueryContextAttributes failed: 0x%08x\n", ss);
00290          return FALSE;
00291       }
00292       else
00293       {
00294          printf("FLags: %x\n", SecPkgFlags.Flags);
00295
00296       }
00297
00298    }
00299
00300    if(g_fVerbose)
00301       printf("InitializeSecurityContext result = 0x%08x\n", ss);
00302
00303
00304    return TRUE;
00305 }
00306
00307 BOOL GenServerContext (
00308          DWORD dwKey,
00309          BYTE *pIn,
00310          DWORD cbIn,
00311          BYTE **pOut,
00312          DWORD *pcbOut,
00313          BOOL *pfDone,
00314          ULONG *pAttribs)
00315 /*++
00316
00317  Routine Description:
00318
00319     Takes an input buffer coming from the client and returns a buffer
00320    to be sent to the client.  Also returns an indication of whether or
00321    not the context is complete.
00322
00323  Return Value:
00324
00325     Returns TRUE is successful; otherwise FALSE is returned.
00326
00327 --*/
00328 {
00329    SECURITY_STATUS   ss;
00330    TimeStamp         Lifetime;
00331    SecBufferDesc     OutBuffDesc;
00332    SecBuffer         OutSecBuff;
00333    SecBufferDesc     InBuffDesc;
00334    SecBuffer         InSecBuff;
00335    ULONG             ContextAttributes;
00336    PAUTH_SEQ         pAS;
00337    SecPkgContext_Sizes SecPkgContextSizes;
00338    SecPkgContext_NegotiationInfo SecPkgNegInfo;
00339
00340    // Lookup pAS based on Key
00341    //
00342    if (!GetEntry (dwKey, (PVOID*) &pAS))
00343       return(FALSE);
00344
00345    if (pAS->_fNewConversation)  {
00346       ss = AcquireCredentialsHandle (
00347                NULL, // principal
00348                g_lpPackageName,
00349                SECPKG_CRED_INBOUND,
00350                NULL, // LOGON id
00351                NULL, // auth data
00352                NULL, // get key fn
00353                NULL, // get key arg
00354                &pAS->_hcred,
00355                &Lifetime
00356                );
00357       if (SEC_SUCCESS (ss))
00358          pAS->_fHaveCredHandle = TRUE;
00359       else {
00360          fprintf (stderr, "AcquireCreds failed: 0x%08x\n", ss);
00361          return(FALSE);
00362       }
00363    }
00364
00365    // prepare output buffer
00366    //
00367    OutBuffDesc.ulVersion = 0;
00368    OutBuffDesc.cBuffers = 1;
00369    OutBuffDesc.pBuffers = &OutSecBuff;
00370
00371    OutSecBuff.cbBuffer = 0;
00372    OutSecBuff.BufferType = SECBUFFER_TOKEN;
00373    OutSecBuff.pvBuffer = NULL;
00374
00375    // prepare input buffer
00376    //
00377    InBuffDesc.ulVersion = 0;
00378    InBuffDesc.cBuffers = 1;
00379    InBuffDesc.pBuffers = &InSecBuff;
00380
00381    InSecBuff.cbBuffer = cbIn;
00382    InSecBuff.BufferType = SECBUFFER_TOKEN;
00383    InSecBuff.pvBuffer = pIn;
00384
00385    if(g_fVerbose)
00386    {
00387       printf ("token buffer recieved (%lu bytes):\n", InSecBuff.cbBuffer);
00388       PrintHexDump (InSecBuff.cbBuffer, (PBYTE)InSecBuff.pvBuffer);
00389    }
00390
00391    // Always have the package allocate the memory
00392    *pAttribs |= ISC_REQ_ALLOCATE_MEMORY;
00393
00394    ss = AcceptSecurityContext (
00395             &pAS->_hcred,
00396             pAS->_fNewConversation ? NULL : &pAS->_hctxt,
00397             &InBuffDesc,
00398             *pAttribs, // context requirements
00399             SECURITY_NATIVE_DREP,
00400             &pAS->_hctxt,
00401             &OutBuffDesc,
00402             &ContextAttributes,
00403             &Lifetime
00404             );
00405    if (!SEC_SUCCESS (ss))  {
00406       fprintf (stderr, "AcceptSecurityContext failed: 0x%08x\n", ss);
00407       return FALSE;
00408    }
00409
00410    pAS->_fHaveCtxtHandle = TRUE;
00411
00412    // Complete token -- if applicable
00413    //
00414    if ((SEC_I_COMPLETE_NEEDED == ss) || (SEC_I_COMPLETE_AND_CONTINUE == ss))  {
00415       ss = CompleteAuthToken (&pAS->_hctxt, &OutBuffDesc);
00416       if (!SEC_SUCCESS(ss))  {
00417          fprintf (stderr, "complete failed: 0x%08x\n", ss);
00418          return FALSE;
00419       }
00420    }
00421
00422    *pcbOut = OutSecBuff.cbBuffer;
00423    *pOut = (PBYTE)OutSecBuff.pvBuffer;
00424
00425    if (pAS->_fNewConversation)
00426       pAS->_fNewConversation = FALSE;
00427
00428    if(g_fVerbose)
00429    {
00430       printf ("token buffer generated (%lu bytes):\n", OutSecBuff.cbBuffer);
00431       PrintHexDump (OutSecBuff.cbBuffer, (PBYTE)OutSecBuff.pvBuffer);
00432    }
00433
00434
00435    *pfDone = !((SEC_I_CONTINUE_NEEDED == ss) ||
00436             (SEC_I_COMPLETE_AND_CONTINUE == ss));
00437
00438    // find size of token
00439    //
00440    if(*pfDone) {
00441
00442       // find size of signature and trailer blocks
00443       //
00444       ss = QueryContextAttributes(
00445                &pAS->_hctxt,
00446                SECPKG_ATTR_SIZES,
00447                &SecPkgContextSizes );
00448
00449       if (!SEC_SUCCESS(ss))  {
00450          fprintf (stderr, "QueryContextAttributes failed: 0x%08x\n", ss);
00451          return FALSE;
00452       }
00453
00454       // these values are used for encryption and signing
00455       //
00456       pAS->cbMaxSignature = SecPkgContextSizes.cbMaxSignature;
00457       pAS->cbSecurityTrailer = SecPkgContextSizes.cbSecurityTrailer;
00458
00459       // return the attributes we ended up with
00460       //
00461       *pAttribs = ContextAttributes;
00462
00463             // find out what package was negotiated
00464       //
00465       ss = QueryContextAttributes(
00466            &pAS->_hctxt,
00467            SECPKG_ATTR_NEGOTIATION_INFO,
00468            &SecPkgNegInfo );
00469
00470       if (!SEC_SUCCESS(ss))
00471       {
00472          fprintf (stderr, "QueryContextAttributes failed: 0x%08x\n", ss);
00473          return FALSE;
00474       }
00475       else
00476       {
00477          printf("Package Name: %s\n", SecPkgNegInfo.PackageInfo->Name);
00478
00479          // free up the allocated buffer
00480          //
00481          FreeContextBuffer(SecPkgNegInfo.PackageInfo);
00482       }
00483
00484
00485
00486    }
00487
00488    if(g_fVerbose)
00489       printf("AcceptSecurityContext result = 0x%08x\n", ss);
00490
00491    return TRUE;
00492 }
00493
00494 BOOL ImpersonateContext (DWORD dwKey)
00495 /*++
00496
00497  Routine Description:
00498
00499     Impersonates the client whose context is associated with the
00500    supplied key.
00501
00502  Return Value:
00503
00504     Returns TRUE is successful; otherwise FALSE is returned.
00505
00506 --*/
00507 {
00508    SECURITY_STATUS   ss;
00509    PAUTH_SEQ         pAS;
00510
00511    // Lookup pAS based on Key
00512    //
00513    if (!GetEntry (dwKey, (PVOID*) &pAS))
00514       return(FALSE);
00515
00516    ss = ImpersonateSecurityContext (&pAS->_hctxt);
00517    if (!SEC_SUCCESS(ss)) {
00518       fprintf (stderr, "Impersonate failed: 0x%08x\n", ss);
00519       return(FALSE);
00520    }
00521
00522    return(TRUE);
00523 }
00524
00525 BOOL RevertContext (DWORD dwKey)
00526 /*++
00527
00528  Routine Description:
00529
00530     Reverts to the original server context.
00531
00532  Return Value:
00533
00534     Returns TRUE is successful; otherwise FALSE is returned.
00535
00536 --*/
00537 {
00538    SECURITY_STATUS   ss;
00539    PAUTH_SEQ         pAS;
00540
00541    // Lookup pAS based on Key
00542    //
00543    if (!GetEntry (dwKey, (PVOID*) &pAS))
00544       return(FALSE);
00545
00546    ss = RevertSecurityContext (&pAS->_hctxt);
00547    if (!SEC_SUCCESS(ss)) {
00548       fprintf (stderr, "Revert failed: 0x%08x\n", ss);
00549       return(FALSE);
00550    }
00551
00552    return(TRUE);
00553 }
00554
00555 BOOL EncryptThis (
00556          DWORD dwKey,
00557          PBYTE pMessage,
00558          ULONG cbMessage,
00559          BYTE ** ppOutput,
00560          ULONG * pcbOutput)
00561 /*++
00562
00563  Routine Description:
00564
00565     Encrypts a message
00566
00567  Return Value:
00568
00569     Returns TRUE is successful; otherwise FALSE is returned.
00570
00571 --*/
00572 {
00573    SECURITY_STATUS   ss;
00574    PAUTH_SEQ         pAS;
00575    SecBufferDesc     BuffDesc;
00576    SecBuffer         SecBuff[2];
00577    ULONG             ulQop = 0;
00578    ULONG             SigBufferSize;
00579
00580
00581    // Lookup pAS based on Key
00582    //
00583    if (!GetEntry (dwKey, (PVOID*) &pAS))
00584       return(FALSE);
00585
00586    // the size of the trailer (signature + padding) block is
00587    // determined from this value
00588    //
00589    SigBufferSize = pAS->cbSecurityTrailer;
00590
00591    if(g_fVerbose)
00592       printf ("data before encryption: %s\n", pMessage);
00593
00594    // allocate a buffer big enough to hold the
00595    // signature + encrypted data + a dword that
00596    // will tell the other side how big the trailer block is
00597    //
00598    * ppOutput = (PBYTE) malloc (SigBufferSize + cbMessage + sizeof(DWORD));
00599
00600    // prepare buffers
00601    //
00602    BuffDesc.ulVersion = 0;
00603    BuffDesc.cBuffers = 2;
00604    BuffDesc.pBuffers = SecBuff;
00605
00606    SecBuff[0].cbBuffer = SigBufferSize;
00607    SecBuff[0].BufferType = SECBUFFER_TOKEN;
00608    SecBuff[0].pvBuffer = *ppOutput + sizeof(DWORD);
00609
00610    SecBuff[1].cbBuffer = cbMessage;
00611    SecBuff[1].BufferType = SECBUFFER_DATA;
00612    SecBuff[1].pvBuffer = pMessage;
00613
00614
00615    ss = EncryptMessage(
00616       &pAS->_hctxt,
00617       ulQop,
00618       &BuffDesc,
00619       0
00620       );
00621
00622    if (!SEC_SUCCESS(ss)) {
00623       fprintf (stderr, "EncryptMessage failed: 0x%08x\n", ss);
00624       return(FALSE);
00625    }
00626
00627    // indicate in the first DWORD of our output buffer how big
00628    // the trailer block is
00629    //
00630    *((DWORD *) *ppOutput) = SecBuff[0].cbBuffer;
00631
00632    // Here we append the encrypted data to our trailer block
00633    // to form a single block. And yes, it's confusing that we put the trailer
00634    // in the beginning of our data to send to the client, but it worked out
00635    // better that way.
00636    //
00637    memcpy (*ppOutput+SecBuff[0].cbBuffer+sizeof(DWORD), pMessage, cbMessage);
00638
00639    *pcbOutput = cbMessage + SecBuff[0].cbBuffer + sizeof(DWORD);
00640
00641    if(g_fVerbose)
00642    {
00643       printf ("data after encryption including trailer (%lu bytes):\n", *pcbOutput);
00644       PrintHexDump (*pcbOutput, *ppOutput);
00645    }
00646
00647    return TRUE;
00648
00649 }
00650
00651
00652 PBYTE DecryptThis(
00653           DWORD dwKey,
00654           PBYTE pBuffer,
00655           LPDWORD pcbMessage)
00656 /*++
00657
00658  Routine Description:
00659
00660     Decrypts a message
00661
00662  Return Value:
00663
00664     Returns TRUE is successful; otherwise FALSE is returned.
00665
00666 --*/
00667 {
00668    SECURITY_STATUS   ss;
00669    PAUTH_SEQ         pAS;
00670    SecBufferDesc     BuffDesc;
00671    SecBuffer         SecBuff[2];
00672    ULONG             ulQop = 0;
00673    PBYTE             pSigBuffer;
00674    PBYTE             pDataBuffer;
00675    DWORD             SigBufferSize;
00676
00677
00678    // Lookup pAS based on Key
00679    //
00680    if (!GetEntry (dwKey, (PVOID*) &pAS))
00681       return(FALSE);
00682
00683    // When the server encrypted the message it set the size
00684    // of the trailer block to be just what it needed. We have to
00685    // tell DecryptMessage how big the trailer block turned out to be,
00686    // so we sent the size of the trailer as the first dword of the
00687    // message.
00688    //
00689    SigBufferSize = *((DWORD *) pBuffer);
00690
00691    if(g_fVerbose)
00692    {
00693       printf ("data before decryption including trailer (%lu bytes):\n", *pcbMessage);
00694       PrintHexDump (*pcbMessage, (PBYTE) pBuffer);
00695    }
00696
00697    // we know the trailer is at the beginning of the blob
00698    // but after the trailer size dword
00699    //
00700    pSigBuffer = pBuffer + sizeof(DWORD);
00701
00702    // and that the data is after the trailer
00703    //
00704    pDataBuffer = pSigBuffer + SigBufferSize;
00705
00706    // reset the size of the data to reflect just the encrypted blob
00707    //
00708    *pcbMessage = *pcbMessage - SigBufferSize - sizeof(DWORD);
00709
00710    // prepare buffer
00711    //
00712    BuffDesc.ulVersion = 0;
00713    BuffDesc.cBuffers = 2;
00714    BuffDesc.pBuffers = SecBuff;
00715
00716    SecBuff[0].cbBuffer = SigBufferSize;
00717    SecBuff[0].BufferType = SECBUFFER_TOKEN;
00718    SecBuff[0].pvBuffer = pSigBuffer;
00719
00720    SecBuff[1].cbBuffer = *pcbMessage;
00721    SecBuff[1].BufferType = SECBUFFER_DATA;
00722    SecBuff[1].pvBuffer = pDataBuffer;
00723
00724    ss = DecryptMessage(
00725       &pAS->_hctxt,
00726       &BuffDesc,
00727       0,
00728       &ulQop
00729       );
00730
00731    if (!SEC_SUCCESS(ss)) {
00732       fprintf (stderr, "DecryptMessage failed: 0x%08x\n", ss);
00733       return(FALSE);
00734    }
00735
00736    // only return a pointer to the data which we decrypted -
00737    // discard the trailer data
00738    return pDataBuffer;
00739
00740 }
00741
00742 BOOL SignThis (
00743          DWORD dwKey,
00744          PBYTE pMessage,
00745          ULONG cbMessage,
00746          BYTE ** ppOutput,
00747          LPDWORD pcbOutput)
00748
00749 /*++
00750
00751  Routine Description:
00752
00753     Signs a message
00754
00755  Return Value:
00756
00757     Returns TRUE is successful; otherwise FALSE is returned.
00758
00759 --*/
00760 {
00761    SECURITY_STATUS   ss;
00762    PAUTH_SEQ         pAS;
00763    SecBufferDesc     BuffDesc;
00764    SecBuffer         SecBuff[2];
00765    ULONG             ulQop = 0;
00766    PBYTE             pSigBuffer;
00767    DWORD             SigBufferSize;
00768
00769
00770    // Lookup pAS based on Key
00771    //
00772    if (!GetEntry (dwKey, (PVOID*) &pAS))
00773       return(FALSE);
00774
00775    // the size of the signature block is determined from this value
00776    //
00777    SigBufferSize = pAS->cbMaxSignature;
00778
00779    // for reasons apparent later, we are going to allocate
00780    // a buffer big enough to hold the signature + signed data
00781    pSigBuffer = (PBYTE) malloc (SigBufferSize + cbMessage);
00782
00783    // prepare buffers
00784    //
00785    BuffDesc.ulVersion = 0;
00786    BuffDesc.cBuffers = 2;
00787    BuffDesc.pBuffers = SecBuff;
00788
00789    SecBuff[0].cbBuffer = SigBufferSize;
00790    SecBuff[0].BufferType = SECBUFFER_TOKEN;
00791    SecBuff[0].pvBuffer = pSigBuffer;
00792
00793    SecBuff[1].cbBuffer = cbMessage;
00794    SecBuff[1].BufferType = SECBUFFER_DATA;
00795    SecBuff[1].pvBuffer = pMessage;
00796
00797    ss = MakeSignature(
00798       &pAS->_hctxt,
00799       ulQop,
00800       &BuffDesc,
00801       0
00802       );
00803
00804    if (!SEC_SUCCESS(ss)) {
00805       fprintf (stderr, "MakeSignature failed: 0x%08x\n", ss);
00806       return(FALSE);
00807    }
00808
00809    // here we append the signed data to our signature block
00810    // and also reducing the size of our signature buffer if
00811    // the package did not use the size that we provided
00812    //
00813    memcpy (pSigBuffer+SecBuff[0].cbBuffer, pMessage, cbMessage);
00814
00815    // point the data buffer to our new blob and reset the size
00816    //
00817    *ppOutput = pSigBuffer;
00818
00819    *pcbOutput = cbMessage + SecBuff[0].cbBuffer;
00820
00821    if(g_fVerbose)
00822    {
00823       printf ("data after signing including signature (%lu bytes):\n", *pcbOutput);
00824       PrintHexDump (*pcbOutput, *ppOutput);
00825    }
00826
00827    return TRUE;
00828
00829 }
00830
00831
00832 PBYTE VerifyThis(
00833           DWORD   dwKey,
00834           PBYTE   pBuffer,
00835           LPDWORD pcbMessage)
00836 /*++
00837
00838  Routine Description:
00839
00840     Decrypts a message
00841
00842  Return Value:
00843
00844     Returns TRUE is successful; otherwise FALSE is returned.
00845
00846 --*/
00847 {
00848    SECURITY_STATUS   ss;
00849    PAUTH_SEQ         pAS;
00850    SecBufferDesc     BuffDesc;
00851    SecBuffer         SecBuff[2];
00852    ULONG             ulQop = 0;
00853    PBYTE             pSigBuffer;
00854    PBYTE             pDataBuffer;
00855    DWORD             SigBufferSize;
00856
00857    // Lookup pAS based on Key
00858    //
00859    if (!GetEntry (dwKey, (PVOID*) &pAS))
00860       return(FALSE);
00861
00862    // the size of the signature block is determined from this value
00863    //
00864    SigBufferSize = pAS->cbMaxSignature;
00865
00866    if(g_fVerbose)
00867    {
00868       printf ("data before verifying (including signature):\n");
00869       PrintHexDump (*pcbMessage, pBuffer);
00870    }
00871    // we know the signature is at the beginning of the blob
00872    //
00873    pSigBuffer = pBuffer;
00874
00875    // and that the data is after the signature
00876    //
00877    pDataBuffer = pBuffer + SigBufferSize;
00878
00879    // reset the size of the data to reflect just the data
00880    //
00881    *pcbMessage = *pcbMessage - (SigBufferSize);
00882
00883    // prepare buffer
00884    //
00885    BuffDesc.ulVersion = 0;
00886    BuffDesc.cBuffers = 2;
00887    BuffDesc.pBuffers = SecBuff;
00888
00889    SecBuff[0].cbBuffer = SigBufferSize;
00890    SecBuff[0].BufferType = SECBUFFER_TOKEN;
00891    SecBuff[0].pvBuffer = pSigBuffer;
00892
00893    SecBuff[1].cbBuffer = *pcbMessage;
00894    SecBuff[1].BufferType = SECBUFFER_DATA;
00895    SecBuff[1].pvBuffer = pDataBuffer;
00896
00897    ss = VerifySignature(
00898       &pAS->_hctxt,
00899       &BuffDesc,
00900       0,
00901       &ulQop
00902       );
00903
00904    if (!SEC_SUCCESS(ss)) {
00905       fprintf (stderr, "VerifyMessage failed: 0x%08x\n", ss);
00906       return(FALSE);
00907    }
00908    else
00909       printf("Message was properly signed.\n");
00910
00911    return pDataBuffer;
00912
00913 }
00914
00915
00916 BOOL InitSession (DWORD dwKey)
00917 /*++
00918
00919  Routine Description:
00920
00921     Initializes the context associated with a key and adds it to the
00922    collection.
00923
00924  Return Value:
00925
00926     Returns TRUE is successful; otherwise FALSE is returned.
00927
00928 --*/
00929 {
00930    PAUTH_SEQ pAS;
00931
00932    pAS = (PAUTH_SEQ) malloc (sizeof (AUTH_SEQ));
00933    if (NULL == pAS)
00934       return(FALSE);
00935
00936    pAS->_fNewConversation = TRUE;
00937    pAS->_fHaveCredHandle = FALSE;
00938    pAS->_fHaveCtxtHandle = FALSE;
00939
00940    if (!AddEntry (dwKey, (PVOID)pAS))  {
00941       free (pAS);
00942       return(FALSE);
00943    }
00944
00945    return(TRUE);
00946 }
00947
00948 BOOL TermSession (DWORD dwKey)
00949 /*++
00950
00951  Routine Description:
00952
00953     Releases the resources associated with a key and removes it from
00954    the collection.
00955
00956  Return Value:
00957
00958     Returns TRUE is successful; otherwise FALSE is returned.
00959
00960 --*/
00961 {
00962    PAUTH_SEQ pAS;
00963
00964    if (!DeleteEntry (dwKey, (LPVOID*)&pAS))
00965       return(FALSE);
00966
00967    if (pAS->_fHaveCtxtHandle)
00968       DeleteSecurityContext (&pAS->_hctxt);
00969
00970    if (pAS->_fHaveCredHandle)
00971       FreeCredentialHandle (&pAS->_hcred);
00972
00973    free (pAS);
00974
00975    return(TRUE);
00976 }
00977
00978 void PrintHexDump(DWORD length, PBYTE buffer)
00979 {
00980    DWORD i,count,index;
00981    CHAR rgbDigits[]="0123456789abcdef";
00982    CHAR rgbLine[100];
00983    char cbLine;
00984
00985    for(index = 0; length; length -= count, buffer += count, index += count)
00986    {
00987       count = (length > 16) ? 16:length;
00988
00989       sprintf(rgbLine, "%4.4x  ",index);
00990       cbLine = 6;
00991
00992       for(i=0;i<count;i++)
00993       {
00994          rgbLine[cbLine++] = rgbDigits[buffer[i] >> 4];
00995          rgbLine[cbLine++] = rgbDigits[buffer[i] & 0x0f];
00996          if(i == 7)
00997          {
00998             rgbLine[cbLine++] = ':';
00999          }
01000          else
01001          {
01002             rgbLine[cbLine++] = ' ';
01003          }
01004       }
01005       for(; i < 16; i++)
01006       {
01007          rgbLine[cbLine++] = ' ';
01008          rgbLine[cbLine++] = ' ';
01009          rgbLine[cbLine++] = ' ';
01010       }
01011
01012       rgbLine[cbLine++] = ' ';
01013
01014       for(i = 0; i < count; i++)
01015       {
01016          if(buffer[i] < 32 || buffer[i] > 126)
01017          {
01018             rgbLine[cbLine++] = '.';
01019          }
01020          else
01021          {
01022             rgbLine[cbLine++] = buffer[i];
01023          }
01024       }
01025
01026       rgbLine[cbLine++] = 0;
01027       printf("%s\n", rgbLine);
01028    }
01029 }
01030
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/HtmlIFlt.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

HtmlIFlt.Cxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       htmliflt.cxx
00006 //
00007 //  Contents:   Html IFilter
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #include <pch.cxx>
00012 #pragma hdrstop
00013
00014 class CHtmlElement;
00015
00016 #include <eh.h>
00017
00018 #include <htmliflt.hxx>
00019 #include <serstrm.hxx>
00020
00021 #include <bag.hxx>
00022 #include <charhash.hxx>
00023 #include <htmlfilt.hxx>
00024
00025 long gulcInstances = 0;
00026
00027 extern "C" GUID CLSID_HtmlIFilter = {
00028     0xE0CA5340,
00029     0x4534,
00030     0x11CF,
00031     { 0xB9, 0x52, 0x00, 0xAA, 0x00, 0x51, 0xFE, 0x20 }
00032 };
00033
00034 //
00035 // NOTE:  CLSID_HtmlClass is only necessary because real OLE doesn't
00036 //        yet support persistent handlers.
00037 //        When DllGetClassObject is called, real OLE asks for CLSID_HtmlClass,
00038 //        whereas under the persistent handler model, CLSID_HtmlIFilter
00039 //        should be used.
00040 //
00041
00042 extern "C" GUID CLSID_HtmlClass = {
00043     0x6A7A7550,
00044     0x4535,
00045     0x11CF,
00046     { 0xB9, 0x52, 0x00, 0xAA, 0x00, 0x51, 0xFE, 0x20 }
00047 };
00048
00049 //+-------------------------------------------------------------------------
00050 //
00051 //  Method:     CHtmlIFilterBase::CHtmlIFilterBase
00052 //
00053 //  Synopsis:   Base constructor
00054 //
00055 //  Effects:    Manages global refcount
00056 //
00057 //--------------------------------------------------------------------------
00058
00059 CHtmlIFilterBase::CHtmlIFilterBase()
00060 {
00061     _uRefs = 1;
00062     InterlockedIncrement( &gulcInstances );
00063 }
00064
00065 //+-------------------------------------------------------------------------
00066 //
00067 //  Method:     CHtmlIFilterBase::~CHtmlIFilterBase
00068 //
00069 //  Synopsis:   Base destructor
00070 //
00071 //  Effects:    Manages global refcount
00072 //
00073 //--------------------------------------------------------------------------
00074
00075 CHtmlIFilterBase::~CHtmlIFilterBase()
00076 {
00077     InterlockedDecrement( &gulcInstances );
00078 }
00079
00080 //+-------------------------------------------------------------------------
00081 //
00082 //  Method:     CHtmlIFilterBase::QueryInterface
00083 //
00084 //  Synopsis:   Rebind to other interface
00085 //
00086 //  Arguments:  [riid]      -- IID of new interface
00087 //              [ppvObject] -- New interface * returned here
00088 //
00089 //  Returns:    S_OK if bind succeeded, E_NOINTERFACE if bind failed
00090 //
00091 //--------------------------------------------------------------------------
00092
00093 SCODE STDMETHODCALLTYPE CHtmlIFilterBase::QueryInterface( REFIID riid,
00094                                                           void  ** ppvObject)
00095 {
00096     if ( 0 == ppvObject )
00097         return E_INVALIDARG;
00098
00099     *ppvObject = 0;
00100
00101     if ( IID_IPersistFile == riid )
00102         *ppvObject = (IUnknown *)(IPersist *)(IPersistFile *)this;
00103     else if ( IID_IFilter == riid )
00104         *ppvObject = (IUnknown *)(IFilter *)this;
00105     else if ( IID_IPersist == riid )
00106         *ppvObject = (IUnknown *)(IPersist *)(IPersistFile *)this;
00107     else if ( IID_IPersistFile == riid )
00108         *ppvObject = (IUnknown *)(IPersistFile *)this;
00109     else if ( IID_IUnknown  == riid )
00110         *ppvObject = (IUnknown *)(IPersistFile *)this;
00111     else
00112         return E_NOINTERFACE;
00113
00114     AddRef();
00115     return S_OK;
00116 } //QueryInterface
00117
00118 //+-------------------------------------------------------------------------
00119 //
00120 //  Method:     CHtmlIFilterBase::AddRef
00121 //
00122 //  Synopsis:   Increments refcount
00123 //
00124 //--------------------------------------------------------------------------
00125
00126 ULONG STDMETHODCALLTYPE CHtmlIFilterBase::AddRef()
00127 {
00128     return InterlockedIncrement( &_uRefs );
00129 }
00130
00131 //+-------------------------------------------------------------------------
00132 //
00133 //  Method:     CHtmlIFilterBase::Release
00134 //
00135 //  Synopsis:   Decrement refcount.  Delete if necessary.
00136 //
00137 //--------------------------------------------------------------------------
00138
00139 ULONG STDMETHODCALLTYPE CHtmlIFilterBase::Release()
00140 {
00141     unsigned long uTmp = InterlockedDecrement( &_uRefs );
00142
00143     if ( 0 == uTmp )
00144         delete this;
00145
00146     return(uTmp);
00147 }
00148
00149 //+-------------------------------------------------------------------------
00150 //
00151 //  Method:     CHtmlIFilterCF::CHtmlIFilterCF
00152 //
00153 //  Synopsis:   Html IFilter class factory constructor
00154 //
00155 //+-------------------------------------------------------------------------
00156
00157 CHtmlIFilterCF::CHtmlIFilterCF()
00158 {
00159     _uRefs = 1;
00160     InterlockedIncrement( &gulcInstances );
00161 }
00162
00163 //+-------------------------------------------------------------------------
00164 //
00165 //  Method:     CHtmlIFilterCF::~CHtmlIFilterCF
00166 //
00167 //  Synopsis:   Html IFilter class factory destructor
00168 //
00169 //  History:    1-Jan-1996    SitaramR    Created
00170 //
00171 //--------------------------------------------------------------------------
00172
00173 CHtmlIFilterCF::~CHtmlIFilterCF()
00174 {
00175     InterlockedDecrement( &gulcInstances );
00176 }
00177
00178 //+-------------------------------------------------------------------------
00179 //
00180 //  Method:     CHtmlIFilterCF::QueryInterface
00181 //
00182 //  Synopsis:   Rebind to other interface
00183 //
00184 //  Arguments:  [riid]      -- IID of new interface
00185 //              [ppvObject] -- New interface * returned here
00186 //
00187 //  Returns:    S_OK if bind succeeded, E_NOINTERFACE if bind failed
00188 //
00189 //--------------------------------------------------------------------------
00190
00191 SCODE STDMETHODCALLTYPE CHtmlIFilterCF::QueryInterface( REFIID riid,
00192                                                         void  ** ppvObject )
00193 {
00194     if ( 0 == ppvObject )
00195         return E_INVALIDARG;
00196
00197     *ppvObject = 0;
00198
00199     if ( IID_IClassFactory == riid )
00200         *ppvObject = (IUnknown *)(IClassFactory *)this;
00201     else if ( IID_IUnknown  == riid )
00202         *ppvObject = (IUnknown *)this;
00203     else
00204         return E_NOINTERFACE;
00205
00206     AddRef();
00207     return S_OK;
00208 } //QueryInterface
00209
00210 //+-------------------------------------------------------------------------
00211 //
00212 //  Method:     CHtmlIFilterCF::AddRef
00213 //
00214 //  Synopsis:   Increments refcount
00215 //
00216 //--------------------------------------------------------------------------
00217
00218 ULONG STDMETHODCALLTYPE CHtmlIFilterCF::AddRef()
00219 {
00220     return InterlockedIncrement( &_uRefs );
00221 }
00222
00223 //+-------------------------------------------------------------------------
00224 //
00225 //  Method:     CHtmlIFilterCF::Release
00226 //
00227 //  Synopsis:   Decrement refcount.  Delete if necessary.
00228 //
00229 //--------------------------------------------------------------------------
00230
00231 ULONG STDMETHODCALLTYPE CHtmlIFilterCF::Release()
00232 {
00233     unsigned long uTmp = InterlockedDecrement( &_uRefs );
00234
00235     if ( 0 == uTmp )
00236         delete this;
00237
00238     return(uTmp);
00239 }
00240
00241
00242 //+-------------------------------------------------------------------------
00243 //
00244 //  Method:     CHtmlIFilterCF::CreateInstance
00245 //
00246 //  Synopsis:   Creates new HtmlIFilter object
00247 //
00248 //  Arguments:  [pUnkOuter] -- 'Outer' IUnknown
00249 //              [riid]      -- Interface to bind
00250 //              [ppvObject] -- Interface returned here
00251 //
00252 //--------------------------------------------------------------------------
00253
00254 SCODE STDMETHODCALLTYPE CHtmlIFilterCF::CreateInstance( IUnknown * pUnkOuter,
00255                                                         REFIID riid,
00256                                                         void  * * ppvObject )
00257 {
00258     CHtmlIFilter *  pIUnk = 0;
00259     SCODE sc = S_OK;
00260
00261     _se_translator_function tf = _set_se_translator( SystemExceptionTranslator );
00262
00263     try
00264     {
00265         pIUnk = newk(mtNewX, NULL) CHtmlIFilter();
00266         sc = pIUnk->QueryInterface(  riid , ppvObject );
00267
00268         if( SUCCEEDED(sc) )
00269             pIUnk->Release();  // Release extra refcount from QueryInterface
00270     }
00271     catch(CException& e)
00272     {
00273         Win4Assert( 0 == pIUnk );
00274
00275         htmlDebugOut(( DEB_ERROR,
00276                        "Exception 0x%x caught in CHtmlIFilterCF::CreateInstance",
00277                        e.GetErrorCode() ));
00278         sc = GetOleError( e );
00279     }
00280
00281     _set_se_translator( tf );
00282
00283     return (sc);
00284 }
00285
00286 //+-------------------------------------------------------------------------
00287 //
00288 //  Method:     CHtmlIFilterCF::LockServer
00289 //
00290 //  Synopsis:   Force class factory to remain loaded
00291 //
00292 //  Arguments:  [fLock] -- TRUE if locking, FALSE if unlocking
00293 //
00294 //  Returns:    S_OK
00295 //
00296 //--------------------------------------------------------------------------
00297
00298 SCODE STDMETHODCALLTYPE CHtmlIFilterCF::LockServer(BOOL fLock)
00299 {
00300     if(fLock)
00301         InterlockedIncrement( &gulcInstances );
00302     else
00303         InterlockedDecrement( &gulcInstances );
00304
00305     return(S_OK);
00306 }
00307
00308 //+-------------------------------------------------------------------------
00309 //
00310 //  Function:   DllGetClassObject
00311 //
00312 //  Synopsis:   Ole DLL load class routine
00313 //
00314 //  Arguments:  [cid]    -- Class to load
00315 //              [iid]    -- Interface to bind to on class object
00316 //              [ppvObj] -- Interface pointer returned here
00317 //
00318 //  Returns:    Html filter class factory
00319 //
00320 //--------------------------------------------------------------------------
00321
00322 extern "C" SCODE STDMETHODCALLTYPE DllGetClassObject( REFCLSID   cid,
00323                                                       REFIID     iid,
00324                                                       void **    ppvObj )
00325 {
00326     IUnknown *  pResult = 0;
00327     SCODE       sc      = S_OK;
00328
00329     _se_translator_function tf = _set_se_translator( SystemExceptionTranslator );
00330
00331     try
00332     {
00333         if ( cid == CLSID_HtmlIFilter || cid == CLSID_HtmlClass )
00334             pResult = (IUnknown *) newk(mtNewX, NULL) CHtmlIFilterCF;
00335         else
00336             sc = E_NOINTERFACE;
00337
00338         if ( pResult )
00339         {
00340             sc = pResult->QueryInterface( iid, ppvObj );
00341             pResult->Release();     // Release extra refcount from QueryInterface
00342         }
00343     }
00344     catch(CException& e)
00345     {
00346         if ( pResult )
00347             pResult->Release();
00348
00349         htmlDebugOut(( DEB_ERROR,
00350                        "Exception 0x%x caught in CHtmlIFilterCF::CreateInstance",
00351                        e.GetErrorCode() ));
00352         sc = GetOleError( e );
00353     }
00354
00355     _set_se_translator( tf );
00356
00357     return (sc);
00358 }
00359
00360 //+-------------------------------------------------------------------------
00361 //
00362 //  Method:     DllCanUnloadNow
00363 //
00364 //  Synopsis:   Notifies DLL to unload (cleanup global resources)
00365 //
00366 //  Returns:    S_OK if it is acceptable for caller to unload DLL.
00367 //
00368 //--------------------------------------------------------------------------
00369
00370 extern "C" SCODE STDMETHODCALLTYPE DllCanUnloadNow( void )
00371 {
00372     if ( 0 == gulcInstances )
00373         return( S_OK );
00374     else
00375         return( S_FALSE );
00376 }
00377
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagPROPSTRUCT Member List

This is the complete list of members for _tagPROPSTRUCT, including all inherited members.
boolVal | _tagPROPSTRUCT
dwFlags | _tagPROPSTRUCT
dwPropertyID | _tagPROPSTRUCT
longVal | _tagPROPSTRUCT
pwstrDescBuffer | _tagPROPSTRUCT
pwstrVal | _tagPROPSTRUCT
vtType | _tagPROPSTRUCT
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/SampleMSP/Common.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • SampleMSP

Common.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     common.h
00008
00009 Abstract:
00010
00011     commonly used headers.
00012 --*/
00013
00014 #ifndef __COMMON_H_
00015 #define __COMMON_H_
00016
00017 #include <mmsystem.h>
00018 #include <mmreg.h>
00019 #include <evcode.h>
00020
00021 #include "sampmsp.h"
00022 #include "sampaddr.h"
00023 #include "sampstrm.h"
00024 #include "sampcall.h"
00025
00026 #endif
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/SampleFSP/NewFsp.c Source File

  • NetDS
  • fax
  • SampleFSP

NewFsp.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1997 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007   newfsp.c
00008
00009 Abstract:
00010
00011   This module implements a sample Windows NT Fax Service Provider
00012
00013 --*/
00014
00015 #include "newfsp.h"
00016 #include <tchar.h>
00017
00018 HANDLE  g_HeapHandle = NULL;
00019
00020 // DeviceReceiveThread() is a thread to watch for an incoming fax transmission
00021 DWORD WINAPI DeviceReceiveThread(LPDWORD pdwDeviceId);
00022
00023 BOOL WINAPI
00024 DllEntryPoint(
00025     HINSTANCE  hInstance,
00026     DWORD      dwReason,
00027     LPVOID     pContext
00028 )
00029 /*++
00030
00031 Routine Description:
00032
00033   DLL entry-point function
00034
00035 Arguments:
00036
00037   hInstance - handle to the DLL
00038   dwReason - specifies a flag indicating why the DLL entry-point function is being called
00039
00040 Return Value:
00041
00042   TRUE on success
00043
00044 --*/
00045 {
00046     // pDeviceInfo is a pointer to the virtual fax devices
00047     PDEVICE_INFO  pDeviceInfo;
00048     // pCurrentDeviceInfo is a pointer to the current virtual fax device
00049     PDEVICE_INFO  pCurrentDeviceInfo;
00050
00051     if (dwReason == DLL_PROCESS_ATTACH) {
00052         // Set g_hInstance
00053         g_hInstance = hInstance;
00054
00055         // Disable the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the DLL
00056         DisableThreadLibraryCalls(hInstance);
00057     }
00058     else if (dwReason == DLL_PROCESS_DETACH) {
00059         if (g_pDeviceInfo != NULL) {
00060             // Enumerate the virtual fax devices
00061             for (pCurrentDeviceInfo = g_pDeviceInfo[0]; pCurrentDeviceInfo; pCurrentDeviceInfo = pDeviceInfo) {
00062                 pDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo;
00063
00064                 if (pCurrentDeviceInfo->ExitEvent) {
00065                     // Set the event to indicate the thread to watch for an incoming fax transmission is to exit
00066                     SetEvent(pCurrentDeviceInfo->ExitEvent);
00067                 }
00068
00069                 // Delete the critical section
00070                 DeleteCriticalSection(&pCurrentDeviceInfo->cs);
00071                 // Delete the virtual fax device data
00072                 MemFreeMacro(pCurrentDeviceInfo);
00073             }
00074
00075             g_pDeviceInfo = NULL;
00076         }
00077
00078         // Close the log file
00079         CloseLogFile();
00080     }
00081
00082     return TRUE;
00083 }
00084
00085 BOOL WINAPI
00086 FaxDevVirtualDeviceCreation(
00087     OUT LPDWORD    DeviceCount,
00088     OUT LPWSTR     DeviceNamePrefix,
00089     OUT LPDWORD    DeviceIdPrefix,
00090     IN  HANDLE     CompletionPort,
00091     IN  ULONG_PTR  CompletionKey
00092 )
00093 /*++
00094
00095 Routine Description:
00096
00097   The fax service calls the FaxDevVirtualDeviceCreation function during initialization to allow the fax service provider to present virtual fax devices
00098
00099 Arguments:
00100
00101   DeviceCount - pointer to a variable that receives the number of virtual fax devices the fax service must create for the fax service provider
00102   DeviceNamePrefix - pointer to a variable that receives a string of the name prefix for the virtual fax devices
00103   DeviceIdPrefix - pointer to a variable that receives a unique numeric value that identifies the virtual fax devices
00104   CompletionPort - specifies a handle to an I/O completion port that the fax service provider must use to post I/O completion port packets to the fax service for asynchronous line status events
00105   CompletionKey - specifies a completion port key value
00106
00107 Return Value:
00108
00109   TRUE on success
00110
00111 --*/
00112 {
00113     BOOL  bReturnValue;
00114
00115     WriteDebugString(L"---SampleFSP: FaxDevVirtualDeviceCreation Enter---\n");
00116
00117     // Initialize the parameters
00118     *DeviceCount = 0;
00119     ZeroMemory(DeviceNamePrefix, 128 * sizeof(WCHAR));
00120     *DeviceIdPrefix = 0;
00121
00122     // Copy the handle to the completion port
00123     g_CompletionPort = CompletionPort;
00124     g_CompletionKey = CompletionKey;
00125
00126     // Get the registry data for the newfsp service provider
00127     bReturnValue = GetNewFspRegistryData(NULL,
00128                      NULL,
00129                      0,
00130                      NULL,
00131                      DeviceCount);
00132
00133     if (bReturnValue == FALSE) {
00134         WriteDebugString(L"   ERROR: GetNewFspRegistryData Failed: 0x%08x\n", GetLastError());
00135         WriteDebugString(L"   ERROR: FaxDevVirtualDeviceCreation Failed\n");
00136         WriteDebugString(L"---SampleFSP: FaxDevVirtualDeviceCreation Exit---\n");
00137
00138         return FALSE;
00139     }
00140
00141     if (*DeviceCount == 0) {
00142         WriteDebugString(L"   ERROR: No Virtual Fax Devices Installed\n");
00143         WriteDebugString(L"   ERROR: FaxDevVirtualDeviceCreation Failed\n");
00144         WriteDebugString(L"---SampleFSP: FaxDevVirtualDeviceCreation Exit---\n");
00145
00146         return FALSE;
00147     }
00148
00149     // Copy the name prefix for the virtual fax devices, limited to 128 WCHARs including the termininating null character
00150     lstrcpyn(DeviceNamePrefix, NEWFSP_DEVICE_NAME_PREFIX, 128);
00151     // Copy the values that identifies the virtual fax devices
00152     *DeviceIdPrefix = NEWFSP_DEVICE_ID_PREFIX;
00153
00154     WriteDebugString(L"---SampleFSP: FaxDevVirtualDeviceCreation Exit---\n");
00155
00156     return TRUE;
00157 }
00158
00159 VOID CALLBACK
00160 FaxLineCallback(
00161     IN HANDLE     FaxHandle,
00162     IN DWORD      hDevice,
00163     IN DWORD      dwMessage,
00164     IN DWORD_PTR  dwInstance,
00165     IN DWORD_PTR  dwParam1,
00166     IN DWORD_PTR  dwParam2,
00167     IN DWORD_PTR  dwParam3
00168 )
00169 /*++
00170
00171 Routine Description:
00172
00173   An application-defined callback function that the fax service calls to deliver TAPI events to the fax service provider
00174
00175 Arguments:
00176
00177   FaxHandle - specifies a fax handle returned by the FaxDevStartJob function
00178   hDevice - specifies a handle to either a line device or a call device
00179   dwMessage - specifies a line device or a call device message
00180   dwInstance - specifies job-specific instance data passed back to the application
00181   dwParam1 - specifies a parameter for this message
00182   dwParam2 - specifies a parameter for this message
00183   dwParam3 - specifies a parameter for this message
00184
00185 Return Value:
00186
00187   TRUE on success
00188
00189 --*/
00190 {
00191     // pdwDeviceId is the pointer to the virtual fax device identifier
00192     LPDWORD   pdwDeviceId;
00193     // hThread is a handle to the thread to watch for an incoming fax transmission
00194     HANDLE    hThread;
00195
00196     WriteDebugString(L"---SampleFSP: fnFaxLineCallback Enter---\n");
00197
00198     // Wait for access to this virtual fax device
00199     EnterCriticalSection(&g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->cs);
00200
00201     if ((dwParam1 == 0) && (g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent)) {
00202         // Receive has been disabled for this virtual fax device so set the event to indicate the thread to watch for an incoming fax transmission is to exit
00203         SetEvent(g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent);
00204         g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent = NULL;
00205     }
00206     else if ((dwParam1 != 0) && (g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent == NULL)) {
00207         // Allocate a block of memory for the virtual fax device identifier
00208         pdwDeviceId = MemAllocMacro(sizeof(DWORD));
00209         if (pdwDeviceId != NULL) {
00210             // Copy the virtual fax device identifier
00211             *pdwDeviceId = (hDevice - NEWFSP_DEVICE_ID_PREFIX);
00212
00213             // Receive has been enabled for this virtual fax device so create the thread to watch for an incoming fax transmission
00214             g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent = CreateEvent(NULL,
00215                                             TRUE,
00216                                             FALSE,
00217                                             NULL);
00218             if (g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent != NULL) {
00219                 hThread = CreateThread(NULL,
00220                      0,
00221                      DeviceReceiveThread,
00222                      pdwDeviceId,
00223                      0,
00224                      NULL);
00225                 if (hThread != NULL) {
00226                     // Close the handle to the thread
00227                     CloseHandle(hThread);
00228                 }
00229                 else {
00230                     // Close the handle to the exit event
00231                     CloseHandle(g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent);
00232                     g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->ExitEvent = NULL;
00233                 }
00234             }
00235         }
00236     }
00237
00238     // Release access to this virtual fax device
00239     LeaveCriticalSection(&g_pDeviceInfo[hDevice - NEWFSP_DEVICE_ID_PREFIX]->cs);
00240
00241     WriteDebugString(L"---SampleFSP: fnFaxLineCallback Exit---\n");
00242
00243     return;
00244 }
00245
00246 BOOL WINAPI
00247 FaxDevInitialize(
00248     IN  HLINEAPP               LineAppHandle,
00249     IN  HANDLE                 HeapHandle,
00250     OUT PFAX_LINECALLBACK      *LineCallbackFunction,
00251     IN  PFAX_SERVICE_CALLBACK  FaxServiceCallback
00252 )
00253 /*++
00254
00255 Routine Description:
00256
00257   The fax service calls the FaxDevInitialize function each time the service starts to initialize communication
00258   between the fax service and the fax service provider DLL
00259
00260 Arguments:
00261
00262   LineAppHandle - specifies a handle to the fax service's registration with TAPI
00263   HeapHandle - specifies a handle to a heap that the fax service provider must use for all memory allocations
00264   LineCallbackFunction - pointer to a variable that receives a pointer to a TAPI line callback function
00265   FaxServiceCallback - pointer to a service callback function
00266
00267 Return Value:
00268
00269   TRUE on success
00270
00271 --*/
00272 {
00273     // bLoggingEnabled indicates if logging is enabled
00274     BOOL          bLoggingEnabled;
00275     // szLoggingDirectory indicates the logging directory
00276     WCHAR         szLoggingDirectory[MAX_PATH_LEN];
00277     // pDeviceInfo is a pointer to the virtual fax devices
00278     PDEVICE_INFO  pDeviceInfo;
00279     // pCurrentDeviceInfo is a pointer to the current virtual fax device
00280     PDEVICE_INFO  pCurrentDeviceInfo;
00281     // dwNumDevices is the number of virtual fax devices
00282     DWORD         dwNumDevices;
00283     // dwIndex is a counter to enumerate each virtual fax device
00284     DWORD         dwIndex;
00285     // bReturnValue is the value to return to the fax service
00286     BOOL          bReturnValue;
00287
00288     WriteDebugString(L"---SampleFSP: FaxDevInitialize Enter---\n");
00289
00290     // Set g_hLineApp
00291     g_LineAppHandle = LineAppHandle;
00292
00293     // Set g_hHeap
00294     MemInitializeMacro(HeapHandle);
00295
00296     // Set LineCallbackFunction
00297     *LineCallbackFunction = FaxLineCallback;
00298
00299     // Get the registry data for the newfsp service provider
00300     bLoggingEnabled = FALSE;
00301     ZeroMemory(szLoggingDirectory, sizeof(szLoggingDirectory));
00302     pDeviceInfo = NULL;
00303     dwNumDevices = 0;
00304     bReturnValue = GetNewFspRegistryData(&bLoggingEnabled,
00305                      szLoggingDirectory,
00306                      sizeof(szLoggingDirectory)/sizeof(szLoggingDirectory[0]),
00307                      &pDeviceInfo,
00308                      &dwNumDevices);
00309
00310     if (bReturnValue == FALSE) {
00311         WriteDebugString(L"   ERROR: GetNewFspRegistryData Failed: 0x%08x\n", GetLastError());
00312         WriteDebugString(L"   ERROR: FaxDevInitialize Failed\n");
00313         WriteDebugString(L"---SampleFSP: FaxDevInitialize Exit---\n");
00314
00315         return FALSE;
00316     }
00317
00318     if (dwNumDevices == 0) {
00319         WriteDebugString(L"   ERROR: No Virtual Fax Devices Installed\n");
00320         WriteDebugString(L"   ERROR: FaxDevInitialize Failed\n");
00321         WriteDebugString(L"---SampleFSP: FaxDevInitialize Exit---\n");
00322
00323         return FALSE;
00324     }
00325
00326     // Open the log file
00327     bReturnValue = OpenLogFile(bLoggingEnabled, szLoggingDirectory);
00328
00329     if (dwNumDevices > 0) {
00330         // Allocate a block of memory for the virtual fax device data
00331         g_pDeviceInfo = MemAllocMacro(sizeof(PDEVICE_INFO) * dwNumDevices);
00332         if (g_pDeviceInfo == NULL) {
00333             // Set the error code
00334             SetLastError(ERROR_NOT_ENOUGH_MEMORY);
00335
00336             // Enumerate the virtual fax devices
00337             for (pCurrentDeviceInfo = pDeviceInfo; pCurrentDeviceInfo; pCurrentDeviceInfo = pDeviceInfo) {
00338                 // Delete the virtual fax device data
00339                 pDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo;
00340                 MemFreeMacro(pCurrentDeviceInfo);
00341             }
00342
00343             WriteDebugString(L"   ERROR: FaxDevInitialize Failed: ERROR_NOT_ENOUGH_MEMORY\n");
00344             WriteDebugString(L"---SampleFSP: FaxDevInitialize Exit---\n");
00345
00346             return FALSE;
00347         }
00348     }
00349     else {
00350         g_pDeviceInfo = NULL;
00351     }
00352
00353     // Marshall the virtual fax devices
00354     for (pCurrentDeviceInfo = pDeviceInfo, dwIndex = 0;
00355      pCurrentDeviceInfo;
00356      pCurrentDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo, dwIndex++) {
00357         g_pDeviceInfo[dwIndex] = pCurrentDeviceInfo;
00358
00359         // Initialize the virtual fax device's critical section
00360         InitializeCriticalSection(&g_pDeviceInfo[dwIndex]->cs);
00361         // Initialize the virtual fax device's status to idle
00362         g_pDeviceInfo[dwIndex]->Status = DEVICE_IDLE;
00363         // Initialize the virtual fax device's handle to the exit event
00364         g_pDeviceInfo[dwIndex]->ExitEvent = NULL;
00365         // Initialize the virtual fax device's associated fax job
00366         g_pDeviceInfo[dwIndex]->pJobInfo = NULL;
00367     }
00368
00369     WriteDebugString(L"---SampleFSP: FaxDevInitialize Exit---\n");
00370
00371     return TRUE;
00372 }
00373
00374 BOOL WINAPI
00375 FaxDevStartJob(
00376     IN  HLINE      LineHandle,
00377     IN  DWORD      DeviceId,
00378     OUT PHANDLE    FaxHandle,
00379     IN  HANDLE     CompletionPortHandle,
00380     IN  ULONG_PTR  CompletionKey
00381 )
00382 /*++
00383
00384 Routine Description:
00385
00386   The fax service calls the FaxDevStartJob function to initialize a new fax job
00387
00388 Arguments:
00389
00390   LineHandle - specifies a handle to the open line device associated with the fax job
00391   DeviceId - specifies the TAPI line device identifier associated with the fax job
00392   FaxHandle - pointer to a variable that receives a fax handle associated with the fax job
00393   CompltionPortHandle - specifies a handle to an I/O completion port
00394   CompletionKey - specifies a completion port key value
00395
00396 Return Value:
00397
00398   TRUE on success
00399
00400 --*/
00401 {
00402     // pJobInfo is a pointer to the fax job data
00403     PJOB_INFO  pJobInfo;
00404
00405     WriteDebugString(L"---SampleFSP: FaxDevStartJob Enter---\n");
00406
00407     // Initialize the parameters
00408     *FaxHandle = NULL;
00409
00410     // Allocate a block of memory for the fax job instance data
00411     pJobInfo = MemAllocMacro(sizeof(JOB_INFO));
00412     if (pJobInfo == NULL) {
00413         // Set the error code
00414         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
00415
00416         WriteDebugString(L"   ERROR: FaxDevStartJob Failed: ERROR_NOT_ENOUGH_MEMORY\n");
00417         WriteDebugString(L"---SampleFSP: FaxDevStartJob Exit---\n");
00418         return FALSE;
00419     }
00420
00421     // Set the FaxHandle
00422     *FaxHandle = (PHANDLE) pJobInfo;
00423
00424     // Wait for access to this virtual fax device
00425     EnterCriticalSection(&g_pDeviceInfo[DeviceId]->cs);
00426
00427     // Initialize the fax job data
00428     // Set the fax job's associated virtual fax device
00429     pJobInfo->pDeviceInfo = g_pDeviceInfo[DeviceId];
00430     // Copy the handle to the I/O completion port
00431     pJobInfo->CompletionPortHandle = CompletionPortHandle;
00432     // Copy the completion port key value
00433     pJobInfo->CompletionKey = CompletionKey;
00434     // Initialize the fax job type
00435     pJobInfo->JobType = JOB_UNKNOWN;
00436     // Set the fax job status to FS_INITIALIZING
00437     pJobInfo->Status = FS_INITIALIZING;
00438     // Copy the handle to the open line device associated with the fax job
00439     pJobInfo->LineHandle = LineHandle;
00440     // Initialize the handle to the active call associated with the fax job
00441     pJobInfo->CallHandle = (HCALL) 0;
00442     // Initialize the full path to the file that contains the data stream for the fax document
00443     pJobInfo->FileName = NULL;
00444     // Initialize the name of the calling device
00445     pJobInfo->CallerName = NULL;
00446     // Initialize the telephone number of the calling device
00447     pJobInfo->CallerNumber = NULL;
00448     // Initialize name of the receiving device
00449     pJobInfo->ReceiverName = NULL;
00450     // Initialize telephone number of the receiving device
00451     pJobInfo->ReceiverNumber = NULL;
00452     // Initialize number of retries associated with the fax job
00453     pJobInfo->RetryCount = 0;
00454     // Initialize whether the fax service provider should generate a brand at the top of the fax transmission
00455     pJobInfo->Branding = FALSE;
00456     // Initialize the number of pages associated with the fax job
00457     pJobInfo->PageCount = 0;
00458     // Initialize the identifier of the remote fax device
00459     pJobInfo->CSI = NULL;
00460     // Initialize the identifier of the calling fax device
00461     pJobInfo->CallerId = NULL;
00462     // Initialize the routing string associated with the fax job
00463     pJobInfo->RoutingInfo = NULL;
00464
00465     // Set the virtual fax device status
00466     g_pDeviceInfo[DeviceId]->Status = DEVICE_START;
00467     // Set the virtual fax device's associated fax job
00468     g_pDeviceInfo[DeviceId]->pJobInfo = pJobInfo;
00469
00470     // Release access to this virtual fax device
00471     LeaveCriticalSection(&g_pDeviceInfo[DeviceId]->cs);
00472
00473     WriteDebugString(L"---SampleFSP: FaxDevStartJob Exit---\n");
00474
00475     return TRUE;
00476 }
00477
00478 BOOL WINAPI
00479 FaxDevEndJob(
00480     IN HANDLE  FaxHandle
00481 )
00482 /*++
00483
00484 Routine Description:
00485
00486   The fax service calls the FaxDevEndJob function after the last operation in a fax job
00487
00488 Arguments:
00489
00490   FaxHandle - specifies a fax handle returned by the FaxDevStartJob function
00491
00492 Return Value:
00493
00494   TRUE on success
00495
00496 --*/
00497 {
00498     // pJobInfo is a pointer to the fax job data
00499     PJOB_INFO     pJobInfo;
00500     // pDeviceInfo is a pointer to the virtual fax device data
00501     PDEVICE_INFO  pDeviceInfo;
00502
00503     WriteDebugString(L"---SampleFSP: FaxDevEndJob Enter---\n");
00504
00505     if (FaxHandle == NULL) {
00506         // Set the error code
00507         SetLastError(ERROR_INVALID_HANDLE);
00508
00509         WriteDebugString(L"   ERROR: FaxDevEndJob Failed: ERROR_INVALID_HANDLE\n");
00510         WriteDebugString(L"---SampleFSP: FaxDevEndJob Exit---\n");
00511         return FALSE;
00512     }
00513
00514     // Get the fax job data from FaxHandle
00515     pJobInfo = (PJOB_INFO) FaxHandle;
00516     // Get the virtual fax device data from the fax job data
00517     pDeviceInfo = (PDEVICE_INFO) pJobInfo->pDeviceInfo;
00518
00519     // Wait for access to this virtual fax device
00520     EnterCriticalSection(&pDeviceInfo->cs);
00521
00522     // Free the fax job data
00523     // Free the full path to the file that contains the data stream for the fax document
00524     if (pJobInfo->FileName != NULL) {
00525         MemFreeMacro(pJobInfo->FileName);
00526     }
00527     // Free the name of the calling device
00528     if (pJobInfo->CallerName != NULL) {
00529         MemFreeMacro(pJobInfo->CallerName);
00530     }
00531     // Free the telephone number of the calling device
00532     if (pJobInfo->CallerNumber != NULL) {
00533         MemFreeMacro(pJobInfo->CallerNumber);
00534     }
00535     // Free name of the receiving device
00536     if (pJobInfo->ReceiverName != NULL) {
00537         MemFreeMacro(pJobInfo->ReceiverName);
00538     }
00539     // Free telephone number of the receiving device
00540     if (pJobInfo->ReceiverNumber != NULL) {
00541         MemFreeMacro(pJobInfo->ReceiverNumber);
00542     }
00543     // Free the identifier of the remote fax device
00544     if (pJobInfo->CSI != NULL) {
00545         MemFreeMacro(pJobInfo->CSI);
00546     }
00547     // Free the identifier of the calling fax device
00548     if (pJobInfo->CallerId != NULL) {
00549         MemFreeMacro(pJobInfo->CallerId);
00550     }
00551     // Free the routing string associated with the fax job
00552     if (pJobInfo->RoutingInfo != NULL) {
00553         MemFreeMacro(pJobInfo->RoutingInfo);
00554     }
00555     // Free the fax job data
00556     MemFreeMacro(pJobInfo);
00557
00558     // Set the virtual fax device status
00559     pDeviceInfo->Status = DEVICE_IDLE;
00560     // Initialize the virtual fax device's associated fax job
00561     pDeviceInfo->pJobInfo = NULL;
00562
00563     // Release access to this virtual fax device
00564     LeaveCriticalSection(&pDeviceInfo->cs);
00565
00566     WriteDebugString(L"---SampleFSP: FaxDevEndJob Exit---\n");
00567
00568     return TRUE;
00569 }
00570
00571 BOOL WINAPI
00572 FaxDevSend(
00573     IN HANDLE              FaxHandle,
00574     IN PFAX_SEND           FaxSend,
00575     IN PFAX_SEND_CALLBACK  FaxSendCallback
00576 )
00577 /*++
00578
00579 Routine Description:
00580
00581   The fax service calls the FaxDevSend function to signal a fax service provider that it must initiate an outgoing
00582   fax transmission
00583
00584 Arguments:
00585
00586   FaxHandle - specifies a fax handle returned by the FaxDevStartJob function
00587   FaxSend - pointer to a FAX_SEND structure that contains the sending information
00588   FaxSendCallback - pointer to a callback function that notifies the fax service of the call handle that TAPI assigns
00589
00590 Return Value:
00591
00592   TRUE on success
00593
00594 --*/
00595 {
00596     // pJobInfo is a pointer to the fax job data
00597     PJOB_INFO     pJobInfo;
00598     // pDeviceInfo is a pointer to the virtual fax device data
00599     PDEVICE_INFO  pDeviceInfo;
00600
00601     // dwReceiverNumberAttributes is the file attributes of the directory specified in the telephone number of the receiving device
00602     DWORD         dwReceiverNumberAttributes;
00603
00604     // hSourceFile is the handle to the source file
00605     HANDLE        hSourceFile = INVALID_HANDLE_VALUE;
00606     // szSourceName is the source filename name
00607     WCHAR         szSourceName[_MAX_FNAME];
00608     // szSourceExt is the source filename extension
00609     WCHAR         szSourceExt[_MAX_EXT];
00610
00611     // hDestinationFile is the handle to the destination file
00612     HANDLE        hDestinationFile = INVALID_HANDLE_VALUE;
00613     // szDestinationFilename is the destination filename
00614     WCHAR         szDestinationFilename[MAX_PATH_LEN + _MAX_FNAME + 6];
00615   // szDeviceFolder is the associated device folder.
00616   WCHAR         szDeviceFolder[MAX_PATH_LEN];
00617
00618     // FileBytes is the bytes to be copied from the source file to the destination file
00619     BYTE          FileBytes[1024];
00620     // dwBytes is the number of bytes read from the source file
00621     DWORD         dwBytes;
00622   //iDestinationDevice is the destination device
00623   int iDestinationDevice;
00624
00625     WriteDebugString(L"---SampleFSP: FaxDevSend Enter---\n");
00626
00627     if (FaxHandle == NULL) {
00628         // Set the error code
00629         SetLastError(ERROR_INVALID_HANDLE);
00630
00631         WriteDebugString(L"   ERROR: FaxDevSend Failed: ERROR_INVALID_HANDLE\n");
00632         WriteDebugString(L"---SampleFSP: FaxDevSend Exit---\n");
00633         return FALSE;
00634     }
00635
00636     // Get the fax job data from FaxHandle
00637     pJobInfo = (PJOB_INFO) FaxHandle;
00638     // Get the virtual fax device data from the fax job data
00639     pDeviceInfo = (PDEVICE_INFO) pJobInfo->pDeviceInfo;
00640
00641     // Wait for access to this virtual fax device
00642     EnterCriticalSection(&pDeviceInfo->cs);
00643
00644     if (pDeviceInfo->Status == DEVICE_ABORTING) {
00645         goto ExitUserAbort;
00646     }
00647
00648     // Set the virtual fax device status
00649     pDeviceInfo->Status = DEVICE_SEND;
00650
00651     // Set the fax job type
00652     pJobInfo->JobType = JOB_SEND;
00653     // Copy the handle to the active call associated with the fax job
00654     pJobInfo->CallHandle = FaxSend->CallHandle;
00655     // Copy the full path to the file that contains the data stream for the fax document
00656     if (FaxSend->FileName != NULL) {
00657         pJobInfo->FileName = MemAllocMacro((lstrlen(FaxSend->FileName) + 1) * sizeof(WCHAR));
00658         if (pJobInfo->FileName) {
00659             lstrcpy(pJobInfo->FileName, FaxSend->FileName);
00660         }
00661     }
00662     // Copy the name of the calling device
00663     if (FaxSend->CallerName != NULL) {
00664         pJobInfo->CallerName = MemAllocMacro((lstrlen(FaxSend->CallerName) + 1) * sizeof(WCHAR));
00665         if (pJobInfo->CallerName) {
00666             lstrcpy(pJobInfo->CallerName, FaxSend->CallerName);
00667         }
00668     }
00669     // Copy the telephone number of the calling device
00670     if (FaxSend->CallerNumber != NULL) {
00671         pJobInfo->CallerNumber = MemAllocMacro((lstrlen(FaxSend->CallerNumber) + 1) * sizeof(WCHAR));
00672         if (pJobInfo->CallerNumber) {
00673             lstrcpy(pJobInfo->CallerNumber, FaxSend->CallerNumber);
00674         }
00675     }
00676     // Copy the name of the receiving device
00677     if (FaxSend->ReceiverName != NULL) {
00678         pJobInfo->ReceiverName = MemAllocMacro((lstrlen(FaxSend->ReceiverName) + 1) * sizeof(WCHAR));
00679         if (pJobInfo->ReceiverName) {
00680             lstrcpy(pJobInfo->ReceiverName, FaxSend->ReceiverName);
00681         }
00682     }
00683     // Copy the telephone number of the receiving device
00684     if (FaxSend->ReceiverNumber != NULL) {
00685         pJobInfo->ReceiverNumber = MemAllocMacro((lstrlen(FaxSend->ReceiverNumber) + 1) * sizeof(WCHAR));
00686         if (pJobInfo->ReceiverNumber)
00687     {
00688       lstrcpy(pJobInfo->ReceiverNumber, FaxSend->ReceiverNumber);
00689         }
00690     }
00691
00692   //We skip the 1st char "T" or "P" (Tone or Pulse) that the fax service added based on the dialing rule
00693   iDestinationDevice = _wtoi(_wcsinc(FaxSend->ReceiverNumber));
00694   lstrcpy(szDeviceFolder, g_pDeviceInfo[iDestinationDevice]->Directory);
00695
00696     // Copy whether the fax service provider should generate a brand at the top of the fax transmission
00697     pJobInfo->Branding = FaxSend->Branding;
00698
00699     // Release access to this virtual fax device
00700     LeaveCriticalSection(&pDeviceInfo->cs);
00701
00702     WriteDebugString(L"   FaxSend->SizeOfStruct   : 0x%08x\n", FaxSend->SizeOfStruct);
00703     WriteDebugString(L"   FaxSend->FileName       : %s\n", FaxSend->FileName);
00704     WriteDebugString(L"   FaxSend->CallerName     : %s\n", FaxSend->CallerName);
00705     WriteDebugString(L"   FaxSend->CallerNumber   : %s\n", FaxSend->CallerNumber);
00706     WriteDebugString(L"   FaxSend->ReceiverName   : %s\n", FaxSend->ReceiverName);
00707     WriteDebugString(L"   FaxSend->ReceiverNumber : %s\n", FaxSend->ReceiverNumber);
00708     WriteDebugString(L"   FaxSend->Branding       : %s\n", FaxSend->Branding ? L"TRUE" : L"FALSE");
00709     WriteDebugString(L"   FaxSend->CallHandle     : 0x%08x\n", FaxSend->CallHandle);
00710   WriteDebugString(L"   Dest. device Folder     : 0x%08x\n", szDeviceFolder);
00711
00712
00713     // Wait for access to this virtual fax device
00714     EnterCriticalSection(&pDeviceInfo->cs);
00715
00716     if (pDeviceInfo->Status == DEVICE_ABORTING) {
00717         goto ExitUserAbort;
00718     }
00719
00720     // Set the fax job status
00721     pJobInfo->Status = FS_INITIALIZING;
00722     // Post the FS_INITIALIZING line status event to the fax service
00723     PostJobStatus(pJobInfo->CompletionPortHandle,
00724           pJobInfo->CompletionKey,
00725           FS_INITIALIZING,
00726           ERROR_SUCCESS);
00727
00728     // Validate the folder of the receive device
00729     dwReceiverNumberAttributes = GetFileAttributes(szDeviceFolder);
00730     if ((dwReceiverNumberAttributes == 0xFFFFFFFF) || ((dwReceiverNumberAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)) {
00731         // The folder of the receive device is invalid
00732         goto ExitFatalError;
00733     }
00734
00735     // Open the source file
00736     hSourceFile = CreateFile(FaxSend->FileName,
00737                GENERIC_READ,
00738                0,
00739                NULL,
00740                OPEN_EXISTING,
00741                FILE_ATTRIBUTE_NORMAL,
00742                NULL);
00743     if (hSourceFile == INVALID_HANDLE_VALUE) {
00744         // The source file failed to be opened
00745         goto ExitFatalError;
00746     }
00747
00748     // Split the full path of the file that contains the data stream for the fax document
00749     _wsplitpath(FaxSend->FileName,
00750         NULL,
00751         NULL,
00752         szSourceName,
00753         szSourceExt);
00754
00755     // Set the destination filename
00756     lstrcpy(szDestinationFilename, szDeviceFolder);
00757     lstrcat(szDestinationFilename, L"\\");
00758     lstrcat(szDestinationFilename, szSourceName);
00759     lstrcat(szDestinationFilename, L".tif");
00760   if ( wcslen(szDestinationFilename) >= MAX_PATH) {
00761         // The destination file path is too long
00762         goto ExitFatalError;
00763     }
00764
00765
00766     // Create the destination file
00767     hDestinationFile = CreateFile(szDestinationFilename,
00768                   GENERIC_WRITE,
00769                   0,
00770                   NULL,
00771                   CREATE_ALWAYS,
00772                   FILE_ATTRIBUTE_NORMAL,
00773                   NULL);
00774     if (hDestinationFile == INVALID_HANDLE_VALUE) {
00775         // The destination file failed to be created
00776         goto ExitFatalError;
00777     }
00778
00779     // Release access to this virtual fax device
00780     LeaveCriticalSection(&pDeviceInfo->cs);
00781
00782     // Wait for access to this virtual fax device
00783     EnterCriticalSection(&pDeviceInfo->cs);
00784
00785     if (pDeviceInfo->Status == DEVICE_ABORTING) {
00786         goto ExitUserAbort;
00787     }
00788
00789     // Set the fax job status
00790     pJobInfo->Status = FS_TRANSMITTING;
00791     // Post the FS_TRANSMITTING line status event to the fax service
00792     PostJobStatus(pJobInfo->CompletionPortHandle,
00793           pJobInfo->CompletionKey,
00794           FS_TRANSMITTING,
00795           ERROR_SUCCESS);
00796
00797     // Release access to this virtual fax device
00798     LeaveCriticalSection(&pDeviceInfo->cs);
00799
00800     while (TRUE) {
00801         // The following sleep statement slows the bit copy to a reasonable speed so that a FaxDevAbortOperation()
00802     // call is possible
00803         Sleep(250);
00804
00805         // Wait for access to this virtual fax device
00806         EnterCriticalSection(&pDeviceInfo->cs);
00807
00808         if (pDeviceInfo->Status == DEVICE_ABORTING) {
00809             goto ExitUserAbort;
00810         }
00811
00812         // Read the bytes from the source file
00813         if (ReadFile(hSourceFile,
00814            FileBytes,
00815            sizeof(FileBytes),
00816            &dwBytes,
00817            NULL) == FALSE) {
00818             // Failed to read the bytes from the source file
00819             goto ExitFatalError;
00820         }
00821
00822         if (dwBytes == 0) {
00823             // The file pointer has reached the end of the source file
00824             // Release access to this virtual fax device
00825             LeaveCriticalSection(&pDeviceInfo->cs);
00826             break;
00827         }
00828
00829         // Write the bytes to the destination file
00830         if (WriteFile(hDestinationFile,
00831             FileBytes,
00832             dwBytes,
00833             &dwBytes,
00834             NULL) == FALSE) {
00835             // Failed to write the bytes to the destination file
00836             goto ExitFatalError;
00837         }
00838
00839         // Release access to this virtual fax device
00840         LeaveCriticalSection(&pDeviceInfo->cs);
00841     }
00842
00843     // Wait for access to this virtual fax device
00844     EnterCriticalSection(&pDeviceInfo->cs);
00845
00846     if (pDeviceInfo->Status == DEVICE_ABORTING) {
00847         goto ExitUserAbort;
00848     }
00849
00850     // Close the destination file
00851     CloseHandle(hDestinationFile);
00852
00853     // Close the source file
00854     CloseHandle(hSourceFile);
00855
00856     // Set the fax job status
00857     pJobInfo->Status = FS_COMPLETED;
00858     // Post the FS_COMPLETED line status event to the fax service
00859     PostJobStatus(pJobInfo->CompletionPortHandle,
00860           pJobInfo->CompletionKey,
00861           FS_COMPLETED,
00862           ERROR_SUCCESS);
00863
00864     // Release access to this virtual fax device
00865     LeaveCriticalSection(&pDeviceInfo->cs);
00866
00867     WriteDebugString(L"---SampleFSP: FaxDevSend Exit---\n");
00868
00869     return TRUE;
00870
00871 ExitFatalError:
00872     // Set the fax job status
00873     pJobInfo->Status = FS_FATAL_ERROR;
00874     goto Exit;
00875
00876 ExitUserAbort:
00877     // Set the fax job status
00878     pJobInfo->Status = FS_USER_ABORT;
00879     goto Exit;
00880
00881 Exit:
00882     // Close and delete the destination file
00883     if (hDestinationFile != INVALID_HANDLE_VALUE) {
00884         CloseHandle(hDestinationFile);
00885
00886         DeleteFile(szDestinationFilename);
00887     }
00888
00889     // Close the source file
00890     if (hSourceFile != INVALID_HANDLE_VALUE) {
00891         CloseHandle(hSourceFile);
00892     }
00893
00894     // Post the line status event to the fax service
00895     PostJobStatus(pJobInfo->CompletionPortHandle,
00896           pJobInfo->CompletionKey,
00897           pJobInfo->Status,
00898           ERROR_SUCCESS);
00899
00900     // Release access to this virtual fax device
00901     LeaveCriticalSection(&pDeviceInfo->cs);
00902
00903     WriteDebugString(L"---SampleFSP: FaxDevSend Exit---\n");
00904
00905     return FALSE;
00906 }
00907
00908 BOOL WINAPI
00909 FaxDevReceive(
00910     IN     HANDLE        FaxHandle,
00911     IN     HCALL         CallHandle,
00912     IN OUT PFAX_RECEIVE  FaxReceive
00913 )
00914 /*++
00915
00916 Routine Description:
00917
00918   The fax service calls the FaxDevReceive function to signal an incoming fax transmission to the fax service provider
00919
00920 Arguments:
00921
00922   FaxHandle - specifies a fax handle returned by the FaxDevStartJob function
00923   CallHandle - specifies a TAPI call handle
00924   FaxReceive - pointer to a FAX_RECEIVE stucture that contains information about an incoming fax document
00925
00926 Return Value:
00927
00928   TRUE on success
00929
00930 --*/
00931 {
00932     // pJobInfo is a pointer to the fax job data
00933     PJOB_INFO        pJobInfo;
00934     // pDeviceInfo is a pointer to the virtual fax device data
00935     PDEVICE_INFO     pDeviceInfo;
00936
00937     // hSourceFile is the handle to the source file
00938     HANDLE           hSourceFile = INVALID_HANDLE_VALUE;
00939     // szSourceFilename is the source filename
00940     WCHAR            szSourceFilename[MAX_PATH + MAX_PATH_LEN + 1];
00941
00942     // hFindFile is a find file handle
00943     HANDLE           hFindFile = INVALID_HANDLE_VALUE;
00944     // FindData is a WIN32_FIND_DATA structure
00945     WIN32_FIND_DATA  FindData;
00946     // szSearchPath is the search path
00947     WCHAR            szSearchPath[MAX_PATH];
00948
00949     // hDestinationFile is the handle to the destination file
00950     HANDLE           hDestinationFile = INVALID_HANDLE_VALUE;
00951
00952     // FileBytes is the bytes to be copied from the source file to the destination file
00953     BYTE             FileBytes[1024];
00954     // dwBytes is the number of bytes read from the source file
00955     DWORD            dwBytes;
00956
00957     WriteDebugString(L"---SampleFSP: FaxDevReceive Enter---\n");
00958
00959     if (FaxHandle == NULL) {
00960         // Set the error code
00961         SetLastError(ERROR_INVALID_HANDLE);
00962
00963         WriteDebugString(L"   ERROR: FaxDevReceive Failed: ERROR_INVALID_HANDLE\n");
00964         WriteDebugString(L"---SampleFSP: FaxDevReceive Exit---\n");
00965         return FALSE;
00966     }
00967
00968     // Get the fax job data from FaxHandle
00969     pJobInfo = (PJOB_INFO) FaxHandle;
00970     // Get the virtual fax device data from the fax job data
00971     pDeviceInfo = (PDEVICE_INFO) pJobInfo->pDeviceInfo;
00972
00973     // Wait for access to this virtual fax device
00974     EnterCriticalSection(&pDeviceInfo->cs);
00975
00976     if (pDeviceInfo->Status == DEVICE_ABORTING) {
00977         goto ExitUserAbort;
00978     }
00979
00980     // Set the virtual fax device status
00981     pDeviceInfo->Status = DEVICE_RECEIVE;
00982
00983     // Set the fax job type
00984     pJobInfo->JobType = JOB_RECEIVE;
00985     // Copy the handle to the active call associated with the fax job
00986     pJobInfo->CallHandle = CallHandle;
00987
00988     // Release access to this virtual fax device
00989     LeaveCriticalSection(&pDeviceInfo->cs);
00990
00991     WriteDebugString(L"   CallHandle                 : 0x%08x\n", CallHandle);
00992     WriteDebugString(L"   FaxReceive->SizeOfStruct   : 0x%08x\n", FaxReceive->SizeOfStruct);
00993     WriteDebugString(L"   FaxReceive->FileName       : %s\n", FaxReceive->FileName);
00994     WriteDebugString(L"   FaxReceive->ReceiverName   : %s\n", FaxReceive->ReceiverName);
00995     WriteDebugString(L"   FaxReceive->ReceiverNumber : %s\n", FaxReceive->ReceiverNumber);
00996
00997     // Wait for access to this virtual fax device
00998     EnterCriticalSection(&pDeviceInfo->cs);
00999
01000     if (pDeviceInfo->Status == DEVICE_ABORTING) {
01001         goto ExitUserAbort;
01002     }
01003
01004     // Set the fax job status
01005     pJobInfo->Status = FS_ANSWERED;
01006     // Post the FS_ANSWERED line status event to the fax service
01007     PostJobStatus(pJobInfo->CompletionPortHandle,
01008           pJobInfo->CompletionKey,
01009           FS_ANSWERED,
01010           ERROR_SUCCESS);
01011
01012     // Set the search path
01013     lstrcpy(szSearchPath, pDeviceInfo->Directory);
01014     lstrcat(szSearchPath, L"\\*.tif");
01015
01016     // Initialize the find file data
01017     ZeroMemory(&FindData, sizeof(FindData));
01018     FindData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
01019
01020     // Find the incoming fax file
01021     hFindFile = FindFirstFile(szSearchPath, &FindData);
01022     if (hFindFile == INVALID_HANDLE_VALUE) {
01023         // The incoming fax file was not found
01024         goto ExitFatalError;
01025     }
01026
01027     // Close the find file handle
01028     FindClose(hFindFile);
01029     hFindFile = INVALID_HANDLE_VALUE;
01030
01031     // Set the source filename
01032     lstrcpy(szSourceFilename, pDeviceInfo->Directory);
01033     lstrcat(szSourceFilename, L"\\");
01034     lstrcat(szSourceFilename, FindData.cFileName);
01035
01036   if (wcslen(szSourceFilename) >= MAX_PATH) {
01037         // The source file name is too long
01038         goto ExitFatalError;
01039     }
01040
01041     // Open the source file
01042     hSourceFile = CreateFile(szSourceFilename,
01043                GENERIC_READ,
01044                0,
01045                NULL,
01046                OPEN_EXISTING,
01047                FILE_ATTRIBUTE_NORMAL,
01048                NULL);
01049     if (hSourceFile == INVALID_HANDLE_VALUE) {
01050         // The source file failed to be opened
01051         goto ExitFatalError;
01052     }
01053
01054     // Open the destination file
01055     hDestinationFile = CreateFile(FaxReceive->FileName,
01056                   GENERIC_WRITE,
01057                   0,
01058                   NULL,
01059                   OPEN_EXISTING,
01060                   FILE_ATTRIBUTE_NORMAL,
01061                   NULL);
01062     if (hDestinationFile == INVALID_HANDLE_VALUE) {
01063         // The destination file failed to be created
01064         goto ExitFatalError;
01065     }
01066
01067     // Release access to this virtual fax device
01068     LeaveCriticalSection(&pDeviceInfo->cs);
01069
01070     // Wait for access to this virtual fax device
01071     EnterCriticalSection(&pDeviceInfo->cs);
01072
01073     if (pDeviceInfo->Status == DEVICE_ABORTING) {
01074         goto ExitUserAbort;
01075     }
01076
01077     // Set the fax job status
01078     pJobInfo->Status = FS_RECEIVING;
01079     // Post the FS_RECEIVING line status event to the fax service
01080     PostJobStatus(pJobInfo->CompletionPortHandle,
01081           pJobInfo->CompletionKey,
01082           FS_RECEIVING,
01083           ERROR_SUCCESS);
01084
01085     // Release access to this virtual fax device
01086     LeaveCriticalSection(&pDeviceInfo->cs);
01087
01088     while (TRUE) {
01089         // The following sleep statement slows the bit copy to a reasonable speed so that a FaxDevAbortOperation() call is possible
01090         Sleep(250);
01091
01092         // Wait for access to this virtual fax device
01093         EnterCriticalSection(&pDeviceInfo->cs);
01094
01095         if (pDeviceInfo->Status == DEVICE_ABORTING) {
01096             goto ExitUserAbort;
01097         }
01098
01099         // Read the bytes from the source file
01100         if (ReadFile(hSourceFile,
01101            FileBytes,
01102            sizeof(FileBytes),
01103            &dwBytes,
01104            NULL) == FALSE) {
01105             // Failed to read the bytes from the source file
01106             goto ExitFatalError;
01107         }
01108
01109         if (dwBytes == 0) {
01110             // The file pointer has reached the end of the source file
01111             // Release access to this virtual fax device
01112             LeaveCriticalSection(&pDeviceInfo->cs);
01113             break;
01114         }
01115
01116         // Write the bytes to the destination file
01117         if (WriteFile(hDestinationFile,
01118             FileBytes,
01119             dwBytes,
01120             &dwBytes,
01121             NULL) == FALSE) {
01122             // Failed to write the bytes to the destination file
01123             goto ExitFatalError;
01124         }
01125
01126         // Release access to this virtual fax device
01127         LeaveCriticalSection(&pDeviceInfo->cs);
01128     }
01129
01130   // Wait for access to this virtual fax device
01131     EnterCriticalSection(&pDeviceInfo->cs);
01132
01133     if (pDeviceInfo->Status == DEVICE_ABORTING) {
01134         goto ExitUserAbort;
01135     }
01136
01137     // Close the destination file
01138     CloseHandle(hDestinationFile);
01139
01140     // Close the source file
01141     CloseHandle(hSourceFile);
01142
01143   //Source file is now copied, delete the source file
01144   DeleteFile(szSourceFilename);
01145
01146     // Set the fax job status
01147     pJobInfo->Status = FS_COMPLETED;
01148     // Post the FS_COMPLETED line status event to the fax service
01149     PostJobStatus(pJobInfo->CompletionPortHandle,
01150           pJobInfo->CompletionKey,
01151           FS_COMPLETED,
01152           ERROR_SUCCESS);
01153
01154     // Release access to this virtual fax device
01155     LeaveCriticalSection(&pDeviceInfo->cs);
01156
01157     WriteDebugString(L"---SampleFSP: FaxDevReceive Exit---\n");
01158
01159     return TRUE;
01160
01161 ExitFatalError:
01162     // Set the fax job status
01163     pJobInfo->Status = FS_FATAL_ERROR;
01164     goto Exit;
01165
01166 ExitUserAbort:
01167     // Set the fax job status
01168     pJobInfo->Status = FS_USER_ABORT;
01169     goto Exit;
01170
01171 Exit:
01172     // Close the destination file
01173     if (hDestinationFile != INVALID_HANDLE_VALUE) {
01174         CloseHandle(hDestinationFile);
01175     }
01176
01177     // Close the source file
01178     if (hSourceFile != INVALID_HANDLE_VALUE) {
01179         CloseHandle(hSourceFile);
01180     }
01181
01182     // Post the line status event to the fax service
01183     PostJobStatus(pJobInfo->CompletionPortHandle,
01184           pJobInfo->CompletionKey,
01185           pJobInfo->Status,
01186           ERROR_SUCCESS);
01187
01188     // Release access to this virtual fax device
01189     LeaveCriticalSection(&pDeviceInfo->cs);
01190
01191     WriteDebugString(L"---SampleFSP: FaxDevReceive Exit---\n");
01192
01193     return FALSE;
01194 }
01195
01196 BOOL WINAPI
01197 FaxDevReportStatus(
01198     IN  HANDLE           FaxHandle OPTIONAL,
01199     OUT PFAX_DEV_STATUS  FaxStatus,
01200     IN  DWORD            FaxStatusSize,
01201     OUT LPDWORD          FaxStatusSizeRequired
01202 )
01203 /*++
01204
01205 Routine Description:
01206
01207   The fax service calls the FaxDevReportStatus function to query a fax service provider for status information about an individual active fax operation or for status information after a failed fax operation
01208
01209 Arguments:
01210
01211   FaxHandle - specifies a fax handle returned by the FaxDevStartJob function
01212   FaxStatus - pointer to a FAX_DEV_STATUS structure that receives status and identification information
01213   FaxStatusSize - specifies the size, in bytes, of the buffer pointer to by the FaxStatus parameter
01214   FaxStatusSizeRequired - pointer to a variable that receives the calculated size, in bytes, of the buffer required to hold the FAX_DEV_STATUS structure
01215
01216 Return Value:
01217
01218   TRUE on success
01219
01220 --*/
01221 {
01222     // pJobInfo is a pointer to the fax job data
01223     PJOB_INFO     pJobInfo;
01224     // pDeviceInfo is a pointer to the virtual fax device data
01225     PDEVICE_INFO  pDeviceInfo;
01226     // dwSize is the size of the completion packet
01227     DWORD         dwSize;
01228     // upString is the offset of the strings within the completion packet
01229     UINT_PTR      upStringOffset;
01230
01231     WriteDebugString(L"---SampleFSP: FaxDevReportStatus Enter---\n");
01232
01233     if (FaxHandle == NULL) {
01234         // Set the error code
01235         SetLastError(ERROR_INVALID_HANDLE);
01236
01237         WriteDebugString(L"   ERROR: FaxDevReportStatus Failed: ERROR_INVALID_HANDLE\n");
01238         WriteDebugString(L"---SampleFSP: FaxDevReportStatus Exit---\n");
01239         return FALSE;
01240     }
01241
01242     if (FaxStatusSizeRequired == NULL) {
01243         // Set the error code
01244         SetLastError(ERROR_INVALID_PARAMETER);
01245
01246         WriteDebugString(L"   ERROR: FaxDevReportStatus Failed: ERROR_INVALID_PARAMETER\n");
01247         WriteDebugString(L"---SampleFSP: FaxDevReportStatus Exit---\n");
01248         return FALSE;
01249     }
01250
01251     if ((FaxStatus == NULL) && (FaxStatusSize != 0)) {
01252         // Set the error code
01253         SetLastError(ERROR_INVALID_PARAMETER);
01254
01255         WriteDebugString(L"   ERROR: FaxDevReportStatus Failed: ERROR_INVALID_PARAMETER\n");
01256         WriteDebugString(L"---SampleFSP: FaxDevReportStatus Exit---\n");
01257         return FALSE;
01258     }
01259
01260     // Get the fax job data from FaxHandle
01261     pJobInfo = (PJOB_INFO) FaxHandle;
01262     // Get the virtual fax device data from the fax job data
01263     pDeviceInfo = (PDEVICE_INFO) pJobInfo->pDeviceInfo;
01264
01265     // Wait for access to this virtual fax device
01266     EnterCriticalSection(&pDeviceInfo->cs);
01267
01268     // Initialize the size of the completion packet
01269     dwSize = sizeof(FAX_DEV_STATUS);
01270     if (pJobInfo->CSI != NULL) {
01271         // Increase the size of the completion packet for the remote fax device indentifier
01272         dwSize += (lstrlen(pJobInfo->CSI) + 1) * sizeof(WCHAR);
01273     }
01274     if (pJobInfo->CallerId != NULL) {
01275         // Increase the size of the completion packet for the calling fax device identifier
01276         dwSize += (lstrlen(pJobInfo->CallerId) + 1) * sizeof(WCHAR);
01277     }
01278     if (pJobInfo->RoutingInfo != NULL) {
01279         // Increase the size of the completion packet for the routing string
01280         dwSize += (lstrlen(pJobInfo->RoutingInfo) + 1) * sizeof(WCHAR);
01281     }
01282
01283     // Set the calculated size of the buffer required to hold the completion packet
01284     *FaxStatusSizeRequired = dwSize;
01285
01286     if ((FaxStatus == NULL) && (FaxStatusSize == 0)) {
01287         // Release access to this virtual fax device
01288         LeaveCriticalSection(&pDeviceInfo->cs);
01289
01290         WriteDebugString(L"---SampleFSP: FaxDevReportStatus Exit---\n");
01291         return TRUE;
01292     }
01293
01294     if (FaxStatusSize < dwSize) {
01295         // Set the error code
01296         SetLastError(ERROR_INSUFFICIENT_BUFFER);
01297
01298         // Release access to this virtual fax device
01299         LeaveCriticalSection(&pDeviceInfo->cs);
01300
01301         WriteDebugString(L"   ERROR: FaxDevReportStatus Failed: ERROR_INSUFFICIENT_BUFFER\n");
01302         WriteDebugString(L"---SampleFSP: FaxDevReportStatus Exit---\n");
01303         return FALSE;
01304     }
01305
01306     // Initialize upStringOffset
01307     upStringOffset = sizeof(FAX_DEV_STATUS);
01308
01309     // Set the completion packet's structure size
01310     FaxStatus->SizeOfStruct = sizeof(FAX_DEV_STATUS);
01311     // Copy the completion packet's fax status identifier
01312     FaxStatus->StatusId = pJobInfo->Status;
01313     // Set the completion packet's string resource identifier to 0
01314     FaxStatus->StringId = 0;
01315     // Copy the completion packet's current page number
01316     FaxStatus->PageCount = pJobInfo->PageCount;
01317     // Copy the completion packet's remote fax device identifier
01318     if (pJobInfo->CSI != NULL) {
01319         FaxStatus->CSI = (LPWSTR) ((UINT_PTR) FaxStatus + upStringOffset);
01320         lstrcpy(FaxStatus->CSI, pJobInfo->CSI);
01321         upStringOffset += (lstrlen(pJobInfo->CSI) + 1) * sizeof(WCHAR);
01322     }
01323     // Set the completion packet's calling fax device identifier to NULL
01324     FaxStatus->CallerId = NULL;
01325     if (pJobInfo->CallerId != NULL) {
01326         FaxStatus->CallerId = (LPWSTR) ((UINT_PTR) FaxStatus + upStringOffset);
01327         lstrcpy(FaxStatus->CallerId, pJobInfo->CallerId);
01328         upStringOffset += (lstrlen(pJobInfo->CallerId) + 1) * sizeof(WCHAR);
01329     }
01330     // Set the completion packet's routing string to NULL
01331     FaxStatus->RoutingInfo = NULL;
01332     if (pJobInfo->RoutingInfo != NULL) {
01333         FaxStatus->RoutingInfo = (LPWSTR) ((UINT_PTR) FaxStatus + upStringOffset);
01334         lstrcpy(FaxStatus->RoutingInfo, pJobInfo->RoutingInfo);
01335         upStringOffset += (lstrlen(pJobInfo->RoutingInfo) + 1) * sizeof(WCHAR);
01336     }
01337     // Copy the completion packet's Win32 error code
01338     FaxStatus->ErrorCode = ERROR_SUCCESS;
01339
01340     // Release access to this virtual fax device
01341     LeaveCriticalSection(&pDeviceInfo->cs);
01342
01343     WriteDebugString(L"---SampleFSP: FaxDevReportStatus Exit---\n");
01344
01345     return TRUE;
01346 }
01347
01348 BOOL WINAPI
01349 FaxDevAbortOperation(
01350     IN HANDLE  FaxHandle
01351 )
01352 /*++
01353
01354 Routine Description:
01355
01356   The fax service calls the FaxDevAbortOperation function to request that the fax service provider terminate the active fax operation for the fax job specified by the FaxHandle parameter
01357
01358 Arguments:
01359
01360   FaxHandle - specifies a fax handle returned by the FaxDevStartJob function
01361
01362 Return Value:
01363
01364   TRUE on success
01365
01366 --*/
01367 {
01368     // pJobInfo is a pointer to the fax job data
01369     PJOB_INFO     pJobInfo;
01370     // pDeviceInfo is a pointer to the virtual fax device data
01371     PDEVICE_INFO  pDeviceInfo;
01372
01373     WriteDebugString(L"---SampleFSP: FaxDevAbortOperation Enter---\n");
01374
01375     if (FaxHandle == NULL) {
01376         // Set the error code
01377         SetLastError(ERROR_INVALID_HANDLE);
01378
01379         WriteDebugString(L"   ERROR: FaxDevAbortOperation Failed: ERROR_INVALID_HANDLE\n");
01380         WriteDebugString(L"---SampleFSP: FaxDevAbortOperation Exit---\n");
01381         return FALSE;
01382     }
01383
01384     // Get the fax job data from FaxHandle
01385     pJobInfo = (PJOB_INFO) FaxHandle;
01386     // Get the virtual fax device data from the fax job data
01387     pDeviceInfo = (PDEVICE_INFO) pJobInfo->pDeviceInfo;
01388
01389     // Wait for access to this virtual fax device
01390     EnterCriticalSection(&pDeviceInfo->cs);
01391
01392     // Set the virtual fax device status
01393     pDeviceInfo->Status = DEVICE_ABORTING;
01394
01395     // Release access to this virtual fax device
01396     LeaveCriticalSection(&pDeviceInfo->cs);
01397
01398     WriteDebugString(L"---SampleFSP: FaxDevAbortOperation Exit---\n");
01399
01400     return TRUE;
01401 }
01402
01403 DWORD WINAPI DeviceReceiveThread(LPDWORD pdwDeviceId)
01404 /*++
01405
01406 Routine Description:
01407
01408   Thread to watch for an incoming fax transmission
01409
01410 Arguments:
01411
01412   pdwDeviceId - pointer to the virtual fax device identifier
01413
01414 Return Value:
01415
01416   DWORD
01417
01418 --*/
01419 {
01420     // hChangeNotification is a handle to a notification change in a directory
01421     HANDLE         hChangeNotification;
01422     // hWaitObjects are the handles to the wait objects
01423     HANDLE         hWaitObjects[2];
01424     // dwDeviceId is the virtual fax device identifier
01425     DWORD          dwDeviceId;
01426     // pLineMessage is a pointer to LINEMESSAGE structure to signal an incoming fax transmission to the fax service
01427     LPLINEMESSAGE  pLineMessage;
01428
01429     WriteDebugString(L"---SampleFSP: DeviceReceiveThread Enter---\n");
01430
01431     // Copy the virtual fax device identifier
01432     dwDeviceId = *pdwDeviceId;
01433     MemFreeMacro(pdwDeviceId);
01434
01435     // Create the change notification handle
01436     hChangeNotification = FindFirstChangeNotification(g_pDeviceInfo[dwDeviceId]->Directory,
01437                             FALSE,
01438                             FILE_NOTIFY_CHANGE_ATTRIBUTES);
01439     if (hChangeNotification == INVALID_HANDLE_VALUE) {
01440         goto Exit;
01441     }
01442
01443     // Wait for access to this virtual fax device
01444     EnterCriticalSection(&g_pDeviceInfo[dwDeviceId]->cs);
01445
01446     // Set hWaitObjects
01447     hWaitObjects[0] = g_pDeviceInfo[dwDeviceId]->ExitEvent;
01448     hWaitObjects[1] = hChangeNotification;
01449
01450     // Release access to this virtual fax device
01451     LeaveCriticalSection(&g_pDeviceInfo[dwDeviceId]->cs);
01452
01453     while (TRUE) {
01454         // Wait for the exit event or notification change to be signaled
01455         if ( WaitForMultipleObjects(2,
01456                   hWaitObjects,
01457                   FALSE,
01458                   INFINITE) == WAIT_OBJECT_0) {
01459             break;
01460         }
01461
01462         // Wait for access to this virtual fax device
01463         EnterCriticalSection(&g_pDeviceInfo[dwDeviceId]->cs);
01464
01465         if (g_pDeviceInfo[dwDeviceId]->Status == DEVICE_IDLE) {
01466             // Allocate a block of memory for the completion packet
01467             pLineMessage = LocalAlloc(LPTR, sizeof(LINEMESSAGE));
01468             if (pLineMessage != NULL) {
01469                 // Initialize the completion packet
01470                 // Set the completion packet's handle to the virtual fax device
01471                 pLineMessage->hDevice = dwDeviceId + NEWFSP_DEVICE_ID_PREFIX;
01472                 // Set the completion packet's virtual fax device message
01473                 pLineMessage->dwMessageID = 0;
01474                 // Set the completion packet's instance data
01475                 pLineMessage->dwCallbackInstance = 0;
01476                 // Set the completion packet's first parameter
01477                 pLineMessage->dwParam1 = LINEDEVSTATE_RINGING;
01478                 // Set the completion packet's second parameter
01479                 pLineMessage->dwParam2 = 0;
01480                 // Set the completion packet's third parameter
01481                 pLineMessage->dwParam3 = 0;
01482
01483                 WriteDebugString(L"---SampleFSP: DeviceReceiveThread Signaling Fax Service...---\n");
01484
01485                 // Post the completion packet
01486                 PostQueuedCompletionStatus(g_CompletionPort,
01487                        sizeof(LINEMESSAGE),
01488                        g_CompletionKey,
01489                        (LPOVERLAPPED) pLineMessage);
01490             }
01491         }
01492
01493         // Release access to this virtual fax device
01494         LeaveCriticalSection(&g_pDeviceInfo[dwDeviceId]->cs);
01495
01496         // Find the next notification change
01497         FindNextChangeNotification(hChangeNotification);
01498     }
01499
01500 Exit:
01501     if (hChangeNotification != INVALID_HANDLE_VALUE) {
01502         // Close the handle to the change notification
01503         FindCloseChangeNotification(hChangeNotification);
01504     }
01505
01506     // Close the handle to the exit event
01507     CloseHandle(hWaitObjects[0]);
01508
01509     WriteDebugString(L"---SampleFSP: DeviceReceiveThread Exit---\n");
01510
01511     return 0;
01512 }
01513
01514 STDAPI DllRegisterServer()
01515 /*++
01516
01517 Routine Description:
01518
01519   Function for the in-process server to create its registry entries
01520
01521 Return Value:
01522
01523   S_OK on success
01524
01525 --*/
01526 {
01527     // hModWinfax is the handle to the winfax module
01528     HANDLE                       hModWinfax;
01529
01530     // szCurrentDirectory is the name of the current directory
01531     WCHAR                        szCurrentDirectory[MAX_PATH_LEN];
01532     // szCurrentFilename is the name of the current filename
01533     WCHAR                        szCurrentFilename[_MAX_FNAME];
01534     // szDestinationFilename is the name of the destination filename
01535     WCHAR                        szDestinationFilename[MAX_PATH];
01536   // szWinFaxDllLocation is the location of the winfax.dll
01537     WCHAR szWinFaxDllLocation[MAX_PATH+12]={0};
01538
01539     // pFaxRegisterServiceProvider is a pointer to the FaxRegisterServiceProvider() winfax api
01540     PFAXREGISTERSERVICEPROVIDER  pFaxRegisterServiceProvider;
01541
01542     // pDeviceInfo is a pointer to the virtual fax devices
01543     PDEVICE_INFO                 pDeviceInfo;
01544     // pCurrentDeviceInfo is a pointer to the current virtual fax device
01545     PDEVICE_INFO                 pCurrentDeviceInfo;
01546     // dwIndex is a counter to enumerate each virtual fax device
01547     DWORD                        dwIndex;
01548
01549     // Open the log file
01550     OpenLogFile(FALSE, NULL);
01551
01552     WriteDebugString(L"---SampleFSP: DllRegisterServer Enter---\n");
01553
01554     // Get the current directory
01555     if (GetCurrentDirectory(MAX_PATH_LEN, szCurrentDirectory) == 0) {
01556         WriteDebugString(L"   ERROR: GetCurrentDirectory Failed: 0x%08x\n", GetLastError());
01557         WriteDebugString(L"   ERROR: DllRegisterServer Failed\n");
01558         WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01559
01560         // Close the log file
01561         CloseLogFile();
01562
01563         return E_UNEXPECTED;
01564     }
01565     // Set the current filename
01566     lstrcpy(szCurrentFilename, szCurrentDirectory);
01567     lstrcat(szCurrentFilename, L"\\SampleFSP.dll");
01568
01569     // Get the destination filename
01570     if (ExpandEnvironmentStrings(NEWFSP_PROVIDER_IMAGENAME, szDestinationFilename, MAX_PATH) == 0) {
01571         WriteDebugString(L"   ERROR: ExpandEnvironmentStrings Failed: 0x%08x\n", GetLastError());
01572         WriteDebugString(L"   ERROR: DllRegisterServer Failed\n");
01573         WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01574
01575         // Close the log file
01576         CloseLogFile();
01577
01578         return E_UNEXPECTED;
01579     }
01580
01581     if (lstrcmpi(szDestinationFilename, szCurrentFilename) != 0) {
01582         // Copy the current filename to the destination filename
01583         if (CopyFile(L"SampleFSP.dll", szDestinationFilename, FALSE) == FALSE) {
01584             WriteDebugString(L"   ERROR: CopyFile Failed: 0x%08x\n", GetLastError());
01585             WriteDebugString(L"   ERROR: DllRegisterServer Failed\n");
01586             WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01587
01588             // Close the log file
01589             CloseLogFile();
01590
01591             return E_UNEXPECTED;
01592         }
01593     }
01594
01595   //we assume that winfax.dll is located in SystemDirectory path
01596
01597   if (GetSystemDirectory(szWinFaxDllLocation, MAX_PATH+1) == 0)
01598   {
01599     WriteDebugString( L"GetSystemDirectory failed, ec = %d\n", GetLastError() );
01600         // Close the log file
01601         CloseLogFile();
01602     return E_UNEXPECTED;
01603   }
01604
01605   wcscat(szWinFaxDllLocation,L"\\winfax.dll" );
01606   if (wcslen(szWinFaxDllLocation) >= MAX_PATH) {
01607         WriteDebugString(L"   ERROR: Winfax.dll location is too long\n");
01608         // Close the log file
01609         CloseLogFile();
01610
01611         return E_UNEXPECTED;
01612     }
01613
01614     // Load the winfax dll
01615     hModWinfax = LoadLibrary( szWinFaxDllLocation );
01616     if (hModWinfax == NULL) {
01617         WriteDebugString(L"   ERROR: LoadLibrary Failed: 0x%08x\n", GetLastError());
01618         WriteDebugString(L"   ERROR: DllRegisterServer Failed\n");
01619         WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01620
01621         // Close the log file
01622         CloseLogFile();
01623
01624         return E_UNEXPECTED;
01625     }
01626
01627     pFaxRegisterServiceProvider = (PFAXREGISTERSERVICEPROVIDER) GetProcAddress(hModWinfax, "FaxRegisterServiceProviderW");
01628     if (pFaxRegisterServiceProvider == NULL) {
01629         WriteDebugString(L"   ERROR: GetProcAddress Failed: 0x%08x\n", GetLastError());
01630         WriteDebugString(L"   ERROR: DllRegisterServer Failed\n");
01631
01632         FreeLibrary(hModWinfax);
01633
01634         WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01635
01636         // Close the log file
01637         CloseLogFile();
01638
01639         return E_UNEXPECTED;
01640     }
01641
01642     // Register the fax service provider
01643     if (pFaxRegisterServiceProvider(NEWFSP_PROVIDER,
01644                   NEWFSP_PROVIDER_FRIENDLYNAME,
01645                   NEWFSP_PROVIDER_IMAGENAME,
01646                   NEWFSP_PROVIDER_PROVIDERNAME) == FALSE) {
01647         WriteDebugString(L"   ERROR: FaxRegisterServiceProvider Failed: 0x%08x\n", GetLastError());
01648         WriteDebugString(L"   ERROR: DllRegisterServer Failed\n");
01649
01650         FreeLibrary(hModWinfax);
01651
01652         WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01653
01654         // Close the log file
01655         CloseLogFile();
01656
01657         return E_UNEXPECTED;
01658     }
01659
01660     FreeLibrary(hModWinfax);
01661
01662     // Set g_hHeap
01663     MemInitializeMacro(GetProcessHeap());
01664
01665     // Create the virtual fax devices
01666     for (dwIndex = 0, pCurrentDeviceInfo = NULL, pDeviceInfo = NULL; dwIndex < NEWFSP_DEVICE_LIMIT; dwIndex++) {
01667         // Allocate a block of memory for the virtual fax device data
01668         if (pCurrentDeviceInfo == NULL) {
01669             pCurrentDeviceInfo = MemAllocMacro(sizeof(DEVICE_INFO));
01670             if (pCurrentDeviceInfo == NULL) {
01671                 continue;
01672             }
01673         }
01674         else {
01675             pCurrentDeviceInfo->pNextDeviceInfo = MemAllocMacro(sizeof(DEVICE_INFO));
01676             if (pCurrentDeviceInfo->pNextDeviceInfo == NULL) {
01677                 continue;
01678             }
01679
01680             // Set the pointer to the current virtual fax device
01681             pCurrentDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo;
01682         }
01683
01684         // Set the indentifier of the virtual fax device
01685         pCurrentDeviceInfo->DeviceId = dwIndex;
01686         // Set the virtual fax device's incoming fax directory to the current directory
01687         lstrcpy(pCurrentDeviceInfo->Directory, szCurrentDirectory);
01688
01689         if (pDeviceInfo == NULL) {
01690             // Set the pointer to the virtual fax devices
01691             pDeviceInfo = pCurrentDeviceInfo;
01692         }
01693     }
01694
01695     // Set the registry data for the newfsp service provider
01696     SetNewFspRegistryData(FALSE, szCurrentDirectory, pDeviceInfo);
01697
01698     // Enumerate the virtual fax devices
01699     for (pCurrentDeviceInfo = pDeviceInfo; pCurrentDeviceInfo; pCurrentDeviceInfo = pDeviceInfo) {
01700         // Delete the virtual fax device data
01701         pDeviceInfo = pCurrentDeviceInfo->pNextDeviceInfo;
01702         MemFreeMacro(pCurrentDeviceInfo);
01703     }
01704
01705     WriteDebugString(L"---SampleFSP: DllRegisterServer Exit---\n");
01706
01707     // Close the log file
01708     CloseLogFile();
01709
01710     return S_OK;
01711 }
01712
01713
01714
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Resourcesub.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Resourcesub.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include <comsvcs.h>
00019 #include "ComSpyCtl.h"
00020 #include "ComSpyAudit.h"
00021 #include "CCOMSpy.h"
00022 #include "SysLCESub.h"
00023 #include "ResourceSub.h"
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // CResourceSub
00028
00029 STDMETHODIMP CResourceSub::OnResourceCreate(
00030     COMSVCSEVENTINFO * pInfo,
00031   ULONG64 ObjectID,
00032     LPCOLESTR pszType,
00033     ULONG64 resId,
00034   BOOL enlisted)
00035 {
00036   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnResourceCreate"), GuidToBstr(pInfo->guidApp));
00037   m_pSpy -> AddParamValueToList(L"Type", pszType);
00038
00039   WCHAR szObjectID[32];
00040   wsprintfW(szObjectID, L"0x%016X", ObjectID);
00041   m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00042
00043   WCHAR szResID[32];
00044   wsprintfW(szResID, L"0x%016X", resId);
00045   m_pSpy -> AddParamValueToList(L"ResourceID", szResID);
00046
00047   WCHAR szEnlisted[10];
00048   if (enlisted)
00049     wsprintfW(szEnlisted, L"TRUE");
00050   else
00051     wsprintfW(szEnlisted, L"FALSE");
00052   m_pSpy -> AddParamValueToList(L"Enlisted", szEnlisted);
00053
00054   IF_AUDIT_DO(OnResourceCreate)(pInfo->perfCount,GuidToBstr(pInfo->guidApp), szObjectID, pszType, szResID,enlisted);
00055
00056   return S_OK;
00057 }
00058
00059
00060 STDMETHODIMP CResourceSub::OnResourceAllocate(
00061   COMSVCSEVENTINFO * pInfo,
00062   ULONG64 ObjectID,
00063     LPCOLESTR pszType,
00064     ULONG64 resId,
00065   BOOL enlisted,
00066   DWORD NumRated,
00067   DWORD Rating)
00068 {
00069
00070   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnResourceAllocate"),GuidToBstr(pInfo->guidApp));
00071   m_pSpy -> AddParamValueToList(L"Type", pszType);
00072
00073   WCHAR szObjectID[32];
00074   wsprintfW(szObjectID, L"0x%016X", ObjectID);
00075   m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00076
00077   WCHAR szResID[32];
00078   wsprintfW(szResID, L"0x%016X", resId);
00079   m_pSpy -> AddParamValueToList(L"ResourceID", szResID);
00080
00081   WCHAR szEnlisted[10];
00082   if (enlisted)
00083     wsprintfW(szEnlisted, L"TRUE");
00084   else
00085     wsprintfW(szEnlisted, L"FALSE");
00086   m_pSpy -> AddParamValueToList(L"Enlisted", szEnlisted);
00087
00088   WCHAR szNumRated[16];
00089   wsprintfW(szNumRated, L"0x%08X", NumRated);
00090   m_pSpy -> AddParamValueToList(L"NumRated", szNumRated);
00091
00092   WCHAR szRating[16];
00093   wsprintfW(szRating, L"0x%08X", Rating);
00094   m_pSpy -> AddParamValueToList(L"Rating", szRating);
00095
00096   IF_AUDIT_DO(OnResourceAllocate)(pInfo->perfCount,GuidToBstr(pInfo->guidApp), szObjectID, pszType, szResID,enlisted,szNumRated,szRating);
00097   return S_OK;
00098 }
00099
00100
00101 STDMETHODIMP CResourceSub::OnResourceRecycle(
00102   COMSVCSEVENTINFO * pInfo,
00103   ULONG64 ObjectID,
00104     LPCOLESTR pszType,
00105     ULONG64 resId)
00106 {
00107   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnResourceRecycle"),GuidToBstr(pInfo->guidApp));
00108   m_pSpy -> AddParamValueToList(L"Type", pszType);
00109
00110   WCHAR szObjectID[32];
00111   wsprintfW(szObjectID, L"0x%016X", ObjectID);
00112   m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00113
00114   WCHAR szResID[32];
00115   wsprintfW(szResID, L"0x%016X", resId);
00116   m_pSpy -> AddParamValueToList(L"ResourceID", szResID);
00117
00118   IF_AUDIT_DO(OnResourceRecycle)(pInfo->perfCount,GuidToBstr(pInfo->guidApp), szObjectID, pszType, szResID);
00119   return S_OK;
00120 }
00121
00122
00123 STDMETHODIMP CResourceSub::OnResourceDestroy(
00124     COMSVCSEVENTINFO * pInfo,
00125   ULONG64 ObjectID,
00126   HRESULT hr,
00127     LPCOLESTR pszType,
00128     ULONG64 resId)
00129 {
00130   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnResourceDestroy"),GuidToBstr(pInfo->guidApp));
00131
00132   m_pSpy -> AddParamValueToList(L"Type", pszType);
00133
00134   WCHAR szObjectID[32];
00135   wsprintfW(szObjectID, L"0x%016X", ObjectID);
00136   m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00137
00138   WCHAR szResID[32];
00139   wsprintfW(szResID, L"0x%016X", resId);
00140   m_pSpy -> AddParamValueToList(L"ResourceID", szResID);
00141
00142   WCHAR szHResult[16];
00143   wsprintfW(szHResult, L"0x%08X", hr);
00144   m_pSpy -> AddParamValueToList(L"Destroy HR", szHResult);
00145
00146   IF_AUDIT_DO(OnResourceDestroy)(pInfo->perfCount, GuidToBstr(pInfo->guidApp), szObjectID, hr,pszType, szResID);
00147   return S_OK;
00148 }
00149
00150 STDMETHODIMP CResourceSub::OnResourceTrack(
00151                       COMSVCSEVENTINFO * pInfo,
00152                       ULONG64 ObjectID,
00153                       LPCOLESTR pszType,
00154                       ULONG64 resId,
00155                       BOOL enlisted)
00156 {
00157   m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnResourceTrack"), GuidToBstr(pInfo->guidApp));
00158
00159   m_pSpy -> AddParamValueToList(L"Type", pszType);
00160
00161   WCHAR szObjectID[32];
00162   wsprintfW(szObjectID, L"0x%016X", ObjectID);
00163   m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00164
00165   WCHAR szResID[32];
00166   wsprintfW(szResID, L"0x%016X", resId);
00167   m_pSpy -> AddParamValueToList(L"ResourceID", szResID);
00168
00169   WCHAR szEnlisted[10];
00170   if (enlisted)
00171     wsprintfW(szEnlisted, L"TRUE");
00172   else
00173     wsprintfW(szEnlisted, L"FALSE");
00174   m_pSpy -> AddParamValueToList(L"Enlisted", szEnlisted);
00175
00176   IF_AUDIT_DO(OnResourceTrack)(pInfo->perfCount,GuidToBstr(pInfo->guidApp), szObjectID, pszType, szResID,enlisted);
00177
00178
00179   return S_OK;
00180 }
00181
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CError Member List

This is the complete list of members for CError, including all inherited members.
AutoQI(DWORD dwCreateOpts) | CError | [virtual]
AutoRelease() | CError | [virtual]
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CError(CMainWindow *pCMainwindow) | CError |
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
DisplayObject() | CBase | [virtual]
GetBaseType() | CBase | [inline]
GetCustomErrorObject(ULONG ulRecordNum, REFIID riid, IUnknown **ppObject) | CError | [virtual]
GetDefaultInterface() | CError | [inline, virtual]
GetDescription(BSTR *pbstrDescription) | CError | [virtual]
GetErrorInfo(ULONG ulRecordNum, LCID lcid, IErrorInfo **ppErrorInfo) | CError | [virtual]
GetGUID(GUID *pGuid) | CError | [virtual]
GetHelpContext(DWORD *pdwHelpContext) | CError | [virtual]
GetHelpFile(BSTR *pbstrHelpFile) | CError | [virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CError | [virtual]
GetObjectDesc() | CError | [virtual]
GetObjectImage() | CError | [inline, virtual]
GetObjectMenu() | CError | [inline, virtual]
GetObjectName() | CError | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetParent(SOURCE eSource) | CBase | [virtual]
GetRecordCount(ULONG *pulCount) | CError | [virtual]
GetSource(BSTR *pbstrSource) | CError | [virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_cRef | CBase | [protected]
m_dwCLSCTX | CBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_guidSource | CBase |
m_hTreeItem | CBase |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pIErrorInfo | CError |
m_pIErrorRecords | CError |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_strObjectDesc | CBase | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
~CBase() | CBase | [virtual]
~CError() | CError | [virtual]
Generated on Wed Nov 13 2024 16:56:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Tbarext/globals.h Source File

  • SysMgmt
  • MMC
  • Tbarext

globals.h

Go to the documentation of this file.
00001
00002 //==============================================================;
00003 //
00004 //  This source code is only intended as a supplement to existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _MMC_GLOBALS_H
00021 #define _MMC_GLOBALS_H
00022
00023 #include <tchar.h>
00024
00025 #ifndef STRINGS_ONLY
00026   #define IDM_BUTTON1    0x100
00027   #define IDM_BUTTON2    0x101
00028
00029   extern HINSTANCE g_hinst;
00030   extern ULONG g_uObjects;
00031
00032   #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00033   #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00034
00035 #endif
00036
00037 //=--------------------------------------------------------------------------=
00038 // allocates a temporary buffer that will disappear when it goes out of scope
00039 // NOTE: be careful of that -- make sure you use the string in the same or
00040 // nested scope in which you created this buffer. people should not use this
00041 // class directly.  use the macro(s) below.
00042 //
00043 class TempBuffer {
00044   public:
00045     TempBuffer(ULONG cBytes) {
00046         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00047         m_fHeapAlloc = (cBytes > 120);
00048     }
00049     ~TempBuffer() {
00050         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00051     }
00052     void *GetBuffer() {
00053         return m_pBuf;
00054     }
00055
00056   private:
00057     void *m_pBuf;
00058     // we'll use this temp buffer for small cases.
00059     //
00060     char  m_szTmpBuf[120];
00061     unsigned m_fHeapAlloc:1;
00062 };
00063
00064 //=--------------------------------------------------------------------------=
00065 // string helpers.
00066 //
00067 // given a _TCHAR, copy it into a wide buffer.
00068 // be careful about scoping when using this macro!
00069 //
00070 // how to use the below two macros:
00071 //
00072 //  ...
00073 //  LPTSTR pszT;
00074 //  pszT = MyGetTStringRoutine();
00075 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00076 //  MyUseWideStringRoutine(pwsz);
00077 //  ...
00078 #ifdef UNICODE
00079 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00080     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00081     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00082     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00083     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00084 #else // ANSI
00085 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00086     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00087     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00088     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00089     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00090     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00091 #endif
00092
00093 #ifdef UNICODE
00094 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00095     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00096     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00097     lstrcpyW((LPWSTR)ptrname, tstr)
00098 #else // ANSI
00099 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00100     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00101     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00102     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00103     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00104 #endif
00105
00106 //
00107 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00108 // have to be declared, and no clean up must be done.
00109 //
00110 // * 2 for DBCS handling in below length computation
00111 //
00112 #ifdef UNICODE
00113 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00114     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00115     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00116     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00117     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00118 #else // ANSI
00119 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00120     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00121     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00122     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00123     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00124 #endif
00125
00126 #endif // _MMC_GLOBALS_H
00127
00128
00129
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Recordset20.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Recordset20.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Recordset20
00019 /** @com.interface(iid=0000054F-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Recordset20 extends msado15.Recordset15
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=1000, type=PROPGET, name="AbsolutePosition", name2="getAbsolutePosition", addFlagsVtable=4)
00027       @com.parameters([type=I4] return) */
00028   public int getAbsolutePosition();
00029
00030   /** @com.method(vtoffset=6, dispid=1000, type=PROPPUT, name="AbsolutePosition", name2="putAbsolutePosition", addFlagsVtable=4)
00031       @com.parameters([in,type=I4] pl) */
00032   public void setAbsolutePosition(int pl);
00033
00034   /** @com.method(vtoffset=7, dispid=1001, type=PROPPUTREF, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00035       @com.parameters([in,iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] pvar) */
00036   public void setActiveConnection(Object pvar);
00037
00038   /** @com.method(vtoffset=8, dispid=1001, type=PROPPUT, name="ActiveConnection", name2="putActiveConnection", addFlagsVtable=4)
00039       @com.parameters([in,type=VARIANT] pvar) */
00040   public void setActiveConnection(Variant pvar);
00041
00042   /** @com.method(vtoffset=9, dispid=1001, type=PROPGET, name="ActiveConnection", name2="getActiveConnection", addFlagsVtable=4)
00043       @com.parameters([type=VARIANT] return) */
00044   public Variant getActiveConnection();
00045
00046   /** @com.method(vtoffset=10, dispid=1002, type=PROPGET, name="BOF", name2="getBOF", addFlagsVtable=4)
00047       @com.parameters([type=BOOLEAN] return) */
00048   public boolean getBOF();
00049
00050   /** @com.method(vtoffset=11, dispid=1003, type=PROPGET, name="Bookmark", name2="getBookmark", addFlagsVtable=4)
00051       @com.parameters([type=VARIANT] return) */
00052   public Variant getBookmark();
00053
00054   /** @com.method(vtoffset=12, dispid=1003, type=PROPPUT, name="Bookmark", name2="putBookmark", addFlagsVtable=4)
00055       @com.parameters([in,type=VARIANT] pvBookmark) */
00056   public void setBookmark(Variant pvBookmark);
00057
00058   /** @com.method(vtoffset=13, dispid=1004, type=PROPGET, name="CacheSize", name2="getCacheSize", addFlagsVtable=4)
00059       @com.parameters([type=I4] return) */
00060   public int getCacheSize();
00061
00062   /** @com.method(vtoffset=14, dispid=1004, type=PROPPUT, name="CacheSize", name2="putCacheSize", addFlagsVtable=4)
00063       @com.parameters([in,type=I4] pl) */
00064   public void setCacheSize(int pl);
00065
00066   /** @com.method(vtoffset=15, dispid=1005, type=PROPGET, name="CursorType", name2="getCursorType", addFlagsVtable=4)
00067       @com.parameters([type=I4] return) */
00068   public int getCursorType();
00069
00070   /** @com.method(vtoffset=16, dispid=1005, type=PROPPUT, name="CursorType", name2="putCursorType", addFlagsVtable=4)
00071       @com.parameters([in,type=I4] plCursorType) */
00072   public void setCursorType(int plCursorType);
00073
00074   /** @com.method(vtoffset=17, dispid=1006, type=PROPGET, name="EOF", name2="getEOF", addFlagsVtable=4)
00075       @com.parameters([type=BOOLEAN] return) */
00076   public boolean getEOF();
00077
00078   /** @com.method(vtoffset=18, dispid=0, type=PROPGET, name="Fields", name2="getFields", addFlagsVtable=4)
00079       @com.parameters([iid=00000564-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00080   public msado15.Fields getFields();
00081
00082   /** @com.method(vtoffset=19, dispid=1008, type=PROPGET, name="LockType", name2="getLockType", addFlagsVtable=4)
00083       @com.parameters([type=I4] return) */
00084   public int getLockType();
00085
00086   /** @com.method(vtoffset=20, dispid=1008, type=PROPPUT, name="LockType", name2="putLockType", addFlagsVtable=4)
00087       @com.parameters([in,type=I4] plLockType) */
00088   public void setLockType(int plLockType);
00089
00090   /** @com.method(vtoffset=21, dispid=1009, type=PROPGET, name="MaxRecords", name2="getMaxRecords", addFlagsVtable=4)
00091       @com.parameters([type=I4] return) */
00092   public int getMaxRecords();
00093
00094   /** @com.method(vtoffset=22, dispid=1009, type=PROPPUT, name="MaxRecords", name2="putMaxRecords", addFlagsVtable=4)
00095       @com.parameters([in,type=I4] plMaxRecords) */
00096   public void setMaxRecords(int plMaxRecords);
00097
00098   /** @com.method(vtoffset=23, dispid=1010, type=PROPGET, name="RecordCount", name2="getRecordCount", addFlagsVtable=4)
00099       @com.parameters([type=I4] return) */
00100   public int getRecordCount();
00101
00102   /** @com.method(vtoffset=24, dispid=1011, type=PROPPUTREF, name="Source", name2="putSource", addFlagsVtable=4)
00103       @com.parameters([in,iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] pvSource) */
00104   public void setSource(Object pvSource);
00105
00106   /** @com.method(vtoffset=25, dispid=1011, type=PROPPUT, name="Source", name2="putSource", addFlagsVtable=4)
00107       @com.parameters([in,type=STRING] pvSource) */
00108   public void setSource(String pvSource);
00109
00110   /** @com.method(vtoffset=26, dispid=1011, type=PROPGET, name="Source", name2="getSource", addFlagsVtable=4)
00111       @com.parameters([type=VARIANT] return) */
00112   public Variant getSource();
00113
00114   /** @com.method(vtoffset=27, dispid=1012, type=METHOD, name="AddNew", addFlagsVtable=4)
00115       @com.parameters([in,type=VARIANT] FieldList, [in,type=VARIANT] Values) */
00116   public void AddNew(Variant FieldList, Variant Values);
00117
00118   /** @com.method(vtoffset=28, dispid=1013, type=METHOD, name="CancelUpdate", addFlagsVtable=4)
00119       @com.parameters() */
00120   public void CancelUpdate();
00121
00122   /** @com.method(vtoffset=29, dispid=1014, type=METHOD, name="Close", addFlagsVtable=4)
00123       @com.parameters() */
00124   public void Close();
00125
00126   /** @com.method(vtoffset=30, dispid=1015, type=METHOD, name="Delete", addFlagsVtable=4)
00127       @com.parameters([in,type=I4] AffectRecords) */
00128   public void Delete(int AffectRecords);
00129
00130   /** @com.method(vtoffset=31, dispid=1016, type=METHOD, name="GetRows", addFlagsVtable=4)
00131       @com.parameters([in,type=I4] Rows, [in,type=VARIANT] Start, [in,type=VARIANT] Fields, [type=VARIANT] return) */
00132   public Variant GetRows(int Rows, Variant Start, Variant Fields);
00133
00134   /** @com.method(vtoffset=32, dispid=1017, type=METHOD, name="Move", addFlagsVtable=4)
00135       @com.parameters([in,type=I4] NumRecords, [in,type=VARIANT] Start) */
00136   public void Move(int NumRecords, Variant Start);
00137
00138   /** @com.method(vtoffset=33, dispid=1018, type=METHOD, name="MoveNext", addFlagsVtable=4)
00139       @com.parameters() */
00140   public void MoveNext();
00141
00142   /** @com.method(vtoffset=34, dispid=1019, type=METHOD, name="MovePrevious", addFlagsVtable=4)
00143       @com.parameters() */
00144   public void MovePrevious();
00145
00146   /** @com.method(vtoffset=35, dispid=1020, type=METHOD, name="MoveFirst", addFlagsVtable=4)
00147       @com.parameters() */
00148   public void MoveFirst();
00149
00150   /** @com.method(vtoffset=36, dispid=1021, type=METHOD, name="MoveLast", addFlagsVtable=4)
00151       @com.parameters() */
00152   public void MoveLast();
00153
00154   /** @com.method(vtoffset=37, dispid=1022, type=METHOD, name="Open", addFlagsVtable=4)
00155       @com.parameters([in,type=VARIANT] Source, [in,type=VARIANT] ActiveConnection, [in,type=I4] CursorType, [in,type=I4] LockType, [in,type=I4] Options) */
00156   public void Open(Variant Source, Variant ActiveConnection, int CursorType, int LockType, int Options);
00157
00158   /** @com.method(vtoffset=38, dispid=1023, type=METHOD, name="Requery", addFlagsVtable=4)
00159       @com.parameters([in,type=I4] Options) */
00160   public void Requery(int Options);
00161
00162   /** @com.method(vtoffset=39, dispid=1610809378, type=METHOD, name="_xResync", addFlagsVtable=4)
00163       @com.parameters([in,type=I4] AffectRecords)
00164       @hidden */
00165   public void _xResync(int AffectRecords);
00166
00167   /** @com.method(vtoffset=40, dispid=1025, type=METHOD, name="Update", addFlagsVtable=4)
00168       @com.parameters([in,type=VARIANT] Fields, [in,type=VARIANT] Values) */
00169   public void Update(Variant Fields, Variant Values);
00170
00171   /** @com.method(vtoffset=41, dispid=1047, type=PROPGET, name="AbsolutePage", name2="getAbsolutePage", addFlagsVtable=4)
00172       @com.parameters([type=I4] return) */
00173   public int getAbsolutePage();
00174
00175   /** @com.method(vtoffset=42, dispid=1047, type=PROPPUT, name="AbsolutePage", name2="putAbsolutePage", addFlagsVtable=4)
00176       @com.parameters([in,type=I4] pl) */
00177   public void setAbsolutePage(int pl);
00178
00179   /** @com.method(vtoffset=43, dispid=1026, type=PROPGET, name="EditMode", name2="getEditMode", addFlagsVtable=4)
00180       @com.parameters([type=I4] return) */
00181   public int getEditMode();
00182
00183   /** @com.method(vtoffset=44, dispid=1030, type=PROPGET, name="Filter", name2="getFilter", addFlagsVtable=4)
00184       @com.parameters([type=VARIANT] return) */
00185   public Variant getFilter();
00186
00187   /** @com.method(vtoffset=45, dispid=1030, type=PROPPUT, name="Filter", name2="putFilter", addFlagsVtable=4)
00188       @com.parameters([in,type=VARIANT] Criteria) */
00189   public void setFilter(Variant Criteria);
00190
00191   /** @com.method(vtoffset=46, dispid=1050, type=PROPGET, name="PageCount", name2="getPageCount", addFlagsVtable=4)
00192       @com.parameters([type=I4] return) */
00193   public int getPageCount();
00194
00195   /** @com.method(vtoffset=47, dispid=1048, type=PROPGET, name="PageSize", name2="getPageSize", addFlagsVtable=4)
00196       @com.parameters([type=I4] return) */
00197   public int getPageSize();
00198
00199   /** @com.method(vtoffset=48, dispid=1048, type=PROPPUT, name="PageSize", name2="putPageSize", addFlagsVtable=4)
00200       @com.parameters([in,type=I4] pl) */
00201   public void setPageSize(int pl);
00202
00203   /** @com.method(vtoffset=49, dispid=1031, type=PROPGET, name="Sort", name2="getSort", addFlagsVtable=4)
00204       @com.parameters([type=STRING] return) */
00205   public String getSort();
00206
00207   /** @com.method(vtoffset=50, dispid=1031, type=PROPPUT, name="Sort", name2="putSort", addFlagsVtable=4)
00208       @com.parameters([in,type=STRING] Criteria) */
00209   public void setSort(String Criteria);
00210
00211   /** @com.method(vtoffset=51, dispid=1029, type=PROPGET, name="Status", name2="getStatus", addFlagsVtable=4)
00212       @com.parameters([type=I4] return) */
00213   public int getStatus();
00214
00215   /** @com.method(vtoffset=52, dispid=1054, type=PROPGET, name="State", name2="getState", addFlagsVtable=4)
00216       @com.parameters([type=I4] return) */
00217   public int getState();
00218
00219   /** @com.method(vtoffset=53, dispid=1610809392, type=METHOD, name="_xClone", addFlagsVtable=4)
00220       @com.parameters([iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return)
00221       @hidden */
00222   public msado15._Recordset _xClone();
00223
00224   /** @com.method(vtoffset=54, dispid=1035, type=METHOD, name="UpdateBatch", addFlagsVtable=4)
00225       @com.parameters([in,type=I4] AffectRecords) */
00226   public void UpdateBatch(int AffectRecords);
00227
00228   /** @com.method(vtoffset=55, dispid=1049, type=METHOD, name="CancelBatch", addFlagsVtable=4)
00229       @com.parameters([in,type=I4] AffectRecords) */
00230   public void CancelBatch(int AffectRecords);
00231
00232   /** @com.method(vtoffset=56, dispid=1051, type=PROPGET, name="CursorLocation", name2="getCursorLocation", addFlagsVtable=4)
00233       @com.parameters([type=I4] return) */
00234   public int getCursorLocation();
00235
00236   /** @com.method(vtoffset=57, dispid=1051, type=PROPPUT, name="CursorLocation", name2="putCursorLocation", addFlagsVtable=4)
00237       @com.parameters([in,type=I4] plCursorLoc) */
00238   public void setCursorLocation(int plCursorLoc);
00239
00240   /** @com.method(vtoffset=58, dispid=1052, type=METHOD, name="NextRecordset", addFlagsVtable=4)
00241       @com.parameters([out,elementType=VARIANT,type=PTR] RecordsAffected, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00242   public msado15._Recordset NextRecordset(Variant RecordsAffected);
00243
00244   /** @com.method(vtoffset=59, dispid=1036, type=METHOD, name="Supports", addFlagsVtable=4)
00245       @com.parameters([in,type=I4] CursorOptions, [type=BOOLEAN] return) */
00246   public boolean Supports(int CursorOptions);
00247
00248   /** @com.method(vtoffset=60, dispid=4294967288, type=PROPGET, name="Collect", name2="getCollect", addFlagsVtable=4)
00249       @com.parameters([in,type=VARIANT] Index, [type=VARIANT] return)
00250       @hidden */
00251   public Variant getCollect(Variant Index);
00252
00253   /** @com.method(vtoffset=61, dispid=4294967288, type=PROPPUT, name="Collect", name2="putCollect", addFlagsVtable=4)
00254       @com.parameters([in,type=VARIANT] Index, [in,type=VARIANT] pvar)
00255       @hidden */
00256   public void setCollect(Variant Index, Variant pvar);
00257
00258   /** @com.method(vtoffset=62, dispid=1053, type=PROPGET, name="MarshalOptions", name2="getMarshalOptions", addFlagsVtable=4)
00259       @com.parameters([type=I4] return) */
00260   public int getMarshalOptions();
00261
00262   /** @com.method(vtoffset=63, dispid=1053, type=PROPPUT, name="MarshalOptions", name2="putMarshalOptions", addFlagsVtable=4)
00263       @com.parameters([in,type=I4] peMarshal) */
00264   public void setMarshalOptions(int peMarshal);
00265
00266   /** @com.method(vtoffset=64, dispid=1058, type=METHOD, name="Find", addFlagsVtable=4)
00267       @com.parameters([in,type=STRING] Criteria, [in,type=I4] SkipRecords, [in,type=I4] SearchDirection, [in,type=VARIANT] Start) */
00268   public void Find(String Criteria, int SkipRecords, int SearchDirection, Variant Start);
00269
00270   /** @com.method(vtoffset=65, dispid=1055, type=METHOD, name="Cancel", addFlagsVtable=4)
00271       @com.parameters() */
00272   public void Cancel();
00273
00274   /** @com.method(vtoffset=66, dispid=1056, type=PROPGET, name="DataSource", name2="getDataSource", addFlagsVtable=4)
00275       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00276   public IUnknown getDataSource();
00277
00278   /** @com.method(vtoffset=67, dispid=1056, type=PROPPUTREF, name="DataSource", name2="putDataSource", addFlagsVtable=4)
00279       @com.parameters([in,iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] ppunkDataSource) */
00280   public void setDataSource(IUnknown ppunkDataSource);
00281
00282   /** @com.method(vtoffset=68, dispid=1610874883, type=METHOD, name="_xSave", addFlagsVtable=4)
00283       @com.parameters([in,type=STRING] FileName, [in,type=I4] PersistFormat)
00284       @hidden */
00285   public void _xSave(String FileName, int PersistFormat);
00286
00287   /** @com.method(vtoffset=69, dispid=1061, type=PROPGET, name="ActiveCommand", name2="getActiveCommand", addFlagsVtable=4)
00288       @com.parameters([iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] return) */
00289   public Object getActiveCommand();
00290
00291   /** @com.method(vtoffset=70, dispid=1063, type=PROPPUT, name="StayInSync", name2="putStayInSync", addFlagsVtable=4)
00292       @com.parameters([in,type=BOOLEAN] pbStayInSync) */
00293   public void setStayInSync(boolean pbStayInSync);
00294
00295   /** @com.method(vtoffset=71, dispid=1063, type=PROPGET, name="StayInSync", name2="getStayInSync", addFlagsVtable=4)
00296       @com.parameters([type=BOOLEAN] return) */
00297   public boolean getStayInSync();
00298
00299   /** @com.method(vtoffset=72, dispid=1062, type=METHOD, name="GetString", addFlagsVtable=4)
00300       @com.parameters([in,type=I4] StringFormat, [in,type=I4] NumRows, [in,type=STRING] ColumnDelimeter, [in,type=STRING] RowDelimeter, [in,type=STRING] NullExpr, [type=STRING] return) */
00301   public String GetString(int StringFormat, int NumRows, String ColumnDelimeter, String RowDelimeter, String NullExpr);
00302
00303   /** @com.method(vtoffset=73, dispid=1064, type=PROPGET, name="DataMember", name2="getDataMember", addFlagsVtable=4)
00304       @com.parameters([type=STRING] return) */
00305   public String getDataMember();
00306
00307   /** @com.method(vtoffset=74, dispid=1064, type=PROPPUT, name="DataMember", name2="putDataMember", addFlagsVtable=4)
00308       @com.parameters([in,type=STRING] pbstrDataMember) */
00309   public void setDataMember(String pbstrDataMember);
00310
00311   /** @com.method(vtoffset=75, dispid=1065, type=METHOD, name="CompareBookmarks", addFlagsVtable=4)
00312       @com.parameters([in,type=VARIANT] Bookmark1, [in,type=VARIANT] Bookmark2, [type=I4] return) */
00313   public int CompareBookmarks(Variant Bookmark1, Variant Bookmark2);
00314
00315   /** @com.method(vtoffset=76, dispid=1034, type=METHOD, name="Clone", addFlagsVtable=4)
00316       @com.parameters([in,type=I4] LockType, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00317   public msado15._Recordset Clone(int LockType);
00318
00319   /** @com.method(vtoffset=77, dispid=1024, type=METHOD, name="Resync", addFlagsVtable=4)
00320       @com.parameters([in,type=I4] AffectRecords, [in,type=I4] ResyncValues) */
00321   public void Resync(int AffectRecords, int ResyncValues);
00322
00323
00324   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x54f, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00325 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ASYNC_REQUEST Member List

This is the complete list of members for _ASYNC_REQUEST, including all inherited members.
dwCommand | _ASYNC_REQUEST
dwRequestID | _ASYNC_REQUEST
pNext | _ASYNC_REQUEST
szCommand | _ASYNC_REQUEST
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/delebase.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

delebase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021
00022 const GUID CDelegationBase::thisGuid = { 0x2974380b, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 HBITMAP CDelegationBase::m_pBMapSm = NULL;
00025 HBITMAP CDelegationBase::m_pBMapLg = NULL;
00026
00027
00028 //==============================================================
00029 //
00030 // CDelegationBase implementation
00031 //
00032 //
00033 CDelegationBase::CDelegationBase()
00034 : bExpanded(FALSE)
00035 {
00036     if (NULL == m_pBMapSm || NULL == m_pBMapLg)
00037         LoadBitmaps();
00038 }
00039
00040 CDelegationBase::~CDelegationBase()
00041 {
00042 }
00043
00044 // CDelegationBase::AddImages sets up the collection of images to be displayed
00045 // by the IComponent in the result pane as a result of its MMCN_SHOW handler
00046 HRESULT CDelegationBase::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
00047 {
00048     return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
00049         (long *)m_pBMapLg, // pointer to a handle
00050         0, // index of the first image in the strip
00051         RGB(0, 128, 128)  // color of the icon mask
00052         );
00053 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/enumtask.h Source File

  • SysMgmt
  • MMC
  • Taskpads

enumtask.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _ENUMTASK_H
00021 #define _ENUMTASK_H
00022
00023 #include <mmc.h>
00024
00025 class CEnumTASK : public IEnumTASK
00026 {
00027 public:
00028     CEnumTASK(MMC_TASK *pTaskList, ULONG nTasks);
00029     virtual ~CEnumTASK();
00030
00031     ///////////////////////////////
00032     // Interface IUnknown
00033     ///////////////////////////////
00034     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00035     STDMETHODIMP_(ULONG) AddRef();
00036     STDMETHODIMP_(ULONG) Release();
00037
00038     ///////////////////////////////
00039     // Interface IEnumTASK
00040     ///////////////////////////////
00041     virtual HRESULT STDMETHODCALLTYPE Next(
00042         /* [in] */ ULONG celt,
00043         /* [length_is][size_is][out] */ MMC_TASK __RPC_FAR *rgelt,
00044         /* [out] */ ULONG __RPC_FAR *pceltFetched);
00045
00046         virtual HRESULT STDMETHODCALLTYPE Skip(
00047         /* [in] */ ULONG celt);
00048
00049         virtual HRESULT STDMETHODCALLTYPE Reset( void);
00050
00051     virtual HRESULT STDMETHODCALLTYPE Clone(
00052         /* [out] */ IEnumTASK __RPC_FAR *__RPC_FAR *ppenum);
00053
00054 private:
00055     MMC_TASK *m_pTaskList;
00056     ULONG m_TaskCount;
00057     ULONG m_CurrTask;
00058
00059     ULONG m_cref;
00060 };
00061
00062 #endif // _ENUMTASK_H
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/TempConsumer/Consumer.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • TempConsumer

Consumer.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  CONSUMER.CPP
00006 //
00007 // Description:
00008 //     Temporary Async Event Consumer which consumes the events
00009 //     produced by the provider in the "EventProvider" project.
00010 //
00011 //     The events that this consumer asks for are of class "MyEvent".
00012 //
00013 // History:
00014 //
00015 // **************************************************************************
00016
00017 #define _WIN32_WINNT    0x0400
00018
00019 #include <windows.h>
00020 #include <stdio.h>
00021 #include <wbemidl.h>
00022
00023 #include "oahelp.inl"
00024
00025
00026 //***************************************************************************
00027 //
00028 //***************************************************************************
00029
00030 class CMySink : public IWbemObjectSink
00031 {
00032     UINT m_cRef;
00033
00034 public:
00035     CMySink() { m_cRef = 1; }
00036    ~CMySink() { }
00037
00038     //
00039     // IUnknown members
00040     //
00041     STDMETHODIMP         QueryInterface(REFIID, LPVOID *);
00042     STDMETHODIMP_(ULONG) AddRef(void);
00043     STDMETHODIMP_(ULONG) Release(void);
00044
00045     virtual /* [id] */ HRESULT STDMETHODCALLTYPE Indicate(
00046             /* [in] */ long lObjectCount,
00047             /* [size_is][in] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObjArray
00048             );
00049
00050     virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetStatus(
00051             /* [in] */ long lFlags,
00052             /* [in] */ HRESULT hResult,
00053             /* [in] */ BSTR strParam,
00054             /* [in] */ IWbemClassObject __RPC_FAR *pObjParam
00055             );
00056 };
00057
00058
00059 //***************************************************************************
00060 //
00061 //***************************************************************************
00062
00063 STDMETHODIMP CMySink::QueryInterface(REFIID riid, LPVOID * ppv)
00064 {
00065     *ppv = 0;
00066
00067     if (IID_IUnknown==riid || IID_IWbemObjectSink == riid)
00068     {
00069         *ppv = (IWbemObjectSink *) this;
00070         AddRef();
00071         return NOERROR;
00072     }
00073
00074     return E_NOINTERFACE;
00075 }
00076
00077
00078 //***************************************************************************
00079 //
00080 //***************************************************************************
00081
00082 ULONG CMySink::AddRef()
00083 {
00084     return ++m_cRef;
00085 }
00086
00087 //***************************************************************************
00088 //
00089 //***************************************************************************
00090
00091 ULONG CMySink::Release()
00092 {
00093     if (0 != --m_cRef)
00094         return m_cRef;
00095
00096     delete this;
00097     return 0;
00098 }
00099
00100 //***************************************************************************
00101 //
00102 //***************************************************************************
00103
00104 HRESULT CMySink::Indicate(
00105     long lObjectCount,
00106     IWbemClassObject __RPC_FAR *__RPC_FAR *ppObjArray
00107     )
00108 {
00109     printf("Indicate called with %d object(s)\n", lObjectCount);
00110
00111     // Get the info from the object.
00112     // =============================
00113
00114     for (long i = 0; i < lObjectCount; i++)
00115     {
00116         IWbemClassObject *pObj = ppObjArray[i];
00117
00118         // If here, we know the object is one of the kind we asked for.
00119         // ============================================================
00120
00121         CVARIANT vName;
00122         HRESULT hr = pObj->Get(CBSTR(L"Name"), 0, &vName, 0, 0);
00123     if (FAILED(hr))
00124     {
00125       //could fail due to out of memory condition (CBSTR constructor failed
00126       //to allocate internal BSTR)
00127     }
00128         CVARIANT vValue;
00129         hr = pObj->Get(CBSTR(L"Value"), 0, &vValue, 0, 0);
00130     if (FAILED(hr))
00131     {
00132       //could fail due to out of memory condition (CBSTR constructor failed
00133       //to allocate internal BSTR)
00134     }
00135
00136         printf("Event info %S %u\n", vName.GetStr(), vValue.GetLONG());
00137     }
00138
00139     return WBEM_NO_ERROR;
00140 }
00141
00142
00143 //***************************************************************************
00144 //
00145 //***************************************************************************
00146
00147 HRESULT CMySink::SetStatus(
00148     /* [in] */ long lFlags,
00149     /* [in] */ HRESULT hResult,
00150     /* [in] */ BSTR strParam,
00151     /* [in] */ IWbemClassObject __RPC_FAR *pObjParam
00152     )
00153 {
00154     // Not called during event delivery.
00155
00156     return WBEM_NO_ERROR;
00157 }
00158
00159 //***************************************************************************
00160 //
00161 //***************************************************************************
00162
00163 BOOL ExecuteQuery(
00164     IWbemObjectSink *pDestSink,
00165     IWbemServices *pSvc
00166     )
00167 {
00168     CBSTR Language(L"WQL");
00169     CBSTR Query(L"select * from MyEvent");
00170
00171     HRESULT hRes = pSvc->ExecNotificationQueryAsync(
00172         Language,
00173         Query,
00174         0,                  // Flags
00175         0,                  // Context
00176         pDestSink
00177         );
00178
00179     if (hRes != 0)
00180         return FALSE;
00181
00182     return TRUE;
00183 }
00184
00185
00186
00187 //***************************************************************************
00188 //
00189 //***************************************************************************
00190
00191 void main(int argc, char **argv)
00192 {
00193     HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
00194   if (FAILED(hr))
00195   {
00196       printf("\nCoInitializeEx returned 0x%x", hr);
00197     return;
00198   }
00199
00200
00201   //  NOTE:
00202   //  When using asynchronous WMI API's remotely in an environment where the "Local System" account
00203   //  has no network identity (such as non-Kerberos domains), the authentication level of
00204   //  RPC_C_AUTHN_LEVEL_NONE is needed. However, lowering the authentication level to
00205   //  RPC_C_AUTHN_LEVEL_NONE makes your application less secure. It is wise to
00206   //  use semi-synchronous API's for accessing WMI data and events instead of the asynchronous ones.
00207
00208     hr = CoInitializeSecurity( NULL, -1, NULL, NULL,
00209                       RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
00210                       RPC_C_IMP_LEVEL_IMPERSONATE,
00211                       NULL,
00212                       EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
00213                       NULL );
00214   if (FAILED(hr))
00215   {
00216       printf("\nCoInitializeSecurity returned 0x%x", hr);
00217     return;
00218   }
00219
00220     IWbemLocator *pLoc = 0;
00221
00222     hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
00223             IID_IWbemLocator, (LPVOID *) &pLoc);
00224
00225    if (FAILED(hr))
00226     {
00227     printf("Failed to create IWbemLocator object. Error: 0x%x\n", hr );
00228         CoUninitialize();
00229         return;
00230     }
00231
00232
00233     // Connect to CIMOM.
00234     // =================
00235
00236     IWbemServices *pSvc = 0;
00237
00238     HRESULT hRes = pLoc->ConnectServer(
00239             CBSTR(L"\\\\.\\ROOT\\DEFAULT"),
00240             NULL,
00241             NULL,
00242             0,
00243             0,
00244             0,
00245             0,
00246             &pSvc
00247             );
00248
00249     if (hRes)
00250     {
00251         printf("Could not connect. Error code = 0x%X\n", hRes);
00252         CoUninitialize();
00253         return;
00254     }
00255
00256     // If here, we succeeded.
00257     // ======================
00258
00259
00260     printf("Connected to CIMOM.\n");
00261
00262
00263     // Create a new sink.
00264     // ===================
00265
00266     CMySink *pSink = new CMySink;
00267   if (pSink == NULL)
00268   {
00269     printf("Could not allocate sink: out of memory");
00270         CoUninitialize();
00271         return;
00272     }
00273
00274     BOOL bRes = ExecuteQuery(pSink, pSvc);
00275
00276     // Now, we wait until the user hits ENTER to stop.
00277     // ===============================================
00278
00279     if (bRes == TRUE)
00280     {
00281
00282         int input = 'a';
00283     while((input = getchar()) != '\n');
00284
00285         pSvc->CancelAsyncCall(pSink);
00286     }
00287     else
00288     {
00289         printf("Unable to execute the event query\n");
00290     }
00291
00292     // Cleanup.
00293     // ========
00294
00295     printf("Shutting down\n");
00296
00297     pSink->Release();
00298     pSvc->Release();
00299     pLoc->Release();
00300
00301     CoUninitialize();
00302 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Multisel

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDrawArea Member List

This is the complete list of members for CDrawArea, including all inherited members.
AddKeystroke(char *mbsKey) | CDrawArea |
AddKeystroke(char *mbsKey) | CDrawArea |
AddKeystroke(char *mbsKey) | CDrawArea |
AddLine(LINE line) | CDrawArea |
AddLine(LINE line) | CDrawArea |
AddLine(LINE line) | CDrawArea |
CDrawArea() | CDrawArea |
CDrawArea() | CDrawArea |
CDrawArea() | CDrawArea |
CtlColor(CDC *pDC, UINT nCtlColor) | CDrawArea | [protected]
CtlColor(CDC *pDC, UINT nCtlColor) | CDrawArea | [protected]
CtlColor(CDC *pDC, UINT nCtlColor) | CDrawArea | [protected]
m_listLines | CDrawArea | [protected]
m_ptLast | CDrawArea | [protected]
OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) | CDrawArea | [protected]
OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) | CDrawArea | [protected]
OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) | CDrawArea | [protected]
OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | CDrawArea | [protected]
OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | CDrawArea | [protected]
OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | CDrawArea | [protected]
OnLButtonDblClk(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnLButtonDblClk(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnLButtonDblClk(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnLButtonDown(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnLButtonDown(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnLButtonDown(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnMouseMove(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnMouseMove(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnMouseMove(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnPaint() | CDrawArea | [protected]
OnPaint() | CDrawArea | [protected]
OnPaint() | CDrawArea | [protected]
OnRButtonUp(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnRButtonUp(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnRButtonUp(UINT nFlags, CPoint point) | CDrawArea | [protected]
OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message) | CDrawArea | [protected]
OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message) | CDrawArea | [protected]
OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message) | CDrawArea | [protected]
OnSetFocus(CWnd *pOldWnd) | CDrawArea | [protected]
OnSetFocus(CWnd *pOldWnd) | CDrawArea | [protected]
OnSetFocus(CWnd *pOldWnd) | CDrawArea | [protected]
~CDrawArea() | CDrawArea | [virtual]
~CDrawArea() | CDrawArea | [virtual]
~CDrawArea() | CDrawArea | [virtual]
Generated on Wed Nov 13 2024 16:56:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHuman Member List

This is the complete list of members for CHuman, including all inherited members.
CHuman() | CHuman | [inline]
EnterNewGame(IN BSTR bstrLocalName, OUT VARIANT *pvGameID, OUT VARIANT *pvName, OUT VARIANT *pvOrder) | CHuman |
GetNewMove(IN long lGameID, IN long lOrder, OUT VARIANT *pvName, OUT VARIANT *pvFoeX, OUT VARIANT *pvFoeY, OUT VARIANT *pvWin, OUT VARIANT *pvUpdate) | CHuman |
HowManyTurns() | CHuman | [private]
InitArray() | CHuman | [inline, private]
InterfaceSupportsErrorInfo(REFIID riid) | CHuman | [private]
IsWin(long lPlayer) | CHuman | [private]
LoadArray(long lGameID) | CHuman | [private]
NewMove(IN long lGameID, IN long lOrder, IN long lX, IN long lY, OUT VARIANT *pvWin) | CHuman |
plField | CHuman | [private]
SaveArray(long lGameID) | CHuman | [private]
Generated on Wed Nov 13 2024 16:56:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/AboutDlg.c Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

AboutDlg.c

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1996 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:  aboutdlg.c
00009 //
00010 // Overview:   contains the windows functions used by the about box
00011 //
00012 // PLATFORMS:  Windows NT (only)
00013 //
00014 //  FUNCTIONS:  About() About box DlgProc
00015 //
00016 //
00017 // Windows Header Files:
00018 #define WIN32_LEAN_AND_MEAN 1
00019 #include <windows.h>
00020
00021 // C RunTime Header Files
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024
00025 // Local Header Files
00026 #include "statlist.h"
00027 #include "winutils.h"
00028 #include "aboutdlg.h"
00029 //
00030 //  FUNCTION: About(HWND, unsigned, WORD, LONG)
00031 //
00032 //  PURPOSE:  Processes messages for "About" dialog box
00033 //       This version allows greater flexibility over the contents of the 'About' box,
00034 //       by pulling out values from the 'Version' resource.
00035 //
00036 //  MESSAGES:
00037 //
00038 // WM_INITDIALOG - initialize dialog box
00039 // WM_COMMAND    - Input received
00040 //
00041 //
00042 LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00043 {
00044    static  HFONT hfontDlg;    // Font for dialog text
00045    static   HFONT hFinePrint; // Font for 'fine print' in dialog
00046    DWORD   dwVerInfoSize;     // Size of version information block
00047    LPSTR   lpVersion;         // String pointer to 'version' text
00048    DWORD   dwVerHnd=0;        // An 'ignored' parameter, always '0'
00049    UINT    uVersionLen;
00050    BOOL    bRetCode;
00051    int     i;
00052    char    szFullPath[256];
00053    char    szResult[256];
00054    char    szGetName[256];
00055    DWORD dwVersion;
00056    char  szVersion[40];
00057    DWORD dwResult;
00058
00059    switch (message)
00060    {
00061    case WM_INITDIALOG:
00062       // hide window while it's being constructed
00063       ShowWindow (hDlg, SW_HIDE);
00064
00065       // crate and load the fonts to be used for the text
00066       hfontDlg = CreateFont(14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00067                             VARIABLE_PITCH | FF_SWISS, "");
00068       hFinePrint = CreateFont(11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00069                               VARIABLE_PITCH | FF_SWISS, "");
00070
00071       // position the window in the center of the parent
00072       CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
00073
00074       // get the .exe path
00075       GetModuleFileName ((HINSTANCE)(GetWindowLongPtr(hDlg, GWLP_HINSTANCE)),
00076                          szFullPath, sizeof(szFullPath));
00077
00078       // Now lets dive in and pull out the version information:
00079       dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
00080       if (dwVerInfoSize)
00081       {
00082          LPSTR   lpstrVffInfo;
00083          HANDLE  hMem;
00084          hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
00085          lpstrVffInfo  = GlobalLock(hMem);
00086          GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpstrVffInfo);
00087          // The below 'hex' value looks a little confusing, but
00088          // essentially what it is, is the hexidecimal representation
00089          // of a couple different values that represent the language
00090          // and character set that we are wanting string values for.
00091          // 040904E4 is a very common one, because it means:
00092          //   US English, Windows MultiLingual characterset
00093          // Or to pull it all apart:
00094          // 04------        = SUBLANG_ENGLISH_USA
00095          // --09----        = LANG_ENGLISH
00096          // --11----        = LANG_JAPANESE
00097          // ----04E4 = 1252 = Codepage for Windows:Multilingual
00098
00099          _snprintf(szGetName, 256, "%sProductName", GetStringRes(IDS_VER_INFO_LANG));
00100
00101          // Set the title of the dialog:
00102          bRetCode = VerQueryValue((LPVOID)lpstrVffInfo,
00103                                   (LPSTR)szGetName,
00104                                   (LPVOID)&lpVersion,
00105                                   (UINT *)&uVersionLen);
00106
00107          // Notice order of version and string...
00108          _snprintf(szResult, 256, "About %s", lpVersion);
00109
00110          // set dialog caption
00111          SetWindowText (hDlg, szResult);
00112
00113          // Walk through the dialog items that we want to replace:
00114          for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++)
00115          {
00116             GetDlgItemText(hDlg, i, szResult, sizeof(szResult));
00117             _snprintf(szGetName, 256, "%s%s", GetStringRes(IDS_VER_INFO_LANG), szResult);
00118             uVersionLen   = 0;
00119             lpVersion     = NULL;
00120             bRetCode      =  VerQueryValue((LPVOID)lpstrVffInfo,
00121                                            (LPSTR)szGetName,
00122                                            (LPVOID)&lpVersion,
00123                                            (UINT *)&uVersionLen);
00124
00125             if ( bRetCode && uVersionLen && lpVersion)
00126             {
00127                // Replace dialog item text with version info
00128                lstrcpyn(szResult, lpVersion, 256);
00129                SetDlgItemText(hDlg, i, szResult);
00130             }
00131             else
00132             {
00133                dwResult = GetLastError();
00134
00135                _snprintf(szResult, 256, GetStringRes(IDS_VERSION_ERROR), dwResult);
00136                SetDlgItemText (hDlg, i, szResult);
00137             }
00138             SendMessage (GetDlgItem (hDlg, i), WM_SETFONT,
00139                          (UINT_PTR)((i==DLG_VERLAST)?hFinePrint:hfontDlg),
00140                          TRUE);
00141          } // for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++)
00142
00143          GlobalUnlock(hMem);
00144          GlobalFree(hMem);
00145
00146       }
00147       else
00148       {
00149          // No version information available.
00150
00151       } // if (dwVerInfoSize)
00152
00153       SendMessage (GetDlgItem (hDlg, IDC_LABEL), WM_SETFONT,
00154                    (WPARAM)hfontDlg,(LPARAM)TRUE);
00155
00156       // We are  using GetVersion rather then GetVersionEx
00157       // because earlier versions of Windows NT and Win32s
00158       // didn't include GetVersionEx:
00159       dwVersion = GetVersion();
00160
00161       if (dwVersion < 0x80000000)
00162       {
00163          // Windows NT
00164          _snprintf(szVersion, 40, "Microsoft Windows NT %u.%u (Build: %u)",
00165                    (DWORD)(LOBYTE(LOWORD(dwVersion))),
00166                    (DWORD)(HIBYTE(LOWORD(dwVersion))),
00167                    (DWORD)(HIWORD(dwVersion)) );
00168       }
00169       else if (LOBYTE(LOWORD(dwVersion))<4)
00170       {
00171          // Win32s
00172          _snprintf(szVersion, 40, "Microsoft Win32s %u.%u (Build: %u)",
00173                    (DWORD)(LOBYTE(LOWORD(dwVersion))),
00174                    (DWORD)(HIBYTE(LOWORD(dwVersion))),
00175                    (DWORD)(HIWORD(dwVersion) & ~0x8000) );
00176       }
00177       else
00178       {
00179          // Windows 95
00180          _snprintf(szVersion, 40, "Microsoft Windows 95 %u.%u",
00181                    (DWORD)(LOBYTE(LOWORD(dwVersion))),
00182                    (DWORD)(HIBYTE(LOWORD(dwVersion))) );
00183       }
00184
00185       SetWindowText (GetDlgItem(hDlg, IDC_OSVERSION), szVersion);
00186
00187       // now display the finished product
00188       ShowWindow (hDlg, SW_SHOW);
00189       return (TRUE);
00190
00191    case WM_COMMAND:
00192       if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
00193       {
00194          EndDialog(hDlg, TRUE);
00195          DeleteObject (hfontDlg);
00196          DeleteObject (hFinePrint);
00197          return (TRUE);
00198       }
00199       break;
00200    }
00201
00202    return FALSE;
00203 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Parent/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Parent
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__3E24B180_AFD5_11D2_9A74_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__3E24B180_AFD5_11D2_9A74_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__3E24B180_AFD5_11D2_9A74_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Complete/people.h Source File

  • SysMgmt
  • MMC
  • Complete

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //      This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBicycle : public CDelegationBase {
00026 public:
00027     CBicycle(int i) : id(i) { }
00028     virtual ~CBicycle() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00033
00034 private:
00035     // {9E3FF366-6BE7-11d3-9156-00C04F65B3F9}
00036     static const GUID thisGuid;
00037
00038     int id;
00039 };
00040
00041 class CBicycleFolder : public CDelegationBase {
00042 public:
00043     CBicycleFolder();
00044     virtual ~CBicycleFolder();
00045
00046     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Bicycles"); }
00047     virtual const GUID & getNodeType() { return thisGuid; }
00048     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00049     virtual void SetScopeItemValue(HSCOPEITEM hscopeitem) { m_hParentHScopeItem = hscopeitem; }
00050     virtual HSCOPEITEM GetParentScopeItem() { return m_hParentHScopeItem; }
00051
00052 public:
00053     // virtual functions go here (for MMCN_*)
00054     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00055
00056 private:
00057     // {9671350A-6BE7-11d3-9156-00C04F65B3F9}
00058     static const GUID thisGuid;
00059
00060     HSCOPEITEM m_hParentHScopeItem;
00061
00062     enum { NUMBER_OF_CHILDREN = 20 };
00063     CDelegationBase *children[NUMBER_OF_CHILDREN];
00064 };
00065
00066 class CSkateboard : public CDelegationBase {
00067 public:
00068     CSkateboard(int i) : id(i) { }
00069     virtual ~CSkateboard() {}
00070
00071     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00072     virtual const GUID & getNodeType() { return thisGuid; }
00073     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00074
00075 private:
00076     // {A6707E01-6BE7-11d3-9156-00C04F65B3F9}
00077     static const GUID thisGuid;
00078
00079     int id;
00080 };
00081
00082 class CSkateboardFolder : public CDelegationBase {
00083 public:
00084     CSkateboardFolder();
00085     virtual ~CSkateboardFolder();
00086
00087     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Skateboards"); }
00088     virtual const GUID & getNodeType() { return thisGuid; }
00089     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00090     virtual void SetScopeItemValue(HSCOPEITEM hscopeitem) { m_hParentHScopeItem = hscopeitem; }
00091     virtual HSCOPEITEM GetParentScopeItem() { return m_hParentHScopeItem; }
00092
00093 public:
00094     // virtual functions go here (for MMCN_*)
00095     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00096
00097 private:
00098     // {9671350B-6BE7-11d3-9156-00C04F65B3F9}
00099     static const GUID thisGuid;
00100
00101     HSCOPEITEM m_hParentHScopeItem;
00102
00103     enum { NUMBER_OF_CHILDREN = 20 };
00104     CDelegationBase *children[NUMBER_OF_CHILDREN];
00105 };
00106
00107 class CIceSkate : public CDelegationBase {
00108 public:
00109     CIceSkate(int i) : id(i) { }
00110     virtual ~CIceSkate() {}
00111
00112     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00113     virtual const GUID & getNodeType() { return thisGuid; }
00114     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00115
00116 private:
00117     // {A6707E02-6BE7-11d3-9156-00C04F65B3F9}
00118     static const GUID thisGuid;
00119
00120     int id;
00121 };
00122
00123 class CIceSkateFolder : public CDelegationBase {
00124 public:
00125     CIceSkateFolder();
00126     virtual ~CIceSkateFolder();
00127
00128     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Ice Skates"); }
00129     virtual const GUID & getNodeType() { return thisGuid; }
00130     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00131     virtual void SetScopeItemValue(HSCOPEITEM hscopeitem) { m_hParentHScopeItem = hscopeitem; }
00132     virtual HSCOPEITEM GetParentScopeItem() { return m_hParentHScopeItem; }
00133
00134 public:
00135     // virtual functions go here (for MMCN_*)
00136     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00137
00138 private:
00139     // {9E3FF365-6BE7-11d3-9156-00C04F65B3F9}
00140     static const GUID thisGuid;
00141
00142     HSCOPEITEM m_hParentHScopeItem;
00143
00144     enum { NUMBER_OF_CHILDREN = 20 };
00145     CDelegationBase *children[NUMBER_OF_CHILDREN];
00146 };
00147
00148 class CPeoplePoweredVehicle : public CDelegationBase {
00149 public:
00150     CPeoplePoweredVehicle();
00151     virtual ~CPeoplePoweredVehicle();
00152
00153     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00154     virtual const GUID & getNodeType() { return thisGuid; }
00155     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00156
00157     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00158
00159     virtual void SetScopeItemValue(HSCOPEITEM hscopeitem) { m_hParentHScopeItem = hscopeitem; }
00160     virtual HSCOPEITEM GetParentScopeItem() { return m_hParentHScopeItem; }
00161
00162 private:
00163     enum { IDM_NEW_PEOPLE = 1 };
00164
00165     // {96713509-6BE7-11d3-9156-00C04F65B3F9}
00166     static const GUID thisGuid;
00167
00168     HSCOPEITEM m_hParentHScopeItem;
00169
00170         enum { NUMBER_OF_CHILDREN = 3 };
00171     CDelegationBase *children[3];
00172 };
00173
00174 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/eventlog/log.c Source File

  • WinBase
  • Debug
  • eventlog

log.c

Go to the documentation of this file.
00001 // Copyright (c) Microsoft Corporation. All rights reserved.
00002 /*
00003 version 1.0 (initial NT 3.1 release)
00004 version 1.1 (NT 3.51 release)
00005   - added support for replaceable parameter strings ("%%xxx" codes)
00006   - corrected processing of registry API return codes and errors
00007   - added support for PrimaryModule key - default message file
00008   - added support for multiple message files per message
00009   - can now dump arbitrary log from command line
00010 version 1.2
00011   - fixed bug with multiple paths ('path;path' format) for message DLL
00012   - display event type (error, warning, etc.) as string instead of number
00013   - dumps account names from SID in eventlog record
00014 version 1.3
00015   - added category ID support
00016   - added logging of the callers Sid
00017 version 1.4
00018   - added support for remote logging. Easier than I thought. :-)
00019   - removed FormatMessage call to insert message strings - do it manually
00020     like the Event Viewer to avoid unwanted formatting of the message string
00021 version 1.5
00022   - fixed queryEventLog() to handle events registered with NULL for src name
00023 version 1.6
00024   - added support for default category message files (new to Win2000)
00025 version 1.7 5/8/01
00026   - fixed bug in lookupStringFromMsgDll with messages with multiple message
00027     DLLs in the EventMessageFile key
00028   - enabled security log read privilege for Win2000
00029   - ported to 64-bit (5 minutes :-)
00030 version 1.8 6/11/01
00031   - fixed memory leak bug, didn't free temp string after returning from all
00032     calls to lookupStringFromMsgDll. Dumping huge logs would leak memory like
00033     crazy.
00034   - Added code to print the first and last record sequence number using
00035     GetOldestEventLogRecord
00036
00037 ToDo: this sample isn't super robust and will not cleanly recover from all
00038   possible problems, though I do try to handle the major, common problems.
00039   Robustness left as an excercise for the reader. :-)
00040
00041 Known issues/bugs:
00042   - remote eventlogging: please see readme.txt for details.
00043
00044 Written by Eric Sassaman, Microsoft Developer Support
00045 */
00046
00047 #include <stdio.h>
00048 #include <windows.h>
00049 #include <strsafe.h>
00050 #include <string.h>
00051 #include <stdlib.h>
00052 #include <process.h>
00053 #include "messages.h"
00054
00055 #define LOGSAMPVER 1.8
00056 #define PERR(bSuccess, api) {if (!(bSuccess)) printf("\n%s: Error %d from %s \
00057     on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
00058 #define REG_ERR(lRegError, api) {if (lRegError!=ERROR_SUCCESS) printf("%s: \
00059     Error %d from %s on line %d\n", __FILE__, lRegError, api, __LINE__);}
00060
00061 #define MAX_MSG_LENGTH 3000
00062 #define MSG_ID_MASK 0x0000FFFF
00063 /* MACHINE should either be NULL for local logging or a UNC name of a remote
00064    machine, i.e. "\\\\Server1" */
00065 #define MACHINE_NAME NULL
00066 /* if MACHINE_NAME != NULL, REMOTE_MSG_DLL_PATH must have a UNC path to the proper
00067    directory containing messages.dll. The target machine must have access to
00068    this directory via the UNC pathname given */
00069 #define REMOTE_MSG_DLL_PATH "\\\\ericsa2\\d$\\ntwork\\eventlog"
00070
00071 /*********************************************************************
00072 * FUNCTION: addSourceToRegistry(LPSTR pszLogName, LPSTR pszSrcName,  *
00073 *                               LPSTR pszMsgDLL)                     *
00074 *                                                                    *
00075 * PURPOSE: Add a source name key, message DLL name value, and        *
00076 *          'message types supported' value to the registry           *
00077 *                                                                    *
00078 * INPUT: name of log (Application, System, or Security),             *
00079 *        source name, path of message DLL                            *
00080 *                                                                    *
00081 * RETURNS: none                                                      *
00082 *********************************************************************/
00083
00084 void addSourceToRegistry(LPSTR pszLogName, LPSTR pszSrcName, LPSTR pszMsgDLL)
00085 {
00086   HKEY hk, hklm;          // registry key handle
00087   DWORD dwData;
00088   TCHAR szTemp[MAX_PATH];
00089   LONG lRegError;         // return value from registry APIs
00090
00091   /* connect to remote registry (or local if MACHINE_NAME == NULL) */
00092   lRegError = RegConnectRegistry(MACHINE_NAME, HKEY_LOCAL_MACHINE, &hklm);
00093   REG_ERR(lRegError, "RegConnectRegistry");
00094   /* When a process uses the RegisterEventSource or OpenEventLog function to
00095      get a handle of an event log, the event logging service searches for the
00096      specified source name in the registry. You can add a new source name to
00097      the registry by opening a new registry subkey under the EventLog key and
00098      adding registry values to the new subkey. */
00099   // Create a new key for our source
00100   StringCbPrintf(szTemp,sizeof(szTemp), "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s",
00101       pszLogName, pszSrcName);
00102   lRegError = RegCreateKey(hklm, szTemp, &hk);
00103   REG_ERR(lRegError, "RegCreateKey");
00104   RegCloseKey(hklm);
00105   // Add the Event-ID message-file name to the subkey.
00106   lRegError = RegSetValueEx(hk,  // subkey handle
00107       "EventMessageFile",        // value name
00108       0,                         // must be zero
00109       REG_EXPAND_SZ,             // value type
00110       (LPBYTE) pszMsgDLL,        // address of value data
00111       (DWORD) strlen(pszMsgDLL) + 1);    // length of value data
00112   REG_ERR(lRegError, "RegSetValueEx");
00113
00114   /* Add the Category message-file name to the subkey. These category strings
00115      correspond to the fwCategory parameter passed into ReportEvent(). */
00116
00117   lRegError = RegSetValueEx(hk,  // subkey handle
00118       "CategoryMessageFile",     // value name
00119       0,                         // must be zero
00120       REG_EXPAND_SZ,             // value type
00121       (LPBYTE) pszMsgDLL,        // address of value data
00122       (DWORD) strlen(pszMsgDLL) + 1);    // length of value data
00123   REG_ERR(lRegError, "RegSetValueEx");
00124
00125   /* Add the replaceable parameter message-file name to the subkey. This is
00126      used to replace %%nnn values in messages with the appropriate string */
00127   lRegError = RegSetValueEx(hk,  // subkey handle
00128       "ParameterMessageFile",    // value name
00129       0,                         // must be zero
00130       REG_EXPAND_SZ,             // value type
00131       (LPBYTE) pszMsgDLL,        // address of value data
00132       (DWORD) strlen(pszMsgDLL) + 1);    // length of value data
00133   REG_ERR(lRegError, "RegSetValueEx");
00134
00135   // Set the supported types flags and add it to the subkey.
00136   dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
00137     EVENTLOG_INFORMATION_TYPE;
00138   lRegError = RegSetValueEx(hk,  // subkey handle
00139       "TypesSupported",          // value name
00140       0,                         // must be zero
00141       REG_DWORD,                 // value type
00142       (LPBYTE) &dwData,          // address of value data
00143       sizeof(DWORD));            // length of value data
00144   REG_ERR(lRegError, "RegSetValueEx");
00145
00146   // Set the number of categories supported
00147   dwData = 3;
00148   lRegError = RegSetValueEx(hk,  // subkey handle
00149       "CategoryCount",           // value name
00150       0,                         // must be zero
00151       REG_DWORD,                 // value type
00152       (LPBYTE) &dwData,          // address of value data
00153       sizeof(DWORD));            // length of value data
00154   REG_ERR(lRegError, "RegSetValueEx");
00155   RegCloseKey(hk);
00156   return;
00157 } // addSourceToRegistry
00158
00159 /*********************************************************************
00160 * FUNCTION: reportAnEvent(LPSTR pszSrcName, DWORD dwIdEvent,         *
00161 *                         WORD wCategory, WORD cStrings,             *
00162 *                         LPTSTR *pszStrings);                       *
00163 *                                                                    *
00164 * PURPOSE: add the event to the event log                            *
00165 *                                                                    *
00166 * INPUT: source name, the event ID to report in the log,             *
00167 *        the category, the number of insert strings, and an array of *
00168 *        null-terminated insert strings                              *
00169 *                                                                    *
00170 * RETURNS: none                                                      *
00171 *********************************************************************/
00172
00173 void reportAnEvent(LPSTR pszSrcName, DWORD dwIdEvent, WORD wCategory,
00174      WORD cStrings, LPTSTR * pszStrings)
00175 {
00176   #define SID_BUF_SIZE 1024
00177   HANDLE hLog;
00178   HANDLE hAccessToken;
00179   PTOKEN_USER ptgUser;
00180   BYTE UserBuf[SID_BUF_SIZE];
00181   DWORD cbUserBufSize = SID_BUF_SIZE;
00182   BOOL bSuccess;
00183
00184   // get the current process access token
00185   bSuccess = OpenProcessToken(GetCurrentProcess(),
00186             TOKEN_QUERY,
00187             &hAccessToken);
00188   PERR(bSuccess, "OpenProcessToken");
00189   ptgUser = (PTOKEN_USER) UserBuf;
00190   /* get the TOKEN_USER structure from the access token, which contains
00191      the Sid representing the caller */
00192   bSuccess = GetTokenInformation(hAccessToken,
00193             TokenUser,
00194             ptgUser,
00195             cbUserBufSize,
00196             &cbUserBufSize);
00197   PERR(bSuccess, "GetTokenInformation");
00198   CloseHandle(hAccessToken);
00199   // Get a handle to the event log
00200   hLog = RegisterEventSource(MACHINE_NAME,  // use machine defined elsewhere
00201       pszSrcName);                  // source name
00202   PERR(hLog, "RegisterEventSource");
00203   // Now report the event, which will add this event to the event log
00204   bSuccess = ReportEvent(hLog,  // event-log handle
00205       EVENTLOG_ERROR_TYPE,      // event type
00206       wCategory,                // category
00207       dwIdEvent,                // event ID
00208       ptgUser->User.Sid,        // Sid representing caller
00209       cStrings,                 // number of substitution strings
00210       0,                        // no binary data
00211       pszStrings,               // string array
00212       NULL);                    // address of data
00213   PERR(bSuccess, "ReportEvent");
00214   DeregisterEventSource(hLog);
00215   return;
00216 } // reportAnEvent
00217
00218 /*********************************************************************
00219 * FUNCTION: insertMsgString(HKEY hk, PTCHAR szMsg, WORD wNumStrings  *
00220 *     PTCHAR szInsStrings);                                          *
00221 *                                                                    *
00222 * PURPOSE: replace "%xxx" parameters in message strings with         *
00223 *          appropriate value from eventlog insert strings            *
00224 *                                                                    *
00225 * INPUT: message to scan for "%xxx" parameters, strings to insert,   *
00226 *        and the number of strings to insert                         *
00227 *                                                                    *
00228 * RETURNS: the string resulting from the string replacement          *
00229 *          operation. This memory must be freed by the caller via    *
00230 *          free().                                                   *
00231 *********************************************************************/
00232
00233 // size of replaceable parameter strings - should fit a DWORD as a string
00234 #define PARAM_SIZE (16)
00235
00236 PTCHAR insertMsgString(HKEY hk, PTCHAR szMsg, WORD wNumStrings,
00237     PTCHAR szInsStrings)
00238 {
00239   BOOL bSuccess;
00240   DWORD dwType;    // for RegQueryValueEx
00241   LONG lRegError;  // return value from registry APIs
00242   // paths to ParameterMessageFile
00243   TCHAR szParamMsgPath[MAX_PATH], szTemp[MAX_PATH];
00244   DWORD dwcbData;
00245   HINSTANCE hLib;   // handle to DLL containing ParameterMessageFile
00246   DWORD dwID;       // message ID
00247   LPTSTR msgBuf;
00248   PTCHAR szTempMsg;  // the message with replaced "%" or "%%" insert strings
00249   PTCHAR p1 = szMsg, p2 = szMsg; // temp pointers to walk the string
00250   PTCHAR szInsStr;   // point to insert strings in the EVENTLOGRECORD struct
00251   DWORD cchDest;
00252   int i;
00253
00254   szTempMsg = malloc(MAX_MSG_LENGTH);
00255   szTempMsg[0] = 0;
00256   while (p2)
00257   {
00258     p2 = strchr(p1, '%');
00259     if (!p2)  // "%" not found, just copy the rest of the string and quit
00260     {
00261       StringCbCat(szTempMsg,sizeof(szTempMsg), p1);
00262       continue;
00263     }
00264     strncat(szTempMsg, p1, p2 - p1);  // copy up to "%"
00265     /* is this a special "%%" string? If so, replace with language-dependant
00266        insert string from the ParameterMessageFile from registry. If it's not
00267        a "%%" string, skip down to else clause to replace as normal insert
00268        strings from the EVENTLOGRECORD structure */
00269     if (p2[1] == '%') // yup, it's a "%%" parameter string
00270     {
00271       p2 += 2;          // point to number, past the "%%"
00272       dwID = atoi(p2);  // get the message ID following the "%%"
00273       if (!dwID)        // it's not a number, copy "%%" as-is
00274       {
00275         StringCbCat(szTempMsg,sizeof(szTempMsg), "%%");
00276         p1 = p2;
00277         continue;
00278       }
00279       else
00280         p1 = p2 + strspn(p2, "0123456789"); // point past number
00281
00282       /* now look up the string corresponding to the message ID and append
00283          it into our temp string */
00284       dwcbData = MAX_PATH;
00285       lRegError = RegQueryValueEx(hk,  // handle of key to query
00286           "ParameterMessageFile",      // value name
00287           NULL,                        // must be NULL
00288           &dwType,                     // address of type value
00289           (LPBYTE) szTemp,             // path to replaceable parameter message file
00290           &dwcbData);                  // length of value data
00291       REG_ERR(lRegError, "RegQueryValueEx");
00292
00293       /* Expand environment variable strings in the message DLL path name, in
00294          case any are there */
00295       cchDest = ExpandEnvironmentStrings(szTemp, szParamMsgPath, MAX_PATH);
00296       PERR(cchDest != 0, "ExpandEnvironmentStrings");
00297       PERR(cchDest < MAX_PATH, "ExpandEnvironmentStrings");
00298
00299       hLib = LoadLibraryEx(szParamMsgPath, NULL, DONT_RESOLVE_DLL_REFERENCES);
00300       PERR(hLib != NULL, "LoadLibraryEx");
00301       bSuccess = FormatMessage(
00302           FORMAT_MESSAGE_FROM_HMODULE |     // get the message from the DLL
00303           FORMAT_MESSAGE_ALLOCATE_BUFFER |  // allocate the msg buffer
00304           FORMAT_MESSAGE_ARGUMENT_ARRAY |   // lpArgs is an array of pointers
00305           FORMAT_MESSAGE_IGNORE_INSERTS |   // don't do any formatting
00306           70,                     // line length for the mesages
00307           hLib,                   // the messagetable DLL handle
00308           dwID,                   // message ID
00309           LANG_USER_DEFAULT,      // language ID
00310           (LPTSTR) &msgBuf,       // address of pointer to buffer for message
00311           PARAM_SIZE,             // maximum size of the message buffer
00312           NULL);                  // array of insert strings for the message
00313       PERR(bSuccess, "FormatMessage");
00314       FreeLibrary(hLib);
00315       StringCbCat(szTempMsg,sizeof(szTempMsg), msgBuf);
00316       LocalFree((HLOCAL) msgBuf);
00317     }
00318     else //a normal insert string, look up in EVENTLOGRECORD structure
00319     {
00320       p2++;            // point to number, past the "%"
00321       dwID = atoi(p2);  // get the message ID following the "%"
00322       if (!dwID)        // it's not a number, copy "%" as-is
00323       {
00324         StringCbCat(szTempMsg,sizeof(szTempMsg), "%");
00325         p1 = p2;
00326         continue;
00327       }
00328       else
00329         p1 = p2 + strspn(p2, "0123456789"); // point past number
00330       szInsStr = szInsStrings;
00331       for (i = 1; i < (int) dwID; i++) // find string number dwID
00332       {
00333         if (i > wNumStrings) // handle bogus string number
00334         {
00335           puts("**Error! Insert string ID too large");
00336           continue;
00337         }
00338         szInsStr += (strlen(szInsStr) + 1); // point to next string
00339       }
00340       StringCbCat(szTempMsg,sizeof(szTempMsg), szInsStr);
00341     } //else
00342   } //while
00343   return (szTempMsg);  // caller must free()!
00344 } // insertMsgString
00345
00346 /*********************************************************************
00347 * FUNCTION: lookupStringFromMsgDll(HKEY hk, DWORD dwEventID,         *
00348 *     WORD wNumStrings, PTCHAR szStrings, PTCHAR szMsgDllPath);      *
00349 *                                                                    *
00350 * PURPOSE: look up a string from a message file                      *
00351 *                                                                    *
00352 * INPUT: root of the key containing the eventlog info for this       *
00353 *        eventlog source, the ID of the string to look up, the       *
00354 *        number of replacement strings, the replacement strings      *
00355 *        from the EVENTLOGRECORD structure, and the list of message  *
00356 *        DLLs to search for the message                              *
00357 *                                                                    *
00358 * RETURNS: the string string from the message file. This string      *
00359 *          should be freed by the caller                             *
00360 *********************************************************************/
00361
00362 PTCHAR lookupStringFromMsgDll(HKEY hk, DWORD dwEventID, WORD wNumStrings,
00363     PTCHAR szStrings, PTCHAR szMsgDllPath)
00364 {
00365   DWORD cchDest;
00366   PTCHAR pMsgDll;   // one of the message DLLs in the list
00367   PTCHAR pNextDll;  // pointer to next DLL in the list
00368   HINSTANCE hLib;  // handle to the messagetable DLL
00369   LPTSTR msgBuf;   // hold text of the error message that we build
00370   PTCHAR p = NULL;
00371   TCHAR szTempMsg[MAX_MSG_LENGTH];
00372   BOOL bSuccess;
00373   TCHAR szMsgDllPathEx[MAX_PATH];  // after environment string expansion
00374
00375   /* Expand environment variable strings in the message DLL path name, in
00376      case any are there, such as %systemroot% */
00377   cchDest = ExpandEnvironmentStrings(szMsgDllPath, szMsgDllPathEx, MAX_PATH);
00378   PERR(cchDest != 0, "ExpandEnvironmentStrings");
00379   PERR(cchDest < MAX_PATH, "ExpandEnvironmentStrings");
00380
00381   // The list is delimited by ';' chars, check each DLL for the message
00382   pMsgDll = szMsgDllPathEx;  // point to beginning of DLL list
00383   while (pMsgDll)
00384   {
00385     pNextDll = strchr(szMsgDllPathEx, ';');
00386     if (pNextDll)
00387     {
00388       *pNextDll = 0;  // replace ';' with 0 to null terminate the name
00389       pNextDll++;     // point to the next name in the list
00390     }
00391
00392     // Now we've got a message DLL name, load the DLL.
00393     hLib = LoadLibraryEx(pMsgDll, NULL, DONT_RESOLVE_DLL_REFERENCES);
00394     PERR(hLib != NULL, "LoadLibraryEx");
00395     if (!hLib)
00396       continue;
00397
00398     /* retrieve the message from the messagetable DLL. For the language
00399     identifier, use the values we defined in the LanguageNames statements in
00400     the .mc file. If no LanguageNames values were defined in the .mc file, as
00401     in this case, use the LANG_USER_DEFAULT macro defined in winnt.h */
00402     bSuccess = FormatMessage(
00403         FORMAT_MESSAGE_FROM_HMODULE |     // get the message from the DLL
00404         FORMAT_MESSAGE_ALLOCATE_BUFFER |  // allocate the msg buffer for us
00405         FORMAT_MESSAGE_ARGUMENT_ARRAY |   // lpArgs is an array of pointers
00406         FORMAT_MESSAGE_IGNORE_INSERTS |   // just get the message
00407         70,                 // line length for the mesages
00408         hLib,               // the messagetable DLL handle
00409         dwEventID,          // message ID
00410         LANG_USER_DEFAULT,  // language ID
00411         (LPTSTR) &msgBuf,   // address of pointer to buffer for message
00412         MAX_MSG_LENGTH,     // maximum size of the message buffer
00413         NULL);              // array of insert strings for the message
00414     // if the message was not found, try the next DLL in the list
00415     if (!bSuccess && GetLastError() == ERROR_MR_MID_NOT_FOUND && pNextDll)
00416     {
00417       FreeLibrary(hLib);
00418       pMsgDll = pNextDll;  // point to next DLL in list (or NULL if no more)
00419       continue;            /* if the msg doesn't exist, and we have more
00420                               DLL's to check, continue down the list */
00421     }
00422     if (!bSuccess && GetLastError() == ERROR_MR_MID_NOT_FOUND) //Msg ID not found, no more DLLs
00423       printf("**Error: Message ID not found in Messagetable resource in DLL: %s\n",
00424           pMsgDll);
00425     else
00426       PERR(bSuccess, "FormatMessage");
00427
00428     // if everything is ok, continue on, otherwise proceed to next event
00429     if (bSuccess)
00430     {
00431       /* process insert strings. Call twice - insert strings may contain
00432          special "%%" language-dependant replaceable parameter strings */
00433       strncpy(szTempMsg, msgBuf,strlen(msgBuf));
00434       LocalFree((HLOCAL) msgBuf);
00435       p = insertMsgString(hk, szTempMsg, wNumStrings, szStrings);
00436       StringCbCopy(szTempMsg,sizeof(szTempMsg), p);
00437       free(p);  // free buffer allocated by insertParamString()
00438       p = insertMsgString(hk, szTempMsg, wNumStrings, szStrings);
00439       //we now have our formatted string, return it - we're done
00440       FreeLibrary(hLib);
00441       return(p);
00442       //don't free p again, it will be returned to the caller to free.
00443     } // if
00444     else
00445       p = NULL;
00446     pMsgDll = pNextDll;  // point to next DLL in list (or NULL if no more)
00447     // free the message DLL since we don't know if we'll need it again
00448     FreeLibrary(hLib);
00449   } // while
00450   return(p);  // p will be freed by our caller
00451 } // lookupStringFromMsgDll
00452
00453 /*********************************************************************
00454 * FUNCTION: queryEventLog(HANDLE hEventLog, LPCTSTR pszLogName,      *
00455 *           LPCTSTR pszSourceName)                                   *
00456 *                                                                    *
00457 * PURPOSE: dump out some of the data for each event in the specified *
00458 *          event log                                                 *
00459 *                                                                    *
00460 * INPUT: handle of the open eventlog (or NULL if not open), the name *
00461 *        of the log to dump (application, system, security),         *
00462 *        and the name of an eventlog source within that log (or NULL *
00463 *        if not available, but required if hLog is NULL)             *
00464 *                                                                    *
00465 * RETURNS: none                                                      *
00466 *                                                                    *
00467 *********************************************************************/
00468
00469 void queryEventLog(HANDLE hEventLog, LPCTSTR pszLogName, LPCTSTR pszSourceName)
00470 {
00471   EVENTLOGRECORD *pevlr;
00472   PBYTE bBuffer;    // hold the event log record raw data
00473   DWORD dwRead, dwNeeded;
00474   HANDLE hLog;                // handle to the log
00475   BOOL bSuccess;
00476   DWORD cRecords, dwOldestRecord, dwNewestRecord, cLastRec = 0;
00477   LONG lRegError;
00478   DWORD dwType;
00479   DWORD dwcbData;
00480   HKEY hklm, hk;
00481   TCHAR szTemp[MAX_PATH];
00482   TCHAR szPrimaryMsgFile[64] = { 0 };  // name of primary (default) message file
00483   TCHAR szPrimaryCatFile[64] = { 0 };  // name of primary (default) category file
00484   PTCHAR p;
00485
00486   // allocate memory on the heap for our buffer
00487
00488   bBuffer = malloc(1024*64);
00489   if (NULL == bBuffer)
00490   {
00491       // malloc failed
00492       return;
00493   }
00494
00495   if (!hEventLog)
00496   {
00497     HANDLE hToken;
00498     TOKEN_PRIVILEGES TokenPrivileges;
00499
00500     //Enable the SE_SECURITY_NAME priv to allow us to view the security log
00501     bSuccess = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken);
00502     PERR(bSuccess, "OpenProcessToken");
00503     bSuccess = LookupPrivilegeValue(NULL, SE_SECURITY_NAME,
00504         &(TokenPrivileges.Privileges[0].Luid));
00505     PERR(bSuccess, "LookupPrivilegeValue");
00506     TokenPrivileges.PrivilegeCount = 1;
00507     TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
00508     bSuccess = AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, 0, NULL,NULL);
00509     PERR(bSuccess, "AdjustTokenPrivileges");
00510
00511     hLog = OpenEventLog(MACHINE_NAME,
00512         pszSourceName);        // source name - assumed to be valid
00513     PERR(hLog, "OpenEventLog");
00514   }
00515   else
00516     hLog = hEventLog;
00517
00518   // Get the number of records in the log.
00519   bSuccess = GetNumberOfEventLogRecords(hLog, &cRecords);
00520   PERR(bSuccess, "GetNumberOfEventLogRecords");
00521   printf("There are %d records in the %s log.\n", cRecords, pszLogName);
00522   bSuccess = GetOldestEventLogRecord(hLog, &dwOldestRecord);
00523   PERR(bSuccess, "GetOldestEventLogRecord");
00524   /* the newest record may not be sequence #1 if the log is set to overwrite */
00525   dwNewestRecord = dwOldestRecord + cRecords - 1;
00526   printf("First record sequence number: %d, Last record sequence number: %d\n",
00527       dwOldestRecord, dwNewestRecord);
00528   /* If the eventlog key contains a PrimaryModule value, get the default
00529      messagefile from it. This is the default EventMessageFile if an
00530      EventMessageFile value doesn't exist for a given source. */
00531   StringCbPrintf(szTemp,sizeof(szTemp), "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s",
00532       pszLogName);
00533   lRegError = RegConnectRegistry(MACHINE_NAME, HKEY_LOCAL_MACHINE, &hklm);
00534   REG_ERR(lRegError, "RegConnectRegistry");
00535   lRegError = RegOpenKeyEx(hklm, szTemp, 0, KEY_READ, &hk);
00536   REG_ERR(lRegError, "RegOpenKeyEx");
00537   RegCloseKey(hklm);
00538   dwcbData = MAX_PATH;
00539   lRegError = RegQueryValueEx(hk,  // handle of key to query
00540       "PrimaryModule",             // value name
00541       NULL,                        // must be NULL
00542       &dwType,                     // address of type value
00543       (LPBYTE) szPrimaryMsgFile,   // path to primary (default) message DLL
00544       &dwcbData);                  // length of value data
00545   if (lRegError != ERROR_FILE_NOT_FOUND)  // the key doesn't exist, no default file
00546     REG_ERR(lRegError, "RegQueryValueEx");
00547   RegCloseKey(hk);
00548   /* if the key exists, get the default EventMessageFile and CategoryMessageFile
00549      from the specified subkey. Note that both keys may or may not exist. */
00550   if (lRegError == ERROR_SUCCESS)
00551   {
00552     StringCbCat(szTemp,sizeof(szTemp), "\\");
00553     StringCbCat(szTemp,sizeof(szTemp), szPrimaryMsgFile);
00554     lRegError = RegConnectRegistry(MACHINE_NAME, HKEY_LOCAL_MACHINE, &hklm);
00555     REG_ERR(lRegError, "RegConnectRegistry");
00556     lRegError = RegOpenKeyEx(hklm, szTemp, 0, KEY_READ, &hk);
00557     REG_ERR(lRegError, "RegOpenKeyEx");
00558     RegCloseKey(hklm);
00559     dwcbData = MAX_PATH;
00560     lRegError = RegQueryValueEx(hk,  // handle of key to query
00561         "EventMessageFile",          // value name
00562         NULL,                        // must be NULL
00563         &dwType,                     // address of type value
00564         (LPBYTE) szPrimaryMsgFile,   // path(s) to message DLL
00565         &dwcbData);                  // length of value data
00566     if (lRegError == ERROR_FILE_NOT_FOUND)
00567       szPrimaryMsgFile[0] = 0;       // no default; set it to NULL for later testing
00568     else
00569       REG_ERR(lRegError, "RegQueryValueEx");
00570     dwcbData = MAX_PATH;
00571     lRegError = RegQueryValueEx(hk,  // handle of key to query
00572         "CategoryMessageFile",       // value name
00573         NULL,                        // must be NULL
00574         &dwType,                     // address of type value
00575         (LPBYTE) szPrimaryCatFile,   // path(s) to message DLL
00576         &dwcbData);                  // length of value data
00577     if (lRegError == ERROR_FILE_NOT_FOUND)
00578       szPrimaryCatFile[0] = 0;       // no default; set it to NULL for later testing
00579     else
00580       REG_ERR(lRegError, "RegQueryValueEx");
00581     RegCloseKey(hk);
00582   }
00583
00584   pevlr = (EVENTLOGRECORD *) bBuffer;
00585   /* Opening the log positions the file pointer for this handle at the
00586      beginning of the log. Read records sequentially until there are no more
00587      records. */
00588   while (bSuccess = ReadEventLog(hLog,  // event-log handle
00589           EVENTLOG_FORWARDS_READ |      // read forward
00590           EVENTLOG_SEQUENTIAL_READ,     // sequential read
00591           0,                            // ignored for sequential reads
00592           bBuffer,                      // address of buffer
00593           sizeof(bBuffer),              // size of buffer
00594           &dwRead,                      // count of bytes read
00595           &dwNeeded))                   // bytes in next record
00596   {
00597     while (dwRead > 0)
00598     {
00599       /* Print the event ID, type, source name, and category. The source name
00600          is just past the end of the formal structure. */
00601       printf("\n%03d  Event ID: 0x%08X  EventType: ", pevlr->RecordNumber,
00602           pevlr->EventID);
00603       cLastRec = pevlr->RecordNumber;
00604       switch (pevlr->EventType)
00605       {
00606         case EVENTLOG_ERROR_TYPE:
00607           printf("EVENTLOG_ERROR_TYPE");
00608           break;
00609         case EVENTLOG_WARNING_TYPE:
00610           printf("EVENTLOG_WARNING_TYPE");
00611           break;
00612         case EVENTLOG_INFORMATION_TYPE:
00613           printf("EVENTLOG_INFORMATION_TYPE");
00614           break;
00615         case EVENTLOG_AUDIT_SUCCESS:
00616           printf("EVENTLOG_AUDIT_SUCCESS");
00617           break;
00618         case EVENTLOG_AUDIT_FAILURE:
00619           printf("EVENTLOG_AUDIT_FAILURE");
00620           break;
00621         default:
00622           printf("UNKNOWN");
00623           break;
00624       }
00625
00626       printf("\nSource: %s", (LPSTR) ((LPBYTE) pevlr + sizeof(EVENTLOGRECORD)));
00627       // mask off the actual message number and show it
00628       printf("  Message ID: %d", pevlr->EventID & MSG_ID_MASK);
00629
00630       /* From the event log source name, we know the name of the registry key
00631          to look under for the list of the message DLLs that may contain the
00632          message we need to extract with FormatMessage. Get the event log
00633          source name list... */
00634       // The source name follows the EVENTLOGRECORD structure
00635       StringCbPrintf(szTemp,sizeof(szTemp), "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s",
00636           pszLogName, (PTCHAR) ((LPBYTE) pevlr + sizeof(EVENTLOGRECORD)));
00637       /* Now open this key and get the EventMessageFile value, which is the
00638          list of the message DLLs for that source */
00639       lRegError = RegConnectRegistry(MACHINE_NAME, HKEY_LOCAL_MACHINE, &hklm);
00640       REG_ERR(lRegError, "RegConnectRegistry");
00641       lRegError = RegOpenKeyEx(hklm, szTemp, 0, KEY_READ, &hk);
00642       REG_ERR(lRegError, "RegOpenKeyEx");
00643       RegCloseKey(hklm);
00644
00645       // first, look up the path(s) to the category message DLL, use default if none
00646       dwcbData = MAX_PATH;
00647       lRegError = RegQueryValueEx(hk,  // handle of key to query
00648           "CategoryMessageFile",       // value name
00649           NULL,                        // must be NULL
00650           &dwType,                     // address of type value
00651           (LPBYTE) szTemp,             // path to category message DLL
00652           &dwcbData);                  // length of value data
00653       if (lRegError == ERROR_FILE_NOT_FOUND)
00654       {
00655         if (szPrimaryCatFile[0])
00656           StringCbCopy(szTemp,sizeof(szTemp), szPrimaryCatFile);
00657         else //must have been registered with NULL for source name
00658           szTemp[0] = 0; //no category DLL
00659       }
00660       else
00661         REG_ERR(lRegError, "RegQueryValueEx");
00662       // if we have a valid category DLL and the category is not 0 (none)
00663       if (szTemp[0] && pevlr->EventCategory)
00664       {
00665         // get the string from the category DLL
00666         p = lookupStringFromMsgDll(hk, pevlr->EventCategory, 0, NULL, szTemp);
00667         if (p)
00668         {
00669           printf("  Category: %s", p);
00670           free(p);
00671         }
00672       }
00673       else //category type is 0, no category DLL found, or no default category DLL
00674         printf("  Category: none");
00675       // print out the user's account name if the SID was logged in the record
00676       if (pevlr->UserSidLength)
00677       {
00678         TCHAR szAccountName[64], szDomainName[64];
00679         DWORD cbAccountSize, cbDomainSize;
00680         SID_NAME_USE snu;
00681         PSID psid;
00682
00683         /* get the user name associated with the Security identifier (SID)
00684            in the event log record */
00685         psid = (PSID)((LPBYTE) pevlr + pevlr->UserSidOffset);
00686         cbAccountSize = sizeof(szAccountName);
00687         cbDomainSize = sizeof(szDomainName);
00688         bSuccess = LookupAccountSid(NULL, psid, szAccountName, &cbAccountSize,
00689             szDomainName, &cbDomainSize, &snu);
00690         PERR(bSuccess, "LookupAccountSid");
00691         printf("  User: %s", bSuccess ? szAccountName : "N/A");
00692       }
00693
00694       // now look up the path(s) to the message DLL to get the message text
00695       dwcbData = MAX_PATH;
00696       lRegError = RegQueryValueEx(hk,  // handle of key to query
00697           "EventMessageFile",          // value name
00698           NULL,                        // must be NULL
00699           &dwType,                     // address of type value
00700           (LPBYTE) szTemp,             // path(s) to message DLL
00701           &dwcbData);                  // length of value data
00702       // if the message file isn't there, and a default exists, use default
00703       if (lRegError == ERROR_FILE_NOT_FOUND)
00704       {
00705         if (szPrimaryMsgFile[0])
00706           StringCbCopy(szTemp,sizeof(szTemp), szPrimaryMsgFile);
00707         else //must have been registered with NULL for source name
00708           szTemp[0] = 0; //no message DLL
00709       }
00710       else
00711         REG_ERR(lRegError, "RegQueryValueEx");
00712       if (szTemp[0])
00713       {
00714         /* get the message from the message DLL, replacing parameters and
00715            replaceable parameter strings as appropriate */
00716         p = lookupStringFromMsgDll(hk, pevlr->EventID, pevlr->NumStrings,
00717             (PTCHAR) ((LPBYTE) pevlr + pevlr->StringOffset), szTemp);
00718         if (p)
00719         {
00720           printf("\nMessage: %s\n", p);
00721           free(p);
00722         }
00723       }
00724       // Subtract the size of the event log record we just read
00725       dwRead -= pevlr->Length;
00726       // Point to the next event log record in the buffer
00727       pevlr = (EVENTLOGRECORD *) ((LPBYTE) pevlr + pevlr->Length);
00728       RegCloseKey(hk);  // close key for this event source
00729     } // while
00730     /* reset our event log record pointer back to the beginning of the buffer
00731        in preparation for reading the next record. */
00732     pevlr = (EVENTLOGRECORD *) bBuffer;
00733   } // while
00734   if (GetLastError() != ERROR_HANDLE_EOF)
00735     PERR(bSuccess, "ReadEventLog");
00736   /* If you're reading at the end of the eventlog and records are added, you may get
00737      ERROR_HANDLE_EOF if the write doesn't complete in time for the read. This is normal.
00738      If the write completes, the record will be read normally.
00739      If the eventlog is cleared while you're in the middle of reading it, then you'll
00740      get ERROR_EVENTLOG_FILE_CHANGED on the next ReadEventLog. */
00741   if (GetLastError() == ERROR_EVENTLOG_FILE_CHANGED)
00742     puts("The Eventlog has been changed by another process between reads.");
00743   /* If you want to check if new records have been added, perhaps before
00744      clearing the log, check the sequence number of most recent record */
00745   bSuccess = GetOldestEventLogRecord(hLog, &dwOldestRecord);
00746   PERR(bSuccess, "GetOldestEventLogRecord");
00747   bSuccess = GetNumberOfEventLogRecords(hLog, &cRecords);
00748   PERR(bSuccess, "GetNumberOfEventLogRecords");
00749   if (dwNewestRecord != dwOldestRecord + cRecords - 1)
00750     printf("New records have been added to the eventlog.\n"
00751         "Last record read was %d, newest record is %d\n", cLastRec, dwOldestRecord + cRecords - 1);
00752   if (!hEventLog)  // if we had to open the event log, close it
00753   {
00754     bSuccess = CloseEventLog(hLog);
00755     PERR(bSuccess, "CloseEventLog");
00756   }
00757   return;
00758 } // queryEventLog
00759
00760 void usage()
00761 {
00762   puts("log <[logname] [backuplog]>");
00763   puts("[logname] is an optional eventlog category such as Application, Security, or\n"
00764       "System. [backuplog] is the filename of a backup log file to view. If this\n"
00765       "parameter is specified, [logname] must be given as well.\n");
00766   return;
00767 } // usage()
00768
00769 void notifyChange(LPCTSTR logSource)
00770 {
00771   BOOL bSuccess;
00772   HANDLE hEventLog, hEvent;
00773   DWORD dwWaitResult;
00774
00775   hEvent = CreateEvent(NULL,    // address of security attributes
00776       FALSE,                    // no manual reset
00777       FALSE,                    // create as not signaled
00778       NULL);                    // event name
00779   hEventLog = OpenEventLog(MACHINE_NAME,  // open on machine defined elsewhere
00780       logSource);                 // event log source name
00781   PERR(hEventLog, "OpenEventLog");
00782   bSuccess = NotifyChangeEventLog(hEventLog,
00783       hEvent);
00784   PERR(bSuccess, "NotifyChangeEventLog");
00785   dwWaitResult = WaitForSingleObject(hEvent, INFINITE);
00786   if (dwWaitResult != WAIT_FAILED)
00787     printf("**Notification: %s has changed\n", logSource);
00788   else
00789     PERR(dwWaitResult == WAIT_FAILED, "WaitForSingleObject");
00790   CloseHandle(hEvent);
00791   //CloseHandle(hEventLog);
00792   return;
00793 } // notifyChange
00794
00795 /* To create your own log (other than Application, System, or Security), change
00796    LOGNAME to your custom log name. A new .evt file and registry key will be
00797    created by the eventlog service with this name to hold events logged to that
00798    log name. You can dump them by specifying the log name (less the .evt
00799    extension) on the command line for this sample. */
00800 /* NOTE: you must reboot after changing a logsource from one log (i.e. Application)
00801    to another (i.e. a custom log source key) */
00802 #define LOGNAME "Application"
00803 #define LOGSOURCE "LogSample"
00804
00805 int main(int argc, char *argv[])
00806 {
00807   TCHAR szMsgPath[MAX_PATH];
00808   PTCHAR aInsertStrs[16];  // array of pointers to insert strings
00809   TCHAR szTemp[MAX_PATH];
00810   BOOL bSuccess;
00811   HANDLE hEventLog;
00812   OSVERSIONINFO osv;
00813
00814   // Check to make sure we are running on Windows NT
00815   osv.dwOSVersionInfoSize = sizeof(osv);
00816   bSuccess = GetVersionEx(&osv);
00817   if (osv.dwPlatformId != VER_PLATFORM_WIN32_NT)
00818   {
00819     MessageBox(NULL, "Sorry, this application requires Windows NT.\n"
00820         "This application will now terminate.",
00821         "Error", MB_OK);
00822     return (1);
00823   }
00824   printf("Log.exe EventLog sample version %.2f\n", LOGSAMPVER);
00825   if (argc == 1)  // no args, use default defines
00826   {
00827     /* Set the Event-ID message-file name. For local logging, we assume that
00828        the message DLL is in the same directory as this application. For
00829        remote logging, this sample will access the message DLL over the net
00830        via a UNC name for simplicity. This will be very slow when reading a
00831        large number of events from the eventlog. */
00832     if (MACHINE_NAME == NULL)
00833       GetCurrentDirectory(sizeof(szMsgPath), szMsgPath);
00834     else
00835       StringCbCopy(szMsgPath,sizeof(szMsgPath), REMOTE_MSG_DLL_PATH);
00836     StringCbCat(szMsgPath, sizeof(szMsgPath), "\\messages.dll");
00837     addSourceToRegistry(LOGNAME, LOGSOURCE, szMsgPath);
00838
00839     // clear the event log
00840     hEventLog = OpenEventLog(MACHINE_NAME,  // open on machine defined elsewhere
00841         LOGSOURCE);                 // event log source name
00842     PERR(hEventLog, "OpenEventLog");
00843     bSuccess = ClearEventLog(hEventLog, NULL);
00844     PERR(bSuccess, "ClearEventLog");
00845     // can't use the log handle now that it's been cleared, we must close it
00846     bSuccess = CloseEventLog(hEventLog);
00847     PERR(bSuccess, "CloseEventLog");
00848
00849     /* set up a notification event thread that will print a message when the
00850        first message is added to LOGSOURCE. This will only work for local
00851        logging. */
00852     if (MACHINE_NAME == NULL)
00853     {
00854       _beginthread(notifyChange, 0, LOGSOURCE);
00855       Sleep(200); //give the thread time to initialize for this sample
00856     }
00857     // Set up our array of insert strings for our error message
00858     reportAnEvent(LOGSOURCE,  // source name
00859         MSG_BAD_COMMAND,      // the message to log
00860         CAT_1,                // category
00861         0,                    // number of insert strings
00862         aInsertStrs);         // the array of insert strings
00863     reportAnEvent(LOGSOURCE,  // source name
00864         MSG_BAD_PARM1,        // the message to log
00865         CAT_3,                // category
00866         0,                    // number of insert strings
00867         aInsertStrs);         // the array of insert strings
00868     reportAnEvent(LOGSOURCE,  // source name
00869         MSG_STRIKE_ANY_KEY,   // the message to log
00870         CAT_2,                // category
00871         0,                    // number of insert strings
00872         aInsertStrs);         // the array of insert strings
00873     aInsertStrs[0] = "2,567";
00874     aInsertStrs[1] = "10";
00875     reportAnEvent(LOGSOURCE,  // source name
00876         MSG_RETRYS,           // the message to log
00877         CAT_1,                // category
00878         2,                    // number of insert strings
00879         aInsertStrs);         // the array of insert strings
00880     StringCbCopy(szTemp,sizeof(szTemp), "%%");
00881     itoa(SPROCKETS, szTemp + 2, 10);  // concatenate the value
00882     aInsertStrs[0] = "foo.dat";
00883     aInsertStrs[1] = szTemp;
00884     reportAnEvent(LOGSOURCE,    // source name
00885         MSG_FILE_BAD_CONTENTS,  // the message to log
00886         CAT_1,                  // category
00887         2,                      // number of insert strings
00888         aInsertStrs);           // the array of insert strings
00889     aInsertStrs[0] = "a:";
00890     reportAnEvent(LOGSOURCE,    // source name
00891         MSG_INSERT_DISK,        // the message to log
00892         0,                      // category, 0 always means "none"
00893         1,                      // number of insert strings
00894         aInsertStrs);           // the array of insert strings
00895     queryEventLog(NULL, LOGNAME, LOGSOURCE);  // query the log
00896   }
00897   else
00898   {  // we've got parameters
00899     if (argc > 1 && !strcmpi(argv[1], "Application") ||
00900         !strcmpi(argv[1], "Security") || !strcmpi(argv[1], "System"))
00901     {
00902       if (argc > 2)  // got a backup log name
00903       {
00904         hEventLog = OpenBackupEventLog(NULL, argv[2]); // must be local
00905         if (hEventLog)
00906         {
00907           queryEventLog(hEventLog, argv[1], NULL);  // dump the backup log
00908           bSuccess = CloseEventLog(hEventLog);
00909           PERR(bSuccess, "CloseEventLog");
00910         }
00911         else
00912         {  // 2nd arg was bad
00913           printf("can't open backup eventlog %s\n", argv[2]);
00914           PERR(hEventLog, "OpenBackupEventLog");
00915           usage();
00916         }
00917       }
00918       else
00919       {  // only got logname, dump it
00920         HKEY hk, hklm;
00921         FILETIME ft;
00922         LONG lRegError;
00923         DWORD cchName = sizeof(szTemp);
00924
00925         // get arbitrary subkey of param to be used to open event log
00926         StringCbPrintf(szTemp,sizeof(szTemp), "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s",
00927             argv[1]);
00928         lRegError = RegConnectRegistry(MACHINE_NAME, HKEY_LOCAL_MACHINE, &hklm);
00929         REG_ERR(lRegError, "RegConnectRegistry");
00930         lRegError = RegOpenKeyEx(hklm, szTemp, 0, KEY_READ, &hk);
00931         REG_ERR(lRegError, "RegOpenKeyEx");
00932         RegCloseKey(hklm);
00933         lRegError = RegEnumKeyEx(hk, 0, szTemp, &cchName, NULL,
00934             NULL, NULL, &ft);
00935         REG_ERR(lRegError, "RegEnumKeyEx");
00936         queryEventLog(NULL, argv[1], szTemp);  // query the log
00937       }
00938     }
00939     else  // first arg was bad
00940       usage();
00941   }  // else
00942   return (0);
00943 }
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/CeError.Cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

CeError.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        ceerror.cpp
00007 //
00008 // Contents:    Cert Server error wrapper routines
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include <pch.cpp>
00013
00014 #pragma hdrstop
00015
00016 #include "celibw2k.h"
00017 #include <assert.h>
00018 #include <stdio.h>
00019 #include <ntdsbmsg.h>
00020
00021
00022 #define CERTLIB_12BITERRORMASK  0x00000fff
00023 #define CERTLIB_WIN32ERRORMASK  0x0000ffff
00024
00025
00026 //+--------------------------------------------------------------------------
00027 // Jet errors:
00028
00029 #define HRESULT_FROM_JETWARNING(jerr) \
00030   ((STATUS_SEVERITY_WARNING << 30) | (FACILITY_NTDSB << 16) | jerr)
00031
00032 #define HRESULT_FROM_JETERROR(jerr) \
00033   ((STATUS_SEVERITY_ERROR << 30) | (FACILITY_NTDSB << 16) | -jerr)
00034
00035 #define JETERROR_FROM_HRESULT(hr) \
00036   (-(LONG) (CERTLIB_WIN32ERRORMASK & (hr)))
00037
00038 #define ISJETERROR(hr) \
00039     ((~CERTLIB_WIN32ERRORMASK & (hr)) == ~CERTLIB_WIN32ERRORMASK)
00040
00041 #define ISJETHRESULT(hr) \
00042     ((~CERTLIB_WIN32ERRORMASK & (hr)) == ((STATUS_SEVERITY_ERROR << 30) | \
00043             (FACILITY_NTDSB << 16)))
00044
00045 #define wszJETERRORPREFIX L"EDB"
00046
00047
00048 //+--------------------------------------------------------------------------
00049 // Win32 errors:
00050
00051 #define ISWIN32ERROR(hr) \
00052     ((~CERTLIB_WIN32ERRORMASK & (hr)) == 0)
00053
00054 #define ISWIN32HRESULT(hr) \
00055     ((~CERTLIB_WIN32ERRORMASK & (hr)) == ((STATUS_SEVERITY_WARNING << 30) | \
00056             (FACILITY_WIN32 << 16)))
00057
00058 #define WIN32ERROR_FROM_HRESULT(hr) \
00059     (CERTLIB_WIN32ERRORMASK & (hr))
00060
00061 #define wszWIN32ERRORPREFIX L"WIN32"
00062
00063
00064 //+--------------------------------------------------------------------------
00065 // Delayload errors:
00066
00067 #define FACILITY_DELAYLOAD  109
00068 #define DELAYLOAD_FROM_WIN32(hr) \
00069     ((HRESULT) ((STATUS_SEVERITY_ERROR << 30) | \
00070     (FACILITY_DELAYLOAD << 16) | \
00071     (hr)))
00072
00073 #define WIN32ERROR_FROM_DELAYLOAD(hr) \
00074     (CERTLIB_WIN32ERRORMASK & (hr))
00075
00076 #define ISDELAYLOADHRESULTFACILITY(hr) \
00077     ((~CERTLIB_WIN32ERRORMASK & (hr)) == ((STATUS_SEVERITY_ERROR << 30) | \
00078             (FACILITY_DELAYLOAD << 16)))
00079
00080 // E_DELAYLOAD_MOD_NOT_FOUND  0xc06d007e
00081 #define E_DELAYLOAD_MOD_NOT_FOUND   DELAYLOAD_FROM_WIN32(ERROR_MOD_NOT_FOUND)
00082
00083 // E_DELAYLOAD_PROC_NOT_FOUND 0xc06d007f
00084 #define E_DELAYLOAD_PROC_NOT_FOUND  DELAYLOAD_FROM_WIN32(ERROR_PROC_NOT_FOUND)
00085
00086 #define ISDELAYLOADHRESULT(hr) \
00087     (E_DELAYLOAD_MOD_NOT_FOUND == (hr) || \
00088      E_DELAYLOAD_PROC_NOT_FOUND == (hr) || \
00089      HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND) == (hr) || \
00090      HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND) == (hr))
00091
00092
00093 //+--------------------------------------------------------------------------
00094 // ASN encoding errors:
00095
00096 #define ISOSSERROR(hr) \
00097     ((~CERTLIB_12BITERRORMASK & (hr)) == CRYPT_E_OSS_ERROR)
00098
00099 #define OSSERROR_FROM_HRESULT(hr) \
00100     (CERTLIB_12BITERRORMASK & (hr))
00101
00102 #define wszOSSERRORPREFIX L"ASN"
00103
00104
00105
00106
00107 HRESULT
00108 ceJetHResult(
00109     IN HRESULT hr)
00110 {
00111 #if DBG_CERTSRV
00112     HRESULT hrIn = hr;
00113 #endif
00114     if (S_OK != hr)
00115     {
00116         if (SUCCEEDED(hr))
00117         {
00118 #if 0
00119       hr = HRESULT_FROM_JETWARNING(hr);
00120 #else
00121             if (S_FALSE != hr)
00122       {
00123     ceERRORPRINTLINE("JetHResult: mapping to S_FALSE", hr);
00124       }
00125             assert(S_FALSE == hr);
00126             hr = S_FALSE;
00127 #endif
00128         }
00129         else if (ISJETERROR(hr))
00130         {
00131       hr = HRESULT_FROM_JETERROR(hr);
00132         }
00133     }
00134     assert(S_OK == hr || S_FALSE == hr || FAILED(hr));
00135     return(hr);
00136 }
00137
00138
00139 HRESULT
00140 ceHExceptionCode(
00141     IN EXCEPTION_POINTERS const *pep)
00142 {
00143     HRESULT hr = pep->ExceptionRecord->ExceptionCode;
00144
00145     return(ceHError(hr));
00146 }
00147
00148
00149 BOOL
00150 ceIsDelayLoadHResult(
00151     IN HRESULT hr)
00152 {
00153     return(ISDELAYLOADHRESULT(hr));
00154 }
00155
00156
00157 #define wszCOLONSPACE L": "
00158
00159 WCHAR const *
00160 ceHResultToStringEx(
00161     IN OUT WCHAR *awchr,
00162     IN HRESULT hr,
00163     IN BOOL fRaw)
00164 {
00165     HRESULT hrd;
00166     WCHAR const *pwszType;
00167
00168     hrd = hr;
00169     pwszType = L"";
00170     if (ISJETERROR(hr))
00171     {
00172   pwszType = wszJETERRORPREFIX wszCOLONSPACE;
00173     }
00174     else if (ISJETHRESULT(hr))
00175     {
00176   hrd = JETERROR_FROM_HRESULT(hr);
00177   pwszType = wszJETERRORPREFIX wszCOLONSPACE;
00178     }
00179     else if (ISWIN32HRESULT(hr))
00180     {
00181   hrd = WIN32ERROR_FROM_HRESULT(hr);
00182   pwszType = wszWIN32ERRORPREFIX wszCOLONSPACE;
00183     }
00184     else if (ISDELAYLOADHRESULTFACILITY(hr))
00185     {
00186   hrd = WIN32ERROR_FROM_DELAYLOAD(hr);
00187   pwszType = wszWIN32ERRORPREFIX wszCOLONSPACE;
00188     }
00189     else if (ISOSSERROR(hr))
00190     {
00191   hrd = OSSERROR_FROM_HRESULT(hr);
00192   pwszType = wszOSSERRORPREFIX wszCOLONSPACE;
00193     }
00194     if (fRaw)
00195     {
00196   pwszType = L"";
00197     }
00198
00199     _snwprintf(
00200   awchr,
00201   cwcHRESULTSTRING,
00202   L"0x%x (%ws%d)",
00203   hr,
00204   pwszType,
00205   hrd);
00206     return(awchr);
00207 }
00208
00209
00210 WCHAR const *
00211 ceHResultToString(
00212     IN OUT WCHAR *awchr,
00213     IN HRESULT hr)
00214 {
00215     return(ceHResultToStringEx(awchr, hr, FALSE));
00216 }
00217
00218
00219 WCHAR const *
00220 ceHResultToStringRaw(
00221     IN OUT WCHAR *awchr,
00222     IN HRESULT hr)
00223 {
00224     return(ceHResultToStringEx(awchr, hr, TRUE));
00225 }
00226
00227
00228 static DWORD s_idsUnexpected = 0;
00229 static DWORD s_idsUnknownErrorCode = 0; // L"Error %ws %ws"
00230
00231 VOID
00232 ceInitErrorMessageText(
00233     IN DWORD idsUnexpected,
00234     IN DWORD idsUnknownErrorCode) // L"Error %ws %ws"
00235 {
00236     s_idsUnexpected = idsUnexpected;
00237     s_idsUnknownErrorCode = idsUnknownErrorCode;
00238 }
00239
00240
00241 // Alloc and return error message string
00242
00243 WCHAR *
00244 ceGetErrorMessageText(
00245     IN HRESULT hr,
00246     IN BOOL fHResultString)
00247 {
00248     static WCHAR s_wszUknownDefault[] = L"Error %ws %ws";
00249     WCHAR *pwszRet = NULL;
00250     WCHAR *pwszMsgT;
00251     WCHAR const *pwszUnknown;
00252     WCHAR wszUnknown[10 * ARRAYSIZE(s_wszUknownDefault)];
00253     WCHAR wszUnexpected[512];
00254     WCHAR awchr[cwcHRESULTSTRING];
00255     DWORD cwc;
00256     DWORD cwcUnexpected = 0;
00257     HMODULE hMod = NULL;
00258
00259     wszUnexpected[0] = L'\0';
00260     if (E_UNEXPECTED == hr && 0 != s_idsUnexpected)
00261     {
00262   cwcUnexpected = LoadString(
00263         NULL,
00264         s_idsUnexpected,  // L"Unexpected method call sequence."
00265         wszUnknown,
00266         ARRAYSIZE(wszUnknown));
00267     }
00268     cwc = FormatMessage(
00269                 FORMAT_MESSAGE_ALLOCATE_BUFFER |
00270         FORMAT_MESSAGE_FROM_SYSTEM |
00271         FORMAT_MESSAGE_IGNORE_INSERTS,
00272                 NULL,
00273                 hr,
00274                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00275                 (WCHAR *) &pwszRet,
00276                 0,
00277                 NULL);
00278     if (0 == cwc)
00279     {
00280   hMod = LoadLibrary(L"ntdsbmsg.dll");
00281   if (NULL != hMod)
00282   {
00283       cwc = FormatMessage(
00284         FORMAT_MESSAGE_ALLOCATE_BUFFER |
00285       FORMAT_MESSAGE_FROM_HMODULE |
00286       FORMAT_MESSAGE_IGNORE_INSERTS,
00287         hMod,
00288         hr,
00289         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00290         (WCHAR *) &pwszRet,
00291         0,
00292         NULL);
00293   }
00294     }
00295     if (0 == cwc)
00296     {
00297   // couldn't find error, _snwprintf it instead
00298
00299   if (0 != s_idsUnknownErrorCode)
00300   {
00301       cwc = LoadString(
00302       NULL,
00303       s_idsUnknownErrorCode,  // L"Error %ws %ws"
00304       wszUnknown,
00305       ARRAYSIZE(wszUnknown));
00306   }
00307   if (0 == cwc)
00308   {
00309       pwszUnknown = s_wszUknownDefault;
00310   }
00311   else
00312   {
00313       pwszUnknown = wszUnknown;
00314   }
00315   cwc = (DWORD)(wcslen(pwszUnknown) + cwcUnexpected + ARRAYSIZE(awchr) + 1);
00316         pwszRet = (WCHAR *) LocalAlloc(LMEM_FIXED, cwc * sizeof(WCHAR));
00317   if (NULL == pwszRet)
00318   {
00319       ceERRORPRINTLINE("LocalAlloc", E_OUTOFMEMORY);
00320       goto error;
00321   }
00322         _snwprintf(
00323     pwszRet,
00324     cwc,
00325     pwszUnknown,
00326     wszUnexpected,
00327     ceHResultToString(awchr, hr));
00328     }
00329     else
00330     {
00331         // strip trailing \r\n
00332
00333         cwc = (DWORD)wcslen(pwszRet);
00334
00335         if (2 <= cwc &&
00336       L'\r' == pwszRet[cwc - 2] &&
00337       L'\n' == pwszRet[cwc - 1])
00338   {
00339             pwszRet[cwc - 2] = L'\0';
00340   }
00341   awchr[0] = L'\0';
00342   if (fHResultString)
00343   {
00344       ceHResultToString(awchr, hr);
00345   }
00346   if (fHResultString || 0 != cwcUnexpected)
00347   {
00348       cwc = (DWORD)(wcslen(pwszRet) + 1 + cwcUnexpected + 1 + wcslen(awchr) + 1);
00349       pwszMsgT = (WCHAR *) LocalAlloc(LMEM_FIXED, cwc * sizeof(WCHAR));
00350       if (NULL == pwszMsgT)
00351       {
00352     ceERRORPRINTLINE("LocalAlloc", E_OUTOFMEMORY);
00353     goto error;
00354       }
00355       _snwprintf(
00356         pwszMsgT,
00357         cwc,
00358         L"%ws %ws %ws",
00359         pwszRet,
00360         wszUnexpected,
00361         awchr);
00362       LocalFree(pwszRet);
00363       pwszRet = pwszMsgT;
00364   }
00365     }
00366
00367 error:
00368     if (NULL != hMod)
00369     {
00370   FreeLibrary(hMod);
00371     }
00372     return(pwszRet);
00373 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/comp.h Source File

  • SysMgmt
  • MMC
  • About

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent
00025 {
00026 private:
00027     ULONG       m_cref;
00028
00029     IConsole*   m_ipConsole;
00030
00031     class CComponentData *m_pComponentData;
00032
00033     public:
00034         CComponent(CComponentData *parent);
00035         ~CComponent();
00036
00037         ///////////////////////////////
00038         // Interface IUnknown
00039         ///////////////////////////////
00040         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00041         STDMETHODIMP_(ULONG) AddRef();
00042         STDMETHODIMP_(ULONG) Release();
00043
00044         ///////////////////////////////
00045         // Interface IComponent
00046         ///////////////////////////////
00047         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00048             /* [in] */ LPCONSOLE lpConsole);
00049
00050             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00051             /* [in] */ LPDATAOBJECT lpDataObject,
00052             /* [in] */ MMC_NOTIFY_TYPE event,
00053             /* [in] */ LPARAM arg,
00054             /* [in] */ LPARAM param);
00055
00056             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00057             /* [in] */ MMC_COOKIE cookie);
00058
00059             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00060             /* [in] */ MMC_COOKIE cookie,
00061             /* [in] */ DATA_OBJECT_TYPES type,
00062             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00063
00064             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00065             /* [in] */ MMC_COOKIE cookie,
00066             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00067             /* [out] */ long __RPC_FAR *pViewOptions);
00068
00069             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00070             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00071
00072             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00073             /* [in] */ LPDATAOBJECT lpDataObjectA,
00074             /* [in] */ LPDATAOBJECT lpDataObjectB);
00075 };
00076
00077 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ComObj/CAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ComObj

CAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CAR.CPP
00003
00004   Summary:   Implementation file for the COCar COM Object Class (for
00005              aggregatable Car COM Objects).
00006
00007              Of particular interest for an COM application, CAR
00008              showcases a COM Object Class offering a main IUnknown
00009              interface and the ICar interface of Car-related features.
00010              This multiple interface COM Object Class is achieved via
00011              the technique of nested classes: the implementation of the
00012              ICar interface is nested inside of the COCar COM
00013              Object Class.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial COMOBJ.HTM
00017              file.  For more specific technical details on the internal
00018              workings see the comments dispersed throughout the
00019              module's source code.
00020
00021   Classes:   COCar
00022
00023   Functions: none.
00024
00025   Origin:    8-19-95: atrent - Created.
00026
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042
00043 /*---------------------------------------------------------------------------
00044   We include WINDOWS.H for all Win32 applications.
00045   We include OLE2.H because we will make calls to the COM/OLE Libraries.
00046   We include APPUTIL.H because we will be building this application using
00047     the convenient Virtual Window and Dialog classes and other
00048     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00049   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00050     class, GUID, and CLSID specifications.
00051   We include COMOBJI.H because it has internal class declarations and
00052     resource ID definitions specific for this DLL.
00053   We include COMOBJ.H because it has the interface declarations.
00054   We include CAR.H because it has the class COCar declarations.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <apputil.h>
00059 #include <icars.h>
00060 #include <carguids.h>
00061 #include "comobji.h"
00062 #include "comobj.h"
00063 #include "car.h"
00064
00065
00066 /*---------------------------------------------------------------------------
00067   COCar's implementation of its main COM object class including
00068   Constructor, Destructor, QueryInterface, AddRef, and Release.
00069 ---------------------------------------------------------------------------*/
00070
00071 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00072   Method:   COCar::COCar
00073
00074   Summary:  COCar Constructor. Note the member initializer:
00075             "m_ImpICar(this, pUnkOuter)" which is used to pass the 'this'
00076             and pUnkOuter pointers of this constructor function to the
00077             constructor in the instantiation of the implementation of
00078             the CImpICar interface (which is nested inside this present
00079             COCar Object Class).
00080
00081   Args:     IUnknown* pUnkOuter)
00082               Pointer to the the outer Unknown.  NULL means this COM Object
00083               is not being Aggregated.  Non NULL means it is being created
00084               on behalf of an outside COM object that is reusing it via
00085               aggregation.
00086
00087   Modifies: m_cRefs, m_pUnkOuter.
00088
00089   Returns:  void
00090 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00091 COCar::COCar(
00092   IUnknown* pUnkOuter) :
00093   m_ImpICar(this, pUnkOuter)
00094 {
00095   // Zero the COM object's reference count.
00096   m_cRefs = 0;
00097
00098   // No AddRef necessary if non-NULL, as we're nested.
00099   m_pUnkOuter = pUnkOuter;
00100
00101   LOGF1("D: COCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00102
00103   return;
00104 }
00105
00106
00107 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00108   Method:   COCar::~COCar
00109
00110   Summary:  COCar Destructor.
00111
00112   Args:     void
00113
00114   Returns:  void
00115 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00116 COCar::~COCar(void)
00117 {
00118   LOG("D: COCar::Destructor.");
00119
00120   return;
00121 }
00122
00123
00124 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00125   Method:   COCar::QueryInterface
00126
00127   Summary:  QueryInterface of the COCar non-delegating
00128             IUnknown implementation.
00129
00130   Args:     REFIID riid,
00131               [in] GUID of the Interface being requested.
00132             PPVOID ppv)
00133               [out] Address of the caller's pointer variable that will
00134               receive the requested interface pointer.
00135
00136   Returns:  HRESULT
00137 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00138 STDMETHODIMP COCar::QueryInterface(
00139                REFIID riid,
00140                PPVOID ppv)
00141 {
00142   HRESULT hr = E_NOINTERFACE;
00143   *ppv = NULL;
00144
00145   if (IID_IUnknown == riid)
00146   {
00147     *ppv = this;
00148     LOG("D: COCar::QueryInterface. 'this' pIUnknown returned.");
00149   }
00150   else if (IID_ICar == riid)
00151   {
00152     *ppv = &m_ImpICar;
00153     LOG("D: COCar::QueryInterface. pICar returned.");
00154   }
00155
00156   if (NULL != *ppv)
00157   {
00158     // We've handed out a pointer to the interface so obey the COM rules
00159     //   and AddRef the reference count.
00160     ((LPUNKNOWN)*ppv)->AddRef();
00161     hr = NOERROR;
00162   }
00163
00164   return (hr);
00165 }
00166
00167
00168 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00169   Method:   COCar::AddRef
00170
00171   Summary:  AddRef of the COCar non-delegating IUnknown implementation.
00172
00173   Args:     void
00174
00175   Modifies: m_cRefs.
00176
00177   Returns:  ULONG
00178               New value of m_cRefs (COM object's reference count).
00179 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00180 STDMETHODIMP_(ULONG) COCar::AddRef(void)
00181 {
00182   m_cRefs++;
00183
00184   LOGF1("D: COCar::AddRef. New cRefs=%i.", m_cRefs);
00185
00186   return m_cRefs;
00187 }
00188
00189
00190 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00191   Method:   COCar::Release
00192
00193   Summary:  Release of the COCar non-delegating IUnknown implementation.
00194
00195   Args:     void
00196
00197   Modifies: m_cRefs.
00198
00199   Returns:  ULONG
00200               New value of m_cRefs (COM object's reference count).
00201 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00202 STDMETHODIMP_(ULONG) COCar::Release(void)
00203 {
00204   m_cRefs--;
00205
00206   LOGF1("D: COCar::Release. New cRefs=%i.", m_cRefs);
00207
00208   if (0 == m_cRefs)
00209   {
00210     // We artificially bump the main ref count to prevent reentrancy
00211     // via the main object destructor.  Not really needed in this
00212     // COCar but a good practice because we are aggregatable and
00213     // may at some point in the future add something entertaining like
00214     // some Releases to the COCar destructor.
00215     m_cRefs++;
00216     delete this;
00217   }
00218
00219   return m_cRefs;
00220 }
00221
00222
00223 /*---------------------------------------------------------------------------
00224   COCar's nested implementation of the ICar interface including
00225   Constructor, Destructor, QueryInterface, AddRef, Release,
00226   Shift, Clutch, Speed, and Steer.
00227 ---------------------------------------------------------------------------*/
00228
00229 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00230   Method:   COCar::CImpICar::CImpICar
00231
00232   Summary:  Constructor for the CImpICar interface instantiation.
00233
00234   Args:     COCar* pBackObj,
00235               Back pointer to the parent outer object.
00236             IUnknown* pUnkOuter)
00237               Pointer to the outer Unknown.  For delegation.
00238
00239   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00240
00241   Returns:  void
00242 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00243 COCar::CImpICar::CImpICar(
00244   COCar* pBackObj,
00245   IUnknown* pUnkOuter)
00246 {
00247   // Init the Interface Ref Count (used for debugging only).
00248   m_cRefI = 0;
00249
00250   // Init the Back Object Pointer to point to the parent object.
00251   m_pBackObj = pBackObj;
00252
00253   // Init the CImpICar interface's delegating Unknown pointer.  We use
00254   // the Back Object pointer for IUnknown delegation here if we are not
00255   // being aggregated.  If we are being aggregated we use the supplied
00256   // pUnkOuter for IUnknown delegation.  In either case the pointer
00257   // assignment requires no AddRef because the CImpICar lifetime is
00258   // quaranteed by the lifetime of the parent object in which
00259   // CImpICar is nested.
00260   if (NULL == pUnkOuter)
00261   {
00262     m_pUnkOuter = pBackObj;
00263     LOG("D: COCar::CImpICar Constructor. Non-Aggregating.");
00264   }
00265   else
00266   {
00267     m_pUnkOuter = pUnkOuter;
00268     LOG("D: COCar::CImpICar Constructor. Aggregating.");
00269   }
00270
00271   return;
00272 }
00273
00274
00275 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00276   Method:   COCar::CImpICar::~CImpICar
00277
00278   Summary:  Destructor for the CImpICar interface instantiation.
00279
00280   Args:     void
00281
00282   Returns:  void
00283 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00284 COCar::CImpICar::~CImpICar(void)
00285 {
00286   LOG("D: COCar::CImpICar Destructor.");
00287
00288   return;
00289 }
00290
00291
00292 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00293   Method:   COCar::CImpICar::QueryInterface
00294
00295   Summary:  The QueryInterface IUnknown member of this ICar interface
00296             implementation that delegates to m_pUnkOuter, whatever it is.
00297
00298   Args:     REFIID riid,
00299               [in] GUID of the Interface being requested.
00300             PPVOID ppv)
00301               [out] Address of the caller's pointer variable that will
00302               receive the requested interface pointer.
00303
00304   Returns:  HRESULT
00305               Returned by the delegated outer QueryInterface call.
00306 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00307 STDMETHODIMP COCar::CImpICar::QueryInterface(
00308                REFIID riid,
00309                PPVOID ppv)
00310 {
00311   LOG("D: COCar::CImpICar::QueryInterface. Delegating.");
00312
00313   // Delegate this call to the outer object's QueryInterface.
00314   return m_pUnkOuter->QueryInterface(riid, ppv);
00315 }
00316
00317
00318 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00319   Method:   COCar::CImpICar::AddRef
00320
00321   Summary:  The AddRef IUnknown member of this ICar interface
00322             implementation that delegates to m_pUnkOuter, whatever it is.
00323
00324   Args:     void
00325
00326   Modifies: m_cRefI.
00327
00328   Returns:  ULONG
00329               Returned by the delegated outer AddRef call.
00330 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00331 STDMETHODIMP_(ULONG) COCar::CImpICar::AddRef(void)
00332 {
00333   // Increment the Interface Reference Count.
00334   ++m_cRefI;
00335
00336   LOGF1("D: COCar::CImpICar::Addref. Delegating. New cI=%i.", m_cRefI);
00337
00338   // Delegate this call to the outer object's AddRef.
00339   return m_pUnkOuter->AddRef();
00340 }
00341
00342
00343 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00344   Method:   COCar::CImpICar::Release
00345
00346   Summary:  The Release IUnknown member of this ICar interface
00347             implementation that delegates to m_pUnkOuter, whatever it is.
00348
00349   Args:     void
00350
00351   Returns:  ULONG
00352               Returned by the delegated outer Release call.
00353 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00354 STDMETHODIMP_(ULONG) COCar::CImpICar::Release(void)
00355 {
00356   // Decrement the Interface Reference Count.
00357   --m_cRefI;
00358
00359   LOGF1("D: COCar::CImpICar::Release. Delegating. New cI=%i.", m_cRefI);
00360
00361   // Delegate this call to the outer object's Release.
00362   return m_pUnkOuter->Release();
00363 }
00364
00365
00366 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00367   Method:   COCar::CImpICar::Shift
00368
00369   Summary:  The Shift member method of this ICar interface implementation.
00370             A simple empty method on a COCar COM object for tutorial
00371             purposes.  Presumably if this Car object were modeling
00372             a real Car then the Shift method would shift to the specified
00373             gear.
00374
00375   Args:     short nGear
00376               0 - Neutral; 1 - 5 First 5 forward gears; 6 - Reverse.
00377
00378   Returns:  HRESULT
00379               NOERROR
00380 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00381 STDMETHODIMP COCar::CImpICar::Shift(
00382                short nGear)
00383 {
00384   LOGF1("D: COCar::CImpICar::Shift. Called. nGear=%i.",nGear);
00385
00386   return NOERROR;
00387 }
00388
00389
00390 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00391   Method:   COCar::CImpICar::Clutch
00392
00393   Summary:  The Clutch member method of this ICar interface implementation.
00394             A simple empty method on a COCar COM object for tutorial
00395             purposes.  Presumably if this Car object were modeling
00396             a real Car then the Clutch method would engage the clutch the
00397             specified amount.
00398
00399   Args:     short nEngaged)
00400               Percent clutch is engaged (0 to 100%).
00401
00402   Returns:  HRESULT
00403               NOERROR
00404 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00405 STDMETHODIMP COCar::CImpICar::Clutch(
00406                short nEngaged)
00407 {
00408   LOGF1("D: COCar::CImpICar::Clutch. Called. nEngaged=%i.",nEngaged);
00409
00410   return NOERROR;
00411 }
00412
00413
00414 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00415   Method:   COCar::CImpICar::Speed
00416
00417   Summary:  The Speed member method of this ICar interface implementation.
00418             A simple empty method on a COCar COM object for tutorial
00419             purposes.  Presumably if this Car object were modeling
00420             a real Car then this method would accelerate/brake to bring
00421             the car to the specified speed.
00422
00423   Args:     short nMph
00424               New speed in miles per hour.
00425
00426   Returns:  HRESULT
00427               NOERROR
00428 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00429 STDMETHODIMP COCar::CImpICar::Speed(
00430                short nMph)
00431 {
00432   LOGF1("D: COCar::CImpICar::Speed. Called. nMph=%i.",nMph);
00433
00434   return NOERROR;
00435 }
00436
00437
00438 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00439   Method:   COCar::CImpICar::Steer
00440
00441   Summary:  The Steer member method of this ICar interface implementation.
00442             A simple empty method on a COCar COM object for tutorial
00443             purposes.  Presumably if this Car object were modeling
00444             a real Car then the Steer method would set the steering
00445             angle of the Car.
00446
00447   Args:     short nAngle)
00448               0 degrees straight ahead, -45 Full left, +45 Full right.
00449
00450   Returns:  HRESULT
00451               NOERROR
00452 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00453 STDMETHODIMP COCar::CImpICar::Steer(
00454                short nAngle)
00455 {
00456   LOGF1("D: COCar::CImpICar::Steer. Called. nAngle=%i.",nAngle);
00457
00458   return NOERROR;
00459 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/NewsEvent/newsEventClass/NewsEvent.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • NewsEvent
  • newsEventClass

NewsEvent.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc147.tmp" /nologo /d "D:\ComPlusSamples\Source\LCE\NewsEvent" "D:\ComPlusSamples\Source\LCE\NewsEvent\NewsEventClass.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package newseventclass;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.register(clsid=997FF9C0-0F01-11D3-9257-0080C7C30D72, typelib=94007C90-0F00-11D3-9257-0080C7C30D72, version="1.0", description="NewsEvent Class")*/
00019 public class NewsEvent implements IUnknown,com.ms.com.NoAutoScripting,newseventclass.INewsEventDefault
00020 {
00021   public void NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL)
00022   {
00023   }
00024
00025   public void ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow)
00026   {
00027   }
00028
00029   public void LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate)
00030   {
00031   }
00032
00033 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CIceSkate Member List

This is the complete list of members for CIceSkate, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
bSelected | CIceSkate | [private]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CIceSkate(int i) | CIceSkate | [inline]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetBitmapIndex() | CIceSkate | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetDisplayName(int nCol=0) | CIceSkate | [virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
getNodeType() | CIceSkate | [inline, virtual]
GetParentScopeItem() | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
id | CIceSkate | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
IsSelected() const | CIceSkate | [inline]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CDelegationBase | [inline, virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CIceSkate | [virtual]
CDelegationBase::OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
CDelegationBase::OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CIceSkate | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
~CIceSkate() | CIceSkate | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMyUIExtApp Member List

This is the complete list of members for CMyUIExtApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CAppLite(UINT nAppID) | CAppLite |
CWinApp() | CWinApp |
ExitInstance() | CMyUIExtApp | [virtual]
ExitInstance() | CMyUIExtApp | [virtual]
InitInstance() | CMyUIExtApp | [virtual]
InitInstance() | CMyUIExtApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/space.h Source File

  • SysMgmt
  • MMC
  • Taskpads

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CRocket : public CDelegationBase {
00026 public:
00027     CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload);
00028     virtual ~CRocket();
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00033
00034 public:
00035     // virtual functions go here (for MMCN_*)
00036     virtual HRESULT OnRename(LPOLESTR pszNewName);
00037     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00038
00039 private:
00040     // {29743810-4C4B-11d2-89D8-000021473128}
00041     static const GUID thisGuid;
00042
00043     _TCHAR *szName;
00044     LONG   lWeight;
00045     LONG   lHeight;
00046     LONG   lPayload;
00047     int    nId;
00048     enum {RUNNING, PAUSED, STOPPED} iStatus;
00049 };
00050
00051 class CSpaceVehicle : public CDelegationBase {
00052 public:
00053     CSpaceVehicle();
00054
00055     virtual ~CSpaceVehicle();
00056
00057     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00058     virtual const GUID & getNodeType() { return thisGuid; }
00059     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00060
00061 public:
00062     // virtual functions go here (for MMCN_*)
00063     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00064
00065 private:
00066     enum { IDM_NEW_SPACE = 4 };
00067
00068     // {29743810-4C4B-11d2-89D8-000021473128}
00069     static const GUID thisGuid;
00070
00071 private:
00072     enum { NUMBER_OF_CHILDREN = 4 };
00073     CRocket *children[NUMBER_OF_CHILDREN];
00074 };
00075
00076 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/dataobj.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

dataobj.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "DataObj.h"
00016 #include "Guids.h"
00017 #include "StaticNode.h"
00018
00019
00020 /////////////////////////////////////////////////////////////////////////////
00021 // Construction/Destruction
00022
00023
00024 CDataObject::CDataObject()
00025 {
00026   m_cRef     = 0;
00027   m_uCookie  = 0;
00028   m_uContext = 0;
00029
00030 }
00031
00032 CDataObject::~CDataObject()
00033 {
00034 }
00035
00036 /////////////////////////////////////////////////////////////////////////////
00037 // IUnknown implementation
00038
00039 //---------------------------------------------------------------------------
00040 STDMETHODIMP CDataObject::QueryInterface
00041 (
00042   REFIID   riid,
00043   LPVOID*  ppv
00044 )
00045 {
00046   if( !ppv )
00047     return E_FAIL;
00048
00049   HRESULT hResult = E_NOINTERFACE;
00050   *ppv = NULL;
00051
00052   if( IsEqualIID(riid, IID_IUnknown) )
00053     *ppv = static_cast<IDataObject*>(this);
00054   else if( IsEqualIID(riid, IID_IDataObject) )
00055     *ppv = static_cast<IDataObject*>(this);
00056
00057   if( *ppv )
00058   {
00059     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00060     hResult = S_OK;
00061   }
00062
00063   return hResult;
00064 }
00065
00066 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00067 {
00068     return InterlockedIncrement((LONG*)&m_cRef);
00069 }
00070
00071 STDMETHODIMP_(ULONG) CDataObject::Release()
00072 {
00073     if (InterlockedDecrement((LONG*)&m_cRef) == 0)
00074     {
00075         delete this;
00076         return 0;
00077     }
00078     return m_cRef;
00079
00080 }
00081
00082 /////////////////////////////////////////////////////////////////////////////
00083 // IDataObject implementation
00084 //
00085
00086 //---------------------------------------------------------------------------
00087 //  MMC will call GetDataHere() for it's required clipboard formats
00088 //
00089 HRESULT CDataObject::GetDataHere
00090 (
00091   FORMATETC *pFormatEtc,     //[in]  Pointer to the FORMATETC structure
00092   STGMEDIUM *pMedium         //[out] Pointer to the STGMEDIUM structure
00093 )
00094 {
00095   const CLIPFORMAT cf = pFormatEtc->cfFormat;
00096   IStream* ipStream = NULL;
00097
00098   HRESULT hResult = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &ipStream );
00099   if( S_OK != hResult )
00100     return hResult;                        // Minimal error checking
00101
00102   hResult = DV_E_FORMATETC;                // Unknown format
00103
00104   if( cf == g_cfDisplayName )
00105   {
00106     hResult = RetrieveDisplayString( ipStream );
00107   }
00108   else if( cf == g_cfSnapinClsid )
00109   {
00110     hResult = RetrieveSnapInClassID( ipStream );
00111   }
00112   else if( cf == g_cfNodeType )
00113   {
00114     hResult = RetrieveNodeTypeGuid( ipStream );
00115   }
00116   else if( cf == g_cfszNodeType )
00117   {
00118     hResult = RetrieveGuidString( ipStream );
00119   }
00120
00121   ipStream->Release();
00122
00123   return hResult;
00124 }
00125
00126 //---------------------------------------------------------------------------
00127 VOID CDataObject::SetPrivateData
00128 (
00129   ULONG  uCookie,      //[in] Pointer to node this object represents
00130   ULONG  uContext      //[in] Context of the node
00131 )
00132 {
00133   m_uCookie  = uCookie;
00134   m_uContext = uContext;
00135 }
00136
00137 /////////////////////////////////////////////////////////////////////////////
00138 //  Handlers for MMC's required clipboard formats
00139
00140
00141 //---------------------------------------------------------------------------
00142 // CCF_DISPLAY_NAME is one of the required clipformats.
00143 // MMC askes for this string to display the name of the SnapIn's StaticNode
00144 // in the ScopePane
00145 //
00146 HRESULT CDataObject::RetrieveDisplayString
00147 (
00148   IStream* ipStream        //[in][out] Stream to return our data in.
00149 )
00150 {
00151   CBaseNode* pNode = reinterpret_cast<CBaseNode*>(m_uCookie);
00152   LPWSTR pNodeName = pNode->GetNodeName();
00153
00154   ULONG ulSizeofName = (wcslen(pNodeName) + 1) * sizeof(WCHAR);
00155   return ipStream->Write(pNodeName, ulSizeofName, NULL);
00156
00157 }
00158
00159 //---------------------------------------------------------------------------
00160 //  CCF_SNAPIN_CLASSID is one of the required clipformats.
00161 //  MMC will ask for this data.  This ClassID which we return represents
00162 //  the COM object which is the entry point for our SnapIn
00163 //
00164 HRESULT CDataObject::RetrieveSnapInClassID
00165 (
00166   IStream* ipStream        //[in][out] Stream to return our data in.
00167 )
00168 {
00169   return ipStream->Write( &CLSID_CComponentData, sizeof(GUID), NULL );
00170 }
00171
00172
00173 //---------------------------------------------------------------------------
00174 //  CCF_NODETYPE is one of the required clipformats.
00175 //  MMC needs the NodeType GUID to determine what extensions to activate
00176 //  for a node.  It looks under the MMC/NodeTypes registry key for the GUID
00177 //  and enumerates the extensions found beneath it.  MMC uses this GUID
00178 //  strictly as a uniquie identifier.  It does not expect it to correspond
00179 //  to the ClaseID of a com object.
00180 //
00181 HRESULT CDataObject::RetrieveNodeTypeGuid
00182 (
00183   IStream* ipStream        //[in][out] Stream to return our data in.
00184 )
00185 {
00186   CBaseNode* pNode = reinterpret_cast<CBaseNode*>(m_uCookie);
00187   GUID* pGuid = pNode->GetNodeGUID();
00188
00189   return ipStream->Write( (void*)pGuid, sizeof(GUID), NULL );
00190 }
00191
00192
00193 //---------------------------------------------------------------------------
00194 //  CCF_SZNODETYPE is a required clipboard format.
00195 //  We return the node's GUID as a wide string.
00196 //
00197 HRESULT CDataObject::RetrieveGuidString
00198 (
00199   IStream* ipStream        //[in][out] Stream to return our data in.
00200 )
00201 {
00202   LPOLESTR pszGUID;
00203   GUID     TmpGUID;
00204
00205   CBaseNode* pNode = reinterpret_cast<CBaseNode*>(m_uCookie);
00206   CopyMemory( &TmpGUID, pNode->GetNodeGUID(), sizeof(GUID) );
00207
00208   HRESULT  hResult = StringFromCLSID( TmpGUID, &pszGUID );
00209   if( S_OK == hResult )
00210   {
00211     hResult = ipStream->Write( pszGUID, (wcslen(pszGUID) + 1) * sizeof(WCHAR), NULL );
00212     CoTaskMemFree( pszGUID );
00213   }
00214   return hResult;
00215 }
00216
00217
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/UpCaseMap/UpCaseMap.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • UpCaseMap

UpCaseMap.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: UpCaseMap.cpp
00006
00007 Abstract:
00008
00009     ISAPI extension to demonstrate a wildcard script map
00010     that modifies request entity in a filter-like manner.
00011
00012     UpCaseMap will intercept requests and acquire the
00013     entity body.  If the entity body is of a text mime
00014     type, then UpCaseMap will convert all characters to
00015     upper case and use HSE_REQ_EXEC_URL to hand off the
00016     modified request to be handled.
00017
00018     UpCaseMap also does bounds checking to enforce a
00019     size limit on the amount of entity that will be
00020     accepted.  If this size is exceeded by the client,
00021     a "413 Entity Too Large" response will be sent.
00022
00023     UpCaseMap uses the ISABUFFER and ISAREQUEST helper
00024     objects.
00025
00026 Author:
00027
00028     ISAPI developer (Microsoft employee), October 2002
00029
00030 --*/
00031
00032 #ifndef _WIN32_WINNT
00033 #define _WIN32_WINNT 0x0500
00034 #endif
00035
00036 #include <IsapiTools.h>
00037
00038 //
00039 // Local definitions
00040 //
00041
00042 #define MAX_ALLOWED_REQUEST_ENTITY 64*1024
00043
00044 #define UPCASE_ANSI_CHAR(c) ((((unsigned char)c & 0xdf) < 'A' || \
00045                               ((unsigned char)c & 0xdf) > 'Z') ? \
00046                               c : \
00047                               (c & 0xdf))
00048
00049 //
00050 // Local prototypes
00051 //
00052
00053 VOID
00054 WINAPI
00055 HandleCompletion(
00056     EXTENSION_CONTROL_BLOCK *   pecb,
00057     VOID *                      pContext,
00058     DWORD                       cbIO,
00059     DWORD                       dwError
00060     );
00061
00062 //
00063 // ISAPI entry point implementations
00064 //
00065
00066 BOOL
00067 WINAPI
00068 GetExtensionVersion(
00069     HSE_VERSION_INFO *  pVer
00070     )
00071 /*++
00072
00073 Purpose:
00074
00075     Entry point for ISAPI extension initialization.  Required.
00076
00077     This function will be called exactly once in the lifetime
00078     of the extension, at initialization time.  This function is
00079     a useful point to do complex initialization tasks.  This
00080     function is called outside of the system loader lock, so
00081     it does not have the same restrictions as DllMain.
00082
00083 Arguments:
00084
00085     pVer - points to extension version info structure
00086
00087 Returns:
00088
00089     TRUE on success, FALSE on failure.
00090
00091     Note that in the case of FALSE, IIS will call GetLastError()
00092     and return an error page to the client.  The entity body of
00093     the page may be textual if the FormatMessage API can resolve
00094     it, or it may just be an error number if FormatMessage can't
00095     resolve it.
00096
00097 --*/
00098 {
00099     //
00100     // Tell IIS which version of ISAPI this extension was build from.
00101     //
00102
00103     pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
00104                                          HSE_VERSION_MAJOR);
00105
00106     //
00107     // Report the description string for this extension.  Ensure
00108     // that it does not exceed the maximum length and is NULL
00109     // terminated.
00110     //
00111
00112     strncpy( pVer->lpszExtensionDesc,
00113              "UpCaseMap Sample ISAPI Extension",
00114              HSE_MAX_EXT_DLL_NAME_LEN );
00115
00116     pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
00117
00118     //
00119     // Return TRUE if we successfully initialized.
00120     //
00121
00122   return TRUE;
00123 }
00124
00125 DWORD
00126 WINAPI
00127 HttpExtensionProc(
00128     EXTENSION_CONTROL_BLOCK *   pecb
00129     )
00130 /*++
00131
00132 Purpose:
00133
00134     Entry point for ISAPI requests.  Required.
00135
00136     This function is called once per request.  The EXTENSION_CONTROL_BLOCK
00137     passed in contains information and function pointers sufficient to
00138     interact with the server during this processing.
00139
00140     Note that, once HttpExtensionProc is called, it is the responsibility
00141     of the extension to send back any data that the client should receive.
00142     IIS will not automatically generate any response, even in the case of
00143     HSE_STATUS_ERROR once the request has progressed to the point where
00144     this function is called.
00145
00146     Also note that you should not make any blocking calls or do long-running
00147     operations within this function.  To allow efficient scaling of your
00148     server, you should consider creating a pool of private threads to handle
00149     the requests.  In that case, the implementation of this function would
00150     be just to add the pecb to a queue and return HSE_STATUS_PENDING.  The
00151     threads in the pool would be responsible for dequeing a pecb and calling
00152     HSE_REQ_DONE_WITH_SESSION when they are finished processing it.
00153
00154 Arguments:
00155
00156     pecb - pointer to the extenstion control block
00157
00158 Returns:
00159
00160     HSE_STATUS_SUCCESS - Indicates successful request.
00161     HSE_STATUS_ERROR   - Indicates failed request.
00162     HSE_STATUS_PENDING - Indicates that processing of the request
00163                          should continue after this function returns.
00164                          It HSE_STATUS_PENDING is used, it is necessary
00165                          that HSE_REQ_DONE_WITH_SESSION is called
00166                          exactly once when processing is completed for
00167                          the request.
00168
00169 --*/
00170 {
00171     HSE_EXEC_URL_INFO           ExecUrlInfo;
00172     HSE_EXEC_URL_ENTITY_INFO    EntityInfo;
00173     ISAPI_BUFFER *              pbuffEntity = NULL;
00174     ISAPI_REQUEST               Request( pecb );
00175     BOOL                        fModifiedEntity = FALSE;
00176
00177     //
00178     // If there is no entity body on this request, we
00179     // don't need to do any processing.
00180     //
00181
00182     if ( pecb->cbTotalBytes == 0 )
00183     {
00184         goto CallExecUrl;
00185     }
00186
00187     //
00188     // Since we are going to ultimately pass our entity buffer
00189     // to someone else, we need to allocate it on the heap, and
00190     // keep it valid until they are done.
00191     //
00192
00193     pbuffEntity = new ISAPI_BUFFER();
00194
00195     if ( !pbuffEntity )
00196     {
00197         goto Failed;
00198     }
00199
00200     //
00201     // Set the maximum entity body that we will allow
00202     //
00203
00204     pbuffEntity->SetMaxAlloc( MAX_ALLOWED_REQUEST_ENTITY );
00205
00206     //
00207     // Read the entity body.  If we fail due to
00208     // ERROR_NOT_ENOUGH_MEMORY, then we'll send a 413
00209     // response, else we'll send a 500.
00210     //
00211
00212     if ( !Request.ReadAllEntity( pbuffEntity ) )
00213     {
00214         //
00215         // Since we failed to read the entity, we can
00216         // clean up the buffer now.
00217         //
00218
00219         delete pbuffEntity;
00220         pbuffEntity = NULL;
00221
00222         if ( GetLastError() == ERROR_NOT_ENOUGH_MEMORY )
00223         {
00224             HSE_CUSTOM_ERROR_INFO CustomError;
00225
00226             //
00227             // Send a 413 response synchronously using
00228             // HSE_REQ_SEND_CUSTOM_ERROR
00229             //
00230
00231             CustomError.pszStatus = "413 Entity Too Large";
00232             CustomError.uHttpSubError = 0;
00233             CustomError.fAsync = FALSE;
00234
00235             if ( pecb->ServerSupportFunction( pecb->ConnID,
00236                                               HSE_REQ_SEND_CUSTOM_ERROR,
00237                                               &CustomError,
00238                                               NULL,
00239                                               NULL ) == FALSE )
00240             {
00241                 //
00242                 // The custom error call failed (which is likely, since
00243                 // IIS does not include a custom error for this by default).
00244                 //
00245                 // Go ahead and send it manually.
00246                 //
00247
00248                 Request.SyncWriteCompleteResponse( "413 Entity Too Large",
00249                                                    "Content-Type: text/html\r\n\r\n",
00250                                                    "<html>\r\n"
00251                                                    "<head> <title> Entity Too Large "
00252                                                    "</head> </title>\r\n"
00253                                                    "<h1> 413 Entity Too Large </h1>\r\n"
00254                                                    "<hr>\r\n"
00255                                                    "The size of the request entity "
00256                                                    "is too large.\r\n"
00257                                                    "</html>");
00258             }
00259
00260             return HSE_STATUS_ERROR;
00261         }
00262
00263         goto Failed;
00264     }
00265
00266     //
00267     // If the entity is a text type, then convert it to
00268     // upper case.
00269     //
00270     // Note that we could modify the entity body in any
00271     // way that we want to here.  When we pass the details
00272     // of the resulting buffer through the EXEC_URL call,
00273     // the request will be processed as if the client had
00274     // originally sent the contents of our buffer.
00275     //
00276     // This is substantially different than writing a
00277     // READ_RAW_DATA filter in IIS versions earlier than
00278     // 6.0 for a number of reasons.  For example:
00279     //
00280     // - It is easy to assemble the data in a single,
00281     //   contiguous chunk for parsing.
00282     // - We can change the size of the entity body and
00283     //   EXEC_URL will handle the details of making the
00284     //   child request properly recognize it.
00285     // - We could acquire the entity asynchronously (although
00286     //   this sample does not demonstrate async reads).
00287     // - We don't have to worry about writing logic to handle
00288     //   chunk transfer encoding.
00289     // - The request has been authenticed by the time this
00290     //   extension runs, so we don't have to worry about
00291     //   recognizing raw authentication data streams.
00292     //
00293
00294     if ( strnicmp( pecb->lpszContentType, "text/", 5 ) == 0 )
00295     {
00296         //
00297         // Walk the entity body and convert ANSI characters
00298         // to upper case.  We won't use _strupr for this, since
00299         // it assumes that the data is NULL terminated.  This
00300         // is not necessarily true for HTTP entity bodies.
00301         //
00302
00303         CHAR *  pCursor;
00304
00305         //
00306         // Get a pointer to the start of the entity data.
00307         // Note that we will use QueryPtr, and not QueryStr.
00308         // The reason for this is that QueryStr enforces
00309         // NULL termination.  In the case where the entity
00310         // body is already the maximum allowed size, adding
00311         // the NULL will push the buffer one byte over and
00312         // cause it to fail to return the string (with
00313         // last error ERROR_NOT_ENOUGH_MEMORY).
00314         //
00315
00316         pCursor = (CHAR*)pbuffEntity->QueryPtr();
00317
00318         for ( DWORD x = 0; x < pbuffEntity->QueryDataSize(); x++ )
00319         {
00320             *(pCursor + x) = UPCASE_ANSI_CHAR( *(pCursor + x) );
00321         }
00322
00323         fModifiedEntity = TRUE;
00324     }
00325
00326     //
00327     // Associate our modified buffer with the child request
00328     //
00329
00330     EntityInfo.lpbData = pbuffEntity->QueryPtr();
00331     EntityInfo.cbAvailable = pbuffEntity->QueryDataSize();
00332
00333     //
00334     // Fall through
00335     //
00336
00337 CallExecUrl:
00338
00339     //
00340     // Use EXEC_URL to pass the request along
00341     //
00342     // We will pass NULL for all of the parts of the request
00343     // that we don't want to modify.
00344     //
00345     // We will also use the HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR
00346     // flag.  This will ensure that UpCaseMap is not called again
00347     // on this request (which could otherwise happen in some cases).
00348     //
00349
00350     ExecUrlInfo.pszUrl = NULL;
00351     ExecUrlInfo.pszMethod = NULL;
00352     ExecUrlInfo.pszChildHeaders = NULL;
00353     ExecUrlInfo.pUserInfo = NULL;
00354     ExecUrlInfo.pEntity = NULL;
00355     ExecUrlInfo.dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;
00356
00357     if ( fModifiedEntity )
00358     {
00359         ExecUrlInfo.pEntity = &EntityInfo;
00360     }
00361
00362     //
00363     // Associate the completion routine and the current URL with
00364     // this request.
00365     //
00366
00367     if ( pecb->ServerSupportFunction( pecb->ConnID,
00368                                       HSE_REQ_IO_COMPLETION,
00369                                       HandleCompletion,
00370                                       NULL,
00371                                       (DWORD*)pbuffEntity ) == FALSE )
00372     {
00373         goto Failed;
00374     }
00375
00376     //
00377     // Call ExecUrl
00378     //
00379
00380     if ( pecb->ServerSupportFunction( pecb->ConnID,
00381                                       HSE_REQ_EXEC_URL,
00382                                       &ExecUrlInfo,
00383                                       NULL,
00384                                       NULL ) == FALSE )
00385     {
00386         goto Failed;
00387     }
00388
00389     //
00390     // Since EXEC_URL is asynchonous, we need to return STATUS_PENDING.
00391     // The I/O completion routine will clean up.
00392     //
00393
00394     return HSE_STATUS_PENDING;
00395
00396 Failed:
00397
00398     //
00399     // If we've successfully allocated our own entity buffer,
00400     // delete it now.
00401     //
00402
00403     if ( pbuffEntity )
00404     {
00405         delete pbuffEntity;
00406         pbuffEntity = NULL;
00407     }
00408
00409     //
00410     // Send a 500 error
00411     //
00412
00413     return SyncSendGenericServerError( pecb );
00414 }
00415
00416 VOID
00417 WINAPI
00418 HandleCompletion(
00419     EXTENSION_CONTROL_BLOCK *   pecb,
00420     VOID *                      pContext,
00421     DWORD                       cbIO,
00422     DWORD                       dwError
00423     )
00424 {
00425     ISAPI_BUFFER * pEntity = (ISAPI_BUFFER*)pContext;
00426
00427     //
00428     // The child is done.  Delete the entity buffer now.
00429     //
00430
00431     if ( pEntity )
00432     {
00433         delete pEntity;
00434         pEntity = 0;
00435     }
00436
00437     //
00438     // Let IIS know that we are done with the
00439     // ECB and return.
00440     //
00441
00442     pecb->ServerSupportFunction( pecb->ConnID,
00443                                  HSE_REQ_DONE_WITH_SESSION,
00444                                  NULL,
00445                                  NULL,
00446                                  NULL );
00447
00448 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/virtualfile.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

virtualfile.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Defines a virtual file class derived from CBaseNode.  This
00014 //             class will represent our result items
00015 //
00016
00017
00018 #ifndef _CLASS_VIRTUALFILE_
00019 #define _CLASS_VIRTUALFILE_
00020
00021 #include "Globals.h"
00022 #include "BaseNode.h"
00023
00024
00025 class CFolderNode;           // References
00026 class CComponentData;
00027
00028 //---------------------------------------------------------------------------
00029 class CVirtualFile : public CBaseNode
00030 {
00031   public:
00032     CVirtualFile();
00033     virtual ~CVirtualFile();
00034
00035     HRESULT Initialize( NODE_PROPERTIES* pNodeProps );
00036
00037   ///////////////////////////////////////////////////////////////////////////
00038   // Virtual methods
00039   public:
00040     ULONG   GetNodeType() { return NODETYPE_VFILE; }
00041     GUID&   GetNodeGUID() { return thisGUID; }
00042
00043     HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo )
00044             { return E_NOTIMPL; }
00045
00046     HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI )
00047             { return E_NOTIMPL; }
00048
00049     HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI );
00050
00051   ///////////////////////////////////////////////////////////////////////////
00052   // Property Page methods
00053   public:
00054     HRESULT QueryForPropertyPage();
00055     HRESULT CreatePropertyPages( LPPROPERTYSHEETCALLBACK lpCallback, LONG_PTR Handle );
00056     HRESULT GetWatermarks( HBITMAP __RPC_FAR *lphWatermark,
00057                            HBITMAP __RPC_FAR *lphHeader,
00058                            HPALETTE __RPC_FAR *lphPalette,
00059                            BOOL __RPC_FAR *bStretch );
00060
00061
00062   /////////////////////////////////////////////////////////////////////////
00063   //  Notification handlers
00064   public:
00065     HRESULT OnSelect( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00066     HRESULT OnShow( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00067     HRESULT OnDelete( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent );
00068
00069     HRESULT OnExpand( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData )
00070             { return E_NOTIMPL; }
00071
00072     HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData )
00073             { return E_NOTIMPL; }
00074
00075   ///////////////////////////////////////////////////////////////////////////
00076   //  Context Menu methods
00077   public:
00078     HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed );
00079     HRESULT Command( long lCommandID );
00080
00081   private:
00082     static GUID      thisGUID;
00083     CFolderNode*     m_pParentFolder;
00084     CComponentData*  m_pCompData;
00085
00086   private:
00087     static BOOL CALLBACK PPageWndProc0( HWND hPage, UINT uMsg, WPARAM wParam, LPARAM lParam );
00088
00089     BOOL   OnInitPropPage( HWND hPage, WPARAM wParam, LPARAM lParam );
00090     BOOL   OnApplyChanges( HWND hPage, WPARAM wParam, LPARAM lParam );
00091
00092   public:
00093     LONG_PTR     m_nNotifyHandle;
00094
00095   public:
00096     BOOL    IsAttributeSet( DWORD dwAttribute );
00097     VOID    SetAttribute( DWORD dwAttribute );
00098     VOID    RemoveAttribute( DWORD dwAttribute );
00099     LPWSTR  GetAttributeString();
00100     DWORD   GetAttributes()  { return m_dwAttributes; }
00101
00102     LPWSTR  GetObjectPath()  { return L"X:\\TestDirectory\\TestFile.cpp"; }
00103
00104 };
00105
00106 #endif //_CLASS_VIRTUALFILE_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMShare/cShare.h Source File

  • Web
  • NetMeeting
  • NMShare

cShare.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMSHARE.EXE
00003 //  File:       CSHARE.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 //****************************************************************************
00016 //
00017 // CLASS CAppShareNotify
00018 //
00019 //****************************************************************************
00020
00021 class CAppShareNotify : public RefCount, public CNotify, public INmChannelAppShareNotify
00022 {
00023 public:
00024   CAppShareNotify();
00025   ~CAppShareNotify();
00026
00027   // INmChannelAppShareNotify
00028   HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
00029   HRESULT STDMETHODCALLTYPE MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember * pMember);
00030   HRESULT STDMETHODCALLTYPE StateChanged(NM_SHAPP_STATE uNotify, INmSharableApp *pApp);
00031
00032   // ICNotify methods
00033   HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
00034   HRESULT STDMETHODCALLTYPE Disconnect(void);
00035
00036   // IUnknown methods
00037   ULONG STDMETHODCALLTYPE AddRef(void);
00038   ULONG STDMETHODCALLTYPE Release(void);
00039   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
00040 };
00041
00042
00043 //****************************************************************************
00044 //
00045 // Global Variables
00046 //
00047 //****************************************************************************
00048
00049 extern INmChannelAppShare * g_pChannelAppShare;
00050 extern CAppShareNotify    * g_pNotifyAppShare;
00051
00052
00053 //****************************************************************************
00054 //
00055 // Global Routines
00056 //
00057 //****************************************************************************
00058
00059 HRESULT HookChannel(INmChannel * pChannel);
00060 VOID UnHookChannel(INmChannel * pChannel);
00061 VOID FreeAppShareChannel(void);
00062
00063 // from cHwnd.cpp
00064 VOID UpdateApp(INmSharableApp * pApp);
00065 VOID UpdateAppList(void);
00066 VOID DoEnumApps(void);
00067 VOID FreeAllApps(void);
00068
00069 VOID DoWorkAlone(void);
00070 VOID DoCollaborate(void);
00071 VOID DoTakeControl(void);
00072
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step3/StdAfx.h Source File

  • NetDS
  • upnp
  • StepByStep
  • Step3

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__A8BF4DF9_648E_4723_880E_DAB5CBF2B111__INCLUDED_)
00006 #define AFX_STDAFX_H__A8BF4DF9_648E_4723_880E_DAB5CBF2B111__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0400
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__A8BF4DF9_648E_4723_880E_DAB5CBF2B111__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/src/IsapiStringW.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • src

IsapiStringW.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiStringW.cpp
00006
00007 Abstract:
00008
00009     A simple string class build on
00010     the ISAPI_BUFFER class
00011
00012 Author:
00013
00014     ISAPI developer (Microsoft employee), October 2002
00015
00016 --*/
00017
00018 #include <IsapiTools.h>
00019 #include <stdio.h>
00020
00021 ISAPI_STRINGW::ISAPI_STRINGW(
00022     DWORD   dwMaxAlloc
00023     )
00024 /*++
00025
00026 Purpose:
00027
00028     Constructor for ISAPI_STRINGW object
00029
00030 Arguments:
00031
00032     dwMaxAlloc - The max allocation for the storage of this object
00033
00034 Returns:
00035
00036     None
00037
00038 --*/
00039 {
00040     _Buffer.SetMaxAlloc( dwMaxAlloc );
00041 }
00042
00043 ISAPI_STRINGW::~ISAPI_STRINGW()
00044 /*++
00045
00046 Purpose:
00047
00048     Destructor for ISAPI_STRING object
00049
00050 Arguments:
00051
00052     None
00053
00054 Returns:
00055
00056     None
00057
00058 --*/
00059 {
00060 }
00061
00062 BOOL
00063 ISAPI_STRINGW::Copy(
00064     WCHAR * szStringW,
00065     DWORD   cchStringW
00066     )
00067 /*++
00068
00069 Purpose:
00070
00071     Copies a Unicode string to the ISAPI_STRINGW object
00072
00073 Arguments:
00074
00075     szStringW  - The Unicode string to copy
00076     cchStringW - The number of characters to copy
00077
00078 Returns:
00079
00080     TRUE on success, FALSE on failure
00081
00082 --*/
00083 {
00084     //
00085     // If necessary, calculate the length
00086     // of the new data.
00087     //
00088
00089     if ( cchStringW == 0 )
00090     {
00091         cchStringW = wcslen( szStringW );
00092     }
00093
00094     return CopyToOffset( szStringW,
00095                          cchStringW,
00096                          0 );
00097 }
00098
00099 BOOL
00100 ISAPI_STRINGW::CopyA(
00101     CHAR *  szString,
00102     DWORD   cchString
00103     )
00104 /*++
00105
00106 Purpose:
00107
00108     Copies an ANSI string to the ISAPI_STRINGW object
00109
00110 Arguments:
00111
00112     szString  - The ANSI string to copy
00113     cchString - The number of characters to copy
00114
00115 Returns:
00116
00117     TRUE on success, FALSE on failure
00118
00119 --*/
00120 {
00121     //
00122     // If necessary, calculate the length
00123     // of the new data
00124     //
00125
00126     if ( cchString == 0 )
00127     {
00128         cchString = strlen( szString );
00129     }
00130
00131     return CopyAToOffset( szString,
00132                           cchString,
00133                           0 );
00134 }
00135
00136 BOOL
00137 ISAPI_STRINGW::Append(
00138     WCHAR * szStringW,
00139     DWORD   cchStringW
00140     )
00141 /*++
00142
00143 Purpose:
00144
00145     Appends a Unicode string to the ISAPI_STRINGW object
00146
00147 Arguments:
00148
00149     szStringW  - The Unicode string to append
00150     cchStringW - The number of characters to append
00151
00152 Returns:
00153
00154     TRUE on success, FALSE on failure
00155
00156 --*/
00157 {
00158     //
00159     // If necessary, calculate the length
00160     // of the new data.
00161     //
00162
00163     if ( cchStringW == 0 )
00164     {
00165         cchStringW = wcslen( szStringW );
00166     }
00167
00168     return CopyToOffset( szStringW,
00169                          cchStringW,
00170                          QueryCCH() );
00171 }
00172
00173 BOOL
00174 ISAPI_STRINGW::AppendA(
00175     CHAR *  szString,
00176     DWORD   cchString
00177     )
00178 /*++
00179
00180 Purpose:
00181
00182     Appends an ANSI string to the ISAPI_STRINGW object
00183
00184 Arguments:
00185
00186     szString  - The ANSI string to append
00187     cchString - The number of characters to Append
00188
00189 Returns:
00190
00191     TRUE on success, FALSE on failure
00192
00193 --*/
00194 {
00195     //
00196     // If necessary, calculate the length
00197     // of the new data
00198     //
00199
00200     if ( cchString == 0 )
00201     {
00202         cchString = strlen( szString );
00203     }
00204
00205     return CopyAToOffset( szString,
00206                           cchString,
00207                           QueryCCH() );
00208 }
00209
00210 BOOL
00211 ISAPI_STRINGW::Printf(
00212     WCHAR *  szStringW,
00213     ...
00214     )
00215 /*++
00216
00217 Purpose:
00218
00219     Sets the specified printf-style formatted Unicode string
00220     into the ISAPI_STRINGW object using a variable number
00221     of arguments.
00222
00223 Arguments:
00224
00225     szString - The Unicode string format
00226     ...      - Zero or more additional arguments
00227
00228 Returns:
00229
00230     TRUE on success, FALSE on failure
00231
00232 --*/
00233 {
00234     BOOL    fResult;
00235
00236     //
00237     // Let ISAPI_BUFFER::Vsprintf do the work
00238     //
00239
00240     va_list args;
00241
00242     va_start( args, szStringW );
00243
00244     fResult = Vsprintf( szStringW,
00245                         args );
00246
00247     va_end( args );
00248
00249     return fResult;
00250 }
00251
00252 BOOL
00253 ISAPI_STRINGW::Vsprintf(
00254     WCHAR * szFormatW,
00255     va_list args
00256     )
00257 /*++
00258
00259 Purpose:
00260
00261     Sets the specified printf-style formatted Unicode string
00262     into the ISAPI_STRINGW object using a va_list of args.
00263
00264 Arguments:
00265
00266     szFormat - The Unicode string format
00267     ...      - Zero or more additional arguments
00268
00269 Returns:
00270
00271     TRUE on success, FALSE on failure
00272
00273 --*/
00274 {
00275     INT     cchWritten;
00276     DWORD   cbBuffer;
00277     BOOL    fResult;
00278
00279     //
00280     // Build the formatted string
00281     //
00282
00283     do
00284     {
00285         cbBuffer = QueryBufferSize();
00286
00287         cchWritten = (DWORD)_vsnwprintf( QueryStr(),
00288                                          cbBuffer,
00289                                          szFormatW,
00290                                          args );
00291
00292         if ( cchWritten < 0 )
00293         {
00294             //
00295             // If we just failed, and the buffer
00296             // is already at its maximum size,
00297             // then fail.
00298             //
00299
00300             if ( cbBuffer >= QueryMaxAlloc() )
00301             {
00302                 goto Failed;
00303             }
00304
00305             //
00306             // Grow the buffer and try again
00307             //
00308
00309             cbBuffer *= 2;
00310
00311             //
00312             // Don't exceed the max buffer size
00313             //
00314
00315             if ( cbBuffer > QueryMaxAlloc() )
00316             {
00317                 cbBuffer = QueryMaxAlloc();
00318             }
00319
00320             fResult = ResizeBuffer( cbBuffer );
00321
00322             if ( !fResult )
00323             {
00324                 goto Failed;
00325             }
00326         }
00327
00328     } while ( cchWritten < 0 );
00329
00330     SetLen( cchWritten );
00331
00332     return TRUE;
00333
00334 Failed:
00335
00336     //
00337     // No special cleanup needed
00338     //
00339
00340     return FALSE;
00341 }
00342
00343 VOID
00344 ISAPI_STRINGW::CalcLen(
00345     VOID
00346     )
00347 /*++
00348
00349 Purpose:
00350
00351     Calculates the size in characters of the ISAPI_STRINGW data by
00352     doing a wcslen.
00353
00354 Arguments:
00355
00356     None
00357
00358 Returns:
00359
00360     None
00361
00362 --*/
00363 {
00364     _Buffer.SetDataSize( wcslen( QueryStr() ) + 1 );
00365 }
00366
00367 DWORD
00368 ISAPI_STRINGW::QueryCB(
00369     VOID
00370     )
00371 /*++
00372
00373 Purpose:
00374
00375     Returns the size, in bytes, of the ISAPI_STRINGW data (not
00376     including the NULL terminator).
00377
00378 Arguments:
00379
00380     None
00381
00382 Returns:
00383
00384     The size in bytes
00385
00386 --*/
00387 {
00388     DWORD   cbBuffer = _Buffer.QueryDataSize();
00389
00390     return cbBuffer == 0 ? 0 : ( cbBuffer - 1 );
00391 }
00392
00393 DWORD
00394 ISAPI_STRINGW::QueryCCH(
00395     VOID
00396     )
00397 /*++
00398
00399 Purpose:
00400
00401     Returns the size, in characters, of the ISAPI_STRINGW data (not
00402     including the NULL terminator).
00403
00404 Arguments:
00405
00406     None
00407
00408 Returns:
00409
00410     The size in characters
00411
00412 --*/
00413 {
00414     return QueryCB() / sizeof(WCHAR);
00415 }
00416
00417 BOOL
00418 ISAPI_STRINGW::SetLen(
00419     DWORD   cchNewLength
00420     )
00421 /*++
00422
00423 Purpose:
00424
00425     Sets the length of the data, in characters, in the ISAPI_STRINGW
00426     object, truncating the current data if necessary.
00427
00428 Arguments:
00429
00430     cchNewLength - The new data length in characters.
00431
00432 Returns:
00433
00434     TRUE on success, FALSE on failure.
00435
00436 --*/
00437 {
00438     WCHAR * pCursor;
00439     DWORD   cbNewLength = cchNewLength * sizeof(WCHAR);
00440     BOOL    fResult;
00441
00442     fResult = _Buffer.SetDataSize( cbNewLength + sizeof(WCHAR) );
00443
00444     if ( !fResult )
00445     {
00446         return FALSE;
00447     }
00448
00449     pCursor = (WCHAR*)_Buffer.QueryPtr() + cchNewLength;
00450
00451     *pCursor = L'\0';
00452
00453     return TRUE;
00454 }
00455
00456 DWORD
00457 ISAPI_STRINGW::QueryBufferSize(
00458     VOID
00459     )
00460 /*++
00461
00462 Purpose:
00463
00464     Returns the size, in bytes, of the ISAPI_STRINGW buffer
00465
00466 Arguments:
00467
00468     None
00469
00470 Returns:
00471
00472     The buffer size, in bytes
00473
00474 --*/
00475 {
00476     return _Buffer.QueryBufferSize();
00477 }
00478
00479 BOOL
00480 ISAPI_STRINGW::ResizeBuffer(
00481     DWORD   cbSize
00482     )
00483 /*++
00484
00485 Purpose:
00486
00487     Guarantees that the data storage buffer of the ISAPI_STRINGW
00488     object is at least the number of specified bytes.
00489
00490 Arguments:
00491
00492     cbSize - The target size
00493
00494 Returns:
00495
00496     TRUE on success, FALSE on failure
00497
00498 --*/
00499 {
00500     return _Buffer.Resize( cbSize );
00501 }
00502
00503 DWORD
00504 ISAPI_STRINGW::QueryMaxAlloc(
00505     VOID
00506     )
00507 /*++
00508
00509 Purpose:
00510
00511     Returns the max allocation size for the ISAPI_STRINGW's buffer
00512
00513 Arguments:
00514
00515     None
00516
00517 Returns:
00518
00519     The max allocation size
00520
00521 --*/
00522 {
00523     return _Buffer.QueryMaxAlloc();
00524 }
00525
00526 VOID
00527 ISAPI_STRINGW::SetMaxAlloc(
00528     DWORD   dwMaxAlloc
00529     )
00530 /*++
00531
00532 Purpose:
00533
00534     Sets the max allocation size for the ISAPI_STRINGW's buffer
00535
00536 Arguments:
00537
00538     The max allocation size
00539
00540 Returns:
00541
00542     None
00543
00544 --*/
00545 {
00546     _Buffer.SetMaxAlloc( dwMaxAlloc );
00547 }
00548
00549 WCHAR *
00550 ISAPI_STRINGW::QueryStr(
00551     VOID
00552     )
00553 /*++
00554
00555 Purpose:
00556
00557     Returns the data pointer for the ISAPI_STRINGW
00558
00559 Arguments:
00560
00561     None
00562
00563 Returns:
00564
00565     The data pointer
00566
00567 --*/
00568 {
00569     return (WCHAR*)_Buffer.QueryPtr();
00570 }
00571
00572 BOOL
00573 ISAPI_STRINGW::CopyToOffset(
00574     WCHAR * szStringW,
00575     DWORD   cchStringW,
00576     DWORD   cchOffset
00577     )
00578 /*++
00579
00580 Purpose:
00581
00582     Copies a Unicode string into the ISAPI_STRINGW's data, starting at the
00583     specified offset, in characters.
00584
00585 Arguments:
00586
00587     szStringW  - The Unicode string to copy
00588     cchStringW - The number of characters to copy
00589     cchOffset  - The offset, in chracters, at which to copy
00590
00591 Returns:
00592
00593     TRUE on success, FALSE on failure
00594
00595 --*/
00596 {
00597     DWORD   cbData;
00598
00599     //
00600     // Ensure that we have enough storage available
00601     //
00602
00603     cbData = ( cchStringW + 1 ) * sizeof(WCHAR);
00604
00605     if ( ResizeBuffer( cbData + cchOffset * sizeof(WCHAR) ) == FALSE )
00606     {
00607         return FALSE;
00608     }
00609
00610     //
00611     // Copy the data and ensure proper termination
00612     //
00613
00614     CopyMemory( QueryStr() + cchOffset, szStringW, cbData );
00615
00616     SetLen( QueryCCH() + cchStringW );
00617
00618     return TRUE;
00619 }
00620
00621 BOOL
00622 ISAPI_STRINGW::CopyAToOffset(
00623     CHAR *  szString,
00624     DWORD   cchString,
00625     DWORD   cchOffset
00626     )
00627 /*++
00628
00629 Purpose:
00630
00631     Copies an ANSI string into the ISAPI_STRINGW's data, starting at the
00632     specified offset, in characters.
00633
00634 Arguments:
00635
00636     szString  - The ANSI string to copy
00637     cchString - The number of characters to copy
00638     cchOffset - The offset, in chracters, at which to copy
00639
00640 Returns:
00641
00642     TRUE on success, FALSE on failure
00643
00644 --*/
00645 {
00646     WCHAR * pCursor;
00647     DWORD   cbString;
00648     DWORD   cchCopied;
00649     DWORD   cchData;
00650     DWORD   cbData;
00651
00652     cchData = QueryCCH();
00653     cbData = QueryCB();
00654
00655     //
00656     // Ensure that we have enough storage available
00657     //
00658
00659     cbString = ( cchString + 1 ) * sizeof(WCHAR);
00660
00661     if ( ResizeBuffer( cbString + cchOffset * sizeof(WCHAR) ) == FALSE )
00662     {
00663         goto Failed;
00664     }
00665
00666     //
00667     // Set the point into which the copy will occur
00668     //
00669
00670     pCursor = QueryStr() + cchData;
00671
00672     //
00673     // Convert the ANSI string into Unicode using
00674     // the default system code page.
00675     //
00676
00677     cchCopied = MultiByteToWideChar( CP_ACP,
00678                                      MB_PRECOMPOSED,
00679                                      szString,
00680                                      cchString,
00681                                      pCursor,
00682                                      cbData );
00683
00684     if ( cchCopied == 0 )
00685     {
00686         goto Failed;
00687     }
00688
00689     SetLen( cchData + cchCopied );
00690
00691     return TRUE;
00692
00693 Failed:
00694
00695     //
00696     // No special cleanup to be done
00697     //
00698
00699     return FALSE;
00700 }
00701
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/bitarray.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

bitarray.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module BITARRAY.CPP | This contains an implementation of a bit array
00008 // class currently used by the Internal Buffer to mark released or
00009 // unreleased rows.
00010 //
00011 //
00012 #include "headers.h"
00013 #include "bitarray.h"
00014
00015
00016 //--------------------------------------------------------------------
00017 // @mfunc Constructor for this class
00018 //
00019 // @rdesc NONE
00020 //
00021 CBitArray::CBitArray
00022     (
00023     void
00024     )
00025 {
00026     m_rgbBit       = NULL;
00027     m_cPageMax     = 0;
00028     m_cPageCurrent = 0;
00029     m_cslotCurrent = 0;
00030 }
00031
00032
00033 //--------------------------------------------------------------------
00034 // @mfunc Destructor for this class
00035 //
00036 // @rdesc NONE
00037 //
00038 CBitArray:: ~CBitArray
00039     (
00040     void
00041     )
00042 {
00043     if (m_rgbBit)
00044         {
00045         if (m_cPageCurrent)
00046             VirtualFree((VOID *) m_rgbBit, m_cPageCurrent *m_cbPage, MEM_DECOMMIT );
00047         VirtualFree((VOID *) m_rgbBit, 0, MEM_RELEASE );
00048         }
00049 }
00050
00051
00052 //--------------------------------------------------------------------
00053 // @mfunc Allocate and Initialize the array of bits
00054 //
00055 // @rdesc HRESULT indicating routines status
00056 //      @flag  S_OK          | Initialization succeeded
00057 //      @flag  E_OUTOFMEMORY | Not enough memory to allocate bit array
00058 //
00059 STDMETHODIMP CBitArray::FInit
00060     (
00061     ULONG cslotMax,     //@parm IN  | Maximum number of slot
00062     ULONG cbPage        //@parm IN  | Count of bytes per page
00063     )
00064 {
00065     ULONG cPage;
00066     ULONG ib;
00067
00068     cPage = (cslotMax / 8 + 1) / cbPage + 1;
00069     m_rgbBit = (BYTE *) VirtualAlloc( NULL, cbPage *cPage, MEM_RESERVE, PAGE_READWRITE );
00070
00071     if (m_rgbBit == NULL)
00072         return ResultFromScode( E_OUTOFMEMORY );
00073
00074     m_cPageMax = cPage;
00075
00076     m_cbPage = cbPage;
00077
00078     for (ib =0; ib < 8; ib++)
00079         m_rgbBitMask[ib] = (1 << ib);
00080     return ResultFromScode( S_OK );
00081 }
00082
00083
00084 //--------------------------------------------------------------------
00085 // @mfunc Set a range of bit slots
00086 //
00087 // @rdesc HRESULT indicating routines status
00088 //      @flag  S_OK          | Initialization succeeded
00089 //      @flag  E_OUTOFMEMORY | Not enough memory to allocate bit array
00090 //
00091 STDMETHODIMP CBitArray::SetSlots
00092     (
00093     ULONG islotFirst,   //@parm IN | First slot in range to set
00094     ULONG islotLast     //@parm IN | Last slot in range to set
00095     )
00096 {
00097     ULONG islot;
00098
00099     if (islotLast >=    m_cslotCurrent)
00100         {
00101         ULONG cPageAdd;
00102
00103         cPageAdd = ((islotLast - m_cslotCurrent + 1) / 8 + 1) / m_cbPage + 1;
00104
00105         if ((cPageAdd + m_cPageCurrent) > m_cPageMax
00106             || VirtualAlloc( m_rgbBit + m_cPageCurrent*m_cbPage, cPageAdd *m_cbPage, MEM_COMMIT, PAGE_READWRITE ) == NULL)
00107             return ResultFromScode( E_OUTOFMEMORY );
00108
00109         memset( m_rgbBit + m_cPageCurrent*m_cbPage, 0x00, cPageAdd *m_cbPage );
00110         m_cPageCurrent += cPageAdd;
00111         m_cslotCurrent += cPageAdd *m_cbPage *8;
00112         }
00113
00114     // Only do this top section
00115     // if we have at least 2 byte's worth of bits to set.
00116     // Although no real speedup until we have 3 byte's worth.
00117     // Note really ought to be ((ilast-ifirst+1) >= 2*8).
00118     // (Note could use CHAR_BIT, num bits in a char.)
00119     // Also optimized end cases, so nothing is done
00120     // if the start or end is byte aligned.
00121     // Need this copied into ResetSlots.
00122
00123     //if((islotLast -islotFirst) > 2*sizeof(BYTE))
00124     if (islotLast - islotFirst > 2 * 8)
00125         {
00126         ULONG ibFirst, ibLast;
00127         int iFixFirst, iFixLast;
00128
00129         ibFirst = islotFirst / 8;
00130         ibLast  = islotLast / 8;
00131         iFixFirst = (islotFirst % 8 != 0);  // set to 1 if first byte not totally set
00132         iFixLast  = (islotLast % 8 != 7);   // set to 1 if last  byte not totally set
00133
00134         if (iFixFirst)
00135             for (islot = islotFirst; (islot / 8) == ibFirst; islot++)
00136                 m_rgbBit[islot / 8] |= m_rgbBitMask[islot % 8];
00137
00138         memset( &m_rgbBit[ibFirst + iFixFirst], 0xff, ibLast - ibFirst + 1 - iFixFirst - iFixLast );
00139
00140         if (iFixLast)
00141             for (islot = islotLast; (islot / 8) == ibLast; islot--)
00142                 m_rgbBit[islot / 8] |= m_rgbBitMask[islot % 8];
00143         }
00144     else
00145         {
00146         for (islot = islotFirst; islot <= islotLast; islot++)
00147             m_rgbBit[islot / 8] |= m_rgbBitMask[islot % 8];
00148         }
00149
00150     return ResultFromScode( S_OK );
00151 }
00152
00153
00154 //--------------------------------------------------------------------
00155 // @mfunc Reset a range of slots
00156 //
00157 // @rdesc HRESULT indicating routines status
00158 //      @flag  S_OK | Reset Succeeded
00159 //
00160 STDMETHODIMP CBitArray::ResetSlots
00161     (
00162     ULONG islotFirst,   //@parm IN | First slot in range to reset
00163     ULONG islotLast     //@parm IN | Last slot in range to reset
00164     )
00165 {
00166     ULONG ibFirst, ibLast, islot;
00167
00168     if (islotFirst < m_cslotCurrent)
00169         {
00170         if (islotLast >=    m_cslotCurrent)
00171             islotLast = m_cslotCurrent - 1;
00172
00173         if ((islotLast - islotFirst) > 2*8)
00174             {
00175             ibFirst = islotFirst / 8;
00176             ibLast  = islotLast / 8;
00177             for (islot = islotFirst; (islot / 8) == ibFirst; islot++)
00178                 m_rgbBit[islot / 8] &= ~m_rgbBitMask[islot % 8];
00179             memset( &m_rgbBit[ibFirst + 1], 0x00, (ULONG)(ibLast - ibFirst - 1) );
00180             for (islot = islotLast; (islot / 8) == ibLast; islot--)
00181                 m_rgbBit[islot / 8] &= ~m_rgbBitMask[islot % 8];
00182             }
00183         else
00184             {
00185             for (islot = islotFirst; islot <= islotLast; islot++)
00186                 m_rgbBit[islot / 8] &= ~m_rgbBitMask[islot % 8];
00187             }
00188         }
00189
00190     return ResultFromScode( S_OK );
00191 }
00192
00193
00194 //--------------------------------------------------------------------
00195 // @mfunc Determines if any bits are set
00196 //
00197 // @rdesc HRESULT indicating routines status
00198 //      @flag  S_OK     | Array is Empty
00199 //      @flag  S_FALSE  | Array contains set bits
00200 //
00201 STDMETHODIMP CBitArray::ArrayEmpty
00202     (
00203     void
00204     )
00205 {
00206     if (m_cPageCurrent)
00207         {
00208         ULONG idw, cdw, *rgdw;
00209
00210         cdw = m_cPageCurrent * (m_cbPage / sizeof( ULONG ));
00211         rgdw = (ULONG *) m_rgbBit;
00212         for (idw =0; idw < cdw; idw++)
00213             if (rgdw[idw])
00214                 return ResultFromScode( S_FALSE );
00215         }
00216     return ResultFromScode( S_OK );
00217 }
00218
00219
00220
00221 //--------------------------------------------------------------------
00222 // @mfunc Determine if a particular bit slot is set
00223 //
00224 // @rdesc HRESULT indicating routines status
00225 //      @flag  S_OK          | Slot is set
00226 //      @flag  E_OUTOFMEMORY | Slot is not set
00227 //
00228 STDMETHODIMP CBitArray::IsSlotSet
00229     (
00230     ULONG islot   //@parm IN | Bit slot to check
00231     )
00232 {
00233     if (islot >= m_cslotCurrent || (m_rgbBit[islot / 8] & m_rgbBitMask[islot % 8]) == 0x00)
00234         return ResultFromScode( S_FALSE );  // not set
00235     else
00236         return ResultFromScode( S_OK ); // is set
00237 }
00238
00239
00240 //--------------------------------------------------------------------
00241 // @mfunc Find the first set slot within the bit array given a starting
00242 // position
00243 //
00244 // @rdesc HRESULT indicating routines status
00245 //      @flag  S_OK          | Initialization succeeded
00246 //      @flag  E_OUTOFMEMORY | Not enough memory to allocate bit array
00247 //
00248 STDMETHODIMP CBitArray::FindSet
00249     (
00250     ULONG islotStart,   //@parm IN | Starting slot to search from
00251     ULONG islotLimit,   //@parm IN | Number of slots to check
00252     ULONG *pislot       //@parm OUT | Index of first set slot
00253     )
00254 {
00255     ULONG ibStart, ibLimit, idwStart, idwLimit, ibEnd, ib, islot, islotEnd, idw, *pdw;
00256
00257     if (islotStart > islotLimit)
00258         {
00259         ibStart  = islotStart / 8;
00260         ibLimit  = islotLimit / 8;
00261         if ((ibStart - ibLimit) > 1)
00262             {
00263             islotEnd = ibStart*8;
00264             for (islot = islotStart; islot >= islotEnd; islot--)
00265                 if (m_rgbBit[islot / 8] & m_rgbBitMask[islot % 8])
00266                     {
00267                     *pislot = islot;
00268                     return ResultFromScode( S_OK );
00269                     }
00270             idwStart = islotStart / 32;
00271             idwLimit = islotLimit / 32;
00272             if (idwStart - idwLimit > 1)
00273                 {
00274                 ibEnd = idwStart*4;
00275                 for (ib = ibStart - 1; ib >= ibEnd; ib--)
00276                     if (m_rgbBit[ib])
00277                         {
00278                         islot = ib*8 + 7;
00279                         goto Found1;
00280                         }
00281                 for (pdw = (ULONG *) & m_rgbBit[ (idwStart - 1) *4], idw = idwStart - 1; idw > idwLimit; idw--, pdw--)
00282                     if (*pdw)
00283                         {
00284                         islot = idw*32 + 31;
00285                         goto Found1;
00286                         }
00287                 ib = (idwLimit*4 + 3);
00288                 }
00289             else
00290                 ib = ibStart - 1;
00291             for (; ib > ibLimit; ib--)
00292                 if (m_rgbBit[ib])
00293                     {
00294                     islot = ib*8 + 7;
00295                     goto Found1;
00296                     }
00297             islot = (ibLimit*8 + 7);
00298             }
00299         else
00300             islot = islotStart;
00301
00302         Found1:
00303         for (; islot >= islotLimit; islot--)
00304             if (m_rgbBit[islot / 8] & m_rgbBitMask[islot % 8])
00305                 {
00306                 *pislot = islot;
00307                 return ResultFromScode( S_OK );
00308                 }
00309         return ResultFromScode( S_FALSE );  // not found
00310         }
00311     else
00312         return ResultFromScode( E_FAIL );
00313 }
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIDBCreateCommand Member List

This is the complete list of members for CImpIDBCreateCommand, including all inherited members.
CreateCommand(IUnknown *, REFIID, IUnknown **) | CImpIDBCreateCommand |
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CDBSession, CImpIDBCreateCommand) | CImpIDBCreateCommand |
DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CDBSession) | CImpIDBCreateCommand | [private]
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIOleDocumentSite Member List

This is the complete list of members for CImpIOleDocumentSite, including all inherited members.
ActivateMe(IOleDocumentView *) | CImpIOleDocumentSite |
CImpIOleDocumentSite(class CSite *, IUnknown *) | CImpIOleDocumentSite |
m_cRef | CImpIOleDocumentSite | [protected]
m_pSite | CImpIOleDocumentSite | [protected]
m_pUnkOuter | CImpIOleDocumentSite | [protected]
QueryInterface(REFIID, void **) | CImpIOleDocumentSite |
STDMETHODIMP_(ULONG) AddRef(void) | CImpIOleDocumentSite |
STDMETHODIMP_(ULONG) Release(void) | CImpIOleDocumentSite |
~CImpIOleDocumentSite(void) | CImpIOleDocumentSite |
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIRowChange Member List

This is the complete list of members for CImpIRowChange, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRow, CImpIRowChange) | CImpIRowChange
SetColumns(DBORDINAL cColumns, DBCOLUMNACCESS rgColumns[]) | CImpIRowChange
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/DComPerm/Wrappers.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • DComPerm

Wrappers.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <stdio.h>
00020 #include <conio.h>
00021 #include <tchar.h>
00022 #include "ntsecapi.h"
00023 #include "dcomperm.h"
00024
00025 /*---------------------------------------------------------------------------*\
00026  * NAME: ListMachineAccessACL                                                *
00027  * --------------------------------------------------------------------------*
00028  * DESCRIPTION: Displays the Machine Access ACL                              *
00029  * --------------------------------------------------------------------------*
00030  * RETURNS: WIN32 Error Code                                                 *
00031 \*---------------------------------------------------------------------------*/
00032 DWORD ListMachineAccessACL()
00033 {
00034     return ListNamedValueSD (HKEY_LOCAL_MACHINE,
00035                              _T("Software\\Microsoft\\Ole"),
00036                              _T("MachineAccessRestriction"),
00037                              SDTYPE_MACHINE_ACCESS);
00038 }
00039
00040 /*---------------------------------------------------------------------------*\
00041  * NAME: ListMachineLaunchACL                                                *
00042  * --------------------------------------------------------------------------*
00043  * DESCRIPTION: Displays the Machine Launch ACL                              *
00044  * --------------------------------------------------------------------------*
00045  * RETURNS: WIN32 Error Code                                                 *
00046 \*---------------------------------------------------------------------------*/
00047 DWORD ListMachineLaunchACL()
00048 {
00049     return ListNamedValueSD (HKEY_LOCAL_MACHINE,
00050                              _T("Software\\Microsoft\\Ole"),
00051                              _T("MachineLaunchRestriction"),
00052                              SDTYPE_MACHINE_LAUNCH);
00053 }
00054
00055 /*---------------------------------------------------------------------------*\
00056  * NAME: ListDefaultAccessACL                                                *
00057  * --------------------------------------------------------------------------*
00058  * DESCRIPTION: Displays the Default Access ACL                              *
00059  * --------------------------------------------------------------------------*
00060  * RETURNS: WIN32 Error Code                                                 *
00061 \*---------------------------------------------------------------------------*/
00062 DWORD ListDefaultAccessACL()
00063 {
00064     return ListNamedValueSD (HKEY_LOCAL_MACHINE,
00065                              _T("Software\\Microsoft\\Ole"),
00066                              _T("DefaultAccessPermission"),
00067                              SDTYPE_DEFAULT_ACCESS);
00068 }
00069
00070 /*---------------------------------------------------------------------------*\
00071  * NAME: ListDefaultLaunchACL                                                *
00072  * --------------------------------------------------------------------------*
00073  * DESCRIPTION: Displays the Defualt Launch/Activate ACL                     *
00074  * --------------------------------------------------------------------------*
00075  * RETURNS: WIN32 Error Code                                                 *
00076 \*---------------------------------------------------------------------------*/
00077 DWORD ListDefaultLaunchACL()
00078 {
00079     return ListNamedValueSD (HKEY_LOCAL_MACHINE,
00080                              _T("Software\\Microsoft\\Ole"),
00081                              _T("DefaultLaunchPermission"),
00082                              SDTYPE_DEFAULT_LAUNCH);
00083 }
00084
00085 /*---------------------------------------------------------------------------*\
00086  * NAME: ListAppIDAccessACL                                                  *
00087  * --------------------------------------------------------------------------*
00088  * DESCRIPTION: Displays a designated Application Access ACL                 *
00089  * --------------------------------------------------------------------------*
00090  * RETURNS: WIN32 Error Code                                                 *
00091 \*---------------------------------------------------------------------------*/
00092 DWORD ListAppIDAccessACL (
00093     LPTSTR tszAppID
00094     )
00095 {
00096     TCHAR   tszKeyName [256] = {0};
00097
00098     _sntprintf (tszKeyName,
00099                  (sizeof(tszKeyName)/sizeof(*tszKeyName))-1,
00100                  tszAppID [0] == '{' ? _T("APPID\\%s") : _T("APPID\\{%s}"),
00101                  tszAppID);
00102
00103     return ListNamedValueSD (HKEY_CLASSES_ROOT,
00104                              tszKeyName,
00105                              _T("AccessPermission"),
00106                              SDTYPE_APPLICATION_ACCESS);
00107 }
00108
00109 /*---------------------------------------------------------------------------*\
00110  * NAME: ListAppIDLaunchACL                                                  *
00111  * --------------------------------------------------------------------------*
00112  * DESCRIPTION: Displays a designated Application Launch/Activate ACL        *
00113  * --------------------------------------------------------------------------*
00114  * RETURNS: WIN32 Error Code                                                 *
00115 \*---------------------------------------------------------------------------*/
00116 DWORD ListAppIDLaunchACL (
00117     LPTSTR tszAppID
00118     )
00119 {
00120     TCHAR   tszKeyName [256] = {0};
00121
00122     _sntprintf (tszKeyName,
00123                  (sizeof(tszKeyName)/sizeof(*tszKeyName))-1,
00124                  tszAppID [0] == '{' ? _T("APPID\\%s") : _T("APPID\\{%s}"),
00125                  tszAppID);
00126
00127     return ListNamedValueSD (HKEY_CLASSES_ROOT,
00128                              tszKeyName,
00129                              _T("LaunchPermission"),
00130                              SDTYPE_APPLICATION_LAUNCH);
00131 }
00132
00133
00134 /*---------------------------------------------------------------------------*\
00135  * NAME: ChangeMachineAccessACL                                              *
00136  * --------------------------------------------------------------------------*
00137  * DESCRIPTION: Modifies the machine-wide access ACL. The                    *
00138  * system uses the machine-wide access ACL to determine the type of access   *
00139  * a principal has to servers on this machine.  This value will override     *
00140  * any default or application specific settings.                             *
00141  * --------------------------------------------------------------------------*
00142  *  ARGUMENTS:                                                               *
00143  *                                                                           *
00144  *  tszPrincipal - Name of user or group (e.g. "redmond\johndoe").           *
00145  *                                                                           *
00146  *  fSetPrincipal - TRUE if you want to add/update the principal's entry in  *
00147  *  the ACL, FALSE if you want to remove the principal from the ACL.         *
00148  *                                                                           *
00149  *  fSetPrincipal - TRUE if you want to add/update the principal's entry in  *
00150  *  the ACL, FALSE if you want to remove the principal from the ACL.         *
00151  *                                                                           *
00152  *  dwAccessMask - Specifies what type of access the principal is to be      *
00153  *  given.  Can be any combination of the COM_RIGHTS_* values.               *
00154  *                                                                           *
00155  * --------------------------------------------------------------------------*
00156  * RETURNS: WIN32 Error Code                                                 *
00157 \*---------------------------------------------------------------------------*/
00158 DWORD ChangeMachineAccessACL (
00159     LPTSTR tszPrincipal,
00160     BOOL fSetPrincipal,
00161     BOOL fPermit,
00162     DWORD dwAccessMask
00163     )
00164 {
00165
00166     DWORD dwReturnValue = ERROR_SUCCESS;
00167
00168     if (fSetPrincipal)
00169     {
00170         dwReturnValue =
00171             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00172                                              _T("Software\\Microsoft\\Ole"),
00173                                              _T("MachineAccessRestriction"),
00174                                              tszPrincipal,
00175                                              fPermit ? ACCESS_ALLOWED_ACE_TYPE : ACCESS_DENIED_ACE_TYPE);
00176
00177         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00178
00179         dwReturnValue =
00180             UpdatePrincipalInNamedValueSD(HKEY HKEY_LOCAL_MACHINE,
00181                                           _T("Software\\Microsoft\\Ole"),
00182                                           _T("MachineAccessRestriction"),
00183                                           tszPrincipal,
00184                                           dwAccessMask,
00185                                           TRUE,
00186                                           fPermit ? ACCESS_DENIED_ACE_TYPE : ACCESS_ALLOWED_ACE_TYPE);
00187
00188         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00189
00190         dwReturnValue =
00191             AddPrincipalToNamedValueSD (HKEY_LOCAL_MACHINE,
00192                                         _T("Software\\Microsoft\\Ole"),
00193                                         _T("MachineAccessRestriction"),
00194                                         tszPrincipal,
00195                                         fPermit,
00196                                         dwAccessMask,
00197                                         SDTYPE_MACHINE_ACCESS);
00198     }
00199     else
00200     {
00201         dwReturnValue =
00202             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00203                                              _T("Software\\Microsoft\\Ole"),
00204                                              _T("MachineAccessRestriction"),
00205                                              tszPrincipal,
00206                                              ACE_TYPE_ALL);
00207     }
00208
00209     return dwReturnValue;
00210 }
00211
00212 /*---------------------------------------------------------------------------*\
00213  * NAME: ChangeMachineLaunchAndActivateACL                                   *
00214  * --------------------------------------------------------------------------*
00215  * DESCRIPTION: Modifies the machine-wide launch access control list. The    *
00216  * system uses the machine-wide launch ACL to determine the type of launch   *
00217  * and/or activation privileges a principal has for servers on this machine. *
00218  * This value will override any default or application specific settings.    *
00219  *---------------------------------------------------------------------------*
00220  *  ARGUMENTS:                                                               *
00221  *                                                                           *
00222  *  tszPrincipal - Name of user or group (e.g. "redmond\johndoe").           *
00223  *                                                                           *
00224  *  fSetPrincipal - TRUE if you want to add/update the principal's entry     *
00225  *  in the ACL, FALSE if you want to remove the principal from the ACL.      *
00226  *                                                                           *
00227  *  fPermit - TRUE if you want to allow the principal to access the object,  *
00228  *  FALSE if you want to prevent the principal from accessing the object.    *
00229  *                                                                           *
00230  *  dwAccessMask - Specifies what type of access the principal is to be      *
00231  *  given.  Can be any combination of the COM_RIGHTS_* values.               *
00232  *                                                                           *
00233  * --------------------------------------------------------------------------*
00234  * RETURNS: WIN32 Error Code                                                 *
00235 \*---------------------------------------------------------------------------*/
00236 DWORD ChangeMachineLaunchAndActivateACL (
00237     LPTSTR tszPrincipal,
00238     BOOL fSetPrincipal,
00239     BOOL fPermit,
00240     DWORD dwAccessMask
00241     )
00242 {
00243
00244     DWORD dwReturnValue = ERROR_SUCCESS;
00245
00246     if (fSetPrincipal)
00247     {
00248         dwReturnValue =
00249             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00250                                              _T("Software\\Microsoft\\Ole"),
00251                                              _T("MachineLaunchRestriction"),
00252                                              tszPrincipal,
00253                                              fPermit ? ACCESS_ALLOWED_ACE_TYPE :
00254                                              ACCESS_DENIED_ACE_TYPE);
00255
00256         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00257
00258         dwReturnValue =
00259             UpdatePrincipalInNamedValueSD(HKEY_LOCAL_MACHINE,
00260                                           _T("Software\\Microsoft\\Ole"),
00261                                           _T("MachineLaunchRestriction"),
00262                                           tszPrincipal,
00263                                           dwAccessMask,
00264                                           TRUE,
00265                                           fPermit ? ACCESS_DENIED_ACE_TYPE :
00266                                           ACCESS_ALLOWED_ACE_TYPE);
00267
00268         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00269
00270         dwReturnValue =
00271             AddPrincipalToNamedValueSD (HKEY_LOCAL_MACHINE,
00272                                         _T("Software\\Microsoft\\Ole"),
00273                                         _T("MachineLaunchRestriction"),
00274                                         tszPrincipal,
00275                                         fPermit,
00276                                         dwAccessMask,
00277                                         SDTYPE_MACHINE_LAUNCH);
00278     }
00279     else
00280     {
00281         dwReturnValue =
00282             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00283                                              _T("Software\\Microsoft\\Ole"),
00284                                              _T("MachineLaunchRestriction"),
00285                                              tszPrincipal,
00286                                              ACE_TYPE_ALL);
00287     }
00288
00289     return dwReturnValue;
00290 }
00291
00292
00293 /*---------------------------------------------------------------------------*\
00294  * NAME: ChangeDefaultAccessACL                                              *
00295  * --------------------------------------------------------------------------*
00296  * DESCRIPTION: Modifies the default access ACL. The system uses the         *
00297  * default access ACL to determine if a principal is allowed to access the   *
00298  * COM server if the COM server does not have its own access ACL in the      *
00299  * AppID section of the registry.                                            *
00300  * --------------------------------------------------------------------------*
00301  *  ARGUMENTS:                                                               *
00302  *                                                                           *
00303  *  tszPrincipal - Name of user or group (e.g. "redmond\johndoe").           *
00304  *                                                                           *
00305  *  fSetPrincipal - TRUE if you want to add/update the principal's entry in  *
00306  *  the ACL, FALSE if you want to remove the principal from the ACL.         *
00307  *                                                                           *
00308  *  fPermit - TRUE if you want to allow the principal to access the object,  *
00309  *  FALSE if you want to prevent the principal from accessing the object.    *
00310  *                                                                           *
00311  *  dwAccessMask - Specifies what type of access the principal is to be      *
00312  *  given.  Can be any combination of the COM_RIGHTS_* values.               *
00313  *                                                                           *
00314  * --------------------------------------------------------------------------*
00315  * RETURNS: WIN32 Error Code                                                 *
00316 \*---------------------------------------------------------------------------*/
00317 DWORD ChangeDefaultAccessACL (
00318     LPTSTR tszPrincipal,
00319     BOOL fSetPrincipal,
00320     BOOL fPermit,
00321     DWORD dwAccessMask
00322     )
00323 {
00324
00325     DWORD dwReturnValue = ERROR_SUCCESS;
00326
00327     if (fSetPrincipal)
00328     {
00329         dwReturnValue =
00330             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00331                                              _T("Software\\Microsoft\\Ole"),
00332                                              _T("DefaultAccessPermission"),
00333                                              tszPrincipal,
00334                                              fPermit ? ACCESS_ALLOWED_ACE_TYPE :
00335                                              ACCESS_DENIED_ACE_TYPE);
00336
00337         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00338
00339         dwReturnValue =
00340             UpdatePrincipalInNamedValueSD(HKEY_LOCAL_MACHINE,
00341                                           _T("Software\\Microsoft\\Ole"),
00342                                           _T("DefaultAccessPermission"),
00343                                           tszPrincipal,
00344                                           dwAccessMask,
00345                                           TRUE,
00346                                           fPermit ? ACCESS_DENIED_ACE_TYPE :
00347                                           ACCESS_ALLOWED_ACE_TYPE);
00348
00349         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00350
00351         dwReturnValue =
00352             AddPrincipalToNamedValueSD (HKEY_LOCAL_MACHINE,
00353                                         _T("Software\\Microsoft\\Ole"),
00354                                         _T("DefaultAccessPermission"),
00355                                         tszPrincipal,
00356                                         fPermit,
00357                                         dwAccessMask,
00358                                         SDTYPE_DEFAULT_ACCESS);
00359     }
00360     else
00361     {
00362         dwReturnValue =
00363             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00364                                              _T("Software\\Microsoft\\Ole"),
00365                                              _T("DefaultAccessPermission"),
00366                                              tszPrincipal,
00367                                              ACE_TYPE_ALL);
00368     }
00369
00370     return dwReturnValue;
00371
00372 }
00373
00374 /*---------------------------------------------------------------------------*\
00375  * NAME: ChangeDefaultLaunchAndActivateACL                                   *
00376  * --------------------------------------------------------------------------*
00377  * DESCRIPTION: Modifies the default launch access control list. The         *
00378  * system uses the default launch ACL to determine if a principal is         *
00379  * allowed to launch a COM server if the COM server does not have its        *
00380  * own launch ACL in the AppID section of the registry.                      *
00381  * --------------------------------------------------------------------------*
00382  *  ARGUMENTS:                                                               *
00383  *                                                                           *
00384  *  tszPrincipal - Name of user or group (e.g. "redmond\johndoe").           *
00385  *                                                                           *
00386  *  fSetPrincipal - TRUE if you want to add/update the principal's entry     *
00387  *  in the ACL, FALSE if you want to remove the principal from the ACL.      *
00388  *                                                                           *
00389  *  fPermit - TRUE if you want to allow the principal to launch the object   *
00390  *  FALSE if you want to prevent the principal from launching the object.    *
00391  *                                                                           *
00392  *  dwAccessMask - Specifies what type of access the principal is to be      *
00393  *  given.  Can be any combination of the COM_RIGHTS_* values.               *
00394  *                                                                           *
00395  * --------------------------------------------------------------------------*
00396  * RETURNS: WIN32 Error Code                                                 *
00397 \*---------------------------------------------------------------------------*/
00398 DWORD ChangeDefaultLaunchAndActivateACL (
00399     LPTSTR tszPrincipal,
00400     BOOL fSetPrincipal,
00401     BOOL fPermit,
00402     DWORD dwAccessMask
00403     )
00404 {
00405     DWORD dwReturnValue = ERROR_SUCCESS;
00406
00407     if (fSetPrincipal)
00408     {
00409         dwReturnValue =
00410             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00411                                              _T("Software\\Microsoft\\Ole"),
00412                                              _T("DefaultLaunchPermission"),
00413                                              tszPrincipal,
00414                                              fPermit ? ACCESS_ALLOWED_ACE_TYPE :
00415                                              ACCESS_DENIED_ACE_TYPE);
00416
00417         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00418
00419         dwReturnValue =
00420             UpdatePrincipalInNamedValueSD(HKEY_LOCAL_MACHINE,
00421                                           _T("Software\\Microsoft\\Ole"),
00422                                           _T("DefaultLaunchPermission"),
00423                                           tszPrincipal,
00424                                           dwAccessMask,
00425                                           TRUE,
00426                                           fPermit ? ACCESS_DENIED_ACE_TYPE :
00427                                           ACCESS_ALLOWED_ACE_TYPE);
00428
00429         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00430
00431         dwReturnValue =
00432             AddPrincipalToNamedValueSD (HKEY_LOCAL_MACHINE,
00433                                         _T("Software\\Microsoft\\Ole"),
00434                                         _T("DefaultLaunchPermission"),
00435                                         tszPrincipal,
00436                                         fPermit,
00437                                         dwAccessMask,
00438                                         SDTYPE_DEFAULT_LAUNCH);
00439     }
00440     else
00441     {
00442         dwReturnValue =
00443             RemovePrincipalFromNamedValueSD (HKEY_LOCAL_MACHINE,
00444                                              _T("Software\\Microsoft\\Ole"),
00445                                              _T("DefaultLaunchPermission"),
00446                                              tszPrincipal,
00447                                              ACE_TYPE_ALL);
00448     }
00449
00450     return dwReturnValue;
00451
00452
00453 }
00454
00455 /*---------------------------------------------------------------------------*\
00456  * NAME: ChangeAppIDAccessACL                                                *
00457  * --------------------------------------------------------------------------*
00458  * DESCRIPTION: Modifies an AppID's access ACL. The                          *
00459  * system uses the AppID access ACL to determine if a principal is           *
00460  * allowed to access the COM server associated with the AppID.               *
00461  * --------------------------------------------------------------------------*
00462  *  ARGUEMENTS:                                                              *
00463  *                                                                           *
00464  *  tszAppID - The Application ID you wish to modify                         *
00465  *  (e.g. "{99999999-9999-9999-9999-00AA00BBF7C7}")                          *
00466  *                                                                           *
00467  *  tszPrincipal - Name of user or group (e.g. "redmond\johndoe")            *
00468  *                                                                           *
00469  *  fSetPrincipal - TRUE if you want to add/update the principal's entry     *
00470  *  in the ACL, FALSE if you want to remove the principal from the ACL       *
00471  *                                                                           *
00472  *  fPermit - TRUE if you want to allow the principal to access the object,  *
00473  *  FALSE if you want to prevent the principal from accessing the object     *
00474  *                                                                           *
00475  *  dwAccessMask - Specifies what type of access the principal is to be      *
00476  *  given.  Can be any combination of the COM_RIGHTS_* values                *
00477  *                                                                           *
00478  * --------------------------------------------------------------------------*
00479  * RETURNS: WIN32 Error Code                                                 *
00480 \*---------------------------------------------------------------------------*/
00481 DWORD ChangeAppIDAccessACL (
00482     LPTSTR tszAppID,
00483     LPTSTR tszPrincipal,
00484     BOOL fSetPrincipal,
00485     BOOL fPermit,
00486     DWORD dwAccessMask
00487     )
00488 {
00489     TCHAR   tszKeyName [256] = {0};
00490     DWORD dwReturnValue = ERROR_SUCCESS;
00491
00492     _sntprintf (tszKeyName,
00493                  (sizeof(tszKeyName)/sizeof(*tszKeyName))-1,
00494                  tszAppID [0] == '{' ? _T("APPID\\%s") : _T("APPID\\{%s}"),
00495                  tszAppID);
00496
00497     if (fSetPrincipal)
00498     {
00499         dwReturnValue =
00500             RemovePrincipalFromNamedValueSD (HKEY_CLASSES_ROOT,
00501                                              tszKeyName,
00502                                              _T("AccessPermission"),
00503                                              tszPrincipal,
00504                                              fPermit ? ACCESS_ALLOWED_ACE_TYPE :
00505                                              ACCESS_DENIED_ACE_TYPE);
00506
00507         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00508
00509         dwReturnValue =
00510             UpdatePrincipalInNamedValueSD(HKEY_CLASSES_ROOT,
00511                                           tszKeyName,
00512                                           _T("AccessPermission"),
00513                                           tszPrincipal,
00514                                           dwAccessMask,
00515                                           TRUE,
00516                                           fPermit ? ACCESS_DENIED_ACE_TYPE :
00517                                           ACCESS_ALLOWED_ACE_TYPE);
00518
00519         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00520
00521         dwReturnValue =
00522             AddPrincipalToNamedValueSD (HKEY_CLASSES_ROOT,
00523                                         tszKeyName,
00524                                         _T("AccessPermission"),
00525                                         tszPrincipal,
00526                                         fPermit,
00527                                         dwAccessMask,
00528                                         SDTYPE_APPLICATION_ACCESS);
00529     }
00530     else
00531     {
00532         dwReturnValue =
00533             RemovePrincipalFromNamedValueSD (HKEY_CLASSES_ROOT,
00534                                              tszKeyName,
00535                                              _T("AccessPermission"),
00536                                              tszPrincipal,
00537                                              ACE_TYPE_ALL);
00538     }
00539
00540     return dwReturnValue;
00541 }
00542
00543 /*---------------------------------------------------------------------------*\
00544  * NAME: ChangeAppIDLaunchAndActivateACL                                     *
00545  * --------------------------------------------------------------------------*
00546  * DESCRIPTION: Modifies an AppID's launch access control list.              *
00547  * The system uses the AppID launch ACL to determine if a principal          *
00548  * (a user or group of users) is allowed to launch the COM server            *
00549  * associated with the AppID.                                                *
00550  * --------------------------------------------------------------------------*
00551  *  ARGUMENTS:                                                               *
00552  *                                                                           *
00553  *  tszAppID - The Application ID you wish to modify                         *
00554  *  (e.g. "{99999999-9999-9999-9999-00AA00BBF7C7}")                          *
00555  *                                                                           *
00556  *  tszPrincipal - Name of user or group (e.g. "redmond\johndoe")            *
00557  *                                                                           *
00558  *  fSetPrincipal - TRUE if you want to add/update the principal's entry     *
00559  *  in the ACL, FALSE if you want to remove the principal from the ACL       *
00560  *                                                                           *
00561  *  fPermit - TRUE if you want to allow the principal to launch the object   *
00562  *  FALSE if you want to prevent the principal from launching the object     *
00563  *                                                                           *
00564  *  dwAccessMask - Specifies what type of access the principal is to be      *
00565  *  given.  Can be any combination of the COM_RIGHTS_* values                *
00566  *                                                                           *
00567  * --------------------------------------------------------------------------*
00568  * RETURNS: WIN32 Error Code                                                 *
00569 \*---------------------------------------------------------------------------*/
00570 DWORD ChangeAppIDLaunchAndActivateACL (
00571     LPTSTR tszAppID,
00572     LPTSTR tszPrincipal,
00573     BOOL fSetPrincipal,
00574     BOOL fPermit,
00575     DWORD dwAccessMask
00576     )
00577 {
00578     TCHAR   tszKeyName [256] = {0};
00579     DWORD dwReturnValue = ERROR_SUCCESS;
00580
00581     _sntprintf (tszKeyName,
00582                  (sizeof(tszKeyName)/sizeof(*tszKeyName))-1,
00583                  tszAppID [0] == '{' ? _T("APPID\\%s") : _T("APPID\\{%s}"),
00584                  tszAppID);
00585
00586     if (fSetPrincipal)
00587     {
00588         dwReturnValue =
00589             RemovePrincipalFromNamedValueSD (HKEY_CLASSES_ROOT,
00590                                              tszKeyName,
00591                                              _T("LaunchPermission"),
00592                                              tszPrincipal,
00593                                              fPermit ? ACCESS_ALLOWED_ACE_TYPE :
00594                                              ACCESS_DENIED_ACE_TYPE);
00595
00596         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00597
00598         dwReturnValue =
00599             UpdatePrincipalInNamedValueSD(HKEY_CLASSES_ROOT,
00600                                           tszKeyName,
00601                                           _T("LaunchPermission"),
00602                                           tszPrincipal,
00603                                           dwAccessMask,
00604                                           TRUE,
00605                                           fPermit ? ACCESS_DENIED_ACE_TYPE :
00606                                           ACCESS_ALLOWED_ACE_TYPE);
00607
00608         if(dwReturnValue != ERROR_SUCCESS) return dwReturnValue;
00609
00610         dwReturnValue =
00611             AddPrincipalToNamedValueSD (HKEY_CLASSES_ROOT,
00612                                         tszKeyName,
00613                                         _T("LaunchPermission"),
00614                                         tszPrincipal,
00615                                         fPermit,
00616                                         dwAccessMask,
00617                                         SDTYPE_APPLICATION_LAUNCH);
00618     }
00619     else
00620     {
00621         dwReturnValue =
00622             RemovePrincipalFromNamedValueSD (HKEY_CLASSES_ROOT,
00623                                              tszKeyName,
00624                                              _T("LaunchPermission"),
00625                                              tszPrincipal,
00626                                              ACE_TYPE_ALL);
00627     }
00628
00629     return dwReturnValue;
00630 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/dataobj.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

dataobj.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _CLASS_CDATAOBJECT_
00015 #define _CLASS_CDATAOBJECT_
00016
00017 #include "Globals.h"
00018 #include "StaticNode.h"
00019 #include "EnumFormatEtc.h"             // DRAGDROP: New interface implemented
00020
00021 //---------------------------------------------------------------------------
00022 class CDataObject : public IDataObject
00023 {
00024   private:
00025     ULONG     m_cRef;
00026     ULONG     m_uCookie;
00027     ULONG     m_uContext;
00028     ULONG     m_uNodeTypeFlg;          // DRAGDROP: New data member
00029
00030   public:
00031     CDataObject();
00032     ~CDataObject();
00033
00034   public:  // Interface IUnknown
00035     STDMETHODIMP QueryInterface( REFIID riid, LPVOID* ppv );
00036     STDMETHODIMP_(ULONG) AddRef();
00037     STDMETHODIMP_(ULONG) Release();
00038
00039   public:  // IDataObject methods
00040     STDMETHODIMP GetDataHere (FORMATETC* pFormatEtc, STGMEDIUM* pStgMedium);
00041     STDMETHODIMP GetData (FORMATETC* pFormatEtc, STGMEDIUM* pStgMedium);
00042     STDMETHODIMP QueryGetData (FORMATETC* pFormatEtc);
00043     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc);
00044
00045
00046     // The rest are not implemented
00047     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00048     { return E_NOTIMPL; };
00049
00050     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00051     { return E_NOTIMPL; };
00052
00053     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00054     { return E_NOTIMPL; };
00055
00056     STDMETHODIMP DUnadvise (DWORD dwConnection)
00057     { return E_NOTIMPL; };
00058
00059     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00060     { return E_NOTIMPL; };
00061
00062   ///////////////////////////////////////////////////////////////////////////
00063   // Custom Methods
00064   public:
00065     VOID   SetPrivateData( ULONG uCookie, ULONG uContext );
00066
00067     ULONG  GetContext() { return m_uContext; }
00068     ULONG  GetCookie()  { return m_uCookie;  }   // Returns unique indentifier
00069
00070   public:
00071     CEnumFormatEtc*    m_pEnumFormatEtc;
00072
00073
00074   ///////////////////////////////////////////////////////////////////////////
00075   // Handlers for required clipboard formats
00076   private:
00077     HRESULT  RetrieveDisplayString( IStream* ipStream );
00078     HRESULT  RetrieveSnapInClassID( IStream* ipStream );
00079     HRESULT  RetrieveNodeTypeGuid( IStream* ipStream );
00080     HRESULT  RetrieveGuidString( IStream* ipStream );
00081     HRESULT  RetrieveBaseNodePtr( IStream* ipStream );
00082     HRESULT  RetrieveDataObjPtr( IStream* ipStream );
00083
00084     // DRAGDROP: New methods to support interprocess DragDrop
00085     HRESULT  RetrieveNodePropPtr( STGMEDIUM*  pStgMedium );
00086     HRESULT  RetrieveNodeTypeFlg( STGMEDIUM*  pStgmedium );
00087
00088 };
00089
00090 #endif //_CLASS_CDATAOBJECT_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyCapabilities/MyCapabilities.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyCapabilities

MyCapabilities.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      MyCapabilities.h
00005 //
00006 //  Description:
00007 //      Declaration of the CMyCapabilities class.
00008 //
00009 //////////////////////////////////////////////////////////////////////////////
00010
00011 #pragma once
00012
00013 //
00014 // Categories and ClusCfg GUIDS
00015 //
00016 #include <ClusCfgGuids.h>
00017
00018 #include "resource.h"
00019
00020 //
00021 // Store the warning state.
00022 //
00023 #pragma warning( push )
00024
00025 //
00026 // Disable warning 4995. The text of the warning is below:
00027 // 'wsprintf': name was marked as #pragma deprecated
00028 //
00029 #pragma warning( disable : 4995 )
00030
00031 // {96FCE880-4763-4287-A64B-53BD2AA99A04}
00032 DEFINE_GUID( CLSID_MyCapabilities,
00033 0x96fce880, 0x4763, 0x4287, 0xa6, 0x4b, 0x53, 0xbd, 0x2a, 0xa9, 0x9a, 0x4);
00034
00035 // {065CC8AF-D454-4f55-9413-9C4D975105ED}
00036 DEFINE_GUID( TASKID_Minor_MyApp_Compat_Info,
00037 0x65cc8af, 0xd454, 0x4f55, 0x94, 0x13, 0x9c, 0x4d, 0x97, 0x51, 0x5, 0xed);
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 //++
00041 //
00042 // CMyCapabilities class definition
00043 //
00044 //--
00045 /////////////////////////////////////////////////////////////////////////////
00046 class CMyCapabilities
00047     : public CComObjectRootEx<CComMultiThreadModel>
00048     , public CComCoClass<CMyCapabilities, &CLSID_MyCapabilities>
00049     , public IClusCfgCapabilities
00050     , public IClusCfgInitialize
00051 {
00052 private:
00053     //
00054     // Locale id.
00055     //
00056     LCID                m_lcid;
00057
00058     //
00059     // Pointer to the callback interface.
00060     //
00061     IClusCfgCallback *  m_piccCallback;
00062
00063 protected:
00064     //
00065     // Constructor and destructor
00066     //
00067     CMyCapabilities( void );
00068     ~CMyCapabilities( void );
00069
00070     //
00071     // HrGetApplicationCompatibilityInfo contains the logic to decide whether
00072     // or not "The App" is compatible with Clustering or not.
00073     //
00074     HRESULT HrGetApplicationCompatibilityInfo( BOOL * pfIsAppCompatible );
00075
00076 public:
00077
00078     DECLARE_REGISTRY_RESOURCEID( IDR_MYCAPABILITIES )
00079     DECLARE_NOT_AGGREGATABLE( CMyCapabilities )
00080
00081     DECLARE_PROTECT_FINAL_CONSTRUCT()
00082
00083     BEGIN_COM_MAP( CMyCapabilities )
00084         COM_INTERFACE_ENTRY( IClusCfgCapabilities )
00085         COM_INTERFACE_ENTRY( IClusCfgInitialize )
00086     END_COM_MAP()
00087
00088     BEGIN_CATEGORY_MAP( CMyCapabilities )
00089         IMPLEMENTED_CATEGORY( CATID_ClusCfgCapabilities )
00090     END_CATEGORY_MAP()
00091
00092     //
00093     // IClusCfgCapabilities methods
00094     //
00095     STDMETHOD( CanNodeBeClustered )( void );
00096
00097     //
00098     // IClusCfgInitialize methods
00099     //
00100     STDMETHOD( Initialize )( IUnknown * punkCallbackIn, LCID lcidIn );
00101
00102 }; //*** class: CMyCapabilities
00103
00104 //
00105 // Restore the warning state.
00106 //
00107 #pragma warning( pop )
00108
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/guids.h Source File

  • SysMgmt
  • MMC
  • CMenu

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {B5982EC8-8971-11d2-8A09-000021473128}
00020 DEFINE_GUID(CLSID_CComponentData,
00021             0xb5982ec8, 0x8971, 0x11d2, 0x8a, 0x9, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28);
00022
00023 // {B5982ECA-8971-11d2-8A09-000021473128}
00024 DEFINE_GUID(CLSID_CSnapinAbout,
00025             0xb5982eca, 0x8971, 0x11d2, 0x8a, 0x9, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/ADOVCGEN/resource.h Source File

  • Dataaccess
  • ADO
  • ADOVCGEN

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ADVCGEN.rc
00004 //
00005 #define IDM_ABOUTBOX                    0x0010
00006 #define IDD_ABOUTBOX                    100
00007 #define IDS_ABOUTBOX                    101
00008 #define IDD_ADVCGEN_DIALOG              102
00009 #define IDR_MAINFRAME                   128
00010 #define IDC_BUTTON1                     1000
00011 #define IDC_CONNECTSTRING               1001
00012 #define IDC_TABLELIST                   1003
00013 #define IDC_DATAGRID1                   1004
00014 #define IDC_EDIT1                       1005
00015 #define IDC_BUTTON2                     1006
00016 #define IDC_CHECK1                      1010
00017 #define ID_REFRESH                      57671
00018
00019 // Next default values for new objects
00020 //
00021 #ifdef APSTUDIO_INVOKED
00022 #ifndef APSTUDIO_READONLY_SYMBOLS
00023 #define _APS_NEXT_RESOURCE_VALUE        130
00024 #define _APS_NEXT_COMMAND_VALUE         32771
00025 #define _APS_NEXT_CONTROL_VALUE         1000
00026 #define _APS_NEXT_SYMED_VALUE           101
00027 #endif
00028 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/resource.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by DragDrop.rc
00004 //
00005 #define IDB_APPIMG_32                   101
00006 #define IDB_APPIMG_16                   104
00007 #define IDI_APP_ICON                    105
00008 #define IDB_NODEIMAGES_16               106
00009 #define IDB_NODEIMAGES_32               107
00010 #define IDD_BASE_DIALOG                 108
00011 #define IDD_ADDDEVICE_DLG               109
00012 #define IDD_ADDVFILE_DLG                110
00013 #define IDC_ARCHIVE_ATTR                1000
00014 #define IDC_HIDDEN_ATTR                 1001
00015 #define IDC_LOCKED_ATTR                 1002
00016 #define IDC_READONLY_ATTR               1003
00017 #define IDC_DEVNAME_EDIT                1004
00018 #define IDC_BACKUP_FLAG                 1005
00019
00020 // Next default values for new objects
00021 //
00022 #ifdef APSTUDIO_INVOKED
00023 #ifndef APSTUDIO_READONLY_SYMBOLS
00024 #define _APS_NEXT_RESOURCE_VALUE        110
00025 #define _APS_NEXT_COMMAND_VALUE         40001
00026 #define _APS_NEXT_CONTROL_VALUE         1006
00027 #define _APS_NEXT_SYMED_VALUE           101
00028 #endif
00029 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/prsample/error.cpp Source File

  • Dataaccess
  • oledb
  • prsample

error.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 // Microsoft OLE DB Programmer's Reference Sample
00003 // Copyright (C) 1998 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module ERROR.CPP
00008 //
00009 //---------------------------------------------------------------------------
00010
00011
00012 ////////////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 ////////////////////////////////////////////////////////////////////////
00016 #include "prsample.h"   // Programmer's Reference Sample includes
00017
00018
00019 ////////////////////////////////////////////////////////////////////////
00020 // myHandleResult
00021 //
00022 //  This function is called as part of the XCHECK_HR macro; it takes a
00023 //  HRESULT, which is returned by the method called in the XCHECK_HR
00024 //  macro, and the file and line number where the method call was made.
00025 //  If the method call failed, this function attempts to get and display
00026 //  the extended error information for the call from the IErrorInfo,
00027 //  IErrorRecords, and ISQLErrorInfo interfaces.
00028 //
00029 ////////////////////////////////////////////////////////////////////////
00030 HRESULT myHandleResult
00031   (
00032   HRESULT         hrReturned,
00033   LPCWSTR         pwszFile,
00034   ULONG         ulLine
00035   )
00036 {
00037   HRESULT         hr;
00038   IErrorInfo *      pIErrorInfo         = NULL;
00039   IErrorRecords *     pIErrorRecords        = NULL;
00040   ULONG         cRecords;
00041   ULONG         iErr;
00042
00043   // If the method called as part of the XCHECK_HR macro failed,
00044   // we will attempt to get extended error information for the call
00045   if( FAILED(hrReturned) )
00046   {
00047     // Obtain the current Error object, if any, by using the
00048     // OLE Automation GetErrorInfo function, which will give
00049     // us back an IErrorInfo interface pointer if successful
00050     hr = GetErrorInfo(0, &pIErrorInfo);
00051
00052     // We've got the IErrorInfo interface pointer on the Error object
00053     if( SUCCEEDED(hr) && pIErrorInfo )
00054     {
00055       // OLE DB extends the OLE Automation error model by allowing
00056       // Error objects to support the IErrorRecords interface; this
00057       // interface can expose information on multiple errors.
00058       hr = pIErrorInfo->QueryInterface(IID_IErrorRecords,
00059             (void**)&pIErrorRecords);
00060       if( SUCCEEDED(hr) )
00061       {
00062         // Get the count of error records from the object
00063         CHECK_HR(hr = pIErrorRecords->GetRecordCount(&cRecords));
00064
00065         // Loop through the set of error records and
00066         // display the error information for each one
00067         for( iErr = 0; iErr < cRecords; iErr++ )
00068         {
00069           myDisplayErrorRecord(hrReturned, iErr, pIErrorRecords,
00070             pwszFile, ulLine);
00071         }
00072       }
00073       // The object didn't support IErrorRecords; display
00074       // the error information for this single error
00075       else
00076       {
00077         myDisplayErrorInfo(hrReturned, pIErrorInfo, pwszFile, ulLine);
00078       }
00079     }
00080     // There was no Error object, so just display the HRESULT to the user
00081     else
00082     {
00083       wprintf(L"\nNo Error Info posted; HResult: 0x%08x\n"
00084         L"File: %s, Line: %d\n", hrReturned, pwszFile, ulLine);
00085     }
00086   }
00087
00088 CLEANUP:
00089   if( pIErrorInfo )
00090     pIErrorInfo->Release();
00091   if( pIErrorRecords )
00092     pIErrorRecords->Release();
00093   return hrReturned;
00094 }
00095
00096
00097 ////////////////////////////////////////////////////////////////////////
00098 // myDisplayErrorRecord
00099 //
00100 //  This function displays the error information for a single error
00101 //  record, including information from ISQLErrorInfo, if supported
00102 //
00103 ////////////////////////////////////////////////////////////////////////
00104 HRESULT myDisplayErrorRecord
00105   (
00106   HRESULT         hrReturned,
00107   ULONG         iRecord,
00108   IErrorRecords *     pIErrorRecords,
00109   LPCWSTR         pwszFile,
00110   ULONG         ulLine
00111   )
00112 {
00113   HRESULT         hr;
00114   IErrorInfo *      pIErrorInfo         = NULL;
00115   BSTR          bstrDescription       = NULL;
00116   BSTR          bstrSource          = NULL;
00117   BSTR          bstrSQLInfo         = NULL;
00118
00119   static LCID       lcid            = GetUserDefaultLCID();
00120
00121   LONG          lNativeError        = 0;
00122   ERRORINFO       ErrorInfo;
00123
00124   // Get the IErrorInfo interface pointer for this error record
00125   CHECK_HR(hr = pIErrorRecords->GetErrorInfo(iRecord, lcid, &pIErrorInfo));
00126
00127   // Get the description of this error
00128   CHECK_HR(hr = pIErrorInfo->GetDescription(&bstrDescription));
00129
00130   // Get the source of this error
00131   CHECK_HR(hr = pIErrorInfo->GetSource(&bstrSource));
00132
00133   // Get the basic error information for this record
00134   CHECK_HR(hr = pIErrorRecords->GetBasicErrorInfo(iRecord, &ErrorInfo));
00135
00136   // If the error object supports ISQLErrorInfo, get this information
00137   myGetSqlErrorInfo(iRecord, pIErrorRecords, &bstrSQLInfo, &lNativeError);
00138
00139   // Display the error information to the user
00140   if( bstrSQLInfo )
00141   {
00142     wprintf(L"\nErrorRecord:  HResult: 0x%08x\nDescription: %s\n"
00143       L"SQLErrorInfo: %s\nSource: %s\nFile: %s, Line: %d\n",
00144       ErrorInfo.hrError,
00145       bstrDescription,
00146       bstrSQLInfo,
00147       bstrSource,
00148       pwszFile,
00149       ulLine);
00150   }
00151   else
00152   {
00153     wprintf(L"\nErrorRecord:  HResult: 0x%08x\nDescription: %s\n"
00154       L"Source: %s\nFile: %s, Line: %d\n",
00155       ErrorInfo.hrError,
00156       bstrDescription,
00157       bstrSource,
00158       pwszFile,
00159       ulLine);
00160   }
00161
00162 CLEANUP:
00163   if( pIErrorInfo )
00164     pIErrorInfo->Release();
00165   SysFreeString(bstrDescription);
00166   SysFreeString(bstrSource);
00167   SysFreeString(bstrSQLInfo);
00168   return hr;
00169 }
00170
00171
00172 ////////////////////////////////////////////////////////////////////////
00173 // myDisplayErrorInfo
00174 //
00175 //  This function displays basic error information for an error object
00176 //  that doesn't support the IErrorRecords interface
00177 //
00178 ////////////////////////////////////////////////////////////////////////
00179 HRESULT myDisplayErrorInfo
00180   (
00181   HRESULT         hrReturned,
00182   IErrorInfo *      pIErrorInfo,
00183   LPCWSTR         pwszFile,
00184   ULONG         ulLine
00185   )
00186 {
00187   HRESULT         hr;
00188   BSTR          bstrDescription       = NULL;
00189   BSTR          bstrSource          = NULL;
00190
00191   // Get the description of the error
00192   CHECK_HR(hr = pIErrorInfo->GetDescription(&bstrDescription));
00193
00194   // Get the source of the error -- this will be the window title
00195   CHECK_HR(hr = pIErrorInfo->GetSource(&bstrSource));
00196
00197   // Display this error information
00198   wprintf(L"\nErrorInfo:  HResult: 0x%08x, Description: %s\nSource: %s\n"
00199         L"File: %s, Line: %d\n",
00200         hrReturned,
00201         bstrDescription,
00202         bstrSource,
00203         pwszFile,
00204         ulLine);
00205
00206 CLEANUP:
00207   SysFreeString(bstrDescription);
00208   SysFreeString(bstrSource);
00209   return hr;
00210 }
00211
00212
00213 ////////////////////////////////////////////////////////////////////////
00214 // myGetSqlErrorInfo
00215 //
00216 //  If the error object supports ISQLErrorInfo, get the SQL error
00217 //  string and native error code for this error
00218 //
00219 ////////////////////////////////////////////////////////////////////////
00220 HRESULT myGetSqlErrorInfo
00221   (
00222   ULONG         iRecord,
00223   IErrorRecords *     pIErrorRecords,
00224   BSTR *          pBstr,
00225   LONG *          plNativeError
00226   )
00227 {
00228   HRESULT         hr;
00229   ISQLErrorInfo *     pISQLErrorInfo        = NULL;
00230   LONG          lNativeError        = 0;
00231
00232   // Attempt to get the ISQLErrorInfo interface for this error
00233   // record through GetCustomErrorObject. Note that ISQLErrorInfo
00234   // is not mandatory, so failure is acceptable here
00235   CHECK_HR(hr = pIErrorRecords->GetCustomErrorObject(
00236         iRecord,            //iRecord
00237         IID_ISQLErrorInfo,        //riid
00238         (IUnknown**)&pISQLErrorInfo   //ppISQLErrorInfo
00239         ));
00240
00241   // If we obtained the ISQLErrorInfo interface, get the SQL
00242   // error string and native error code for this error
00243   if( pISQLErrorInfo )
00244     hr = pISQLErrorInfo->GetSQLInfo(pBstr, &lNativeError);
00245
00246 CLEANUP:
00247   if( plNativeError )
00248     *plNativeError = lNativeError;
00249   if( pISQLErrorInfo )
00250     pISQLErrorInfo->Release();
00251   return hr;
00252 }
00253
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PROPIDLIST Member List

This is the complete list of members for _PROPIDLIST, including all inherited members.
byteOffset | _PROPIDLIST
propertyID | _PROPIDLIST
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Sample::SignVerify Member List

This is the complete list of members for Sample::SignVerify, including all inherited members.
GetSignatureKey(out RSACryptoServiceProvider rsa, out X509Certificate x509Cert) | Sample::SignVerify | [inline, private, static]
GetX509Certificate(ICertificate2 cert) | Sample::SignVerify | [inline, private, static]
SignXML(string strXML) | Sample::SignVerify | [inline, static]
SignXMLX509Data(string strXML) | Sample::SignVerify | [inline, static]
VerifyXML(string strXML) | Sample::SignVerify | [inline, static]
Generated on Wed Nov 13 2024 16:58:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/Init.c Source File

  • NetDS
  • WinSock
  • IpxChat

Init.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   init.c
00009 //
00010 //  PURPOSE:   Performs application and instance specific initialization.
00011 //
00012 //  FUNCTIONS:
00013 //    InitApplication() - Initializes window data and registers window.
00014 //
00015 //  COMMENTS:
00016 //
00017 #include "globals.h"            // prototypes specific to this application
00018 #include <windows.h>            // required for all Windows applications
00019
00020
00021
00022 HINSTANCE hInst = NULL;                // current instance
00023
00024 char szAppName[9] = {'\0'};              // The name of this application
00025 char szTitle[40] = {'\0'};               // The title bar text
00026
00027 char szConnectNetwork[] = "00000000";
00028 char szConnectNode[] = "000000000000";
00029 char szConnectSocket[] = "2FFF";
00030 char szListenSocket[] = "2FFF";
00031
00032 BOOL i_should_sleep = TRUE;
00033
00034 //
00035 //  FUNCTION: InitApplication(HINSTANCE, int)
00036 //
00037 //  PURPOSE: Initializes window data and registers window class.
00038 //
00039 //  PARAMETERS:
00040 //    hInstance - The handle to the instance of this application that
00041 //                is currently being executed.
00042 //    nCmdShow  - Specifies how the main window is to be displayed.
00043 //
00044 //  RETURN VALUE:
00045 //    TRUE  - Success
00046 //    FALSE - Initialization failed
00047 //
00048 //  COMMENTS:
00049 //
00050 //    This function is called at application initialization time.  It
00051 //    performs initialization tasks for the current application instance.
00052 //    Unlike Win16, in Win32, each instance of an application must register
00053 //    window classes.
00054 //
00055 //    In this function, we initialize a window class by filling out a data
00056 //    structure of type WNDCLASS and calling the Windows RegisterClass()
00057 //    function.  Then we create the main window and show it.
00058 //
00059 //
00060
00061 BOOL InitApplication(HINSTANCE hInstance, int nCmdShow)
00062 {
00063     WNDCLASS  wc = {0};
00064     HWND      hwnd = NULL; // Main window handle.
00065
00066     // Load the application name and description strings.
00067
00068     LoadString(hInstance, IDS_APPNAME, szAppName, sizeof(szAppName));
00069     LoadString(hInstance, IDS_DESCRIPTION, szTitle, sizeof(szTitle));
00070
00071     // Save the instance handle in static variable, which will be used in
00072     // many subsequence calls from this application to Windows.
00073
00074     hInst = hInstance; // Store instance handle in our global variable
00075
00076     // Fill in window class structure with parameters that describe the
00077     // main window.
00078
00079     wc.style         = CS_HREDRAW | CS_VREDRAW; // Class style(s).
00080     wc.lpfnWndProc   = (WNDPROC)WndProc;        // Window Procedure
00081     wc.cbClsExtra    = 0;                       // No per-class extra data.
00082     wc.cbWndExtra    = 0;                       // No per-window extra data.
00083     wc.hInstance     = hInstance;               // Owner of this class
00084     wc.hIcon         = LoadIcon (hInstance, szAppName); // Icon name from .RC
00085     wc.hCursor       = LoadCursor(NULL, IDC_ARROW); // Cursor
00086     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // Default color
00087     wc.lpszMenuName  = szAppName;               // Menu name from .RC
00088     wc.lpszClassName = szAppName;               // Name to register as
00089
00090     // Register the window class and return FALSE if unsuccesful.
00091
00092     if (!RegisterClass(&wc))
00093     {
00094         return FALSE;
00095     }
00096
00097     // Create a main window for this application instance.
00098     hwnd = CreateWindow(szAppName,           // See RegisterClass() call
00099                         szTitle,             // Text for window title bar
00100                         WS_OVERLAPPEDWINDOW, // Window style
00101                         CW_USEDEFAULT, 0,    // Use default positioning
00102                         CW_USEDEFAULT, 0,    // Use default size
00103                         NULL,                // Overlapped has no parent
00104                         NULL,                // Use the window class menu
00105                         hInstance,           // This instance owns this window
00106                         NULL                 // Don't need data in WM_CREATE
00107     );
00108
00109     // If window could not be created, return "failure"
00110     if (!hwnd)
00111         return FALSE;
00112
00113     // Make the window visible; update its client area; and return "success"
00114     ShowWindow(hwnd, nCmdShow);  // Show the window
00115     UpdateWindow(hwnd);          // Sends WM_PAINT message
00116
00117     return TRUE;                 // We succeeded...
00118 }
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DllServe/DllServe.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DllServe

DllServe.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DLLSERVE.CPP
00003
00004   Summary:   Implementation file for a DLL COM Component server providing
00005              several Car-related COM Components: Car, UtilityCar,
00006              and CruiseCar.  Access to Class Factories is provided in
00007              this module for each.  This server also supports self
00008              registration and unregistration.  A special Utility COM
00009              Component is also provided: CarSample.  Exposing an ISample
00010              interface it supports utility operations on the DLL server
00011              itself (eg, the server can be given a pointer to the Client's
00012              trace Logging facility and can be told to show the server's
00013              Aboutbox dialog).
00014
00015              For a comprehensive tutorial code tour of DLLSERVE's
00016              contents and offerings see the tutorial DLLSERVE.HTM file.
00017              For more specific technical details on the internal workings
00018              see the comments dispersed throughout the DLLSERVE source code.
00019
00020   Classes:   none.
00021
00022   Functions: DllMain, DllGetClassObject, DllCanUnloadNow, DllRegisterServer,
00023              DllUnregisterServer.
00024
00025   Origin:    9-11-95: atrent - Editor-inheritance from COMOBJ.CPP in
00026                the COMOBJ Tutorial Code Sample.
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 /*---------------------------------------------------------------------------
00044   We include WINDOWS.H for all Win32 applications.
00045   We include OLE2.H because we will be calling the COM/OLE Libraries.
00046   We include INITGUID.H only once (here) in the entire DLL because we
00047     will be defining GUIDs and want them as constants in the data segment.
00048   We include APPUTIL.H because we will be building this DLL using
00049     the convenient Virtual Window and Dialog classes and other
00050     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00051   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00052     class, GUID, and CLSID specifications.
00053   We include DLLSERVE.H because it has the main declerations of all the
00054     car related interfaces and their GUIDs.  It also has the _DLLEXPORT_
00055     controlled import and export specifications.
00056   We include SERVER.H because it has the necessary internal class and
00057     resource definitions for this DLL.
00058   We include FACTORY.H because it has the necessary internal class factory
00059     declarations for this DLL component server.
00060 ---------------------------------------------------------------------------*/
00061 #include <windows.h>
00062 #include <ole2.h>
00063 #include <initguid.h>
00064 #include <apputil.h>
00065 #include <icars.h>
00066 #include <carguids.h>
00067 #define _DLLEXPORT_
00068 #include "dllserve.h"
00069 #include "server.h"
00070 #include "factory.h"
00071
00072
00073 // Global variable definitions. Some Initialized in DllMain() below.
00074
00075 // We encapsulate the control of this COM server (eg, lock and object
00076 // counting) in a server control C++ object.  Here is it's pointer.
00077 CServer* g_pServer = NULL;
00078
00079 // Here is a pointer for use by the global Trace Message logging macros.
00080 // Set by the ISample::Init function call from an outside EXE client.
00081 CMsgLog* g_pMsgLog = NULL;
00082
00083
00084 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00085   Function: UnicodeOk
00086
00087   Summary:  Checks if the platform will handle unicode versions of
00088             Win32 string API calls.
00089
00090   Args:     void
00091
00092   Returns:  BOOL
00093               TRUE if unicode support; FALSE if not.
00094 ------------------------------------------------------------------------F-F*/
00095 BOOL UnicodeOk(void)
00096 {
00097   BOOL bOk = TRUE;
00098   TCHAR szUserName[MAX_STRING_LENGTH];
00099   DWORD dwSize = MAX_STRING_LENGTH;
00100
00101   if (!GetUserName(szUserName, &dwSize))
00102     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00103
00104   return bOk;
00105 }
00106
00107
00108 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00109   Function: DllMain
00110
00111   Summary:  Like WinMain is for an EXE application, this DllMain function
00112             is the main entry point for this DLL.  It is called when the
00113             DLL is loaded by a process, and when new threads are created
00114             by a process that has already loaded this DLL.  DllMain is also
00115             called when threads of a process that has loaded the DLL exit
00116             cleanly and when the process itself unloads the DLL.
00117
00118             If you want to use C runtime libraries, keep this function
00119             named "DllMain" and you won't have to do anything special to
00120             initialize the runtime libraries.
00121
00122             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
00123             to determine if the DLL should remain loaded, or should be
00124             immediately unloaded depending upon whether the DLL could be
00125             initialized properly.  For all other values of fdwReason,
00126             the return value is ignored.
00127
00128   Args:     HINSTANCE hDLLInst,
00129               Instance handle of the DLL.
00130             DWORD fdwReason,
00131               Process attach/detach or thread attach/detach.
00132               Reason for calling.
00133             LPVOID lpvReserved)
00134               Reserved and not used.
00135
00136   Returns:  BOOL,
00137               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
00138               TRUE  -  Used to signify that the DLL should remain loaded.
00139               FALSE -  Used to signify that the DLL should be
00140                 immediately unloaded.
00141 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00142 BOOL WINAPI DllMain(
00143               HINSTANCE hDllInst,
00144               DWORD fdwReason,
00145               LPVOID lpvReserved)
00146 {
00147   BOOL bResult = TRUE;
00148
00149   // Dispatch this main call based on the reason it was called.
00150   switch (fdwReason)
00151   {
00152     case DLL_PROCESS_ATTACH:
00153       // The DLL is being loaded for the first time by a given process.
00154       // Perform per-process initialization here.  If the initialization
00155       // is successful, return TRUE; if unsuccessful, return FALSE.
00156       bResult = FALSE;
00157       if (UnicodeOk())
00158       {
00159         // Instantiate the CServer utility class.
00160         g_pServer = new CServer;
00161         if (NULL != g_pServer)
00162         {
00163           // Remember the DLL Instance handle.
00164           g_pServer->m_hDllInst = hDllInst;
00165
00166           // Create a MsgBox object.
00167           g_pServer->m_pMsgBox = new CMsgBox;
00168           if (NULL != g_pServer->m_pMsgBox)
00169             bResult = TRUE;
00170         }
00171       }
00172       break;
00173
00174     case DLL_PROCESS_DETACH:
00175       // The DLL is being unloaded by a given process.  Do any
00176       // per-process clean up here, such as undoing what was done in
00177       // DLL_PROCESS_ATTACH.  The return value is ignored.
00178       DELETE_POINTER(g_pServer->m_pMsgBox);
00179       DELETE_POINTER(g_pServer);
00180       break;
00181
00182     case DLL_THREAD_ATTACH:
00183       // A thread is being created in a process that has already loaded
00184       // this DLL.  Perform any per-thread initialization here.  The
00185       // return value is ignored.
00186       break;
00187
00188     case DLL_THREAD_DETACH:
00189       // A thread is exiting cleanly in a process that has already
00190       // loaded this DLL.  Perform any per-thread clean up here.  The
00191       // return value is ignored.
00192       break;
00193
00194     default:
00195       break;
00196   }
00197
00198   return (bResult);
00199 }
00200
00201
00202 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00203   Function: DllGetClassObject
00204
00205   Summary:  The standard exported function that the COM service library
00206             uses to obtain an object class of the class factory for a
00207             specified component provided by this server DLL.
00208
00209   Args:     REFCLSID rclsid,
00210               [in] The CLSID of the requested Component.
00211             REFIID riid,
00212               [in] GUID of the requested interface on the Class Factory.
00213             PPVOID ppv)
00214               [out] Address of the caller's pointer variable that will
00215               receive the requested interface pointer.
00216
00217   Returns:  HRESULT
00218               E_FAIL if requested component isn't supported.
00219               E_OUTOFMEMORY if out of memory.
00220               Error code out of the QueryInterface.
00221 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00222 STDAPI DllGetClassObject(
00223          REFCLSID rclsid,
00224          REFIID riid,
00225          PPVOID ppv)
00226 {
00227   HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
00228   IUnknown* pCob = NULL;
00229
00230   if (CLSID_DllCar == rclsid)
00231   {
00232     LOG("S: DllGetClassObject: Requesting CFCar.");
00233     hr = E_OUTOFMEMORY;
00234     pCob = new CFCar(NULL, g_pServer);
00235   }
00236   else if (CLSID_DllUtilityCar == rclsid)
00237   {
00238     LOG("S: DllGetClassObject: Requesting CFUtilityCar.");
00239     hr = E_OUTOFMEMORY;
00240     pCob = new CFUtilityCar(NULL, g_pServer);
00241   }
00242   else if (CLSID_DllCruiseCar == rclsid)
00243   {
00244     LOG("S: DllGetClassObject: Requesting CFCruiseCar.");
00245     hr = E_OUTOFMEMORY;
00246     pCob = new CFCruiseCar(NULL, g_pServer);
00247   }
00248   else if (CLSID_DllCarSample == rclsid)
00249   {
00250     LOG("S: DllGetClassObject: Requesting CFCarSample.");
00251     hr = E_OUTOFMEMORY;
00252     pCob = new CFCarSample(NULL, g_pServer);
00253   }
00254
00255   if (NULL != pCob)
00256   {
00257     g_pServer->ObjectsUp();
00258     hr = pCob->QueryInterface(riid, ppv);
00259     if (FAILED(hr))
00260     {
00261       g_pServer->ObjectsDown();
00262       DELETE_POINTER(pCob);
00263     }
00264   }
00265
00266   return hr;
00267 }
00268
00269
00270 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00271   Function: DllCanUnloadNow
00272
00273   Summary:  The standard exported function that the COM service library
00274             uses to determine if this server DLL can be unloaded.
00275
00276   Args:     void.
00277
00278   Returns:  HRESULT
00279               S_OK if this DLL server can be unloaded.
00280               S_FALSE if this DLL can not be unloaded.
00281 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00282 STDAPI DllCanUnloadNow(void)
00283 {
00284   HRESULT hr;
00285
00286   LOGF2("S: DllCanUnloadNow. cObjects=%i, cLocks=%i.", g_pServer->m_cObjects, g_pServer->m_cLocks);
00287
00288   // We return S_OK of there are no longer any living objects AND
00289   // there are no outstanding client locks on this server.
00290   hr = (0L==g_pServer->m_cObjects && 0L==g_pServer->m_cLocks) ? S_OK : S_FALSE;
00291
00292   return hr;
00293 }
00294
00295
00296 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00297   Function: DllRegisterServer
00298
00299   Summary:  The standard exported function that can be called to command
00300             this DLL server to register itself in the system registry.
00301
00302   Args:     void.
00303
00304   Returns:  HRESULT
00305               NOERROR
00306 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00307 STDAPI DllRegisterServer(void)
00308 {
00309   HRESULT  hr = NOERROR;
00310   TCHAR    szID[GUID_SIZE+1];
00311   TCHAR    szCLSID[GUID_SIZE+32];
00312   TCHAR    szModulePath[MAX_PATH];
00313
00314   // Obtain the path to this module's executable file for later use.
00315   GetModuleFileName(
00316     g_pServer->m_hDllInst,
00317     szModulePath,
00318     sizeof(szModulePath)/sizeof(TCHAR));
00319
00320   /*-------------------------------------------------------------------------
00321     Create registry entries for the DllCar Component.
00322   -------------------------------------------------------------------------*/
00323   // Create some base key strings.
00324   StringFromGUID2(CLSID_DllCar, szID, GUID_SIZE);
00325   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00326   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00327
00328   // Create ProgID keys.
00329   SetRegKeyValue(
00330     TEXT("CTS.DllCar.1"),
00331     NULL,
00332     TEXT("DllCar Component - DLLSERVE Code Sample"));
00333   SetRegKeyValue(
00334     TEXT("CTS.DllCar.1"),
00335     TEXT("CLSID"),
00336     szID);
00337
00338   // Create VersionIndependentProgID keys.
00339   SetRegKeyValue(
00340     TEXT("CTS.DllCar"),
00341     NULL,
00342     TEXT("DllCar Component - DLLSERVE Code Sample"));
00343   SetRegKeyValue(
00344     TEXT("CTS.DllCar"),
00345     TEXT("CurVer"),
00346     TEXT("CTS.DllCar.1"));
00347   SetRegKeyValue(
00348     TEXT("CTS.DllCar"),
00349     TEXT("CLSID"),
00350     szID);
00351
00352   // Create entries under CLSID.
00353   SetRegKeyValue(
00354     szCLSID,
00355     NULL,
00356     TEXT("DllCar Component - DLLSERVE Code Sample"));
00357   SetRegKeyValue(
00358     szCLSID,
00359     TEXT("ProgID"),
00360     TEXT("CTS.DllCar.1"));
00361   SetRegKeyValue(
00362     szCLSID,
00363     TEXT("VersionIndependentProgID"),
00364     TEXT("CTS.DllCar"));
00365   SetRegKeyValue(
00366     szCLSID,
00367     TEXT("NotInsertable"),
00368     NULL);
00369   SetRegKeyValue(
00370     szCLSID,
00371     TEXT("InprocServer32"),
00372     szModulePath);
00373
00374   /*-------------------------------------------------------------------------
00375     Create registry entries for the DllUtilityCar Component.
00376   -------------------------------------------------------------------------*/
00377   // Create some base key strings.
00378   StringFromGUID2(CLSID_DllUtilityCar, szID, GUID_SIZE);
00379   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00380   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00381
00382   // Create ProgID keys.
00383   SetRegKeyValue(
00384     TEXT("CTS.DllUtilityCar.1"),
00385     NULL,
00386     TEXT("DllUtilityCar Component - DLLSERVE Code Sample"));
00387   SetRegKeyValue(
00388     TEXT("CTS.DllUtilityCar.1"),
00389     TEXT("CLSID"),
00390     szID);
00391
00392   // Create VersionIndependentProgID keys.
00393   SetRegKeyValue(
00394     TEXT("CTS.DllUtilityCar"),
00395     NULL,
00396     TEXT("DllUtilityCar Component - DLLSERVE Code Sample"));
00397   SetRegKeyValue(
00398     TEXT("CTS.DllUtilityCar"),
00399     TEXT("CurVer"),
00400     TEXT("CTS.DllUtilityCar.1"));
00401   SetRegKeyValue(
00402     TEXT("CTS.DllUtilityCar"),
00403     TEXT("CLSID"),
00404     szID);
00405
00406   // Create entries under CLSID.
00407   SetRegKeyValue(
00408     szCLSID,
00409     NULL,
00410     TEXT("DllUtilityCar Component - DLLSERVE Code Sample"));
00411   SetRegKeyValue(
00412     szCLSID,
00413     TEXT("ProgID"),
00414     TEXT("CTS.DllUtilityCar.1"));
00415   SetRegKeyValue(
00416     szCLSID,
00417     TEXT("VersionIndependentProgID"),
00418     TEXT("CTS.DllUtilityCar"));
00419   SetRegKeyValue(
00420     szCLSID,
00421     TEXT("NotInsertable"),
00422     NULL);
00423   SetRegKeyValue(
00424     szCLSID,
00425     TEXT("InprocServer32"),
00426     szModulePath);
00427
00428   /*-------------------------------------------------------------------------
00429     Create registry entries for the DllCruiseCar Component.
00430   -------------------------------------------------------------------------*/
00431   // Create some base key strings.
00432   StringFromGUID2(CLSID_DllCruiseCar, szID, GUID_SIZE);
00433   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00434   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00435
00436   // Create ProgID keys.
00437   SetRegKeyValue(
00438     TEXT("CTS.DllCruiseCar.1"),
00439     NULL,
00440     TEXT("DllCruiseCar Component - DLLSERVE Code Sample"));
00441   SetRegKeyValue(
00442     TEXT("CTS.DllCruiseCar.1"),
00443     TEXT("CLSID"),
00444     szID);
00445
00446   // Create VersionIndependentProgID keys.
00447   SetRegKeyValue(
00448     TEXT("CTS.DllCruiseCar"),
00449     NULL,
00450     TEXT("DllCruiseCar Component - DLLSERVE Code Sample"));
00451   SetRegKeyValue(
00452     TEXT("CTS.DllCruiseCar"),
00453     TEXT("CurVer"),
00454     TEXT("CTS.DllCruiseCar.1"));
00455   SetRegKeyValue(
00456     TEXT("CTS.DllCruiseCar"),
00457     TEXT("CLSID"),
00458     szID);
00459
00460   // Create entries under CLSID.
00461   SetRegKeyValue(
00462     szCLSID,
00463     NULL,
00464     TEXT("DllCruiseCar Component - DLLSERVE Code Sample"));
00465   SetRegKeyValue(
00466     szCLSID,
00467     TEXT("ProgID"),
00468     TEXT("CTS.DllCruiseCar.1"));
00469   SetRegKeyValue(
00470     szCLSID,
00471     TEXT("VersionIndependentProgID"),
00472     TEXT("CTS.DllCruiseCar"));
00473   SetRegKeyValue(
00474     szCLSID,
00475     TEXT("NotInsertable"),
00476     NULL);
00477   SetRegKeyValue(
00478     szCLSID,
00479     TEXT("InprocServer32"),
00480     szModulePath);
00481
00482   /*-------------------------------------------------------------------------
00483     Create registry entries for the DllCarSample Component.
00484   -------------------------------------------------------------------------*/
00485   // Create some base key strings.
00486   StringFromGUID2(CLSID_DllCarSample, szID, GUID_SIZE);
00487   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00488   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00489
00490   // Create ProgID keys.
00491   SetRegKeyValue(
00492     TEXT("CTS.DllCarSample.1"),
00493     NULL,
00494     TEXT("DllCarSample Component - DLLSERVE Code Sample"));
00495   SetRegKeyValue(
00496     TEXT("CTS.DllCarSample.1"),
00497     TEXT("CLSID"),
00498     szID);
00499
00500   // Create VersionIndependentProgID keys.
00501   SetRegKeyValue(
00502     TEXT("CTS.DllCarSample"),
00503     NULL,
00504     TEXT("DllCarSample Component - DLLSERVE Code Sample"));
00505   SetRegKeyValue(
00506     TEXT("CTS.DllCarSample"),
00507     TEXT("CurVer"),
00508     TEXT("CTS.DllCarSample.1"));
00509   SetRegKeyValue(
00510     TEXT("CTS.DllCarSample"),
00511     TEXT("CLSID"),
00512     szID);
00513
00514   // Create entries under CLSID.
00515   SetRegKeyValue(
00516     szCLSID,
00517     NULL,
00518     TEXT("DllCarSample Component - DLLSERVE Code Sample"));
00519   SetRegKeyValue(
00520     szCLSID,
00521     TEXT("ProgID"),
00522     TEXT("CTS.DllCarSample.1"));
00523   SetRegKeyValue(
00524     szCLSID,
00525     TEXT("VersionIndependentProgID"),
00526     TEXT("CTS.DllCarSample"));
00527   SetRegKeyValue(
00528     szCLSID,
00529     TEXT("NotInsertable"),
00530     NULL);
00531   SetRegKeyValue(
00532     szCLSID,
00533     TEXT("InprocServer32"),
00534     szModulePath);
00535
00536   return hr;
00537 }
00538
00539
00540 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00541   Function: DllUnregisterServer
00542
00543   Summary:  The standard exported function that can be called to command
00544             this DLL server to unregister itself from the system Registry.
00545
00546   Args:     void.
00547
00548   Returns:  HRESULT
00549               NOERROR
00550 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00551 STDAPI DllUnregisterServer(void)
00552 {
00553   HRESULT  hr = NOERROR;
00554   TCHAR    szID[GUID_SIZE+1];
00555   TCHAR    szCLSID[GUID_SIZE+32];
00556   TCHAR    szTemp[MAX_PATH+GUID_SIZE];
00557
00558   /*-------------------------------------------------------------------------
00559     Delete registry entries for the DllCar Component.
00560   -------------------------------------------------------------------------*/
00561   //Create some base key strings.
00562   StringFromGUID2(CLSID_DllCar, szID, GUID_SIZE);
00563   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00564   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00565
00566   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCar\\CurVer"));
00567   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCar\\CLSID"));
00568   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCar"));
00569
00570   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCar.1\\CLSID"));
00571   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCar.1"));
00572
00573   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00574   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00575
00576   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00577   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00578
00579   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00580   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00581
00582   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00583   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00584
00585   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00586
00587   /*-------------------------------------------------------------------------
00588     Delete registry entries for the DllUtilityCar Component.
00589   -------------------------------------------------------------------------*/
00590   //Create some base key strings.
00591   StringFromGUID2(CLSID_DllUtilityCar, szID, GUID_SIZE);
00592   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00593   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00594
00595   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllUtilityCar\\CurVer"));
00596   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllUtilityCar\\CLSID"));
00597   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllUtilityCar"));
00598
00599   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllUtilityCar.1\\CLSID"));
00600   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllUtilityCar.1"));
00601
00602   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00603   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00604
00605   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00606   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00607
00608   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00609   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00610
00611   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00612   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00613
00614   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00615
00616   /*-------------------------------------------------------------------------
00617     Delete registry entries for the DllCruiseCar Component.
00618   -------------------------------------------------------------------------*/
00619   //Create some base key strings.
00620   StringFromGUID2(CLSID_DllCruiseCar, szID, GUID_SIZE);
00621   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00622   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00623
00624   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCruiseCar\\CurVer"));
00625   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCruiseCar\\CLSID"));
00626   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCruiseCar"));
00627
00628   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCruiseCar.1\\CLSID"));
00629   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCruiseCar.1"));
00630
00631   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00632   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00633
00634   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00635   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00636
00637   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00638   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00639
00640   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00641   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00642
00643   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00644
00645   /*-------------------------------------------------------------------------
00646     Delete registry entries for the DllCarSample Component.
00647   -------------------------------------------------------------------------*/
00648   //Create some base key strings.
00649   StringFromGUID2(CLSID_DllCarSample, szID, GUID_SIZE);
00650   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00651   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00652
00653   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCarSample\\CurVer"));
00654   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCarSample\\CLSID"));
00655   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCarSample"));
00656
00657   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCarSample.1\\CLSID"));
00658   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllCarSample.1"));
00659
00660   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00661   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00662
00663   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00664   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00665
00666   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00667   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00668
00669   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00670   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00671
00672   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00673
00674   return hr;
00675 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userwizard/userwizard.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userwizard

userwizard.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       userwizard.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011
00012 // GUID's for Cclasses
00013
00014 extern const GUID CLSID_WizExtUser;
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/about.Cpp Source File

  • SysMgmt
  • MMC
  • Openserv

about.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "About.h"
00020 #include "resource.h"
00021 #include "globals.h"
00022 #include <crtdbg.h>
00023
00024 CSnapinAbout::CSnapinAbout()
00025 : m_cref(0)
00026 {
00027     OBJECT_CREATED
00028
00029         m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00030     m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00031
00032     m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00033
00034     m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
00035 }
00036
00037 CSnapinAbout::~CSnapinAbout()
00038 {
00039     if (m_hSmallImage != NULL)
00040         FreeResource(m_hSmallImage);
00041
00042     if (m_hLargeImage != NULL)
00043         FreeResource(m_hLargeImage);
00044
00045     if (m_hSmallImageOpen != NULL)
00046         FreeResource(m_hSmallImageOpen);
00047
00048     if (m_hAppIcon != NULL)
00049         FreeResource(m_hAppIcon);
00050
00051     m_hSmallImage = NULL;
00052     m_hLargeImage = NULL;
00053     m_hSmallImageOpen = NULL;
00054     m_hAppIcon = NULL;
00055
00056     OBJECT_DESTROYED
00057 }
00058
00059 ///////////////////////
00060 // IUnknown implementation
00061 ///////////////////////
00062
00063 STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
00064 {
00065     if (!ppv)
00066         return E_FAIL;
00067
00068     *ppv = NULL;
00069
00070     if (IsEqualIID(riid, IID_IUnknown))
00071         *ppv = static_cast<ISnapinAbout *>(this);
00072     else if (IsEqualIID(riid, IID_ISnapinAbout))
00073         *ppv = static_cast<ISnapinAbout *>(this);
00074
00075     if (*ppv)
00076     {
00077         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00078         return S_OK;
00079     }
00080
00081     return E_NOINTERFACE;
00082 }
00083
00084 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00085 {
00086     return InterlockedIncrement((LONG *)&m_cref);
00087 }
00088
00089 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00090 {
00091     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00092     {
00093         // we need to decrement our object count in the DLL
00094         delete this;
00095         return 0;
00096     }
00097     return m_cref;
00098
00099 }
00100
00101 ///////////////////////////////
00102 // Interface ISnapinAbout
00103 ///////////////////////////////
00104 STDMETHODIMP CSnapinAbout::GetSnapinDescription(
00105                                                 /* [out] */ LPOLESTR *lpDescription)
00106 {
00107     _TCHAR szDesc[MAX_PATH];
00108
00109     LoadString(g_hinst, IDS_SNAPINDESC, szDesc, (sizeof szDesc)/(sizeof szDesc[0]));
00110
00111     return AllocOleStr(lpDescription, szDesc);
00112 }
00113
00114
00115 STDMETHODIMP CSnapinAbout::GetProvider(
00116                                        /* [out] */ LPOLESTR *lpName)
00117 {
00118     return AllocOleStr(lpName, _T("Copyright © 1999 - 2001 Microsoft Corporation"));;
00119 }
00120
00121
00122 STDMETHODIMP CSnapinAbout::GetSnapinVersion(
00123                                             /* [out] */ LPOLESTR *lpVersion)
00124 {
00125     return AllocOleStr(lpVersion, _T("1.0"));;
00126 }
00127
00128
00129 STDMETHODIMP CSnapinAbout::GetSnapinImage(
00130                                           /* [out] */ HICON *hAppIcon)
00131 {
00132     *hAppIcon = m_hAppIcon;
00133
00134     if (*hAppIcon == NULL)
00135         return E_FAIL;
00136     else
00137         return S_OK;
00138 }
00139
00140
00141 STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
00142                                                 /* [out] */ HBITMAP *hSmallImage,
00143                                                 /* [out] */ HBITMAP *hSmallImageOpen,
00144                                                 /* [out] */ HBITMAP *hLargeImage,
00145                                                 /* [out] */ COLORREF *cMask)
00146 {
00147     *hSmallImage = m_hSmallImage;
00148     *hLargeImage = m_hLargeImage;
00149
00150     *hSmallImageOpen = m_hSmallImageOpen;
00151
00152     *cMask = RGB(0, 128, 128);
00153
00154     if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
00155         return E_FAIL;
00156     else
00157         return S_OK;
00158 }
00159
00160 // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
00161 HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
00162 {
00163         MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
00164         *lpDest = wszStr;
00165
00166
00167     return S_OK;
00168 }
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/tracemacro.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

tracemacro.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  TraceMacro.h : Defines custom tracing helpers.
00014 //
00015
00016
00017 #ifndef _TRACE_MACRO_HEADER_
00018 #define _TRACE_MACRO_HEADER_
00019
00020 //---------------------------------------------------------------------------
00021 //  Function prototypes
00022 //
00023 VOID Trace_Start( LPCTSTR pszClass, LPCTSTR pszFunction );
00024 VOID Trace_HR( LPCTSTR pszClass, LPCTSTR pszFunction, HRESULT hr );
00025 VOID Trace_Value( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszValueName, LONG nValue );
00026 VOID Trace_Pointer( LPCTSTR pszClass, LPCTSTR pszFunction, LPCTSTR pszAction, ULONG ulValue );
00027 VOID Trace_Event( LPCTSTR pszClass, LPCTSTR pszFunction, LONG nEvent );
00028 VOID MapEvent( LONG Event, LPTSTR szEventStr );
00029
00030
00031 // Alternate version provides complete path to the file
00032 // #define TRACE_HRESULT(str,hr)  Trace_HR( _T(__FILE__), (str), (hr) )
00033
00034 #ifdef _DEBUG
00035
00036 #undef  TRACE_HRESULT
00037 #define TRACE_HRESULT(s1,hr) Trace_HR( (MODULESTRING),(s1),(hr) )
00038
00039 #undef  TRACE_VAL
00040 #define TRACE_VAL(s1,s2,val) Trace_Value( (MODULESTRING),(s1),(s2),(val) )
00041
00042 #undef  TRACE_PTR
00043 #define TRACE_PTR(s1,s2,val) Trace_Pointer( (MODULESTRING),(s1),(s2),(val) )
00044
00045 #undef  TRACE_EVENT
00046 #define TRACE_EVENT(s1,val)  Trace_Event( (MODULESTRING),(s1),(val) )
00047
00048 #undef  TRACE_START
00049 #define TRACE_START( s1 )    Trace_Start( (MODULESTRING),(s1) )
00050
00051
00052 #else
00053
00054 #undef  TRACE_HRESULT
00055 #define TRACE_HRESULT
00056
00057 #undef  TRACE_VAL
00058 #define TRACE_VAL
00059
00060 #undef  TRACE_PTR
00061 #define TRACE_PTR
00062
00063 #undef  TRACE_EVENT
00064 #define TRACE_EVENT
00065
00066 #undef  TRACE_START
00067 #define TRACE_START
00068
00069 #endif //_DEBUG
00070
00071
00072 #endif //_TRACE_MACRO_HEADER_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIGetSession Member List

This is the complete list of members for CImpIGetSession, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRow, CImpIGetSession) | CImpIGetSession
GetSession(REFIID riid, IUnknown **ppSession) | CImpIGetSession
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Sample::UI::MainWindow Member List

This is the complete list of members for Sample::UI::MainWindow, including all inherited members.
AboutBoxHandler(object sender, System.EventArgs e) | Sample::UI::MainWindow | [inline, private]
aboutMenu | Sample::UI::MainWindow | [private]
buttonSign | Sample::UI::MainWindow | [private]
buttonSign_Click(object sender, System.EventArgs e) | Sample::UI::MainWindow | [inline, private]
buttonVerify | Sample::UI::MainWindow | [private]
buttonVerify_Click(object sender, System.EventArgs e) | Sample::UI::MainWindow | [inline, private]
closeMenu | Sample::UI::MainWindow | [private]
components | Sample::UI::MainWindow | [private]
EscapeHandler(object sender, System.EventArgs e) | Sample::UI::MainWindow | [inline, private]
fileMenu | Sample::UI::MainWindow | [private]
helpMenu | Sample::UI::MainWindow | [private]
InitializeComponent() | Sample::UI::MainWindow | [inline, private]
keyInfoBox | Sample::UI::MainWindow | [private]
labelSign | Sample::UI::MainWindow | [private]
labelVerify | Sample::UI::MainWindow | [private]
mainMenu | Sample::UI::MainWindow | [private]
MainWindow() | Sample::UI::MainWindow | [inline]
OpenFileHandler(object sender, System.EventArgs e) | Sample::UI::MainWindow | [inline, private]
openFileMenu | Sample::UI::MainWindow | [private]
signGroupBox | Sample::UI::MainWindow | [private]
statusBar | Sample::UI::MainWindow | [private]
textBoxSign | Sample::UI::MainWindow | [private]
textBoxVerify | Sample::UI::MainWindow | [private]
Generated on Wed Nov 13 2024 16:58:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/RPCsvc/Service.H Source File

  • NetDS
  • RPC
  • RPCsvc

Service.H

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE: service.h
00009 //
00010 //  AUTHOR: Craig Link
00011 //
00012 //
00013 //  Comments:  The use of this header file and the accompanying service.c
00014 //  file simplifies the process of writting a service.  You as a developer
00015 //  simply need to follow the TODO's outlined in this header file, and
00016 //  implement the ServiceStart() and ServiceStop() functions.
00017 //
00018 //  There is no need to modify the code in service.c.  Just add service.c
00019 //  to your project and link with the following libraries...
00020 //
00021 //  libcmt.lib kernel32.lib advapi.lib shell32.lib
00022 //
00023 //  This code also supports unicode.  Be sure to compile both service.c and
00024 //  and code #include "service.h" with the same Unicode setting.
00025 //
00026 //  Upon completion, your code will have the following command line interface
00027 //
00028 //  <service exe> -?                to display this list
00029 //  <service exe> -install          to install the service
00030 //  <service exe> -remove           to remove the service
00031 //  <service exe> -debug <params>   to run as a console app for debugging
00032 //
00033 //  Note: This code also implements Ctrl+C and Ctrl+Break handlers
00034 //        when using the debug option.  These console events cause
00035 //        your ServiceStop routine to be called
00036 //
00037 //        Also, this code only handles the OWN_SERVICE service type
00038 //        running in the LOCAL_SYSTEM security context.
00039 //
00040 //        To control your service ( start, stop, etc ) you may use the
00041 //        Services control panel applet or the NET.EXE program.
00042 //
00043 //        To aid in writing/debugging service, the
00044 //        SDK contains a utility (MSTOOLS\BIN\SC.EXE) that
00045 //        can be used to control, configure, or obtain service status.
00046 //        SC displays complete status for any service/driver
00047 //        in the service database, and allows any of the configuration
00048 //        parameters to be easily changed at the command line.
00049 //        For more information on SC.EXE, type SC at the command line.
00050 //
00051
00052 #ifndef _SERVICE_H
00053 #define _SERVICE_H
00054
00055
00056 #ifdef __cplusplus
00057 extern "C" {
00058 #endif
00059
00060
00061 //////////////////////////////////////////////////////////////////////////////
00062 //// todo: change to desired strings
00063 ////
00064 // name of the executable
00065 #define SZAPPNAME            "RpcSvc"
00066 // internal name of the service
00067 #define SZSERVICENAME        "SimpleRpcService"
00068 // displayed name of the service
00069 #define SZSERVICEDISPLAYNAME "Simple RPC Service"
00070 // list of service dependencies - "dep1\0dep2\0\0"
00071 #define SZDEPENDENCIES       "RPCSS\0\0"
00072 //////////////////////////////////////////////////////////////////////////////
00073
00074
00075
00076 //////////////////////////////////////////////////////////////////////////////
00077 //// todo: ServiceStart()must be defined by in your code.
00078 ////       The service should use ReportStatusToSCMgr to indicate
00079 ////       progress.  This routine must also be used by StartService()
00080 ////       to report to the SCM when the service is running.
00081 ////
00082 ////       If a ServiceStop procedure is going to take longer than
00083 ////       3 seconds to execute, it should spawn a thread to
00084 ////       execute the stop code, and return.  Otherwise, the
00085 ////       ServiceControlManager will believe that the service has
00086 ////       stopped responding
00087 ////
00088 VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
00089 VOID ServiceStop();
00090 //////////////////////////////////////////////////////////////////////////////
00091
00092
00093
00094 //////////////////////////////////////////////////////////////////////////////
00095 //// The following are procedures which
00096 //// may be useful to call within the above procedures,
00097 //// but require no implementation by the user.
00098 //// They are implemented in service.c
00099
00100 //
00101 //  FUNCTION: ReportStatusToSCMgr()
00102 //
00103 //  PURPOSE: Sets the current status of the service and
00104 //           reports it to the Service Control Manager
00105 //
00106 //  PARAMETERS:
00107 //    dwCurrentState - the state of the service
00108 //    dwWin32ExitCode - error code to report
00109 //    dwWaitHint - worst case estimate to next checkpoint
00110 //
00111 //  RETURN VALUE:
00112 //    TRUE  - success
00113 //    FALSE - failure
00114 //
00115 BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
00116
00117
00118 //
00119 //  FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
00120 //
00121 //  PURPOSE: Allows any thread to log an error message
00122 //
00123 //  PARAMETERS:
00124 //    lpszMsg - text for message
00125 //
00126 //  RETURN VALUE:
00127 //    none
00128 //
00129 void AddToMessageLog(LPTSTR lpszMsg);
00130 //////////////////////////////////////////////////////////////////////////////
00131
00132
00133 #ifdef __cplusplus
00134 }
00135 #endif
00136
00137 #endif
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Hello/Hellos.c Source File

  • NetDS
  • RPC
  • Hello

Hellos.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         hello Example
00005
00006     FILE:       hellos.c
00007
00008     USAGE:      hellos  -p protocol_sequence
00009                         -e endpoint
00010                         -m max calls
00011                         -n min calls
00012                         -f flag for RpcServerListen
00013
00014     PURPOSE:    Server side of RPC distributed application hello
00015
00016     FUNCTIONS:  main() - registers server as RPC server
00017
00018     COMMENTS:   This version of the distributed application that prints
00019                 "hello, world" (or other string) on the server features
00020                 a client that manages its connection to the server.
00021                 It uses the binding handle hello_IfHandle, defined in
00022                 the file hello.h.
00023
00024 ****************************************************************************/
00025
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <ctype.h>
00029 #include "hello.h"    // header file generated by MIDL compiler
00030
00031 #define PURPOSE \
00032 "This Microsoft RPC Version 1.0 sample program demonstrates\n\
00033 the use of the [string] attribute. For more information\n\
00034 about the attributes and the RPC API functions, see the\n\
00035 RPC programming guide and reference.\n\n"
00036
00037 void Usage(char * pszProgramName)
00038 {
00039     fprintf(stderr, "%s", PURPOSE);
00040     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00041     fprintf(stderr, " -p protocol_sequence\n");
00042     fprintf(stderr, " -e endpoint\n");
00043     fprintf(stderr, " -m maxcalls\n");
00044     fprintf(stderr, " -n mincalls\n");
00045     fprintf(stderr, " -f flag_wait_op\n");
00046     exit(1);
00047 }
00048
00049 /* main:  register the interface, start listening for clients */
00050 void __cdecl main(int argc, char * argv[])
00051 {
00052     RPC_STATUS status;
00053     unsigned char * pszProtocolSequence = "ncacn_np";
00054     unsigned char * pszSecurity         = NULL;
00055     unsigned char * pszEndpoint         = "\\pipe\\hello";
00056     unsigned int    cMinCalls           = 1;
00057     unsigned int    cMaxCalls           = 20;
00058     unsigned int    fDontWait           = FALSE;
00059     int i;
00060
00061     /* allow the user to override settings with command line switches */
00062     for (i = 1; i < argc; i++) {
00063         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00064             switch (tolower(*(argv[i]+1))) {
00065             case 'p':  // protocol sequence
00066                 pszProtocolSequence = argv[++i];
00067                 break;
00068             case 'e':
00069                 pszEndpoint = argv[++i];
00070                 break;
00071             case 'm':
00072                 cMaxCalls = (unsigned int) atoi(argv[++i]);
00073                 break;
00074             case 'n':
00075                 cMinCalls = (unsigned int) atoi(argv[++i]);
00076                 break;
00077             case 'f':
00078                 fDontWait = (unsigned int) atoi(argv[++i]);
00079                 break;
00080             case 'h':
00081             case '?':
00082             default:
00083                 Usage(argv[0]);
00084             }
00085         }
00086         else
00087             Usage(argv[0]);
00088     }
00089
00090     status = RpcServerUseProtseqEp(pszProtocolSequence,
00091                                    cMaxCalls,
00092                                    pszEndpoint,
00093                                    pszSecurity);  // Security descriptor
00094     printf("RpcServerUseProtseqEp returned 0x%x\n", status);
00095     if (status) {
00096         exit(status);
00097     }
00098
00099     status = RpcServerRegisterIf(hello_ServerIfHandle,  // interface to register
00100                                  NULL,   // MgrTypeUuid
00101                                  NULL);  // MgrEpv; null means use default
00102     printf("RpcServerRegisterIf returned 0x%x\n", status);
00103     if (status) {
00104         exit(status);
00105     }
00106
00107     printf("Calling RpcServerListen\n");
00108     status = RpcServerListen(cMinCalls,
00109                              cMaxCalls,
00110                              fDontWait);
00111     printf("RpcServerListen returned: 0x%x\n", status);
00112     if (status) {
00113         exit(status);
00114     }
00115
00116     if (fDontWait) {
00117         printf("Calling RpcMgmtWaitServerListen\n");
00118         status = RpcMgmtWaitServerListen();  // wait operation
00119         printf("RpcMgmtWaitServerListen returned: 0x%x\n", status);
00120         if (status) {
00121             exit(status);
00122         }
00123     }
00124
00125 }  // end main()
00126
00127
00128 /*********************************************************************/
00129 /*                MIDL allocate and free                             */
00130 /*********************************************************************/
00131
00132 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00133 {
00134     return(malloc(len));
00135 }
00136
00137 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00138 {
00139     free(ptr);
00140 }
00141
00142 /* end file hellos.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAppletSession Member List

This is the complete list of members for CAppletSession, including all inherited members.
AddRef(void) | CAppletSession |
Advise(void) | CAppletSession | [inline]
AllocateHandleConfirm(HRESULT hrResult, ULONG nFirstHandle, ULONG cHandles) | CAppletSession |
BuildJoinSessionStructure(void) | CAppletSession | [private]
CAppletSession(CApplet *pApplet, IAppletSession *pISession) | CAppletSession |
ChannelConfirm(AppletChannelCommand eCommand, HRESULT hrResult, AppletChannelID nChannelID) | CAppletSession |
ChannelIndication(AppletChannelCommand eCommand, AppletChannelID nChannelID, AppletReason eReason, AppletUserID uidManager) | CAppletSession |
CRefCount() | CRefCount |
GetConfID(void) | CAppletSession | [inline]
GetMemberName(AppletUserID uid) | CAppletSession | [private]
InquireRosterConfirm(HRESULT hrResult, ULONG cRosters, AppletRoster **apAppRosters) | CAppletSession |
InvokeApplet(void) | CAppletSession |
InvokeAppletConfirm(AppletRequestTag nReqTag, HRESULT hrResult) | CAppletSession |
Join(void) | CAppletSession | [inline]
JoinSessionConfirm(HRESULT hrResult, AppletUserID uidMyself, AppletNodeID nidMyself, AppletSessionID sidMyself, AppletEntityID eidMyself, ULONG cDynamicChannels, AppletChannelID aDynamicChannels[]) | CAppletSession |
Leave(void) | CAppletSession | [inline]
LeaveSessionIndication(AppletReason eReason, AppletUserID uidLeave) | CAppletSession |
m_apMembers | CAppletSession | [private]
m_cMembers | CAppletSession | [private]
m_dwCookie | CAppletSession | [private]
m_DynChnlRegKey | CAppletSession | [private]
m_eidMyself | CAppletSession | [private]
m_fTopProvider | CAppletSession | [private]
m_JoinSessionReq | CAppletSession | [private]
m_nConfID | CAppletSession | [private]
m_nDynamicMulticastChannel | CAppletSession | [private]
m_nidMyself | CAppletSession | [private]
m_pApplet | CAppletSession | [private]
m_pISession | CAppletSession | [private]
m_pszMyName | CAppletSession | [private]
m_sidMyself | CAppletSession | [private]
m_uidMyself | CAppletSession | [private]
QueryInterface(REFIID riid, void **ppvObj) | CAppletSession |
RegistryConfirm(AppletRegistryCommand eCommand, HRESULT hrResult, AppletRegistryKey *pRegistryKey, AppletRegistryItem *pRegistryItem, AppletRegistryEntryOwner *pEntryOwner, AppletModificationRights eRights) | CAppletSession |
Release(void) | CAppletSession |
RemoveMember(INmMember *) | CAppletSession |
RosterReportIndication(ULONG cRosters, AppletRoster **apAppRosters) | CAppletSession |
SendData(AppletChannelID, ULONG cbBufSize, BYTE *pBuffer) | CAppletSession |
SendDataIndication(BOOL fUniformSend, AppletUserID uidInitiator, AppletChannelID nChannelID, AppletPriority eDataPriority, AppletOctetString Data) | CAppletSession |
SetMember(INmMember *pIMember) | CAppletSession |
SetMember(AppletRecord *) | CAppletSession | [private]
TestTokenConfirm(AppletTokenID nTokenID, AppletTokenStatus eStatus) | CAppletSession |
TokenConfirm(AppletTokenCommand eCommand, HRESULT hrResult, AppletTokenID nTokenID) | CAppletSession |
TokenIndication(AppletTokenCommand eCommand, AppletReason eReason, AppletTokenID nTokenID, AppletUserID uidInitiator) | CAppletSession |
UnAdvise(void) | CAppletSession | [inline]
~CAppletSession(void) | CAppletSession |
~CRefCount() | CRefCount | [virtual]
Generated on Wed Nov 13 2024 16:55:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFontSelect Member List

This is the complete list of members for CFontSelect, including all inherited members.
_canvas | CFontSelect | [protected]
_hfontOld | CFontSelect | [protected]
CFontSelect(CCanvas &canvas, HFONT hfont) | CFontSelect | [inline]
~CFontSelect() | CFontSelect | [inline]
Generated on Wed Nov 13 2024 16:56:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Record Member List

This is the complete list of members for msado15::Record, including all inherited members.
Cancel() | msado15::Record |
Close() | msado15::Record |
clsid | msado15::Record | [static]
CopyRecord(String Source, String Destination, String UserName, String Password, int Options, boolean Async) | msado15::Record |
DeleteRecord(String Source, boolean Async) | msado15::Record |
getActiveConnection() | msado15::Record |
GetChildren() | msado15::Record |
getFields() | msado15::Record |
getMode() | msado15::Record |
getParentURL() | msado15::Record |
getProperties() | msado15::Record |
getRecordType() | msado15::Record |
getSource() | msado15::Record |
getState() | msado15::Record |
iid | msado15::Record | [static]
MoveRecord(String Source, String Destination, String UserName, String Password, int Options, boolean Async) | msado15::Record |
Open(Variant Source, Variant ActiveConnection, int Mode, int CreateOptions, int Options, String UserName, String Password) | msado15::Record |
setActiveConnection(String pvar) | msado15::Record |
setActiveConnection(msado15._Connection pvar) | msado15::Record |
setMode(int pMode) | msado15::Record |
setSource(String pvar) | msado15::Record |
setSource(Object pvar) | msado15::Record |
Generated on Wed Nov 13 2024 16:58:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/cmonitor.cpp Source File

  • Web
  • bits
  • Upload

cmonitor.cpp

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  cmonitor.cpp
00011 //
00012 //  Purpose:
00013 //  This module implements the CMonitor class, which is
00014 //  used in the sample to respond to job callbacks.
00015 //
00016 //  Take special note of the CMonitor::JobTransferred() method. It executes
00017 //  the important step of calling Job->Complete(), which causes the file
00018 //  upload to be effectively completed.
00019 //
00020 //  Also note the treatment of Upload-reply jobs. If the job was created
00021 //  with the type BG_JOB_TYPE_UPLOAD_REPLY, then additional processing is
00022 //  needed to actually read the reply and do something with it.
00023 //  For the client to see upload replies, the IIS virtual directory
00024 //  needs to be configured to process notifications, and the processing
00025 //  application needs to post data back (see the script newupload.asp).
00026 //
00027 //  The script configure.js, included with this sample, provides a convenient
00028 //  way of configuring the IIS upload virtual directory to work properly
00029 //  with this sample.
00030 //
00031 //----------------------------------------------------------------------------
00032
00033
00034 #include <windows.h>
00035 #include <crtdbg.h>
00036 #include <unknwn.h>
00037 #include <strsafe.h>
00038 #include <bits.h>
00039
00040 #include "util.h"
00041 #include "main.h"
00042 #include "cmonitor.h"
00043
00044
00045 //----------------------------------------------------------------------------
00046 // CMonitor's IUnknown methods
00047 //----------------------------------------------------------------------------
00048
00049 HRESULT CMonitor::QueryInterface(REFIID riid, LPVOID* ppvObj)
00050 {
00051     if (riid == __uuidof(IUnknown) || riid == __uuidof(IBackgroundCopyCallback))
00052     {
00053         *ppvObj = this;
00054     }
00055     else
00056     {
00057         *ppvObj = NULL;
00058         return E_NOINTERFACE;
00059     }
00060
00061     AddRef();
00062     return NOERROR;
00063 }
00064
00065 ULONG CMonitor::AddRef()
00066 {
00067     if (m_lRefCount == 0) // first time this function is called
00068     {
00069         g_hSafeToExitEvent = CreateEvent(
00070              NULL,   // default security attributes
00071              FALSE,  // auto-reset event object
00072              FALSE,  // initial state is nonsignaled
00073              NULL);  // unnamed object
00074
00075         // in case of failure just act as we didn't create the event
00076         if (!g_hSafeToExitEvent)
00077         {
00078             g_hSafeToExitEvent = INVALID_HANDLE_VALUE;
00079         }
00080     }
00081
00082     return InterlockedIncrement(&m_lRefCount);
00083 }
00084
00085 ULONG CMonitor::Release()
00086 {
00087     ULONG ulCount = InterlockedDecrement(&m_lRefCount);
00088
00089     if (ulCount == 0)
00090     {
00091         if (g_hSafeToExitEvent != INVALID_HANDLE_VALUE)
00092         {
00093             SetEvent(g_hSafeToExitEvent);
00094         }
00095     }
00096
00097     return ulCount;
00098 }
00099
00100
00101 //----------------------------------------------------------------------------
00102 // CMonitor's IBackgroundCopyJob methods
00103 //
00104 // Note that the implementation of these methods need to be thread-safe
00105 //
00106 //----------------------------------------------------------------------------
00107
00108 HRESULT CMonitor::JobTransferred(IBackgroundCopyJob* pJob)
00109 {
00110     HRESULT hr;
00111     GUID    guid;
00112     BG_JOB_TYPE JobType;
00113
00114
00115     hr = pJob->GetType(&JobType);
00116     if (FAILED(hr))
00117     {
00118         goto cleanup;
00119     }
00120
00121     if (JobType == BG_JOB_TYPE_UPLOAD_REPLY)
00122     {
00123         hr = ProcessReply(pJob);
00124         if (FAILED(hr))
00125         {
00126             goto cleanup;
00127         }
00128     }
00129
00130     hr = pJob->Complete();
00131     if (FAILED(hr))
00132     {
00133         // BITS probably was unable to rename one or more of the
00134         // temporary files. We won't do anything about this
00135         goto cleanup;
00136     }
00137
00138     hr = pJob->GetId(&guid);
00139     if (FAILED(hr))
00140     {
00141         goto cleanup;
00142     }
00143
00144     g_pDialog->AddStatusMessage(L"Notification received (BG_NOTIFY_JOB_TRANSFERRED). File was uploaded! (Job ID %s)", ConvertGuidToString(guid));
00145     g_pDialog->AddStatusMessage(L"END OF UPLOAD PROCESS");
00146
00147
00148 cleanup:
00149
00150     if (FAILED(hr))
00151     {
00152         DisplayErrorMessage(L"Notification received (BG_NOTIFY_JOB_TRANSFERRED), but an error occured. Error id is 0x%X", hr);
00153     }
00154
00155     //If you do not return S_OK, BITS continues to call this callback.
00156     return S_OK;
00157 }
00158
00159
00160 HRESULT CMonitor::JobError(IBackgroundCopyJob* pJob, IBackgroundCopyError* pError)
00161 {
00162     HRESULT hr;
00163     GUID    guid;
00164     HRESULT hrErrorId;
00165     WCHAR  *pwszErrorDescription   = NULL;
00166     WCHAR  *pwszContextDescription = NULL;
00167     BG_ERROR_CONTEXT Context;
00168
00169
00170     //
00171     // Collect information about the failed job
00172     //
00173
00174     hr = pJob->GetId(&guid);
00175     if (FAILED(hr))
00176     {
00177         goto cleanup;
00178     }
00179
00180     hr = pError->GetError(&Context, &hrErrorId);
00181     if (FAILED(hr))
00182     {
00183         goto cleanup;
00184     }
00185
00186     hr = pError->GetErrorContextDescription(MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), &pwszContextDescription);
00187     if (FAILED(hr))
00188     {
00189         goto cleanup;
00190     }
00191
00192     hr = pError->GetErrorDescription(MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), &pwszErrorDescription);
00193     if (FAILED(hr))
00194     {
00195         goto cleanup;
00196     }
00197
00198     //
00199     // Cancel the job because the error is not recoverable
00200     //
00201     hr = pJob->Cancel();
00202
00203     g_pDialog->AddStatusMessage(L"Notification received (BG_NOTIFY_JOB_ERROR). (Job ID %s)\r\n"
00204         L"   Error context: %s"
00205         L"   Error id: Ox%X\r\n"
00206         L"   Error description: %s"
00207         L"   This error is not recoverable and the job will be cancelled.",
00208         ConvertGuidToString(guid),
00209         pwszContextDescription,
00210         hrErrorId,
00211         pwszErrorDescription
00212     );
00213     g_pDialog->AddStatusMessage(L"END OF UPLOAD PROCESS -- FAILED");
00214
00215 cleanup:
00216
00217     if (FAILED(hr))
00218     {
00219         DisplayErrorMessage(L"Notification received (BG_NOTIFY_JOB_ERROR), but the error description could not be retrieved and the job was not cancelled. Error id is 0x%X", hr);
00220     }
00221
00222     // safe to call these if pointer is NULL
00223     CoTaskMemFree(pwszContextDescription);
00224     CoTaskMemFree(pwszErrorDescription);
00225
00226     //If you do not return S_OK, BITS continues to call this callback.
00227     return S_OK;
00228 }
00229
00230 HRESULT CMonitor::JobModification(IBackgroundCopyJob* pJob, DWORD dwReserved)
00231 {
00232     HRESULT      hr;
00233     GUID         guid;
00234     BG_JOB_STATE State;
00235     WCHAR        *pwszErrorDescription   =    NULL;
00236     WCHAR        *pwszContextDescription =    NULL;
00237     HRESULT hrErrorId;
00238     BG_ERROR_CONTEXT Context;
00239
00240     hr = pJob->GetState(&State);
00241     if (FAILED(hr))
00242     {
00243         DisplayErrorMessage(L"BITS Upload Sample was unable to get the BITS job state. ", hr);
00244         return S_OK;
00245     }
00246
00247     if (State == BG_JOB_STATE_TRANSIENT_ERROR)
00248     {
00249         CSmartComPtr<IBackgroundCopyError> Error;
00250
00251         hr = pJob->GetId(&guid);
00252         if (FAILED(hr))
00253         {
00254             goto cleanup;
00255         }
00256
00257         hr = pJob->GetError(&Error);
00258         if (FAILED(hr))
00259         {
00260             goto cleanup;
00261         }
00262
00263         hr = Error->GetError(&Context, &hrErrorId);
00264         if (FAILED(hr))
00265         {
00266             goto cleanup;
00267         }
00268
00269         hr = Error->GetErrorContextDescription(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), &pwszContextDescription);
00270         if (FAILED(hr))
00271         {
00272             goto cleanup;
00273         }
00274
00275         hr = Error->GetErrorDescription(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), &pwszErrorDescription);
00276         if (FAILED(hr))
00277         {
00278             goto cleanup;
00279         }
00280
00281         g_pDialog->AddStatusMessage(L"Job entered a transient error state. (Job ID %s)\r\n"
00282             L"   Error context: %s"
00283             L"   Error id: 0x%X\r\n"
00284             L"   Error description: %s"
00285             L"   BITS will retry to upload the file.",
00286             ConvertGuidToString(guid),
00287             pwszContextDescription,
00288             hrErrorId,
00289             pwszErrorDescription
00290         );
00291     }
00292
00293 cleanup:
00294
00295     // safe to call these if pointer is NULL
00296     CoTaskMemFree(pwszContextDescription);
00297     CoTaskMemFree(pwszErrorDescription);
00298
00299     return S_OK;
00300 }
00301
00302 //----------------------------------------------------------------------------
00303 // CMonitor's private methods
00304 //----------------------------------------------------------------------------
00305
00306 HRESULT CMonitor::ProcessReply(IBackgroundCopyJob* pJob)
00307 {
00308     HRESULT hr;
00309     CSmartComPtr<IBackgroundCopyJob2> Job2;
00310     BYTE  *pReply    = NULL;
00311     WCHAR *pTextData = NULL;
00312     UINT64 ReplySize;
00313     GUID   guid;
00314
00315     //
00316     // Initialize our Job2 smart object. Note the use of the & operator
00317     //
00318     hr = pJob->QueryInterface(__uuidof(IBackgroundCopyJob2), (void**)&Job2);
00319     if (FAILED(hr))
00320     {
00321         goto cleanup;
00322     }
00323
00324     hr = pJob->GetId(&guid);
00325     if (FAILED(hr))
00326     {
00327         goto cleanup;
00328     }
00329
00330     hr = Job2->GetReplyData(&pReply, &ReplySize);
00331     if (hr == S_OK)
00332     {
00333         // check if we got the reply data.
00334         // As we are expecting to receive a Unicode file as a reply, check that at least
00335         // 2 bytes were received. 2 bytes is the size of the unicode prologue
00336         if (pReply && (ReplySize > 2))
00337         {
00338             // allocate a buffer to copy the data
00339             // we need to do this because we need to add a \0 at the end of the
00340             // data stream before we can treat it as a WCHAR string
00341             pTextData = reinterpret_cast<WCHAR *>(new BYTE[static_cast<size_t>(ReplySize)]);
00342             if (!pTextData)
00343             {
00344                 hr = E_OUTOFMEMORY;
00345                 goto cleanup;
00346             }
00347
00348             // now here's something tricky: we want to add a \0 to the end of the string,
00349             // but we also want to skip 2 bytes at the beguinning of the string.
00350             // Note that overall we have enough space by allocating just ReplySize
00351
00352             // initialize our buffer with zeros
00353             memset(pTextData, 0, static_cast<size_t>(ReplySize));
00354
00355             // copy the relevant data to the buffer, skipping 2 bytes because of the Unicode prologue
00356             // note that pTextData is WCHAR* and pReply is BYTE*
00357             memcpy(pTextData, (pReply + 2), (static_cast<size_t>(ReplySize) - 2));
00358
00359             g_pDialog->AddStatusMessage(L"The server sent the following data as a response to the uploaded file: (Job ID %s)\r\n"
00360                                         L"\r\n%s", ConvertGuidToString(guid), pTextData);
00361
00362         }
00363         else
00364         {
00365             g_pDialog->AddStatusMessage(L"No reply data was received. (Job ID %s)", ConvertGuidToString(guid));
00366         }
00367     }
00368
00369 cleanup:
00370
00371     if (pReply)
00372     {
00373         CoTaskMemFree(pReply);
00374         pReply = NULL;
00375     }
00376
00377     if (pTextData)
00378     {
00379         delete [] reinterpret_cast<BYTE *>(pTextData);
00380         pTextData = NULL;
00381     }
00382
00383     return hr;
00384 }
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/Init.Cpp Source File

  • Web
  • NetMeeting
  • NMUI

Init.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       INIT.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 // string constants (no change for international)
00018
00019 TCHAR gszAppClassName[] = TEXT("NMUI");
00020 TCHAR gszAppName[]      = TEXT("NmUi");
00021 TCHAR gszIniName[]      = TEXT("NmUi.ini");
00022
00023 // Section Names
00024 TCHAR gszMainWnd[]  = TEXT("MainWnd");
00025 TCHAR gszSbar[]     = TEXT("SBar");
00026 TCHAR gszTbar[]     = TEXT("TBar");
00027 TCHAR gszChat[]     = TEXT("Chat");
00028 TCHAR gszMsg[]      = TEXT("Messages");
00029 TCHAR gszMsgFont[]  = TEXT("Message Font");
00030 TCHAR gszAddr[]     = TEXT("Addr");
00031 TCHAR gszAddrType[] = TEXT("AddrType");
00032 TCHAR gszConferenceName[] = TEXT("Conference Name");
00033 TCHAR gszFileName[] = TEXT("Filename");
00034
00035 TCHAR gszIniCallType[] = TEXT("CallType");
00036
00037 TCHAR gszIniAutoMonitor[] = TEXT("AutoMonitor");
00038 TCHAR gszIniAutoHost[]    = TEXT("AutoHost");
00039 TCHAR gszIniAutoCall[]    = TEXT("AutoCall");
00040 TCHAR gszIniAutoChat[]    = TEXT("AutoChat");
00041
00042 TCHAR gszIniInit[]        = TEXT("Init");
00043
00044 TCHAR gszIniMsgTrace[]    = TEXT("Trace Msgs");
00045 TCHAR gszIniMsgObjects[]  = TEXT("Object Msgs");
00046 TCHAR gszIniMsgNotify[]   = TEXT("Notify Msgs");
00047 TCHAR gszIniMsgState[]    = TEXT("State change Msgs");
00048
00049 // See ILV_*
00050 static COL _rgColMember[] = {
00051   {80, TEXT("Name")},
00052   {40, TEXT("Ver")},
00053   {60, TEXT("Caps")},
00054   {60, TEXT("Audio")},
00055   {60, TEXT("Ft")},
00056   {90, TEXT("App Sharing")},
00057   {40, TEXT("MCU")},
00058   {40, TEXT("Local")},
00059   {80, TEXT("IP Addr")},
00060   {80, TEXT("ID")},
00061 };
00062
00063
00064 //****************************************************************************
00065 //
00066 // VOID ReadPref(void)
00067 //
00068 // Reads the current preferences from the NmUi.ini file.
00069 //
00070 //****************************************************************************
00071
00072 VOID ReadPref(void)
00073 {
00074   ZeroMemory(&gPref, sizeof(PREF));
00075
00076   gPref.fSbar       = GetIniBool(gszSbar, TRUE);
00077   gPref.fTbar       = GetIniBool(gszTbar, TRUE);
00078   gPref.fMsg        = GetIniBool(gszMsg, TRUE);
00079   gPref.fChat       = GetIniBool(gszChat, TRUE);
00080
00081   gPref.pszConferenceName = GetIniStr(gszConferenceName, TEXT("NmUi Conference"));
00082
00083   gPref.pszAddr    = GetIniStr(gszAddr, TEXT("User 1"));
00084   gPref.nmAddrType = (NM_ADDR_TYPE) GetIniInt(gszAddrType, NM_ADDR_UNKNOWN);
00085   gPref.nmCallType = (NM_CALL_TYPE) GetIniInt(gszIniCallType, (int) NM_CALL_DEFAULT);
00086
00087   GetIniHex(gszMainWnd, &gPref.wpMain, sizeof(WINDOWPLACEMENT));
00088   GetIniHex(gszMsgFont, &gPref.lf, sizeof(LOGFONT));
00089
00090   gPref.fAutoMonitor= GetIniBool(gszIniAutoMonitor, FALSE);
00091   gPref.fAutoHost   = GetIniBool(gszIniAutoHost, FALSE);
00092   gPref.fAutoCall   = GetIniBool(gszIniAutoCall, FALSE);
00093   gPref.fAutoChat   = GetIniBool(gszIniAutoChat, FALSE);
00094
00095   gPref.fMsgTrace   = GetIniBool(gszIniMsgTrace, TRUE);
00096   gPref.fMsgObjects = GetIniBool(gszIniMsgObjects, FALSE);
00097   gPref.fMsgNotify  = GetIniBool(gszIniMsgNotify, TRUE);
00098   gPref.fMsgState   = GetIniBool(gszIniMsgState, TRUE);
00099
00100   gPref.iInit       = GetIniInt(gszIniInit, NM_INIT_NORMAL);
00101
00102   gPref.pszFileName = GetIniStr(gszFileName, TEXT("C:\\autoexec.bat"));
00103 }
00104
00105
00106 //****************************************************************************
00107 //
00108 // VOID WritePref(void)
00109 //
00110 // Write the current preferences
00111 //
00112 //****************************************************************************
00113
00114 VOID WritePref(void)
00115 {
00116   WriteIniBool(gszSbar, gPref.fSbar);
00117   WriteIniBool(gszTbar, gPref.fTbar);
00118   WriteIniBool(gszMsg, gPref.fMsg);
00119   WriteIniBool(gszChat, gPref.fChat);
00120
00121   WriteIniStr(gszConferenceName, gPref.pszConferenceName);
00122   FreePlpv(&gPref.pszConferenceName);
00123
00124   WriteIniStr(gszFileName, gPref.pszFileName);
00125   FreePlpv(&gPref.pszFileName);
00126
00127   WriteIniStr(gszAddr, gPref.pszAddr);
00128   FreePlpv(&gPref.pszAddr);
00129   WriteIniInt(gszAddrType, (int) gPref.nmAddrType);
00130   WriteIniInt(gszIniCallType, (int) gPref.nmCallType);
00131
00132   if (NULL != ghwndMain)
00133   {
00134     gPref.wpMain.length = sizeof(WINDOWPLACEMENT);
00135     GetWindowPlacement(ghwndMain, &gPref.wpMain);
00136   }
00137   WriteIniHex(gszMainWnd, &gPref.wpMain, sizeof(WINDOWPLACEMENT));
00138
00139   WriteIniHex(gszMsgFont, &gPref.lf, sizeof(LOGFONT));
00140
00141   WriteIniTbar();
00142
00143   WriteIniBool(gszIniAutoMonitor, gPref.fAutoMonitor);
00144   WriteIniBool(gszIniAutoHost,    gPref.fAutoHost);
00145   WriteIniBool(gszIniAutoCall,    gPref.fAutoCall);
00146   WriteIniBool(gszIniAutoChat,    gPref.fAutoChat);
00147
00148   WriteIniInt(gszIniInit,        gPref.iInit);
00149
00150   WriteIniBool(gszIniMsgTrace,    gPref.fMsgTrace);
00151   WriteIniBool(gszIniMsgObjects,  gPref.fMsgObjects);
00152   WriteIniBool(gszIniMsgNotify,   gPref.fMsgNotify);
00153   WriteIniBool(gszIniMsgState,    gPref.fMsgState);
00154 }
00155
00156
00157 //****************************************************************************
00158 //
00159 // BOOL FCreateLView(void)
00160 //
00161 //****************************************************************************
00162
00163 BOOL FCreateLView(void)
00164 {
00165   ghwndLView = CreateWindow(TEXT("SysListView32"), NULL,
00166     WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | WS_CLIPSIBLINGS | LVS_REPORT,
00167     0, 0, 0, 0,
00168     ghwndMain, (HMENU) IDW_LVIEW, ghInst, NULL);
00169   if (ghwndLView == NULL)
00170     return FALSE;
00171
00172   ListView_SetExtendedListViewStyle(ghwndLView, LVS_EX_FULLROWSELECT);
00173
00174   // Initialize column data
00175   {
00176     int     iCol  = 0;
00177     LPCOL   lpCol = _rgColMember;
00178     LV_COLUMN lvc;
00179
00180     ZeroMemory(&lvc, sizeof(LV_COLUMN));
00181
00182     lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
00183     lvc.fmt = LVCFMT_LEFT;
00184     for (iCol = 0; iCol < ARRAY_ELEMENTS(_rgColMember); iCol++)
00185     {
00186       lvc.iSubItem = iCol;
00187       lvc.cx = lpCol->dwWidth;
00188       lvc.pszText = lpCol->lpsz;
00189       if (ListView_InsertColumn(ghwndLView, iCol, &lvc) == -1)
00190         return FALSE;
00191       lpCol++;
00192     }
00193   }
00194
00195   return TRUE;
00196 }
00197
00198
00199 //****************************************************************************
00200 //
00201 // BOOL FCreateMsgWindow(void)
00202 //
00203 // Create the main message window
00204 //
00205 //****************************************************************************
00206
00207 BOOL FCreateMsgWindow(void)
00208 {
00209   ghwndMsg = CreateWindow(TEXT("LISTBOX"), NULL,
00210     WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | WS_CLIPSIBLINGS |
00211     LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS ,
00212     0, 0, 0, 0,
00213     ghwndMain, (HMENU) IDW_MSG, ghInst, NULL);
00214   if (ghwndMsg == NULL)
00215     return FALSE;
00216
00217   // set the font for the window
00218   ghfontEntry = CreateFontIndirect(&gPref.lf);
00219   if (NULL == ghfontEntry)
00220     return TRUE;
00221
00222   SendMessage(ghwndMsg, WM_SETFONT, (WPARAM) ghfontEntry, MAKELPARAM(TRUE, 0));
00223
00224   return TRUE;
00225 }
00226
00227
00228 WNDPROC lpProcEdit = NULL;
00229 VOID CmdChat(void);
00230 LRESULT FAR PASCAL SubClsEdit(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00231
00232 LRESULT FAR PASCAL SubClsEdit(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00233 {
00234   if ((uMsg == WM_CHAR) && (VK_RETURN == wParam))
00235   {
00236     CmdChat();
00237     return 0L;
00238   }
00239
00240   return CallWindowProc(lpProcEdit, hwnd, uMsg, wParam, lParam);
00241 }
00242
00243
00244 //****************************************************************************
00245 //
00246 // BOOL FCreateChatWindow(void)
00247 //
00248 //****************************************************************************
00249
00250 BOOL FCreateChatWindow(void)
00251 {
00252   ghwndChat = CreateWindow(TEXT("EDIT"), NULL,
00253     WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS |  WS_TABSTOP |
00254       ES_AUTOHSCROLL,
00255     0, 0, DXP_SEND, DYP_SEND,
00256     ghwndMain, (HMENU) IDW_CHAT, ghInst, NULL);
00257   if (ghwndChat == NULL)
00258     return FALSE;
00259
00260   // set the font for the window
00261
00262   ghwndSend = CreateWindow(TEXT("BUTTON"), TEXT("Send To"),
00263     WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS | WS_TABSTOP |
00264       BS_DEFPUSHBUTTON,
00265     0, 0, DXP_SEND, DYP_SEND,
00266     ghwndMain, (HMENU) IDW_SEND, ghInst, NULL);
00267   if (ghwndSend == NULL)
00268     return FALSE;
00269
00270   lpProcEdit = (WNDPROC) GetWindowLongPtr(ghwndChat, GWLP_WNDPROC);
00271   SetWindowLongPtr(ghwndChat, GWLP_WNDPROC, (LONG)(WNDPROC) SubClsEdit);
00272
00273   ghwndUList = CreateWindow(TEXT("COMBOBOX"), TEXT("Everyone"),
00274     WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS | WS_VSCROLL | WS_TABSTOP |
00275       CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED,
00276     0, 0, DXP_ULIST, DYP_ULIST,
00277     ghwndMain, (HMENU) IDL_USERS, ghInst, NULL);
00278   if (ghwndUList == NULL)
00279     return FALSE;
00280
00281   return TRUE;
00282 }
00283
00284
00285 //****************************************************************************
00286 //
00287 // BOOL FInitMain(void)
00288 //
00289 // Initialize the window data and register the window class
00290 //
00291 //****************************************************************************
00292
00293 BOOL FInitMain(void)
00294 {
00295   TCHAR szTitle[MAX_PATH + 1];
00296   WNDCLASS  wc;
00297
00298   ZeroMemory(szTitle, sizeof(TCHAR) * (MAX_PATH + 1));
00299   ZeroMemory(&wc, sizeof(wc));
00300
00301   ASSERT(NULL != ghInst);
00302   if (NULL == ghInst)
00303   {
00304     ERROR_MSG(TEXT("FInitMain: NULL == ghInst"));
00305     return FALSE;
00306   }
00307
00308   ghAccelTable = LoadAccelerators(ghInst, MAKEINTRESOURCE(ID_APPACCEL));
00309
00310   LoadString(ghInst, IDS_APP_TITLE, szTitle, MAX_PATH);
00311
00312   wc.style         = CS_HREDRAW | CS_VREDRAW;
00313   wc.lpfnWndProc   = (WNDPROC)WndProc;
00314   wc.cbClsExtra    = 0;
00315   wc.cbWndExtra    = 0;
00316   wc.hInstance     = ghInst;
00317   wc.hIcon         = LoadIcon(ghInst, MAKEINTRESOURCE(ICO_MAIN));
00318   wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00319   wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
00320   wc.lpszMenuName  = MAKEINTRESOURCE(IDM_APP);
00321   wc.lpszClassName = gszAppClassName;
00322
00323   // Register the window class and return FALSE if unsuccesful.
00324   if (!RegisterClass(&wc))
00325     return FALSE;
00326
00327   // MAIN WINDOW
00328   // Create a main window for this application instance.
00329   ghwndMain = CreateWindow(gszAppClassName, szTitle, WS_OVERLAPPEDWINDOW,
00330     CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
00331     NULL, NULL, ghInst, NULL);
00332   if (ghwndMain == NULL)
00333     return FALSE;
00334
00335   ghMenu = GetMenu(ghwndMain);
00336   if (NULL == ghMenu)
00337     return FALSE;
00338
00339   if (!FCreateSbar() || !FCreateTbar() ||
00340     !FCreateLView() || !FCreateMsgWindow() || !FCreateChatWindow())
00341     return FALSE;
00342
00343   ShowHwnd(ghwndTbar, gPref.fTbar, IDM_VIEW_TBAR);
00344   ShowHwnd(ghwndSbar, gPref.fSbar, IDM_VIEW_SBAR);
00345
00346   if (gPref.wpMain.length != 0)
00347     SetWindowPlacement(ghwndMain, &gPref.wpMain);
00348
00349   return TRUE;
00350 }
00351
00352
00353 //****************************************************************************
00354 //
00355 // BOOL FInitApp(LPSTR lpszCmd, int nCmdShow)
00356 //
00357 // Initialize the application after checking command line, etc.
00358 //
00359 //****************************************************************************
00360
00361 BOOL FInitApp(LPSTR lpszCmd, int nCmdShow)
00362 {
00363   InitCommonControls();
00364
00365
00366   if (FAILED(CoInitialize(NULL)))
00367     return FALSE;
00368
00369   ReadPref();
00370
00371   if (!FInitMain())
00372     return FALSE;
00373
00374   ASSERT(NULL != ghwndMain);
00375   ShowWindow(ghwndMain, nCmdShow);
00376   UpdateWindow(ghwndMain);
00377
00378   TRACE_MSG(TEXT("System Initialized"));
00379
00380   OnStartup();
00381   return TRUE;
00382 }
00383
00384
00385 //****************************************************************************
00386 //
00387 // VOID FreeAllComObjects(void)
00388 //
00389 //****************************************************************************
00390
00391 extern INmChannelFt * g_pChannelFt;
00392
00393 extern CFileTransferNotify * g_pNotifyFileTransfer;
00394
00395 VOID FreeAllComObjects(void)
00396 {
00397   // Release all objects to which this app has a reference
00398   FreeAs();
00399
00400   if(NULL != g_pNotifyFileTransfer)
00401   {
00402     g_pNotifyFileTransfer->Disconnect();
00403     g_pNotifyFileTransfer->Release();
00404     g_pNotifyFileTransfer = NULL;
00405   }
00406
00407   if(NULL != g_pChannelFt)
00408   {
00409     g_pChannelFt->Release();
00410     g_pChannelFt = NULL;
00411   }
00412
00413   FreeFt();
00414
00415   FreeDataChannel();
00416   FreeAllUsers();
00417   FreeChannels();
00418   FreeCalls();
00419   FreeConferences();
00420   FreeConfMgr();
00421 }
00422
00423
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCShip/QCShip.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCShip

QCShip.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      QCShip.cpp
00003   Summary:   Implementation of DLL exports
00004   Classes:   None
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #include "stdafx.h"
00023 #include "resource.h"
00024 #include "initguid.h"
00025 #include <adoid.h>    // ADO
00026 #include "..\QCNotify\QCNotify.h"
00027 #include "..\QCNotify\QCNotify_i.c"
00028 #include "QCShip.h"
00029 #include "QCShip_i.c"
00030 #include "Ship.h"
00031
00032
00033 CComModule _Module;
00034
00035 BEGIN_OBJECT_MAP(ObjectMap)
00036   OBJECT_ENTRY(CLSID_Ship, COShip)
00037 END_OBJECT_MAP()
00038
00039 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00040   Function: DllMain
00041   Summary:  Main QCShip DLL entry point
00042   Args:     HINSTANCE hInstance   An instance identifier
00043       DWORD dwReason      Reason DLL loaded
00044       LPVOID                  Reserved
00045   Returns:  BOOL - always TRUE
00046 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00047
00048 extern "C"
00049 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00050 {
00051   if (dwReason == DLL_PROCESS_ATTACH)
00052   {
00053     _Module.Init(ObjectMap, hInstance);
00054     DisableThreadLibraryCalls(hInstance);
00055   }
00056   else if (dwReason == DLL_PROCESS_DETACH)
00057     _Module.Term();
00058   return TRUE;    // ok
00059 }
00060
00061 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00062   Function: DllCanUnloadNow
00063   Summary:  Is this DLL in use or can it be unloaded
00064   Args:     None
00065   Returns:  S_OK    Can be unloaded
00066             S_FALSE Still in use
00067 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00068
00069 STDAPI DllCanUnloadNow(void)
00070 {
00071   return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00072 }
00073
00074 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00075   Function: DllGetClassObject
00076   Summary:  Returns a class factory to create an object of the requested type
00077   Args:     REFCLSID rclsid     Class ID
00078             REFIID riid         Interface ID
00079             LPVOID *ppv         Returned class factory
00080   Returns:  Status from GetClassObject
00081 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00082
00083 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00084 {
00085   return _Module.GetClassObject(rclsid, riid, ppv);
00086 }
00087
00088 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00089   Function: DllRegisterServer
00090   Summary:  Adds entries to the system registry
00091   Args:     None
00092   Returns:  Status from RegisterServer
00093 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00094
00095
00096 STDAPI DllRegisterServer(void)
00097 {
00098   // registers object, typelib and all interfaces in typelib
00099   return _Module.RegisterServer(TRUE);
00100 }
00101
00102 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00103   Function: DllUnregisterServer
00104   Summary:  Removes entries from the system registry
00105   Args:     None
00106   Returns:  Status from UnregisterServer
00107 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00108
00109 STDAPI DllUnregisterServer(void)
00110 {
00111   _Module.UnregisterServer();
00112   return S_OK;
00113 }
00114
00115
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/globals.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

globals.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef _MMC_GLOBALS_H
00015 #define _MMC_GLOBALS_H
00016
00017 #include <TChar.h>
00018 #include <Mmc.h>
00019 #include <CrtDbg.h>
00020 #include "Guids.h"
00021
00022
00023 class CBaseNode;                       // References
00024 class CDataObject;
00025
00026
00027 //---------------------------------------------------------------------------
00028 extern HINSTANCE g_hInst;              // Global instance handle
00029 extern ULONG     g_uObjectCount;       // Instance count for this object
00030 extern ULONG     g_uServerLocks;       // Server lock count for this object
00031
00032 //---------------------------------------------------------------------------
00033 // Clipformats requiered by MMC
00034
00035 extern UINT g_cfDisplayName;      // DisplayName for our SnapIn node
00036 extern UINT g_cfNodeType;         // GUID of the selected node
00037 extern UINT g_cfSnapinClsid;      // Class ID of this SnapIn
00038 extern UINT g_cfszNodeType;       // String version of namespace GUID
00039
00040 extern UINT g_cfBaseNodePtr;      // Retrieves BaseNode pointer
00041 extern UINT g_cfDataObjPtr;       // Retrieves pointer to CDataObject
00042
00043 //---------------------------------------------------------------------------
00044 //  Global function prototypes
00045
00046 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide );
00047 void _fastcall CopyT2W( LPWSTR strDest, LPCTSTR strSource, size_t count);
00048
00049 void InitClipboardFormats();
00050
00051 HRESULT ExtractFromDataObject( LPDATAOBJECT ipDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal );
00052
00053 CBaseNode* ExtractBaseNodePtr( LPDATAOBJECT ipDataObject );
00054 CDataObject* ExtractDataObjPtr( LPDATAOBJECT ipDataObject );
00055
00056 //---------------------------------------------------------------------------
00057 //  Global Strings
00058
00059
00060 static TCHAR*  gtszSNAPIN_NAME       = _T("Sample L (MMC 2.0) - View Extensions");
00061 static TCHAR*  gtszABOUT_NAME        = _T("Sample L (MMC 2.0) - ISnapinAbout");
00062
00063
00064 static WCHAR*  gwszROOT_NODE_NAME    = L"View Extensions Sample";
00065 static WCHAR*  gwszABOUT_DESCRIPTION = L"MMC SDK View Extensions Sample";
00066 static WCHAR*  gwszABOUT_PROVIDER    = L"Copyright © 1999 - 2001 Microsoft Corporation";
00067 static WCHAR*  gwszABOUT_VERSION     = L"2.0";
00068
00069 // VIEWEX:  Add this strings to support adding view extensions to the registry
00070 static TCHAR*  gtszCLSID_FOLDERNODE  = _T("{520F23FA-775D-4015-B437-98A24B9D085E}");
00071 static TCHAR*  gtszCLSID_MMCVIEWEX   = _T("{B708457E-DB61-4C55-A92F-0D4B5E9B1224}");
00072
00073 // We need to do this to get around MMC.IDL - it explicitly defines
00074 // the clipboard formats as WCHAR types...
00075 #define T_CCF_DISPLAY_NAME    _T("CCF_DISPLAY_NAME")
00076 #define T_CCF_NODETYPE        _T("CCF_NODETYPE")
00077 #define T_CCF_SZNODETYPE      _T("CCF_SZNODETYPE")
00078 #define T_CCF_SNAPIN_CLASSID  _T("CCF_SNAPIN_CLASSID")
00079
00080 #define T_CCF_BASENODE_PTR    _T("CCF_BASENODE_PTR")
00081 #define T_CCF_DATAOBJ_PTR     _T("CCF_DATAOBJ_PTR")
00082
00083 //---------------------------------------------------------------------------
00084 // Constants
00085
00086 #define NODETYPE_STATIC                100   // Node Types
00087 #define NODETYPE_DEVICE                200
00088 #define NODETYPE_FOLDER                300
00089 #define NODETYPE_VFILE                 400
00090
00091
00092 #define ATTRIBUTE_DATA_ARCHIVE         2     // Node Attributes
00093 #define ATTRIBUTE_DATA_HIDDEN          4
00094 #define ATTRIBUTE_DATA_LOCKED          8
00095 #define ATTRIBUTE_DATA_READONLY        16
00096 #define ATTRIBUTE_BACKUP_DEVICE        2048  //0xFFFF
00097
00098
00099 #define IMG_DEVICE_DEFAULT             0     // Image Indexes
00100 #define IMG_DEVICE_OFFLINE             1
00101 #define IMG_DATA_FILE                  2
00102 #define IMG_DRIVE_DEFAULT              3
00103 #define IMG_DRIVE_OFFLINE              4
00104 #define IMG_FOLDER_DEFAULT             5
00105 #define IMG_CDROM_DEFAULT              6
00106 #define IMG_REMOVABLE_MEDIA            7
00107
00108 #define IDM_NEW_DEVICE                 100
00109 #define IDM_NEW_FOLDER                 200
00110 #define IDM_TOGGLE_STATUS              300
00111 #define IDM_NEW_VIRTFILE               400   // RESULTITEM:  New menu
00112
00113 #define STATUS_ONLINE                  1
00114 #define STATUS_OFFLINE                 0
00115
00116 // Define some custom window messages so that objects running in
00117 // different threads can send us commands.
00118 //
00119 #define WM_DEL_DEVICENODES             (WM_USER + 100)
00120 #define WM_ADD_DEVICENODE              (WM_USER + 101)
00121 #define WM_DEVICENODE_CLOSED           (WM_USER + 102)
00122 #define WM_ADD_VIRTUALFILE             (WM_USER + 103)
00123 #define WM_VIRTUALFILE_CLOSED          (WM_USER + 104)
00124
00125
00126 // Defines interfaces which can be requested from IComponentData
00127 // or IComponet's ::GetInterface method
00128 //
00129 #define REQUEST_ICONSOLENAMESPACE      1000
00130 #define REQUEST_ICONSOLE               1001
00131 #define REQUEST_ICONSOLEVERB           1002
00132 #define REQUEST_IRESULTDATA            1003
00133 #define REQUEST_IHEADERCTRL            1004
00134
00135
00136 // Hints used with IConsole::UpdateAllViews
00137 //
00138 #define HINT_UPDATE_ITEM                2
00139 #define HINT_UPDATE_ALL_ITEMS           4
00140
00141
00142 /////////////////////////////////////////////////////////////////////////////
00143 // Helper classes and macros
00144
00145 #define BYTE_SIZE(string)          ((_tcslen(string)+1) * sizeof(TCHAR))
00146
00147 #define BREAK_ON_ERROR( hResult )  if( S_OK != hResult ) continue
00148
00149 // Useful only for debugging.  Never use modal dialogs in release builds!!
00150 #define MsgBox(wszMsg, wszTitle) ::MessageBox(NULL, wszMsg, wszTitle, MB_OK)
00151
00152
00153 //---------------------------------------------------------------------------
00154 template<class TYPE>
00155 inline void SAFE_RELEASE( TYPE*& pObj )
00156 {
00157   if( NULL != pObj )
00158   {
00159     pObj->Release();
00160     pObj = NULL;
00161   }
00162   else
00163   {
00164     OutputDebugString(_T("Attempted to release NULL Com pointer.\n"));
00165   }
00166 }
00167
00168 //---------------------------------------------------------------------------
00169 template<class TYPE>
00170 inline void SAFE_FREE_BITMAP( TYPE*& pObj )
00171 {
00172   if( NULL != pObj )
00173   {
00174     BOOL bStatus = DeleteObject( pObj );
00175     pObj = NULL;
00176   }
00177   else
00178   {
00179     OutputDebugString(_T("Attempted to delete NULL Bitmap handle.\n"));
00180   }
00181 }
00182
00183 //---------------------------------------------------------------------------
00184 template<class TYPE>
00185 inline void SAFE_FREE_ICON( TYPE*& pObj )
00186 {
00187   if( NULL != pObj )
00188   {
00189     BOOL bStatus = DestroyIcon( pObj );
00190     pObj = NULL;
00191   }
00192   else
00193   {
00194     OutputDebugString(_T("Attempted to delete NULL Icon handle.\n"));
00195   }
00196 }
00197
00198
00199
00200 //---------------------------------------------------------------------------
00201 //  W2T converts a wide character string to unicode if _UNICODE is not
00202 //  defined.  If it is defined then the sting is copied to another buffer.
00203 //
00204 #ifndef _UNICODE
00205 #define W2T( szAnsiPtr, szWide )   Unicode2Ansi( szAnsiPtr, szWide )
00206 #else
00207 #define W2T( szAnsiPtr, szWide )                                 \
00208         *szAnsiPtr = (WCHAR*)CoTaskMemAlloc(BYTE_SIZE(szWide) ); \
00209         CopyMemory( *szAnsiPtr, szWide, BYTE_SIZE(szWide) )
00210
00211 #endif //_UNICODE
00212
00213
00214 #endif //_MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

RECTI Member List

This is the complete list of members for RECTI, including all inherited members.
bottom | RECTI
left | RECTI
right | RECTI
top | RECTI
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

TableSelection Member List

This is the complete list of members for TableSelection, including all inherited members.
dyRowsFromTop | TableSelection
id | TableSelection
ncells | TableSelection
nrows | TableSelection
startcell | TableSelection
startrow | TableSelection
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStartupListener/resource.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStartupListener

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by MyStartupListener.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_MYSTARTUPLISTENER           101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerServe/PerServe.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerServe

PerServe.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PERSERVE.CPP
00003
00004   Summary:   Main implementation file for a DLL COM Component server
00005              providing a PageList COM Component. Access to Class Factories
00006              is provided in this module.  This module also supports self
00007              registration and unregistration for the components housed
00008              in the server.
00009
00010              For a comprehensive tutorial code tour of PERSERVE's contents
00011              and offerings see the tutorial PERSERVE.HTM file. For more
00012              specific technical details on the internal workings see the
00013              comments dispersed throughout the PERSERVE source code. For
00014              more details on how PERSERVE's components are functioned by
00015              the PERCLIEN client see PERCLIEN.HTM in the main tutorial
00016              directory.
00017
00018   Classes:   none.
00019
00020   Functions: DllMain, DllGetClassObject, DllCanUnloadNow, DllRegisterServer,
00021              DllUnregisterServer.
00022
00023   Origin:    5-18-97: atrent - Editor-inheritance from STOSERVE.CPP in
00024                the STOSERVE Tutorial Code Sample.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 /*---------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will be calling the COM/OLE Libraries.
00044   We include INITGUID.H only once (here) in the entire DLL because we
00045     will be defining GUIDs and want them as constants in the data segment.
00046   We include APPUTIL.H because we will be building this DLL using
00047     the convenient Virtual Window and Dialog classes and other
00048     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00049   We include IPAGES.H and PAGEGUID.H for the common PageList-related
00050     Interface class, GUID, and CLSID specifications.
00051   We include PERSERVE.H because it has the _DLLEXPORT_ controlled import
00052     and export specifications.
00053   We include SERVER.H because it has internal class declarations for
00054     the server's control object.
00055   We include FACTORY.H because it has the necessary internal class factory
00056     declarations for this DLL component server.
00057 ---------------------------------------------------------------------------*/
00058 #include <windows.h>
00059 #include <ole2.h>
00060 #include <initguid.h>
00061 #include <apputil.h>
00062 #include <ipages.h>
00063 #include <pageguid.h>
00064 #define _DLLEXPORT_
00065 #include "perserve.h"
00066 #include "server.h"
00067 #include "factory.h"
00068
00069
00070 // Global variable definitions. Some Initialized in DllMain() below.
00071
00072 // We encapsulate the control of this COM server (eg, lock and object
00073 // counting) in a server control C++ object. Here is it's global pointer.
00074 CServer* g_pServer = NULL;
00075
00076
00077 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00078   Function: UnicodeOk
00079
00080   Summary:  Checks if the platform will handle unicode versions of
00081             Win32 string API calls.
00082
00083   Args:     void
00084
00085   Returns:  BOOL
00086               TRUE if unicode support; FALSE if not.
00087 ------------------------------------------------------------------------F-F*/
00088 BOOL UnicodeOk(void)
00089 {
00090   BOOL bOk = TRUE;
00091   TCHAR szUserName[MAX_STRING_LENGTH];
00092   DWORD dwSize = MAX_STRING_LENGTH;
00093
00094   if (!GetUserName(szUserName, &dwSize))
00095     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00096
00097   return bOk;
00098 }
00099
00100
00101 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00102   Function: DllMain
00103
00104   Summary:  Just as WinMain is for an EXE application, this DllMain
00105             function is the main entry point for this DLL.  It is called
00106             when the DLL is loaded by a process, and when new threads are
00107             created by a process that has already loaded this DLL.
00108             DllMain is also called when threads of a process that has
00109             loaded the DLL exit cleanly and when the process itself
00110             unloads the DLL.
00111
00112             If you want to use C runtime libraries, keep this function
00113             named "DllMain" and you won't have to do anything special to
00114             initialize the runtime libraries.
00115
00116             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
00117             to determine if the DLL should remain loaded, or should be
00118             immediately unloaded depending upon whether the DLL could be
00119             initialized properly.  For all other values of fdwReason, the
00120             return value is ignored.
00121
00122   Args:     HINSTANCE hDLLInst,
00123               Instance handle of the DLL.
00124             DWORD fdwReason,
00125               Process attach/detach or thread attach/detach.
00126               Reason for calling.
00127             LPVOID lpvReserved)
00128               Reserved and not used.
00129
00130   Returns:  BOOL,
00131               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
00132               TRUE  -  Used to signify that the DLL should remain loaded.
00133               FALSE -  Used to signify that the DLL should be
00134                 immediately unloaded.
00135 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00136 BOOL WINAPI DllMain(
00137               HINSTANCE hDllInst,
00138               DWORD fdwReason,
00139               LPVOID lpvReserved)
00140 {
00141   BOOL bResult = TRUE;
00142
00143   // Dispatch this main call based on the reason it was called.
00144   switch (fdwReason)
00145   {
00146     case DLL_PROCESS_ATTACH:
00147       // The DLL is being loaded for the first time by a given process.
00148       // Perform per-process initialization here.  If the initialization
00149       // is successful, return TRUE; if unsuccessful, return FALSE.
00150       bResult = FALSE;
00151       if (UnicodeOk())
00152       {
00153         // Instantiate the CServer utility class.
00154         g_pServer = new CServer;
00155         if (NULL != g_pServer)
00156         {
00157           // Remember the DLL Instance handle.
00158           g_pServer->m_hDllInst = hDllInst;
00159           bResult = TRUE;
00160         }
00161       }
00162       break;
00163
00164     case DLL_PROCESS_DETACH:
00165       // The DLL is being unloaded by a given process.  Do any
00166       // per-process clean up here, such as undoing what was done in
00167       // DLL_PROCESS_ATTACH.  The return value is ignored.
00168       DELETE_POINTER(g_pServer);
00169       break;
00170
00171     case DLL_THREAD_ATTACH:
00172       // A thread is being created in a process that has already loaded
00173       // this DLL.  Perform any per-thread initialization here.  The
00174       // return value is ignored.
00175       break;
00176
00177     case DLL_THREAD_DETACH:
00178       // A thread is exiting cleanly in a process that has already
00179       // loaded this DLL.  Perform any per-thread clean up here.  The
00180       // return value is ignored.
00181       break;
00182
00183     default:
00184       break;
00185   }
00186
00187   return (bResult);
00188 }
00189
00190
00191 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00192   Function: DllGetClassObject
00193
00194   Summary:  The standard exported function that the COM service library
00195             uses to obtain the class factory for a specified component
00196             provided by this server DLL.
00197
00198   Args:     REFCLSID rclsid,
00199               [in] The CLSID of the requested Component.
00200             REFIID riid,
00201               [in] GUID of the requested interface on the Class Factory.
00202             PPVOID ppv)
00203               [out] Address of the caller's pointer variable that will
00204               receive the requested interface pointer.
00205
00206   Returns:  HRESULT
00207               E_FAIL if requested component isn't supported.
00208               E_OUTOFMEMORY if out of memory.
00209               Error code out of the QueryInterface.
00210 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00211 STDAPI DllGetClassObject(
00212          REFCLSID rclsid,
00213          REFIID riid,
00214          PPVOID ppv)
00215 {
00216   HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
00217   IUnknown* pCO = NULL;
00218
00219   if (CLSID_PageList == rclsid)
00220   {
00221     hr = E_OUTOFMEMORY;
00222     pCO = new CFPageList(NULL, g_pServer);
00223   }
00224
00225   if (NULL != pCO)
00226   {
00227     g_pServer->ObjectsUp();
00228     hr = pCO->QueryInterface(riid, ppv);
00229     if (FAILED(hr))
00230     {
00231       g_pServer->ObjectsDown();
00232       DELETE_POINTER(pCO);
00233     }
00234   }
00235
00236   return hr;
00237 }
00238
00239
00240 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00241   Function: DllCanUnloadNow
00242
00243   Summary:  The standard exported function that the COM service library
00244             uses to determine if this server DLL can be unloaded.
00245
00246   Args:     void.
00247
00248   Returns:  HRESULT
00249               S_OK if this DLL server can be unloaded.
00250               S_FALSE if this DLL can not be unloaded.
00251 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00252 STDAPI DllCanUnloadNow(void)
00253 {
00254   HRESULT hr;
00255
00256   // We return S_OK if there are no longer any living objects AND
00257   // there are no outstanding client locks on this server.
00258   hr = g_pServer->CanUnloadNow();
00259
00260   return hr;
00261 }
00262
00263
00264 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00265   Function: DllRegisterServer
00266
00267   Summary:  The standard exported function that can be called to command
00268             this DLL server to register its components in the system
00269             registry.
00270
00271   Args:     void.
00272
00273   Returns:  HRESULT
00274               NOERROR
00275 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00276 STDAPI DllRegisterServer(void)
00277 {
00278   HRESULT  hr = NOERROR;
00279   TCHAR    szID[GUID_SIZE+1];
00280   TCHAR    szCLSID[GUID_SIZE+32];
00281   TCHAR    szModulePath[MAX_PATH];
00282
00283   // Obtain the path to this module's executable file for later use.
00284   GetModuleFileName(
00285     g_pServer->m_hDllInst,
00286     szModulePath,
00287     sizeof(szModulePath)/sizeof(TCHAR));
00288
00289   /*-------------------------------------------------------------------------
00290     Create registry entries for the PageList Component.
00291   -------------------------------------------------------------------------*/
00292   // Create some base key strings.
00293   StringFromGUID2(CLSID_PageList, szID, GUID_SIZE);
00294   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00295   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00296
00297   // Create ProgID keys.
00298   SetRegKeyValue(
00299     TEXT("CTS.PageList.1"),
00300     NULL,
00301     TEXT("PageList Component - PERSERVE Code Sample"));
00302   SetRegKeyValue(
00303     TEXT("CTS.PageList.1"),
00304     TEXT("CLSID"),
00305     szID);
00306
00307   // Create VersionIndependentProgID keys.
00308   SetRegKeyValue(
00309     TEXT("CTS.PageList"),
00310     NULL,
00311     TEXT("PageList Component - PERSERVE Code Sample"));
00312   SetRegKeyValue(
00313     TEXT("CTS.PageList"),
00314     TEXT("CurVer"),
00315     TEXT("CTS.PageList.1"));
00316   SetRegKeyValue(
00317     TEXT("CTS.PageList"),
00318     TEXT("CLSID"),
00319     szID);
00320
00321   // Create entries under CLSID.
00322   SetRegKeyValue(
00323     szCLSID,
00324     NULL,
00325     TEXT("PageList Component - PERSERVE Code Sample"));
00326   SetRegKeyValue(
00327     szCLSID,
00328     TEXT("ProgID"),
00329     TEXT("CTS.PageList.1"));
00330   SetRegKeyValue(
00331     szCLSID,
00332     TEXT("VersionIndependentProgID"),
00333     TEXT("CTS.PageList"));
00334   SetRegKeyValue(
00335     szCLSID,
00336     TEXT("NotInsertable"),
00337     NULL);
00338   SetRegKeyValue(
00339     szCLSID,
00340     TEXT("InprocServer32"),
00341     szModulePath);
00342   AddRegNamedValue(
00343     szCLSID,
00344     TEXT("InprocServer32"),
00345     TEXT("ThreadingModel"),
00346     TEXT("Apartment"));
00347
00348   return hr;
00349 }
00350
00351
00352 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00353   Function: DllUnregisterServer
00354
00355   Summary:  The standard exported function that can be called to command
00356             this DLL server to unregister its components from the system
00357             Registry.
00358
00359   Args:     void.
00360
00361   Returns:  HRESULT
00362               NOERROR
00363 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00364 STDAPI DllUnregisterServer(void)
00365 {
00366   HRESULT  hr = NOERROR;
00367   TCHAR    szID[GUID_SIZE+1];
00368   TCHAR    szCLSID[GUID_SIZE+32];
00369   TCHAR    szTemp[MAX_PATH+GUID_SIZE];
00370
00371   /*-------------------------------------------------------------------------
00372     Delete registry entries for the PageList Component.
00373   -------------------------------------------------------------------------*/
00374   //Create some base key strings.
00375   StringFromGUID2(CLSID_PageList, szID, GUID_SIZE);
00376   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00377   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00378
00379   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.PageList\\CurVer"));
00380   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.PageList\\CLSID"));
00381   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.PageList"));
00382
00383   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.PageList.1\\CLSID"));
00384   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.PageList.1"));
00385
00386   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00387   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00388
00389   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00390   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00391
00392   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00393   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00394
00395   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00396   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00397
00398   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00399
00400   return hr;
00401 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/globals.h Source File

  • WinUI
  • tsfapp

globals.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Globals.h
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 #ifndef GLOBALS_H
00019 #define GLOBALS_H
00020
00021 /**************************************************************************
00022    #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <msctf.h>
00027
00028 /**************************************************************************
00029    function prototypes
00030 **************************************************************************/
00031
00032 /**************************************************************************
00033    global variables and definitions
00034 **************************************************************************/
00035
00036 extern ITfThreadMgr *g_pThreadMgr;
00037
00038 #define ARRAYSIZE(a)    (sizeof(a)/sizeof(a[0]))
00039
00040 #endif //GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/tmgrsink.cpp Source File

  • WinUI
  • TSFcase

tmgrsink.cpp

Go to the documentation of this file.
00001 //
00002 // tmgrsink.cpp
00003 //
00004 // ITfThreadMgrEventSink implementation.
00005 //
00006
00007 #include "globals.h"
00008 #include "case.h"
00009 #include "snoop.h"
00010
00011 //+---------------------------------------------------------------------------
00012 //
00013 // OnInitDocumentMgr
00014 //
00015 // Sink called by the framework just before the first context is pushed onto
00016 // a document.
00017 //----------------------------------------------------------------------------
00018
00019 STDAPI CCaseTextService::OnInitDocumentMgr(ITfDocumentMgr *pDocMgr)
00020 {
00021     return S_OK;
00022 }
00023
00024 //+---------------------------------------------------------------------------
00025 //
00026 // OnUninitDocumentMgr
00027 //
00028 // Sink called by the framework just after the last context is popped off a
00029 // document.
00030 //----------------------------------------------------------------------------
00031
00032 STDAPI CCaseTextService::OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr)
00033 {
00034     return S_OK;
00035 }
00036
00037 //+---------------------------------------------------------------------------
00038 //
00039 // OnSetFocus
00040 //
00041 // Sink called by the framework when focus changes from one document to
00042 // another.  Either document may be NULL, meaning previously there was no
00043 // focus document, or now no document holds the input focus.
00044 //----------------------------------------------------------------------------
00045
00046 STDAPI CCaseTextService::OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus)
00047 {
00048     // track text changes on the focus doc
00049     // we are guarenteed a final OnSetFocus(NULL, ..) which we use for cleanup
00050     _InitTextEditSink(pDocMgrFocus);
00051
00052     // let's update the snoop window with text from the new focus context
00053     _pSnoopWnd->_UpdateText(NULL);
00054     return S_OK;
00055 }
00056
00057 //+---------------------------------------------------------------------------
00058 //
00059 // OnPushContext
00060 //
00061 // Sink called by the framework when a context is pushed.
00062 //----------------------------------------------------------------------------
00063
00064 STDAPI CCaseTextService::OnPushContext(ITfContext *pContext)
00065 {
00066     return S_OK;
00067 }
00068
00069 //+---------------------------------------------------------------------------
00070 //
00071 // OnPopContext
00072 //
00073 // Sink called by the framework when a context is popped.
00074 //----------------------------------------------------------------------------
00075
00076 STDAPI CCaseTextService::OnPopContext(ITfContext *pContext)
00077 {
00078     return S_OK;
00079 }
00080
00081 //+---------------------------------------------------------------------------
00082 //
00083 // _InitThreadMgrSink
00084 //
00085 // Advise our sink.
00086 //----------------------------------------------------------------------------
00087
00088 BOOL CCaseTextService::_InitThreadMgrSink()
00089 {
00090     ITfSource *pSource;
00091     BOOL fRet;
00092
00093     if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) != S_OK)
00094         return FALSE;
00095
00096     fRet = FALSE;
00097
00098     if (pSource->AdviseSink(IID_ITfThreadMgrEventSink, (ITfThreadMgrEventSink *)this, &_dwThreadMgrEventSinkCookie) != S_OK)
00099     {
00100         // make sure we don't try to Unadvise _dwThreadMgrEventSinkCookie later
00101         _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
00102         goto Exit;
00103     }
00104
00105     fRet = TRUE;
00106
00107 Exit:
00108     pSource->Release();
00109     return fRet;
00110 }
00111
00112 //+---------------------------------------------------------------------------
00113 //
00114 // _UninitThreadMgrSink
00115 //
00116 // Unadvise our sink.
00117 //----------------------------------------------------------------------------
00118
00119 void CCaseTextService::_UninitThreadMgrSink()
00120 {
00121     ITfSource *pSource;
00122
00123     if (_dwThreadMgrEventSinkCookie == TF_INVALID_COOKIE)
00124         return; // never Advised
00125
00126     if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK)
00127     {
00128         pSource->UnadviseSink(_dwThreadMgrEventSinkCookie);
00129         pSource->Release();
00130     }
00131
00132     _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
00133 }
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/resource.h Source File

  • SysMgmt
  • MMC
  • CMenu

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Resources.rc
00004 //
00005 #define IDS_HELPFILE                    1
00006 #define IDS_SNAPINDESC                  2
00007 #define IDS_NAME                        3
00008 #define IDS_SNAPINNAME                  6
00009 #define IDS_ABOUTNAME                   9
00010 #define IDI_ICON1                       108
00011 #define IDR_SMICONS                     120
00012 #define IDR_LGICONS                     121
00013 #define IDB_SMOPEN                      124
00014 #define IDB_SMBMP                       125
00015 #define IDB_LGBMP                       126
00016 #define IDB_ROCKET                      40004
00017 #define IDB_CAR                         40005
00018 #define IDB_PLANE                       40006
00019 #define IDB_BIKE                        40007
00020 #define IDB_ROCKET2                     40008
00021 #define IDB_CAR2                        40009
00022 #define IDB_PLANE2                      40010
00023 #define IDB_BIKE2                       40011
00024 #define IDB_CLOSED2                     40012
00025 #define IDB_OPEN2                       40013
00026 #define IDB_CLOSED                      40014
00027 #define IDB_OPEN                        40015
00028 #define ID_BUTTON40016                  40016
00029 #define ID_BUTTON40017                  40017
00030 #define ID_BUTTON40018                  40018
00031 #define ID_BUTTON40019                  40019
00032 #define ID_BUTTON40020                  40020
00033 #define ID_BUTTON40021                  40021
00034 #define ID_BUTTON40022                  40022
00035 #define ID_BUTTON40023                  40023
00036 #define ID_BUTTON40024                  40024
00037 #define ID_BUTTON40025                  40025
00038 #define ID_BUTTON40026                  40026
00039
00040 // Next default values for new objects
00041 //
00042 #ifdef APSTUDIO_INVOKED
00043 #ifndef APSTUDIO_READONLY_SYMBOLS
00044 #define _APS_NEXT_RESOURCE_VALUE        127
00045 #define _APS_NEXT_COMMAND_VALUE         40027
00046 #define _APS_NEXT_CONTROL_VALUE         1000
00047 #define _APS_NEXT_SYMED_VALUE           101
00048 #endif
00049 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/guids.h Source File

  • SysMgmt
  • MMC
  • Menubtn

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {3684860C-8A36-11d2-8A0A-000021473128}
00020 DEFINE_GUID(CLSID_CComponentData,
00021             0x3684860c, 0x8a36, 0x11d2, 0x8a, 0xa, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28);
00022
00023 // {3684860F-8A36-11d2-8A0A-000021473128}
00024 DEFINE_GUID(CLSID_CSnapinAbout,
00025             0x3684860f, 0x8a36, 0x11d2, 0x8a, 0xa, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/app.Cpp Source File

  • Com
  • Fundamentals
  • SimpDnd

app.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: app.cpp
00003 //
00004 //    Implementation file for the CSimpleApp Class
00005 //
00006 // Functions:
00007 //
00008 //    See app.h for a list of member functions.
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "app.h"
00017 #include "site.h"
00018 #include "doc.h"
00019
00020 //**********************************************************************
00021 //
00022 // CSimpleApp::CSimpleApp()
00023 //
00024 // Purpose:
00025 //
00026 //      Constructor for CSimpleApp
00027 //
00028 // Parameters:
00029 //
00030 //      None
00031 //
00032 // Return Value:
00033 //
00034 //      None
00035 //
00036 // Function Calls:
00037 //      Function                    Location
00038 //
00039 //      OutputDebugString           Windows API
00040 //      SetRectEmpty                Windows API
00041 //
00042 // Comments:
00043 //
00044 //********************************************************************
00045 CSimpleApp::CSimpleApp()
00046 {
00047         OutputDebugString("In CSimpleApp's Constructor \r\n");
00048
00049         // clear members
00050         m_hAppWnd = NULL;
00051         m_hInst = NULL;
00052         m_lpDoc = NULL;
00053
00054         // clear flags
00055         m_fInitialized = FALSE;
00056         m_fOleStdInit = FALSE;
00057 }
00058
00059 //**********************************************************************
00060 //
00061 // CSimpleApp::~CSimpleApp()
00062 //
00063 // Purpose:
00064 //
00065 //      Destructor for CSimpleApp Class.
00066 //
00067 // Parameters:
00068 //
00069 //      None
00070 //
00071 // Return Value:
00072 //
00073 //      None
00074 //
00075 // Function Calls:
00076 //      Function                    Location
00077 //
00078 //      OutputDebugString           Windows API
00079 //      OleUninitialize             OLE API
00080 //
00081 // Comments:
00082 //
00083 //********************************************************************
00084
00085 CSimpleApp::~CSimpleApp()
00086 {
00087         OutputDebugString("In CSimpleApp's Destructor\r\n");
00088
00089         // need to uninit the library...
00090         if (m_fOleStdInit)
00091                 OleStdUninitialize();
00092         if (m_fInitialized)
00093                 OleUninitialize();
00094 }
00095
00096 //**********************************************************************
00097 //
00098 // CSimpleApp::DestroyDocs()
00099 //
00100 // Purpose:
00101 //
00102 //      Destroys all of the open documents in the application (Only one
00103 //      since this is an SDI app, but could easily be modified to
00104 //      support MDI).
00105 //
00106 // Parameters:
00107 //
00108 //      None
00109 //
00110 // Return Value:
00111 //
00112 //      None
00113 //
00114 // Function Calls:
00115 //      Function                    Location
00116 //
00117 // Comments:
00118 //
00119 //********************************************************************
00120
00121 void CSimpleApp::DestroyDocs()
00122 {
00123         CStabilize stabilize(this);
00124         m_lpDoc->Close();   // we have only 1 document
00125 }
00126
00127 //**********************************************************************
00128 //
00129 // CSimpleApp::QueryInterface
00130 //
00131 // Purpose:
00132 //
00133 //      Used for interface negotiation at the Frame level.
00134 //
00135 // Parameters:
00136 //
00137 //      REFIID riid         -   A reference to the interface that is
00138 //                              being queried.
00139 //
00140 //      LPVOID FAR* ppvObj  -   An out parameter to return a pointer to
00141 //                              the interface.
00142 //
00143 // Return Value:
00144 //
00145 //      S_OK    -   The interface is supported.
00146 //      S_FALSE -   The interface is not supported
00147 //
00148 // Function Calls:
00149 //      Function                    Location
00150 //
00151 //      OutputDebugString           Windows API
00152 //                   OLE API
00153 //
00154 // Comments:
00155 //
00156 //********************************************************************
00157
00158 STDMETHODIMP CSimpleApp::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00159 {
00160         OutputDebugString("In CSimpleApp::QueryInterface\r\n");
00161
00162         *ppvObj = NULL;     // must set out pointer parameters to NULL
00163
00164         // Not a supported interface
00165         return E_NOINTERFACE;
00166 }
00167
00168 //**********************************************************************
00169 //
00170 // CSimpleApp::AddRef
00171 //
00172 // Purpose:
00173 //
00174 //      Adds to the reference count at the Application level.
00175 //
00176 // Parameters:
00177 //
00178 //      None
00179 //
00180 // Return Value:
00181 //
00182 //      ULONG   -   The new reference count of the application.
00183 //
00184 // Function Calls:
00185 //      Function                    Location
00186 //
00187 //      OutputDebugString           Windows API
00188 //
00189 // Comments:
00190 //
00191 //      Due to the reference counting model that is used in this
00192 //      implementation, this reference count is the sum of the
00193 //      reference counts on all interfaces of all objects open
00194 //      in the application.
00195 //
00196 //********************************************************************
00197
00198 STDMETHODIMP_(ULONG) CSimpleApp::AddRef()
00199 {
00200         OutputDebugString("In CSimpleApp::AddRef\r\n");
00201         return SafeAddRef();
00202 }
00203
00204 //**********************************************************************
00205 //
00206 // CSimpleApp::Release
00207 //
00208 // Purpose:
00209 //
00210 //      Decrements the reference count at this level
00211 //
00212 // Parameters:
00213 //
00214 //      None
00215 //
00216 // Return Value:
00217 //
00218 //      ULONG   -   The new reference count of the application.
00219 //
00220 // Function Calls:
00221 //      Function                    Location
00222 //
00223 //      OutputDebugString           Windows API
00224 //
00225 // Comments:
00226 //
00227 //********************************************************************
00228
00229 STDMETHODIMP_(ULONG) CSimpleApp::Release()
00230 {
00231         OutputDebugString("In CSimpleApp::Release\r\n");
00232
00233         return SafeRelease();
00234 }
00235
00236 //**********************************************************************
00237 //
00238 // CSimpleApp::fInitApplication
00239 //
00240 // Purpose:
00241 //
00242 //      Initializes the application
00243 //
00244 // Parameters:
00245 //
00246 //      HANDLE hInstance    -   Instance handle of the application.
00247 //
00248 // Return Value:
00249 //
00250 //      TRUE    -   Application was successfully initialized.
00251 //      FALSE   -   Application could not be initialized
00252 //
00253 // Function Calls:
00254 //      Function                    Location
00255 //
00256 //      LoadIcon                    Windows API
00257 //      LoadCursor                  Windows API
00258 //      GetStockObject              Windows API
00259 //      RegisterClass               Windows API
00260 //
00261 // Comments:
00262 //
00263 //********************************************************************
00264
00265 BOOL CSimpleApp::fInitApplication(HANDLE hInstance)
00266 {
00267         WNDCLASS  wc;
00268         CStabilize stabilize(this);
00269
00270         // Fill in window class structure with parameters that describe the
00271         // main window.
00272
00273         wc.style = NULL;                    // Class style(s).
00274         wc.lpfnWndProc = MainWndProc;       // Function to retrieve messages for
00275                                                                                 // windows of this class.
00276         wc.cbClsExtra = 0;                  // No per-class extra data.
00277         wc.cbWndExtra = 0;                  // No per-window extra data.
00278         wc.hInstance = (HINSTANCE) hInstance; // Application that owns the class.
00279         wc.hIcon = LoadIcon((HINSTANCE) hInstance,"SimpDnd");
00280         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00281         wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00282         wc.lpszMenuName =  "SIMPLEMENU";    // Name of menu resource in .RC file.
00283         wc.lpszClassName = "SimpDndAppWClass";  // Name used in CreateWindow call.
00284
00285         if (!RegisterClass(&wc))
00286                 return FALSE;
00287
00288         wc.style = CS_DBLCLKS;              // Class style(s). allow DBLCLK's
00289         wc.lpfnWndProc = DocWndProc;        // Function to retrieve messages for
00290                                                                                 // windows of this class.
00291         wc.cbClsExtra = 0;                  // No per-class extra data.
00292         wc.cbWndExtra = 0;                  // No per-window extra data.
00293         wc.hInstance = (HINSTANCE) hInstance; // Application that owns the class.
00294         wc.hIcon = NULL;
00295         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00296         wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00297         wc.lpszMenuName =  NULL;
00298         wc.lpszClassName = "SimpDndDocWClass"; // Name used in CreateWindow call.
00299
00300         // Register the window class and return success/failure code.
00301
00302         return (RegisterClass(&wc));
00303 }
00304
00305 //**********************************************************************
00306 //
00307 // CSimpleApp::fInitInstance
00308 //
00309 // Purpose:
00310 //
00311 //      Instance initialization.
00312 //
00313 // Parameters:
00314 //
00315 //      HANDLE hInstance    -   App. Instance Handle.
00316 //
00317 //      int nCmdShow        -   Show parameter from WinMain
00318 //
00319 // Return Value:
00320 //
00321 //      TRUE    -   Initialization Successful
00322 //      FALSE   -   Initialization Failed.
00323 //
00324 //
00325 // Function Calls:
00326 //      Function                    Location
00327 //
00328 //      CreateWindow                Windows API
00329 //      ShowWindow                  Windows API
00330 //      UpdateWindow                Windows API
00331 //      OleBuildVersion             OLE API
00332 //      OleInitialize               OLE API
00333 //
00334 // Comments:
00335 //
00336 //      Note that successful Initalization of the OLE libraries
00337 //      is remembered so the UnInit is only called if needed.
00338 //
00339 //********************************************************************
00340
00341 BOOL CSimpleApp::fInitInstance (HANDLE hInstance, int nCmdShow)
00342 {
00343         CStabilize stabilize(this);
00344         DWORD dwVer = OleBuildVersion();
00345         LPMALLOC lpMalloc = NULL;
00346
00347         // check to see if we are compatible with this version of the libraries
00348         if (HIWORD(dwVer) != rmm || LOWORD(dwVer) < rup) {
00349 #ifdef _DEBUG
00350                 OutputDebugString("WARNING: Incompatible OLE library version\r\n");
00351 #else
00352                 return FALSE;
00353 #endif
00354         }
00355
00356         if (SUCCEEDED(OleInitialize(NULL)))
00357         {
00358             m_fInitialized = TRUE;
00359         }
00360
00361         m_fOleStdInit = OleStdInitialize((HINSTANCE) hInstance);
00362         OleDbgSetDbgLevel(10);
00363
00364         m_hInst = (HINSTANCE) hInstance;
00365
00366         // Create the "application" windows
00367         m_hAppWnd = CreateWindow ("SimpDndAppWClass",
00368                                                           "Simple OLE 2.0 Drag/Drop Container",
00369                                                           WS_OVERLAPPEDWINDOW,
00370                                                           CW_USEDEFAULT,
00371                                                           CW_USEDEFAULT,
00372                                                           CW_USEDEFAULT,
00373                                                           CW_USEDEFAULT,
00374                                                           NULL,
00375                                                           NULL,
00376                                                           (HINSTANCE) hInstance,
00377                                                           NULL);
00378
00379         if (!m_hAppWnd)
00380                 return FALSE;
00381
00382         // delay before dragging should start, in milliseconds
00383         m_nDragDelay = GetProfileInt(
00384                         "windows",
00385                         "DragDelay",
00386                         DD_DEFDRAGDELAY
00387         );
00388
00389         // minimum distance (radius) before drag should start, in pixels
00390         m_nDragMinDist = GetProfileInt(
00391                         "windows",
00392                         "DragMinDist",
00393                         DD_DEFDRAGMINDIST
00394         );
00395
00396         // delay before scrolling, in milliseconds
00397         m_nScrollDelay = GetProfileInt(
00398                         "windows",
00399                         "DragScrollDelay",
00400                         DD_DEFSCROLLDELAY
00401         );
00402
00403         // inset-width of the hot zone, in pixels
00404         m_nScrollInset = GetProfileInt(
00405                         "windows",
00406                         "DragScrollInset",
00407                         DD_DEFSCROLLINSET
00408         );
00409
00410         // scroll interval, in milliseconds
00411         m_nScrollInterval = GetProfileInt(
00412                         "windows",
00413                         "DragScrollInterval",
00414                         DD_DEFSCROLLINTERVAL
00415         );
00416
00417         ShowWindow (m_hAppWnd, nCmdShow);
00418         UpdateWindow (m_hAppWnd);
00419
00420         return m_fInitialized && m_fOleStdInit;
00421 }
00422
00423 //**********************************************************************
00424 //
00425 // CSimpleApp::lCommandHandler
00426 //
00427 // Purpose:
00428 //
00429 //      Handles the processing of WM_COMMAND.
00430 //
00431 // Parameters:
00432 //
00433 //      HWND hWnd       -   Handle to the application Window
00434 //
00435 //      UINT message    -   message (always WM_COMMAND)
00436 //
00437 //      WPARAM wParam   -   Same as passed to the WndProc
00438 //
00439 //      LPARAM lParam   -   Same as passed to the WndProc
00440 //
00441 // Return Value:
00442 //
00443 //      NULL
00444 //
00445 // Function Calls:
00446 //      Function                                    Location
00447 //
00448 //      IOleObject::DoVerb                          Object
00449 //      GetClientRect                               Windows API
00450 //      MessageBox                                  Windows API
00451 //      DialogBox                                   Windows API
00452 //      MakeProcInstance                            Windows API
00453 //      FreeProcInstance                            Windows API
00454 //      SendMessage                                 Windows API
00455 //      DefWindowProc                               Windows API
00456 //      CSimpleDoc::InsertObject                    DOC.CPP
00457 //
00458 // Comments:
00459 //
00460 //********************************************************************
00461
00462 long CSimpleApp::lCommandHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00463 {
00464         RECT rect;
00465         CStabilize stabilize(this);
00466
00467         // see if the command is a verb selections
00468         //@@WTK WIN32, UNICODE
00469         //if (wParam >= IDM_VERB0)
00470         if (LOWORD(wParam) >= IDM_VERB0)
00471                 {
00472                 // get the rectangle of the object
00473                 m_lpDoc->m_lpSite->GetObjRect(&rect);
00474
00475                 m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(
00476                                 LOWORD(wParam) - IDM_VERB0, NULL,
00477                                 &m_lpDoc->m_lpSite->m_OleClientSite, -1,
00478                                 m_lpDoc->m_hDocWnd, &rect);
00479                 }
00480         else
00481                 {
00482                 //@@WTK WIN32, UNICODE
00483                 //switch (wParam) {
00484                 switch (LOWORD(wParam)) {
00485                         // bring up the About box
00486                         case IDM_ABOUT:
00487                                 {
00488
00489                                 DialogBox(m_hInst,               // current instance
00490                                         "AboutBox",                  // resource to use
00491                                         m_hAppWnd,                   // parent handle
00492                                         (DLGPROC) About);                // About() instance address
00493
00494                                 break;
00495                                 }
00496
00497                         // bring up the InsertObject Dialog
00498                         case IDM_INSERTOBJECT:
00499                                 m_lpDoc->InsertObject();
00500                                 break;
00501
00502                         // Copy the object to the Clipboard
00503                         case IDM_COPY:
00504                                 m_lpDoc->CopyObjectToClip();
00505                                 break;
00506
00507                         // exit the application
00508                         case IDM_EXIT:
00509                                 SendMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
00510                                 break;
00511
00512                         case IDM_NEW:
00513                                 m_lpDoc->Close();
00514                                 m_lpDoc = NULL;
00515                                 lCreateDoc(hWnd, 0, 0, 0);
00516                                 break;
00517
00518                         default:
00519                                 return (DefWindowProc(hWnd, message, wParam, lParam));
00520                         }   // end of switch
00521                 }  // end of else
00522         return NULL;
00523 }
00524
00525 //**********************************************************************
00526 //
00527 // CSimpleApp::lSizeHandler
00528 //
00529 // Purpose:
00530 //
00531 //      Handles the WM_SIZE message
00532 //
00533 // Parameters:
00534 //
00535 //      HWND hWnd       -   Handle to the application Window
00536 //
00537 //      UINT message    -   message (always WM_SIZE)
00538 //
00539 //      WPARAM wParam   -   Same as passed to the WndProc
00540 //
00541 //      LPARAM lParam   -   Same as passed to the WndProc
00542 //
00543 // Return Value:
00544 //
00545 //      LONG    -   returned from the "document" resizing
00546 //
00547 // Function Calls:
00548 //      Function                    Location
00549 //
00550 //      GetClientRect               Windows API
00551 //      CSimpleDoc::lResizeDoc      DOC.CPP
00552 //
00553 // Comments:
00554 //
00555 //********************************************************************
00556
00557 long CSimpleApp::lSizeHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00558 {
00559         RECT rect;
00560
00561         CStabilize stabilize(this);
00562         GetClientRect(m_hAppWnd, &rect);
00563         return m_lpDoc->lResizeDoc(&rect);
00564 }
00565
00566 //**********************************************************************
00567 //
00568 // CSimpleApp::lCreateDoc
00569 //
00570 // Purpose:
00571 //
00572 //      Handles the creation of a document.
00573 //
00574 // Parameters:
00575 //
00576 //      HWND hWnd       -   Handle to the application Window
00577 //
00578 //      UINT message    -   message (always WM_CREATE)
00579 //
00580 //      WPARAM wParam   -   Same as passed to the WndProc
00581 //
00582 //      LPARAM lParam   -   Same as passed to the WndProc
00583 //
00584 // Return Value:
00585 //
00586 //      NULL
00587 //
00588 // Function Calls:
00589 //      Function                    Location
00590 //
00591 //      GetClientRect               Windows API
00592 //      CSimpleDoc::CSimpleDoc      DOC.CPP
00593 //
00594 // Comments:
00595 //
00596 //********************************************************************
00597
00598 long CSimpleApp::lCreateDoc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00599 {
00600         RECT rect;
00601
00602         CStabilize stabilize(this);
00603         GetClientRect(hWnd, &rect);
00604
00605         m_lpDoc = CSimpleDoc::Create(this, &rect, hWnd);
00606
00607         return NULL;
00608 }
00609
00610 //**********************************************************************
00611 //
00612 // CSimpleApp::HandleAccelerators
00613 //
00614 // Purpose:
00615 //
00616 //      To properly handle accelerators in the Message Loop
00617 //
00618 // Parameters:
00619 //
00620 //      LPMSG lpMsg -   A pointer to the message structure.
00621 //
00622 // Return Value:
00623 //
00624 //      TRUE    -   The accelerator was handled
00625 //      FALSE   -   The accelerator was not handled
00626 //
00627 // Function Calls:
00628 //      Function                                        Location
00629 //
00630 // Comments:
00631 //
00632 //********************************************************************
00633
00634 BOOL CSimpleApp::HandleAccelerators(LPMSG lpMsg)
00635 {
00636         BOOL retval = FALSE;
00637
00638         // we do not have any accelerators
00639
00640         return retval;
00641 }
00642
00643 //**********************************************************************
00644 //
00645 // CSimpleApp::PaintApp
00646 //
00647 // Purpose:
00648 //
00649 //      Handles the painting of the doc window.
00650 //
00651 //
00652 // Parameters:
00653 //
00654 //      HDC hDC -   hDC to the Doc Window.
00655 //
00656 // Return Value:
00657 //
00658 //      None
00659 //
00660 // Function Calls:
00661 //      Function                    Location
00662 //
00663 //      CSimpleDoc::PaintDoc        DOC.CPP
00664 //
00665 // Comments:
00666 //
00667 //      This is an app level function in case we want to do palette
00668 //      management.
00669 //
00670 //********************************************************************
00671
00672 void CSimpleApp::PaintApp (HDC hDC)
00673 {
00674         CStabilize stabilize(this);
00675         // at this level, we could enumerate through all of the
00676         // visible objects in the application, so that a palette
00677         // that best fits all of the objects can be built.
00678
00679         // This app is designed to take on the same palette
00680         // functionality that was provided in OLE 1.0, the palette
00681         // of the last object drawn is realized.  Since we only
00682         // support one object at a time, it shouldn't be a big
00683         // deal.
00684
00685         // if we supported multiple documents, we would enumerate
00686         // through each of the open documents and call paint.
00687
00688         if (m_lpDoc)
00689                 m_lpDoc->PaintDoc(hDC);
00690
00691 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/StrOut/StrOut.Idl Source File

  • NetDS
  • RPC
  • StrOut

StrOut.Idl

Go to the documentation of this file.
00001 /*************************************************************************
00002             Copyright Microsoft Corp. 1992 - 1996
00003                 Remote Machine strout sample
00004
00005     FILE    :   strout.idl
00006
00007     PURPOSE :   This file defines the interface for the strout example
00008
00009 *************************************************************************/
00010 [
00011 uuid(cab31280-b996-11cf-9548-00aa00374e69), // UUID
00012 pointer_default(unique),                    // Pointer default
00013 version(1.0)                                // Program version
00014 ]
00015 interface strout_sample
00016 {
00017
00018 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00019 /* Define a type for the second dimension variables that should be      */
00020 /* returned from the server. This should also work for UNICODE          */
00021 /* characters                                                           */
00022 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00023 #if defined _UNICODE
00024     typedef [string, unique] wchar_t * str; // String of wide chars
00025 #else
00026     typedef [string, unique] char * str;    // String of ASCII chars
00027 #endif
00028
00029     /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00030     /* Declaration of the remote procedure.                             */
00031     /* This procedure will get the environment strings from the server  */
00032     /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00033     void GetRemoteEnv(
00034         // Number of lines in the envirionment block
00035         [in, out] unsigned long   * Lines,
00036         // Pointer to an array of pointers to the lines in the env. block.
00037         // MUST have comma before *Lines in size_of  to set the size of
00038         // the right dimension, which is the size of the array of pointers
00039         [out, size_is(,*Lines)] str **EnvBlock);
00040
00041     // Procedure to shut down the server
00042     void ShutDown(void);
00043 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ClientList Member List

This is the complete list of members for ClientList, including all inherited members.
ClientList() | ClientList | [inline]
GetIterator(OUT ClientList::Iterator &It) const | ClientList | [inline]
InsertBack(RqsClient *pClient) | ClientList | [inline]
LISTNODE typedef | ClientList | [private]
m_iCount | ClientList | [private]
m_pHead | ClientList | [private]
m_pTail | ClientList | [private]
RemoveItem(RqsClient *pClient) | ClientList | [inline]
~ClientList() | ClientList | [inline]
Generated on Wed Nov 13 2024 16:56:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/SecurObj/Resource.h Source File

  • Security
  • Authorization
  • SecurObj

Resource.h

Go to the documentation of this file.
00001 /*
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 Used by Main.rc
00011 */
00012
00013 #define IDS_PRIV_READ                   1
00014 #define IDS_PRIV_MODIFY                 2
00015 #define IDS_PRIV_ALL                    3
00016 #define IDS_PRIV_ROOT                   4
00017 #define IDS_PRIV_DELETE                 5
00018 #define IDS_INH_ALL                     6
00019 #define IDS_INH_CONTAINER               7
00020 #define IDS_INH_OBJECT                  8
00021 #define IDS_INH_NONE                    9
00022 #define IDD_DIALOG_MAIN                 101
00023 #define IDI_LARGE                       102
00024 #define IDD_LOGON                       105
00025 #define IDR_PRIVOBJ_ACC                 107
00026 #define IDC_OBJECT_TREE                 1000
00027 #define IDC_NEW_PIPE                    1001
00028 #define IDC_NEW_CONTAINER               1001
00029 #define IDC_NEW_MMF                     1002
00030 #define IDC_NEW_OBJECT                  1002
00031 #define IDC_IMPERSONATE                 1005
00032 #define IDC_USERLIST                    1007
00033 #define IDC_ACCESSCHECK                 1008
00034 #define IDC_USERNAME                    1009
00035 #define IDC_PASSWORD                    1010
00036 #define IDC_SECURITY                    1011
00037 #define IDC_DOMAIN                      1012
00038 #define IDC_ADDACCESS                   1013
00039 #define IDC_LOOKSD                      1014
00040 #define IDC_NEW_TREE                    1015
00041 #define DUMMY                           40001
00042 #define IDC_STATIC                      -1
00043
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Dt_Dll/Handlers.h Source File

  • NetDS
  • WinSock
  • Dt_Dll

Handlers.h

Go to the documentation of this file.
00001 /*++
00002
00003   Copyright (c) 1995 Intel Corp
00004
00005   Module Name:
00006
00007     handlers.h
00008
00009   Abstract:
00010
00011     Contains handler function prototypes and typedefs for handlers.cpp.
00012
00013
00014 --*/
00015
00016 //
00017 // Typedefs
00018 //
00019
00020 // This typedef defines a pointer to a handler function.  See
00021 // dt_dll.cpp for examples of how this is used.
00022 typedef BOOL (CALLBACK * LPFNDTHANDLER)(
00023     IN     va_list vl,
00024     IN OUT LPVOID  ReturnValue,
00025     IN     LPSTR   LibraryName,
00026     OUT    char    *Buffer,
00027     IN     int     Index,
00028     IN     int     BufLen,
00029     IN     BOOL    PreOrPost);
00030
00031 typedef LPFNDTHANDLER *LPLPFNDTHANDLER;
00032
00033
00034
00035 //
00036 // Function Prototypes
00037 //
00038
00039 BOOL
00040 DTHandlerInit(
00041     OUT LPLPFNDTHANDLER HandlerFuncTable,
00042     int                 NumEntries);
00043
00044
00045 BOOL CALLBACK
00046 DTHandler_accept(
00047     IN     va_list vl,
00048     IN OUT LPVOID  ReturnValue,
00049     IN     LPSTR   LibraryName,
00050     OUT    char    *Buffer,
00051     IN     int     Index,
00052     IN     int     BufLen,
00053     IN     BOOL    PreOrPost);
00054
00055 BOOL CALLBACK
00056 DTHandler_bind(
00057     IN     va_list vl,
00058     IN OUT LPVOID  ReturnValue,
00059     IN     LPSTR   LibraryName,
00060     OUT    char    *Buffer,
00061     IN     int     Index,
00062     IN     int     BufLen,
00063     IN     BOOL    PreOrPost);
00064
00065 BOOL CALLBACK
00066 DTHandler_closesocket(
00067     IN     va_list vl,
00068     IN OUT LPVOID  ReturnValue,
00069     IN     LPSTR   LibraryName,
00070     OUT    char    *Buffer,
00071     IN     int     Index,
00072     IN     int     BufLen,
00073     IN     BOOL    PreOrPost);
00074
00075 BOOL CALLBACK
00076 DTHandler_connect(
00077     IN     va_list vl,
00078     IN OUT LPVOID  ReturnValue,
00079     IN     LPSTR   LibraryName,
00080     OUT    char    *Buffer,
00081     IN     int     Index,
00082     IN     int     BufLen,
00083     IN     BOOL    PreOrPost);
00084
00085 BOOL CALLBACK
00086 DTHandler_getpeername(
00087     IN     va_list vl,
00088     IN OUT LPVOID  ReturnValue,
00089     IN     LPSTR   LibraryName,
00090     OUT    char    *Buffer,
00091     IN     int     Index,
00092     IN     int     BufLen,
00093     IN     BOOL    PreOrPost);
00094
00095 BOOL CALLBACK
00096 DTHandler_getsockname(
00097     IN     va_list vl,
00098     IN OUT LPVOID  ReturnValue,
00099     IN     LPSTR   LibraryName,
00100     OUT    char    *Buffer,
00101     IN     int     Index,
00102     IN     int     BufLen,
00103     IN     BOOL    PreOrPost);
00104
00105 BOOL CALLBACK
00106 DTHandler_getsockopt(
00107     IN     va_list vl,
00108     IN OUT LPVOID  ReturnValue,
00109     IN     LPSTR   LibraryName,
00110     OUT    char    *Buffer,
00111     IN     int     Index,
00112     IN     int     BufLen,
00113     IN     BOOL    PreOrPost);
00114
00115 BOOL CALLBACK
00116 DTHandler_htonl(
00117     IN     va_list vl,
00118     IN OUT LPVOID  ReturnValue,
00119     IN     LPSTR   LibraryName,
00120     OUT    char    *Buffer,
00121     IN     int     Index,
00122     IN     int     BufLen,
00123     IN     BOOL    PreOrPost);
00124
00125 BOOL CALLBACK
00126 DTHandler_htons(
00127     IN     va_list vl,
00128     IN OUT LPVOID  ReturnValue,
00129     IN     LPSTR   LibraryName,
00130     OUT    char    *Buffer,
00131     IN     int     Index,
00132     IN     int     BufLen,
00133     IN     BOOL    PreOrPost);
00134
00135 BOOL CALLBACK
00136 DTHandler_ioctlsocket(
00137     IN     va_list vl,
00138     IN OUT LPVOID  ReturnValue,
00139     IN     LPSTR   LibraryName,
00140     OUT    char    *Buffer,
00141     IN     int     Index,
00142     IN     int     BufLen,
00143     IN     BOOL    PreOrPost);
00144
00145 BOOL CALLBACK
00146 DTHandler_listen(
00147     IN     va_list vl,
00148     IN OUT LPVOID  ReturnValue,
00149     IN     LPSTR   LibraryName,
00150     OUT    char    *Buffer,
00151     IN     int     Index,
00152     IN     int     BufLen,
00153     IN     BOOL    PreOrPost);
00154
00155 BOOL CALLBACK
00156 DTHandler_ntohl(
00157     IN     va_list vl,
00158     IN OUT LPVOID  ReturnValue,
00159     IN     LPSTR   LibraryName,
00160     OUT    char    *Buffer,
00161     IN     int     Index,
00162     IN     int     BufLen,
00163     IN     BOOL    PreOrPost);
00164
00165 BOOL CALLBACK
00166 DTHandler_ntohs(
00167     IN     va_list vl,
00168     IN OUT LPVOID  ReturnValue,
00169     IN     LPSTR   LibraryName,
00170     OUT    char    *Buffer,
00171     IN     int     Index,
00172     IN     int     BufLen,
00173     IN     BOOL    PreOrPost);
00174
00175 BOOL CALLBACK
00176 DTHandler_recv(
00177     IN     va_list vl,
00178     IN OUT LPVOID  ReturnValue,
00179     IN     LPSTR   LibraryName,
00180     OUT    char    *Buffer,
00181     IN     int     Index,
00182     IN     int     BufLen,
00183     IN     BOOL    PreOrPost);
00184
00185 BOOL CALLBACK
00186 DTHandler_recvfrom(
00187     IN     va_list vl,
00188     IN OUT LPVOID  ReturnValue,
00189     IN     LPSTR   LibraryName,
00190     OUT    char    *Buffer,
00191     IN     int     Index,
00192     IN     int     BufLen,
00193     IN     BOOL    PreOrPost);
00194
00195 BOOL CALLBACK
00196 DTHandler_select(
00197     IN     va_list vl,
00198     IN OUT LPVOID  ReturnValue,
00199     IN     LPSTR   LibraryName,
00200     OUT    char    *Buffer,
00201     IN     int     Index,
00202     IN     int     BufLen,
00203     IN     BOOL    PreOrPost);
00204
00205 BOOL CALLBACK
00206 DTHandler_send(
00207     IN     va_list vl,
00208     IN OUT LPVOID  ReturnValue,
00209     IN     LPSTR   LibraryName,
00210     OUT    char    *Buffer,
00211     IN     int     Index,
00212     IN     int     BufLen,
00213     IN     BOOL    PreOrPost);
00214
00215 BOOL CALLBACK
00216 DTHandler_sendto(
00217     IN     va_list vl,
00218     IN OUT LPVOID  ReturnValue,
00219     IN     LPSTR   LibraryName,
00220     OUT    char    *Buffer,
00221     IN     int     Index,
00222     IN     int     BufLen,
00223     IN     BOOL    PreOrPost);
00224
00225 BOOL CALLBACK
00226 DTHandler_setsockopt(
00227     IN     va_list vl,
00228     IN OUT LPVOID  ReturnValue,
00229     IN     LPSTR   LibraryName,
00230     OUT    char    *Buffer,
00231     IN     int     Index,
00232     IN     int     BufLen,
00233     IN     BOOL    PreOrPost);
00234
00235 BOOL CALLBACK
00236 DTHandler_shutdown(
00237     IN     va_list vl,
00238     IN OUT LPVOID  ReturnValue,
00239     IN     LPSTR   LibraryName,
00240     OUT    char    *Buffer,
00241     IN     int     Index,
00242     IN     int     BufLen,
00243     IN     BOOL    PreOrPost);
00244
00245 BOOL CALLBACK
00246 DTHandler_socket(
00247     IN     va_list vl,
00248     IN OUT LPVOID  ReturnValue,
00249     IN     LPSTR   LibraryName,
00250     OUT    char    *Buffer,
00251     IN     int     Index,
00252     IN     int     BufLen,
00253     IN     BOOL    PreOrPost);
00254
00255 BOOL CALLBACK
00256 DTHandler_WSAAccept(
00257     IN     va_list vl,
00258     IN OUT LPVOID  ReturnValue,
00259     IN     LPSTR   LibraryName,
00260     OUT    char    *Buffer,
00261     IN     int     Index,
00262     IN     int     BufLen,
00263     IN     BOOL    PreOrPost);
00264
00265 BOOL CALLBACK
00266 DTHandler_WSAAsyncSelect(
00267     IN     va_list vl,
00268     IN OUT LPVOID  ReturnValue,
00269     IN     LPSTR   LibraryName,
00270     OUT    char    *Buffer,
00271     IN     int     Index,
00272     IN     int     BufLen,
00273     IN     BOOL    PreOrPost);
00274
00275 BOOL CALLBACK
00276 DTHandler_WSACancelBlockingCall(
00277     IN     va_list vl,
00278     IN OUT LPVOID  ReturnValue,
00279     IN     LPSTR   LibraryName,
00280     OUT    char    *Buffer,
00281     IN     int     Index,
00282     IN     int     BufLen,
00283     IN     BOOL    PreOrPost);
00284
00285 BOOL CALLBACK
00286 DTHandler_WSACleanup(
00287     IN     va_list vl,
00288     IN OUT LPVOID  ReturnValue,
00289     IN     LPSTR   LibraryName,
00290     OUT    char    *Buffer,
00291     IN     int     Index,
00292     IN     int     BufLen,
00293     IN     BOOL    PreOrPost);
00294
00295 BOOL CALLBACK
00296 DTHandler_WSACloseEvent(
00297     IN     va_list vl,
00298     IN OUT LPVOID  ReturnValue,
00299     IN     LPSTR   LibraryName,
00300     OUT    char    *Buffer,
00301     IN     int     Index,
00302     IN     int     BufLen,
00303     IN     BOOL    PreOrPost);
00304
00305 BOOL CALLBACK
00306 DTHandler_WSAConnect(
00307     IN     va_list vl,
00308     IN OUT LPVOID  ReturnValue,
00309     IN     LPSTR   LibraryName,
00310     OUT    char    *Buffer,
00311     IN     int     Index,
00312     IN     int     BufLen,
00313     IN     BOOL    PreOrPost);
00314
00315 BOOL CALLBACK
00316 DTHandler_WSACreateEvent(
00317     IN     va_list vl,
00318     IN OUT LPVOID  ReturnValue,
00319     IN     LPSTR   LibraryName,
00320     OUT    char    *Buffer,
00321     IN     int     Index,
00322     IN     int     BufLen,
00323     IN     BOOL    PreOrPost);
00324
00325 BOOL CALLBACK
00326 DTHandler_WSADuplicateSocketA(
00327     IN     va_list vl,
00328     IN OUT LPVOID  ReturnValue,
00329     IN     LPSTR   LibraryName,
00330     OUT    char    *Buffer,
00331     IN     int     Index,
00332     IN     int     BufLen,
00333     IN     BOOL    PreOrPost);
00334
00335 BOOL CALLBACK
00336 DTHandler_WSADuplicateSocketW(
00337     IN     va_list vl,
00338     IN OUT LPVOID  ReturnValue,
00339     IN     LPSTR   LibraryName,
00340     OUT    char    *Buffer,
00341     IN     int     Index,
00342     IN     int     BufLen,
00343     IN     BOOL    PreOrPost);
00344
00345 BOOL CALLBACK
00346 DTHandler_WSAEnumNetworkEvents(
00347     IN     va_list vl,
00348     IN OUT LPVOID  ReturnValue,
00349     IN     LPSTR   LibraryName,
00350     OUT    char    *Buffer,
00351     IN     int     Index,
00352     IN     int     BufLen,
00353     IN     BOOL    PreOrPost);
00354
00355 BOOL CALLBACK
00356 DTHandler_WSAEnumProtocolsA(
00357     IN     va_list vl,
00358     IN OUT LPVOID  ReturnValue,
00359     IN     LPSTR   LibraryName,
00360     OUT    char    *Buffer,
00361     IN     int     Index,
00362     IN     int     BufLen,
00363     IN     BOOL    PreOrPost);
00364
00365 BOOL CALLBACK
00366 DTHandler_WSAEnumProtocolsW(
00367     IN     va_list vl,
00368     IN OUT LPVOID  ReturnValue,
00369     IN     LPSTR   LibraryName,
00370     OUT    char    *Buffer,
00371     IN     int     Index,
00372     IN     int     BufLen,
00373     IN     BOOL    PreOrPost);
00374
00375 BOOL CALLBACK
00376 DTHandler_WSAEventSelect(
00377     IN     va_list vl,
00378     IN OUT LPVOID  ReturnValue,
00379     IN     LPSTR   LibraryName,
00380     OUT    char    *Buffer,
00381     IN     int     Index,
00382     IN     int     BufLen,
00383     IN     BOOL    PreOrPost);
00384
00385 BOOL CALLBACK
00386 DTHandler_WSAGetLastError(
00387     IN     va_list vl,
00388     IN OUT LPVOID  ReturnValue,
00389     IN     LPSTR   LibraryName,
00390     OUT    char    *Buffer,
00391     IN     int     Index,
00392     IN     int     BufLen,
00393     IN     BOOL    PreOrPost);
00394
00395 BOOL CALLBACK
00396 DTHandler_WSAGetOverlappedResult(
00397     IN     va_list vl,
00398     IN OUT LPVOID  ReturnValue,
00399     IN     LPSTR   LibraryName,
00400     OUT    char    *Buffer,
00401     IN     int     Index,
00402     IN     int     BufLen,
00403     IN     BOOL    PreOrPost);
00404
00405 BOOL CALLBACK
00406 DTHandler_WSAGetQOSByName(
00407     IN     va_list vl,
00408     IN OUT LPVOID  ReturnValue,
00409     IN     LPSTR   LibraryName,
00410     OUT    char    *Buffer,
00411     IN     int     Index,
00412     IN     int     BufLen,
00413     IN     BOOL    PreOrPost);
00414
00415 BOOL CALLBACK
00416 DTHandler_WSAHtonl(
00417     IN     va_list vl,
00418     IN OUT LPVOID  ReturnValue,
00419     IN     LPSTR   LibraryName,
00420     OUT    char    *Buffer,
00421     IN     int     Index,
00422     IN     int     BufLen,
00423     IN     BOOL    PreOrPost);
00424
00425 BOOL CALLBACK
00426 DTHandler_WSAHtons(
00427     IN     va_list vl,
00428     IN OUT LPVOID  ReturnValue,
00429     IN     LPSTR   LibraryName,
00430     OUT    char    *Buffer,
00431     IN     int     Index,
00432     IN     int     BufLen,
00433     IN     BOOL    PreOrPost);
00434
00435 BOOL CALLBACK
00436 DTHandler_WSAIoctl(
00437     IN     va_list vl,
00438     IN OUT LPVOID  ReturnValue,
00439     IN     LPSTR   LibraryName,
00440     OUT    char    *Buffer,
00441     IN     int     Index,
00442     IN     int     BufLen,
00443     IN     BOOL    PreOrPost);
00444
00445 BOOL CALLBACK
00446 DTHandler_WSAIsBlocking(
00447     IN     va_list vl,
00448     IN OUT LPVOID  ReturnValue,
00449     IN     LPSTR   LibraryName,
00450     OUT    char    *Buffer,
00451     IN     int     Index,
00452     IN     int     BufLen,
00453     IN     BOOL    PreOrPost);
00454
00455 BOOL CALLBACK
00456 DTHandler_WSAJoinLeaf(
00457     IN     va_list vl,
00458     IN OUT LPVOID  ReturnValue,
00459     IN     LPSTR   LibraryName,
00460     OUT    char    *Buffer,
00461     IN     int     Index,
00462     IN     int     BufLen,
00463     IN     BOOL    PreOrPost);
00464
00465 BOOL CALLBACK
00466 DTHandler_WSANtohl(
00467     IN     va_list vl,
00468     IN OUT LPVOID  ReturnValue,
00469     IN     LPSTR   LibraryName,
00470     OUT    char    *Buffer,
00471     IN     int     Index,
00472     IN     int     BufLen,
00473     IN     BOOL    PreOrPost);
00474
00475 BOOL CALLBACK
00476 DTHandler_WSANtohs(
00477     IN     va_list vl,
00478     IN OUT LPVOID  ReturnValue,
00479     IN     LPSTR   LibraryName,
00480     OUT    char    *Buffer,
00481     IN     int     Index,
00482     IN     int     BufLen,
00483     IN     BOOL    PreOrPost);
00484
00485 BOOL CALLBACK
00486 DTHandler_WSARecv(
00487     IN     va_list vl,
00488     IN OUT LPVOID  ReturnValue,
00489     IN     LPSTR   LibraryName,
00490     OUT    char    *Buffer,
00491     IN     int     Index,
00492     IN     int     BufLen,
00493     IN     BOOL    PreOrPost);
00494
00495 BOOL CALLBACK
00496 DTHandler_WSARecvDisconnect(
00497     IN     va_list vl,
00498     IN OUT LPVOID  ReturnValue,
00499     IN     LPSTR   LibraryName,
00500     OUT    char    *Buffer,
00501     IN     int     Index,
00502     IN     int     BufLen,
00503     IN     BOOL    PreOrPost);
00504
00505 BOOL CALLBACK
00506 DTHandler_WSARecvFrom(
00507     IN     va_list vl,
00508     IN OUT LPVOID  ReturnValue,
00509     IN     LPSTR   LibraryName,
00510     OUT    char    *Buffer,
00511     IN     int     Index,
00512     IN     int     BufLen,
00513     IN     BOOL    PreOrPost);
00514
00515 BOOL CALLBACK
00516 DTHandler_WSAResetEvent(
00517     IN     va_list vl,
00518     IN OUT LPVOID  ReturnValue,
00519     IN     LPSTR   LibraryName,
00520     OUT    char    *Buffer,
00521     IN     int     Index,
00522     IN     int     BufLen,
00523     IN     BOOL    PreOrPost);
00524
00525 BOOL CALLBACK
00526 DTHandler_WSASend(
00527     IN     va_list vl,
00528     IN OUT LPVOID  ReturnValue,
00529     IN     LPSTR   LibraryName,
00530     OUT    char    *Buffer,
00531     IN     int     Index,
00532     IN     int     BufLen,
00533     IN     BOOL    PreOrPost);
00534
00535 BOOL CALLBACK
00536 DTHandler_WSASendDisconnect(
00537     IN     va_list vl,
00538     IN OUT LPVOID  ReturnValue,
00539     IN     LPSTR   LibraryName,
00540     OUT    char    *Buffer,
00541     IN     int     Index,
00542     IN     int     BufLen,
00543     IN     BOOL    PreOrPost);
00544
00545 BOOL CALLBACK
00546 DTHandler_WSASendTo(
00547     IN     va_list vl,
00548     IN OUT LPVOID  ReturnValue,
00549     IN     LPSTR   LibraryName,
00550     OUT    char    *Buffer,
00551     IN     int     Index,
00552     IN     int     BufLen,
00553     IN     BOOL    PreOrPost);
00554
00555 BOOL CALLBACK
00556 DTHandler_WSASetBlockingHook(
00557     IN     va_list vl,
00558     IN OUT LPVOID  ReturnValue,
00559     IN     LPSTR   LibraryName,
00560     OUT    char    *Buffer,
00561     IN     int     Index,
00562     IN     int     BufLen,
00563     IN     BOOL    PreOrPost);
00564
00565 BOOL CALLBACK
00566 DTHandler_WSASetEvent(
00567     IN     va_list vl,
00568     IN OUT LPVOID  ReturnValue,
00569     IN     LPSTR   LibraryName,
00570     OUT    char    *Buffer,
00571     IN     int     Index,
00572     IN     int     BufLen,
00573     IN     BOOL    PreOrPost);
00574
00575 BOOL CALLBACK
00576 DTHandler_WSASetLastError(
00577     IN     va_list vl,
00578     IN OUT LPVOID  ReturnValue,
00579     IN     LPSTR   LibraryName,
00580     OUT    char    *Buffer,
00581     IN     int     Index,
00582     IN     int     BufLen,
00583     IN     BOOL    PreOrPost);
00584
00585 BOOL CALLBACK
00586 DTHandler_WSASocketA(
00587     IN     va_list vl,
00588     IN OUT LPVOID  ReturnValue,
00589     IN     LPSTR   LibraryName,
00590     OUT    char    *Buffer,
00591     IN     int     Index,
00592     IN     int     BufLen,
00593     IN     BOOL    PreOrPost);
00594
00595 BOOL CALLBACK
00596 DTHandler_WSASocketW(
00597     IN     va_list vl,
00598     IN OUT LPVOID  ReturnValue,
00599     IN     LPSTR   LibraryName,
00600     OUT    char    *Buffer,
00601     IN     int     Index,
00602     IN     int     BufLen,
00603     IN     BOOL    PreOrPost);
00604
00605 BOOL CALLBACK
00606 DTHandler_WSAStartup(
00607     IN     va_list vl,
00608     IN OUT LPVOID  ReturnValue,
00609     IN     LPSTR   LibraryName,
00610     OUT    char    *Buffer,
00611     IN     int     Index,
00612     IN     int     BufLen,
00613     IN     BOOL    PreOrPost);
00614
00615 BOOL CALLBACK
00616 DTHandler_WSAUnhookBlockingHook(
00617     IN     va_list vl,
00618     IN OUT LPVOID  ReturnValue,
00619     IN     LPSTR   LibraryName,
00620     OUT    char    *Buffer,
00621     IN     int     Index,
00622     IN     int     BufLen,
00623     IN     BOOL    PreOrPost);
00624
00625 BOOL CALLBACK
00626 DTHandler_WSAWaitForMultipleEvents(
00627     IN     va_list vl,
00628     IN OUT LPVOID  ReturnValue,
00629     IN     LPSTR   LibraryName,
00630     OUT    char    *Buffer,
00631     IN     int     Index,
00632     IN     int     BufLen,
00633     IN     BOOL    PreOrPost);
00634
00635 BOOL CALLBACK
00636 DTHandler_gethostbyaddr(
00637     IN     va_list vl,
00638     IN OUT LPVOID  ReturnValue,
00639     IN     LPSTR   LibraryName,
00640     OUT    char    *Buffer,
00641     IN     int     Index,
00642     IN     int     BufLen,
00643     IN     BOOL    PreOrPost);
00644
00645 BOOL CALLBACK
00646 DTHandler_gethostbyname(
00647     IN     va_list vl,
00648     IN OUT LPVOID  ReturnValue,
00649     IN     LPSTR   LibraryName,
00650     OUT    char    *Buffer,
00651     IN     int     Index,
00652     IN     int     BufLen,
00653     IN     BOOL    PreOrPost);
00654
00655 BOOL CALLBACK
00656 DTHandler_gethostname(
00657     IN     va_list vl,
00658     IN OUT LPVOID  ReturnValue,
00659     IN     LPSTR   LibraryName,
00660     OUT    char    *Buffer,
00661     IN     int     Index,
00662     IN     int     BufLen,
00663     IN     BOOL    PreOrPost);
00664
00665 BOOL CALLBACK
00666 DTHandler_getprotobyname(
00667     IN     va_list vl,
00668     IN OUT LPVOID  ReturnValue,
00669     IN     LPSTR   LibraryName,
00670     OUT    char    *Buffer,
00671     IN     int     Index,
00672     IN     int     BufLen,
00673     IN     BOOL    PreOrPost);
00674
00675 BOOL CALLBACK
00676 DTHandler_getprotobynumber(
00677     IN     va_list vl,
00678     IN OUT LPVOID  ReturnValue,
00679     IN     LPSTR   LibraryName,
00680     OUT    char    *Buffer,
00681     IN     int     Index,
00682     IN     int     BufLen,
00683     IN     BOOL    PreOrPost);
00684
00685 BOOL CALLBACK
00686 DTHandler_getservbyname(
00687     IN     va_list vl,
00688     IN OUT LPVOID  ReturnValue,
00689     IN     LPSTR   LibraryName,
00690     OUT    char    *Buffer,
00691     IN     int     Index,
00692     IN     int     BufLen,
00693     IN     BOOL    PreOrPost);
00694
00695 BOOL CALLBACK
00696 DTHandler_getservbyport(
00697     IN     va_list vl,
00698     IN OUT LPVOID  ReturnValue,
00699     IN     LPSTR   LibraryName,
00700     OUT    char    *Buffer,
00701     IN     int     Index,
00702     IN     int     BufLen,
00703     IN     BOOL    PreOrPost);
00704
00705 BOOL CALLBACK
00706 DTHandler_inet_addr(
00707     IN     va_list vl,
00708     IN OUT LPVOID  ReturnValue,
00709     IN     LPSTR   LibraryName,
00710     OUT    char    *Buffer,
00711     IN     int     Index,
00712     IN     int     BufLen,
00713     IN     BOOL    PreOrPost);
00714
00715 BOOL CALLBACK
00716 DTHandler_inet_ntoa(
00717     IN     va_list vl,
00718     IN OUT LPVOID  ReturnValue,
00719     IN     LPSTR   LibraryName,
00720     OUT    char    *Buffer,
00721     IN     int     Index,
00722     IN     int     BufLen,
00723     IN     BOOL    PreOrPost);
00724
00725 BOOL CALLBACK
00726 DTHandler_WSAAsyncGetHostByAddr(
00727     IN     va_list vl,
00728     IN OUT LPVOID  ReturnValue,
00729     IN     LPSTR   LibraryName,
00730     OUT    char    *Buffer,
00731     IN     int     Index,
00732     IN     int     BufLen,
00733     IN     BOOL    PreOrPost);
00734
00735 BOOL CALLBACK
00736 DTHandler_WSAAsyncGetHostByName(
00737     IN     va_list vl,
00738     IN OUT LPVOID  ReturnValue,
00739     IN     LPSTR   LibraryName,
00740     OUT    char    *Buffer,
00741     IN     int     Index,
00742     IN     int     BufLen,
00743     IN     BOOL    PreOrPost);
00744
00745 BOOL CALLBACK
00746 DTHandler_WSAAsyncGetProtoByName(
00747     IN     va_list vl,
00748     IN OUT LPVOID  ReturnValue,
00749     IN     LPSTR   LibraryName,
00750     OUT    char    *Buffer,
00751     IN     int     Index,
00752     IN     int     BufLen,
00753     IN     BOOL    PreOrPost);
00754
00755 BOOL CALLBACK
00756 DTHandler_WSAAsyncGetProtoByNumber(
00757     IN     va_list vl,
00758     IN OUT LPVOID  ReturnValue,
00759     IN     LPSTR   LibraryName,
00760     OUT    char    *Buffer,
00761     IN     int     Index,
00762     IN     int     BufLen,
00763     IN     BOOL    PreOrPost);
00764
00765 BOOL CALLBACK
00766 DTHandler_WSAAsyncGetServByName(
00767     IN     va_list vl,
00768     IN OUT LPVOID  ReturnValue,
00769     IN     LPSTR   LibraryName,
00770     OUT    char    *Buffer,
00771     IN     int     Index,
00772     IN     int     BufLen,
00773     IN     BOOL    PreOrPost);
00774
00775 BOOL CALLBACK
00776 DTHandler_WSAAsyncGetServByPort(
00777     IN     va_list vl,
00778     IN OUT LPVOID  ReturnValue,
00779     IN     LPSTR   LibraryName,
00780     OUT    char    *Buffer,
00781     IN     int     Index,
00782     IN     int     BufLen,
00783     IN     BOOL    PreOrPost);
00784
00785 BOOL CALLBACK
00786 DTHandler_WSACancelAsyncRequest(
00787     IN     va_list vl,
00788     IN OUT LPVOID  ReturnValue,
00789     IN     LPSTR   LibraryName,
00790     OUT    char    *Buffer,
00791     IN     int     Index,
00792     IN     int     BufLen,
00793     IN     BOOL    PreOrPost);
00794
00795 BOOL CALLBACK
00796 DTHandler_WSPAccept(
00797     IN     va_list vl,
00798     IN OUT LPVOID  ReturnValue,
00799     IN     LPSTR   LibraryName,
00800     OUT    char    *Buffer,
00801     IN     int     Index,
00802     IN     int     BufLen,
00803     IN     BOOL    PreOrPost);
00804
00805 BOOL CALLBACK
00806 DTHandler_WSPAsyncSelect(
00807     IN     va_list vl,
00808     IN OUT LPVOID  ReturnValue,
00809     IN     LPSTR   LibraryName,
00810     OUT    char    *Buffer,
00811     IN     int     Index,
00812     IN     int     BufLen,
00813     IN     BOOL    PreOrPost);
00814
00815 BOOL CALLBACK
00816 DTHandler_WSPBind(
00817     IN     va_list vl,
00818     IN OUT LPVOID  ReturnValue,
00819     IN     LPSTR   LibraryName,
00820     OUT    char    *Buffer,
00821     IN     int     Index,
00822     IN     int     BufLen,
00823     IN     BOOL    PreOrPost);
00824
00825 BOOL CALLBACK
00826 DTHandler_WSPCancelBlockingCall(
00827     IN     va_list vl,
00828     IN OUT LPVOID  ReturnValue,
00829     IN     LPSTR   LibraryName,
00830     OUT    char    *Buffer,
00831     IN     int     Index,
00832     IN     int     BufLen,
00833     IN     BOOL    PreOrPost);
00834
00835 BOOL CALLBACK
00836 DTHandler_WSPCleanup(
00837     IN     va_list vl,
00838     IN OUT LPVOID  ReturnValue,
00839     IN     LPSTR   LibraryName,
00840     OUT    char    *Buffer,
00841     IN     int     Index,
00842     IN     int     BufLen,
00843     IN     BOOL    PreOrPost);
00844
00845 BOOL CALLBACK
00846 DTHandler_WSPCloseSocket(
00847     IN     va_list vl,
00848     IN OUT LPVOID  ReturnValue,
00849     IN     LPSTR   LibraryName,
00850     OUT    char    *Buffer,
00851     IN     int     Index,
00852     IN     int     BufLen,
00853     IN     BOOL    PreOrPost);
00854
00855 BOOL CALLBACK
00856 DTHandler_WSPConnect(
00857     IN     va_list vl,
00858     IN OUT LPVOID  ReturnValue,
00859     IN     LPSTR   LibraryName,
00860     OUT    char    *Buffer,
00861     IN     int     Index,
00862     IN     int     BufLen,
00863     IN     BOOL    PreOrPost);
00864
00865 BOOL CALLBACK
00866 DTHandler_WSPDuplicateSocket(
00867     IN     va_list vl,
00868     IN OUT LPVOID  ReturnValue,
00869     IN     LPSTR   LibraryName,
00870     OUT    char    *Buffer,
00871     IN     int     Index,
00872     IN     int     BufLen,
00873     IN     BOOL    PreOrPost);
00874
00875 BOOL CALLBACK
00876 DTHandler_WSPEnumNetworkEvents(
00877     IN     va_list vl,
00878     IN OUT LPVOID  ReturnValue,
00879     IN     LPSTR   LibraryName,
00880     OUT    char    *Buffer,
00881     IN     int     Index,
00882     IN     int     BufLen,
00883     IN     BOOL    PreOrPost);
00884
00885 BOOL CALLBACK
00886 DTHandler_WSPEventSelect(
00887     IN     va_list vl,
00888     IN OUT LPVOID  ReturnValue,
00889     IN     LPSTR   LibraryName,
00890     OUT    char    *Buffer,
00891     IN     int     Index,
00892     IN     int     BufLen,
00893     IN     BOOL    PreOrPost);
00894
00895 BOOL CALLBACK
00896 DTHandler_WSPGetOverlappedResult(
00897     IN     va_list vl,
00898     IN OUT LPVOID  ReturnValue,
00899     IN     LPSTR   LibraryName,
00900     OUT    char    *Buffer,
00901     IN     int     Index,
00902     IN     int     BufLen,
00903     IN     BOOL    PreOrPost);
00904
00905 BOOL CALLBACK
00906 DTHandler_WSPGetPeerName(
00907     IN     va_list vl,
00908     IN OUT LPVOID  ReturnValue,
00909     IN     LPSTR   LibraryName,
00910     OUT    char    *Buffer,
00911     IN     int     Index,
00912     IN     int     BufLen,
00913     IN     BOOL    PreOrPost);
00914
00915
00916 BOOL CALLBACK
00917 DTHandler_WSPGetSockName(
00918     IN     va_list vl,
00919     IN OUT LPVOID  ReturnValue,
00920     IN     LPSTR   LibraryName,
00921     OUT    char    *Buffer,
00922     IN     int     Index,
00923     IN     int     BufLen,
00924     IN     BOOL    PreOrPost);
00925
00926 BOOL CALLBACK
00927 DTHandler_WSPGetSockOpt(
00928     IN     va_list vl,
00929     IN OUT LPVOID  ReturnValue,
00930     IN     LPSTR   LibraryName,
00931     OUT    char    *Buffer,
00932     IN     int     Index,
00933     IN     int     BufLen,
00934     IN     BOOL    PreOrPost);
00935
00936 BOOL CALLBACK
00937 DTHandler_WSPGetQOSByName(
00938     IN     va_list vl,
00939     IN OUT LPVOID  ReturnValue,
00940     IN     LPSTR   LibraryName,
00941     OUT    char    *Buffer,
00942     IN     int     Index,
00943     IN     int     BufLen,
00944     IN     BOOL    PreOrPost);
00945
00946 BOOL CALLBACK
00947 DTHandler_WSPIoctl(
00948     IN     va_list vl,
00949     IN OUT LPVOID  ReturnValue,
00950     IN     LPSTR   LibraryName,
00951     OUT    char    *Buffer,
00952     IN     int     Index,
00953     IN     int     BufLen,
00954     IN     BOOL    PreOrPost);
00955
00956 BOOL CALLBACK
00957 DTHandler_WSPJoinLeaf(
00958     IN     va_list vl,
00959     IN OUT LPVOID  ReturnValue,
00960     IN     LPSTR   LibraryName,
00961     OUT    char    *Buffer,
00962     IN     int     Index,
00963     IN     int     BufLen,
00964     IN     BOOL    PreOrPost);
00965
00966 BOOL CALLBACK
00967 DTHandler_WSPListen(
00968     IN     va_list vl,
00969     IN OUT LPVOID  ReturnValue,
00970     IN     LPSTR   LibraryName,
00971     OUT    char    *Buffer,
00972     IN     int     Index,
00973     IN     int     BufLen,
00974     IN     BOOL    PreOrPost);
00975
00976 BOOL CALLBACK
00977 DTHandler_WSPRecv(
00978     IN     va_list vl,
00979     IN OUT LPVOID  ReturnValue,
00980     IN     LPSTR   LibraryName,
00981     OUT    char    *Buffer,
00982     IN     int     Index,
00983     IN     int     BufLen,
00984     IN     BOOL    PreOrPost);
00985
00986 BOOL CALLBACK
00987 DTHandler_WSPRecvDisconnect(
00988     IN     va_list vl,
00989     IN OUT LPVOID  ReturnValue,
00990     IN     LPSTR   LibraryName,
00991     OUT    char    *Buffer,
00992     IN     int     Index,
00993     IN     int     BufLen,
00994     IN     BOOL    PreOrPost);
00995
00996 BOOL CALLBACK
00997 DTHandler_WSPRecvFrom(
00998     IN     va_list vl,
00999     IN OUT LPVOID  ReturnValue,
01000     IN     LPSTR   LibraryName,
01001     OUT    char    *Buffer,
01002     IN     int     Index,
01003     IN     int     BufLen,
01004     IN     BOOL    PreOrPost);
01005
01006 BOOL CALLBACK
01007 DTHandler_WSPSelect(
01008     IN     va_list vl,
01009     IN OUT LPVOID  ReturnValue,
01010     IN     LPSTR   LibraryName,
01011     OUT    char    *Buffer,
01012     IN     int     Index,
01013     IN     int     BufLen,
01014     IN     BOOL    PreOrPost);
01015
01016 BOOL CALLBACK
01017 DTHandler_WSPSend(
01018     IN     va_list vl,
01019     IN OUT LPVOID  ReturnValue,
01020     IN     LPSTR   LibraryName,
01021     OUT    char    *Buffer,
01022     IN     int     Index,
01023     IN     int     BufLen,
01024     IN     BOOL    PreOrPost);
01025
01026 BOOL CALLBACK
01027 DTHandler_WSPSendDisconnect(
01028     IN     va_list vl,
01029     IN OUT LPVOID  ReturnValue,
01030     IN     LPSTR   LibraryName,
01031     OUT    char    *Buffer,
01032     IN     int     Index,
01033     IN     int     BufLen,
01034     IN     BOOL    PreOrPost);
01035
01036 BOOL CALLBACK
01037 DTHandler_WSPSendTo(
01038     IN     va_list vl,
01039     IN OUT LPVOID  ReturnValue,
01040     IN     LPSTR   LibraryName,
01041     OUT    char    *Buffer,
01042     IN     int     Index,
01043     IN     int     BufLen,
01044     IN     BOOL    PreOrPost);
01045
01046 BOOL CALLBACK
01047 DTHandler_WSPSetSockOpt(
01048     IN     va_list vl,
01049     IN OUT LPVOID  ReturnValue,
01050     IN     LPSTR   LibraryName,
01051     OUT    char    *Buffer,
01052     IN     int     Index,
01053     IN     int     BufLen,
01054     IN     BOOL    PreOrPost);
01055
01056 BOOL CALLBACK
01057 DTHandler_WSPShutdown(
01058     IN     va_list vl,
01059     IN OUT LPVOID  ReturnValue,
01060     IN     LPSTR   LibraryName,
01061     OUT    char    *Buffer,
01062     IN     int     Index,
01063     IN     int     BufLen,
01064     IN     BOOL    PreOrPost);
01065
01066 BOOL CALLBACK
01067 DTHandler_WSPSocket(
01068     IN     va_list vl,
01069     IN OUT LPVOID  ReturnValue,
01070     IN     LPSTR   LibraryName,
01071     OUT    char    *Buffer,
01072     IN     int     Index,
01073     IN     int     BufLen,
01074     IN     BOOL    PreOrPost);
01075
01076 BOOL CALLBACK
01077 DTHandler_WSPStartup(
01078     IN     va_list vl,
01079     IN OUT LPVOID  ReturnValue,
01080     IN     LPSTR   LibraryName,
01081     OUT    char    *Buffer,
01082     IN     int     Index,
01083     IN     int     BufLen,
01084     IN     BOOL    PreOrPost);
01085
01086 BOOL CALLBACK
01087 DTHandler_WPUCloseEvent(
01088     IN     va_list vl,
01089     IN OUT LPVOID  ReturnValue,
01090     IN     LPSTR   LibraryName,
01091     OUT    char    *Buffer,
01092     IN     int     Index,
01093     IN     int     BufLen,
01094     IN     BOOL    PreOrPost);
01095
01096 BOOL CALLBACK
01097 DTHandler_WPUCloseSocketHandle(
01098     IN     va_list vl,
01099     IN OUT LPVOID  ReturnValue,
01100     IN     LPSTR   LibraryName,
01101     OUT    char    *Buffer,
01102     IN     int     Index,
01103     IN     int     BufLen,
01104     IN     BOOL    PreOrPost);
01105
01106 BOOL CALLBACK
01107 DTHandler_WPUCreateEvent(
01108     IN     va_list vl,
01109     IN OUT LPVOID  ReturnValue,
01110     IN     LPSTR   LibraryName,
01111     OUT    char    *Buffer,
01112     IN     int     Index,
01113     IN     int     BufLen,
01114     IN     BOOL    PreOrPost);
01115
01116 BOOL CALLBACK
01117 DTHandler_WPUCreateSocketHandle(
01118     IN     va_list vl,
01119     IN OUT LPVOID  ReturnValue,
01120     IN     LPSTR   LibraryName,
01121     OUT    char    *Buffer,
01122     IN     int     Index,
01123     IN     int     BufLen,
01124     IN     BOOL    PreOrPost);
01125
01126 BOOL CALLBACK
01127 DTHandler_WSCDeinstallProvider(
01128     IN     va_list vl,
01129     IN OUT LPVOID  ReturnValue,
01130     IN     LPSTR   LibraryName,
01131     OUT    char    *Buffer,
01132     IN     int     Index,
01133     IN     int     BufLen,
01134     IN     BOOL    PreOrPost);
01135
01136 BOOL CALLBACK
01137 DTHandler_WSCInstallProvider(
01138     IN     va_list vl,
01139     IN OUT LPVOID  ReturnValue,
01140     IN     LPSTR   LibraryName,
01141     OUT    char    *Buffer,
01142     IN     int     Index,
01143     IN     int     BufLen,
01144     IN     BOOL    PreOrPost);
01145
01146 BOOL CALLBACK
01147 DTHandler_WPUModifyIFSHandle(
01148     IN     va_list vl,
01149     IN OUT LPVOID  ReturnValue,
01150     IN     LPSTR   LibraryName,
01151     OUT    char    *Buffer,
01152     IN     int     Index,
01153     IN     int     BufLen,
01154     IN     BOOL    PreOrPost);
01155
01156 BOOL CALLBACK
01157 DTHandler_WPUQueryBlockingCallback(
01158     IN     va_list vl,
01159     IN OUT LPVOID  ReturnValue,
01160     IN     LPSTR   LibraryName,
01161     OUT    char    *Buffer,
01162     IN     int     Index,
01163     IN     int     BufLen,
01164     IN     BOOL    PreOrPost);
01165
01166 BOOL CALLBACK
01167 DTHandler_WPUQuerySocketHandleContext(
01168     IN     va_list vl,
01169     IN OUT LPVOID  ReturnValue,
01170     IN     LPSTR   LibraryName,
01171     OUT    char    *Buffer,
01172     IN     int     Index,
01173     IN     int     BufLen,
01174     IN     BOOL    PreOrPost);
01175
01176 BOOL CALLBACK
01177 DTHandler_WPUQueueApc(
01178     IN     va_list vl,
01179     IN OUT LPVOID  ReturnValue,
01180     IN     LPSTR   LibraryName,
01181     OUT    char    *Buffer,
01182     IN     int     Index,
01183     IN     int     BufLen,
01184     IN     BOOL    PreOrPost);
01185
01186 BOOL CALLBACK
01187 DTHandler_WPUResetEvent(
01188     IN     va_list vl,
01189     IN OUT LPVOID  ReturnValue,
01190     IN     LPSTR   LibraryName,
01191     OUT    char    *Buffer,
01192     IN     int     Index,
01193     IN     int     BufLen,
01194     IN     BOOL    PreOrPost);
01195
01196 BOOL CALLBACK
01197 DTHandler_WPUSetEvent(
01198     IN     va_list vl,
01199     IN OUT LPVOID  ReturnValue,
01200     IN     LPSTR   LibraryName,
01201     OUT    char    *Buffer,
01202     IN     int     Index,
01203     IN     int     BufLen,
01204     IN     BOOL    PreOrPost);
01205
01206 BOOL CALLBACK
01207 DTHandler_WPUFDIsSet(
01208     IN     va_list vl,
01209     IN OUT LPVOID  ReturnValue,
01210     IN     LPSTR   LibraryName,
01211     OUT    char    *Buffer,
01212     IN     int     Index,
01213     IN     int     BufLen,
01214     IN     BOOL    PreOrPost);
01215
01216 BOOL CALLBACK
01217 DTHandler_WPUGetProviderPath(
01218     IN     va_list vl,
01219     IN OUT LPVOID  ReturnValue,
01220     IN     LPSTR   LibraryName,
01221     OUT    char    *Buffer,
01222     IN     int     Index,
01223     IN     int     BufLen,
01224     IN     BOOL    PreOrPost);
01225
01226 BOOL CALLBACK
01227 DTHandler_WPUPostMessage(
01228     IN     va_list vl,
01229     IN OUT LPVOID  ReturnValue,
01230     IN     LPSTR   LibraryName,
01231     OUT    char    *Buffer,
01232     IN     int     Index,
01233     IN     int     BufLen,
01234     IN     BOOL    PreOrPost);
01235
01236 BOOL CALLBACK
01237 DTHandler___WSAFDIsSet(
01238     IN     va_list vl,
01239     IN OUT LPVOID  ReturnValue,
01240     IN     LPSTR   LibraryName,
01241     OUT    char    *Buffer,
01242     IN     int     Index,
01243     IN     int     BufLen,
01244     IN     BOOL    PreOrPost);
01245
01246 BOOL CALLBACK
01247 DTHandler_WSCEnumProtocols(
01248     IN     va_list vl,
01249     IN OUT LPVOID  ReturnValue,
01250     IN     LPSTR   LibraryName,
01251     OUT    char    *Buffer,
01252     IN     int     Index,
01253     IN     int     BufLen,
01254     IN     BOOL    PreOrPost);
01255
01256 BOOL CALLBACK
01257 DTHandler_WSAAddressToStringA(
01258     IN     va_list vl,
01259     IN OUT LPVOID  ReturnValue,
01260     IN     LPSTR   LibraryName,
01261     OUT    char    *Buffer,
01262     IN     int     Index,
01263     IN     int     BufLen,
01264     IN     BOOL    PreOrPost);
01265
01266 BOOL CALLBACK
01267 DTHandler_WSAAddressToStringW(
01268     IN     va_list vl,
01269     IN OUT LPVOID  ReturnValue,
01270     IN     LPSTR   LibraryName,
01271     OUT    char    *Buffer,
01272     IN     int     Index,
01273     IN     int     BufLen,
01274     IN     BOOL    PreOrPost);
01275
01276 BOOL CALLBACK
01277 DTHandler_WSAStringToAddressA(
01278     IN     va_list vl,
01279     IN OUT LPVOID  ReturnValue,
01280     IN     LPSTR   LibraryName,
01281     OUT    char    *Buffer,
01282     IN     int     Index,
01283     IN     int     BufLen,
01284     IN     BOOL    PreOrPost);
01285
01286 BOOL CALLBACK
01287 DTHandler_WSAStringToAddressW(
01288     IN     va_list vl,
01289     IN OUT LPVOID  ReturnValue,
01290     IN     LPSTR   LibraryName,
01291     OUT    char    *Buffer,
01292     IN     int     Index,
01293     IN     int     BufLen,
01294     IN     BOOL    PreOrPost);
01295
01296 BOOL CALLBACK
01297 DTHandler_WSALookupServiceBeginA(
01298     IN     va_list vl,
01299     IN OUT LPVOID  ReturnValue,
01300     IN     LPSTR   LibraryName,
01301     OUT    char    *Buffer,
01302     IN     int     Index,
01303     IN     int     BufLen,
01304     IN     BOOL    PreOrPost);
01305
01306 BOOL CALLBACK
01307 DTHandler_WSALookupServiceBeginW(
01308     IN     va_list vl,
01309     IN OUT LPVOID  ReturnValue,
01310     IN     LPSTR   LibraryName,
01311     OUT    char    *Buffer,
01312     IN     int     Index,
01313     IN     int     BufLen,
01314     IN     BOOL    PreOrPost);
01315
01316 BOOL CALLBACK
01317 DTHandler_WSALookupServiceNextA(
01318     IN     va_list vl,
01319     IN OUT LPVOID  ReturnValue,
01320     IN     LPSTR   LibraryName,
01321     OUT    char    *Buffer,
01322     IN     int     Index,
01323     IN     int     BufLen,
01324     IN     BOOL    PreOrPost);
01325
01326 BOOL CALLBACK
01327 DTHandler_WSALookupServiceNextW(
01328     IN     va_list vl,
01329     IN OUT LPVOID  ReturnValue,
01330     IN     LPSTR   LibraryName,
01331     OUT    char    *Buffer,
01332     IN     int     Index,
01333     IN     int     BufLen,
01334     IN     BOOL    PreOrPost);
01335
01336 BOOL CALLBACK
01337 DTHandler_WSALookupServiceEnd(
01338     IN     va_list vl,
01339     IN OUT LPVOID  ReturnValue,
01340     IN     LPSTR   LibraryName,
01341     OUT    char    *Buffer,
01342     IN     int     Index,
01343     IN     int     BufLen,
01344     IN     BOOL    PreOrPost);
01345
01346 BOOL CALLBACK
01347 DTHandler_WSAGetAddressByNameA(
01348     IN     va_list vl,
01349     IN OUT LPVOID  ReturnValue,
01350     IN     LPSTR   LibraryName,
01351     OUT    char    *Buffer,
01352     IN     int     Index,
01353     IN     int     BufLen,
01354     IN     BOOL    PreOrPost);
01355
01356 BOOL CALLBACK
01357 DTHandler_WSAGetAddressByNameW(
01358     IN     va_list vl,
01359     IN OUT LPVOID  ReturnValue,
01360     IN     LPSTR   LibraryName,
01361     OUT    char    *Buffer,
01362     IN     int     Index,
01363     IN     int     BufLen,
01364     IN     BOOL    PreOrPost);
01365
01366 BOOL CALLBACK
01367 DTHandler_WSAInstallServiceClassA(
01368     IN     va_list vl,
01369     IN OUT LPVOID  ReturnValue,
01370     IN     LPSTR   LibraryName,
01371     OUT    char    *Buffer,
01372     IN     int     Index,
01373     IN     int     BufLen,
01374     IN     BOOL    PreOrPost);
01375
01376 BOOL CALLBACK
01377 DTHandler_WSAInstallServiceClassW(
01378     IN     va_list vl,
01379     IN OUT LPVOID  ReturnValue,
01380     IN     LPSTR   LibraryName,
01381     OUT    char    *Buffer,
01382     IN     int     Index,
01383     IN     int     BufLen,
01384     IN     BOOL    PreOrPost);
01385
01386 BOOL CALLBACK
01387 DTHandler_WSASetServiceA(
01388     IN     va_list vl,
01389     IN OUT LPVOID  ReturnValue,
01390     IN     LPSTR   LibraryName,
01391     OUT    char    *Buffer,
01392     IN     int     Index,
01393     IN     int     BufLen,
01394     IN     BOOL    PreOrPost);
01395
01396 BOOL CALLBACK
01397 DTHandler_WSASetServiceW(
01398     IN     va_list vl,
01399     IN OUT LPVOID  ReturnValue,
01400     IN     LPSTR   LibraryName,
01401     OUT    char    *Buffer,
01402     IN     int     Index,
01403     IN     int     BufLen,
01404     IN     BOOL    PreOrPost);
01405
01406 BOOL CALLBACK
01407 DTHandler_WSARemoveServiceClass(
01408     IN     va_list vl,
01409     IN OUT LPVOID  ReturnValue,
01410     IN     LPSTR   LibraryName,
01411     OUT    char    *Buffer,
01412     IN     int     Index,
01413     IN     int     BufLen,
01414     IN     BOOL    PreOrPost);
01415
01416 BOOL CALLBACK
01417 DTHandler_WSAGetServiceClassInfoA(
01418     IN     va_list vl,
01419     IN OUT LPVOID  ReturnValue,
01420     IN     LPSTR   LibraryName,
01421     OUT    char    *Buffer,
01422     IN     int     Index,
01423     IN     int     BufLen,
01424     IN     BOOL    PreOrPost);
01425
01426 BOOL CALLBACK
01427 DTHandler_WSAGetServiceClassInfoW(
01428     IN     va_list vl,
01429     IN OUT LPVOID  ReturnValue,
01430     IN     LPSTR   LibraryName,
01431     OUT    char    *Buffer,
01432     IN     int     Index,
01433     IN     int     BufLen,
01434     IN     BOOL    PreOrPost);
01435
01436 BOOL CALLBACK
01437 DTHandler_WSAEnumNameSpaceProvidersA(
01438     IN     va_list vl,
01439     IN OUT LPVOID  ReturnValue,
01440     IN     LPSTR   LibraryName,
01441     OUT    char    *Buffer,
01442     IN     int     Index,
01443     IN     int     BufLen,
01444     IN     BOOL    PreOrPost);
01445
01446 BOOL CALLBACK
01447 DTHandler_WSAEnumNameSpaceProvidersW(
01448     IN     va_list vl,
01449     IN OUT LPVOID  ReturnValue,
01450     IN     LPSTR   LibraryName,
01451     OUT    char    *Buffer,
01452     IN     int     Index,
01453     IN     int     BufLen,
01454     IN     BOOL    PreOrPost);
01455
01456 BOOL CALLBACK
01457 DTHandler_WSAGetServiceClassNameByClassIdA(
01458     IN     va_list vl,
01459     IN OUT LPVOID  ReturnValue,
01460     IN     LPSTR   LibraryName,
01461     OUT    char    *Buffer,
01462     IN     int     Index,
01463     IN     int     BufLen,
01464     IN     BOOL    PreOrPost);
01465
01466 BOOL CALLBACK
01467 DTHandler_WSAGetServiceClassNameByClassIdW(
01468     IN     va_list vl,
01469     IN OUT LPVOID  ReturnValue,
01470     IN     LPSTR   LibraryName,
01471     OUT    char    *Buffer,
01472     IN     int     Index,
01473     IN     int     BufLen,
01474     IN     BOOL    PreOrPost);
01475
01476 BOOL CALLBACK
01477 DTHandler_NSPCleanup(
01478     IN     va_list vl,
01479     IN OUT LPVOID  ReturnValue,
01480     IN     LPSTR   LibraryName,
01481     OUT    char    *Buffer,
01482     IN     int     Index,
01483     IN     int     BufLen,
01484     IN     BOOL    PreOrPost);
01485
01486 BOOL CALLBACK
01487 DTHandler_NSPLookupServiceBegin(
01488     IN     va_list vl,
01489     IN OUT LPVOID  ReturnValue,
01490     IN     LPSTR   LibraryName,
01491     OUT    char    *Buffer,
01492     IN     int     Index,
01493     IN     int     BufLen,
01494     IN     BOOL    PreOrPost);
01495
01496 BOOL CALLBACK
01497 DTHandler_NSPLookupServiceNext(
01498     IN     va_list vl,
01499     IN OUT LPVOID  ReturnValue,
01500     IN     LPSTR   LibraryName,
01501     OUT    char    *Buffer,
01502     IN     int     Index,
01503     IN     int     BufLen,
01504     IN     BOOL    PreOrPost);
01505
01506 BOOL CALLBACK
01507 DTHandler_NSPLookupServiceEnd(
01508     IN     va_list vl,
01509     IN OUT LPVOID  ReturnValue,
01510     IN     LPSTR   LibraryName,
01511     OUT    char    *Buffer,
01512     IN     int     Index,
01513     IN     int     BufLen,
01514     IN     BOOL    PreOrPost);
01515
01516 BOOL CALLBACK
01517 DTHandler_NSPSetService(
01518     IN     va_list vl,
01519     IN OUT LPVOID  ReturnValue,
01520     IN     LPSTR   LibraryName,
01521     OUT    char    *Buffer,
01522     IN     int     Index,
01523     IN     int     BufLen,
01524     IN     BOOL    PreOrPost);
01525
01526 BOOL CALLBACK
01527 DTHandler_NSPInstallServiceClass(
01528     IN     va_list vl,
01529     IN OUT LPVOID  ReturnValue,
01530     IN     LPSTR   LibraryName,
01531     OUT    char    *Buffer,
01532     IN     int     Index,
01533     IN     int     BufLen,
01534     IN     BOOL    PreOrPost);
01535
01536 BOOL CALLBACK
01537 DTHandler_NSPRemoveServiceClass(
01538     IN     va_list vl,
01539     IN OUT LPVOID  ReturnValue,
01540     IN     LPSTR   LibraryName,
01541     OUT    char    *Buffer,
01542     IN     int     Index,
01543     IN     int     BufLen,
01544     IN     BOOL    PreOrPost);
01545
01546 BOOL CALLBACK
01547 DTHandler_NSPGetServiceClassInfo(
01548     IN     va_list vl,
01549     IN OUT LPVOID  ReturnValue,
01550     IN     LPSTR   LibraryName,
01551     OUT    char    *Buffer,
01552     IN     int     Index,
01553     IN     int     BufLen,
01554     IN     BOOL    PreOrPost);
01555
01556
01557
01558 
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/GSS/GssMisc.c Source File

  • Security
  • SSPI
  • GSS

GssMisc.c

Go to the documentation of this file.
00001 /*
00002  * Copyright 1994 by OpenVision Technologies, Inc.
00003  *
00004  * Permission to use, copy, modify, distribute, and sell this software
00005  * and its documentation for any purpose is hereby granted without fee,
00006  * provided that the above copyright notice appears in all copies and
00007  * that both that copyright notice and this permission notice appear in
00008  * supporting documentation, and that the name of OpenVision not be used
00009  * in advertising or publicity pertaining to distribution of the software
00010  * without specific, written prior permission. OpenVision makes no
00011  * representations about the suitability of this software for any
00012  * purpose.  It is provided "as is" without express or implied warranty.
00013  *
00014  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00015  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
00016  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00017  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
00018  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
00019  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00020  * PERFORMANCE OF THIS SOFTWARE.
00021  */
00022
00023 #include "gss-misc.h"
00024
00025 FILE *display_file;
00026
00027 void display_status_1
00028 PROTOTYPE( (char *m, ULONG code, int type) );
00029
00030 int write_all(int fildes, char *buf, unsigned int nbyte)
00031 {
00032    int ret;
00033    char *ptr;
00034
00035    for (ptr = buf; nbyte; ptr += ret, nbyte -= ret)
00036    {
00037       ret = send(fildes, ptr, nbyte,0);
00038       if (ret < 0)
00039       {
00040          return (ret);
00041       }
00042       else if (ret == 0)
00043       {
00044          return (int)(ptr-buf);
00045       }
00046    }
00047
00048    return (int)(ptr-buf);
00049 }
00050
00051 int read_all(int fildes, char *buf, unsigned int nbyte)
00052 {
00053    int ret;
00054    char *ptr;
00055
00056    for (ptr = buf; nbyte; ptr += ret, nbyte -= ret)
00057    {
00058       ret = recv(fildes, ptr, nbyte,0);
00059       if (ret < 0)
00060       {
00061          return (ret);
00062       }
00063       else if (ret == 0)
00064       {
00065          return (int)(ptr-buf);
00066       }
00067    }
00068
00069    return (int)(ptr-buf);
00070 }
00071
00072 /*
00073  * Function: send_token
00074  *
00075  * Purpose: Writes a token to a file descriptor.
00076  *
00077  * Arguments:
00078  *
00079  *      s               (r) an open file descriptor
00080  *      tok             (r) the token to write
00081  *
00082  * Returns: 0 on success, -1 on failure
00083  *
00084  * Effects:
00085  *
00086  * send_token writes the token length (as a network long) and then the
00087  * token data to the file descriptor s.  It returns 0 on success, and
00088  * -1 if an error occurs or if it could not write all the data.
00089  */
00090 int send_token(s, tok)
00091 int s;
00092 PSecBuffer tok;
00093 {
00094    ULONG len;
00095    ULONG ret;
00096
00097    len = htonl(tok->cbBuffer);
00098
00099    ret = write_all(s, (char *) &len, 4);
00100    if (ret < 0)
00101    {
00102       perror("sending token length");
00103       return -1;
00104    }
00105    else if (ret != 4)
00106    {
00107       if (display_file)
00108          fprintf(display_file,
00109                  "sending token length: %d of %d bytes written\n",
00110                  ret, 4);
00111       return -1;
00112    }
00113
00114    ret = write_all(s, tok->pvBuffer, tok->cbBuffer);
00115    if (ret < 0)
00116    {
00117       perror("sending token data");
00118       return -1;
00119    }
00120    else if (ret != tok->cbBuffer)
00121    {
00122       if (display_file)
00123          fprintf(display_file,
00124                  "sending token data: %d of %d bytes written\n",
00125                  ret, tok->cbBuffer);
00126       return -1;
00127    }
00128
00129    return 0;
00130 }
00131
00132 /*
00133  * Function: recv_token
00134  *
00135  * Purpose: Reads a token from a file descriptor.
00136  *
00137  * Arguments:
00138  *
00139  *      s               (r) an open file descriptor
00140  *      tok             (w) the read token
00141  *
00142  * Returns: 0 on success, -1 on failure
00143  *
00144  * Effects:
00145  *
00146  * recv_token reads the token length (as a network long), allocates
00147  * memory to hold the data, and then reads the token data from the
00148  * file descriptor s.  It blocks to read the length and data, if
00149  * necessary.  On a successful return, the token should be freed with
00150  * gss_release_buffer.  It returns 0 on success, and -1 if an error
00151  * occurs or if it could not read all the data.
00152  */
00153 int recv_token(s, tok)
00154 int s;
00155 PSecBuffer tok;
00156 {
00157    ULONG ret;
00158
00159    ret = read_all(s, (char *) &tok->cbBuffer, 4);
00160    if (ret < 0)
00161    {
00162       perror("reading token length");
00163       return -1;
00164    }
00165    else if (ret != 4)
00166    {
00167       if (display_file)
00168          fprintf(display_file,
00169                  "reading token length: %d of %d bytes read\n",
00170                  ret, 4);
00171       return -1;
00172    }
00173
00174    tok->cbBuffer = ntohl(tok->cbBuffer);
00175    tok->pvBuffer = (char *) malloc(tok->cbBuffer);
00176    if (tok->pvBuffer == NULL)
00177    {
00178       if (display_file)
00179          fprintf(display_file,
00180                  "Out of memory allocating token data\n");
00181       return -1;
00182    }
00183
00184    ret = read_all(s, (char *) tok->pvBuffer, tok->cbBuffer);
00185    if (ret < 0)
00186    {
00187       perror("reading token data");
00188       free(tok->pvBuffer);
00189       return -1;
00190    }
00191    else if (ret != tok->cbBuffer)
00192    {
00193       fprintf(stderr, "sending token data: %d of %d bytes written\n",
00194               ret, tok->cbBuffer);
00195       free(tok->pvBuffer);
00196       return -1;
00197    }
00198
00199    return 0;
00200 }
00201
00202 void display_status_1(m, code, type)
00203 char *m;
00204 ULONG code;
00205 int type;
00206 {
00207
00208    if (display_file)
00209       fprintf(display_file, "GSS-API error %s: %x\n", m,
00210               code);
00211 }
00212
00213 /*
00214  * Function: display_status
00215  *
00216  * Purpose: displays GSS-API messages
00217  *
00218  * Arguments:
00219  *
00220  *      msg             a string to be displayed with the message
00221  *      maj_stat        the GSS-API major status code
00222  *      min_stat        the GSS-API minor status code
00223  *
00224  * Effects:
00225  *
00226  * The GSS-API messages associated with maj_stat and min_stat are
00227  * displayed on stderr, each preceeded by "GSS-API error <msg>: " and
00228  * followed by a newline.
00229  */
00230 void display_status(msg, maj_stat, min_stat)
00231 char *msg;
00232 ULONG maj_stat;
00233 ULONG min_stat;
00234 {
00235    display_status_1(msg, maj_stat, GSS_C_GSS_CODE);
00236    display_status_1(msg, min_stat, GSS_C_MECH_CODE);
00237 }
00238
00239 /*
00240  * Function: display_ctx_flags
00241  *
00242  * Purpose: displays the flags returned by context initation in
00243  *          a human-readable form
00244  *
00245  * Arguments:
00246  *
00247  *      int             ret_flags
00248  *
00249  * Effects:
00250  *
00251  * Strings corresponding to the context flags are printed on
00252  * stdout, preceded by "context flag: " and followed by a newline
00253  */
00254
00255 void display_ctx_flags(flags)
00256 ULONG flags;
00257 {
00258    if (flags & GSS_C_DELEG_FLAG)
00259       fprintf(display_file, "context flag: GSS_C_DELEG_FLAG\n");
00260    if (flags & GSS_C_MUTUAL_FLAG)
00261       fprintf(display_file, "context flag: GSS_C_MUTUAL_FLAG\n");
00262    if (flags & GSS_C_REPLAY_FLAG)
00263       fprintf(display_file, "context flag: GSS_C_REPLAY_FLAG\n");
00264    if (flags & GSS_C_SEQUENCE_FLAG)
00265       fprintf(display_file, "context flag: GSS_C_SEQUENCE_FLAG\n");
00266    if (flags & GSS_C_CONF_FLAG )
00267       fprintf(display_file, "context flag: GSS_C_CONF_FLAG \n");
00268    if (flags & GSS_C_INTEG_FLAG )
00269       fprintf(display_file, "context flag: GSS_C_INTEG_FLAG \n");
00270 }
00271
00272 void print_token(tok)
00273 PSecBuffer tok;
00274 {
00275    ULONG i;
00276    unsigned char *p = (PUCHAR) tok->pvBuffer;
00277
00278    if (!display_file)
00279       return;
00280    for (i=0; i < tok->cbBuffer; i++, p++)
00281    {
00282       fprintf(display_file, "%02x ", *p);
00283       if ((i % 16) == 15)
00284       {
00285          fprintf(display_file, "\n");
00286       }
00287    }
00288    fprintf(display_file, "\n");
00289    fflush(display_file);
00290 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_BLRPLATECONFIG Member List

This is the complete list of members for _BLRPLATECONFIG, including all inherited members.
nTotalLength _BLRPLATECONFIG
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHelloEditSession Member List

This is the complete list of members for CHelloEditSession, including all inherited members.
_pContext | CEditSessionBase | [protected]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CHelloEditSession(ITfContext *pContext) | CHelloEditSession | [inline]
DoEditSession(TfEditCookie ec) | CHelloEditSession | [virtual]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmMonitor/DllDatax.h Source File

  • Com
  • Services
  • Crm
  • CrmMonitor

DllDatax.h

Go to the documentation of this file.
00001 #if !defined(AFX_DLLDATAX_H__1721CAC0_E9BA_11D1_A8D7_00A0C91EEDE9__INCLUDED_)
00002 #define AFX_DLLDATAX_H__1721CAC0_E9BA_11D1_A8D7_00A0C91EEDE9__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007
00008 #ifdef _MERGE_PROXYSTUB
00009
00010 extern "C"
00011 {
00012 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
00013   LPVOID lpReserved);
00014 STDAPI PrxDllCanUnloadNow(void);
00015 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
00016 STDAPI PrxDllRegisterServer(void);
00017 STDAPI PrxDllUnregisterServer(void);
00018 }
00019
00020 #endif
00021
00022 //{{AFX_INSERT_LOCATION}}
00023 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00024
00025 #endif // !defined(AFX_DLLDATAX_H__1721CAC0_E9BA_11D1_A8D7_00A0C91EEDE9__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagDescType Member List

This is the complete list of members for tagDescType, including all inherited members.
szDescName | tagDescType
uwDescType | tagDescType
uwTypeMask | tagDescType
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/adddevicedlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

adddevicedlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddDeviceDlg.cpp:  Implementation of the CAddDeviceDlg class.
00015 //
00016
00017
00018
00019 #include "AddDeviceDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddDeviceDlg::CAddDeviceDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddDeviceDlg::~CAddDeviceDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddDeviceDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00055   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00056
00057   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00060   lResult = SendMessage( hBackupCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00061   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00062
00063   lResult = SetWindowText( hDevNameCtrl, _T("") );
00064   SetFocus( hDevNameCtrl );
00065
00066   return 0;
00067 }
00068
00069 //---------------------------------------------------------------------------
00070 LRESULT CAddDeviceDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00071 {
00072   LRESULT          lResult = 0;
00073   NODE_PROPERTIES  NodeProps;
00074
00075   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00076
00077   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00078   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00079   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00080   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00081   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00082   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00083
00084   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00086
00087   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00089
00090   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00092
00093   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00094     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00095
00096   if( BST_CHECKED == SendMessage( hBackupCtrl, BM_GETCHECK, 0, 0 ) )
00097     NodeProps.dwAttributes |= ATTRIBUTE_BACKUP_DEVICE;
00098
00099   // Convert to wide characters here for all platforms.  This is the node name
00100   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00101   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00102   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00103   // Probably a good idea to check for NULL name strings here
00104
00105   // This message passes the user supplied info to the Static Node
00106   SendMessage( m_hParentWnd, WM_ADD_DEVICENODE, (WPARAM)&NodeProps, 0 );
00107
00108   // Now tell the static node we are deleting ourselves so the
00109   // context menu option can be enabled
00110   SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00111
00112   // Call the base class to shut down the dialog
00113   CBaseDialog::OnOK( hDlg, wParam, lParam );
00114   return 0;
00115 }
00116
00117 /////////////////////////////////////////////////////////////////////////////
00118 //  Virtual function implementations
00119
00120 //---------------------------------------------------------------------------
00121 BOOL CAddDeviceDlg::ProcessMessage
00122 (
00123   HWND     hDlg,           //[in] Handle to dialog box
00124   UINT     uMsg,           //[in] Message
00125   WPARAM   wParam,         //[in] First message parameter
00126   LPARAM   lParam          //[in] Second message parameter
00127 )
00128 {
00129   LRESULT lResult = 0;
00130
00131   switch( uMsg )
00132   {
00133     case WM_INITDIALOG:
00134       lResult = OnInitDialog( hDlg, wParam, lParam );
00135       break;
00136
00137     case WM_DESTROY:
00138       lResult = OnDestroy( hDlg, wParam, lParam );
00139       break;
00140
00141     case WM_NCDESTROY:
00142       lResult = OnNcDestroy( hDlg, wParam, lParam );
00143       break;
00144
00145     case WM_CLOSE:
00146       // Not overriding WM_CLOSE and IDCANCEL so we must send
00147       // WM_DEVICENODE_CLOSED before calling the base class or else
00148       // the context menu will stay grayed
00149       SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00150       lResult = OnClose( hDlg, wParam, lParam );
00151       break;
00152
00153     case WM_COMMAND:
00154       switch( wParam )
00155       {
00156         case IDOK:
00157           lResult = OnOK( hDlg, wParam, lParam );
00158           break;
00159
00160         case IDCANCEL:
00161           SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00162           lResult = OnCancel( hDlg, wParam, lParam );
00163           break;
00164
00165         default:
00166           break;
00167       }
00168     default:
00169       break;
00170   }
00171   return (BOOL)lResult;
00172 }
00173
00174
00175
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

LOGPAL Member List

This is the complete list of members for LOGPAL, including all inherited members.
cpe | LOGPAL
rgpe | LOGPAL
wVersion | LOGPAL
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/string_fast.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

string_fast.h

Go to the documentation of this file.
00001 #ifndef STRING_FAST
00002 #define STRING_FAST
00003
00004 #include <stdarg.h>
00005
00006 extern inline long wcscpy_count (WCHAR *d, WCHAR const *s);
00007 extern inline long WriteChars(WCHAR* string, int nData);
00008 extern inline long WriteChars(WCHAR* str, const WCHAR *text);
00009 extern inline long WriteChars(WCHAR* str, const WCHAR *str1, const WCHAR *str2, const WCHAR *str3);
00010 extern inline long WriteChars(WCHAR* str, const WCHAR *name, const WCHAR *data, short nDay, short nYear);
00011 extern inline long WriteChars(WCHAR* str, const WCHAR *name, const WCHAR *data, int slen, bool bQuotes);
00012 extern inline long WriteChars(WCHAR* string, const WCHAR *name, int nData);
00013 extern inline WCHAR * wcscpy_fast (WCHAR *d, WCHAR const *s);
00014 extern inline WCHAR * __cdecl wcsncpy_fast (WCHAR * dest, const WCHAR * source, size_t count);
00015 extern inline int wcsncmp_fast (const WCHAR * first, const WCHAR * last, size_t count);
00016 extern inline int __cdecl wcscmp_fast (const WCHAR * src, const WCHAR * dst);
00017
00018 #endif /* STRING_FAST */
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/CapMFC.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

CapMFC.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 #include "stdafx.h"
00045 #include "CapMFC.h"
00046 #include "MainDlg.h"
00047
00048 #ifdef _DEBUG
00049 #define new DEBUG_NEW
00050 #undef THIS_FILE
00051 static char THIS_FILE[] = __FILE__;
00052 #endif
00053
00054 // Application Title
00055
00056 extern const LPTSTR kpszAppTitle = _T("Microsoft Agent Character Previewer");
00057
00058
00059 BEGIN_MESSAGE_MAP(CCapMFCApp, CWinApp)
00060   //{{AFX_MSG_MAP(CCapMFCApp)
00061   //}}AFX_MSG
00062   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00063 END_MESSAGE_MAP()
00064
00065
00066 CCapMFCApp::CCapMFCApp() {
00067 }
00068
00069 CCapMFCApp theApp;
00070
00071
00072 BOOL CCapMFCApp::InitInstance() {
00073
00074   AfxEnableControlContainer();
00075
00076   // Standard initialization
00077
00078 #ifdef _AFXDLL
00079   Enable3dControls();     // Call this when using MFC in a shared DLL
00080 #else
00081   Enable3dControlsStatic(); // Call this when linking to MFC statically
00082 #endif
00083
00084   CCapMFCDlg dlg;
00085   m_pMainWnd = &dlg;
00086
00087   dlg.DoModal();
00088
00089   return FALSE;
00090 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/InvokObjThreads/IsapiThread.h Source File

  • Web
  • iis
  • extensions
  • InvokObjThreads

IsapiThread.h

Go to the documentation of this file.
00001 //  Copyright (c) 1998-2002 Microsoft Corporation
00002 //
00003 //  Module Name:
00004 //
00005 //    IsapiThread.h
00006 //
00007 //  Abstract:
00008 //
00009 //    Header file for the IsapiThread class
00010
00011 #ifndef _ISAPITHREAD_DEFINED
00012 #define _ISAPITHREAD_DEFINED
00013
00014 #include <windows.h>
00015 #include <httpext.h>
00016
00017 class ISAPITHREAD
00018 {
00019   public:
00020
00021     // Semaphore handle
00022
00023     HANDLE m_hWorkerThreadSemaphore;
00024
00025     // Init and queue functions
00026
00027     BOOL InitThreadPool(
00028       LPTHREAD_START_ROUTINE pThreadProc,         // Worker thread proc
00029       DWORD dwNumThreads = 5,                     // number of threads in pool
00030       DWORD dwQueueSize = 0xffffffff);            // size of work item queue
00031
00032     BOOL QueueWorkItem(
00033       EXTENSION_CONTROL_BLOCK *pecb,              // ECB to queue
00034       BOOL fReleaseThread = TRUE);                // Release thread automatically?
00035
00036     EXTENSION_CONTROL_BLOCK *GetWorkItem(void);
00037
00038     void ReleaseThread(DWORD dwNumThreads = 1);   // Number of threads to release
00039
00040     void ClearQueue(void);
00041
00042     //
00043     // Constructor and destructor
00044     //
00045
00046     ISAPITHREAD(void);
00047     ~ISAPITHREAD(void);
00048
00049   private:
00050
00051     EXTENSION_CONTROL_BLOCK **m_WorkItemQueue;
00052     CRITICAL_SECTION m_csQueue;
00053     DWORD m_dwNumThreads;
00054     DWORD m_dwWorkItemQueueSize;
00055     DWORD m_dwCurrentItem;
00056     DWORD m_dwItemsInQueue;
00057     HANDLE *m_arrWorkerThreads;
00058 };
00059
00060 #endif  // _ISAPITHREAD_DEFINED
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • Proppage

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/SSL/WebServer/WebServer.c Source File

  • Security
  • SSPI
  • SSL
  • WebServer

WebServer.c

Go to the documentation of this file.
00001 /*++
00002
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1999 - 2002  Microsoft Corporation.  All rights reserved.
00009
00010 Module Name:
00011
00012     webserver.c
00013
00014 Abstract:
00015
00016     Schannel web server sample application.
00017
00018 --*/
00019
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <windows.h>
00023 #include <winsock.h>
00024 #include <wincrypt.h>
00025 #include <wintrust.h>
00026 #include <schannel.h>
00027
00028 #define SECURITY_WIN32
00029 #include <security.h>
00030 #include <sspi.h>
00031
00032 #define IO_BUFFER_SIZE  0x10000
00033 #define DLL_NAME TEXT("Secur32.dll")
00034 #define NT4_DLL_NAME TEXT("Security.dll")
00035
00036 // User options.
00037 INT     iPortNumber     = 443;
00038 BOOL    fVerbose        = FALSE;
00039 LPSTR   pszUserName     = NULL;
00040 BOOL    fClientAuth     = FALSE;
00041 BOOL    fMachineStore   = FALSE;
00042 DWORD   dwProtocol      = 0;
00043
00044 HCERTSTORE  hMyCertStore = NULL;
00045
00046 CHAR IoBuffer[IO_BUFFER_SIZE];
00047 DWORD cbIoBuffer = 0;
00048
00049 HMODULE g_hSecurity = NULL;
00050
00051 PSecurityFunctionTable g_pSSPI;
00052
00053
00054 static
00055 DWORD
00056 CreateCredentials(
00057     LPSTR pszUserName,
00058     PCredHandle phCreds);
00059
00060 static void
00061 WebServer(CredHandle *phServerCreds);
00062
00063 static
00064 BOOL
00065 ParseRequest (
00066     IN PCHAR InputBuffer,
00067     IN INT InputBufferLength,
00068     OUT PCHAR ObjectName,
00069     OUT DWORD *pcbContentLength);
00070
00071 static
00072 BOOL
00073 SSPINegotiateLoop(
00074     SOCKET          Socket,
00075     PCtxtHandle     phContext,
00076     PCredHandle     phCred,
00077     BOOL            fClientAuth,
00078     BOOL            fDoInitialRead,
00079     BOOL            NewContext);
00080
00081 static
00082 LONG
00083 DisconnectFromClient(
00084     SOCKET          Socket,
00085     PCredHandle     phCreds,
00086     CtxtHandle *    phContext);
00087
00088 static void PrintHexDump(DWORD length, PBYTE buffer);
00089
00090
00091 /*****************************************************************************/
00092 void Usage(void)
00093 {
00094     printf("\n");
00095     printf("USAGE: webserver -u<user> [ <options> ]\n");
00096     printf("\n");
00097     printf("    -u<user>        Name of user (in existing certificate)\n");
00098     printf("    -U<user>        Name of user (machine store)\n");
00099     printf("    -p<port>        Port to listen on (default 443).\n");
00100     printf("    -a              Ask for client authentication.\n");
00101     printf("    -v              Verbose Mode.\n");
00102     printf("    -P<protocol>    Protocol to use\n");
00103     printf("                        2 = SSL 2.0\n");
00104     printf("                        3 = SSL 3.0\n");
00105     printf("                        4 = TLS 1.0\n");
00106
00107     exit(1);
00108 }
00109
00110 /*****************************************************************************/
00111 BOOL
00112 LoadSecurityLibrary(void)
00113 {
00114     INIT_SECURITY_INTERFACE         pInitSecurityInterface;
00115     QUERY_CREDENTIALS_ATTRIBUTES_FN pQueryCredentialsAttributes;
00116     OSVERSIONINFO VerInfo;
00117     UCHAR lpszDLL[MAX_PATH];
00118
00119     //
00120     //  Find out which security DLL to use, depending on
00121     //  whether we are on Win2k, NT or Win9x
00122     //
00123
00124     VerInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
00125     if (!GetVersionEx (&VerInfo))
00126     {
00127         return FALSE;
00128     }
00129
00130     if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT
00131         && VerInfo.dwMajorVersion == 4)
00132     {
00133         strcpy (lpszDLL, NT4_DLL_NAME );
00134     }
00135     else if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
00136           VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
00137     {
00138         strcpy (lpszDLL, DLL_NAME );
00139     }
00140     else
00141     {
00142         return FALSE;
00143     }
00144
00145     //
00146     //  Load Security DLL
00147     //
00148
00149     g_hSecurity = LoadLibrary(lpszDLL);
00150     if(g_hSecurity == NULL)
00151     {
00152         printf("Error 0x%x loading %s.\n", GetLastError(), lpszDLL);
00153         return FALSE;
00154     }
00155
00156     pInitSecurityInterface = (INIT_SECURITY_INTERFACE)GetProcAddress(
00157                                     g_hSecurity,
00158                                     "InitSecurityInterfaceA");
00159
00160     if(pInitSecurityInterface == NULL)
00161     {
00162         printf("Error 0x%x reading InitSecurityInterface entry point.\n",
00163                GetLastError());
00164         return FALSE;
00165     }
00166
00167     g_pSSPI = pInitSecurityInterface();
00168
00169     if(g_pSSPI == NULL)
00170     {
00171         printf("Error 0x%x reading security interface.\n",
00172                GetLastError());
00173         return FALSE;
00174     }
00175
00176     return TRUE;
00177 }
00178
00179 /*****************************************************************************/
00180 void
00181 UnloadSecurityLibrary(void)
00182 {
00183     FreeLibrary(g_hSecurity);
00184     g_hSecurity = NULL;
00185 }
00186
00187
00188 /*****************************************************************************/
00189 void _cdecl main(int argc, char *argv[])
00190 {
00191     WSADATA WsaData;
00192     CredHandle hServerCreds;
00193
00194     INT i;
00195     INT iOption;
00196     PCHAR pszOption;
00197
00198     //
00199     // Parse the command line.
00200     //
00201
00202     if(argc <= 1)
00203     {
00204         Usage();
00205     }
00206
00207     for(i = 1; i < argc; i++)
00208     {
00209         if(argv[i][0] == '/') argv[i][0] = '-';
00210
00211         if(argv[i][0] != '-')
00212         {
00213             printf("**** Invalid argument \"%s\"\n", argv[i]);
00214             Usage();
00215         }
00216
00217         iOption = argv[i][1];
00218         pszOption = &argv[i][2];
00219
00220         switch(iOption)
00221         {
00222         case 'p':
00223             iPortNumber = atoi(pszOption);
00224             break;
00225
00226         case 'v':
00227             fVerbose = TRUE;
00228             break;
00229
00230         case 'u':
00231             pszUserName = pszOption;
00232             fMachineStore = FALSE;
00233             break;
00234
00235         case 'U':
00236             pszUserName = pszOption;
00237             fMachineStore = TRUE;
00238             break;
00239
00240         case 'a':
00241             fClientAuth = TRUE;
00242             break;
00243
00244         case 'P':
00245             switch(atoi(pszOption))
00246             {
00247                 case 2:
00248                     dwProtocol = SP_PROT_SSL2;
00249                     break;
00250                 case 3:
00251                     dwProtocol = SP_PROT_SSL3;
00252                     break;
00253                 case 4:
00254                     dwProtocol = SP_PROT_TLS1;
00255                     break;
00256                 default:
00257                     dwProtocol = 0;
00258                     break;
00259             }
00260             break;
00261
00262         default:
00263             printf("**** Invalid option \"%s\"\n", argv[i]);
00264             Usage();
00265         }
00266     }
00267
00268     if(!LoadSecurityLibrary())
00269     {
00270         printf("Error initializing the security library\n");
00271         return;
00272     }
00273
00274     //
00275     // Initialize the WinSock subsystem.
00276     //
00277
00278     if(WSAStartup(0x0101, &WsaData) == SOCKET_ERROR)
00279     {
00280         printf("Error %d returned by WSAStartup\n", GetLastError());
00281         exit(1);
00282     }
00283
00284     //
00285     // NOTE: In theory, an application could enumerate the security packages
00286     // until it finds one with attributes it likes. Some applications
00287     // (such as IIS) enumerate the packages and call AcquireCredentialsHandle
00288     // on each until it finds one that accepts the SCHANNEL_CRED structure.
00289     // If an application has its heart set on using SSL, like this sample does,
00290     // then just hardcoding the UNISP_NAME package name when calling
00291     // AcquireCredentialsHandle is not a bad thing.
00292     //
00293
00294     //
00295     // Create credentials.
00296     //
00297
00298     if(CreateCredentials(pszUserName, &hServerCreds))
00299     {
00300         printf("Error creating credentials\n");
00301         exit(1);
00302     }
00303
00304
00305     WebServer(&hServerCreds);
00306
00307     // Free SSPI credentials handle.
00308     g_pSSPI->FreeCredentialsHandle(&hServerCreds);
00309
00310     // Shutdown WinSock subsystem.
00311     WSACleanup();
00312
00313     // Close "MY" certificate store.
00314     if(hMyCertStore)
00315     {
00316         CertCloseStore(hMyCertStore, 0);
00317     }
00318
00319
00320     exit(0);
00321 }
00322
00323 /*****************************************************************************/
00324 static
00325 void
00326 DisplayCertChain(
00327     PCCERT_CONTEXT pServerCert)
00328 {
00329     CHAR szName[1000];
00330     PCCERT_CONTEXT pCurrentCert;
00331     PCCERT_CONTEXT pIssuerCert;
00332     DWORD dwVerificationFlags;
00333
00334     printf("\n");
00335
00336     // display leaf name
00337     if(!CertNameToStr(pServerCert->dwCertEncodingType,
00338                       &pServerCert->pCertInfo->Subject,
00339                       CERT_X500_NAME_STR | CERT_NAME_STR_NO_PLUS_FLAG,
00340                       szName, sizeof(szName)))
00341     {
00342         printf("**** Error 0x%x building subject name\n", GetLastError());
00343     }
00344     printf("Client subject: %s\n", szName);
00345     if(!CertNameToStr(pServerCert->dwCertEncodingType,
00346                       &pServerCert->pCertInfo->Issuer,
00347                       CERT_X500_NAME_STR | CERT_NAME_STR_NO_PLUS_FLAG,
00348                       szName, sizeof(szName)))
00349     {
00350         printf("**** Error 0x%x building issuer name\n", GetLastError());
00351     }
00352     printf("Client issuer: %s\n\n", szName);
00353
00354     // display certificate chain
00355     pCurrentCert = pServerCert;
00356     while(pCurrentCert != NULL)
00357     {
00358         dwVerificationFlags = 0;
00359         pIssuerCert = CertGetIssuerCertificateFromStore(pServerCert->hCertStore,
00360                                                         pCurrentCert,
00361                                                         NULL,
00362                                                         &dwVerificationFlags);
00363         if(pIssuerCert == NULL)
00364         {
00365             if(pCurrentCert != pServerCert)
00366             {
00367                 CertFreeCertificateContext(pCurrentCert);
00368             }
00369             break;
00370         }
00371
00372         if(!CertNameToStr(pIssuerCert->dwCertEncodingType,
00373                           &pIssuerCert->pCertInfo->Subject,
00374                           CERT_X500_NAME_STR | CERT_NAME_STR_NO_PLUS_FLAG,
00375                           szName, sizeof(szName)))
00376         {
00377             printf("**** Error 0x%x building subject name\n", GetLastError());
00378         }
00379         printf("CA subject: %s\n", szName);
00380         if(!CertNameToStr(pIssuerCert->dwCertEncodingType,
00381                           &pIssuerCert->pCertInfo->Issuer,
00382                           CERT_X500_NAME_STR | CERT_NAME_STR_NO_PLUS_FLAG,
00383                           szName, sizeof(szName)))
00384         {
00385             printf("**** Error 0x%x building issuer name\n", GetLastError());
00386         }
00387         printf("CA issuer: %s\n\n", szName);
00388
00389         if(pCurrentCert != pServerCert)
00390         {
00391             CertFreeCertificateContext(pCurrentCert);
00392         }
00393         pCurrentCert = pIssuerCert;
00394         pIssuerCert = NULL;
00395     }
00396 }
00397
00398
00399 /*****************************************************************************/
00400 static
00401 void
00402 DisplayWinVerifyTrustError(DWORD Status)
00403 {
00404     LPSTR pszName = NULL;
00405
00406     switch(Status)
00407     {
00408     case CERT_E_EXPIRED:                pszName = "CERT_E_EXPIRED";                 break;
00409     case CERT_E_VALIDITYPERIODNESTING:  pszName = "CERT_E_VALIDITYPERIODNESTING";   break;
00410     case CERT_E_ROLE:                   pszName = "CERT_E_ROLE";                    break;
00411     case CERT_E_PATHLENCONST:           pszName = "CERT_E_PATHLENCONST";            break;
00412     case CERT_E_CRITICAL:               pszName = "CERT_E_CRITICAL";                break;
00413     case CERT_E_PURPOSE:                pszName = "CERT_E_PURPOSE";                 break;
00414     case CERT_E_ISSUERCHAINING:         pszName = "CERT_E_ISSUERCHAINING";          break;
00415     case CERT_E_MALFORMED:              pszName = "CERT_E_MALFORMED";               break;
00416     case CERT_E_UNTRUSTEDROOT:          pszName = "CERT_E_UNTRUSTEDROOT";           break;
00417     case CERT_E_CHAINING:               pszName = "CERT_E_CHAINING";                break;
00418     case TRUST_E_FAIL:                  pszName = "TRUST_E_FAIL";                   break;
00419     case CERT_E_REVOKED:                pszName = "CERT_E_REVOKED";                 break;
00420     case CERT_E_UNTRUSTEDTESTROOT:      pszName = "CERT_E_UNTRUSTEDTESTROOT";       break;
00421     case CERT_E_REVOCATION_FAILURE:     pszName = "CERT_E_REVOCATION_FAILURE";      break;
00422     case CERT_E_CN_NO_MATCH:            pszName = "CERT_E_CN_NO_MATCH";             break;
00423     case CERT_E_WRONG_USAGE:            pszName = "CERT_E_WRONG_USAGE";             break;
00424     default:                            pszName = "(unknown)";                      break;
00425     }
00426
00427     printf("Error 0x%x (%s) returned by CertVerifyCertificateChainPolicy!\n",
00428         Status, pszName);
00429 }
00430
00431 /*****************************************************************************/
00432 static
00433 DWORD
00434 VerifyClientCertificate(
00435     PCCERT_CONTEXT  pServerCert,
00436     DWORD           dwCertFlags)
00437 {
00438     HTTPSPolicyCallbackData  polHttps;
00439     CERT_CHAIN_POLICY_PARA   PolicyPara;
00440     CERT_CHAIN_POLICY_STATUS PolicyStatus;
00441     CERT_CHAIN_PARA          ChainPara;
00442     PCCERT_CHAIN_CONTEXT     pChainContext = NULL;
00443     LPSTR                    pszUsage;
00444
00445     DWORD   Status;
00446
00447     if(pServerCert == NULL)
00448     {
00449         return SEC_E_WRONG_PRINCIPAL;
00450     }
00451
00452
00453     //
00454     // Build certificate chain.
00455     //
00456
00457     pszUsage = szOID_PKIX_KP_CLIENT_AUTH;
00458
00459     ZeroMemory(&ChainPara, sizeof(ChainPara));
00460     ChainPara.cbSize = sizeof(ChainPara);
00461     ChainPara.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR;
00462     ChainPara.RequestedUsage.Usage.cUsageIdentifier     = 1;
00463     ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = &pszUsage;
00464
00465     if(!CertGetCertificateChain(
00466                             NULL,
00467                             pServerCert,
00468                             NULL,
00469                             pServerCert->hCertStore,
00470                             &ChainPara,
00471                             0,
00472                             NULL,
00473                             &pChainContext))
00474     {
00475         Status = GetLastError();
00476         printf("Error 0x%x returned by CertGetCertificateChain!\n", Status);
00477         goto cleanup;
00478     }
00479
00480
00481     //
00482     // Validate certificate chain.
00483     //
00484
00485     ZeroMemory(&polHttps, sizeof(HTTPSPolicyCallbackData));
00486     polHttps.cbStruct           = sizeof(HTTPSPolicyCallbackData);
00487     polHttps.dwAuthType         = AUTHTYPE_CLIENT;
00488     polHttps.fdwChecks          = dwCertFlags;
00489     polHttps.pwszServerName     = NULL;
00490
00491     memset(&PolicyPara, 0, sizeof(PolicyPara));
00492     PolicyPara.cbSize            = sizeof(PolicyPara);
00493     PolicyPara.pvExtraPolicyPara = &polHttps;
00494
00495     memset(&PolicyStatus, 0, sizeof(PolicyStatus));
00496     PolicyStatus.cbSize = sizeof(PolicyStatus);
00497
00498     if(!CertVerifyCertificateChainPolicy(
00499                             CERT_CHAIN_POLICY_SSL,
00500                             pChainContext,
00501                             &PolicyPara,
00502                             &PolicyStatus))
00503     {
00504         Status = GetLastError();
00505         printf("Error 0x%x returned by CertVerifyCertificateChainPolicy!\n", Status);
00506         goto cleanup;
00507     }
00508
00509     if(PolicyStatus.dwError)
00510     {
00511         Status = PolicyStatus.dwError;
00512         DisplayWinVerifyTrustError(Status);
00513         goto cleanup;
00514     }
00515
00516
00517     Status = SEC_E_OK;
00518
00519 cleanup:
00520
00521     if(pChainContext)
00522     {
00523         CertFreeCertificateChain(pChainContext);
00524     }
00525
00526     return Status;
00527 }
00528
00529 /*****************************************************************************/
00530 static void
00531 WebServer(CredHandle *phServerCreds)
00532 {
00533     SOCKET ListenSocket = INVALID_SOCKET;
00534     SOCKET Socket = INVALID_SOCKET;
00535     SOCKADDR_IN address;
00536     SOCKADDR_IN remoteAddress;
00537     INT remoteSockaddrLength;
00538     DWORD cConnections = 0;
00539     INT err;
00540     INT i;
00541
00542     CHAR objectName[256];
00543     DWORD currentDirectoryLength;
00544     HANDLE objectHandle = INVALID_HANDLE_VALUE;
00545     BY_HANDLE_FILE_INFORMATION fileInfo;
00546     INT bytesSent;
00547     DWORD bytesRead;
00548     DWORD cbContentLength;
00549
00550     CtxtHandle      hContext;
00551     BOOL            fContextInitialized = FALSE;
00552     SecBufferDesc   Message;
00553     SecBuffer       Buffers[4];
00554     SecBufferDesc   MessageOut;
00555     SecBuffer       OutBuffers[4];
00556     SecPkgContext_StreamSizes Sizes;
00557     SECURITY_STATUS scRet;
00558     PCCERT_CONTEXT pRemoteCertContext = NULL;
00559
00560     HANDLE hUserToken = NULL;
00561     BOOL fImpersonating = FALSE;
00562
00563     //
00564     // Initialize security buffer structs
00565     //
00566
00567     Message.ulVersion = SECBUFFER_VERSION;
00568     Message.cBuffers = 4;
00569     Message.pBuffers = Buffers;
00570
00571     Buffers[0].BufferType = SECBUFFER_EMPTY;
00572     Buffers[1].BufferType = SECBUFFER_EMPTY;
00573     Buffers[2].BufferType = SECBUFFER_EMPTY;
00574     Buffers[3].BufferType = SECBUFFER_EMPTY;
00575
00576     MessageOut.ulVersion = SECBUFFER_VERSION;
00577     MessageOut.cBuffers = 4;
00578     MessageOut.pBuffers = OutBuffers;
00579
00580     OutBuffers[0].BufferType = SECBUFFER_EMPTY;
00581     OutBuffers[1].BufferType = SECBUFFER_EMPTY;
00582     OutBuffers[2].BufferType = SECBUFFER_EMPTY;
00583     OutBuffers[3].BufferType = SECBUFFER_EMPTY;
00584
00585
00586
00587     //
00588     // Figure out our current directory so that we can open files
00589     // relative to it.
00590     //
00591
00592     currentDirectoryLength = GetCurrentDirectory( 256, objectName );
00593     if ( currentDirectoryLength == 0 )
00594     {
00595         printf( "GetCurrentDirectory failed: %ld\n", GetLastError( ) );
00596         exit(1);
00597     }
00598
00599
00600     //
00601     // Set up a socket listening on the HTTPS port.
00602     //
00603
00604     ListenSocket = socket( AF_INET, SOCK_STREAM, 0 );
00605     if ( ListenSocket == INVALID_SOCKET )
00606     {
00607         printf( "socket() failed for ListenSocket: %ld\n", GetLastError( ) );
00608         exit(1);
00609     }
00610
00611     RtlZeroMemory( &address, sizeof(address) );
00612     address.sin_family = AF_INET;
00613     address.sin_port = htons( (short)iPortNumber );    // https port
00614     address.sin_addr.s_addr = 0;
00615
00616     err = bind(ListenSocket, (PSOCKADDR) &address, sizeof(address));
00617     if (err == SOCKET_ERROR)
00618     {
00619         printf("bind failed: %ld\n", GetLastError());
00620         exit(1);
00621     }
00622
00623     err = listen(ListenSocket, 1);
00624     if (err == SOCKET_ERROR)
00625     {
00626         printf("listen failed: %ld\n", GetLastError());
00627         exit(1);
00628     }
00629
00630
00631     //
00632     // Loop processing connections.
00633     //
00634
00635     while (TRUE)
00636     {
00637         PSecBuffer pDataBuffer;
00638
00639         fContextInitialized = FALSE;
00640
00641         objectHandle = INVALID_HANDLE_VALUE;
00642
00643         //
00644         // First accept an incoming connection.
00645         //
00646
00647         printf("\nWaiting for connection %d\n", ++cConnections);
00648
00649         remoteSockaddrLength = sizeof(remoteAddress);
00650
00651         Socket = accept(ListenSocket,
00652                         (LPSOCKADDR)&remoteAddress,
00653                         &remoteSockaddrLength);
00654         if(Socket == INVALID_SOCKET)
00655         {
00656             printf( "accept() failed: %ld\n", GetLastError( ) );
00657             goto cleanup;
00658         }
00659
00660         printf("Socket connection established\n");
00661
00662
00663         //
00664         // Perform handshake
00665         //
00666
00667         cbIoBuffer = 0;
00668
00669         if(!SSPINegotiateLoop(Socket,
00670                           &hContext,
00671                           phServerCreds,
00672                           fClientAuth,
00673                           TRUE,
00674                           TRUE))
00675         {
00676             printf("Couldn't connect\n");
00677             goto cleanup;
00678         }
00679
00680         fContextInitialized = TRUE;
00681
00682         if(fClientAuth)
00683         {
00684             //
00685             // We requested client authentication. There are two ways
00686             // to go here.
00687             //
00688
00689             //
00690             // Some server applications will want to validate
00691             // the client certificate themselves, in which case they
00692             // should read the client certificate using QueryContextAttributes
00693             // and validate it, etc.
00694             //
00695
00696             // Read the client certificate.
00697             scRet = g_pSSPI->QueryContextAttributes(&hContext,
00698                                             SECPKG_ATTR_REMOTE_CERT_CONTEXT,
00699                                             (PVOID)&pRemoteCertContext);
00700             if(scRet != SEC_E_OK)
00701             {
00702                 printf("Error 0x%lx querying client certificate\n", scRet);
00703             }
00704             else
00705             {
00706                 // Display client certificate chain.
00707                 DisplayCertChain(pRemoteCertContext);
00708
00709                 // Attempt to validate client certificate.
00710                 scRet = VerifyClientCertificate(pRemoteCertContext, 0);
00711                 if(scRet)
00712                 {
00713                     printf("Error 0x%lx authenticating client credentials\n", scRet);
00714                     goto cleanup;
00715                 }
00716                 else
00717                     printf("\nAuth succeeded, ready for command\n");
00718
00719             }
00720
00721             //
00722             // Many server applications want to validate the client user,
00723             // but they don't want to get involved with validating the client
00724             // certificate themselves. This is really easy to do, since schannel's
00725             // certificate mapper code will automatically map the client
00726             // certificate to a user account whenever possible. If this
00727             // technique is used, then the code above can be removed, since
00728             // if a valid user token is obtained, then the server application
00729             // is guaranteed that the client certificate validated correctly.
00730             // This approach allows the server application to access ACL'ed
00731             // files on the behalf of the client user, which is really cool.
00732             // Note that this only works on Win2K, WinXP, and later versions
00733             // of Windows.
00734             //
00735
00736             fImpersonating = FALSE;
00737
00738             scRet = g_pSSPI->QuerySecurityContextToken(&hContext,
00739                                                        &hUserToken);
00740             if(SUCCEEDED(scRet))
00741             {
00742                 if(ImpersonateLoggedOnUser(hUserToken))
00743                 {
00744                     // We're impersonating the client user. Too cool.
00745                     printf("Impersonating client\n");
00746                     fImpersonating = TRUE;
00747                 }
00748             }
00749         }
00750
00751
00752         //
00753         // Find out how big the header will be:
00754         //
00755
00756         scRet = g_pSSPI->QueryContextAttributes(&hContext, SECPKG_ATTR_STREAM_SIZES, &Sizes);
00757
00758
00759         if(scRet != SEC_E_OK)
00760         {
00761             printf("Couldn't get Sizes\n");
00762             goto cleanup;
00763         }
00764
00765
00766         //
00767         // Receive the HTTP request from the client.  Note the
00768         // assumption that the client will send the request all in one
00769         // chunk.
00770         //
00771
00772         do
00773         {
00774             Buffers[0].pvBuffer = IoBuffer;
00775             Buffers[0].cbBuffer = cbIoBuffer;
00776             Buffers[0].BufferType = SECBUFFER_DATA;
00777
00778             Buffers[1].BufferType = SECBUFFER_EMPTY;
00779             Buffers[2].BufferType = SECBUFFER_EMPTY;
00780             Buffers[3].BufferType = SECBUFFER_EMPTY;
00781
00782             scRet = g_pSSPI->DecryptMessage(&hContext, &Message, 0, NULL);
00783
00784             if(scRet == SEC_E_INCOMPLETE_MESSAGE)
00785             {
00786                 err = recv(Socket, IoBuffer + cbIoBuffer, IO_BUFFER_SIZE - cbIoBuffer, 0);
00787                 if ((err == SOCKET_ERROR) || (err == 0))
00788                 {
00789                     printf("recv failed: %ld\n", GetLastError());
00790                     goto cleanup;
00791                 }
00792
00793                 printf("\nReceived %d (request) bytes from client\n", err);
00794                 if(fVerbose)
00795                 {
00796                     PrintHexDump(err, IoBuffer+cbIoBuffer);
00797                 }
00798                 else
00799                 {
00800                     PrintHexDump(16, IoBuffer+cbIoBuffer);
00801                 }
00802
00803                 cbIoBuffer += err;
00804             }
00805         }
00806         while(scRet == SEC_E_INCOMPLETE_MESSAGE);
00807
00808         if(scRet == SEC_I_CONTEXT_EXPIRED)
00809         {
00810             // Client signalled end of session
00811             goto cleanup;
00812         }
00813
00814         if(scRet != SEC_E_OK)
00815         {
00816             printf("Couldn't decrypt, error %lx\n", scRet);
00817             goto cleanup;
00818         }
00819         cbIoBuffer = 0;
00820
00821         // Locate data buffer.
00822         pDataBuffer  = NULL;
00823         for(i = 1; i < 4; i++)
00824         {
00825             if(Buffers[i].BufferType == SECBUFFER_DATA)
00826             {
00827                 pDataBuffer = &Buffers[i];
00828                 break;
00829             }
00830         }
00831         if(pDataBuffer == NULL)
00832         {
00833             goto cleanup;
00834         }
00835
00836         // Make sure the data in the output buffer is zero-terminated
00837         // and print it out.
00838         ((CHAR *) pDataBuffer->pvBuffer)[pDataBuffer->cbBuffer] = '\0';
00839         printf("\nMessage is: '%s'\n", pDataBuffer->pvBuffer);
00840
00841
00842         // Parse the request in order to determine the requested object.
00843         // Note that we only handle the GET verb in this server.
00844
00845         if(!ParseRequest(
00846                         pDataBuffer->pvBuffer,
00847                         pDataBuffer->cbBuffer,
00848                         objectName+currentDirectoryLength,
00849                         &cbContentLength))
00850         {
00851             printf("Unable to parse message\n");
00852             goto cleanup;
00853         }
00854
00855
00856
00857         objectHandle = CreateFileA(
00858                            objectName,
00859                            GENERIC_READ,
00860                            FILE_SHARE_READ,
00861                            NULL,
00862                            OPEN_EXISTING,
00863                            0,
00864                            NULL);
00865         if (objectHandle == INVALID_HANDLE_VALUE)
00866         {
00867             printf("CreateFile(%s) failed: %ld\n", objectName, GetLastError());
00868             goto cleanup;
00869         }
00870
00871         // Determine the length of the file.
00872
00873         if(!GetFileInformationByHandle(objectHandle, &fileInfo))
00874         {
00875             printf("GetFileInformationByHandle failed: %ld\n", GetLastError());
00876             goto cleanup;
00877         }
00878
00879         //
00880         // Build and the HTTP response header.
00881         //
00882
00883         ZeroMemory(IoBuffer, Sizes.cbHeader);
00884
00885         i = sprintf(
00886             IoBuffer + Sizes.cbHeader,
00887             "HTTP/1.0 200 OK\r\nContent-Length: %d\r\n\r\n",
00888             fileInfo.nFileSizeLow);
00889
00890         //
00891         // Line up the buffers so that the header and content will be
00892         // all set to go.
00893         //
00894
00895         Buffers[0].pvBuffer = IoBuffer;
00896         Buffers[0].cbBuffer = Sizes.cbHeader;
00897         Buffers[0].BufferType = SECBUFFER_STREAM_HEADER;
00898
00899         Buffers[1].pvBuffer = IoBuffer + Sizes.cbHeader;
00900         Buffers[1].cbBuffer = i;
00901         Buffers[1].BufferType = SECBUFFER_DATA;
00902
00903         Buffers[2].pvBuffer = IoBuffer + Sizes.cbHeader + i;
00904         Buffers[2].cbBuffer = Sizes.cbTrailer;
00905         Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER;
00906
00907         Buffers[3].BufferType = SECBUFFER_EMPTY;
00908
00909         scRet = g_pSSPI->EncryptMessage(&hContext, 0, &Message, 0);
00910
00911         if ( FAILED( scRet ) )
00912         {
00913             printf(" EncryptMessage failed with %#x\n", scRet );
00914             goto cleanup;
00915         }
00916
00917
00918         err = send( Socket,
00919                     IoBuffer,
00920                     Buffers[0].cbBuffer + Buffers[1].cbBuffer + Buffers[2].cbBuffer,
00921                     0 );
00922
00923         printf("\nSend %d header bytes to client\n", Buffers[0].cbBuffer + Buffers[1].cbBuffer + Buffers[2].cbBuffer);
00924         if(fVerbose > 1)
00925         {
00926             PrintHexDump(Buffers[0].cbBuffer + Buffers[1].cbBuffer + Buffers[2].cbBuffer, IoBuffer);
00927         }
00928         else
00929         {
00930             PrintHexDump(16, IoBuffer);
00931         }
00932         if ( err == SOCKET_ERROR )
00933         {
00934             printf( "send failed: %ld\n", GetLastError( ) );
00935             goto cleanup;
00936         }
00937
00938         //
00939         // Now read and send the file data.
00940         //
00941
00942         for(bytesSent = 0;
00943             bytesSent < (INT) fileInfo.nFileSizeLow;
00944             bytesSent += err)
00945         {
00946
00947             if(!ReadFile(objectHandle,
00948                           IoBuffer + Sizes.cbHeader,
00949                           IO_BUFFER_SIZE - (Sizes.cbHeader + Sizes.cbTrailer),
00950                           &bytesRead,
00951                           NULL))
00952             {
00953                 printf( "ReadFile failed: %ld\n", GetLastError( ) );
00954                 break;
00955             }
00956
00957             if(bytesRead == 0)
00958             {
00959                 printf( "zero bytes read\n");
00960                 break;
00961             }
00962
00963
00964             Buffers[0].pvBuffer = IoBuffer;
00965             Buffers[0].cbBuffer = Sizes.cbHeader;
00966             Buffers[0].BufferType = SECBUFFER_STREAM_HEADER;
00967
00968             Buffers[1].pvBuffer = IoBuffer + Sizes.cbHeader;
00969             Buffers[1].cbBuffer = bytesRead;
00970             Buffers[1].BufferType = SECBUFFER_DATA;
00971
00972             Buffers[2].pvBuffer = IoBuffer + Sizes.cbHeader + bytesRead;
00973             Buffers[2].cbBuffer = Sizes.cbTrailer;
00974             Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER;
00975
00976             Buffers[3].BufferType = SECBUFFER_EMPTY;
00977
00978             scRet = g_pSSPI->EncryptMessage(&hContext,
00979                                 0,
00980                                 &Message,
00981                                 0);
00982
00983             if ( FAILED( scRet ) )
00984             {
00985                 printf(" EncryptMessage failed with %#x\n", scRet );
00986                 goto cleanup;
00987             }
00988
00989             err = send( Socket,
00990                         IoBuffer,
00991                         Buffers[0].cbBuffer + Buffers[1].cbBuffer + Buffers[2].cbBuffer,
00992                         0 );
00993
00994             printf("\nSend %d data bytes to client\n", Buffers[0].cbBuffer + Buffers[1].cbBuffer + Buffers[2].cbBuffer);
00995             if(fVerbose > 1)
00996             {
00997                 PrintHexDump(Buffers[0].cbBuffer + Buffers[1].cbBuffer + Buffers[2].cbBuffer, IoBuffer);
00998             }
00999             else
01000             {
01001                 PrintHexDump(16, IoBuffer);
01002             }
01003
01004             if ( err == SOCKET_ERROR )
01005             {
01006                 printf( "send failed: %ld\n", GetLastError( ) );
01007                 break;
01008             }
01009         }
01010
01011 cleanup:
01012
01013         if(fImpersonating)
01014         {
01015             RevertToSelf();
01016             fImpersonating = FALSE;
01017         }
01018
01019         if(hUserToken)
01020         {
01021             CloseHandle(hUserToken);
01022             hUserToken = NULL;
01023         }
01024
01025         if(fContextInitialized)
01026         {
01027             scRet = DisconnectFromClient(Socket, phServerCreds, &hContext);
01028
01029             if(scRet == SEC_E_OK)
01030             {
01031                 fContextInitialized = FALSE;
01032                 Socket = INVALID_SOCKET;
01033             }
01034             else
01035             {
01036                 printf("Error disconnecting from server\n");
01037             }
01038         }
01039
01040         if(objectHandle != INVALID_HANDLE_VALUE)
01041         {
01042             CloseHandle(objectHandle);
01043         }
01044
01045         // Free SSPI context handle.
01046         if(fContextInitialized)
01047         {
01048             g_pSSPI->DeleteSecurityContext(&hContext);
01049             fContextInitialized = FALSE;
01050         }
01051
01052         // Close socket.
01053         if(Socket != INVALID_SOCKET)
01054         {
01055             closesocket(Socket);
01056             Socket = INVALID_SOCKET;
01057         }
01058     }
01059
01060 } // WebServer
01061
01062
01063 static
01064 BOOL
01065 SSPINegotiateLoop(
01066     SOCKET          Socket,
01067     PCtxtHandle     phContext,
01068     PCredHandle     phCred,
01069     BOOL            fClientAuth,
01070     BOOL            fDoInitialRead,
01071     BOOL            NewContext)
01072 {
01073     TimeStamp            tsExpiry;
01074     SECURITY_STATUS      scRet;
01075     SecBufferDesc        InBuffer;
01076     SecBufferDesc        OutBuffer;
01077     SecBuffer            InBuffers[2];
01078     SecBuffer            OutBuffers[1];
01079     DWORD                err = 0;
01080
01081     BOOL                 fDoRead;
01082     BOOL                 fInitContext = NewContext;
01083
01084     DWORD                dwSSPIFlags, dwSSPIOutFlags;
01085
01086     fDoRead = fDoInitialRead;
01087
01088     dwSSPIFlags =   ASC_REQ_SEQUENCE_DETECT        |
01089                     ASC_REQ_REPLAY_DETECT      |
01090                     ASC_REQ_CONFIDENTIALITY  |
01091                     ASC_REQ_EXTENDED_ERROR    |
01092                     ASC_REQ_ALLOCATE_MEMORY  |
01093                     ASC_REQ_STREAM;
01094
01095     if(fClientAuth)
01096     {
01097         dwSSPIFlags |= ASC_REQ_MUTUAL_AUTH;
01098     }
01099
01100
01101     //
01102     //  set OutBuffer for InitializeSecurityContext call
01103     //
01104
01105     OutBuffer.cBuffers = 1;
01106     OutBuffer.pBuffers = OutBuffers;
01107     OutBuffer.ulVersion = SECBUFFER_VERSION;
01108
01109
01110     scRet = SEC_I_CONTINUE_NEEDED;
01111
01112     while( scRet == SEC_I_CONTINUE_NEEDED ||
01113             scRet == SEC_E_INCOMPLETE_MESSAGE ||
01114             scRet == SEC_I_INCOMPLETE_CREDENTIALS)
01115     {
01116
01117         if(0 == cbIoBuffer || scRet == SEC_E_INCOMPLETE_MESSAGE)
01118         {
01119             if(fDoRead)
01120             {
01121                 err = recv(Socket, IoBuffer+cbIoBuffer, IO_BUFFER_SIZE, 0);
01122
01123                 if (err == SOCKET_ERROR || err == 0)
01124                 {
01125                     printf(" recv failed: %d\n", GetLastError() );
01126                     return FALSE;
01127                 }
01128                 else
01129                 {
01130                     printf("\nReceived %d (handshake) bytes from client\n", err);
01131                     if(fVerbose)
01132                     {
01133                         PrintHexDump(err, IoBuffer+cbIoBuffer);
01134                     }
01135                     else
01136                     {
01137                         PrintHexDump(min(16, err), IoBuffer+cbIoBuffer);
01138                     }
01139
01140                     cbIoBuffer += err;
01141                 }
01142             }
01143             else
01144             {
01145                 fDoRead = TRUE;
01146             }
01147         }
01148
01149
01150
01151
01152
01153         //
01154         // InBuffers[1] is for getting extra data that
01155         //  SSPI/SCHANNEL doesn't proccess on this
01156         //  run around the loop.
01157         //
01158
01159         InBuffers[0].pvBuffer = IoBuffer;
01160         InBuffers[0].cbBuffer = cbIoBuffer;
01161         InBuffers[0].BufferType = SECBUFFER_TOKEN;
01162
01163         InBuffers[1].pvBuffer   = NULL;
01164         InBuffers[1].cbBuffer   = 0;
01165         InBuffers[1].BufferType = SECBUFFER_EMPTY;
01166
01167         InBuffer.cBuffers        = 2;
01168         InBuffer.pBuffers        = InBuffers;
01169         InBuffer.ulVersion       = SECBUFFER_VERSION;
01170
01171
01172         //
01173         // Initialize these so if we fail, pvBuffer contains NULL,
01174         // so we don't try to free random garbage at the quit
01175         //
01176
01177         OutBuffers[0].pvBuffer   = NULL;
01178         OutBuffers[0].BufferType = SECBUFFER_TOKEN;
01179         OutBuffers[0].cbBuffer   = 0;
01180
01181
01182         scRet = g_pSSPI->AcceptSecurityContext(
01183                         phCred,
01184                         (fInitContext?NULL:phContext),
01185                         &InBuffer,
01186                         dwSSPIFlags,
01187                         SECURITY_NATIVE_DREP,
01188                         (fInitContext?phContext:NULL),
01189                         &OutBuffer,
01190                         &dwSSPIOutFlags,
01191                         &tsExpiry);
01192
01193
01194
01195         fInitContext = FALSE;
01196
01197
01198         if ( scRet == SEC_E_OK ||
01199              scRet == SEC_I_CONTINUE_NEEDED ||
01200              (FAILED(scRet) && (0 != (dwSSPIOutFlags & ISC_RET_EXTENDED_ERROR))))
01201         {
01202             if  (OutBuffers[0].cbBuffer != 0    &&
01203                  OutBuffers[0].pvBuffer != NULL )
01204             {
01205                 //
01206                 // Send response to server if there is one
01207                 //
01208                 err = send( Socket,
01209                             OutBuffers[0].pvBuffer,
01210                             OutBuffers[0].cbBuffer,
01211                             0 );
01212
01213                 printf("\nSend %d handshake bytes to client\n", OutBuffers[0].cbBuffer);
01214                 if(fVerbose)
01215                 {
01216                     PrintHexDump(OutBuffers[0].cbBuffer, OutBuffers[0].pvBuffer);
01217                 }
01218                 else
01219                 {
01220                     PrintHexDump(16, OutBuffers[0].pvBuffer);
01221                 }
01222
01223                 g_pSSPI->FreeContextBuffer( OutBuffers[0].pvBuffer );
01224                 OutBuffers[0].pvBuffer = NULL;
01225             }
01226         }
01227
01228
01229         if ( scRet == SEC_E_OK )
01230         {
01231
01232
01233             if ( InBuffers[1].BufferType == SECBUFFER_EXTRA )
01234             {
01235
01236                     memcpy(IoBuffer,
01237                            (LPBYTE) (IoBuffer + (cbIoBuffer - InBuffers[1].cbBuffer)),
01238                             InBuffers[1].cbBuffer);
01239                     cbIoBuffer = InBuffers[1].cbBuffer;
01240             }
01241             else
01242             {
01243                 cbIoBuffer = 0;
01244             }
01245
01246             if(fClientAuth)
01247             {
01248                 // Display info about cert...
01249
01250
01251             }
01252
01253             return TRUE;
01254         }
01255         else if (FAILED(scRet) && (scRet != SEC_E_INCOMPLETE_MESSAGE))
01256         {
01257
01258             printf("Accept Security Context Failed with error code %lx\n", scRet);
01259             return FALSE;
01260
01261         }
01262
01263
01264
01265         if ( scRet != SEC_E_INCOMPLETE_MESSAGE &&
01266              scRet != SEC_I_INCOMPLETE_CREDENTIALS)
01267         {
01268
01269
01270             if ( InBuffers[1].BufferType == SECBUFFER_EXTRA )
01271             {
01272
01273
01274
01275                 memcpy(IoBuffer,
01276                        (LPBYTE) (IoBuffer + (cbIoBuffer - InBuffers[1].cbBuffer)),
01277                         InBuffers[1].cbBuffer);
01278                 cbIoBuffer = InBuffers[1].cbBuffer;
01279             }
01280             else
01281             {
01282                 //
01283                 // prepare for next receive
01284                 //
01285
01286                 cbIoBuffer = 0;
01287             }
01288         }
01289     }
01290
01291     return FALSE;
01292 }
01293
01294
01295
01296 static
01297 BOOL
01298 ParseRequest (
01299     IN PCHAR InputBuffer,
01300     IN INT InputBufferLength,
01301     OUT PCHAR ObjectName,
01302     OUT DWORD *pcbContentLength)
01303 {
01304     PCHAR s = InputBuffer;
01305     DWORD i;
01306
01307     *pcbContentLength = 0;
01308
01309     while ( (INT)(s - InputBuffer) < InputBufferLength )
01310     {
01311
01312         // Parse off verb
01313
01314         //
01315         // First determine whether this line starts with the GET
01316         // verb.
01317         //
01318
01319         while(*s != '\0' && *s != ' ' && *s != '\t')
01320         {
01321             *s = (CHAR)toupper(*s);
01322             s++;
01323         }
01324
01325         if(*s == '\0' || *s == ' ' || *s == '\0')
01326         {
01327             *s = '\0';
01328 //            printf("Verb is :%s\n", InputBuffer);
01329
01330             //
01331             // It is a GET.  Skip over white space.
01332             //
01333             for ( s++; *s == ' ' || *s == '\t'; s++ );
01334
01335             //
01336             // Now grab the object name.
01337             //
01338
01339             for ( i = 0; *s != 0xA && *s != 0xD && *s != ' ' && *s != '\0'; s++, i++ ) {
01340                 ObjectName[i] = *s;
01341                 if ( ObjectName[i] == '/' ) {
01342                     ObjectName[i] = '\\';
01343                 }
01344             }
01345
01346             ObjectName[i] = '\0';
01347
01348             //
01349             // We're done parsing.
01350             //
01351
01352             if(strcmp(ObjectName, "\\") == 0)
01353             {
01354                 strcpy(ObjectName, "\\default.html");
01355             }
01356             if(strcmp(InputBuffer, "POST") == 0)
01357             {
01358                 char * content_length;
01359                 DWORD cbContent = 0;
01360                 // look for content length;
01361                 content_length = strstr(s, "Content-Length: ");
01362                 if(content_length)
01363                 {
01364                     cbContent = atoi(content_length+16);
01365                     printf("Content Length is %d\n", cbContent);
01366                     *pcbContentLength = cbContent;
01367                 }
01368             }
01369             return TRUE;
01370         }
01371
01372         //
01373         // Skip to the end of the line and continue parsing.
01374         //
01375
01376         while ( *s != 0xA && *s != 0xD )
01377         {
01378             s++;
01379         }
01380
01381         s++;
01382
01383         if ( *s == 0xD || *s == 0xA )
01384         {
01385             s++;
01386         }
01387     }
01388
01389     return FALSE;
01390
01391 } // ParseRequest
01392
01393
01394
01395 /*****************************************************************************/
01396 static
01397 DWORD
01398 CreateCredentials(
01399     LPSTR pszUserName,              // in
01400     PCredHandle phCreds)            // out
01401 {
01402     SCHANNEL_CRED   SchannelCred;
01403     TimeStamp       tsExpiry;
01404     SECURITY_STATUS Status;
01405     PCCERT_CONTEXT  pCertContext = NULL;
01406
01407     if(pszUserName == NULL || strlen(pszUserName) == 0)
01408     {
01409         printf("**** No user name specified!\n");
01410         return SEC_E_NO_CREDENTIALS;
01411     }
01412
01413     // Open the "MY" certificate store.
01414     if(hMyCertStore == NULL)
01415     {
01416         if(fMachineStore)
01417         {
01418             hMyCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
01419                                          X509_ASN_ENCODING,
01420                                          0,
01421                                          CERT_SYSTEM_STORE_LOCAL_MACHINE,
01422                                          L"MY");
01423         }
01424         else
01425         {
01426             hMyCertStore = CertOpenSystemStore(0, "MY");
01427         }
01428
01429         if(!hMyCertStore)
01430         {
01431             printf("**** Error 0x%x returned by CertOpenSystemStore\n",
01432                 GetLastError());
01433             return SEC_E_NO_CREDENTIALS;
01434         }
01435     }
01436
01437     // Find certificate. Note that this sample just searchs for a
01438     // certificate that contains the user name somewhere in the subject name.
01439     // A real application should be a bit less casual.
01440     pCertContext = CertFindCertificateInStore(hMyCertStore,
01441                                               X509_ASN_ENCODING,
01442                                               0,
01443                                               CERT_FIND_SUBJECT_STR_A,
01444                                               pszUserName,
01445                                               NULL);
01446     if(pCertContext == NULL)
01447     {
01448         printf("**** Error 0x%x returned by CertFindCertificateInStore\n",
01449             GetLastError());
01450         return SEC_E_NO_CREDENTIALS;
01451     }
01452
01453
01454     //
01455     // Build Schannel credential structure. Currently, this sample only
01456     // specifies the protocol to be used (and optionally the certificate,
01457     // of course). Real applications may wish to specify other parameters
01458     // as well.
01459     //
01460
01461     ZeroMemory(&SchannelCred, sizeof(SchannelCred));
01462
01463     SchannelCred.dwVersion = SCHANNEL_CRED_VERSION;
01464
01465     SchannelCred.cCreds = 1;
01466     SchannelCred.paCred = &pCertContext;
01467
01468     SchannelCred.grbitEnabledProtocols = dwProtocol;
01469
01470
01471     //
01472     // Create an SSPI credential.
01473     //
01474
01475     Status = g_pSSPI->AcquireCredentialsHandle(
01476                         NULL,                   // Name of principal
01477                         UNISP_NAME_A,           // Name of package
01478                         SECPKG_CRED_INBOUND,    // Flags indicating use
01479                         NULL,                   // Pointer to logon ID
01480                         &SchannelCred,          // Package specific data
01481                         NULL,                   // Pointer to GetKey() func
01482                         NULL,                   // Value to pass to GetKey()
01483                         phCreds,                // (out) Cred Handle
01484                         &tsExpiry);             // (out) Lifetime (optional)
01485     if(Status != SEC_E_OK)
01486     {
01487         printf("**** Error 0x%x returned by AcquireCredentialsHandle\n", Status);
01488         return Status;
01489     }
01490
01491
01492     //
01493     // Free the certificate context. Schannel has already made its own copy.
01494     //
01495
01496     if(pCertContext)
01497     {
01498         CertFreeCertificateContext(pCertContext);
01499     }
01500
01501
01502     return SEC_E_OK;
01503 }
01504
01505 /*****************************************************************************/
01506 static
01507 LONG
01508 DisconnectFromClient(
01509     SOCKET          Socket,
01510     PCredHandle     phCreds,
01511     CtxtHandle *    phContext)
01512 {
01513     DWORD           dwType;
01514     PBYTE           pbMessage;
01515     DWORD           cbMessage;
01516     DWORD           cbData;
01517
01518     SecBufferDesc   OutBuffer;
01519     SecBuffer       OutBuffers[1];
01520     DWORD           dwSSPIFlags;
01521     DWORD           dwSSPIOutFlags;
01522     TimeStamp       tsExpiry;
01523     DWORD           Status;
01524
01525     //
01526     // Notify schannel that we are about to close the connection.
01527     //
01528
01529     dwType = SCHANNEL_SHUTDOWN;
01530
01531     OutBuffers[0].pvBuffer   = &dwType;
01532     OutBuffers[0].BufferType = SECBUFFER_TOKEN;
01533     OutBuffers[0].cbBuffer   = sizeof(dwType);
01534
01535     OutBuffer.cBuffers  = 1;
01536     OutBuffer.pBuffers  = OutBuffers;
01537     OutBuffer.ulVersion = SECBUFFER_VERSION;
01538
01539     Status = g_pSSPI->ApplyControlToken(phContext, &OutBuffer);
01540
01541     if(FAILED(Status))
01542     {
01543         printf("**** Error 0x%x returned by ApplyControlToken\n", Status);
01544         goto cleanup;
01545     }
01546
01547     //
01548     // Build an SSL close notify message.
01549     //
01550
01551     dwSSPIFlags =   ASC_REQ_SEQUENCE_DETECT     |
01552                     ASC_REQ_REPLAY_DETECT       |
01553                     ASC_REQ_CONFIDENTIALITY     |
01554                     ASC_REQ_EXTENDED_ERROR      |
01555                     ASC_REQ_ALLOCATE_MEMORY     |
01556                     ASC_REQ_STREAM;
01557
01558     OutBuffers[0].pvBuffer   = NULL;
01559     OutBuffers[0].BufferType = SECBUFFER_TOKEN;
01560     OutBuffers[0].cbBuffer   = 0;
01561
01562     OutBuffer.cBuffers  = 1;
01563     OutBuffer.pBuffers  = OutBuffers;
01564     OutBuffer.ulVersion = SECBUFFER_VERSION;
01565
01566     Status = g_pSSPI->AcceptSecurityContext(
01567                     phCreds,
01568                     phContext,
01569                     NULL,
01570                     dwSSPIFlags,
01571                     SECURITY_NATIVE_DREP,
01572                     NULL,
01573                     &OutBuffer,
01574                     &dwSSPIOutFlags,
01575                     &tsExpiry);
01576
01577     if(FAILED(Status))
01578     {
01579         printf("**** Error 0x%x returned by AcceptSecurityContext\n", Status);
01580         goto cleanup;
01581     }
01582
01583     pbMessage = OutBuffers[0].pvBuffer;
01584     cbMessage = OutBuffers[0].cbBuffer;
01585
01586
01587     //
01588     // Send the close notify message to the client.
01589     //
01590
01591     if(pbMessage != NULL && cbMessage != 0)
01592     {
01593         cbData = send(Socket, pbMessage, cbMessage, 0);
01594         if(cbData == SOCKET_ERROR || cbData == 0)
01595         {
01596             Status = WSAGetLastError();
01597             printf("**** Error %d sending close notify\n", Status);
01598             goto cleanup;
01599         }
01600
01601         printf("\n%d bytes of handshake data sent\n", cbData);
01602
01603         if(fVerbose)
01604         {
01605             PrintHexDump(cbData, pbMessage);
01606         }
01607         else
01608         {
01609             PrintHexDump(min(16, cbData), pbMessage);
01610         }
01611
01612         // Free output buffer.
01613         g_pSSPI->FreeContextBuffer(pbMessage);
01614     }
01615
01616
01617 cleanup:
01618
01619     // Free the security context.
01620     g_pSSPI->DeleteSecurityContext(phContext);
01621
01622     // Close the socket.
01623     closesocket(Socket);
01624
01625     return Status;
01626 }
01627
01628 /*****************************************************************************/
01629 static void
01630 PrintHexDump(DWORD length, PBYTE buffer)
01631 {
01632     DWORD i,count,index;
01633     CHAR rgbDigits[]="0123456789abcdef";
01634     CHAR rgbLine[100];
01635     char cbLine;
01636
01637     for(index = 0; length; length -= count, buffer += count, index += count)
01638     {
01639         count = (length > 16) ? 16:length;
01640
01641         sprintf(rgbLine, "%4.4x  ",index);
01642         cbLine = 6;
01643
01644         for(i=0;i<count;i++)
01645         {
01646             rgbLine[cbLine++] = rgbDigits[buffer[i] >> 4];
01647             rgbLine[cbLine++] = rgbDigits[buffer[i] & 0x0f];
01648             if(i == 7)
01649             {
01650                 rgbLine[cbLine++] = ':';
01651             }
01652             else
01653             {
01654                 rgbLine[cbLine++] = ' ';
01655             }
01656         }
01657         for(; i < 16; i++)
01658         {
01659             rgbLine[cbLine++] = ' ';
01660             rgbLine[cbLine++] = ' ';
01661             rgbLine[cbLine++] = ' ';
01662         }
01663
01664         rgbLine[cbLine++] = ' ';
01665
01666         for(i = 0; i < count; i++)
01667         {
01668             if(buffer[i] < 32 || buffer[i] > 126 || buffer[i] == '%')
01669             {
01670                 rgbLine[cbLine++] = '.';
01671             }
01672             else
01673             {
01674                 rgbLine[cbLine++] = buffer[i];
01675             }
01676         }
01677
01678         rgbLine[cbLine++] = 0;
01679         printf("%s\n", rgbLine);
01680     }
01681 }
01682
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CListHeader Member List

This is the complete list of members for CListHeader, including all inherited members.
CLinkable() | CLinkable | [inline]
CListHeader() | CListHeader | [inline]
First() | CListHeader | [inline]
InsertAfter(CLinkable *other) | CLinkable |
InsertBefore(CLinkable *other) | CLinkable |
InsertFirst(CLinkable *other) | CListHeader | [inline]
InsertLast(CLinkable *other) | CListHeader | [inline]
IsEmpty() | CListHeader | [inline]
IsLinked() | CLinkable | [inline]
Last() | CListHeader | [inline]
Next() | CLinkable | [inline]
Previous() | CLinkable | [inline]
Remove() | CLinkable |
~CLinkable() | CLinkable | [inline]
~CListHeader() | CListHeader | [inline]
Generated on Wed Nov 13 2024 16:56:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/Status.c Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

Status.c

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      STATUS.C                                                      */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #include <windows.h>
00010 #include <commctrl.h>
00011 #include <imm.h>
00012 #include "resource.h"
00013 #include "imeapps.h"
00014
00015 const char szImeNull[]     = "";
00016 const char szImeOpen[]     = "On";
00017 const char szImeClose[]    = "Off";
00018 const char szImeAlpha[]    = "Alpha";
00019 const char szImeNative[]   = "Native";
00020 const char szImeKatakana[] = "Kata";
00021 const char szImeHalf[]     = "Half";
00022 const char szImeFull[]     = "Full";
00023 const char szImeRoman[]    = "Roman";
00024 const char szImeCode[]     = "Code";
00025 const char szImeHanja[]    = "Hanja";
00026 const char szImeSoftKbd[]  = "SoftKbd";
00027 const char szImeNoConv[]   = "NoConv";
00028 const char szImeEUDC[]     = "EUDC";
00029 const char szImeSymbol[]   = "Symbol";
00030
00031 #define SBITEM_OPENSTATUS    0
00032 #define SBITEM_NATIVEMODE    1
00033 #define SBITEM_FULLSHAPE     2
00034 #define SBITEM_ROMAN         3
00035 #define SBITEM_CHARCODE      4
00036 #define SBITEM_HANJA         5
00037 #define SBITEM_SOFTKBD       6
00038 #define SBITEM_NOCONVERSION  7
00039 #define SBITEM_EUDC          8
00040 #define SBITEM_SYMBOL        9
00041
00042 #define SBITEM_CMODEFIRST    1
00043 #define SBITEM_CMODELAST     9
00044
00045 #define NUM_PARTS 10
00046 int nPartsWidthTbl[NUM_PARTS] = {30,50,30,30,30,30,30,30,30,30};
00047
00048 BOOL CreateStatus(HWND hWnd)
00049 {
00050     int *pPartsWidth;
00051     int i;
00052     int nWidth = 0;
00053
00054     hWndStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE, NULL ,
00055                                     hWnd,  STATUS_ID);
00056
00057
00058     if (!hWndStatus)
00059     {
00060         return FALSE;
00061     }
00062
00063     pPartsWidth = (int *)LocalAlloc(LPTR,sizeof(int) * NUM_PARTS);
00064
00065     for (i = 0; i < NUM_PARTS; i++)
00066     {
00067         nWidth += nPartsWidthTbl[i];
00068         pPartsWidth[i] = nWidth;
00069     }
00070
00071     SendMessage(hWndStatus, SB_SETPARTS,
00072                 (WPARAM)NUM_PARTS,(LPARAM)pPartsWidth);
00073
00074     LocalFree((HANDLE)pPartsWidth);
00075
00076     return TRUE;
00077 }
00078
00079 void SetStatusItems(HWND hWnd)
00080 {
00081     HIMC hIMC = NULL;
00082     BOOL fOpen;
00083     DWORD dwConvMode,dwSentMode;
00084
00085     hIMC = ImmGetContext(hWnd);
00086
00087     fOpen = ImmGetOpenStatus(hIMC);
00088     SetOpenStatusParts(fOpen);
00089     ImmGetConversionStatus(hIMC,&dwConvMode,&dwSentMode);
00090
00091     if (fOpen)
00092     {
00093         SetConvModeParts(dwConvMode);
00094     }
00095     else
00096     {
00097         ClearConvModeParts();
00098     }
00099
00100     ImmReleaseContext(hWnd,hIMC);
00101 }
00102
00103
00104 void SetOpenStatusParts(BOOL fOpen)
00105 {
00106     if (fOpen)
00107     {
00108         SendMessage(hWndStatus,SB_SETTEXT,
00109                     SBITEM_OPENSTATUS,(LPARAM)&szImeOpen);
00110     }
00111     else
00112     {
00113         SendMessage(hWndStatus,SB_SETTEXT,
00114                     SBITEM_OPENSTATUS,(LPARAM)&szImeClose);
00115     }
00116 }
00117
00118 void SetConvModeParts(DWORD dwConvMode)
00119 {
00120     switch (dwConvMode & IME_CMODE_LANGUAGE)
00121     {
00122         case IME_CMODE_ALPHANUMERIC:
00123             SendMessage(hWndStatus,SB_SETTEXT,
00124                         SBITEM_NATIVEMODE,(LPARAM)&szImeAlpha);
00125             break;
00126
00127         case IME_CMODE_NATIVE:
00128             SendMessage(hWndStatus,SB_SETTEXT,
00129                         SBITEM_NATIVEMODE,(LPARAM)&szImeNative);
00130
00131             break;
00132
00133         case (IME_CMODE_NATIVE | IME_CMODE_KATAKANA):
00134             SendMessage(hWndStatus,SB_SETTEXT,
00135                         SBITEM_NATIVEMODE,(LPARAM)&szImeKatakana);
00136
00137             break;
00138
00139         default:
00140             SendMessage(hWndStatus,SB_SETTEXT,
00141                         SBITEM_NATIVEMODE,(LPARAM)&szImeNull);
00142             break;
00143     }
00144
00145
00146     if (dwConvMode & IME_CMODE_ROMAN)
00147     {
00148         SendMessage(hWndStatus,SB_SETTEXT,
00149                     SBITEM_ROMAN,(LPARAM)&szImeRoman);
00150     }
00151     else
00152     {
00153         SendMessage(hWndStatus,SB_SETTEXT,
00154                     SBITEM_ROMAN,(LPARAM)&szImeNull);
00155     }
00156
00157
00158     if (dwConvMode & IME_CMODE_CHARCODE)
00159     {
00160         SendMessage(hWndStatus,SB_SETTEXT,
00161                     SBITEM_CHARCODE,(LPARAM)&szImeCode);
00162     }
00163     else
00164     {
00165         SendMessage(hWndStatus,SB_SETTEXT,
00166                     SBITEM_CHARCODE,(LPARAM)&szImeNull);
00167     }
00168
00169
00170     if (dwConvMode & IME_CMODE_FULLSHAPE)
00171     {
00172         SendMessage(hWndStatus,SB_SETTEXT,
00173                     SBITEM_FULLSHAPE,(LPARAM)&szImeFull);
00174     }
00175     else
00176     {
00177         SendMessage(hWndStatus,SB_SETTEXT,
00178                     SBITEM_FULLSHAPE,(LPARAM)&szImeHalf);
00179     }
00180
00181
00182     if (dwConvMode & IME_CMODE_HANJACONVERT)
00183     {
00184         SendMessage(hWndStatus,SB_SETTEXT,
00185                     SBITEM_HANJA,(LPARAM)&szImeHanja);
00186     }
00187     else
00188     {
00189         SendMessage(hWndStatus,SB_SETTEXT,
00190                     SBITEM_HANJA,(LPARAM)&szImeNull);
00191     }
00192
00193
00194     if (dwConvMode & IME_CMODE_SOFTKBD)
00195     {
00196         SendMessage(hWndStatus,SB_SETTEXT,
00197                     SBITEM_SOFTKBD,(LPARAM)&szImeSoftKbd);
00198     }
00199     else
00200     {
00201         SendMessage(hWndStatus,SB_SETTEXT,
00202                     SBITEM_SOFTKBD,(LPARAM)&szImeNull);
00203     }
00204
00205
00206     if (dwConvMode & IME_CMODE_NOCONVERSION)
00207     {
00208         SendMessage(hWndStatus,SB_SETTEXT,
00209                     SBITEM_NOCONVERSION,(LPARAM)&szImeNoConv);
00210     }
00211     else
00212     {
00213         SendMessage(hWndStatus,SB_SETTEXT,
00214                     SBITEM_NOCONVERSION,(LPARAM)&szImeNull);
00215     }
00216
00217
00218     if (dwConvMode & IME_CMODE_EUDC)
00219     {
00220         SendMessage(hWndStatus,SB_SETTEXT,SBITEM_EUDC,(LPARAM)&szImeEUDC);
00221     }
00222     else
00223     {
00224         SendMessage(hWndStatus,SB_SETTEXT,SBITEM_EUDC,(LPARAM)&szImeNull);
00225     }
00226
00227
00228     if (dwConvMode & IME_CMODE_SYMBOL)
00229     {
00230         SendMessage(hWndStatus,SB_SETTEXT,SBITEM_SYMBOL,(LPARAM)&szImeSymbol);
00231     }
00232     else
00233     {
00234         SendMessage(hWndStatus,SB_SETTEXT,SBITEM_SYMBOL,(LPARAM)&szImeNull);
00235     }
00236 }
00237
00238
00239 void ClearConvModeParts()
00240 {
00241     int i;
00242
00243     for (i = SBITEM_CMODEFIRST; i <= SBITEM_CMODELAST; i++)
00244     {
00245         SendMessage(hWndStatus,SB_SETTEXT, i,(LPARAM)&szImeNull);
00246     }
00247 }
00248
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpproppage/SCPUI.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpproppage

SCPUI.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCPUI.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef _SCPUI_H
00012 #define _SCPUI_H
00013
00014 #include "resource.h"
00015 #include "util.h"
00016
00017 //
00018 // General Page Definition
00019 //
00020 class CSCPUIGeneral : public CPropertyPage
00021 {
00022   DECLARE_DYNCREATE(CSCPUIGeneral)
00023 public:
00024   CSCPUIGeneral() {}
00025   CSCPUIGeneral(HWND hNotifyObj)
00026     : CPropertyPage(IDD_SCP_GENERAL_PAGE),
00027       m_hNotifyObj(hNotifyObj)
00028   {
00029     m_bDirty = FALSE;
00030     m_szServiceDNSName    = _T("");
00031     m_szServiceDNSNameType= _T("");
00032     m_szBindingInfo       = _T("");
00033     m_szDescription       = _T("");
00034     m_szServiceClassName  = _T("");
00035   }
00036
00037   ~CSCPUIGeneral()
00038   {
00039   }
00040
00041   virtual BOOL OnInitDialog();
00042   virtual BOOL OnApply();
00043   virtual void OnDestroy();
00044
00045   afx_msg void OnPropertyChange();
00046
00047   virtual HRESULT Init(PWSTR pszPath, PWSTR pszClass);
00048
00049   virtual void SetUIData();
00050   virtual void GetUIData();
00051
00052   DECLARE_MESSAGE_MAP()
00053
00054 private:
00055   //
00056   // Member Data
00057   //
00058   HWND                      m_hNotifyObj;
00059   CString                   m_szPath;
00060   CString                   m_szClass;
00061   CComPtr<IDirectoryObject> m_spDsObj;
00062   PADS_ATTR_INFO            m_pWritableAttrs;
00063
00064   BOOL                      m_bDirty;
00065   CString                   m_szServiceDNSName;
00066   CString                   m_szServiceDNSNameType;
00067   CString                   m_szBindingInfo;
00068   CString                   m_szDescription;
00069   CString                   m_szServiceClassName;
00070 };
00071
00072 //
00073 // Keywords Page Definition
00074 //
00075 class CSCPUIBindingInfo : public CPropertyPage
00076 {
00077   DECLARE_DYNCREATE(CSCPUIBindingInfo)
00078 public:
00079   CSCPUIBindingInfo() {}
00080   CSCPUIBindingInfo(HWND hNotifyObj)
00081     : CPropertyPage(IDD_SCP_BINDING_INFO_PAGE),
00082       m_hNotifyObj(hNotifyObj)
00083   {
00084     m_bDirty = FALSE;
00085     m_pAttributeEditor = NULL;
00086   }
00087
00088   ~CSCPUIBindingInfo()
00089   {
00090     if (m_pAttributeEditor != NULL)
00091       delete m_pAttributeEditor;
00092   }
00093
00094   virtual BOOL OnInitDialog();
00095   virtual BOOL OnApply();
00096   virtual void OnDestroy();
00097
00098   afx_msg void OnPropertyChange();
00099
00100   virtual HRESULT Init(PWSTR pszPath, PWSTR pszClass);
00101
00102   virtual void SetUIData();
00103
00104   DECLARE_MESSAGE_MAP()
00105
00106 private:
00107   //
00108   // Member Data
00109   //
00110   HWND                      m_hNotifyObj;
00111   CString                   m_szPath;
00112   CString                   m_szClass;
00113   CComPtr<IDirectoryObject> m_spDsObj;
00114   PADS_ATTR_INFO            m_pWritableAttrs;
00115
00116   BOOL                      m_bDirty;
00117
00118   CStringList               m_szValueList;
00119   CMultiValuedAttributeEditor*  m_pAttributeEditor;
00120 };
00121
00122 //
00123 // Keywords Page Definition
00124 //
00125 class CSCPUIKeywords : public CPropertyPage
00126 {
00127   DECLARE_DYNCREATE(CSCPUIKeywords)
00128 public:
00129   CSCPUIKeywords() {}
00130   CSCPUIKeywords(HWND hNotifyObj)
00131     : CPropertyPage(IDD_SCP_KEYWORDS_PAGE),
00132       m_hNotifyObj(hNotifyObj)
00133   {
00134     m_bDirty = FALSE;
00135     m_pAttributeEditor = NULL;
00136   }
00137
00138   ~CSCPUIKeywords()
00139   {
00140     if (m_pAttributeEditor != NULL)
00141       delete m_pAttributeEditor;
00142   }
00143
00144   virtual BOOL OnInitDialog();
00145   virtual BOOL OnApply();
00146   virtual void OnDestroy();
00147
00148   afx_msg void OnPropertyChange();
00149
00150   virtual HRESULT Init(PWSTR pszPath, PWSTR pszClass);
00151
00152   virtual void SetUIData();
00153
00154   DECLARE_MESSAGE_MAP()
00155
00156 private:
00157   //
00158   // Member Data
00159   //
00160   HWND                      m_hNotifyObj;
00161   CString                   m_szPath;
00162   CString                   m_szClass;
00163   CComPtr<IDirectoryObject> m_spDsObj;
00164   PADS_ATTR_INFO            m_pWritableAttrs;
00165
00166   BOOL                      m_bDirty;
00167
00168   CStringList               m_szValueList;
00169   CMultiValuedAttributeEditor*  m_pAttributeEditor;
00170 };
00171
00172 #endif // _SCPUI_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/land.h Source File

  • SysMgmt
  • MMC
  • Extens

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035 private:
00036     enum { IDM_NEW_LAND = 2 };
00037
00038     // {2974380E-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/dllmain.cpp Source File

  • WinUI
  • TSFmark

dllmain.cpp

Go to the documentation of this file.
00001 //
00002 // dllmain.cpp
00003 //
00004 // DllMain module entry point.
00005 //
00006
00007 #include "globals.h"
00008
00009 //+---------------------------------------------------------------------------
00010 //
00011 // DllMain
00012 //
00013 //----------------------------------------------------------------------------
00014
00015 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved)
00016 {
00017     switch (dwReason)
00018     {
00019         case DLL_PROCESS_ATTACH:
00020
00021             g_hInst = hInstance;
00022
00023             if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0))
00024                 return FALSE;
00025
00026             break;
00027
00028         case DLL_PROCESS_DETACH:
00029
00030             DeleteCriticalSection(&g_cs);
00031
00032             break;
00033     }
00034
00035     return TRUE;
00036 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRow Member List

This is the complete list of members for CRow, including all inherited members.
Abort(HCHAPTER hChapter, DBASYNCHOP eOperation) | CAsynchBase | [virtual]
AddEOL() | CRow |
AddRefAccessor(HACCESSOR hAccessor) | CDataAccess | [virtual]
AdjustStartLocationForEOL() | CRow | [inline]
AdviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
AllocProxyBuffer(ATLCOLUMNINFO *prgColInfo, int cNumCols) | CRow |
AutoQI(DWORD dwCreateOpts) | CRow | [virtual]
AutoRelease() | CRow | [virtual]
Bind(CAggregate *pCAggregate, WCHAR *pwszURL, DBBINDURLFLAG dwBindFlags, REFGUID rguidObjectType, REFIID riid, IUnknown **ppIUnknown) | CRow | [virtual]
CalculateRowData(ATLCOLUMNINFO *prgColInfo, ULONG cNumCols, bool bAddEOL=false) | CRow |
CalculateRowDataToDelete(ATLCOLUMNINFO *prgColInfo, ULONG cNumCols, bool bAddEOL=false) | CRow |
CAsynchBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CAsynchBase |
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CBaseObj(EBaseObjectType botVal) | CBaseObj | [protected]
CContainerBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CContainerBase |
CDataAccess(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CDataAccess |
CImpIColumnsInfo class | CRow | [friend]
CImpIConvertType class | CRow | [friend]
CImpIGetSession class | CRow | [friend]
CImpIRow class | CRow | [friend]
CImpIRowChange class | CRow | [friend]
CreateAccessor(DBACCESSORFLAGS dwAccessorFlags, DBCOUNTITEM cBindings, const DBBINDING *rgBindings, DBLENGTH cRowSize, HACCESSOR *phAccessor) | CDataAccess | [virtual]
CreateAccessors(BINDCOLS eBindCols) | CDataAccess | [virtual]
CreateCommand(CAggregate *pCAggregate, REFIID riid, IUnknown **ppIUnknown) | CRow | [virtual]
CreateDefaultRow(ATLCOLUMNINFO *prgColInfo, ULONG cNumCols, bool bAddEOL=false) | CRow |
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
CRow() | CRow | [inline]
CRow(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRow |
CRow(LPUNKNOWN) | CRow |
CStream class | CRow | [friend]
DisplayObject() | CRow | [virtual]
FetchColumnString(char *pszColData, char *&pPos) | CRow |
FindConnectionPoint(REFIID riid, IConnectionPoint **ppIConnectionPoint) | CContainerBase | [virtual]
FInit(CRowset *) | CRow |
FInit(CDBSession *, CFileIO *, DBCOUNTITEM) | CRow |
GetBaseObjectType() | CBaseObj | [inline]
GetBaseType() | CBase | [inline]
GetColInfo() | CDataAccess | [virtual]
GetColInfo(DBORDINAL *pcColumns, DBCOLUMNINFO **prgColumnInfo, WCHAR **ppStringBuffer, DBORDINAL *pcHiddenColumns) | CDataAccess | [virtual]
GetColumnData(const DBBINDING *pBinding, void *pData, DBSTATUS *pdbStatus, DBLENGTH *pdbLength, DBTYPE *pwSubType, WCHAR *pwszValue, ULONG ulMaxSize, DWORD dwFlags, DBTYPE wBackendType) | CDataAccess | [virtual]
GetColumnImage(const DBCOLUMNINFO *pColInfo, DBSTATUS dbStatus=DBSTATUS_S_OK) | CDataAccess | [virtual]
GetColumnOrdinal(CFileIO *, DBID *, DBORDINAL *) | CRow |
GetColumns(ULONG cColAccess, DBCOLUMNACCESS *rgColAccess) | CRow | [virtual]
GetColumnsRowset(CAggregate *pCAggregate, bool fOptColumns, REFIID riid, ULONG cPropSets, DBPROPSET *rgPropSets, IUnknown **ppIUnknown) | CDataAccess | [virtual]
GetDefaultInterface() | CRow | [inline, virtual]
GetExtraColCount() | CRow | [inline]
GetExtraColumnInfo() | CRow | [inline]
GetFileObj() | CRow |
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CRow | [virtual]
GetObjectDesc() | CRow | [virtual]
GetObjectImage() | CRow | [inline, virtual]
GetObjectMenu() | CRow | [inline, virtual]
GetObjectName() | CRow | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetOuterUnknown() | CBaseObj | [inline]
GetParent(SOURCE eSource) | CBase | [virtual]
GetProxyData(ATLCOLUMNINFO *pColInfo, ULONG cCols) | CRow |
GetRowBuff() | CRow |
GetStatus(HCHAPTER hChapter, DBASYNCHOP eOperation, DBCOUNTITEM *pulProgress, DBCOUNTITEM *pulProgressMax, DBASYNCHPHASE *peAsynchPhase, LPOLESTR *ppwszStatusText) | CAsynchBase | [virtual]
HasEOL(BYTE *pbEOF) | CRow |
Initialize() | CAsynchBase | [virtual]
IsInitialized() | CAsynchBase | [inline, virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
m_Bindings | CDataAccess |
m_bmk | CRow |
m_bRetrieved | CRow |
m_bSchemaRowset | CDataAccess |
m_cbRowSize | CRow |
m_cbRowSize | CRow | [protected]
m_cColAccess | CRow |
m_cExtraCols | CRow | [protected]
m_ColumnInfo | CDataAccess |
m_cRef | CRow | [protected]
m_dwCLSCTX | CBase |
m_dwCookieAsynchNotify | CAsynchBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_fInitialized | CAsynchBase |
m_guidSource | CBase |
m_hAccessor | CDataAccess |
m_hBmkAccessor | CDataAccess |
m_hRow | CRow | [protected]
m_hSourceRow | CRow |
m_hTreeItem | CBase |
m_pbProxyData | CRow |
m_pbStartLoc | CRow |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pData | CDataAccess |
m_pFileio | CRow | [protected]
m_pIAccessor | CDataAccess |
m_pIAggregate | CBase |
m_pIBindResource | CRow |
m_pIColumnsInfo | CRow | [protected]
m_pIColumnsInfo2 | CRow |
m_pIColumnsRowset | CDataAccess |
m_pIConnectionPointContainer | CContainerBase |
m_pIConvertType | CRow | [protected]
m_pICreateRow | CRow |
m_pIDBAsynchStatus | CAsynchBase |
m_pIDBCreateCommand | CRow |
m_pIDBInitialize | CAsynchBase |
m_pIGetSession | CRow |
m_pIGetSession | CRow | [protected]
m_pIRow | CRow |
m_pIRow | CRow | [protected]
m_pIRowChange | CRow |
m_pIRowChange | CRow | [protected]
m_pIRowSchemaChange | CRow |
m_pIScopedOperations | CRow |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_pParentObj | CRow | [protected]
m_pRowBuff | CRow | [protected]
m_pUnkOuter | CBaseObj | [protected]
m_rgColAccess | CRow |
m_rgExtracolinfo | CRow | [protected]
m_strObjectDesc | CBase | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
Open(CAggregate *pCAggregate, DBID *pColumnID, REFGUID rguidObjectType, REFIID riid, IUnknown **ppIUnknown) | CRow | [virtual]
OpenRowset(CAggregate *pCAggregate, DBID *pTableID, DBID *pIndexID, REFIID riid, ULONG cPropSets, DBPROPSET *rgPropSets, IUnknown **ppIUnknown) | CRow | [virtual]
QueryInterface(REFIID, LPVOID *) | CRow |
CDataAccess::QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseAccessor(HACCESSOR *phAccessor, BOOL fReleaseAlways=FALSE) | CDataAccess | [virtual]
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetColumnData(const DBBINDING *pBinding, void *pData, DBSTATUS dbStatus, DBLENGTH dbLength, WCHAR *pwszValue, DWORD dwFlags, DBTYPE wBackendType) | CDataAccess | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
SetRowHandle(HROW) | CRow |
SetupBindings(BINDCOLS eBindCols, DBCOUNTITEM *cBindings, DBBINDING **prgBindings, DBLENGTH *pcRowSize=NULL) | CDataAccess | [virtual]
SetupColAccess(BINDCOLS eBindCols=BIND_ALLCOLS) | CRow | [virtual]
STDMETHODIMP_(DBREFCOUNT) AddRef(void) | CRow |
STDMETHODIMP_(DBREFCOUNT) Release(void) | CRow |
CDataAccess::STDMETHODIMP_(ULONG) AddRef() | CBase |
StoreInProxy(unsigned int iCol, char *szColumnString, ATLCOLUMNINFO *pColInfo) | CRow |
UnadviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
Uninitialize() | CAsynchBase | [virtual]
Update(ATLCOLUMNINFO *prgColInfo, ULONG cCols) | CRow |
ValidateAccessor(HACCESSOR hAccessor, ULONG ulRefCount=1) | CDataAccess | [virtual]
~CAsynchBase() | CAsynchBase | [virtual]
~CBase() | CBase | [virtual]
~CBaseObj() | CBaseObj | [virtual]
~CContainerBase() | CContainerBase | [virtual]
~CDataAccess() | CDataAccess | [virtual]
~CRow() | CRow | [virtual]
~CRow(void) | CRow | [virtual]
Generated on Wed Nov 13 2024 16:57:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/Inc/AppUtil.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • Inc

AppUtil.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      APPUTIL.H
00003
00004   Summary:   Include file for the general application utility classes
00005              and functions offered by the APPUTIL library.  APPUTIL is
00006              meant to be statically linked to applications that want
00007              to exploit it.
00008
00009              For a comprehensive tutorial code tour of APPUTIL's
00010              contents and offerings see the tutorial APPUTIL.HTM file.
00011              For more specific details on the internal workings see the
00012              comments dispersed throughout the APPUTIL source code.
00013
00014   Classes:   CVirWindow, CVirDialog, CAboutBox, CDelayBox, CMsgBox, CMsgLog,
00015              CSendLog, CThreaded.
00016
00017   Functions: WindowProc, DialogProc, SkipAnsi, FileExist, MakeFamilyPath,
00018              GetExeName, CmdExec, HrMsg, HrMsgId, ReadHelp, ReadTutorial,
00019              GoWeb, ReadSource, OutputDebugFmt, DComOk, lRandom, AnsiToUc,
00020              UcToAnsi, A_StringFromGUID2, A_WriteFmtUserTypeStg,
00021              A_StgIsStorageFile, A_StgCreateDocfile, A_StgOpenStorage,
00022              DelayBox, ErrorBox, CreateColorScalePalette, PaintWindow,
00023              GetErrorMsg.
00024
00025   Origin:    8-28-97: atrent - Revised (based on WINHLPRS by stevebl).
00026
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2002 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042 // Don't allow recursive includes of this file.
00043 #ifndef APPUTIL_H
00044 #define APPUTIL_H
00045
00046
00047 /*--------------------------------------------------------------------------
00048   The following pragma disables the C4355 warning which reads:
00049
00050   "'this': used in base member initializer list."
00051
00052   This warning is triggered by the nested interface implementation
00053   classes--a coding technique used throughout the sample series. The
00054   warning says: "The 'this' pointer is only valid within nonstatic member
00055   functions, but was used in the initializer list for a base class. This
00056   is a level 1 warning when Microsoft extensions are enabled (/Ze) but a
00057   level 4 warning otherwise."  The initializer technique is necessary for
00058   the coding of nested class interface implementations. See COMOBJ.HTM for
00059   details on the technique.
00060 --------------------------------------------------------------------------*/
00061 #pragma warning( disable : 4355 )
00062
00063
00064 // Needed #include for assertion checking
00065 #include <assert.h>
00066
00067
00068 // Convenient typedefs.
00069 #ifndef PPVOID
00070 typedef LPVOID* PPVOID;
00071 #endif
00072
00073
00074 // Convenient macros.
00075
00076 #define DELETE_POINTER(p)\
00077 {\
00078   if (NULL != p)\
00079   {\
00080     delete p;\
00081     p = NULL;\
00082   }\
00083 }
00084
00085 #define RELEASE_INTERFACE(p)\
00086 {\
00087   IUnknown* pTmp = (IUnknown*)p;\
00088   p = NULL;\
00089   if (NULL != pTmp)\
00090     pTmp->Release();\
00091 }
00092
00093 // An enumeration of persistent storage states for use in the
00094 // implementation of IPersistStorage.
00095 typedef enum
00096 {
00097   PERS_UNINIT = 0,  // Uninitialized.
00098   PERS_SCRIBBLE,    // Write     permitted; Read     permitted.
00099   PERS_NOSCRIBBLE,  // Write NOT permitted; Read     permitted.
00100   PERS_HANDSOFF     // Write NOT permitted; Read NOT permitted.
00101 } PERSTGSTATE;
00102
00103 // PCRTTHREADPROC is a type for pointer variables that hold addresses of
00104 // C-RunTime thread procedures.
00105 typedef unsigned (WINAPI *PCRTTHREADPROC)(LPVOID pThreadProc);
00106
00107 #define GETINSTANCE(hWnd)   (HANDLE)GetWindowLong(hWnd,GWL_HINSTANCE)
00108 #define GETCLASSBRUSH(hWnd) (HBRUSH)GetClassLong(hWnd,GCL_HBRBACKGROUND)
00109
00110
00111 // Some General defines for Message Boxes and Dialogs
00112 #define GUID_SIZE 128
00113 #define MAX_STRING_LENGTH 256
00114 #define MAX_LINE_NUM 99999
00115 #define MAX_LINE_CHARS 5
00116 #define DEBUG_FMT_CHARS 8
00117 #define MAXLOGST MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS
00118 #define MAX_LOG_LINES 500
00119 #define DELAYBOX_DURATION 3000
00120
00121 #define COLOR_SCALE_RED     1
00122 #define COLOR_SCALE_GREEN   2
00123 #define COLOR_SCALE_BLUE    3
00124 #define COLOR_SCALE_GRAY    4
00125
00126 #define EDITOR_EXE_STR "notepad.exe "
00127 #define TUTORIAL_EXE_STR "tutorial.exe "
00128 #define OFN_SOURCEFILES_STR "Source Files (*.CPP;*.H;*.RC;*.C;*.MAK;*.TXT;*.)\0*.CPP;*.H;*.RC;*.C;*.MAK;*.TXT;makefile\0"
00129 #define OFN_SOURCETITLE_STR "Open Source File"
00130 #define NOTICE_TITLE_STR "-Notice-"
00131 #define ERROR_TITLE_STR "-Error-"
00132 #define NOCOM_ERROR_STR "Can't Init COM."
00133 #define NOEDITOR_ERROR_STR "Can't run editor."
00134 #define NOTUTORIAL_ERROR_STR "Can't run tutorial."
00135 #define NOTXT_ERROR_STR "Can't find .TXT file."
00136 #define NOHTM_ERROR_STR "Can't find .HTM file."
00137 #define NOBROWSE_ERROR_STR "Can't run browser."
00138 #define ASSERTFAIL_ERROR_STR "Assertion Failed."
00139 #define HELP_FILE_EXT    ".htm"
00140 #define HTML_FILE_EXT    ".htm"
00141 #define TXT_FILE_EXT     ".txt"
00142 #define LICENSE_FILE_EXT ".lic"
00143
00144
00145 #ifdef __cplusplus
00146 // If compiling under C++ Ensure that Windows callbacks are
00147 // undecorated extern C calls.
00148 extern "C" {
00149 #endif
00150
00151
00152 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00153   Function: WindowProc
00154
00155   Summary:  Standard WindowProc callback function that forwards Windows
00156             messages on to the CVirWindow::WindowProc method.  This
00157             Window procedure expects that it will receive a "this"
00158             pointer as the lpCreateParams member passed as part of the
00159             WM_NCCREATE message.  It saves the "this" pointer in the
00160             GWL_USERDATA field of the window structure.
00161
00162   Args:     HWND hWnd,
00163               Window handle
00164             UINT uMsg,
00165               Windows message
00166             WPARAM wParam,
00167               First message parameter (word sized)
00168             LPARAM lParam);
00169               Second message parameter (long sized)
00170
00171   Returns:  LRESULT.  Windows window procedure callback return value.
00172 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00173 LRESULT CALLBACK WindowProc(
00174                    HWND hWnd,
00175                    UINT uMsg,
00176                    WPARAM wParam,
00177                    LPARAM lParam);
00178
00179
00180 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00181   Function: DialogProc
00182
00183   Summary:  The general dialog procedure callback function.  Used by all
00184             CVirDialog class objects.  This procedure is the DialogProc
00185             registered for all dialogs created with the CVirDialog class.
00186             It uses the parameter passed with the WM_INITDIALOG message
00187             to identify the dialog classes' "this" pointer which it then
00188             stores in the window structure's GWL_USERDATA field.
00189             All subsequent messages can then be forwarded on to the
00190             correct dialog class's DialogProc method by using the pointer
00191             stored in the GWL_USERDATA field.
00192
00193   Args:     HWND hWndDlg,
00194               Handle of dialog box.
00195             UINT uMsg,
00196               Message
00197             WPARAM wParam,
00198               First message parameter (word sized).
00199             LPARAM lParam);
00200               Second message parameter (long sized).
00201
00202   Returns:  BOOL.  Return of the CVirDialog::DialogProc method.
00203 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00204 BOOL CALLBACK DialogProc(
00205                 HWND hWndDlg,
00206                 UINT uMsg,
00207                 WPARAM wParam,
00208                 LPARAM lParam);
00209
00210
00211 #ifdef __cplusplus
00212 }
00213
00214
00215 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00216   Class:    CVirWindow
00217
00218   Summary:  Abstract base class for wrapping a window.
00219
00220             This class allows a window to be cleanly wrapped in a
00221             c++ class.  Specifically, it provides a way for a c++ class
00222             to use one of its methods as a WindowProc, giving it a "this"
00223             pointer and allowing it to have direct access to all of its
00224             private members.
00225
00226   Methods:  Create:
00227               Maps to Windows' CreateWindow function.
00228             WindowProc:
00229               Pure virtual WindowProc for the window.
00230             Gethwnd:
00231               Get the handle to the window.
00232             CVirWindow:
00233               Constructor.
00234             ~CVirWindow:
00235               Destructor.
00236 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00237 class CVirWindow
00238 {
00239 public:
00240   // Constructor
00241   CVirWindow()
00242   {
00243     m_hInst = NULL;
00244     m_hWnd = NULL;
00245   };
00246
00247   // Destructor
00248   virtual ~CVirWindow(){};
00249
00250   // Envelopes the Windows' CreateWindow function call.
00251   HWND Create(
00252          LPTSTR lpszClassName,   // Address of registered class name
00253          LPTSTR lpszWindowName,  // Address of window name
00254          DWORD dwStyle,          // Window style
00255          int x,                  // Horizontal position of window
00256          int y,                  // Vertical position of window
00257          int nWidth,             // Window width
00258          int nHeight,            // Window height
00259          HWND hWndParent,        // Handle of parent or owner window
00260          HMENU hMenu,            // Handle of menu, or child window identifier
00261          HINSTANCE hInst);       // Handle of application instance
00262
00263   // Get the protected handle of this window.
00264   HWND GetHwnd(void)
00265   {
00266     return(m_hWnd);
00267   }
00268
00269   // WindowProc is a pure virtual member function and MUST be over-ridden
00270   // in any derived classes.
00271   virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
00272
00273 protected:
00274   // Application instance handle.
00275   HINSTANCE m_hInst;
00276   // Handle of this window.
00277   HWND m_hWnd;
00278
00279   // Tell the compiler that the outside WindowProc callback is a friend
00280   // of this class and can get at its protected data members.
00281   friend LRESULT CALLBACK ::WindowProc(
00282                               HWND hWnd,
00283                               UINT uMsg,
00284                               WPARAM wParam,
00285                               LPARAM lParam);
00286 };
00287
00288
00289 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00290   Class:    CVirDialog
00291
00292   Summary:  Abstract base class for wrapping a Windows dialog box window.
00293
00294             This class allows a dialog box to be cleanly wrapped in
00295             a c++ class.  Specifically, it provides a way for a c++ class
00296             to use one of its methods as a DialogProc, giving it a "this"
00297             pointer and allowing it to have direct access to all of its
00298             private members.
00299
00300   Methods:  ShowDialog:
00301               Maps to Windows' DialogBox function.
00302             GetHwnd:
00303               Get the handle to the dialog window.
00304             DialogProc:
00305               Pure virtual DialogProc for the dialog box
00306             ~CVirDialog:
00307               Destructor
00308 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00309 class CVirDialog
00310 {
00311 public:
00312   // Constructor
00313   CVirDialog()
00314   {
00315     m_hInst = NULL;
00316     m_hWnd = NULL;
00317   };
00318
00319   // Destructor
00320   virtual ~CVirDialog(){};
00321
00322   // ShowDialog creates the Dialog (using the DialogBoxParam API).
00323   virtual int ShowDialog(
00324                 HINSTANCE hInst,
00325                 LPTSTR lpszTemplate,
00326                 HWND hWndOwner);
00327
00328   // DialogProc is a pure virtual member function and MUST be over-ridden
00329   // in any derived classes.
00330   virtual BOOL DialogProc(
00331                  HWND hWndDlg,
00332                  UINT uMsg,
00333                  WPARAM wParam,
00334                  LPARAM lParam) = 0;
00335
00336 protected:
00337   HINSTANCE m_hInst;
00338   HWND m_hWnd;
00339
00340   // Tell the compiler that the outside DialogProc callback is a friend
00341   // of this class and can get at its protected data members.
00342   friend BOOL CALLBACK ::DialogProc(
00343                            HWND hWndDlg,
00344                            UINT uMsg,
00345                            WPARAM wParam,
00346                            LPARAM lParam);
00347 };
00348
00349
00350 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00351   Class:    CAboutBox
00352
00353   Summary:  A class that implements a common About Dialog Box
00354             functionality for the APPUTIL library.
00355
00356   Methods:  DialogProc
00357               Dialog procedure
00358 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00359 class CAboutBox: public CVirDialog
00360 {
00361 public:
00362   // This DialogProc method definition overrides the same-named pure
00363   // virtual function in abstract base class CVirDialog thus giving
00364   // AboutBox-unique message dispatching behavior to this derivation
00365   // of CVirDialog.  The remaining behavior of CAboutBox is inherited
00366   // from CVirDialog and is common to all CVirDialogs.
00367   BOOL DialogProc(
00368          HWND hWndDlg,
00369          UINT uMsg,
00370          WPARAM wParam,
00371          LPARAM lParam);
00372 };
00373
00374
00375 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00376   Class:    CDelayBox
00377
00378   Summary:  A class that implements a common Dialog Box functionality for
00379             the APPUTIL library. This dialog box has no buttons and and
00380             appears on screen for 8 seconds.
00381
00382   Methods:  DialogProc
00383               Dialog procedure
00384 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00385 class CDelayBox: public CVirDialog
00386 {
00387 public:
00388   // This DialogProc method definition overrides the same-named pure
00389   // virtual function in abstract base class CVirDialog thus giving
00390   // AboutBox-unique message dispatching behavior to this derivation
00391   // of CVirDialog.  The remaining behavior of CAboutBox is inherited
00392   // from CVirDialog and is common to all CVirDialogs.
00393   BOOL DialogProc(
00394          HWND hWndDlg,
00395          UINT uMsg,
00396          WPARAM wParam,
00397          LPARAM lParam);
00398 };
00399
00400
00401 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00402   Function: DelayBox
00403
00404   Summary:  Uses the specified dialog template from the caller's resources
00405             and shows a buttonless dialog message box that remains on
00406             screen for about 3 seconds.
00407
00408   Args:     HINSTANCE hInst,
00409               Handle of the module instance.  Needed to specify the
00410               module instance for fetching the dialog template resource
00411               (ie, from either a host EXE or DLL).
00412             LPTSTR pszTemplate,
00413               Identifies the dialog box template.
00414             HWND hwndOwner)
00415               Handle of the owner window. NULL for desktop.
00416
00417   Returns:  void
00418 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00419 void DelayBox(
00420       HINSTANCE hInst,
00421       LPTSTR pszTemplate,
00422       HWND hWndOwner);
00423
00424
00425 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00426   Function: ErrorBox
00427
00428   Summary:  The ErrorBox function displays an error message dialog box. It
00429             displays an error message string in the dialog that is
00430             specified in the call by a resource ID.
00431
00432   Args:     HINSTANCE hInst,
00433               Handle of the module instance.  Needed to specify the
00434               module instance for fetching the specified string resource.
00435             HWND hwndOwner,
00436               Handle of the owner window. NULL for desktop.
00437             INT iStringID
00438               Resource ID of the error message sting.
00439
00440   Returns:  void
00441 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00442 void ErrorBox(
00443       HINSTANCE hInst,
00444       HWND hWndOwner,
00445       INT iStringID);
00446
00447
00448 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00449   Class:    CMsgBox
00450
00451   Summary:  Class for showing messages in a Message Box dialog.  Uses the
00452             standard Windows MessageBox function but retrieves the box
00453             title and message strings from the application's resources
00454             using specified resource IDs.  These message boxes have only
00455             an OK button.
00456
00457   Methods:  Init
00458               Initializes the owner window and the module instance.
00459             Error
00460               Shows a message string in an Error MessageBox Dialog.
00461             ErrorID
00462               Shows a resource message string in an Error MessageBox Dialog.
00463             Note
00464               Shows a message string in a Notice MessageBox Dialog.
00465             NoteID
00466               Shows a resource message string in a Notice MessageBox Dialog.
00467             NoteFmt
00468               Shows a printf-style formatted message string in a Notice
00469               MessageBox Dialog.
00470             NoteFmtID
00471               Shows a printf-style formatted resource message string in a
00472               Notice MessageBox Dialog.
00473 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00474 class CMsgBox
00475 {
00476 public:
00477   // Constructor.
00478   CMsgBox()
00479   {
00480     m_hInst = 0;
00481     m_hWndOwner = 0;
00482   };
00483
00484   BOOL Init(HINSTANCE hInst, HWND hWndOwner);
00485   int  Error(LPTSTR szMsg);
00486   int  ErrorID(UINT uMsgID);
00487   int  Note(LPTSTR szMsg);
00488   int  NoteID(UINT uMsgID);
00489   int  NoteFmt(LPTSTR szFmtMsg, ...);
00490   int  NoteFmtID(UINT uMsgID, ...);
00491
00492 private:
00493   // Remember the App Instance Handle.
00494   HINSTANCE m_hInst;
00495   // Remember the Owner Window Handle.
00496   HWND m_hWndOwner;
00497 };
00498
00499
00500 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00501   Class:    CMsgLog
00502
00503   Summary:  Class for logging messages to a Listbox.  This is for tutorial
00504             code samples that employ debug messages to announce internal
00505             activity in the code being studied.  When used, this Message
00506             Log listbox occupies the entire client area of the parent
00507             window.  The various message output functions use string
00508             resource IDs to retrieve the message strings from the app's
00509             resources.
00510
00511   Methods:  Create
00512               Creates the Trace Message Log ListBox window.
00513             Logging
00514               Toggles logging on or off.
00515             Msg
00516               Logs a message as a separate line.
00517             MsgFmt
00518               Logs a printf-style formated message as a separate line.
00519             Resize
00520               Resizes the listbox to a new width and height.
00521             Clear
00522               Clears all logged messages from the message log.
00523             CMsgLog
00524               Constructor.
00525             ~CMsgLog
00526               Destructor.
00527 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00528 class CMsgLog
00529 {
00530 public:
00531   // Constructor.
00532   CMsgLog()
00533   {
00534     m_hInstLog = 0;
00535     m_hWndLog = 0;
00536     m_bChild = FALSE;
00537     m_bLogging = FALSE;
00538     m_hLogData = 0;
00539   };
00540
00541   BOOL Create(HINSTANCE hInst, HWND hWndParent, BOOL bChild);
00542   BOOL Logging(BOOL bLogging);
00543   BOOL Msg(LPTSTR szMsg);
00544   BOOL MsgFmt(LPTSTR szFmtMsg, ...);
00545   BOOL MsgID(int iMsgID);
00546   BOOL MsgFmtID(int iFmtID, ...);
00547   BOOL Resize(int nWidth, int nHeight);
00548   BOOL Clear(void);
00549   BOOL Copy(void);
00550
00551 private:
00552   // Remember the App Instance Handle.
00553   HINSTANCE m_hInstLog;
00554   // Remember the handle of the listbox window.
00555   HWND m_hWndLog;
00556   // Remember if CMsgLog was created as child window.
00557   BOOL m_bChild;
00558   // Remember whether logging or not.
00559   BOOL m_bLogging;
00560   // Remember the global handle to clipboard data.
00561   HGLOBAL m_hLogData;
00562 };
00563
00564
00565 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00566   Class:    CSendLog
00567
00568   Summary:  Class for logging messages to a CMsgLog facility in another
00569             application process. This is for tutorial code samples that
00570             employ debug messages to announce internal activity in the
00571             code being studied.  Uses the WM_COPYDATA message of the
00572             Win32 SendMessage API.
00573
00574   Methods:  CreateServerLog
00575               Initializes the SendLog facility and creates the Trace
00576               Message Log ListBox window shown in the local server app.
00577             SetClient
00578               Sets destination client window handle.
00579             LogToServer
00580               Set whether logging is to local server or to client.
00581             Msg
00582               Logs a message as a separate line.
00583             MsgFmt
00584               Logs a printf-style formated message as a separate line.
00585             Resize
00586               Resizes the listbox to a new width and height.
00587             Clear
00588               Clears all logged messages from the message log.
00589             CSendLog
00590               Constructor.
00591             ~CSendLog
00592               Destructor.
00593 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00594 class CSendLog
00595 {
00596 public:
00597   // Constructor.
00598   CSendLog()
00599   {
00600     m_hInstSender = 0;
00601     m_hWndSender = 0;
00602     m_hWndReceiver = 0;
00603     m_hWndListBox = 0;
00604     m_bLogToServer = FALSE;
00605     m_bChild = FALSE;
00606     m_hLogData = 0;
00607   };
00608
00609   BOOL CreateServerLog(HINSTANCE hInst, HWND hWndParent, BOOL bChild);
00610   BOOL SetClient(HINSTANCE hInstSender, HWND hWndSender, HWND hWndReceiver);
00611   BOOL LogToServer(BOOL bLogToServer);
00612   BOOL Msg(LPTSTR szMsg);
00613   BOOL MsgFmt(LPTSTR szFmtMsg, ...);
00614   BOOL MsgID(int iMsgID);
00615   BOOL MsgFmtID(int iFmtID, ...);
00616   BOOL Resize(int nWidth, int nHeight);
00617   BOOL Clear(void);
00618   BOOL Copy(void);
00619
00620 private:
00621   // Remember the Sender App Instance Handle.
00622   HINSTANCE m_hInstSender;
00623   // Remember the handle of the sending application main window.
00624   HWND m_hWndSender;
00625   // Remember the handle of the destination receiving window.
00626   HWND m_hWndReceiver;
00627   // Remember the handle of the server's listbox window.
00628   HWND m_hWndListBox;
00629   // Boolean for logging to client or logging to server.
00630   BOOL m_bLogToServer;
00631   // Remember if CMsgLog was created as child window.
00632   BOOL m_bChild;
00633   // Remember the global handle to clipboard data.
00634   HGLOBAL m_hLogData;
00635 };
00636
00637
00638 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00639   Class:    CThreaded
00640
00641   Summary:  Derive a class from this class to provide multi-threaded
00642             access to objects of the derived class. This is a utility
00643             base class providing useful methods for achieving mutually
00644             exclusive access to data in objects of the derived class.
00645
00646   Methods:  OwnThis
00647               Blocks executing thread until access to this object is
00648               permitted at which point the thread "owns" this object.
00649             UnOwnThis
00650               Executed by owning thread to relinquish ownership of
00651               this object.
00652             CThreaded
00653               Constructor. Creates mutex to govern mutually exclusive
00654               access to data in this object by multiple threads.
00655             ~CThreaded
00656               Destructor. Destroys mutex.
00657 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00658 class CThreaded
00659 {
00660   protected:
00661     // Variables for providing mutually exclusive access by multiple
00662     // threads to objects of classes derived from this class.
00663     HANDLE m_hOwnerMutex;
00664     BOOL   m_bOwned;
00665
00666   public:
00667     // Methods.
00668     CThreaded(void) :
00669       m_hOwnerMutex(CreateMutex(0,FALSE,0)),
00670       m_bOwned(FALSE)
00671     {
00672     };
00673
00674     ~CThreaded(void)
00675     {
00676       // Close down the mutex.
00677       CloseHandle(m_hOwnerMutex);
00678     };
00679
00680     // The following virtual functions have overriding definitions in
00681     // the derived class to provide convenient trace logging. Rely on
00682     // the below default definitions for non-tutorial applications.
00683
00684     virtual BOOL OwnThis(void)
00685     {
00686       BOOL bOwned = FALSE;
00687
00688       if (WAIT_OBJECT_0 == WaitForSingleObject(m_hOwnerMutex, INFINITE))
00689         m_bOwned = bOwned = TRUE;
00690
00691       return bOwned;
00692     };
00693
00694     virtual void UnOwnThis(void)
00695     {
00696       if (m_bOwned)
00697       {
00698         m_bOwned = FALSE;
00699         ReleaseMutex(m_hOwnerMutex);
00700       }
00701
00702       return;
00703     };
00704 };
00705
00706
00707 #endif //__cplusplus
00708
00709
00710
00711 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00712   Function: AnsiToUc
00713
00714   Summary:  Convert an ANSI 'multibyte' string into a UNICODE 'wide
00715             character' string.
00716
00717   Args:     LPSTR pszAnsi
00718               Pointer to a caller's null terminated input ANSI string.
00719             LPWSTR pwszUc
00720               Pointer to a caller's output UNICODE wide string buffer.
00721             int cch
00722               Size of pwszUc in number of wide characters.  Must be greater
00723               than 0.
00724
00725   Returns:  HRESULT
00726               Standard result code. NOERROR for success.
00727 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00728 HRESULT AnsiToUc(
00729           LPSTR pszAnsi,
00730           LPWSTR pszUc,
00731           int cch);
00732
00733
00734 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00735   Function: UcToAnsi
00736
00737   Summary:  Convert a UNICODE 'wide character' input string to an output
00738             ANSI 'multi-byte' string.
00739
00740   Args:     LPWSTR pwszUc
00741               Pointer to a caller's input UNICODE wide string.
00742             LPSTR pszAnsi
00743               Pointer to a caller's output ANSI string.
00744             int cch
00745               Size of pszAnsi in number of characters.  Must be greater than
00746               0.
00747
00748   Returns:  HRESULT
00749               Standard result code. NOERROR for success.
00750 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00751 HRESULT UcToAnsi(
00752           LPWSTR pwszUc,
00753           LPSTR pszAnsi,
00754           int cch);
00755
00756
00757 /*---------------------------------------------------------------------------
00758   Here are some surrogate API macro prototypes--all names begin with A_.
00759   These are for use when the code sample is being compiled for ANSI
00760   strings (the default) and the calls they stand in place of only support
00761   UNICODE (thus forcing some string conversions from ANSI to UNICODE
00762   before the real call is made inside the surrogate). For example, if
00763   UNICODE is NOT defined during the compile then any calls in the samples
00764   to the StringFromGUID2 function are actually changed (by the below
00765   macros) into calls to an A_StringFromGUID2 function implemented in
00766   APPUTIL. This function accepts the ANSI input string pointer, calls the
00767   actual StringFromGUID2 call, and does the necessary Unicode to ANSI
00768   conversion. Other A_ calls will convert input ANSI strings to Unicode
00769   strings prior to calling the actual COM/OLE function.
00770 ---------------------------------------------------------------------------*/
00771 #if !defined(UNICODE)
00772
00773 STDAPI A_StringFromGUID2(REFGUID, LPSTR, int);
00774
00775 STDAPI A_WriteFmtUserTypeStg(IStorage*, CLIPFORMAT, LPSTR);
00776
00777 STDAPI A_StgIsStorageFile(LPSTR);
00778 STDAPI A_StgCreateDocfile(LPSTR, DWORD, DWORD, IStorage**);
00779 STDAPI A_StgOpenStorage(LPSTR, IStorage*, DWORD, SNB, DWORD, IStorage**);
00780
00781 #if !defined(_NOANSIMACROS_)
00782
00783 #undef StringFromGUID2
00784 #define StringFromGUID2(a, b, c) A_StringFromGUID2(a, b, c)
00785
00786 #undef WriteFmtUserTypeStg
00787 #define WriteFmtUserTypeStg(a, b, c) A_WriteFmtUserTypeStg(a, b, c)
00788
00789 #undef StgIsStorageFile
00790 #define StgIsStorageFile(a) A_StgIsStorageFile(a)
00791
00792 #undef StgCreateDocfile
00793 #define StgCreateDocfile(a, b, c, d) A_StgCreateDocfile(a, b, c, d)
00794
00795 #undef StgOpenStorage
00796 #define StgOpenStorage(a, b, c, d, e, f) A_StgOpenStorage(a, b, c, d, e, f)
00797
00798 #endif
00799
00800 #endif
00801
00802
00803 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00804   Function: DComOk
00805
00806   Summary:  Determine if DCOM (Distributed COM) can be used. It can if it
00807             is installed and is enabled on the current machine.
00808
00809   Args:     void
00810
00811   Returns:  BOOL
00812               TRUE - DCOM installed and enabled; FALSE - NOT.
00813 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00814 BOOL DComOk(void);
00815
00816
00817 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00818   Function: lRandom
00819
00820   Summary:  Simple random number generator. Returns a random DWORD.
00821
00822   Args:     void
00823
00824   Returns:  DWORD
00825               Random number.
00826 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00827 DWORD lRandom(void);
00828
00829
00830 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00831   Function: CreateColorScalePalette
00832
00833   Summary:  This function creates a palette representing the scale values
00834             of a particular RGB color.  A gray-scale palette can also be
00835             created.
00836
00837   Args:     HDC hDC,
00838               Handle to device context.
00839             int nColor
00840               New color.
00841
00842   Returns:  HPALETTE
00843               Handle to new pallete.
00844 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00845 HPALETTE CreateColorScalePalette(HWND hDC, int nColor);
00846
00847
00848 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00849   Function: PaintWindow
00850
00851   Summary:  This function is used to wash the background of a window.
00852
00853   Args:     HWND hWnd,
00854               Window handle.
00855             int nColor
00856               New window color.
00857
00858   Returns:  void.
00859 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00860 VOID PaintWindow(HWND hWnd, int nColor);
00861
00862
00863 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00864   Function: SkipAnsi
00865
00866   Summary:  Utility function to scan an input ANSI string and either skips
00867             white characters or skips non-white characters.
00868
00869   Args;     LPSTR psz,
00870               Input ANSI string to be scanned.
00871             BOOL bSkipWhite
00872               Input boolean determining whether to skip white space
00873               or not.  TRUE means skip white space; FALSE means skip
00874               non-white chars.
00875
00876   Returns:  LPSTR
00877               String pointer after the skip (ANSI)
00878 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00879 LPSTR SkipAnsi(
00880          LPSTR psz,
00881          BOOL bSkipWhite);
00882
00883
00884 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00885   Function: FileExist
00886
00887   Summary:  Function to test for the existance of a file.
00888
00889   Args:     TCHAR* szFileName
00890               String pointer to file's path/name.
00891
00892   Returns:  BOOL.  TRUE if file exists; FALSE if not.
00893 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00894 BOOL FileExist(TCHAR *szFileName);
00895
00896
00897 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00898   Function: MakeFamilyPath
00899
00900   Summary:  Function to make a family file/path/name string using the
00901             detetected pathname of the current executable module.
00902
00903   Args:     HINSTANCE hInst
00904               Handle to the module intstance.
00905             TCHAR* pszNewPath
00906               String pointer to the new path/name.
00907             TCHAR* pszFileExt
00908               String pointer to the filename extension for the new path.
00909
00910   Returns:  BOOL.  TRUE if success; FALSE if not.
00911 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00912 BOOL MakeFamilyPath(
00913        HINSTANCE hInst,
00914        TCHAR* pszNewPath,
00915        TCHAR* pszFileExt);
00916
00917
00918 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00919   Function: GetExeName
00920
00921   Summary:  Function to get the executable file name of the current
00922             module. Makes names like: MyApp.EXE or MyDll.DLL.
00923
00924   Args:     HINSTANCE hInst
00925               Handle to the module intstance.
00926             TCHAR* pszExeName
00927               String pointer to the new executable file name.
00928               A char string allocated by user.
00929
00930   Returns:  BOOL.  TRUE if success; FALSE if not.
00931 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00932 BOOL GetExeName(
00933        HINSTANCE hInst,
00934        TCHAR* pszExeName);
00935
00936
00937 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00938   Function: CmdExec
00939
00940   Summary:  Execute an EXE Win32 program by creating a process and
00941             running the specified EXE in it.  A Unicode version of
00942             WinExec that always has SW_SHOW.
00943
00944   Args:     LPTSTR szCmd,
00945               Entire command line (eg, "notepad.exe mytext.txt")
00946
00947   Returns:  BOOL
00948               TRUE if succeed; FALSE if fail.
00949 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00950 BOOL CmdExec(
00951        LPTSTR szCmd);
00952
00953
00954 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00955   Function: HrMsg
00956
00957   Summary:  HRESULT Error Message box. Takes standard result code,
00958             looks it up in the system tables, and shows a message
00959             box with the error code (in hex) and the associated
00960             system message.
00961
00962   Args:     HWND hWndOwner,
00963               Handle to owner parent window.
00964             LPTSTR pszTitle
00965               User message string (eg, designating the attempted function).
00966               Appears in the dialog title bar.
00967             HRESULT hr
00968               Standard return code.
00969
00970   Returns:  void
00971 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00972 void HrMsg(
00973        HWND hWndOwner,
00974        LPTSTR pszTitle,
00975        HRESULT hr);
00976
00977
00978 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00979   Function: HrMsgId
00980
00981   Summary:  HRESULT Error Message box using string resource ID. Takes
00982             standard result code, looks it up in the system tables, and
00983             shows a message box with the error code (in hex) and the
00984             associated system message. An additional user message string
00985             (specified as a resource ID) is also shown.
00986
00987   Args:     HINSTANCE hInst,
00988               Handle of the module instance.  Needed to specify the
00989               module instance for fetching the specified string resource.
00990             HWND hwndOwner,
00991               Handle of the owner window. NULL for desktop.
00992             INT iStringID
00993               Resource ID of error message string. Appears in the
00994               dialog title bar.
00995             HRESULT hr,
00996               Standard result code.
00997
00998   Returns:  void
00999 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01000 void HrMsgId(
01001       HINSTANCE hInst,
01002       HWND hWndOwner,
01003       INT iStringID,
01004       HRESULT hr);
01005
01006
01007 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01008   Function: ReadHelp
01009
01010   Summary:  The ReadHelp function is a general help reader for
01011             applications. It uses the shell to run the reader application
01012             associated with the extension of the specified file/path name.
01013             For example, if the family-named file name is MYAPP.HTM, then
01014             the web browser will be used to read the HTML help file.
01015
01016   Args:     HWND hWndOwner,
01017               Handle to owner parent window.
01018             LPTSTR pszHelpFile,
01019               Pointer to the help file/path name string.
01020
01021   Returns:  void
01022 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01023 void ReadHelp(
01024        HWND hWndOwner,
01025        LPTSTR pszHelpFile);
01026
01027
01028 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01029   Function: ReadTutorial
01030
01031   Summary:  The ReadTutorial function is for use by tutorial code sample
01032             applications that study themselves. This function uses simple
01033             Hyperlinking to launch the web browser to read an HTML web
01034             page that contains a tutorial covering the sample. If no HTM
01035             file (in a sibling or parent directory) is specified, this
01036             function assumes a family-named <sample>.HTM tutorial HTML
01037             file that is located next to the main .EXE file of the
01038             application calling ReadTutorial. "Family-named" means that if
01039             the EXE program calling this function is MYAPP.EXE then the
01040             associated family-named HTML file is constructed as MYAPP.HTM.
01041
01042   Args:     HINSTANCE hInst,
01043               Handle of the executable module instance.
01044             HWND hWndOwner,
01045               Handle to owner parent window.
01046             LPTSTR pszHTMLFile,
01047               Pointer to an optional HTML FileName string. If this pointer
01048               is NULL, then the family-named file is assumed for the HTML
01049               file and is assumed to be located next to the main .EXE file
01050               of the program executing this function. Non-NULL values are
01051               of the form "MySiblingDirectory\MyHTMLFile.HTM" or of the
01052               form "MyHTMLFileInTheParentDirectory.HTM". Special non-NULL
01053               values beginning with '.' (eg. ".HTM" or ".ASP") specify
01054               that the family-named file is assumed to be located in the
01055               parent directory. In this case, the specified file extension
01056               is used.
01057
01058   Returns:  void
01059 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01060 void ReadTutorial(
01061        HINSTANCE hInst,
01062        HWND hWndOwner,
01063        LPTSTR pszHTMLFile);
01064
01065
01066 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01067   Function: GoWeb
01068
01069   Summary:  General utility function to launch a web browser on a
01070             specified HTML file via either a URL or a full file path/name.
01071
01072   Args:     HINSTANCE hInst,
01073               Handle of the executable module instance.
01074             LPSTR pszTarget
01075               Pointer to the Target specification string (must be ANSI).
01076               If null then call the ReadTutorial function. If pszTarget
01077               starts with '//' then the target is assumed to be a www URL
01078               trailer of the form: //www.microsoft.com. If any other
01079               string, then it is assumed to be a full path/file name.
01080
01081   Returns:  void
01082 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01083 void GoWeb(
01084        HINSTANCE hInst,
01085        LPSTR pszTarget);
01086
01087
01088 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01089   Function: ReadSource
01090
01091   Summary:  For use by code sample applications that study themselves
01092             as it were.  This function allows you to select one of the
01093             source files of this code sample and launch a reader to
01094             edit/read it.  NOTEPAD.EXE is the default editor/reader.
01095             You can change this by changing EDITOR_FILE_STR in
01096             APPUTIL.H above.
01097
01098   Args:     HWND hWndOwner
01099               Handle of parent window.
01100             OPENFILENAME* pofn,
01101               Pointer to the Open File Name Common Dialog structure.
01102
01103   Returns:  void
01104 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01105 void ReadSource(
01106        HWND hWndOwner,
01107        OPENFILENAME* pOfn);
01108
01109
01110 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01111   Function: OutputDebugFmt
01112
01113   Summary:  Wraps the Win32 OutputDebugString API call to provide
01114             printf-style formatted (and variable argument) output.
01115
01116   Args:     LPTSTR szFmt,
01117               Format string.
01118             [...]
01119               Arguments to match those specified in the format string.
01120
01121   Returns:  void
01122 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01123 void OutputDebugFmt(
01124        LPTSTR szFmt,
01125        ...);
01126
01127
01128 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01129   Function: GetErrorMsg
01130
01131   Summary:  Accepts a Win32 error code and retrieves a human readable
01132             system message for it.
01133
01134   Args:     HRESULT hr
01135               SCODE error code.
01136             LPTSTR pszMsg
01137               Pointer string where message will be placed.
01138             UINT uiSize
01139               Max size of the msg string.
01140
01141   Returns:  BOOL
01142               TRUE if hr was error; FALSE if not.
01143 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01144 BOOL GetErrorMsg(
01145        HRESULT hr,
01146        LPTSTR pszMsg,
01147        UINT uiSize);
01148
01149
01150 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01151   Function: SetRegKeyValue
01152
01153   Summary:  Internal utility function to set a Key, Subkey, and value
01154             in the system Registry.
01155
01156   Args:     LPTSTR pszKey,
01157             LPTSTR pszSubkey,
01158             LPTSTR pszValue)
01159
01160   Returns:  BOOL
01161               TRUE if success; FALSE if not.
01162 ------------------------------------------------------------------------F-F*/
01163 BOOL SetRegKeyValue(
01164        LPTSTR pszKey,
01165        LPTSTR pszSubkey,
01166        LPTSTR pszValue);
01167
01168
01169 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01170   Function: AddRegNamedValue
01171
01172   Summary:  Internal utility function to add a named data value to an
01173             existing Key (with optional Subkey) in the system Registry
01174             under HKEY_CLASSES_ROOT.
01175
01176   Args:     LPTSTR pszKey,
01177             LPTSTR pszSubkey,
01178             LPTSTR pszValueName,
01179             LPTSTR pszValue)
01180
01181   Returns:  BOOL
01182               TRUE if success; FALSE if not.
01183 ------------------------------------------------------------------------F-F*/
01184 BOOL AddRegNamedValue(
01185        LPTSTR pszKey,
01186        LPTSTR pszSubkey,
01187        LPTSTR pszValueName,
01188        LPTSTR pszValue);
01189
01190 #if defined(_UNICODE)
01191 #define lstrncat(strDest,strSource,count) wcsncat(strDest,strSource,count)
01192 #else
01193 #define lstrncat(strDest,strSource,count) strncat(strDest,strSource,count)
01194 #endif // _UNICODE
01195
01196 #define TID GetCurrentThreadId()
01197
01198 #if defined(DEBUG)
01199
01200 //Basic debug and logging macros
01201
01202 // Output debug string; literal or variable.
01203 // Note the assertion checking to make sure that we don't exceed the size
01204 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01205 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01206 #define ODS(sMsg) \
01207 {\
01208   TCHAR szDebug[MAXLOGST];\
01209   OutputDebugFmt(TEXT("%s"),TEXT(sMsg));\
01210   assert(__LINE__ <= MAX_LINE_NUM);\
01211   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01212    < MAXLOGST);\
01213   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01214   OutputDebugString(szDebug);\
01215 }
01216
01217 // Output debug string formatted; one argument.
01218 // Note the assertion checking to make sure that we don't exceed the size
01219 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01220 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01221 #define ODF1(sFmt,x) \
01222 {\
01223   TCHAR szDebug[MAXLOGST];\
01224   OutputDebugFmt(TEXT(sFmt),x);\
01225   assert(__LINE__ <= MAX_LINE_NUM);\
01226   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01227    < MAXLOGST);\
01228   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01229   OutputDebugString(szDebug);\
01230 }
01231
01232 // Output debug string formatted; two argument.
01233 // Note the assertion checking to make sure that we don't exceed the size
01234 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01235 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01236 #define ODF2(sFmt,x,y) \
01237 {\
01238   TCHAR szDebug[MAXLOGST];\
01239   OutputDebugFmt(TEXT(sFmt),x,y);\
01240   assert(__LINE__ <= MAX_LINE_NUM);\
01241   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01242    < MAXLOGST);\
01243   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01244   OutputDebugString(szDebug);\
01245 }
01246
01247 // Output debug string formatted; three argument.
01248 // Note the assertion checking to make sure that we don't exceed the size
01249 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01250 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01251 #define ODF3(sFmt,x,y,z) \
01252 {\
01253   TCHAR szDebug[MAXLOGST];\
01254   OutputDebugFmt(TEXT(sFmt),x,y,z);\
01255   assert(__LINE__ <= MAX_LINE_NUM);\
01256   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01257    < MAXLOGST);\
01258   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01259   OutputDebugString(szDebug);\
01260 }
01261
01262 // Check condition and Output assertion failed message to debugger.
01263 #define ASSERT(condition) \
01264 {\
01265   if (!(condition))\
01266     ODS(TEXT("Assertion Failed"));\
01267 }
01268
01269 // Check standard HRESULT for error and put up message box if error.
01270 // Two arguments. Pfx = Prefix msg string; Ec = error code.
01271 // Eg: CKHR("MyFunction:",hr);
01272 // Note the assertion checking to make sure that we don't exceed the size
01273 // of szMsg.  This is a valid assertion to make since MAXLOGST is defined
01274 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01275 #define CKHR(Pfx,Ec) \
01276 {\
01277   TCHAR szMsg[MAXLOGST];\
01278   if (GetErrorMsg(Ec,szMsg,MAX_PATH))\
01279   {\
01280     HrMsg(NULL,TEXT(Pfx),Ec);\
01281     assert(__LINE__ <= MAX_LINE_NUM);\
01282     assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01283      < MAXLOGST);\
01284     wsprintf(szMsg, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01285     OutputDebugString(szMsg);\
01286   }\
01287 }
01288
01289 // Log debug string (output both to Message Log and to Debugger)
01290 // Note the assertion checking to make sure that we don't exceed the size
01291 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01292 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01293 #define LOG(sMsg) \
01294 {\
01295   TCHAR szDebug[MAXLOGST];\
01296   if (NULL!=g_pMsgLog)\
01297     g_pMsgLog->Msg(TEXT(sMsg));\
01298   assert(__LINE__ <= MAX_LINE_NUM);\
01299   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01300    < MAXLOGST);\
01301   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01302   OutputDebugString(szDebug);\
01303 }
01304
01305 // Log debug string (output both to Message Log and to Debugger).
01306 // One argument.
01307 // Note the assertion checking to make sure that we don't exceed the size
01308 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01309 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01310 #define LOGF1(sFmt,x) \
01311 {\
01312   TCHAR szDebug[MAXLOGST];\
01313   if (NULL!=g_pMsgLog)\
01314     g_pMsgLog->MsgFmt(TEXT(sFmt),x);\
01315   assert(__LINE__ <= MAX_LINE_NUM);\
01316   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01317    < MAXLOGST);\
01318   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01319   OutputDebugString(szDebug);\
01320 }
01321
01322 // Log debug string (output both to Message Log and to Debugger).
01323 // Two argument.
01324 // Note the assertion checking to make sure that we don't exceed the size
01325 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01326 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01327 #define LOGF2(sFmt,x,y) \
01328 {\
01329   TCHAR szDebug[MAXLOGST];\
01330   if (NULL!=g_pMsgLog)\
01331     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y);\
01332   assert(__LINE__ <= MAX_LINE_NUM);\
01333   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01334    < MAXLOGST);\
01335   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01336   OutputDebugString(szDebug);\
01337 }
01338
01339 // Log debug string (output both to Message Log and to Debugger).
01340 // Three argument.
01341 // Note the assertion checking to make sure that we don't exceed the size
01342 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01343 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01344 #define LOGF3(sFmt,x,y,z) \
01345 {\
01346   TCHAR szDebug[MAXLOGST];\
01347   if (NULL!=g_pMsgLog)\
01348     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y,z);\
01349   assert(__LINE__ <= MAX_LINE_NUM);\
01350   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01351    < MAXLOGST);\
01352   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01353   OutputDebugString(szDebug);\
01354 }
01355
01356 // Log error message string (output both to Message Log and to Debugger).
01357 // Two arguments. Pfx = Prefix msg string; Ec = error code.
01358 // Eg: LOGERROR("MyFunction:",hr);
01359 // Note the assertion checking to make sure that we don't exceed the size
01360 // of szMsg.  This is a valid assertion to make since MAXLOGST is defined
01361 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01362 #define LOGERROR(Pfx,Ec) \
01363 {\
01364   TCHAR szMsg[MAXLOGST];\
01365   if (NULL!=g_pMsgLog && GetErrorMsg(Ec,szMsg,MAX_PATH))\
01366   {\
01367     g_pMsgLog->MsgFmt(TEXT("%s Error=0x%X: %s"),TEXT(Pfx),Ec,szMsg);\
01368     assert(__LINE__ <= MAX_LINE_NUM);\
01369     assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01370      < MAXLOGST);\
01371     wsprintf(szMsg, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01372     OutputDebugString(szMsg);\
01373   }\
01374 }
01375
01376 // Log debug string (output both to Message Log and to Debugger).
01377 // Use a string resource ID to retrieve the display string.
01378 // Note the assertion checking to make sure that we don't exceed the size
01379 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01380 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01381 #define LOGID(id) \
01382 {\
01383   TCHAR szDebug[MAXLOGST];\
01384   if (NULL!=g_pMsgLog)\
01385     g_pMsgLog->MsgID(id);\
01386   assert(__LINE__ <= MAX_LINE_NUM);\
01387   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01388    < MAXLOGST);\
01389   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01390   OutputDebugString(szDebug);\
01391 }
01392
01393 // Log assertion failure.
01394 #define LOGASSERT(condition) \
01395 {\
01396   if (!(condition))\
01397     LOGID(IDS_ASSERT_FAIL);\
01398 }
01399
01400 #else  // !defined(DEBUG)
01401
01402 #define ODS(x)
01403
01404 #define ODF1(sFmt,x)
01405
01406 #define ODF2(sFmt,x,y)
01407
01408 #define ODF3(sFmt,x,y,z)
01409
01410 #define ASSERT(condition)
01411
01412 #define CKHR(Pfx,Ec)
01413
01414 #define LOG(sMsg) \
01415 {\
01416   if (NULL!=g_pMsgLog)\
01417     g_pMsgLog->Msg(TEXT(sMsg));\
01418 }
01419
01420 // Log debug string (output both to Message Log and not to Debugger).
01421 // One argument.
01422 #define LOGF1(sFmt,x) \
01423 {\
01424   if (NULL!=g_pMsgLog)\
01425     g_pMsgLog->MsgFmt(TEXT(sFmt),x);\
01426 }
01427
01428 // Log debug string (output both to Message Log and not to Debugger).
01429 // Two argument.
01430 #define LOGF2(sFmt,x,y) \
01431 {\
01432   if (NULL!=g_pMsgLog)\
01433     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y);\
01434 }
01435
01436 // Log debug string (output both to Message Log and not to Debugger).
01437 // Three argument.
01438 #define LOGF3(sFmt,x,y,z) \
01439 {\
01440   if (NULL!=g_pMsgLog)\
01441     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y,z);\
01442 }
01443
01444 // Log error message string (output both to Message Log and not to Debugger).
01445 // Two arguments. Pfx = Prefix msg string; Ec = error code.
01446 // Eg: LOGERROR("MyFunction:",hr);
01447 #define LOGERROR(Pfx,Ec) \
01448 {\
01449   TCHAR szMsg[MAX_PATH];\
01450   if (NULL!=g_pMsgLog && GetErrorMsg(Ec,szMsg,MAX_PATH))\
01451     g_pMsgLog->MsgFmt(TEXT("%s Error=0x%X: %s"),TEXT(Pfx),Ec,szMsg);\
01452 }
01453
01454 // Log debug string (output both to Message Log and not to Debugger).
01455 // Use a string resource ID to retrieve the display string.
01456 #define LOGID(id) \
01457 {\
01458   if (NULL!=g_pMsgLog)\
01459     g_pMsgLog->MsgID(id);\
01460 }
01461
01462 // Log assertion failure.
01463 #define LOGASSERT(condition)\
01464 {\
01465   if (!(condition))\
01466     LOGID(IDS_ASSERT_FAIL);\
01467 }
01468
01469 #endif // DEBUG
01470
01471 #endif //APPUTIL_H
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CLandBasedVehicle Member List

This is the complete list of members for CLandBasedVehicle, including all inherited members.
AddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
bExpanded | CDelegationBase | [protected]
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CDelegationBase() | CDelegationBase |
CLandBasedVehicle(CComponentData *pComponentData=NULL) | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CLandBasedVehicle(CComponentData *pComponentData=NULL) | CLandBasedVehicle | [inline]
CLandBasedVehicle() | CLandBasedVehicle | [inline]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
CreatePropertyPages(IPropertySheetCallback *lpProvider, LONG_PTR handle) | CDelegationBase | [inline, virtual]
Expand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetBitmapIndex() | CLandBasedVehicle | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildColumnInfo(RESULTDATAITEM *rdi) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetChildPtr(int index) | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetCookie() | CDelegationBase | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetDisplayName(int nCol=0) | CLandBasedVehicle | [inline, virtual]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline]
GetHandle() | CDelegationBase | [inline, virtual]
GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo) | CDelegationBase | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
getNodeType() | CLandBasedVehicle | [inline, virtual]
GetParentScopeItem() | CLandBasedVehicle | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) | CDelegationBase | [inline, virtual]
GetTaskList(LPOLESTR szTaskGroup, LONG *nCount) | CDelegationBase | [inline, virtual]
GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO) | CDelegationBase | [inline, virtual]
GetTaskpadDescription(LPOLESTR *pszDescription) | CDelegationBase | [inline, virtual]
GetTaskpadTitle(LPOLESTR *pszTitle) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
GetWatermarks(HBITMAP *lphWatermark, HBITMAP *lphHeader, HPALETTE *lphPalette, BOOL *bStretch) | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
HasPropertySheets() | CDelegationBase | [inline, virtual]
IDM_NEW_LAND enum value | CLandBasedVehicle | [private]
InitOCX(IUnknown *pUnknown) | CDelegationBase | [inline, virtual]
LoadBitmaps() | CDelegationBase | [inline, protected]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
LoadBitmaps() | CDelegationBase | [inline, protected, static]
m_hParentHScopeItem | CLandBasedVehicle | [private]
m_pBMapLg | CDelegationBase |
m_pBMapLg | CDelegationBase | [static]
m_pBMapSm | CDelegationBase |
m_pBMapSm | CDelegationBase | [static]
m_pComponentData | CDelegationBase |
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddImages(IImageList *pImageList, HSCOPEITEM hsi) | CDelegationBase | [virtual]
OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed) | CLandBasedVehicle | [virtual]
OnButtonClicked(CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsoleComp) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDelete(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnDeleteScopeItem(IConsoleNameSpace *pConsoleNameSpace) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) | CDelegationBase | [inline, virtual]
OnListpad(IConsole *pConsole, BOOL bAttaching) | CDelegationBase | [inline, virtual]
OnMenuButtonCommand(IConsole *pConsole, int nMenuId, long lCommandID) | CDelegationBase | [inline, virtual]
OnMenuCommand(IConsole *pConsole, long lCommandID) | CLandBasedVehicle | [virtual]
CDelegationBase::OnMenuCommand(IConsole *pConsole, IConsoleNameSpace *pConsoleNameSpace, long lCommandID, IDataObject *piDataObject) | CDelegationBase | [inline, virtual]
OnPaste(IConsole *pConsole, CComponentData *pComponentData, CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole, CComponent *pComponent) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnPropertyChange(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnQueryPaste(CDelegationBase *pPasted) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh(IConsole *pConsole) | CDelegationBase | [inline, virtual]
OnRefresh() | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnRename(LPOLESTR pszNewName) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(CComponent *pComponent, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetMenuButton(IConsole *pConsole, MENUBUTTONDATA *pmbd) | CDelegationBase | [inline, virtual]
OnSetToolbar(IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnSetToolbar(CComponent *pComponent, IControlbar *pControlbar, IToolbar *pToolbar, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [virtual]
OnToolbarCommand(IConsole *pConsole, MMC_CONSOLE_VERB verb, IDataObject *pDataObject) | CDelegationBase | [inline, virtual]
OnToolbarCommand(CComponent *pComponent, IConsole *pConsole, MMC_CONSOLE_VERB verb) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
OnUpdateItem(IConsole *pConsole, long item, ITEM_TYPE itemtype) | CDelegationBase | [inline, virtual]
Select(IConsole *pConsole, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SelectItem(IConsole *pConsole) | CDelegationBase | [inline, virtual]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetComponentData(CComponentData *pComponentData) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline]
SetHandle(HANDLE handle) | CDelegationBase | [inline, virtual]
SetMenuState(IControlbar *pControlbar, IMenuButton *pMenuButton, BOOL bScope, BOOL bSelect) | CDelegationBase | [inline, virtual]
SetScopeItemValue(LONG scopeitem) | CLandBasedVehicle | [inline, virtual]
CDelegationBase::SetScopeItemValue(HSCOPEITEM hscopeitem) | CDelegationBase | [inline, virtual]
Show(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) | CDelegationBase | [inline, virtual]
ShowContextHelp(IConsole *pConsole, IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile) | CDelegationBase | [inline, virtual]
TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2) | CDelegationBase | [inline, virtual]
thisGuid | CLandBasedVehicle | [private, static]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CDelegationBase() | CDelegationBase | [virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
~CLandBasedVehicle() | CLandBasedVehicle | [inline, virtual]
Generated on Wed Nov 13 2024 16:56:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/ADOVCGEN/stdafx.cpp Source File

  • Dataaccess
  • ADO
  • ADOVCGEN

stdafx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  ADVCGEN.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007
00008
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/people.h Source File

  • SysMgmt
  • MMC
  • Openserv

people.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _PEOPLE_H
00021 #define _PEOPLE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBicycle : public CDelegationBase {
00026 public:
00027     CBicycle(int i) : id(i) { }
00028     virtual ~CBicycle() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00033
00034 private:
00035     // {2974380D-4C4B-11d2-89D8-000021473128}
00036     static const GUID thisGuid;
00037
00038     int id;
00039 };
00040
00041 class CBicycleFolder : public CDelegationBase {
00042 public:
00043     CBicycleFolder();
00044     virtual ~CBicycleFolder();
00045
00046     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Bicycles"); }
00047     virtual const GUID & getNodeType() { return thisGuid; }
00048     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00049
00050 public:
00051     // virtual functions go here (for MMCN_*)
00052     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00053
00054 private:
00055     // {2974380D-4C4B-11d2-89D8-000021473128}
00056     static const GUID thisGuid;
00057
00058     enum { NUMBER_OF_CHILDREN = 20 };
00059     CDelegationBase *children[NUMBER_OF_CHILDREN];
00060 };
00061
00062 class CSkateboard : public CDelegationBase {
00063 public:
00064     CSkateboard(int i) : id(i) { }
00065     virtual ~CSkateboard() {}
00066
00067     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00068     virtual const GUID & getNodeType() { return thisGuid; }
00069     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00070
00071 private:
00072     // {2974380D-4C4B-11d2-89D8-000021473128}
00073     static const GUID thisGuid;
00074
00075     int id;
00076 };
00077
00078 class CSkateboardFolder : public CDelegationBase {
00079 public:
00080     CSkateboardFolder();
00081     virtual ~CSkateboardFolder();
00082
00083     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Skateboards"); }
00084     virtual const GUID & getNodeType() { return thisGuid; }
00085     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00086
00087 public:
00088     // virtual functions go here (for MMCN_*)
00089     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00090
00091 private:
00092     // {2974380D-4C4B-11d2-89D8-000021473128}
00093     static const GUID thisGuid;
00094
00095     enum { NUMBER_OF_CHILDREN = 20 };
00096     CDelegationBase *children[NUMBER_OF_CHILDREN];
00097 };
00098
00099 class CIceSkate : public CDelegationBase {
00100 public:
00101     CIceSkate(int i) : id(i) { }
00102     virtual ~CIceSkate() {}
00103
00104     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00105     virtual const GUID & getNodeType() { return thisGuid; }
00106     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00107
00108 private:
00109     // {2974380D-4C4B-11d2-89D8-000021473128}
00110     static const GUID thisGuid;
00111
00112     int id;
00113 };
00114
00115 class CIceSkateFolder : public CDelegationBase {
00116 public:
00117     CIceSkateFolder();
00118     virtual ~CIceSkateFolder();
00119
00120     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Ice Skates"); }
00121     virtual const GUID & getNodeType() { return thisGuid; }
00122     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00123
00124 public:
00125     // virtual functions go here (for MMCN_*)
00126     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00127
00128 private:
00129     // {2974380D-4C4B-11d2-89D8-000021473128}
00130     static const GUID thisGuid;
00131
00132     enum { NUMBER_OF_CHILDREN = 20 };
00133     CDelegationBase *children[NUMBER_OF_CHILDREN];
00134 };
00135
00136 class CPeoplePoweredVehicle : public CDelegationBase {
00137 public:
00138     CPeoplePoweredVehicle();
00139     virtual ~CPeoplePoweredVehicle();
00140
00141     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("People-powered Vehicles"); }
00142     virtual const GUID & getNodeType() { return thisGuid; }
00143     virtual const int GetBitmapIndex() { return INDEX_PEOPLEICON; }
00144
00145     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00146
00147 private:
00148     enum { IDM_NEW_PEOPLE = 1 };
00149
00150     // {2974380D-4C4B-11d2-89D8-000021473128}
00151     static const GUID thisGuid;
00152
00153     enum { NUMBER_OF_CHILDREN = 3 };
00154     CDelegationBase *children[3];
00155 };
00156
00157 #endif // _PEOPLE_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

vcacct::CAccount Member List

This is the complete list of members for vcacct::CAccount, including all inherited members.
clsid | vcacct::CAccount | [static]
iid | vcacct::CAccount | [static]
Post(int lAccount, int lAmount) | vcacct::CAccount |
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/TextWIN.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

TextWIN.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      TEXTWIN.CPP
00003
00004   Summary:   Implementation of the CTextWin C++ object that encapsulates
00005              the the text edit control window used to edit text pages.
00006
00007   Classes:   CTextWin.
00008
00009   Functions: none.
00010
00011   Origin:    5-24-97: atrent - Editor Inheritance from CMsgLog in
00012              APPUTIL.CPP.
00013
00014 ----------------------------------------------------------------------------
00015   This file is part of the Microsoft COM Tutorial Code Samples.
00016
00017   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00018
00019   This source code is intended only as a supplement to Microsoft
00020   Development Tools and/or on-line documentation.  See these other
00021   materials for detailed information regarding Microsoft code samples.
00022
00023   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00024   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00025   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00026   PARTICULAR PURPOSE.
00027 ==========================================================================+*/
00028
00029 /*---------------------------------------------------------------------------
00030   We include WINDOWS.H for all Win32 applications.
00031   We include TCHAR.H for general Unicode/Ansi prototype of utility
00032     functions like wvsprintf.
00033   We include APPUTIL.H because we will be building this application using
00034     the convenient Virtual Window and Dialog classes and other
00035     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00036   We include TEXTWIN.H for the defines and the CTextWin class
00037     declaration needed in TEXTWIN.
00038 ---------------------------------------------------------------------------*/
00039 #include <windows.h>
00040 #include <tchar.h>
00041 #include <apputil.h>
00042 #include "textwin.h"
00043
00044
00045 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00046   Method:   CTextWin::CTextWin
00047
00048   Summary:  CTextWin Constructor.
00049
00050   Args:     .
00051
00052   Returns:  .
00053 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00054 CTextWin::CTextWin()
00055 {
00056   m_hInst = NULL;
00057   m_hWnd = NULL;
00058   m_wWidth = 0;
00059   m_wHeight = 0;
00060 }
00061
00062
00063 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00064   Method:   CMainWindow::~CMainWindow
00065
00066   Summary:  CMainWindow Destructor.
00067
00068   Args:     .
00069
00070   Returns:  .
00071 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00072 CTextWin::~CTextWin()
00073 {
00074 }
00075
00076
00077 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00078   Method:   CTextWin::Init
00079
00080   Summary:  Initializes the Text Edit Control Window. Creates this window
00081             as a child window and fits it to fill the client area of the
00082             specified parent window.
00083
00084   Args:     HINSTANCE hInst,
00085               Instance handle of the application.
00086             HWND hWndparent,
00087               Window handle for the parent window of the listbox.
00088             HWND* phWndEdit)
00089               Address of variable that is assigned the window handle
00090               of the new text window (edit control window).
00091
00092   Returns:  HRESULT
00093               Standard result code. NOERROR for success.
00094 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00095 HRESULT CTextWin::Init(
00096           HINSTANCE hInst,
00097           HWND hWndParent,
00098           HWND* phWndEdit)
00099 {
00100   HRESULT hr = E_FAIL;
00101   BOOL bResult = FALSE;
00102   HWND hWnd;
00103   RECT rect;
00104   DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE
00105                   | ES_LEFT | ES_AUTOVSCROLL | ES_AUTOHSCROLL;
00106
00107   if (IsWindow(hWndParent))
00108   {
00109     GetClientRect(hWndParent, &rect);
00110
00111     // Create the edit control window.
00112     hWnd = ::CreateWindowEx(
00113                0,                // Extended Window Style
00114                TEXT("EDIT"),     // Class Name
00115                NULL,             // Window Title
00116                dwStyle,          // The window style
00117                0,                // (x,y)=Upper left of Parent window
00118                0,
00119                rect.right,       // Width; Fill Client Window
00120                rect.bottom,      // Height
00121                hWndParent,       // Parent Window Handle
00122                (HMENU) IDC_TEXTWIN, // No menu but rig ID for notifications.
00123                hInst,            // App Instance Handle
00124                NULL);            // Window Creation Data
00125     if (NULL != hWnd)
00126     {
00127       // Set keyboard focus to this TextWin edit control.
00128       SetFocus(hWnd);
00129       // Remember the instance of this application.
00130       m_hInst = hInst;
00131       // Remember the window handle of this edit window.
00132       m_hWnd = hWnd;
00133       // Assign the window handle to the caller's variable.
00134       if (NULL != phWndEdit)
00135         *phWndEdit = hWnd;
00136       // Return success.
00137       hr = NOERROR;
00138     }
00139   }
00140
00141   return (hr);
00142 }
00143
00144
00145 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00146   Method:   CTextWin::GetLength
00147
00148   Summary:  Gets the length of the text content in the edit control.
00149
00150   Args:     INT* piTextLength
00151               Address of INT variable that is assigned the length.
00152
00153   Returns:  HRESULT
00154               Standard result code. NOERROR for success.
00155 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00156 HRESULT CTextWin::GetLength(
00157           INT* piTextLength)
00158 {
00159   HRESULT hr = E_POINTER;
00160   INT iLen;
00161
00162   if (NULL != piTextLength)
00163   {
00164     // Set output in case of error.
00165     *piTextLength = 0;
00166
00167     hr = E_FAIL;
00168     if (IsWindow(m_hWnd))
00169     {
00170       iLen = (int)::SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0);
00171
00172       if (iLen >= 0)
00173       {
00174         // Assign caller's variable.
00175         *piTextLength = iLen;
00176         hr = NOERROR;
00177       }
00178     }
00179   }
00180
00181   return hr;
00182 }
00183
00184
00185 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00186   Method:   CTextWin::GetText
00187
00188   Summary:  Gets the text content of the edit control.
00189
00190   Args:     WCHAR* pwszText
00191               Address of output string buffer that is assigned the text.
00192
00193   Returns:  HRESULT
00194               Standard result code. NOERROR for success.
00195 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00196 HRESULT CTextWin::GetText(
00197           WCHAR* pwszText)
00198 {
00199   HRESULT hr = E_POINTER;
00200   INT iTextLength;
00201
00202   if (NULL != pwszText)
00203   {
00204     // Set output in case of error.
00205     pwszText[0] = 0;
00206
00207     if (IsWindow(m_hWnd))
00208     {
00209       hr = GetLength(&iTextLength);
00210       if (SUCCEEDED(hr) && iTextLength >= 0)
00211       {
00212 #if defined(UNICODE)
00213         ::SendMessage(
00214             m_hWnd,
00215             WM_GETTEXT,
00216             iTextLength+1,
00217             (LPARAM) pwszText);
00218 #else
00219         CHAR* pszText;
00220
00221         // Allocate some temporary space for the text.
00222         pszText = new CHAR[iTextLength+2];
00223         if (NULL != pszText)
00224         {
00225           // Get the text from the the edit control.
00226           ::SendMessage(
00227               m_hWnd,
00228               WM_GETTEXT,
00229               iTextLength+1,
00230               (LPARAM) pszText);
00231           AnsiToUc(pszText, pwszText, iTextLength+2);
00232           // Delete the temporary text buffer.
00233           delete [] pszText;
00234         }
00235         else
00236           hr = E_OUTOFMEMORY;
00237 #endif
00238       }
00239     }
00240   }
00241
00242   return hr;
00243 }
00244
00245
00246 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00247   Method:   CTextWin::PutText
00248
00249   Summary:  Puts text content into the edit control. Also
00250             sets keyboard focus to the TextWin edit control.
00251
00252   Args:     WCHAR* pwszText
00253               Pointer to Zero-terminated wide character string.
00254             INT iTextLength)
00255               The length of the text data in characters including the
00256               terminating 0.
00257
00258   Returns:  HRESULT
00259               Standard result code. NOERROR for success.
00260 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00261 HRESULT CTextWin::PutText(
00262           WCHAR* pwszText,
00263           INT iTextLength)
00264 {
00265   HRESULT hr = E_POINTER;
00266   LRESULT lr;
00267
00268   if (IsWindow(m_hWnd) && NULL != pwszText)
00269   {
00270 #if defined(UNICODE)
00271     // Send the text to the edit control.
00272     lr = ::SendMessage(
00273              m_hWnd,
00274              WM_SETTEXT,
00275              0,
00276              (LPARAM) pwszText);
00277     hr = lr ? NOERROR : E_FAIL;
00278 #else
00279     CHAR* pszText;
00280
00281     // Allocate some temporary space for the text.
00282     pszText = new CHAR[iTextLength+2];
00283     if (NULL != pszText)
00284     {
00285       UcToAnsi(pwszText, pszText, iTextLength+2);
00286       // Send the text to the edit control.
00287       lr = ::SendMessage(
00288                m_hWnd,
00289                WM_SETTEXT,
00290                0,
00291                (LPARAM) pszText);
00292       hr = lr ? NOERROR : E_FAIL;
00293       // Delete the temporary text buffer.
00294       delete [] pszText;
00295     }
00296     else
00297       hr = E_OUTOFMEMORY;
00298 #endif
00299   }
00300
00301   return hr;
00302 }
00303
00304
00305 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00306   Method:   CTextWin::Resize
00307
00308   Summary:  Resizes the edit control to a new width and height.  Called
00309             during the parent window's WM_SIZE to fit the control to the
00310             client area of the parent window.  It only honors this request
00311             if it is an integral child window.
00312
00313   Args:     INT nWidth
00314               New width in pixels of the edit control.
00315             INT nHeight
00316               New height in pixels of the edit control.
00317
00318   Returns:  HRESULT
00319               Standard result code. NOERROR for success.
00320 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00321 HRESULT CTextWin::Resize(
00322           INT nWidth,
00323           INT nHeight)
00324 {
00325   HRESULT hr = E_POINTER;
00326   BOOL bResult = FALSE;
00327
00328   if (IsWindow(m_hWnd))
00329   {
00330     bResult = ::MoveWindow(m_hWnd, 0, 0, nWidth, nHeight, TRUE);
00331
00332     hr = bResult ? NOERROR : E_FAIL;
00333   }
00334
00335   return hr;
00336 }
00337
00338
00339 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00340   Method:   CTextWin::Clear
00341
00342   Summary:  Clears/Deletes all text content in the edit control. The
00343             content is cut to the windows clipboard.
00344
00345   Args:     void
00346
00347   Returns:  HRESULT
00348               Standard result code. NOERROR for success.
00349 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00350 HRESULT CTextWin::Clear(
00351           void)
00352 {
00353   HRESULT hr;
00354
00355   hr = EditSelectAll();
00356   if (SUCCEEDED(hr))
00357     hr = EditDelete();
00358
00359   return hr;
00360 }
00361
00362
00363 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00364   Method:   CTextWin::EditUndo
00365
00366   Summary:  Tell text edit control to undo last operation.
00367
00368   Args:     void
00369
00370   Returns:  HRESULT
00371               Standard result code. NOERROR for success.
00372 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00373 HRESULT CTextWin::EditUndo(
00374           void)
00375 {
00376   HRESULT hr = E_FAIL;
00377
00378   if (IsWindow(m_hWnd))
00379   {
00380     ::SendMessage(m_hWnd, WM_UNDO, 0, 0);
00381     hr = NOERROR;
00382   }
00383
00384   return hr;
00385 }
00386
00387
00388 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00389   Method:   CTextWin::EditSelectAll
00390
00391   Summary:  Tell text edit control to select all text in it.
00392
00393   Args:     void
00394
00395   Returns:  HRESULT
00396               Standard result code. NOERROR for success.
00397 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00398 HRESULT CTextWin::EditSelectAll(
00399           void)
00400 {
00401   HRESULT hr = E_FAIL;
00402
00403   if (IsWindow(m_hWnd))
00404   {
00405     ::SendMessage(m_hWnd, EM_SETSEL, 0, -1);
00406     hr = NOERROR;
00407   }
00408
00409   return hr;
00410 }
00411
00412
00413 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00414   Method:   CTextWin::EditCut
00415
00416   Summary:  Tell edit control to cut currently selected text to the
00417             windows clipboard.
00418
00419   Args:     void
00420
00421   Returns:  HRESULT
00422               Standard result code. NOERROR for success.
00423 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00424 HRESULT CTextWin::EditCut(
00425           void)
00426 {
00427   HRESULT hr = E_FAIL;
00428
00429   if (IsWindow(m_hWnd))
00430   {
00431     ::SendMessage(m_hWnd, WM_CUT, 0, 0);
00432     hr = NOERROR;
00433   }
00434
00435   return hr;
00436 }
00437
00438
00439 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00440   Method:   CTextWin::EditCopy
00441
00442   Summary:  Tell edit control to copy currently selected text to the
00443             windows clipboard.
00444
00445   Args:     void
00446
00447   Returns:  HRESULT
00448               Standard result code. NOERROR for success.
00449 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00450 HRESULT CTextWin::EditCopy(
00451           void)
00452 {
00453   HRESULT hr = E_FAIL;
00454
00455   if (IsWindow(m_hWnd))
00456   {
00457     ::SendMessage(m_hWnd, WM_COPY, 0, 0);
00458     hr = NOERROR;
00459   }
00460
00461   return hr;
00462 }
00463
00464
00465 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00466   Method:   CTextWin::EditPaste
00467
00468   Summary:  Tell edit control to paste the content of the windows
00469             clipboard into the text edit control at the current
00470             caret location.
00471
00472   Args:     void
00473
00474   Returns:  HRESULT
00475               Standard result code. NOERROR for success.
00476 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00477 HRESULT CTextWin::EditPaste(
00478           void)
00479 {
00480   HRESULT hr = E_FAIL;
00481
00482   if (IsWindow(m_hWnd))
00483   {
00484     ::SendMessage(m_hWnd, WM_PASTE, 0, 0);
00485     hr = NOERROR;
00486   }
00487
00488   return hr;
00489 }
00490
00491
00492 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00493   Method:   CTextWin::EditDelete
00494
00495   Summary:  Tell the edit control to delete the currently selected text.
00496
00497   Args:     void
00498
00499   Returns:  HRESULT
00500               Standard result code. NOERROR for success.
00501 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00502 HRESULT CTextWin::EditDelete(
00503           void)
00504 {
00505   HRESULT hr = E_FAIL;
00506
00507   if (IsWindow(m_hWnd))
00508   {
00509     ::SendMessage(m_hWnd, WM_CLEAR, 0, 0);
00510     hr = NOERROR;
00511   }
00512
00513   return hr;
00514 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/omniprov/source/crow.h Source File

  • Dataaccess
  • oledb
  • omniprov
  • source

crow.h

Go to the documentation of this file.
00001 // File: CRow.h
00002 //
00003 //
00004 //  This file contains the definition for the CRow class
00005 //
00006 //  The CRow class does the following:
00007 //
00008 //
00009 //    - Contains the conversion functions for getting the
00010 //      data from the string of data for the row into each
00011 //      CColumn class
00012 //    - Contains the CColumn array which has an element
00013 //      for each column
00014 //      - Contains the HROW associate with that column
00015 //      - Contains bookmark information
00016 //      - Contains pointer to the starting location of the row
00017 //      in the file and ending offset
00018 //
00019
00020 #ifndef __CRow_H_
00021 #define __CRow_H_
00022
00023 #define MAX_COLUMNSIZE 255
00024 #define BAD_RECORD_FORMAT -1
00025
00026 struct ATLCOLUMNINFO;
00027
00028 class CRow
00029 {
00030 public:
00031   char * m_pbStartLoc;
00032   long m_bmk;
00033   int m_cbRowSize;
00034   BYTE * m_pbProxyData;
00035 //  BYTE * m_pbUpdateProxy;  // TODO: pending updates
00036   bool m_bRetrieved;
00037
00038   CRow()
00039   {
00040     m_pbStartLoc = NULL;
00041     m_bmk = 0;
00042     m_cbRowSize = 0;
00043     m_pbProxyData = NULL;
00044 //    m_pbUpdateProxy = NULL;
00045     m_bRetrieved = false;
00046   }
00047
00048 // Methods
00049   void AllocProxyBuffer(ATLCOLUMNINFO * prgColInfo, int cNumCols);
00050   void GetProxyData(ATLCOLUMNINFO * pColInfo, ULONG cCols);
00051   int FetchColumnString(char * pszColData, char * &pPos);
00052   void StoreInProxy(unsigned int iCol, char * szColumnString, ATLCOLUMNINFO * pColInfo);
00053   int  Update(ATLCOLUMNINFO * prgColInfo, ULONG cCols);
00054   int CalculateRowData(ATLCOLUMNINFO * prgColInfo, ULONG cNumCols, bool bAddEOL = false);
00055     int CreateDefaultRow(ATLCOLUMNINFO *prgColInfo, ULONG cNumCols, bool bAddEOL = false);
00056   int CalculateRowDataToDelete(ATLCOLUMNINFO * prgColInfo, ULONG cNumCols, bool bAddEOL=false);
00057   bool HasEOL(BYTE * pbEOF);
00058   void AddEOL();
00059   void AdjustStartLocationForEOL() { m_pbStartLoc +=2; }  // previous line had EOL added
00060                                                          // we need to move this rows starting
00061                                                          // location
00062 };
00063
00064 #endif __CROW_H_
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_WSAOVERLAPPEDPLUS Member List

This is the complete list of members for _WSAOVERLAPPEDPLUS, including all inherited members.
AcceptExArgs | _WSAOVERLAPPEDPLUS
CallerSocket | _WSAOVERLAPPEDPLUS
CallerThreadId | _WSAOVERLAPPEDPLUS
ConnectExArgs | _WSAOVERLAPPEDPLUS
DisconnectExArgs | _WSAOVERLAPPEDPLUS
Error | _WSAOVERLAPPEDPLUS
Iocp | _WSAOVERLAPPEDPLUS
IoctlArgs | _WSAOVERLAPPEDPLUS
lpCallerCompletionRoutine | _WSAOVERLAPPEDPLUS
lpCallerOverlapped | _WSAOVERLAPPEDPLUS
next | _WSAOVERLAPPEDPLUS
Operation | _WSAOVERLAPPEDPLUS
Provider | _WSAOVERLAPPEDPLUS
ProviderOverlapped | _WSAOVERLAPPEDPLUS
ProviderSocket | _WSAOVERLAPPEDPLUS
RecvArgs | _WSAOVERLAPPEDPLUS
RecvFromArgs | _WSAOVERLAPPEDPLUS
SendArgs | _WSAOVERLAPPEDPLUS
SendToArgs | _WSAOVERLAPPEDPLUS
SockInfo | _WSAOVERLAPPEDPLUS
TransmitFileArgs | _WSAOVERLAPPEDPLUS
TransmitPacketsArgs | _WSAOVERLAPPEDPLUS
WSARecvMsgArgs | _WSAOVERLAPPEDPLUS
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagPIDLDATA Member List

This is the complete list of members for tagPIDLDATA, including all inherited members.
fFolder | tagPIDLDATA
wszData | tagPIDLDATA
wszName | tagPIDLDATA
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSampleDirectoryInfo Member List

This is the complete list of members for CSampleDirectoryInfo, including all inherited members.
CSampleDirectory class | CSampleDirectoryInfo | [friend]
CSampleDirectoryInfo() | CSampleDirectoryInfo | [inline]
m_dwFlags | CSampleDirectoryInfo | [private]
m_pNext | CSampleDirectoryInfo | [private]
m_pszwName | CSampleDirectoryInfo | [private]
m_qwSize | CSampleDirectoryInfo | [private]
~CSampleDirectoryInfo() | CSampleDirectoryInfo | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/dataobj.h Source File

  • SysMgmt
  • MMC
  • Toolbar

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DragImg/Render.Cpp Source File

  • WinUI
  • Shell
  • DragImg

Render.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Render.cpp
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023 #include <shlobj.h>
00024 #include <strsafe.h>
00025 #define ARRAYSIZE(a)    (sizeof(a)/sizeof(a[0]))
00026 #include "Render.h"
00027
00028 /**************************************************************************
00029    local function prototypes
00030 **************************************************************************/
00031
00032 LPTSTR GetNextName(LPCTSTR);
00033
00034 /**************************************************************************
00035
00036    CreateFileGroupDescriptor()
00037
00038 **************************************************************************/
00039
00040 HGLOBAL CreateFileGroupDescriptor(LPCTSTR pszFiles)
00041 {
00042 HGLOBAL              hg;
00043 FILEGROUPDESCRIPTOR  *pfgd;
00044 LPTSTR               pszNext;
00045 DWORD                dwItems;
00046
00047 //get the number of items
00048 for(dwItems = 0, pszNext = (LPTSTR)pszFiles; pszNext; pszNext = GetNextName(pszNext))
00049    {
00050    dwItems++;
00051    }
00052
00053 hg = GlobalAlloc(GMEM_FIXED, sizeof(FILEGROUPDESCRIPTOR) + (dwItems - 1) * sizeof(FILEDESCRIPTOR));
00054 if(hg)
00055    {
00056    pfgd = (FILEGROUPDESCRIPTOR*)GlobalLock(hg);
00057    if(pfgd)
00058       {
00059       int   i;
00060
00061       pfgd->cItems = dwItems;
00062
00063       for(i = 0, pszNext = (LPTSTR)pszFiles; pszNext; pszNext = GetNextName(pszNext), i++)
00064          {
00065              pfgd->fgd[i].dwFlags = FD_ATTRIBUTES;
00066              pfgd->fgd[i].dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
00067              lstrcpyn(pfgd->fgd[i].cFileName, pszNext, ARRAYSIZE(pfgd->fgd[i].cFileName));
00068          }
00069
00070       GlobalUnlock(hg);
00071       }
00072    }
00073 return hg;
00074 }
00075
00076 /**************************************************************************
00077
00078    CreateFileContents()
00079
00080 **************************************************************************/
00081
00082 HGLOBAL CreateFileContents(LPCTSTR pszFiles, int nItem)
00083 {
00084 HGLOBAL  hg = NULL;
00085 TCHAR    szText[MAX_PATH];
00086 LPTSTR   pszNext;
00087 int      i, cch;
00088
00089 for(i = 0, pszNext = (LPTSTR)pszFiles; i < nItem; pszNext = GetNextName(pszNext), i++)
00090    {
00091    }
00092
00093 StringCchPrintf(szText, ARRAYSIZE(szText), TEXT("This file is %s created from CFSTR_FILECONTENTS"), pszNext);
00094 cch = lstrlen(szText) + 1;
00095 hg = GlobalAlloc(GMEM_FIXED, cch * sizeof(TCHAR));
00096
00097 if(hg)
00098    {
00099    LPTSTR psz = (LPSTR)GlobalLock(hg);
00100
00101    if(psz)
00102       {
00103       StringCchCopy(psz, cch, szText);
00104
00105       GlobalUnlock(hg);
00106       }
00107    }
00108
00109 return hg;
00110 }
00111
00112 /**************************************************************************
00113
00114    GetNextName()
00115
00116 **************************************************************************/
00117
00118 LPTSTR GetNextName(LPCTSTR pszFiles)
00119 {
00120 LPTSTR   pszTemp = (LPTSTR)pszFiles;
00121 while(*pszTemp)
00122    {
00123    pszTemp++;
00124    }
00125
00126 pszTemp++;
00127
00128 return *pszTemp ? pszTemp : NULL;
00129 }
00130
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/langbar.cpp Source File

  • WinUI
  • TSFmark

langbar.cpp

Go to the documentation of this file.
00001 //
00002 // langbar.cpp
00003 //
00004 // Language bar ui code.
00005 //
00006
00007 #include "globals.h"
00008 #include "mark.h"
00009 #include "resource.h"
00010
00011 #define MARK_LANGBARITEMSINK_COOKIE 0x0fab0fab
00012
00013 const struct
00014 {
00015     const WCHAR *pchDesc;
00016     void (*pfnHandler)(CMarkTextService *_this);
00017 }
00018 c_rgMenuItems[] =
00019 {
00020     { L"Start/End Composition", CMarkTextService::_Menu_OnComposition },
00021     { L"Set Global Compartment", CMarkTextService::_Menu_OnSetGlobalCompartment },
00022     { L"Set Case Property", CMarkTextService::_Menu_OnSetCaseProperty },
00023     { L"Set Custom Property", CMarkTextService::_Menu_OnSetCustomProperty },
00024     { L"View Case Property", CMarkTextService::_Menu_OnViewCaseProperty },
00025     { L"View Custom Property", CMarkTextService::_Menu_OnViewCustomProperty },
00026 };
00027
00028 class CLangBarItemButton : public ITfLangBarItemButton,
00029                            public ITfSource
00030 {
00031 public:
00032     CLangBarItemButton(CMarkTextService *pMark);
00033     ~CLangBarItemButton();
00034
00035     // IUnknown
00036     STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
00037     STDMETHODIMP_(ULONG) AddRef(void);
00038     STDMETHODIMP_(ULONG) Release(void);
00039
00040     // ITfLangBarItem
00041     STDMETHODIMP GetInfo(TF_LANGBARITEMINFO *pInfo);
00042     STDMETHODIMP GetStatus(DWORD *pdwStatus);
00043     STDMETHODIMP Show(BOOL fShow);
00044     STDMETHODIMP GetTooltipString(BSTR *pbstrToolTip);
00045
00046     // ITfLangBarItemButton
00047     STDMETHODIMP OnClick(TfLBIClick click, POINT pt, const RECT *prcArea);
00048     STDMETHODIMP InitMenu(ITfMenu *pMenu);
00049     STDMETHODIMP OnMenuSelect(UINT wID);
00050     STDMETHODIMP GetIcon(HICON *phIcon);
00051     STDMETHODIMP GetText(BSTR *pbstrText);
00052
00053     // ITfSource
00054     STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
00055     STDMETHODIMP UnadviseSink(DWORD dwCookie);
00056
00057 private:
00058     CMarkTextService *_pMark;
00059     ITfLangBarItemSink *_pLangBarItemSink;
00060     TF_LANGBARITEMINFO _tfLangBarItemInfo;
00061     LONG _cRef;
00062 };
00063
00064 //+---------------------------------------------------------------------------
00065 //
00066 // ctor
00067 //
00068 //----------------------------------------------------------------------------
00069
00070 CLangBarItemButton::CLangBarItemButton(CMarkTextService *pMark)
00071 {
00072     DllAddRef();
00073
00074     _tfLangBarItemInfo.clsidService = c_clsidMarkTextService;
00075     _tfLangBarItemInfo.guidItem = c_guidLangBarItemButton;
00076     _tfLangBarItemInfo.dwStyle = TF_LBI_STYLE_BTN_MENU;
00077     _tfLangBarItemInfo.ulSort = 0;
00078     SafeStringCopy(_tfLangBarItemInfo.szDescription, ARRAYSIZE(_tfLangBarItemInfo.szDescription), LANGBAR_ITEM_DESC);
00079
00080     _pMark = pMark;
00081     _pMark->AddRef();
00082     _pLangBarItemSink = NULL;
00083
00084     _cRef = 1;
00085 }
00086
00087 //+---------------------------------------------------------------------------
00088 //
00089 // dtor
00090 //
00091 //----------------------------------------------------------------------------
00092
00093 CLangBarItemButton::~CLangBarItemButton()
00094 {
00095     DllRelease();
00096     _pMark->Release();
00097 }
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 // QueryInterface
00102 //
00103 //----------------------------------------------------------------------------
00104
00105 STDAPI CLangBarItemButton::QueryInterface(REFIID riid, void **ppvObj)
00106 {
00107     if (ppvObj == NULL)
00108         return E_INVALIDARG;
00109
00110     *ppvObj = NULL;
00111
00112     if (IsEqualIID(riid, IID_IUnknown) ||
00113         IsEqualIID(riid, IID_ITfLangBarItem) ||
00114         IsEqualIID(riid, IID_ITfLangBarItemButton))
00115     {
00116         *ppvObj = (ITfLangBarItemButton *)this;
00117     }
00118     else if (IsEqualIID(riid, IID_ITfSource))
00119     {
00120         *ppvObj = (ITfSource *)this;
00121     }
00122
00123     if (*ppvObj)
00124     {
00125         AddRef();
00126         return S_OK;
00127     }
00128
00129     return E_NOINTERFACE;
00130 }
00131
00132
00133 //+---------------------------------------------------------------------------
00134 //
00135 // AddRef
00136 //
00137 //----------------------------------------------------------------------------
00138
00139 STDAPI_(ULONG) CLangBarItemButton::AddRef()
00140 {
00141     return ++_cRef;
00142 }
00143
00144 //+---------------------------------------------------------------------------
00145 //
00146 // Release
00147 //
00148 //----------------------------------------------------------------------------
00149
00150 STDAPI_(ULONG) CLangBarItemButton::Release()
00151 {
00152     LONG cr = --_cRef;
00153
00154     assert(_cRef >= 0);
00155
00156     if (_cRef == 0)
00157     {
00158         delete this;
00159     }
00160
00161     return cr;
00162 }
00163
00164 //+---------------------------------------------------------------------------
00165 //
00166 // GetInfo
00167 //
00168 //----------------------------------------------------------------------------
00169
00170 STDAPI CLangBarItemButton::GetInfo(TF_LANGBARITEMINFO *pInfo)
00171 {
00172     *pInfo = _tfLangBarItemInfo;
00173     return S_OK;
00174 }
00175
00176 //+---------------------------------------------------------------------------
00177 //
00178 // GetStatus
00179 //
00180 //----------------------------------------------------------------------------
00181
00182 STDAPI CLangBarItemButton::GetStatus(DWORD *pdwStatus)
00183 {
00184     *pdwStatus = 0;
00185     return S_OK;
00186 }
00187
00188 //+---------------------------------------------------------------------------
00189 //
00190 // Show
00191 //
00192 //----------------------------------------------------------------------------
00193
00194 STDAPI CLangBarItemButton::Show(BOOL fShow)
00195 {
00196     return E_NOTIMPL;
00197 }
00198
00199 //+---------------------------------------------------------------------------
00200 //
00201 // GetTooltipString
00202 //
00203 //----------------------------------------------------------------------------
00204
00205 STDAPI CLangBarItemButton::GetTooltipString(BSTR *pbstrToolTip)
00206 {
00207     *pbstrToolTip = SysAllocString(LANGBAR_ITEM_DESC);
00208
00209     return (*pbstrToolTip == NULL) ? E_OUTOFMEMORY : S_OK;
00210 }
00211
00212 //+---------------------------------------------------------------------------
00213 //
00214 // OnClick
00215 //
00216 //----------------------------------------------------------------------------
00217
00218 STDAPI CLangBarItemButton::OnClick(TfLBIClick click, POINT pt, const RECT *prcArea)
00219 {
00220     return S_OK;
00221 }
00222
00223 //+---------------------------------------------------------------------------
00224 //
00225 // InitMenu
00226 //
00227 //----------------------------------------------------------------------------
00228
00229 STDAPI CLangBarItemButton::InitMenu(ITfMenu *pMenu)
00230 {
00231     int i;
00232
00233     for (i=0; i<ARRAYSIZE(c_rgMenuItems); i++)
00234     {
00235         pMenu->AddMenuItem(i, 0, NULL, NULL, c_rgMenuItems[i].pchDesc, (ULONG)wcslen(c_rgMenuItems[i].pchDesc), NULL);
00236     }
00237
00238     return S_OK;
00239 }
00240
00241 //+---------------------------------------------------------------------------
00242 //
00243 // OnMenuSelect
00244 //
00245 //----------------------------------------------------------------------------
00246
00247 STDAPI CLangBarItemButton::OnMenuSelect(UINT wID)
00248 {
00249     c_rgMenuItems[wID].pfnHandler(_pMark);
00250     return S_OK;
00251 }
00252
00253 //+---------------------------------------------------------------------------
00254 //
00255 // GetIcon
00256 //
00257 //----------------------------------------------------------------------------
00258
00259 STDAPI CLangBarItemButton::GetIcon(HICON *phIcon)
00260 {
00261     *phIcon = (HICON)LoadImage(g_hInst, TEXT("IDI_MARK"), IMAGE_ICON, 16, 16, 0);
00262
00263     return (*phIcon != NULL) ? S_OK : E_FAIL;
00264 }
00265
00266 //+---------------------------------------------------------------------------
00267 //
00268 // GetText
00269 //
00270 //----------------------------------------------------------------------------
00271
00272 STDAPI CLangBarItemButton::GetText(BSTR *pbstrText)
00273 {
00274     *pbstrText = SysAllocString(LANGBAR_ITEM_DESC);
00275
00276     return (*pbstrText == NULL) ? E_OUTOFMEMORY : S_OK;
00277 }
00278
00279 //+---------------------------------------------------------------------------
00280 //
00281 // AdviseSink
00282 //
00283 //----------------------------------------------------------------------------
00284
00285 STDAPI CLangBarItemButton::AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie)
00286 {
00287     if (!IsEqualIID(IID_ITfLangBarItemSink, riid))
00288         return CONNECT_E_CANNOTCONNECT;
00289
00290     if (_pLangBarItemSink != NULL)
00291         return CONNECT_E_ADVISELIMIT;
00292
00293     if (punk->QueryInterface(IID_ITfLangBarItemSink, (void **)&_pLangBarItemSink) != S_OK)
00294     {
00295         _pLangBarItemSink = NULL;
00296         return E_NOINTERFACE;
00297     }
00298
00299     *pdwCookie = MARK_LANGBARITEMSINK_COOKIE;
00300     return S_OK;
00301 }
00302
00303 //+---------------------------------------------------------------------------
00304 //
00305 // UnadviseSink
00306 //
00307 //----------------------------------------------------------------------------
00308
00309 STDAPI CLangBarItemButton::UnadviseSink(DWORD dwCookie)
00310 {
00311     if (dwCookie != MARK_LANGBARITEMSINK_COOKIE)
00312         return CONNECT_E_NOCONNECTION;
00313
00314     if (_pLangBarItemSink == NULL)
00315         return CONNECT_E_NOCONNECTION;
00316
00317     _pLangBarItemSink->Release();
00318     _pLangBarItemSink = NULL;
00319
00320     return S_OK;
00321 }
00322
00323 //+---------------------------------------------------------------------------
00324 //
00325 // _InitLanguageBar
00326 //
00327 //----------------------------------------------------------------------------
00328
00329 BOOL CMarkTextService::_InitLanguageBar()
00330 {
00331     ITfLangBarItemMgr *pLangBarItemMgr;
00332     BOOL fRet;
00333
00334     if (_pThreadMgr->QueryInterface(IID_ITfLangBarItemMgr, (void **)&pLangBarItemMgr) != S_OK)
00335         return FALSE;
00336
00337     fRet = FALSE;
00338
00339     if ((_pLangBarItem = new CLangBarItemButton(this)) == NULL)
00340         goto Exit;
00341
00342     if (pLangBarItemMgr->AddItem(_pLangBarItem) != S_OK)
00343     {
00344         _pLangBarItem->Release();
00345         _pLangBarItem = NULL;
00346         goto Exit;
00347     }
00348
00349     fRet = TRUE;
00350
00351 Exit:
00352     pLangBarItemMgr->Release();
00353     return fRet;
00354 }
00355
00356 //+---------------------------------------------------------------------------
00357 //
00358 // _UninitLanguageBar
00359 //
00360 //----------------------------------------------------------------------------
00361
00362 void CMarkTextService::_UninitLanguageBar()
00363 {
00364     ITfLangBarItemMgr *pLangBarItemMgr;
00365
00366     if (_pLangBarItem == NULL)
00367         return;
00368
00369     if (_pThreadMgr->QueryInterface(IID_ITfLangBarItemMgr, (void **)&pLangBarItemMgr) == S_OK)
00370     {
00371         pLangBarItemMgr->RemoveItem(_pLangBarItem);
00372         pLangBarItemMgr->Release();
00373     }
00374
00375     _pLangBarItem->Release();
00376     _pLangBarItem = NULL;
00377 }
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

PROFILE_STRUCT Member List

This is the complete list of members for PROFILE_STRUCT, including all inherited members.
DebugErrorLevel | PROFILE_STRUCT
DebuggeePriority | PROFILE_STRUCT
DebugMode | PROFILE_STRUCT
fClearOnNew | PROFILE_STRUCT
fMaximized | PROFILE_STRUCT
fMinimized | PROFILE_STRUCT
fSavedDirectory | PROFILE_STRUCT
fSaveOnExit | PROFILE_STRUCT
fSavePreferences | PROFILE_STRUCT
fShowSymbols | PROFILE_STRUCT
fToolBar | PROFILE_STRUCT
fVerbose | PROFILE_STRUCT
LogFont | PROFILE_STRUCT
nHeight | PROFILE_STRUCT
nWidth | PROFILE_STRUCT
rgbBackColor | PROFILE_STRUCT
rgbForeColor | PROFILE_STRUCT
szInitialDir | PROFILE_STRUCT
xPos | PROFILE_STRUCT
yPos | PROFILE_STRUCT
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/Msi/create.dll/Create.Cpp Source File

  • SysMgmt
  • Msi
  • create.dll

Create.Cpp

Go to the documentation of this file.
00001 #if 0  // makefile definitions
00002 DESCRIPTION = CreateUserAccount on Local Machine
00003 MODULENAME = create
00004 FILEVERSION = Msi
00005 ENTRY = CreateUserAccount
00006 UNICODE=1
00007 LINKLIBS = netapi32.lib
00008 !include "..\TOOLS\MsiTool.mak"
00009 !if 0  #nmake skips the rest of this file
00010 #endif // end of makefile definitions
00011
00012 // Required headers
00013 #define WINDOWS_LEAN_AND_MEAN  // faster compile
00014 #include <windows.h>
00015 #ifndef RC_INVOKED    // start of source code
00016
00017 #include "msiquery.h"
00018 #include "msidefs.h"
00019 #include <windows.h>
00020 #include <basetsd.h>
00021 #include <stdlib.h>
00022 #include <lm.h>
00023
00024 #define UNICODE 1
00025
00026 //+-------------------------------------------------------------------------
00027 //
00028 //  Microsoft Windows
00029 //
00030 //  Copyright (C) Microsoft Corporation, all rights reserved
00031 //
00032 //  File:       create.cpp
00033 //
00034 //  Notes: DLL custom action sample , must be used in conjunction with the DLL
00035 //         custom actions included in process.cpp and remove.cpp
00036 //--------------------------------------------------------------------------
00037
00038 //-----------------------------------------------------------------------------------------
00039 //
00040 // BUILD Instructions
00041 //
00042 // notes:
00043 //  - SDK represents the full path to the install location of the
00044 //     Windows Installer SDK
00045 //
00046 // Using NMake:
00047 //      %vcbin%\nmake -f create.cpp include="%include;SDK\Include" lib="%lib%;SDK\Lib"
00048 //
00049 // Using MsDev:
00050 //      1. Create a new Win32 DLL project
00051 //      2. Add create.cpp to the project
00052 //      3. Add SDK\Include and SDK\Lib directories on the Tools\Options Directories tab
00053 //      4. Add msi.lib and netapi32.lib to the library list in the Project Settings dialog
00054 //          (in addition to the standard libs included by MsDev)
00055 //      5. Add /DUNICODE to the project options in the Project Settings dialog
00056 //
00057 //------------------------------------------------------------------------------------------
00058
00059 /////////////////////////////////////////////////////////////////////////////
00060 // ClearSecret
00061 //
00062 //     Zeroes the secret data in the wszSecret buffer.  This is to reduce
00063 //     the amount of time the secret data is kept in clear text in memory.
00064 //
00065 void ClearSecret(WCHAR* wszSecret, DWORD cbSecret)
00066 {
00067   if (!wszSecret)
00068     return; // nothing to do
00069
00070   volatile char* vpch = (volatile char*)wszSecret;
00071   while (cbSecret)
00072   {
00073     *vpch = 0;
00074     vpch++;
00075     cbSecret--;
00076   }
00077 }
00078
00079 /////////////////////////////////////////////////////////////////////////////
00080 // CreateUserAccount
00081 //
00082 //     Attempts to create a user account on the local machine according
00083 //       to the "instructions" provided in the CustomActionData property
00084 //
00085 //     As a deferred custom action, you do not have access to the database.
00086 //       The only source of infromation comes from a property that another
00087 //       custom action can set to provide the information you need.  This
00088 //       property is written into the script
00089 //
00090 UINT __stdcall CreateUserAccount(MSIHANDLE hInstall)
00091 {
00092   const WCHAR* wszSep = L"\001";
00093   const int iCreationError = 25001;
00094   const int iCreationDuplicate = 25002;
00095
00096   // Grab the CustomActionData property
00097   WCHAR* wszCAData = 0;
00098   DWORD cchCAData = 0;
00099
00100   if (ERROR_MORE_DATA != MsiGetPropertyW(hInstall, IPROPNAME_CUSTOMACTIONDATA, L"", &cchCAData))
00101     return ERROR_INSTALL_FAILURE;
00102
00103   wszCAData = new WCHAR[++cchCAData];
00104   if ( !wszCAData )
00105     return ERROR_INSTALL_FAILURE; // out of memory
00106
00107   wszCAData[0] = 0;
00108
00109   if (ERROR_SUCCESS != MsiGetPropertyW(hInstall, IPROPNAME_CUSTOMACTIONDATA, wszCAData, &cchCAData))
00110   {
00111     delete [] wszCAData;
00112     return ERROR_INSTALL_FAILURE; // error -- should never happen
00113   }
00114
00115   USER_INFO_1 ui;
00116   ZeroMemory(&ui, sizeof(USER_INFO_1));
00117
00118   DWORD dwLevel = 1; // represents USER_INFO_1 struct
00119   NET_API_STATUS nStatus = NERR_Success;
00120
00121   //
00122   // Parse CustomActionDataProperty
00123   //
00124   WCHAR* wszUserName = wcstok(wszCAData, wszSep);
00125   if ( !wszUserName )
00126   {
00127     ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00128     delete [] wszCAData;
00129     return ERROR_INSTALL_FAILURE;
00130   }
00131   WCHAR* wszPassWd   = wcstok(NULL, wszSep);
00132   if ( !wszPassWd )
00133   {
00134     ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00135     delete [] wszCAData;
00136     return ERROR_INSTALL_FAILURE;
00137   }
00138   WCHAR* pwch = wcstok(NULL, wszSep);
00139   if ( !pwch )
00140   {
00141     ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00142     delete [] wszCAData;
00143     return ERROR_INSTALL_FAILURE; // error -- should never happen
00144   }
00145
00146   int iUserFlags = wcstol(pwch, 0, 10);
00147
00148   //
00149   // Set up the USER_INFO_1 structure.
00150   //  USER_PRIV_USER: name identifies a user,
00151   //    rather than an administrator or a guest.
00152   //  UF_SCRIPT: required for LAN Manager 2.0 and
00153   //    Windows NT/Windows 2000.
00154   //
00155   ui.usri1_name = wszUserName;
00156   ui.usri1_password = wszPassWd;
00157   ui.usri1_priv = USER_PRIV_USER;
00158   ui.usri1_flags = UF_SCRIPT | iUserFlags;
00159   ui.usri1_home_dir = NULL;
00160   ui.usri1_comment = NULL;
00161   ui.usri1_script_path = NULL;
00162
00163   // Send ActionData message (template in ActionText table)
00164   PMSIHANDLE hRec = MsiCreateRecord(1);
00165   if ( !hRec || ERROR_SUCCESS != MsiRecordSetStringW(hRec, 1, wszUserName))
00166   {
00167     ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00168     delete [] wszCAData;
00169     return ERROR_INSTALL_FAILURE;
00170   }
00171
00172   int iRet = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRec);
00173   if (IDCANCEL == iRet || IDABORT == iRet)
00174   {
00175     ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00176     delete [] wszCAData;
00177     return ERROR_INSTALL_USEREXIT;
00178   }
00179
00180
00181   //
00182   // Call the NetUserAdd function, specifying level 1.
00183   //
00184   nStatus = NetUserAdd(NULL /*local machine*/, dwLevel, (LPBYTE)&ui, NULL);
00185
00186   if (nStatus != NERR_Success)
00187   {
00188     PMSIHANDLE hRecErr = MsiCreateRecord(3);
00189     if ( !hRecErr
00190       || ERROR_SUCCESS != MsiRecordSetInteger(hRecErr, 1, (nStatus == NERR_UserExists) ? iCreationDuplicate : iCreationError)
00191       || ERROR_SUCCESS != MsiRecordSetStringW(hRecErr, 2, wszUserName)
00192       || ERROR_SUCCESS != MsiRecordSetInteger(hRecErr, 3, nStatus))
00193     {
00194       ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00195       delete [] wszCAData;
00196       return ERROR_INSTALL_FAILURE;
00197     }
00198
00199     // ignore MsiProcessMessage return below because we are aborting the install
00200     MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecErr);
00201
00202     ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00203     delete [] wszCAData;
00204     return ERROR_INSTALL_FAILURE; // error
00205   }
00206
00207   ClearSecret(wszCAData, cchCAData*sizeof(WCHAR));
00208   delete [] wszCAData;
00209   return ERROR_SUCCESS;
00210 }
00211
00212 #else // RC_INVOKED, end of source code, start of resources
00213 // resource definition go here
00214
00215 #endif // RC_INVOKED
00216 #if 0
00217 !endif // makefile terminator
00218 #endif
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTerminateCompositionEditSession Member List

This is the complete list of members for CTerminateCompositionEditSession, including all inherited members.
_pContext | CEditSessionBase | [protected]
_pMark | CTerminateCompositionEditSession | [private]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CEditSessionBase(ITfContext *pContext) | CEditSessionBase | [inline]
CTerminateCompositionEditSession(CMarkTextService *pMark, ITfContext *pContext) | CTerminateCompositionEditSession | [inline]
DoEditSession(TfEditCookie ec) | CTerminateCompositionEditSession | [inline, virtual]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
QueryInterface(REFIID riid, void **ppvObj) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) AddRef(void) | CEditSessionBase | [inline]
STDMETHODIMP_(ULONG) Release(void) | CEditSessionBase | [inline]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
~CEditSessionBase() | CEditSessionBase | [inline, virtual]
~CTerminateCompositionEditSession() | CTerminateCompositionEditSession | [inline]
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/LSAPolicy/MachAcct/MachAcct.c Source File

  • Security
  • LSAPolicy
  • MachAcct

MachAcct.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011     machacct.c
00012
00013 Abstract:
00014
00015     The following sample illustrates how to create a machine account on the
00016     specified domain.
00017
00018     Machine account types are defined by the following flags:
00019
00020     UF_SERVER_TRUST_ACCOUNT (Backup domain controller)
00021     UF_WORKSTATION_TRUST_ACCOUNT (Workstation and server)
00022     UF_INTERDOMAIN_TRUST_ACCOUNT (Interdomain trust account)
00023
00024     This sample attempts to create a workstation machine account, of type
00025     UF_WORKSTATION_TRUST_ACCOUNT.  This account type used for workstations
00026     and non-DC servers which are domain members.
00027
00028     If the computer account creation fails with GetLastError ==
00029     ERROR_ACCESS_DENIED, the sample attempts to enable the
00030     SeMachineAccountPrivilege for the caller. If the privilege is enabled
00031     successfully, the computer account add operation is re-tried.
00032
00033     Deleting machine accounts can be accomplished using the NetUserDel()
00034     Windows NT Lan Manager API call.
00035
00036     Account update operations against a domain must be performed against
00037     the primary domain controller for the specified domain.  This sample
00038     uses the NetGetDCName Windows NT Lan Manager API call to determine
00039     the computer name of the primary domain controller.
00040
00041     Commandline parameter argv[1] indicates the name of the account to
00042     create, which is typically the name of the machine.
00043
00044     Commandline parameter argv[2] is optional and indicates the target domain.
00045     If this commandline argument is omitted, the machine account is created
00046     on the local domain.  It is recommended that you always supply a domain
00047     name in this sample, as this insures that the update occurs at the primary
00048     domain controller.
00049
00050     The following commandline creates a machine account named WINBASE in
00051     the domain named CORP
00052
00053     machacct.exe WINBASE CORP
00054 --*/
00055
00056 #include <windows.h>
00057 #include <stdio.h>
00058 #include <lm.h>
00059
00060 BOOL
00061 AddMachineAccount(
00062     LPWSTR wTargetComputer, // specifies where to add account
00063     LPWSTR MachineAccount,  // name of account
00064     DWORD AccountType       // account type
00065     );
00066
00067 BOOL
00068 SetCurrentPrivilege(
00069     LPCTSTR Privilege,      // Privilege to enable/disable
00070     BOOL bEnablePrivilege,  // to enable or disable privilege
00071     BOOL * bPreviousPrivilege // returns previous state of the privilege
00072     );
00073
00074 void
00075 DisplayError(
00076     LPSTR szAPI,    // pointer to failed API name
00077     DWORD dwLastError
00078     );
00079
00080 #define RTN_OK 0
00081 #define RTN_USAGE 1
00082 #define RTN_ERROR 13
00083
00084 //
00085 // Unicode entry point and argv
00086 //
00087
00088 int
00089 __cdecl
00090 wmain(
00091     int argc,
00092     wchar_t *argv[]
00093     )
00094 {
00095     LPWSTR wMachineAccount;
00096     LPWSTR wPrimaryDC;
00097     LPTSTR MachineAccountPrivilege = SE_MACHINE_ACCOUNT_NAME;
00098     DWORD dwTrustAccountType = UF_WORKSTATION_TRUST_ACCOUNT;
00099     NET_API_STATUS nas;
00100     BOOL bSuccess;
00101
00102     if(argc < 2) {
00103         fprintf(stderr, "Usage: %ls <machineaccountname> [domain]\n",
00104             argv[0]);
00105         return RTN_USAGE;
00106     }
00107
00108     wMachineAccount = argv[1];
00109
00110     //
00111     // if a domain name was specified, fetch the computer name of the
00112     // primary domain controller
00113     //
00114     if(argc == 3) {
00115
00116         nas = NetGetDCName(NULL, argv[2], (LPBYTE *)&wPrimaryDC);
00117
00118         if(nas != NERR_Success) {
00119             DisplayError("NetGetDCName", nas);
00120             return RTN_ERROR;
00121         }
00122     } else {
00123         //
00124         // default will operate on local machine.  Non-NULL wPrimaryDC will
00125         // cause buffer to be freed
00126         //
00127         wPrimaryDC = NULL;
00128     }
00129
00130     bSuccess = AddMachineAccount(
00131         wPrimaryDC,         // primary DC computer name
00132         wMachineAccount,    // computer account name
00133         dwTrustAccountType  // computer account type
00134         );
00135
00136     if(!bSuccess && GetLastError() == ERROR_ACCESS_DENIED ) {
00137
00138         BOOL Previous;
00139
00140         //
00141         // try to enable the SeMachineAccountPrivilege
00142         //
00143         if(SetCurrentPrivilege( MachineAccountPrivilege, TRUE, &Previous )) {
00144
00145             //
00146             // enabled the privilege.  retry the add operation
00147             //
00148             bSuccess = AddMachineAccount(
00149                 wPrimaryDC,
00150                 wMachineAccount,
00151                 dwTrustAccountType
00152                 );
00153
00154             //
00155             // disable the privilege
00156             //
00157             SetCurrentPrivilege( MachineAccountPrivilege, Previous, NULL );
00158         }
00159     }
00160
00161     //
00162     // free the buffer allocated for the PDC computer name
00163     //
00164     if(wPrimaryDC) NetApiBufferFree(wPrimaryDC);
00165
00166     if(!bSuccess) {
00167         DisplayError("AddMachineAccount", GetLastError());
00168         return RTN_ERROR;
00169     }
00170
00171     return RTN_OK;
00172 }
00173
00174 BOOL
00175 AddMachineAccount(
00176     LPWSTR wTargetComputer,
00177     LPWSTR MachineAccount,
00178     DWORD AccountType
00179     )
00180 {
00181     WCHAR wAccount[MAX_COMPUTERNAME_LENGTH + 2];
00182     LPWSTR wPassword;
00183     USER_INFO_1 ui;
00184     DWORD cchAccount;
00185     DWORD cchLength;
00186     NET_API_STATUS nas;
00187
00188     //
00189     // ensure a valid computer account type was passed
00190     // TODO SetLastError
00191     //
00192     if (AccountType != UF_WORKSTATION_TRUST_ACCOUNT &&
00193         AccountType != UF_SERVER_TRUST_ACCOUNT &&
00194         AccountType != UF_INTERDOMAIN_TRUST_ACCOUNT
00195         ) {
00196         SetLastError(ERROR_INVALID_PARAMETER);
00197         return FALSE;
00198     }
00199
00200     //
00201     // obtain number of chars in computer account name
00202     //
00203     cchLength = cchAccount = lstrlenW(MachineAccount);
00204
00205     //
00206     // ensure computer name doesn't exceed maximum length
00207     //
00208     if(cchLength > MAX_COMPUTERNAME_LENGTH) {
00209         SetLastError(ERROR_INVALID_ACCOUNT_NAME);
00210         return FALSE;
00211     }
00212
00213     //
00214     // password is the computer account name converted to lowercase
00215     // convert the passed MachineAccount in place
00216     //
00217     wPassword = MachineAccount;
00218
00219     //
00220     // copy MachineAccount to the wAccount buffer allocated while
00221     // converting computer account name to uppercase.
00222     // convert password (inplace) to lowercase
00223     //
00224     while(cchAccount--) {
00225         wAccount[cchAccount] = towupper( MachineAccount[cchAccount] );
00226         wPassword[cchAccount] = towlower( wPassword[cchAccount] );
00227     }
00228
00229     //
00230     // computer account names have a trailing Unicode '$'
00231     //
00232     wAccount[cchLength] = L'$';
00233     wAccount[cchLength + 1] = L'\0'; // terminate the string
00234
00235     //
00236     // if the password is greater than the max allowed, truncate
00237     //
00238     if(cchLength > LM20_PWLEN) wPassword[LM20_PWLEN] = L'\0';
00239
00240     //
00241     // initialize USER_INFO_x structure
00242     //
00243     ZeroMemory(&ui, sizeof(ui));
00244
00245     ui.usri1_name = wAccount;
00246     ui.usri1_password = wPassword;
00247
00248     ui.usri1_flags = AccountType | UF_SCRIPT;
00249     ui.usri1_priv = USER_PRIV_USER;
00250
00251     nas = NetUserAdd(
00252                 wTargetComputer,    // target computer name
00253                 1,                  // info level
00254                 (LPBYTE) &ui,       // buffer
00255                 NULL
00256                 );
00257
00258     //
00259     // indicate whether it was successful
00260     //
00261     if(nas == NERR_Success) {
00262         return TRUE;
00263     }
00264     else {
00265         SetLastError(nas);
00266         return FALSE;
00267     }
00268 }
00269
00270 DWORD
00271 SetCurrentPrivilege(
00272     LPCTSTR Privilege,      // Privilege to enable/disable
00273     BOOL bEnablePrivilege,  // to enable or disable privilege
00274     BOOL * bPreviousPrivilege // returns previous state of the privilege
00275     )
00276 {
00277     DWORD dwError;
00278     HANDLE hToken;
00279     TOKEN_PRIVILEGES tp;
00280     LUID luid;
00281     TOKEN_PRIVILEGES tpPrevious;
00282     DWORD cbPrevious=sizeof(TOKEN_PRIVILEGES);
00283     BOOL bSuccess=FALSE;
00284
00285     if(!LookupPrivilegeValue(NULL, Privilege, &luid)) return ERROR_NO_SUCH_PRIVILEGE;
00286
00287     if(!OpenProcessToken(
00288             GetCurrentProcess(),
00289             TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES,
00290             &hToken
00291             )) return GetLastError();
00292
00293     //
00294     // first pass.  get current privilege setting
00295     //
00296     tp.PrivilegeCount           = 1;
00297     tp.Privileges[0].Luid       = luid;
00298     tp.Privileges[0].Attributes = 0;
00299
00300     AdjustTokenPrivileges(
00301             hToken,
00302             FALSE,
00303             &tp,
00304             sizeof(TOKEN_PRIVILEGES),
00305             &tpPrevious,
00306             &cbPrevious
00307             );
00308
00309     if(( dwError = GetLastError()) == ERROR_SUCCESS) {
00310         //
00311         // second pass.  set privilege based on previous setting
00312         //
00313         tpPrevious.PrivilegeCount     = 1;
00314         tpPrevious.Privileges[0].Luid = luid;
00315
00316         if ( bPreviousPrivilege ) {
00317
00318             *bPreviousPrivilege = (( tpPrevious.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED ) != 0 );
00319         }
00320
00321         if(bEnablePrivilege) {
00322             tpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED);
00323         }
00324         else {
00325             tpPrevious.Privileges[0].Attributes &= ~(SE_PRIVILEGE_ENABLED);
00326         }
00327
00328         AdjustTokenPrivileges(
00329                 hToken,
00330                 FALSE,
00331                 &tpPrevious,
00332                 cbPrevious,
00333                 NULL,
00334                 NULL
00335                 );
00336
00337         dwError = GetLastError();
00338     }
00339
00340     CloseHandle(hToken);
00341
00342     return dwError;
00343 }
00344
00345 void
00346 DisplayError(
00347     LPSTR szAPI,    // pointer to failed API name
00348     DWORD dwLastError
00349     )
00350 {
00351     HMODULE hModule = NULL;
00352     LPSTR MessageBuffer;
00353     DWORD dwBufferLength;
00354
00355     fprintf(stderr,"%s error! (rc=%lu)\n", szAPI, dwLastError);
00356
00357     if(dwLastError >= NERR_BASE && dwLastError <= MAX_NERR) {
00358         hModule = LoadLibraryEx(
00359             TEXT("netmsg.dll"),
00360             NULL,
00361             LOAD_LIBRARY_AS_DATAFILE
00362             );
00363     }
00364
00365     if(dwBufferLength=FormatMessageA(
00366         FORMAT_MESSAGE_ALLOCATE_BUFFER |
00367         FORMAT_MESSAGE_IGNORE_INSERTS |
00368         FORMAT_MESSAGE_FROM_SYSTEM |
00369         ((hModule != NULL) ? FORMAT_MESSAGE_FROM_HMODULE : 0),
00370         hModule, // module to get message from
00371         dwLastError,
00372         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
00373         (LPSTR) &MessageBuffer,
00374         0,
00375         NULL
00376         ))
00377     {
00378         DWORD dwBytesWritten;
00379
00380         //
00381         // Output message string on stderr
00382         //
00383         WriteFile(
00384             GetStdHandle(STD_ERROR_HANDLE),
00385             MessageBuffer,
00386             dwBufferLength,
00387             &dwBytesWritten,
00388             NULL
00389             );
00390
00391         //
00392         // free the buffer allocated by the system
00393         //
00394         LocalFree(MessageBuffer);
00395     }
00396
00397     if(hModule != NULL)
00398         FreeLibrary(hModule);
00399 }
00400
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/Resource.h Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by PoolTest.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_PoolTest                    100
00007 #define IDD_TESTDLG                     101
00008 #define IDC_NUMBERWRITES                201
00009
00010 // Next default values for new objects
00011 //
00012 #ifdef APSTUDIO_INVOKED
00013 #ifndef APSTUDIO_READONLY_SYMBOLS
00014 #define _APS_NEXT_RESOURCE_VALUE        201
00015 #define _APS_NEXT_COMMAND_VALUE         32768
00016 #define _APS_NEXT_CONTROL_VALUE         202
00017 #define _APS_NEXT_SYMED_VALUE           102
00018 #endif
00019 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/SimpCntr.h Source File

  • Com
  • Fundamentals
  • SimpCntr

SimpCntr.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: simple.h
00003 //
00004 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00005 //**********************************************************************
00006 #define IDM_ABOUT 100
00007 #define IDM_INSERT  101
00008 #define IDM_VERB0 1000
00009
00010 //@@WTK WIN32, UNICODE
00011 #ifdef WIN32
00012 #define EXPORT
00013 #else
00014 #define EXPORT __export
00015 #endif
00016
00017 int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow);
00018 BOOL InitApplication(HANDLE hInstance);
00019 BOOL InitInstance(HANDLE hInstance, int nCmdShow);
00020 //@@WTK WIN32, UNICODE _export ==> EXPORT, portable params
00021 long FAR PASCAL EXPORT MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00022 long FAR PASCAL EXPORT DocWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00023 BOOL FAR PASCAL EXPORT About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/CPartitionInfo.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

CPartitionInfo.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      CPartitionInfo.cpp
00005 //
00006 //  Description:
00007 //      This file contains the definition of the CPartitionInfo class.
00008 //
00009 //      The class CPartitionInfo represents a disk partition.
00010 //      It implements the IClusCfgPartitionInfo interface.
00011 //
00012 //////////////////////////////////////////////////////////////////////////////
00013
00014 //////////////////////////////////////////////////////////////////////////////
00015 // Include Files
00016 //////////////////////////////////////////////////////////////////////////////
00017
00018 #include "stdafx.h"
00019 #include "WMIHelpers.h"
00020 #include "CPartitionInfo.h"
00021
00022
00023 //////////////////////////////////////////////////////////////////////////////
00024 // CPartitionInfo class
00025 //////////////////////////////////////////////////////////////////////////////
00026
00027
00028 //////////////////////////////////////////////////////////////////////////////
00029 //++
00030 //
00031 //  CPartitionInfo::CPartitionInfo
00032 //
00033 //  Description:
00034 //      Constructor of the CPartitionInfo class. This initializes
00035 //      the m_cRef variable to 1 instead of 0 to account of possible
00036 //      QueryInterface failure in DllGetClassObject.
00037 //
00038 //  Arguments:
00039 //      None.
00040 //
00041 //  Return Value:
00042 //      None.
00043 //
00044 //  Remarks:
00045 //      None.
00046 //
00047 //--
00048 //////////////////////////////////////////////////////////////////////////////
00049 CPartitionInfo::CPartitionInfo( void )
00050     : m_cRef( 1 )
00051 {
00052     m_pIWbemServices = NULL;
00053     m_bstrName = NULL;
00054     m_bstrDescription = NULL;
00055     m_bstrUID = NULL;
00056     m_prgLogicalDisks = NULL;
00057     m_idxNextLogicalDisk = 0;
00058     m_ulPartitionSize = 0;
00059     m_bstrDiskDeviceID = NULL;
00060
00061 } //*** CPartitionInfo::CPartitionInfo
00062
00063
00064 //////////////////////////////////////////////////////////////////////////////
00065 //++
00066 //
00067 //  CPartitionInfo::~CPartitionInfo
00068 //
00069 //  Description:
00070 //      Desstructor of the CPartitionInfo class.
00071 //
00072 //  Arguments:
00073 //      None.
00074 //
00075 //  Return Value:
00076 //      None.
00077 //
00078 //  Remarks:
00079 //      None.
00080 //
00081 //--
00082 //////////////////////////////////////////////////////////////////////////////
00083 CPartitionInfo::~CPartitionInfo( void )
00084 {
00085     ULONG   idx;
00086
00087     SysFreeString( m_bstrName );
00088     SysFreeString( m_bstrDescription );
00089     SysFreeString( m_bstrUID );
00090     SysFreeString( m_bstrDiskDeviceID );
00091
00092     for ( idx = 0; idx < m_idxNextLogicalDisk; idx++ )
00093     {
00094         ((*m_prgLogicalDisks)[ idx ])->Release();
00095     } // for:
00096
00097     HeapFree( GetProcessHeap(), 0, m_prgLogicalDisks );
00098
00099     if ( m_pIWbemServices != NULL )
00100     {
00101         m_pIWbemServices->Release();
00102     } // if:
00103
00104 } //*** CPartitionInfo::~CPartitionInfo
00105
00106
00107 //////////////////////////////////////////////////////////////////////////////
00108 // CPartitionInfo -- IWMIService interface.
00109 //////////////////////////////////////////////////////////////////////////////
00110
00111
00112 //////////////////////////////////////////////////////////////////////////////
00113 //++
00114 //
00115 //  CPartitionInfo::SetWbemServices
00116 //
00117 //  Description:
00118 //      Set the WBEM services provider.
00119 //
00120 //  Arguments:
00121 //      pIWbemServicesIn
00122 //          IWbemServices pointer to save.
00123 //
00124 //  Return Value:
00125 //      S_OK
00126 //          Success
00127 //
00128 //      E_POINTER
00129 //          The pIWbemServicesIn param is NULL.
00130 //
00131 //  Remarks:
00132 //      None.
00133 //
00134 //--
00135 //////////////////////////////////////////////////////////////////////////////
00136 STDMETHODIMP
00137 CPartitionInfo::SetWbemServices(
00138     IWbemServices * pIWbemServicesIn
00139     )
00140 {
00141     HRESULT hr = S_OK;
00142
00143     if ( pIWbemServicesIn == NULL )
00144     {
00145         hr = E_POINTER;
00146         STATUS_REPORT_REF(
00147                   TASKID_Major_Find_Devices
00148                 , TASKID_Minor_SetWbemServices_Partition
00149                 , IDS_ERROR_NULL_POINTER
00150                 , IDS_ERROR_NULL_POINTER_REF
00151                 , hr
00152                 );
00153         goto Cleanup;
00154     } // if:
00155
00156     m_pIWbemServices = pIWbemServicesIn;
00157     m_pIWbemServices->AddRef();
00158
00159 Cleanup:
00160
00161     return hr;
00162
00163 } //*** CPartitionInfo::SetWbemServices
00164
00165
00166 //////////////////////////////////////////////////////////////////////////////
00167 // CPartitionInfo -- IWMIObject interface.
00168 //////////////////////////////////////////////////////////////////////////////
00169
00170
00171 //////////////////////////////////////////////////////////////////////////////
00172 //++
00173 //
00174 //  CPartitionInfo::SetWbemObject
00175 //
00176 //  Description:
00177 //      Initialize this component by querying WMI for the properties.
00178 //
00179 //  Arguments:
00180 //      pPartitionIn
00181 //          WMI disk partition object to associate with this object.
00182 //
00183 //      pfRetainObjectOut
00184 //          If set to true the object will be added to the storage resource array.
00185 //
00186 //  Return Value:
00187 //      S_OK
00188 //          Success.
00189 //
00190 //      Other.
00191 //          An error occurred.
00192 //
00193 //  Remarks:
00194 //      None.
00195 //
00196 //--
00197 //////////////////////////////////////////////////////////////////////////////
00198 HRESULT
00199 CPartitionInfo::SetWbemObject(
00200       IWbemClassObject *    pPartitionIn
00201     , BOOL *                pfRetainObjectOut
00202     )
00203 {
00204     assert( pPartitionIn != NULL );
00205     assert( pfRetainObjectOut != NULL );
00206
00207     HRESULT     hr = S_OK;
00208     VARIANT     var;
00209     ULONGLONG   ull = 0;
00210     int         cch = 0;
00211
00212     VariantInit( &var );
00213
00214     hr = HrGetWMIProperty( pPartitionIn, L"Description", VT_BSTR, &var );
00215     if ( FAILED( hr ) )
00216     {
00217         goto Cleanup;
00218     } // if:
00219
00220     m_bstrDescription = SysAllocString( var.bstrVal );
00221     if ( m_bstrDescription == NULL )
00222     {
00223         goto OutOfMemory;
00224     } // if:
00225
00226     VariantClear( &var );
00227
00228     hr = HrGetWMIProperty( pPartitionIn, L"DeviceID", VT_BSTR, &var );
00229     if ( FAILED( hr ) )
00230     {
00231         goto Cleanup;
00232     } // if:
00233
00234     m_bstrUID = SysAllocString( var.bstrVal );
00235     if ( m_bstrUID == NULL )
00236     {
00237         goto OutOfMemory;
00238     } // if:
00239
00240     VariantClear( &var );
00241
00242     hr = HrGetWMIProperty( pPartitionIn, L"Name", VT_BSTR, &var );
00243     if ( FAILED( hr ) )
00244     {
00245         goto Cleanup;
00246     } // if:
00247
00248     m_bstrName = SysAllocString( var.bstrVal );
00249     if ( m_bstrName == NULL )
00250     {
00251         goto OutOfMemory;
00252     } // if:
00253
00254     VariantClear( &var );
00255
00256     hr = HrGetWMIProperty( pPartitionIn, L"Size", VT_BSTR, &var );
00257     if ( FAILED( hr ) )
00258     {
00259         goto Cleanup;
00260     } // if:
00261
00262     cch = swscanf( var.bstrVal, L"%I64u", &ull );
00263     assert( cch > 0 );
00264
00265     m_ulPartitionSize = (ULONG) ( ull / ( 1024 * 1024 ) );
00266
00267     hr = HrGetLogicalDisks( pPartitionIn );
00268
00269     *pfRetainObjectOut = true;
00270
00271     goto Cleanup;
00272
00273 OutOfMemory:
00274
00275     hr = E_OUTOFMEMORY;
00276     STATUS_REPORT_REF(
00277               TASKID_Major_Find_Devices
00278             , TASKID_Minor_SetWbemObject_Partition
00279             , IDS_ERROR_OUTOFMEMORY
00280             , IDS_ERROR_OUTOFMEMORY_REF
00281             , hr
00282             );
00283
00284 Cleanup:
00285
00286     VariantClear( &var );
00287
00288     return hr;
00289
00290 } //*** CPartitionInfo::SetWbemObject
00291
00292
00293 //////////////////////////////////////////////////////////////////////////////
00294 // CPartitionInfo -- IClusCfgManagedResourceInfo interface.
00295 //////////////////////////////////////////////////////////////////////////////
00296
00297
00298 //////////////////////////////////////////////////////////////////////////////
00299 //++
00300 //
00301 //  CPartitionInfo::GetUID
00302 //
00303 //  Description:
00304 //      Retrieve the UID of the object.
00305 //
00306 //  Arguments:
00307 //      pbstrUIDOut
00308 //          Upon success will point to an allocated BSTR containing the UID.
00309 //
00310 //  Return Value:
00311 //      S_OK
00312 //          Success.  pbstrUIDOut contains the UID.
00313 //
00314 //      S_FALSE
00315 //          There is no UID associated with this object.
00316 //
00317 //      Other
00318 //          An error occurred.
00319 //
00320 //  Remarks:
00321 //      If S_OK is returned the caller needs to call SysFreeString on pbstrUIDOut.
00322 //
00323 //--
00324 //////////////////////////////////////////////////////////////////////////////
00325 STDMETHODIMP
00326 CPartitionInfo::GetUID( BSTR * pbstrUIDOut )
00327 {
00328     HRESULT hr = S_OK;
00329
00330     if ( pbstrUIDOut == NULL )
00331     {
00332         hr = E_POINTER;
00333         STATUS_REPORT_REF(
00334                   TASKID_Major_Find_Devices
00335                 , TASKID_Minor_PartitionInfo_GetUID_Pointer
00336                 , IDS_ERROR_NULL_POINTER
00337                 , IDS_ERROR_NULL_POINTER_REF
00338                 , hr
00339                 );
00340         goto Cleanup;
00341     } // if:
00342
00343     //
00344     //  If we don't have a UID then simply return S_FALSE to
00345     //  indicate that we have no data.
00346     //
00347
00348     if ( m_bstrUID == NULL )
00349     {
00350         hr = S_FALSE;
00351         goto Cleanup;
00352     } // if:
00353
00354     *pbstrUIDOut = SysAllocString( m_bstrUID );
00355     if ( *pbstrUIDOut == NULL )
00356     {
00357         hr = E_OUTOFMEMORY;
00358         STATUS_REPORT_REF(
00359                   TASKID_Major_Find_Devices
00360                 , TASKID_Minor_PartitionInfo_GetUID_Memory
00361                 , IDS_ERROR_OUTOFMEMORY
00362                 , IDS_ERROR_OUTOFMEMORY_REF
00363                 , hr
00364                 );
00365     } // if:
00366
00367 Cleanup:
00368
00369     return hr;
00370
00371 } //*** CPartitionInfo::GetUID
00372
00373
00374 //////////////////////////////////////////////////////////////////////////////
00375 //++
00376 //
00377 //  CPartitionInfo::GetName
00378 //
00379 //  Description:
00380 //      Retrive the name of the partition.
00381 //
00382 //  Arguments:
00383 //      pbstrNameOut
00384 //          Upon success will point to an allocated BSTR containing the name.
00385 //
00386 //  Return Value:
00387 //      S_OK
00388 //          Success.  psbstrNameOut contains the name.
00389 //
00390 //      S_FALSE
00391 //          There is no name associated with this object.
00392 //
00393 //      Other
00394 //          An error occurred.
00395 //
00396 //  Remarks:
00397 //      If S_OK is returned the caller needs to call SysFreeString on pbstrNameOut.
00398 //
00399 //--
00400 //////////////////////////////////////////////////////////////////////////////
00401 STDMETHODIMP
00402 CPartitionInfo::GetName(
00403     BSTR * pbstrNameOut
00404     )
00405 {
00406     HRESULT hr = S_OK;
00407
00408     if ( pbstrNameOut == NULL )
00409     {
00410         hr = E_POINTER;
00411         STATUS_REPORT_REF(
00412                   TASKID_Major_Find_Devices
00413                 , TASKID_Minor_PartitionInfo_GetName_Pointer
00414                 , IDS_ERROR_NULL_POINTER
00415                 , IDS_ERROR_NULL_POINTER_REF
00416                 , hr
00417                 );
00418         goto Cleanup;
00419     } // if:
00420
00421     //
00422     //  If we don't have a name then simply return S_FALSE to
00423     //  indicate that we have no data.
00424     //
00425
00426     if ( m_bstrName == NULL )
00427     {
00428         hr = S_FALSE;
00429         goto Cleanup;
00430     } // if:
00431
00432     *pbstrNameOut = SysAllocString( m_bstrName );
00433     if (*pbstrNameOut == NULL )
00434     {
00435         hr = E_OUTOFMEMORY;
00436         STATUS_REPORT_REF(
00437                   TASKID_Major_Find_Devices
00438                 , TASKID_Minor_GetName_Memory
00439                 , IDS_ERROR_OUTOFMEMORY
00440                 , IDS_ERROR_OUTOFMEMORY_REF
00441                 , hr
00442                 );
00443     } // if:
00444
00445 Cleanup:
00446
00447     return hr;
00448
00449 } //*** CPartitionInfo::GetName
00450
00451
00452 //////////////////////////////////////////////////////////////////////////////
00453 //++
00454 //
00455 //  CPartitionInfo::SetName
00456 //
00457 //  Description:
00458 //      Sets the name of the object.
00459 //
00460 //  Arguments:
00461 //      pcszNameIn
00462 //          Name to assign.
00463 //
00464 //  Return Value:
00465 //      E_NOTIMPL
00466 //          This function is not implemented.
00467 //
00468 //  Remarks:
00469 //      None.
00470 //
00471 //--
00472 //////////////////////////////////////////////////////////////////////////////
00473 STDMETHODIMP
00474 CPartitionInfo::SetName(
00475     LPCWSTR pcszNameIn
00476     )
00477 {
00478     HRESULT hr = E_NOTIMPL;
00479
00480     UNREFERENCED_PARAMETER( pcszNameIn );
00481
00482     return hr;
00483
00484 } //*** CPartitionInfo::SetName
00485
00486
00487 //////////////////////////////////////////////////////////////////////////////
00488 //++
00489 //
00490 //  CPartitionInfo::GetDescription
00491 //
00492 //  Description:
00493 //      Retrieve the description of the object.
00494 //
00495 //  Arguments:
00496 //      pbstrDescriptionOut
00497 //          Upon success will point to an allocated BSTR containing the description.
00498 //
00499 //  Return Value:
00500 //      S_OK
00501 //          Success.  pbstrDescriptionOut contains the description.
00502 //
00503 //      S_FALSE
00504 //          There is no description associated with this object.
00505 //
00506 //  Remarks:
00507 //      If S_OK is returned the caller needs to call SysFreeString on pbstrDescriptionOut.
00508 //
00509 //--
00510 //////////////////////////////////////////////////////////////////////////////
00511 STDMETHODIMP
00512 CPartitionInfo::GetDescription(
00513     BSTR * pbstrDescriptionOut
00514     )
00515 {
00516     HRESULT hr = S_OK;
00517
00518     if ( pbstrDescriptionOut == NULL )
00519     {
00520         hr = E_POINTER;
00521         STATUS_REPORT_REF(
00522                   TASKID_Major_Find_Devices
00523                 , TASKID_Minor_PartitionInfo_GetDescription_Pointer
00524                 , IDS_ERROR_NULL_POINTER
00525                 , IDS_ERROR_NULL_POINTER_REF
00526                 , hr
00527                 );
00528         goto Cleanup;
00529     } // if:
00530
00531     if ( m_bstrDescription == NULL )
00532     {
00533         hr = S_FALSE;
00534         goto Cleanup;
00535     } // if:
00536
00537     *pbstrDescriptionOut = SysAllocString( m_bstrDescription );
00538     if (*pbstrDescriptionOut == NULL )
00539     {
00540         hr = E_OUTOFMEMORY;
00541         STATUS_REPORT_REF(
00542                   TASKID_Major_Find_Devices
00543                 , TASKID_Minor_PartitionInfo_GetDescription_Memory
00544                 , IDS_ERROR_OUTOFMEMORY
00545                 , IDS_ERROR_OUTOFMEMORY_REF
00546                 , hr
00547                 );
00548     } // if:
00549
00550 Cleanup:
00551
00552     return hr;
00553
00554 } //*** CPartitionInfo::GetDescription
00555
00556
00557 //////////////////////////////////////////////////////////////////////////////
00558 //++
00559 //
00560 //  CPartitionInfo::SetDescription
00561 //
00562 //  Description:
00563 //      Sets the description of the object.
00564 //
00565 //  Arguments:
00566 //      pcszDescriptionIn
00567 //          Description to assign.
00568 //
00569 //  Return Value:
00570 //      E_NOTIMPL
00571 //          This function is not implemented.
00572 //
00573 //      E_INVALIDARG
00574 //          pcszDescriptionIn is NULL.
00575 //
00576 //  Remarks:
00577 //      None.
00578 //
00579 //--
00580 //////////////////////////////////////////////////////////////////////////////
00581 STDMETHODIMP
00582 CPartitionInfo::SetDescription(
00583     LPCWSTR pcszDescriptionIn
00584     )
00585 {
00586     HRESULT hr;
00587
00588     if ( pcszDescriptionIn == NULL )
00589     {
00590         hr = E_INVALIDARG;
00591     } // if:
00592     else
00593     {
00594         hr = E_NOTIMPL;
00595     } // else:
00596
00597     return hr;
00598
00599 } //*** CPartitionInfo::SetDescription
00600
00601
00602 //////////////////////////////////////////////////////////////////////////////
00603 //++
00604 //
00605 //  CPartitionInfo::GetDriveLetterMappings
00606 //
00607 //  Description:
00608 //      Retrieve the associated drive letters of this partition.
00609 //
00610 //  Arguments:
00611 //      pdlmDriveLetterMappingOut
00612 //          Upon success will contain all of the mappings for this partition.
00613 //
00614 //  Return Value:
00615 //      S_OK
00616 //          Success.
00617 //
00618 //      S_FALSE
00619 //          There are no drive letters associated with this partition.
00620 //
00621 //      Other
00622 //          An error occurred.
00623 //
00624 //  Remarks:
00625 //      None.
00626 //
00627 //--
00628 //////////////////////////////////////////////////////////////////////////////
00629 STDMETHODIMP
00630 CPartitionInfo::GetDriveLetterMappings(
00631     SDriveLetterMapping * pdlmDriveLetterMappingOut
00632     )
00633 {
00634     HRESULT             hr = S_FALSE;
00635     IWbemClassObject *  pLogicalDisk = NULL;
00636     VARIANT             var;
00637     ULONG               idx;
00638     int                 idxDrive;
00639
00640     VariantInit( & var );
00641
00642     if ( pdlmDriveLetterMappingOut == NULL )
00643     {
00644         hr = E_POINTER;
00645         STATUS_REPORT_REF(
00646                   TASKID_Major_Find_Devices
00647                 , TASKID_Minor_GetDriveLetterMappings_Partition
00648                 , IDS_ERROR_NULL_POINTER
00649                 , IDS_ERROR_NULL_POINTER_REF
00650                 , hr
00651                 );
00652         goto Cleanup;
00653     } // if:
00654
00655     for ( idx = 0; idx < m_idxNextLogicalDisk; idx++ )
00656     {
00657         hr = ((*m_prgLogicalDisks)[ idx ])->TypeSafeQI( IWbemClassObject, &pLogicalDisk );
00658         if ( FAILED( hr ) )
00659         {
00660             goto Cleanup;
00661         } // if:
00662
00663         VariantClear( &var );
00664
00665         hr = HrGetWMIProperty( pLogicalDisk, L"Name", VT_BSTR, &var );
00666         if ( FAILED( hr ) )
00667         {
00668             goto Cleanup;
00669         } // if:
00670
00671         CharUpper( var.bstrVal );
00672
00673         idxDrive = var.bstrVal[ 0 ] - 'A';
00674
00675         VariantClear( &var );
00676
00677         hr = HrGetWMIProperty( pLogicalDisk, L"DriveType", VT_I4, &var );
00678         if ( FAILED( hr ) )
00679         {
00680             goto Cleanup;
00681         } // if:
00682
00683         pdlmDriveLetterMappingOut->dluDrives[ idxDrive ] = (EDriveLetterUsage) var.iVal;
00684
00685         pLogicalDisk->Release();
00686         pLogicalDisk = NULL;
00687     } // for:
00688
00689 Cleanup:
00690
00691     VariantClear( &var );
00692
00693     if ( pLogicalDisk != NULL )
00694     {
00695         pLogicalDisk->Release();
00696     } // if:
00697
00698     return hr;
00699
00700 } //*** CPartitionInfo::GetDriveLetterMappings
00701
00702
00703 //////////////////////////////////////////////////////////////////////////////
00704 //++
00705 //
00706 //  CPartitionInfo::SetDriveLetterMappings
00707 //
00708 //  Description:
00709 //      Set the drive letters associated with this partition.
00710 //
00711 //  Arguments:
00712 //      dlmDriveLetterMappingIn
00713 //          Contains all of the drive letters to associate with this partition.
00714 //
00715 //  Return Value:
00716 //      E_NOTIMPL
00717 //          This function is not implemented.
00718 //
00719 //  Remarks:
00720 //      None.
00721 //
00722 //--
00723 //////////////////////////////////////////////////////////////////////////////
00724 STDMETHODIMP
00725 CPartitionInfo::SetDriveLetterMappings(
00726     SDriveLetterMapping dlmDriveLetterMappingIn
00727     )
00728 {
00729     HRESULT hr = E_NOTIMPL;
00730
00731     UNREFERENCED_PARAMETER( dlmDriveLetterMappingIn );
00732
00733     return hr;
00734
00735 } //*** CPartitionInfo::SetDriveLetterMappings
00736
00737
00738 //////////////////////////////////////////////////////////////////////////////
00739 //++
00740 //
00741 //  CPartitionInfo::GetSize
00742 //
00743 //  Description:
00744 //      Retrieve the size (in megabytes) of this partition.
00745 //
00746 //  Arguments:
00747 //      pcMegaBytes
00748 //          On success will contain the size in megabytes.
00749 //
00750 //  Return Value:
00751 //      S_OK
00752 //          Success.
00753 //
00754 //      Other
00755 //          An error occurred.
00756 //
00757 //  Remarks:
00758 //      None.
00759 //
00760 //--
00761 //////////////////////////////////////////////////////////////////////////////
00762 STDMETHODIMP
00763 CPartitionInfo::GetSize(
00764     ULONG * pcMegaBytes
00765     )
00766 {
00767     HRESULT hr = S_OK;
00768
00769     if ( pcMegaBytes == NULL )
00770     {
00771         hr = E_POINTER;
00772         STATUS_REPORT_REF(
00773                   TASKID_Major_Find_Devices
00774                 , TASKID_Minor_GetSize
00775                 , IDS_ERROR_NULL_POINTER
00776                 , IDS_ERROR_NULL_POINTER_REF
00777                 , hr
00778                 );
00779         goto Cleanup;
00780     } // if:
00781
00782     *pcMegaBytes = m_ulPartitionSize;
00783
00784 Cleanup:
00785
00786     return hr;
00787
00788 } //*** CPartitionInfo::GetSize
00789
00790
00791 //////////////////////////////////////////////////////////////////////////////
00792 // CPartitionInfo -- IPartitionProperties interface.
00793 //////////////////////////////////////////////////////////////////////////////
00794
00795
00796 //////////////////////////////////////////////////////////////////////////////
00797 //++
00798 //
00799 //  CPartitionInfo::HrIsThisLogicalDisk
00800 //
00801 //  Description:
00802 //      Does this partition have the passed in logical disk?
00803 //
00804 //  Arguments:
00805 //      cLogicalDiskIn
00806 //          The drive letter to check for.
00807 //
00808 //  Return Value:
00809 //      S_OK
00810 //          Success, the partition has the logical disk.
00811 //
00812 //      S_FALSE
00813 //          Success, the partition does not have the logical disk.
00814 //
00815 //      Other
00816 //          An error occurred.
00817 //
00818 //  Remarks:
00819 //      None.
00820 //
00821 //--
00822 //////////////////////////////////////////////////////////////////////////////
00823 STDMETHODIMP
00824 CPartitionInfo::HrIsThisLogicalDisk(
00825     WCHAR cLogicalDiskIn
00826     )
00827 {
00828     HRESULT             hr = S_FALSE;
00829     DWORD               idx;
00830     IWbemClassObject *  piwco = NULL;
00831     VARIANT             var;
00832     bool                fFoundIt = false;
00833
00834     VariantInit( &var );
00835
00836     if ( m_idxNextLogicalDisk == 0 )
00837     {
00838         goto Cleanup;
00839     } // if:
00840
00841     for ( idx = 0; idx < m_idxNextLogicalDisk; idx++ )
00842     {
00843         hr = ((*m_prgLogicalDisks)[ idx ])->TypeSafeQI( IWbemClassObject, &piwco );
00844         if ( FAILED( hr ) )
00845         {
00846             goto Cleanup;
00847         } // if:
00848
00849         hr = HrGetWMIProperty( piwco, L"DeviceID", VT_BSTR, &var );
00850         if ( FAILED( hr ) )
00851         {
00852             goto Cleanup;
00853         } // if:
00854
00855         if ( cLogicalDiskIn == var.bstrVal[ 0 ] )
00856         {
00857             fFoundIt = true;
00858             break;
00859         } // if:
00860
00861         VariantClear( &var );
00862
00863         piwco->Release();
00864         piwco = NULL;
00865     } // for:
00866
00867     if ( !fFoundIt )
00868     {
00869         hr = S_FALSE;
00870     } // if:
00871
00872 Cleanup:
00873
00874     VariantClear( &var );
00875
00876     if ( piwco != NULL )
00877     {
00878         piwco->Release();
00879     } // if:
00880
00881     return hr;
00882
00883 } //*** CPartitionInfo::HrIsThisLogicalDisk
00884
00885
00886 //////////////////////////////////////////////////////////////////////////////
00887 //++
00888 //
00889 //  CPartitionInfo::HrIsNTFS
00890 //
00891 //  Description:
00892 //      Is this an NTFS partition?
00893 //
00894 //  Arguments:
00895 //      None.
00896 //
00897 //  Return Value:
00898 //      S_OK
00899 //          Success, the partition is NTFS.
00900 //
00901 //      S_FALSE
00902 //          Success, the partition is not NTFS.
00903 //
00904 //      Other
00905 //          An error occurred.
00906 //
00907 //  Remarks:
00908 //      None.
00909 //
00910 //--
00911 //////////////////////////////////////////////////////////////////////////////
00912 STDMETHODIMP
00913 CPartitionInfo::HrIsNTFS( void )
00914 {
00915     HRESULT             hr = S_FALSE;
00916     VARIANT             var;
00917     ULONG               idx;
00918     IWbemClassObject *  piwco = NULL;
00919
00920     VariantInit( &var );
00921
00922     for ( idx = 0; idx < m_idxNextLogicalDisk; idx++ )
00923     {
00924         hr = ((*m_prgLogicalDisks)[ idx ])->TypeSafeQI( IWbemClassObject, &piwco );
00925         if ( FAILED( hr ) )
00926         {
00927             goto Cleanup;
00928         } // if:
00929
00930         VariantClear( &var );
00931
00932         hr = HrGetWMIProperty( piwco, L"FileSystem", VT_BSTR, &var );
00933         if ( ( hr == E_PROPTYPEMISMATCH ) && ( var.vt == VT_NULL ) )
00934         {
00935             VariantClear( &var );
00936
00937             hr = S_FALSE;
00938             HrGetWMIProperty( piwco, L"DeviceID", VT_BSTR, &var );
00939             STATUS_REPORT_STRING_REF(
00940                       TASKID_Major_Find_Devices
00941                     , TASKID_Minor_Disk_No_File_System
00942                     , IDS_ERROR_DISK_NO_FILE_SYSTEM
00943                     , var.bstrVal
00944                     , IDS_ERROR_DISK_NO_FILE_SYSTEM_REF
00945                     , hr
00946                     );
00947             break;
00948         } // if:
00949         else if ( FAILED( hr ) )
00950         {
00951             goto Cleanup;
00952         } // else if:
00953
00954         if ( NIStringCompareW( var.bstrVal, SysStringLen( var.bstrVal ), L"NTFS", RTL_NUMBER_OF( L"NTFS" ) ) != 0 )
00955         {
00956             VariantClear( &var );
00957
00958             hr = S_FALSE;
00959             HrGetWMIProperty( piwco, L"DeviceID", VT_BSTR, &var );
00960             STATUS_REPORT_STRING_REF(
00961                       TASKID_Major_Find_Devices
00962                     , TASKID_Minor_Disk_Not_NTFS
00963                     , IDS_WARN_DISK_NOT_NTFS
00964                     , var.bstrVal
00965                     , IDS_WARN_DISK_NOT_NTFS_REF
00966                     , hr
00967                     );
00968             break;
00969         } // if:
00970
00971         piwco->Release();
00972         piwco = NULL;
00973     } // for:
00974
00975 Cleanup:
00976
00977     VariantClear( &var );
00978
00979     if ( piwco != NULL )
00980     {
00981         piwco->Release();
00982     } // if:
00983
00984     return hr;
00985
00986 } //*** CPartitionInfo::HrIsNTFS
00987
00988
00989 //////////////////////////////////////////////////////////////////////////////
00990 //++
00991 //
00992 //  CPartitionInfo::HrGetFriendlyName
00993 //
00994 //  Description:
00995 //      Get the friendly name of this partition.  This name will be the
00996 //      logical disk names of all logical disks on this partition.
00997 //
00998 //  Arguments:
00999 //      pbstrNameOut
01000 //          Upon success will point to an allocated BSTR containing the name.
01001 //
01002 //  Return Value:
01003 //      S_OK
01004 //          Success.
01005 //
01006 //      Other
01007 //          An error occurred.
01008 //
01009 //  Remarks:
01010 //      If S_OK is returned the caller needs to call SysFreeString on pbstrNameOut.
01011 //
01012 //--
01013 //////////////////////////////////////////////////////////////////////////////
01014 STDMETHODIMP
01015 CPartitionInfo::HrGetFriendlyName(
01016     BSTR * pbstrNameOut
01017     )
01018 {
01019     HRESULT             hr = S_FALSE;
01020     DWORD               idx;
01021     IWbemClassObject *  piwco = NULL;
01022     WCHAR *             pwsz = NULL;
01023     WCHAR *             pwszTmp = NULL;
01024     DWORD               cch = 0;
01025     VARIANT             var;
01026
01027     VariantInit( &var );
01028
01029     if ( m_idxNextLogicalDisk == 0 )
01030     {
01031         goto Cleanup;
01032     } // if:
01033
01034     if ( pbstrNameOut == NULL )
01035     {
01036         hr = E_POINTER;
01037         STATUS_REPORT_REF(
01038                   TASKID_Major_Find_Devices
01039                 , TASKID_Minor_GetFriendlyName
01040                 , IDS_ERROR_NULL_POINTER
01041                 , IDS_ERROR_NULL_POINTER_REF
01042                 , hr
01043                 );
01044         goto Cleanup;
01045     } // if:
01046
01047     for ( idx = 0; idx < m_idxNextLogicalDisk; idx++ )
01048     {
01049         hr = ((*m_prgLogicalDisks)[ idx ])->TypeSafeQI( IWbemClassObject, &piwco );
01050         if ( FAILED( hr ) )
01051         {
01052             goto Cleanup;
01053         } // if:
01054
01055         hr = HrGetWMIProperty( piwco, L"DeviceID", VT_BSTR, &var );
01056         if ( FAILED( hr ) )
01057         {
01058             goto Cleanup;
01059         } // if:
01060
01061         cch += ( UINT ) wcslen( var.bstrVal ) + 2;                      // a space and the '\0'
01062
01063         pwszTmp = (WCHAR *) HEAPREALLOC( pwsz, sizeof( WCHAR ) * cch, HEAP_ZERO_MEMORY );
01064         if ( pwszTmp == NULL  )
01065         {
01066             goto OutOfMemory;
01067         } // if:
01068
01069         pwsz = pwszTmp;
01070         pwszTmp = NULL;
01071
01072         hr = StringCchCatW( pwsz, cch, L" " );
01073         if ( FAILED( hr ) )
01074         {
01075             goto Cleanup;
01076         } // if:
01077
01078         hr = StringCchCatW( pwsz, cch, var.bstrVal );
01079         if ( FAILED( hr ) )
01080         {
01081             goto Cleanup;
01082         } // if:
01083
01084         VariantClear( &var );
01085
01086         piwco->Release();
01087         piwco = NULL;
01088     } // for:
01089
01090     *pbstrNameOut = SysAllocString( pwsz );
01091     if ( *pbstrNameOut == NULL )
01092     {
01093         goto OutOfMemory;
01094     } // if:
01095
01096     goto Cleanup;
01097
01098 OutOfMemory:
01099
01100     hr = E_OUTOFMEMORY;
01101     STATUS_REPORT_REF(
01102               TASKID_Major_Find_Devices
01103             , TASKID_Minor_HrGetFriendlyName
01104             , IDS_ERROR_OUTOFMEMORY
01105             , IDS_ERROR_OUTOFMEMORY_REF
01106             , hr
01107             );
01108
01109 Cleanup:
01110
01111     VariantClear( &var );
01112
01113     if ( piwco != NULL )
01114     {
01115         piwco->Release();
01116     } // if:
01117
01118     if ( pwsz != NULL )
01119     {
01120         HeapFree( GetProcessHeap(), 0, pwsz );
01121     } // if:
01122
01123     if ( pwszTmp != NULL )
01124     {
01125         HeapFree( GetProcessHeap(), 0, pwszTmp );
01126     } // if:
01127
01128     return hr;
01129
01130 } //*** CPartitionInfo::HrGetFriendlyName
01131
01132
01133 //////////////////////////////////////////////////////////////////////////////
01134 //++
01135 //
01136 //  CPartitionInfo::HrSetDeviceID
01137 //
01138 //  Description:
01139 //      Sets the device ID of this object.
01140 //
01141 //  Arguments:
01142 //      bstrDeviceIDIn
01143 //          Device ID to assign.
01144 //
01145 //  Return Value:
01146 //      S_OK
01147 //          Success.
01148 //
01149 //      Other
01150 //          An error occurred.
01151 //
01152 //  Remarks:
01153 //      None.
01154 //
01155 //--
01156 //////////////////////////////////////////////////////////////////////////////
01157 HRESULT
01158 CPartitionInfo::HrSetDeviceID(
01159     BSTR    bstrDeviceIDIn      // = NULL
01160     )
01161 {
01162     HRESULT hr = S_OK;
01163
01164     if ( bstrDeviceIDIn != NULL )
01165     {
01166         m_bstrDiskDeviceID = SysAllocString( bstrDeviceIDIn );
01167         if ( m_bstrDiskDeviceID == NULL )
01168         {
01169             hr = E_OUTOFMEMORY;
01170         } // if:
01171     } // if:
01172
01173     return hr;
01174
01175 } //*** CPartitionInfo::HrSetDeviceID
01176
01177
01178 //////////////////////////////////////////////////////////////////////////////
01179 // CPartitionInfo class -- Private Methods.
01180 //////////////////////////////////////////////////////////////////////////////
01181
01182
01183 /////////////////////////////////////////////////////////////////////////////
01184 //++
01185 //
01186 //  CPartitionInfo:HrAddLogicalDiskToArray
01187 //
01188 //  Description:
01189 //      Add the passed in logical disk to the array of punks that holds the
01190 //      logical disks.
01191 //
01192 //  Arguments:
01193 //      pLogicalDiskIn
01194 //          Logical disk to add to the array.
01195 //
01196 //  Return Value:
01197 //      S_OK
01198 //          Success
01199 //
01200 //      Other
01201 //          An error occurred.
01202 //
01203 //  Remarks:
01204 //      None.
01205 //
01206 //--
01207 //////////////////////////////////////////////////////////////////////////////
01208 HRESULT
01209 CPartitionInfo::HrAddLogicalDiskToArray(
01210     IWbemClassObject * pLogicalDiskIn
01211     )
01212 {
01213     HRESULT     hr = S_OK;
01214     IUnknown *  punk;
01215     IUnknown *  ((*prgpunks)[]) = NULL;
01216
01217     prgpunks = (IUnknown *((*)[])) HEAPREALLOC( m_prgLogicalDisks, sizeof( IUnknown * ) * ( m_idxNextLogicalDisk + 1 ), HEAP_ZERO_MEMORY );
01218     if ( prgpunks == NULL )
01219     {
01220         hr = E_OUTOFMEMORY;
01221         STATUS_REPORT_REF(
01222                   TASKID_Major_Find_Devices
01223                 , TASKID_Minor_HrAddLogicalDiskToArray
01224                 , IDS_ERROR_OUTOFMEMORY
01225                 , IDS_ERROR_OUTOFMEMORY_REF
01226                 , hr
01227                 );
01228         goto Cleanup;
01229     } // else:
01230
01231     m_prgLogicalDisks = prgpunks;
01232
01233     hr = pLogicalDiskIn->TypeSafeQI( IUnknown, &punk );
01234     if ( SUCCEEDED( hr ) )
01235     {
01236         (*m_prgLogicalDisks)[ m_idxNextLogicalDisk++ ] = punk;
01237     } // if:
01238
01239 Cleanup:
01240
01241     return hr;
01242
01243 } //*** CPartitionInfo::HrAddLogicalDiskToArray
01244
01245
01246 /////////////////////////////////////////////////////////////////////////////
01247 //++
01248 //
01249 //  CPartitionInfo:HrGetLogicalDisks
01250 //
01251 //  Description:
01252 //      Get the logical disks for the passed in partition.
01253 //
01254 //  Arguments:
01255 //      pPartitionIn
01256 //          WMI partition object to query on.
01257 //
01258 //  Return Value:
01259 //      S_OK
01260 //          Success
01261 //
01262 //      S_FALSE
01263 //          The file system was not NTFS.
01264 //
01265 //      Other
01266 //          An error occurred.
01267 //
01268 //  Remarks:
01269 //      None.
01270 //
01271 //--
01272 //////////////////////////////////////////////////////////////////////////////
01273 HRESULT
01274 CPartitionInfo::HrGetLogicalDisks(
01275     IWbemClassObject * pPartitionIn
01276     )
01277 {
01278     HRESULT                 hr;
01279     VARIANT                 var;
01280     WCHAR                   szBuf[ 256 ];
01281     IEnumWbemClassObject *  pLogicalDisks = NULL;
01282     IWbemClassObject *      pLogicalDisk = NULL;
01283     ULONG                   ulReturned;
01284     BSTR                    bstrQuery = NULL;
01285     BSTR                    bstrWQL = NULL;
01286
01287     VariantInit( &var );
01288
01289     bstrWQL = SysAllocString( L"WQL" );
01290     if ( bstrWQL == NULL )
01291     {
01292         hr = E_OUTOFMEMORY;
01293         STATUS_REPORT_REF(
01294                   TASKID_Major_Find_Devices
01295                 , TASKID_Minor_HrGetLogicalDisks
01296                 , IDS_ERROR_OUTOFMEMORY
01297                 , IDS_ERROR_OUTOFMEMORY_REF
01298                 , hr
01299                 );
01300         goto Cleanup;
01301     } // if:
01302
01303     //
01304     //  Need to enum the logical disk(s) of this partition to determine if it is booted
01305     //  bootable.
01306     //
01307     hr = HrGetWMIProperty( pPartitionIn, L"DeviceID", VT_BSTR, &var );
01308     if ( FAILED( hr ) )
01309     {
01310         goto Cleanup;
01311     } // if:
01312
01313     hr = StringCchPrintfW(
01314                       szBuf
01315                     , RTL_NUMBER_OF( szBuf )
01316                     , L"Associators of {Win32_DiskPartition.DeviceID='%ws'} where AssocClass=Win32_LogicalDiskToPartition"
01317                     , var.bstrVal
01318                     );
01319     if ( FAILED( hr ) )
01320     {
01321         goto Cleanup;
01322     } // if:
01323
01324     bstrQuery = SysAllocString( szBuf );
01325     if ( bstrQuery == NULL )
01326     {
01327         hr = E_OUTOFMEMORY;
01328         STATUS_REPORT_REF(
01329                   TASKID_Major_Find_Devices
01330                 , TASKID_Minor_HrGetLogicalDisks
01331                 , IDS_ERROR_OUTOFMEMORY
01332                 , IDS_ERROR_OUTOFMEMORY_REF
01333                 , hr
01334                 );
01335         goto Cleanup;
01336     } // if:
01337
01338     hr = m_pIWbemServices->ExecQuery( bstrWQL, bstrQuery, WBEM_FLAG_FORWARD_ONLY, NULL, &pLogicalDisks );
01339     if ( FAILED( hr ) )
01340     {
01341         STATUS_REPORT_REF(
01342               TASKID_Major_Find_Devices
01343             , TASKID_Minor_WMI_Logical_Disks_Qry_Failed
01344             , IDS_ERROR_WMI_DISKS_QRY_FAILED
01345             , IDS_ERROR_WMI_DISKS_QRY_FAILED_REF
01346             , hr
01347             );
01348         goto Cleanup;
01349     } // if:
01350
01351     for ( ; ; )
01352     {
01353         hr = pLogicalDisks->Next( WBEM_INFINITE, 1, &pLogicalDisk, &ulReturned );
01354         if ( ( hr == S_OK ) && ( ulReturned == 1 ) )
01355         {
01356             HrLogLogicalDiskInfo( pLogicalDisk, var.bstrVal );
01357             hr = HrAddLogicalDiskToArray( pLogicalDisk );
01358             if ( FAILED( hr ) )
01359             {
01360                 goto Cleanup;
01361             } // if:
01362
01363             pLogicalDisk->Release();
01364             pLogicalDisk = NULL;
01365         } // if:
01366         else if ( ( hr == S_FALSE ) && ( ulReturned == 0 ) )
01367         {
01368             hr = S_OK;
01369             break;
01370         } // else if:
01371         else
01372         {
01373             STATUS_REPORT_STRING_REF(
01374                       TASKID_Major_Find_Devices
01375                     , TASKID_Minor_HrGetLogicalDisks_Next
01376                     , IDS_ERROR_WQL_QRY_NEXT_FAILED
01377                     , bstrQuery
01378                     , IDS_ERROR_WQL_QRY_NEXT_FAILED_REF
01379                     , hr
01380                     );
01381             goto Cleanup;
01382         } // else:
01383     } // for:
01384
01385 Cleanup:
01386
01387     VariantClear( &var );
01388
01389     SysFreeString( bstrQuery );
01390     SysFreeString( bstrWQL );
01391
01392     if ( pLogicalDisk != NULL )
01393     {
01394         pLogicalDisk->Release();
01395     } // if:
01396
01397     if ( pLogicalDisks != NULL )
01398     {
01399         pLogicalDisks->Release();
01400     } // if:
01401
01402     return hr;
01403
01404 } //*** CPartitionInfo::HrGetLogicalDisks
01405
01406
01407 /////////////////////////////////////////////////////////////////////////////
01408 //++
01409 //
01410 //  CPartitionInfo:HrLogLogicalDiskInfo
01411 //
01412 //  Description:
01413 //      Log the info about the passed in logical disk.
01414 //
01415 //  Arguments:
01416 //      pLogicalDiskIn
01417 //          The logical disk to log info about.
01418 //
01419 //      bstrDeviceIDIn
01420 //          The device ID of the current partition to which this logical disk
01421 //          belongs.
01422 //
01423 //  Return Value:
01424 //      S_OK
01425 //          Success
01426 //
01427 //      Other
01428 //          An error occurred.
01429 //
01430 //--
01431 //////////////////////////////////////////////////////////////////////////////
01432 HRESULT
01433 CPartitionInfo::HrLogLogicalDiskInfo(
01434       IWbemClassObject *    pLogicalDiskIn
01435     , BSTR                  bstrDeviceIDIn
01436     )
01437 {
01438     assert( m_bstrDiskDeviceID != NULL );
01439     assert( pLogicalDiskIn != NULL );
01440     assert( bstrDeviceIDIn != NULL );
01441
01442     HRESULT hr = S_OK;
01443     VARIANT var;
01444
01445     VariantInit( &var );
01446
01447     if ( ( pLogicalDiskIn == NULL ) || ( bstrDeviceIDIn == NULL ) )
01448     {
01449         hr = E_INVALIDARG;
01450         goto Cleanup;
01451     } // if:
01452
01453     hr = HrGetWMIProperty( pLogicalDiskIn, L"Name", VT_BSTR, &var );
01454     if ( FAILED( hr ) )
01455     {
01456         goto Cleanup;
01457     } // if:
01458
01459     LOG_STATUS_REPORT_STRING4(
01460                   L"Found %1!ws! resource \"%2!ws!\" with partition \"%3!ws!\" which has the logical disk \"%3!ws!\"."
01461                 , GetResTypeName()
01462                 , m_bstrDiskDeviceID
01463                 , bstrDeviceIDIn
01464                 , var.bstrVal
01465                 , hr
01466                 );
01467
01468 Cleanup:
01469
01470     VariantClear( &var );
01471
01472     return hr;
01473
01474 } //*** CPartitionInfo::HrLogLogicalDiskInfo
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerServe/Connect.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerServe

Connect.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.H
00003
00004   Summary:   Include file declaring COM object classes and constants for
00005              managing the connection points (and their connections)
00006              exposed by the connectable objects in the PERSERVE server.
00007
00008              For a comprehensive tutorial code tour of this module's
00009              contents and offerings see the tutorial PERSERVE.HTM
00010              file. For more specific technical details on the internal
00011              workings see the comments dispersed throughout the module's
00012              source code.
00013
00014   Functions: .
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Origin:    6-10-96: atrent - Editor inheritance from the CONSERVE COM
00020              Tutorial Code Sample. Very little change was required.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 #if !defined(CONNECT_H)
00038 #define CONNECT_H
00039
00040 #ifdef __cplusplus
00041
00042
00043 // An enumeration giving symbol names for the connection
00044 // points offered by the PageList component in this server.
00045 enum
00046 {
00047   CONNPOINT_PAGELISTSINK = 0
00048 };
00049
00050 enum
00051 {
00052   // The maximum number of connection points offered by the PageList
00053   // component in this PERSERVE server.  The number of items in the
00054   // connection point enumeration above.
00055   MAX_CONNECTION_POINTS = 1,
00056
00057   // A constant for the number of connections to add to the allocation
00058   // of the dynamic connection array.
00059   ALLOC_CONNECTIONS = 8,
00060
00061   // The start value for the connection key (cookie) counter.
00062   COOKIE_START_VALUE = 500
00063 };
00064
00065
00066 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00067   ObjectClass: COEnumConnectionPoints
00068
00069   Summary:     COM object class for enumerating the Connection Points
00070                offered by a connectable object.
00071
00072   Interfaces:  IUnknown
00073                  Standard interface providing COM object features.
00074                IEnumConnectionPoints
00075                  Interface for connection point enumeration.
00076
00077   Aggregation: COEnumConnectionPoints COM Objects are not aggregatable.
00078 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00079 class COEnumConnectionPoints : public IEnumConnectionPoints
00080 {
00081   public:
00082     // Main Object Constructor & Destructor.
00083     COEnumConnectionPoints(IUnknown* pHostObj);
00084     ~COEnumConnectionPoints(void);
00085
00086     // A general method for initializing this newly created object.
00087     // Creates any subordinate arrays, structures, or objects.
00088     HRESULT Init(
00089               ULONG cConnPts,
00090               IConnectionPoint** paConnPts,
00091               ULONG iEnumIndex);
00092
00093     // IUnknown methods. Main object, non-delegating.
00094     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00095     STDMETHODIMP_(ULONG) AddRef(void);
00096     STDMETHODIMP_(ULONG) Release(void);
00097
00098     // IEnumConnectionPoints methods.
00099     STDMETHODIMP         Next(ULONG, IConnectionPoint**, ULONG*);
00100     STDMETHODIMP         Skip(ULONG);
00101     STDMETHODIMP         Reset(void);
00102     STDMETHODIMP         Clone(IEnumConnectionPoints**);
00103
00104   private:
00105     // Private data of COEnumConnectionPoints COM objects.
00106
00107     // Main Object reference count.
00108     ULONG              m_cRefs;
00109
00110     // IUnknown pointer to host COM object being enumerated.
00111     IUnknown*          m_pHostObj;
00112
00113     // Connection Point index variable.
00114     ULONG              m_iEnumIndex;
00115
00116     // Number of Connection Points being enumerated.
00117     ULONG              m_cConnPts;
00118
00119     // Allocated array of Connection Point interface pointers.
00120     IConnectionPoint** m_paConnPts;
00121 };
00122
00123
00124 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00125   ObjectClass: COConnectionPoint
00126
00127   Summary:     Connection Point COM object class. Implements a native
00128                IConnectionPoint interface.
00129
00130   Interfaces:  IUnknown
00131                  Standard interface providing COM object features.
00132                IConnectionPoint
00133                  Interface for connection point features.
00134
00135   Aggregation: COConnectionPoint COM Objects are not aggregatable.
00136 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00137 class COConnectionPoint : public IConnectionPoint
00138 {
00139   public:
00140     // Main Object Constructor & Destructor.
00141     COConnectionPoint(IUnknown* pHostObj);
00142     ~COConnectionPoint(void);
00143
00144     // A general method for initializing this newly created object.
00145     // Creates any subordinate arrays, structures, or objects.
00146     HRESULT Init(REFIID riid);
00147
00148     // IUnknown methods. Main object, non-delegating.
00149     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00150     STDMETHODIMP_(ULONG) AddRef(void);
00151     STDMETHODIMP_(ULONG) Release(void);
00152
00153     // IConnectionPoint methods.
00154     STDMETHODIMP GetConnectionInterface(IID*);
00155     STDMETHODIMP GetConnectionPointContainer(IConnectionPointContainer**);
00156     STDMETHODIMP Advise(IUnknown*, DWORD*);
00157     STDMETHODIMP Unadvise(DWORD);
00158     STDMETHODIMP EnumConnections(IEnumConnections**);
00159
00160   private:
00161     // Private utility methods of COConnectionPoint.
00162     HRESULT GetSlot(UINT* puiFreeSlot);
00163     HRESULT FindSlot(DWORD dwCookie, UINT* puiSlot);
00164
00165     // Private data of COConnectionPoint COM objects.
00166
00167     // Main Object reference count.
00168     ULONG          m_cRefs;
00169
00170     // IUnknown pointer to host COM object offering this connection point.
00171     IUnknown*      m_pHostObj;
00172
00173     // The IID of the sink interface associated with this connection point.
00174     IID            m_iidSink;
00175
00176     // The current connection cookie (key) counter.
00177     DWORD          m_dwNextCookie;
00178
00179     // The current number of live sink connections to this connection point.
00180     UINT           m_cConnections;
00181
00182     // The current maximum index into the dynamic connection array.
00183     UINT           m_uiMaxIndex;
00184
00185     // The dynamic array of sink connections to this connection point.
00186     CONNECTDATA*   m_paConnections;
00187 };
00188
00189
00190 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00191   ObjectClass: COEnumConnections
00192
00193   Summary:     COM object class for enumerating the connections of a
00194                connection point of a connectable object.
00195
00196   Interfaces:  IUnknown
00197                  Standard interface providing COM object features.
00198                IEnumConnections
00199                  Interface for connection enumeration features.
00200
00201   Aggregation: COEnumConnections COM Objects are not aggregatable.
00202 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00203 class COEnumConnections : public IEnumConnections
00204 {
00205   public:
00206     // Main Object Constructor & Destructor.
00207     COEnumConnections(IUnknown* pHostObj);
00208     ~COEnumConnections(void);
00209
00210     // A general method for initializing this newly created object.
00211     // Creates any subordinate arrays, structures, or objects.
00212     HRESULT Init(
00213               ULONG cConnections,
00214               CONNECTDATA* paConnections,
00215               ULONG iEnumIndex);
00216
00217     // IUnknown methods. Main object, non-delegating.
00218     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00219     STDMETHODIMP_(ULONG) AddRef(void);
00220     STDMETHODIMP_(ULONG) Release(void);
00221
00222     // IEnumConnections methods.
00223     STDMETHODIMP         Next(ULONG, CONNECTDATA*, ULONG*);
00224     STDMETHODIMP         Skip(ULONG);
00225     STDMETHODIMP         Reset(void);
00226     STDMETHODIMP         Clone(IEnumConnections**);
00227
00228   private:
00229     // Private data of COEnumConnections COM objects.
00230
00231     // Main Object reference count.
00232     ULONG            m_cRefs;
00233
00234     // IUnknown pointer to host connection point COM object being
00235     // enumerated.
00236     IUnknown*        m_pHostObj;
00237
00238     // Connection index variable.
00239     ULONG            m_iEnumIndex;
00240
00241     // Number of Connections being enumerated.
00242     ULONG            m_cConnections;
00243
00244     // Allocated array of live Connections only.
00245     CONNECTDATA*     m_paConnections;
00246 };
00247
00248 #endif // __cplusplus
00249
00250
00251 #endif // CONNECT_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/adddevicedlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

adddevicedlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddDeviceDlg.h:  Header for the CAddDeviceDlg class.  This is a
00014 //                   modeless dialog class used to add device nodes.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDDEVICEDLG_
00019 #define _CLASS_ADDDEVICEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddDeviceDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddDeviceDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddDeviceDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDDEVICEDLG_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/stdafx.h Source File

  • Dataaccess
  • rds
  • handler
  • vc

stdafx.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:        StdAfx.h
00004 //
00005 // Copyright:   Copyright (c) 1997-1999 Microsoft Corporation
00006 //
00007 // Contents:    include file for standard system include files,
00008 //              or project specific include files that are used frequently,
00009 //              but are changed infrequently
00010 //
00011 // Comments:
00012 //
00013 //-----------------------------------------------------------------------------
00014
00015 #if !defined(AFX_STDAFX_H__A1A6B990_497F_11D1_9217_00C04FBBBFB3__INCLUDED_)
00016 #define AFX_STDAFX_H__A1A6B990_497F_11D1_9217_00C04FBBBFB3__INCLUDED_
00017
00018 #if _MSC_VER >= 1000
00019 #pragma once
00020 #endif // _MSC_VER >= 1000
00021
00022 #define STRICT
00023
00024
00025 #define _WIN32_WINNT 0x0400
00026 //#define _ATL_APARTMENT_THREADED
00027 #define _ATL_FREE_THREADED
00028
00029
00030 #include <atlbase.h>
00031 //You may derive a class from CComModule and use it if you want to override
00032 //something, but do not change the name of _Module
00033 extern CComModule _Module;
00034 #include <atlcom.h>
00035
00036 //{{AFX_INSERT_LOCATION}}
00037 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00038
00039 #endif // !defined(AFX_STDAFX_H__A1A6B990_497F_11D1_9217_00C04FBBBFB3__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpwizard/SCPWizard.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpwizard

SCPWizard.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCPWizard.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011
00012 // GUID's for Cclasses
00013
00014 extern const GUID CLSID_SCPWizard;
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DcdServe/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DcdServe

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the class factories of the DCDSERVE
00005              server.  This server provides the SharePaper COM component.
00006              For this component, IClassFactory is implemented in an
00007              appropriate class factory COM object: CFPaper. The COM
00008              component that can be manufactured by this server is known
00009              outside the server by its CLSID: CLSID_SharePaper.
00010
00011              The class factories in this server use the CThreaded
00012              OwnThis mechanism to ensure mutually exclusive access by
00013              contending multiple threads.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial DCDSERVE.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   CFPaper.
00022
00023   Functions: .
00024
00025   Origin:    8-24-97: atrent - Editor-inheritance from FACTORY.CPP in
00026                the LOCSERVE Tutorial Code Sample. [Revised]
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043 /*---------------------------------------------------------------------------
00044   We include WINDOWS.H for all Win32 applications.
00045   We include OLE2.H because we will be calling the COM/OLE Libraries.
00046   We include OLECTL.H because it has definitions for connectable objects.
00047   We include APPUTIL.H because we will be building this EXE using
00048     the convenient Virtual Window and Dialog classes and other
00049     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00050   We include PAPINT.H and PAPGUIDS.H for the common Paper-related
00051     Interface class, GUID, and CLSID specifications. PAPINT.H is generated
00052     in the DCDMARSH marshaling sample.
00053   We include SERVER.H because it has the necessary internal class and
00054     resource definitions for this EXE.
00055   We include FACTORY.H because it has the necessary internal class factory
00056     declarations for this EXE component server.  Those factories we will be
00057     implementing in this module.
00058   We include CONNECT.H for object class declarations for the various
00059     connection point and connection COM objects used in DCDSERVE.
00060   We include PAPER.H, for the object class declarations for the
00061     COPaper COM object.
00062 ---------------------------------------------------------------------------*/
00063 #include <windows.h>
00064 #include <ole2.h>
00065 #include <olectl.h>
00066 #include <apputil.h>
00067 #include <papint.h>
00068 #include <papguids.h>
00069 #include "server.h"
00070 #include "factory.h"
00071 #include "connect.h"
00072 #include "paper.h"
00073
00074 /*---------------------------------------------------------------------------
00075   Implementation the CFPaper Class Factory.  CFPaper is the COM
00076   object class for the Class Factory that can manufacture COPaper
00077   COM Components.
00078 ---------------------------------------------------------------------------*/
00079
00080 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00081   Method:   CFPaper::CFPaper
00082
00083   Summary:  CFPaper Constructor. Note the member initializer:
00084             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00085             to pass the 'this', pUnkOuter, and pServer pointers of this
00086             constructor function to the constructor executed in the
00087             instantiation of the CImpIClassFactory interface whose
00088             implementation is nested inside this present object class.
00089
00090   Args:     IUnknown* pUnkOuter,
00091               Pointer to the the outer Unknown.  NULL means this COM Object
00092               is not being Aggregated.  Non NULL means it is being created
00093               on behalf of an outside COM object that is reusing it via
00094               aggregation.
00095             CServer* pServer)
00096               Pointer to the server's control object.
00097
00098   Modifies: m_cRefs, m_pUnkOuter.
00099
00100   Returns:  void
00101 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00102 CFPaper::CFPaper(
00103   IUnknown* pUnkOuter,
00104   CServer* pServer) :
00105   m_ImpIClassFactory(this, pUnkOuter, pServer)
00106 {
00107   // Zero the COM object's reference count.
00108   m_cRefs = 0;
00109
00110   // No AddRef necessary if non-NULL, as we're nested.
00111   m_pUnkOuter = pUnkOuter;
00112
00113   // Init the pointer to the server control object.
00114   m_pServer = pServer;
00115
00116   return;
00117 }
00118
00119
00120 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00121   Method:   CFPaper::~CFPaper
00122
00123   Summary:  CFPaper Destructor.
00124
00125   Args:     void
00126
00127   Returns:  void
00128 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00129 CFPaper::~CFPaper(void)
00130 {
00131   return;
00132 }
00133
00134
00135 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00136   Method:   CFPaper::QueryInterface
00137
00138   Summary:  QueryInterface of the CFPaper non-delegating
00139             IUnknown implementation.
00140
00141   Args:     REFIID riid,
00142               [in] GUID of the Interface being requested.
00143             PPVOID ppv)
00144               [out] Address of the caller's pointer variable that will
00145               receive the requested interface pointer.
00146
00147   Returns:  HRESULT
00148               Standard result code. NOERROR for success.
00149 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00150 STDMETHODIMP CFPaper::QueryInterface(
00151                REFIID riid,
00152                PPVOID ppv)
00153 {
00154   HRESULT hr = E_POINTER;
00155
00156   if (OwnThis())
00157   {
00158     if (NULL != ppv)
00159     {
00160       hr = E_NOINTERFACE;
00161       *ppv = NULL;
00162
00163       if (IID_IUnknown == riid)
00164         *ppv = this;
00165       else if (IID_IClassFactory == riid)
00166         *ppv = &m_ImpIClassFactory;
00167
00168       if (NULL != *ppv)
00169       {
00170         // We've handed out a pointer to the interface so obey the COM
00171         // rules and AddRef the reference count.
00172         ((LPUNKNOWN)*ppv)->AddRef();
00173         hr = NOERROR;
00174       }
00175     }
00176
00177     UnOwnThis();
00178   }
00179
00180   return (hr);
00181 }
00182
00183
00184 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00185   Method:   CFPaper::AddRef
00186
00187   Summary:  AddRef of the CFPaper non-delegating IUnknown implementation.
00188
00189   Args:     void
00190
00191   Modifies: m_cRefs.
00192
00193   Returns:  ULONG
00194               New value of m_cRefs (COM object's reference count).
00195 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00196 STDMETHODIMP_(ULONG) CFPaper::AddRef(void)
00197 {
00198   ULONG cRefs;
00199
00200   if (OwnThis())
00201   {
00202     cRefs = ++m_cRefs;
00203
00204     UnOwnThis();
00205   }
00206
00207   return cRefs;
00208 }
00209
00210
00211 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00212   Method:   CFPaper::Release
00213
00214   Summary:  Release of the CFPaper non-delegating IUnknown implementation.
00215
00216   Args:     void
00217
00218   Modifies: m_cRefs.
00219
00220   Returns:  ULONG
00221               New value of m_cRefs (COM object's reference count).
00222 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00223 STDMETHODIMP_(ULONG) CFPaper::Release(void)
00224 {
00225   ULONG cRefs;
00226
00227   if (OwnThis())
00228   {
00229     cRefs = --m_cRefs;
00230
00231     if (0 == cRefs)
00232     {
00233       // We've reached a zero reference count for this COM object.
00234       // So we tell the server housing to decrement its global object
00235       // count so that the server will be unloaded if appropriate.
00236       if (NULL != m_pServer)
00237         m_pServer->ObjectsDown();
00238
00239       // We artificially bump the main ref count to prevent reentrancy
00240       // via the main object destructor.  Not really needed in this
00241       // CFPaper but a good practice because we are aggregatable and
00242       // may at some point in the future add something entertaining like
00243       // some Releases to the CFPaper destructor.
00244       m_cRefs++;
00245       UnOwnThis();
00246       delete this;
00247     }
00248     else
00249       UnOwnThis();
00250   }
00251
00252   return cRefs;
00253 }
00254
00255
00256 /*---------------------------------------------------------------------------
00257   CFPaper's nested implementation of the IClassFactory interface
00258   including Constructor, Destructor, QueryInterface, AddRef, Release,
00259   CreateInstance, and LockServer methods.
00260 ---------------------------------------------------------------------------*/
00261
00262 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00263   Method:   CFPaper::CImpIClassFactory::CImpIClassFactory
00264
00265   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00266
00267   Args:     CFPaper* pCO,
00268               Back pointer to the parent outer object.
00269             IUnknown* pUnkOuter,
00270               Pointer to the outer Unknown.  For delegation.
00271             CServer* pServer)
00272               Pointer to the server's control object.
00273
00274   Modifies: m_pCO, m_pUnkOuter, m_pServer.
00275
00276   Returns:  void
00277 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00278 CFPaper::CImpIClassFactory::CImpIClassFactory(
00279   CFPaper* pCO,
00280   IUnknown* pUnkOuter,
00281   CServer* pServer)
00282 {
00283   // Init the Back Object Pointer to point to the parent object.
00284   m_pCO = pCO;
00285
00286   // Init the pointer to the server control object.
00287   m_pServer = pServer;
00288
00289   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00290   // We use the Back Object pointer for IUnknown delegation here if we are
00291   // not being aggregated. If we are being aggregated we use the supplied
00292   // pUnkOuter for IUnknown delegation. In either case the pointer
00293   // assignment requires no AddRef because the CImpIClassFactory lifetime
00294   // is quaranteed by the lifetime of the parent object in which
00295   // CImpIClassFactory is nested.
00296   if (NULL == pUnkOuter)
00297     m_pUnkOuter = pCO;
00298   else
00299     m_pUnkOuter = pUnkOuter;
00300
00301   return;
00302 }
00303
00304
00305 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00306   Method:   CFPaper::CImpIClassFactory::~CImpIClassFactory
00307
00308   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00309
00310   Args:     void
00311
00312   Returns:  void
00313 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00314 CFPaper::CImpIClassFactory::~CImpIClassFactory(void)
00315 {
00316   return;
00317 }
00318
00319
00320 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00321   Method:   CFPaper::CImpIClassFactory::QueryInterface
00322
00323   Summary:  The QueryInterface IUnknown member of this IClassFactory
00324             interface implementation that delegates to m_pUnkOuter,
00325             whatever it is.
00326
00327   Args:     REFIID riid,
00328               [in] GUID of the Interface being requested.
00329             PPVOID ppv)
00330               [out] Address of the caller's pointer variable that will
00331               receive the requested interface pointer.
00332
00333   Returns:  HRESULT
00334               Standard result code. NOERROR for success.
00335               Returned by the delegated outer QueryInterface call.
00336 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00337 STDMETHODIMP CFPaper::CImpIClassFactory::QueryInterface(
00338                REFIID riid,
00339                PPVOID ppv)
00340 {
00341   // Delegate this call to the outer object's QueryInterface.
00342   return m_pUnkOuter->QueryInterface(riid, ppv);
00343 }
00344
00345
00346 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00347   Method:   CFPaper::CImpIClassFactory::AddRef
00348
00349   Summary:  The AddRef IUnknown member of this IClassFactory interface
00350             implementation that delegates to m_pUnkOuter, whatever it is.
00351
00352   Args:     void
00353
00354   Returns:  ULONG
00355               Returned by the delegated outer AddRef call.
00356 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00357 STDMETHODIMP_(ULONG) CFPaper::CImpIClassFactory::AddRef(void)
00358 {
00359   // Delegate this call to the outer object's AddRef.
00360   return m_pUnkOuter->AddRef();
00361 }
00362
00363
00364 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00365   Method:   CFPaper::CImpIClassFactory::Release
00366
00367   Summary:  The Release IUnknown member of this IClassFactory interface
00368             implementation that delegates to m_pUnkOuter, whatever it is.
00369
00370   Args:     void
00371
00372   Returns:  ULONG
00373               Returned by the delegated outer Release call.
00374 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00375 STDMETHODIMP_(ULONG) CFPaper::CImpIClassFactory::Release(void)
00376 {
00377   // Delegate this call to the outer object's Release.
00378   return m_pUnkOuter->Release();
00379 }
00380
00381
00382 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00383   Method:   CFPaper::CImpIClassFactory::CreateInstance
00384
00385   Summary:  The CreateInstance member method of this IClassFactory
00386             interface implementation.  Creates an instance of the COPaper
00387             COM component.
00388
00389   Args:     IUnknown* pUnkOuter,
00390               [in] Pointer to the controlling IUnknown.
00391             REFIID riid,
00392               [in] GUID of the Interface being requested.
00393             PPVOID ppvCob)
00394               [out] Address of the caller's pointer variable that will
00395               receive the requested interface pointer.
00396
00397   Returns:  HRESULT
00398               Standard result code. NOERROR for success.
00399 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00400 STDMETHODIMP CFPaper::CImpIClassFactory::CreateInstance(
00401                IUnknown* pUnkOuter,
00402                REFIID riid,
00403                PPVOID ppv)
00404 {
00405   HRESULT hr = E_POINTER;
00406   COPaper* pCob = NULL;
00407
00408   if (NULL != ppv)
00409   {
00410     // NULL the output pointer.
00411     *ppv = NULL;
00412     hr = E_FAIL;
00413
00414     // If the creation call is requesting aggregation (pUnkOuter != NULL),
00415     // the COM rules state the IUnknown interface MUST also be concomitantly
00416     // be requested.  If it is not so requested (riid != IID_IUnknown) then
00417     // an error must be returned indicating that no aggregate creation of
00418     // the CFPaper COM Object can be performed.
00419     if (NULL != pUnkOuter && riid != IID_IUnknown)
00420       hr = CLASS_E_NOAGGREGATION;
00421     else
00422     {
00423       if (m_pServer->ObjectFirst())
00424       {
00425         // Instantiate a COPaper COM Object.
00426         pCob = new COPaper(pUnkOuter, m_pServer);
00427         if (NULL != pCob)
00428         {
00429           // Create and initialize any subordinate objects.
00430           hr = pCob->Init();
00431           if (SUCCEEDED(hr))
00432           {
00433             // We successfully created the new COM object so tell the
00434             // server to increment its global server object count.
00435             m_pServer->ObjectsUp();
00436
00437             // We QueryInterface this new COM Object not only to deposit the
00438             // main interface pointer to the caller's pointer variable, but
00439             // to also automatically bump the Reference Count on the new COM
00440             // Object after handing out this reference to it.
00441             hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00442             if (SUCCEEDED(hr))
00443             {
00444               // Rig so that any subsequent creates get the same shared
00445               // single object.
00446               m_pServer->ObjectSet(pCob);
00447             }
00448             else
00449             {
00450               delete pCob;
00451               m_pServer->ObjectsDown();
00452             }
00453
00454           }
00455           else
00456             delete pCob;
00457         }
00458         else
00459           hr = E_OUTOFMEMORY;
00460       }
00461       else
00462         hr = m_pServer->ObjectQI(riid, ppv);
00463     }
00464   }
00465
00466   return hr;
00467 }
00468
00469
00470 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00471   Method:   CFPaper::CImpIClassFactory::LockServer
00472
00473   Summary:  The LockServer member method of this IClassFactory interface
00474             implementation.
00475
00476   Args:     BOOL bLock)
00477               [in] Flag determining whether to Lock or Unlock the server.
00478
00479   Returns:  HRESULT
00480               Standard result code. NOERROR for success.
00481 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00482 STDMETHODIMP CFPaper::CImpIClassFactory::LockServer(
00483                BOOL bLock)
00484 {
00485   HRESULT hr = NOERROR;
00486
00487   if (bLock)
00488     m_pServer->Lock();
00489   else
00490     m_pServer->Unlock();
00491
00492   return hr;
00493 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/rtcsample/rtcsession.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • rtcsample

rtcsession.h

Go to the documentation of this file.
00001 // rtcsession.h
00002 //
00003
00004 #ifndef _RTCSESSION_H_
00005 #define _RTCSESSION_H_
00006
00007 // Base class for session windows
00008 class CRTCSession
00009 {
00010 public:
00011     CRTCSession();
00012     ~CRTCSession();
00013
00014 protected:
00015
00016     friend class CRTCWin;
00017
00018     HWND m_hWnd;
00019     HWND m_hStatusBar;
00020
00021     IRTCSession * m_pSession;
00022     CRTCWin * m_pWin;
00023     RTC_SESSION_STATE m_enState;
00024
00025     // Helpers
00026     void ShowMessageBox(PWSTR szText);
00027     void SetStatusText(PWSTR szText);
00028
00029     // Window message handlers
00030     virtual LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam);
00031     virtual LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam);
00032     virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam);
00033     virtual LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam);
00034
00035     // Event handlers
00036     virtual HRESULT DeliverSessionState(RTC_SESSION_STATE enState);
00037     virtual HRESULT DeliverParticipantState(IRTCParticipant * pParticipant, RTC_PARTICIPANT_STATE enState);
00038     virtual HRESULT DeliverMessage(IRTCParticipant * pParticipant, BSTR bstrContentType, BSTR bstrMessage);
00039     virtual HRESULT DeliverUserStatus(IRTCParticipant * pParticipant, RTC_MESSAGING_USER_STATUS enStatus);
00040     virtual HRESULT DeliverMedia(long lMediaType, RTC_MEDIA_EVENT_TYPE enType, RTC_MEDIA_EVENT_REASON enReason);
00041     virtual HRESULT DeliverIntensity(RTC_AUDIO_DEVICE enDevice, long lLevel);
00042     virtual HRESULT DeliverClient(RTC_CLIENT_EVENT_TYPE enEventType);
00043 };
00044
00045 #endif //_RTCSESSION_H_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/UserEvents/VCAcct/StdAfx.cpp Source File

  • Com
  • Services
  • Events
  • UserEvents
  • VCAcct

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #include <initguid.h>
00008 #include <adoid.h>
00009 #include <adoint.h>
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
00017
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ERRORMAP Member List

This is the complete list of members for _ERRORMAP, including all inherited members.
hr | _ERRORMAP
pwszError | _ERRORMAP
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMDIFrameLite Member List

This is the complete list of members for CMDIFrameLite, including all inherited members.
CFrameWndLite() | CFrameWndLite |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CMDIFrameLite() | CMDIFrameLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, HICON hIcon, DWORD dwStyle=WS_OVERLAPPEDWINDOW, DWORD dwExStyle=WS_EX_APPWINDOW, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CFrameWndLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
FindWindow(WCHAR *pwszClassName=NULL) | CMDIFrameLite | [virtual]
GetActiveWindow(WCHAR *pwszClassName=NULL) | CMDIFrameLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CMDIFrameLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndMDIClient | CMDIFrameLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
MDIActivate(HWND hWnd) | CMDIFrameLite | [inline, virtual]
MDIDestroy(HWND hWnd) | CMDIFrameLite | [inline, virtual]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnAutoPosition() | CMDIFrameLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CFrameWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CMDIFrameLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CMDIFrameLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CMDIFrameLite | [virtual]
OnCreateClient(CREATESTRUCT *pCREATESTRUCT) | CMDIFrameLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CMDIFrameLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CMDIFrameLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnToolTip(INT idCtrl, NMHDR *pNMHDR) | CFrameWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CMDIFrameLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PreTranslateMessage(MSG *pmsg) | CMDIFrameLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CMDIFrameLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CFrameWndLite() | CFrameWndLite | [virtual]
~CMDIFrameLite() | CMDIFrameLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/PAPFILE.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

PAPFILE.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAPFILE.H
00003
00004   Summary:   Include file for the application's paper data file related
00005              classes. Declares the CPapFile C++ class. A CPapFile is a C++
00006              object that encapsulates load and save operations on a
00007              structured storage compound file.  CPapFile knows about an
00008              underlying server-based COM object, COPaper, that manages the
00009              actual paper drawing data and uses an IStorage provided
00010              to store and retrieve that paper drawing data.
00011
00012              For a comprehensive tutorial code tour of PAPFILE's contents
00013              and offerings see the tutorial STOCLIEN.HTM file. For
00014              more specific technical details on the internal workings see
00015              the comments dispersed throughout the PAPFILE source code.
00016
00017   Classes:   CPapFile.
00018
00019   Origin:    6-13-96: atrent - Created for STOCLIEN Code Sample.
00020
00021 ----------------------------------------------------------------------------
00022   This file is part of the Microsoft COM Tutorial Code Samples.
00023
00024   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00025
00026   This source code is intended only as a supplement to Microsoft
00027   Development Tools and/or on-line documentation.  See these other
00028   materials for detailed information regarding Microsoft code samples.
00029
00030   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00031   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00032   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00033   PARTICULAR PURPOSE.
00034 ==========================================================================+*/
00035
00036 #if !defined(PAPFILE_H)
00037 #define PAPFILE_H
00038
00039 #if defined(__cplusplus)
00040
00041
00042 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00043   Class:    CPapFile
00044
00045   Summary:  Class to encapsulate the paper data compound file.
00046
00047   Methods:  CPapFile
00048               Constructor.
00049             ~CPapFile
00050               Destructor.
00051             HRESULT Init(TCHAR* pszFileName, IPaper* pIPaper);
00052               Initialize CPapFile.
00053             HRESULT Load(SHORT nLockKey, TCHAR* pszFileName);
00054               Load default paper data file or a specified paper data file.
00055             HRESULT Save(SHORT nLockKey, TCHAR* pszFileName);
00056               Save drawing data to the current paper data file.
00057 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00058 class CPapFile
00059 {
00060   public:
00061     CPapFile(void);
00062     ~CPapFile(void);
00063     HRESULT Init(TCHAR* pszFileName, IPaper* pIPaper);
00064     HRESULT Load(SHORT nLockKey, TCHAR* pszFileName);
00065     HRESULT Save(SHORT nLockKey, TCHAR* pszFileName);
00066
00067   private:
00068     TCHAR          m_szCurFileName[MAX_PATH];
00069     IPaper*        m_pIPaper;
00070     IStorage*      m_pIStorage;
00071 };
00072
00073
00074 #endif // __cplusplus
00075
00076 #endif
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/statnode.h Source File

  • SysMgmt
  • MMC
  • Menubtn

statnode.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SNAPINBASE_H
00021 #define _SNAPINBASE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CStaticNode : public CDelegationBase {
00026 public:
00027     CStaticNode();
00028
00029     virtual ~CStaticNode();
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) {
00032         static _TCHAR szDisplayName[256];
00033         LoadString(g_hinst, IDS_SNAPINNAME, szDisplayName, (sizeof szDisplayName)/(sizeof szDisplayName[0]));
00034         return szDisplayName;
00035     }
00036     virtual const GUID & getNodeType() { return thisGuid; }
00037     virtual const int GetBitmapIndex() { return INDEX_NONE; }
00038
00039 public:
00040     // virtual functions go here (for MMCN_*)
00041     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00042
00043 private:
00044     enum { NUMBER_OF_CHILDREN = 4 };
00045     CDelegationBase *children[NUMBER_OF_CHILDREN];
00046
00047     // {2974380C-4C4B-11d2-89D8-000021473128}
00048     static const GUID thisGuid;
00049 };
00050
00051 #endif // _SNAPINBASE_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Property Member List

This is the complete list of members for msado15::Property, including all inherited members.
getAttributes() | msado15::Property |
getName() | msado15::Property |
getType() | msado15::Property |
getValue() | msado15::Property |
iid | msado15::Property | [static]
setAttributes(int plAttributes) | msado15::Property |
setValue(Variant pval) | msado15::Property |
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Printer/Resource.h Source File

  • Multimedia
  • Gdi
  • Printer

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Printer.RC
00004 //
00005 #define MAIN_ICON                       1
00006 #define IDS_ERR_PRINTER                 16
00007 #define IDS_ERR_PAINT                   17
00008 #define IDS_ERR_GETCAPS                 18
00009 #define IDS_ERR_GETPDRIV                19
00010 #define IDS_ERR_ENUMPRT                 20
00011 #define IDS_MAINWNDTITLE                21
00012 #define IDS_FMT_OPNPRTFAIL              22
00013 #define IDS_LALLOCFAIL                  23
00014 #define IDS_GETPRTDRVFAIL               24
00015 #define IDS_ASKDOMSRVNM                 25
00016 #define IDS_ENUMPRTLALLOCFAIL           26
00017 #define IDS_ENUMPRT1FAIL                27
00018 #define IDS_ENUMPRTDRVRET0              28
00019 #define IDS_FMT_MOREDSPFNTNL            29
00020 #define IDS_GETDCFAIL                   30
00021 #define IDS_FMT_CREDCFAIL               31
00022 #define IDS_ASKSELPRT                   32
00023 #define IDS_ENUMPRTFAIL                 33
00024 #define IDS_NOPRTLST                    34
00025 #define IDS_PRTDLGFAIL                  35
00026 #define IDS_PRTTST                      36
00027 #define IDS_BLANKPG                     37
00028 #define IDM_PRINT                       101
00029 #define IDM_PRINTDLG                    102
00030 #define IDM_GETDEVICECAPS               103
00031 #define IDM_ENUMPRINTERS                104
00032 #define IDM_GETPRINTERDRIVER            105
00033 #define IDM_ENUMPRINTERDRIVERS          106
00034 #define IDM_REFRESH                     107
00035 #define IDM_ABOUT                       108
00036 #define IDM_HIENGLISH                   201
00037 #define IDM_HIMETRIC                    202
00038 #define IDM_LOENGLISH                   203
00039 #define IDM_LOMETRIC                    204
00040 #define IDM_TWIPS                       205
00041 #define IDM_ISOTROPIC                   206
00042 #define IDM_ANISOTROPIC                 207
00043 #define IDM_TEXT                        208
00044 #define IDM_ARC                         301
00045 #define IDM_ELLIPSE                     302
00046 #define IDM_LINETO                      303
00047 #define IDM_PIE                         304
00048 #define IDM_PLGBLT                      305
00049 #define IDM_POLYBEZIER                  306
00050 #define IDM_POLYGON                     307
00051 #define IDM_POLYLINE                    308
00052 #define IDM_POLYPOLYGON                 309
00053 #define IDM_RECTANGLE                   310
00054 #define IDM_ROUNDRECT                   311
00055 #define IDM_STRETCHBLT                  312
00056 #define IDM_ALLGRAPHICS                 313
00057 #define IDM_NOGRAPHICS                  314
00058 #define IDM_ENUMFONTS                   315
00059 #define IDM_DRAWAXIS                    316
00060 #define IDM_SETPENCOLOR                 401
00061 #define IDM_PENWIDTH_1                  402
00062 #define IDM_PENWIDTH_2                  403
00063 #define IDM_PENWIDTH_3                  404
00064 #define IDM_PENWIDTH_4                  405
00065 #define IDM_PENWIDTH_5                  406
00066 #define IDM_PENWIDTH_6                  407
00067 #define IDM_PENWIDTH_7                  408
00068 #define IDM_PENWIDTH_8                  409
00069 #define IDM_PENCOLOR_SOLID              410
00070 #define IDM_PENCOLOR_DASH               411
00071 #define IDM_PENCOLOR_DOT                412
00072 #define IDM_PENCOLOR_DASHDOT            413
00073 #define IDM_PENCOLOR_DASHDOTDOT         414
00074 #define IDM_PENCOLOR_NULL               415
00075 #define IDM_PENCOLOR_INSIDEFRAME        416
00076 #define IDM_SETBRUSHCOLOR               501
00077 #define DID_OK                          501
00078 #define IDM_BRUSHSTYLE_HORIZONTAL       502
00079 #define DID_LISTBOX                     502
00080 #define IDM_BRUSHSTYLE_VERTICAL         503
00081 #define DID_CANCEL                      503
00082 #define IDM_BRUSHSTYLE_FDIAGONAL        504
00083 #define DID_EDITTEXT                    504
00084 #define IDM_BRUSHSTYLE_BDIAGONAL        505
00085 #define IDM_BRUSHSTYLE_CROSS            506
00086 #define IDM_BRUSHSTYLE_DIAGCROSS        507
00087 #define IDM_TEXTCOLOR                   601
00088 #define ID_COMBOBOX                     701
00089 #define IDM_EXIT                        40001
00090 #define IDC_STATIC                      -1
00091
00092 // Next default values for new objects
00093 //
00094 #ifdef APSTUDIO_INVOKED
00095 #ifndef APSTUDIO_READONLY_SYMBOLS
00096 #define _APS_NO_MFC                     1
00097 #define _APS_NEXT_RESOURCE_VALUE        101
00098 #define _APS_NEXT_COMMAND_VALUE         40002
00099 #define _APS_NEXT_CONTROL_VALUE         1000
00100 #define _APS_NEXT_SYMED_VALUE           102
00101 #endif
00102 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IHelloWorldVtbl Member List

This is the complete list of members for IHelloWorldVtbl, including all inherited members.
cNames | IHelloWorldVtbl
dispIdMember | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Say)(IHelloWorld __RPC_FAR *This) | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(IHelloWorld __RPC_FAR *This | IHelloWorldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Say)(IHelloWorld __RPC_FAR *This) | IHelloWorldVtbl
iTInfo | IHelloWorldVtbl
lcid | IHelloWorldVtbl
lcid | IHelloWorldVtbl
lcid | IHelloWorldVtbl
pctinfo | IHelloWorldVtbl
pDispParams | IHelloWorldVtbl
pExcepInfo | IHelloWorldVtbl
ppTInfo | IHelloWorldVtbl
ppvObject | IHelloWorldVtbl
puArgErr | IHelloWorldVtbl
pVarResult | IHelloWorldVtbl
rgDispId | IHelloWorldVtbl
rgszNames | IHelloWorldVtbl
riid | IHelloWorldVtbl
riid | IHelloWorldVtbl
riid | IHelloWorldVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(IHelloWorld __RPC_FAR *This) | IHelloWorldVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(IHelloWorld __RPC_FAR *This) | IHelloWorldVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(IHelloWorld __RPC_FAR *This) | IHelloWorldVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(IHelloWorld __RPC_FAR *This) | IHelloWorldVtbl
wFlags | IHelloWorldVtbl
Generated on Wed Nov 13 2024 16:57:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/VCAcct/Updatereceipt.h Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • VCAcct

Updatereceipt.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: UpdateReceipt.h
00003 //
00004 // Description: Declaration of UpdateReceipt
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022 #if !defined(AFX_UPDATERECEIPT_H__A81260B9_DDC8_11D0_B5A0_00C04FB957D8__INCLUDED_)
00023 #define AFX_UPDATERECEIPT_H__A81260B9_DDC8_11D0_B5A0_00C04FB957D8__INCLUDED_
00024
00025 #if _MSC_VER >= 1000
00026 #pragma once
00027 #endif // _MSC_VER >= 1000
00028
00029 #include "resource.h"       // main symbols
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // CUpdateReceipt
00033
00034 class CUpdateReceipt :
00035   public IDispatchImpl<IUpdateReceipt, &IID_IUpdateReceipt, &LIBID_ACCOUNT>,
00036   public ISupportErrorInfo,
00037   public CComObjectRoot,
00038   public CComCoClass<CUpdateReceipt,&CLSID_CUpdateReceipt>
00039 {
00040 public:
00041   CUpdateReceipt() {}
00042 BEGIN_COM_MAP(CUpdateReceipt)
00043   COM_INTERFACE_ENTRY(IDispatch)
00044   COM_INTERFACE_ENTRY(IUpdateReceipt)
00045   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00046 END_COM_MAP()
00047 //DECLARE_NOT_AGGREGATABLE(CUpdateReceipt)
00048 // Remove the comment from the line above if you don't want your object to
00049 // support aggregation.
00050
00051 DECLARE_REGISTRY_RESOURCEID(IDR_UpdateReceipt)
00052 // ISupportsErrorInfo
00053   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00054
00055 // IUpdateReceipt
00056 public:
00057   STDMETHOD (Update) (OUT long* plReceiptNo);
00058 };
00059
00060 #endif // !defined(AFX_UPDATERECEIPT_H__A81260B9_DDC8_11D0_B5A0_00C04FB957D8__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/pooleddata.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

pooleddata.h

Go to the documentation of this file.
00001 #ifndef __POOLEDDATA_H
00002 #define __POOLEDDATA_H
00003
00004 typedef struct tagFieldMetaData
00005 {
00006   DECLARE_FIXED_ALLOC(tagFieldMetaData);
00007 public:
00008   CString wszName;
00009   VARTYPE vt;
00010   bool bNull;
00011   short sqltype;
00012   short sqldatatype;
00013   WCHAR pData[MAX_FIELD_DATA_SIZE];
00014   unsigned long nDataLen;
00015   long nDataBindLen;
00016   short nScale;
00017   short nNullable;
00018 } FieldMetaData;
00019
00020 class CPooledData
00021 {
00022
00023 protected:
00024   CComPtr<IObjectContext> m_spObjectContext;
00025
00026   GUID m_txuow;
00027   BOOL m_bObjectPooled;
00028   BOOL m_bConstructed;
00029   BOOL m_bShouldEnlist;
00030
00031   CPooledData()
00032   {
00033     m_bConstructed = FALSE;
00034     m_bShouldEnlist = FALSE;
00035     m_txuow = GUID_NULL;
00036     m_bObjectPooled = FALSE;
00037   }
00038
00039   ~CPooledData()
00040   {
00041   }
00042
00043   STDMETHOD(ActivateData)(IObjectContext * pObjectContext)
00044   {
00045     //  should only do this when we are being activated in different
00046     //  tx units of work
00047     m_bShouldEnlist = FALSE;
00048
00049     if (!m_bObjectPooled)
00050       return S_OK;
00051
00052     HRESULT hr = S_OK;
00053     GUID txUOW = GUID_NULL;
00054     IObjectContextInfo  * pObjTx = NULL;
00055     hr = pObjectContext->QueryInterface(IID_IObjectContextInfo, (void **)&pObjTx);
00056     if (pObjTx)
00057     {
00058       pObjTx -> GetTransactionId (&txUOW);
00059       pObjTx -> Release();
00060     }
00061
00062     if (txUOW != m_txuow)
00063     {
00064       m_bShouldEnlist = TRUE;
00065       m_txuow = txUOW;
00066     }
00067     return hr;
00068   }
00069
00070   STDMETHODIMP ConstructData(IDispatch * pUnk)
00071   {
00072     if (!pUnk)
00073       return E_UNEXPECTED;
00074     HRESULT hr = E_FAIL;
00075     IObjectConstructString * pString = NULL;
00076     hr = pUnk -> QueryInterface(IID_IObjectConstructString, (void **)&pString);
00077     if (pString)
00078     {
00079       CComBSTR s;
00080       pString -> get_ConstructString(&s);
00081       m_bObjectPooled = TRUE;
00082       hr = ManualConstruct(s);
00083       pString -> Release();
00084     }
00085     return hr;
00086   }
00087
00088     virtual BOOL STDMETHODCALLTYPE CanConnectionBePooled(void)
00089   {
00090     return m_bObjectPooled;
00091   }
00092
00093   virtual HRESULT QueryEnlist(const CLSID &clsid, const IID &iid)
00094   {
00095     HRESULT hr = S_OK;
00096
00097     if (m_bShouldEnlist)
00098     {
00099       hr = Enlist(m_spObjectContext, clsid, iid);
00100       if (FAILED(hr))
00101       {
00102         SETABORT;
00103         hr = AtlReportError(clsid, (LPCSTR)"Failed to enlist in transaction", iid, hr);
00104       }
00105     }
00106     return hr;
00107   }
00108
00109   // The pure virtual elements that the derived class must provide
00110   STDMETHOD(ManualConstruct)(BSTR ConstructString) = 0;
00111     virtual void STDMETHODCALLTYPE DeactivateData(void) = 0;
00112   virtual HRESULT Enlist(IObjectContext * pObjectContext, const CLSID &clsid, const IID &iid) = 0;
00113 };
00114
00115 #endif
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/land.Cpp Source File

  • SysMgmt
  • MMC
  • CMenu

land.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Land.h"
00021
00022 const GUID CLandBasedVehicle::thisGuid = { 0x2974380e, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CLandBasedVehicle implementation
00027 //
00028 //
00029 HRESULT CLandBasedVehicle::OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed)
00030 {
00031     HRESULT hr = S_OK;
00032     CONTEXTMENUITEM menuItemsNew[] =
00033     {
00034         {
00035             L"Land based", L"Add a new land based vehicle",
00036                 IDM_NEW_LAND, CCM_INSERTIONPOINTID_PRIMARY_NEW, 0, CCM_SPECIAL_DEFAULT_ITEM
00037         },
00038         { NULL, NULL, 0, 0, 0 }
00039     };
00040
00041     // Loop through and add each of the menu items
00042     if (*pInsertionsAllowed & CCM_INSERTIONALLOWED_NEW)
00043     {
00044         for (LPCONTEXTMENUITEM m = menuItemsNew; m->strName; m++)
00045         {
00046             hr = pContextMenuCallback->AddItem(m);
00047
00048             if (FAILED(hr))
00049                 break;
00050         }
00051     }
00052
00053     return hr;
00054 }
00055
00056 HRESULT CLandBasedVehicle::OnMenuCommand(IConsole *pConsole, long lCommandID)
00057 {
00058     switch (lCommandID)
00059     {
00060     case IDM_NEW_LAND:
00061         pConsole->MessageBox(L"This sample does not create a new item\nSee Complete sample for a demonstration", L"Menu Command", MB_OK|MB_ICONINFORMATION, NULL);
00062         break;
00063     }
00064
00065     return S_OK;
00066 }
00067
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletRegistryKey Member List

This is the complete list of members for tagAppletRegistryKey, including all inherited members.
ostrResourceID | tagAppletRegistryKey
SessionKey | tagAppletRegistryKey
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/Eap/CeapCfg.h Source File

  • NetDS
  • RRas
  • Eap

CeapCfg.h

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1997 - 2000 Microsoft Corporation, all rights reserved
00004
00005 Description:
00006
00007 History:
00008
00009 */
00010
00011 #ifndef _CEAPCFG_H_
00012 #define _CEAPCFG_H_
00013
00014 #if _MSC_VER >= 1000
00015 #pragma once
00016 #endif // _MSC_VER >= 1000
00017
00018 #define _ATL_APARTMENT_THREADED
00019
00020 #include <atlbase.h>
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023 #include <rrascfg.h>    // IEAPProviderConfig declarations
00024
00025 #include "resource.h"
00026
00027 // Define this here so that our macros will expand correctly
00028 #define IMPL
00029
00030 // External references
00031 extern const CLSID  CLSID_EapCfg;
00032
00033 class ATL_NO_VTABLE CEapCfg :
00034     public CComObjectRootEx<CComSingleThreadModel>,
00035     public CComCoClass<CEapCfg, &CLSID_EapCfg>,
00036     public IEAPProviderConfig
00037 {
00038 public:
00039     CEapCfg()  {}
00040
00041 DECLARE_REGISTRY_RESOURCEID(IDR_EAPCFG)
00042 DECLARE_NOT_AGGREGATABLE(CEapCfg)
00043
00044 BEGIN_COM_MAP(CEapCfg)
00045     COM_INTERFACE_ENTRY(IEAPProviderConfig)
00046 END_COM_MAP()
00047
00048 public:
00049     // This is the declaration of the UI interface members.
00050     // See rrascfg.idl for the prototypes
00051     DeclareIEAPProviderConfigMembers(IMPL);
00052 };
00053
00054 #endif // _CEAPCFG_H_
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/AclApi/AclApi.c Source File

  • Security
  • Authorization
  • AclApi

AclApi.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010
00011     aclapi.c
00012
00013 Abstract:
00014
00015     This module illustrates new Acl management API for Windows NT 4.0.
00016
00017     Developers of new software which is to run on Windows NT version 4.0
00018     and above are encouraged to utilize these security API rather than
00019     implementing code which uses lower level security API.  The development
00020     and test time can be drastically reduced by utilizing these new API.
00021
00022     This sample illustrates this point by implementing code which modifies
00023     the security on an existing file using the new Windows NT 4.0
00024     Acl management API.
00025
00026
00027     The following new API functions are illustrated in this sample:
00028
00029     GetNamedSecurityInfo()
00030     BuildExplicitAccessWithName()
00031     SetEntriesInAcl()
00032     SetNamedSecurityInfo()
00033
00034     The following lower-level security API would have been used to achieve
00035     the same result:
00036
00037     LookupAccountName()
00038     InitializeSecurityDescriptor()
00039     InitializeAcl()
00040     GetSecurityDescriptorDacl()
00041     GetAclInformation()
00042     GetAce()
00043     SetSecurityDescriptorDacl()
00044     AddAce()
00045     AddAccessAllowedAce() / AddAccessDeniedAce()
00046     GetFileSecurity()
00047     SetFileSecurity()
00048
00049     Less code and less complex code is required to achieve this task using
00050     the new Windows NT 4.0 Acl management API.
00051
00052 --*/
00053
00054 #include <windows.h>
00055 #include <aclapi.h>
00056 #include <lmerr.h>
00057
00058 #include <stdio.h>
00059
00060 #define RTN_OK 0
00061 #define RTN_USAGE 1
00062 #define RTN_ERROR 13
00063
00064 void
00065 DisplayLastError(
00066     LPSTR szAPI
00067     );
00068
00069 int
00070 __cdecl
00071 main(
00072     int argc,
00073     char *argv[]
00074     )
00075 {
00076     LPTSTR FileName;
00077     LPTSTR TrusteeName;
00078
00079     DWORD AccessMask = GENERIC_ALL;
00080     DWORD InheritFlag = NO_INHERITANCE;
00081     ACCESS_MODE option;
00082     EXPLICIT_ACCESS explicitaccess;
00083
00084     PACL ExistingDacl;
00085     PACL NewAcl = NULL;
00086     PSECURITY_DESCRIPTOR psd = NULL;
00087
00088     DWORD dwError;
00089     BOOL bSuccess = FALSE; // assume failure
00090
00091     if(argc < 4) {
00092         printf("Usage: %s <filename> {/Deny | /Grant | /Revoke | /Set} [<trustee>] [<permissions>] [<InheritFlag>]\n", argv[0]);
00093         return RTN_USAGE;
00094     }
00095
00096     FileName = argv[1];
00097     TrusteeName = argv[3];
00098
00099     if ( (0 == stricmp(argv[2], "/Deny") ) ||
00100         (0 == stricmp(argv[2], "/D") ) )
00101     {
00102       option = DENY_ACCESS;
00103     } else if ( ( (0 == stricmp(argv[2], "/Revoke") ) ||
00104                  (0 == stricmp(argv[2], "/R") ) ) )
00105     {
00106       option = REVOKE_ACCESS;
00107     } else if ( (0 == stricmp(argv[2], "/Set") ) ||
00108                (0 == stricmp(argv[2], "/S") ) )
00109     {
00110       option = SET_ACCESS;
00111     } else if ( (0 == stricmp(argv[2], "/Grant") ) ||
00112                (0 == stricmp(argv[2], "/G") ) )
00113     {
00114       option = GRANT_ACCESS;
00115     } else {
00116         printf("Invalid action specified\n");
00117         return RTN_ERROR;
00118     }
00119
00120     if (argc > 4)
00121     {
00122         AccessMask = atol( argv[4] );
00123     }
00124
00125     if (argc > 5)
00126     {
00127        InheritFlag = atol( argv[5] );
00128     }
00129
00130     //
00131     // get current Dacl on specified file
00132     //
00133
00134     dwError = GetNamedSecurityInfo(
00135                         FileName,
00136                         SE_FILE_OBJECT,
00137                         DACL_SECURITY_INFORMATION,
00138                         NULL,
00139                         NULL,
00140                         &ExistingDacl,
00141                         NULL,
00142                         &psd
00143                         );
00144
00145     if(dwError != ERROR_SUCCESS) {
00146         DisplayLastError("GetNamedSecurityInfo");
00147         return RTN_ERROR;
00148     }
00149
00150     BuildExplicitAccessWithName(
00151             &explicitaccess,
00152             TrusteeName,
00153             AccessMask,
00154             option,
00155             InheritFlag
00156             );
00157
00158     //
00159     // add specified access to the object
00160     //
00161
00162     dwError = SetEntriesInAcl(
00163             1,
00164             &explicitaccess,
00165             ExistingDacl,
00166             &NewAcl
00167             );
00168
00169     if(dwError != ERROR_SUCCESS) {
00170         DisplayLastError("SetEntriesInAcl");
00171         goto cleanup;
00172     }
00173
00174     //
00175     // apply new security to file
00176     //
00177
00178     dwError = SetNamedSecurityInfo(
00179                     FileName,
00180                     SE_FILE_OBJECT, // object type
00181                     DACL_SECURITY_INFORMATION,
00182                     NULL,
00183                     NULL,
00184                     NewAcl,
00185                     NULL
00186                     );
00187
00188     if(dwError != ERROR_SUCCESS) {
00189         DisplayLastError("SetNamedSecurityInfo");
00190         goto cleanup;
00191     }
00192
00193     bSuccess = TRUE; // indicate success
00194
00195 cleanup:
00196
00197     if( NewAcl != NULL ) AccFree( NewAcl );
00198     if( psd != NULL) AccFree( psd );
00199
00200
00201     if(!bSuccess)
00202         return RTN_ERROR;
00203
00204     return RTN_OK;
00205 }
00206
00207 void
00208 DisplayLastError(
00209     LPSTR szAPI
00210     )
00211 {
00212     HMODULE hModule = NULL; // default to system source
00213     DWORD dwLastError = GetLastError();
00214     LPSTR MessageBuffer;
00215     DWORD dwBufferLength;
00216
00217     DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
00218         FORMAT_MESSAGE_IGNORE_INSERTS |
00219         FORMAT_MESSAGE_FROM_SYSTEM ;
00220
00221     //
00222     // if dwLastError is in the network range, load the message source
00223     //
00224
00225     if(dwLastError >= NERR_BASE && dwLastError <= MAX_NERR) {
00226         hModule = LoadLibraryEx(
00227             TEXT("netmsg.dll"),
00228             NULL,
00229             LOAD_LIBRARY_AS_DATAFILE
00230             );
00231
00232         if(hModule != NULL)
00233             dwFormatFlags |= FORMAT_MESSAGE_FROM_HMODULE;
00234     }
00235
00236     printf("%s error! (rc=%lu)\n", szAPI, dwLastError);
00237
00238     //
00239     // call FormatMessage() to allow for message text to be acquired
00240     // from the system or the supplied module handle
00241     //
00242
00243     if(dwBufferLength = FormatMessageA(
00244         dwFormatFlags,
00245         hModule, // module to get message from (NULL == system)
00246         dwLastError,
00247         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
00248         (LPSTR) &MessageBuffer,
00249         0,
00250         NULL
00251         ))
00252     {
00253         DWORD dwBytesWritten;
00254
00255         //
00256         // Output message string on stderr
00257         //
00258         WriteFile(
00259             GetStdHandle(STD_ERROR_HANDLE),
00260             MessageBuffer,
00261             dwBufferLength,
00262             &dwBytesWritten,
00263             NULL
00264             );
00265
00266         //
00267         // free the buffer allocated by the system
00268         //
00269         LocalFree(MessageBuffer);
00270     }
00271
00272     //
00273     // if we loaded a message source, unload it
00274     //
00275     if(hModule != NULL)
00276         FreeLibrary(hModule);
00277 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/onaddequipment.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

onaddequipment.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  OnAddEquipment.cpp
00006 //
00007 // Description:
00008 //  This file implements the OnAddEquipment() routine which
00009 //    demonstrates how to create new classes and instances.
00010 //
00011 // History:
00012 //
00013 // **************************************************************************
00014
00015 #include "stdafx.h"
00016 #include "AdvClientDlg.h"
00017 #include "OfficeDlg.h"
00018
00019 #define TIMEOUT -1
00020
00021 // **************************************************************************
00022 //
00023 //  CAdvClientDlg::GetCompSysRef()
00024 //
00025 // Description:
00026 //    Gets the name of the computer so that office equipment can be
00027 //    associated with it.
00028 // Parameters:
00029 //    v (out) - ptr to variant receiving the computer name.
00030 //
00031 // Returns:
00032 //    S_OK if succcessful, otherwise the HRESULT of the failed called.
00033 //
00034 // Globals accessed:
00035 //    None.
00036 //
00037 // Globals modified:
00038 //    None.
00039 //
00040 //===========================================================================
00041 HRESULT CAdvClientDlg::GetCompSysRef(VARIANT *v)
00042 {
00043   // these are for enumerating.
00044   DWORD uReturned;
00045   HRESULT  hRes;
00046   IWbemClassObject *pCompSys = NULL;
00047   IEnumWbemClassObject *pEnumCompSys = NULL;
00048
00049   // these help get properties.
00050   BSTR propName = SysAllocString(L"__PATH");
00051   if (!propName)
00052   {
00053     return E_OUTOFMEMORY;
00054   }
00055
00056   // here's what we're looking for.
00057   // NOTE: make sure you specify a class that has a Provider()
00058   //  specified for it in the mof file. All other classes are
00059   //  abstract and wont be found using HMM_FLAG_SHALLOW. They
00060   //  will be found using HMM_FLAG_DEEP.
00061   BSTR className = SysAllocString(L"Win32_ComputerSystem");
00062   if (!className)
00063   {
00064     SysFreeString(propName);
00065     return E_OUTOFMEMORY;
00066   }
00067
00068   TRACE(_T("Going for class\n"));
00069
00070   // get the list of the computerSystems. There should only be one.
00071     if ((hRes = m_pIWbemServices->CreateInstanceEnum(className,
00072                         WBEM_FLAG_SHALLOW,
00073                         NULL,
00074                         &pEnumCompSys)) == S_OK)
00075   {
00076     TRACE(_T("good enumerator\n"));
00077
00078     // No need to actually loop since there should only be one instance
00079     // of 'Win32_ComputerSystem'.
00080     if(((hRes = pEnumCompSys->Next(TIMEOUT,
00081                   1,
00082                   &pCompSys,
00083                   &uReturned)) == S_OK) &&
00084        (uReturned == 1))
00085     {
00086
00087       TRACE(_T("Got a device class\n"));
00088
00089
00090       // Add the path
00091       if ((hRes = pCompSys->Get(propName, 0L,
00092                 v, NULL, NULL)) == S_OK)
00093       {
00094         TRACE(_T("Got the computer name %s\n"), V_BSTR(v));
00095       }
00096       else
00097       {
00098         TRACE(_T("Get() comp name: %s\n"), ErrorString(hRes));
00099       } // endif Get()
00100
00101       // Done with this object.
00102       if (pCompSys)
00103       {
00104         pCompSys->Release();
00105         pCompSys = NULL;
00106       }
00107     }
00108     else
00109     {
00110       TRACE(_T("done looking up comp name: %s\n"), ErrorString(hRes));
00111     } // endif Next()
00112
00113     // Done with the enumerator.
00114     if (pEnumCompSys)
00115     {
00116       pEnumCompSys->Release();
00117       pEnumCompSys = NULL;
00118     }
00119     }
00120   else // CreateInstanceEnum() failed.
00121   {
00122     TRACE(_T("CreateInstanceEnum() failed: %s\n"), ErrorString(hRes));
00123
00124   } // endif CreateInstanceEnum()
00125
00126   SysFreeString(propName);
00127
00128   TRACE(_T("returning\n"));
00129
00130   return hRes;
00131 }
00132
00133 // **************************************************************************
00134 //
00135 //  CAdvClientDlg::AssociateToMachine()
00136 //
00137 // Description:
00138 //    Creates an association between the machine and the office equipment.
00139 // Parameters:
00140 //    pEquipInst (in) - the equipment to be associated.
00141 //
00142 // Returns:
00143 //    HRESULT.
00144 //
00145 // Globals accessed:
00146 //    None.
00147 //
00148 // Globals modified:
00149 //    None.
00150 //
00151 //===========================================================================
00152 HRESULT CAdvClientDlg::AssociateToMachine(IWbemClassObject *pEquipInst)
00153 {
00154   IWbemClassObject *pAClass = NULL;
00155   IWbemClassObject *pAInst = NULL;
00156   IWbemQualifierSet *pQual = NULL;
00157
00158   VARIANT v, vTRUE, ref, def;
00159   VariantInit(&v);
00160   VariantInit(&vTRUE);
00161   VariantInit(&ref);
00162   VariantInit(&def);
00163
00164   HRESULT hRes = S_OK;
00165
00166   BSTR AssocClassName = NULL;
00167   BSTR EquipProp = NULL;
00168   BSTR CompProp = NULL;
00169   BSTR PathProp = NULL;
00170   BSTR Key = NULL;
00171   BSTR CimType = NULL;
00172   BSTR Class = NULL;
00173
00174   EquipProp = SysAllocString(L"Equipment");
00175   if (!EquipProp)
00176     goto OutOfMemory;
00177
00178   CompProp = SysAllocString(L"ComputerSystem");
00179   if (!CompProp)
00180     goto OutOfMemory;
00181
00182   AssocClassName = SysAllocString(L"SAMPLE_EquipmentToSystem");
00183   if (!AssocClassName)
00184     goto OutOfMemory;
00185
00186   // if association class doesn't exist yet...
00187   hRes = m_pOfficeService->GetObject(AssocClassName,
00188                     0L, NULL,
00189                     &pAClass,
00190                     NULL);
00191
00192   SysFreeString(AssocClassName);
00193   if(hRes != S_OK)
00194   {
00195     // create new class. Parm1 == NULL gives a new, empty
00196     // class to load with property values.
00197     if((hRes = m_pOfficeService->GetObject(NULL, 0, NULL,
00198                       &pAClass, NULL)) == S_OK)
00199     {
00200       //-----------------------------------
00201       // name the class.
00202       V_VT(&v) = VT_BSTR;
00203       V_BSTR(&v) = SysAllocString(L"SAMPLE_EquipmentToSystem");
00204       if (!V_BSTR(&v))
00205         goto OutOfMemory;
00206
00207
00208       Class = SysAllocString(L"__CLASS");
00209       if (!Class)
00210         goto OutOfMemory;
00211
00212       pAClass->Put(Class, 0, &v, 0);
00213       SysFreeString(Class);
00214       VariantClear(&v);
00215
00216       //-----------------------------------
00217       // make it an association.
00218       pAClass->GetQualifierSet(&pQual);
00219
00220       BSTR assoc = SysAllocString(L"Association");
00221       if (!assoc)
00222         goto OutOfMemory;
00223
00224
00225       V_VT(&vTRUE) = VT_BOOL;
00226       V_BOOL(&vTRUE) = VARIANT_TRUE;
00227
00228       pQual->Put(assoc, &vTRUE, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
00229                 WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS);
00230
00231       // cleanup.
00232       SysFreeString(assoc);
00233       pQual->Release();
00234       pQual = NULL;
00235
00236       //-----------------------------------
00237       // common stuff for properties
00238       Key = SysAllocString(L"Key");
00239       CimType = SysAllocString(L"CIMTYPE");
00240       if (!Key || ! CimType)
00241         goto OutOfMemory;
00242
00243       V_VT(&def) = VT_BSTR;
00244       V_BSTR(&def) = SysAllocString(L"");
00245       if (!V_BSTR(&def))
00246         goto OutOfMemory;
00247
00248       //-----------------------------------
00249       // create the equipment property.
00250       pAClass->Put(EquipProp, 0, &def, 0);
00251
00252       // make it a key.
00253       pAClass->GetPropertyQualifierSet(EquipProp, &pQual);
00254       pQual->Put(Key, &vTRUE, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
00255                 WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS);
00256
00257       // make it a strongly typed reference.
00258       V_VT(&ref) = VT_BSTR;
00259       V_BSTR(&ref) = SysAllocString(L"REF:SAMPLE_OfficeEquipment");
00260       if (!V_BSTR(&ref))
00261         goto OutOfMemory;
00262       pQual->Put(CimType, &ref, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
00263                 WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS);
00264
00265       // cleanup the property specific stuff.
00266       VariantClear(&ref);
00267       pQual->Release();
00268       pQual = NULL;
00269
00270       //-----------------------------------
00271       // 'ComputerSystem' is the other key property.
00272       pAClass->Put(CompProp, 0, &def, 0);
00273
00274       // make it a key.
00275       pAClass->GetPropertyQualifierSet(CompProp, &pQual);
00276       pQual->Put(Key, &vTRUE, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
00277                 WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS);
00278
00279       // make it a strongly typed reference.
00280       V_VT(&ref) = VT_BSTR;
00281       V_BSTR(&ref) = SysAllocString(L"REF:Win32_ComputerSystem");
00282       if (!V_BSTR(&ref))
00283         goto OutOfMemory;
00284       pQual->Put(CimType, &ref, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
00285                 WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS);
00286
00287       // cleanup the property specific stuff.
00288       VariantClear(&ref);
00289       pQual->Release();
00290       pQual = NULL;
00291
00292       //-----------------------------------
00293       // cleanup the common stuff too.
00294       SysFreeString(Key);
00295       SysFreeString(CimType);
00296       VariantClear(&v);
00297       VariantClear(&vTRUE);
00298       VariantClear(&def);
00299
00300       //-----------------------------------
00301       // register new class
00302       if((hRes = m_pOfficeService->PutClass(pAClass,
00303                         0, NULL, NULL)) != S_OK)
00304       {
00305         TRACE(_T("Second PutClass() failed: %s\n"), ErrorString(hRes));
00306       }
00307
00308       pAClass->Release();
00309       pAClass = NULL;
00310     }
00311     else
00312     {
00313       TRACE(_T("GetObject() NULL failed: %s\n"), ErrorString(hRes));
00314     }
00315
00316     // NOTE: now pAClass exists for sure but you have to go get a new pointer
00317     //  from CIMOM before you can spawnInstance() on it. You CANNOT continue to use
00318     //   the pAClass ptr from above.
00319     AssocClassName = SysAllocString(L"SAMPLE_EquipmentToSystem");
00320     if (!AssocClassName)
00321       goto OutOfMemory;
00322
00323     hRes = m_pOfficeService->GetObject(AssocClassName,
00324                         0L, NULL,
00325                         &pAClass,
00326                         NULL);
00327     SysFreeString(AssocClassName);
00328     if(hRes != S_OK)
00329     {
00330       TRACE(_T("Second GetObject() failed: %s\n"), ErrorString(hRes));
00331     } //endif GetObject()
00332
00333   } // endif class doesnt exist.
00334
00335   ASSERT(pAClass);
00336
00337   // spawn a new instance.
00338   if((hRes = pAClass->SpawnInstance(0, &pAInst)) == S_OK)
00339   {
00340     TRACE(_T("Assoc SpawnInstance() worked\n"));
00341
00342     PathProp = SysAllocString(L"__PATH");
00343     if (!PathProp)
00344       goto OutOfMemory;
00345
00346     //-----------------------------------
00347     // set equipment reference
00348     if ((hRes = pEquipInst->Get(PathProp, 0L,
00349               &v, NULL, NULL)) == S_OK)
00350     {
00351       TRACE(_T("Got equipment ref\n"));
00352       pAInst->Put(EquipProp, 0, &v, 0);
00353       VariantClear(&v);
00354     }
00355     else
00356     {
00357       TRACE(_T("Get() equipment ref failed: %s\n"), ErrorString(hRes));
00358     } //endif Get()
00359
00360     SysFreeString(PathProp);
00361
00362     //-----------------------------------
00363     // set ComputerSystem reference
00364     if ((hRes = GetCompSysRef(&v)) == S_OK)
00365     {
00366       TRACE(_T("Got the ComputerSystem ref\n"));
00367       pAInst->Put(CompProp, 0, &v, 0);
00368       VariantClear(&v);
00369     }
00370     else
00371     {
00372       TRACE(_T("Get() compSys ref failed: %s\n"), ErrorString(hRes));
00373     } //endif Get()
00374
00375     //-----------------------------------
00376     // putInstance
00377     hRes = m_pOfficeService->PutInstance(pAInst, 0, NULL, NULL);
00378     pAInst->Release();
00379     pAInst = NULL;
00380   }
00381   else
00382   {
00383     TRACE(_T("SpawnInstance() failed: %s\n"), ErrorString(hRes));
00384
00385   } //endif SpawnInstance()
00386
00387   pAClass->Release();  // Don't need the class any more
00388   pAClass = NULL;
00389
00390   SysFreeString(EquipProp);
00391   SysFreeString(CompProp);
00392
00393   return hRes;
00394
00395 OutOfMemory:
00396   SysFreeString(EquipProp);
00397   SysFreeString(CompProp);
00398   SysFreeString(PathProp);
00399   SysFreeString(AssocClassName);
00400   SysFreeString(Key);
00401   SysFreeString(CimType);
00402   SysFreeString(Class);
00403
00404   if (pAClass)
00405   {
00406     pAClass->Release();
00407   }
00408   if (pAInst)
00409   {
00410     pAInst->Release();
00411   }
00412   if (pQual)
00413   {
00414     pQual->Release();
00415   }
00416
00417   VariantClear(&v);
00418   VariantClear(&vTRUE);
00419   VariantClear(&ref);
00420   VariantClear(&def);
00421
00422   TRACE(_T("Not enough memory"));
00423
00424   return E_OUTOFMEMORY;
00425
00426
00427 }
00428 // **************************************************************************
00429 //
00430 //  CAdvClientDlg::OnAddEquipment()
00431 //
00432 // Description:
00433 //    Creates an SAMPLE_OfficeEquipment if necessary. Creates an OfficeEquipment
00434 //    instance. Associates the instance with the machine's instance.
00435 // Parameters:
00436 //    pEquipInst (in) - the equipment to be associated.
00437 //
00438 // Returns:
00439 //    nothing.
00440 //
00441 // Globals accessed:
00442 //    None.
00443 //
00444 // Globals modified:
00445 //    None.
00446 //
00447 //===========================================================================
00448 void CAdvClientDlg::OnAddEquipment()
00449 {
00450   IWbemClassObject *pEquipClass = NULL;
00451   IWbemClassObject *pEquipInst = NULL;
00452   IEnumWbemClassObject *pEnumEquipment = NULL;
00453
00454   HRESULT hRes;
00455   CString buf;
00456   BSTR Prop = NULL;
00457   BSTR curInst = NULL;
00458   VARIANT v;
00459   DWORD uReturned;
00460
00461   //allocate some strings
00462
00463   COfficeDlg dlg;
00464
00465   VariantInit(&v);
00466   m_outputList.ResetContent();
00467   m_outputList.AddString(_T("working..."));
00468
00469   // collect office equipment info.
00470   dlg.DoModal();
00471
00472   // switch to the root\cimv2\office namespace.
00473   if(EnsureOfficeNamespace())
00474   {
00475     // the namespace exists now, allow user to register for its events.
00476     m_perm.EnableWindow(TRUE);
00477     m_temp.EnableWindow(TRUE);
00478
00479     BSTR EquipClassName = SysAllocString(L"SAMPLE_OfficeEquipment");
00480     if (!EquipClassName)
00481     {
00482       TRACE(_T("Not enough memory: SysAllocString failed"));
00483       return;
00484     }
00485
00486     // if class doesn't exist yet...
00487     if((hRes = m_pOfficeService->GetObject(EquipClassName,
00488                       0L, NULL,
00489                       &pEquipClass,
00490                       NULL)) != S_OK)
00491     {
00492
00493       //-----------------------------------
00494       // create new class. Parm1 == NULL gives a new, empty
00495       // class to load with property values.
00496       if((hRes = m_pOfficeService->GetObject(NULL, 0, NULL,
00497                         &pEquipClass, NULL)) == S_OK)
00498       {
00499
00500         // name the class.
00501         V_VT(&v) = VT_BSTR;
00502         V_BSTR(&v) = EquipClassName;
00503
00504         BSTR  Class = SysAllocString(L"__CLASS");
00505         if (!Class)
00506         {
00507           pEquipClass->Release();
00508           SysFreeString(EquipClassName);
00509           TRACE(_T("Not enough memory: SysAllocString failed"));
00510           return;
00511         }
00512         pEquipClass->Put(Class, 0, &v, 0);
00513         SysFreeString(Class);
00514         VariantClear(&v);
00515
00516         // 'SKU' is the key property
00517         V_VT(&v) = VT_BSTR;
00518
00519         BSTR Default = SysAllocString(L"<default>");
00520         if (!Default)
00521         {
00522           pEquipClass->Release();
00523           SysFreeString(EquipClassName);
00524           TRACE(_T("Not enough memory: SysAllocString failed"));
00525           return;
00526         }
00527
00528         V_BSTR(&v) = Default;
00529
00530         Prop = SysAllocString(L"SKU");
00531         if (!Prop)
00532         {
00533           pEquipClass->Release();
00534           SysFreeString(EquipClassName);
00535           TRACE(_T("Not enough memory: SysAllocString failed"));
00536           return;
00537         };
00538         pEquipClass->Put(Prop, 0, &v, 0);
00539         VariantClear(&v);
00540
00541         // Mark the "OfficeNum" property as the 'key'.
00542         IWbemQualifierSet *pQual = NULL;
00543         if (FAILED(pEquipClass->GetPropertyQualifierSet(Prop, &pQual)))
00544         {
00545           pEquipClass->Release();
00546           SysFreeString(EquipClassName);
00547           TRACE(_T("Failed to get qualifier set"));
00548           return;
00549         }
00550         V_VT(&v) = VT_BOOL;
00551         V_BOOL(&v) = VARIANT_TRUE;
00552         BSTR Key = SysAllocString(L"Key");
00553         if (!Key)
00554         {
00555           pQual->Release();
00556           pEquipClass->Release();
00557           SysFreeString(EquipClassName);
00558           TRACE(_T("Not enough memory: SysAllocString failed"));
00559           return;
00560         }
00561
00562         // NOTE: Qualifier flavors not required for KEY
00563         pQual->Put(Key,
00564               &v,
00565               WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
00566               WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS);
00567         SysFreeString(Key);
00568
00569         // No longer need the qualifier set for "SKU".
00570         pQual->Release();
00571         VariantClear(&v);
00572
00573         // add description of item.
00574         V_VT(&v) = VT_BSTR;
00575         V_BSTR(&v) = SysAllocString(L"<default>");
00576         if (!V_BSTR(&v))
00577         {
00578           pEquipClass->Release();
00579           SysFreeString(EquipClassName);
00580           TRACE(_T("Not enough memory: SysAllocString failed"));
00581           return;
00582         }
00583
00584         SysFreeString(Prop);
00585         Prop = SysAllocString(L"Item");
00586         if (!Prop)
00587         {
00588           pEquipClass->Release();
00589           SysFreeString(EquipClassName);
00590           TRACE(_T("Not enough memory: SysAllocString failed"));
00591           return;
00592         };
00593
00594         pEquipClass->Put(Prop, 0, &v, 0);
00595         SysFreeString(Prop);
00596
00597         // register new class
00598         if((hRes = m_pOfficeService->PutClass(pEquipClass, 0, NULL, NULL)) != S_OK)
00599         {
00600           TRACE(_T("equipment PutClass() failed: %s\n"), ErrorString(hRes));
00601         }
00602
00603         pEquipClass->Release();
00604         pEquipClass = NULL;
00605
00606         //-----------------------------------
00607         // NOTE: now pEquipClass exists for sure but you have to go get a new pointer
00608         //  from CIMOM before you can spawnInstance() on it. You CANNOT continue to use
00609         //   the pEquipClass ptr from above.
00610         if((hRes = m_pOfficeService->GetObject(EquipClassName,
00611                             0L, NULL,
00612                             &pEquipClass,
00613                             NULL)) != S_OK)
00614         {
00615           TRACE(_T("Second GetObject() failed: %s\n"), ErrorString(hRes));
00616         } //endif GetObject()
00617       }
00618       else
00619       {
00620         TRACE(_T("GetObject() NULL failed: %s\n"), ErrorString(hRes));
00621       } //endif GetObject() NULL
00622
00623     } // endif class doesnt exist.
00624     VariantClear(&v);
00625
00626
00627     //-----------------------------------
00628     // spawn a new instance
00629     if((hRes = pEquipClass->SpawnInstance(0, &pEquipInst)) == S_OK)
00630     {
00631       TRACE(_T("SpawnInstance() worked\n"));
00632
00633       // set the property values
00634       V_VT(&v) = VT_BSTR;
00635       V_BSTR(&v) = dlg.m_item.AllocSysString();
00636       if (!V_BSTR(&v))
00637       {
00638         pEquipClass->Release();
00639         pEquipInst->Release();
00640
00641         SysFreeString(EquipClassName);
00642         TRACE(_T("Not enough memory: SysAllocString failed"));
00643         return;
00644       }
00645       Prop = SysAllocString(L"Item");
00646       if (!Prop)
00647       {
00648         VariantClear(&v);
00649         pEquipClass->Release();
00650         pEquipInst->Release();
00651
00652         SysFreeString(EquipClassName);
00653         TRACE(_T("Not enough memory: SysAllocString failed"));
00654         return;
00655       };
00656       pEquipInst->Put(Prop, 0, &v, 0);
00657       VariantClear(&v);
00658
00659       V_VT(&v) = VT_BSTR;
00660       V_BSTR(&v) = dlg.m_SKU.AllocSysString();
00661       if (!V_BSTR(&v))
00662       {
00663         pEquipClass->Release();
00664         pEquipInst->Release();
00665
00666         SysFreeString(EquipClassName);
00667         VariantClear(&v);
00668         TRACE(_T("Not enough memory: SysAllocString failed"));
00669         return;
00670       }
00671       Prop = SysAllocString(L"SKU");
00672       if (!Prop)
00673       {
00674         pEquipClass->Release();
00675         pEquipInst->Release();
00676
00677         SysFreeString(EquipClassName);
00678         VariantClear(&v);
00679         TRACE(_T("Not enough memory: SysAllocString failed"));
00680         return;
00681       };
00682       pEquipInst->Put(Prop, 0, &v, 0);
00683       VariantClear(&v);
00684
00685       // putInstance
00686       hRes = m_pOfficeService->PutInstance(pEquipInst, 0, NULL, NULL);
00687
00688       pEquipInst->Release();
00689       pEquipInst = NULL;
00690
00691       CString str("SAMPLE_OfficeEquipment.SKU=\"");
00692       str += dlg.m_SKU;
00693       str += _T("\"");
00694
00695       curInst = str.AllocSysString();
00696       if (!curInst)
00697       {
00698         pEquipClass->Release();
00699         pEquipInst->Release();
00700
00701         SysFreeString(EquipClassName);
00702         TRACE(_T("Not enough memory: SysAllocString failed"));
00703         return;
00704       };
00705
00706       TRACE(_T("flushing instance for %s\n"), str);
00707
00708       if((hRes = m_pOfficeService->GetObject(curInst,
00709                           0L, NULL,
00710                           &pEquipInst,
00711                           NULL)) != S_OK)
00712       {
00713         TRACE(_T("Second GetObject() pEquipInst failed: %s\n"), ErrorString(hRes));
00714       } //endif GetObject()
00715
00716       SysFreeString(Prop);
00717       SysFreeString(curInst);
00718
00719       //-----------------------------------
00720       // make the association.
00721       hRes = AssociateToMachine(pEquipInst);
00722       if (FAILED(hRes))
00723       {
00724         TRACE(_T("AssociateToMachine() failed: %s\n"), ErrorString(hRes));
00725       }
00726
00727       pEquipInst->Release();
00728       pEquipInst = NULL;
00729     }
00730     else
00731     {
00732       TRACE(_T("SpawnInstance() failed: %s\n"), ErrorString(hRes));
00733
00734     } //endif SpawnInstance()
00735
00736     pEquipClass->Release();  // Don't need the class any more
00737     pEquipClass = NULL;
00738
00739     //-----------------------------------
00740     // enum the office equipment for display purposes.
00741     if ((hRes = m_pOfficeService->CreateInstanceEnum(EquipClassName,
00742                           WBEM_FLAG_SHALLOW,
00743                           NULL,
00744                           &pEnumEquipment)) == S_OK)
00745     {
00746       TRACE(_T("good equip enum\n"));
00747       SysFreeString(EquipClassName);
00748
00749
00750       m_outputList.ResetContent();
00751
00752       uReturned = 1;
00753       while(uReturned == 1)
00754       {
00755         // enumerate through the resultset.
00756         hRes = pEnumEquipment->Next(TIMEOUT,
00757                       1,
00758                       &pEquipInst,
00759                       &uReturned);
00760
00761         TRACE(_T("Next() %d:%s\n"), uReturned, ErrorString(hRes));
00762
00763         // was one found?
00764         if((hRes == S_OK) && (uReturned == 1))
00765         {
00766           TRACE(_T("Got a device class\n"));
00767
00768           // Get the "SKU" property.
00769           VariantClear(&v);
00770           SysFreeString(Prop);
00771           Prop = SysAllocString(L"SKU");
00772           if (!Prop)
00773           {
00774             pEnumEquipment->Release();
00775             pEquipInst->Release();
00776             TRACE(_T("Not enough memory: SysAllocString failed"));
00777             return;
00778           }
00779
00780           if (pEquipInst->Get(Prop, 0L,
00781                     &v, NULL, NULL) == S_OK)
00782           {
00783             TRACE(_T("Got the SKU\n"));
00784              buf = V_BSTR(&v);
00785             buf += _T("=>");
00786           }
00787
00788           // Get the "Item" property.
00789           VariantClear(&v);
00790           SysFreeString(Prop);
00791           Prop = SysAllocString(L"Item");
00792           if (!Prop)
00793           {
00794             pEnumEquipment->Release();
00795             pEquipInst->Release();
00796             TRACE(_T("Not enough memory: SysAllocString failed"));
00797             return;
00798           };
00799
00800
00801           if (pEquipInst->Get(Prop, 0L,
00802                     &v, NULL, NULL) == S_OK)
00803           {
00804             TRACE(_T("Got an item\n"));
00805             buf += V_BSTR(&v);
00806           }
00807
00808           // add to the output listbox.
00809           m_outputList.AddString(buf);
00810
00811           // cleanup for next loop
00812           VariantClear(&v);
00813           SysFreeString(Prop);
00814
00815           // Done with this object.
00816           if (pEquipInst)
00817           {
00818             pEquipInst->Release();
00819
00820             // NOTE: pEquipInst MUST be set to NULL for the next all to Next().
00821             pEquipInst = NULL;
00822           }
00823
00824         } // endif (hRes == S_OK)
00825
00826       } // endwhile
00827
00828       TRACE(_T("done enumming: %s\n"), ErrorString(hRes));
00829
00830       // Done with this enumerator.
00831       if (pEnumEquipment)
00832       {
00833         pEnumEquipment->Release();
00834         pEnumEquipment = NULL;
00835       }
00836     }
00837     else // CreateInstanceEnum() failed.
00838     {
00839       TRACE(_T("CreateInstanceEnum() failed: %s\n"), ErrorString(hRes));
00840
00841     } // endif CreateInstanceEnum()
00842
00843     SysFreeString(EquipClassName);
00844
00845   } // endif EnsureOfficeNamespace()
00846 }
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagCol Member List

This is the complete list of members for _tagCol, including all inherited members.
dwWidth | _tagCol
lpsz | _tagCol
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCharBlock Member List

This is the complete list of members for CCharBlock, including all inherited members.
_Char | CCharBlock | [protected]
_Code | CCharBlock | [protected]
_Line | CCharBlock | [protected]
CCharBlock(UINT cCol, UINT cRow, UINT iBlockOffset, const CBlockFormat &bf) | CCharBlock |
Hittest(POINT pt, POINT ptTest) | CCharBlock |
Paint(CCanvas &canvas, RECT rc, POINT pt) | CCharBlock |
SetFont(HFONT font) | CCharBlock |
SetFormat(UINT fuFormat=HEXADECIMAL) | CCharBlock |
Generated on Wed Nov 13 2024 16:55:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/Pch.Cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

Pch.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        pch.cpp
00007 //
00008 // Contents:    Cert Server precompiled header
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include <windows.h>
00013
00014 #include <atlbase.h>
00015
00016 //You may derive a class from CComModule and use it if you want to override
00017 //something, but do not change the name of _Module
00018 extern CComModule _Module;
00019
00020 #include <atlcom.h>
00021 #include <certsrv.h>
00022
00023 #pragma hdrstop
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CLock Member List

This is the complete list of members for CLock, including all inherited members.
CLock(CLockHandler *pLockHandler) | CLock | [inline]
cRefs | CLock | [private]
Enter() | CLock | [inline]
Leave() | CLock | [inline]
m_dwThreadID | CLock | [private]
m_pLockHandler | CLock | [private]
~CLock() | CLock | [inline]
Generated on Wed Nov 13 2024 16:56:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ExecuteOptionEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ExecuteOptionEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ExecuteOptionEnum
00019
00020 public class ExecuteOptionEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adOptionUnspecified = -1;
00023   public static final short adAsyncExecute = 16;
00024   public static final short adAsyncFetch = 32;
00025   public static final short adAsyncFetchNonBlocking = 64;
00026   public static final short adExecuteNoRecords = 128;
00027 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSharp_Draw::InputBox Member List

This is the complete list of members for CSharp_Draw::InputBox, including all inherited members.
bResult | CSharp_Draw::InputBox |
btnCancel | CSharp_Draw::InputBox | [private]
btnCancel_Click(object sender, System.EventArgs e) | CSharp_Draw::InputBox | [inline, private]
btnOK | CSharp_Draw::InputBox | [private]
btnOK_Click(object sender, System.EventArgs e) | CSharp_Draw::InputBox | [inline, private]
components | CSharp_Draw::InputBox | [private]
Dispose() | CSharp_Draw::InputBox | [inline]
InitializeComponent() | CSharp_Draw::InputBox | [inline, private]
InputBox() | CSharp_Draw::InputBox | [inline]
label1 | CSharp_Draw::InputBox | [private]
textBoxName | CSharp_Draw::InputBox |
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/atl/atlcontrol.Cpp Source File

  • SysMgmt
  • MMC
  • ActiveX
  • atl

atlcontrol.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // ATLControl.cpp : Implementation of DLL Exports.
00020
00021
00022 // Note: Proxy/Stub Information
00023 //      To build a separate proxy/stub DLL,
00024 //      run nmake -f ATLControlps.mk in the project directory.
00025
00026 #include "stdafx.h"
00027 #include "resource.h"
00028 #include <initguid.h>
00029 #include "ATLControl.h"
00030
00031 #include "ATLControl_i.c"
00032 #include "MMCControl.h"
00033
00034
00035 CComModule _Module;
00036
00037 BEGIN_OBJECT_MAP(ObjectMap)
00038 OBJECT_ENTRY(CLSID_MMCControl, CMMCControl)
00039 END_OBJECT_MAP()
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 // DLL Entry Point
00043
00044 extern "C"
00045 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00046 {
00047     if (dwReason == DLL_PROCESS_ATTACH)
00048     {
00049         _Module.Init(ObjectMap, hInstance, &LIBID_ATLCONTROLLib);
00050         DisableThreadLibraryCalls(hInstance);
00051     }
00052     else if (dwReason == DLL_PROCESS_DETACH)
00053         _Module.Term();
00054     return TRUE;    // ok
00055 }
00056
00057 /////////////////////////////////////////////////////////////////////////////
00058 // Used to determine whether the DLL can be unloaded by OLE
00059
00060 STDAPI DllCanUnloadNow(void)
00061 {
00062     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00063 }
00064
00065 /////////////////////////////////////////////////////////////////////////////
00066 // Returns a class factory to create an object of the requested type
00067
00068 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00069 {
00070     return _Module.GetClassObject(rclsid, riid, ppv);
00071 }
00072
00073 /////////////////////////////////////////////////////////////////////////////
00074 // DllRegisterServer - Adds entries to the system registry
00075
00076 STDAPI DllRegisterServer(void)
00077 {
00078     // registers object, typelib and all interfaces in typelib
00079     return _Module.RegisterServer(TRUE);
00080 }
00081
00082 /////////////////////////////////////////////////////////////////////////////
00083 // DllUnregisterServer - Removes entries from the system registry
00084
00085 STDAPI DllUnregisterServer(void)
00086 {
00087     return _Module.UnregisterServer(TRUE);
00088 }
00089
00090
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step1/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step1

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__E1E3EDEE_48D1_11D2_B22B_0000F87A6B50__INCLUDED_)
00006 #define AFX_STDAFX_H__E1E3EDEE_48D1_11D2_B22B_0000F87A6B50__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0400
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <afxwin.h>
00019 #include <afxdisp.h>
00020
00021 #include <atlbase.h>
00022 //You may derive a class from CComModule and use it if you want to override
00023 //something, but do not change the name of _Module
00024 extern CComModule _Module;
00025 #include <atlcom.h>
00026
00027 #include "activeds.h"
00028
00029 //{{AFX_INSERT_LOCATION}}
00030 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00031
00032 #endif // !defined(AFX_STDAFX_H__E1E3EDEE_48D1_11D2_B22B_0000F87A6B50__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Adminwrap.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Adminwrap.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "Adminwrap.h"
00019 #include <comadmin.h>
00020 #include <assert.h>
00021
00022 #define SAFERELEASE(p)  if (p) \
00023       { p->Release();\
00024       p = 0;}
00025
00026 #define exit(hr)  if FAILED(hr) \
00027           goto exit;
00028
00029 //*********************************************
00030 // Globals
00031
00032 BSTR g_bstrPUBID = L"PublisherID";
00033 BSTR g_bstrNAME = L"Name";
00034 BSTR g_bstrVALUE = L"Value";
00035 BSTR g_bstrECID = L"EventCLSID";
00036 BSTR g_bstrIID = L"InterfaceID";
00037 BSTR g_bstrMETHOD = L"MethodName";
00038 BSTR g_bstrCRITERIA = L"FilterCriteria";
00039 BSTR g_bstrTRANSSUB = L"TransientSubscriptions";
00040 BSTR g_bstrSUBINT = L"SubscriberInterface";
00041 BSTR g_bstrTRANSPUBPROP = L"TransientPublisherProperties";
00042
00043 ///////////////////////////////////////////////////////////////////////////////////////////////////
00044 // Name     : AddTransientSubscription
00045 // Purppose   : Adds a Persistent Subscription
00046 // Parameters :
00047 //        :ICOMAdminCatalog* pICat -interface pointer to admin catelog object
00048 //        : WCHAR* pwzSubName   - Name of the subscription
00049 //        : WCHAR* pwzECID    - EventClass ID
00050 //        : WCHAR* pwzPubID   - Name of the Publisher
00051 //        : WCHAR* pwzIID         - Interface Name (in string form)
00052 //        : IUnknown* punk    - IUnknown* of the subscriber
00053 //        : WCHAR* pwzMethod    - Method in the interface to subscribe
00054 //        : WCHAR* pwzCriteria  - Filter Criteria (used in parameterized filtering)
00055 //        : WCHAR* pwzPubProp   - Publisher Property Name
00056 //        : WCHAR* pwzPubVal    - Publisher Property Value
00057 // Return Value : HRESULT
00058 ////////////////////////////////////////////////////////////////////////////////////////////////////
00059
00060 HRESULT AddTransientSubscription(ICOMAdminCatalog* pICat,
00061                      WCHAR* pwzSubName, WCHAR* pwzECID, WCHAR* pwzPubID, WCHAR* pwzIID, IUnknown *punk,
00062                      WCHAR* pwzMethod, WCHAR* pwzCriteria, WCHAR* pwzPubProp, WCHAR* pwzPubVal)
00063 {
00064   HRESULT         hr =0;
00065   ICatalogObject      *pISub=0, *pIProp=0;
00066   ICatalogCollection    *pISubs=0, *pIProps=0;
00067   IDispatch       *pIDisp=0;
00068   long          lret=0;
00069   BOOL          fCreate=FALSE, fComplete = FALSE;
00070
00071   if (!pICat || !pwzSubName || !punk)
00072     return E_INVALIDARG;
00073
00074   hr = GetCollection(pICat, g_bstrTRANSSUB, &pISubs);
00075   exit(hr);
00076
00077   hr = pISubs->Add(&pIDisp);
00078   exit(hr);
00079
00080   hr = pIDisp->QueryInterface(__uuidof(ICatalogObject), (LPVOID*)&pISub);
00081   exit(hr);
00082
00083   hr = SetStringProperty(pISub, g_bstrNAME, pwzSubName);
00084   exit(hr);
00085
00086   hr = SetStringProperty(pISub, g_bstrECID, pwzECID);
00087   exit(hr);
00088
00089   hr = SetStringProperty(pISub, g_bstrPUBID, pwzPubID);
00090   exit(hr);
00091
00092   hr = SetStringProperty(pISub, g_bstrIID, pwzIID);
00093   exit(hr);
00094
00095   hr = SetIUnknownProperty(pISub, g_bstrSUBINT, punk);
00096   exit(hr);
00097
00098   hr = SetStringProperty(pISub, g_bstrMETHOD, pwzMethod);
00099   exit(hr);
00100
00101   hr = SetStringProperty(pISub, g_bstrCRITERIA, pwzCriteria);
00102   exit(hr);
00103
00104   hr = pISubs->SaveChanges(&lret);
00105   exit(hr);
00106
00107   fCreate = TRUE;
00108
00109   if (pwzPubProp && pwzPubVal)
00110   {
00111
00112     hr = GetCollection(pISubs, pISub, g_bstrTRANSPUBPROP, &pIProps);
00113     exit(hr);
00114
00115     SAFERELEASE(pIDisp);
00116     hr = pIProps->Add(&pIDisp);
00117     exit(hr);
00118
00119     hr = pIDisp->QueryInterface(__uuidof(ICatalogObject), (LPVOID*)&pIProp);
00120     exit(hr);
00121
00122     hr = SetStringProperty(pIProp, g_bstrNAME, pwzPubProp);
00123     exit(hr);
00124
00125     hr = SetStringProperty(pIProp, g_bstrVALUE, pwzPubVal);
00126     exit(hr);
00127
00128     hr = pIProps->SaveChanges(&lret);
00129     exit(hr);
00130   }
00131
00132   fComplete = TRUE;
00133
00134 exit:
00135   if (fCreate && !fComplete)
00136     RemoveTransientSubscription(pICat, pwzSubName);
00137   SAFERELEASE(pIDisp);
00138   SAFERELEASE(pIProp);
00139   SAFERELEASE(pIProps);
00140   SAFERELEASE(pISub);
00141   SAFERELEASE(pISubs);
00142   return hr;
00143 }
00144
00145 ///////////////////////////////////////////////////////////////////////////////////////////////////
00146 // Name     : RemoveTransientSubscription
00147 // Purppose   : Remolves a Persistent Subscription
00148 // Parameters :
00149 //        : WCHAR* pwzSubName   - Name of the subscription
00150 // Return Value : HRESULT
00151 ////////////////////////////////////////////////////////////////////////////////////////////////////
00152 HRESULT RemoveTransientSubscription(ICOMAdminCatalog* pICat, WCHAR* pwzName)
00153 {
00154   HRESULT         hr =0;
00155   ICatalogCollection    *pISubs=0;
00156
00157   if (!pICat || !pwzName)
00158     return E_INVALIDARG;
00159
00160   hr = GetCollection(pICat, g_bstrTRANSSUB, &pISubs);
00161   exit(hr);
00162
00163   hr = RemoveNamedObjectFromCollection(pISubs, BSTR(pwzName), TRANSIENTSUB);
00164 exit:
00165   SAFERELEASE(pISubs);
00166   return hr;
00167 }
00168
00169
00170
00171 ///////////////////////////////////////////////////////////////////////////////////////////////////
00172 // Name     : GetCollection
00173 // Purppose   : Gets a collection from the Catalogue
00174 // Parameters :
00175 //        : ICOMAdminCatalog* pICat       - Admin Catalog object
00176 //        : BSTR szCollName           - Collection Name
00177 //        : ICatalogCollection** ppICol     - Collection returned
00178 // Return Value : HRESULT
00179 ////////////////////////////////////////////////////////////////////////////////////////////////////
00180 HRESULT GetCollection(ICOMAdminCatalog* pICat, BSTR szCollName, ICatalogCollection** ppICol)
00181 {
00182   HRESULT hr = E_INVALIDARG;
00183   IDispatch* pIDisp = NULL;
00184   if (!pICat || !szCollName || !ppICol)
00185     goto exit;
00186
00187   hr = pICat->GetCollection(szCollName, &pIDisp);
00188   exit(hr);
00189   hr = pIDisp->QueryInterface(__uuidof(ICatalogCollection), (LPVOID*)ppICol);
00190   exit(hr);
00191   hr = (*ppICol)->Populate();
00192 exit:
00193   SAFERELEASE(pIDisp);
00194   return hr;
00195 }
00196
00197 ///////////////////////////////////////////////////////////////////////////////////////////////////
00198 // Name     : GetCollection
00199 // Purppose   : Gets a collection from the Catalogue
00200 // Parameters :
00201 //        : ICatalogCollection* pIParentColl    - Parent Collection
00202 //        : ICatalogObject* pICatObj        - Parent Object
00203 //        : BSTR szCollName           - Collection Name
00204 //        : ICatalogCollection** ppICol     - Collection returned
00205 // Return Value : HRESULT
00206 ////////////////////////////////////////////////////////////////////////////////////////////////////
00207 HRESULT GetCollection(ICatalogCollection* pIParentColl, ICatalogObject* pICatObj, BSTR szCollName,
00208             ICatalogCollection** ppICol)
00209 {
00210   HRESULT hr = E_INVALIDARG;
00211   VARIANT var;
00212   IDispatch* pIDisp = NULL;
00213   VariantInit(&var);
00214   if (!pIParentColl || !pICatObj || !szCollName || !ppICol)
00215     goto exit;
00216   hr = pICatObj->get_Key(&var);
00217   exit(hr);
00218   hr = pIParentColl->GetCollection(szCollName, var, &pIDisp);
00219   exit(hr);
00220   hr = pIDisp->QueryInterface(__uuidof(ICatalogCollection), (LPVOID*)ppICol);
00221   exit(hr);
00222   hr = (*ppICol)->Populate();
00223 exit:
00224   VariantClear(&var);
00225   if(pIDisp)
00226     pIDisp->Release();
00227   return hr;
00228 }
00229
00230
00231
00232 ///////////////////////////////////////////////////////////////////////////////////////////////////
00233 // Name     : RemoveNamedObjectFromCollection
00234 // Purppose   : Removes an object from a collection
00235 // Parameters :
00236 //        : ICatalogCollection* pIParentColl    - Collection from the object has to be
00237 //                              removed
00238 //        : BSTR szObjectName           - Object name
00239 //        : ADMINTYPE type            - type of the object
00240 // Return Value : HRESULT
00241 ////////////////////////////////////////////////////////////////////////////////////////////////////
00242 HRESULT RemoveNamedObjectFromCollection(ICatalogCollection* pICol, BSTR szObjectName, ADMINTYPE type)
00243 {
00244   HRESULT hr = E_FAIL;
00245   ICatalogObject* pICatObj = NULL;
00246   LONG key, lTotal;
00247
00248   if (wcscmp(szObjectName, SysAllocString(L"*")))
00249   {
00250     hr = GetNamedObjectFromCollection(pICol, szObjectName, &pICatObj, &key, type);
00251     exit(hr);
00252     hr = pICol->Remove(key);
00253     exit(hr);
00254     hr = pICol->SaveChanges(&key);
00255   }
00256   else
00257   {
00258     hr = pICol->get_Count(&lTotal);
00259     exit(hr);
00260     for (key=lTotal-1; key >= 0; key--)
00261     {
00262       hr = pICol->Remove(key);
00263       exit(hr);
00264       hr = pICol->SaveChanges(&key);
00265       exit(hr);
00266     }
00267   }
00268
00269 exit:
00270   if(pICatObj)
00271     pICatObj->Release();
00272   return hr;
00273 }
00274
00275 ///////////////////////////////////////////////////////////////////////////////////////////////////
00276 // Name     : GetNamedObjectFromCollection
00277 // Purppose   : Gets an object from a collection
00278 // Parameters :
00279 //        : ICatalogCollection* pIParentColl    - Collection from the object has to be
00280 //                              retrieved
00281 //        : BSTR bstrObjName            - Object name
00282 //        : ADMINTYPE type            - type of the object
00283 //        : ICatalogObject** ppObj        - return Object
00284 //        : LONG* plIndex             - Index of the object (-1, if not found)
00285 //        : ADMINTYPE type            - type of the object
00286 //        : BSTR bstrPropname           - name of the property
00287 // Return Value : HRESULT
00288 ////////////////////////////////////////////////////////////////////////////////////////////////////
00289 HRESULT GetNamedObjectFromCollection(ICatalogCollection* pCol, BSTR bstrObjName, ICatalogObject** ppObj,
00290                    LONG* plIndex, ADMINTYPE type, BSTR bstrPropname)
00291 {
00292   HRESULT hr = E_FAIL;
00293   LONG lCount = 0;
00294   LONG i = 0;
00295   ICatalogObject* pObj = NULL;
00296   CComBSTR bstrName;
00297   VARIANT varProp;
00298   BOOL  fFound = FALSE;
00299
00300   VariantInit(&varProp);
00301   if (!pCol || !bstrObjName || !ppObj)
00302     return E_INVALIDARG;
00303
00304   if (!bstrPropname)
00305   {
00306     bstrName = g_bstrNAME;
00307   }
00308   else
00309     bstrName = bstrPropname;
00310
00311   *ppObj = NULL;
00312
00313   hr = pCol->Populate();
00314   exit(hr);
00315
00316   hr = pCol->get_Count(&lCount);
00317   exit(hr);
00318
00319   if (lCount == 0)
00320   {
00321     *plIndex = -1; // To indicate that the object is not found in the collection
00322     exit(hr=E_FAIL);
00323   }
00324
00325   // Loop through
00326   for (i = 0; i < lCount; i++)
00327   {
00328     VariantClear(&varProp);
00329
00330     // Get the next item
00331     hr = pCol->get_Item(i, (IDispatch**)&pObj);
00332     exit(hr);
00333
00334     // Retrieve it's name property
00335     hr = pObj->get_Value((BSTR)bstrName, &varProp);
00336     exit(hr);
00337
00338     // Check it's name property for a match
00339     if (wcscmp(bstrObjName, varProp.bstrVal) == 0)
00340     {
00341       // Found it!
00342       *ppObj = pObj;
00343       pObj->AddRef();
00344       VariantClear(&varProp);
00345       // does user want index of the just-found object?
00346       if (plIndex)
00347         *plIndex = i;
00348       fFound = TRUE;
00349       hr = S_OK;
00350       goto exit;
00351     }
00352       SAFERELEASE(pObj);
00353   }
00354
00355   // If we got here then we didn't find it
00356   if (plIndex)
00357     *plIndex = -1; // To indicate that the object is not found in the collection
00358 exit:
00359   SAFERELEASE(pObj);
00360   return hr;
00361 }
00362
00363
00364 ///////////////////////////////////////////////////////////////////////////////////////////////////
00365 // Name     : SetStringProperty
00366 // Purppose   : Gets the property name of the object
00367 // Parameters :
00368 //        : ICatalogObject *pcat      -  Pointer to the object
00369 //        : BSTR bstrPROP         -  Name of the property
00370 //              : WCHAR* pval         -  Value of the property
00371 // Return Value : HRESULT
00372 ////////////////////////////////////////////////////////////////////////////////////////////////////
00373 HRESULT SetStringProperty(ICatalogObject *pcat, BSTR bstrPROP, WCHAR* pval)
00374 {
00375   HRESULT hr;
00376   VARIANT var;
00377   if (!pcat)
00378     return E_INVALIDARG;
00379
00380   if (!pval)
00381     return S_FALSE;
00382
00383   VariantClear(&var);
00384
00385   var.bstrVal = SysAllocString(pval);
00386   if (!var.bstrVal)
00387     exit(hr=E_OUTOFMEMORY);
00388   var.vt = VT_BSTR;
00389
00390   hr = pcat->put_Value(bstrPROP, var);
00391   exit(hr);
00392
00393 exit:
00394   VariantClear(&var);
00395   return hr;
00396 }
00397
00398 ///////////////////////////////////////////////////////////////////////////////////////////////////
00399 // Name     : SetIUnknownProperty
00400 // Purppose   : Gets the property name of the object
00401 // Parameters :
00402 //        : ICatalogObject *pcat      -  Pointer to the object
00403 //        : BSTR bstrPROP         -  Name of the property
00404 //              : IUnknown* punk        -  Value of the property
00405 // Return Value : HRESULT
00406 ////////////////////////////////////////////////////////////////////////////////////////////////////
00407 HRESULT SetIUnknownProperty(ICatalogObject *pcat, BSTR bstrPROP, IUnknown* punk)
00408 {
00409   HRESULT hr;
00410   VARIANT var;
00411   if (!punk || !pcat)
00412     return E_INVALIDARG;
00413
00414   VariantClear(&var);
00415
00416   var.punkVal = punk;
00417   var.vt = VT_UNKNOWN;
00418   punk->AddRef(); // We'll be caling VariantClear
00419
00420   hr = pcat->put_Value(bstrPROP, var);
00421   exit(hr);
00422
00423 exit:
00424   VariantClear(&var);
00425   return hr;
00426 }
00427
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/compdata.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

compdata.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "Comp.h"
00016 #include "CompData.h"
00017 #include "DataObj.h"
00018 #include "Resource.h"
00019
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CComponentData")
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // Construction/Destruction
00028
00029
00030 //---------------------------------------------------------------------------
00031 //  This constructor is called when the Snap-in is selected from the
00032 //  Add/Remove dialog.  Build our static node and load the required
00033 //  clipformats before MMC calls us.
00034 //
00035 CComponentData::CComponentData()
00036 {
00037   // Do not assume only one instance of IComponentData implementation is created.
00038
00039
00040     m_cRef                = 0;
00041     m_ipConsoleNameSpace  = NULL;
00042     m_ipConsole           = NULL;
00043
00044     // Increment this so DllCanUnloadNow works correctly
00045     InterlockedIncrement((long*)&g_uObjectCount);
00046
00047     NODEPROPS NodeProps;
00048     ZeroMemory( &NodeProps, sizeof(NODEPROPS) );
00049     wcscpy( NodeProps.szNodeName, gwszROOT_NODE_NAME );
00050     NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(this);
00051     NodeProps.pParentObject  = NULL;
00052     NodeProps.nChildCount    = INIT_DEFAULT_NODE;
00053
00054     m_pStaticNode = new CStaticNode;
00055     m_pStaticNode->Initialize( &NodeProps );
00056
00057     InitClipboardFormats();
00058 }
00059
00060 //---------------------------------------------------------------------------
00061 CComponentData::~CComponentData()
00062 {
00063   if( NULL != m_pStaticNode )
00064   {
00065     delete m_pStaticNode;
00066     m_pStaticNode = NULL;
00067   }
00068
00069   // All done, decrement object count so the dll can be unloaded
00070   InterlockedDecrement((long*)&g_uObjectCount);
00071 }
00072
00073
00074 /////////////////////////////////////////////////////////////////////////////
00075 // IUnknown implementation
00076
00077 //---------------------------------------------------------------------------
00078 STDMETHODIMP CComponentData::QueryInterface
00079 (
00080   REFIID   riid,       //[in] Identifier of the requested interface
00081   LPVOID   *ppv        //[out] Address of requested interface
00082 )
00083 {
00084   if( !ppv )
00085     return E_FAIL;
00086
00087   *ppv = NULL;
00088
00089   if( IsEqualIID(riid, IID_IUnknown) )
00090     *ppv = static_cast<IComponentData*>(this);
00091   else if( IsEqualIID(riid, IID_IComponentData) )
00092     *ppv = static_cast<IComponentData*>(this);
00093   else if( IsEqualIID(riid, IID_IComponentData2) )
00094     *ppv = static_cast<IComponentData2*>(this);
00095   else if( IsEqualIID(riid, IID_IExtendContextMenu) )
00096     *ppv = static_cast<IExtendContextMenu *>(this);
00097
00098
00099   if( *ppv )
00100   {
00101     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00102     return S_OK;
00103   }
00104
00105   return E_NOINTERFACE;
00106 }
00107
00108 //---------------------------------------------------------------------------
00109 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00110 {
00111   return InterlockedIncrement((LONG*)&m_cRef);
00112 }
00113
00114 //---------------------------------------------------------------------------
00115 STDMETHODIMP_(ULONG) CComponentData::Release()
00116 {
00117   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00118   {
00119     delete this;
00120     return 0;
00121   }
00122
00123   return m_cRef;
00124 }
00125
00126 /////////////////////////////////////////////////////////////////////////////
00127 // Interface IComponentData
00128
00129 //---------------------------------------------------------------------------
00130 //  Called when the user selects the Snap-in from the scope pane.
00131 //  This is where we QI and cache interfaces we will use later.  These
00132 //  interfaces are for future use since they are not used in this sample
00133 //
00134 HRESULT CComponentData::Initialize
00135 (
00136   LPUNKNOWN pUnknown         //[in] Pointer to the console's IUnknown
00137 )
00138 {
00139   HRESULT hResult = S_FALSE;
00140   hResult = GetConsoleVersion( &g_CV );
00141                              // S_FALSE is returned for any version earlier
00142                              // than 2.0.  The values in g_CV will be 0.0
00143
00144                              // Fail to initialize if we can't get the
00145   do                         // interfaces we need to cache
00146   {
00147     hResult = pUnknown->QueryInterface(IID_IConsole3, (void**)&m_ipConsole);
00148     BREAK_ON_ERROR( hResult );
00149
00150     hResult = pUnknown->QueryInterface(IID_IConsoleNameSpace2, (void**)&m_ipConsoleNameSpace);
00151     BREAK_ON_ERROR( hResult );
00152
00153     // Add the images for the scope tree
00154     LPIMAGELIST ipScopeImage = NULL;
00155     hResult = m_ipConsole->QueryScopeImageList(&ipScopeImage);
00156     BREAK_ON_ERROR( hResult );
00157
00158     // Load the bitmaps from the dll
00159     HBITMAP hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16) );
00160     if( NULL == hImageStrip16 )
00161     {
00162       hResult = S_FALSE;
00163       continue;
00164     }
00165
00166     HBITMAP hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32) );
00167      if( NULL == hImageStrip32)
00168     {
00169       hResult = S_FALSE;
00170       continue;
00171     }
00172
00173     // Set the images
00174     hResult = ipScopeImage->ImageListSetStrip( (LONG_PTR*)hImageStrip16,
00175                                                (LONG_PTR*)hImageStrip32,
00176                                                0,
00177                                                RGB(0,255,0)
00178                                              );
00179     BREAK_ON_ERROR( hResult );
00180
00181     SAFE_RELEASE( ipScopeImage      ); // Release these here.  IComponent
00182     SAFE_FREE_BITMAP( hImageStrip16 ); // will get an MMCN_ADD_IMAGES when
00183     SAFE_FREE_BITMAP( hImageStrip32 ); // the console needs them again.
00184   }
00185   while( 0 );
00186
00187   return hResult;
00188 }
00189
00190 //---------------------------------------------------------------------------
00191 //  Called by the console every time we need to create a new result view.
00192 //  There can be several different result views. Aside from the default one
00193 //  created when the Snap-in initializes, additional ones are created by
00194 //  selecting "New window from here" in MMC's user interface.
00195 //
00196 HRESULT CComponentData::CreateComponent
00197 (
00198   LPCOMPONENT __RPC_FAR* ppComponent   //[out] Points to new IComponent class
00199 )
00200 {
00201   *ppComponent = NULL;
00202
00203   // Pass the new CComponent a pointer to it's parent
00204   CComponent* pComponent = new CComponent( this );
00205
00206   if( NULL == pComponent )
00207     return E_OUTOFMEMORY;
00208
00209   return pComponent->QueryInterface( IID_IComponent, (void**)ppComponent );
00210 }
00211
00212 //---------------------------------------------------------------------------
00213 //  Handles notification events from MMC
00214 //
00215 HRESULT CComponentData::Notify
00216 (
00217   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00218   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00219   LONG             nArg,           //[in] Depends on the notification type
00220   LONG             nParam          //[in] Depends on the notification type
00221 )
00222 {
00223   TRACE_EVENT( _T("Notify"), MmcEvent );  // Provides trace output
00224
00225   HRESULT hResult = S_FALSE;
00226   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00227   if( NULL == pNode )
00228     return hResult;
00229
00230   switch( MmcEvent )
00231   {
00232     case MMCN_EXPAND:
00233       hResult = pNode->OnExpand( ipDataObject, nArg, nParam, (LONG_PTR)this );
00234       break;
00235
00236     case MMCN_REMOVE_CHILDREN:
00237       hResult = pNode->OnRemoveChildren( ipDataObject, nArg, nParam, (LONG_PTR)this );
00238       break;
00239
00240     case MMCN_PRELOAD:                 // Notification not implemented
00241     case MMCN_PROPERTY_CHANGE:         // Notification not implemented
00242     case MMCN_DELETE:                  // Notification not implemented
00243       break;
00244
00245     case MMCN_RENAME:
00246       hResult = pNode->OnRename( ipDataObject, nArg, nParam, (LONG_PTR)this );
00247       break;
00248
00249     default:
00250       break;
00251   }
00252
00253   return hResult;
00254 }
00255
00256 //---------------------------------------------------------------------------
00257 //  This is where we release any cached interface pointers or any
00258 //  allocated resources.
00259 //
00260 HRESULT CComponentData::Destroy( void)
00261 {
00262   SAFE_RELEASE( m_ipConsoleNameSpace );
00263   SAFE_RELEASE( m_ipConsole          );
00264
00265   return S_OK;
00266 }
00267
00268 //---------------------------------------------------------------------------
00269 //  MMC provides a NULL cookie for the static/root node.  In this sample
00270 //  we don't pass that on, instead we use the pointer to our static node
00271 //  object which handles notifications
00272 //
00273 HRESULT CComponentData::QueryDataObject
00274 (
00275   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00276   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00277   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00278 )
00279 {
00280   HRESULT hResult = S_FALSE;
00281   ULONG   uCookie = 0;
00282
00283   CDataObject* pNewObject = new CDataObject();
00284   if( NULL == pNewObject )
00285     hResult = E_OUTOFMEMORY;
00286
00287   (0 == nCookie) ? uCookie = (ULONG)m_pStaticNode : uCookie = nCookie;
00288   pNewObject->SetPrivateData( uCookie, (ULONG)nEnumType );
00289
00290   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00291
00292   return hResult;
00293 }
00294
00295 //---------------------------------------------------------------------------
00296 //  Delegate the call to the static node object
00297 //
00298 HRESULT CComponentData::GetDisplayInfo
00299 (
00300   SCOPEDATAITEM* pScopeDataItem    //[out][in] Points to a SCOPEDATAITEM struct
00301 )
00302 {
00303   _ASSERT( NULL != pScopeDataItem );
00304   HRESULT hResult = S_OK;
00305
00306   // The console will only ask for the name string
00307   if(  pScopeDataItem->mask & SDI_STR )
00308   {
00309     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(pScopeDataItem->lParam);
00310     hResult = pNode->GetDisplayInfo( pScopeDataItem );
00311   }
00312
00313   return hResult;
00314 }
00315
00316 //---------------------------------------------------------------------------
00317 HRESULT CComponentData::CompareObjects
00318 (
00319   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00320   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00321 )
00322 {
00323   return E_NOTIMPL;
00324 }
00325
00326
00327 //---------------------------------------------------------------------------
00328 HRESULT CComponentData::QueryDispatch
00329 (
00330   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00331   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00332   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00333 )
00334 {
00335   return E_NOTIMPL;
00336 }
00337
00338
00339 /////////////////////////////////////////////////////////////////////////////
00340 // Interface IExtendContextMenu
00341
00342 //---------------------------------------------------------------------------
00343 HRESULT CComponentData::AddMenuItems
00344 (
00345   LPDATAOBJECT ipDataObject,         //[in]
00346   LPCONTEXTMENUCALLBACK ipCallback,  //[in]
00347   long __RPC_FAR* pInsertionAllowed  //[out-in]
00348 )
00349 {
00350   _ASSERT( NULL != ipCallback );
00351   HRESULT hResult = S_FALSE;
00352
00353   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00354   if( NULL != pNode )
00355     hResult = pNode->AddMenuItems( ipCallback, pInsertionAllowed );
00356
00357   return hResult;
00358 }
00359
00360 //---------------------------------------------------------------------------
00361 //
00362 HRESULT CComponentData::Command
00363 (
00364   long         lCommandID,   //[in] Identifier of the menu item
00365   LPDATAOBJECT ipDataObject  //[in] DataObject for selected node
00366 )
00367 {
00368   HRESULT hResult = S_OK;
00369
00370   CBaseNode* pNode = ExtractBaseNodePtr( ipDataObject );
00371   if( NULL != pNode )
00372     hResult = pNode->Command( lCommandID );
00373
00374   return hResult;
00375 }
00376
00377 /////////////////////////////////////////////////////////////////////////////
00378 //  Helper methods
00379
00380 //---------------------------------------------------------------------------
00381 HRESULT CComponentData::GetInterface
00382 (
00383   DWORD     dwRequestedInterface,  //[in] Request flag
00384   LONG_PTR* ppInterface            //[in-out] Interface pointer to return
00385 )
00386 {
00387   _ASSERT( NULL != ppInterface );
00388   HRESULT hResult = S_OK;
00389
00390   switch( dwRequestedInterface )
00391   {
00392     case REQUEST_ICONSOLENAMESPACE:
00393       _ASSERT( NULL != m_ipConsoleNameSpace );
00394       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleNameSpace);
00395       break;
00396
00397     case REQUEST_ICONSOLE:
00398       _ASSERT( NULL != m_ipConsole );
00399       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00400       break;
00401
00402     default:
00403       hResult = S_FALSE;
00404       *ppInterface = NULL;
00405       break;
00406   }
00407
00408   return hResult;
00409 }
00410
00411
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenuExt/cMenuext.Cpp Source File

  • SysMgmt
  • MMC
  • CMenuExt

cMenuext.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "CMenuExt.h"
00020 #include "globals.h"
00021 #include "resource.h"
00022 #include <crtdbg.h>
00023
00024 // we need to do this to get around MMC.IDL - it explicitly defines
00025 // the clipboard formats as WCHAR types...
00026 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00027 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00028 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00029
00030 // These are the clipboard formats that we must supply at a minimum.
00031 // mmc.h actually defined these. We can make up our own to use for
00032 // other reasons. We don't need any others at this time.
00033 UINT CContextMenuExtension::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00034 UINT CContextMenuExtension::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00035 UINT CContextMenuExtension::s_cfSnapInCLSID = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00036
00037 CContextMenuExtension::CContextMenuExtension() : m_cref(0)
00038 {
00039     OBJECT_CREATED
00040 }
00041
00042 CContextMenuExtension::~CContextMenuExtension()
00043 {
00044     OBJECT_DESTROYED
00045 }
00046
00047 ///////////////////////
00048 // IUnknown implementation
00049 ///////////////////////
00050
00051 STDMETHODIMP CContextMenuExtension::QueryInterface(REFIID riid, LPVOID *ppv)
00052 {
00053     if (!ppv)
00054         return E_FAIL;
00055
00056     *ppv = NULL;
00057
00058     if (IsEqualIID(riid, IID_IUnknown))
00059         *ppv = static_cast<IExtendContextMenu *>(this);
00060     else if (IsEqualIID(riid, IID_IExtendContextMenu))
00061         *ppv = static_cast<IExtendContextMenu *>(this);
00062
00063     if (*ppv)
00064     {
00065         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00066         return S_OK;
00067     }
00068
00069     return E_NOINTERFACE;
00070 }
00071
00072 STDMETHODIMP_(ULONG) CContextMenuExtension::AddRef()
00073 {
00074     return InterlockedIncrement((LONG *)&m_cref);
00075 }
00076
00077 STDMETHODIMP_(ULONG) CContextMenuExtension::Release()
00078 {
00079     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00080     {
00081         // we need to decrement our object count in the DLL
00082         delete this;
00083         return 0;
00084     }
00085
00086     return m_cref;
00087 }
00088
00089 HRESULT CContextMenuExtension::ExtractData( IDataObject* piDataObject,
00090                                            CLIPFORMAT   cfClipFormat,
00091                                            BYTE*        pbData,
00092                                            DWORD        cbData )
00093 {
00094     HRESULT hr = S_OK;
00095
00096     FORMATETC formatetc = {cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
00097     STGMEDIUM stgmedium = {TYMED_HGLOBAL, NULL};
00098
00099     stgmedium.hGlobal = ::GlobalAlloc(GPTR, cbData);
00100     do // false loop
00101     {
00102         if (NULL == stgmedium.hGlobal)
00103         {
00104             hr = E_OUTOFMEMORY;
00105             break;
00106         }
00107         hr = piDataObject->GetDataHere( &formatetc, &stgmedium );
00108         if ( FAILED(hr) )
00109         {
00110             break;
00111         }
00112
00113         BYTE* pbNewData = reinterpret_cast<BYTE*>(stgmedium.hGlobal);
00114         if (NULL == pbNewData)
00115         {
00116             hr = E_UNEXPECTED;
00117             break;
00118         }
00119         ::memcpy( pbData, pbNewData, cbData );
00120     } while (FALSE); // false loop
00121
00122     if (NULL != stgmedium.hGlobal)
00123     {
00124         ::GlobalFree(stgmedium.hGlobal);
00125     }
00126     return hr;
00127 } // ExtractData()
00128
00129 HRESULT CContextMenuExtension::ExtractString( IDataObject *piDataObject,
00130                                              CLIPFORMAT   cfClipFormat,
00131                                              WCHAR        *pstr,
00132                                              DWORD        cchMaxLength)
00133 {
00134     return ExtractData( piDataObject, cfClipFormat, (PBYTE)pstr, cchMaxLength );
00135 }
00136
00137 HRESULT CContextMenuExtension::ExtractSnapInCLSID( IDataObject* piDataObject, CLSID* pclsidSnapin )
00138 {
00139     return ExtractData( piDataObject, s_cfSnapInCLSID, (PBYTE)pclsidSnapin, sizeof(CLSID) );
00140 }
00141
00142 HRESULT CContextMenuExtension::ExtractObjectTypeGUID( IDataObject* piDataObject, GUID* pguidObjectType )
00143 {
00144     return ExtractData( piDataObject, s_cfNodeType, (PBYTE)pguidObjectType, sizeof(GUID) );
00145 }
00146
00147 ///////////////////////////////
00148 // Interface IExtendContextMenu
00149 ///////////////////////////////
00150 HRESULT CContextMenuExtension::AddMenuItems(
00151                                             /* [in] */ LPDATAOBJECT piDataObject,
00152                                             /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
00153                                             /* [out][in] */ long __RPC_FAR *pInsertionAllowed)
00154 {
00155     HRESULT hr = S_OK;
00156     CONTEXTMENUITEM menuItemsTask[] =
00157     {
00158         {
00159             L"People Extension", L"Do an extension thing",
00160                 1, CCM_INSERTIONPOINTID_3RDPARTY_TASK  , 0, 0
00161         },
00162         { NULL, NULL, 0, 0, 0 }
00163     };
00164
00165     // Loop through and add each of the menu items
00166     if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TASK)
00167     {
00168         for (CONTEXTMENUITEM *m = menuItemsTask; m->strName; m++)
00169         {
00170             hr = piCallback->AddItem(m);
00171
00172             if (FAILED(hr))
00173                 break;
00174         }
00175     }
00176
00177     return hr;
00178
00179 }
00180
00181 HRESULT CContextMenuExtension::Command(
00182                                        /* [in] */ long lCommandID,
00183                                        /* [in] */ LPDATAOBJECT piDataObject)
00184 {
00185     WCHAR pszName[255];
00186     HRESULT hr = ExtractString(piDataObject, s_cfDisplayName, pszName, sizeof(pszName));
00187     MAKE_TSTRPTR_FROMWIDE(ptrname, pszName);
00188
00189     if (SUCCEEDED(hr)) {
00190         switch (lCommandID)
00191         {
00192         case 1:
00193             ::MessageBox(NULL, ptrname, _T("Menu Command"), MB_OK|MB_ICONEXCLAMATION);
00194             break;
00195         }
00196     }
00197
00198     return hr;
00199 }
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/drawarea.cpp Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

drawarea.cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // drawarea.cpp : implementation file
00014 //
00015
00016
00017 #include "stdafx.h"
00018 #include "mqfdraw.h"
00019 #include "drawdlg.h"
00020
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026
00027 /////////////////////////////////////////////////////////////////////////////
00028 // CDrawArea
00029
00030 CDrawArea::CDrawArea()
00031 {
00032 }
00033
00034 CDrawArea::~CDrawArea()
00035 {
00036 }
00037
00038
00039 BEGIN_MESSAGE_MAP(CDrawArea, CEdit)
00040   //{{AFX_MSG_MAP(CDrawArea)
00041   ON_WM_LBUTTONDOWN()
00042   ON_WM_MOUSEMOVE()
00043   ON_WM_PAINT()
00044   ON_WM_RBUTTONUP()
00045   ON_WM_CTLCOLOR_REFLECT()
00046   ON_WM_KEYDOWN()
00047   ON_WM_CHAR()
00048   ON_WM_SETFOCUS()
00049   ON_WM_SETCURSOR()
00050   ON_WM_LBUTTONDBLCLK()
00051   //}}AFX_MSG_MAP
00052 END_MESSAGE_MAP()
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // CDrawArea message handlers
00056
00057 void CDrawArea::AddKeystroke(char *mbsKey)
00058 {
00059   //
00060   // The backspace keystroke should erase the last character.
00061   //
00062   if (mbsKey[0] == VK_BACK)
00063   {
00064     int nStart, nEnd;
00065     GetSel(nStart, nEnd);
00066     SetSel(nEnd-1, nEnd);
00067     mbsKey[0] = '\0';
00068
00069         //
00070         // Erasing a line feed should erase the preceding carriage return.
00071         //
00072         CString strText;
00073         GetWindowText(strText);
00074         int iLength = strText.GetLength();
00075         if (iLength > 0 && strText.GetAt(strText.GetLength() - 1) == '\n')
00076             SetSel(nEnd-2, nEnd);
00077   }
00078
00079   //
00080   // Append a line feed to a carriage return.
00081   //
00082   else if (mbsKey[0] == VK_RETURN)
00083   {
00084     mbsKey[1] = '\xa';
00085     mbsKey[2] = '\0';
00086   }
00087
00088   //
00089   // Store the new keystroke.
00090   //
00091   ReplaceSel(mbsKey);
00092 }
00093
00094
00095 void CDrawArea::AddLine(LINE line)
00096 {
00097   //
00098   // Set the clipping region for the drawing.
00099   //
00100   CClientDC dc(this);
00101   RECT rect;
00102   GetClientRect(&rect);
00103   CRgn rgn;
00104   rgn.CreateRectRgnIndirect(&rect);
00105   dc.SelectClipRgn(&rgn);
00106
00107   //
00108   // Draw the line and save it for redrawing.
00109   //
00110   dc.MoveTo(line.ptStart);
00111   dc.LineTo(line.ptEnd);
00112     m_listLines.AddTail(line);
00113 }
00114
00115
00116 void CDrawArea::OnLButtonDown(UINT nFlags, CPoint point)
00117 {
00118   // TODO: Add your message handler code here and/or call the default.
00119
00120   m_ptLast = point;
00121   SetFocus();
00122 }
00123
00124
00125 void CDrawArea::OnMouseMove(UINT nFlags, CPoint point)
00126 {
00127   // TODO: Add your message handler code here and/or call the default.
00128
00129   if (nFlags & MK_LBUTTON)
00130   {
00131     //
00132     // Add the line drawn to the drawing.
00133     //
00134     LINE line;
00135     line.ptStart = m_ptLast;
00136     line.ptEnd = point;
00137         AddLine(line);
00138
00139     //
00140     // Send the line to the friend.
00141     //
00142     ((CDisdrawDlg *)GetParent())->SendMouseMovement(line);
00143
00144     //
00145     // Remember the end point of the line.
00146     //
00147     m_ptLast = point;
00148   }
00149 }
00150
00151
00152 void CDrawArea::OnPaint()
00153 {
00154   CPaintDC dc(this); // device context for painting
00155
00156   // TODO: Add your message handler code here.
00157
00158   //
00159   // Set the clipping region for the drawing.
00160   //
00161   RECT rect;
00162   GetClientRect(&rect);
00163   CRgn rgn;
00164   rgn.CreateRectRgnIndirect(&rect);
00165   dc.SelectClipRgn(&rgn);
00166
00167   //
00168   // Erase the drawing area.
00169   //
00170   dc.FillSolidRect(&rect, GetSysColor(COLOR_MENU));
00171
00172   //
00173   // Redisplay the text.
00174   //
00175     CString strText;
00176     GetWindowText(strText);
00177     dc.SelectStockObject(ANSI_VAR_FONT);
00178     rect.top++;
00179     rect.left++;
00180     dc.DrawText(strText, &rect, DT_TOP | DT_WORDBREAK);
00181
00182   //
00183   // Redraw each line.
00184   //
00185   LINE line;
00186   POSITION posLine = m_listLines.GetHeadPosition();
00187   while (posLine != NULL)
00188   {
00189     line = m_listLines.GetNext(posLine);
00190     dc.MoveTo(line.ptStart);
00191     dc.LineTo(line.ptEnd);
00192   }
00193
00194   // Do not call CEdit::OnPaint() for painting messages.
00195 }
00196
00197
00198 void CDrawArea::OnRButtonUp(UINT nFlags, CPoint point)
00199 {
00200   // TODO: Add your message handler code here and/or call the default.
00201
00202   //
00203   // Clear the drawing area.
00204   //
00205   SetSel(0, -1);
00206   Clear();
00207   m_listLines.RemoveAll();
00208   RedrawWindow();
00209 }
00210
00211
00212 BOOL CDrawArea::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00213 {
00214   // TODO: Add your message handler code here and/or call the default.
00215
00216   return 0;
00217 }
00218
00219
00220 void CDrawArea::OnSetFocus(CWnd* pOldWnd)
00221 {
00222   CEdit::OnSetFocus(pOldWnd);
00223
00224   // TODO: Add your message handler code here.
00225
00226   HideCaret();
00227 }
00228
00229
00230 HBRUSH CDrawArea::CtlColor(CDC* pDC, UINT nCtlColor)
00231 {
00232   // TODO: Change any attributes of the DC here.
00233   pDC->SetBkColor(GetSysColor(COLOR_MENU));
00234
00235   // TODO: Return a non-NULL brush if the parent's handler should not be called.
00236   return HBRUSH((CBrush *)pDC->SelectStockObject(LTGRAY_BRUSH));
00237 }
00238
00239
00240 void CDrawArea::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
00241 {
00242   // TODO: Add your message handler code here and/or call default.
00243
00244   switch (nChar)
00245   {
00246   case VK_LEFT:
00247   case VK_RIGHT:
00248   case VK_UP:
00249   case VK_DOWN:
00250   case VK_HOME: break;
00251   default:    CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
00252   }
00253 }
00254
00255
00256 void CDrawArea::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
00257 {
00258   // TODO: Add your message handler code here and/or call the default.
00259   ((CDisdrawDlg *)GetParent())->SendKeystroke(nChar);
00260
00261   CEdit::OnChar(nChar, nRepCnt, nFlags);
00262
00263   RedrawWindow();
00264 }
00265
00266
00267 void CDrawArea::OnLButtonDblClk(UINT nFlags, CPoint point)
00268 {
00269   // TODO: Add your message handler code here and/or call the default.
00270 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ADOCommandConstruction Member List

This is the complete list of members for msado15::ADOCommandConstruction, including all inherited members.
getOLEDBCommand() | msado15::ADOCommandConstruction |
iid | msado15::ADOCommandConstruction | [static]
setOLEDBCommand(IUnknown ppOLEDBCommand) | msado15::ADOCommandConstruction |
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/TextSINK.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

TextSINK.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      TEXTSINK.CPP
00003
00004   Summary:   Implementation file for the COTextPageSink COM Object Class.
00005              Connectable object notifications for textpage-related
00006              events are handled by COTextPageSink.
00007
00008              COTextPageSink offers a main IUnknown standard interface and
00009              the ITextPageSink custom interface (with the TextPage related
00010              event features). This multiple interface COM Object Class is
00011              achieved via the technique of nested classes.  The
00012              implementation of the ITextPageSink interface is nested
00013              inside the COTextPageSink Class.
00014
00015              For a comprehensive tutorial code tour of this module's
00016              contents and offerings see the tutorial PERCLIEN.HTM
00017              file. For more specific technical details on the internal
00018              workings see the comments dispersed throughout the module's
00019              source code.
00020
00021   Classes:   COTextPageSink.
00022
00023   Functions: none.
00024
00025   Origin:    5-24-97: atrent - Editor-inheritance from SINK.CPP in
00026              the STOCLIEN Tutorial Code Sample. [Revised]
00027
00028 ----------------------------------------------------------------------------
00029   This file is part of the Microsoft COM Tutorial Code Samples.
00030
00031   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00032
00033   This source code is intended only as a supplement to Microsoft
00034   Development Tools and/or on-line documentation.  See these other
00035   materials for detailed information regarding Microsoft code samples.
00036
00037   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00038   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00039   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00040   PARTICULAR PURPOSE.
00041 ==========================================================================+*/
00042
00043
00044 /*---------------------------------------------------------------------------
00045   We include WINDOWS.H for all Win32 applications.
00046   We include OLE2.H because we will be calling the COM/OLE Libraries.
00047   We include OLECTL.H because it has definitions for connectable objects.
00048   We include APPUTIL.H because we will be building this application using
00049     the convenient Virtual Window and Dialog classes and other
00050     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00051   We include IPAGES.H and PAGEGUID.H for the common Page-related
00052     Interface class, GUID, and CLSID specifications.
00053   We include TEXTWIN.H because CGuiText creates and uses a CTextWin to
00054     encapsulate the multiline text edit control.
00055   We include GUITEXT.H because it declares the class for the main C++
00056     object that can service the text page Sink events.
00057   We include TEXTSINK.H because it has the COTextPageSink class declaration.
00058 ---------------------------------------------------------------------------*/
00059 #include <windows.h>
00060 #include <ole2.h>
00061 #include <olectl.h>
00062 #include <apputil.h>
00063 #include <ipages.h>
00064 #include <pageguid.h>
00065 #include "textwin.h"
00066 #include "guitext.h"
00067 #include "textsink.h"
00068
00069
00070 /*---------------------------------------------------------------------------
00071   COTextPageSink's implementation of its main COM object class including
00072   Constructor, Destructor, QueryInterface, AddRef, and Release.
00073 ---------------------------------------------------------------------------*/
00074
00075 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00076   Method:   COTextPageSink::COTextPageSink
00077
00078   Summary:  COTextPageSink Constructor. Note the member initializer:
00079             "m_ImpITextPageSink(this, pUnkOuter)" which is used to pass
00080             the 'this' and pUnkOuter pointers of this constructor function
00081             to the constructor in the instantiation of the implementation
00082             of the CImpITextPageSink interface (which is nested inside
00083             this present COTextPageSink Object Class).
00084
00085   Args:     IUnknown* pUnkOuter,
00086               Pointer to the the outer Unknown.  NULL means this COM Object
00087               is not being Aggregated.  Non NULL means it is being created
00088               on behalf of an outside COM object that is reusing it via
00089               aggregation.
00090             CGuiList* pGuiList)
00091               Pointer to the main C++ object that can service the
00092               TextPageSink events.
00093
00094   Modifies: m_cRefs, m_pUnkOuter, m_pGuiList.
00095
00096   Returns:  void
00097 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00098 COTextPageSink::COTextPageSink(
00099   IUnknown* pUnkOuter,
00100   CGuiText* pGuiText) :
00101   m_ImpITextPageSink(this, pUnkOuter)
00102 {
00103   // Zero the COM object's reference count.
00104   m_cRefs = 0;
00105
00106   // No AddRef necessary if non-NULL, as we're nested.
00107   m_pUnkOuter = pUnkOuter;
00108
00109   // Assign the pointer to the Sink service C++ object.
00110   m_pGuiText = pGuiText;
00111
00112   return;
00113 }
00114
00115
00116 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00117   Method:   COTextPageSink::~COTextPageSink
00118
00119   Summary:  COTextPageSink Destructor.
00120
00121   Args:     void
00122
00123   Returns:  void
00124 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00125 COTextPageSink::~COTextPageSink(void)
00126 {
00127   return;
00128 }
00129
00130
00131 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00132   Method:   COTextPageSink::QueryInterface
00133
00134   Summary:  QueryInterface of the COTextPageSink non-delegating
00135             IUnknown implementation.
00136
00137   Args:     REFIID riid,
00138               [in] GUID of the Interface being requested.
00139             PPVOID ppv)
00140               [out] Address of the caller's pointer variable that will
00141               receive the requested interface pointer.
00142
00143   Returns:  HRESULT
00144 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00145 STDMETHODIMP COTextPageSink::QueryInterface(
00146                REFIID riid,
00147                PPVOID ppv)
00148 {
00149   HRESULT hr = E_NOINTERFACE;
00150
00151   *ppv = NULL;
00152
00153   if (IID_IUnknown == riid)
00154     *ppv = this;
00155   else if (IID_ITextPageSink == riid)
00156     *ppv = &m_ImpITextPageSink;
00157
00158   if (NULL != *ppv)
00159   {
00160     // We've handed out a pointer to the interface so obey the COM rules
00161     // and AddRef the reference count.
00162     ((LPUNKNOWN)*ppv)->AddRef();
00163     hr = NOERROR;
00164   }
00165
00166
00167   return (hr);
00168 }
00169
00170
00171 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00172   Method:   COTextPageSink::AddRef
00173
00174   Summary:  AddRef of the COTextPageSink non-delegating IUnknown
00175             implementation.
00176
00177   Args:     void
00178
00179   Modifies: m_cRefs.
00180
00181   Returns:  ULONG
00182               New value of m_cRefs (COM object's reference count).
00183 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00184 STDMETHODIMP_(ULONG) COTextPageSink::AddRef(void)
00185 {
00186   ULONG cRefs;
00187
00188   cRefs = ++m_cRefs;
00189
00190   return cRefs;
00191 }
00192
00193
00194 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00195   Method:   COTextPageSink::Release
00196
00197   Summary:  Release of the COTextPageSink non-delegating IUnknown
00198             implementation.
00199
00200   Args:     void
00201
00202   Modifies: m_cRefs.
00203
00204   Returns:  ULONG
00205               New value of m_cRefs (COM object's reference count).
00206 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00207 STDMETHODIMP_(ULONG) COTextPageSink::Release(void)
00208 {
00209   ULONG cRefs;
00210
00211   cRefs = --m_cRefs;
00212
00213   if (0 == cRefs)
00214   {
00215     // We artificially bump the main ref count to prevent reentrancy
00216     // via the main object destructor.  Not really needed in this
00217     // COTextPageSink but a good practice because we are aggregatable and
00218     // may at some point in the future add something entertaining like
00219     // some Releases to the COTextPageSink destructor.
00220     m_cRefs++;
00221     delete this;
00222   }
00223
00224   return cRefs;
00225 }
00226
00227
00228 /*---------------------------------------------------------------------------
00229   COTextPageSink's nested implementation of the ITextPageSink interface
00230   including Constructor, Destructor, QueryInterface, AddRef, Release,
00231   Loaded, Saved, Put, and Cleared. Methods in this interface are called by
00232   COM objects on the server side to send notifications to the client.
00233 ---------------------------------------------------------------------------*/
00234
00235 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00236   Method:   COTextPageSink::CImpITextPageSink::CImpITextPageSink
00237
00238   Summary:  Constructor for the CImpITextPageSink interface instantiation.
00239
00240   Args:     COTextPageSink* pCO,
00241               Back pointer to the parent outer object.
00242             IUnknown* pUnkOuter
00243               Pointer to the outer Unknown.  For delegation.
00244
00245   Modifies: m_pCO, m_pUnkOuter.
00246
00247   Returns:  void
00248 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00249 COTextPageSink::CImpITextPageSink::CImpITextPageSink(
00250   COTextPageSink* pCO,
00251   IUnknown* pUnkOuter)
00252 {
00253   // Init the main object pointer to point to the parent object.
00254   m_pCO = pCO;
00255
00256   // Init the CImpITextPageSink interface's delegating Unknown pointer. We
00257   // use the main object pointer for IUnknown delegation here if we are
00258   // not being aggregated.  If we are being aggregated we use the supplied
00259   // pUnkOuter for IUnknown delegation.  In either case the pointer
00260   // assignment requires no AddRef because the CImpITextPageSink lifetime
00261   // is quaranteed by the lifetime of the parent object in which
00262   // CImpITextPageSink is nested.
00263   if (NULL == pUnkOuter)
00264     m_pUnkOuter = pCO;
00265   else
00266     m_pUnkOuter = pUnkOuter;
00267
00268   return;
00269 }
00270
00271
00272 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00273   Method:   COTextPageSink::CImpITextPageSink::~CImpITextPageSink
00274
00275   Summary:  Destructor for the CImpITextPageSink interface instantiation.
00276
00277   Args:     void
00278
00279   Returns:  void
00280 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00281 COTextPageSink::CImpITextPageSink::~CImpITextPageSink(void)
00282 {
00283   return;
00284 }
00285
00286
00287 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00288   Method:   COTextPageSink::CImpITextPageSink::QueryInterface
00289
00290   Summary:  The QueryInterface IUnknown member of this ITextPageSink
00291             interface implementation that delegates to m_pUnkOuter,
00292             whatever it is.
00293
00294   Args:     REFIID riid,
00295               [in] GUID of the Interface being requested.
00296             PPVOID ppv)
00297               [out] Address of the caller's pointer variable that will
00298               receive the requested interface pointer.
00299
00300   Returns:  HRESULT
00301               Returned by the delegated outer QueryInterface call.
00302 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00303 STDMETHODIMP COTextPageSink::CImpITextPageSink::QueryInterface(
00304                REFIID riid,
00305                PPVOID ppv)
00306 {
00307   // Delegate this call to the outer object's QueryInterface.
00308   return m_pUnkOuter->QueryInterface(riid, ppv);
00309 }
00310
00311
00312 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00313   Method:   COTextPageSink::CImpITextPageSink::AddRef
00314
00315   Summary:  The AddRef IUnknown member of this ITextPageSink interface
00316             implementation that delegates to m_pUnkOuter, whatever it is.
00317
00318   Args:     void
00319
00320   Returns:  ULONG
00321               Returned by the delegated outer AddRef call.
00322 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00323 STDMETHODIMP_(ULONG) COTextPageSink::CImpITextPageSink::AddRef(void)
00324 {
00325   // Delegate this call to the outer object's AddRef.
00326   return m_pUnkOuter->AddRef();
00327 }
00328
00329
00330 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00331   Method:   COTextPageSink::CImpITextPageSink::Release
00332
00333   Summary:  The Release IUnknown member of this ITextPageSink interface
00334             implementation that delegates to m_pUnkOuter, whatever it is.
00335
00336   Args:     void
00337
00338   Returns:  ULONG
00339               Returned by the delegated outer Release call.
00340 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00341 STDMETHODIMP_(ULONG) COTextPageSink::CImpITextPageSink::Release(void)
00342 {
00343   // Delegate this call to the outer object's Release.
00344   return m_pUnkOuter->Release();
00345 }
00346
00347
00348 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00349   Method:   COTextPageSink::CImpITextPageSink::Loaded
00350
00351   Summary:  The COTextPage object's text data was loaded from a client's
00352             compound file.
00353
00354   Args:     void
00355
00356   Returns:  HRESULT
00357               Standard result code. NOERROR for success.
00358 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00359 STDMETHODIMP COTextPageSink::CImpITextPageSink::Loaded(
00360                void)
00361 {
00362   HRESULT hr = E_NOTIMPL;
00363
00364   // For future evolution.
00365
00366   return hr;
00367 }
00368
00369
00370 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00371   Method:   COTextPageSink::CImpITextPageSink::Saved
00372
00373   Summary:  The COTextPage object's text data was saved to a client's
00374             compound file.
00375
00376   Args:     void
00377
00378   Returns:  HRESULT
00379               Standard result code. NOERROR for success.
00380 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00381 STDMETHODIMP COTextPageSink::CImpITextPageSink::Saved(
00382                void)
00383 {
00384   HRESULT hr = E_NOTIMPL;
00385
00386   // For future evolution.
00387
00388   return hr;
00389 }
00390
00391
00392 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00393   Method:   COTextPageSink::CImpITextPageSink::Put
00394
00395   Summary:  A client put new text data into the shared COTextPage.
00396
00397   Args:     void
00398
00399   Returns:  HRESULT
00400               Standard result code. NOERROR for success.
00401 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00402 STDMETHODIMP COTextPageSink::CImpITextPageSink::Put(
00403                void)
00404 {
00405   HRESULT hr = E_NOTIMPL;
00406
00407   // For future evolution.
00408
00409   return hr;
00410 }
00411
00412
00413 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00414   Method:   COTextPageSink::CImpITextPageSink::Cleared
00415
00416   Summary:  A client cleared all text data in the shared COTextPage.
00417
00418   Args:     void
00419
00420   Returns:  HRESULT
00421               Standard result code. NOERROR for success.
00422 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00423 STDMETHODIMP COTextPageSink::CImpITextPageSink::Cleared(
00424                void)
00425 {
00426   HRESULT hr = E_NOTIMPL;
00427
00428   // For future evolution.
00429
00430   return hr;
00431 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/RenderBehave/renderproject/Stdafx.h Source File

  • Web
  • Browser
  • RenderBehave
  • renderproject

Stdafx.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.h : include file for standard system include files,
00006 //      or project specific include files that are used frequently,
00007 //      but are changed infrequently.
00008
00009 #if !defined(AFX_STDAFX_H__140D5503_2290_11D2_AF61_00A0C9C9E6C5__INCLUDED_)
00010 #define AFX_STDAFX_H__140D5503_2290_11D2_AF61_00A0C9C9E6C5__INCLUDED_
00011
00012 #if _MSC_VER >= 1000
00013 #pragma once
00014 #endif // _MSC_VER >= 1000
00015
00016 #define STRICT
00017
00018
00019 #define _WIN32_WINNT 0x0400
00020 #define _ATL_APARTMENT_THREADED
00021
00022 #include <atlbase.h>
00023
00024 //You may derive a class from CComModule and use it if you want to override
00025 //something, but do not change the name of _Module
00026 extern CComModule _Module;
00027 #include <atlcom.h>
00028 #include <atlctl.h>   // IObjectSafetyImpl
00029
00030 #include <mshtmdid.h> // DHTML Behavior identifiers
00031 #include <mshtmhst.h> // DHTML Behavior interfaces
00032 #include <mshtml.h>
00033
00034 //{{AFX_INSERT_LOCATION}}
00035 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00036
00037 #endif // !defined(AFX_STDAFX_H__140D5503_2290_11D2_AF61_00A0C9C9E6C5__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/MessageDlg.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

MessageDlg.Cpp

Go to the documentation of this file.
00001 // MessageDlg.cpp : implementation file
00002 //
00003 //  Copyright 1995-1998, Citrix Systems Inc.
00004 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00005
00006
00007 #include "stdafx.h"
00008 #include "API.h"
00009 #include "APIDoc.h"
00010 #include "MessageDlg.h"
00011
00012 #ifdef _DEBUG
00013 #define new DEBUG_NEW
00014 #undef THIS_FILE
00015 static char THIS_FILE[] = __FILE__;
00016 #endif
00017
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // CMessageDlg dialog
00021
00022
00023 CMessageDlg::CMessageDlg(CWnd* pParent /*=NULL*/)
00024   : CDialog(CMessageDlg::IDD, pParent)
00025 {
00026   //{{AFX_DATA_INIT(CMessageDlg)
00027   m_message = _T("");
00028   //}}AFX_DATA_INIT
00029 }
00030
00031
00032 void CMessageDlg::DoDataExchange(CDataExchange* pDX)
00033 {
00034   CDialog::DoDataExchange(pDX);
00035   //{{AFX_DATA_MAP(CMessageDlg)
00036   DDX_Control(pDX, IDC_SERVERNAME, m_serverName);
00037   DDX_Control(pDX, IDC_SEND_MESSAGE, m_sendMessage);
00038   DDX_Text(pDX, IDC_SEND_MESSAGE, m_message);
00039   //}}AFX_DATA_MAP
00040 }
00041
00042
00043 BEGIN_MESSAGE_MAP(CMessageDlg, CDialog)
00044   //{{AFX_MSG_MAP(CMessageDlg)
00045   ON_BN_CLICKED(ID_SEND_MESSAGE, OnSendMessage)
00046   //}}AFX_MSG_MAP
00047 END_MESSAGE_MAP()
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // CMessageDlg message handlers
00051
00052 void CMessageDlg::OnSendMessage()
00053 {
00054   LPSTR serverName = g_pDoc->GetServerName();
00055   HANDLE serverHandle =  WTSOpenServer(serverName);
00056   DWORD Response;
00057   int messageLength;
00058   m_sendMessage.GetWindowText(m_message);
00059   messageLength = m_message.GetLength();
00060
00061   //int GetLine( int nIndex, LPTSTR lpszBuffer ) const;
00062   //int GetLineCount( ) const;
00063
00064   if (WTSSendMessage(serverHandle, 0, "Test Message", sizeof("Test Message"),
00065       (char *) LPCTSTR(m_message), messageLength+1,
00066       MB_OKCANCEL, 5, &Response, 1))
00067     AfxMessageBox("Message was sent");
00068   else
00069     AfxMessageBox("Unable to send message");
00070
00071   //CString temp
00072   //temp.Format("%d,
00073
00074   WTSCloseServer(serverHandle);
00075 }
00076
00077 BOOL CMessageDlg::OnInitDialog()
00078 {
00079   CDialog::OnInitDialog();
00080   LPSTR serverName = g_pDoc->GetServerName();
00081   CString serverDisplay;
00082   serverDisplay = "Enter in message to send to ";
00083   if (*serverName == NULL)
00084     serverDisplay += "local server";
00085   else
00086     serverDisplay += serverName;
00087   m_serverName.SetWindowText(serverDisplay);
00088
00089   return TRUE;  // return TRUE unless you set the focus to a control
00090                 // EXCEPTION: OCX Property Pages should return FALSE
00091 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_HASH_TABLE Member List

This is the complete list of members for _HASH_TABLE, including all inherited members.
pfnCompare | _HASH_TABLE
pfnDisplay | _HASH_TABLE
pfnFree | _HASH_TABLE
pfnHash | _HASH_TABLE
pleBuckets | _HASH_TABLE
ulNumBuckets | _HASH_TABLE
ulNumEntries | _HASH_TABLE
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step4/DimmerService.cpp Source File

  • NetDS
  • upnp
  • StepByStep
  • Step4

DimmerService.cpp

Go to the documentation of this file.
00001 // DimmerService.cpp : Implementation of CDimmerService
00002 #include "stdafx.h"
00003 #include "MyDevice.h"
00004 #include "DimmerService.h"
00005
00006 CDimmerService::CDimmerService()
00007 {
00008   //set the default values for the state table variables power and dimLevel
00009     power = VARIANT_FALSE;
00010   dimnessLevel = 0;
00011
00012   InitializeCriticalSection(&csSync);
00013
00014   esEventingManager = NULL; // Make it NULL and this will be later set when the device host calls the Advise()
00015 }
00016
00017
00018
00019 CDimmerService::~CDimmerService()
00020 {
00021   //Cleanup before the service exits
00022     if (esEventingManager)
00023   {
00024         // we have to release the pointer to the Eventing Manager Interface on shutdown
00025         esEventingManager->Release();
00026         esEventingManager = NULL;
00027     }
00028
00029   DeleteCriticalSection(&csSync);
00030 }
00031
00032
00033
00034 HRESULT CDimmerService::get_Power(VARIANT_BOOL *pval)
00035 {
00036     // return the value of the state table variable Power
00037   EnterCriticalSection(&csSync);
00038     *pval = power;
00039   LeaveCriticalSection(&csSync);
00040     return S_OK;
00041 }
00042
00043
00044
00045 HRESULT CDimmerService::get_dimLevel(LONG *dLevel)
00046 {
00047     // return the value of the state table variable dimLevel
00048   EnterCriticalSection(&csSync);
00049     *dLevel = dimnessLevel;
00050   LeaveCriticalSection(&csSync);
00051     return S_OK;
00052 }
00053
00054
00055
00056 HRESULT CDimmerService::PowerOn()
00057 {
00058     DISPID rgdispidChanges[1];
00059
00060   EnterCriticalSection(&csSync);
00061
00062   if(power!=VARIANT_TRUE)
00063   {
00064         power = VARIANT_TRUE;
00065     LeaveCriticalSection(&csSync);
00066
00067         // We have to send an event here indicating that the value of Power has changed
00068         if(esEventingManager)
00069     {
00070             // Send the event that power = TRUE through OnStateChanged API exposed by IUPnPEventSource
00071             rgdispidChanges[0]=DISPID_POWER;
00072             esEventingManager->OnStateChanged(1, rgdispidChanges);
00073         }
00074     }
00075   else
00076     LeaveCriticalSection(&csSync);
00077
00078   return S_OK;
00079 }
00080
00081
00082
00083
00084 HRESULT CDimmerService::PowerOff()
00085 {
00086     DISPID rgdispidChanges[1];
00087
00088   EnterCriticalSection(&csSync);
00089     if(power!=VARIANT_FALSE)
00090   {
00091         power = VARIANT_FALSE;
00092         // We have to send an event here since the value of a State table variable has changed
00093     LeaveCriticalSection(&csSync);
00094
00095     if(esEventingManager)
00096     {
00097             // Send the event using the OnStateChanged API and indicate the the value of the State table variable Power
00098       //has changed
00099             rgdispidChanges[0]=DISPID_POWER;
00100             esEventingManager->OnStateChanged(1, rgdispidChanges);
00101         }
00102     }
00103   else
00104     LeaveCriticalSection(&csSync);
00105
00106     return S_OK;
00107 }
00108
00109
00110
00111 HRESULT CDimmerService::GetPowerValue(VARIANT_BOOL*powerVal)
00112 {
00113   EnterCriticalSection(&csSync);
00114   *powerVal = power;
00115   LeaveCriticalSection(&csSync);
00116
00117   // We have no events to send for this action
00118     return S_OK;
00119 }
00120
00121
00122
00123 HRESULT CDimmerService::SetDimLevel(LONG dLevel)
00124 {
00125     DISPID rgdispidChanges[1];
00126
00127   EnterCriticalSection(&csSync);
00128   dimnessLevel = dLevel;
00129   //the possible values for dimnessLevel are 0 - 100
00130   if (dimnessLevel>100) dimnessLevel=100;
00131   if(dimnessLevel <0) dimnessLevel=0;
00132   LeaveCriticalSection(&csSync);
00133
00134   // We have to send an event here
00135   if(esEventingManager)
00136   {
00137             // Send the event using the OnStateChanged API to indicate that value of State table varaible dimLevel has
00138       //changed
00139             rgdispidChanges[0]=DISPID_DIMLEVEL;
00140             esEventingManager->OnStateChanged(1, rgdispidChanges);
00141     }
00142
00143     return S_OK;
00144 }
00145
00146
00147 HRESULT CDimmerService::GetDimLevel(LONG *dLevel)
00148 {
00149   EnterCriticalSection(&csSync);
00150   *dLevel = dimnessLevel;
00151   LeaveCriticalSection(&csSync);
00152
00153   // We have no events to send here as the state table has not changed
00154     return S_OK;
00155 }
00156
00157
00158
00159 HRESULT CDimmerService::GetConfigDetails(VARIANT_BOOL *powerVal,LONG *dLevel)
00160 {
00161   EnterCriticalSection(&csSync);
00162   *dLevel = dimnessLevel;
00163   *powerVal = power;
00164   LeaveCriticalSection(&csSync);
00165
00166   // We have no events to send here as the state table has not changed
00167     return S_OK;
00168 }
00169
00170
00171 HRESULT CDimmerService::Advise (IUPnPEventSink *punkSubscriber)
00172 {
00173     // We have to get query for the IUPnPEventSink Interface to send events later  using the OnStateChanged API
00174
00175     HRESULT hr = S_OK;
00176
00177   //query the pointer passed to the Advise function for the IUPnPEventSink Interface
00178     hr = punkSubscriber->QueryInterface(IID_IUPnPEventSink, (void **)&esEventingManager);
00179     if(FAILED(hr))
00180   {
00181         OutputDebugString(_TEXT("CDimmerService: Query Interface failed.Could not get pointer to IUPnPEventSink\n"));
00182         return hr;
00183     }
00184
00185     return hr;
00186 }
00187
00188
00189
00190 HRESULT CDimmerService::Unadvise(IUPnPEventSink *punkSubscriber)
00191 {
00192   //Device Host is not interested in receiving more events and so set the pointer to the IUPnPEventSink interface
00193   //to NULL
00194     if (esEventingManager)
00195   {
00196         // esEventingManager is already set by the advise
00197         esEventingManager->Release();
00198         esEventingManager = NULL;
00199     }
00200
00201     return S_OK;
00202 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/McastIP/resolve.h Source File

  • NetDS
  • WinSock
  • McastIP

resolve.h

Go to the documentation of this file.
00001 //
00002 // This file contains function prototypes for resolve.cpp
00003 //
00004 // Description:
00005 //    These are common routines for resolving and printing IPv4 and IPv6
00006 //    addresses.
00007 //
00008 // NOTE:
00009 //   From Network Programming for Microsoft Windows, Second Edition
00010 //   by Anthony Jones and James Ohlund.  Copyright 2002.
00011 //   Reproduced by permission of Microsoft Press.  All rights reserved.
00012 //
00013 #ifndef _RESOLVE_H_
00014 #define _RESOLVE_H_
00015
00016 #ifdef _cplusplus
00017 extern "C" {
00018 #endif
00019
00020 int              PrintAddress(SOCKADDR *sa, int salen);
00021 int              FormatAddress(SOCKADDR *sa, int salen, char *addrbuf, int addrbuflen);
00022 int              ReverseLookup(SOCKADDR *sa, int salen, char *namebuf, int namebuflen);
00023 struct addrinfo *ResolveAddress(char *addr, char *port, int af, int type, int proto);
00024
00025 #ifdef _cplusplus
00026 }
00027 #endif
00028
00029 #endif
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Common/VListVw/Resource.h Source File

  • WinUI
  • Controls
  • Common
  • VListVw

Resource.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 //{{NO_DEPENDENCIES}}
00011 // Microsoft Developer Studio generated include file.
00012 // Used by VListVw.rc
00013 //
00014 #define IDS_APPTITLE                    1
00015 #define IDD_ABOUT                       100
00016 #define IDI_MAINICON                    101
00017 #define IDM_MAIN_MENU                   102
00018 #define IDM_CONTEXT_MENU                103
00019 #define IDI_DISK                        104
00020 #define IDM_EXIT                        100
00021 #define IDM_ABOUT                       101
00022 #define IDM_LARGE_ICONS                 200
00023 #define IDM_SMALL_ICONS                 201
00024 #define IDM_LIST                        202
00025 #define IDM_REPORT                      203
00026
00027 // Next default values for new objects
00028 //
00029 #ifdef APSTUDIO_INVOKED
00030 #ifndef APSTUDIO_READONLY_SYMBOLS
00031 #define _APS_NEXT_RESOURCE_VALUE        105
00032 #define _APS_NEXT_COMMAND_VALUE         102
00033 #define _APS_NEXT_CONTROL_VALUE         1000
00034 #define _APS_NEXT_SYMED_VALUE           102
00035 #endif
00036 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagPREPAREFORSYNCMSG Member List

This is the complete list of members for _tagPREPAREFORSYNCMSG, including all inherited members.
cbNumItems | _tagPREPAREFORSYNCMSG
dwReserved | _tagPREPAREFORSYNCMSG
hWndParent | _tagPREPAREFORSYNCMSG
pItemIDs | _tagPREPAREFORSYNCMSG
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIRowset Member List

This is the complete list of members for CImpIRowset, including all inherited members.
AddRefRows(DBCOUNTITEM, const HROW rghRows[], DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[]) | CImpIRowset
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowset) | CImpIRowset
GetData(HROW, HACCESSOR, void *) | CImpIRowset
GetNextRows(HCHAPTER, DBROWOFFSET, DBROWCOUNT, DBCOUNTITEM *, HROW **) | CImpIRowset
ReleaseRows(DBCOUNTITEM, const HROW rghRows[], DBROWOPTIONS rgRowOptions[], DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[]) | CImpIRowset
RestartPosition(HCHAPTER) | CImpIRowset
Generated on Wed Nov 13 2024 16:56:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CVirtualFile Member List

This is the complete list of members for CVirtualFile, including all inherited members.
AddMenuItems(LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR *pInsertionAllowed) | CVirtualFile | [virtual]
AddMenuItems(LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR *pInsertionAllowed) | CVirtualFile | [virtual]
AddMenuItems(LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR *pInsertionAllowed) | CVirtualFile | [virtual]
AddMenuItems(LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR *pInsertionAllowed) | CVirtualFile | [virtual]
AddMenuItems(LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR *pInsertionAllowed) | CVirtualFile | [virtual]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
CBaseNode() | CBaseNode | [inline]
Command(long lCommandID) | CVirtualFile | [virtual]
Command(long lCommandID) | CVirtualFile | [virtual]
Command(long lCommandID) | CVirtualFile | [virtual]
Command(long lCommandID) | CVirtualFile | [virtual]
Command(long lCommandID) | CVirtualFile | [virtual]
ControlbarNotify(LPARAM nArg, LPARAM lParam, LONG_PTR pComp) | CVirtualFile | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpCallback, LONG_PTR Handle) | CVirtualFile | [virtual]
CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpCallback, LONG_PTR Handle) | CVirtualFile | [virtual]
CVirtualFile() | CVirtualFile |
CVirtualFile() | CVirtualFile |
CVirtualFile() | CVirtualFile |
CVirtualFile() | CVirtualFile |
CVirtualFile() | CVirtualFile |
GetAttributes() | CVirtualFile | [inline, virtual]
GetAttributes() | CVirtualFile | [inline, virtual]
GetAttributes() | CVirtualFile | [inline, virtual]
GetAttributes() | CVirtualFile | [inline, virtual]
GetAttributeString() | CVirtualFile | [virtual]
GetAttributeString() | CVirtualFile | [virtual]
GetAttributeString() | CVirtualFile | [virtual]
GetAttributeString() | CVirtualFile | [virtual]
GetAttributeString() | CVirtualFile | [virtual]
GetDescriptionString() | CVirtualFile | [inline]
GetDisplayInfo(SCOPEDATAITEM *pSDI) | CVirtualFile | [inline, virtual]
GetDisplayInfo(RESULTDATAITEM *pRDI) | CVirtualFile | [virtual]
GetDisplayInfo(SCOPEDATAITEM *pSDI) | CVirtualFile | [inline, virtual]
GetDisplayInfo(RESULTDATAITEM *pRDI) | CVirtualFile | [virtual]
GetDisplayInfo(SCOPEDATAITEM *pSDI) | CVirtualFile | [inline, virtual]
GetDisplayInfo(RESULTDATAITEM *pRDI) | CVirtualFile | [virtual]
GetDisplayInfo(SCOPEDATAITEM *pSDI) | CVirtualFile | [inline, virtual]
GetDisplayInfo(RESULTDATAITEM *pRDI) | CVirtualFile | [virtual]
GetDisplayInfo(SCOPEDATAITEM *pSDI) | CVirtualFile | [inline, virtual]
GetDisplayInfo(RESULTDATAITEM *pRDI) | CVirtualFile | [virtual]
GetNodeGUID() | CVirtualFile | [inline, virtual]
GetNodeGUID() | CVirtualFile | [inline, virtual]
GetNodeGUID() | CVirtualFile | [inline, virtual]
GetNodeGUID() | CVirtualFile | [inline, virtual]
GetNodeGUID() | CVirtualFile | [inline, virtual]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeName() | CBaseNode | [inline]
GetNodeType() | CVirtualFile | [inline, virtual]
GetNodeType() | CVirtualFile | [inline, virtual]
GetNodeType() | CVirtualFile | [inline, virtual]
GetNodeType() | CVirtualFile | [inline, virtual]
GetNodeType() | CVirtualFile | [inline, virtual]
GetObjectPath() | CVirtualFile | [inline, virtual]
GetParent() | CVirtualFile | [inline]
GetProperties(LPNODEPROPS *ppNodeProps) | CVirtualFile | [virtual]
GetProperty(BSTR bstrPropertyName, PBSTR pbstrProperty) | CVirtualFile | [virtual]
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CVirtualFile | [inline, virtual]
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CVirtualFile | [inline, virtual]
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CVirtualFile | [inline, virtual]
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CVirtualFile | [inline, virtual]
GetResultViewType2(MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo) | CVirtualFile | [inline, virtual]
GetWatermarks(HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CVirtualFile | [virtual]
GetWatermarks(HBITMAP __RPC_FAR *lphWatermark, HBITMAP __RPC_FAR *lphHeader, HPALETTE __RPC_FAR *lphPalette, BOOL __RPC_FAR *bStretch) | CVirtualFile | [virtual]
Initialize(LPNODEPROPS pNodeProps) | CVirtualFile | [virtual]
Initialize(NODE_PROPERTIES *pNodeProps) | CVirtualFile | [virtual]
Initialize(LPNODEPROPS pNodeProps) | CVirtualFile | [virtual]
Initialize(NODE_PROPERTIES *pNodeProps) | CVirtualFile | [virtual]
Initialize(NODE_PROPERTIES *pNodeProps) | CVirtualFile | [virtual]
IsAttributeSet(DWORD dwAttribute) | CVirtualFile | [virtual]
IsAttributeSet(DWORD dwAttribute) | CVirtualFile | [virtual]
IsAttributeSet(DWORD dwAttribute) | CVirtualFile | [virtual]
IsAttributeSet(DWORD dwAttribute) | CVirtualFile | [virtual]
IsAttributeSet(DWORD dwAttribute) | CVirtualFile | [virtual]
m_dwAttributes | CVirtualFile | [private]
m_InitTime | CVirtualFile | [private]
m_nNotifyHandle | CVirtualFile |
m_nPropPageCount | CBaseNode | [protected]
m_pAttribStr | CVirtualFile | [private]
m_pAttributeStr | CVirtualFile | [private]
m_pCompData | CVirtualFile | [private]
m_pComponent | CVirtualFile | [private]
m_pDescripStr | CVirtualFile | [private]
m_pParentFolder | CVirtualFile | [private]
m_pwszNodeName | CBaseNode | [protected]
m_RDI | CBaseNode |
m_SDI | CBaseNode |
m_thisGUID | CVirtualFile | [private, static]
OnApplyChanges(HWND hPage, WPARAM wParam, LPARAM lParam) | CVirtualFile | [private]
OnApplyChanges(HWND hPage, WPARAM wParam, LPARAM lParam) | CVirtualFile | [private]
OnContextHelp(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnCutOrMove(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnDelete(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnDelete(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnDelete(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnExpand(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnExpand(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnExpand(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnExpand(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnExpand(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnInitPropPage(HWND hPage, WPARAM wParam, LPARAM lParam) | CVirtualFile | [private]
OnInitPropPage(HWND hPage, WPARAM wParam, LPARAM lParam) | CVirtualFile | [private]
OnPaste(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnQueryPaste(LPDATAOBJECT ipTargetDO, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnRemoveChildren(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnRemoveChildren(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnRemoveChildren(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnRemoveChildren(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnRemoveChildren(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData) | CVirtualFile | [inline, virtual]
OnRename(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnRename(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnRename(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnSelect(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnSelect(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnSelect(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnSelect(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnSelect(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnShow(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnShow(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnShow(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnShow(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnShow(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [virtual]
OnViewChange(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [inline, virtual]
OnViewChange(LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent) | CVirtualFile | [inline, virtual]
CBaseNode::OnViewChange(LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam, LONG_PTR pComponent) | CBaseNode | [inline, virtual]
PPageWndProc0(HWND hPage, UINT uMsg, WPARAM wParam, LPARAM lParam) | CVirtualFile | [private, static]
PPageWndProc0(HWND hPage, UINT uMsg, WPARAM wParam, LPARAM lParam) | CVirtualFile | [private, static]
QueryForPropertyPage() | CVirtualFile | [virtual]
QueryForPropertyPage() | CVirtualFile | [virtual]
RemoveAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
RemoveAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
RemoveAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
RemoveAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
RemoveAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
SetAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
SetAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
SetAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
SetAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
SetAttribute(DWORD dwAttribute) | CVirtualFile | [virtual]
thisGUID | CVirtualFile | [private, static]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CBaseNode() | CBaseNode | [inline, virtual]
~CVirtualFile() | CVirtualFile | [virtual]
~CVirtualFile() | CVirtualFile | [virtual]
~CVirtualFile() | CVirtualFile | [virtual]
~CVirtualFile() | CVirtualFile | [virtual]
~CVirtualFile() | CVirtualFile | [virtual]
Generated on Wed Nov 13 2024 16:57:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinCap32/Resource.h Source File

  • Multimedia
  • Gdi
  • WinCap32

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // App Studio generated include file.
00003 // Used by WINCAP.RC
00004 //
00005 #define IDS_RECT2                       2
00006 #define IDS_RECT3                       3
00007 #define IDS_SELECT2                     5
00008 #define IDS_SELECT3                     6
00009 #define IDS_MAINWINDOWTITLE       7
00010 #define IDS_WINCAPRUNNING               8
00011 #define IDS_NOIMAGE                     9
00012 #define IDS_VWFULLSCRN                  10
00013 #define IDS_SAVEBMP                     11
00014 #define IDS_CAPTEDALREADY               12
00015 #define IDS_CANTSAVE                    13
00016 #define IDS_SAVEERROR                   14
00017 #define IDS_ENTIRESCRN                  15
00018 #define IDS_USERSELECT                  16
00019 #define IDS_CANTCAPWNDW                 17
00020 #define IDS_WNDWNOTVIS                  18
00021 #define IDS_INTERROR                    19
00022 #define IDS_SAVEFILTER                  20
00023 #define IDD_SELECT                      102
00024 #define IDC_STATIC_RECT2                1002
00025 #define IDC_STATIC_RECT3                1003
00026 #define IDC_STATIC_SELECT2              1004
00027 #define IDC_STATIC_SELECT3              1005
00028 #define IDC_STATIC                      -1
00029
00030 // Next default values for new objects
00031 //
00032 #ifdef APSTUDIO_INVOKED
00033 #ifndef APSTUDIO_READONLY_SYMBOLS
00034
00035 #define _APS_NEXT_RESOURCE_VALUE        105
00036 #define _APS_NEXT_COMMAND_VALUE         101
00037 #define _APS_NEXT_CONTROL_VALUE         1006
00038 #define _APS_NEXT_SYMED_VALUE           101
00039 #endif
00040 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/FullSvr/stdafx.Cpp Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • FullSvr

stdafx.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: StdAfx.cpp
00004
00005 Summary:  Produced by VS6 ATL Wizard.
00006
00007 ----------------------------------------------------------------------------
00008
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021
00022 ==========================================================================+*/
00023
00024 #include "stdafx.h"
00025
00026 #ifdef _ATL_STATIC_REGISTRY
00027 #include <statreg.h>
00028 #include <statreg.cpp>
00029 #endif
00030
00031 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/basesnap.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

basesnap.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  This file contains implementations for IClassFactory
00014 //             and the Snap-in's DLL exported functions
00015
00016
00017 #include <ObjBase.h>
00018 #include <InitGuid.h>
00019 #include "Globals.h"
00020 #include "BaseSnap.h"
00021 #include "CompData.h"
00022 #include "About.h"
00023 #include "Registry.h"
00024
00025
00026 #include "TraceMacro.h"
00027 #undef  MODULESTRING
00028 #define MODULESTRING  _T("BaseSnap")
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 //  Implementation of IClassFactory for CComponentData
00033
00034 //---------------------------------------------------------------------------
00035 CClassFactory::CClassFactory( FACTORY_TYPE eFactoryType )
00036 {
00037   m_cRef = 0;
00038   m_FactoryType = eFactoryType;
00039
00040   InterlockedIncrement((long*)&g_uObjectCount);
00041 }
00042
00043
00044 //---------------------------------------------------------------------------
00045 CClassFactory::~CClassFactory()
00046 {
00047   InterlockedDecrement((long*)&g_uObjectCount);
00048 }
00049
00050
00051 //---------------------------------------------------------------------------
00052 STDMETHODIMP CClassFactory::QueryInterface
00053 (
00054   REFIID   riid,             //[in] Identifier of the requested interface
00055   LPVOID*  ppv               //[out] Address of requested interface
00056 )
00057 {
00058   if( NULL == ppv )
00059     return E_FAIL;
00060
00061   HRESULT hResult = E_NOINTERFACE;
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065   {
00066     *ppv = static_cast<IClassFactory*>(this);
00067   }
00068   else if( IsEqualIID(riid, IID_IClassFactory) )
00069   {
00070     *ppv = static_cast<IClassFactory*>(this);
00071   }
00072
00073   if( *ppv )
00074   {
00075     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00076     hResult = S_OK;
00077   }
00078
00079   return hResult;
00080 }
00081
00082
00083 //---------------------------------------------------------------------------
00084 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00085 {
00086   return InterlockedIncrement( (long*)&m_cRef );
00087 }
00088
00089
00090 //---------------------------------------------------------------------------
00091 STDMETHODIMP_(ULONG) CClassFactory::Release()
00092 {
00093   if( 0 == InterlockedDecrement( (long*)&m_cRef) )
00094   {
00095     delete this;
00096     return 0;
00097   }
00098   return m_cRef;
00099 }
00100
00101 //---------------------------------------------------------------------------
00102 //  Creates an instance of the object type which was passed in the
00103 //  class constructor
00104 //
00105 STDMETHODIMP CClassFactory::CreateInstance
00106 (
00107   LPUNKNOWN  pUnkOuter,      //[in] NULL unless object is part of aggregate
00108   REFIID     riid,           //[in] Reference to interface indentifier
00109   LPVOID*    ppvObj          //[out] Address of requested interface pointer
00110 )
00111 {
00112   HRESULT  hResult = E_FAIL;
00113   void*    pObject = NULL;
00114
00115   if( NULL == ppvObj )
00116     return hResult;
00117
00118   *ppvObj = NULL;
00119
00120   // Our object does does not support aggregation, so we need to
00121   // fail if they ask us to do aggregation.
00122   if( pUnkOuter )
00123     return CLASS_E_NOAGGREGATION;
00124
00125   // Support for providing CSnapinAbout/CComponentData objects
00126   switch( m_FactoryType )
00127   {
00128     case COMPONENTDATA:
00129       pObject = new CComponentData();
00130       break;
00131
00132     case ABOUT:
00133       pObject = new CSnapinAbout();
00134       break;
00135
00136     default:
00137       pObject = NULL;
00138   }
00139
00140   if( NULL == pObject )                // Failed to create an object
00141     return E_INVALIDARG;               // due to bad argument
00142
00143   // QueryInterface will do the AddRef() for us, don't do it here
00144   hResult = ( (LPUNKNOWN)pObject)->QueryInterface( riid, ppvObj );
00145
00146   if( S_OK != hResult )
00147     delete pObject;
00148
00149   return hResult;
00150 }
00151
00152
00153 //---------------------------------------------------------------------------
00154 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00155 {
00156   if( TRUE == fLock )
00157     InterlockedIncrement((long*)&g_uServerLocks);
00158   else
00159     InterlockedDecrement((long*)&g_uServerLocks);
00160
00161   return S_OK;
00162 }
00163
00164
00165 /////////////////////////////////////////////////////////////////////////////
00166 //  Our Snap-in's exported functions
00167 //
00168
00169 //---------------------------------------------------------------------------
00170 //  Entry point into our Snap-in DLL
00171 //
00172 BOOL WINAPI DllMain
00173 (
00174   HINSTANCE  hInstDLL,         //[in] Handle to DLL module
00175   DWORD      fdwReason,        //[in] Reason for calling function
00176   void*      lpvReserved       //[in] Reserved
00177 )
00178 {
00179   if( DLL_PROCESS_ATTACH == fdwReason )
00180   {
00181      g_hInst = hInstDLL;
00182   }
00183
00184   return TRUE;
00185 }
00186
00187
00188 //---------------------------------------------------------------------------
00189 STDAPI DllGetClassObject
00190 (
00191   REFCLSID   rclsid,         //[in] CLSID for the class object
00192   REFIID     riid,           //[in] Reference to interface identifier
00193   LPVOID     *ppvObj         //[out] Object which recieves interface pointer
00194 )
00195 {
00196   // Test for CSnapinAbout
00197   if( (rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout) )
00198     return CLASS_E_CLASSNOTAVAILABLE;
00199
00200   if( !ppvObj )
00201     return E_FAIL;
00202
00203   *ppvObj = NULL;
00204
00205   // We can only hand out IUnknown and IClassFactory pointers.  Fail
00206   // if caller asks for anything else.
00207   if( !IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory) )
00208     return E_NOINTERFACE;
00209
00210   CClassFactory *pFactory = NULL;
00211
00212   // Create the new class factory.  Pass in the type of object to create
00213   if( rclsid == CLSID_CComponentData )
00214     pFactory = new CClassFactory(CClassFactory::COMPONENTDATA);
00215   else if( rclsid == CLSID_CSnapinAbout )
00216     pFactory = new CClassFactory(CClassFactory::ABOUT);
00217
00218
00219   HRESULT hResult = pFactory->QueryInterface( riid, ppvObj );
00220
00221   return hResult;
00222 }
00223
00224
00225 //---------------------------------------------------------------------------
00226 STDAPI DllCanUnloadNow(void)
00227 {
00228   if( 0 == g_uObjectCount && 0 == g_uServerLocks )
00229     return S_OK;
00230   else
00231     return S_FALSE;
00232 }
00233
00234
00235 //---------------------------------------------------------------------------
00236 STDAPI DllRegisterServer()
00237 {
00238   HRESULT hResult = S_FALSE;
00239
00240   do
00241   { // Support ISnapinAbout
00242     hResult = RegisterServer( g_hInst, CLSID_CSnapinAbout, gtszABOUT_NAME );
00243     BREAK_ON_ERROR( hResult );
00244
00245     hResult = RegisterServer( g_hInst, CLSID_CComponentData, gtszSNAPIN_NAME );
00246     BREAK_ON_ERROR( hResult );
00247
00248     // VIEWEX: Set last parameter to TRUE so that we can use the View Extension
00249     hResult = RegisterSnapin( CLSID_CComponentData, gtszSNAPIN_NAME, CLSID_CSnapinAbout, TRUE );
00250     BREAK_ON_ERROR( hResult );
00251
00252   }while( 0 );
00253
00254   return hResult;
00255 }
00256
00257
00258 //---------------------------------------------------------------------------
00259 STDAPI DllUnregisterServer()
00260 {
00261   if( S_OK != UnregisterServer( CLSID_CComponentData )  ||
00262       S_OK != UnregisterServer( CLSID_CSnapinAbout   )  ||
00263       S_OK != UnregisterSnapin( CLSID_CComponentData )
00264     )
00265     return E_UNEXPECTED;
00266   else
00267     return S_OK;
00268
00269 }
00270
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userproppage/userproppage.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userproppage

userproppage.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       userproppage.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011
00012 // GUID's for Cclasses
00013
00014 extern const GUID CLSID_ProppageUser;
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/GUIList.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

GUIList.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUILIST.CPP
00003
00004   Summary:   Implementation file for the CGuiList C++ class. A GuiList is
00005              a C++ object that displays a list of pages that are kept in a
00006              compound file. The CGuiList provides the main application
00007              window for the PERCLIEN application. During the operation of
00008              this application CGuiList is used to manage a list of
00009              editable pages. These pages have their own child windows. For
00010              example, GUIDRAW.CPP codes the drawing page window and
00011              GUITEXT.CPP codes the text page window. CGuiList is anchored
00012              to the Windows GUI (Graphical User Interface) environment--it
00013              retains knowledge of window handles and device contexts on
00014              the local machine. This GuiList object relies on a virtual
00015              List object for persistent storage of the list of pages.
00016              This virtual List object (a COPageList) is instantiated
00017              as a COM object in a separate In-process server, PERSERVE.
00018
00019              For a comprehensive tutorial code tour of GUILIST's contents
00020              and offerings see the tutorial PERCLIEN.HTM file. For more
00021              specific technical details on the internal workings see the
00022              comments dispersed throughout the GUILIST source code.
00023
00024   Classes:   CGuiList.
00025
00026   Origin:    5-20-97: atrent - Editor inheritance from GUIPAPER.CPP in the
00027              STOCLIEN source.
00028
00029 ----------------------------------------------------------------------------
00030   This file is part of the Microsoft COM Tutorial Code Samples.
00031
00032   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00033
00034   This source code is intended only as a supplement to Microsoft
00035   Development Tools and/or on-line documentation.  See these other
00036   materials for detailed information regarding Microsoft code samples.
00037
00038   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00039   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00040   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00041   PARTICULAR PURPOSE.
00042 ==========================================================================+*/
00043
00044 /*--------------------------------------------------------------------------
00045   We include WINDOWS.H for all Win32 applications.
00046   We include OLE2.H because we will be calling the COM/OLE Libraries.
00047   We include OLECTL.H because it has definitions for connectable objects.
00048   We include COMMDLG.H because we will be using the Open File and
00049     potentially other Common dialogs.
00050   We include TCHAR.H for general Unicode/Ansi prototype of utility
00051     functions like _tsplitpath, etc.
00052   We include APPUTIL.H because we will be building this application using
00053     the convenient Virtual Window and Dialog classes and other
00054     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00055   We include IPAGES.H and PAGEGUID.H for the common page-related Interface
00056     class, GUID, and CLSID specifications.
00057   We include RESDEF.H because it has class and resource definitions
00058     specific to this application.
00059   We include PAGEFILE.H because it has the C++ class used for compound file
00060     storage of page list ata.
00061   We include LISTWIN.H because CGuiList creates and uses a CListWin to
00062     manage a standard list box window.
00063   We include GUILIST.H because it has the C++ class used for GUI display
00064     of the page List.
00065   We include LISTSINK.H because it has the C++ class used for the sink
00066     that receives event notifications from COPageList in the server.
00067   We include TEXTWIN.H because it has the C++ class that encapsulates
00068     the standard multi-line text editing window/control.
00069   We include GUITEXT.H because it has the C++ class used for GUI display
00070     of text pages.
00071   We include TEXTSINK.H because it has the C++ class used for the sink
00072     that receives event notifications from COTextPage in the server.
00073   We include GUIDRAW.H because it has the C++ class used for GUI display
00074     of drawing pages.
00075   We include DRAWSINK.H because it has the C++ class used for the sink
00076     that receives event notifications from CODrawPage in the server.
00077   We include PERCLIEN.H because it has the class declarations for the
00078     main window of this application.
00079 ---------------------------------------------------------------------------*/
00080 #include <windows.h>
00081 #include <ole2.h>
00082 #include <olectl.h>
00083 #include <commdlg.h>
00084 #include <tchar.h>
00085 #include <apputil.h>
00086 #include <ipages.h>
00087 #include <pageguid.h>
00088 #include "resdef.h"
00089 #include "pagefile.h"
00090 #include "listwin.h"
00091 #include "guilist.h"
00092 #include "listsink.h"
00093 #include "textwin.h"
00094 #include "guitext.h"
00095 #include "textsink.h"
00096 #include "guidraw.h"
00097 #include "drawsink.h"
00098 #include "perclien.h"
00099
00100
00101 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00102   Method:   CGuiList::CGuiList
00103
00104   Summary:  Constructor.
00105
00106   Args:     void
00107
00108   Returns:  void
00109 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00110 CGuiList::CGuiList(void)
00111 {
00112   m_hWnd            = NULL;
00113   m_hInst           = NULL;
00114   m_pIPageList      = NULL;
00115   m_pIStorage_Root  = NULL;
00116   m_pCOPageListSink = NULL;
00117   m_dwPageListSink  = 0;
00118   m_pListWin        = NULL;
00119   m_pPageFile       = NULL;
00120   m_bChanged        = FALSE;
00121
00122   // Init the file name for title display to <MyModule>.<EXT>.
00123   if (GetModuleFileName(m_hInst, m_szFileName, MAX_PATH))
00124   {
00125     _tsplitpath(m_szFileName, NULL, NULL, m_szFileTitle, NULL);
00126     lstrncat(m_szFileTitle, TEXT(PAG_FILE_EXT), sizeof(m_szFileTitle)/
00127       sizeof(TCHAR) - lstrlen(m_szFileTitle));
00128   }
00129
00130   // Ensure the m_szFileName OFN member variable string is NULL.
00131   m_szFileName[0] = 0;
00132
00133   // Zero the open list array.
00134   memset(m_paOpenList, 0, OPENLIST_SIZE * sizeof(OPENITEM));
00135 }
00136
00137
00138 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00139   Method:   CGuiList::~CGuiList
00140
00141   Summary:  Destructor.
00142
00143   Args:     void
00144
00145   Returns:  void
00146 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00147 CGuiList::~CGuiList(void)
00148 {
00149   if (m_pIPageList)
00150   {
00151     // Use CGuiList's Close method to close down the PageList. This
00152     // disconnects the Sink, performs final release of the COPageList
00153     // object, and closes the file by releasing the IStorage for the file.
00154     Close();
00155
00156     // Release the reference to the PageListSink object.
00157     RELEASE_INTERFACE(m_pCOPageListSink);
00158
00159     // Delete the CPageFile object.
00160     DELETE_POINTER(m_pPageFile);
00161
00162     // Delete the CListWin object.
00163     DELETE_POINTER(m_pListWin);
00164   }
00165 }
00166
00167
00168 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00169   Method:   CGuiList::Init
00170
00171   Summary:  Get CGuiList started. Make any subordinate objects, like
00172             COPageList, CListWin, and CPageFile, and get them started.
00173
00174   Args:     HINSTANCE hInst
00175               Handle to the application instance.
00176             HWND hWnd
00177               Handle of the display window. Part of what makes CGuiList
00178               a GUI kind of thing.
00179             TCHAR* pszCmdLineFile)
00180               Pointer to file name for an initial file to load that was
00181               specified on the app command line.
00182
00183   Returns:  BOOL
00184               TRUE for success; FALSE for fail.
00185 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00186 BOOL CGuiList::Init(
00187        HINSTANCE hInst,
00188        HWND hWnd,
00189        TCHAR* pszCmdLineFile)
00190 {
00191   BOOL bOk = FALSE;
00192   HRESULT hr;
00193   COPageListSink* pCob = NULL;
00194   HCURSOR hCurPrev;
00195   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
00196
00197   if (hInst && hWnd)
00198   {
00199     m_hInst = hInst;
00200     m_hWnd = hWnd;
00201
00202     // Change cursor to the hour glass. Init could take awhile.
00203     hCurPrev = SetCursor(hCurWait);
00204
00205     // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00206     m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00207     m_ofnFile.hwndOwner = hWnd;
00208     m_ofnFile.hInstance = hInst;
00209     m_ofnFile.lpstrCustomFilter = NULL;
00210     m_ofnFile.nMaxCustFilter = 0;
00211     m_ofnFile.nFilterIndex = 1;
00212     m_ofnFile.lpstrFile = m_szFileName;
00213     m_ofnFile.nMaxFile = MAX_PATH;
00214     m_ofnFile.lpstrInitialDir = TEXT(".");
00215     m_ofnFile.lpstrFileTitle = m_szFileTitle;
00216     m_ofnFile.nMaxFileTitle = MAX_PATH;
00217     m_ofnFile.lpstrDefExt = TEXT(PAG_EXT);
00218
00219     if (LoadString(m_hInst, IDS_OFN_PAGFILES, m_szFileFilter, MAX_PATH))
00220       m_ofnFile.lpstrFilter = m_szFileFilter;
00221     else
00222       m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00223
00224     // Create the CPageFile object so we can store page list data in
00225     // .PAG compound files.
00226     m_pPageFile = new CPageFile;
00227     if (NULL != m_pPageFile)
00228     {
00229       if (FileExist(pszCmdLineFile))
00230       {
00231         // If the user specified a file name on the app's command
00232         // invocation line then use that name if it actually refers
00233         // to an existing file. If not then ignore it.
00234         lstrcpy(m_szFileName, pszCmdLineFile);
00235         lstrcpy(m_szFileTitle, pszCmdLineFile);
00236       }
00237       else
00238       {
00239         // Build a path to where the default application .PAG file
00240         // should be. It should be in the same directory as the .EXE
00241         // as the appname with an .PAG extension.
00242         MakeFamilyPath(m_hInst, m_szFileName, TEXT(PAG_FILE_EXT));
00243       }
00244
00245       // Init the CPageFile object.
00246       hr = m_pPageFile->Init(m_szFileName);
00247       if (SUCCEEDED(hr))
00248       {
00249         // Create the CListWin object so we can show page list data
00250         // in a list box window.
00251         m_pListWin = new CListWin;
00252         if (NULL != m_pListWin)
00253         {
00254           if (m_pListWin->Create(m_hInst, m_hWnd, FALSE))
00255           {
00256             // Create the COPageListSink object to receive PageList events.
00257             pCob = new COPageListSink(NULL, this);
00258             if (NULL != pCob)
00259             {
00260               // Save a pointer to the COPageListSink IUnknown interface.
00261               // AddRef because of this saved copy. Released in destructor.
00262               m_pCOPageListSink = pCob;
00263               m_pCOPageListSink->AddRef();
00264               bOk = TRUE;
00265             }
00266           }
00267         }
00268       }
00269     }
00270
00271     // Set Cursor from hourglass back to what it was.
00272     SetCursor(hCurPrev);
00273   }
00274
00275   return (bOk);
00276 }
00277
00278
00279 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00280   Method:   CGuiList::GetConnectionPoint
00281
00282   Summary:  Internal private method to obtain a connection point interface.
00283
00284   Args:     REFIID riid
00285               IID of the requested connection point Interface.
00286
00287   Returns:  IConnectionPoint*
00288               Requested IConnectionPoint interface pointer. NULL if none.
00289 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00290 IConnectionPoint* CGuiList::GetConnectionPoint(
00291                     REFIID riid)
00292 {
00293   IConnectionPoint* pConnPoint = NULL;
00294   IConnectionPointContainer* pConnPointContainer = NULL;
00295   IConnectionPoint* pConnPt;
00296   HRESULT hr;
00297
00298   // First query the object for its Connection Point Container. This
00299   // essentially asks the object in the server if it is connectable.
00300   hr = m_pIPageList->QueryInterface(
00301          IID_IConnectionPointContainer,
00302          (PPVOID)&pConnPointContainer);
00303   if SUCCEEDED(hr)
00304   {
00305     // Find the requested Connection Point. This AddRef's the
00306     // returned pointer.
00307     hr = pConnPointContainer->FindConnectionPoint(riid, &pConnPt);
00308     if (SUCCEEDED(hr))
00309       pConnPoint = pConnPt;
00310
00311     RELEASE_INTERFACE(pConnPointContainer);
00312   }
00313
00314   return pConnPoint;
00315 }
00316
00317
00318 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00319   Method:   CGuiList::ConnectSink
00320
00321   Summary:  Connect the PageListSink to the server COPageList event
00322             source.
00323
00324   Args:     void
00325
00326   Returns:  HRESULT
00327               Standard result code. NOERROR for success.
00328 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00329 HRESULT CGuiList::ConnectSink(void)
00330 {
00331   HRESULT hr = E_FAIL;
00332   DWORD dwKey;
00333   IConnectionPoint* pConnPoint;
00334
00335   if (!m_dwPageListSink)
00336   {
00337     // Get the PageList Sink connection point in the server.
00338     pConnPoint = GetConnectionPoint(IID_IPageListSink);
00339     if (NULL != pConnPoint)
00340     {
00341       // Connect the server's object to the PageList Sink in this client.
00342       hr = pConnPoint->Advise(m_pCOPageListSink, &dwKey);
00343       if (SUCCEEDED(hr))
00344         m_dwPageListSink = dwKey;
00345
00346       RELEASE_INTERFACE(pConnPoint);
00347     }
00348   }
00349
00350   return hr;
00351 }
00352
00353
00354 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00355   Method:   CGuiList::DisconnectSink
00356
00357   Summary:  Disconnect the PageListSink from the server COPageList event
00358             source.
00359
00360   Args:     void.
00361
00362   Returns:  HRESULT
00363               Standard result code. NOERROR for success.
00364 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00365 HRESULT CGuiList::DisconnectSink(void)
00366 {
00367   HRESULT hr = E_FAIL;
00368   IConnectionPoint* pConnPoint;
00369
00370   if (m_dwPageListSink)
00371   {
00372     // Get the PageList Sink connection point.
00373     pConnPoint = GetConnectionPoint(IID_IPageListSink);
00374     if (NULL != pConnPoint)
00375     {
00376       // Disconnect the object in the server from the PageList Sink in
00377       // this client.
00378       hr = pConnPoint->Unadvise(m_dwPageListSink);
00379       if (SUCCEEDED(hr))
00380         m_dwPageListSink = 0;
00381
00382       RELEASE_INTERFACE(pConnPoint);
00383     }
00384   }
00385
00386   return hr;
00387 }
00388
00389
00390 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00391   Method:   CGuiList::Resize
00392
00393   Summary:  Handle a user-initiated Resize of the app's main window.
00394             Pass this resize on to the child list box window.
00395
00396   Args:     WORD wWidth,
00397               New width of window in pixels.
00398             WORD wHeight)
00399               New height of window in pixels.
00400
00401   Returns:  HRESULT
00402               Standard result code. NOERROR for success.
00403 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00404 HRESULT CGuiList::Resize(
00405           WORD wWidth,
00406           WORD wHeight)
00407 {
00408   HRESULT hr = E_FAIL;
00409   BOOL bOk = FALSE;
00410
00411   bOk = m_pListWin->Resize(wWidth, wHeight);
00412   if (bOk)
00413     hr = NOERROR;
00414
00415   return hr;
00416 }
00417
00418
00419 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00420   Method:   CGuiList::Show
00421
00422   Summary:  Show the content of the page list by putting the list content
00423             into a standard list box control/window.
00424
00425   Args:     INT iNewSel)
00426               The highlighted current selection index in the list.
00427               If < 0 then use/restore the current list box selection.
00428               If >= 0 then set the selection to the index specified.
00429
00430   Returns:  HRESULT
00431               Standard result code. NOERROR for success.
00432 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00433 HRESULT CGuiList::Show(
00434           INT iNewSel)
00435 {
00436   HRESULT hr = E_FAIL;
00437   INT iPage = 0;
00438   INT iCurSel;
00439   BOOL bDone = FALSE;
00440   BOOL bOpen = FALSE;
00441   SHORT nType = PAGETYPE_NONE;
00442   WCHAR wszTitle[PAGE_TITLE_SIZE];
00443   WCHAR wszDataName[PAGE_NAME_SIZE];
00444   TCHAR szOpen[4];
00445   TCHAR szType[4];
00446
00447   // Get currently selected page index.
00448   if (iNewSel < 0)
00449     m_pListWin->GetCurSel(&iCurSel);
00450   else
00451     iCurSel = iNewSel;
00452
00453   // First clear all ListWin display content.
00454   m_pListWin->Clear();
00455
00456   // Now loop. Ask COPageList for all Page List items and add
00457   // display entries for them in ListWin.
00458   while (!bDone)
00459   {
00460     hr = m_pIPageList->Get(iPage, &bOpen, &nType, wszTitle, wszDataName);
00461     if (SUCCEEDED(hr))
00462     {
00463       if (bOpen)
00464         lstrcpyn(szOpen, TEXT(PAGE_OPEN_STR), sizeof(szOpen)/sizeof(TCHAR));
00465       else
00466         lstrcpyn(szOpen, TEXT(PAGE_CLOSED_STR), sizeof(szOpen)/sizeof(TCHAR));
00467
00468       switch (nType)
00469       {
00470         case PAGETYPE_TEXT:
00471           lstrcpyn(szType, TEXT(TYPE_TEXT_STR), sizeof(szType)/
00472             sizeof(TCHAR));
00473           break;
00474         case PAGETYPE_DRAWING:
00475           lstrcpyn(szType, TEXT(TYPE_DRAWING_STR), sizeof(szType)/
00476             sizeof(TCHAR));
00477           break;
00478         default:
00479           lstrcpyn(szType, TEXT(TYPE_UNKNOWN_STR), sizeof(szType)/
00480             sizeof(TCHAR));
00481           break;
00482       }
00483 #if defined(UNICODE)
00484       if(m_pListWin->AddFmt(
00485                          TEXT(LISTWIN_FMT_STR),
00486                          szOpen,
00487                          iPage,
00488                          szType,
00489                          wszTitle))
00490       {
00491          hr = S_OK;
00492       }
00493       else
00494       {
00495          hr = E_FAIL;
00496       }
00497 #else
00498       {
00499         CHAR szTitle[PAGE_TITLE_SIZE];
00500
00501         UcToAnsi(wszTitle, szTitle, PAGE_TITLE_SIZE);
00502         if (m_pListWin->AddFmt(
00503                            TEXT(LISTWIN_FMT_STR),
00504                            szOpen,
00505                            iPage,
00506                            szType,
00507                            szTitle))
00508         {
00509            hr = S_OK;
00510         }
00511         else
00512         {
00513            hr = E_FAIL;
00514         }
00515       }
00516 #endif
00517       iPage++;
00518     }
00519     else
00520     {
00521       hr = NOERROR;
00522       bDone = TRUE;
00523     }
00524   }
00525
00526   // Restore currently selected page index.
00527   m_pListWin->SetCurSel(iCurSel);
00528
00529   return hr;
00530 }
00531
00532
00533 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00534   Method:   CGuiList::GetOpenItem
00535
00536   Summary:  Private method. Get the open item for a specified page. Also
00537             indicate whether the open array can accept any new open items.
00538
00539   Args:     INT iPage,
00540               The requested page number of the page to get. Can be -1
00541               indicating that only the AddOk status is requested.
00542             SHORT* pnPageType,
00543               Address of the output page type variable for the requested
00544               open page item. Can be NULL indicating no request.
00545             PPVOID ppGuiPage,
00546               Address of the output pointer variable that receives a
00547               pointer to the C++ object that controls the page's window.
00548               Can be NULL indicating no request.
00549             BOOL* pAddOk)
00550               Address of the output BOOL variable that, if TRUE, signals
00551               the caller whether any new items can be added/opened.
00552
00553   Returns:  HRESULT
00554               Standard result code. NOERROR for success.
00555 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00556 HRESULT CGuiList::GetOpenItem(
00557           INT iPage,
00558           SHORT* pnPageType,
00559           PPVOID ppGuiPage,
00560           BOOL* pAddOk)
00561 {
00562   HRESULT hr = E_FAIL;
00563   SHORT nOpenType;
00564   INT i;
00565   BOOL bAddOk = FALSE;
00566
00567   // Loop thru the open list array and find the open page.
00568   for (i=0; i<OPENLIST_SIZE; i++)
00569   {
00570     nOpenType = m_paOpenList[i].nType;
00571
00572     if (!bAddOk && pAddOk != NULL && nOpenType == PAGETYPE_NONE)
00573       *pAddOk = bAddOk = TRUE;
00574
00575     if (nOpenType != PAGETYPE_NONE && m_paOpenList[i].iPage == iPage)
00576     {
00577       if (E_FAIL == hr)
00578       {
00579         if (NULL != pnPageType)
00580           *pnPageType = m_paOpenList[i].nType;
00581         if (NULL != ppGuiPage)
00582           *ppGuiPage = m_paOpenList[i].pGuiPage;
00583         hr = NOERROR;
00584       }
00585     }
00586   }
00587
00588   return hr;
00589 }
00590
00591
00592 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00593   Method:   CGuiList::AddOpenItem
00594
00595   Summary:  Private method. Add a new open item to the open item array.
00596
00597   Args:     INT iPage,
00598               Page number of new open item.
00599             SHORT nPageType,
00600               Page type of new open item.
00601             void* pGuiPage)
00602               Pointer to window control C++ object (eg, pGuiText).
00603
00604   Returns:  HRESULT
00605               Standard result code. NOERROR for success.
00606 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00607 HRESULT CGuiList::AddOpenItem(
00608           INT iPage,
00609           SHORT nPageType,
00610           void* pGuiPage)
00611 {
00612   HRESULT hr = E_FAIL;
00613   SHORT nOpenType;
00614   INT i;
00615
00616   // Loop thru the open list array and find an empty slot.
00617   for (i=0; i<OPENLIST_SIZE; i++)
00618   {
00619     nOpenType = m_paOpenList[i].nType;
00620
00621     if (nOpenType == PAGETYPE_NONE)
00622     {
00623       m_paOpenList[i].nType = nPageType;
00624       m_paOpenList[i].iPage = iPage;
00625       m_paOpenList[i].pGuiPage = pGuiPage;
00626       hr = NOERROR;
00627       break;
00628     }
00629   }
00630
00631   return hr;
00632 }
00633
00634
00635 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00636   Method:   CGuiList::DeleteOpenItem
00637
00638   Summary:  Private method. Delete the specified open item from the
00639             open item array.
00640
00641   Args:     INT iPage,
00642               Dynamic number of page to delete.
00643
00644   Returns:  HRESULT
00645               Standard result code. NOERROR for success.
00646 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00647 HRESULT CGuiList::DeleteOpenItem(
00648           INT iPage)
00649 {
00650   HRESULT hr = E_FAIL;
00651   SHORT nOpenType;
00652   INT i;
00653
00654   // Loop thru the open list array and find the open page.
00655   for (i=0; i<OPENLIST_SIZE; i++)
00656   {
00657     nOpenType = m_paOpenList[i].nType;
00658
00659     if (nOpenType != PAGETYPE_NONE && m_paOpenList[i].iPage == iPage)
00660     {
00661       // When found, mark the item as PAGETYPE_DELETED.
00662       m_paOpenList[i].nType = PAGETYPE_DELETED;
00663       hr = NOERROR;
00664       break;
00665     }
00666   }
00667
00668   return hr;
00669 }
00670
00671
00672 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00673   Method:   CGuiList::RenumOpenItems
00674
00675   Summary:  Private method. Renumber appropriate items in the open item
00676             array to account for a permanently deleted page.
00677
00678   Args:     INT iPage,
00679               Dynamic number of deleted page.
00680
00681   Returns:  HRESULT
00682               Standard result code. NOERROR for success.
00683 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00684 HRESULT CGuiList::RenumOpenItems(
00685           INT iPage)
00686 {
00687   HRESULT hr = NOERROR;
00688   SHORT nOpenType = PAGETYPE_NONE;
00689   INT i, iPg;
00690   CGuiText* pGuiText;
00691   CGuiDraw* pGuiDraw;
00692
00693   // Renumber the remaining open pages to account for a permanently
00694   // deleted page.
00695   for (i=0; i<OPENLIST_SIZE; i++)
00696   {
00697     nOpenType = m_paOpenList[i].nType;
00698     iPg = m_paOpenList[i].iPage;
00699
00700     if (nOpenType != PAGETYPE_NONE && iPg >= 0 && iPg > iPage)
00701     {
00702       if (iPg > 0)
00703       {
00704         iPg--;
00705         m_paOpenList[i].iPage = iPg;
00706         // Tell the open pages that they have a new dynamic page number.
00707         switch (nOpenType)
00708         {
00709           case PAGETYPE_TEXT:
00710             pGuiText = (CGuiText*) m_paOpenList[i].pGuiPage;
00711             if (NULL != pGuiText)
00712               hr = pGuiText->Renumber(iPg);
00713             break;
00714           case PAGETYPE_DRAWING:
00715             pGuiDraw = (CGuiDraw*) m_paOpenList[i].pGuiPage;
00716             if (NULL != pGuiDraw)
00717               hr = pGuiDraw->Renumber(iPg);
00718             break;
00719           default:
00720             break;
00721         }
00722       }
00723     }
00724   }
00725
00726   return hr;
00727 }
00728
00729
00730 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00731   Method:   CGuiList::CloseOpenItem
00732
00733   Summary:  Private method. Delete the open item for the specified page
00734             in the open item array.
00735
00736   Args:     INT iPage,
00737               Dynamic number of page open item to delete.
00738
00739   Returns:  HRESULT
00740               Standard result code. NOERROR for success.
00741 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00742 HRESULT CGuiList::CloseOpenItem(
00743           INT iPage)
00744 {
00745   HRESULT hr = E_FAIL;
00746   SHORT nOpenType = PAGETYPE_NONE;
00747   INT i;
00748
00749   // Loop thru the open list array and find the open page entry.
00750   for (i=0; i<OPENLIST_SIZE; i++)
00751   {
00752     nOpenType = m_paOpenList[i].nType;
00753
00754     if (nOpenType != PAGETYPE_NONE && m_paOpenList[i].iPage == iPage)
00755     {
00756       // When found, mark the item as PAGETYPE_NONE.
00757       m_paOpenList[i].nType = PAGETYPE_NONE;
00758       hr = NOERROR;
00759       break;
00760     }
00761   }
00762
00763   // Renumber the remaining open pages to account for a permanently
00764   // deleted page.
00765   if (SUCCEEDED(hr) && PAGETYPE_DELETED == nOpenType)
00766     RenumOpenItems(iPage);
00767
00768   return hr;
00769 }
00770
00771
00772 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00773   Method:   CGuiList::SaveOpenPages
00774
00775   Summary:  Private method. Loop through the open list and save all
00776             open pages.
00777
00778   Args:     void.
00779
00780   Returns:  HRESULT
00781               Standard result code. NOERROR for success.
00782 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00783 HRESULT CGuiList::SaveOpenPages(void)
00784 {
00785   HRESULT hr = E_FAIL;
00786   SHORT nOpenType;
00787   CGuiText* pGuiText;
00788   CGuiDraw* pGuiDraw;
00789   INT i;
00790
00791   // Loop thru the open list array and save all open pages.
00792   for (i=0; i<OPENLIST_SIZE; i++)
00793   {
00794     nOpenType = m_paOpenList[i].nType;
00795
00796     switch (nOpenType)
00797     {
00798       case PAGETYPE_TEXT:
00799         pGuiText = (CGuiText*) m_paOpenList[i].pGuiPage;
00800         if (NULL != pGuiText)
00801           hr = pGuiText->Save();
00802         break;
00803       case PAGETYPE_DRAWING:
00804         pGuiDraw = (CGuiDraw*) m_paOpenList[i].pGuiPage;
00805         if (NULL != pGuiDraw)
00806           hr = pGuiDraw->Save();
00807         break;
00808       default:
00809         break;
00810     }
00811   }
00812
00813   if (SUCCEEDED(hr))
00814   {
00815     // All open pages saved so clear any changed flag.
00816     m_bChanged = FALSE;
00817   }
00818
00819   return hr;
00820 }
00821
00822
00823 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00824   Method:   CGuiList::CloseOpenPages
00825
00826   Summary:  Private method. Loop through the open list and close all
00827             open pages.
00828
00829   Args:     void.
00830
00831   Returns:  HRESULT
00832               Standard result code. NOERROR for success.
00833 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00834 HRESULT CGuiList::CloseOpenPages(void)
00835 {
00836   HRESULT hr = E_FAIL;
00837   SHORT nOpenType;
00838   INT i;
00839   CGuiText* pGuiText;
00840   CGuiDraw* pGuiDraw;
00841
00842   // Loop thru the open list array and close all open pages.
00843   for (i=0; i<OPENLIST_SIZE; i++)
00844   {
00845     nOpenType = m_paOpenList[i].nType;
00846
00847     switch (nOpenType)
00848     {
00849       case PAGETYPE_TEXT:
00850         pGuiText = (CGuiText*) m_paOpenList[i].pGuiPage;
00851         if (NULL != pGuiText)
00852         {
00853           hr = pGuiText->Close();
00854           if (SUCCEEDED(hr))
00855           {
00856             m_paOpenList[i].nType = PAGETYPE_NONE;
00857           }
00858         }
00859         break;
00860       case PAGETYPE_DRAWING:
00861         pGuiDraw = (CGuiDraw*) m_paOpenList[i].pGuiPage;
00862         if (NULL != pGuiDraw)
00863         {
00864           hr = pGuiDraw->Close();
00865           if (SUCCEEDED(hr))
00866           {
00867             m_paOpenList[i].nType = PAGETYPE_NONE;
00868           }
00869         }
00870         break;
00871       default:
00872         break;
00873     }
00874   }
00875
00876   if (SUCCEEDED(hr))
00877   {
00878     m_bChanged = FALSE;
00879   }
00880
00881   return hr;
00882 }
00883
00884
00885 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00886   Method:   CGuiList::ReleaseOpenPages
00887
00888   Summary:  Private method. Loop throught the open list array and
00889             release storage for all open pages.
00890
00891   Args:     void.
00892
00893   Returns:  HRESULT
00894               Standard result code. NOERROR for success.
00895 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00896 HRESULT CGuiList::ReleaseOpenPages(void)
00897 {
00898   HRESULT hr = E_FAIL;
00899   SHORT nOpenType;
00900   INT i;
00901   CGuiText* pGuiText;
00902   CGuiDraw* pGuiDraw;
00903
00904   // Loop thru the open list array and release all open page storage.
00905   for (i=0; i<OPENLIST_SIZE; i++)
00906   {
00907     nOpenType = m_paOpenList[i].nType;
00908
00909     switch (nOpenType)
00910     {
00911       case PAGETYPE_TEXT:
00912         pGuiText = (CGuiText*) m_paOpenList[i].pGuiPage;
00913           hr = pGuiText->ReleasePage();
00914         break;
00915       case PAGETYPE_DRAWING:
00916         pGuiDraw = (CGuiDraw*) m_paOpenList[i].pGuiPage;
00917         if (NULL != pGuiDraw)
00918           hr = pGuiDraw->ReleasePage();
00919         break;
00920       default:
00921         break;
00922     }
00923   }
00924
00925   return hr;
00926 }
00927
00928
00929 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00930   Method:   CGuiList::RestoreOpenPages
00931
00932   Summary:  Private method. Loop through the open list array and reopen
00933             storage for the open pages. Use the specified root storage.
00934
00935   Args:     IStorage* pIStorage_Root)
00936               Root storage for the compound file containing the pages.
00937
00938   Returns:  HRESULT
00939               Standard result code. NOERROR for success.
00940 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00941 HRESULT CGuiList::RestoreOpenPages(
00942           IStorage* pIStorage_Root)
00943 {
00944   HRESULT hr = E_FAIL;
00945   SHORT nOpenType;
00946   INT i;
00947   CGuiText* pGuiText;
00948   CGuiDraw* pGuiDraw;
00949
00950   // Loop thru the open list array and reopen storage for the open pages.
00951   for (i=0; i<OPENLIST_SIZE; i++)
00952   {
00953     nOpenType = m_paOpenList[i].nType;
00954
00955     switch (nOpenType)
00956     {
00957       case PAGETYPE_TEXT:
00958         pGuiText = (CGuiText*) m_paOpenList[i].pGuiPage;
00959         if (NULL != pGuiText)
00960         {
00961           hr = pGuiText->RestorePage(pIStorage_Root);
00962           if (SUCCEEDED(hr))
00963           {
00964             // Make sure the Text page in the reopend storage
00965             // matches the Text page object data in RAM.
00966             hr = pGuiText->Save();
00967           }
00968         }
00969         break;
00970       case PAGETYPE_DRAWING:
00971         pGuiDraw = (CGuiDraw*) m_paOpenList[i].pGuiPage;
00972         if (NULL != pGuiDraw)
00973         {
00974           hr = pGuiDraw->RestorePage(pIStorage_Root);
00975           if (SUCCEEDED(hr))
00976           {
00977             // Make sure the Draw page in the reopend storage
00978             // matches the Draw page object data in RAM.
00979             hr = pGuiDraw->Save();
00980           }
00981         }
00982         break;
00983       default:
00984         break;
00985     }
00986   }
00987
00988   return hr;
00989 }
00990
00991
00992 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00993   Method:   CGuiList::Load
00994
00995   Summary:  Load PageList data from the current compound file.
00996
00997   Args:     void.
00998
00999   Returns:  HRESULT
01000               Standard result code. NOERROR for success.
01001 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01002 HRESULT CGuiList::Load(void)
01003 {
01004   HRESULT hr = E_FAIL;
01005   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01006   HCURSOR hCurPrev;
01007   TCHAR szTitle[MAX_PATH + 32];
01008
01009   if (NULL != m_pPageFile)
01010   {
01011     // Change cursor to the hour glass.
01012     hCurPrev = SetCursor(hCurWait);
01013
01014     // Ask the PageFile object to load the PageList data from the current
01015     // compound file. This load internally uses IPersist* features in a
01016     // COPageList object that is created and reconstituted from
01017     // persistent storage.
01018     hr = m_pPageFile->Load(NULL, &m_pIStorage_Root, &m_pIPageList);
01019     if (SUCCEEDED(hr))
01020     {
01021       // If we created and reconstituted a COPageList object then
01022       // connect the sinks in the client to the connection sources
01023       // in the server.
01024       hr = ConnectSink();
01025       if (SUCCEEDED(hr))
01026       {
01027         // Set Main Window Title.
01028         lstrcpyn(szTitle, TEXT(MAIN_APP_NAME_STR), sizeof(szTitle)/
01029           sizeof(TCHAR));
01030         lstrncat(szTitle, m_szFileTitle, sizeof(szTitle)/sizeof(TCHAR) -
01031           lstrlen(szTitle));
01032         SetWindowText(m_hWnd, szTitle);
01033
01034         // Set focus to ListWin and select first item in list.
01035         m_pListWin->SetCurSel(0);
01036
01037         // Newly loaded file isn't changed yet.
01038         m_bChanged = FALSE;
01039       }
01040     }
01041
01042     // Set Cursor back to what it was.
01043     SetCursor(hCurPrev);
01044   }
01045
01046   return hr;
01047 }
01048
01049
01050 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01051   Method:   CGuiList::Save
01052
01053   Summary:  Calls on CPageFile to save the current PageList data in
01054             the current compound file.
01055
01056   Args:     void.
01057
01058   Returns:  HRESULT
01059               Standard result code. NOERROR for success.
01060 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01061 HRESULT CGuiList::Save(void)
01062 {
01063   HRESULT hr = E_FAIL;
01064   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01065   HCURSOR hCurPrev;
01066
01067   if (NULL != m_pPageFile)
01068   {
01069     // Change cursor to the hour glass.
01070     hCurPrev = SetCursor(hCurWait);
01071
01072     // Save any open pages if needed.
01073     SaveOpenPages();
01074
01075     // Ask the PageFile object to save itself to the current file.
01076     hr = m_pPageFile->Save(m_pIStorage_Root, m_pIPageList);
01077     if (SUCCEEDED(hr))
01078       m_bChanged = FALSE;
01079
01080     // Set Cursor back to what it was.
01081     SetCursor(hCurPrev);
01082   }
01083
01084   return hr;
01085 }
01086
01087
01088 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01089   Method:   CGuiList::AskSave
01090
01091   Summary:  Checks if any open pages were changed or if the PageList dirty
01092             flag is set. The dirty flag is TRUE if the current PageList
01093             data was modified and is out of sync with the PageList data
01094             stored in the compound file. If a page was changed or if the
01095             PageList is dirty, then ask user in a simple dialog if he
01096             wants to save everthing. If he says yes, then save the current
01097             PageList data into the current compound file and tell any
01098             changed open pages to do the same.
01099
01100   Args:     void.
01101
01102   Returns:  HRESULT
01103               Standard result code. NOERROR for success.
01104 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01105 int CGuiList::AskSave(void)
01106 {
01107   int iAns = IDNO;
01108   HRESULT hr;
01109   TCHAR szTitle[MAX_STRING_LENGTH];
01110   TCHAR szAsk[MAX_STRING_LENGTH];
01111   TCHAR szMsg[MAX_PATH + MAX_STRING_LENGTH];
01112   IPersistStream* pIPersistStream;
01113
01114   hr = m_pIPageList->QueryInterface(
01115            IID_IPersistStream,
01116            (PPVOID)&pIPersistStream);
01117   if (SUCCEEDED(hr))
01118   {
01119     // Did any page change or is the PageList object dirty?
01120     if (m_bChanged || S_FALSE != pIPersistStream->IsDirty())
01121     {
01122       // The current data is dirty; ask user if he wants to save it.
01123       if (LoadString(m_hInst, IDS_FILE_CHANGED, szTitle, MAX_STRING_LENGTH)
01124         && LoadString(m_hInst, IDS_ASK_SAVE, szAsk, MAX_STRING_LENGTH))
01125       {
01126         lstrcpyn(szMsg, m_szFileName, sizeof(szMsg)/sizeof(TCHAR));
01127         lstrncat(szMsg, szAsk, sizeof(szMsg)/sizeof(TCHAR) - lstrlen(szMsg));
01128         // Display AskSaveDlg to user. Ask if he wants to save.
01129         iAns = MessageBox(
01130                  m_hWnd,
01131                  szMsg,
01132                  szTitle,
01133                  MB_YESNOCANCEL | MB_ICONEXCLAMATION);
01134         switch (iAns)
01135         {
01136           case IDYES:
01137             // Tell CPageFile to save itself to the current compound file.
01138             // Save any changed open pages as well.
01139             Save();
01140             break;
01141           case IDNO:
01142             // User clicked No. So don't save; abandon changes.
01143             m_bChanged = FALSE;
01144             break;
01145           case IDCANCEL:
01146           default:
01147             break;
01148         }
01149       }
01150     }
01151
01152     // Done with IPersistStream for now so release it.
01153     pIPersistStream->Release();
01154   }
01155
01156   return iAns;
01157 }
01158
01159
01160 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01161   Method:   CGuiList::Close
01162
01163   Summary:  Close down the existing Page List. This saves the current file
01164             if needed, disconnects the sinks, releases the COPageList COM
01165             object, and closes the file by releasing the IStorage.
01166
01167   Args:     void.
01168
01169   Returns:  HRESULT
01170               Standard result code. NOERROR for success.
01171 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01172 HRESULT CGuiList::Close(void)
01173 {
01174   HRESULT hr = NOERROR;
01175   TCHAR szTitle[MAX_PATH];
01176   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01177   HCURSOR hCurPrev;
01178
01179   // Change cursor to the hour glass.
01180   hCurPrev = SetCursor(hCurWait);
01181
01182   // Save the page list into the existing .PAG file if needed.
01183   m_pPageFile->Save(m_pIStorage_Root, m_pIPageList);
01184
01185   // Disconnect the Sink in the client from the connection points in
01186   // the server.
01187   DisconnectSink();
01188
01189   // Close the file by releasing the root IStorage.
01190   RELEASE_INTERFACE(m_pIStorage_Root);
01191
01192   // Destroy the existing COPageList by releasing the IPageList interface.
01193   RELEASE_INTERFACE(m_pIPageList);
01194
01195   // Set Main Window Title.
01196   lstrcpyn(szTitle, TEXT(MAIN_APP_NAME_STR), sizeof(szTitle)/sizeof(TCHAR));
01197   lstrncat(szTitle, TEXT(NOFILE_STR), sizeof(szTitle)/sizeof(TCHAR) -
01198     lstrlen(szTitle));
01199   SetWindowText(m_hWnd, szTitle);
01200
01201   // Set Cursor back to what it was.
01202   SetCursor(hCurPrev);
01203
01204   return hr;
01205 }
01206
01207
01208 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01209   Method:   CGuiList::Open
01210
01211   Summary:  If current PageList data has been modified then ask user if he
01212             wants to first save it to the current file. Then use Open File
01213             Name common dialog to ask user for a new file name to load. If
01214             user chooses a file name then load the PageList data from that
01215             compound file.
01216
01217   Args:     void.
01218
01219   Returns:  HRESULT
01220               Standard result code. NOERROR for success.
01221 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01222 HRESULT CGuiList::Open(void)
01223 {
01224   HRESULT hr = NOERROR;
01225   TCHAR szFileName[MAX_PATH];
01226   TCHAR szTitle[MAX_PATH];
01227   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01228   HCURSOR hCurPrev;
01229   BOOL bOpen;
01230
01231   // If current data is dirty then ask user if he wants to save it first.
01232   if (IDCANCEL != AskSave())
01233   {
01234     // Use the Open File Name common dialog to get file name from user.
01235     // Set the dialog's file filter and title.
01236     szFileName[0] = 0;
01237     m_ofnFile.lpstrFile = szFileName;
01238     if (LoadString(m_hInst, IDS_OFN_PAGOPEN, szTitle, sizeof(szTitle)/
01239       sizeof(TCHAR)))
01240       m_ofnFile.lpstrTitle = szTitle;
01241     m_ofnFile.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
01242
01243     // Call up the dialog to get a file name from the user.
01244     bOpen = GetOpenFileName(&m_ofnFile);
01245     if (bOpen)
01246     {
01247       // Change cursor to the hour glass.
01248       hCurPrev = SetCursor(hCurWait);
01249
01250       // Close any open pages.
01251       CloseOpenPages();
01252
01253       // Close down the existing Page List. This saves the current
01254       // file if needed, disconnects the sinks, releases the
01255       // COPageList COM object, and closes the file by releasing
01256       // the root IStorage.
01257       Close();
01258
01259       // Tell CPageFile object to load the Page List data from the newly
01260       // chosen compound file. This creates a new COPageList object.
01261       hr = m_pPageFile->Load(szFileName, &m_pIStorage_Root, &m_pIPageList);
01262       if (SUCCEEDED(hr))
01263       {
01264         // Connect the sinks in the client to the connection sources
01265         // in the server.
01266         hr = ConnectSink();
01267         if (SUCCEEDED(hr))
01268         {
01269           // Remember the new current compound file name.
01270           lstrcpyn(m_szFileName, szFileName, sizeof(m_szFileName)/
01271             sizeof(TCHAR));
01272
01273           // Set Main Window Title.
01274           lstrcpyn(szFileName, TEXT(MAIN_APP_NAME_STR), sizeof(szFileName)/
01275             sizeof(TCHAR));
01276           lstrncat(szFileName, m_szFileTitle, sizeof(szFileName)/
01277             sizeof(TCHAR) - lstrlen(szFileName));
01278           SetWindowText(m_hWnd, szFileName);
01279
01280           // Set focus to ListWin and select first item in list and
01281           // show the newly loaded page list.
01282           Show(0);
01283         }
01284       }
01285
01286       // Set Cursor back to what it was.
01287       SetCursor(hCurPrev);
01288     }
01289   }
01290
01291   return hr;
01292 }
01293
01294
01295 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01296   Method:   CGuiList::SaveAs
01297
01298   Summary:  Use the File SaveAs common dialog to ask user for a new file
01299             name to save to. Then save the current PageList data to the
01300             specified compound file. That file becomes the new current
01301             file. The previously open file is closed and left unchanged
01302             since the last save to it.
01303
01304   Args:     void.
01305
01306   Returns:  HRESULT
01307               Standard result code. NOERROR for success.
01308 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01309 HRESULT CGuiList::SaveAs(void)
01310 {
01311   HRESULT hr = E_FAIL;
01312   TCHAR szFileName[MAX_PATH];
01313   TCHAR szTitle[MAX_PATH];
01314   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01315   HCURSOR hCurPrev;
01316   BOOL bOpen;
01317
01318   // Use the File Save As common dialog to get file name from user.
01319   // Set the dialog's file filter and title.
01320   szFileName[0] = 0;
01321   m_ofnFile.lpstrFile = szFileName;
01322   if (LoadString(m_hInst, IDS_OFN_PAGSAVE, szTitle, sizeof(szTitle)/
01323     sizeof(TCHAR)))
01324     m_ofnFile.lpstrTitle = szTitle;
01325   m_ofnFile.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
01326
01327   // Call up the dialog to get a file name from the user.
01328   bOpen = GetSaveFileName(&m_ofnFile);
01329   if (bOpen)
01330   {
01331     // Change cursor to the hour glass.
01332     hCurPrev = SetCursor(hCurWait);
01333
01334     // No need to close any open page windows. But we do need to
01335     // release the existing Storage interfaces that are held for
01336     // those pages. For Drawing pages supporting IPersistStorage this
01337     // eventually calls HandsOffStorage on all the open draw pages.
01338     hr = ReleaseOpenPages();
01339
01340     // Do the final close of the root storage of the existing file.
01341     RELEASE_INTERFACE(m_pIStorage_Root);
01342
01343     // All open storages/streams in the file are released and closed.
01344     // Now copy a clone of the existing file (for the SaveAs).
01345     if (CopyFile(m_szFileName, szFileName, FALSE))
01346     {
01347       // Tell CPageFile object to save the PageList data to the newly
01348       // copied compound file.
01349       hr = m_pPageFile->SaveAs(szFileName, m_pIPageList, &m_pIStorage_Root);
01350       if (SUCCEEDED(hr))
01351       {
01352         // Client is done changing the file from underneath the open
01353         // pages. Now re-open storage for the existing open pages
01354         // using the data storages in the new file. For Drawing pages
01355         // that support IPersistStorage this eventually calls
01356         // SaveCompleted on all the open draw pages.
01357         hr = RestoreOpenPages(m_pIStorage_Root);
01358         if (SUCCEEDED(hr))
01359         {
01360           // Remember the new current compound file name.
01361           lstrcpyn(m_szFileName, szFileName, sizeof(m_szFileName)/
01362             sizeof(TCHAR));
01363
01364           // Set Main Window Title.
01365           lstrcpyn(szFileName, TEXT(MAIN_APP_NAME_STR), sizeof(szFileName)/
01366             sizeof(TCHAR));
01367           lstrncat(szFileName, m_szFileTitle, sizeof(szFileName)/
01368             sizeof(TCHAR) - lstrlen(szFileName));
01369           SetWindowText(m_hWnd, szFileName);
01370
01371           // Restored pages are assumed to match their file image.
01372           m_bChanged = FALSE;
01373         }
01374       }
01375     }
01376
01377     // Set Cursor back to what it was.
01378     SetCursor(hCurPrev);
01379   }
01380
01381   return hr;
01382 }
01383
01384
01385 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01386   Method:   CGuiList::New
01387
01388   Summary:  If current PageList data has been modified then ask user if he
01389             wants to first save it to the current file. Then use the
01390             SaveAs File Name common dialog to ask user for a new file name
01391             to Create. If user chooses a file name then create an empty
01392             new PageList compound file using the file name specified.
01393
01394   Args:     void.
01395
01396   Returns:  HRESULT
01397               Standard result code. NOERROR for success.
01398 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01399 HRESULT CGuiList::New(void)
01400 {
01401   HRESULT hr = NOERROR;
01402   TCHAR szFileName[MAX_PATH];
01403   TCHAR szTitle[MAX_PATH];
01404   HCURSOR hCurWait = LoadCursor(NULL, IDC_WAIT);
01405   HCURSOR hCurPrev;
01406   BOOL bOpen;
01407
01408   // If current data is dirty then ask user if he wants to save it first.
01409   if (IDCANCEL != AskSave())
01410   {
01411     // Use the File Save As common dialog to get file name from user.
01412     // Set the dialog's file filter and title.
01413     szFileName[0] = 0;
01414     m_ofnFile.lpstrFile = szFileName;
01415     if (LoadString(m_hInst, IDS_OFN_PAGSAVE, szTitle, sizeof(szTitle)/
01416       sizeof(TCHAR)))
01417       m_ofnFile.lpstrTitle = szTitle;
01418     m_ofnFile.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
01419
01420     // Call up the dialog to get a file name from the user.
01421     bOpen = GetSaveFileName(&m_ofnFile);
01422     if (bOpen)
01423     {
01424       // Change cursor to the hour glass.
01425       hCurPrev = SetCursor(hCurWait);
01426
01427       // Close any open pages.
01428       CloseOpenPages();
01429
01430       // Close down the existing Page List. This saves the current
01431       // file if needed, disconnects the sinks, releases the COPageList
01432       // COM object, and closes the file by releasing the IStorage.
01433       Close();
01434
01435       // Tell CPageFile object to create a new empty .PAG compound
01436       // file using the specified file name. This also creates
01437       // a new COPageList object.
01438       hr = m_pPageFile->New(szFileName, &m_pIStorage_Root, &m_pIPageList);
01439       if (SUCCEEDED(hr))
01440       {
01441         // Connect the sinks in the client to the connection sources
01442         // in the server.
01443         hr = ConnectSink();
01444         if (SUCCEEDED(hr))
01445         {
01446           // Remember the new current compound file name.
01447           lstrcpyn(m_szFileName, szFileName, sizeof(m_szFileName)/
01448             sizeof(TCHAR));
01449
01450           // Set Main Window Title.
01451           lstrcpyn(szFileName, TEXT(MAIN_APP_NAME_STR), sizeof(szFileName)/
01452             sizeof(TCHAR));
01453           lstrncat(szFileName, m_szFileTitle, sizeof(szFileName)/
01454             sizeof(TCHAR) - lstrlen(szFileName));
01455           SetWindowText(m_hWnd, szFileName);
01456
01457           // Set focus to ListWin and select first item in list and
01458           // show the newly loaded page list.
01459           Show(0);
01460         }
01461       }
01462
01463       // Set Cursor back to what it was.
01464       SetCursor(hCurPrev);
01465     }
01466   }
01467
01468   return hr;
01469 }
01470
01471
01472 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01473   Method:   CGuiList::PageTitle
01474
01475   Summary:  Uses a dialog box to edit the title of the currently selected
01476             page list item.
01477
01478   Args:     void.
01479
01480   Returns:  HRESULT
01481               Standard result code. NOERROR for success.
01482 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01483 HRESULT CGuiList::PageTitle(void)
01484 {
01485   HRESULT hr = E_FAIL;
01486   BOOL bOk;
01487   INT iOk, iPage;
01488   CDlgPageProps dlgPageProps;
01489   WCHAR wszPageTitle[PAGE_TITLE_SIZE];
01490
01491   bOk = m_pListWin->GetCurSel(&iPage);
01492   if (bOk)
01493   {
01494     // Get the Page List title for this page number.
01495 #if defined(UNICODE)
01496     hr = m_pIPageList->Get(iPage, NULL, NULL, g_szPageTitle, NULL);
01497 #else
01498     hr = m_pIPageList->Get(iPage, NULL, NULL, wszPageTitle, NULL);
01499     if (SUCCEEDED(hr))
01500       UcToAnsi(wszPageTitle, g_szPageTitle, PAGE_TITLE_SIZE);
01501 #endif
01502
01503     // Ask the user for the new title of the page in the Page
01504     // Properties dialog.
01505     iOk = dlgPageProps.ShowDialog(
01506             m_hInst,
01507             MAKEINTRESOURCE(IDD_PAGE_PROPS),
01508             m_hWnd);
01509     if (iOk)
01510     {
01511       // If the user clicked Ok, then a new title was edited.
01512       // Ask the COPageList object to set the new title.
01513       // Use the Title entered by the user.
01514 #ifdef UNICODE
01515       hr = m_pIPageList->Set(iPage, 0, g_szPageTitle);
01516 #else
01517       // Convert to Unicode if we are compiled for Ansi.
01518       AnsiToUc(g_szPageTitle, wszPageTitle, PAGE_TITLE_SIZE);
01519       hr = m_pIPageList->Set(iPage, 0, wszPageTitle);
01520 #endif
01521     }
01522   }
01523
01524   return hr;
01525 }
01526
01527
01528 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01529   Method:   CGuiList::PageOpen
01530
01531   Summary:  Opens and loads the page object associated with the currently
01532             selected page list item. A separate window is used for
01533             editing the data of the loaded page.
01534
01535   Args:     void.
01536
01537   Returns:  HRESULT
01538               Standard result code. NOERROR for success.
01539 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01540 HRESULT CGuiList::PageOpen(void)
01541 {
01542   HRESULT hr = E_FAIL;
01543   BOOL bOk;
01544   INT iPage;
01545   SHORT nType;
01546   WCHAR wszTitle[PAGE_TITLE_SIZE];
01547   WCHAR wszDataName[PAGE_NAME_SIZE];
01548   void* pGuiPage;
01549   CGuiText* pGuiText;
01550   CGuiDraw* pGuiDraw;
01551
01552   bOk = m_pListWin->GetCurSel(&iPage);
01553   if (bOk)
01554   {
01555     hr = GetOpenItem(iPage, &nType, &pGuiPage, &bOk);
01556     if (FAILED(hr))
01557     {
01558       // Failed means this page is not already open for editing.
01559       if (bOk)
01560       {
01561         // bOk means there is room for another open page, Get the page's
01562         // DataName and Title from the COPageList COM object and then
01563         // Create the separate edit window.
01564         hr = m_pIPageList->Get(iPage, NULL, &nType, wszTitle, wszDataName);
01565         if (SUCCEEDED(hr))
01566         {
01567           switch (nType)
01568           {
01569             case PAGETYPE_TEXT:
01570               pGuiText = new CGuiText(m_hInst, m_hWnd, iPage);
01571               if (NULL != pGuiText)
01572               {
01573                 hr = pGuiText->OpenWin(m_pIStorage_Root, wszTitle, wszDataName);
01574                 if (SUCCEEDED(hr))
01575                 {
01576                   // Add an entry to the open list for the newly opened page.
01577                   hr = AddOpenItem(iPage, nType, pGuiText);
01578                 }
01579               }
01580               else
01581                 hr = E_OUTOFMEMORY;
01582               break;
01583             case PAGETYPE_DRAWING:
01584               pGuiDraw = new CGuiDraw(m_hInst, m_hWnd, iPage);
01585               if (NULL != pGuiDraw)
01586               {
01587                 hr = pGuiDraw->OpenWin(m_pIStorage_Root, wszTitle, wszDataName);
01588                 if (SUCCEEDED(hr))
01589                 {
01590                   // Add an entry to the open list for the newly opened page.
01591                   hr = AddOpenItem(iPage, nType, pGuiDraw);
01592                 }
01593               }
01594               else
01595                 hr = E_OUTOFMEMORY;
01596               break;
01597             default:
01598               break;
01599           }
01600         }
01601       }
01602       else
01603       {
01604         // Put up error message box saying that ther are too many
01605         // open pages.
01606         ErrorBox(m_hInst, m_hWnd, IDS_TOOMANYOPEN);
01607       }
01608     }
01609     else
01610     {
01611       // The page is already open. Bring its window to top.
01612       switch (nType)
01613       {
01614         case PAGETYPE_TEXT:
01615           pGuiText = (CGuiText*) pGuiPage;
01616           if (NULL != pGuiText)
01617             hr = pGuiText->TopWin();
01618           break;
01619         case PAGETYPE_DRAWING:
01620           pGuiDraw = (CGuiDraw*) pGuiPage;
01621           if (NULL != pGuiDraw)
01622             hr = pGuiDraw->TopWin();
01623           break;
01624         default:
01625           break;
01626       }
01627     }
01628   }
01629
01630   return hr;
01631 }
01632
01633
01634 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01635   Method:   CGuiList::PageAdd
01636
01637   Summary:  Add a new page of specified type to the page list. First
01638             creates the new page using the appropriate server and then
01639             adds an appropriate entry in the page list.
01640
01641   Args:     SHORT nPageType
01642               The page type (eg, PAGETYPE_DRAWING).
01643
01644   Returns:  HRESULT
01645               Standard result code. NOERROR for success.
01646 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01647 HRESULT CGuiList::PageAdd(
01648           SHORT nPageType)
01649 {
01650   HRESULT hr = E_FAIL;
01651   BOOL bOk;
01652   WCHAR wszTitle[PAGE_TITLE_SIZE];
01653   WCHAR wszDataName[PAGE_NAME_SIZE];
01654   INT iPg;
01655   CGuiText* pGuiText;
01656   CGuiDraw* pGuiDraw;
01657
01658   GetOpenItem(-1, NULL, NULL, &bOk);
01659   if (bOk)
01660   {
01661     // If there is room for another open page.
01662     // Ask the COPageList object to add a new page of the specified type.
01663     // Use "Untitled" as the default title.
01664 #ifdef UNICODE
01665     hr = m_pIPageList->Add(-1, nPageType, TEXT(PAGE_UNTITLED_STR), &iPg);
01666 #else
01667     {
01668       WCHAR wszPageTitle[PAGE_TITLE_SIZE];
01669
01670       // Convert to Unicode if we are compiled for Ansi.
01671       AnsiToUc(TEXT(PAGE_UNTITLED_STR), wszPageTitle, PAGE_TITLE_SIZE);
01672       hr = m_pIPageList->Add(-1, nPageType, wszPageTitle, &iPg);
01673     }
01674 #endif
01675
01676     if (SUCCEEDED(hr))
01677     {
01678       // Open the new page for editing. Get the page's DataName and Title
01679       // and then Create the separate edit window.
01680       hr = m_pIPageList->Get(iPg, NULL, NULL, wszTitle, wszDataName);
01681       switch (nPageType)
01682       {
01683         case PAGETYPE_TEXT:
01684           pGuiText = new CGuiText(m_hInst, m_hWnd, iPg);
01685           if (NULL != pGuiText)
01686           {
01687             hr = pGuiText->OpenWin(m_pIStorage_Root, wszTitle, wszDataName);
01688             if (SUCCEEDED(hr))
01689             {
01690               // Add the newly opened page to the open list.
01691               hr = AddOpenItem(iPg, nPageType, pGuiText);
01692             }
01693           }
01694           else
01695             hr = E_OUTOFMEMORY;
01696           break;
01697         case PAGETYPE_DRAWING:
01698           pGuiDraw = new CGuiDraw(m_hInst, m_hWnd, iPg);
01699           if (NULL != pGuiDraw)
01700           {
01701             hr = pGuiDraw->OpenWin(m_pIStorage_Root, wszTitle, wszDataName);
01702             if (SUCCEEDED(hr))
01703             {
01704               // Add the newly opened page to the open list.
01705               hr = AddOpenItem(iPg, nPageType, pGuiDraw);
01706             }
01707           }
01708           else
01709             hr = E_OUTOFMEMORY;
01710           break;
01711         default:
01712           break;
01713       }
01714     }
01715   }
01716   else
01717   {
01718     // Put up error message box saying that ther are too many
01719     // open pages.
01720     ErrorBox(m_hInst, m_hWnd, IDS_TOOMANYOPEN);
01721   }
01722
01723   return hr;
01724 }
01725
01726
01727 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01728   Method:   CGuiList::PageDelete
01729
01730   Summary:  Delete the page that corresponds to the currently selected
01731             page list item.
01732
01733   Args:     void.
01734
01735   Returns:  HRESULT
01736               Standard result code. NOERROR for success.
01737 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01738 HRESULT CGuiList::PageDelete(void)
01739 {
01740   HRESULT hr = E_FAIL;
01741   BOOL bOk;
01742   INT iPage;
01743   SHORT nType;
01744   WCHAR wszDataName[PAGE_NAME_SIZE];
01745   CGuiText* pGuiText = NULL;
01746   CGuiDraw* pGuiDraw = NULL;
01747
01748   bOk = m_pListWin->GetCurSel(&iPage);
01749   if (bOk)
01750   {
01751     // Get the page's Type.
01752     hr = m_pIPageList->Get(iPage, NULL, &nType, NULL, wszDataName);
01753     if (SUCCEEDED(hr))
01754     {
01755       switch (nType)
01756       {
01757         case PAGETYPE_TEXT:
01758           hr = GetOpenItem(iPage, NULL, (void**)&pGuiText, NULL);
01759           if (SUCCEEDED(hr))
01760           {
01761             hr = pGuiText->Delete();
01762             if (SUCCEEDED(hr))
01763             {
01764               // Mark the open item as deleted. This will force a later
01765               // renumber of open page numbers to account for the
01766               // permanently missing page. This renumber will occur in
01767               // the PageClosed method when the page is closed.
01768               hr = DeleteOpenItem(iPage);
01769               // Now Close the GuiText window.
01770               pGuiText->Close();
01771             }
01772           }
01773           else
01774           {
01775             // If not open, just destroy the entire text page's stream.
01776             hr = m_pIStorage_Root->DestroyElement(wszDataName);
01777             if (SUCCEEDED(hr))
01778             {
01779               // Renumber any open pages as needed.
01780               hr = RenumOpenItems(iPage);
01781             }
01782           }
01783           break;
01784         case PAGETYPE_DRAWING:
01785           hr = GetOpenItem(iPage, NULL, (void**)&pGuiDraw, NULL);
01786           if (SUCCEEDED(hr))
01787           {
01788             hr = pGuiDraw->Delete();
01789             if (SUCCEEDED(hr))
01790             {
01791               // Mark the open item as deleted. This will force a later
01792               // renumber of open page numbers to account for the
01793               // permanently missing page. This renumber will occur in
01794               // the PageClosed method when the page is closed.
01795               hr = DeleteOpenItem(iPage);
01796               // Now Close the GuiDraw window.
01797               pGuiDraw->Close();
01798             }
01799           }
01800           else
01801           {
01802             // If not open, just destroy the entire draw page's storage.
01803             hr = m_pIStorage_Root->DestroyElement(wszDataName);
01804             if (SUCCEEDED(hr))
01805             {
01806               // Renumber any open pages as needed.
01807               hr = RenumOpenItems(iPage);
01808             }
01809           }
01810           break;
01811         default:
01812           break;
01813       }
01814     }
01815
01816     if (SUCCEEDED(hr))
01817     {
01818       // Finally, delete the page from the page list.
01819       hr = m_pIPageList->Delete(iPage);
01820     }
01821   }
01822
01823   return hr;
01824 }
01825
01826
01827 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01828   Method:   CGuiList::PageChanged
01829
01830   Summary:  An open page was changed.
01831
01832   Args:     INT iPage)
01833               Page number of the page that changed.
01834
01835   Returns:  HRESULT
01836               Standard result code. NOERROR for success.
01837 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01838 HRESULT CGuiList::PageChanged(
01839          INT iPage)
01840 {
01841   HRESULT hr = NOERROR;;
01842
01843   m_bChanged |= TRUE;
01844
01845   return hr;
01846 }
01847
01848
01849 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01850   Method:   CGuiList::PageClosed
01851
01852   Summary:  A page editing window was closed.
01853
01854   Args:     INT iPage)
01855               Page number of the page that was closed.
01856
01857   Returns:  HRESULT
01858               Standard result code. NOERROR for success.
01859 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01860 HRESULT CGuiList::PageClosed(
01861          INT iPage)
01862 {
01863   HRESULT hr;
01864
01865   // Mark the open item for the page as closed in the open item array.
01866   hr = CloseOpenItem(iPage);
01867
01868   return hr;
01869 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyStorageResource/SIndexedDisk.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyStorageResource

SIndexedDisk.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Module Name:
00004 //      SIndexedDisk.h
00005 //
00006 //  Implementation Files:
00007 //      SIndexedDisk.cpp
00008 //
00009 //  Description:
00010 //      This file contains the declaration of the SIndexedDisk structure.
00011 //
00012 //      This is a helper for CEnumStorageResource, but has its own file
00013 //      due to the one-class-per-file restriction.
00014 //
00015 //////////////////////////////////////////////////////////////////////////////
00016
00017 #pragma once
00018
00019
00020 //////////////////////////////////////////////////////////////////////////////
00021 // Include Files
00022 //////////////////////////////////////////////////////////////////////////////
00023
00024 #include "stdafx.h"
00025
00026
00027 //////////////////////////////////////////////////////////////////////////////
00028 // Constant Declarations
00029 //////////////////////////////////////////////////////////////////////////////
00030
00031
00032 //////////////////////////////////////////////////////////////////////////////
00033 //++
00034 //
00035 //  struct SIndexedDisk
00036 //
00037 //  Description:
00038 //      The SIndexedDisk structure associates a pointer to a disk object with
00039 //      the disk object's Index property.
00040 //
00041 //--
00042 //////////////////////////////////////////////////////////////////////////////
00043 struct SIndexedDisk
00044 {
00045     SIndexedDisk( void );
00046     // accept default destructor, copy constructor, and assignment operator
00047
00048     DWORD       idxDisk;
00049     IUnknown *  punkDisk;
00050
00051     HRESULT HrInit( IUnknown * punkDiskIn );
00052
00053 }; //*** struct SIndexedDisk
00054
00055
00056 inline SIndexedDisk::SIndexedDisk( void )
00057     : idxDisk( 0 )
00058     , punkDisk( NULL )
00059 {
00060 } //*** SIndexedDisk::SIndexedDisk
00061
00062
00063 //////////////////////////////////////////////////////////////////////////////
00064 //++
00065 //
00066 //  struct SIndexedDiskLessThan
00067 //
00068 //  Description:
00069 //      The SIndexedDiskLessThan function object provides a comparison
00070 //      operation to arrange SIndexedDisk objects in ascending order when used
00071 //      with generic sort algorithms or sorted containers.
00072 //
00073 //      Although a simple function pointer would work, making it a function
00074 //      object allows the compiler to inline the comparison operation.
00075 //
00076 //--
00077 //////////////////////////////////////////////////////////////////////////////
00078
00079 struct SIndexedDiskLessThan
00080 {
00081     bool operator()( const SIndexedDisk & rLeftIn, const SIndexedDisk & rRightIn ) const
00082     {
00083         return ( rLeftIn.idxDisk < rRightIn.idxDisk );
00084     }
00085
00086 }; //*** struct SIndexedDiskLessThan
00087
00088
Generated on Wed Nov 13 2024 16:52:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSampleMSPCall Member List

This is the complete list of members for CSampleMSPCall, including all inherited members.
CreateStream(IN DWORD dwMediaType, IN TERMINAL_DIRECTION Direction, IN OUT ITStream **ppStream) | CSampleMSPCall |
CreateStreamObject(IN DWORD dwMediaType, IN TERMINAL_DIRECTION Direction, IN IMediaEvent *pGraph, IN ITStream **ppStream) | CSampleMSPCall | [virtual]
CSampleMSPCall() | CSampleMSPCall |
Init(IN CMSPAddress *pMSPAddress, IN MSP_HANDLE htCall, IN DWORD dwReserved, IN DWORD dwMediaType) | CSampleMSPCall | [virtual]
m_pCaptureStream | CSampleMSPCall | [protected]
m_pRenderStream | CSampleMSPCall | [protected]
MSPCallAddRef(void) | CSampleMSPCall | [virtual]
MSPCallRelease(void) | CSampleMSPCall | [virtual]
ReceiveTSPCallData(IN PBYTE pBuffer, IN DWORD dwSize) | CSampleMSPCall | [virtual]
RemoveStream(IN ITStream *pStream) | CSampleMSPCall |
~CSampleMSPCall() | CSampleMSPCall | [virtual]
Generated on Wed Nov 13 2024 16:57:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/globals.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

globals.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015
00016 //---------------------------------------------------------------------------
00017 // MMC's requiered clipboard formats
00018
00019 UINT g_cfDisplayName = 0;      // DisplayName for our SnapIn node
00020 UINT g_cfNodeType    = 0;      // GUID of the selected node
00021 UINT g_cfszNodeType  = 0;      // String representation of namespace GUID
00022 UINT g_cfSnapinClsid = 0;      // Class ID of this SnapIn
00023
00024 HINSTANCE g_hInst = NULL;      // Our global instance handle
00025 ULONG g_uObjectCount = 0;      // Global object count
00026 ULONG g_uServerLocks = 0;      // Global lock count
00027
00028
00029 //---------------------------------------------------------------------------
00030 //  This is the fast, simple way to convert unicode to ansi.  It does NOT
00031 //  handle multibyte ansi strings and is not localized.  But it should be
00032 //  fine for registry entries
00033 //  NOTE:  The caller is responsible for freeing the memory.
00034 //
00035 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide )
00036 {
00037   SIZE_T nLen = wcslen( szWide ) +1;
00038   *pszAnsi = (char*)CoTaskMemAlloc( nLen );
00039   char* pCounter = *pszAnsi;
00040
00041   while( *szWide )
00042   {
00043     *pCounter = LOBYTE(*szWide);
00044     pCounter++;
00045     szWide++;
00046   }
00047   *pCounter = NULL;
00048 }
00049
00050
00051 //---------------------------------------------------------------------------
00052 //
00053 void InitClipboardFormats()
00054 {
00055   g_cfDisplayName  = RegisterClipboardFormat( T_CCF_DISPLAY_NAME );
00056   g_cfNodeType     = RegisterClipboardFormat( T_CCF_NODETYPE );
00057   g_cfszNodeType   = RegisterClipboardFormat( T_CCF_SZNODETYPE );
00058   g_cfSnapinClsid  = RegisterClipboardFormat( T_CCF_SNAPIN_CLASSID );
00059
00060 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Except.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

Except.Hxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       except.hxx
00006 //
00007 //  Contents:   Throw exception class
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef _EXCEPT_HXX_
00012 #define _EXCEPT_HXX_
00013
00014 //+---------------------------------------------------------------------------
00015 //
00016 //  Class:      CException
00017 //
00018 //  Purpose:    All exception objects (e.g. objects that are THROW)
00019 //              inherit from CException.
00020 //
00021 //----------------------------------------------------------------------------
00022
00023 class CException
00024 {
00025 public:
00026              CException(long lError) : _lError(lError), _dbgInfo(0) {}
00027     long     GetErrorCode() { return _lError;}
00028     void     SetInfo(unsigned dbgInfo) { _dbgInfo = dbgInfo; }
00029     unsigned long GetInfo(void) const { return _dbgInfo; }
00030
00031 protected:
00032
00033     long          _lError;
00034     unsigned long _dbgInfo;
00035 };
00036
00037 SCODE GetOleError(CException & e);
00038
00039 void _cdecl SystemExceptionTranslator( unsigned int uiWhat,
00040                                        struct _EXCEPTION_POINTERS * pexcept );
00041
00042 #endif // _EXCEPT_HXX_
00043
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/RTCOutgoingDlg.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

RTCOutgoingDlg.h

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: RTCOutGoingDlg.h
00006  * ---------- [ Header Declaration File]
00007  *
00008  * @Description :
00009  * -------------
00010  * Class Declaration file for the Main RTCOutgoing Dialog Box
00011  * this Class will contain the state machine transitions
00012  * of the RTC Core Sample,creating PC-PC,PC-PH,PH-PH calls,
00013  * receiving events disconnected calls, displaying video
00014  * starting T120 App Sharing and Starting the Tunning Wizard
00015  *
00016  *
00017  ******************************************************/
00018
00019
00020
00021 #ifndef ____RTCOUTGOINGDLG_H_____
00022 #define ____RTCOUTGOINGDLG_H_____
00023
00024 #if _MSC_VER > 1000
00025 #pragma once
00026 #endif // _MSC_VER > 1000
00027
00028
00029 #define WM_RTCCORE_EVENT    WM_USER+501
00030
00031 #define RECVVID_LEFT        420
00032 #define RECVVID_TOP         170
00033 #define RECVVID_RIGHT       13
00034 #define RECVVID_BOTTOM      20
00035
00036
00037 #define PREVVID_LEFT        420
00038 #define PREVVID_TOP         35
00039 #define PREVVID_RIGHT       13
00040 #define PREVVID_BOTTOM      20
00041
00042
00043 #define MAX_RTCTIMEOUT      5000
00044
00045
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 // CRTCOutgoingDlg dialog
00049
00050 class CRTCOutgoingDlg : public CDialog,
00051               public IRTCEventNotification
00052 {
00053 // Construction
00054 public:
00055   CRTCOutgoingDlg(CWnd* pParent = NULL);  // standard constructor
00056
00057   // Dialog Data
00058   //
00059   //{{AFX_DATA(CRTCOutgoingDlg)
00060   enum { IDD = IDD_RTCOUTGOING_DIALOG };
00061   CEdit m_ctrlEditStatus;
00062   CEdit m_editLURI;
00063   CEdit m_editDURI;
00064   CListBox  m_lbParties;
00065   CButton m_btnPcPh;
00066   CButton m_btnPhPh;
00067   CButton m_btnPcPc;
00068   CButton m_btnTune;
00069   CButton m_btnRemoveParty;
00070   CButton m_btnAppSharing;
00071   CButton m_btnAddParty;
00072   CButton m_btnDisconnect;
00073   CButton m_btnConnect;
00074   //}}AFX_DATA
00075
00076   // ClassWizard generated virtual function overrides
00077   //{{AFX_VIRTUAL(CRTCOutgoingDlg)
00078   protected:
00079   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00080   virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
00081   //}}AFX_VIRTUAL
00082
00083   //
00084   // Initializing the State of the Dialog Box Controls
00085   //
00086
00087
00088   void InitialControlsState();
00089
00090   //
00091   // Helpers for Changing the state of
00092   // the UI Controls
00093   //
00094
00095
00096   void StateConnectIDC(VARIANT_BOOL fEnable);
00097   void StateConnectIDCVisible(VARIANT_BOOL fVisible);
00098   void StateDisconnectIDC(VARIANT_BOOL fEnable);
00099   void StateAddPartyIDC(VARIANT_BOOL fEnable);
00100   void StateAddPartyIDCVisible(VARIANT_BOOL fVisible);
00101   void StateRemovePartyIDC(VARIANT_BOOL fEnable);
00102   void StateTuneIDC(VARIANT_BOOL fEnable);
00103   void StateAppSharingIDC(VARIANT_BOOL fEnable);
00104   void StateDUriIDC(VARIANT_BOOL fEnable);
00105   void StateLUriIDC(VARIANT_BOOL fEnable);
00106   void StatePartyListIDC(VARIANT_BOOL fEnable);
00107   void AddToParticipantList(BSTR bstrParty);
00108
00109
00110   //
00111   // Initialization of state machine and shutdown
00112   //
00113
00114   HRESULT InitializeRTCApp();
00115   HRESULT ShutdownRTCApp();
00116
00117
00118   //
00119   // Event Source Method for Receiving RTC Events
00120   // and posting Messages to Main thread RTCEventThread
00121   //
00122
00123   HRESULT STDMETHODCALLTYPE Event(
00124       RTC_EVENT RTCEvent,
00125             IDispatch * pEvent
00126             );
00127
00128
00129   // IUnknown Implementations from IRTCEventNotification
00130   //
00131
00132   HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
00133                        void **ppvObject);
00134
00135   ULONG STDMETHODCALLTYPE AddRef(void);
00136   ULONG STDMETHODCALLTYPE Release(void);
00137
00138
00139   //
00140   // state transition methods for sessions
00141   //
00142
00143   typedef enum tagSESSION_OPERATION
00144   {
00145
00146     STO_CREATE,
00147     STO_ADDPARTY,
00148     STO_REMOVEPARTY,
00149     STO_TERMINATE
00150
00151   } SESSION_OPERATION;
00152
00153
00154   //
00155   // RTC Core Helpers for State Transition
00156   // operations
00157   //
00158
00159   HRESULT StateCoCreateClient();
00160   HRESULT StateInitClient();
00161   HRESULT StateSinkEvent(LONG lEventMask);
00162   HRESULT StateUnSinkEvent();
00163
00164   HRESULT StateSessionControl(SESSION_OPERATION soType);
00165   HRESULT StateQueryActiveMedia(LONG *plActiveMedia);
00166   HRESULT StateListenMode(RTC_LISTEN_MODE lMode);
00167   HRESULT StateStartT120(RTC_T120_APPLET tType);
00168   HRESULT StateStartTunning();
00169   HRESULT AddToMediaCapabilities(LONG lMedia, VARIANT_BOOL fPersist);
00170   HRESULT RemoveFromMediaCapabilities(LONG lMedia, VARIANT_BOOL fPersist);
00171   HRESULT ReleaseStateMachine();
00172
00173   //
00174   // Helper Event Parsers
00175   //
00176
00177   HRESULT RTCClientEvent(IDispatch *pIDispatch);
00178   HRESULT RTCSessionStateEvent(IDispatch *pIDispatch);
00179   HRESULT RTCMediaEvent(IDispatch *pIDispatch);
00180
00181 // Implementation
00182 protected:
00183   HICON m_hIcon;
00184
00185   //
00186   // Client CoClass default interface
00187   //
00188
00189   IRTCClient      *m_pIRTCClient;
00190
00191   //
00192   // pointer to Session interface
00193   //
00194
00195   IRTCSession     *m_pIRTCSession;
00196
00197   //
00198   // Callback event/Advise cookie
00199   //
00200
00201   DWORD            m_dwEventCookie;
00202
00203   //
00204   // Render / Capture Video Windows
00205   //
00206
00207   IVideoWindow    *m_pIRecvVideo;
00208   IVideoWindow    *m_pIPrevVideo;
00209
00210   //
00211   // Pointer to Participant Information
00212   //
00213
00214   IRTCParticipant *m_pIRTCParty;
00215   LONG             m_dwRefCount;
00216
00217   //
00218   // Type of the Session
00219   //
00220
00221   RTC_SESSION_TYPE m_SessionType;
00222
00223   //
00224   // Generated message map functions
00225   //
00226   //{{AFX_MSG(CRTCOutgoingDlg)
00227   virtual BOOL OnInitDialog();
00228   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00229   afx_msg void OnPaint();
00230   afx_msg HCURSOR OnQueryDragIcon();
00231   afx_msg void OnPcpcradio();
00232   afx_msg void OnPcphradio();
00233   afx_msg void OnPhphradio();
00234   afx_msg void OnConnect();
00235   afx_msg void OnDisconnect();
00236   afx_msg void OnAppsharing();
00237   afx_msg void OnTune();
00238   afx_msg void OnAddparty();
00239   afx_msg void OnRemoveparty();
00240   afx_msg void OnClose();
00241   afx_msg void OnSelchangePartylist();
00242   afx_msg void OnDblclkPartylist();
00243   //}}AFX_MSG
00244   DECLARE_MESSAGE_MAP()
00245 };
00246
00247
00248 #endif //  ____RTCOUTGOINGDLG_H_____
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/APIDoc.h Source File

  • WinBase
  • WtsApi
  • WtsApi

APIDoc.h

Go to the documentation of this file.
00001 // APIDoc.h : interface of the CAPIDoc class
00002 //
00003 //  Copyright 1995-1999, Citrix Systems Inc.
00004 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00005
00006 /////////////////////////////////////////////////////////////////////////////
00007
00008 #if !defined(AFX_APIDOC_H__C090CEF0_303B_11D1_8310_00C04FBEFCDA__INCLUDED_)
00009 #define AFX_APIDOC_H__C090CEF0_303B_11D1_8310_00C04FBEFCDA__INCLUDED_
00010
00011 #if _MSC_VER >= 1000
00012 #pragma once
00013 #endif // _MSC_VER >= 1000
00014
00015 #include <wtsapi32.h>
00016
00017 class CAPIDoc : public CDocument
00018 {
00019 protected: // create from serialization only
00020   CAPIDoc();
00021   DECLARE_DYNCREATE(CAPIDoc)
00022
00023 // Attributes
00024 public:
00025
00026 // Operations
00027 public:
00028
00029 // Overrides
00030   // ClassWizard generated virtual function overrides
00031   //{{AFX_VIRTUAL(CAPIDoc)
00032   public:
00033   virtual void Serialize(CArchive& ar);
00034   //}}AFX_VIRTUAL
00035
00036 // Implementation
00037 public:
00038   void SetSessionID(DWORD p) {sessionID=p;};
00039   DWORD GetSessionID() {return sessionID;};
00040   LPSTR GetServerName() {return serverName;};
00041   void SetServerName(TCHAR* temp) {strcpy(serverName, temp);};
00042   void ReadTrustedDomains();
00043   DWORD count;
00044   PWTS_SERVER_INFO pServerInfo;
00045   DWORD sessionID;
00046   TCHAR* serverName;
00047   LPSTR domainName;
00048   virtual ~CAPIDoc();
00049
00050 #ifdef _DEBUG
00051   virtual void AssertValid() const;
00052   virtual void Dump(CDumpContext& dc) const;
00053 #endif
00054
00055 protected:
00056
00057 // Generated message map functions
00058 protected:
00059   //{{AFX_MSG(CAPIDoc)
00060   afx_msg void OnRunTest();
00061   afx_msg void OnProcess();
00062   afx_msg void OnSession();
00063   afx_msg void OnShutdownSystem();
00064   afx_msg void OnSendMessage();
00065   afx_msg void OnWaitEvent();
00066   afx_msg void OnUserconfig();
00067   //}}AFX_MSG
00068   DECLARE_MESSAGE_MAP()
00069 private:
00070   char m_ServerName[70];
00071 };
00072
00073 extern CAPIDoc *g_pDoc;
00074
00075 /////////////////////////////////////////////////////////////////////////////
00076
00077 //{{AFX_INSERT_LOCATION}}
00078 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00079
00080 #endif // !defined(AFX_APIDOC_H__C090CEF0_303B_11D1_8310_00C04FBEFCDA__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/module.h Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

module.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        module.h
00007 //
00008 // Contents:    CCertManagePolicyModuleSample definition
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "certpsam.h"
00013 #include "resource.h"       // main symbols
00014
00015
00016 class CCertManagePolicyModuleSample:
00017     public CComDualImpl<ICertManageModule, &IID_ICertManageModule, &LIBID_CERTPOLICYSAMPLELib>,
00018     public CComObjectRoot,
00019     public CComCoClass<CCertManagePolicyModuleSample, &CLSID_CCertManagePolicyModuleSample>
00020 {
00021 public:
00022     CCertManagePolicyModuleSample() {}
00023     ~CCertManagePolicyModuleSample() {}
00024
00025 BEGIN_COM_MAP(CCertManagePolicyModuleSample)
00026     COM_INTERFACE_ENTRY(IDispatch)
00027     COM_INTERFACE_ENTRY(ICertManageModule)
00028 END_COM_MAP()
00029
00030 DECLARE_NOT_AGGREGATABLE(CCertManagePolicyModuleSample)
00031 // Remove the comment from the line above if you don't want your object to
00032 // support aggregation.  The default is to support it
00033
00034 // UNDONE UNDONE
00035 DECLARE_REGISTRY(
00036     CCertManagePolicyModuleSample,
00037     wszCLASS_CERTMANAGEPOLICYMODULESAMPLE TEXT(".1"),
00038     wszCLASS_CERTMANAGEPOLICYMODULESAMPLE,
00039     IDS_CERTMANAGEPOLICYMODULE_DESC,
00040     THREADFLAGS_BOTH)
00041
00042 // ICertManageModule
00043 public:
00044     STDMETHOD (GetProperty) (
00045             /* [in] */ const BSTR strConfig,
00046             /* [in] */ BSTR strStorageLocation,
00047             /* [in] */ BSTR strPropertyName,
00048             /* [in] */ LONG dwFlags,
00049             /* [retval][out] */ VARIANT __RPC_FAR *pvarProperty);
00050
00051     STDMETHOD (SetProperty)(
00052             /* [in] */ const BSTR strConfig,
00053             /* [in] */ BSTR strStorageLocation,
00054             /* [in] */ BSTR strPropertyName,
00055             /* [in] */ LONG dwFlags,
00056             /* [in] */ VARIANT const __RPC_FAR *pvarProperty);
00057
00058     STDMETHOD (Configure)(
00059             /* [in] */ const BSTR strConfig,
00060             /* [in] */ BSTR strStorageLocation,
00061             /* [in] */ LONG dwFlags);
00062 };
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMonitorServer Member List

This is the complete list of members for CMonitorServer, including all inherited members.
CMonitorServer() | CMonitorServer | [inline]
GetData(LONG __RPC_FAR *pData) | CMonitorServer |
GetPingResponder(IPingResponder __RPC_FAR *__RPC_FAR *ppPing) | CMonitorServer |
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

WiaWrap::CProgressDlg Member List

This is the complete list of members for WiaWrap::CProgressDlg, including all inherited members.
Cancelled() const | WiaWrap::CProgressDlg |
CProgressDlg(HWND hWndParent) | WiaWrap::CProgressDlg |
DialogProc(HWND, UINT, WPARAM, LPARAM) | WiaWrap::CProgressDlg | [private, static]
m_bCancelled | WiaWrap::CProgressDlg | [private]
m_cRef | WiaWrap::CProgressDlg | [private]
m_hDlg | WiaWrap::CProgressDlg | [private]
m_hInitDlg | WiaWrap::CProgressDlg | [private]
m_hWndParent | WiaWrap::CProgressDlg | [private]
QueryInterface(REFIID iid, LPVOID *ppvObj) | WiaWrap::CProgressDlg |
SetMessage(PCTSTR pszMessage) | WiaWrap::CProgressDlg |
SetPercent(UINT nPercent) | WiaWrap::CProgressDlg |
SetTitle(PCTSTR pszTitle) | WiaWrap::CProgressDlg |
STDMETHOD_(ULONG, AddRef)() | WiaWrap::CProgressDlg |
STDMETHOD_(ULONG, Release)() | WiaWrap::CProgressDlg |
ThreadProc(PVOID pParameter) | WiaWrap::CProgressDlg | [private, static]
~CProgressDlg() | WiaWrap::CProgressDlg |
Generated on Wed Nov 13 2024 16:58:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CObjConstSub Member List

This is the complete list of members for CObjConstSub, including all inherited members.
CObjConstSub(CComSpy *pSpy) | CObjConstSub | [inline]
CObjConstSub() | CObjConstSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetEventClass(LPGUID guid) | CObjConstSub | [inline, virtual]
GetEventType(EventEnum *e) | CObjConstSub | [inline, virtual]
GetInterface(IID *iid) | CObjConstSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnObjectConstruct(COMSVCSEVENTINFO *pInfo, REFGUID guidClass, LPCOLESTR pszConstructString, ULONG64 ObjectID) | CObjConstSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:56:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/StepByStep/Step1/DimmingService_SCPD.idl Source File

  • NetDS
  • upnp
  • StepByStep
  • Step1

DimmingService_SCPD.idl

Go to the documentation of this file.
00001 typedef [v1_enum] enum DIMMINGSERVICE_SCPD_DISPIDS
00002 {
00003    DISPID_POWER = 1,
00004    DISPID_DIMLEVEL,
00005    DISPID_POWERON,
00006    DISPID_POWEROFF,
00007    DISPID_GETPOWERVALUE,
00008    DISPID_SETDIMLEVEL,
00009    DISPID_GETDIMLEVEL,
00010    DISPID_GETCONFIGDETAILS
00011
00012 } DIMMINGSERVICE_SCPD_DISPIDS;
00013
00014 [
00015    uuid(a315fcbd-7f4b-4081-a172-2f534c438957),
00016    oleautomation,
00017    pointer_default(unique)
00018 ]
00019 interface IUPnPService_DimmingService_SCPD : IDispatch {
00020   [propget, id(DISPID_POWER), helpstring("Property Power")]
00021   HRESULT Power(
00022     [out, retval] VARIANT_BOOL *pPower);
00023
00024   [propget, id(DISPID_DIMLEVEL), helpstring("Property dimLevel")]
00025   HRESULT dimLevel(
00026     [out, retval] long *pdimLevel);
00027
00028
00029   [ id(DISPID_POWERON), helpstring("Method PowerOn")]
00030   HRESULT PowerOn();
00031
00032   [ id(DISPID_POWEROFF), helpstring("Method PowerOff")]
00033   HRESULT PowerOff();
00034
00035   [ id(DISPID_GETPOWERVALUE), helpstring("Method GetPowerValue")]
00036   HRESULT GetPowerValue(
00037     [in, out] VARIANT_BOOL *ppowerVall);
00038
00039   [ id(DISPID_SETDIMLEVEL), helpstring("Method SetDimLevel")]
00040   HRESULT SetDimLevel(
00041     [in] long dLevel);
00042
00043   [ id(DISPID_GETDIMLEVEL), helpstring("Method GetDimLevel")]
00044   HRESULT GetDimLevel(
00045     [in, out] long *pdLevel);
00046
00047   [ id(DISPID_GETCONFIGDETAILS), helpstring("Method GetConfigDetails")]
00048   HRESULT GetConfigDetails(
00049     [in, out] VARIANT_BOOL *ppowerVal,
00050     [in, out] long *pdLevel);
00051 };
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/CStatHlp.Cpp Source File

  • WinUI
  • Shell
  • FileView

CStatHlp.Cpp

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //    PROGRAM:        CSTATHLP.CPP
00009 //
00010 //    PURPOSE:  Implements the  CStatusHelper class to assist managing the strings for the
00011 //           status bar.  Here we provide menu ID to string ID mapping  services using a mapping
00012 //           structure in the module's resources.  This code assumes that the status bar is a standard Windows
00013 //           status bar control.
00014 //
00015 //    PLATFORMS:    Windows 95
00016 //
00017 //    SPECIAL INSTRUCTIONS: N/A
00018 //
00019
00020 #include "fileview.h"
00021
00022 //
00023 //   FUNCTION:     CStatusHelper::CStatusHelper
00024 //
00025 //   PURPOSE:  Constructor for the CStatusHelper class
00026 //
00027 //   PARAMETERS:
00028 //  hWnd            HWND of the Status Bar control to work with.
00029 //  hInst           HINSTANCE of the module we're in.
00030 //
00031 CStatusHelper::CStatusHelper(HWND hWnd, HINSTANCE hInst)
00032     {
00033     m_hWnd=hWnd;
00034     m_hInst=hInst;
00035
00036     m_uIDCur=0xFFFFFFFF;    //Nothing shown yet.
00037
00038     m_pST=NULL;
00039     m_pPMM=NULL;
00040     m_pSMM=NULL;
00041     m_hMemSMM=NULL;
00042
00043     //With this FALSE, many other members are ignored.
00044     m_fMapped=FALSE;
00045     return;
00046     }
00047 //
00048 //   FUNCTION:  CStatusHelper::~CStatusHelper
00049 //
00050 //   PURPOSE: Destructor for the CStatusHelper class.
00051 //
00052 CStatusHelper::~CStatusHelper(void)
00053     {
00054     //Free up anything from MessageMap
00055     if (NULL!=m_pPMM)
00056         {
00057         LocalFree((HLOCAL)m_pPMM);
00058         m_pPMM=NULL;
00059         }
00060
00061     if (NULL!=m_pST)
00062         {
00063         delete m_pST;
00064         m_pST=NULL;
00065         }
00066
00067     if (NULL!=m_pSMM)
00068         {
00069         LocalFree((HLOCAL)m_pSMM);
00070         UnlockResource(m_hMemSMM);
00071         m_pSMM=NULL;
00072         }
00073
00074     if (NULL!=m_hMemSMM)
00075         {
00076         FreeResource(m_hMemSMM);
00077         m_hMemSMM=NULL;
00078         }
00079
00080     return;
00081     }
00082 //
00083 //   FUNCTION: CStatusHelper::MessageMap
00084 //
00085 //   PURPOSE:    Initializes a CStatusHelper for automated processing of
00086 //  WM_MENUSELECT messages as well as setting up a list of messages
00087 //  that we can display using identifiers instead of string
00088 //  pointers.  See MenuSelect and MessageDisplay members.
00089 //
00090 //  PARAMETERS:
00091 //  hWndOwner - HWND of the window owning menus we're interested in serving
00092 //  uIDRMap - UINT identifying a resource mapping ID values to string ID values
00093 //  idsMin - UINT specifying the lowest string ID to load
00094 //  idsMax - UINT specifying the hightest string ID to load
00095 //  cchMax - UINT maximum string length
00096 //  uIDPopupMin - UINT of the lowest ID to assign to popup menus
00097 //  uIDPopupMax - UINT of the highest ID to assign to popup menus
00098 //  uIDStatic- UINT of the ID for the quiescent state message
00099 //  uIDBlank - UINT of the ID for a blank message
00100 //  uIDSysMenu - UINT of the ID for the system menu
00101 //
00102 //  RETURN VALUE:
00103 //  BOOL     TRUE if the function was successful,
00104 //                  FALSE otherwise.
00105 //
00106 //   COMMENTS:  This function is the initializer for the CStatusHelper class.
00107 //  If it fails, then the caller should delete the object.
00108 //
00109 BOOL CStatusHelper::MessageMap(HWND hWndOwner, UINT uIDRMap
00110     , UINT idsMin, UINT idsMax, UINT cchMax, UINT uIDPopupMin
00111     , UINT uIDPopupMax, UINT uIDStatic, UINT uIDBlank, UINT uIDSysMenu)
00112     {
00113     HMENU           hMenu;
00114     HRSRC           hRes;
00115     UINT            i;
00116     USHORT          uID;
00117     DWORD           dwSize;
00118     PSTATMESSAGEMAP pSMM;
00119
00120     // Check if we even got a valid window in the constructor
00121     // or if we've already been called.
00122     if (!IsWindow(m_hWnd) || m_fMapped)
00123         return FALSE;
00124
00125     //Parameter validation
00126     if (idsMax < idsMin || uIDPopupMax < uIDPopupMin)
00127         return FALSE;
00128
00129     //Cache away all this vital information
00130     m_hWndOwner  =hWndOwner;
00131     m_idsMin     =idsMin;
00132     m_idsMax     =idsMax;
00133     m_cMessages  =(USHORT)(idsMax-idsMin+1);
00134
00135     m_uIDPopupMin=uIDPopupMin;
00136     m_uIDPopupMax=uIDPopupMax;
00137     m_cPopups    =(USHORT)(uIDPopupMax-uIDPopupMin+1);
00138     m_uIDStatic  =uIDStatic;
00139     m_uIDBlank   =uIDBlank;
00140     m_uIDSysMenu =uIDSysMenu;
00141
00142     //Get a stringtable with all the messages
00143     m_pST=new CStringTable(m_hInst);
00144
00145     if (NULL==m_pST)
00146         return FALSE;
00147
00148     if (!m_pST->FInit(idsMin, idsMax, CCHSTATUSMSGMAX))
00149         return FALSE;
00150
00151     //Load the STATMESSAGEMAP array from resources
00152     hRes=FindResource(m_hInst, MAKEINTRESOURCE(uIDRMap), RT_RCDATA);
00153
00154     if (NULL==hRes)
00155         return FALSE;
00156
00157     m_hMemSMM=LoadResource(m_hInst, hRes);
00158
00159     if (NULL==m_hMemSMM)
00160         return FALSE;
00161
00162     pSMM=(PSTATMESSAGEMAP)LockResource(m_hMemSMM);
00163
00164     if (NULL==pSMM)
00165         return FALSE;
00166
00167     // Now get the size of the resource
00168     dwSize = SizeofResource(m_hInst, hRes);
00169
00170     // Resources are ReadOnly data so copy it to memory that can
00171     // be used
00172     m_pSMM = (PSTATMESSAGEMAP)LocalAlloc(LPTR, dwSize);
00173     if (NULL==m_pSMM)
00174         return FALSE;
00175     CopyMemory(m_pSMM, pSMM, dwSize);
00176
00177     //Sort these for binary search lookup.
00178     Sort();
00179
00180     //Allocate an array of POPUPMENUMAP structures
00181     m_pPMM=(PPOPUPMENUMAP)LocalAlloc(LPTR
00182         , sizeof(POPUPMENUMAP)*m_cPopups);
00183
00184     if (NULL==m_pPMM)
00185         return FALSE;
00186
00187     //Initialize the array mapping popup menus to specific IDs.
00188     uID=uIDPopupMin;
00189     hMenu=GetMenu(m_hWndOwner);
00190
00191     for (i=0; i < m_cPopups; i++)
00192         {
00193         m_pPMM[i].hMenu=GetSubMenu(hMenu, i);
00194         m_pPMM[i].uID  =uID++;
00195         }
00196
00197     //All done!
00198     m_fMapped=TRUE;
00199     return TRUE;
00200     }
00201 //
00202 //   FUNCTION: CStatusHelper::MenuSelect
00203 //
00204 //   PURPOSE:  Displays the appropriate message for whatever is in the
00205 //  parameters of a WM_MENUSELECT message.  This can only be called
00206 //  if StatStripMessageMap has already been called and must be used
00207 //  with the same menu the owner window had at the time of that call.
00208 //
00209 //   PARAMETERS:
00210 //  wItem           WORD identifying the selected item
00211 //  wFlags          WORD specifying the type of menu item
00212 //  hMenu           HMENU of the menu selected.
00213 //
00214 void CStatusHelper::MenuSelect(WORD wItem, WORD wFlags, HMENU hMenu)
00215     {
00216     USHORT          uID;
00217
00218     if (!m_fMapped)
00219         return;
00220
00221     //Case 1:  Menu was cancelled, display static string
00222     if (0==wItem && (WORD)0xFFFF==wFlags)
00223         uID=m_uIDStatic;
00224     else
00225         {
00226         //Case 2:  System menu selected by itself.
00227         if ((MF_POPUP & wFlags) && (MF_SYSMENU & wFlags))
00228             uID=m_uIDSysMenu;
00229         else
00230             {
00231              //  Case 3:  A popup menu was chosen:
00232              //  Find the ID for the popup menu index in wItem
00233             if (MF_POPUP & wFlags)
00234                 uID=IDFromHMenu((HMENU)wItem);
00235             else
00236                 //Case 4:  A menu item is selected
00237                 if (0!=wItem)
00238                     uID=(UINT)wItem;
00239                 else
00240                     //Case 5:  Nothing is selected (e.g. separator)
00241                     uID=m_uIDBlank;
00242            }
00243         }
00244
00245     //Display the message
00246     MessageDisplay(uID);
00247     return;
00248     }
00249 //
00250 //   FUNCTION:       CStatusHelper::MessageDisplay
00251 //
00252 //   PURPOSE:  Displays the appropriate message for a given ID value.  This
00253 //  can only be called if MessageMap has already been called.
00254 //
00255 //   PARAMETERS:
00256 //     uID             UINT of the message to display.  This is not a string ID but an ID
00257 //                       in the STATMESSAGEMAP structure that maps to a string ID.
00258 //
00259 void CStatusHelper::MessageDisplay(UINT uID)
00260     {
00261     UINT        idsMsg;
00262
00263     if (!m_fMapped)
00264         return;
00265
00266     //If we're already displaying this ID, nothing we need to do
00267     if (m_uIDCur==uID)
00268         return;
00269
00270     //Go look up the string ID to display.
00271     idsMsg=IStringFromID(uID);
00272
00273     //Display it.
00274     SetWindowText(m_hWnd, (*m_pST)[idsMsg]);
00275     return;
00276     }
00277 //
00278 //   FUNCTION:       CStatusHelper::Sort          (Private)
00279 //
00280 //   PURPOSE:   Performs a selection sort on the STATMESSAGEMAP array that we
00281 //  load from resources.  Since we expect that the data is partially
00282 //  sorted (we tend to place things in resources in groups of
00283 //  seqential values), since the number of messages is usually
00284 //  less than 200, and since we're usually doing this stuff on startup
00285 //  (which takes a long time anyway), a cimple selection sort is a
00286 //  better choice than a more complex qsort.
00287 //
00288 void CStatusHelper::Sort(void)
00289     {
00290     UINT            i, j, k;
00291     STATMESSAGEMAP  smm;
00292
00293     for (j=0; j < (UINT)(m_cMessages-1); j++)
00294         {
00295         k=j;
00296         smm.uID   =m_pSMM[j].uID;
00297         smm.idsMsg=m_pSMM[j].idsMsg;
00298
00299         for (i=j+1; i < (UINT)m_cMessages; i++)
00300             {
00301             if (m_pSMM[i].uID < smm.uID)
00302                 {
00303                 smm.uID   =m_pSMM[i].uID;
00304                 smm.idsMsg=m_pSMM[i].idsMsg;
00305                 k=i;
00306                 }
00307             }
00308
00309         smm.uID         =m_pSMM[j].uID;
00310         smm.idsMsg      =m_pSMM[j].idsMsg;
00311         m_pSMM[j].uID   =m_pSMM[k].uID;   ;
00312         m_pSMM[j].idsMsg=m_pSMM[k].idsMsg;;
00313         m_pSMM[k].uID   =smm.uID;
00314         m_pSMM[k].idsMsg=smm.idsMsg;
00315         }
00316
00317     return;
00318     }
00319 //
00320 //   FUNCTION:       CStatusHelper::IDFromHMenu (Private)
00321 //
00322 //   PURPOSE:   Given a specific popup menu index, searches through m_pPMM for
00323 //  a match and returns the ID associated with that menu.
00324 //
00325 //   PARAMETERS:
00326 //       hMenu           HMENU to of he popup menu.
00327 //
00328 //   RETURN VALUE:
00329 //       USHORT          ID associated with the menu handle.
00330 //
00331 USHORT CStatusHelper::IDFromHMenu(HMENU hMenu)
00332     {
00333     USHORT      uID=m_uIDBlank;      //Default is empty
00334     UINT        i;
00335
00336     for (i=0; i < m_cPopups; i++)
00337         {
00338         if (m_pPMM[i].hMenu==hMenu)
00339             {
00340             uID=m_pPMM[i].uID;
00341             break;
00342             }
00343         }
00344
00345     return uID;
00346     }
00347 //
00348 //   FUNCTION:     CStatusHelper::IStringFromID (Private)
00349 //
00350 //   PURPOSE:  Performs a binary search in a STATMESSAGEMAP array looking for
00351 //  a specific item ID returning the string ID for that item.
00352 //
00353 //   PARAMETERS:
00354 //        uID             USHORT item ID to locate.
00355 //
00356 //   RETURN VALUE:
00357 //       UINT            String ID associated with wItem.
00358 //
00359 UINT CStatusHelper::IStringFromID(USHORT uID)
00360     {
00361     UINT        iLow =0;
00362     UINT        iHigh=m_cMessages-1;
00363     UINT        iMid;
00364
00365     while (TRUE)
00366         {
00367         iMid=(iLow+iHigh) >> 1;
00368
00369         if (uID < m_pSMM[iMid].uID)
00370             iHigh=iMid-1;
00371         else
00372             {
00373             if (uID > m_pSMM[iMid].uID)
00374                 iLow=iMid+1;
00375             else
00376                 break;    //Equality
00377             }
00378
00379         if (iHigh < iLow)
00380             break;
00381         }
00382
00383     return m_pSMM[iMid].idsMsg;
00384     }
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Service/Service.c Source File

  • WinBase
  • Service

Service.c

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 MODULE:   service.c
00010
00011 PURPOSE:  Implements functions required by all Windows NT services
00012
00013 FUNCTIONS:
00014   main(int argc, char **argv);
00015   service_ctrl(DWORD dwCtrlCode);
00016   service_main(DWORD dwArgc, LPTSTR *lpszArgv);
00017   CmdInstallService();
00018   CmdRemoveService();
00019   CmdDebugService(int argc, char **argv);
00020   ControlHandler ( DWORD dwCtrlType );
00021   GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
00022
00023 ---------------------------------------------------------------------------*/
00024
00025 #include <windows.h>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <process.h>
00029 #include <tchar.h>
00030
00031 #include "service.h"
00032
00033 // internal variables
00034 SERVICE_STATUS          ssStatus;       // current status of the service
00035 SERVICE_STATUS_HANDLE   sshStatusHandle;
00036 DWORD                   dwErr = 0;
00037 BOOL                    bDebug = FALSE;
00038 TCHAR                   szErr[256];
00039
00040 // internal function prototypes
00041 VOID WINAPI service_ctrl(DWORD dwCtrlCode);
00042 VOID WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv);
00043 VOID CmdInstallService();
00044 VOID CmdRemoveService();
00045 VOID CmdDebugService(int argc, char **argv);
00046 BOOL WINAPI ControlHandler ( DWORD dwCtrlType );
00047 LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
00048
00049 //
00050 //  FUNCTION: main
00051 //
00052 //  PURPOSE: entrypoint for service
00053 //
00054 //  PARAMETERS:
00055 //    argc - number of command line arguments
00056 //    argv - array of command line arguments
00057 //
00058 //  RETURN VALUE:
00059 //    none
00060 //
00061 //  COMMENTS:
00062 //    main() either performs the command line task, or
00063 //    call StartServiceCtrlDispatcher to register the
00064 //    main service thread.  When the this call returns,
00065 //    the service has stopped, so exit.
00066 //
00067 void __cdecl main(int argc, char **argv)
00068 {
00069    SERVICE_TABLE_ENTRY dispatchTable[] =
00070    {
00071       { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main},
00072       { NULL, NULL}
00073    };
00074
00075    if ( (argc > 1) &&
00076         ((*argv[1] == '-') || (*argv[1] == '/')) )
00077    {
00078       if ( _stricmp( "install", argv[1]+1 ) == 0 )
00079       {
00080          CmdInstallService();
00081       }
00082       else if ( _stricmp( "remove", argv[1]+1 ) == 0 )
00083       {
00084          CmdRemoveService();
00085       }
00086       else if ( _stricmp( "debug", argv[1]+1 ) == 0 )
00087       {
00088          bDebug = TRUE;
00089          CmdDebugService(argc, argv);
00090       }
00091       else
00092       {
00093          goto dispatch;
00094       }
00095       exit(0);
00096    }
00097
00098    // if it doesn't match any of the above parameters
00099    // the service control manager may be starting the service
00100    // so we must call StartServiceCtrlDispatcher
00101    dispatch:
00102    // this is just to be friendly
00103    printf( "%s -install          to install the service\n", SZAPPNAME );
00104    printf( "%s -remove           to remove the service\n", SZAPPNAME );
00105    printf( "%s -debug <params>   to run as a console app for debugging\n", SZAPPNAME );
00106    printf( "\nStartServiceCtrlDispatcher being called.\n" );
00107    printf( "This may take several seconds.  Please wait.\n" );
00108
00109    if (!StartServiceCtrlDispatcher(dispatchTable))
00110       AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed."));
00111 }
00112
00113
00114
00115 //
00116 //  FUNCTION: service_main
00117 //
00118 //  PURPOSE: To perform actual initialization of the service
00119 //
00120 //  PARAMETERS:
00121 //    dwArgc   - number of command line arguments
00122 //    lpszArgv - array of command line arguments
00123 //
00124 //  RETURN VALUE:
00125 //    none
00126 //
00127 //  COMMENTS:
00128 //    This routine performs the service initialization and then calls
00129 //    the user defined ServiceStart() routine to perform majority
00130 //    of the work.
00131 //
00132 void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
00133 {
00134
00135    // register our service control handler:
00136    //
00137    sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), service_ctrl);
00138
00139    if (!sshStatusHandle)
00140       goto cleanup;
00141
00142    // SERVICE_STATUS members that don't change in example
00143    //
00144    ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
00145    ssStatus.dwServiceSpecificExitCode = 0;
00146
00147
00148    // report the status to the service control manager.
00149    //
00150    if (!ReportStatusToSCMgr(
00151                            SERVICE_START_PENDING, // service state
00152                            NO_ERROR,              // exit code
00153                            3000))                 // wait hint
00154       goto cleanup;
00155
00156
00157    ServiceStart( dwArgc, lpszArgv );
00158
00159    cleanup:
00160
00161    // try to report the stopped status to the service control manager.
00162    //
00163    if (sshStatusHandle)
00164       (VOID)ReportStatusToSCMgr(
00165                                SERVICE_STOPPED,
00166                                dwErr,
00167                                0);
00168
00169    return;
00170 }
00171
00172
00173
00174 //
00175 //  FUNCTION: service_ctrl
00176 //
00177 //  PURPOSE: This function is called by the SCM whenever
00178 //           ControlService() is called on this service.
00179 //
00180 //  PARAMETERS:
00181 //    dwCtrlCode - type of control requested
00182 //
00183 //  RETURN VALUE:
00184 //    none
00185 //
00186 //  COMMENTS:
00187 //
00188 VOID WINAPI service_ctrl(DWORD dwCtrlCode)
00189 {
00190    // Handle the requested control code.
00191    //
00192    switch (dwCtrlCode)
00193    {
00194    // Stop the service.
00195    //
00196    // SERVICE_STOP_PENDING should be reported before
00197    // setting the Stop Event - hServerStopEvent - in
00198    // ServiceStop().  This avoids a race condition
00199    // which may result in a 1053 - The Service did not respond...
00200    // error.
00201    case SERVICE_CONTROL_STOP:
00202       ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);
00203       ServiceStop();
00204       return;
00205
00206       // Update the service status.
00207       //
00208    case SERVICE_CONTROL_INTERROGATE:
00209       break;
00210
00211       // invalid control code
00212       //
00213    default:
00214       break;
00215
00216    }
00217
00218    ReportStatusToSCMgr(ssStatus.dwCurrentState, NO_ERROR, 0);
00219 }
00220
00221
00222
00223 //
00224 //  FUNCTION: ReportStatusToSCMgr()
00225 //
00226 //  PURPOSE: Sets the current status of the service and
00227 //           reports it to the Service Control Manager
00228 //
00229 //  PARAMETERS:
00230 //    dwCurrentState - the state of the service
00231 //    dwWin32ExitCode - error code to report
00232 //    dwWaitHint - worst case estimate to next checkpoint
00233 //
00234 //  RETURN VALUE:
00235 //    TRUE  - success
00236 //    FALSE - failure
00237 //
00238 //  COMMENTS:
00239 //
00240 BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
00241                          DWORD dwWin32ExitCode,
00242                          DWORD dwWaitHint)
00243 {
00244    static DWORD dwCheckPoint = 1;
00245    BOOL fResult = TRUE;
00246
00247
00248    if ( !bDebug ) // when debugging we don't report to the SCM
00249    {
00250       if (dwCurrentState == SERVICE_START_PENDING)
00251          ssStatus.dwControlsAccepted = 0;
00252       else
00253          ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
00254
00255       ssStatus.dwCurrentState = dwCurrentState;
00256       ssStatus.dwWin32ExitCode = dwWin32ExitCode;
00257       ssStatus.dwWaitHint = dwWaitHint;
00258
00259       if ( ( dwCurrentState == SERVICE_RUNNING ) ||
00260            ( dwCurrentState == SERVICE_STOPPED ) )
00261          ssStatus.dwCheckPoint = 0;
00262       else
00263          ssStatus.dwCheckPoint = dwCheckPoint++;
00264
00265
00266       // Report the status of the service to the service control manager.
00267       //
00268       if (!(fResult = SetServiceStatus( sshStatusHandle, &ssStatus)))
00269       {
00270          AddToMessageLog(TEXT("SetServiceStatus"));
00271       }
00272    }
00273    return fResult;
00274 }
00275
00276
00277
00278 //
00279 //  FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
00280 //
00281 //  PURPOSE: Allows any thread to log an error message
00282 //
00283 //  PARAMETERS:
00284 //    lpszMsg - text for message
00285 //
00286 //  RETURN VALUE:
00287 //    none
00288 //
00289 //  COMMENTS:
00290 //
00291 VOID AddToMessageLog(LPTSTR lpszMsg)
00292 {
00293    TCHAR szMsg [(sizeof(SZSERVICENAME) / sizeof(TCHAR)) + 100 ];
00294    HANDLE  hEventSource;
00295    LPTSTR  lpszStrings[2];
00296
00297    if ( !bDebug )
00298    {
00299       dwErr = GetLastError();
00300
00301       // Use event logging to log the error.
00302       //
00303       hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
00304
00305       _stprintf(szMsg, TEXT("%s error: %d"), TEXT(SZSERVICENAME), dwErr);
00306       lpszStrings[0] = szMsg;
00307       lpszStrings[1] = lpszMsg;
00308
00309       if (hEventSource != NULL)
00310       {
00311          ReportEvent(hEventSource, // handle of event source
00312                      EVENTLOG_ERROR_TYPE,  // event type
00313                      0,                    // event category
00314                      0,                    // event ID
00315                      NULL,                 // current user's SID
00316                      2,                    // strings in lpszStrings
00317                      0,                    // no bytes of raw data
00318                      lpszStrings,          // array of error strings
00319                      NULL);                // no raw data
00320
00321          (VOID) DeregisterEventSource(hEventSource);
00322       }
00323    }
00324 }
00325
00326
00327
00328
00329 ///////////////////////////////////////////////////////////////////
00330 //
00331 //  The following code handles service installation and removal
00332 //
00333
00334
00335 //
00336 //  FUNCTION: CmdInstallService()
00337 //
00338 //  PURPOSE: Installs the service
00339 //
00340 //  PARAMETERS:
00341 //    none
00342 //
00343 //  RETURN VALUE:
00344 //    none
00345 //
00346 //  COMMENTS:
00347 //
00348 void CmdInstallService()
00349 {
00350    SC_HANDLE   schService;
00351    SC_HANDLE   schSCManager;
00352
00353    TCHAR szPath[512];
00354
00355    if ( GetModuleFileName( NULL, szPath, 512 ) == 0 )
00356    {
00357       _tprintf(TEXT("Unable to install %s - %s\n"), TEXT(SZSERVICEDISPLAYNAME), GetLastErrorText(szErr, 256));
00358       return;
00359    }
00360
00361    schSCManager = OpenSCManager(
00362                                NULL,                   // machine (NULL == local)
00363                                NULL,                   // database (NULL == default)
00364                                SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE  // access required
00365                                );
00366    if ( schSCManager )
00367    {
00368       schService = CreateService(
00369                                 schSCManager,               // SCManager database
00370                                 TEXT(SZSERVICENAME),        // name of service
00371                                 TEXT(SZSERVICEDISPLAYNAME), // name to display
00372                                 SERVICE_QUERY_STATUS,         // desired access
00373                                 SERVICE_WIN32_OWN_PROCESS,  // service type
00374                                 SERVICE_DEMAND_START,       // start type
00375                                 SERVICE_ERROR_NORMAL,       // error control type
00376                                 szPath,                     // service's binary
00377                                 NULL,                       // no load ordering group
00378                                 NULL,                       // no tag identifier
00379                                 TEXT(SZDEPENDENCIES),       // dependencies
00380                                 NULL,                       // LocalSystem account
00381                                 NULL);                      // no password
00382
00383       if ( schService )
00384       {
00385          _tprintf(TEXT("%s installed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
00386          CloseServiceHandle(schService);
00387       }
00388       else
00389       {
00390          _tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText(szErr, 256));
00391       }
00392
00393       CloseServiceHandle(schSCManager);
00394    }
00395    else
00396       _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
00397 }
00398
00399
00400
00401 //
00402 //  FUNCTION: CmdRemoveService()
00403 //
00404 //  PURPOSE: Stops and removes the service
00405 //
00406 //  PARAMETERS:
00407 //    none
00408 //
00409 //  RETURN VALUE:
00410 //    none
00411 //
00412 //  COMMENTS:
00413 //
00414 void CmdRemoveService()
00415 {
00416    SC_HANDLE   schService;
00417    SC_HANDLE   schSCManager;
00418
00419    schSCManager = OpenSCManager(
00420                                NULL,                   // machine (NULL == local)
00421                                NULL,                   // database (NULL == default)
00422                                SC_MANAGER_CONNECT   // access required
00423                                );
00424    if ( schSCManager )
00425    {
00426       schService = OpenService(schSCManager, TEXT(SZSERVICENAME), DELETE | SERVICE_STOP | SERVICE_QUERY_STATUS);
00427
00428       if (schService)
00429       {
00430          // try to stop the service
00431          if ( ControlService( schService, SERVICE_CONTROL_STOP, &ssStatus ) )
00432          {
00433             _tprintf(TEXT("Stopping %s."), TEXT(SZSERVICEDISPLAYNAME));
00434             Sleep( 1000 );
00435
00436             while ( QueryServiceStatus( schService, &ssStatus ) )
00437             {
00438                if ( ssStatus.dwCurrentState == SERVICE_STOP_PENDING )
00439                {
00440                   _tprintf(TEXT("."));
00441                   Sleep( 1000 );
00442                }
00443                else
00444                   break;
00445             }
00446
00447             if ( ssStatus.dwCurrentState == SERVICE_STOPPED )
00448                _tprintf(TEXT("\n%s stopped.\n"), TEXT(SZSERVICEDISPLAYNAME) );
00449             else
00450                _tprintf(TEXT("\n%s failed to stop.\n"), TEXT(SZSERVICEDISPLAYNAME) );
00451
00452          }
00453
00454          // now remove the service
00455          if ( DeleteService(schService) )
00456             _tprintf(TEXT("%s removed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
00457          else
00458             _tprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText(szErr,256));
00459
00460
00461          CloseServiceHandle(schService);
00462       }
00463       else
00464          _tprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText(szErr,256));
00465
00466       CloseServiceHandle(schSCManager);
00467    }
00468    else
00469       _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
00470 }
00471
00472
00473
00474
00475 ///////////////////////////////////////////////////////////////////
00476 //
00477 //  The following code is for running the service as a console app
00478 //
00479
00480
00481 //
00482 //  FUNCTION: CmdDebugService(int argc, char ** argv)
00483 //
00484 //  PURPOSE: Runs the service as a console application
00485 //
00486 //  PARAMETERS:
00487 //    argc - number of command line arguments
00488 //    argv - array of command line arguments
00489 //
00490 //  RETURN VALUE:
00491 //    none
00492 //
00493 //  COMMENTS:
00494 //
00495 void CmdDebugService(int argc, char ** argv)
00496 {
00497    DWORD dwArgc;
00498    LPTSTR *lpszArgv;
00499
00500 #ifdef UNICODE
00501    lpszArgv = CommandLineToArgvW(GetCommandLineW(), &(dwArgc) );
00502    if (NULL == lpszArgv)
00503    {
00504        // CommandLineToArvW failed!!
00505        _tprintf(TEXT("CmdDebugService CommandLineToArgvW returned NULL\n"));
00506        return;
00507    }
00508 #else
00509    dwArgc   = (DWORD) argc;
00510    lpszArgv = argv;
00511 #endif
00512
00513    _tprintf(TEXT("Debugging %s.\n"), TEXT(SZSERVICEDISPLAYNAME));
00514
00515    SetConsoleCtrlHandler( ControlHandler, TRUE );
00516
00517    ServiceStart( dwArgc, lpszArgv );
00518
00519 #ifdef UNICODE
00520 // Must free memory allocated for arguments
00521
00522    GlobalFree(lpszArgv);
00523 #endif // UNICODE
00524
00525 }
00526
00527
00528 //
00529 //  FUNCTION: ControlHandler ( DWORD dwCtrlType )
00530 //
00531 //  PURPOSE: Handled console control events
00532 //
00533 //  PARAMETERS:
00534 //    dwCtrlType - type of control event
00535 //
00536 //  RETURN VALUE:
00537 //    True - handled
00538 //    False - unhandled
00539 //
00540 //  COMMENTS:
00541 //
00542 BOOL WINAPI ControlHandler ( DWORD dwCtrlType )
00543 {
00544    switch ( dwCtrlType )
00545    {
00546    case CTRL_BREAK_EVENT:  // use Ctrl+C or Ctrl+Break to simulate
00547    case CTRL_C_EVENT:      // SERVICE_CONTROL_STOP in debug mode
00548       _tprintf(TEXT("Stopping %s.\n"), TEXT(SZSERVICEDISPLAYNAME));
00549       ServiceStop();
00550       return TRUE;
00551       break;
00552
00553    }
00554    return FALSE;
00555 }
00556
00557 //
00558 //  FUNCTION: GetLastErrorText
00559 //
00560 //  PURPOSE: copies error message text to string
00561 //
00562 //  PARAMETERS:
00563 //    lpszBuf - destination buffer
00564 //    dwSize - size of buffer
00565 //
00566 //  RETURN VALUE:
00567 //    destination buffer
00568 //
00569 //  COMMENTS:
00570 //
00571 LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize )
00572 {
00573    DWORD dwRet;
00574    LPTSTR lpszTemp = NULL;
00575
00576    dwRet = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_ARGUMENT_ARRAY,
00577                           NULL,
00578                           GetLastError(),
00579                           LANG_NEUTRAL,
00580                           (LPTSTR)&lpszTemp,
00581                           0,
00582                           NULL );
00583
00584    // supplied buffer is not long enough
00585    if ( !dwRet || ( (long)dwSize < (long)dwRet+14 ) )
00586       lpszBuf[0] = TEXT('\0');
00587    else
00588    {
00589       lpszTemp[lstrlen(lpszTemp)-2] = TEXT('\0');  //remove cr and newline character
00590       _stprintf( lpszBuf, TEXT("%s (0x%x)"), lpszTemp, GetLastError() );
00591    }
00592
00593    if ( lpszTemp )
00594       LocalFree((HLOCAL) lpszTemp );
00595
00596    return lpszBuf;
00597 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/mibmgr.c Source File

  • NetDS
  • RRas
  • ip

mibmgr.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\mibmanager.c
00008
00009 Abstract:
00010
00011     The file contains IP Sample's MIB implementation.
00012
00013 Revision History:
00014
00015     MohitT      June-15-1999    Created
00016
00017 --*/
00018
00019 #include "pchsample.h"
00020 #pragma hdrstop
00021
00022
00023 DWORD
00024 WINAPI
00025 MM_MibSet (
00026     IN      PIPSAMPLE_MIB_SET_INPUT_DATA    pimsid)
00027 /*++
00028
00029 Routine Description
00030     Set IPSAMPLE's global or interface configuration.
00031
00032 Locks
00033     Acquires shared      (g_ce.pneNetworkEntry)->rwlLock
00034     Releases             (g_ce.pneNetworkEntry)->rwlLock
00035
00036 Arguments
00037     pimsid              input data, contains global/interface configuration
00038
00039 Return Value
00040     NO_ERROR            success
00041     Error Code          o/w
00042
00043 --*/
00044 {
00045     DWORD                   dwErr = NO_ERROR;
00046     ROUTING_PROTOCOL_EVENTS rpeEvent;
00047     MESSAGE                 mMessage = {0, 0, 0};
00048
00049     if (!ENTER_SAMPLE_API()) { return ERROR_CAN_NOT_COMPLETE; }
00050
00051     do                          // breakout loop
00052     {
00053         // set global configuration
00054         if (pimsid->IMSID_TypeID is IPSAMPLE_GLOBAL_CONFIG_ID)
00055         {
00056             if (pimsid->IMSID_BufferSize < sizeof(IPSAMPLE_GLOBAL_CONFIG))
00057             {
00058                 dwErr = ERROR_INVALID_PARAMETER;
00059                 break;
00060             }
00061
00062             dwErr = CM_SetGlobalInfo((PVOID) pimsid->IMSID_Buffer);
00063             if (dwErr != NO_ERROR)
00064                 break;
00065
00066             rpeEvent = SAVE_GLOBAL_CONFIG_INFO;
00067         }
00068         // set interface configuration
00069         else if (pimsid->IMSID_TypeID is IPSAMPLE_IF_CONFIG_ID)
00070         {
00071             if (pimsid->IMSID_BufferSize < sizeof(IPSAMPLE_IF_CONFIG))
00072             {
00073                 dwErr = ERROR_INVALID_PARAMETER;
00074                 break;
00075             }
00076
00077             dwErr = NM_SetInterfaceInfo(pimsid->IMSID_IfIndex,
00078                                         (PVOID) pimsid->IMSID_Buffer);
00079             if (dwErr != NO_ERROR)
00080                 break;
00081
00082             rpeEvent                = SAVE_INTERFACE_CONFIG_INFO;
00083             mMessage.InterfaceIndex = pimsid->IMSID_IfIndex;
00084         }
00085         // error, unexpected type
00086         else
00087         {
00088             dwErr = ERROR_INVALID_PARAMETER;
00089             break;
00090         }
00091
00092         // notify router manager
00093         if (EnqueueEvent(rpeEvent, mMessage) is NO_ERROR)
00094             SetEvent(g_ce.hMgrNotificationEvent);
00095
00096     } while(FALSE);
00097
00098
00099     LEAVE_SAMPLE_API();
00100
00101     return dwErr;
00102 }
00103
00104
00105
00106 DWORD
00107 WINAPI
00108 MM_MibGet (
00109     IN      PIPSAMPLE_MIB_GET_INPUT_DATA    pimgid,
00110     OUT     PIPSAMPLE_MIB_GET_OUTPUT_DATA   pimgod,
00111     IN OUT  PULONG                          pulOutputSize,
00112     IN      MODE                            mMode)
00113 /*++
00114
00115 Routine Description
00116     Handles the structure accesses required to read MIB data.  Supports
00117     three modes of querying: EXACT, FIRST, and NEXT, which correspond to
00118     MibGet(), MibGetFirst(), and MibGetNext() respectively.
00119
00120 Locks
00121     Acquires shared      (g_ce.pneNetworkEntry)->rwlLock
00122     Releases             (g_ce.pneNetworkEntry)->rwlLock
00123
00124 Arguments
00125     pimgid              input data
00126     pimgod              output buffer
00127     pulOutputSize       IN  size of output buffer given
00128                         OUT size of output buffer needed
00129     mMode               query type
00130
00131 Return Value
00132     NO_ERROR            success
00133     Error Code          o/w
00134
00135 --*/
00136 {
00137     DWORD               dwErr           = NO_ERROR;
00138     ULONG               ulSizeGiven     = 0;
00139     ULONG               ulSizeNeeded    = 0;
00140     PINTERFACE_ENTRY    pie;
00141
00142
00143     if (!ENTER_SAMPLE_API()) { return ERROR_CAN_NOT_COMPLETE; }
00144
00145     // compute the size of the buffer available for storing
00146     // returned structures (the size of IMGOD_Buffer)
00147     if (*pulOutputSize < sizeof(IPSAMPLE_MIB_GET_OUTPUT_DATA))
00148         ulSizeGiven = 0;
00149     else
00150         ulSizeGiven = *pulOutputSize - sizeof(IPSAMPLE_MIB_GET_OUTPUT_DATA);
00151
00152     switch (pimgid->IMGID_TypeID)
00153     {
00154         // the global statistics struct is fixed-length.
00155         // there is a single instance.
00156         case IPSAMPLE_GLOBAL_STATS_ID:
00157         {
00158             PIPSAMPLE_GLOBAL_STATS pigsdst, pigssrc;
00159
00160             // only GET_EXACT and GET_FIRST are valid for the
00161             // global stats object since there is only one entry
00162             if (mMode is GET_NEXT)
00163             {
00164                 dwErr = ERROR_NO_MORE_ITEMS;
00165                 break;
00166             }
00167
00168             // set the output size required for this entry
00169             ulSizeNeeded = sizeof(IPSAMPLE_GLOBAL_STATS);
00170
00171             // check that the output buffer is big enough
00172             if (ulSizeGiven < ulSizeNeeded)
00173             {
00174                 dwErr = ERROR_INSUFFICIENT_BUFFER;
00175                 break;
00176             }
00177
00178             pimgod->IMGOD_TypeID = IPSAMPLE_GLOBAL_STATS_ID;
00179
00180             // since access to this structure is synchronized through
00181             // locked increments/decrements, we must copy it field by field
00182             pigssrc = &(g_ce.igsStats);
00183             pigsdst = (PIPSAMPLE_GLOBAL_STATS) pimgod->IMGOD_Buffer;
00184
00185             pigsdst->ulNumInterfaces = pigssrc->ulNumInterfaces;
00186
00187             break;
00188         }
00189
00190         // the global configuration structure may be of variable size.
00191         // there is a single instance.
00192         case IPSAMPLE_GLOBAL_CONFIG_ID:
00193         {
00194             // only GET_EXACT and GET_FIRST are valid for the
00195             // global configuration object since there is only one entry
00196             if (mMode is GET_NEXT)
00197             {
00198                 dwErr = ERROR_NO_MORE_ITEMS;
00199                 break;
00200             }
00201
00202             // CM_GetGlobalInfo() decides whether the buffer size is
00203             // sufficient.  if so, it retrieves the global configuration.
00204             // either case it sets the required output buffer size.
00205             dwErr = CM_GetGlobalInfo ((PVOID) pimgod->IMGOD_Buffer,
00206                                       &ulSizeGiven,
00207                                       NULL,
00208                                       NULL,
00209                                       NULL);
00210             ulSizeNeeded = ulSizeGiven;
00211
00212             // check that the output buffer was big enough
00213             if (dwErr != NO_ERROR)
00214                 break;
00215
00216             pimgod->IMGOD_TypeID = IPSAMPLE_GLOBAL_CONFIG_ID;
00217
00218             break;
00219         }
00220
00221         // the interface statistics struct is fixed-length.
00222         // there may be multiple instances.
00223         case IPSAMPLE_IF_STATS_ID:
00224         {
00225             PIPSAMPLE_IF_STATS  piisdst, piissrc;
00226
00227             ACQUIRE_READ_LOCK(&(g_ce.pneNetworkEntry)->rwlLock);
00228
00229             do                  // breakout loop
00230             {
00231                 // retrieve the interface whose stats are to be read
00232                 dwErr = IE_GetIndex(pimgid->IMGID_IfIndex,
00233                                     mMode,
00234                                     &pie);
00235                 if (dwErr != NO_ERROR)
00236                     break;
00237
00238                 // set the output size required for this entry
00239                 ulSizeNeeded = sizeof(IPSAMPLE_IF_STATS);
00240
00241                 // check that the output buffer is big enough
00242                 if (ulSizeGiven < ulSizeNeeded)
00243                 {
00244                     dwErr = ERROR_INSUFFICIENT_BUFFER;
00245                     break;
00246                 }
00247
00248                 pimgod->IMGOD_TypeID = IPSAMPLE_IF_STATS_ID;
00249                 pimgod->IMGOD_IfIndex = pie->dwIfIndex;
00250
00251                 // access to this structure is synchronized through locked
00252                 // increments/decrements, so we copy it field by field
00253                 piissrc = &(pie->iisStats);
00254                 piisdst = (PIPSAMPLE_IF_STATS) pimgod->IMGOD_Buffer;
00255
00256                 piisdst->ulNumPackets = piissrc->ulNumPackets;
00257             } while (FALSE);
00258
00259             RELEASE_READ_LOCK(&(g_ce.pneNetworkEntry)->rwlLock);
00260
00261             break;
00262         }
00263
00264         // the interface configuration structure may be of variable size.
00265         // there may be multiple instances.
00266         case IPSAMPLE_IF_CONFIG_ID:
00267         {
00268             // get the queried interface's index
00269             ACQUIRE_READ_LOCK(&(g_ce.pneNetworkEntry)->rwlLock);
00270
00271             do                  // breakout loop
00272             {
00273                 dwErr = IE_GetIndex(pimgid->IMGID_IfIndex,
00274                                     mMode,
00275                                     &pie);
00276                 if (dwErr != NO_ERROR)
00277                     break;
00278
00279                 // read lock acuired again, which is fine :)
00280                 dwErr = NM_GetInterfaceInfo(pie->dwIfIndex,
00281                                             (PVOID) pimgod->IMGOD_Buffer,
00282                                             &ulSizeGiven,
00283                                             NULL,
00284                                             NULL,
00285                                             NULL);
00286                 ulSizeNeeded = ulSizeGiven;
00287
00288                 // check that the output buffer was big enough
00289                 if (dwErr != NO_ERROR)
00290                     break;
00291
00292                 pimgod->IMGOD_TypeID    = IPSAMPLE_IF_CONFIG_ID;
00293                 pimgod->IMGOD_IfIndex   = pie->dwIfIndex;
00294             } while (FALSE);
00295
00296             RELEASE_READ_LOCK(&(g_ce.pneNetworkEntry)->rwlLock);
00297
00298             break;
00299         }
00300
00301         // the interface binding structure is of variable size.
00302         // there may be multiple instances.
00303         case IPSAMPLE_IF_BINDING_ID:
00304         {
00305             PIPSAMPLE_IF_BINDING    piib;
00306             PIPSAMPLE_IP_ADDRESS    piia;
00307
00308             ACQUIRE_READ_LOCK(&(g_ce.pneNetworkEntry)->rwlLock);
00309
00310             do                  // breakout loop
00311             {
00312                 // retrieve the interface whose stats are to be read
00313                 dwErr = IE_GetIndex(pimgid->IMGID_IfIndex,
00314                                     mMode,
00315                                     &pie);
00316                 if (dwErr != NO_ERROR)
00317                     break;
00318
00319                 // set the output size required for this entry
00320                 ulSizeNeeded = sizeof(IPSAMPLE_IF_BINDING) +
00321                     pie->ulNumBindings * sizeof(IPSAMPLE_IP_ADDRESS);
00322
00323                 // check that the output buffer is big enough
00324                 if (ulSizeGiven < ulSizeNeeded)
00325                 {
00326                     dwErr = ERROR_INSUFFICIENT_BUFFER;
00327                     break;
00328                 }
00329
00330                 pimgod->IMGOD_TypeID    = IPSAMPLE_IF_BINDING_ID;
00331                 pimgod->IMGOD_IfIndex   = pie->dwIfIndex;
00332
00333                 piib = (PIPSAMPLE_IF_BINDING) pimgod->IMGOD_Buffer;
00334                 piia = IPSAMPLE_IF_ADDRESS_TABLE(piib);
00335
00336                 if (INTERFACE_IS_ACTIVE(pie))
00337                     piib->dwState |= IPSAMPLE_STATE_ACTIVE;
00338
00339                 if (INTERFACE_IS_BOUND(pie))
00340                     piib->dwState |= IPSAMPLE_STATE_BOUND;
00341
00342                 piib->ulCount = pie->ulNumBindings;
00343                 CopyMemory((PVOID) piia, // address,mask pairs
00344                            (PVOID) pie->pbeBindingTable, // ditto
00345                            pie->ulNumBindings * sizeof(IPSAMPLE_IP_ADDRESS));
00346             } while (FALSE);
00347
00348             RELEASE_READ_LOCK(&(g_ce.pneNetworkEntry)->rwlLock);
00349
00350             break;
00351         }
00352
00353         default:
00354         {
00355             dwErr = ERROR_INVALID_PARAMETER;
00356             break;
00357         }
00358     }
00359
00360     *pulOutputSize = sizeof(IPSAMPLE_MIB_GET_OUTPUT_DATA) + ulSizeNeeded;
00361
00362     LEAVE_SAMPLE_API();
00363
00364     return dwErr;
00365 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/WinMain.c Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

WinMain.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   winmain.c
00009 //
00010 //  PURPOSE:   Calls initialization functions and processes the message loop
00011 //
00012 //
00013 //  PLATFORMS: Windows 95
00014 //
00015 //  FUNCTIONS:
00016 //    WinMain() - calls initialization functions, processes message loop
00017 //
00018 //  COMMENTS:
00019 //
00020 //
00021
00022 #include <windows.h>            // required for all Windows applications
00023 #include "globals.h"            // prototypes specific to this application
00024
00025 //
00026 //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
00027 //
00028 //  PURPOSE: calls initialization function, processes message loop
00029 //
00030 //  PARAMETERS:
00031 //
00032 //    hInstance - The handle to the instance of this application that
00033 //          is currently being executed.
00034 //
00035 //    hPrevInstance - This parameter is always NULL in Win32
00036 //          applications.
00037 //
00038 //    lpCmdLine - A pointer to a null terminated string specifying the
00039 //          command line of the application.
00040 //
00041 //    nCmdShow - Specifies how the main window is to be diplayed.
00042 //
00043 //  RETURN VALUE:
00044 //    If the function terminates before entering the message loop,
00045 //    return FALSE.
00046 //    Otherwise, return the WPARAM value sent by the WM_QUIT message.
00047 //
00048 //
00049 //  COMMENTS:
00050 //
00051 //    Windows recognizes this function by name as the initial entry point
00052 //    for the program.  This function calls the initialization routine
00053 //    It then executes a message retrieval and dispatch loop that is the
00054 //    top-level control structure for the remainder of execution.  The
00055 //    loop is terminated when a WM_QUIT  message is received, at which
00056 //    time this function exits the application instance by returning the
00057 //    value passed by PostQuitMessage().
00058 //
00059 //    If this function must abort before entering the message loop, it
00060 //    returns the conventional value NULL.
00061 //
00062
00063 int APIENTRY WinMain(HINSTANCE hInstance,
00064                      HINSTANCE hPrevInstance,
00065                      LPSTR lpCmdLine,
00066                      int nCmdShow)
00067
00068 {
00069     MSG msg;
00070     HANDLE hAccelTable;
00071
00072     // Initialize application by setting up the main window.
00073     if (!InitApplication(hInstance, nCmdShow))
00074     {
00075         return FALSE;           // Exits if unable to initialize
00076     }
00077
00078     hAccelTable = LoadAccelerators(hInstance, szAppName);
00079
00080     // Acquire and dispatch messages until a WM_QUIT message is received.
00081     while( GetMessage(&msg, NULL, 0, 0))
00082     {
00083
00084         if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg))
00085         {
00086             TranslateMessage(&msg);  // Translates virtual key codes
00087             DispatchMessage(&msg);   // Dispatches message to window
00088         }
00089     }
00090     return (int)msg.wParam;  // Returns the value from PostQuitMessage
00091 }
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSysLCESub Member List

This is the complete list of members for CSysLCESub, including all inherited members.
CSysLCESub() | CSysLCESub | [inline]
EventName(EventEnum e) | CSysLCESub | [private]
GetEventClass(LPGUID EventClass)=0 | CSysLCESub | [pure virtual]
GetEventType(EventEnum *e)=0 | CSysLCESub | [pure virtual]
GetInterface(IID *iid)=0 | CSysLCESub | [pure virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:57:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/ADOVCGEN/stdafx.h Source File

  • Dataaccess
  • ADO
  • ADOVCGEN

stdafx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__BBDBD0BD_062B_4F57_B787_69C5A71C7850__INCLUDED_)
00007 #define AFX_STDAFX_H__BBDBD0BD_062B_4F57_B787_69C5A71C7850__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00014
00015 #include <afxwin.h>         // MFC core and standard components
00016 #include <afxext.h>         // MFC extensions
00017 #include <afxdisp.h>        // MFC Automation classes
00018 #include <afxdtctl.h>   // MFC support for Internet Explorer 4 Common Controls
00019 #ifndef _AFX_NO_AFXCMN_SUPPORT
00020 #include <afxcmn.h>     // MFC support for Windows Common Controls
00021 #endif // _AFX_NO_AFXCMN_SUPPORT
00022
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__BBDBD0BD_062B_4F57_B787_69C5A71C7850__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/ComSyncObject/ComSyncTest.Cpp Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • ComSyncObject

ComSyncTest.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: ComSyncTest.cpp
00004
00005 Summary: Implementation of CComSyncTest
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021
00022 #include "stdafx.h"
00023 #include "ComSyncObject.h"
00024 #include "ComSyncTest.h"
00025 #define LOOPCOUNT 10000
00026
00027 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00028
00029 Class: CComSyncTest
00030
00031 CComSyncTest is a simply object that does nothing but is marked as FREE threaded,
00032 and marked in COM+ as requring syncronization but doesn't have any by itself.
00033 It's purpose is just so our client has a free threaded COM syncronized object to call
00034
00035 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00036
00037 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00038
00039 Method: Exercise
00040
00041 Summary: Exercise simply loops for a while doing some math on the stack.
00042      This version does not utilize a CritSec. This is because this
00043      object will be marked as requires syncronization in COM+
00044
00045 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00046
00047 STDMETHODIMP CComSyncTest::Exercise(void)
00048 {
00049
00050   DWORD dwCount, dwValue = 0;
00051
00052   for (dwCount = 0; dwCount < LOOPCOUNT; dwCount++)
00053     dwValue += dwCount;
00054
00055   return S_OK;
00056 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/mqfdraw.h Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

mqfdraw.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // mqfdraw.h : main header file for the DISDRAW application
00014 //
00015
00016
00017 #ifndef __AFXWIN_H__
00018   #error include 'stdafx.h' before including this file for PCH
00019 #endif
00020
00021 #include "resource.h"   // main symbols
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // CDisdrawApp:
00025 // See disdraw.cpp for the implementation of this class
00026 //
00027
00028 class CDisdrawApp : public CWinApp
00029 {
00030 public:
00031   CDisdrawApp();
00032
00033 // Overrides
00034   // ClassWizard generated virtual function overrides
00035   //{{AFX_VIRTUAL(CDisdrawApp)
00036   public:
00037   virtual BOOL InitInstance();
00038   //}}AFX_VIRTUAL
00039
00040 // Implementation
00041
00042
00043   //{{AFX_MSG(CDisdrawApp)
00044     // NOTE - the ClassWizard will add and remove member functions here.
00045     //    DO NOT EDIT what you see in these blocks of generated code !
00046   //}}AFX_MSG
00047   DECLARE_MESSAGE_MAP()
00048 };
00049
00050
00051 /////////////////////////////////////////////////////////////////////////////
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/defs.h Source File

  • NetDS
  • RRas
  • ip

defs.h

Go to the documentation of this file.
00001
00002 /*++
00003
00004 Copyright (c) 1999 - 2000 Microsoft Corporation
00005
00006 Module Name:
00007
00008     sample\defs.h
00009
00010 Abstract:
00011
00012     The file contains various...
00013     . constants
00014     . definitions
00015     . macros
00016       - memory-allocation
00017       - logging
00018       - tracing
00019
00020 --*/
00021
00022 #ifndef _DEFS_H_
00023 #define _DEFS_H_
00024
00025
00026 // constants
00027
00028 #define INTERFACE_TABLE_BUCKETS     29 // # buckets in the interface hash table
00029
00030 #define NOW                         0
00031 #define INFINITE_INTERVAL           0x7fffffff
00032 #define PERIODIC_INTERVAL           5   // # seconds
00033
00034 #define MAX_PACKET_LENGTH           512
00035
00036
00037
00038 // definitions
00039
00040 #define is                          ==
00041 #define and                         &&
00042 #define or                          ||
00043
00044 #define GLOBAL_HEAP                 g_ce.hGlobalHeap
00045 #define TRACEID                     g_ce.dwTraceID
00046 #define LOGLEVEL                    g_ce.dwLogLevel
00047 #define LOGHANDLE                   g_ce.hLogHandle
00048 #define LOCKSTORE                   g_ce.dlsDynamicLocksStore
00049
00050 // invoked when entering API or worker functions
00051 #define ENTER_SAMPLE_API()          EnterSampleAPI()
00052 #define ENTER_SAMPLE_WORKER()       EnterSampleWorker()
00053
00054 // invoked when leaving API or worker functions
00055 #define LEAVE_SAMPLE_API()          LeaveSampleWorker()
00056 #define LEAVE_SAMPLE_WORKER()       LeaveSampleWorker()
00057
00058 // dynamic locks
00059 #define ACQUIRE_READ_DLOCK(pLock)                                   \
00060     AcquireDynamicReadwriteLock(&pLock, READ_MODE, LOCKSTORE)
00061 #define RELEASE_READ_DLOCK(pLock)                                   \
00062     ReleaseDynamicReadwriteLock(pLock, READ_MODE, LOCKSTORE)
00063 #define ACQUIRE_WRITE_DLOCK(pLock)                                  \
00064     AcquireDynamicReadwriteLock(&pLock, WRITE_MODE, LOCKSTORE)
00065 #define RELEASE_WRITE_DLOCK(pLock)                                  \
00066     ReleaseDynamicReadwriteLock(pLock, WRITE_MODE, LOCKSTORE)
00067
00068
00069
00070 // macros
00071
00072 #define SECTOMILLISEC(x)            ((x) * 1000)
00073 #define MAX(a, b)                   (((a) >= (b)) ? (a) : (b))
00074 #define MIN(a, b)                   (((a) <= (b)) ? (a) : (b))
00075
00076
00077
00078 // IP ADDRESS
00079
00080 // type
00081 typedef DWORD   IPADDRESS, *PIPADDRESS;
00082
00083
00084 // definitions
00085 #define IP_LOWEST                   0x00000000
00086 #define IP_HIGHEST                  0xffffffff
00087 #define STAR                        0x00000000
00088
00089
00090 // macros
00091
00092 // compare a and b
00093 #define IP_COMPARE(a, b)            (((a) < (b)) ? -1       \
00094                                                  : (((a) is (b)) ? 0 : 1))
00095
00096 // assign b to a
00097 #define IP_ASSIGN(pip, ip)          *(pip) = (ip)
00098
00099 // verify whether an ip address is valid
00100 #define IP_VALID(ip)                (IP_COMPARE(ip, IP_HIGHEST) is -1)
00101
00102 // returns the string representation of an ip address in a static buffer
00103 #define INET_NTOA(x)                (inet_ntoa(*(struct in_addr*)&(x)))
00104
00105
00106
00107 // TIMER
00108
00109 // macros
00110
00111 #define CREATE_TIMER(phHandle, pfnCallback, pvContext, ulWhen, pdwErr)      \
00112 {                                                                           \
00113     if (CreateTimerQueueTimer((phHandle),                                   \
00114                               g_ce.hTimerQueue,                             \
00115                               (pfnCallback),                                \
00116                               (pvContext),                                  \
00117                               SECTOMILLISEC(ulWhen),                        \
00118                               INFINITE_INTERVAL,                            \
00119                               0))                                           \
00120     {                                                                       \
00121         *(pdwErr) = NO_ERROR;                                               \
00122     }                                                                       \
00123     else                                                                    \
00124     {                                                                       \
00125         *(pdwErr) = GetLastError();                                         \
00126         TRACE1(ANY, "Error %u creating timer", *(pdwErr));                  \
00127         LOGERR0(CREATE_TIMER_FAILED, *(pdwErr));                            \
00128     }                                                                       \
00129 }
00130
00131 // it is safe to hold locks while making this call since
00132 // it is non blocking (NULL for hCompletionEvent).
00133 #define DELETE_TIMER(hHandle, pdwErr)                                       \
00134 {                                                                           \
00135     if (DeleteTimerQueueTimer(g_ce.hTimerQueue,                             \
00136                               (hHandle),                                    \
00137                               NULL))                                        \
00138     {                                                                       \
00139         *(pdwErr) = NO_ERROR;                                               \
00140     }                                                                       \
00141     else                                                                    \
00142     {                                                                       \
00143         *(pdwErr) = GetLastError();                                         \
00144         TRACE1(ANY, "Error %u deleting timer, continuing...", *(pdwErr));   \
00145     }                                                                       \
00146 }
00147
00148 #define RESTART_TIMER(hHandle, ulWhen, pdwErr)                              \
00149 {                                                                           \
00150     if (ChangeTimerQueueTimer(g_ce.hTimerQueue,                             \
00151                               (hHandle),                                    \
00152                               SECTOMILLISEC(ulWhen),                        \
00153                               INFINITE_INTERVAL))                           \
00154     {                                                                       \
00155         *(pdwErr) = NO_ERROR;                                               \
00156     }                                                                       \
00157     else                                                                    \
00158     {                                                                       \
00159         *(pdwErr) = GetLastError();                                         \
00160         TRACE1(ANY, "Error %u restarting timer, continuing...", *(pdwErr)); \
00161     }                                                                       \
00162 }
00163
00164
00165
00166 // MEMORY ALLOCATION
00167
00168 // macros
00169 #define MALLOC(ppPointer, ulSize, pdwErr)                                   \
00170 {                                                                           \
00171     if (*(ppPointer) = HeapAlloc(GLOBAL_HEAP, HEAP_ZERO_MEMORY, (ulSize)))  \
00172     {                                                                       \
00173         *(pdwErr) = NO_ERROR;                                               \
00174     }                                                                       \
00175     else                                                                    \
00176     {                                                                       \
00177         *(pdwErr) = ERROR_NOT_ENOUGH_MEMORY;                                \
00178         TRACE1(ANY, "Error allocating %u bytes", (ulSize));                 \
00179         LOGERR0(HEAP_ALLOC_FAILED, *(pdwErr));                              \
00180     }                                                                       \
00181 }
00182 #define REALLOC(ptr, size)          HeapReAlloc(GLOBAL_HEAP, 0, ptr, size)
00183 #define FREE(ptr)                                           \
00184 {                                                           \
00185      HeapFree(GLOBAL_HEAP, 0, (ptr));                       \
00186      (ptr) = NULL;                                          \
00187 }
00188
00189 #define FREE_NOT_NULL(ptr)                                  \
00190 {                                                           \
00191      if (!(ptr)) HeapFree(GLOBAL_HEAP, 0, (ptr));           \
00192      (ptr) = NULL;                                          \
00193 }
00194
00195
00196
00197 // TRACING
00198
00199 // definitions...
00200 #define IPSAMPLE_TRACE_ANY             ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
00201 #define IPSAMPLE_TRACE_ENTER           ((DWORD)0x00010000 | TRACE_USE_MASK)
00202 #define IPSAMPLE_TRACE_LEAVE           ((DWORD)0x00020000 | TRACE_USE_MASK)
00203 #define IPSAMPLE_TRACE_DEBUG           ((DWORD)0x00040000 | TRACE_USE_MASK)
00204 #define IPSAMPLE_TRACE_CONFIGURATION   ((DWORD)0x00100000 | TRACE_USE_MASK)
00205 #define IPSAMPLE_TRACE_NETWORK         ((DWORD)0x00200000 | TRACE_USE_MASK)
00206 #define IPSAMPLE_TRACE_PACKET          ((DWORD)0x00400000 | TRACE_USE_MASK)
00207 #define IPSAMPLE_TRACE_TIMER           ((DWORD)0x00800000 | TRACE_USE_MASK)
00208 #define IPSAMPLE_TRACE_MIB             ((DWORD)0x01000000 | TRACE_USE_MASK)
00209
00210
00211 // macros...
00212 #define TRACE0(l,a)                                                     \
00213     if (TRACEID != INVALID_TRACEID)                                     \
00214         TracePrintfEx(TRACEID, IPSAMPLE_TRACE_ ## l, a)
00215 #define TRACE1(l,a,b)                                                   \
00216     if (TRACEID != INVALID_TRACEID)                                     \
00217         TracePrintfEx(TRACEID, IPSAMPLE_TRACE_ ## l, a, b)
00218 #define TRACE2(l,a,b,c)                                                 \
00219     if (TRACEID != INVALID_TRACEID)                                     \
00220         TracePrintfEx(TRACEID, IPSAMPLE_TRACE_ ## l, a, b, c)
00221 #define TRACE3(l,a,b,c,d)                                               \
00222     if (TRACEID != INVALID_TRACEID)                                     \
00223         TracePrintfEx(TRACEID, IPSAMPLE_TRACE_ ## l, a, b, c, d)
00224 #define TRACE4(l,a,b,c,d,e)                                             \
00225     if (TRACEID != INVALID_TRACEID)                                     \
00226         TracePrintfEx(TRACEID, IPSAMPLE_TRACE_ ## l, a, b, c, d, e)
00227 #define TRACE5(l,a,b,c,d,e,f)                                           \
00228     if (TRACEID != INVALID_TRACEID)                                     \
00229         TracePrintfEx(TRACEID, IPSAMPLE_TRACE_ ## l, a, b, c, d, e, f)
00230
00231
00232
00233 // EVENT LOGGING
00234
00235 // definitions...
00236 #define LOGERR              RouterLogError
00237 #define LOGWARN             RouterLogWarning
00238 #define LOGINFO             RouterLogInformation
00239 #define LOGWARNDATA         RouterLogWarningData
00240
00241
00242 // macros...
00243
00244 //      ERRORS
00245 #define LOGERR0(msg,err)                                                \
00246         if (LOGLEVEL >= IPSAMPLE_LOGGING_ERROR)                         \
00247             LOGERR(LOGHANDLE,IPSAMPLELOG_ ## msg,0,NULL,(err))
00248 #define LOGERR1(msg,a,err)                                              \
00249         if (LOGLEVEL >= IPSAMPLE_LOGGING_ERROR)                         \
00250             LOGERR(LOGHANDLE,IPSAMPLELOG_ ## msg,1,&(a),(err))
00251 #define LOGERR2(msg,a,b,err)                                            \
00252         if (LOGLEVEL >= IPSAMPLE_LOGGING_ERROR) {                       \
00253             LPSTR _asz[2] = { (a), (b) };                               \
00254             LOGERR(LOGHANDLE,IPSAMPLELOG_ ## msg,2,_asz,(err));         \
00255         }
00256 #define LOGERR3(msg,a,b,c,err)                                          \
00257         if (LOGLEVEL >= IPSAMPLE_LOGGING_ERROR) {                       \
00258             LPSTR _asz[3] = { (a), (b), (c) };                          \
00259             LOGERR(LOGHANDLE,IPSAMPLELOG_ ## msg,3,_asz,(err));         \
00260         }
00261 #define LOGERR4(msg,a,b,c,d,err)                                        \
00262         if (LOGLEVEL >= IPSAMPLE_LOGGING_ERROR) {                       \
00263             LPSTR _asz[4] = { (a), (b), (c), (d) };                     \
00264             LOGERR(LOGHANDLE,IPSAMPLELOG_ ## msg,4,_asz,(err));         \
00265         }
00266
00267 //      WARNINGS
00268 #define LOGWARN0(msg,err)                                               \
00269         if (LOGLEVEL >= IPSAMPLE_LOGGING_WARN)                          \
00270             LOGWARN(LOGHANDLE,IPSAMPLELOG_ ## msg,0,NULL,(err))
00271 #define LOGWARN1(msg,a,err)                                             \
00272         if (LOGLEVEL >= IPSAMPLE_LOGGING_WARN)                          \
00273             LOGWARN(LOGHANDLE,IPSAMPLELOG_ ## msg,1,&(a),(err))
00274 #define LOGWARN2(msg,a,b,err)                                           \
00275         if (LOGLEVEL >= IPSAMPLE_LOGGING_WARN) {                        \
00276             LPSTR _asz[2] = { (a), (b) };                               \
00277             LOGWARN(LOGHANDLE,IPSAMPLELOG_ ## msg,2,_asz,(err));        \
00278         }
00279 #define LOGWARN3(msg,a,b,c,err)                                         \
00280         if (LOGLEVEL >= IPSAMPLE_LOGGING_WARN) {                        \
00281             LPSTR _asz[3] = { (a), (b), (c) };                          \
00282             LOGWARN(LOGHANDLE,IPSAMPLELOG_ ## msg,3,_asz,(err));        \
00283         }
00284 #define LOGWARN4(msg,a,b,c,d,err)                                       \
00285         if (LOGLEVEL >= IPSAMPLE_LOGGING_WARN) {                        \
00286             LPSTR _asz[4] = { (a), (b), (c), (d) };                     \
00287             LOGWARN(LOGHANDLE,IPSAMPLELOG_ ## msg,4,_asz,(err));        \
00288         }
00289
00290 #define LOGWARNDATA2(msg,a,b,dw,buf)                                    \
00291         if (LOGLEVEL >= IPSAMPLE_LOGGING_WARN) {                        \
00292             LPSTR _asz[2] = { (a), (b) };                               \
00293             LOGWARNDATA(LOGHANDLE,IPSAMPLELOG_ ## msg,2,_asz,(dw),(buf)); \
00294         }
00295
00296 //      INFORMATION
00297 #define LOGINFO0(msg,err)                                               \
00298         if (LOGLEVEL >= IPSAMPLE_LOGGING_INFO)                          \
00299             LOGINFO(LOGHANDLE,IPSAMPLELOG_ ## msg,0,NULL,(err))
00300 #define LOGINFO1(msg,a,err)                                             \
00301         if (LOGLEVEL >= IPSAMPLE_LOGGING_INFO)                          \
00302             LOGINFO(LOGHANDLE,IPSAMPLELOG_ ## msg,1,&(a),(err))
00303 #define LOGINFO2(msg,a,b,err)                                           \
00304         if (LOGLEVEL >= IPSAMPLE_LOGGING_INFO) {                        \
00305             LPSTR _asz[2] = { (a), (b) };                               \
00306             LOGINFO(LOGHANDLE,IPSAMPLELOG_ ## msg,2,_asz,(err));        \
00307         }
00308 #define LOGINFO3(msg,a,b,c,err)                                         \
00309         if (LOGLEVEL >= IPSAMPLE_LOGGING_INFO) {                        \
00310             LPSTR _asz[3] = { (a), (b), (c) };                          \
00311             LOGINFO(LOGHANDLE,IPSAMPLELOG_ ## msg,3,_asz,(err));        \
00312         }
00313 #define LOGINFO4(msg,a,b,c,d,err)                                       \
00314         if (LOGLEVEL >= IPSAMPLE_LOGGING_INFO) {                        \
00315             LPSTR _asz[4] = { (a), (b), (c), (d) };                     \
00316             LOGINFO(LOGHANDLE,IPSAMPLELOG_ ## msg,4,_asz,(err));        \
00317         }
00318
00319 #endif // _DEFS_H_
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/IFileVW.Cpp Source File

  • WinUI
  • Shell
  • FileView

IFileVW.Cpp

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  PROGRAM:  IFILEVW.CPP
00009 //
00010 //  PURPOSE: IFileViewer interface implementation for a FileViewer.
00011 // Custom FileViewer objects should modify the Show member
00012 // to suit its own needs.
00013 //
00014 //  PLATFORMS:  Windows 95
00015 //
00016 //  SPECIAL INSTRUCTIONS: N/A
00017 //
00018
00019 #include "fileview.h"
00020
00021 //
00022 //   FUNCTION: CImpIFileViewer::CImpIFileViewer
00023 //
00024 //   PURPOSE:   Constructor
00025 //
00026 //   PARAMETERS:
00027 //    pObj            PCFileViewer of the object we're in.
00028 //    pUnkOuter       LPUNKNOWN to which we delegate.
00029 //
00030 CImpIFileViewer::CImpIFileViewer(PCFileViewer pObj
00031     , LPUNKNOWN pUnkOuter)
00032     {
00033     m_pObj=pObj;
00034     m_pUnkOuter=pUnkOuter;
00035     return;
00036     }
00037 //
00038 //   FUNCTION:  CImpIFileViewer::~CImpIFileViewer
00039 //
00040 //   PURPOSE:   Destructor
00041 //
00042 CImpIFileViewer::~CImpIFileViewer(void)
00043     {
00044     return;
00045     }
00046 //
00047 //   FUNCTION:  CImpIFileViewer::QueryInterface
00048 //               CImpIFileViewer::AddRef
00049 //               CImpIFileViewer::Release
00050 //
00051 //   PURPOSE:    IUnknown members for CImpIFileViewer object that only delegate.
00052 //
00053 STDMETHODIMP CImpIFileViewer::QueryInterface(REFIID riid
00054     , PPVOID ppv)
00055     {
00056     return m_pUnkOuter->QueryInterface(riid, ppv);
00057     }
00058
00059 STDMETHODIMP_(ULONG) CImpIFileViewer::AddRef(void)
00060     {
00061     return m_pUnkOuter->AddRef();
00062     }
00063
00064 STDMETHODIMP_(ULONG) CImpIFileViewer::Release(void)
00065     {
00066     return m_pUnkOuter->Release();
00067     }
00068 //
00069 //   FUNCTION:CImpIFileViewer::PrintTo
00070 //
00071 //   PURPOSE:    Asks a FileViewer to print the file that came through
00072 //  IPersistFile::Load to a specific device with or without
00073 //  any user interaction.  This function should not return
00074 //  until the printing is complete.
00075 //
00076 //   PARAMETERS:
00077 //      pszDriver       LPSTR with the path of the driver to use.  If NULL, use the default driver.
00078 //      fSuppressUI     BOOL indicating if this function is to show any UI or not.
00079 //
00080 //   RETURN VALUE:
00081 //  HRESULT         NOERROR on success, error code otherwise.
00082 //
00083 STDMETHODIMP CImpIFileViewer::PrintTo(LPSTR pszDriver
00084     , BOOL fSuppressUI)
00085     {
00086      // Printing not implemented in this sample, but
00087      // make a stub call anyway.
00088     return m_pObj->PrintTo(pszDriver, fSuppressUI);
00089     }
00090 //
00091 //   FUNCTION: CImpIFileViewer::ShowInitialize
00092 //
00093 //   PURPOSE:  Initializes everything necessary to display the FileViewer
00094 //  window but does not show it.  The FileViewer should do all
00095 //  the necessary pre-visible work here as this is the only
00096 //  time the FileViewer is allowed to fail.
00097 //
00098 //   PARAMETERS:
00099 //
00100 //   RETURN VALUE:
00101 //     HRESULT         NOERROR or an appropriate error code such as
00102 //                  E_UNEXPECTED, E_FAIL, or E_OUTOFMEMORY.
00103 //
00104 STDMETHODIMP CImpIFileViewer::ShowInitialize(LPFILEVIEWERSITE lpfsi)
00105     {
00106     return m_pObj->FileShowInit(lpfsi);
00107     }
00108 //
00109 //   FUNCTION:CImpIFileViewer::Show
00110 //
00111 //   PURPOSE:    Displays the FileViewer's window in which the file is
00112 //  displayed.  This function cannot be called unless
00113 //  Initialize has already been called.  If Initialize has
00114 //  been called then this function is not allowed to fail and
00115 //  should do little more than show the window and enter a
00116 //  message loop, that is, perform no allocations or anything
00117 //  else that may fail due to low-memory conditions.
00118 //
00119 //  Treat this function like a WinMain function.
00120 //
00121 //   PARAMETERS:
00122 //      nCmdShow        int indicating how to initially show the FileViewer window.
00123 //
00124 //   RETURN VALUE:
00125 //      HRESULT         E_UNEXPECTED if Initalize has not been called, otherwise must be NOERROR.
00126 //
00127 STDMETHODIMP CImpIFileViewer::Show(LPFVSHOWINFO pvsi)
00128     {
00129     if (!m_pObj->m_fShowInit)
00130         return ResultFromScode(E_UNEXPECTED);
00131
00132     m_pObj->FileShow(pvsi);
00133     return NOERROR;
00134     }
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_IPSAMPLE_GLOBAL_CONFIG Member List

This is the complete list of members for _IPSAMPLE_GLOBAL_CONFIG, including all inherited members.
dwLoggingLevel _IPSAMPLE_GLOBAL_CONFIG
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Field15 Member List

This is the complete list of members for msado15::Field15, including all inherited members.
AppendChunk(Variant Data) | msado15::Field15 |
getActualSize() | msado15::Field15 |
getAttributes() | msado15::Field15 |
GetChunk(int Length) | msado15::Field15 |
getDefinedSize() | msado15::Field15 |
getName() | msado15::Field15 |
getNumericScale() | msado15::Field15 |
getOriginalValue() | msado15::Field15 |
getPrecision() | msado15::Field15 |
getProperties() | msado15::Field15 |
getType() | msado15::Field15 |
getUnderlyingValue() | msado15::Field15 |
getValue() | msado15::Field15 |
iid | msado15::Field15 | [static]
setValue(Variant pvar) | msado15::Field15 |
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CUserSub Member List

This is the complete list of members for CUserSub, including all inherited members.
CSysLCESub() | CSysLCESub | [inline]
CUserSub(CComSpy *pSpy) | CUserSub | [inline]
CUserSub() | CUserSub | [inline]
GetEventClass(LPGUID guid) | CUserSub | [inline, virtual]
GetEventType(EventEnum *e) | CUserSub | [inline, virtual]
GetInterface(IID *iid) | CUserSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnUserEvent(COMSVCSEVENTINFO *pInfo, VARIANT *var) | CUserSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:57:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCNotify/Notify.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCNotify

Notify.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Notify.cpp
00003   Summary:   Implementation of CONotify class
00004   Classes:   Implemented: CONotify
00005        Used: ADO  CLSID_ADOConnection
00006        Used: COM+ ObjectContext
00007   Methods:   put_CustomerId
00008        put_OrderId
00009        LineItem
00010        ProcessOrder
00011   Origin:    Implementation of case study in Queued Components specification
00012 ----------------------------------------------------------------------------
00013   Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00014
00015     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00016     ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00017     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018     PARTICULAR PURPOSE
00019 ==========================================================================+*/
00020
00021 #include "stdafx.h"
00022 #include "..\DataSourceNames.h" // ADO Data Source Names, userid, password
00023 #include <adoid.h>    // ADO from OLEDBSDK
00024 #include <adoint.h>   // ADO from OLEDBSDK
00025 #include "QCNotify.h" // MIDL output from QCNotify.idl
00026 #include "Notify.h"   // Class header
00027 #include "..\QCOrder\processFlags.h"  // process flag descriptions
00028
00029 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00030   Method:   CONotify::put_CustomerId
00031   Summary:  property put for CustomerId property
00032   Args:     long lCustomerId      A customer identifier.
00033   Modifies: class member variable m_lCustomerId
00034   Returns:  HRESULT - Always returns S_OK
00035 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00036
00037 STDMETHODIMP CONotify::put_CustomerId(long lCustomerId)
00038 {
00039   m_lCustomerId = lCustomerId;
00040   return S_OK;
00041 }
00042
00043 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00044   Method:   CONotify::put_OrderId
00045   Summary:  property put for OrderId property
00046   Args:     long lOrderId     An order identifier.
00047   Modifies: class member variable m_lOrderId
00048   Returns:  HRESULT - Always returns S_OK
00049 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00050
00051 STDMETHODIMP CONotify::put_OrderId(long lOrderId)
00052 {
00053   m_lOrderId = lOrderId;
00054   return S_OK;
00055 }
00056
00057 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00058   Method:   CONotify::LineItem
00059   Summary:  Adds a single item to an order
00060   Args:     long lItemId      An item identifier (e.g. stock number)
00061       long lQuantity      Quantity of the item ordered
00062       ShipStatus shipStatus Shipping Status (see QCSamp2.idl)
00063   Modifies: class members m_veclItemId, m_veclQuantity, m_vecShipStatus
00064   Returns:  HRESULT - Always returns S_OK
00065 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00066
00067 STDMETHODIMP CONotify::LineItem(long lItemId, long lQuantity, ShipStatus shipStatus)
00068 {
00069   _ASSERTE(shipStatus >= ssShipped && shipStatus <= ssUnrecognizedItem);
00070
00071   m_veclItemId.push_back(lItemId);
00072   m_veclQuantity.push_back(lQuantity);
00073   m_vecShipStatus.push_back(shipStatus);
00074   return S_OK;
00075 }
00076
00077 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00078   Method:   CONotify::Process
00079   Summary:  Updates order entry database with shipping status strings.
00080   Args:     long  lFlags - option flag bits
00081   Modifies: Rows in order entry database (DSN = QCSampOrder)
00082       Issues COM+ SetComplete or SetAbort depending on request success.
00083   Returns:  HRESULT - returns failure from embedded function requests or S_OK.
00084 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00085
00086 STDMETHODIMP CONotify::Process(long lFlags)
00087 {
00088   HRESULT hr = S_OK;
00089
00090   _RPT1(_CRT_WARN, "QCSamp2 %d Notify\n", m_lOrderId);
00091
00092   if (lFlags & processFlagWriteDB)
00093   {
00094     CComPtr<ADOConnection> pADOConnection;
00095
00096     hr = CoCreateInstance(  CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,
00097                 IID_IADOConnection, (void **) &pADOConnection);
00098     if (SUCCEEDED(hr))
00099     {
00100       // Constants for Data Source Names, userid, password are in DataSourceName.h
00101
00102       hr = pADOConnection->Open(  _bstr_t(pszOrderDSN), _bstr_t(pszUserId),
00103                     _bstr_t(pszPassword), adOpenUnspecified);
00104
00105       TCHAR szSQLStmt[512];
00106
00107       // The elements in this array correspond to the ShipStatus enumeration
00108       LPCTSTR const apszShipStatus[] =
00109       {
00110         _T("Not yet processed"),
00111         _T("Shipped"),
00112         _T("Back Ordered"),
00113         _T("Not Stocked"),
00114         _T("Unrecognized Item ID")
00115       };
00116
00117       LPCTSTR const pszPrototypeSQLStmt =
00118         _T("update QCSampleOrder set ship_status = \'%s\' ")
00119         _T(" where order_id = %ld ")
00120         _T("   and cust_id  = %ld ")
00121         _T("   and line_no  = %ld ")
00122         _T("   and item_id  = %ld ")
00123         _T("   and quantity = %ld ");
00124
00125       for (int ix = 0; ix < m_veclItemId.size() && SUCCEEDED(hr); ix++)
00126       {
00127         wsprintf( szSQLStmt,
00128               pszPrototypeSQLStmt,
00129               apszShipStatus[m_vecShipStatus[ix]],
00130               m_lOrderId,
00131               m_lCustomerId,
00132               ix,
00133               m_veclItemId[ix],
00134               m_veclQuantity[ix]);
00135
00136         hr = pADOConnection->Execute(_bstr_t(szSQLStmt), NULL, adCmdText, NULL);
00137       }
00138     }
00139   }
00140   // Invoke SetComplete or SetAbort depending on our success
00141
00142   CComPtr<IObjectContext> pIObjectContext;
00143
00144   if (SUCCEEDED(CoGetObjectContext(IID_IObjectContext, (void**)&pIObjectContext)))
00145   {
00146     if (SUCCEEDED(hr))  pIObjectContext->SetComplete();
00147     else        pIObjectContext->SetAbort();
00148   }
00149
00150   return hr;
00151 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/guids.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

guids.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Note that the GUIDs for CComponentData and CSnapinAbout are different
00014 //  from the ScopeNode project.  The Node GUIDs can stay the same since
00015 //  they are not really COM objects.
00016
00017
00018 #ifndef _PROPPAGE_PROJECT_GUIDS_
00019 #define _PROPPAGE_PROJECT_GUIDS_
00020
00021 // {f321bdf7-b850-427d-8062-5df89c1bb688}
00022 DEFINE_GUID( CLSID_CComponentData,
00023              0xf321bdf7, 0xb850, 0x427d, 0x80, 0x62, 0x5d, 0xf8, 0x9c, 0x1b, 0xb6, 0x88);
00024
00025 // {64de9ae8-f74b-48c5-9874-0308c1add5d7}
00026 DEFINE_GUID( CLSID_CSnapinAbout,
00027              0x64de9ae8, 0xf74b, 0x48c5, 0x98, 0x74, 0x03, 0x08, 0xc1, 0xad, 0xd5, 0xd7);
00028
00029 // {520F23F9-775D-4015-B437-98A24B9D085E}
00030 DEFINE_GUID( CLSID_DeviceNode,
00031              0x520F23f9, 0x775D, 0x4015, 0xB4, 0x37, 0x98, 0xA2, 0x4B, 0x9D, 0x8, 0x5E);
00032
00033 // {520F23FA-775D-4015-B437-98A24B9D085E}
00034 DEFINE_GUID( CLSID_CFolderNode,
00035              0x520F23fA, 0x775D, 0x4015, 0xb4, 0x37, 0x98, 0xA2, 0x4B, 0x9D, 0x8, 0x5E);
00036
00037 // {f0091c49-c869-4941-a81c-c719ad8174cc}
00038 DEFINE_GUID( CLSID_CVirtualFile,
00039              0xf0091c49, 0xc869, 0x4941, 0xa8, 0x1c, 0xc7, 0x19, 0xad, 0x81, 0x74, 0xcc);
00040
00041
00042
00043 #endif //_PROPPAGE_PROJECT_GUIDS_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Common/Stablize.Cxx Source File

  • Com
  • Fundamentals
  • Common

Stablize.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright 1992 - 2000 Microsoft Corporation.
00005 //
00006 //  File:       stablize.cxx
00007 //
00008 //  Contents:   Stabilization Classes used to stabilize objects during
00009 //              re-entrant calls.
00010 //
00011 //  Classes:    CSafeRefCount
00012 //              CStabilize
00013 //
00014 //  History:    8-26-94   stevebl   Modified from code written by AlexGo
00015 //
00016 //----------------------------------------------------------------------------
00017
00018 #include <windows.h>
00019 #include <ole2.h>
00020 #include <stablize.h>
00021 #include <assert.h>
00022
00023 //+-------------------------------------------------------------------------
00024 //
00025 //  Member:     CSafeRefCount::CSafeRefCount
00026 //
00027 //  Synopsis:   constructor for the safe ref count class
00028 //
00029 //  History:    dd-mmm-yy Author    Comment
00030 //              28-Jul-94 alexgo    author
00031 //              8-26-94   stevebl   modified for use by SDK samples
00032 //
00033 //--------------------------------------------------------------------------
00034
00035 CSafeRefCount::CSafeRefCount()
00036 {
00037         m_cRefs = 0;
00038         m_cNest = 0;
00039         m_fInDelete = FALSE;
00040 }
00041
00042 //+-------------------------------------------------------------------------
00043 //
00044 //  Member:     CSafeRefCount::~CSafeRefCount (virtual)
00045 //
00046 //  History:    dd-mmm-yy Author    Comment
00047 //              28-Jul-94 alexgo    author
00048 //              8-26-94   stevebl   modified for use by SDK samples
00049 //
00050 //--------------------------------------------------------------------------
00051
00052 CSafeRefCount::~CSafeRefCount()
00053 {
00054         assert(m_cRefs == 0 && m_cNest == 0 && m_fInDelete == TRUE);
00055 }
00056
00057 //+-------------------------------------------------------------------------
00058 //
00059 //  Member:     CSafeRefCount::SafeAddRef
00060 //
00061 //  Synopsis:   increments the reference count on the object
00062 //
00063 //  Returns:    ULONG -- the reference count after the increment
00064 //
00065 //  History:    dd-mmm-yy Author    Comment
00066 //              28-Jul-94 alexgo    author
00067 //              8-26-94   stevebl   modified for use by SDK samples
00068 //
00069 //--------------------------------------------------------------------------
00070
00071 ULONG CSafeRefCount::SafeAddRef()
00072 {
00073         m_cRefs++;
00074         return m_cRefs;
00075 }
00076
00077 //+-------------------------------------------------------------------------
00078 //
00079 //  Member:     CSafeRefCount::SafeRelease
00080 //
00081 //  Synopsis:   decrements the reference count on the object
00082 //
00083 //  Effects:    May delete the object!
00084 //
00085 //  Returns:    ULONG -- the reference count after decrement
00086 //
00087 //  Algorithm:  decrements the reference count.  If the reference count
00088 //              is zero AND the nest count is zero AND we are not currently
00089 //              trying to delete our object, then it is safe to delete.
00090 //
00091 //  History:    dd-mmm-yy Author    Comment
00092 //              28-Jul-94 alexgo    author
00093 //              8-26-94   stevebl   modified for use by SDK samples
00094 //
00095 //--------------------------------------------------------------------------
00096
00097 ULONG CSafeRefCount::SafeRelease()
00098 {
00099         ULONG   cRefs;
00100
00101         if( m_cRefs > 0 )
00102         {
00103                 cRefs = --m_cRefs;
00104
00105                 if( m_cRefs == 0 && m_cNest == 0 && m_fInDelete == FALSE )
00106                 {
00107                         m_fInDelete = TRUE;
00108                         delete this;
00109                 }
00110         }
00111         else
00112         {
00113                 // somebody is releasing a non-addrefed pointer!!
00114                 assert(NULL == "Release called on a non-addref'ed pointer!\n");
00115                 cRefs = 0;
00116         }
00117         return cRefs;
00118 }
00119
00120 //+-------------------------------------------------------------------------
00121 //
00122 //  Member:     CSafeRefCount::IncrementNestCount
00123 //
00124 //  Synopsis:   increments the nesting count of the object
00125 //
00126 //  Arguments:  none
00127 //
00128 //  Returns:    ULONG; the nesting count after increment
00129 //
00130 //  History:    dd-mmm-yy Author    Comment
00131 //              28-Jul-94 alexgo    author
00132 //              8-26-94   stevebl   modified for use by SDK samples
00133 //
00134 //  Notes:      The nesting count is the count of how many times an
00135 //              an object has been re-entered.  For example, suppose
00136 //              somebody calls pFoo->Bar1(), which makes some calls that
00137 //              eventually call pFoo->Bar2();.  On entrace to Bar2, the
00138 //              nest count of the object should be 2 (since the invocation
00139 //              of Bar1 is still on the stack above us).
00140 //
00141 //              It is important to keep track of the nest count so we do
00142 //              not accidentally delete ourselves during a nested invocation.
00143 //              If we did, then when the stack unwinds to the original
00144 //              top level call, it could try to access a non-existent member
00145 //              variable and crash.
00146 //
00147 //--------------------------------------------------------------------------
00148
00149 ULONG CSafeRefCount::IncrementNestCount()
00150 {
00151         m_cNest++;
00152         return m_cNest;
00153 }
00154
00155 //+-------------------------------------------------------------------------
00156 //
00157 //  Member:     CSafeRefCount::DecrementNestCount
00158 //
00159 //  Synopsis:   decrements the nesting count and deletes the object
00160 //              (if necessary)
00161 //
00162 //  Effects:    may delete 'this' object!
00163 //
00164 //  Arguments:  none
00165 //
00166 //  Returns:    ULONG, the nesting count after decrement
00167 //
00168 //  Algorithm:  decrements the nesting count.  If the nesting count is zero
00169 //              AND the reference count is zero AND we are not currently
00170 //              trying to delete ourselves, then delete 'this' object
00171 //
00172 //  History:    dd-mmm-yy Author    Comment
00173 //              28-Jul-94 alexgo    author
00174 //              8-26-94   stevebl   modified for use by SDK samples
00175 //
00176 //  Notes:
00177 //
00178 //--------------------------------------------------------------------------
00179
00180 ULONG CSafeRefCount::DecrementNestCount()
00181 {
00182         ULONG   cNest;
00183
00184         if( m_cNest > 0 )
00185         {
00186                 cNest = --m_cNest;
00187
00188                 if( m_cRefs == 0 && m_cNest == 0 && m_fInDelete == FALSE )
00189                 {
00190                         m_fInDelete = TRUE;
00191                         delete this;
00192                 }
00193         }
00194         else
00195         {
00196                 // somebody forget to increment the nest count!!
00197                 assert(NULL == "Unbalanced nest count!!");
00198                 cNest = 0;
00199         }
00200         return cNest;
00201 }
00202
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/resource.h Source File

  • SysMgmt
  • MMC
  • Multisel

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Resource.rc
00004 //
00005 #define IDS_HELPFILE                    1
00006 #define IDS_SNAPINDESC                  2
00007 #define IDS_NAME                        3
00008 #define IDS_SNAPINNAME                  6
00009 #define IDS_ABOUTNAME                   9
00010 #define IDI_ICON1                       108
00011 #define IDB_SMOPEN                      111
00012 #define IDB_SMBMP                       112
00013 #define IDB_LGBMP                       113
00014 #define IDR_SMICONS                     120
00015 #define IDR_LGICONS                     121
00016 #define IDB_ROCKET                      40004
00017 #define IDB_CAR                         40005
00018 #define IDB_PLANE                       40006
00019 #define IDB_BIKE                        40007
00020 #define IDB_ROCKET2                     40008
00021 #define IDB_CAR2                        40009
00022 #define IDB_PLANE2                      40010
00023 #define IDB_BIKE2                       40011
00024 #define IDB_CLOSED2                     40012
00025 #define IDB_OPEN2                       40013
00026 #define IDB_CLOSED                      40014
00027 #define IDB_OPEN                        40015
00028
00029 // Next default values for new objects
00030 //
00031 #ifdef APSTUDIO_INVOKED
00032 #ifndef APSTUDIO_READONLY_SYMBOLS
00033 #define _APS_NEXT_RESOURCE_VALUE        114
00034 #define _APS_NEXT_COMMAND_VALUE         40016
00035 #define _APS_NEXT_CONTROL_VALUE         1000
00036 #define _APS_NEXT_SYMED_VALUE           101
00037 #endif
00038 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/resource.h Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by AdvClient.rc
00004 //
00005 #define IDM_ABOUTBOX                    0x0010
00006 #define IDD_ABOUTBOX                    100
00007 #define IDS_ABOUTBOX                    101
00008 #define IDD_WBEMSAMP_DIALOG             102
00009 #define IDD_WBEMSAMPLE_DIALOG           102
00010 #define IDD_SAMPLE_DIALOG               102
00011 #define IDR_MAINFRAME                   128
00012 #define IDD_OFFICEEQUIP                 129
00013 #define IDD_USERINFO                    130
00014 #define IDC_ENUMDISKS                   1000
00015 #define IDC_ADDEQUIPMENT                1001
00016 #define IDC_ENUMSERVICES                1002
00017 #define IDC_ADDUSER                     1003
00018 #define IDC_CONNECT                     1004
00019 #define IDC_NAMESPACE                   1005
00020 #define IDC_OUTPUTLIST                  1006
00021 #define IDC_ENUMSERVICESASYNC           1007
00022 #define IDC_DISKDETAILS                 1008
00023 #define IDC_ITEM                        1009
00024 #define IDC_REGTEMP                     1009
00025 #define IDC_ACCTNAME                    1010
00026 #define IDC_REGPERM                     1010
00027 #define IDC_DOMAIN                      1011
00028 #define IDC_EVENTLIST                   1011
00029 #define IDC_SKU                         1012
00030 #define IDC_DISK_PROPS_DESCRIPTIONS     1013
00031
00032 // Next default values for new objects
00033 //
00034 #ifdef APSTUDIO_INVOKED
00035 #ifndef APSTUDIO_READONLY_SYMBOLS
00036 #define _APS_NEXT_RESOURCE_VALUE        131
00037 #define _APS_NEXT_COMMAND_VALUE         32771
00038 #define _APS_NEXT_CONTROL_VALUE         1014
00039 #define _APS_NEXT_SYMED_VALUE           101
00040 #endif
00041 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/property.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

property.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module PROPERTY.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 ////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 ////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 ///////////////////////////////////////////////////////////////
00019 // TPropBase
00020 //
00021 ///////////////////////////////////////////////////////////////
00022 template <class TYPE> TPropBase<TYPE>::TPropBase(ULONG cElements, TYPE* rgElements)
00023 {
00024   if(cElements)
00025     Attach(cElements, rgElements);
00026 }
00027
00028 ///////////////////////////////////////////////////////////////
00029 // ~TPropBase
00030 //
00031 ///////////////////////////////////////////////////////////////
00032 template <class TYPE> TPropBase<TYPE>::~TPropBase()
00033 {
00034   RemoveAll();
00035 }
00036
00037
00038 ///////////////////////////////////////////////////////////////
00039 // TPropBase::AddProperty
00040 //
00041 ///////////////////////////////////////////////////////////////
00042 template <class TYPE> TYPE* TPropBase<TYPE>::AddProperty(DBPROPID dwPropertyID, const DBID& colid)
00043 {
00044   //See if the property exists...
00045   TYPE* pProp = FindProperty(dwPropertyID, colid);
00046   if(!pProp)
00047   {
00048     TYPE dbProp;
00049     memset(&dbProp, 0, sizeof(TYPE));
00050
00051     //Add this property...
00052     pProp = AddElement(dbProp);
00053   }
00054
00055   return pProp;
00056 }
00057
00058
00059 ///////////////////////////////////////////////////////////////
00060 // CProperties
00061 //
00062 ///////////////////////////////////////////////////////////////
00063 CProperties::CProperties(DBPROPSET* pPropSet)
00064 {
00065   Attach(pPropSet);
00066 }
00067
00068 ///////////////////////////////////////////////////////////////
00069 // ~CProperties
00070 //
00071 ///////////////////////////////////////////////////////////////
00072 CProperties::~CProperties()
00073 {
00074 }
00075
00076
00077 ///////////////////////////////////////////////////////////////
00078 // CProperties::Attach
00079 //
00080 ///////////////////////////////////////////////////////////////
00081 void CProperties::Attach(DBPROPSET* pPropSet)
00082 {
00083   //Delegate
00084   if(pPropSet)
00085     CVector<DBPROP>::Attach(pPropSet->cProperties, pPropSet->rgProperties);
00086 }
00087
00088 ///////////////////////////////////////////////////////////////
00089 // CProperties::Detach
00090 //
00091 ///////////////////////////////////////////////////////////////
00092 void CProperties::Detach(DBPROPSET* pPropSet)
00093 {
00094   //Delegate
00095   CVector<DBPROP>::Detach(&pPropSet->cProperties, &pPropSet->rgProperties);
00096 }
00097
00098
00099 ///////////////////////////////////////////////////////////////
00100 // CProperties::RemoveAll
00101 //
00102 ///////////////////////////////////////////////////////////////
00103 void CProperties::RemoveAll()
00104 {
00105   //We need to walk and free out-of-line data...
00106   for(ULONG iProp=0; iProp<m_cElements; iProp++)
00107     VariantClearFast(&m_rgElements[iProp].vValue);
00108
00109   //Delegate
00110   CVector<DBPROP>::RemoveAll();
00111 }
00112
00113
00114 ///////////////////////////////////////////////////////////////
00115 // CProperties::FindProperty
00116 //
00117 ///////////////////////////////////////////////////////////////
00118 DBPROP* CProperties::FindProperty(DBPROPID dwPropertyID, const DBID& colid)
00119 {
00120   //Loop over the array of properties in this set
00121   for(ULONG iProp=0; iProp<m_cElements; iProp++)
00122   {
00123     DBPROP* pProp = &m_rgElements[iProp];
00124     if(pProp->dwPropertyID == dwPropertyID && DBIDEqual(&pProp->colid, &colid))
00125       return pProp;
00126   }
00127
00128   return NULL;
00129 }
00130
00131
00132 ///////////////////////////////////////////////////////////////
00133 // CProperties::SetProperty
00134 //
00135 ///////////////////////////////////////////////////////////////
00136 HRESULT CProperties::SetProperty(DBPROPID dwPropertyID, DBTYPE wType, void* pv, DBPROPOPTIONS dwOptions, const DBID& colid)
00137 {
00138   HRESULT hr = S_OK;
00139
00140   //Add this property (if it doesn't already exist)
00141   DBPROP* pProp = AddProperty(dwPropertyID, colid);
00142   if(!pProp)
00143     TESTC(hr = E_OUTOFMEMORY);
00144
00145   //Free any previous value
00146   VariantClearFast(&pProp->vValue);
00147   DBIDFree(&pProp->colid);
00148
00149   //Setup the new property
00150   pProp->dwPropertyID = dwPropertyID;
00151   pProp->dwOptions    = dwOptions;
00152   pProp->dwStatus     = DBPROPSTATUS_OK;
00153
00154   //Copy the colid
00155   DBIDCopy(&pProp->colid, &colid);
00156
00157   //Copy the Value
00158   pProp->vValue.vt    = wType;
00159   switch(wType)
00160   {
00161     case DBTYPE_BOOL:
00162       V_BOOL(&pProp->vValue)    = (VARIANT_BOOL)pv;
00163       break;
00164
00165     case DBTYPE_I2:
00166       V_I2(&pProp->vValue)    = (SHORT)(ULONG_PTR)(pv);
00167       break;
00168
00169     case DBTYPE_I4:
00170       V_I4(&pProp->vValue)    = (LONG)(ULONG_PTR)(pv);
00171       break;
00172
00173 #ifdef _WIN64
00174     case DBTYPE_I8:
00175 //TODO64: V_I8(&pProp->vValue)    = (LONG_PTR)pv;
00176       pProp->vValue.ullVal    = (LONG_PTR)pv;
00177       break;
00178 #endif //_WIN64
00179
00180     case DBTYPE_WSTR:
00181     case DBTYPE_BSTR:
00182       V_BSTR(&pProp->vValue)    = SysAllocString((BSTR)pv);
00183       break;
00184
00185     case DBTYPE_VARIANT:
00186       XTEST(VariantCopyFast(&pProp->vValue, (VARIANT*)pv));
00187       break;
00188
00189     default:
00190       ASSERT(FALSE); //Unhandled property type
00191       TESTC(hr = E_INVALIDARG);
00192       break;
00193   }
00194
00195 CLEANUP:
00196   return hr;
00197 }
00198
00199
00200
00201 ///////////////////////////////////////////////////////////////
00202 // CPropertyInfos
00203 //
00204 ///////////////////////////////////////////////////////////////
00205 CPropertyInfos::CPropertyInfos(DBPROPINFOSET* pPropSet)
00206 {
00207   Attach(pPropSet);
00208 }
00209
00210 ///////////////////////////////////////////////////////////////
00211 // ~CPropertyInfos
00212 //
00213 ///////////////////////////////////////////////////////////////
00214 CPropertyInfos::~CPropertyInfos()
00215 {
00216 }
00217
00218
00219 ///////////////////////////////////////////////////////////////
00220 // CPropertyInfos::Attach
00221 //
00222 ///////////////////////////////////////////////////////////////
00223 void CPropertyInfos::Attach(DBPROPINFOSET* pPropSet)
00224 {
00225   //Delegate
00226   if(pPropSet)
00227     CVector<DBPROPINFO>::Attach(pPropSet->cPropertyInfos, pPropSet->rgPropertyInfos);
00228 }
00229
00230
00231 ///////////////////////////////////////////////////////////////
00232 // CPropertyInfos::Detach
00233 //
00234 ///////////////////////////////////////////////////////////////
00235 void CPropertyInfos::Detach(DBPROPINFOSET* pPropSet)
00236 {
00237   //Delegate
00238   CVector<DBPROPINFO>::Detach(&pPropSet->cPropertyInfos, &pPropSet->rgPropertyInfos);
00239 }
00240
00241
00242 ///////////////////////////////////////////////////////////////
00243 // CPropertyInfos::RemoveAll
00244 //
00245 ///////////////////////////////////////////////////////////////
00246 void CPropertyInfos::RemoveAll()
00247 {
00248   //We need to walk and free out-of-line data...
00249   for(ULONG iProp=0; iProp<m_cElements; iProp++)
00250     VariantClearFast(&m_rgElements[iProp].vValues);
00251
00252   //Delegate
00253   CVector<DBPROPINFO>::RemoveAll();
00254 }
00255
00256
00257 ///////////////////////////////////////////////////////////////
00258 // CPropertyInfos::FindProperty
00259 //
00260 ///////////////////////////////////////////////////////////////
00261 DBPROPINFO* CPropertyInfos::FindProperty(DBPROPID dwPropertyID, const DBID& colid)
00262 {
00263   //Loop over the array of properties in this set
00264   for(ULONG iPropInfo=0; iPropInfo<m_cElements; iPropInfo++)
00265   {
00266     DBPROPINFO* pPropInfo = &m_rgElements[iPropInfo];
00267     if(pPropInfo->dwPropertyID == dwPropertyID)
00268       return pPropInfo;
00269   }
00270
00271   return NULL;
00272 }
00273
00274
00275
00276
00277 ///////////////////////////////////////////////////////////////
00278 // CPropertyIDs
00279 //
00280 ///////////////////////////////////////////////////////////////
00281 CPropertyIDs::CPropertyIDs(DBPROPIDSET* pPropSet)
00282 {
00283   Attach(pPropSet);
00284 }
00285
00286 ///////////////////////////////////////////////////////////////
00287 // ~CPropertyIDs
00288 //
00289 ///////////////////////////////////////////////////////////////
00290 CPropertyIDs::~CPropertyIDs()
00291 {
00292 }
00293
00294
00295 ///////////////////////////////////////////////////////////////
00296 // CPropertyIDs::Attach
00297 //
00298 ///////////////////////////////////////////////////////////////
00299 void CPropertyIDs::Attach(DBPROPIDSET* pPropSet)
00300 {
00301   //Delegate
00302   if(pPropSet)
00303     CVector<DBPROPID>::Attach(pPropSet->cPropertyIDs, pPropSet->rgPropertyIDs);
00304 }
00305
00306
00307 ///////////////////////////////////////////////////////////////
00308 // CPropertyIDs::Detach
00309 //
00310 ///////////////////////////////////////////////////////////////
00311 void CPropertyIDs::Detach(DBPROPIDSET* pPropSet)
00312 {
00313   //Delegate
00314   CVector<DBPROPID>::Detach(&pPropSet->cPropertyIDs, &pPropSet->rgPropertyIDs);
00315 }
00316
00317
00318 ///////////////////////////////////////////////////////////////
00319 // CPropertyIDs::FindProperty
00320 //
00321 ///////////////////////////////////////////////////////////////
00322 DBPROPID* CPropertyIDs::FindProperty(DBPROPID dwPropertyID, const DBID& colid)
00323 {
00324   //Loop over the array of properties in this set
00325   for(ULONG iProp=0; iProp<m_cElements; iProp++)
00326   {
00327     DBPROPID* pPropID = &m_rgElements[iProp];
00328     if(*pPropID == dwPropertyID)
00329       return pPropID;
00330   }
00331
00332   return NULL;
00333 }
00334
00335
00336 ///////////////////////////////////////////////////////////////
00337 // CPropertyIDs::SetProperty
00338 //
00339 ///////////////////////////////////////////////////////////////
00340 HRESULT CPropertyIDs::SetProperty(DBPROPID dwPropertyID)
00341 {
00342   HRESULT hr = S_OK;
00343
00344   //Add this property (if it doesn't already exist)
00345   DBPROPID* pPropID = AddProperty(dwPropertyID, DB_NULLID);
00346   if(!pPropID)
00347     TESTC(hr = E_OUTOFMEMORY);
00348
00349   //Setup the value
00350   *pPropID = dwPropertyID;
00351
00352 CLEANUP:
00353   return hr;
00354 }
00355
00356
00357
00358
00359 ///////////////////////////////////////////////////////////////
00360 // TPropSetBase
00361 //
00362 ///////////////////////////////////////////////////////////////
00363 template <class TYPE, class OBJTYPE> TPropSetBase<TYPE, OBJTYPE>::TPropSetBase(ULONG cElements, TYPE* rgElements)
00364 {
00365   if(cElements)
00366     Attach(cElements, rgElements);
00367 }
00368
00369 ///////////////////////////////////////////////////////////////
00370 // ~TPropSetBase
00371 //
00372 ///////////////////////////////////////////////////////////////
00373 template <class TYPE, class OBJTYPE> TPropSetBase<TYPE, OBJTYPE>::~TPropSetBase()
00374 {
00375   RemoveAll();
00376 }
00377
00378
00379 ///////////////////////////////////////////////////////////////
00380 // TPropSetBase::RemoveAll
00381 //
00382 ///////////////////////////////////////////////////////////////
00383 template <class TYPE, class OBJTYPE> void TPropSetBase<TYPE, OBJTYPE>::RemoveAll()
00384 {
00385    //We need to walk and free out-of-line data...
00386 	::FreeProperties(&m_cElements, &m_rgElements);
00387
00388   //Delegate
00389   CVector<TYPE>::RemoveAll();
00390 }
00391
00392
00393 ///////////////////////////////////////////////////////////////
00394 // TPropSetBase::AddPropSet
00395 //
00396 ///////////////////////////////////////////////////////////////
00397 template <class TYPE, class OBJTYPE> TYPE* TPropSetBase<TYPE, OBJTYPE>::AddPropSet(REFGUID guidPropertySet)
00398 {
00399   //See if the property set already exists...
00400   TYPE* pPropSet = FindPropSet(guidPropertySet);
00401   if(!pPropSet)
00402   {
00403     TYPE dbPropSet;
00404     memset(&dbPropSet, 0, sizeof(TYPE));
00405     dbPropSet.guidPropertySet = guidPropertySet;
00406
00407     //Add this property set
00408     pPropSet = AddElement(dbPropSet);
00409   }
00410
00411   return pPropSet;
00412 }
00413
00414
00415 ///////////////////////////////////////////////////////////////
00416 // TPropSetBase::FindPropSet
00417 //
00418 ///////////////////////////////////////////////////////////////
00419 template <class TYPE, class OBJTYPE> TYPE* TPropSetBase<TYPE, OBJTYPE>::FindPropSet(REFGUID guidPropertySet)
00420 {
00421   //Loop over the number of property sets
00422   for(ULONG iPropSet=0; iPropSet<m_cElements; iPropSet++)
00423   {
00424     TYPE* pPropSet = &m_rgElements[iPropSet];
00425
00426     //Make sure where looking in the right property set
00427     if(guidPropertySet == pPropSet->guidPropertySet)
00428       return pPropSet;
00429   }
00430
00431   return NULL;
00432 }
00433
00434
00435 ///////////////////////////////////////////////////////////////
00436 // CPropSets
00437 //
00438 ///////////////////////////////////////////////////////////////
00439 CPropSets::CPropSets(ULONG cPropSets, DBPROPSET* rgPropSets)
00440   : TPropSetBase<DBPROPSET, CProperties>(cPropSets, rgPropSets)
00441 {
00442 }
00443
00444 ///////////////////////////////////////////////////////////////
00445 // ~CPropSets
00446 //
00447 ///////////////////////////////////////////////////////////////
00448 CPropSets::~CPropSets()
00449 {
00450 }
00451
00452
00453 ///////////////////////////////////////////////////////////////
00454 // CPropSets::SetProperty
00455 //
00456 ///////////////////////////////////////////////////////////////
00457 HRESULT CPropSets::SetProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet, DBTYPE wType, void* pv, DBPROPOPTIONS dwOptions, const DBID& colid)
00458 {
00459   //Add this property set (if doesn't already exist)
00460   DBPROPSET* pPropSet = AddPropSet(guidPropertySet);
00461   if(!pPropSet)
00462     return E_OUTOFMEMORY;
00463
00464   //Delegate
00465   CProperties sCProperties(pPropSet);
00466   HRESULT hr = sCProperties.SetProperty(dwPropertyID, wType, pv, dwOptions, colid);
00467   sCProperties.Detach(pPropSet);
00468
00469   return hr;
00470 }
00471
00472
00473 ///////////////////////////////////////////////////////////////
00474 // CPropSets::FindProperty
00475 //
00476 ///////////////////////////////////////////////////////////////
00477 DBPROP* CPropSets::FindProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet, const DBID& colid)
00478 {
00479   //Find the property set...
00480   DBPROPSET* pPropSet = FindPropSet(guidPropertySet);
00481   if(pPropSet)
00482   {
00483     CProperties sCProperties(pPropSet);
00484     DBPROP* pProp = sCProperties.FindProperty(dwPropertyID, colid);
00485     sCProperties.Detach(pPropSet);
00486
00487     return pProp;
00488   }
00489
00490   return NULL;
00491 }
00492
00493
00494
00495
00496 ///////////////////////////////////////////////////////////////
00497 // CPropInfoSets
00498 //
00499 ///////////////////////////////////////////////////////////////
00500 CPropInfoSets::CPropInfoSets(ULONG cPropInfoSets, DBPROPINFOSET* rgPropInfoSets)
00501 : TPropSetBase<DBPROPINFOSET, CPropertyInfos>(cPropInfoSets, rgPropInfoSets)
00502 {
00503 }
00504
00505 ///////////////////////////////////////////////////////////////
00506 // ~CPropInfoSets
00507 //
00508 ///////////////////////////////////////////////////////////////
00509 CPropInfoSets::~CPropInfoSets()
00510 {
00511 }
00512
00513
00514 ///////////////////////////////////////////////////////////////
00515 // CPropInfoSets::FindProperty
00516 //
00517 ///////////////////////////////////////////////////////////////
00518 DBPROPINFO* CPropInfoSets::FindProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet)
00519 {
00520   //Find the property set...
00521   DBPROPINFOSET* pPropSet = FindPropSet(guidPropertySet);
00522   if(pPropSet)
00523   {
00524     CPropertyInfos sCProperties(pPropSet);
00525     DBPROPINFO* pProp = sCProperties.FindProperty(dwPropertyID, DB_NULLID);
00526     sCProperties.Detach(pPropSet);
00527
00528     return pProp;
00529   }
00530
00531   return NULL;
00532 }
00533
00534
00535
00536 ///////////////////////////////////////////////////////////////
00537 // CPropIDSets
00538 //
00539 ///////////////////////////////////////////////////////////////
00540 CPropIDSets::CPropIDSets(ULONG cPropIDSets, DBPROPIDSET* rgPropIDSets)
00541   : TPropSetBase<DBPROPIDSET, CPropertyIDs>(cPropIDSets, rgPropIDSets)
00542 {
00543 }
00544
00545 ///////////////////////////////////////////////////////////////
00546 // ~CPropIDSets
00547 //
00548 ///////////////////////////////////////////////////////////////
00549 CPropIDSets::~CPropIDSets()
00550 {
00551 }
00552
00553
00554 ///////////////////////////////////////////////////////////////
00555 // CPropIDSets::SetProperty
00556 //
00557 ///////////////////////////////////////////////////////////////
00558 HRESULT CPropIDSets::SetProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet)
00559 {
00560   //Add this property set (if doesn't already exist)
00561   DBPROPIDSET* pPropSet = AddPropSet(guidPropertySet);
00562   if(!pPropSet)
00563     return E_OUTOFMEMORY;
00564
00565   //Delegate
00566   CPropertyIDs sCProperties(pPropSet);
00567   HRESULT hr = sCProperties.SetProperty(dwPropertyID);
00568   sCProperties.Detach(pPropSet);
00569
00570   return hr;
00571 }
00572
00573
00574 ///////////////////////////////////////////////////////////////
00575 // CPropIDSets::FindProperty
00576 //
00577 ///////////////////////////////////////////////////////////////
00578 DBPROPID* CPropIDSets::FindProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet)
00579 {
00580   //Find the property set...
00581   DBPROPIDSET* pPropSet = FindPropSet(guidPropertySet);
00582   if(pPropSet)
00583   {
00584     CPropertyIDs sCProperties(pPropSet);
00585     DBPROPID* pProp = sCProperties.FindProperty(dwPropertyID, DB_NULLID);
00586     sCProperties.Detach(pPropSet);
00587
00588     return pProp;
00589   }
00590
00591   return NULL;
00592 }
00593
00594
00595 ////////////////////////////////////////////////////////////////////////////
00596 //  Find the Property Set within the PropInfoSets and return a pointer to it
00597 //
00598 ////////////////////////////////////////////////////////////////////////////
00599 DBPROPINFOSET* FindPropSet(REFGUID guidPropertySet, ULONG cPropInfoSets, DBPROPINFOSET* rgPropInfoSets)
00600 {
00601   //Loop over the property sets
00602   for(ULONG iPropSet=0; iPropSet<cPropInfoSets; iPropSet++)
00603   {
00604     DBPROPINFOSET* pPropInfoSet = &rgPropInfoSets[iPropSet];
00605
00606     //Make sure where looking in the right property set
00607     if(guidPropertySet == pPropInfoSet->guidPropertySet)
00608       return pPropInfoSet;
00609   }
00610
00611   return NULL;
00612 }
00613
00614
00615 ////////////////////////////////////////////////////////////////////////////
00616 //  Find the Property within the PropInfoSets and return a pointer to it
00617 //
00618 ////////////////////////////////////////////////////////////////////////////
00619 DBPROPINFO* FindProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet, ULONG cPropInfoSets, DBPROPINFOSET* rgPropInfoSets)
00620 {
00621   //Loop over the number of property sets
00622   for(ULONG iPropSet=0; iPropSet<cPropInfoSets; iPropSet++)
00623   {
00624     DBPROPINFOSET* pPropInfoSet = &rgPropInfoSets[iPropSet];
00625
00626     //Make sure where looking in the right property set
00627     if(guidPropertySet != pPropInfoSet->guidPropertySet)
00628       continue;
00629
00630     //Loop over the array of properties in this set
00631     for(ULONG iProp=0; iProp<pPropInfoSet->cPropertyInfos; iProp++)
00632     {
00633       DBPROPINFO* pPropInfo = &pPropInfoSet->rgPropertyInfos[iProp];
00634       if(pPropInfo->dwPropertyID == dwPropertyID)
00635         return pPropInfo;
00636     }
00637   }
00638
00639   return NULL;
00640 }
00641
00642
00643 ////////////////////////////////////////////////////////////////////////////
00644 //  CombineProperties
00645 //
00646 ////////////////////////////////////////////////////////////////////////////
00647 HRESULT CombineProperties(ULONG* pcPropInfoSets, DBPROPINFOSET** prgPropInfoSets, ULONG cPropInfoSets2, DBPROPINFOSET* rgPropInfoSets2, BOOL bFreeAddedPropSet)
00648 {
00649   ASSERT(pcPropInfoSets);
00650   ASSERT(prgPropInfoSets);
00651   HRESULT hr = S_OK;
00652
00653   //Make our lives a little easier...
00654   ULONG cPropInfoSets = *pcPropInfoSets;
00655   DBPROPINFOSET* rgPropInfoSets = *prgPropInfoSets;
00656
00657   //Now combine both sets...
00658   if(cPropInfoSets2 && rgPropInfoSets2)
00659   {
00660     if(cPropInfoSets && rgPropInfoSets)
00661     {
00662       //Loop over all the provider returned properties, and see if they
00663       //already exist in the OLE DB Defined properties.
00664       for(ULONG iPropSet=0; iPropSet<cPropInfoSets2; iPropSet++)
00665       {
00666         DBPROPINFOSET* pPropInfoSet2 = &rgPropInfoSets2[iPropSet];
00667         DBPROPINFOSET* pFoundSet = FindPropSet(pPropInfoSet2->guidPropertySet, cPropInfoSets, rgPropInfoSets);
00668
00669         if(pFoundSet)
00670         {
00671           //Add all properties of this set...
00672           for(ULONG iProp=0; iProp<pPropInfoSet2->cPropertyInfos; iProp++)
00673           {
00674             DBPROPINFO* pPropInfo2 = &pPropInfoSet2->rgPropertyInfos[iProp];
00675             DBPROPINFO* pFoundProp = FindProperty(pPropInfo2->dwPropertyID, pPropInfoSet2->guidPropertySet, 1, pFoundSet);
00676
00677             if(pFoundProp)
00678             {
00679               //Found the propertyset as well as the property
00680               //just need to update it in the list...
00681               *pFoundProp = *pPropInfo2;
00682             }
00683             else
00684             {
00685               //Found the property set, but not the property
00686               //just need to add this property to the list...
00687               SAFE_REALLOC(pFoundSet->rgPropertyInfos, DBPROPINFO, pFoundSet->cPropertyInfos + 1);
00688               pFoundSet->rgPropertyInfos[pFoundSet->cPropertyInfos] = *pPropInfo2;
00689               pFoundSet->cPropertyInfos++;
00690             }
00691
00692             //Do we need to make a copy of the variant...
00693             if(!bFreeAddedPropSet)
00694             {
00695               //TODO
00696               //Also what about the stringbuffer with property descriptions?
00697             }
00698           }
00699         }
00700         else
00701         {
00702           //Need to add the entire property set, as well as all the properties.
00703           SAFE_REALLOC(rgPropInfoSets, DBPROPINFOSET, cPropInfoSets + 1);
00704           rgPropInfoSets[cPropInfoSets].guidPropertySet = pPropInfoSet2->guidPropertySet;
00705           rgPropInfoSets[cPropInfoSets].cPropertyInfos  = pPropInfoSet2->cPropertyInfos;
00706
00707           //Add all the properties of this set...
00708           SAFE_ALLOC(rgPropInfoSets[cPropInfoSets].rgPropertyInfos, DBPROPINFO, pPropInfoSet2->cPropertyInfos);
00709           for(ULONG iProp=0; iProp<pPropInfoSet2->cPropertyInfos; iProp++)
00710           {
00711             rgPropInfoSets[cPropInfoSets].rgPropertyInfos[iProp] = pPropInfoSet2->rgPropertyInfos[iProp];
00712
00713             //Do we need to make a copy of the variant...
00714             if(!bFreeAddedPropSet)
00715             {
00716               //TODO
00717               //Also what about the stringbuffer with property descriptions?
00718             }
00719           }
00720           cPropInfoSets++;
00721         }
00722
00723         //We are done with this array of properties...
00724         if(bFreeAddedPropSet)
00725           SAFE_FREE(pPropInfoSet2->rgPropertyInfos);
00726       }
00727
00728       //NOTE: In the process of combining both of these sets, we are doing
00729       //direct memory copy of the internal DBPROPINFO items, this way
00730       //we don't need to variant copy all the values, and duplicate all the
00731       //strings.  But this also requires that we don't free the source of the
00732       //copies as well.  So we will finally end up freeing the combined
00733       //property sets (cPropInfoSets) but not (cPropInfoSets2)
00734       if(bFreeAddedPropSet)
00735         SAFE_FREE(rgPropInfoSets2);
00736     }
00737     else
00738     {
00739       cPropInfoSets = cPropInfoSets2;
00740       rgPropInfoSets = rgPropInfoSets2;
00741     }
00742   }
00743
00744 CLEANUP:
00745   *pcPropInfoSets = cPropInfoSets;
00746   *prgPropInfoSets = rgPropInfoSets;
00747   return hr;
00748 }
00749
00750
00751 ////////////////////////////////////////////////////////////////////////////
00752 //  CombineProperties
00753 //
00754 ////////////////////////////////////////////////////////////////////////////
00755 HRESULT CombineProperties(ULONG* pcPropInfoSets, DBPROPINFOSET** prgPropInfoSets, ULONG cPropSets2, DBPROPSET* rgPropSets2, BOOL bFreeAddedPropSet)
00756 {
00757   ASSERT(pcPropInfoSets);
00758   ASSERT(prgPropInfoSets);
00759   HRESULT hr = S_OK;
00760
00761   //Make our lives a little easier...
00762   ULONG cPropInfoSets = *pcPropInfoSets;
00763   DBPROPINFOSET* rgPropInfoSets = *prgPropInfoSets;
00764
00765   //Now combine both sets...
00766   if(cPropSets2 && rgPropSets2)
00767   {
00768     //Loop over all the provider returned properties, and see if they
00769     //already exist in the OLE DB Defined properties.
00770     for(ULONG iPropSet=0; iPropSet<cPropSets2; iPropSet++)
00771     {
00772       DBPROPSET* pPropSet2 = &rgPropSets2[iPropSet];
00773       DBPROPINFOSET* pFoundSet = FindPropSet(pPropSet2->guidPropertySet, cPropInfoSets, rgPropInfoSets);
00774
00775       if(pFoundSet)
00776       {
00777         //Add all properties of this set...
00778         for(ULONG iProp=0; iProp<pPropSet2->cProperties; iProp++)
00779         {
00780           DBPROP* pProp2 = &pPropSet2->rgProperties[iProp];
00781           DBPROPINFO* pFoundProp = FindProperty(pProp2->dwPropertyID, pPropSet2->guidPropertySet, 1, pFoundSet);
00782
00783           if(pFoundProp)
00784           {
00785             //Found the propertyset as well as the property
00786             //just need to update it in the list...
00787             pFoundProp->dwPropertyID  = pProp2->dwPropertyID;
00788             pFoundProp->vValues     = pProp2->vValue;
00789
00790             //Update the Type (if its meaningful...)
00791             if(pProp2->vValue.vt != VT_EMPTY)
00792               pFoundProp->vtType    = pProp2->vValue.vt;
00793
00794             //NOTE: WE store the dwOptions flag within the DBPROPFLAGS_REQUIRED
00795             ENABLE_BIT(pFoundProp->dwFlags, DBPROPFLAGS_REQUIRED, pProp2->dwOptions == DBPROPOPTIONS_REQUIRED);
00796           }
00797           else
00798           {
00799             //Found the property set, but not the property
00800             //just need to add this property to the list...
00801             SAFE_REALLOC(pFoundSet->rgPropertyInfos, DBPROPINFO, pFoundSet->cPropertyInfos + 1);
00802             memset(&pFoundSet->rgPropertyInfos[pFoundSet->cPropertyInfos], 0, sizeof(DBPROPINFO));
00803             pFoundSet->rgPropertyInfos[pFoundSet->cPropertyInfos].dwPropertyID  = pProp2->dwPropertyID;
00804             pFoundSet->rgPropertyInfos[pFoundSet->cPropertyInfos].vtType    = pProp2->vValue.vt;
00805             pFoundSet->rgPropertyInfos[pFoundSet->cPropertyInfos].vValues   = pProp2->vValue;
00806
00807             //NOTE: WE store the dwOptions flag within the DBPROPFLAGS_REQUIRED
00808             ENABLE_BIT(pFoundSet->rgPropertyInfos[pFoundSet->cPropertyInfos].dwFlags, DBPROPFLAGS_REQUIRED, pProp2->dwOptions == DBPROPOPTIONS_REQUIRED);
00809             pFoundSet->cPropertyInfos++;
00810           }
00811
00812           //Do we need to make a copy of the variant...
00813           if(!bFreeAddedPropSet)
00814           {
00815             //TODO
00816             //Also what about the stringbuffer with property descriptions?
00817           }
00818         }
00819       }
00820       else
00821       {
00822         //Need to add the entire property set, as well as all the properties.
00823         SAFE_REALLOC(rgPropInfoSets, DBPROPINFOSET, cPropInfoSets + 1);
00824         rgPropInfoSets[cPropInfoSets].guidPropertySet = pPropSet2->guidPropertySet;
00825         rgPropInfoSets[cPropInfoSets].cPropertyInfos  = pPropSet2->cProperties;
00826
00827         //Add all the properties of this set...
00828         SAFE_ALLOC(rgPropInfoSets[cPropInfoSets].rgPropertyInfos, DBPROPINFO, pPropSet2->cProperties);
00829         for(ULONG iProp=0; iProp<pPropSet2->cProperties; iProp++)
00830         {
00831           memset(&rgPropInfoSets[cPropInfoSets].rgPropertyInfos[iProp], 0, sizeof(DBPROPINFO));
00832           rgPropInfoSets[cPropInfoSets].rgPropertyInfos[iProp].dwPropertyID = pPropSet2->rgProperties[iProp].dwPropertyID;
00833           rgPropInfoSets[cPropInfoSets].rgPropertyInfos[iProp].vtType     = pPropSet2->rgProperties[iProp].vValue.vt;
00834           rgPropInfoSets[cPropInfoSets].rgPropertyInfos[iProp].vValues    = pPropSet2->rgProperties[iProp].vValue;
00835
00836           //NOTE: WE store the dwOptions flag within the DBPROPFLAGS_REQUIRED
00837           ENABLE_BIT(rgPropInfoSets[cPropInfoSets].rgPropertyInfos[iProp].dwFlags, DBPROPFLAGS_REQUIRED, pPropSet2->rgProperties[iProp].dwOptions == DBPROPOPTIONS_REQUIRED);
00838
00839           //Do we need to make a copy of the variant...
00840           if(!bFreeAddedPropSet)
00841           {
00842             //TODO
00843             //Also what about the stringbuffer with property descriptions?
00844           }
00845         }
00846         cPropInfoSets++;
00847       }
00848
00849       //We are done with this array of properties...
00850       if(bFreeAddedPropSet)
00851         SAFE_FREE(pPropSet2->rgProperties);
00852     }
00853
00854     //NOTE: In the process of combining both of these sets, we are doing
00855     //direct memory copy of the internal DBPROPINFO items, this way
00856     //we don't need to variant copy all the values, and duplicate all the
00857     //strings.  But this also requires that we don't free the source of the
00858     //copies as well.  So we will finally end up freeing the combined
00859     //property sets (cPropInfoSets) but not (cPropInfoSets2)
00860     if(bFreeAddedPropSet)
00861       SAFE_FREE(rgPropSets2);
00862   }
00863
00864 CLEANUP:
00865   *pcPropInfoSets = cPropInfoSets;
00866   *prgPropInfoSets = rgPropInfoSets;
00867   return hr;
00868 }
00869
00870
00871 /////////////////////////////////////////////////////////////////////////////
00872 // HRESULT GetProperty
00873 //
00874 // Get the property information from the data source or object.
00875 // propid specifies the property and propset specifies the property set to which
00876 // propid belongs. The datatype of the property is required for the correct
00877 // coercion of the data
00878 /////////////////////////////////////////////////////////////////////////////
00879 HRESULT GetProperty(REFIID riid, IUnknown* pIUnknown, DBPROPID dwPropertyID, REFGUID guidPropertySet, DBPROP** ppProperty)
00880 {
00881   ASSERT(ppProperty);
00882   *ppProperty = NULL;
00883
00884   HRESULT hr = S_OK;
00885
00886   //Invalid Arguments
00887   if(!pIUnknown)
00888     return E_INVALIDARG;
00889
00890   ULONG     cPropSets = 0;
00891   DBPROPSET*    rgPropSets = NULL;
00892   const ULONG   cPropertyIDSets = 1;
00893   DBPROPIDSET   rgPropertyIDSets[cPropertyIDSets];
00894
00895   //SetUp input DBPROPIDSET struct (all static)
00896   rgPropertyIDSets[0].cPropertyIDs = cPropertyIDSets;
00897   rgPropertyIDSets[0].rgPropertyIDs = &dwPropertyID;
00898   rgPropertyIDSets[0].guidPropertySet = guidPropertySet;
00899
00900   //Need to figure out which Interface was passed in
00901   //IDBInitialize, or ICommand, or IRowset, all three allow GetProperties
00902   if(riid == IID_IDBProperties)
00903   {
00904     //GetProperties, property might not be supported
00905     hr = ((IDBProperties*)pIUnknown)->GetProperties(cPropertyIDSets, rgPropertyIDSets, &cPropSets, &rgPropSets);
00906   }
00907   else if(riid == IID_ICommandProperties)
00908   {
00909     //GetProperties, property might not be supported
00910     hr = ((ICommandProperties*)pIUnknown)->GetProperties(cPropertyIDSets, rgPropertyIDSets, &cPropSets, &rgPropSets);
00911   }
00912   else if(riid == IID_IRowsetInfo)
00913   {
00914     //GetProperties, property might not be supported
00915     hr = ((IRowsetInfo*)pIUnknown)->GetProperties(cPropertyIDSets, rgPropertyIDSets, &cPropSets, &rgPropSets);
00916   }
00917
00918   //Check return result
00919   //Can be DB_S_ / DB_E_ERRORSOCCURRED if notsupported property...
00920   if(FAILED(hr) && hr != DB_E_ERRORSOCCURRED)
00921     TESTC(hr);
00922
00923   //Verify results
00924   ASSERTC(cPropSets==1 && rgPropSets!=NULL);
00925   ASSERTC(rgPropSets[0].cProperties==1 && rgPropSets[0].rgProperties!=NULL);
00926   ASSERTC(rgPropSets[0].rgProperties[0].dwPropertyID == dwPropertyID);
00927
00928   //Return the property to the user
00929   *ppProperty = rgPropSets[0].rgProperties;
00930
00931 CLEANUP:
00932   //Just Free the outer Struct,
00933   //since we return the inner Property for the user to free
00934   SAFE_FREE(rgPropSets);
00935   return hr;
00936 }
00937
00938 /////////////////////////////////////////////////////////////////////////////
00939 // HRESULT GetProperty
00940 //
00941 /////////////////////////////////////////////////////////////////////////////
00942 HRESULT GetProperty(REFIID riid, IUnknown* pIUnknown, DBPROPID dwPropertyID, REFGUID guidPropertySet, DBTYPE wType, void* pv)
00943 {
00944   ASSERT(pv);
00945   HRESULT hr = S_OK;
00946   DBPROP* pProp = NULL;
00947
00948   //Delegate
00949   hr = GetProperty(riid, pIUnknown, dwPropertyID, guidPropertySet, &pProp);
00950
00951   //Put the value in the users buffer...
00952   if(SUCCEEDED(hr) && pProp)
00953   {
00954     //If the types are not what the user expected to receive then
00955     //we have to fail since pValue is of type wType.
00956     if(wType != pProp->vValue.vt)
00957     {
00958       //Free the property (since were not returning it to the user...)
00959       XTEST(hr = VariantClearFast(&pProp->vValue));
00960       TESTC(hr = E_INVALIDARG);
00961     }
00962
00963     switch(wType)
00964     {
00965       case DBTYPE_BOOL:
00966         *(VARIANT_BOOL*)pv      = V_BOOL(&pProp->vValue);
00967         break;
00968
00969       case DBTYPE_I2:
00970         *(SHORT*)pv         = V_I2(&pProp->vValue);
00971         break;
00972
00973       case DBTYPE_I4:
00974         *(LONG*)pv          = V_I4(&pProp->vValue);
00975         break;
00976
00977   #ifdef _WIN64
00978       case DBTYPE_I8:
00979   //TODO64: *(LONG_PTR*)pv        = V_I8(&pProp->vValue);
00980         *(LONG_PTR*)pv        = pProp->vValue.ullVal;
00981         break;
00982   #endif //_WIN64
00983
00984       case DBTYPE_WSTR:
00985       case DBTYPE_BSTR:
00986         *(BSTR*)pv          = V_BSTR(&pProp->vValue);
00987         break;
00988
00989       case DBTYPE_VARIANT:
00990         *(VARIANT*)pv       = pProp->vValue;  //Assignment
00991         break;
00992
00993       default:
00994         ASSERT(FALSE); //Unhandled property type
00995         TESTC(hr = E_INVALIDARG);
00996         break;
00997     };
00998   }
00999
01000 CLEANUP:
01001   //NOTE: GetProperty returns a pointer to the DBPROP (rgProperties) which is allocated
01002   //and needs to be free'd.  But the actual value we passed directly to the user which
01003   //is required to free the value, but we need to the free the outer array
01004   SAFE_FREE(pProp);
01005   return hr;
01006 }
01007
01008
01009 /////////////////////////////////////////////////////////////////////////////
01010 // HRESULT GetPropInfo
01011 //
01012 /////////////////////////////////////////////////////////////////////////////
01013 HRESULT GetPropInfo(IDBProperties* pIDBProperties, DBPROPID dwPropertyID, REFGUID guidPropertySet, DBPROPINFO** ppPropInfo)
01014 {
01015   if(ppPropInfo)
01016     *ppPropInfo = NULL;
01017
01018   if(!pIDBProperties)
01019     return E_FAIL;
01020
01021   HRESULT hr = S_OK;
01022   const ULONG cPropIDSets = 1;
01023   DBPROPIDSET rgPropIDSets[cPropIDSets];
01024
01025   ULONG cPropInfoSets = 0;
01026   DBPROPINFOSET* rgPropInfoSets = NULL;
01027
01028   //Construct the DBPROPIDSET structure
01029   rgPropIDSets[0].cPropertyIDs = 1;
01030   rgPropIDSets[0].rgPropertyIDs = &dwPropertyID;
01031   rgPropIDSets[0].guidPropertySet = guidPropertySet;
01032
01033   //Don't display dialog if errors occurred.
01034   //Errors can occur if properties are not supported by the provider
01035   TESTC(hr = pIDBProperties->GetPropertyInfo(cPropIDSets,rgPropIDSets,&cPropInfoSets,&rgPropInfoSets,NULL));
01036
01037 CLEANUP:
01038   *ppPropInfo = rgPropInfoSets ? rgPropInfoSets[0].rgPropertyInfos  : NULL;
01039   SAFE_FREE(rgPropInfoSets);
01040   return hr;
01041 }
01042
01043
01044 /////////////////////////////////////////////////////////////////////////////
01045 // DBPROPFLAGS GetPropInfoFlags
01046 //
01047 /////////////////////////////////////////////////////////////////////////////
01048 DBPROPFLAGS GetPropInfoFlags(IDBProperties* pIDBProperties, DBPROPID dwPropertyID, REFGUID guidPropertySet)
01049 {
01050   if(!pIDBProperties)
01051     return 0;
01052
01053   DBPROPINFO* pPropInfo = NULL;
01054   DBPROPFLAGS dwFlags = DBPROPFLAGS_NOTSUPPORTED;
01055
01056   //GetPropInfo
01057   TESTC(GetPropInfo(pIDBProperties, dwPropertyID, guidPropertySet, &pPropInfo));
01058   if(pPropInfo)
01059   {
01060     dwFlags = pPropInfo->dwFlags;
01061
01062     //Free the variant, could contain a safearray or similar...
01063     XTEST(VariantClearFast(&pPropInfo->vValues));
01064   }
01065
01066 CLEANUP:
01067   SAFE_FREE(pPropInfo);
01068   return dwFlags;
01069 }
01070
01071
01072 /////////////////////////////////////////////////////////////////////////////
01073 // BOOL IsSupportedProperty
01074 //
01075 /////////////////////////////////////////////////////////////////////////////
01076 BOOL IsSupportedProperty(IDBProperties* pIDBProperties, DBPROPID dwPropertyID, REFGUID guidPropertySet)
01077 {
01078   return GetPropInfoFlags(pIDBProperties, dwPropertyID, guidPropertySet) != DBPROPFLAGS_NOTSUPPORTED;
01079 }
01080
01081
01082 /////////////////////////////////////////////////////////////////////////////
01083 // BOOL IsSettableProperty
01084 //
01085 /////////////////////////////////////////////////////////////////////////////
01086 BOOL IsSettableProperty(IDBProperties* pIDBProperties, DBPROPID dwPropertyID, REFGUID guidPropertySet)
01087 {
01088   return GetPropInfoFlags(pIDBProperties, dwPropertyID, guidPropertySet) & DBPROPFLAGS_WRITE;
01089 }
01090
01091
01092 /////////////////////////////////////////////////////////////////////////////
01093 // HRESULT SetProperty
01094 //
01095 /////////////////////////////////////////////////////////////////////////////
01096 HRESULT SetProperty(DBPROPID dwPropertyID, REFGUID guidPropertySet, ULONG* pcPropSets, DBPROPSET** prgPropSets, DBTYPE wType, void* pv, DBPROPOPTIONS dwOptions, const DBID& colid)
01097 {
01098   ASSERT(prgPropSets && pcPropSets);
01099
01100   //The simplest Approach is to just use our class...
01101   CPropSets sCPropSets(*pcPropSets, *prgPropSets);
01102
01103   //Delegate
01104   HRESULT hr = sCPropSets.SetProperty(dwPropertyID, guidPropertySet, wType, pv, dwOptions, colid);
01105
01106   //Return the properties to the user and remove from static class...
01107   sCPropSets.Detach(pcPropSets, prgPropSets);
01108   return hr;
01109 }
01110
01111
01112 /////////////////////////////////////////////////////////////////////////////
01113 // HRESULT FreeProperties
01114 //
01115 /////////////////////////////////////////////////////////////////////////////
01116 HRESULT FreeProperties(ULONG* pcProperties, DBPROP** prgProperties)
01117 {
01118   ASSERT(pcProperties);
01119   ASSERT(prgProperties);
01120   HRESULT hr = S_OK;
01121
01122   //no-op case
01123   if(*pcProperties==0 || *prgProperties==NULL)
01124     return S_OK;
01125
01126   //Free the inner variants first
01127   for(ULONG iProp=0; iProp<*pcProperties; iProp++)
01128   {
01129     DBPROP* pProp = &((*prgProperties)[iProp]);
01130     XTEST(hr = VariantClearFast(&pProp->vValue));
01131   }
01132
01133   //Now NULL the set
01134   *pcProperties = 0;
01135   SAFE_FREE(*prgProperties);
01136   return hr;
01137 }
01138
01139 /////////////////////////////////////////////////////////////////////////////
01140 // HRESULT FreeProperties
01141 //
01142 /////////////////////////////////////////////////////////////////////////////
01143 HRESULT FreeProperties(ULONG* pcPropSets, DBPROPSET** prgPropSets)
01144 {
01145   ASSERT(pcPropSets);
01146   ASSERT(prgPropSets);
01147   HRESULT hr = S_OK;
01148
01149   //Loop over all the property sets
01150   for(ULONG iPropSet=0; iPropSet<*pcPropSets; iPropSet++)
01151   {
01152     DBPROPSET* pPropSet = &((*prgPropSets)[iPropSet]);
01153     FreeProperties(&pPropSet->cProperties, &pPropSet->rgProperties);
01154   }
01155
01156   //Now NULL the outer set
01157   *pcPropSets = 0;
01158   SAFE_FREE(*prgPropSets);
01159   return hr;
01160 }
01161
01162
01163 /////////////////////////////////////////////////////////////////////////////
01164 // HRESULT FreeProperties
01165 //
01166 /////////////////////////////////////////////////////////////////////////////
01167 HRESULT FreeProperties(ULONG* pcPropIDSets, DBPROPIDSET** prgPropIDSets)
01168 {
01169   ASSERT(pcPropIDSets);
01170   ASSERT(prgPropIDSets);
01171   HRESULT hr = S_OK;
01172
01173   //Loop over all the property sets
01174   for(ULONG iPropIDSet=0; iPropIDSet<*pcPropIDSets; iPropIDSet++)
01175   {
01176     DBPROPIDSET* pPropIDSet = &((*prgPropIDSets)[iPropIDSet]);
01177     SAFE_FREE(pPropIDSet->rgPropertyIDs);
01178   }
01179
01180   //Now NULL the outer set
01181   *pcPropIDSets = 0;
01182   SAFE_FREE(*prgPropIDSets);
01183   return hr;
01184 }
01185
01186
01187 /////////////////////////////////////////////////////////////////////////////
01188 // HRESULT FreeProperties
01189 //
01190 /////////////////////////////////////////////////////////////////////////////
01191 HRESULT FreeProperties(ULONG* pcPropInfoSets, DBPROPINFOSET** prgPropInfoSets)
01192 {
01193   ASSERT(pcPropInfoSets);
01194   ASSERT(prgPropInfoSets);
01195   HRESULT hr = S_OK;
01196
01197   //Loop over all the property info sets
01198   for(ULONG iPropSet=0; iPropSet<*pcPropInfoSets; iPropSet++)
01199   {
01200     DBPROPINFOSET* pPropInfoSet = &((*prgPropInfoSets)[iPropSet]);
01201
01202     //Free the inner variants first
01203     for(ULONG iProp=0; iProp<pPropInfoSet->cPropertyInfos; iProp++)
01204     {
01205       DBPROPINFO* pPropInfo = &pPropInfoSet->rgPropertyInfos[iProp];
01206       XTEST(hr = VariantClearFast(&pPropInfo->vValues));
01207     }
01208
01209     //Now free the set
01210     SAFE_FREE(pPropInfoSet->rgPropertyInfos);
01211   }
01212
01213   //Now free the outer set
01214   *pcPropInfoSets = 0;
01215   SAFE_FREE((*prgPropInfoSets));
01216   return hr;
01217 }
01218
01219
01220
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/FullSvr/resource.h Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • FullSvr

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by FullSvr.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_FullSvr                     100
00007 #define IDR_FULLSERV                    101
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           102
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Pipes/LocalServer/server.cxx Source File

  • Com
  • Fundamentals
  • Pipes
  • LocalServer

server.cxx

Go to the documentation of this file.
00001 /* Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00002  *
00003  *
00004  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00005  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00006  * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00007 */
00008
00009 #include <windows.h>
00010 #include <winbase.h>
00011 #include <tchar.h>
00012 #include <conio.h>
00013 #include <iostream.h>
00014 #include "component.hxx"
00015
00016 DWORD g_dwRegisterClass;
00017 HANDLE g_hEvent;
00018
00019 const char *g_RegTable[][3] = {
00020     { "CLSID\\{84f2059a-d9ae-11d2-86a3-00c04f8ef940}",0, "PipeSample" },
00021     { "CLSID\\{84f2059a-d9ae-11d2-86a3-00c04f8ef940}\\LocalServer32",0,
00022       (const char*)-1}
00023     };
00024
00025
00026 STDAPI UnRegisterServer()
00027 {
00028     HRESULT hr = S_OK;
00029
00030     int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);
00031     for (int i=nEntries -1; i >=0; i--) {
00032         long err = RegDeleteKeyA(HKEY_CLASSES_ROOT, g_RegTable[i][0]);
00033         if ( ERROR_SUCCESS != err ) hr=S_FALSE;
00034     }
00035     return hr;
00036 }
00037
00038 STDAPI RegisterServer()
00039 {
00040     HRESULT hr = S_OK;
00041     HINSTANCE hInstance = 0;
00042     char szFileName[1000];
00043     GetModuleFileNameA(hInstance, szFileName, 1000);
00044
00045     int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);
00046     for (int i=0; SUCCEEDED(hr) && i < nEntries; i++) {
00047         const char *pszKeyName = g_RegTable[i][0];
00048         const char *pszValueName = g_RegTable[i][1];
00049         const char *pszValue = g_RegTable[i][2];
00050
00051         if (pszValue == (const char*)-1) pszValue = szFileName;
00052         HKEY hKey;
00053         long err = RegCreateKeyA(HKEY_CLASSES_ROOT, pszKeyName, &hKey);
00054         if ( ERROR_SUCCESS == err ) {
00055            err = RegSetValueExA(hKey, pszValueName, 0, REG_SZ, (const BYTE*)pszValue, (strlen(pszValue) + 1));
00056            RegCloseKey(hKey);
00057         }
00058         if ( ERROR_SUCCESS != err ) {
00059            UnRegisterServer();
00060            hr = E_FAIL;  // Need to be specific here
00061         }
00062      }
00063      return hr;
00064 }
00065
00066 /*************************************************************************
00067 * WinMain
00068 *
00069 * Program Entry point
00070 *************************************************************************/
00071
00072 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE nPrevInstance, LPSTR lpCmdLine, int nCmdShow)
00073 {
00074     HRESULT hr;
00075     MSG msg;
00076
00077     hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
00078     if (FAILED(hr))
00079        return hr;
00080
00081     // Creating a console...
00082
00083     //AllocConsole();
00084     //HANDLE hConsoleOutput;
00085     //hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
00086     //const TCHAR* lpBuffer1 = __TEXT("First Output for console \n");
00087     //const TCHAR* lpBuffer2 = __TEXT("Second Output for console \n");
00088
00089     //WriteConsole(hConsoleOutput, lpBuffer1, strlen(lpBuffer1), 0, NULL);
00090     //WriteConsole(hConsoleOutput, lpBuffer2, strlen(lpBuffer2), 0, NULL);
00091
00092     //FreeConsole();
00093
00094
00095     if ( 0 != strstr(lpCmdLine, "/RegServer") ||
00096          0 != strstr(lpCmdLine, "-RegServer")  ) {
00097        hr = RegisterServer();
00098        MessageBox(NULL, NULL, TEXT("PIPE SAMPLE SERVER REGISTERED"), MB_SETFOREGROUND);
00099        CoUninitialize();
00100        return 0;
00101     }
00102     else if ( 0 != strstr(lpCmdLine, "/UnRegServer") ||
00103               0 != strstr(lpCmdLine, "-UnRegServer")  ) {
00104             hr = UnRegisterServer();
00105             MessageBox(NULL, NULL, TEXT("PIPE SAMPLE SERVER UN-REGISTERED"), MB_SETFOREGROUND);
00106             CoUninitialize();
00107             return 0;
00108     }
00109
00110     CFactory* pCFactory = new CFactory();
00111
00112     hr=CoRegisterClassObject(CLSID_SimpleClass, pCFactory, CLSCTX_LOCAL_SERVER, REGCLS_SUSPENDED, &g_dwRegisterClass);
00113     hr=CoResumeClassObjects();
00114
00115     if (FAILED(hr)) {
00116        MessageBox(NULL, TEXT("Failed to register the class object with the SCM"), TEXT("ERROR"), MB_SETFOREGROUND);
00117     }
00118     else
00119     {
00120        while (GetMessage(&msg, NULL, 0, 0)) {
00121           DispatchMessage(&msg);
00122        }
00123        CoRevokeClassObject(g_dwRegisterClass);
00124     }
00125     delete pCFactory;
00126
00127     CoUninitialize();
00128     return 0;
00129 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Pipes/Pipec.c Source File

  • NetDS
  • RPC
  • Pipes

Pipec.c

Go to the documentation of this file.
00001 /*************************************************************************
00002                     Copyright Microsoft Corp. 1992 - 2000
00003                         Remote Machine pipe sample
00004
00005     FILE        :   pipec.c
00006
00007     USAGE       :   client  <local file> <new file> [options]
00008                         -s Scramble file
00009                         -u Unscramble the file
00010                         -n network_address
00011                         -p protocol_sequence
00012                         -e endpoint
00013                         -o options
00014
00015     PURPOSE     :   Client side of the RPC distributed application pipes.
00016
00017     COMMENTS    :   This program shows the client side an application that
00018                     transfers a file from the client to the server, using
00019                     pipes. When the file is received at the server it
00020                     "encodes" the data by incrementing all the characters,
00021                     and sends the "encoded" file back to the client.
00022
00023                     Since this program uses the implicit binding method,
00024                     some of the binding handling must be done at the client
00025                     side
00026 *************************************************************************/
00027 #include "pipe.h"                   // Generated by the MIDL compiler
00028 #include "common.h"                 // Common definitions
00029
00030 #define CLIENT_BUFFER_SIZE  500     // Can send or recieve 500 elements
00031
00032 // Client side global variables
00033 pipe_state  in_out_pipe_state;      // Pipe state on the client side
00034 _TUCHAR     pcClientBuffer[CLIENT_BUFFER_SIZE];  // Buffer used in PipeAlloc
00035
00036
00037 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00038 /*  Procedure   :   void Usage(_TUCHAR *)                               */
00039 /*  Desc        :   This procedure prints out an error message if the   */
00040 /*                  command line arguments are wrong                    */
00041 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00042 void Usage(_TUCHAR * pszProgramName)
00043 {
00044     _tprintf(TEXT("USAGE : %s <local_file> <new_file> [-option]\n"),
00045         pszProgramName);
00046     _tprintf(TEXT("Options : -s\tTo encode the file\n"));
00047     _tprintf(TEXT("          -u\tTo Decode the file\n"));
00048     _tprintf(TEXT("          -n\t<Network Address>\n"));
00049     _tprintf(TEXT("          -p\t<Protocol Sequence>\n"));
00050     _tprintf(TEXT("          -e\t<Endpoint>\n"));
00051     _tprintf(TEXT("          -o\t<Options>\n"));
00052     exit(EXECUTION_FAILED);
00053 }
00054
00055
00056 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00057 /*  Procedure   :   PipeAlloc                                           */
00058 /*  Desc        :   This procedure allocates a chunck of memory and     */
00059 /*                  returns a pointer to it.                            */
00060 /*                  In this sample the Alloc routine returns a pointer  */
00061 /*                  to the same global allocated memory every time.     */
00062 /*                  This can be done since after each Pull/Push, data   */
00063 /*                  is read/written to file.                            */
00064 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00065 void PipeAlloc(
00066     char            *pcStateInfo,       // The state structure
00067     unsigned long   nReqSize,           // Req. size of buffer in bytes
00068     _TUCHAR         **pcAllocatedBuffer,// Pointer to the allocated buffer
00069     unsigned long   *pnAllocatedSize)   // Size of allocated buf. in bytes
00070 {
00071     // Since the memory is already allocated, just return a pointer to it
00072     if(nReqSize > (CLIENT_BUFFER_SIZE * sizeof(_TUCHAR)))
00073     {
00074         *pnAllocatedSize = CLIENT_BUFFER_SIZE * sizeof(_TUCHAR);
00075     }
00076     else
00077     {
00078         *pnAllocatedSize = nReqSize;
00079     }
00080     *pcAllocatedBuffer = pcClientBuffer;
00081 }
00082
00083
00084 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00085 /*  Procedure   :   PipePull                                            */
00086 /*  Desc        :   This procedure is called by the stub when its ready */
00087 /*                  to send a chunck of the pipe to the server.         */
00088 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00089 void PipePull(
00090     char            *pcStateInfo,   // The state struct on client side
00091     _TUCHAR         *pcBuffer,      // Pointer to the buffer
00092     unsigned long   nMaxBufferSize, // Size of buffer in elements
00093     unsigned long   *pnSizeToSend)  // Number of elements put in buffer
00094 {
00095     // Declare a state variable
00096     pipe_state  *psState = (pipe_state *) pcStateInfo;
00097
00098     // Open the local file, if it is not already opened
00099     if(psState->hOld == NULL)
00100     {
00101         if(NULL == (psState->hOld =
00102             _tfopen(psState->pszOldName, TEXT("rt"))))
00103         {
00104             _tprintf(TEXT("Could not open the file %s\n"),
00105                 psState->pszOldName);
00106             exit(EXECUTION_FAILED);
00107         }
00108     }
00109
00110     // Read max_buffer_size into the buffer
00111     *pnSizeToSend = (ULONG) fread(
00112         pcBuffer,
00113         sizeof(_TUCHAR),
00114         nMaxBufferSize,
00115         psState->hOld);
00116
00117     if(*pnSizeToSend == 0)      // When end of the data is reached
00118     {                           // cleanup the application
00119         fclose(psState->hOld);
00120         psState->hOld = NULL;
00121     }
00122 }
00123
00124
00125 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00126 /*  Procedure   :   PipePush                                            */
00127 /*  Desc        :   This procedure is called by the stub when a chunck  */
00128 /*                  of data is received from the server.                */
00129 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00130 void PipePush(
00131     char            *nStateInfo,        // State structure on client side
00132     _TUCHAR         *pcBuffer,          // Ptr to the buffer with the data
00133     unsigned long   nNumberOfElements)  // Number of elements in the buffer
00134 {
00135     // Declare a state variable
00136     pipe_state  *psState = (pipe_state *) nStateInfo;
00137
00138     // Open the New file, if it is not already opened
00139     if(psState->hNew == NULL)
00140     {
00141         if(NULL == (psState->hNew =
00142             _tfopen(psState->pszNewName, TEXT("w"))))
00143         {
00144             _tprintf( TEXT("Unable to create the file %s\n"),
00145                     psState->pszNewName);
00146             exit(EXECUTION_FAILED);
00147         }
00148     }
00149
00150
00151     // When number of elements received is 0, this is the end of the pipe
00152     if(nNumberOfElements == 0)
00153     {
00154         // Clean up by closing the opened file
00155         fclose (psState->hNew);
00156         psState->hNew = NULL;
00157     }
00158     else
00159     {
00160         // Write the buffer to the file
00161         fwrite(pcBuffer, sizeof(_TUCHAR), nNumberOfElements, psState->hNew);
00162     }
00163 }
00164
00165
00166 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00167 /*  Client side main program                                            */
00168 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00169 int __cdecl main(int argc, char *argv[])
00170 {
00171     RPC_STATUS      nStatus;        // Status returned from RPC-calls
00172     CHAR_PIPE_TYPE  in_out_pipe;    // Pipe structure used for the pipe
00173     TCHAR
00174         *pszOldFileName,        // Name of the input file
00175         *pszNewFileName;        // Name of the output file
00176     unsigned long
00177         nAction = SCRAMBLE,     // Scramble / Unscramble file
00178         nIdx,                   // Counter in loops
00179         nNumArgs;               // The number of args from the command line
00180
00181     // These variables are used for the implicit binding
00182     _TUCHAR *pszUuid      = NULL;
00183     _TUCHAR *pszProtocolSequence= PROTOCOL_SEQUENCE;
00184     _TUCHAR *pszNetworkAddress  = NULL;
00185     _TUCHAR *pszEndpoint    = END_POINT;
00186     _TUCHAR *pszOptions     = NULL;
00187     _TUCHAR *pszStringBinding = NULL;
00188
00189
00190     // Get a common handle on the command line arguments for both
00191     // UNICODE and ASCII
00192 #ifdef _UNICODE
00193     LPWSTR  *szArglist= CommandLineToArgvW(GetCommandLine(), &nNumArgs);
00194     if (NULL == szArglist)
00195     {
00196         _tprintf(TEXT("SERVER.C : CommandLineToArgW failed"));
00197         exit(EXECUTION_FAILED);
00198     }
00199 #else
00200     char **szArglist  = argv;
00201     nNumArgs = argc;
00202 #endif
00203
00204     // Check to see that the call was correct
00205     if (nNumArgs < 3)
00206     {
00207         Usage(szArglist[0]);
00208     }
00209
00210     // Allow the user to override settings with commandline switches
00211     for (nIdx = 3; nIdx < nNumArgs; nIdx++)
00212     {
00213         if ((_tcscmp(szArglist[nIdx], TEXT("-n")) == 0) ||
00214             (_tcscmp(szArglist[nIdx], TEXT("-N")) == 0))
00215         {
00216             pszNetworkAddress = szArglist[++nIdx];
00217         }
00218         else if((_tcscmp(szArglist[nIdx], TEXT("-p")) == 0) ||
00219             (_tcscmp(szArglist[nIdx], TEXT("-P")) == 0))
00220         {
00221             pszProtocolSequence = szArglist[++nIdx];
00222         }
00223         else if((_tcscmp(szArglist[nIdx], TEXT("-e")) == 0) ||
00224                 (_tcscmp(szArglist[nIdx], TEXT("-e")) == 0))
00225         {
00226             pszEndpoint = szArglist[++nIdx];
00227         }
00228         else if((_tcscmp(szArglist[nIdx], TEXT("-o")) == 0) ||
00229                (_tcscmp(szArglist[nIdx], TEXT("-O")) == 0))
00230         {
00231             pszOptions = szArglist[++nIdx];
00232         }
00233         else if((_tcscmp(szArglist[nIdx], TEXT("-s")) == 0) ||
00234                 (_tcscmp(szArglist[nIdx], TEXT("-S")) == 0))
00235         {
00236             nAction = SCRAMBLE;
00237         }
00238         else if((_tcscmp(szArglist[nIdx], TEXT("-u")) == 0) ||
00239                 (_tcscmp(szArglist[nIdx], TEXT("-U")) == 0))
00240         {
00241             nAction = UNSCRAMBLE;
00242         }
00243         else
00244         {
00245             Usage(szArglist[0]);
00246         }
00247     }
00248
00249     // Allocate space for the filenames
00250     if(NULL == (pszOldFileName  = (TCHAR *) midl_user_allocate(
00251         sizeof(TCHAR) * (_tcsclen(szArglist[1]) + 1))))
00252     {
00253         _tprintf(TEXT("Memory allocation error\n"));
00254         exit(EXECUTION_FAILED);
00255     }
00256     if(NULL == (pszNewFileName  = (TCHAR *) midl_user_allocate(
00257         sizeof(TCHAR) * (_tcsclen(szArglist[2]) + 1))))
00258     {
00259         _tprintf(TEXT("Memory allocation error\n"));
00260         exit(EXECUTION_FAILED);
00261     }
00262
00263     // Initialize the state variables for the in pipe
00264     _tcscpy(pszOldFileName, szArglist[1]);
00265     _tcscpy(pszNewFileName, szArglist[2]);
00266
00267     // Since we are doing implicit binding, we need to initialize the
00268     // global varaible global_pipe_sample_handle from the client.
00269     // Use a function to concatenate the elements of the string
00270     // binding into the proper sequence
00271     nStatus = RpcStringBindingCompose(
00272         pszUuid,
00273         pszProtocolSequence,
00274         pszNetworkAddress,
00275         pszEndpoint,
00276         pszOptions,
00277         &pszStringBinding);
00278     EXIT_IF_FAIL(nStatus, "RpcStringBindingCompose");
00279
00280     // Set the binding handle that will be used to bind to the server
00281     nStatus = RpcBindingFromStringBinding(
00282         pszStringBinding,
00283         &global_pipe_sample_handle);        // The global handle
00284     EXIT_IF_FAIL(nStatus, "RpcBindingFromStringBinding");
00285
00286
00287     /* Initialize pipestructure */
00288     in_out_pipe_state.hOld = NULL;
00289     in_out_pipe_state.hNew = NULL;
00290     in_out_pipe_state.pszOldName = pszOldFileName;
00291     in_out_pipe_state.pszNewName = pszNewFileName;
00292
00293     in_out_pipe.state = (char *) &in_out_pipe_state;
00294     in_out_pipe.alloc = PipeAlloc;
00295     in_out_pipe.pull  = PipePull;
00296     in_out_pipe.push  = PipePush;
00297
00298     RpcTryExcept
00299     {
00300         // Call the remote procedure to send the file to remote machine
00301         _tprintf(TEXT("Calling the remote procedure ScrambleFile()\n"));
00302         ScrambleFile(nAction, &in_out_pipe);
00303         _tprintf(TEXT("Call to ScrambleFile() returned\n"));
00304     }
00305     RpcExcept(DO_EXCEPTION)
00306     {
00307         _tprintf(TEXT("Run-time exception %08X = %d in %s\n"),
00308                 RpcExceptionCode(), RpcExceptionCode(), TEXT(__FILE__));
00309         exit(EXECUTION_FAILED);
00310     }
00311     RpcEndExcept
00312
00313
00314     // Deallocate the memory used for the names in the state variable
00315     midl_user_free(pszOldFileName);
00316     midl_user_free(pszNewFileName);
00317
00318     // Deallocate the memory used for the ARGLIST if using UNICODE
00319 #ifdef _UNICODE
00320     if (NULL != szArglist)
00321         free(szArglist);
00322 #endif
00323
00324     // Shut down the server
00325     ShutDown();
00326
00327     return (EXECUTION_OK);
00328 }
00329
00330
00331 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00332 /* Procedure    :   midl_user_allocate() and midl_user_free()           */
00333 /* Desc.        :   These procedure are declared in the header file     */
00334 /*                  generated by the midl compiler. These procedures    */
00335 /*                  should be used for all memory allocation and        */
00336 /*                  deallocation.                                       */
00337 /*                  These procedures are also called by the stub code to*/
00338 /*                  allocate and free memory.                           */
00339 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00340 void __RPC_FAR * __RPC_API midl_user_allocate(size_t nLen)
00341 {
00342     return (malloc(nLen));
00343 }
00344
00345 void __RPC_API midl_user_free(void __RPC_FAR * lpvPointer)
00346 {
00347     if(NULL == lpvPointer)
00348     {
00349         free (lpvPointer);
00350     }
00351 }
00352
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagPOSTKEY Member List

This is the complete list of members for _tagPOSTKEY, including all inherited members.
bHasCtrlChars | _tagPOSTKEY
dwLength | _tagPOSTKEY
dwOffset | _tagPOSTKEY
lpbyBuf | _tagPOSTKEY
nInstance | _tagPOSTKEY
pHead | _tagPOSTKEY
pNext | _tagPOSTKEY
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagLINE Member List

This is the complete list of members for tagLINE, including all inherited members.
ptEnd | tagLINE
ptStart | tagLINE
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows2000/Exit.h Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows2000

Exit.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        exit.h
00007 //
00008 // Contents:    CCertExitSample definition
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "certxsam.h"
00013 #include "resource.h"       // main symbols
00014
00015 #define wszCLASS_CERTEXITSAMPLEPREFIX TEXT("CertAuthority_Sample")
00016
00017 #define wszCLASS_CERTEXITSAMPLE wszCLASS_CERTEXITSAMPLEPREFIX wszCERTEXITMODULE_POSTFIX
00018 #define wszCLASS_CERTMANAGESAMPLE wszCLASS_CERTEXITSAMPLEPREFIX wszCERTMANAGEEXIT_POSTFIX
00019
00020 #define wsz_SAMPLE_NAME           L"CertXSam.dll"
00021 #define wsz_SAMPLE_DESCRIPTION    L"Sample Exit Module"
00022 #define wsz_SAMPLE_COPYRIGHT      L"(c)1999-2000 Microsoft"
00023 #define wsz_SAMPLE_FILEVER        L"v 1.0"
00024 #define wsz_SAMPLE_PRODUCTVER     L"v 5.00"
00025
00026
00027 #define CRL_PUBLISH_RETRY_DEFAULT 10
00028
00029 HRESULT
00030 GetServerCallbackInterface(
00031     OUT ICertServerExit** ppServer,
00032     IN LONG Context);
00033
00034 /////////////////////////////////////////////////////////////////////////////
00035 // certexit
00036
00037 class CCertExitSample:
00038     public CComDualImpl<ICertExit, &IID_ICertExit, &LIBID_CERTEXITSAMPLELib>,
00039     public ISupportErrorInfo,
00040     public CComObjectRoot,
00041     public CComCoClass<CCertExitSample, &CLSID_CCertExitSample>
00042 {
00043 public:
00044     CCertExitSample()
00045     {
00046   m_bstrDescription = NULL;
00047         m_strCAName = NULL;
00048         m_wszRegStorageLoc = NULL;
00049         m_hExitKey = NULL;
00050         m_dwExitPublishFlags = 0;
00051         m_cCACert = 0;
00052         m_cCRLPublishRetryCount = CRL_PUBLISH_RETRY_DEFAULT;
00053
00054     }
00055     ~CCertExitSample();
00056
00057 BEGIN_COM_MAP(CCertExitSample)
00058     COM_INTERFACE_ENTRY(IDispatch)
00059     COM_INTERFACE_ENTRY(ICertExit)
00060     COM_INTERFACE_ENTRY(ISupportErrorInfo)
00061 END_COM_MAP()
00062
00063 DECLARE_NOT_AGGREGATABLE(CCertExitSample)
00064
00065 DECLARE_REGISTRY(
00066     CCertExitSample,
00067     wszCLASS_CERTEXITSAMPLE TEXT(".1"),
00068     wszCLASS_CERTEXITSAMPLE,
00069     IDS_CERTEXIT_DESC,
00070     THREADFLAGS_BOTH)
00071
00072     // ISupportsErrorInfo
00073     STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00074
00075     // ICertExit
00076 public:
00077     STDMETHOD(Initialize)(
00078             /* [in] */ BSTR const strConfig,
00079             /* [retval][out] */ LONG __RPC_FAR *pEventMask);
00080
00081     STDMETHOD(Notify)(
00082             /* [in] */ LONG ExitEvent,
00083             /* [in] */ LONG Context);
00084
00085     STDMETHOD(GetDescription)(
00086             /* [retval][out] */ BSTR *pstrDescription);
00087
00088 private:
00089     HRESULT _NotifyNewCert(IN LONG Context);
00090
00091     HRESULT _NotifyCRLIssued(IN LONG Context);
00092
00093     HRESULT _WriteCertToFile(
00094   IN ICertServerExit *pServer,
00095   IN BYTE const *pbCert,
00096   IN DWORD cbCert);
00097
00098     HRESULT _ExpandEnvironmentVariables(
00099   IN WCHAR const *pwszIn,
00100   OUT WCHAR *pwszOut,
00101   IN DWORD cwcOut);
00102
00103
00104     // Member variables & private methods here:
00105     BSTR           m_bstrDescription;
00106     BSTR           m_strCAName;
00107     LPWSTR         m_wszRegStorageLoc;
00108     HKEY           m_hExitKey;
00109     DWORD          m_dwExitPublishFlags;
00110     DWORD          m_cCACert;
00111     INT            m_cCRLPublishRetryCount;
00112
00113 };
00114
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/comp.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

comp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENT_
00016 #define _CLASS_CCOMPONENT_
00017
00018 #include "Globals.h"
00019
00020
00021 class CComponentData;                  // References
00022
00023
00024 //---------------------------------------------------------------------------
00025 class CComponent : public IComponent2
00026 {
00027   // Construction/Destruction
00028   public:
00029     CComponent( CComponentData* pParent );
00030     ~CComponent();
00031
00032
00033     /////////////////////////////////////////////////////////////////////////
00034     // Interface IUnknown
00035     //
00036     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00037     STDMETHODIMP_(ULONG) AddRef();
00038     STDMETHODIMP_(ULONG) Release();
00039
00040     /////////////////////////////////////////////////////////////////////////
00041     // Interface IComponent
00042     //
00043     HRESULT STDMETHODCALLTYPE Initialize
00044             ( /*[in] */ LPCONSOLE ipConsole );
00045
00046     HRESULT STDMETHODCALLTYPE Notify
00047             ( /*[in] */ LPDATAOBJECT ipDataObject,
00048               /*[in] */ MMC_NOTIFY_TYPE MmcEvent,
00049               /*[in] */ LPARAM nArg,
00050               /*[in] */ LPARAM nParam
00051             );
00052
00053     HRESULT STDMETHODCALLTYPE Destroy
00054             ( /*[in] */ MMC_COOKIE nCookie );
00055
00056     HRESULT STDMETHODCALLTYPE QueryDataObject
00057             ( /*[in] */  MMC_COOKIE nCookie,
00058               /*[in] */  DATA_OBJECT_TYPES nEnumType,
00059               /*[out]*/  LPDATAOBJECT __RPC_FAR* ppDataObject
00060             );
00061
00062     HRESULT STDMETHODCALLTYPE GetResultViewType
00063             ( /*[in] */  MMC_COOKIE nCookie,
00064               /*[out]*/  LPOLESTR __RPC_FAR* ppViewType,
00065               /*[out]*/  long __RPC_FAR* pViewOptions
00066             );
00067
00068     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00069             ( /*[out][in] */ RESULTDATAITEM __RPC_FAR* pResultDataItem );
00070
00071     HRESULT STDMETHODCALLTYPE CompareObjects
00072             ( /*[in] */ LPDATAOBJECT lpDataObjectA,
00073               /*[in] */ LPDATAOBJECT lpDataObjectB
00074             );
00075
00076     HRESULT STDMETHODCALLTYPE QueryDispatch
00077             ( /*[in] */  MMC_COOKIE  nCookie,
00078               /*[in] */  DATA_OBJECT_TYPES eType,
00079               /*[out]*/  LPDISPATCH* pipDispatch
00080             );
00081
00082     HRESULT STDMETHODCALLTYPE GetResultViewType2
00083             ( /*[in] */    MMC_COOKIE nCookie,
00084               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pResultViewType
00085             );
00086
00087     HRESULT STDMETHODCALLTYPE RestoreResultView
00088             ( /*[in] */    MMC_COOKIE nCookie,
00089               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pResultViewType
00090             );
00091
00092   private:
00093     ULONG            m_cRef;
00094     CComponentData*  m_pComponentData;
00095
00096 };
00097
00098 #endif //_CLASS_CCOMPONENT_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/compdata.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

compdata.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENTDATA_
00016 #define _CLASS_CCOMPONENTDATA_
00017
00018
00019 #include "Globals.h"
00020 #include "BaseNode.h"
00021
00022 class  CStaticNode;           // References
00023
00024 //---------------------------------------------------------------------------
00025 class CComponentData : public IComponentData2,
00026                               IExtendContextMenu
00027 {
00028   private:
00029     ULONG                m_cRef;
00030     LPCONSOLE3           m_ipConsole;
00031     LPCONSOLENAMESPACE2  m_ipConsoleNameSpace2;
00032     LPIMAGELIST          m_ipScopeImage;         // Caching the image list
00033     CStaticNode*         m_pStaticNode;
00034     HSCOPEITEM           m_hStaticNode;
00035     HBITMAP              m_hImageStrip16;
00036     HBITMAP              m_hImageStrip32;
00037
00038
00039   public:
00040     CComponentData();
00041     ~CComponentData();
00042
00043     /////////////////////////////////////////////////////////////////////////
00044     // Interface IUnknown
00045     //
00046     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00047     STDMETHODIMP_(ULONG) AddRef();
00048     STDMETHODIMP_(ULONG) Release();
00049
00050     /////////////////////////////////////////////////////////////////////////
00051     // Interface IComponentData2
00052     //
00053     HRESULT STDMETHODCALLTYPE Initialize
00054             ( /*[in]*/ LPUNKNOWN pUnknown );
00055
00056     HRESULT STDMETHODCALLTYPE CreateComponent
00057             ( /*[out]*/ LPCOMPONENT __RPC_FAR* ppComponent);
00058
00059     HRESULT STDMETHODCALLTYPE Notify
00060             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00061               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00062               /*[in]*/ LONG nArg,
00063               /*[in]*/ LONG nParam
00064             );
00065
00066     HRESULT STDMETHODCALLTYPE Destroy( void);
00067
00068     HRESULT STDMETHODCALLTYPE QueryDataObject
00069             ( /*[in]*/  MMC_COOKIE uCookie,
00070               /*[in]*/  DATA_OBJECT_TYPES nEnumType,
00071               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00072             );
00073
00074     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00075             ( /*[out][in]*/ SCOPEDATAITEM __RPC_FAR* pScopeDataItem );
00076
00077     HRESULT STDMETHODCALLTYPE CompareObjects
00078             ( /*[in]*/ LPDATAOBJECT ipDataObjectA,
00079               /*[in]*/ LPDATAOBJECT ipDataObjectB
00080             );
00081
00082     HRESULT STDMETHODCALLTYPE QueryDispatch
00083             ( /*[in] */  MMC_COOKIE  nCookie,
00084               /*[in] */  DATA_OBJECT_TYPES eType,
00085               /*[out]*/  LPDISPATCH* pipDispatch
00086             );
00087
00088     /////////////////////////////////////////////////////////////////////////
00089     // Interface IExtendContextMenu
00090     //
00091     HRESULT STDMETHODCALLTYPE AddMenuItems
00092             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00093               /*[in]*/ LPCONTEXTMENUCALLBACK ipCallback,
00094               /*[out,in]*/ long __RPC_FAR* pInsertionAllowed
00095             );
00096
00097     HRESULT STDMETHODCALLTYPE Command
00098             ( /*[in]*/ long lCommandID,
00099               /*[in]*/ LPDATAOBJECT piDataObject
00100             );
00101
00102
00103   // Pulic helper methods
00104   public:
00105     CStaticNode* GetStaticNode() { return m_pStaticNode; }
00106     HRESULT      GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00107
00108 };
00109
00110 #endif //_CLASS_CCOMPONENTDATA_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IAccount Member List

This is the complete list of members for IAccount, including all inherited members.
Post([in] long lAccount,[in] long lAmount,[out, retval] BSTR *pbstrResult) | IAccount
Post([in] long lngAccntNum,[in] long lngAmount,[out, retval] BSTR *pVal) | IAccount
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CellPos Member List

This is the complete list of members for CellPos, including all inherited members.
clipend | CellPos
clipstart | CellPos
size | CellPos
start | CellPos
Generated on Wed Nov 13 2024 16:56:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/Utils.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

Utils.cpp

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: Utils.cpp
00006  * ---------- [ Source Definition File]
00007  *
00008  * @Description:
00009  * -------------
00010  * Utilities for logging Error Messages in the debugger
00011  * or in a Popup message box
00012  *
00013  ******************************************************/
00014
00015
00016 #include "Stdafx.h"
00017 #include "Utils.h"
00018
00019
00020 /**********************************************************
00021 //@DBLOGGER
00022 //
00023 //@Description
00024 //
00025 //  Spews text output to the debugger
00026 //
00027 //@Args In:
00028 //
00029 //  LPCTSTR str   -> Formatted String
00030 //
00031 //
00032 //@Args Out:    None
00033 //
00034 //
00035 //*********************************************************/
00036 extern "C" int DBLOGGER(TCHAR *str, ...)
00037 {
00038
00039   _ASSERTE( str != NULL);
00040
00041   TCHAR buffer[512] = {_T('\0')};
00042
00043   va_list v;
00044   va_start(v,str);
00045   _tcscpy(buffer,_T("\n"));
00046   _vsntprintf(buffer,511,str,v);
00047   ::OutputDebugString(buffer);
00048
00049   va_end(v);
00050   return 1;
00051 }
00052
00053
00054 /**********************************************************
00055 //@LOGMSGERROR
00056 //
00057 //@Description
00058 //
00059 //  Reports an Error in a Message Box
00060 //
00061 //@Args In:
00062 //
00063 //  LPCTSTR str   ->  String
00064 //
00065 //
00066 //@Args Out:    None
00067 //
00068 //
00069 //*********************************************************/
00070 extern "C" void LOGMSGERROR(TCHAR *str, ...)
00071 {
00072
00073   _ASSERT(NULL != str);
00074
00075   TCHAR buffer[512] = {_T('\0')};
00076
00077   va_list v;
00078   va_start(v,str);
00079   _tcscpy(buffer,_T("\n"));
00080   _vsntprintf(buffer,511,str,v);
00081
00082   MessageBox(NULL, buffer, _T("RTCOut Error"), MB_OK);
00083
00084   va_end(v);
00085 }
00086
00087
00088
00089 /**********************************************************
00090 //@LOGMSG
00091 //
00092 //@Description
00093 //
00094 //  Reports an Error in a Message Box
00095 //
00096 //@Args In:
00097 //
00098 //  LPCTSTR str   ->  String
00099 //
00100 //
00101 //@Args Out:    None
00102 //
00103 //
00104 //*********************************************************/
00105 extern "C" void LOGMSG(TCHAR *str, ...)
00106 {
00107
00108   _ASSERT(NULL != str);
00109
00110   TCHAR buffer[512] = {_T('\0')};
00111
00112   va_list v;
00113   va_start(v,str);
00114   _tcscpy(buffer,_T("\n"));
00115   _vsntprintf(buffer,511,str,v);
00116
00117   MessageBox(NULL, buffer, _T("RTCOut Info"), MB_OK);
00118
00119   va_end(v);
00120 }
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/mspstrm.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

mspstrm.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1997-1999  Microsoft Corporation
00004
00005 Module Name:
00006
00007     mspstrm.cpp
00008
00009 Abstract:
00010
00011     This module contains implementation of CMSPStream. The object represents
00012     one stream in the filter graph.
00013
00014 --*/
00015
00016 #include "precomp.h"
00017 #pragma hdrstop
00018
00019 /////////////////////////////////////////////////////////////////////////////
00020 // CMSPStream
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 CMSPStream::CMSPStream()
00024     : m_dwState(STRM_INITIAL),
00025       m_dwMediaType(0),
00026       m_pFTM(NULL),
00027       m_hAddress(NULL),
00028       m_pMSPCall(NULL),
00029       m_pIGraphBuilder(NULL),
00030       m_pIMediaControl(NULL),
00031
00032 #if ((WINVER > 0x501) && (_WIN32_WINNT > 0x501))
00033       m_pPTEventSink( NULL ),
00034       m_lMyPersonalRefcount(0),
00035       m_bFirstAddRef(TRUE)
00036 #else
00037       m_pPTEventSink( NULL )
00038 #endif // ((WINVER > 0x501) && (_WIN32_WINNT > 0x501))
00039 {
00040     LOG((MSP_TRACE, "CMSPStream::CMSPStream - enter"));
00041     LOG((MSP_TRACE, "CMSPStream::CMSPStream - exit"));
00042 }
00043
00044 CMSPStream::~CMSPStream()
00045 {
00046     LOG((MSP_TRACE, "CMSPStream::~CMSPStream - enter"));
00047
00048     ReleaseSink();
00049
00050     LOG((MSP_TRACE, "CMSPStream::~CMSPStream - exit"));
00051 }
00052
00053 STDMETHODIMP CMSPStream::get_MediaType(
00054     OUT     long *                  plTapiMediaType
00055     )
00056 {
00057     LOG((MSP_TRACE, "CMSPStream::get_MediaType - enter"));
00058
00059     if (MSPB_IsBadWritePtr(plTapiMediaType, sizeof (long *)))
00060     {
00061         LOG((MSP_ERROR, "CMSPStream::get_MediaType - exit E_POINTER"));
00062
00063         return E_POINTER;
00064     }
00065
00066
00067     CLock lock(m_lock);
00068
00069     *plTapiMediaType = m_dwMediaType;
00070
00071     LOG((MSP_TRACE, "CMSPStream::get_MediaType - exit S_OK"));
00072
00073     return S_OK;
00074 }
00075
00076 STDMETHODIMP CMSPStream::get_Direction(
00077     OUT     TERMINAL_DIRECTION *    pTerminalDirection
00078     )
00079 {
00080     LOG((MSP_TRACE, "CMSPStream::get_Direction - enter"));
00081
00082     if (MSPB_IsBadWritePtr(pTerminalDirection, sizeof (TERMINAL_DIRECTION *)))
00083     {
00084         LOG((MSP_ERROR, "CMSPStream::get_Direction - exit E_POINTER"));
00085
00086         return E_POINTER;
00087     }
00088
00089
00090     CLock lock(m_lock);
00091
00092
00093     *pTerminalDirection = m_Direction;
00094
00095     LOG((MSP_TRACE, "CMSPStream::get_Direction - exit S_OK"));
00096
00097     return S_OK;
00098 }
00099
00100 STDMETHODIMP CMSPStream::SelectTerminal(
00101     IN      ITTerminal *            pTerminal
00102     )
00103 /*++
00104
00105 Routine Description:
00106
00107 Arguments:
00108
00109
00110 Return Value:
00111
00112 S_OK
00113
00114 E_POINTER
00115 E_OUTOFMEMORY
00116 TAPI_E_MAXTERMINALS
00117 TAPI_E_INVALIDTERMINAL
00118
00119 --*/
00120 {
00121     LOG((MSP_TRACE, "CMSPStream::SelectTerminal - enter"));
00122
00123     //
00124     // Check parameter.
00125     //
00126
00127     if ( IsBadReadPtr(pTerminal, sizeof(ITTerminal) ) )
00128     {
00129         LOG((MSP_ERROR, "CMSPStream::SelectTerminal - exit E_POINTER"));
00130
00131         return E_POINTER;
00132     }
00133
00134     HRESULT hr;
00135     ITTerminalControl *pTerminalControl;
00136
00137     //
00138     // Get the private interface from this terminal.
00139     //
00140
00141     hr = pTerminal->QueryInterface(IID_ITTerminalControl,
00142                                    (void **) &pTerminalControl);
00143
00144     if (FAILED(hr))
00145     {
00146         LOG((MSP_ERROR, "CMSPStream::SelectTerminal - "
00147             "can't get ITTerminalControl - exit TAPI_E_INVALIDTERMINAL"));
00148
00149         return TAPI_E_INVALIDTERMINAL;
00150     }
00151
00152     //
00153     // Get the address handle and release the private interface.
00154     //
00155
00156     MSP_HANDLE hAddress;
00157     hr = pTerminalControl->get_AddressHandle(&hAddress);
00158
00159     pTerminalControl->Release();
00160
00161     if (FAILED(hr))
00162     {
00163         LOG((MSP_ERROR, "CMSPStream::SelectTerminal - "
00164             "can't get address handle - exit TAPI_E_INVALIDTERMINAL"));
00165
00166         return TAPI_E_INVALIDTERMINAL;
00167     }
00168
00169     //
00170     // Find out if the terminal belongs to this address. Reject it if it belongs
00171     // to another address, but accept it if it is an application-provided terminal
00172     // (NULL address handle).
00173     //
00174
00175     if ( ( hAddress != NULL ) && ( hAddress != (MSP_HANDLE) m_hAddress ) )
00176     {
00177         LOG((MSP_ERROR, "CMSPStream::SelectTerminal - "
00178             "terminal from another address - exit TAPI_E_INVALIDTERMINAL"));
00179
00180         return TAPI_E_INVALIDTERMINAL;
00181     }
00182
00183     //
00184     // Find out if the terminal is already in our list.
00185     //
00186
00187     CLock lock(m_lock);
00188
00189     if (m_Terminals.Find(pTerminal) >= 0)
00190     {
00191         LOG((MSP_ERROR, "CMSPStream::SelectTerminal - "
00192             "terminal already selected - exit TAPI_E_INVALIDTERMINAL"));
00193
00194         return TAPI_E_INVALIDTERMINAL;
00195     }
00196
00197     //
00198     // Add the new terminal into our list and addref it.
00199     //
00200
00201     if (!m_Terminals.Add(pTerminal))
00202     {
00203         LOG((MSP_ERROR, "CMSPStream::SelectTerminal - "
00204             "exit E_OUTOFMEMORY"));
00205
00206         return E_OUTOFMEMORY;
00207     }
00208
00209     pTerminal->AddRef();
00210
00211     hr = RegisterPluggableTerminalEventSink( pTerminal );
00212     if( FAILED(hr) )
00213     {
00214         LOG((MSP_TRACE, "CMSPStream::SelectTerminal - "
00215             "something wrong in RegisterPluggableTerminalEventSink"));
00216     }
00217
00218     LOG((MSP_TRACE, "CMSPStream::SelectTerminal - exit S_OK"));
00219
00220     return S_OK;
00221 }
00222
00223 STDMETHODIMP CMSPStream::UnselectTerminal(
00224     IN     ITTerminal *             pTerminal
00225     )
00226 {
00227     LOG((MSP_TRACE, "CMSPStream::UnselectTerminal - enter"));
00228
00229     //
00230     // find out if the terminal is in our list.
00231     //
00232
00233     CLock lock(m_lock);
00234     int index;
00235
00236     if ((index = m_Terminals.Find(pTerminal)) < 0)
00237     {
00238         LOG((MSP_ERROR, "CMSPStream::UnselectTerminal - "
00239             "exit TAPI_E_INVALIDTERMINAL"));
00240
00241         return TAPI_E_INVALIDTERMINAL;
00242     }
00243
00244     //
00245     // Unregister the PTEventSink object
00246     //
00247
00248     HRESULT hr = E_FAIL;
00249     hr = UnregisterPluggableTerminalEventSink( pTerminal );
00250
00251     if( FAILED(hr) )
00252     {
00253         LOG((MSP_TRACE, "CMSPStream::UnselectTerminal - "
00254             "something wrong in UnregisterPluggableTerminalEventSink"));
00255     }
00256
00257     //
00258     // remove the terminal from our list and release it.
00259     //
00260
00261     if (!m_Terminals.RemoveAt(index))
00262     {
00263         LOG((MSP_ERROR, "CMSPStream::UnselectTerminal - "
00264             "exit E_UNEXPECTED"));
00265
00266         return E_UNEXPECTED;
00267     }
00268
00269     pTerminal->Release();
00270
00271     LOG((MSP_TRACE, "CMSPStream::UnselectTerminal - exit S_OK"));
00272
00273     return S_OK;
00274 }
00275
00276 STDMETHODIMP CMSPStream::EnumerateTerminals(
00277     OUT     IEnumTerminal **        ppEnumTerminal
00278     )
00279 {
00280     LOG((MSP_TRACE,
00281         "EnumerateTerminals entered. ppEnumTerminal:%x", ppEnumTerminal));
00282
00283     if (MSPB_IsBadWritePtr(ppEnumTerminal, sizeof(VOID *)))
00284     {
00285         LOG((MSP_ERROR, "ppEnumTerminal is a bad pointer"));
00286         return E_POINTER;
00287     }
00288
00289     // acquire the lock before accessing the Terminal object list.
00290     CLock lock(m_lock);
00291
00292     if (m_Terminals.GetData() == NULL)
00293     {
00294         LOG((MSP_ERROR, "CMSPStream::EnumerateTerminals - "
00295             "stream appears to have been shut down - exit E_UNEXPECTED"));
00296
00297         return E_UNEXPECTED;
00298     }
00299
00300     typedef _CopyInterface<ITTerminal> CCopy;
00301     typedef CSafeComEnum<IEnumTerminal, &IID_IEnumTerminal,
00302                 ITTerminal *, CCopy> CEnumerator;
00303
00304     HRESULT hr;
00305
00306     CMSPComObject<CEnumerator> *pEnum = NULL;
00307
00308     hr = CMSPComObject<CEnumerator>::CreateInstance(&pEnum);
00309     if (pEnum == NULL)
00310     {
00311         LOG((MSP_ERROR, "Could not create enumerator object, %x", hr));
00312         return hr;
00313     }
00314
00315     // query for the IID_IEnumTerminal i/f
00316     hr = pEnum->_InternalQueryInterface(IID_IEnumTerminal, (void**)ppEnumTerminal);
00317     if (FAILED(hr))
00318     {
00319         LOG((MSP_ERROR, "query enum interface failed, %x", hr));
00320         delete pEnum;
00321         return hr;
00322     }
00323
00324     // The CSafeComEnum can handle zero-sized array.
00325     hr = pEnum->Init(
00326         m_Terminals.GetData(),                        // the begin itor
00327         m_Terminals.GetData() + m_Terminals.GetSize(),  // the end itor,
00328         NULL,                                       // IUnknown
00329         AtlFlagCopy                                 // copy the data.
00330         );
00331
00332     if (FAILED(hr))
00333     {
00334         LOG((MSP_ERROR, "init enumerator object failed, %x", hr));
00335         (*ppEnumTerminal)->Release();
00336         return hr;
00337     }
00338
00339     LOG((MSP_TRACE, "CMSPStream::EnumerateTerminals - exit S_OK"));
00340
00341     return hr;
00342 }
00343
00344 STDMETHODIMP CMSPStream::get_Terminals(
00345     OUT     VARIANT *               pVariant
00346     )
00347 {
00348     LOG((MSP_TRACE, "CMSPStream::get_Terminals - enter"));
00349
00350     //
00351     // Check parameters.
00352     //
00353
00354     if ( MSPB_IsBadWritePtr(pVariant, sizeof(VARIANT) ) )
00355     {
00356         LOG((MSP_ERROR, "CMSPStream::get_Terminals - "
00357             "bad pointer argument - exit E_POINTER"));
00358
00359         return E_POINTER;
00360     }
00361
00362     //
00363     // See if this stream has been shut down. Acquire the lock before accessing
00364     // the terminal object list.
00365     //
00366
00367     CLock lock(m_lock);
00368
00369     if (m_Terminals.GetData() == NULL)
00370     {
00371         LOG((MSP_ERROR, "CMSPStream::get_Terminals - "
00372             "stream appears to have been shut down - exit E_UNEXPECTED"));
00373
00374         return E_UNEXPECTED;
00375     }
00376
00377
00378     //
00379     // create the collection object - see mspcoll.h
00380     //
00381
00382     HRESULT hr;
00383     typedef CTapiIfCollection< ITTerminal * > TerminalCollection;
00384     CComObject<TerminalCollection> * pCollection;
00385     hr = CComObject<TerminalCollection>::CreateInstance( &pCollection );
00386
00387     if ( FAILED(hr) )
00388     {
00389         LOG((MSP_ERROR, "CMSPStream::get_Terminals - "
00390             "can't create collection - exit 0x%08x", hr));
00391
00392         return hr;
00393     }
00394
00395     //
00396     // get the Collection's IDispatch interface
00397     //
00398
00399     IDispatch * pDispatch;
00400
00401     hr = pCollection->_InternalQueryInterface(IID_IDispatch,
00402                                               (void **) &pDispatch );
00403
00404     if ( FAILED(hr) )
00405     {
00406         LOG((MSP_ERROR, "CMSPStream::get_Terminals - "
00407             "QI for IDispatch on collection failed - exit 0x%08x", hr));
00408
00409         delete pCollection;
00410
00411         return hr;
00412     }
00413
00414     //
00415     // Init the collection using an iterator -- pointers to the beginning and
00416     // the ending element plus one.
00417     //
00418
00419     hr = pCollection->Initialize( m_Terminals.GetSize(),
00420                                   m_Terminals.GetData(),
00421                                   m_Terminals.GetData() + m_Terminals.GetSize() );
00422
00423     if (FAILED(hr))
00424     {
00425         LOG((MSP_ERROR, "CMSPStream::get_Terminals - "
00426             "Initialize on collection failed - exit 0x%08x", hr));
00427
00428         pDispatch->Release();
00429         return hr;
00430     }
00431
00432     //
00433     // put the IDispatch interface pointer into the variant
00434     //
00435
00436     LOG((MSP_TRACE, "CMSPStream::get_Terminals - "
00437         "placing IDispatch value %08x in variant", pDispatch));
00438
00439     VariantInit(pVariant);
00440     pVariant->vt = VT_DISPATCH;
00441     pVariant->pdispVal = pDispatch;
00442
00443     LOG((MSP_TRACE, "CMSPStream::get_Terminals - exit S_OK"));
00444
00445     return S_OK;
00446 }
00447
00448 STDMETHODIMP CMSPStream::StartStream()
00449 {
00450     LOG((MSP_TRACE, "CMSPStream - RUNNING GRAPH"));
00451
00452     HRESULT hr = m_pIMediaControl->Run();
00453
00454     if(FAILED(hr))
00455     {
00456         LOG((MSP_ERROR, "graph doesn't run, %x", hr));
00457     }
00458     return hr;
00459 }
00460
00461 STDMETHODIMP CMSPStream::PauseStream()
00462 {
00463     LOG((MSP_TRACE, "CMSPStream - PAUSING GRAPH"));
00464
00465     HRESULT hr = m_pIMediaControl->Pause();
00466
00467     if(FAILED(hr))
00468     {
00469         LOG((MSP_ERROR, "graph doesn't pause, %x", hr));
00470     }
00471     return hr;
00472 }
00473
00474 STDMETHODIMP CMSPStream::StopStream()
00475 {
00476     LOG((MSP_TRACE, "CMSPStream - STOPPING GRAPH"));
00477
00478     HRESULT hr = m_pIMediaControl->Stop();
00479
00480     if(FAILED(hr))
00481     {
00482         LOG((MSP_ERROR, "graph doesn't stop, %x", hr));
00483     }
00484     return hr;
00485 }
00486
00487 // methods called by the MSPCall object.
00488 HRESULT CMSPStream::Init(
00489     IN     HANDLE                   hAddress,
00490     IN     CMSPCallBase *           pMSPCall,
00491     IN     IMediaEvent *            pGraph,
00492     IN     DWORD                    dwMediaType,
00493     IN     TERMINAL_DIRECTION       Direction
00494     )
00495 {
00496     LOG((MSP_TRACE, "CMSPStream::Init - enter"));
00497
00498
00499     CLock lock(m_lock);
00500
00501
00502     // This method is called only once when the object is created. No other
00503     // method will be called until this function succeeds. No need to lock.
00504     _ASSERTE(m_hAddress == NULL);
00505
00506     // initialize the terminal array so that the array is not NULL. Used for
00507     // generating an empty enumerator if no terminal is selected.
00508     if (!m_Terminals.Grow())
00509     {
00510         LOG((MSP_ERROR, "CMSPStream::Init - exit E_OUTOFMEMORY"));
00511
00512         return E_OUTOFMEMORY;
00513     }
00514
00515     HRESULT hr;
00516     hr = CoCreateFreeThreadedMarshaler(GetControllingUnknown(), &m_pFTM);
00517     if (FAILED(hr))
00518     {
00519         LOG((MSP_ERROR, "create marshaler failed, %x", hr));
00520         return hr;
00521     }
00522
00523     // Get the media control interface on the graph.
00524     IMediaControl *pMC;
00525     hr = pGraph->QueryInterface(IID_IMediaControl, (void **) &pMC);
00526     if(FAILED(hr))
00527     {
00528         LOG((MSP_ERROR, "get IMediaControl interface, %x", hr));
00529         return hr;
00530     }
00531
00532     // Get the graph builder interface on the graph.
00533     IGraphBuilder *pGB;
00534     hr = pGraph->QueryInterface(IID_IGraphBuilder, (void **) &pGB);
00535     if(FAILED(hr))
00536     {
00537         LOG((MSP_ERROR, "get IGraphBuilder interface, %x", hr));
00538         pMC->Release();
00539         return hr;
00540     }
00541
00542     m_hAddress          = hAddress;
00543
00544     m_pMSPCall          = pMSPCall;
00545     m_pMSPCall->MSPCallAddRef();
00546
00547     m_pIMediaControl    = pMC;
00548     // no addref because QI addrefs for us above
00549
00550     m_pIGraphBuilder    = pGB;
00551     // no addref because QI addrefs for us above
00552
00553     m_dwMediaType       = dwMediaType;
00554     m_Direction         = Direction;
00555
00556     LOG((MSP_TRACE, "CMSPStream::Init - exit S_OK"));
00557
00558     return S_OK;
00559 }
00560
00561 HRESULT CMSPStream::ShutDown()
00562 {
00563     LOG((MSP_TRACE, "CMSPStream::Shutdown - enter"));
00564
00565     CLock lock(m_lock);
00566
00567     //
00568     // We are shut down, so the call is now NULL.
00569     //
00570
00571     m_pMSPCall->MSPCallRelease();
00572     m_pMSPCall = NULL;
00573
00574     //
00575     // Unselect all the terminals. Rather than just removing all the
00576     // terminals, we call UnselectTerminal on each one to give the derived
00577     // class a chance to do whatever else it needs to do when a terminal
00578     // is unselected.
00579     //
00580     // We walk the list in reverse order because the list shrinks with
00581     // each iteration (see msputils.h).
00582     //
00583
00584     for ( int i = m_Terminals.GetSize() - 1; i >= 0; i-- )
00585     {
00586         UnselectTerminal(m_Terminals[i]);
00587     }
00588
00589     //
00590     // At this point the derive class should have removed and released
00591     // all of the terminals from the list. If that's not the case, the
00592     // derived class is buggy.
00593     //
00594
00595     _ASSERTE( m_Terminals.GetSize() == 0 );
00596
00597
00598     //
00599     // no longer need the sink
00600     //
00601
00602     ReleaseSink();
00603
00604     LOG((MSP_TRACE, "CMSPStream::Shutdown - exit S_OK"));
00605
00606     return S_OK;
00607 }
00608
00609 void CMSPStream::FinalRelease()
00610 {
00611     LOG((MSP_TRACE, "CMSPStream::FinalRelease - enter"));
00612
00613     // release the two interface pointers to the graph.
00614     if (m_pIMediaControl)
00615     {
00616         m_pIMediaControl->Release();
00617     }
00618
00619     if (m_pIGraphBuilder)
00620     {
00621         m_pIGraphBuilder->Release();
00622     }
00623
00624     if (m_pFTM)
00625     {
00626         m_pFTM->Release();
00627     }
00628
00629     LOG((MSP_TRACE, "CMSPStream::FinalRelease - exit"));
00630 }
00631
00632 HRESULT CMSPStream::HandleTSPData(
00633     IN     BYTE *                   pData,
00634     IN     DWORD                    dwSize
00635     )
00636 {
00637     LOG((MSP_TRACE, "CMSPStream::HandleTSPData - enter"));
00638     LOG((MSP_TRACE, "CMSPStream::HandleTSPData - exit S_OK"));
00639
00640     return S_OK;
00641 }
00642
00643 HRESULT CMSPStream::ProcessGraphEvent(
00644     IN  long lEventCode,
00645     IN  LONG_PTR lParam1,
00646     IN  LONG_PTR lParam2
00647     )
00648 {
00649     LOG((MSP_TRACE, "CMSPStream::ProcessGraphEvent - enter"));
00650     LOG((MSP_TRACE, "CMSPStream::ProcessGraphEvent - exit S_OK"));
00651
00652     return S_OK;
00653 }
00654
00655 /*++
00656 RegisterPluggableTerminalEventSink
00657
00658 Parameters:
00659  The terminla interface
00660
00661 Description;
00662  Is called by SelectTerminal if is a dynamic terminal
00663 --*/
00664 HRESULT CMSPStream::RegisterPluggableTerminalEventSink(
00665     IN  ITTerminal* pTerminal
00666     )
00667 {
00668     LOG((MSP_TRACE, "CMSPStream::RegisterPluggableTerminalEventSink - enter"));
00669
00670     //
00671     // Validates arguments
00672     //
00673
00674     if( IsBadReadPtr( pTerminal, sizeof( ITTerminal) ))
00675     {
00676         LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00677             "pTerminal invalid, returns E_POINTER"));
00678         return E_POINTER;
00679     }
00680
00681     //
00682     // Get the type of the terminal
00683     //
00684
00685     TERMINAL_TYPE nTerminalType;
00686     HRESULT hr = E_FAIL;
00687
00688     hr = pTerminal->get_TerminalType( &nTerminalType );
00689
00690     if( FAILED(hr) )
00691     {
00692         LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00693             "get_TerminalType failed, exit E_UNEXPECTED"));
00694
00695         return E_UNEXPECTED;
00696     }
00697
00698     //
00699     // The terminal should by a dynamic terminal
00700     //
00701
00702     if( TT_DYNAMIC != nTerminalType)
00703     {
00704         LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00705             "terminal is not dynamic, exit E_INVALIDARG"));
00706         return E_INVALIDARG;
00707     }
00708
00709
00710     CLock lock(m_lock);
00711
00712
00713     //
00714     // Create the sink if we don't have one already
00715     //
00716
00717     if(NULL == m_pPTEventSink)
00718     {
00719         //Create a PTEventSink object
00720         CComObject<CPTEventSink>* pPTEventSink;
00721         hr = CComObject<CPTEventSink>::CreateInstance(&pPTEventSink);
00722
00723         if( FAILED(hr) )
00724         {
00725
00726             LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00727                 "CreateInstance failed, returns E_OUTOFMEMORY"));
00728             return E_OUTOFMEMORY;
00729         }
00730
00731
00732         // tell sink that we are ready to be processing its events
00733
00734         hr = pPTEventSink->SetSinkStream(this);
00735
00736         if (FAILED(hr))
00737         {
00738             LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00739                 "event sink refused to accept sink stream. hr = %lx", hr));
00740
00741             delete pPTEventSink;
00742
00743             return hr;
00744         }
00745
00746
00747         // Get ITPluggableTerminalEventSink interface from the sink
00748
00749         hr = pPTEventSink->QueryInterface(IID_ITPluggableTerminalEventSink, (void**)&m_pPTEventSink);
00750
00751         if( FAILED(hr) )
00752         {
00753             LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00754                 "QI for ITPluggableTerminalEventSink failed, returns E_UNEXPECTED"));
00755
00756
00757             //
00758             // ok, the sink is no good. get rid of it.
00759             //
00760
00761             pPTEventSink->SetSinkStream(NULL);
00762             delete pPTEventSink;
00763             pPTEventSink = NULL;
00764
00765
00766             //
00767             // sink does not expose IID_ITPluggableTerminalEventSink interface?
00768             // something is seriously wrong
00769             //
00770
00771             return E_UNEXPECTED;
00772         }
00773
00774
00775     }
00776
00777
00778     // Get the ITDTEventHandler interface
00779     ITPluggableTerminalEventSinkRegistration*   pEventRegistration = NULL;
00780
00781     hr = pTerminal->QueryInterface( IID_ITPluggableTerminalEventSinkRegistration,
00782         (void**)&pEventRegistration
00783         );
00784
00785     if( FAILED(hr) )
00786     {
00787         // The dynamic terminal doesn't implement ITPluggableTerminalEventSinkRegistration
00788         // This is bad! We cannot use the new event stuff
00789         LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00790            "QI for ITPluggableTerminalEventSinkregistration failed, returns S_FALSE"));
00791
00792         //
00793         // no need to keep the sink
00794         //
00795
00796         ReleaseSink();
00797
00798         return S_FALSE;
00799     }
00800
00801     // pass the sink to the terminal
00802     hr = pEventRegistration->RegisterSink(
00803         m_pPTEventSink
00804         );
00805
00806
00807     // Clean up, anyway
00808     pEventRegistration->Release();
00809
00810     if( FAILED(hr) )
00811     {
00812
00813         LOG((MSP_ERROR, "CMSPStream::RegisterPluggableTerminalEventSink "
00814            "RegisterSink failed, returns E_FAIL"));
00815
00816
00817         //
00818         // no need to keep the sink
00819         //
00820
00821         ReleaseSink();
00822
00823         return E_FAIL;
00824     }
00825
00826     LOG((MSP_TRACE, "CMSPStream::RegisterPluggableTerminalEventSink - exit S_OK"));
00827     return S_OK;
00828 }
00829
00830 /*++
00831 UnregisterPluggableTerminalEventSink
00832
00833 Parameters:
00834  The terminal interface
00835
00836 Description;
00837  Is called by UnselectTerminal if is a dynamic terminal
00838 --*/
00839 HRESULT CMSPStream::UnregisterPluggableTerminalEventSink(
00840     IN  ITTerminal* pTerminal
00841     )
00842 {
00843     LOG((MSP_TRACE, "CMSPStream::UnregisterPluggableTerminalEventSink - enter"));
00844
00845         //
00846     // Validates arguments
00847     //
00848
00849     if( IsBadReadPtr( pTerminal, sizeof( ITTerminal) ))
00850     {
00851         LOG((MSP_ERROR, "CMSPStream::UnregisterPluggableTerminalEventSink "
00852             "pTerminal invalid, returns E_POINTER"));
00853         return E_POINTER;
00854     }
00855
00856     //
00857     // Get the type of the terminal
00858     //
00859
00860     TERMINAL_TYPE nTerminalType;
00861     HRESULT hr = E_FAIL;
00862
00863     hr = pTerminal->get_TerminalType( &nTerminalType );
00864
00865     if( FAILED(hr) )
00866     {
00867         LOG((MSP_ERROR, "CMSPStream::UnregisterPluggableTerminalEventSink "
00868             "get_TerminalType failed, exit E_UNEXPECTED"));
00869
00870         return E_UNEXPECTED;
00871     }
00872
00873     //
00874     // The terminal should be a dynamic terminal
00875     //
00876
00877     if( TT_DYNAMIC != nTerminalType)
00878     {
00879         LOG((MSP_ERROR, "CMSPStream::UnregisterPluggableTerminalEventSink "
00880             "terminal is not dynamic, exit E_INVALIDARG"));
00881         return E_INVALIDARG;
00882     }
00883
00884
00885     CLock lock(m_lock);
00886
00887
00888     //
00889     // Have we an EventSink object
00890     //
00891
00892     if(NULL == m_pPTEventSink)
00893     {
00894         LOG((MSP_TRACE, "CMSPStream::UnregisterPluggableTerminalEventSink - "
00895             "No EventSink - exit S_OK"));
00896         return S_OK;
00897     }
00898
00899     //
00900     // Get the ITPluggableTemrinalEventSinkRegistration interface
00901     //
00902     ITPluggableTerminalEventSinkRegistration*   pEventRegistration = NULL;
00903
00904     hr = pTerminal->QueryInterface( IID_ITPluggableTerminalEventSinkRegistration,
00905         (void**)&pEventRegistration
00906         );
00907
00908     if( FAILED(hr) )
00909     {
00910         //
00911         // The pluggable terminal doesn't implement ITPluggableTerminalEventSinkRegistration
00912         // This is bad!
00913
00914         LOG((MSP_ERROR, "CMSPStream::UnregisterPluggableTerminalEventSink "
00915            "QI for ITPluggableTerminalEventSinkRegistration failed, returns E_NOTIMPL"));
00916         return E_NOTIMPL;
00917     }
00918
00919
00920     hr = pEventRegistration->UnregisterSink( );
00921
00922     //
00923     // Clean up, anyway
00924     //
00925
00926     pEventRegistration->Release();
00927
00928     if( FAILED(hr) )
00929     {
00930         LOG((MSP_ERROR, "CMSPStream::UnregisterPluggableTerminalEventSink "
00931            "UnregisterSink failed, returns E_FAIL"));
00932         return E_FAIL;
00933     }
00934
00935
00936     //
00937     // no longer need this sink
00938     //
00939
00940     ReleaseSink();
00941
00942
00943     LOG((MSP_TRACE, "CMSPStream::UnregisterPluggableTerminalEventSink - exit S_OK"));
00944     return S_OK;
00945 }
00946
00947
00948 //////////////////////////////////////////////////////////////////////////////
00949 //
00950 // CMSPStream::HandleSinkEvent
00951 //
00952 //
00953 // CPTEventSink calls this method when it has an event for us to process
00954 // HandleSinkEvent delegates event processing to the call, if we have one
00955 //
00956 //////////////////////////////////////////////////////////////////////////////
00957
00958 HRESULT CMSPStream::HandleSinkEvent(MSPEVENTITEM *pEventItem)
00959 {
00960     LOG((MSP_TRACE, "CMSPStream::HandleSinkEvent - enter"));
00961
00962     HRESULT hr = TAPI_E_CALLUNAVAIL;
00963
00964
00965     CLock lock(m_lock);
00966
00967
00968     if (NULL != m_pMSPCall)
00969     {
00970
00971         //
00972         // we have a call. ask it to process the event
00973         //
00974
00975         hr = m_pMSPCall->HandleStreamEvent(pEventItem);
00976     }
00977     else
00978     {
00979
00980         LOG((MSP_WARN,
00981             "CMSPStream::HandleSinkEvent - there is no call to pass event to"));
00982     }
00983
00984
00985     LOG((MSP_(hr), "CMSPStream::HandleSinkEvent - exit hr = %lx", hr));
00986
00987     return hr;
00988 }
00989
00990
00991 //////////////////////////////////////////////////////////////////////////////
00992 //
00993 // CMSPStream::ReleaseSink
00994 //
00995 //
00996 // this is a helper function that lets go of sink when it no longer needed
00997 //
00998 //////////////////////////////////////////////////////////////////////////////
00999
01000
01001 HRESULT CMSPStream::ReleaseSink()
01002 {
01003     LOG((MSP_TRACE, "CMSPStream::ReleaseSink - enter"));
01004
01005
01006     HRESULT hr = S_OK;
01007
01008
01009     CLock lock(m_lock);
01010
01011
01012     //
01013     // if sink is present, let it know that we will no longer be available to
01014     // process its events and release it
01015     //
01016
01017     if( m_pPTEventSink)
01018     {
01019
01020         CPTEventSink *pSinkObject = static_cast<CPTEventSink *>(m_pPTEventSink);
01021
01022
01023         HRESULT hr = pSinkObject->SetSinkStream(NULL);
01024
01025         if (FAILED(hr))
01026         {
01027
01028             LOG((MSP_ERROR,
01029                 "CMSPStream::ReleaseSink - pSinkObject->SetSinkStream failed. hr - %lx",
01030                 hr));
01031         }
01032
01033
01034         m_pPTEventSink->Release();
01035         m_pPTEventSink = NULL;
01036     }
01037
01038     LOG((MSP_(hr), "CMSPStream::ReleaseSink - exit. hr - %lx", hr));
01039
01040     return hr;
01041 }
01042
01043 #if ((WINVER > 0x501) && (_WIN32_WINNT > 0x501))
01044
01045 //////////////////////////////////////////////////////////////////////////////
01046 //
01047 // CMSPStream::InternalAddRef
01048 //
01049 //
01050 // this is a helper function that lets go of sink when it no longer needed
01051 //
01052 //////////////////////////////////////////////////////////////////////////////
01053
01054 ULONG CMSPStream::InternalAddRef()
01055 {
01056     LOG((MSP_TRACE, "CMSPStream::InternalAddRef - enter"));
01057
01058     m_lockRefCount.Lock();
01059
01060
01061     //
01062     // if the refcount is zero, return 1. this is the indication that the
01063     // addref was called while the object is in its finalrelease or entering
01064     // destructor. Note that the only time this could happen is when event sink
01065     // attempts to send an event and addrefs the stream object after the stream
01066     // objects received its last Release() but before the stream object told
01067     // the sink to stop using it (which takes place in stream's destructor).
01068     //
01069     // we also need to be able to tell if refcount was 0 because it's a new
01070     // object or if the addref was called on an object whose refcount became
01071     // zero because of a release.
01072     //
01073
01074     if ( !m_bFirstAddRef && (0 == m_lMyPersonalRefcount) )
01075     {
01076
01077         //
01078         // the caller (event sink logic) should detect this condition (by the
01079         // return value of 1) and not expect that the stream is going to
01080         // continue to be valid.
01081         //
01082
01083         LOG((MSP_WARN, "CMSPStream::InternalAddRef - current refcount is zero... finalrelease/destructor is probably in progress"));
01084
01085         m_lockRefCount.Unlock();
01086
01087         return 1;
01088     }
01089
01090
01091     //
01092     // we have made a transition from non-zero refcount to zero. set the
01093     // flag, so that future addrefs know to return 1 in ths case when refcount
01094     // is 0
01095     //
01096
01097     m_bFirstAddRef = FALSE;
01098
01099
01100     //
01101     // since we are inside a lock, no need to use interlocked api
01102     //
01103
01104     long lNewRefcountValue = (++m_lMyPersonalRefcount);
01105
01106
01107     m_lockRefCount.Unlock();
01108
01109     LOG((MSP_TRACE, "CMSPStream::InternalAddRef - finish. %ld", lNewRefcountValue));
01110
01111     return lNewRefcountValue;
01112 }
01113
01114
01115 ULONG CMSPStream::InternalRelease()
01116 {
01117     LOG((MSP_TRACE, "CMSPStream::InternalRelease - enter"));
01118
01119     m_lockRefCount.Lock();
01120
01121     // try to catch over-releases
01122     _ASSERTE(m_lMyPersonalRefcount > 0);
01123
01124
01125     // we are inside a lock, no need to use interlocked api
01126     long lNewRefcount = (--m_lMyPersonalRefcount);
01127
01128
01129     m_lockRefCount.Unlock();
01130
01131     LOG((MSP_TRACE, "CMSPStream::InternalRelease - finish. %ld", lNewRefcount));
01132
01133     return lNewRefcount;
01134 }
01135
01136 #endif // ((WINVER > 0x501) && (_WIN32_WINNT > 0x501))
01137
01138
01139 // eof
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/internetpublishing/ippsample/StdAfx.h Source File

  • Dataaccess
  • oledb
  • internetpublishing
  • ippsample

StdAfx.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004   TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005   PARTICULAR PURPOSE.
00006
00007   Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009   stdafx.h
00010
00011   the header to be included in each source file for pre-compiled header
00012 ------------------------------------------------------------------------------*/
00013
00014 // stdafx.h : include file for standard system include files,
00015 //  or project specific include files that are used frequently, but
00016 //      are changed infrequently
00017 //
00018
00019 #if !defined(AFX_STDAFX_H__BB6C072B_AA52_11D2_8E8A_00C04FB9C68B__INCLUDED_)
00020 #define AFX_STDAFX_H__BB6C072B_AA52_11D2_8E8A_00C04FB9C68B__INCLUDED_
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026 #define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers
00027
00028 #include <stdio.h>
00029
00030 // TODO: reference additional headers your program requires here
00031
00032 /*------------------------------------------------------------------------------
00033   Please note that oledb.h and oledberr.h from the OLEDB 2.5 SDK is required.
00034   In addition, oledb.lib from the OLEDB 2.5 is required for linking.
00035 ------------------------------------------------------------------------------*/
00036 #include <oledb.h>
00037 #include <oledberr.h>
00038
00039 /*------------------------------------------------------------------------------
00040   msdaipp.h has the definition MSDAIPP-specific properties.
00041 ------------------------------------------------------------------------------*/
00042 #include <msdaipp.h>
00043
00044 /*------------------------------------------------------------------------------
00045   msdasc.h has the definition of CLSID_RootBinder and some URLMON integration
00046   necessities
00047   Link to msdasc.lib for its symbol.
00048 ------------------------------------------------------------------------------*/
00049 #include <msdasc.h>
00050
00051 #include "sample1.h"
00052
00053 //{{AFX_INSERT_LOCATION}}
00054 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00055
00056 #endif // !defined(AFX_STDAFX_H__BB6C072B_AA52_11D2_8E8A_00C04FB9C68B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/oipObj.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

oipObj.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          OIPObj.h
00021
00022   Description:   COleInPlaceObject definitions.
00023
00024 **************************************************************************/
00025
00026 #ifndef OLEINPLACEOBJECT_H
00027 #define OLEINPLACEOBJECT_H
00028
00029 /**************************************************************************
00030 #include statements
00031 **************************************************************************/
00032
00033 #include "DOServer.h"
00034
00035 /**************************************************************************
00036
00037   CPersistStorage class definition
00038
00039 **************************************************************************/
00040
00041 class COleDocument;
00042
00043 class COleInPlaceObject : public IOleInPlaceObject
00044 {
00045 private:
00046   COleDocument   *m_pOleDoc;
00047
00048 public:
00049   COleInPlaceObject::COleInPlaceObject(COleDocument*);
00050   COleInPlaceObject::~COleInPlaceObject();
00051
00052   //IUnknown methods
00053   STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00054   STDMETHODIMP_(ULONG) AddRef();
00055   STDMETHODIMP_(ULONG) Release();
00056
00057   //IOleInPlaceObject methods
00058   STDMETHODIMP InPlaceDeactivate();
00059   STDMETHODIMP UIDeactivate() ;
00060   STDMETHODIMP SetObjectRects(LPCRECT, LPCRECT);
00061   STDMETHODIMP GetWindow(HWND*) ;
00062   STDMETHODIMP ContextSensitiveHelp(BOOL);
00063   STDMETHODIMP ReactivateAndUndo();
00064 };
00065
00066 #endif   //OLEINPLACEOBJECT_H
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/CallBackClient/callbackclient.Cpp Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • CallBackClient

callbackclient.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CallBackClient.cpp
00004
00005 Summary:  Demonstrates aggregation of the call object in order to recieve a
00006       callback on non-blocking method call completion
00007
00008 ----------------------------------------------------------------------------
00009
00010 This file is part of the Microsoft COM+ Samples.
00011
00012 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00013
00014 This source code is intended only as a supplement to Microsoft
00015 Development Tools and/or on-line documentation. See these other
00016 materials for detailed information regarding Microsoft code samples.
00017
00018 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00019 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00021 PARTICULAR PURPOSE.
00022
00023 ==========================================================================+*/
00024
00025 #include "stdafx.h"
00026 #include "CallBackClient.h"
00027 #include "FullSvr.h"
00028 #include <iostream.h>
00029 #include <conio.h>
00030
00031 int main(int argc, char* argv[])
00032 {
00033   UNREFERENCED_PARAMETER(argc);
00034   UNREFERENCED_PARAMETER(argv);
00035   HRESULT hr;
00036   ISynchronize * pISynchronize;
00037
00038   //Create an STA
00039   hr = CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
00040   _ASSERT(SUCCEEDED(hr));
00041
00042   //Create the call back component
00043   CComObject<CCallBack> * pCallBackObj = NULL;
00044   hr = CComObject<CCallBack>::CreateInstance(&pCallBackObj);
00045   _ASSERT(SUCCEEDED(hr));
00046
00047   //Get ISynchronize from our callback object
00048   hr = pCallBackObj->QueryInterface(IID_ISynchronize,(void**)&pISynchronize);
00049
00050
00051   //Start the non-blocking method call
00052   hr = pCallBackObj->StartCall(2,3);
00053   if(FAILED(hr)){
00054     cerr<<"StartCall Failed"<<endl;
00055   } else {
00056     //Enter message loop waiting for callback
00057     pISynchronize->Wait(0,INFINITE);
00058   }
00059
00060   pISynchronize->Release();
00061   CoUninitialize();
00062
00063   cout<<endl<<"Press Enter to continue..\n \n"<<endl;
00064   _getch();
00065
00066   return 0;
00067 }
00068
00069 //ATL unlock method.  Called during destruction of CCallBack
00070 CExeModule _Module;
00071 LONG CExeModule::Unlock()
00072 {
00073     return 0;
00074 }
00075
00076 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00077   Method:   CCallBack::StartCall
00078   Summary:  Starts a non-blocking method call and aggregates the call object
00079   Args:     [in] i,j the numbers to sum
00080   Returns:  HRESULT
00081 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00082 STDMETHODIMP CCallBack::StartCall(int i, int j){
00083
00084   HRESULT hr = S_OK;
00085   ICallFactory * pICallFactory = NULL;
00086   IUnknown * pIUnknown = NULL;
00087   AsyncIFullServ * pAsyncIFullServ = NULL;
00088
00089   //Create FullServ
00090   hr = CoCreateInstance(CLSID_FullServ,NULL,CLSCTX_SERVER,IID_IUnknown,(void**)&pIUnknown);
00091   if(FAILED(hr))
00092     return hr;
00093
00094   //Get ICallFactory
00095   hr = pIUnknown->QueryInterface(IID_ICallFactory,(void**)&pICallFactory);
00096   if(FAILED(hr))
00097     goto CleanUp;
00098
00099   //Create and aggregate the call object
00100   hr = pICallFactory->CreateCall(IID_AsyncIFullServ,GetControllingUnknown(),IID_IUnknown,(IUnknown**)&m_pCallObjUnk);
00101   if(FAILED(hr))
00102     goto CleanUp;
00103
00104   //Get the Async interface and begin the call
00105   hr = QueryInterface(IID_AsyncIFullServ,(void**)&pAsyncIFullServ);
00106   if(FAILED(hr))
00107     goto CleanUp;
00108
00109   hr = pAsyncIFullServ->Begin_Sum(i,j);
00110
00111   if(SUCCEEDED(hr))
00112   cout<<"Call sent to the server"<<endl;
00113
00114   //Release all but the call object's unk
00115 CleanUp:
00116   if(pIUnknown) pIUnknown->Release();
00117   if(pICallFactory) pICallFactory->Release();
00118   if(pAsyncIFullServ) pAsyncIFullServ->Release();
00119   return hr;
00120 }
00121
00122 /////////////////////////////////////////////////////////
00123 //ISynchronize
00124
00125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00126   Method:   CCallBack::Reset implementing ISynchronize::Reset
00127   Summary:  Passes through reset call to the contained synch object
00128 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00129 STDMETHODIMP CCallBack::Reset(){
00130   return smartPtrISynchronize->Reset();
00131 }
00132
00133 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00134   Method:   CCallBack::Wait implementing ISynchronize::Wait
00135   Summary:  Passes through wait call to the contained synch object
00136 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00137 STDMETHODIMP CCallBack::Wait(DWORD flags,DWORD timeout){
00138   return smartPtrISynchronize->Wait(flags,timeout);
00139 }
00140
00141 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00142   Method:   CCallBack::Signal implementing ISynchronize::Signal
00143   Summary:  Passes through signal call to the contained synch object
00144       then does the work of the call back. This method is the clients
00145       call back on completion of the non-blocking method call
00146   Note:   The client must pass through the signal call before continuing
00147       with the call back.
00148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00149 STDMETHODIMP CCallBack::Signal(){
00150   smartPtrISynchronize->Signal();
00151   CallBack();
00152   return S_OK;
00153 }
00154
00155 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00156   Method:   CCallBack::CallBack
00157   Summary:  upon recieving the call back this function finishes the non-blocking
00158       method call and displays the results
00159 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00160 STDMETHODIMP CCallBack::CallBack(){
00161
00162   HRESULT hr;
00163   AsyncIFullServ * pAsyncIFullServ;
00164   int i;
00165
00166   cout<<"Recieved a Call Back"<<endl;
00167
00168   //Get Async interface
00169   hr = QueryInterface(IID_AsyncIFullServ,(void**)&pAsyncIFullServ);
00170   _ASSERT(SUCCEEDED(hr));
00171
00172   //Finish the call
00173   hr = pAsyncIFullServ->Finish_Sum(&i);
00174   if(FAILED(hr)){
00175     cerr<<"Finish_Sum failed"<<endl;
00176   }else{
00177     cout<<"Sum of 2 and 3 is: "<<i<<endl;
00178   }
00179
00180   pAsyncIFullServ->Release();
00181
00182   return S_OK;
00183 }
00184
00185 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00186   Function: QueryFunc
00187   Summary:  this function acts as a hook into CCallBack's QueryInterface.
00188       This function simply passes the call to CCallBack::MyQuery
00189   Args:     pv - CCallBack
00190   Returns:  DWORD always returns 0
00191 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00192 HRESULT WINAPI QueryFunc(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw){
00193   UNREFERENCED_PARAMETER(dw);
00194   return ((CCallBack *)pv)->MyQuery(riid,ppv);
00195 }
00196
00197 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00198   Method:   CCallBack::MyQuery
00199   Summary:  CCallBack aggregates the call object, and therfore needs to pass
00200       QI calls to m_pCallObjUnk.  However, the call object isn't created
00201       until StartCall executes.  Therefore we use MyQuery to pass the QI
00202       calls to m_pCallObjUnk only when it is non-null
00203 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00204 //Pass QI to the call object if it has been created
00205 STDMETHODIMP CCallBack::MyQuery(REFIID riid, LPVOID* ppv){
00206
00207   if(!m_pCallObjUnk)
00208     return E_NOINTERFACE;
00209
00210   return m_pCallObjUnk->QueryInterface(riid,ppv);
00211 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/FileView/CStatHlp.h Source File

  • WinUI
  • Shell
  • FileView

CStatHlp.h

Go to the documentation of this file.
00001 //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1994 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  PROGRAM: CSTATHLP.H
00009 //
00010 //  PURPOSE: Class and structure definitions for the CStatusHelper class
00011 //  that manages messages to display in the status bar.
00012 //
00013 //  PLATFORMS:  Windows 95
00014 //
00015 //  SPECIAL INSTRUCTIONS: N/A
00016 //
00017 #ifndef _CSTATHLP_H_
00018 #define _CSTATHLP_H_
00019
00020
00021 //For loading the RCDATA mapping menu item IDs to string IDs
00022 typedef struct tagSTATMESSAGEMAP
00023     {
00024     USHORT      uID;
00025     USHORT      idsMsg;
00026     } STATMESSAGEMAP, *PSTATMESSAGEMAP;
00027
00028 //Array mapping menu handles to menu item IDs
00029 typedef struct tagPOPUPMENUMAP
00030     {
00031     HMENU       hMenu;
00032     USHORT      uID;
00033     } POPUPMENUMAP, *PPOPUPMENUMAP;
00034
00035
00036 /*
00037  * The CStatusHelper class simplifies run-time management of
00038  * status bar messages by setting up a mapping between popup
00039  * menu handles and item IDs to resource string IDs.  The
00040  * MenuSelect member processes any WM_MENUSELECT message
00041  * automatically to display the appropriate message.
00042  */
00043
00044 class CStatusHelper
00045     {
00046     protected:
00047         HWND                m_hWnd;             //hWnd of control
00048         HINSTANCE           m_hInst;            //Module instance
00049         BOOL                m_fMapped;          //MessageMap called?
00050         PCStringTable       m_pST;              //Message strings
00051
00052         UINT                m_uIDCur;           //Current displayed ID.
00053
00054         HWND                m_hWndOwner;        //Frame window
00055         USHORT              m_cMessages;        //Number of messages
00056         UINT                m_idsMin;           //Lowest string ID
00057         UINT                m_idsMax;           //Maximum string ID
00058
00059         USHORT              m_uIDStatic;        //Quiescent message ID
00060         USHORT              m_uIDBlank;         //Blank message ID
00061         USHORT              m_uIDSysMenu;       //System menu message ID
00062
00063         USHORT              m_cPopups;          //Number of menus
00064         USHORT              m_uIDPopupMin;      //Lowest menu ID
00065         USHORT              m_uIDPopupMax;      //Highest menu ID
00066
00067         HGLOBAL             m_hMemSMM;          //Mapping resource
00068         PSTATMESSAGEMAP     m_pSMM;             //Item to ID mapping
00069         PPOPUPMENUMAP       m_pPMM;             //Menu to ID mapping
00070
00071     public:
00072         CStatusHelper(HWND, HINSTANCE);
00073         ~CStatusHelper(void);
00074
00075         BOOL   MessageMap(HWND, UINT, UINT, UINT, UINT, UINT, UINT, UINT, UINT, UINT);
00076         void   MessageDisplay(UINT);
00077         void   MenuSelect(WORD, WORD, HMENU);
00078
00079     private:
00080         void   Sort(void);
00081         USHORT IDFromHMenu(HMENU);
00082         UINT   IStringFromID(USHORT);
00083
00084     };
00085
00086 typedef CStatusHelper *PCStatusHelper;
00087
00088
00089 #endif //_CSTATHLP_H_
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/RSM/mll/stl_mll.h Source File

  • WinBase
  • IO
  • RSM
  • mll

stl_mll.h

Go to the documentation of this file.
00001 /*
00002  *  This is a part of the Microsoft Source Code Samples.
00003  *  Copyright 1996 - 1998 Microsoft Corporation.
00004  *  All rights reserved.
00005  *
00006  *  This sample code shows the useage of some portions
00007  *  of the RSM API and MLL structure.
00008  *
00009  *
00010  */
00011
00012
00013 #include <ntmsmli.h>
00014
00015 #ifdef __cplusplus
00016 extern "C" {
00017 #endif  /* __cplusplus */
00018
00019 #define RSM_APPSAMPLE_LABEL_EXPORT __declspec(dllexport)
00020
00021 RSM_APPSAMPLE_LABEL_EXPORT DWORD WINAPI ClaimMediaLabel(const BYTE * const pBuffer,
00022               const DWORD nBufferSize,
00023               MediaLabelInfo * const pLabelInfo) ;
00024
00025 RSM_APPSAMPLE_LABEL_EXPORT DWORD WINAPI MaxMediaLabel(DWORD * const pMaxSize) ;
00026
00027 #ifdef __cplusplus
00028 }
00029 #endif
00030
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocServe/Factory.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocServe

Factory.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      FACTORY.CPP
00003
00004   Summary:   Implementation file for the ClassFactories of the LOCSERVE
00005              server.  This server provides several Car-related COM
00006              Components: Car, UtilityCar, and CruiseCar.  For each of
00007              these components, IClassFactory is implemented in
00008              appropriate ClassFactory COM objects: CFCar, CFUtilityCar,
00009              and CFCruiseCar. The COM Components that can be manufactured
00010              by this server are known outside the server by their
00011              respective CLSIDs: CLSID_LocCar, CLSID_LocUtilityCar,
00012              and CLSID_LocCruiseCar.
00013
00014              For a comprehensive tutorial code tour of this module's
00015              contents and offerings see the tutorial LOCSERVE.HTM file.
00016              For more specific technical details on the internal workings
00017              see the comments dispersed throughout the module's source code.
00018
00019   Classes:   CFCar, CFUtilityCar, CFCruiseCar
00020
00021   Functions: .
00022
00023   Origin:    1/29/98: atrent - Editor-inheritance from CAR.CPP in
00024                the DLLSERVE Tutorial Code Sample [Revised].
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 /*---------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will be calling the COM/OLE Libraries.
00044   We include APPUTIL.H because we will be building this EXE using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00048     class, GUID, and CLSID specifications.
00049   We include SERVER.H because it has the necessary internal class and
00050     resource definitions for this EXE.
00051   We include FACTORY.H because it has the necessary internal class factory
00052     declarations for this EXE component server.  Those factories we will be
00053     implementing in this module.
00054   We include CAR.H, UTILCAR,H, and, CRUCAR.H for the object class
00055     declarations for the COCar, COUtilityCar, and COCruiseCar COM objects.
00056 ---------------------------------------------------------------------------*/
00057 #include <windows.h>
00058 #include <ole2.h>
00059 #include <apputil.h>
00060 #include <micars.h>
00061 #include <carguids.h>
00062 #include "server.h"
00063 #include "factory.h"
00064 #include "car.h"
00065 #include "utilcar.h"
00066 #include "crucar.h"
00067
00068 /*---------------------------------------------------------------------------
00069   Implementation the CFCar Class Factory.  CFCar is the COM
00070   object class for the Class Factory that can manufacture COCar
00071   COM Components.
00072 ---------------------------------------------------------------------------*/
00073
00074 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00075   Method:   CFCar::CFCar
00076
00077   Summary:  CFCar Constructor. Note the member initializer:
00078             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00079             to pass the 'this', pUnkOuter, and pServer pointers of this
00080             constructor function to the constructor executed in the
00081             instantiation of the CImpIClassFactory interface whose
00082             implementation is nested inside this present object class.
00083
00084   Args:     IUnknown* pUnkOuter,
00085               Pointer to the the outer Unknown.  NULL means this COM Object
00086               is not being Aggregated.  Non NULL means it is being created
00087               on behalf of an outside COM object that is reusing it via
00088               aggregation.
00089             CServer* pServer)
00090               Pointer to the server's control object.
00091
00092   Modifies: m_cRefs, m_pUnkOuter.
00093
00094   Returns:  void
00095 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00096 CFCar::CFCar(
00097   IUnknown* pUnkOuter,
00098   CServer* pServer) :
00099   m_ImpIClassFactory(this, pUnkOuter, pServer)
00100 {
00101   // Zero the COM object's reference count.
00102   m_cRefs = 0;
00103
00104   // No AddRef necessary if non-NULL, as we're nested.
00105   m_pUnkOuter = pUnkOuter;
00106
00107   // Init the pointer to the server control object.
00108   m_pServer = pServer;
00109
00110   LOGF1("L: CFCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00111
00112   return;
00113 }
00114
00115
00116 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00117   Method:   CFCar::~CFCar
00118
00119   Summary:  CFCar Destructor.
00120
00121   Args:     void
00122
00123   Returns:  void
00124 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00125 CFCar::~CFCar(void)
00126 {
00127   LOG("L: CFCar::Destructor.");
00128
00129   return;
00130 }
00131
00132
00133 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00134   Method:   CFCar::QueryInterface
00135
00136   Summary:  QueryInterface of the CFCar non-delegating
00137             IUnknown implementation.
00138
00139   Args:     REFIID riid,
00140               [in] GUID of the Interface being requested.
00141             PPVOID ppv)
00142               [out] Address of the caller's pointer variable that will
00143               receive the requested interface pointer.
00144
00145   Returns:  HRESULT
00146               Standard result code. NOERROR for success.
00147 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00148 STDMETHODIMP CFCar::QueryInterface(
00149                REFIID riid,
00150                PPVOID ppv)
00151 {
00152   HRESULT hr = E_NOINTERFACE;
00153   *ppv = NULL;
00154
00155   if (IID_IUnknown == riid)
00156   {
00157     *ppv = this;
00158     LOG("L: CFCar::QueryInterface. 'this' pIUnknown returned.");
00159   }
00160   else if (IID_IClassFactory == riid)
00161   {
00162     *ppv = &m_ImpIClassFactory;
00163     LOG("L: CFCar::QueryInterface. pIClassFactory returned.");
00164   }
00165
00166   if (NULL != *ppv)
00167   {
00168     // We've handed out a pointer to the interface so obey the COM rules
00169     // and AddRef the reference count.
00170     ((LPUNKNOWN)*ppv)->AddRef();
00171     hr = NOERROR;
00172   }
00173
00174   return (hr);
00175 }
00176
00177
00178 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00179   Method:   CFCar::AddRef
00180
00181   Summary:  AddRef of the CFCar non-delegating IUnknown implementation.
00182
00183   Args:     void
00184
00185   Modifies: m_cRefs.
00186
00187   Returns:  ULONG
00188               New value of m_cRefs (COM object's reference count).
00189 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00190 STDMETHODIMP_(ULONG) CFCar::AddRef(void)
00191 {
00192   InterlockedIncrement((PLONG) &m_cRefs);
00193
00194   LOGF1("L: CFCar::AddRef. New cRefs=%i.", m_cRefs);
00195
00196   return m_cRefs;
00197 }
00198
00199
00200 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00201   Method:   CFCar::Release
00202
00203   Summary:  Release of the CFCar non-delegating IUnknown implementation.
00204
00205   Args:     void
00206
00207   Modifies: m_cRefs.
00208
00209   Returns:  ULONG
00210               New value of m_cRefs (COM object's reference count).
00211 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00212 STDMETHODIMP_(ULONG) CFCar::Release(void)
00213 {
00214   ULONG cRefs;
00215   InterlockedDecrement((PLONG) &m_cRefs);
00216   cRefs = m_cRefs;
00217
00218   LOGF1("L: CFCar::Release. New cRefs=%i.", m_cRefs);
00219
00220   if (0 == m_cRefs)
00221   {
00222     // We artificially bump the main ref count to prevent reentrancy
00223     // via the main object destructor.  Not really needed in this
00224     // CFCar but a good practice because we are aggregatable and
00225     // may at some point in the future add something entertaining like
00226     // some Releases to the CFCar destructor.
00227     InterlockedIncrement((PLONG) &m_cRefs);
00228     delete this;
00229   }
00230
00231   return cRefs;
00232 }
00233
00234
00235 /*---------------------------------------------------------------------------
00236   CFCar's nested implementation of the IClassFactory interface
00237   including Constructor, Destructor, QueryInterface, AddRef, Release,
00238   CreateInstance, and LockServer methods.
00239 ---------------------------------------------------------------------------*/
00240
00241 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00242   Method:   CFCar::CImpIClassFactory::CImpIClassFactory
00243
00244   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00245
00246   Args:     CFCar* pBackObj,
00247               Back pointer to the parent outer object.
00248             IUnknown* pUnkOuter,
00249               Pointer to the outer Unknown.  For delegation.
00250             CServer* pServer)
00251               Pointer to the server's control object.
00252
00253   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
00254
00255   Returns:  void
00256 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00257 CFCar::CImpIClassFactory::CImpIClassFactory(
00258   CFCar* pBackObj,
00259   IUnknown* pUnkOuter,
00260   CServer* pServer)
00261 {
00262   // Init the Interface Ref Count (used for debugging only).
00263   m_cRefI = 0;
00264
00265   // Init the Back Object Pointer to point to the parent object.
00266   m_pBackObj = pBackObj;
00267
00268   // Init the pointer to the server control object.
00269   m_pServer = pServer;
00270
00271   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00272   // We use the Back Object pointer for IUnknown delegation here if we are
00273   // not being aggregated.  If we are being aggregated we use the supplied
00274   // pUnkOuter for IUnknown delegation.  In either case the pointer
00275   // assignment requires no AddRef because the CImpIClassFactory lifetime is
00276   // quaranteed by the lifetime of the parent object in which
00277   // CImpIClassFactory is nested.
00278   if (NULL == pUnkOuter)
00279   {
00280     m_pUnkOuter = pBackObj;
00281     LOG("L: CFCar::CImpIClassFactory Constructor. Non-Aggregating.");
00282   }
00283   else
00284   {
00285     m_pUnkOuter = pUnkOuter;
00286     LOG("L: CFCar::CImpIClassFactory Constructor. Aggregating.");
00287   }
00288
00289   return;
00290 }
00291
00292
00293 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00294   Method:   CFCar::CImpIClassFactory::~CImpIClassFactory
00295
00296   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00297
00298   Args:     void
00299
00300   Returns:  void
00301 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00302 CFCar::CImpIClassFactory::~CImpIClassFactory(void)
00303 {
00304   LOG("L: CFCar::CImpIClassFactory Destructor.");
00305
00306   return;
00307 }
00308
00309
00310 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00311   Method:   CFCar::CImpIClassFactory::QueryInterface
00312
00313   Summary:  The QueryInterface IUnknown member of this IClassFactory
00314             interface implementation that delegates to m_pUnkOuter,
00315             whatever it is.
00316
00317   Args:     REFIID riid,
00318               [in] GUID of the Interface being requested.
00319             PPVOID ppv)
00320               [out] Address of the caller's pointer variable that will
00321               receive the requested interface pointer.
00322
00323   Returns:  HRESULT
00324               Standard result code. NOERROR for success.
00325               Returned by the delegated outer QueryInterface call.
00326 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00327 STDMETHODIMP CFCar::CImpIClassFactory::QueryInterface(
00328                REFIID riid,
00329                PPVOID ppv)
00330 {
00331   LOG("L: CFCar::CImpIClassFactory::QueryInterface. Delegating.");
00332
00333   // Delegate this call to the outer object's QueryInterface.
00334   return m_pUnkOuter->QueryInterface(riid, ppv);
00335 }
00336
00337
00338 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00339   Method:   CFCar::CImpIClassFactory::AddRef
00340
00341   Summary:  The AddRef IUnknown member of this IClassFactory interface
00342             implementation that delegates to m_pUnkOuter, whatever it is.
00343
00344   Args:     void
00345
00346   Modifies: m_cRefI.
00347
00348   Returns:  ULONG
00349               Returned by the delegated outer AddRef call.
00350 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00351 STDMETHODIMP_(ULONG) CFCar::CImpIClassFactory::AddRef(void)
00352 {
00353   // Increment the Interface Reference Count.
00354   InterlockedIncrement((PLONG) &m_cRefI);
00355
00356   LOGF1("L: CFCar::CImpIClassFactory::Addref. Delegating. New cI=%i.",m_cRefI);
00357
00358   // Delegate this call to the outer object's AddRef.
00359   return m_pUnkOuter->AddRef();
00360 }
00361
00362
00363 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00364   Method:   CFCar::CImpIClassFactory::Release
00365
00366   Summary:  The Release IUnknown member of this IClassFactory interface
00367             implementation that delegates to m_pUnkOuter, whatever it is.
00368
00369   Args:     void
00370
00371   Returns:  ULONG
00372               Returned by the delegated outer Release call.
00373 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00374 STDMETHODIMP_(ULONG) CFCar::CImpIClassFactory::Release(void)
00375 {
00376   // Decrement the Interface Reference Count.
00377   InterlockedDecrement((PLONG) &m_cRefI);
00378
00379   LOGF1("L: CFCar::CImpIClassFactory::Release. Delegating. New cI=%i.",m_cRefI);
00380
00381   // Delegate this call to the outer object's Release.
00382   return m_pUnkOuter->Release();
00383 }
00384
00385
00386 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00387   Method:   CFCar::CImpIClassFactory::CreateInstance
00388
00389   Summary:  The CreateInstance member method of this IClassFactory interface
00390             implementation.  Creates an instance of the COCar COM
00391             component.
00392
00393   Args:     IUnknown* pUnkOuter,
00394               [in] Pointer to the controlling IUnknown.
00395             REFIID riid,
00396               [in] GUID of the Interface being requested.
00397             PPVOID ppvCob)
00398               [out] Address of the caller's pointer variable that will
00399               receive the requested interface pointer.
00400
00401   Returns:  HRESULT
00402               Standard result code. NOERROR for success.
00403 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00404 STDMETHODIMP CFCar::CImpIClassFactory::CreateInstance(
00405                IUnknown* pUnkOuter,
00406                REFIID riid,
00407                PPVOID ppv)
00408 {
00409   HRESULT hr = E_FAIL;
00410   COCar* pCob = NULL;
00411
00412   LOGF1("L: CFCar::CImpIClassFactory::CreateInstance. pUnkOuter=0x%X.",pUnkOuter);
00413
00414   // NULL the output pointer.
00415   *ppv = NULL;
00416
00417   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00418   // the COM rules state the IUnknown interface MUST also be concomitantly
00419   // requested.  If it is not so requested (riid != IID_IUnknown) then
00420   // an error must be returned indicating that no aggregate creation of
00421   // the CFCar COM Object can be performed.
00422   if (NULL != pUnkOuter && riid != IID_IUnknown)
00423     hr = CLASS_E_NOAGGREGATION;
00424   else
00425   {
00426     // Instantiate a COCar COM Object.
00427     pCob = new COCar(pUnkOuter, m_pServer);
00428     if (NULL != pCob)
00429     {
00430       // We initially created the new COM object so tell the server
00431       // to increment its global server object count to help ensure
00432       // that the server remains loaded until this partial creation
00433       // of a COM component is completed.
00434       m_pServer->ObjectsUp();
00435
00436       // We QueryInterface this new COM Object not only to deposit the
00437       // main interface pointer to the caller's pointer variable, but to
00438       // also automatically bump the Reference Count on the new COM
00439       // Object after handing out this reference to it.
00440       hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00441       if (FAILED(hr))
00442       {
00443         delete pCob;
00444         m_pServer->ObjectsDown();
00445       }
00446     }
00447     else
00448     {
00449       // If we were launched to create this object and could not then
00450       // we should force a shutdown of this server.
00451       m_pServer->ObjectsUp();
00452       m_pServer->ObjectsDown();
00453       hr = E_OUTOFMEMORY;
00454     }
00455   }
00456
00457   if (SUCCEEDED(hr))
00458   {
00459     LOGF1("L: CFCar::CImpIClassFactory::CreateInstance Succeeded. *ppv=0x%X.",*ppv);
00460   }
00461   else
00462   {
00463     LOG("L: CFCar::CImpIClassFactory::CreateInstance Failed.");
00464   }
00465
00466   return hr;
00467 }
00468
00469
00470 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00471   Method:   CFCar::CImpIClassFactory::LockServer
00472
00473   Summary:  The LockServer member method of this IClassFactory interface
00474             implementation.
00475
00476   Args:     BOOL fLock)
00477               [in] Flag determining whether to Lock or Unlock the server.
00478
00479   Returns:  HRESULT
00480               Standard result code. NOERROR for success.
00481 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00482 STDMETHODIMP CFCar::CImpIClassFactory::LockServer(
00483                BOOL fLock)
00484 {
00485   HRESULT hr = NOERROR;
00486
00487   LOG("L: CFCar::CImpIClassFactory::LockServer.");
00488
00489   if (fLock)
00490     m_pServer->Lock();
00491   else
00492     m_pServer->Unlock();
00493
00494   return hr;
00495 }
00496
00497
00498 /*---------------------------------------------------------------------------
00499   Implementation the CFUtilityCar Class Factory.  CFUtilityCar is the COM
00500   object class for the Class Factory that can manufacture COUtilityCar
00501   COM Components.
00502 ---------------------------------------------------------------------------*/
00503
00504 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00505   Method:   CFUtilityCar::CFUtilityCar
00506
00507   Summary:  CFUtilityCar Constructor. Note the member initializer:
00508             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00509             to pass the 'this', pUnkOuter, and pServer pointers of this
00510             constructor function to the constructor executed in the
00511             instantiation of the CImpIClassFactory interface whose
00512             implementation is nested inside this present object class.
00513
00514   Args:     IUnknown* pUnkOuter,
00515               Pointer to the the outer Unknown.  NULL means this COM Object
00516               is not being Aggregated.  Non NULL means it is being created
00517               on behalf of an outside COM object that is reusing it via
00518               aggregation.
00519             CServer* pServer)
00520               Pointer to the server's control object.
00521
00522   Modifies: m_cRefs, m_pUnkOuter.
00523
00524   Returns:  void
00525 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00526 CFUtilityCar::CFUtilityCar(
00527   IUnknown* pUnkOuter,
00528   CServer* pServer) :
00529   m_ImpIClassFactory(this, pUnkOuter, pServer)
00530 {
00531   // Zero the COM object's reference count.
00532   m_cRefs = 0;
00533
00534   // No AddRef necessary if non-NULL, as we're nested.
00535   m_pUnkOuter = pUnkOuter;
00536
00537   // Init the pointer to the server control object.
00538   m_pServer = pServer;
00539
00540   LOGF1("L: CFUtilityCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00541
00542   return;
00543 }
00544
00545
00546 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00547   Method:   CFUtilityCar::~CFUtilityCar
00548
00549   Summary:  CFUtilityCar Destructor.
00550
00551   Args:     void
00552
00553   Returns:  void
00554 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00555 CFUtilityCar::~CFUtilityCar(void)
00556 {
00557   LOG("L: CFUtilityCar::Destructor.");
00558
00559   return;
00560 }
00561
00562
00563 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00564   Method:   CFUtilityCar::QueryInterface
00565
00566   Summary:  QueryInterface of the CFUtilityCar non-delegating
00567             IUnknown implementation.
00568
00569   Args:     REFIID riid,
00570               [in] GUID of the Interface being requested.
00571             PPVOID ppv)
00572               [out] Address of the caller's pointer variable that will
00573               receive the requested interface pointer.
00574
00575   Returns:  HRESULT
00576               Standard result code. NOERROR for success.
00577 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00578 STDMETHODIMP CFUtilityCar::QueryInterface(
00579                REFIID riid,
00580                PPVOID ppv)
00581 {
00582   HRESULT hr = E_NOINTERFACE;
00583   *ppv = NULL;
00584
00585   if (IID_IUnknown == riid)
00586   {
00587     *ppv = this;
00588     LOG("L: CFUtilityCar::QueryInterface. 'this' pIUnknown returned.");
00589   }
00590   else if (IID_IClassFactory == riid)
00591   {
00592     *ppv = &m_ImpIClassFactory;
00593     LOG("L: CFUtilityCar::QueryInterface. pIClassFactory returned.");
00594   }
00595
00596   if (NULL != *ppv)
00597   {
00598     // We've handed out a pointer to the interface so obey the COM rules
00599     //   and AddRef the reference count.
00600     ((LPUNKNOWN)*ppv)->AddRef();
00601     hr = NOERROR;
00602   }
00603
00604   return (hr);
00605 }
00606
00607
00608 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00609   Method:   CFUtilityCar::AddRef
00610
00611   Summary:  AddRef of the CFUtilityCar non-delegating IUnknown implementation.
00612
00613   Args:     void
00614
00615   Modifies: m_cRefs.
00616
00617   Returns:  ULONG
00618               New value of m_cRefs (COM object's reference count).
00619 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00620 STDMETHODIMP_(ULONG) CFUtilityCar::AddRef(void)
00621 {
00622   InterlockedIncrement((PLONG) &m_cRefs);
00623
00624   LOGF1("L: CFUtilityCar::AddRef. New cRefs=%i.", m_cRefs);
00625
00626   return m_cRefs;
00627 }
00628
00629
00630 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00631   Method:   CFUtilityCar::Release
00632
00633   Summary:  Release of the CFUtilityCar non-delegating IUnknown implementation.
00634
00635   Args:     void
00636
00637   Modifies: m_cRefs.
00638
00639   Returns:  ULONG
00640               New value of m_cRefs (COM object's reference count).
00641 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00642 STDMETHODIMP_(ULONG) CFUtilityCar::Release(void)
00643 {
00644   ULONG cRefs;
00645   InterlockedDecrement((PLONG) &m_cRefs);
00646   cRefs = m_cRefs;
00647
00648   LOGF1("L: CFUtilityCar::Release. New cRefs=%i.", m_cRefs);
00649
00650   if (0 == m_cRefs)
00651   {
00652     // We artificially bump the main ref count to prevent reentrancy
00653     // via the main object destructor.  Not really needed in this
00654     // CFUtilityCar but a good practice because we are aggregatable and
00655     // may at some point in the future add something entertaining like
00656     // some Releases to the CFUtilityCar destructor.
00657     InterlockedIncrement((PLONG) &m_cRefs);
00658     delete this;
00659   }
00660
00661   return cRefs;
00662 }
00663
00664
00665 /*---------------------------------------------------------------------------
00666   CFUtilityCar's nested implementation of the IClassFactory interface
00667   including Constructor, Destructor, QueryInterface, AddRef, Release,
00668   CreateInstance, and LockServer methods.
00669 ---------------------------------------------------------------------------*/
00670
00671 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00672   Method:   CFUtilityCar::CImpIClassFactory::CImpIClassFactory
00673
00674   Summary:  Constructor for the CImpIClassFactory interface instantiation.
00675
00676   Args:     CFUtilityCar* pBackObj,
00677               Back pointer to the parent outer object.
00678             IUnknown* pUnkOuter,
00679               Pointer to the outer Unknown.  For delegation.
00680             CServer* pServer)
00681               Pointer to the server's control object.
00682
00683   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
00684
00685   Returns:  void
00686 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00687 CFUtilityCar::CImpIClassFactory::CImpIClassFactory(
00688   CFUtilityCar* pBackObj,
00689   IUnknown* pUnkOuter,
00690   CServer* pServer)
00691 {
00692   // Init the Interface Ref Count (used for debugging only).
00693   m_cRefI = 0;
00694
00695   // Init the Back Object Pointer to point to the parent object.
00696   m_pBackObj = pBackObj;
00697
00698   // Init the pointer to the server control object.
00699   m_pServer = pServer;
00700
00701   // Init the CImpIClassFactory interface's delegating Unknown pointer.
00702   // We use the Back Object pointer for IUnknown delegation here if we are
00703   // not being aggregated.  If we are being aggregated we use the supplied
00704   // pUnkOuter for IUnknown delegation.  In either case the pointer
00705   // assignment requires no AddRef because the CImpIClassFactory lifetime is
00706   // quaranteed by the lifetime of the parent object in which
00707   // CImpIClassFactory is nested.
00708   if (NULL == pUnkOuter)
00709   {
00710     m_pUnkOuter = pBackObj;
00711     LOG("L: CFUtilityCar::CImpIClassFactory Constructor. Non-Aggregating.");
00712   }
00713   else
00714   {
00715     m_pUnkOuter = pUnkOuter;
00716     LOG("L: CFUtilityCar::CImpIClassFactory Constructor. Aggregating.");
00717   }
00718
00719   return;
00720 }
00721
00722
00723 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00724   Method:   CFUtilityCar::CImpIClassFactory::~CImpIClassFactory
00725
00726   Summary:  Destructor for the CImpIClassFactory interface instantiation.
00727
00728   Args:     void
00729
00730   Returns:  void
00731 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00732 CFUtilityCar::CImpIClassFactory::~CImpIClassFactory(void)
00733 {
00734   LOG("L: CFUtilityCar::CImpIClassFactory Destructor.");
00735
00736   return;
00737 }
00738
00739
00740 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00741   Method:   CFUtilityCar::CImpIClassFactory::QueryInterface
00742
00743   Summary:  The QueryInterface IUnknown member of this IClassFactory
00744             interface implementation that delegates to m_pUnkOuter,
00745             whatever it is.
00746
00747   Args:     REFIID riid,
00748               [in] GUID of the Interface being requested.
00749             PPVOID ppv)
00750               [out] Address of the caller's pointer variable that will
00751               receive the requested interface pointer.
00752
00753   Returns:  HRESULT
00754               Standard result code. NOERROR for success.
00755               Returned by the delegated outer QueryInterface call.
00756 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00757 STDMETHODIMP CFUtilityCar::CImpIClassFactory::QueryInterface(
00758                REFIID riid,
00759                PPVOID ppv)
00760 {
00761   LOG("L: CFUtilityCar::CImpIClassFactory::QueryInterface. Delegating.");
00762
00763   // Delegate this call to the outer object's QueryInterface.
00764   return m_pUnkOuter->QueryInterface(riid, ppv);
00765 }
00766
00767
00768 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00769   Method:   CFUtilityCar::CImpIClassFactory::AddRef
00770
00771   Summary:  The AddRef IUnknown member of this IClassFactory interface
00772             implementation that delegates to m_pUnkOuter, whatever it is.
00773
00774   Args:     void
00775
00776   Modifies: m_cRefI.
00777
00778   Returns:  ULONG
00779               Returned by the delegated outer AddRef call.
00780 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00781 STDMETHODIMP_(ULONG) CFUtilityCar::CImpIClassFactory::AddRef(void)
00782 {
00783   // Increment the Interface Reference Count.
00784   InterlockedIncrement((PLONG) &m_cRefI);
00785
00786   LOGF1("L: CFUtilityCar::CImpIClassFactory::Addref. Delegating. New cI=%i.",m_cRefI);
00787
00788   // Delegate this call to the outer object's AddRef.
00789   return m_pUnkOuter->AddRef();
00790 }
00791
00792
00793 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00794   Method:   CFUtilityCar::CImpIClassFactory::Release
00795
00796   Summary:  The Release IUnknown member of this IClassFactory interface
00797             implementation that delegates to m_pUnkOuter, whatever it is.
00798
00799   Args:     void
00800
00801   Returns:  ULONG
00802               Returned by the delegated outer Release call.
00803 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00804 STDMETHODIMP_(ULONG) CFUtilityCar::CImpIClassFactory::Release(void)
00805 {
00806   // Decrement the Interface Reference Count.
00807   InterlockedDecrement((PLONG) &m_cRefI);
00808
00809   LOGF1("L: CFUtilityCar::CImpIClassFactory::Release. Delegating. New cI=%i.",m_cRefI);
00810
00811   // Delegate this call to the outer object's Release.
00812   return m_pUnkOuter->Release();
00813 }
00814
00815
00816 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00817   Method:   CFUtilityCar::CImpIClassFactory::CreateInstance
00818
00819   Summary:  The CreateInstance member method of this IClassFactory interface
00820             implementation.  Creates an instance of the COUtilityCar COM
00821             component.
00822
00823   Args:     IUnknown* pUnkOuter,
00824               [in] Pointer to the controlling IUnknown.
00825             REFIID riid,
00826               [in] GUID of the Interface being requested.
00827             PPVOID ppvCob)
00828               [out] Address of the caller's pointer variable that will
00829               receive the requested interface pointer.
00830
00831   Returns:  HRESULT
00832               Standard result code. NOERROR for success.
00833 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00834 STDMETHODIMP CFUtilityCar::CImpIClassFactory::CreateInstance(
00835                IUnknown* pUnkOuter,
00836                REFIID riid,
00837                PPVOID ppv)
00838 {
00839   HRESULT hr = E_FAIL;
00840   COUtilityCar* pCob = NULL;
00841
00842   LOGF1("L: CFUtilityCar::CImpIClassFactory::CreateInstance. pUnkOuter=0x%X.",pUnkOuter);
00843
00844   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00845   // the COM rules state the IUnknown interface MUST also be concomitantly
00846   // requested.  If it is not so requested ( riid != IID_IUnknown) then
00847   // an error must be returned indicating that no aggregate creation of
00848   // the COUtilityCar COM Object can be performed.
00849   if (NULL != pUnkOuter && riid != IID_IUnknown)
00850     hr = CLASS_E_NOAGGREGATION;
00851   else
00852   {
00853     // Instantiate a COUtilityCar COM Object.
00854     pCob = new COUtilityCar(pUnkOuter, m_pServer);
00855     if (NULL != pCob)
00856     {
00857       // We initially created the new COM object so tell the server
00858       // to increment its global server object count to help ensure
00859       // that the server remains loaded until this partial creation
00860       // of a COM component is completed.
00861       m_pServer->ObjectsUp();
00862
00863       // If we have succeeded in instantiating the COM object we
00864       // initialize it to set up any subordinate objects.
00865       hr = pCob->Init();
00866       if (SUCCEEDED(hr))
00867       {
00868         // We QueryInterface this new COM Object not only to deposit the
00869         // main interface pointer to the caller's pointer variable, but to
00870         // also automatically bump the Reference Count on the new COM
00871         // Object after handing out this reference to it.
00872         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00873       }
00874
00875       if (FAILED(hr))
00876       {
00877         delete pCob;
00878         m_pServer->ObjectsDown();
00879       }
00880     }
00881     else
00882     {
00883       // If we were launched to create this object and could not then
00884       // we should force a shutdown of this server.
00885       m_pServer->ObjectsUp();
00886       m_pServer->ObjectsDown();
00887       hr = E_OUTOFMEMORY;
00888     }
00889   }
00890
00891   if (SUCCEEDED(hr))
00892   {
00893     LOGF1("L: CFUtilityCar::CImpIClassFactory::CreateInstance Succeeded. *ppv=0x%X.",*ppv);
00894   }
00895   else
00896   {
00897     LOG("L: CFUtilityCar::CImpIClassFactory::CreateInstance Failed.");
00898   }
00899
00900   return hr;
00901 }
00902
00903
00904 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00905   Method:   CFUtilityCar::CImpIClassFactory::LockServer
00906
00907   Summary:  The LockServer member method of this IClassFactory interface
00908             implementation.
00909
00910   Args:     BOOL fLock)
00911               [in] Flag determining whether to Lock or Unlock the server.
00912
00913   Returns:  HRESULT
00914               Standard result code. NOERROR for success.
00915 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00916 STDMETHODIMP CFUtilityCar::CImpIClassFactory::LockServer(
00917                BOOL fLock)
00918 {
00919   HRESULT hr = NOERROR;
00920
00921   LOG("L: CFUtilityCar::CImpIClassFactory::LockServer.");
00922
00923   if (fLock)
00924     m_pServer->Lock();
00925   else
00926     m_pServer->Unlock();
00927
00928   return hr;
00929 }
00930
00931
00932 /*---------------------------------------------------------------------------
00933   Implementation the CFCruiseCar Class Factory.  CFCruiseCar is the COM
00934   object class for the Class Factory that can manufacture COCruiseCar
00935   COM Components.
00936 ---------------------------------------------------------------------------*/
00937
00938 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00939   Method:   CFCruiseCar::CFCruiseCar
00940
00941   Summary:  CFCruiseCar Constructor. Note the member initializer:
00942             "m_ImpIClassFactory(this, pUnkOuter, pServer)" which is used
00943             to pass the 'this', pUnkOuter, and pServer pointers of this
00944             constructor function to the constructor executed in the
00945             instantiation of the CImpIClassFactory interface whose
00946             implementation is nested inside this present object class.
00947
00948   Args:     IUnknown* pUnkOuter,
00949               Pointer to the the outer Unknown.  NULL means this COM Object
00950               is not being Aggregated.  Non NULL means it is being created
00951               on behalf of an outside COM object that is reusing it via
00952               aggregation.
00953             CServer* pServer)
00954               Pointer to the server's control object.
00955
00956   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00957
00958   Returns:  void
00959 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00960 CFCruiseCar::CFCruiseCar(
00961   IUnknown* pUnkOuter,
00962   CServer* pServer) :
00963   m_ImpIClassFactory(this, pUnkOuter, pServer)
00964 {
00965   // Zero the COM object's reference count.
00966   m_cRefs = 0;
00967
00968   // No AddRef necessary if non-NULL, as we're nested.
00969   m_pUnkOuter = pUnkOuter;
00970
00971   // Init the pointer to the server control object.
00972   m_pServer = pServer;
00973
00974   LOGF1("L: CFCruiseCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00975
00976   return;
00977 }
00978
00979
00980 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00981   Method:   CFCruiseCar::~CFCruiseCar
00982
00983   Summary:  CFCruiseCar Destructor.
00984
00985   Args:     void
00986
00987   Returns:  void
00988 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00989 CFCruiseCar::~CFCruiseCar(void)
00990 {
00991   LOG("L: CFCruiseCar::Destructor.");
00992
00993   return;
00994 }
00995
00996
00997 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00998   Method:   CFCruiseCar::QueryInterface
00999
01000   Summary:  QueryInterface of the CFCruiseCar non-delegating
01001             IUnknown implementation.
01002
01003   Args:     REFIID riid,
01004               [in] GUID of the Interface being requested.
01005             PPVOID ppv)
01006               [out] Address of the caller's pointer variable that will
01007               receive the requested interface pointer.
01008
01009   Returns:  HRESULT
01010               Standard result code. NOERROR for success.
01011 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01012 STDMETHODIMP CFCruiseCar::QueryInterface(
01013                REFIID riid,
01014                PPVOID ppv)
01015 {
01016   HRESULT hr = E_NOINTERFACE;
01017   *ppv = NULL;
01018
01019   if (IID_IUnknown == riid)
01020   {
01021     *ppv = this;
01022     LOG("L: CFCruiseCar::QueryInterface. 'this' pIUnknown returned.");
01023   }
01024   else if (IID_IClassFactory == riid)
01025   {
01026     *ppv = &m_ImpIClassFactory;
01027     LOG("L: CFCruiseCar::QueryInterface. pIClassFactory returned.");
01028   }
01029
01030   if (NULL != *ppv)
01031   {
01032     // We've handed out a pointer to the interface so obey the COM rules
01033     // and AddRef the reference count.
01034     ((LPUNKNOWN)*ppv)->AddRef();
01035     hr = NOERROR;
01036   }
01037
01038   return (hr);
01039 }
01040
01041
01042 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01043   Method:   CFCruiseCar::AddRef
01044
01045   Summary:  AddRef of the CFCruiseCar non-delegating IUnknown implementation.
01046
01047   Args:     void
01048
01049   Modifies: m_cRefs.
01050
01051   Returns:  ULONG
01052               New value of m_cRefs (COM object's reference count).
01053 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01054 STDMETHODIMP_(ULONG) CFCruiseCar::AddRef(void)
01055 {
01056   InterlockedIncrement((PLONG) &m_cRefs);
01057
01058   LOGF1("L: CFCruiseCar::AddRef. New cRefs=%i.", m_cRefs);
01059
01060   return m_cRefs;
01061 }
01062
01063
01064 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01065   Method:   CFCruiseCar::Release
01066
01067   Summary:  Release of the CFCruiseCar non-delegating IUnknown implementation.
01068
01069   Args:     void
01070
01071   Modifies: m_cRefs.
01072
01073   Returns:  ULONG
01074               New value of m_cRefs (COM object's reference count).
01075 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01076 STDMETHODIMP_(ULONG) CFCruiseCar::Release(void)
01077 {
01078   ULONG cRefs;
01079   InterlockedDecrement((PLONG) &m_cRefs);
01080   cRefs = m_cRefs;
01081
01082   LOGF1("L: CFCruiseCar::Release. New cRefs=%i.", m_cRefs);
01083
01084   if (0 == m_cRefs)
01085   {
01086     // We artificially bump the main ref count to prevent reentrancy
01087     // via the main object destructor.  Not really needed in this
01088     // CFCruiseCar but a good practice because we are aggregatable and
01089     // may at some point in the future add something entertaining like
01090     // some Releases to the CFCruiseCar destructor.
01091     InterlockedIncrement((PLONG) &m_cRefs);
01092     delete this;
01093   }
01094
01095   return cRefs;
01096 }
01097
01098
01099 /*---------------------------------------------------------------------------
01100   CFCruiseCar's nested implementation of the IClassFactory interface
01101   including Constructor, Destructor, QueryInterface, AddRef, Release,
01102   CreateInstance, and LockServer methods.
01103 ---------------------------------------------------------------------------*/
01104
01105 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01106   Method:   CFCruiseCar::CImpIClassFactory::CImpIClassFactory
01107
01108   Summary:  Constructor for the CImpIClassFactory interface instantiation.
01109
01110   Args:     CFCruiseCar* pBackObj,
01111               Back pointer to the parent outer object.
01112             IUnknown* pUnkOuter,
01113               Pointer to the outer Unknown.  For delegation.
01114             CServer* pServer)
01115               Pointer to the server's control object.
01116
01117   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter, m_pServer.
01118
01119   Returns:  void
01120 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01121 CFCruiseCar::CImpIClassFactory::CImpIClassFactory(
01122   CFCruiseCar* pBackObj,
01123   IUnknown* pUnkOuter,
01124   CServer* pServer)
01125 {
01126   // Init the Interface Ref Count (used for debugging only).
01127   m_cRefI = 0;
01128
01129   // Init the Back Object Pointer to point to the parent object.
01130   m_pBackObj = pBackObj;
01131
01132   // Init the pointer to the server control object.
01133   m_pServer = pServer;
01134
01135   // Init the CImpIClassFactory interface's delegating Unknown pointer.
01136   // We use the Back Object pointer for IUnknown delegation here if we are
01137   // not being aggregated.  If we are being aggregated we use the supplied
01138   // pUnkOuter for IUnknown delegation.  In either case the pointer
01139   // assignment requires no AddRef because the CImpIClassFactory lifetime is
01140   // quaranteed by the lifetime of the parent object in which
01141   // CImpIClassFactory is nested.
01142   if (NULL == pUnkOuter)
01143   {
01144     m_pUnkOuter = pBackObj;
01145     LOG("L: CFCruiseCar::CImpIClassFactory Constructor. Non-Aggregating.");
01146   }
01147   else
01148   {
01149     m_pUnkOuter = pUnkOuter;
01150     LOG("L: CFCruiseCar::CImpIClassFactory Constructor. Aggregating.");
01151   }
01152
01153   return;
01154 }
01155
01156
01157 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01158   Method:   CFCruiseCar::CImpIClassFactory::~CImpIClassFactory
01159
01160   Summary:  Destructor for the CImpIClassFactory interface instantiation.
01161
01162   Args:     void
01163
01164   Returns:  void
01165 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01166 CFCruiseCar::CImpIClassFactory::~CImpIClassFactory(void)
01167 {
01168   LOG("L: CFCruiseCar::CImpIClassFactory Destructor.");
01169
01170   return;
01171 }
01172
01173
01174 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01175   Method:   CFCruiseCar::CImpIClassFactory::QueryInterface
01176
01177   Summary:  The QueryInterface IUnknown member of this IClassFactory
01178             interface implementation that delegates to m_pUnkOuter,
01179             whatever it is.
01180
01181   Args:     REFIID riid,
01182               [in] GUID of the Interface being requested.
01183             PPVOID ppv)
01184               [out] Address of the caller's pointer variable that will
01185               receive the requested interface pointer.
01186
01187   Returns:  HRESULT
01188               Standard result code. NOERROR for success.
01189               Returned by the delegated outer QueryInterface call.
01190 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01191 STDMETHODIMP CFCruiseCar::CImpIClassFactory::QueryInterface(
01192                REFIID riid,
01193                PPVOID ppv)
01194 {
01195   LOG("L: CFCruiseCar::CImpIClassFactory::QueryInterface. Delegating.");
01196
01197   // Delegate this call to the outer object's QueryInterface.
01198   return m_pUnkOuter->QueryInterface(riid, ppv);
01199 }
01200
01201
01202 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01203   Method:   CFCruiseCar::CImpIClassFactory::AddRef
01204
01205   Summary:  The AddRef IUnknown member of this IClassFactory interface
01206             implementation that delegates to m_pUnkOuter, whatever it is.
01207
01208   Args:     void
01209
01210   Modifies: m_cRefI.
01211
01212   Returns:  ULONG
01213               Returned by the delegated outer AddRef call.
01214 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01215 STDMETHODIMP_(ULONG) CFCruiseCar::CImpIClassFactory::AddRef(void)
01216 {
01217   // Increment the Interface Reference Count.
01218   InterlockedIncrement((PLONG) &m_cRefI);
01219
01220   LOGF1("L: CFCruiseCar::CImpIClassFactory::Addref. Delegating. New cI=%i.",m_cRefI);
01221
01222   // Delegate this call to the outer object's AddRef.
01223   return m_pUnkOuter->AddRef();
01224 }
01225
01226
01227 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01228   Method:   CFCruiseCar::CImpIClassFactory::Release
01229
01230   Summary:  The Release IUnknown member of this IClassFactory interface
01231             implementation that delegates to m_pUnkOuter, whatever it is.
01232
01233   Args:     void
01234
01235   Returns:  ULONG
01236               Returned by the delegated outer Release call.
01237 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01238 STDMETHODIMP_(ULONG) CFCruiseCar::CImpIClassFactory::Release(void)
01239 {
01240   // Decrement the Interface Reference Count.
01241   InterlockedDecrement((PLONG) &m_cRefI);
01242
01243   LOGF1("L: CFCruiseCar::CImpIClassFactory::Release. Delegating. New cI=%i.",m_cRefI);
01244
01245   // Delegate this call to the outer object's Release.
01246   return m_pUnkOuter->Release();
01247 }
01248
01249
01250 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01251   Method:   CFCruiseCar::CImpIClassFactory::CreateInstance
01252
01253   Summary:  The CreateInstance member method of this IClassFactory interface
01254             implementation.  Creates an instance of the COCruiseCar COM
01255             component.
01256
01257   Args:     IUnknown* pUnkOuter,
01258               [in] Pointer to the controlling IUnknown.
01259             REFIID riid,
01260               [in] GUID of the Interface being requested.
01261             PPVOID ppvCob)
01262               [out] Address of the caller's pointer variable that will
01263               receive the requested interface pointer.
01264
01265   Returns:  HRESULT
01266               Standard result code. NOERROR for success.
01267 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01268 STDMETHODIMP CFCruiseCar::CImpIClassFactory::CreateInstance(
01269                IUnknown* pUnkOuter,
01270                REFIID riid,
01271                PPVOID ppv)
01272 {
01273   HRESULT hr = E_FAIL;
01274   COCruiseCar* pCob = NULL;
01275
01276   LOGF1("L: CFCruiseCar::CImpIClassFactory::CreateInstance. pUnkOuter=0x%X.",pUnkOuter);
01277
01278   // If the creation call is requesting aggregation (pUnkOuter != NULL),
01279   // the COM rules state the IUnknown interface MUST also be concomitantly
01280   // requested.  If it is not so requested ( riid != IID_IUnknown) then
01281   // an error must be returned indicating that no aggregate creation of
01282   // the COCruiseCarFactory COM Object can be performed.
01283   if (NULL != pUnkOuter && riid != IID_IUnknown)
01284     hr = CLASS_E_NOAGGREGATION;
01285   else
01286   {
01287     // Instantiate a COCruiseCar COM Object.
01288     pCob = new COCruiseCar(pUnkOuter, m_pServer);
01289     if (NULL != pCob)
01290     {
01291       // We initially created the new COM object so tell the server
01292       // to increment its global server object count to help ensure
01293       // that the server remains loaded until this partial creation
01294       // of a COM component is completed.
01295       m_pServer->ObjectsUp();
01296
01297       // If we have succeeded in instantiating the COM object we
01298       // initialize it to set up any subordinate objects.
01299       hr = pCob->Init();
01300       if (SUCCEEDED(hr))
01301       {
01302         // We QueryInterface this new COM Object not only to deposit the
01303         // main interface pointer to the caller's pointer variable, but to
01304         // also automatically bump the Reference Count on the new COM
01305         // Object after handing out this reference to it.
01306         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
01307       }
01308
01309       if (FAILED(hr))
01310       {
01311         delete pCob;
01312         m_pServer->ObjectsDown();
01313       }
01314     }
01315     else
01316     {
01317       // If we were launched to create this object and could not then
01318       // we should force a shutdown of this server.
01319       m_pServer->ObjectsUp();
01320       m_pServer->ObjectsDown();
01321       hr = E_OUTOFMEMORY;
01322     }
01323   }
01324
01325   if (SUCCEEDED(hr))
01326   {
01327     LOGF1("L: CFCruiseCar::CImpIClassFactory::CreateInstance Succeeded. *ppv=0x%X.",*ppv);
01328   }
01329   else
01330   {
01331     LOG("L: CFCruiseCar::CImpIClassFactory::CreateInstance Failed.");
01332   }
01333
01334   return hr;
01335 }
01336
01337
01338 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01339   Method:   CFCruiseCar::CImpIClassFactory::LockServer
01340
01341   Summary:  The LockServer member method of this IClassFactory interface
01342             implementation.
01343
01344   Args:     BOOL fLock)
01345               [in] Flag determining whether to Lock or Unlock the server.
01346
01347   Returns:  HRESULT
01348               Standard result code. NOERROR for success.
01349 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01350 STDMETHODIMP CFCruiseCar::CImpIClassFactory::LockServer(
01351                BOOL fLock)
01352 {
01353   HRESULT hr = NOERROR;
01354
01355   LOG("L: CFCruiseCar::CImpIClassFactory::LockServer.");
01356
01357   if (fLock)
01358     m_pServer->Lock();
01359   else
01360     m_pServer->Unlock();
01361
01362   return hr;
01363 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFullConnectProperties Member List

This is the complete list of members for CFullConnectProperties, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CFullConnectProperties() | CFullConnectProperties |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CPropPageLite(UINT uIDD, TCHAR *ptszTitle=NULL) | CPropPageLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetParent() | CPropPageLite | [inline, virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_dwAsynchProp | CFullConnectProperties |
m_dwlcidProp | CFullConnectProperties |
m_dwModeProp | CFullConnectProperties |
m_dwTimeoutProp | CFullConnectProperties |
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pCPropSheet | CPropPageLite |
m_psPage | CPropPageLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
m_wszCatalog | CFullConnectProperties |
m_wszProvString | CFullConnectProperties |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnApply() | CPropPageLite | [virtual]
OnCancel() | CPropPageLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CFullConnectProperties | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CFullConnectProperties | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnKillActive() | CFullConnectProperties | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CPropPageLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnReset() | CPropPageLite | [virtual]
OnSetActive() | CFullConnectProperties | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
PropPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropPageLite | [static]
RefreshProperties() | CFullConnectProperties | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParent(CPropSheetLite *pCPropSheetLite) | CPropPageLite | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateProperties() | CFullConnectProperties | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CPropPageLite() | CPropPageLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CustomSurrogate/Surrog/custsur.Cpp Source File

  • Com
  • Fundamentals
  • CustomSurrogate
  • Surrog

custsur.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 //////////////////////////////////////////////////////////////////////
00019 //
00020 // CustSur.cpp
00021 //
00022 // Custom Surrogate sample WinMain.
00023 //
00024 // Order of events:
00025 //
00026 // 1. Initialize COM libraries
00027 // 2. Initialize security context based on AppID of the inproc CLSID being requested
00028 // 3. Instantiate the surrogate object and register it with COM
00029 // 4. Call our surrogate object's ISurrogate::LoadDllServer() for the first CLSID
00030 //    that we will be hosting (this is passed to us via szCmdParam upon entry)
00031 // 5. Pump messages until WM_QUIT
00032 // 6. Uninitialize COM libraries and return.
00033 //
00034 ////////////////////////////////////////////////////////////////////////
00035
00036 #include "common.h"
00037 #include "csur.h"
00038
00039
00040 HRESULT GetAppIDFromClsid(LPSTR szClsid, IID & AppID);
00041
00042 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR szCmdParam, int)
00043 {
00044   // 1. register with COM as STA
00045   //
00046   // Note: when initializing OLE as COINIT_MULTITHREADED, use a semaphore or
00047   // other mechanism to convey termination condition for WinMain() instead of
00048   // PostQuitMessage(0) in the ISurrogate::FreeSurrogate() call.  WinMain() will
00049   // be called on a different thread from the surrogate object and PostQuitMessage()
00050   // will only terminate the surrogate object thread, not WinMain()'s.
00051   HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
00052   assert(hr == S_OK);
00053
00054   OutputDebugString("CoInitializeEx() called.");
00055
00056   // 2. get the AppID associated with the requested CLSID and initialize security
00057   // based on it.
00058   IID appid;
00059
00060   CHAR szCLSID[39];
00061   strncpy(szCLSID, szCmdParam, 39);
00062   szCLSID[38] = 0;
00063   hr = GetAppIDFromClsid(szCLSID, appid);
00064
00065   assert(hr == S_OK);
00066
00067     hr = CoInitializeSecurity((PSECURITY_DESCRIPTOR*)&appid,
00068                   -1, NULL, NULL, 0, 0, NULL, EOAC_APPID, NULL);
00069   assert(hr == S_OK);
00070
00071   OutputDebugString("CoInitializeSecurity() called.");
00072
00073   // 3. register the surrogate object
00074   CSurrogate sur;
00075   hr = CoRegisterSurrogate(&sur);
00076   assert(hr == S_OK);
00077   OutputDebugString("CoRegisterSurrogate() called.");
00078
00079   // 4. we were passed the clsid for whom this surrogate exe was loaded by SCM
00080   // we now need to explicitly call ISurrogate::LoadDllServer() on that clsid
00081   OLECHAR wszGUID[39];
00082   mbstowcs(wszGUID, szCmdParam, 39);
00083   wszGUID[38]=0;
00084   CLSID clsid;
00085   hr = CLSIDFromString(wszGUID, &clsid);
00086   assert(hr == S_OK);
00087
00088   hr = sur.LoadDllServer(clsid);
00089   assert(hr == S_OK);
00090
00091   OutputDebugString("LoadDllServer() called.");
00092
00093   // 5. the message pump: we can do custom behaviour here, too.
00094
00095   MSG msg;
00096
00097   while (GetMessage(&msg, 0, 0, 0))
00098     DispatchMessage(&msg);
00099
00100   // 6. Uninitialize COM libraries and return.
00101   CoUninitialize();
00102   OutputDebugString("CoUninitialize() called.");
00103   return 0;
00104
00105 }
00106
00107 //
00108 // Look up the AppID associated with the requested CLSID and return it to the caller
00109 //
00110 HRESULT GetAppIDFromClsid(LPSTR szClsid, IID & AppID)
00111 {
00112     HKEY hkHKCR_CLSID = NULL;
00113     HKEY hkObjClsid = NULL;
00114     CHAR szAppid[MAX_GUIDSTR_LEN + 1];
00115     WCHAR wszAppid[MAX_GUIDSTR_LEN + 1];
00116     DWORD dwAppidSize = sizeof(szAppid);
00117     HRESULT hr = E_FAIL;
00118
00119     // open HKEY_CLASSES_ROOT/CLSID
00120     if(RegOpenKeyExA(HKEY_CLASSES_ROOT, szClsidKeyName, 0, KEY_READ, &hkHKCR_CLSID) != ERROR_SUCCESS)
00121     return FALSE;
00122
00123     // open the key for the requested CLSID
00124     if(RegOpenKeyExA(hkHKCR_CLSID, szClsid, 0, KEY_READ,  &hkObjClsid) != ERROR_SUCCESS)
00125     goto cleanup_and_exit;
00126
00127     // read the appid value
00128     if(RegQueryValueExA(hkObjClsid, szAppidValueName, NULL, NULL, (LPBYTE)szAppid, &dwAppidSize) != ERROR_SUCCESS)
00129     goto cleanup_and_exit;
00130
00131     // we're done with the registry, close the keys
00132     RegCloseKey(hkObjClsid);
00133     hkObjClsid = NULL;
00134
00135     RegCloseKey(hkHKCR_CLSID);
00136     hkHKCR_CLSID = NULL;
00137
00138     // now convert the appid string from the registry into
00139     // a unicode string
00140     if(!(MultiByteToWideChar(CP_ACP, 0, szAppid, lstrlenA(szAppid) + 1, wszAppid, MAX_GUIDSTR_LEN + 1)))
00141     goto cleanup_and_exit;
00142
00143   // use the unicode appid string to create a guid
00144     hr = IIDFromString(wszAppid,&AppID);
00145
00146     if(FAILED(hr))
00147     goto cleanup_and_exit;
00148
00149   // couldn't find the security descriptor so return "file not found".
00150     if(hr == MAKE_SCODE(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND))
00151     hr = S_OK;
00152
00153 cleanup_and_exit:
00154
00155     // close open keys
00156     if(hkObjClsid)
00157     RegCloseKey(hkObjClsid);
00158
00159     if(hkHKCR_CLSID)
00160     RegCloseKey(hkHKCR_CLSID);
00161
00162     return hr;
00163
00164 }
00165
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/SockAuth/Collect.cpp Source File

  • Security
  • SSPI
  • SockAuth

Collect.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 Module Name:
00006
00007     collect.cpp
00008
00009 Abstract:
00010
00011     Implements a very simple collection for mapping DWORD key values
00012   to a blob of data.
00013
00014 Revision History:
00015
00016 --*/
00017
00018 #include <windows.h>
00019 #include <stdlib.h>
00020 #include "collect.h"
00021
00022 typedef struct _node_tag  {
00023   DWORD dwKey;
00024   PVOID *pData;
00025   struct _node_tag *pNext;
00026 } NODE, *PNODE;
00027
00028 static NODE Head = {(DWORD)-1, NULL, NULL};
00029
00030 BOOL GetEntry (DWORD dwKey, PVOID *ppData)
00031 {
00032   PNODE pCurrent;
00033
00034   pCurrent = Head.pNext;
00035   while (NULL != pCurrent) {
00036     if (dwKey == pCurrent->dwKey)  {
00037       *ppData = pCurrent->pData;
00038       return(TRUE);
00039     }
00040     pCurrent = pCurrent->pNext;
00041   }
00042
00043   return(FALSE);
00044 }
00045
00046 BOOL AddEntry (DWORD dwKey, PVOID pData)
00047 {
00048   PNODE pTemp;
00049
00050   pTemp = (PNODE) malloc (sizeof (NODE));
00051   if (NULL == pTemp)  {
00052     return(FALSE);
00053   }
00054
00055   pTemp->dwKey = dwKey;
00056   pTemp->pData = (PVOID *) pData;
00057   pTemp->pNext = Head.pNext;
00058   Head.pNext = pTemp;
00059
00060   return(TRUE);
00061 }
00062
00063 BOOL DeleteEntry (DWORD dwKey, PVOID *ppData)
00064 {
00065   PNODE pCurrent, pTemp;
00066
00067   pTemp = &Head;
00068   pCurrent = Head.pNext;
00069
00070   while (NULL != pCurrent) {
00071     if (dwKey == pCurrent->dwKey)  {
00072       pTemp->pNext = pCurrent->pNext;
00073       *ppData = pCurrent->pData;
00074       free (pCurrent);
00075       return(TRUE);
00076     }
00077     else {
00078       pTemp = pCurrent;
00079       pCurrent = pCurrent->pNext;
00080     }
00081   }
00082
00083   return(FALSE);
00084 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • WMI

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/DiskQuota/Commands.h Source File

  • WinBase
  • IO
  • DiskQuota

Commands.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1999 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 Commands.h
00011
00012 ----------------------------------------------------------------------------*/
00013
00014 #if !defined (_COMMANDS_H_)
00015 #define _COMMANDS_H_
00016
00017 BOOL GetDefaultQuota(IDiskQuotaControl* lpDiskQuotaControl);
00018 BOOL GetQuotaLogFlags(IDiskQuotaControl* lpDiskQuotaControl);
00019 BOOL GetDefaultHardLimit(IDiskQuotaControl* lpDiskQuotaControl);
00020 BOOL GetDefaultThreshold(IDiskQuotaControl* lpDiskQuotaControl);
00021 BOOL SetDefaultHardLimit(IDiskQuotaControl* lpDiskQuotaControl);
00022 BOOL SetDefaultThreshold(IDiskQuotaControl* lpDiskQuotaControl);
00023 BOOL SetUserHardLimit(IDiskQuotaControl* lpDiskQuotaControl);
00024 BOOL SetUserThreshold(IDiskQuotaControl* lpDiskQuotaControl);
00025 BOOL GetUserQuotaInfo(IDiskQuotaControl* lpDiskQuotaControl);
00026 BOOL AddUser(IDiskQuotaControl* lpDiskQuotaControl);
00027 BOOL DeleteUser(IDiskQuotaControl* lpDiskQuotaControl);
00028 BOOL EnumerateUsers(IDiskQuotaControl* lpDiskQuotaControl);
00029 BOOL EnumerateUserQuotas(IDiskQuotaControl* lpDiskQuotaControl);
00030
00031 void PrintError(HRESULT hr);
00032 void LfcrToNull(LPWSTR szString);
00033
00034 #endif /* _COMMANDS_H_ */
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/ObjPool2sub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

ObjPool2sub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __OBJPOOL2SUB_H__
00018 #define __OBJPOOL2SUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CObjPool2Sub
00028 Summary: Object Pool2 Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CObjPool2Sub :
00031   public CSysLCESub,
00032   public IComObjectPoolEvents2
00033 {
00034 public:
00035   CObjPool2Sub(CComSpy * pSpy)
00036   {
00037     m_pSpy = pSpy;
00038   }
00039
00040   CObjPool2Sub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045   DECLARE_NOT_AGGREGATABLE(CObjPool2Sub)
00046   DECLARE_GET_CONTROLLING_UNKNOWN()
00047
00048   BEGIN_COM_MAP(CObjPool2Sub)
00049     COM_INTERFACE_ENTRY(IComObjectPoolEvents2)
00050     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00051   END_COM_MAP()
00052
00053   STDMETHODIMP GetEventType(EventEnum * e){*e = ObjectPool2;return S_OK;}
00054   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00055   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComObjectPoolEvents2;return S_OK;}
00056
00057   STDMETHODIMP OnObjPoolCreateObject(COMSVCSEVENTINFO * pInfo,
00058                      REFGUID guidClass,
00059                      DWORD dwObjsCreated,
00060                      ULONG64 ObjectID)
00061   {
00062
00063     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjPoolCreateObject"), GuidToBstr(pInfo->guidApp));
00064     m_pSpy -> AddParamValueToList(L"guidClass", GuidToBstr( guidClass ));
00065
00066     WCHAR p1[16];
00067     wsprintfW(p1, L"%lu", dwObjsCreated);
00068     m_pSpy -> AddParamValueToList(L"dwObjsCreated", p1);
00069
00070     WCHAR szObjectID[32];
00071     wsprintfW(szObjectID, L"0x%08X", ObjectID);
00072     m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00073
00074     IF_AUDIT_DO(OnObjPoolCreateObject)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00075                     GuidToBstr( guidClass ),
00076                     dwObjsCreated,
00077                     szObjectID);
00078     return S_OK;
00079   }
00080
00081
00082   STDMETHODIMP  OnObjPoolDestroyObject(COMSVCSEVENTINFO * pInfo,
00083                      REFGUID guidClass,
00084                      DWORD dwObjsCreated,
00085                      ULONG64 ObjectID)
00086   {
00087
00088     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjPoolDestroyObject"), GuidToBstr(pInfo->guidApp));
00089     m_pSpy -> AddParamValueToList(L"guidClass", GuidToBstr( guidClass ));
00090
00091     WCHAR p1[16];
00092     wsprintfW(p1, L"%lu", dwObjsCreated);
00093     m_pSpy -> AddParamValueToList(L"dwObjsCreated", p1);
00094
00095     WCHAR szObjectID[32];
00096     wsprintfW(szObjectID, L"0x%08X", ObjectID);
00097     m_pSpy -> AddParamValueToList(L"ObjectID", szObjectID);
00098
00099     IF_AUDIT_DO(OnObjPoolDestroyObject)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00100                     GuidToBstr( guidClass ),
00101                     dwObjsCreated,
00102                     szObjectID);
00103
00104     return S_OK;
00105   }
00106
00107   STDMETHODIMP  OnObjPoolCreateDecision(COMSVCSEVENTINFO * pInfo,
00108                       DWORD dwThreadsWaiting,
00109                       DWORD dwAvail,
00110                       DWORD dwCreated,
00111                       DWORD dwMin,
00112                       DWORD dwMax)
00113   {
00114     WCHAR p1[16];
00115     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjPoolCreateDecision"), GuidToBstr(pInfo->guidApp));
00116     wsprintfW(p1,  L"%lu", dwThreadsWaiting);
00117     m_pSpy -> AddParamValueToList(L"dwThreadsWaiting", p1);
00118     wsprintfW(p1,  L"%lu", dwAvail);
00119     m_pSpy -> AddParamValueToList(L"dwAvail", p1);
00120     wsprintfW(p1,  L"%lu", dwCreated);
00121     m_pSpy -> AddParamValueToList(L"dwCreated", p1);
00122     wsprintfW(p1,  L"%lu", dwMin);
00123     m_pSpy -> AddParamValueToList(L"dwMin", p1);
00124     wsprintfW(p1,  L"%lu", dwMax);
00125     m_pSpy -> AddParamValueToList(L"dwMax", p1);
00126
00127     IF_AUDIT_DO(OnObjPoolCreateDecision)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00128                     dwThreadsWaiting,
00129                     dwAvail,
00130                     dwCreated,
00131                     dwMin,
00132                     dwMax);
00133     return S_OK;
00134   }
00135
00136
00137   STDMETHODIMP  OnObjPoolTimeout(COMSVCSEVENTINFO * pInfo,
00138                    REFGUID guidActivity,
00139                    REFGUID guidClass,
00140                    DWORD dwTimeout)
00141   {
00142     WCHAR p1[16];
00143     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjPoolGetFromTx"), GuidToBstr(pInfo->guidApp));
00144     m_pSpy -> AddParamValueToList(L"guidActivity", GuidToBstr( guidActivity ));
00145     m_pSpy -> AddParamValueToList(L"guidClass", GuidToBstr( guidClass ));
00146     wsprintfW(p1,L"0x%08X", dwTimeout);
00147     m_pSpy -> AddParamValueToList(L"dwTimeout", p1);
00148
00149     IF_AUDIT_DO(OnObjPoolTimeout)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00150                     GuidToBstr( guidActivity ),
00151                     GuidToBstr( guidClass ),
00152                     dwTimeout);
00153
00154     return S_OK;
00155   }
00156
00157   STDMETHODIMP  OnObjPoolCreatePool(COMSVCSEVENTINFO * pInfo,
00158                     REFGUID guidClass,
00159                     DWORD dwMin,
00160                     DWORD dwMax,
00161                     DWORD dwTimeout)
00162   {
00163     WCHAR p1[16];
00164     m_pSpy -> AddEventToList(pInfo->perfCount, _TEXT("OnObjPoolCreatePool"), GuidToBstr(pInfo->guidApp));
00165     m_pSpy -> AddParamValueToList(L"guidClass", GuidToBstr( guidClass ));
00166     wsprintfW(p1,  L"0x%08X", dwMin);
00167     m_pSpy -> AddParamValueToList(L"dwMin", p1);
00168     wsprintfW(p1,  L"0x%08X", dwMax);
00169     m_pSpy -> AddParamValueToList(L"dwMax", p1);
00170     wsprintfW(p1,L"0x%08X", dwTimeout);
00171     m_pSpy -> AddParamValueToList(L"dwTimeout", p1);
00172
00173     IF_AUDIT_DO(OnObjPoolCreatePool)(pInfo->perfCount, GuidToBstr(pInfo->guidApp),
00174                     GuidToBstr( guidClass ),
00175                     dwMin,
00176                     dwMax,
00177                     dwTimeout);
00178
00179
00180     return S_OK;
00181   }
00182 };
00183
00184 #endif //__OBJPOOL2SUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/ClsFact.Cpp Source File

  • WinUI
  • Shell
  • SampView

ClsFact.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ClsFact.cpp
00013
00014    Description:   Implements CClassFactory.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ClsFact.h"
00023
00024 /**************************************************************************
00025    private function prototypes
00026 **************************************************************************/
00027
00028 /**************************************************************************
00029    global variables
00030 **************************************************************************/
00031
00032 ///////////////////////////////////////////////////////////////////////////
00033 //
00034 // IClassFactory implementation
00035 //
00036
00037 /**************************************************************************
00038
00039    CClassFactory::CClassFactory
00040
00041 **************************************************************************/
00042
00043 CClassFactory::CClassFactory()
00044 {
00045 g_DllRefCount++;
00046 m_ObjRefCount = 1;
00047 }
00048
00049 /**************************************************************************
00050
00051    CClassFactory::~CClassFactory
00052
00053 **************************************************************************/
00054
00055 CClassFactory::~CClassFactory()
00056 {
00057 g_DllRefCount--;
00058 }
00059
00060 /**************************************************************************
00061
00062    CClassFactory::QueryInterface
00063
00064 **************************************************************************/
00065
00066 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppReturn)
00067 {
00068 *ppReturn = NULL;
00069
00070 if(IsEqualIID(riid, IID_IUnknown))
00071    {
00072    *ppReturn = this;
00073    }
00074
00075 else if(IsEqualIID(riid, IID_IClassFactory))
00076    {
00077    *ppReturn = (IClassFactory*)this;
00078    }
00079
00080 if(*ppReturn)
00081    {
00082    (*(LPUNKNOWN*)ppReturn)->AddRef();
00083    return S_OK;
00084    }
00085
00086 return E_NOINTERFACE;
00087 }
00088
00089 /**************************************************************************
00090
00091    CClassFactory::AddRef
00092
00093 **************************************************************************/
00094
00095 STDMETHODIMP_(DWORD) CClassFactory::AddRef()
00096 {
00097 return ++m_ObjRefCount;
00098 }
00099
00100
00101 /**************************************************************************
00102
00103    CClassFactory::Release
00104
00105 **************************************************************************/
00106
00107 STDMETHODIMP_(DWORD) CClassFactory::Release()
00108 {
00109 if(--m_ObjRefCount == 0)
00110    {
00111    delete this;
00112    return 0;
00113    }
00114
00115 return m_ObjRefCount;
00116 }
00117
00118 /**************************************************************************
00119
00120    CClassFactory::CreateInstance
00121
00122 **************************************************************************/
00123
00124 STDMETHODIMP CClassFactory::CreateInstance(  LPUNKNOWN pUnknown,
00125                                              REFIID riid,
00126                                              LPVOID *ppObject)
00127 {
00128 *ppObject = NULL;
00129
00130 if(pUnknown != NULL)
00131    return CLASS_E_NOAGGREGATION;
00132
00133 //add implementation specific code here
00134
00135 CShellFolder *pShellFolder = new CShellFolder();
00136 if(NULL == pShellFolder)
00137    return E_OUTOFMEMORY;
00138
00139 //get the QueryInterface return for our return value
00140 HRESULT hResult = pShellFolder->QueryInterface(riid, ppObject);
00141
00142 //call Release to decement the ref count
00143 pShellFolder->Release();
00144
00145 //return the result from QueryInterface
00146 return hResult;
00147 }
00148
00149 /**************************************************************************
00150
00151    CClassFactory::LockServer
00152
00153 **************************************************************************/
00154
00155 STDMETHODIMP CClassFactory::LockServer(BOOL)
00156 {
00157 return E_NOTIMPL;
00158 }
00159
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SPropertyEntry Member List

This is the complete list of members for SPropertyEntry, including all inherited members.
awcName | SPropertyEntry
dbType | SPropertyEntry
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/Marshal/MICARS.Idl Source File

  • Com
  • Fundamentals
  • TutSamp
  • Marshal

MICARS.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      MICARS.IDL
00003
00004   Summary:   Interface definition file for use by the MIDL compiler.
00005              Specifies the following custom interfaces: ICar, IUtility,
00006              and ICruise. Part of the MARSHAL and MARSHAL2 code samples
00007              which is used by later code samples in the series (eg, the
00008              LOCSERVE, LOCCLIEN, APTSERVE, APTCLIEN, and REMCLIEN
00009              samples).
00010
00011              Compilation of this file using the MIDL.EXE compiler
00012              generates additional source files MICARS.H, MICARS_I.C,
00013              MICARS_P.C, and DLLDATA.C.  They are in turn compiled in the
00014              Makefile to produce the marshaling server which is used by
00015              later code samples to provide standard marshaling for the
00016              ICar, IUtility, and ICruise custom interfaces.
00017
00018   Origin:    6-9-97: atrent - Revised for MARSHAL and MARSHAL2.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995-1998 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 [uuid(0002da00-0000-0000-c000-000000000046),
00036     object
00037 ]
00038 interface ICar : IUnknown
00039 {
00040   import "unknwn.idl";
00041
00042   HRESULT Shift([in] short nGear);
00043   HRESULT Clutch([in] short nEngaged);
00044   HRESULT Speed([in] short nMph);
00045   HRESULT Steer([in] short nAngle);
00046 }
00047
00048 [uuid(0002da01-0000-0000-c000-000000000046),
00049     object
00050 ]
00051 interface IUtility : IUnknown
00052 {
00053   import "unknwn.idl";
00054
00055   HRESULT Offroad([in] short nGear);
00056   HRESULT Winch([in] short nRpm);
00057 }
00058
00059 [uuid(0002da02-0000-0000-c000-000000000046),
00060     object
00061 ]
00062 interface ICruise : IUnknown
00063 {
00064   import "unknwn.idl";
00065
00066   HRESULT Engage([in] BOOL bOnOff);
00067   HRESULT Adjust([in] BOOL bUpDown);
00068 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/basenode.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

basenode.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Generic base node class.  All nodes are derived from this.
00014
00015
00016 #ifndef _CLASS_CBASENODE_
00017 #define _CLASS_CBASENODE_
00018
00019 #include "Globals.h"
00020 #include "Resource.h"
00021
00022
00023 #define DEFAULT_SDI_MASK  (SDI_STR | SDI_PARAM | SDI_IMAGE | SDI_OPENIMAGE | SDI_PARENT | SDI_CHILDREN)
00024 #define DEFAULT_RDI_MASK  (RDI_STR | RDI_PARAM | RDI_IMAGE)
00025
00026 #define MAX_NAME_LEN     64
00027
00028
00029 class CBaseNode;
00030
00031
00032 //---------------------------------------------------------------------------
00033 //  Data types specific to this object
00034 //
00035 typedef struct tag_BASENODE_PROPERTIES
00036 {
00037   WCHAR      szNodeName[MAX_NAME_LEN];
00038   LONG_PTR   pComponentData;
00039   LONG_PTR   pParentObject;
00040   DWORD      dwAttributes;
00041
00042 }NODE_PROPERTIES;
00043
00044
00045 typedef NODE_PROPERTIES*  LPNODEPROPS;
00046 typedef CBaseNode*        LPBASENODE;
00047
00048
00049 //---------------------------------------------------------------------------
00050 class CBaseNode
00051 {
00052   public:
00053     CBaseNode()
00054     {
00055       m_pwszNodeName      = NULL;
00056
00057       ZeroMemory( &m_SDI, sizeof(SCOPEDATAITEM) );
00058       ZeroMemory( &m_RDI, sizeof(RESULTDATAITEM) );
00059     };
00060
00061     virtual ~CBaseNode()
00062     {
00063       if( NULL != m_pwszNodeName )
00064         CoTaskMemFree( m_pwszNodeName );
00065     };
00066
00067   public:
00068     LPWSTR   GetNodeName()     { return m_pwszNodeName;  }
00069
00070     virtual  HRESULT Initialize( NODE_PROPERTIES* pProperties ) = 0;
00071     virtual  ULONG   GetNodeType() = 0;
00072     virtual  GUID&   GetNodeGUID() = 0;
00073
00074   ///////////////////////////////////////////////////////////////////////////
00075   // These virtual methods handle calls from the console
00076   //
00077   public:
00078     virtual  HRESULT GetDisplayInfo( SCOPEDATAITEM* pSDI ) = 0;
00079     virtual  HRESULT GetDisplayInfo( RESULTDATAITEM* pRDI ) = 0;
00080     virtual  HRESULT GetResultViewType2( MMC_COOKIE nCookie, PRESULT_VIEW_TYPE_INFO pRVTinfo ) = 0;
00081
00082   ///////////////////////////////////////////////////////////////////////////
00083   // IExtendContextMenu support
00084   //
00085   public:
00086     virtual  HRESULT AddMenuItems( LPCONTEXTMENUCALLBACK ipCallback, long __RPC_FAR* pInsertionAllowed ) = 0;
00087     virtual  HRESULT Command( long lCommandID ) = 0;
00088
00089
00090   ///////////////////////////////////////////////////////////////////////////
00091   // IExtendControlbar support
00092   //
00093   public:
00094     virtual  HRESULT ControlbarNotify( LPARAM nArg, LPARAM lParam, LONG_PTR pComp ) = 0;
00095
00096   ///////////////////////////////////////////////////////////////////////////
00097   // These virtual methods handle notifications
00098   //
00099   public:
00100     virtual  HRESULT OnSelect( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00101     virtual  HRESULT OnShow( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00102     virtual  HRESULT OnExpand( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData ) = 0;
00103     virtual  HRESULT OnRemoveChildren( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pCompData ) = 0;
00104     virtual  HRESULT OnRename( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00105     virtual  HRESULT OnViewChange( LPDATAOBJECT ipDataObject, LPARAM nArg, LPARAM nParam, LONG_PTR pComponent ) = 0;
00106
00107   public:
00108     SCOPEDATAITEM    m_SDI;
00109     RESULTDATAITEM   m_RDI;
00110
00111   protected:
00112     LPWSTR     m_pwszNodeName;
00113
00114 }; //end class CBaseNode
00115
00116 #endif //_CLASS_CBASENODE_
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/adddevicedlg.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

adddevicedlg.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  AddDeviceDlg.h:  Header for the CAddDeviceDlg class.  This is a
00014 //                   modeless dialog class used to add device nodes.
00015 //
00016
00017
00018 #ifndef _CLASS_ADDDEVICEDLG_
00019 #define _CLASS_ADDDEVICEDLG_
00020
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027 #include "BaseDialog.h"
00028
00029
00030 //---------------------------------------------------------------------------
00031 class CAddDeviceDlg : public CBaseDialog
00032 {
00033   public:
00034     CAddDeviceDlg( ULONG nTemplate, HWND hParentWnd );
00035     ~CAddDeviceDlg();
00036
00037
00038   public:
00039     BOOL ProcessMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
00040
00041
00042   // Messages we will be handling
00043   private:
00044     LRESULT OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam );
00045     LRESULT OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam );
00046
00047   private:
00048     HWND    m_hParentWnd;
00049
00050
00051 };
00052
00053 #endif //_CLASS_ADDDEVICEDLG_
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/resource.h Source File

  • Web
  • NetMeeting
  • PlugTransport

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ui.rc
00004 //
00005 #define IDD_DIALOG1                     101
00006 #define IDD_PLUGTRANSPORT               101
00007 #define IDC_EDIT1                       1000
00008 #define IDC_NAME                        1000
00009 #define IDC_CONNECT                     1001
00010 #define IDC_LISTEN                      1002
00011 #define IDC_X224                        1003
00012 #define IDC_PSTN                        1004
00013 #define ID_CONTROL                      1005
00014 #define ID_CALL                         1005
00015 #define ID_CONNECT                      1006
00016
00017 // Next default values for new objects
00018 //
00019 #ifdef APSTUDIO_INVOKED
00020 #ifndef APSTUDIO_READONLY_SYMBOLS
00021 #define _APS_NEXT_RESOURCE_VALUE        102
00022 #define _APS_NEXT_COMMAND_VALUE         40001
00023 #define _APS_NEXT_CONTROL_VALUE         1007
00024 #define _APS_NEXT_SYMED_VALUE           101
00025 #endif
00026 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/guids.h Source File

  • SysMgmt
  • MMC
  • Extens

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {AEA15790-A656-11d2-992F-000000000000}
00020 DEFINE_GUID(CLSID_CComponentData,
00021             0xaea15790, 0xa656, 0x11d2, 0x99, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0);
00022
00023 // {AEA15792-A656-11d2-992F-000000000000}
00024 DEFINE_GUID(CLSID_CSnapinAbout,
00025             0xaea15792, 0xa656, 0x11d2, 0x99, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::IRecFields Member List

This is the complete list of members for msado15::IRecFields, including all inherited members.
ADOCheck() | msado15::IRecFields |
iid | msado15::IRecFields | [static]
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::LockTypeEnum Member List

This is the complete list of members for msado15::LockTypeEnum, including all inherited members.
adLockBatchOptimistic | msado15::LockTypeEnum | [static]
adLockOptimistic | msado15::LockTypeEnum | [static]
adLockPessimistic | msado15::LockTypeEnum | [static]
adLockReadOnly | msado15::LockTypeEnum | [static]
adLockUnspecified | msado15::LockTypeEnum | [static]
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

diritem Member List

This is the complete list of members for diritem, including all inherited members.
attr | diritem
bLocalIsTemp | diritem
checksum | diritem
direct | diritem
fileerror | diritem
ft_lastwrite | diritem
localname | diritem
name | diritem
sequence | diritem
size | diritem
sumvalid | diritem
Generated on Wed Nov 13 2024 16:57:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Move/vc/Move.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Move
  • vc

Move.cpp

Go to the documentation of this file.
00001 // Move.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "stdio.h"
00006 #include "activeds.h"
00007
00008
00009 int main(int argc, char* argv[])
00010 {
00011   CoInitialize(NULL);
00012
00013
00014   ////////////////////////////////////////////
00015   // First bind to the destination container
00016   ////////////////////////////////////////////
00017   HRESULT hr;
00018   IADsContainer *pCont=NULL;
00019     hr = ADsGetObject(L"LDAP://OU=trOU,DC=domain1,DC=domain2,DC=microsoft,DC=com",
00020                   IID_IADsContainer,
00021             (void**) &pCont );
00022
00023   if ( !SUCCEEDED(hr) )
00024   {
00025     return 0;
00026   }
00027
00028   /////////////////////////////////////////////////
00029   // Now, move the object to the bound container
00030   ///////////////////////////////////////////////////
00031   IDispatch *pDisp=NULL;
00032
00033   hr = pCont->MoveHere(L"LDAP://CN=Mike Smith,OU=srOU,DC=domain1,DC=domain2,DC=microsoft,DC=com", NULL, &pDisp );
00034   pCont->Release();
00035
00036   if (SUCCEEDED(hr) )
00037   {
00038     // You may do other operation here, such as updating attributes
00039     pDisp->Release();
00040   }
00041
00042
00043   CoUninitialize();
00044   return 0;
00045 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/GenericUCP/CPP/stdafx.h Source File

  • NetDS
  • upnp
  • GenericUCP
  • CPP

stdafx.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005
00006 --*/
00007 // stdafx.h : include file for standard system include files,
00008 //  or project specific include files that are used frequently, but
00009 //      are changed infrequently
00010 //
00011
00012 #if !defined(AFX_STDAFX_H__AF164577_F925_4155_9BB5_00F3E494F350__INCLUDED_)
00013 #define AFX_STDAFX_H__AF164577_F925_4155_9BB5_00F3E494F350__INCLUDED_
00014
00015 #if _MSC_VER > 1000
00016 #pragma once
00017 #endif // _MSC_VER > 1000
00018
00019 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00020
00021 #include <afxwin.h>         // MFC core and standard components
00022 #include <afxext.h>         // MFC extensions
00023 #include <afxdisp.h>        // MFC Automation classes
00024 #include <afxdtctl.h>   // MFC support for Internet Explorer 4 Common Controls
00025 #include <afxcoll.h>    // MFC Collection classes
00026 #include <afxtempl.h>   // MFC Template classes
00027 #ifndef _AFX_NO_AFXCMN_SUPPORT
00028 #include <afxcmn.h>     // MFC support for Windows Common Controls
00029 #endif // _AFX_NO_AFXCMN_SUPPORT
00030
00031 //#include <afxsock.h>    // MFC socket extensions
00032 #include <winsock2.h>
00033 #include <windows.h>
00034 #include <upnp.h>
00035
00036
00037 // ATL functions
00038
00039 #include <atldef.h>
00040 #include <atlbase.h>
00041 extern CComModule _Module;
00042 #include <atlcom.h>
00043
00044 //{{AFX_INSERT_LOCATION}}
00045 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00046
00047 #endif // !defined(AFX_STDAFX_H__AF164577_F925_4155_9BB5_00F3E494F350__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/SendMDlg.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

SendMDlg.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // SendMDlg.cpp : implementation file
00013 //
00014
00015
00016
00017 #include "stdafx.h"
00018 #include "MQApitst.h"
00019 #include "SendMDlg.h"
00020
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026 //const TCHAR a[]='6';
00027
00028 const TCHAR MULTICAST[] = _T("MULTICAST=");
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CSendMessageDialog dialog
00031
00032
00033 CSendMessageDialog::CSendMessageDialog(CArray<ARRAYQ*, ARRAYQ*>* pStrArray, CWnd* pParent /*=NULL*/)
00034   : CDialog(CSendMessageDialog::IDD, pParent)
00035 {
00036   m_pStrArray = pStrArray;
00037
00038   //{{AFX_DATA_INIT(CSendMessageDialog)
00039   m_strBody = szLastMessageBody;
00040   m_strLabel = szLastMessageLabel;
00041   m_bPriority = (MQ_MAX_PRIORITY - MQ_MIN_PRIORITY)/2;
00042   m_iAck = MQMSG_ACKNOWLEDGMENT_NONE;
00043   m_iDelivery = MQMSG_DELIVERY_EXPRESS;
00044   m_szPathName = _T("");
00045   m_szAdminPathName = _T("");
00046   m_Journal = FALSE;
00047   m_DeadLetter = FALSE;
00048   m_Authenticated = FALSE;
00049   m_Encrypted = FALSE;
00050   m_dwTimeToReachQueue = (DWORD)DEFAULT_M_TIMETOREACHQUEUE;
00051   m_dwTimeToBeReceived = (DWORD)DEFAULT_M_TIMETOBERECEIVED;
00052   //}}AFX_DATA_INIT
00053 }
00054
00055
00056 void CSendMessageDialog::DoDataExchange(CDataExchange* pDX)
00057 {
00058   CDialog::DoDataExchange(pDX);
00059   //{{AFX_DATA_MAP(CSendMessageDialog)
00060   DDX_Control(pDX, IDC_ADMIN_COMBO, m_AdminPathNameCB);
00061   DDX_Control(pDX, IDC_TARGET_COMBO, m_PathNameCB);
00062   DDX_Text(pDX, IDC_BODY, m_strBody);
00063   DDV_MaxChars(pDX, m_strBody, 128);
00064   DDX_Text(pDX, IDC_LABEL, m_strLabel);
00065   DDV_MaxChars(pDX, m_strLabel, 128);
00066   DDX_Text(pDX, IDC_MESSAGE_PRIORITY, m_bPriority);
00067   DDV_MinMaxByte(pDX, m_bPriority, MQ_MIN_PRIORITY, MQ_MAX_PRIORITY);
00068   DDX_Radio(pDX, IDC_ACK_NONE_RADIO, m_iAck);
00069   DDX_Radio(pDX, IDC_DELIVERY_EXPRESS_RADIO, m_iDelivery);
00070   DDX_CBString(pDX, IDC_TARGET_COMBO, m_szPathName);
00071   DDV_MaxChars(pDX, m_szPathName, 4000);
00072   DDX_CBString(pDX, IDC_ADMIN_COMBO, m_szAdminPathName);
00073   DDV_MaxChars(pDX, m_szAdminPathName, 4000);
00074   DDX_Check(pDX, IDC_JOURNAL, m_Journal);
00075   DDX_Check(pDX, IDC_DEAD_LETTER, m_DeadLetter);
00076   DDX_Check(pDX, IDC_AUTHENTICATED, m_Authenticated);
00077   DDX_Check(pDX, IDC_ENCRYPTED, m_Encrypted);
00078   DDX_Text(pDX, IDC_TIME_TO_REACH_QUEUE, m_dwTimeToReachQueue);
00079   DDX_Text(pDX, IDC_TIME_TO_BE_RECEIVED, m_dwTimeToBeReceived);
00080   //}}AFX_DATA_MAP
00081 }
00082
00083
00084 BEGIN_MESSAGE_MAP(CSendMessageDialog, CDialog)
00085   //{{AFX_MSG_MAP(CSendMessageDialog)
00086   ON_CBN_SELCHANGE(IDC_TARGET_COMBO, OnSelchangeTargetCombo)
00087   //}}AFX_MSG_MAP
00088 END_MESSAGE_MAP()
00089
00090 /////////////////////////////////////////////////////////////////////////////
00091 // CSendMessageDialog message handlers
00092
00093 BOOL CSendMessageDialog::OnInitDialog()
00094 {
00095   CDialog::OnInitDialog();
00096
00097   int i;
00098
00099   // TODO: Add extra initialization here
00100   for  (i=0 ; i<m_pStrArray->GetSize() ; i++)
00101   {
00102     if (((*m_pStrArray)[i]->dwAccess & MQ_SEND_ACCESS) != FALSE)
00103     {
00104       if ((*m_pStrArray)[i]->bFormatNameOnly)
00105       {
00106         VERIFY (m_PathNameCB.AddString((*m_pStrArray)[i]->szFormatName) != CB_ERR);
00107       }
00108       else
00109       {
00110         VERIFY (m_PathNameCB.AddString((*m_pStrArray)[i]->szPathName) != CB_ERR);
00111       }
00112     }
00113     if ((*m_pStrArray)[i]->bFormatNameOnly)
00114     {
00115       CString str = (*m_pStrArray)[i]->szFormatName;
00116       str=str.Left(sizeof(MULTICAST)/sizeof(TCHAR)-1);
00117       if (str.Left(sizeof(MULTICAST)/sizeof(TCHAR)-1).CompareNoCase(MULTICAST) != 0)
00118       {
00119         VERIFY (m_AdminPathNameCB.AddString((*m_pStrArray)[i]->szFormatName) != CB_ERR);
00120       }
00121     }
00122     else
00123     {
00124       VERIFY (m_AdminPathNameCB.AddString((*m_pStrArray)[i]->szPathName) != CB_ERR);
00125     }
00126   }
00127
00128     //
00129     // Set the first PathName as default selection.
00130     //
00131     if (m_PathNameCB.GetCount() > 0) m_PathNameCB.SetCurSel(0);
00132     if (m_AdminPathNameCB.GetCount() > 0) m_AdminPathNameCB.SetCurSel(0);
00133
00134     return TRUE;  // return TRUE unless you set the focus to a control
00135                 // EXCEPTION: OCX Property Pages should return FALSE
00136 }
00137
00138
00139 void CSendMessageDialog::OnOK()
00140 {
00141
00142   UpdateData(TRUE);
00143   if ((m_szAdminPathName == _T("")) && (m_iAck != 0))
00144   {
00145     AfxMessageBox(_T("The chosen acknowledgement requires Admin queue. Please enter a path for the admin queue."));
00146     return;
00147   }
00148
00149   CDialog::OnOK();
00150 }
00151
00152 void CSendMessageDialog::OnSelchangeTargetCombo()
00153 {
00154   UpdateData(TRUE);
00155   int a=m_PathNameCB.GetCurSel();
00156   CString str=(*m_pStrArray)[m_PathNameCB.GetCurSel()]->szFormatName;
00157   if (str.Left(10).CompareNoCase(_T("MULTICAST=")) == 0)
00158   {
00159     m_AdminPathNameCB.SetCurSel(-1);
00160   }
00161 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/PidlMgr.h Source File

  • WinUI
  • Shell
  • SampView

PidlMgr.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          PidlMgr.h
00013
00014    Description:   CPidlMgr definitions.
00015
00016 **************************************************************************/
00017
00018 #ifndef PIDLMGR_H
00019 #define PIDLMGR_H
00020
00021 #include <windows.h>
00022 #include <shlobj.h>
00023
00024 /**************************************************************************
00025    data types
00026 **************************************************************************/
00027
00028 #define MAX_NAME MAX_PATH
00029 #define MAX_DATA 128
00030
00031 typedef struct tagPIDLDATA
00032    {
00033    BOOL fFolder;
00034    /*
00035    The character types must be the same on all platforms no matter if UNICODE
00036    is defined. This allows a PIDL created on one machine to work on another
00037    machine that has the extension installed.
00038    */
00039    WCHAR wszName[MAX_NAME];
00040    WCHAR wszData[MAX_DATA];
00041    }PIDLDATA, FAR *LPPIDLDATA;
00042
00043 /**************************************************************************
00044
00045    CPidlMgr class definition
00046
00047 **************************************************************************/
00048
00049 class CPidlMgr
00050 {
00051 public:
00052    CPidlMgr();
00053    ~CPidlMgr();
00054
00055    VOID Delete(LPITEMIDLIST);
00056    LPITEMIDLIST GetNextItem(LPCITEMIDLIST);
00057    LPITEMIDLIST Copy(LPCITEMIDLIST);
00058    LPITEMIDLIST CopySingleItem(LPCITEMIDLIST);
00059    LPITEMIDLIST GetLastItem(LPCITEMIDLIST);
00060    LPITEMIDLIST Concatenate(LPCITEMIDLIST, LPCITEMIDLIST);
00061    LPITEMIDLIST CreateFolderPidl(LPCTSTR);
00062    LPITEMIDLIST CreateItemPidl(LPCTSTR, LPCTSTR);
00063
00064    int GetName(LPCITEMIDLIST, LPTSTR, DWORD);
00065    int GetRelativeName(LPCITEMIDLIST, LPTSTR, DWORD);
00066    int GetData(LPCITEMIDLIST, LPTSTR, DWORD);
00067    BOOL IsFolder(LPCITEMIDLIST);
00068    int SetData(LPCITEMIDLIST, LPCTSTR);
00069    UINT GetSize(LPCITEMIDLIST);
00070
00071 private:
00072    LPMALLOC m_pMalloc;
00073
00074    LPITEMIDLIST Create(VOID);
00075    LPPIDLDATA GetDataPointer(LPCITEMIDLIST);
00076 };
00077
00078 #endif   //PIDLMGR_H
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagObject Member List

This is the complete list of members for tagObject, including all inherited members.
fContainer | tagObject
hTreeItem | tagObject
Objects | tagObject
Parent | tagObject
pSD | tagObject
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCShip2/Resource.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCShip2

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by QCShip.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_SHIP2                       101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Menu/Menu.h Source File

  • WinUI
  • Menu

Menu.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corp.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 // Porting macro
00013 #ifdef WIN32
00014 #define LONG2POINT(l, pt)  ((pt).x = (SHORT)LOWORD(l), (pt).y = (SHORT)HIWORD(l))
00015 #else
00016 #define LONG2POINT(l, pt)  ((pt).x = (INT)LOWORD(l), (pt).y = (INT)HIWORD(l))
00017 #endif
00018
00019 /* Defines for top-level menu positions */
00020 #define IDFILE_POS     0
00021 #define IDCOLORS_POS   1
00022 #define IDSTATES_POS   2
00023 #define IDHELP_POS     3
00024
00025 #define MEASUREITEMWIDTH  40
00026 #define MEASUREITEMHEIGHT 40
00027
00028 /* Dialog ID for the About.. dialog */
00029 #define ID_ABOUT 100
00030
00031 /* Defines for menu items */
00032 #define IDM_EXIT   202
00033 #define IDM_ABOUT  203
00034
00035 /* Colors menu IDs */
00036 #define IDM_COLOROWNERDR 500
00037 #define IDM_BLACK        501
00038 #define IDM_BLUE         502
00039 #define IDM_RED          503
00040 #define IDM_GREEN        504
00041
00042 /* Floating popup menu IDs */
00043 #define IDM_FONT         600
00044 #define IDM_SIZE         601
00045 #define IDM_STYLE        602
00046
00047 /* States menu IDs */
00048 #define IDM_STATE1       610
00049 #define IDM_STATE2       611
00050 #define IDM_STATE3       612
00051 #define IDM_STATE4       613
00052
00053 /* BitBlt Raster operation */
00054 #define ROP_PSDPxax     0x00B8074AL
00055
00056 BOOL MenuInit (HINSTANCE);
00057 LRESULT CALLBACK MenuWindowProc (HWND, UINT, WPARAM, LPARAM);
00058 INT_PTR APIENTRY AboutDialogProc (HWND, UINT, WPARAM, LPARAM);
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/globals.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

globals.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015
00016 //---------------------------------------------------------------------------
00017 // MMC's requiered clipboard formats
00018
00019 UINT g_cfDisplayName = 0;      // DisplayName for our SnapIn node
00020 UINT g_cfNodeType    = 0;      // GUID of the selected node
00021 UINT g_cfszNodeType  = 0;      // String representation of namespace GUID
00022 UINT g_cfSnapinClsid = 0;      // Class ID of this SnapIn
00023
00024
00025 // Global variables
00026
00027 HINSTANCE g_hInst = NULL;      // Our global instance handle
00028 ULONG g_uObjectCount = 0;      // Global object count
00029 ULONG g_uServerLocks = 0;      // Global lock count
00030
00031
00032 //---------------------------------------------------------------------------
00033 //  This is the fast, simple way to convert unicode to ansi.  It does NOT
00034 //  handle multibyte ansi strings and is not localized.  But it should be
00035 //  fine for registry entries
00036 //  NOTE:  The caller is responsible for freeing the memory.
00037 //
00038 void _fastcall Unicode2Ansi( CHAR** pszAnsi, WCHAR* szWide )
00039 {
00040   LONG nLen = wcslen( szWide ) +1;
00041   *pszAnsi = (char*)CoTaskMemAlloc( nLen );
00042   char* pCounter = *pszAnsi;
00043
00044   while( *szWide )
00045   {
00046     *pCounter = LOBYTE(*szWide);
00047     pCounter++;
00048     szWide++;
00049   }
00050   *pCounter = NULL;
00051 }
00052
00053
00054 //---------------------------------------------------------------------------
00055 //
00056 void InitClipboardFormats()
00057 {
00058   g_cfDisplayName  = RegisterClipboardFormat( T_CCF_DISPLAY_NAME );
00059   g_cfNodeType     = RegisterClipboardFormat( T_CCF_NODETYPE );
00060   g_cfszNodeType   = RegisterClipboardFormat( T_CCF_SZNODETYPE );
00061   g_cfSnapinClsid  = RegisterClipboardFormat( T_CCF_SNAPIN_CLASSID );
00062
00063 }
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/EncryptDecrypt/SessionKey/SessionKey.cpp Source File

  • Security
  • CryptoApi
  • EncryptDecrypt
  • SessionKey

SessionKey.cpp

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2002.  Microsoft Corporation.  All rights reserved.
00008 */
00009
00010 #define _WIN32_WINNT 0x0400
00011 #include <windows.h>
00012 #include <tchar.h>
00013 #include <stdio.h>
00014
00015 const int IN_BUFFER_SIZE    = 64 * 1024;
00016 // OUT_BUFFER_SIZE is 8 bytes larger than IN_BUFFER_SIZE
00017 // When CALG_RC2 algorithm is used, encrypted data
00018 // will be 8 bytes larger than IN_BUFFER_SIZE
00019 const int OUT_BUFFER_SIZE   = IN_BUFFER_SIZE + 8; // extra padding
00020
00021 void PrintUsage()
00022 {
00023    _tprintf(_T("SessionKey <password> [</e>|</d>] <InputFile> <OutputFile>\n"));
00024    _tprintf(_T("/e for Encryption\n"));
00025    _tprintf(_T("/d for Decryption\n"));
00026 }
00027
00028 void _tmain(int argc, TCHAR *argv[])
00029 {
00030    BOOL fResult = FALSE;
00031    HCRYPTPROV hProv = NULL;
00032    HCRYPTHASH hHash = NULL;
00033    HCRYPTKEY hSessionKey = NULL;
00034    HANDLE hInFile = INVALID_HANDLE_VALUE;
00035    HANDLE hOutFile = INVALID_HANDLE_VALUE;
00036    BOOL fEncrypt = FALSE;
00037    BOOL finished = FALSE;
00038    BYTE pbBuffer[OUT_BUFFER_SIZE];
00039    DWORD dwByteCount = 0;
00040    DWORD dwBytesWritten = 0;
00041
00042    if (argc != 5)
00043    {
00044       PrintUsage();
00045       return;
00046    }
00047
00048    __try
00049    {
00050       /* Check whether the action to be performed is encrypt or decrypt */
00051       if (_tcsicmp(argv[2], _T("/e")) == 0)
00052       {
00053          fEncrypt = TRUE;
00054       }
00055       else if (_tcsicmp(argv[2], _T("/d")) == 0)
00056       {
00057          fEncrypt = FALSE;
00058       }
00059       else
00060       {
00061          PrintUsage();
00062          return;
00063       }
00064
00065       // Open the input file to be encrypted or decrypted
00066       hInFile = CreateFile(argv[3],
00067                   GENERIC_READ,
00068                   0,
00069                   NULL,
00070                   OPEN_EXISTING,
00071                   FILE_ATTRIBUTE_NORMAL,
00072                   NULL);
00073       if (hInFile == INVALID_HANDLE_VALUE)
00074       {
00075          _tprintf(_T("CreateFile failed with %d\n"), GetLastError());
00076          __leave;
00077       }
00078
00079       // Open the output file to write the encrypted or decrypted data
00080       hOutFile = CreateFile(argv[4],
00081                   GENERIC_WRITE,
00082                   0,
00083                   NULL,
00084                   CREATE_ALWAYS,
00085                   FILE_ATTRIBUTE_NORMAL,
00086                   NULL);
00087       if (hOutFile == INVALID_HANDLE_VALUE)
00088       {
00089          _tprintf(_T("CreateFile failed with %d\n"), GetLastError());
00090          __leave;
00091       }
00092
00093       // Acquire a handle to MS_DEF_PROV using CRYPT_VERIFYCONTEXT for dwFlags
00094       // parameter as we are going to do only session key encryption or decryption
00095       fResult = CryptAcquireContext(&hProv,
00096                                     NULL,
00097                                     MS_DEF_PROV,
00098                                     PROV_RSA_FULL,
00099                                     CRYPT_VERIFYCONTEXT);
00100       if (!fResult)
00101       {
00102          _tprintf(_T("CryptAcquireContext failed with %X\n"), GetLastError());
00103          __leave;
00104       }
00105
00106       fResult = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash);
00107       if (!fResult)
00108       {
00109          _tprintf(_T("CryptCreateHash failed with %X\n"), GetLastError());
00110          __leave;
00111       }
00112
00113       // Hash the supplied secret password
00114       fResult = CryptHashData(hHash, (LPBYTE)argv[1], (DWORD)_tcslen(argv[1]), 0);
00115       if (!fResult)
00116       {
00117          _tprintf(_T("CryptHashData failed with %X\n"), GetLastError());
00118          __leave;
00119       }
00120
00121       // Derive a symmetric session key from password hash
00122       fResult = CryptDeriveKey(hProv, CALG_RC4, hHash, 0, &hSessionKey);
00123       if (!fResult)
00124       {
00125          _tprintf(_T("CryptDeriveKey failed with %X\n"), GetLastError());
00126          __leave;
00127       }
00128
00129       do
00130       {
00131          dwByteCount = 0;
00132
00133          // Now read data from the input file 64K bytes at a time.
00134          fResult = ReadFile(hInFile, pbBuffer, IN_BUFFER_SIZE, &dwByteCount, NULL);
00135
00136          // If the file size is exact multiple of 64K, dwByteCount will be zero after
00137          // all the data has been read from the input file. In this case, simply break
00138          // from the while loop. The check to do this is below
00139          if (dwByteCount == 0)
00140             break;
00141
00142          if (!fResult)
00143          {
00144             _tprintf(_T("ReadFile failed with %d\n"), GetLastError());
00145             __leave;
00146          }
00147
00148          finished = (dwByteCount < IN_BUFFER_SIZE);
00149
00150          // Encrypt/Decrypt depending on the required action.
00151          if (fEncrypt)
00152          {
00153             fResult = CryptEncrypt(hSessionKey, 0, finished, 0, pbBuffer, &dwByteCount,
00154                            OUT_BUFFER_SIZE);
00155             if (!fResult)
00156             {
00157                _tprintf(_T("CryptEncrypt failed with %X\n"), GetLastError());
00158                __leave;
00159             }
00160          }
00161          else
00162          {
00163             fResult = CryptDecrypt(hSessionKey, 0, finished, 0, pbBuffer, &dwByteCount);
00164             if (!fResult)
00165             {
00166                _tprintf(_T("CryptDecrypt failed with %X\n"), GetLastError());
00167                __leave;
00168             }
00169          }
00170
00171          // Write the encrypted/decrypted data to the output file.
00172          fResult = WriteFile(hOutFile, pbBuffer, dwByteCount,
00173             &dwBytesWritten, NULL);
00174          if (!fResult)
00175          {
00176             _tprintf(_T("WriteFile failed with %d\n"), GetLastError());
00177             __leave;
00178          }
00179
00180       } while (!finished);
00181
00182       if (fEncrypt)
00183          _tprintf(_T("File %s is encrypted successfully!\n"), argv[3]);
00184       else
00185          _tprintf(_T("File %s is decrypted successfully!\n"), argv[3]);
00186    }
00187    __finally
00188    {
00189       /* Cleanup */
00190       if (hInFile != INVALID_HANDLE_VALUE) CloseHandle(hInFile);
00191       if (hOutFile != INVALID_HANDLE_VALUE) CloseHandle(hOutFile);
00192       if (hSessionKey != NULL) CryptDestroyKey(hSessionKey);
00193       if (hHash != NULL) CryptDestroyHash(hHash);
00194       if (hProv != NULL) CryptReleaseContext(hProv, 0);
00195    }
00196 }
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkCollection/C#/InkCollection.cs Source File

  • TabletPC
  • InkCollection
  • C#

InkCollection.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: InkCollection.cs
00013 //  Simple Ink Collection Sample Application
00014 //
00015 //  This sample program is a "Hello World" application, which
00016 //  demonstrates basic functionality of the Tablet PC platform.
00017 //  It is the simplest program that you can build using the
00018 //  Tablet PC Platform APIs. This application uses an ink
00019 //  collector to collect and render pen input.
00020 //
00021 //  The features used are: InkCollector, default tablet, and
00022 //  modifying default drawing attributes.
00023 //
00024 //--------------------------------------------------------------------------
00025
00026 using System;
00027 using System.Drawing;
00028 using System.Windows.Forms;
00029
00030 // The Ink namespace, which contains the Tablet PC Platform API
00031 using Microsoft.Ink;
00032
00033
00034 namespace InkCollection
00035 {
00036   /// <summary>
00037   /// The InkCollection Sample Application form class
00038   /// </summary>
00039   public class InkCollection : System.Windows.Forms.Form
00040   {
00041
00042         // Declare the Ink Collector object
00043         private InkCollector myInkCollector;
00044
00045         // Declare constants for the pen widths used by this application.
00046         // Note that these constants are in high metric units (1 unit = .01mm)
00047         private const float ThinInkWidth = 10;
00048         private const float MediumInkWidth = 100;
00049         private const float ThickInkWidth = 200;
00050
00051         #region Standard Template Code
00052
00053         private System.Windows.Forms.MenuItem miMainFile;
00054         private System.Windows.Forms.MenuItem miExit;
00055         private System.Windows.Forms.MenuItem miMainInk;
00056         private System.Windows.Forms.MenuItem miEnabled;
00057         private System.Windows.Forms.MenuItem miColor;
00058         private System.Windows.Forms.MenuItem miRed;
00059         private System.Windows.Forms.MenuItem miGreen;
00060         private System.Windows.Forms.MenuItem miBlue;
00061         private System.Windows.Forms.MenuItem miBlack;
00062         private System.Windows.Forms.MenuItem miWidth;
00063         private System.Windows.Forms.MenuItem miThin;
00064         private System.Windows.Forms.MenuItem miMedium;
00065         private System.Windows.Forms.MenuItem miThick;
00066         private System.Windows.Forms.MainMenu miMain;
00067         private System.ComponentModel.Container components = null;
00068         #endregion
00069
00070     public InkCollection()
00071     {
00072             #region Standard Template Code
00073       // Required for Windows Form Designer support
00074       InitializeComponent();
00075             #endregion
00076         }
00077
00078         #region Standard Template Code
00079     /// <summary>
00080     /// Clean up any resources being used.
00081     /// </summary>
00082     protected override void Dispose( bool disposing )
00083     {
00084       if( disposing )
00085       {
00086         if (components != null)
00087         {
00088           components.Dispose();
00089         }
00090       }
00091       base.Dispose( disposing );
00092     }
00093         #endregion
00094
00095     #region Windows Form Designer generated code
00096     /// <summary>
00097     /// ----- Standard Template Code -----
00098     /// Required method for Designer support - do not modify
00099     /// the contents of this method with the code editor.
00100     /// </summary>
00101     private void InitializeComponent()
00102     {
00103             this.miMain = new System.Windows.Forms.MainMenu();
00104             this.miMainFile = new System.Windows.Forms.MenuItem();
00105             this.miExit = new System.Windows.Forms.MenuItem();
00106             this.miMainInk = new System.Windows.Forms.MenuItem();
00107             this.miEnabled = new System.Windows.Forms.MenuItem();
00108             this.miColor = new System.Windows.Forms.MenuItem();
00109             this.miRed = new System.Windows.Forms.MenuItem();
00110             this.miGreen = new System.Windows.Forms.MenuItem();
00111             this.miBlue = new System.Windows.Forms.MenuItem();
00112             this.miBlack = new System.Windows.Forms.MenuItem();
00113             this.miWidth = new System.Windows.Forms.MenuItem();
00114             this.miThin = new System.Windows.Forms.MenuItem();
00115             this.miMedium = new System.Windows.Forms.MenuItem();
00116             this.miThick = new System.Windows.Forms.MenuItem();
00117             //
00118             // miMain
00119             //
00120             this.miMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00121                                                                                    this.miMainFile,
00122                                                                                    this.miMainInk});
00123             //
00124             // miMainFile
00125             //
00126             this.miMainFile.Index = 0;
00127             this.miMainFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00128                                                                                        this.miExit});
00129             this.miMainFile.Text = "File";
00130             //
00131             // miExit
00132             //
00133             this.miExit.Index = 0;
00134             this.miExit.Text = "Exit";
00135             this.miExit.Click += new System.EventHandler(this.miExit_Click);
00136             //
00137             // miMainInk
00138             //
00139             this.miMainInk.Index = 1;
00140             this.miMainInk.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00141                                                                                       this.miEnabled,
00142                                                                                       this.miColor,
00143                                                                                       this.miWidth});
00144             this.miMainInk.Text = "Ink";
00145             //
00146             // miEnabled
00147             //
00148             this.miEnabled.Checked = true;
00149             this.miEnabled.Index = 0;
00150             this.miEnabled.Text = "Enabled";
00151             this.miEnabled.Click += new System.EventHandler(this.miEnabled_Click);
00152             //
00153             // miColor
00154             //
00155             this.miColor.Index = 1;
00156             this.miColor.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00157                                                                                     this.miRed,
00158                                                                                     this.miGreen,
00159                                                                                     this.miBlue,
00160                                                                                     this.miBlack});
00161             this.miColor.Text = "Color";
00162             //
00163             // miRed
00164             //
00165             this.miRed.Index = 0;
00166             this.miRed.Text = "Red";
00167             this.miRed.Click += new System.EventHandler(this.miRed_Click);
00168             //
00169             // miGreen
00170             //
00171             this.miGreen.Index = 1;
00172             this.miGreen.Text = "Green";
00173             this.miGreen.Click += new System.EventHandler(this.miGreen_Click);
00174             //
00175             // miBlue
00176             //
00177             this.miBlue.Index = 2;
00178             this.miBlue.Text = "Blue";
00179             this.miBlue.Click += new System.EventHandler(this.miBlue_Click);
00180             //
00181             // miBlack
00182             //
00183             this.miBlack.Index = 3;
00184             this.miBlack.Text = "Black";
00185             this.miBlack.Click += new System.EventHandler(this.miBlack_Click);
00186             //
00187             // miWidth
00188             //
00189             this.miWidth.Index = 2;
00190             this.miWidth.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00191                                                                                     this.miThin,
00192                                                                                     this.miMedium,
00193                                                                                     this.miThick});
00194             this.miWidth.Text = "Width";
00195             //
00196             // miThin
00197             //
00198             this.miThin.Index = 0;
00199             this.miThin.Text = "Thin";
00200             this.miThin.Click += new System.EventHandler(this.miThin_Click);
00201             //
00202             // miMedium
00203             //
00204             this.miMedium.Index = 1;
00205             this.miMedium.Text = "Medium";
00206             this.miMedium.Click += new System.EventHandler(this.miMedium_Click);
00207             //
00208             // miThick
00209             //
00210             this.miThick.Index = 2;
00211             this.miThick.Text = "Thick";
00212             this.miThick.Click += new System.EventHandler(this.miThick_Click);
00213             //
00214             // InkCollection
00215             //
00216             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00217             this.ClientSize = new System.Drawing.Size(292, 245);
00218             this.Menu = this.miMain;
00219             this.Name = "InkCollection";
00220             this.Text = "Ink Collection Sample";
00221             this.Load += new System.EventHandler(this.InkCollection_Load);
00222
00223         }
00224     #endregion
00225
00226         #region Standard Template Code
00227     /// <summary>
00228     /// The main entry point for the application.
00229     /// </summary>
00230     [STAThread]
00231     static void Main()
00232     {
00233       Application.Run(new InkCollection());
00234     }
00235         #endregion
00236
00237         /// <summary>
00238         /// Event Handler from Form Load Event
00239         /// Setup the ink collector for collection
00240         /// </summary>
00241         /// <param name="sender">The control that raised the event.</param>
00242         /// <param name="e">The event arguments.</param>
00243         private void InkCollection_Load(object sender, System.EventArgs e)
00244         {
00245
00246             // Create a new ink collector and assign it to this form's window
00247             myInkCollector = new InkCollector(this.Handle);
00248
00249             // Set the pen width to be a medium width
00250             myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;
00251
00252             //
00253             // If you do not modify the default drawing attributes, the default
00254             // drawing attributes will use the following properties and values:
00255             //
00256             //      AntiAliased     = true
00257             //      Color           = black
00258             //      FitToCurve      = false
00259             //      Height          = 1
00260             //      IgnorePressure  = false
00261             //      PenTip          = ball
00262             //      RasterOperation = copy pen
00263             //      Transparency    = 0
00264             //      Width           = 53 (2 pixels on a 96 dpi screen)
00265             //
00266             // For an example of how to modify other drawing attributes, uncomment
00267             // the following lines of code:
00268             // myInkCollector.DefaultDrawingAttributes.PenTip = PenTip.Rectangle;
00269             // myInkCollector.DefaultDrawingAttributes.Height = (.5F)*MediumInkWidth;
00270             // myInkCollector.DefaultDrawingAttributes.Transparency = 128;
00271             //
00272
00273             // Turn the ink collector on
00274             myInkCollector.Enabled = true;
00275         }
00276
00277     /// <summary>
00278     /// Event Handler from Ink->Color->Red Menu Item
00279     /// </summary>
00280     /// <param name="sender">The control that raised the event.</param>
00281     /// <param name="e">The event arguments.</param>
00282         private void miRed_Click(object sender, System.EventArgs e)
00283         {
00284             myInkCollector.DefaultDrawingAttributes.Color = Color.Red;
00285     }
00286
00287         /// <summary>
00288         /// Event Handler from Ink->Color->Green Menu Item
00289         /// </summary>
00290         /// <param name="sender">The control that raised the event.</param>
00291         /// <param name="e">The event arguments.</param>
00292         private void miGreen_Click(object sender, System.EventArgs e)
00293         {
00294             myInkCollector.DefaultDrawingAttributes.Color = Color.Green;
00295         }
00296
00297         /// <summary>
00298         /// Event Handler from Ink->Color->Blue Menu Item
00299         /// </summary>
00300         /// <param name="sender">The control that raised the event.</param>
00301         /// <param name="e">The event arguments.</param>
00302         private void miBlue_Click(object sender, System.EventArgs e)
00303         {
00304             myInkCollector.DefaultDrawingAttributes.Color = Color.Blue;
00305         }
00306
00307         /// <summary>
00308         /// Event Handler from Ink->Color->Black Menu Item
00309         /// </summary>
00310         /// <param name="sender">The control that raised the event.</param>
00311         /// <param name="e">The event arguments.</param>
00312         private void miBlack_Click(object sender, System.EventArgs e)
00313         {
00314             myInkCollector.DefaultDrawingAttributes.Color = Color.Black;
00315         }
00316
00317         /// <summary>
00318         /// Event Handler from Ink->Width->Thin Menu Item
00319         /// </summary>
00320         /// <param name="sender">The control that raised the event.</param>
00321         /// <param name="e">The event arguments.</param>
00322         private void miThin_Click(object sender, System.EventArgs e)
00323         {
00324             myInkCollector.DefaultDrawingAttributes.Width = ThinInkWidth;
00325         }
00326
00327         /// <summary>
00328         /// Event Handler from Ink->Width->Medium Menu Item
00329         /// </summary>
00330         /// <param name="sender">The control that raised the event.</param>
00331         /// <param name="e">The event arguments.</param>
00332         private void miMedium_Click(object sender, System.EventArgs e)
00333         {
00334             myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;
00335         }
00336
00337         /// <summary>
00338         /// Event Handler from Ink->Width->Thick Menu Item
00339         /// </summary>
00340         /// <param name="sender">The control that raised the event.</param>
00341         /// <param name="e">The event arguments.</param>
00342         private void miThick_Click(object sender, System.EventArgs e)
00343         {
00344             myInkCollector.DefaultDrawingAttributes.Width = ThickInkWidth;
00345         }
00346
00347         /// <summary>
00348         /// Event Handler from File->Exit Menu Item
00349         /// </summary>
00350         /// <param name="sender">The control that raised the event.</param>
00351         /// <param name="e">The event arguments.</param>
00352         private void miExit_Click(object sender, System.EventArgs e)
00353         {
00354             myInkCollector.Enabled = false;
00355             this.Dispose();
00356         }
00357
00358         /// <summary>
00359         /// Event Handler from Ink->Enabled Menu Item
00360         /// </summary>
00361         /// <param name="sender">The control that raised the event.</param>
00362         /// <param name="e">The event arguments.</param>
00363         private void miEnabled_Click(object sender, System.EventArgs e)
00364         {
00365             // Toggle the enabled state of the ink collector
00366             myInkCollector.Enabled = !myInkCollector.Enabled;
00367             miEnabled.Checked = myInkCollector.Enabled;
00368         }
00369
00370   }
00371 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/Viewlist.h Source File

  • WinUI
  • Shell
  • SampView

Viewlist.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ViewList.h
00013
00014    Description:   CViewList definitions.
00015
00016 **************************************************************************/
00017
00018 #ifndef VIEWLIST_H
00019 #define VIEWLIST_H
00020
00021 #include <windows.h>
00022 #include <shlobj.h>
00023
00024 #include "PidlMgr.h"
00025 #include "ShlView.h"
00026
00027 /**************************************************************************
00028    structure defintions
00029 **************************************************************************/
00030
00031 typedef struct tagVIEWLIST
00032    {
00033    struct tagVIEWLIST   *pNext;
00034    CShellView           *pView;
00035    }VIEWLIST, FAR *LPVIEWLIST;
00036
00037 /**************************************************************************
00038
00039    CViewList class definition
00040
00041 **************************************************************************/
00042
00043 class CViewList
00044 {
00045 public:
00046    CViewList();
00047    ~CViewList();
00048
00049    CShellView* GetNextView (CShellView*);
00050    BOOL AddToList(CShellView*);
00051    VOID RemoveFromList(CShellView*);
00052
00053 private:
00054    BOOL DeleteList(VOID);
00055    LPMALLOC m_pMalloc;
00056    LPVIEWLIST m_pFirst;
00057    LPVIEWLIST m_pLast;
00058 };
00059
00060 #endif   //VIEWLIST_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagTools Member List

This is the complete list of members for _tagTools, including all inherited members.
hIcon | _tagTools
hwnd | _tagTools
iHeight | _tagTools
iWidth | _tagTools
wType | _tagTools
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Find.c Source File

  • WinUI
  • CommDlg
  • CDTest

Find.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 /************************************************************************
00007
00008   File: find.c
00009
00010   Purpose:
00011
00012      Manages CDTEST's find/replace dialog box.
00013
00014   Functions:
00015
00016     - lpfnFilterProc()      -- A callback function for a filter that must be
00017                                installed if a modeless dialog is created with
00018                                another dialog as its parent.
00019
00020     - DoFindDialog()        -- Creates CDTEST's Open/Save dialog.
00021
00022     - FindProc()            -- Callback function for CDTEST's Find/Replace dlg.
00023
00024     - InitFindStruct()      -- Fills a FINDREPLACE structure with some defaults.
00025
00026     - FillFindDlg()         -- Fills CDTESTs Find/Replace dialog with the contents
00027                                of a FINDREPLACE structure.
00028
00029     - GetFindDlg()          -- Retrieves the users edit's from CDTEST's find/
00030                                replace dialog and puts them in a FINDREPLACE
00031                                structure.
00032
00033     - FindReplaceHookProc() -- Callback function for FindText() or ReplaceText()
00034                                which will be called if either of these dialogs
00035                                is created with the FR_ENABLEHOOK flag.
00036
00037     - GetFindDlgHandle()    -- Returns a handle to a preloaded FindText() template.
00038
00039     - GetReplaceDlgHandle() -- Returns a handle to a preloaded ReplaceText() template.
00040
00041     - DoFindRepStuff()      -- Calls FindText() or ReplaceText().
00042
00043
00044   NOTE: CDTEST does not multithread the FindText() or the ReplaceText()
00045         common dialogs.  The reason for this is that since these dialogs
00046         are modeless, their creation functions return immediately after the
00047         dialogs are created as opposed to other dialog functions that
00048         don't return until after the dialog has been destroyed by the user.
00049
00050         As a result, any threads that create modeless dialogs will end
00051         immediately unless the threads themselves have separate message
00052         loops.  For the sake of clarity, this functionality has not been
00053         added to CDTEST.
00054
00055 ************************************************************************/
00056
00057
00058 #include <windows.h>
00059 #include <commdlg.h>
00060 #include <stdlib.h>
00061 #include <winnls.h>
00062 #include <shlwapi.h>
00063 #include "cdtest.h"
00064 #include "find.h"
00065 #include "replace.h"
00066
00067
00068 /* All functions used in this module + some exported ones */
00069
00070 void InitFindStruct(HWND, LPFINDREPLACE) ;
00071 void FillFindDlg(HWND, LPFINDREPLACE) ;
00072 void GetFindDlg(HWND, LPFINDREPLACE) ;
00073 extern UINT_PTR uMode ;
00074 extern LONG_PTR MyAtol(LPTSTR, BOOL, LPBOOL) ;
00075 UINT_PTR CALLBACK FindReplaceHookProc(HWND, UINT, WPARAM, LPARAM) ;
00076 void DoFindRepStuff(LPFINDREPLACE) ;
00077
00078
00079
00080 /* All global variables used in this module */
00081
00082 HWND hwndFind ;
00083 HWND hwndMainDialog ;
00084
00085 FINDREPLACE fr ;
00086 LPFINDREPLACE lpFr ;
00087
00088 TCHAR szFindWhat[100] ;
00089 TCHAR szReplaceWith[100] ;
00090 TCHAR szTemplate[40] ;
00091
00092 HRSRC hResFind;
00093 HGLOBAL hDialogFind ;
00094 HANDLE GetFindDlgHandle(void) ;
00095 HANDLE GetReplaceDlgHandle(void) ;
00096
00097 HBRUSH hBrushDlg ;
00098 HBRUSH hBrushEdit ;    //brush handles for new colors done with hook proc
00099 HBRUSH hBrushButton ;
00100
00101
00102
00103
00104
00105 /************************************************************************
00106
00107   Function: lpfnFilterProc(int, WPARAM, LAPRAM)
00108
00109   Purpose: This is needed if a modeless dialog is created with its parent
00110            as another dialog box.
00111
00112
00113   Returns: TRUE if the message was handled and FALSE if not.
00114
00115   Comments:
00116
00117     The reason for this is that the DialogBox() procedure does not call
00118     the IsDialogMessage() function before it processes messages, so we
00119     need to install a hook function to do it for us.
00120
00121 ************************************************************************/
00122
00123
00124 LRESULT CALLBACK lpfnFilterProc(int nCode, WPARAM wParam, LPARAM lParam)
00125 {
00126   static bFirstTime = TRUE ;
00127
00128   if (nCode < 0)
00129     return CallNextHookEx(hHook, nCode, wParam, lParam) ;
00130
00131   if (nCode == MSGF_DIALOGBOX && bFirstTime)
00132   {
00133     bFirstTime = FALSE ;
00134
00135     if (hwndFind && IsDialogMessage(hwndFind, (LPMSG) lParam))
00136     {
00137       bFirstTime = TRUE ;
00138       return 1L ;
00139     }
00140
00141     else
00142     {
00143       bFirstTime = TRUE ;
00144       return 0L ;
00145     }
00146   }
00147   else return 0L ;
00148 }
00149
00150
00151
00152
00153
00154
00155
00156 /************************************************************************
00157
00158   Function: DoFindDialog(HWND)
00159
00160   Purpose: This function installs the Hook function, creates the Find/
00161            Replace dialog, and un-installs the Hook.
00162
00163   Returns: Nothing.
00164
00165   Comments:
00166
00167 ************************************************************************/
00168
00169 void DoFindDialog(HWND hwnd)
00170 {
00171   bDoFindDlg = TRUE ;
00172
00173   /* this is a little different than the others.  If the dialog is just
00174      created normally, it will make no IsDlgMessage() checks and the
00175      find/replace dialogs will have no keyboard input (i.e. tabbing and
00176      alt+key-ing from control to control.  To fix this, a message hook
00177      and message filter have to be installed
00178
00179      It must be set to only look at the input for the current thread, or other
00180      programs will be interrupted by this hook also.
00181   */
00182
00183   hHook = SetWindowsHookEx(WH_MSGFILTER, lpfnFilterProc,
00184                            hInst, GetCurrentThreadId()) ;
00185
00186   if (!hHook) return ;
00187
00188   DialogBox(hInst, MAKEINTRESOURCE(ID_FINDDIALOG), hwnd, FindProc) ;
00189
00190   UnhookWindowsHookEx(hHook) ;
00191
00192 }
00193
00194
00195
00196
00197
00198
00199
00200 /************************************************************************
00201
00202   Function: FindProc(HWND, UINT, WPARAM, LPARAM)
00203
00204   Purpose: This is the callback function for the CDTEST's Find/Replace
00205            Dialog.
00206
00207   Returns: TRUE or FALSE depending on the situation.
00208
00209   Comments:
00210
00211 ************************************************************************/
00212
00213 INT_PTR APIENTRY FindProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00214 {
00215   switch (msg)
00216   {
00217     case WM_INITDIALOG:
00218
00219         if (bDoFindDlg)
00220           SetWindowText(hwnd, TEXT("FindText()")) ;
00221         else
00222           SetWindowText(hwnd, TEXT("ReplaceText()")) ;
00223
00224         InitFindStruct(hwnd, &fr) ;
00225         FillFindDlg(hwnd, &fr) ;
00226
00227         hwndMainDialog = hwnd ;
00228
00229
00230         /* The find and replace dialogs are a lot harder to multithread because they
00231            are modeless.  Modeless dialog creation functions return right after the
00232            dialog is created.  Since ExitThread will be called at this point, it is
00233            probably not possible to multithread these dialogs without a separate
00234            GetMessage() loop.
00235         */
00236
00237
00238         EnableWindow(GetDlgItem(hwnd, ID_MULTITHREADFINDREP), FALSE) ;
00239
00240         SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEFT)) ;
00241
00242         break ;
00243
00244
00245     case WM_COMMAND:
00246     {
00247         switch (LOWORD(wParam))
00248         {
00249           case IDOK:
00250             GetFindDlg(hwnd, &fr) ;
00251             DoFindRepStuff(&fr) ;
00252             break ;
00253
00254           case ID_RESETFIND:
00255             SendDlgItemMessage(hwnd, ID_FRNULLSTRUCT, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00256             SendDlgItemMessage(hwnd, ID_PRELOADEDFIND, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
00257             InitFindStruct(hwnd, &fr) ;
00258             FillFindDlg(hwnd, &fr) ;
00259             SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEFT)) ;
00260             break ;
00261
00262           case IDCANCEL:
00263             EndDialog(hwnd, FALSE) ;
00264
00265             break ;
00266
00267
00268           default: break ;
00269         }
00270
00271     }
00272
00273     default:
00274
00275
00276     /* nFindMsg is registered at program startup (see CDTEST.c).  The
00277        FindText() and ReplaceText() dialogs will communicate with the
00278        calling application via this message. */
00279
00280     if (msg == nFindMsg)
00281     {
00282         lpFr = (LPFINDREPLACE) lParam ;
00283
00284         if (lpFr->Flags & FR_DIALOGTERM)
00285         {
00286           PostMessage(hwnd, UMSG_DECREMENTDLGCOUNT, 0, 0L) ;
00287
00288           if (hDialogFind)
00289           {
00290             FreeResource(hDialogFind) ;
00291             hDialogFind = (HANDLE) 0 ;
00292             hResFind = (HANDLE) 0 ;
00293           }
00294
00295           hwndFind = (HWND) 0 ;
00296         }
00297
00298         FillFindDlg(hwnd, &fr) ;
00299
00300         wsprintf(szTemp, szLongFilter, CommDlgExtendedError()) ;
00301         SetDlgItemText(hwnd, ID_ERRORFT, szTemp) ;
00302
00303         wsprintf(szTemp, szLongFilter, hwndFind) ;
00304         SetDlgItemText(hwnd, ID_RETURNFT, szTemp) ;
00305     }
00306
00307
00308     /* If the help button is pressed in the FindText() or ReplaceText()
00309        dialogs, it will send a message Registered with RegisterWindowMessage()
00310        to the parent window.  The message nHelpMessage was registered
00311        at application startup */
00312
00313     if (msg == nHelpMessage)
00314       MessageBox(GetForegroundWindow(), TEXT("Hello from the help button"),
00315                  TEXT("Find Help Button"), MB_OK | MB_APPLMODAL) ;
00316
00317     break ;
00318   }
00319
00320   return FALSE ;
00321 }
00322
00323
00324
00325
00326
00327
00328 /************************************************************************
00329
00330   Function: InitFindStruct(HWND, LPFINDREPLACE)
00331
00332   Purpose: Fills a FINDREPLACE structure with some defaults.
00333
00334
00335   Returns: Nothing.
00336
00337   Comments:
00338
00339 ************************************************************************/
00340
00341 void InitFindStruct(HWND hwnd, LPFINDREPLACE pfr)
00342 {
00343   pfr->lStructSize = (DWORD) sizeof(FINDREPLACE) ;
00344   pfr->hwndOwner = hwnd ;
00345   pfr->hInstance = (HANDLE) hInst ;
00346   pfr->Flags = FR_DOWN | FR_SHOWHELP  ;
00347
00348   lstrcpyn(szFindWhat, TEXT("Word to find"), ARRAYSIZE(szFindWhat)) ;
00349   pfr->lpstrFindWhat = szFindWhat ;
00350   pfr->wFindWhatLen = 100 ;
00351
00352   lstrcpyn(szReplaceWith, TEXT("Replace with word"), ARRAYSIZE(szReplaceWith)) ;
00353   pfr->lpstrReplaceWith = szReplaceWith ;
00354   pfr->wReplaceWithLen = 100 ;
00355
00356   pfr->lCustData = (DWORD) 0 ;
00357
00358   pfr->lpfnHook = FindReplaceHookProc ;
00359
00360   lstrcpyn(szTemplate, TEXT("fttemp1"), ARRAYSIZE(szTemplate)) ;
00361
00362   pfr->lpTemplateName = szTemplate ;
00363 }
00364
00365
00366
00367
00368
00369
00370 /************************************************************************
00371
00372   Function: FillFindDlg(HWND, LPFINDREPLACE)
00373
00374   Purpose:  Fills CDTEST's Find/Replace dialog with the contents of a
00375             FINDREPLACE structure.
00376
00377   Returns:  Nothing.
00378
00379   Comments:
00380
00381 ************************************************************************/
00382
00383 void FillFindDlg(HWND hwnd, LPFINDREPLACE pfr)
00384 {
00385   wsprintf(szTemp, szLongFilter, pfr->lStructSize) ;
00386   SetDlgItemText(hwnd, ID_STRUCTSIZEFT, szTemp) ;
00387
00388   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) pfr->hwndOwner) ;
00389   SetDlgItemText(hwnd, ID_HWNDOWNERFT, szTemp) ;
00390
00391   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) pfr->hInstance) ;
00392   SetDlgItemText(hwnd, ID_HINSTANCEFT, szTemp) ;
00393
00394   wsprintf(szTemp, szLongFilter, pfr->Flags) ;
00395   SetDlgItemText(hwnd, ID_FLAGSFT, szTemp) ;
00396
00397   SetDlgItemText(hwnd, ID_FINDWHATFT, pfr->lpstrFindWhat) ;
00398
00399   wsprintf(szTemp, szLongFilter, pfr->wFindWhatLen) ;
00400   SetDlgItemText(hwnd, ID_FINDWHATLENFT, szTemp) ;
00401
00402   SetDlgItemText(hwnd, ID_REPLACEWITHFT, pfr->lpstrReplaceWith) ;
00403
00404   wsprintf(szTemp, szLongFilter, pfr->wReplaceWithLen) ;
00405   SetDlgItemText(hwnd, ID_REPLACEWITHLENFT, szTemp) ;
00406
00407   wsprintf(szTemp, szLongFilter, pfr->lCustData) ;
00408   SetDlgItemText(hwnd, ID_CUSTDATAFT, szTemp) ;
00409
00410   wsprintf(szTemp, szPointerFilter, (DWORD_PTR) pfr->lpfnHook) ;
00411   SetDlgItemText(hwnd, ID_HOOKFT, szTemp) ;
00412
00413   SetDlgItemText(hwnd, ID_TEMPLATEFT, pfr->lpTemplateName) ;
00414 }
00415
00416
00417
00418
00419
00420
00421 /************************************************************************
00422
00423   Function: GetFindDlg(HWND, LPFINDREPLACE)
00424
00425   Purpose:  Fills a FINDREPLACE structure with the user's edits in CDTEST's
00426             Find/Replace dialog.
00427
00428   Returns:  Nothing.
00429
00430   Comments:
00431
00432 ************************************************************************/
00433
00434 void GetFindDlg(HWND hwnd, LPFINDREPLACE pfr)
00435 {
00436   TCHAR szNum[30] ;
00437   BOOL b ;
00438
00439   #define WSIZEFR 30
00440
00441   GetDlgItemText(hwnd, ID_STRUCTSIZEFT, szNum, WSIZEFR) ;
00442   pfr->lStructSize = (DWORD) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00443
00444   GetDlgItemText(hwnd, ID_HWNDOWNERFT, szNum, WSIZEFR) ;
00445   pfr->hwndOwner = (HWND) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00446
00447   GetDlgItemText(hwnd, ID_HINSTANCEFT, szNum, WSIZEFR) ;
00448   pfr->hInstance = (HANDLE) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00449
00450   GetDlgItemText(hwnd, ID_FLAGSFT, szNum, WSIZEFR) ;
00451   pfr->Flags = (DWORD) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00452
00453
00454   GetDlgItemText(hwnd, ID_FINDWHATFT, szFindWhat, 100) ;
00455
00456   GetDlgItemText(hwnd, ID_REPLACEWITHFT, szReplaceWith, 100) ;
00457
00458
00459   GetDlgItemText(hwnd, ID_FINDWHATLENFT, szNum, WSIZEFR) ;
00460   pfr->wFindWhatLen = (WORD) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00461
00462   GetDlgItemText(hwnd, ID_REPLACEWITHLENFT, szNum, WSIZEFR) ;
00463   pfr->wReplaceWithLen = (WORD) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00464
00465   GetDlgItemText(hwnd, ID_CUSTDATAFT, szNum, WSIZEFR) ;
00466   pfr->lCustData = MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00467
00468   GetDlgItemText(hwnd, ID_HOOKFT, szNum, WSIZEFR) ;
00469   pfr->lpfnHook = (LPFRHOOKPROC) MyAtol(szNum, uMode == IDM_HEXMODE, &b) ;
00470
00471   GetDlgItemText(hwnd, ID_TEMPLATEFT, szTemplate, 40) ;
00472 }
00473
00474
00475
00476
00477
00478
00479 /************************************************************************
00480
00481   Function: FindReplaceHookProc(HWND, UINT, WPARAM, LPARAM)
00482
00483   Purpose:  Is the callback function that will be called by FindText()
00484             or ReplaceText() if the function is called with the
00485             FR_ENABLEHOOK flag.
00486
00487
00488   Returns:  TRUE to discard the message, and FALSE to instruct the common
00489             dialogs to process the message with the default logic.
00490
00491   Comments:
00492
00493      NOTE!
00494
00495      If the application returns FALSE in response to the WM_INITDIALOG
00496      message, it is then responsible for displaying the dialog by
00497      calling ShowWindow() and UpdateWindow().
00498
00499 ***********************************************************************/
00500
00501
00502 UINT_PTR CALLBACK FindReplaceHookProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00503 {
00504   LPFINDREPLACE pFr ;
00505   TCHAR szMsg[75] ;
00506   TCHAR szTmp[20] ;
00507   int i ;
00508   TCHAR szDefString[] = TEXT("Default String ") ;
00509
00510   switch(msg)
00511   {
00512     case WM_INITDIALOG:
00513
00514       pFr = (LPFINDREPLACE) lParam ;
00515
00516       if (pFr->lCustData != 0L)
00517       {
00518         wsprintf(szMsg, TEXT("FINDREPLACE->lCustData is: %ld"), pFr->lCustData) ;
00519
00520         MessageBox(hwnd, szMsg, TEXT("lCustData Sent!"), MB_OK | MB_APPLMODAL) ;
00521       }
00522
00523       SetWindowText(hwnd, TEXT("Find Hook Proc Dialog")) ;
00524
00525       if (GetDlgItem(hwnd, ID_DEFSTRINGS))
00526       {
00527         for (i=0; i<5; i++)
00528         {
00529           lstrcpyn(szMsg, szDefString, ARRAYSIZE(szMsg)) ;
00530           wsprintf(szTmp, TEXT("Number %d"), i+1) ;
00531           StrCatBuff(szMsg, szTmp, ARRAYSIZE(szTmp)) ;
00532           SendDlgItemMessage(hwnd, ID_DEFSTRINGS, LB_ADDSTRING, (WPARAM) 0,
00533                              (LONG_PTR) (LPTSTR) szMsg) ;
00534         }
00535       }
00536
00537       return 1 ;
00538
00539       break ;
00540
00541
00542
00543     /* use the WM_CTLCOLOR* messages to change the color of the Open
00544        dialog */
00545
00546     case WM_CTLCOLORDLG:
00547
00548         if (!hBrushDlg)
00549             hBrushDlg = GetStockObject(LTGRAY_BRUSH) ;
00550
00551         return (LRESULT) hBrushDlg;
00552
00553         break ;
00554
00555
00556     case WM_CTLCOLORBTN:
00557
00558         SetBkMode((HDC) wParam, TRANSPARENT) ;   //sets background color
00559                                                  //for push and check box
00560                                                  //buttons...
00561
00562         if (!hBrushButton)
00563             hBrushButton = GetStockObject(LTGRAY_BRUSH) ;
00564
00565         return (LRESULT) hBrushButton ;
00566
00567         break ;
00568
00569
00570     case WM_CTLCOLORSTATIC:
00571
00572         SetTextColor((HDC) wParam, RGB(0x00, 0xff, 0x00)) ;  //green
00573         SetBkMode((HDC) wParam, TRANSPARENT) ;               //transparent text
00574
00575         if (!hBrushDlg)
00576             hBrushDlg = GetStockObject(LTGRAY_BRUSH) ;
00577
00578         return (LRESULT) hBrushDlg;
00579
00580         break ;
00581
00582
00583     default:
00584       break ;
00585   }
00586
00587   return 0 ;   //send msg to the common dialog code
00588 }
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 /************************************************************************
00599
00600   Function: GetFindDlgHandle(void)
00601
00602   Purpose:  Finds, loads, and returns a handle to the custom template
00603             for FindText() in CDTEST.EXE.
00604
00605   Returns:  HANDLE to the dialog resource.
00606
00607   Comments:
00608
00609 ************************************************************************/
00610
00611 HANDLE GetFindDlgHandle(void)
00612 {
00613   hResFind = FindResource(hInst, TEXT("fttemp1"), RT_DIALOG) ;
00614
00615   hDialogFind = LoadResource(hInst, hResFind) ;
00616
00617
00618   return hDialogFind ;
00619 }
00620
00621
00622
00623
00624
00625 /************************************************************************
00626
00627   Function: GetReplaceDlgHandle(void)
00628
00629   Purpose:  Finds, loads, and returns a handle to the custom template
00630             for ReplaceText() in CDTEST.EXE.
00631
00632   Returns:  HANDLE to the dialog resource.
00633
00634   Comments:
00635
00636 ************************************************************************/
00637
00638 HANDLE GetReplaceDlgHandle(void)
00639 {
00640   hResFind = FindResource(hInst, TEXT("fttemp2"), RT_DIALOG) ;
00641
00642   hDialogFind = LoadResource(hInst, hResFind) ;
00643
00644   return hDialogFind ;
00645 }
00646
00647
00648
00649
00650
00651
00652 /************************************************************************
00653
00654   Function: DoFindReplaceStuff(LPFINDREPLACE)
00655
00656   Purpose:  Calls FindText() or ReplaceText().
00657
00658   Returns:  Nothing:
00659
00660   Comments:
00661
00662 ************************************************************************/
00663
00664 void DoFindRepStuff(LPFINDREPLACE pfr)
00665 {
00666   if (IsDlgButtonChecked(hwndMainDialog, ID_PRELOADEDFIND) == 1)
00667   {
00668     if (bDoFindDlg)
00669       pfr->hInstance = GetFindDlgHandle() ;
00670     else
00671       pfr->hInstance = GetReplaceDlgHandle() ;
00672   }
00673
00674   if (bDoFindDlg)
00675   {
00676     if (IsDlgButtonChecked(hwndMainDialog, ID_FRNULLSTRUCT) == 1)
00677     {
00678         hwndFind = FindText((LPFINDREPLACE) NULL) ;
00679     }
00680     else
00681     {
00682         hwndFind = FindText(pfr) ;
00683     }
00684   }
00685   else
00686   {
00687     if (IsDlgButtonChecked(hwndMainDialog, ID_FRNULLSTRUCT) == 1)
00688     {
00689         hwndFind = ReplaceText((LPFINDREPLACE) NULL) ;
00690     }
00691     else
00692     {
00693         hwndFind = ReplaceText(pfr) ;
00694     }
00695
00696   }
00697
00698
00699   wsprintf(szTemp, szLongFilter, CommDlgExtendedError()) ;
00700   SetDlgItemText(hwndMainDialog, ID_ERRORFT, szTemp) ;
00701
00702   wsprintf(szTemp, szLongFilter, hwndFind) ;
00703   SetDlgItemText(hwndMainDialog, ID_RETURNFT, szTemp) ;
00704 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/space.h Source File

  • SysMgmt
  • MMC
  • Extens

space.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SPACE_H
00021 #define _SPACE_H
00022
00023 #include "DeleBase.h"
00024
00025 class CRocket : public CDelegationBase {
00026 public:
00027     CRocket(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload);
00028     virtual ~CRocket();
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00033
00034 public:
00035     // virtual functions go here (for MMCN_*)
00036     virtual HRESULT OnRename(LPOLESTR pszNewName);
00037     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00038
00039 private:
00040     // {29743811-4C4B-11d2-89D8-000021473128}
00041     static const GUID thisGuid;
00042
00043     _TCHAR *szName;
00044     LONG   lWeight;
00045     LONG   lHeight;
00046     LONG   lPayload;
00047     int    nId;
00048     enum {RUNNING, PAUSED, STOPPED} iStatus;
00049 };
00050
00051 class CSpaceVehicle : public CDelegationBase {
00052 public:
00053     CSpaceVehicle();
00054
00055     virtual ~CSpaceVehicle();
00056
00057     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Future Vehicles"); }
00058     virtual const GUID & getNodeType() { return thisGuid; }
00059     virtual const int GetBitmapIndex() { return INDEX_SPACEICON; }
00060
00061 public:
00062     // virtual functions go here (for MMCN_*)
00063     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00064
00065 private:
00066     enum { IDM_NEW_SPACE = 4 };
00067
00068     // {29743810-4C4B-11d2-89D8-000021473128}
00069     static const GUID thisGuid;
00070
00071 private:
00072     enum { NUMBER_OF_CHILDREN = 4 };
00073     CRocket *children[NUMBER_OF_CHILDREN];
00074 };
00075
00076 #endif // _SPACE_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditCommands/BrowserHost.cpp Source File

  • Web
  • Browser
  • EditCommands

BrowserHost.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // BrowserHost.cpp : Implementation of CBrowserHost
00006 #include "stdafx.h"
00007 #include "EdCommands.h"
00008 #include "BrowserHost.h"
00009 #include "exdispid.h"
00010 #include "mshtmdid.h"
00011 #include "mshtmhst.h"
00012 #include "mshtmcid.h"
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // CBrowserHost
00016
00017 LRESULT CBrowserHost::OnButton1(WORD, WORD, HWND, BOOL& bHandled)
00018 {
00019   _ASSERT(m_spWebBrowser);
00020
00021   if (!m_spDoc)
00022   {
00023      MessageBox(_T("Document object no available."));
00024      return 0;
00025   }
00026
00027   USES_CONVERSION; // Needed for the OLE2A conversion macro
00028   BSTR bstrMode;
00029   HRESULT hr;
00030
00031   hr = AtlUnadvise(m_spDoc,
00032            DIID_HTMLDocumentEvents2,
00033            m_dwCookie2);
00034
00035   m_dwCookie2 = NULL;
00036
00037   m_spDoc->get_designMode(&bstrMode);
00038   char* cMode = OLE2A(bstrMode);
00039
00040   if (strcmp(cMode, "On"))
00041   {
00042     m_spDoc->put_designMode(L"On");
00043     m_wndButton1.SendMessage(BM_SETCHECK, BST_CHECKED, NULL);
00044   }
00045   else
00046   {
00047     m_spDoc->put_designMode(L"Off");
00048     m_wndButton1.SendMessage(BM_SETCHECK, BST_UNCHECKED, NULL);
00049   }
00050
00051   if (m_bIsChecked)
00052   {
00053     m_wndBox1.SetWindowText(_T(""));
00054     m_wndBox2.SetWindowText(_T(""));
00055     m_wndBox3.SetWindowText(_T(""));
00056   }
00057
00058
00059   hr = AtlAdvise(m_spDoc,
00060            GetUnknown(),
00061            DIID_HTMLDocumentEvents2,
00062            &m_dwCookie2);
00063
00064   m_spOleCmdTarg = m_spWebBrowser;
00065
00066   bHandled = TRUE;
00067
00068   return 0;
00069 }
00070
00071 LRESULT CBrowserHost::OnButton2(WORD, WORD, HWND, BOOL& bHandled)
00072 {
00073   // Bold Selection
00074   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00075              IDM_BOLD,
00076              MSOCMDEXECOPT_DODEFAULT,
00077              NULL,
00078              NULL);
00079
00080   return 0;
00081 }
00082
00083 LRESULT CBrowserHost::OnButton3(WORD, WORD, HWND, BOOL& bHandled)
00084 {
00085   // Italicize Selection
00086   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00087              IDM_ITALIC,
00088              MSOCMDEXECOPT_DODEFAULT,
00089              NULL,
00090              NULL);
00091
00092   return 0;
00093 }
00094
00095 LRESULT CBrowserHost::OnButton4(WORD, WORD, HWND, BOOL& bHandled)
00096 {
00097   // Font Color
00098   USES_CONVERSION;
00099
00100   CComBSTR bstrColor;
00101
00102   // CODE REVIEW: Add this security comment.
00103   /* The following use of GetWindowText is simplified for illustrative
00104   purposes. This simplified use in production code can expose a
00105   security risk in some situations. In production code you might want
00106   to ensure that the receiving buffer size isn't exceeded by the size
00107   of the source string. */
00108   m_wndBox1.GetWindowText(bstrColor.m_str);
00109
00110   VARIANT vColor;
00111   vColor.vt = VT_BSTR;
00112   vColor.bstrVal = bstrColor;
00113
00114   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00115              IDM_FORECOLOR,
00116              MSOCMDEXECOPT_DODEFAULT,
00117              &vColor,
00118              NULL);
00119
00120   return 0;
00121 }
00122
00123 LRESULT CBrowserHost::OnButton5(WORD, WORD, HWND, BOOL& bHandled)
00124 {
00125   // FontSize
00126   USES_CONVERSION;
00127
00128   CComBSTR bstrSize;
00129
00130   // CODE REVIEW: Add this security comment.
00131   /* The following use of GetWindowText is simplified for illustrative
00132   purposes. This simplified use in production code can expose a
00133   security risk in some situations. In production code you might want
00134   to ensure that the receiving buffer size isn't exceeded by the size
00135   of the source string. */
00136   m_wndBox2.GetWindowText(bstrSize.m_str);
00137
00138   LPSTR szSize = OLE2A(bstrSize);
00139
00140   LONG lSize = atoi(szSize);
00141
00142   VARIANT vSize;
00143   vSize.vt = VT_I4;
00144   vSize.lVal = lSize;
00145
00146   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00147              IDM_FONTSIZE,
00148              MSOCMDEXECOPT_DODEFAULT,
00149              &vSize,
00150              NULL);
00151
00152   return 0;
00153 }
00154
00155 LRESULT CBrowserHost::OnButton6(WORD, WORD, HWND, BOOL& bHandled)
00156 {
00157   // FontName
00158   USES_CONVERSION;
00159
00160   CComBSTR bstrName;
00161
00162   // CODE REVIEW: Add this security comment.
00163   /* The following use of GetWindowText is simplified for illustrative
00164   purposes. This simplified use in production code can expose a
00165   security risk in some situations. In production code you might want
00166   to ensure that the receiving buffer size isn't exceeded by the size
00167   of the source string. */
00168   m_wndBox3.GetWindowText(bstrName.m_str);
00169
00170   VARIANT vName;
00171   vName.vt = VT_BSTR;
00172   vName.bstrVal = bstrName;
00173
00174   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00175              IDM_FONTNAME,
00176              MSOCMDEXECOPT_DODEFAULT,
00177              &vName,
00178              NULL);
00179
00180   return 0;
00181 }
00182
00183 LRESULT CBrowserHost::OnButton7(WORD, WORD, HWND, BOOL& bHandled)
00184 {
00185   //InsertImage
00186   USES_CONVERSION;
00187
00188   CComBSTR bstrImage;
00189
00190   // CODE REVIEW: Add this security comment.
00191   /* The following use of GetWindowText is simplified for illustrative
00192   purposes. This simplified use in production code can expose a
00193   security risk in some situations. In production code you might want
00194   to ensure that the receiving buffer size isn't exceeded by the size
00195   of the source string. */
00196   m_wndBox4.GetWindowText(bstrImage.m_str);
00197
00198   VARIANT vImage;
00199   vImage.vt = VT_BSTR;
00200   vImage.bstrVal = bstrImage;
00201
00202   m_spOleCmdTarg->Exec(&CGID_MSHTML,
00203              IDM_IMAGE,
00204              MSOCMDEXECOPT_DONTPROMPTUSER,
00205              &vImage,
00206              NULL);
00207
00208   return 0;
00209 }
00210
00211 LRESULT CBrowserHost::OnCheckBox(WORD, WORD, HWND, BOOL& bHandled)
00212 {
00213   m_bIsChecked = !m_bIsChecked;
00214
00215   return 0;
00216 }
00217
00218 LRESULT CBrowserHost::OnAddressBox(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00219 {
00220   USES_CONVERSION;
00221
00222   if (wParam == VK_RETURN)
00223   {
00224     CComBSTR bstrURL;
00225
00226     // CODE REVIEW: Add this security comment.
00227     /* The following use of GetWindowText is simplified for illustrative
00228     purposes. This simplified use in production code can expose a
00229     security risk in some situations. In production code you might want
00230     to ensure that the receiving buffer size isn't exceeded by the size
00231     of the source string. */
00232     m_wndAddressBox.GetWindowText(bstrURL.m_str);
00233     m_spWebBrowser->Navigate(bstrURL, NULL, NULL, NULL, NULL);
00234   }
00235
00236   return 0;
00237 }
00238
00239 LRESULT CBrowserHost::OnBox1(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00240 {
00241   if (wParam == VK_RETURN)
00242     OnButton4(NULL, NULL, NULL, bHandled);
00243
00244   return 0;
00245 }
00246
00247 LRESULT CBrowserHost::OnBox2(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00248 {
00249   if (wParam == VK_RETURN)
00250     OnButton5(uMsg, wParam, NULL, bHandled);
00251
00252   return 0;
00253 }
00254
00255 LRESULT CBrowserHost::OnBox3(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00256 {
00257   if (wParam == VK_RETURN)
00258     OnButton6(uMsg, wParam, NULL, bHandled);
00259
00260   return 0;
00261 }
00262
00263 LRESULT CBrowserHost::OnBox4(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00264 {
00265   if (wParam == VK_RETURN)
00266     OnButton7(uMsg, wParam, NULL, bHandled);
00267
00268   return 0;
00269 }
00270
00271 STDMETHODIMP CBrowserHost::Run()
00272 {
00273   // Create and show the window
00274   RECT rcClient = { CW_USEDEFAULT, 0, 0, 0 };
00275
00276   Create(GetDesktopWindow(),
00277        rcClient,
00278        _T("Editing Command Sample App"),
00279        WS_VISIBLE | WS_OVERLAPPEDWINDOW,
00280        0,
00281        NULL);
00282
00283   ShowWindow(SW_SHOWNORMAL);
00284
00285   // Add status bar
00286   m_wndStatusBar.Attach(CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE,
00287                          _T("Ready"),
00288                        m_hWnd,
00289                        2));
00290
00291   // CreateWebBrowser Control
00292   CComQIPtr<IOleObject> spOleObject;
00293   HRESULT hr = CoCreateInstance(CLSID_WebBrowser,
00294                   NULL,
00295                   CLSCTX_INPROC,
00296                   IID_IWebBrowser,
00297                   (void**)&m_spWebBrowser);
00298
00299   m_spInPlaceObject = m_spWebBrowser;
00300   spOleObject = m_spWebBrowser;
00301
00302   hr = spOleObject->SetClientSite(this);
00303   if (FAILED(hr))
00304   {
00305     MessageBox(_T("SetClientSite failed"));
00306     return E_FAIL;
00307   }
00308
00309
00310   // In-place activate the WebBrower control
00311   MSG msg;
00312   GetClientRect(&rcClient);
00313
00314   hr = spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, m_hWnd, &rcClient);
00315
00316   // Set up event notification to browser
00317   hr = AtlAdvise(m_spWebBrowser,
00318            GetUnknown(),
00319            DIID_DWebBrowserEvents2,
00320            &m_dwCookie);
00321
00322   // Create Top Band Window
00323   RECT rc;
00324
00325   GetClientRect(&rc);
00326   rc.bottom = rc.top + m_lTopBandHeight;
00327
00328   m_wndTopBand.Create(m_hWnd,
00329              rc,
00330              NULL,
00331              WS_CHILD|WS_VISIBLE|SS_BLACKRECT,
00332              0,
00333              ID_TOPBAND);
00334
00335   // Create Left Band Window
00336   GetClientRect(&rc);
00337   rc.right = rc.left + m_lLeftBandWidth;
00338   rc.top = rc.top + m_lTopBandHeight;
00339
00340   RECT rcStatus;
00341   m_wndStatusBar.GetWindowRect(&rcStatus);
00342
00343   rc.bottom = rc.bottom - (rcStatus.bottom - rcStatus.top);
00344
00345   m_wndLeftBand.Create(m_hWnd,
00346              rc,
00347              NULL,
00348              WS_CHILD|WS_VISIBLE|SS_BLACKRECT,
00349              0,
00350              ID_LEFTBAND);
00351
00352   // Add buttons
00353   LONG lheight = 25;
00354   LONG lwidth = 80;
00355   LONG lYOffset = 35;
00356   LONG lTopMargin = 10;
00357   LONG lLeftMargin = 10;
00358
00359   GetClientRect(&rc);
00360
00361   rc.top = rc.top + lTopMargin;
00362   rc.left = rc.left + lLeftMargin;
00363   rc.bottom = rc.top + lheight;
00364   rc.right = rc.left + 110;
00365
00366   m_wndButton1.Create(m_wndLeftBand.m_hWnd,
00367             rc,
00368             _T("DesignModeOn"),
00369             WS_CHILD|WS_VISIBLE|BS_CHECKBOX|BS_PUSHLIKE,
00370             0,
00371             ID_BUTTON1);
00372
00373   rc.top = rc.top + lYOffset;
00374   rc.bottom = rc.top + lheight;
00375   rc.right = rc.left + lwidth;
00376
00377   m_wndButton2.Create(m_wndLeftBand.m_hWnd,
00378             rc,
00379             _T("Bold"),
00380             WS_CHILD|WS_VISIBLE| BS_PUSHBUTTON,
00381             0,
00382             ID_BUTTON2);
00383
00384   rc.top = rc.top + lYOffset;
00385   rc.bottom = rc.top + lheight;
00386   rc.right = rc.left + lwidth;
00387
00388   m_wndButton3.Create(m_wndLeftBand.m_hWnd,
00389             rc,
00390             _T("Italic"),
00391             WS_CHILD|WS_VISIBLE| BS_PUSHBUTTON,
00392             0,
00393             ID_BUTTON3);
00394
00395   rc.top = rc.top + lYOffset;
00396   rc.bottom = rc.top + lheight;
00397   rc.right = rc.left + lwidth;
00398
00399   m_wndButton4.Create(m_wndLeftBand.m_hWnd,
00400             rc,
00401             _T("FontColor"),
00402             WS_CHILD|WS_VISIBLE| BS_PUSHBUTTON,
00403             0,
00404             ID_BUTTON4);
00405
00406   rc.top = rc.top + lYOffset;
00407   rc.bottom = rc.top + lheight;
00408   rc.right = rc.left + lwidth;
00409
00410   m_wndButton5.Create(m_wndLeftBand.m_hWnd,
00411             rc,
00412             _T("FontSize"),
00413             WS_CHILD|WS_VISIBLE| BS_PUSHBUTTON,
00414             0,
00415             ID_BUTTON5);
00416
00417   rc.top = rc.top + lYOffset;
00418   rc.bottom = rc.top + lheight;
00419   rc.right = rc.left + lwidth;
00420
00421   m_wndButton6.Create(m_wndLeftBand.m_hWnd,
00422             rc,
00423             _T("FontName"),
00424             WS_CHILD|WS_VISIBLE| BS_PUSHBUTTON,
00425             0,
00426             ID_BUTTON6);
00427
00428   rc.top = rc.top + lYOffset;
00429   rc.bottom = rc.top + lheight;
00430   rc.right = rc.left + lwidth + 10;
00431
00432   m_wndButton7.Create(m_wndLeftBand.m_hWnd,
00433             rc,
00434             _T("InsertImage"),
00435             WS_CHILD|WS_VISIBLE| BS_PUSHBUTTON,
00436             0,
00437             ID_BUTTON7);
00438
00439   // Add edit boxes
00440   lwidth = 65;
00441   lheight = 25;
00442
00443   rc.left = rc.left + 90;
00444   rc.right = rc.left + lwidth;
00445   rc.top = rc.top - 3 *lYOffset;
00446   rc.bottom = rc.top + lheight;
00447
00448   m_wndBox1.Create(m_wndLeftBand.m_hWnd,
00449            rc,
00450            NULL,
00451            WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL,
00452            0,
00453            ID_BOX1);
00454
00455   rc.right = rc.left + lwidth;
00456   rc.top = rc.top + lYOffset;
00457   rc.bottom = rc.top + lheight;
00458
00459   m_wndBox2.Create(m_wndLeftBand.m_hWnd,
00460            rc,
00461            NULL,
00462            WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL,
00463            0,
00464            ID_BOX2);
00465
00466   rc.right = rc.left + lwidth;
00467   rc.top = rc.top + lYOffset;
00468   rc.bottom = rc.top + lheight;
00469
00470   m_wndBox3.Create(m_wndLeftBand.m_hWnd,
00471            rc,
00472            NULL,
00473            WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL,
00474            0,
00475            ID_BOX3);
00476
00477   rc.left = rc.left - 80;
00478   rc.right = rc.left + lwidth + 80;
00479   rc.top = rc.top + 2 *lYOffset;
00480   rc.bottom = rc.top + lheight;
00481
00482   m_wndBox4.Create(m_wndLeftBand.m_hWnd,
00483            rc,
00484            NULL,
00485            WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL,
00486            0,
00487            ID_BOX4);
00488
00489   m_wndBox1.SetWindowText(_T("red"));
00490   m_wndBox2.SetWindowText(_T("7"));
00491   m_wndBox3.SetWindowText(_T("comic sans ms"));
00492   m_wndBox4.SetWindowText(_T("res://edcommands.exe/cone.jpg"));
00493
00494   rc.top = rc.top + 2*lYOffset;
00495   rc.bottom = rc.top + 3*lheight/2;
00496   rc.left = rc.left - 10;
00497   rc.right = rc.left + 130;
00498
00499   m_wndCheckBox.Create(m_wndLeftBand.m_hWnd,
00500            rc,
00501            _T("Track Selection Properties"),
00502            WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX|BS_MULTILINE,
00503            0,
00504            ID_CHECKBOX);
00505
00506   // Add addressbox
00507   GetClientRect(&rc);
00508   rc.top += 5;
00509   rc.bottom = rc.top + 25;
00510   rc.left += lLeftMargin;
00511   rc.right = rc.left + 450;
00512
00513   m_wndAddressBox.Create(m_wndTopBand.m_hWnd,
00514            rc,
00515            NULL,
00516            WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL,
00517            0,
00518            ID_ADDRESSBOX);
00519
00520
00521   m_wndStatusBar.GetWindowRect(&rc);
00522
00523   // resize webbrowser to account for status bar, top and left band
00524   GetClientRect(&rcClient);
00525   rcClient.top = rcClient.top + m_lTopBandHeight;
00526   rcClient.left = rcClient.left + m_lLeftBandWidth;
00527   rcClient.bottom = rcClient.bottom - (rc.bottom - rc.top);
00528
00529   m_spInPlaceObject->SetObjectRects(&rcClient, &rcClient);
00530
00531   // Navigate to home page
00532   m_spWebBrowser->Navigate(L"res://edcommands.exe/test.html", NULL, NULL, NULL, NULL);
00533   m_wndAddressBox.SetWindowText(_T("res://edcommands.exe/test.html"));
00534
00535   m_spOleCmdTarg = m_spWebBrowser;
00536
00537   return S_OK;
00538 }
00539
00540 STDMETHODIMP CBrowserHost::Stop()
00541 {
00542   HRESULT hr = AtlUnadvise(m_spWebBrowser,
00543                DIID_DWebBrowserEvents2,
00544                m_dwCookie);
00545
00546   m_dwCookie = NULL;
00547
00548   PostQuitMessage(0);
00549
00550   return S_OK;
00551 }
00552
00553 LRESULT CBrowserHost::OnCreate(UINT, WPARAM, LPARAM, BOOL&) {return 0;}
00554
00555 LRESULT CBrowserHost::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00556 {
00557   Stop();
00558   return 0;
00559 }
00560
00561
00562 LRESULT CBrowserHost::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00563 {
00564   RECT rcStatus;
00565   RECT rc;
00566
00567   // Resize the status bar
00568   if (m_wndStatusBar.m_hWnd)
00569   {
00570     GetClientRect(&rc);
00571
00572     // Keep the status bar height the same.
00573     m_wndStatusBar.GetWindowRect(&rcStatus);
00574     rc.top = rc.bottom - (rcStatus.bottom - rcStatus.top);
00575
00576     m_wndStatusBar.MoveWindow(&rc, TRUE);
00577   }
00578
00579   // Resize Top Band
00580   if (m_wndTopBand.m_hWnd)
00581   {
00582     GetClientRect(&rc);
00583     rc.bottom = rc.top + m_lTopBandHeight;
00584     m_wndTopBand.MoveWindow(&rc, TRUE);
00585   }
00586
00587   // Resize Left Band
00588   if (m_wndLeftBand.m_hWnd)
00589   {
00590     GetClientRect(&rc);
00591     rc.right = rc.left + m_lLeftBandWidth;
00592     rc.top = rc.top + m_lTopBandHeight;
00593     rc.bottom = rc.bottom - (rcStatus.bottom - rcStatus.top);
00594     m_wndLeftBand.MoveWindow(&rc, TRUE);
00595   }
00596
00597   // Resize the WebBrowser
00598   if (m_spWebBrowser && m_bInPlaceActive)
00599   {
00600     GetClientRect(&rc);
00601
00602     // Resize the control to accomodate the status bar and toolbar
00603     rc.bottom -= (rcStatus.bottom - rcStatus.top);
00604
00605     //m_wndToolBar.GetWindowRect(&rcWindow);
00606     rc.left += m_lLeftBandWidth;
00607     rc.top += m_lTopBandHeight;
00608
00609     if (m_spInPlaceObject)
00610       m_spInPlaceObject->SetObjectRects(&rc, &rc);
00611   }
00612
00613   return 0;
00614 }
00615
00616 LRESULT CBrowserHost::OnKeydown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00617 {
00618   // Deal with tab and delete key events
00619   // Check for doc first
00620   if (!m_spDoc) return 0;
00621
00622   USES_CONVERSION;
00623   // Determine current designMode
00624   CComBSTR bstrMode;
00625   m_spDoc->get_designMode(&bstrMode);
00626   char* cMode = OLE2A(bstrMode);
00627
00628   // Handle tab when design mode is off
00629   // Handle return regardless of designMode
00630   if ((strcmp(cMode, "On") && wParam == VK_TAB) || wParam == VK_RETURN)
00631   {
00632     // Pass user interface control to the WebBrowser when
00633     // the tab or return keys are pressed (that is, UIActivate it)
00634     // This lets the WebBrowser change focus between the
00635     // various controls on the page when the tab key is pressed
00636     CComQIPtr<IOleObject, &IID_IOleObject> spOleObject(m_spWebBrowser);
00637
00638     RECT rect;
00639     GetClientRect(&rect);
00640     spOleObject->DoVerb(OLEIVERB_UIACTIVATE, NULL, this, 0, m_hWnd, &rect);
00641   }
00642
00643   // When designMode is on, tab, backspace, right arrow,
00644   // left arrow, up arrow, down arrow, and end key events
00645   // shouldn't be passed to the WebBrowser
00646   // (They require special handling to work correctly)
00647   // Also, pass VK_TAB to WebBrowser control when designMode is off
00648   // Pass return key events regardless of designMode
00649   if ((!strcmp(cMode, "On") && wParam != VK_TAB &&
00650                  wParam != VK_BACK &&
00651                  wParam != VK_RIGHT &&
00652                  wParam != VK_LEFT &&
00653                  wParam != VK_UP &&
00654                  wParam != VK_DOWN &&
00655                  wParam != VK_END) ||
00656     (strcmp(cMode, "On") && wParam == VK_TAB) ||
00657     (wParam == VK_RETURN))
00658   {
00659     // Call TranslateAccelerator on the in-place active
00660     // object to pass events to the WebBrowser control
00661     CComQIPtr<IOleInPlaceActiveObject,
00662         &IID_IOleInPlaceActiveObject> spInPlaceActiveObject(m_spWebBrowser);
00663
00664     MSG msg;
00665     msg.message = uMsg;
00666     msg.wParam = wParam;
00667     msg.lParam = lParam;
00668
00669     spInPlaceActiveObject->TranslateAccelerator(&msg);
00670   }
00671
00672   return 0;
00673 }
00674
00675 // IDispatch Methods
00676 STDMETHODIMP CBrowserHost::Invoke(DISPID dispidMember, REFIID riid,
00677                      LCID lcid, WORD wFlags,
00678                      DISPPARAMS* pDispParams,
00679                      VARIANT* pvarResult, EXCEPINFO*  pExcepInfo,
00680                      UINT* puArgErr)
00681 {
00682   USES_CONVERSION;
00683   HRESULT hr;
00684   CComBSTR bstrString;
00685   CComVariant var;
00686   TCHAR szRed[3];
00687   TCHAR szGreen[3];
00688   TCHAR szBlue[3];
00689   TCHAR szColor[8];
00690   TCHAR szString[25];
00691   int i = 0;
00692   int j = 0;
00693   int hex = 1;
00694   LONG lColor, lRed, lGreen, lBlue;
00695
00696   switch (dispidMember)
00697   {
00698     case DISPID_DOCUMENTCOMPLETE:
00699     {
00700       IDispatch* pDisp;
00701       m_spDoc = (IHTMLDocument2*)NULL;
00702       m_spWebBrowser->get_Document(&pDisp);
00703       pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&m_spDoc);
00704
00705       // Set up event notification to document
00706       if (!m_dwCookie2) // Check m_dwCookie because Invoke is called
00707                 // w/DISPID_DOCUMENTCOMPLETE more than once
00708                 // and we don't want to set more than one
00709                 // connection point to document
00710         hr = AtlAdvise(m_spDoc,
00711                  GetUnknown(),
00712                  DIID_HTMLDocumentEvents2,
00713                  &m_dwCookie2);
00714
00715       pDisp->Release();
00716       break;
00717     }
00718
00719     case DISPID_BEFORENAVIGATE:
00720     case DISPID_BEFORENAVIGATE2:
00721     case DISPID_ONQUIT:
00722     {
00723       if (!m_dwCookie2 || !m_spDoc) break;
00724       hr = AtlUnadvise(m_spDoc,
00725                DIID_HTMLDocumentEvents2,
00726                m_dwCookie2);
00727
00728       m_dwCookie2 = NULL;
00729
00730       break;
00731     }
00732
00733     case DISPID_HTMLDOCUMENTEVENTS2_ONSELECTIONCHANGE:
00734     {
00735       if (!m_bIsChecked) break;
00736
00737       // Get font color
00738       hr = m_spOleCmdTarg->Exec(&CGID_MSHTML,
00739                  IDM_FORECOLOR, // To compile with IE 5.0 Headers and Libs use:  IDM_DISABLE_EDITFOCUS_UI
00740                  MSOCMDEXECOPT_DODEFAULT,
00741                  NULL,
00742                  &var);
00743
00744       // Convert long returned in var to hash-prefixed
00745       // hexidecimal string
00746       lColor = var.lVal;
00747       lBlue = lColor/(256*256);
00748       lColor = lColor - lBlue*256*256;
00749       lGreen = lColor/256;
00750       lRed = lColor - lGreen*256;
00751
00752       _itot(lRed, szRed, 16);
00753       _itot(lGreen, szGreen, 16);
00754       _itot(lBlue, szBlue, 16);
00755
00756       szColor[0] = '#';
00757       if (lRed < 16)
00758       {
00759         szColor[1] = '0';
00760         szColor[2] = szRed[0];
00761       }
00762       else
00763       {
00764         szColor[1] = szRed[0];
00765         szColor[2] = szRed[1];
00766       }
00767       if (lGreen < 16)
00768       {
00769         szColor[3] = '0';
00770         szColor[4] = szGreen[0];
00771       }
00772       else
00773       {
00774         szColor[3] = szGreen[0];
00775         szColor[4] = szGreen[1];
00776       }
00777       if (lBlue < 16)
00778       {
00779         szColor[5] = '0';
00780         szColor[6] = szBlue[0];
00781       }
00782       else
00783       {
00784         szColor[5] = szBlue[0];
00785         szColor[6] = szBlue[1];
00786       }
00787
00788       szColor[7] = NULL;
00789
00790       if (var.vt != VT_EMPTY)
00791         m_wndBox1.SetWindowText(szColor);
00792       else
00793         m_wndBox1.SetWindowText(_T(""));
00794
00795       // Get font size
00796       hr = m_spOleCmdTarg->Exec(&CGID_MSHTML,
00797                  IDM_FONTSIZE,
00798                  MSOCMDEXECOPT_DODEFAULT,
00799                  NULL,
00800                  &var);
00801
00802       _itot(var.lVal, szString, 10);
00803
00804       if (var.vt != VT_EMPTY)
00805         m_wndBox2.SetWindowText(szString);
00806       else
00807         m_wndBox2.SetWindowText(_T(""));
00808
00809       // Get font name
00810       hr = m_spOleCmdTarg->Exec(&CGID_MSHTML,
00811                  IDM_FONTNAME,
00812                  MSOCMDEXECOPT_DODEFAULT,
00813                  NULL,
00814                  &var);
00815
00816       if (var.vt != VT_EMPTY)
00817         m_wndBox3.SetWindowText(OLE2T(var.bstrVal));
00818       else
00819         m_wndBox3.SetWindowText(_T(""));
00820
00821       break;
00822     }
00823
00824     case DISPID_STATUSTEXTCHANGE:
00825       m_wndStatusBar.SetWindowText(OLE2T(pDispParams->rgvarg[0].bstrVal));
00826       break;
00827
00828     default:
00829       return DISP_E_MEMBERNOTFOUND;
00830   }
00831
00832   return S_OK;
00833 }
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/globaldev/gentab.c Source File

  • WinUI
  • GlobalDev
  • globaldev

gentab.c

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 // PARTICULAR PURPOSE.
00007 //
00008 // Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00009 //
00010 // Purpose:
00011 //  This application demonstrates the different aspects of software globalization:
00012 //
00013 //      - A single executable with world-wide functionality (fully Unicode enabled
00014 //      for Windows 2000 and Windows XP).
00015 //
00016 //      - Locale independency by using Windows NLS APIs to display data (dates,
00017 //      numbers, time, etc.) within a user's desired format.
00018 //
00019 //      - Multilingual editing using standard edit controls.
00020 //
00021 //      - Multilingual input locales within edit control fields.
00022 //
00023 //      - Font selection and their affect on displayed data.
00024 //
00025 //      - Multilingual user interface and satellite DLLs.
00026 //
00027 // Written by Houman Pournasseh
00028 //
00029 ///////////////////////////////////////////////////////////////////////////////////////////
00030
00031 ///////////////////////////////////////////////////////////////////////////////////////////
00032 //
00033 //   Module:        GENTAB.C
00034 //
00035 //   Description:   Handles the window proc for the "General" tab of the property sheet.
00036 //
00037 //   Functions:
00038 //      GeneralDlgProc()        - Window procedure message handler
00039 //      InitLangList()          - lists languages for which we have a resource DLL available
00040 //
00041 ///////////////////////////////////////////////////////////////////////////////////////////
00042
00043 #include "global.h"
00044
00045
00046 // Internal function definition
00047 void InitLangList(HWND);
00048
00049 ///////////////////////////////////////////////////////////////////////////////////////////
00050 //  Function:       GeneralDlgProc
00051 //
00052 //  Description:    Message-processing function for general tab
00053 //
00054 //  Comments:
00055 //
00056 ///////////////////////////////////////////////////////////////////////////////////////////
00057 INT_PTR CALLBACK GeneralDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
00058 {
00059     int      nIndex;
00060     static   LCID  wNewLang;
00061     BOOL     bSuccess = TRUE;
00062
00063     switch(uMsg)
00064     {
00065             case WM_INITDIALOG:
00066              {
00067                    HANDLE hFile = NULL;
00068                    LPTSTR lpszText = 0;
00069                    DWORD  dwReadByte = 0;
00070                    DWORD  dwFileSize = 0;
00071
00072                     // We are displaying the content of global.txt in an edit control on this page.
00073                     // Load the file and set the text.
00074                     if((hFile = CreateFile(TEXT("global.txt"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
00075                     {
00076                         dwFileSize = GetFileSize(hFile, &dwReadByte);
00077                         if(NULL==(lpszText = (LPTSTR)VirtualAlloc(NULL, dwFileSize, MEM_COMMIT, PAGE_READWRITE)))
00078                         {
00079                             bSuccess = FALSE;
00080                             break;
00081                         }
00082
00083                         ReadFile(hFile, lpszText, dwFileSize, &dwReadByte, NULL);
00084                         if(FALSE == CloseHandle(hFile))
00085                         {
00086                             bSuccess = FALSE;
00087                             VirtualFree(lpszText, dwFileSize, MEM_RELEASE);
00088                             break;
00089                         }
00090
00091                         SetWindowText(GetDlgItem(hDlg, IDC_PURPOSE), lpszText);
00092                         VirtualFree(lpszText, dwFileSize, MEM_RELEASE);
00093                     }
00094                     else
00095                     {
00096                         bSuccess = FALSE;
00097                         break;
00098                     }
00099
00100                     // Create the list of the available languages to be displayed in our
00101                     // drop-down menu for UI language selection
00102                     InitLangList(hDlg);
00103             }
00104             break;
00105
00106             case WM_COMMAND:
00107                 switch(LOWORD(wParam))
00108                 {
00109                     case IDCANCEL:  /* fall-through*/
00110                     case IDOK:
00111                         break;
00112                 }
00113
00114                 switch (HIWORD(wParam))
00115                 {
00116                     case CBN_SELCHANGE:  /* fall-through*/
00117                     case CBN_DBLCLK:
00118
00119                     // track the user changes into the language selection drop-down menu.
00120                     nIndex = (int)SendMessage((HWND) lParam, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
00121
00122                     if(CB_ERR == nIndex)
00123                     {
00124                         bSuccess = FALSE;
00125                         break;
00126                     }
00127
00128                     wNewLang = (LCID) SendMessage((HWND) lParam, CB_GETITEMDATA, (WPARAM) nIndex, (LPARAM) 0 );
00129                     if (wNewLang != (LCID)g_wCurLang)
00130                     {
00131                         // enable the apply buton...
00132                         SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);   // enable Apply
00133                     }
00134                     else
00135                     {
00136                         SendMessage(GetParent(hDlg), PSM_UNCHANGED, (WPARAM)hDlg, 0L);   // enable Apply
00137                     }
00138                     break;
00139                 }
00140                 break;
00141
00142             case WM_NOTIFY:
00143                 switch (((NMHDR *)lParam)->code)
00144                 {
00145                     case PSN_APPLY:
00146                     {
00147                         PSHNOTIFY *lppsn = NULL;
00148
00149                         lppsn = (LPPSHNOTIFY) lParam;
00150                         if (lppsn->lParam == FALSE)
00151                         {
00152                             // we have an apply, we need to re-load new langauge resources...
00153
00154                             STARTUPINFO         sui = {0};
00155                             PROCESS_INFORMATION pi1 = {0};
00156                             TCHAR               szProcess[MAX_STR];
00157
00158                             // Create a new instance on ourselve and pass the new language
00159                             // dll as a parameter.
00160                             sui.cb = sizeof (STARTUPINFO);
00161                             _sntprintf(szProcess,MAX_STR,TEXT("global %x"), wNewLang);
00162               bSuccess = CreateProcess(NULL, szProcess, 0, 0, 0, 0, 0, 0, &sui, &pi1);
00163
00164                             // close the previous version...
00165                             PostMessage(GetParent(hDlg), WM_CLOSE, 0, 0);
00166                         }
00167                     }
00168                     break;
00169                 }
00170                 break;
00171
00172         default:
00173          bSuccess = FALSE;
00174    }
00175
00176     return bSuccess;
00177 }
00178
00179
00180 ///////////////////////////////////////////////////////////////////////////////////////////
00181 //  Function:       InitLangList
00182 //
00183 //  Description:    Makes a list of available language DLLs and fills out the language
00184 //                  selection drop-down menu.
00185 //  Comments:
00186 //
00187 ///////////////////////////////////////////////////////////////////////////////////////////
00188 void InitLangList(HWND hDlg)
00189 {
00190     int   nIndex = 0;
00191     WIN32_FIND_DATA wfd = {0};
00192     HANDLE hFindFile = NULL;
00193
00194     // Our naming convention for resource DLLs is as follow: gres[langID].dll
00195     // Find all available resource dlls in the current directory but enumerating gres*.* files
00196     hFindFile = FindFirstFile(TEXT("gres*.*"), &wfd);
00197
00198     if(NULL != hFindFile)
00199     {
00200         do
00201         {
00202             LANGID wFileLang = 0;
00203             TCHAR szLangName[32];
00204
00205             // Skip first four letters ("GRES") of filename, convert the rest to a langID.
00206             wFileLang = (LANGID) _tcstoul(wfd.cFileName+4, NULL, 16);
00207
00208             // We only offer UI languages that are in fact supported...
00209             // This is done to prevent users from selecting a language for which the support (font, USP...)
00210             // are not installed.
00211             if (IsValidLocale(wFileLang, LCID_INSTALLED))
00212             {
00213                 // Get the native name of the country associated with that language ID.
00214                 GetLocaleInfo(MAKELCID(wFileLang, SORT_DEFAULT) , LOCALE_SNATIVELANGNAME, szLangName, 32);
00215
00216                 // Add the new language to our list of UI languages.
00217                 SendDlgItemMessage(hDlg, IDC_LANGUAGES, CB_INSERTSTRING, nIndex, (LPARAM) szLangName);
00218
00219                 // Store the langID of the current resource DLL in the combo-box data area
00220                 // for later use.
00221                 SendDlgItemMessage(hDlg, IDC_LANGUAGES, CB_SETITEMDATA, nIndex, (LPARAM) wFileLang);
00222
00223                 // Select the current language in the combo box edit control.
00224                 if(wFileLang == g_wCurLang)
00225                 {
00226                     SendDlgItemMessage(hDlg, IDC_LANGUAGES, CB_SETCURSEL, nIndex, 0L );
00227                 }
00228
00229                 nIndex++;
00230             }
00231         }
00232         // Look for the followig resouce DLL
00233         while (FindNextFile(hFindFile, &wfd) );  // Test for do ... while loop
00234     }
00235 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SStemForm Member List

This is the complete list of members for SStemForm, including all inherited members.
iForm | SStemForm
iList | SStemForm
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/basesnap.h Source File

  • SysMgmt
  • MMC
  • WMI

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/LSP/lspguid.cpp Source File

  • NetDS
  • WinSock
  • LSP

lspguid.cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: lspguid.cpp
00009 //
00010 // Description:
00011 //
00012 //    This module simply defines the LSPs DLL name and the GUID
00013 //    under which the LSPs provider (dummy) entry is installed under.
00014 //
00015 //    You can generate multiple LSPs to layer over one another by
00016 //    changing the LSPs name (e.g. lsp2.dll) and the GUID (to another
00017 //    unique value). The lsp.def file must also be updated to indicate
00018 //    the LSP name as well as the makefile (to output a lsp2.dll instead
00019 //    of lsp.dll). Note that the instlsp.exe generated will only install
00020 //    lsp2.dll so it must be kept seperate from the installer generated
00021 //    for the original LSP.
00022 //
00023 #include "provider.h"
00024 #include <windows.h>
00025
00026 //
00027 // Initialize the LSP's provider path
00028 //
00029 WCHAR *ProviderPath = L"%SYSTEMROOT%\\system32\\lsp.dll";
00030
00031 //
00032 // This is the hardcoded guid for our dummy (hidden) catalog entry
00033 //
00034 GUID ProviderGuid = { //c5fabbd0-9736-11d1-937f-00c04fad860d
00035     0xc5fabbd0,
00036     0x9736,
00037     0x11d1,
00038     {0x93, 0x7f, 0x00, 0xc0, 0x4f, 0xad, 0x86, 0x0d}
00039 };
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPrintCanvas Member List

This is the complete list of members for CPrintCanvas, including all inherited members.
_hdc | CCanvas | [protected]
CCanvas() | CCanvas | [inline]
Char(int x, int y, TCHAR ch) | CCanvas | [inline]
Circle(int x, int y, int r) | CCanvas | [inline]
Clear(RECT &rect) | CCanvas | [inline]
CPrintCanvas(CPrintRequest &pr) | CPrintCanvas | [inline]
DPtoLP(LPPOINT lppt) | CCanvas | [inline]
Init(HDC hdc) | CCanvas | [inline, protected]
Line(COORD x1, COORD y1, COORD x2, COORD y2) | CCanvas | [inline]
LPtoDP(LPPOINT lppt) | CCanvas | [inline]
operator HDC() | CCanvas | [inline]
RCText(LPRECT lprc, LPTSTR buf, int cBuf) | CCanvas | [inline]
Scale(UINT iScale) | CCanvas | [inline]
Scroll(int dx, int dy) | CCanvas | [inline]
Text(int x, int y, LPTSTR buf, int cBuf) | CCanvas | [inline]
TextAlign(WORD aligntype) | CCanvas | [inline]
~CPrintCanvas() | CPrintCanvas | [inline]
Generated on Wed Nov 13 2024 16:57:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/common.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

common.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     File Replication Sample
00005     Server System Service
00006
00007     FILE: common.cpp
00008
00009     PURPOSE: Provides common file replication service routine definitions.
00010
00011 */
00012
00013 #include "common.h"
00014
00015 #include <tchar.h>
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018
00019 HANDLE hProcessHeap = NULL;
00020
00021 VOID GetEEInfoText(TCHAR *Msg, UINT BuffSize, UINT *MsgSize) {
00022     RPC_STATUS status;
00023     RPC_ERROR_ENUM_HANDLE EnumHandle;
00024
00025   *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("EEInfo:\n"));
00026
00027     status = RpcErrorStartEnumeration(&EnumHandle);
00028
00029     if (status == RPC_S_ENTRY_NOT_FOUND) {
00030         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("no EEInfo found\n"));
00031     }
00032     else if (status != RPC_S_OK) {
00033         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("could not get EEInfo\n"));
00034     }
00035     else {
00036         RPC_EXTENDED_ERROR_INFO ErrorInfo;
00037
00038         while (status == RPC_S_OK) {
00039             ErrorInfo.Version = RPC_EEINFO_VERSION;
00040             ErrorInfo.Flags = 0;
00041             ErrorInfo.NumberOfParameters = 4;
00042
00043             status = RpcErrorGetNextRecord(&EnumHandle, FALSE, &ErrorInfo);
00044             if (status == RPC_S_ENTRY_NOT_FOUND) {
00045                 break;
00046             }
00047             else if (status != RPC_S_OK) {
00048                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("enumeration broke with status %d\n"), status);
00049                 break;
00050             }
00051             else {
00052                 INT i;
00053
00054                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("GeneratingComponent: %d\n"), ErrorInfo.GeneratingComponent);
00055                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Status: %d\n"), ErrorInfo.Status);
00056                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Detection Location: %d\n"), ErrorInfo.DetectionLocation);
00057                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Flags: %d\n"), ErrorInfo.Flags);
00058                 *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("NumberOfParameters: %d\n"), ErrorInfo.NumberOfParameters);
00059
00060                 for (i = 0; i < ErrorInfo.NumberOfParameters; i++) {
00061                     switch (ErrorInfo.Parameters[i].ParameterType) {
00062                     case eeptAnsiString:
00063                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("AnsiString: %s\n"), ErrorInfo.Parameters[i].u.AnsiString);
00064                         break;
00065
00066                     case eeptUnicodeString:
00067                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("UnicodeString: %S\n"), ErrorInfo.Parameters[i].u.UnicodeString);
00068                         break;
00069
00070                     case eeptLongVal:
00071                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("LongVal: %d\n"), ErrorInfo.Parameters[i].u.LVal);
00072                         break;
00073
00074                     case eeptShortVal:
00075                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("ShortVal: %d\n"), ErrorInfo.Parameters[i].u.SVal);
00076                         break;
00077
00078                     case eeptPointerVal:
00079                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("PointerVal: %d\n"), ErrorInfo.Parameters[i].u.PVal);
00080                         break;
00081
00082                     case eeptNone:
00083                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Invalid type of parameter %d\n"), ErrorInfo.Parameters[i].ParameterType);
00084                         break;
00085
00086                     default:
00087                         *MsgSize += _sntprintf(&Msg[*MsgSize], BuffSize - *MsgSize, TEXT("Invalid type of parameter %d\n"), ErrorInfo.Parameters[i].ParameterType);
00088                     }
00089                 }
00090             }
00091         }
00092     }
00093 }
00094
00095 VOID PrintProcFailureEEInfo(LPTSTR ProcName, DWORD ErrCode) {
00096     TCHAR Msg[MSG_SIZE];
00097     UINT MsgSize = 0;
00098
00099     MsgSize += _stprintf(&Msg[MsgSize], TEXT("%s failed with code %d\n"), ProcName, ErrCode);
00100   GetEEInfoText(Msg, MSG_SIZE, &MsgSize);
00101
00102   Msg[MsgSize] = 0;
00103
00104     _tprintf(TEXT("%s"), Msg);
00105 }
00106
00107 // Memory management functions.
00108 VOID * AutoHeapAlloc(size_t dwBytes) {
00109     if (hProcessHeap == NULL) {
00110         hProcessHeap = GetProcessHeap();
00111     }
00112     return HeapAlloc(hProcessHeap, 0, dwBytes);
00113 }
00114
00115 VOID AutoHeapFree(VOID * lpMem) {
00116     DWORD status;
00117     ASSERT(hProcessHeap != NULL);
00118     status = HeapFree(hProcessHeap, 0, lpMem);
00119     ASSERT(status);
00120 }
00121
00122
00123 // end common.cpp
00124
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/drawdlg.h Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

drawdlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // drawdlg.h : header file
00014 //
00015
00016
00017 #include "drawarea.h"
00018
00019 //#define FORMAT_NAME_LIST_LEN 1024
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // CDisdrawDlg dialog
00023
00024 class CDisdrawDlg : public CDialog
00025 {
00026 // Construction
00027 public:
00028
00029
00030   CDisdrawDlg(CWnd* pParent = NULL);  // standard constructor
00031
00032   void SendMouseMovement(LINE lineNew);
00033   void SendKeystroke(UINT uChar);
00034
00035 // Data
00036   CString m_strLogin;
00037   HANDLE m_hqIncoming;
00038   HANDLE m_hqOutgoing;
00039   int   m_iRadioDS;
00040   WCHAR  * m_wcsFormatNameList;
00041   BOOL m_fDsEnabledLocaly;
00042   unsigned int m_iFormatNameList;
00043
00044
00045 // Dialog Data
00046   //{{AFX_DATA(CDisdrawDlg)
00047   enum { IDD = IDD_DISDRAW_DIALOG };
00048   CButton m_cFriendFrame;
00049   CStatic m_cComputerLabel;
00050   CButton m_CancelButton;
00051   CStatic m_cQueueLabel;
00052   CButton m_cMessageFrame;
00053   CButton m_cQueueFrame;
00054   CButton m_cRadioExpress;
00055   CEdit m_cComputerInput;
00056   CEdit m_cQueueInput;
00057   CDrawArea m_drawScribble;
00058   CButton m_btnAttach;
00059   CString m_strFriend;
00060   int   m_iDelivery;
00061   int   m_iType;
00062   CString m_strRemoteComputerName;
00063     CButton m_cRadioRecoverable;
00064   CButton m_cRadioPublic;
00065   CButton m_cRadioPrivate;
00066   CButton m_btnAddQueue;
00067   CStatic m_cConnectionMode;
00068   //}}AFX_DATA
00069
00070
00071
00072   // ClassWizard generated virtual function overrides
00073   //{{AFX_VIRTUAL(CDisdrawDlg)
00074   protected:
00075   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00076   //}}AFX_VIRTUAL
00077
00078 // Implementation
00079 protected:
00080   void startReceiveUpdateThread();
00081   BOOL OpenPrivateReceiveQueue();
00082   HICON m_hIcon;
00083   BOOL OpenReceiveQueue();
00084
00085
00086   // Generated message map functions
00087   //{{AFX_MSG(CDisdrawDlg)
00088   virtual BOOL OnInitDialog();
00089   afx_msg void OnPaint();
00090   afx_msg HCURSOR OnQueryDragIcon();
00091   afx_msg void OnButtonAttach();
00092   afx_msg void OnButtonAddQueue();
00093   afx_msg void OnClose();
00094   afx_msg void OnRadioPrivatequeue();
00095   afx_msg void OnRadioPublicqueue();
00096   //}}AFX_MSG
00097   DECLARE_MESSAGE_MAP()
00098 //private:
00099
00100
00101 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/packet.c Source File

  • NetDS
  • RRas
  • ip

packet.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\packet.c
00008
00009 Abstract:
00010
00011     The file contains functions to deal with an ip sample packet.
00012
00013 --*/
00014
00015 #include "pchsample.h"
00016 #pragma hdrstop
00017
00018 // Macro for counting maximum characters that will fit into a buffer
00019 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00020
00021 DWORD
00022 PacketCreate (
00023     OUT PPACKET         *ppPacket)
00024 /*++
00025
00026 Routine Description
00027     Creates a packet.
00028
00029 Locks
00030     None
00031
00032 Arguments
00033     ppPacket            pointer to the packet address
00034
00035 Return Value
00036     NO_ERROR            if success
00037     Failure code        o/w
00038
00039 --*/
00040 {
00041     DWORD   dwErr   = NO_ERROR;
00042
00043     // validate parameters
00044     if (!ppPacket)
00045         return ERROR_INVALID_PARAMETER;
00046
00047     do                          // breakout loop
00048     {
00049         // allocate and zero out the packet structure
00050         MALLOC(ppPacket, sizeof(PACKET), &dwErr);
00051         if (dwErr != NO_ERROR)
00052             break;
00053
00054         // initialize fields
00055
00056         // ((*ppPacket)->ipSource  zero'ed out
00057
00058         _snprintf((*ppPacket)->rgbyBuffer, CELEMS((*ppPacket)->rgbyBuffer), "hello world!"); // for now
00059
00060         (*ppPacket)->wsaBuffer.buf = (*ppPacket)->rgbyBuffer;
00061         (*ppPacket)->wsaBuffer.len = strlen((*ppPacket)->rgbyBuffer);
00062
00063     } while (FALSE);
00064
00065     return dwErr;
00066 }
00067
00068
00069
00070 DWORD
00071 PacketDestroy (
00072     IN  PPACKET                 pPacket)
00073 /*++
00074
00075 Routine Description
00076     Destroys a packet.
00077
00078 Locks
00079     None
00080
00081 Arguments
00082     pPacket             packet to destroy
00083
00084 Return Value
00085     NO_ERROR            always
00086
00087 --*/
00088 {
00089     // validate parameters
00090     if (!pPacket)
00091         return NO_ERROR;
00092
00093     FREE(pPacket);
00094
00095     return NO_ERROR;
00096 }
00097
00098
00099
00100 #ifdef DEBUG
00101 DWORD
00102 PacketDisplay (
00103     IN  PPACKET                 pPacket)
00104 /*++
00105
00106 Routine Description
00107     Displays a packet, it's fields and the buffer.
00108
00109 Locks
00110     None
00111
00112 Arguments
00113     pPacket             packet to destroy
00114
00115 Return Value
00116     NO_ERROR            always
00117
00118 --*/
00119 {
00120     ULONG   i;
00121     CHAR    szBuffer[2 * MAX_PACKET_LENGTH + 1]; // buffer in hex
00122
00123     for (i = 0; i < pPacket->wsaBuffer.len; i++)
00124         _snprintf(szBuffer + i*2, CELEMS(szBuffer) - i*2, "%02x", pPacket->rgbyBuffer[i]);
00125
00126     TRACE3(NETWORK, "Packet... Source %s, Length %d, Buffer %s",
00127            INET_NTOA(pPacket->ipSource), pPacket->wsaBuffer.len, szBuffer);
00128
00129     return NO_ERROR;
00130 }
00131 #endif // DEBUG
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/iocs.h Source File

  • Com
  • Fundamentals
  • SimpDnd

iocs.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOCS.H
00003 //
00004 //      Definition of COleClientSite
00005 //
00006 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008 #if !defined( _IOCS_H_ )
00009 #define _IOCS_H_
00010
00011 #include <assert.h>
00012
00013 class CSimpleSite;
00014
00015 interface COleClientSite : public IOleClientSite
00016 {
00017   int m_nCount;
00018   CSimpleSite FAR * m_pSite;
00019
00020   COleClientSite(CSimpleSite FAR * pSite) {
00021     OutputDebugString("In IOCS's constructor\r\n");
00022     m_pSite = pSite;
00023     m_nCount = 0;
00024     }
00025
00026   ~COleClientSite() {
00027     OutputDebugString("In IOCS's destructor\r\n");
00028     assert(m_nCount == 0);
00029     }
00030
00031   STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
00032   STDMETHODIMP_(ULONG) AddRef();
00033   STDMETHODIMP_(ULONG) Release();
00034
00035   // *** IOleClientSite methods ***
00036   STDMETHODIMP SaveObject();
00037   STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER FAR* ppmk);
00038   STDMETHODIMP GetContainer(LPOLECONTAINER FAR* ppContainer);
00039   STDMETHODIMP ShowObject();
00040   STDMETHODIMP OnShowWindow(BOOL fShow);
00041   STDMETHODIMP RequestNewObjectLayout();
00042 };
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsimple/service.h Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsimple

service.h

Go to the documentation of this file.
00001 #pragma once
00002 /*
00003     Copyright Microsoft Corp. 1992 - 2001
00004
00005     File Replication Sample
00006     Server System Service
00007
00008     FILE: Service.h
00009
00010     PURPOSE: Provides file replication service function declarations.
00011
00012     FUNCTIONS:
00013
00014     COMMENTS: These funtions may be used by the main service routines
00015         as well as by the client and server file replication RPC routines.
00016
00017 */
00018
00019 // Name of the executable
00020 #define APPNAME "FileRepService"
00021
00022 // Internal name of the service
00023 #define SERVICENAME "FileRepService"
00024
00025 // Displayed name of the service
00026 #define SERVICEDISPLAYNAME "File Replication Service"
00027
00028 // List of service dependencies
00029 #define DEPENDENCIES "RPCSS\0\0"
00030
00031 #ifdef PROF
00032 #include "Prof.h"
00033 #endif
00034
00035 /*
00036     These are prototypes for shared service functions.
00037     See function definitions in Service.c for help.
00038 */
00039
00040 BOOL ReportStatusToSCMgr(SERVICE_STATUS_HANDLE *sshStatusHandle,
00041        SERVICE_STATUS *ssStatus,
00042        DWORD dwCurrentState,
00043        DWORD dwWin32ExitCode,
00044        DWORD dwWaitHint);
00045
00046 VOID AddToMessageLog(LPTSTR lpszMsg);
00047
00048 // The initial size of the RPC heap
00049 #define RPC_HEAP_SIZE_INIT (1024*1024)
00050 #define RPC_HEAP_SIZE_MAX (128*1024*1024)
00051
00052 // Heap for use by midl_user_allocate and midl_user_free.
00053 extern HANDLE RpcHeap;
00054
00055 // end Service.h
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/capicom/c_sharp/storesh/storesh.cs Source File

  • Security
  • capicom
  • c_sharp
  • storesh

storesh.cs

Go to the documentation of this file.
00001 //******************************************************************************
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00004 // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00005 // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00006 //
00007 // Copyright (C) 1999 - 2002.  Microsoft Corporation.  All rights reserved.
00008 //
00009 //******************************************************************************
00010 //
00011 // storesh.cs
00012 //
00013 // This is a sample script to illustrate how to use CAPICOM and C#. It creates a
00014 // pseudo shell to navigate certificate stores.
00015 //
00016 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00017 //
00018 // To run this sample you need to have Microsoft Visual C# .NET
00019 // To start: open the storesh.sln file in Visual Studio
00020 //
00021 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00022 //
00023 //
00024 //  Try these commands:
00025 //
00026 //  help
00027 //  dir
00028 //  cd ..
00029 //  cd ..\addressbook
00030 //  dir -l
00031 //  dir -subject John
00032 //  cd \LocalMachine
00033 //  cd \lm
00034 //  display 3
00035 //  view 2
00036 //  import c:\home\temp\pfx1.pfx
00037 //  export 7 c:\home\temp\itm.cer
00038 //  pfxexport 11 c:\home\temp\foo.pfx secretpassword
00039 //  del 2
00040 //  dir -issuer "Thawte"
00041 //  dir -eku "Code Signing"
00042 //  dir -eku 1.3.6.1.5.5.7.3.4
00043 //
00044 // Note: For simplicity, this script does not handle exceptions.
00045 //
00046 //******************************************************************************
00047
00048 using System;
00049 using System.Collections;
00050 using System.Runtime.InteropServices;
00051 using CAPICOM;
00052 using System.Text;
00053
00054 namespace storesh
00055 {
00056
00057
00058   public class Win32
00059   {
00060
00061     [DllImport("crypt32.dll",CharSet=CharSet.Unicode )]
00062     public static extern uint CertEnumSystemStore(
00063       uint dwFlags,
00064       uint pvSystemStoreLocationPara,
00065       String pvArg,
00066       CertEnumSystemStoreCallback pfnEnum
00067       );
00068
00069   }
00070
00071   public delegate bool CertEnumSystemStoreCallback(
00072     [In, MarshalAs( UnmanagedType.LPWStr) ] String pvSystemStore,
00073     uint dwFlags,
00074     ref CERT_SYSTEM_STORE_INFO pStoreInfo,
00075     uint pvReserved,
00076     [In, MarshalAs( UnmanagedType.LPWStr) ] String pvArg
00077   );
00078
00079   [StructLayout(LayoutKind.Sequential)]
00080   public struct CERT_SYSTEM_STORE_INFO
00081   {
00082     uint cbSize;
00083   }
00084
00085
00086
00087   class Storesh
00088   {
00089     const uint CERT_SYSTEM_STORE_CURRENT_USER  = 0x10000;
00090     const uint CERT_SYSTEM_STORE_LOCAL_MACHINE  = 0x20000;
00091     const int VALIDITY_LENGTH = 23;
00092     const int CERTNAME_LENGTH = 20;
00093     const int THUMBPRINT_LENGTH = 42;
00094     const int FRIENDLYNAME_LENGTH = 20;
00095     const int CAPICOM_ENCODED_DATA_FORMAT_MULTI_LINES =1 ;
00096     const int HELP_PAD = 30;
00097     const String CurrentUser = "CurrentUser";
00098     const String LocalMachine = "LocalMachine";
00099
00100     static private String _currStoreName = "My";
00101     static private String _currStoreLocation = CurrentUser;
00102     static IEnumerator _currFilter;
00103     static StoreClass _oCurrStore;
00104
00105     enum Listing {Brief, Long};
00106
00107
00108     /// The main entry point for the application.
00109     [STAThread]
00110     static void Main(string[] args)
00111     {
00112
00113       //We take one argument, a starting store name
00114       if (args.Length > 0)
00115       {
00116         _currStoreName = args[0];
00117       }
00118       _oCurrStore = new StoreClass();
00119       _oCurrStore.Open(
00120         CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE,
00121         _currStoreName,
00122         CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_EXISTING_ONLY |
00123         CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED);
00124       waitForInput();
00125     }
00126
00127     static void waitForInput()
00128     {
00129       bool done = false;
00130       String input;
00131       while (!done)
00132       {
00133         Console.Write(_currStoreLocation + "\\" + _currStoreName + ">");
00134         input = Console.ReadLine();
00135         done = parseCommandLine(input);
00136       }
00137     }
00138
00139     static bool parseCommandLine ( String input)
00140     {
00141
00142       ArrayList alArgs = ParseArgs(input);
00143       Certificate oCert = null;
00144
00145       switch ((String)alArgs[0])
00146       {
00147         case "cd":
00148         {
00149           //This is the 'change directory' command
00150           String storename;
00151           if (alArgs.Count >0 )
00152           {
00153             storename = (String)alArgs[1];
00154           }
00155           else
00156           {
00157             storename = _currStoreName; //reset store name
00158           }
00159
00160           if (storename.Equals("..") && _currStoreName.Length > 0 )
00161           {
00162             _oCurrStore = new StoreClass();
00163             storename = null;
00164             _currFilter = null;
00165             _currStoreName = "";
00166           }
00167           else if (storename.StartsWith("..") && _currStoreName.Length > 0 )
00168           {
00169             _oCurrStore = new StoreClass();
00170             _currFilter = null;
00171             storename = storename.Substring(3,storename.Length - 3);
00172             _currStoreName = "";
00173           }
00174           else if (storename.Equals(".."))
00175           {
00176             storename = null;
00177           }
00178           else if (storename.Equals("\\" + LocalMachine)  || storename.Equals("\\lm" ))
00179           {
00180             _oCurrStore = new StoreClass();
00181             _currStoreName = "";
00182             storename = null;
00183             _currStoreLocation = LocalMachine;
00184             _currFilter = null;
00185           }
00186           else if (storename.Equals("\\" + CurrentUser)  || storename.Equals("\\cu" ))
00187           {
00188             _oCurrStore = new StoreClass();
00189             _currStoreName = "";
00190             storename = null;
00191             _currStoreLocation = CurrentUser;
00192             _currFilter = null;
00193           }
00194           if (storename != null && _currStoreName.Equals(""))
00195           {
00196
00197             try
00198             {
00199               CAPICOM_STORE_LOCATION OpenMode = CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE;
00200               if (_currStoreLocation.Equals(LocalMachine))
00201               {
00202                 OpenMode = CAPICOM_STORE_LOCATION.CAPICOM_LOCAL_MACHINE_STORE;
00203               }
00204
00205               //Open the store MAX_ALLOWED in case the user wants to import/del/export
00206               //They may not have permission to modify HKLM stores
00207               _oCurrStore.Open( OpenMode,
00208                 storename,
00209                 CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_EXISTING_ONLY |
00210                 CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED);
00211               _currStoreName = storename;
00212
00213             }
00214             catch (Exception e)
00215             {
00216               Console.WriteLine (e.Message);
00217             }
00218           }
00219           return false;
00220         }
00221         case "q":
00222         case "quit":
00223         {
00224           return true;
00225         }
00226         case "h":
00227         case "help":
00228         {
00229           DisplayHelp();
00230
00231           return false;
00232         }
00233         case "v":
00234         case "view":
00235           try
00236           {
00237             oCert = GetCertByIndex(Convert.ToInt32(alArgs[1]));
00238             if (oCert != null )
00239             {
00240               DisplayCertificate(oCert, "");
00241             }
00242             else
00243             {
00244               Console.WriteLine ("No certificate with that index (" + alArgs[1] + ") could be found.");
00245             }
00246           }
00247           catch (Exception e)
00248           {
00249             Console.WriteLine ("An error was encountered processing the " + alArgs[0] + " command: " + e.Message);
00250           }
00251           break;
00252         case "y":
00253         case "display":
00254           try
00255           {
00256             oCert = GetCertByIndex(Convert.ToInt32(alArgs[1]));
00257             if (oCert != null )
00258             {
00259               oCert.Display();
00260             }
00261             else
00262             {
00263               Console.WriteLine ("No certificate with that index (" + alArgs[1] + ") could be found.");
00264             }
00265           }
00266           catch (Exception e)
00267           {
00268             Console.WriteLine ("An error was encountered processing the " + alArgs[0] + " command: " + e.Message);
00269           }
00270           break;
00271         case "del":
00272           try
00273           {
00274             oCert = GetCertByIndex(Convert.ToInt32(alArgs[1]));
00275             if (oCert != null )
00276             {
00277               String answer = "n";
00278               Console.WriteLine(  ToColumn (oCert.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME), CERTNAME_LENGTH) +
00279                 " " +
00280                 ToColumn (oCert.Thumbprint, THUMBPRINT_LENGTH ));
00281               Console.WriteLine ("Issuer: " + oCert.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME));
00282               Console.WriteLine ("Validity Period: " + oCert.ValidFromDate + " - " + oCert.ValidToDate);
00283               DisplayEKU(oCert.ExtendedKeyUsage().EKUs);
00284               Console.WriteLine();
00285               Console.Write("Are you sure you want to delete this certificate (y/n)? ");
00286               answer = Console.ReadLine();
00287               if (!answer.Equals("y"))
00288               {
00289                 break;
00290               }
00291
00292               if (oCert.HasPrivateKey() && !oCert.PrivateKey.IsHardwareDevice() )
00293               {
00294                 oCert.PrivateKey.Delete();
00295                 Console.WriteLine ("The private key was deleted.");
00296               }
00297               try
00298               {
00299                 _oCurrStore.Remove(oCert);
00300                 Console.WriteLine("The certificate was removed.");
00301               }
00302               catch
00303               {
00304                 Console.WriteLine("The certificate could not be removed.");
00305               }
00306             }
00307             else
00308             {
00309               Console.WriteLine ("No certificate with that index (" + alArgs[1] + ") could be found.");
00310             }
00311           }
00312           catch (Exception e)
00313           {
00314             Console.WriteLine ("An error was encountered processing the " + alArgs[0] + " command: " + e.Message);
00315           }
00316           break;
00317         case "e":
00318         case "export":
00319           try
00320           {
00321             oCert = GetCertByIndex(Convert.ToInt32(alArgs[1]));
00322             if (oCert != null )
00323             {
00324               String filename =  (String)alArgs[2];
00325               if (filename != null)
00326               {
00327                 oCert.Save(filename,
00328                   "",
00329                   CAPICOM_CERTIFICATE_SAVE_AS_TYPE.CAPICOM_CERTIFICATE_SAVE_AS_CER,
00330                   CAPICOM_CERTIFICATE_INCLUDE_OPTION.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY);
00331
00332               }
00333               else
00334               {
00335                 Console.WriteLine("No filename specified.");
00336               }
00337             }
00338             else
00339             {
00340               Console.WriteLine ("No certificate with that index (" + alArgs[1] + ") could be found.");
00341             }
00342           }
00343           catch (Exception e)
00344           {
00345             Console.WriteLine ("An error was encountered processing the " + alArgs[0] + " command: " + e.Message);
00346           }
00347           break;
00348         case "i":
00349         case "import":
00350           try
00351           {
00352             String filename = null;
00353             String password = null;
00354             CAPICOM_KEY_STORAGE_FLAG iFlag = CAPICOM_KEY_STORAGE_FLAG.CAPICOM_KEY_STORAGE_DEFAULT;
00355
00356             if (alArgs.Count >= 2)
00357             {
00358               filename = (String)alArgs[1];
00359             }
00360             if (alArgs.Count >= 3)
00361             {
00362               password = (String)alArgs[2];
00363             }
00364             if (alArgs.Count >= 4)
00365             {
00366               String flag = null;
00367               if (alArgs.Count == 4)
00368               {
00369                 password = null;
00370                 flag = (String)alArgs[3];
00371               }
00372               else if (alArgs.Count == 5)
00373               {
00374                 flag = (String)alArgs[4];
00375               }
00376               if (flag.Equals ("e"))
00377               {
00378                 iFlag = CAPICOM_KEY_STORAGE_FLAG.CAPICOM_KEY_STORAGE_EXPORTABLE;
00379               }
00380               else if (flag.Equals ("p"))
00381               {
00382                 iFlag = CAPICOM_KEY_STORAGE_FLAG.CAPICOM_KEY_STORAGE_USER_PROTECTED;
00383               }
00384               else if (flag.Equals ("ep") || flag.Equals ("pe"))
00385               {
00386                 iFlag = CAPICOM_KEY_STORAGE_FLAG.CAPICOM_KEY_STORAGE_USER_PROTECTED | CAPICOM_KEY_STORAGE_FLAG.CAPICOM_KEY_STORAGE_EXPORTABLE;
00387               }
00388             }
00389             _oCurrStore.Load(filename, password, iFlag);
00390           }
00391           catch (Exception e)
00392           {
00393             Console.WriteLine ("An error was encountered processing the " + alArgs[0] + " command: " + e.Message);
00394           }
00395           break;
00396         case "p":
00397         case "pfxexport":
00398           try
00399           {
00400             oCert = GetCertByIndex(Convert.ToInt32(alArgs[1]));
00401             if (oCert != null )
00402             {
00403               String filename =  (String)alArgs[2];
00404               String password =  (String)alArgs[3];
00405
00406               if (filename != null)
00407               {
00408                 oCert.Save(filename,
00409                   password,
00410                   CAPICOM_CERTIFICATE_SAVE_AS_TYPE.CAPICOM_CERTIFICATE_SAVE_AS_PFX,
00411                   CAPICOM_CERTIFICATE_INCLUDE_OPTION.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN);
00412               }
00413               else
00414               {
00415                 Console.WriteLine("No filename specified.");
00416               }
00417             }
00418             else
00419             {
00420               Console.WriteLine ("No certificate with that index (" + alArgs[1] + ") could be found.");
00421             }
00422           }
00423           catch (Exception e)
00424           {
00425             Console.WriteLine ("An error was encountered processing the " + alArgs[0] + " command: " + e.Message);
00426           }
00427           break;
00428         case "d":
00429         case "dir":
00430         {
00431           Certificates oCerts;
00432           Listing listing = Listing.Brief;
00433
00434           if ((_currStoreLocation.Equals(CurrentUser) || _currStoreLocation.Equals(LocalMachine))
00435             && _currStoreName.Length == 0)
00436           {
00437             uint retval = 0;
00438             uint dwFlags = CERT_SYSTEM_STORE_CURRENT_USER;
00439
00440             CertEnumSystemStoreCallback StoreCallback = new CertEnumSystemStoreCallback(Storesh.CertEnumSystemStoreCallback);
00441             if (_currStoreLocation.Equals(LocalMachine))
00442             {
00443               dwFlags = CERT_SYSTEM_STORE_LOCAL_MACHINE;
00444             }
00445             retval= Win32.CertEnumSystemStore(
00446               dwFlags,
00447               0,
00448               _currStoreName,
00449               StoreCallback
00450               );
00451           }
00452           else if (alArgs.Count >= 1)
00453           {
00454             int i =0 ;
00455             try
00456             {
00457               _currFilter = _oCurrStore.Certificates.GetEnumerator();
00458               for (i = 1; i < alArgs.Count; i++)
00459               {
00460                 String param = ((String)alArgs[i]).ToLower();
00461                 if (param.Equals("/l") || param.Equals("-l"))
00462                 {
00463                   listing = Listing.Long;
00464                 }
00465                 else if (param.Equals("/subject") || param.Equals("-subject"))
00466                 {
00467                   Object filter = (System.String)alArgs[++i];
00468                   oCerts = (Certificates)_oCurrStore.Certificates;
00469                   oCerts = (Certificates)oCerts.Find(CAPICOM_CERTIFICATE_FIND_TYPE.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME,
00470                     filter,
00471                     false);
00472                   _currFilter = oCerts.GetEnumerator();
00473
00474                 }
00475                 else if (param.Equals("/eku") || param.Equals("-eku"))
00476                 {
00477                   Object filter = (System.String)alArgs[++i];
00478                   oCerts = (Certificates)_oCurrStore.Certificates;
00479                   oCerts = (Certificates)oCerts.Find(CAPICOM_CERTIFICATE_FIND_TYPE.CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY,
00480                     filter,
00481                     false);
00482                   _currFilter = oCerts.GetEnumerator();
00483
00484                 }
00485                 else if (param.Equals("/issuer") || param.Equals("-issuer"))
00486                 {
00487                   Object filter = (System.String)alArgs[++i];
00488                   oCerts = (Certificates)_oCurrStore.Certificates;
00489                   oCerts = (Certificates)oCerts.Find(CAPICOM_CERTIFICATE_FIND_TYPE.CAPICOM_CERTIFICATE_FIND_ISSUER_NAME,
00490                     filter,
00491                     false);
00492                   _currFilter = oCerts.GetEnumerator();
00493
00494                 }
00495                 else if (param.Equals("/sha1") || param.Equals("-sha1"))
00496                 {
00497                   String filter = (String)alArgs[++i];
00498                   oCerts = (Certificates)_oCurrStore.Certificates;
00499                   oCerts = (Certificates)oCerts.Find(CAPICOM_CERTIFICATE_FIND_TYPE.CAPICOM_CERTIFICATE_FIND_SHA1_HASH,
00500                     filter,
00501                     false);
00502                   _currFilter = oCerts.GetEnumerator();
00503                 }
00504               }
00505               i = 1;
00506               while (_currFilter.MoveNext() == true)
00507               {
00508                 oCert = (Certificate) _currFilter.Current;
00509                 Console.Write ( (i++ + ". ").PadRight(4,' '));
00510                 switch (listing)
00511                 {
00512                   case Listing.Brief:
00513                     Console.WriteLine(  ToColumn (oCert.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME), CERTNAME_LENGTH) +
00514                       " " +
00515                       ToColumn (oCert.ValidToDate.ToString(), VALIDITY_LENGTH) +
00516                       ToColumn (oCert.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME), CERTNAME_LENGTH) );
00517                     break;
00518                   case Listing.Long:
00519                   {
00520                     Console.WriteLine(  ToColumn (oCert.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME), CERTNAME_LENGTH) +
00521                       " " +
00522                       ToColumn (oCert.Thumbprint, THUMBPRINT_LENGTH ));
00523                     Console.WriteLine ("Issuer: " + oCert.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME));
00524                     Console.WriteLine ("Validity Period: " + oCert.ValidFromDate + " - " + oCert.ValidToDate);
00525                     DisplayEKU(oCert.ExtendedKeyUsage().EKUs);
00526                     Console.WriteLine();
00527                     break;
00528                   }
00529                 }
00530               }
00531             }
00532             catch (Exception e)
00533             {
00534               Console.WriteLine("An error was encountered: " + e.Message);
00535             }
00536           }
00537           break;
00538         }
00539         default:
00540           DisplayHelp();
00541           break;
00542
00543       }
00544
00545       return false;
00546     }
00547
00548     public static bool CertEnumSystemStoreCallback(
00549       String pvSystemStore,
00550       uint dwFlags,
00551       ref CERT_SYSTEM_STORE_INFO pStoreInfo,
00552       uint pvReserved,
00553       String pvArg
00554       )
00555     {
00556       Console.WriteLine("[ " +pvSystemStore + " ]");
00557       return true;
00558     }
00559
00560     public static Certificate GetCertByIndex( int idx )
00561     {
00562       Certificate oCert;
00563       int i = 0;
00564
00565       if (_oCurrStore != null)
00566       {
00567         if (_currFilter == null)
00568         {
00569           _currFilter = _oCurrStore.Certificates.GetEnumerator();
00570         }
00571         else
00572         {
00573           _currFilter.Reset();
00574         }
00575
00576         while (_currFilter.MoveNext() == true)
00577         {
00578           oCert  = (Certificate)_currFilter.Current;
00579           i++;
00580           if (i == idx)
00581           {
00582             return oCert;
00583           }
00584         }
00585       }
00586       return null;
00587     }
00588
00589     private static ArrayList ParseArgs(String input)
00590     {
00591       char[] delims = new char[] {' '};
00592       ArrayList argsarray = new ArrayList();
00593       String multiString = null;
00594
00595       String[] argSplit = input.Split(delims);
00596       for (int i = 0; i < argSplit.Length; i++)
00597       {
00598         String curr = argSplit[i];
00599         if (curr.StartsWith("\"") && curr.EndsWith("\""))
00600         {
00601           argsarray.Add(curr.Substring(1,curr.Length-2));
00602         }
00603         else if (curr.StartsWith("\""))
00604         {
00605           multiString = curr;
00606         }
00607         else if (argSplit[i].EndsWith("\""))
00608         {
00609           multiString = multiString + " " + curr;
00610           argsarray.Add(multiString.Substring(1,multiString.Length-2));
00611           multiString = null;
00612         }
00613         else
00614         {
00615           if (multiString != null)
00616           {
00617             multiString = multiString + " " + curr;
00618           }
00619           else
00620           {
00621             argsarray.Add(curr);
00622           }
00623         }
00624       }
00625       argSplit = null;
00626       return argsarray;
00627     }
00628
00629     public static void DisplayHelp()
00630     {
00631       Console.WriteLine();
00632       Console.Write("[h]elp".PadRight(HELP_PAD, ' '));
00633       Console.WriteLine("This screen");
00634
00635       Console.WriteLine();
00636       Console.Write("cd <location>".PadRight(HELP_PAD, ' '));
00637       Console.WriteLine("<location> is a store name or ..");
00638       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "Can also be \\LocalMachine (\\lm) or \\CurrentUser (\\cu)");
00639
00640       Console.WriteLine();
00641       Console.Write("[d]ir <options>".PadRight(HELP_PAD, ' '));
00642       Console.WriteLine("List the contents of a certificate store");
00643       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-l Long listing");
00644       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-subject <name>  Match subject name.");
00645       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-issuer <name> Match issuer name.");
00646       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-eku <EKU> Must have specified EKU.");
00647       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-sha1 <sha1> Match thumbprint.");
00648
00649       Console.WriteLine();
00650       Console.Write("[v]iew <idx>".PadRight(HELP_PAD, ' '));
00651       Console.WriteLine("<idx> is the number of the certificate to view");
00652
00653       Console.WriteLine();
00654       Console.Write("del <idx>".PadRight(HELP_PAD, ' '));
00655       Console.WriteLine("<idx> is the number of the certificate to delete");
00656
00657       Console.WriteLine();
00658       Console.Write("displa[y] <idx>".PadRight(HELP_PAD, ' '));
00659       Console.WriteLine("<idx> is the number of the certificate to display");
00660
00661       Console.WriteLine();
00662       Console.Write("[e]xport <idx> <file>".PadRight(HELP_PAD, ' '));
00663       Console.WriteLine("<idx> is the number of the certificate to display");
00664       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<file> is the destination filename");
00665
00666       Console.WriteLine();
00667       Console.Write("[p]fxexport <idx> <file> <pw>".PadRight(HELP_PAD, ' '));
00668       Console.WriteLine("<idx> is the number of the certificate to display");
00669       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<file> is the destination filename");
00670       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<pw> is the password");
00671
00672       Console.WriteLine();
00673       Console.Write("[i]mport <file> <pw> [-key e|p]".PadRight(HELP_PAD, ' '));
00674       Console.WriteLine("<file> is the input filename");
00675       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<pw> is the filename password");
00676       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-key: e is exportable");
00677       Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-key: p is user protected. Both may be specified");
00678
00679     }
00680
00681     public static String ToColumn (String s, int i)
00682     {
00683       String retval;
00684       if (s == null || i > s.Length )
00685       {
00686         retval = s.PadRight(i);
00687       }
00688       else
00689       {
00690         retval = s.Substring(0,i).PadRight(i,' ');
00691       }
00692       return retval;
00693     }
00694
00695     public static void DisplayEKU (EKUs EKUs)
00696     {
00697       if (EKUs.Count > 0)
00698       {
00699         OID OID;
00700         OID = new OIDClass();
00701         foreach (EKU EKU in EKUs)
00702         {
00703           OID.Value = EKU.OID;
00704           Console.WriteLine( "  " + OID.FriendlyName + " (" + OID.Value + ")" );
00705         }
00706         OID = null;
00707       }
00708     }
00709
00710     public static void DisplayCertificate ( Certificate Certificate , String Title)
00711     {
00712       String[] KeySpecStrings = {"Unknown", "Exchange","Signature" };
00713       String[] ProviderTypes = {  "Unknown",
00714                      "PROV_RSA_FULL",
00715                      "PROV_RSA_SIG",
00716                      "PROV_DSS",
00717                      "PROV_FORTEZZA",
00718                      "PROV_MS_EXCHANGE",
00719                      "PROV_SSL",
00720                      "PROV_STT_MER",
00721                      "PROV_STT_ACQ",
00722                      "PROV_STT_BRND",
00723                      "PROV_STT_ROOT",
00724                      "PROV_STT_ISS",
00725                      "PROV_RSA_SCHANNEL",
00726                      "PROV_DSS_DH",
00727                      "PROV_EC_ECDSA_SIG",
00728                      "PROV_EC_ECNRA_SIG",
00729                      "PROV_EC_ECDSA_FULL",
00730                      "PROV_EC_ECNRA_FULL",
00731                      "PROV_DH_SCHANNEL",
00732                      "PROV_SPYRUS_LYNKS",
00733                      "PROV_RNG",
00734                      "PROV_INTEL_SEC",
00735                      "PROV_REPLACE_OWF",
00736                      "PROV_RSA_AES" };
00737
00738       //int iIndex = 0;
00739
00740       Console.WriteLine( Title );
00741       Console.WriteLine();
00742       Console.WriteLine( "Subject Name:");
00743       Console.WriteLine( "  Simple name = " + Certificate.SubjectName);
00744       Console.WriteLine( "  Email name  = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME));
00745       Console.WriteLine( "  UPN name    = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_UPN));
00746       Console.WriteLine( "  DNS name    = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_DNS_NAME));
00747       Console.WriteLine();
00748       Console.WriteLine( "Issuer Name: " + Certificate.IssuerName);
00749       Console.WriteLine();
00750       Console.WriteLine( "Serial Number: " + Certificate.SerialNumber);
00751       Console.WriteLine();
00752       Console.WriteLine( "Not Before: " + Certificate.ValidFromDate);
00753       Console.WriteLine();
00754       Console.WriteLine( "Not After: " + Certificate.ValidToDate);
00755       Console.WriteLine();
00756       Console.WriteLine( "SHA1 Hash: " + Certificate.Thumbprint);
00757       Console.WriteLine();
00758       Console.WriteLine( "IsValid: " + Certificate.IsValid().Result);
00759       Console.WriteLine();
00760       Console.WriteLine( "Archived: " + Certificate.Archived);
00761       Console.WriteLine();
00762
00763
00764       if (Certificate.BasicConstraints().IsPresent)
00765       {
00766         Console.WriteLine( "Basic Constraints:" );
00767         Console.WriteLine( "  Critical          = " + Certificate.BasicConstraints().IsCritical );
00768         Console.WriteLine( "  CA                = " + Certificate.BasicConstraints().IsCertificateAuthority );
00769         Console.WriteLine( "  PathLenConstraint = ");
00770         if (Certificate.BasicConstraints().IsPathLenConstraintPresent)
00771         {
00772           Console.WriteLine( Certificate.BasicConstraints().PathLenConstraint);
00773         }
00774         else
00775         {
00776           Console.WriteLine( "Not present.");
00777         }
00778       }
00779       else
00780       {
00781         Console.WriteLine( "Basic Constraints: Not present." );
00782       }
00783       Console.WriteLine();
00784
00785       if (Certificate.KeyUsage().IsPresent)
00786       {
00787         Console.WriteLine( "Key Usage:");
00788         Console.WriteLine( "  Critical                  = " + Certificate.KeyUsage().IsCritical);
00789         Console.WriteLine( "  IsDigitalSignatureEnabled = " + Certificate.KeyUsage().IsDigitalSignatureEnabled );
00790         Console.WriteLine( "  IsNonRepudiationEnabled   = " + Certificate.KeyUsage().IsNonRepudiationEnabled);
00791         Console.WriteLine( "  IsKeyEnciphermentEnabled  = " + Certificate.KeyUsage().IsKeyEnciphermentEnabled);
00792         Console.WriteLine( "  IsDataEnciphermentEnabled = " + Certificate.KeyUsage().IsDataEnciphermentEnabled);
00793         Console.WriteLine( "  IsKeyAgreementEnabled     = " + Certificate.KeyUsage().IsKeyAgreementEnabled);
00794         Console.WriteLine( "  IsKeyCertSignEnabled      = " + Certificate.KeyUsage().IsKeyCertSignEnabled);
00795         Console.WriteLine( "  IsCRLSignEnabled          = " + Certificate.KeyUsage().IsCRLSignEnabled);
00796         Console.WriteLine( "  IsEncipherOnlyEnabled     = " + Certificate.KeyUsage().IsEncipherOnlyEnabled);
00797         Console.WriteLine( "  IsDecipherOnlyEnabled     = " + Certificate.KeyUsage().IsDecipherOnlyEnabled);
00798       }
00799       else
00800       {
00801         Console.WriteLine( "Key Usage: Not present.");
00802
00803       }
00804       Console.WriteLine();
00805
00806       if (Certificate.ExtendedKeyUsage().IsPresent)
00807       {
00808         if (Certificate.ExtendedKeyUsage().EKUs.Count > 0)
00809         {
00810           OID OID;
00811           OID = new OIDClass();
00812           Console.WriteLine( "Extended Key Usage:");
00813           Console.WriteLine( "  Critical = " + Certificate.ExtendedKeyUsage().IsCritical);
00814           foreach (EKU EKU in Certificate.ExtendedKeyUsage().EKUs)
00815           {
00816             OID.Value = EKU.OID;
00817             Console.WriteLine( "  " + OID.FriendlyName + " (" + OID.Value + ")" );
00818           }
00819           OID = null;
00820         }
00821         else
00822         {
00823           Console.WriteLine( "Extended Key Usage: Not valid for any usage.");
00824           Console.WriteLine( "  Critical = " + Certificate.ExtendedKeyUsage().IsCritical );
00825         }
00826       }
00827       else
00828       {
00829         Console.WriteLine( "Extended Key Usage: Not present (valid for all usages).");
00830       }
00831       Console.WriteLine();
00832
00833       if (Certificate.Template().IsPresent)
00834       {
00835         Console.WriteLine( "Template:");
00836         Console.WriteLine( "  Critical = " + Certificate.Template().IsCritical);
00837         Console.WriteLine( "  Name     = " + Certificate.Template().Name);
00838         Console.WriteLine( "  OID      = " + Certificate.Template().OID.FriendlyName + "(" + Certificate.Template().OID.Value + ")");
00839         Console.WriteLine( "  Major    = " + Certificate.Template().MajorVersion);
00840         Console.WriteLine( "  Minor    = " + Certificate.Template().MinorVersion);
00841       }
00842       else
00843       {
00844         Console.WriteLine( "Template: Not present.");
00845       }
00846       Console.WriteLine();
00847
00848       Console.WriteLine( "Public Key:");
00849       Console.WriteLine( "  Algorithm  = " + Certificate.PublicKey().Algorithm.FriendlyName + "(" + Certificate.PublicKey().Algorithm.Value + ")");
00850       Console.WriteLine( "  Length     = " + Certificate.PublicKey().Length + " bits");
00851       Console.WriteLine( "  Key blob   = " + Certificate.PublicKey().EncodedKey.Format(true));
00852       Console.WriteLine( "  Parameters = " + Certificate.PublicKey().EncodedParameters.Format(true));
00853
00854       if (Certificate.HasPrivateKey())
00855       {
00856         Console.WriteLine( "Private Key:");
00857         Console.WriteLine( "  Container name   = " + Certificate.PrivateKey.ContainerName);
00858         //Don't display unique container name for hardware token because it may cause UI to be displayed.
00859         if (! Certificate.PrivateKey.IsHardwareDevice())
00860         {
00861           Console.WriteLine( "  Unique name      = " + Certificate.PrivateKey.UniqueContainerName);
00862         }
00863         Console.WriteLine( "  Provider name    = " + Certificate.PrivateKey.ProviderName);
00864         Console.WriteLine(     "  Provider type    = " );
00865         if (Convert.ToInt32(Certificate.PrivateKey.ProviderType) > ProviderTypes.GetUpperBound(0))
00866         {
00867           Console.WriteLine( ProviderTypes[0] + " (" + Convert.ToString(Certificate.PrivateKey.ProviderType) + ")");
00868         }
00869         else
00870         {
00871           Console.WriteLine( ProviderTypes[Convert.ToInt32(Certificate.PrivateKey.ProviderType)] + " (" + Convert.ToString(Certificate.PrivateKey.ProviderType) + ")");
00872         }
00873         Console.WriteLine(     "  Key spec         = " );
00874         if (Convert.ToInt32(Certificate.PrivateKey.KeySpec) > KeySpecStrings.GetUpperBound(0))
00875         {
00876           Console.WriteLine( KeySpecStrings[0] + " (" + Convert.ToString(Certificate.PrivateKey.KeySpec) + ")");
00877         }
00878         else
00879         {
00880           Console.WriteLine( KeySpecStrings[Convert.ToInt32(Certificate.PrivateKey.KeySpec)] + " (" + Convert.ToString(Certificate.PrivateKey.KeySpec) + ")");
00881         }
00882         Console.WriteLine( "  Accessible       = " + Certificate.PrivateKey.IsAccessible());
00883         Console.WriteLine( "  Protected        = " + Certificate.PrivateKey.IsProtected());
00884         Console.WriteLine( "  Exportable       = " + Certificate.PrivateKey.IsExportable());
00885         Console.WriteLine( "  Removable        = " + Certificate.PrivateKey.IsRemovable());
00886         Console.WriteLine( "  Machine keyset   = " + Certificate.PrivateKey.IsMachineKeyset());
00887         Console.WriteLine( "  Hardware storage = " + Certificate.PrivateKey.IsHardwareDevice());
00888       }
00889       else
00890       {
00891         Console.WriteLine( "Private Key: Not found." );
00892       }
00893       Console.WriteLine();
00894
00895       if (true)
00896       {
00897         int iIndex = 0;
00898
00899         foreach (Extension Extension in Certificate.Extensions())
00900         {
00901           iIndex++;
00902           Console.WriteLine( "Extension #" + Convert.ToString(iIndex) + ": " + Extension.OID.FriendlyName + "(" + Extension.OID.Value + ")");
00903           Console.WriteLine( "  " + Extension.EncodedData.Format(true));
00904
00905           if (Extension.EncodedData.Decoder() != null)
00906           {
00907             switch (Extension.OID.Value)
00908             {
00909               case Constants.CAPICOM_CERT_POLICIES_OID:
00910               {
00911                 CertificatePolicies CertPolicies;
00912                 int pIndex = 0;
00913
00914                 CertPolicies = (CertificatePolicies)Extension.EncodedData.Decoder();
00915                 Console.WriteLine( "Decoded Certificate Policies: " + Convert.ToString(CertPolicies.Count) + " PolicyInformation(s)");
00916
00917                 foreach  (PolicyInformation PolicyInformation in CertPolicies)
00918                 {
00919                   int qIndex = 0;
00920                   pIndex++;
00921                   Console.WriteLine( "  PolicyInformation #" + Convert.ToString(pIndex) + ": " + Convert.ToString(PolicyInformation.Qualifiers.Count) + " Qualifier(s)");
00922                   Console.WriteLine( "    OID = " + PolicyInformation.OID.FriendlyName + "(" + PolicyInformation.OID.Value + ")");
00923
00924
00925                   foreach (Qualifier Qualifier  in PolicyInformation.Qualifiers)
00926                   {
00927                     qIndex++;
00928                     Console.WriteLine( "    Qualifier #" + Convert.ToString(qIndex) + ":");
00929                     Console.WriteLine( "      OID               = " + Qualifier.OID.FriendlyName + "(" + Qualifier.OID.Value + ")");
00930                     Console.WriteLine( "      CPS URI           = " + Qualifier.CPSPointer);
00931                     Console.WriteLine( "      Organization name = " + Qualifier.OrganizationName);
00932                     Console.WriteLine( "      Notice number(s)  = ");
00933                     if (Qualifier.NoticeNumbers != null)
00934                     {
00935                       foreach (NoticeNumbers NoticeNumber in Qualifier.NoticeNumbers)
00936                       {
00937                         Console.WriteLine( Convert.ToString(NoticeNumber));
00938                       }
00939                     }
00940                     Console.WriteLine();
00941                     Console.WriteLine( "      Explicit text     = " + Qualifier.ExplicitText);
00942                   }
00943                   Console.WriteLine();
00944                 }
00945                 break;
00946               }
00947             }
00948           }
00949         }
00950         if (iIndex == 0)
00951         {
00952           Console.WriteLine( "Extension: None.");
00953           Console.WriteLine();
00954         }
00955
00956         iIndex = 0;
00957         foreach (ExtendedProperty ExtendedProperty in Certificate.ExtendedProperties())
00958         {
00959           iIndex ++;
00960           Console.WriteLine( "Property #" + Convert.ToString(iIndex) + " (ID = " + ExtendedProperty.PropID + "):" );
00961           Console.WriteLine( "  " + ExtendedProperty.get_Value(CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64));
00962         }
00963         if (iIndex == 0)
00964         {
00965           Console.WriteLine( "Property: None.");
00966           Console.WriteLine();
00967         }
00968
00969       }
00970     }
00971   }
00972
00973
00974 }
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/registry.h Source File

  • SysMgmt
  • MMC
  • WMI

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authentication/Authenticate.idl Source File

  • Multimedia
  • WindowsMediaServices9
  • Authentication

Authenticate.idl

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       Authenticate.idl
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011
00012
00013 cpp_quote("//+-------------------------------------------------------------------------")
00014 cpp_quote("//")
00015 cpp_quote("//  Microsoft Windows Media Technologies")
00016 cpp_quote("//  Copyright (C) Microsoft Corporation. All rights reserved.")
00017 cpp_quote("//")
00018 cpp_quote("//  Automatically generated by Midl from Authenticate.idl")
00019 cpp_quote("//")
00020 cpp_quote("//  DO NOT EDIT THIS FILE.")
00021 cpp_quote("//")
00022 cpp_quote("//--------------------------------------------------------------------------")
00023
00024 import "oaidl.idl";
00025 import "ocidl.idl";
00026
00027
00028 cpp_quote( "EXTERN_GUID( LIBID_AUTHENTICATEPLUGINLib, 0x5D3BABFB,0x48A8,0x4BC8,0xB1,0xE9,0x13,0x0D,0x3F,0x74,0x91,0xFC );" )
00029 cpp_quote( "EXTERN_GUID( CLSID_AuthenticatePlugin, 0x394D8DC7,0x5F9D,0x4B42,0x95,0xF1,0x1B,0x35,0xF4,0xFE,0x96,0x8C );" )
00030 cpp_quote( "EXTERN_GUID( CLSID_AuthenticateContext, 0x216A00A7,0x1C9F,0x4550,0x97,0xC0,0x63,0xA2,0x1F,0x63,0x2C,0xFB );" )
00031 cpp_quote( "EXTERN_GUID( IID_AuthenticateContext, 0x2673E72B,0x1132,0x4EF2,0x81,0x9C,0xC1,0xE1,0x9B,0xCB,0x00,0xBA );" )
00032 cpp_quote( "EXTERN_GUID( CLSID_AuthenticateAdmin, 0xE0B7D97C,0x32AB,0x4540,0x95,0x2E,0xD5,0xC3,0xA8,0xBA,0x43,0xA4 );" )
00033 cpp_quote( "EXTERN_GUID( IID_IAuthenticateAdmin, 0xD2DFF596,0xE522,0x4923,0xB0,0x9E,0x9C,0xAA,0x43,0xDE,0xC5,0xB0 );" )
00034
00035 [
00036   object,
00037   uuid(D3FB653C-8534-45E3-A030-E11B8492D8D1),
00038   helpstring("IAuthenticatePlugin Interface"),
00039   pointer_default(unique)
00040 ]
00041 interface IAuthenticatePlugin : IUnknown
00042 {
00043 };
00044
00045 [
00046   object,
00047   uuid(2673E72B-1132-4EF2-819C-C1E19BCB00BA),
00048   helpstring("IAuthenticateContext Interface"),
00049   pointer_default(unique)
00050 ]
00051 interface IAuthenticateContext : IUnknown
00052 {
00053 };
00054
00055 [
00056   object,
00057   uuid(D2DFF596-E522-4923-B09E-9CAA43DEC5B0),
00058
00059   helpstring("IAuthenticateAdmin Interface"),
00060   pointer_default(unique)
00061 ]
00062 interface IAuthenticateAdmin : IDispatch
00063 {
00064 };
00065
00066 [
00067   uuid(5D3BABFB-48A8-4BC8-B1E9-130D3F7491FC),
00068   version(9.0),
00069   helpstring("Authenticate 9.0 Type Library")
00070 ]
00071 library AUTHENTICATEPLUGINLib
00072 {
00073   importlib("stdole32.tlb");
00074   importlib("stdole2.tlb");
00075
00076   [
00077     uuid(394D8DC7-5F9D-4B42-95F1-1B35F4FE968C),
00078     helpstring("AuthenticatePlugin Class")
00079   ]
00080   coclass AuthenticatePlugin
00081   {
00082     [default] interface IAuthenticatePlugin;
00083   };
00084   [
00085     uuid(216A00A7-1C9F-4550-97C0-63A21F632CFB),
00086     helpstring("AuthenticateContext Class")
00087   ]
00088   coclass AuthenticateContext
00089   {
00090     [default] interface IAuthenticateContext;
00091   };
00092   [
00093     uuid(E0B7D97C-32AB-4540-952E-D5C3A8BA43A4),
00094     helpstring("AuthenticateAdmin Class")
00095   ]
00096   coclass AuthenticateAdmin
00097   {
00098     [default] interface IAuthenticateAdmin;
00099   };
00100 };
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authorization/dbauthplugin.h Source File

  • Multimedia
  • WindowsMediaServices9
  • Authorization

dbauthplugin.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName: DBAuthPlugin.h
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011 #pragma once
00012
00013 #if !defined(AFX_DBAUTHPLUGIN_H__7F3F40ED_1634_4AB8_B2C8_1686B8BFC93A__INCLUDED_)
00014 #define AFX_DBAUTHPLUGIN_H__7F3F40ED_1634_4AB8_B2C8_1686B8BFC93A__INCLUDED_
00015
00016 #include "resource.h"       // main symbols
00017
00018 // #import "WMSServerTypeLib.tlb" named_guids no_namespace raw_interfaces_only
00019 #include "wmsdefs.h"
00020
00021 // Forward declare the CDBAuthAdmin interface
00022 class CDBAuthAdmin;
00023
00024 class CSids
00025 {
00026 public:
00027     CSids() : m_cItems( 0 ), m_pSidList( NULL ) {};
00028     ~CSids() { CleanUp(); };
00029     void CleanUp( BOOL fFreeSid = TRUE );
00030     BOOL MatchSid( PSID pSid, DWORD *pdwIndex );
00031     HRESULT CopyAndAddSid( PSID pSid, CSids **ppSids );
00032     HRESULT CopyAndRemoveItem( DWORD dwIndex, CSids **ppSids );
00033     HRESULT SetAuthorizedUsers( IWMSNamedValues *pNamedValues );
00034     HRESULT GetAuthorizedUsers( IWMSNamedValues *pNamedValues );
00035     HRESULT GetUsers( BSTR *pbstrUserNames );
00036
00037 public:
00038     DWORD   m_cItems;
00039     PSID    *m_pSidList;
00040 };
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 // CDBAuthPlugin
00044 class ATL_NO_VTABLE CDBAuthPlugin :
00045     public CComObjectRootEx<CComMultiThreadModel>,
00046     public CComCoClass<CDBAuthPlugin, &CLSID_DBAuthPlugin>,
00047     public IWMSEventAuthorizationPlugin,
00048     public IWMSBasicPlugin,
00049     public IDBAuthPlugin
00050 {
00051 public:
00052     CDBAuthPlugin();
00053     ~CDBAuthPlugin();
00054
00055 DECLARE_REGISTRY_RESOURCEID(IDR_DBAUTHPLUGIN)
00056
00057 DECLARE_PROTECT_FINAL_CONSTRUCT()
00058
00059 BEGIN_COM_MAP(CDBAuthPlugin)
00060         COM_INTERFACE_ENTRY(IWMSEventAuthorizationPlugin)
00061         COM_INTERFACE_ENTRY(IWMSBasicPlugin)
00062         COM_INTERFACE_ENTRY(IDBAuthPlugin)
00063 END_COM_MAP()
00064
00065 public:
00066     // IWMSBasicPlugin
00067     STDMETHOD( InitializePlugin )( IWMSContext *pServerContext, IWMSNamedValues *pNamedValues, IWMSClassObject *pClassFactory );
00068     STDMETHOD( OnHeartbeat )( );
00069     STDMETHOD( GetCustomAdminInterface )( IDispatch **ppValue );
00070     STDMETHOD( ShutdownPlugin )();
00071     STDMETHOD( EnablePlugin ) ( long *pdwFlags, long *pdwHeartbeatPeriod );
00072     STDMETHOD( DisablePlugin )();
00073
00074     // IWMSEventAuthorizationPlugin
00075     STDMETHOD( GetAuthorizedEvents )( VARIANT *pvarAuthorizedEvents );
00076     STDMETHOD( AuthorizeEvent )( WMS_EVENT *pEvent, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx, IWMSEventAuthorizationCallback *pCallback, VARIANT Context );
00077
00078     HRESULT AddUser( LPCWSTR pwszUserName );
00079     HRESULT RemoveUser( LPCWSTR pwszUserName );
00080     HRESULT VerifyUserMembership( LPCWSTR pwszUserName, BOOL *pfFound, DWORD *pdwIndex );
00081     HRESULT GetUsers( BSTR *pbstrUserNames );
00082
00083 private:
00084     // Authorization Helper Functions
00085     HRESULT OnAuthorizeOpen ( IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx );
00086
00087     // Private Member Functions
00088     HRESULT CreateArrayOfEvents ( VARIANT *pvarEvents, WMS_EVENT_TYPE *pWMSEvents, long nNumEvents);
00089
00090     BOOL VerifySidMembership( PSID pSid, DWORD *pdwIndex );
00091     void Lock();
00092     void Unlock();
00093     HRESULT GetSIDFromName( LPCWSTR pwszUserName, PSID *ppSid );
00094
00095 private:
00096     // Private Member Variables
00097     CComPtr<IWMSServer>         m_spServer;
00098     CComPtr<IWMSNamedValues>    m_spNamedValues;
00099     CSids                       *m_pSids;
00100     CRITICAL_SECTION            m_CritSec;
00101 };
00102
00103
00104 #endif // !defined(AFX_DBAUTHPLUGIN_H__7F3F40ED_1634_4AB8_B2C8_1686B8BFC93A__INCLUDED_)
00105
00106
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/DataSource/sdksamplestorageplugin.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • DataSource

sdksamplestorageplugin.cpp

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName:            SDKSampleStoragePlugin.cpp
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011
00012 #include "stdafx.h"
00013 #include "resource.h"
00014 #include <initguid.h>
00015 #include "SDKSampleStoragePlugin.h"
00016 #include "SDKSampleStorageSystem.h"
00017
00018 #ifdef _MERGE_PROXYSTUB
00019 extern "C" HINSTANCE hProxyDll;
00020 #endif
00021
00022 CComModule _Module;
00023
00024 BEGIN_OBJECT_MAP(ObjectMap)
00025 OBJECT_ENTRY(CLSID_SDKSampleStorageSystem, CSDKSampleStorageSystem)
00026 END_OBJECT_MAP()
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // DLL Entry Point
00030
00031 extern "C"
00032 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00033 {
00034     lpReserved;
00035 #ifdef _MERGE_PROXYSTUB
00036     if (!PrxDllMain(hInstance, dwReason, lpReserved))
00037         return FALSE;
00038 #endif
00039     if (dwReason == DLL_PROCESS_ATTACH)
00040     {
00041         _Module.Init(ObjectMap, hInstance, &LIBID_SDKSAMPLESTORAGEPLUGINLib);
00042         DisableThreadLibraryCalls(hInstance);
00043     }
00044     else if (dwReason == DLL_PROCESS_DETACH)
00045         _Module.Term();
00046     return TRUE;    // ok
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // Used to determine whether the DLL can be unloaded by OLE
00051
00052 STDAPI DllCanUnloadNow(void)
00053 {
00054 #ifdef _MERGE_PROXYSTUB
00055     if (PrxDllCanUnloadNow() != S_OK)
00056         return S_FALSE;
00057 #endif
00058     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00059 }
00060
00061 /////////////////////////////////////////////////////////////////////////////
00062 // Returns a class factory to create an object of the requested type
00063
00064 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00065 {
00066 #ifdef _MERGE_PROXYSTUB
00067     if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00068         return S_OK;
00069 #endif
00070     return _Module.GetClassObject(rclsid, riid, ppv);
00071 }
00072
00073 /////////////////////////////////////////////////////////////////////////////
00074 // DllRegisterServer - Adds entries to the system registry
00075
00076 STDAPI DllRegisterServer(void)
00077 {
00078 #ifdef _MERGE_PROXYSTUB
00079     HRESULT hRes = PrxDllRegisterServer();
00080     if (FAILED(hRes))
00081         return hRes;
00082 #endif
00083     // registers object, typelib and all interfaces in typelib
00084     return _Module.RegisterServer(TRUE);
00085 }
00086
00087 /////////////////////////////////////////////////////////////////////////////
00088 // DllUnregisterServer - Removes entries from the system registry
00089
00090 STDAPI DllUnregisterServer(void)
00091 {
00092 #ifdef _MERGE_PROXYSTUB
00093     PrxDllUnregisterServer();
00094 #endif
00095     return _Module.UnregisterServer(TRUE);
00096 }
00097
00098
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/x224.h Source File

  • Web
  • NetMeeting
  • PlugTransport

x224.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     PLUGTRANSPORT.EXE
00003 //  File:       X224.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015
00016
00017 #ifndef _X224_H_
00018 #define _X224_H_
00019
00020 #define MAXHOSTNAMELENGTH   64
00021
00022 class CX224
00023 {
00024 private:
00025   SOCKET  m_hListenSocket;
00026   TCHAR   m_szHostName[MAXHOSTNAMELENGTH];
00027   SOCKET  m_hSocket;
00028 public:
00029   CX224::CX224(void);
00030   CX224::~CX224(void);
00031   HRESULT CreateListenSocket(HWND hwnd);
00032   HRESULT CreateConnectSocket(HWND hwnd, LPSTR pszHostName);
00033   HRESULT CX224::CreateAcceptSocket(HWND hWnd);
00034   LPSTR   SetAndGetHostName();
00035   HRESULT CloseSocket();
00036   HRESULT CloseListenSocket();
00037   SOCKET  GetSocket();
00038 };
00039
00040 #endif  // _X224_H_
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step1/HelloWorld.h Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step1

HelloWorld.h

Go to the documentation of this file.
00001 // HelloWorld.h: Definition of the HelloWorld class
00002 //
00003 //////////////////////////////////////////////////////////////////////
00004
00005 #if !defined(AFX_HELLOWORLD_H__E1E3EDF9_48D1_11D2_B22B_0000F87A6B50__INCLUDED_)
00006 #define AFX_HELLOWORLD_H__E1E3EDF9_48D1_11D2_B22B_0000F87A6B50__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #include "resource.h"       // main symbols
00013
00014 /////////////////////////////////////////////////////////////////////////////
00015 // HelloWorld
00016
00017 class HelloWorld :
00018   public IDispatchImpl<IHelloWorld, &IID_IHelloWorld, &LIBID_ADSFIRSTEXTLib>,
00019   public ISupportErrorInfo,
00020   public CComObjectRoot,
00021   public CComCoClass<HelloWorld,&CLSID_HelloWorld>
00022 {
00023 public:
00024   HelloWorld() {}
00025 BEGIN_COM_MAP(HelloWorld)
00026   COM_INTERFACE_ENTRY(IDispatch)
00027   COM_INTERFACE_ENTRY(IHelloWorld)
00028   COM_INTERFACE_ENTRY(ISupportErrorInfo)
00029 END_COM_MAP()
00030 //DECLARE_NOT_AGGREGATABLE(HelloWorld)
00031 // Remove the comment from the line above if you don't want your object to
00032 // support aggregation.
00033
00034 DECLARE_REGISTRY_RESOURCEID(IDR_HelloWorld)
00035 // ISupportsErrorInfo
00036   STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00037
00038 // IHelloWorld
00039 public:
00040   STDMETHOD(Say)();
00041 };
00042
00043 #endif // !defined(AFX_HELLOWORLD_H__E1E3EDF9_48D1_11D2_B22B_0000F87A6B50__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/basesnap.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

basesnap.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  Abstract: This module provides the basic COM and DLL methods to create
00015 //            and load the Snap-in.  IClassFactory::CreateInstance creates
00016 //            an instance of a class whose type is passed in the constructor
00017 //
00018
00019
00020 #ifndef _BASESNAP_H_
00021 #define _BASESNAP_H_
00022
00023 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppvObj);
00024 STDAPI DllCanUnloadNow(void);
00025
00026 //---------------------------------------------------------------------------
00027 class CClassFactory : public IClassFactory
00028 {
00029   public:
00030     enum FACTORY_TYPE {COMPONENTDATA = 0, ABOUT = 1};
00031
00032   public:
00033     CClassFactory(FACTORY_TYPE eFactoryType);
00034     ~CClassFactory();
00035
00036     STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv);
00037     STDMETHODIMP_(ULONG) AddRef();
00038     STDMETHODIMP_(ULONG) Release();
00039
00040     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
00041     STDMETHODIMP LockServer(BOOL);
00042
00043   private:
00044     ULONG         m_cRef;
00045     FACTORY_TYPE  m_FactoryType;
00046
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/ADDFolderdlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

ADDFolderdlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddDeviceDlg.cpp:  Implementation of the CAddDeviceDlg class.
00015 //
00016
00017
00018
00019 #include "AddFolderDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddFolderDlg::CAddFolderDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddFolderDlg::~CAddFolderDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddFolderDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hFldrNameCtrl = GetDlgItem( hDlg, IDC_FLDRNAME_EDIT );
00055
00056   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00057   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00060
00061   lResult = SetWindowText( hFldrNameCtrl, _T("") );
00062   SetFocus( hFldrNameCtrl );
00063
00064   return 0;
00065 }
00066
00067 //---------------------------------------------------------------------------
00068 LRESULT CAddFolderDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00069 {
00070   LRESULT          lResult = 0;
00071   NODE_PROPERTIES  NodeProps;
00072
00073   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00074
00075   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00076   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00077   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00078   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00079   HWND hFldrNameCtrl = GetDlgItem( hDlg, IDC_FLDRNAME_EDIT );
00080
00081   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00082     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00083
00084   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00086
00087   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00089
00090   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00092
00093   // Convert to wide characters here for all platforms.  This is the node name
00094   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00095   GetWindowText( hFldrNameCtrl, szBuff, MAX_NAME_LEN );
00096   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00097   // Probably a good idea to check for NULL name strings here
00098
00099   // This message passes the user supplied info to the Static Node
00100   SendMessage( m_hParentWnd, WM_ADDNEW_NODE, (WPARAM)&NodeProps, 0 );
00101
00102   // Now tell the parent node we are deleting ourselves so the
00103   // context menu option can be enabled
00104   SendMessage( m_hParentWnd, WM_DIALOG_CLOSED, 0, 0 );
00105
00106   // Call the base class to shut down the dialog
00107   CBaseDialog::OnOK( hDlg, wParam, lParam );
00108   return 0;
00109 }
00110
00111 /////////////////////////////////////////////////////////////////////////////
00112 //  Virtual function implementations
00113
00114 //---------------------------------------------------------------------------
00115 BOOL CAddFolderDlg::ProcessMessage
00116 (
00117   HWND     hDlg,           //[in] Handle to dialog box
00118   UINT     uMsg,           //[in] Message
00119   WPARAM   wParam,         //[in] First message parameter
00120   LPARAM   lParam          //[in] Second message parameter
00121 )
00122 {
00123   LRESULT lResult = 0;
00124
00125   switch( uMsg )
00126   {
00127     case WM_INITDIALOG:
00128       lResult = OnInitDialog( hDlg, wParam, lParam );
00129       break;
00130
00131     case WM_DESTROY:
00132       lResult = OnDestroy( hDlg, wParam, lParam );
00133       break;
00134
00135     case WM_NCDESTROY:
00136       lResult = OnNcDestroy( hDlg, wParam, lParam );
00137       break;
00138
00139     case WM_CLOSE:
00140       // Not overriding WM_CLOSE and IDCANCEL so we must send
00141       // WM_DIALOG_CLOSED before calling the base class or else
00142       // the context menu will stay grayed
00143       SendMessage( m_hParentWnd, WM_DIALOG_CLOSED, 0, 0 );
00144       lResult = OnClose( hDlg, wParam, lParam );
00145       break;
00146
00147     case WM_COMMAND:
00148       switch( wParam )
00149       {
00150         case IDOK:
00151           lResult = OnOK( hDlg, wParam, lParam );
00152           break;
00153
00154         case IDCANCEL:
00155           SendMessage( m_hParentWnd, WM_DIALOG_CLOSED, 0, 0 );
00156           lResult = OnCancel( hDlg, wParam, lParam );
00157           break;
00158
00159         default:
00160           break;
00161       }
00162     default:
00163       break;
00164   }
00165   return (BOOL)lResult;
00166 }
00167
00168
00169
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/globals.h Source File

  • SysMgmt
  • MMC
  • Multisel

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <mmc.h>
00023 #include <tchar.h>
00024
00025 #ifndef STRINGS_ONLY
00026
00027     enum UPDATE_VIEWS_HINT {UPDATE_SCOPEITEM = 1000, DELETE_SCOPEITEM, UPDATE_RESULTITEM, DELETE_RESULTITEM};
00028     enum ITEM_TYPE {SCOPE = 10, RESULT};
00029
00030         #define IDM_BUTTON1    0x100
00031         #define IDM_BUTTON2    0x101
00032
00033         extern HINSTANCE g_hinst;
00034         extern ULONG g_uObjects;
00035
00036         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00037         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00038
00039         // uncomment the following #define to enable message cracking
00040         // #define MMC_CRACK_MESSAGES
00041         void MMCN_Crack(BOOL bComponentData,
00042                                         IDataObject *pDataObject,
00043                                         IComponentData *pCompData,
00044                                         IComponent *pComp,
00045                                         MMC_NOTIFY_TYPE event,
00046                                         LPARAM arg,
00047                                         LPARAM param);
00048 #endif
00049
00050 //=--------------------------------------------------------------------------=
00051 // allocates a temporary buffer that will disappear when it goes out of scope
00052 // NOTE: be careful of that -- make sure you use the string in the same or
00053 // nested scope in which you created this buffer. people should not use this
00054 // class directly.  use the macro(s) below.
00055 //
00056 class TempBuffer {
00057   public:
00058     TempBuffer(ULONG cBytes) {
00059         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00060         m_fHeapAlloc = (cBytes > 120);
00061     }
00062     ~TempBuffer() {
00063         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00064     }
00065     void *GetBuffer() {
00066         return m_pBuf;
00067     }
00068
00069   private:
00070     void *m_pBuf;
00071     // we'll use this temp buffer for small cases.
00072     //
00073     char  m_szTmpBuf[120];
00074     unsigned m_fHeapAlloc:1;
00075 };
00076
00077 //=--------------------------------------------------------------------------=
00078 // string helpers.
00079 //
00080 // given a _TCHAR, copy it into a wide buffer.
00081 // be careful about scoping when using this macro!
00082 //
00083 // how to use the below two macros:
00084 //
00085 //  ...
00086 //  LPTSTR pszT;
00087 //  pszT = MyGetTStringRoutine();
00088 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00089 //  MyUseWideStringRoutine(pwsz);
00090 //  ...
00091 #ifdef UNICODE
00092 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00093     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00094     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00095     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00096     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00097 #else // ANSI
00098 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00099     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00100     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00101     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00102     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00103     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00104 #endif
00105
00106 #ifdef UNICODE
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00109     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00110     lstrcpyW((LPWSTR)ptrname, tstr)
00111 #else // ANSI
00112 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00113     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00114     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00115     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00116     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00117 #endif
00118
00119 //
00120 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00121 // have to be declared, and no clean up must be done.
00122 //
00123 // * 2 for DBCS handling in below length computation
00124 //
00125 #ifdef UNICODE
00126 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00127     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00128     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00129     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00130     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00131 #else // ANSI
00132 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00133     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00134     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00135     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00136     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00137 #endif
00138
00139 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tpc_hdr Member List

This is the complete list of members for tpc_hdr, including all inherited members.
ack_num | tpc_hdr
dest_portno | tpc_hdr
lenflags | tpc_hdr
seq_num | tpc_hdr
src_portno | tpc_hdr
tcp_checksum | tpc_hdr
tcp_urgentptr | tpc_hdr
window_size | tpc_hdr
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/PerfDllS/PerfGen/Perfmsg.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • PerfDllS
  • PerfGen

Perfmsg.h

Go to the documentation of this file.
00001 /*++ BUILD Version: 0001    // Increment this if a change has global effects
00002
00003 Copyright 1995 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     perfmsg.h
00008
00009 Abstract:
00010
00011     This file provides the macros and definitions used by the extensible
00012     counters for reporting events to the event logging facility
00013
00014 Author:
00015
00016     Bob Watson  28-Jul-1995
00017
00018 Revision History:
00019
00020
00021 --*/
00022 #ifndef  _PERFMSG_H_
00023 #define  _PERFMSG_H_
00024 //
00025 // Report error message ID's for Counters
00026 //
00027
00028 #define APP_NAME  "perfgen"
00029
00030 //
00031 // The constant below defines how many (if any) messages will be reported
00032 // to the event logger. As the number goes up in value more and more events
00033 // will be reported. The purpose of this is to allow lots of messages during
00034 // development and debugging (e.g. a message level of 3) to a minimum of
00035 // messages (e.g. operational messages with a level of 1) or no messages if
00036 // message logging inflicts too much of a performance penalty. Right now
00037 // this is a compile time constant, but could later become a registry entry.
00038 //
00039 //    Levels:  LOG_NONE = No event log messages ever
00040 //             LOG_USER = User event log messages (e.g. errors)
00041 //             LOG_DEBUG = Minimum Debugging
00042 //             LOG_VERBOSE = Maximum Debugging
00043 //
00044
00045 #define  LOG_NONE     0
00046 #define  LOG_USER     1
00047 #define  LOG_DEBUG    2
00048 #define  LOG_VERBOSE  3
00049
00050 #define  MESSAGE_LEVEL_DEFAULT  LOG_USER
00051
00052 // define macros
00053 //
00054 // Format for event log calls without corresponding insertion strings is:
00055 //    REPORT_xxx (message_value, message_level)
00056 //       where:
00057 //          xxx is the severity to be displayed in the event log
00058 //          message_value is the numeric ID from above
00059 //          message_level is the "filtering" level of error reporting
00060 //             using the error levels above.
00061 //
00062 // if the message has a corresponding insertion string whose symbol conforms
00063 // to the format CONSTANT = numeric value and CONSTANT_S = string constant for
00064 // that message, then the
00065 //
00066 //    REPORT_xxx_STRING (message_value, message_level)
00067 //
00068 // macro may be used.
00069 //
00070
00071 //
00072 // REPORT_SUCCESS was intended to show Success in the error log, rather it
00073 // shows "N/A" so for now it's the same as information, though it could
00074 // (should) be changed  in the future
00075 //
00076
00077
00078 #define REPORT_SUCCESS(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_INFORMATION_TYPE, \
00079    0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
00080
00081 #define REPORT_INFORMATION(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_INFORMATION_TYPE, \
00082    0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
00083
00084 #define REPORT_WARNING(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_WARNING_TYPE, \
00085    0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
00086
00087 #define REPORT_ERROR(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_ERROR_TYPE, \
00088    0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
00089
00090 #define REPORT_INFORMATION_DATA(i,l,d,s) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_INFORMATION_TYPE, \
00091    0, i, (PSID)NULL, 0, s, NULL, (PVOID)(d)) : FALSE)
00092
00093 #define REPORT_WARNING_DATA(i,l,d,s) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_WARNING_TYPE, \
00094    0, i, (PSID)NULL, 0, s, NULL, (PVOID)(d)) : FALSE)
00095
00096 #define REPORT_ERROR_DATA(i,l,d,s) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_ERROR_TYPE, \
00097    0, i, (PSID)NULL, 0, s, NULL, (PVOID)(d)) : FALSE)
00098
00099 // External Variables
00100
00101 extern HANDLE hEventLog;   // handle to event log
00102 extern DWORD  dwLogUsers;  // counter of event log using routines
00103 extern DWORD  MESSAGE_LEVEL; // event logging detail level
00104
00105 #endif //_PERFMSG_H_
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

UsageStringInfo Member List

This is the complete list of members for UsageStringInfo, including all inherited members.
m_cIndent | UsageStringInfo
m_fExternalOnly | UsageStringInfo
m_fInternalOnly | UsageStringInfo
m_ids | UsageStringInfo
Generated on Wed Nov 13 2024 16:58:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/StdAfx.h Source File

  • Com
  • Services
  • Concurrency
  • SyncComp

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__247FF7E1_F38D_11D2_A10A_0080C71F306F__INCLUDED_)
00006 #define AFX_STDAFX_H__247FF7E1_F38D_11D2_A10A_0080C71F306F__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016
00017 #include <atlbase.h>
00018 extern CComModule       _Module;
00019 extern IGlobalInterfaceTable*   g_pGIT;
00020
00021 #include <atlcom.h>
00022 #include <atlwin.h>
00023 #include <stdio.h>
00024
00025 //{{AFX_INSERT_LOCATION}}
00026 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00027
00028 #endif // !defined(AFX_STDAFX_H__247FF7E1_F38D_11D2_A10A_0080C71F306F__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/cpack.h Source File

  • Web
  • bits
  • Upload

cpack.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  cpack.h
00011 //
00012 //  Purpose:
00013 //  Defines the class CPack, used to pack the user's input as an XML file
00014 //  and upload it using BITS.
00015 //
00016 //----------------------------------------------------------------------------
00017
00018
00019 #pragma once
00020
00021
00022 class CPack
00023 {
00024     WCHAR   m_wszTempFile[MAX_PATH+1];
00025     WCHAR  *m_pwszFilename;
00026     HANDLE  m_hFile;
00027
00028     HRESULT OpenTempFile();
00029     void    CloseTempFile();
00030
00031     HRESULT WriteWCharAsUTF8(LPCWSTR wszText, DWORD cCharsToWrite);
00032     HRESULT WriteWCharAsUTF8(LPCWSTR wszText);
00033     HRESULT WriteXMLString(LPCWSTR wszText);
00034
00035     HRESULT BuildRemoteUrl(IN LPCWSTR wszUploadDir, IN LPCWSTR wszTempFile, OUT WCHAR *wszRemoteUrl, DWORD cbRemoteUrl);
00036
00037 public:
00038
00039     CPack();
00040     ~CPack();
00041
00042     HRESULT  PackText(LPCWSTR wszText);
00043     LPCWSTR  GetFileName();
00044     HRESULT  Upload(LPCWSTR wszJobName, LPCWSTR wszRemoteFile, BOOL fRequireUploadReply);
00045 };
00046
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Proppage

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RecordsetVtbl Member List

This is the complete list of members for _RecordsetVtbl, including all inherited members.
ActiveConnection | _RecordsetVtbl
AffectRecords | _RecordsetVtbl
bstrConn | _RecordsetVtbl
CacheSize | _RecordsetVtbl
cNames | _RecordsetVtbl
Criteria | _RecordsetVtbl
Criteria | _RecordsetVtbl
Criteria | _RecordsetVtbl
Criteria | _RecordsetVtbl
CursorOptions | _RecordsetVtbl
CursorType | _RecordsetVtbl
dispIdMember | _RecordsetVtbl
eMarshal | _RecordsetVtbl
FieldList | _RecordsetVtbl
Fields | _RecordsetVtbl
Fields | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Properties)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_AbsolutePosition)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_AbsolutePosition)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *putref_ActiveADOConnection)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_ActiveConnection)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_ActiveConnection)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_BOF)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Bookmark)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Bookmark)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CacheSize)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CacheSize)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CursorType)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CursorType)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_EOF)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Fields)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_LockType)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_LockType)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_MaxRecords)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_MaxRecords)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_RecordCount)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *putref_Source)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Source)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Source)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *AddNew)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *CancelUpdate)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Close)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Delete)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetRows)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Move)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *MoveNext)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *MovePrevious)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *MoveFirst)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *MoveLast)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Open)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Requery)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Resync)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Update)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_AbsolutePage)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_AbsolutePage)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_EditMode)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Filter)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Filter)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_PageCount)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_PageSize)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_PageSize)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Sort)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Sort)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Status)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_State)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Clone)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *UpdateBatch)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *CancelBatch)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CursorLocation)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CursorLocation)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *NextADORecordset)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Cancel)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Supports)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Collect)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Collect)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_MarshalOptions)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_MarshalOptions)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Find)(_ADORecordset __RPC_FAR *This | _RecordsetVtbl
Index | _RecordsetVtbl
iTInfo | _RecordsetVtbl
lcid | _RecordsetVtbl
lcid | _RecordsetVtbl
lcid | _RecordsetVtbl
lCursorLoc | _RecordsetVtbl
lCursorType | _RecordsetVtbl
lLockType | _RecordsetVtbl
lMaxRecords | _RecordsetVtbl
LockType | _RecordsetVtbl
NumRecords | _RecordsetVtbl
Options | _RecordsetVtbl
Options | _RecordsetVtbl
Page | _RecordsetVtbl
PageSize | _RecordsetVtbl
pb | _RecordsetVtbl
pb | _RecordsetVtbl
pcmd | _RecordsetVtbl
pconn | _RecordsetVtbl
pctinfo | _RecordsetVtbl
pDispParams | _RecordsetVtbl
peMarshal | _RecordsetVtbl
pExcepInfo | _RecordsetVtbl
pl | _RecordsetVtbl
pl | _RecordsetVtbl
pl | _RecordsetVtbl
plCursorLoc | _RecordsetVtbl
plCursorType | _RecordsetVtbl
plLockType | _RecordsetVtbl
plMaxRecords | _RecordsetVtbl
plObjState | _RecordsetVtbl
Position | _RecordsetVtbl
ppiRs | _RecordsetVtbl
ppTInfo | _RecordsetVtbl
ppvObject | _RecordsetVtbl
ppvObject | _RecordsetVtbl
ppvObject | _RecordsetVtbl
ppvObject | _RecordsetVtbl
puArgErr | _RecordsetVtbl
pvar | _RecordsetVtbl
pvar | _RecordsetVtbl
pvar | _RecordsetVtbl
pVarResult | _RecordsetVtbl
pvBookmark | _RecordsetVtbl
pvSource | _RecordsetVtbl
RecordsAffected | _RecordsetVtbl
rgDispId | _RecordsetVtbl
rgszNames | _RecordsetVtbl
riid | _RecordsetVtbl
riid | _RecordsetVtbl
riid | _RecordsetVtbl
Rows | _RecordsetVtbl
SearchDirection | _RecordsetVtbl
SkipCurrent | _RecordsetVtbl
Source | _RecordsetVtbl
Start | _RecordsetVtbl
Start | _RecordsetVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(_ADORecordset __RPC_FAR *This) | _RecordsetVtbl
value | _RecordsetVtbl
Values | _RecordsetVtbl
vBookmark | _RecordsetVtbl
vConn | _RecordsetVtbl
wFlags | _RecordsetVtbl
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CLockHandler Member List

This is the complete list of members for CLockHandler, including all inherited members.
CLock | CLockHandler | [private]
CLockHandler() | CLockHandler |
GetLockThreadId() | CLockHandler | [inline]
Lock(DWORD dwThreadId) | CLockHandler |
m_CriticalSection | CLockHandler | [private]
m_dwLockThreadId | CLockHandler | [private]
UnLock() | CLockHandler |
~CLockHandler() | CLockHandler |
Generated on Wed Nov 13 2024 16:56:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/Server/Server.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • Server

Server.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: server.cpp
00004
00005 Summary:  Produced by VS6 ATL Wizard. Implements main module for server.exe.
00006           Handles class registration for implementations contained in server.exe.
00007
00008 ----------------------------------------------------------------------------
00009
00010 This file is part of the Microsoft COM+ Samples.
00011
00012 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00013
00014 This source code is intended only as a supplement to Microsoft
00015 Development Tools and/or on-line documentation. See these other
00016 materials for detailed information regarding Microsoft code samples.
00017
00018 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00019 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00021 PARTICULAR PURPOSE.
00022
00023 ==========================================================================+*/
00024 // server.cpp : Implementation of WinMain
00025
00026
00027 // Note: Proxy/Stub Information
00028 //    To build a separate proxy/stub DLL,
00029 //    run nmake -f serverps.mk in the project directory.
00030
00031 #include "stdafx.h"
00032 #include "resource.h"
00033 #include "initguid.h"
00034 #include "server.h"
00035
00036 #include "server_i.c"
00037 #include "MonitorServer.h"
00038
00039
00040 LONG CExeModule::Unlock()
00041 {
00042   LONG l = CComModule::Unlock();
00043   if (l == 0)
00044   {
00045 #if _WIN32_WINNT >= 0x0400
00046     if (CoSuspendClassObjects() == S_OK)
00047       PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00048 #else
00049     PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00050 #endif
00051   }
00052   return l;
00053 }
00054
00055 CExeModule _Module;
00056
00057 BEGIN_OBJECT_MAP(ObjectMap)
00058   OBJECT_ENTRY(CLSID_MonitorServer, CMonitorServer)
00059 END_OBJECT_MAP()
00060
00061
00062 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
00063 {
00064   while (*p1 != NULL)
00065   {
00066     LPCTSTR p = p2;
00067     while (*p != NULL)
00068     {
00069       if (*p1 == *p++)
00070         return p1+1;
00071     }
00072     p1++;
00073   }
00074   return NULL;
00075 }
00076
00077 /////////////////////////////////////////////////////////////////////////////
00078 //
00079 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00080   HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
00081 {
00082   lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
00083   HRESULT hRes = CoInitialize(NULL);
00084 //  If you are running on NT 4.0 or higher you can use the following call
00085 //  instead to make the EXE free threaded.
00086 //  This means that calls come in on a random RPC thread
00087 //  HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00088   _ASSERTE(SUCCEEDED(hRes));
00089   _Module.Init(ObjectMap, hInstance);
00090   _Module.dwThreadID = GetCurrentThreadId();
00091   TCHAR szTokens[] = _T("-/");
00092
00093   int nRet = 0;
00094   BOOL bRun = TRUE;
00095   LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
00096   while (lpszToken != NULL)
00097   {
00098     if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
00099     {
00100       _Module.UpdateRegistryFromResource(IDR_Server, FALSE);
00101       nRet = _Module.UnregisterServer();
00102       bRun = FALSE;
00103       break;
00104     }
00105     if (lstrcmpi(lpszToken, _T("RegServer"))==0)
00106     {
00107       _Module.UpdateRegistryFromResource(IDR_Server, TRUE);
00108       nRet = _Module.RegisterServer(TRUE);
00109       bRun = FALSE;
00110       break;
00111     }
00112     lpszToken = FindOneOf(lpszToken, szTokens);
00113   }
00114
00115   if (bRun)
00116   {
00117     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00118       REGCLS_MULTIPLEUSE);
00119     _ASSERTE(SUCCEEDED(hRes));
00120
00121     MSG msg;
00122     while (GetMessage(&msg, 0, 0, 0))
00123       DispatchMessage(&msg);
00124
00125     _Module.RevokeClassObjects();
00126   }
00127
00128   CoUninitialize();
00129   return nRet;
00130 }
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/iocp/IocpClient.Cpp Source File

  • NetDS
  • WinSock
  • iocp

IocpClient.Cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      iocpclient.cpp
00010 //
00011 // Abstract:
00012 //      Use the -? commandline switch to determine available options.
00013 //
00014 //      This application is a very simple minded program that sends buffers of
00015 //      data to a server and waits for the server to echo the data back and then
00016 //      compares the first and last byte of the buffers.  The destination server
00017 //      can be specified using the (-n) option and the destination port using the
00018 //      (-e) option.  The size of the buffer to send is specified using the (-b)
00019 //      option which is in 1k increments.  Multiple threads can be spawned to hit
00020 //      the server.
00021 //
00022 //      Please note that spawning multiple threads is not a scalable way
00023 //      to handle multiple socket connections.  This sample was built for the
00024 //      express purpose of providing a simple and easy to understand client to
00025 //      pound on the iocp socket server.
00026 //
00027 //      Another point worth noting is that the Win32 API CreateThread() does not
00028 //      initialize the C Runtime and therefore, C runtime functions such as
00029 //      printf() have been avoid or rewritten (see myprintf()) to use just Win32 APIs.
00030 //
00031 // Entry Points:
00032 //      main - this is where it all starts
00033 //
00034 // Build:
00035 //      Use the headers and libs from the Jan98 Platform SDK or later.
00036 //      Link with ws2_32.lib
00037 //
00038 //  Author: Wei Hua, Barry Butterklee - Microsoft Developer Support
00039 //
00040 //
00041
00042 #ifdef _IA64_
00043   #pragma warning(disable:4127 4706 4267)
00044 #endif
00045
00046 #include <stdlib.h>
00047 #include <stdio.h>
00048 #include <winsock2.h>
00049 #include <ws2tcpip.h>
00050
00051 #define MAXTHREADS 64
00052
00053 #define xmalloc(s) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(s))
00054 #define xfree(p)   HeapFree(GetProcessHeap(),0,(p))
00055
00056 typedef struct _OPTIONS {
00057   char szHostname[64];
00058   char *port;
00059   int nTotalThreads;
00060   int nBufSize;
00061   BOOL bVerbose;
00062 } OPTIONS;
00063
00064 typedef struct THREADINFO {
00065   HANDLE hThread[MAXTHREADS];
00066   SOCKET sd[MAXTHREADS];
00067 } THREADINFO;
00068
00069 static OPTIONS default_options = {"localhost", "5001", 1, 4096, FALSE};
00070 static OPTIONS g_Options;
00071 static THREADINFO g_ThreadInfo;
00072 static BOOL g_bEndClient = FALSE;
00073 static WSAEVENT g_hCleanupEvent[1];
00074
00075 static BOOL WINAPI CtrlHandler (DWORD dwEvent);
00076 static BOOL ValidOptions(char *argv[], int argc);
00077 static VOID Usage(char *szProgramname, OPTIONS *pOptions);
00078 static DWORD WINAPI EchoThread(LPVOID lpParameter);
00079 static BOOL CreateConnectedSocket(int nThreadNum);
00080 static BOOL SendBuffer(int nThreadNum, char *outbuf);
00081 static BOOL RecvBuffer(int nThreadNum, char *inbuf);
00082 static int myprintf(const char *lpFormat, ...);
00083
00084 int __cdecl main(int argc, char *argv[]) {
00085
00086   OSVERSIONINFO verInfo = {0};
00087   WSADATA WSAData;
00088   DWORD dwThreadId = 0;
00089   DWORD dwRet = 0;
00090   BOOL bInitError = FALSE;
00091   int nThreadNum[MAXTHREADS];
00092   int i = 0;
00093   int nRet = 0;
00094
00095   verInfo.dwOSVersionInfoSize = sizeof(verInfo);
00096   GetVersionEx(&verInfo);
00097   if( verInfo.dwPlatformId  == VER_PLATFORM_WIN32_WINDOWS ) {
00098
00099     //
00100     // Since this application can heavily stress system resources
00101     // we decided to limit running it on NT.
00102     //
00103     myprintf("Please run %s only on NT, thank you\n", argv[0]);
00104     return(0);
00105   }
00106
00107   for( i = 0; i < MAXTHREADS; i++ ) {
00108     g_ThreadInfo.sd[i] = INVALID_SOCKET;
00109     g_ThreadInfo.hThread[i] = INVALID_HANDLE_VALUE;
00110     nThreadNum[i] = 0;
00111   }
00112
00113   g_hCleanupEvent[0] = WSA_INVALID_EVENT;
00114
00115   if( !ValidOptions(argv, argc) )
00116     return(1);
00117
00118   if( (nRet = WSAStartup(MAKEWORD(2,2), &WSAData)) != 0 ) {
00119     myprintf("WSAStartup() failed: %d", nRet);
00120     return(1);
00121   }
00122
00123   g_hCleanupEvent[0] = WSACreateEvent();
00124   if( g_hCleanupEvent[0] == WSA_INVALID_EVENT ) {
00125     myprintf("WSACreateEvent() failed: %d\n", WSAGetLastError());
00126     WSACleanup();
00127     return(1);
00128   }
00129
00130   //
00131   // be able to gracefully handle CTRL-C and close handles
00132   //
00133   if( !SetConsoleCtrlHandler (CtrlHandler, TRUE) ) {
00134     myprintf("SetConsoleCtrlHandler() failed: %d\n", GetLastError());
00135     if( g_hCleanupEvent[0] != WSA_INVALID_EVENT ) {
00136       WSACloseEvent(g_hCleanupEvent[0]);
00137       g_hCleanupEvent[0] = WSA_INVALID_EVENT;
00138     }
00139     WSACleanup();
00140     return(1);
00141   }
00142
00143   //
00144   // spawn the threads
00145   //
00146   for( i = 0; i < g_Options.nTotalThreads && !bInitError; i++ ) {
00147
00148     //
00149     // if CTRL-C is pressed before all the sockets have connected, closure of
00150     // the program could take a little while, especially if the server is
00151     // down and we have to wait for connect to fail.  Checking for this
00152     // global flag allows us to shortcircuit that.
00153     //
00154     if( g_bEndClient )
00155       break;
00156     else if( CreateConnectedSocket(i) ) {
00157
00158       //
00159       // a unique memory location needs to be passed into each thread,
00160       // otherwise the value would change by the time all the threads
00161       // get a chance to run.
00162       //
00163       nThreadNum[i] = i;
00164       g_ThreadInfo.hThread[i] = CreateThread(NULL, 0, EchoThread, (LPVOID)&nThreadNum[i], 0, &dwThreadId);
00165       if( g_ThreadInfo.hThread[i] == NULL ) {
00166         myprintf("CreateThread(%d) failed: %d\n", i, GetLastError());
00167         bInitError = TRUE;
00168         break;
00169       }
00170     }
00171   }
00172
00173     if( !bInitError ) {
00174
00175     //
00176     // wait for the threads to exit
00177     //
00178     dwRet = WaitForMultipleObjects(g_Options.nTotalThreads, g_ThreadInfo.hThread, TRUE, INFINITE);
00179     if( dwRet == WAIT_FAILED )
00180       myprintf("WaitForMultipleObject(): %d\n", GetLastError());
00181   }
00182
00183     if( !GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0) ) {
00184     myprintf("GenerateConsoleCtrlEvent() failed: %d\n", GetLastError());
00185   };
00186
00187     if( WSAWaitForMultipleEvents(1, g_hCleanupEvent, TRUE, WSA_INFINITE, FALSE) == WSA_WAIT_FAILED ) {
00188     myprintf("WSAWaitForMultipleEvents() failed: %d\n", WSAGetLastError());
00189   };
00190
00191     if( g_hCleanupEvent[0] != WSA_INVALID_EVENT ) {
00192     WSACloseEvent(g_hCleanupEvent[0]);
00193     g_hCleanupEvent[0] = WSA_INVALID_EVENT;
00194   }
00195
00196   WSACleanup();
00197
00198   //
00199   // Restores default processing of CTRL signals.
00200   //
00201   SetConsoleCtrlHandler(CtrlHandler, FALSE);
00202   SetConsoleCtrlHandler(NULL, FALSE);
00203
00204   return(0);
00205 }
00206
00207 //
00208 // Abstract:
00209 //     This is the thread that continually sends and receives a specific size
00210 //     buffer to the server.  Upon receipt of the echo from the server, a
00211 //     simple check is performed to check the integrity of the transfer.
00212 //
00213 static DWORD WINAPI EchoThread(LPVOID lpParameter) {
00214
00215   char *inbuf  = NULL;
00216   char *outbuf = NULL;
00217   int *pArg = (int *)lpParameter;
00218   int nThreadNum = *pArg;
00219
00220   myprintf("Starting thread %d\n", nThreadNum);
00221
00222   if( (inbuf = (char *)xmalloc(g_Options.nBufSize)) &&
00223     (outbuf = (char *)xmalloc(g_Options.nBufSize) ) ) {
00224
00225     //
00226     // NOTE data possible data loss with INT conversion to BYTE
00227     //
00228     FillMemory(outbuf, g_Options.nBufSize, (BYTE)nThreadNum);
00229
00230     while( TRUE ) {
00231
00232       //
00233       // just continually send and wait for the server to echo the data
00234       // back.  Just do a simple minded comparison.
00235       //
00236       if( SendBuffer(nThreadNum, outbuf) &&
00237         RecvBuffer(nThreadNum, inbuf) ) {
00238         if( (inbuf[0] == outbuf[0]) &&
00239           (inbuf[g_Options.nBufSize-1] == outbuf[g_Options.nBufSize-1]) ) {
00240           if( g_Options.bVerbose )
00241             myprintf("ack(%d)\n", nThreadNum);
00242         } else {
00243           myprintf("nak(%d) in[0]=%d, out[0]=%d in[%d]=%d out[%d]%d\n",
00244                nThreadNum,
00245                inbuf[0], outbuf[0],
00246                g_Options.nBufSize-1, inbuf[g_Options.nBufSize-1],
00247                g_Options.nBufSize-1, outbuf[g_Options.nBufSize-1]);
00248           break;
00249         }
00250       } else
00251         break;
00252     }
00253   }
00254
00255   if( inbuf )
00256     xfree(inbuf);
00257   if( outbuf )
00258     xfree(outbuf);
00259
00260   return(TRUE);
00261 }
00262
00263 //
00264 // Abstract:
00265 //     Create a socket and connect to the server process.
00266 //
00267 static BOOL CreateConnectedSocket(int nThreadNum) {
00268
00269   BOOL bRet = TRUE;
00270   int nRet = 0;
00271   struct addrinfo hints;
00272   struct addrinfo *addr_srv = NULL;
00273
00274   //
00275   // Resolve the interface
00276   //
00277   memset(&hints, 0, sizeof(hints));
00278   hints.ai_flags  = 0;
00279   hints.ai_family = AF_INET;
00280   hints.ai_socktype = SOCK_STREAM;
00281   hints.ai_protocol = IPPROTO_TCP;
00282
00283   if( getaddrinfo(g_Options.szHostname, g_Options.port, &hints, &addr_srv) != 0 ) {
00284     myprintf("getaddrinfo() failed with error %d\n", WSAGetLastError());
00285     bRet = FALSE;
00286   }
00287
00288   if( addr_srv == NULL ) {
00289     myprintf("getaddrinfo() failed to resolve/convert the interface\n");
00290     bRet = FALSE;
00291   } else {
00292     g_ThreadInfo.sd[nThreadNum] = socket(addr_srv->ai_family, addr_srv->ai_socktype, addr_srv->ai_protocol);
00293     if( g_ThreadInfo.sd[nThreadNum] == INVALID_SOCKET ) {
00294       myprintf("socket() failed: %d\n", WSAGetLastError());
00295       bRet = FALSE;
00296     }
00297   }
00298
00299   if( bRet != FALSE ) {
00300     nRet = connect(g_ThreadInfo.sd[nThreadNum], addr_srv->ai_addr, addr_srv->ai_addrlen);
00301     if( nRet == SOCKET_ERROR ) {
00302       myprintf("connect(thread %d) failed: %d\n", nThreadNum, WSAGetLastError());
00303       bRet = FALSE;
00304     } else
00305       myprintf("connected(thread %d)\n", nThreadNum);
00306
00307     freeaddrinfo(addr_srv);
00308   }
00309
00310   return(bRet);
00311 }
00312
00313 //
00314 // Abstract:
00315 //     Send a buffer - keep send'ing until the requested amount of
00316 //     data has been sent or the socket has been closed or error.
00317 //
00318 static BOOL SendBuffer(int nThreadNum, char *outbuf) {
00319
00320   BOOL bRet = TRUE;
00321   char *bufp = outbuf;
00322   int nTotalSend = 0;
00323   int nSend = 0;
00324
00325   while( nTotalSend < g_Options.nBufSize ) {
00326     nSend = send(g_ThreadInfo.sd[nThreadNum], bufp, g_Options.nBufSize - nTotalSend, 0);
00327     if( nSend == SOCKET_ERROR ) {
00328       myprintf("send(thread=%d) failed: %d\n", nThreadNum, WSAGetLastError());
00329       bRet = FALSE;
00330       break;
00331     } else if( nSend == 0 ) {
00332       myprintf("connection closed\n");
00333       bRet = FALSE;
00334       break;
00335     } else {
00336       nTotalSend += nSend;
00337       bufp += nSend;
00338     }
00339   }
00340
00341   return(bRet);
00342 }
00343
00344 //
00345 // Abstract:
00346 //     Receive a buffer - keep recv'ing until the requested amount of
00347 //     data has been received or the socket has been closed or error.
00348 //
00349 static BOOL RecvBuffer(int nThreadNum, char *inbuf) {
00350
00351   BOOL bRet = TRUE;
00352   char *bufp = inbuf;
00353   int nTotalRecv = 0;
00354   int nRecv = 0;
00355
00356   while( nTotalRecv < g_Options.nBufSize ) {
00357     nRecv = recv(g_ThreadInfo.sd[nThreadNum], bufp, g_Options.nBufSize - nTotalRecv, 0);
00358     if( nRecv == SOCKET_ERROR ) {
00359       myprintf("recv(thread=%d) failed: %d\n", nThreadNum, WSAGetLastError());
00360       bRet = FALSE;
00361       break;
00362     } else if( nRecv == 0 ) {
00363       myprintf("connection closed\n");
00364       bRet = FALSE;
00365       break;
00366     } else {
00367       nTotalRecv += nRecv;
00368       bufp += nRecv;
00369     }
00370   }
00371
00372   return(bRet);
00373 }
00374
00375 //
00376 // Abstract:
00377 //      Verify options passed in and set options structure accordingly.
00378 //
00379 static BOOL ValidOptions(char *argv[], int argc) {
00380
00381   g_Options = default_options;
00382
00383   for( int i=1; i<argc; i++ ) {
00384     if( (argv[i][0] == '-') || (argv[i][0] == '/') ) {
00385       switch( tolower(argv[i][1]) ) {
00386       case 'b' :
00387         if( lstrlen(argv[i]) > 3 )
00388           g_Options.nBufSize = 1024*atoi(&argv[i][3]);
00389         break;
00390
00391       case 'e' :
00392         if( lstrlen(argv[i]) > 3 )
00393           g_Options.port = &argv[i][3];
00394         break;
00395
00396       case 'n' :
00397         if( lstrlen(argv[i]) > 3 )
00398           lstrcpy(g_Options.szHostname, &argv[i][3]);
00399         break;
00400
00401       case 't' :
00402         if( lstrlen(argv[i]) > 3 )
00403           g_Options.nTotalThreads = min(MAXTHREADS, atoi(&argv[i][3]));
00404         break;
00405
00406       case 'v' :
00407         g_Options.bVerbose = TRUE;
00408         break;
00409
00410       case '?' :
00411         Usage(argv[0], &default_options);
00412         return(FALSE);
00413         break;
00414
00415       default:
00416         myprintf("  unknown options flag %s\n", argv[i]);
00417         Usage(argv[0], &default_options);
00418         return(FALSE);
00419         break;
00420       }
00421     } else {
00422       myprintf("  unknown option %s\n", argv[i]);
00423       Usage(argv[0], &default_options);
00424       return(FALSE);
00425     }
00426   }
00427
00428   return(TRUE);
00429 }
00430
00431 //
00432 // Abstract:
00433 //      Print out usage table for the program
00434 //
00435 static VOID Usage(char *szProgramname, OPTIONS *pOptions) {
00436
00437   myprintf("usage:\n%s [-b:#] [-e:#] [-n:host] [-t:#] [-v]\n",
00438        szProgramname);
00439   myprintf("%s -?\n", szProgramname);
00440   myprintf("  -?\t\tDisplay this help\n");
00441   myprintf("  -b:bufsize\tSize of send/recv buffer; in 1K increments (Def:%d)\n",
00442        pOptions->nBufSize);
00443   myprintf("  -e:port\tEndpoint number (port) to use (Def:%d)\n",
00444        pOptions->port);
00445   myprintf("  -n:host\tAct as the client and connect to 'host' (Def:%s)\n",
00446        pOptions->szHostname);
00447   myprintf("  -t:#\tNumber of threads to use\n");
00448   myprintf("  -v\t\tVerbose, print an ack when echo received and verified\n");
00449   return;
00450 }
00451
00452 static BOOL WINAPI CtrlHandler (DWORD dwEvent) {
00453
00454   int i = 0;
00455   DWORD dwRet = 0;
00456
00457   switch( dwEvent ) {
00458   case CTRL_C_EVENT:
00459   case CTRL_BREAK_EVENT:
00460   case CTRL_LOGOFF_EVENT:
00461   case CTRL_SHUTDOWN_EVENT:
00462   case CTRL_CLOSE_EVENT:
00463
00464     myprintf("Closing handles and sockets\n");
00465
00466     //
00467     // Temporarily disables processing of CTRL_C_EVENT signal.
00468     //
00469     SetConsoleCtrlHandler(NULL, TRUE);
00470
00471     g_bEndClient = TRUE;
00472
00473     for( i = 0; i < g_Options.nTotalThreads; i++ ) {
00474       if( g_ThreadInfo.sd[i] != INVALID_SOCKET ) {
00475
00476         //
00477         // force the subsequent closesocket to be abortative.
00478         //
00479         LINGER  lingerStruct;
00480
00481         lingerStruct.l_onoff = 1;
00482         lingerStruct.l_linger = 0;
00483         setsockopt(g_ThreadInfo.sd[i], SOL_SOCKET, SO_LINGER,
00484                (char *)&lingerStruct, sizeof(lingerStruct));
00485         closesocket(g_ThreadInfo.sd[i]);
00486         g_ThreadInfo.sd[i] = INVALID_SOCKET;
00487
00488         if( g_ThreadInfo.hThread[i] != INVALID_HANDLE_VALUE ) {
00489
00490           dwRet = WaitForSingleObject(g_ThreadInfo.hThread[i], INFINITE);
00491           if( dwRet == WAIT_FAILED )
00492             myprintf("WaitForSingleObject(): %d\n", GetLastError());
00493
00494           CloseHandle(g_ThreadInfo.hThread[i]);
00495           g_ThreadInfo.hThread[i] = INVALID_HANDLE_VALUE;
00496         }
00497       }
00498     }
00499
00500     break;
00501
00502   default:
00503
00504     //
00505     // unknown type--better pass it on.
00506     //
00507     return(FALSE);
00508   }
00509
00510   WSASetEvent(g_hCleanupEvent[0]);
00511
00512   return(TRUE);
00513 }
00514
00515 static int myprintf (const char *lpFormat, ... ) {
00516
00517   int nLen = 0;
00518   int nRet = 0;
00519   char cBuffer[512] ;
00520   va_list arglist ;
00521   HANDLE hOut = NULL;
00522
00523   ZeroMemory(cBuffer, sizeof(cBuffer));
00524
00525   va_start(arglist, lpFormat);
00526
00527   nLen = lstrlen( lpFormat ) ;
00528   nRet = wvsprintf( cBuffer, lpFormat, arglist );
00529
00530   if( nRet >= nLen || GetLastError() == 0 ) {
00531     hOut = GetStdHandle(STD_OUTPUT_HANDLE) ;
00532     if( hOut != INVALID_HANDLE_VALUE )
00533       WriteConsole( hOut, cBuffer, lstrlen(cBuffer), (LPDWORD)&nLen, NULL ) ;
00534   }
00535
00536   return nLen ;
00537 }
00538
00539
00540
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/ImageTag.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

ImageTag.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       imagetag.cxx
00006 //
00007 //  Contents:   Parsing algorithm for image tag in Html
00008 //
00009 //  Classes:    CImageTag
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <imagetag.hxx>
00017 #include <htmlguid.hxx>
00018 #include <ntquery.h>
00019
00020 //+-------------------------------------------------------------------------
00021 //
00022 //  Method:     CImageTag::CImageTag
00023 //
00024 //  Synopsis:   Constructor
00025 //
00026 //  Arguments:  [htmlIFilter]    -- Html IFilter
00027 //              [serialStream]   -- Input stream
00028 //
00029 //--------------------------------------------------------------------------
00030
00031 CImageTag::CImageTag( CHtmlIFilter& htmlIFilter,
00032                       CSerialStream& serialStream )
00033     : CHtmlElement(htmlIFilter, serialStream),
00034       _pwcValueBuf(0),
00035       _cValueChars(0),
00036       _cValueCharsFiltered(0)
00037 {
00038 }
00039
00040
00041
00042 //+-------------------------------------------------------------------------
00043 //
00044 //  Method:     CImageTag::GetChunk
00045 //
00046 //  Synopsis:   Gets the next chunk and returns chunk information in pStat
00047 //
00048 //  Arguments:  [pStat] -- chunk information returned here
00049 //
00050 //--------------------------------------------------------------------------
00051
00052 SCODE CImageTag::GetChunk( STAT_CHUNK * pStat )
00053 {
00054     SCODE sc = SwitchToNextHtmlElement( pStat );
00055
00056     return sc;
00057 }
00058
00059
00060
00061 //+-------------------------------------------------------------------------
00062 //
00063 //  Method:     CImageTag::GetText
00064 //
00065 //  Synopsis:   Retrieves text from current chunk
00066 //
00067 //  Arguments:  [pcwcOutput] -- count of UniCode characters in buffer
00068 //              [awcBuffer]  -- buffer for text
00069 //
00070 //--------------------------------------------------------------------------
00071
00072 SCODE CImageTag::GetText( ULONG *pcwcOutput, WCHAR *awcBuffer )
00073 {
00074     ULONG cCharsRemaining = _cValueChars - _cValueCharsFiltered;
00075
00076     if ( cCharsRemaining == 0 )
00077     {
00078         *pcwcOutput = 0;
00079         return FILTER_E_NO_MORE_TEXT;
00080     }
00081
00082     if ( *pcwcOutput < cCharsRemaining )
00083     {
00084         RtlCopyMemory( awcBuffer,
00085                        _pwcValueBuf + _cValueCharsFiltered,
00086                        *pcwcOutput * sizeof(WCHAR) );
00087         _cValueCharsFiltered += *pcwcOutput;
00088
00089         return S_OK;
00090     }
00091     else
00092     {
00093         RtlCopyMemory( awcBuffer,
00094                        _pwcValueBuf + _cValueCharsFiltered,
00095                        cCharsRemaining * sizeof(WCHAR) );
00096         _cValueCharsFiltered += cCharsRemaining;
00097         *pcwcOutput = cCharsRemaining;
00098
00099         return FILTER_S_LAST_TEXT;
00100     }
00101 }
00102
00103
00104
00105 //+-------------------------------------------------------------------------
00106 //
00107 //  Method:     CImageTag::InitStatChunk
00108 //
00109 //  Synopsis:   Initializes the STAT_CHUNK
00110 //
00111 //  Arguments:  [pStat] -- STAT_CHUNK to initialize
00112 //
00113 //--------------------------------------------------------------------------
00114
00115 void CImageTag::InitStatChunk( STAT_CHUNK *pStat )
00116 {
00117     //
00118     // Read the alt field of image tag
00119     //
00120     _scanner.ReadTagIntoBuffer();
00121     _scanner.ScanTagBuffer( L"alt=\"", _pwcValueBuf, _cValueChars );
00122
00123     _cValueCharsFiltered = 0;
00124
00125     pStat->idChunk = _htmlIFilter.GetNextChunkId();
00126     pStat->flags = CHUNK_TEXT;
00127     pStat->locale = _htmlIFilter.GetLocale();
00128     pStat->attribute.guidPropSet = CLSID_Storage;
00129     pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00130     pStat->attribute.psProperty.propid = PID_STG_CONTENTS;
00131     pStat->breakType = CHUNK_EOS;
00132     pStat->idChunkSource = pStat->idChunk;
00133     pStat->cwcStartSource = 0;
00134     pStat->cwcLenSource = 0;
00135 }
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCrmFilesCompensator Member List

This is the complete list of members for CCrmFilesCompensator, including all inherited members.
AbortRecord(CrmLogRecordRead crmLogRec, BOOL __RPC_FAR *pfForget) | CCrmFilesCompensator |
BeginAbort(BOOL fRecovery) | CCrmFilesCompensator |
BeginCommit(BOOL fRecovery) | CCrmFilesCompensator |
BeginPrepare(void) | CCrmFilesCompensator |
CCrmFilesCompensator() | CCrmFilesCompensator | [inline]
CommitRecord(CrmLogRecordRead crmLogRec, BOOL __RPC_FAR *pfForget) | CCrmFilesCompensator |
EndAbort(void) | CCrmFilesCompensator |
EndCommit(void) | CCrmFilesCompensator |
EndPrepare(BOOL __RPC_FAR *pfOkToPrepare) | CCrmFilesCompensator |
GetColumn(CrmLogRecordRead CrmLogRec, LPVARIANT pFormattedLogRecord) | CCrmFilesCompensator |
GetColumnCount(long __RPC_FAR *plColumnCount) | CCrmFilesCompensator |
GetColumnHeaders(LPVARIANT pHeaders) | CCrmFilesCompensator |
GetColumnVariants(VARIANT LogRecord, LPVARIANT pFormattedLogRecord) | CCrmFilesCompensator |
m_CommandType | CCrmFilesCompensator | [private]
m_pICrmLogControl | CCrmFilesCompensator | [private]
m_wszSourceFileName | CCrmFilesCompensator | [private]
m_wszTempFileName | CCrmFilesCompensator | [private]
MakeVariantArray(int i_iNumVariants, _variant_t *i_vArray, LPVARIANT i_pVarSafeArray) | CCrmFilesCompensator | [private]
PrepareRecord(CrmLogRecordRead crmLogRec, BOOL __RPC_FAR *pfForget) | CCrmFilesCompensator |
ProcessLogRecord(CrmLogRecordRead crmLogRec) | CCrmFilesCompensator | [private]
SetLogControl(ICrmLogControl __RPC_FAR *pLogControl) | CCrmFilesCompensator |
Generated on Wed Nov 13 2024 16:55:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/row.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

row.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module ROW.CPP | CRow object implementation
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014
00015
00016 // Code ----------------------------------------------------------------------
00017
00018 // CRow::CRow ----------------------------------------------------------------
00019 //
00020 // @mfunc Constructor for this class
00021 //
00022 // @rdesc NONE
00023 //
00024 CRow::CRow
00025     (
00026     LPUNKNOWN pUnkOuter         //@parm IN | Outer Unkown Pointer
00027     ) // invoke ctor for base class
00028   : CBaseObj( BOT_ROW )
00029 {
00030   //  Initialize simple member vars
00031     m_cRef          = 0L;
00032   m_pUnkOuter   = pUnkOuter ? pUnkOuter : this;
00033   m_pFileio   = NULL;
00034   m_cbRowSize   = 0;
00035   m_pRowBuff    = NULL;
00036
00037   m_pParentObj  = NULL;
00038
00039   m_pIRow       = NULL;
00040   m_pIColumnsInfo   = NULL;
00041   m_pIConvertType   = NULL;
00042   m_pIGetSession    = NULL;
00043   m_pIRowChange   = NULL;
00044
00045   // Fill in information about the ROW object's default stream
00046   // This is the only extra column that Sample Provider support
00047   m_rgExtracolinfo[DEFAULT_STREAM].wType      = DBTYPE_IUNKNOWN;
00048   m_rgExtracolinfo[DEFAULT_STREAM].ulColumnSize = sizeof(IUnknown *);
00049   m_rgExtracolinfo[DEFAULT_STREAM].pwszName   = NULL;
00050   m_rgExtracolinfo[DEFAULT_STREAM].pTypeInfo    = NULL;
00051   m_rgExtracolinfo[DEFAULT_STREAM].iOrdinal   = 0;
00052   m_rgExtracolinfo[DEFAULT_STREAM].dwFlags    = DBCOLUMNFLAGS_ISDEFAULTSTREAM;
00053   m_rgExtracolinfo[DEFAULT_STREAM].bPrecision   = ~0;
00054   m_rgExtracolinfo[DEFAULT_STREAM].bScale     = ~0;
00055   memcpy(&m_rgExtracolinfo[DEFAULT_STREAM].columnid, &DBROWCOL_DEFAULTSTREAM,
00056       sizeof(DBID));
00057
00058   m_cExtraCols    = EXTRA_COLUMNS;
00059
00060   //Associated Row Handle
00061   m_hRow        = DB_NULL_HROW;
00062
00063   // Increment global object count.
00064     OBJECT_CONSTRUCTED();
00065 }
00066
00067
00068 // CRow::~CRow ---------------------------------------------------------------
00069 //
00070 // @mfunc Destructor for this class
00071 //
00072 // @rdesc NONE
00073 //
00074 CRow:: ~CRow
00075     (
00076     void
00077     )
00078 {
00079   delete [] m_pRowBuff;
00080
00081   SAFE_DELETE(m_pFileio);
00082
00083   SAFE_DELETE(m_pIRow);
00084   SAFE_DELETE(m_pIColumnsInfo);
00085   SAFE_DELETE(m_pIConvertType);
00086   SAFE_DELETE(m_pIGetSession);
00087   SAFE_DELETE(m_pIRowChange);
00088
00089   //Release outstanding row handle...
00090   IRowset * pIRowset = NULL;
00091   if( m_pParentObj &&
00092     m_pParentObj->GetBaseObjectType() == BOT_ROWSET &&
00093     SUCCEEDED(m_pParentObj->QueryInterface(IID_IRowset, (void**)&pIRowset)) )
00094   {
00095     if( pIRowset )
00096     {
00097       pIRowset->ReleaseRows(1, &m_hRow, NULL, NULL, NULL);
00098       pIRowset->Release();
00099     }
00100   }
00101
00102   if( m_pParentObj )
00103     m_pParentObj->GetOuterUnknown()->Release();
00104 }
00105
00106
00107 // CRow::FInit ---------------------------------------------------------------
00108 //
00109 // @mfunc Initialize the row Object when it is a part of a rowset
00110 //
00111 // @rdesc Did the Initialization Succeed
00112 //      @flag  TRUE  | Initialization succeeded
00113 //      @flag  FALSE | Initialization failed
00114 //
00115 BOOL CRow::FInit
00116   (
00117   CRowset * pParentObj    //@parm IN | pointer to parent rowset object
00118   )
00119 {
00120   assert(pParentObj);
00121   assert(pParentObj->m_pFileio);
00122     assert(m_pUnkOuter);
00123
00124   m_pParentObj = pParentObj;
00125   m_pParentObj->GetOuterUnknown()->AddRef();
00126
00127     // Allocate contained interface objects
00128   m_pIRow           = new CImpIRow( this, m_pUnkOuter );
00129     m_pIColumnsInfo             = new CImpIColumnsInfo( this, m_pUnkOuter );
00130   m_pIConvertType       = new CImpIConvertType( this, m_pUnkOuter );
00131   m_pIGetSession        = new CImpIGetSession( this, m_pUnkOuter );
00132     m_pIRowChange       = new CImpIRowChange( this, m_pUnkOuter );
00133
00134   m_cbRowSize = pParentObj->m_cbRowSize;
00135
00136     // if all interfaces were created, return success
00137     return (BOOL) (m_pIRow && m_pIColumnsInfo && m_pIConvertType &&
00138                    m_pIGetSession && m_pIRowChange);
00139 }
00140
00141
00142 // CRow::FInit ---------------------------------------------------------------
00143 //
00144 // @mfunc Initialize the row Object on a direct bind
00145 //
00146 // @rdesc Did the Initialization Succeed
00147 //      @flag  TRUE  | Initialization succeeded
00148 //      @flag  FALSE | Initialization failed
00149 //
00150 BOOL CRow::FInit
00151   (
00152   CDBSession *  pParentObj,     //@parm IN | pointer to parent session object
00153   CFileIO *   pFileIO,      //@parm IN | pointer to FileIO object
00154   DBCOUNTITEM   ulRowNum      //@parm IN | Row number to fetch
00155   )
00156 {
00157   DBORDINAL   cCols;
00158   COLUMNDATA *  pColumn = NULL;
00159
00160   assert(pFileIO);
00161     assert(m_pUnkOuter);
00162
00163   m_pParentObj = pParentObj;
00164   m_pParentObj->GetOuterUnknown()->AddRef();
00165
00166   m_pFileio = pFileIO;
00167
00168     // Allocate contained interface objects
00169   m_pIRow           = new CImpIRow( this, m_pUnkOuter );
00170     m_pIColumnsInfo             = new CImpIColumnsInfo( this, m_pUnkOuter );
00171   m_pIConvertType       = new CImpIConvertType( this, m_pUnkOuter );
00172   m_pIGetSession        = new CImpIGetSession( this, m_pUnkOuter );
00173     m_pIRowChange       = new CImpIRowChange( this, m_pUnkOuter );
00174
00175   m_cbRowSize = m_pFileio->GetRowSize();
00176   m_pRowBuff = new BYTE [ ROUND_UP( m_pFileio->GetRowSize() + sizeof(ROWBUFF), COLUMN_ALIGNVAL ) ];
00177   memset(m_pRowBuff, 0, ROUND_UP( m_pFileio->GetRowSize() + sizeof(ROWBUFF), COLUMN_ALIGNVAL ) );
00178
00179   // Set up the row buff bindings
00180   for (cCols=1; cCols <= m_pFileio->GetColumnCnt(); cCols++)
00181   {
00182     pColumn = m_pFileio->GetColumnData(cCols, (ROWBUFF *)m_pRowBuff);
00183     if (FAILED(m_pFileio->SetColumnBind(cCols, pColumn)))
00184       return FALSE;
00185   }
00186
00187   // Actually fetch the data
00188     if( S_OK != m_pFileio->Fetch( ulRowNum ) )
00189         return FALSE;
00190
00191   ((ROWBUFF *)m_pRowBuff)->ulRefCount = 1;
00192   ((ROWBUFF *)m_pRowBuff)->pbBmk = (void *)ulRowNum;
00193
00194
00195
00196
00197     // if all interfaces were created, return success
00198     return (BOOL) (m_pIRow && m_pIColumnsInfo && m_pIConvertType &&
00199                    m_pIGetSession && m_pIRowChange && m_pFileio &&
00200            m_pRowBuff);
00201 }
00202
00203
00204 // CRow::QueryInterface ------------------------------------------------------
00205 //
00206 // @mfunc Returns a pointer to a specified interface. Callers use
00207 // QueryInterface to determine which interfaces the called object
00208 // supports.
00209 //
00210 // @rdesc HRESULT indicating the status of the method
00211 //      @flag S_OK | Interface is supported and ppvObject is set.
00212 //      @flag E_NOINTERFACE | Interface is not supported by the object
00213 //      @flag E_INVALIDARG | One or more arguments are invalid.
00214 //
00215 STDMETHODIMP CRow::QueryInterface
00216     (
00217     REFIID riid,
00218     LPVOID * ppv
00219     )
00220 {
00221   if( NULL == ppv )
00222     return E_INVALIDARG;
00223
00224   //  Place NULL in *ppv in case of failure
00225   *ppv = NULL;
00226
00227     //  This is the non-delegating IUnknown implementation
00228   if( riid == IID_IUnknown )
00229     *ppv = (LPVOID) this;
00230   else if( riid == IID_IRow )
00231     *ppv = (LPVOID) m_pIRow;
00232   else if( riid == IID_IColumnsInfo )
00233     *ppv = (LPVOID) m_pIColumnsInfo;
00234   else if( riid == IID_IConvertType )
00235     *ppv = (LPVOID) m_pIConvertType;
00236   else if( riid == IID_IGetSession )
00237     *ppv = m_pIGetSession;
00238   else if( riid == IID_IRowChange )
00239     *ppv = m_pIRowChange;
00240
00241     //  If we're going to return an interface, AddRef it first
00242     if( *ppv )
00243   {
00244         ((LPUNKNOWN) *ppv)->AddRef();
00245         return ResultFromScode( S_OK );
00246   }
00247     else
00248         return ResultFromScode( E_NOINTERFACE );
00249 }
00250
00251
00252 // CRow::AddRef --------------------------------------------------------------
00253 //
00254 // @mfunc Increments a persistence count for the object
00255 //
00256 // @rdesc Current reference count
00257 //
00258 STDMETHODIMP_( DBREFCOUNT ) CRow::AddRef
00259      (
00260      void
00261      )
00262 {
00263     return ++m_cRef;
00264 }
00265
00266
00267 // CRow::Release -------------------------------------------------------------
00268 //
00269 // @mfunc Decrements a persistence count for the object and if
00270 // persistence count is 0, the object destroys itself.
00271 //
00272 // @rdesc Current reference count
00273 //
00274 STDMETHODIMP_( DBREFCOUNT ) CRow::Release
00275      (
00276      void
00277      )
00278 {
00279     if (!--m_cRef)
00280         {
00281         delete this;
00282         return 0;
00283         }
00284
00285     return m_cRef;
00286 }
00287
00288
00289 // CRow::SetRowHandle --------------------------------------------------------
00290 //
00291 // @mfunc Internal member function which sets the HROW which this row object
00292 // represents
00293 //
00294 // @rdesc HRESULT indicating the status of the method
00295 //      @flag S_OK               | method succeeded
00296 //      @flag DB_E_DELETEDROW    | hrow referred to a deleted row
00297 //      @flag DB_E_BADROWHANDLE  | hrow did not belong to the parent rowset
00298 //
00299 STDMETHODIMP CRow::SetRowHandle(HROW hRow)
00300 {
00301   IRowset *   pIRowset  = NULL;
00302   HRESULT     hr      = DB_E_NOSOURCEOBJECT;
00303   DBROWSTATUS   dwRowStatus = DBROWSTATUS_S_OK;
00304
00305   //Obtain the parent rowset...
00306   if( m_pParentObj )
00307   {
00308     hr = m_pParentObj->QueryInterface(IID_IRowset, (void**)&pIRowset);
00309
00310     if( pIRowset )
00311     {
00312       //AddRef the row,
00313       //To be able to hang onto the row, and determine if its invalid or not...
00314       if(FAILED(hr = pIRowset->AddRefRows(1, &hRow, NULL, &dwRowStatus)))
00315       {
00316         switch(dwRowStatus)
00317         {
00318           case DBROWSTATUS_E_DELETED:
00319             hr = DB_E_DELETEDROW;
00320             break;
00321
00322           default:
00323             hr = DB_E_BADROWHANDLE;
00324             break;
00325         };
00326       }
00327
00328       //We made it this far, store the row...
00329       if( SUCCEEDED(hr) )
00330         m_hRow = hRow;
00331       pIRowset->Release();
00332     }
00333   }
00334
00335   return hr;
00336 }
00337
00338
00339 // CRow::GetRowBuff ----------------------------------------------------------
00340 //
00341 // @mfunc Returns the underlying ROWBUFF
00342 //
00343 ROWBUFF * CRow::GetRowBuff()
00344 {
00345   if( BOT_ROWSET == m_pParentObj->GetBaseObjectType() )
00346     return ((CRowset *)m_pParentObj)->GetRowBuff( m_hRow, TRUE );
00347   else
00348   {
00349     assert( BOT_SESSION == m_pParentObj->GetBaseObjectType() );
00350     return (ROWBUFF *)m_pRowBuff;
00351   }
00352 }
00353
00354
00355 // CRow::GetFileObj ----------------------------------------------------------
00356 //
00357 // @mfunc Returns the underlying Fileio object
00358 //
00359 CFileIO * CRow::GetFileObj()
00360 {
00361   if( BOT_ROWSET == m_pParentObj->GetBaseObjectType() )
00362     return ((CRowset *)m_pParentObj)->m_pFileio;
00363   else
00364   {
00365     assert( BOT_SESSION == m_pParentObj->GetBaseObjectType() );
00366     return m_pFileio;
00367   }
00368 }
00369
00370
00371 // CRow::GetColumnData -------------------------------------------------------
00372 //
00373 // @mfunc Returns TRUE if pColumnID is valid
00374 //
00375 BOOL  CRow::GetColumnOrdinal
00376   (
00377   CFileIO * pFileio,
00378   DBID *    pColumnID,
00379   DBORDINAL * pcCol
00380   )
00381 {
00382   if( (pColumnID->eKind == DBKIND_GUID_PROPID) &&
00383     (pColumnID->uGuid.guid == GUID_NULL)     &&
00384     (pColumnID->uName.ulPropid >= 1)          &&
00385         (pColumnID->uName.ulPropid <= pFileio->GetColumnCnt()) )
00386     {
00387         if( pcCol )
00388       *pcCol = pColumnID->uName.ulPropid;
00389     return TRUE;
00390     }
00391     else
00392         return FALSE;
00393 }
00394
00395
00396 // CImpIRow::GetColumns ------------------------------------------------------
00397 //
00398 // @mfunc Gets multiple columns from the row
00399 //
00400 // @rdesc HRESULT
00401 //      @flag S_OK                 | Method Succeeded
00402 //      @flag E_INVALIDARG         | rgColumns was null and cColumns != 0
00403 //      @flag DB_E_DELETEDROW      | The row has been deleted
00404 //      @flag DB_S_ERRORSOCCURRED  | Failure to retrieve one or more values
00405 //
00406 STDMETHODIMP CImpIRow::GetColumns
00407   (
00408   DBORDINAL cColumns,
00409   DBCOLUMNACCESS rgColumns[]
00410   )
00411 {
00412   HRESULT     hr;
00413   DBORDINAL   cCols;
00414   DBORDINAL   cIter;
00415   DBORDINAL   cErrorCount;
00416   ROWBUFF *   pRowBuff = NULL;
00417   COLUMNDATA *  pColumnData = NULL;
00418   CFileIO *   pFileio = NULL;
00419   DBCOLUMNINFO *  rgdbcolumninfo = NULL;
00420   CStream *   pCStream = NULL;
00421
00422   //
00423   // Asserts
00424     //
00425   assert( m_pObj );
00426
00427   // cColumns == 0 is a no-op
00428   if( cColumns == 0 )
00429     return S_OK;
00430
00431   if( !rgColumns )
00432     return E_INVALIDARG;
00433
00434   // Check to see if we have a DC
00435   if( !g_pIDataConvert )
00436     return E_FAIL;
00437
00438   pFileio = m_pObj->GetFileObj();
00439   assert( pFileio );
00440
00441     // Internal error for a 0 reference count on this row,
00442     // since we depend on the slot-set stuff.
00443     pRowBuff = m_pObj->GetRowBuff();
00444     assert( pRowBuff->ulRefCount );
00445
00446   // Check for the Deleted Row
00447   if ( pFileio->IsDeleted( (DBBKMARK) pRowBuff->pbBmk ) == S_OK )
00448         return DB_E_DELETEDROW;
00449
00450     cErrorCount = 0;
00451   rgdbcolumninfo = pFileio->GetColInfo();
00452     for (cIter = 0; cIter < cColumns; cIter++)
00453   {
00454     if( IsEqualDBID(&rgColumns[cIter].columnid, &DBROWCOL_DEFAULTSTREAM) )
00455     {
00456       if( rgColumns[cIter].wType == DBTYPE_IUNKNOWN )
00457       {
00458         pCStream = new CStream(NULL);
00459         if( pCStream && pCStream->FInit(m_pObj, pRowBuff) )
00460         {
00461           //Obtain the requested interface
00462           pCStream->AddRef();
00463           if( rgColumns[cIter].pData )
00464             *((IUnknown **)rgColumns[cIter].pData) = (IUnknown *)pCStream;
00465           else
00466             pCStream->Release();
00467
00468           rgColumns[cIter].dwStatus = DBSTATUS_S_OK;
00469           rgColumns[cIter].cbDataLen = sizeof(IUnknown *);
00470         }
00471         else
00472         {
00473           rgColumns[cIter].dwStatus = DBSTATUS_E_CANTCREATE;
00474           cErrorCount++;
00475
00476         }
00477       }
00478       else
00479       {
00480         rgColumns[cIter].dwStatus = DBSTATUS_E_BADACCESSOR;
00481         cErrorCount++;
00482       }
00483       continue;
00484     }
00485
00486     if( !m_pObj->GetColumnOrdinal(pFileio, &rgColumns[cIter].columnid, &cCols) )
00487     {
00488       rgColumns[cIter].dwStatus = DBSTATUS_E_DOESNOTEXIST;
00489       cErrorCount++;
00490       continue;
00491     }
00492
00493     pColumnData = pFileio->GetColumnData(cCols, pRowBuff);
00494
00495         hr = g_pIDataConvert->DataConvert(
00496                 rgdbcolumninfo[cCols].wType,  // src Type
00497                 rgColumns[cIter].wType,     // dst Type
00498                 pColumnData->dwLength,      // src Length
00499                 &rgColumns[cIter].cbDataLen,  // dst Length
00500                 &(pColumnData->bData),      // pSrc
00501                 rgColumns[cIter].pData,     // pDst
00502                 rgColumns[cIter].cbMaxLen,    // cbMaxLen
00503                 pColumnData->dwStatus,      // src Status
00504                 &rgColumns[cIter].dwStatus,   // dst Status
00505                 rgColumns[cIter].bPrecision,  // bPrecision for conversion to DBNUMERIC
00506         rgColumns[cIter].bScale,    // bScale for conversion to DBNUMERIC
00507         DBDATACONVERT_DEFAULT);
00508
00509     if (hr != S_OK)
00510             cErrorCount++;
00511   }
00512
00513   // Return S_OK if all columns retrieved with successful status
00514     // Return DB_S_ERRORSOCCURED on failure to retrieve one or more column values
00515     // Return DB_E_ERRORSOCCURED on failure to retrieve all column values
00516
00517   return cErrorCount ? ( cErrorCount < cColumns ) ?
00518     ResultFromScode( DB_S_ERRORSOCCURRED ) :
00519     ResultFromScode( DB_E_ERRORSOCCURRED ) :
00520     ResultFromScode( S_OK );
00521 }
00522
00523
00524 // CImpIRow::GetSourceRowset -------------------------------------------------
00525 //
00526 // @mfunc Returns the rowset interface of which this row is a part
00527 //
00528 // @rdesc HRESULT
00529 //      @flag S_OK          | Method Succeeded
00530 //      @flag E_INVALIDARG  | Invalid parameters were specified
00531 //
00532 STDMETHODIMP CImpIRow::GetSourceRowset
00533   (
00534   REFIID    riid,
00535   IUnknown ** ppRowset,
00536   HROW *    phRow
00537   )
00538 {
00539   HRESULT   hr;
00540   CRowset * pCRowset = NULL;
00541   IUnknown *  pSourceRowset = NULL;
00542   ROWBUFF * pRowBuff = NULL;
00543
00544   //
00545   // Asserts
00546     //
00547   assert(m_pObj);
00548   assert(m_pObj->m_pParentObj);
00549
00550   if( !ppRowset && !phRow )
00551     return E_INVALIDARG;
00552
00553   if( ppRowset )
00554     *ppRowset = NULL;
00555   if( phRow )
00556     *phRow = DB_NULL_HROW;
00557
00558   if( BOT_SESSION == m_pObj->m_pParentObj->GetBaseObjectType() )
00559     return DB_E_NOSOURCEOBJECT;
00560
00561   pCRowset = (CRowset *)m_pObj->m_pParentObj;
00562   if( !pCRowset )
00563     return E_FAIL;
00564
00565   hr = pCRowset->m_pUnkOuter->QueryInterface(riid, (LPVOID *)&pSourceRowset);
00566   if( FAILED(hr) )
00567     return hr;
00568
00569   // Check for the Deleted Row
00570     pRowBuff = pCRowset->GetRowBuff( (DBCOUNTITEM)m_pObj->m_hRow, TRUE );
00571     assert( pRowBuff && pRowBuff->ulRefCount );
00572
00573   if ( pCRowset->m_pFileio &&
00574      pCRowset->m_pFileio->IsDeleted( (DBBKMARK) pRowBuff->pbBmk ) == S_OK )
00575   {
00576     pSourceRowset->Release();
00577         return DB_E_DELETEDROW;
00578   }
00579
00580   if( ppRowset )
00581     *ppRowset = pSourceRowset;
00582   else
00583     pSourceRowset->Release();
00584
00585   if( phRow )
00586   {
00587     // return the HROW and add a refcout
00588     *phRow = m_pObj->m_hRow;
00589
00590     pRowBuff->ulRefCount++;
00591     pCRowset->m_ulRowRefCount++;
00592   }
00593
00594   return S_OK;
00595 }
00596
00597
00598 // CImpIRow::Open ------------------------------------------------------------
00599 //
00600 // @mfunc Retrieves interface from an object valued column
00601 //
00602 // @rdesc HRESULT
00603 //    @flag S_OK                 | method succeeded
00604 //      @flag DB_E_OBJECTMISMATCH  | Requested an object that does not match
00605 //                   the object type of the column
00606 //
00607 STDMETHODIMP CImpIRow::Open
00608   (
00609   IUnknown *  pUnkOuter,
00610   DBID *    pColumnID,
00611   REFGUID   rguidColumnType,
00612   DWORD   dwBindFlags,
00613   REFIID    riid,
00614   IUnknown ** ppUnk
00615   )
00616 {
00617   HRESULT   hr = S_OK;
00618   CStream * pCStream = NULL;
00619   CFileIO * pFileio = NULL;
00620   ROWBUFF * pRowBuff = NULL;
00621
00622   //
00623   // Asserts
00624     //
00625   assert(m_pObj);
00626
00627   if( ppUnk )
00628     *ppUnk = NULL;
00629
00630   if(!pColumnID )
00631     return E_INVALIDARG;
00632
00633   if( pUnkOuter && riid != IID_IUnknown )
00634     return DB_E_NOAGGREGATION;
00635
00636   pFileio = m_pObj->GetFileObj();
00637   pRowBuff = m_pObj->GetRowBuff();
00638
00639   if( pFileio->IsDeleted( (DBBKMARK) pRowBuff->pbBmk ) == S_OK )
00640         return DB_E_DELETEDROW;
00641
00642   // The only supported object valued column is the default stream object
00643   if( rguidColumnType != DBGUID_STREAM &&
00644     rguidColumnType != GUID_NULL )
00645     return DB_E_OBJECTMISMATCH;
00646
00647   if( IsEqualDBID(pColumnID, &DBROWCOL_DEFAULTSTREAM) )
00648   {
00649     pCStream = new CStream(pUnkOuter);
00650     if( pCStream && pCStream->FInit(m_pObj, pRowBuff) )
00651     {
00652       //Obtain the requested interface
00653       hr = pCStream->QueryInterface(riid, (void**)ppUnk);
00654     }
00655     else
00656       hr = E_OUTOFMEMORY;
00657   }
00658   else
00659   {
00660     //Either this columnid does not exist or
00661     //this columnid is not an object valued column
00662     if( !m_pObj->GetColumnOrdinal(pFileio, pColumnID, NULL) )
00663     {
00664       hr = DB_E_BADCOLUMNID;
00665     }
00666     else
00667       hr = DB_E_OBJECTMISMATCH;
00668   }
00669
00670   if( FAILED(hr) )
00671     SAFE_DELETE( pCStream );
00672
00673   return hr;
00674 }
00675
00676
00677 // CImpIGetSession::GetSession -----------------------------------------------
00678 //
00679 // @mfunc Returns the session interface on which the row has been created
00680 //
00681 // @rdesc HRESULT
00682 //      @flag S_OK                 | Method Succeeded
00683 //    @flag DB_E_NOSOURCEOBJECT  | There is no session object for the row
00684 //      @flag E_INVALIDARG         | Invalid parameters were specified
00685 //
00686 STDMETHODIMP CImpIGetSession::GetSession
00687   (
00688   REFIID    riid,
00689     IUnknown ** ppunkSession
00690   )
00691 {
00692   CRowset *   pCRowset = NULL;
00693   CBaseObj *    pCRowsetParent = NULL;
00694   CDBSession *  pCSession = NULL;
00695
00696   //
00697   // Asserts
00698     //
00699   assert(m_pObj);
00700   assert(m_pObj->m_pParentObj);
00701
00702   if( NULL == ppunkSession )
00703     return (E_INVALIDARG);
00704
00705   *ppunkSession = NULL;
00706
00707   if( BOT_SESSION == m_pObj->m_pParentObj->GetBaseObjectType() )
00708   {
00709     pCSession = (CDBSession *)m_pObj->m_pParentObj;
00710   }
00711   else
00712   {
00713     assert( BOT_ROWSET == m_pObj->m_pParentObj->GetBaseObjectType() );
00714     pCRowset = (CRowset *)m_pObj->m_pParentObj;
00715     if( !pCRowset )
00716       return E_FAIL;
00717
00718     pCRowsetParent = pCRowset->m_pParentObj;
00719     if( !pCRowsetParent )
00720       return E_FAIL;
00721
00722     if( BOT_SESSION == pCRowsetParent->GetBaseObjectType() )
00723       pCSession = (CDBSession *)pCRowsetParent;
00724     else if( BOT_COMMAND == pCRowsetParent->GetBaseObjectType() )
00725       pCSession = ((CCommand *)pCRowsetParent)->m_pCSession;
00726     else
00727       return E_FAIL;
00728   }
00729
00730   if( pCSession )
00731     return pCSession->GetOuterUnknown()->QueryInterface(riid, (LPVOID*)ppunkSession);
00732   else
00733     return DB_E_NOSOURCEOBJECT;
00734 }
00735
00736
00737 // CImpIRowChange::SetColumns ------------------------------------------------
00738 //
00739 // @mfunc Sets multiple column values on a row
00740 //
00741 // @rdesc HRESULT
00742 //      @flag S_OK                 | Method Succeeded
00743 //      @flag E_INVALIDARG         | rgColumns was null and cColumns != 0
00744 //      @flag DB_E_DELETEDROW      | The row has been deleted or moved
00745 //      @flag DB_E_ERRORSOCCURRED  | No columns set
00746 //    @flag DB_E_DELETEDROW    | The row has been deleted
00747 //
00748 STDMETHODIMP CImpIRowChange::SetColumns
00749   (
00750   DBORDINAL cColumns,
00751   DBCOLUMNACCESS rgColumns[]
00752   )
00753 {
00754   HRESULT     hr;
00755   DBORDINAL   cIter = 0;
00756   DBORDINAL   cErrorCount = 0;
00757   DBORDINAL   cCols = 0;
00758   DWORD     dwSrcStatus;
00759   ROWBUFF *   pRowBuff = NULL;
00760   COLUMNDATA *  pColumnData = NULL;
00761   BYTE *      rgbRowDataSave = NULL;
00762   DBCOLUMNINFO *  rgdbcolumninfo = NULL;
00763   CFileIO *   pFileio = NULL;
00764
00765   //
00766   // Asserts
00767     //
00768   assert( m_pObj );
00769   assert( m_pObj->m_pParentObj );
00770
00771   // cColumns == 0 is a no-op
00772   if( cColumns == 0 )
00773     return S_OK;
00774
00775   if( !rgColumns )
00776     return E_INVALIDARG;
00777
00778   // Check to see if we have a DC
00779   if( !g_pIDataConvert )
00780     return E_FAIL;
00781
00782   pFileio   = m_pObj->GetFileObj();
00783     pRowBuff  = m_pObj->GetRowBuff();
00784
00785     // Is row handle deleted?
00786     if ( pFileio->IsDeleted((DBBKMARK) ((PROWBUFF) pRowBuff)->pbBmk ) == S_OK )
00787         return DB_E_DELETEDROW;
00788
00789     rgbRowDataSave = new BYTE[m_pObj->m_cbRowSize];
00790     if ( rgbRowDataSave == NULL )
00791         return E_OUTOFMEMORY;
00792
00793     // Save the row.
00794     memcpy( rgbRowDataSave, pRowBuff, m_pObj->m_cbRowSize );
00795
00796   rgdbcolumninfo = pFileio->GetColInfo();
00797     for (cIter = 0; cIter < cColumns; cIter++)
00798   {
00799     // Check the Status for DBSTATUS_S_IGNORE
00800     dwSrcStatus = rgColumns[cIter].dwStatus;
00801     if( dwSrcStatus == DBSTATUS_S_IGNORE )
00802       continue;
00803
00804     if( IsEqualDBID(&rgColumns[cIter].columnid, &DBROWCOL_DEFAULTSTREAM) )
00805     {
00806       // Default stream column is read only
00807       rgColumns[cIter].dwStatus = DBSTATUS_E_PERMISSIONDENIED;
00808       cErrorCount++;
00809       continue;
00810     }
00811     else
00812     {
00813       if( !m_pObj->GetColumnOrdinal(pFileio, &rgColumns[cIter].columnid, &cCols) )
00814       {
00815         rgColumns[cIter].dwStatus = DBSTATUS_E_DOESNOTEXIST;
00816         cErrorCount++;
00817         continue;
00818       }
00819     }
00820
00821     pColumnData = pFileio->GetColumnData(cCols, pRowBuff);
00822
00823         // Check the Status for DBSTATUS_S_DEFAULT
00824     if( dwSrcStatus == DBSTATUS_S_DEFAULT )
00825       dwSrcStatus = DBSTATUS_S_ISNULL;
00826
00827         // Check the Status of the value being sent in
00828     if( (dwSrcStatus != DBSTATUS_S_OK && dwSrcStatus != DBSTATUS_S_ISNULL &&
00829        dwSrcStatus != DBSTATUS_S_IGNORE && dwSrcStatus != DBSTATUS_S_DEFAULT) )
00830     {
00831       rgColumns[cIter].dwStatus = DBSTATUS_E_BADSTATUS;
00832       cErrorCount++;
00833       continue;
00834     }
00835
00836     hr = g_pIDataConvert->DataConvert(
00837         rgColumns[cIter].wType,         // src Type
00838                 rgdbcolumninfo[cCols].wType,      // dst Type
00839                 rgColumns[cIter].cbDataLen,       // src Length
00840                 (DBLENGTH *)&(pColumnData->dwLength),   // dst Length
00841                 rgColumns[cIter].pData,         // pSrc
00842                 &(pColumnData->bData),          // pDst
00843                 rgColumns[cIter].cbMaxLen,        // cbMaxLen
00844                 dwSrcStatus,              // src Status
00845                 &(pColumnData->dwStatus),       // dst Status
00846                 rgColumns[cIter].bPrecision,      // bPrecision for conversion to DBNUMERIC
00847         rgColumns[cIter].bScale,        // bScale for conversion to DBNUMERIC
00848         DBDATACONVERT_SETDATABEHAVIOR);
00849
00850     // fatal error
00851     if( FAILED(hr) )
00852     {
00853       cErrorCount++;
00854       rgColumns[cIter].dwStatus = pColumnData->dwStatus;
00855       continue;
00856     }
00857   }
00858
00859     // Carry out the update.
00860     if( FAILED( pFileio->UpdateRow((DBBKMARK) ((PROWBUFF) pRowBuff)->pbBmk, (BYTE *)pRowBuff, UPDATE )) )
00861   {
00862         // Restore the row to its previous state
00863         memcpy( pRowBuff, rgbRowDataSave, m_pObj->m_cbRowSize );
00864         return ResultFromScode( E_FAIL );
00865   }
00866
00867     delete [] rgbRowDataSave;
00868
00869   // Return S_OK if all columns were updated
00870     // Return DB_S_ERRORSOCCURED one or more columns failed to be updated
00871     // Return DB_E_ERRORSOCCURED on failure to set all columns
00872
00873   return cErrorCount ? ( cErrorCount < cColumns ) ?
00874       ResultFromScode( DB_S_ERRORSOCCURRED ) :
00875       ResultFromScode( DB_E_ERRORSOCCURRED ) :
00876       ResultFromScode( S_OK );
00877 }
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Custom/SpinCube/Paint.h Source File

  • WinUI
  • Controls
  • Custom
  • SpinCube

Paint.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *
00003 *                               MODULE: PAINT.H
00004 *
00005 \******************************************************************************/
00006
00007
00008
00009 /******************************************************************************\
00010 *                             SYMBOLIC CONSTANTS
00011 \******************************************************************************/
00012
00013 #define  NUMVERTICES  8 /* number of polyhedron vertices */
00014 #define  NUMFACETS    6 /* number of polyhedron facets   */
00015
00016 #define  MAX_POINTS_PER_FACET 4
00017
00018
00019
00020 /******************************************************************************\
00021 *                                  TYPEDEFs
00022 \******************************************************************************/
00023
00024 typedef struct
00025 {
00026   LONG x, y, z;
00027
00028 } POINT3D;
00029
00030
00031
00032 /******************************************************************************\
00033 *                          GLOBAL VARIABLES
00034 \******************************************************************************/
00035
00036 //
00037 //  This particular set of vertices "gNormalizedVertices" and corresponding
00038 //    facets "gaiFacets" describe a normalized cube centered about the
00039 //    origin ([0,0,0] in 3-space). The gaiFacet array is made up of a series
00040 //    of indices into the array of vertices, each describing an individual
00041 //    facet (eg. a polygon), and are separated by -1. Note that the facets
00042 //    are decribed in COUNTERCLOCKWISE (relative to the viewer) order so we
00043 //    can consistently find the normal to any given facet. (The normal
00044 //    is used to determine facet visibilty.)
00045 //
00046
00047 static POINT3D gNormalizedVertices[NUMVERTICES] = {{ 1, 1, 1}, { 1,-1, 1},
00048                                                    {-1,-1, 1}, {-1, 1, 1},
00049                                                    { 1, 1,-1}, { 1,-1,-1},
00050                                                    {-1,-1,-1}, {-1, 1,-1}  };
00051
00052
00053 static int gaiFacets[30] = { 3, 2, 1, 0, -1,
00054                              4, 5, 6, 7, -1,
00055                              0, 1, 5, 4, -1,
00056                              6, 2, 3, 7, -1,
00057                              7, 3, 0, 4, -1,
00058                              5, 1, 2, 6, -1  };
00059
00060 POINT3D gXformedVertices[NUMVERTICES];
00061
00062 float   gM[2][3]; /* the transformation matrix */
00063
00064
00065
00066 /******************************************************************************\
00067 *                         FUNCTION PROTOTYPES
00068 \******************************************************************************/
00069
00070 void TransformVertices (HWND, RECT *, PSPINCUBEINFO, LONG);
00071 void ComputeRotationTransformation (float, float, float);
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCOutgoing/RTCOutgoing.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCOutgoing

RTCOutgoing.cpp

Go to the documentation of this file.
00001 /******************************************************>
00002  * Copyright (c) 2001 Microsoft Corporation.
00003  * All rights reserved.
00004  *
00005  * @Abstract: RTCOutgoing.cpp
00006  * ---------- [ Source Definition File]
00007  *
00008  *
00009  *
00010  ******************************************************/
00011
00012
00013
00014 #include "stdafx.h"
00015 #include "RTCOutgoing.h"
00016 #include "RTCOutgoingDlg.h"
00017
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023
00024 /**********************************************************
00025 //@CRTCOutGoingApp MessageMap
00026 //
00027 //*********************************************************/
00028
00029
00030 BEGIN_MESSAGE_MAP(CRTCOutgoingApp, CWinApp)
00031   //{{AFX_MSG_MAP(CRTCOutgoingApp)
00032
00033   //}}AFX_MSG
00034   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00035 END_MESSAGE_MAP()
00036
00037
00038 /**********************************************************
00039 //@CRTCOutgoingApp()
00040 //
00041 //@Description
00042 //
00043 //  Constructor
00044 //
00045 //@Args In:     Void
00046 //@Args Out:    Void
00047 //
00048 //
00049 //*********************************************************/
00050 CRTCOutgoingApp::CRTCOutgoingApp()
00051 {
00052   //
00053   // No initialization required
00054   //
00055 }
00056
00057 /**********************************************************
00058 //@Declaration of the OutGoing App CRTCOutGoingApp
00059 //
00060 //
00061 //*********************************************************/
00062
00063
00064 CRTCOutgoingApp theApp;
00065
00066 /**********************************************************
00067 //@InitInstance()
00068 //
00069 //@Description
00070 //
00071 //  App Initializer
00072 //
00073 //@Args In:     Void
00074 //@Args Out:    Void
00075 //
00076 //
00077 //*********************************************************/
00078 BOOL CRTCOutgoingApp::InitInstance()
00079 {
00080   AfxEnableControlContainer();
00081
00082 #ifdef _AFXDLL
00083   Enable3dControls();     // Call this when using MFC in a shared DLL
00084 #else
00085   Enable3dControlsStatic(); // Call this when linking to MFC statically
00086 #endif
00087
00088   CRTCOutgoingDlg dlg;
00089   m_pMainWnd = &dlg;
00090
00091   //
00092   // we do not handle the response from
00093   // the dialog  RTCIncomingDlg
00094   //
00095
00096   int nResponse = dlg.DoModal();
00097
00098
00099   return FALSE;
00100 }
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/OleImp/Util.Cpp Source File

  • Com
  • Fundamentals
  • DCom
  • OleImp

Util.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 // %%Includes: ---------------------------------------------------------------
00019 #define INC_OLE2
00020 #define STRICT
00021 #include <windows.h>
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include "util.h"
00025
00026 // ---------------------------------------------------------------------------
00027 // %%Function: UtilAllocMem
00028 // ---------------------------------------------------------------------------
00029 BOOL UtilAllocMem (PVOID *ppv, DWORD cb)
00030 {
00031   *ppv = malloc (cb);
00032   return (NULL != *ppv);
00033 }
00034
00035 // ---------------------------------------------------------------------------
00036 // %%Function: UtilFreeMem
00037 // ---------------------------------------------------------------------------
00038 void UtilFreeMem (PVOID pv)
00039 {
00040   if (NULL != pv)
00041     free (pv);
00042 }
00043
00044 // ---------------------------------------------------------------------------
00045 // %%Function: GetUserSidFromToken
00046 //  Returns the SID of the user identified by the supplied token.
00047 // ---------------------------------------------------------------------------
00048 BOOL GetUserSidFromToken (HANDLE hToken, PSID *ppSid)
00049 {
00050   TOKEN_USER *pUser = NULL;
00051   PSID psidUser = NULL;
00052   DWORD cbSid;
00053   DWORD cbRequired;
00054
00055   if (GetTokenInformation (hToken, TokenUser, NULL, 0, &cbRequired))
00056     return(FALSE);  // we shouldn't succeed without a buffer...
00057
00058   if (ERROR_INSUFFICIENT_BUFFER != GetLastError ())
00059     return(FALSE);
00060
00061   if (!UtilAllocMem ((PVOID*)&pUser, cbRequired))
00062     return(FALSE);
00063
00064   __try  {
00065     if (!GetTokenInformation (hToken, TokenUser, pUser, cbRequired,
00066         &cbRequired))
00067       return(FALSE);
00068
00069     // Need a buffer with just the SID, so allocate and copy
00070     cbSid = GetLengthSid (pUser->User.Sid);
00071     if (!UtilAllocMem ((PVOID*)&psidUser, cbSid))
00072       return(FALSE);
00073
00074     if (!CopySid (cbSid, psidUser, pUser->User.Sid))
00075       return(FALSE);
00076
00077     *ppSid = psidUser;
00078     psidUser = NULL;  // so we don't free the sid
00079
00080     return(TRUE);
00081   } __finally  {
00082     UtilFreeMem (psidUser);
00083     UtilFreeMem (pUser);
00084   }
00085   return FALSE;
00086 }
00087
00088 // ---------------------------------------------------------------------------
00089 // %%Function: GetGroupSidFromToken
00090 //  Returns the SID for the primary group in the supplied token
00091 // ---------------------------------------------------------------------------
00092 BOOL GetGroupSidFromToken (HANDLE hToken, PSID *ppSid)
00093 {
00094   TOKEN_PRIMARY_GROUP *pGroup = NULL;
00095   PSID psidGroup = NULL;
00096   DWORD cbSid;
00097   DWORD cbRequired;
00098
00099   if (GetTokenInformation (hToken, TokenPrimaryGroup, NULL, 0, &cbRequired))
00100     return(FALSE);  // something's really screwy
00101
00102   if (ERROR_INSUFFICIENT_BUFFER != GetLastError ())
00103     return(FALSE);
00104
00105   if (!UtilAllocMem ((PVOID*)&pGroup, cbRequired))
00106     return(FALSE);
00107
00108   __try  {
00109     if (!GetTokenInformation (hToken, TokenPrimaryGroup, pGroup,
00110         cbRequired, &cbRequired))
00111       return(FALSE);
00112
00113     // Need a buffer with just the SID, so allocate and copy
00114     cbSid = GetLengthSid (pGroup->PrimaryGroup);
00115     if (!UtilAllocMem ((PVOID*)&psidGroup, cbSid))
00116       return(FALSE);
00117
00118     if (!CopySid (cbSid, psidGroup, pGroup->PrimaryGroup))
00119       return(FALSE);
00120
00121     *ppSid = psidGroup;
00122     psidGroup = NULL; // so we don't free the sid
00123
00124     return(TRUE);
00125   } __finally  {
00126     UtilFreeMem (psidGroup);
00127     UtilFreeMem (pGroup);
00128   }
00129   return FALSE;
00130 }
00131
00132 // ---------------------------------------------------------------------------
00133 // %%Function: CreateAppSecurityDescriptor
00134 //  Creates a security descriptor that allows the world access and is
00135 // owned by the current user.  AccessCheck is used to verify the SD
00136 // because an SD can be valid without having everything required by
00137 // CoInitializeSecurity.
00138 // ---------------------------------------------------------------------------
00139 BOOL CreateAppSecurityDescriptor(PSECURITY_DESCRIPTOR *ppsd)
00140 {
00141   PSECURITY_DESCRIPTOR psd = NULL;
00142   PSID psidUser = NULL, psidGroup = NULL;
00143   HANDLE hToken;
00144   GENERIC_MAPPING gm =  {1, 2, 4, 8}; // dummy GM for AccessCheck
00145   DWORD dwDesired = 1;  // MUST be a value from GM
00146   BOOL fAccess = FALSE;
00147   DWORD dwGranted;
00148   PRIVILEGE_SET ps;
00149   DWORD cbPriv = sizeof (ps);
00150
00151   // allocate the security descriptor
00152   if (!UtilAllocMem ((PVOID*)&psd, SECURITY_DESCRIPTOR_MIN_LENGTH))
00153     return(FALSE);
00154
00155   // we have to impersonate ourselves for the AccessCheck later
00156   if (!ImpersonateSelf(SecurityImpersonation))
00157     return(FALSE);
00158
00159   __try  {
00160
00161     if (!InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION))
00162       return(FALSE);
00163
00164     // give it a NULL DACL -- allow all access
00165     if (!SetSecurityDescriptorDacl (psd, TRUE, NULL, FALSE))
00166       return(FALSE);
00167
00168     // open the token to get the user and group for the new SD
00169     if (!OpenThreadToken (GetCurrentThread(), TOKEN_QUERY, TRUE, &hToken))
00170       return(FALSE);
00171
00172     // set the SD owner
00173     if (!GetUserSidFromToken(hToken, &psidUser))
00174       return(FALSE);
00175     if (!SetSecurityDescriptorOwner(psd, psidUser, FALSE))
00176       return(FALSE);
00177
00178     // set the SD group
00179     if (!GetGroupSidFromToken(hToken, &psidGroup))
00180       return(FALSE);
00181     if (!SetSecurityDescriptorGroup(psd, psidGroup, FALSE))
00182       return(FALSE);
00183
00184     // use AccessCheck to verify that we have a good SD
00185     // using dummy values since we don't really have anything to check
00186     if (!AccessCheck(psd, hToken, dwDesired, &gm, &ps, &cbPriv,
00187         &dwGranted, &fAccess))
00188       return(FALSE);
00189
00190     *ppsd = psd;
00191     psd = NULL;     //
00192     psidUser = NULL;  // don't free these...
00193     psidGroup = NULL; //
00194
00195     return(TRUE);
00196
00197   } __finally  {
00198     UtilFreeMem (psd);
00199     UtilFreeMem (psidUser);
00200     UtilFreeMem (psidGroup);
00201     RevertToSelf ();
00202   }
00203   return FALSE;
00204 }
00205
00206 // ---------------------------------------------------------------------------
00207 // %%Function: FreeAppSecurityDescriptor
00208 //  Releases resources used by the security descriptor.
00209 // ---------------------------------------------------------------------------
00210 BOOL FreeAppSecurityDescriptor (PSECURITY_DESCRIPTOR psd)
00211 {
00212   PSID psid;
00213   BOOL fDefaulted;
00214
00215   if (!GetSecurityDescriptorOwner(psd, &psid, &fDefaulted))
00216     return(FALSE);
00217   UtilFreeMem (psid);
00218
00219   if (!GetSecurityDescriptorGroup(psd, &psid, &fDefaulted))
00220     return(FALSE);
00221   UtilFreeMem (psid);
00222
00223   UtilFreeMem (psd);
00224
00225   return(TRUE);
00226 }
00227
00228 // ---------------------------------------------------------------------------
00229 // %%Function: ErrorMessage
00230 // ---------------------------------------------------------------------------
00231 void ErrorMessage(HWND hwnd, LPCTSTR szFunction, HRESULT hr)
00232 {
00233   LPTSTR   szMessage;
00234
00235   if (HRESULT_FACILITY(hr) == FACILITY_WINDOWS)
00236     hr = HRESULT_CODE(hr);
00237
00238   if (!FormatMessage(
00239       FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00240       NULL, hr,
00241       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default
00242       (LPTSTR)&szMessage, 0, NULL))
00243     return;
00244
00245   if (hwnd == NULL)
00246     {
00247     OutputDebugString(szFunction);
00248     OutputDebugString(TEXT(": "));
00249     OutputDebugString(szMessage);
00250     OutputDebugString(TEXT("\n"));
00251     }
00252   else
00253     MessageBox(hwnd, szMessage, szFunction, MB_OK);
00254
00255   LocalFree(szMessage);
00256 }  // ErrorMessage
00257
00258 // EOF =======================================================================
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/BandObjs.Cpp Source File

  • WinUI
  • Shell
  • BandObjs

BandObjs.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          BandObjs.cpp
00013
00014    Description:   Contains DLLMain and standard OLE COM object creation stuff.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <ole2.h>
00023 #include <comcat.h>
00024 #include <olectl.h>
00025 #include "ClsFact.h"
00026
00027 /**************************************************************************
00028    GUID stuff
00029 **************************************************************************/
00030
00031 //this part is only done once
00032 //if you need to use the GUID in another file, just include Guid.h
00033 #define INITGUID
00034 #include <initguid.h>
00035 #include <shlguid.h>
00036 #include "Guid.h"
00037
00038 /**************************************************************************
00039    private function prototypes
00040 **************************************************************************/
00041
00042 extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
00043 BOOL RegisterServer(CLSID, LPTSTR);
00044 BOOL RegisterComCat(CLSID, CATID);
00045 BOOL RegisterToolBand(CLSID);
00046
00047 /**************************************************************************
00048    global variables
00049 **************************************************************************/
00050
00051 HINSTANCE   g_hInst;
00052 UINT        g_DllRefCount;
00053
00054 /**************************************************************************
00055
00056    DllMain
00057
00058 **************************************************************************/
00059
00060 extern "C" BOOL WINAPI DllMain(  HINSTANCE hInstance,
00061                                  DWORD dwReason,
00062                                  LPVOID lpReserved)
00063 {
00064 switch(dwReason)
00065    {
00066    case DLL_PROCESS_ATTACH:
00067       g_hInst = hInstance;
00068       break;
00069
00070    case DLL_PROCESS_DETACH:
00071       break;
00072    }
00073
00074 return TRUE;
00075 }
00076
00077 /**************************************************************************
00078
00079    DllCanUnloadNow
00080
00081 **************************************************************************/
00082
00083 STDAPI DllCanUnloadNow(void)
00084 {
00085 return (g_DllRefCount ? S_FALSE : S_OK);
00086 }
00087
00088 /**************************************************************************
00089
00090    DllGetClassObject
00091
00092 **************************************************************************/
00093
00094 STDAPI DllGetClassObject(  REFCLSID rclsid,
00095                            REFIID riid,
00096                            LPVOID *ppReturn)
00097 {
00098 *ppReturn = NULL;
00099
00100 //if we don't support this classid, return the proper error code
00101 if(   !IsEqualCLSID(rclsid, CLSID_SampleDeskBand) &&
00102       !IsEqualCLSID(rclsid, CLSID_SampleExplorerBar) &&
00103       !IsEqualCLSID(rclsid, CLSID_SampleCommBand) &&
00104       !IsEqualCLSID(rclsid, CLSID_SampleToolBand))
00105    return CLASS_E_CLASSNOTAVAILABLE;
00106
00107 //create a CClassFactory object and check it for validity
00108 CClassFactory *pClassFactory = new CClassFactory(rclsid);
00109 if(NULL == pClassFactory)
00110    return E_OUTOFMEMORY;
00111
00112 //get the QueryInterface return for our return value
00113 HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn);
00114
00115 //call Release to decement the ref count - creating the object set it to one
00116 //and QueryInterface incremented it - since its being used externally (not by
00117 //us), we only want the ref count to be 1
00118 pClassFactory->Release();
00119
00120 //return the result from QueryInterface
00121 return hResult;
00122 }
00123
00124 /**************************************************************************
00125
00126    DllRegisterServer
00127
00128 **************************************************************************/
00129
00130 STDAPI DllRegisterServer(void)
00131 {
00132 //Register the desk band object.
00133 if(!RegisterServer(CLSID_SampleDeskBand, TEXT("Sample &Desk Band")))
00134    return SELFREG_E_CLASS;
00135
00136 //Register the component categories for the desk band object.
00137 if(!RegisterComCat(CLSID_SampleDeskBand, CATID_DeskBand))
00138    return SELFREG_E_CLASS;
00139
00140 //Register the explorer bar object.
00141 if(!RegisterServer(CLSID_SampleExplorerBar, TEXT("Sample &Explorer Bar")))
00142    return SELFREG_E_CLASS;
00143
00144 //Register the component categories for the explorer bar object.
00145 if(!RegisterComCat(CLSID_SampleExplorerBar, CATID_InfoBand))
00146    return SELFREG_E_CLASS;
00147
00148 //Register the comm band object.
00149 if(!RegisterServer(CLSID_SampleCommBand, TEXT("Sample &Comm Band")))
00150    return SELFREG_E_CLASS;
00151
00152 //Register the component categories for the comm band object.
00153 if(!RegisterComCat(CLSID_SampleCommBand, CATID_CommBand))
00154    return SELFREG_E_CLASS;
00155
00156 //Register the tool band object.
00157 if(!RegisterServer(CLSID_SampleToolBand, TEXT("Sample &Tool Band")))
00158    return SELFREG_E_CLASS;
00159
00160 //Register the tool band object.
00161 if(!RegisterToolBand(CLSID_SampleToolBand))
00162    return SELFREG_E_CLASS;
00163
00164 /*
00165 Remove the cache of the deskbands on Windows 2000. This will cause the new
00166 deskband to be displayed in the toolbar menu the next time the user brings it
00167 up. See KB article Q214842 for more information on this.
00168 */
00169 TCHAR    szSubKey[MAX_PATH];
00170 TCHAR    szCATID[MAX_PATH];
00171 LPWSTR   pwszCATID;
00172
00173 StringFromCLSID(CATID_DeskBand, &pwszCATID);
00174 if(pwszCATID)
00175    {
00176 #ifdef UNICODE
00177    lstrcpyn(szCATID, pwszCATID, ARRAYSIZE(szCATID));
00178 #else
00179    WideCharToMultiByte( CP_ACP,
00180                         0,
00181                         pwszCATID,
00182                         -1,
00183                         szCATID,
00184                         ARRAYSIZE(szCATID),
00185                         NULL,
00186                         NULL);
00187 #endif
00188
00189    //free the string
00190    CoTaskMemFree(pwszCATID);
00191
00192    wsprintf(szSubKey, TEXT("Component Categories\\%s\\Enum"), szCATID);
00193
00194    RegDeleteKey(HKEY_CLASSES_ROOT, szSubKey);
00195    }
00196
00197 return S_OK;
00198 }
00199
00200 /**************************************************************************
00201
00202    RegisterServer
00203
00204 **************************************************************************/
00205
00206 typedef struct{
00207    HKEY  hRootKey;
00208    LPTSTR szSubKey;//TCHAR szSubKey[MAX_PATH];
00209    LPTSTR lpszValueName;
00210    LPTSTR szData;//TCHAR szData[MAX_PATH];
00211 }DOREGSTRUCT, *LPDOREGSTRUCT;
00212
00213 BOOL RegisterServer(CLSID clsid, LPTSTR lpszTitle)
00214 {
00215 int      i;
00216 HKEY     hKey;
00217 LRESULT  lResult;
00218 DWORD    dwDisp;
00219 TCHAR    szSubKey[MAX_PATH];
00220 TCHAR    szCLSID[MAX_PATH];
00221 TCHAR    szModule[MAX_PATH];
00222 LPWSTR   pwsz;
00223
00224 //get the CLSID in string form
00225 StringFromIID(clsid, &pwsz);
00226
00227 if(pwsz)
00228    {
00229 #ifdef UNICODE
00230    lstrcpyn(szCLSID, pwsz, ARRAYSIZE(szCLSID));
00231 #else
00232    WideCharToMultiByte( CP_ACP,
00233                         0,
00234                         pwsz,
00235                         -1,
00236                         szCLSID,
00237                         ARRAYSIZE(szCLSID),
00238                         NULL,
00239                         NULL);
00240 #endif
00241
00242    //free the string
00243    CoTaskMemFree(pwsz);
00244    }
00245
00246 //get this app's path and file name
00247 GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule));
00248
00249 DOREGSTRUCT ClsidEntries[] = {HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s"),                  NULL,                   lpszTitle,
00250                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),  NULL,                   szModule,
00251                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),  TEXT("ThreadingModel"), TEXT("Apartment"),
00252                               NULL,                NULL,                               NULL,                   NULL};
00253
00254 //register the CLSID entries
00255 for(i = 0; ClsidEntries[i].hRootKey; i++)
00256    {
00257    //create the sub key string - for this case, insert the file extension
00258    wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID);
00259
00260    lResult = RegCreateKeyEx(  ClsidEntries[i].hRootKey,
00261                               szSubKey,
00262                               0,
00263                               NULL,
00264                               REG_OPTION_NON_VOLATILE,
00265                               KEY_WRITE,
00266                               NULL,
00267                               &hKey,
00268                               &dwDisp);
00269
00270    if(NOERROR == lResult)
00271       {
00272       TCHAR szData[MAX_PATH];
00273
00274       //if necessary, create the value string
00275       wsprintf(szData, ClsidEntries[i].szData, szModule);
00276
00277       lResult = RegSetValueEx(   hKey,
00278                                  ClsidEntries[i].lpszValueName,
00279                                  0,
00280                                  REG_SZ,
00281                                  (LPBYTE)szData,
00282                                  lstrlen(szData) + 1);
00283
00284       RegCloseKey(hKey);
00285       }
00286    else
00287       return FALSE;
00288    }
00289
00290 //If running on NT, register the extension as approved.
00291 OSVERSIONINFO  osvi;
00292
00293 osvi.dwOSVersionInfoSize = sizeof(osvi);
00294 GetVersionEx(&osvi);
00295
00296 if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
00297    {
00298    lstrcpyn( szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), ARRAYSIZE(szSubKey));
00299
00300    lResult = RegCreateKeyEx(  HKEY_LOCAL_MACHINE,
00301                               szSubKey,
00302                               0,
00303                               NULL,
00304                               REG_OPTION_NON_VOLATILE,
00305                               KEY_WRITE,
00306                               NULL,
00307                               &hKey,
00308                               &dwDisp);
00309
00310    if(NOERROR == lResult)
00311       {
00312       TCHAR szData[MAX_PATH];
00313
00314       //Create the value string.
00315       lstrcpyn(szData, lpszTitle, ARRAYSIZE(szData));
00316
00317       lResult = RegSetValueEx(   hKey,
00318                                  szCLSID,
00319                                  0,
00320                                  REG_SZ,
00321                                  (LPBYTE)szData,
00322                                  (lstrlen(szData) + 1) * sizeof(TCHAR));
00323
00324       RegCloseKey(hKey);
00325       }
00326    else
00327       return FALSE;
00328    }
00329
00330 return TRUE;
00331 }
00332
00333 /**************************************************************************
00334
00335    RegisterComCat
00336
00337 **************************************************************************/
00338
00339 BOOL RegisterComCat(CLSID clsid, CATID CatID)
00340 {
00341 ICatRegister   *pcr;
00342 HRESULT        hr = S_OK ;
00343
00344 CoInitialize(NULL);
00345
00346 hr = CoCreateInstance(  CLSID_StdComponentCategoriesMgr,
00347                         NULL,
00348                         CLSCTX_INPROC_SERVER,
00349                         IID_ICatRegister,
00350                         (LPVOID*)&pcr);
00351
00352 if(SUCCEEDED(hr))
00353    {
00354    hr = pcr->RegisterClassImplCategories(clsid, 1, &CatID);
00355
00356    pcr->Release();
00357    }
00358
00359 CoUninitialize();
00360
00361 return SUCCEEDED(hr);
00362 }
00363
00364 /**************************************************************************
00365
00366    RegisterToolBand
00367
00368 **************************************************************************/
00369
00370 BOOL RegisterToolBand(CLSID clsid)
00371 {
00372 HKEY     hKey;
00373 LRESULT  lResult;
00374 DWORD    dwDisp;
00375 TCHAR    szCLSID[MAX_PATH];
00376 LPWSTR   pwsz;
00377
00378 //get the CLSID in string form
00379 StringFromIID(clsid, &pwsz);
00380
00381 if(pwsz)
00382    {
00383 #ifdef UNICODE
00384    lstrcpyn(szCLSID, pwsz, ARRAYSIZE(szCLSID));
00385 #else
00386    WideCharToMultiByte( CP_ACP,
00387                         0,
00388                         pwsz,
00389                         -1,
00390                         szCLSID,
00391                         ARRAYSIZE(szCLSID),
00392                         NULL,
00393                         NULL);
00394 #endif
00395
00396    //free the string
00397    CoTaskMemFree(pwsz);
00398    }
00399
00400 lResult = RegCreateKeyEx(  HKEY_LOCAL_MACHINE,
00401                            TEXT("Software\\Microsoft\\Internet Explorer\\Toolbar"),
00402                            0,
00403                            NULL,
00404                            REG_OPTION_NON_VOLATILE,
00405                            KEY_WRITE,
00406                            NULL,
00407                            &hKey,
00408                            &dwDisp);
00409
00410 if(NOERROR == lResult)
00411    {
00412    TCHAR szData[] = TEXT("");
00413
00414    lResult = RegSetValueEx(   hKey,
00415                               szCLSID,
00416                               0,
00417                               REG_SZ,
00418                               (LPBYTE)szData,
00419                               lstrlen(szData) + 1);
00420
00421    RegCloseKey(hKey);
00422    }
00423 else
00424    return FALSE;
00425
00426 return TRUE;
00427 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRefClient Member List

This is the complete list of members for CRefClient, including all inherited members.
AddEnum() | CRefClient |
AddObjects() | CRefClient |
CRefClient() | CRefClient |
Initialize(IWbemServices *pNameSpace) | CRefClient |
m_Enum | CRefClient | [private]
m_Instances | CRefClient | [private]
m_pConfig | CRefClient | [private]
m_pNameSpace | CRefClient | [private]
m_pRefresher | CRefClient | [private]
Refresh() | CRefClient |
RemoveEnum() | CRefClient |
RemoveObjects() | CRefClient |
SetHandles() | CRefClient | [protected]
ShowEnumeratorData() | CRefClient |
ShowObjectData() | CRefClient |
~CRefClient() | CRefClient | [virtual]
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/delebase.Cpp Source File

  • SysMgmt
  • MMC
  • Taskpads

delebase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021
00022 const GUID CDelegationBase::thisGuid = { 0x2974380b, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 HBITMAP CDelegationBase::m_pBMapSm = NULL;
00025 HBITMAP CDelegationBase::m_pBMapLg = NULL;
00026
00027
00028 //==============================================================
00029 //
00030 // CDelegationBase implementation
00031 //
00032 //
00033 CDelegationBase::CDelegationBase()
00034 : bExpanded(FALSE)
00035
00036 {
00037     if (NULL == m_pBMapSm || NULL == m_pBMapLg)
00038         LoadBitmaps();
00039 }
00040
00041 CDelegationBase::~CDelegationBase()
00042 {
00043 }
00044
00045 // CDelegationBase::AddImages sets up the collection of images to be displayed
00046 // by the IComponent in the result pane as a result of its MMCN_SHOW handler
00047 HRESULT CDelegationBase::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
00048 {
00049     return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
00050         (long *)m_pBMapLg, // pointer to a handle
00051         0, // index of the first image in the strip
00052         RGB(0, 128, 128)  // color of the icon mask
00053         );
00054 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/basedialog.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

basedialog.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  BaseDialog.cpp: implementation of the CBaseDialog class.
00014 //
00015
00016 #include "BaseDialog.h"
00017 #include "Globals.h"
00018
00019
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 // Construction/Destruction
00023
00024 //---------------------------------------------------------------------------
00025 CBaseDialog::CBaseDialog( ULONG nTemplate )
00026 {
00027   _ASSERT( NULL != nTemplate );
00028
00029   m_nTemplate = nTemplate;
00030   m_hWnd      = NULL;          // Handle returned by CreateDialogParam
00031   m_DlgProc   = DlgProc;       // Point to default dialog proc
00032   m_dwFlags   = 0;
00033 }
00034
00035 //---------------------------------------------------------------------------
00036 CBaseDialog::~CBaseDialog()
00037 {
00038 }
00039
00040 //---------------------------------------------------------------------------
00041 //  Use CreateDialogParam rather than CreateDialog so that we can later
00042 //  retrieve the 'this' pointer which we will need to point back to the
00043 //  particular instance of this class.
00044 //
00045 HWND CBaseDialog::Create
00046 (
00047   HINSTANCE  hInstance,      //[in] Global instance handle
00048   HWND       hWndParent,     //[in] Handle to parent window
00049   DWORD      dwFlags         //[in] Create flags - not used
00050 )
00051 {
00052   _ASSERT( NULL != hInstance );
00053
00054   m_dwFlags = dwFlags;
00055   m_hWnd = CreateDialogParam( hInstance,
00056                               MAKEINTRESOURCE(m_nTemplate),
00057                               hWndParent,
00058                               m_DlgProc,
00059                               (LPARAM)this
00060                             );
00061
00062   BOOL bReturn = ShowWindow( m_hWnd, SW_SHOW );  // Should return 0
00063
00064   return m_hWnd;
00065 }
00066
00067
00068 /////////////////////////////////////////////////////////////////////////////
00069 //  Message Handlers
00070
00071 //---------------------------------------------------------------------------
00072 LRESULT CBaseDialog::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00073 {
00074   return 1;
00075 }
00076
00077 //---------------------------------------------------------------------------
00078 //  This is the first message sent by the DetroyWindow() function.
00079 //  It is sent after the window is removed from the screen, but it should
00080 //  be assumed that any child windows still exist.
00081 //
00082 LRESULT CBaseDialog::OnDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam )
00083 {
00084   return 1;
00085 }
00086
00087 //---------------------------------------------------------------------------
00088 //  This is sent after WM_DESTROY, and informs the app that the non-client
00089 //  area is being destroyed.  This is where allocated resources should be
00090 //  cleaned up.
00091 //
00092 LRESULT CBaseDialog::OnNcDestroy( HWND hDlg, WPARAM wParam, LPARAM lParam )
00093 {
00094   m_hWnd = NULL;             // Since this is a modeless-only dialog
00095   delete this;               // class we delete ourselves here
00096
00097   return 1;
00098 }
00099
00100 //---------------------------------------------------------------------------
00101 LRESULT CBaseDialog::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00102 {
00103   return DestroyWindow( m_hWnd);
00104 }
00105
00106 //---------------------------------------------------------------------------
00107 LRESULT CBaseDialog::OnCancel( HWND hDlg, WPARAM wParam, LPARAM lParam )
00108 {
00109   return DestroyWindow( m_hWnd);
00110 }
00111
00112 //---------------------------------------------------------------------------
00113 LRESULT CBaseDialog::OnClose( HWND hDlg, WPARAM wParam, LPARAM lParam )
00114 {
00115   return DestroyWindow( m_hWnd);
00116 }
00117
00118
00119 /////////////////////////////////////////////////////////////////////////////
00120 //  Dialog Procedures
00121
00122 //---------------------------------------------------------------------------
00123 //  Since this is a static function we can't use a 'this' pointer or call
00124 //  the base class directly.  There may be multiple base classes using
00125 //  this method.  We get around this by storing the 'this' pointer in the
00126 //  lParam of CreateDialogParam.  When we get WM_INITDIALOG we get this
00127 //  pointer back in the lParam.  Now we can use SetWindowLongPtr to store
00128 //  it, and later retireve it with GetWindowLongPtr.  Once we have a
00129 //  valid 'this' pointer we can cast it back to the base class and then
00130 //  call the base class's ProcessMessage function.
00131 //
00132 BOOL CALLBACK CBaseDialog::DlgProc
00133 (
00134   HWND     hDlg,           //[in] Handle to dialog box
00135   UINT     uMsg,           //[in] Message
00136   WPARAM   wParam,         //[in] First message parameter
00137   LPARAM   lParam          //[in] Second message parameter
00138 )
00139 {
00140   BOOL bReturn = FALSE;
00141   if( WM_INITDIALOG == uMsg )
00142   {
00143     SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
00144   }
00145
00146   CBaseDialog* pThis = reinterpret_cast<CBaseDialog*>(GetWindowLongPtr(hDlg, GWL_USERDATA));
00147   if( NULL != pThis )
00148   {
00149     bReturn = pThis->ProcessMessage( hDlg, uMsg, wParam, lParam );
00150   }
00151
00152   return bReturn;
00153 }
00154
00155 //---------------------------------------------------------------------------
00156 //  This is the instance specific method used to process messages.  The
00157 //  DialogProc delegates this responsibiliy to each instance of the class.
00158 //  This is a pure virtual function.  The code below is provided to cut
00159 //  and paste into the derived class's implementation.
00160 /*
00161 BOOL CBaseDialog::ProcessMessage
00162 (
00163   HWND     hDlg,           //[in] Handle to dialog box
00164   UINT     uMsg,           //[in] Message
00165   WPARAM   wParam,         //[in] First message parameter
00166   LPARAM   lParam          //[in] Second message parameter
00167 )
00168 {
00169   LRESULT lResult = 0;
00170   switch( uMsg )
00171   {
00172     case WM_INITDIALOG:
00173       lResult = OnInitDialog( hDlg, wParam, lParam );
00174       break;
00175
00176     case WM_DESTROY:
00177       lResult = OnDestroy( hDlg, wParam, lParam );
00178       break;
00179
00180     case WM_NCDESTROY:
00181       lResult = OnNcDestroy( hDlg, wParam, lParam );
00182       break;
00183
00184     case WM_CLOSE:
00185       lResult = OnClose( hDlg, wParam, lParam );
00186
00187     case WM_COMMAND:
00188       switch( wParam )
00189       {
00190         case IDOK:
00191           lResult = OnOK( hDlg, wParam, lParam );
00192           break;
00193
00194         case IDCANCEL:
00195           lResult = OnCancel( hDlg, wParam, lParam );
00196           break;
00197
00198         default:
00199           break;
00200       }
00201     default:
00202       break;
00203   }
00204   return (BOOL)lResult;
00205 }
00206 */
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/prsample/datasource.cpp Source File

  • Dataaccess
  • oledb
  • prsample

datasource.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 // Microsoft OLE DB Programmer's Reference Sample
00003 // Copyright (C) 1998 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module DATASOURCE.CPP
00008 //
00009 //---------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////
00016 #include "prsample.h"   // Programmer's Reference Sample includes
00017
00018
00019
00020 /////////////////////////////////////////////////////////////////
00021 // myCreateDataSource
00022 //
00023 //  This function creates an OLE DB DataSource object for a
00024 //  provider selected by the user, sets initialization properties
00025 //  for the DataSource, and initializes the DataSource. The
00026 //  function returns a pointer to the DataSource object's
00027 //  IUnknown in *ppUnkDataSource.
00028 //
00029 /////////////////////////////////////////////////////////////////
00030 HRESULT myCreateDataSource
00031   (
00032   IUnknown **       ppUnkDataSource
00033   )
00034 {
00035   HRESULT         hr;
00036   IDataInitialize *   pIDataInitialize      = NULL;
00037   IDBPromptInitialize * pIDBPromptInitialize    = NULL;
00038   IDBInitialize *     pIDBInitialize        = NULL;
00039   CLSID         clsid           = CLSID_MSDASQL;
00040
00041   // Use the Microsoft Data Links UI to create the DataSource
00042   // object; this will allow the user to select the provider
00043   // to connect to and to set the initialization properties
00044   // for the DataSource object, which will be created by the
00045   // Data Links UI.
00046   if( g_dwFlags & USE_PROMPTDATASOURCE )
00047   {
00048     // Create the Data Links UI object and obtain the
00049     // IDBPromptInitialize interface from it
00050     XCHECK_HR(hr = CoCreateInstance(
00051           CLSID_DataLinks,        //clsid -- Data Links UI
00052           NULL,             //pUnkOuter
00053           CLSCTX_INPROC_SERVER,     //dwClsContext
00054           IID_IDBPromptInitialize,    //riid
00055           (void**)&pIDBPromptInitialize //ppvObj
00056           ));
00057
00058     // Invoke the Data Links UI to allow the user to select
00059     // the provider and set initialization properties for
00060     // the DataSource object that this will create
00061     XCHECK_HR(hr = pIDBPromptInitialize->PromptDataSource(
00062           NULL,             //pUnkOuter
00063           GetDesktopWindow(),       //hWndParent
00064           DBPROMPTOPTIONS_PROPERTYSHEET,  //dwPromptOptions
00065           0,                //cSourceTypeFilter
00066           NULL,             //rgSourceTypeFilter
00067           NULL,             //pwszszzProviderFilter
00068           IID_IDBInitialize,        //riid
00069           (IUnknown**)&pIDBInitialize   //ppDataSource
00070           ));
00071
00072     // We've obtained a DataSource object from the Data Links UI. This
00073     // object has had its initialization properties set, so all we
00074     // need to do is Initialize it
00075     XCHECK_HR(hr = pIDBInitialize->Initialize());
00076   }
00077   // We are not using the Data Links UI to create the DataSource object.
00078   // Instead, we will enumerate the providers installed on this system
00079   // through the OLE DB Enumerator and will allow the user to select
00080   // the ProgID of the provider for which we will create a DataSource
00081   // object.
00082   else
00083   {
00084     // Use the OLE DB Enumerator to obtain a rowset of installed providers,
00085     // then allow the user to select a provider from this rowset
00086     CHECK_HR(hr = myCreateEnumerator(CLSID_OLEDB_ENUMERATOR, &clsid));
00087
00088     // We will create the DataSource object through the OLE DB service
00089     // component IDataInitialize interface, so we need to create an
00090     // instance of the data initialization object
00091     XCHECK_HR(hr = CoCreateInstance(
00092           CLSID_MSDAINITIALIZE,     //clsid -- data initialize
00093           NULL,             //pUnkOuter
00094           CLSCTX_INPROC_SERVER,     //dwClsContext
00095           IID_IDataInitialize,      //riid
00096           (void**)&pIDataInitialize   //ppvObj
00097           ));
00098
00099     // Use IDataInitialize::CreateDBInstance to create an uninitialized
00100     // DataSource object for the chosen provider. By using this service
00101     // component method, the service component manager can provide
00102     // additional functionality beyond what is natively supported by the
00103     // provider if the consumer requests that functionality
00104     XCHECK_HR(hr = pIDataInitialize->CreateDBInstance(
00105           clsid,              //clsid -- provider
00106           NULL,             //pUnkOuter
00107           CLSCTX_INPROC_SERVER,     //dwClsContext
00108           NULL,             //pwszReserved
00109           IID_IDBInitialize,        //riid
00110           (IUnknown**)&pIDBInitialize   //ppDataSource
00111           ));
00112
00113     // Initialize the DataSource object by setting any required
00114     // initialization properties and calling IDBInitialize::Initialize
00115     CHECK_HR(hr = myDoInitialization(pIDBInitialize));
00116   }
00117
00118 CLEANUP:
00119   *ppUnkDataSource = pIDBInitialize;
00120   if( pIDataInitialize )
00121     pIDataInitialize->Release();
00122   if( pIDBPromptInitialize )
00123     pIDBPromptInitialize->Release();
00124   return hr;
00125 }
00126
00127
00128 /////////////////////////////////////////////////////////////////
00129 // myDoInitialization
00130 //
00131 //  This function sets initialization properties that tell the
00132 //  provider to prompt the user for any information required to
00133 //  initialize the provider, then calls the provider's
00134 //  initialization function.
00135 //
00136 /////////////////////////////////////////////////////////////////
00137 HRESULT myDoInitialization
00138   (
00139   IUnknown *        pIUnknown
00140   )
00141 {
00142   HRESULT         hr;
00143   IDBInitialize *     pIDBInitialize        = NULL;
00144   IDBProperties *     pIDBProperties        = NULL;
00145   HWND          hWnd            = GetDesktopWindow();
00146
00147   const ULONG       cProperties         = 2;
00148   DBPROP          rgProperties[cProperties];
00149   DBPROPSET       rgPropSets[1];
00150
00151   // In order to initialize the DataSource object most providers require
00152   // some initialization properties to be set by the consumer. For instance,
00153   // these might include the data source to connect to and the user ID and
00154   // password to use to establish identity. We will ask the provider to
00155   // prompt the user for this required information by setting the following
00156   // properties:
00157   myAddProperty(&rgProperties[0],DBPROP_INIT_PROMPT,VT_I2,DBPROMPT_COMPLETE);
00158   myAddProperty(&rgProperties[1],DBPROP_INIT_HWND,  VT_I4,(LONG)hWnd);
00159
00160   rgPropSets[0].rgProperties    = rgProperties;
00161   rgPropSets[0].cProperties   = cProperties;
00162   rgPropSets[0].guidPropertySet = DBPROPSET_DBINIT;
00163
00164   // Obtain the needed interfaces
00165   XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IDBProperties,
00166         (void**)&pIDBProperties));
00167   XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IDBInitialize,
00168         (void**)&pIDBInitialize));
00169
00170   // If a provider requires initialization properties, it must support the
00171   // properties that we are setting (_PROMPT and _HWND). However, some
00172   // providers do not need initialization properties and may therefore
00173   // not support the _PROMPT and _HWND properties. Because of this, we will
00174   // not check the return value from SetProperties
00175   hr = pIDBProperties->SetProperties(1, rgPropSets);
00176
00177   // Now that we've set our properties, initialize the provider
00178   XCHECK_HR(hr = pIDBInitialize->Initialize());
00179
00180 CLEANUP:
00181   if( pIDBProperties )
00182     pIDBProperties->Release();
00183   if( pIDBInitialize )
00184     pIDBInitialize->Release();
00185   return hr;
00186 }
00187
00188
00189
00190 /////////////////////////////////////////////////////////////////
00191 // myGetProperty
00192 //
00193 //  This function gets the BOOL value for the specified property
00194 //  and returns the result in *pbValue.
00195 //
00196 /////////////////////////////////////////////////////////////////
00197 HRESULT myGetProperty
00198   (
00199   IUnknown *        pIUnknown,
00200   REFIID          riid,
00201   DBPROPID        dwPropertyID,
00202   REFGUID         guidPropertySet,
00203   BOOL *          pbValue
00204   )
00205 {
00206   HRESULT         hr;
00207   DBPROPID        rgPropertyIDs[1];
00208   DBPROPIDSET       rgPropertyIDSets[1];
00209
00210   ULONG         cPropSets         = 0;
00211   DBPROPSET *       rgPropSets          = NULL;
00212
00213   IDBProperties *     pIDBProperties        = NULL;
00214   ISessionProperties *  pISesProps          = NULL;
00215   ICommandProperties *  pICmdProps          = NULL;
00216   IRowsetInfo *     pIRowsetInfo        = NULL;
00217
00218   // Initialize the output value
00219   *pbValue = FALSE;
00220
00221   // Set up the property ID array
00222   rgPropertyIDs[0] = dwPropertyID;
00223
00224   // Set up the Property ID Set
00225   rgPropertyIDSets[0].rgPropertyIDs = rgPropertyIDs;
00226   rgPropertyIDSets[0].cPropertyIDs  = 1;
00227   rgPropertyIDSets[0].guidPropertySet = guidPropertySet;
00228
00229   // Get the property value for this property from the provider, but
00230   // don't try to display extended error information, since this may
00231   // not be a supported property: a failure is, in fact, expected if
00232   // the property is not supported
00233   if( riid == IID_IDBProperties )
00234   {
00235     XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IDBProperties,
00236           (void**)&pIDBProperties));
00237     CHECK_HR(hr = pIDBProperties->GetProperties(
00238           1,          //cPropertyIDSets
00239           rgPropertyIDSets, //rgPropertyIDSets
00240           &cPropSets,     //pcPropSets
00241           &rgPropSets     //prgPropSets
00242           ));
00243   }
00244   else if( riid == IID_ISessionProperties )
00245   {
00246     XCHECK_HR(hr = pIUnknown->QueryInterface(IID_ISessionProperties,
00247           (void**)&pISesProps));
00248     CHECK_HR(hr = pISesProps->GetProperties(
00249           1,          //cPropertyIDSets
00250           rgPropertyIDSets, //rgPropertyIDSets
00251           &cPropSets,     //pcPropSets
00252           &rgPropSets     //prgPropSets
00253           ));
00254   }
00255   else if( riid == IID_ICommandProperties )
00256   {
00257     XCHECK_HR(hr = pIUnknown->QueryInterface(IID_ICommandProperties,
00258           (void**)&pICmdProps));
00259     CHECK_HR(hr = pICmdProps->GetProperties(
00260           1,          //cPropertyIDSets
00261           rgPropertyIDSets, //rgPropertyIDSets
00262           &cPropSets,     //pcPropSets
00263           &rgPropSets     //prgPropSets
00264           ));
00265   }
00266   else
00267   {
00268     XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IRowsetInfo,
00269           (void**)&pIRowsetInfo));
00270     CHECK_HR(hr = pIRowsetInfo->GetProperties(
00271           1,          //cPropertyIDSets
00272           rgPropertyIDSets, //rgPropertyIDSets
00273           &cPropSets,     //pcPropSets
00274           &rgPropSets     //prgPropSets
00275           ));
00276   }
00277
00278   // Return the value for this property to the caller if
00279   // it's a VT_BOOL type value, as expected
00280   if( V_VT(&rgPropSets[0].rgProperties[0].vValue) == VT_BOOL )
00281     *pbValue = V_BOOL(&rgPropSets[0].rgProperties[0].vValue);
00282
00283 CLEANUP:
00284   if( rgPropSets )
00285   {
00286     CoTaskMemFree(rgPropSets[0].rgProperties);
00287     CoTaskMemFree(rgPropSets);
00288   }
00289   if( pIDBProperties )
00290     pIDBProperties->Release();
00291   if( pISesProps )
00292     pISesProps->Release();
00293   if( pICmdProps )
00294     pICmdProps->Release();
00295   if( pIRowsetInfo )
00296     pIRowsetInfo->Release();
00297   return hr;
00298 }
00299
00300
00301
00302 /////////////////////////////////////////////////////////////////
00303 // myAddProperty
00304 //
00305 //  This function initializes the property structure pProp
00306 //
00307 /////////////////////////////////////////////////////////////////
00308 void myAddProperty
00309   (
00310   DBPROP *        pProp,
00311   DBPROPID        dwPropertyID,
00312   VARTYPE         vtType,
00313   LONG          lValue,
00314   DBPROPOPTIONS     dwOptions
00315   )
00316 {
00317   // Set up the property structure
00318   pProp->dwPropertyID   = dwPropertyID;
00319   pProp->dwOptions    = dwOptions;
00320   pProp->dwStatus     = DBPROPSTATUS_OK;
00321   pProp->colid      = DB_NULLID;
00322   V_VT(&pProp->vValue)  = vtType;
00323
00324   // Since VARIANT data is a union, we can place the value in any
00325   // member (except for VT_DECIMAL, which is a union with the whole
00326   // VARIANT structure -- but we know we're not passing VT_DECIMAL)
00327   V_I4(&pProp->vValue)  = lValue;
00328 }
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/irowset.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

irowset.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module IROWSET.CPP | IRowset interface implementation
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014
00015 // Code ----------------------------------------------------------------------
00016
00017 //  IRowset specific interface methods
00018
00019 // CImpIRowset::GetData --------------------------------------------------
00020 //
00021 // @mfunc Retrieves data from the rowset's cache
00022 //
00023 // @rdesc Returns one of the following values:
00024 //      @flag S_OK                   | Method Succeeded
00025 //      @flag DB_S_ERRORSOCCURED     | Could not coerce a column value
00026 //      @flag DB_E_BADACCESSORHANDLE | Invalid Accessor given
00027 //      @flag DB_E_BADROWHANDLE      | Invalid row handle given
00028 //      @flag E_INVALIDARG           | pData was NULL
00029 //      @flag OTHER                  | Other HRESULTs returned by called functions
00030 //
00031 STDMETHODIMP CImpIRowset::GetData
00032     (
00033     HROW        hRow,       //@parm IN | Row Handle
00034     HACCESSOR   hAccessor,  //@parm IN | Accessor to use
00035     void       *pData       //@parm OUT | Pointer to buffer where data should go.
00036     )
00037 {
00038     PACCESSOR   pAccessor;
00039     DBORDINAL   cCols;
00040   DBORDINAL   cBind;
00041     ROWBUFF     *pRowBuff;
00042     COLUMNDATA    *pColumnData;
00043     DBBINDING   *pBinding;
00044     DBCOUNTITEM   cBindings;
00045     DBORDINAL   cErrorCount;
00046     DBTYPE      dwSrcType;
00047     DBTYPE      dwDstType;
00048     void      *pSrc;
00049     void      *pDst;
00050     DBBYTEOFFSET  ulSrcLength;
00051     DBLENGTH*   pulDstLength;
00052     DBLENGTH    cbDstMaxLength;
00053     ULONG     dwSrcStatus;
00054     ULONG     *pdwDstStatus;
00055     DWORD     dwPart;
00056     HRESULT     hr;
00057
00058   DBCOLUMNINFO *  rgdbcolumninfo = NULL;
00059
00060     // Coerce data for row 'hRow', according to hAccessor.
00061     // Put in location 'pData'.  Offsets and types are in hAccessor's bindings.
00062     //
00063   // Return S_OK if all columns retrieved with successful status
00064     // Return DB_S_ERRORSOCCURED on failure to retrieve one or more column values
00065     // Return DB_E_ERRORSOCCURED on failure to retrieve all column values
00066
00067     // GetItemOfExtBuffer is basically operator[].
00068     // It takes an index (or handle) (referenced from 1...n),
00069     // and a ptr for where to write the data.
00070     //
00071     // It holds ptrs to a variable-length ACCESSOR struct.
00072     // So we get the ACCESSOR ptr for the client's accessor handle.
00073
00074     assert( m_pObj->m_pextbufferAccessor );
00075     m_pObj->m_pextbufferAccessor->GetItemOfExtBuffer(hAccessor, &pAccessor);
00076     if( !pAccessor )
00077         return DB_E_BADACCESSORHANDLE;
00078
00079     assert( pAccessor );
00080     cBindings = pAccessor->cBindings;
00081     pBinding  = pAccessor->rgBindings;
00082
00083     // IsSlotSet returns S_OK    if row is marked.
00084     //                   S_FALSE if row is not marked.
00085     // The "mark" means that there is data present in the row.
00086     // Rows are [1...n], slot marks are [0...n-1].
00087     if (m_pObj->m_prowbitsIBuffer->IsSlotSet( (ULONG) hRow ) != S_OK)
00088         return ResultFromScode( DB_E_BADROWHANDLE );
00089
00090   // Ensure a place to put data, unless the accessor is the null accessor then
00091     // a NULL pData is okay.
00092     if ( pData == NULL && cBindings != 0 )
00093         return ResultFromScode( E_INVALIDARG );
00094
00095   // Check to see if we have a DC
00096   if( !g_pIDataConvert)
00097     return (E_FAIL);
00098
00099     // Internal error for a 0 reference count on this row,
00100     // since we depend on the slot-set stuff.
00101     pRowBuff = m_pObj->GetRowBuff( (DBCOUNTITEM) hRow, TRUE );
00102     assert( pRowBuff->ulRefCount );
00103
00104   // Check for the Deleted Row
00105   if ( m_pObj->m_pFileio->IsDeleted( (DBBKMARK) pRowBuff->pbBmk ) == S_OK )
00106         return ResultFromScode( DB_E_DELETEDROW );
00107
00108     cErrorCount = 0;
00109   rgdbcolumninfo = m_pObj->m_pFileio->GetColInfo();
00110     for (cBind=0; cBind < cBindings; cBind++)
00111   {
00112     cCols = pBinding[cBind].iOrdinal;
00113
00114         // make sure column number is in range
00115         if ( !(0 < cCols && cCols <= m_pObj->m_cCols) )
00116             return ResultFromScode( DB_E_BADORDINAL );
00117
00118         pColumnData    = m_pObj->m_pFileio->GetColumnData(cCols, pRowBuff);
00119
00120         dwSrcType      = rgdbcolumninfo[cCols].wType;
00121         pSrc           = &(pColumnData->bData);
00122         ulSrcLength    = pColumnData->dwLength;
00123         dwSrcStatus    = pColumnData->dwStatus;
00124         cbDstMaxLength = pBinding[cBind].cbMaxLen;
00125         dwDstType      = pBinding[cBind].wType;
00126         dwPart         = pBinding[cBind].dwPart;
00127
00128         pDst           = dwPart & DBPART_VALUE ? ((BYTE *) pData + pBinding[cBind].obValue) : NULL;
00129         pulDstLength   = dwPart & DBPART_LENGTH ? (DBLENGTH *) ((BYTE*) pData + pBinding[cBind].obLength) : NULL;
00130         pdwDstStatus   = dwPart & DBPART_STATUS ? (ULONG *) ((BYTE*) pData + pBinding[cBind].obStatus) : NULL;
00131
00132         hr = g_pIDataConvert->DataConvert(
00133                 dwSrcType,
00134                 dwDstType,
00135                 ulSrcLength,
00136                 pulDstLength,
00137                 pSrc,
00138                 pDst,
00139                 cbDstMaxLength,
00140                 dwSrcStatus,
00141                 pdwDstStatus,
00142                 pBinding[cBind].bPrecision, // bPrecision for conversion to DBNUMERIC
00143         pBinding[cBind].bScale,   // bScale for conversion to DBNUMERIC
00144         DBDATACONVERT_DEFAULT);
00145
00146     // rounding or truncation or can't coerce
00147     if (hr != S_OK)
00148             cErrorCount++;
00149   }
00150
00151     // We report any lossy conversions with a special status.
00152     // Note that DB_S_ERRORSOCCURED is a success, rather than failure.
00153   return cErrorCount ? ( cErrorCount < cBindings ) ?
00154     ( DB_S_ERRORSOCCURRED ) : ( DB_E_ERRORSOCCURRED ) : ( S_OK );
00155 }
00156
00157
00158
00159 // CImpIRowset::GetNextRows --------------------------------------------------
00160 //
00161 // @mfunc Fetches rows in a sequential style, remembering the previous position
00162 //
00163 // @rdesc Returns one of the following values:
00164 //      @flag S_OK                      | Method Succeeded
00165 //      @flag DB_S_ENDOFROWSET          | Reached end of rowset
00166 //      @flag DB_E_CANTFETCHBACKWARDS   | cRows was negative and we can't fetch backwards
00167 //      @flag DB_E_ROWSNOTRELEASED      | Must release all HROWs before calling GetNextRows
00168 //      @flag E_FAIL                    | Provider-specific error
00169 //      @flag E_INVALIDARG              | pcRowsObtained or prghRows was NULL
00170 //      @flag E_OUTOFMEMORY             | Out of Memory
00171 //      @flag OTHER                     | Other HRESULTs returned by called functions
00172 //
00173 STDMETHODIMP CImpIRowset::GetNextRows
00174     (
00175     HCHAPTER    hChapter,        //@parm IN | The Chapter handle.
00176     DBROWOFFSET lRowOffset,      //@parm IN | Rows to skip before reading
00177     DBROWCOUNT  cRows,           //@parm IN | Number of rows to fetch
00178     DBCOUNTITEM *pcRowsObtained, //@parm OUT | Number of rows obtained
00179     HROW        **prghRows       //@parm OUT | Array of Hrows obtained
00180     )
00181 {
00182     ULONG   cRowsTmp;
00183     ULONG   cSlotAlloc =0;
00184     DBROWCOUNT  irow, ih;
00185     ULONG   cRowFirst, cRowLast;
00186     PROWBUFF  prowbuff;
00187     HRESULT   hr;
00188   BOOL    fCanHoldRows = FALSE;
00189   DBPROPIDSET rgPropertyIDSets[1];
00190   ULONG   cPropertySets;
00191   DBPROPSET*  prgPropertySets;
00192   DBPROPID  rgPropId[1];
00193
00194
00195     // init out-params
00196   if ( pcRowsObtained )
00197     *pcRowsObtained = 0;
00198
00199     // Check validity of arguments.
00200     if ( pcRowsObtained == NULL || prghRows == NULL )
00201         return ResultFromScode( E_INVALIDARG );
00202
00203     // No-op case always succeeds.
00204     if ( cRows == 0 )
00205         return ResultFromScode( S_OK );
00206
00207     // This implementation doesn't support scrolling backward.
00208     if ( cRows < 0 )
00209         return ResultFromScode( DB_E_CANTFETCHBACKWARDS );
00210
00211     // This implementation doesn't support scrolling backward.
00212     if ( lRowOffset < 0 )
00213         return ResultFromScode( DB_E_CANTSCROLLBACKWARDS );
00214
00215     // Get the value of the DBPROP_CANHOLDROWS property
00216   rgPropertyIDSets[0].guidPropertySet = DBPROPSET_ROWSET;
00217   rgPropertyIDSets[0].rgPropertyIDs = rgPropId;
00218   rgPropertyIDSets[0].cPropertyIDs  = 1;
00219   rgPropId[0]             = DBPROP_CANHOLDROWS;
00220
00221     m_pObj->m_pUtilProp->GetProperties(
00222                   PROPSET_ROWSET,
00223                   1,
00224                   rgPropertyIDSets,
00225                   &cPropertySets,
00226                   &prgPropertySets );
00227
00228   // Get the Prompt value
00229   if( V_BOOL(&prgPropertySets->rgProperties->vValue) == VARIANT_TRUE )
00230     fCanHoldRows = TRUE;
00231
00232   // Free the memory
00233   SAFE_FREE(prgPropertySets[0].rgProperties);
00234   SAFE_FREE(prgPropertySets);
00235
00236     // Are there any unreleased rows?
00237     if( ((m_pObj->m_prowbitsIBuffer)->ArrayEmpty() != S_OK) && (!fCanHoldRows) )
00238         return ResultFromScode( DB_E_ROWSNOTRELEASED );
00239
00240     // Is the cursor fully materialized (end-of-cursor condition)?
00241     if (m_pObj->m_dwStatus & STAT_ENDOFCURSOR)
00242         return ResultFromScode( DB_S_ENDOFROWSET );
00243
00244     assert( m_pObj->m_rgbRowData );
00245     if (FAILED( m_pObj->Rebind((BYTE *) m_pObj->GetRowBuff( m_pObj->m_irowMin, TRUE ))))
00246         return ResultFromScode( E_FAIL );
00247
00248     //
00249     // Fetch Data
00250     //
00251     if (lRowOffset)
00252         {
00253         // Calculate the new position
00254         m_pObj->m_irowFilePos += lRowOffset;
00255
00256         // Check if skip causes END_OF_ROWSET
00257         if (m_pObj->m_irowFilePos > m_pObj->m_pFileio->GetRowCnt() ||
00258             m_pObj->m_irowFilePos <= 0)
00259             {
00260             m_pObj->m_dwStatus |= STAT_ENDOFCURSOR;
00261             return ResultFromScode( DB_S_ENDOFROWSET );
00262             }
00263         }
00264
00265   if (FAILED( hr = GetNextSlots( m_pObj->m_pIBuffer, (ULONG)cRows, &cRowFirst )))
00266         return hr;
00267
00268     cSlotAlloc = (ULONG)cRows;
00269
00270     for (irow =1; irow <= cRows; irow++)
00271         {
00272     // Setup the row
00273     prowbuff = m_pObj->GetRowBuff( cRowFirst + irow - 1, TRUE );
00274     memset(prowbuff->cdData, 0, m_pObj->m_cbRowSize);
00275     if (FAILED( m_pObj->Rebind((BYTE *) prowbuff)))
00276       return ResultFromScode( E_FAIL );
00277
00278     // Get the Data from the File into the row buffer
00279         if (S_FALSE == ( hr = m_pObj->m_pFileio->Fetch( m_pObj->m_irowFilePos + irow )))
00280             {
00281             m_pObj->m_dwStatus |= STAT_ENDOFCURSOR;
00282             break;
00283             }
00284         else
00285             {
00286             if (FAILED( hr ))
00287                 return ResultFromScode( E_FAIL );
00288             }
00289         }
00290
00291     cRowsTmp = (ULONG)(irow - 1); //Irow will be +1 because of For Loop
00292     m_pObj->m_irowLastFilePos = m_pObj->m_irowFilePos;
00293     m_pObj->m_irowFilePos += cRowsTmp;
00294
00295
00296     //
00297     // Through fetching many rows of data
00298     //
00299     // Allocate row handles for client.
00300     // Note that we need to use IMalloc for this.
00301     //
00302     // Should only malloc cRowsTmp, instead of cRows.
00303     //
00304     // Modified to use IMalloc.
00305     // Should malloc cRows, since client will assume it's that big.
00306     //
00307
00308     *pcRowsObtained = cRowsTmp;
00309
00310   if ( *prghRows == NULL && cRowsTmp )
00311         *prghRows = (HROW *) PROVIDER_ALLOC( cRows*sizeof( HROW ));
00312
00313     if ( *prghRows == NULL  && cRowsTmp )
00314         return ResultFromScode( E_OUTOFMEMORY );
00315
00316     //
00317     // Fill in the status information: Length, IsNull
00318     // May be able to wait until first call to GetData,
00319     // but have to do it sometime.
00320     //
00321     // Suggest keeping an array of structs of accessor info.
00322     // One element is whether accessor requires any status info or length info.
00323     // Then we could skip this whole section.
00324     //
00325     // Added check for cRowsTmp to MarkRows call.
00326     // Don't want to call if cRowsTmp==0.
00327     // (Range passed to MarkRows is inclusive, so can't specify marking 0 rows.)
00328     //
00329     // Note that SetSlots is a CBitArray member function -- not an IBuffer function.
00330     //
00331     // Bits are [0...n-1], row handles are [1...n].
00332     //
00333     // Cleanup. Row handles, bits, indices are the same [m....(m+n)], where m is some # >0,
00334     //
00335     // Added row-wise reference counts and cursor-wise reference counts.
00336     //
00337
00338     // Set row handles, fix data length field and compute data status field.//
00339     m_pObj->m_cRows   = cRowsTmp;
00340     cRowLast = cRowFirst + cRowsTmp - 1;
00341
00342     // Cleanup extra slots where no hRow actually was put..
00343     //  ** Because of less rows than asked for
00344     //  ** Because of temporary for for data transfer.
00345     if (cSlotAlloc > (cRowsTmp))
00346         if (FAILED( hr = ReleaseSlots( m_pObj->m_pIBuffer, cRowFirst + cRowsTmp, (cSlotAlloc - cRowsTmp))))
00347             return hr;
00348
00349     for (irow = (LONG) (cRowFirst), ih =0; irow <= (LONG) cRowLast; irow++, ih++)
00350         {
00351         // Increment the rows-read count,
00352         // then store it as the bookmark in the very first DWORD of the row.
00353         prowbuff = m_pObj->GetRowBuff( irow, TRUE );
00354
00355         // Insert the bookmark and its row number (from 1...n) into a hash table.
00356         // This allows us to quickly determine the presence of a row in mem, given the bookmark.
00357         // The bookmark is contained in the row buffer, at the very beginning.
00358         // Bookmark is the row number within the entire result set [1...num_rows_read].
00359
00360         // This was a new Bookmark, not in memory,
00361         // so return to user (in *prghRows) the hRow we stored.
00362         prowbuff->ulRefCount++;
00363         prowbuff->pbBmk = (BYTE*) m_pObj->m_irowLastFilePos + ih + 1;
00364         m_pObj->m_ulRowRefCount++;
00365
00366         (*prghRows)[ih] = (HROW) ( irow );
00367         }
00368
00369     if (m_pObj->m_dwStatus & STAT_ENDOFCURSOR)
00370         return ResultFromScode( DB_S_ENDOFROWSET );
00371     else
00372         return ResultFromScode( S_OK );
00373 }
00374
00375
00376
00377 // CImpIRowset::ReleaseRows ---------------------------------------
00378 //
00379 // @mfunc Releases row handles
00380 //
00381 // @rdesc Returns one of the following values:
00382 //      @flag S_OK            | success
00383 //      @flag DB_S_ERRORSOCCURRED   | some elements of rghRows were invalid
00384 //      @flag DB_E_ERRORSOCCURRED   | all elements of rghRows were invalid
00385 //      @flag E_INVALIDARG        | rghRows was a NULL pointer and crow > 0
00386 //
00387 STDMETHODIMP CImpIRowset::ReleaseRows
00388     (
00389     DBCOUNTITEM   cRows,          //@parm IN | Number of rows to release
00390     const HROW    rghRows[],      //@parm IN | Array of handles of rows to be released
00391   DBROWOPTIONS  rgRowOptions[], //@parm IN | Additional Options
00392   DBREFCOUNT    rgRefCounts[],  //@parm OUT | array of ref counts of released rows
00393   DBROWSTATUS   rgRowStatus[] //@parm OUT | status array of for input rows
00394     )
00395 {
00396     HRESULT hr        = S_OK;
00397     DBCOUNTITEM chRow   = 0L;
00398     DBCOUNTITEM cErrors   = 0L;
00399     ROWBUFF     *pRowBuff = NULL;
00400
00401     // check params
00402     if ( cRows && !rghRows )
00403         return ResultFromScode( E_INVALIDARG );
00404
00405     while ( chRow < cRows )
00406   {
00407         // check the row handle
00408     hr = (m_pObj->m_prowbitsIBuffer)->IsSlotSet((ULONG) rghRows[chRow]);
00409         if ( (hr == S_OK) && (m_pObj->m_ulRowRefCount) &&
00410        (pRowBuff=m_pObj->GetRowBuff((DBCOUNTITEM) rghRows[chRow], TRUE)) &&
00411        (pRowBuff->ulRefCount) )
00412     {
00413             // Found valid row, so decrement reference counts.
00414             // (Internal error for refcount to be 0 here, since slot set.)
00415             --pRowBuff->ulRefCount;
00416             --m_pObj->m_ulRowRefCount;
00417
00418       // stuff new refcount into caller's array
00419       if ( rgRefCounts )
00420         rgRefCounts[chRow] = pRowBuff->ulRefCount;
00421
00422       if ( rgRowStatus )
00423         rgRowStatus[chRow] = DBROWSTATUS_S_OK;
00424
00425             if ( pRowBuff->ulRefCount == 0 )
00426                 ReleaseSlots( m_pObj->m_pIBuffer, (ULONG) rghRows[chRow], 1 );
00427     }
00428         else
00429     {
00430             // It is an error for client to try to release a row
00431             // for which "IsSetSlot" is false.  Client gave us an invalid handle.
00432             // Ignore it (we can't release it...) and report error when done.
00433       if ( rgRefCounts )
00434         rgRefCounts[chRow] = 0;
00435
00436       if ( rgRowStatus )
00437         rgRowStatus[chRow] = DBROWSTATUS_E_INVALID;
00438
00439             ++ cErrors;
00440     }
00441
00442     chRow++;
00443   }
00444
00445   // If everything went OK except errors in rows use DB_S_ERRORSOCCURRED.
00446   return cErrors ? ( cErrors < cRows ) ?
00447       ResultFromScode( DB_S_ERRORSOCCURRED ) :
00448       ResultFromScode( DB_E_ERRORSOCCURRED ) :
00449       ResultFromScode( S_OK );
00450 }
00451
00452
00453
00454
00455
00456
00457 // CImpIRowset::ResartPosition ---------------------------------------
00458 //
00459 // @mfunc Repositions the next fetch position to the start of the rowset
00460 //
00461 // - all rows must be released before calling this method
00462 // - it is not expensive to Restart us, because we are from a single table
00463 //
00464 //
00465 // @rdesc Returns one of the following values:
00466 //      @flag S_OK                  | Method Succeeded
00467 //      @flag DB_E_ROWSNOTRELEASED  | All HROWs must be released before calling
00468 //
00469 STDMETHODIMP CImpIRowset::RestartPosition
00470     (
00471     HCHAPTER    hChapter        //@parm IN | The Chapter handle.
00472     )
00473 {
00474   // make sure all rows have been released
00475   // Fail even if CANHOLDROWS is true
00476     if( ((m_pObj->m_prowbitsIBuffer)->ArrayEmpty() != S_OK) )
00477         return ResultFromScode( DB_E_ROWSNOTRELEASED );
00478
00479     // set "next fetch" position to the start of the rowset
00480   m_pObj->m_irowFilePos = 0;
00481
00482     // clear "end of cursor" flag
00483     m_pObj->m_dwStatus &= ~STAT_ENDOFCURSOR;
00484
00485     return ResultFromScode( S_OK );
00486 }
00487
00488
00489 // CImpIRowset::AddRefRows --------------------------------------------------
00490 //
00491 // @mfunc Adds a reference count to an existing row handle
00492 //
00493 // @rdesc Returns one of the following values:
00494 //      @flag S_OK            | success
00495 //      @flag DB_S_ERRORSOCCURRED   | some elements of rghRows were invalid
00496 //      @flag DB_E_ERRORSOCCURRED   | all elements of rghRows were invalid
00497 //      @flag E_INVALIDARG        | rghRows was a NULL pointer and crow > 0
00498
00499 STDMETHODIMP  CImpIRowset::AddRefRows
00500     (
00501     DBCOUNTITEM     cRows,          // @parm IN     | Number of rows to refcount
00502     const HROW      rghRows[],      // @parm IN     | Array of row handles to refcount
00503     DBREFCOUNT    rgRefCounts[],  // @parm OUT    | Array of refcounts
00504     DBROWSTATUS     rgRowStatus[]   // @parm OUT    | Array of row status
00505     )
00506 {
00507     HRESULT hr        = S_OK;
00508     DBCOUNTITEM chRow   = 0L;
00509     DBCOUNTITEM cErrors   = 0L;
00510     ROWBUFF     *pRowBuff = NULL;
00511
00512     // check params
00513     if ( cRows && !rghRows )
00514         return ResultFromScode( E_INVALIDARG );
00515
00516     // for each of the HROWs the caller provided...
00517     for (chRow = 0; chRow < cRows; chRow++)
00518   {
00519         // check the row handle
00520     if( ((m_pObj->m_prowbitsIBuffer)->IsSlotSet((ULONG) rghRows[chRow]) == S_OK) &&
00521       (pRowBuff=m_pObj->GetRowBuff((DBCOUNTITEM) rghRows[chRow], TRUE )) &&
00522       (m_pObj->m_pFileio->IsDeleted((DBBKMARK) pRowBuff->pbBmk) != S_OK) )
00523     {
00524       // bump refcount
00525       pRowBuff = m_pObj->GetRowBuff((DBCOUNTITEM) rghRows[chRow], TRUE );
00526       assert( pRowBuff->ulRefCount != 0 );
00527       assert( m_pObj->m_ulRowRefCount != 0 );
00528       ++pRowBuff->ulRefCount;
00529       ++m_pObj->m_ulRowRefCount;
00530
00531       // stuff new refcount into caller's array
00532       if ( rgRefCounts )
00533         rgRefCounts[chRow] = pRowBuff->ulRefCount;
00534
00535       if ( rgRowStatus )
00536         rgRowStatus[chRow] = DBROWSTATUS_S_OK;
00537     }
00538     else
00539     {
00540       if ( rgRefCounts )
00541         rgRefCounts[chRow] = 0;
00542
00543       if ( rgRowStatus )
00544       {
00545         if ( pRowBuff && m_pObj->m_pFileio->IsDeleted((DBBKMARK) pRowBuff->pbBmk) == S_OK )
00546           rgRowStatus[chRow] = DBROWSTATUS_E_DELETED;
00547         else
00548           rgRowStatus[chRow] = DBROWSTATUS_E_INVALID;
00549       }
00550
00551             ++ cErrors;
00552     }
00553   }
00554
00555   // If everything went OK except errors in rows use DB_S_ERRORSOCCURRED.
00556   return cErrors ? ( cErrors < cRows ) ?
00557       ResultFromScode( DB_S_ERRORSOCCURRED ) :
00558       ResultFromScode( DB_E_ERRORSOCCURRED ) :
00559       ResultFromScode( S_OK );
00560 }
00561
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/SID/vc/objectSid.cpp Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • SID
  • vc

objectSid.cpp

Go to the documentation of this file.
00001 // bindtoparen.cpp : Defines the entry point for the console application.
00002 //
00003 #include <wchar.h>
00004 #include <objbase.h>
00005 #include <activeds.h>
00006
00007 //For converting sid to string.
00008 //Make sure you define UNICODE
00009 //Need to define version 5 for Windows 2000
00010 #define _WIN32_WINNT 0x0500
00011 #include <sddl.h>
00012
00013
00014 HRESULT GetLPBYTEtoOctetString(VARIANT *pVar, //IN. Pointer to variant containing the octetstring.
00015                                LPBYTE *ppByte //OUT. Return LPBYTE to the data represented in octetstring.
00016                  );
00017
00018 HRESULT FindUserByName(IDirectorySearch *pSearchBase, //Container to search
00019              LPOLESTR szFindUser, //Name of user to find.
00020              IADs **ppUser); //Return a pointer to the user
00021
00022
00023
00024 void wmain( int argc, wchar_t *argv[ ])
00025 {
00026
00027 //Handle the command line arguments.
00028 LPOLESTR pszBuffer = NULL;
00029 pszBuffer = new OLECHAR[MAX_PATH*2];
00030 if(pszBuffer == NULL)
00031     goto ret;
00032 if (argv[1] == NULL)
00033 {
00034   wprintf(L"This program finds a user in the current Window 2000 domain\n");
00035   wprintf(L"and displays its objectSid property in string form.\n");
00036   wprintf(L"This program demonstrates reading a property of type octet string.\n\n");
00037
00038   wprintf(L"Enter Common Name of the user to find:");
00039   _getws(pszBuffer);
00040 }
00041 else
00042    wcscpy(pszBuffer, argv[1]);
00043 //if empty string, exit.
00044 if (0==wcscmp(L"", pszBuffer))
00045    goto ret;
00046
00047 wprintf(L"\nFinding user: %s...\n",pszBuffer);
00048
00049 //Intialize COM
00050 CoInitialize(NULL);
00051 HRESULT hr = S_OK;
00052 //Get rootDSE and the domain container's DN.
00053 IADs *pObject = NULL;
00054 IDirectorySearch *pDS = NULL;
00055 LPOLESTR szPath = NULL;
00056 szPath = new OLECHAR[MAX_PATH];
00057 if(szPath == NULL)
00058     goto ret;
00059
00060 VARIANT var;
00061 hr = ADsOpenObject(L"LDAP://rootDSE",
00062          NULL,
00063          NULL,
00064          ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00065          IID_IADs,
00066          (void**)&pObject);
00067 if (FAILED(hr))
00068 {
00069    wprintf(L"Not Found. Could not bind to the domain.\n");
00070    if (pObject)
00071      pObject->Release();
00072    goto ret;
00073 }
00074
00075 VariantInit(&var);
00076 hr = pObject->Get(L"defaultNamingContext",&var);
00077 if (SUCCEEDED(hr))
00078 {
00079   wcscpy(szPath,L"LDAP://");
00080   wcscat(szPath,var.bstrVal);
00081   VariantClear(&var);
00082   if (pObject)
00083   {
00084      pObject->Release();
00085      pObject = NULL;
00086   }
00087   //Bind to the root of the current domain.
00088   hr = ADsOpenObject(szPath,
00089            NULL,
00090            NULL,
00091            ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00092            IID_IDirectorySearch,
00093            (void**)&pDS);
00094   if (SUCCEEDED(hr))
00095   {
00096     hr =  FindUserByName(pDS, //Container to search
00097                pszBuffer, //Name of user to find.
00098                &pObject); //Return a pointer to the user
00099     if (SUCCEEDED(hr))
00100     {
00101       //Get the objectSid property
00102       hr = pObject->Get(L"objectSid", &var);
00103       if (SUCCEEDED(hr))
00104       {
00105         LPBYTE pByte = NULL;
00106         wprintf (L"----------------------------------------------\n");
00107         wprintf (L"----------Call GetLPBYTEtoOctetString---------\n");
00108         wprintf (L"----------------------------------------------\n");
00109         hr = GetLPBYTEtoOctetString(&var, //IN. Pointer to variant containing the octetstring.
00110                  &pByte //OUT. Return LPBYTE to the data represented in octetstring.
00111                  );
00112
00113         PSID pObjectSID = (PSID)pByte;
00114         //Convert SID to string.
00115         LPOLESTR szSID = NULL;
00116         ConvertSidToStringSid(pObjectSID, &szSID);
00117         wprintf(L"objectSid:%s\n",szSID);
00118         LocalFree(szSID);
00119         //Free the buffer.
00120         CoTaskMemFree(pByte);
00121       }
00122       else
00123         wprintf(L"Get method failed with hr: %x\n",hr);
00124       VariantClear(&var);
00125     }
00126     else
00127     {
00128             wprintf(L"User \"%s\" not Found.\n",pszBuffer);
00129       wprintf (L"FindUserByName failed with the following HR: %x\n", hr);
00130     }
00131     if (pObject)
00132       pObject->Release();
00133   }
00134
00135   if (pDS)
00136      pDS->Release();
00137 }
00138 ret:
00139     if(pszBuffer) delete pszBuffer;
00140     if(szPath)     delete szPath;
00141 //Uninitalize COM
00142 CoUninitialize();
00143
00144   return;
00145 }
00146
00147 //Function for handling Octet Strings returned by variants
00148 //It allocates memory for data, copies the data to the buffer, and returns a pointer to the buffer.
00149 //Caller must free the buffer with CoTaskMemFree.
00150 HRESULT GetLPBYTEtoOctetString(VARIANT *pVar, //IN. Pointer to variant containing the octetstring.
00151                                LPBYTE *ppByte //OUT. Return LPBYTE to the data represented in octetstring.
00152                  )
00153 {
00154 HRESULT hr = E_FAIL;
00155 //Check args
00156 if ((!pVar)||(!ppByte))
00157   return E_INVALIDARG;
00158 //Check the variant type for unsigned char array (octet string).
00159 if ((pVar->vt)!=(VT_UI1|VT_ARRAY))
00160   return E_INVALIDARG;
00161
00162 void HUGEP *pArray;
00163 long lLBound, lUBound;
00164 hr = SafeArrayGetLBound(V_ARRAY(pVar), 1, &lLBound);
00165 hr = SafeArrayGetUBound(V_ARRAY(pVar), 1, &lUBound);
00166 //Get the count of elements
00167 long cElements = lUBound-lLBound + 1;
00168 hr = SafeArrayAccessData( V_ARRAY(pVar),
00169                 &pArray );
00170 if (SUCCEEDED(hr))
00171 {
00172  LPBYTE pTemp = (LPBYTE)pArray;
00173  *ppByte = (LPBYTE) CoTaskMemAlloc(cElements);
00174  if (*ppByte)
00175     memcpy(*ppByte, pTemp, cElements);
00176  else
00177   hr = E_OUTOFMEMORY;
00178 }
00179 SafeArrayUnaccessData( V_ARRAY(pVar) );
00180
00181 return hr;
00182 }
00183
00184
00185 HRESULT FindUserByName(IDirectorySearch *pSearchBase, //Container to search
00186              LPOLESTR szFindUser, //Name of user to find.
00187              IADs **ppUser) //Return a pointer to the user
00188 {
00189     HRESULT hrObj = E_FAIL;
00190     HRESULT hr = E_FAIL;
00191   if ((!pSearchBase)||(!szFindUser))
00192     return E_INVALIDARG;
00193   //Create search filter
00194   LPOLESTR pszSearchFilter = NULL;
00195        LPOLESTR szADsPath = NULL;
00196   pszSearchFilter = new OLECHAR[MAX_PATH];
00197   szADsPath = new OLECHAR[MAX_PATH];
00198        if(pszSearchFilter == NULL || szADsPath == NULL)
00199             return  E_OUT_OF_MEMORY;
00200
00201   wcscpy(pszSearchFilter, L"(&(objectCategory=person)(objectClass=user)(cn=");
00202   wcscat(pszSearchFilter, szFindUser);
00203   wcscat(pszSearchFilter, L"))");
00204     //Search entire subtree from root.
00205   ADS_SEARCHPREF_INFO SearchPrefs;
00206   SearchPrefs.dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
00207   SearchPrefs.vValue.dwType = ADSTYPE_INTEGER;
00208   SearchPrefs.vValue.Integer = ADS_SCOPE_SUBTREE;
00209     DWORD dwNumPrefs = 1;
00210   // COL for iterations
00211     ADS_SEARCH_COLUMN col;
00212     // Handle used for searching
00213     ADS_SEARCH_HANDLE hSearch;
00214   // Set the search preference
00215     hr = pSearchBase->SetSearchPreference( &SearchPrefs, dwNumPrefs);
00216     if (FAILED(hr))
00217         goto ret;
00218   // Set attributes to return
00219   CONST DWORD dwAttrNameSize = 1;
00220     LPOLESTR pszAttribute[dwAttrNameSize] = {L"ADsPath"};
00221
00222     // Execute the search
00223     hr = pSearchBase->ExecuteSearch(pszSearchFilter,
00224                               pszAttribute,
00225                   dwAttrNameSize,
00226                   &hSearch
00227                   );
00228   if (SUCCEEDED(hr))
00229   {
00230
00231     // Call IDirectorySearch::GetNextRow() to retrieve the next row
00232     //of data
00233         while( pSearchBase->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS )
00234     {
00235             // loop through the array of passed column names,
00236             // print the data for each column
00237             for (DWORD x = 0; x < dwAttrNameSize; x++)
00238             {
00239           // Get the data for this column
00240                 hr = pSearchBase->GetColumn( hSearch, pszAttribute[x], &col );
00241           if ( SUCCEEDED(hr) )
00242           {
00243             // Print the data for the column and free the column
00244           // Note the attribute we asked for is type CaseIgnoreString.
00245                     wcscpy(szADsPath, col.pADsValues->CaseIgnoreString);
00246           hr = ADsOpenObject(szADsPath,
00247                    NULL,
00248                    NULL,
00249                    ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
00250                    IID_IADs,
00251                    (void**)ppUser);
00252           if (SUCCEEDED(hr))
00253           {
00254                        wprintf(L"Found User.\n",szFindUser);
00255                        wprintf(L"%s: %s\r\n",pszAttribute[x],col.pADsValues->CaseIgnoreString);
00256              hrObj = S_OK;
00257           }
00258             pSearchBase->FreeColumn( &col );
00259           }
00260           else
00261             hr = E_FAIL;
00262             }
00263     }
00264     // Close the search handle to clean up
00265         pSearchBase->CloseSearchHandle(hSearch);
00266   }
00267   if (FAILED(hrObj))
00268     hr = hrObj;
00269
00270   ret:
00271         delete pszSearchFilter;
00272         delete szADsPath;
00273         return hr;
00274 }
00275
00276
00277
00278
00279
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/EnumDesk/tree.h Source File

  • WinUI
  • Shell
  • EnumDesk

tree.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Tree.h
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include <windows.h>
00023
00024 /**************************************************************************
00025    function prototypes
00026 **************************************************************************/
00027
00028 HWND Tree_Create(HINSTANCE, HWND, HIMAGELIST);
00029 void Tree_Init(HWND);
00030 LRESULT Tree_Notify(HWND, LPARAM);
00031 void Tree_DoContextMenu(HWND, LPPOINT);
00032
00033 /**************************************************************************
00034    global variables and definitions
00035 **************************************************************************/
00036
Generated on Wed Nov 13 2024 16:51:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ADOCommandConstruction.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ADOCommandConstruction.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // VTable-only interface ADOCommandConstruction
00019 /** @com.interface(iid=00000517-0000-0010-8000-00AA006D2EA4, thread=AUTO) */
00020 public interface ADOCommandConstruction extends IUnknown
00021 {
00022   /** @com.method(vtoffset=0, addFlagsVtable=4)
00023       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00024   public IUnknown getOLEDBCommand();
00025
00026   /** @com.method(vtoffset=1, addFlagsVtable=4)
00027       @com.parameters([in,iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] ppOLEDBCommand) */
00028   public void setOLEDBCommand(IUnknown ppOLEDBCommand);
00029
00030
00031   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x517, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00032 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEditValueDlg Member List

This is the complete list of members for CEditValueDlg, including all inherited members.
CDialogLite(UINT uIDD=0) | CDialogLite |
CEditValueDlg(UINT nID, WCHAR *pwszTitle) | CEditValueDlg |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateDlg(HWND hWndParent) | CDialogLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [static]
DoModal(HWND hWndParent) | CDialogLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
EndDialog(int nResult) | CDialogLite | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetValue() | CEditValueDlg | [inline, virtual]
GetVariant(DBTYPE wType, VARIANT *pVariant) | CEditValueDlg | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDialogLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_editValue | CEditValueDlg | [protected]
m_fModal | CDialogLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_pwszTitle | CEditValueDlg | [protected]
m_pwszValue | CEditValueDlg | [protected]
m_uIDD | CDialogLite |
m_wndPlacement | CWndLite |
m_wReqType | CEditValueDlg | [protected]
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CDialogLite | [virtual]
OnCancel() | CDialogLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitDialog() | CEditValueDlg | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnOK() | CEditValueDlg | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetReqType(DBTYPE wType) | CEditValueDlg | [inline, virtual]
SetValue(WCHAR *pwszValue) | CEditValueDlg | [inline, virtual]
SetVariant(VARIANT *pVariant) | CEditValueDlg | [virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CDialogLite() | CDialogLite | [virtual]
~CEditValueDlg() | CEditValueDlg | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmFilesTest/StdAfx.h Source File

  • Com
  • Services
  • Crm
  • CrmFilesTest

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__963680D5_FCB4_11D1_83D0_00A0C91EEDE9__INCLUDED_)
00006 #define AFX_STDAFX_H__963680D5_FCB4_11D1_83D0_00A0C91EEDE9__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #if !defined(_WIN32_WINNT)
00016 #define _WIN32_WINNT 0x0500
00017 #endif // !defined(_WIN32_WINNT)
00018
00019 #define _ATL_APARTMENT_THREADED
00020
00021
00022 #include <atlbase.h>
00023 //You may derive a class from CComModule and use it if you want to override
00024 //something, but do not change the name of _Module
00025 extern CComModule _Module;
00026 #include <atlcom.h>
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00030
00031 #endif // !defined(AFX_STDAFX_H__963680D5_FCB4_11D1_83D0_00A0C91EEDE9__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/Simple/QSample.Cxx Source File

  • WinBase
  • Indexing
  • Simple

QSample.Cxx

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 // PARTICULAR PURPOSE.
00007 //
00008 // Copyright (c) Microsoft Corporation. All rights reserved.
00009 //
00010 // PROGRAM:  qsample.cxx
00011 //
00012 // PURPOSE:  Illustrates a minimal query using Indexing Service.
00013 //           Uses CIMakeICommand and CITextToFullTree helper functions.
00014 //
00015 // PLATFORM: Windows 2000
00016 //
00017 //--------------------------------------------------------------------------
00018
00019 #define UNICODE
00020 #define DBINITCONSTANTS
00021
00022 #include <stdio.h>
00023 #include <wchar.h>
00024 #include <windows.h>
00025 #include <oledberr.h>
00026 #include <oledb.h>
00027 #include <cmdtree.h>
00028 #include <ntquery.h>
00029 #include <mlang.h>
00030
00031 #include "qsample.hxx"
00032
00033 // This is found in disptree.cxx
00034
00035 extern void DisplayCommandTree( DBCOMMANDTREE * pNode, ULONG iLevel = 0 );
00036
00037 //+---------------------------------------------------------------------------
00038 //
00039 //  Class:      XBStr
00040 //
00041 //  Purpose:    Smart BSTR class
00042 //
00043 //----------------------------------------------------------------------------
00044
00045 class XBStr
00046 {
00047 public:
00048     XBStr(BSTR p = 0) : _p( p ) {}
00049     XBStr ( XBStr & x ): _p( x.Acquire() ) {}
00050     ~XBStr() { SysFreeString( _p ); }
00051     BOOL IsNull() const { return ( 0 == _p ); }
00052     void Set ( BSTR pOleStr ) { _p = pOleStr; }
00053     BSTR Acquire()
00054     {
00055         BSTR pTemp = _p;
00056         _p = 0;
00057         return pTemp;
00058     }
00059     BSTR GetPointer() const { return _p; }
00060     void Free() { SysFreeString( Acquire() ); }
00061 private:
00062     BSTR _p;
00063 };
00064
00065 //+-------------------------------------------------------------------------
00066 //
00067 //  Template:   XInterface
00068 //
00069 //  Synopsis:   Template for managing ownership of interfaces
00070 //
00071 //--------------------------------------------------------------------------
00072
00073 template<class T> class XInterface
00074 {
00075 public:
00076     XInterface( T * p = 0 ) : _p( p ) {}
00077     ~XInterface() { if ( 0 != _p ) _p->Release(); }
00078     T * operator->() { return _p; }
00079     T * GetPointer() const { return _p; }
00080     IUnknown ** GetIUPointer() { return (IUnknown **) &_p; }
00081     T ** GetPPointer() { return &_p; }
00082     void ** GetQIPointer() { return (void **) &_p; }
00083     T * Acquire() { T * p = _p; _p = 0; return p; }
00084     BOOL IsNull() { return ( 0 == _p ); }
00085
00086 private:
00087     T * _p;
00088 };
00089
00090 //+-------------------------------------------------------------------------
00091 //
00092 //  Template:   XPtr
00093 //
00094 //  Synopsis:   Template for managing ownership of memory
00095 //
00096 //--------------------------------------------------------------------------
00097
00098 template<class T> class XPtr
00099 {
00100 public:
00101     XPtr( unsigned c ) : _p(0) { if ( 0 != c ) _p = new T [ c ]; }
00102     ~XPtr() { Free(); }
00103     void SetSize( unsigned c ) { Free(); _p = new T [ c ]; }
00104     void Set ( T * p ) { _p = p; }
00105     T * Get() const { return _p ; }
00106     void Free() { delete [] Acquire(); }
00107     T & operator[]( unsigned i ) { return _p[i]; }
00108     T const & operator[]( unsigned i ) const { return _p[i]; }
00109     T * Acquire() { T * p = _p; _p = 0; return p; }
00110     BOOL IsNull() const { return ( 0 == _p ); }
00111
00112 private:
00113     T * _p;
00114 };
00115
00116 //+-------------------------------------------------------------------------
00117 //
00118 //  Template:   CResString
00119 //
00120 //  Synopsis:   Class for loading string resources
00121 //
00122 //--------------------------------------------------------------------------
00123
00124 class CResString
00125 {
00126 public:
00127     CResString() { _awc[ 0 ] = 0; }
00128     CResString( UINT strIDS ) { Load( strIDS ); }
00129     WCHAR const * Get() const { return _awc; }
00130
00131     BOOL Load( UINT strIDS )
00132     {
00133         _awc[ 0 ] = 0;
00134         LoadString( 0, strIDS, _awc, sizeof _awc / sizeof WCHAR );
00135         return ( 0 != _awc[ 0 ] );
00136     }
00137
00138 private:
00139     WCHAR _awc[ 200 ];
00140 };
00141
00142 //+-------------------------------------------------------------------------
00143 //
00144 //  Function:   FormatError
00145 //
00146 //  Synopsis:   Formats an error code into a string
00147 //
00148 //  Arguments:  [sc]   - An Indexing Service or Win32 HRESULT
00149 //              [pwc]  - Where to write the error string
00150 //              [cwc]  - Count of characters in pwc
00151 //              [lcid] - Locale for the error string
00152 //
00153 //--------------------------------------------------------------------------
00154
00155 void FormatError(
00156     SCODE   sc,
00157     WCHAR * pwc,
00158     ULONG   cwc,
00159     LCID    lcid )
00160 {
00161     // FormatMessage works best when based on thread locale.
00162
00163     LCID SaveLCID = GetThreadLocale();
00164     BOOL fLocaleSet = SetThreadLocale( lcid );
00165
00166     // Is this an Indexing Service error?  These errors are in query.dll.
00167
00168     if ( ! FormatMessage( FORMAT_MESSAGE_FROM_HMODULE,
00169                           GetModuleHandle( L"query.dll" ),
00170                           sc,
00171                           0,
00172                           pwc,
00173                           cwc,
00174                           0 ) )
00175     {
00176         // Is this a Win32 error?  These are in kernel32.dll
00177
00178         const ULONG facWin32 = ( FACILITY_WIN32 << 16 );
00179         ULONG Win32Error = sc;
00180
00181         if ( (Win32Error & facWin32) == facWin32 )
00182             Win32Error &= ~( 0x80000000 | facWin32 );
00183
00184         if ( ! FormatMessage( FORMAT_MESSAGE_FROM_HMODULE,
00185                               GetModuleHandle( L"kernel32.dll" ),
00186                               Win32Error,
00187                               0,
00188                               pwc,
00189                               cwc,
00190                               0 ) )
00191         {
00192             // It's not from Indexing Service or Win32; display a default error
00193
00194             CResString str( IDS_UNKNOWNERROR );
00195
00196             if ( wcslen( str.Get() ) >= cwc )
00197                 pwc[0] = 0;
00198             else
00199                 wcscpy( pwc, str.Get() );
00200         }
00201     }
00202
00203     // Restore the original thread locale
00204
00205     if ( fLocaleSet )
00206         SetThreadLocale( SaveLCID );
00207 } //FormatError
00208
00209 //+-------------------------------------------------------------------------
00210 //
00211 //  Function:   DisplayError
00212 //
00213 //  Synopsis:   Prints an error message from a string resource
00214 //
00215 //  Arguments:  [uiError]     - The error message resource id
00216 //              [pwcArgument] - A string argument for the error message
00217 //              [hr]          - The error code
00218 //              [lcid]        - Locale for the error string
00219 //
00220 //--------------------------------------------------------------------------
00221
00222 void DisplayError(
00223     UINT          uiError,
00224     WCHAR const * pwcArgument,
00225     HRESULT       hr,
00226     LCID          lcid )
00227 {
00228     WCHAR awcError[ 200 ];
00229     FormatError( hr, awcError, sizeof awcError / sizeof WCHAR, lcid );
00230
00231     CResString str( uiError );
00232     wprintf( str.Get(), pwcArgument, hr, awcError );
00233 } //DisplayError
00234
00235 //+-------------------------------------------------------------------------
00236 //
00237 //  Function:   DisplayWin32Error
00238 //
00239 //  Synopsis:   Prints an error message taken from GetLastError()
00240 //
00241 //  Arguments:  [uiError]     - The string resource to use for the error
00242 //              [pwcArgument] - A string argument for the error message
00243 //              [lcid]        - Locale for the error string
00244 //
00245 //--------------------------------------------------------------------------
00246
00247 HRESULT DisplayWin32Error(
00248     UINT          uiError,
00249     WCHAR const * pwcArgument,
00250     LCID          lcid )
00251 {
00252     HRESULT hr = HRESULT_FROM_WIN32( GetLastError() );
00253     DisplayError( uiError, pwcArgument, hr, lcid );
00254     return hr;
00255 } //DisplayWin32Error
00256
00257 void DisplayStat( DWORD dw, UINT uiMsg )
00258 {
00259     CResString str( uiMsg );
00260     wprintf( L"%8d %ws\n", dw, str.Get() );
00261 } //DisplayStat
00262
00263 void DisplayStat( WCHAR const *pwcMsg, UINT uiMsg )
00264 {
00265     CResString str( uiMsg );
00266     wprintf( L"%ws: %ws\n", str.Get(), pwcMsg );
00267 } //DisplayStat
00268
00269 void DisplayStat( UINT uiMsg )
00270 {
00271     CResString str( uiMsg );
00272     wprintf( L"%ws\n", str.Get() );
00273 } //DisplayStat
00274
00275 //+-------------------------------------------------------------------------
00276 //
00277 //  Function:   Usage
00278 //
00279 //  Synopsis:   Displays information about how to use the app and exits
00280 //
00281 //--------------------------------------------------------------------------
00282
00283 void Usage()
00284 {
00285     HRSRC hrc = FindResource( 0, (LPCWSTR) IDR_USAGE, RT_RCDATA );
00286
00287     if ( 0 != hrc )
00288     {
00289         HGLOBAL hg = LoadResource( 0, hrc );
00290
00291         if ( 0 != hg )
00292         {
00293             void * pv = LockResource( hg );
00294
00295             if ( 0 != pv )
00296                 wprintf( L"%ws\n", pv );
00297         }
00298     }
00299
00300     exit( -1 );
00301 } //Usage
00302
00303 //+-------------------------------------------------------------------------
00304 //
00305 //  Function:   LocaleToCodepage
00306 //
00307 //  Synopsis:   Finds the best matching codepage given a locale id.
00308 //
00309 //  Arguments:  [lcid]  - Locale to check
00310 //
00311 //  Returns:    The best matching codepage.
00312 //
00313 //--------------------------------------------------------------------------
00314
00315 ULONG LocaleToCodepage( LCID lcid )
00316 {
00317     ULONG codepage;
00318
00319     int cwc = GetLocaleInfo( lcid,
00320                              LOCALE_RETURN_NUMBER |
00321                                  LOCALE_IDEFAULTANSICODEPAGE,
00322                              (WCHAR *) &codepage,
00323                              sizeof ULONG / sizeof WCHAR );
00324
00325     // If an error occurred, return the Ansi code page
00326
00327     if ( 0 == cwc )
00328          return CP_ACP;
00329
00330     return codepage;
00331 } //LocaleToCodepage
00332
00333 //+-------------------------------------------------------------------------
00334 //
00335 //  Function:   GetLocaleString
00336 //
00337 //  Synopsis:   Looks up a locale string given an LCID
00338 //
00339 //  Arguments:  [lcid] - The lcid to look up
00340 //
00341 //  Returns:    The matching string (in a static buffer, caller beware).
00342 //
00343 //--------------------------------------------------------------------------
00344
00345 WCHAR const * GetLocaleString( LCID lcid )
00346 {
00347     static WCHAR awcLocale[ 100 ];
00348     wcscpy( awcLocale, L"Neutral" );
00349
00350     XInterface<IMultiLanguage> xMultiLang;
00351
00352     HRESULT hr = CoCreateInstance( CLSID_CMultiLanguage,
00353                                    0,
00354                                    CLSCTX_INPROC_SERVER,
00355                                    IID_IMultiLanguage,
00356                                    xMultiLang.GetQIPointer() );
00357
00358     if ( SUCCEEDED( hr ) )
00359     {
00360         BSTR bstrLocale;
00361
00362         hr = xMultiLang->GetRfc1766FromLcid( lcid, &bstrLocale );
00363         if ( SUCCEEDED( hr ) )
00364         {
00365             wcscpy( awcLocale, bstrLocale );
00366             SysFreeString( bstrLocale );
00367         }
00368     }
00369
00370     return awcLocale;
00371 } //GetLocaleString
00372
00373 //+-------------------------------------------------------------------------
00374 //
00375 //  Function:   LcidFromHttpAcceptLanguage
00376 //
00377 //  Synopsis:   Looks up an LCID given an HTTP Accept Language string
00378 //
00379 //  Arguments:  [pwc] - The string to look up
00380 //
00381 //  Returns:    The matching LCID.
00382 //
00383 //--------------------------------------------------------------------------
00384
00385 LCID LcidFromHttpAcceptLanguage( WCHAR const * pwc )
00386 {
00387     // Default to the system locale
00388
00389     LCID lcid = GetSystemDefaultLCID();
00390
00391     if ( 0 != pwc )
00392     {
00393         XInterface<IMultiLanguage> xMultiLang;
00394
00395         HRESULT hr = CoCreateInstance( CLSID_CMultiLanguage,
00396                                        0,
00397                                        CLSCTX_INPROC_SERVER,
00398                                        IID_IMultiLanguage,
00399                                        xMultiLang.GetQIPointer() );
00400
00401         if ( SUCCEEDED( hr ) )
00402         {
00403             BSTR bstr = SysAllocString( pwc );
00404
00405             if ( 0 != bstr )
00406             {
00407                 hr = xMultiLang->GetLcidFromRfc1766( &lcid, bstr );
00408
00409                 SysFreeString( bstr );
00410
00411                 if ( S_FALSE == hr ||
00412                      E_FAIL == hr )
00413                 {
00414                     if ( !_wcsicmp( pwc, L"neutral" ) ||
00415                          !_wcsicmp( pwc, L"neutr" ) )
00416                         lcid = 0;
00417                     else
00418                         Usage();
00419                 }
00420                 else if ( FAILED( hr ) )
00421                 {
00422                     Usage();
00423                 }
00424             }
00425         }
00426     }
00427
00428     return lcid;
00429 } //LcidFromHttpAcceptLanguage
00430
00431 //+-------------------------------------------------------------------------
00432 //
00433 //  Function:   SetCommandProperties
00434 //
00435 //  Synopsis:   Sets the DBPROP_USEEXTENDEDDBTYPES property to TRUE, so
00436 //              data is returned in PROPVARIANTs, as opposed to the
00437 //              default, which is OLE automation VARIANTs.  PROPVARIANTS
00438 //              allow a superset of VARIANT data types.  Use of these
00439 //              types avoids costly coercions.
00440 //
00441 //              Also sets the DBPROP_USECONTENTINDEX property to TRUE, so
00442 //              the index will always be used to resolve the query (as
00443 //              opposed to enumerating all the files on the disk), even
00444 //              if the index is out of date.  This is set optionally.
00445 //
00446 //              Both of these properties are unique to Indexing Service's
00447 //              OLE DB implementation.
00448 //
00449 //  Arguments:  [pICommand] - The ICommand used to set the property
00450 //              [fForceUseContentIndex] - TRUE to always use index
00451 //                                        FALSE to allow directory enumeration
00452 //              [lcid] - The locale of the query
00453 //              [cMaxHits] - The maximum number of rows to return, 0 for all.
00454 //
00455 //  Returns:    HRESULT result of setting the properties
00456 //
00457 //--------------------------------------------------------------------------
00458
00459 HRESULT SetCommandProperties(
00460     ICommand * pICommand,
00461     BOOL       fForceUseContentIndex,
00462     LCID       lcid,
00463     ULONG      cMaxHits )
00464 {
00465     static const DBID dbcolNull = { { 0,0,0, { 0,0,0,0,0,0,0,0 } },
00466                                     DBKIND_GUID_PROPID, 0 };
00467     static const GUID guidQueryExt = DBPROPSET_QUERYEXT;
00468
00469     DBPROP aProp[2];
00470
00471     // Use extened types in accessor bindings -- it's faster and more accurate
00472
00473     aProp[0].dwPropertyID = DBPROP_USEEXTENDEDDBTYPES;
00474     aProp[0].dwOptions = DBPROPOPTIONS_OPTIONAL;
00475     aProp[0].dwStatus = 0;
00476     aProp[0].colid = dbcolNull;
00477     aProp[0].vValue.vt = VT_BOOL;
00478     aProp[0].vValue.boolVal = VARIANT_TRUE;
00479
00480     // Should we force use of the index?  Otherwise, enumeration will be slow.
00481
00482     aProp[1] = aProp[0];
00483     aProp[1].dwPropertyID = DBPROP_USECONTENTINDEX;
00484     aProp[1].vValue.boolVal = fForceUseContentIndex ? VARIANT_TRUE : VARIANT_FALSE;
00485
00486     DBPROPSET aPropSet[3];
00487
00488     aPropSet[0].rgProperties = &aProp[0];
00489     aPropSet[0].cProperties = 2;
00490     aPropSet[0].guidPropertySet = guidQueryExt;
00491
00492     const GUID guidMSIDXS_ROWSETEXT = DBPROPSET_MSIDXS_ROWSETEXT;
00493
00494     DBPROP aRowsetExtProp[1];
00495
00496     aPropSet[1].rgProperties = &aRowsetExtProp[0];
00497     aPropSet[1].cProperties = 1;
00498     aPropSet[1].guidPropertySet = guidMSIDXS_ROWSETEXT;
00499
00500     // Set the default locale of the query
00501
00502     aRowsetExtProp[0] = aProp[0];
00503     aRowsetExtProp[0].dwPropertyID = MSIDXSPROP_COMMAND_LOCALE_STRING;
00504     aRowsetExtProp[0].vValue.vt = VT_BSTR;
00505     aRowsetExtProp[0].vValue.bstrVal = SysAllocString( GetLocaleString( lcid ) );
00506     if ( 0 == aRowsetExtProp[0].vValue.bstrVal )
00507         return E_OUTOFMEMORY;
00508
00509     DBPROP aRowsetProp[1];
00510     aPropSet[2].rgProperties = &aRowsetProp[0];
00511     aPropSet[2].cProperties = 1;
00512     aPropSet[2].guidPropertySet = DBPROPSET_ROWSET;
00513
00514     // Set the first or best maximum number of result rows
00515
00516     aRowsetProp[0] = aProp[0];
00517     aRowsetProp[0].dwPropertyID = DBPROP_MAXROWS;
00518     aRowsetProp[0].vValue.vt = VT_I4;
00519     aRowsetProp[0].vValue.lVal = (LONG) cMaxHits;
00520
00521     XInterface<ICommandProperties> xICommandProperties;
00522     HRESULT hr = pICommand->QueryInterface( IID_ICommandProperties,
00523                                             xICommandProperties.GetQIPointer() );
00524     if ( SUCCEEDED( hr ) )
00525     {
00526         hr = xICommandProperties->SetProperties( 3,
00527                                                  aPropSet ); // the properties
00528     }
00529
00530     // Free the locale string
00531
00532     HRESULT hr2 = VariantClear( &aRowsetExtProp[0].vValue );
00533
00534     if ( SUCCEEDED( hr ) && FAILED( hr2 ) )
00535         hr = hr2;
00536
00537     return hr;
00538 } //SetCommandProperties
00539
00540 //+-------------------------------------------------------------------------
00541 //
00542 //  Function:   Render
00543 //
00544 //  Synopsis:   Prints an item in a safearray
00545 //
00546 //  Arguments:  [vt]  - type of the element
00547 //              [pa]  - pointer to the item
00548 //
00549 //--------------------------------------------------------------------------
00550
00551 void PrintSafeArray( VARTYPE vt, LPSAFEARRAY pa );
00552
00553 void Render( VARTYPE vt, void * pv )
00554 {
00555     if ( VT_ARRAY & vt )
00556     {
00557         PrintSafeArray( (VARTYPE) ( vt - VT_ARRAY ), *(SAFEARRAY **) pv );
00558         return;
00559     }
00560
00561     switch ( vt )
00562     {
00563         case VT_UI1: wprintf( L"%u", (unsigned) *(BYTE *)pv ); break;
00564         case VT_I1: wprintf( L"%d", (int) *(CHAR *)pv ); break;
00565         case VT_UI2: wprintf( L"%u", (unsigned) *(USHORT *)pv ); break;
00566         case VT_I2: wprintf( L"%d", (int) *(SHORT *)pv ); break;
00567         case VT_UI4:
00568         case VT_UINT: wprintf( L"%u", (unsigned) *(ULONG *)pv ); break;
00569         case VT_I4:
00570         case VT_ERROR:
00571         case VT_INT: wprintf( L"%d", *(LONG *)pv ); break;
00572         case VT_UI8: wprintf( L"%I64u", *(unsigned __int64 *)pv ); break;
00573         case VT_I8: wprintf( L"%I64d", *(__int64 *)pv ); break;
00574         case VT_R4: wprintf( L"%f", *(float *)pv ); break;
00575         case VT_R8: wprintf( L"%lf", *(double *)pv ); break;
00576         case VT_DECIMAL:
00577         {
00578             double dbl;
00579             HRESULT hr = VarR8FromDec( (DECIMAL *) pv, &dbl );
00580             if ( SUCCEEDED( hr ) )
00581                 wprintf( L"%lf", dbl );
00582             break;
00583         }
00584         case VT_CY:
00585         {
00586             double dbl;
00587             HRESULT hr = VarR8FromCy( * (CY *) pv, &dbl );
00588             if ( SUCCEEDED( hr ) )
00589                 wprintf( L"%lf", dbl );
00590             break;
00591         }
00592         case VT_BOOL: wprintf( *(VARIANT_BOOL *)pv ? L"TRUE" : L"FALSE" ); break;
00593         case VT_BSTR: wprintf( L"%ws", *(BSTR *) pv ); break;
00594         case VT_VARIANT:
00595         {
00596             PROPVARIANT * pVar = (PROPVARIANT *) pv;
00597             Render( pVar->vt, & pVar->lVal );
00598             break;
00599         }
00600         case VT_DATE:
00601         {
00602             SYSTEMTIME st;
00603
00604             BOOL fOK = VariantTimeToSystemTime( *(DATE *)pv, &st );
00605
00606             if ( !fOK )
00607                 break;
00608
00609             BOOL pm = st.wHour >= 12;
00610
00611             if ( st.wHour > 12 )
00612                 st.wHour -= 12;
00613             else if ( 0 == st.wHour )
00614                 st.wHour = 12;
00615
00616             wprintf( L"%2d-%02d-%04d %2d:%02d%wc",
00617                     (DWORD) st.wMonth,
00618                     (DWORD) st.wDay,
00619                     (DWORD) st.wYear,
00620                     (DWORD) st.wHour,
00621                     (DWORD) st.wMinute,
00622                     pm ? L'p' : L'a' );
00623             break;
00624         }
00625         case VT_EMPTY:
00626         case VT_NULL:
00627             break;
00628         default :
00629         {
00630             wprintf( L"(vt 0x%x)", (int) vt );
00631             break;
00632         }
00633     }
00634 } //Render
00635
00636 //+-------------------------------------------------------------------------
00637 //
00638 //  Function:   PrintSafeArray
00639 //
00640 //  Synopsis:   Prints items in a safearray
00641 //
00642 //  Arguments:  [vt]  - type of elements in the safearray
00643 //              [pa]  - pointer to the safearray
00644 //
00645 //--------------------------------------------------------------------------
00646
00647 void PrintSafeArray( VARTYPE vt, LPSAFEARRAY pa )
00648 {
00649     // Get the dimensions of the array
00650
00651     UINT cDim = SafeArrayGetDim( pa );
00652     if ( 0 == cDim )
00653         return;
00654
00655     XPtr<LONG> xDim( cDim );
00656     XPtr<LONG> xLo( cDim );
00657     XPtr<LONG> xUp( cDim );
00658
00659     for ( UINT iDim = 0; iDim < cDim; iDim++ )
00660     {
00661         HRESULT hr = SafeArrayGetLBound( pa, iDim + 1, &xLo[iDim] );
00662         if ( FAILED( hr ) )
00663             return;
00664
00665         xDim[ iDim ] = xLo[ iDim ];
00666
00667         hr = SafeArrayGetUBound( pa, iDim + 1, &xUp[iDim] );
00668         if ( FAILED( hr ) )
00669             return;
00670
00671         wprintf( L"{" );
00672     }
00673
00674     // slog through the array
00675
00676     UINT iLastDim = cDim - 1;
00677     BOOL fDone = FALSE;
00678
00679     while ( !fDone )
00680     {
00681         // inter-element formatting
00682
00683         if ( xDim[ iLastDim ] != xLo[ iLastDim ] )
00684             wprintf( L"," );
00685
00686         // Get the element and render it
00687
00688         void *pv;
00689         HRESULT hr = SafeArrayPtrOfIndex( pa, xDim.Get(), &pv );
00690         if ( FAILED( hr ) )
00691             return;
00692
00693         Render( vt, pv );
00694
00695         // Move to the next element and carry if necessary
00696
00697         ULONG cOpen = 0;
00698
00699         for ( LONG iDim = iLastDim; iDim >= 0; iDim-- )
00700         {
00701             if ( xDim[ iDim ] < xUp[ iDim ] )
00702             {
00703                 xDim[ iDim ] = 1 + xDim[ iDim ];
00704                 break;
00705             }
00706
00707             wprintf( L"}" );
00708
00709             if ( 0 == iDim )
00710                 fDone = TRUE;
00711             else
00712             {
00713                 cOpen++;
00714                 xDim[ iDim ] = xLo[ iDim ];
00715             }
00716         }
00717
00718         for ( ULONG i = 0; !fDone && i < cOpen; i++ )
00719             wprintf( L"{" );
00720     }
00721 } //PrintSafeArray
00722
00723 //+-------------------------------------------------------------------------
00724 //
00725 //  Function:   PrintVectorItems
00726 //
00727 //  Synopsis:   Prints items in a PROPVARIANT vector
00728 //
00729 //  Arguments:  [pVal]  - The array of values
00730 //              [cVals] - The count of values
00731 //              [pcFmt] - The format string
00732 //
00733 //--------------------------------------------------------------------------
00734
00735 template<class T> void PrintVectorItems(
00736     T *     pVal,
00737     ULONG   cVals,
00738     char *  pcFmt )
00739 {
00740     printf( "{ " );
00741
00742     for( ULONG iVal = 0; iVal < cVals; iVal++ )
00743     {
00744         if ( 0 != iVal )
00745             printf( "," );
00746         printf( pcFmt, *pVal++ );
00747     }
00748
00749     printf( " }" );
00750 } //PrintVectorItems
00751
00752 //+-------------------------------------------------------------------------
00753 //
00754 //  Function:   DisplayValue
00755 //
00756 //  Synopsis:   Displays a PROPVARIANT value.  Limited formatting is done.
00757 //
00758 //  Arguments:  [pVar] - The value to display
00759 //
00760 //--------------------------------------------------------------------------
00761
00762 void DisplayValue( PROPVARIANT const * pVar )
00763 {
00764     if ( 0 == pVar )
00765     {
00766         wprintf( L"NULL" );
00767         return;
00768     }
00769
00770     // Display the most typical variant types
00771
00772     PROPVARIANT const & v = *pVar;
00773
00774     switch ( v.vt )
00775     {
00776         case VT_EMPTY : break;
00777         case VT_NULL : break;
00778         case VT_I4 : wprintf( L"%10d", v.lVal ); break;
00779         case VT_UI1 : wprintf( L"%10d", v.bVal ); break;
00780         case VT_I2 : wprintf( L"%10d", v.iVal ); break;
00781         case VT_R4 : wprintf( L"%10f", v.fltVal ); break;
00782         case VT_R8 : wprintf( L"%10lf", v.dblVal ); break;
00783         case VT_BOOL : wprintf( v.boolVal ? L"TRUE" : L"FALSE" ); break;
00784         case VT_I1 : wprintf( L"%10d", v.cVal ); break;
00785         case VT_UI2 : wprintf( L"%10u", v.uiVal ); break;
00786         case VT_UI4 : wprintf( L"%10u", v.ulVal ); break;
00787         case VT_INT : wprintf( L"%10d", v.lVal ); break;
00788         case VT_UINT : wprintf( L"%10u", v.ulVal ); break;
00789         case VT_I8 : wprintf( L"%20I64d", v.hVal ); break;
00790         case VT_UI8 : wprintf( L"%20I64u", v.hVal ); break;
00791         case VT_ERROR : wprintf( L"%#x", v.scode ); break;
00792         case VT_LPSTR : wprintf( L"%S", v.pszVal ); break;
00793         case VT_LPWSTR : wprintf( L"%ws", v.pwszVal ); break;
00794         case VT_BSTR : wprintf( L"%ws", v.bstrVal ); break;
00795         case VT_CY:
00796         {
00797             double dbl;
00798             HRESULT hr = VarR8FromCy( v.cyVal, &dbl );
00799             if ( SUCCEEDED( hr ) )
00800                 wprintf( L"%lf", dbl );
00801             break;
00802         }
00803         case VT_DECIMAL :
00804         {
00805             double dbl;
00806             HRESULT hr = VarR8FromDec( (DECIMAL *) &v.decVal, &dbl );
00807             if ( SUCCEEDED( hr ) )
00808                 wprintf( L"%lf", dbl );
00809             break;
00810         }
00811         case VT_FILETIME :
00812         case VT_DATE :
00813         {
00814             SYSTEMTIME st;
00815             ZeroMemory( &st, sizeof st );
00816
00817             if ( VT_DATE == v.vt )
00818             {
00819                 BOOL fOK = VariantTimeToSystemTime( v.date, &st );
00820
00821                 if ( !fOK )
00822                     break;
00823             }
00824             else
00825             {
00826                 FILETIME ft;
00827                 BOOL fOK = FileTimeToLocalFileTime( &v.filetime, &ft );
00828
00829                 if ( fOK )
00830                     fOK = FileTimeToSystemTime( &ft, &st );
00831
00832                 if ( !fOK )
00833                     break;
00834             }
00835
00836             BOOL pm = st.wHour >= 12;
00837
00838             if ( st.wHour > 12 )
00839                 st.wHour -= 12;
00840             else if ( 0 == st.wHour )
00841                 st.wHour = 12;
00842
00843             wprintf( L"%2d-%02d-%04d %2d:%02d%wc",
00844                     (DWORD) st.wMonth,
00845                     (DWORD) st.wDay,
00846                     (DWORD) st.wYear,
00847                     (DWORD) st.wHour,
00848                     (DWORD) st.wMinute,
00849                     pm ? L'p' : L'a' );
00850             break;
00851         }
00852         case VT_VECTOR | VT_I1:
00853             PrintVectorItems( v.cac.pElems, v.cac.cElems, "%d" ); break;
00854         case VT_VECTOR | VT_I2:
00855             PrintVectorItems( v.cai.pElems, v.cai.cElems, "%d" ); break;
00856         case VT_VECTOR | VT_I4:
00857             PrintVectorItems( v.cal.pElems, v.cal.cElems, "%d" ); break;
00858         case VT_VECTOR | VT_I8:
00859             PrintVectorItems( v.cah.pElems, v.cah.cElems, "%I64d" ); break;
00860         case VT_VECTOR | VT_UI1:
00861             PrintVectorItems( v.caub.pElems, v.caub.cElems, "%u" ); break;
00862         case VT_VECTOR | VT_UI2:
00863             PrintVectorItems( v.caui.pElems, v.caui.cElems, "%u" ); break;
00864         case VT_VECTOR | VT_UI4:
00865             PrintVectorItems( v.caul.pElems, v.caul.cElems, "%u" ); break;
00866         case VT_VECTOR | VT_ERROR:
00867             PrintVectorItems( v.cascode.pElems, v.cascode.cElems, "%#x" ); break;
00868         case VT_VECTOR | VT_UI8:
00869             PrintVectorItems( v.cauh.pElems, v.cauh.cElems, "%I64u" ); break;
00870         case VT_VECTOR | VT_BSTR:
00871             PrintVectorItems( v.cabstr.pElems, v.cabstr.cElems, "%ws" ); break;
00872         case VT_VECTOR | VT_LPSTR:
00873             PrintVectorItems( v.calpstr.pElems, v.calpstr.cElems, "%S" ); break;
00874         case VT_VECTOR | VT_LPWSTR:
00875             PrintVectorItems( v.calpwstr.pElems, v.calpwstr.cElems, "%ws" ); break;
00876         case VT_VECTOR | VT_R4:
00877             PrintVectorItems( v.caflt.pElems, v.caflt.cElems, "%f" ); break;
00878         case VT_VECTOR | VT_R8:
00879             PrintVectorItems( v.cadbl.pElems, v.cadbl.cElems, "%lf" ); break;
00880         default :
00881         {
00882             if ( VT_ARRAY & v.vt )
00883                 PrintSafeArray( (VARTYPE) ( v.vt - VT_ARRAY ), v.parray );
00884             else
00885                 wprintf( L"vt 0x%05x", v.vt );
00886             break;
00887         }
00888     }
00889 } //DisplayValue
00890
00891 //-----------------------------------------------------------------------------
00892 //
00893 //  Function:   GetOleDBErrorInfo
00894 //
00895 //  Synopsis:   Retrieves the secondary error from the OLE DB error object.
00896 //
00897 //  Arguments:  [pErrSrc]      - Pointer to object that posted the error.
00898 //              [riid]         - Interface that posted the error.
00899 //              [lcid]         - Locale in which the text is desired.
00900 //              [pErrorInfo]   - Pointer to memory where ERRORINFO should be.
00901 //              [ppIErrorInfo] - Holds the returning IErrorInfo. Caller
00902 //                               should release this.
00903 //
00904 //  Returns:    HRESULT for whether the error info was retrieved
00905 //
00906 //-----------------------------------------------------------------------------
00907
00908 HRESULT GetOleDBErrorInfo(
00909     IUnknown *    pErrSrc,
00910     REFIID        riid,
00911     LCID          lcid,
00912     ERRORINFO *   pErrorInfo,
00913     IErrorInfo ** ppIErrorInfo )
00914 {
00915     *ppIErrorInfo = 0;
00916
00917     // See if an error is available that is of interest to us.
00918
00919     XInterface<ISupportErrorInfo> xSupportErrorInfo;
00920     HRESULT hr = pErrSrc->QueryInterface( IID_ISupportErrorInfo,
00921                                           xSupportErrorInfo.GetQIPointer() );
00922     if ( FAILED( hr ) )
00923         return hr;
00924
00925     hr = xSupportErrorInfo->InterfaceSupportsErrorInfo( riid );
00926     if ( FAILED( hr ) )
00927         return hr;
00928
00929     // Get the current error object. Return if none exists.
00930
00931     XInterface<IErrorInfo> xErrorInfo;
00932     hr = GetErrorInfo( 0, xErrorInfo.GetPPointer() );
00933     if ( xErrorInfo.IsNull() )
00934         return hr;
00935
00936     // Get the IErrorRecord interface and get the count of errors.
00937
00938     XInterface<IErrorRecords> xErrorRecords;
00939     hr = xErrorInfo->QueryInterface( IID_IErrorRecords,
00940                                      xErrorRecords.GetQIPointer() );
00941     if ( FAILED( hr ) )
00942         return hr;
00943
00944     ULONG cErrRecords;
00945     hr = xErrorRecords->GetRecordCount( &cErrRecords );
00946     if ( 0 == cErrRecords )
00947         return hr;
00948
00949 #if 1 // A good way to get the complete error message...
00950
00951     XInterface<IErrorInfo> xErrorInfoRec;
00952     ERRORINFO ErrorInfo;
00953     for ( unsigned i=0; i<cErrRecords; i++ )
00954     {
00955         // Get basic error information.
00956
00957         xErrorRecords->GetBasicErrorInfo( i, &ErrorInfo );
00958
00959         // Get error description and source through the IErrorInfo interface
00960         // pointer on a particular record.
00961
00962         xErrorRecords->GetErrorInfo( i, lcid, xErrorInfoRec.GetPPointer() );
00963
00964         XBStr bstrDescriptionOfError;
00965         XBStr bstrSourceOfError;
00966
00967         BSTR bstrDesc = bstrDescriptionOfError.GetPointer();
00968         BSTR bstrSrc = bstrSourceOfError.GetPointer();
00969
00970         xErrorInfoRec->GetDescription( &bstrDesc );
00971         xErrorInfoRec->GetSource( &bstrSrc );
00972
00973         // At this point, you could call GetCustomErrorObject and query for
00974         // additional interfaces to determine what else happened.
00975
00976         wprintf( L"%s (%#x)\n%s\n", bstrDesc, ErrorInfo.hrError, bstrSrc );
00977     }
00978 #endif
00979
00980     // Get basic error information for the most recent error
00981
00982     ULONG iRecord = cErrRecords - 1;
00983     hr = xErrorRecords->GetBasicErrorInfo( iRecord, pErrorInfo );
00984     if ( FAILED( hr ) )
00985         return hr;
00986
00987     return xErrorRecords->GetErrorInfo( iRecord, lcid, ppIErrorInfo );
00988 } //GetOleDBErrorInfo
00989
00990 //-----------------------------------------------------------------------------
00991 //
00992 //  Function:   DisplayRowsetStatus
00993 //
00994 //  Synopsis:   Retrieves status information about the rowset and catalog.
00995 //
00996 //  Arguments:  [xIRowset] - Rowset about which information is retrieved.
00997 //
00998 //  Returns:    HRESULT result of retrieving the status
00999 //
01000 //-----------------------------------------------------------------------------
01001
01002 HRESULT DisplayRowsetStatus( XInterface<IRowset> & xIRowset )
01003 {
01004     XInterface<IRowsetInfo> xIRowsetInfo;
01005     HRESULT hr = xIRowset->QueryInterface( IID_IRowsetInfo,
01006                                            xIRowsetInfo.GetQIPointer() );
01007
01008     if ( SUCCEEDED( hr ) )
01009     {
01010         // This rowset property is Indexing-Service specific
01011
01012         DBPROPID propId = MSIDXSPROP_ROWSETQUERYSTATUS;
01013         DBPROPIDSET propSet;
01014         propSet.rgPropertyIDs = &propId;
01015         propSet.cPropertyIDs = 1;
01016         const GUID guidRowsetExt = DBPROPSET_MSIDXS_ROWSETEXT;
01017         propSet.guidPropertySet = guidRowsetExt;
01018
01019         ULONG cPropertySets = 0;
01020         DBPROPSET * pPropertySets;
01021
01022         hr = xIRowsetInfo->GetProperties( 1,
01023                                           &propSet,
01024                                           &cPropertySets,
01025                                           &pPropertySets );
01026
01027         if ( SUCCEEDED( hr ) )
01028         {
01029             DWORD dwStatus = pPropertySets->rgProperties->vValue.ulVal;
01030
01031             CoTaskMemFree( pPropertySets->rgProperties );
01032             CoTaskMemFree( pPropertySets );
01033
01034             DWORD dwFill = QUERY_FILL_STATUS( dwStatus );
01035
01036             if ( STAT_ERROR == dwFill )
01037                 DisplayStat( IDS_ROWSET_STAT_ERROR );
01038
01039             DWORD dwReliability = QUERY_RELIABILITY_STATUS( dwStatus );
01040
01041             if ( 0 != ( STAT_PARTIAL_SCOPE & dwReliability ) )
01042                 DisplayStat( IDS_ROWSET_STAT_PARTIAL_SCOPE );
01043             if ( 0 != ( STAT_NOISE_WORDS & dwReliability ) )
01044                 DisplayStat( IDS_ROWSET_STAT_NOISE_WORDS );
01045             if ( 0 != ( STAT_CONTENT_OUT_OF_DATE & dwReliability ) )
01046                 DisplayStat( IDS_ROWSET_STAT_CONTENT_OUT_OF_DATE );
01047             if ( 0 != ( STAT_REFRESH_INCOMPLETE & dwReliability ) )
01048                 DisplayStat( IDS_ROWSET_STAT_REFRESH_INCOMPLETE );
01049             if ( 0 != ( STAT_CONTENT_QUERY_INCOMPLETE & dwReliability ) )
01050                 DisplayStat( IDS_ROWSET_STAT_CONTENT_QUERY_INCOMPLETE );
01051             if ( 0 != ( STAT_TIME_LIMIT_EXCEEDED & dwReliability ) )
01052                 DisplayStat( IDS_ROWSET_STAT_TIME_LIMIT_EXCEEDED );
01053             if ( 0 != ( STAT_SHARING_VIOLATION & dwReliability ) )
01054                 DisplayStat( IDS_ROWSET_STAT_SHARING_VIOLATION );
01055         }
01056     }
01057
01058     return hr;
01059 } //DisplayRowsetStatus
01060
01061 //+-------------------------------------------------------------------------
01062 //
01063 //  Function:   IssueQuery
01064 //
01065 //  Synopsis:   Creates and executes a query, then displays the results.
01066 //
01067 //  Arguments:  [pwcQueryCatalog]       - Catalog name over which query is run
01068 //              [pwcQueryMachine]       - Machine name on which query is run
01069 //              [pwcQueryScope]         - Scope of the query
01070 //              [dwScopeFlags]          - Scope flags
01071 //              [pwcQueryRestrition]    - The actual query string
01072 //              [pwcColumns]            - Output column names
01073 //              [pwcSort]               - Sort order names, may be 0
01074 //              [fDisplayTree]          - TRUE to display the command tree
01075 //              [fQuiet]                - if TRUE, don't display hitcount
01076 //              [fForceUseContentIndex] - TRUE to always use index
01077 //                                        FALSE to allow directory enumeration
01078 //              [fNoQuery]              - if TRUE, just parse and display query
01079 //              [ulDialect]             - Query dialect (1 or 2)
01080 //              [cMaxHits]              - Maximum # of hits, or 0 for no limit
01081 //              [lcid]                  - Locale for the query
01082 //
01083 //  Returns:    HRESULT result of the query
01084 //
01085 //--------------------------------------------------------------------------
01086
01087 HRESULT IssueQuery(
01088     WCHAR const * pwcQueryCatalog,
01089     WCHAR const * pwcQueryMachine,
01090     WCHAR const * pwcQueryScope,
01091     DWORD         dwScopeFlags,
01092     WCHAR const * pwcQueryRestriction,
01093     WCHAR const * pwcColumns,
01094     WCHAR const * pwcSort,
01095     BOOL          fDisplayTree,
01096     BOOL          fQuiet,
01097     BOOL          fForceUseContentIndex,
01098     BOOL          fNoQuery,
01099     ULONG         ulDialect,
01100     ULONG         cMaxHits,
01101     LCID          lcid )
01102 {
01103     // Create an ICommand object.  CIMakeICommand is a shortcut for making an
01104     // ICommand.  The ADVQUERY sample shows the OLE DB equivalent.
01105
01106     XInterface<ICommand> xICommand;
01107     HRESULT hr = CIMakeICommand( xICommand.GetPPointer(),  // result
01108                                  1,                        // 1 scope
01109                                  &dwScopeFlags,            // scope flags
01110                                  &pwcQueryScope,           // scope path
01111                                  &pwcQueryCatalog,         // catalog
01112                                  &pwcQueryMachine );       // machine
01113     if ( FAILED( hr ) )
01114         return hr;
01115
01116     // Set required properties on the ICommand
01117
01118     hr = SetCommandProperties( xICommand.GetPointer(),
01119                                fForceUseContentIndex,
01120                                lcid,
01121                                cMaxHits );
01122     if ( FAILED( hr ) )
01123         return hr;
01124
01125     // Get a command tree object
01126
01127     XInterface<ICommandTree> xICommandTree;
01128     hr = xICommand->QueryInterface( IID_ICommandTree,
01129                                     xICommandTree.GetQIPointer() );
01130     if ( FAILED( hr ) )
01131         return hr;
01132
01133     if ( ulDialect < 3 )
01134     {
01135         // Create an OLE DB query tree based on query parameters.
01136
01137         DBCOMMANDTREE * pTree;
01138         hr = CITextToFullTreeEx( pwcQueryRestriction, // the query itself
01139                                  ulDialect,           // query dialect
01140                                  pwcColumns,          // columns to return
01141                                  pwcSort,             // sort order, may be 0
01142                                  0,                   // reserved
01143                                  &pTree,              // resulting tree
01144                                  0,                   // no custom properties
01145                                  0,                   // no custom properties
01146                                  lcid );              // default locale
01147         if ( FAILED( hr ) )
01148             return hr;
01149
01150         // If directed, display the command tree.
01151
01152         if ( fDisplayTree )
01153         {
01154             wprintf( L"%ws\n", pwcQueryRestriction );
01155             DisplayCommandTree( pTree );
01156         }
01157
01158         // If directed, don't issue the query.  Parsing it was sufficient.
01159
01160         if ( fNoQuery )
01161         {
01162             xICommandTree->FreeCommandTree( &pTree );
01163             return S_OK;
01164         }
01165
01166         // Set the tree in the ICommandTree.  Ownership of the tree is transferred.
01167
01168         hr = xICommandTree->SetCommandTree( &pTree,
01169                                             DBCOMMANDREUSE_NONE,
01170                                             FALSE );
01171         if ( FAILED( hr ) )
01172         {
01173             xICommandTree->FreeCommandTree( &pTree );
01174             return hr;
01175         }
01176     }
01177     else
01178     {
01179         // Get a command text object
01180
01181         XInterface<ICommandText> xICommandText;
01182         hr = xICommand->QueryInterface( IID_ICommandText,
01183                                         xICommandText.GetQIPointer() );
01184         if ( FAILED( hr ) )
01185             return hr;
01186
01187         hr = xICommandText->SetCommandText( DBGUID_SQL, pwcQueryRestriction );
01188         if ( FAILED( hr ) )
01189             return hr;
01190
01191         // If directed, display the command tree.
01192
01193         if ( fDisplayTree )
01194         {
01195             DBCOMMANDTREE * pTree = 0;
01196             hr = xICommandTree->GetCommandTree( &pTree );
01197             if ( FAILED( hr ) )
01198                 return hr;
01199
01200             wprintf( L"%ws\n", pwcQueryRestriction );
01201             DisplayCommandTree( pTree );
01202         }
01203
01204         // If directed, don't issue the query.  Parsing it was sufficient.
01205
01206         if ( fNoQuery )
01207             return S_OK;
01208     }
01209
01210     // Execute the query.  The query is complete when Execute() returns.
01211
01212     XInterface<IRowset> xIRowset;
01213     hr = xICommand->Execute( 0,            // no aggregating IUnknown
01214                              IID_IRowset,  // IID for interface to return
01215                              0,            // no DBPARAMs
01216                              0,            // no rows affected
01217                              xIRowset.GetIUPointer() ); // result
01218     if ( FAILED( hr ) )
01219     {
01220         // Get the real error; OLE DB permits few Execute() return codes
01221
01222         ERRORINFO ErrorInfo;
01223         XInterface<IErrorInfo> xErrorInfo;
01224         HRESULT hr2 = GetOleDBErrorInfo( xICommand.GetPointer(),
01225                                          IID_ICommand,
01226                                          lcid,
01227                                          &ErrorInfo,
01228                                          xErrorInfo.GetPPointer() );
01229
01230         // Post IErrorInfo only if we have a valid pointer to it.
01231
01232         if ( SUCCEEDED( hr2 ) && !xErrorInfo.IsNull() )
01233             hr = ErrorInfo.hrError;
01234
01235         return hr;
01236     }
01237
01238     // Get the count of columns
01239
01240     XInterface<IColumnsInfo> xColumnsInfo;
01241     hr = xIRowset->QueryInterface( IID_IColumnsInfo, xColumnsInfo.GetQIPointer() );
01242     if ( FAILED( hr ) )
01243         return hr;
01244
01245     DBCOLUMNINFO *pColumnInfo = 0;
01246     WCHAR *pColumnNames = 0;
01247     DBORDINAL cColumns = 0;
01248
01249     hr = xColumnsInfo->GetColumnInfo( &cColumns,
01250                                       &pColumnInfo,
01251                                       &pColumnNames );
01252     if ( FAILED( hr ) )
01253         return hr;
01254
01255     // If bookmark was added as column 0, ignore it
01256
01257     if ( 0 != ( pColumnInfo[0].dwFlags & DBCOLUMNFLAGS_ISBOOKMARK ) )
01258         cColumns--;
01259
01260     CoTaskMemFree( pColumnInfo );
01261     CoTaskMemFree( pColumnNames );
01262
01263     // Create an accessor, so data can be retrieved from the rowset.
01264
01265     XInterface<IAccessor> xIAccessor;
01266     hr = xIRowset->QueryInterface( IID_IAccessor,
01267                                    xIAccessor.GetQIPointer() );
01268     if ( FAILED( hr ) )
01269         return hr;
01270
01271     // Column iOrdinals are parallel with those passed to CiTextToFullTree,
01272     // so MapColumnIDs isn't necessary.  These binding values for dwPart,
01273     // dwMemOwner, and wType are the most optimal bindings for Indexing
01274     // Service.
01275
01276     XPtr<DBBINDING> xBindings( (ULONG) cColumns );
01277     if ( xBindings.IsNull() )
01278         return E_OUTOFMEMORY;
01279
01280     memset( xBindings.Get(), 0, sizeof DBBINDING * cColumns );
01281
01282     for ( ULONG i = 0; i < cColumns; i++ )
01283     {
01284         xBindings[i].iOrdinal   = 1 + i; // 1-based column number
01285         xBindings[i].obValue    = i * sizeof( PROPVARIANT * ); // offset
01286         xBindings[i].dwPart     = DBPART_VALUE; // retrieve value, not status
01287         xBindings[i].dwMemOwner = DBMEMOWNER_PROVIDEROWNED; // provider owned
01288         xBindings[i].wType      = DBTYPE_VARIANT | DBTYPE_BYREF; // VARIANT *
01289     }
01290
01291     HACCESSOR hAccessor;
01292     hr = xIAccessor->CreateAccessor( DBACCESSOR_ROWDATA, // rowdata accessor
01293                                      cColumns,           // # of columns
01294                                      xBindings.Get(),    // columns
01295                                      0,                  // ignored
01296                                      &hAccessor,         // result
01297                                      0 );                // no status
01298     if ( FAILED( hr ) )
01299         return hr;
01300
01301     // Display the results of the query.
01302
01303     XPtr<PROPVARIANT *> xData( (ULONG) cColumns );
01304     if ( xData.IsNull() )
01305         hr = E_OUTOFMEMORY;
01306     else
01307     {
01308         DBCOUNTITEM cRowsSoFar = 0;
01309
01310         do
01311         {
01312             DBCOUNTITEM cRowsReturned = 0;
01313             const ULONG cRowsAtATime = 20;
01314             HROW aHRow[cRowsAtATime];
01315             HROW * pgrHRows = aHRow;
01316             hr = xIRowset->GetNextRows( 0,              // no chapter
01317                                         0,              // no rows to skip
01318                                         cRowsAtATime,   // # rows to get
01319                                         &cRowsReturned, // # rows returned
01320                                         &pgrHRows);     // resulting hrows
01321             if ( FAILED( hr ) )
01322                 break;
01323
01324             for ( DBCOUNTITEM iRow = 0; iRow < cRowsReturned; iRow++ )
01325             {
01326                 HRESULT hr2 = xIRowset->GetData( aHRow[iRow],   // hrow being accessed
01327                                                  hAccessor,     // accessor to use
01328                                                  xData.Get() ); // resulting data
01329                 if ( FAILED( hr2 ) )
01330                 {
01331                     hr = hr2;
01332                     break;
01333                 }
01334
01335                 for ( ULONG iCol = 0; iCol < cColumns; iCol++ )
01336                 {
01337                     if ( 0 != iCol )
01338                         wprintf( L"  " );
01339                     DisplayValue( xData[ iCol ] );
01340                 }
01341
01342                 wprintf( L"\n" );
01343             }
01344
01345             // Release the HROWs retrived in GetNextRows
01346
01347             if ( 0 != cRowsReturned )
01348             {
01349                 cRowsSoFar += cRowsReturned;
01350                 xIRowset->ReleaseRows( cRowsReturned, // # of rows to release
01351                                        aHRow,         // rows to release
01352                                        0,             // no options
01353                                        0,             // no refcounts
01354                                        0 );           // no status
01355             }
01356
01357             // Check if all rows are now retrieved.
01358
01359             if ( DB_S_ENDOFROWSET == hr || DB_S_ROWLIMITEXCEEDED == hr )
01360             {
01361                 hr = S_OK; // succeeded, return S_OK from DoQuery
01362                 break;
01363             }
01364
01365             // Check if the query aborted because it was too costly.
01366
01367             if ( DB_S_STOPLIMITREACHED == hr )
01368             {
01369                 CResString str( IDS_QUERYTIMEDOUT );
01370                 wprintf( L"%ws\n", str.Get() );
01371                 hr = S_OK;
01372                 break;
01373             }
01374
01375             if ( FAILED( hr ) )
01376                 break;
01377         } while ( TRUE );
01378
01379         if ( !fQuiet )
01380         {
01381             CResString str( IDS_QUERYDONE );
01382             wprintf( str.Get(), cRowsSoFar, pwcQueryRestriction );
01383         }
01384     }
01385
01386     xIAccessor->ReleaseAccessor( hAccessor, 0 );
01387
01388     // Get query status information
01389
01390     if ( SUCCEEDED( hr ) && !fQuiet )
01391         hr = DisplayRowsetStatus( xIRowset );
01392
01393     return hr;
01394 } //IssueQuery
01395
01396 //+-------------------------------------------------------------------------
01397 //
01398 //  Function:   DoQuery
01399 //
01400 //  Synopsis:   Issues a query and displays an error message on failure
01401 //
01402 //  Arguments:  [pwcQueryCatalog]       - Catalog name over which query is run
01403 //              [pwcQueryMachine]       - Machine name on which query is run
01404 //              [pwcQueryScope]         - Scope of the query
01405 //              [dwScopeFlags]          - Scope flags
01406 //              [pwcQueryRestrition]    - The actual query string
01407 //              [pwcColumns]            - Output column names
01408 //              [pwcSort]               - Sort order names, may be 0
01409 //              [fDisplayTree]          - TRUE to display the command tree
01410 //              [fQuiet]                - if TRUE, don't display hitcount
01411 //              [fForceUseContentIndex] - TRUE to always use index
01412 //                                        FALSE to allow directory enumeration
01413 //              [fNoQuery]              - if TRUE, just parse and display query
01414 //              [ulDialect]             - Query dialect (1 or 2)
01415 //              [cMaxHits]              - Maximum # of hits, or 0 for no limit
01416 //              [lcid]                  - Locale for the query
01417 //
01418 //  Returns:    HRESULT result of the query
01419 //
01420 //--------------------------------------------------------------------------
01421
01422 HRESULT DoQuery(
01423     WCHAR const * pwcCatalog,
01424     WCHAR const * pwcMachine,
01425     WCHAR const * pwcScope,
01426     DWORD         dwScopeFlags,
01427     WCHAR const * pwcRestriction,
01428     WCHAR const * pwcColumns,
01429     WCHAR const * pwcSort,
01430     BOOL          fDisplayTree,
01431     BOOL          fQuiet,
01432     BOOL          fForceUseContentIndex,
01433     BOOL          fNoQuery,
01434     ULONG         ulDialect,
01435     ULONG         cMaxHits,
01436     LCID          lcid )
01437 {
01438     HRESULT hr = IssueQuery( pwcCatalog,
01439                              pwcMachine,
01440                              pwcScope,
01441                              dwScopeFlags,
01442                              pwcRestriction,
01443                              pwcColumns,
01444                              pwcSort,
01445                              fDisplayTree,
01446                              fQuiet,
01447                              fForceUseContentIndex,
01448                              fNoQuery,
01449                              ulDialect,
01450                              cMaxHits,
01451                              lcid );
01452
01453     if ( FAILED( hr ) )
01454         DisplayError( IDS_QUERYFAILED, pwcRestriction, hr, lcid );
01455
01456     return hr;
01457 } //DoQuery
01458
01459 //+-------------------------------------------------------------------------
01460 //
01461 //  Function:   DoQueryFile
01462 //
01463 //  Synopsis:   Issues each query in the specified query file.  A query file
01464 //              is just a text file where each line contains a query.
01465 //
01466 //  Arguments:  [pwcQueryCatalog]       - Catalog name over which query is run
01467 //              [pwcQueryMachine]       - Machine name on which query is run
01468 //              [pwcQueryScope]         - Scope of the query
01469 //              [dwScopeFlags]          - Scope flags
01470 //              [pwcColumns]            - Output column names
01471 //              [pwcSort]               - Sort order names, may be 0
01472 //              [fDisplayTree]          - TRUE to display the command tree
01473 //              [fQuiet]                - if TRUE, don't display hitcount
01474 //              [fForceUseContentIndex] - TRUE to always use index
01475 //                                        FALSE to allow directory enumeration
01476 //              [fNoQuery]              - if TRUE, just parse and display query
01477 //              [ulDialect]             - Query dialect (1 or 2)
01478 //              [cMaxHits]              - Maximum # of hits, or 0 for no limit
01479 //              [lcid]                  - Locale for the query
01480 //              [pwcQueryFile]          - File containing queries, 1 per line
01481 //
01482 //  Returns:    HRESULT result of the query
01483 //
01484 //--------------------------------------------------------------------------
01485
01486 HRESULT DoQueryFile(
01487     WCHAR const * pwcQueryCatalog,
01488     WCHAR const * pwcQueryMachine,
01489     WCHAR const * pwcQueryScope,
01490     DWORD         dwScopeFlags,
01491     WCHAR const * pwcColumns,
01492     WCHAR const * pwcSort,
01493     BOOL          fDisplayTree,
01494     BOOL          fQuiet,
01495     BOOL          fForceUseContentIndex,
01496     BOOL          fNoQuery,
01497     ULONG         ulDialect,
01498     ULONG         cMaxHits,
01499     LCID          lcid,
01500     WCHAR const * pwcQueryFile )
01501 {
01502     // Open and read the query file
01503
01504     HANDLE hFile = CreateFile( pwcQueryFile,
01505                                FILE_GENERIC_READ,
01506                                FILE_SHARE_READ | FILE_SHARE_DELETE,
01507                                0,
01508                                OPEN_EXISTING,
01509                                0,
01510                                0 );
01511
01512     if ( 0 == hFile || INVALID_HANDLE_VALUE == hFile )
01513         return DisplayWin32Error( IDS_CANTOPENFILE,
01514                                   pwcQueryFile,
01515                                   lcid );
01516
01517     DWORD cbFile = GetFileSize( hFile, 0 );
01518
01519     if ( 0xffffffff == cbFile )
01520     {
01521         CloseHandle( hFile );
01522         return DisplayWin32Error( IDS_CANTGETFILESIZE,
01523                                   pwcQueryFile,
01524                                   lcid );
01525     }
01526
01527     // Allocate a buffer for the file
01528
01529     XPtr<BYTE> xQueries( cbFile + sizeof WCHAR );
01530     if ( xQueries.IsNull() )
01531     {
01532         CloseHandle( hFile );
01533         SetLastError( ERROR_NOT_ENOUGH_MEMORY );
01534         return DisplayWin32Error( IDS_CANTGETMEMORY,
01535                                   pwcQueryFile,
01536                                   lcid );
01537     }
01538
01539     // Read the file into the buffer
01540
01541     DWORD cbRead;
01542     BOOL fRead = ReadFile( hFile, xQueries.Get(), cbFile, &cbRead, 0 );
01543
01544     CloseHandle( hFile );
01545
01546     if ( ! fRead )
01547         return DisplayWin32Error( IDS_CANTREADFROMFILE,
01548                                   pwcQueryFile,
01549                                   lcid );
01550
01551     // Check if the file is Unicode already
01552
01553     BOOL fUnicode = ( 0xfeff == ( * (WCHAR *) xQueries.Get() ) );
01554
01555     WCHAR * pwcIn = 0;
01556     DWORD cwcIn = 0;
01557
01558     if ( fUnicode )
01559     {
01560         pwcIn = (WCHAR *) xQueries.Get();
01561
01562         // skip past the Unicode marker
01563
01564         pwcIn++;
01565         cwcIn = ( cbFile / sizeof WCHAR ) - 1;
01566     }
01567     else
01568     {
01569         // Convert to Unicode.  Leave a little room for slack.
01570
01571         DWORD cbTmp = cbFile * sizeof WCHAR + cbFile / 8;
01572         XPtr<BYTE> xTmp( cbTmp + sizeof WCHAR );
01573         if ( xTmp.IsNull() )
01574         {
01575             SetLastError( ERROR_NOT_ENOUGH_MEMORY );
01576             return DisplayWin32Error( IDS_CANTGETMEMORY,
01577                                       pwcQueryFile,
01578                                       lcid );
01579         }
01580
01581         cwcIn = MultiByteToWideChar( LocaleToCodepage( lcid ),
01582                                      0,
01583                                      (const char *) xQueries.Get(),
01584                                      cbFile,
01585                                      (WCHAR *) xTmp.Get(),
01586                                      cbTmp );
01587         if ( 0 == cwcIn )
01588             return DisplayWin32Error( IDS_CANTCONVERTTOUNICODE,
01589                                       pwcQueryFile,
01590                                       lcid );
01591
01592         pwcIn = (WCHAR *) xTmp.Get();
01593         xQueries.Free();
01594         xQueries.Set( xTmp.Acquire() );
01595     }
01596
01597     // Read each line in the file and issue the query
01598
01599     pwcIn[ cwcIn ] = 0;
01600     WCHAR * pwc = pwcIn;
01601
01602     do
01603     {
01604         while ( 0     != *pwcIn &&
01605                 L'\r' != *pwcIn &&
01606                 L'\n' != *pwcIn )
01607             pwcIn++;
01608
01609         BOOL fEOF = ( 0 == *pwcIn );
01610
01611         *pwcIn = 0;
01612
01613         if ( pwc != pwcIn )
01614         {
01615             DoQuery( pwcQueryCatalog,
01616                      pwcQueryMachine,
01617                      pwcQueryScope,
01618                      dwScopeFlags,
01619                      pwc,
01620                      pwcColumns,
01621                      pwcSort,
01622                      fDisplayTree,
01623                      fQuiet,
01624                      fForceUseContentIndex,
01625                      fNoQuery,
01626                      ulDialect,
01627                      cMaxHits,
01628                      lcid );
01629             wprintf( L"\n\n" );
01630         }
01631
01632         if ( fEOF )
01633             break;
01634
01635         pwcIn++;
01636         while ( '\r' == *pwcIn || '\n' == *pwcIn )
01637             pwcIn++;
01638         pwc = pwcIn;
01639     } while ( TRUE );
01640
01641     return S_OK;
01642 } //DoQueryFile
01643
01644 //+-------------------------------------------------------------------------
01645 //
01646 //  Function:   LookupCatalog
01647 //
01648 //  Synopsis:   Looks for a catalog and machine matching the scope
01649 //
01650 //  Arguments:  [pwcScope]   - The scope used to find the catalog
01651 //              [pwcMachine] - Returns the machine name
01652 //              [cwcMachine] - In/Out: Count of characters in pwcMachine
01653 //              [pwcCatalog] - Returns the catalog name
01654 //              [cwcCatalog] - In/Out: Count of characters in pwcCatalog
01655 //              [lcid]       - Locale to use for errors
01656 //
01657 //--------------------------------------------------------------------------
01658
01659 HRESULT LookupCatalog(
01660     WCHAR const * pwcScope,
01661     WCHAR *       pwcMachine,
01662     ULONG &       cwcMachine,
01663     WCHAR *       pwcCatalog,
01664     ULONG &       cwcCatalog,
01665     LCID          lcid )
01666 {
01667     HRESULT hr = LocateCatalogs( pwcScope,       // scope to lookup
01668                                  0,              // go with the first match
01669                                  pwcMachine,     // returns the machine
01670                                  &cwcMachine,    // buffer size in/out
01671                                  pwcCatalog,     // returns the catalog
01672                                  &cwcCatalog );  // buffer size in/out
01673
01674     if ( FAILED( hr ) || ( S_FALSE == hr ) )
01675     {
01676         DisplayError( IDS_CANTFINDCATALOG, pwcScope, hr, lcid );
01677         hr = E_FAIL;
01678     }
01679
01680     return hr;
01681 } //LookupCatalog
01682
01683 //+-------------------------------------------------------------------------
01684 //
01685 //  Function:   NormalizeScope
01686 //
01687 //  Synopsis:   Normalizes a scope and sets scope flags.
01688 //
01689 //  Arguments:  [pwcIn]        - The scope for the query
01690 //              [pwcOut]       - Returns the scope for the query
01691 //              [dwScopeFlags] - Returns the scope flags for the query
01692 //
01693 //--------------------------------------------------------------------------
01694
01695 HRESULT NormalizeScope(
01696     WCHAR const * pwcIn,
01697     WCHAR *       pwcOut,
01698     BOOL          fShallow,
01699     DWORD &       dwScopeFlags )
01700 {
01701     if ( wcslen( pwcIn ) >= MAX_PATH )
01702         return E_INVALIDARG;
01703
01704     if ( fShallow )
01705         dwScopeFlags = QUERY_SHALLOW;
01706     else
01707         dwScopeFlags = QUERY_DEEP;
01708
01709     wcscpy( pwcOut, pwcIn );
01710
01711     // Check if the scope is an IIS virtual scope.
01712
01713     WCHAR wc = pwcIn[0];
01714
01715     if ( L'/' == wc )
01716     {
01717         // Set the virtual scope flag and flip the slashes.
01718
01719         dwScopeFlags |= QUERY_VIRTUAL_PATH;
01720         for ( WCHAR * pwc = pwcOut; *pwc; pwc++ )
01721             if ( '/' == *pwc )
01722                 *pwc = '\\';
01723     }
01724     else if ( ( !( L'\\' == wc && L'\\' == pwcIn[1] ) ) &&
01725               ( !( L'\\' == wc && 0 == pwcIn[1] ) ) &&
01726               L':' != pwcIn[1] &&
01727               0 != wc )
01728     {
01729         // Turn the relative path into a full path based on the current dir.
01730
01731         _wfullpath( pwcOut, pwcIn, MAX_PATH );
01732     }
01733
01734     return S_OK;
01735 } //NormalizeScope
01736
01737 //+-------------------------------------------------------------------------
01738 //
01739 //  Function:   DisplayStatus
01740 //
01741 //  Synopsis:   Displays status information about a catalog
01742 //
01743 //  Arguments:  [pwcCatalog] - Catalog name
01744 //              [pwcMachine] - Machine on which catalog resides
01745 //              [lcid]       - Locale to use
01746 //
01747 //--------------------------------------------------------------------------
01748
01749 HRESULT DisplayStatus(
01750     WCHAR const * pwcCatalog,
01751     WCHAR const * pwcMachine,
01752     LCID          lcid )
01753 {
01754     CI_STATE state;
01755     state.cbStruct = sizeof state;
01756
01757     DisplayStat( pwcMachine, IDS_STAT_MACHINE );
01758     DisplayStat( pwcCatalog, IDS_STAT_CATALOG );
01759
01760     HRESULT hr = CIState( pwcCatalog, pwcMachine, &state );
01761
01762     if ( SUCCEEDED( hr ) )
01763     {
01764         DisplayStat( state.cTotalDocuments, IDS_STAT_TOTALDOCUMENTS );
01765         DisplayStat( state.cFreshTest, IDS_STAT_FRESHTEST );
01766         DisplayStat( state.cFilteredDocuments, IDS_STAT_FILTEREDDOCUMENTS );
01767         DisplayStat( state.cDocuments, IDS_STAT_DOCUMENTS );
01768         DisplayStat( state.cSecQDocuments, IDS_STAT_SECQDOCUMENTS );
01769         DisplayStat( state.cUniqueKeys, IDS_STAT_UNIQUEKEYS );
01770         DisplayStat( state.cWordList, IDS_STAT_WORDLIST );
01771         DisplayStat( state.cPersistentIndex, IDS_STAT_PERSISTENTINDEX );
01772         DisplayStat( state.cQueries, IDS_STAT_QUERIES );
01773         DisplayStat( state.dwIndexSize, IDS_STAT_INDEXSIZE );
01774         DisplayStat( state.dwPropCacheSize / 1024, IDS_STAT_PROPCACHESIZE );
01775
01776         DisplayStat( ( state.eState & CI_STATE_SCANNING ) ?
01777                      state.cPendingScans : 0,
01778                      IDS_STAT_SCANS );
01779
01780         const DWORD ALL_CI_MERGE = ( CI_STATE_SHADOW_MERGE |
01781                                      CI_STATE_ANNEALING_MERGE |
01782                                      CI_STATE_INDEX_MIGRATION_MERGE |
01783                                      CI_STATE_MASTER_MERGE |
01784                                      CI_STATE_MASTER_MERGE_PAUSED );
01785
01786         if ( 0 != ( ALL_CI_MERGE & state.eState ) )
01787         {
01788             UINT idStr;
01789             if ( state.eState & CI_STATE_SHADOW_MERGE )
01790                 idStr = IDS_STAT_MERGE_SHADOW;
01791             else if ( state.eState & CI_STATE_ANNEALING_MERGE )
01792                 idStr = IDS_STAT_MERGE_ANNEALING;
01793             else if ( state.eState & CI_STATE_INDEX_MIGRATION_MERGE )
01794                 idStr = IDS_STAT_MERGE_INDEX_MIGRATION;
01795             else if ( state.eState & CI_STATE_MASTER_MERGE )
01796                 idStr = IDS_STAT_MERGE_MASTER;
01797             else
01798                 idStr = IDS_STAT_MERGE_MASTER_PAUSED;
01799
01800             DisplayStat( state.dwMergeProgress, idStr );
01801         }
01802
01803         if ( CI_STATE_READ_ONLY & state.eState )
01804             DisplayStat( IDS_STAT_READ_ONLY );
01805         if ( CI_STATE_RECOVERING & state.eState )
01806             DisplayStat( IDS_STAT_RECOVERING );
01807         if ( CI_STATE_LOW_MEMORY & state.eState )
01808             DisplayStat( IDS_STAT_LOW_MEMORY );
01809         if ( CI_STATE_HIGH_IO & state.eState )
01810             DisplayStat( IDS_STAT_HIGH_IO );
01811         if ( CI_STATE_BATTERY_POWER & state.eState )
01812             DisplayStat( IDS_STAT_BATTERY_POWER );
01813         if ( CI_STATE_USER_ACTIVE & state.eState )
01814             DisplayStat( IDS_STAT_USER_ACTIVE );
01815         if ( CI_STATE_STARTING & state.eState )
01816             DisplayStat( IDS_STAT_STARTING );
01817         if ( CI_STATE_READING_USNS & state.eState )
01818             DisplayStat( IDS_STAT_READING_USNS );
01819     }
01820     else
01821     {
01822         DisplayError( IDS_CANTDISPLAYSTATUS, pwcCatalog, hr, lcid );
01823     }
01824
01825     return hr;
01826 } //DisplayStatus
01827
01828 //+-------------------------------------------------------------------------
01829 //
01830 //  Function:   DisplayUpToDate
01831 //
01832 //  Synopsis:   Checks if the index is up to date.
01833 //
01834 //  Arguments:  [pwcCatalog] - Catalog name
01835 //              [pwcMachine] - Machine on which catalog resides
01836 //              [lcid]       - Locale to use
01837 //
01838 //--------------------------------------------------------------------------
01839
01840 HRESULT DisplayUpToDate(
01841     WCHAR const * pwcCatalog,
01842     WCHAR const * pwcMachine,
01843     LCID          lcid )
01844 {
01845     CI_STATE state;
01846     state.cbStruct = sizeof state;
01847
01848     HRESULT hr = CIState( pwcCatalog, pwcMachine, &state );
01849
01850     if ( SUCCEEDED( hr ) )
01851     {
01852         // It's up to date if there are no documents to filter, no scans or
01853         // usn activity, and the index isn't starting or recovering.
01854
01855         BOOL fUpToDate = ( ( 0 == state.cDocuments ) &&
01856                            ( 0 == ( state.eState & CI_STATE_SCANNING ) ) &&
01857                            ( 0 == ( state.eState & CI_STATE_READING_USNS ) ) &&
01858                            ( 0 == ( state.eState & CI_STATE_STARTING ) ) &&
01859                            ( 0 == ( state.eState & CI_STATE_RECOVERING ) ) );
01860
01861         DisplayStat( fUpToDate ? IDS_STAT_UP_TO_DATE :
01862                                  IDS_STAT_NOT_UP_TO_DATE );
01863     }
01864     else
01865     {
01866         DisplayError( IDS_CANTDISPLAYSTATUS, pwcCatalog, hr, lcid );
01867     }
01868
01869     return hr;
01870 } //DisplayUpToDate
01871
01872 //+-------------------------------------------------------------------------
01873 //
01874 //  Function:   wmain
01875 //
01876 //  Synopsis:   Entry point for the app.  Parses command line arguments and
01877 //              issues a query.
01878 //
01879 //  Arguments:  [argc]     - Argument count
01880 //              [argv]     - Arguments
01881 //
01882 //--------------------------------------------------------------------------
01883
01884 extern "C" int __cdecl wmain( int argc, WCHAR * argv[] )
01885 {
01886     WCHAR const * pwcCatalog     = 0;        // default: lookup catalog
01887     WCHAR const * pwcMachine     = L".";     // default: local machine
01888     WCHAR const * pwcScope       = L"\\";    // default: entire catalog
01889     WCHAR const * pwcRestriction = 0;        // no default restriction
01890     WCHAR const * pwcColumns     = L"path";  // default output column(s)
01891     WCHAR const * pwcSort        = 0;        // no sort is the default
01892     WCHAR const * pwcQueryFile   = 0;        // no query file specified
01893     WCHAR const * pwcLocale      = 0;        // default: system locale
01894     BOOL fDisplayTree            = FALSE;    // don't display the tree
01895     BOOL fForceUseContentIndex   = TRUE;     // always use the index
01896     ULONG ulDialect              = 1;        // original query language dialect
01897     BOOL fQuiet                  = FALSE;    // show the hitcount
01898     ULONG cMaxHits               = 0;        // default: retrieve all hits
01899     BOOL fDisplayStatus          = FALSE;    // default: don't show status
01900     BOOL fDisplayUpToDate        = FALSE;    // default: don't show up to date
01901     ULONG cRepetitions           = 1;        // # of times to repeat command
01902     BOOL fShallow                = FALSE;    // default: all subdirectories
01903     BOOL fNoQuery                = FALSE;    // default: execute query
01904
01905     // Parse command line parameters
01906
01907     for ( int i = 1; i < argc; i++ )
01908     {
01909         if ( L'-' == argv[i][0] || L'/' == argv[i][0] )
01910         {
01911             WCHAR wc = towupper( argv[i][1] );
01912
01913             if ( ':' != argv[i][2] &&
01914                  'D' != wc &&
01915                  'J' != wc &&
01916                  'N' != wc &&
01917                  'Q' != wc &&
01918                  'U' != wc &&
01919                  'T' != wc )
01920                 Usage();
01921
01922             if ( 'C' == wc )
01923                 pwcCatalog = argv[i] + 3;
01924             else if ( 'M' == wc )
01925                 pwcMachine = argv[i] + 3;
01926             else if ( 'P' == wc )
01927                 pwcScope = argv[i] + 3;
01928             else if ( 'O' == wc )
01929                 pwcColumns = argv[i] + 3;
01930             else if ( 'S' == wc )
01931                 pwcSort = argv[i] + 3;
01932             else if ( 'X' == wc )
01933                 cMaxHits = _wtoi( argv[i] + 3 );
01934             else if ( 'I' == wc )
01935             {
01936                 if ( 0 != pwcRestriction )
01937                     Usage();
01938                 pwcQueryFile = argv[i] + 3;
01939             }
01940             else if ( 'R' == wc)
01941             {
01942                 // get the next arg as a number
01943                 cRepetitions = _wtol(argv[i]+3);
01944             }
01945             else if ( 'D' == wc )
01946                 fDisplayTree = TRUE;
01947             else if ( 'J' == wc )
01948                 fShallow = TRUE;
01949             else if ( 'N' == wc )
01950                 fNoQuery = TRUE;
01951             else if ( 'Q' == wc )
01952                 fQuiet = TRUE;
01953             else if ( 'T' == wc )
01954                 fDisplayStatus = TRUE;
01955             else if ( 'U' == wc )
01956                 fDisplayUpToDate = TRUE;
01957             else if ( 'E' == wc )
01958                 pwcLocale = argv[i] + 3;
01959             else if ( 'L' == wc )
01960             {
01961                 if ( '1' == argv[i][3] )
01962                     ulDialect = 1;
01963                 else if ( '2' == argv[i][3] )
01964                     ulDialect = 2;
01965                 else if ( '3' == argv[i][3] )
01966                     ulDialect = 3;
01967                 else
01968                     Usage();
01969             }
01970             else if ( 'F' == wc )
01971             {
01972                 if ( '+' == argv[i][3] )
01973                     fForceUseContentIndex = TRUE;
01974                 else if ( '-' == argv[i][3] )
01975                     fForceUseContentIndex = FALSE;
01976                 else
01977                     Usage();
01978             }
01979             else
01980                 Usage();
01981         }
01982         else if ( 0 != pwcRestriction || 0 != pwcQueryFile )
01983             Usage();
01984         else
01985             pwcRestriction = argv[i];
01986     }
01987
01988     // A query restriction, query file, or status request is necessary.
01989
01990     if ( 0 == pwcRestriction && 0 == pwcQueryFile &&
01991          !fDisplayStatus && !fDisplayUpToDate )
01992         Usage();
01993
01994     // Normalize relative and virtual scopes
01995
01996     WCHAR awcScope[ MAX_PATH ];
01997     DWORD dwScopeFlags;
01998     HRESULT hr = NormalizeScope( pwcScope, awcScope, fShallow, dwScopeFlags );
01999
02000     // Initialize OLE
02001
02002     BOOL fCoInit = FALSE;
02003
02004     if ( SUCCEEDED( hr ) )
02005     {
02006         hr = CoInitialize( 0 );
02007         if ( SUCCEEDED( hr ) )
02008             fCoInit = TRUE;
02009     }
02010
02011     if ( FAILED( hr ) )
02012         return -1;
02013
02014     // Get the locale identifier to use for the query
02015
02016     LCID lcid = LcidFromHttpAcceptLanguage( pwcLocale );
02017
02018     // If no catalog was specified, infer one based on the scope
02019
02020     WCHAR awcMachine[ MAX_PATH ], awcCatalog[ MAX_PATH ];
02021
02022     if ( SUCCEEDED( hr ) && ( 0 == pwcCatalog ) && !fNoQuery )
02023     {
02024         ULONG cwcMachine = sizeof awcMachine / sizeof WCHAR;
02025         ULONG cwcCatalog = sizeof awcCatalog / sizeof WCHAR;
02026         hr = LookupCatalog( awcScope,
02027                             awcMachine,
02028                             cwcMachine,
02029                             awcCatalog,
02030                             cwcCatalog,
02031                             lcid );
02032         pwcMachine = awcMachine;
02033         pwcCatalog = awcCatalog;
02034
02035         // Turn scopes like \\machine into \ now that the lookup is done
02036         // and we've found a catalog and machine name.
02037
02038         if ( SUCCEEDED( hr ) &&
02039              L'\\' == awcScope[0] && L'\\' == awcScope[1] &&
02040              0 == wcschr( awcScope + 2, L'\\' ) )
02041             awcScope[1] = 0;
02042     }
02043
02044     if ( SUCCEEDED( hr ) )
02045     {
02046         for (ULONG j = 0; j < cRepetitions; j++)
02047         {
02048             if ( 0 != pwcQueryFile )
02049                 hr = DoQueryFile( fNoQuery ? L"::_noquery" : pwcCatalog,
02050                                   pwcMachine,
02051                                   awcScope,
02052                                   dwScopeFlags,
02053                                   pwcColumns,
02054                                   pwcSort,
02055                                   fDisplayTree,
02056                                   fQuiet,
02057                                   fForceUseContentIndex,
02058                                   fNoQuery,
02059                                   ulDialect,
02060                                   cMaxHits,
02061                                   lcid,
02062                                   pwcQueryFile );
02063             else if ( 0 != pwcRestriction )
02064                 hr = DoQuery( fNoQuery ? L"::_noquery" : pwcCatalog,
02065                               pwcMachine,
02066                               awcScope,
02067                               dwScopeFlags,
02068                               pwcRestriction,
02069                               pwcColumns,
02070                               pwcSort,
02071                               fDisplayTree,
02072                               fQuiet,
02073                               fForceUseContentIndex,
02074                               fNoQuery,
02075                               ulDialect,
02076                               cMaxHits,
02077                               lcid );
02078
02079             if ( SUCCEEDED( hr ) && fDisplayStatus )
02080                 hr = DisplayStatus( pwcCatalog, pwcMachine, lcid );
02081
02082             if ( SUCCEEDED( hr ) && fDisplayUpToDate )
02083                 hr = DisplayUpToDate( pwcCatalog, pwcMachine, lcid );
02084         }
02085     }
02086
02087     if ( fCoInit )
02088         CoUninitialize();
02089
02090     if ( FAILED( hr ) )
02091         return -1;
02092
02093     return 0;
02094 } //wmain
02095
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/limits.h Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

limits.h

Go to the documentation of this file.
00001 #ifndef _LIMITS_H
00002 #define _LIMITS_H
00003
00004 // These are the static limits placed on the internal structures
00005 // The limits exist to minimize the use of the heap, and aid performance
00006 // and scalability of the framework.
00007
00008 // MAX_FIELD_DATA_SIZE has a significant effect on the size of the CProxy object
00009 #define MAX_FIELD_DATA_SIZE 2048// max length of field value buffer (number of WCHARs)
00010
00011 // ENTITY_BANKS * ENTITY_PER_BANK = max number of rows returned from a query
00012 #define ENTITY_PER_BANK 100   // max entities per entity bank in EntityQuery
00013 #define ENTITY_BANKS 100    // max number of entity banks in EntityQuery
00014
00015 // Not a significant in dynamic memory overhead (i.e. only used on stack)
00016 #define FIELDNAME_MAXSIZE 128 // max size of a field name
00017
00018 #endif
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MIDL_PROC_FORMAT_STRING Member List

This is the complete list of members for _MIDL_PROC_FORMAT_STRING, including all inherited members.
Format | _MIDL_PROC_FORMAT_STRING
Pad | _MIDL_PROC_FORMAT_STRING
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/about.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

about.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  Implementation of ISnapinAbout
00014 //
00015
00016
00017 #include "Globals.h"
00018 #include "About.h"
00019 #include "Resource.h"
00020
00021 /////////////////////////////////////////////////////////////////////////////
00022 //  Construction/Destruction
00023
00024 //---------------------------------------------------------------------------
00025 CSnapinAbout::CSnapinAbout()
00026 {
00027   m_cRef = 0;
00028   InterlockedIncrement((long*)&g_uObjectCount);
00029
00030   m_hSmallImage = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_16), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00031   m_hLargeImage = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_32), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
00032
00033   // This image is displayed when the static node is selected
00034   m_hOpenImage  = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_APPIMG_16), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
00035
00036   m_hAppIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_APP_ICON));
00037 }
00038
00039 CSnapinAbout::~CSnapinAbout()
00040 {
00041   SAFE_FREE_BITMAP( m_hSmallImage );
00042   SAFE_FREE_BITMAP( m_hLargeImage );
00043   SAFE_FREE_BITMAP( m_hOpenImage  );
00044   SAFE_FREE_ICON( m_hAppIcon );
00045
00046   InterlockedDecrement((long*)&g_uObjectCount);
00047 }
00048
00049 /////////////////////////////////////////////////////////////////////////////
00050 // IUnknown implementation
00051
00052 //---------------------------------------------------------------------------
00053 STDMETHODIMP CSnapinAbout::QueryInterface
00054 (
00055   REFIID   riid,       //[in] Identifier of the requested interface
00056   LPVOID   *ppv        //[out] Address of requested interface
00057 )
00058 {
00059   if( !ppv )
00060     return E_FAIL;
00061
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065     *ppv = static_cast<ISnapinAbout*>(this);
00066   else if( IsEqualIID(riid, IID_ISnapinAbout) )
00067     *ppv = static_cast<ISnapinAbout*>(this);
00068
00069   if( *ppv )
00070   {
00071     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00072     return S_OK;
00073   }
00074
00075   return E_NOINTERFACE;
00076 }
00077
00078 //---------------------------------------------------------------------------
00079 STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
00080 {
00081   return InterlockedIncrement((long*)&m_cRef);
00082 }
00083
00084 //---------------------------------------------------------------------------
00085 STDMETHODIMP_(ULONG) CSnapinAbout::Release()
00086 {
00087   if( 0 == InterlockedDecrement((long*)&m_cRef) )
00088   {
00089     // we need to decrement our object count in the DLL
00090     delete this;
00091     return 0;
00092   }
00093   return m_cRef;
00094 }
00095
00096
00097 /////////////////////////////////////////////////////////////////////////////
00098 // Interface ISnapinAbout
00099
00100 //---------------------------------------------------------------------------
00101 STDMETHODIMP CSnapinAbout::GetSnapinDescription
00102 (
00103   LPOLESTR* pszDescription   //[out] Pointer to the description text
00104 )
00105 {
00106   LONG nLen = wcslen( gwszABOUT_DESCRIPTION ) + 1;
00107   *pszDescription = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00108   if( NULL == *pszDescription )
00109     return E_OUTOFMEMORY;
00110
00111   wcscpy( *pszDescription, gwszABOUT_DESCRIPTION );
00112   return S_OK;
00113 }
00114
00115 //---------------------------------------------------------------------------
00116 STDMETHODIMP CSnapinAbout::GetProvider
00117 (
00118   LPOLESTR* pszProvider      //[out] Pointer to provider text
00119 )
00120 {
00121   LONG nLen = wcslen( gwszABOUT_PROVIDER ) + 1;
00122   *pszProvider = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00123   if( NULL == *pszProvider )
00124     return E_OUTOFMEMORY;
00125
00126   wcscpy( *pszProvider, gwszABOUT_PROVIDER );
00127   return S_OK;
00128 }
00129
00130 //---------------------------------------------------------------------------
00131 STDMETHODIMP CSnapinAbout::GetSnapinVersion
00132 (
00133   LPOLESTR*  pszVersion      //[out] Pointer to version text
00134 )
00135 {
00136   LONG nLen = wcslen( gwszABOUT_VERSION ) + 1;
00137   *pszVersion = (LPOLESTR)CoTaskMemAlloc( nLen * sizeof(WCHAR) );
00138   if( NULL == *pszVersion )
00139     return E_OUTOFMEMORY;
00140
00141   wcscpy( *pszVersion, gwszABOUT_VERSION );
00142   return S_OK;
00143 }
00144
00145 //---------------------------------------------------------------------------
00146 STDMETHODIMP CSnapinAbout::GetSnapinImage
00147 (
00148   HICON *hAppIcon            //[out] Pointer to the Snap-in's main icon
00149 )
00150 {
00151   *hAppIcon = m_hAppIcon;
00152   HRESULT hResult = S_FALSE;
00153   (NULL == *hAppIcon ) ? hResult = E_FAIL : hResult = S_OK;
00154
00155   return hResult;
00156 }
00157
00158 //---------------------------------------------------------------------------
00159 STDMETHODIMP CSnapinAbout::GetStaticFolderImage
00160 (
00161   HBITMAP*   hSmallImage,      //[out] Pointer to small image
00162   HBITMAP*   hOpenImage,       //[out] Pointer to open folder image
00163   HBITMAP*   hLargeImage,      //[out] Pointer to large image
00164   COLORREF*  cMask             //[out] Pointer to image color mask
00165 )
00166 {
00167   *hSmallImage = m_hSmallImage;
00168   *hLargeImage = m_hLargeImage;
00169   *hOpenImage  = m_hOpenImage;
00170   *cMask = RGB(0, 128, 128);
00171
00172   if( NULL == *hSmallImage || NULL == *hLargeImage || NULL == *hOpenImage )
00173     return E_FAIL;
00174
00175   return S_OK;
00176 }
00177
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

Counter Member List

This is the complete list of members for Counter, including all inherited members.
Bound | Counter
Value | Counter
Generated on Wed Nov 13 2024 16:57:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/Connect.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

Connect.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.H
00003
00004   Summary:   Include file declaring COM object classes and constants for
00005              managing the connection points (and their connections)
00006              exposed by the connectable objects in the PERTEXT server.
00007
00008              For a comprehensive tutorial code tour of this module's
00009              contents and offerings see the tutorial PERTEXT.HTM
00010              file. For more specific technical details on the internal
00011              workings see the comments dispersed throughout the module's
00012              source code.
00013
00014   Functions: .
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Origin:    5-20-97: atrent - Editor inheritance from the STOSERVE COM
00020              Tutorial Code Sample. Very little change was required.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 #if !defined(CONNECT_H)
00038 #define CONNECT_H
00039
00040 #ifdef __cplusplus
00041
00042
00043 // An enumeration giving symbol names for the connection
00044 // points offered by the TextPage component in this server.
00045 enum
00046 {
00047   CONNPOINT_TEXTPAGESINK = 0
00048 };
00049
00050 enum
00051 {
00052   // The maximum number of connection points offered by the TextPage
00053   // component in this PERTEXT server.  The number of items in the
00054   // connection point enumeration above.
00055   MAX_CONNECTION_POINTS = 1,
00056
00057   // A constant for the number of connections to add to the allocation
00058   // of the dynamic connection array.
00059   ALLOC_CONNECTIONS = 8,
00060
00061   // The start value for the connection key (cookie) counter.
00062   COOKIE_START_VALUE = 700
00063 };
00064
00065
00066 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00067   ObjectClass: COEnumConnectionPoints
00068
00069   Summary:     COM object class for enumerating the Connection Points
00070                offered by a connectable object.
00071
00072   Interfaces:  IUnknown
00073                  Standard interface providing COM object features.
00074                IEnumConnectionPoints
00075                  Interface for connection point enumeration.
00076
00077   Aggregation: COEnumConnectionPoints COM Objects are not aggregatable.
00078 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00079 class COEnumConnectionPoints : public IEnumConnectionPoints
00080 {
00081   public:
00082     // Main Object Constructor & Destructor.
00083     COEnumConnectionPoints(IUnknown* pHostObj);
00084     ~COEnumConnectionPoints(void);
00085
00086     // A general method for initializing this newly created object.
00087     // Creates any subordinate arrays, structures, or objects.
00088     HRESULT Init(
00089               ULONG cConnPts,
00090               IConnectionPoint** paConnPts,
00091               ULONG iEnumIndex);
00092
00093     // IUnknown methods. Main object, non-delegating.
00094     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00095     STDMETHODIMP_(ULONG) AddRef(void);
00096     STDMETHODIMP_(ULONG) Release(void);
00097
00098     // IEnumConnectionPoints methods.
00099     STDMETHODIMP         Next(ULONG, IConnectionPoint**, ULONG*);
00100     STDMETHODIMP         Skip(ULONG);
00101     STDMETHODIMP         Reset(void);
00102     STDMETHODIMP         Clone(IEnumConnectionPoints**);
00103
00104   private:
00105     // Private data of COEnumConnectionPoints COM objects.
00106
00107     // Main Object reference count.
00108     ULONG              m_cRefs;
00109
00110     // IUnknown pointer to host COM object being enumerated.
00111     IUnknown*          m_pHostObj;
00112
00113     // Connection Point index variable.
00114     ULONG              m_iEnumIndex;
00115
00116     // Number of Connection Points being enumerated.
00117     ULONG              m_cConnPts;
00118
00119     // Allocated array of Connection Point interface pointers.
00120     IConnectionPoint** m_paConnPts;
00121 };
00122
00123
00124 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00125   ObjectClass: COConnectionPoint
00126
00127   Summary:     Connection Point COM object class. Implements a native
00128                IConnectionPoint interface.
00129
00130   Interfaces:  IUnknown
00131                  Standard interface providing COM object features.
00132                IConnectionPoint
00133                  Interface for connection point features.
00134
00135   Aggregation: COConnectionPoint COM Objects are not aggregatable.
00136 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00137 class COConnectionPoint : public IConnectionPoint
00138 {
00139   public:
00140     // Main Object Constructor & Destructor.
00141     COConnectionPoint(IUnknown* pHostObj);
00142     ~COConnectionPoint(void);
00143
00144     // A general method for initializing this newly created object.
00145     // Creates any subordinate arrays, structures, or objects.
00146     HRESULT Init(REFIID riid);
00147
00148     // IUnknown methods. Main object, non-delegating.
00149     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00150     STDMETHODIMP_(ULONG) AddRef(void);
00151     STDMETHODIMP_(ULONG) Release(void);
00152
00153     // IConnectionPoint methods.
00154     STDMETHODIMP GetConnectionInterface(IID*);
00155     STDMETHODIMP GetConnectionPointContainer(IConnectionPointContainer**);
00156     STDMETHODIMP Advise(IUnknown*, DWORD*);
00157     STDMETHODIMP Unadvise(DWORD);
00158     STDMETHODIMP EnumConnections(IEnumConnections**);
00159
00160   private:
00161     // Private utility methods of COConnectionPoint.
00162     HRESULT GetSlot(UINT* puiFreeSlot);
00163     HRESULT FindSlot(DWORD dwCookie, UINT* puiSlot);
00164
00165     // Private data of COConnectionPoint COM objects.
00166
00167     // Main Object reference count.
00168     ULONG          m_cRefs;
00169
00170     // IUnknown pointer to host COM object offering this connection point.
00171     IUnknown*      m_pHostObj;
00172
00173     // The IID of the sink interface associated with this connection point.
00174     IID            m_iidSink;
00175
00176     // The current connection cookie (key) counter.
00177     DWORD          m_dwNextCookie;
00178
00179     // The current number of live sink connections to this connection point.
00180     UINT           m_cConnections;
00181
00182     // The current maximum index into the dynamic connection array.
00183     UINT           m_uiMaxIndex;
00184
00185     // The dynamic array of sink connections to this connection point.
00186     CONNECTDATA*   m_paConnections;
00187 };
00188
00189
00190 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00191   ObjectClass: COEnumConnections
00192
00193   Summary:     COM object class for enumerating the connections of a
00194                connection point of a connectable object.
00195
00196   Interfaces:  IUnknown
00197                  Standard interface providing COM object features.
00198                IEnumConnections
00199                  Interface for connection enumeration features.
00200
00201   Aggregation: COEnumConnections COM Objects are not aggregatable.
00202 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00203 class COEnumConnections : public IEnumConnections
00204 {
00205   public:
00206     // Main Object Constructor & Destructor.
00207     COEnumConnections(IUnknown* pHostObj);
00208     ~COEnumConnections(void);
00209
00210     // A general method for initializing this newly created object.
00211     // Creates any subordinate arrays, structures, or objects.
00212     HRESULT Init(
00213               ULONG cConnections,
00214               CONNECTDATA* paConnections,
00215               ULONG iEnumIndex);
00216
00217     // IUnknown methods. Main object, non-delegating.
00218     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00219     STDMETHODIMP_(ULONG) AddRef(void);
00220     STDMETHODIMP_(ULONG) Release(void);
00221
00222     // IEnumConnections methods.
00223     STDMETHODIMP         Next(ULONG, CONNECTDATA*, ULONG*);
00224     STDMETHODIMP         Skip(ULONG);
00225     STDMETHODIMP         Reset(void);
00226     STDMETHODIMP         Clone(IEnumConnections**);
00227
00228   private:
00229     // Private data of COEnumConnections COM objects.
00230
00231     // Main Object reference count.
00232     ULONG            m_cRefs;
00233
00234     // IUnknown pointer to host connection point COM object being
00235     // enumerated.
00236     IUnknown*        m_pHostObj;
00237
00238     // Connection index variable.
00239     ULONG            m_iEnumIndex;
00240
00241     // Number of Connections being enumerated.
00242     ULONG            m_cConnections;
00243
00244     // Allocated array of live Connections only.
00245     CONNECTDATA*     m_paConnections;
00246 };
00247
00248 #endif // __cplusplus
00249
00250
00251 #endif // CONNECT_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ParameterDirectionEnum Member List

This is the complete list of members for msado15::ParameterDirectionEnum, including all inherited members.
adParamInput | msado15::ParameterDirectionEnum | [static]
adParamInputOutput | msado15::ParameterDirectionEnum | [static]
adParamOutput | msado15::ParameterDirectionEnum | [static]
adParamReturnValue | msado15::ParameterDirectionEnum | [static]
adParamUnknown | msado15::ParameterDirectionEnum | [static]
Generated on Wed Nov 13 2024 16:58:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step2/dlldata.c Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step2

dlldata.c

Go to the documentation of this file.
00001 /*********************************************************
00002    DllData file -- generated by MIDL compiler
00003
00004         DO NOT ALTER THIS FILE
00005
00006    This file is regenerated by MIDL on every IDL file compile.
00007
00008    To completely reconstruct this file, delete it and rerun MIDL
00009    on all the IDL files in this DLL, specifying this file for the
00010    /dlldata command line option
00011
00012 *********************************************************/
00013
00014 #define PROXY_DELEGATION
00015
00016 #include <rpcproxy.h>
00017
00018 #ifdef __cplusplus
00019 extern "C"   {
00020 #endif
00021
00022 EXTERN_PROXY_FILE( ADsFirstExt )
00023
00024
00025 PROXYFILE_LIST_START
00026 /* Start of list */
00027   REFERENCE_PROXY_FILE( ADsFirstExt ),
00028 /* End of list */
00029 PROXYFILE_LIST_END
00030
00031
00032 DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
00033
00034 #ifdef __cplusplus
00035 }  /*extern "C" */
00036 #endif
00037
00038 /* end of generated dlldata file */
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cobjtree.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cobjtree.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module COBJTREE.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////
00016 #include "Headers.h"
00017 #include "CObjTree.h"
00018
00019
00020 ////////////////////////////////////////////////////////////////
00021 // CObjTree::CObjTree
00022 //
00023 /////////////////////////////////////////////////////////////////
00024 CObjTree::CObjTree(CMainWindow* pCMainWindow)
00025 {
00026   //Data
00027   ASSERT(pCMainWindow);
00028   m_pCMainWindow = pCMainWindow;
00029 }
00030
00031
00032 ////////////////////////////////////////////////////////////////
00033 // CObjTree::~CObjTree
00034 //
00035 /////////////////////////////////////////////////////////////////
00036 CObjTree::~CObjTree()
00037 {
00038 }
00039
00040
00041 ////////////////////////////////////////////////////////////////
00042 // CObjTree::OnRButtonDown
00043 //
00044 /////////////////////////////////////////////////////////////////
00045 BOOL CObjTree::OnRButtonDown(WPARAM fwKeys, REFPOINTS pts)
00046 {
00047   //NOTE: The right mouse button doesn't automatically activate the MDI window...
00048   m_pCMainWindow->MDIActivate(m_hWndParent);
00049
00050   //NOTE: The right mouse doesn't automatically select the tree item
00051   //so we have to find where the mouse clicked and determine the inteneded item...
00052   HTREEITEM hItem = HitTest(pts, NULL);
00053   if(hItem)
00054     SelectItem(hItem);
00055
00056   //Display the Context Menu (for this object)
00057   CBase* pCBase = (CBase*)GetItemParam(hItem);
00058   if(pCBase)
00059   {
00060     UINT nIDMenu = pCBase->GetObjectMenu();
00061     if(nIDMenu)
00062     {
00063       //xPos, yPos are Relative to the Client Area...
00064       DisplayContextMenu(
00065                 m_hWnd,
00066                 nIDMenu,
00067                 pts,
00068                 m_pCMainWindow->GetWnd(),
00069                 TRUE
00070                 );
00071
00072     }
00073   }
00074
00075   return TRUE;
00076 }
00077
00078 ////////////////////////////////////////////////////////////////
00079 // CObjTree::OnContextMenu
00080 //
00081 /////////////////////////////////////////////////////////////////
00082 BOOL CObjTree::OnContextMenu(HWND hWnd, REFPOINTS pts)
00083 {
00084   CBase* pCBase = GetSelectedObject();
00085   if(pCBase)
00086   {
00087     UINT nIDMenu = pCBase->GetObjectMenu();
00088
00089     if(nIDMenu)
00090     {
00091       DisplayContextMenu(
00092               hWnd,
00093               nIDMenu,
00094               pts,
00095               m_pCMainWindow->GetWnd()
00096               );
00097     }
00098   }
00099
00100   return  TRUE;
00101 }
00102
00103
00104 /////////////////////////////////////////////////////////////////////////////
00105 // CObjTree::OnUpdateCommand
00106 //
00107 /////////////////////////////////////////////////////////////////////////////
00108 BOOL CObjTree::OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags)
00109 {
00110   //Is this command meant for the Child Window?
00111   CBase* pCBase = GetSelectedObject();
00112   if(pCBase && pCBase->m_pCMDIChild)
00113     if(pCBase->m_pCMDIChild->OnUpdateCommand(hMenu, nID, pdwFlags))
00114       return TRUE;
00115
00116   return FALSE;
00117 }
00118
00119
00120 /////////////////////////////////////////////////////////////////////
00121 // CObjTree::OnCommand
00122 //
00123 /////////////////////////////////////////////////////////////////////
00124 BOOL CObjTree::OnCommand(UINT iID, HWND hWndCtrl)
00125 {
00126   //Is this command meant for the Child Window?
00127   CBase* pCBase = GetSelectedObject();
00128   if(pCBase && pCBase->m_pCMDIChild)
00129     if(pCBase->m_pCMDIChild->OnCommand(iID, hWndCtrl))
00130       return TRUE;
00131
00132   return FALSE;
00133 }
00134
00135
00136 /////////////////////////////////////////////////////////////////////////////
00137 // CObjTree::OnDblclk
00138 //
00139 /////////////////////////////////////////////////////////////////////////////
00140 BOOL CObjTree::OnDblclk(WPARAM fwKeys, REFPOINTS pts)
00141 {
00142   UINT uFlags = 0;
00143   HTREEITEM hItem = HitTest(pts, &uFlags);
00144   if(hItem)
00145   {
00146     CBase* pCBase = (CBase*)GetItemParam(hItem);
00147     if(pCBase)
00148     {
00149       //If there is a child assoicated with this object, then let it perform what it should
00150       //do on a double click operation (which by default activates the  child window)
00151       pCBase->OnDefOperation();
00152       return TRUE;
00153     }
00154   }
00155
00156   return FALSE;
00157 }
00158
00159
00160 /////////////////////////////////////////////////////////////////////////////
00161 // CObjTree::OnKeyDown
00162 //
00163 /////////////////////////////////////////////////////////////////////////////
00164 BOOL CObjTree::OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData)
00165 {
00166   switch(nVirtKey)
00167   {
00168     case VK_RETURN:
00169     {
00170       CBase* pCBase = GetSelectedObject();
00171       if(pCBase)
00172       {
00173         //NOTE: Not all objects in the tree will have an assiocate child Window
00174         if(pCBase->m_pCMDIChild)
00175         {
00176           //Activate the MDIChild window assoicated with this object
00177           m_pCMainWindow->MDIActivate(pCBase->m_pCMDIChild->m_hWnd);
00178         }
00179         return TRUE;
00180       }
00181       break;
00182     }
00183   };
00184
00185   return FALSE;
00186 }
00187
00188
00189 /////////////////////////////////////////////////////////////////////////////
00190 // CObjTree::AddObject
00191 //
00192 /////////////////////////////////////////////////////////////////////////////
00193 BOOL CObjTree::AddObject(CBase* pCSource, CBase* pCBase)
00194 {
00195   if(pCBase)
00196   {
00197     WCHAR* pwszDesc = pCBase->GetObjectDesc();
00198     WCHAR* pwszName = pCBase->GetObjectName();
00199
00200     //Obtain the icon/image for the object
00201     INT iImage = pCBase->GetObjectImage();
00202     if(pCBase->m_pIAggregate)
00203       iImage = IMAGE_INTERFACE;
00204
00205     if(pwszDesc)
00206     {
00207       static WCHAR wszBuffer[MAX_NAME_LEN] = {0};
00208       if(pCBase->m_dwCLSCTX == CLSCTX_INPROC_SERVER)
00209         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%s (%s)", pwszName, pwszDesc);
00210       else
00211         StringFormat(wszBuffer, NUMELE(wszBuffer), L"%s%s (%s)", L"Remote ", pwszName, pwszDesc);
00212       pwszName = wszBuffer;
00213     }
00214
00215     //Insert the Item (if not already)
00216     if(pCBase->m_hTreeItem == NULL)
00217     {
00218       pCBase->m_hTreeItem = InsertItem(pCSource ? pCSource->m_hTreeItem : NULL, NULL, pwszName, (INT_PTR)pCBase, iImage, iImage);
00219     }
00220     else
00221     {
00222       //Otherwise it probably just needs to have the item updated...
00223       SetItemText(pCBase->m_hTreeItem, pwszName);
00224       SetItemParam(pCBase->m_hTreeItem, (INT_PTR)pCBase);
00225       SetItemImage(pCBase->m_hTreeItem, iImage, iImage);
00226     }
00227
00228     SelectObject(pCBase);
00229   }
00230   return TRUE;
00231 }
00232
00233
00234 /////////////////////////////////////////////////////////////////////////////
00235 // CObjTree::RemoveObject
00236 //
00237 /////////////////////////////////////////////////////////////////////////////
00238 BOOL CObjTree::RemoveObject(CBase* pCBase)
00239 {
00240   //No-op
00241   if(!m_hWnd || !pCBase || !pCBase->m_hTreeItem)
00242     return TRUE;
00243
00244   //Make a copy, since RemoveNode will null the objects members...
00245   HTREEITEM hParentItem = GetParentItem(pCBase->m_hTreeItem);
00246
00247   //First try and remove this node (and possibly any children)
00248   if(RemoveNode(pCBase->m_hTreeItem))
00249   {
00250     pCBase->m_hTreeItem = NULL;
00251
00252     //If we were able to remove this node, then maybe we should
00253     //try and "garbage-collect" any parent nodes now that this is gone...
00254     if(hParentItem)
00255       GarbageCollectNode(hParentItem);
00256     return TRUE;
00257   }
00258
00259   return FALSE;
00260 }
00261
00262
00263 /////////////////////////////////////////////////////////////////////////////
00264 // CObjTree::GarbageCollectNode
00265 //
00266 /////////////////////////////////////////////////////////////////////////////
00267 BOOL CObjTree::GarbageCollectNode(HTREEITEM hTreeItem)
00268 {
00269   //No-op
00270   if(!m_hWnd || !hTreeItem)
00271     return TRUE;
00272
00273   HTREEITEM hHighestItem = NULL;
00274
00275   //Try to find the "highest" un-used parent node.
00276   while(hTreeItem)
00277   {
00278     //As soon as one of the nodes has a (non-empty) object, its no longer "un-used"
00279     CBase* pCBase = (CBase*)GetItemParam(hTreeItem);
00280     if(pCBase && pCBase->m_pIUnknown)
00281       break;
00282
00283     hHighestItem = hTreeItem;
00284     hTreeItem = GetParentItem(hTreeItem);
00285   }
00286
00287   //Have we found "un-used" parents, that can be garbage-collected
00288   if(hHighestItem)
00289   {
00290     //Garbage Collect the usued nodes...
00291     return RemoveNode(hHighestItem);
00292   }
00293
00294   return FALSE;
00295 }
00296
00297
00298 /////////////////////////////////////////////////////////////////////////////
00299 // CObjTree::RemoveNode
00300 //
00301 /////////////////////////////////////////////////////////////////////////////
00302 BOOL CObjTree::RemoveNode(HTREEITEM hTreeItem)
00303 {
00304   //No-op
00305   if(!m_hWnd || !hTreeItem)
00306     return TRUE;
00307
00308   BOOL bSafeToRemove = TRUE;
00309   CBase* pCBase = (CBase*)GetItemParam(hTreeItem);
00310   CMDIChild* pCMDIChild = pCBase ? pCBase->m_pCMDIChild : NULL;
00311
00312   //First, make sure this node is safe to remove...
00313   if(pCBase && pCBase->m_pIUnknown)
00314     bSafeToRemove = FALSE;
00315
00316   //If it is before deleting it from the tree, we need to make there are no child nodes
00317   //that depend upon it
00318   if(bSafeToRemove)
00319   {
00320     HTREEITEM hChildItem = GetChildItem(hTreeItem);
00321     while(hChildItem)
00322     {
00323       //NOTE: Before deleting this node of the tree, obtain the next sibling (if there is one...)
00324       //Since we can't do this after the node has been deleted!
00325       HTREEITEM hNextSibling = GetNextItem(hChildItem);
00326
00327       //Recurse
00328       if(!RemoveNode(hChildItem))
00329       {
00330         bSafeToRemove = FALSE;
00331         break;
00332       }
00333
00334       //Go to the next sibling...
00335       hChildItem = hNextSibling;
00336     }
00337   }
00338
00339   if(bSafeToRemove)
00340   {
00341     //Completely safe to delete this node (and all children)
00342     DeleteItem(hTreeItem);
00343     if(pCBase)
00344       pCBase->m_hTreeItem = NULL;
00345   }
00346
00347   return bSafeToRemove;
00348 }
00349
00350
00351 /////////////////////////////////////////////////////////////////////////////
00352 // CObjTree::SelectObject
00353 //
00354 /////////////////////////////////////////////////////////////////////////////
00355 BOOL CObjTree::SelectObject(CBase* pCBase)
00356 {
00357   if(pCBase && pCBase->m_hTreeItem)
00358     SelectItem(pCBase->m_hTreeItem);
00359
00360   return TRUE;
00361 }
00362
00363
00364 /////////////////////////////////////////////////////////////////////////////
00365 // CObjTree::GetSelectedObject
00366 //
00367 /////////////////////////////////////////////////////////////////////////////
00368 CBase* CObjTree::GetSelectedObject()
00369 {
00370   //Obtain the selected item
00371   return (CBase*)GetItemParam(GetSelectedItem());
00372 }
00373
00374
00375 ////////////////////////////////////////////////////////////////
00376 // CMDIObjects::CMDIObjects
00377 //
00378 /////////////////////////////////////////////////////////////////
00379 CMDIObjects::CMDIObjects(CMainWindow* pCMainWindow)
00380 {
00381   //Objects
00382   ASSERT(pCMainWindow);
00383   m_pCMainWindow = pCMainWindow;
00384
00385   //Controls
00386   m_pCObjTree   = new CObjTree(pCMainWindow);
00387 }
00388
00389
00390 ////////////////////////////////////////////////////////////////
00391 // CMDIObjects::~CMDIObjects
00392 //
00393 /////////////////////////////////////////////////////////////////
00394 CMDIObjects::~CMDIObjects()
00395 {
00396   //Controls
00397   SAFE_DELETE(m_pCObjTree);
00398 }
00399
00400
00401
00402 ////////////////////////////////////////////////////////////////
00403 // CMDIObjects::PreCreateWindow
00404 //
00405 /////////////////////////////////////////////////////////////////
00406 BOOL CMDIObjects::PreCreateWindow(CREATESTRUCTW& cs)
00407 {
00408   //Load Saved Window Positions
00409   memset(&m_wndPlacement, 0, sizeof(m_wndPlacement));
00410   GetRegEntry(HKEY_ROWSETVIEWER, wszOBJECTS_KEY, L"WinPosition",  &m_wndPlacement, sizeof(m_wndPlacement), NULL);
00411
00412   //Window Hidden?
00413   if(m_wndPlacement.length)
00414   {
00415     if(m_wndPlacement.showCmd == SW_HIDE)
00416       cs.style &= ~WS_VISIBLE;
00417   }
00418
00419   return TRUE;
00420 }
00421
00422
00423 ////////////////////////////////////////////////////////////////
00424 // CMDIObjects::AutoPosition
00425 //
00426 /////////////////////////////////////////////////////////////////
00427 BOOL CMDIObjects::AutoPosition(BOOL fDefaultPosition)
00428 {
00429   if(fDefaultPosition || m_wndPlacement.length == 0)
00430   {
00431     //Default setting, left corner (1/4 of the client area)...
00432     SIZE sizeClient = GetClientSize(m_pCMainWindow->m_hWndMDIClient);
00433     return MoveWindow(m_hWnd, 0, 0, (INT)((float)sizeClient.cx * 0.25), sizeClient.cy, TRUE);
00434   }
00435   else
00436   {
00437     return SetWindowPlacement();
00438   }
00439 }
00440
00441
00442 ////////////////////////////////////////////////////////////////
00443 // CMDIObjects::OnCreate
00444 //
00445 /////////////////////////////////////////////////////////////////
00446 BOOL CMDIObjects::OnCreate(LPCREATESTRUCT lpCreateStruct)
00447 {
00448   //Create Object Tree
00449   SIZE size = GetClientSize(m_hWnd);
00450   m_pCObjTree->Create(m_hWnd, WC_TREEVIEWW, NULL, ID_OBJECTTREE,
00451     WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | WS_TABSTOP | /*TVS_EDITLABELS |*/ TVS_LINESATROOT | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS, WS_EX_CLIENTEDGE,
00452     0, 0, size.cx, size.cy);
00453   TreeView_SetImageList(m_pCObjTree->m_hWnd, ImageList_LoadImage(GetAppLite()->m_hInstance, MAKEINTRESOURCE(IDB_IMAGE), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR), TVSIL_NORMAL);
00454   m_pCObjTree->OnCreate(NULL);
00455
00456   //Window Position
00457   AutoPosition(m_wndPlacement.length == 0/*fDefaultPosition*/);
00458   return TRUE;
00459 }
00460
00461
00462 /////////////////////////////////////////////////////////////////////////////
00463 // CMDIObjects::OnDestroy
00464 //
00465 /////////////////////////////////////////////////////////////////////////////
00466 BOOL CMDIObjects::OnDestroy()
00467 {
00468   //Save Window Positions
00469   if(GetWindowPlacement())
00470     SetRegEntry(HKEY_ROWSETVIEWER, wszOBJECTS_KEY, L"WinPosition",  &m_wndPlacement,  sizeof(m_wndPlacement));
00471
00472   //Delegate
00473   return CMDIChildLite::OnDestroy();
00474 }
00475
00476
00477 /////////////////////////////////////////////////////////////////////////////
00478 // CMDIObjects::OnClose
00479 //
00480 /////////////////////////////////////////////////////////////////////////////
00481 BOOL CMDIObjects::OnClose()
00482 {
00483   //NOTE:  OnClose only gets hit for MDI Child Windows when the user actually
00484   //closes the window.  If the mainframe window is closed directly then OnClose is never fired...
00485
00486   //Due to this, if the user has closed the window before exiting the app, then all we really
00487   //want to do is make the window not-visible, so if they bring the window up again it has all
00488   //the info saved.
00489
00490   ShowWindow(SW_HIDE);
00491
00492   //NOTE:  Don't delegate the call, since we don't want to "DestroyWindow"
00493   return TRUE;
00494 }
00495
00496
00497 ////////////////////////////////////////////////////////////////
00498 // CMDIObjects::OnInitialUpdate
00499 //
00500 /////////////////////////////////////////////////////////////////
00501 BOOL CMDIObjects::OnInitialUpdate()
00502 {
00503   return TRUE;
00504 }
00505
00506
00507 /////////////////////////////////////////////////////////////////////
00508 // CMDIObjects::OnMDIActivate
00509 //
00510 /////////////////////////////////////////////////////////////////////
00511 BOOL CMDIObjects::OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate)
00512 {
00513   //So see if this window is being activated or deactivated
00514   if(hWndActivate == m_hWnd)
00515   {
00516     //Refresh all Controls
00517     UpdateControls();
00518   }
00519   return TRUE;
00520 }
00521
00522
00523 ////////////////////////////////////////////////////////////////
00524 // CMDIObjects::UpdateControls
00525 //
00526 /////////////////////////////////////////////////////////////////
00527 BOOL CMDIObjects::UpdateControls()
00528 {
00529   //ToolBar Buttons
00530   m_pCMainWindow->UpdateControls();
00531   return TRUE;
00532 }
00533
00534
00535 /////////////////////////////////////////////////////////////////////////////
00536 // CMDIObjects::OnUpdateCommand
00537 //
00538 /////////////////////////////////////////////////////////////////////////////
00539 BOOL CMDIObjects::OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags)
00540 {
00541   return m_pCObjTree->OnUpdateCommand(hMenu, nID, pdwFlags);
00542 }
00543
00544
00545 /////////////////////////////////////////////////////////////////////
00546 // CMDIObjects::OnNotify
00547 //
00548 /////////////////////////////////////////////////////////////////////
00549 BOOL CMDIObjects::OnNotify(INT idCtrl, NMHDR* pNMHDR)
00550 {
00551   return m_pCObjTree->OnNotify(idCtrl, pNMHDR);
00552 }
00553
00554
00555
00556 /////////////////////////////////////////////////////////////////////
00557 // CMDIObjects::OnCommand
00558 //
00559 /////////////////////////////////////////////////////////////////////
00560 BOOL CMDIObjects::OnCommand(UINT iID, HWND hWndCtrl)
00561 {
00562   return m_pCObjTree->OnCommand(iID, hWndCtrl);
00563 }
00564
00565
00566 /////////////////////////////////////////////////////////////////////
00567 // CMDIObjects::OnSize
00568 //
00569 /////////////////////////////////////////////////////////////////////
00570 BOOL CMDIObjects::OnSize(WPARAM nType, REFPOINTS pts)
00571 {
00572   ASSERT(m_pCObjTree->m_hWnd);
00573
00574   switch(nType)
00575   {
00576     case SIZE_RESTORED:
00577     case SIZE_MAXIMIZED:
00578     {
00579       if(pts.x && pts.y)
00580       {
00581         //Obtain window sizes...
00582         MoveWindow(m_pCObjTree->m_hWnd, 0, 0, pts.x, pts.y, TRUE);
00583
00584         //Call default procedure first,
00585         //to let MDI position the child & then move its children
00586         //We simply do this by returning false, to indicate we didn't handle it...
00587         return FALSE;
00588       }
00589       break;
00590     }
00591   };
00592
00593   return FALSE;
00594 }
00595
00596
00597 /////////////////////////////////////////////////////////////////////////////
00598 // CMDIObjects::OnSetFocus
00599 //
00600 /////////////////////////////////////////////////////////////////////////////
00601 BOOL CMDIObjects::OnSetFocus(HWND hWndPrevFocus)
00602 {
00603   m_pCObjTree->SetFocus();
00604   return TRUE;
00605 }
00606
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CommandVtbl Member List

This is the complete list of members for _CommandVtbl, including all inherited members.
bstr | _CommandVtbl
bstrName | _CommandVtbl
cNames | _CommandVtbl
Direction | _CommandVtbl
dispIdMember | _CommandVtbl
fPrepared | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Properties)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_ActiveConnection)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *putref_ActiveADOConnection)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_ActiveConnection)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CommandText)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CommandText)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CommandTimeout)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CommandTimeout)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Prepared)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Prepared)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Execute)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *CreateParameter)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Cancel)(_ADOCommand __RPC_FAR *This) | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Parameters)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_CommandType)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_CommandType)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_State)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Name)(_ADOCommand __RPC_FAR *This | _CommandVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Name)(_ADOCommand __RPC_FAR *This | _CommandVtbl
iTInfo | _CommandVtbl
lcid | _CommandVtbl
lcid | _CommandVtbl
lcid | _CommandVtbl
lCmdType | _CommandVtbl
Name | _CommandVtbl
Options | _CommandVtbl
Parameters | _CommandVtbl
pbstr | _CommandVtbl
pbstrName | _CommandVtbl
pCon | _CommandVtbl
pctinfo | _CommandVtbl
pDispParams | _CommandVtbl
pExcepInfo | _CommandVtbl
pfPrepared | _CommandVtbl
pl | _CommandVtbl
plCmdType | _CommandVtbl
plObjState | _CommandVtbl
ppiprm | _CommandVtbl
ppirs | _CommandVtbl
ppTInfo | _CommandVtbl
ppvObject | _CommandVtbl
ppvObject | _CommandVtbl
ppvObject | _CommandVtbl
ppvObject | _CommandVtbl
puArgErr | _CommandVtbl
pVarResult | _CommandVtbl
RecordsAffected | _CommandVtbl
rgDispId | _CommandVtbl
rgszNames | _CommandVtbl
riid | _CommandVtbl
riid | _CommandVtbl
riid | _CommandVtbl
Size | _CommandVtbl
Timeout | _CommandVtbl
Type | _CommandVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(_ADOCommand __RPC_FAR *This) | _CommandVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(_ADOCommand __RPC_FAR *This) | _CommandVtbl
Value | _CommandVtbl
vConn | _CommandVtbl
wFlags | _CommandVtbl
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ISAPITHREAD Member List

This is the complete list of members for ISAPITHREAD, including all inherited members.
ClearQueue(void) | ISAPITHREAD |
GetWorkItem(void) | ISAPITHREAD |
InitThreadPool(LPTHREAD_START_ROUTINE pThreadProc, DWORD dwNumThreads=5, DWORD dwQueueSize=0xffffffff) | ISAPITHREAD |
ISAPITHREAD(void) | ISAPITHREAD |
m_arrWorkerThreads | ISAPITHREAD | [private]
m_csQueue | ISAPITHREAD | [private]
m_dwCurrentItem | ISAPITHREAD | [private]
m_dwItemsInQueue | ISAPITHREAD | [private]
m_dwNumThreads | ISAPITHREAD | [private]
m_dwWorkItemQueueSize | ISAPITHREAD | [private]
m_hWorkerThreadSemaphore | ISAPITHREAD |
m_WorkItemQueue | ISAPITHREAD | [private]
QueueWorkItem(EXTENSION_CONTROL_BLOCK *pecb, BOOL fReleaseThread=TRUE) | ISAPITHREAD |
ReleaseThread(DWORD dwNumThreads=1) | ISAPITHREAD |
~ISAPITHREAD(void) | ISAPITHREAD |
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

vcacct::IUpdateReceipt Member List

This is the complete list of members for vcacct::IUpdateReceipt, including all inherited members.
iid | vcacct::IUpdateReceipt | [static]
Update() | vcacct::IUpdateReceipt |
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/DataObj.h Source File

  • WinUI
  • Shell
  • SampView

DataObj.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /******************************************************************************
00011
00012    File:          DataObj.h
00013
00014    Description:   CDataObject definitions.
00015
00016 ******************************************************************************/
00017
00018 #ifndef DATAOBJ_H
00019 #define DATAOBJ_H
00020
00021 #include <windows.h>
00022 #include <windowsx.h>
00023 #include <shlobj.h>
00024 #include "ShlFldr.h"
00025 #include "PidlMgr.h"
00026 #include "resource.h"
00027
00028 #define SETDefFormatEtc(fe, cf, med) \
00029   {\
00030   (fe).cfFormat=(CLIPFORMAT)cf; \
00031   (fe).dwAspect=DVASPECT_CONTENT; \
00032   (fe).ptd=NULL;\
00033   (fe).tymed=med;\
00034   (fe).lindex=-1;\
00035   };
00036
00037 /**************************************************************************
00038
00039    CDataObject class definition
00040
00041 **************************************************************************/
00042
00043 class CDataObject : public IDataObject, IEnumFORMATETC
00044 {
00045 private:
00046    DWORD          m_ObjRefCount;
00047    LPITEMIDLIST   *m_aPidls;
00048    IMalloc        *m_pMalloc;
00049    CPidlMgr       *m_pPidlMgr;
00050    CShellFolder   *m_psfParent;
00051    UINT           m_uItemCount;
00052   ULONG         m_iCurrent;
00053   ULONG         m_cFormatEtc;
00054   LPFORMATETC    m_pFormatEtc;
00055    UINT           m_cfPrivateData;
00056    UINT           m_cfShellIDList;
00057
00058 public:
00059    CDataObject(CShellFolder*, LPCITEMIDLIST*, UINT);
00060    ~CDataObject();
00061
00062    //IUnknown methods
00063    STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
00064    STDMETHODIMP_(DWORD) AddRef();
00065    STDMETHODIMP_(DWORD) Release();
00066
00067    //IDataObject methods
00068   STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
00069   STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
00070   STDMETHODIMP QueryGetData(LPFORMATETC);
00071   STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
00072   STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
00073   STDMETHODIMP EnumFormatEtc(DWORD, IEnumFORMATETC**);
00074   STDMETHODIMP DAdvise(LPFORMATETC, DWORD, IAdviseSink*, LPDWORD);
00075   STDMETHODIMP DUnadvise(DWORD dwConnection);
00076   STDMETHODIMP EnumDAdvise(IEnumSTATDATA** ppEnumAdvise);
00077
00078   // IEnumFORMATETC members
00079   STDMETHODIMP Next(ULONG, LPFORMATETC, ULONG*);
00080   STDMETHODIMP Skip(ULONG);
00081   STDMETHODIMP Reset(void);
00082   STDMETHODIMP Clone(LPENUMFORMATETC*);
00083
00084 private:
00085    BOOL AllocPidlTable(DWORD);
00086    VOID FreePidlTable(VOID);
00087    BOOL FillPidlTable(LPCITEMIDLIST*, UINT);
00088 };
00089
00090 #endif// DATAOBJ_H
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDBSession Member List

This is the complete list of members for CDBSession, including all inherited members.
CBaseObj(EBaseObjectType botVal) | CBaseObj | [protected]
CDBSession(LPUNKNOWN) | CDBSession |
CImpIBindResource class | CDBSession | [friend]
CImpICreateCommand class | CDBSession | [friend]
CImpIDataSource class | CDBSession | [friend]
CImpIGetDataSource class | CDBSession | [friend]
CImpIOpenRowset class | CDBSession | [friend]
CImpISessionProperties class | CDBSession | [friend]
FInit(CDataSource *pCDataSource) | CDBSession |
GetBaseObjectType() | CBaseObj | [inline]
GetOuterUnknown() | CBaseObj | [inline]
m_cRef | CDBSession | [protected]
m_pCDataSource | CDBSession |
m_pIBindResource | CDBSession | [protected]
m_pIDBCreateCommand | CDBSession | [protected]
m_pIGetDataSource | CDBSession | [protected]
m_pIOpenRowset | CDBSession | [protected]
m_pISessionProperties | CDBSession | [protected]
m_pUnkOuter | CBaseObj | [protected]
m_pUtilProp | CDBSession | [protected]
QueryInterface(REFIID, LPVOID *) | CDBSession |
STDMETHODIMP_(DBREFCOUNT) AddRef(void) | CDBSession |
STDMETHODIMP_(DBREFCOUNT) Release(void) | CDBSession |
~CBaseObj() | CBaseObj | [virtual]
~CDBSession(void) | CDBSession |
Generated on Wed Nov 13 2024 16:56:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/OleStd.c Source File

  • Com
  • Fundamentals
  • OleStd

OleStd.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2 Standard Utilities
00004 **
00005 **    olestd.c
00006 **
00007 **    This file contains utilities that are useful for most standard
00008 **        OLE 2.0 compound document type applications.
00009 **
00010 **    (c) Copyright Microsoft Corp. 1992-2000 All Rights Reserved
00011 **
00012 *************************************************************************/
00013
00014 #define NONAMELESSUNION     // use strict ANSI standard (for DVOBJ.H)
00015
00016 #define STRICT  1
00017 #include "olestd.h"
00018 #include <stdlib.h>
00019 #include <ctype.h>
00020 #include <shellapi.h>
00021 #include "common.h"
00022
00023 OLEDBGDATA
00024
00025 static char szAssertMemAlloc[] = "CoGetMalloc failed";
00026 static int IsCloseFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight);
00027
00028
00029 /* OleStdSetupAdvises
00030 ** ------------------
00031 **    Setup the standard View advise required by a standard,
00032 **    compound document-oriented container. Such a container relies on
00033 **    Ole to manage the presentation of the Ole object. The container
00034 **    call IViewObject::Draw to render (display) the object.
00035 **
00036 **    This helper routine performs the following tasks:
00037 **                      setup View advise
00038 **                      Call IOleObject::SetHostNames
00039 **                      Call OleSetContainedObject
00040 **
00041 **    fCreate should be set to TRUE if the object is being created. if
00042 **    an existing object is being loaded, then fCreate should be FALSE.
00043 **    if it is a creation situation, then the ADVF_PRIMEFIRST flag is
00044 **    used when settinp up the IViewObject::Advise. This will result in
00045 **    the immediate sending of the initial picture.
00046 **
00047 **    NOTE: the standard container does NOT need to set up an OLE
00048 **    Advise (IOleObject::Advise). this routine does NOT set up an OLE
00049 **    Advise (a previous version of this function used to setup this
00050 **    advise, but it was not useful).
00051 */
00052 STDAPI_(BOOL) OleStdSetupAdvises(LPOLEOBJECT lpOleObject, DWORD dwDrawAspect,
00053                LPOLESTR lpszContainerApp, LPOLESTR lpszContainerObj,
00054                LPADVISESINK lpAdviseSink, BOOL fCreate)
00055 {
00056    LPVIEWOBJECT lpViewObject;
00057    HRESULT hrErr;
00058    BOOL fStatus = TRUE;
00059 #if defined( SPECIAL_CONTAINER )
00060    DWORD dwTemp;
00061 #endif
00062
00063    hrErr = lpOleObject->lpVtbl->QueryInterface(
00064          lpOleObject,
00065          &IID_IViewObject,
00066          (LPVOID FAR*)&lpViewObject
00067    );
00068
00069    /* Setup View advise */
00070    if (hrErr == NOERROR) {
00071
00072       OLEDBG_BEGIN2("IViewObject::SetAdvise called\r\n")
00073       lpViewObject->lpVtbl->SetAdvise(
00074             lpViewObject,
00075             dwDrawAspect,
00076             (fCreate ? ADVF_PRIMEFIRST : 0),
00077             lpAdviseSink
00078       );
00079       OLEDBG_END2
00080
00081       OleStdRelease((LPUNKNOWN)lpViewObject);
00082    } else {
00083       fStatus = FALSE;
00084    }
00085
00086 #if defined( SPECIAL_CONTAINER )
00087    /* Setup OLE advise.
00088    **    NOTE: normally containers do NOT need to setup an OLE
00089    **    advise. this advise connection is only useful for the OLE's
00090    **    DefHandler and the OleLink object implementation. some
00091    **    special container's might need to setup this advise for
00092    **    programatic reasons.
00093    **
00094    **    NOTE: this advise will be torn down automatically by the
00095    **    server when we release the object, therefore we do not need
00096    **    to store the connection id.
00097    */
00098    OLEDBG_BEGIN2("IOleObject::Advise called\r\n")
00099    hrErr = lpOleObject->lpVtbl->Advise(
00100          lpOleObject,
00101          lpAdviseSink,
00102          (DWORD FAR*)&dwTemp
00103    );
00104    OLEDBG_END2
00105    if (hrErr != NOERROR) fStatus = FALSE;
00106 #endif
00107
00108    /* Setup the host names for the OLE object. */
00109    OLEDBG_BEGIN2("IOleObject::SetHostNames called\r\n")
00110    hrErr = lpOleObject->lpVtbl->SetHostNames(
00111          lpOleObject,
00112          lpszContainerApp,
00113          lpszContainerObj
00114    );
00115    OLEDBG_END2
00116    if (hrErr != NOERROR) fStatus = FALSE;
00117
00118    /* Inform the loadded object's handler/inproc-server that it is in
00119    **    its embedding container's process.
00120    */
00121    OLEDBG_BEGIN2("OleSetContainedObject(TRUE) called\r\n")
00122    OleSetContainedObject((LPUNKNOWN)lpOleObject, TRUE);
00123    OLEDBG_END2
00124
00125    return fStatus;
00126 }
00127
00128
00129 /* OleStdSwitchDisplayAspect
00130 ** -------------------------
00131 **    Switch the currently cached display aspect between DVASPECT_ICON
00132 **    and DVASPECT_CONTENT.
00133 **
00134 **    NOTE: when setting up icon aspect, any currently cached content
00135 **    cache is discarded and any advise connections for content aspect
00136 **    are broken.
00137 **
00138 **    RETURNS:
00139 **      S_OK -- new display aspect setup successfully
00140 **      E_INVALIDARG -- IOleCache interface is NOT supported (this is
00141 **                  required).
00142 **      <other SCODE> -- any SCODE that can be returned by
00143 **                  IOleCache::Cache method.
00144 **      NOTE: if an error occurs then the current display aspect and
00145 **            cache contents unchanged.
00146 */
00147 STDAPI OleStdSwitchDisplayAspect(
00148       LPOLEOBJECT             lpOleObj,
00149       LPDWORD                 lpdwCurAspect,
00150       DWORD                   dwNewAspect,
00151       HGLOBAL                 hMetaPict,
00152       BOOL                    fDeleteOldAspect,
00153       BOOL                    fSetupViewAdvise,
00154       LPADVISESINK            lpAdviseSink,
00155       BOOL FAR*               lpfMustUpdate
00156 )
00157 {
00158    LPOLECACHE      lpOleCache = NULL;
00159    LPVIEWOBJECT    lpViewObj = NULL;
00160    LPENUMSTATDATA  lpEnumStatData = NULL;
00161    STATDATA        StatData;
00162    FORMATETC       FmtEtc;
00163    STGMEDIUM       Medium;
00164    DWORD           dwAdvf;
00165    DWORD           dwNewConnection;
00166    DWORD           dwOldAspect = *lpdwCurAspect;
00167    HRESULT         hrErr;
00168
00169    if (lpfMustUpdate)
00170       *lpfMustUpdate = FALSE;
00171
00172    lpOleCache = (LPOLECACHE)OleStdQueryInterface(
00173                               (LPUNKNOWN)lpOleObj,&IID_IOleCache);
00174
00175    // if IOleCache* is NOT available, do nothing
00176    if (! lpOleCache)
00177       return E_INVALIDARG;
00178
00179    // Setup new cache with the new aspect
00180    FmtEtc.cfFormat = 0;     // whatever is needed to draw
00181    FmtEtc.ptd      = NULL;
00182    FmtEtc.dwAspect = dwNewAspect;
00183    FmtEtc.lindex   = -1;
00184    FmtEtc.tymed    = TYMED_NULL;
00185
00186    /* NOTE: if we are setting up Icon aspect with a custom icon
00187    **    then we do not want DataAdvise notifications to ever change
00188    **    the contents of the data cache. thus we set up a NODATA
00189    **    advise connection. otherwise we set up a standard DataAdvise
00190    **    connection.
00191    */
00192    if (dwNewAspect == DVASPECT_ICON && hMetaPict)
00193       dwAdvf = ADVF_NODATA;
00194    else
00195       dwAdvf = ADVF_PRIMEFIRST;
00196
00197    OLEDBG_BEGIN2("IOleCache::Cache called\r\n")
00198    hrErr = lpOleCache->lpVtbl->Cache(
00199          lpOleCache,
00200          (LPFORMATETC)&FmtEtc,
00201          dwAdvf,
00202          (LPDWORD)&dwNewConnection
00203    );
00204    OLEDBG_END2
00205
00206    if (! SUCCEEDED(hrErr)) {
00207       OleDbgOutHResult("IOleCache::Cache returned", hrErr);
00208       OleStdRelease((LPUNKNOWN)lpOleCache);
00209       return hrErr;
00210    }
00211
00212    *lpdwCurAspect = dwNewAspect;
00213
00214    /* NOTE: if we are setting up Icon aspect with a custom icon,
00215    **    then stuff the icon into the cache. otherwise the cache must
00216    **    be forced to be updated. set the *lpfMustUpdate flag to tell
00217    **    caller to force the object to Run so that the cache will be
00218    **    updated.
00219    */
00220    if (dwNewAspect == DVASPECT_ICON && hMetaPict) {
00221
00222       FmtEtc.cfFormat = CF_METAFILEPICT;
00223       FmtEtc.ptd      = NULL;
00224       FmtEtc.dwAspect = DVASPECT_ICON;
00225       FmtEtc.lindex   = -1;
00226       FmtEtc.tymed    = TYMED_MFPICT;
00227
00228       Medium.tymed            = TYMED_MFPICT;
00229       Medium.u.hGlobal        = hMetaPict;
00230       Medium.pUnkForRelease   = NULL;
00231
00232       OLEDBG_BEGIN2("IOleCache::SetData called\r\n")
00233       hrErr = lpOleCache->lpVtbl->SetData(
00234             lpOleCache,
00235             (LPFORMATETC)&FmtEtc,
00236             (LPSTGMEDIUM)&Medium,
00237             FALSE   /* fRelease */
00238       );
00239       OLEDBG_END2
00240    } else {
00241       if (lpfMustUpdate)
00242          *lpfMustUpdate = TRUE;
00243    }
00244
00245    if (fSetupViewAdvise && lpAdviseSink) {
00246       /* NOTE: re-establish the ViewAdvise connection */
00247       lpViewObj = (LPVIEWOBJECT)OleStdQueryInterface(
00248                               (LPUNKNOWN)lpOleObj,&IID_IViewObject);
00249
00250       if (lpViewObj) {
00251
00252          OLEDBG_BEGIN2("IViewObject::SetAdvise called\r\n")
00253          lpViewObj->lpVtbl->SetAdvise(
00254                lpViewObj,
00255                dwNewAspect,
00256                0,
00257                lpAdviseSink
00258          );
00259          OLEDBG_END2
00260
00261          OleStdRelease((LPUNKNOWN)lpViewObj);
00262       }
00263    }
00264
00265    /* NOTE: remove any existing caches that are set up for the old
00266    **    display aspect. It WOULD be possible to retain the caches set
00267    **    up for the old aspect, but this would increase the storage
00268    **    space required for the object and possibly require additional
00269    **    overhead to maintain the unused cachaes. For these reasons the
00270    **    strategy to delete the previous caches is prefered. if it is a
00271    **    requirement to quickly switch between Icon and Content
00272    **    display, then it would be better to keep both aspect caches.
00273    */
00274
00275    if (fDeleteOldAspect) {
00276       OLEDBG_BEGIN2("IOleCache::EnumCache called\r\n")
00277       hrErr = lpOleCache->lpVtbl->EnumCache(
00278             lpOleCache,
00279             (LPENUMSTATDATA FAR*)&lpEnumStatData
00280       );
00281       OLEDBG_END2
00282
00283       while(hrErr == NOERROR) {
00284          hrErr = lpEnumStatData->lpVtbl->Next(
00285                lpEnumStatData,
00286                1,
00287                (LPSTATDATA)&StatData,
00288                NULL
00289          );
00290          if (hrErr != NOERROR)
00291             break;              // DONE! no more caches.
00292
00293          if (StatData.formatetc.dwAspect == dwOldAspect) {
00294
00295             // Remove previous cache with old aspect
00296             OLEDBG_BEGIN2("IOleCache::Uncache called\r\n")
00297             lpOleCache->lpVtbl->Uncache(lpOleCache,StatData.dwConnection);
00298             OLEDBG_END2
00299          }
00300       }
00301
00302       if (lpEnumStatData) {
00303          OleStdVerifyRelease(
00304                (LPUNKNOWN)lpEnumStatData,
00305                OLESTR ("OleStdSwitchDisplayAspect: Cache enumerator NOT released"));
00306       }
00307    }
00308
00309    if (lpOleCache)
00310       OleStdRelease((LPUNKNOWN)lpOleCache);
00311
00312    return NOERROR;
00313 }
00314
00315
00316 /* OleStdSetIconInCache
00317 ** --------------------
00318 **    SetData a new icon into the existing DVASPECT_ICON cache.
00319 **
00320 **    RETURNS:
00321 **      HRESULT returned from IOleCache::SetData
00322 */
00323 STDAPI OleStdSetIconInCache(LPOLEOBJECT lpOleObj, HGLOBAL hMetaPict)
00324 {
00325    LPOLECACHE      lpOleCache = NULL;
00326    FORMATETC       FmtEtc;
00327    STGMEDIUM       Medium;
00328    HRESULT         hrErr;
00329
00330    if (! hMetaPict)
00331       return FALSE;   // invalid icon
00332
00333    lpOleCache = (LPOLECACHE)OleStdQueryInterface(
00334                               (LPUNKNOWN)lpOleObj,&IID_IOleCache);
00335    if (! lpOleCache)
00336       return FALSE;   // if IOleCache* is NOT available, do nothing
00337
00338    FmtEtc.cfFormat = CF_METAFILEPICT;
00339    FmtEtc.ptd      = NULL;
00340    FmtEtc.dwAspect = DVASPECT_ICON;
00341    FmtEtc.lindex   = -1;
00342    FmtEtc.tymed    = TYMED_MFPICT;
00343
00344    // stuff the icon into the cache.
00345    Medium.tymed            = TYMED_MFPICT;
00346    Medium.u.hGlobal        = hMetaPict;
00347    Medium.pUnkForRelease   = NULL;
00348
00349    OLEDBG_BEGIN2("IOleCache::SetData called\r\n")
00350    hrErr = lpOleCache->lpVtbl->SetData(
00351          lpOleCache,
00352          (LPFORMATETC)&FmtEtc,
00353          (LPSTGMEDIUM)&Medium,
00354          FALSE   /* fRelease */
00355    );
00356    OLEDBG_END2
00357
00358    OleStdRelease((LPUNKNOWN)lpOleCache);
00359
00360    return hrErr;
00361 }
00362
00363
00364
00365 /* OleStdDoConvert
00366 ** ---------------
00367 ** Do the container-side responsibilities for converting an object.
00368 **    This function would be used in conjunction with the OleUIConvert
00369 **    dialog. If the user selects to convert an object then the
00370 **    container must do the following:
00371 **          1. unload the object.
00372 **          2. write the NEW CLSID and NEW user type name
00373 **              string into the storage of the object,
00374 **              BUT write the OLD format tag.
00375 **          3. force an update of the object to force the actual
00376 **              conversion of the data bits.
00377 **
00378 **    This function takes care of step 2.
00379 */
00380 STDAPI OleStdDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew)
00381 {
00382    HRESULT error;
00383    CLSID clsidOld;
00384    CLIPFORMAT cfOld;
00385    LPOLESTR lpszOld = NULL;
00386    OLECHAR szNew[OLEUI_CCHKEYMAX];
00387
00388    if ((error = ReadClassStg(lpStg, &clsidOld)) != NOERROR) {
00389       clsidOld = CLSID_NULL;
00390       goto errRtn;
00391    }
00392
00393    // read old fmt/old user type; sets out params to NULL on error
00394    error = ReadFmtUserTypeStg(lpStg, &cfOld, &lpszOld);
00395    OleDbgAssert(error == NOERROR || (cfOld == 0 && lpszOld == NULL));
00396
00397    // get new user type name; if error, set to NULL string
00398    if (OleStdGetUserTypeOfClass(
00399          (LPCLSID)rClsidNew, szNew, OLEUI_CCHKEYMAX,NULL /* hKey */) == 0)
00400       OLESTRCPY (szNew, OLESTR (""));
00401
00402    // write class stg
00403    if ((error = WriteClassStg(lpStg, rClsidNew)) != NOERROR)
00404       goto errRtn;
00405
00406    // write old fmt/new user type;
00407    if ((error = WriteFmtUserTypeStg(lpStg, cfOld, szNew)) != NOERROR)
00408       goto errRewriteInfo;
00409
00410    // set convert bit
00411    if ((error = SetConvertStg(lpStg, TRUE)) != NOERROR)
00412       goto errRewriteInfo;
00413
00414    goto okRtn;
00415
00416 errRewriteInfo:
00417    (void)WriteClassStg(lpStg, &clsidOld);
00418    (void)WriteFmtUserTypeStg(lpStg, cfOld, lpszOld);
00419
00420 errRtn:
00421
00422 okRtn:
00423    OleStdFreeString(lpszOld, NULL);
00424    return error;
00425 }
00426
00427
00428 /* OleStdGetTreatAsFmtUserType
00429 ** ---------------------------
00430 **    Determine if the application should perform a TreatAs (ActivateAs
00431 **    object or emulation) operation for the object that is stored in
00432 **    the storage.
00433 **
00434 **    if the CLSID written in the storage is not the same as the
00435 **    application's own CLSID (clsidApp), then a TreatAs operation
00436 **    should take place. if so determine the format the data should be
00437 **    written and the user type name of the object the app should
00438 **    emulate (ie. pretend to be). if this information is not written
00439 **    in the storage then it is looked up in the REGDB. if it can not
00440 **    be found in the REGDB, then the TreatAs operation can NOT be
00441 **    executed.
00442 **
00443 **    RETURNS: TRUE -- if TreatAs should be performed.
00444 **               valid lpclsid, lplpszType, lpcfFmt to TreatAs are returned
00445 **                      (NOTE: lplpszType must be freed by caller)
00446 **             FALSE -- NO TreatAs. lpszType will be NULL.
00447 **               lpclsid = CLSID_NULL; lplpszType = lpcfFmt = NULL;
00448 */
00449 STDAPI_(BOOL) OleStdGetTreatAsFmtUserType(
00450       REFCLSID        rclsidApp,
00451       LPSTORAGE       lpStg,
00452       CLSID FAR*      lpclsid,
00453       CLIPFORMAT FAR* lpcfFmt,
00454       LPOLESTR FAR*   lplpszType
00455 )
00456 {
00457    HRESULT hrErr;
00458    HKEY    hKey;
00459    LONG    lRet;
00460    UINT    lSize;
00461    OLECHAR szBuf[OLEUI_CCHKEYMAX];
00462
00463    *lpclsid    = CLSID_NULL;
00464    *lpcfFmt    = 0;
00465    *lplpszType = NULL;
00466
00467    hrErr = ReadClassStg(lpStg, lpclsid);
00468    if (hrErr == NOERROR &&
00469       ! IsEqualCLSID(lpclsid, &CLSID_NULL) &&
00470       ! IsEqualCLSID(lpclsid, rclsidApp)) {
00471
00472       hrErr = ReadFmtUserTypeStg(lpStg,(CLIPFORMAT FAR*)lpcfFmt,lplpszType);
00473       if (hrErr == NOERROR && lplpszType && *lpcfFmt != 0)
00474          return TRUE;    // Do TreatAs. info was in lpStg.
00475
00476       /* read info from REGDB
00477       **    *lpcfFmt = value of field: CLSID\{...}\DataFormats\DefaultFile
00478       **    *lplpszType = value of field: CLSID\{...}
00479       */
00480       //Open up the root key.
00481       lRet=RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
00482       if (lRet != (LONG)ERROR_SUCCESS)
00483          return FALSE;
00484       *lpcfFmt = OleStdGetDefaultFileFormatOfClass(lpclsid, hKey);
00485       if (*lpcfFmt == 0)
00486          return FALSE;
00487       lSize = OleStdGetUserTypeOfClass(lpclsid,szBuf,OLEUI_CCHKEYMAX, hKey);
00488       if (lSize == 0)
00489          return FALSE;
00490       *lplpszType = OleStdCopyString(szBuf, NULL);
00491    } else {
00492       return FALSE;       // NO TreatAs
00493    }
00494 }
00495
00496
00497
00498 /* OleStdDoTreatAsClass
00499 ** --------------------
00500 ** Do the container-side responsibilities for "ActivateAs" (aka.
00501 **    TreatAs) for an object.
00502 **    This function would be used in conjunction with the OleUIConvert
00503 **    dialog. If the user selects to ActivateAs an object then the
00504 **    container must do the following:
00505 **          1. unload ALL objects of the OLD class that app knows about
00506 **          2. add the TreatAs tag in the registration database
00507 **              by calling CoTreatAsClass().
00508 **          3. lazily it can reload the objects; when the objects
00509 **              are reloaded the TreatAs will take effect.
00510 **
00511 **    This function takes care of step 2.
00512 */
00513 STDAPI OleStdDoTreatAsClass(LPOLESTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew)
00514 {
00515    HRESULT hrErr;
00516    LPOLESTR   lpszCLSID = NULL;
00517    char       lpszAnsiCLSID[256];
00518    LONG    lRet;
00519    HKEY    hKey;
00520    char    lpszAnsiUserType[256];
00521
00522    OLEDBG_BEGIN2("CoTreatAsClass called\r\n")
00523    hrErr = CoTreatAsClass(rclsid, rclsidNew);
00524    OLEDBG_END2
00525
00526    if ((hrErr != NOERROR) && lpszUserType) {
00527       lRet = RegOpenKey(HKEY_CLASSES_ROOT, (LPCSTR)"CLSID",
00528             (HKEY FAR *)&hKey);
00529       StringFromCLSID(rclsid, /*(LPOLESTR FAR*)*/&lpszCLSID);
00530       W2A (lpszCLSID, lpszAnsiCLSID, 256);
00531       W2A (lpszUserType, lpszAnsiUserType, 256);
00532       RegSetValue(hKey, lpszAnsiCLSID, REG_SZ, lpszAnsiUserType,
00533             lstrlen(lpszAnsiUserType));
00534
00535       if (lpszCLSID)
00536          OleStdFreeString(lpszCLSID, NULL);
00537
00538       hrErr = CoTreatAsClass(rclsid, rclsidNew);
00539       RegCloseKey(hKey);
00540    }
00541
00542    return hrErr;
00543 }
00544
00545
00546
00547 /* OleStdIsOleLink
00548 ** ---------------
00549 **    Returns TRUE if the OleObject is infact an OLE link object. this
00550 **    checks if IOleLink interface is supported. if so, the object is a
00551 **    link, otherwise not.
00552 */
00553 STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk)
00554 {
00555    LPOLELINK lpOleLink;
00556
00557    lpOleLink = (LPOLELINK)OleStdQueryInterface(lpUnk, &IID_IOleLink);
00558
00559    if (lpOleLink) {
00560       OleStdRelease((LPUNKNOWN)lpOleLink);
00561       return TRUE;
00562    } else
00563       return FALSE;
00564 }
00565
00566
00567 /* OleStdQueryInterface
00568 ** --------------------
00569 **    Returns the desired interface pointer if exposed by the given object.
00570 **    Returns NULL if the interface is not available.
00571 **    eg.:
00572 **      lpDataObj = OleStdQueryInterface(lpOleObj, &IID_DataObject);
00573 */
00574 STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid)
00575 {
00576    LPUNKNOWN lpInterface;
00577    HRESULT hrErr;
00578
00579    hrErr = lpUnk->lpVtbl->QueryInterface(
00580          lpUnk,
00581          riid,
00582          (LPVOID FAR*)&lpInterface
00583    );
00584
00585    if (hrErr == NOERROR)
00586       return lpInterface;
00587    else
00588       return NULL;
00589 }
00590
00591
00592 /* OleStdGetData
00593 ** -------------
00594 **    Retrieve data from an IDataObject in a specified format on a
00595 **    global memory block. This function ALWAYS returns a private copy
00596 **    of the data to the caller. if necessary a copy is made of the
00597 **    data (ie. if lpMedium->pUnkForRelease != NULL). The caller assumes
00598 **    ownership of the data block in all cases and must free the data
00599 **    when done with it. The caller may directly free the data handle
00600 **    returned (taking care whether it is a simple HGLOBAL or a HANDLE
00601 **    to a MetafilePict) or the caller may call
00602 **    ReleaseStgMedium(lpMedium). this OLE helper function will do the
00603 **    right thing.
00604 **
00605 **    PARAMETERS:
00606 **        LPDATAOBJECT lpDataObj  -- object on which GetData should be
00607 **                                                         called.
00608 **        CLIPFORMAT cfFormat     -- desired clipboard format (eg. CF_TEXT)
00609 **        DVTARGETDEVICE FAR* lpTargetDevice -- target device for which
00610 **                                  the data should be composed. This may
00611 **                                  be NULL. NULL can be used whenever the
00612 **                                  data format is insensitive to target
00613 **                                  device or when the caller does not care
00614 **                                  what device is used.
00615 **        LPSTGMEDIUM lpMedium    -- ptr to STGMEDIUM struct. the
00616 **                                  resultant medium from the
00617 **                                  IDataObject::GetData call is
00618 **                                  returned.
00619 **
00620 **    RETURNS:
00621 **       HGLOBAL -- global memory handle of retrieved data block.
00622 **       NULL    -- if error.
00623 */
00624 STDAPI_(HGLOBAL) OleStdGetData(
00625       LPDATAOBJECT        lpDataObj,
00626       CLIPFORMAT          cfFormat,
00627       DVTARGETDEVICE FAR* lpTargetDevice,
00628       DWORD               dwDrawAspect,
00629       LPSTGMEDIUM         lpMedium
00630 )
00631 {
00632    HRESULT hrErr;
00633    FORMATETC formatetc;
00634    HGLOBAL hGlobal = NULL;
00635    HGLOBAL hCopy;
00636    LPVOID  lp;
00637
00638    formatetc.cfFormat = cfFormat;
00639    formatetc.ptd = lpTargetDevice;
00640    formatetc.dwAspect = dwDrawAspect;
00641    formatetc.lindex = -1;
00642
00643    switch (cfFormat) {
00644       case CF_METAFILEPICT:
00645          formatetc.tymed = TYMED_MFPICT;
00646          break;
00647
00648       case CF_BITMAP:
00649          formatetc.tymed = TYMED_GDI;
00650          break;
00651
00652       default:
00653          formatetc.tymed = TYMED_HGLOBAL;
00654          break;
00655    }
00656
00657    OLEDBG_BEGIN2("IDataObject::GetData called\r\n")
00658    hrErr = lpDataObj->lpVtbl->GetData(
00659          lpDataObj,
00660          (LPFORMATETC)&formatetc,
00661          lpMedium
00662    );
00663    OLEDBG_END2
00664
00665    if (hrErr != NOERROR)
00666       return NULL;
00667
00668    if ((hGlobal = lpMedium->u.hGlobal) == NULL)
00669       return NULL;
00670
00671    // Check if hGlobal really points to valid memory
00672    if ((lp = GlobalLock(hGlobal)) != NULL) {
00673       if (IsBadReadPtr(lp, 1)) {
00674          GlobalUnlock(hGlobal);
00675          return NULL;    // ERROR: memory is NOT valid
00676       }
00677       GlobalUnlock(hGlobal);
00678    }
00679
00680    if (hGlobal != NULL && lpMedium->pUnkForRelease != NULL) {
00681       /* NOTE: the callee wants to retain ownership of the data.
00682       **    this is indicated by passing a non-NULL pUnkForRelease.
00683       **    thus, we will make a copy of the data and release the
00684       **    callee's copy.
00685       */
00686
00687       hCopy = OleDuplicateData(hGlobal, cfFormat, GHND|GMEM_SHARE);
00688       ReleaseStgMedium(lpMedium); // release callee's copy of data
00689
00690       hGlobal = hCopy;
00691       lpMedium->u.hGlobal = hCopy;
00692       lpMedium->pUnkForRelease = NULL;
00693    }
00694    return hGlobal;
00695 }
00696
00697
00698 /* OleStdMalloc
00699 ** ------------
00700 **    allocate memory using the currently active IMalloc* allocator
00701 */
00702 STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize)
00703 {
00704    LPVOID pout;
00705    LPMALLOC pmalloc;
00706
00707    if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR) {
00708       OleDbgAssertSz(0, szAssertMemAlloc);
00709       return NULL;
00710    }
00711
00712    pout = (LPVOID)pmalloc->lpVtbl->Alloc(pmalloc, ulSize);
00713
00714    if (pmalloc != NULL) {
00715       ULONG refs = pmalloc->lpVtbl->Release(pmalloc);
00716    }
00717
00718    return pout;
00719 }
00720
00721
00722 /* OleStdRealloc
00723 ** -------------
00724 **    re-allocate memory using the currently active IMalloc* allocator
00725 */
00726 STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize)
00727 {
00728    LPVOID pout = NULL;
00729    LPMALLOC pmalloc;
00730
00731    if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR) {
00732       OleDbgAssertSz(0, szAssertMemAlloc);
00733       return NULL;
00734    }
00735
00736    if (pmalloc != NULL)
00737    {
00738        ULONG refs;
00739        pout = (LPVOID)pmalloc->lpVtbl->Realloc(pmalloc, pmem, ulSize);
00740        refs = pmalloc->lpVtbl->Release(pmalloc);
00741    }
00742
00743    return pout;
00744 }
00745
00746
00747 /* OleStdFree
00748 ** ----------
00749 **    free memory using the currently active IMalloc* allocator
00750 */
00751 STDAPI_(void) OleStdFree(LPVOID pmem)
00752 {
00753    LPMALLOC pmalloc;
00754
00755    if (pmem == NULL)
00756       return;
00757
00758    if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR) {
00759       OleDbgAssertSz(0, szAssertMemAlloc);
00760       return;
00761    }
00762
00763
00764     if (pmalloc != NULL)
00765     {
00766         ULONG refs;
00767 #if defined(_DEBUG)
00768         int iReturn;
00769         iReturn = pmalloc->lpVtbl->DidAlloc(pmalloc, pmem);
00770         OleDbgAssertSz(1 == iReturn, "OleStdFree tried to release a suspicious pointer");
00771 #endif
00772         pmalloc->lpVtbl->Free(pmalloc, pmem);
00773         refs = pmalloc->lpVtbl->Release(pmalloc);
00774     }
00775 }
00776
00777
00778 /* OleStdGetSize
00779 ** -------------
00780 **    Get the size of a memory block that was allocated using the
00781 **    currently active IMalloc* allocator.
00782 */
00783 STDAPI_(ULONG) OleStdGetSize(LPVOID pmem)
00784 {
00785    ULONG ulSize;
00786    LPMALLOC pmalloc;
00787
00788    if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR) {
00789       OleDbgAssertSz(0, szAssertMemAlloc);
00790       return (ULONG)-1;
00791    }
00792
00793    ulSize = pmalloc->lpVtbl->GetSize(pmalloc, pmem);
00794
00795    if (pmalloc != NULL) {
00796       ULONG refs = pmalloc->lpVtbl->Release(pmalloc);
00797    }
00798
00799    return ulSize;
00800 }
00801
00802
00803 /* OleStdFreeString
00804 ** ----------------
00805 **    Free a string that was allocated with the currently active
00806 **    IMalloc* allocator.
00807 **
00808 **    if the caller has the current IMalloc* handy, then it can be
00809 **    passed as a argument, otherwise this function will retrieve the
00810 **    active allocator and use it.
00811 */
00812 STDAPI_(void) OleStdFreeString(LPOLESTR lpsz, LPMALLOC lpMalloc)
00813 {
00814    BOOL fMustRelease = FALSE;
00815
00816    if (! lpMalloc) {
00817       if (CoGetMalloc(MEMCTX_TASK, &lpMalloc) != NOERROR)
00818          return;
00819       fMustRelease = TRUE;
00820    }
00821
00822    lpMalloc->lpVtbl->Free(lpMalloc, lpsz);
00823
00824    if (fMustRelease)
00825       lpMalloc->lpVtbl->Release(lpMalloc);
00826 }
00827
00828
00829 /* OleStdCopyString
00830 ** ----------------
00831 **    Copy a string into memory allocated with the currently active
00832 **    IMalloc* allocator.
00833 **
00834 **    if the caller has the current IMalloc* handy, then it can be
00835 **    passed as a argument, otherwise this function will retrieve the
00836 **    active allocator and use it.
00837 */
00838 STDAPI_(LPOLESTR) OleStdCopyString(LPOLESTR lpszSrc, LPMALLOC lpMalloc)
00839 {
00840    LPOLESTR lpszDest = NULL;
00841    BOOL fMustRelease = FALSE;
00842    UINT lSize = OLESTRLEN(lpszSrc);
00843
00844    if (! lpMalloc) {
00845       if (CoGetMalloc(MEMCTX_TASK, &lpMalloc) != NOERROR)
00846          return NULL;
00847       fMustRelease = TRUE;
00848    }
00849
00850    lpszDest = lpMalloc->lpVtbl->Alloc(lpMalloc, (lSize+1)*sizeof(OLECHAR));
00851
00852    if (lpszDest)
00853       OLESTRCPY(lpszDest, lpszSrc);
00854
00855    if (fMustRelease)
00856       lpMalloc->lpVtbl->Release(lpMalloc);
00857    return lpszDest;
00858 }
00859
00860
00861 /*
00862  * OleStdCreateStorageOnHGlobal()
00863  *
00864  * Purpose:
00865  *  Create a memory based IStorage*.
00866  *
00867  *  NOTE: if fDeleteOnRelease==TRUE, then the ILockBytes is created
00868  *            such that it will delete them memory on its last release.
00869  *            the IStorage on created on top of the ILockBytes in NOT
00870  *            created with STGM_DELETEONRELEASE. when the IStorage receives
00871  *            its last release, it will release the ILockBytes which will
00872  *            in turn free the memory. it is in fact an error to specify
00873  *            STGM_DELETEONRELEASE in this situation.
00874  *
00875  * Parameters:
00876  *  hGlobal --  handle to MEM_SHARE allocated memory. may be NULL and
00877  *              memory will be automatically allocated.
00878  *  fDeleteOnRelease -- controls if the memory is freed on the last release.
00879  *  grfMode --  flags passed to StgCreateDocfileOnILockBytes
00880  *
00881  *  NOTE: if hGlobal is NULL, then a new IStorage is created and
00882  *              STGM_CREATE flag is passed to StgCreateDocfileOnILockBytes.
00883  *        if hGlobal is non-NULL, then it is assumed that the hGlobal already
00884  *              has an IStorage inside it and STGM_CONVERT flag is passed
00885  *              to StgCreateDocfileOnILockBytes.
00886  *
00887  * Return Value:
00888  *    SCODE  -  S_OK if successful
00889  */
00890 STDAPI_(LPSTORAGE) OleStdCreateStorageOnHGlobal(
00891       HANDLE hGlobal,
00892       BOOL fDeleteOnRelease,
00893       DWORD grfMode
00894 )
00895 {
00896    DWORD grfCreateMode=grfMode | (hGlobal==NULL ? STGM_CREATE:STGM_CONVERT);
00897    HRESULT hrErr;
00898    LPLOCKBYTES lpLockBytes = NULL;
00899    DWORD reserved = 0;
00900    LPSTORAGE lpStg = NULL;
00901
00902    hrErr = CreateILockBytesOnHGlobal(
00903          hGlobal,
00904          fDeleteOnRelease,
00905          (LPLOCKBYTES FAR*)&lpLockBytes
00906    );
00907    if (hrErr != NOERROR)
00908       return NULL;
00909
00910    hrErr = StgCreateDocfileOnILockBytes(
00911          lpLockBytes,
00912          grfCreateMode,
00913          reserved,
00914          (LPSTORAGE FAR*)&lpStg
00915    );
00916    if (hrErr != NOERROR) {
00917       OleStdRelease((LPUNKNOWN)lpLockBytes);
00918       return NULL;
00919    }
00920    OleStdRelease((LPUNKNOWN)lpLockBytes);
00921    return lpStg;
00922 }
00923
00924
00925
00926 /*
00927  * OleStdCreateTempStorage()
00928  *
00929  * Purpose:
00930  *  Create a temporay IStorage* that will DeleteOnRelease.
00931  *  this can be either memory based or file based.
00932  *
00933  * Parameters:
00934  *  fUseMemory -- controls if memory-based or file-based stg is created
00935  *  grfMode --  storage mode flags
00936  *
00937  * Return Value:
00938  *    LPSTORAGE  -  if successful, NULL otherwise
00939  */
00940 STDAPI_(LPSTORAGE) OleStdCreateTempStorage(BOOL fUseMemory, DWORD grfMode)
00941 {
00942    LPSTORAGE   lpstg;
00943    HRESULT     hrErr;
00944    DWORD       reserved = 0;
00945
00946    if (fUseMemory) {
00947       lpstg = OleStdCreateStorageOnHGlobal(
00948             NULL,  /* auto allocate */
00949             TRUE,  /* delete on release */
00950             grfMode
00951       );
00952    } else {
00953       /* allocate a temp docfile that will delete on last release */
00954       hrErr = StgCreateDocfile(
00955             NULL,
00956             grfMode | STGM_DELETEONRELEASE | STGM_CREATE,
00957             reserved,
00958             &lpstg
00959       );
00960       if (hrErr != NOERROR)
00961          return NULL;
00962    }
00963    return lpstg;
00964 }
00965
00966
00967 /* OleStdGetOleObjectData
00968 ** ----------------------
00969 **    Render CF_EMBEDSOURCE/CF_EMBEDDEDOBJECT data on an TYMED_ISTORAGE
00970 **    medium by asking the object to save into the storage.
00971 **    the object must support IPersistStorage.
00972 **
00973 **    if lpMedium->tymed == TYMED_NULL, then a delete-on-release
00974 **    storage is allocated (either file-based or memory-base depending
00975 **    the value of fUseMemory). this is useful to support an
00976 **    IDataObject::GetData call where the callee must allocate the
00977 **    medium.
00978 **
00979 **    if lpMedium->tymed == TYMED_ISTORAGE, then the data is writen
00980 **    into the passed in IStorage. this is useful to support an
00981 **    IDataObject::GetDataHere call where the caller has allocated his
00982 **    own IStorage.
00983 */
00984 STDAPI OleStdGetOleObjectData(
00985       LPPERSISTSTORAGE        lpPStg,
00986       LPFORMATETC             lpformatetc,
00987       LPSTGMEDIUM             lpMedium,
00988       BOOL                    fUseMemory
00989 )
00990 {
00991    LPSTORAGE   lpstg = NULL;
00992    DWORD       reserved = 0;
00993    SCODE       sc = S_OK;
00994    HRESULT     hrErr;
00995
00996    lpMedium->pUnkForRelease = NULL;
00997
00998    if (lpMedium->tymed == TYMED_NULL) {
00999
01000       if (lpformatetc->tymed & TYMED_ISTORAGE) {
01001
01002          /* allocate a temp docfile that will delete on last release */
01003          lpstg = OleStdCreateTempStorage(
01004                TRUE /*fUseMemory*/,
01005                STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE
01006          );
01007          if (!lpstg)
01008             return E_OUTOFMEMORY;
01009
01010          lpMedium->u.pstg = lpstg;
01011          lpMedium->tymed = TYMED_ISTORAGE;
01012          lpMedium->pUnkForRelease = NULL;
01013       } else {
01014          return DATA_E_FORMATETC;
01015       }
01016    } else if (lpMedium->tymed == TYMED_ISTORAGE) {
01017       lpMedium->tymed = TYMED_ISTORAGE;
01018    } else {
01019       return DATA_E_FORMATETC;
01020    }
01021
01022    // NOTE: even if OleSave returns an error you should still call
01023    // SaveCompleted.
01024
01025    OLEDBG_BEGIN2("OleSave called\r\n")
01026    hrErr = OleSave(lpPStg, lpMedium->u.pstg, FALSE /* fSameAsLoad */);
01027    OLEDBG_END2
01028
01029    if (hrErr != NOERROR) {
01030       OleDbgOutHResult("WARNING: OleSave returned", hrErr);
01031       sc = hrErr;
01032    }
01033    OLEDBG_BEGIN2("IPersistStorage::SaveCompleted called\r\n")
01034    hrErr = lpPStg->lpVtbl->SaveCompleted(lpPStg, NULL);
01035    OLEDBG_END2
01036
01037    if (hrErr != NOERROR) {
01038       OleDbgOutHResult("WARNING: SaveCompleted returned",hrErr);
01039       if (sc == S_OK)
01040          sc = hrErr;
01041    }
01042
01043    return sc;
01044 }
01045
01046
01047 STDAPI OleStdGetLinkSourceData(
01048       LPMONIKER           lpmk,
01049       LPCLSID             lpClsID,
01050       LPFORMATETC         lpformatetc,
01051       LPSTGMEDIUM         lpMedium
01052 )
01053 {
01054    LPSTREAM    lpstm = NULL;
01055    DWORD       reserved = 0;
01056    HRESULT     hrErr;
01057
01058    if (lpMedium->tymed == TYMED_NULL) {
01059       if (lpformatetc->tymed & TYMED_ISTREAM) {
01060          hrErr = CreateStreamOnHGlobal(
01061                NULL, /* auto allocate */
01062                TRUE, /* delete on release */
01063                (LPSTREAM FAR*)&lpstm
01064          );
01065          if (hrErr != NOERROR) {
01066             lpMedium->pUnkForRelease = NULL;
01067             return E_OUTOFMEMORY;
01068          }
01069          lpMedium->u.pstm = lpstm;
01070          lpMedium->tymed = TYMED_ISTREAM;
01071          lpMedium->pUnkForRelease = NULL;
01072       } else {
01073          lpMedium->pUnkForRelease = NULL;
01074          return DATA_E_FORMATETC;
01075       }
01076    } else {
01077       if (lpMedium->tymed == TYMED_ISTREAM) {
01078          lpMedium->tymed = TYMED_ISTREAM;
01079          lpMedium->u.pstm = lpMedium->u.pstm;
01080          lpMedium->pUnkForRelease = NULL;
01081       } else {
01082          lpMedium->pUnkForRelease = NULL;
01083          return DATA_E_FORMATETC;
01084       }
01085    }
01086
01087    hrErr = OleSaveToStream((LPPERSISTSTREAM)lpmk, lpMedium->u.pstm);
01088    if (hrErr != NOERROR) return hrErr;
01089    return WriteClassStm(lpMedium->u.pstm, lpClsID);
01090 }
01091
01092 /*
01093  * OleStdGetObjectDescriptorData
01094  *
01095  * Purpose:
01096  *  Fills and returns a OBJECTDESCRIPTOR structure.
01097  *  See OBJECTDESCRIPTOR for more information.
01098  *
01099  * Parameters:
01100  *  clsid           CLSID   CLSID of object being transferred
01101  *  dwDrawAspect    DWORD   Display Aspect of object
01102  *  sizel           SIZEL   Size of object in HIMETRIC
01103  *  pointl          POINTL  Offset from upper-left corner of object where mouse went
01104  *                          down for drag. Meaningful only when drag-drop is used.
01105  *  dwStatus        DWORD   OLEMISC flags
01106  *  lpszFullUserTypeName  LPSTR Full User Type Name
01107  *  lpszSrcOfCopy   LPSTR   Source of Copy
01108  *
01109  * Return Value:
01110  *  HBGLOBAL         Handle to OBJECTDESCRIPTOR structure.
01111  */
01112 STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
01113    CLSID     clsid,
01114    DWORD     dwDrawAspect,
01115    SIZEL     sizel,
01116    POINTL    pointl,
01117    DWORD     dwStatus,
01118    LPOLESTR  lpszFullUserTypeName,
01119    LPOLESTR  lpszSrcOfCopy
01120 )
01121 {
01122    HGLOBAL            hMem = NULL;
01123    IBindCtx   FAR    *pbc = NULL;
01124    LPOBJECTDESCRIPTOR lpOD;
01125    DWORD     dwObjectDescSize, dwFullUserTypeNameLen, dwSrcOfCopyLen;
01126    DWORD dwODSize ;
01127
01128    // Get the length of Full User Type Name; Add 1 for the null terminator
01129    dwFullUserTypeNameLen = lpszFullUserTypeName ?
01130                                     OLESTRLEN(lpszFullUserTypeName)+1 : 0;
01131
01132    // Get the Source of Copy string and it's length; Add 1 for the null terminator
01133    if (lpszSrcOfCopy)
01134       dwSrcOfCopyLen = OLESTRLEN(lpszSrcOfCopy)+1;
01135    else {
01136       // No src moniker so use user type name as source string.
01137       lpszSrcOfCopy =  lpszFullUserTypeName;
01138       dwSrcOfCopyLen = dwFullUserTypeNameLen;
01139    }
01140
01141    // Allocate space for OBJECTDESCRIPTOR and the additional string data
01142    dwObjectDescSize = sizeof(OBJECTDESCRIPTOR);
01143    dwODSize = dwObjectDescSize + (sizeof(OLECHAR) *
01144                                 (dwFullUserTypeNameLen + dwSrcOfCopyLen)) ;
01145    hMem = GlobalAlloc((GMEM_MOVEABLE | GMEM_SHARE), dwODSize) ;
01146    if (NULL == hMem)
01147       goto error;
01148
01149    lpOD = (LPOBJECTDESCRIPTOR)GlobalLock(hMem);
01150
01151    // Set the FullUserTypeName offset and copy the string
01152    if (lpszFullUserTypeName)
01153    {
01154       lpOD->dwFullUserTypeName = dwObjectDescSize;
01155       OLESTRCPY((LPOLESTR)((LPSTR)lpOD + lpOD->dwFullUserTypeName) ,
01156                                                     lpszFullUserTypeName);
01157    }
01158    else lpOD->dwFullUserTypeName = 0;  // zero offset indicates that string is not present
01159
01160    // Set the SrcOfCopy offset and copy the string
01161    if (lpszSrcOfCopy)
01162    {
01163       lpOD->dwSrcOfCopy = dwObjectDescSize +
01164                                (sizeof(OLECHAR) * dwFullUserTypeNameLen) ;
01165       OLESTRCPY((LPOLESTR)((LPSTR)lpOD + lpOD->dwSrcOfCopy), lpszSrcOfCopy);
01166    }
01167    else lpOD->dwSrcOfCopy = 0;  // zero offset indicates that string is not present
01168
01169    // Initialize the rest of the OBJECTDESCRIPTOR
01170    lpOD->cbSize       = dwODSize ;
01171    lpOD->clsid        = clsid;
01172    lpOD->dwDrawAspect = dwDrawAspect;
01173    lpOD->sizel        = sizel;
01174    lpOD->pointl       = pointl;
01175    lpOD->dwStatus     = dwStatus;
01176
01177    GlobalUnlock(hMem);
01178    return hMem;
01179
01180 error:
01181    if (hMem)
01182    {
01183       GlobalUnlock(hMem);
01184       GlobalFree(hMem);
01185    }
01186    return NULL;
01187 }
01188
01189 /*
01190  * OleStdGetObjectDescriptorDataFromOleObject
01191  *
01192  * Purpose:
01193  *  Fills and returns a OBJECTDESCRIPTOR structure. Information for the structure is
01194  *  obtained from an OLEOBJECT.
01195  *  See OBJECTDESCRIPTOR for more information.
01196  *
01197  * Parameters:
01198  *  lpOleObj        LPOLEOBJECT OleObject from which ONJECTDESCRIPTOR info
01199  *                  is obtained.
01200  *  lpszSrcOfCopy   LPSTR string to identify source of copy.
01201  *                  May be NULL in which case IOleObject::GetMoniker is called
01202  *                  to get the moniker of the object. if the object is loaded
01203  *                  as part of a data transfer document, then usually
01204  *                  lpOleClientSite==NULL is passed to OleLoad when loading
01205  *                  the object. in this case the IOleObject:GetMoniker call
01206  *                  will always fail (it tries to call back to the object's
01207  *                  client site). in this situation a non-NULL lpszSrcOfCopy
01208  *                  parameter should be passed.
01209  *  dwDrawAspect    DWORD   Display Aspect of object
01210  *  pointl          POINTL  Offset from upper-left corner of object where
01211  *                  mouse went down for drag. Meaningful only when drag-drop
01212  *                  is used.
01213  *  lpSizelHim      SIZEL   (optional) If the object is being scaled in its
01214  *                  container, then the container should pass the extents
01215  *                  that it is using to display the object.
01216  *                  May be NULL if the object is NOT being scaled. in this
01217  *                  case, IViewObject2::GetExtent will be called to get the
01218  *                  extents from the object.
01219  *
01220  * Return Value:
01221  *  HBGLOBAL         Handle to OBJECTDESCRIPTOR structure.
01222  */
01223
01224 STDAPI_(HGLOBAL) OleStdGetObjectDescriptorDataFromOleObject(
01225       LPOLEOBJECT lpOleObj,
01226       LPOLESTR       lpszSrcOfCopy,
01227       DWORD       dwDrawAspect,
01228       POINTL      pointl,
01229       LPSIZEL     lpSizelHim
01230 )
01231 {
01232    CLSID clsid;
01233    LPOLESTR lpszFullUserTypeName = NULL;
01234    char     lpszAnsiFullUserTypeName[256];
01235    LPMONIKER lpSrcMonikerOfCopy = NULL;
01236    HGLOBAL hObjDesc;
01237    IBindCtx  FAR  *pbc = NULL;
01238    HRESULT hrErr;
01239    SIZEL sizelHim;
01240    BOOL  fFreeSrcOfCopy = FALSE;
01241    LPOLELINK lpOleLink = (LPOLELINK)
01242          OleStdQueryInterface((LPUNKNOWN)lpOleObj,&IID_IOleLink);
01243    LPVIEWOBJECT2 lpViewObj2 = (LPVIEWOBJECT2)
01244          OleStdQueryInterface((LPUNKNOWN)lpOleObj, &IID_IViewObject2);
01245    BOOL  fIsLink = (lpOleLink ? TRUE : FALSE);
01246    OLECHAR  szLinkedTypeFmt[80];
01247    char     szAnsiLinkedTypeFmt[80];
01248    LPOLESTR lpszBuf = NULL;
01249    char     lpszAnsiBuf[256];
01250    DWORD dwStatus = 0;
01251
01252    // Get CLSID
01253    OLEDBG_BEGIN2("IOleObject::GetUserClassID called\r\n")
01254    hrErr = lpOleObj->lpVtbl->GetUserClassID(lpOleObj, &clsid);
01255    OLEDBG_END2
01256    if (hrErr != NOERROR)
01257       clsid = CLSID_NULL;
01258
01259    // Get FullUserTypeName
01260    OLEDBG_BEGIN2("IOleObject::GetUserType called\r\n")
01261    hrErr = lpOleObj->lpVtbl->GetUserType(
01262          lpOleObj,
01263          USERCLASSTYPE_FULL,
01264          /*(LPOLESTR FAR*)*/&lpszFullUserTypeName
01265    );
01266    OLEDBG_END2
01267
01268    /* if object is a link, then expand usertypename to be "Linked %s" */
01269    if (fIsLink && lpszFullUserTypeName) {
01270       if (0 == LoadString(ghInst, (UINT)IDS_OLE2UIPASTELINKEDTYPE,
01271                   /*(LPSTR)*/szAnsiLinkedTypeFmt, 80))
01272          lstrcpy(szAnsiLinkedTypeFmt, /*(LPSTR)*/"Linked %s");
01273       A2W (szAnsiLinkedTypeFmt, szLinkedTypeFmt, 80);
01274       lpszBuf = OleStdMalloc(
01275             (OLESTRLEN(lpszFullUserTypeName)+OLESTRLEN(szLinkedTypeFmt)+1)*sizeof(OLECHAR));
01276       if (lpszBuf) {
01277          W2A (lpszFullUserTypeName, lpszAnsiFullUserTypeName, 256);
01278          wsprintf(lpszAnsiBuf, szAnsiLinkedTypeFmt, lpszAnsiFullUserTypeName);
01279          OleStdFreeString(lpszFullUserTypeName, NULL);
01280          A2W (lpszAnsiBuf, lpszBuf, 256);
01281          lpszFullUserTypeName = lpszBuf;
01282       }
01283    }
01284
01285    /* Get Source Of Copy
01286    **    if the object is an embedding, then get the object's moniker
01287    **    if the object is a link, then get the link source moniker
01288    */
01289    if (fIsLink) {
01290
01291       OLEDBG_BEGIN2("IOleLink::GetSourceDisplayName called\r\n")
01292       hrErr = lpOleLink->lpVtbl->GetSourceDisplayName(
01293             lpOleLink, &lpszSrcOfCopy );
01294       OLEDBG_END2
01295       fFreeSrcOfCopy = TRUE;
01296
01297    } else {
01298
01299       if (lpszSrcOfCopy == NULL) {
01300          OLEDBG_BEGIN2("IOleObject::GetMoniker called\r\n")
01301          hrErr = lpOleObj->lpVtbl->GetMoniker(
01302                lpOleObj,
01303                OLEGETMONIKER_TEMPFORUSER,
01304                OLEWHICHMK_OBJFULL,
01305                (LPMONIKER FAR*)&lpSrcMonikerOfCopy
01306          );
01307          OLEDBG_END2
01308          if (hrErr == NOERROR)
01309          {
01310             CreateBindCtx(0, (LPBC FAR*)&pbc);
01311             lpSrcMonikerOfCopy->lpVtbl->GetDisplayName(
01312                   lpSrcMonikerOfCopy, pbc, NULL, &lpszSrcOfCopy);
01313             pbc->lpVtbl->Release(pbc);
01314             fFreeSrcOfCopy = TRUE;
01315          }
01316       }
01317    }
01318
01319    // Get SIZEL
01320    if (lpSizelHim) {
01321       // Use extents passed by the caller
01322       sizelHim = *lpSizelHim;
01323    } else if (lpViewObj2) {
01324       // Get the current extents from the object
01325       OLEDBG_BEGIN2("IViewObject2::GetExtent called\r\n")
01326       hrErr = lpViewObj2->lpVtbl->GetExtent(
01327             lpViewObj2,
01328             dwDrawAspect,
01329             -1,     /*lindex*/
01330             NULL,   /*ptd*/
01331             (LPSIZEL)&sizelHim
01332       );
01333       OLEDBG_END2
01334       if (hrErr != NOERROR)
01335          sizelHim.cx = sizelHim.cy = 0;
01336    } else {
01337       sizelHim.cx = sizelHim.cy = 0;
01338    }
01339
01340    // Get DWSTATUS
01341    OLEDBG_BEGIN2("IOleObject::GetMiscStatus called\r\n")
01342    hrErr = lpOleObj->lpVtbl->GetMiscStatus(
01343             lpOleObj,
01344             dwDrawAspect,
01345             &dwStatus
01346    );
01347    OLEDBG_END2
01348    if (hrErr != NOERROR)
01349       dwStatus = 0;
01350
01351    // Get OBJECTDESCRIPTOR
01352    hObjDesc = OleStdGetObjectDescriptorData(
01353          clsid,
01354          dwDrawAspect,
01355          sizelHim,
01356          pointl,
01357          dwStatus,
01358          lpszFullUserTypeName,
01359          lpszSrcOfCopy
01360    );
01361    if (! hObjDesc)
01362       goto error;
01363
01364    // Clean up
01365    if (lpszFullUserTypeName)
01366       OleStdFreeString(lpszFullUserTypeName, NULL);
01367    if (fFreeSrcOfCopy && lpszSrcOfCopy)
01368       OleStdFreeString(lpszSrcOfCopy, NULL);
01369    if (lpSrcMonikerOfCopy)
01370       OleStdRelease((LPUNKNOWN)lpSrcMonikerOfCopy);
01371    if (lpOleLink)
01372       OleStdRelease((LPUNKNOWN)lpOleLink);
01373    if (lpViewObj2)
01374       OleStdRelease((LPUNKNOWN)lpViewObj2);
01375
01376    return hObjDesc;
01377
01378 error:
01379    if (lpszFullUserTypeName)
01380       OleStdFreeString(lpszFullUserTypeName, NULL);
01381    if (fFreeSrcOfCopy && lpszSrcOfCopy)
01382       OleStdFreeString(lpszSrcOfCopy, NULL);
01383    if (lpSrcMonikerOfCopy)
01384       OleStdRelease((LPUNKNOWN)lpSrcMonikerOfCopy);
01385    if (lpOleLink)
01386       OleStdRelease((LPUNKNOWN)lpOleLink);
01387    if (lpViewObj2)
01388       OleStdRelease((LPUNKNOWN)lpViewObj2);
01389
01390    return NULL;
01391 }
01392
01393 /*
01394  * OleStdFillObjectDescriptorFromData
01395  *
01396  * Purpose:
01397  *  Fills and returns a OBJECTDESCRIPTOR structure. The source object will
01398  *  offer CF_OBJECTDESCRIPTOR if it is an OLE2 object, CF_OWNERLINK if it
01399  *  is an OLE1 object, or CF_FILENAME if it has been copied to the clipboard
01400  *  by FileManager.
01401  *
01402  * Parameters:
01403  *  lpDataObject    LPDATAOBJECT Source object
01404  *  lpmedium        LPSTGMEDIUM  Storage medium
01405  *  lpcfFmt         CLIPFORMAT FAR * Format offered by lpDataObject
01406  *                  (OUT parameter)
01407  *
01408  * Return Value:
01409  *  HBGLOBAL         Handle to OBJECTDESCRIPTOR structure.
01410  */
01411
01412 STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
01413       LPDATAOBJECT     lpDataObject,
01414       LPSTGMEDIUM      lpmedium,
01415       CLIPFORMAT FAR* lpcfFmt
01416 )
01417 {
01418    CLSID              clsid;
01419    SIZEL              sizelHim;
01420    POINTL             pointl;
01421    LPOLESTR           lpsz, szFullUserTypeName, szSrcOfCopy, szClassName, szDocName, szItemName;
01422    int                nClassName, nDocName, nItemName, nFullUserTypeName;
01423    LPOLESTR           szBuf = NULL;
01424    HGLOBAL            hMem = NULL;
01425    HKEY               hKey = NULL;
01426    LPMALLOC           pIMalloc = NULL;
01427    DWORD              dw = OLEUI_CCHKEYMAX;
01428    HGLOBAL            hObjDesc;
01429    HRESULT            hrErr;
01430    char               szAnsiString[256];
01431
01432
01433    // GetData CF_OBJECTDESCRIPTOR format from the object on the clipboard.
01434    // Only OLE 2 objects on the clipboard will offer CF_OBJECTDESCRIPTOR
01435    if (hMem = OleStdGetData(
01436          lpDataObject,
01437          (CLIPFORMAT)cfObjectDescriptor,
01438          NULL,
01439          DVASPECT_CONTENT,
01440          lpmedium))
01441    {
01442       *lpcfFmt = cfObjectDescriptor;
01443       return hMem;  // Don't drop to clean up at the end of this function
01444    }
01445    // If CF_OBJECTDESCRIPTOR is not available, i.e. if this is not an OLE2 object,
01446    //     check if this is an OLE 1 object. OLE 1 objects will offer CF_OWNERLINK
01447    else if (hMem = OleStdGetData(
01448             lpDataObject,
01449             (CLIPFORMAT)cfOwnerLink,
01450             NULL,
01451             DVASPECT_CONTENT,
01452             lpmedium))
01453    {
01454       *lpcfFmt = cfOwnerLink;
01455       // CF_OWNERLINK contains null-terminated strings for class name, document name
01456       // and item name with two null terminating characters at the end
01457       szClassName = /*(LPOLESTR)*/GlobalLock(hMem);
01458       nClassName  = OLESTRLEN(szClassName);
01459       szDocName   = szClassName + nClassName + 1;
01460       nDocName    = OLESTRLEN(szDocName);
01461       szItemName  = szDocName + nDocName + 1;
01462       nItemName   = OLESTRLEN(szItemName);
01463
01464       hrErr = CoGetMalloc(MEMCTX_TASK, &pIMalloc);
01465       if (hrErr != NOERROR)
01466          goto error;
01467
01468       // Find FullUserTypeName from Registration database using class name
01469       if (RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey) != ERROR_SUCCESS)
01470          goto error;
01471
01472       // Allocate space for szFullUserTypeName & szSrcOfCopy. Maximum length of FullUserTypeName
01473       // is OLEUI_CCHKEYMAX. SrcOfCopy is constructed by concatenating FullUserTypeName, Document
01474       // Name and ItemName separated by spaces.
01475       szBuf = /*(LPOLESTR)*/pIMalloc->lpVtbl->Alloc(pIMalloc,
01476                      (DWORD)2*OLEUI_CCHKEYMAX+nDocName+nItemName+4);
01477       if (NULL == szBuf)
01478          goto error;
01479       szFullUserTypeName = szBuf;
01480       szSrcOfCopy = szFullUserTypeName+OLEUI_CCHKEYMAX+1;
01481
01482       // Get FullUserTypeName
01483       if (RegQueryValue(hKey, NULL, szAnsiString, &dw) != ERROR_SUCCESS)
01484          goto error;
01485       A2W (szAnsiString, szFullUserTypeName, OLEUI_CCHKEYMAX);
01486
01487       // Build up SrcOfCopy string from FullUserTypeName, DocumentName & ItemName
01488       lpsz = szSrcOfCopy;
01489       OLESTRCPY(lpsz, szFullUserTypeName);
01490       nFullUserTypeName = OLESTRLEN(szFullUserTypeName);
01491       lpsz[nFullUserTypeName]=' ';
01492       lpsz += nFullUserTypeName+1;
01493       OLESTRCPY(lpsz, szDocName);
01494       lpsz[nDocName] = ' ';
01495       lpsz += nDocName+1;
01496       OLESTRCPY(lpsz, szItemName);
01497
01498       sizelHim.cx = sizelHim.cy = 0;
01499       pointl.x = pointl.y = 0;
01500
01501       CLSIDFromProgID(szClassName, &clsid);
01502
01503       hObjDesc = OleStdGetObjectDescriptorData(
01504             clsid,
01505             DVASPECT_CONTENT,
01506             sizelHim,
01507             pointl,
01508             0,
01509             szFullUserTypeName,
01510             szSrcOfCopy
01511       );
01512       if (!hObjDesc)
01513          goto error;
01514     }
01515     // Check if object is CF_FILENAME
01516     else if (hMem = OleStdGetData(
01517             lpDataObject,
01518             (CLIPFORMAT)cfFileName,
01519             NULL,
01520             DVASPECT_CONTENT,
01521             lpmedium))
01522     {
01523        *lpcfFmt = cfFileName;
01524        lpsz = /*(LPOLESTR)*/GlobalLock(hMem);
01525        hrErr = GetClassFile(lpsz, &clsid);
01526
01527        /* NOTE: if the file does not have an OLE class
01528        **    associated, then use the OLE 1 Packager as the class of
01529        **    the object to be created. this is the behavior of
01530        **    OleCreateFromData API
01531        */
01532        if (hrErr != NOERROR)
01533          CLSIDFromProgID(OLESTR("Package"), &clsid);
01534        sizelHim.cx = sizelHim.cy = 0;
01535        pointl.x = pointl.y = 0;
01536
01537        hrErr = CoGetMalloc(MEMCTX_TASK, &pIMalloc);
01538        if (hrErr != NOERROR)
01539          goto error;
01540        szBuf = /*(LPOLESTR)*/pIMalloc->lpVtbl->Alloc(pIMalloc, (DWORD)OLEUI_CCHKEYMAX);
01541        if (NULL == szBuf)
01542          goto error;
01543
01544        OleStdGetUserTypeOfClass(&clsid, szBuf, OLEUI_CCHKEYMAX, NULL);
01545
01546        hObjDesc = OleStdGetObjectDescriptorData(
01547             clsid,
01548             DVASPECT_CONTENT,
01549             sizelHim,
01550             pointl,
01551             0,
01552             szBuf,
01553             lpsz
01554       );
01555       if (!hObjDesc)
01556          goto error;
01557     }
01558     else goto error;
01559
01560     // Clean up
01561     if (szBuf)
01562        pIMalloc->lpVtbl->Free(pIMalloc, (LPVOID)szBuf);
01563     if (pIMalloc)
01564        pIMalloc->lpVtbl->Release(pIMalloc);
01565     if (hMem)
01566     {
01567        GlobalUnlock(hMem);
01568        GlobalFree(hMem);
01569     }
01570     if (hKey)
01571        RegCloseKey(hKey);
01572     return hObjDesc;
01573
01574 error:
01575    if (szBuf)
01576       pIMalloc->lpVtbl->Free(pIMalloc, (LPVOID)szBuf);
01577    if (pIMalloc)
01578       pIMalloc->lpVtbl->Release(pIMalloc);
01579     if (hMem)
01580     {
01581        GlobalUnlock(hMem);
01582        GlobalFree(hMem);
01583     }
01584     if (hKey)
01585        RegCloseKey(hKey);
01586     return NULL;
01587 }
01588
01589
01590 #if defined( OBSOLETE )
01591
01592 /*************************************************************************
01593 ** The following API's have been converted into macros:
01594 **          OleStdQueryOleObjectData
01595 **          OleStdQueryLinkSourceData
01596 **          OleStdQueryObjectDescriptorData
01597 **          OleStdQueryFormatMedium
01598 **          OleStdCopyMetafilePict
01599 **          OleStdGetDropEffect
01600 **
01601 **    These macros are defined in olestd.h
01602 *************************************************************************/
01603
01604 STDAPI OleStdQueryOleObjectData(LPFORMATETC lpformatetc)
01605 {
01606    if (lpformatetc->tymed & TYMED_ISTORAGE) {
01607       return NOERROR;
01608    } else {
01609       return DATA_E_FORMATETC;
01610    }
01611 }
01612
01613
01614 STDAPI OleStdQueryLinkSourceData(LPFORMATETC lpformatetc)
01615 {
01616    if (lpformatetc->tymed & TYMED_ISTREAM) {
01617       return NOERROR;
01618    } else {
01619       return DATA_E_FORMATETC;
01620    }
01621 }
01622
01623
01624 STDAPI OleStdQueryObjectDescriptorData(LPFORMATETC lpformatetc)
01625 {
01626    if (lpformatetc->tymed & TYMED_HGLOBAL) {
01627       return NOERROR;
01628    } else {
01629       return DATA_E_FORMATETC;
01630    }
01631 }
01632
01633
01634 STDAPI OleStdQueryFormatMedium(LPFORMATETC lpformatetc, TYMED tymed)
01635 {
01636    if (lpformatetc->tymed & tymed) {
01637       return NOERROR;
01638    } else {
01639       return DATA_E_FORMATETC;
01640    }
01641 }
01642
01643
01644 /*
01645  * OleStdCopyMetafilePict()
01646  *
01647  * Purpose:
01648  *    Make an independent copy of a MetafilePict
01649  * Parameters:
01650  *
01651  * Return Value:
01652  *    TRUE if successful, else FALSE.
01653  */
01654 STDAPI_(BOOL) OleStdCopyMetafilePict(HANDLE hpictin, HANDLE FAR* phpictout)
01655 {
01656    HANDLE hpictout;
01657    LPMETAFILEPICT ppictin, ppictout;
01658
01659    if (hpictin == NULL || phpictout == NULL) {
01660       OleDbgAssert(hpictin == NULL || phpictout == NULL);
01661       return FALSE;
01662    }
01663
01664    *phpictout = NULL;
01665
01666    if ((ppictin = (LPMETAFILEPICT)GlobalLock(hpictin)) == NULL) {
01667       return FALSE;
01668    }
01669
01670    hpictout = GlobalAlloc(GHND|GMEM_SHARE, sizeof(METAFILEPICT));
01671
01672    if (hpictout && (ppictout = (LPMETAFILEPICT)GlobalLock(hpictout))){
01673       ppictout->hMF  = CopyMetaFile(ppictin->hMF, NULL);
01674       ppictout->xExt = ppictin->xExt;
01675       ppictout->yExt = ppictin->yExt;
01676       ppictout->mm   = ppictin->mm;
01677       GlobalUnlock(hpictout);
01678    }
01679
01680    *phpictout = hpictout;
01681
01682    return TRUE;
01683
01684 }
01685
01686
01687 /* OleStdGetDropEffect
01688 ** -------------------
01689 **
01690 ** Convert a keyboard state into a DROPEFFECT.
01691 **
01692 ** returns the DROPEFFECT value derived from the key state.
01693 **    the following is the standard interpretation:
01694 **          no modifier -- Default Drop     (NULL is returned)
01695 **          CTRL        -- DROPEFFECT_COPY
01696 **          SHIFT       -- DROPEFFECT_MOVE
01697 **          CTRL-SHIFT  -- DROPEFFECT_LINK
01698 **
01699 **    Default Drop: this depends on the type of the target application.
01700 **    this is re-interpretable by each target application. a typical
01701 **    interpretation is if the drag is local to the same document
01702 **    (which is source of the drag) then a MOVE operation is
01703 **    performed. if the drag is not local, then a COPY operation is
01704 **    performed.
01705 */
01706 STDAPI_(DWORD) OleStdGetDropEffect( DWORD grfKeyState )
01707 {
01708
01709    if (grfKeyState & MK_CONTROL) {
01710
01711       if (grfKeyState & MK_SHIFT)
01712          return DROPEFFECT_LINK;
01713       else
01714          return DROPEFFECT_COPY;
01715
01716    } else if (grfKeyState & MK_SHIFT)
01717       return DROPEFFECT_MOVE;
01718
01719    return 0;    // no modifier -- do default operation
01720 }
01721 #endif  // OBSOLETE
01722
01723
01724 /*
01725  * OleStdGetMetafilePictFromOleObject()
01726  *
01727  * Purpose:
01728  *      Generate a MetafilePict by drawing the OLE object.
01729  * Parameters:
01730  *  lpOleObj        LPOLEOBJECT pointer to OLE Object
01731  *  dwDrawAspect    DWORD   Display Aspect of object
01732  *  lpSizelHim      SIZEL   (optional) If the object is being scaled in its
01733  *                  container, then the container should pass the extents
01734  *                  that it is using to display the object.
01735  *                  May be NULL if the object is NOT being scaled. in this
01736  *                  case, IViewObject2::GetExtent will be called to get the
01737  *                  extents from the object.
01738  *  ptd             TARGETDEVICE FAR*   (optional) target device to render
01739  *                  metafile for. May be NULL.
01740  *
01741  * Return Value:
01742  *    HANDLE    -- handle of allocated METAFILEPICT
01743  */
01744 STDAPI_(HANDLE) OleStdGetMetafilePictFromOleObject(
01745       LPOLEOBJECT         lpOleObj,
01746       DWORD               dwDrawAspect,
01747       LPSIZEL             lpSizelHim,
01748       DVTARGETDEVICE FAR* ptd
01749 )
01750 {
01751    LPVIEWOBJECT2 lpViewObj2 = NULL;
01752    HDC hDC;
01753    HMETAFILE hmf;
01754    HANDLE hMetaPict;
01755    LPMETAFILEPICT lpPict;
01756    RECT rcHim;
01757    RECTL rclHim;
01758    SIZEL sizelHim;
01759    HRESULT hrErr;
01760    SIZE size;
01761    POINT point;
01762
01763    lpViewObj2 = (LPVIEWOBJECT2)OleStdQueryInterface(
01764          (LPUNKNOWN)lpOleObj, &IID_IViewObject2);
01765    if (! lpViewObj2)
01766       return NULL;
01767
01768    // Get SIZEL
01769    if (lpSizelHim) {
01770       // Use extents passed by the caller
01771       sizelHim = *lpSizelHim;
01772    } else {
01773       // Get the current extents from the object
01774       OLEDBG_BEGIN2("IViewObject2::GetExtent called\r\n")
01775       hrErr = lpViewObj2->lpVtbl->GetExtent(
01776             lpViewObj2,
01777             dwDrawAspect,
01778             -1,     /*lindex*/
01779             ptd,    /*ptd*/
01780             (LPSIZEL)&sizelHim
01781       );
01782       OLEDBG_END2
01783       if (hrErr != NOERROR)
01784          sizelHim.cx = sizelHim.cy = 0;
01785    }
01786
01787    hDC = CreateMetaFile(NULL);
01788
01789    rclHim.left     = 0;
01790    rclHim.top      = 0;
01791    rclHim.right    = sizelHim.cx;
01792    rclHim.bottom   = sizelHim.cy;
01793
01794    rcHim.left      = (int)rclHim.left;
01795    rcHim.top       = (int)rclHim.top;
01796    rcHim.right     = (int)rclHim.right;
01797    rcHim.bottom    = (int)rclHim.bottom;
01798
01799    SetWindowOrgEx(hDC, rcHim.left, rcHim.top, &point);
01800    SetWindowExtEx(hDC, rcHim.right-rcHim.left, rcHim.bottom-rcHim.top,&size);
01801
01802    OLEDBG_BEGIN2("IViewObject::Draw called\r\n")
01803    hrErr = lpViewObj2->lpVtbl->Draw(
01804          lpViewObj2,
01805          dwDrawAspect,
01806          -1,
01807          NULL,
01808          ptd,
01809          NULL,
01810          hDC,
01811          (LPRECTL)&rclHim,
01812          (LPRECTL)&rclHim,
01813          NULL,
01814          0
01815    );
01816    OLEDBG_END2
01817
01818    OleStdRelease((LPUNKNOWN)lpViewObj2);
01819    if (hrErr != NOERROR) {
01820       OleDbgOutHResult("IViewObject::Draw returned", hrErr);
01821       CloseMetaFile(hDC);
01822       return(NULL);
01823    }
01824
01825    hmf = CloseMetaFile(hDC);
01826
01827    hMetaPict = GlobalAlloc(GHND|GMEM_SHARE, sizeof(METAFILEPICT));
01828
01829    if (hMetaPict && (lpPict = (LPMETAFILEPICT)GlobalLock(hMetaPict))){
01830       lpPict->hMF  = hmf;
01831       lpPict->xExt = (int)sizelHim.cx ;
01832       lpPict->yExt = (int)sizelHim.cy ;
01833       lpPict->mm   = MM_ANISOTROPIC;
01834       GlobalUnlock(hMetaPict);
01835    }
01836
01837    return hMetaPict;
01838 }
01839
01840
01841 /* Call Release on the object that is expected to go away.
01842 **      if the refcnt of the object did no go to 0 then give a debug message.
01843 */
01844 STDAPI_(ULONG) OleStdVerifyRelease(LPUNKNOWN lpUnk, LPOLESTR lpszMsg)
01845 {
01846    ULONG cRef;
01847    char  lpszAnsiMsg[256];
01848
01849    W2A (lpszMsg, lpszAnsiMsg, 256);
01850    cRef = lpUnk->lpVtbl->Release(lpUnk);
01851
01852 #if defined( _DEBUG )
01853    if (cRef != 0) {
01854       char szBuf[80];
01855       if (lpszMsg)
01856          MessageBox(NULL, lpszAnsiMsg, NULL, MB_ICONEXCLAMATION | MB_OK);
01857       wsprintf(
01858             /*(LPSTR)*/szBuf,
01859             "refcnt (%ld) != 0 after object (0x%lx) release\n",
01860             cRef,
01861             lpUnk
01862       );
01863       if (lpszMsg)
01864          OleDbgOut1(lpszAnsiMsg);
01865       OleDbgOut1(/*(LPSTR)*/szBuf);
01866       OleDbgAssertSz(cRef == 0, /*(LPSTR)*/szBuf);
01867    } else {
01868       char szBuf[80];
01869       wsprintf(
01870             /*(LPSTR)*/szBuf,
01871             "refcnt = 0 after object (0x%lx) release\n", lpUnk
01872       );
01873       OleDbgOut4(/*(LPSTR)*/szBuf);
01874    }
01875 #endif
01876    return cRef;
01877 }
01878
01879
01880 /* Call Release on the object that is NOT necessarily expected to go away.
01881 */
01882 STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk)
01883 {
01884    ULONG cRef;
01885
01886    cRef = lpUnk->lpVtbl->Release(lpUnk);
01887
01888 #if defined( _DEBUG )
01889    {
01890       char szBuf[80];
01891       wsprintf(
01892             /*(LPSTR)*/szBuf,
01893             "refcnt = %ld after object (0x%lx) release\n",
01894             cRef,
01895             lpUnk
01896       );
01897       OleDbgOut4(/*(LPSTR)*/szBuf);
01898    }
01899 #endif
01900    return cRef;
01901 }
01902
01903
01904 /* OleStdInitVtbl
01905 ** --------------
01906 **
01907 **    Initialize an interface Vtbl to ensure that there are no NULL
01908 **    function pointers in the Vtbl. All entries in the Vtbl are
01909 **    set to a valid funtion pointer (OleStdNullMethod) that issues
01910 **        debug assert message (message box) and returns E_NOTIMPL if called.
01911 **
01912 **    NOTE: this funtion does not initialize the Vtbl with usefull
01913 **    function pointers, only valid function pointers to avoid the
01914 **    horrible run-time crash when a call is made through the Vtbl with
01915 **    a NULL function pointer. this API is only necessary when
01916 **    initializing the Vtbl's in C. C++ guarantees that all interface
01917 **    functions (in C++ terms -- pure virtual functions) are implemented.
01918 */
01919
01920 STDAPI_(void) OleStdInitVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl)
01921 {
01922    LPVOID FAR* lpFuncPtrArr = (LPVOID FAR*)lpVtbl;
01923    UINT nMethods = nSizeOfVtbl/sizeof(VOID FAR*);
01924    UINT i;
01925
01926    for (i = 0; i < nMethods; i++) {
01927       lpFuncPtrArr[i] = OleStdNullMethod;
01928    }
01929 }
01930
01931
01932 /* OleStdCheckVtbl
01933 ** ---------------
01934 **
01935 **    Check if all entries in the Vtbl are properly initialized with
01936 **    valid function pointers. If any entries are either NULL or
01937 **    OleStdNullMethod, then this function returns FALSE. If compiled
01938 **    for _DEBUG this function reports which function pointers are
01939 **    invalid.
01940 **
01941 **    RETURNS:  TRUE if all entries in Vtbl are valid
01942 **                              FALSE otherwise.
01943 */
01944
01945 STDAPI_(BOOL) OleStdCheckVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl, LPOLESTR lpszIface)
01946 {
01947    LPVOID FAR* lpFuncPtrArr = (LPVOID FAR*)lpVtbl;
01948    UINT nMethods = nSizeOfVtbl/sizeof(VOID FAR*);
01949    UINT i;
01950    BOOL fStatus = TRUE;
01951    int nChar = 0;
01952
01953    for (i = 0; i < nMethods; i++) {
01954       if (lpFuncPtrArr[i] == NULL || lpFuncPtrArr[i] == OleStdNullMethod) {
01955 #if defined( _DEBUG )
01956          char szAnsiStr[256];
01957          char szBuf[256];
01958          W2A (lpszIface, szAnsiStr, 256);
01959          wsprintf(szBuf, "%s::method# %d NOT valid!", szAnsiStr, i);
01960          OleDbgOut1(/*(LPSTR)*/szBuf);
01961 #endif
01962          fStatus = FALSE;
01963       }
01964    }
01965    return fStatus;
01966 }
01967
01968
01969 /* OleStdNullMethod
01970 ** ----------------
01971 **    Dummy method used by OleStdInitVtbl to initialize an interface
01972 **    Vtbl to ensure that there are no NULL function pointers in the
01973 **    Vtbl. All entries in the Vtbl are set to this function. this
01974 **    function issues a debug assert message (message box) and returns
01975 **    E_NOTIMPL if called. If all is done properly, this function will
01976 **    NEVER be called!
01977 */
01978 STDMETHODIMP OleStdNullMethod(LPUNKNOWN lpThis)
01979 {
01980    MessageBox(
01981          NULL,
01982          "ERROR: INTERFACE METHOD NOT IMPLEMENTED!\r\n",
01983          NULL,
01984          MB_SYSTEMMODAL | MB_ICONHAND | MB_OK
01985    );
01986
01987    return E_NOTIMPL;
01988 }
01989
01990
01991
01992 static BOOL  GetFileTimes(LPSTR lpszFileName, FILETIME FAR* pfiletime)
01993 {
01994 #ifdef WIN32
01995    WIN32_FIND_DATA fd;
01996    HANDLE hFind;
01997    hFind = FindFirstFile(lpszFileName,&fd);
01998    if (hFind == NULL || hFind == INVALID_HANDLE_VALUE) {
01999       return FALSE;
02000    }
02001    FindClose(hFind);
02002    *pfiletime = fd.ftLastWriteTime;
02003    return TRUE;
02004 #else
02005    static char sz[256];
02006    static struct _find_t fileinfo;
02007
02008    LSTRCPYN(/*(LPSTR)*/sz, lpszFileName, sizeof(sz)-1);
02009    sz[sizeof(sz)-1]= '\0';
02010    AnsiToOem(sz, sz);
02011    return (_dos_findfirst(sz,_A_NORMAL|_A_HIDDEN|_A_SUBDIR|_A_SYSTEM,
02012                 (struct _find_t *)&fileinfo) == 0 &&
02013       CoDosDateTimeToFileTime(fileinfo.wr_date,fileinfo.wr_time,pfiletime));
02014 #endif
02015 }
02016
02017
02018
02019 /* OleStdRegisterAsRunning
02020 ** -----------------------
02021 **    Register a moniker in the RunningObjectTable.
02022 **    if there is an existing registration (*lpdwRegister!=NULL), then
02023 **    first revoke that registration.
02024 **
02025 **    new dwRegister key is returned via *lpdwRegister parameter.
02026 */
02027 STDAPI_(void) OleStdRegisterAsRunning(LPUNKNOWN lpUnk, LPMONIKER lpmkFull, DWORD FAR* lpdwRegister)
02028 {
02029    LPRUNNINGOBJECTTABLE lpROT;
02030    HRESULT hrErr;
02031    DWORD dwOldRegister = *lpdwRegister;
02032
02033    OLEDBG_BEGIN2("OleStdRegisterAsRunning\r\n")
02034
02035    OLEDBG_BEGIN2("GetRunningObjectTable called\r\n")
02036    hrErr = GetRunningObjectTable(0,(LPRUNNINGOBJECTTABLE FAR*)&lpROT);
02037    OLEDBG_END2
02038
02039    if (hrErr == NOERROR) {
02040
02041       /* register as running if a valid moniker is passed
02042       **
02043       ** NOTE: we deliberately register the new moniker BEFORE
02044       **    revoking the old moniker just in case the object
02045       **    currently has no external locks. if the object has no
02046       **    locks then revoking it from the running object table will
02047       **    cause the object's StubManager to initiate shutdown of
02048       **    the object.
02049       */
02050       if (lpmkFull) {
02051
02052          OLEDBG_BEGIN2("IRunningObjectTable::Register called\r\n")
02053          lpROT->lpVtbl->Register(lpROT, 0, lpUnk,lpmkFull,lpdwRegister);
02054          OLEDBG_END2
02055
02056 #if defined(_DEBUG)
02057          {
02058             char szBuf[512];
02059             LPOLESTR lpszDisplay;
02060             char     lpszAnsiDisplay[256];
02061             LPBC lpbc;
02062
02063             CreateBindCtx(0, (LPBC FAR*)&lpbc);
02064             lpmkFull->lpVtbl->GetDisplayName(
02065                   lpmkFull,
02066                   lpbc,
02067                   NULL,
02068                   /*(LPOLESTR FAR*)*/&lpszDisplay
02069             );
02070             OleStdRelease((LPUNKNOWN)lpbc);
02071             W2A (lpszDisplay, lpszAnsiDisplay, 256);
02072             wsprintf(
02073                   szBuf,
02074                   "Moniker '%s' REGISTERED as [0x%lx] in ROT\r\n",
02075                   lpszAnsiDisplay,
02076                   *lpdwRegister
02077             );
02078             OleDbgOut2(szBuf);
02079             OleStdFreeString(lpszDisplay, NULL);
02080          }
02081 #endif  // _DEBUG
02082
02083       }
02084
02085       // if already registered, revoke
02086       if (dwOldRegister != 0) {
02087
02088 #if defined(_DEBUG)
02089          {
02090             char szBuf[512];
02091
02092             wsprintf(
02093                   szBuf,
02094                   "Moniker [0x%lx] REVOKED from ROT\r\n",
02095                   dwOldRegister
02096             );
02097             OleDbgOut2(szBuf);
02098          }
02099 #endif  // _DEBUG
02100
02101          OLEDBG_BEGIN2("IRunningObjectTable::Revoke called\r\n")
02102          lpROT->lpVtbl->Revoke(lpROT, dwOldRegister);
02103          OLEDBG_END2
02104       }
02105
02106       OleStdRelease((LPUNKNOWN)lpROT);
02107    } else {
02108       OleDbgAssertSz(
02109             lpROT != NULL,
02110             "OleStdRegisterAsRunning: GetRunningObjectTable FAILED\r\n"
02111       );
02112    }
02113
02114    OLEDBG_END2
02115 }
02116
02117
02118
02119 /* OleStdRevokeAsRunning
02120 ** ---------------------
02121 **    Revoke a moniker from the RunningObjectTable if there is an
02122 **    existing registration (*lpdwRegister!=NULL).
02123 **
02124 **    *lpdwRegister parameter will be set to NULL.
02125 */
02126 STDAPI_(void) OleStdRevokeAsRunning(DWORD FAR* lpdwRegister)
02127 {
02128    LPRUNNINGOBJECTTABLE lpROT;
02129    HRESULT hrErr;
02130
02131    OLEDBG_BEGIN2("OleStdRevokeAsRunning\r\n")
02132
02133    // if still registered, then revoke
02134    if (*lpdwRegister != 0) {
02135
02136       OLEDBG_BEGIN2("GetRunningObjectTable called\r\n")
02137       hrErr = GetRunningObjectTable(0,(LPRUNNINGOBJECTTABLE FAR*)&lpROT);
02138       OLEDBG_END2
02139
02140       if (hrErr == NOERROR) {
02141
02142 #if defined(_DEBUG)
02143          {
02144             char szBuf[512];
02145
02146             wsprintf(
02147                   szBuf,
02148                   "Moniker [0x%lx] REVOKED from ROT\r\n",
02149                   *lpdwRegister
02150             );
02151             OleDbgOut2(szBuf);
02152          }
02153 #endif  // _DEBUG
02154
02155          OLEDBG_BEGIN2("IRunningObjectTable::Revoke called\r\n")
02156          lpROT->lpVtbl->Revoke(lpROT, *lpdwRegister);
02157          OLEDBG_END2
02158
02159          *lpdwRegister = 0;
02160
02161          OleStdRelease((LPUNKNOWN)lpROT);
02162       } else {
02163          OleDbgAssertSz(
02164                lpROT != NULL,
02165                "OleStdRevokeAsRunning: GetRunningObjectTable FAILED\r\n"
02166          );
02167       }
02168    }
02169    OLEDBG_END2
02170 }
02171
02172
02173 /* OleStdNoteFileChangeTime
02174 ** ------------------------
02175 **    Note the time a File-Based object has been saved in the
02176 **    RunningObjectTable. These change times are used as the basis for
02177 **    IOleObject::IsUpToDate.
02178 **    It is important to set the time of the file-based object
02179 **    following a save operation to exactly the time of the saved file.
02180 **    this helps IOleObject::IsUpToDate to give the correct answer
02181 **    after a file has been saved.
02182 */
02183 STDAPI_(void) OleStdNoteFileChangeTime(LPOLESTR lpszFileName, DWORD dwRegister)
02184 {
02185    char lpszAnsiFileName[256];
02186
02187    W2A (lpszFileName, lpszAnsiFileName, 256);
02188    if (dwRegister != 0) {
02189
02190       LPRUNNINGOBJECTTABLE lprot;
02191       FILETIME filetime;
02192
02193       if (GetFileTimes(lpszAnsiFileName, &filetime) &&
02194          GetRunningObjectTable(0,&lprot) == NOERROR)
02195       {
02196          lprot->lpVtbl->NoteChangeTime( lprot, dwRegister, &filetime );
02197          lprot->lpVtbl->Release(lprot);
02198
02199          OleDbgOut2("IRunningObjectTable::NoteChangeTime called\r\n");
02200       }
02201    }
02202 }
02203
02204
02205 /* OleStdNoteObjectChangeTime
02206 ** --------------------------
02207 **    Set the last change time of an object that is registered in the
02208 **    RunningObjectTable. These change times are used as the basis for
02209 **    IOleObject::IsUpToDate.
02210 **
02211 **    every time the object sends out a OnDataChange notification, it
02212 **    should update the Time of last change in the ROT.
02213 **
02214 **    NOTE: this function set the change time to the current time.
02215 */
02216 STDAPI_(void) OleStdNoteObjectChangeTime(DWORD dwRegister)
02217 {
02218    if (dwRegister != 0) {
02219
02220       LPRUNNINGOBJECTTABLE lprot;
02221       FILETIME filetime;
02222
02223       if (GetRunningObjectTable(0,&lprot) == NOERROR)
02224       {
02225          CoFileTimeNow( &filetime );
02226          lprot->lpVtbl->NoteChangeTime( lprot, dwRegister, &filetime );
02227          lprot->lpVtbl->Release(lprot);
02228
02229          OleDbgOut2("IRunningObjectTable::NoteChangeTime called\r\n");
02230       }
02231    }
02232 }
02233
02234
02235 /* OleStdCreateTempFileMoniker
02236 ** ---------------------------
02237 **    return the next available FileMoniker that can be used as the
02238 **    name of an untitled document.
02239 **    the FileMoniker is built of the form:
02240 **          <lpszPrefixString><number>
02241 **      eg. "Outline1", "Outline2", etc.
02242 **
02243 **    The RunningObjectTable (ROT) is consulted to determine if a
02244 **    FileMoniker is in use. If the name is in use then the number is
02245 **    incremented and the ROT is checked again.
02246 **
02247 ** Parameters:
02248 **    LPSTR lpszPrefixString    - prefix used to build the name
02249 **    UINT FAR* lpuUnique       - (IN-OUT) last used number.
02250 **                                  this number is used to make the
02251 **                                  name unique. on entry, the input
02252 **                                  number is incremented. on output,
02253 **                                  the number used is returned. this
02254 **                                  number should be passed again
02255 **                                  unchanged on the next call.
02256 **    LPSTR lpszName            - (OUT) buffer used to build string.
02257 **                                  caller must be sure buffer is large
02258 **                                  enough to hold the generated string.
02259 **    LPMONIKER FAR* lplpmk     - (OUT) next unused FileMoniker
02260 **
02261 ** Returns:
02262 **    void
02263 **
02264 ** Comments:
02265 **    This function is similar in spirit to the Windows API
02266 **    CreateTempFileName.
02267 */
02268 STDAPI_(void) OleStdCreateTempFileMoniker(
02269       LPOLESTR        lpszPrefixString,
02270       UINT FAR*       lpuUnique,
02271       LPOLESTR        lpszName,
02272       LPMONIKER FAR*  lplpmk
02273 )
02274 {
02275    LPRUNNINGOBJECTTABLE lpROT = NULL;
02276    UINT i = (lpuUnique != NULL ? *lpuUnique : 1);
02277    HRESULT hrErr;
02278    char    lpszAnsiPrefixString[256], lpszAnsiName[256];
02279
02280    W2A (lpszPrefixString, lpszAnsiPrefixString, 256);
02281    wsprintf(lpszAnsiName, "%s%d", lpszAnsiPrefixString, i++);
02282    A2W (lpszAnsiName, lpszName, OLEUI_CCHLABELMAX);
02283    CreateFileMoniker(lpszName, lplpmk);
02284
02285    OLEDBG_BEGIN2("GetRunningObjectTable called\r\n")
02286    hrErr = GetRunningObjectTable(0,(LPRUNNINGOBJECTTABLE FAR*)&lpROT);
02287    OLEDBG_END2
02288
02289    if (hrErr == NOERROR) {
02290
02291       while (1) {
02292          if (! *lplpmk)
02293             break;  // failed to create FileMoniker
02294
02295          OLEDBG_BEGIN2("IRunningObjectTable::IsRunning called\r\n")
02296          hrErr = lpROT->lpVtbl->IsRunning(lpROT,*lplpmk);
02297          OLEDBG_END2
02298
02299          if (hrErr != NOERROR)
02300             break;  // the Moniker is NOT running; found unused one!
02301
02302          OleStdVerifyRelease(
02303                (LPUNKNOWN)*lplpmk,
02304                OLESTR("OleStdCreateTempFileMoniker: Moniker NOT released")
02305             );
02306
02307          wsprintf(lpszAnsiName, "%s%d", lpszAnsiPrefixString, i++);
02308          A2W (lpszAnsiName, lpszName, OLEUI_CCHLABELMAX);
02309          CreateFileMoniker(lpszName, lplpmk);
02310       }
02311
02312       OleStdRelease((LPUNKNOWN)lpROT);
02313    }
02314
02315    if (lpuUnique != NULL)
02316       *lpuUnique = i;
02317 }
02318
02319
02320 /* OleStdGetFirstMoniker
02321 ** ---------------------
02322 **    return the first piece of a moniker.
02323 **
02324 **    NOTE: if the given moniker is not a generic composite moniker,
02325 **    then an AddRef'ed pointer to the given moniker is returned.
02326 */
02327 STDAPI_(LPMONIKER) OleStdGetFirstMoniker(LPMONIKER lpmk)
02328 {
02329    LPMONIKER       lpmkFirst = NULL;
02330    LPENUMMONIKER   lpenumMoniker;
02331    DWORD           dwMksys;
02332    HRESULT         hrErr;
02333
02334    if (! lpmk)
02335       return NULL;
02336
02337    if (lpmk->lpVtbl->IsSystemMoniker(lpmk, (LPDWORD)&dwMksys) == NOERROR
02338       && dwMksys == MKSYS_GENERICCOMPOSITE) {
02339
02340       /* NOTE: the moniker is a GenericCompositeMoniker.
02341       **    enumerate the moniker to pull off the first piece.
02342       */
02343
02344       hrErr = lpmk->lpVtbl->Enum(
02345             lpmk,
02346             TRUE /* fForward */,
02347             (LPENUMMONIKER FAR*)&lpenumMoniker
02348       );
02349       if (hrErr != NOERROR)
02350          return NULL;    // ERROR: give up!
02351
02352       hrErr = lpenumMoniker->lpVtbl->Next(
02353             lpenumMoniker,
02354             1,
02355             (LPMONIKER FAR*)&lpmkFirst,
02356             NULL
02357       );
02358       lpenumMoniker->lpVtbl->Release(lpenumMoniker);
02359       return lpmkFirst;
02360
02361    } else {
02362       /* NOTE: the moniker is NOT a GenericCompositeMoniker.
02363       **    return an AddRef'ed pointer to the input moniker.
02364       */
02365       lpmk->lpVtbl->AddRef(lpmk);
02366       return lpmk;
02367    }
02368 }
02369
02370
02371 /* OleStdGetLenFilePrefixOfMoniker
02372 ** -------------------------------
02373 **    if the first piece of the Moniker is a FileMoniker, then return
02374 **    the length of the filename string.
02375 **
02376 **    lpmk      pointer to moniker
02377 **
02378 **    Returns
02379 **      0       if moniker does NOT start with a FileMoniker
02380 **      uLen    string length of filename prefix of the display name
02381 **              retrieved from the given (lpmk) moniker.
02382 */
02383 STDAPI_(ULONG) OleStdGetLenFilePrefixOfMoniker(LPMONIKER lpmk)
02384 {
02385    LPMONIKER       lpmkFirst = NULL;
02386    DWORD           dwMksys;
02387    LPOLESTR        lpsz = NULL;
02388    LPBC            lpbc = NULL;
02389    ULONG           uLen = 0;
02390    HRESULT         hrErr;
02391
02392    if (! lpmk)
02393       return 0;
02394
02395    lpmkFirst = OleStdGetFirstMoniker(lpmk);
02396    if (lpmkFirst) {
02397       if ( (lpmkFirst->lpVtbl->IsSystemMoniker(
02398                      lpmkFirst, (LPDWORD)&dwMksys) == NOERROR)
02399             && dwMksys == MKSYS_FILEMONIKER) {
02400
02401          hrErr = CreateBindCtx(0, (LPBC FAR*)&lpbc);
02402          if (hrErr == NOERROR) {
02403             hrErr = lpmkFirst->lpVtbl->GetDisplayName(
02404                   lpmkFirst,
02405                   lpbc,
02406                   NULL,   /* pmkToLeft */
02407                   /*(LPOLESTR FAR*)*/&lpsz
02408             );
02409             if (hrErr == NOERROR && lpsz != NULL) {
02410                uLen = OLESTRLEN(lpsz);
02411                OleStdFreeString(lpsz, NULL);
02412             }
02413             OleStdRelease((LPUNKNOWN)lpbc);
02414          }
02415       }
02416       lpmkFirst->lpVtbl->Release(lpmkFirst);
02417    }
02418    return uLen;
02419 }
02420
02421
02422 /* OleStdMkParseDisplayName
02423 **    Parse a string into a Moniker by calling the OLE API
02424 **    MkParseDisplayName. if the original link source class was an OLE1
02425 **    class, then attempt the parsing assuming the same class applies.
02426 **
02427 **    if the class of the previous link source was an OLE1 class,
02428 **    then first attempt to parse a string that it is qualified
02429 **    with the progID associated with the OLE1 class. this more
02430 **    closely matches the semantics of OLE1 where the class of
02431 **    link sources is not expected to change. prefixing the
02432 **    string with "@<ProgID -- OLE1 class name>!" will force the
02433 **    parsing of the string to assume the file is of that
02434 **    class.
02435 **    NOTE: this trick of prepending the string with "@<ProgID>
02436 **    only works for OLE1 classes.
02437 **
02438 **  PARAMETERS:
02439 **    REFCLSID rClsid       -- original class of link source.
02440 **                              CLSID_NULL if class is unknown
02441 **    ... other parameters the same as MkParseDisplayName API ...
02442 **
02443 **  RETURNS
02444 **    NOERROR if string parsed successfully
02445 **    else error code returned by MkParseDisplayName
02446 */
02447 STDAPI OleStdMkParseDisplayName(
02448       REFCLSID        rClsid,
02449       LPBC            lpbc,
02450       LPOLESTR        lpszUserName,
02451       ULONG FAR*      lpchEaten,
02452       LPMONIKER FAR*  lplpmk
02453 )
02454 {
02455    HRESULT hrErr;
02456
02457    if (!IsEqualCLSID(rClsid,&CLSID_NULL) && CoIsOle1Class(rClsid) &&
02458       lpszUserName[0] != '@') {
02459       LPOLESTR lpszBuf;
02460       LPOLESTR lpszProgID;
02461       char     lpszAnsiBuf[256], lpszAnsiProgID[256], lpszAnsiUserName[256];
02462
02463       // Prepend "@<ProgID>!" to the input string
02464       ProgIDFromCLSID(rClsid, &lpszProgID);
02465       if (lpszProgID == NULL)
02466          goto Cont1;
02467       lpszBuf = OleStdMalloc(
02468             ((ULONG)OLESTRLEN(lpszUserName)+OLESTRLEN(lpszProgID)+3) * sizeof(OLECHAR));
02469       if (lpszBuf == NULL) {
02470          if (lpszProgID)
02471             OleStdFree(lpszProgID);
02472          goto Cont1;
02473       }
02474
02475       W2A (lpszProgID, lpszAnsiProgID, 256);
02476       W2A (lpszUserName, lpszAnsiUserName, 256);
02477       wsprintf(lpszAnsiBuf, "@%s!%s", lpszAnsiProgID, lpszAnsiUserName);
02478       A2W (lpszAnsiBuf, lpszBuf, OLESTRLEN(lpszUserName)+OLESTRLEN(lpszProgID)+3);
02479       OLEDBG_BEGIN2("MkParseDisplayName called\r\n")
02480       hrErr = MkParseDisplayName(lpbc, lpszBuf, lpchEaten, lplpmk);
02481       OLEDBG_END2
02482
02483       if (lpszProgID)
02484          OleStdFree(lpszProgID);
02485       if (lpszBuf)
02486          OleStdFree(lpszBuf);
02487
02488       if (hrErr == NOERROR)
02489          return NOERROR;
02490    }
02491
02492 Cont1:
02493    OLEDBG_BEGIN2("MkParseDisplayName called\r\n")
02494    hrErr = MkParseDisplayName(lpbc, lpszUserName, lpchEaten, lplpmk);
02495    OLEDBG_END2
02496
02497    return hrErr;
02498 }
02499
02500
02501 /*
02502  * OleStdMarkPasteEntryList
02503  *
02504  * Purpose:
02505  *  Mark each entry in the PasteEntryList if its format is available from
02506  *  the source IDataObject*. the dwScratchSpace field of each PasteEntry
02507  *  is set to TRUE if available, else FALSE.
02508  *
02509  * Parameters:
02510  *  LPOLEUIPASTEENTRY   array of PasteEntry structures
02511  *  int                 count of elements in PasteEntry array
02512  *  LPDATAOBJECT        source IDataObject* pointer
02513  *
02514  * Return Value:
02515  *   none
02516  */
02517 STDAPI_(void) OleStdMarkPasteEntryList(
02518       LPDATAOBJECT        lpSrcDataObj,
02519       LPOLEUIPASTEENTRY   lpPriorityList,
02520       int                 cEntries
02521 )
02522 {
02523    LPENUMFORMATETC     lpEnumFmtEtc = NULL;
02524    #define FORMATETC_MAX 20
02525    FORMATETC           rgfmtetc[FORMATETC_MAX];
02526    int                 i;
02527    HRESULT             hrErr;
02528    long                j, cFetched;
02529
02530    // Clear all marks
02531    for (i = 0; i < cEntries; i++) {
02532       lpPriorityList[i].dwScratchSpace = FALSE;
02533
02534       if (! lpPriorityList[i].fmtetc.cfFormat) {
02535          // caller wants this item always considered available
02536          // (by specifying a NULL format)
02537          lpPriorityList[i].dwScratchSpace = TRUE;
02538       } else if (lpPriorityList[i].fmtetc.cfFormat == cfEmbeddedObject
02539             || lpPriorityList[i].fmtetc.cfFormat == cfEmbedSource
02540             || lpPriorityList[i].fmtetc.cfFormat == cfFileName) {
02541
02542          // if there is an OLE object format, then handle it
02543          // specially by calling OleQueryCreateFromData. the caller
02544          // need only specify one object type format.
02545          OLEDBG_BEGIN2("OleQueryCreateFromData called\r\n")
02546          hrErr = OleQueryCreateFromData(lpSrcDataObj);
02547          OLEDBG_END2
02548          if(NOERROR == hrErr) {
02549             lpPriorityList[i].dwScratchSpace = TRUE;
02550          }
02551       } else if (lpPriorityList[i].fmtetc.cfFormat == cfLinkSource) {
02552
02553          // if there is OLE 2.0 LinkSource format, then handle it
02554          // specially by calling OleQueryLinkFromData.
02555          OLEDBG_BEGIN2("OleQueryLinkFromData called\r\n")
02556          hrErr = OleQueryLinkFromData(lpSrcDataObj);
02557          OLEDBG_END2
02558          if(NOERROR == hrErr) {
02559             lpPriorityList[i].dwScratchSpace = TRUE;
02560          }
02561       }
02562    }
02563
02564    OLEDBG_BEGIN2("IDataObject::EnumFormatEtc called\r\n")
02565    hrErr = lpSrcDataObj->lpVtbl->EnumFormatEtc(
02566          lpSrcDataObj,
02567          DATADIR_GET,
02568          (LPENUMFORMATETC FAR*)&lpEnumFmtEtc
02569    );
02570    OLEDBG_END2
02571
02572    if (hrErr != NOERROR)
02573       return;    // unable to get format enumerator
02574
02575    // Enumerate the formats offered by the source
02576    // Loop over all formats offered by the source
02577    cFetched = 0;
02578    _fmemset(rgfmtetc,0,FORMATETC_MAX*sizeof(FORMATETC));
02579    if (lpEnumFmtEtc->lpVtbl->Next(
02580          lpEnumFmtEtc, FORMATETC_MAX, rgfmtetc, &cFetched) == NOERROR
02581       || (cFetched > 0 && cFetched <= FORMATETC_MAX) )
02582    {
02583
02584       for (j = 0; j < cFetched; j++)
02585       {
02586          for (i = 0; i < cEntries; i++)
02587          {
02588             if (! lpPriorityList[i].dwScratchSpace &&
02589                IsCloseFormatEtc(&rgfmtetc[j], &lpPriorityList[i].fmtetc))
02590             {
02591                lpPriorityList[i].dwScratchSpace = TRUE;
02592             }
02593          }
02594       }
02595    } // endif
02596
02597    // Clean up
02598    if (lpEnumFmtEtc)
02599       OleStdRelease((LPUNKNOWN)lpEnumFmtEtc);
02600 }
02601
02602
02603 /* OleStdGetPriorityClipboardFormat
02604 ** --------------------------------
02605 **
02606 **    Retrieve the first clipboard format in a list for which data
02607 **    exists in the source IDataObject*.
02608 **
02609 **    Returns -1 if no acceptable match is found.
02610 **            index of first acceptable match in the priority list.
02611 **
02612 */
02613 STDAPI_(int) OleStdGetPriorityClipboardFormat(
02614       LPDATAOBJECT        lpSrcDataObj,
02615       LPOLEUIPASTEENTRY   lpPriorityList,
02616       int                 cEntries
02617 )
02618 {
02619    int i;
02620    int nFmtEtc = -1;
02621
02622    // Mark all entries that the Source provides
02623    OleStdMarkPasteEntryList(lpSrcDataObj, lpPriorityList, cEntries);
02624
02625    // Loop over the target's priority list of formats
02626    for (i = 0; i < cEntries; i++)
02627    {
02628       if (lpPriorityList[i].dwFlags != OLEUIPASTE_PASTEONLY &&
02629             !(lpPriorityList[i].dwFlags & OLEUIPASTE_PASTE))
02630          continue;
02631
02632       // get first marked entry
02633       if (lpPriorityList[i].dwScratchSpace) {
02634          nFmtEtc = i;
02635          break;          // Found priority format; DONE
02636       }
02637    }
02638
02639    return nFmtEtc;
02640 }
02641
02642
02643 /* OleStdIsDuplicateFormat
02644 ** -----------------------
02645 **    Returns TRUE if the lpFmtEtc->cfFormat is found in the array of
02646 **    FormatEtc structures.
02647 */
02648 STDAPI_(BOOL) OleStdIsDuplicateFormat(
02649       LPFORMATETC         lpFmtEtc,
02650       LPFORMATETC         arrFmtEtc,
02651       int                 nFmtEtc
02652 )
02653 {
02654    int i;
02655
02656    for (i = 0; i < nFmtEtc; i++) {
02657       if (IsEqualFORMATETC((*lpFmtEtc), arrFmtEtc[i]))
02658          return TRUE;
02659    }
02660
02661    return FALSE;
02662 }
02663
02664
02665 /* OleStdGetItemToken
02666  * ------------------
02667  *
02668  * LPSTR lpszSrc - Pointer to a source string
02669  * LPSTR lpszDst - Pointer to destination buffer
02670  *
02671  * Will copy one token from the lpszSrc buffer to the lpszItem buffer.
02672  * It considers all alpha-numeric and white space characters as valid
02673  * characters for a token. the first non-valid character delimates the
02674  * token.
02675  *
02676  * returns the number of charaters eaten.
02677  */
02678 STDAPI_(ULONG) OleStdGetItemToken(LPOLESTR lpszSrc, LPOLESTR lpszDst, int nMaxChars)
02679 {
02680    ULONG chEaten = 0L;
02681    char szAnsiSrc[256], szAnsiDst[256];
02682    LPSTR lpszAnsiDst = szAnsiDst;
02683    LPSTR lpszAnsiSrc = szAnsiSrc;
02684
02685    W2A (lpszSrc, szAnsiSrc, 256);
02686
02687    // skip leading delimeter characters
02688    while (*lpszAnsiSrc && --nMaxChars > 0
02689                         && ((*lpszAnsiSrc=='/') || (*lpszAnsiSrc=='\\') ||
02690                            (*lpszAnsiSrc=='!') || (*lpszAnsiSrc==':'))) {
02691       *lpszAnsiSrc++;
02692       chEaten++;
02693    }
02694
02695    // Extract token string (up to first delimeter char or EOS)
02696    while (*lpszAnsiSrc && --nMaxChars > 0
02697                         && !((*lpszAnsiSrc=='/') || (*lpszAnsiSrc=='\\') ||
02698                            (*lpszAnsiSrc=='!') || (*lpszAnsiSrc==':'))) {
02699       *lpszAnsiDst++ = *lpszAnsiSrc++;
02700       chEaten++;
02701    }
02702    *lpszAnsiDst = '\0';
02703
02704    A2W (szAnsiDst, lpszDst, OLEUI_CCHPATHMAX);
02705    return chEaten;
02706 }
02707
02708 /*************************************************************************
02709 ** OleStdCreateRootStorage
02710 **    create a root level Storage given a filename that is compatible
02711 **    to be used by a top-level OLE container. if the filename
02712 **    specifies an existing file, then an error is returned.
02713 **    the root storage (Docfile) that is created by this function
02714 **    is suitable to be used to create child storages for embedings.
02715 **    (CreateChildStorage can be used to create child storages.)
02716 **    NOTE: the root-level storage is opened in transacted mode.
02717 *************************************************************************/
02718
02719 STDAPI_(LPSTORAGE) OleStdCreateRootStorage(LPOLESTR lpszStgName, DWORD grfMode)
02720 {
02721    HRESULT hr;
02722    DWORD grfCreateMode = STGM_READWRITE | STGM_TRANSACTED;
02723    DWORD reserved = 0;
02724    LPSTORAGE lpRootStg;
02725    char szMsg[64];
02726
02727    // if temp file is being created, enable delete-on-release
02728    if (! lpszStgName)
02729       grfCreateMode |= STGM_DELETEONRELEASE;
02730
02731    hr = StgCreateDocfile(
02732          lpszStgName,
02733          grfMode | grfCreateMode,
02734          reserved,
02735          (LPSTORAGE FAR*)&lpRootStg
02736       );
02737
02738    if (hr == NOERROR)
02739       return lpRootStg;               // existing file successfully opened
02740
02741    OleDbgOutHResult("StgCreateDocfile returned", hr);
02742
02743    if (0 == LoadString(ghInst, (UINT)IDS_OLESTDNOCREATEFILE, /*(LPSTR)*/szMsg, 64))
02744      return NULL;
02745
02746    MessageBox(NULL, /*(LPSTR)*/szMsg, NULL,MB_ICONEXCLAMATION | MB_OK);
02747    return NULL;
02748 }
02749
02750
02751 /*************************************************************************
02752 ** OleStdOpenRootStorage
02753 **    open a root level Storage given a filename that is compatible
02754 **    to be used by a top-level OLE container. if the file does not
02755 **    exist then an error is returned.
02756 **    the root storage (Docfile) that is opened by this function
02757 **    is suitable to be used to create child storages for embedings.
02758 **    (CreateChildStorage can be used to create child storages.)
02759 **    NOTE: the root-level storage is opened in transacted mode.
02760 *************************************************************************/
02761
02762 STDAPI_(LPSTORAGE) OleStdOpenRootStorage(LPOLESTR lpszStgName, DWORD grfMode)
02763 {
02764    HRESULT hr;
02765    DWORD reserved = 0;
02766    LPSTORAGE lpRootStg;
02767    char  szMsg[64];
02768
02769    if (lpszStgName) {
02770
02771       hr = StgOpenStorage(
02772             lpszStgName,
02773             NULL,
02774             grfMode | STGM_TRANSACTED,
02775             NULL,
02776             reserved,
02777             (LPSTORAGE FAR*)&lpRootStg
02778          );
02779
02780       if (hr == NOERROR)
02781          return lpRootStg;     // existing file successfully opened
02782
02783       OleDbgOutHResult("StgOpenStorage returned", hr);
02784    }
02785
02786    if (0 == LoadString(ghInst, (UINT)IDS_OLESTDNOOPENFILE, szMsg, 64))
02787      return NULL;
02788
02789    MessageBox(NULL, /*(LPSTR)*/szMsg, NULL,MB_ICONEXCLAMATION | MB_OK);
02790    return NULL;
02791 }
02792
02793
02794 /*************************************************************************
02795 ** OpenOrCreateRootStorage
02796 **    open a root level Storage given a filename that is compatible
02797 **    to be used by a top-level OLE container. if the filename
02798 **    specifies an existing file, then it is open, otherwise a new file
02799 **    with the given name is created.
02800 **    the root storage (Docfile) that is created by this function
02801 **    is suitable to be used to create child storages for embedings.
02802 **    (CreateChildStorage can be used to create child storages.)
02803 **    NOTE: the root-level storage is opened in transacted mode.
02804 *************************************************************************/
02805
02806 STDAPI_(LPSTORAGE) OleStdOpenOrCreateRootStorage(LPOLESTR lpszStgName, DWORD grfMode)
02807 {
02808    HRESULT hrErr;
02809    SCODE sc;
02810    DWORD reserved = 0;
02811    LPSTORAGE lpRootStg;
02812    char      szMsg[64];
02813
02814    if (lpszStgName) {
02815
02816       hrErr = StgOpenStorage(
02817             lpszStgName,
02818             NULL,
02819             grfMode | STGM_READWRITE | STGM_TRANSACTED,
02820             NULL,
02821             reserved,
02822             (LPSTORAGE FAR*)&lpRootStg
02823       );
02824
02825       if (hrErr == NOERROR)
02826          return lpRootStg;      // existing file successfully opened
02827
02828       OleDbgOutHResult("StgOpenStorage returned", hrErr);
02829       sc = hrErr;
02830
02831       if (sc!=STG_E_FILENOTFOUND && sc!=STG_E_FILEALREADYEXISTS) {
02832          return NULL;
02833       }
02834    }
02835
02836    /* if file did not already exist, try to create a new one */
02837    hrErr = StgCreateDocfile(
02838          lpszStgName,
02839          grfMode | STGM_READWRITE | STGM_TRANSACTED,
02840          reserved,
02841          (LPSTORAGE FAR*)&lpRootStg
02842    );
02843
02844    if (hrErr == NOERROR)
02845       return lpRootStg;               // existing file successfully opened
02846
02847    OleDbgOutHResult("StgCreateDocfile returned", hrErr);
02848
02849    if (0 == LoadString(ghInst, (UINT)IDS_OLESTDNOCREATEFILE, /*(LPSTR)*/szMsg, 64))
02850      return NULL;
02851
02852    MessageBox(NULL, /*(LPSTR)*/szMsg, NULL, MB_ICONEXCLAMATION | MB_OK);
02853    return NULL;
02854 }
02855
02856
02857 /*
02858 ** OleStdCreateChildStorage
02859 **    create a child Storage inside the given lpStg that is compatible
02860 **    to be used by an embedded OLE object. the return value from this
02861 **    function can be passed to OleCreateXXX functions.
02862 **    NOTE: the child storage is opened in transacted mode.
02863 */
02864 STDAPI_(LPSTORAGE) OleStdCreateChildStorage(LPSTORAGE lpStg, LPOLESTR lpszStgName)
02865 {
02866    if (lpStg != NULL) {
02867       LPSTORAGE lpChildStg;
02868       DWORD grfMode = (STGM_READWRITE | STGM_TRANSACTED |
02869             STGM_SHARE_EXCLUSIVE);
02870       DWORD reserved = 0;
02871
02872       HRESULT hrErr = lpStg->lpVtbl->CreateStorage(
02873             lpStg,
02874             lpszStgName,
02875             grfMode,
02876             reserved,
02877             reserved,
02878             (LPSTORAGE FAR*)&lpChildStg
02879          );
02880
02881       if (hrErr == NOERROR)
02882          return lpChildStg;
02883
02884       OleDbgOutHResult("lpStg->lpVtbl->CreateStorage returned", hrErr);
02885    }
02886    return NULL;
02887 }
02888
02889
02890 /*
02891 ** OleStdOpenChildStorage
02892 **    open a child Storage inside the given lpStg that is compatible
02893 **    to be used by an embedded OLE object. the return value from this
02894 **    function can be passed to OleLoad function.
02895 **    NOTE: the child storage is opened in transacted mode.
02896 */
02897 STDAPI_(LPSTORAGE) OleStdOpenChildStorage(LPSTORAGE lpStg, LPOLESTR lpszStgName, DWORD grfMode)
02898 {
02899    LPSTORAGE lpChildStg;
02900    LPSTORAGE lpstgPriority = NULL;
02901    DWORD reserved = 0;
02902    HRESULT hrErr;
02903
02904    if (lpStg  != NULL) {
02905
02906       hrErr = lpStg->lpVtbl->OpenStorage(
02907             lpStg,
02908             lpszStgName,
02909             lpstgPriority,
02910             grfMode | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
02911             NULL,
02912             reserved,
02913             (LPSTORAGE FAR*)&lpChildStg
02914          );
02915
02916       if (hrErr == NOERROR)
02917          return lpChildStg;
02918
02919       OleDbgOutHResult("lpStg->lpVtbl->OpenStorage returned", hrErr);
02920    }
02921    return NULL;
02922 }
02923
02924
02925 /* OleStdCommitStorage
02926 ** -------------------
02927 **    Commit the changes to the given IStorage*. This routine can be
02928 **    called on either a root-level storage as used by an OLE-Container
02929 **    or by a child storage as used by an embedded object.
02930 **
02931 **    This routine first attempts to perform this commit in a safe
02932 **    manner. if this fails it then attempts to do the commit in a less
02933 **    robust manner (STGC_OVERWRITE).
02934 */
02935 STDAPI_(BOOL) OleStdCommitStorage(LPSTORAGE lpStg)
02936 {
02937    HRESULT hrErr;
02938
02939    // make the changes permanent
02940    hrErr = lpStg->lpVtbl->Commit(lpStg, 0);
02941
02942    if (hrErr == STG_E_MEDIUMFULL) {
02943       // try to commit changes in less robust manner.
02944       OleDbgOut("Warning: commiting with STGC_OVERWRITE specified\n");
02945       hrErr = lpStg->lpVtbl->Commit(lpStg, STGC_OVERWRITE);
02946    }
02947
02948    if (hrErr != NOERROR)
02949    {
02950       char szMsg[64];
02951
02952       if (0 == LoadString(ghInst, (UINT)IDS_OLESTDDISKFULL, /*(LPSTR)*/szMsg, 64))
02953          return FALSE;
02954
02955       MessageBox(NULL, /*(LPSTR)*/szMsg, NULL, MB_ICONEXCLAMATION | MB_OK);
02956       return FALSE;
02957    }
02958    else {
02959       return TRUE;
02960    }
02961 }
02962
02963
02964 /* OleStdDestroyAllElements
02965 ** ------------------------
02966 **    Destroy all elements within an open storage. this is subject
02967 **    to the current transaction.
02968 */
02969 STDAPI OleStdDestroyAllElements(LPSTORAGE lpStg)
02970 {
02971    IEnumSTATSTG FAR* lpEnum;
02972    STATSTG sstg;
02973    HRESULT hrErr;
02974
02975    hrErr = lpStg->lpVtbl->EnumElements(
02976          lpStg, 0, NULL, 0, (IEnumSTATSTG FAR* FAR*)&lpEnum);
02977
02978    if (hrErr != NOERROR)
02979       return hrErr;
02980
02981    while (1) {
02982       if (lpEnum->lpVtbl->Next(lpEnum, 1, &sstg, NULL) != NOERROR)
02983          break;
02984       lpStg->lpVtbl->DestroyElement(lpStg, sstg.pwcsName);
02985       OleStdFree(sstg.pwcsName);
02986    }
02987    lpEnum->lpVtbl->Release(lpEnum);
02988    return NOERROR;
02989 }
02990
02991 // returns 1 for a close match
02992 //  (all fields match exactly except the tymed which simply overlaps)
02993 // 0 for no match
02994
02995 int IsCloseFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight)
02996 {
02997         if (pFetcLeft->cfFormat != pFetcRight->cfFormat)
02998                 return 0;
02999         else if (!OleStdCompareTargetDevice (pFetcLeft->ptd, pFetcRight->ptd))
03000                 return 0;
03001         if (pFetcLeft->dwAspect != pFetcRight->dwAspect)
03002                 return 0;
03003         return((pFetcLeft->tymed | pFetcRight->tymed) != 0);
03004 }
03005
03006
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DiskCleanupHandler/ClassFactory.Cpp Source File

  • WinUI
  • Shell
  • DiskCleanupHandler

ClassFactory.Cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  ClassFactory.cpp
00011 //
00012 //      Implementation of the CClassFactory class.
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #include "Cleanup.h"
00017 #include "ClassFactory.h"
00018 #include "EmptyVolumeCache.h"
00019
00020
00021 //////////////////////////////////////////////////////////////////////
00022 // Construction/Destruction
00023 //////////////////////////////////////////////////////////////////////
00024
00025 CClassFactory::CClassFactory()
00026 {
00027     m_nRefCount = 0;
00028     nDllRefCount++;
00029 }
00030
00031 CClassFactory::~CClassFactory()
00032 {
00033     nDllRefCount--;
00034 }
00035
00036 /////////////////////////////////////////////////////////////////////
00037 //  IUnknown Methods
00038 /////////////////////////////////////////////////////////////////////
00039 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppvObject)
00040 {
00041     HRESULT hr = E_NOINTERFACE;
00042
00043     *ppvObject = NULL;
00044     if (IsEqualIID (riid, IID_IUnknown) || IsEqualIID (riid, IID_IClassFactory))
00045     {
00046         *ppvObject = (LPVOID)(LPCLASSFACTORY) this;
00047     }
00048
00049     if (*ppvObject != NULL)
00050     {
00051         ((LPUNKNOWN)*ppvObject)->AddRef ();
00052         hr = S_OK;
00053     }
00054     return hr;
00055 }
00056
00057 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00058 {
00059     m_nRefCount++;
00060     return m_nRefCount;
00061 }
00062
00063 STDMETHODIMP_(ULONG) CClassFactory::Release()
00064 {
00065     if (--m_nRefCount == 0)
00066     {
00067         delete this;
00068         return 0;
00069     }
00070     return m_nRefCount;
00071 }
00072
00073 /////////////////////////////////////////////////////////////////////
00074 //  IClassFactory Methods
00075 /////////////////////////////////////////////////////////////////////
00076 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
00077 {
00078     *ppvObject = NULL;
00079     if (pUnkOuter)
00080     {
00081         return CLASS_E_NOAGGREGATION;
00082     }
00083
00084     CEmptyVolumeCache *pevc = new CEmptyVolumeCache;
00085     if (!pevc)
00086     {
00087         return E_OUTOFMEMORY;
00088     }
00089
00090     HRESULT hResult = pevc->QueryInterface (riid, ppvObject);
00091     if (FAILED(hResult))
00092     {
00093         delete pevc;
00094         *ppvObject = NULL;
00095     }
00096     return hResult;
00097 }
00098
00099 STDMETHODIMP CClassFactory::LockServer (BOOL bLock)
00100 {
00101     return S_OK;
00102 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/Snd/StdAfx.h Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • Snd

StdAfx.h

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <tchar.h>
00003 #include <comdef.h>
00004 #include <objbase.h>
00005 #include <stdio.h>
00006 #include <iostream.h>
00007 #include "../GraphObj/GraphObj_i.c" // For IID_IPoint and IID_ILine
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Pipes/Include/pipesample.Idl Source File

  • Com
  • Fundamentals
  • Pipes
  • Include

pipesample.Idl

Go to the documentation of this file.
00001 import "unknwn.idl";
00002 import "objidl.idl";
00003
00004 // interface definition
00005
00006 [ object,
00007   uuid(cc603a56-d9ad-11d2-86a3-00c04f8ef940),
00008   pointer_default(unique) ]
00009
00010 interface ISimpleInterface : IUnknown
00011 {
00012     HRESULT InPipeSample([in] IPipeLong *pPipe);
00013     HRESULT OutPipeSample([out] IPipeLong **ppPipe);
00014     HRESULT InOutPipeSample([in, out] IPipeLong **ppPipe);
00015     HRESULT InInOutPipesSample([in] IPipeLong *pPipe1, [in] IPipeLong *pPipe2,
00016                                [out] IPipeLong **ppPipe3);
00017 }
00018
00019 // library definition
00020 [
00021          uuid(74c4b0f0-d9ae-11d2-86a3-00c04f8ef940),
00022          helpstring("Pipes Sample Library"),
00023          version(1)
00024 ]
00025 library SimpleLib
00026 {
00027    importlib("stdole2.tlb");
00028
00029    // Class definition
00030    [
00031          uuid(84f2059a-d9ae-11d2-86a3-00c04f8ef940),
00032          helpstring("Simple class")
00033    ]
00034    coclass SimpleClass
00035    {
00036       [default] interface ISimpleInterface;
00037    };
00038 };
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/Debug.Hxx Source File

  • WinBase
  • Indexing
  • IFilter

Debug.Hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       debug.hxx
00006 //
00007 //  Contents:   Debugging macros
00008 //
00009 //----------------------------------------------------------------------------
00010
00011 #ifndef __DEBUG_HXX__
00012 #define __DEBUG_HXX__
00013
00014 #if DBG == 1
00015
00016 #include <stdio.h>
00017 #include <stdarg.h>
00018
00019 # define Win4Assert(x)  \
00020         (void)((x) || (Win4AssertEx(__FILE__, __LINE__, #x),0))
00021
00022 void Win4AssertEx( char const * szFile, int iLine, char const * szMessage);
00023
00024
00025 #define DEB_ERROR     0x00000001      // exported error paths
00026 #define DEB_WARN      0x00000002      // exported warnings
00027 #define DEB_TRACE     0x00000004      // exported trace messages
00028
00029 #define DEB_IERROR    0x00000100      // internal error paths
00030 #define DEB_IWARN     0x00000200      // internal warnings
00031 #define DEB_ITRACE    0x00000400      // internal trace messages
00032
00033
00034 #define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
00035
00036 #define DECLARE_INFOLEVEL(comp) \
00037         extern unsigned long comp##InfoLevel = DEF_INFOLEVEL;
00038
00039 #define DECLARE_DEBUG(comp) \
00040     extern unsigned long comp##InfoLevel; \
00041     _inline void \
00042     comp##InlineDebugOut(unsigned long fDebugMask, char *pszfmt, ...) \
00043     { \
00044         if (comp##InfoLevel & fDebugMask) \
00045         { \
00046             char acsString[120];\
00047             va_list va; \
00048             va_start(va, pszfmt);\
00049             vsprintf(acsString, pszfmt, va); \
00050             va_end(va);\
00051             OutputDebugStringA(acsString);\
00052         } \
00053     }
00054
00055 #else  // DBG == 0
00056
00057 #define Win4Assert(x)
00058 #define DECLARE_DEBUG(comp)
00059 #define DECLARE_INFOLEVEL(comp)
00060
00061 #endif // DBG == 0
00062
00063 #endif // __DEBUG_HXX__
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/list.h Source File

  • Begin
  • sdkdiff

list.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 #ifndef __LIST_H__
00012 #define __LIST_H__
00013                    /*----------------------
00014                    |         List          |
00015                     ----------------------*/
00016
00017 /* worth also looking at nt\public\sdk\inc\ntrtl.h which also has some
00018 |  low level list pointer chaining stuff in it
00019 */
00020 /* Note here that Modula-2 style comments (*like this*) are used
00021    within examples which are already within C comments to indicate
00022    where comments should go in the examples
00023 */
00024
00025 /*------------------------------------------------------------------------
00026 | Abstract data type LIST OF (*untyped*) object.
00027 | Different lists can have different types of object in them
00028 | Different items in a list can have different types of object in them.
00029 | The price of this lack of typing is that you have a slightly more
00030 | awkward syntax and you get no help from the compiler if you try to
00031 | put the wrong type of data into the list.
00032 |
00033 | The list is implemented as a collection of items.  Within the item
00034 | somewhere is the object.
00035 |
00036 | Objects are stored UNALIGNED within items.
00037 |
00038 | Use:
00039 |
00040 |   #include <list.h>
00041 |   . . .
00042 |   LIST MyList; (* or LIST liMyList for Hungarians *)
00043 |   . . .
00044 |   MyList = List_Create();
00045 |   List_AddLast(MyList,&MyObject,sizeof(OBJECT));
00046 |
00047 | In the abstract a LIST is a list of objects.  The representation
00048 | is a linked collection of items.  The manner of the linking is
00049 | implementation dependent (as I write this it's linear but when you
00050 | read it it might be a tree (See Knuth for why a tree)).
00051 |
00052 | A LIST is a "handle" for a list which may be thought of as a POINTER
00053 | (whether it is really a pointer or not is implementation dependent)
00054 | so that it can be copied at the risk of creating an alias. e.g.
00055 |
00056 |   L = List_Create();
00057 |   L1 = L;             (* L and L1 are both healthy and empty *)
00058 |   List_AddFirst(L, &elem, sizeof(elem));
00059 |   (* L1 may also appear to have one object, there again it may be sick *)
00060 |   L1 = L;               (* Now they both surely see the one element *)
00061 |   List_Destroy(&L1);    (* L is almost certainly sick now too *)
00062 |   L1 = List_Create();   (* All bets off as to what L is like now
00063 |                            but L1 is empty and healthy
00064 |                         *)
00065 |
00066 | If two handles compare equal then the lists must be equal, but
00067 | unequal handles could address two similar lists i.e. the same list
00068 | of objects held in two different LISTs of items (like pointers).
00069 |
00070 | A LIST can be transferred from one variable to another like this:
00071 |
00072 |   NewList = OldList;           (* copy the handle *)
00073 |   OldList = List_Create();     (* kill the old alias *)
00074 |
00075 | and the Create statement can be omitted if OldList is never touched again.
00076 |
00077 | Items are identified by Cursors.  A cursor is the address of an object
00078 | within an item in the list. i.e. it is the address of the piece of your
00079 | data that you had inserted.  (It is probably NOT the address of the item).
00080 | It is typed as pointer to void here, but you should declare it as a pointer
00081 | to whatever sort of object you are putting in the LIST.
00082 |
00083 | The operations AddFirst, AddLast, AddAfter and AddBefore
00084 | all copy elements by direct assignment.  If an element is itself
00085 | a complex structure (say a tree) then this will only copy a pointer
00086 | or an anchor block or whatever and give all the usual problems of
00087 | aliases.  Clear will make the list empty, but will only free the
00088 | storage that it can "see" directly.  SplitBefore or Split After may
00089 | also perform a Clear operation.  To deal with fancy data structures
00090 | use New rather than Add calls and copy the data yourself
00091 |   e.g.  P = List_NewLast(MyList, sizeof(MyArray[14])*(23-14+1));
00092 |         CopyArraySlice(P, MyArray, 14, 23);
00093 |
00094 | The operations NewFirst, NewLast, NewAfter, NewBefore, First and Last
00095 | all return pointers to elements and thus allow you to do any copying.
00096 | This is how you might copy a whole list of fancy structures:
00097 |
00098 |    void CopyFancyList(LIST * To, LIST From)
00099 |             (* Assumes that To has been Created and is empty *)
00100 |    { PELEMENT Cursor;
00101 |      PELEMENT P;
00102 |
00103 |      List_TRAVERSE(From, Cursor);
00104 |      { P = List_NewLast(To, sizeof(element) );
00105 |        FancyCopy(P, Cursor);    (* Copy so that *Cursor==*P afterwords *)
00106 |      }
00107 |    }
00108  --------------------------------------------------------------------*/
00109
00110   typedef struct item_tag FAR * LIST;
00111   typedef LIST FAR * PLIST;
00112
00113   void APIENTRY List_Init(void);
00114   /* MUST BE CALLED BEFORE ANY OF THE OTHER FUNCTIONS. Don't ask, just do it */
00115
00116   void APIENTRY List_Term(void);
00117   /* Call at end of application (does some checking and resource freeing) */
00118
00119   void APIENTRY List_Dump(LPSTR Header, LIST lst);
00120   /* Dump the internals to current output stream -- debug only */
00121
00122   void APIENTRY List_Show(LIST lst);
00123   /* Dump hex representation of handle to current out stream -- debug only */
00124
00125   LIST APIENTRY List_Create(void);
00126   /* Create a list.  It will be initially empty */
00127
00128   void APIENTRY List_Destroy(PLIST plst);
00129   /* Destroy *plst.  It does not need to be empty first.
00130   |  All storage directly in the list wil be freed.
00131   */
00132
00133   void APIENTRY List_AddFirst(LIST lst, LPVOID pObject, UINT uLen);
00134   /* Add an item holding Object to the beginning of * plst */
00135
00136   LPVOID APIENTRY List_NewFirst(LIST lst, UINT uLen);
00137   /* Return the address of the place for Len bytes of data in a new
00138   |  item at the start of *plst.
00139   |  The storage is zeroed BEFORE chaining it in.
00140   */
00141
00142   void APIENTRY List_DeleteFirst(LIST lst);
00143   /* Delete the first item in lst.  Error if lst is empty */
00144
00145   void APIENTRY List_AddLast(LIST lst, LPVOID pObject, UINT uLen);
00146   /* Add an item holding Object to the end of lst */
00147
00148   LPVOID APIENTRY List_NewLast(LIST lst, UINT uLen);
00149   /* Return the address of the place for uLen bytes of data in a new
00150   |  item at the end of lst
00151   |  The storage is zeroed BEFORE chaining it in.
00152   */
00153
00154   void APIENTRY List_DeleteLast(LIST lst);
00155   /* Delete the last item in lst.  Error if lst is empty */
00156
00157   void APIENTRY List_AddAfter( LIST lst
00158                     , LPVOID Curs
00159                     , LPVOID pObject
00160                     , UINT uLen
00161                     );
00162   /*--------------------------------------------------------------------
00163   | Add an item holding *pObject to lst immediately after Curs.
00164   | List_AddAfter(lst, NULL, pObject, Len) adds it to the start of the lst
00165    ---------------------------------------------------------------------*/
00166
00167   LPVOID APIENTRY List_NewAfter(LIST lst, LPVOID Curs, UINT uLen);
00168   /*--------------------------------------------------------------------
00169   | Return the address of the place for uLen bytes of data in a new
00170   | item immediately after Curs.
00171   | List_NewAfter(Lst, NULL, uLen) returns a pointer
00172   | to space for uLen bytes in a new first element.
00173   | The storage is zeroed BEFORE chaining it in.
00174    ---------------------------------------------------------------------*/
00175
00176   void APIENTRY List_AddBefore( LIST lst
00177                      , LPVOID Curs
00178                      , LPVOID pObject
00179                      , UINT uLen
00180                      );
00181   /*--------------------------------------------------------------------
00182   | Add an item holding Object to lst immediately before Curs.
00183   | List_AddBefore(Lst, NULL, Object, uLen) adds it to the end of the list
00184    ---------------------------------------------------------------------*/
00185
00186   LPVOID APIENTRY List_NewBefore(LIST lst, LPVOID Curs, UINT uLen );
00187   /*--------------------------------------------------------------------
00188   | Return the address of the place for uLen bytes of data in a new
00189   | item immediately before Curs.
00190   | List_NewBefore(Lst, NULL, uLen) returns a pointer
00191   | to space for uLen bytes in a new last element.
00192   | The storage is zeroed BEFORE chaining it in.
00193    ---------------------------------------------------------------------*/
00194
00195 #if 0
00196 // these functions are not actually defined...
00197
00198   void APIENTRY List_DeleteAndNext(LPVOID * pCurs);
00199   /* Delete the item that *pCurs identifies and move *pCurs to the Next item */
00200
00201   void APIENTRY List_DeleteAndPrev(LPVOID * pCurs);
00202   /* Delete the item that *pCurs identifies and move *pCurs to the Prev item */
00203 #endif
00204
00205   void APIENTRY List_Delete(LPVOID Curs);
00206   /*------------------------------------------------------------------
00207   | Delete the item that Curs identifies.
00208   | I'm not too sure about this:
00209   | This will be only a few (maybe as little as 3) machine instructions
00210   | quicker than DeleteAndNext or DeleteAndPrev but leaves Curs dangling.
00211   | It is therefore NOT usually to be preferred.
00212   | It may be useful when you have a function which returns an LPVOID
00213   | since the argument does not need to be a variable.
00214   |     Trivial example: List_Delete(List_First(L));
00215   | I am not sure which is more damaging, a dangling pointer which points
00216   | at garbage or one that points at something that is real live data.
00217    -------------------------------------------------------------------*/
00218
00219   int APIENTRY List_ItemLength(LPVOID Curs);
00220   /* Return the length of the object identified by the cursor Curs */
00221
00222   /*------------------------------------------------------------------
00223   | TRAVERSING THE ULIST
00224   |
00225   | LIST lst;
00226   | object * Curs;
00227   | . . .
00228   | Curs = List_First(lst);
00229   | while (Curs!=NULL)
00230   | {  DoSomething(*Curs);   (* Curs points to YOUR data not to chain ptrs *)
00231   |    Curs = List_Next(Curs);
00232   | }
00233   |
00234   | This is identically equal to
00235   | List_TRAVERSE(lst, Curs)  // note NO SEMI COLON!
00236   | {  DoSomething(*Curs); }
00237    -------------------------------------------------------------------*/
00238
00239   #define List_TRAVERSE(lst, curs)  for(  curs=List_First(lst)            \
00240                                        ;  curs!=NULL                      \
00241                                        ;  curs = List_Next((LPVOID)curs)  \
00242                                        )
00243   #define List_REVERSETRAVERSE(lst, curs)  for(  curs=List_Last(lst)             \
00244                                               ;  curs!=NULL                      \
00245                                               ;  curs = List_Prev((LPVOID)curs)  \
00246                                               )
00247
00248   LPVOID APIENTRY List_First(LIST lst);
00249   /*------------------------------------------------------------------
00250   | Return the address of the first object in lst
00251   |  If lst is empty then Return NULL.
00252   --------------------------------------------------------------------*/
00253
00254   LPVOID APIENTRY List_Last(LIST lst);
00255   /*------------------------------------------------------------------
00256   | Return the address of the last object in lst
00257   | If lst is empty then return NULL.
00258   --------------------------------------------------------------------*/
00259
00260   LPVOID APIENTRY List_Next(LPVOID Curs);
00261   /*------------------------------------------------------------------
00262   | Return the address of the object after Curs^.
00263   | List_Next(List_Last(lst)) == NULL;  List_Next(NULL) is an error.
00264   | List_Next(List_Prev(curs)) is illegal if curs identifies first el
00265   --------------------------------------------------------------------*/
00266
00267   LPVOID APIENTRY List_Prev(LPVOID Curs);
00268   /*------------------------------------------------------------------
00269   | Return the address of the object after Curs^.
00270   | List_Prev(List_First(L)) == NULL;  List_Prev(NULL) is an error.
00271   | List_Prev(List_Next(curs)) is illegal if curs identifies last el
00272   --------------------------------------------------------------------*/
00273
00274   /*------------------------------------------------------------------
00275   |  Whole list operations
00276    -----------------------------------------------------------------*/
00277   void APIENTRY List_Clear(LIST lst);
00278   /* arrange that lst is empty after this */
00279
00280   BOOL APIENTRY List_IsEmpty(LIST lst);
00281   /* Return TRUE if and only if lst is empty */
00282
00283   void APIENTRY List_Join(LIST l1, LIST l2);
00284   /*-----------------------------------------------------------------------
00285   | l1 := l1||l2; l2 := empty
00286   | The elements themselves are not moved, so pointers to them remain valid.
00287   |
00288   | l1 gets all the elements of l1 in their original order followed by
00289   | all the elements of l2 in the order they were in in l2.
00290   | l2 becomes empty.
00291    ------------------------------------------------------------------------*/
00292
00293   void APIENTRY List_InsertListAfter(LIST l1, LIST l2, LPVOID Curs);
00294   /*-----------------------------------------------------------------------
00295   | l1 := l1[...Curs] || l2 || l1[Curs+1...]; l2 := empty
00296   | Curs=NULL means insert l2 at the start of l1
00297   | The elements themselves are not moved, so pointers to them remain valid.
00298   |
00299   | l1 gets the elements of l1 from the start up to and including the element
00300   | that Curs points at, in their original order,
00301   | followed by all the elements that were in l2, in their original order,
00302   | followed by the rest of l1
00303    ------------------------------------------------------------------------*/
00304
00305   void APIENTRY List_InsertListBefore(LIST l1, LIST l2, LPVOID Curs);
00306   /*-----------------------------------------------------------------------
00307   | l1 := l1[...Curs-1] || l2 || l1[Curs...]; l2 := empty
00308   | Curs=NULL means insert l2 at the end of l1
00309   | The elements themselves are not moved, so pointers to them remain valid.
00310   |
00311   | l1 gets the elements of l1 from the start up to but not including the
00312   | element that Curs points at, in their original order,
00313   | followed by all the elements that were in l2, in their original order,
00314   | followed by the rest of l1.
00315    ------------------------------------------------------------------------*/
00316
00317   void APIENTRY List_SplitAfter(LIST l1, LIST l2, LPVOID Curs);
00318   /*-----------------------------------------------------------------------
00319   | Let l1 be l1 and l2 be l2
00320   | Split l2 off from the front of l1:    final l2,l1 = original l1
00321   |
00322   | Split l1 into l2: objects of l1 up to and including Curs object
00323   |               l1: objects of l1 after Curs
00324   | Any original contents of l2 are freed.
00325   | List_Spilt(l1, l2, NULL) splits l1 before the first object so l1 gets all.
00326   | The elements themselves are not moved.
00327    ------------------------------------------------------------------------*/
00328
00329   void APIENTRY List_SplitBefore(LIST l1, LIST l2, LPVOID Curs);
00330   /*----------------------------------------------------------------------
00331   | Split l2 off from the back of l1:  final l1,l2 = original l1
00332   |
00333   | Split l1 into l1: objects of l1 up to but not including Curs object
00334   |               l2: objects of l1 from Curs onwards
00335   | Any original contants of l2 are freed.
00336   | List_Spilt(l1, l2, NULL) splits l1 after the last object so l1 gets all.
00337   | The elements themselves are not moved.
00338    -----------------------------------------------------------------------*/
00339
00340   int APIENTRY List_Card(LIST lst);
00341   /* Return the number of items in L */
00342
00343   /*------------------------------------------------------------------
00344   | Error handling.
00345   |
00346   | Each list has within it a flag which indicates whether any illegal
00347   | operation has been detected (e.g. DeleteFirst when empty).
00348   | Rather than have a flag on every operation, there is a flag held
00349   | within the list that can be queried when convenient.  Many operations
00350   | do not have enough redundancy to allow any meaningful check.  This
00351   | is a design compromise (for instance to allow P = List_Next(P);
00352   | rather than P = List_Next(L, P); which is more awkward, especially
00353   | if L is actually a lengthy phrase).
00354   |
00355   | List_IsOK tests this flag (so is a very simple, quick operation).
00356   | MakeOK sets the flag to TRUE, in other words to accept the current
00357   | state of the list.
00358   |
00359   | It is possible for a list to be damaged (whether or not the flag
00360   | says OK) for instance by the storage being overwritten.
00361   |
00362   | List_Check attempts to verify that the list is sound (for instance where
00363   | there are both forward and backward pointers they should agree).
00364   |
00365   | List_Recover attempts to make a sound list out of whatever debris is left.
00366   | If the list is damaged, Recover may trap (e.g. address error) but
00367   | if the list was damaged then ANY operation on it may trap.
00368   | If Check succeeds without trapping then so will Recover.
00369    -----------------------------------------------------------------*/
00370
00371   BOOL APIENTRY List_IsOK(LIST lst);
00372   /* Check return code */
00373
00374   void APIENTRY List_MakeOK(LIST lst);
00375   /* Set return code to good */
00376
00377   BOOL APIENTRY List_Check(LIST lst);
00378   /* Attempt to validate the chains */
00379
00380   void APIENTRY List_Recover(PLIST plst);
00381   /* Desperate stuff.  Attempt to reconstruct something */
00382
00383 /*------------------------------------------------------------------
00384 |  It is designed to be as easy to USE as possible, consistent
00385 |  only with being an opaque type.
00386 |
00387 |  In particular, the decision to use the address of an object a list cursor
00388 |  means that there is a small amount of extra arithmetic (in the
00389 |  IMPLEMENTATION) in cursor operations (e.g. Next and Prev).
00390 |  and spurious arguments are avoided whenever possible, even though
00391 |  it would allow greater error checking.
00392 |
00393 | Of the "whole list" operations, Clear is given because it seems to be
00394 | a common operation, even though the caller can implement it with almost
00395 | the same efficiency as the List implementation module.
00396 | Join, Split and InsertListXxx cannot be implemented efficiently without
00397 | knowing the representation.
00398  --------------------------------------------------------------------*/
00399 #endif
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/about.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

about.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     This class implements ISnapinAbout
00014
00015
00016
00017 #ifndef _CLASS_CSNAPINABOUT_
00018 #define _CLASS_CSNAPINABOUT_
00019
00020 #include <mmc.h>
00021
00022
00023 //---------------------------------------------------------------------------
00024 class CSnapinAbout : public ISnapinAbout
00025 {
00026   private:
00027     ULONG       m_cRef;
00028     HBITMAP     m_hSmallImage;
00029     HBITMAP     m_hLargeImage;
00030     HBITMAP     m_hOpenImage;
00031     HICON       m_hAppIcon;
00032
00033   public:
00034     CSnapinAbout();
00035     ~CSnapinAbout();
00036
00037     /////////////////////////////////////////////////////////////////////////
00038     // Interface IUnknown
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     /////////////////////////////////////////////////////////////////////////
00044     // Interface ISnapinAbout
00045     STDMETHODIMP GetSnapinDescription(/*[out]*/ LPOLESTR* pszDescription );
00046
00047     STDMETHODIMP GetProvider(/*[out]*/ LPOLESTR* pszProvider );
00048
00049     STDMETHODIMP GetSnapinVersion(/*[out]*/ LPOLESTR* pszVersion);
00050
00051     STDMETHODIMP GetSnapinImage(/*[out]*/ HICON* hAppIcon );
00052
00053     STDMETHODIMP GetStaticFolderImage
00054                  (/*[out]*/ HBITMAP*  hSmallImage,
00055                   /*[out]*/ HBITMAP*  hOpenImage,
00056                   /*[out]*/ HBITMAP*  hLargeImage,
00057                   /*[out]*/ COLORREF* cMask
00058                  );
00059 };
00060
00061 #endif _CLASS_CSNAPINABOUT_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/DataSource/stdafx.h Source File

  • Multimedia
  • WindowsMediaServices9
  • DataSource

stdafx.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName:            stdafx.h
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011
00012 #if !defined(AFX_STDAFX_H__8B75479A_0330_42EC_8A21_F33918FF067D__INCLUDED_)
00013 #define AFX_STDAFX_H__8B75479A_0330_42EC_8A21_F33918FF067D__INCLUDED_
00014
00015 #if _MSC_VER > 1000
00016 #pragma once
00017 #endif // _MSC_VER > 1000
00018
00019 #define STRICT
00020 #ifndef _WIN32_WINNT
00021 #define _WIN32_WINNT 0x0400
00022 #endif
00023 #define _ATL_APARTMENT_THREADED
00024
00025 #include <atlbase.h>
00026 //You may derive a class from CComModule and use it if you want to override
00027 //something, but do not change the name of _Module
00028 extern CComModule _Module;
00029 #include <atlcom.h>
00030
00031 //{{AFX_INSERT_LOCATION}}
00032 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00033
00034 #endif // !defined(AFX_STDAFX_H__8B75479A_0330_42EC_8A21_F33918FF067D__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/ParameterDirectionEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

ParameterDirectionEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: ParameterDirectionEnum
00019
00020 public class ParameterDirectionEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adParamUnknown = 0;
00023   public static final short adParamInput = 1;
00024   public static final short adParamOutput = 2;
00025   public static final short adParamInputOutput = 3;
00026   public static final short adParamReturnValue = 4;
00027 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/FileRepServer.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

FileRepServer.cpp

Go to the documentation of this file.
00001 /*
00002
00003     File Replication Sample
00004     Server System Service
00005
00006     FILE: FileRepServer.cpp
00007
00008     PURPOSE: Provides file replication services.
00009
00010     USAGE:
00011         FileRepService
00012
00013     FUNCTIONS:
00014         main() - calls the StartServiceCtrlDispatcher function to
00015             connect to the SCM and start the control dispatcher thread.
00016         ServiceMain() - the entry point for the service.
00017         ServiceCtrl() - this function is called by the dispatcher thread.
00018             It handles the control code passed to it.
00019         ServiceStart() - performs actual initialization and starts the service.
00020             Makes the RPC server listen for calls.
00021
00022     COMMENTS:
00023
00024 */
00025
00026 // Common definitions
00027 #include "common.h"
00028
00029 #define SECURITY_WIN32
00030
00031 #include <process.h>
00032 #include <tchar.h>
00033 #include <rpc.h>
00034 #include <Ntdsapi.h>
00035 #include <Ntsecapi.h>
00036 #include <Security.h>
00037 #include <Secext.h>
00038 #include <Dsgetdc.h>
00039 #include <Lm.h>
00040
00041 // Contains declarations for system service functions.
00042 #include "Service.h"
00043
00044 #ifdef PROF
00045 #include "Prof.h"
00046 #endif
00047
00048 #ifdef DEBUG1
00049 #include "DbgMsg.h"
00050 #endif
00051
00052 /*
00053     FUNCTION: main()
00054
00055     PURPOSE: main() calls StartServiceCtrlDispatcher to register the
00056         main service thread.    When this call returns,
00057         the service has stopped.
00058
00059     PARAMETERS:
00060         dwArgc - number of command line arguments
00061         lpszArgv - array of command line arguments
00062
00063     RETURN VALUE:
00064         none
00065
00066     COMMENTS:
00067 */
00068 VOID _cdecl main(int argc, char **argv){
00069     RPC_STATUS status;
00070
00071     int nNumArgs;
00072     LPWSTR *szArgList = CommandLineToArgvW(GetCommandLine(), &nNumArgs);
00073
00074     if (NULL == szArgList) {
00075         _tprintf(TEXT("FileRep main: CommandLineToArgW failed"));
00076         exit(EXIT_FAILURE);
00077     }
00078
00079     // Allow the user to override settings with command line switches.
00080     for (int i = 1; i < nNumArgs; i++) {
00081         // Well-formed argument switches start with '/' or '-' and are
00082         // two characters long.
00083         if (((*szArgList[i] == TEXT('-')) || (*szArgList[i] == TEXT('/'))) && _tcsclen(szArgList[i]) == 2) {
00084
00085             switch (_totlower(*(szArgList[i]+1))) {
00086
00087                 case TEXT('f'):
00088       bNoFileIO = true;
00089       break;
00090
00091                 case TEXT('h'):
00092                 case TEXT('?'):
00093                 default:
00094                     exit(EXIT_SUCCESS);
00095             }
00096         }
00097         else {
00098     _tprintf(TEXT("Bad arguments.\n\n"));
00099     exit(EXIT_FAILURE);
00100         }
00101     }
00102
00103     // Service initialization
00104     if (!StartFileRepServer()) {
00105       return;
00106     } else {
00107       bServerListening = TRUE;
00108
00109       // RpcMgmtWaitServerListen() will block until the server has
00110       // stopped listening.
00111       status = RpcMgmtWaitServerListen();
00112       if (status != RPC_S_OK){
00113         AddToMessageLogProcFailureEEInfo(TEXT("ServiceStart: RpcMgmtWaitServerListen"), status);
00114         return;
00115       }
00116     }
00117
00118     return;
00119 }
00120
00121 // end FileRepServer.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/delebase.h Source File

  • SysMgmt
  • MMC
  • WMI

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CDelegationBase {
00030 public:
00031     CDelegationBase();
00032     virtual ~CDelegationBase();
00033
00034     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00035     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00036
00037     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00038     virtual const int GetBitmapIndex() = 0;
00039
00040     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00041
00042 public:
00043     // virtual functions go here (for MMCN_*)
00044     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00045     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00046     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00047     virtual HRESULT OnRename(LPOLESTR pszNewName) { return S_FALSE; }
00048     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00049
00050     virtual HRESULT CreatePropertyPages(IPropertySheetCallback *lpProvider,
00051         LONG_PTR handle) { return S_FALSE; }
00052     virtual HRESULT HasPropertySheets() { return S_FALSE; }
00053     virtual HRESULT GetWatermarks(HBITMAP *lphWatermark,
00054         HBITMAP *lphHeader,
00055         HPALETTE *lphPalette,
00056         BOOL *bStretch) { return S_FALSE; }
00057
00058     virtual HRESULT OnPropertyChange(IConsole *pConsole) { return S_OK; }
00059
00060 public:
00061     static HBITMAP m_pBMapSm;
00062     static HBITMAP m_pBMapLg;
00063
00064 protected:
00065     static void LoadBitmaps() {
00066         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00067         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00068     }
00069
00070     BOOL bExpanded;
00071
00072 private:
00073     // {2974380B-4C4B-11d2-89D8-000021473128}
00074     static const GUID thisGuid;
00075 };
00076
00077 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CThreadData Member List

This is the complete list of members for CThreadData, including all inherited members.
CLinkable() | CLinkable | [inline]
CThreadData() | CThreadData | [inline]
CThreadData(THREADDATA *pData) | CThreadData | [inline]
GetThreadData() | CThreadData | [inline]
InsertAfter(CLinkable *other) | CLinkable |
InsertBefore(CLinkable *other) | CLinkable |
IsLinked() | CLinkable | [inline]
m_td | CThreadData | [private]
Next() | CLinkable | [inline]
Previous() | CLinkable | [inline]
Remove() | CLinkable |
~CLinkable() | CLinkable | [inline]
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/JavaClient/Class1.java Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • JavaClient

Class1.java

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Class1.java
00003   Summary:   Simple demo of non-blocking method calls in Java
00004 -----------------------------------------------------------------------------
00005
00006 This file is part of the Microsoft COM+ Samples.
00007
00008 Copyright (C) 1995-1998 Microsoft Corporation. All rights reserved.
00009
00010 This source code is intended only as a supplement to Microsoft
00011 Development Tools and/or on-line documentation. See these other
00012 materials for detailed information regarding Microsoft code samples.
00013
00014 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 PARTICULAR PURPOSE.
00018
00019 ==========================================================================+*/
00020 import fullsvr.*;//VS6 imported COM wrapper
00021 import java.io.IOException;
00022
00023 public class Class1
00024 {
00025
00026   public static void main (String[] args)
00027   {
00028     int i;
00029
00030     //Create the server
00031     FullServ pFullServ = new FullServ();
00032
00033     //QueryInterface for ICallFactory
00034     ICallFactory pICallFactory = (ICallFactory)pFullServ;
00035
00036     //Create the call object
00037     AsyncIFullServ arrayAsyncIFullServ[] = new AsyncIFullServ[1];
00038     pICallFactory.CreateCall(AsyncIFullServ.iid,null,AsyncIFullServ.iid,arrayAsyncIFullServ);
00039     AsyncIFullServ pAsyncIFullServ = arrayAsyncIFullServ[0];
00040
00041     //QueryInterface for ISynchronize
00042     ISynchronize pISynchronize = (ISynchronize) pAsyncIFullServ;
00043
00044     //Begin non-blocking call
00045     pAsyncIFullServ.Begin_Sum(2,3);
00046
00047     System.out.println("Waiting for call completion.");
00048     //Wait for call completion
00049     try{
00050       pISynchronize.Wait(0,-1);// -1 = INFINITE
00051     }catch(com.ms.com.ComFailException cfe){
00052       System.err.println("Error during Wait");
00053       return;
00054     }
00055     //Finish the call
00056     i = pAsyncIFullServ.Finish_Sum();
00057
00058     System.out.println("2 + 3 = " + i );
00059
00060     System.out.println("\n\nPress Enter to continue..\n \n");
00061     try{System.in.read();}
00062     catch(IOException e){}
00063
00064   }
00065 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSCPUIBindingInfo Member List

This is the complete list of members for CSCPUIBindingInfo, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
CSCPUIBindingInfo() | CSCPUIBindingInfo | [inline]
CSCPUIBindingInfo(HWND hNotifyObj) | CSCPUIBindingInfo | [inline]
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [virtual]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
Init(PWSTR pszPath, PWSTR pszClass) | CSCPUIBindingInfo | [virtual]
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_bDirty | CSCPUIBindingInfo | [private]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hNotifyObj | CSCPUIBindingInfo | [private]
m_hWnd | CPropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_pAttributeEditor | CSCPUIBindingInfo | [private]
m_pIPropertyPageSite | CPropertyPage | [protected]
m_pWritableAttrs | CSCPUIBindingInfo | [private]
m_spDsObj | CSCPUIBindingInfo | [private]
m_szClass | CSCPUIBindingInfo | [private]
m_szPath | CSCPUIBindingInfo | [private]
m_szValueList | CSCPUIBindingInfo | [private]
Move(LPCRECT pRect) | CPropertyPage |
OnApply() | CSCPUIBindingInfo | [virtual]
OnDestroy() | CSCPUIBindingInfo | [virtual]
OnInitDialog() | CSCPUIBindingInfo | [virtual]
OnPropertyChange() | CSCPUIBindingInfo |
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
SetUIData() | CSCPUIBindingInfo | [virtual]
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
~CPropertyPage() | CPropertyPage | [virtual]
~CSCPUIBindingInfo() | CSCPUIBindingInfo | [inline]
Generated on Wed Nov 13 2024 16:57:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Client/BYOTTransaction/Resource.h Source File

  • Com
  • Services
  • BYOT
  • Client
  • BYOTTransaction

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ByotTransaction.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_BYOTTRANSOBJ                101
00007
00008 // Next default values for new objects
00009 //
00010 #ifdef APSTUDIO_INVOKED
00011 #ifndef APSTUDIO_READONLY_SYMBOLS
00012 #define _APS_NEXT_RESOURCE_VALUE        201
00013 #define _APS_NEXT_COMMAND_VALUE         32768
00014 #define _APS_NEXT_CONTROL_VALUE         201
00015 #define _APS_NEXT_SYMED_VALUE           102
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Client/BYOTTransaction/BYOTTransaction.Cpp Source File

  • Com
  • Services
  • BYOT
  • Client
  • BYOTTransaction

BYOTTransaction.Cpp

Go to the documentation of this file.
00001 // ByotTransaction.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f ByotTransactionps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "ByotTransaction.h"
00012
00013 #include "ByotTransaction_i.c"
00014 #include "ByotTransObj.h"
00015
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP(ObjectMap)
00020 OBJECT_ENTRY(CLSID_ByotTransObj, CByotTransObj)
00021 END_OBJECT_MAP()
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // DLL Entry Point
00025
00026 extern "C"
00027 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00028 {
00029     if (dwReason == DLL_PROCESS_ATTACH)
00030     {
00031         _Module.Init(ObjectMap, hInstance, &LIBID_BYOTTRANSACTIONLib);
00032         DisableThreadLibraryCalls(hInstance);
00033     }
00034     else if (dwReason == DLL_PROCESS_DETACH)
00035         _Module.Term();
00036     return TRUE;    // ok
00037 }
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // Used to determine whether the DLL can be unloaded by OLE
00041
00042 STDAPI DllCanUnloadNow(void)
00043 {
00044     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00045 }
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 // Returns a class factory to create an object of the requested type
00049
00050 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00051 {
00052     return _Module.GetClassObject(rclsid, riid, ppv);
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // DllRegisterServer - Adds entries to the system registry
00057
00058 STDAPI DllRegisterServer(void)
00059 {
00060     // registers object, typelib and all interfaces in typelib
00061     return _Module.RegisterServer(TRUE);
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // DllUnregisterServer - Removes entries from the system registry
00066
00067 STDAPI DllUnregisterServer(void)
00068 {
00069     return _Module.UnregisterServer(TRUE);
00070 }
00071
00072
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmMonitor/CrmMonCompObj.h Source File

  • Com
  • Services
  • Crm
  • CrmMonitor

CrmMonCompObj.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CrmMonCompObj.h
00004
00005
00006
00007 Summary:  This is a sample of how to use the monitoring interfaces for the Compensating Resource Manager (CRM).
00008
00009       The following interfaces are used -
00010
00011         ICrmMonitor
00012         ICrmMonitorLogRecords
00013         ICrmMonitorClerks
00014         ICrmFormatLogRecords
00015
00016       This sample shows how CRM clerks in a specified transaction can be found and queried.
00017
00018       This component should be installed in the application to be monitored. It does not require a transaction.
00019
00020
00021 Classes: CCrmMonComp
00022
00023
00024 ----------------------------------------------------------------------------
00025
00026 This file is part of the Microsoft COM+ Samples.
00027
00028
00029
00030 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00031
00032
00033
00034 This source code is intended only as a supplement to Microsoft
00035
00036 Development Tools and/or on-line documentation. See these other
00037
00038 materials for detailed information regarding Microsoft code samples.
00039
00040
00041
00042 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00043
00044 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00045
00046 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00047
00048 PARTICULAR PURPOSE.
00049
00050 ==========================================================================+*/
00051
00052 #ifndef __CRMMONCOMP_H_
00053 #define __CRMMONCOMP_H_
00054
00055 #include "resource.h"       // main symbols
00056
00057 #include "comdef.h"     // for _variant_t
00058
00059 #include <comsvcs.h>    // CRM interfaces
00060
00061 // STL
00062
00063 #include <vector>
00064 using namespace std;
00065 #pragma warning(disable:4786)
00066 // warning C4786: identifier was truncated to '255' characters in the browser information
00067
00068 struct CLERK_ENTRY
00069 {
00070   _variant_t          m_vIndex;
00071
00072   ICrmMonitorLogRecords   *m_pICrmMonitorLogRecords;
00073 };
00074
00075 typedef vector<CLERK_ENTRY *> VEC_CLERKS;           // array of held clerks
00076
00077 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00078
00079 Class: CCrmMonComp
00080
00081   This is a monitor for the CRM. It captures a snapshot of the current
00082   state of the CRMs and holds a specific CRM clerk.
00083
00084 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00085
00086 /////////////////////////////////////////////////////////////////////////////
00087 // CCrmMonComp
00088 class ATL_NO_VTABLE CCrmMonComp :
00089   public CComObjectRootEx<CComMultiThreadModel>,
00090   public CComCoClass<CCrmMonComp, &CLSID_CrmMonComp>,
00091   public ICrmMonComp
00092 {
00093 public:
00094   CCrmMonComp() :
00095    m_pICrmMonitor(NULL)
00096   ,m_pICrmMonitorClerks(NULL)
00097   ,m_lClerkNumber(0)
00098   ,m_lRecordNumber(0)
00099   ,m_pICrmFormatLogRecords(NULL)
00100   {
00101     m_pUnkMarshaler = NULL;
00102   }
00103
00104 DECLARE_REGISTRY_RESOURCEID(IDR_CRMMONCOMP)
00105 DECLARE_GET_CONTROLLING_UNKNOWN()
00106
00107 BEGIN_COM_MAP(CCrmMonComp)
00108   COM_INTERFACE_ENTRY(ICrmMonComp)
00109   COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
00110 END_COM_MAP()
00111
00112   HRESULT FinalConstruct();
00113
00114   void FinalRelease();
00115
00116   CComPtr<IUnknown> m_pUnkMarshaler;
00117
00118 // ICrmMonComp
00119 public:
00120   STDMETHOD(get_FormattedRecord)(/*[out, retval]*/ VARIANT *pVal);
00121   STDMETHOD(get_ColumnHeaders)(/*[out, retval]*/ VARIANT *pVal);
00122   STDMETHOD(SetRecord)(/*[in]*/ long lRecordNumber);
00123   STDMETHOD(AbortTransaction)();
00124   STDMETHOD(get_NumberOfLogRecords)(/*[out, retval]*/ long *pVal);
00125   STDMETHOD(get_Description)(/*[out, retval]*/ VARIANT *pVal);
00126   STDMETHOD(get_ProgId)(/*[out, retval]*/ VARIANT *pVal);
00127   STDMETHOD(get_ActivityId)(/*[out, retval]*/ VARIANT *pVal);
00128   STDMETHOD(get_TransactionState)(/*[out, retval]*/ VARIANT *pVal);
00129   STDMETHOD(SetClerk)(/*[in]*/ long lClerkNumber);
00130   STDMETHOD(get_FindClerks)(/*[out, retval]*/ long * plNumberOfClerks);
00131   STDMETHOD(put_TransactionUOW)(/*[in]*/ VARIANT newVal);
00132
00133 private:
00134
00135   HRESULT CreateCompensator(void);
00136
00137 private:
00138
00139   ICrmMonitor         *m_pICrmMonitor;
00140
00141   ICrmMonitorClerks     *m_pICrmMonitorClerks;
00142
00143   _variant_t          m_vTxUOWRequired;
00144
00145   VEC_CLERKS          m_vecClerks;
00146
00147   _variant_t          m_vActivityId;
00148
00149   long            m_lClerkNumber;
00150
00151   long            m_lRecordNumber;
00152
00153   ICrmFormatLogRecords    *m_pICrmFormatLogRecords;
00154
00155 };
00156
00157 #endif //__CRMMONCOMP_H_
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/CustomAuth/CustomAuth.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • CustomAuth

CustomAuth.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: CustomAuth.cpp
00006
00007 Abstract:
00008
00009     ISAPI extension to demonstrate using a wildcard script
00010     map with HSE_REQ_EXEC_URL to implement a custom forms
00011     based authentication scheme.
00012
00013 Author:
00014
00015     ISAPI developer (Microsoft employee), October 2002
00016
00017 --*/
00018
00019 #include <IsapiTools.h>
00020 #include <httpfilt.h>
00021 #include "CustomAuth.h"
00022
00023 //
00024 // Globals
00025 //
00026
00027 ISAPI_EXTENSION  g_Extension;
00028 ISAPI_STRING     g_strIniFile;
00029 ISAPI_STRING     g_strLogonUrl;
00030 ISAPI_STRING     g_strLogonSuccessUrl;
00031 ISAPI_STRING     g_strLogoffUrl;
00032 INT              g_LogonTimeoutSeconds;
00033 BOOL             g_fFilterInitialized;
00034 BOOL             g_fUseBuiltInLogon;
00035 BOOL             g_fUseBuiltInLogoff;
00036 BOOL             g_fUseSSLForSubmission;
00037 BOOL             g_fUseClientIpForEncryption;
00038 DWORD            g_LogonType;
00039
00040 //
00041 // Local prototypes
00042 //
00043
00044 VOID
00045 WINAPI
00046 HandleExecUrlCompletion(
00047     EXTENSION_CONTROL_BLOCK *   pecb,
00048     VOID *                      pContext,
00049     DWORD                       cbIO,
00050     DWORD                       dwError
00051     );
00052
00053 VOID
00054 WINAPI
00055 HandleSendPageCompletion(
00056     EXTENSION_CONTROL_BLOCK *   pecb,
00057     VOID *                      pContext,
00058     DWORD                       cbIO,
00059     DWORD                       dwError
00060     );
00061
00062 DWORD
00063 ProcessLogon(
00064     EXTENSION_CONTROL_BLOCK *   pecb
00065     );
00066
00067 DWORD
00068 ProcessLogoff(
00069     EXTENSION_CONTROL_BLOCK *   pecb
00070     );
00071
00072 DWORD
00073 SendBuiltinLogonPage(
00074     EXTENSION_CONTROL_BLOCK *   pecb
00075     );
00076
00077 BOOL
00078 GetUserInfoAndUpdateCookie(
00079     ISAPI_STRING *              pstrCookie,
00080     CHAR *                      szClientIP,
00081     HSE_EXEC_URL_USER_INFO *    pUserInfo,
00082     ISAPI_STRING *              pstrUser    );
00083
00084 BOOL
00085 EncryptAndEncodeCredentials(
00086     CHAR *          szUser,
00087     CHAR *          szPassword,
00088     CHAR *          szClientIP,
00089     ISAPI_STRING *  pstrResult
00090     );
00091
00092 BOOL
00093 DecodeAndDecryptCredentials(
00094     CHAR *          szCredentials,
00095     CHAR *          szClientIP,
00096     ISAPI_STRING *  pstrUser,
00097     ISAPI_STRING *  pstrPassword,
00098     FILETIME *      pft
00099     );
00100
00101 //
00102 // Extension entry point implementations
00103 //
00104
00105 BOOL
00106 WINAPI
00107 GetExtensionVersion(
00108     HSE_VERSION_INFO *  pVer
00109     )
00110 /*++
00111
00112 Purpose:
00113
00114     Entry point for ISAPI extension initialization.  Required.
00115
00116     This function will be called exactly once in the lifetime
00117     of the extension, at initialization time.  This function is
00118     a useful point to do complex initialization tasks.  This
00119     function is called outside of the system loader lock, so
00120     it does not have the same restrictions as DllMain.
00121
00122 Arguments:
00123
00124     pVer - points to extension version info structure
00125
00126 Returns:
00127
00128     TRUE on success, FALSE on failure.
00129
00130     Note that in the case of FALSE, IIS will call GetLastError()
00131     and return an error page to the client.  The entity body of
00132     the page may be textual if the FormatMessage API can resolve
00133     it, or it may just be an error number if FormatMessage can't
00134     resolve it.
00135
00136 --*/
00137 {
00138     //
00139     // Tell IIS which version of ISAPI this extension was built from.
00140     //
00141
00142     pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
00143                                          HSE_VERSION_MAJOR);
00144
00145     //
00146     // Report the description string for this extension.  Ensure
00147     // that it does not exceed the maximum length and is NULL
00148     // terminated.
00149     //
00150
00151     strncpy( pVer->lpszExtensionDesc,
00152              "CustomAuth ISAPI Sample",
00153              HSE_MAX_EXT_DLL_NAME_LEN );
00154
00155     pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
00156
00157     //
00158     // Return TRUE if we successfully initialized.
00159     //
00160
00161     return TRUE;
00162 }
00163
00164 DWORD
00165 WINAPI
00166 HttpExtensionProc(
00167     EXTENSION_CONTROL_BLOCK *   pecb
00168     )
00169 /*++
00170
00171 Purpose:
00172
00173     Entry point for ISAPI requests.  Required.
00174
00175     This function is called once per request.  The EXTENSION_CONTROL_BLOCK
00176     passed in contains information and function pointers sufficient to
00177     interact with the server during this processing.
00178
00179     Note that, once HttpExtensionProc is called, it is the responsibility
00180     of the extension to send back any data that the client should receive.
00181     IIS will not automatically generate any response, even in the case of
00182     HSE_STATUS_ERROR once the request has progressed to the point where
00183     this function is called.
00184
00185     Also note that you should not make any blocking calls or do long-running
00186     operations within this function.  To allow efficient scaling of your
00187     server, you should consider creating a pool of private threads to handle
00188     the requests.  In that case, the implementation of this function would
00189     be just to add the pecb to a queue and return HSE_STATUS_PENDING.  The
00190     threads in the pool would be responsible for dequeing a pecb and calling
00191     HSE_REQ_DONE_WITH_SESSION when they are finished processing it.
00192
00193 Arguments:
00194
00195     pecb - pointer to the extenstion control block
00196
00197 Returns:
00198
00199     HSE_STATUS_SUCCESS - Indicates successful request.
00200     HSE_STATUS_ERROR   - Indicates failed request.
00201     HSE_STATUS_PENDING - Indicates that processing of the request
00202                          should continue after this function returns.
00203                          It HSE_STATUS_PENDING is used, it is necessary
00204                          that HSE_REQ_DONE_WITH_SESSION is called
00205                          exactly once when processing is completed for
00206                          the request.
00207
00208 --*/
00209 {
00210     HTTP_FILTER_CONTEXT *   pfc = NULL;
00211     HSE_EXEC_URL_INFO       ExecUrlInfo;
00212     HSE_EXEC_URL_USER_INFO  UserInfo = {0};
00213     ISAPI_REQUEST           Request( pecb );
00214     ISAPI_STRING            strUrl;
00215     ISAPI_STRING            strCookie;
00216     ISAPI_STRING            strClientIP;
00217     ISAPI_STRING            strUser;
00218     ISAPI_STRING            strFilterContext;
00219     ISAPI_STRING            strAuthType;
00220     HANDLE                  hToken = NULL;
00221     BOOL                    fModifiedUserInfo = FALSE;
00222     DWORD                   dwResult;
00223     BOOL                    fResult;
00224
00225     //
00226     // Before doing anythine else, check to see if this request
00227     // has already been authenticated.  If so, just let the
00228     // request run.
00229     //
00230
00231     fResult = Request.GetServerVariable( "AUTH_TYPE", &strAuthType );
00232
00233     if ( !fResult )
00234     {
00235         goto Failed;
00236     }
00237
00238     if ( *( strAuthType.QueryStr() ) != '\0' )
00239     {
00240         goto CallExecUrl;
00241     }
00242
00243     //
00244     // Get the URL and check to see if it's one that we should
00245     // deal with.
00246     //
00247
00248     fResult = Request.GetServerVariable( "URL", &strUrl );
00249
00250     if ( !fResult )
00251     {
00252         goto Failed;
00253     }
00254
00255     //
00256     // Logon request?
00257     //
00258
00259     if ( stricmp( strUrl.QueryStr(), "/Logon" ) == 0 )
00260     {
00261         dwResult = ProcessLogon( pecb );
00262
00263         if ( dwResult == HSE_STATUS_ERROR )
00264         {
00265             goto Failed;
00266         }
00267
00268         return dwResult;
00269     }
00270
00271     //
00272     // Logoff request?
00273     //
00274
00275     if ( stricmp( strUrl.QueryStr(), "/Logoff" ) == 0 )
00276     {
00277         dwResult = ProcessLogoff( pecb );
00278
00279         if ( dwResult == HSE_STATUS_ERROR )
00280         {
00281             goto Failed;
00282         }
00283
00284         return dwResult;
00285     }
00286
00287     //
00288     // Use built-in logon page?
00289     //
00290
00291     if ( g_fUseBuiltInLogon == TRUE &&
00292          stricmp( strUrl.QueryStr(), g_strLogonUrl.QueryStr() ) == 0 )
00293     {
00294         dwResult = SendBuiltinLogonPage( pecb );
00295
00296         if ( dwResult == HSE_STATUS_ERROR )
00297         {
00298             goto Failed;
00299         }
00300
00301         return dwResult;
00302     }
00303
00304     //
00305     // Check for a cookie and process it if found
00306     //
00307
00308     fResult = Request.GetServerVariable( "HTTP_COOKIE",
00309                                          &strCookie );
00310
00311     if ( fResult )
00312     {
00313         fResult = Request.GetServerVariable( "REMOTE_ADDR",
00314                                              &strClientIP );
00315
00316         if ( !fResult )
00317         {
00318             goto Failed;
00319         }
00320
00321         fResult = Request.UnimpersonateClient();
00322
00323         if ( !fResult )
00324         {
00325             goto Failed;
00326         }
00327
00328         fResult = GetUserInfoAndUpdateCookie( &strCookie,
00329                                               strClientIP.QueryStr(),
00330                                               &UserInfo,
00331                                               &strUser );
00332
00333         Request.ImpersonateClient();
00334
00335         //
00336         // If we didn't get any user info from the cookie, then
00337         // just allow the request through as anonymous.
00338         //
00339
00340         if ( !fResult )
00341         {
00342             goto CallExecUrl;
00343         }
00344
00345         //
00346         // Set the updated cookie back into the client.
00347         //
00348         // Note that this action has a bit of cleverness to it.
00349         // Since we are going to call a child URL, and not send
00350         // response headers directly, we can't just send the
00351         // response header as an extension normally would.  Instead,
00352         // since this dll has both a filter and extension component,
00353         // we are getting the HTTP_FILTER_CONTEXT for the request
00354         // from the filter via a custom request header (which the
00355         // client never sees), and using a filter function to add
00356         // our set-cookie header so that it will be included when
00357         // the response headers are sent, as if it were an IIS
00358         // built-in header
00359         //
00360
00361         fResult = Request.GetServerVariable( "HTTP_CUSTOMAUTH_CONTEXT",
00362                                              &strFilterContext );
00363
00364         if ( fResult )
00365         {
00366             pfc = (HTTP_FILTER_CONTEXT*)strtoul( strFilterContext.QueryStr(),
00367                                                  NULL,
00368                                                  16 );
00369         }
00370
00371         if ( pfc )
00372         {
00373             ISAPI_STRING    strSetCookie;
00374
00375             if ( strSetCookie.Printf( "Set-Cookie: %s\r\n",
00376                                       strCookie.QueryStr() ) == FALSE )
00377             {
00378                 goto Failed;
00379             }
00380
00381             if ( pfc->AddResponseHeaders( pfc,
00382                                           strSetCookie.QueryStr(),
00383                                           0 ) == FALSE )
00384             {
00385                 goto Failed;
00386             }
00387         }
00388
00389         fModifiedUserInfo = TRUE;
00390     }
00391
00392     //
00393     // Fall through
00394     //
00395
00396 CallExecUrl:
00397
00398     //
00399     // Use EXEC_URL to pass the request along
00400     //
00401     // We will pass NULL for all of the parts of the request
00402     // that we don't want to modify.
00403     //
00404     // We will also use the HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR
00405     // flag.  This will ensure that this extension is not called again
00406     // on this request (which could otherwise happen in some cases).
00407     //
00408
00409     ExecUrlInfo.pszUrl = NULL;
00410     ExecUrlInfo.pszMethod = NULL;
00411     ExecUrlInfo.pszChildHeaders = NULL;
00412     ExecUrlInfo.pUserInfo = NULL;
00413     ExecUrlInfo.pEntity = NULL;
00414     ExecUrlInfo.dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;
00415
00416     if ( fModifiedUserInfo )
00417     {
00418         ExecUrlInfo.pUserInfo = &UserInfo;
00419     }
00420
00421     //
00422     // Associate the completion routine and the current URL with
00423     // this request.
00424     //
00425
00426     if ( pecb->ServerSupportFunction( pecb->ConnID,
00427                                       HSE_REQ_IO_COMPLETION,
00428                                       HandleExecUrlCompletion,
00429                                       NULL,
00430                                       (DWORD*)UserInfo.hImpersonationToken ) == FALSE )
00431     {
00432         goto Failed;
00433     }
00434
00435     //
00436     // Call ExecUrl
00437     //
00438
00439     if ( pecb->ServerSupportFunction( pecb->ConnID,
00440                                       HSE_REQ_EXEC_URL,
00441                                       &ExecUrlInfo,
00442                                       NULL,
00443                                       NULL ) == FALSE )
00444     {
00445         goto Failed;
00446     }
00447
00448     //
00449     // Since EXEC_URL is asynchonous, we need to return STATUS_PENDING.
00450     // The I/O completion routine will clean up.
00451     //
00452
00453     return HSE_STATUS_PENDING;
00454
00455 Failed:
00456
00457     WriteDebug( "HttpExtensionProc failed.  Error %d.\r\n",
00458                 GetLastError() );
00459
00460     //
00461     // If we've already got a token, close it now.
00462     //
00463
00464     if ( UserInfo.hImpersonationToken )
00465     {
00466         CloseHandle( UserInfo.hImpersonationToken );
00467         UserInfo.hImpersonationToken = NULL;
00468     }
00469
00470     //
00471     // Send a 500 error
00472     //
00473
00474     Request.SyncWriteCompleteResponse( "500 Server Error",
00475                                        "Content-Type: text/html\r\n\r\n",
00476                                        SERVER_ERROR );
00477
00478     return HSE_STATUS_ERROR;
00479
00480 }
00481
00482 VOID
00483 WINAPI
00484 HandleExecUrlCompletion(
00485     EXTENSION_CONTROL_BLOCK *   pecb,
00486     VOID *                      pContext,
00487     DWORD                       cbIO,
00488     DWORD                       dwError
00489     )
00490 /*++
00491
00492 Purpose:
00493
00494     Handles completion of an asynchronous HSE_REQ_EXEC_URL
00495     call.  The pContext passed into this function is the
00496     token that was set in the HSE_EXEC_URL_USER_INFO
00497     structure that did the EXEC_URL.  This function needs
00498     to close that handle.
00499
00500 Arguments:
00501
00502     pecb     - Pointer to the EXTENSION_CONTROL_BLOCK
00503     pContext - The completion context (token per above)
00504     cbIO     - I/O bytes associated with this completion
00505     dwError  - Error associated with this completion
00506
00507 Returns:
00508
00509     None
00510
00511 --*/
00512 {
00513     HSE_EXEC_URL_STATUS ExecUrlStatus;
00514     HANDLE              hToken = (HANDLE)pContext;
00515
00516     //
00517     // The child is done.  Delete the entity buffer now.
00518     //
00519
00520     if ( hToken )
00521     {
00522         CloseHandle( hToken );
00523         hToken = NULL;
00524     }
00525
00526     //
00527     // Get the child's HTTP status and set it into the ECB
00528     //
00529
00530     if ( pecb->ServerSupportFunction( pecb->ConnID,
00531                                       HSE_REQ_GET_EXEC_URL_STATUS,
00532                                       &ExecUrlStatus,
00533                                       NULL,
00534                                       NULL ) == TRUE )
00535     {
00536         pecb->dwHttpStatusCode = ExecUrlStatus.uHttpStatusCode;
00537     }
00538
00539     //
00540     // Let IIS know that we are done with the
00541     // ECB and return.
00542     //
00543
00544     pecb->ServerSupportFunction( pecb->ConnID,
00545                                  HSE_REQ_DONE_WITH_SESSION,
00546                                  NULL,
00547                                  NULL,
00548                                  NULL );
00549
00550 }
00551
00552 VOID
00553 WINAPI
00554 HandleSendPageCompletion(
00555     EXTENSION_CONTROL_BLOCK *   pecb,
00556     VOID *                      pContext,
00557     DWORD                       cbIO,
00558     DWORD                       dwError
00559     )
00560 /*++
00561
00562 Purpose:
00563
00564     Handles completion of a send through AsyncTransmitBufferedResponse
00565     call.  The pContext passed into this function is the ISAPI_REQUEST
00566     object used.  We need to delete that object.  It's destructor will
00567     take care of doing HSE_REQ_DONE_WITH_SESSION as appropriate.
00568
00569 Arguments:
00570
00571     pecb     - Pointer to the EXTENSION_CONTROL_BLOCK
00572     pContext - The completion context (ISAPI_REQUEST per above)
00573     cbIO     - I/O bytes associated with this completion
00574     dwError  - Error associated with this completion
00575
00576 Returns:
00577
00578     None
00579
00580 --*/
00581 {
00582     ISAPI_REQUEST * pRequest = (ISAPI_REQUEST*)pContext;
00583
00584     //
00585     // Delete the request object.  Its destructor will
00586     // take care of doing the right DONE_WITH_SESSION stuff.
00587     //
00588
00589     if ( pRequest )
00590     {
00591         delete pRequest;
00592         pRequest = NULL;
00593     }
00594 }
00595
00596 DWORD
00597 ProcessLogon(
00598     EXTENSION_CONTROL_BLOCK *   pecb
00599     )
00600 /*++
00601
00602 Purpose:
00603
00604     Handles logon requests by reading the entity body, parsing
00605     it for username and password information, creating a
00606     cookie to store them on the client (encrypted and base64
00607     encoded), and sending a 302 redirect to the configured
00608     logon success URL.
00609
00610     This send is done asynchronously.
00611
00612 Arguments:
00613
00614     pecb     - Pointer to the EXTENSION_CONTROL_BLOCK
00615
00616 Returns:
00617
00618     HSE_STATUS_PENDING on success, or HSE_STATUS_ERROR
00619     on failure.
00620
00621 --*/
00622 {
00623     ISAPI_REQUEST * pRequest;
00624     ISAPI_STRING    strClientIP;
00625     ISAPI_STRING    strCredentials;
00626     ISAPI_STRING    strSetCookie;
00627     ISAPI_STRING    strUser;
00628     ISAPI_STRING    strPassword;
00629     ISAPI_STRING    strEntity;
00630     ISAPI_BUFFER    Entity;
00631     CHAR *          pCursor;
00632     CHAR *          pDelimiter;
00633     BOOL            fResult;
00634
00635     pRequest = new ISAPI_REQUEST( pecb );
00636
00637     if ( !pRequest )
00638     {
00639         goto Failed;
00640     }
00641
00642     //
00643     // Get the entity body for this request and store
00644     // it in an ISAPI_STRING
00645     //
00646
00647     if ( pRequest->ReadAllEntity( &Entity ) == FALSE )
00648     {
00649         goto Failed;
00650     }
00651
00652     if ( strEntity.Copy( (CHAR*)Entity.QueryPtr(),
00653                          Entity.QueryDataSize() ) == FALSE )
00654     {
00655         goto Failed;
00656     }
00657
00658     //
00659     // Parse the username out of the entity
00660     //
00661
00662     pCursor = strEntity.FindStr( "username=", TRUE );
00663
00664     if ( !pCursor )
00665     {
00666         SetLastError( ERROR_INVALID_DATA );
00667         goto Failed;
00668     }
00669
00670     pCursor += sizeof("username=") - 1;
00671
00672     pDelimiter = strchr( pCursor, '&' );
00673
00674     if ( pDelimiter )
00675     {
00676         fResult = strUser.Copy( pCursor, pDelimiter - pCursor );
00677     }
00678     else
00679     {
00680         fResult = strUser.Copy( pCursor );
00681     }
00682
00683     if ( !fResult )
00684     {
00685         goto Failed;
00686     }
00687
00688     strUser.Unescape();
00689
00690     //
00691     // Parse the password  out of the entity
00692     //
00693
00694     pCursor = strEntity.FindStr( "password=", TRUE );
00695
00696     if ( !pCursor )
00697     {
00698         SetLastError( ERROR_INVALID_DATA );
00699         goto Failed;
00700     }
00701
00702     pCursor += sizeof("password=") - 1;
00703
00704     pDelimiter = strchr( pCursor, '&' );
00705
00706     if ( pDelimiter )
00707     {
00708         fResult = strPassword.Copy( pCursor, pDelimiter - pCursor );
00709     }
00710     else
00711     {
00712         fResult = strPassword.Copy( pCursor );
00713     }
00714
00715     if ( !fResult )
00716     {
00717         goto Failed;
00718     }
00719
00720     strPassword.Unescape();
00721
00722     //
00723     // Get the IP address of the client.  This will be passed to the
00724     // encryption routine so that the resulting encrypted blob can
00725     // only be decrypted on a request from the same client.
00726     //
00727
00728     if ( pRequest->GetServerVariable( "REMOTE_ADDR",
00729                                       &strClientIP ) == FALSE )
00730     {
00731         goto Failed;
00732     }
00733
00734     //
00735     // Get the encrypted credentials and build a
00736     // set-cookie header with them
00737     //
00738     // Temporarily stop impersonating the client while
00739     // calling the encryption code.
00740     //
00741
00742     if ( pRequest->UnimpersonateClient() == FALSE )
00743     {
00744         goto Failed;
00745     }
00746
00747     fResult = EncryptAndEncodeCredentials( strUser.QueryStr(),
00748                                            strPassword.QueryStr(),
00749                                            strClientIP.QueryStr(),
00750                                            &strCredentials );
00751
00752     pRequest->ImpersonateClient();
00753
00754     if ( !fResult )
00755     {
00756         goto Failed;
00757     }
00758
00759     if ( strSetCookie.Printf( "CustomAuth=%s; Path=/",
00760                               strCredentials.QueryStr() ) == FALSE )
00761     {
00762         goto Failed;
00763     }
00764
00765     //
00766     // Set the status for the response, which will be a redirect
00767     // to the logon success URL.
00768     //
00769
00770     if ( pRequest->SetBufferedResponseStatus( "302 Object Moved" ) == FALSE )
00771     {
00772         goto Failed;
00773     }
00774
00775     //
00776     // Add the set-cookie with the credentials
00777     //
00778
00779     if ( pRequest->AddHeaderToBufferedResponse( "Set-Cookie",
00780                                                 strSetCookie.QueryStr() ) == FALSE )
00781     {
00782         goto Failed;
00783     }
00784
00785     //
00786     // Add the location header
00787     //
00788
00789     if ( pRequest->AddHeaderToBufferedResponse( "Location",
00790                                                 g_strLogonSuccessUrl.QueryStr() ) == FALSE )
00791     {
00792         goto Failed;
00793     }
00794
00795     //
00796     // Add "Expires: 0" so that the client doesn't cache this page.
00797     //
00798
00799     if ( pRequest->AddHeaderToBufferedResponse( "Expires",
00800                                                 "0" ) == FALSE )
00801     {
00802         goto Failed;
00803     }
00804
00805     //
00806     // Add the entity for the page
00807     //
00808
00809     if ( pRequest->PrintfToResponseBuffer( REDIRECT_ENTITY,
00810                                            g_strLogonSuccessUrl.QueryStr() ) == FALSE )
00811     {
00812         goto Failed;
00813     }
00814
00815     //
00816     // Zero out any buffers that contain unencrypted password
00817     // information
00818     //
00819
00820     Entity.ZeroBuffer();
00821     strEntity.ZeroBuffer();
00822     strPassword.ZeroBuffer();
00823
00824     //
00825     // Send the request asynchronously
00826     //
00827
00828     if ( pRequest->AsyncTransmitBufferedResponse( HandleSendPageCompletion ) == TRUE )
00829     {
00830         //
00831         // On success, we need to immediately return status pending
00832         //
00833
00834         return HSE_STATUS_PENDING;
00835     }
00836
00837     //
00838     // Fall through to error handler
00839     //
00840
00841 Failed:
00842
00843     WriteDebug( "ProcessLogon failed.  Error %d\r\n",
00844                 GetLastError() );
00845
00846     //
00847     // Zero out any buffers that contain unencrypted password
00848     // information
00849     //
00850
00851     Entity.ZeroBuffer();
00852     strEntity.ZeroBuffer();
00853     strPassword.ZeroBuffer();
00854
00855     if ( pRequest )
00856     {
00857         delete pRequest;
00858         pRequest = NULL;
00859     }
00860
00861     return HSE_STATUS_ERROR;
00862 }
00863
00864 DWORD
00865 ProcessLogoff(
00866     EXTENSION_CONTROL_BLOCK *   pecb
00867     )
00868 {
00869     ISAPI_REQUEST * pRequest;
00870
00871     pRequest = new ISAPI_REQUEST( pecb );
00872
00873     if ( !pRequest )
00874     {
00875         goto Failed;
00876     }
00877
00878     //
00879     // Build the response.  If we are supposed to use the built-in
00880     // logoff page, then we'll send it directly.  Otherwise, the
00881     // response will be a 302 to the configured page.
00882     //
00883
00884     if ( g_fUseBuiltInLogoff == TRUE )
00885     {
00886         if ( pRequest->SetBufferedResponseStatus( "200 OK" ) ==  FALSE )
00887         {
00888             goto Failed;
00889         }
00890
00891         if ( pRequest->AddHeaderToBufferedResponse( "Expires",
00892                                                     "0" ) == FALSE )
00893         {
00894             goto Failed;
00895         }
00896
00897         if ( pRequest->AddDataToResponseBuffer( LOGOFF_PAGE,
00898                                                 sizeof(LOGOFF_PAGE) - 1 ) == FALSE )
00899         {
00900             goto Failed;
00901         }
00902     }
00903     else
00904     {
00905         if ( pRequest->SetBufferedResponseStatus( "302 Object Moved" ) ==  FALSE )
00906         {
00907             goto Failed;
00908         }
00909
00910         if ( pRequest->AddHeaderToBufferedResponse( "Location",
00911                                                     g_strLogoffUrl.QueryStr() ) == FALSE )
00912         {
00913             goto Failed;
00914         }
00915
00916         if ( pRequest->PrintfToResponseBuffer( REDIRECT_ENTITY,
00917                                                g_strLogoffUrl ) == FALSE )
00918         {
00919             goto Failed;
00920         }
00921     }
00922
00923     //
00924     // Add a set-cookie header to remove the credentials
00925     //
00926
00927     if ( pRequest->AddHeaderToBufferedResponse( "Set-Cookie",
00928                                                 DELETE_COOKIE ) == FALSE )
00929     {
00930         goto Failed;
00931     }
00932
00933     //
00934     // Send the response
00935     //
00936
00937     if ( pRequest->AsyncTransmitBufferedResponse( HandleSendPageCompletion ) == TRUE )
00938     {
00939         //
00940         // On success, we need to return HSE_STATUS_PENDING
00941         //
00942
00943         return HSE_STATUS_PENDING;
00944     }
00945
00946     //
00947     // Fall through to error handler
00948     //
00949
00950 Failed:
00951
00952     WriteDebug( "ProcessLogoff failed.  Error %d.\r\n",
00953                 GetLastError() );
00954
00955     if ( pRequest )
00956     {
00957         delete pRequest;
00958         pRequest = NULL;
00959     }
00960
00961     return HSE_STATUS_ERROR;
00962 }
00963
00964 DWORD
00965 SendBuiltinLogonPage(
00966     EXTENSION_CONTROL_BLOCK *   pecb
00967     )
00968 /*++
00969
00970 Purpose:
00971
00972     If we are configured to send back the built-in logon
00973     page (instead of using a user-provided custom page),
00974     this function does the work.
00975
00976 Arguments:
00977
00978     pecb     - Pointer to the EXTENSION_CONTROL_BLOCK
00979
00980 Returns:
00981
00982     HSE_STATUS_PENDING on success, or HSE_STATUS_ERROR
00983     on failure.
00984
00985 --*/
00986 {
00987     ISAPI_REQUEST * pRequest;
00988     ISAPI_STRING    strServerName;
00989     ISAPI_STRING    strHttps;
00990
00991     pRequest = new ISAPI_REQUEST( pecb );
00992
00993     if ( !pRequest )
00994     {
00995         goto Failed;
00996     }
00997
00998     //
00999     // Set the status for the response
01000     //
01001
01002     if ( pRequest->SetBufferedResponseStatus( "200 OK" ) == FALSE )
01003     {
01004         goto Failed;
01005     }
01006
01007     //
01008     // Set the entity body for the response
01009     //
01010
01011     strHttps.ZeroBuffer();
01012
01013     if ( g_fUseSSLForSubmission )
01014     {
01015         if ( pRequest->GetServerVariable( "SERVER_NAME",
01016                                           &strServerName ) == FALSE )
01017         {
01018             goto Failed;
01019         }
01020
01021         if ( strHttps.Printf( "https://%s", strServerName.QueryStr() ) == FALSE )
01022         {
01023             goto Failed;
01024         }
01025     }
01026
01027     if ( pRequest->PrintfToResponseBuffer( LOGON_PAGE,
01028                                            strHttps.QueryStr() ) == FALSE )
01029     {
01030         goto Failed;
01031     }
01032
01033     //
01034     // Now send the page asynchronously
01035     //
01036
01037     if ( pRequest->AsyncTransmitBufferedResponse( HandleSendPageCompletion ) == TRUE )
01038     {
01039         //
01040         // On success, we should return status pending immediately.
01041         //
01042
01043         return HSE_STATUS_PENDING;
01044     }
01045
01046     //
01047     // Fall through to error handler
01048     //
01049
01050 Failed:
01051
01052     WriteDebug( "SendBuiltinLogonPage failed.  Error %d.\r\n",
01053                 GetLastError() );
01054
01055     if ( pRequest )
01056     {
01057         delete pRequest;
01058         pRequest = NULL;
01059     }
01060
01061     return HSE_STATUS_ERROR;
01062 }
01063
01064 BOOL
01065 GetUserInfoAndUpdateCookie(
01066     ISAPI_STRING *              pstrCookie,
01067     CHAR *                      szClientIP,
01068     HSE_EXEC_URL_USER_INFO *    pUserInfo,
01069     ISAPI_STRING *              pstrUser    )
01070 /*++
01071
01072 Purpose:
01073
01074     Accepts a raw cookie header value from the client, extracts the
01075     username and password from it, and uses the resulting credentials
01076     to get a token and populate an HSE_EXEC_URL_USER_INFO structure.
01077
01078     Upon return, pstrCookie will be modified to hold an updated cookie
01079     value, modified to reflect the current time.
01080
01081 Arguments:
01082
01083     pstrCookie - The raw cookie value to process
01084     szClientIP - The IP address of the client
01085     pUserInfo  - The caller's HSE_EXEC_URL_USER_INFO to popluate
01086     pstrUser   - Upon return, contains the processed username
01087
01088 Returns:
01089
01090     TRUE on success, FALSE on failure.
01091
01092 --*/
01093 {
01094     ISAPI_STRING    strLastVisit;
01095     ISAPI_STRING    strCredentials;
01096     ISAPI_STRING    strPassword;
01097     ISAPI_STRING    strUpdatedCredentials;
01098     FILETIME        ftLastVisit;
01099     CHAR *          pCursor;
01100     CHAR *          pDelimiter;
01101     HANDLE          hToken = NULL;
01102     BOOL            fResult;
01103
01104     //
01105     // Get the credentials from the cookie
01106     //
01107
01108     pCursor = pstrCookie->FindStr( "customauth=", TRUE );
01109
01110     if ( pCursor == NULL )
01111     {
01112         //
01113         // credentials not found
01114         //
01115
01116         goto Failed;
01117     }
01118
01119     pCursor += sizeof("customauth=") - 1;
01120
01121     pDelimiter = strchr( pCursor, ';' );
01122
01123     if ( pDelimiter != NULL )
01124     {
01125         if ( pDelimiter == pCursor )
01126         {
01127             //
01128             // Empty CustomAuth value
01129             //
01130
01131             goto Failed;
01132         }
01133
01134         fResult = strCredentials.Copy( pCursor, pDelimiter - pCursor );
01135     }
01136     else
01137     {
01138         if ( *pCursor == '\0' )
01139         {
01140             //
01141             // Empty CustomAuth value
01142             //
01143
01144             goto Failed;
01145         }
01146
01147         fResult = strCredentials.Copy( pCursor );
01148     }
01149
01150     if ( !fResult )
01151     {
01152         goto Failed;
01153     }
01154
01155     //
01156     // Decrypt them.
01157     //
01158
01159     fResult = DecodeAndDecryptCredentials( strCredentials.QueryStr(),
01160                                            szClientIP,
01161                                            pstrUser,
01162                                            &strPassword,
01163                                            &ftLastVisit );
01164
01165     if ( !fResult )
01166     {
01167         goto Failed;
01168     }
01169
01170     //
01171     // If the last visit is older than the logon timeout period,
01172     // then fail.
01173     //
01174
01175     if ( g_LogonTimeoutSeconds )
01176     {
01177         FILETIME    ftCurrent;
01178
01179         if ( GetCurrentTimeAsFileTime( &ftCurrent ) == FALSE )
01180         {
01181             goto Failed;
01182         }
01183
01184         if ( DiffFileTimeInSeconds( &ftLastVisit, &ftCurrent ) > (DWORD)g_LogonTimeoutSeconds )
01185         {
01186             SetLastError( ERROR_SEM_TIMEOUT );
01187             goto Failed;
01188         }
01189     }
01190
01191     //
01192     // Update the cookie
01193     //
01194
01195     if ( EncryptAndEncodeCredentials( pstrUser->QueryStr(),
01196                                       strPassword.QueryStr(),
01197                                       szClientIP,
01198                                       &strUpdatedCredentials ) == FALSE )
01199     {
01200         goto Failed;
01201     }
01202
01203     if ( pstrCookie->Printf( "CustomAuth=%s; Path=/",
01204                              strUpdatedCredentials.QueryStr() ) == FALSE )
01205     {
01206         goto Failed;
01207     }
01208
01209     //
01210     // Log on the user
01211     //
01212
01213     fResult = LogonUser( pstrUser->QueryStr(),
01214                          NULL,
01215                          strPassword.QueryStr(),
01216                          g_LogonType,
01217                          LOGON32_PROVIDER_DEFAULT,
01218                          &hToken );
01219
01220     //
01221     // Regardless of the result, we are done with the password
01222     //
01223
01224     strPassword.ZeroBuffer();
01225
01226     if ( !fResult )
01227     {
01228         goto Failed;
01229     }
01230
01231     //
01232     // Populate the user info from the caller
01233     //
01234
01235     pUserInfo->hImpersonationToken = hToken;
01236     pUserInfo->pszCustomUserName = pstrUser->QueryStr();
01237     pUserInfo->pszCustomAuthType = "CustomAuth";
01238
01239     return TRUE;
01240
01241 Failed:
01242
01243     WriteDebug( "GetUserInfoAndUpdateCookie failed.  Error %d.\r\n",
01244                 GetLastError() );
01245
01246     if ( hToken != NULL )
01247     {
01248         CloseHandle( hToken );
01249         hToken = NULL;
01250     }
01251
01252     return FALSE;
01253 }
01254
01255 BOOL
01256 EncryptAndEncodeCredentials(
01257     CHAR *          szUser,
01258     CHAR *          szPassword,
01259     CHAR *          szClientIP,
01260     ISAPI_STRING *  pstrResult
01261     )
01262 /*++
01263
01264 Purpose:
01265
01266     Accepts username and password information from the caller,
01267     encrypts and base64 encodes the data, and populates an
01268     ISAPI_STRING with the result.  The client's IP address is
01269     used in the encryption process to ensure that only requests
01270     from this same client will be able to decrypt them.
01271
01272 Arguments:
01273
01274     szUser     - The user name to encrypt
01275     szPassword - The password to encrypt
01276     szClientIP - The client's IP address
01277     pstrResult - On successful return, contains the result
01278
01279 Returns:
01280
01281     TRUE on success, FALSE on failure.
01282
01283 --*/
01284 {
01285     DATA_BLOB       ClearBlob = {0};
01286     DATA_BLOB       EncryptedBlob = {0};
01287     DATA_BLOB       EntropyBlob = {0};
01288     ISAPI_STRING    strEncodedUser;
01289     ISAPI_STRING    strEncodedPassword;
01290     ISAPI_STRING    strCurrentTime;
01291     ISAPI_STRING    strCookedCredentials;
01292     BOOL            fResult = FALSE;
01293
01294     //
01295     // Encode the username and credentials
01296     //
01297
01298     if ( strEncodedUser.Copy( szUser ) == FALSE )
01299     {
01300         goto Done;
01301     }
01302
01303     if ( strEncodedUser.Escape( TRUE ) == FALSE )
01304     {
01305         goto Done;
01306     }
01307
01308     if ( strEncodedPassword.Copy( szPassword ) == FALSE )
01309     {
01310         goto Done;
01311     }
01312
01313     if ( strEncodedPassword.Escape() == FALSE )
01314     {
01315         goto Done;
01316     }
01317
01318     //
01319     // Get the current time and escape it
01320     //
01321
01322     if ( GetCurrentTimeAsString( &strCurrentTime ) == FALSE )
01323     {
01324         goto Done;
01325     }
01326
01327     if ( strCurrentTime.Escape() == FALSE )
01328     {
01329         goto Done;
01330     }
01331
01332     //
01333     // Create the raw cookie value
01334     //
01335
01336     if ( strCookedCredentials.Printf( "%s#%s#%s",
01337                                        strEncodedUser.QueryStr(),
01338                                        strEncodedPassword.QueryStr(),
01339                                        strCurrentTime.QueryStr() ) == FALSE )
01340     {
01341         goto Done;
01342     }
01343
01344     //
01345     // Set up the input data blobs.
01346     //
01347     // Use the client IP for the entropy blob, and
01348     // cooked credentials for the clear data blob.
01349     //
01350
01351     EntropyBlob.pbData = (BYTE*)szClientIP;
01352     EntropyBlob.cbData = strlen( szClientIP );
01353
01354     ClearBlob.pbData = (BYTE*)strCookedCredentials.QueryStr();
01355     ClearBlob.cbData = strCookedCredentials.QueryCB() + sizeof(CHAR);
01356
01357     //
01358     // Encrypt the data.  Zero out the clear data blob right afterward.
01359     //
01360
01361     if ( CryptProtectData( &ClearBlob,
01362                            L"",
01363                            g_fUseClientIpForEncryption ? &EntropyBlob : NULL,
01364                            NULL,
01365                            NULL,
01366                            CRYPTPROTECT_UI_FORBIDDEN,
01367                            &EncryptedBlob ) == FALSE )
01368     {
01369         goto Done;
01370     }
01371
01372     //
01373     // Now encode the data into the caller's buffer
01374     //
01375
01376     fResult = pstrResult->Base64Encode( EncryptedBlob.pbData,
01377                                         EncryptedBlob.cbData );
01378
01379 Done:
01380
01381     if ( fResult == FALSE )
01382     {
01383         WriteDebug( "EncryptAndEncodeCredentials failed.  Error %d.\r\n",
01384                     GetLastError() );
01385     }
01386
01387     //
01388     // Clean up data structures
01389     //
01390
01391     if ( EncryptedBlob.pbData )
01392     {
01393         LocalFree( EncryptedBlob.pbData );
01394         EncryptedBlob.pbData = NULL;
01395         EncryptedBlob.cbData = 0;
01396     }
01397
01398     //
01399     // Zero out our buffer that held the cooked credentials
01400     //
01401
01402     strCookedCredentials.ZeroBuffer();
01403
01404     return fResult;
01405 }
01406
01407 BOOL
01408 DecodeAndDecryptCredentials(
01409     CHAR *          szCredentials,
01410     CHAR *          szClientIP,
01411     ISAPI_STRING *  pstrUser,
01412     ISAPI_STRING *  pstrPassword,
01413     FILETIME *      pft
01414     )
01415 /*++
01416
01417 Purpose:
01418
01419     Accepts a string from the caller containing credentials
01420     that have been encrypted and base64 encoded, and returns
01421     the username and password.  The correct client's IP
01422     address is required to successfully complete the process.
01423
01424 Arguments:
01425
01426     szCredentials - The encrypted and encoded credentials
01427     szClientIP    - The client's IP address
01428     pstrUser      - On successful return, contains the username
01429     pstrPassword  - On successful return, contains the password
01430     pft           - On successful return, contains the time stamp
01431
01432 Returns:
01433
01434     TRUE on success, FALSE on failure.
01435
01436 --*/
01437 {
01438     DATA_BLOB       ClearData = {0};
01439     DATA_BLOB       EncryptedData = {0};
01440     DATA_BLOB       EntropyData = {0};
01441     ISAPI_BUFFER    Buffer;
01442     ISAPI_STRING    strTimeStamp;
01443     CHAR *          pUsername;
01444     CHAR *          pPassword;
01445     CHAR *          pTimeStamp;
01446     CHAR *          pCursor;
01447     BOOL            fResult = FALSE;
01448
01449     //
01450     // Decode the credentials
01451     //
01452
01453     if ( Buffer.Base64Decode( szCredentials ) == FALSE )
01454     {
01455         goto Done;
01456     }
01457
01458     //
01459     // Now decrypt them
01460     //
01461
01462     EntropyData.pbData = (BYTE*)szClientIP;
01463     EntropyData.cbData = strlen( szClientIP );
01464
01465     EncryptedData.pbData = (BYTE*)Buffer.QueryPtr();
01466     EncryptedData.cbData = Buffer.QueryDataSize();
01467
01468     if ( CryptUnprotectData( &EncryptedData,
01469                              NULL,
01470                              g_fUseClientIpForEncryption ? &EntropyData : NULL,
01471                              NULL,
01472                              NULL,
01473                              CRYPTPROTECT_UI_FORBIDDEN,
01474                              &ClearData ) == FALSE )
01475     {
01476         goto Done;
01477     }
01478
01479     //
01480     // Now parse the data for the username and password.
01481     // We assume the the code that encrypted the data
01482     // did so with the NULL terminator.
01483     //
01484
01485     pUsername = (CHAR*)ClearData.pbData;
01486
01487     pCursor = strchr( pUsername, '#' );
01488
01489     if ( !pCursor )
01490     {
01491         SetLastError( ERROR_INVALID_PARAMETER );
01492         goto Done;
01493     }
01494
01495     *pCursor = '\0';
01496
01497     pPassword = pCursor + 1;
01498
01499     pCursor = strchr( pPassword, '#' );
01500
01501     if ( !pCursor )
01502     {
01503         SetLastError( ERROR_INVALID_PARAMETER );
01504         goto Done;
01505     }
01506
01507     *pCursor = '\0';
01508
01509     pTimeStamp = pCursor + 1;
01510
01511     if ( pstrUser->Copy( pUsername ) == FALSE )
01512     {
01513         goto Done;
01514     }
01515
01516     pstrUser->Unescape();
01517
01518     if ( pstrPassword->Copy( pPassword ) == FALSE )
01519     {
01520         goto Done;
01521     }
01522
01523     pstrPassword->Unescape();
01524
01525     if ( strTimeStamp.Copy( pTimeStamp ) == FALSE )
01526     {
01527         goto Done;
01528     }
01529
01530     strTimeStamp.Unescape();
01531
01532     if ( GetFileTimeFromString( pft, strTimeStamp.QueryStr() ) == FALSE )
01533     {
01534         goto Done;
01535     }
01536
01537     fResult = TRUE;
01538
01539 Done:
01540
01541     if ( fResult == FALSE )
01542     {
01543         WriteDebug( "DecodeAndDecryptCredentials failed.  Error %d.\r\n",
01544                     GetLastError() );
01545     }
01546
01547     //
01548     // Clean up data structures
01549     //
01550
01551     if ( ClearData.pbData )
01552     {
01553         LocalFree( ClearData.pbData );
01554         ClearData.pbData = 0;
01555         ClearData.cbData = 0;
01556     }
01557
01558     return fResult;
01559 }
01560
01561
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

persistatl::INewsEvent Member List

This is the complete list of members for persistatl::INewsEvent, including all inherited members.
iid | persistatl::INewsEvent | [static]
LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate) | persistatl::INewsEvent |
NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL) | persistatl::INewsEvent |
ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow) | persistatl::INewsEvent |
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CExplorerBar Member List

This is the complete list of members for CExplorerBar, including all inherited members.
CExplorerBar() | CExplorerBar |
CloseDW(DWORD dwReserved) | CExplorerBar |
ContextSensitiveHelp(BOOL) | CExplorerBar |
FocusChange(BOOL) | CExplorerBar | [private]
GetBandInfo(DWORD, DWORD, DESKBANDINFO *) | CExplorerBar |
GetClassID(LPCLSID) | CExplorerBar |
GetSite(REFIID, LPVOID *) | CExplorerBar |
GetSizeMax(ULARGE_INTEGER *) | CExplorerBar |
GetWindow(HWND *) | CExplorerBar |
HasFocusIO(void) | CExplorerBar |
IsDirty(void) | CExplorerBar |
Load(LPSTREAM) | CExplorerBar |
m_bFocus | CExplorerBar | [private]
m_dwBandID | CExplorerBar | [private]
m_dwViewMode | CExplorerBar | [private]
m_hWnd | CExplorerBar | [private]
m_hwndParent | CExplorerBar | [private]
m_ObjRefCount | CExplorerBar | [protected]
m_pSite | CExplorerBar | [private]
OnCommand(WPARAM wParam, LPARAM lParam) | CExplorerBar | [private]
OnKillFocus(void) | CExplorerBar | [private]
OnPaint(void) | CExplorerBar | [private]
OnSetFocus(void) | CExplorerBar | [private]
QueryInterface(REFIID, LPVOID *) | CExplorerBar |
RegisterAndCreateWindow(void) | CExplorerBar | [private]
ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) | CExplorerBar |
Save(LPSTREAM, BOOL) | CExplorerBar |
SetSite(IUnknown *) | CExplorerBar |
ShowDW(BOOL fShow) | CExplorerBar |
STDMETHODIMP_(DWORD) AddRef() | CExplorerBar |
STDMETHODIMP_(DWORD) Release() | CExplorerBar |
TranslateAcceleratorIO(LPMSG) | CExplorerBar |
UIActivateIO(BOOL, LPMSG) | CExplorerBar |
WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) | CExplorerBar | [private, static]
~CExplorerBar() | CExplorerBar |
Generated on Wed Nov 13 2024 16:56:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRTCWin Member List

This is the complete list of members for CRTCWin, including all inherited members.
AddSession(IRTCSession *pSession, RTC_SESSION_TYPE enType) | CRTCWin | [private]
CleanupSessions() | CRTCWin | [private]
ClearBuddyList() | CRTCWin | [private]
CRTCWin() | CRTCWin |
DoAddBuddy(BSTR bstrURI, BSTR bstrName) | CRTCWin | [private]
DoAuth(BSTR bstrURI, BSTR bstrAccount, BSTR bstrPassword) | CRTCWin | [private]
DoCall(RTC_SESSION_TYPE enType, BSTR bstrURI) | CRTCWin | [private]
DoEnablePresence(BOOL fEnable) | CRTCWin | [private]
DoGenerateProvisioning(BSTR bstrURI, BSTR bstrServer, BSTR bstrTransport, BSTR *pbstrXML) | CRTCWin | [private]
DoLogOff() | CRTCWin | [private]
DoLogOn(BSTR bstrURI, BSTR bstrServer, BSTR bstrTransport) | CRTCWin | [private]
DoRemoveBuddy(IRTCBuddy *pBuddy) | CRTCWin | [private]
DoSetPresence(RTC_PRESENCE_STATUS enStatus) | CRTCWin | [private]
DoTuningWizard() | CRTCWin | [private]
FindSession(IRTCSession *pSession, CRTCSession **ppSessWindow) | CRTCWin | [private]
GetUserURI(BSTR *pbstrURI) | CRTCWin |
m_enState | CRTCWin | [private]
m_fPresenceEnabled | CRTCWin | [private]
m_hBuddyList | CRTCWin | [private]
m_hStatusBar | CRTCWin | [private]
m_hWnd | CRTCWin | [private]
m_pClient | CRTCWin | [private]
m_pEvents | CRTCWin | [private]
m_pProfile | CRTCWin | [private]
m_SessionList | CRTCWin | [private]
OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
OnLoggedOff() | CRTCWin | [private]
OnLoggedOn() | CRTCWin | [private]
OnLoggingOff() | CRTCWin | [private]
OnLoggingOn() | CRTCWin | [private]
OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
OnRTCBuddyEvent(IRTCBuddyEvent *pEvent) | CRTCWin | [private]
OnRTCClientEvent(IRTCClientEvent *pEvent) | CRTCWin | [private]
OnRTCEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
OnRTCIntensityEvent(IRTCIntensityEvent *pEvent) | CRTCWin | [private]
OnRTCMediaEvent(IRTCMediaEvent *pEvent) | CRTCWin | [private]
OnRTCMessagingEvent(IRTCMessagingEvent *pEvent) | CRTCWin | [private]
OnRTCParticipantStateChangeEvent(IRTCParticipantStateChangeEvent *pEvent) | CRTCWin | [private]
OnRTCRegistrationStateChangeEvent(IRTCRegistrationStateChangeEvent *pEvent) | CRTCWin | [private]
OnRTCSessionStateChangeEvent(IRTCSessionStateChangeEvent *pEvent) | CRTCWin | [private]
OnRTCWatcherEvent(IRTCWatcherEvent *pEvent) | CRTCWin | [private]
OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [private]
RegisterClass() | CRTCWin | [static]
RemoveSession(CRTCSession *pSessWindow) | CRTCWin |
SetStatusText(PWSTR szText) | CRTCWin | [private]
ShowMessageBox(PWSTR szText) | CRTCWin | [private]
UpdateBuddyList(IRTCBuddy *pBuddy) | CRTCWin | [private]
WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCWin | [static]
~CRTCWin() | CRTCWin |
Generated on Wed Nov 13 2024 16:57:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/GenericUCP/CPP/deviceprop.cpp Source File

  • NetDS
  • upnp
  • GenericUCP
  • CPP

deviceprop.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005
00006 --*/
00007
00008 // DeviceProp.cpp : implementation file
00009 //
00010
00011 #include "stdafx.h"
00012 #include "genericucp.h"
00013 #include "DeviceProp.h"
00014
00015 #ifdef _DEBUG
00016 #define new DEBUG_NEW
00017 #undef THIS_FILE
00018 static char THIS_FILE[] = __FILE__;
00019 #endif
00020
00021 #define DATA_BUFSIZE 2048
00022 /////////////////////////////////////////////////////////////////////////////
00023 // DeviceProp dialog
00024
00025
00026 CDeviceProp::CDeviceProp(IUPnPDevice* pDevice, CWnd* pParent)
00027 : CDialog(CDeviceProp::IDD, pParent)
00028 {
00029   //{{AFX_DATA_INIT(CDeviceProp)
00030   //}}AFX_DATA_INIT
00031     pCurrentDevice=pDevice;
00032   pCurrentDevice->AddRef();
00033 }
00034
00035 CDeviceProp::~CDeviceProp(){
00036
00037   pCurrentDevice->Release();
00038 }
00039
00040 void CDeviceProp::DoDataExchange(CDataExchange* pDX)
00041 {
00042   CDialog::DoDataExchange(pDX);
00043   //{{AFX_DATA_MAP(CDeviceProp)
00044   DDX_Control(pDX, IDC_OK, m_OkButton);
00045   DDX_Control(pDX, IDC_EDITUPC, m_UPC);
00046   DDX_Control(pDX, IDC_EDITUDN, m_UDN);
00047   DDX_Control(pDX, IDC_EDITSERIALNUMBER, m_SerialNumber);
00048   DDX_Control(pDX, IDC_EDITPRESENTATIONURL, m_PresentationUrl);
00049   DDX_Control(pDX, IDC_EDITMODELURL, m_ModelUrl);
00050   DDX_Control(pDX, IDC_EDITMODELNUMBER, m_ModelNumber);
00051   DDX_Control(pDX, IDC_EDITMODELNAME, m_ModelName);
00052   DDX_Control(pDX, IDC_EDITMODELDESCRIPTION, m_ModelDescription);
00053   DDX_Control(pDX, IDC_EDITMANUFACTURERURL, m_ManufacturerUrl);
00054   DDX_Control(pDX, IDC_EDITMANUFACTURER, m_Manufacturer);
00055   DDX_Control(pDX, IDC_EDITFRIENDLYNAME, m_FriendlyName);
00056   DDX_Control(pDX, IDC_EDITDEVICETYPE, m_DeviceType);
00057   //}}AFX_DATA_MAP
00058 }
00059
00060
00061 BEGIN_MESSAGE_MAP(CDeviceProp, CDialog)
00062   //{{AFX_MSG_MAP(CDeviceProp)
00063   ON_BN_CLICKED(IDC_OK, OnOk)
00064   //}}AFX_MSG_MAP
00065 END_MESSAGE_MAP()
00066
00067 /////////////////////////////////////////////////////////////////////////////
00068 // DeviceProp message handlers
00069
00070 void CDeviceProp::OnOk()
00071 {
00072   // TODO: Add your control notification handler code here
00073   EndDialog(1);
00074   return;
00075 }
00076
00077 //+---------------------------------------------------------------------------
00078 //
00079 //  Member:   OnInitDialog
00080 //
00081 //  Purpose:    Initialization of the dialog box.
00082 //
00083 //  Arguments:
00084 //        None
00085 //
00086 //  Returns:    TRUE
00087 //
00088 //  Notes:
00089 //
00090 //
00091
00092
00093
00094 BOOL CDeviceProp::OnInitDialog()
00095 {
00096     CDialog::OnInitDialog();
00097
00098   HRESULT hr=S_OK;
00099   BSTR  bstrTemp = NULL;
00100
00101   // Print all the properties to the respective edit boxes.
00102
00103   hr=pCurrentDevice->get_UniqueDeviceName(&bstrTemp);
00104   PrintTextToEditBox(&m_UDN, bstrTemp, hr);
00105   SysFreeString(bstrTemp);
00106
00107   hr=pCurrentDevice->get_FriendlyName(&bstrTemp);
00108   PrintTextToEditBox(&m_FriendlyName, bstrTemp, hr);
00109   SysFreeString(bstrTemp);
00110
00111   hr=pCurrentDevice->get_Type(&bstrTemp);
00112   PrintTextToEditBox(&m_DeviceType, bstrTemp, hr);
00113   SysFreeString(bstrTemp);
00114
00115   hr=pCurrentDevice->get_PresentationURL(&bstrTemp);
00116   PrintTextToEditBox(&m_PresentationUrl, bstrTemp, hr);
00117   SysFreeString(bstrTemp);
00118
00119   hr=pCurrentDevice->get_ManufacturerName(&bstrTemp);
00120   PrintTextToEditBox(&m_Manufacturer, bstrTemp, hr);
00121   SysFreeString(bstrTemp);
00122
00123   hr=pCurrentDevice->get_ManufacturerURL(&bstrTemp);
00124   PrintTextToEditBox(&m_ManufacturerUrl, bstrTemp, hr);
00125   SysFreeString(bstrTemp);
00126
00127   hr=pCurrentDevice->get_ModelName(&bstrTemp);
00128   PrintTextToEditBox(&m_ModelName, bstrTemp, hr);
00129   SysFreeString(bstrTemp);
00130
00131   hr=pCurrentDevice->get_ModelNumber(&bstrTemp);
00132   PrintTextToEditBox(&m_ModelNumber, bstrTemp, hr);
00133   SysFreeString(bstrTemp);
00134
00135   hr=pCurrentDevice->get_Description(&bstrTemp);
00136   PrintTextToEditBox(&m_ModelDescription, bstrTemp, hr);
00137   SysFreeString(bstrTemp);
00138
00139   hr=pCurrentDevice->get_ModelURL(&bstrTemp);
00140   PrintTextToEditBox(&m_ModelUrl, bstrTemp, hr);
00141   SysFreeString(bstrTemp);
00142
00143   hr=pCurrentDevice->get_UPC(&bstrTemp);
00144   PrintTextToEditBox(&m_UPC, bstrTemp, hr);
00145   SysFreeString(bstrTemp);
00146
00147   hr=pCurrentDevice->get_SerialNumber(&bstrTemp);
00148   PrintTextToEditBox(&m_SerialNumber, bstrTemp, hr);
00149   SysFreeString(bstrTemp);
00150
00151     return TRUE;
00152 }
00153
00154 //+---------------------------------------------------------------------------
00155 //
00156 //  Member:   PrintTextToEditBox
00157 //
00158 //  Purpose:    Helper function to print to appropriate text box
00159 //
00160 //  Arguments:
00161 //        None
00162 //
00163 //  Returns:
00164 //        None
00165 //
00166 //  Notes:
00167 //
00168 //
00169
00170 void CDeviceProp::PrintTextToEditBox(CEdit *pEditBox, BSTR bstrPrintText, HRESULT hrCheck)
00171 {
00172   TCHAR tszPropertyString[DATA_BUFSIZE];
00173   if( hrCheck != S_OK ){
00174     PrintErrorText(hrCheck);
00175   }
00176   else{
00177     _sntprintf(tszPropertyString, DATA_BUFSIZE-1, _T("%S"), bstrPrintText);
00178     (*pEditBox).SetWindowText(tszPropertyString);
00179   }
00180
00181 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Rename/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Rename
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Rename.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/globals.h Source File

  • SysMgmt
  • MMC
  • Proppage

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025         #define IDM_BUTTON1    0x100
00026         #define IDM_BUTTON2    0x101
00027
00028         extern HINSTANCE g_hinst;
00029         extern ULONG g_uObjects;
00030
00031         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034         // uncomment the following #define to enable message cracking
00035         // #define MMC_CRACK_MESSAGES
00036         void MMCN_Crack(BOOL bComponentData,
00037                                         IDataObject *pDataObject,
00038                                         IComponentData *pCompData,
00039                                         IComponent *pComp,
00040                                         MMC_NOTIFY_TYPE event,
00041                                         LPARAM arg,
00042                                         LPARAM param);
00043 #endif
00044
00045 //=--------------------------------------------------------------------------=
00046 // allocates a temporary buffer that will disappear when it goes out of scope
00047 // NOTE: be careful of that -- make sure you use the string in the same or
00048 // nested scope in which you created this buffer. people should not use this
00049 // class directly.  use the macro(s) below.
00050 //
00051 class TempBuffer {
00052   public:
00053     TempBuffer(ULONG cBytes) {
00054         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00055         m_fHeapAlloc = (cBytes > 120);
00056     }
00057     ~TempBuffer() {
00058         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00059     }
00060     void *GetBuffer() {
00061         return m_pBuf;
00062     }
00063
00064   private:
00065     void *m_pBuf;
00066     // we'll use this temp buffer for small cases.
00067     //
00068     char  m_szTmpBuf[120];
00069     unsigned m_fHeapAlloc:1;
00070 };
00071
00072 //=--------------------------------------------------------------------------=
00073 // string helpers.
00074 //
00075 // given a _TCHAR, copy it into a wide buffer.
00076 // be careful about scoping when using this macro!
00077 //
00078 // how to use the below two macros:
00079 //
00080 //  ...
00081 //  LPTSTR pszT;
00082 //  pszT = MyGetTStringRoutine();
00083 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00084 //  MyUseWideStringRoutine(pwsz);
00085 //  ...
00086 #ifdef UNICODE
00087 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00088     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00089     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00090     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00091     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00092 #else // ANSI
00093 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00094     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00095     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00096     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00097     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00098     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00099 #endif
00100
00101 #ifdef UNICODE
00102 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00103     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00104     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00105     lstrcpyW((LPWSTR)ptrname, tstr)
00106 #else // ANSI
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00109     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00110     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00111     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00112 #endif
00113
00114 //
00115 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00116 // have to be declared, and no clean up must be done.
00117 //
00118 // * 2 for DBCS handling in below length computation
00119 //
00120 #ifdef UNICODE
00121 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00122     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00123     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00124     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00125     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00126 #else // ANSI
00127 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00128     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00129     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00130     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00131     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00132 #endif
00133
00134 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/MultiUI/Resource.h Source File

  • WinUI
  • Input
  • Ime
  • MultiUI

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by multcon.RC
00004 //
00005 #define IDM_ABOUT                        40003
00006
00007 // Next default values for new objects
00008 //
00009 #ifdef APSTUDIO_INVOKED
00010 #ifndef APSTUDIO_READONLY_SYMBOLS
00011 #define _APS_NO_MFC                     1
00012 #define _APS_NEXT_RESOURCE_VALUE        102
00013 #define _APS_NEXT_COMMAND_VALUE         40002
00014 #define _APS_NEXT_CONTROL_VALUE         1003
00015 #define _APS_NEXT_SYMED_VALUE           101
00016 #endif
00017 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagFILEOBJECT Member List

This is the complete list of members for _tagFILEOBJECT, including all inherited members.
fDirectory | _tagFILEOBJECT
fLastUpdateValid | _tagFILEOBJECT
fName | _tagFILEOBJECT
ftLastUpdate | _tagFILEOBJECT
genericItem | _tagFILEOBJECT
pChildList | _tagFILEOBJECT
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCertEncodeBitString Member List

This is the complete list of members for CCertEncodeBitString, including all inherited members.
_Cleanup(VOID) | CCertEncodeBitString | [private]
_SetErrorInfo(IN HRESULT hrError, IN WCHAR const *pwszDescription) | CCertEncodeBitString | [private]
CCertEncodeBitString() | CCertEncodeBitString | [inline]
Encode(LONG BitCount, BSTR strBitString, BSTR *pstrBinary) | CCertEncodeBitString |
GetBitString(BSTR __RPC_FAR *pstrBitString) | CCertEncodeBitString |
m_cBits | CCertEncodeBitString | [private]
m_DecodeInfo | CCertEncodeBitString | [private]
~CCertEncodeBitString() | CCertEncodeBitString |
Generated on Wed Nov 13 2024 16:55:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Common/Inc/MtsUserEventObj.Idl Source File

  • Com
  • Common
  • Inc

MtsUserEventObj.Idl

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 ********************************************************************************
00004 * Filename: MtsUserEventObj.idl
00005 *
00006 * Description:
00007 *
00008 * This file is provided as part of the Microsoft Transaction Server
00009 * Software Development Kit
00010 *
00011 *THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00012 *WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00013 *INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00014 *OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
00015 *PURPOSE.
00016 *
00017 * Copyright (C) 1997 Microsoft Corporation, All rights reserved
00018 ********************************************************************************
00019 \******************************************************************************/
00020 // MtsUserEventObj.idl : IDL source for MtsUserEventObj.dll
00021 //
00022
00023 // This file will be processed by the MIDL tool to
00024 // produce the type library (MtsUserEventObj.tlb) and marshalling code.
00025
00026 import "oaidl.idl";
00027 import "ocidl.idl";
00028
00029   [
00030     object,
00031     uuid(F523E424-8485-11D0-B170-00AA00BA3258),
00032     dual,
00033     helpstring("IMtsUserEventData Interface"),
00034     pointer_default(unique)
00035   ]
00036   interface IMtsUserEventData : IDispatch
00037   {
00038     [propput, id(1), helpstring("property DisplayName")] HRESULT DisplayName([in] BSTR newVal);
00039     [propput, id(2), helpstring("property GuidEventId")] HRESULT GuidEventId([in] BSTR newVal);
00040     [propput, id(3), helpstring("property Value")] HRESULT Value(BSTR sKey, [in] VARIANT * newVal);
00041   };
00042 [
00043   uuid(F523E415-8485-11D0-B170-00AA00BA3258),
00044   version(1.0),
00045   helpstring("MtsUserEventObj 1.0 Type Library")
00046 ]
00047 library MTSUSEREVENTOBJLib
00048 {
00049   importlib("stdole2.tlb");
00050
00051   [
00052     uuid(F523E425-8485-11D0-B170-00AA00BA3258),
00053     helpstring("MtsUserEventData Class")
00054   ]
00055   coclass MtsUserEventData
00056   {
00057     [default] interface IMtsUserEventData;
00058   };
00059 };
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/LSP/extension.cpp Source File

  • NetDS
  • WinSock
  • LSP

extension.cpp

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: extension.cpp
00009 //
00010 // Description:
00011 //
00012 //    This sample illustrates how to develop a layered service provider that is
00013 //    capable of counting all bytes transmitted through a TCP/IP socket.
00014 //
00015 //    This file contains all of the Winsock extension functions that can
00016 //    be monitored by a service provider. This is done by intercepting any
00017 //    WSAIoctl calls with the SIO_GET_EXTENSION_FUNCTION_POINTER (see spi.cpp
00018 //    and WSPIoctl for more info). We substitute our own function pointer so
00019 //    that an application calls into us. Currently we intercept only TransmitFile
00020 //    and AcceptEx.
00021 //
00022
00023 #include "provider.h"
00024
00025 //
00026 // Used to output debug messages
00027 //
00028 static TCHAR        Msg[512];
00029 static ULONG_PTR    EventMask=1;
00030
00031 //
00032 // Function: LoadExtensionFunction
00033 //
00034 // Description:
00035 //    This function dynamically loads the given extension function from the
00036 //    underlying provider. Each extension function checks to see if the
00037 //    corresponding extension function for the lower provider is loaded
00038 //    before calling. If not, it will load it as needed. This is necessary
00039 //    if the app loads the extension function for say TCP and then calls
00040 //    that extension function on a UDP socket. Normally this isn't the case
00041 //    but we're being defensive here.
00042 //
00043 BOOL
00044 LoadExtensionFunction(
00045     FARPROC **func,
00046     GUID ExtensionGuid,
00047     LPWSPIOCTL fnIoctl,
00048     SOCKET  s
00049     )
00050 {
00051     DWORD   dwBytes;
00052     int     rc,
00053             error;
00054
00055     // Use the lower provider's WSPIoctl to load the extension function
00056     rc = fnIoctl(
00057             s,
00058             SIO_GET_EXTENSION_FUNCTION_POINTER,
00059            &ExtensionGuid,
00060             sizeof(GUID),
00061             func,
00062             sizeof(FARPROC),
00063            &dwBytes,
00064             NULL,
00065             NULL,
00066             NULL,
00067            &error
00068             );
00069     if (rc == SOCKET_ERROR)
00070     {
00071         dbgprint("LoadExtensionFunction: WSAIoctl (SIO_GET_EXTENSION_FUNCTION) failed: %d",
00072             error);
00073
00074         return FALSE;
00075     }
00076     else
00077     {
00078         return TRUE;
00079     }
00080 }
00081
00082 //
00083 // Function: ExtTransmitFile
00084 //
00085 // Description:
00086 //    This is our provider's TransmitFile function. When an app calls WSAIoctl
00087 //    to request the function pointer to TransmitFile, we intercept the call
00088 //    and return a pointer to our extension function instead.
00089 //
00090 BOOL PASCAL FAR ExtTransmitFile (
00091     IN SOCKET hSocket,
00092     IN HANDLE hFile,
00093     IN DWORD nNumberOfBytesToWrite,
00094     IN DWORD nNumberOfBytesPerSend,
00095     IN LPOVERLAPPED lpOverlapped,
00096     IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
00097     IN DWORD dwFlags)
00098 {
00099   SOCK_INFO          *SocketContext;
00100   LPWSAOVERLAPPEDPLUS ProviderOverlapped;
00101   int                 Errno,
00102                         ret;
00103
00104     // Get the context
00105     SocketContext = FindAndLockSocketContext(hSocket, &Errno);
00106     if (SocketContext == NULL)
00107     {
00108         dbgprint("ExtTransmitFile: WPUQuerySocketHandleContext() failed: %d", Errno);
00109         WSASetLastError(Errno);
00110     return FALSE;
00111     }
00112
00113     // Make sure we already have the extension function
00114     if (!SocketContext->Provider->NextProcTableExt.lpfnTransmitFile)
00115     {
00116         GUID    guidTransmitFile = WSAID_TRANSMITFILE;
00117
00118         if (LoadExtensionFunction(
00119                 (FARPROC **)&SocketContext->Provider->NextProcTableExt.lpfnTransmitFile,
00120                 guidTransmitFile,
00121                 SocketContext->Provider->NextProcTable.lpWSPIoctl,
00122                 SocketContext->ProviderSocket
00123                 ) == FALSE)
00124         {
00125             UnlockSocketContext(SocketContext, &Errno);
00126             dbgprint("Next proc table TransmitFile == NULL!");
00127             WSASetLastError(WSAEFAULT);
00128             return FALSE;
00129         }
00130     }
00131
00132   // Check for overlapped I/O
00133
00134   if (lpOverlapped)
00135   {
00136     ProviderOverlapped = GetOverlappedStructure(SocketContext);
00137         if (!ProviderOverlapped)
00138         {
00139             UnlockSocketContext(SocketContext, &Errno);
00140             dbgprint("ExtTransmitFile: GetOverlappedStructure() returned NULL!");
00141             WSASetLastError(WSAENOBUFS);
00142             return FALSE;
00143         }
00144         // Verify the event is valid
00145         __try {
00146             if ( lpOverlapped->hEvent != NULL )
00147             {
00148                 ret = ResetEvent((HANDLE)((ULONG_PTR)lpOverlapped->hEvent & ~EventMask));
00149                 if (ret == 0)
00150                 {
00151                     // Return to original state and indicate error
00152                     (SocketContext->dwOutstandingAsync)--;
00153                     UnlockSocketContext(SocketContext, &Errno);
00154                     PutbackOverlappedStructure(ProviderOverlapped);
00155                     WSASetLastError(ERROR_INVALID_HANDLE);
00156                     return FALSE;
00157                 }
00158             }
00159             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
00160         }
00161         __except(EXCEPTION_EXECUTE_HANDLER)
00162         {
00163             // Return to original state and indicate error
00164             (SocketContext->dwOutstandingAsync)--;
00165             UnlockSocketContext(SocketContext, &Errno);
00166             PutbackOverlappedStructure(ProviderOverlapped);
00167             WSASetLastError(WSAEFAULT);
00168             return FALSE;
00169         }
00170         //
00171         // Save off the arguments and setup the overlapped structure
00172         //
00173         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
00174         ProviderOverlapped->SockInfo           = SocketContext;
00175         ProviderOverlapped->CallerSocket       = hSocket;
00176         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
00177         ProviderOverlapped->Error              = NO_ERROR;
00178         ProviderOverlapped->Operation          = LSP_OP_TRANSMITFILE;
00179         ProviderOverlapped->lpCallerCompletionRoutine              = NULL;
00180         ProviderOverlapped->TransmitFileArgs.hFile                 = hFile;
00181         ProviderOverlapped->TransmitFileArgs.nNumberOfBytesToWrite = nNumberOfBytesToWrite;
00182         ProviderOverlapped->TransmitFileArgs.nNumberOfBytesPerSend = nNumberOfBytesPerSend;
00183         ProviderOverlapped->TransmitFileArgs.lpTransmitBuffers     = lpTransmitBuffers;
00184         ProviderOverlapped->TransmitFileArgs.dwFlags               = dwFlags;
00185         ProviderOverlapped->Provider = SocketContext->Provider;
00186
00187         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
00188
00189         if (ret != NO_ERROR)
00190         {
00191             WSASetLastError(ret);
00192             ret = FALSE;
00193         }
00194         else
00195         {
00196             ret = TRUE;
00197         }
00198   }
00199   else
00200   {
00201     ret = SocketContext->Provider->NextProcTableExt.lpfnTransmitFile(
00202       SocketContext->ProviderSocket,
00203       hFile,
00204       nNumberOfBytesToWrite,
00205       nNumberOfBytesPerSend,
00206       NULL,
00207       lpTransmitBuffers,
00208       dwFlags);
00209   }
00210
00211     UnlockSocketContext(SocketContext, &Errno);
00212
00213     return ret;
00214 }
00215
00216 //
00217 // Function: ExtAcceptEx
00218 //
00219 // Description:
00220 //    This is our provider's AcceptEx function. When an app calls WSAIoctl
00221 //    to request the function pointer to AcceptEx, we intercept the call
00222 //    and return a pointer to our extension function instead.
00223 //
00224 BOOL PASCAL FAR ExtAcceptEx(
00225   IN SOCKET sListenSocket,
00226   IN SOCKET sAcceptSocket,
00227   IN PVOID lpOutputBuffer,
00228   IN DWORD dwReceiveDataLength,
00229   IN DWORD dwLocalAddressLength,
00230   IN DWORD dwRemoteAddressLength,
00231   OUT LPDWORD lpdwBytesReceived,
00232   IN LPOVERLAPPED lpOverlapped)
00233 {
00234   LPWSAOVERLAPPEDPLUS ProviderOverlapped;
00235   SOCK_INFO          *ListenSocketContext=NULL,
00236                      *AcceptSocketContext=NULL;
00237   int                 Errno,
00238                         ret;
00239
00240
00241     //
00242     // Query the socket context for the listening socket
00243     //
00244     ListenSocketContext = FindAndLockSocketContext(sListenSocket, &Errno);
00245     if (ListenSocketContext == NULL)
00246     {
00247         dbgprint("AcceptExExt: WPUQuerySocketHandleContext "
00248                   "on listen socket failed: %d", Errno);
00249         Errno = WSAENOTSOCK;
00250         WSASetLastError(Errno);
00251     return FALSE;
00252     }
00253     //
00254     // Also need to query the socket context for the accept socket
00255     //
00256     AcceptSocketContext = FindAndLockSocketContext(sAcceptSocket, &Errno);
00257     if (AcceptSocketContext == NULL)
00258     {
00259         UnlockSocketContext(ListenSocketContext, &Errno);
00260
00261         dbgprint("AcceptExExt: WPUQuerySocketHandleContext "
00262                   "on accept socket failed: %d", Errno);
00263         Errno = WSAENOTSOCK;
00264         WSASetLastError(Errno);
00265     return FALSE;
00266     }
00267
00268     if (!ListenSocketContext->Provider->NextProcTableExt.lpfnAcceptEx)
00269     {
00270         GUID    guidAcceptEx = WSAID_ACCEPTEX;
00271
00272         if (LoadExtensionFunction(
00273                 (FARPROC **)&ListenSocketContext->Provider->NextProcTableExt.lpfnAcceptEx,
00274                 guidAcceptEx,
00275                 ListenSocketContext->Provider->NextProcTable.lpWSPIoctl,
00276                 ListenSocketContext->ProviderSocket
00277                 ) == FALSE)
00278         {
00279             UnlockSocketContext(ListenSocketContext, &Errno);
00280             UnlockSocketContext(AcceptSocketContext, &Errno);
00281
00282             dbgprint("Lower provider AcceptEx == NULL!");
00283             WSASetLastError(WSAEFAULT);
00284             return FALSE;
00285         }
00286     }
00287
00288   // Check for overlapped I/O
00289
00290   if (lpOverlapped)
00291   {
00292     ProviderOverlapped = GetOverlappedStructure(ListenSocketContext);
00293         if (!ProviderOverlapped)
00294         {
00295             UnlockSocketContext(ListenSocketContext, &Errno);
00296             UnlockSocketContext(AcceptSocketContext, &Errno);
00297
00298             dbgprint("ExtAcceptEx: GetOverlappedStructre() returne NULL!");
00299             WSASetLastError(WSAENOBUFS);
00300             return FALSE;
00301         }
00302
00303         // Verify the event is valid
00304         __try {
00305             if ( lpOverlapped->hEvent != NULL )
00306             {
00307                 ret = ResetEvent((HANDLE)((ULONG_PTR)lpOverlapped->hEvent & ~EventMask));
00308                 if (ret == 0)
00309                 {
00310                     // Return to original state and indicate error
00311                     (ListenSocketContext->dwOutstandingAsync)--;
00312
00313                     UnlockSocketContext(ListenSocketContext, &Errno);
00314                     UnlockSocketContext(AcceptSocketContext, &Errno);
00315
00316                     PutbackOverlappedStructure(ProviderOverlapped);
00317                     WSASetLastError(ERROR_INVALID_HANDLE);
00318                     return FALSE;
00319                 }
00320             }
00321             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
00322             ProviderOverlapped->AcceptExArgs.dwBytesReceived = (lpdwBytesReceived ? *lpdwBytesReceived : 0);
00323         }
00324         __except(EXCEPTION_EXECUTE_HANDLER)
00325         {
00326             // Return to original state and indicate error
00327             (ListenSocketContext->dwOutstandingAsync)--;
00328
00329             UnlockSocketContext(ListenSocketContext, &Errno);
00330             UnlockSocketContext(AcceptSocketContext, &Errno);
00331
00332             PutbackOverlappedStructure(ProviderOverlapped);
00333             WSASetLastError(WSAEFAULT);
00334             return FALSE;
00335         }
00336         //
00337         // Save off the paramters and initalize the overlapped structure
00338         //
00339         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
00340         ProviderOverlapped->SockInfo           = ListenSocketContext;
00341         ProviderOverlapped->CallerSocket       = sListenSocket;
00342         ProviderOverlapped->ProviderSocket     = ListenSocketContext->ProviderSocket;
00343         ProviderOverlapped->Error              = NO_ERROR;
00344         ProviderOverlapped->Operation          = LSP_OP_ACCEPTEX;
00345         ProviderOverlapped->lpCallerCompletionRoutine          = NULL;
00346         ProviderOverlapped->AcceptExArgs.sAcceptSocket         = sAcceptSocket;
00347         ProviderOverlapped->AcceptExArgs.sProviderAcceptSocket = AcceptSocketContext->ProviderSocket;
00348         ProviderOverlapped->AcceptExArgs.lpOutputBuffer        = lpOutputBuffer;
00349         ProviderOverlapped->AcceptExArgs.dwReceiveDataLength   = dwReceiveDataLength;
00350         ProviderOverlapped->AcceptExArgs.dwLocalAddressLength  = dwLocalAddressLength;
00351         ProviderOverlapped->AcceptExArgs.dwRemoteAddressLength = dwRemoteAddressLength;
00352         ProviderOverlapped->Provider = AcceptSocketContext->Provider;
00353
00354         ret = QueueOverlappedOperation(ProviderOverlapped, ListenSocketContext);
00355
00356         if (ret != NO_ERROR)
00357         {
00358             WSASetLastError(ret);
00359             ret = FALSE;
00360         }
00361         else
00362         {
00363             ret = TRUE;
00364         }
00365   }
00366   else
00367   {
00368     ret = ListenSocketContext->Provider->NextProcTableExt.lpfnAcceptEx(
00369       ListenSocketContext->ProviderSocket,
00370       AcceptSocketContext->ProviderSocket,
00371       lpOutputBuffer,
00372       dwReceiveDataLength,
00373       dwLocalAddressLength,
00374       dwRemoteAddressLength,
00375       lpdwBytesReceived,
00376       NULL);
00377   }
00378
00379     UnlockSocketContext(ListenSocketContext, &Errno);
00380     UnlockSocketContext(AcceptSocketContext, &Errno);
00381
00382     return ret;
00383 }
00384
00385 //
00386 // Function: ExtConnectEx
00387 //
00388 // Description:
00389 //    This is our provider's ConnectEx function. When an app calls WSAIoctl
00390 //    to request the function pointer to ConnectEx, we intercept the call
00391 //    and return a pointer to our extension function instead.
00392 //
00393 BOOL PASCAL FAR ExtConnectEx(
00394     IN SOCKET s,
00395     IN const struct sockaddr FAR *name,
00396     IN int namelen,
00397     IN PVOID lpSendBuffer OPTIONAL,
00398     IN DWORD dwSendDataLength,
00399     OUT LPDWORD lpdwBytesSent,
00400     IN LPOVERLAPPED lpOverlapped)
00401 {
00402     SOCK_INFO           *SocketContext=NULL;
00403     LPWSAOVERLAPPEDPLUS  ProviderOverlapped=NULL;
00404     int                  Errno,
00405                          ret;
00406
00407     // Get the context
00408     SocketContext = FindAndLockSocketContext(s, &Errno);
00409     if (SocketContext == NULL)
00410     {
00411         dbgprint("ExtConnectEx: WPUQuerySocketHandleContext() failed: %d", Errno);
00412         return FALSE;
00413     }
00414
00415     // Verify the function pointer is correct
00416     if (!SocketContext->Provider->NextProcTableExt.lpfnConnectEx)
00417     {
00418         GUID    guidConnectEx = WSAID_CONNECTEX;
00419
00420         if (LoadExtensionFunction(
00421                 (FARPROC **)&SocketContext->Provider->NextProcTableExt.lpfnConnectEx,
00422                 guidConnectEx,
00423                 SocketContext->Provider->NextProcTable.lpWSPIoctl,
00424                 SocketContext->ProviderSocket
00425                 ) == FALSE)
00426         {
00427             UnlockSocketContext(SocketContext, &Errno);
00428
00429             dbgprint("Next proc table ConnectEx == NULL!");
00430             WSASetLastError(WSAEFAULT);
00431             return FALSE;
00432         }
00433     }
00434
00435     // Check for overlapped I/O
00436
00437     if (lpOverlapped)
00438     {
00439         ProviderOverlapped = GetOverlappedStructure(SocketContext);
00440         if (!ProviderOverlapped)
00441         {
00442             UnlockSocketContext(SocketContext, &Errno);
00443
00444             dbgprint("ExtConnectEx: GetOverlappedStructure() returned NULL");
00445             WSASetLastError(WSAENOBUFS);
00446             return FALSE;
00447         }
00448         //
00449         // Save off the arguments and setup the overlapped structure
00450         //
00451         // Also reset the event handle if present
00452         //
00453         __try {
00454             if ( lpOverlapped->hEvent != NULL )
00455             {
00456                 ret = ResetEvent((HANDLE)((ULONG_PTR)lpOverlapped->hEvent & ~EventMask));
00457                 if (ret == 0)
00458                 {
00459                     // Return to original state and indicate error
00460                     (SocketContext->dwOutstandingAsync)--;
00461                     UnlockSocketContext(SocketContext, &Errno);
00462                     PutbackOverlappedStructure(ProviderOverlapped);
00463                     WSASetLastError(ERROR_INVALID_HANDLE);
00464                     return FALSE;
00465                 }
00466             }
00467             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
00468             if (namelen <= sizeof(ProviderOverlapped->ConnectExArgs.name))
00469                 CopyMemory(&ProviderOverlapped->ConnectExArgs.name, name, namelen);
00470             ProviderOverlapped->ConnectExArgs.dwBytesSent = (lpdwBytesSent ? *lpdwBytesSent : 0);
00471         }
00472         __except(EXCEPTION_EXECUTE_HANDLER)
00473         {
00474             (SocketContext->dwOutstandingAsync)--;
00475             UnlockSocketContext(SocketContext, &Errno);
00476             PutbackOverlappedStructure(ProviderOverlapped);
00477             WSASetLastError(WSAEFAULT);
00478             return FALSE;
00479         }
00480
00481         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
00482         ProviderOverlapped->SockInfo           = SocketContext;
00483         ProviderOverlapped->CallerSocket       = s;
00484         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
00485         ProviderOverlapped->Error              = NO_ERROR;
00486         ProviderOverlapped->Operation          = LSP_OP_CONNECTEX;
00487         ProviderOverlapped->lpCallerCompletionRoutine      = NULL;
00488         ProviderOverlapped->ConnectExArgs.s                = s;
00489         ProviderOverlapped->ConnectExArgs.namelen          = namelen;
00490         ProviderOverlapped->ConnectExArgs.lpSendBuffer     = lpSendBuffer;
00491         ProviderOverlapped->ConnectExArgs.dwSendDataLength = dwSendDataLength;
00492         ProviderOverlapped->Provider           = SocketContext->Provider;
00493
00494         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
00495
00496         if (ret != NO_ERROR)
00497         {
00498             WSASetLastError(ret);
00499             ret = FALSE;
00500         }
00501         else
00502         {
00503             ret = TRUE;
00504         }
00505     }
00506     else
00507     {
00508         ret = SocketContext->Provider->NextProcTableExt.lpfnConnectEx(
00509             SocketContext->ProviderSocket,
00510             name,
00511             namelen,
00512             lpSendBuffer,
00513             dwSendDataLength,
00514             lpdwBytesSent,
00515             NULL);
00516     }
00517     UnlockSocketContext(SocketContext, &Errno);
00518
00519     return ret;
00520 }
00521
00522 //
00523 // Function: ExtTransmitPackets
00524 //
00525 // Description:
00526 //    This is our provider's TransmitPackets function. When an app calls WSAIoctl
00527 //    to request the function pointer to TransmitPackets, we intercept the call
00528 //    and return a pointer to our extension function instead.
00529 //
00530 BOOL PASCAL FAR ExtTransmitPackets(
00531     SOCKET hSocket,
00532     LPTRANSMIT_PACKETS_ELEMENT lpPacketArray,
00533     DWORD nElementCount,
00534     DWORD nSendSize,
00535     LPOVERLAPPED lpOverlapped,
00536     DWORD dwFlags)
00537 {
00538     SOCK_INFO           *SocketContext=NULL;
00539     LPWSAOVERLAPPEDPLUS  ProviderOverlapped=NULL;
00540     int                  Errno,
00541                          ret;
00542
00543     // Get the context
00544     SocketContext = FindAndLockSocketContext(hSocket, &Errno);
00545     if (SocketContext == NULL)
00546     {
00547         dbgprint("ExtTransmitPackets: WPUQuerySocketHandleContext() failed: %d", Errno);
00548         WSASetLastError(Errno);
00549         return FALSE;
00550     }
00551
00552     // Make sure we already have the extension function
00553     if (!SocketContext->Provider->NextProcTableExt.lpfnTransmitPackets)
00554     {
00555         GUID    guidTransmitPackets = WSAID_TRANSMITPACKETS;
00556
00557         if (LoadExtensionFunction(
00558                 (FARPROC **)&SocketContext->Provider->NextProcTableExt.lpfnTransmitPackets,
00559                 guidTransmitPackets,
00560                 SocketContext->Provider->NextProcTable.lpWSPIoctl,
00561                 SocketContext->ProviderSocket
00562                 ) == FALSE)
00563         {
00564             UnlockSocketContext(SocketContext, &Errno);
00565             dbgprint("Next proc table TransmitPackets == NULL!");
00566             WSASetLastError(WSAEFAULT);
00567             return FALSE;
00568         }
00569     }
00570     //
00571     // Check for overlapped I/O
00572     //
00573     if (lpOverlapped)
00574     {
00575         ProviderOverlapped = GetOverlappedStructure(SocketContext);
00576         if (!ProviderOverlapped)
00577         {
00578             UnlockSocketContext(SocketContext, &Errno);
00579             dbgprint("ExtTransmitPackets: GetOverlappedStructure() returned NULL");
00580             WSASetLastError(WSAENOBUFS);
00581             return FALSE;
00582         }
00583         //
00584         // Save off the arguments and setup the overlapped structure
00585         //
00586         // Verify the event is valid
00587         //
00588         __try {
00589             if ( lpOverlapped->hEvent != NULL )
00590             {
00591                 ret = ResetEvent((HANDLE)((ULONG_PTR)lpOverlapped->hEvent & ~EventMask));
00592                 if (ret == 0)
00593                 {
00594                     // Return to original state and indicate error
00595                     (SocketContext->dwOutstandingAsync)--;
00596                     UnlockSocketContext(SocketContext, &Errno);
00597                     PutbackOverlappedStructure(ProviderOverlapped);
00598                     WSASetLastError(ERROR_INVALID_HANDLE);
00599                     return FALSE;
00600                 }
00601             }
00602             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
00603         }
00604         __except(EXCEPTION_EXECUTE_HANDLER)
00605         {
00606             // Return to original state and indicate error
00607             (SocketContext->dwOutstandingAsync)--;
00608             UnlockSocketContext(SocketContext, &Errno);
00609             PutbackOverlappedStructure(ProviderOverlapped);
00610             WSASetLastError(WSAEFAULT);
00611             return FALSE;
00612         }
00613         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
00614         ProviderOverlapped->SockInfo           = SocketContext;
00615         ProviderOverlapped->CallerSocket       = hSocket;
00616         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
00617         ProviderOverlapped->Error              = NO_ERROR;
00618         ProviderOverlapped->Operation          = LSP_OP_TRANSMITPACKETS;
00619         ProviderOverlapped->lpCallerCompletionRoutine           = NULL;
00620         ProviderOverlapped->TransmitPacketsArgs.s               = hSocket;
00621         ProviderOverlapped->TransmitPacketsArgs.lpPacketArray   = lpPacketArray;
00622         ProviderOverlapped->TransmitPacketsArgs.nElementCount   = nElementCount;
00623         ProviderOverlapped->TransmitPacketsArgs.nSendSize       = nSendSize;
00624         ProviderOverlapped->TransmitPacketsArgs.dwFlags         = dwFlags;
00625         ProviderOverlapped->Provider           = SocketContext->Provider;
00626
00627         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
00628
00629         if (ret != NO_ERROR)
00630         {
00631             WSASetLastError(ret);
00632             ret = FALSE;
00633         }
00634         else
00635         {
00636             ret = TRUE;
00637         }
00638
00639     }
00640     else
00641     {
00642         ret = SocketContext->Provider->NextProcTableExt.lpfnTransmitPackets(
00643             SocketContext->ProviderSocket,
00644             lpPacketArray,
00645             nElementCount,
00646             nSendSize,
00647             NULL,
00648             dwFlags);
00649     }
00650     UnlockSocketContext(SocketContext, &Errno);
00651
00652     return ret;
00653 }
00654
00655 //
00656 // Function: ExtDisconnectEx
00657 //
00658 // Description:
00659 //    This is our provider's DisconnectEx function. When an app calls WSAIoctl
00660 //    to request the function pointer to DisconnectEx, we intercept the call
00661 //    and return a pointer to our extension function instead.
00662 //
00663 BOOL PASCAL FAR ExtDisconnectEx(
00664     IN SOCKET s,
00665     IN LPOVERLAPPED lpOverlapped,
00666     IN DWORD  dwFlags,
00667     IN DWORD  dwReserved)
00668 {
00669     SOCK_INFO           *SocketContext=NULL;
00670     LPWSAOVERLAPPEDPLUS  ProviderOverlapped=NULL;
00671     int                  Errno,
00672                          ret;
00673
00674     // Get the context
00675     SocketContext = FindAndLockSocketContext(s, &Errno);
00676     if (SocketContext == NULL)
00677     {
00678         dbgprint("ExtDisconnectEx: WPUQuerySocketHandleContext() failed: %d", Errno);
00679         WSASetLastError(Errno);
00680         return FALSE;
00681     }
00682
00683     // Make sure we already have the extension function
00684     if (!SocketContext->Provider->NextProcTableExt.lpfnDisconnectEx)
00685     {
00686         GUID    guidDisconnectEx = WSAID_DISCONNECTEX;
00687
00688         if (LoadExtensionFunction(
00689                  (FARPROC **)&SocketContext->Provider->NextProcTableExt.lpfnDisconnectEx,
00690                  guidDisconnectEx,
00691                  SocketContext->Provider->NextProcTable.lpWSPIoctl,
00692                  SocketContext->ProviderSocket
00693                  ) == NULL)
00694         {
00695             UnlockSocketContext(SocketContext, &Errno);
00696             dbgprint("Next proc table DisconnectEx == NULL!");
00697             WSASetLastError(WSAEFAULT);
00698             return FALSE;
00699         }
00700     }
00701
00702
00703     // Check for overlapped I/O
00704
00705     if (lpOverlapped)
00706     {
00707         ProviderOverlapped = GetOverlappedStructure(SocketContext);
00708         if (!ProviderOverlapped)
00709         {
00710             UnlockSocketContext(SocketContext, &Errno);
00711             dbgprint("ExtDisconnectEx: GetOverlappedStructure() returned NULL");
00712             WSASetLastError(WSAENOBUFS);
00713             return FALSE;
00714         }
00715         //
00716         // Save off the arguments and setup the overlapped structure
00717         //
00718         // Verify the event is valid
00719         //
00720         __try {
00721             if ( lpOverlapped->hEvent != NULL )
00722             {
00723                 ret = ResetEvent((HANDLE)((ULONG_PTR)lpOverlapped->hEvent & ~EventMask));
00724                 if (ret == 0)
00725                 {
00726                     (SocketContext->dwOutstandingAsync)--;
00727                     PutbackOverlappedStructure(ProviderOverlapped);
00728                     UnlockSocketContext(SocketContext, &Errno);
00729                     WSASetLastError(ERROR_INVALID_HANDLE);
00730                     return FALSE;
00731                 }
00732             }
00733             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
00734         }
00735         __except(EXCEPTION_EXECUTE_HANDLER)
00736         {
00737             (SocketContext->dwOutstandingAsync)--;
00738             PutbackOverlappedStructure(ProviderOverlapped);
00739             UnlockSocketContext(SocketContext, &Errno);
00740             WSASetLastError(WSAEFAULT);
00741             return FALSE;
00742         }
00743
00744         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
00745         ProviderOverlapped->SockInfo           = SocketContext;
00746         ProviderOverlapped->CallerSocket       = s;
00747         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
00748         ProviderOverlapped->Error              = NO_ERROR;
00749         ProviderOverlapped->Operation          = LSP_OP_DISCONNECTEX;
00750         ProviderOverlapped->lpCallerCompletionRoutine           = NULL;
00751         ProviderOverlapped->DisconnectExArgs.s                  = s;
00752         ProviderOverlapped->DisconnectExArgs.dwFlags            = dwFlags;
00753         ProviderOverlapped->DisconnectExArgs.dwReserved         = dwReserved;
00754         ProviderOverlapped->Provider           = SocketContext->Provider;
00755
00756         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
00757
00758         if (ret != NO_ERROR)
00759         {
00760             WSASetLastError(ret);
00761             ret = FALSE;
00762         }
00763         else
00764         {
00765             ret = TRUE;
00766         }
00767     }
00768     else
00769     {
00770         ret = SocketContext->Provider->NextProcTableExt.lpfnDisconnectEx(
00771             SocketContext->ProviderSocket,
00772             lpOverlapped,
00773             dwFlags,
00774             dwReserved);
00775     }
00776     UnlockSocketContext(SocketContext, &Errno);
00777
00778     return ret;
00779 }
00780
00781 //
00782 // Function: ExtWSARecvMsg
00783 //
00784 // Description:
00785 //    This is our provider's WSARecvMsg function. When an app calls WSAIoctl
00786 //    to request the function pointer to WSARecvMsg, we intercept the call
00787 //    and return a pointer to our extension function instead.
00788 //
00789 INT PASCAL FAR ExtWSARecvMsg(
00790     IN SOCKET s,
00791     IN OUT LPWSAMSG lpMsg,
00792     OUT LPDWORD lpdwNumberOfBytesRecvd,
00793     IN LPWSAOVERLAPPED lpOverlapped,
00794     IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
00795 {
00796     SOCK_INFO           *SocketContext=NULL;
00797     LPWSAOVERLAPPEDPLUS  ProviderOverlapped=NULL;
00798     int                  Errno,
00799                          ret = NO_ERROR;
00800
00801     // Get the context
00802     SocketContext = FindAndLockSocketContext(s, &Errno);
00803     if (SocketContext == NULL)
00804     {
00805         dbgprint("ExtWSARecvmsg: WPUQuerySocketHandleContext() failed: %d", Errno);
00806         WSASetLastError(Errno);
00807         return SOCKET_ERROR;
00808     }
00809
00810     // Make sure we already have the extension function
00811     if (!SocketContext->Provider->NextProcTableExt.lpfnWSARecvMsg)
00812     {
00813         GUID    guidWSARecvMsg = WSAID_WSARECVMSG;
00814
00815         if (LoadExtensionFunction(
00816                 (FARPROC **)&SocketContext->Provider->NextProcTableExt.lpfnWSARecvMsg,
00817                 guidWSARecvMsg,
00818                 SocketContext->Provider->NextProcTable.lpWSPIoctl,
00819                 SocketContext->ProviderSocket
00820                 ) == FALSE)
00821         {
00822             UnlockSocketContext(SocketContext, &Errno);
00823             dbgprint("Next proc table WSARecvMsg == NULL!");
00824             WSASetLastError(WSAEFAULT);
00825             return SOCKET_ERROR;
00826         }
00827     }
00828     //
00829     // Check for overlapped I/O
00830     //
00831     if (lpOverlapped)
00832     {
00833         ProviderOverlapped = GetOverlappedStructure(SocketContext);
00834         if (!ProviderOverlapped)
00835         {
00836             UnlockSocketContext(SocketContext, &Errno);
00837             dbgprint("ExtWSARecvMsg: GetOverlappedStructure() returned NULL");
00838             WSASetLastError(WSAENOBUFS);
00839             return SOCKET_ERROR;
00840         }
00841         //
00842         // Save off the arguments and setup the overlapped structure
00843         //
00844         __try {
00845             if (( lpCompletionRoutine == NULL ) && ( lpOverlapped->hEvent != NULL ))
00846             {
00847                 // Verify the event is valid
00848                 ret = ResetEvent((HANDLE)((ULONG_PTR)lpOverlapped->hEvent & ~EventMask));
00849                 if (ret == 0)
00850                 {
00851                     // Return to original state and indicate error
00852                     (SocketContext->dwOutstandingAsync)--;
00853                     UnlockSocketContext(SocketContext, &Errno);
00854                     PutbackOverlappedStructure(ProviderOverlapped);
00855                     WSASetLastError(ERROR_INVALID_HANDLE);
00856                     return SOCKET_ERROR;
00857                 }
00858             }
00859             CopyOffset(&ProviderOverlapped->ProviderOverlapped, lpOverlapped);
00860             ProviderOverlapped->WSARecvMsgArgs.dwNumberOfBytesRecvd = (lpdwNumberOfBytesRecvd ? *lpdwNumberOfBytesRecvd : 0);
00861         }
00862         __except(EXCEPTION_EXECUTE_HANDLER)
00863         {
00864             // Return to original state and indicate error
00865             (SocketContext->dwOutstandingAsync)--;
00866             UnlockSocketContext(SocketContext, &Errno);
00867             PutbackOverlappedStructure(ProviderOverlapped);
00868             WSASetLastError(WSAEFAULT);
00869             return SOCKET_ERROR;
00870         }
00871         ProviderOverlapped->lpCallerOverlapped = lpOverlapped;
00872         ProviderOverlapped->SockInfo           = SocketContext;
00873         ProviderOverlapped->CallerSocket       = s;
00874         ProviderOverlapped->ProviderSocket     = SocketContext->ProviderSocket;
00875         ProviderOverlapped->Error              = NO_ERROR;
00876         ProviderOverlapped->Operation          = LSP_OP_WSARECVMSG;
00877         ProviderOverlapped->lpCallerCompletionRoutine           = lpCompletionRoutine;
00878         ProviderOverlapped->WSARecvMsgArgs.s                    = s;
00879         ProviderOverlapped->WSARecvMsgArgs.lpMsg                = lpMsg;
00880         ProviderOverlapped->Provider           = SocketContext->Provider;
00881
00882         ret = QueueOverlappedOperation(ProviderOverlapped, SocketContext);
00883
00884         if (ret != NO_ERROR)
00885         {
00886             WSASetLastError(ret);
00887             ret = SOCKET_ERROR;
00888         }
00889         else
00890         {
00891             ret = NO_ERROR;
00892         }
00893     }
00894     else
00895     {
00896         ret = SocketContext->Provider->NextProcTableExt.lpfnWSARecvMsg(
00897             SocketContext->ProviderSocket,
00898             lpMsg,
00899             lpdwNumberOfBytesRecvd,
00900             NULL,
00901             NULL);
00902     }
00903
00904     UnlockSocketContext(SocketContext, &Errno);
00905
00906     return ret;
00907 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

fullsvr::AsyncIFullServ Member List

This is the complete list of members for fullsvr::AsyncIFullServ, including all inherited members.
Begin_Sum(int i, int j) | fullsvr::AsyncIFullServ |
Finish_Sum() | fullsvr::AsyncIFullServ |
iid | fullsvr::AsyncIFullServ | [static]
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/RPCssm/RPCssmc.c Source File

  • NetDS
  • RPC
  • RPCssm

RPCssmc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                       rpcssm Example
00005
00006     FILE:       rpcssmc.c
00007
00008     USAGE:      rpcssmc  -n network_address
00009                          -p protocol_sequence
00010                          -e endpoint
00011                          -o options
00012
00013     PURPOSE:    Client side of RPC distributed application
00014
00015     FUNCTIONS:  main() - binds to server and calls remote procedure
00016
00017     COMMENTS:   This distributed application uses the rpcssm package.
00018
00019 ****************************************************************************/
00020
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include "rpcssm.h"    // header file generated by MIDL compiler
00024
00025
00026 #define PURPOSE \
00027 "This Microsoft RPC Version 2.0 sample program demonstrates\n\
00028 the use of the [context_handle] attribute. For more information\n\
00029 about attributes and RPC API functions, see the RPC programming\n\
00030 guide and reference.\n\n"
00031
00032 void AllocateSmList( PBOX * ppBox, short sListSize );
00033 void AllocateList( PBOX * ppBox, short sListSize );
00034 void InitList( PBOX  pBox, long lStartValue );
00035 void FreeList( PBOX  pBox );
00036 void PrintList( PBOX pBox );
00037
00038
00039 void Usage(char * pszProgramName)
00040 {
00041     fprintf(stderr, "%s", PURPOSE);
00042     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00043     fprintf(stderr, " -p protocol_sequence\n");
00044     fprintf(stderr, " -n network_address\n");
00045     fprintf(stderr, " -e endpoint\n");
00046     fprintf(stderr, " -o options\n");
00047     exit(1);
00048 }
00049
00050 void __cdecl main(int argc, char **argv)
00051 {
00052     RPC_STATUS status;
00053     PBOX       pBox = NULL;
00054
00055     unsigned char * pszUuid             = NULL;
00056     unsigned char * pszProtocolSequence = "ncacn_np";
00057     unsigned char * pszNetworkAddress   = NULL;
00058     unsigned char * pszEndpoint         = "\\pipe\\rpcssm";
00059     unsigned char * pszOptions          = NULL;
00060     unsigned char * pszStringBinding    = NULL;
00061     int i;
00062
00063     /* allow the user to override settings with command line switches */
00064     for (i = 1; i < argc; i++) {
00065         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00066             switch (tolower(*(argv[i]+1))) {
00067             case 'p':  // protocol sequence
00068                 pszProtocolSequence = argv[++i];
00069                 break;
00070             case 'n':  // network address
00071                 pszNetworkAddress = argv[++i];
00072                 break;
00073             case 'e':
00074                 pszEndpoint = argv[++i];
00075                 break;
00076             case 'o':
00077                 pszOptions = argv[++i];
00078                 break;
00079             case 'h':
00080             case '?':
00081             default:
00082                 Usage(argv[0]);
00083             }
00084         }
00085         else
00086             Usage(argv[0]);
00087     }
00088
00089     RpcTryExcept {
00090
00091         /* Use a convenience function to concatenate the elements of  */
00092         /* the string binding into the proper sequence.               */
00093         status = RpcStringBindingCompose(pszUuid,
00094                                          pszProtocolSequence,
00095                                          pszNetworkAddress,
00096                                          pszEndpoint,
00097                                          pszOptions,
00098                                          &pszStringBinding);
00099         printf("RpcStringBindingCompose returned 0x%x\n", status);
00100         printf("pszStringBinding = %s\n", pszStringBinding);
00101         if (status) {
00102             exit(status);
00103         }
00104
00105         /* Set the binding handle that will be used to bind to the server. */
00106         status = RpcBindingFromStringBinding(pszStringBinding,
00107                                              &hStarter);
00108         printf("RpcBindingFromStringBinding returned 0x%x\n", status);
00109         if (status) {
00110             exit(status);
00111         }
00112
00113         /* Now a different case: a client stub is in an enabled environment */
00114
00115         status = RpcSmEnableAllocate();
00116         printf("RpcSmEnableAllocate returned 0x%x\n", status);
00117         if (status) {
00118             exit(status);
00119         }
00120
00121         pBox = NULL;
00122         AllocateSmList( &pBox, 4 );
00123         InitList( pBox, 0xabcd0000 );
00124         PrintList( pBox );
00125
00126         printf("Calling the remote procedure InOutList\n");
00127         InOutList( &pBox );
00128         PrintList( pBox );
00129
00130         /* No need to free the memory allocated with RpcSmAllocate,
00131            RpcSmDisableAllocate would free it.
00132         */
00133
00134         status = RpcSmDisableAllocate();
00135         printf("RpcSmDisableAllocate returned 0x%x\n", status);
00136         if (status) {
00137             exit(status);
00138         }
00139
00140         printf(" All nodes from this case freed by RpcSmDisableAllocate().\n" );
00141         printf(" Client with memory environment done.\n\n" );
00142
00143         Shutdown();
00144
00145         /*  Free the string binding */
00146         status = RpcStringFree(&pszStringBinding);
00147         printf("RpcStringFree returned 0x%x\n", status);
00148         if (status) {
00149             exit(status);
00150         }
00151
00152         status = RpcBindingFree(&hStarter);
00153         printf("RpcBindingFree returned 0x%x\n", status);
00154         if (status) {
00155             exit(status);
00156         }
00157     }
00158     RpcExcept(1) {
00159
00160         #if defined(WIN32)
00161             printf( "Unexpected exception: %ld\n", RpcExceptionCode() );
00162         #else
00163             printf( "Unexpected exception: %d\n", RpcExceptionCode() );
00164         #endif
00165         printf("Did you set a net address (like -n server_name etc.)?\n");
00166         exit(1);
00167     }
00168     RpcEndExcept;
00169
00170     exit(0);
00171
00172 }  // end main()
00173
00174
00175 //=====================================================================
00176 //        List allocation/deallocation routines
00177 //=====================================================================
00178
00179 void
00180 AllocateSmList( PBOX * ppBox, short sListSize)
00181 {
00182     PBOX    pBox, head;
00183     int     i = 0;
00184
00185     //.. Allocate a list of boxes, if needed  (when *ppBox==NULL).
00186
00187     if ( *ppBox == NULL ) {
00188
00189         RPC_STATUS status;
00190
00191         head = 0;
00192         for (i = 0; i < sListSize; i++)
00193         {
00194             pBox = (PBOX) RpcSmAllocate( sizeof(LBOX), &status);
00195             if ( status != RPC_S_OK )
00196             {
00197                 printf("AllocateList FAILED: not enough memory\n");
00198                 break;
00199             }
00200             pBox->next = head;
00201             head = pBox;
00202         }
00203         *ppBox = head;
00204     }
00205     printf("%d nodes allocated.\n", i);
00206 }
00207
00208 //=====================================================================
00209 //        Initialization and pprint routines
00210 //=====================================================================
00211
00212 void  InitList( PBOX  pBox, long lStartValue )
00213 {
00214     int i = 0;
00215
00216     while( pBox ) {
00217         pBox->data = lStartValue + ++i;
00218         pBox = pBox->next;
00219     }
00220     printf("%d nodes inited.\n", i);
00221 }
00222
00223 // --------------------------------------------------------------------
00224
00225 void
00226 PrintList( PBOX  pBox )
00227 {
00228     int i = 0;
00229
00230
00231     while( pBox ) {
00232
00233         if ( (i % 4) != 0 )
00234             printf("  data[%d]= %lx", i, pBox->data);
00235         else
00236             printf( "\n  data[%d]= %lx", i, pBox->data);
00237         pBox = pBox->next;
00238         i++;
00239     }
00240     printf("\n" );
00241 }
00242
00243
00244 /* end rpcssmc.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_APPMEM_DATA_DEFINITION Member List

This is the complete list of members for _APPMEM_DATA_DEFINITION, including all inherited members.
AppMemAllocs | _APPMEM_DATA_DEFINITION
AppMemAllocsSec | _APPMEM_DATA_DEFINITION
AppMemBytesAllocated | _APPMEM_DATA_DEFINITION
AppMemFrees | _APPMEM_DATA_DEFINITION
AppMemFreesSec | _APPMEM_DATA_DEFINITION
AppMemObjectType | _APPMEM_DATA_DEFINITION
AppMemReAllocs | _APPMEM_DATA_DEFINITION
AppMemReAllocsSec | _APPMEM_DATA_DEFINITION
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/guids.h Source File

  • SysMgmt
  • MMC
  • Proppage

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019
00020 // {6C26B387-E3F7-4a7c-BD2A-DD4D596CDE86}
00021 DEFINE_GUID(CLSID_CComponentData,
00022 0x6c26b387, 0xe3f7, 0x4a7c, 0xbd, 0x2a, 0xdd, 0x4d, 0x59, 0x6c, 0xde, 0x86);
00023
00024
00025 // {9E6D45FD-C65D-4d1e-89A5-81E3A842F3AA}
00026 DEFINE_GUID(CLSID_CSnapinAbout,
00027 0x9e6d45fd, 0xc65d, 0x4d1e, 0x89, 0xa5, 0x81, 0xe3, 0xa8, 0x42, 0xf3, 0xaa);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ENUMERATE_DIRECTORY_STATE Member List

This is the complete list of members for _ENUMERATE_DIRECTORY_STATE, including all inherited members.
Depth | _ENUMERATE_DIRECTORY_STATE
Path | _ENUMERATE_DIRECTORY_STATE
Stack | _ENUMERATE_DIRECTORY_STATE
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/GUIText.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

GUIText.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      GUITEXT.H
00003
00004   Summary:   Include file for the CGuiText C++ class. A GuiText is a C++
00005              object that encapsulates and displays edited text in a
00006              separate window. The text is edited in a standard Win32
00007              multi-line edit control which is a child window occupying
00008              the entire client area of a separate window. The separate
00009              window is based on APPUTIL's CVirWindow. CGuiText is derived
00010              from CVirWindow and extends it.
00011
00012              GuiText is anchored to the Windows GUI (Graphical User
00013              Interface) environment. This GuiText object relies on a text
00014              object that is instantiated as a COM object (a COTextPage) in
00015              a separate In-process server, PERTEXT, to store the page's
00016              text data.
00017
00018              For a comprehensive tutorial code tour of GUITEXT's contents
00019              and offerings see the tutorial PERCLIEN.HTM file. For
00020              more specific technical details on the internal workings see
00021              the comments dispersed throughout the GUITEXT source code.
00022
00023   Classes:   CGuiText.
00024
00025   Origin:    5-25-97: atrent - Editor inheritance from GUIPAPER.H in the
00026              STOCLIEN source.
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042
00043 #if !defined(GUITEXT_H)
00044 #define GUITEXT_H
00045
00046
00047 #if defined(__cplusplus)
00048
00049
00050 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00051   Class:    CGuiText
00052
00053   Summary:  Class to encapsulate the displayable Graphical User Interface
00054             (GUI) for functioning text edit control objects in separate
00055             windows. Such a window has its own menu and window procedure.
00056             CGuiText is derived from APPUTIL's CVirWindow and thus
00057             inherits all the features and benefits of CVirWindow.
00058
00059   Methods:  CGuiText
00060               Constructor.
00061             ~CGuiText
00062               Destructor.
00063             HRESULT OpenWin(
00064                       IStorage* pIStorage_Root,
00065                       WCHAR* pwszPageTitle,
00066                       WCHAR* pwszDataName);
00067               Get CGuiText started. Create Window. Make subordinate objects.
00068             HRESULT TopWin(void);
00069               Bring the CGuiText window to the on-screen top.
00070             HRESULT ResizeWin(WORD wWidth, WORD wHeight);
00071               Resize the current CGuiText window. Pass to edit control too.
00072             HRESULT Renumber(INT iPage);
00073               Re-assign the current dynamic page number of this page.
00074             HRESULT ReleasePage(void);
00075               Release the root storage held by this text page.
00076             HRESULT RestorePage(IStorage* pIStorage_Root);
00077               Restore the root storage for a new compound file.
00078             HRESULT Close();
00079               Close this page & window.
00080             HRESULT Save(void);
00081               Use COTextPage's IPersistStreamInit to save the text page.
00082             INT AskSave(void);
00083               If text changed ask user if save. Save text user says yes.
00084             HRESULT Delete(void);
00085               Delete the stored text page. Close page if open in window.
00086 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00087 class CGuiText : public CVirWindow
00088 {
00089   public:
00090     // Constructor and Destructor override those in CVirWindow.
00091     CGuiText(HINSTANCE hInst, HWND hWndApp, INT iPage);
00092     ~CGuiText(void);
00093
00094     // The public CGuiText methods that extend CVirWindow.
00095     HRESULT OpenWin(
00096               IStorage* pIStorage_Root,
00097               WCHAR* pwszPageTitle,
00098               WCHAR* pwszDataName);
00099     HRESULT TopWin(void);
00100     HRESULT ResizeWin(WORD wWidth, WORD wHeight);
00101     HRESULT Renumber(INT iPage);
00102     HRESULT ReleasePage(void);
00103     HRESULT RestorePage(IStorage* pIStorage_Root);
00104     HRESULT Close();
00105     HRESULT Save(void);
00106     INT     AskSave(void);
00107     HRESULT Delete(void);
00108
00109   protected:
00110     LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
00111
00112   private:
00113     // Private methods.
00114     HRESULT Clear(void);
00115     HRESULT Load(void);
00116     IConnectionPoint* GetConnectionPoint(REFIID riid);
00117     HRESULT ConnectSink(void);
00118     HRESULT DisconnectSink(void);
00119     HRESULT InitEditMenu(HMENU hEditMenu);
00120     LRESULT DoCommand(WPARAM wParam, LPARAM lParam);
00121
00122     // Private data members.
00123     HWND m_hWndApp;              // Handle of the parent app window.
00124     RECT m_WinRect;              // GuiText Window position rectangle.
00125     HWND m_hWndEdit;             // Text edit control window handle.
00126     CTextWin* m_pTextWin;        // Text edit control window C++ object.
00127     IStorage* m_pIStorage_Root;  // IStorage on the root storage.
00128     ITextPage* m_pITextPage;     // ITextPage on the COTextPage COM object.
00129     INT m_iPage;                 // Page Number of this text page.
00130     CLSID m_CidTextPage;         // The Class ID for COTextPage objects.
00131     WCHAR m_wszDataName[PAGE_NAME_SIZE]; // Page DataName.
00132     IUnknown* m_pCOTextPageSink; // Interface to TextPageSink COM object.
00133     DWORD m_dwTextPageSink;      // Sink connection key.
00134     BOOL m_bChanged;             // Was textwin data changed?
00135 };
00136
00137
00138 #endif // __cplusplus
00139
00140 #endif // GUITEXT.H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DiskCleanupHandler/Cleanup.Cpp Source File

  • WinUI
  • Shell
  • DiskCleanupHandler

Cleanup.Cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  Cleanup.cpp
00011 //
00012 //      Implements DLL entry-point (DllMain), DllGetClassObject and
00013 //      DllCanUnloadNow functions.
00014 //
00015 //////////////////////////////////////////////////////////////////////
00016
00017 #include "Cleanup.h"
00018 #include "ClassFactory.h"
00019
00020 HINSTANCE hDllInstance = NULL;
00021 ULONG nDllRefCount = 0;
00022
00023 /* CLSID_CleanupSample = {D0748010-026C-11D3-B1BD-00600893AD51} */
00024 CLSID CLSID_CleanupSample = {0xD0748010, 0x026C, 0x11D3, {0xB1, 0xBD, 0x00, 0x60, 0x08, 0x93, 0xAD, 0x51}};
00025
00026 BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00027 {
00028     switch (dwReason)
00029     {
00030         case DLL_PROCESS_ATTACH:
00031             hDllInstance = hInstance;
00032             nDllRefCount = 0;
00033             break;
00034
00035         case DLL_THREAD_ATTACH:
00036             break;
00037
00038         case DLL_THREAD_DETACH:
00039             break;
00040
00041         case DLL_PROCESS_DETACH:
00042             break;
00043
00044         default:
00045             break;
00046     }
00047     return TRUE;
00048 }
00049
00050
00051 STDAPI DllCanUnloadNow (VOID)
00052 {
00053     if (nDllRefCount > 0)
00054         return S_FALSE;
00055     return S_OK;
00056 }
00057
00058
00059 STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
00060 {
00061     if (ppv == NULL)
00062         return E_INVALIDARG;
00063
00064     *ppv = NULL;
00065
00066     if (!IsEqualIID(rclsid, CLSID_CleanupSample))
00067         return CLASS_E_CLASSNOTAVAILABLE;
00068
00069     CClassFactory *pFactory = new CClassFactory;
00070     if (!pFactory)
00071         return E_OUTOFMEMORY;
00072
00073     HRESULT hResult = NOERROR;
00074     hResult = pFactory->QueryInterface (riid, ppv);
00075
00076     return hResult;
00077 }
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTSFMainWnd Member List

This is the complete list of members for CTSFMainWnd, including all inherited members.
_CleanupEditWnd(BOOL fNuke) | CTSFMainWnd | [private]
_GetFileName(HWND hwndOwner, LPTSTR lpszFileName, ULONG uChars, BOOL fOpen) | CTSFMainWnd | [private]
_OnActivate(WPARAM) | CTSFMainWnd | [private]
_OnCommand(WORD, WORD, HWND) | CTSFMainWnd | [private]
_OnCreate(VOID) | CTSFMainWnd | [private]
_OnDestroy(VOID) | CTSFMainWnd | [private]
_OnInitMenuPopup(WPARAM, LPARAM) | CTSFMainWnd | [private]
_OnKillFocus(VOID) | CTSFMainWnd | [private]
_OnNotify(UINT, LPNMHDR) | CTSFMainWnd | [private]
_OnSetFocus(VOID) | CTSFMainWnd | [private]
_OnSize(WORD, WORD) | CTSFMainWnd | [private]
_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) | CTSFMainWnd | [private, static]
CTSFMainWnd(HINSTANCE hInstance) | CTSFMainWnd |
Initialize(int nCmdShow) | CTSFMainWnd |
m_hInst | CTSFMainWnd | [private]
m_hWnd | CTSFMainWnd | [private]
m_pTSFEditWnd | CTSFMainWnd | [private]
m_tfClientID | CTSFMainWnd | [private]
~CTSFMainWnd() | CTSFMainWnd |
Generated on Wed Nov 13 2024 16:57:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Msp/MSPBase/msptrmac.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Msp
  • MSPBase

msptrmac.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1998-1999 Microsoft Corporation
00004
00005 Module Name:
00006
00007     msptrmac.cpp
00008
00009 Abstract:
00010
00011     MSP base classes: implementation of audio capture terminal.
00012
00013 --*/
00014
00015 #include "precomp.h"
00016 #pragma hdrstop
00017
00018 #define MAX_LONG 0xefffffff
00019
00020 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00021 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022
00023 CAudioCaptureTerminal::CAudioCaptureTerminal()
00024 {
00025     m_TerminalDirection = TD_CAPTURE;
00026     m_TerminalType = TT_STATIC;
00027
00028     m_bResourceReserved = false;
00029
00030     LOG((MSP_TRACE, "CAudioCaptureTerminal::CAudioCaptureTerminal() finished"));
00031 }
00032
00033 CAudioCaptureTerminal::~CAudioCaptureTerminal()
00034 {
00035     LOG((MSP_TRACE, "CAudioCaptureTerminal::~CAudioCaptureTerminal() finished"));
00036 }
00037
00038 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00039 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00040
00041
00042 HRESULT CAudioCaptureTerminal::CreateTerminal(
00043     IN  CComPtr<IMoniker>   pMoniker,
00044     IN  MSP_HANDLE          htAddress,
00045     OUT ITTerminal        **ppTerm
00046     )
00047 {
00048     // Enable ATL string conversion macros.
00049     USES_CONVERSION;
00050
00051     LOG((MSP_TRACE, "CAudioCaptureTerminal::CreateTerminal : enter"));
00052
00053     //
00054     // Validate the parameters
00055     //
00056
00057     if ( MSPB_IsBadWritePtr(ppTerm, sizeof(ITTerminal *) ) )
00058     {
00059         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateTerminal : "
00060             "bad terminal pointer; returning E_POINTER"));
00061         return E_POINTER;
00062     }
00063
00064     if ( IsBadReadPtr(pMoniker, sizeof(IMoniker) ) )
00065     {
00066         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateTerminal : "
00067             "bad moniker pointer; returning E_POINTER"));
00068         return E_POINTER;
00069     }
00070
00071     //
00072     // We return a NULL terminal if there is an error.
00073     //
00074
00075     *ppTerm = NULL;
00076     HRESULT hr;
00077
00078     //
00079     // Bind the moniker to storage as a property bag.
00080     //
00081
00082     CComPtr<IPropertyBag> pBag;
00083     hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
00084     if (FAILED(hr))
00085     {
00086         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateTerminal (IMoniker::BindToStorage) - returning  %8x", hr));
00087         return hr;
00088     }
00089
00090     VARIANT var;
00091
00092     //
00093     // Get the wave ID from the property bag.
00094     // Skip this terminal if it doesn't have a wave ID.
00095     // (Needed because WDM devices don't work, and we don't want more than one
00096     // terminal per device.)
00097     //
00098
00099     var.vt = VT_I4;
00100     hr = pBag->Read(L"WaveInId", &var, 0);
00101
00102     if (FAILED(hr))
00103     {
00104         LOG((MSP_INFO, "CAudioCaptureTerminal::CreateTerminal - "
00105             "IPropertyBag::Read failed on WaveID - "
00106             "skipping terminal (not cause for alarm) - "
00107             "returning  0x%08x", hr));
00108
00109         return hr;
00110     }
00111
00112     //
00113     // Get the name for this filter out of the property bag.
00114     // Skip this terminal if it doesn't have a name.
00115     //
00116
00117     var.vt = VT_BSTR;
00118     hr = pBag->Read(L"FriendlyName", &var, 0);
00119
00120     if (FAILED(hr))
00121     {
00122         LOG((MSP_INFO, "CAudioCaptureTerminal::CreateTerminal - "
00123             "IPropertyBag::Read failed on FriendlyName - "
00124             "skipping terminal (not cause for alarm) - "
00125             "returning  0x%08x", hr));
00126
00127         return hr;
00128     }
00129
00130     //
00131     // Create the filter.
00132     //
00133
00134     CMSPComObject<CAudioCaptureTerminal> *pLclTerm = new CMSPComObject<CAudioCaptureTerminal>;
00135
00136     if (pLclTerm == NULL)
00137     {
00138         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateTerminal - returning E_OUTOFMEMORY"));
00139         return E_OUTOFMEMORY;
00140     }
00141
00142     //
00143     // Save some stuff in the terminal.
00144     //
00145
00146     pLclTerm->m_pMoniker = pMoniker;
00147
00148     lstrcpyn(pLclTerm->m_szName, OLE2T(var.bstrVal), MAX_PATH);
00149
00150     SysFreeString(var.bstrVal);
00151
00152     //
00153     // Get the ITTerminal interface that we were asked for.
00154     //
00155     hr = pLclTerm->_InternalQueryInterface(IID_ITTerminal, (void**)ppTerm);
00156
00157     if ( FAILED(hr) )
00158     {
00159         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateTerminal - "
00160             "Internal QI failed; returning 0x%08x", hr));
00161
00162         delete pLclTerm;
00163         *ppTerm = NULL; // just in case
00164
00165         return hr;
00166     }
00167
00168     //
00169     // Finish initializing the terminal.
00170     //
00171
00172     hr = pLclTerm->Initialize(CLSID_MicrophoneTerminal,
00173                               TAPIMEDIATYPE_AUDIO,
00174                               TD_CAPTURE,
00175                               htAddress
00176                              );
00177     if ( FAILED(hr) )
00178     {
00179         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateTerminal - "
00180             "Initialize failed; returning 0x%08x", hr));
00181
00182         (*ppTerm)->Release();
00183         *ppTerm = NULL;
00184
00185         return hr;
00186     }
00187
00188
00189     LOG((MSP_TRACE, "CAudioCaptureTerminal::CreateTerminal - exit S_OK"));
00190     return S_OK;
00191 }
00192
00193 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00194 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00195 // Create the filters used by this terminal
00196
00197 HRESULT CAudioCaptureTerminal::CreateFilters(void)
00198 {
00199     LOG((MSP_TRACE, "CAudioCaptureTerminal::CreateFilters() called"));
00200
00201     //
00202     // This should only be called atmost once in the lifetime of this instance
00203     //
00204
00205     if ( (m_pIFilter            != NULL) ||
00206          (m_pIPin               != NULL) ||
00207          (m_pIAMAudioInputMixer != NULL) )
00208     {
00209         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateFilters() : we've already been called; returning E_FAIL"));
00210         return E_FAIL;
00211     }
00212
00213     //
00214     // Create the filter.
00215     //
00216
00217     HRESULT hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pIFilter);
00218
00219     if ( FAILED(hr) || (m_pIFilter == NULL) )
00220     {
00221         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateFilters() : BindToObject failed 0x%08x", hr));
00222
00223         m_pIFilter = NULL; // we are being extra careful...
00224         return hr;
00225     }
00226
00227     //
00228     // Get the basic audio (mixer) interface for the filter.
00229     //
00230
00231     hr = m_pIFilter->QueryInterface(IID_IAMAudioInputMixer,
00232                                        (void **) &m_pIAMAudioInputMixer);
00233
00234     if ( FAILED(hr) || (m_pIAMAudioInputMixer == NULL) )
00235     {
00236         //
00237         // The filter doesn't support the mixer interface. This is not catastrophic;
00238         // all it means is that subsequent mixer operations on the terminal will fail.
00239         //
00240
00241         LOG((MSP_WARN, "CAudioCaptureTerminal::CreateFilters() : mixer QI failed 0x%08x", hr));
00242         m_pIAMAudioInputMixer = NULL;
00243     }
00244
00245     //
00246     // Find the output pin (this is a private method on the terminal).
00247     //
00248
00249     hr = FindTerminalPin();
00250
00251     if ( FAILED(hr) || (m_pIPin == NULL) )
00252     {
00253         LOG((MSP_ERROR, "CAudioCaptureTerminal::CreateFilters() : FindTerminalPin failed 0x%08x", hr));
00254
00255         //
00256         // Clean up our mess.
00257         //
00258
00259         if (m_pIAMAudioInputMixer != NULL)
00260         {
00261             m_pIAMAudioInputMixer = NULL; // implicit release
00262         }
00263
00264         m_pIFilter = NULL; // implicit release
00265
00266         return hr;
00267     }
00268
00269     LOG((MSP_TRACE, "CAudioCaptureTerminal::CreateFilters() succeeded"));
00270     return S_OK;
00271 }
00272
00273 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00274 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00275
00276 HRESULT
00277 CAudioCaptureTerminal::FindTerminalPin(
00278     )
00279 {
00280     LOG((MSP_TRACE, "CAudioCaptureTerminal::FindTerminalPin - enter"));
00281
00282     // We must not do CreateFiltersIfRequired here because that would
00283     // result in a recursive call to us again.
00284
00285     if (m_pIPin != NULL)
00286     {
00287         LOG((MSP_ERROR, "CAudioCaptureTerminal::FindTerminalPin - "
00288             "we've alread got a pin; returning E_UNEXPECTED"));
00289         return E_UNEXPECTED;
00290     }
00291
00292     HRESULT hr;
00293     CComPtr<IEnumPins> pIEnumPins;
00294     ULONG cFetched;
00295
00296     //
00297     // Find the capture pin for the filter.
00298     //
00299
00300     if (FAILED(hr = m_pIFilter->EnumPins(&pIEnumPins)))
00301     {
00302         LOG((MSP_ERROR,
00303             "CAudioCaptureTerminal::FindTerminalPin - can't enum pins %8x",
00304             hr));
00305         return hr;
00306     }
00307
00308     IPin * pIPin;
00309
00310     // Enumerate all the pins and break on the
00311     // first pin that meets requirement.
00312     for (;;)
00313     {
00314         if (pIEnumPins->Next(1, &pIPin, &cFetched) != S_OK)
00315         {
00316             LOG((MSP_ERROR,
00317                 "CAudioCaptureTerminal::FindTerminalPin - can't get a pin %8x",
00318                 hr));
00319             return (hr == S_FALSE) ? E_FAIL : hr;
00320         }
00321
00322         if (0 == cFetched)
00323         {
00324             LOG((MSP_ERROR, "CAudioCaptureTerminal::FindTerminalPin - got zero pins"));
00325             return E_FAIL;
00326         }
00327
00328         PIN_DIRECTION dir;
00329
00330         if (FAILED(hr = pIPin->QueryDirection(&dir)))
00331         {
00332             LOG((MSP_ERROR,
00333                 "CAudioCaptureTerminal::FindTerminalPin - can't query pin direction %8x",
00334                 hr));
00335             pIPin->Release();
00336             return hr;
00337         }
00338
00339         if (PINDIR_OUTPUT == dir)
00340         {
00341             break;
00342         }
00343
00344         pIPin->Release();
00345     }
00346
00347     m_pIPin = pIPin;
00348
00349     LOG((MSP_TRACE, "CAudioCaptureTerminal::FindTerminalPin - exit S_OK"));
00350
00351     return S_OK;
00352 }
00353
00354
00355 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00356 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00357
00358 HRESULT CAudioCaptureTerminal::AddFiltersToGraph(
00359     )
00360 {
00361     LOG((MSP_TRACE, "CAudioCaptureTerminal::AddFiltersToGraph - enter"));
00362
00363     if (m_pGraph == NULL)
00364     {
00365         LOG((MSP_ERROR, "CAudioCaptureTerminal::AddFiltersToGraph - "
00366             "we don't have a filter graph; returning E_UNEXPECTED"));
00367         return E_UNEXPECTED;
00368     }
00369
00370     HRESULT hr = CreateFiltersIfRequired();
00371
00372     if ( FAILED(hr) )
00373     {
00374         LOG((MSP_ERROR, "CAudioCaptureTerminal::AddFiltersToGraph - "
00375             "CreateFiltersIfRequired failed; returning hr = 0x%08x", hr));
00376         return hr;
00377     }
00378
00379     if (m_pIFilter == NULL)
00380     {
00381         LOG((MSP_ERROR, "CAudioCaptureTerminal::AddFiltersToGraph - "
00382             "we don't have a filter; returning E_UNEXPECTED"));
00383         return E_UNEXPECTED;
00384     }
00385
00386     //
00387     // Add the filter to the graph.
00388     //
00389     // A word about names:
00390     // If a filter has already been added with the same name (which will
00391     // happen if we have more than one audio capture terminal in the same
00392     // graph) then that will return VFW_S_DUPLICATE_NAME, which is not
00393     // a failure.
00394     //
00395
00396     hr = m_pGraph->AddFilter(m_pIFilter, WAVEIN_NAME);
00397
00398     if ( FAILED(hr) )
00399     {
00400         LOG((MSP_ERROR, "CAudioCaptureTerminal::AddFiltersToGraph - "
00401             "AddFilter failed; returning hr = 0x%08x", hr));
00402         return hr;
00403     }
00404
00405     LOG((MSP_TRACE, "CAudioCaptureTerminal::AddFiltersToGraph - exit S_OK"));
00406     return S_OK;
00407 }
00408 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00409 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00410
00411 HRESULT CAudioCaptureTerminal::CompleteConnectTerminal(void)
00412 {
00413     CLock lock(m_CritSec);
00414
00415     LOG((MSP_TRACE, "CAudioCaptureTerminal::CompleteConnectTerminal - enter"));
00416
00417     // By default, we need not unreserve later.
00418     m_bResourceReserved = false;
00419
00420     HRESULT hr = CSingleFilterTerminal::CompleteConnectTerminal();
00421     if (FAILED(hr))
00422     {
00423         LOG((MSP_ERROR, "CAudioCaptureTerminal::CompleteConnectTerminal: "
00424                 "CSingleFilterTerminal method failed"));
00425         return hr;
00426     }
00427
00428     // So here we are, after our filter has been added to the filter graph and connected up, but before
00429     // the MSP has told it to run.
00430
00431     //////////////////////////////////////////////////////////////////////////
00432     // connect-time device reservation:
00433     // we must inform the filter that we want it to grab the wave device.
00434     // We do this after connecting because the filter needs to negotiate the
00435     // media type before it can open a wave device.
00436
00437     CComPtr <IAMResourceControl> pIResource;
00438
00439     hr = m_pIFilter->QueryInterface(IID_IAMResourceControl, (void **) &pIResource);
00440     if (FAILED(hr))
00441     {
00442         LOG((MSP_WARN, "CAudioCaptureTerminal::CompleteConnectTerminal - QI failed: %8x", hr));
00443
00444         // This is a nonesential operation so we do not "return hr;" here.
00445     }
00446     else // QueryInterface didn't fail
00447     {
00448         hr = pIResource->Reserve(AMRESCTL_RESERVEFLAGS_RESERVE, NULL);
00449
00450         if (hr != S_OK)
00451         {
00452             LOG((MSP_ERROR, "CAudioCaptureTerminal::CompleteConnectTerminal - "
00453                     "device reservation failed: %8x", hr));
00454             return hr;
00455         }
00456
00457         // We have succeeded in reserving, so we will want to unreserve later.
00458         m_bResourceReserved = true;
00459     }
00460
00461     LOG((MSP_TRACE, "CAudioCaptureTerminal::CompleteConnectTerminal - exit S_OK"));
00462     return S_OK;
00463 }
00464
00465 //////////////////////////////////////////////////////////////////////////////////
00466 // We override this here so we can unreserve the resource when we are done.
00467 // removes filters from the filter graph and resets member variables
00468 // Disconnect may be called anytime after Connect succeeds (it need not be called
00469 // if CompleteConnect fails)
00470
00471 STDMETHODIMP CAudioCaptureTerminal::DisconnectTerminal(
00472             IN      IGraphBuilder  * pGraph,
00473             IN      DWORD            dwReserved
00474             )
00475 {
00476     LOG((MSP_TRACE, "CAudioCaptureTerminal::DisconnectTerminal - enter"));
00477
00478     HRESULT hr;
00479
00480     //
00481     // First call the base class method, to make sure we validate everything
00482     // and don't mess with our resource reservation unless this is a valid
00483     // disconnection (e.g., the filter graph pointersmatch).
00484     //
00485
00486     hr = CSingleFilterTerminal::DisconnectTerminal(pGraph, dwReserved);
00487
00488     if (FAILED(hr))
00489     {
00490         LOG((MSP_TRACE, "CAudioCaptureTerminal::DisconnectTerminal : "
00491                 "CSingleFilterTerminal method failed; hr = %d", hr));
00492         return hr;
00493     }
00494
00495     // if we need to unreserve the resource now
00496     if (m_bResourceReserved)
00497     {
00498         CComPtr <IAMResourceControl> pIResource;
00499
00500         hr = m_pIFilter->QueryInterface(IID_IAMResourceControl,
00501                                         (void **) &pIResource);
00502         if (FAILED(hr))
00503         {
00504             LOG((MSP_WARN, "CAudioCaptureTerminal::DisconnectTerminal - "
00505                                  "QI failed: %8x", hr));
00506
00507             // This is a nonesential operation so we do not "return hr;" here.
00508         }
00509         else
00510         {
00511             // QueryInterface didn't fail, so UNRESERVE now
00512
00513             hr = pIResource->Reserve(AMRESCTL_RESERVEFLAGS_UNRESERVE, NULL);
00514             if (hr != S_OK)
00515             {
00516                 LOG((MSP_WARN, "CAudioCaptureTerminal::DisconnectTerminal - "
00517                                      "device unreservation failed: %8x", hr));
00518                 // no reason to completely die at this point, so we just continue
00519             }
00520
00521             // if other things fail we may be called again, but we should not try
00522             // to unreserve again.
00523             m_bResourceReserved = false;
00524
00525         } // {if QI succeeded}
00526     } // {if we need to release}
00527
00528     LOG((MSP_TRACE, "CAudioCaptureTerminal::DisconnectTerminal - exit S_OK"));
00529
00530     return S_OK;
00531 }
00532
00533
00534 ///////////////////////////////////////////////////////////////////////////////
00535 //***************************************************************************//
00536 //*                                                                         *//
00537 //* NOTE: The input filter does not support IBasicAudio so we need to masage*//
00538 //*       the parameters for the basic audio methods so that the will work  *//
00539 //*       for IAMAudioInputMixer.                                           *//
00540 //*                                                                         *//
00541 //*****************************************************************************
00542 ///////////////////////////////////////////////////////////////////////////////
00543
00544 static const long   TMGR_MIN_API_VOLUME     = 0;      // our terminal semantics
00545 static const long   TMGR_MAX_API_VOLUME     = 0xFFFF;
00546 static const double TMGR_MIN_CAPTURE_VOLUME = 0.0;    // capture filter semantics
00547 static const double TMGR_MAX_CAPTURE_VOLUME = 1.0;
00548
00549 STDMETHODIMP CAudioCaptureTerminal::get_Volume(long * plVolume)
00550 {
00551     CLock lock(m_CritSec);
00552
00553     LOG((MSP_TRACE, "CAudioCaptureTerminal::get_Volume - enter"));
00554
00555     //
00556     // Check parameters.
00557     //
00558
00559     if ( MSPB_IsBadWritePtr(plVolume, sizeof(long)) )
00560     {
00561         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_Volume - "
00562             "invalid pointer passed in - returning E_POINTER"));
00563         return E_POINTER;
00564     }
00565
00566     //
00567     // Create the filters if required. This protects us if the creation fails.
00568     //
00569
00570     HRESULT hr = CreateFiltersIfRequired();
00571
00572     if ( FAILED(hr) )
00573     {
00574         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_Volume - "
00575             "CreateFiltersIfRequired failed; returning hr = 0x%08x", hr));
00576         return hr;
00577     }
00578
00579     //
00580     // Check if CreateFiltersIfRequired was able to get us the mixer interface.
00581     // If not, we must fail.
00582     //
00583
00584     if (m_pIAMAudioInputMixer == NULL)
00585     {
00586         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_Volume - "
00587             "filter does not support mixer interface - returning E_FAIL"));
00588         return E_FAIL;
00589     }
00590
00591     //
00592     // Perform the call on the filter.
00593     //
00594
00595     double dVolume;
00596     hr = m_pIAMAudioInputMixer->get_MixLevel(&dVolume);
00597     if (FAILED(hr))
00598     {
00599         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_Volume "
00600             "(get_MixLevel) - returning  %8x", hr));
00601         return hr;
00602     }
00603
00604
00605     //
00606     // Massage ranges to convert between disparate semantics.
00607     //
00608
00609
00610     // Our argument is a pointer to a long in the range 0 - 0xFFFF.
00611     // We need to output that based on a double ranging from 0.0 to 1.0.
00612
00613     if (dVolume < TMGR_MIN_CAPTURE_VOLUME)
00614     {
00615         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_Volume - observed "
00616             "volume %d < %d; returning E_INVALIDARG",
00617             dVolume, TMGR_MIN_CAPTURE_VOLUME));
00618
00619         return E_INVALIDARG;
00620     }
00621
00622     if (dVolume > TMGR_MAX_CAPTURE_VOLUME)
00623     {
00624         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_Volume - observed "
00625             "volume %d > %d; returning E_INVALIDARG",
00626             dVolume, TMGR_MAX_CAPTURE_VOLUME));
00627
00628         return E_INVALIDARG;
00629     }
00630
00631     // Convert the volume from whatever range of doubles the filter uses
00632     // to the range 0 - 1. Right now this does nothing but makes the code more general.
00633     dVolume = ( dVolume                 - TMGR_MIN_CAPTURE_VOLUME )
00634             / ( TMGR_MAX_CAPTURE_VOLUME - TMGR_MIN_CAPTURE_VOLUME );
00635
00636     // Convert the volume from the range 0 - 1 to the API's range.
00637     *plVolume = TMGR_MIN_API_VOLUME +
00638         (long) (( TMGR_MAX_API_VOLUME - TMGR_MIN_API_VOLUME ) * dVolume);
00639
00640     LOG((MSP_TRACE, "CAudioCaptureTerminal::get_Volume - exit S_OK"));
00641     return S_OK;
00642 }
00643
00644 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00645 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00646
00647 STDMETHODIMP CAudioCaptureTerminal::put_Volume(long lVolume)
00648 {
00649     CLock lock(m_CritSec);
00650
00651     LOG((MSP_TRACE, "CAudioCaptureTerminal::put_Volume - enter"));
00652
00653     //
00654     // Create the filters if required. This protects us if the creation fails.
00655     //
00656
00657     HRESULT hr = CreateFiltersIfRequired();
00658
00659     if ( FAILED(hr) )
00660     {
00661         LOG((MSP_ERROR, "CAudioCaptureTerminal::put_Volume - "
00662             "CreateFiltersIfRequired failed; returning hr = 0x%08x", hr));
00663         return hr;
00664     }
00665
00666     //
00667     // Check if CreateFiltersIfRequired was able to get us the mixer interface.
00668     // If not, we must fail.
00669     //
00670
00671     if (m_pIAMAudioInputMixer == NULL)
00672     {
00673         LOG((MSP_ERROR, "CAudioCaptureTerminal::put_Volume - "
00674             "filter does not support mixer interface - returning E_FAIL"));
00675         return E_FAIL;
00676     }
00677
00678     //
00679     // Massage ranges to convert between disparate semantics.
00680     //
00681
00682     // Our argument is a long in the range 0 - 0xFFFF. We need to convert it
00683     // to a double ranging from 0.0 to 1.0.
00684
00685     if (lVolume < TMGR_MIN_API_VOLUME)
00686     {
00687         LOG((MSP_ERROR, "CAudioCaptureTerminal::put_Volume - requested "
00688             "volume %d < %d; returning E_INVALIDARG",
00689             lVolume, TMGR_MIN_API_VOLUME));
00690
00691         return E_INVALIDARG;
00692     }
00693
00694     if (lVolume > TMGR_MAX_API_VOLUME)
00695     {
00696         LOG((MSP_ERROR, "CAudioCaptureTerminal::put_Volume - requested "
00697             "volume %d > %d; returning E_INVALIDARG",
00698             lVolume, TMGR_MAX_API_VOLUME));
00699
00700         return E_INVALIDARG;
00701     }
00702
00703     // Convert to the range 0 to 1.
00704     double dVolume =
00705                ( (double) ( lVolume             - TMGR_MIN_API_VOLUME ) )
00706              / ( (double) ( TMGR_MAX_API_VOLUME - TMGR_MIN_API_VOLUME ) );
00707
00708     // Convert the volume to whatever range of doubles the filter uses
00709     // from the range 0 - 1. Right now this does nothing but makes the code
00710     // more general.
00711
00712     dVolume = TMGR_MIN_CAPTURE_VOLUME +
00713         ( TMGR_MAX_CAPTURE_VOLUME - TMGR_MIN_CAPTURE_VOLUME ) * dVolume;
00714
00715     hr = m_pIAMAudioInputMixer->put_MixLevel(dVolume);
00716
00717     LOG((MSP_TRACE, "CAudioCaptureTerminal::put_Volume - exit 0x%08x", hr));
00718     return hr;
00719 }
00720
00721 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00722 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00723
00724 STDMETHODIMP CAudioCaptureTerminal::get_Balance(long * plBalance)
00725 {
00726
00727     HRESULT hr = E_NOTIMPL;
00728
00729     LOG((MSP_TRACE, "CAudioCaptureTerminal::get_Balance - enter"));
00730     LOG((MSP_TRACE, "CAudioCaptureTerminal::get_Balance - exit 0x%08x", hr));
00731
00732     return hr;
00733 }
00734
00735 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00736 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00737
00738 STDMETHODIMP CAudioCaptureTerminal::put_Balance(long lBalance)
00739 {
00740     HRESULT hr = E_NOTIMPL;
00741
00742     LOG((MSP_TRACE, "CAudioCaptureTerminal::put_Balance - enter"));
00743     LOG((MSP_TRACE, "CAudioCaptureTerminal::put_Balance - exit 0x%08x", hr));
00744
00745     return hr;
00746 }
00747
00748 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00749 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00750
00751 STDMETHODIMP
00752 CAudioCaptureTerminal::get_WaveId(
00753     OUT long * plWaveId
00754     )
00755 {
00756     LOG((MSP_TRACE, "CAudioCaptureTerminal::get_WaveId - enter"));
00757
00758     CLock lock(m_CritSec);
00759
00760     //
00761     // Parameter checks.
00762     //
00763
00764     if ( MSPB_IsBadWritePtr(plWaveId, sizeof(long)) )
00765     {
00766         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_WaveId - "
00767             "bad pointer argument"));
00768
00769         return E_POINTER;
00770     }
00771
00772     //
00773     // Check the moniker pointer.
00774     //
00775
00776     if ( IsBadReadPtr( m_pMoniker, sizeof(IMoniker) ) )
00777     {
00778         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_WaveId - "
00779             "bad moniker pointer - exit E_UNEXPECTED"));
00780
00781         return E_UNEXPECTED;
00782     }
00783
00784     //
00785     // Get a property bag from the moniker.
00786     //
00787
00788     IPropertyBag * pBag;
00789
00790     HRESULT hr = m_pMoniker->BindToStorage(0,
00791                                            0,
00792                                            IID_IPropertyBag,
00793                                            (void **) &pBag);
00794
00795     if ( FAILED(hr) )
00796     {
00797         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_WaveId - "
00798             "can't get property bag - exit 0x%08x", hr));
00799
00800         return hr;
00801     }
00802
00803     //
00804     // Get the ID from the property bag.
00805     //
00806
00807     VARIANT var;
00808
00809     var.vt = VT_I4;
00810
00811     hr = pBag->Read(
00812         L"WaveInId",
00813         &var,
00814         0);
00815
00816     pBag->Release();
00817
00818     if ( FAILED(hr) )
00819     {
00820         LOG((MSP_ERROR, "CAudioCaptureTerminal::get_WaveId - "
00821             "can't read wave ID - exit 0x%08x", hr));
00822
00823         return hr;
00824     }
00825
00826     *plWaveId = (long) var.lVal;
00827
00828     LOG((MSP_TRACE, "CAudioCaptureTerminal::get_WaveId - exit S_OK"));
00829
00830     return S_OK;
00831 }
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/msgtable/MsgTest.c Source File

  • WinUI
  • Resource
  • msgtable

MsgTest.c

Go to the documentation of this file.
00001 /* Microsoft Developer Support
00002    Copyright 1992 - 2000 Microsoft Corporation */
00003
00004 #include <windows.h>
00005 #include <tchar.h>
00006 #include <stdio.h>
00007
00008 /* messages.h is created by mc.exe when compiling messages.mc */
00009 #include "messages.h"
00010
00011 #define MAX_MESSAGES            5
00012 #define MAX_MSG_LENGTH       1024
00013 #define SEVERITY_MASK  0xC0000000
00014 #define FACILITY_MASK  0x0FFF0000
00015 #define MSG_ID_MASK    0x0000FFFF
00016
00017
00018 /********************************************************************
00019 * FUNCTION: myPutMsg(HINSTANCE hLib, LPVOID lpArgs, DWORD dwMsgId,  *
00020 *                    DWORD dwLangId)                                *
00021 *                                                                   *
00022 * PURPOSE: format and output error dwMsgId, using string defined    *
00023 *          for language dwLangId, with insert strings lpArgs, from  *
00024 *          the messagetable resource in the DLL referenced by       *
00025 *          handle hLib                                              *
00026 *                                                                   *
00027 * INPUT: Library handle, insert strings, message ID number, and     *
00028 *        language ID as defined in the .mc file                     *
00029 *                                                                   *
00030 * RETURNS: none                                                     *
00031 ********************************************************************/
00032 VOID myPutMsg (
00033     HINSTANCE hLib,
00034     PVOID pArgs,
00035     DWORD dwMsgId,
00036     DWORD dwLangId)
00037 {
00038     BOOL bSuccess  = FALSE;
00039     PTSTR msgBuf   = NULL;  /* hold text of the error message that we build */
00040     int dwCode;  /* hold various codes extracted from dwMsgId */
00041
00042     /*
00043
00044     Here is the layout of the message ID:
00045
00046     3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
00047     1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
00048     +---+-+-+-----------------------+-------------------------------+
00049     |Sev|C|R|     Facility          |               Code            |
00050     +---+-+-+-----------------------+-------------------------------+
00051
00052     where
00053
00054       Sev - is the severity code
00055       C - is the Customer code flag
00056       R - is a reserved bit
00057       Facility - is the facility code
00058       Code - is the facility's status code
00059     */
00060
00061     _tprintf(TEXT("Severity: "));
00062     /* output the severity and facility code. Mask off the severity */
00063     /* bits with SEVERITY_MASK and shift them down */
00064     dwCode = (dwMsgId & SEVERITY_MASK) >> 30;
00065     switch (dwCode)
00066     {
00067         case STATUS_SEVERITY_WARNING:
00068             _tprintf(TEXT("STATUS_SEVERITY_WARNING  "));
00069             break;
00070
00071         case STATUS_SEVERITY_SUCCESS:
00072             _tprintf(TEXT("STATUS_SEVERITY_SUCCESS  "));
00073             break;
00074
00075         case STATUS_SEVERITY_INFORMATIONAL:
00076             _tprintf(TEXT("STATUS_SEVERITY_INFORMATIONAL  "));
00077             break;
00078
00079         case STATUS_SEVERITY_ERROR:
00080             _tprintf(TEXT("STATUS_SEVERITY_ERROR  "));
00081             break;
00082
00083         default:
00084             _tprintf(TEXT("Unknown!  "));
00085             break;
00086     }
00087
00088     _tprintf (TEXT("\nFacility: "));
00089     /* Mask off the facility bits with FACILITY_MASK and shift them down */
00090     dwCode = (dwMsgId & FACILITY_MASK) >> 16;
00091     switch (dwCode)
00092     {
00093         case FACILITY_SYSTEM:
00094             _tprintf(TEXT("FACILITY_SYSTEM  "));
00095             break;
00096
00097         case FACILITY_STUBS:
00098             _tprintf(TEXT("FACILITY_STUBS  "));
00099             break;
00100
00101         case FACILITY_RUNTIME:
00102             _tprintf(TEXT("FACILITY_RUNTIME  "));
00103             break;
00104
00105         case FACILITY_IO_ERROR_CODE:
00106             _tprintf(TEXT("FACILITY_IO_ERROR_CODE  "));
00107             break;
00108
00109         default:
00110              _tprintf(TEXT("Unknown!  "));
00111              break;
00112     }
00113
00114     /* retrieve and format the message from the messagetable DLL. */
00115     bSuccess = FormatMessage(
00116         FORMAT_MESSAGE_FROM_HMODULE         |   /* get the message from the DLL */
00117             FORMAT_MESSAGE_ALLOCATE_BUFFER  |   /* allocate the msg buffer for us */
00118             FORMAT_MESSAGE_ARGUMENT_ARRAY   |   /* pArgs is an array of 32-bit values */
00119         60,                                     /* line length for the mesages */
00120         hLib,                                   /* the messagetable DLL handle */
00121         dwMsgId,                                /* message ID */
00122         dwLangId,                               /* language ID as defined in .mc file */
00123         msgBuf,                                 /* address of pointer to buffer for message */
00124         MAX_MSG_LENGTH,                         /* maximum size of the message buffer */
00125         pArgs);                                 /* array of insert strings for the message */
00126
00127     if (!bSuccess)
00128     {
00129         _tprintf(TEXT("Error %d from FormatMessage\n"), GetLastError());
00130     }
00131     else
00132     {
00133         /* mask off the actual message number with MSG_ID_MASK and show it */
00134         _tprintf(TEXT("\nError: %d: %s"), dwMsgId & MSG_ID_MASK, msgBuf);
00135         /* Free the buffer that FormatMessage allocated for us. */
00136         LocalFree((HLOCAL) msgBuf);
00137     }
00138
00139     _tprintf(TEXT("\n__________\n"));
00140     CloseHandle(hLib);
00141 }
00142
00143
00144 /********************************************************************
00145 * FUNCTION: _tmain()                                                *
00146 *                                                                   *
00147 * PURPOSE: Load the message resource DLL, and call myPutMsg() to    *
00148 *          format and output error messages to the user             *
00149 *                                                                   *
00150 * INPUT: none                                                       *
00151 *                                                                   *
00152 * RETURNS: none                                                     *
00153 ********************************************************************/
00154 int __cdecl _tmain ()
00155 {
00156     HINSTANCE hLib = NULL;  /* handle to the messagetable DLL */
00157     PTCHAR aInsertStrs[8] = {0};  /* array of 32-bit insert values for FormatMessage*/
00158     WORD wLangID;
00159
00160     /* Check to make sure we are running on Windows NT */
00161     if( GetVersion() & 0x80000000 )
00162     {
00163         MessageBox(NULL,
00164             TEXT("Sorry, this application requires Windows NT.\n")
00165             TEXT("This application will now terminate."),
00166             TEXT("Error: Windows NT Required to Run"),  MB_OK );
00167         return(1);
00168     }
00169
00170     /*
00171      * Load the resource library without calling any entry points since
00172      * this is a resource-only DLL
00173      * Note that in general one should use absolute paths in calls of
00174      * LoadLibraries and LoadLibraryEx, because relative paths pose a
00175      * significant security risk. For more information refer to MSDN for the
00176      * documentation of LoadLibrary and LoadLibraryEx
00177      */
00178     hLib = LoadLibraryEx(TEXT("messages.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
00179     if (!hLib)
00180     {
00181         _tprintf(TEXT("Error %d from LoadLibrary\n"), GetLastError());
00182     }
00183
00184     /* Messages in the .mc file have been defined using standard locale ID's:
00185        see MAKELANGID and LANG_* definitions in winnt.h */
00186     wLangID = LANG_USER_DEFAULT;
00187
00188     /*
00189      * To force a different language, define the language ID as one of the values
00190      * defined in the Language statement in the .mc file. Alternatively, you
00191      * can choose a different language in the International applet in the control
00192      * panel and stick with LANG_USER_DEFAULT.
00193      */
00194     //wLangID = 0x411;
00195
00196
00197     /*
00198      * Output some error messages from the messagetable DLL
00199      * The first three have no insert strings
00200      */
00201     myPutMsg(hLib, NULL, MSG_BAD_COMMAND, wLangID);
00202     myPutMsg(hLib, NULL, MSG_BAD_PARM1, wLangID);
00203     myPutMsg(hLib, NULL, MSG_STRIKE_ANY_KEY, wLangID);
00204
00205
00206     /* wait for user to hit enter as per last error message */
00207     getchar();
00208
00209
00210     /*
00211      * The next two messages contain insert strings - set up our array
00212      * of insert strings and pass the array to myPutMsg()
00213      */
00214     aInsertStrs[0] = TEXT("foo.c");
00215     aInsertStrs[1] = TEXT("BAR");
00216     myPutMsg(hLib, aInsertStrs, MSG_CMD_DELETE, wLangID);
00217
00218     aInsertStrs[0] = (PTCHAR) 47;
00219     aInsertStrs[1] = (PTCHAR) 5;
00220     myPutMsg(hLib, aInsertStrs, MSG_RETRYS, wLangID);
00221     return(0);
00222 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/IPArp/IPArp.h Source File

  • NetDS
  • IPHelp
  • IPArp

IPArp.h

Go to the documentation of this file.
00001 #ifndef _IPARP_H
00002 #define _IPARP_H
00003
00004 #include <windows.h>
00005 #include <winsock.h>
00006 #include <iphlpapi.h>
00007 #include <assert.h>
00008 #include <stdlib.h>
00009 #include <malloc.h>
00010 #include <stdio.h>
00011 #include <string.h>
00012 #include <limits.h>
00013 #include <iptypes.h>
00014
00015
00016 void  PrintIpNetTable(PMIB_IPNETTABLE pIpNetTable);
00017 DWORD MyGetIpNetTable(PMIB_IPNETTABLE & pIpArpTab, bool fOrder = FALSE);
00018 DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE& pIpAddrTable, bool fOrder = FALSE);
00019 void  PrintIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable);
00020
00021 void DoGetIpNetTable();
00022 void DoSetIpNetEntry(char* pszDottedInetAddr, char* pszPhysAddr, char* pszInterface = NULL);
00023 void DoDeleteIpNetEntry(char* pszInetAddr, char* pszInterface = NULL);
00024
00025 bool PhysAddrToString(BYTE PhysAddr[], DWORD PhysAddrLen, char str[]);
00026 int  StringToPhysAddr(char* szInEther, char* szOutEther);
00027 bool InterfaceIdxToInterfaceIp(PMIB_IPADDRTABLE pIpAddrTable, DWORD dwIndex, char str[]);
00028
00029
00030 #endif //_IPARP_H
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepmultiuser/prof.h Source File

  • NetDS
  • RPC
  • FileRep
  • filerepmultiuser

prof.h

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Profiling Routines
00005
00006     FILE: Prof.h
00007
00008     PURPOSE: Routines for profiling server system services.
00009
00010     FUNCTIONS:
00011         ProfOpenLog - Opens the profile log file and prepares to
00012     take timings.
00013         ProfRecordTime - Records the time of an event.
00014         ProfCloseLog - Writes the profiling data to the file
00015     and closes it.
00016
00017     COMMENTS: These routines depend on the existence of a high-resolution
00018         performance counter.
00019 */
00020 #pragma once
00021
00022 // Maximum size for the profile log.
00023 // After the log reaches this size new entries "fall off" (threy
00024 // do not get reorded).
00025 #define PROF_LOG_MAX_SIZE (10*1024*1024)
00026
00027 // This critsec is used for mutial exclusion when generating and
00028 // writing the profiling information.  It is also accessible to
00029 // the server routines that may want to use it for syncronising
00030 // their internal operation and creation of profiling info.
00031 // The critsec can only be used between the calls to ProfOpenLog and
00032 // ProfCloseLog.
00033 extern CRITICAL_SECTION ProfCriticalSection;
00034
00035 /*
00036     FUNCTION: ProfOpenLog
00037
00038     PURPOSE: Opens the profile log file and prepares to
00039     take timings.  Also inits the mutex.
00040
00041     PARAMETERS:
00042         LogFileName - Name of the profile log file.
00043
00044     RETURN VALUE:
00045         none
00046
00047     COMMENTS:
00048
00049 */
00050 VOID ProfOpenLog(LPTSTR LogFileName);
00051
00052 /*
00053     FUNCTION: ProfRecordTime
00054
00055     PURPOSE: Creates an entry for the even with identifier id, and
00056         with message msg with a timestamp corresponding to the number of
00057         secods since the start of the program.
00058
00059     PARAMETERS:
00060         id - Id of the event.
00061         msg - Message for the event.
00062
00063     RETURN VALUE:
00064         none
00065
00066     COMMENTS:  If the maximum log size has been exceeded, no action is taken.
00067
00068 */
00069 VOID ProfRecordTime(UINT id, LPTSTR msg);
00070
00071 /*
00072     FUNCTION: ProfCloseLog
00073
00074     PURPOSE: Writes out the acumulated profile data and closes the log file.
00075         Closes the mutex.
00076
00077     PARAMETERS:
00078         none
00079
00080     RETURN VALUE:
00081         none
00082
00083     COMMENTS:
00084
00085 */
00086 VOID ProfCloseLog(VOID);
00087
00088 // end Prof.h
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CServer Member List

This is the complete list of members for CServer, including all inherited members.
ActiveComponents() | CUnknown | [inline, protected, static]
AutoQI(DWORD dwCreateOpts) | CUnknown | [inline, virtual]
AutoRelease() | CUnknown | [inline, virtual]
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CreateInstance(IUnknown *pUnknownOuter, CUnknown **ppNewComponent) | CServer | [static]
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
CServer(IUnknown *pUnknownOuter) | CServer | [private]
CUnknown(IUnknown *pUnknownOuter, LPCSTR className="CUnknown") | CUnknown | [protected]
CUnknown(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CUnknown | [inline]
DisplayObject() | CBase | [virtual]
FinalRelease() | CServer | [private, virtual]
CUnknown::FinalRelease() | CUnknown | [protected, virtual]
FinishQI(IUnknown *pI, REFIID iid, void **ppv) | CUnknown | [protected]
GetBaseType() | CBase | [inline]
GetCLSID() | CServer | [inline, static]
GetDefaultInterface() | CUnknown | [inline, virtual]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CUnknown | [inline, virtual]
GetObjectDesc() | CBase | [inline, virtual]
GetObjectImage() | CUnknown | [inline, virtual]
GetObjectMenu() | CUnknown | [inline, virtual]
GetObjectName() | CUnknown | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetOuterUnknown() const | CUnknown | [inline]
GetParent(SOURCE eSource) | CBase | [virtual]
GetProgID() | CServer | [inline, static]
Init(const CFactoryData *pData) | CServer | [private, virtual]
CUnknown::Init(const CFactoryData *pData)=0 | CUnknown | [protected, pure virtual]
CUnknown::Init() | CUnknown | [inline, protected, virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
LPTEST typedef | ITest |
m_dwCLSCTX | CBase |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_guidSource | CBase |
m_hTreeItem | CBase |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pIService | CBase |
m_pISupportErrorInfo | CBase |
m_pIUnknown | CBase |
m_strObjectDesc | CBase | [protected]
NondelegatingAddRef() | CUnknown | [protected, virtual]
NondelegatingQueryInterface(const IID &iid, void **ppv) | CServer | [private, virtual]
CUnknown::NondelegatingQueryInterface(const IID &, void **) | CUnknown | [protected, virtual]
NondelegatingRelease() | CUnknown | [protected, virtual]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
QueryInterface(REFIID riid, void **ppvObject) | CBase |
Quit() | CUnknown | [protected, virtual]
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CBase |
STDMETHODIMP_(ULONG) Release() | CBase |
Test1(BSTR bstr) | CServer | [private]
Test2(BSTR bstrIn, BSTR *lpbstrOut) | CServer | [private]
~CBase() | CBase | [virtual]
~CServer() | CServer | [private]
~CUnknown() | CUnknown | [protected, virtual]
~CUnknown() | CUnknown | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat/PreComp.h Source File

  • Web
  • NetMeeting
  • NMChat

PreComp.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       PRECOMP.H
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1997-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #ifndef _PRECOMP_H
00016 #define _PRECOMP_H
00017
00018 // System Include files
00019 #include <windows.h>
00020 #include <windowsx.h>
00021 #include <commctrl.h>
00022 #include <tchar.h>
00023 #include <ocidl.h>
00024 #include <stdio.h>
00025
00026 #include "imsconf2.h"
00027
00028 #include "global.h"
00029 #include "clUtil.h"
00030 #include "cConf.h"
00031 #include "cData.h"
00032 #include "cMemb.h"
00033
00034 #include "resource.h"
00035
00036 #endif /* _PRECOMP_H */
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/basesnap.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

basesnap.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  This file contains implementations for IClassFactory
00014 //             and the Snap-in's DLL exported functions
00015
00016
00017 #include <ObjBase.h>
00018 #include <InitGuid.h>
00019 #include "Globals.h"
00020 #include "BaseSnap.h"
00021 #include "CompData.h"
00022 #include "About.h"
00023 #include "Registry.h"
00024
00025
00026 #include "TraceMacro.h"
00027 #undef  MODULESTRING
00028 #define MODULESTRING  _T("BaseSnap")
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 //  Implementation of IClassFactory for CComponentData
00033
00034 //---------------------------------------------------------------------------
00035 CClassFactory::CClassFactory( FACTORY_TYPE eFactoryType )
00036 {
00037   m_cRef = 0;
00038   m_FactoryType = eFactoryType;
00039
00040   InterlockedIncrement((long*)&g_uObjectCount);
00041 }
00042
00043
00044 //---------------------------------------------------------------------------
00045 CClassFactory::~CClassFactory()
00046 {
00047   InterlockedDecrement((long*)&g_uObjectCount);
00048 }
00049
00050
00051 //---------------------------------------------------------------------------
00052 STDMETHODIMP CClassFactory::QueryInterface
00053 (
00054   REFIID   riid,             //[in] Identifier of the requested interface
00055   LPVOID*  ppv               //[out] Address of requested interface
00056 )
00057 {
00058   if( NULL == ppv )
00059     return E_FAIL;
00060
00061   HRESULT hResult = E_NOINTERFACE;
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065   {
00066     *ppv = static_cast<IClassFactory*>(this);
00067   }
00068   else if( IsEqualIID(riid, IID_IClassFactory) )
00069   {
00070     *ppv = static_cast<IClassFactory*>(this);
00071   }
00072
00073   if( *ppv )
00074   {
00075     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00076     hResult = S_OK;
00077   }
00078
00079   return hResult;
00080 }
00081
00082
00083 //---------------------------------------------------------------------------
00084 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00085 {
00086   return InterlockedIncrement( (long*)&m_cRef );
00087 }
00088
00089
00090 //---------------------------------------------------------------------------
00091 STDMETHODIMP_(ULONG) CClassFactory::Release()
00092 {
00093   if( 0 == InterlockedDecrement( (long*)&m_cRef) )
00094   {
00095     delete this;
00096     return 0;
00097   }
00098   return m_cRef;
00099 }
00100
00101 //---------------------------------------------------------------------------
00102 //  Creates an instance of the object type which was passed in the
00103 //  class constructor
00104 //
00105 STDMETHODIMP CClassFactory::CreateInstance
00106 (
00107   LPUNKNOWN  pUnkOuter,      //[in] NULL unless object is part of aggregate
00108   REFIID     riid,           //[in] Reference to interface indentifier
00109   LPVOID*    ppvObj          //[out] Address of requested interface pointer
00110 )
00111 {
00112   HRESULT  hResult = E_FAIL;
00113   void*    pObject = NULL;
00114
00115   if( NULL == ppvObj )
00116     return hResult;
00117
00118   *ppvObj = NULL;
00119
00120   // Our object does does not support aggregation, so we need to
00121   // fail if they ask us to do aggregation.
00122   if( pUnkOuter )
00123     return CLASS_E_NOAGGREGATION;
00124
00125   // Support for providing CSnapinAbout/CComponentData objects
00126   switch( m_FactoryType )
00127   {
00128     case COMPONENTDATA:
00129       pObject = new CComponentData();
00130       break;
00131
00132     case ABOUT:
00133       pObject = new CSnapinAbout();
00134       break;
00135
00136     default:
00137       pObject = NULL;
00138   }
00139
00140   if( NULL == pObject )                // Failed to create an object
00141     return E_INVALIDARG;               // due to bad argument
00142
00143   // QueryInterface will do the AddRef() for us, don't do it here
00144   hResult = ( (LPUNKNOWN)pObject)->QueryInterface( riid, ppvObj );
00145
00146   if( S_OK != hResult )
00147     delete pObject;
00148
00149   return hResult;
00150 }
00151
00152
00153 //---------------------------------------------------------------------------
00154 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00155 {
00156   if( TRUE == fLock )
00157     InterlockedIncrement((long*)&g_uServerLocks);
00158   else
00159     InterlockedDecrement((long*)&g_uServerLocks);
00160
00161   return S_OK;
00162 }
00163
00164
00165 /////////////////////////////////////////////////////////////////////////////
00166 //  Our Snap-in's exported functions
00167 //
00168
00169 //---------------------------------------------------------------------------
00170 //  Entry point into our Snap-in DLL
00171 //
00172 BOOL WINAPI DllMain
00173 (
00174   HINSTANCE  hInstDLL,         //[in] Handle to DLL module
00175   DWORD      fdwReason,        //[in] Reason for calling function
00176   void*      lpvReserved       //[in] Reserved
00177 )
00178 {
00179   if( DLL_PROCESS_ATTACH == fdwReason )
00180   {
00181      g_hInst = hInstDLL;
00182   }
00183
00184   return TRUE;
00185 }
00186
00187
00188 //---------------------------------------------------------------------------
00189 STDAPI DllGetClassObject
00190 (
00191   REFCLSID   rclsid,         //[in] CLSID for the class object
00192   REFIID     riid,           //[in] Reference to interface identifier
00193   LPVOID     *ppvObj         //[out] Object which recieves interface pointer
00194 )
00195 {
00196   // Test for CSnapinAbout
00197   if( (rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout) )
00198     return CLASS_E_CLASSNOTAVAILABLE;
00199
00200   if( !ppvObj )
00201     return E_FAIL;
00202
00203   *ppvObj = NULL;
00204
00205   // We can only hand out IUnknown and IClassFactory pointers.  Fail
00206   // if caller asks for anything else.
00207   if( !IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory) )
00208     return E_NOINTERFACE;
00209
00210   CClassFactory *pFactory = NULL;
00211
00212   // Create the new class factory.  Pass in the type of object to create
00213   if( rclsid == CLSID_CComponentData )
00214     pFactory = new CClassFactory(CClassFactory::COMPONENTDATA);
00215   else if( rclsid == CLSID_CSnapinAbout )
00216     pFactory = new CClassFactory(CClassFactory::ABOUT);
00217
00218
00219   HRESULT hResult = pFactory->QueryInterface( riid, ppvObj );
00220
00221   return hResult;
00222 }
00223
00224
00225 //---------------------------------------------------------------------------
00226 STDAPI DllCanUnloadNow(void)
00227 {
00228   if( 0 == g_uObjectCount && 0 == g_uServerLocks )
00229     return S_OK;
00230   else
00231     return S_FALSE;
00232 }
00233
00234
00235 //---------------------------------------------------------------------------
00236 STDAPI DllRegisterServer()
00237 {
00238   HRESULT hResult = S_FALSE;
00239
00240   do
00241   { // Support ISnapinAbout
00242     hResult = RegisterServer( g_hInst, CLSID_CSnapinAbout, gtszABOUT_NAME );
00243     BREAK_ON_ERROR( hResult );
00244
00245     hResult = RegisterServer( g_hInst, CLSID_CComponentData, gtszSNAPIN_NAME );
00246     BREAK_ON_ERROR( hResult );
00247
00248     hResult = RegisterSnapin( CLSID_CComponentData, gtszSNAPIN_NAME, CLSID_CSnapinAbout, FALSE );
00249     BREAK_ON_ERROR( hResult );
00250
00251   }while( 0 );
00252
00253   return hResult;
00254 }
00255
00256
00257 //---------------------------------------------------------------------------
00258 STDAPI DllUnregisterServer()
00259 {
00260   if( S_OK != UnregisterServer( CLSID_CComponentData )  ||
00261       S_OK != UnregisterServer( CLSID_CSnapinAbout   )  ||
00262       S_OK != UnregisterSnapin( CLSID_CComponentData )
00263     )
00264     return E_UNEXPECTED;
00265   else
00266     return S_OK;
00267 }
00268
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/AppBar/AppBar.c Source File

  • WinUI
  • Shell
  • AppBar

AppBar.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1993 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:     appbar.c
00009 //
00010 //  PURPOSE:    Contains routines to manage an appbar.
00011 //
00012 //  PLATFORMS:  Windows 95, Windows 98, Windows 2000, Windows NT 4.0
00013 //
00014 //  FUNCTIONS:
00015 //      AppBar_Size()               - Updates appbar's size and position
00016 //      AppBar_QueryPos()           - Asks the system if a rect is ok
00017 //      AppBar_QuerySetPos()        - Moves the appbar if possible
00018 //      AppBar_PosChanged()         - Calculates new appbar size and moves
00019 //      AppBar_Callback()           - Callback for appbar notifcations
00020 //      AppBar_Register()           - Registers appbar with the system
00021 //      AppBar_UnRegister()         - Unregisters appbar with the system
00022 //      AppBar_SetAutoHide()        - Sets the autohide state to on or off
00023 //      AppBar_AutoHide()           - Sets autohide
00024 //      AppBar_NoAutoHide()         - Removes autohide
00025 //      AppBar_SetSide()            - Sets the side the appbar is attached to
00026 //      AppBar_SetAlwaysOnTop()     - Sets the always on top state
00027 //      AppBar_Hide()               - Hides the appbar
00028 //      AppBar_UnHide()             - Shows a hidden appbar
00029 //      AppBar_SetAutoHideTimer()   - Sets a delay for the hiding
00030 //      AppBar_SetAutoUnhideTimer() - Sets a delay for the showing
00031 //      GetAppbarData()             - Retrieves the OPTIONS struct from the
00032 //                                    appbar window bytes
00033 //
00034
00035
00036 #include <windows.h>
00037 #include <windowsx.h>
00038 #include "globals.h"
00039 #include "resource.h"
00040 #include "appbar.h"
00041
00042
00043
00044 /////////////////////////////////////////////////////////////////////////////
00045 // Local Prototypes
00046
00047 BOOL AppBar_AutoHide(HWND hwnd);
00048 BOOL AppBar_NoAutoHide(HWND hwnd);
00049
00050 /////////////////////////////////////////////////////////////////////////////
00051 // Global Variables
00052
00053 BOOL g_fAppRegistered = FALSE;      // TRUE if the appbar is registered
00054 RECT g_rcAppBar;                    // Current rect of the appbar
00055
00056 DWORD g_cxWidth, g_cyHeight;
00057
00058 //
00059 //  FUNCTION:   AppBar_Size(HWND)
00060 //
00061 //  PURPOSE:    Handles updating the appbar's size and position.
00062 //
00063 //  PARAMETERS:
00064 //      hwnd    - handle of the appbar
00065 //
00066 //  COMMENTS:
00067 //
00068
00069 void AppBar_Size(HWND hwnd)
00070 {
00071     RECT rc;
00072     APPBARDATA abd;
00073     POPTIONS pOpt;
00074
00075     if (g_fAppRegistered)
00076     {
00077         DebugMsg("AppBarSize Called\r\n");
00078
00079         pOpt = GetAppbarData(hwnd);
00080
00081         abd.cbSize = sizeof(APPBARDATA);
00082         abd.hWnd = hwnd;
00083
00084         GetWindowRect(hwnd, &rc);
00085         AppBar_QuerySetPos(pOpt->uSide, &rc, &abd, TRUE);
00086     }
00087 }
00088
00089
00090 //
00091 //  FUNCTION:   AppBar_QueryPos
00092 //
00093 //  PURPOSE:    Asks the system if the AppBar can occupy the rectangle specified
00094 //              in lprc.  The system will change the lprc rectangle to make
00095 //              it a valid rectangle on the desktop.
00096 //
00097 //  PARAMETERS:
00098 //      hwnd - Handle to the AppBar window.
00099 //      lprc - Rectange that the AppBar is requesting to occupy.
00100 //
00101
00102 void AppBar_QueryPos(HWND hwnd, LPRECT lprc)
00103 {
00104     POPTIONS pOpt = GetAppbarData(hwnd);
00105     APPBARDATA abd;
00106     int iWidth = 0;
00107     int iHeight = 0;
00108
00109     // Fill out the APPBARDATA struct and save the edge we're moving to
00110     // in the appbar OPTIONS struct.
00111     abd.hWnd = hwnd;
00112     abd.cbSize = sizeof(APPBARDATA);
00113     abd.rc = *lprc;
00114     abd.uEdge = pOpt->uSide;
00115
00116     // Calculate the part we want to occupy.  We only figure out the top
00117     // and bottom coordinates if we're on the top or bottom of the screen.
00118     // Likewise for the left and right.  We will always try to occupy the
00119     // full height or width of the screen edge.
00120     if ((ABE_LEFT == abd.uEdge) || (ABE_RIGHT == abd.uEdge))
00121     {
00122         iWidth = abd.rc.right - abd.rc.left;
00123         abd.rc.top = 0;
00124         abd.rc.bottom = GetSystemMetrics(SM_CYSCREEN);
00125     }
00126     else
00127     {
00128         iHeight = abd.rc.bottom - abd.rc.top;
00129         abd.rc.left = 0;
00130         abd.rc.right = GetSystemMetrics(SM_CXSCREEN);
00131     }
00132
00133     // Ask the system for the screen space
00134     SHAppBarMessage(ABM_QUERYPOS, &abd);
00135
00136     // The system will return an approved position along the edge we're asking
00137     // for.  However, if we can't get the exact position requested, the system
00138     // only updates the edge that's incorrect.  For example, if we want to
00139     // attach to the bottom of the screen and the taskbar is already there,
00140     // we'll pass in a rect like 0, 964, 1280, 1024 and the system will return
00141     // 0, 964, 1280, 996.  Since the appbar has to be above the taskbar, the
00142     // bottom of the rect was adjusted to 996.  We need to adjust the opposite
00143     // edge of the rectangle to preserve the height we want.
00144
00145     switch (abd.uEdge)
00146     {
00147         case ABE_LEFT:
00148             abd.rc.right = abd.rc.left + iWidth;
00149             break;
00150
00151         case ABE_RIGHT:
00152             abd.rc.left = abd.rc.right - iWidth;
00153             break;
00154
00155         case ABE_TOP:
00156             abd.rc.bottom = abd.rc.top + iHeight;
00157             break;
00158
00159         case ABE_BOTTOM:
00160             abd.rc.top = abd.rc.bottom - iHeight;
00161             break;
00162     }
00163
00164
00165     *lprc = abd.rc;
00166 }
00167
00168
00169 //
00170 //  FUNCTION:   AppBar_QuerySetPos(UINT, LPRECT, PAPPBARDATA, BOOL)
00171 //
00172 //  PURPOSE:    Asks the system if the appbar can move itself to a particular
00173 //              side of the screen and then does move the appbar.
00174 //
00175 //  PARAMETERS:
00176 //      uEdge   - Side of the screen to move to.  Can be ABE_TOP, ABE_BOTTOM,
00177 //                ABE_LEFT, or ABE_RIGHT.
00178 //      lprc    - Screen rect the appbar wishes to occupy.  This will be
00179 //                modified and will return the area the system will let the
00180 //                appbar occupy.
00181 //      pabd    - Pointer to the APPBARDATA struct used in all appbar system
00182 //                calls.
00183 //      fMove   - TRUE if the function should move the appbar, FALSE if the
00184 //                caller will move the AppBar.
00185 //
00186
00187 void AppBar_QuerySetPos(UINT uEdge, LPRECT lprc, PAPPBARDATA pabd, BOOL fMove)
00188 {
00189     int iHeight = 0;
00190     int iWidth = 0;
00191     POPTIONS pOpt = GetAppbarData(pabd->hWnd);
00192
00193     DebugMsg("AppBarQuerySetPos: uEdge=%d, lprc->left=%d, lprc->top=%d, "
00194              "lprc->right=%d, lprc->bottom=%d\r\n", uEdge, lprc->left,
00195              lprc->top, lprc->right, lprc->bottom);
00196
00197     // Fill out the APPBARDATA struct and save the edge we're moving to
00198     // in the appbar OPTIONS struct.
00199     pabd->rc = *lprc;
00200     pabd->uEdge = uEdge;
00201     pOpt->uSide = uEdge;
00202
00203     AppBar_QueryPos(pabd->hWnd, &(pabd->rc));
00204
00205
00206     // Tell the system we're moving to this new approved position.
00207     SHAppBarMessage(ABM_SETPOS, pabd);
00208
00209     if (fMove)
00210     {
00211         // Move the appbar window to the new position
00212         MoveWindow(pabd->hWnd, pabd->rc.left, pabd->rc.top,
00213                    pabd->rc.right - pabd->rc.left,
00214                    pabd->rc.bottom - pabd->rc.top, TRUE);
00215     }
00216
00217     // Save the appbar rect.  We use this later when we autohide.  If we're
00218     // currently hidden, then don't mess with this.
00219     if (!pOpt->fAutoHide)
00220         g_rcAppBar = pabd->rc;
00221 }
00222
00223
00224 //
00225 //  FUNCTION:   AppBar_PosChanged(PAPPBARDATA)
00226 //
00227 //  PURPOSE:    The system has changed our position for some reason.  We need
00228 //              to recalculate the position on the screen we want to occupy
00229 //              by determining how wide or thick we are and the update the
00230 //              screen position.
00231 //
00232 //
00233 //  PARAMETERS:
00234 //      pabd    - Pointer to the APPBARDATA structure used in all AppBar calls
00235 //                to the system.
00236 //
00237
00238 void AppBar_PosChanged(PAPPBARDATA pabd)
00239 {
00240     RECT rc;
00241     RECT rcWindow;
00242     int iHeight;
00243     int iWidth;
00244     POPTIONS pOpt = GetAppbarData(pabd->hWnd);
00245
00246     DebugMsg("AppBarPosChanged\r\n");
00247
00248     // Start by getting the size of the screen.
00249     rc.top = 0;
00250     rc.left = 0;
00251     rc.right = GetSystemMetrics(SM_CXSCREEN);
00252     rc.bottom = GetSystemMetrics(SM_CYSCREEN);
00253
00254     // Update the g_rcAppbar so when we slide (if hidden) we slide to the
00255     // right place.
00256     if (pOpt->fAutoHide)
00257     {
00258         g_rcAppBar = rc;
00259         switch (pOpt->uSide)
00260         {
00261             case ABE_TOP:
00262                 g_rcAppBar.bottom = g_rcAppBar.top + g_cyHeight;
00263                 break;
00264
00265             case ABE_BOTTOM:
00266                 g_rcAppBar.top = g_rcAppBar.bottom - g_cyHeight;
00267                 break;
00268
00269             case ABE_LEFT:
00270                 g_rcAppBar.right = g_rcAppBar.left + g_cxWidth;
00271                 break;
00272
00273             case ABE_RIGHT:
00274                 g_rcAppBar.left = g_rcAppBar.right - g_cxWidth;
00275                 break;
00276         }
00277     }
00278
00279     // Now get the current window rectangle and find the height and width
00280     GetWindowRect(pabd->hWnd, &rcWindow);
00281     iHeight = rcWindow.bottom - rcWindow.top;
00282     iWidth = rcWindow.right - rcWindow.left;
00283
00284     // Depending on which side we're on, try to preserve the thickness of
00285     // the window
00286     switch (pOpt->uSide)
00287     {
00288         case ABE_TOP:
00289             rc.bottom = rc.top + iHeight;
00290             break;
00291
00292         case ABE_BOTTOM:
00293             rc.top = rc.bottom - iHeight;
00294             break;
00295
00296         case ABE_LEFT:
00297             rc.right = rc.left + iWidth;
00298             break;
00299
00300         case ABE_RIGHT:
00301             rc.left = rc.right - iWidth;
00302             break;
00303     }
00304
00305     // Move the appbar.
00306     AppBar_QuerySetPos(pOpt->uSide, &rc, pabd, TRUE);
00307
00308 }
00309
00310
00311 //
00312 //  FUNCTION:   AppBar_Callback(HWND, UINT, WPARAM, LPARAM)
00313 //
00314 //  PURPOSE:    Handles notification messages sent from the system to our
00315 //              appbar.
00316 //
00317 //  PARAMETERS:
00318 //      hwnd    - Handle of the appbar window receiving the notification.
00319 //      uMsg    - The appbar notification message that we registered.
00320 //      wParam  - Contains the specific notification code.
00321 //      lParam  - Extra information dependant on the notification code.
00322 //
00323
00324 void AppBar_Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00325 {
00326     APPBARDATA abd;
00327     static HWND hwndZOrder = NULL;
00328     POPTIONS pOpt = GetAppbarData(hwnd);
00329
00330     abd.cbSize = sizeof(abd);
00331     abd.hWnd = hwnd;
00332
00333     switch (wParam)
00334     {
00335         // Notifies the appbar that the taskbar's autohide or always-on-top
00336         // state has changed.  The appbar can use this to conform to the settings
00337         // of the system taskbar.
00338         case ABN_STATECHANGE:
00339             DebugMsg("AppBarCallback: ABN_STATECHANGE\r\n");
00340             break;
00341
00342         // Notifies the appbar when a full screen application is opening or
00343         // closing.  When a full screen app is opening, the appbar must drop
00344         // to the bottom of the Z-Order.  When the app is closing, we should
00345         // restore our Z-order position.
00346         case ABN_FULLSCREENAPP:
00347             DebugMsg("AppBarCallback: ABN_FULLSCREENAPP\r\n");
00348             if (lParam)
00349             {
00350                 // A full screen app is opening.  Move us to the bottom of the
00351                 // Z-Order.
00352
00353                 // First get the window that we're underneath so we can correctly
00354                 // restore our position
00355                 hwndZOrder = GetWindow(hwnd, GW_HWNDPREV);
00356
00357                 // Now move ourselves to the bottom of the Z-Order
00358                 SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
00359                              SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
00360             }
00361             else
00362             {
00363                 // The app is closing.  Restore the Z-order
00364                 SetWindowPos(hwnd, pOpt->fOnTop ? HWND_TOPMOST : hwndZOrder,
00365                              0, 0, 0, 0,
00366                              SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
00367
00368                 hwndZOrder = NULL;
00369             }
00370             break;
00371
00372         // Notifies the appbar when an event has occured that may effect the
00373         // appbar's size and position.  These events include changes in the
00374         // taskbar's size, position, and visiblity as well as adding, removing,
00375         // or resizing another appbar on the same side of the screen.
00376         case ABN_POSCHANGED:
00377             DebugMsg("AppBarCallback: ABN_POSCHANGED\r\n");
00378
00379             // Update our position in response to the system change
00380             AppBar_PosChanged(&abd);
00381             break;
00382     }
00383 }
00384
00385
00386 //
00387 //  FUNCTION:   AppBar_Register(HWND)
00388 //
00389 //  PURPOSE:    Registers the appbar with the system.
00390 //
00391 //  PARAMETERS:
00392 //      hwnd    - handle of the appbar to register.
00393 //
00394 //  RETURN VALUE:
00395 //      Returns TRUE if successful, FALSE otherwise.
00396 //
00397 //  COMMENTS:
00398 //      Sets the system wide g_fAppRegistered variable.
00399 //
00400
00401 BOOL AppBar_Register(HWND hwnd)
00402 {
00403     APPBARDATA abd;
00404
00405     abd.cbSize = sizeof(APPBARDATA);
00406     abd.hWnd = hwnd;
00407     abd.uCallbackMessage = APPBAR_CALLBACK;
00408
00409     g_fAppRegistered = (BOOL)SHAppBarMessage(ABM_NEW, &abd);
00410     return g_fAppRegistered;
00411 }
00412
00413
00414 //
00415 //  FUNCTION:   AppBar_UnRegister(HWND)
00416 //
00417 //  PARAMETERS:
00418 //      hwnd    - handle of the appbar to register.
00419 //
00420 //  RETURN VALUE:
00421 //      Returns TRUE if successful, FALSE otherwise.
00422 //
00423 //  COMMENTS:
00424 //      Sets the system wide g_fAppRegistered variable.
00425 //
00426
00427 BOOL AppBar_UnRegister(HWND hwnd)
00428 {
00429     APPBARDATA abd;
00430
00431     abd.cbSize = sizeof(APPBARDATA);
00432     abd.hWnd = hwnd;
00433
00434     g_fAppRegistered = !SHAppBarMessage(ABM_REMOVE, &abd);
00435
00436     return !g_fAppRegistered;
00437 }
00438
00439
00440 //
00441 //  FUNCTION:   AppBar_SetAutoHide(HWND, BOOL)
00442 //
00443 //  PURPOSE:    Causes the appbar window to either auto hide or stop auto
00444 //              hiding.
00445 //
00446 //  PARAMETERS:
00447 //      hwnd    - Handle of the appbar window to change the auto hide state.
00448 //      fHide   - TRUE if we want the window to autohide, FALSE to stop.
00449 //
00450 //  RETURN VALUE:
00451 //      Returns TRUE if successful, FALSE otherwise.
00452 //
00453
00454 BOOL AppBar_SetAutoHide(HWND hwnd, BOOL fHide)
00455 {
00456     if (fHide)
00457         return AppBar_AutoHide(hwnd);
00458     else
00459         return AppBar_NoAutoHide(hwnd);
00460 }
00461
00462
00463 //
00464 //  FUNCTION:   AppBar_AutoHide(HWND)
00465 //
00466 //  PURPOSE:    Does the work of changing the appbar to autohide.  We check
00467 //              to see if we can autohide, and if so unregister and tell
00468 //              the system we are autohiding.
00469 //
00470 //  PARAMETERS:
00471 //      hwnd    - Window handle of the appbar.
00472 //
00473 //  RETURN VALUE:
00474 //      TRUE if successful, FALSE otherwise.
00475 //
00476
00477 BOOL AppBar_AutoHide(HWND hwnd)
00478 {
00479     HWND hwndAutoHide;
00480     APPBARDATA abd;
00481     POPTIONS pOpt = GetAppbarData(hwnd);
00482     BOOL fSuccess;
00483     RECT rc;
00484
00485     abd.cbSize = sizeof(APPBARDATA);
00486     abd.hWnd = hwnd;
00487     abd.uEdge = pOpt->uSide;
00488
00489     // First figure out if someone already has this side for
00490     // autohiding
00491     hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
00492     if (hwndAutoHide != NULL)
00493     {
00494         DebugMsg(TEXT("ERROR: Another appbar is already hiding ")
00495                  TEXT("on this edge.  Cannot set to autohide.\r\n"));
00496         return (FALSE);
00497     }
00498
00499     // We can autohide on this edge.  Set the autohide style.
00500     abd.lParam = TRUE;
00501
00502     fSuccess = (BOOL) SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd);
00503     if (!fSuccess)
00504     {
00505         DebugMsg(TEXT("ERROR: Error trying to set autohidebar.\r\n"));
00506         ErrorHandler();
00507         return (FALSE);
00508     }
00509     else
00510     {
00511         // Since we're allowed to autohide, we need to adjust our screen
00512         // rectangle to the autohidden position.  This will allow the system
00513         // to resize the desktop.
00514         pOpt->fAutoHide = TRUE;
00515         g_cxWidth = pOpt->cxWidth;
00516         g_cyHeight = pOpt->cyHeight;
00517
00518         rc = g_rcAppBar;
00519         switch (pOpt->uSide)
00520         {
00521             case ABE_TOP:
00522                 rc.bottom = rc.top + 2;
00523                 break;
00524             case ABE_BOTTOM:
00525                 rc.top = rc.bottom - 2;
00526                 break;
00527             case ABE_LEFT:
00528                 rc.right = rc.left + 2;
00529                 break;
00530             case ABE_RIGHT:
00531                 rc.left = rc.right - 2;
00532                 break;
00533         }
00534
00535         AppBar_QuerySetPos(pOpt->uSide, &rc, &abd, TRUE);
00536     }
00537
00538     return (TRUE);
00539 }
00540
00541
00542 //
00543 //  FUNCTION:   AppBar_NoAutoHide(HWND)
00544 //
00545 //  PURPOSE:    Does the work of changing the appbar to no-autohide.  We
00546 //              check to make sure we are actually auto hiding, and if so
00547 //              re-register the appbar to get our desktop scren space back.
00548 //
00549 //  PARAMETERS:
00550 //      hwnd    - Window handle of the appbar.
00551 //
00552 //  RETURN VALUE:
00553 //      TRUE if successful, FALSE otherwise.
00554 //
00555
00556 BOOL AppBar_NoAutoHide(HWND hwnd)
00557 {
00558     HWND hwndAutoHide;
00559     APPBARDATA abd;
00560     POPTIONS pOpt = GetAppbarData(hwnd);
00561     BOOL fSuccess;
00562
00563     abd.cbSize = sizeof(APPBARDATA);
00564     abd.hWnd = hwnd;
00565     abd.uEdge = pOpt->uSide;
00566
00567     // First let's check to see if we're the appbar attached to the
00568     // side of the screen
00569     abd.uEdge = pOpt->uSide;
00570     hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
00571     if (hwndAutoHide != hwnd)
00572     {
00573         DebugMsg(TEXT("ERROR: We're not hidden currently\r\n"));
00574         return (FALSE);
00575     }
00576
00577     // We can autohide or stop autohide on this edge.  Set the autohide style.
00578     abd.lParam = FALSE;
00579
00580     fSuccess = (BOOL) SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd);
00581     if (!fSuccess)
00582     {
00583         DebugMsg(TEXT("ERROR: Error trying to set autohidebar.\r\n"));
00584         ErrorHandler();
00585         return (FALSE);
00586     }
00587     else
00588     {
00589         // Need to change the appbar to get the screen desktop space
00590         // back.  Also need to reattach the appbar to that edge of the
00591         // screen.
00592         pOpt->fAutoHide = FALSE;
00593
00594         pOpt->cxWidth = g_cxWidth;
00595         pOpt->cyHeight = g_cyHeight;
00596
00597         AppBar_SetSide(hwnd, pOpt->uSide);
00598     }
00599
00600     return (TRUE);
00601 }
00602
00603
00604 //
00605 //  FUNCTION:   AppBar_SetSide(HWND, UINT)
00606 //
00607 //  PURPOSE:    Sets the side the AppBar is currently attached to.
00608 //
00609 //  PARAMETERS:
00610 //      hwnd    - Window handle of the appbar.
00611 //      uSide   - Side of the screen to attach to.  Can be ABE_TOP, ABE_BOTTOM,
00612 //                ABE_LEFT, or ABE_RIGHT.
00613 //
00614 //  RETURN VALUE:
00615 //      TRUE if successful, FALSE otherwise.
00616 //
00617
00618 BOOL AppBar_SetSide(HWND hwnd, UINT uSide)
00619 {
00620     APPBARDATA abd;
00621     RECT       rc;
00622     POPTIONS   pOpt = GetAppbarData(hwnd);
00623     BOOL       fAutoHide = FALSE;
00624
00625     // Calculate the size of the screen so we can occupy the full width or
00626     // height of the screen on the edge we request.
00627     rc.top = 0;
00628     rc.left = 0;
00629     rc.right = GetSystemMetrics(SM_CXSCREEN);
00630     rc.bottom = GetSystemMetrics(SM_CYSCREEN);
00631
00632     // Fill out the APPBARDATA struct with the basic information
00633     abd.cbSize = sizeof(APPBARDATA);
00634     abd.hWnd = hwnd;
00635
00636     // If the appbar is autohidden, turn that off so we can move the bar
00637     if (pOpt->fAutoHide)
00638     {
00639         fAutoHide = pOpt->fAutoHide;
00640
00641         // Turn off the redrawing of the desktop while we move things around.
00642         // If you put any breakpoints in this area you will lock up the desktop
00643         // Since turning off the desktop repaints turns it off for all the apps
00644         // in the system
00645         SetWindowRedraw(GetDesktopWindow(), FALSE);
00646         AppBar_SetAutoHide(hwnd, FALSE);
00647     }
00648
00649     // Adjust the rectangle to set our height or width depending on the
00650     // side we want.
00651     switch (uSide)
00652     {
00653         case ABE_TOP:
00654             rc.bottom = rc.top + pOpt->cyHeight;
00655             break;
00656         case ABE_BOTTOM:
00657             rc.top = rc.bottom - pOpt->cyHeight;
00658             break;
00659         case ABE_LEFT:
00660             rc.right = rc.left + pOpt->cxWidth;
00661             break;
00662         case ABE_RIGHT:
00663             rc.left = rc.right - pOpt->cxWidth;
00664             break;
00665     }
00666
00667     // Move the appbar to the new screen space.
00668     AppBar_QuerySetPos(uSide, &rc, &abd, TRUE);
00669
00670     // If the appbar was hidden, rehide it now
00671     if (fAutoHide)
00672     {
00673         AppBar_SetAutoHide(hwnd, TRUE);
00674
00675         SetWindowRedraw(GetDesktopWindow(), TRUE);
00676         RedrawWindow(GetDesktopWindow(), NULL, NULL,
00677                      RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
00678     }
00679
00680     return (TRUE);
00681 }
00682
00683
00684 //
00685 //  FUNCTION:   AppBar_SetAlwaysOnTop(HWND, BOOL)
00686 //
00687 //  PURPOSE:    Set's the Always-On-Top state for the appbar.
00688 //
00689 //  PARAMETERS:
00690 //      hwnd    - Window handle of the AppBar to set the state for.
00691 //      fOnTop  - TRUE to set the AppBar to Always-On-Top, FALSE otherwise
00692 //
00693
00694 void AppBar_SetAlwaysOnTop(HWND hwnd, BOOL fOnTop)
00695 {
00696     POPTIONS pOpt = GetAppbarData(hwnd);
00697
00698     // Update the window position to HWND_TOPMOST if we're to be always
00699     // on top, or HWND_NOTOPMOST if we're not.
00700     SetWindowPos(hwnd, (fOnTop) ? HWND_TOPMOST : HWND_NOTOPMOST,
00701                  0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
00702
00703     // Store the setting in the appbar OPTIONS struct.
00704     pOpt->fOnTop = fOnTop;
00705 }
00706
00707
00708 //
00709 //  FUNCTION:   AppBar_Hide(HWND)
00710 //
00711 //  PURPOSE:    Causes the appbar to hide itself.
00712 //
00713 //  PARAMETERS:
00714 //      hwnd    - Handle of the AppBar to hide.
00715 //
00716
00717 void AppBar_Hide(HWND hwnd)
00718 {
00719     POPTIONS pOpt = GetAppbarData(hwnd);
00720     RECT rc;
00721
00722     // Don't want to hide if AutoHide not set
00723     if (!pOpt->fAutoHide)
00724     {
00725         return;
00726     }
00727
00728     // Calculate a hidden rectangle to use
00729     rc = g_rcAppBar;
00730     switch (pOpt->uSide)
00731     {
00732         case ABE_TOP:
00733             rc.bottom = rc.top + 2;
00734             break;
00735         case ABE_BOTTOM:
00736             rc.top = rc.bottom - 2;
00737             break;
00738         case ABE_LEFT:
00739             rc.right = rc.left + 2;
00740             break;
00741         case ABE_RIGHT:
00742             rc.left = rc.right - 2;
00743             break;
00744     }
00745
00746     pOpt->fHiding = TRUE;
00747     SlideWindow(hwnd, &rc);
00748 }
00749
00750
00751 //
00752 //  FUNCTION:   AppBar_UnHide(HWND)
00753 //
00754 //  PURPOSE:    Causes a hidden appbar to unhide itself.
00755 //
00756 //  PARAMETERS:
00757 //      hwnd    - Handle of the appbar to unhide.
00758 //
00759
00760 void AppBar_UnHide(HWND hwnd)
00761 {
00762     POPTIONS pOpt = GetAppbarData(hwnd);
00763
00764     SlideWindow(hwnd, &g_rcAppBar);
00765     pOpt->fHiding = FALSE;
00766
00767     AppBar_SetAutoHideTimer(hwnd);
00768 }
00769
00770
00771 //
00772 //  FUNCTION:   AppBar_SetAutoHideTimer(HWND)
00773 //
00774 //  PURPOSE:    Starts the auto hide timer.
00775 //
00776 //  PARAMETERS:
00777 //      hwnd    - Handle of the appbar to set the timer for.
00778 //
00779 //  COMMENTS:
00780 //      This is called to cause a delay between when the user's mouse leaves
00781 //      the appbar area and the appbar is slid off the screen.
00782 //
00783
00784 void AppBar_SetAutoHideTimer(HWND hwnd)
00785 {
00786     POPTIONS pOpt = GetAppbarData(hwnd);
00787
00788     if (pOpt->fAutoHide)
00789         SetTimer(hwnd, IDT_AUTOHIDE, 500, NULL);
00790 }
00791
00792
00793 //
00794 //  FUNCTION:   AppBar_SetAutoUnhideTimer(HWND)
00795 //
00796 //  PURPOSE:    Starts the auto-UNhide timer.
00797 //
00798 //  PARAMETERS:
00799 //      hwnd    - Handle of the appbar to set the timer for.
00800 //
00801 //  COMMENTS:
00802 //      This is called to cause a delay between the time where the mouse enters
00803 //      the appbar window and the time where the appbar displays itself.
00804 //
00805
00806 void AppBar_SetAutoUnhideTimer(HWND hwnd)
00807 {
00808     POPTIONS pOpt = GetAppbarData(hwnd);
00809
00810     if (pOpt->fAutoHide && pOpt->fHiding)
00811         SetTimer(hwnd, IDT_AUTOUNHIDE, 50, NULL);
00812 }
00813
00814
00815 //
00816 //  FUNCTION:   GetAppbarData(HWND)
00817 //
00818 //  PURPOSE:    Retrieves a pointer to the OPTIONS structure stored in the
00819 //              window's extra bytes.
00820 //
00821 //  PARAMETERS:
00822 //      hwnd    - Handle of the window to retrieve the pointer from.
00823 //
00824 //  RETURN VALUE:
00825 //      Returns a pointer to an OPTIONS struct
00826 //
00827
00828 POPTIONS GetAppbarData(HWND hwnd)
00829 {
00830     return (POPTIONS) GetWindowLongPtr(hwnd, 0);
00831 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpy/ComSpy.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpy

ComSpy.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "resource.h"
00019 #include "initguid.h"
00020 #include "ComSpy.h"
00021 #include "ComSpyCtl.h"
00022 #include "ComSpyCtl_i.c"
00023 #include "ComSpy_i.c"
00024 #include "SpyCon.h"
00025
00026
00027 LONG CExeModule::Unlock()
00028 {
00029   LONG l = CComModule::Unlock();
00030   if (l == 0)
00031   {
00032 #if _WIN32_WINNT >= 0x0400
00033     if (CoSuspendClassObjects() == S_OK)
00034       PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00035 #else
00036     PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
00037 #endif
00038   }
00039   return l;
00040 }
00041
00042 CExeModule _Module;
00043
00044 BEGIN_OBJECT_MAP(ObjectMap)
00045   OBJECT_ENTRY(CLSID_SpyCon, CSpyCon)
00046 END_OBJECT_MAP()
00047
00048
00049 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
00050 {
00051   while (*p1 != NULL)
00052   {
00053     LPCTSTR p = p2;
00054     while (*p != NULL)
00055     {
00056       if (*p1 == *p++)
00057         return p1+1;
00058     }
00059     p1++;
00060   }
00061   return NULL;
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 //
00066 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
00067   HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
00068 {
00069   lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
00070   HRESULT hRes = CoInitialize(NULL);
00071 //  If you are running on NT 4.0 or higher you can use the following call
00072 //  instead to make the EXE free threaded.
00073 //  This means that calls come in on a random RPC thread
00074 //  HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
00075   _ASSERTE(SUCCEEDED(hRes));
00076   _Module.Init(ObjectMap, hInstance);
00077   _Module.dwThreadID = GetCurrentThreadId();
00078   TCHAR szTokens[] = _T("-/");
00079
00080   int nRet = 0;
00081   BOOL bRun = TRUE;
00082   LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
00083   while (lpszToken != NULL)
00084   {
00085     if (_tcsnicmp(lpszToken, _T("UnregServer"), 11)==0)
00086     {
00087       _Module.UpdateRegistryFromResource(IDR_ComSpy, FALSE);
00088       nRet = _Module.UnregisterServer();
00089       bRun = FALSE;
00090       break;
00091     }
00092     if (_tcsnicmp(lpszToken, _T("RegServer"), 9)==0)
00093     {
00094       _Module.UpdateRegistryFromResource(IDR_ComSpy, TRUE);
00095       nRet = _Module.RegisterServer(TRUE);
00096       bRun = FALSE;
00097       break;
00098     }
00099     lpszToken = FindOneOf(lpszToken, szTokens);
00100   }
00101
00102   if (bRun)
00103   {
00104     hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
00105       REGCLS_MULTIPLEUSE);
00106     _ASSERTE(SUCCEEDED(hRes));
00107
00108     ISpyCon * pApp;
00109     CoCreateInstance(CLSID_SpyCon, NULL, CLSCTX_INPROC_SERVER, IID_ISpyCon, (void**)&pApp);
00110     if (pApp)
00111     {
00112       pApp->Run();
00113       MSG msg;
00114       while (GetMessage(&msg, 0, 0, 0))
00115       {
00116         TranslateMessage(&msg);
00117         DispatchMessage(&msg);
00118       }
00119
00120       ULONG ul = pApp -> Release();
00121       _ASSERTE(ul==0);
00122     }
00123     else
00124       _ASSERTE(0);
00125
00126     _Module.RevokeClassObjects();
00127   }
00128
00129   CoUninitialize();
00130   return nRet;
00131 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/PerText.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

PerText.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PERTEXT.H
00003
00004   Summary:   Main include file for the PERTEXT.DLL dynamic link library.
00005              Intended primarily for external users of this DLL who exploit
00006              it via static linkage to the DllRegisterServer and
00007              DllUnregisterServer exported service calls.
00008
00009              For a comprehensive tutorial code tour of PERTEXT's contents
00010              and offerings see the tutorial PERTEXT.HTM file. For
00011              more specific technical details on the internal workings see
00012              the comments dispersed throughout the PERTEXT source code.
00013
00014   Classes:   none.
00015
00016   Functions: DllRegisterServer, DllUnregisterServer.
00017
00018   Origin:    5-20-97: atrent - Editor-inheritance from STOSERVE.H in
00019                the STOSERVE Tutorial Code Sample.
00020
00021 ----------------------------------------------------------------------------
00022   This file is part of the Microsoft COM Tutorial Code Samples.
00023
00024   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00025
00026   This source code is intended only as a supplement to Microsoft
00027   Development Tools and/or on-line documentation.  See these other
00028   materials for detailed information regarding Microsoft code samples.
00029
00030   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00031   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00032   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00033   PARTICULAR PURPOSE.
00034 ==========================================================================+*/
00035
00036 #if !defined(PERTEXT_H)
00037 #define PERTEXT_H
00038
00039 #if !defined(RC_INCLUDE)
00040
00041 #if !defined(_DLLEXPORT_)
00042
00043 // If _DLLEXPORT_ is NOT defined then the default is to import.
00044 #if defined(__cplusplus)
00045 #define DLLENTRY extern "C" __declspec(dllimport)
00046 #else
00047 #define DLLENTRY extern __declspec(dllimport)
00048 #endif
00049 #define STDENTRY DLLENTRY HRESULT WINAPI
00050 #define STDENTRY_(type) DLLENTRY type WINAPI
00051
00052 // Here is the list of server APIs offered by the DLL (using the
00053 // appropriate entry API declaration macros just #defined above).
00054
00055 STDENTRY DllRegisterServer(void);
00056
00057 STDENTRY DllUnregisterServer(void);
00058
00059 #else  // _DLLEXPORT_
00060
00061 // Else if _DLLEXPORT_ is indeed defined then we've been told to export.
00062 #if defined(__cplusplus)
00063 #define DLLENTRY extern "C" __declspec(dllexport)
00064 #else
00065 #define DLLENTRY __declspec(dllexport)
00066 #endif
00067 #define STDENTRY DLLENTRY HRESULT WINAPI
00068 #define STDENTRY_(type) DLLENTRY type WINAPI
00069
00070 #endif // _DLLEXPORT_
00071
00072 #endif // RC_INCLUDE
00073
00074 #endif // PERTEXT_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagCAPSLOOKUP Member List

This is the complete list of members for tagCAPSLOOKUP, including all inherited members.
iValue | tagCAPSLOOKUP
szValue | tagCAPSLOOKUP
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/Authorization/resource.h Source File

  • Multimedia
  • WindowsMediaServices9
  • Authorization

resource.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName: Resource.h
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011 #pragma once
00012 //{{NO_DEPENDENCIES}}
00013 // Microsoft Developer Studio generated include file.
00014 // Used by DBAuth.rc
00015 //
00016 #define IDS_PROJNAME                    100
00017 #define IDR_DBAUTHPLUGIN         101
00018 #define IDR_DBAUTHADMIN          102
00019
00020 // Next default values for new objects
00021 //
00022 #ifdef APSTUDIO_INVOKED
00023 #ifndef APSTUDIO_READONLY_SYMBOLS
00024 #define _APS_NEXT_RESOURCE_VALUE        201
00025 #define _APS_NEXT_COMMAND_VALUE         32768
00026 #define _APS_NEXT_CONTROL_VALUE         201
00027 #define _APS_NEXT_SYMED_VALUE           103
00028 #endif
00029 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppage/adddevicedlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppage

adddevicedlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddDeviceDlg.cpp:  Implementation of the CAddDeviceDlg class.
00015 //
00016
00017
00018
00019 #include "AddDeviceDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddDeviceDlg::CAddDeviceDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddDeviceDlg::~CAddDeviceDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddDeviceDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00055   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00056
00057   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00060   lResult = SendMessage( hBackupCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00061   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00062
00063   lResult = SetWindowText( hDevNameCtrl, _T("") );
00064   SetFocus( hDevNameCtrl );
00065
00066   return 0;
00067 }
00068
00069 //---------------------------------------------------------------------------
00070 LRESULT CAddDeviceDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00071 {
00072   LRESULT          lResult = 0;
00073   NODE_PROPERTIES  NodeProps;
00074
00075   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00076
00077   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00078   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00079   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00080   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00081   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00082   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00083
00084   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00086
00087   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00089
00090   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00092
00093   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00094     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00095
00096   if( BST_CHECKED == SendMessage( hBackupCtrl, BM_GETCHECK, 0, 0 ) )
00097     NodeProps.dwAttributes |= ATTRIBUTE_BACKUP_DEVICE;
00098
00099   // Convert to wide characters here for all platforms.  This is the node name
00100   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00101   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00102   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00103   // Probably a good idea to check for NULL name strings here
00104
00105   // This message passes the user supplied info to the Static Node
00106   SendMessage( m_hParentWnd, WM_ADD_DEVICENODE, (WPARAM)&NodeProps, 0 );
00107
00108   // Now tell the static node we are deleting ourselves so the
00109   // context menu option can be enabled
00110   SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00111
00112   // Call the base class to shut down the dialog
00113   CBaseDialog::OnOK( hDlg, wParam, lParam );
00114   return 0;
00115 }
00116
00117 /////////////////////////////////////////////////////////////////////////////
00118 //  Virtual function implementations
00119
00120 //---------------------------------------------------------------------------
00121 BOOL CAddDeviceDlg::ProcessMessage
00122 (
00123   HWND     hDlg,           //[in] Handle to dialog box
00124   UINT     uMsg,           //[in] Message
00125   WPARAM   wParam,         //[in] First message parameter
00126   LPARAM   lParam          //[in] Second message parameter
00127 )
00128 {
00129   LRESULT lResult = 0;
00130
00131   switch( uMsg )
00132   {
00133     case WM_INITDIALOG:
00134       lResult = OnInitDialog( hDlg, wParam, lParam );
00135       break;
00136
00137     case WM_DESTROY:
00138       lResult = OnDestroy( hDlg, wParam, lParam );
00139       break;
00140
00141     case WM_NCDESTROY:
00142       lResult = OnNcDestroy( hDlg, wParam, lParam );
00143       break;
00144
00145     case WM_CLOSE:
00146       // Not overriding WM_CLOSE and IDCANCEL so we must send
00147       // WM_DEVICENODE_CLOSED before calling the base class or else
00148       // the context menu will stay grayed
00149       SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00150       lResult = OnClose( hDlg, wParam, lParam );
00151
00152     case WM_COMMAND:
00153       switch( wParam )
00154       {
00155         case IDOK:
00156           lResult = OnOK( hDlg, wParam, lParam );
00157           break;
00158
00159         case IDCANCEL:
00160           SendMessage( m_hParentWnd, WM_DEVICENODE_CLOSED, 0, 0 );
00161           lResult = OnCancel( hDlg, wParam, lParam );
00162           break;
00163
00164         default:
00165           break;
00166       }
00167     default:
00168       break;
00169   }
00170   return (BOOL)lResult;
00171 }
00172
00173
00174
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoServe/Connect.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoServe

Connect.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.H
00003
00004   Summary:   Include file declaring COM object classes and constants for
00005              managing the connection points (and their connections)
00006              exposed by the connectable objects in the STOSERVE server.
00007
00008              For a comprehensive tutorial code tour of this module's
00009              contents and offerings see the tutorial STOSERVE.HTM
00010              file. For more specific technical details on the internal
00011              workings see the comments dispersed throughout the module's
00012              source code.
00013
00014   Functions: .
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Origin:    6-10-96: atrent - Editor inheritance from the CONSERVE COM
00020              Tutorial Code Sample. Very little change was required.
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037 #if !defined(CONNECT_H)
00038 #define CONNECT_H
00039
00040 #ifdef __cplusplus
00041
00042
00043 // An enumeration giving symbol names for the connection
00044 // points offered by the DllPaper component in this server.
00045 enum
00046 {
00047   CONNPOINT_PAPERSINK = 0
00048 };
00049
00050 enum
00051 {
00052   // The maximum number of connection points offered by the DllPaper
00053   // component in this STOSERVE server.  The number of items in the
00054   // connection point enumeration above.
00055   MAX_CONNECTION_POINTS = 1,
00056
00057   // A constant for the number of connections to add to the allocation
00058   // of the dynamic connection array.
00059   ALLOC_CONNECTIONS = 8,
00060
00061   // The start value for the connection key (cookie) counter.
00062   COOKIE_START_VALUE = 500
00063 };
00064
00065
00066 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00067   ObjectClass: COEnumConnectionPoints
00068
00069   Summary:     COM object class for enumerating the Connection Points
00070                offered by a connectable object.
00071
00072   Interfaces:  IUnknown
00073                  Standard interface providing COM object features.
00074                IEnumConnectionPoints
00075                  Interface for connection point enumeration.
00076
00077   Aggregation: COEnumConnectionPoints COM Objects are not aggregatable.
00078 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00079 class COEnumConnectionPoints : public IEnumConnectionPoints
00080 {
00081   public:
00082     // Main Object Constructor & Destructor.
00083     COEnumConnectionPoints(IUnknown* pHostObj);
00084     ~COEnumConnectionPoints(void);
00085
00086     // A general method for initializing this newly created object.
00087     // Creates any subordinate arrays, structures, or objects.
00088     HRESULT Init(
00089               ULONG cConnPts,
00090               IConnectionPoint** paConnPts,
00091               ULONG iEnumIndex);
00092
00093     // IUnknown methods. Main object, non-delegating.
00094     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00095     STDMETHODIMP_(ULONG) AddRef(void);
00096     STDMETHODIMP_(ULONG) Release(void);
00097
00098     // IEnumConnectionPoints methods.
00099     STDMETHODIMP         Next(ULONG, IConnectionPoint**, ULONG*);
00100     STDMETHODIMP         Skip(ULONG);
00101     STDMETHODIMP         Reset(void);
00102     STDMETHODIMP         Clone(IEnumConnectionPoints**);
00103
00104   private:
00105     // Private data of COEnumConnectionPoints COM objects.
00106
00107     // Main Object reference count.
00108     ULONG              m_cRefs;
00109
00110     // IUnknown pointer to host COM object being enumerated.
00111     IUnknown*          m_pHostObj;
00112
00113     // Connection Point index variable.
00114     ULONG              m_iEnumIndex;
00115
00116     // Number of Connection Points being enumerated.
00117     ULONG              m_cConnPts;
00118
00119     // Allocated array of Connection Point interface pointers.
00120     IConnectionPoint** m_paConnPts;
00121 };
00122
00123 typedef COEnumConnectionPoints* PCOEnumConnectionPoints;
00124
00125
00126 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00127   ObjectClass: COConnectionPoint
00128
00129   Summary:     Connection Point COM object class. Implements a native
00130                IConnectionPoint interface. The Advise, Unadvise, and
00131                EnumConnections methods use the CThreaded OwnThis mechanism
00132                to provide thread-safe mutually exclusive access to this
00133                connection point object.
00134
00135   Interfaces:  IUnknown
00136                  Standard interface providing COM object features.
00137                IConnectionPoint
00138                  Interface for connection point features.
00139
00140   Aggregation: COConnectionPoint COM Objects are not aggregatable.
00141 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00142 class COConnectionPoint : public IConnectionPoint, public CThreaded
00143 {
00144   public:
00145     // Main Object Constructor & Destructor.
00146     COConnectionPoint(IUnknown* pHostObj);
00147     ~COConnectionPoint(void);
00148
00149     // A general method for initializing this newly created object.
00150     // Creates any subordinate arrays, structures, or objects.
00151     HRESULT Init(REFIID riid);
00152
00153     // IUnknown methods. Main object, non-delegating.
00154     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00155     STDMETHODIMP_(ULONG) AddRef(void);
00156     STDMETHODIMP_(ULONG) Release(void);
00157
00158     // IConnectionPoint methods.
00159     STDMETHODIMP GetConnectionInterface(IID*);
00160     STDMETHODIMP GetConnectionPointContainer(IConnectionPointContainer**);
00161     STDMETHODIMP Advise(IUnknown*, DWORD*);
00162     STDMETHODIMP Unadvise(DWORD);
00163     STDMETHODIMP EnumConnections(IEnumConnections**);
00164
00165   private:
00166     // Private utility methods of COConnectionPoint.
00167     HRESULT GetSlot(UINT* puiFreeSlot);
00168     HRESULT FindSlot(DWORD dwCookie, UINT* puiSlot);
00169
00170     // Private data of COConnectionPoint COM objects.
00171
00172     // Main Object reference count.
00173     ULONG          m_cRefs;
00174
00175     // IUnknown pointer to host COM object offering this connection point.
00176     IUnknown*      m_pHostObj;
00177
00178     // The IID of the sink interface associated with this connection point.
00179     IID            m_iidSink;
00180
00181     // The current connection cookie (key) counter.
00182     DWORD          m_dwNextCookie;
00183
00184     // The current number of live sink connections to this connection point.
00185     UINT           m_cConnections;
00186
00187     // The current maximum index into the dynamic connection array.
00188     UINT           m_uiMaxIndex;
00189
00190     // The dynamic array of sink connections to this connection point.
00191     CONNECTDATA*   m_paConnections;
00192 };
00193
00194 typedef COConnectionPoint* PCOConnectionPoint;
00195
00196
00197 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00198   ObjectClass: COEnumConnections
00199
00200   Summary:     COM object class for enumerating the connections of a
00201                connection point of a connectable object.
00202
00203   Interfaces:  IUnknown
00204                  Standard interface providing COM object features.
00205                IEnumConnections
00206                  Interface for connection enumeration features.
00207
00208   Aggregation: COEnumConnections COM Objects are not aggregatable.
00209 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00210 class COEnumConnections : public IEnumConnections
00211 {
00212   public:
00213     // Main Object Constructor & Destructor.
00214     COEnumConnections(IUnknown* pHostObj);
00215     ~COEnumConnections(void);
00216
00217     // A general method for initializing this newly created object.
00218     // Creates any subordinate arrays, structures, or objects.
00219     HRESULT Init(
00220               ULONG cConnections,
00221               CONNECTDATA* paConnections,
00222               ULONG iEnumIndex);
00223
00224     // IUnknown methods. Main object, non-delegating.
00225     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00226     STDMETHODIMP_(ULONG) AddRef(void);
00227     STDMETHODIMP_(ULONG) Release(void);
00228
00229     // IEnumConnections methods.
00230     STDMETHODIMP         Next(ULONG, CONNECTDATA*, ULONG*);
00231     STDMETHODIMP         Skip(ULONG);
00232     STDMETHODIMP         Reset(void);
00233     STDMETHODIMP         Clone(IEnumConnections**);
00234
00235   private:
00236     // Private data of COEnumConnections COM objects.
00237
00238     // Main Object reference count.
00239     ULONG            m_cRefs;
00240
00241     // IUnknown pointer to host connection point COM object being
00242     // enumerated.
00243     IUnknown*        m_pHostObj;
00244
00245     // Connection index variable.
00246     ULONG            m_iEnumIndex;
00247
00248     // Number of Connections being enumerated.
00249     ULONG            m_cConnections;
00250
00251     // Allocated array of live Connections only.
00252     CONNECTDATA*     m_paConnections;
00253 };
00254
00255 typedef COEnumConnections* PCOEnumConnections;
00256
00257 #endif // __cplusplus
00258
00259
00260 #endif // CONNECT_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/delebase.Cpp Source File

  • SysMgmt
  • MMC
  • Openserv

delebase.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "DeleBase.h"
00021
00022 const GUID CDelegationBase::thisGuid = { 0x2974380b, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 HBITMAP CDelegationBase::m_pBMapSm = NULL;
00025 HBITMAP CDelegationBase::m_pBMapLg = NULL;
00026
00027
00028 //==============================================================
00029 //
00030 // CDelegationBase implementation
00031 //
00032 //
00033 CDelegationBase::CDelegationBase()
00034 : bExpanded(FALSE), m_handle(NULL)
00035 {
00036     if (NULL == m_pBMapSm || NULL == m_pBMapLg)
00037         LoadBitmaps();
00038 }
00039
00040 CDelegationBase::~CDelegationBase()
00041 {
00042 }
00043
00044 // CDelegationBase::AddImages sets up the collection of images to be displayed
00045 // by the IComponent in the result pane as a result of its MMCN_SHOW handler
00046 HRESULT CDelegationBase::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
00047 {
00048     return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
00049         (long *)m_pBMapLg, // pointer to a handle
00050         0, // index of the first image in the strip
00051         RGB(0, 128, 128)  // color of the icon mask
00052         );
00053 }
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyEvictListener/StdAfx.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyEvictListener

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #pragma once
00006
00007 #define STRICT
00008 #ifndef _WIN32_WINNT
00009 #define _WIN32_WINNT 0x0502
00010 #endif
00011 #define _ATL_APARTMENT_THREADED
00012
00013 #include <atlbase.h>
00014 //You may derive a class from CComModule and use it if you want to override
00015 //something, but do not change the name of _Module
00016 extern CComModule _Module;
00017 #include <atlcom.h>
00018
00019 // Interface definitions for IClusCfgEvictListener
00020 #include <ClusCfgServer.h>
00021
00022 // Categories and ClusCfg GUIDS
00023 #include <ClusCfgGuids.h>
00024
00025 // Safe string functions
00026 #include <strsafe.h>
00027
00028 #ifndef RTL_NUMBER_OF
00029 #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
00030 #endif
00031
00032 //{{AFX_INSERT_LOCATION}}
00033 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/UnBufCpy/UnBufCp2.c Source File

  • WinBase
  • IO
  • UnBufCpy

UnBufCp2.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1994 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009
00010 Module Name:
00011
00012     unbufcp2.c
00013
00014 Abstract:
00015
00016     Intended to demonstrate how to complete I/O in a different thread
00017     asynchronously than the I/O was started from.  This is useful for
00018     people who want a more powerful mechanism of asynchronous completion
00019     callbacks than Win32 provides (i.e. VMS developers who are used to ASTs).
00020
00021     Two threads are used. The first thread posts overlapped reads from the
00022     source file. These reads complete to an I/O completion port the second
00023     thread is waiting on. The second thread sees the I/O completion and
00024     posts an overlapped write to the destination file. The write completes
00025     to another I/O completion port that the first thread is waiting on.
00026     The first thread sees the I/O completion and posts another overlapped
00027     read.
00028
00029     Thread 1                                        Thread 2
00030        |                                               |
00031        |                                               |
00032     kick off a few                           -->GetQueuedCompletionStatus(ReadPort)
00033     overlapped reads                         |         |
00034        |                                     |         |
00035        |                                     |  read has completed,
00036   ->GetQueuedCompletionStatus(WritePort)     |  kick off the corresponding
00037   |    |                                     |  write.
00038   | write has completed,                     |         |
00039   | kick off another                         |_________|
00040   | read
00041   |    |
00042   |____|
00043
00044 --*/
00045
00046 #ifdef _IA64_
00047 #pragma warning(disable:4100 4127)
00048 #endif
00049
00050 #include <windows.h>
00051 #include <stdio.h>
00052 #include <stdlib.h>
00053 #include <ctype.h>
00054
00055 //
00056 // File handles for the copy operation. All read operations are
00057 // from SourceFile. All write operations are to DestFile.
00058 //
00059 HANDLE SourceFile;
00060 HANDLE DestFile;
00061
00062 //
00063 // I/O completion ports. All reads from the source file complete
00064 // to ReadPort. All writes to the destination file complete to
00065 // WritePort.
00066 //
00067 HANDLE ReadPort;
00068 HANDLE WritePort;
00069
00070 //
00071 //version information
00072 //
00073 OSVERSIONINFO     ver;
00074
00075 //
00076 // Structure used to track each outstanding I/O. The maximum
00077 // number of I/Os that will be outstanding at any time is
00078 // controllable by the MAX_CONCURRENT_IO definition.
00079 //
00080
00081 #define MAX_CONCURRENT_IO 20
00082
00083 typedef struct _COPY_CHUNK {
00084     OVERLAPPED Overlapped;
00085     LPVOID Buffer;
00086 } COPY_CHUNK, *PCOPY_CHUNK;
00087
00088 COPY_CHUNK CopyChunk[MAX_CONCURRENT_IO];
00089
00090 //
00091 // Define the size of the buffers used to do the I/O.
00092 // 64K is a nice number.
00093 //
00094 #define BUFFER_SIZE (64*1024)
00095
00096 //
00097 // The system's page size will always be a multiple of the
00098 // sector size. Do all I/Os in page-size chunks.
00099 //
00100 DWORD PageSize;
00101
00102
00103 //
00104 // Local function prototypes
00105 //
00106 VOID
00107 WINAPI
00108 WriteLoop(
00109     ULARGE_INTEGER FileSize
00110     );
00111
00112 VOID
00113 ReadLoop(
00114     ULARGE_INTEGER FileSize
00115     );
00116
00117 int
00118 __cdecl
00119 main(
00120     int argc,
00121     char *argv[],
00122     char *envp
00123     )
00124 {
00125     HANDLE WritingThread;
00126     DWORD ThreadId;
00127     ULARGE_INTEGER FileSize;
00128     ULARGE_INTEGER InitialFileSize;
00129     BOOL Success;
00130     DWORD Status;
00131     DWORD StartTime, EndTime;
00132     SYSTEM_INFO SystemInfo;
00133     HANDLE BufferedHandle;
00134
00135     if (argc != 3) {
00136         fprintf(stderr, "Usage: %s SourceFile DestinationFile\n", argv[0]);
00137         exit(1);
00138     }
00139
00140     //
00141     //confirm we are running on Windows NT 3.5 or greater, if not, display notice and
00142     //terminate.  Completion ports are only supported on Win32 & Win32s.  Creating a
00143     //Completion port with no handle specified is only supported on NT 3.51, so we need
00144     //to know what we're running on.  Note, Win32s does not support console apps, thats
00145     //why we exit here if we are not on Windows NT.
00146     //
00147     //
00148     //ver.dwOSVersionInfoSize needs to be set before calling GetVersionInfoEx()
00149     //
00150     ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00151
00152     //
00153     //Failure here could mean several things 1. On an NT system,
00154     //it indicates NT version 3.1 because GetVersionEx() is only
00155     //implemented on NT 3.5.  2. On Windows 3.1 system, it means
00156     //either Win32s version 1.1 or 1.0 is installed.
00157     //
00158     Success = GetVersionEx((LPOSVERSIONINFO) &ver);
00159
00160     if ( (!Success) ||                                   //GetVersionEx() failed - see above.
00161          (ver.dwPlatformId != VER_PLATFORM_WIN32_NT) )   //GetVersionEx() succeeded but we are not on NT.
00162       {
00163        MessageBox(NULL,
00164                   "This sample application can only be run on Windows NT. 3.5 or greater\n"
00165                   "This application will now terminate.",
00166                   "UnBufCp2",
00167                   MB_OK           |
00168                   MB_ICONSTOP     |
00169                   MB_SETFOREGROUND );
00170        exit( 1 );
00171       }
00172
00173     //
00174     // Get the system's page size.
00175     //
00176     GetSystemInfo(&SystemInfo);
00177     PageSize = SystemInfo.dwPageSize;
00178
00179     //
00180     // Open the source file and create the destination file.
00181     // Use FILE_FLAG_NO_BUFFERING to avoid polluting the
00182     // system cache with two copies of the same data.
00183     //
00184
00185     SourceFile = CreateFile(argv[1],
00186                             GENERIC_READ | GENERIC_WRITE,
00187                             FILE_SHARE_READ,
00188                             NULL,
00189                             OPEN_EXISTING,
00190                             FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,
00191                             NULL);
00192     if (SourceFile == INVALID_HANDLE_VALUE) {
00193         fprintf(stderr, "failed to open %s, error %d\n", argv[1], GetLastError());
00194         exit(1);
00195     }
00196     FileSize.LowPart = GetFileSize(SourceFile, &FileSize.HighPart);
00197     if ((FileSize.LowPart == 0xffffffff) && (GetLastError() != NO_ERROR)) {
00198         fprintf(stderr, "GetFileSize failed, error %d\n", GetLastError());
00199         exit(1);
00200     }
00201
00202     DestFile = CreateFile(argv[2],
00203                           GENERIC_READ | GENERIC_WRITE,
00204                           FILE_SHARE_READ | FILE_SHARE_WRITE,
00205                           NULL,
00206                           CREATE_ALWAYS,
00207                           FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,
00208                           SourceFile);
00209     if (DestFile == INVALID_HANDLE_VALUE) {
00210         fprintf(stderr, "failed to open %s, error %d\n", argv[2], GetLastError());
00211         exit(1);
00212     }
00213
00214     //
00215     // Extend the destination file so that the filesystem does not
00216     // turn our asynchronous writes into synchronous ones.
00217     //
00218     InitialFileSize.QuadPart = (FileSize.QuadPart + PageSize - 1) & ~((DWORD_PTR)(PageSize - 1));
00219     Status = SetFilePointer(DestFile,
00220                             InitialFileSize.LowPart,
00221                             (PLONG)&InitialFileSize.HighPart,
00222                             FILE_BEGIN);
00223     if ((Status == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR)) {
00224         fprintf(stderr, "SetFilePointer failed, error %d\n", GetLastError());
00225         exit(1);
00226     }
00227     Success = SetEndOfFile(DestFile);
00228     if (!Success) {
00229         fprintf(stderr, "SetEndOfFile failed, error %d\n", GetLastError());
00230         exit(1);
00231     }
00232
00233     //
00234     //In NT 3.51 it is not necessary to specify the FileHandle parameter
00235     //of CreateIoCompletionPort()--It is legal to specify the FileHandle
00236     //as INVALID_HANDLE_VALUE.  However, for NT 3.5 an overlapped file
00237     //handle is needed.
00238     //
00239     //We know already that we are running on NT, or else we wouldn't have
00240     //gotten this far, so lets see what version we are running on.
00241     //
00242     if (ver.dwMajorVersion == 3 && ver.dwMinorVersion == 50)
00243         {
00244           //
00245           //we're running on NT 3.5 - Completion Ports exists
00246           //
00247           ReadPort = CreateIoCompletionPort(SourceFile,        //file handle to associate with I/O completion port
00248                                             NULL,              //optional handle to existing I/O completion port
00249                                             (DWORD_PTR)SourceFile, //completion key
00250                                             1);                //# of threads allowed to execute concurrently
00251
00252           if (ReadPort == NULL) {
00253             fprintf(stderr, "failed to create ReadPort, error %d\n", GetLastError());
00254             exit(1);
00255           }
00256         }
00257
00258     else
00259       //
00260       //We are running on NT 3.51 or greater.
00261       //
00262       //Create the I/O Completion Port.
00263       //
00264         {
00265           ReadPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, //file handle to associate with I/O completion port
00266                                             NULL,                 //optional handle to existing I/O completion port
00267                                             (DWORD_PTR)SourceFile,    //completion key
00268                                             1);                   //# of threads allowed to execute concurrently
00269
00270
00271
00272
00273          //
00274          //If we need to, aka we're running on NT 3.51, let's associate a file handle with the
00275          //completion port.
00276          //
00277          ReadPort = CreateIoCompletionPort(SourceFile,
00278                                            ReadPort,
00279                                            (DWORD_PTR)SourceFile,  //should be the previously specified key.
00280                                            1);
00281
00282          if (ReadPort == NULL)
00283           {
00284             fprintf(stderr,
00285                     "failed to create ReadPort, error %d\n",
00286                     GetLastError());
00287
00288             exit(1);
00289
00290           }
00291         }
00292
00293     WritePort = CreateIoCompletionPort(DestFile,
00294                                        NULL,
00295                                        (DWORD_PTR)DestFile,
00296                                        1);
00297     if (WritePort == NULL) {
00298         fprintf(stderr, "failed to create WritePort, error %d\n", GetLastError());
00299         exit(1);
00300     }
00301
00302     //
00303     // Start the writing thread
00304     //
00305     WritingThread = CreateThread(NULL,
00306                                  0,
00307                                  (LPTHREAD_START_ROUTINE)WriteLoop,
00308                                  &FileSize,
00309                                  0,
00310                                  &ThreadId);
00311     if (WritingThread == NULL) {
00312         fprintf(stderr, "failed to create write thread, error %d\n", GetLastError());
00313         exit(1);
00314     }
00315     CloseHandle(WritingThread);
00316
00317     StartTime = GetTickCount();
00318
00319     //
00320     // Start the reads
00321     //
00322     ReadLoop(FileSize);
00323
00324     EndTime = GetTickCount();
00325
00326     //
00327     // We need another handle to the destination file that is
00328     // opened without FILE_FLAG_NO_BUFFERING. This allows us to set
00329     // the end-of-file marker to a position that is not sector-aligned.
00330     //
00331     BufferedHandle = CreateFile(argv[2],
00332                                 GENERIC_WRITE,
00333                                 FILE_SHARE_READ | FILE_SHARE_WRITE,
00334                                 NULL,
00335                                 OPEN_EXISTING,
00336                                 0,
00337                                 NULL);
00338     if (BufferedHandle == INVALID_HANDLE_VALUE) {
00339         fprintf(stderr,
00340                 "failed to open buffered handle to %s, error %d\n",
00341                 argv[2],
00342                 GetLastError());
00343         exit(1);
00344     }
00345
00346     //
00347     // Set the destination's file size to the size of the
00348     // source file, in case the size of the source file was
00349     // not a multiple of the page size.
00350     //
00351     Status = SetFilePointer(BufferedHandle,
00352                             FileSize.LowPart,
00353                             (PLONG)&FileSize.HighPart,
00354                             FILE_BEGIN);
00355     if ((Status == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR)) {
00356         fprintf(stderr, "final SetFilePointer failed, error %d\n", GetLastError());
00357         exit(1);
00358     }
00359     Success = SetEndOfFile(BufferedHandle);
00360     if (!Success) {
00361         fprintf(stderr, "SetEndOfFile failed, error %d\n", GetLastError());
00362         exit(1);
00363     }
00364     CloseHandle(BufferedHandle);
00365     CloseHandle(SourceFile);
00366     CloseHandle(DestFile);
00367
00368     printf("\n\n%d bytes copied in %.3f seconds\n",
00369            FileSize.LowPart,
00370            (float)(EndTime-StartTime)/1000.0);
00371     printf("%.2f MB/sec\n",
00372            ((LONGLONG)FileSize.QuadPart/(1024.0*1024.0)) / (((float)(EndTime-StartTime)) / 1000.0));
00373
00374     return(0);
00375
00376 }
00377
00378 VOID
00379 ReadLoop(
00380     ULARGE_INTEGER FileSize
00381     )
00382 {
00383     ULARGE_INTEGER ReadPointer;
00384     BOOL Success;
00385     DWORD NumberBytes;
00386     LPOVERLAPPED CompletedOverlapped;
00387     DWORD_PTR Key;
00388     PCOPY_CHUNK Chunk;
00389     int PendingIO = 0;
00390     int i;
00391
00392     //
00393     // Start reading the file. Kick off MAX_CONCURRENT_IO reads, then just
00394     // loop waiting for writes to complete.
00395     //
00396     ReadPointer.QuadPart = 0;
00397
00398     for (i=0; i < MAX_CONCURRENT_IO; i++) {
00399         if (ReadPointer.QuadPart >= FileSize.QuadPart) {
00400             break;
00401         }
00402         //
00403         // Use VirtualAlloc so we get a page-aligned buffer suitable
00404         // for unbuffered I/O.
00405         //
00406         CopyChunk[i].Buffer = VirtualAlloc(NULL,
00407                                            BUFFER_SIZE,
00408                                            MEM_COMMIT,
00409                                            PAGE_READWRITE);
00410         if (CopyChunk[i].Buffer == NULL) {
00411             fprintf(stderr, "VirtualAlloc %d failed, error %d\n",i, GetLastError());
00412             exit(1);
00413         }
00414         CopyChunk[i].Overlapped.Offset = ReadPointer.LowPart;
00415         CopyChunk[i].Overlapped.OffsetHigh = ReadPointer.HighPart;
00416         CopyChunk[i].Overlapped.hEvent = NULL;     // not needed
00417
00418         Success = ReadFile(SourceFile,
00419                            CopyChunk[i].Buffer,
00420                            BUFFER_SIZE,
00421                            &NumberBytes,
00422                            &CopyChunk[i].Overlapped);
00423
00424         if (!Success && (GetLastError() != ERROR_IO_PENDING)) {
00425             fprintf(stderr,
00426                     "ReadFile at %lx failed, error %d\n",
00427                     ReadPointer.LowPart,
00428                     GetLastError());
00429             exit(1);
00430         } else {
00431             ReadPointer.QuadPart += BUFFER_SIZE;
00432             ++PendingIO;
00433
00434         }
00435     }
00436
00437     //
00438     // We have started the initial async. reads, enter the main loop.
00439     // This simply waits until a write completes, then issues the next
00440     // read.
00441     //
00442     while (PendingIO) {
00443         Success = GetQueuedCompletionStatus(WritePort,
00444                                             &NumberBytes,
00445                                             &Key,
00446                                             &CompletedOverlapped,
00447                                             INFINITE);
00448         if (!Success) {
00449             //
00450             // Either the function failed to dequeue a completion packet
00451             // (CompletedOverlapped is not NULL) or it dequeued a completion
00452             // packet of a failed I/O operation (CompletedOverlapped is NULL).
00453             //
00454             fprintf(stderr,
00455                     "GetQueuedCompletionStatus on the IoPort failed, error %d\n",
00456                     GetLastError());
00457             exit(1);
00458         }
00459         //
00460         // Issue the next read using the buffer that has just completed.
00461         //
00462         if (ReadPointer.QuadPart < FileSize.QuadPart) {
00463             Chunk = (PCOPY_CHUNK)CompletedOverlapped;
00464             Chunk->Overlapped.Offset = ReadPointer.LowPart;
00465             Chunk->Overlapped.OffsetHigh = ReadPointer.HighPart;
00466             ReadPointer.QuadPart += BUFFER_SIZE;
00467             Success = ReadFile(SourceFile,
00468                                Chunk->Buffer,
00469                                BUFFER_SIZE,
00470                                &NumberBytes,
00471                                &Chunk->Overlapped);
00472
00473             if (!Success && (GetLastError() != ERROR_IO_PENDING)) {
00474                 fprintf(stderr,
00475                         "ReadFile at %lx failed, error %d\n",
00476                         Chunk->Overlapped.Offset,
00477                         GetLastError());
00478                 exit(1);
00479             }
00480         }
00481         else {
00482             //
00483             // There are no more reads left to issue, just wait
00484             // for the pending writes to drain.
00485             //
00486             --PendingIO;
00487
00488         }
00489     }
00490     //
00491     // All done. There is no need to call VirtualFree() to free CopyChunk
00492     // buffers here. The buffers will be freed when this process exits.
00493     //
00494 }
00495
00496 VOID
00497 WINAPI
00498 WriteLoop(
00499     ULARGE_INTEGER FileSize
00500     )
00501 {
00502     BOOL Success;
00503     DWORD_PTR Key;
00504     LPOVERLAPPED CompletedOverlapped;
00505     PCOPY_CHUNK Chunk;
00506     DWORD NumberBytes;
00507     ULARGE_INTEGER TotalBytesWritten;
00508
00509     TotalBytesWritten.QuadPart = 0;
00510
00511     while (TRUE) {
00512         Success = GetQueuedCompletionStatus(ReadPort,
00513                                             &NumberBytes,
00514                                             &Key,
00515                                             &CompletedOverlapped,
00516                                             INFINITE);
00517
00518         if (!Success) {
00519             //
00520             // Either the function failed to dequeue a completion packet
00521             // (CompletedOverlapped is not NULL) or it dequeued a completion
00522             // packet of a failed I/O operation (CompletedOverlapped is NULL).
00523             //
00524             fprintf(stderr,
00525                     "GetQueuedCompletionStatus on the IoPort failed, error %d\n",
00526                     GetLastError());
00527             exit(1);
00528         }
00529
00530         //
00531         // Update the total number of bytes written.
00532         //
00533         TotalBytesWritten.QuadPart += NumberBytes;
00534
00535         //
00536         // Issue the next write using the buffer that has just been read into.
00537         //
00538         Chunk = (PCOPY_CHUNK)CompletedOverlapped;
00539
00540         //
00541         // Round the number of bytes to write up to a sector boundary
00542         //
00543         NumberBytes = (NumberBytes + PageSize - 1) & ~(PageSize-1);
00544
00545         Success = WriteFile(DestFile,
00546                             Chunk->Buffer,
00547                             NumberBytes,
00548                             &NumberBytes,
00549                             &Chunk->Overlapped);
00550
00551         if (!Success && (GetLastError() != ERROR_IO_PENDING)) {
00552             fprintf(stderr,
00553                     "WriteFile at %lx failed, error %d\n",
00554                     Chunk->Overlapped.Offset,
00555                     GetLastError());
00556             exit(1);
00557         }
00558
00559         //
00560         //Check to see if we've copied the complete file, if so return
00561         //
00562         if (TotalBytesWritten.QuadPart >= FileSize.QuadPart)
00563             return;
00564     }
00565 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDSLAdvancedPage Member List

This is the complete list of members for CDSLAdvancedPage, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
CDSLAdvancedPage() | CDSLAdvancedPage |
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CDSLAdvancedPage | [virtual]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hWnd | CPropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_pIPropertyPageSite | CPropertyPage | [protected]
Move(LPCRECT pRect) | CPropertyPage |
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
~CDSLAdvancedPage() | CDSLAdvancedPage | [virtual]
~CPropertyPage() | CPropertyPage | [virtual]
Generated on Wed Nov 13 2024 16:56:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEapCfg Member List

This is the complete list of members for CEapCfg, including all inherited members.
CEapCfg() | CEapCfg | [inline]
DeclareIEAPProviderConfigMembers(IMPL) | CEapCfg |
Generated on Wed Nov 13 2024 16:56:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/Secure/secSvr.h Source File

  • Com
  • Fundamentals
  • DCom
  • Secure

secSvr.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by SECSVR.RC
00004 //
00005 #define IDD_SECSVR                      101
00006 #define IDC_USERNAME                    1000
00007 #define IDC_COLOR                       1001
00008 #define IDC_CHOOSECOLOR                 1002
00009 #define IDC_COLORTEXT                   1003
00010 #define IDC_NOPUTCOLOR                  1004
00011 #define IDC_INITIALIZE                  1005
00012 #define IDC_NOPUTUSERNAME               1006
00013 #define IDC_SERVER_AUTHNLEVEL           1007
00014 #define IDC_SERVER_IMPLEVEL             1008
00015 #define IDC_OBJECTS                     1009
00016
00017 // Next default values for new objects
00018 //
00019 #ifdef APSTUDIO_INVOKED
00020 #ifndef APSTUDIO_READONLY_SYMBOLS
00021 #define _APS_NO_MFC                     1
00022 #define _APS_NEXT_RESOURCE_VALUE        102
00023 #define _APS_NEXT_COMMAND_VALUE         40001
00024 #define _APS_NEXT_CONTROL_VALUE         1005
00025 #define _APS_NEXT_SYMED_VALUE           101
00026 #endif
00027 #endif
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/TextFx/Resource.h Source File

  • Multimedia
  • Gdi
  • TextFx

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by TEXTFX.RC
00004 //
00005 #define IDM_EXIT                        106
00006 #define IDM_CHOOSEFONT                  108
00007 #define IDM_RENDER                      124
00008 #define IDM_SHOWGUIDES                  125
00009 #define IDM_OUTLINE                     126
00010 #define IDM_QUICKTEST                   127
00011 #define IDM_ABOUT                       303
00012 #define DLG_VERFIRST                    400
00013 #define DLG_VERLAST                     404
00014 #define IDC_STATIC                      -1
00015
00016 // Next default values for new objects
00017 //
00018 #ifdef APSTUDIO_INVOKED
00019 #ifndef APSTUDIO_READONLY_SYMBOLS
00020 #define _APS_NO_MFC                     1
00021 #define _APS_NEXT_RESOURCE_VALUE        102
00022 #define _APS_NEXT_COMMAND_VALUE         128
00023 #define _APS_NEXT_CONTROL_VALUE         1001
00024 #define _APS_NEXT_SYMED_VALUE           101
00025 #endif
00026 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Encode/AltName.h Source File

  • Security
  • CertServices
  • Encode

AltName.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1997 - 2000
00006 //
00007 //  File:       altname.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // altname.h: Declaration of the CCertEncodeAltName
00012
00013
00014 #include "resource.h"       // main symbols
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // certenc
00018
00019 #define wszCLASS_CERTENCODEALTNAME wszCLASS_CERTENCODE TEXT("AltName")
00020
00021 class CCertEncodeAltName:
00022     public IDispatchImpl<ICertEncodeAltName, &IID_ICertEncodeAltName, &LIBID_CERTENCODELib>,
00023     public ISupportErrorInfoImpl<&IID_ICertEncodeAltName>,
00024     public CComObjectRoot,
00025     public CComCoClass<CCertEncodeAltName, &CLSID_CCertEncodeAltName>
00026 {
00027 public:
00028     CCertEncodeAltName();
00029     ~CCertEncodeAltName();
00030
00031 BEGIN_COM_MAP(CCertEncodeAltName)
00032     COM_INTERFACE_ENTRY(IDispatch)
00033     COM_INTERFACE_ENTRY(ISupportErrorInfo)
00034     COM_INTERFACE_ENTRY(ICertEncodeAltName)
00035 END_COM_MAP()
00036
00037 DECLARE_NOT_AGGREGATABLE(CCertEncodeAltName)
00038 // Remove the comment from the line above if you don't want your object to
00039 // support aggregation.  The default is to support it
00040
00041 DECLARE_REGISTRY(
00042     CCertEncodeAltName,
00043     wszCLASS_CERTENCODEALTNAME TEXT(".1"),
00044     wszCLASS_CERTENCODEALTNAME,
00045     IDS_CERTENCODEALTNAME_DESC,
00046     THREADFLAGS_BOTH)
00047
00048 // ICertEncodeAltName
00049 public:
00050     STDMETHOD(Decode)(
00051     /* [in] */ BSTR const strBinary);
00052
00053     STDMETHOD(GetNameCount)(
00054     /* [out, retval] */ LONG __RPC_FAR *pNameCount);
00055
00056     STDMETHOD(GetNameChoice)(
00057     /* [in] */ LONG NameIndex,
00058     /* [out, retval] */ LONG __RPC_FAR *pNameChoice);
00059
00060     STDMETHOD(GetName)(
00061     /* [in] */ LONG NameIndex,    // NameIndex | EAN_*
00062     /* [out, retval] */ BSTR __RPC_FAR *pstrName);
00063
00064     STDMETHOD(Reset)(
00065     /* [in] */ LONG NameCount);
00066
00067     STDMETHOD(SetNameEntry)(
00068     /* [in] */ LONG NameIndex,    // NameIndex | EAN_*
00069     /* [in] */ LONG NameChoice,
00070     /* [in] */ BSTR const strName);
00071
00072     STDMETHOD(Encode)(
00073     /* [out, retval] */ BSTR *pstrBinary);
00074 private:
00075     VOID _Cleanup(VOID);
00076
00077     BOOL _VerifyName(
00078     IN LONG NameIndex);
00079
00080     HRESULT _MapName(
00081     IN BOOL fEncode,
00082     IN LONG NameIndex,
00083     OUT CERT_ALT_NAME_ENTRY **ppName);
00084
00085     HRESULT _SetErrorInfo(
00086     IN HRESULT hrError,
00087     IN WCHAR const *pwszDescription);
00088
00089     typedef enum _enumNameType {
00090   enumUnknown = 0,
00091   enumUnicode,
00092   enumAnsi,
00093   enumBlob,
00094   enumOther,
00095     } enumNameType;
00096
00097     enumNameType _NameType(
00098     IN DWORD NameChoice);
00099
00100     CERT_ALT_NAME_ENTRY *m_aValue;
00101     LONG     m_cValue;
00102     CERT_ALT_NAME_INFO  *m_DecodeInfo;
00103     DWORD    m_DecodeLength;
00104     BOOL     m_fConstructing;
00105 };
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/pre.h Source File

  • Com
  • Fundamentals
  • SimpDnd

pre.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: pre.h
00003 //
00004 //      Used for precompiled headers
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008
00009 #if !defined( _PRE_H_)
00010 #define _PRE_H_
00011
00012 #include <windows.h>
00013 #include <ole2.h>
00014 #include <olestd.h>
00015 #include <assert.h>
00016 #include <string.h>
00017 #include "simpdnd.h"
00018 #include "resource.h"
00019 #include <ole2ver.h>
00020
00021
00022 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WinNT/PerfTool/Pdh/StatList/MainWnd.h Source File

  • WinBase
  • WinNT
  • PerfTool
  • Pdh
  • StatList

MainWnd.h

Go to the documentation of this file.
00001 /*
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 data type and constant definitions used by mainwnd.c
00010 */
00011
00012 #include <pdh.h>
00013
00014 // Use larger string buffer for counter path to accomondate longer counter/instance names.
00015 #define COUNTER_STRING_SIZE 1024
00016
00017 typedef struct _CounterInfoBlock {
00018     struct _CounterInfoBlock *pNext;
00019     TCHAR   szCounterPath[COUNTER_STRING_SIZE];
00020     HCOUNTER    hCounter;
00021     PPDH_RAW_COUNTER    pCounterArray;
00022     DWORD       dwFirstIndex;
00023     DWORD       dwNextIndex;
00024     DWORD       dwLastIndex;
00025     PDH_STATISTICS  pdhCurrentStats;
00026     double      dLastValue;
00027 } CIB, *PCIB;
00028
00029 // global functions found in mainwnd.c
00030 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSelectEventsDlg Member List

This is the complete list of members for CSelectEventsDlg, including all inherited members.
AppsListHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSelectEventsDlg |
CSelectEventsDlg() | CSelectEventsDlg | [private]
CSelectEventsDlg(MapStringToAppInfo *spMap, CAppInfo *pSysAppInfo, CComSpy *pSpyObj) | CSelectEventsDlg |
GetCatalogApps() | CSelectEventsDlg |
GetRunningApps() | CSelectEventsDlg |
IDD enum value | CSelectEventsDlg |
LVEventItemChanged(int idCtrl, LPNMHDR pnmh, BOOL &bHandled) | CSelectEventsDlg |
LVSystemEventItemChanged(int idCtrl, LPNMHDR pnmh, BOOL &bHandled) | CSelectEventsDlg |
m_map | CSelectEventsDlg | [private]
m_pSpyObj | CSelectEventsDlg | [private]
m_pSysAppInfo | CSelectEventsDlg | [private]
MarkAllAppsForDelete(bool bDeleteUnused) | CSelectEventsDlg |
OnDestroyDlg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CSelectEventsDlg |
OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) | CSelectEventsDlg |
OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSelectEventsDlg |
OnSelectAllApps(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) | CSelectEventsDlg |
PopulateEventList() | CSelectEventsDlg |
PopulateSysEventList() | CSelectEventsDlg |
SelectAllApps(bool bSelectAll) | CSelectEventsDlg |
SelectApplication(int nItem) | CSelectEventsDlg |
ShowSelectedEvents(CAppInfo *pInfo) | CSelectEventsDlg |
ShowSelectedSystemEvents() | CSelectEventsDlg |
Generated on Wed Nov 13 2024 16:57:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagGRAPHICLOOKUP Member List

This is the complete list of members for tagGRAPHICLOOKUP, including all inherited members.
dwGraphic | tagGRAPHICLOOKUP
wMenuItem | tagGRAPHICLOOKUP
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook ServerEx/ExtObjID.idl Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook ServerEx

ExtObjID.idl

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ExtObjID.idl
00007 //
00008 //  Description:
00009 //      Definition of COM interfaces for the Cluster Administrator
00010 //      ClipBookServerEx Extension DLL.
00011 //
00012 //  Author:
00013 //      <name> (<e-mail name>) Mmmm DD, 2003
00014 //
00015 //  Revision History:
00016 //
00017 //  Notes:
00018 //      This file will be processed by the MIDL tool to
00019 //      produce the type library (ExtObj.tlb) and marshalling code.
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 [
00024     uuid(0047E941-ABBC-456F-8814-11B0B3351B2E),
00025     version(1.0),
00026     helpstring("ClipBookServerEx 1.0 Type Library")
00027 ]
00028 library CLUADMEXLib
00029 {
00030     importlib("stdole2.tlb");
00031     import "CluAdmEx.idl";
00032
00033     [
00034         uuid(9E747617-E5D1-42D7-A8C3-0FC1D418B76B),
00035         helpstring("CoClipBookServerEx Class")
00036     ]
00037     coclass CoClipBookServerEx
00038     {
00039         interface IWEExtendPropertySheet;
00040         interface IWEExtendWizard;
00041     };
00042
00043 };
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcChar.Cpp Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcChar.Cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1998 - 2000 by Microsoft Corporation
00003
00004   THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO
00005   AS "SOFTWARE") IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
00006   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00007   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
00008   NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
00009   ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
00010   CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
00011   MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
00012   POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
00013   LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE
00014   FOREGOING LIMITATION MAY NOT APPLY.
00015
00016   This software may be copied and distributed royalty-free subject to
00017   the following conditions:
00018
00019   1. You must copy all software without modification and must include
00020      all pages, if the software is distributed without inclusion in your
00021      software product. If you are incorporating the software in
00022      conjunction with and as a part of your software product which adds
00023      substantial value, you may modify and include portions of the
00024      software.
00025
00026   2. You must place all copyright notices and other protective
00027      disclaimers and notices contained on the software on all copies of
00028      the software and your software product.
00029
00030   3. Unless the software is incorporated in your software product which
00031      adds substantial value, you may not distribute this software for
00032      profit.
00033
00034   4. You may not use Microsoft's name, logo, or trademarks to market
00035      your software product.
00036
00037   5. You agree to indemnify, hold harmless, and defend Microsoft and its
00038      suppliers from and against any claims or lawsuits, including
00039      attorneys' fees, that arise or result from the use or distribution
00040      of your software product and any modifications to the software.
00041 */
00042
00043
00044 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00045
00046 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00047 //  Microsoft Visual C++, your modifications will be overwritten.
00048
00049
00050 #include "stdafx.h"
00051 #include "ACChar.h"
00052
00053 // Dispatch interfaces referenced by this interface
00054 #include "ACBall.h"
00055 #include "ACComms.h"
00056 #include "ACReq.h"
00057 #include "ACAnim.h"
00058
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061 // CAgentCtlCharacterEx properties
00062
00063 /////////////////////////////////////////////////////////////////////////////
00064 // CAgentCtlCharacterEx operations
00065
00066 CAgentCtlBalloonEx CAgentCtlCharacterEx::GetBalloon()
00067 {
00068   LPDISPATCH pDispatch;
00069   InvokeHelper(0x17, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
00070   return CAgentCtlBalloonEx(pDispatch);
00071 }
00072
00073 CAgentCtlCommandsEx CAgentCtlCharacterEx::GetCommands()
00074 {
00075   LPDISPATCH pDispatch;
00076   InvokeHelper(0x19, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
00077   return CAgentCtlCommandsEx(pDispatch);
00078 }
00079
00080 CString CAgentCtlCharacterEx::GetName()
00081 {
00082   CString result;
00083   InvokeHelper(0x18, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00084   return result;
00085 }
00086
00087 CString CAgentCtlCharacterEx::GetDescription()
00088 {
00089   CString result;
00090   InvokeHelper(0x1c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00091   return result;
00092 }
00093
00094 BOOL CAgentCtlCharacterEx::GetVisible()
00095 {
00096   BOOL result;
00097   InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00098   return result;
00099 }
00100
00101 void CAgentCtlCharacterEx::SetLeft(short nNewValue)
00102 {
00103   static BYTE parms[] =
00104     VTS_I2;
00105   InvokeHelper(0x3, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00106      nNewValue);
00107 }
00108
00109 short CAgentCtlCharacterEx::GetLeft()
00110 {
00111   short result;
00112   InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00113   return result;
00114 }
00115
00116 void CAgentCtlCharacterEx::SetTop(short nNewValue)
00117 {
00118   static BYTE parms[] =
00119     VTS_I2;
00120   InvokeHelper(0x4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00121      nNewValue);
00122 }
00123
00124 short CAgentCtlCharacterEx::GetTop()
00125 {
00126   short result;
00127   InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00128   return result;
00129 }
00130
00131 void CAgentCtlCharacterEx::SetHeight(short nNewValue)
00132 {
00133   static BYTE parms[] =
00134     VTS_I2;
00135   InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00136      nNewValue);
00137 }
00138
00139 short CAgentCtlCharacterEx::GetHeight()
00140 {
00141   short result;
00142   InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00143   return result;
00144 }
00145
00146 void CAgentCtlCharacterEx::SetWidth(short nNewValue)
00147 {
00148   static BYTE parms[] =
00149     VTS_I2;
00150   InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00151      nNewValue);
00152 }
00153
00154 short CAgentCtlCharacterEx::GetWidth()
00155 {
00156   short result;
00157   InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00158   return result;
00159 }
00160
00161 long CAgentCtlCharacterEx::GetSpeed()
00162 {
00163   long result;
00164   InvokeHelper(0xa, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00165   return result;
00166 }
00167
00168 long CAgentCtlCharacterEx::GetPitch()
00169 {
00170   long result;
00171   InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00172   return result;
00173 }
00174
00175 void CAgentCtlCharacterEx::SetIdleOn(BOOL bNewValue)
00176 {
00177   static BYTE parms[] =
00178     VTS_BOOL;
00179   InvokeHelper(0x1d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00180      bNewValue);
00181 }
00182
00183 BOOL CAgentCtlCharacterEx::GetIdleOn()
00184 {
00185   BOOL result;
00186   InvokeHelper(0x1d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00187   return result;
00188 }
00189
00190 BOOL CAgentCtlCharacterEx::Activate(const VARIANT& State)
00191 {
00192   BOOL result;
00193   static BYTE parms[] =
00194     VTS_VARIANT;
00195   InvokeHelper(0x1a, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
00196     &State);
00197   return result;
00198 }
00199
00200 CAgentCtlRequest CAgentCtlCharacterEx::Play(LPCTSTR Animation)
00201 {
00202   LPDISPATCH pDispatch;
00203   static BYTE parms[] =
00204     VTS_BSTR;
00205   InvokeHelper(0xd, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00206     Animation);
00207   return CAgentCtlRequest(pDispatch);
00208 }
00209
00210 CAgentCtlRequest CAgentCtlCharacterEx::Get(LPCTSTR Type, LPCTSTR Name, const VARIANT& Queue)
00211 {
00212   LPDISPATCH pDispatch;
00213   static BYTE parms[] =
00214     VTS_BSTR VTS_BSTR VTS_VARIANT;
00215   InvokeHelper(0x1b, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00216     Type, Name, &Queue);
00217   return CAgentCtlRequest(pDispatch);
00218 }
00219
00220 void CAgentCtlCharacterEx::Stop(const VARIANT& Request)
00221 {
00222   static BYTE parms[] =
00223     VTS_VARIANT;
00224   InvokeHelper(0xe, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
00225      &Request);
00226 }
00227
00228 CAgentCtlRequest CAgentCtlCharacterEx::Wait(LPDISPATCH WaitForRequest)
00229 {
00230   LPDISPATCH pDispatch;
00231   static BYTE parms[] =
00232     VTS_DISPATCH;
00233   InvokeHelper(0x16, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00234     WaitForRequest);
00235   return CAgentCtlRequest(pDispatch);
00236 }
00237
00238 CAgentCtlRequest CAgentCtlCharacterEx::Interrupt(LPDISPATCH InterruptRequest)
00239 {
00240   LPDISPATCH pDispatch;
00241   static BYTE parms[] =
00242     VTS_DISPATCH;
00243   InvokeHelper(0x15, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00244     InterruptRequest);
00245   return CAgentCtlRequest(pDispatch);
00246 }
00247
00248 CAgentCtlRequest CAgentCtlCharacterEx::Speak(const VARIANT& Text, const VARIANT& Url)
00249 {
00250   LPDISPATCH pDispatch;
00251   static BYTE parms[] =
00252     VTS_VARIANT VTS_VARIANT;
00253   InvokeHelper(0xf, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00254     &Text, &Url);
00255   return CAgentCtlRequest(pDispatch);
00256 }
00257
00258 CAgentCtlRequest CAgentCtlCharacterEx::GestureAt(short x, short y)
00259 {
00260   LPDISPATCH pDispatch;
00261   static BYTE parms[] =
00262     VTS_I2 VTS_I2;
00263   InvokeHelper(0x11, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00264     x, y);
00265   return CAgentCtlRequest(pDispatch);
00266 }
00267
00268 CAgentCtlRequest CAgentCtlCharacterEx::MoveTo(short x, short y, const VARIANT& Speed)
00269 {
00270   LPDISPATCH pDispatch;
00271   static BYTE parms[] =
00272     VTS_I2 VTS_I2 VTS_VARIANT;
00273   InvokeHelper(0x12, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00274     x, y, &Speed);
00275   return CAgentCtlRequest(pDispatch);
00276 }
00277
00278 CAgentCtlRequest CAgentCtlCharacterEx::Hide(const VARIANT& Fast)
00279 {
00280   LPDISPATCH pDispatch;
00281   static BYTE parms[] =
00282     VTS_VARIANT;
00283   InvokeHelper(0x13, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00284     &Fast);
00285   return CAgentCtlRequest(pDispatch);
00286 }
00287
00288 CAgentCtlRequest CAgentCtlCharacterEx::Show(const VARIANT& Fast)
00289 {
00290   LPDISPATCH pDispatch;
00291   static BYTE parms[] =
00292     VTS_VARIANT;
00293   InvokeHelper(0x14, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00294     &Fast);
00295   return CAgentCtlRequest(pDispatch);
00296 }
00297
00298 void CAgentCtlCharacterEx::StopAll(const VARIANT& Types)
00299 {
00300   static BYTE parms[] =
00301     VTS_VARIANT;
00302   InvokeHelper(0x1f, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
00303      &Types);
00304 }
00305
00306 short CAgentCtlCharacterEx::GetMoveCause()
00307 {
00308   short result;
00309   InvokeHelper(0x20, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00310   return result;
00311 }
00312
00313 short CAgentCtlCharacterEx::GetVisibilityCause()
00314 {
00315   short result;
00316   InvokeHelper(0x21, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00317   return result;
00318 }
00319
00320 BOOL CAgentCtlCharacterEx::GetHasOtherClients()
00321 {
00322   BOOL result;
00323   InvokeHelper(0x22, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00324   return result;
00325 }
00326
00327 void CAgentCtlCharacterEx::SetSoundEffectsOn(BOOL bNewValue)
00328 {
00329   static BYTE parms[] =
00330     VTS_BOOL;
00331   InvokeHelper(0x23, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00332      bNewValue);
00333 }
00334
00335 BOOL CAgentCtlCharacterEx::GetSoundEffectsOn()
00336 {
00337   BOOL result;
00338   InvokeHelper(0x23, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00339   return result;
00340 }
00341
00342 void CAgentCtlCharacterEx::SetName(LPCTSTR lpszNewValue)
00343 {
00344   static BYTE parms[] =
00345     VTS_BSTR;
00346   InvokeHelper(0x18, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00347      lpszNewValue);
00348 }
00349
00350 void CAgentCtlCharacterEx::SetDescription(LPCTSTR lpszNewValue)
00351 {
00352   static BYTE parms[] =
00353     VTS_BSTR;
00354   InvokeHelper(0x1c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00355      lpszNewValue);
00356 }
00357
00358 CString CAgentCtlCharacterEx::GetExtraData()
00359 {
00360   CString result;
00361   InvokeHelper(0x24, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00362   return result;
00363 }
00364
00365 void CAgentCtlCharacterEx::ShowPopupMenu(short x, short y)
00366 {
00367   static BYTE parms[] =
00368     VTS_I2 VTS_I2;
00369   InvokeHelper(0x25, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
00370      x, y);
00371 }
00372
00373 void CAgentCtlCharacterEx::SetAutoPopupMenu(BOOL bNewValue)
00374 {
00375   static BYTE parms[] =
00376     VTS_BOOL;
00377   InvokeHelper(0x26, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00378      bNewValue);
00379 }
00380
00381 BOOL CAgentCtlCharacterEx::GetAutoPopupMenu()
00382 {
00383   BOOL result;
00384   InvokeHelper(0x26, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00385   return result;
00386 }
00387
00388 void CAgentCtlCharacterEx::SetHelpModeOn(BOOL bNewValue)
00389 {
00390   static BYTE parms[] =
00391     VTS_BOOL;
00392   InvokeHelper(0x27, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00393      bNewValue);
00394 }
00395
00396 BOOL CAgentCtlCharacterEx::GetHelpModeOn()
00397 {
00398   BOOL result;
00399   InvokeHelper(0x27, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
00400   return result;
00401 }
00402
00403 void CAgentCtlCharacterEx::SetHelpContextID(long nNewValue)
00404 {
00405   static BYTE parms[] =
00406     VTS_I4;
00407   InvokeHelper(0x28, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00408      nNewValue);
00409 }
00410
00411 long CAgentCtlCharacterEx::GetHelpContextID()
00412 {
00413   long result;
00414   InvokeHelper(0x28, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00415   return result;
00416 }
00417
00418 short CAgentCtlCharacterEx::GetActive()
00419 {
00420   short result;
00421   InvokeHelper(0x29, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00422   return result;
00423 }
00424
00425 BOOL CAgentCtlCharacterEx::Listen(BOOL Listen)
00426 {
00427   BOOL result;
00428   static BYTE parms[] =
00429     VTS_BOOL;
00430   InvokeHelper(0x2a, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
00431     Listen);
00432   return result;
00433 }
00434
00435 void CAgentCtlCharacterEx::SetLanguageID(long nNewValue)
00436 {
00437   static BYTE parms[] =
00438     VTS_I4;
00439   InvokeHelper(0x2b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00440      nNewValue);
00441 }
00442
00443 long CAgentCtlCharacterEx::GetLanguageID()
00444 {
00445   long result;
00446   InvokeHelper(0x2b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00447   return result;
00448 }
00449
00450 CString CAgentCtlCharacterEx::GetSRModeID()
00451 {
00452   CString result;
00453   InvokeHelper(0x2e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00454   return result;
00455 }
00456
00457 void CAgentCtlCharacterEx::SetSRModeID(LPCTSTR lpszNewValue)
00458 {
00459   static BYTE parms[] =
00460     VTS_BSTR;
00461   InvokeHelper(0x2e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00462      lpszNewValue);
00463 }
00464
00465 CString CAgentCtlCharacterEx::GetTTSModeID()
00466 {
00467   CString result;
00468   InvokeHelper(0x2f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00469   return result;
00470 }
00471
00472 void CAgentCtlCharacterEx::SetTTSModeID(LPCTSTR lpszNewValue)
00473 {
00474   static BYTE parms[] =
00475     VTS_BSTR;
00476   InvokeHelper(0x2f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00477      lpszNewValue);
00478 }
00479
00480 CString CAgentCtlCharacterEx::GetHelpFile()
00481 {
00482   CString result;
00483   InvokeHelper(0x30, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00484   return result;
00485 }
00486
00487 void CAgentCtlCharacterEx::SetHelpFile(LPCTSTR lpszNewValue)
00488 {
00489   static BYTE parms[] =
00490     VTS_BSTR;
00491   InvokeHelper(0x30, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
00492      lpszNewValue);
00493 }
00494
00495 CString CAgentCtlCharacterEx::GetGuid()
00496 {
00497   CString result;
00498   InvokeHelper(0x31, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00499   return result;
00500 }
00501
00502 short CAgentCtlCharacterEx::GetOriginalHeight()
00503 {
00504   short result;
00505   InvokeHelper(0x32, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00506   return result;
00507 }
00508
00509 short CAgentCtlCharacterEx::GetOriginalWidth()
00510 {
00511   short result;
00512   InvokeHelper(0x33, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
00513   return result;
00514 }
00515
00516 CAgentCtlRequest CAgentCtlCharacterEx::Think(LPCTSTR Text)
00517 {
00518   LPDISPATCH pDispatch;
00519   static BYTE parms[] =
00520     VTS_BSTR;
00521   InvokeHelper(0x34, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,
00522     Text);
00523   return CAgentCtlRequest(pDispatch);
00524 }
00525
00526 CString CAgentCtlCharacterEx::GetVersion()
00527 {
00528   CString result;
00529   InvokeHelper(0x35, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
00530   return result;
00531 }
00532
00533 CAgentCtlAnimationNames CAgentCtlCharacterEx::GetAnimationNames()
00534 {
00535   LPDISPATCH pDispatch;
00536   InvokeHelper(0x36, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
00537   return CAgentCtlAnimationNames(pDispatch);
00538 }
00539
00540 long CAgentCtlCharacterEx::GetSRStatus()
00541 {
00542   long result;
00543   InvokeHelper(0x37, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
00544   return result;
00545 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagOPTIONS Member List

This is the complete list of members for tagOPTIONS, including all inherited members.
cxWidth | tagOPTIONS
cyHeight | tagOPTIONS
fAutoHide | tagOPTIONS
fHiding | tagOPTIONS
fOnTop | tagOPTIONS
iOption | tagOPTIONS
iXScale | tagOPTIONS
iYScale | tagOPTIONS
rcEdges | tagOPTIONS
uSide | tagOPTIONS
Generated on Wed Nov 13 2024 16:58:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/bits/Upload/util.h Source File

  • Web
  • bits
  • Upload

util.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //
00006 //  BITS Upload sample
00007 //  ==================
00008 //
00009 //  Module name:
00010 //  util.h
00011 //
00012 //  Purpose:
00013 //  Forward prototypes for functions defined on util.cpp and
00014 //  declaration/implementation of CSmartComPtr.
00015 //
00016 //----------------------------------------------------------------------------
00017
00018 #pragma once
00019
00020 #define ARRAYSIZE(a)                (sizeof(a)/sizeof(a[0]))
00021 #define MAX_BUFFER_SIZE             4096
00022 #define MAX_GUID_STRING_LENGTH      40
00023
00024
00025 // ----------------------------------------------------------------------------------
00026 // Prototypes for functions defined in util.cpp
00027 // ----------------------------------------------------------------------------------
00028
00029 HRESULT DisplayErrorMessage(LPCWSTR pwszAdditionalMsg, HRESULT hrCode);
00030 LPCWSTR ConvertGuidToString(REFGUID guid);
00031
00032
00033 // ----------------------------------------------------------------------------------
00034 // Parametrized utility classes
00035 // ----------------------------------------------------------------------------------
00036
00037 //
00038 // CSmartComPtr class
00039 // For those used to ATL, this class is very similar to CComPtr
00040 //
00041 template <class T> class CSmartComPtr
00042 {
00043     T *m_pI;
00044
00045     void AddReference()
00046     {
00047         if (m_pI)
00048         {
00049             m_pI->AddRef();
00050         }
00051     }
00052
00053     void ReleaseInterface()
00054     {
00055         if (m_pI)
00056         {
00057             m_pI->Release();
00058             m_pI = NULL;
00059         }
00060     }
00061
00062 public:
00063
00064     CSmartComPtr()
00065     {
00066         m_pI = NULL;
00067     }
00068
00069     CSmartComPtr(T* pInterface)
00070     {
00071         m_pI = pInterface;
00072         AddReference();
00073     }
00074
00075     CSmartComPtr(const CSmartComPtr<T>& lpAnother)
00076     {
00077         m_pI = lpAnother.m_pI;
00078         AddReference();
00079     }
00080
00081     ~CSmartComPtr()
00082     {
00083         ReleaseInterface();
00084     }
00085
00086     T* Release()
00087     {
00088         T* pTemp = m_pI;
00089         m_pI = NULL;
00090         return temp;
00091     }
00092
00093     void Clear()
00094     {
00095         ReleaseInterface();
00096     }
00097
00098     operator const T*() const
00099     {
00100         return m_pI;
00101     }
00102
00103     // shouldn't be used for in/out parameters if interface pointer is
00104     // already initialized
00105     T** operator&()
00106     {
00107         _ASSERT(m_pI == NULL);
00108         return &m_pI;
00109     }
00110
00111     T* operator->() const
00112     {
00113         return m_pI;
00114     }
00115
00116     CSmartComPtr& operator=(CSmartComPtr &Other )
00117     {
00118         ReleaseInterface();
00119         m_pI = Other.m_pI;
00120         AddReference();
00121
00122         return *this;
00123     }
00124
00125     T** GrabOutPtr()
00126     {
00127         ReleaseInterface();
00128         return &m_pI;
00129     }
00130 };
00131
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRefresher Member List

This is the complete list of members for CRefresher, including all inherited members.
AddEnum(IWbemHiPerfEnum *pHiPerfEnum, long *plId) | CRefresher |
AddObject(IWbemObjectAccess *pObj, IWbemObjectAccess **ppReturnObj, long *plId) | CRefresher |
CRefresher(CHiPerfProvider *pProvider, CSampleDataSource *pDS) | CRefresher |
Initialize(IWbemClassObject *pSampleClass) | CRefresher |
m_apEnumerator | CRefresher | [private]
m_apInstances | CRefresher | [private]
m_apInstMap | CRefresher | [private]
m_lRef | CRefresher | [private]
m_pDS | CRefresher | [private]
m_pProvider | CRefresher | [private]
QueryInterface(REFIID riid, void **ppv) | CRefresher |
Refresh(long lFlags) | CRefresher |
RemoveEnum(long lId) | CRefresher |
RemoveObject(long lId) | CRefresher |
STDMETHODIMP_(ULONG) AddRef() | CRefresher |
STDMETHODIMP_(ULONG) Release() | CRefresher |
~CRefresher() | CRefresher | [virtual]
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_FundsRM Member List

This is the complete list of members for _FundsRM, including all inherited members.
_dwFundsAvailable | _FundsRM
_hRM | _FundsRM
_SD | _FundsRM
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • Nameext

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CNamespaceExtension;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/delebase.h Source File

  • SysMgmt
  • MMC
  • Nodes

delebase.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BRANCHES_H
00021 #define _BRANCHES_H
00022
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "globals.h"
00026 #include "resource.h"
00027 #include "LocalRes.h"
00028
00029 class CDelegationBase {
00030 public:
00031     CDelegationBase();
00032     virtual ~CDelegationBase();
00033
00034     virtual const _TCHAR *GetDisplayName(int nCol = 0) = 0;
00035     virtual void GetChildColumnInfo(RESULTDATAITEM *rdi) { }
00036     virtual const GUID & getNodeType() { _ASSERT(FALSE); return IID_NULL; }
00037
00038     virtual const LPARAM GetCookie() { return reinterpret_cast<LPARAM>(this); }
00039     virtual const int GetBitmapIndex() = 0;
00040
00041   virtual CDelegationBase *GetChildPtr(int index) { return NULL; }
00042
00043     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions) { return S_FALSE; }
00044
00045 public:
00046     // virtual functions go here (for MMCN_*)
00047     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent) { return S_FALSE; }
00048     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem) { return S_FALSE; }
00049     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00050     virtual HRESULT OnRename(LPOLESTR pszNewName) { return S_FALSE; }
00051     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect) { return S_FALSE; }
00052     virtual HRESULT OnRefresh() { return S_FALSE; }
00053
00054 public:
00055     static HBITMAP m_pBMapSm;
00056     static HBITMAP m_pBMapLg;
00057
00058 protected:
00059     static void LoadBitmaps() {
00060         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00061         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00062     }
00063
00064     BOOL bExpanded;
00065
00066 private:
00067     // {2974380B-4C4B-11d2-89D8-000021473128}
00068     static const GUID thisGuid;
00069 };
00070
00071 #endif // _BRANCHES_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

gss_OID_set_desc_struct Member List

This is the complete list of members for gss_OID_set_desc_struct, including all inherited members.
count | gss_OID_set_desc_struct
elements | gss_OID_set_desc_struct
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

TPropSetBase< TYPE, OBJTYPE > Member List

This is the complete list of members for TPropSetBase< TYPE, OBJTYPE >, including all inherited members.
AddElement(TYPE element) | CVector< TYPE > | [virtual]
AddPropSet(REFGUID guidPropertySet) | TPropSetBase< TYPE, OBJTYPE > | [virtual]
Attach(CVector &rVector) | CVector< TYPE > | [virtual]
Attach(ULONGcElements, TYPE *rgElements) | CVector< TYPE > | [virtual]
CVector(ULONGulLowerBound=0, ULONGulGrowSize=10) | CVector< TYPE > |
Detach(ULONG *pcElements, TYPE **prgElements) | CVector< TYPE > | [virtual]
FindPropSet(REFGUID guidPropertySet) | TPropSetBase< TYPE, OBJTYPE > | [virtual]
GetCount() | CVector< TYPE > | [inline, virtual]
GetElement(ULONGiIndex) | CVector< TYPE > | [virtual]
GetElements() const | CVector< TYPE > | [inline, virtual]
GetPropSets() | TPropSetBase< TYPE, OBJTYPE > | [inline, virtual]
InsertAt(ULONGiIndex, TYPE element) | CVector< TYPE > | [virtual]
m_cElements | CVector< TYPE > | [protected]
m_rgElements | CVector< TYPE > | [protected]
m_ulGrowSize | CVector< TYPE > | [protected]
m_ulLowerBound | CVector< TYPE > | [protected]
m_ulMaxSize | CVector< TYPE > | [protected]
operator[](ULONGiIndex) | CVector< TYPE > | [inline, virtual]
RemoveAll() | TPropSetBase< TYPE, OBJTYPE > | [virtual]
RemoveAt(ULONGiIndex) | CVector< TYPE > | [virtual]
TPropSetBase(ULONG cElements=0, TYPE *rgElements=NULL) | TPropSetBase< TYPE, OBJTYPE > |
~CVector() | CVector< TYPE > | [virtual]
~TPropSetBase() | TPropSetBase< TYPE, OBJTYPE > | [virtual]
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagHANDLES Member List

This is the complete list of members for tagHANDLES, including all inherited members.
fHandleType | tagHANDLES
hHandle | tagHANDLES
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_DynaCollection Member List

This is the complete list of members for msado15::_DynaCollection, including all inherited members.
_NewEnum() | msado15::_DynaCollection |
Append(Object Object) | msado15::_DynaCollection |
Delete(Variant Index) | msado15::_DynaCollection |
getCount() | msado15::_DynaCollection |
iid | msado15::_DynaCollection | [static]
Refresh() | msado15::_DynaCollection |
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/Resources.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

Resources.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     FILE: Resources.cpp
00005
00006     PURPOSE: Declarations for resource management routines and
00007         data structures.
00008
00009     COMMENTS:  See Resources.h for function and data-type info.
00010
00011 */
00012
00013 #include "common.h"
00014
00015 #include "Resources.h"
00016 #include "Service.h"
00017
00018 #ifdef DEBUG2
00019 #include "DbgMsg.h"
00020 #endif
00021
00022 Counter * CounterCreate(UINT Bound) {
00023     Counter * pCounter;
00024
00025 #ifdef DEBUG2
00026     DbgMsgRecord(TEXT("-> CounterCreate\n"));
00027 #endif
00028
00029     pCounter = (Counter *)AutoHeapAlloc(sizeof(Counter));
00030
00031     if (pCounter == NULL) {
00032         return NULL;
00033     }
00034
00035     pCounter->Value = 0;
00036     pCounter->Bound = Bound;
00037
00038 #ifdef DEBUG2
00039     DbgMsgRecord(TEXT("<- CounterCreate\n"));
00040 #endif
00041
00042     return pCounter;
00043 }
00044
00045 VOID CounterDelete(Counter * pCounter) {
00046
00047 #ifdef DEBUG2
00048     DbgMsgRecord(TEXT("-> CounterDelete\n"));
00049 #endif
00050
00051     ASSERT(pCounter != NULL);
00052
00053     AutoHeapFree(pCounter);
00054
00055 #ifdef DEBUG2
00056     DbgMsgRecord(TEXT("<- CounterDelete\n"));
00057 #endif
00058 }
00059
00060 BOOL CounterIncrement(Counter *pCounter) {
00061     BOOL ret = FALSE;
00062
00063 #ifdef DEBUG2
00064     DbgMsgRecord(TEXT("-> CounterIncrement\n"));
00065 #endif
00066
00067     ASSERT(pCounter != NULL);
00068
00069     // Check for the bound.
00070     if (InterlockedIncrement(&pCounter->Value) > pCounter->Bound) {
00071         ret = FALSE;
00072         InterlockedDecrement(&pCounter->Value);
00073     }
00074     else {
00075         ret = TRUE;
00076     }
00077
00078 #ifdef DEBUG2
00079     DbgMsgRecord(TEXT("<- CounterIncrement\n"));
00080 #endif
00081
00082     return ret;
00083 }
00084
00085 VOID CounterDecrement(Counter *pCounter) {
00086
00087 #ifdef DEBUG2
00088     DbgMsgRecord(TEXT("-> CounterDecrement\n"));
00089 #endif
00090
00091     ASSERT(pCounter != NULL);
00092
00093     InterlockedDecrement(&pCounter->Value);
00094
00095 #ifdef DEBUG2
00096     DbgMsgRecord(TEXT("<- CounterDecrement\n"));
00097 #endif
00098
00099 }
00100
00101 BOOL CountersCreate(Counter *pCounters[], UINT n, UINT * Bounds) {
00102     BOOL ret = FALSE;
00103
00104 #ifdef DEBUG2
00105     DbgMsgRecord(TEXT("-> CountersCreate\n"));
00106 #endif
00107
00108     for (UINT i=0; i<n; i++) {
00109         if ((pCounters[i] = CounterCreate(Bounds[i])) == NULL) {
00110             CountersDelete(pCounters, i-1);
00111             ret = FALSE;
00112             break;
00113         }
00114     }
00115     ret = TRUE;
00116
00117 #ifdef DEBUG2
00118     DbgMsgRecord(TEXT("<- CountersCreate\n"));
00119 #endif
00120
00121     return ret;
00122 }
00123
00124 VOID CountersDelete(Counter *pCounters[], UINT n) {
00125
00126 #ifdef DEBUG2
00127     DbgMsgRecord(TEXT("-> CountersDelete\n"));
00128 #endif
00129
00130     for (UINT i=0; i<n; i++) {
00131         ASSERT(pCounters[i] != NULL);
00132         CounterDelete(pCounters[i]);
00133         pCounters[i] = NULL;
00134     }
00135
00136 #ifdef DEBUG2
00137     DbgMsgRecord(TEXT("<- CountersDelete\n"));
00138 #endif
00139 }
00140
00141 BOOL CountersCheckForNonzero(Counter *pCounters[], UINT n) {
00142     for (UINT i=0; i<n; i++) {
00143         ASSERT(pCounters[i] != NULL);
00144         if (pCounters[i]->Value != 0) {
00145             return TRUE;
00146         }
00147     }
00148     return FALSE;
00149 }
00150
00151 Queue * QueueCreate(BOOL NoCritSec) {
00152     Queue * pQueue;
00153
00154 #ifdef DEBUG2
00155     DbgMsgRecord(TEXT("-> QueueCreate\n"));
00156 #endif
00157
00158     pQueue = (Queue *)AutoHeapAlloc(sizeof(Queue));
00159
00160     if (pQueue == NULL) {
00161         AddToMessageLog(TEXT("QueueCreate: AutoHeapAlloc failed"));
00162         return NULL;
00163     }
00164
00165     pQueue->pFirst = NULL;
00166     pQueue->pLast = NULL;
00167
00168     if (NoCritSec) {
00169         pQueue->lpCriticalSection = NULL;
00170     }
00171     else {
00172         pQueue->lpCriticalSection = (LPCRITICAL_SECTION) AutoHeapAlloc(sizeof(CRITICAL_SECTION));
00173         if (InitializeCriticalSectionAndSpinCount(pQueue->lpCriticalSection, 100) == 0) {
00174             AddToMessageLogProcFailure(TEXT("QueueCreate: InitializeCriticalSectionAndSpinCount"), GetLastError());
00175             QueueDelete(pQueue);
00176             return NULL;
00177         }
00178     }
00179
00180 #ifdef DEBUG2
00181     DbgMsgRecord(TEXT("<- QueueCreate\n"));
00182 #endif
00183
00184     return pQueue;
00185 }
00186
00187 VOID QueueDelete(Queue * pQueue) {
00188     QueueNode *pNextNode;
00189
00190 #ifdef DEBUG2
00191     DbgMsgRecord(TEXT("-> QueueDelete\n"));
00192 #endif
00193
00194     ASSERT(pQueue != NULL);
00195
00196     if (pQueue->lpCriticalSection != NULL) {
00197         DeleteCriticalSection(pQueue->lpCriticalSection);
00198         AutoHeapFree(pQueue->lpCriticalSection);
00199     }
00200
00201     if (pQueue->pFirst != NULL) {
00202         for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNextNode) {
00203             pNextNode = pNode->pNext;
00204             AutoHeapFree(pNode->pData);
00205             AutoHeapFree(pNode);
00206         }
00207     }
00208
00209     AutoHeapFree(pQueue);
00210
00211 #ifdef DEBUG2
00212     DbgMsgRecord(TEXT("<- QueueDelete\n"));
00213 #endif
00214 }
00215
00216 BOOL QueueIsEmpty(Queue * pQueue) {
00217     BOOL Ret = FALSE;
00218
00219     ASSERT(pQueue != NULL);
00220
00221     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00222
00223     Ret = (pQueue->pFirst == NULL);
00224
00225     ASSERT((!Ret) || (pQueue->pFirst == pQueue->pLast));
00226
00227     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00228
00229     return Ret;
00230 }
00231
00232 VOID QueueAdd(Queue *pQueue, VOID *pData, BOOL EnterCritSec) {
00233
00234     ASSERT(pQueue != NULL);
00235
00236 #ifdef DEBUG2
00237     DbgMsgRecord(TEXT("-> QueueAdd\n"));
00238 #endif
00239
00240     QueueNode * pNode = (QueueNode *) AutoHeapAlloc(sizeof(QueueNode));
00241     if (pNode == NULL) {
00242         AddToMessageLog(TEXT("QueueAdd: AutoHeapAlloc failed"));
00243         return;
00244     }
00245
00246     pNode->pNext = NULL;
00247     pNode->pData = pData;
00248
00249     if (pQueue->lpCriticalSection != NULL && EnterCritSec) EnterCriticalSection(pQueue->lpCriticalSection);
00250
00251     if (pQueue->pFirst == NULL) {
00252         //ASSERT(pQueue->pLast == NULL);
00253         pQueue->pFirst = pNode;
00254         pQueue->pLast = pNode;
00255     }
00256     else {
00257         ASSERT(pQueue->pLast->pNext == NULL);
00258         pQueue->pLast->pNext = pNode;
00259         pQueue->pLast = pNode;
00260     }
00261
00262 #ifdef DEBUG2
00263     DbgMsgRecord(TEXT("<- QueueAdd\n"));
00264 #endif
00265
00266     if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00267 }
00268
00269 VOID * QueueRemove(Queue *pQueue) {
00270     VOID * pData;
00271     QueueNode *pFuturepFirst;
00272     VOID * pToFree;
00273
00274     ASSERT(pQueue != NULL);
00275
00276     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00277
00278 #ifdef DEBUG2
00279     DbgMsgRecord(TEXT("-> QueueRemove\n"));
00280 #endif
00281
00282     if (pQueue->pFirst == NULL) {
00283         ASSERT(pQueue->pFirst == pQueue->pLast);
00284
00285         if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00286         return NULL;
00287     }
00288
00289     pData = pQueue->pFirst->pData;
00290     pFuturepFirst = pQueue->pFirst->pNext;
00291
00292     if (pFuturepFirst == NULL) {
00293         pQueue->pLast = NULL;
00294     }
00295
00296     pToFree = pQueue->pFirst;
00297     pQueue->pFirst = pFuturepFirst;
00298
00299 #ifdef DEBUG2
00300     DbgMsgRecord(TEXT("<- QueueRemove\n"));
00301 #endif
00302
00303     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00304
00305     AutoHeapFree(pToFree);
00306
00307     return pData;
00308 }
00309
00310 VOID * QueueRemoveData(Queue *pQueue, VOID *pData) {
00311     QueueNode *pFuturepFirst = NULL;
00312     VOID *pToFree = NULL;
00313     QueueNode *pNodeToFree = NULL;
00314     QueueNode *pPrevNode = NULL;
00315
00316     ASSERT(pQueue != NULL);
00317
00318     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00319
00320 #ifdef DEBUG2
00321     DbgMsgRecord(TEXT("-> QueueRemoveData\n"));
00322 #endif
00323
00324     // Find a node to remove.
00325     // Walk the queue of active client requests
00326     for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNode->pNext) {
00327         if (pNode->pData == pData) {
00328     // If this is not the first node
00329     if (pPrevNode) {
00330       pPrevNode->pNext = pNode->pNext;
00331       if (pQueue->pLast == pNode) {
00332         ASSERT(pNode->pNext == NULL);
00333         pQueue->pLast = pPrevNode;
00334       }
00335     }
00336     else {
00337       pQueue->pFirst = pNode->pNext;
00338     }
00339     pToFree = pNode;
00340     break;
00341         }
00342
00343   pPrevNode = pNode;
00344     }
00345
00346 #ifdef DEBUG2
00347     DbgMsgRecord(TEXT("<- QueueRemoveData\n"));
00348 #endif
00349
00350     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00351
00352     AutoHeapFree(pToFree);
00353
00354     return pData;
00355 }
00356
00357 VOID QueueMoveToBack(Queue *pQueue, QueueNode *pNode, QueueNode *pPrevNode) {
00358
00359     ASSERT(pQueue != NULL);
00360     ASSERT(pNode != NULL);
00361
00362     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00363
00364     // If it is the first element.
00365     if (pPrevNode == NULL) {
00366         pQueue->pFirst = pNode->pNext;
00367     }
00368     // If it has a predecessor in the queue
00369     else {
00370         pPrevNode->pNext = pNode->pNext;
00371     }
00372
00373     // If it is the last element.
00374     if (pNode->pNext == NULL) {
00375         if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00376         return;
00377     }
00378
00379     // Put the subqueue onto the back of the queue.
00380     pNode->pNext = NULL;
00381     if (QueueIsEmpty(pQueue)) {
00382         pQueue->pFirst = pNode;
00383         pQueue->pLast = pNode;
00384     }
00385     else {
00386         pQueue->pLast->pNext = pNode;
00387         pQueue->pLast = pNode;
00388     }
00389
00390     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00391 }
00392
00393 BOOL QueuesCreate(Queue *Queues[], UINT n, BOOL NoCritSec) {
00394     BOOL ret = FALSE;
00395
00396 #ifdef DEBUG2
00397     DbgMsgRecord(TEXT("-> QueuesCreate\n"));
00398 #endif
00399
00400     for (UINT i=0; i<n; i++) {
00401         if ((Queues[i] = QueueCreate(NoCritSec)) == NULL) {
00402             QueuesDelete(Queues, i-1);
00403             ret = FALSE;
00404             break;
00405         }
00406     }
00407
00408     ret = TRUE;
00409
00410 #ifdef DEBUG2
00411     DbgMsgRecord(TEXT("<- QueuesCreate\n"));
00412 #endif
00413
00414     return ret;
00415 }
00416
00417 VOID QueuesDelete(Queue *Queues[], UINT n) {
00418
00419 #ifdef DEBUG2
00420     DbgMsgRecord(TEXT("-> QueuesDelete\n"));
00421 #endif
00422
00423     for (UINT i=0; i<n; i++) {
00424         QueueDelete(Queues[i]);
00425         Queues[i] = NULL;
00426     }
00427
00428 #ifdef DEBUG2
00429     DbgMsgRecord(TEXT("<- QueuesDelete\n"));
00430 #endif
00431
00432 }
00433
00434 VOID QueueHashAdd(Queue *pQueue, PSID Sid, VOID *pValue, BOOL EnterCritSec) {
00435     QueueHashNode *pQueueHashNode;
00436     DWORD SidLength;
00437
00438     ASSERT(pQueue != NULL);
00439
00440     if (pQueue->lpCriticalSection != NULL && EnterCritSec) EnterCriticalSection(pQueue->lpCriticalSection);
00441
00442 #ifdef DEBUG2
00443     DbgMsgRecord(TEXT("-> QueueHashAdd\n"));
00444 #endif
00445
00446     pQueueHashNode = (QueueHashNode *) AutoHeapAlloc(sizeof(QueueHashNode));
00447
00448     SidLength = GetLengthSid(Sid);
00449
00450     // We need to copy the key so that if the original
00451     // copy gets deallocated we still have one.
00452     if ((pQueueHashNode->pKey = AutoHeapAlloc(SidLength)) == NULL) {
00453         AddToMessageLog(TEXT("QueueHashAdd: AutoHeapAlloc failed"));
00454
00455         if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00456         return;
00457     }
00458
00459     if (CopySid(SidLength, pQueueHashNode->pKey, Sid) == 0) {
00460         AddToMessageLogProcFailure(TEXT("QueueHashAdd: CopySid"), GetLastError());
00461
00462         if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00463         return;
00464     }
00465
00466     pQueueHashNode->pValue = pValue;
00467
00468     QueueAdd(pQueue, (VOID *) pQueueHashNode, FALSE);
00469
00470 #ifdef DEBUG2
00471     DbgMsgRecord(TEXT("<- QueueHashAdd\n"));
00472 #endif
00473
00474     if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00475 }
00476
00477 VOID * QueueHashLookup(Queue *pQueue, PSID Sid, BOOL EnterCritSec) {
00478     VOID * pValue;
00479     QueueNode *pNextNode;
00480
00481     ASSERT(pQueue != NULL);
00482
00483     if (pQueue->lpCriticalSection != NULL && EnterCritSec) EnterCriticalSection(pQueue->lpCriticalSection);
00484
00485 #ifdef DEBUG2
00486     DbgMsgRecord(TEXT("-> QueueHashLookup\n"));
00487 #endif
00488
00489     pValue = NULL;
00490
00491     for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNextNode) {
00492         pNextNode = pNode->pNext;
00493         if (EqualSid(((QueueHashNode *)(pNode->pData))->pKey, Sid) == TRUE) {
00494             pValue = ((QueueHashNode *)(pNode->pData))->pValue;
00495             break;
00496         }
00497     }
00498
00499 #ifdef DEBUG2
00500     DbgMsgRecord(TEXT("<- QueueHashLookup\n"));
00501 #endif
00502
00503     if (pQueue->lpCriticalSection != NULL && EnterCritSec) LeaveCriticalSection(pQueue->lpCriticalSection);
00504
00505     return pValue;
00506 }
00507
00508 VOID QueueHashAddToSubqueue(Queue *pHashQueue, PSID pSID, VOID * pData) {
00509
00510     ASSERT(pHashQueue != NULL);
00511
00512     if (pHashQueue->lpCriticalSection != NULL) EnterCriticalSection(pHashQueue->lpCriticalSection);
00513
00514 #ifdef DEBUG2
00515     DbgMsgRecord(TEXT("-> QueueHashAddToSubqueue\n"));
00516 #endif
00517
00518     // Put the request onto the appropriate queue.
00519
00520     // Lookup the subqueue for the user's sid.
00521     Queue * pQueue = (Queue *) QueueHashLookup(pHashQueue, pSID, FALSE);
00522     // If the subqueue does not exist, create it.
00523     if (pQueue == NULL) {
00524         if ((pQueue = QueueCreate(TRUE)) == NULL) {
00525             AddToMessageLog(TEXT("QueueHashAddToSubqueue: QueueCreate failed"));
00526             if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00527             return;
00528   }
00529         QueueHashAdd(pHashQueue, pSID, pQueue, FALSE);
00530     }
00531     // Add the request to the subqueue
00532     QueueAdd(pQueue, pData, FALSE);
00533
00534 #ifdef DEBUG2
00535     DbgMsgRecord(TEXT("<- QueueHashAddToSubqueue\n"));
00536 #endif
00537
00538     if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00539 }
00540
00541 VOID * QueueHashRemoveFromSubqueue(Queue *pQueue) {
00542     Queue * pSubQueue;
00543     QueueNode *pPrevNode;
00544     VOID * pData;
00545
00546     ASSERT(pQueue != NULL);
00547
00548     if (pQueue->lpCriticalSection != NULL) EnterCriticalSection(pQueue->lpCriticalSection);
00549
00550     pSubQueue = NULL;
00551
00552 #ifdef DEBUG2
00553     DbgMsgRecord(TEXT("-> QueueHashRemoveFromSubqueue\n"));
00554 #endif
00555
00556     // If the hash queue is not empty.
00557     if (pQueue->pFirst != NULL) {
00558         // Find the first nonempty subqueue.
00559         pPrevNode = NULL;
00560         for (QueueNode *pNode = pQueue->pFirst; pNode != NULL; pNode = pNode->pNext) {
00561
00562             // Check if it has elements in it.
00563             if (!QueueIsEmpty((Queue*) ((QueueHashNode *)pNode->pData)->pValue)) {
00564                 // Select it.  We will extract an element off this subqueue
00565                 // and put the subqueue into the end of the hash queue.
00566                 pSubQueue = (Queue*) ((QueueHashNode *)pNode->pData)->pValue;
00567
00568                 // Take it off the hash queue and put it
00569                 // on the back.
00570                 QueueMoveToBack(pQueue, pNode, pPrevNode);
00571
00572                 break;
00573             }
00574
00575             pPrevNode = pNode;
00576         }
00577         if (pSubQueue == NULL) {
00578             // We did not find any nonemoty subqueues.
00579             pData = NULL;
00580         }
00581     }
00582     else {
00583         // There are no nonempty subqueues.
00584         pData = NULL;
00585     }
00586
00587     if (pSubQueue != NULL) {
00588         // Extract an element from the subqueue.
00589         pData = QueueRemove(pSubQueue);
00590     }
00591
00592 #ifdef DEBUG2
00593     DbgMsgRecord(TEXT("<- QueueHashRemoveFromSubqueue\n"));
00594 #endif
00595
00596     if (pQueue->lpCriticalSection != NULL) LeaveCriticalSection(pQueue->lpCriticalSection);
00597
00598     return pData;
00599 }
00600
00601 BOOL QueueHashIncrementCounter(Queue *pHashQueue, PSID pSID) {
00602     Counter *pCounter;
00603     BOOL ret;
00604
00605     ASSERT(pHashQueue != NULL);
00606
00607     if (pHashQueue->lpCriticalSection != NULL) EnterCriticalSection(pHashQueue->lpCriticalSection);
00608
00609 #ifdef DEBUG2
00610     DbgMsgRecord(TEXT("-> QueueHashIncrementCounter\n"));
00611 #endif
00612
00613     // Put the counter onto the appropriate queue.
00614     // Lookup the counter for the user's sid.
00615     pCounter = (Counter *) QueueHashLookup(pHashQueue, pSID, FALSE);
00616     // If the counter does not exist, create it.
00617     if (pCounter == NULL) {
00618         if ((pCounter = CounterCreate(MaxUserReqs)) == NULL) {
00619             AddToMessageLog(TEXT("QueueHashIncrementCounter: CounterCreate failed"));
00620             if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00621             return FALSE;
00622         }
00623         QueueHashAdd(pHashQueue, pSID, pCounter, FALSE);
00624     }
00625     // Attempt to increment the counter
00626     ret = CounterIncrement(pCounter);
00627
00628 #ifdef DEBUG2
00629     DbgMsgRecord(TEXT("<- QueueHashIncrementCounter\n"));
00630 #endif
00631
00632     if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00633
00634     return ret;
00635 }
00636
00637 VOID QueueHashDecrementCounter(Queue *pHashQueue, PSID pSID) {
00638     Counter *pCounter;
00639
00640     ASSERT(pHashQueue != NULL);
00641
00642     if (pHashQueue->lpCriticalSection != NULL) EnterCriticalSection(pHashQueue->lpCriticalSection);
00643
00644 #ifdef DEBUG2
00645     DbgMsgRecord(TEXT("-> QueueHashDecrementCounter\n"));
00646 #endif
00647
00648     // Put the counter onto the appropriate queue.
00649     // Lookup the counter for the user's sid.
00650     pCounter = (Counter *) QueueHashLookup(pHashQueue, pSID, FALSE);
00651     // If the counter does not exist, create it.
00652     if (pCounter == NULL) {
00653         if ((pCounter = CounterCreate(MaxUserReqs)) == NULL) {
00654             AddToMessageLog(TEXT("QueueHashIncrementCounter: CounterCreate failed"));
00655             if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00656             return;
00657         }
00658         QueueHashAdd(pHashQueue, pSID, pCounter, FALSE);
00659     }
00660     // Decrement the counter.
00661     CounterDecrement(pCounter);
00662
00663 #ifdef DEBUG2
00664     DbgMsgRecord(TEXT("<- QueueHashDecrementCounter\n"));
00665 #endif
00666
00667     if (pHashQueue->lpCriticalSection != NULL) LeaveCriticalSection(pHashQueue->lpCriticalSection);
00668 }
00669
00670 // end Resources.cpp
00671
00672
00673
00674
00675
00676
00677
00678
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/AutoClaims15/C#/AutoClaims.cs Source File

  • TabletPC
  • AutoClaims15
  • C#

AutoClaims.cs

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: AutoClaims.cs
00013 //  AutoClaims Sample Application
00014 //
00015 //  This sample program simulates an auto insurance claim
00016 //  form. It uses the InkEdit control to allow the user to
00017 //  enter vehicle information and the InkPicture control to
00018 //  illustrate car damage.  The car damage diagram allows
00019 //  the user to select from multiple ink layers;  each layer
00020 //  has its own color and visibility setting.
00021 //
00022 //  The features used are:
00023 //   - PenInputPanel (collecting handwriting in an attached window)
00024 //   - InkEdit (providing Correction UI)
00025 //   - InkPicture (demonstrating multiple layers of ink within a control)
00026 //
00027 //--------------------------------------------------------------------------
00028
00029 using System;
00030 using System.Drawing;
00031 using System.Windows.Forms;
00032 using System.Data;
00033
00034 // The Ink namespace, which contains the Tablet PC Platform API
00035 using Microsoft.Ink;
00036
00037 namespace AutoClaims
00038 {
00039     /// <summary>
00040     /// InkLayer represents a given ink layer, which has a
00041     /// color and visibility setting associated with it.
00042     /// </summary>
00043     struct InkLayer
00044     {
00045         // Declare the ink, color, and visibility for this layer
00046         private Ink myInk;
00047         private Color myColor;
00048         private bool myHidden;
00049
00050         /// <summary>
00051         /// Constructor for InkLayer
00052         /// </summary>
00053         /// <param name="ink">The ink</param>
00054         /// <param name="color">The color of the layer</param>
00055         /// <param name="hidden">True if the layer is hidden</param>
00056         public InkLayer(Ink ink, Color color, bool hidden)
00057         {
00058             myInk = ink;
00059             myColor = color;
00060             myHidden = hidden;
00061         }
00062
00063         /// <summary>
00064         /// The property used to set the ink associated with this layer
00065         /// </summary>
00066         public Ink ActiveInk
00067         {
00068             get
00069             {
00070                 return myInk;
00071             }
00072             set
00073             {
00074                 myInk = value;
00075             }
00076         }
00077
00078         /// <summary>
00079         /// The color associated with this layer
00080         /// </summary>
00081         public Color ActiveColor
00082         {
00083             get
00084             {
00085                 return myColor;
00086             }
00087             set
00088             {
00089                 myColor = value;
00090             }
00091         }
00092
00093         /// <summary>
00094         /// True if this layer is hidden.
00095         /// </summary>
00096         public bool Hidden
00097         {
00098             get
00099             {
00100                 return myHidden;
00101             }
00102             set
00103             {
00104                 myHidden = value;
00105             }
00106         }
00107     }
00108
00109     /// <summary>
00110     /// The AutoClaims Sample Application form class
00111     /// </summary>
00112     public class AutoClaims : System.Windows.Forms.Form
00113     {
00114         // Win32 Error code REGDB_E_CLASSNOTREG
00115         private readonly int ObjectsNotInstalledError = -2147221164; // 0x80040154
00116
00117         // Declare the array of ink layers used the vehicle illustration.
00118         InkLayer[] inkLayers;
00119
00120         // Declare an empty ink object (used when we don't want to draw
00121         // any ink).
00122         Ink emptyInk = null;
00123
00124         // Declare PenInputPanel objects (used to collect handwriting
00125         // for the edit controls on the form)...
00126         // pipShared is shared between the Year, Make, and Model fields
00127         PenInputPanel pipShared = null;
00128         // pipPolicyNumber is used for the Policy Number field
00129         PenInputPanel pipPolicyNumber = null;
00130         // pipName is used for the Insured Name field
00131         PenInputPanel pipName = null;
00132
00133         // Declare a value to hold the index of selected ink
00134         int selectedIndex = -1;
00135
00136         // Declare a value to hold whether the selected ink is hidden
00137         bool selectedHidden = false;
00138
00139         #region Standard Template Code
00140         internal System.Windows.Forms.CheckBox chHideLayer;
00141         internal System.Windows.Forms.Label lblVehicleDamage;
00142         internal System.Windows.Forms.Label lblVehicleDescription;
00143         internal System.Windows.Forms.Label lblModel;
00144         internal System.Windows.Forms.Label lblYear;
00145         internal System.Windows.Forms.Label lblMake;
00146         internal System.Windows.Forms.Label lblPolicyNumber;
00147         internal System.Windows.Forms.Label lblInsuredName;
00148         internal System.Windows.Forms.Label lblInstructions;
00149         internal System.Windows.Forms.Label lblTitle;
00150         internal System.Windows.Forms.PictureBox pictVehicleBox;
00151         internal System.Windows.Forms.PictureBox pictPolicyBox;
00152         internal System.Windows.Forms.PictureBox pictHorzontalBar2;
00153         internal System.Windows.Forms.PictureBox pictHorzontalBar3;
00154         internal System.Windows.Forms.PictureBox pictHorzontalBar1;
00155         internal System.Windows.Forms.PictureBox pictCheckmarks;
00156         internal System.Windows.Forms.ListBox lstAnnotationLayer;
00157         private Microsoft.Ink.InkPicture inkPictVehicle;
00158         private Microsoft.Ink.InkEdit inkEdPolicyNumber;
00159         private Microsoft.Ink.InkEdit inkEdName;
00160         private Microsoft.Ink.InkEdit inkEdYear;
00161         private Microsoft.Ink.InkEdit inkEdMake;
00162         private Microsoft.Ink.InkEdit inkEdModel;
00163         private System.ComponentModel.Container components = null;
00164         #endregion
00165
00166         public AutoClaims()
00167         {
00168             #region Standard Template Code
00169             //
00170             // Required for Windows Form Designer support
00171             //
00172             InitializeComponent();
00173             #endregion
00174         }
00175
00176         #region Standard Template Code
00177         /// <summary>
00178         /// Clean up any resources being used.
00179         /// </summary>
00180         protected override void Dispose( bool disposing )
00181         {
00182             if( disposing )
00183             {
00184                 if (components != null)
00185                 {
00186                     components.Dispose();
00187                 }
00188
00189                 // dispose any resources associated with our input panels
00190                 if (pipShared != null)
00191                 {
00192                     pipShared.Dispose();
00193                 }
00194                 if (pipPolicyNumber != null)
00195                 {
00196                     pipPolicyNumber.Dispose();
00197                 }
00198                 if (pipName != null)
00199                 {
00200                     pipName.Dispose();
00201                 }
00202
00203                 // dispose any resources associated with our ink objects
00204                 foreach (InkLayer layer in inkLayers)
00205                 {
00206                     layer.ActiveInk.Dispose();
00207                 }
00208
00209                 // Dispose the empty ink object
00210                 if(emptyInk != null)
00211                 {
00212                     emptyInk.Dispose();
00213                 }
00214             }
00215             base.Dispose( disposing );
00216         }
00217         #endregion
00218
00219         #region Windows Form Designer generated code
00220         /// <summary>
00221         /// Required method for Designer support - do not modify
00222         /// the contents of this method with the code editor.
00223         /// </summary>
00224         private void InitializeComponent()
00225         {
00226             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AutoClaims));
00227             this.lblVehicleDamage = new System.Windows.Forms.Label();
00228             this.lblVehicleDescription = new System.Windows.Forms.Label();
00229             this.lblModel = new System.Windows.Forms.Label();
00230             this.lblYear = new System.Windows.Forms.Label();
00231             this.lblMake = new System.Windows.Forms.Label();
00232             this.lblPolicyNumber = new System.Windows.Forms.Label();
00233             this.lblInsuredName = new System.Windows.Forms.Label();
00234             this.chHideLayer = new System.Windows.Forms.CheckBox();
00235             this.pictHorzontalBar2 = new System.Windows.Forms.PictureBox();
00236             this.pictVehicleBox = new System.Windows.Forms.PictureBox();
00237             this.pictHorzontalBar3 = new System.Windows.Forms.PictureBox();
00238             this.pictPolicyBox = new System.Windows.Forms.PictureBox();
00239             this.pictHorzontalBar1 = new System.Windows.Forms.PictureBox();
00240             this.lblInstructions = new System.Windows.Forms.Label();
00241             this.lblTitle = new System.Windows.Forms.Label();
00242             this.pictCheckmarks = new System.Windows.Forms.PictureBox();
00243             this.inkPictVehicle = new Microsoft.Ink.InkPicture();
00244             this.lstAnnotationLayer = new System.Windows.Forms.ListBox();
00245             this.inkEdPolicyNumber = new Microsoft.Ink.InkEdit();
00246             this.inkEdName = new Microsoft.Ink.InkEdit();
00247             this.inkEdYear = new Microsoft.Ink.InkEdit();
00248             this.inkEdMake = new Microsoft.Ink.InkEdit();
00249             this.inkEdModel = new Microsoft.Ink.InkEdit();
00250             this.SuspendLayout();
00251             //
00252             // lblVehicleDamage
00253             //
00254             this.lblVehicleDamage.AutoSize = true;
00255             this.lblVehicleDamage.BackColor = System.Drawing.Color.White;
00256             this.lblVehicleDamage.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00257             this.lblVehicleDamage.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00258             this.lblVehicleDamage.Location = new System.Drawing.Point(8, 408);
00259             this.lblVehicleDamage.Name = "lblVehicleDamage";
00260             this.lblVehicleDamage.Size = new System.Drawing.Size(256, 20);
00261             this.lblVehicleDamage.TabIndex = 58;
00262             this.lblVehicleDamage.Text = "Description of vehicle damage";
00263             this.lblVehicleDamage.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00264             //
00265             // lblVehicleDescription
00266             //
00267             this.lblVehicleDescription.AutoSize = true;
00268             this.lblVehicleDescription.BackColor = System.Drawing.Color.White;
00269             this.lblVehicleDescription.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00270             this.lblVehicleDescription.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00271             this.lblVehicleDescription.Location = new System.Drawing.Point(8, 240);
00272             this.lblVehicleDescription.Name = "lblVehicleDescription";
00273             this.lblVehicleDescription.Size = new System.Drawing.Size(386, 20);
00274             this.lblVehicleDescription.TabIndex = 56;
00275             this.lblVehicleDescription.Text = "Enter the involved vehicle listed on the policy ";
00276             this.lblVehicleDescription.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00277             //
00278             // lblModel
00279             //
00280             this.lblModel.AutoSize = true;
00281             this.lblModel.BackColor = System.Drawing.Color.Gainsboro;
00282             this.lblModel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00283             this.lblModel.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00284             this.lblModel.Location = new System.Drawing.Point(112, 360);
00285             this.lblModel.Name = "lblModel";
00286             this.lblModel.Size = new System.Drawing.Size(73, 23);
00287             this.lblModel.TabIndex = 52;
00288             this.lblModel.Text = "Model:";
00289             this.lblModel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00290             //
00291             // lblYear
00292             //
00293             this.lblYear.AutoSize = true;
00294             this.lblYear.BackColor = System.Drawing.Color.Gainsboro;
00295             this.lblYear.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00296             this.lblYear.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00297             this.lblYear.Location = new System.Drawing.Point(48, 280);
00298             this.lblYear.Name = "lblYear";
00299             this.lblYear.Size = new System.Drawing.Size(135, 23);
00300             this.lblYear.TabIndex = 51;
00301             this.lblYear.Text = "Year (YYYY):";
00302             this.lblYear.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00303             //
00304             // lblMake
00305             //
00306             this.lblMake.AutoSize = true;
00307             this.lblMake.BackColor = System.Drawing.Color.Gainsboro;
00308             this.lblMake.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00309             this.lblMake.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00310             this.lblMake.Location = new System.Drawing.Point(112, 320);
00311             this.lblMake.Name = "lblMake";
00312             this.lblMake.Size = new System.Drawing.Size(67, 23);
00313             this.lblMake.TabIndex = 50;
00314             this.lblMake.Text = "Make:";
00315             this.lblMake.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00316             //
00317             // lblPolicyNumber
00318             //
00319             this.lblPolicyNumber.AutoSize = true;
00320             this.lblPolicyNumber.BackColor = System.Drawing.Color.Gainsboro;
00321             this.lblPolicyNumber.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00322             this.lblPolicyNumber.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00323             this.lblPolicyNumber.Location = new System.Drawing.Point(32, 136);
00324             this.lblPolicyNumber.Name = "lblPolicyNumber";
00325             this.lblPolicyNumber.Size = new System.Drawing.Size(157, 23);
00326             this.lblPolicyNumber.TabIndex = 47;
00327             this.lblPolicyNumber.Text = "Policy Number:";
00328             this.lblPolicyNumber.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00329             //
00330             // lblInsuredName
00331             //
00332             this.lblInsuredName.AutoSize = true;
00333             this.lblInsuredName.BackColor = System.Drawing.Color.Gainsboro;
00334             this.lblInsuredName.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00335             this.lblInsuredName.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
00336             this.lblInsuredName.Location = new System.Drawing.Point(32, 176);
00337             this.lblInsuredName.Name = "lblInsuredName";
00338             this.lblInsuredName.Size = new System.Drawing.Size(154, 23);
00339             this.lblInsuredName.TabIndex = 46;
00340             this.lblInsuredName.Text = "Insured Name:";
00341             this.lblInsuredName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00342             //
00343             // chHideLayer
00344             //
00345             this.chHideLayer.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00346             this.chHideLayer.Location = new System.Drawing.Point(416, 576);
00347             this.chHideLayer.Name = "chHideLayer";
00348             this.chHideLayer.Size = new System.Drawing.Size(144, 24);
00349             this.chHideLayer.TabIndex = 61;
00350             this.chHideLayer.Text = "Hide Layer";
00351             this.chHideLayer.CheckedChanged += new System.EventHandler(this.chHideLayer_CheckedChanged);
00352             //
00353             // pictHorzontalBar2
00354             //
00355             this.pictHorzontalBar2.BackColor = System.Drawing.SystemColors.AppWorkspace;
00356             this.pictHorzontalBar2.Location = new System.Drawing.Point(8, 224);
00357             this.pictHorzontalBar2.Name = "pictHorzontalBar2";
00358             this.pictHorzontalBar2.Size = new System.Drawing.Size(536, 2);
00359             this.pictHorzontalBar2.TabIndex = 57;
00360             this.pictHorzontalBar2.TabStop = false;
00361             //
00362             // pictVehicleBox
00363             //
00364             this.pictVehicleBox.BackColor = System.Drawing.Color.Gainsboro;
00365             this.pictVehicleBox.Location = new System.Drawing.Point(8, 272);
00366             this.pictVehicleBox.Name = "pictVehicleBox";
00367             this.pictVehicleBox.Size = new System.Drawing.Size(184, 120);
00368             this.pictVehicleBox.TabIndex = 49;
00369             this.pictVehicleBox.TabStop = false;
00370             //
00371             // pictHorzontalBar3
00372             //
00373             this.pictHorzontalBar3.BackColor = System.Drawing.SystemColors.AppWorkspace;
00374             this.pictHorzontalBar3.Location = new System.Drawing.Point(8, 400);
00375             this.pictHorzontalBar3.Name = "pictHorzontalBar3";
00376             this.pictHorzontalBar3.Size = new System.Drawing.Size(536, 2);
00377             this.pictHorzontalBar3.TabIndex = 48;
00378             this.pictHorzontalBar3.TabStop = false;
00379             //
00380             // pictPolicyBox
00381             //
00382             this.pictPolicyBox.BackColor = System.Drawing.Color.Gainsboro;
00383             this.pictPolicyBox.Location = new System.Drawing.Point(8, 128);
00384             this.pictPolicyBox.Name = "pictPolicyBox";
00385             this.pictPolicyBox.Size = new System.Drawing.Size(184, 80);
00386             this.pictPolicyBox.TabIndex = 44;
00387             this.pictPolicyBox.TabStop = false;
00388             //
00389             // pictHorzontalBar1
00390             //
00391             this.pictHorzontalBar1.BackColor = System.Drawing.SystemColors.AppWorkspace;
00392             this.pictHorzontalBar1.Location = new System.Drawing.Point(8, 112);
00393             this.pictHorzontalBar1.Name = "pictHorzontalBar1";
00394             this.pictHorzontalBar1.Size = new System.Drawing.Size(536, 2);
00395             this.pictHorzontalBar1.TabIndex = 43;
00396             this.pictHorzontalBar1.TabStop = false;
00397             //
00398             // lblInstructions
00399             //
00400             this.lblInstructions.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00401             this.lblInstructions.Location = new System.Drawing.Point(96, 48);
00402             this.lblInstructions.Name = "lblInstructions";
00403             this.lblInstructions.Size = new System.Drawing.Size(456, 56);
00404             this.lblInstructions.TabIndex = 42;
00405             this.lblInstructions.Text = "Enter the required information for the policy applicable to the auto claim you ar" +
00406                 "e submitting. Enter the vehicle exactly as it appears on the policy or insurance" +
00407                 " card.";
00408             //
00409             // lblTitle
00410             //
00411             this.lblTitle.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00412             this.lblTitle.Location = new System.Drawing.Point(8, 8);
00413             this.lblTitle.Name = "lblTitle";
00414             this.lblTitle.Size = new System.Drawing.Size(288, 32);
00415             this.lblTitle.TabIndex = 41;
00416             this.lblTitle.Text = "Auto Claim";
00417             //
00418             // pictCheckmarks
00419             //
00420             this.pictCheckmarks.BackColor = System.Drawing.Color.White;
00421             this.pictCheckmarks.BackgroundImage = ((System.Drawing.Bitmap)(resources.GetObject("pictCheckmarks.BackgroundImage")));
00422             this.pictCheckmarks.Location = new System.Drawing.Point(32, 40);
00423             this.pictCheckmarks.Name = "pictCheckmarks";
00424             this.pictCheckmarks.Size = new System.Drawing.Size(40, 72);
00425             this.pictCheckmarks.TabIndex = 66;
00426             this.pictCheckmarks.TabStop = false;
00427             //
00428             // inkPictVehicle
00429             //
00430             this.inkPictVehicle.AutoRedraw = false;
00431             this.inkPictVehicle.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
00432             this.inkPictVehicle.Image = ((System.Drawing.Bitmap)(resources.GetObject("inkPictVehicle.Image")));
00433             this.inkPictVehicle.Location = new System.Drawing.Point(32, 440);
00434             this.inkPictVehicle.MarginX = -1;
00435             this.inkPictVehicle.MarginY = -1;
00436             this.inkPictVehicle.Name = "inkPictVehicle";
00437             this.inkPictVehicle.Size = new System.Drawing.Size(352, 232);
00438             this.inkPictVehicle.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
00439             this.inkPictVehicle.TabIndex = 67;
00440             this.inkPictVehicle.Paint += new System.Windows.Forms.PaintEventHandler(this.inkPictVehicle_Paint);
00441             //
00442             // lstAnnotationLayer
00443             //
00444             this.lstAnnotationLayer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
00445             this.lstAnnotationLayer.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00446             this.lstAnnotationLayer.ItemHeight = 19;
00447             this.lstAnnotationLayer.Items.AddRange(new object[] {
00448                                                                     "Body",
00449                                                                     "Windows",
00450                                                                     "Tires",
00451                                                                     "Headlights"});
00452             this.lstAnnotationLayer.Location = new System.Drawing.Point(416, 432);
00453             this.lstAnnotationLayer.Name = "lstAnnotationLayer";
00454             this.lstAnnotationLayer.Size = new System.Drawing.Size(104, 135);
00455             this.lstAnnotationLayer.TabIndex = 68;
00456             this.lstAnnotationLayer.SelectedIndexChanged += new System.EventHandler(this.lstAnnotationLayer_SelectedIndexChanged);
00457             //
00458             // inkEdPolicyNumber
00459             //
00460             this.inkEdPolicyNumber.Cursor = System.Windows.Forms.Cursors.Default;
00461             this.inkEdPolicyNumber.InkMode = Microsoft.Ink.InkMode.Disabled;
00462             this.inkEdPolicyNumber.Location = new System.Drawing.Point(208, 136);
00463             this.inkEdPolicyNumber.Name = "inkEdPolicyNumber";
00464             this.inkEdPolicyNumber.Size = new System.Drawing.Size(312, 32);
00465             this.inkEdPolicyNumber.TabIndex = 69;
00466             this.inkEdPolicyNumber.Text = "";
00467             //
00468             // inkEdName
00469             //
00470             this.inkEdName.Cursor = System.Windows.Forms.Cursors.Default;
00471             this.inkEdName.InkMode = Microsoft.Ink.InkMode.Disabled;
00472             this.inkEdName.Location = new System.Drawing.Point(208, 176);
00473             this.inkEdName.Name = "inkEdName";
00474             this.inkEdName.Size = new System.Drawing.Size(312, 32);
00475             this.inkEdName.TabIndex = 70;
00476             this.inkEdName.Text = "";
00477             //
00478             // inkEdYear
00479             //
00480             this.inkEdYear.Cursor = System.Windows.Forms.Cursors.Default;
00481             this.inkEdYear.InkMode = Microsoft.Ink.InkMode.Disabled;
00482             this.inkEdYear.Location = new System.Drawing.Point(208, 280);
00483             this.inkEdYear.Name = "inkEdYear";
00484             this.inkEdYear.Size = new System.Drawing.Size(312, 32);
00485             this.inkEdYear.TabIndex = 71;
00486             this.inkEdYear.Text = "";
00487             this.inkEdYear.Enter += new System.EventHandler(this.inkEdYear_Enter);
00488             //
00489             // inkEdMake
00490             //
00491             this.inkEdMake.Cursor = System.Windows.Forms.Cursors.Default;
00492             this.inkEdMake.InkMode = Microsoft.Ink.InkMode.Disabled;
00493             this.inkEdMake.Location = new System.Drawing.Point(208, 320);
00494             this.inkEdMake.Name = "inkEdMake";
00495             this.inkEdMake.Size = new System.Drawing.Size(312, 32);
00496             this.inkEdMake.TabIndex = 72;
00497             this.inkEdMake.Text = "";
00498             this.inkEdMake.Enter += new System.EventHandler(this.inkEdMake_Enter);
00499             //
00500             // inkEdModel
00501             //
00502             this.inkEdModel.Cursor = System.Windows.Forms.Cursors.Default;
00503             this.inkEdModel.InkMode = Microsoft.Ink.InkMode.Disabled;
00504             this.inkEdModel.Location = new System.Drawing.Point(208, 360);
00505             this.inkEdModel.Name = "inkEdModel";
00506             this.inkEdModel.Size = new System.Drawing.Size(312, 32);
00507             this.inkEdModel.TabIndex = 73;
00508             this.inkEdModel.Text = "";
00509             this.inkEdModel.Enter += new System.EventHandler(this.inkEdModel_Enter);
00510             //
00511             // AutoClaims
00512             //
00513             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00514             this.AutoScroll = true;
00515             this.BackColor = System.Drawing.Color.White;
00516             this.ClientSize = new System.Drawing.Size(560, 694);
00517             this.Controls.AddRange(new System.Windows.Forms.Control[] {
00518                                                                           this.inkEdModel,
00519                                                                           this.inkEdMake,
00520                                                                           this.inkEdYear,
00521                                                                           this.inkEdName,
00522                                                                           this.inkEdPolicyNumber,
00523                                                                           this.lstAnnotationLayer,
00524                                                                           this.inkPictVehicle,
00525                                                                           this.lblVehicleDamage,
00526                                                                           this.lblVehicleDescription,
00527                                                                           this.lblModel,
00528                                                                           this.lblYear,
00529                                                                           this.lblMake,
00530                                                                           this.lblPolicyNumber,
00531                                                                           this.lblInsuredName,
00532                                                                           this.chHideLayer,
00533                                                                           this.pictHorzontalBar2,
00534                                                                           this.pictVehicleBox,
00535                                                                           this.pictHorzontalBar3,
00536                                                                           this.pictPolicyBox,
00537                                                                           this.pictHorzontalBar1,
00538                                                                           this.lblInstructions,
00539                                                                           this.lblTitle,
00540                                                                           this.pictCheckmarks});
00541             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
00542             this.MaximizeBox = false;
00543             this.Name = "AutoClaims";
00544             this.Text = "AutoClaims";
00545             this.Load += new System.EventHandler(this.AutoClaims_Load);
00546             this.ResumeLayout(false);
00547
00548         }
00549         #endregion
00550
00551         #region Standard Template Code
00552         /// <summary>
00553         /// The main entry point for the application.
00554         /// </summary>
00555         [STAThread]
00556         static void Main()
00557         {
00558             Application.Run(new AutoClaims());
00559         }
00560         #endregion
00561
00562         /// <summary>
00563         /// This method occurs when the form is loaded.  It
00564         /// configures the insertion mode, the ink used by
00565         /// this application, and the default behavior for the PenInputPanels.
00566         /// </summary>
00567         /// <param name="sender">The control that raised the event.</param>
00568         /// <param name="e">The event arguments.</param>
00569         private void AutoClaims_Load(object sender, System.EventArgs e)
00570         {
00571             // Initialize the empty ink
00572             emptyInk = new Ink();
00573
00574             // Initialize the PenInputPanel objects inside a Try/Catch block
00575             // since the objects are not supported off a Tablet PC.
00576             try
00577             {
00578                 // Initialize the PenInputPanel objects.
00579                 // - pipShared is attached dynamically at run-time
00580                 // - pipPolicyNumber is only attached to the Policy Number field
00581                 // - pipName is only attached to the Insured Name field
00582                 pipShared = new PenInputPanel();
00583                 pipPolicyNumber = new PenInputPanel(inkEdPolicyNumber);
00584                 pipName = new PenInputPanel(inkEdName);
00585
00586                 // Policy numbers are typically prone to recognizer errors, so we'll
00587                 // default to the keyboard panel to be visible for the Policy number.
00588                 pipPolicyNumber.DefaultPanel = PanelType.Keyboard;
00589
00590                 // Enable Text Services Framework on the Name and Policy Number fields.
00591                 // InkEdit already provides a correction UI, but here EnableTsf is allowing
00592                 // the PenInputPanel to use the TSF insertion context rather than SendInput
00593                 // to send the handwriting recognition results into the control. This means
00594                 // that text can be inserted even if the field no longer has focus.
00595                 pipName.EnableTsf(true);
00596                 pipPolicyNumber.EnableTsf(true);
00597
00598                 // Since the fields are laid out vertically on the form, we'll
00599                 // display the PenInputPanels slightly further to the right
00600                 // in order to make it easier for the user to navigate.
00601                 pipShared.HorizontalOffset = 32;
00602                 pipPolicyNumber.HorizontalOffset = 32;
00603                 pipName.HorizontalOffset = 32;
00604             }
00605             catch (System.Runtime.InteropServices.COMException ex)
00606             {
00607                 // If the peninputpanel objects cannot be created, set them
00608                 // to null. Other code that references these objects will need
00609                 // to check
00610                 if (ex.ErrorCode == ObjectsNotInstalledError)
00611                 {
00612                     pipShared = null;
00613                     pipPolicyNumber = null;
00614                     pipName = null;
00615                 }
00616                 else
00617                 {
00618                     throw; // rethrow unexpected exception
00619                 }
00620             }
00621
00622             // Initialize the four different layers of ink on the vehicle diagram:
00623             // vehicle body, windows, tires, and headlights.
00624             inkLayers = new InkLayer[4];
00625             inkLayers[0] = new InkLayer(new Ink(), Color.Red, false);
00626             inkLayers[1] = new InkLayer(new Ink(), Color.Violet, false);
00627             inkLayers[2] = new InkLayer(new Ink(), Color.LightGreen, false);
00628             inkLayers[3] = new InkLayer(new Ink(), Color.Aqua, false);
00629
00630             // By default, select the first ink layer
00631             lstAnnotationLayer.SelectedIndex = 0;
00632             inkPictVehicle.DefaultDrawingAttributes.Color = inkLayers[lstAnnotationLayer.SelectedIndex].ActiveColor;
00633         }
00634
00635         /// <summary>
00636         ///  Event Handler from lstAnnotationLayer->SelectedIndexChanged Event
00637         /// </summary>
00638         /// <param name="sender">The control that raised the event.</param>
00639         /// <param name="e">The event arguments.</param>
00640         private void lstAnnotationLayer_SelectedIndexChanged(object sender, System.EventArgs e)
00641         {
00642             // Provided that the new selected index value is different than
00643             // the previous value...
00644             if (lstAnnotationLayer.SelectedIndex != selectedIndex)
00645             {
00646                 if (!inkPictVehicle.CollectingInk)
00647                 {
00648                     // Set the ink and visibility of the current ink layer
00649                     inkPictVehicle.DefaultDrawingAttributes.Color = inkLayers[lstAnnotationLayer.SelectedIndex].ActiveColor;
00650                     chHideLayer.Checked = inkLayers[lstAnnotationLayer.SelectedIndex].Hidden;
00651
00652                     // Set the active ink object to the selected ink
00653                     // Note that if the current layer is not visible, empty
00654                     // ink is used to prevent flicker.
00655                     inkPictVehicle.InkEnabled = false;
00656                     inkPictVehicle.Ink = chHideLayer.Checked?emptyInk:inkLayers[lstAnnotationLayer.SelectedIndex].ActiveInk;
00657                     inkPictVehicle.InkEnabled = !chHideLayer.Checked;
00658
00659                     selectedIndex = lstAnnotationLayer.SelectedIndex;
00660
00661                     this.Refresh();
00662                 }
00663                 else
00664                 {
00665                     // If ink collection is enabled, the active ink cannot be changed
00666                     // and it is necessary to restore the selection to its previous value.
00667                     lstAnnotationLayer.SelectedIndex = selectedIndex;
00668                     MessageBox.Show("Cannot change active ink while collecting ink.");
00669                 }
00670             }
00671         }
00672
00673         /// <summary>
00674         /// Event Handler from chHideLayer->CheckChanged Event
00675         /// </summary>
00676         /// <param name="sender">The control that raised the event.</param>
00677         /// <param name="e">The event arguments.</param>
00678         private void chHideLayer_CheckedChanged(object sender, System.EventArgs e)
00679         {
00680             // Provided that the new checked hidden value is different than
00681             // the previous value...
00682             if (chHideLayer.Checked != selectedHidden)
00683             {
00684                 if (!inkPictVehicle.CollectingInk)
00685                 {
00686                     // Update the array indicating the visibility of each ink layer
00687                     inkLayers[lstAnnotationLayer.SelectedIndex].Hidden = chHideLayer.Checked;
00688
00689                     // Set the active ink object to the selected ink
00690                     // Note that if the current layer is not visible, empty
00691                     // ink is used to prevent flicker.
00692                     inkPictVehicle.InkEnabled = false;
00693                     inkPictVehicle.Ink = chHideLayer.Checked?emptyInk:inkLayers[lstAnnotationLayer.SelectedIndex].ActiveInk;
00694
00695                     // If the layer is marked hidden, disable ink collections
00696                     inkPictVehicle.InkEnabled = !chHideLayer.Checked;
00697
00698                     // Update the previous checkbox value to reflect the current
00699                     selectedHidden = chHideLayer.Checked;
00700
00701                     this.Refresh();
00702                 }
00703                 else
00704                 {
00705                     // If ink collection is enabled, the active ink cannot be changed
00706                     // and it is necessary to restore the checkbox to its previous value.
00707                     chHideLayer.Checked = selectedHidden;
00708                     MessageBox.Show("Cannot change visibility while collecting ink.");
00709                 }
00710             }
00711         }
00712
00713         /// <summary>
00714         /// Event Handler from inkPictVehicle->Paint Event
00715         ///
00716         /// It is necessary to draw four different types of ink
00717         /// and the ink picture only has one ink associated with it.
00718         /// As a result, the autoredraw feature is turned off
00719         /// and the paint event is handled.
00720         /// </summary>
00721         /// <param name="sender">The control that raised the event.</param>
00722         /// <param name="e">The event arguments.</param>
00723         private void inkPictVehicle_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
00724         {
00725             // Cycle through each ink layer.  If it is visible, paint it.
00726             // Note that it is necessary to customize the paint
00727             // behavior, since we want to hide/show different ink layers.
00728             foreach (InkLayer layer in inkLayers)
00729             {
00730                 if (!layer.Hidden)
00731                 {
00732                     inkPictVehicle.Renderer.Draw(e.Graphics,layer.ActiveInk.Strokes);
00733                 }
00734             }
00735         }
00736
00737         /// <summary>
00738         /// Event Handler for inkEdYear->Enter Event
00739         ///
00740         /// As the edit control receives focus, we attach the shared PenInputPanel to it.
00741         /// The Year, Make, and Model fields demonstrate how to share a single PenInputPanel
00742         /// among multiple controls
00743         /// </summary>
00744         /// <param name="sender">The control that raised the event.</param>
00745         /// <param name="e">The event arguments.</param>
00746         private void inkEdYear_Enter(object sender, System.EventArgs e)
00747         {
00748             if (pipShared != null)
00749             {
00750                 // Attach the shared PenInputPanel to the Year field
00751                 pipShared.AttachedEditControl = inkEdYear;
00752
00753                 // set the NUMBER factoid to bias recognition for numbers
00754                 pipShared.Factoid = Factoid.Number;
00755
00756                 // Enable Text Services Framework on the Year field.
00757                 // InkEdit already provides a correction UI, but here EnableTsf is allowing
00758                 // the PenInputPanel to use the TSF insertion context rather than SendInput
00759                 // to send the handwriting recognition results into the control. This means
00760                 // that text can be inserted even if the field no longer has focus.
00761                 pipShared.EnableTsf(true);
00762             }
00763         }
00764
00765         /// <summary>
00766         /// Event Handler for inkEdMake->Enter Event
00767         ///
00768         /// As the edit control receives focus, we attach the shared PenInputPanel to it.
00769         /// The Year, Make, and Model fields demonstrate how to share a single PenInputPanel
00770         /// among multiple controls
00771         /// </summary>
00772         /// <param name="sender">The control that raised the event.</param>
00773         /// <param name="e">The event arguments.</param>
00774         private void inkEdMake_Enter(object sender, System.EventArgs e)
00775         {
00776             if (pipShared != null)
00777             {
00778                 // Attach the shared PenInputPanel to the Make field
00779                 pipShared.AttachedEditControl = inkEdMake;
00780
00781                 // reset the factoid to bias recognition for general text
00782                 pipShared.Factoid = "DEFAULT";
00783
00784                 // Enable Text Services Framework on the Make field.
00785                 // InkEdit already provides a correction UI, but here EnableTsf is allowing
00786                 // the PenInputPanel to use the TSF insertion context rather than SendInput
00787                 // to send the handwriting recognition results into the control. This means
00788                 // that text can be inserted even if the field no longer has focus.
00789                 pipShared.EnableTsf(true);
00790             }
00791         }
00792
00793         /// <summary>
00794         /// Event Handler for inkEdModel->Enter Event
00795         ///
00796         /// As the edit control receives focus, we attach the shared PenInputPanel to it.
00797         /// The Year, Make, and Model fields demonstrate how to share a single PenInputPanel
00798         /// among multiple controls
00799         /// </summary>
00800         /// <param name="sender">The control that raised the event.</param>
00801         /// <param name="e">The event arguments.</param>
00802         private void inkEdModel_Enter(object sender, System.EventArgs e)
00803         {
00804             if (pipShared != null)
00805             {
00806                 // Attach the shared PenInputPanel to the Model field
00807                 pipShared.AttachedEditControl = inkEdModel;
00808
00809                 // reset the factoid to bias recognition for general text
00810                 pipShared.Factoid = "DEFAULT";
00811
00812                 // Enable Text Services Framework on the Model field.
00813                 // InkEdit already provides a correction UI, but here EnableTsf is allowing
00814                 // the PenInputPanel to use the TSF insertion context rather than SendInput
00815                 // to send the handwriting recognition results into the control. This means
00816                 // that text can be inserted even if the field no longer has focus.
00817                 pipShared.EnableTsf(true);
00818             }
00819         }
00820     }
00821 }
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/BrochureMachine/PTLauncher.cpp Source File

  • Web
  • Browser
  • BrochureMachine

PTLauncher.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // PTLauncher.cpp : Implementation of CPTLauncher
00006 #include "stdafx.h"
00007 #include "BrochureMachine.h"
00008 #include "PTLauncher.h"
00009 #include "ExDisp.h"
00010 #include "shlguid.h"
00011 #include "mshtml.h"
00012 #include "mshtmcid.h"
00013 #include "mshtmhst.h"
00014 #include "mshtmdid.h"
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CPTLauncher
00017
00018 STDMETHODIMP CPTLauncher::LaunchPT()
00019 {
00020   CComPtr<IOleContainer> spContainer;
00021   CComPtr<IServiceProvider> spSP;
00022   CComPtr<IWebBrowser2> spWB;
00023   CComPtr<IDispatch> spDisp;
00024   CComPtr<IHTMLDocument2> spDoc;
00025   CComPtr<IOleCommandTarget> spCT;
00026   CComVariant vPTPath = "res://BrochureMachine.dll/PT.htm";
00027
00028   m_spClientSite->GetContainer(&spContainer);
00029   spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP);
00030   spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB);
00031   spWB->get_Document(&spDisp);
00032   spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc);
00033   spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT);
00034   spCT->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, NULL, &vPTPath, NULL);
00035
00036   return S_OK;
00037 }
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/ExtObj.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

ExtObj.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ExtObj.cpp
00007 //
00008 //  Description:
00009 //      Implementation of the CExtObject class, which implements the
00010 //      extension interfaces required by a Microsoft Windows NT Cluster
00011 //      Administrator Extension DLL.
00012 //
00013 //  Author:
00014 //      <name> (<e-mail name>) Mmmm DD, 2003
00015 //
00016 //  Revision History:
00017 //
00018 //  Notes:
00019 //
00020 /////////////////////////////////////////////////////////////////////////////
00021
00022 #include "stdafx.h"
00023 #include "File Share SampleEx.h"
00024 #include "ExtObj.h"
00025 #include "ExtObjData.h"
00026 #include "ResProp.h"
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CExtObject
00030 /////////////////////////////////////////////////////////////////////////////
00031
00032 /////////////////////////////////////////////////////////////////////////////
00033 //++
00034 //
00035 //  CExtObject::CExtObject
00036 //
00037 //  Description:
00038 //      Default constructor.
00039 //
00040 //  Arguments:
00041 //      None.
00042 //
00043 //  Return Value:
00044 //      None.
00045 //
00046 //--
00047 /////////////////////////////////////////////////////////////////////////////
00048 CExtObject::CExtObject( void )
00049 {
00050     m_piData = NULL;
00051     m_piWizardCallback = NULL;
00052     m_bWizard = FALSE;
00053
00054     m_lcid = NULL;
00055     m_hfont = NULL;
00056     m_hicon = NULL;
00057     m_hCluster = NULL;
00058     m_cobj = 0;
00059     m_podObjData = NULL;
00060
00061 } //*** CExtObject::CExtObject
00062
00063 /////////////////////////////////////////////////////////////////////////////
00064 //++
00065 //
00066 //  CExtObject::~CExtObject
00067 //
00068 //  Description:
00069 //      Destructor.
00070 //
00071 //  Arguments:
00072 //      None.
00073 //
00074 //  Return Value:
00075 //      None.
00076 //
00077 //--
00078 /////////////////////////////////////////////////////////////////////////////
00079 CExtObject::~CExtObject( void )
00080 {
00081     POSITION    pos = NULL;
00082
00083     //
00084     // Release the data interface.
00085     //
00086
00087     if ( m_piData != NULL )
00088     {
00089         m_piData->Release();
00090         m_piData = NULL;
00091     } // if:  we have a data interface pointer
00092
00093     //
00094     // Release the wizard callback interface.
00095     //
00096
00097     if ( m_piWizardCallback != NULL )
00098     {
00099         m_piWizardCallback->Release();
00100         m_piWizardCallback = NULL;
00101     } // if:  we have a wizard callback interface pointer
00102
00103     //
00104     // Delete the pages.
00105     //
00106
00107     pos = m_lpg.GetHeadPosition();
00108     while ( pos != NULL )
00109     {
00110         delete m_lpg.GetNext(pos);
00111     } // while:  more pages in the list
00112
00113     //
00114     // Delete the object.
00115     //
00116
00117     delete m_podObjData;
00118     m_podObjData = NULL;
00119
00120 } //*** CExtObject::~CExtObject
00121
00122 /////////////////////////////////////////////////////////////////////////////
00123 // ISupportErrorInfo Implementation
00124 /////////////////////////////////////////////////////////////////////////////
00125
00126 /////////////////////////////////////////////////////////////////////////////
00127 //++
00128 //
00129 //  CExtObject::InterfaceSupportsErrorInfo (ISupportErrorInfo)
00130 //
00131 //  Routine Description:
00132 //      Indicates whether an interface suportes the IErrorInfo interface.
00133 //      This interface is provided by ATL.
00134 //
00135 //  Arguments:
00136 //      riid        Interface ID.
00137 //
00138 //  Return Value:
00139 //      S_OK        Interface supports IErrorInfo.
00140 //      S_FALSE     Interface does not support IErrorInfo.
00141 //
00142 //--
00143 /////////////////////////////////////////////////////////////////////////////
00144 STDMETHODIMP
00145 CExtObject::InterfaceSupportsErrorInfo(
00146     REFIID riid
00147     )
00148 {
00149     HRESULT hr = S_FALSE;
00150     int iiid = 0;
00151     static const IID * rgiid[] =
00152     {
00153           &IID_IWEExtendPropertySheet
00154         , &IID_IWEExtendWizard
00155         , &IID_IWEExtendContextMenu
00156     };
00157
00158     for ( iiid = 0 ; iiid < sizeof( rgiid ) / sizeof( rgiid[ 0 ] ) ; iiid++ )
00159     {
00160         if ( ::InlineIsEqualGUID( *rgiid[ iiid ], riid ) )
00161         {
00162             hr = S_OK;
00163             goto Cleanup;
00164         } // if: found a matching IID
00165     } // for: each interface we support
00166
00167 Cleanup:
00168
00169     return hr;
00170
00171 } //*** CExtObject::InterfaceSupportsErrorInfo
00172
00173 /////////////////////////////////////////////////////////////////////////////
00174 // IWEExtendPropertySheet Implementation
00175 /////////////////////////////////////////////////////////////////////////////
00176
00177 /////////////////////////////////////////////////////////////////////////////
00178 //++
00179 //
00180 //  CExtObject::CreatePropertySheetPages (IWEExtendPropertySheet)
00181 //
00182 //  Description:
00183 //      Create property sheet pages and add them to the sheet.
00184 //
00185 //  Arguments:
00186 //      piDataIn
00187 //          IUnkown pointer from which to obtain interfaces for obtaining data
00188 //          describing the object for which the sheet is being displayed.
00189 //
00190 //      piCallbackIn
00191 //          Pointer to an IWCPropertySheetCallback interface for adding pages
00192 //          to the sheet.
00193 //
00194 //  Return Value:
00195 //      S_OK         Pages added successfully.
00196 //      E_INVALIDARG    Invalid arguments to the function.
00197 //      E_OUTOFMEMORY   Error allocating memory.
00198 //      E_FAIL          Error creating a page.
00199 //      E_NOTIMPL       Not implemented for this type of data.
00200 //      hr             Any error codes from HrGetUIInfo() or HrSaveData().
00201 //
00202 //--
00203 /////////////////////////////////////////////////////////////////////////////
00204 STDMETHODIMP
00205 CExtObject::CreatePropertySheetPages(
00206       IUnknown *                   piDataIn
00207     , IWCPropertySheetCallback *   piCallbackIn
00208     )
00209 {
00210     HRESULT             hr = S_OK;
00211     CRuntimeClass **    pprtc = NULL;
00212     int                 irtc = 0;
00213     CBasePropertyPage * ppage = NULL;
00214     POSITION            pos = NULL;
00215
00216     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00217
00218     //
00219     // Validate the parameters.
00220     //
00221
00222     if ( (piDataIn == NULL) || (piCallbackIn == NULL) )
00223     {
00224         hr = E_INVALIDARG;
00225         goto Cleanup;
00226     } // if:  all interfaces not specified
00227
00228     //
00229     //  Since the MFC collection classes can throw exceptions a minimal try
00230     //  catch block is needed.
00231     //
00232
00233     try
00234     {
00235         //
00236         // Get info about displaying UI.
00237         //
00238
00239         hr = HrGetUIInfo( piDataIn );
00240         if ( FAILED( hr ) )
00241         {
00242             goto Cleanup;
00243         } // if:  error getting UI info
00244
00245         //
00246         // Save the data.
00247         //
00248
00249         hr = HrSaveData( piDataIn );
00250         if ( FAILED( hr ) )
00251         {
00252             goto Cleanup;
00253         } // if:  error saving data from host
00254
00255         //
00256         // Delete any previous pages.
00257         //
00258
00259         pos = m_lpg.GetHeadPosition();
00260         while ( pos != NULL )
00261         {
00262             delete m_lpg.GetNext( pos );
00263         } // while:  more pages in the list
00264
00265         m_lpg.RemoveAll();
00266
00267         //
00268         // Create property pages.
00269         //
00270
00271         ASSERT( m_podObjData != NULL );
00272         hr = m_podObjData->GetPropertySheetPages( &pprtc );
00273         if ( FAILED( hr ) )
00274         {
00275             goto Cleanup;
00276         } // if: failed to get the property sheet pages.
00277
00278         //
00279         // Create each page.
00280         //
00281
00282         for ( irtc = 0 ; pprtc[ irtc ] != NULL ; irtc++ )
00283         {
00284             //
00285             // Create the page.
00286             //
00287
00288             ppage = static_cast< CBasePropertyPage * >( pprtc[ irtc ]->CreateObject() );
00289             ASSERT( ppage->IsKindOf( pprtc[ irtc ] ) );
00290
00291             //
00292             // Add it to the list.
00293             //
00294
00295             m_lpg.AddTail( ppage );
00296
00297             //
00298             // Initialize the property page.
00299             //
00300
00301             hr = ppage->HrInit( this );
00302             if ( FAILED( hr ) )
00303             {
00304                 goto Cleanup;
00305             } // if:  error initializing the page
00306
00307             //
00308             // Create the page.
00309             //
00310
00311             hr = ppage->HrCreatePage();
00312             if ( FAILED( hr ) )
00313             {
00314                 goto Cleanup;
00315             } // if:  error creating the page
00316
00317             //
00318             // Add it to the property sheet.
00319             //
00320
00321             hr = piCallbackIn->AddPropertySheetPage( reinterpret_cast< LONG * >( ppage->Hpage() ) );
00322             if ( FAILED( hr ) )
00323             {
00324                 goto Cleanup;
00325             } // if:  error adding the page to the sheet
00326         } // for:  each page in the list
00327     } // try:
00328     catch ( CMemoryException * pme )
00329     {
00330         //
00331         //  An MFC memory exception occurred.
00332         //
00333
00334         TRACE( _T("CExtObject::CreatePropetySheetPages() - Failed to add property page\n") );
00335
00336         pme->Delete();
00337         hr = E_OUTOFMEMORY;
00338     } // catch:  MFC memory exception.
00339     catch( ... )
00340     {
00341         //
00342         //  An unknown exception occurred.
00343         //
00344
00345         hr = E_UNEXPECTED;
00346     } // catch: anything.
00347
00348 Cleanup:
00349
00350     //
00351     //  Contractually obligated to release these interfaces. Cluadmin did
00352     //  an AddRef on them before we were called.
00353     //
00354
00355     piDataIn->Release();
00356     piCallbackIn->Release();
00357
00358     return hr;
00359
00360 } //*** CExtObject::CreatePropertySheetPages
00361
00362 /////////////////////////////////////////////////////////////////////////////
00363 // IWEExtendWizard Implementation
00364 /////////////////////////////////////////////////////////////////////////////
00365
00366 /////////////////////////////////////////////////////////////////////////////
00367 //++
00368 //
00369 //  CExtObject::CreateWizardPages (IWEExtendWizard)
00370 //
00371 //  Description:
00372 //      Create property sheet pages and add them to the wizard.
00373 //
00374 //  Arguments:
00375 //      piDataIn
00376 //          IUnkown pointer from which to obtain interfaces for obtaining data
00377 //          describing the object for which the wizard is being displayed.
00378 //
00379 //      piCallbackIn
00380 //          Pointer to an IWCPropertySheetCallback interface for adding pages
00381 //          to the sheet.
00382 //
00383 //  Return Value:
00384 //      S_OK         Pages added successfully.
00385 //      E_INVALIDARG    Invalid arguments to the function.
00386 //      E_OUTOFMEMORY   Error allocating memory.
00387 //      E_FAIL          Error creating a page.
00388 //      E_NOTIMPL       Not implemented for this type of data.
00389 //      hr             Any error codes from HrGetUIInfo() or HrSaveData().
00390 //
00391 //--
00392 /////////////////////////////////////////////////////////////////////////////
00393 STDMETHODIMP
00394 CExtObject::CreateWizardPages(
00395       IUnknown *           piDataIn
00396     , IWCWizardCallback *  piCallbackIn
00397     )
00398 {
00399     HRESULT             hr = S_OK;
00400     CRuntimeClass **    pprtc = NULL;
00401     int                 irtc = 0;
00402     CBasePropertyPage * ppage = NULL;
00403     POSITION            pos = NULL;
00404
00405     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00406
00407     //
00408     // Validate the parameters.
00409     //
00410
00411     if ( (piDataIn == NULL) || (piCallbackIn == NULL) )
00412     {
00413         hr = E_INVALIDARG;
00414         goto Cleanup;
00415     } // if:  all interfaces not specified
00416
00417     //
00418     //  Since the MFC collection classes can throw exceptions a minimal try
00419     //  catch block is needed.
00420     //
00421
00422     try
00423     {
00424         //
00425         // Get info about displaying UI.
00426         //
00427
00428         hr = HrGetUIInfo( piDataIn );
00429         if ( FAILED( hr ) )
00430         {
00431             goto Cleanup;
00432         } // if:  error getting UI info
00433
00434         //
00435         // Save the data.
00436         //
00437
00438         hr = HrSaveData( piDataIn );
00439         if ( FAILED( hr ) )
00440         {
00441             goto Cleanup;
00442         } // if:  error saving data from host
00443
00444         //
00445         // Delete any previous pages.
00446         //
00447
00448         pos = m_lpg.GetHeadPosition();
00449         while ( pos != NULL )
00450         {
00451             delete m_lpg.GetNext( pos );
00452         } // while:  more pages in the list
00453
00454         m_lpg.RemoveAll();
00455
00456         //
00457         // Update our callback pointer.
00458         //
00459
00460         piCallbackIn->AddRef();
00461         m_piWizardCallback = piCallbackIn;
00462
00463         m_bWizard = TRUE;
00464
00465         //
00466         // Create property pages.
00467         //
00468
00469         ASSERT( m_podObjData != NULL );
00470         hr = m_podObjData->GetWizardPages( &pprtc );
00471         if ( FAILED( hr ) )
00472         {
00473             goto Cleanup;
00474         } // if: failed to get the wizard pages.
00475
00476         //
00477         // Create each page.
00478         //
00479
00480         for ( irtc = 0 ; pprtc[ irtc ] != NULL ; irtc++ )
00481         {
00482             //
00483             // Create the page.
00484             //
00485
00486             ppage = static_cast< CBasePropertyPage * >( pprtc[ irtc ]->CreateObject() );
00487             ASSERT( ppage->IsKindOf( pprtc[ irtc ] ) );
00488
00489             //
00490             // Add it to the list.
00491             //
00492
00493             m_lpg.AddTail( ppage );
00494
00495             //
00496             // Initialize the property page.
00497             //
00498
00499             hr = ppage->HrInit( this );
00500             if ( FAILED( hr ) )
00501             {
00502                 goto Cleanup;
00503             } // if:  error initializing the page
00504
00505             //
00506             // Create the page.
00507             //
00508
00509             hr = ppage->HrCreatePage();
00510             if ( FAILED( hr ) )
00511             {
00512                 goto Cleanup;
00513             } // if:  error creating the page
00514
00515             //
00516             // Add it to the property sheet.
00517             //
00518
00519             hr = piCallbackIn->AddWizardPage( reinterpret_cast< LONG * >( ppage->Hpage() ) );
00520             if ( FAILED( hr ) )
00521             {
00522                 goto Cleanup;
00523             } // if:  error adding the page to the sheet
00524         } // for:  each page in the list
00525     } // try:
00526     catch ( CMemoryException * pme )
00527     {
00528         //
00529         //  An MFC memory exception occurred.
00530         //
00531
00532         TRACE( _T("CExtObject::CreateWizardPages() - Failed to add wizard page\n") );
00533
00534         pme->Delete();
00535         hr = E_OUTOFMEMORY;
00536     } // catch: MFC memory exception.
00537     catch( ... )
00538     {
00539         //
00540         //  An unknown exception occurred.
00541         //
00542
00543         hr = E_UNEXPECTED;
00544     } // catch: anything.
00545
00546 Cleanup:
00547
00548     //
00549     //  If we failed for any reason then we need to cleanup up the wizard
00550     //  callback interface if we saved it off.
00551     //
00552
00553     if ( FAILED( hr ) )
00554     {
00555         if ( m_piWizardCallback == piCallbackIn )
00556         {
00557             m_piWizardCallback->Release();
00558             m_piWizardCallback = NULL;
00559         } // if: already saved interface pointer
00560     } // if:  error occurred
00561
00562     //
00563     //  Contractually obligated to release these interfaces. Cluadmin did
00564     //  an AddRef on them before we were called.
00565     //
00566
00567     piDataIn->Release();
00568     piCallbackIn->Release();
00569
00570     return hr;
00571
00572 } //*** CExtObject::CreateWizardPages
00573
00574 /////////////////////////////////////////////////////////////////////////////
00575 // IWEExtendContextMenu Implementation
00576 /////////////////////////////////////////////////////////////////////////////
00577
00578 /////////////////////////////////////////////////////////////////////////////
00579 //++
00580 //
00581 //  CExtObject::AddContextMenuItems (IWEExtendContextMenu)
00582 //
00583 //  Description:
00584 //      Add items to a context menu.  This is called each time the context menu
00585 //      is invoked.
00586 //
00587 //  Arguments:
00588 //      piDataIn
00589 //          IUnkown pointer from which to obtain interfaces for obtaining data
00590 //          describing the object for which the context menu is being
00591 //          displayed.
00592 //
00593 //      piCallbackIn
00594 //          Pointer to an IWCContextMenuCallback interface for adding menu
00595 //          items to the context menu.
00596 //
00597 //  Return Value:
00598 //      S_OK         Pages added successfully.
00599 //      E_INVALIDARG    Invalid arguments to the function.
00600 //      E_FAIL          Error adding context menu item.
00601 //      E_NOTIMPL       Not implemented for this type of data.
00602 //      hr             Any error codes returned by HrSaveData().
00603 //
00604 //--
00605 /////////////////////////////////////////////////////////////////////////////
00606 STDMETHODIMP
00607 CExtObject::AddContextMenuItems(
00608       IUnknown *               piDataIn
00609     , IWCContextMenuCallback * piCallbackIn
00610     )
00611 {
00612     HRESULT     hr = S_OK;
00613
00614     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00615
00616     //
00617     // Validate the parameters.
00618     //
00619
00620     if ( (piDataIn == NULL) || (piCallbackIn == NULL) )
00621     {
00622         hr = E_INVALIDARG;
00623         goto Cleanup;
00624     } // if: not all interfaces not specified
00625
00626     //
00627     //  Since the MFC collection classes can throw exceptions a minimal try
00628     //  catch block is needed.
00629     //
00630
00631     try
00632     {
00633         //
00634         // Get info about displaying UI.
00635         //
00636
00637         hr = HrGetUIInfo( piDataIn );
00638         if ( FAILED( hr ) )
00639         {
00640             goto Cleanup;
00641         } // if:  error getting UI info
00642
00643         //
00644         // Save the data.
00645         //
00646
00647         hr = HrSaveData( piDataIn );
00648         if ( FAILED( hr ) )
00649         {
00650             goto Cleanup;
00651         } // if:  error saving data from host
00652
00653         //
00654         //  Add the context menu.
00655         //
00656
00657         hr = m_podObjData->AddContextMenuItems( piCallbackIn );
00658         if ( FAILED( hr ) )
00659         {
00660             goto Cleanup;
00661         } // if:  error saving data from host
00662     } // try:
00663     catch ( CMemoryException * pme )
00664     {
00665         //
00666         //  An MFC memory exception occurred.
00667         //
00668
00669         TRACE( _T("CExtObject::AddContextMenuItems() - Failed to add menu items\n") );
00670
00671         pme->Delete();
00672         hr = E_OUTOFMEMORY;
00673     } // catch: MFC memory exception.
00674     catch( ... )
00675     {
00676         //
00677         //  An unknown exception occurred.
00678         //
00679
00680         hr = E_UNEXPECTED;
00681     } // catch: anything.
00682
00683 Cleanup:
00684
00685     //
00686     //  Contractually obligated to release these interfaces. Cluadmin did
00687     //  an AddRef on them before we were called.
00688     //
00689
00690     piDataIn->Release();
00691     piCallbackIn->Release();
00692
00693     return hr;
00694
00695 } //*** CExtObject::AddContextMenuItems
00696
00697 /////////////////////////////////////////////////////////////////////////////
00698 // IWEInvokeCommand Implementation
00699 /////////////////////////////////////////////////////////////////////////////
00700
00701 /////////////////////////////////////////////////////////////////////////////
00702 //++
00703 //
00704 //  CExtObject::InvokeCommand (IWEInvokeCommand)
00705 //
00706 //  Description:
00707 //      Invoke a command offered by a context menu.
00708 //
00709 //  Arguments:
00710 //      nCommandIDIn
00711 //          ID of the menu item to execute.  This is the same ID passed to the
00712 //          IWCContextMenuCallback::AddExtensionMenuItem() method.
00713 //
00714 //      piDataIn
00715 //          IUnkown pointer from which to obtain interfaces for obtaining data
00716 //          describing the object for which the command is to be invoked.
00717 //
00718 //  Return Value:
00719 //      S_OK         Command invoked successfully.
00720 //      E_INVALIDARG    Invalid arguments to the function.
00721 //      E_NOTIMPL       Not implemented for this type of data.
00722 //      hr             Any error codes from HrSaveData().
00723 //
00724 //--
00725 /////////////////////////////////////////////////////////////////////////////
00726 HRESULT
00727 CExtObject::InvokeCommand(
00728       ULONG        nCommandIDIn
00729     , IUnknown *   piDataIn
00730     )
00731 {
00732     HRESULT hr = S_OK;
00733
00734     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
00735
00736     //
00737     // Check parameters.
00738     //
00739     if ( piDataIn == NULL )
00740     {
00741         hr = E_INVALIDARG;
00742         goto Cleanup;
00743     } // if:  interface not specified
00744
00745     //
00746     //  Since the MFC collection classes can throw exceptions a minimal try
00747     //  catch block is needed.
00748     //
00749
00750     try
00751     {
00752         //
00753         // Get info about displaying UI.
00754         //
00755
00756         hr = HrGetUIInfo( piDataIn );
00757         if ( FAILED( hr ) )
00758         {
00759             goto Cleanup;
00760         } // if:  error getting UI info
00761
00762         //
00763         // Save the data.
00764         //
00765
00766         hr = HrSaveData( piDataIn );
00767         if ( FAILED( hr ) )
00768         {
00769             goto Cleanup;
00770         } // if:
00771
00772         ASSERT( m_podObjData != NULL );
00773         hr = m_podObjData->InvokeCommand( nCommandIDIn );
00774         if ( FAILED( hr ) )
00775         {
00776             goto Cleanup;
00777         } // if:
00778     } // try:
00779     catch ( CMemoryException * pme )
00780     {
00781         //
00782         //  An MFC memory exception occurred.
00783         //
00784
00785         TRACE( _T("CExtObject::InvokeCommand() - Invoking the context menu command failed\n") );
00786
00787         pme->Delete();
00788         hr = E_OUTOFMEMORY;
00789     } // catch: MFC memory exception.
00790     catch( ... )
00791     {
00792         //
00793         //  An unknown exception occurred.
00794         //
00795
00796         hr = E_UNEXPECTED;
00797     } // catch: anything.
00798
00799 Cleanup:
00800
00801     //
00802     //  Contractually obligated to release these interfaces. Cluadmin did
00803     //  an AddRef on them before we were called.
00804     //
00805
00806     piDataIn->Release();
00807
00808     return hr;
00809
00810 } //*** CExtObject::InvokeCommand
00811
00812 /////////////////////////////////////////////////////////////////////////////
00813 //++
00814 //
00815 //  CExtObject::HrGetUIInfo
00816 //
00817 //  Description:
00818 //      Get info about displaying UI.
00819 //
00820 //  Arguments:
00821 //      piDataIn
00822 //          IUnkown pointer from which to obtain interfaces for obtaining data
00823 //          describing the object.
00824 //
00825 //  Return Value:
00826 //      S_OK
00827 //          Data saved successfully.
00828 //
00829 //      E_NOTIMPL
00830 //          Not implemented for this type of data.
00831 //
00832 //      hr
00833 //          Any error codes from IUnknown::QueryInterface(),
00834 //          HrGetObjectName(), or HrGetResourceName().
00835 //
00836 //--
00837 /////////////////////////////////////////////////////////////////////////////
00838 HRESULT
00839 CExtObject::HrGetUIInfo(
00840     IUnknown * piDataIn
00841     )
00842 {
00843     ASSERT( piDataIn != NULL );
00844
00845     HRESULT             hr = S_OK;
00846     IGetClusterUIInfo * pi = NULL;
00847
00848     //
00849     // Save info about all types of objects.
00850     //
00851
00852     hr = piDataIn->QueryInterface( IID_IGetClusterUIInfo, reinterpret_cast< LPVOID * >( &pi ) );
00853     if ( FAILED( hr ) )
00854     {
00855         goto Cleanup;
00856     } // if:  error querying for interface
00857
00858     m_lcid = pi->GetLocale();
00859     m_hfont = pi->GetFont();
00860     m_hicon = pi->GetIcon();
00861
00862 Cleanup:
00863
00864     if ( pi != NULL )
00865     {
00866         pi->Release();
00867     } // if:
00868
00869     return hr;
00870
00871 } //*** CExtObject::HrGetUIInfo
00872
00873 /////////////////////////////////////////////////////////////////////////////
00874 //++
00875 //
00876 //  CExtObject::HrSaveData
00877 //
00878 //  Routine Description:
00879 //      Save data from the object so that it can be used for the life
00880 //      of the object.
00881 //
00882 //  Arguments:
00883 //      piDataIn
00884 //          IUnkown pointer from which to obtain interfaces for obtaining data
00885 //          describing the object.
00886 //
00887 //  Return Value:
00888 //      S_OK
00889 //          Data saved successfully.
00890 //
00891 //      E_NOTIMPL
00892 //          Not implemented for this type of data.
00893 //
00894 //      hr
00895 //          Any error codes from IUnknown::QueryInterface(),
00896 //          HrGetObjectName(), or HrGetResourceName().
00897 //
00898 //--
00899 /////////////////////////////////////////////////////////////////////////////
00900 HRESULT
00901 CExtObject::HrSaveData(
00902     IUnknown * piDataIn
00903     )
00904 {
00905     ASSERT( piDataIn != NULL );
00906
00907     HRESULT                 hr = S_OK;
00908     IGetClusterDataInfo *   pi = NULL;
00909
00910     //
00911     //  Save the new piData interface.
00912     //
00913
00914     if ( piDataIn != m_piData )
00915     {
00916         if ( m_piData != NULL )
00917         {
00918             m_piData->Release();
00919         } // if:  interface queried for previously
00920
00921         piDataIn->AddRef();
00922         m_piData = piDataIn;
00923     } // if:  different data interface pointer
00924
00925     //
00926     // Save info about all types of objects.
00927     //
00928
00929     hr = piDataIn->QueryInterface( IID_IGetClusterDataInfo, reinterpret_cast< LPVOID * >( &pi ) );
00930     if ( FAILED( hr ) )
00931     {
00932         goto Cleanup;
00933     } // if:  error querying for interface
00934
00935     m_hCluster = pi->GetClusterHandle();
00936
00937     m_cobj = pi->GetObjectCount();
00938     if ( m_cobj != 1 )  // We only have support for one selected object.
00939     {
00940         hr = E_NOTIMPL;
00941         goto Cleanup;
00942     } // if:  too many objects for us to handle
00943
00944     //
00945     // Save info about this object.
00946     //
00947
00948     hr = HrGetObjectInfo();
00949     if ( FAILED( hr ) )
00950     {
00951         goto Cleanup;
00952     } // if:
00953
00954 Cleanup:
00955
00956     if ( pi != NULL )
00957     {
00958         pi->Release();
00959     } // if:
00960
00961     return hr;
00962
00963 } //*** CExtObject::HrSaveData
00964
00965 /////////////////////////////////////////////////////////////////////////////
00966 //++
00967 //
00968 //  CExtObject::HrGetObjectInfo
00969 //
00970 //  Description:
00971 //      Get information about the object.
00972 //
00973 //  Arguments:
00974 //      None.
00975 //
00976 //  Return Value:
00977 //      S_OK
00978 //          Data saved successfully.
00979 //
00980 //      E_OUTOFMEMORY
00981 //         Error allocating memory.
00982 //
00983 //      E_NOTIMPL
00984 //          Not implemented for this type of data.
00985 //
00986 //      hr
00987 //          Any error codes from IUnknown::QueryInterface(),
00988 //          HrGetObjectName(), or HrGetResourceTypeName().
00989 //
00990 //--
00991 /////////////////////////////////////////////////////////////////////////////
00992 HRESULT
00993 CExtObject::HrGetObjectInfo( void )
00994 {
00995     HRESULT hr = S_OK;
00996
00997     //
00998     // Delete the old object and create a new one.
00999     //
01000
01001     delete m_podObjData;
01002     m_podObjData = NULL;
01003
01004     hr = CObjData::S_HrCreateObject( m_piData, &m_podObjData );
01005
01006     return hr;
01007
01008 } //*** CExtObject::HrGetObjectInfo
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CComSyncTest Member List

This is the complete list of members for CComSyncTest, including all inherited members.
CComSyncTest() | CComSyncTest | [inline]
Exercise(void) | CComSyncTest |
Generated on Wed Nov 13 2024 16:55:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/src/IsapiString.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • src

IsapiString.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiString.cpp
00006
00007 Abstract:
00008
00009     A simple string class build on
00010     the ISAPI_BUFFER class
00011
00012 Author:
00013
00014     ISAPI developer (Microsoft employee), October 2002
00015
00016 --*/
00017
00018 #include <IsapiTools.h>
00019 #include <stdio.h>
00020
00021 //
00022 // Local definitions
00023 //
00024
00025 #define SIZE_ENCODED_CHUNK      4
00026 #define SIZE_UNENCODED_CHUNK    3
00027
00028 #define UPCASE_ANSI_CHAR(c) ((((unsigned char)c & 0xdf) < 'A' || \
00029                               ((unsigned char)c & 0xdf) > 'Z') ? \
00030                               c : \
00031                               (c & 0xdf))
00032
00033 //
00034 // Local functions
00035 //
00036
00037 VOID
00038 Base64EncodeChunk(
00039     BYTE *  pData,
00040     DWORD   cbData,
00041     CHAR    szOutput[5]
00042     );
00043
00044 BOOL
00045 IsEscapeSequence(
00046     CHAR *  str
00047     );
00048
00049 BOOL
00050 ShouldEscape(
00051     BYTE    c
00052     );
00053
00054 //
00055 // Member function implementations
00056 //
00057
00058 ISAPI_STRING::ISAPI_STRING(
00059     DWORD   dwMaxAlloc
00060     )
00061 /*++
00062
00063 Purpose:
00064
00065     Constructor for ISAPI_STRING object
00066
00067 Arguments:
00068
00069     dwMaxAlloc - The max allocation for the storage of this object
00070
00071 Returns:
00072
00073     None
00074
00075 --*/
00076 {
00077     _Buffer.SetMaxAlloc( dwMaxAlloc );
00078 }
00079
00080 ISAPI_STRING::~ISAPI_STRING()
00081 /*++
00082
00083 Purpose:
00084
00085     Destructor for the ISAPI_STRING object
00086
00087 Arguments:
00088
00089     None
00090
00091 Returns:
00092
00093     None
00094
00095 --*/
00096 {
00097 }
00098
00099 BOOL
00100 ISAPI_STRING::Copy(
00101     CHAR *  szString,
00102     DWORD   cchString
00103     )
00104 /*++
00105
00106 Purpose:
00107
00108     Copies the specified NULL terminated string into the
00109     ISAPI_STRING object.
00110
00111 Arguments:
00112
00113     szString  - The string to copy
00114     cchString - The number of characters to copy
00115
00116 Returns:
00117
00118     TRUE on success, FALSE on failure
00119
00120 --*/
00121 {
00122     //
00123     // If necessary, calculate the length
00124     // of the new data.
00125     //
00126
00127     if ( cchString == 0 )
00128     {
00129         cchString = strlen( szString );
00130     }
00131
00132     return CopyToOffset( szString,
00133                          cchString,
00134                          0 );
00135 }
00136
00137 BOOL
00138 ISAPI_STRING::CopyW(
00139     WCHAR * szStringW,
00140     DWORD   cchStringW
00141     )
00142 /*++
00143
00144 Purpose:
00145
00146     Copies the specified NULL terminated Unicode string into the
00147     ISAPI_STRING object.
00148
00149 Arguments:
00150
00151     szStringW  - The Unicode string to copy
00152     cchStringW - The number of characters to copy
00153
00154 Returns:
00155
00156     TRUE on success, FALSE on failure
00157
00158 --*/
00159 {
00160     //
00161     // If necessary, calculate the length
00162     // of the new data
00163     //
00164
00165     if ( cchStringW == 0 )
00166     {
00167         cchStringW = wcslen( szStringW );
00168     }
00169
00170     return CopyWToOffset( szStringW,
00171                           cchStringW,
00172                           0 );
00173 }
00174
00175 BOOL
00176 ISAPI_STRING::Append(
00177     CHAR *  szString,
00178     DWORD   cchString
00179     )
00180 /*++
00181
00182 Purpose:
00183
00184     Appends the specified NULL terminated string into the
00185     ISAPI_STRING object.
00186
00187 Arguments:
00188
00189     szString  - The string to append
00190     cchString - The number of characters to append
00191
00192 Returns:
00193
00194     TRUE on success, FALSE on failure
00195
00196 --*/
00197 {
00198     //
00199     // If necessary, calculate the length
00200     // of the new data.
00201     //
00202
00203     if ( cchString == 0 )
00204     {
00205         cchString = strlen( szString );
00206     }
00207
00208     return CopyToOffset( szString,
00209                          cchString,
00210                          QueryCCH() );
00211 }
00212
00213 BOOL
00214 ISAPI_STRING::AppendW(
00215     WCHAR * szStringW,
00216     DWORD   cchStringW
00217     )
00218 /*++
00219
00220 Purpose:
00221
00222     Appends the specified NULL terminated Unicode string into the
00223     ISAPI_STRING object.
00224
00225 Arguments:
00226
00227     szStringW  - The Unicode string to append
00228     cchStringW - The number of characters to append
00229
00230 Returns:
00231
00232     TRUE on success, FALSE on failure
00233
00234 --*/
00235 {
00236     //
00237     // If necessary, calculate the length
00238     // of the new data
00239     //
00240
00241     if ( cchStringW == 0 )
00242     {
00243         cchStringW = wcslen( szStringW );
00244     }
00245
00246     return CopyWToOffset( szStringW,
00247                           cchStringW,
00248                           QueryCCH() );
00249 }
00250
00251 BOOL
00252 ISAPI_STRING::Printf(
00253     CHAR *  szString,
00254     ...
00255     )
00256 /*++
00257
00258 Purpose:
00259
00260     Sets the specified printf-style formatted string
00261     into the ISAPI_STRING object using a variable number
00262     of arguments.
00263
00264 Arguments:
00265
00266     szString - The string format
00267     ...      - Zero or more additional arguments
00268
00269 Returns:
00270
00271     TRUE on success, FALSE on failure
00272
00273 --*/
00274 {
00275     BOOL    fResult;
00276
00277     //
00278     // Let ISAPI_BUFFER::Vsprintf do the work
00279     //
00280
00281     va_list args;
00282
00283     va_start( args, szString );
00284
00285     fResult = Vsprintf( szString,
00286                         args );
00287
00288     va_end( args );
00289
00290     return fResult;
00291 }
00292
00293 BOOL
00294 ISAPI_STRING::Vsprintf(
00295     CHAR *  szFormat,
00296     va_list args
00297     )
00298 /*++
00299
00300 Purpose:
00301
00302     Sets the specified printf-style formatted string
00303     into the ISAPI_STRING object using a va_list of args.
00304
00305 Arguments:
00306
00307     szFormat - The string format
00308     ...      - Zero or more additional arguments
00309
00310 Returns:
00311
00312     TRUE on success, FALSE on failure
00313
00314 --*/
00315 {
00316     DWORD   cchWritten;
00317     DWORD   cbBuffer;
00318     BOOL    fResult;
00319
00320     //
00321     // Build the formatted string
00322     //
00323
00324     do
00325     {
00326         cbBuffer = QueryBufferSize();
00327
00328         cchWritten = (DWORD)_vsnprintf( QueryStr(),
00329                                         cbBuffer,
00330                                         szFormat,
00331                                         args );
00332
00333         if ( cchWritten == (DWORD)-1 )
00334         {
00335             //
00336             // If we just failed, and the buffer
00337             // is already at its maximum size,
00338             // then fail.
00339             //
00340
00341             if ( cbBuffer >= QueryMaxAlloc() )
00342             {
00343                 goto Failed;
00344             }
00345
00346             //
00347             // Grow the buffer and try again
00348             //
00349
00350             cbBuffer *= 2;
00351
00352             //
00353             // Don't exceed the max buffer size
00354             //
00355
00356             if ( cbBuffer > QueryMaxAlloc() )
00357             {
00358                 cbBuffer = QueryMaxAlloc();
00359             }
00360
00361             fResult = ResizeBuffer( cbBuffer );
00362
00363             if ( !fResult )
00364             {
00365                 goto Failed;
00366             }
00367         }
00368
00369     } while ( cchWritten == (DWORD)-1 );
00370
00371     SetLen( cchWritten );
00372
00373     return TRUE;
00374
00375 Failed:
00376
00377     //
00378     // No special cleanup needed
00379     //
00380
00381     return FALSE;
00382 }
00383
00384 VOID
00385 ISAPI_STRING::CalcLen(
00386     VOID
00387     )
00388 /*++
00389
00390 Purpose:
00391
00392     Calculates the size in characters of the ISAPI_STRING data by
00393     doing a strlen.
00394
00395 Arguments:
00396
00397     None
00398
00399 Returns:
00400
00401     None
00402
00403 --*/
00404 {
00405     _Buffer.SetDataSize( strlen( QueryStr() ) + 1 );
00406 }
00407
00408 DWORD
00409 ISAPI_STRING::QueryCB(
00410     VOID
00411     )
00412 /*++
00413
00414 Purpose:
00415
00416     Returns the number of bytes (not including NULL terminator)
00417     in the ISAPI_STRING data
00418
00419 Arguments:
00420
00421     None
00422
00423 Returns:
00424
00425     The number of bytes
00426
00427 --*/
00428 {
00429     return QueryCCH();
00430 }
00431
00432 DWORD
00433 ISAPI_STRING::QueryCCH(
00434     VOID
00435     )
00436 /*++
00437
00438 Purpose:
00439
00440     Returns the number of characters (not including NULL terminator)
00441     in the ISAPI_STRING data
00442
00443 Arguments:
00444
00445     None
00446
00447 Returns:
00448
00449     The number of characters
00450
00451 --*/
00452 {
00453     DWORD   cbBuffer = _Buffer.QueryDataSize();
00454
00455     return cbBuffer == 0 ? 0 : cbBuffer - 1;
00456 }
00457
00458 BOOL
00459 ISAPI_STRING::SetLen(
00460     DWORD   cchNewLength
00461     )
00462 /*++
00463
00464 Purpose:
00465
00466     Sets the length of the data in the ISAPI_STRING object,
00467     truncating the current data if necessary.
00468
00469 Arguments:
00470
00471     cchNewLength - The new data length.
00472
00473 Returns:
00474
00475     TRUE on success, FALSE on failure.
00476
00477 --*/
00478 {
00479     CHAR *  pCursor;
00480
00481     //
00482     // Ensure that we don't set the length to
00483     // something longer than the current buffer
00484     //
00485
00486     if ( cchNewLength > QueryBufferSize() - 1 )
00487     {
00488         SetLastError( ERROR_INVALID_PARAMETER );
00489         return FALSE;
00490     }
00491
00492     pCursor = QueryStr();
00493
00494     pCursor[cchNewLength] = '\0';
00495
00496     _Buffer.SetDataSize( cchNewLength + sizeof(CHAR) );
00497
00498     return TRUE;
00499 }
00500
00501 DWORD
00502 ISAPI_STRING::QueryBufferSize(
00503     VOID
00504     )
00505 /*++
00506
00507 Purpose:
00508
00509     Returns the number of bytes in the ISAPI_STRING data buffer
00510
00511 Arguments:
00512
00513     None
00514
00515 Returns:
00516
00517     The number of bytes
00518
00519 --*/
00520 {
00521     return _Buffer.QueryBufferSize();
00522 }
00523
00524 BOOL
00525 ISAPI_STRING::ResizeBuffer(
00526     DWORD   cbSize
00527     )
00528 /*++
00529
00530 Purpose:
00531
00532     Guarantees that the data storage buffer of the ISAPI_STRING
00533     object is at least the number of specified bytes.
00534
00535 Arguments:
00536
00537     cbSize - The target size
00538
00539 Returns:
00540
00541     TRUE on success, FALSE on failure
00542
00543 --*/
00544 {
00545     return _Buffer.Resize( cbSize );
00546 }
00547
00548 DWORD
00549 ISAPI_STRING::QueryMaxAlloc(
00550     VOID
00551     )
00552 /*++
00553
00554 Purpose:
00555
00556     Returns the max allocation size for the ISAPI_STRING's buffer
00557
00558 Arguments:
00559
00560     None
00561
00562 Returns:
00563
00564     The max allocation size
00565
00566 --*/
00567 {
00568     return _Buffer.QueryMaxAlloc();
00569 }
00570
00571 VOID
00572 ISAPI_STRING::SetMaxAlloc(
00573     DWORD   dwMaxAlloc
00574     )
00575 /*++
00576
00577 Purpose:
00578
00579     Sets the max allocation size for the ISAPI_STRING's buffer
00580
00581 Arguments:
00582
00583     The max allocation size
00584
00585 Returns:
00586
00587     None
00588
00589 --*/
00590 {
00591     _Buffer.SetMaxAlloc( dwMaxAlloc );
00592 }
00593
00594 CHAR *
00595 ISAPI_STRING::FindStr(
00596     CHAR *  szSubString,
00597     BOOL    fCaseInsensitive,
00598     DWORD   dwStartingOffset
00599     )
00600 /*++
00601
00602 Purpose:
00603
00604     Finds the specified sub-string in the ISAPI_STRING's
00605     data.
00606
00607 Arguments:
00608
00609     szSubString      - The sub-string to find
00610     fCaseInsensitive - If TRUE, does a case insensitive search
00611     dwStartingOffset - The starting offset in the ISAPI_STRING to start search
00612
00613 Returns:
00614
00615     Pointer to the instance of the sub-string if found, NULL if not found
00616
00617 --*/
00618 {
00619     CHAR *  pCursor;
00620     CHAR *  pEnd;
00621     CHAR *  szFound;
00622     CHAR *  szString;
00623     CHAR    c1;
00624     CHAR    c2;
00625     DWORD   cchString;
00626     DWORD   cchSubString;
00627     DWORD   cchData;
00628     DWORD   n;
00629
00630     //
00631     // If we are trying to search beyond the length
00632     // of the string, then we aren't going to find it
00633     //
00634
00635     cchData = QueryCCH();
00636
00637     if ( dwStartingOffset > cchData )
00638     {
00639         goto NotFound;
00640     }
00641
00642     szString = QueryStr() + dwStartingOffset;
00643
00644     cchString = cchData - dwStartingOffset;
00645
00646     //
00647     // If szString is smaller than szSubString, then
00648     // we aren't going to find it.
00649     //
00650
00651     cchSubString = strlen( szSubString );
00652
00653     if ( cchSubString > cchString )
00654     {
00655         goto NotFound;
00656     }
00657
00658     //
00659     // Set boundaries for the search
00660     //
00661
00662     pEnd = szString + cchString - cchSubString;
00663
00664     //
00665     // Search now
00666     //
00667
00668     szFound = NULL;
00669
00670     for ( pCursor = szString; pCursor <= pEnd; pCursor++ )
00671     {
00672         c1 = fCaseInsensitive ? UPCASE_ANSI_CHAR( *pCursor ) : *pCursor;
00673         c2 = fCaseInsensitive ? UPCASE_ANSI_CHAR( *szSubString ) : *szSubString;
00674
00675         if ( c1 == c2 )
00676         {
00677             szFound = pCursor;
00678
00679             for ( n = 1; n < cchSubString; n++ )
00680             {
00681                 c1 = fCaseInsensitive ? UPCASE_ANSI_CHAR( *(pCursor+n) ) : *(pCursor+n);
00682                 c2 = fCaseInsensitive ? UPCASE_ANSI_CHAR( *(szSubString+n) ) : *(szSubString+n);
00683
00684                 if ( c1 != c2 )
00685                 {
00686                     szFound = NULL;
00687                     break;
00688                 }
00689             }
00690
00691             if ( szFound )
00692             {
00693                 return szFound;
00694             }
00695         }
00696     }
00697
00698 NotFound:
00699
00700     SetLastError( ERROR_INVALID_INDEX );
00701
00702     return NULL;
00703 }
00704
00705 BOOL
00706 ISAPI_STRING::Base64Encode(
00707     VOID *  pBuffer,
00708     DWORD   cbBuffer
00709     )
00710 /*++
00711
00712 Purpose:
00713
00714     Base64 encodes the specified buffer into the ISAPI_STRING
00715
00716 Arguments:
00717
00718     pBuffer  - The buffer to encode
00719     cbBuffer - The size of the buffer
00720
00721 Returns:
00722
00723     TRUE on success, FALSE on failure
00724
00725 --*/
00726 {
00727     CHAR    szChunk[SIZE_ENCODED_CHUNK+1];
00728     BYTE *  pCursor;
00729     DWORD   cbRemaining;
00730     DWORD   cbThisTime;
00731     BOOL    fResult;
00732
00733     //
00734     // Encode the data in chunks
00735     //
00736
00737     pCursor = (BYTE*)pBuffer;
00738     cbRemaining = cbBuffer;
00739
00740     while ( cbRemaining )
00741     {
00742         cbThisTime = cbRemaining > SIZE_UNENCODED_CHUNK ?
00743                      SIZE_UNENCODED_CHUNK :
00744                      cbRemaining;
00745
00746         Base64EncodeChunk( pCursor,
00747                            cbThisTime,
00748                            szChunk );
00749
00750         fResult = Append( szChunk, SIZE_ENCODED_CHUNK );
00751
00752         if ( !fResult )
00753         {
00754             goto Failed;
00755         }
00756
00757         cbRemaining -= cbThisTime;
00758         pCursor += cbThisTime;
00759     }
00760
00761     return TRUE;
00762
00763 Failed:
00764
00765     //
00766     // No special cleanup required
00767     //
00768
00769     return FALSE;
00770 }
00771
00772 BOOL
00773 ISAPI_STRING::Escape(
00774     BOOL    fAllowDoubleEscaping
00775     )
00776 /*++
00777
00778 Purpose:
00779
00780     Escape encodes the ISAPI_STRING's data per RFC2396
00781
00782 Arguments:
00783
00784     fAllowDoubleEscaping - If FALSE, then this function will not encode
00785                            any '%' characters that are part of an escape
00786                            sequence.  If TRUE, all '%' characters will
00787                            be encoded.
00788
00789 Returns:
00790
00791     TRUE on success, FALSE on failure
00792
00793 --*/
00794 {
00795     ISAPI_STRING    strCooked;
00796     DWORD           dwNumEscapes = 0;
00797     CHAR            szHex[3] = {0};
00798     BYTE *          pRead;
00799     BYTE *          pWrite;
00800
00801     //
00802     // Walk through the string once.  If there
00803     // are no escapes, then we can just return.
00804     //
00805
00806     pRead = (BYTE*)_Buffer.QueryPtr();
00807
00808     while ( *pRead != '\0' )
00809     {
00810         if ( ( fAllowDoubleEscaping ||
00811                !IsEscapeSequence( (CHAR*)pRead ) ) &&
00812              ShouldEscape( *pRead ) )
00813         {
00814             dwNumEscapes++;
00815         }
00816
00817         pRead++;
00818     }
00819
00820     if ( dwNumEscapes == 0 )
00821     {
00822         return TRUE;
00823     }
00824
00825     //
00826     // Make sure that our cooked string buffer is big enough, so
00827     // we can manipulate its pointer directly.
00828     //
00829
00830     if ( strCooked.ResizeBuffer( QueryCB() + dwNumEscapes * 2 + 1 ) == FALSE )
00831     {
00832         goto Failed;
00833     }
00834
00835     pRead = (BYTE*)_Buffer.QueryPtr();
00836     pWrite = (BYTE*)strCooked.QueryStr();
00837
00838     while ( *pRead != '\0' )
00839     {
00840         if ( ( fAllowDoubleEscaping ||
00841                !IsEscapeSequence( (CHAR*)pRead ) ) &&
00842              ShouldEscape( *pRead ) )
00843         {
00844             itoa( *pRead, szHex, 16 );
00845
00846             *pWrite = '%';
00847             *(pWrite+1) = szHex[0];
00848             *(pWrite+2) = szHex[1];
00849
00850             pRead++;
00851             pWrite += 3;
00852
00853             continue;
00854         }
00855
00856         *pWrite = *pRead;
00857
00858         pRead++;
00859         pWrite++;
00860     }
00861
00862     *pWrite = '\0';
00863
00864     if ( Copy( strCooked.QueryStr() ) == FALSE )
00865     {
00866         goto Failed;
00867     }
00868
00869     return TRUE;
00870
00871 Failed:
00872
00873     return FALSE;
00874 }
00875
00876 VOID
00877 ISAPI_STRING::Unescape(
00878     VOID
00879     )
00880 /*++
00881
00882 Purpose:
00883
00884     Decodes escape sequences in the ISAPI_STRING's data
00885
00886 Arguments:
00887
00888     None
00889
00890 Returns:
00891
00892     None
00893
00894 --*/
00895 {
00896     CHAR *  pRead;
00897     CHAR *  pWrite;
00898     CHAR    szHex[3] = {0};
00899     BYTE    c;
00900
00901     pRead = (CHAR*)_Buffer.QueryPtr();
00902     pWrite = pRead;
00903
00904     while ( *pRead )
00905     {
00906         if ( IsEscapeSequence( pRead ) )
00907         {
00908             szHex[0] = *(pRead+1);
00909             szHex[1] = *(pRead+2);
00910
00911             c = (BYTE)strtoul( szHex, NULL, 16 );
00912
00913             *pWrite = c;
00914
00915             pRead += 3;
00916             pWrite++;
00917
00918             continue;
00919         }
00920
00921         *pWrite = *pRead;
00922
00923         pRead++;
00924         pWrite++;
00925     }
00926
00927     *pWrite = '\0';
00928
00929     CalcLen();
00930
00931     return;
00932 }
00933
00934 CHAR *
00935 ISAPI_STRING::QueryStr(
00936     VOID
00937     )
00938 /*++
00939
00940 Purpose:
00941
00942     Returns a pointer to the ISAPI_STRING's data
00943
00944 Arguments:
00945
00946     None
00947
00948 Returns:
00949
00950     The data pointer
00951
00952 --*/
00953 {
00954     return (CHAR*)_Buffer.QueryPtr();
00955 }
00956
00957 VOID
00958 ISAPI_STRING::ZeroBuffer(
00959     VOID
00960     )
00961 /*++
00962
00963 Purpose:
00964
00965     Fills the ISAPI_STRING's buffer with zeros
00966
00967 Arguments:
00968
00969     None
00970
00971 Returns:
00972
00973     None
00974
00975 --*/
00976 {
00977     _Buffer.ZeroBuffer();
00978     _Buffer.SetDataSize( 0 );
00979 }
00980
00981 BOOL
00982 ISAPI_STRING::CopyToOffset(
00983     CHAR *  szString,
00984     DWORD   cchString,
00985     DWORD   dwOffset
00986     )
00987 /*++
00988
00989 Purpose:
00990
00991     Copies a string into the ISAPI_STRING's data, starting at the
00992     specified offset.
00993
00994 Arguments:
00995
00996     szString  - The string to copy
00997     cchString - The number of characters to copy
00998     dwOffset  - The offset at which to copy
00999
01000 Returns:
01001
01002     TRUE on success, FALSE on failure
01003
01004 --*/
01005 {
01006     DWORD   cbData;
01007
01008     //
01009     // Ensure that we have enough storage available
01010     //
01011
01012     cbData = cchString + sizeof(CHAR);
01013
01014     if ( ResizeBuffer( cbData + dwOffset ) == FALSE )
01015     {
01016         return FALSE;
01017     }
01018
01019     //
01020     // Copy the data and ensure proper termination
01021     //
01022
01023     CopyMemory( QueryStr() + dwOffset, szString, cbData );
01024
01025     SetLen( QueryCCH() + cbData - sizeof(CHAR) );
01026
01027     return TRUE;
01028 }
01029
01030 BOOL
01031 ISAPI_STRING::CopyWToOffset(
01032     WCHAR * szStringW,
01033     DWORD   cchStringW,
01034     DWORD   dwOffset
01035     )
01036 /*++
01037
01038 Purpose:
01039
01040     Copies a Unicode string into the ISAPI_STRING's data,
01041     starting at the specified offset.
01042
01043 Arguments:
01044
01045     szStringW  - The Unicode string to copy
01046     cchStringW - The number of characters to copy
01047     dwOffset   - The offset at which to copy
01048
01049 Returns:
01050
01051     TRUE on success, FALSE on failure
01052
01053 --*/
01054 {
01055     CHAR *  pCursor;
01056     DWORD   cbData;
01057     DWORD   cbCopied;
01058     DWORD   cchData;
01059
01060     cchData = QueryCCH();
01061
01062     //
01063     // Ensure that we have enough storage available
01064     //
01065
01066     cbData = cchStringW + sizeof(CHAR);
01067
01068     if ( QueryBufferSize() < cbData + dwOffset &&
01069          ResizeBuffer( cbData + dwOffset ) == FALSE )
01070     {
01071         goto Failed;
01072     }
01073
01074     //
01075     // Set the point into which the copy will occur
01076     //
01077
01078     pCursor = QueryStr() + cchData;
01079
01080     //
01081     // Convert the wide string into ANSI using
01082     // the default system code page.
01083     //
01084
01085     cbCopied = WideCharToMultiByte( CP_ACP,
01086                                     0,
01087                                     szStringW,
01088                                     cchStringW,
01089                                     pCursor,
01090                                     cbData,
01091                                     NULL,
01092                                     NULL );
01093
01094     if ( cbCopied == 0 )
01095     {
01096         goto Failed;
01097     }
01098
01099     SetLen( cchData + cbCopied );
01100
01101     return TRUE;
01102
01103 Failed:
01104
01105     //
01106     // No special cleanup to be done
01107     //
01108
01109     return FALSE;
01110 }
01111
01112 VOID
01113 Base64EncodeChunk(
01114     BYTE *  pData,
01115     DWORD   cbData,
01116     CHAR    szOutput[5]
01117     )
01118 /*++
01119
01120 Purpose:
01121
01122     Base64 encodes up to 3 bytes of data into a 4 byte encoded chunk
01123
01124 Arguments:
01125
01126     pData    - The data to encode
01127     cbData   - The number of bytes to encode
01128     szOutput - On return, contains the encoded chunk
01129
01130 Returns:
01131
01132     TRUE on success, FALSE on failure
01133
01134 --*/
01135 {
01136     DWORD   x;
01137     BYTE    szTable[] = "ABCDEFGH"
01138                         "IJKLMNOP"
01139                         "QRSTUVWX"
01140                         "YZabcdef"
01141                         "ghijklmn"
01142                         "opqrstuv"
01143                         "wxyz0123"
01144                         "456789+/";
01145
01146     //
01147     // *** Warning ***
01148     //
01149     // This function assumes that the output buffer
01150     // is at least 5 bytes.  If this is not true,
01151     // then this function will overrun the output
01152     // buffer.
01153     //
01154
01155     ZeroMemory( szOutput, 5 );
01156
01157     //
01158     // Handle invalid input data
01159     //
01160
01161     if ( cbData > 3 )
01162     {
01163         cbData = 3;
01164     }
01165
01166     if ( !cbData )
01167     {
01168         return;
01169     }
01170
01171     //
01172     // Do the bit shift shuffle...
01173     //
01174
01175     for ( x = 0; x < cbData; x++ )
01176     {
01177         switch ( x )
01178         {
01179         case 0:
01180
01181             szOutput[0] = pData[0] >> 2;
01182             szOutput[1] = ( pData[0] & 0x3 ) << 4;
01183             break;
01184
01185         case 1:
01186
01187             szOutput[1] |= ( pData[1] ) >> 4;
01188             szOutput[2] = ( pData[1] & 0xf ) << 2;
01189             break;
01190
01191         case 2:
01192
01193             szOutput[2] |= ( pData[2] >> 6 );
01194             szOutput[3] = pData[2] & 0x3f;
01195             break;
01196         }
01197     }
01198
01199     //
01200     // Handle padding
01201     //
01202
01203     if ( x < 3 )
01204     {
01205         szOutput[3] = '=';
01206     }
01207
01208     if ( x < 2 )
01209     {
01210         szOutput[2] = '=';
01211     }
01212
01213     //
01214     // Convert bits to mapped printable characters
01215     //
01216
01217     do
01218     {
01219         szOutput[x] = szTable[szOutput[x]];
01220     } while ( x-- );
01221
01222     //
01223     // Done
01224     //
01225
01226     return;
01227 }
01228
01229 BOOL
01230 IsEscapeSequence(
01231     CHAR *  str
01232     )
01233 /*++
01234
01235 Purpose:
01236
01237     Determines whether the specified NULL terminated
01238     sequence of characters is an escape sequence (ie. %00).
01239
01240 Arguments:
01241
01242     str - The NULL terminated string to consider
01243
01244 Returns:
01245
01246     TRUE if yes, FALSE if no
01247
01248 --*/
01249 {
01250     if ( *str == '%' &&
01251          isxdigit( *(str+1) ) &&
01252          isxdigit( *(str+2) ) )
01253     {
01254         return TRUE;
01255     }
01256
01257     return FALSE;
01258 }
01259
01260 BOOL
01261 ShouldEscape(
01262     BYTE    c
01263     )
01264 /*++
01265
01266 Purpose:
01267
01268     Determines whether the specified character should
01269     be escape encoded, per RFC2396
01270
01271 Arguments:
01272
01273     c - The character to consider
01274
01275 Returns:
01276
01277     TRUE if yes, FALSE if no
01278
01279 --*/
01280 {
01281     //
01282     // If the character is listed in RFC2396, section
01283     // 2.4.3 as control, space, delims or unwise, we
01284     // should escape it.  Also, we should escape characters
01285     // with the high bit set.
01286     //
01287
01288     if ( c <= 0x1f ||
01289          c == 0x7f )
01290     {
01291         //
01292         // Control character
01293         //
01294
01295         goto ReturnTrue;
01296     }
01297
01298     if ( c >= 0x80 )
01299     {
01300         //
01301         // High bit set
01302         //
01303
01304         goto ReturnTrue;
01305     }
01306
01307     switch ( c )
01308     {
01309
01310     //
01311     // space
01312     //
01313     case ' ':
01314
01315     //
01316     // delims
01317     //
01318     case '<':
01319     case '>':
01320     case '#':
01321     case '%':
01322     case '\"':
01323
01324     //
01325     // unwise
01326     //
01327     case '{':
01328     case '}':
01329     case '|':
01330     case '\\':
01331     case '^':
01332     case '[':
01333     case ']':
01334     case '`':
01335
01336         goto ReturnTrue;
01337     }
01338
01339     //
01340     // If we get here, then the character should not be
01341     // escaped
01342     //
01343
01344     return FALSE;
01345
01346 ReturnTrue:
01347
01348     return TRUE;
01349 }
01350
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/resource.h Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

resource.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1997 - 1999
00006 //
00007 //  File:       resource.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 //{{NO_DEPENDENCIES}}
00012 // Microsoft Developer Studio generated include file.
00013 // Used by certpsam.rc
00014 //
00015 #define IDS_CERTPOLICY_DESC 1
00016 #define IDS_CERTMANAGEPOLICYMODULE_DESC 2
00017
00018
00019 // Next default values for new objects
00020 //
00021 #ifdef APSTUDIO_INVOKED
00022 #ifndef APSTUDIO_READONLY_SYMBOLS
00023 #define _APS_NEXT_RESOURCE_VALUE        201
00024 #define _APS_NEXT_COMMAND_VALUE         32768
00025 #define _APS_NEXT_CONTROL_VALUE         201
00026 #define _APS_NEXT_SYMED_VALUE           101
00027 #endif
00028 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Explore.VC/VCExploreDlg.h Source File

  • Com
  • Administration
  • Explore.VC

VCExploreDlg.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018
00019 #if !defined(AFX_VCEXPLOREDLG_H__12723F27_B2F5_11D2_86A1_000000000000__INCLUDED_)
00020 #define AFX_VCEXPLOREDLG_H__12723F27_B2F5_11D2_86A1_000000000000__INCLUDED_
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // CVCExploreDlg dialog
00028
00029 class CVCExploreDlg : public CDialog
00030 {
00031 // Construction
00032 public:
00033   void set_ComputerName(_bstr_t bstrComputerName);
00034   void set_CurrentCollection(ICatalogCollection* pCollection);
00035   CVCExploreDlg(CWnd* pParent = NULL);  // standard constructor
00036
00037 // Dialog Data
00038   //{{AFX_DATA(CVCExploreDlg)
00039   enum { IDD = IDD_VCEXPLORE };
00040   CButton m_btnSetProperty;
00041   CEdit   m_edtPropertyValue;
00042   CListBox  m_lstRelatedCollections;
00043   CListBox  m_lstProperties;
00044   CListBox  m_lstParentCollections;
00045   CListBox  m_lstObjects;
00046   CStatic   m_lblComputerName;
00047   CStatic   m_lblCollectionName;
00048   //}}AFX_DATA
00049
00050   // ClassWizard generated virtual function overrides
00051   //{{AFX_VIRTUAL(CVCExploreDlg)
00052   protected:
00053   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00054   //}}AFX_VIRTUAL
00055
00056 // Implementation
00057 protected:
00058   HICON m_hIcon;
00059
00060   // Generated message map functions
00061   //{{AFX_MSG(CVCExploreDlg)
00062   virtual BOOL OnInitDialog();
00063   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00064   afx_msg void OnPaint();
00065   afx_msg HCURSOR OnQueryDragIcon();
00066   afx_msg void OnTBtnAbout();
00067   afx_msg void OnTBtnConnect();
00068   afx_msg void OnTBtnDelete();
00069   afx_msg void OnTBtnExportApp();
00070   afx_msg void OnTBtnImportComponent();
00071   afx_msg void OnTBtnInstallApp();
00072   afx_msg void OnTBtnInstallComponent();
00073   afx_msg void OnTBtnNew();
00074   afx_msg void OnTBtnRefresh();
00075   afx_msg void OnTBtnSave();
00076   afx_msg void OnTBtnStartApp();
00077   afx_msg void OnTBtnStopApp();
00078   afx_msg void OnTBtnUtility();
00079   afx_msg void OnClose();
00080   afx_msg void OnSelChangeRelatedCollections();
00081   afx_msg void OnSelChangeParentCollections();
00082   afx_msg void OnSelChangeObjects();
00083   afx_msg void OnSelChangeProperties();
00084   afx_msg void OnSetProperty();
00085   //}}AFX_MSG
00086   DECLARE_MESSAGE_MAP()
00087
00088 private:
00089   ICOMAdminCatalog* GetCatalog();
00090   HRESULT   CreateCatalog();
00091   void    DestroyCatalog();
00092   HRESULT   NavigateTo(ICatalogCollection* pCatalogCollection, BOOL bPopulate = TRUE);
00093   void    DisplayPropertyValue();
00094   int     AddParent(ICatalogCollection* pCatalogCollection);
00095   void    RemoveParent(int nNewCurrIndex);
00096   void    TryToSaveChanges();
00097
00098   HWND        m_hwndToolBar;
00099   ICOMAdminCatalog* m_pCatalog;
00100   ICatalogCollection* m_pCurrCollection;
00101   BOOL   m_bChangesArePending;
00102 };
00103
00104 //{{AFX_INSERT_LOCATION}}
00105 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00106
00107 #endif // !defined(AFX_VCEXPLOREDLG_H__12723F27_B2F5_11D2_86A1_000000000000__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/hashtable.h Source File

  • NetDS
  • RRas
  • ip

hashtable.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\hashtable.h
00008
00009 Abstract:
00010
00011     The file contains the header for hashtable.c.
00012
00013 --*/
00014
00015 #ifndef _HASH_TABLE_H_
00016 #define _HASH_TABLE_H_
00017
00018
00019 typedef VOID (*PVOID_FUNCTION)
00020     (PLIST_ENTRY    pleEntry);
00021
00022 typedef PVOID_FUNCTION PDISPLAY_FUNCTION;
00023
00024 typedef PVOID_FUNCTION PFREE_FUNCTION;
00025
00026 typedef ULONG (*PHASH_FUNCTION)
00027     (PLIST_ENTRY    pleEntry);
00028
00029 // < 0 KeyEntry less than TableEntry
00030 //   0 KeyEntry identical TableEntry
00031 // > 0 KeyEntry more than TableEntry
00032 typedef LONG  (*PCOMPARE_FUNCTION)
00033     (PLIST_ENTRY    pleTableEntry,
00034      PLIST_ENTRY    pleKeyEntry);
00035
00036 typedef struct _HASH_TABLE
00037 {
00038     ULONG               ulNumBuckets;   // # buckets in hash table
00039     ULONG               ulNumEntries;   // # entries in hash table
00040
00041     PDISPLAY_FUNCTION   pfnDisplay;     // display an entry (optional)
00042     PFREE_FUNCTION      pfnFree;        // free an entry
00043     PHASH_FUNCTION      pfnHash;        // hash an entry
00044     PCOMPARE_FUNCTION   pfnCompare;     // compare two entries
00045
00046     PLIST_ENTRY         pleBuckets;     // the buckets
00047 } HASH_TABLE, *PHASH_TABLE;
00048
00049
00050
00051 // Create the hash table
00052 DWORD
00053 HT_Create(
00054     IN  HANDLE              hHeap,
00055     IN  ULONG               ulNumBuckets,
00056     IN  PDISPLAY_FUNCTION   pfnDisplay  OPTIONAL,
00057     IN  PFREE_FUNCTION      pfnFree,
00058     IN  PHASH_FUNCTION      pfnHash,
00059     IN  PCOMPARE_FUNCTION   pfnCompare,
00060     OUT PHASH_TABLE         *pphtHashTable);
00061
00062 // Destroy the hash table
00063 DWORD
00064 HT_Destroy(
00065     IN  HANDLE              hHeap,
00066     IN  PHASH_TABLE         phtTable);
00067
00068 // Clean hash table by destroying all entries
00069 DWORD
00070 HT_Cleanup(
00071     IN  PHASH_TABLE         phtHashTable);
00072
00073 // Display all entries in the hash table
00074 #define HT_Display(phtHashTable)                                    \
00075 {                                                                   \
00076     if (phtHashTable)                                               \
00077         HT_MapCar(phtHashTable, phtHashTable->pfnDisplay);          \
00078 }
00079
00080 // # entries in the hash table
00081 #define HT_Size(phtHashTable)                           \
00082 (                                                       \
00083     phtHashTable->ulNumEntries                          \
00084 )
00085
00086 // Is hash table empty?
00087 #define HT_IsEmpty(phtHashTable)                        \
00088 (                                                       \
00089     HT_Size(phtHashTable) is 0                          \
00090 )
00091
00092 // Inserts an entry in the hash table
00093 DWORD
00094 HT_InsertEntry(
00095     IN  PHASH_TABLE         phtHashTable,
00096     IN  PLIST_ENTRY         pleEntry);
00097
00098 // Gets the hash table entry with the given key
00099 DWORD
00100 HT_GetEntry(
00101     IN  PHASH_TABLE         phtHashTable,
00102     IN  PLIST_ENTRY         pleKey,
00103     OUT PLIST_ENTRY         *ppleEntry);
00104
00105 // Delete an entry from the hash table
00106 DWORD
00107 HT_DeleteEntry(
00108     IN  PHASH_TABLE         phtHashTable,
00109     IN  PLIST_ENTRY         pleKey,
00110     OUT PLIST_ENTRY         *ppleEntry);
00111
00112 // Remove this entry from the hash table
00113 #define HT_RemoveEntry(phtHashTable, pleEntry)          \
00114 (                                                       \
00115     RemoveEntryList(pleEntry)                           \
00116     phtHashTable->ulNumEntries--;                       \
00117 )
00118
00119 DWORD
00120 HT_DeleteEntry(
00121     IN  PHASH_TABLE         phtHashTable,
00122     IN  PLIST_ENTRY         pleKey,
00123     OUT PLIST_ENTRY         *ppleEntry);
00124
00125 // Is key present in the hash table?
00126 BOOL
00127 HT_IsPresentEntry(
00128     IN  PHASH_TABLE         phtHashTable,
00129     IN  PLIST_ENTRY         pleKey);
00130
00131 // Apply the specified function to all entries in the hash table
00132 DWORD
00133 HT_MapCar(
00134     IN  PHASH_TABLE         phtHashTable,
00135     IN  PVOID_FUNCTION      pfnVoidFunction);
00136
00137 #endif // _HASH_TABLE_H_
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/prsample/enum.cpp Source File

  • Dataaccess
  • oledb
  • prsample

enum.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 // Microsoft OLE DB Programmer's Reference Sample
00003 // Copyright (C) 1998 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module ENUM.CPP
00008 //
00009 //---------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////
00016 #include "prsample.h"   // Programmer's Reference Sample includes
00017
00018
00019
00020 /////////////////////////////////////////////////////////////////
00021 // myCreateEnumerator
00022 //
00023 //  This function creates an enumerator, obtains a sources rowset
00024 //  from it, displays the rowset to the user, and allows the user
00025 //  to specify the ProgID of a provider. The CLSID that matches
00026 //  this ProgID is retuned to the caller in *pCLSID.
00027 //
00028 /////////////////////////////////////////////////////////////////
00029 HRESULT myCreateEnumerator
00030   (
00031   REFCLSID        clsidEnumerator,
00032   CLSID *         pCLSID
00033   )
00034 {
00035   HRESULT         hr;
00036   IUnknown *        pIUnkEnumerator       = NULL;
00037   ISourcesRowset *    pISourcesRowset       = NULL;
00038   IRowset *       pIRowset          = NULL;
00039   IDBInitialize *     pIDBInitialize        = NULL;
00040   WCHAR         wszProgID[MAX_NAME_LEN + 1] = {0};
00041
00042   const ULONG       cProperties         = 2;
00043   DBPROP          rgProperties[cProperties];
00044   DBPROPSET       rgPropSets[1];
00045
00046   // Create the Enumerator object. We ask for IUnknown when creating
00047   // the enumerator because some enumerators may require initialization
00048   // before we can obtain a sources rowset from the enumerator. This is
00049   // indicated by whether the enumerator object exposes IDBInitialize
00050   // or not (we don't want to ask for IDBInitialize, since enumerators
00051   // that don't require initialization will cause the CoCreateInstance
00052   // to fail)
00053   XCHECK_HR(hr = CoCreateInstance(
00054         clsidEnumerator,      //clsid -- enumerator
00055         NULL,           //pUnkOuter
00056         CLSCTX_INPROC_SERVER,   //dwClsContext
00057         IID_IUnknown,       //riid
00058         (void**)&pIUnkEnumerator  //ppvObj
00059         ));
00060
00061   // If the enumerator exposes IDBInitialize, we need to initialize it
00062   if( SUCCEEDED(hr = pIUnkEnumerator->QueryInterface(IID_IDBInitialize,
00063         (void**)&pIDBInitialize)) )
00064   {
00065     CHECK_HR(hr = myDoInitialization(pIUnkEnumerator));
00066   }
00067
00068   // Set properties on the rowset, to request additional functionality
00069   myAddRowsetProperties(rgPropSets, cProperties, rgProperties);
00070
00071   // Obtain a sources rowset from the enumerator. This rowset contains
00072   // all of the OLE DB providers that this enumerator is able to list
00073   XCHECK_HR(hr = pIUnkEnumerator->QueryInterface(IID_ISourcesRowset,
00074         (void**)&pISourcesRowset));
00075   XCHECK_HR(hr = pISourcesRowset->GetSourcesRowset(
00076         NULL,         //pUnkOuter
00077         IID_IRowset,      //riid
00078         1,            //cPropSets
00079         rgPropSets,       //rgPropSets
00080         (IUnknown**)&pIRowset //ppRowset
00081         ));
00082
00083   // Display the rowset to the user; this will allow the user to
00084   // perform basic navigation of the rowset and will allow the user
00085   // to select a row containing a desired provider.
00086   CHECK_HR(hr = myDisplayRowset(pIRowset,
00087         L"SOURCES_NAME", MAX_NAME_LEN, wszProgID));
00088
00089   // Obtain the ProgID for the provider to use from the user;
00090   // the default value for this is the value of the SOURCES_NAME
00091   // column in the row selected by the user previously
00092   myGetInputFromUser(wszProgID, L"\nType the ProgID of a provider"
00093         L" to use [Enter = `%s`]: ", wszProgID);
00094   XCHECK_HR(hr = CLSIDFromProgID(wszProgID, pCLSID));
00095
00096 CLEANUP:
00097   if( pIUnkEnumerator )
00098     pIUnkEnumerator->Release();
00099   if( pISourcesRowset )
00100     pISourcesRowset->Release();
00101   if( pIRowset )
00102     pIRowset->Release();
00103   if( pIDBInitialize )
00104     pIDBInitialize->Release();
00105   return hr;
00106 }
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/CommCode.h Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

CommCode.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // PURPOSE:
00009 //    Contains public declarations for the CommCode module.
00010 //
00011
00012 BOOL StartComm(HANDLE hNewCommFile);
00013 void StopComm();
00014 BOOL WriteCommString(LPCSTR pszStringToWrite, DWORD nSizeofStringToWrite);
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/guids.h Source File

  • SysMgmt
  • MMC
  • Nameext

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019
00020 // {64026453-6A22-11d3-9154-00C04F65B3F9}
00021 DEFINE_GUID(CLSID_CNamespaceExtension,
00022 0x64026453, 0x6a22, 0x11d3, 0x91, 0x54, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
00023
00024
00025 // {AF2039D3-6A26-11d3-9154-00C04F65B3F9}
00026 DEFINE_GUID(CLSID_CSnapinAbout,
00027 0xaf2039d3, 0x6a26, 0x11d3, 0x91, 0x54, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/pluggable/plgtermpin.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • pluggable

plgtermpin.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999-2001 Microsoft Corporation
00004
00005 Module Name:
00006
00007     PlgTstPin.cpp
00008
00009 Abstract:
00010
00011     Implementation of the Input pin of the pluggable filter
00012
00013
00014
00015 --*/
00016
00017 #include "stdafx.h"
00018 #include "PlgTermPin.h"
00019 #include <initguid.h>
00020 #include "GUIDs.h"
00021
00022 // --- Construction/Destruction ---
00023 CPlgPin::CPlgPin(
00024         CPlgFilter*  pFilter,
00025         HRESULT*    phr,
00026         LPCWSTR     pPinName)
00027         : CBaseInputPin(_T("CPlgPin"), pFilter, pFilter, phr, pPinName)
00028 {
00029     LOG((MSP_TRACE, "CPlgPin::CPlgPin"));
00030 }
00031
00032 CPlgPin::~CPlgPin()
00033 {
00034     LOG((MSP_TRACE, "CPlgPin::~CPlgPin"));
00035 }
00036
00037
00038 // -- CBasePin ---
00039
00040 /*++
00041 CheckMediaType
00042
00043 Description:
00044     Abstract method from CBasePin
00045     Check if the pin can support this specific proposed type&format
00046 --*/
00047 HRESULT CPlgPin::CheckMediaType(const CMediaType * pmt)
00048 {
00049     LOG((MSP_TRACE, "CPlgPin::CheckMediaType - enter"));
00050
00051     //
00052     // Validates parameters
00053     //
00054
00055     if( IsBadReadPtr(pmt, sizeof(CMediaType)) )
00056     {
00057         LOG((MSP_ERROR, "CPlgPin::CheckMediaType - "
00058             "invalid pointer, return E_POINTER"));
00059         return E_POINTER;
00060     }
00061
00062
00063     if ( !pmt->IsValid() )
00064     {
00065
00066         LOG((MSP_ERROR,
00067             "CPlgPin::CheckMediaType - media type invalid. "
00068             "E_INVALIDARG"));
00069
00070         return VFW_E_INVALIDMEDIATYPE;
00071     }
00072
00073     CAutoLock lock((CPlgFilter*)m_pFilter);
00074
00075     //
00076     // reject non-Audio type
00077     //
00078
00079     if (pmt->majortype  != MEDIATYPE_Audio ||
00080         pmt->formattype != FORMAT_WaveFormatEx)
00081     {
00082         LOG((MSP_ERROR, "CPlgPin::CheckMediaType - "
00083             "non-Audio type, return VFW_E_INVALIDMEDIATYPE"));
00084         return VFW_E_INVALIDMEDIATYPE;
00085     }
00086
00087     LOG((MSP_TRACE, "CPlgPin::CheckMediaType - succeeded"));
00088     return S_OK;
00089 }
00090
00091
00092 /*++
00093 SetMediaType
00094
00095 Description:
00096     Method from CBasePin not necessary to be rewritten
00097     CBasePin, start using this mediatype
00098 --*/
00099 HRESULT CPlgPin::SetMediaType(
00100      IN     const CMediaType*       pmt
00101      )
00102 {
00103     LOG((MSP_TRACE, "CPlgPin::SetMediaType - enter"));
00104
00105     LOG((MSP_TRACE,"SetMediaType %d bit %d channel %dHz",
00106         ((LPWAVEFORMATEX)(pmt->pbFormat))->wBitsPerSample,
00107         ((LPWAVEFORMATEX)(pmt->pbFormat))->nChannels,
00108         ((LPWAVEFORMATEX)(pmt->pbFormat))->nSamplesPerSec));
00109
00110     CAutoLock lock((CPlgFilter*)m_pFilter);
00111
00112     // Pass the call up to my base class
00113
00114     HRESULT hr = CBaseInputPin::SetMediaType(pmt);
00115     if (SUCCEEDED(hr))
00116     {
00117
00118         WAVEFORMATEX *pwf = (WAVEFORMATEX *) pmt->Format();
00119
00120    }
00121     // We assume this format has been checked out already and is OK
00122     LOG((MSP_TRACE, "CPlgPin::SetMediaType - exit 0x%08x", hr));
00123     return hr;
00124 }
00125
00126 /*++
00127 GetMediaType
00128
00129 Description:
00130     Method from CBasePin should be rewrote
00131     Enumerate supported input types
00132 --*/
00133 HRESULT CPlgPin::GetMediaType(
00134      OUT    CMediaType*             pmt
00135      )
00136 {
00137     LOG((MSP_TRACE, "CPlgPin::GetMediaType - enter"));
00138     //
00139     // Validates parameters
00140     //
00141
00142     if( IsBadReadPtr(pmt, sizeof(CMediaType)) )
00143     {
00144         LOG((MSP_ERROR, "CPlgPin::GetMediaType - "
00145             "invalid pointer, return E_POINTER"));
00146         return E_POINTER;
00147     }
00148
00149     if(NULL == m_pFilter)
00150     {
00151         return E_UNEXPECTED;
00152     }
00153
00154     CAutoLock lock((CPlgFilter*)m_pFilter);
00155
00156     HRESULT hr = InitMediaType();
00157     if (FAILED (hr))
00158     {
00159         LOG((MSP_ERROR, "CPlgPin::GetMediaType - "
00160             "InitMediaType failed, return 0x%08x", hr));
00161         return hr;
00162     }
00163
00164     CPlgFilter* pFilter = (CPlgFilter*)m_pFilter;
00165
00166     //
00167     //create media type to return
00168     //
00169     hr = CreateAudioMediaType(pFilter->m_lpWaveFormatEx, pmt, TRUE);
00170
00171     LOG((MSP_TRACE, "CPlgPin::GetMediaType - exit 0x%08x", hr));
00172     return hr;
00173 }
00174
00175 /*++
00176 Active
00177
00178 Description;
00179     Implements the remaining IMemInputPin virtual methods
00180 --*/
00181 HRESULT CPlgPin::Active(void)
00182 {
00183     LOG((MSP_TRACE, "CPlgPin::Active - enter"));
00184
00185     if(NULL == m_pFilter)
00186     {
00187         return E_UNEXPECTED;
00188     }
00189
00190
00191     CAutoLock lock((CPlgFilter*)m_pFilter);
00192
00193     HRESULT hr = CBasePin::Active();
00194
00195   if(((CPlgFilter*)m_pFilter)->m_pPlgEventSink != NULL)
00196   {
00197     ((CPlgFilter*)m_pFilter)->m_pPlgEventSink->FireEvent(1);
00198   }
00199
00200     LOG((MSP_TRACE, "CPlgPin::Active - exit 0x%08x", hr));
00201     return hr;
00202 }
00203
00204 /*++
00205 Inactive
00206
00207 Description:
00208     Called when the filter is stopped
00209 --*/
00210 HRESULT CPlgPin::Inactive(void)
00211 {
00212     LOG((MSP_TRACE, "CPlgPin::Inactive - enter"));
00213
00214     if(NULL == m_pFilter)
00215     {
00216         return E_UNEXPECTED;
00217     }
00218
00219
00220     CAutoLock lock((CPlgFilter*)m_pFilter);
00221
00222     HRESULT hr = CBasePin::Inactive();
00223
00224     if(((CPlgFilter*)m_pFilter)->m_pPlgEventSink != NULL)
00225     {
00226         ((CPlgFilter*)m_pFilter)->m_pPlgEventSink->FireEvent(0);
00227     }
00228
00229     LOG((MSP_TRACE, "CPlgPin::Inactive - exit 0x%08x", hr));
00230     return hr;
00231 }
00232
00233 /*++
00234 Receive
00235
00236 Description:
00237     Here's the next block of data from the stream
00238 --*/
00239 HRESULT CPlgPin::Receive(
00240     IN  IMediaSample*       pSample
00241     )
00242 {
00243     LOG((MSP_TRACE, "CPlgPin::Receive - enter"));
00244     //
00245     //validate parameters
00246     //
00247     if(IsBadWritePtr(pSample, sizeof(IMediaSample*)))
00248     {
00249         LOG((MSP_ERROR, "CPlgPin::Receive - exit E_POINTER"));
00250         return E_POINTER;
00251     }
00252     LOG((MSP_TRACE, "CPlgPin::Receive - sample size 0x%08x", pSample->GetSize()));
00253
00254     if(NULL == m_pFilter)
00255     {
00256         return E_UNEXPECTED;
00257     }
00258
00259     CAutoLock lock((CPlgFilter*)m_pFilter);
00260
00261     // If we're stopped, then reject this call
00262     // (the filter graph may be in mid-change)
00263     if (((CPlgFilter*)m_pFilter)->m_State == State_Stopped)
00264     {
00265         LOG((MSP_ERROR, "CPlgPin::Receive - "
00266             "the filter is stoped, return E_FAIL"));
00267         return E_FAIL;
00268     }
00269
00270     // Check all is well with the base class
00271     HRESULT hr = CBaseInputPin::Receive(pSample);
00272     if (FAILED(hr))
00273     {
00274         LOG((MSP_ERROR, "CPlgPin::Receive - "
00275             "base Received failed, return 0x%08x", hr));
00276         return hr;
00277     }
00278
00279     LOG((MSP_TRACE, "CPlgPin::Receive - ended 0x%08x", hr));
00280     return hr;
00281
00282 }
00283
00284
00285
00286 // --- Helper methods ---
00287
00288 /*++
00289 InitMediaType
00290
00291 Description:
00292     Initialize WAVEFORMATEX member of CTGFilter
00293     Is called by GetMediaType
00294 --*/
00295 HRESULT CPlgPin::InitMediaType(void)
00296 {
00297     LOG((MSP_TRACE, "CPlgPin::InitMediaType - enter"));
00298
00299     CPlgFilter* pFilter = (CPlgFilter*)m_pFilter;
00300
00301     if(NULL == m_pFilter)
00302     {
00303         return E_UNEXPECTED;
00304     }
00305
00306     //
00307     // Is already initialized ?
00308     //
00309     if(pFilter->m_lpWaveFormatEx != NULL)
00310     {
00311         LOG((MSP_TRACE, "CTGPin::InitMediaType - succeeded,"
00312             "WAVEFORMATEX already initialize"));
00313         return S_OK;
00314     }
00315
00316     //
00317     // Create a new WAVEFORMATEX
00318     //
00319
00320     pFilter->m_lpWaveFormatEx = (LPWAVEFORMATEX) CoTaskMemAlloc(sizeof(WAVEFORMATEX));
00321     if (!pFilter->m_lpWaveFormatEx)
00322     {
00323         LOG((MSP_ERROR, "CTGPin::InitMediaType - "
00324             "cannot allocate WAVEFORMATEX, return E_OUTOFMEMORY"));
00325         return E_OUTOFMEMORY;
00326     }
00327
00328     // reset the memory
00329     ZeroMemory(pFilter->m_lpWaveFormatEx, sizeof (WAVEFORMATEX));
00330
00331     // sets the fields
00332     pFilter->m_lpWaveFormatEx->wFormatTag      = WAVE_FORMAT_PCM;
00333     pFilter->m_lpWaveFormatEx->wBitsPerSample  = 16;
00334     pFilter->m_lpWaveFormatEx->nChannels       = 1;
00335     pFilter->m_lpWaveFormatEx->nSamplesPerSec  = 8000;
00336     pFilter->m_lpWaveFormatEx->nBlockAlign     = 1 * ((16 + 7)/8);
00337     pFilter->m_lpWaveFormatEx->nAvgBytesPerSec = 8000 *
00338                                                pFilter->m_lpWaveFormatEx->nBlockAlign;
00339     pFilter->m_lpWaveFormatEx->cbSize          = 0;
00340
00341     LOG((MSP_TRACE, "CPlgPin::InitMediaType exit - S_OK"));
00342     return S_OK;
00343 }
00344
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::Errors Member List

This is the complete list of members for msado15::Errors, including all inherited members.
_NewEnum() | msado15::Errors |
Clear() | msado15::Errors |
getCount() | msado15::Errors |
getItem(Variant Index) | msado15::Errors |
iid | msado15::Errors | [static]
Refresh() | msado15::Errors |
Generated on Wed Nov 13 2024 16:58:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/DRAWPage.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

DRAWPage.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DRAWPAGE.CPP
00003
00004   Summary:   Implementation file for the CODrawPage COM Object Class (for
00005              connectable, persistent CODrawPage COM Objects). CODrawPage
00006              encapsulates into a COM object the behavior of an persistent
00007              electronic page of white drawing paper. The client can use
00008              the native IDrawPage interface to draw free-form ink lines on
00009              a virtual paper surface. No GUI behavior is provided within
00010              CODrawPage--it only provides the semantics of the virtual
00011              drawing paper and manages the ink data for the drawing done
00012              there by clients. CODrawPages are self-persistent in compound
00013              file storages and can can thus store and load the DrawPage
00014              data contents to and from an IStorage given by the client
00015              (using the standard IPersistStorage interface).
00016
00017              CODrawPage offers a main standard IUnknown interface (basic
00018              COM object features), an implementation of the standard
00019              IConnectionPointContainer interface (connectable object
00020              features), an implementation of the standard IPersistStorage
00021              interface (features for object persistence in compound file
00022              storages), and an implementation of the custom IDrawPage
00023              interface (drawing page related features). This multiple
00024              interface COM Object Class is achieved via the technique of
00025              nested classes.  The implementation of the various
00026              interfaces are nested inside of the CODrawPage Class.
00027
00028              For a comprehensive tutorial code tour of this module's
00029              contents and offerings see the tutorial PERDRAW.HTM file. For
00030              more specific technical details on the internal workings see
00031              the comments dispersed throughout the module's source code.
00032
00033   Classes:   CODrawPage.
00034
00035   Functions: none.
00036
00037   Origin:    5-20-97: atrent - Editor-inheritance from PAPER.CPP in
00038              the STOSERVE Tutorial Code Sample.
00039
00040 ----------------------------------------------------------------------------
00041   This file is part of the Microsoft COM Tutorial Code Samples.
00042
00043   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00044
00045   This source code is intended only as a supplement to Microsoft
00046   Development Tools and/or on-line documentation.  See these other
00047   materials for detailed information regarding Microsoft code samples.
00048
00049   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00050   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00051   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00052   PARTICULAR PURPOSE.
00053 ==========================================================================+*/
00054
00055
00056 /*---------------------------------------------------------------------------
00057   We include WINDOWS.H for all Win32 applications.
00058   We include OLE2.H because we will be calling the COM/OLE Libraries.
00059   We include OLECTL.H because it has definitions for connectable objects.
00060   We include APPUTIL.H because we will be building this application using
00061     the convenient Virtual Window and Dialog classes and other
00062     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00063   We include IPAGES.H and PAGEGUID.H for the common DrawPage-related
00064     Interface classes, GUID, and CLSID specifications.
00065   We include SERVER.H because it has internal class declarations for
00066     the server's control object.
00067   We include CONNECT.H for object class declarations for the various
00068     connection point and connection COM objects used in PERDRAW.
00069   We include DRAWPAGE.H because it has the CODrawPage class declarations.
00070 ---------------------------------------------------------------------------*/
00071 #include <windows.h>
00072 #include <ole2.h>
00073 #include <olectl.h>
00074 #include <apputil.h>
00075 #include <ipages.h>
00076 #include <pageguid.h>
00077 #include "server.h"
00078 #include "connect.h"
00079 #include "drawpage.h"
00080
00081
00082 /*---------------------------------------------------------------------------
00083   CODrawPage's implementation of its main COM object class including
00084   Constructor, Destructor, and the QueryInterface, AddRef, and Release
00085   methods of the principal IUnknown interface.
00086 ---------------------------------------------------------------------------*/
00087
00088 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00089   Method:   CODrawPage::CODrawPage
00090
00091   Summary:  CODrawPage Constructor. Note the member initializers like:
00092             "m_ImpIDrawPage(this, pUnkOuter)" which is used to pass the
00093             'this' and pUnkOuter pointers of the constructor function to
00094             the constructor in the instantiation of the implementation of
00095             the CImpIDrawPage interface (which is nested inside this
00096             present CODrawPage Object Class). Same initializer technique
00097             is used for the other nested interface implementations.
00098
00099   Args:     IUnknown* pUnkOuter,
00100               Pointer to the the outer IUnknown.  NULL means this COM Object
00101               is not being Aggregated.  Non-NULL means it is being created
00102               on behalf of an outside COM object that is reusing it via
00103               aggregation.
00104             CServer* pServer)
00105               Pointer to the server's control object.
00106
00107   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00108
00109   Returns:  void
00110 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00111 CODrawPage::CODrawPage(
00112   IUnknown* pUnkOuter,
00113   CServer* pServer) :
00114   m_ImpIConnectionPointContainer(this, pUnkOuter),
00115   m_ImpIPersistStorage(this, pUnkOuter),
00116   m_ImpIDrawPage(this, pUnkOuter)
00117 {
00118   UINT i;
00119
00120   // Zero the COM object's reference count.
00121   m_cRefs = 0;
00122
00123   // No AddRef necessary if non-NULL, as we're nested.
00124   m_pUnkOuter = pUnkOuter;
00125
00126   // Assign the pointer to the server control object.
00127   m_pServer = pServer;
00128
00129   // Null all entries in the connection point array.
00130   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00131     m_aConnectionPoints[i] = NULL;
00132
00133   // Now initialize the living heart of this virtual DrawPage entity.
00134   m_crWinColor   = RGB(255,255,255); // White window background color.
00135   m_crInkColor   = RGB(0,0,0);       // Black ink drawing color.
00136   m_nInkWidth    = 2;                // 2 pixels wide (thin) for ink.
00137   m_lInkDataEnd  = 0;                // Current drawing data end.
00138   m_lInkDataMax  = 0;                // Upper bound to m_lInkDataEnd.
00139   m_paInkData    = NULL;             // Points to the Ink data array.
00140   m_ClassID      = CLSID_DrawPage;   // ClassID. Copy w/ overloaded '='.
00141   m_ClipFmt      = 0;                // Registered clipboard format ID.
00142   m_StgState     = PERS_UNINIT;      // Persistent Storage State.
00143   m_bDirty       = TRUE;             // File initially doesn't match RAM.
00144
00145   return;
00146 }
00147
00148
00149 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00150   Method:   CODrawPage::~CODrawPage
00151
00152   Summary:  CODrawPage Destructor.
00153
00154   Args:     void
00155
00156   Returns:  void
00157 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00158 CODrawPage::~CODrawPage(void)
00159 {
00160   UINT i;
00161   IConnectionPoint* pIConnectionPoint;
00162
00163   // Do final release of the connection point objects.
00164   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00165   {
00166     pIConnectionPoint = m_aConnectionPoints[i];
00167     RELEASE_INTERFACE(pIConnectionPoint);
00168   }
00169
00170   return;
00171 }
00172
00173
00174 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00175   Method:   CODrawPage::Init
00176
00177   Summary:  CODrawPage initialization method.  Create any necessary arrays,
00178             structures, and subordinate objects. Rigs for connectivity.
00179
00180   Args:     void
00181
00182   Modifies: m_aConnectionPoints.
00183
00184   Returns:  HRESULT
00185               Standard result code. NOERROR for success.
00186 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00187 HRESULT CODrawPage::Init(void)
00188 {
00189   HRESULT hr = NOERROR;
00190   INKDATA* paInkData;
00191   COConnectionPoint* pCOConnPt;
00192
00193   // Zero the Properties structure. Init the ink data version.
00194   memset(&m_DrawProps, 0, sizeof(DRAWPROPS));
00195   m_DrawProps.lInkDataVersion = INKDATA_VERSION20;
00196
00197   // Register a clipboard format for DrawPages.
00198   m_ClipFmt = RegisterClipboardFormat(TEXT(SZ_CLIPUSERTYPE));
00199
00200   // Build the initial dynamic array of InkData.
00201   paInkData = new INKDATA[(LONG) INKDATA_ALLOC_INIT];
00202   if (NULL != paInkData)
00203   {
00204     // Zero the array.
00205     memset(paInkData, 0, INKDATA_ALLOC_INIT * sizeof(INKDATA));
00206
00207     // Rig this object so that it can use the Ink Data array.
00208     m_lInkDataMax = INKDATA_ALLOC_INIT;
00209     m_paInkData = paInkData;
00210   }
00211   else
00212     hr = E_OUTOFMEMORY;
00213
00214   if (SUCCEEDED(hr))
00215   {
00216     // Rig this CODrawPage COM object to be connectable. Assign the
00217     // connection point array. This object's connection points are
00218     // determined at compile time--it currently has only one connection
00219     // point: the CONNPOINT_DRAWPAGESINK connection point. Create a
00220     // connection point object for this and assign it into the array. This
00221     // array could easily grow to support additional connection points in
00222     // the future.
00223
00224     // First try creating a new connection point object. Pass 'this' as the
00225     // pHostObj pointer used by the connection point to pass its AddRef and
00226     // Release calls back to the host connectable object.
00227     pCOConnPt = new COConnectionPoint(this);
00228     if (NULL != pCOConnPt)
00229     {
00230       // If creation succeeded then initialize it (including creating
00231       // its initial dynamic connection array).
00232       hr = pCOConnPt->Init(IID_IDrawPageSink);
00233
00234       // If the init succeeded then use QueryInterface to obtain the
00235       // IConnectionPoint interface on the new connection point object.
00236       // The interface pointer is assigned directly into the
00237       // connection point array. The QI also does the needed AddRef.
00238       if (SUCCEEDED(hr))
00239         hr = pCOConnPt->QueryInterface(
00240                IID_IConnectionPoint,
00241                (PPVOID)&m_aConnectionPoints[CONNPOINT_DRAWPAGESINK]);
00242     }
00243     else
00244       hr = E_OUTOFMEMORY;
00245   }
00246
00247   return hr;
00248 }
00249
00250
00251 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00252   Method:   CODrawPage::QueryInterface
00253
00254   Summary:  QueryInterface of the CODrawPage main non-delegating IUnknown
00255             implementation.
00256
00257   Args:     REFIID riid,
00258               [in] GUID of the Interface being requested.
00259             PPVOID ppv)
00260               [out] Address of the caller's pointer variable that will
00261               receive the requested interface pointer.
00262
00263   Returns:  HRESULT
00264               Standard result code. NOERROR for success.
00265 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00266 STDMETHODIMP CODrawPage::QueryInterface(
00267                REFIID riid,
00268                PPVOID ppv)
00269 {
00270   HRESULT hr = E_NOINTERFACE;
00271
00272   *ppv = NULL;
00273
00274   if (IID_IUnknown == riid)
00275     *ppv = this;
00276   else if (IID_IConnectionPointContainer == riid)
00277     *ppv = &m_ImpIConnectionPointContainer;
00278   else if (IID_IPersistStorage == riid)
00279     *ppv = &m_ImpIPersistStorage;
00280   else if (IID_IDrawPage == riid)
00281     *ppv = &m_ImpIDrawPage;
00282
00283   if (NULL != *ppv)
00284   {
00285     // We've handed out a pointer to the interface so obey the COM rules
00286     // and AddRef the reference count.
00287     ((LPUNKNOWN)*ppv)->AddRef();
00288     hr = NOERROR;
00289   }
00290
00291   return (hr);
00292 }
00293
00294
00295 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00296   Method:   CODrawPage::AddRef
00297
00298   Summary:  AddRef of the CODrawPage non-delegating IUnknown implementation.
00299
00300   Args:     void
00301
00302   Modifies: m_cRefs.
00303
00304   Returns:  ULONG
00305               New value of m_cRefs (COM object's reference count).
00306 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00307 STDMETHODIMP_(ULONG) CODrawPage::AddRef(void)
00308 {
00309   ULONG cRefs;
00310
00311   cRefs = ++m_cRefs;
00312
00313   return cRefs;
00314 }
00315
00316
00317 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00318   Method:   CODrawPage::Release
00319
00320   Summary:  Release of the CODrawPage non-delegating IUnknown implementation.
00321
00322   Args:     void
00323
00324   Modifies: m_cRefs.
00325
00326   Returns:  ULONG
00327               New value of m_cRefs (COM object's reference count).
00328 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00329 STDMETHODIMP_(ULONG) CODrawPage::Release(void)
00330 {
00331   ULONG cRefs;
00332
00333   cRefs = --m_cRefs;
00334
00335   if (0 == cRefs)
00336   {
00337     // We've reached a zero reference count for this COM object.
00338     // So we tell the server housing to decrement its global object
00339     // count so that the server will be unloaded if appropriate.
00340     if (NULL != m_pServer)
00341       m_pServer->ObjectsDown();
00342
00343     // We artificially bump the main ref count to prevent reentrancy
00344     // via the main object destructor.
00345     m_cRefs++;
00346     delete this;
00347   }
00348
00349   return cRefs;
00350 }
00351
00352
00353 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00354   Method:   CODrawPage::NotifySinks
00355
00356   Summary:  Internal utility method of this COM object used to fire event
00357             notification calls to all listening connection sinks in the
00358             client.
00359
00360   Args:     DRAWPAGE_EVENT DrawPageEvent
00361               Type of notification event.
00362             SHORT nX
00363               X cordinate. Value is 0 unless event needs it.
00364             SHORT nY
00365               Y cordinate. Value is 0 unless event needs it.
00366             SHORT nInkWidth
00367               Ink Width. Value is 0 unless event needs it.
00368             SHORT crInkColor
00369               COLORREF RGB color value. Value is 0 unless event needs it.
00370
00371   Returns:  HRESULT
00372               Standard result code. NOERROR for success.
00373 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00374 HRESULT CODrawPage::NotifySinks(
00375        DRAWPAGE_EVENT DrawPageEvent,
00376        SHORT nX,
00377        SHORT nY,
00378        SHORT nInkWidth,
00379        COLORREF crInkColor)
00380 {
00381   HRESULT hr = NOERROR;
00382   IConnectionPoint* pIConnectionPoint;
00383   IEnumConnections* pIEnum;
00384   CONNECTDATA ConnData;
00385
00386   // If there was a DrawPage event, broadcast appropriate notifications to
00387   // all Sinks connected to each connection point.
00388   if (DRAWPAGE_EVENT_NONE != DrawPageEvent)
00389   {
00390     // Here is the section for the DrawPageSink connection point--currently
00391     // this is the only connection point offered by CODrawPage objects.
00392     pIConnectionPoint = m_aConnectionPoints[CONNPOINT_DRAWPAGESINK];
00393     if (NULL != pIConnectionPoint)
00394     {
00395       pIConnectionPoint->AddRef();
00396       hr = pIConnectionPoint->EnumConnections(&pIEnum);
00397       if (SUCCEEDED(hr))
00398       {
00399         // Loop thru the connection point's connections and if the
00400         // listening connection supports IDrawPageSink (ie, DrawPageSink
00401         // events) then dispatch the DrawPageEvent event notification to
00402         // that sink.
00403         while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
00404         {
00405           IDrawPageSink* pIDrawPageSink;
00406
00407           hr = ConnData.pUnk->QueryInterface(
00408                                 IID_IDrawPageSink,
00409                                 (PPVOID)&pIDrawPageSink);
00410           if (SUCCEEDED(hr))
00411           {
00412             switch (DrawPageEvent)
00413             {
00414               case DRAWPAGE_EVENT_INKDRAW:
00415                 pIDrawPageSink->InkDraw(nX, nY);
00416                 break;
00417               case DRAWPAGE_EVENT_INKSTART:
00418                 pIDrawPageSink->InkStart(nX, nY, nInkWidth, crInkColor);
00419                 break;
00420               case DRAWPAGE_EVENT_INKSTOP:
00421                 pIDrawPageSink->InkStop(nX, nY);
00422                 break;
00423               case DRAWPAGE_EVENT_RESIZED:
00424                 pIDrawPageSink->Resized(nX, nY);
00425                 break;
00426               case DRAWPAGE_EVENT_CLEARED:
00427                 pIDrawPageSink->Cleared();
00428                 break;
00429               case DRAWPAGE_EVENT_LOADED:
00430                 pIDrawPageSink->Loaded();
00431                 break;
00432               case DRAWPAGE_EVENT_SAVED:
00433                 pIDrawPageSink->Saved();
00434                 break;
00435               default:
00436                 break;
00437             }
00438             pIDrawPageSink->Release();
00439           }
00440           ConnData.pUnk->Release();
00441         }
00442         pIEnum->Release();
00443       }
00444       pIConnectionPoint->Release();
00445     }
00446   }
00447
00448   return hr;
00449 }
00450
00451
00452 /*---------------------------------------------------------------------------
00453   CODrawPage's nested implementation of the COM standard
00454   IConnectionPointContainer interface including Constructor, Destructor,
00455   QueryInterface, AddRef, Release, FindConnectionPoint, and
00456   EnumConnectionPoints.
00457 ---------------------------------------------------------------------------*/
00458
00459 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00460   Method:   CODrawPage::CImpIConnectionPointContainer
00461               ::CImpIConnectionPointContainer
00462
00463   Summary:  Constructor for the CImpIConnectionPointContainer interface
00464             instantiation.
00465
00466   Args:     CODrawPage* pCO,
00467               Back pointer to the parent outer COM object.
00468             IUnknown* pUnkOuter
00469               Pointer to the outer Unknown.  For delegation.
00470
00471   Modifies: m_pCO, m_pUnkOuter.
00472
00473   Returns:  void
00474 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00475 CODrawPage::CImpIConnectionPointContainer::CImpIConnectionPointContainer(
00476   CODrawPage* pCO,
00477   IUnknown* pUnkOuter)
00478 {
00479   // Init the interface's object pointer to point to the parent COM object.
00480   m_pCO = pCO;
00481
00482   // Init the CImpIConnectionPointContainer interface's delegating Unknown
00483   // pointer.  We use the main Object pointer for IUnknown delegation here
00484   // if we are not being aggregated.  If we are being aggregated we use
00485   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00486   // pointer assignment requires no AddRef because the
00487   // CImpIConnectionPointContainer lifetime is quaranteed by the lifetime
00488   // of the parent object in which CImpIConnectionPointContainer is
00489   // nested.
00490   if (NULL == pUnkOuter)
00491     m_pUnkOuter = pCO;
00492   else
00493     m_pUnkOuter = pUnkOuter;
00494
00495   return;
00496 }
00497
00498
00499 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00500   Method:   CODrawPage::CImpIConnectionPointContainer
00501               ::~CImpIConnectionPointContainer
00502
00503   Summary:  Destructor for the CImpIConnectionPointContainer interface
00504             instantiation.
00505
00506   Args:     void
00507
00508   Returns:  void
00509 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00510 CODrawPage::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
00511 {
00512   return;
00513 }
00514
00515
00516 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00517   Method:   CODrawPage::CImpIConnectionPointContainer::QueryInterface
00518
00519   Summary:  The QueryInterface IUnknown member of this interface
00520             implementation that delegates to m_pUnkOuter, whatever it is.
00521
00522   Args:     REFIID riid,
00523               [in] GUID of the Interface being requested.
00524             PPVOID ppv)
00525               [out] Address of the caller's pointer variable that will
00526               receive the requested interface pointer.
00527
00528   Returns:  HRESULT
00529               Standard result code. NOERROR for success.
00530               Returned by the delegated outer QueryInterface call.
00531 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00532 STDMETHODIMP CODrawPage::CImpIConnectionPointContainer::QueryInterface(
00533                REFIID riid,
00534                PPVOID ppv)
00535 {
00536   // Delegate this call to the outer object's QueryInterface.
00537   return m_pUnkOuter->QueryInterface(riid, ppv);
00538 }
00539
00540
00541 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00542   Method:   CODrawPage::CImpIConnectionPointContainer::AddRef
00543
00544   Summary:  The AddRef IUnknown member of this interface implementation
00545             that delegates to m_pUnkOuter, whatever it is.
00546
00547   Args:     void
00548
00549   Returns:  ULONG
00550               Returned by the delegated outer AddRef call.
00551 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00552 STDMETHODIMP_(ULONG) CODrawPage::CImpIConnectionPointContainer::AddRef(void)
00553 {
00554   // Delegate this call to the outer object's AddRef.
00555   return m_pUnkOuter->AddRef();
00556 }
00557
00558
00559 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00560   Method:   CODrawPage::CImpIConnectionPointContainer::Release
00561
00562   Summary:  The Release IUnknown member of this interface implementation
00563             that delegates to m_pUnkOuter, whatever it is.
00564
00565   Args:     void
00566
00567   Returns:  ULONG
00568               Returned by the delegated outer Release call.
00569 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00570 STDMETHODIMP_(ULONG) CODrawPage::CImpIConnectionPointContainer::Release(void)
00571 {
00572   // Delegate this call to the outer object's Release.
00573   return m_pUnkOuter->Release();
00574 }
00575
00576
00577 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00578   Method:   CODrawPage::CImpIConnectionPointContainer::FindConnectionPoint
00579
00580   Summary:  Given an IID for a connection point sink find and return the
00581             interface pointer for that connection point sink.
00582
00583   Args:     REFIID riid
00584               Reference to an IID
00585             IConnectionPoint** ppConnPt
00586               Address of the caller's IConnectionPoint interface pointer
00587               variable that will receive the requested interface pointer.
00588
00589   Returns:  HRESULT
00590               Standard result code. NOERROR for success.
00591 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00592 STDMETHODIMP CODrawPage::CImpIConnectionPointContainer::FindConnectionPoint(
00593                REFIID riid,
00594                IConnectionPoint** ppConnPt)
00595 {
00596   HRESULT hr = E_NOINTERFACE;
00597   IConnectionPoint* pIConnPt;
00598
00599   // NULL the output variable.
00600   *ppConnPt = NULL;
00601
00602   pIConnPt = m_pCO->m_aConnectionPoints[CONNPOINT_DRAWPAGESINK];
00603   if (NULL != pIConnPt)
00604   {
00605     // This connectable CODrawPage object currently has only the DrawPage
00606     // Sink connection point. If the associated interface is requested,
00607     // use QI to get the Connection Point interface and perform the needed
00608     // AddRef.
00609     if (IID_IDrawPageSink == riid)
00610       hr = pIConnPt->QueryInterface(
00611                        IID_IConnectionPoint,
00612                        (PPVOID)ppConnPt);
00613   }
00614
00615   return hr;
00616 }
00617
00618
00619 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00620   Method:   CODrawPage::CImpIConnectionPointContainer::EnumConnectionPoints
00621
00622   Summary:  Return Enumerator for the connectable object's contained
00623             connection points.
00624
00625   Args:     IEnumConnectionPoints** ppIEnum
00626               Address of the caller's Enumerator interface pointer
00627               variable. An output variable that will receive a pointer to
00628               the connection point enumerator COM object.
00629
00630   Returns:  HRESULT
00631               Standard result code. NOERROR for success.
00632 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00633 STDMETHODIMP CODrawPage::CImpIConnectionPointContainer::EnumConnectionPoints(
00634                        IEnumConnectionPoints** ppIEnum)
00635 {
00636   HRESULT hr = NOERROR;
00637   IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
00638   COEnumConnectionPoints* pCOEnum;
00639   UINT i;
00640
00641   // Zero the output interface pointer.
00642   *ppIEnum = NULL;
00643
00644   // Make a copy on the stack of the array of connection point
00645   // interfaces. The copy is used below in the creation of the new
00646   // Enumerator object.
00647   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00648     aConnPts[i] = (IConnectionPoint*)m_pCO->m_aConnectionPoints[i];
00649
00650   // Create a Connection Point enumerator COM object for the connection
00651   // points offered by this CODrawPage object. Pass 'this' to be used to
00652   // hook the lifetime of the host object to the life time of this
00653   // enumerator object.
00654   pCOEnum = new COEnumConnectionPoints(this);
00655   if (NULL != pCOEnum)
00656   {
00657     // Use the array copy to Init the new Enumerator COM object.
00658     // Set the initial Enumerator index to 0.
00659     hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
00660     if (SUCCEEDED(hr))
00661     {
00662       // QueryInterface to return the requested interface pointer.
00663       // An AddRef will be conveniently done by the QI.
00664       if (SUCCEEDED(hr))
00665         hr = pCOEnum->QueryInterface(
00666                         IID_IEnumConnectionPoints,
00667                         (PPVOID)ppIEnum);
00668     }
00669   }
00670   else
00671     hr = E_OUTOFMEMORY;
00672
00673   return hr;
00674 }
00675
00676
00677 /*---------------------------------------------------------------------------
00678   CODrawPage's nested implementation of the COM standard IPersistStorage
00679   interface including Constructor, Destructor, QueryInterface, AddRef,
00680   Release, GetClassID, IsDirty, InitNew, Load, Save, SaveCompleted, and
00681   HandsOffStorage.
00682 ---------------------------------------------------------------------------*/
00683
00684 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00685   Method:   CODrawPage::CImpIPersistStorage::CImpIPersistStorage
00686
00687   Summary:  Constructor for the CImpIPersistStorage interface
00688             implementation.
00689
00690   Args:     CODrawPage* pCO,
00691               Back pointer to the parent outer object.
00692             IUnknown* pUnkOuter
00693               Pointer to the outer Unknown.  For delegation.
00694
00695   Modifies: m_pCO, m_pUnkOuter.
00696
00697   Returns:  void
00698 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00699 CODrawPage::CImpIPersistStorage::CImpIPersistStorage(
00700   CODrawPage* pCO,
00701   IUnknown* pUnkOuter)
00702 {
00703   // Init the interface's object pointer to point to the parent COM object.
00704   m_pCO = pCO;
00705
00706   // Init the CImpIPersistStorage interface's delegating IUnknown
00707   // pointer.  We use the main object pointer for IUnknown delegation here
00708   // if we are not being aggregated.  If we are being aggregated we use
00709   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00710   // pointer assignment requires no AddRef because the
00711   // CImpIPersistStorage lifetime is quaranteed by the lifetime
00712   // of the parent object in which CImpIPersistStorage is
00713   // nested.
00714   if (NULL == pUnkOuter)
00715     m_pUnkOuter = pCO;
00716   else
00717     m_pUnkOuter = pUnkOuter;
00718
00719   return;
00720 }
00721
00722
00723 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00724   Method:   CODrawPage::CImpIPersistStorage::~CImpIPersistStorage
00725
00726   Summary:  Destructor for the CImpIPersistStorage interface
00727             instantiation.
00728
00729   Args:     void
00730
00731   Returns:  void
00732 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00733 CODrawPage::CImpIPersistStorage::~CImpIPersistStorage(void)
00734 {
00735   // Release the current stream elements and the main storage.
00736   // This NULLs these interface pointers (via the release macro).
00737   RELEASE_INTERFACE(m_pIStream_Props);
00738   RELEASE_INTERFACE(m_pIStream_Data);
00739   RELEASE_INTERFACE(m_pIStorage);
00740
00741   return;
00742 }
00743
00744
00745 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00746   Method:   CODrawPage::CImpIPersistStorage::QueryInterface
00747
00748   Summary:  The QueryInterface IUnknown member of this IDrawPage interface
00749             implementation that delegates to m_pUnkOuter, whatever it is.
00750
00751   Args:     REFIID riid,
00752               [in] GUID of the Interface being requested.
00753             PPVOID ppv)
00754               [out] Address of the caller's pointer variable that will
00755               receive the requested interface pointer.
00756
00757   Returns:  HRESULT
00758               Standard result code. NOERROR for success.
00759               Returned by the delegated outer QueryInterface call.
00760 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00761 STDMETHODIMP CODrawPage::CImpIPersistStorage::QueryInterface(
00762                REFIID riid,
00763                PPVOID ppv)
00764 {
00765   // Delegate this call to the outer object's QueryInterface.
00766   return m_pUnkOuter->QueryInterface(riid, ppv);
00767 }
00768
00769
00770 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00771   Method:   CODrawPage::CImpIPersistStorage::AddRef
00772
00773   Summary:  The AddRef IUnknown member of this IDrawPage interface
00774             implementation that delegates to m_pUnkOuter, whatever it is.
00775
00776   Args:     void
00777
00778   Returns:  ULONG
00779               Returned by the delegated outer AddRef call.
00780 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00781 STDMETHODIMP_(ULONG) CODrawPage::CImpIPersistStorage::AddRef(void)
00782 {
00783   // Delegate this call to the outer object's AddRef.
00784   return m_pUnkOuter->AddRef();
00785 }
00786
00787
00788 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00789   Method:   CODrawPage::CImpIPersistStorage::Release
00790
00791   Summary:  The Release IUnknown member of this IDrawPage interface
00792             implementation that delegates to m_pUnkOuter, whatever it is.
00793
00794   Args:     void
00795
00796   Returns:  ULONG
00797               Returned by the delegated outer Release call.
00798 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00799 STDMETHODIMP_(ULONG) CODrawPage::CImpIPersistStorage::Release(void)
00800 {
00801   // Delegate this call to the outer object's Release.
00802   return m_pUnkOuter->Release();
00803 }
00804
00805
00806 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00807   Method:   CODrawPage::CImpIPersistStorage::GetClassID
00808
00809   Summary:  A method inherited from IPersist. Get the Class ID of this
00810             COM object.
00811
00812   Args:     CLSID* pClassID
00813               [out] Address of variable to hold Class ID.
00814
00815   Returns:  HRESULT
00816               Standard result code. NOERROR for success.
00817 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00818 STDMETHODIMP CODrawPage::CImpIPersistStorage::GetClassID(
00819                CLSID* pClassID)
00820 {
00821   HRESULT hr = E_POINTER;
00822
00823   if (NULL != pClassID)
00824   {
00825     // Use overloaded '=' operator to copy the Class ID to caller.
00826     *pClassID = m_pCO->m_ClassID;
00827     hr = NOERROR;
00828   }
00829
00830   return hr;
00831 }
00832
00833
00834 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00835   Method:   CODrawPage::CImpIPersistStorage::IsDirty
00836
00837   Summary:  Called to determine if changes were made to this COM object
00838             since it was last loaded or initialized.
00839
00840   Args:     none.
00841
00842   Returns:  HRESULT
00843               Standard result code. NOERROR for success.
00844 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00845 STDMETHODIMP CODrawPage::CImpIPersistStorage::IsDirty(
00846                void)
00847 {
00848   HRESULT hr;
00849
00850   hr = m_pCO->m_bDirty ? S_OK : S_FALSE;
00851
00852   return hr;
00853 }
00854
00855
00856 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00857   Method:   CODrawPage::CImpIPersistStorage::InitNew
00858
00859   Summary:  Called to tell the object that it has been newly created. The
00860             object has no existing persistent state already stored and
00861             must create it anew to initialize the object.
00862
00863             InitNew is called INSTEAD of Load when the new object instance
00864             must be initialized with brand new data rather than with
00865             persistent data previously saved. Creates and opens all
00866             storage and stream elements that it needs (including any
00867             elements that it would need in a low-memory save situation).
00868             Pre-allocates any stream space that it will need in a later
00869             save operation.
00870
00871   Args:     IStorage* pIStorage
00872               Interface of the substorage within which the DrawPage stores
00873               its persistent state. The object should hold a copy of the
00874               pStorage reference and any other references it would later
00875               need in a low-memory save operation.
00876
00877   Returns:  HRESULT
00878               Standard result code. NOERROR for success.
00879 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00880 STDMETHODIMP CODrawPage::CImpIPersistStorage::InitNew(
00881                IStorage* pIStorage)
00882 {
00883   HRESULT hr = E_UNEXPECTED;
00884   ULONG ulToWrite, ulWritten;
00885
00886   // There is no previous persistent data for this CODrawPage object.
00887   // Create and init new persistence data for an empty drawing page.
00888
00889   // Return E_UNEXPECTED error if not in the UNINIT state.
00890   if (PERS_UNINIT == m_pCO->m_StgState)
00891   {
00892     if (NULL != pIStorage)
00893     {
00894       // Create the Properties stream.
00895       hr = pIStorage->CreateStream(
00896              WSZ_DRAWPROPS,
00897              STGM_CREATE | STGM_DIRECT
00898                | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
00899              0,
00900              0,
00901              &m_pIStream_Props);
00902       if (SUCCEEDED(hr))
00903       {
00904         // Create the Ink Data stream.
00905         hr = pIStorage->CreateStream(
00906                 WSZ_DRAWDATA,
00907                 STGM_CREATE | STGM_DIRECT
00908                   | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
00909                 0,
00910                 0,
00911                 &m_pIStream_Data);
00912         if (SUCCEEDED(hr))
00913         {
00914           // Write the clipboard format and User Type Name info.
00915           hr = WriteFmtUserTypeStg(
00916                  pIStorage,
00917                  m_pCO->m_ClipFmt,
00918                  TEXT(SZ_CLIPUSERTYPE));
00919         }
00920       }
00921     }
00922     else
00923       hr = E_POINTER;
00924
00925     if (SUCCEEDED(hr))
00926     {
00927       // Preallocate stream space by writing the DRAWPROPS structure.
00928       m_pCO->m_DrawProps.lInkArraySize = m_pCO->m_lInkDataEnd+1;
00929       m_pCO->m_DrawProps.crWinColor = m_pCO->m_crWinColor;
00930       m_pCO->m_DrawProps.WinRect.right = m_pCO->m_WinRect.right;
00931       m_pCO->m_DrawProps.WinRect.bottom = m_pCO->m_WinRect.bottom;
00932       ulToWrite = sizeof(DRAWPROPS);
00933       hr = m_pIStream_Props->Write(
00934              &m_pCO->m_DrawProps,
00935              ulToWrite,
00936              &ulWritten);
00937       if (SUCCEEDED(hr) && ulToWrite != ulWritten)
00938         hr = STG_E_CANTSAVE;
00939       if (SUCCEEDED(hr))
00940       {
00941         // Preallocate stream space by writing the initial Ink Data array.
00942         ulToWrite = m_pCO->m_DrawProps.lInkArraySize * sizeof(INKDATA);
00943         hr = m_pIStream_Data->Write(
00944                m_pCO->m_paInkData,
00945                ulToWrite,
00946                &ulWritten);
00947         if (SUCCEEDED(hr) && ulToWrite != ulWritten)
00948           hr = STG_E_CANTSAVE;
00949         if (FAILED(hr))
00950         {
00951           // Release ink data stream if error writing.
00952           m_pIStream_Data->Release();
00953         }
00954       }
00955       else
00956       {
00957         // Release property stream if error writing.
00958         m_pIStream_Props->Release();
00959       }
00960
00961       if (SUCCEEDED(hr))
00962       {
00963         // Keep open storage pointer around for use in later incremental or
00964         // low-memory calls of Save. AddRef the interface pointer copy.
00965         m_pIStorage = pIStorage;
00966         m_pIStorage->AddRef();
00967
00968         // Switch the persistent storage state to the scribble state.
00969         m_pCO->m_StgState = PERS_SCRIBBLE;
00970       }
00971     }
00972   }
00973
00974   return hr;
00975 }
00976
00977
00978 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00979   Method:   CODrawPage::CImpIPersistStorage::Load
00980
00981   Summary:  Load the object's persistent data from the specified storage
00982             where the persistent data was previously saved in a prior
00983             object lifetime. During/after Load the object should hold any
00984             elements it later needs for scribbling or for low-memory
00985             saves. This includes the pStorage reference. Load is always
00986             called INSTEAD of InitNew when the object is initialized with
00987             its previously stored persistent data.
00988
00989   Args:     IStorage* pIStorage
00990               Interface of the substorage from which the DrawPage loads
00991               its persistent state. The object should hold on to this
00992               pIStorage (and all subordinate storage element pointers)
00993               for later use in incremental or low-memory calls to Save.
00994
00995   Returns:  HRESULT
00996               Standard result code. NOERROR for success.
00997 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00998 STDMETHODIMP CODrawPage::CImpIPersistStorage::Load(
00999                IStorage* pIStorage)
01000 {
01001   HRESULT hr = E_UNEXPECTED;
01002   ULONG ulToRead, ulReadIn;
01003   LONG lNewArraySize;
01004   INKDATA* paInkData;
01005   DRAWPROPS NewProps;
01006
01007   // Return E_UNEXPECTED error if not in the UNINIT state.
01008   if (PERS_UNINIT == m_pCO->m_StgState)
01009   {
01010     if (NULL != pIStorage)
01011     {
01012       // Open the existing DrawPage properties stream.
01013       hr = pIStorage->OpenStream(
01014              WSZ_DRAWPROPS,
01015              0,
01016              STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
01017              0,
01018              &m_pIStream_Props);
01019       if (SUCCEEDED(hr))
01020       {
01021         // Open the existing DrawPage ink data stream.
01022         hr = pIStorage->OpenStream(
01023                WSZ_DRAWDATA,
01024                0,
01025                STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
01026                0,
01027                &m_pIStream_Data);
01028         if (SUCCEEDED(hr))
01029         {
01030           // Read the DrawPage properties from the their stream.
01031           ulToRead = sizeof(DRAWPROPS);
01032           hr = m_pIStream_Props->Read(&NewProps, ulToRead, &ulReadIn);
01033           if (SUCCEEDED(hr) && ulToRead != ulReadIn)
01034             hr = STG_E_READFAULT;
01035           if (SUCCEEDED(hr))
01036           {
01037             // Read the Ink Data of the drawing from its stream.
01038             // Deal with the different versions of ink data format.
01039             switch (NewProps.lInkDataVersion)
01040             {
01041               case INKDATA_VERSION20:
01042                 // Allocate an ink data array big enough--add some extra too.
01043                 lNewArraySize = NewProps.lInkArraySize + INKDATA_ALLOC;
01044                 paInkData = new INKDATA[(LONG) lNewArraySize];
01045                 if (NULL != paInkData)
01046                 {
01047                   // Delete the entire old ink data array.
01048                   delete [] m_pCO->m_paInkData;
01049
01050                   // Assign the new array.
01051                   m_pCO->m_paInkData = paInkData;
01052                   m_pCO->m_lInkDataMax = lNewArraySize;
01053
01054                   // Now read the complete array of Ink Data.
01055                   ulToRead = NewProps.lInkArraySize * sizeof(INKDATA);
01056                   hr = m_pIStream_Data->Read(
01057                          m_pCO->m_paInkData,
01058                          ulToRead,
01059                          &ulReadIn);
01060                   if (SUCCEEDED(hr) && ulToRead != ulReadIn)
01061                     hr = STG_E_READFAULT;
01062                   if (SUCCEEDED(hr))
01063                   {
01064                     // Rig CODrawPage to use the DRAWPROPS info.
01065                     m_pCO->m_lInkDataEnd = NewProps.lInkArraySize-1;
01066                     m_pCO->m_crWinColor = NewProps.crWinColor;
01067                     m_pCO->m_WinRect.right = NewProps.WinRect.right;
01068                     m_pCO->m_WinRect.bottom = NewProps.WinRect.bottom;
01069
01070                     // Copy the new properties into current properties.
01071                     memcpy(
01072                       &m_pCO->m_DrawProps,
01073                       &NewProps,
01074                       sizeof(DRAWPROPS));
01075
01076                     // We are loaded and clean (ie, CODrawPage data
01077                     // matches file data). Clear dirty flag.
01078                     m_pCO->m_bDirty = FALSE;
01079                   }
01080                   else
01081                   {
01082                     // Release data stream if error reading.
01083                     m_pIStream_Data->Release();
01084                   }
01085                 }
01086                 else
01087                   hr = E_OUTOFMEMORY;
01088                 break;
01089               default:
01090                 hr = E_FAIL;  // Bad version.
01091                 break;
01092             }
01093           }
01094           else
01095           {
01096             // Release property stream if error reading.
01097             m_pIStream_Props->Release();
01098           }
01099         }
01100       }
01101
01102       if (SUCCEEDED(hr))
01103       {
01104         // Keep open storage pointer around for use in later incremental or
01105         // low-memory calls of Save. AddRef the interface pointer copy.
01106         m_pIStorage = pIStorage;
01107         m_pIStorage->AddRef();
01108
01109         // Switch the persistent storage state to the scribble state.
01110         m_pCO->m_StgState = PERS_SCRIBBLE;
01111       }
01112     }
01113     else
01114       hr = E_POINTER;
01115   }
01116
01117   // Notify all other connected clients that DrawPage is now loaded.
01118   if (SUCCEEDED(hr))
01119     m_pCO->NotifySinks(DRAWPAGE_EVENT_LOADED, 0, 0, 0, 0);
01120
01121   return hr;
01122 }
01123
01124
01125 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01126   Method:   CODrawPage::CImpIPersistStorage::Save
01127
01128   Summary:  Save the object's persistent state data to the currently open
01129             storage or to a newly specified storage depending on
01130             bSameAsLoad. Regardless of bSameAsLoad, and during/after Save,
01131             the object continues to hold its present pointers to opened
01132             elements. But the object cannot scribble on its data until the
01133             SaveCompleted method is called. Save clears the object's
01134             m_bDirty flag.
01135
01136             Save must not fail if an out-of-memory condition is
01137             encountered. This relies on either InitNew or Load to open and
01138             hold pointers to any elements later needed by Save.
01139
01140   Args:     IStorage* pIStorage
01141               Interface of the substorage into which the DrawPage saves
01142               its persistent state. Always non-NULL.
01143             BOOL bSameAsLoad
01144               TRUE  =>Save to opened storage (ie, the same one previously
01145                 passed to Load or InitNew). Saves only items that need
01146                 saving in the current storage (which could be all)
01147                 without using any extra memory and without opening or
01148                 creating any storages or streams.
01149               FALSE =>Save to the specified storage as a new storage.
01150                 A complete write of all persistent data is done to the
01151                 newly specified storage. The object's currently open
01152                 storage remains open and unaffected.
01153
01154   Returns:  HRESULT
01155               Standard result code. NOERROR for success.
01156 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01157 STDMETHODIMP CODrawPage::CImpIPersistStorage::Save(
01158                IStorage* pIStorage,
01159                BOOL bSameAsLoad)
01160 {
01161   HRESULT hr = E_UNEXPECTED;
01162   IStream* pIStream_Props;
01163   IStream* pIStream_Data;
01164
01165   // Return E_UNEXPECTED error if not in the Scribble state.
01166   if (PERS_SCRIBBLE == m_pCO->m_StgState)
01167   {
01168     if (bSameAsLoad)
01169     {
01170       LARGE_INTEGER li;
01171
01172       // If SameAsLoad use copies of the existing open stream pointers.
01173       pIStream_Props = m_pIStream_Props;
01174       pIStream_Data = m_pIStream_Data;
01175
01176       // AddRef these copies; they are released below.
01177       pIStream_Props->AddRef();
01178       pIStream_Data->AddRef();
01179
01180       // We're going to do a fresh save to existing open elements.
01181       // So recue the stream seek pointers to their start.
01182       LISet32(li, 0);
01183       pIStream_Props->Seek(li, STREAM_SEEK_SET, NULL);
01184       pIStream_Data->Seek(li, STREAM_SEEK_SET, NULL);
01185
01186       hr = NOERROR;
01187     }
01188     else
01189     {
01190       // If not SameAsLoad (save to a different storage) then return the
01191       // E_POINTER error if a NULL pIStroage was passed.
01192       if (NULL != pIStorage)
01193       {
01194         // If we are saving new persistent image of the object to a
01195         // different storage then create all the necessary persistent
01196         // storage elements.
01197
01198         // Create the Properties stream.
01199         hr = pIStorage->CreateStream(
01200                WSZ_DRAWPROPS,
01201                STGM_CREATE | STGM_DIRECT
01202                  | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
01203                0,
01204                0,
01205                &pIStream_Props);
01206         if (SUCCEEDED(hr))
01207         {
01208           // Create the Ink Data stream.
01209           hr = pIStorage->CreateStream(
01210                   WSZ_DRAWDATA,
01211                   STGM_CREATE | STGM_DIRECT
01212                     | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
01213                   0,
01214                   0,
01215                   &pIStream_Data);
01216           if (SUCCEEDED(hr))
01217           {
01218             // Write the clipboard format and User Type Name info.
01219             hr = WriteFmtUserTypeStg(
01220                    pIStorage,
01221                    m_pCO->m_ClipFmt,
01222                    TEXT(SZ_CLIPUSERTYPE));
01223           }
01224         }
01225       }
01226       else
01227         hr = E_POINTER;
01228     }
01229
01230     // Now perform the saves of the persistent data elements.
01231     if (SUCCEEDED(hr))
01232     {
01233       ULONG ulToWrite, ulWritten;
01234
01235       // Save the DrawPage properties in a dedicated stream.
01236       m_pCO->m_DrawProps.lInkArraySize = m_pCO->m_lInkDataEnd+1;
01237       m_pCO->m_DrawProps.crWinColor = m_pCO->m_crWinColor;
01238       m_pCO->m_DrawProps.WinRect.right = m_pCO->m_WinRect.right;
01239       m_pCO->m_DrawProps.WinRect.bottom = m_pCO->m_WinRect.bottom;
01240       ulToWrite = sizeof(DRAWPROPS);
01241       hr = pIStream_Props->Write(&m_pCO->m_DrawProps, ulToWrite, &ulWritten);
01242       if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01243         hr = STG_E_CANTSAVE;
01244       if (SUCCEEDED(hr))
01245       {
01246         // Save the DrawPage ink data in a dedicated stream.
01247         ulToWrite = m_pCO->m_DrawProps.lInkArraySize * sizeof(INKDATA);
01248         hr = pIStream_Data->Write(m_pCO->m_paInkData, ulToWrite, &ulWritten);
01249         if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01250           hr = STG_E_CANTSAVE;
01251       }
01252
01253       // Release any temporary streams used.
01254       pIStream_Props->Release();
01255       pIStream_Data->Release();
01256
01257       if (SUCCEEDED(hr))
01258       {
01259         // Since the persistent save is now done for this object the
01260         // file matches the object. So set object's dirty flag to FALSE.
01261         if (bSameAsLoad)
01262           m_pCO->m_bDirty = FALSE;
01263
01264         // Switch the persistent storage state to the NoScribble state.
01265         // After this Save this object cannot scribble to its persistent
01266         // storage again until the client grants this freedom by calling
01267         // SaveCompleted which switches this object to the Scribble state.
01268         m_pCO->m_StgState = PERS_NOSCRIBBLE;
01269       }
01270     }
01271   }
01272
01273   // Notify all other connected clients that DrawPage is now saved.
01274   if (SUCCEEDED(hr))
01275     m_pCO->NotifySinks(DRAWPAGE_EVENT_SAVED, 0, 0, 0, 0);
01276
01277   return hr;
01278 }
01279
01280
01281 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01282   Method:   CODrawPage::CImpIPersistStorage::SaveCompleted
01283
01284   Summary:  Called by client to inform this COM object that the client has
01285             completed its overall save operations. Restores the object to
01286             a state where it is free to write  (ie, scribble) to its
01287             persistent data elements.
01288
01289   Args:     IStorage* pIStorage
01290               Interface of the storage for which the object must release
01291               its held interface pointers and reopen its persistent data
01292               elements within that specified storage. If NULL then the
01293               release/reopen is not needed and the object can once again
01294               scribble to its expected elements under the currently open
01295               storage.
01296
01297   Returns:  HRESULT
01298               Standard result code. NOERROR for success.
01299 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01300 STDMETHODIMP CODrawPage::CImpIPersistStorage::SaveCompleted(
01301                IStorage* pIStorage)
01302 {
01303   HRESULT hr = E_UNEXPECTED;
01304   IStream* pIStream_Props;
01305   IStream* pIStream_Data;
01306   BOOL bOk;
01307   PERSTGSTATE StgState = m_pCO->m_StgState;
01308
01309   // Return E_UNEXPECTED error if storage is NOT in either the
01310   // No-scribble or Hands-off state.
01311   bOk = (StgState == PERS_NOSCRIBBLE || StgState == PERS_HANDSOFF);
01312   if (bOk)
01313   {
01314     // Return E_UNEXPECTED if in Hands-off state but pIStorage is NULL.
01315     if (StgState == PERS_HANDSOFF && NULL == pIStorage)
01316       bOk = FALSE;
01317     else
01318       hr = NOERROR;
01319   }
01320
01321   if (bOk)
01322   {
01323     if (NULL != pIStorage)
01324     {
01325       // If specified storage is non-NULL, release all storage elements
01326       // and use the specified pIStorage to re-open those elements.
01327       // If pIStorage == NULL then we need do nothing since we already
01328       // have all the pointers to storage elements needed for Save.
01329
01330       // First ensure we can open the property and data streams
01331       hr = pIStorage->OpenStream(
01332              WSZ_DRAWPROPS,
01333              0,
01334              STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
01335              0,
01336              &pIStream_Props);
01337       if (SUCCEEDED(hr))
01338       {
01339         hr = pIStorage->OpenStream(
01340                WSZ_DRAWDATA,
01341                0,
01342                STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
01343                0,
01344                &pIStream_Data);
01345         if (SUCCEEDED(hr))
01346         {
01347           // Release the current stream elements and the main storage.
01348           RELEASE_INTERFACE(m_pIStream_Props);
01349           RELEASE_INTERFACE(m_pIStream_Data);
01350           RELEASE_INTERFACE(m_pIStorage);
01351
01352           // Reassign the storage and stream interface pointers.
01353           m_pIStorage = pIStorage;
01354           m_pIStorage->AddRef();
01355           m_pIStream_Props = pIStream_Props;
01356           m_pIStream_Data = pIStream_Data;
01357         }
01358       }
01359     }
01360
01361     if (SUCCEEDED(hr))
01362     {
01363       // Switch the persistent storage state back to the scribble state.
01364       m_pCO->m_StgState = PERS_SCRIBBLE;
01365
01366       // Since save is completed, no save is needed. So set object's
01367       // dirty flag to FALSE.
01368       m_pCO->m_bDirty = FALSE;
01369     }
01370   }
01371
01372   return hr;
01373 }
01374
01375
01376 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01377   Method:   CODrawPage::CImpIPersistStorage::HandsOffStorage
01378
01379   Summary:  Directs object to release the pointers it holds to all
01380             persistent data elements and, until further notice, NOT to
01381             write to its persistent data elements. A subsequent call to
01382             SaveCompleted restores the object's freedom to write to its
01383             persistent data elements.
01384
01385   Args:     void
01386
01387   Returns:  HRESULT
01388               Standard result code. NOERROR for success.
01389 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01390 STDMETHODIMP CODrawPage::CImpIPersistStorage::HandsOffStorage(
01391                void)
01392 {
01393   HRESULT hr = E_UNEXPECTED;
01394   PERSTGSTATE StgState = m_pCO->m_StgState;
01395
01396   // Return E_UNEXPECTED error if NOT in scribble or no-scribble state.
01397   if (StgState == PERS_NOSCRIBBLE || StgState == PERS_SCRIBBLE)
01398   {
01399     // Release the current stream elements and the main storage.
01400     // This NULLs these interface pointers (via the release macro).
01401     RELEASE_INTERFACE(m_pIStream_Props);
01402     RELEASE_INTERFACE(m_pIStream_Data);
01403     RELEASE_INTERFACE(m_pIStorage);
01404
01405     // Switch the persistent storage state to the Hands-off state.
01406     m_pCO->m_StgState = PERS_HANDSOFF;
01407     hr = NOERROR;
01408   }
01409
01410   return hr;
01411 }
01412
01413
01414 /*---------------------------------------------------------------------------
01415   CODrawPage's nested implementation of the custom IDrawPage interface
01416   including Constructor, Destructor, QueryInterface, AddRef, Release,
01417   InkStart, InkDraw, InkStop, Clear, Resize, and Redraw.
01418 ---------------------------------------------------------------------------*/
01419
01420 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01421   Method:   CODrawPage::CImpIDrawPage::CImpIDrawPage
01422
01423   Summary:  Constructor for the CImpIDrawPage interface instantiation.
01424
01425   Args:     CODrawPage* pCO,
01426               Back pointer to the parent outer COM object.
01427             IUnknown* pUnkOuter
01428               Pointer to the outer Unknown.  For delegation.
01429
01430   Modifies: m_pCO, m_pUnkOuter.
01431
01432   Returns:  void
01433 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01434 CODrawPage::CImpIDrawPage::CImpIDrawPage(
01435   CODrawPage* pCO,
01436   IUnknown* pUnkOuter)
01437 {
01438   // Init the interface's COM object pointer to point to the parent object.
01439   m_pCO = pCO;
01440
01441   // Init the CImpIDrawPage interface's delegating IUnknown pointer.  We
01442   // use the main Object pointer for IUnknown delegation here if we are
01443   // not being aggregated.  If we are being aggregated we use the supplied
01444   // pUnkOuter for IUnknown delegation.  In either case the pointer
01445   // assignment requires no AddRef because the CImpIDrawPage lifetime is
01446   // quaranteed by the lifetime of the parent object in which
01447   // CImpIDrawPage is nested.
01448   if (NULL == pUnkOuter)
01449     m_pUnkOuter = pCO;
01450   else
01451     m_pUnkOuter = pUnkOuter;
01452
01453   return;
01454 }
01455
01456
01457 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01458   Method:   CODrawPage::CImpIDrawPage::~CImpIDrawPage
01459
01460   Summary:  Destructor for the CImpIDrawPage interface instantiation.
01461
01462   Args:     void
01463
01464   Returns:  void
01465 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01466 CODrawPage::CImpIDrawPage::~CImpIDrawPage(void)
01467 {
01468   INKDATA* paInkData;
01469
01470   // NULL the pointer first and then delete the entire ink data array.
01471   paInkData = m_pCO->m_paInkData;
01472   m_pCO->m_paInkData = NULL;
01473   if (NULL != paInkData)
01474     delete [] paInkData;
01475
01476   return;
01477 }
01478
01479
01480 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01481   Method:   CODrawPage::CImpIDrawPage::QueryInterface
01482
01483   Summary:  The QueryInterface IUnknown member of this IDrawPage interface
01484             implementation that delegates to m_pUnkOuter, whatever it is.
01485
01486   Args:     REFIID riid,
01487               [in] GUID of the Interface being requested.
01488             PPVOID ppv)
01489               [out] Address of the caller's pointer variable that will
01490               receive the requested interface pointer.
01491
01492   Returns:  HRESULT
01493               Standard result code. NOERROR for success.
01494               Returned by the delegated outer QueryInterface call.
01495 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01496 STDMETHODIMP CODrawPage::CImpIDrawPage::QueryInterface(
01497                REFIID riid,
01498                PPVOID ppv)
01499 {
01500   // Delegate this call to the outer object's QueryInterface.
01501   return m_pUnkOuter->QueryInterface(riid, ppv);
01502 }
01503
01504
01505 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01506   Method:   CODrawPage::CImpIDrawPage::AddRef
01507
01508   Summary:  The AddRef IUnknown member of this IDrawPage interface
01509             implementation that delegates to m_pUnkOuter, whatever it is.
01510
01511   Args:     void
01512
01513   Returns:  ULONG
01514               Returned by the delegated outer AddRef call.
01515 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01516 STDMETHODIMP_(ULONG) CODrawPage::CImpIDrawPage::AddRef(void)
01517 {
01518   // Delegate this call to the outer object's AddRef.
01519   return m_pUnkOuter->AddRef();
01520 }
01521
01522
01523 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01524   Method:   CODrawPage::CImpIDrawPage::Release
01525
01526   Summary:  The Release IUnknown member of this IDrawPage interface
01527             implementation that delegates to m_pUnkOuter, whatever it is.
01528
01529   Args:     void
01530
01531   Returns:  ULONG
01532               Returned by the delegated outer Release call.
01533 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01534 STDMETHODIMP_(ULONG) CODrawPage::CImpIDrawPage::Release(void)
01535 {
01536   // Delegate this call to the outer object's Release.
01537   return m_pUnkOuter->Release();
01538 }
01539
01540
01541 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01542   Method:   CODrawPage::CImpIDrawPage::NextSlot
01543
01544   Summary:  An internal private utility member method to increment to the
01545             next slot in the dynamic Ink Data array. NextSlot will expand
01546             the dynamic array for more entries if needed.
01547
01548   Args:     void
01549
01550   Modifies: m_lInkDataEnd, m_lInkDataMax, m_paInkData.
01551
01552   Returns:  HRESULT
01553               Standard result code. NOERROR for success.
01554 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01555 HRESULT CODrawPage::CImpIDrawPage::NextSlot(
01556                                void)
01557 {
01558   HRESULT hr = NOERROR;
01559   LONG lInkDataEnd = m_pCO->m_lInkDataEnd + 1;
01560   INKDATA* paInkData;
01561
01562   if (lInkDataEnd >= m_pCO->m_lInkDataMax)
01563   {
01564     // No more room in Ink Data array. Allocate new space.
01565     paInkData = new INKDATA[(LONG) (m_pCO->m_lInkDataMax + INKDATA_ALLOC)];
01566     if (NULL != paInkData)
01567     {
01568       // Copy the content of the old full array to the new larger array.
01569       memcpy(paInkData, m_pCO->m_paInkData, lInkDataEnd * sizeof(INKDATA));
01570
01571       // Zero (& mark as empty) the expanded portion of the new array.
01572       memset(&paInkData[lInkDataEnd], 0, INKDATA_ALLOC * sizeof(INKDATA));
01573
01574       // New larger array is ready--delete the old array.
01575       delete [] m_pCO->m_paInkData;
01576
01577       // Rig the to use the new larger array.
01578       m_pCO->m_paInkData = paInkData;
01579
01580       // Calculate the new max index.
01581       m_pCO->m_lInkDataMax += INKDATA_ALLOC;
01582     }
01583     else
01584       hr = E_OUTOFMEMORY;
01585   }
01586
01587   if (SUCCEEDED(hr))
01588   {
01589     m_pCO->m_lInkDataEnd = lInkDataEnd;
01590     // NextSlot always preceeds the addition of new drawing data.
01591     // So use this convenient common place to set the dirty flag.
01592     m_pCO->m_bDirty = TRUE;
01593   }
01594
01595   return hr;
01596 }
01597
01598
01599 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01600   Method:   CODrawPage::CImpIDrawPage::InkStart
01601
01602   Summary:  The InkStart member method of the IDrawPage interface
01603             implementation. Called by outside clients of a CODrawPage
01604             object to start an ink drawing sequence (ie, a stroke).
01605
01606   Args:     SHORT nX,
01607               The X coordinate of the ink point.
01608             SHORT nY,
01609               The Y coordinate of the ink point.
01610             SHORT nInkWidth,
01611               The width of the ink in pixels.
01612             COLORREF crInkColor);
01613               The new ink color--an RGB COLORREF color.
01614
01615   Returns:  HRESULT
01616               Standard result code. NOERROR for success.
01617 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01618 STDMETHODIMP CODrawPage::CImpIDrawPage::InkStart(
01619                SHORT nX,
01620                SHORT nY,
01621                SHORT nInkWidth,
01622                COLORREF crInkColor)
01623 {
01624   HRESULT hr = E_FAIL;
01625
01626   hr = NextSlot();
01627   if (SUCCEEDED(hr))
01628   {
01629     // Add the new item to the Ink Data Array.
01630     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nType = INKTYPE_START;
01631     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nX = nX;
01632     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nY = nY;
01633     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nWidth = nInkWidth;
01634     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].crColor = crInkColor;
01635     m_pCO->m_nInkWidth = nInkWidth;
01636     m_pCO->m_crInkColor = crInkColor;
01637   }
01638
01639   return hr;
01640 }
01641
01642
01643 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01644   Method:   CODrawPage::CImpIDrawPage::InkDraw
01645
01646   Summary:  The InkDraw member method of the IDrawPage interface
01647             implementation. Called by outside clients of a CODrawPage
01648             object to "draw" ink data into an inking sequence. Adds
01649             ink points to the current stroke.
01650
01651   Args:     SHORT nX,
01652               The X coordinate of the ink point.
01653             SHORT nY,
01654               The Y coordinate of the ink point.
01655
01656   Returns:  HRESULT
01657               Standard result code. NOERROR for success.
01658 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01659 STDMETHODIMP CODrawPage::CImpIDrawPage::InkDraw(
01660                SHORT nX,
01661                SHORT nY)
01662 {
01663   HRESULT hr = E_FAIL;
01664
01665   hr = NextSlot();
01666   if (SUCCEEDED(hr))
01667   {
01668     // Add the new item to the Ink Data Array.
01669     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nType = INKTYPE_DRAW;
01670     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nX = nX;
01671     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nY = nY;
01672     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nWidth = m_pCO->m_nInkWidth;
01673     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].crColor = m_pCO->m_crInkColor;
01674   }
01675
01676   return hr;
01677 }
01678
01679
01680 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01681   Method:   CODrawPage::CImpIDrawPage::InkStop
01682
01683   Summary:  The InkStop member method of the IDrawPage interface
01684             implementation. Called by outside clients of a CODrawPage
01685             object to stop the current ink drawing sequence. Ends the
01686             current stroke.
01687
01688   Args:     SHORT nX,
01689               The X coordinate of the ink point.
01690             SHORT nY,
01691               The Y coordinate of the ink point.
01692
01693   Returns:  HRESULT
01694               Standard result code. NOERROR for success.
01695 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01696 STDMETHODIMP CODrawPage::CImpIDrawPage::InkStop(
01697                SHORT nX,
01698                SHORT nY)
01699 {
01700   HRESULT hr = E_FAIL;
01701
01702   hr = NextSlot();
01703   if (SUCCEEDED(hr))
01704   {
01705     // Add the new item to the Ink Data Array.
01706     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nType = INKTYPE_STOP;
01707     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nX = nX;
01708     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nY = nY;
01709     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].nWidth = m_pCO->m_nInkWidth;
01710     m_pCO->m_paInkData[m_pCO->m_lInkDataEnd].crColor = m_pCO->m_crInkColor;
01711   }
01712
01713   return hr;
01714 }
01715
01716
01717 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01718   Method:   CODrawPage::CImpIDrawPage::Clear
01719
01720   Summary:  The Clear member method of the IDrawPage interface
01721             implementation. Called by outside clients of a CODrawPage
01722             object to clear the drawn ink content of the DrawPage object.
01723             Notifies all connected clients of the event.
01724
01725   Args:     BOOL bSaveNeeded
01726               Specifies whether the cleared draw page should later be
01727               saved to file. TRUE=>later save needed; FALSE=>later save
01728               not needed.
01729
01730   Returns:  HRESULT
01731               Standard result code. NOERROR for success.
01732 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01733 STDMETHODIMP CODrawPage::CImpIDrawPage::Clear(
01734                BOOL bSaveNeeded)
01735 {
01736   HRESULT hr = NOERROR;
01737   LONG i;
01738
01739   if (m_pCO->m_lInkDataEnd > 0 && NULL != m_pCO->m_paInkData)
01740   {
01741     // Loop thru the current Ink Data array and mark each
01742     // item as erased.
01743     for (i=0; i<m_pCO->m_lInkDataMax; i++)
01744       m_pCO->m_paInkData[i].nType = INKTYPE_NONE;
01745
01746     // Reset the Ink Data End index to 0.
01747     m_pCO->m_lInkDataEnd = 0;
01748   }
01749
01750   // Specify if a later save to file is needed.
01751   m_pCO->m_bDirty = bSaveNeeded;
01752
01753   // Notify all other connected clients of the clear.
01754   if (SUCCEEDED(hr))
01755     m_pCO->NotifySinks(DRAWPAGE_EVENT_CLEARED, 0, 0, 0, 0);
01756
01757   return hr;
01758 }
01759
01760
01761 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01762   Method:   CODrawPage::CImpIDrawPage::Resize
01763
01764   Summary:  The Resize member method of the IDrawPage interface
01765             implementation. Called by outside clients of a CODrawPage
01766             object to resize the drawing rectangle of the DrawPage object.
01767             Notifies all connected clients of the event and passes them
01768             the new rectangle size.
01769
01770   Args:     SHORT nWidth,
01771               The new rectangle width in pixels.
01772             SHORT nHeight
01773               The new rectangle height in pixels.
01774
01775   Returns:  HRESULT
01776               Standard result code. NOERROR for success.
01777 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01778 STDMETHODIMP CODrawPage::CImpIDrawPage::Resize(
01779                SHORT nWidth,
01780                SHORT nHeight)
01781 {
01782   HRESULT hr = NOERROR;
01783
01784   if (m_pCO->m_WinRect.right != nWidth
01785       || m_pCO->m_WinRect.bottom != nHeight)
01786   {
01787     m_pCO->m_WinRect.top = 0;
01788     m_pCO->m_WinRect.left = 0;
01789     m_pCO->m_WinRect.right = nWidth;
01790     m_pCO->m_WinRect.bottom = nHeight;
01791
01792     // For future evolution.
01793     // m_pCO->m_bDirty = TRUE;
01794   }
01795
01796   // Notify all other connected clients of the Resize.
01797   m_pCO->NotifySinks(
01798            DRAWPAGE_EVENT_RESIZED,
01799            nWidth,
01800            nHeight,
01801            0,
01802            0);
01803
01804   return hr;
01805 }
01806
01807
01808 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01809   Method:   CODrawPage::CImpIDrawPage::Redraw
01810
01811   Summary:  The Redraw member method of the IDrawPage interface
01812             implementation. Called by outside clients of a CODrawPage
01813             object to resend all of the DrawPage object's current ink data
01814             to all connected clients for a redraw of the content in each.
01815
01816   Args:     void
01817
01818   Returns:  HRESULT
01819               Standard result code. NOERROR for success.
01820 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01821 STDMETHODIMP CODrawPage::CImpIDrawPage::Redraw(
01822                void)
01823 {
01824   HRESULT hr = E_FAIL;
01825   IConnectionPoint* pIConnectionPoint;
01826   IEnumConnections* pIEnum;
01827   CONNECTDATA ConnData;
01828   SHORT nInkType;
01829   LONG i;
01830
01831   // Broadcast InkData notifications to all Sinks connected to
01832   // each connection point.
01833
01834   // Here is the section for the DrawPageSink connection point--currently
01835   // this is the only connection point offered by CODrawPage objects.
01836   pIConnectionPoint = m_pCO->m_aConnectionPoints[CONNPOINT_DRAWPAGESINK];
01837   if (NULL != pIConnectionPoint)
01838   {
01839     pIConnectionPoint->AddRef();
01840     hr = pIConnectionPoint->EnumConnections(&pIEnum);
01841     if (SUCCEEDED(hr))
01842     {
01843       // Loop thru the connection point's connections and if the
01844       // listening connection supports IDrawPageSink (ie, DrawPageSink
01845       // events) then send all the current DrawPage's Ink Data to it.
01846       while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
01847       {
01848         IDrawPageSink* pIDrawPageSink = NULL;
01849
01850         hr = ConnData.pUnk->QueryInterface(
01851                               IID_IDrawPageSink,
01852                               (PPVOID)&pIDrawPageSink);
01853         if (SUCCEEDED(hr))
01854         {
01855           // Loop thru all the Ink Data and send it to this connected
01856           // client sink.
01857           for (i=0; i<m_pCO->m_lInkDataEnd+1; i++)
01858           {
01859             nInkType = m_pCO->m_paInkData[i].nType;
01860             switch (nInkType)
01861             {
01862               case INKTYPE_DRAW:
01863                 pIDrawPageSink->InkDraw(
01864                                   m_pCO->m_paInkData[i].nX,
01865                                   m_pCO->m_paInkData[i].nY);
01866                 break;
01867               case INKTYPE_START:
01868                 pIDrawPageSink->InkStart(
01869                                   m_pCO->m_paInkData[i].nX,
01870                                   m_pCO->m_paInkData[i].nY,
01871                                   m_pCO->m_paInkData[i].nWidth,
01872                                   m_pCO->m_paInkData[i].crColor);
01873                 break;
01874               case INKTYPE_STOP:
01875                 pIDrawPageSink->InkStop(
01876                                   m_pCO->m_paInkData[i].nX,
01877                                   m_pCO->m_paInkData[i].nY);
01878                 break;
01879               default:
01880                 break;
01881             }
01882           }
01883           pIDrawPageSink->Release();
01884         }
01885         ConnData.pUnk->Release();
01886       }
01887       pIEnum->Release();
01888     }
01889     pIConnectionPoint->Release();
01890   }
01891
01892   return hr;
01893 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/mqf_draw/logindlg.cpp Source File

  • NetDS
  • MessageQueuing
  • mqf_draw

logindlg.cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // logindlg.cpp : implementation file
00014 //
00015
00016
00017 #include "stdafx.h"
00018 #include "mqfdraw.h"
00019 #include "logindlg.h"
00020
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026
00027
00028 #define MAX_VAR 20
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 // CLoginDlg dialog box
00032
00033
00034 CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
00035   : CDialog(CLoginDlg::IDD, pParent)
00036 {
00037   //{{AFX_DATA_INIT(CLoginDlg)
00038   m_strLogin = _T("");
00039   m_fDsEnabledLocaly = IsDsEnabledLocaly();
00040
00041   //}}AFX_DATA_INIT
00042 }
00043
00044
00045 void CLoginDlg::DoDataExchange(CDataExchange* pDX)
00046 {
00047   CDialog::DoDataExchange(pDX);
00048   //{{AFX_DATA_MAP(CLoginDlg)
00049   DDX_Text(pDX, IDC_EDIT_LOGIN, m_strLogin);
00050   //}}AFX_DATA_MAP
00051 }
00052
00053
00054 BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
00055   //{{AFX_MSG_MAP(CLoginDlg)
00056     // NOTE: The ClassWizard will add message map macros here.
00057   //}}AFX_MSG_MAP
00058 END_MESSAGE_MAP()
00059
00060 /////////////////////////////////////////////////////////////////////////////
00061
00062
00063 BOOL CLoginDlg::IsDsEnabledLocaly()
00064 /*++
00065
00066 Routine Description:
00067
00068       The routine checks whether the local computer is operating in domain (DS-enabled) mode
00069       or in workgroup (DS-disabled) mode.
00070
00071 Arguments:
00072
00073       None
00074
00075 Return Value:
00076
00077       TRUE     -  domain (DS-enabled) mode.
00078       FALSE    -  workgroup (DS-disabled) mode.
00079
00080 --*/
00081
00082 {
00083
00084
00085     MQPRIVATEPROPS PrivateProps;
00086     QMPROPID       aPropId[MAX_VAR];
00087     MQPROPVARIANT  aPropVar[MAX_VAR];
00088     DWORD          cProp;
00089     HRESULT        hr;
00090     //
00091     // Specify the PROPID_PC_DS_ENABLED property, which indicates whether
00092   // the computer is enabled to access the directory service.
00093     //
00094     cProp = 0;
00095
00096     aPropId[cProp] = PROPID_PC_DS_ENABLED;
00097     aPropVar[cProp].vt = VT_NULL;
00098     ++cProp;
00099     //
00100     // Create a PRIVATEPROPS structure.
00101     //
00102     PrivateProps.cProp = cProp;
00103   PrivateProps.aPropID = aPropId;
00104   PrivateProps.aPropVar = aPropVar;
00105     PrivateProps.aStatus = NULL;
00106
00107     //
00108     // Retrieve the information.
00109     //
00110
00111
00112     //
00113     // This code is used to detect a DS connection.
00114     // This code is designed to allow compilation both on
00115     // NT 4.0 and on Windows 2000 adn later.
00116     //
00117     HINSTANCE hMqrtLibrary = GetModuleHandle(TEXT("mqrt.dll"));
00118   if(hMqrtLibrary == NULL)
00119   {
00120     AfxMessageBox("An incomplete installation of MSMQ was detected. Exiting...");
00121     exit(1);
00122   }
00123
00124     typedef HRESULT (APIENTRY *MQGetPrivateComputerInformation_ROUTINE)(LPCWSTR , MQPRIVATEPROPS*);
00125     MQGetPrivateComputerInformation_ROUTINE pfMQGetPrivateComputerInformation =
00126           (MQGetPrivateComputerInformation_ROUTINE)GetProcAddress(hMqrtLibrary,
00127                            "MQGetPrivateComputerInformation");
00128     if(pfMQGetPrivateComputerInformation == NULL)
00129     {
00130         //
00131         // There is no entry point in the DLL matching this routine.
00132         // It must be an old version of mqrt.dll (MSMQ 1.0).
00133         // It will be OK to handle this case as a case of domain (DS-enabled) mode.
00134         //
00135         return TRUE;
00136     }
00137
00138   hr = pfMQGetPrivateComputerInformation(
00139              NULL,
00140            &PrivateProps);
00141   if(FAILED(hr))
00142   {
00143         //
00144         // We were not able to determine whether the local computer is enabled to access the DS.
00145         // Notify the user and assume the worst case, i.e., that access to the DS is disasbled.
00146         //
00147         AfxMessageBox("No connection to the DS was detected.");
00148         return FALSE;
00149     }
00150
00151
00152     if(PrivateProps.aPropVar[0].boolVal == 0)
00153     {
00154         //
00155         // DS-disabled.
00156         //
00157         return FALSE;
00158     }
00159
00160     return TRUE;
00161
00162 }
00163 // CLoginDlg message handlers
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ADOConnectionConstructionVtbl Member List

This is the complete list of members for ADOConnectionConstructionVtbl, including all inherited members.
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(ADOConnectionConstruction __RPC_FAR *This | ADOConnectionConstructionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_DSO)(ADOConnectionConstruction __RPC_FAR *This | ADOConnectionConstructionVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Session)(ADOConnectionConstruction __RPC_FAR *This | ADOConnectionConstructionVtbl
ppDSO | ADOConnectionConstructionVtbl
ppSession | ADOConnectionConstructionVtbl
ppvObject | ADOConnectionConstructionVtbl
riid | ADOConnectionConstructionVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(ADOConnectionConstruction __RPC_FAR *This) | ADOConnectionConstructionVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(ADOConnectionConstruction __RPC_FAR *This) | ADOConnectionConstructionVtbl
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpCntr/pre.h Source File

  • Com
  • Fundamentals
  • SimpCntr

pre.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: pre.h
00003 //
00004 //      Used for precompiled headers
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008
00009 #if !defined( _PRE_H_)
00010 #define _PRE_H_
00011
00012 #include <windows.h>
00013 #include <ole2.h>
00014 #include "OLEDLG.h"
00015 #include <assert.h>
00016 #include <string.h>
00017 #include "simpcntr.h"
00018 #include "resource.h"
00019 #include <ole2ver.h>
00020
00021
00022 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/registry.h Source File

  • SysMgmt
  • MMC
  • Toolbar

registry.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __Registry_H__
00020 #define __Registry_H__
00021
00022 #include <tchar.h>
00023
00024 // This function will register a component in the Registry.
00025 // The component calls this function from its DllRegisterServer function.
00026 HRESULT RegisterServer(HMODULE hModule,
00027                        const CLSID& clsid,
00028                        const _TCHAR* szFriendlyName) ;
00029
00030 // This function will unregister a component.  Components
00031 // call this function from their DllUnregisterServer function.
00032 HRESULT UnregisterServer(const CLSID& clsid) ;
00033
00034
00035 // This function will register a Snap-In component.  Components
00036 // call this function from their DllRegisterServer function.
00037 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00038                        const _TCHAR* szNameString,   // NameString
00039                        const CLSID& clsidAbout,   // Class Id for About Class
00040                        const BOOL fSupportExtensions = FALSE);
00041
00042 HRESULT UnregisterSnapin(const CLSID& clsid);         // Class ID
00043
00044 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/PropList.h Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

PropList.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      PropList.h
00007 //
00008 //  Implementation File:
00009 //      PropList.cpp
00010 //
00011 //  Description:
00012 //      Definition of the CClusPropList class.
00013 //
00014 //  Author:
00015 //      <name> (<e-mail name>) Mmmm DD, 2003
00016 //
00017 //  Revision History:
00018 //
00019 //  Notes:
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 #pragma once
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Include Files
00027 /////////////////////////////////////////////////////////////////////////////
00028 #include <windows.h>
00029 #include <clusapi.h>
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Forward Class Declarations
00033 /////////////////////////////////////////////////////////////////////////////
00034
00035 class CObjectProperty;
00036 class CClusPropValueList;
00037 class CClusPropList;
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // External Class Declarations
00041 /////////////////////////////////////////////////////////////////////////////
00042
00043 /////////////////////////////////////////////////////////////////////////////
00044 // Type Definitions
00045 /////////////////////////////////////////////////////////////////////////////
00046
00047 #if !defined( ASSERT )
00048 #include <crtdbg.h>
00049 #define ASSERT _ASSERTE
00050 #endif // !defined( ASSERT )
00051
00052 #pragma warning( push, 3 )
00053
00054 /////////////////////////////////////////////////////////////////////////////
00055 // Custom string compare function declarations. Used to replace lstrcmp*
00056 /////////////////////////////////////////////////////////////////////////////
00057
00058 //
00059 // Full string compares.
00060 //
00061
00062 int
00063 IBSTRCompareW(
00064       BSTR  bstrString1In
00065     , BSTR  bstrString2In
00066     );
00067
00068 int
00069 BSTRCompareW(
00070       BSTR  bstrString1In
00071     , BSTR  bstrString2In
00072     );
00073
00074 int
00075 IStringCompareW(
00076       LPCWSTR pcwszString1In
00077     , LPCWSTR pcwszString2In
00078     );
00079
00080 int
00081 StringCompareW(
00082       LPCWSTR pcwszString1In
00083     , LPCWSTR pcwszString2In
00084     );
00085
00086 int
00087 IStringCompareW(
00088       LPCWSTR   pcwszString1In
00089     , size_t    cch1In
00090     , LPCWSTR   pcwszString2In
00091     , size_t    cch2In
00092     );
00093
00094 int
00095 StringCompareW(
00096       LPCWSTR   pcwszString1In
00097     , size_t    cch1In
00098     , LPCWSTR   pcwszString2In
00099     , size_t    cch2In
00100     );
00101
00102 //
00103 // Partial string compares.  They use whichever one's length is shortest
00104 // if both are specified or the NBSTR routines are used.
00105 //
00106
00107 int
00108 NIBSTRCompareW(
00109       BSTR  bstrString1In
00110     , BSTR  bstrString2In
00111     );
00112
00113 int
00114 NBSTRCompareW(
00115       BSTR  bstrString1In
00116     , BSTR  bstrString2In
00117     );
00118
00119 int
00120 NIStringCompareW(
00121       LPCWSTR   pcwszString1In
00122     , LPCWSTR   pcwszString2In
00123     , size_t    cchIn
00124     );
00125
00126 int
00127 NStringCompareW(
00128       LPCWSTR   pcwszString1In
00129     , LPCWSTR   pcwszString2In
00130     , size_t    cchIn
00131     );
00132
00133 int
00134 NIStringCompareW(
00135       LPCWSTR   pcwszString1In
00136     , size_t    cch1In
00137     , LPCWSTR   pcwszString2In
00138     , size_t    cch2In
00139     );
00140
00141 int
00142 NStringCompareW(
00143       LPCWSTR   pcwszString1In
00144     , size_t    cch1In
00145     , LPCWSTR   pcwszString2In
00146     , size_t    cch2In
00147     );
00148
00149 /////////////////////////////////////////////////////////////////////////////
00150 //++
00151 //
00152 //  class CObjectProperty
00153 //
00154 //  Description:
00155 //      Describes a property in a cluster property list.
00156 //
00157 //  Inheritance:
00158 //      CObjectProperty
00159 //
00160 //--
00161 /////////////////////////////////////////////////////////////////////////////
00162
00163 #if defined( __AFX_H__ ) || ( defined( __ATLTMP_H__ ) && !defined( _ATL_TMP_NO_CSTRING ) )
00164
00165 class CObjectProperty
00166 {
00167 public:
00168
00169     LPCWSTR                 m_pwszName;
00170     CLUSTER_PROPERTY_FORMAT m_propFormat;
00171
00172     union CValue
00173     {
00174         CString *   pstr;
00175         LONG *      pl;
00176         DWORD *     pdw;
00177         BOOL *      pb;
00178         struct
00179         {
00180             PBYTE * ppb;
00181             DWORD * pcb;
00182         };
00183     };
00184
00185     CValue  m_value;
00186     CValue  m_valuePrev;
00187     CValue  m_valueEx;      // expand_sz value (if any)
00188
00189     DWORD   m_dwFlags;
00190
00191     enum ObjPropFlags
00192     {
00193         opfNew = 1
00194     };
00195
00196     CObjectProperty::CObjectProperty( void )
00197     {
00198         m_value.pstr = NULL;
00199         m_value.pcb = NULL;
00200         m_valuePrev.pstr = NULL;
00201         m_valuePrev.pcb = NULL;
00202         m_valueEx.pstr = NULL;
00203         m_valueEx.pcb = NULL;
00204     };
00205
00206     void
00207     Set(
00208           LPCWSTR   pwszNameIn
00209         , CString & rstrValueInout
00210         , CString & rstrPrevValueInout
00211         , DWORD     dwFlagsIn = 0
00212         )
00213     {
00214         m_pwszName = pwszNameIn;
00215         m_propFormat = CLUSPROP_FORMAT_SZ;
00216         m_value.pstr = &rstrValueInout;
00217         m_value.pcb = NULL;
00218         m_valuePrev.pstr = &rstrPrevValueInout;
00219         m_valuePrev.pcb = NULL;
00220         m_valueEx.pstr = NULL;
00221         m_valueEx.pcb = NULL;
00222         m_dwFlags = dwFlagsIn;
00223
00224     } //*** Set( CString & )
00225
00226     void
00227     SetExpandSz(
00228           LPCWSTR   pwszNameIn
00229         , CString & rstrValueInout
00230         , CString & rstrPrevValueInout
00231         , DWORD     dwFlagsIn = 0
00232         )
00233     {
00234         m_pwszName = pwszNameIn;
00235         m_propFormat = CLUSPROP_FORMAT_EXPAND_SZ;
00236         m_value.pstr = &rstrValueInout;
00237         m_value.pcb = NULL;
00238         m_valuePrev.pstr = &rstrPrevValueInout;
00239         m_valuePrev.pcb = NULL;
00240         m_valueEx.pstr= NULL;
00241         m_valueEx.pcb = NULL;
00242         m_dwFlags = dwFlagsIn;
00243
00244     } //*** Set( CString & )
00245
00246     // Set() to get extra EXPANDED_SZ value
00247     void
00248     Set(
00249           LPCWSTR   pwszNameIn
00250         , CString & rstrValueInout
00251         , CString & rstrPrevValueInout
00252         , CString & rstrValueEx
00253         , DWORD     dwFlagsIn = 0
00254         )
00255     {
00256         m_pwszName = pwszNameIn;
00257         m_propFormat = CLUSPROP_FORMAT_SZ;
00258         m_value.pstr = &rstrValueInout;
00259         m_value.pcb = NULL;
00260         m_valuePrev.pstr = &rstrPrevValueInout;
00261         m_valuePrev.pcb = NULL;
00262         m_valueEx.pstr = &rstrValueEx;
00263         m_valueEx.pcb = NULL;
00264         m_dwFlags = dwFlagsIn;
00265
00266     } //*** Set( CString & )
00267
00268     // Set() to get extra EXPANDED_SZ value
00269     void
00270     SetExpandSz(
00271           LPCWSTR   pwszNameIn
00272         , CString & rstrValueInout
00273         , CString & rstrPrevValueInout
00274         , CString & rstrValueEx
00275         , DWORD     dwFlagsIn = 0
00276         )
00277     {
00278         m_pwszName = pwszNameIn;
00279         m_propFormat = CLUSPROP_FORMAT_EXPAND_SZ;
00280         m_value.pstr = &rstrValueInout;
00281         m_value.pcb = NULL;
00282         m_valuePrev.pstr = &rstrPrevValueInout;
00283         m_valuePrev.pcb = NULL;
00284         m_valueEx.pstr = &rstrValueEx;
00285         m_valueEx.pcb = NULL;
00286         m_dwFlags = dwFlagsIn;
00287
00288     } //*** Set( CString & )
00289
00290     void
00291     Set(
00292           LPCWSTR   pwszNameIn
00293         , LONG &    rnValueInout
00294         , LONG &    rnPrevValueInout
00295         , DWORD     dwFlagsIn = 0
00296         )
00297     {
00298         m_pwszName = pwszNameIn;
00299         m_propFormat = CLUSPROP_FORMAT_LONG;
00300         m_value.pl = &rnValueInout;
00301         m_value.pcb = NULL;
00302         m_valuePrev.pl = &rnPrevValueInout;
00303         m_valuePrev.pcb = NULL;
00304         m_valueEx.pstr = NULL;
00305         m_valueEx.pcb = NULL;
00306         m_dwFlags = dwFlagsIn;
00307
00308     } //*** Set( LONG & )
00309
00310     void
00311     Set(
00312           LPCWSTR   pwszNameIn
00313         , DWORD &   rdwValueInout
00314         , DWORD &   rdwPrevValueInout
00315         , DWORD     dwFlagsIn = 0
00316         )
00317     {
00318         m_pwszName = pwszNameIn;
00319         m_propFormat = CLUSPROP_FORMAT_DWORD;
00320         m_value.pdw = &rdwValueInout;
00321         m_value.pcb = NULL;
00322         m_valuePrev.pdw = &rdwPrevValueInout;
00323         m_valuePrev.pcb = NULL;
00324         m_valueEx.pstr = NULL;
00325         m_valueEx.pcb = NULL;
00326         m_dwFlags = dwFlagsIn;
00327
00328     } //*** Set( DWORD & )
00329
00330     void
00331     Set(
00332           LPCWSTR   pwszNameIn
00333         , BOOL &    rbValueInout
00334         , BOOL &    rbPrevValueInout
00335         , DWORD     dwFlagsIn = 0
00336         )
00337     {
00338         m_pwszName = pwszNameIn;
00339         m_propFormat = CLUSPROP_FORMAT_DWORD;
00340         m_value.pb = &rbValueInout;
00341         m_value.pcb = NULL;
00342         m_valuePrev.pb = &rbPrevValueInout;
00343         m_valuePrev.pcb = NULL;
00344         m_valueEx.pstr = NULL;
00345         m_valueEx.pcb = NULL;
00346         m_dwFlags = dwFlagsIn;
00347
00348     } //*** Set( BOOL & )
00349
00350     void
00351     Set(
00352           LPCWSTR   pwszNameIn
00353         , PBYTE &   rpbValueInoout
00354         , DWORD &   rcbValueInout
00355         , PBYTE &   rpbPrevValueInout
00356         , DWORD &   rcbPrevValueInout
00357         , DWORD     dwFlagsIn = 0
00358         )
00359     {
00360         m_pwszName = pwszNameIn;
00361         m_propFormat = CLUSPROP_FORMAT_BINARY;
00362         m_value.ppb = &rpbValueInoout;
00363         m_value.pcb = &rcbValueInout;
00364         m_valuePrev.ppb = &rpbPrevValueInout;
00365         m_valuePrev.pcb = &rcbPrevValueInout;
00366         m_valueEx.pstr = NULL;
00367         m_valueEx.pcb = NULL;
00368         m_dwFlags = dwFlagsIn;
00369
00370     } //*** Set( PBYTE & )
00371
00372     void
00373     Set(
00374           LPCWSTR   pwszNameIn
00375         , LPWSTR &  rpwszValue
00376         , DWORD &   rcbValueInout
00377         , LPWSTR &  rpwszPrevValue
00378         , DWORD &   rcbPrevValueInout
00379         , DWORD     dwFlagsIn = 0
00380         )
00381     {
00382         m_pwszName = pwszNameIn;
00383         m_propFormat = CLUSPROP_FORMAT_MULTI_SZ;
00384         m_value.ppb = reinterpret_cast< PBYTE * >( &rpwszValue );
00385         m_value.pcb = &rcbValueInout;
00386         m_valuePrev.ppb = reinterpret_cast< PBYTE * >( &rpwszPrevValue );
00387         m_valuePrev.pcb = &rcbPrevValueInout;
00388         m_valueEx.pstr = NULL;
00389         m_valueEx.pcb = NULL;
00390         m_dwFlags = dwFlagsIn;
00391
00392     } //*** Set( LPWSTR & )
00393
00394 }; //*** class CObjectProperty
00395
00396 #endif  // defined( __AFX_H__ ) || ( defined( __ATLTMP_H__ ) && !defined( _ATL_TMP_NO_CSTRING ) )
00397
00398 /////////////////////////////////////////////////////////////////////////////
00399 //++
00400 //
00401 //  class CClusPropValueList
00402 //
00403 //  Description:
00404 //      Describes a cluster property list.
00405 //
00406 //  Inheritance:
00407 //      CClusPropValueList
00408 //      CObject (MFC only)
00409 //
00410 //--
00411 /////////////////////////////////////////////////////////////////////////////
00412
00413 class CClusPropValueList
00414 #ifdef __AFX_H__
00415     : public CObject
00416 #endif // __AFX_H__
00417 {
00418 #ifdef __AFX_H__
00419     DECLARE_DYNAMIC( CClusPropValueList );
00420 #endif // __AFX_H__
00421
00422 public:
00423
00424     //
00425     // Construction.
00426     //
00427
00428     // Default constructor
00429     CClusPropValueList( void )
00430         : m_cbDataSize( 0 )
00431         , m_cbDataLeft( 0 )
00432         , m_cbBufferSize( 0 )
00433         , m_fAtEnd( FALSE )
00434     {
00435         m_cbhValueList.pb = NULL;
00436         m_cbhCurrentValue.pb = NULL;
00437
00438     } //*** CClusPropValueList
00439
00440     //  Copy constructor.
00441     CClusPropValueList(
00442         const CClusPropValueList & rcpvlInout
00443         )
00444         : m_cbBufferSize( 0 )
00445         , m_fAtEnd( FALSE )
00446     {
00447         Init( rcpvlInout );
00448
00449     } //*** CClusPropValueList
00450
00451     //  Buffer helper constructor.
00452     CClusPropValueList(
00453           CLUSPROP_BUFFER_HELPER    cbhValueListIn
00454         , size_t                    cbDataSizeIn
00455         )
00456         : m_cbBufferSize( 0 )
00457         , m_fAtEnd( FALSE )
00458     {
00459         Init( cbhValueListIn, cbDataSizeIn );
00460
00461     } //*** CClusPropValueList
00462
00463     //  Destructor
00464     ~CClusPropValueList( void )
00465     {
00466         DeleteValueList();
00467
00468     } //*** ~CClusPropValueList
00469
00470     //  Initialize the value list
00471     void
00472     Init(
00473         const CClusPropValueList & rcpvlInout
00474         )
00475     {
00476         ASSERT( m_cbBufferSize == 0 );
00477
00478         m_cbhValueList      = rcpvlInout.m_cbhValueList;
00479         m_cbhCurrentValue   = rcpvlInout.m_cbhCurrentValue;
00480         m_cbDataSize        = rcpvlInout.m_cbDataSize;
00481         m_cbDataLeft        = rcpvlInout.m_cbDataLeft;
00482         m_fAtEnd            = rcpvlInout.m_fAtEnd;
00483
00484     } //*** Init
00485
00486     //  Initialize the value list from a buffer helper
00487     void
00488     Init(
00489           const CLUSPROP_BUFFER_HELPER  cbhValueListIn
00490         , size_t                        cbDataSizeIn
00491         )
00492     {
00493         ASSERT( m_cbBufferSize == 0 );
00494
00495         m_cbhValueList      = cbhValueListIn;
00496         m_cbhCurrentValue   = cbhValueListIn;
00497         m_cbDataSize        = cbDataSizeIn;
00498         m_cbDataLeft        = cbDataSizeIn;
00499         m_fAtEnd            = FALSE;
00500
00501     } //*** Init
00502
00503     //  Assignment operator
00504     void operator=( const CClusPropValueList & rcpvlInout )
00505     {
00506         ASSERT( m_cbBufferSize == 0 );
00507
00508         m_cbhValueList      = rcpvlInout.m_cbhValueList;
00509         m_cbhCurrentValue   = rcpvlInout.m_cbhCurrentValue;
00510         m_cbDataSize        = rcpvlInout.m_cbDataSize;
00511         m_cbDataLeft        = rcpvlInout.m_cbDataLeft;
00512         m_fAtEnd            = rcpvlInout.m_fAtEnd;
00513
00514     } //*** operator=
00515
00516     //
00517     // Accessor methods.
00518     //
00519
00520     // Buffer helper cast operator to access the current value
00521     operator const CLUSPROP_BUFFER_HELPER( void ) const
00522     {
00523         return m_cbhCurrentValue;
00524
00525     } //*** operator CLUSPROP_BUFFER_HELPER
00526
00527     // Access the value list
00528     CLUSPROP_BUFFER_HELPER CbhValueList( void ) const
00529     {
00530         return m_cbhValueList;
00531
00532     } //*** CbhValueList
00533
00534     // Access the current value
00535     CLUSPROP_BUFFER_HELPER CbhCurrentValue( void ) const
00536     {
00537         return m_cbhCurrentValue;
00538
00539     } //*** CbhCurrentValue
00540
00541     // Access the format of the current value
00542     CLUSTER_PROPERTY_FORMAT CpfCurrentValueFormat( void ) const
00543     {
00544         return static_cast< CLUSTER_PROPERTY_FORMAT >( m_cbhCurrentValue.pValue->Syntax.wFormat );
00545
00546     } //*** CpfCurrentValueFormat
00547
00548     // Access the type of the current value
00549     CLUSTER_PROPERTY_TYPE CptCurrentValueType( void ) const
00550     {
00551         return static_cast< CLUSTER_PROPERTY_TYPE >( m_cbhCurrentValue.pValue->Syntax.wType );
00552
00553     } //*** CptCurrentValueType
00554
00555     // Access the syntax of the current value
00556     CLUSTER_PROPERTY_SYNTAX CpsCurrentValueSyntax( void ) const
00557     {
00558         return static_cast< CLUSTER_PROPERTY_SYNTAX >( m_cbhCurrentValue.pValue->Syntax.dw );
00559
00560     } //*** CpsCurrentValueSyntax
00561
00562     // Access the length of the data of the current value
00563     DWORD CbCurrentValueLength( void ) const
00564     {
00565         DWORD cbLength = 0;
00566
00567         if ( m_cbhCurrentValue.pb == NULL )
00568         {
00569             cbLength = 0;
00570         } // if: no value list allocated yet
00571         else
00572         {
00573             cbLength = m_cbhCurrentValue.pValue->cbLength;
00574         } // else: value list allocated
00575
00576         return cbLength;
00577
00578     } //*** CbCurrentValueLength
00579
00580     // Access size of the data in the buffer.
00581     DWORD CbDataSize( void ) const
00582     {
00583         return m_cbDataSize;
00584
00585     } //*** CbDataSize
00586
00587     // Access amount of data left in buffer after current value
00588     DWORD CbDataLeft( void ) const
00589     {
00590         return m_cbDataLeft;
00591
00592     } //*** CbDataLeft
00593
00594     //
00595     // Parsing methods.
00596     //
00597
00598     // Move to the first value in the list
00599     DWORD ScMoveToFirstValue( void );
00600
00601     // Move the value after the current one in the list
00602     DWORD ScMoveToNextValue( void );
00603
00604     // Query whether we are at the last value in the list or not
00605     DWORD ScCheckIfAtLastValue( void );
00606
00607     //
00608     // Methods for building a value list.
00609     //
00610
00611     DWORD ScAllocValueList( size_t cbMinimumIn );
00612
00613     // Delete the value list buffer and cleanup support variables
00614     void DeleteValueList( void )
00615     {
00616         //
00617         // If m_cbBufferSize is greater then 0 then we allocated the value list.
00618         // If it's zero then the value list is a part of the property list in
00619         // CClusPropList.
00620         //
00621
00622         if ( m_cbBufferSize > 0 )
00623         {
00624             delete [] m_cbhValueList.pb;
00625
00626             m_cbhValueList.pb = NULL;
00627             m_cbhCurrentValue.pb = NULL;
00628             m_cbBufferSize = 0;
00629             m_cbDataSize = 0;
00630             m_cbDataLeft = 0;
00631             m_fAtEnd = FALSE;
00632         } // if: we allocated anything
00633
00634     } //*** DeleteValueList
00635
00636     // Get a value list from a resource
00637     DWORD
00638     ScGetResourceValueList(
00639           HRESOURCE hResourceIn
00640         , DWORD     dwControlCodeIn
00641         , HNODE     hHostNodeIn = NULL
00642         , LPVOID    lpBufferIn = NULL
00643         , size_t    cbBufferIn = 0
00644         );
00645
00646     // Get a value list from a resource type
00647     DWORD ScGetResourceTypeValueList(
00648           HCLUSTER  hClusterIn
00649         , LPCWSTR   pwszResTypeNameIn
00650         , DWORD     dwControlCodeIn
00651         , HNODE     hHostNodeIn = NULL
00652         , LPVOID    lpBufferIn = NULL
00653         , size_t    cbBufferIn = 0
00654         );
00655
00656 private:
00657     CLUSPROP_BUFFER_HELPER  m_cbhValueList;     // Pointer to the value list for parsing.
00658     CLUSPROP_BUFFER_HELPER  m_cbhCurrentValue;  // Pointer to the current value for parsing.
00659     DWORD                   m_cbDataSize;       // Amount of data in the buffer.
00660     DWORD                   m_cbDataLeft;       // Amount of data left in buffer after current value.
00661     DWORD                   m_cbBufferSize;     // Size of the buffer if we allocated it.
00662     BOOL                    m_fAtEnd;           // Indicates whether at last value in list.
00663
00664 }; //*** class CClusPropValueList
00665
00666 /////////////////////////////////////////////////////////////////////////////
00667 //++
00668 //
00669 //  class CClusPropList
00670 //
00671 //  Description:
00672 //      Describes a cluster property list.
00673 //
00674 //  Inheritance:
00675 //      CClusPropList
00676 //      CObject (MFC only)
00677 //
00678 //--
00679 /////////////////////////////////////////////////////////////////////////////
00680 class CClusPropList
00681 #ifdef __AFX_H__
00682     : public CObject
00683 #endif // __AFX_H__
00684 {
00685 #ifdef __AFX_H__
00686     DECLARE_DYNAMIC( CClusPropList );
00687 #endif // __AFX_H__
00688
00689 public:
00690
00691     //
00692     // Construction.
00693     //
00694
00695     // Default constructor
00696     CClusPropList(
00697         BOOL bAlwaysAddPropIn = FALSE
00698         )
00699         : m_fAlwaysAddProp( bAlwaysAddPropIn )
00700         , m_cbBufferSize( 0 )
00701         , m_cbDataSize( 0 )
00702         , m_cbDataLeft( 0 )
00703         , m_nPropsRemaining( 0 )
00704     {
00705         m_cbhPropList.pList     = NULL;
00706         m_cbhCurrentProp.pb     = NULL;
00707         m_cbhCurrentPropName.pb = NULL;
00708
00709     } //*** CClusPropList
00710
00711     // Destructor
00712     ~CClusPropList( void )
00713     {
00714         DeletePropList();
00715
00716     } //*** ~CClusPropList
00717
00718     // Copy list into this list (like assignment operator)
00719     DWORD ScCopy( const PCLUSPROP_LIST pcplPropListIn, size_t cbListSizeIn );
00720
00721     // Append list into this list
00722     DWORD ScAppend( const CClusPropList & rclPropListIn );
00723
00724     // Delete the property list buffer and cleanup support variables
00725     void DeletePropList( void )
00726     {
00727         delete [] m_cbhPropList.pb;
00728
00729         m_cbhPropList.pb = NULL;
00730         m_cbhCurrentProp.pb = NULL;
00731         m_cbhCurrentPropName.pb = NULL;
00732         m_cbBufferSize = 0;
00733         m_cbDataSize = 0;
00734         m_cbDataLeft = 0;
00735
00736     } //*** DeletePropList
00737
00738 protected:
00739
00740     //
00741     // Attributes.
00742     //
00743
00744     BOOL                    m_fAlwaysAddProp;       // Indicate if properties should be added even if not different.
00745     CLUSPROP_BUFFER_HELPER  m_cbhPropList;          // Pointer to the beginning of the list.
00746     CLUSPROP_BUFFER_HELPER  m_cbhCurrentProp;       // Pointer to the current property.
00747     DWORD                   m_cbBufferSize;         // Allocated size of the buffer.
00748     DWORD                   m_cbDataSize;           // Amount of data in the buffer.
00749     DWORD                   m_cbDataLeft;           // Amount of data left in buffer after current value.
00750
00751 private:
00752     CLUSPROP_BUFFER_HELPER  m_cbhCurrentPropName;   // Pointer to the current name for parsing
00753     DWORD                   m_nPropsRemaining;      // Used by BMoveToNextProperty() to track end of list.
00754     CClusPropValueList      m_pvlValues;            // Helper class for value list of current property.
00755
00756 public:
00757
00758     //
00759     // Accessor methods.
00760     //
00761
00762     // Access the values of the current property
00763     const CClusPropValueList & RPvlPropertyValue( void )
00764     {
00765         return m_pvlValues;
00766
00767     } //*** RPvlPropertyValue
00768
00769     // Access the property list
00770     operator PCLUSPROP_LIST( void ) const
00771     {
00772         return m_cbhPropList.pList;
00773
00774     } //*** operator PCLUSPROP_LIST
00775
00776     // Access allocated size of the buffer
00777     DWORD CbBufferSize( void ) const
00778     {
00779         return m_cbBufferSize;
00780
00781     } //*** CbBufferSize
00782
00783     // Access the name of the current property
00784     LPCWSTR PszCurrentPropertyName( void ) const
00785     {
00786         return m_cbhCurrentPropName.pName->sz;
00787
00788     } //*** PszCurrentPropertyName
00789
00790     // Access the current property name as a buffer helper
00791     const CLUSPROP_BUFFER_HELPER CbhCurrentPropertyName( void )
00792     {
00793         return m_cbhCurrentPropName;
00794
00795     } //*** CbhCurrentPropertyName
00796
00797     // Access value list of the current property as a buffer helper
00798     const CLUSPROP_BUFFER_HELPER CbhCurrentValueList( void )
00799     {
00800         return m_pvlValues.CbhValueList();
00801
00802     } //*** CbhCurrentValueList
00803
00804     // Access current value of the current property as a buffer helper
00805     const CLUSPROP_BUFFER_HELPER CbhCurrentValue( void )
00806     {
00807         return m_pvlValues.CbhCurrentValue();
00808
00809     } //*** CbhCurrentValue
00810
00811     // Access the format of the current value of the current property
00812     CLUSTER_PROPERTY_FORMAT CpfCurrentValueFormat( void ) const
00813     {
00814         return m_pvlValues.CpfCurrentValueFormat();
00815
00816     } //*** CpfCurrentValueFormat
00817
00818     // Access the type of the current value of the current property
00819     CLUSTER_PROPERTY_TYPE CptCurrentValueType( void ) const
00820     {
00821         return m_pvlValues.CptCurrentValueType();
00822
00823     } //*** CptCurrentValueType
00824
00825     // Access the syntax of the current value of the current property
00826     CLUSTER_PROPERTY_SYNTAX CpsCurrentValueSyntax( void ) const
00827     {
00828         return m_pvlValues.CpsCurrentValueSyntax();
00829
00830     } //*** CpsCurrentValueSyntax
00831
00832     // Access the length of the current value of the current property
00833     DWORD CbCurrentValueLength( void ) const
00834     {
00835         return m_pvlValues.CbCurrentValueLength();
00836
00837     } //*** CbCurrentValueLength
00838
00839     PCLUSPROP_LIST Plist( void )
00840     {
00841         return m_cbhPropList.pList;
00842
00843     } //*** Plist
00844
00845     const CLUSPROP_BUFFER_HELPER CbhPropList( void ) const
00846     {
00847         return m_cbhPropList;
00848
00849     } //*** CbhPropList
00850
00851     PBYTE PbPropList( void ) const
00852     {
00853         return m_cbhPropList.pb;
00854
00855     } //*** PbPropList
00856
00857     DWORD CbPropList( void ) const
00858     {
00859         return m_cbDataSize + sizeof( CLUSPROP_SYNTAX ); /*endmark*/
00860
00861     } //*** CbPropList
00862
00863     // Access amount of data left in buffer after current value
00864     DWORD CbDataLeft( void ) const
00865     {
00866         return m_cbDataLeft;
00867
00868     } //*** CbDataLeft
00869
00870     DWORD Cprops( void ) const
00871     {
00872         if ( m_cbhPropList.pb == NULL )
00873         {
00874             return 0;
00875         } // if:  no buffer yet
00876
00877         return m_cbhPropList.pList->nPropertyCount;
00878
00879     } //*** Cprops
00880
00881 public:
00882     //
00883     // Parsing methods.
00884     //
00885
00886     // Initialize the size after getting properties from an external source
00887     void InitSize( size_t cbSizeIn )
00888     {
00889         ASSERT( m_cbhPropList.pb != NULL );
00890         ASSERT( m_cbBufferSize > 0 );
00891
00892         m_cbDataSize = cbSizeIn;
00893         m_cbDataLeft = cbSizeIn;
00894
00895     } //*** InitSize
00896
00897     // Move to the first property in the list
00898     DWORD ScMoveToFirstProperty( void );
00899
00900     // Move the property after the current one in the list
00901     DWORD ScMoveToNextProperty( void );
00902
00903     // Move to a property by specifying its name
00904     DWORD ScMoveToPropertyByName( LPCWSTR pwszPropNameIn );
00905
00906     // Move to the first value in the current property
00907     DWORD ScMoveToFirstPropertyValue( void )
00908     {
00909         return m_pvlValues.ScMoveToFirstValue();
00910
00911     } //*** ScMoveToFirstPropertyValue
00912
00913     // Move the the value after the current on in the current property
00914     DWORD ScMoveToNextPropertyValue( void )
00915     {
00916         return m_pvlValues.ScMoveToNextValue();
00917
00918     } //*** ScMoveToNextPropertyValue
00919
00920     // Query whether we are at the last property in the list or not
00921     DWORD ScCheckIfAtLastProperty( void ) const
00922     {
00923         DWORD sc;
00924
00925         if ( m_nPropsRemaining <= 1 )
00926         {
00927             sc = ERROR_NO_MORE_ITEMS;
00928         } // if:  at the last property
00929         else
00930         {
00931             sc = ERROR_SUCCESS;
00932         } // else:  not at the last property
00933
00934         return sc;
00935
00936     } //*** ScCheckIfAtLastProperty
00937
00938     // Query whether the list is empty or not
00939     BOOL BIsListEmpty( void ) const
00940     {
00941         ASSERT( m_cbhPropList.pb != NULL );
00942         ASSERT( m_cbDataSize >= sizeof( m_cbhPropList.pList->nPropertyCount ) );
00943
00944         return m_cbhPropList.pList->nPropertyCount == 0;
00945
00946     } //*** BIsListEmpty
00947
00948 public:
00949     //
00950     // Methods for building a property list.
00951     //
00952
00953     // Allocate a property list
00954     DWORD ScAllocPropList( size_t cbMinimumIn );
00955
00956     void ClearPropList( void )
00957     {
00958         m_cbDataSize = 0;
00959         m_cbDataLeft = 0;
00960
00961         if ( m_cbBufferSize != 0 )
00962         {
00963             ZeroMemory( m_cbhPropList.pb, m_cbBufferSize );
00964             m_cbhCurrentProp.pb = m_cbhPropList.pb + sizeof( m_cbhPropList.pList->nPropertyCount );
00965             m_cbhCurrentPropName = m_cbhCurrentProp;
00966         } // if:  buffer already allocated
00967
00968     } //*** ClearPropList
00969
00970     DWORD ScAddProp( LPCWSTR pwszNameIn, LPCWSTR pwszValueIn, LPCWSTR pwszPrevValueIn );
00971
00972     DWORD ScAddExpandSzProp( LPCWSTR pwszNameIn, LPCWSTR pwszValueIn, LPCWSTR pwszPrevValueIn );
00973
00974     DWORD ScAddMultiSzProp( LPCWSTR pwszNameIn, LPCWSTR pwszValueIn, LPCWSTR pwszPrevValueIn );
00975
00976     DWORD ScAddProp( LPCWSTR pwszNameIn, DWORD nValueIn, DWORD nPrevValueIn );
00977
00978     DWORD ScAddProp( LPCWSTR pwszNameIn, LONG nValueIn, LONG nPrevValueIn );
00979
00980     DWORD ScAddProp( LPCWSTR pwszNameIn, ULONGLONG ullValueIn, ULONGLONG ullPrevValueIn );
00981
00982     DWORD ScAddProp( LPCWSTR pwszNameIn, LONGLONG llValueIn, LONGLONG llPrevValueIn );
00983
00984     DWORD ScSetPropToDefault( LPCWSTR pwszNameIn, CLUSTER_PROPERTY_FORMAT propFormatIn );
00985
00986     DWORD ScAddProp(
00987               LPCWSTR               pwszNameIn
00988             , const unsigned char * pbValueIn
00989             , size_t                cbValueIn
00990             , const unsigned char * pbPrevValueIn
00991             , size_t                cbPrevValueIn
00992             );
00993
00994     DWORD ScAddProp( LPCWSTR pwszNameIn, LPCWSTR pwszValueIn )
00995     {
00996         return ScAddProp( pwszNameIn, pwszValueIn, NULL );
00997
00998     } //*** ScAddProp
00999
01000     DWORD ScAddExpandSzProp( LPCWSTR pwszNameIn, LPCWSTR pwszValueIn )
01001     {
01002         return ScAddExpandSzProp( pwszNameIn, pwszValueIn, NULL );
01003
01004     } //*** ScAddExpandSzProp
01005
01006 public:
01007
01008     //
01009     // Get Property methods.
01010     //
01011
01012     DWORD ScGetNodeProperties(
01013           HNODE     hNodeIn
01014         , DWORD     dwControlCodeIn
01015         , HNODE     hHostNodeIn = NULL
01016         , LPVOID    lpBufferIn = NULL
01017         , size_t    cbBufferIn = 0
01018         );
01019
01020     DWORD ScGetGroupProperties(
01021           HGROUP   hGroupIn
01022         , DWORD    dwControlCodeIn
01023         , HNODE    hHostNodeIn = NULL
01024         , LPVOID   lpBufferIn = NULL
01025         , size_t   cbBufferIn = 0
01026         );
01027
01028     DWORD ScGetResourceProperties(
01029           HRESOURCE    hResourceIn
01030         , DWORD        dwControlCodeIn
01031         , HNODE        hHostNodeIn = NULL
01032         , LPVOID       lpBufferIn = NULL
01033         , size_t       cbBufferIn = 0
01034         );
01035
01036     DWORD ScGetResourceTypeProperties(
01037           HCLUSTER hClusterIn
01038         , LPCWSTR  pwszResTypeNameIn
01039         , DWORD    dwControlCodeIn
01040         , HNODE    hHostNodeIn = NULL
01041         , LPVOID   lpBufferIn = NULL
01042         , size_t   cbBufferIn = 0
01043         );
01044
01045     DWORD ScGetNetworkProperties(
01046           HNETWORK hNetworkIn
01047         , DWORD    dwControlCodeIn
01048         , HNODE    hHostNodeIn = NULL
01049         , LPVOID   lpBufferIn = NULL
01050         , size_t   cbBufferIn = 0
01051         );
01052
01053     DWORD ScGetNetInterfaceProperties(
01054           HNETINTERFACE    hNetInterfaceIn
01055         , DWORD            dwControlCodeIn
01056         , HNODE            hHostNodeIn  = NULL
01057         , LPVOID           lpBufferIn = NULL
01058         , size_t           cbBufferIn = 0
01059         );
01060
01061     DWORD ScGetClusterProperties(
01062           HCLUSTER hClusterIn
01063         , DWORD    dwControlCodeIn
01064         , HNODE    hHostNodeIn = NULL
01065         , LPVOID   lpBufferIn = NULL
01066         , size_t   cbBufferIn = 0
01067         );
01068
01069 // Implementation
01070 protected:
01071     void CopyProp(
01072           PCLUSPROP_SZ             ppropIn
01073         , CLUSTER_PROPERTY_TYPE    cptPropTypeIn
01074         , LPCWSTR                  pszIn
01075         , size_t                   cbszIn = 0
01076         );
01077
01078     void CopyExpandSzProp(
01079           PCLUSPROP_SZ             ppropIn
01080         , CLUSTER_PROPERTY_TYPE    cptPropTypeIn
01081         , LPCWSTR                  pszIn
01082         , size_t                   cbszIn = 0
01083         );
01084
01085     void CopyMultiSzProp(
01086           PCLUSPROP_MULTI_SZ       ppropIn
01087         , CLUSTER_PROPERTY_TYPE    cptPropTypeIn
01088         , LPCWSTR                  pszIn
01089         , size_t                   cbszIn = 0
01090         );
01091
01092     void CopyProp(
01093           PCLUSPROP_DWORD          ppropIn
01094         , CLUSTER_PROPERTY_TYPE    cptPropTypeIn
01095         , DWORD                    nValueIn
01096         );
01097
01098     void CopyProp(
01099           PCLUSPROP_LONG           ppropIn
01100         , CLUSTER_PROPERTY_TYPE    cptPropTypeIn
01101         , LONG                     nValueIn
01102         );
01103
01104     void CopyProp(
01105           PCLUSPROP_ULARGE_INTEGER  ppropOut
01106         , CLUSTER_PROPERTY_TYPE     cptPropTypeIn
01107         , ULONGLONG                 ullValueIn
01108         );
01109
01110     void CopyProp(
01111           PCLUSPROP_LARGE_INTEGER  ppropOut
01112         , CLUSTER_PROPERTY_TYPE    cptPropTypeIn
01113         , LONGLONG                 llValueIn
01114         );
01115
01116     void CopyProp(
01117           PCLUSPROP_ULARGE_INTEGER  ppropOut
01118         , CLUSTER_PROPERTY_TYPE     cptPropTypeIn
01119         , LONGLONG                  llValueIn
01120         );
01121     void CopyProp(
01122           PCLUSPROP_BINARY      ppropOut
01123         , CLUSTER_PROPERTY_TYPE cptPropTypeIn
01124         , const unsigned char * pbValueIn
01125         , size_t                cbValueIn
01126         );
01127
01128     void CopyEmptyProp(
01129           PCLUSPROP_VALUE           ppropOut
01130         , CLUSTER_PROPERTY_TYPE     cptPropTypeIn
01131         , CLUSTER_PROPERTY_FORMAT   propFormatIn
01132         );
01133
01134 }; //*** class CClusPropList
01135
01136 #pragma warning( pop )
01137
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/findgoto.cpp Source File

  • Begin
  • sdkdiff

findgoto.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 /*
00012  * findgoto.cpp
00013  */
00014
00015 #include "precomp.h"
00016 #include "table.h"
00017
00018 #include "state.h"
00019 #include "sdkdiff.h"
00020 #include "wdiffrc.h"
00021
00022 #include "list.h"
00023 #include "line.h"
00024 #include "scandir.h"
00025 #include "file.h"
00026 #include "section.h"
00027 #include "compitem.h"
00028 #include "complist.h"
00029
00030 #include "view.h"
00031 #include "findgoto.h"
00032
00033 extern const CHAR szSdkDiff[];
00034 extern VIEW current_view;
00035
00036 static const char szFindSearchDown[]  = "FindSearchDown";
00037 static const char szFindMatchCase[]   = "FindMatchCase";
00038 static const char szFindWholeWord[]   = "FindWholeWord";
00039 static const char szFindStringXX[]    = "FindString%02d";
00040
00041 /*
00042  * DlgProc for the Find dialog
00043  *
00044  */
00045 int FAR PASCAL
00046 FindDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00047 {
00048   HRESULT hr;
00049   switch (message)
00050     {
00051     case WM_INITDIALOG:
00052       {
00053       char rgchFindString[CCH_FINDSTRING];
00054       char rgchKey[32];
00055       int iString = 0;
00056       const BOOL fDown      = GetProfileInt(APPNAME, szFindSearchDown, 1);
00057       const BOOL fMatchCase = GetProfileInt(APPNAME, szFindMatchCase, 0);
00058       const BOOL fWholeWord = GetProfileInt(APPNAME, szFindWholeWord, 0);
00059
00060       CheckDlgButton(hDlg, ((!fDown) ? IDC_OPT_UP : IDC_OPT_DOWN), BST_CHECKED);
00061       CheckDlgButton(hDlg, IDC_CHK_MATCHCASE, ((fMatchCase) ? BST_CHECKED : BST_UNCHECKED));
00062       CheckDlgButton(hDlg, IDC_CHK_WHOLEWORD, ((fWholeWord) ? BST_CHECKED : BST_UNCHECKED));
00063       SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_RESETCONTENT, 0, 0L);
00064       SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, EM_LIMITTEXT, CCH_FINDSTRING, 0L);
00065
00066       for (iString = 0; iString < NUM_FINDSTRINGS; iString++)
00067         {
00068         hr = StringCchPrintf(rgchKey, 32, szFindStringXX, iString);
00069     if (FAILED(hr))
00070       OutputError(hr, IDS_SAFE_PRINTF);
00071         if ( !GetProfileString(APPNAME, rgchKey, "", rgchFindString, CCH_FINDSTRING)
00072           || !*rgchFindString)
00073           {
00074           break;
00075           }
00076
00077         SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_INSERTSTRING, (WPARAM)-1, (LPARAM) rgchFindString);
00078         }
00079
00080       return TRUE;
00081       }
00082
00083     case WM_COMMAND:
00084       switch (wParam)
00085         {
00086         case IDOK:
00087           {
00088           char rgchText[CCH_FINDSTRING];
00089           const BOOL fWholeWord = (IsDlgButtonChecked(hDlg, IDC_CHK_WHOLEWORD) == BST_CHECKED);
00090
00091           WriteProfileInt(APPNAME, szFindSearchDown, (IsDlgButtonChecked(hDlg, IDC_OPT_DOWN) == BST_CHECKED));
00092           WriteProfileInt(APPNAME, szFindMatchCase,  (IsDlgButtonChecked(hDlg, IDC_CHK_MATCHCASE) == BST_CHECKED));
00093           WriteProfileInt(APPNAME, szFindWholeWord,  fWholeWord);
00094
00095           SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, WM_GETTEXT, CCH_FINDSTRING, (LPARAM) rgchText);
00096           if (*rgchText)
00097             {
00098             const LONG iCol = (view_isexpanded(current_view)) ? 2 : 1;
00099             char rgchBuf[CCH_FINDSTRING];
00100             char rgchKey[32];
00101             int iRet = (int) SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM) rgchText);
00102             int iString = 0;
00103
00104             if (iRet != CB_ERR)
00105               {
00106               iString = iRet;
00107
00108               do
00109                 {
00110                 SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_GETLBTEXT, iString, (LPARAM) rgchBuf);
00111                 if (!My_mbsncmp((LPCSTR) rgchText, (LPCSTR) rgchBuf, CCH_FINDSTRING))
00112                   {
00113                   /* delete the string out of its old place */
00114                   SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_DELETESTRING, iString, 0L);
00115                   break;
00116                   }
00117
00118                 iString = (int) SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_FINDSTRINGEXACT, iString, (LPARAM) rgchText);
00119                 } while (iString != CB_ERR && iString != iRet);
00120               }
00121
00122             /* insert the new string at index zero */
00123             SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_INSERTSTRING, 0, (LPARAM) rgchText);
00124
00125             for (iString = 0; iString < NUM_FINDSTRINGS; iString++)
00126               {
00127               *rgchBuf = 0;
00128               iRet = (int) SendDlgItemMessage(hDlg, IDC_DRD_FINDWHAT, CB_GETLBTEXT, iString, (LPARAM) rgchBuf);
00129               if (iRet <= 0 || iRet == CB_ERR || !*rgchBuf)
00130                 break;
00131
00132               hr = StringCchPrintf(rgchKey, 32, szFindStringXX, iString);
00133         if (FAILED(hr))
00134           OutputError(hr, IDS_SAFE_PRINTF);
00135               WriteProfileString(APPNAME, rgchKey, rgchBuf);
00136               }
00137
00138             /* don't end the dlg if we didn't find a match */
00139             if (!FindString(hDlg, iCol, rgchText, 0, ((fWholeWord) ? 1 : -1)))
00140               return TRUE;
00141             }
00142
00143           EndDialog(hDlg, wParam);
00144           return TRUE;
00145           }
00146
00147         case IDCANCEL:
00148           EndDialog(hDlg, wParam);
00149           return TRUE;
00150         }
00151     }
00152
00153   return FALSE;
00154 }
00155
00156
00157 /*
00158  * DlgProc for the Go To Line dialog
00159  *
00160  */
00161 int FAR PASCAL
00162 GoToLineDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00163 {
00164   switch (message)
00165     {
00166     case WM_INITDIALOG:
00167       SendDlgItemMessage(hDlg, IDC_EDT_GOTOLINE, EM_LIMITTEXT, CCH_MAXDIGITS, 0L);
00168       SendDlgItemMessage(hDlg, IDC_EDT_GOTOLINE, WM_SETTEXT, 0, (LPARAM) "1");
00169       return TRUE;
00170
00171     case WM_COMMAND:
00172       switch (wParam)
00173         {
00174         case IDOK:
00175           {
00176           const LONG lMax = view_getrowcount(current_view);
00177           char *pchT = NULL;
00178           int cNumeric = 0;
00179           char rgchBuf[256];
00180
00181           SendDlgItemMessage(hDlg, IDC_EDT_GOTOLINE, WM_GETTEXT, CCH_MAXDIGITS + 1, (LPARAM) rgchBuf);
00182
00183           /* eat leading whitespace */
00184           for (pchT = rgchBuf; *pchT && isspace(*pchT); pchT = CharNext(pchT))
00185             NULL;
00186
00187           for (NULL; *pchT; pchT = CharNext(pchT))
00188             {
00189             if (IsDBCSLeadByte(*pchT) || !isdigit(*pchT))
00190               break;
00191
00192             cNumeric++;
00193             }
00194
00195           /* if we didn't reach the end of the string, we have an invalid numeric string */
00196           if (!cNumeric)
00197             {
00198             MessageBox(hDlg, LoadRcString(IDS_GOTOLINE_INVALIDSTRING), szSdkDiff, MB_OK|MB_ICONSTOP|MB_TASKMODAL);
00199             return TRUE;
00200             }
00201
00202           /* terminate the string after the numeric chars */
00203           *pchT = 0;
00204
00205           /* go find the string */
00206           if (!FindString(hDlg, 0, rgchBuf, 1, 1))
00207             return TRUE;
00208
00209           EndDialog(hDlg, wParam);
00210           return TRUE;
00211           }
00212
00213         case IDCANCEL:
00214           EndDialog(hDlg, wParam);
00215           return TRUE;
00216         }
00217     }
00218
00219   return FALSE;
00220 }
00221
00222
00223 /*
00224  * Cover function for string search
00225  *
00226  */
00227 BOOL
00228 FindString(HWND hwndParent, LONG iCol, const char *pszFind, int nSearchDirection, int nWholeWord)
00229 {
00230   char rgchText[CCH_FINDSTRING];
00231   char rgchKey[32];
00232   BOOL fSearchDown = TRUE;    /* default is to search forward (down) */
00233   const BOOL fMatchCase = GetProfileInt(APPNAME, szFindMatchCase, 0);
00234   BOOL fWholeWord = FALSE;
00235   HRESULT hr;
00236
00237   if (!nWholeWord)
00238     {
00239     fWholeWord = (BOOL) GetProfileInt(APPNAME, szFindWholeWord, 0);
00240     }
00241   else
00242     {
00243     fWholeWord = (nWholeWord == 1);
00244     }
00245
00246   if (nSearchDirection < 0)   /* search backward (up) */
00247     {
00248     fSearchDown = FALSE;
00249     }
00250   else if (!nSearchDirection) /* look it up in the registry */
00251     {
00252     fSearchDown = GetProfileInt(APPNAME, szFindSearchDown, 1);
00253     }
00254
00255   *rgchText = 0;
00256   if (pszFind)
00257     {
00258     /* use the arg string */
00259     My_mbsncpy((LPSTR) rgchText, (LPCSTR) pszFind, CCH_FINDSTRING);
00260     }
00261   else
00262     {
00263     /* look up last find string in registry */
00264     hr = StringCchPrintf(rgchKey, 32, szFindStringXX, 0);
00265   if (FAILED(hr))
00266     OutputError(hr, IDS_SAFE_PRINTF);
00267     if (!GetProfileString(APPNAME, rgchKey, "", rgchText, CCH_FINDSTRING))
00268       *rgchText = 0;
00269     }
00270
00271   if ( !*rgchText
00272     || !view_findstring(current_view, iCol, rgchText, fSearchDown, fMatchCase, fWholeWord))
00273     {
00274     char rgchMsg[CCH_FINDSTRING * 2];
00275     hr = StringCchPrintf(rgchMsg, (CCH_FINDSTRING*2), LoadRcString(IDS_FIND_NOTFOUND), rgchText);
00276   if (FAILED(hr))
00277     OutputError(hr, IDS_SAFE_PRINTF);
00278   else
00279     MessageBox(hwndParent, rgchMsg, szSdkDiff, MB_OK|MB_ICONSTOP|MB_TASKMODAL);
00280     return FALSE;
00281     }
00282
00283   return TRUE;
00284 }
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/about.h Source File

  • SysMgmt
  • MMC
  • Toolbar

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/GlobalDev/CSSamp/Style.Cpp Source File

  • WinUI
  • GlobalDev
  • CSSamp

Style.Cpp

Go to the documentation of this file.
00001 ////    Style - simple character styles for formatted text
00002 //
00003 //      Provides a simple style selection mechanism for demostrating
00004 //      formatted text.
00005
00006 #include "precomp.hxx"
00007 #include "global.h"
00008
00009 void SetLogFont(
00010     PLOGFONTA   plf,
00011     int         iHeight,
00012     int         iWeight,
00013     int         iItalic,
00014     int         iUnderline,
00015     char       *pcFaceName)
00016 {
00017
00018     memset(plf, 0, sizeof(LOGFONTA));
00019     plf->lfCharSet        = DEFAULT_CHARSET;
00020     plf->lfHeight         = iHeight;
00021     plf->lfWeight         = iWeight;
00022     plf->lfItalic         = (BYTE) iItalic;
00023     plf->lfUnderline      = (BYTE) iUnderline;
00024     lstrcpynA(plf->lfFaceName, pcFaceName, min(sizeof(plf->lfFaceName),sizeof(pcFaceName)));
00025     plf->lfOutPrecision   = OUT_STROKE_PRECIS;
00026     plf->lfClipPrecision  = CLIP_STROKE_PRECIS;
00027     plf->lfQuality        = DRAFT_QUALITY;
00028     plf->lfPitchAndFamily = VARIABLE_PITCH;
00029     plf->lfEscapement     = 0;
00030     plf->lfOrientation    = 0;
00031 }
00032
00033 void FreeStyle(int iStyle)
00034 {
00035     if (g_style[iStyle].hf)
00036     {
00037         DeleteObject(g_style[iStyle].hf);
00038     }
00039
00040     if (g_style[iStyle].sc)
00041     {
00042         ScriptFreeCache(&g_style[iStyle].sc);
00043     }
00044 }
00045
00046 void SetStyle(
00047     int     iStyle,
00048     int     iHeight,
00049     int     iWeight,
00050     int     iItalic,
00051     int     iUnderline,
00052     char   *pcFaceName)
00053 {
00054     LOGFONTA lf = {0};
00055     FreeStyle(iStyle);
00056
00057     SetLogFont(&lf, iHeight, iWeight, iItalic, iUnderline, pcFaceName);
00058     g_style[iStyle].hf = CreateFontIndirectA(&lf);
00059     g_style[iStyle].sc = NULL;
00060 }
00061
00062 void InitStyles()
00063 {
00064     memset(g_style, 0, sizeof(g_style));
00065 }
00066
00067 void FreeStyles()
00068 {
00069     int i = 0;
00070     for (i = 0; i < 5; ++i)
00071     {
00072         FreeStyle(i);
00073     }
00074 }
00075
00076 ////    StyleCheckRange - Dir use in ASSERTs
00077 //
00078 //      Returns TRUE if style length matches text length
00079 BOOL StyleCheckRange()
00080 {
00081     int     iFormatPos   = 0;
00082     RUN    *pFormatRider = NULL;
00083
00084     // Check that style length is same as text length
00085     pFormatRider = g_pFirstFormatRun;
00086     iFormatPos = 0;
00087     while (pFormatRider != NULL)
00088     {
00089         iFormatPos += pFormatRider->iLen;
00090         pFormatRider = pFormatRider->pNext;
00091     }
00092
00093     return iFormatPos == g_iTextLen;
00094 }
00095
00096 /////   Style range manipulation
00097 //
00098 //      StyleDeleteRange
00099 //      StyleExtendRange
00100 //      StyleSetRange
00101 //
00102 //      The style list is a linked list of RUNs (see global.h) that
00103 //      covers the entire text buffer.
00104 //
00105 //      Each run has a length, and a style number (an index to g_Style[])
00106 //      (The analysis field in the run is not used by the style list.)
00107 //
00108 //      StyleDeleteRange and StyleExtendRange are called as part of text
00109 //      insertion/deletion to maintain the style list.
00110 //
00111 //      StyleSetRange is called to change the style of the current selection
00112 //      when the user clicks on one the of the numbered style buttons.
00113
00114
00115 ///     StyleDeleteRange - delete range of style information
00116 //
00117 //
00118 void StyleDeleteRange(
00119     int     iDelPos,
00120     int     iDelLen)
00121 {
00122
00123     int     iFormatPos   = 0;
00124     RUN    *pFormatRider = NULL;
00125     RUN    *pPrevRun     = NULL;
00126     RUN    *pDelRun      = NULL;            // Run to be deleted
00127
00128     if (iDelLen <= 0) return;
00129
00130     // Find first run affected by the deletion
00131     iFormatPos   = 0;
00132     pFormatRider = g_pFirstFormatRun;
00133     pPrevRun = NULL;
00134
00135     while (iFormatPos + pFormatRider->iLen <= iDelPos)
00136     {
00137         iFormatPos  += pFormatRider->iLen;
00138         pPrevRun     = pFormatRider;
00139         pFormatRider = pFormatRider->pNext;
00140         ASSERT(pFormatRider);
00141     }
00142
00143     // Delete from end of first run
00144     if (iDelPos + iDelLen  >  iFormatPos + pFormatRider->iLen)
00145     {
00146
00147         // Delete all the way from iDelPos to the end of the first affected run
00148         iDelLen = iDelPos + iDelLen - (iFormatPos + pFormatRider->iLen);    // Amount that will remain to be deleted
00149         pFormatRider->iLen = iDelPos - iFormatPos;
00150
00151     }
00152     else
00153     {
00154         // Deletion is entirely in the first affected run
00155         pFormatRider->iLen -= iDelLen;
00156         iDelLen = 0;
00157     }
00158
00159     // First affected run now contains no range to be deleted
00160     // If it's empty, remove it, otherwise step over it
00161     if (pFormatRider->iLen == 0)
00162     {
00163         // Remove redundant run
00164         if (pFormatRider->pNext)
00165         {
00166             // Replace this run by the next one
00167             pDelRun       = pFormatRider->pNext;
00168             *pFormatRider = *pDelRun;                 // Copy content of next run over this one
00169             delete pDelRun;
00170             pDelRun = NULL;
00171         }
00172         else
00173         {
00174             // No runs following this one
00175             if (pPrevRun)
00176             {
00177                 ASSERT(iDelLen == 0);
00178                 delete pFormatRider;
00179                 pFormatRider = NULL;
00180                 pPrevRun->pNext = NULL;
00181             }
00182             else
00183             {
00184                 // No runs left at all
00185                 ASSERT(iDelLen == 0);
00186                 delete pFormatRider;
00187                 pFormatRider = NULL;
00188                 g_pFirstFormatRun = NULL;
00189             }
00190         }
00191     }
00192     else
00193     {
00194         //  Current run now contains no text to be deleted, so advance to next run
00195         iFormatPos  += pFormatRider->iLen;
00196         pPrevRun     = pFormatRider;
00197         pFormatRider = pFormatRider->pNext;
00198     }
00199
00200     // Delete from start of any remaining runs
00201     while (iDelLen > 0)
00202     {
00203         if (pFormatRider->iLen <= iDelLen)
00204         {
00205             // This entire run must go
00206             ASSERT(pFormatRider->pNext);
00207             iDelLen -= pFormatRider->iLen;
00208             pDelRun  = pFormatRider->pNext;
00209             *pFormatRider = *pDelRun;
00210             delete pDelRun;
00211             pDelRun = NULL;
00212         }
00213         else
00214         {
00215             // Last run is deleted in part only
00216             pFormatRider->iLen -= iDelLen;
00217             iDelLen = 0;
00218         }
00219     }
00220
00221     // Check whether current run (which immediately follows deletion) can
00222     // now be collapsed into the previous run
00223     if (pPrevRun  &&  pFormatRider  &&  pPrevRun->iStyle == pFormatRider->iStyle)
00224     {
00225         pPrevRun->iLen += pFormatRider->iLen;
00226         pPrevRun->pNext = pFormatRider->pNext;
00227         delete pFormatRider;
00228         pFormatRider = NULL;
00229     }
00230 }
00231
00232 ///     StyleExtendRange - Extend style immediately preceeding iPos by iLen characters
00233 //
00234 //
00235 void StyleExtendRange(
00236     int     iExtPos,
00237     int     iExtLen)
00238 {
00239
00240     int     iFormatPos = 0;
00241     RUN    *pFormatRider = NULL;
00242     const SCRIPT_ANALYSIS nullAnalysis = {0};
00243
00244     if (g_pFirstFormatRun == NULL)
00245     {
00246         // Starting from no text at all
00247         ASSERT(iExtPos == 0);
00248         g_pFirstFormatRun           = new RUN;
00249         g_pFirstFormatRun->iLen     = iExtLen;
00250         g_pFirstFormatRun->iStyle   = 1;
00251         g_pFirstFormatRun->pNext    = NULL;
00252         g_pFirstFormatRun->analysis = nullAnalysis;
00253
00254     }
00255     else
00256     {
00257         // Find run containing character immediately prior to iExtPos
00258         iFormatPos = 0;
00259         pFormatRider = g_pFirstFormatRun;
00260
00261         while (iFormatPos + pFormatRider->iLen < iExtPos)
00262         {
00263             iFormatPos += pFormatRider->iLen;
00264             pFormatRider = pFormatRider->pNext;
00265         }
00266
00267         pFormatRider->iLen += iExtLen;
00268     }
00269 }
00270
00271 ////    StyleSetRange - Change style for a given range
00272 //
00273 //
00274 void StyleSetRange(
00275     int    iSetStyle,
00276     int    iSetPos,
00277     int    iSetLen)
00278 {
00279
00280     int     iFormatPos   = 0;
00281     RUN    *pFormatRider = NULL;
00282     RUN    *pNewRun      = NULL;
00283
00284     if (iSetLen <= 0) return;
00285
00286     // Remove existing style for the range
00287
00288     StyleDeleteRange(iSetPos, iSetLen);
00289
00290     if (g_pFirstFormatRun == NULL)
00291     {
00292
00293         // Replace style on entire text
00294         g_pFirstFormatRun = new RUN;
00295         g_pFirstFormatRun->pNext = NULL;
00296         g_pFirstFormatRun->iLen = iSetLen;
00297         g_pFirstFormatRun->iStyle = iSetStyle;
00298     }
00299     else
00300     {
00301         // Find first run affected by the change
00302         iFormatPos   = 0;
00303         pFormatRider = g_pFirstFormatRun;
00304         while (iFormatPos + pFormatRider->iLen < iSetPos)
00305         {
00306             iFormatPos  += pFormatRider->iLen;
00307             pFormatRider = pFormatRider->pNext;
00308             ASSERT(pFormatRider);
00309         }
00310
00311         // New style starts after beginning of this run or at beginning of next run
00312         if (pFormatRider->iStyle == iSetStyle)
00313         {
00314             // Already the same style - just increase length
00315             pFormatRider->iLen += iSetLen;
00316         }
00317         else
00318         {
00319             if (iFormatPos + pFormatRider->iLen > iSetPos)
00320             {
00321                 // New style is within this run
00322                 // Split this run around the new run
00323                 pNewRun = new RUN;          // Create second part of existing run
00324                 *pNewRun = *pFormatRider;
00325                 pNewRun->iLen      -= iSetPos - iFormatPos;
00326                 pFormatRider->iLen  = iSetPos - iFormatPos;
00327                 pFormatRider->pNext = pNewRun;
00328
00329                 pNewRun = new RUN;          // Create inserted run
00330                 *pNewRun = *pFormatRider;
00331                 pNewRun->iLen = iSetLen;
00332                 pNewRun->iStyle = iSetStyle;
00333                 pFormatRider->pNext = pNewRun;
00334             }
00335             else
00336             {
00337                 // New style is between this run and the next run
00338                 if (    pFormatRider->pNext
00339                     &&  pFormatRider->pNext->iStyle == iSetStyle)
00340                 {
00341                     // New style is same as adjacent following run
00342                     pFormatRider->pNext->iLen += iSetLen;
00343                 }
00344                 else
00345                 {
00346                     // Create new run between current run and next run
00347                     pNewRun = new RUN;
00348                     *pNewRun = *pFormatRider;
00349                     pNewRun->iStyle = iSetStyle;
00350                     pNewRun->iLen   = iSetLen;
00351                     pFormatRider->pNext = pNewRun;
00352                 }
00353             }
00354         }
00355     }
00356 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IUPnPService_DimmingService_SCPD Member List

This is the complete list of members for IUPnPService_DimmingService_SCPD, including all inherited members.
dimLevel([out, retval] long *pdimLevel) | IUPnPService_DimmingService_SCPD
GetConfigDetails([in, out] VARIANT_BOOL *ppowerVal,[in, out] long *pdLevel) | IUPnPService_DimmingService_SCPD
GetDimLevel([in, out] long *pdLevel) | IUPnPService_DimmingService_SCPD
GetPowerValue([in, out] VARIANT_BOOL *ppowerVall) | IUPnPService_DimmingService_SCPD
Power([out, retval] VARIANT_BOOL *pPower) | IUPnPService_DimmingService_SCPD
PowerOff() | IUPnPService_DimmingService_SCPD
PowerOn() | IUPnPService_DimmingService_SCPD
SetDimLevel([in] long dLevel) | IUPnPService_DimmingService_SCPD
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/vcAcct/CMoveMoney.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • vcAcct

CMoveMoney.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc19.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\mssdk\samples\com\Services\Transaction\SampleBank\vcacct\release\vcacct.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package vcacct;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.class(classid=04CF0B7B-1989-11D0-B917-0080C7394688,DynamicCasts)
00019     @com.interface(iid=04CF0B77-1989-11D0-B917-0080C7394688, thread=AUTO, type=DUAL) */
00020 public class CMoveMoney implements IUnknown,com.ms.com.NoAutoScripting,vcacct.IMoveMoney
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=METHOD, name="Perform", addFlagsVtable=4)
00023       @com.parameters([in,type=I4] lPrimeAccount, [in,type=I4] lSecondAccount, [in,type=I4] lAmount, [in,type=I4] lTranType, [type=STRING] return) */
00024   public native String Perform(int lPrimeAccount, int lSecondAccount, int lAmount, int lTranType);
00025
00026
00027   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x4cf0b77, (short)0x1989, (short)0x11d0, (byte)0xb9, (byte)0x17, (byte)0x0, (byte)0x80, (byte)0xc7, (byte)0x39, (byte)0x46, (byte)0x88);
00028
00029   public static final com.ms.com._Guid clsid = new com.ms.com._Guid((int)0x4cf0b7b, (short)0x1989, (short)0x11d0, (byte)0xb9, (byte)0x17, (byte)0x0, (byte)0x80, (byte)0xc7, (byte)0x39, (byte)0x46, (byte)0x88);
00030 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpwizard/SCPWiz.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpwizard

SCPWiz.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       SCPWiz.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // SCPWiz.h : Declaration of the CSCPWiz
00012
00013 #ifndef __SCPWIZ_H
00014 #define __SCPWIZ_H
00015
00016 #include "resource.h"       // main symbols
00017 #include "SCPWizard.h"
00018 #include "SCPPageUI.h"
00019
00020
00021 ////////////////////////////////////////////////////////////////////////////////
00022 // CSCPWiz
00023 //
00024 // This class implements the interface needed for a primary wizard extension
00025 // for DS Admin.
00026 //
00027 ////////////////////////////////////////////////////////////////////////////////
00028
00029 class /*ATL_NO_VTABLE*/ CSCPWiz :
00030   public CComObjectRootEx<CComSingleThreadModel>,
00031   public IDsAdminNewObjExt,
00032   public CComCoClass<CSCPWiz, &CLSID_SCPWizard>
00033 {
00034 public:
00035   CSCPWiz()
00036   {
00037     m_hObjClassIcon = NULL;
00038     m_pWizPage1 = NULL;
00039     m_pWizPage2 = NULL;
00040     m_pWizPage3 = NULL;
00041   }
00042
00043   ~CSCPWiz()
00044   {
00045     if (m_pWizPage1 != NULL)
00046       delete m_pWizPage1;
00047
00048     if (m_pWizPage2 != NULL)
00049       delete m_pWizPage2;
00050
00051     if (m_pWizPage3 != NULL)
00052       delete m_pWizPage3;
00053   }
00054
00055
00056 BEGIN_COM_MAP(CSCPWiz)
00057   COM_INTERFACE_ENTRY(IDsAdminNewObjExt)
00058 END_COM_MAP()
00059
00060
00061 public:
00062   DECLARE_REGISTRY_CLSID();
00063
00064   //
00065   // IDsAdminNewObjExt interface
00066   //
00067   STDMETHOD(Initialize)(IADsContainer* pADsContainerObj,
00068                         IADs* pADsCopySource,
00069                         LPCWSTR lpszClassName,
00070                         IDsAdminNewObj* pDsAdminNewObj,
00071                         LPDSA_NEWOBJ_DISPINFO pDispInfo);
00072
00073   STDMETHOD(AddPages)(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
00074   STDMETHOD(SetObject)(IADs* pADsObj);
00075   STDMETHOD(WriteData)(HWND hWnd, ULONG uContext);
00076   STDMETHOD(OnError)(HWND hWnd, HRESULT hr, ULONG uContext);
00077   STDMETHOD(GetSummaryInfo)(BSTR* pBstrText);
00078
00079   //
00080   // Helper functions
00081   //
00082   HRESULT WriteDataHelper();
00083
00084   //
00085   // accessor functions
00086   //
00087   IADs* GetObj() { return m_spADsObj;}
00088   void SetObj(IADs* pADsObj) { m_spADsObj = pADsObj;}
00089   IADsContainer* GetContainer() { return m_spADsContainerObj;}
00090   IDsAdminNewObj* GetIDsAdminNewObj() { return m_spDsAdminNewObj;}
00091   IDsAdminNewObjPrimarySite* GetIDsAdminNewObjPrimarySite() { return m_spDsAdminNewObjPrimarySite; }
00092
00093   IADs* GetCopySourceObj() { return m_spADsCopySourceObj;}
00094
00095   LPCWSTR GetClassName() { return m_szClassName;}
00096   LPCWSTR GetContainerCanonicalName() { return m_szContCanonicalName;}
00097   HICON   GetClassIcon() { return m_hObjClassIcon;}
00098   LPCWSTR GetTitle() { return m_szTitle;}
00099   void GetDefaultSummary(CString& s);
00100
00101 private:
00102   //
00103   // container for object creation, passed to IDsAdminNewObjExt::Initialize()
00104   //
00105   CComPtr<IADsContainer> m_spADsContainerObj;
00106
00107   //
00108   // object under creation, passed to IDsAdminNewObjExt::SetObject()
00109   //
00110   CComPtr<IADs> m_spADsObj;
00111
00112   //
00113   // if present, cached pointer to the source (for copy operation)
00114   //
00115   CComPtr<IADs> m_spADsCopySourceObj;
00116
00117   //
00118   // interface to the DS admin Object creation site
00119   //
00120   CComPtr<IDsAdminNewObj> m_spDsAdminNewObj;
00121
00122   //
00123   // interface to the DS admin Object creation primary site
00124   //
00125   CComPtr<IDsAdminNewObjPrimarySite> m_spDsAdminNewObjPrimarySite;
00126
00127 protected:
00128   //
00129   // class name the extension called for, passed to IDsAdminNewObjExt::Initialize()
00130   //
00131   CString m_szClassName;
00132
00133   //
00134   // display information passed to ::Initialize() in the LPDSA_NEWOBJ_DISPINFO struct
00135   //
00136   CString m_szTitle;
00137   CString m_szContCanonicalName;
00138   HICON   m_hObjClassIcon;
00139
00140   //
00141   // The classes that handle the user interface for the creation wizard
00142   //
00143   CSCPPageGeneral*      m_pWizPage1;
00144   CSCPPageBindingInfo*  m_pWizPage2;
00145   CSCPPageKeywords*     m_pWizPage3;
00146 };
00147
00148
00149 #endif //__SCPWIZ_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/inc/IsapiStringW.h Source File

  • Web
  • iis
  • ISAPI_6.0
  • inc

IsapiStringW.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: IsapiString.h
00006
00007 Abstract:
00008
00009     A simple string class build on
00010     the ISAPI_BUFFER class
00011
00012 Author:
00013
00014     ISAPI developer (Microsoft employee), October 2002
00015
00016 --*/
00017
00018 #ifndef _isapistringw_h
00019 #define _isapistringw_h
00020
00021 #include <IsapiTools.h>
00022
00023 class ISAPI_STRINGW
00024 {
00025 public:
00026
00027     ISAPI_STRINGW(
00028         DWORD   dwMaxAlloc = 0
00029         );
00030
00031     virtual
00032     ~ISAPI_STRINGW();
00033
00034     BOOL
00035     Copy(
00036         WCHAR * szStringW,
00037         DWORD   cchStringW = 0
00038         );
00039
00040     BOOL
00041     CopyA(
00042         CHAR *  szString,
00043         DWORD   cchString = 0
00044         );
00045
00046     BOOL
00047     Append(
00048         WCHAR * szStringW,
00049         DWORD   cchStringW = 0
00050         );
00051
00052     BOOL
00053     AppendA(
00054         CHAR *  szString,
00055         DWORD   cchString = 0
00056         );
00057
00058     BOOL
00059     Printf(
00060         WCHAR * szStringW,
00061         ...
00062         );
00063
00064     BOOL
00065     Vsprintf(
00066         WCHAR * szFormatW,
00067         va_list args
00068         );
00069
00070     VOID
00071     CalcLen(
00072         VOID
00073         );
00074
00075     DWORD
00076     QueryCB(
00077         VOID
00078         );
00079
00080     DWORD
00081     QueryCCH(
00082         VOID
00083         );
00084
00085     BOOL
00086     SetLen(
00087         DWORD   cchNewLength
00088         );
00089
00090     DWORD
00091     QueryBufferSize(
00092         VOID
00093         );
00094
00095     BOOL
00096     ResizeBuffer(
00097         DWORD   cbSize
00098         );
00099
00100     DWORD
00101     QueryMaxAlloc(
00102         VOID
00103         );
00104
00105     VOID
00106     SetMaxAlloc(
00107         DWORD   dwMaxAlloc
00108         );
00109
00110     WCHAR *
00111     QueryStr(
00112         VOID
00113         );
00114
00115 private:
00116
00117     ISAPI_BUFFER    _Buffer;
00118
00119     BOOL
00120     CopyToOffset(
00121         WCHAR * szStringW,
00122         DWORD   cchStringW,
00123         DWORD   cchOffset
00124         );
00125
00126     BOOL
00127     CopyAToOffset(
00128         CHAR *  szString,
00129         DWORD   cchString,
00130         DWORD   cchOffset
00131         );
00132 };
00133
00134 #endif  // _isapistringw_h
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/ShutdownDlg.Cpp Source File

  • WinBase
  • WtsApi
  • WtsApi

ShutdownDlg.Cpp

Go to the documentation of this file.
00001 // ShutdownDlg.cpp : implementation file
00002 //
00003 //  Copyright 1995-1998, Citrix Systems Inc.
00004 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00005
00006
00007 #include "stdafx.h"
00008 #include "API.h"
00009 #include "APIDoc.h"
00010 #include "ShutdownDlg.h"
00011 //#include "wtsapi32.h"
00012
00013 #ifdef _DEBUG
00014 #define new DEBUG_NEW
00015 #undef THIS_FILE
00016 static char THIS_FILE[] = __FILE__;
00017 #endif
00018
00019
00020 Shutdown ShutdownItems[5] =
00021 {
00022   {TEXT("Delete WinStations"), WTS_WSD_LOGOFF},
00023   {TEXT("Normal Shutdown"), WTS_WSD_SHUTDOWN},
00024   {TEXT("Reboot after Shutdown"), WTS_WSD_REBOOT},
00025   {TEXT("Power off computer after shutdown"), WTS_WSD_POWEROFF},
00026   {TEXT("CTRL-SHIFT-ALT-DEL fast reboot"), WTS_WSD_FASTREBOOT}
00027 };
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CShutdownDlg dialog
00031
00032
00033 CShutdownDlg::CShutdownDlg(CWnd* pParent /*=NULL*/)
00034   : CDialog(CShutdownDlg::IDD, pParent)
00035 {
00036   //{{AFX_DATA_INIT(CShutdownDlg)
00037     // NOTE: the ClassWizard will add member initialization here
00038   //}}AFX_DATA_INIT
00039 }
00040
00041
00042 void CShutdownDlg::DoDataExchange(CDataExchange* pDX)
00043 {
00044   CDialog::DoDataExchange(pDX);
00045   //{{AFX_DATA_MAP(CShutdownDlg)
00046   DDX_Control(pDX, IDC_SERVERNAME, m_serverName);
00047   DDX_Control(pDX, IDC_SHUTDOWN_PARAMETERS, m_shutdown);
00048   //}}AFX_DATA_MAP
00049 }
00050
00051
00052 BEGIN_MESSAGE_MAP(CShutdownDlg, CDialog)
00053   //{{AFX_MSG_MAP(CShutdownDlg)
00054   ON_BN_CLICKED(IDSHUTDOWN, OnShutdown)
00055   //}}AFX_MSG_MAP
00056 END_MESSAGE_MAP()
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 // CShutdownDlg message handlers
00060
00061 BOOL CShutdownDlg::OnInitDialog()
00062 {
00063   CDialog::OnInitDialog();
00064
00065   serverName = g_pDoc->GetServerName();
00066   //AfxMessageBox(serverName);
00067   serverHandle = WTSOpenServer(serverName);
00068
00069   CString serverDisplay;
00070   serverDisplay = "Shutdown parameters for ";
00071   if (*serverName == NULL)
00072     serverDisplay += "local server";
00073   else
00074     serverDisplay += serverName;
00075   m_serverName.SetWindowText(serverDisplay);
00076
00077   for (int i=0; i < MAXSHUTDOWNITEMS; i++)
00078     m_shutdown.InsertString(i, ShutdownItems[i].ShutdownName);
00079   m_shutdown.SetCurSel(0);
00080   return TRUE;
00081 }
00082
00083
00084 void CShutdownDlg::OnShutdown()
00085 {
00086   int nIndex = m_shutdown.GetCurSel();
00087   if (!WTSShutdownSystem(serverHandle, ShutdownItems[nIndex].ShutdownFlag))
00088     AfxMessageBox("Unable to shutdown system");
00089   EndDialog(0);
00090 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::_Record Member List

This is the complete list of members for msado15::_Record, including all inherited members.
Cancel() | msado15::_Record |
Close() | msado15::_Record |
CopyRecord(String Source, String Destination, String UserName, String Password, int Options, boolean Async) | msado15::_Record |
DeleteRecord(String Source, boolean Async) | msado15::_Record |
getActiveConnection() | msado15::_Record |
GetChildren() | msado15::_Record |
getFields() | msado15::_Record |
getMode() | msado15::_Record |
getParentURL() | msado15::_Record |
getProperties() | msado15::_Record |
getRecordType() | msado15::_Record |
getSource() | msado15::_Record |
getState() | msado15::_Record |
iid | msado15::_Record | [static]
MoveRecord(String Source, String Destination, String UserName, String Password, int Options, boolean Async) | msado15::_Record |
Open(Variant Source, Variant ActiveConnection, int Mode, int CreateOptions, int Options, String UserName, String Password) | msado15::_Record |
setActiveConnection(String pvar) | msado15::_Record |
setActiveConnection(msado15._Connection pvar) | msado15::_Record |
setMode(int pMode) | msado15::_Record |
setSource(String pvar) | msado15::_Record |
setSource(Object pvar) | msado15::_Record |
Generated on Wed Nov 13 2024 16:58:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EdAnnotator/AnnotatorProject/StdAfx.cpp Source File

  • Web
  • Browser
  • EdAnnotator
  • AnnotatorProject

StdAfx.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // stdafx.cpp : source file that includes just the standard includes
00006 //  stdafx.pch will be the pre-compiled header
00007 //  stdafx.obj will contain the pre-compiled type information
00008
00009 #include "stdafx.h"
00010
00011 #ifdef _ATL_STATIC_REGISTRY
00012 #include <statreg.h>
00013 #include <statreg.cpp>
00014 #endif
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/CascadeEvent/Cascadeec/INewsEvent.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • CascadeEvent
  • Cascadeec

INewsEvent.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc11E.tmp" /nologo /d "D:\ComPlusSamples\Source\LCE\CascadeEvent" "D:\ComPlusSamples\Source\LCE\CascadeEvent\CascadeEC.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package cascadeec;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface INewsEvent
00019 /** @com.interface(iid=4BF5E480-A5D3-11D2-AD4D-0080C7BFF6DB, thread=AUTO, type=DUAL) */
00020 public interface INewsEvent extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=1, type=METHOD, name="NewsFlash", addFlagsVtable=4)
00023       @com.parameters([in,type=DATE] dtTimeStamp, [in,type=STRING] Symbol, [in,type=STRING] Headline, [in,type=STRING] URL) */
00024   public void NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL);
00025
00026   /** @com.method(vtoffset=5, dispid=2, type=METHOD, name="ShortQuote", addFlagsVtable=4)
00027       @com.parameters([in,type=STRING] Symbol, [in,type=R8] BidPrice, [in,type=R8] AskPrice, [in,type=DATE] LastTradeTime, [in,type=R8] LastTradePrice, [in,type=R8] NetChange, [in,type=R8] DailyHigh, [in,type=R8] DailyLow) */
00028   public void ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow);
00029
00030   /** @com.method(vtoffset=6, dispid=3, type=METHOD, name="LongQuote", addFlagsVtable=4)
00031       @com.parameters([in,type=STRING] Symbol, [in,type=R8] BidPrice, [in,type=R8] AskPrice, [in,type=STRING] LastTradeTime, [in,type=R8] LastTradePrice, [in,type=R8] NetChange, [in,type=R8] DailyHigh, [in,type=R8] DailyLow, [in,type=I4] AskSize, [in,type=I4] BidSize, [in,type=R8] OpenPrice, [in,type=R8] ClosePrice, [in,type=STRING] CloseDate) */
00032   public void LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate);
00033
00034
00035   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x4bf5e480, (short)0xa5d3, (short)0x11d2, (byte)0xad, (byte)0x4d, (byte)0x0, (byte)0x80, (byte)0xc7, (byte)0xbf, (byte)0xf6, (byte)0xdb);
00036 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Ras/RasEnumConnections/c/RasEnumConnections.c Source File

  • NetDS
  • Ras
  • RasEnumConnections
  • c

RasEnumConnections.c

Go to the documentation of this file.
00001 //
00002 //       This is a part of the Microsoft Source Code Samples.
00003 //       Copyright 1993 - 2002 Microsoft Corporation.
00004 //       All rights reserved.
00005 //       This source code is only intended as a supplement to
00006 //       Microsoft Development Tools and/or WinHelp documentation.
00007 //       See these sources for detailed information regarding the
00008 //       Microsoft samples programs.
00009 //
00010
00011 //
00012 //    RasEnumConnections.c
00013 //
00014 //    Usage:
00015 //    RasEnumConnections
00016 //
00017 //    RAS API's used:
00018 //        RasEnumConnections
00019 //
00020 #ifndef _WIN32_WINNT
00021 #define _WIN32_WINNT 0x500
00022 #endif
00023
00024
00025 #include <windows.h>
00026 #include <stdio.h>
00027 #include <ras.h>
00028 #include <raserror.h>
00029 #include <tchar.h>
00030
00031 // Macro for counting maximum characters that will fit into a buffer
00032 #define CELEMS(x) ((sizeof(x))/(sizeof(x[0])))
00033
00034 int main(void)
00035 {
00036   DWORD   dwRet = 0;
00037   LPRASCONN lpRasConn = NULL;
00038   LPRASCONN   lpTempRasConn = NULL;
00039     DWORD   cb = sizeof(RASCONN);
00040   DWORD   dwConnections = 0;
00041   DWORD   i = 0;
00042     BOOL        fSuccess = FALSE;
00043     TCHAR       szTempBuf[256] = {0};
00044
00045   // Allocate buffer with space for at least one structure
00046   lpRasConn = (LPRASCONN)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00047   if (NULL == lpRasConn)
00048   {
00049     printf("HeapAlloc failed.\n");
00050     return ERROR_OUTOFMEMORY;
00051   }
00052
00053   lpRasConn->dwSize = sizeof(RASCONN);
00054
00055   dwRet = RasEnumConnections(lpRasConn, &cb, &dwConnections);
00056
00057   switch (dwRet) // Check whether RasEnumConnections succeeded
00058   {
00059   case ERROR_BUFFER_TOO_SMALL: // Since initial buffer allocation was small.
00060     if (HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasConn)) // Free initial buffer
00061         {
00062         // And reassign a new buffer with the value returned in cb
00063           lpRasConn = (LPRASCONN)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
00064         if (NULL == lpRasConn)
00065         {
00066           printf("HeapAlloc failed.\n");
00067           return ERROR_OUTOFMEMORY;
00068         }
00069
00070         lpRasConn->dwSize = sizeof(RASCONN);
00071
00072         // Again call RasEnumConnections
00073         dwRet = RasEnumConnections(lpRasConn, &cb, &dwConnections);
00074         if (ERROR_SUCCESS == dwRet)
00075         {
00076                 fSuccess = TRUE;
00077             }
00078             else
00079             {
00080                 // RasEnumConnections failed
00081           printf("RasEnumConnections failed: Error = %d\n", dwRet);
00082             goto done;
00083         }
00084         }
00085         else
00086         {
00087             printf("HeapFree failed.\n");
00088             goto done;
00089         }
00090     break;
00091
00092   case ERROR_SUCCESS: // RasEnumConnections succeeded with intial buffer allocation.
00093     fSuccess = TRUE;
00094     break;
00095
00096   default: // RasEnumConnections failed with some error.
00097     printf("RasEnumConnections failed: Error = %d\n", dwRet);
00098     break;
00099   }
00100
00101     if (fSuccess)
00102     {
00103
00104
00105         // RasEnumConnections succeeded. Print the results.
00106     printf("The following RAS connections are currently active\n\n");
00107     lpTempRasConn = lpRasConn;
00108     for (i = 0; i < dwConnections; i++)
00109     {
00110       printf("Size: %d\n", lpTempRasConn->dwSize);
00111
00112             ZeroMemory((LPVOID)szTempBuf, sizeof(szTempBuf));
00113             _snprintf(szTempBuf, CELEMS(szTempBuf) - 1, "Entry name: %s\n", lpTempRasConn->szEntryName);
00114       printf(szTempBuf);
00115
00116             ZeroMemory((LPVOID)szTempBuf, sizeof(szTempBuf));
00117             _snprintf(szTempBuf, CELEMS(szTempBuf) - 1, "Device name: %s\n", lpTempRasConn->szDeviceName);
00118       printf(szTempBuf);
00119       lpTempRasConn++;
00120     }
00121     }
00122
00123 done:
00124     HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasConn);
00125   return (int)dwRet;
00126 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/ComDlg32/Resource.h Source File

  • WinUI
  • CommDlg
  • ComDlg32

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by comdlg32.RC
00004 //
00005 #define IDS_DIALOGFAILURE               1
00006 #define IDS_STRUCTSIZE                  2
00007 #define IDS_INITIALIZATION              3
00008 #define IDS_NOTEMPLATE                  4
00009 #define IDS_NOHINSTANCE                 5
00010 #define IDS_LOADSTRFAILURE              6
00011 #define IDS_FINDRESFAILURE              7
00012 #define IDS_LOADRESFAILURE              8
00013 #define IDS_LOCKRESFAILURE              9
00014 #define IDS_MEMALLOCFAILURE             10
00015 #define IDS_MEMLOCKFAILURE              11
00016 #define IDS_NOHOOK                      12
00017 #define IDS_SETUPFAILURE                13
00018 #define IDS_PARSEFAILURE                14
00019 #define IDS_RETDEFFAILURE               15
00020 #define IDS_LOADDRVFAILURE              16
00021 #define IDS_GETDEVMODEFAIL              17
00022 #define IDS_INITFAILURE                 18
00023 #define IDS_NODEVICES                   19
00024 #define IDS_NODEFAULTPRN                20
00025 #define IDS_DNDMMISMATCH                21
00026 #define IDS_CREATEICFAILURE             22
00027 #define IDS_PRINTERNOTFOUND             23
00028 #define IDS_NOFONTS                     24
00029 #define IDS_SUBCLASSFAILURE             25
00030 #define IDS_INVALIDFILENAME             26
00031 #define IDS_BUFFERTOOSMALL              27
00032 #define IDS_FILTERSTRING                28
00033 #define IDS_UNKNOWNERROR                29
00034 #define IDD_COMDLG32                    100
00035 #define IDE_PATH                        102
00036 #define IDM_FILEOPEN                    106
00037 #define IDM_EXIT                        107
00038 #define IDM_ABOUT                       108
00039 #define IDD_ABOUT                       113
00040 #define IDE_SELECTED                    1022
00041 #define IDC_STATIC                      -1
00042
00043 // Next default values for new objects
00044 //
00045 #ifdef APSTUDIO_INVOKED
00046 #ifndef APSTUDIO_READONLY_SYMBOLS
00047 #define _APS_NEXT_RESOURCE_VALUE        114
00048 #define _APS_NEXT_COMMAND_VALUE         109
00049 #define _APS_NEXT_CONTROL_VALUE         1023
00050 #define _APS_NEXT_SYMED_VALUE           101
00051 #endif
00052 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

REGENTRY Member List

This is the complete list of members for REGENTRY, including all inherited members.
hRootKey | REGENTRY
szKeyName | REGENTRY
szValue | REGENTRY
szValueName | REGENTRY
Generated on Wed Nov 13 2024 16:57:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/CConnectionPT.cpp Source File

  • Com
  • async
  • server

CConnectionPT.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include <olectl.h>
00018 #include "DComServer.h"
00019 #include "CEnumXXX.h"
00020 #include "proxy.h"
00021 #include "Debug.h"
00022
00023 class CEnumConnections :
00024   public CEnumXXX<CEnumConnections, CONNECTDATA, IEnumConnections>
00025 {
00026 private:
00027   CEnumConnections();
00028   CEnumConnections(const CEnumConnections&);
00029   CEnumConnections& operator=(const CEnumConnections&);
00030   CEnumConnections* operator&();
00031   CEnumConnections* operator&() const;
00032
00033 public:
00034   bool __stdcall Copy(CONNECTDATA* connLeft, CONNECTDATA &connRight);
00035   void __stdcall FinalRelease();
00036   CEnumConnections(LPUNKNOWN lpUnk, DWORD nCount);
00037   ~CEnumConnections();
00038 };
00039
00040
00041 class CEnumConnectionPoints :
00042   public CEnumXXX<CEnumConnectionPoints, LPCONNECTIONPOINT, IEnumConnectionPoints>
00043 {
00044 private:
00045   CEnumConnectionPoints();
00046   CEnumConnectionPoints(const CEnumConnectionPoints&);
00047   CEnumConnectionPoints& operator=(const CEnumConnectionPoints&);
00048   CEnumConnectionPoints* operator&();
00049   CEnumConnectionPoints* operator&() const;
00050
00051 public:
00052   bool __stdcall Copy(LPCONNECTIONPOINT* lpCPLeft, LPCONNECTIONPOINT lpCPRight);
00053   virtual void __stdcall FinalRelease();
00054   CEnumConnectionPoints(LPUNKNOWN lpUnk, DWORD nCount);
00055   ~CEnumConnectionPoints();
00056 };
00057
00058 /*
00059  * CEnumConnectionPoints::AddRef() will call ConnectionPointContainer::AddRef() to ensure that
00060  * CEnumConnectionPoints::Next() is able to return valid "sinks" owned by ConnectionPointContainer
00061  * This is reversed in CEnumConnectionPoints::Release()
00062
00063  * Since CConnectionPointContainer owns the interface CConnectionPoint it
00064  * will AddRef itself whenever it gives out this interface such as in
00065  * CConnectionPointContainer::FindConnectionPoint(). The other place where
00066  * CConnectionPoint can be given out is in CEnumConnectionPoints::Next().
00067
00068  *  ~CConnectionPointContainer() is where the array of CConnectionPoint is
00069  * freed. CConnectionPoint::Release() will not free itself since it must
00070  * maintain a back pointer to CConnectionPointContainer in order to insure
00071  * that CConnectionPoint::GetConnectionPointContainer() can return the
00072  * CConnectionPointContainer. And CConnectionPointContainer must maintain a
00073  * back pointer to CConnectionPoint in order for CConnectionPointContainer::FindConnectionPoint()
00074  * to be able to return a valid pointer. This catch 22 means that one of these
00075  * interfaces must be god and own the other.
00076
00077 CHECKCHECK: NoExternalConnection is nosense
00078
00079  * In CConnectionPoint::Release when the refcount drops to zero it will
00080  * signal this to CConnectPointContainer via NoExternalConnection. If
00081  * NoExternalConnection finds CConnectionPointContainers refcount to be
00082  * zero then it will delete CConnectionPoint and then itself.
00083  * CConnectionPoint::Release can not free itself since
00084  * CConnectPointContainer holds on a array of these CConnectionPoints
00085  */
00086 CConnectionPointContainer::CConnectionPointContainer() : m_cookie(0), m_cCP(0), m_prgEventIID(NULL), m_prgCP(NULL)
00087 {
00088   DEBUGTRACE(_T("In CConnectionPointContainer ctor"));
00089 }
00090
00091
00092 bool __stdcall CConnectionPointContainer::Init(EventID& events)
00093 {
00094   m_cCP = events.cEventID;
00095   m_prgCP = new CConnectionPoint*[m_cCP];
00096   m_prgEventIID = new IID[m_cCP];
00097   for (DWORD i = 0; i < m_cCP; i++)
00098   {
00099 #if 0
00100     LPOLESTR lpstr;
00101     StringFromIID(events.EventIDs[i], &lpstr);
00102     DEBUGTRACE(_T("passing [%S] to CConnectionPoint ctor"), lpstr);
00103     CoTaskMemFree(lpstr);
00104 #endif
00105     CConnectionPoint *cp = new CConnectionPoint(this, events.EventIDs[i]);
00106     _ASSERT(cp);
00107     m_prgCP[i] = cp;
00108     m_prgEventIID[i] = events.EventIDs[i];
00109   }
00110   return true;
00111 }
00112
00113 /* Since CConnectionPointContainer maintainers ownership of the CConnnectionPoint pointers rather
00114  * than the usual method where each class owns itself we need to explicitly delete these when
00115  * destroying itself
00116  */
00117 CConnectionPointContainer::~CConnectionPointContainer()
00118 {
00119   DEBUGTRACE(_T("In CConnectionPointContainer dtor"));
00120   for (DWORD i = 0; i < m_cCP; i++)
00121     delete m_prgCP[i];
00122   delete [] m_prgEventIID;
00123   delete [] m_prgCP;
00124 }
00125
00126
00127 /*
00128  * Helper function to give the COM object the ConnectionPoint for a specific IID.
00129  * Typically the object would then use this connection point interface to access
00130  * the SignalEvent method of the connection point to notify the sink that a
00131  * specific event of interest has occured.
00132  *
00133  *
00134  * Note the ConnectionPoint interface returned from this method can only be use
00135  * for a "One" use scenario.
00136  *
00137  * i.e. cpc->GetConnectionPont(iid)->SignalEvent(...)
00138  *
00139  * If for some reason you must keep this interface around for a length of time you
00140  * must addref the returned interface.
00141  */
00142 CConnectionPoint* __stdcall CConnectionPointContainer::GetConnectionPoint(REFIID iid)
00143 {
00144 /*
00145  * TODO: What this code should be doing is searching through a list of supported source IID's
00146  */
00147   if (iid == IID_AppEvents)
00148     return m_prgCP[0];
00149
00150   return NULL;
00151 }
00152
00153 HRESULT __stdcall CConnectionPointContainer::EnumConnectionPoints(LPENUMCONNECTIONPOINTS *ppenum)
00154 {
00155   DEBUGTRACE(_T("In IConnectionPointContainer::EnumConnectionPoints"));
00156
00157   CHECKPOINTER(ppenum);
00158   LPCONNECTIONPOINT *elemlist = new LPCONNECTIONPOINT[m_cCP];
00159   for (DWORD i = 0; i < m_cCP; i++)
00160     elemlist[i] = m_prgCP[i]; // only a shallow copy is needed
00161
00162   CEnumConnectionPoints *penum = CEnumConnectionPoints::Create(this, m_cCP, elemlist); // elemlist is now owned by CEnumConnectionPoints
00163   _ASSERT(penum);
00164   HRESULT hr = penum->QueryInterface(IID_IEnumConnectionPoints, reinterpret_cast<PVOID*>(ppenum));
00165   return hr;
00166 }
00167
00168
00169 HRESULT __stdcall CConnectionPointContainer::FindConnectionPoint(REFIID iid, LPCONNECTIONPOINT *ppCP)
00170 {
00171   DEBUGTRACE(_T("In IConnectionPointContainer::FindConnectionPoint"));
00172   CHECKPOINTER(ppCP);
00173
00174   *ppCP = NULL;
00175   for (DWORD i = 0; i < m_cCP; i++)
00176     if (m_prgEventIID[i] == iid)
00177     {
00178       *ppCP = m_prgCP[i];
00179       (*ppCP)->AddRef();
00180       return S_OK;
00181     }
00182
00183   return CONNECT_E_NOCONNECTION;
00184 }
00185
00186   // CEnumConnectionPoints
00187
00188 CEnumConnectionPoints::CEnumConnectionPoints(LPUNKNOWN lpUnk, DWORD nCount) :
00189   CEnumXXX<CEnumConnectionPoints, LPCONNECTIONPOINT, IEnumConnectionPoints>(lpUnk, IID_IEnumConnectionPoints, nCount)
00190 {
00191   DEBUGTRACE(_T("In CEnumConnectionPoints ctor"));
00192 }
00193
00194
00195 CEnumConnectionPoints::~CEnumConnectionPoints()
00196 {
00197   DEBUGTRACE(_T("In CEnumConnectionPoints dtor"));
00198 }
00199
00200 bool __stdcall CEnumConnectionPoints::Copy(LPCONNECTIONPOINT* lpCPLeft, LPCONNECTIONPOINT lpCPRight)
00201 {
00202   DEBUGTRACE(_T("In CEnumConnectionPoints::Copy"));
00203   // data will have already been verified during creation no need to do so here
00204   *lpCPLeft = lpCPRight;
00205   (*lpCPLeft)->AddRef();
00206   return true;
00207 }
00208
00209 void __stdcall CEnumConnectionPoints::FinalRelease()
00210 {
00211   DEBUGTRACE(_T("In CEnumConnectionPoints::FinalRelease()"));
00212   CEnumXXX<CEnumConnectionPoints, LPCONNECTIONPOINT, IEnumConnectionPoints>::FinalRelease();
00213 }
00214
00215
00216
00217   // CConnectionPoint
00218 CConnectionPoint::CConnectionPoint(CConnectionPointContainer *pCPC, IID iid) :
00219   m_cookie(0), m_cRef(0), m_pCPC(pCPC), m_iid(iid), m_Adviselimit(2)
00220 {
00221   DEBUGTRACE(_T("In CConnectionPoint ctor"));
00222 #if 0
00223   LPOLESTR lpstr;
00224   StringFromIID(m_iid, &lpstr);
00225   DEBUGTRACE(_T("[%S] was passed in to CConnectionPoint ctor"), lpstr);
00226   CoTaskMemFree(lpstr);
00227 #endif
00228   _ASSERT(m_pCPC);
00229   for (DWORD i = 0; i < m_Adviselimit; i++)
00230     m_lpEventSink[i] = NULL;
00231 }
00232
00233 CConnectionPoint::~CConnectionPoint()
00234 {
00235   DEBUGTRACE(_T("In CConnectionPoint dtor"));
00236 }
00237   // IUnknown
00238 HRESULT __stdcall CConnectionPoint::QueryInterface(REFIID iid, PVOID *ppObj)
00239 {
00240   CHECKPOINTER(ppObj);
00241
00242   if (iid == IID_IUnknown || iid == IID_IConnectionPoint)
00243     *ppObj = this;
00244   else
00245   {
00246     *ppObj = NULL;
00247     return E_NOINTERFACE;
00248   }
00249
00250   if (*ppObj)
00251     reinterpret_cast<LPUNKNOWN>(*ppObj)->AddRef();
00252
00253   return S_OK;
00254 }
00255
00256 ULONG __stdcall CConnectionPoint::AddRef()
00257 {
00258   DEBUGTRACE(_T("In IConnectionPoint::AddRef refcounts = %i"), m_cRef+1);
00259 /*
00260  * Need to AddRef ConnectionPointContainer since it is what determines
00261  * the lifetime of CConnectionPoint interface. This will be countered
00262  * CConnectionPoint::Release()
00263  */
00264   m_pCPC->AddRef();
00265   return InterlockedIncrement(reinterpret_cast<PLONG>(&m_cRef));
00266 }
00267
00268 /* Note this class can not delete itself since CConnectionPointContainer
00269  * owns it. Instead what this will do is release all refcounts it added
00270  * on CConnectionPointContainer. These are added as a result of a
00271  * container setting up an event sink in Advise and will normally be
00272  * released when the container releases the sink in Unadvise. However for
00273  * those nasty containers which call Unadvise prior to releasing their
00274  * hold on this interface will do so for them.
00275  */
00276 ULONG __stdcall CConnectionPoint::Release()
00277 {
00278   _ASSERT(m_cRef > 0); // not thread safe
00279   DEBUGTRACE(_T("In IConnectionPoint::Release refcounts = %i"), m_cRef-1);
00280
00281   if (InterlockedDecrement(reinterpret_cast<PLONG>(&m_cRef)) == 0)
00282   {
00283     FinalRelease();
00284     return 0;
00285   }
00286   m_pCPC->Release();  // Release strong lock added in by the AddRef()
00287   return m_cRef;
00288 }
00289
00290 void __stdcall CConnectionPoint::FinalRelease()
00291 {
00292 #if 0 // HACK till I get the list for sinks interfaces
00293   _ASSERT(m_cookie == 0);
00294 #endif
00295   m_pCPC->Release();  // Release strong lock added in by the AddRef()
00296 }
00297
00298 /*
00299  *
00300  * Helper function used by the object which defined the source to notify the sink that
00301  * an event has occurred. The source needs to provide the IID of the source, the DISPID
00302  * to fire and the DISPARAMS to pass to the sink
00303  *
00304  */
00305 #if 0
00306 bool __stdcall CConnectionPoint::SignalEvent(DISPID dispid, DISPPARAMS* params)
00307 {
00308 /*
00309  * TODO:
00310  * 1) Verify the DISPID (optional?)
00311  * 2) Run through the table of connections sinks calling calling each of them
00312  */
00313   _ASSERT(params);
00314   if (m_cookie == 0) // No sink has been set up
00315     return false;
00316
00317   HRESULT hr;
00318
00319   for (DWORD i = 0; i < m_cookie; i++)
00320     hr = m_lpEventSink[i]->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
00321       params, NULL, NULL, NULL);
00322
00323   return SUCCEEDED(hr) ? true : false;
00324 }
00325 #endif
00326
00327
00328 /*
00329  *
00330  * SignalEvent is a very limited simple example of how to use COM "automatic completion" to achieve asynchronous events.
00331  * In other words the caller of event does not have to what till the callee has finished processing the event. This
00332  * allows the caller to fire off events to multiple calles without blocking. Unlike sychronous COM interfaces there is
00333  * no guarentee that a method call will reach the callee.
00334  *
00335  * As a consequence of recycling the Call factory, events which have [out] parameters are not valid.
00336  *
00337  * Note that the event interface is _not_ a dispinterface. The reason for this madness is that type library marshaling is not
00338  * supported in NT 5. This will also mean each "sink" will need to at least trivally implement all events on an interface
00339  *
00340  */
00341 bool __stdcall CConnectionPoint::SignalEvent()
00342 {
00343   if (m_cookie == 0) // No sink has been set up
00344     return false;
00345
00346   HRESULT hr;
00347   LPCALLFACTORY pCallF = NULL;
00348   AsyncAppEvents*  pAsyncTest = NULL;
00349   LPSYNCHRONIZE pSync = NULL;
00350
00351   for (DWORD i = 0; i < m_cookie; i++)
00352   {
00353     hr = m_lpEventSink[i]->QueryInterface(IID_ICallFactory, (PVOID*)&pCallF);
00354     _ASSERT(SUCCEEDED(hr) && pCallF);
00355     hr = pCallF->CreateCall(IID_AsyncAppEvents, NULL, IID_AsyncAppEvents, (LPUNKNOWN*)&pAsyncTest);
00356     _ASSERT(SUCCEEDED(hr) && pAsyncTest);
00357     hr = pAsyncTest->Begin_Beep(~0);
00358     RELEASEINTERFACE(pAsyncTest);
00359     RELEASEINTERFACE(pCallF);
00360   }
00361
00362   return SUCCEEDED(hr) ? true : false;
00363 }
00364
00365   // IConnectionPoint
00366 HRESULT __stdcall CConnectionPoint::GetConnectionInterface(IID *pIID)
00367 {
00368   DEBUGTRACE(_T("In IConnectionPoint::GetConnectionInterface"));
00369   CHECKPOINTER(pIID);
00370
00371   *pIID = m_iid;
00372   return S_OK;
00373 }
00374
00375 HRESULT __stdcall CConnectionPoint::GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *ppCPC)
00376 {
00377   DEBUGTRACE(_T("In IConnectionPoint::GetConnectionPointContainer"));
00378   CHECKPOINTER(ppCPC);
00379
00380   HRESULT hr = m_pCPC->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<PVOID*>(ppCPC));
00381   return hr;
00382 }
00383
00384 /*
00385  * Note lpUnk is a _in_ parameter this interface will automatically be freed upon exit
00386  */
00387 HRESULT __stdcall CConnectionPoint::Advise(LPUNKNOWN lpUnk, LPDWORD pdwCookie)
00388 {
00389
00390   DEBUGTRACE(_T("In IConnectionPoint::Advise"));
00391   CHECKPOINTER(pdwCookie && lpUnk);
00392
00393   if (m_cookie >= m_Adviselimit)
00394     return CONNECT_E_ADVISELIMIT;
00395
00396   HRESULT hr =lpUnk->QueryInterface(m_iid, reinterpret_cast<PVOID*>(&m_lpEventSink[m_cookie]));
00397   if (FAILED(hr))
00398     return hr == E_NOINTERFACE ? CONNECT_E_CANNOTCONNECT : hr;
00399
00400   // TODO Add to connection to list
00401   *pdwCookie = m_cookie++; // Running count of # of event sinks
00402   return S_OK;
00403 }
00404
00405 HRESULT __stdcall CConnectionPoint::Unadvise(DWORD dwCookie)
00406 {
00407   DEBUGTRACE(_T("In IConnectionPoint::Unadvise"));
00408
00409   // TODO Remove from list. If cookie does not match return E_UNEXPEC; otherwise do ...
00410   // decrement # of event sinks attached to the list
00411
00412   RELEASEINTERFACE(m_lpEventSink[dwCookie]);
00413   return S_OK;
00414 }
00415
00416 HRESULT __stdcall CConnectionPoint::EnumConnections(LPENUMCONNECTIONS *ppenum)
00417 {
00418   DEBUGTRACE(_T("In IConnectionPoint::EnumConnections"));
00419   CHECKPOINTER(ppenum);
00420
00421   CONNECTDATA* elemlist = new CONNECTDATA[m_cookie]; // m_cookie is running total of connections to this ConnectionPoint
00422   for (DWORD i = 0; i < m_cookie; i++)
00423   {
00424     elemlist[i].dwCookie = i;
00425     elemlist[i].pUnk = m_lpEventSink[i];
00426   }
00427
00428   CEnumConnections *penum = CEnumConnections::Create(this, m_cookie, elemlist);
00429   HRESULT hr = penum->QueryInterface(IID_IEnumConnections, reinterpret_cast<PVOID*>(ppenum));
00430   return hr;
00431 }
00432
00433
00434   // CEnumConnections
00435 CEnumConnections::CEnumConnections(LPUNKNOWN lpUnk, DWORD nCount) :
00436   CEnumXXX<CEnumConnections, CONNECTDATA, IEnumConnections>(lpUnk, IID_IEnumConnections, nCount)
00437
00438 {
00439   DEBUGTRACE(_T("In CEnumConnections ctor"));
00440 }
00441
00442 CEnumConnections::~CEnumConnections()
00443 {
00444   DEBUGTRACE(_T("In CEnumConnections dtor"));
00445 }
00446
00447 bool __stdcall CEnumConnections::Copy(CONNECTDATA* connLeft, CONNECTDATA& connRight)
00448 {
00449   DEBUGTRACE(_T("In CEnumConnections::Copy"));
00450   // data will have already been verified during creation no need to do so here
00451   *connLeft = connRight;
00452   (*connLeft).pUnk->AddRef();
00453   return true;
00454 }
00455
00456 void __stdcall CEnumConnections::FinalRelease()
00457 {
00458   DEBUGTRACE(_T("In CEnumConnections::FinalRelease()"));
00459   CEnumXXX<CEnumConnections, CONNECTDATA, IEnumConnections>::FinalRelease();
00460 }
00461
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/dataobj.h Source File

  • SysMgmt
  • MMC
  • Taskpads

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/dragdrop/foldernode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • dragdrop

foldernode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CFolderNode class.
00014 //
00015
00016
00017 #include "FolderNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020 #include "AddVFileDlg.h"
00021 #include "DataObj.h"
00022 #include "DeviceNode.h"
00023 #include "VirtualFIle.h"
00024                              // Tracing stuff
00025 #include "TraceMacro.h"
00026 #undef  MODULESTRING
00027 #define MODULESTRING  _T("CFolderNode")
00028
00029
00030 // Initialize our static GUID just once
00031 GUID CFolderNode::thisGUID = CLSID_CFolderNode;
00032
00033
00034 /////////////////////////////////////////////////////////////////////////////
00035 // Construction/Destruction
00036
00037 //---------------------------------------------------------------------------
00038 CFolderNode::CFolderNode()
00039 {
00040   m_SDI.mask        = DEFAULT_SDI_MASK;
00041   m_SDI.displayname = MMC_CALLBACK;
00042   m_SDI.nImage      = IMG_FOLDER_DEFAULT;
00043   m_SDI.nOpenImage  = IMG_FOLDER_DEFAULT;
00044   m_SDI.cChildren   = 0;              // Determines if the '+' is displayed
00045   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00046
00047   m_dwAttributes    = 0;
00048   m_pCompData       = NULL;
00049   m_hAddVFileDlg    = NULL;
00050   m_pParentNode     = NULL;
00051 }
00052
00053 //---------------------------------------------------------------------------
00054 CFolderNode::~CFolderNode()
00055 {
00056   RemoveNodes();             // Remove children if we are being deleted
00057
00058   if( NULL != m_hMessageWnd )
00059     DestroyWindow( m_hMessageWnd );
00060 }
00061
00062 //---------------------------------------------------------------------------
00063 HRESULT CFolderNode::Initialize
00064 (
00065   LPNODEPROPS  pNodeProps    //[in] Properties of this node
00066 )
00067 {
00068   _ASSERT( NULL != pNodeProps );
00069   HRESULT hResult = S_OK;
00070
00071   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00072   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00073   wcscpy( pszTmp, pNodeProps->szNodeName );
00074   if( NULL != m_pwszNodeName )
00075     CoTaskMemFree( m_pwszNodeName );
00076
00077   m_pwszNodeName = pszTmp;
00078   m_pCompData    = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00079   m_pParentNode  = reinterpret_cast<CDeviceNode*>(pNodeProps->pParentObject);
00080
00081   CVirtualFile* pNode  = NULL;
00082   LONG  nChildCount    = pNodeProps->nChildCount;
00083   LPCHILDPROPS pChProp = &pNodeProps->pChildProps;
00084   BYTE* pCounter = (BYTE*)pChProp;
00085
00086   if( INIT_DEFAULT_NODE == pNodeProps->nChildCount )
00087   {
00088     InitDefaultVFile();
00089   }
00090   else
00091   {
00092     pNodeProps->pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00093     pNodeProps->pParentObject  = reinterpret_cast<LONG_PTR>(this);
00094     pNodeProps->nChildCount    = 0;
00095
00096     // Create a new VirtualFile node for each ChildProperties struct
00097     // in the array
00098     //
00099     for( LONG nCount = 0; nCount < nChildCount; nCount++ )
00100     {
00101       wcscpy( pNodeProps->szNodeName, pChProp->szNodeName );
00102       pNodeProps->dwAttributes = pChProp->dwAttributes;
00103       pNode = new CVirtualFile;
00104       pNode->Initialize( pNodeProps );
00105       m_NodeList.AddTail( pNode );
00106       pCounter += sizeof(CHILDPROPS);
00107       pChProp = (LPCHILDPROPS)pCounter;
00108     }
00109   }
00110
00111   // We create a hidden window to allow us to communicate with modeless
00112   // dialogs and other objects which run in a seperate thread.
00113   //
00114   WNDCLASS wc;
00115   ZeroMemory(&wc, sizeof(WNDCLASS));
00116   wc.cbWndExtra    = sizeof(this);
00117   wc.lpfnWndProc   = FolderNodeWndProc;
00118   wc.hInstance     = g_hInst;
00119   wc.lpszClassName = _T("FolderNodeMessageWindow");
00120
00121   RegisterClass( &wc );
00122   m_hMessageWnd = CreateWindow( _T("FolderNodeMessageWindow"), NULL,
00123                                 0, 0, 0, 0, 0, NULL, 0, g_hInst, this);
00124
00125   if( NULL == m_hMessageWnd )
00126     hResult = S_FALSE;
00127
00128   return hResult;
00129 }
00130
00131
00132 //---------------------------------------------------------------------------
00133 //  This is our hidden window which is just used for handling messages.  We
00134 //  go to all this trouble so that we don't ever pass interface pointers or
00135 //  other objects across threads.
00136 //
00137 LRESULT CALLBACK CFolderNode::FolderNodeWndProc
00138 (
00139   HWND   hWnd,     //[in] Handle to window
00140   UINT   uMsg,     //[in] Message identifier
00141   WPARAM wParam,   //[in] First message parameter
00142   LPARAM lParam    //[in] Second message parameter
00143 )
00144 {
00145   switch( uMsg )
00146   {
00147     case WM_CREATE:
00148     {
00149       LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
00150       SetWindowLongPtr( hWnd, 0, (LONG_PTR)lpcs->lpCreateParams );
00151       break;
00152     }
00153
00154     case WM_ADD_VIRTUALFILE:
00155     {
00156       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00157       NODE_PROPERTIES* pProps = (NODE_PROPERTIES*)wParam;
00158       pThisNode->AddVirtualFile( pProps );
00159       break;
00160     }
00161
00162     case WM_VIRTUALFILE_CLOSED:
00163     {
00164       CFolderNode* pThisNode = (CFolderNode*)GetWindowLongPtr( hWnd, 0 );
00165       pThisNode->m_hAddVFileDlg = NULL;
00166       break;
00167     }
00168     default:
00169       return DefWindowProc( hWnd, uMsg, wParam, lParam );
00170   }
00171   return 0;
00172 }
00173
00174
00175 /////////////////////////////////////////////////////////////////////////////
00176 // Implementation of virtual methods
00177
00178
00179 //---------------------------------------------------------------------------
00180 //  DRAGDROP:  This method supports the CCF_NODEPROP_PTR clipboard format.
00181 //             The Node Properties struct is allocated in global memory so
00182 //             so that interproccess CUT/COPY/PASTE will work.
00183 //             The caller is responsible for freeing the memory.
00184 //
00185 HRESULT CFolderNode::GetProperties
00186 (
00187   LPNODEPROPS* ppNodeProps   //[out] Properties of this node
00188 )
00189 {
00190   _ASSERT( NULL == *ppNodeProps );
00191
00192   LONG nChildCount = m_NodeList.GetCount();
00193   LONG nBlockSize  = (nChildCount * sizeof(CHILDPROPS)) + sizeof(NODEPROPS);
00194
00195   HGLOBAL hMemBlock = NULL;
00196   hMemBlock = ::GlobalAlloc( GMEM_SHARE | GMEM_MOVEABLE, nBlockSize );
00197   if( NULL == hMemBlock )
00198     return E_OUTOFMEMORY;
00199
00200   hMemBlock = ::GlobalLock( hMemBlock );
00201   LPNODEPROPS pTmpProps = (LPNODEPROPS)hMemBlock;
00202
00203   ZeroMemory( pTmpProps, nBlockSize );
00204   wcscpy( pTmpProps->szNodeName,  m_pwszNodeName );
00205   pTmpProps->pComponentData = NULL;        // Pointers not used for DragDrop
00206   pTmpProps->pParentObject  = NULL;
00207   pTmpProps->dwAttributes   = m_dwAttributes;
00208   pTmpProps->nChildCount    = nChildCount;
00209   pTmpProps->nBlockSize     = nBlockSize;
00210
00211   LPCHILDPROPS pChProps = &pTmpProps->pChildProps;
00212   BYTE* pCounter = (BYTE*)&pTmpProps->pChildProps;
00213
00214   CVirtualFile* pNode = NULL;
00215   POSITION   Pos = m_NodeList.GetHeadPosition();
00216   while( Pos )
00217   {
00218     pNode = m_NodeList.GetNext( Pos );
00219     wcscpy( pChProps->szNodeName, pNode->GetNodeName() );
00220     pChProps->dwAttributes = pNode->GetAttributes();
00221     pCounter += sizeof(CHILDPROPS);    // Next element in the array
00222     pChProps = (LPCHILDPROPS)pCounter;
00223   }
00224
00225   ::GlobalUnlock( hMemBlock );
00226   *ppNodeProps = (LPNODEPROPS)hMemBlock;
00227
00228   return S_OK;
00229 }
00230
00231 //---------------------------------------------------------------------------
00232 //  The minimum implementation of this method is to return the
00233 //  Persistable View Description string.  This string must be allocated
00234 //  with CoTaskMemAlloc.  The console will free the string.
00235 //
00236 HRESULT CFolderNode::GetResultViewType2
00237 (
00238   MMC_COOKIE             nCookie,  //[in] Identifier of object
00239   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00240 )
00241 {
00242   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00243   if( NULL == pszDescStr )
00244     return E_OUTOFMEMORY;
00245
00246   wcscpy( pszDescStr, L"DefaultListView" );
00247   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00248
00249   pRVTinfo->eViewType     = MMC_VIEW_TYPE_LIST;
00250   pRVTinfo->dwListOptions = RVTI_LIST_OPTIONS_ALLOWPASTE;
00251
00252   return S_OK;
00253 }
00254
00255 //---------------------------------------------------------------------------
00256 HRESULT CFolderNode::GetDisplayInfo
00257 (
00258   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00259 )
00260 {
00261   _ASSERT( NULL != pSDI );
00262   pSDI->displayname = m_pwszNodeName;
00263
00264   return S_OK;
00265 }
00266
00267 //---------------------------------------------------------------------------
00268 HRESULT CFolderNode::GetDisplayInfo
00269 (
00270   RESULTDATAITEM* pRDI
00271 )
00272 {
00273   _ASSERT( NULL != pRDI );
00274
00275   HRESULT hResult = S_OK;
00276
00277   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00278   {                                  // for each column
00279     switch( pRDI->nCol )
00280     {
00281       case 0:
00282         pRDI->str = m_pwszNodeName;
00283         break;
00284
00285       case 1:                        // Attributes not supported yet
00286         pRDI->str = L"No attributes";
00287         break;
00288
00289       default:
00290         hResult = S_FALSE;
00291         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00292         break;
00293     }
00294   }
00295   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00296   {
00297     pRDI->nImage = m_SDI.nImage;
00298   }
00299
00300   //TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00301   return hResult;
00302
00303 }
00304
00305 /////////////////////////////////////////////////////////////////////////////
00306 // Implementation of notification handlers
00307
00308
00309 //---------------------------------------------------------------------------
00310 HRESULT CFolderNode::OnSelect
00311 (
00312   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00313   LPARAM        nArg,          //[in] Bools for context & selection state
00314   LPARAM        nParam,        //[in] Not used
00315   LONG_PTR      pComponent     //[in] Points calling CComponent
00316 )
00317 {
00318   HRESULT hResult    = S_FALSE;
00319   BOOL    fScopePane = LOWORD(nArg);
00320   BOOL    fSelected  = HIWORD(nArg);
00321
00322   if( TRUE == fSelected )
00323   {
00324     CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00325
00326     IConsoleVerb* ipConsoleVerb = NULL;
00327     hResult = pComp->GetInterface( REQUEST_ICONSOLEVERB, (LONG_PTR*)&ipConsoleVerb );
00328
00329     // DRAGDROP: Add MMC_VERB_CUT/COPY/PASTE for this object only
00330     hResult = ipConsoleVerb->SetVerbState( MMC_VERB_CUT,   ENABLED, TRUE );
00331     hResult = ipConsoleVerb->SetVerbState( MMC_VERB_COPY,  ENABLED, TRUE );
00332     hResult = ipConsoleVerb->SetVerbState( MMC_VERB_PASTE, ENABLED, TRUE );
00333
00334     // Enable Rename as well
00335     hResult = ipConsoleVerb->SetVerbState( MMC_VERB_RENAME, ENABLED, TRUE );
00336   }
00337
00338   //TRACE_HRESULT(_T("OnSelect"), hResult );
00339   return hResult;
00340 }
00341
00342
00343 //---------------------------------------------------------------------------
00344 HRESULT CFolderNode::OnShow
00345 (
00346   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00347   LPARAM        nArg,          //[in] TRUE if node was selcted
00348   LPARAM        nParam,        //[in] HSCOPEITEM of selected/deselected item
00349   LONG_PTR      pComponent     //[in] Points calling CComponent
00350 )
00351 {
00352   HRESULT  hResult = S_FALSE;
00353
00354   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00355
00356   LPHEADERCTRL2  ipHeaderCtrl = NULL;
00357   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL, (LONG_PTR*)&ipHeaderCtrl );
00358   if( S_OK != hResult )
00359     return hResult;
00360
00361   LPRESULTDATA  ipResultData = NULL;
00362   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00363   if( S_OK != hResult )
00364     return hResult;
00365
00366
00367   if( TRUE == nArg )         // Selecting a scope node
00368   {
00369     do
00370     {
00371       hResult = ipHeaderCtrl->InsertColumn( 0, L"File Name", 0, 150 );
00372       BREAK_ON_ERROR( hResult );
00373
00374       hResult = ipHeaderCtrl->InsertColumn( 1, L"Attributes", 0, 150 );
00375       BREAK_ON_ERROR( hResult );
00376
00377       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00378       BREAK_ON_ERROR( hResult );
00379
00380       hResult = EnumerateResultItems( ipResultData );
00381       BREAK_ON_ERROR( hResult );
00382
00383     }while(0);
00384   }
00385   else                       // Clean up result items on deselection
00386   {
00387     hResult = ipResultData->DeleteAllRsltItems();
00388   }
00389
00390   //TRACE_HRESULT(_T("OnShow"), hResult );
00391   return hResult;
00392 }
00393
00394 //---------------------------------------------------------------------------
00395 HRESULT CFolderNode::OnExpand
00396 (
00397   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00398   LPARAM         nArg,         //[in] TRUE if node was selcted
00399   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00400   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00401 )
00402 {
00403   HRESULT hResult = S_FALSE;
00404
00405   if( NULL == m_pCompData )
00406     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00407
00408   //TRACE_HRESULT( _T("OnExpand"), hResult );
00409   return hResult;              // Not expanding anything
00410 }
00411
00412 //---------------------------------------------------------------------------
00413 HRESULT CFolderNode::OnRemoveChildren
00414 (
00415   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00416   LPARAM         nArg,         //[in] TRUE if node was selcted
00417   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00418   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00419 )
00420 {
00421   HRESULT hResult = S_OK;      // Just delete our child nodes, the
00422                                // corresponding result items are cleaned
00423   RemoveNodes();               // up in MMCN_SHOW -> FALSE
00424
00425   //TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00426   return hResult;
00427 }
00428
00429 //---------------------------------------------------------------------------
00430 HRESULT CFolderNode::OnViewChange
00431 (
00432   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00433   LPARAM         nArg,         //[in] TRUE if node was selcted
00434   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00435   LONG_PTR       pComponent    //[in] Points to calling IComponent
00436 )
00437 {
00438   HRESULT hResult = S_FALSE;
00439   LPRESULTDATA ipResultData = NULL;
00440
00441   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00442   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00443
00444   LONG_PTR pScopeCookie = pComp->GetScopeCookie();
00445
00446   if( pScopeCookie == (LONG_PTR)this )
00447     hResult = EnumerateResultItems( ipResultData );
00448
00449   //TRACE_HRESULT( _T("OnViewChange"), hResult );
00450   return hResult;
00451 }
00452
00453 //---------------------------------------------------------------------------
00454 //  This message must return S_OK to allow the rename.  Anything else will
00455 //  disallow the rename
00456 //
00457 HRESULT CFolderNode::OnRename
00458 (
00459   LPDATAOBJECT ipDataObject,   //[in] Points to Data Object
00460   LPARAM       nArg,           //[in] Not used
00461   LPARAM       nParam,         //[in] Pointer to the new name
00462   LONG_PTR     pCompData       //[in] Points to calling IComponentData
00463 )
00464 {
00465   _ASSERT( NULL != ipDataObject );
00466   HRESULT hResult = S_OK;
00467
00468   LPWSTR pszTmpName = NULL;
00469   LPWSTR pszNewName = (LPWSTR)nParam;  // New name
00470   LONG   nLen = wcslen( pszNewName ) + 1;
00471
00472   pszTmpName = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00473   if( NULL == pszTmpName )
00474   {
00475     hResult = S_FALSE;                 // Can't change the name
00476   }
00477   else
00478   {
00479     wcscpy( pszTmpName, pszNewName );
00480     CoTaskMemFree( m_pwszNodeName );   // Free existing name...
00481     m_pwszNodeName = pszTmpName;       // Assign new name to pointer
00482   }
00483   return hResult;
00484 }
00485
00486 /////////////////////////////////////////////////////////////////////////////
00487 // DRAGDROP: Notifications which support DragDrop
00488
00489 //---------------------------------------------------------------------------
00490 //  MMC20: nParam has changed to a DWORD* which can be used to specify
00491 //         the default behaviour of DragDrop
00492 //
00493 HRESULT CFolderNode::OnQueryPaste
00494 (
00495   LPDATAOBJECT ipDataObject,   //[in] Data object of the selected node
00496   LPARAM       nArg,           //[in] Data object of node to be pasted
00497   LPARAM       nParam,         //[in] DWORD* which specifies default operation
00498   LONG_PTR     pComponent      //[in] Points to calling IComponent
00499 )
00500 {
00501   _ASSERT( NULL != nArg );
00502   ULONG nTypeFlag = ExtractNodeTypeFlg( reinterpret_cast<LPDATAOBJECT>(nArg) );
00503   return (NODETYPE_VFILE == nTypeFlag) ? S_OK : S_FALSE;
00504 }
00505
00506 //---------------------------------------------------------------------------
00507 //  DRAGDROP: This implementation always creates a new node object, and
00508 //            depending on whether we got a cut or copy flag in nParam,
00509 //            pass on the info so the source node can delete itself.
00510 //            We also have to assume the source DataObject is out-of-proc
00511 //            so we can't convert it to a CDataObject.
00512 //
00513 HRESULT CFolderNode::OnPaste
00514 (
00515   LPDATAOBJECT ipDataObject,   //[in] Data object of the destination node
00516   LPARAM       nArg,           //[in] Data object of the source node
00517   LPARAM       nParam,         //[in] NULL for copy, data object for cut
00518   LONG_PTR     pComponent      //[in] Points to calling IComponent
00519 )
00520 {
00521   _ASSERT( NULL != nArg );
00522   _ASSERT( NULL != pComponent );
00523
00524   HRESULT hResult = S_FALSE;
00525   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00526   LPDATAOBJECT ipSourceDO = reinterpret_cast<LPDATAOBJECT>(nArg);
00527
00528   do
00529   {
00530     // Test to see if the data object supports the clipformat we need
00531     FORMATETC NodePropFormatEtc = NP_FORMATETC;
00532     hResult = ipSourceDO->QueryGetData( &NodePropFormatEtc );
00533     BREAK_ON_ERROR( hResult );
00534
00535     STGMEDIUM StgMedium = {TYMED_HGLOBAL, NULL};
00536     hResult = ipSourceDO->GetData( &NodePropFormatEtc, &StgMedium );
00537     BREAK_ON_ERROR( hResult );
00538
00539     NODE_PROPERTIES* pNodeProps = NULL;
00540     pNodeProps = (NODE_PROPERTIES*)::GlobalLock( StgMedium.hGlobal );
00541
00542     // Set variables which must be local
00543     pNodeProps->pParentObject  = reinterpret_cast<LONG_PTR>(this);
00544     pNodeProps->pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00545
00546     // Now add the new node
00547     CVirtualFile* pNode = NULL;
00548     pNode = new CVirtualFile;
00549     pNode->Initialize( pNodeProps );
00550     m_NodeList.AddTail( pNode );
00551
00552     // Now do some housekeeping, and test that everything went OK....
00553     BOOL    bStatus = ::GlobalUnlock( StgMedium.hGlobal );
00554     HGLOBAL hReturn = ::GlobalFree( StgMedium.hGlobal );
00555     _ASSERT( NULL == hReturn );
00556
00557     if( NULL != nParam )
00558     {
00559       // We must AddRef it becuase MMC will release it once when we
00560       // return, and again when CFolderNode::OnCutOrMove returns.
00561       //
00562       BOOL* pbPasted = reinterpret_cast<BOOL*>(nParam);
00563       ULONG nCount = ipSourceDO->AddRef();
00564       *pbPasted = reinterpret_cast<BOOL>(ipSourceDO);
00565     }
00566
00567     // Force ourself to be selected so the new result items
00568     // will be displayed
00569     //
00570 //    LPCONSOLE3 ipConsole3 = NULL;
00571 //    hResult = m_pCompData->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole3 );
00572 //    hResult = ipConsole3->SelectScopeItem( m_SDI.ID );
00573
00574     LPCONSOLE3 ipConsole3 = NULL;
00575     hResult = m_pCompData->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole3 );
00576     if( S_OK != hResult )
00577     return hResult;
00578
00579     hResult = ipConsole3->UpdateAllViews( ipDataObject, 0, (LONG_PTR)this );
00580   }while(0);
00581
00582   return hResult;
00583 }
00584
00585 //---------------------------------------------------------------------------
00586 // DRAGDROP:  This notification is where we delete ourselves.
00587 //
00588 HRESULT CFolderNode::OnCutOrMove
00589 (
00590   LPDATAOBJECT ipDataObject,   //[in] NULL
00591   LPARAM       nArg,           //[in] Pointer to the data object
00592   LPARAM       nParam,         //[in] Not used
00593   LONG_PTR     pComponent      //[in] Points to calling IComponent
00594 )
00595 {
00596   _ASSERT( NULL != m_pParentNode );
00597   _ASSERT( NULL != m_pCompData );
00598   HRESULT hResult = S_FALSE;
00599
00600   LPCONSOLENAMESPACE2 ipCNS = NULL;
00601   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE, (LONG_PTR*)&ipCNS );
00602   hResult = ipCNS->DeleteItem( m_SDI.ID, TRUE );
00603
00604   m_pParentNode->RemoveChildNode( (LONG_PTR)this );
00605
00606   delete this;               // Now we can delete ourselves
00607
00608   return hResult;
00609 }
00610
00611
00612 /////////////////////////////////////////////////////////////////////////////
00613 //  Support for Context Menus
00614
00615 //---------------------------------------------------------------------------
00616 HRESULT CFolderNode::AddMenuItems
00617 (
00618   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00619   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00620 )
00621 {
00622   _ASSERT( NULL != ipCallback );
00623   HRESULT hResult = S_FALSE;
00624
00625   static CONTEXTMENUITEM ctxMenu;
00626     ctxMenu.lCommandID        = IDM_NEW_VIRTFILE;
00627     ctxMenu.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00628     ctxMenu.fSpecialFlags     = 0;
00629     ctxMenu.strName           = L"New Virtual File...";
00630     ctxMenu.strStatusBarText  = L"Add a new virtual file";
00631
00632
00633   if( NULL == m_hAddVFileDlg )     // If the AddVFile dialog is running
00634     ctxMenu.fFlags = 0;            // gray the menu selection
00635   else
00636     ctxMenu.fFlags = MF_GRAYED;
00637
00638
00639   // Add the 'New Device' option to the New menu if allowed...
00640   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00641   {
00642     hResult = ipCallback->AddItem( &ctxMenu );
00643   }
00644
00645   return hResult;
00646 }
00647
00648 //---------------------------------------------------------------------------
00649 HRESULT CFolderNode::Command
00650 (
00651   long lCommandID          //[in] Indentifier for menu ID
00652 )
00653 {
00654   HRESULT hResult = S_OK;
00655
00656   switch( lCommandID )
00657   {
00658     case IDM_NEW_VIRTFILE:
00659     {
00660       CAddVFileDlg* pDlg = new CAddVFileDlg( IDD_ADDVFILE_DLG, m_hMessageWnd );
00661       m_hAddVFileDlg = pDlg->Create( g_hInst, GetDesktopWindow(), 0 );
00662       break;
00663     }
00664     default:
00665     {
00666       hResult = S_FALSE;
00667       break;
00668     }
00669   }
00670   return hResult;
00671 }
00672
00673 /////////////////////////////////////////////////////////////////////////////
00674 //  Helper methods
00675
00676 //---------------------------------------------------------------------------
00677 //  This is called by a child node to have itself removed from the list
00678 //  of child nodes.  The node itself is not deleted, the child node will
00679 //  delete itself when this function returns.
00680 //
00681 VOID CFolderNode::RemoveChildNode
00682 (
00683   LONG_PTR pChildNode    //[in] Child node to remove from list
00684 )
00685 {
00686   CVirtualFile* pNode  = NULL;
00687   CVirtualFile* pChild = reinterpret_cast<CVirtualFile*>(pChildNode);
00688   POSITION      NewPos = m_NodeList.GetHeadPosition();
00689   POSITION      OldPos = NULL;
00690   while( NewPos )
00691   {
00692     OldPos = NewPos;                   // Need to save this
00693     pNode = m_NodeList.GetNext( NewPos );
00694     if( pNode == pChild )
00695     {
00696       m_NodeList.RemoveAt( OldPos );
00697       continue;                        // Exit, found it
00698     }
00699   }
00700 }
00701
00702
00703 //---------------------------------------------------------------------------
00704 // Creates a default Virtual File
00705 //
00706 HRESULT CFolderNode::InitDefaultVFile()
00707 {
00708   NODE_PROPERTIES NodeProps;
00709   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00710   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00711   NodeProps.dwAttributes   = ATTRIBUTE_DATA_ARCHIVE;
00712
00713   RemoveNodes();             // Clean the node list
00714
00715   CVirtualFile* pNode = NULL;
00716   wcscpy( NodeProps.szNodeName, gwszVFILE_NODE_NAME );
00717   pNode = new CVirtualFile;
00718   pNode->Initialize( &NodeProps );
00719   m_NodeList.AddTail( pNode );
00720
00721   return S_OK;
00722 }
00723
00724 //---------------------------------------------------------------------------
00725 //  This is only called to cleanup when we are being deleted
00726 //
00727 VOID CFolderNode::RemoveNodes()
00728 {
00729   CVirtualFile* pNode = NULL;
00730   POSITION   Pos = m_NodeList.GetHeadPosition();
00731   while( Pos )
00732   {
00733     pNode = m_NodeList.GetNext( Pos );
00734     delete pNode;
00735   }
00736   m_NodeList.RemoveAll();              // Clean the list
00737 }
00738
00739
00740 //---------------------------------------------------------------------------
00741 //  This is where OOP gets to be fun.
00742 //  We use the NodeProperties pointer which originally came from the
00743 //  modeless AddVFileDlg, by way of our hidden window, to create a new
00744 //  Virtual File node and add it to our linked list.
00745 //  This by itself will not cause the new node to be displayed.  To do
00746 //  that we need to call IResultData::InsertItem().  However we don't
00747 //  have a way to get that pointer.  So we have to be indirect.  We call
00748 //  IComponentData::QueryDataObject() to create a data object.  The data
00749 //  object points back to this node.  We can then pass that to
00750 //  IConsole2::UpdateAllViews().  This makes sure all instances of
00751 //  IComponent are called (there may me several running).  Then the
00752 //  MMCN_VIEW_CHANGE notification is delegated back to this node, along
00753 //  with a pointer to the correct IComponent.  With this pointer we can
00754 //  call GetInterface() to get an IResultData pointer which we can then
00755 //  pass to EnumerateResultItems() to display the new Virtual File.
00756 //
00757 HRESULT CFolderNode::AddVirtualFile
00758 (
00759   LPNODEPROPS pNodeProps     //[in] Properties of new node
00760 )
00761 {
00762   _ASSERT( NULL != pNodeProps );
00763   HRESULT hResult = S_FALSE;
00764
00765   pNodeProps->pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00766   pNodeProps->pParentObject  = reinterpret_cast<LONG_PTR>(this);
00767
00768   CVirtualFile* pNode = NULL;
00769   pNode = new CVirtualFile;
00770   pNode->Initialize( pNodeProps );
00771   m_NodeList.AddTail( pNode );
00772
00773   LPCONSOLE3 ipConsole3 = NULL;
00774   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLE, (LONG_PTR*)&ipConsole3 );
00775   if( S_OK != hResult )
00776     return hResult;
00777
00778   LPDATAOBJECT pDO = NULL;
00779   m_pCompData->QueryDataObject( (MMC_COOKIE)this, CCT_SCOPE, &pDO );
00780
00781   hResult = ipConsole3->UpdateAllViews( pDO, 0, 0 );
00782   pDO->Release();
00783
00784   return hResult;
00785 }
00786
00787
00788 //---------------------------------------------------------------------------
00789 HRESULT CFolderNode::EnumerateResultItems
00790 (
00791   LPRESULTDATA ipResultData  //[in] Points to cached IResultData
00792 )
00793 {
00794   _ASSERT( NULL != ipResultData );
00795   HRESULT hResult = S_OK;
00796
00797   if( FALSE == m_NodeList.IsEmpty() )
00798     hResult = ipResultData->DeleteAllRsltItems();
00799
00800   if( S_OK == hResult )
00801   {
00802     CVirtualFile*  pNode = NULL;
00803     POSITION       Pos   = m_NodeList.GetHeadPosition();
00804     while( Pos )
00805     {
00806       pNode = m_NodeList.GetNext( Pos );
00807       hResult = ipResultData->InsertItem( &pNode->m_RDI );
00808       _ASSERT( S_OK == hResult );
00809     }
00810   }
00811
00812   //TRACE_HRESULT( _T("EnumerateResultItems"), hResult );
00813   return hResult;
00814 }
00815
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CParameters Member List

This is the complete list of members for CParameters, including all inherited members.
Attach(DB_UPARAMS cParamSets, HACCESSOR hAccessor, DBLENGTH cbRowSize) | CParameters | [inline]
CParameters() | CParameters | [inline]
GetBindings() | CParameters | [inline]
GetData(DB_UPARAMS iParamSet) | CParameters | [inline]
GetParams() | CParameters | [inline]
GetRowSize() | CParameters | [inline]
m_Bindings | CParameters | [protected]
m_cbRowSize | CParameters | [protected]
m_Params | CParameters | [protected]
RemoveAll() | CParameters | [inline]
~CParameters() | CParameters | [inline]
Generated on Wed Nov 13 2024 16:57:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMemoryMappedInputStream Member List

This is the complete list of members for CMemoryMappedInputStream, including all inherited members.
_awcTranslatedBuffer | CMemoryMappedInputStream | [private]
_bytesReadFromMMBuffer | CMemoryMappedInputStream | [private]
_charsReadFromTranslatedBuffer | CMemoryMappedInputStream | [private]
_cwcTranslatedBuffer | CMemoryMappedInputStream | [private]
_fUnGotChar | CMemoryMappedInputStream | [private]
_mmStream | CMemoryMappedInputStream | [private]
_mmStreamBuf | CMemoryMappedInputStream | [private]
_ulCodePage | CMemoryMappedInputStream | [private]
_wch | CMemoryMappedInputStream | [private]
CMemoryMappedInputStream() | CMemoryMappedInputStream |
Eof() | CMemoryMappedInputStream |
GetChar() | CMemoryMappedInputStream |
Init(WCHAR *pwszFileName) | CMemoryMappedInputStream |
UnGetChar(WCHAR Wch) | CMemoryMappedInputStream |
~CMemoryMappedInputStream() | CMemoryMappedInputStream |
Generated on Wed Nov 13 2024 16:56:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/Server.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

Server.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.H
00003
00004   Summary:   Internal include file for the PERDRAW.DLL server code sample.
00005              Contains class declarations and macros for internal use in
00006              constructing this DLL as a COM component server.  Declares
00007              the CServer server control object class. APPUTIL's CThreaded
00008              OwnThis mechanism is used to ensure mutually exclusive access
00009              to the server by contending multiple threads.
00010
00011              For a comprehensive tutorial code tour of this module's
00012              contents and offerings see the tutorial PERDRAW.HTM
00013              file. For more specific technical details on the internal
00014              workings see the comments dispersed throughout the module's
00015              source code.
00016
00017   Classes:   CServer.
00018
00019   Functions: .
00020
00021   Origin:    5-20-97: atrent - Editor-inheritance from SERVER.H in
00022                the STOSERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039
00040 #if !defined(SERVER_H)
00041 #define SERVER_H
00042
00043
00044 #ifdef __cplusplus
00045
00046 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00047   Class:    CServer
00048
00049   Summary:  Class to encapsulate control of this COM server (eg, handle
00050             Lock and Object counting, encapsulate otherwise global data).
00051
00052   Methods:  none
00053 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00054 class CServer : public CThreaded
00055 {
00056   public:
00057     CServer(void);
00058     ~CServer(void);
00059
00060     // Methods for server lifetime control: object counts and lock counts.
00061     void Lock(void);
00062     void Unlock(void);
00063     void ObjectsUp(void);
00064     void ObjectsDown(void);
00065     HRESULT CanUnloadNow(void);
00066
00067     // A place to store the handle to loaded instance of this DLL module.
00068     HINSTANCE m_hDllInst;
00069
00070     // A place to store a client's parent window.
00071     HWND m_hWndParent;
00072
00073     // Global DLL Server living Object count.
00074     LONG m_cObjects;
00075
00076     // Global DLL Server Client Lock count.
00077     LONG m_cLocks;
00078 };
00079
00080 #endif // __cplusplus
00081
00082 // Allow other internal PERDRAW modules to get at the globals.
00083 extern CServer* g_pServer;
00084
00085
00086 #endif // SERVER_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Server/BYOTTxEnlister/EnlistTransaction.Cpp Source File

  • Com
  • Services
  • BYOT
  • Server
  • BYOTTxEnlister

EnlistTransaction.Cpp

Go to the documentation of this file.
00001 // EnlistTransaction.cpp : Implementation of CEnlistTransaction
00002 #include "stdafx.h"
00003 #include "TxEnlister.h"
00004 #include "EnlistTransaction.h"
00005 #include <comsvcs.h>
00006
00007 /////////////////////////////////////////////////////////////////////////////
00008 // CEnlistTransaction
00009
00010 STDMETHODIMP CEnlistTransaction::InterfaceSupportsErrorInfo(REFIID riid)
00011 {
00012   static const IID* arr[] =
00013   {
00014     &IID_IEnlistTransaction
00015   };
00016   for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
00017   {
00018     if (::InlineIsEqualGUID(*arr[i],riid))
00019       return S_OK;
00020   }
00021   return S_FALSE;
00022 }
00023
00024 STDMETHODIMP CEnlistTransaction::EnlistTransaction(BSTR bstrTipUrl)
00025 {
00026   // TODO: Add your implementation code here
00027
00028   if (!bstrTipUrl)
00029     return E_POINTER;
00030
00031   m_bstrTipUrl = bstrTipUrl;
00032
00033   return S_OK;
00034 }
00035
00036 STDMETHODIMP CEnlistTransaction::CreateInstance(BSTR bstrProgId, IDispatch **ppDispatch)
00037 {
00038    HRESULT            hr          = S_OK;
00039    ICreateWithTipTransactionEx* pCreateWithTipTx  = NULL;
00040    GUID             guidObj       = {0};
00041    GUID             guidByotServer    = {0};
00042    MULTI_QI           mqi         = {0};
00043
00044
00045   // TODO: Add your implementation code here
00046
00047   if (NULL == bstrProgId || NULL == ppDispatch)
00048     return E_POINTER;
00049
00050   hr = CLSIDFromProgID(bstrProgId, &guidObj);
00051   if (FAILED(hr))
00052     return hr;
00053
00054   hr = CLSIDFromProgID(L"Byot.ByotServerEx", &guidByotServer);
00055   if (FAILED(hr))
00056     return hr;
00057
00058   mqi.pIID  = &IID_ICreateWithTipTransactionEx;
00059   mqi.pItf  = pCreateWithTipTx;
00060   mqi.hr    = S_OK;
00061
00062   hr = CoCreateInstanceEx(guidByotServer,
00063               NULL,
00064               CLSCTX_INPROC_SERVER,
00065               NULL,
00066               1,
00067               &mqi);
00068   if (FAILED(hr))
00069     return hr;
00070
00071   if (FAILED(mqi.hr))
00072     return hr;
00073
00074   pCreateWithTipTx = (ICreateWithTipTransactionEx*)mqi.pItf;
00075   hr = pCreateWithTipTx->CreateInstance(m_bstrTipUrl,
00076                   guidObj,
00077                   IID_IDispatch,
00078                   (void**)ppDispatch);
00079   pCreateWithTipTx->Release();
00080
00081   return hr;
00082 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Resource.h Source File

  • NetDS
  • SyncMgr
  • SyncDir

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00004 // Used by Handler.rc
00005 //
00006 #define IDI_SAMPLEHANDLERICON           129
00007 #define IDI_SAMPLEHANDLERITEMICON       130
00008 #define IDD_CONFIGDIALOG                200
00009 #define IDC_CONFIGDIALOG_ITEMLIST       201
00010 #define IDC_CONFIGDIALOG_CONFIGTEXT     202
00011 #define IDC_CONFIGDIALOG_ADD            203
00012 #define IDC_CONFIGDIALOG_REMOVE         204
00013 #define IDC_CONFIGDIALOG_EDIT           205
00014 #define IDC_CONFIGDIALOG_SUMMARYTEXT    206
00015
00016 #define  IDD_ITEMCONFIGDIALOG                   300
00017 #define  IDC_ITEMCONFIGDIALOG_STATIC_DISPLAYNAME    301
00018 #define  IDC_ITEMCONFIGDIALOG_EDIT_DISPLAYNAME      302
00019 #define  IDC_ITEMCONFIGDIALOG_STATIC_DIR1NAME       303
00020 #define  IDC_ITEMCONFIGDIALOG_EDIT_DIR1NAME         304
00021 #define  IDC_ITEMCONFIGDIALOG_STATIC_DIR2NAME       305
00022 #define  IDC_ITEMCONFIGDIALOG_EDIT_DIR2NAME         306
00023 #define  IDC_ITEMCONFIGDIALOG_INCLUDESUBDIRS        307
00024
00025 #define  IDS_CONFIG_TAB             500
00026 #define  IDS_CONFIG_TITLE           501
00027 #define  IDS_ITEMCONFIG_TAB         502
00028
00029 // Next default values for new objects
00030 //
00031 #ifdef APSTUDIO_INVOKED
00032 #ifndef APSTUDIO_READONLY_SYMBOLS
00033 #define _APS_NEXT_RESOURCE_VALUE        301
00034 #define _APS_NEXT_COMMAND_VALUE         32771
00035 #define _APS_NEXT_CONTROL_VALUE         1011
00036 #define _APS_NEXT_SYMED_VALUE           101
00037 #endif
00038 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/mmccrack.Cpp Source File

  • SysMgmt
  • MMC
  • CMenu

mmccrack.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <mmc.h>
00020 #include <winuser.h>
00021 #include <tchar.h>
00022
00023 #include "globals.h"
00024
00025 #define STRSAFE_NO_DEPRECATE
00026 #include <strsafe.h>
00027
00028 static TCHAR *MMCN_CrackVerb(MMC_CONSOLE_VERB verb)
00029 {
00030   static TCHAR error[64];
00031
00032   switch (verb) {
00033     case MMC_VERB_NONE:
00034     return _T("NONE");
00035     case MMC_VERB_OPEN:
00036     return _T("OPEN");
00037     case MMC_VERB_COPY:
00038     return _T("COPY");
00039     case MMC_VERB_PASTE:
00040     return _T("PASTE");
00041     case MMC_VERB_DELETE:
00042     return _T("DELETE");
00043     case MMC_VERB_PROPERTIES:
00044     return _T("PROPERTIES");
00045     case MMC_VERB_RENAME:
00046     return _T("RENAME");
00047     case MMC_VERB_REFRESH:
00048     return _T("REFRESH");
00049     case MMC_VERB_PRINT:
00050     return _T("PRINT");
00051     case MMC_VERB_CUT:
00052     return _T("CUT");
00053   default:
00054     wsprintf(error, _T("Unknown verb id %d"), verb);
00055     return error;
00056   }
00057 }
00058
00059 void MMCN_Crack(BOOL bComponentData,
00060                 IDataObject *pDataObject,
00061         IComponentData *pCompData,
00062         IComponent *pComp,
00063                 MMC_NOTIFY_TYPE event,
00064         LPARAM arg,
00065         LPARAM param)
00066 {
00067 #ifdef MMC_CRACK_MESSAGES
00068         const size_t cchMessage = 256;
00069   TCHAR message[cchMessage] = {0};
00070
00071   if (bComponentData == TRUE)
00072     OutputDebugString(_T("IComponentData::Notify( "));
00073   else
00074     OutputDebugString(_T("IComponent::Notify( "));
00075
00076   wsprintf(message, _T("DataObject: %08x, CompData: %08x, Comp: %08x ) - "), pDataObject, pCompData, pComp);
00077   OutputDebugString(message);
00078
00079     switch (event)  {
00080     case MMCN_ACTIVATE:
00081       wsprintf(message, _T("MMCN_ACTIVATE\n\tActivate: %d\n"), arg);
00082       break;
00083
00084     case MMCN_ADD_IMAGES:
00085       wsprintf(message, _T("MMCN_ADD_IMAGES\n\tImage List: %08x\n\tScope Item: %08x\n"), arg, param);
00086       break;
00087
00088     case MMCN_BTN_CLICK:
00089       wsprintf(message, _T("MMCN_BTN_CLICK\n\tVerb: %ws\n"), MMCN_CrackVerb((MMC_CONSOLE_VERB)param));
00090       break;
00091
00092     case MMCN_COLUMN_CLICK:
00093       wsprintf(message, _T("MMCN_COLUMN_CLICK\n\tColumn: %d\n\tSort Option: %d\n"), arg,   param);
00094       break;
00095
00096     case MMCN_COLUMNS_CHANGED:
00097       wsprintf(message, _T("MMCN_COLUMNS_CHANGED\n"));
00098       break;
00099
00100     case MMCN_CONTEXTHELP:
00101       wsprintf(message, _T("MMCN_CONTEXTHELP\n"));
00102       break;
00103
00104     case MMCN_CONTEXTMENU:
00105       wsprintf(message, _T("MMCN_CONTEXTMENU\n"));
00106       break;
00107
00108     case MMCN_CUTORMOVE:
00109       wsprintf(message, _T("MMCN_CUTORMOVE\n"));
00110       break;
00111
00112     case MMCN_DBLCLICK:
00113       wsprintf(message, _T("MMCN_DBLCLICK\n"));
00114       break;
00115
00116     case MMCN_DELETE:
00117       wsprintf(message, _T("MMCN_DELETE\n"));
00118       break;
00119
00120     case MMCN_DESELECT_ALL:
00121       wsprintf(message, _T("MMCN_DESELECT_ALL\n"));
00122       break;
00123
00124     case MMCN_EXPAND:
00125       wsprintf(message, _T("MMCN_EXPAND\n\tExpand: %d\n\tScope Item: %08x\n"), arg, param);
00126       break;
00127
00128     case MMCN_EXPANDSYNC:
00129       wsprintf(message, _T("MMCN_EXPANDSYNC\n"));
00130       break;
00131
00132     case MMCN_FILTERBTN_CLICK:
00133       wsprintf(message, _T("MMCN_FILTERBTN_CLICK\n\tColumn: %d\n"), arg);
00134       break;
00135
00136     case MMCN_FILTER_CHANGE:
00137       wsprintf(message, _T("MMCN_FILTER_CHANGE\n\tColumn: %d\n"), param);
00138       break;
00139
00140     case MMCN_HELP:
00141       wsprintf(message, _T("MMCN_HELP\n"));
00142       break;
00143
00144     case MMCN_INITOCX:
00145       wsprintf(message, _T("MMCN_INITOCX\n\tIUnknown: %08x\n"), param);
00146       break;
00147
00148     case MMCN_LISTPAD:
00149       wsprintf(message, _T("MMCN_LISTPAD\n\tConnect: %d\n"), arg);
00150       break;
00151
00152     case MMCN_MENU_BTNCLICK:
00153       wsprintf(message, _T("MMCN_MENU_BTNCLICK\n"));
00154       break;
00155
00156     case MMCN_MINIMIZED:
00157       wsprintf(message, _T("MMCN_MINIMIZED\n\tMinimized: %d\n"), arg);
00158       break;
00159
00160     case MMCN_PASTE:
00161       wsprintf(message, _T("MMCN_PASTE\n\tCopy: %d\n"), param == NULL);
00162       break;
00163
00164     case MMCN_PRELOAD:
00165       wsprintf(message, _T("MMCN_PRELOAD\n\tScope Item: %08x\n"), arg);
00166       break;
00167
00168     case MMCN_PRINT:
00169       wsprintf(message, _T("MMCN_PRINT\n"));
00170       break;
00171
00172     case MMCN_PROPERTY_CHANGE:
00173       wsprintf(message, _T("MMCN_PROPERTY_CHANGE\n\tScope: %d\n\tArg: %08x\n"), arg, param);
00174       break;
00175
00176     case MMCN_QUERY_PASTE:
00177       wsprintf(message, _T("MMCN_QUERY_PASTE\n"));
00178       break;
00179
00180     case MMCN_REFRESH:
00181       wsprintf(message, _T("MMCN_REFRESH\n"));
00182       break;
00183
00184     case MMCN_REMOVE_CHILDREN:
00185       wsprintf(message, _T("MMCN_REMOVE_CHILDREN\n\tScope Item: %08x\n"), arg);
00186       break;
00187
00188     case MMCN_RENAME:
00189                         // Destination string may contain a truncation of the ideal result.
00190                         // (Indicated by return value other than S_OK).
00191                         // However, it will be null-terminated.
00192       StringCchPrintf(message, cchMessage, _T("MMCN_RENAME\n\tNew Name: '%ws'\n"), (LPOLESTR)param);
00193       break;
00194
00195     case MMCN_RESTORE_VIEW:
00196       wsprintf(message, _T("MMCN_RESTORE_VIEW\n"));
00197       break;
00198
00199     case MMCN_SELECT:
00200       wsprintf(message, _T("MMCN_SELECT\n\tScope: %d\n\tSelect: %08x\n"), LOWORD(arg), HIWORD(arg));
00201       break;
00202
00203     case MMCN_SHOW:
00204       wsprintf(message, _T("MMCN_SHOW\n\tShow: %d\n\tScope Item: %08x\n"), arg, param);
00205       break;
00206
00207     case MMCN_SNAPINHELP:
00208       wsprintf(message, _T("MMCN_SNAPINHELP\n"));
00209       break;
00210
00211     case MMCN_VIEW_CHANGE:
00212       wsprintf(message, _T("MMCN_VIEW_CHANGE\n\tData: %08x\n\tHint: %08x\n"), arg, param);
00213       break;
00214   }
00215
00216   if (message[0] != 0)
00217     OutputDebugString(message);
00218   else
00219     OutputDebugString(_T("unknown event\n"));
00220
00221 #endif
00222   return;
00223 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/Incoming/Callnot.Cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • Incoming

Callnot.Cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00004
00005 Module Name:
00006     callnot.cpp
00007
00008 Abstract:
00009
00010     Implementation of the ITTAPIEventNotification interface.
00011
00012     This is an outgoing interface that is defined by TAPI 3.0.  This
00013     is basically a callback function that TAPI 3.0 calls to inform
00014     the application of events related to calls (on a specific address)
00015
00016     Please refer to COM documentation for information on outgoing
00017     interfaces.
00018
00019     An application must implement and register this interface in order
00020     to receive calls and events related to calls
00021
00022 --*/
00023
00024
00025 #include <windows.h>
00026 #include <tapi3.h>
00027 #include <control.h>
00028 #include <strmif.h>
00029
00030 #include "callnot.h"
00031 #include "resource.h"
00032
00033 extern ITBasicCallControl * gpCall;
00034 extern HWND ghDlg;
00035 extern BSTR gbstrVideo;
00036 extern BOOL gfAutoAnswer;
00037
00038 void
00039 DoMessage(
00040           LPWSTR pszMessage
00041          );
00042
00043 void
00044 SetStatusMessage(
00045                  LPWSTR pszMessage
00046                 );
00047
00048 void
00049 EnableButton(
00050              int ID
00051             );
00052 void
00053 DisableButton(
00054               int ID
00055              );
00056
00057 enum {
00058     VWP_LEFT = 20,
00059     VWP_TOP = 100
00060 };
00061
00062 ///////////////////////////////////////////////////////////////////
00063 // HostWindow
00064 //
00065 // This method takes a pVideoWindow interface pointer and puts
00066 //  the window in our dialog.
00067 //
00068 // The location depends on the iWhere parameter.
00069 //
00070 ///////////////////////////////////////////////////////////////////
00071
00072 void
00073 HostWindow(
00074            IVideoWindow *pVideoWindow,
00075            int iWhere
00076           )
00077 {
00078
00079     pVideoWindow->put_Owner( (LONG_PTR)ghDlg );
00080     pVideoWindow->put_WindowStyle( WS_CHILDWINDOW | WS_BORDER );
00081
00082     long lWidth, lHeight;
00083     pVideoWindow->get_Width( &lWidth );
00084     pVideoWindow->get_Height( &lHeight );
00085
00086     pVideoWindow->SetWindowPosition( VWP_LEFT + (iWhere * (VWP_LEFT + lWidth)),
00087                                      VWP_TOP,
00088                                      lWidth,
00089                                      lHeight );
00090
00091     pVideoWindow->put_Visible( VARIANT_TRUE );
00092 }
00093
00094 ///////////////////////////////////////////////////////////////////
00095 // GetVideoRenderTerminalFromStreamEvent
00096 //
00097 // Find out if this stream has a video render terminal. If not,
00098 // we don't need to do anything with this stream. Also note
00099 // if this is the video capture stream or the video render
00100 // stream.
00101 //
00102 ///////////////////////////////////////////////////////////////////
00103
00104 HRESULT
00105 GetVideoRenderTerminalFromStreamEvent(
00106                                       ITCallMediaEvent  * pCallMediaEvent,
00107                                       ITTerminal       ** ppTerminal,
00108                                       BOOL              * pfRenderStream
00109                                      )
00110 {
00111     HRESULT hr;
00112
00113     //
00114     // Get the stream for this event.
00115     //
00116
00117     ITStream * pStream;
00118
00119     hr = pCallMediaEvent->get_Stream( &pStream );
00120
00121     if ( FAILED(hr) || (pStream == NULL) )
00122     {
00123         return E_FAIL;
00124     }
00125
00126     //
00127     // Find out if this is a video stream. If not, fail --
00128     // we don't care about this stream.
00129     //
00130
00131     long lMediaType;
00132
00133     hr = pStream->get_MediaType(&lMediaType);
00134
00135     if ( FAILED(hr) )
00136     {
00137         pStream->Release();
00138
00139         return hr;
00140     }
00141
00142     if ( lMediaType != TAPIMEDIATYPE_VIDEO )
00143     {
00144         pStream->Release();
00145
00146         return E_FAIL;
00147     }
00148
00149     //
00150     // Find out the direction of this stream. We will return this info to the
00151     // caller.
00152     //
00153
00154     TERMINAL_DIRECTION td;
00155
00156     hr = pStream->get_Direction(&td);
00157
00158     if ( FAILED(hr) )
00159     {
00160         pStream->Release();
00161
00162         return hr;
00163     }
00164
00165     *pfRenderStream = (td == TD_RENDER);
00166
00167     //
00168     // Enumerate the terminals on this stream.
00169     //
00170
00171     IEnumTerminal * pEnumTerminal;
00172
00173     hr = pStream->EnumerateTerminals( &pEnumTerminal );
00174
00175     pStream->Release();
00176
00177     if ( FAILED(hr) )
00178     {
00179         return hr;
00180     }
00181
00182     //
00183     // Search for the first video render terminal and return it. If there are
00184     // none, fail -- we don't care about this stream.
00185     //
00186
00187     while ( S_OK == pEnumTerminal->Next(1, ppTerminal, NULL) )
00188     {
00189         if ( SUCCEEDED( (*ppTerminal)->get_Direction(&td) ) )
00190         {
00191             if ( td == TD_RENDER )
00192             {
00193                 // found it; done with enum, but keep ref on terminal
00194                 pEnumTerminal->Release();
00195
00196                 return S_OK;
00197             }
00198         }
00199
00200         // this is not the right one
00201         (*ppTerminal)->Release();
00202     }
00203
00204     pEnumTerminal->Release();
00205
00206     return E_FAIL; // no terminal found
00207 }
00208
00209 ///////////////////////////////////////////////////////////////////
00210 // CallEventNotification
00211 //
00212 // The only method in the ITCallEventNotification interface.  This gets
00213 // called by TAPI 3.0 when there is a call event to report. This just
00214 // posts the message to our UI thread, so that we do as little as
00215 // possible on TAPI's callback thread.
00216 //
00217 ///////////////////////////////////////////////////////////////////
00218
00219 HRESULT
00220 STDMETHODCALLTYPE
00221 CTAPIEventNotification::Event(
00222                               TAPI_EVENT TapiEvent,
00223                               IDispatch * pEvent
00224                              )
00225 {
00226     //
00227     // Addref the event so it doesn't go away.
00228     //
00229
00230     pEvent->AddRef();
00231
00232     //
00233     // Post a message to our own UI thread.
00234     //
00235
00236     PostMessage(
00237                 ghDlg,
00238                 WM_PRIVATETAPIEVENT,
00239                 (WPARAM) TapiEvent,
00240                 (LPARAM) pEvent
00241                );
00242
00243     return S_OK;
00244 }
00245
00246 ///////////////////////////////////////////////////////////////////
00247 // OnTapiEvent
00248 //
00249 // This is the real event handler, called on our UI thread when
00250 // the WM_PRIVATETAPIEVENT message is received
00251 //
00252 ///////////////////////////////////////////////////////////////////
00253
00254 HRESULT
00255 OnTapiEvent(
00256             TAPI_EVENT TapiEvent,
00257             IDispatch * pEvent
00258            )
00259 {
00260     HRESULT hr;
00261
00262     switch ( TapiEvent )
00263     {
00264         case TE_CALLNOTIFICATION:
00265         {
00266             //
00267             // TE_CALLNOTIFICATION means that the application is being notified
00268             // of a new call.
00269             //
00270             // Note that we don't answer to call at this point.  The application
00271             // should wait for a CS_OFFERING CallState message before answering
00272             // the call.
00273             //
00274
00275             ITCallNotificationEvent         * pNotify;
00276
00277             hr = pEvent->QueryInterface( IID_ITCallNotificationEvent, (void **)&pNotify );
00278
00279             if (S_OK != hr)
00280             {
00281                 DoMessage( L"Incoming call, but failed to get the interface");
00282             }
00283             else
00284             {
00285                 CALL_PRIVILEGE          cp;
00286                 ITCallInfo *            pCall;
00287
00288                 //
00289                 // get the call
00290                 //
00291
00292                 hr = pNotify->get_Call( &pCall );
00293
00294                 pNotify->Release();
00295
00296                 if ( SUCCEEDED(hr) )
00297                 {
00298                     //
00299                     // check to see if we own the call
00300                     //
00301
00302                     hr = pCall->get_Privilege( &cp );
00303
00304                     if ( FAILED(hr) || (CP_OWNER != cp) )
00305                     {
00306                         //
00307                         // just ignore it if we don't own it
00308                         //
00309
00310                         pCall->Release();
00311
00312                         pEvent->Release(); // we addrefed it CTAPIEventNotification::Event()
00313
00314                         return S_OK;
00315                     }
00316
00317                     //
00318                     // Get the ITBasicCallControl interface
00319                     //
00320
00321                     //
00322                     // If we're already in a call, disconnect the new call.  Otherwise,
00323                     // save it in our global variable.
00324                     //
00325
00326                     ITBasicCallControl * pCallControl;
00327
00328                     hr = pCall->QueryInterface( IID_ITBasicCallControl,
00329                                                 (void**)&pCallControl );
00330
00331                     pCall->Release();
00332
00333
00334                     if ( SUCCEEDED(hr) )
00335                     {
00336                         if (gpCall == NULL)
00337                         {
00338                             gpCall = pCallControl;
00339
00340                             //
00341                             // update UI
00342                             //
00343
00344                             EnableButton( IDC_ANSWER );
00345                             DisableButton( IDC_DISCONNECT );
00346                             SetStatusMessage(L"Incoming Owner Call");
00347                         }
00348                         else
00349                         {
00350                             //
00351                             // Reject this call since we're already in a call
00352                             //
00353
00354                             hr = pCallControl->Disconnect(DC_REJECTED);
00355
00356                             pCallControl->Release();
00357
00358                             if (FAILED(hr))
00359                             {
00360                                 break;
00361                             }
00362                         }
00363                     }
00364
00365                 }
00366             }
00367
00368             break;
00369         }
00370
00371         case TE_CALLSTATE:
00372         {
00373             // TE_CALLSTATE is a call state event.  pEvent is
00374             // an ITCallStateEvent
00375
00376             CALL_STATE           cs;
00377             ITCallStateEvent   * pCallStateEvent;
00378             ITCallInfo *         pCall;
00379             ITBasicCallControl * pCallControl;
00380
00381             // Get the interface
00382             hr = pEvent->QueryInterface( IID_ITCallStateEvent, (void **)&pCallStateEvent );
00383
00384             if ( FAILED(hr) )
00385             {
00386                 break;
00387             }
00388
00389             // get the CallInfo interface
00390             hr = pCallStateEvent->get_Call( &pCall );
00391
00392             if ( FAILED(hr) )
00393             {
00394                 pCallStateEvent->Release();
00395                 break;
00396             }
00397
00398             //get the ITBasicCallControl interface and compare it to our existing call
00399             hr = pCall->QueryInterface( IID_ITBasicCallControl,(void**)&pCallControl );
00400
00401             pCall->Release();
00402
00403             if (FAILED(hr))
00404             {
00405                 pCallStateEvent->Release();
00406                 break;
00407             }
00408
00409             //ignore call state events for other calls
00410             if (pCallControl != gpCall)
00411             {
00412                 pCallControl->Release();
00413                 pCallStateEvent->Release();
00414                 break;
00415             }
00416             pCallControl->Release();
00417
00418             //
00419             // This is a call state event for our call
00420             //
00421
00422             // get the CallState that we are being notified of.
00423             hr = pCallStateEvent->get_State( &cs );
00424
00425             // Release the interface
00426             pCallStateEvent->Release();
00427
00428             if ( FAILED(hr) )
00429             {
00430                 break;
00431             }
00432
00433             // if it's offering, update our UI
00434             if (CS_OFFERING == cs)
00435             {
00436                 if (gfAutoAnswer)
00437                 {
00438                     PostMessage(ghDlg, WM_COMMAND, IDC_ANSWER, 0);
00439                 }
00440                 else
00441                 {
00442                     SetStatusMessage(L"Click the Answer button");
00443                 }
00444             }
00445             else if (CS_DISCONNECTED == cs)
00446             {
00447                 PostMessage(ghDlg, WM_COMMAND, IDC_DISCONNECTED, 0);
00448             }
00449             else if (CS_CONNECTED == cs)
00450             {
00451                 // nothing to do -- we handle connection synchronously
00452             }
00453
00454             break;
00455         }
00456
00457         case TE_CALLMEDIA:
00458         {
00459             // TE_CALLMEDIA is a media event.  pEvent is
00460             // an ITCallMediaEvent
00461
00462             CALL_MEDIA_EVENT    cme;
00463             ITCallMediaEvent  * pCallMediaEvent;
00464
00465             // Get the interface
00466             hr = pEvent->QueryInterface( IID_ITCallMediaEvent, (void **)&pCallMediaEvent );
00467
00468             if ( FAILED(hr) )
00469             {
00470                 break;
00471             }
00472
00473             // get the CALL_MEDIA_EVENT that we are being notified of.
00474             hr = pCallMediaEvent->get_Event( &cme );
00475
00476             if ( SUCCEEDED(hr) )
00477             {
00478                 switch ( cme )
00479                 {
00480                 case CME_STREAM_NOT_USED:
00481                 case CME_STREAM_INACTIVE:
00482                 case CME_NEW_STREAM:
00483                     break;
00484
00485                 case CME_STREAM_FAIL:
00486                     DoMessage( L"Call media event: stream failed");
00487                     break;
00488
00489                 case CME_TERMINAL_FAIL:
00490                     DoMessage( L"Call media event: terminal failed");
00491                     break;
00492
00493                 case CME_STREAM_ACTIVE:
00494                 {
00495                     //
00496                     // Find out if this stream has a video render terminal. If not,
00497                     // we don't need to do anything with this stream. Also note
00498                     // if this is the video capture stream or the video render
00499                     // stream.
00500                     //
00501
00502                     ITTerminal * pTerminal;
00503                     BOOL         fRenderStream;
00504
00505                     hr = GetVideoRenderTerminalFromStreamEvent(
00506                                                                pCallMediaEvent,
00507                                                                &pTerminal,
00508                                                                &fRenderStream
00509                                                               );
00510
00511                     if ( SUCCEEDED(hr) )
00512                     {
00513                         // Get the video window interface for the terminal
00514                         IVideoWindow *pVideoWindow = NULL;
00515
00516                         hr = pTerminal->QueryInterface( IID_IVideoWindow, (void**)&pVideoWindow );
00517
00518                         pTerminal->Release();
00519
00520                         if ( SUCCEEDED(hr) )
00521                         {
00522                             // Put this window in our dialog
00523                             HostWindow(pVideoWindow, fRenderStream);
00524
00525                             pVideoWindow->Release();
00526                         }
00527                     }
00528
00529                     break;
00530                 }
00531
00532                 default:
00533                     break;
00534                 }
00535             }
00536
00537             // We no longer need this interface.
00538             pCallMediaEvent->Release();
00539
00540             break;
00541         }
00542
00543         default:
00544             break;
00545     }
00546
00547     pEvent->Release(); // we addrefed it CTAPIEventNotification::Event()
00548
00549     return S_OK;
00550 }
00551
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/localres.h Source File

  • SysMgmt
  • MMC
  • Nodes

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029 #define INDEX_BACKGROUND    6
00030
00031 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMyInkCollector Member List

This is the complete list of members for CMyInkCollector, including all inherited members.
CMyInkCollector() | CMyInkCollector | [inline]
Init(HWND hWnd) | CMyInkCollector | [inline]
m_InkEvents | CMyInkCollector | [private]
m_pInkCollector | CMyInkCollector | [private]
~CMyInkCollector() | CMyInkCollector | [inline]
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MQPers/GraphObj/DllDatax.c Source File

  • NetDS
  • MessageQueuing
  • MQPers
  • GraphObj

DllDatax.c

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 // wrapper for dlldata.c
00013
00014 #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
00015
00016 #define REGISTER_PROXY_DLL //DllRegisterServer, etc.
00017
00018 #define _WIN32_WINNT 0x0400 //for WinNT 4.0 or Win95 with DCOM
00019 #define USE_STUBLESS_PROXY  //defined only with MIDL switch /Oicf
00020
00021 #pragma comment(lib, "rpcndr.lib")
00022 #pragma comment(lib, "rpcns4.lib")
00023 #pragma comment(lib, "rpcrt4.lib")
00024
00025 #define DllMain       PrxDllMain
00026 #define DllRegisterServer PrxDllRegisterServer
00027 #define DllUnregisterServer PrxDllUnregisterServer
00028 #define DllGetClassObject   PrxDllGetClassObject
00029 #define DllCanUnloadNow     PrxDllCanUnloadNow
00030
00031 #include "dlldata.c"
00032 #include "GraphObj_p.c"
00033
00034 #ifdef _NOPROXY //no midl generated dlldata.c
00035
00036 #define STRICT 1
00037 #include <ole2.h>
00038
00039 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00040 {return TRUE;}
00041
00042 STDAPI PrxDllCanUnloadNow(void){return S_OK;}
00043
00044 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00045 {return CLASS_E_CLASSNOTAVAILABLE;}
00046
00047 STDAPI PrxDllRegisterServer(void){return S_OK;}
00048
00049 STDAPI PrxDllUnregisterServer(void){return S_OK;}
00050
00051 #endif //!PROXY_DELEGATION
00052
00053 #endif //_MERGE_PROXYSTUB
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CObjSub Member List

This is the complete list of members for CObjSub, including all inherited members.
CObjSub(CComSpy *pSpy) | CObjSub | [inline]
CObjSub() | CObjSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetEventClass(LPGUID guid) | CObjSub | [inline, virtual]
GetEventType(EventEnum *e) | CObjSub | [inline, virtual]
GetInterface(IID *iid) | CObjSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnDisableCommit(COMSVCSEVENTINFO *pInfo, ULONG64 ContextID) | CObjSub | [inline]
OnEnableCommit(COMSVCSEVENTINFO *pInfo, ULONG64 ContextID) | CObjSub | [inline]
OnObjectActivate(COMSVCSEVENTINFO *pInfo, ULONG64 CtxtID, ULONG64 ObjectID) | CObjSub | [inline]
OnObjectDeactivate(COMSVCSEVENTINFO *pInfo, ULONG64 CtxtID, ULONG64 ObjectID) | CObjSub | [inline]
OnSetAbort(COMSVCSEVENTINFO *pInfo, ULONG64 ContextID) | CObjSub | [inline]
OnSetComplete(COMSVCSEVENTINFO *pInfo, ULONG64 ContextID) | CObjSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/keys.cpp Source File

  • WinUI
  • TSFmark

keys.cpp

Go to the documentation of this file.
00001 //
00002 // keys.cpp
00003 //
00004 // ITfKeyEventSink implementation.
00005 //
00006
00007 #include "globals.h"
00008 #include "mark.h"
00009 #include "editsess.h"
00010
00011 class CKeystrokeEditSession : public CEditSessionBase
00012 {
00013 public:
00014     CKeystrokeEditSession(CMarkTextService *pMark, ITfContext *pContext, WPARAM wParam) : CEditSessionBase(pContext)
00015     {
00016         _pMark = pMark;
00017         _pMark->AddRef();
00018         _wParam = wParam;
00019     }
00020     ~CKeystrokeEditSession()
00021     {
00022         _pMark->Release();
00023     }
00024
00025     // ITfEditSession
00026     STDMETHODIMP DoEditSession(TfEditCookie ec);
00027
00028 private:
00029     CMarkTextService *_pMark;
00030     WPARAM _wParam;
00031 };
00032
00033 //+---------------------------------------------------------------------------
00034 //
00035 // _HandleReturn
00036 //
00037 // Returns S_OK to eat the keystroke, S_FALSE otherwise.
00038 //----------------------------------------------------------------------------
00039
00040 HRESULT CMarkTextService::_HandleReturn(TfEditCookie ec, ITfContext *pContext)
00041 {
00042     // just terminate the composition
00043     _TerminateComposition(ec);
00044     return S_OK;
00045 }
00046
00047 //+---------------------------------------------------------------------------
00048 //
00049 // _HandleArrowKey
00050 //
00051 // Update the selection within a composition.
00052 // Returns S_OK to eat the keystroke, S_FALSE otherwise.
00053 //----------------------------------------------------------------------------
00054
00055 HRESULT CMarkTextService::_HandleArrowKey(TfEditCookie ec, ITfContext *pContext, WPARAM wParam)
00056 {
00057     ITfRange *pRangeComposition;
00058     LONG cch;
00059     BOOL fEqual;
00060     TF_SELECTION tfSelection;
00061     ULONG cFetched;
00062
00063     // get the selection
00064     if (pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK ||
00065         cFetched != 1)
00066     {
00067         // no selection?
00068         return S_OK; // eat the keystroke
00069     }
00070
00071     // get the composition range
00072     if (_pComposition->GetRange(&pRangeComposition) != S_OK)
00073         goto Exit;
00074
00075     // adjust the selection, we won't do anything fancy
00076
00077     if (wParam == VK_LEFT)
00078     {
00079         if (tfSelection.range->IsEqualStart(ec, pRangeComposition, TF_ANCHOR_START, &fEqual) == S_OK &&
00080             !fEqual)
00081         {
00082             tfSelection.range->ShiftStart(ec, -1, &cch, NULL);
00083         }
00084         tfSelection.range->Collapse(ec, TF_ANCHOR_START);
00085     }
00086     else
00087     {
00088         // VK_RIGHT
00089         if (tfSelection.range->IsEqualEnd(ec, pRangeComposition, TF_ANCHOR_END, &fEqual) == S_OK &&
00090             !fEqual)
00091         {
00092             tfSelection.range->ShiftEnd(ec, +1, &cch, NULL);
00093         }
00094         tfSelection.range->Collapse(ec, TF_ANCHOR_END);
00095     }
00096
00097     pContext->SetSelection(ec, 1, &tfSelection);
00098
00099     pRangeComposition->Release();
00100
00101 Exit:
00102     tfSelection.range->Release();
00103     return S_OK; // eat the keystroke
00104 }
00105
00106 //+---------------------------------------------------------------------------
00107 //
00108 // _HandleKeyDown
00109 //
00110 // If the keystroke happens within a composition, eat the key and return S_OK.
00111 // Otherwise, do nothing and return S_FALSE.
00112 //----------------------------------------------------------------------------
00113
00114 HRESULT CMarkTextService::_HandleKeyDown(TfEditCookie ec, ITfContext *pContext, WPARAM wParam)
00115 {
00116     ITfRange *pRangeComposition;
00117     TF_SELECTION tfSelection;
00118     ULONG cFetched;
00119     HRESULT hr;
00120     WCHAR ch;
00121     BOOL fCovered;
00122
00123     if (wParam < 'A' || wParam > 'Z')
00124         return S_OK; // just eat the key if it's not in a range we know how to handle
00125
00126     hr = S_OK; // return S_FALSE to NOT eat the key
00127
00128     // convert the wParam to a WCHAR
00129     if (GetKeyState(VK_SHIFT) & 0x8000)
00130     {
00131         // shift-key, leave it uppercase
00132         ch = (WCHAR)wParam;
00133     }
00134     else
00135     {
00136         // else make it lowercase
00137         ch = (WCHAR)(wParam | 32);
00138     }
00139
00140     // first, test where a keystroke would go in the document if we did an insert
00141     if (pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK || cFetched != 1)
00142         return S_FALSE;
00143
00144     // is the insertion point covered by a composition?
00145     if (_pComposition->GetRange(&pRangeComposition) == S_OK)
00146     {
00147         fCovered = IsRangeCovered(ec, tfSelection.range, pRangeComposition);
00148
00149         pRangeComposition->Release();
00150
00151         if (!fCovered)
00152         {
00153             hr = S_FALSE; // don't eat the key, it's outside our composition
00154             goto Exit;
00155         }
00156     }
00157
00158     // insert the text
00159     // we use SetText here instead of InsertTextAtSelection because we've already started a composition
00160     // we don't want to the app to adjust the insertion point inside our composition
00161     if (tfSelection.range->SetText(ec, 0, &ch, 1) != S_OK)
00162         goto Exit;
00163
00164     // update the selection, we'll make it an insertion point just past
00165     // the inserted text.
00166     tfSelection.range->Collapse(ec, TF_ANCHOR_END);
00167
00168     pContext->SetSelection(ec, 1, &tfSelection);
00169
00170     // apply our dislay attribute property to the inserted text
00171     // we need to apply it to the entire composition, since the
00172     // display attribute property is static, not static compact
00173     _SetCompositionDisplayAttributes(ec);
00174
00175 Exit:
00176     tfSelection.range->Release();
00177     return hr;
00178 }
00179
00180 //+---------------------------------------------------------------------------
00181 //
00182 // _InitKeystrokeSink
00183 //
00184 // Advise a keystroke sink.
00185 //----------------------------------------------------------------------------
00186
00187 BOOL CMarkTextService::_InitKeystrokeSink()
00188 {
00189     ITfKeystrokeMgr *pKeystrokeMgr;
00190     HRESULT hr;
00191
00192     if (_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&pKeystrokeMgr) != S_OK)
00193         return FALSE;
00194
00195     hr = pKeystrokeMgr->AdviseKeyEventSink(_tfClientId, (ITfKeyEventSink *)this, TRUE);
00196
00197     pKeystrokeMgr->Release();
00198
00199     return (hr == S_OK);
00200 }
00201
00202 //+---------------------------------------------------------------------------
00203 //
00204 // _UninitKeystrokeSink
00205 //
00206 // Unadvise a keystroke sink.  Assumes we have advised one already.
00207 //----------------------------------------------------------------------------
00208
00209 void CMarkTextService::_UninitKeystrokeSink()
00210 {
00211     ITfKeystrokeMgr *pKeystrokeMgr;
00212
00213     if (_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&pKeystrokeMgr) != S_OK)
00214         return;
00215
00216     pKeystrokeMgr->UnadviseKeyEventSink(_tfClientId);
00217
00218     pKeystrokeMgr->Release();
00219 }
00220
00221 //+---------------------------------------------------------------------------
00222 //
00223 // OnSetFocus
00224 //
00225 // Called by the system whenever this service gets the keystroke device focus.
00226 //----------------------------------------------------------------------------
00227
00228 STDAPI CMarkTextService::OnSetFocus(BOOL fForeground)
00229 {
00230     return S_OK;
00231 }
00232
00233 //+---------------------------------------------------------------------------
00234 //
00235 // OnTestKeyDown
00236 //
00237 // Called by the system to query if this service wants a potential keystroke.
00238 //----------------------------------------------------------------------------
00239
00240 STDAPI CMarkTextService::OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00241 {
00242     *pfEaten = (_pComposition != NULL);
00243     return S_OK;
00244 }
00245
00246 //+---------------------------------------------------------------------------
00247 //
00248 // OnKeyDown
00249 //
00250 // Called by the system to offer this service a keystroke.  If *pfEaten == TRUE
00251 // on exit, the application will not handle the keystroke.
00252 //
00253 // This text service is interested in handling keystrokes to demonstrate the
00254 // use the compositions.  Some apps will cancel compositions if they receive
00255 // keystrokes while a compositions is ongoing.
00256 //----------------------------------------------------------------------------
00257
00258 STDAPI CMarkTextService::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00259 {
00260     CKeystrokeEditSession *pEditSession;
00261     HRESULT hr;
00262
00263     hr = E_FAIL;
00264     *pfEaten = FALSE;
00265
00266     if (_pComposition != NULL) // only eat keys while composing
00267     {
00268         // we'll insert a char ourselves in place of this keystroke
00269         if ((pEditSession = new CKeystrokeEditSession(this, pContext, wParam)) == NULL)
00270             goto Exit;
00271
00272         // we need a lock to do our work
00273         // nb: this method is one of the few places where it is legal to use
00274         // the TF_ES_SYNC flag
00275         if (pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_SYNC | TF_ES_READWRITE, &hr) != S_OK)
00276         {
00277             hr = E_FAIL;
00278         }
00279
00280         pEditSession->Release();
00281     }
00282
00283 Exit:
00284     // if we made it all the way to the RequestEditSession, then hr is ultimately the
00285     // return code from CKeystrokeEditSession::DoEditSession.  Our DoEditSession method
00286     // return S_OK to signal that the keystroke should be eaten, S_FALSE otherwise.
00287     if (hr == S_OK)
00288     {
00289         *pfEaten = TRUE;
00290     }
00291     return S_OK;
00292 }
00293
00294 //+---------------------------------------------------------------------------
00295 //
00296 // DoEditSession
00297 //
00298 //----------------------------------------------------------------------------
00299
00300 STDAPI CKeystrokeEditSession::DoEditSession(TfEditCookie ec)
00301 {
00302     switch (_wParam)
00303     {
00304         case VK_LEFT:
00305         case VK_RIGHT:
00306             return _pMark->_HandleArrowKey(ec, _pContext, _wParam);
00307
00308         case VK_RETURN:
00309             return _pMark->_HandleReturn(ec, _pContext);
00310
00311         case VK_SPACE:
00312             return S_OK;
00313     }
00314
00315     return _pMark->_HandleKeyDown(ec, _pContext, _wParam);
00316 }
00317
00318 //+---------------------------------------------------------------------------
00319 //
00320 // OnTestKeyUp
00321 //
00322 // Called by the system to query this service wants a potential keystroke.
00323 //----------------------------------------------------------------------------
00324
00325 STDAPI CMarkTextService::OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00326 {
00327     *pfEaten = FALSE;
00328     return S_OK;
00329 }
00330
00331 //+---------------------------------------------------------------------------
00332 //
00333 // OnKeyUp
00334 //
00335 // Called by the system to offer this service a keystroke.  If *pfEaten == TRUE
00336 // on exit, the application will not handle the keystroke.
00337 //----------------------------------------------------------------------------
00338
00339 STDAPI CMarkTextService::OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
00340 {
00341     *pfEaten = FALSE;
00342     return S_OK;
00343 }
00344
00345 //+---------------------------------------------------------------------------
00346 //
00347 // OnPreservedKey
00348 //
00349 // Called when a hotkey (registered by us, or by the system) is typed.
00350 //----------------------------------------------------------------------------
00351
00352 STDAPI CMarkTextService::OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pfEaten)
00353 {
00354     *pfEaten = FALSE;
00355     return S_OK;
00356 }
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinNT/WxForm/WxForm.h Source File

  • Multimedia
  • Gdi
  • WinNT
  • WxForm

WxForm.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /*  wxform.h -- header file for World transform sample.  */
00013
00014
00015 LRESULT CALLBACK MainWndProc     (HWND, UINT, WPARAM, LPARAM);
00016 LRESULT CALLBACK TransformDlgProc(HWND, UINT, WPARAM, LPARAM);
00017 LRESULT CALLBACK MouseDlgProc    (HWND, UINT, WPARAM, LPARAM);
00018
00019
00020
00021 /* dialog id's for the Transform dialog */
00022 #define IDD_EM11        101
00023 #define IDD_EM12        102
00024 #define IDD_EDX         103
00025 #define IDD_EM21        104
00026 #define IDD_EM22        105
00027 #define IDD_EDY         106
00028 #define IDD_13          107
00029 #define IDD_23          108
00030 #define IDD_33          109
00031 #define IDD_SETXFORM    110
00032 #define IDD_IDENTITY    111
00033
00034
00035 /* dialog id's for the Mouse dialog */
00036 #define IDD_SCREENX     201
00037 #define IDD_SCREENY     202
00038 #define IDD_DEVICEX     203
00039 #define IDD_DEVICEY     204
00040 #define IDD_WORLDX      205
00041 #define IDD_WORLDY      206
00042
00043 /* string table ids's */
00044 #define IDS_NTONLY        16
00045 #define IDS_WINDOWTITLE   17
00046
00047 /* special messages for doTrackobject(). */
00048 #define TROB_NEW         WM_USER+1
00049 #define TROB_DELETE      WM_USER+2
00050 #define TROB_PAINT       WM_USER+3
00051 #define TROB_HITTEST     WM_USER+5
00052 #define TROB_CENTER      WM_USER+6
00053 #define TROB_SETXFORM    WM_USER+7
00054
00055 /* special user message for two of the dialogs */
00056 #define WM_PUTUPFLOATS  WM_USER+1
00057
00058
00059 /* Different "Track modes." */
00060 #define TMNONE    0x0000
00061 #define TMMOVE    0x0001
00062 #define TMSIZEX   0x0002
00063 #define TMSIZEY   0x0004
00064 #define TMSIZEXY  0x0006
00065 #define TMSHEARX  0x0010
00066 #define TMSHEARY  0x0020
00067 #define TMROTATE  0x0008
00068
00069
00070 /* misc. defines for drawing and formating */
00071 #define TICKSPACE 20
00072 #define MAXCHARS  32
00073 #define INC   5
00074 #define FORMATFLOAT    "%1.2f"
00075 #define GRIDCOLOR (COLORREF) 0x01000006
00076
00077
00078
00079 /* structure for the track object.  c.f. ptoRect */
00080 typedef struct tagTrackObject{
00081     RECT   rect;
00082     XFORM  xfmChange;   /* World coordinate transform      */
00083     XFORM  xfmDown;     /* transform when the mouse down happens. */
00084     HDC    hdc;
00085     int    Mode;        /* TMROTATE, TMSIZEXY, TMMOVE, ... */
00086     struct tagTrackObject* Next;
00087 } TrackObject, *PTrackObject;
00088
00089
00090 /* function prototypes. */
00091 PTrackObject doTrackObject(PTrackObject, int, HWND, LONG_PTR);
00092 VOID MouseMove(PTrackObject, int, HWND, LONG_PTR);
00093 VOID CenterOrigin (HWND, HDC);
00094
00095
00096 /* Global variables. */
00097 BOOL showTransform, showMouse, showHelp;
00098 HWND hwndTransform, hwndMouse, hwndHelp;
00099 PTrackObject ptoRect = NULL;
00100 HANDLE hInst;
00101 HWND   hwndMain;
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAppUtilDlg Member List

This is the complete list of members for CAppUtilDlg, including all inherited members.
CAppUtilDlg(CWnd *pParent=NULL) | CAppUtilDlg |
DoDataExchange(CDataExchange *pDX) | CAppUtilDlg | [protected, virtual]
IDD enum value | CAppUtilDlg |
m_edtApp | CAppUtilDlg |
m_hIcon | CAppUtilDlg | [protected]
m_nUtilityType | CAppUtilDlg | [private]
m_pCatalog | CAppUtilDlg | [private]
OnAppSearch() | CAppUtilDlg | [protected]
OnClose() | CAppUtilDlg | [protected]
OnInitDialog() | CAppUtilDlg | [protected, virtual]
OnOK() | CAppUtilDlg | [protected, virtual]
ReleaseCatalog() | CAppUtilDlg | [private]
set_Catalog(ICOMAdminCatalog *pCatalog) | CAppUtilDlg |
set_UtilityType(int UtilityType) | CAppUtilDlg |
Generated on Wed Nov 13 2024 16:55:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCJAVA/Components/qcOrder/IOrderDefault.java Source File

  • Com
  • Services
  • Queued_Components
  • QCJAVA
  • Components
  • qcOrder

IOrderDefault.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc7A.tmp" /nologo /d "D:\ComPlusSamples\Source\QCSample1" "D:\ComPlusSamples\Source\QCSample1\QCOrder.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package qcorder;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface IOrderDefault
00019 /** @com.interface(iid=00020400-0000-0000-C000-000000000046, thread=AUTO, type=DUAL) */
00020 public interface IOrderDefault extends qcorder.IOrder
00021 {
00022   /** @com.method(vtoffset=4, dispid=1, type=PROPPUT, name="CustomerId", name2="putCustomerId", addFlagsVtable=4)
00023       @com.parameters([in,type=I4] _jcomparam_0) */
00024   public void setCustomerId(int _jcomparam_0);
00025
00026   /** @com.method(vtoffset=5, dispid=2, type=PROPPUT, name="OrderId", name2="putOrderId", addFlagsVtable=4)
00027       @com.parameters([in,type=I4] _jcomparam_0) */
00028   public void setOrderId(int _jcomparam_0);
00029
00030   /** @com.method(vtoffset=6, dispid=3, type=METHOD, name="LineItem", addFlagsVtable=4)
00031       @com.parameters([in,type=I4] lItemId, [in,type=I4] lQuantity) */
00032   public void LineItem(int lItemId, int lQuantity);
00033
00034   /** @com.method(vtoffset=7, dispid=4, type=METHOD, name="Process", addFlagsVtable=4)
00035       @com.parameters([in,type=I4] lFlags) */
00036   public void Process(int lFlags);
00037
00038
00039   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x20400, (short)0x0, (short)0x0, (byte)0xc0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x46);
00040 }
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/adoint.h Source File

  • Dataaccess
  • rds
  • handler
  • vc

adoint.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:    adoint.h
00004 //
00005 // Copyright: Copyright (c) 1996-1999 Microsoft Corporation
00006 //
00007 // Contents:  ADO Interface header
00008 //
00009 // Comments:
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 #ifndef _ADOINT_H_
00014 #define _ADOINT_H_
00015
00016 #ifndef _INC_TCHAR
00017 #include <tchar.h>
00018 #endif
00019
00020 #if _MSC_VER >= 1100
00021 #define DECLSPEC_UUID(x)    __declspec(uuid(x))
00022 #else
00023 #define DECLSPEC_UUID(x)
00024 #endif
00025
00026
00027 /* this ALWAYS GENERATED file contains the definitions for the interfaces */
00028 /* File created by MIDL compiler version 3.01.75 */
00029 /* at Mon Jul 14 07:56:56 1997
00030  */
00031 /* Compiler settings for m_bobj.odl:
00032     Os (OptLev=s), W4, Zp8, env=Win32, ms_ext, c_ext
00033     error checks: none
00034 */
00035 //@@MIDL_FILE_HEADING(  )
00036 #include "rpc.h"
00037 #include "rpcndr.h"
00038 #ifndef __m_bobj_h__
00039 #define __m_bobj_h__
00040 #ifdef __cplusplus
00041 extern "C"{
00042 #endif
00043 /* Forward Declarations */
00044 #ifndef ___ADOCollection_FWD_DEFINED__
00045 #define ___ADOCollection_FWD_DEFINED__
00046 typedef interface _ADOCollection _ADOCollection;
00047 #endif  /* ___ADOCollection_FWD_DEFINED__ */
00048 #ifndef ___ADODynaCollection_FWD_DEFINED__
00049 #define ___ADODynaCollection_FWD_DEFINED__
00050 typedef interface _ADODynaCollection _ADODynaCollection;
00051 #endif  /* ___ADODynaCollection_FWD_DEFINED__ */
00052 #ifndef ___ADO_FWD_DEFINED__
00053 #define ___ADO_FWD_DEFINED__
00054 typedef interface _ADO _ADO;
00055 #endif  /* ___ADO_FWD_DEFINED__ */
00056 #ifndef __Error_FWD_DEFINED__
00057 #define __Error_FWD_DEFINED__
00058 typedef interface ADOError Error;
00059 #endif  /* __Error_FWD_DEFINED__ */
00060 #ifndef __Errors_FWD_DEFINED__
00061 #define __Errors_FWD_DEFINED__
00062 typedef interface ADOErrors Errors;
00063 #endif  /* __Errors_FWD_DEFINED__ */
00064 #ifndef ___Command_FWD_DEFINED__
00065 #define ___Command_FWD_DEFINED__
00066 typedef interface _ADOCommand _Command;
00067 #endif  /* ___Command_FWD_DEFINED__ */
00068 #ifndef ___Connection_FWD_DEFINED__
00069 #define ___Connection_FWD_DEFINED__
00070 typedef interface _ADOConnection _Connection;
00071 #endif  /* ___Connection_FWD_DEFINED__ */
00072 #ifndef __ADOConnectionConstruction_FWD_DEFINED__
00073 #define __ADOConnectionConstruction_FWD_DEFINED__
00074 typedef interface ADOConnectionConstruction ADOConnectionConstruction;
00075 #endif  /* __ADOConnectionConstruction_FWD_DEFINED__ */
00076 #ifndef __Connection_FWD_DEFINED__
00077 #define __Connection_FWD_DEFINED__
00078 #ifdef __cplusplus
00079 typedef class ADOConnection Connection;
00080 #else
00081 typedef struct ADOConnection Connection;
00082 #endif /* __cplusplus */
00083 #endif  /* __Connection_FWD_DEFINED__ */
00084 #ifndef __Command_FWD_DEFINED__
00085 #define __Command_FWD_DEFINED__
00086 #ifdef __cplusplus
00087 typedef class ADOCommand Command;
00088 #else
00089 typedef struct ADOCommand Command;
00090 #endif /* __cplusplus */
00091 #endif  /* __Command_FWD_DEFINED__ */
00092 #ifndef ___Recordset_FWD_DEFINED__
00093 #define ___Recordset_FWD_DEFINED__
00094 typedef interface _ADORecordset _Recordset;
00095 #endif  /* ___Recordset_FWD_DEFINED__ */
00096 #ifndef __Recordset_FWD_DEFINED__
00097 #define __Recordset_FWD_DEFINED__
00098 #ifdef __cplusplus
00099 typedef class ADORecordset Recordset;
00100 #else
00101 typedef struct ADORecordset Recordset;
00102 #endif /* __cplusplus */
00103 #endif  /* __Recordset_FWD_DEFINED__ */
00104 #ifndef __ADORecordsetConstruction_FWD_DEFINED__
00105 #define __ADORecordsetConstruction_FWD_DEFINED__
00106 typedef interface ADORecordsetConstruction ADORecordsetConstruction;
00107 #endif  /* __ADORecordsetConstruction_FWD_DEFINED__ */
00108 #ifndef __Field_FWD_DEFINED__
00109 #define __Field_FWD_DEFINED__
00110 typedef interface ADOField Field;
00111 #endif  /* __Field_FWD_DEFINED__ */
00112 #ifndef __Fields_FWD_DEFINED__
00113 #define __Fields_FWD_DEFINED__
00114 typedef interface ADOFields Fields;
00115 #endif  /* __Fields_FWD_DEFINED__ */
00116 #ifndef ___Parameter_FWD_DEFINED__
00117 #define ___Parameter_FWD_DEFINED__
00118 typedef interface _ADOParameter _Parameter;
00119 #endif  /* ___Parameter_FWD_DEFINED__ */
00120 #ifndef __Parameter_FWD_DEFINED__
00121 #define __Parameter_FWD_DEFINED__
00122 #ifdef __cplusplus
00123 typedef class ADOParameter Parameter;
00124 #else
00125 typedef struct ADOParameter Parameter;
00126 #endif /* __cplusplus */
00127 #endif  /* __Parameter_FWD_DEFINED__ */
00128 #ifndef __Parameters_FWD_DEFINED__
00129 #define __Parameters_FWD_DEFINED__
00130 typedef interface ADOParameters Parameters;
00131 #endif  /* __Parameters_FWD_DEFINED__ */
00132 #ifndef __Property_FWD_DEFINED__
00133 #define __Property_FWD_DEFINED__
00134 typedef interface ADOProperty Property;
00135 #endif  /* __Property_FWD_DEFINED__ */
00136 #ifndef __Properties_FWD_DEFINED__
00137 #define __Properties_FWD_DEFINED__
00138 typedef interface ADOProperties Properties;
00139 #endif  /* __Properties_FWD_DEFINED__ */
00140 void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
00141 void __RPC_USER MIDL_user_free( void __RPC_FAR * );
00142 /****************************************
00143  * Generated header for interface: __MIDL_itf_m_bobj_0000
00144  * at Mon Jul 14 07:56:56 1997
00145  * using MIDL 3.01.75
00146  ****************************************/
00147 /* [local] */
00148 extern RPC_IF_HANDLE __MIDL_itf_m_bobj_0000_v0_0_c_ifspec;
00149 extern RPC_IF_HANDLE __MIDL_itf_m_bobj_0000_v0_0_s_ifspec;
00150 #ifndef __ADODB_LIBRARY_DEFINED__
00151 #define __ADODB_LIBRARY_DEFINED__
00152 /****************************************
00153  * Generated header for library: ADODB
00154  * at Mon Jul 14 07:56:56 1997
00155  * using MIDL 3.01.75
00156  ****************************************/
00157 /* [helpstring][helpcontext][version][helpfile][uuid] */
00158 typedef /* [uuid][public] */
00159 enum CursorTypeEnum
00160     { adOpenUnspecified = -1,
00161   adOpenForwardOnly = 0,
00162   adOpenKeyset  = 1,
00163   adOpenDynamic = 2,
00164   adOpenStatic  = 3
00165     } CursorTypeEnum;
00166 typedef /* [uuid] */
00167 enum CursorOptionEnum
00168     { adHoldRecords = 0x100,
00169   adMovePrevious  = 0x200,
00170   adAddNew  = 0x1000400,
00171   adDelete  = 0x1000800,
00172   adUpdate  = 0x1008000,
00173   adBookmark  = 0x2000,
00174   adApproxPosition  = 0x4000,
00175   adUpdateBatch = 0x10000,
00176   adResync  = 0x20000,
00177   adNotify  = 0x40000
00178     } CursorOptionEnum;
00179 typedef /* [uuid] */
00180 enum LockTypeEnum
00181     { adLockUnspecified = -1,
00182   adLockReadOnly  = 1,
00183   adLockPessimistic = 2,
00184   adLockOptimistic  = 3,
00185   adLockBatchOptimistic = 4
00186     } LockTypeEnum;
00187 typedef /* [uuid] */
00188 enum ExecuteOptionEnum
00189     { adOptionUnspecified = -1,
00190   adRunAsync  = 0x10
00191     } ExecuteOptionEnum;
00192 typedef /* [uuid] */
00193 enum ObjectStateEnum
00194     { adStateClosed = 0,
00195   adStateOpen = 0x1,
00196   adStateConnecting = 0x2,
00197   adStateExecuting  = 0x4
00198     } ObjectStateEnum;
00199 typedef /* [uuid] */
00200 enum CursorLocationEnum
00201     { adUseNone = 1,
00202   adUseServer = 2,
00203   adUseClient = 3,
00204   adUseClientBatch  = 3
00205     } CursorLocationEnum;
00206 typedef /* [uuid] */
00207 enum DataTypeEnum
00208     { adEmpty = 0,
00209   adTinyInt = 16,
00210   adSmallInt  = 2,
00211   adInteger = 3,
00212   adBigInt  = 20,
00213   adUnsignedTinyInt = 17,
00214   adUnsignedSmallInt  = 18,
00215   adUnsignedInt = 19,
00216   adUnsignedBigInt  = 21,
00217   adSingle  = 4,
00218   adDouble  = 5,
00219   adCurrency  = 6,
00220   adDecimal = 14,
00221   adNumeric = 131,
00222   adBoolean = 11,
00223   adError = 10,
00224   adUserDefined = 132,
00225   adVariant = 12,
00226   adIDispatch = 9,
00227   adIUnknown  = 13,
00228   adGUID  = 72,
00229   adDate  = 7,
00230   adDBDate  = 133,
00231   adDBTime  = 134,
00232   adDBTimeStamp = 135,
00233   adBSTR  = 8,
00234   adChar  = 129,
00235   adVarChar = 200,
00236   adLongVarChar = 201,
00237   adWChar = 130,
00238   adVarWChar  = 202,
00239   adLongVarWChar  = 203,
00240   adBinary  = 128,
00241   adVarBinary = 204,
00242   adLongVarBinary = 205
00243     } DataTypeEnum;
00244 typedef /* [uuid] */
00245 enum FieldAttributeEnum
00246     { adFldMayDefer = 0x2,
00247   adFldUpdatable  = 0x4,
00248   adFldUnknownUpdatable = 0x8,
00249   adFldFixed  = 0x10,
00250   adFldIsNullable = 0x20,
00251   adFldMayBeNull  = 0x40,
00252   adFldLong = 0x80,
00253   adFldRowID  = 0x100,
00254   adFldRowVersion = 0x200,
00255   adFldCacheDeferred  = 0x1000
00256     } FieldAttributeEnum;
00257 typedef /* [uuid] */
00258 enum EditModeEnum
00259     { adEditNone  = 0,
00260   adEditInProgress  = 0x1,
00261   adEditAdd = 0x2
00262     } EditModeEnum;
00263 typedef /* [uuid] */
00264 enum RecordStatusEnum
00265     { adRecOK = 0,
00266   adRecNew  = 0x1,
00267   adRecModified = 0x2,
00268   adRecDeleted  = 0x4,
00269   adRecUnmodified = 0x8,
00270   adRecInvalid  = 0x10,
00271   adRecMultipleChanges  = 0x40,
00272   adRecPendingChanges = 0x80,
00273   adRecCanceled = 0x100,
00274   adRecCantRelease  = 0x400,
00275   adRecConcurrencyViolation = 0x800,
00276   adRecIntegrityViolation = 0x1000,
00277   adRecMaxChangesExceeded = 0x2000,
00278   adRecObjectOpen = 0x4000,
00279   adRecOutOfMemory  = 0x8000,
00280   adRecPermissionDenied = 0x10000,
00281   adRecSchemaViolation  = 0x20000,
00282   adRecDBDeleted  = 0x40000
00283     } RecordStatusEnum;
00284 typedef
00285 enum GetRowsOptionEnum
00286     { adGetRowsRest = -1
00287     } GetRowsOptionEnum;
00288 typedef /* [uuid] */
00289 enum PositionEnum
00290     { adPosUnknown  = -1,
00291   adPosBOF  = -2,
00292   adPosEOF  = -3
00293     } PositionEnum;
00294 typedef
00295 enum BookmarkEnum
00296     { adBookmarkCurrent = 0,
00297   adBookmarkFirst = 1,
00298   adBookmarkLast  = 2
00299     } BookmarkEnum;
00300 typedef /* [uuid] */
00301 enum MarshalOptionsEnum
00302     { adMarshalAll  = 0,
00303   adMarshalModifiedOnly = 1
00304     } MarshalOptionsEnum;
00305 typedef
00306 enum AffectEnum
00307     { adAffectCurrent = 1,
00308   adAffectGroup = 2,
00309   adAffectAll = 3
00310     } AffectEnum;
00311 typedef
00312 enum FilterGroupEnum
00313     { adFilterNone  = 0,
00314   adFilterPendingRecords  = 1,
00315   adFilterAffectedRecords = 2,
00316   adFilterFetchedRecords  = 3,
00317   adFilterPredicate = 4
00318     } FilterGroupEnum;
00319 typedef /* [hidden] */
00320 enum SearchDirection
00321     { adSearchForward = 0,
00322   adSearchBackward  = 1
00323     } SearchDirectionEnum;
00324 typedef /* [uuid] */
00325 enum ConnectPromptEnum
00326     { adPromptAlways  = 1,
00327   adPromptComplete  = 2,
00328   adPromptCompleteRequired  = 3,
00329   adPromptNever = 4
00330     } ConnectPromptEnum;
00331 typedef /* [uuid] */
00332 enum ConnectModeEnum
00333     { adModeUnknown = 0,
00334   adModeRead  = 1,
00335   adModeWrite = 2,
00336   adModeReadWrite = 3,
00337   adModeShareDenyRead = 4,
00338   adModeShareDenyWrite  = 8,
00339   adModeShareExclusive  = 0xc,
00340   adModeShareDenyNone = 0x10
00341     } ConnectModeEnum;
00342 typedef /* [uuid] */
00343 enum IsolationLevelEnum
00344     { adXactUnspecified = 0xffffffff,
00345   adXactChaos = 0x10,
00346   adXactReadUncommitted = 0x100,
00347   adXactBrowse  = 0x100,
00348   adXactCursorStability = 0x1000,
00349   adXactReadCommitted = 0x1000,
00350   adXactRepeatableRead  = 0x10000,
00351   adXactSerializable  = 0x100000,
00352   adXactIsolated  = 0x100000
00353     } IsolationLevelEnum;
00354 typedef /* [uuid] */
00355 enum XactAttributeEnum
00356     { adXactCommitRetaining = 0x20000,
00357   adXactAbortRetaining  = 0x40000
00358     } XactAttributeEnum;
00359 typedef /* [uuid] */
00360 enum PropertyAttributesEnum
00361     { adPropNotSupported  = 0,
00362   adPropRequired  = 0x1,
00363   adPropOptional  = 0x2,
00364   adPropRead  = 0x200,
00365   adPropWrite = 0x400
00366     } PropertyAttributesEnum;
00367 typedef /* [uuid] */
00368 enum ErrorValueEnum
00369     { adErrInvalidArgument  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xbb9),
00370   adErrNoCurrentRecord  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xbcd),
00371   adErrIllegalOperation =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xc93),
00372   adErrInTransaction  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xcae),
00373   adErrFeatureNotAvailable  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xcb3),
00374   adErrItemNotFound =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xcc1),
00375   adErrObjectInADOCollection  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xd27),
00376   adErrObjectNotSet =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xd5c),
00377   adErrDataConversion =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xd5d),
00378   adErrObjectClosed =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe78),
00379   adErrObjectOpen = 0xe79,
00380   adErrProviderNotFound =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe7a),
00381   adErrBoundToCommand =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe7b),
00382   adErrInvalidParamInfo =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe7c),
00383   adErrInvalidConnection  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe7d),
00384   adErrStillExecuting =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe7f),
00385   adErrStillConnecting  =     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, 0xe81),
00386     } ErrorValueEnum;
00387 typedef /* [uuid] */
00388 enum ParameterAttributesEnum
00389     { adParamSigned = 0x10,
00390   adParamNullable = 0x40,
00391   adParamLong = 0x80
00392     } ParameterAttributesEnum;
00393 typedef /* [uuid] */
00394 enum ParameterDirectionEnum
00395     { adParamUnknown  = 0,
00396   adParamInput  = 0x1,
00397   adParamOutput = 0x2,
00398   adParamInputOutput  = 0x3,
00399   adParamReturnValue  = 0x4
00400     } ParameterDirectionEnum;
00401 typedef /* [uuid] */
00402 enum CommandTypeEnum
00403     { adCmdUnspecified  = -1,
00404   adCmdUnknown  = 0x8,
00405   adCmdText = 0x1,
00406   adCmdTable  = 0x2,
00407   adCmdStoredProc = 0x4
00408     } CommandTypeEnum;
00409 typedef /* [uuid] */
00410 enum SchemaEnum
00411     { adSchemaProviderSpecific  = -1,
00412   adSchemaAsserts = 0,
00413   adSchemaCatalogs  = 1,
00414   adSchemaCharacterSets = 2,
00415   adSchemaCollations  = 3,
00416   adSchemaColumns = 4,
00417   adSchemaCheckConstraints  = 5,
00418   adSchemaConstraintColumnUsage = 6,
00419   adSchemaConstraintTableUsage  = 7,
00420   adSchemaKeyColumnUsage  = 8,
00421   adSchemaReferentialContraints = 9,
00422   adSchemaTableConstraints  = 10,
00423   adSchemaColumnsDomainUsage  = 11,
00424   adSchemaIndexes = 12,
00425   adSchemaColumnPrivileges  = 13,
00426   adSchemaTablePrivileges = 14,
00427   adSchemaUsagePrivileges = 15,
00428   adSchemaProcedures  = 16,
00429   adSchemaSchemata  = 17,
00430   adSchemaSQLLanguages  = 18,
00431   adSchemaStatistics  = 19,
00432   adSchemaTables  = 20,
00433   adSchemaTranslations  = 21,
00434   adSchemaProviderTypes = 22,
00435   adSchemaViews = 23,
00436   adSchemaViewColumnUsage = 24,
00437   adSchemaViewTableUsage  = 25,
00438   adSchemaProcedureParameters = 26,
00439   adSchemaForeignKeys = 27,
00440   adSchemaPrimaryKeys = 28,
00441   adSchemaProcedureColumns  = 29
00442     } SchemaEnum;
00443 EXTERN_C const IID LIBID_ADODB;
00444 #ifndef ___ADOCollection_INTERFACE_DEFINED__
00445 #define ___ADOCollection_INTERFACE_DEFINED__
00446 /****************************************
00447  * Generated header for interface: _ADOCollection
00448  * at Mon Jul 14 07:56:56 1997
00449  * using MIDL 3.01.75
00450  ****************************************/
00451 /* [object][uuid][nonextensible][dual] */
00452 EXTERN_C const IID IID__ADOCollection;
00453 #if defined(__cplusplus) && !defined(CINTERFACE)
00454
00455     interface DECLSPEC_UUID("00000512-0000-0010-8000-00AA006D2EA4")
00456     _ADOCollection : public IDispatch
00457     {
00458     public:
00459         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Count(
00460             /* [retval][out] */ long __RPC_FAR *c) = 0;
00461
00462         virtual /* [id][restricted] */ HRESULT STDMETHODCALLTYPE _NewEnum(
00463             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject) = 0;
00464
00465         virtual /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE Refresh( void) = 0;
00466
00467     };
00468
00469 #else   /* C style interface */
00470     typedef struct _ADOCollectionVtbl
00471     {
00472         BEGIN_INTERFACE
00473
00474         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00475             _ADOCollection __RPC_FAR * This,
00476             /* [in] */ REFIID riid,
00477             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00478
00479         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00480             _ADOCollection __RPC_FAR * This);
00481
00482         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00483             _ADOCollection __RPC_FAR * This);
00484
00485         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00486             _ADOCollection __RPC_FAR * This,
00487             /* [out] */ UINT __RPC_FAR *pctinfo);
00488
00489         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00490             _ADOCollection __RPC_FAR * This,
00491             /* [in] */ UINT iTInfo,
00492             /* [in] */ LCID lcid,
00493             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00494
00495         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00496             _ADOCollection __RPC_FAR * This,
00497             /* [in] */ REFIID riid,
00498             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00499             /* [in] */ UINT cNames,
00500             /* [in] */ LCID lcid,
00501             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00502
00503         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00504             _ADOCollection __RPC_FAR * This,
00505             /* [in] */ DISPID dispIdMember,
00506             /* [in] */ REFIID riid,
00507             /* [in] */ LCID lcid,
00508             /* [in] */ WORD wFlags,
00509             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00510             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00511             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00512             /* [out] */ UINT __RPC_FAR *puArgErr);
00513
00514         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Count )(
00515             _ADOCollection __RPC_FAR * This,
00516             /* [retval][out] */ long __RPC_FAR *c);
00517
00518         /* [id][restricted] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *_NewEnum )(
00519             _ADOCollection __RPC_FAR * This,
00520             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
00521
00522         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Refresh )(
00523             _ADOCollection __RPC_FAR * This);
00524
00525         END_INTERFACE
00526     } _ADOCollectionVtbl;
00527     interface _ADOCollection
00528     {
00529         CONST_VTBL struct _ADOCollectionVtbl __RPC_FAR *lpVtbl;
00530     };
00531
00532 #ifdef COBJMACROS
00533 #define _ADOCollection_QueryInterface(This,riid,ppvObject)  \
00534     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00535 #define _ADOCollection_AddRef(This) \
00536     (This)->lpVtbl -> AddRef(This)
00537 #define _ADOCollection_Release(This)  \
00538     (This)->lpVtbl -> Release(This)
00539 #define _ADOCollection_GetTypeInfoCount(This,pctinfo) \
00540     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00541 #define _ADOCollection_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
00542     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00543 #define _ADOCollection_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
00544     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00545 #define _ADOCollection_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
00546     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00547 #define _Collection_get_Count(This,c) \
00548     (This)->lpVtbl -> get_Count(This,c)
00549 #define _ADOCollection__NewEnum(This,ppvObject) \
00550     (This)->lpVtbl -> _NewEnum(This,ppvObject)
00551 #define _ADOCollection_Refresh(This)  \
00552     (This)->lpVtbl -> Refresh(This)
00553 #endif /* COBJMACROS */
00554 #endif  /* C style interface */
00555 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Collection_get_Count_Proxy(
00556     _ADOCollection __RPC_FAR * This,
00557     /* [retval][out] */ long __RPC_FAR *c);
00558 void __RPC_STUB _Collection_get_Count_Stub(
00559     IRpcStubBuffer *This,
00560     IRpcChannelBuffer *_pRpcChannelBuffer,
00561     PRPC_MESSAGE _pRpcMessage,
00562     DWORD *_pdwStubPhase);
00563 /* [id][restricted] */ HRESULT STDMETHODCALLTYPE _ADOCollection__NewEnum_Proxy(
00564     _ADOCollection __RPC_FAR * This,
00565     /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
00566 void __RPC_STUB _ADOCollection__NewEnum_Stub(
00567     IRpcStubBuffer *This,
00568     IRpcChannelBuffer *_pRpcChannelBuffer,
00569     PRPC_MESSAGE _pRpcMessage,
00570     DWORD *_pdwStubPhase);
00571 /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE _ADOCollection_Refresh_Proxy(
00572     _ADOCollection __RPC_FAR * This);
00573 void __RPC_STUB _ADOCollection_Refresh_Stub(
00574     IRpcStubBuffer *This,
00575     IRpcChannelBuffer *_pRpcChannelBuffer,
00576     PRPC_MESSAGE _pRpcMessage,
00577     DWORD *_pdwStubPhase);
00578 #endif  /* ___ADOCollection_INTERFACE_DEFINED__ */
00579 #ifndef ___ADODynaCollection_INTERFACE_DEFINED__
00580 #define ___ADODynaCollection_INTERFACE_DEFINED__
00581 /****************************************
00582  * Generated header for interface: _ADODynaCollection
00583  * at Mon Jul 14 07:56:56 1997
00584  * using MIDL 3.01.75
00585  ****************************************/
00586 /* [object][uuid][nonextensible][dual] */
00587 EXTERN_C const IID IID__ADODynaCollection;
00588 #if defined(__cplusplus) && !defined(CINTERFACE)
00589
00590     interface DECLSPEC_UUID("00000513-0000-0010-8000-00AA006D2EA4")
00591 _ADODynaCollection : public _ADOCollection
00592     {
00593     public:
00594         virtual /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE Append(
00595             /* [in] */ IDispatch __RPC_FAR *Object) = 0;
00596
00597         virtual /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE Delete(
00598             /* [in] */ VARIANT Index) = 0;
00599
00600     };
00601
00602 #else   /* C style interface */
00603     typedef struct _ADODynaCollectionVtbl
00604     {
00605         BEGIN_INTERFACE
00606
00607         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00608             _ADODynaCollection __RPC_FAR * This,
00609             /* [in] */ REFIID riid,
00610             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00611
00612         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00613             _ADODynaCollection __RPC_FAR * This);
00614
00615         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00616             _ADODynaCollection __RPC_FAR * This);
00617
00618         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00619             _ADODynaCollection __RPC_FAR * This,
00620             /* [out] */ UINT __RPC_FAR *pctinfo);
00621
00622         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00623             _ADODynaCollection __RPC_FAR * This,
00624             /* [in] */ UINT iTInfo,
00625             /* [in] */ LCID lcid,
00626             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00627
00628         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00629             _ADODynaCollection __RPC_FAR * This,
00630             /* [in] */ REFIID riid,
00631             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00632             /* [in] */ UINT cNames,
00633             /* [in] */ LCID lcid,
00634             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00635
00636         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00637             _ADODynaCollection __RPC_FAR * This,
00638             /* [in] */ DISPID dispIdMember,
00639             /* [in] */ REFIID riid,
00640             /* [in] */ LCID lcid,
00641             /* [in] */ WORD wFlags,
00642             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00643             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00644             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00645             /* [out] */ UINT __RPC_FAR *puArgErr);
00646
00647         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Count )(
00648             _ADODynaCollection __RPC_FAR * This,
00649             /* [retval][out] */ long __RPC_FAR *c);
00650
00651         /* [id][restricted] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *_NewEnum )(
00652             _ADODynaCollection __RPC_FAR * This,
00653             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
00654
00655         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Refresh )(
00656             _ADODynaCollection __RPC_FAR * This);
00657
00658         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Append )(
00659             _ADODynaCollection __RPC_FAR * This,
00660             /* [in] */ IDispatch __RPC_FAR *Object);
00661
00662         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Delete )(
00663             _ADODynaCollection __RPC_FAR * This,
00664             /* [in] */ VARIANT Index);
00665
00666         END_INTERFACE
00667     } _ADODynaCollectionVtbl;
00668     interface _ADODynaCollection
00669     {
00670         CONST_VTBL struct _ADODynaCollectionVtbl __RPC_FAR *lpVtbl;
00671     };
00672
00673 #ifdef COBJMACROS
00674 #define _ADODynaCollection_QueryInterface(This,riid,ppvObject)  \
00675     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00676 #define _ADODynaCollection_AddRef(This) \
00677     (This)->lpVtbl -> AddRef(This)
00678 #define _ADODynaCollection_Release(This)  \
00679     (This)->lpVtbl -> Release(This)
00680 #define _ADODynaCollection_GetTypeInfoCount(This,pctinfo) \
00681     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00682 #define _ADODynaCollection_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
00683     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00684 #define _ADODynaCollection_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
00685     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00686 #define _ADODynaCollection_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
00687     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00688 #define _DynaCollection_get_Count(This,c) \
00689     (This)->lpVtbl -> get_Count(This,c)
00690 #define _ADODynaCollection__NewEnum(This,ppvObject) \
00691     (This)->lpVtbl -> _NewEnum(This,ppvObject)
00692 #define _ADODynaCollection_Refresh(This)  \
00693     (This)->lpVtbl -> Refresh(This)
00694 #define _ADODynaCollection_Append(This,Object)  \
00695     (This)->lpVtbl -> Append(This,Object)
00696 #define _ADODynaCollection_Delete(This,Index) \
00697     (This)->lpVtbl -> Delete(This,Index)
00698 #endif /* COBJMACROS */
00699 #endif  /* C style interface */
00700 /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE _ADODynaCollection_Append_Proxy(
00701     _ADODynaCollection __RPC_FAR * This,
00702     /* [in] */ IDispatch __RPC_FAR *Object);
00703 void __RPC_STUB _ADODynaCollection_Append_Stub(
00704     IRpcStubBuffer *This,
00705     IRpcChannelBuffer *_pRpcChannelBuffer,
00706     PRPC_MESSAGE _pRpcMessage,
00707     DWORD *_pdwStubPhase);
00708 /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE _ADODynaCollection_Delete_Proxy(
00709     _ADODynaCollection __RPC_FAR * This,
00710     /* [in] */ VARIANT Index);
00711 void __RPC_STUB _ADODynaCollection_Delete_Stub(
00712     IRpcStubBuffer *This,
00713     IRpcChannelBuffer *_pRpcChannelBuffer,
00714     PRPC_MESSAGE _pRpcMessage,
00715     DWORD *_pdwStubPhase);
00716 #endif  /* ___ADODynaCollection_INTERFACE_DEFINED__ */
00717 #ifndef ___ADO_INTERFACE_DEFINED__
00718 #define ___ADO_INTERFACE_DEFINED__
00719 /****************************************
00720  * Generated header for interface: _ADO
00721  * at Mon Jul 14 07:56:56 1997
00722  * using MIDL 3.01.75
00723  ****************************************/
00724 /* [object][uuid][nonextensible][dual] */
00725 EXTERN_C const IID IID__ADO;
00726 #if defined(__cplusplus) && !defined(CINTERFACE)
00727
00728     interface DECLSPEC_UUID("00000534-0000-0010-8000-00AA006D2EA4")
00729     _ADO : public IDispatch
00730     {
00731     public:
00732         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_Properties(
00733             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject) = 0;
00734
00735     };
00736
00737 #else   /* C style interface */
00738     typedef struct _ADOVtbl
00739     {
00740         BEGIN_INTERFACE
00741
00742         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00743             _ADO __RPC_FAR * This,
00744             /* [in] */ REFIID riid,
00745             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00746
00747         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00748             _ADO __RPC_FAR * This);
00749
00750         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00751             _ADO __RPC_FAR * This);
00752
00753         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00754             _ADO __RPC_FAR * This,
00755             /* [out] */ UINT __RPC_FAR *pctinfo);
00756
00757         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00758             _ADO __RPC_FAR * This,
00759             /* [in] */ UINT iTInfo,
00760             /* [in] */ LCID lcid,
00761             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00762
00763         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00764             _ADO __RPC_FAR * This,
00765             /* [in] */ REFIID riid,
00766             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00767             /* [in] */ UINT cNames,
00768             /* [in] */ LCID lcid,
00769             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00770
00771         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00772             _ADO __RPC_FAR * This,
00773             /* [in] */ DISPID dispIdMember,
00774             /* [in] */ REFIID riid,
00775             /* [in] */ LCID lcid,
00776             /* [in] */ WORD wFlags,
00777             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00778             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00779             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00780             /* [out] */ UINT __RPC_FAR *puArgErr);
00781
00782         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Properties )(
00783             _ADO __RPC_FAR * This,
00784             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
00785
00786         END_INTERFACE
00787     } _ADOVtbl;
00788     interface _ADO
00789     {
00790         CONST_VTBL struct _ADOVtbl __RPC_FAR *lpVtbl;
00791     };
00792
00793 #ifdef COBJMACROS
00794 #define _ADO_QueryInterface(This,riid,ppvObject)  \
00795     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00796 #define _ADO_AddRef(This) \
00797     (This)->lpVtbl -> AddRef(This)
00798 #define _ADO_Release(This)  \
00799     (This)->lpVtbl -> Release(This)
00800 #define _ADO_GetTypeInfoCount(This,pctinfo) \
00801     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00802 #define _ADO_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
00803     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00804 #define _ADO_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
00805     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00806 #define _ADO_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
00807     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00808 #define _ADO_get_Properties(This,ppvObject) \
00809     (This)->lpVtbl -> get_Properties(This,ppvObject)
00810 #endif /* COBJMACROS */
00811 #endif  /* C style interface */
00812 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _ADO_get_Properties_Proxy(
00813     _ADO __RPC_FAR * This,
00814     /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
00815 void __RPC_STUB _ADO_get_Properties_Stub(
00816     IRpcStubBuffer *This,
00817     IRpcChannelBuffer *_pRpcChannelBuffer,
00818     PRPC_MESSAGE _pRpcMessage,
00819     DWORD *_pdwStubPhase);
00820 #endif  /* ___ADO_INTERFACE_DEFINED__ */
00821 #ifndef __Error_INTERFACE_DEFINED__
00822 #define __Error_INTERFACE_DEFINED__
00823 /****************************************
00824  * Generated header for interface: Error
00825  * at Mon Jul 14 07:56:56 1997
00826  * using MIDL 3.01.75
00827  ****************************************/
00828 /* [object][helpstring][helpcontext][uuid][nonextensible][dual] */
00829 EXTERN_C const IID IID_Error;
00830 #if defined(__cplusplus) && !defined(CINTERFACE)
00831
00832     interface DECLSPEC_UUID("00000500-0000-0010-8000-00AA006D2EA4")
00833     ADOError : public IDispatch
00834     {
00835     public:
00836         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Number(
00837             /* [retval][out] */ long __RPC_FAR *pl) = 0;
00838
00839         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Source(
00840             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
00841
00842         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_Description(
00843             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
00844
00845         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_HelpFile(
00846             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
00847
00848         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_HelpContext(
00849             /* [retval][out] */ long __RPC_FAR *pl) = 0;
00850
00851         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_SQLState(
00852             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
00853
00854         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_NativeError(
00855             /* [retval][out] */ long __RPC_FAR *pl) = 0;
00856
00857     };
00858
00859 #else   /* C style interface */
00860     typedef struct ErrorVtbl
00861     {
00862         BEGIN_INTERFACE
00863
00864         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
00865             ADOError __RPC_FAR * This,
00866             /* [in] */ REFIID riid,
00867             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
00868
00869         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
00870             ADOError __RPC_FAR * This);
00871
00872         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
00873             ADOError __RPC_FAR * This);
00874
00875         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
00876             ADOError __RPC_FAR * This,
00877             /* [out] */ UINT __RPC_FAR *pctinfo);
00878
00879         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
00880             ADOError __RPC_FAR * This,
00881             /* [in] */ UINT iTInfo,
00882             /* [in] */ LCID lcid,
00883             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
00884
00885         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
00886             ADOError __RPC_FAR * This,
00887             /* [in] */ REFIID riid,
00888             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00889             /* [in] */ UINT cNames,
00890             /* [in] */ LCID lcid,
00891             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
00892
00893         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
00894             ADOError __RPC_FAR * This,
00895             /* [in] */ DISPID dispIdMember,
00896             /* [in] */ REFIID riid,
00897             /* [in] */ LCID lcid,
00898             /* [in] */ WORD wFlags,
00899             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00900             /* [out] */ VARIANT __RPC_FAR *pVarResult,
00901             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00902             /* [out] */ UINT __RPC_FAR *puArgErr);
00903
00904         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Number )(
00905             ADOError __RPC_FAR * This,
00906             /* [retval][out] */ long __RPC_FAR *pl);
00907
00908         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Source )(
00909             ADOError __RPC_FAR * This,
00910             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00911
00912         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Description )(
00913             ADOError __RPC_FAR * This,
00914             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00915
00916         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_HelpFile )(
00917             ADOError __RPC_FAR * This,
00918             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00919
00920         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_HelpContext )(
00921             ADOError __RPC_FAR * This,
00922             /* [retval][out] */ long __RPC_FAR *pl);
00923
00924         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_SQLState )(
00925             ADOError __RPC_FAR * This,
00926             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00927
00928         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_NativeError )(
00929             ADOError __RPC_FAR * This,
00930             /* [retval][out] */ long __RPC_FAR *pl);
00931
00932         END_INTERFACE
00933     } ErrorVtbl;
00934     interface Error
00935     {
00936         CONST_VTBL struct ErrorVtbl __RPC_FAR *lpVtbl;
00937     };
00938
00939 #ifdef COBJMACROS
00940 #define Error_QueryInterface(This,riid,ppvObject) \
00941     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
00942 #define Error_AddRef(This)  \
00943     (This)->lpVtbl -> AddRef(This)
00944 #define Error_Release(This) \
00945     (This)->lpVtbl -> Release(This)
00946 #define Error_GetTypeInfoCount(This,pctinfo)  \
00947     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
00948 #define Error_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
00949     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
00950 #define Error_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
00951     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
00952 #define Error_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
00953     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
00954 #define Error_get_Number(This,pl) \
00955     (This)->lpVtbl -> get_Number(This,pl)
00956 #define Error_get_Source(This,pbstr)  \
00957     (This)->lpVtbl -> get_Source(This,pbstr)
00958 #define Error_get_Description(This,pbstr) \
00959     (This)->lpVtbl -> get_Description(This,pbstr)
00960 #define Error_get_HelpFile(This,pbstr)  \
00961     (This)->lpVtbl -> get_HelpFile(This,pbstr)
00962 #define Error_get_HelpContext(This,pl)  \
00963     (This)->lpVtbl -> get_HelpContext(This,pl)
00964 #define Error_get_SQLState(This,pbstr)  \
00965     (This)->lpVtbl -> get_SQLState(This,pbstr)
00966 #define Error_get_NativeError(This,pl)  \
00967     (This)->lpVtbl -> get_NativeError(This,pl)
00968 #endif /* COBJMACROS */
00969 #endif  /* C style interface */
00970 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Error_get_Number_Proxy(
00971     ADOError __RPC_FAR * This,
00972     /* [retval][out] */ long __RPC_FAR *pl);
00973 void __RPC_STUB Error_get_Number_Stub(
00974     IRpcStubBuffer *This,
00975     IRpcChannelBuffer *_pRpcChannelBuffer,
00976     PRPC_MESSAGE _pRpcMessage,
00977     DWORD *_pdwStubPhase);
00978 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Error_get_Source_Proxy(
00979     ADOError __RPC_FAR * This,
00980     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00981 void __RPC_STUB Error_get_Source_Stub(
00982     IRpcStubBuffer *This,
00983     IRpcChannelBuffer *_pRpcChannelBuffer,
00984     PRPC_MESSAGE _pRpcMessage,
00985     DWORD *_pdwStubPhase);
00986 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE Error_get_Description_Proxy(
00987     ADOError __RPC_FAR * This,
00988     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00989 void __RPC_STUB Error_get_Description_Stub(
00990     IRpcStubBuffer *This,
00991     IRpcChannelBuffer *_pRpcChannelBuffer,
00992     PRPC_MESSAGE _pRpcMessage,
00993     DWORD *_pdwStubPhase);
00994 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Error_get_HelpFile_Proxy(
00995     ADOError __RPC_FAR * This,
00996     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
00997 void __RPC_STUB Error_get_HelpFile_Stub(
00998     IRpcStubBuffer *This,
00999     IRpcChannelBuffer *_pRpcChannelBuffer,
01000     PRPC_MESSAGE _pRpcMessage,
01001     DWORD *_pdwStubPhase);
01002 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Error_get_HelpContext_Proxy(
01003     ADOError __RPC_FAR * This,
01004     /* [retval][out] */ long __RPC_FAR *pl);
01005 void __RPC_STUB Error_get_HelpContext_Stub(
01006     IRpcStubBuffer *This,
01007     IRpcChannelBuffer *_pRpcChannelBuffer,
01008     PRPC_MESSAGE _pRpcMessage,
01009     DWORD *_pdwStubPhase);
01010 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Error_get_SQLState_Proxy(
01011     ADOError __RPC_FAR * This,
01012     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01013 void __RPC_STUB Error_get_SQLState_Stub(
01014     IRpcStubBuffer *This,
01015     IRpcChannelBuffer *_pRpcChannelBuffer,
01016     PRPC_MESSAGE _pRpcMessage,
01017     DWORD *_pdwStubPhase);
01018 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Error_get_NativeError_Proxy(
01019     ADOError __RPC_FAR * This,
01020     /* [retval][out] */ long __RPC_FAR *pl);
01021 void __RPC_STUB Error_get_NativeError_Stub(
01022     IRpcStubBuffer *This,
01023     IRpcChannelBuffer *_pRpcChannelBuffer,
01024     PRPC_MESSAGE _pRpcMessage,
01025     DWORD *_pdwStubPhase);
01026 #endif  /* __Error_INTERFACE_DEFINED__ */
01027 #ifndef __Errors_INTERFACE_DEFINED__
01028 #define __Errors_INTERFACE_DEFINED__
01029 /****************************************
01030  * Generated header for interface: Errors
01031  * at Mon Jul 14 07:56:56 1997
01032  * using MIDL 3.01.75
01033  ****************************************/
01034 /* [object][uuid][helpstring][helpcontext][nonextensible][dual] */
01035 EXTERN_C const IID IID_Errors;
01036 #if defined(__cplusplus) && !defined(CINTERFACE)
01037
01038     interface DECLSPEC_UUID("00000501-0000-0010-8000-00AA006D2EA4")
01039     ADOErrors : public _ADOCollection
01040     {
01041     public:
01042         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Item(
01043             /* [in] */ VARIANT Index,
01044             /* [retval][out] */ ADOError __RPC_FAR *__RPC_FAR *ppvObject) = 0;
01045
01046         virtual HRESULT STDMETHODCALLTYPE Clear( void) = 0;
01047
01048     };
01049
01050 #else   /* C style interface */
01051     typedef struct ErrorsVtbl
01052     {
01053         BEGIN_INTERFACE
01054
01055         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
01056             ADOErrors __RPC_FAR * This,
01057             /* [in] */ REFIID riid,
01058             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
01059
01060         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
01061             ADOErrors __RPC_FAR * This);
01062
01063         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
01064             ADOErrors __RPC_FAR * This);
01065
01066         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
01067             ADOErrors __RPC_FAR * This,
01068             /* [out] */ UINT __RPC_FAR *pctinfo);
01069
01070         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
01071             ADOErrors __RPC_FAR * This,
01072             /* [in] */ UINT iTInfo,
01073             /* [in] */ LCID lcid,
01074             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
01075
01076         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
01077             ADOErrors __RPC_FAR * This,
01078             /* [in] */ REFIID riid,
01079             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
01080             /* [in] */ UINT cNames,
01081             /* [in] */ LCID lcid,
01082             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
01083
01084         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
01085             ADOErrors __RPC_FAR * This,
01086             /* [in] */ DISPID dispIdMember,
01087             /* [in] */ REFIID riid,
01088             /* [in] */ LCID lcid,
01089             /* [in] */ WORD wFlags,
01090             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
01091             /* [out] */ VARIANT __RPC_FAR *pVarResult,
01092             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
01093             /* [out] */ UINT __RPC_FAR *puArgErr);
01094
01095         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Count )(
01096             ADOErrors __RPC_FAR * This,
01097             /* [retval][out] */ long __RPC_FAR *c);
01098
01099         /* [id][restricted] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *_NewEnum )(
01100             ADOErrors __RPC_FAR * This,
01101             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
01102
01103         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Refresh )(
01104             ADOErrors __RPC_FAR * This);
01105
01106         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Item )(
01107             ADOErrors __RPC_FAR * This,
01108             /* [in] */ VARIANT Index,
01109             /* [retval][out] */ ADOError __RPC_FAR *__RPC_FAR *ppvObject);
01110
01111         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Clear )(
01112             ADOErrors __RPC_FAR * This);
01113
01114         END_INTERFACE
01115     } ErrorsVtbl;
01116     interface Errors
01117     {
01118         CONST_VTBL struct ErrorsVtbl __RPC_FAR *lpVtbl;
01119     };
01120
01121 #ifdef COBJMACROS
01122 #define Errors_QueryInterface(This,riid,ppvObject)  \
01123     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
01124 #define Errors_AddRef(This) \
01125     (This)->lpVtbl -> AddRef(This)
01126 #define Errors_Release(This)  \
01127     (This)->lpVtbl -> Release(This)
01128 #define Errors_GetTypeInfoCount(This,pctinfo) \
01129     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
01130 #define Errors_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
01131     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
01132 #define Errors_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
01133     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
01134 #define Errors_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
01135     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
01136 #define Errors_get_Count(This,c)  \
01137     (This)->lpVtbl -> get_Count(This,c)
01138 #define Errors__NewEnum(This,ppvObject) \
01139     (This)->lpVtbl -> _NewEnum(This,ppvObject)
01140 #define Errors_Refresh(This)  \
01141     (This)->lpVtbl -> Refresh(This)
01142 #define Errors_get_Item(This,Index,ppvObject) \
01143     (This)->lpVtbl -> get_Item(This,Index,ppvObject)
01144 #define Errors_Clear(This)  \
01145     (This)->lpVtbl -> Clear(This)
01146 #endif /* COBJMACROS */
01147 #endif  /* C style interface */
01148 /* [id][propget] */ HRESULT STDMETHODCALLTYPE Errors_get_Item_Proxy(
01149     ADOErrors __RPC_FAR * This,
01150     /* [in] */ VARIANT Index,
01151     /* [retval][out] */ ADOError __RPC_FAR *__RPC_FAR *ppvObject);
01152 void __RPC_STUB Errors_get_Item_Stub(
01153     IRpcStubBuffer *This,
01154     IRpcChannelBuffer *_pRpcChannelBuffer,
01155     PRPC_MESSAGE _pRpcMessage,
01156     DWORD *_pdwStubPhase);
01157 HRESULT STDMETHODCALLTYPE Errors_Clear_Proxy(
01158     ADOErrors __RPC_FAR * This);
01159 void __RPC_STUB Errors_Clear_Stub(
01160     IRpcStubBuffer *This,
01161     IRpcChannelBuffer *_pRpcChannelBuffer,
01162     PRPC_MESSAGE _pRpcMessage,
01163     DWORD *_pdwStubPhase);
01164 #endif  /* __Errors_INTERFACE_DEFINED__ */
01165 #ifndef ___Command_INTERFACE_DEFINED__
01166 #define ___Command_INTERFACE_DEFINED__
01167 /****************************************
01168  * Generated header for interface: _Command
01169  * at Mon Jul 14 07:56:56 1997
01170  * using MIDL 3.01.75
01171  ****************************************/
01172 /* [object][uuid][nonextensible][dual] */
01173 EXTERN_C const IID IID__Command;
01174 #if defined(__cplusplus) && !defined(CINTERFACE)
01175
01176     interface DECLSPEC_UUID("00000508-0000-0010-8000-00AA006D2EA4")
01177     _ADOCommand : public _ADO
01178     {
01179     public:
01180         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ActiveConnection(
01181             /* [retval][out] */ _ADOConnection __RPC_FAR *__RPC_FAR *ppvObject) = 0;
01182
01183         virtual /* [propputref] */ HRESULT STDMETHODCALLTYPE putref_ActiveConnection(
01184             /* [in] */ _ADOConnection __RPC_FAR *pCon) = 0;
01185
01186         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ActiveConnection(
01187             /* [in] */ VARIANT vConn) = 0;
01188
01189         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CommandText(
01190             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
01191
01192         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CommandText(
01193             /* [in] */ BSTR bstr) = 0;
01194
01195         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CommandTimeout(
01196             /* [retval][out] */ LONG __RPC_FAR *pl) = 0;
01197
01198         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CommandTimeout(
01199             /* [in] */ LONG Timeout) = 0;
01200
01201         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Prepared(
01202             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pfPrepared) = 0;
01203
01204         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Prepared(
01205             /* [in] */ VARIANT_BOOL fPrepared) = 0;
01206
01207         virtual /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE Execute(
01208             /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
01209             /* [optional][in] */ VARIANT __RPC_FAR *Parameters,
01210             /* [defaultvalue][in] */ long Options,
01211             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppirs) = 0;
01212
01213         virtual HRESULT STDMETHODCALLTYPE CreateParameter(
01214             /* [defaultvalue][in] */ BSTR Name,
01215             /* [defaultvalue][in] */ DataTypeEnum Type,
01216             /* [defaultvalue][in] */ ParameterDirectionEnum Direction,
01217             /* [defaultvalue][in] */ long Size,
01218             /* [optional][in] */ VARIANT Value,
01219             /* [retval][out] */ _ADOParameter __RPC_FAR *__RPC_FAR *ppiprm) = 0;
01220
01221         virtual HRESULT STDMETHODCALLTYPE Cancel( void) = 0;
01222
01223         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_Parameters(
01224             /* [retval][out] */ ADOParameters __RPC_FAR *__RPC_FAR *ppvObject) = 0;
01225
01226         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CommandType(
01227             /* [in] */ CommandTypeEnum lCmdType) = 0;
01228
01229         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CommandType(
01230             /* [retval][out] */ CommandTypeEnum __RPC_FAR *plCmdType) = 0;
01231
01232         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_State(
01233             /* [retval][out] */ LONG __RPC_FAR *plObjState) = 0;
01234
01235         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Name(
01236             /* [retval][out] */ BSTR __RPC_FAR *pbstrName) = 0;
01237
01238         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Name(
01239             /* [in] */ BSTR bstrName) = 0;
01240
01241     };
01242
01243 #else   /* C style interface */
01244     typedef struct _CommandVtbl
01245     {
01246         BEGIN_INTERFACE
01247
01248         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
01249             _ADOCommand __RPC_FAR * This,
01250             /* [in] */ REFIID riid,
01251             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
01252
01253         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
01254             _ADOCommand __RPC_FAR * This);
01255
01256         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
01257             _ADOCommand __RPC_FAR * This);
01258
01259         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
01260             _ADOCommand __RPC_FAR * This,
01261             /* [out] */ UINT __RPC_FAR *pctinfo);
01262
01263         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
01264             _ADOCommand __RPC_FAR * This,
01265             /* [in] */ UINT iTInfo,
01266             /* [in] */ LCID lcid,
01267             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
01268
01269         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
01270             _ADOCommand __RPC_FAR * This,
01271             /* [in] */ REFIID riid,
01272             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
01273             /* [in] */ UINT cNames,
01274             /* [in] */ LCID lcid,
01275             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
01276
01277         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
01278             _ADOCommand __RPC_FAR * This,
01279             /* [in] */ DISPID dispIdMember,
01280             /* [in] */ REFIID riid,
01281             /* [in] */ LCID lcid,
01282             /* [in] */ WORD wFlags,
01283             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
01284             /* [out] */ VARIANT __RPC_FAR *pVarResult,
01285             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
01286             /* [out] */ UINT __RPC_FAR *puArgErr);
01287
01288         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Properties )(
01289             _ADOCommand __RPC_FAR * This,
01290             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
01291
01292         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_ActiveConnection )(
01293             _ADOCommand __RPC_FAR * This,
01294             /* [retval][out] */ _ADOConnection __RPC_FAR *__RPC_FAR *ppvObject);
01295
01296         /* [propputref] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *putref_ActiveADOConnection )(
01297             _ADOCommand __RPC_FAR * This,
01298             /* [in] */ _ADOConnection __RPC_FAR *pCon);
01299
01300         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_ActiveConnection )(
01301             _ADOCommand __RPC_FAR * This,
01302             /* [in] */ VARIANT vConn);
01303
01304         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CommandText )(
01305             _ADOCommand __RPC_FAR * This,
01306             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01307
01308         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CommandText )(
01309             _ADOCommand __RPC_FAR * This,
01310             /* [in] */ BSTR bstr);
01311
01312         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CommandTimeout )(
01313             _ADOCommand __RPC_FAR * This,
01314             /* [retval][out] */ LONG __RPC_FAR *pl);
01315
01316         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CommandTimeout )(
01317             _ADOCommand __RPC_FAR * This,
01318             /* [in] */ LONG Timeout);
01319
01320         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Prepared )(
01321             _ADOCommand __RPC_FAR * This,
01322             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pfPrepared);
01323
01324         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Prepared )(
01325             _ADOCommand __RPC_FAR * This,
01326             /* [in] */ VARIANT_BOOL fPrepared);
01327
01328         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Execute )(
01329             _ADOCommand __RPC_FAR * This,
01330             /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
01331             /* [optional][in] */ VARIANT __RPC_FAR *Parameters,
01332             /* [defaultvalue][in] */ long Options,
01333             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppirs);
01334
01335         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateParameter )(
01336             _ADOCommand __RPC_FAR * This,
01337             /* [defaultvalue][in] */ BSTR Name,
01338             /* [defaultvalue][in] */ DataTypeEnum Type,
01339             /* [defaultvalue][in] */ ParameterDirectionEnum Direction,
01340             /* [defaultvalue][in] */ long Size,
01341             /* [optional][in] */ VARIANT Value,
01342             /* [retval][out] */ _ADOParameter __RPC_FAR *__RPC_FAR *ppiprm);
01343
01344         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Cancel )(
01345             _ADOCommand __RPC_FAR * This);
01346
01347         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Parameters )(
01348             _ADOCommand __RPC_FAR * This,
01349             /* [retval][out] */ ADOParameters __RPC_FAR *__RPC_FAR *ppvObject);
01350
01351         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CommandType )(
01352             _ADOCommand __RPC_FAR * This,
01353             /* [in] */ CommandTypeEnum lCmdType);
01354
01355         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CommandType )(
01356             _ADOCommand __RPC_FAR * This,
01357             /* [retval][out] */ CommandTypeEnum __RPC_FAR *plCmdType);
01358
01359         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_State )(
01360             _ADOCommand __RPC_FAR * This,
01361             /* [retval][out] */ LONG __RPC_FAR *plObjState);
01362
01363         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Name )(
01364             _ADOCommand __RPC_FAR * This,
01365             /* [retval][out] */ BSTR __RPC_FAR *pbstrName);
01366
01367         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Name )(
01368             _ADOCommand __RPC_FAR * This,
01369             /* [in] */ BSTR bstrName);
01370
01371         END_INTERFACE
01372     } _CommandVtbl;
01373     interface _Command
01374     {
01375         CONST_VTBL struct _CommandVtbl __RPC_FAR *lpVtbl;
01376     };
01377
01378 #ifdef COBJMACROS
01379 #define _Command_QueryInterface(This,riid,ppvObject)  \
01380     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
01381 #define _Command_AddRef(This) \
01382     (This)->lpVtbl -> AddRef(This)
01383 #define _Command_Release(This)  \
01384     (This)->lpVtbl -> Release(This)
01385 #define _Command_GetTypeInfoCount(This,pctinfo) \
01386     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
01387 #define _Command_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
01388     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
01389 #define _Command_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
01390     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
01391 #define _Command_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
01392     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
01393 #define _Command_get_Properties(This,ppvObject) \
01394     (This)->lpVtbl -> get_Properties(This,ppvObject)
01395 #define _Command_get_ActiveConnection(This,ppvObject) \
01396     (This)->lpVtbl -> get_ActiveConnection(This,ppvObject)
01397 #define _Command_putref_ActiveConnection(This,pCon) \
01398     (This)->lpVtbl -> putref_ActiveConnection(This,pCon)
01399 #define _Command_put_ActiveConnection(This,vConn) \
01400     (This)->lpVtbl -> put_ActiveConnection(This,vConn)
01401 #define _Command_get_CommandText(This,pbstr)  \
01402     (This)->lpVtbl -> get_CommandText(This,pbstr)
01403 #define _Command_put_CommandText(This,bstr) \
01404     (This)->lpVtbl -> put_CommandText(This,bstr)
01405 #define _Command_get_CommandTimeout(This,pl)  \
01406     (This)->lpVtbl -> get_CommandTimeout(This,pl)
01407 #define _Command_put_CommandTimeout(This,Timeout) \
01408     (This)->lpVtbl -> put_CommandTimeout(This,Timeout)
01409 #define _Command_get_Prepared(This,pfPrepared)  \
01410     (This)->lpVtbl -> get_Prepared(This,pfPrepared)
01411 #define _Command_put_Prepared(This,fPrepared) \
01412     (This)->lpVtbl -> put_Prepared(This,fPrepared)
01413 #define _Command_Execute(This,RecordsAffected,Parameters,Options,ppirs) \
01414     (This)->lpVtbl -> Execute(This,RecordsAffected,Parameters,Options,ppirs)
01415 #define _Command_CreateParameter(This,Name,Type,Direction,Size,Value,ppiprm)  \
01416     (This)->lpVtbl -> CreateParameter(This,Name,Type,Direction,Size,Value,ppiprm)
01417 #define _Command_Cancel(This) \
01418     (This)->lpVtbl -> Cancel(This)
01419 #define _Command_get_Parameters(This,ppvObject) \
01420     (This)->lpVtbl -> get_Parameters(This,ppvObject)
01421 #define _Command_put_CommandType(This,lCmdType) \
01422     (This)->lpVtbl -> put_CommandType(This,lCmdType)
01423 #define _Command_get_CommandType(This,plCmdType)  \
01424     (This)->lpVtbl -> get_CommandType(This,plCmdType)
01425 #define _Command_get_State(This,plObjState) \
01426     (This)->lpVtbl -> get_State(This,plObjState)
01427 #define _Command_get_Name(This,pbstrName) \
01428     (This)->lpVtbl -> get_Name(This,pbstrName)
01429 #define _Command_put_Name(This,bstrName)  \
01430     (This)->lpVtbl -> put_Name(This,bstrName)
01431 #endif /* COBJMACROS */
01432 #endif  /* C style interface */
01433 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_ActiveConnection_Proxy(
01434     _ADOCommand __RPC_FAR * This,
01435     /* [retval][out] */ _ADOConnection __RPC_FAR *__RPC_FAR *ppvObject);
01436 void __RPC_STUB _Command_get_ActiveConnection_Stub(
01437     IRpcStubBuffer *This,
01438     IRpcChannelBuffer *_pRpcChannelBuffer,
01439     PRPC_MESSAGE _pRpcMessage,
01440     DWORD *_pdwStubPhase);
01441 /* [propputref] */ HRESULT STDMETHODCALLTYPE _Command_putref_ActiveConnection_Proxy(
01442     _ADOCommand __RPC_FAR * This,
01443     /* [in] */ _ADOConnection __RPC_FAR *pCon);
01444 void __RPC_STUB _Command_putref_ActiveConnection_Stub(
01445     IRpcStubBuffer *This,
01446     IRpcChannelBuffer *_pRpcChannelBuffer,
01447     PRPC_MESSAGE _pRpcMessage,
01448     DWORD *_pdwStubPhase);
01449 /* [propput] */ HRESULT STDMETHODCALLTYPE _Command_put_ActiveConnection_Proxy(
01450     _ADOCommand __RPC_FAR * This,
01451     /* [in] */ VARIANT vConn);
01452 void __RPC_STUB _Command_put_ActiveConnection_Stub(
01453     IRpcStubBuffer *This,
01454     IRpcChannelBuffer *_pRpcChannelBuffer,
01455     PRPC_MESSAGE _pRpcMessage,
01456     DWORD *_pdwStubPhase);
01457 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_CommandText_Proxy(
01458     _ADOCommand __RPC_FAR * This,
01459     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01460 void __RPC_STUB _Command_get_CommandText_Stub(
01461     IRpcStubBuffer *This,
01462     IRpcChannelBuffer *_pRpcChannelBuffer,
01463     PRPC_MESSAGE _pRpcMessage,
01464     DWORD *_pdwStubPhase);
01465 /* [propput] */ HRESULT STDMETHODCALLTYPE _Command_put_CommandText_Proxy(
01466     _ADOCommand __RPC_FAR * This,
01467     /* [in] */ BSTR bstr);
01468 void __RPC_STUB _Command_put_CommandText_Stub(
01469     IRpcStubBuffer *This,
01470     IRpcChannelBuffer *_pRpcChannelBuffer,
01471     PRPC_MESSAGE _pRpcMessage,
01472     DWORD *_pdwStubPhase);
01473 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_CommandTimeout_Proxy(
01474     _ADOCommand __RPC_FAR * This,
01475     /* [retval][out] */ LONG __RPC_FAR *pl);
01476 void __RPC_STUB _Command_get_CommandTimeout_Stub(
01477     IRpcStubBuffer *This,
01478     IRpcChannelBuffer *_pRpcChannelBuffer,
01479     PRPC_MESSAGE _pRpcMessage,
01480     DWORD *_pdwStubPhase);
01481 /* [propput] */ HRESULT STDMETHODCALLTYPE _Command_put_CommandTimeout_Proxy(
01482     _ADOCommand __RPC_FAR * This,
01483     /* [in] */ LONG Timeout);
01484 void __RPC_STUB _Command_put_CommandTimeout_Stub(
01485     IRpcStubBuffer *This,
01486     IRpcChannelBuffer *_pRpcChannelBuffer,
01487     PRPC_MESSAGE _pRpcMessage,
01488     DWORD *_pdwStubPhase);
01489 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_Prepared_Proxy(
01490     _ADOCommand __RPC_FAR * This,
01491     /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pfPrepared);
01492 void __RPC_STUB _Command_get_Prepared_Stub(
01493     IRpcStubBuffer *This,
01494     IRpcChannelBuffer *_pRpcChannelBuffer,
01495     PRPC_MESSAGE _pRpcMessage,
01496     DWORD *_pdwStubPhase);
01497 /* [propput] */ HRESULT STDMETHODCALLTYPE _Command_put_Prepared_Proxy(
01498     _ADOCommand __RPC_FAR * This,
01499     /* [in] */ VARIANT_BOOL fPrepared);
01500 void __RPC_STUB _Command_put_Prepared_Stub(
01501     IRpcStubBuffer *This,
01502     IRpcChannelBuffer *_pRpcChannelBuffer,
01503     PRPC_MESSAGE _pRpcMessage,
01504     DWORD *_pdwStubPhase);
01505 /* [helpstring][helpcontext] */ HRESULT STDMETHODCALLTYPE _Command_Execute_Proxy(
01506     _ADOCommand __RPC_FAR * This,
01507     /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
01508     /* [optional][in] */ VARIANT __RPC_FAR *Parameters,
01509     /* [defaultvalue][in] */ long Options,
01510     /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppirs);
01511 void __RPC_STUB _Command_Execute_Stub(
01512     IRpcStubBuffer *This,
01513     IRpcChannelBuffer *_pRpcChannelBuffer,
01514     PRPC_MESSAGE _pRpcMessage,
01515     DWORD *_pdwStubPhase);
01516 HRESULT STDMETHODCALLTYPE _Command_CreateParameter_Proxy(
01517     _ADOCommand __RPC_FAR * This,
01518     /* [defaultvalue][in] */ BSTR Name,
01519     /* [defaultvalue][in] */ DataTypeEnum Type,
01520     /* [defaultvalue][in] */ ParameterDirectionEnum Direction,
01521     /* [defaultvalue][in] */ long Size,
01522     /* [optional][in] */ VARIANT Value,
01523     /* [retval][out] */ _ADOParameter __RPC_FAR *__RPC_FAR *ppiprm);
01524 void __RPC_STUB _Command_CreateParameter_Stub(
01525     IRpcStubBuffer *This,
01526     IRpcChannelBuffer *_pRpcChannelBuffer,
01527     PRPC_MESSAGE _pRpcMessage,
01528     DWORD *_pdwStubPhase);
01529 HRESULT STDMETHODCALLTYPE _Command_Cancel_Proxy(
01530     _ADOCommand __RPC_FAR * This);
01531 void __RPC_STUB _Command_Cancel_Stub(
01532     IRpcStubBuffer *This,
01533     IRpcChannelBuffer *_pRpcChannelBuffer,
01534     PRPC_MESSAGE _pRpcMessage,
01535     DWORD *_pdwStubPhase);
01536 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _Command_get_Parameters_Proxy(
01537     _ADOCommand __RPC_FAR * This,
01538     /* [retval][out] */ ADOParameters __RPC_FAR *__RPC_FAR *ppvObject);
01539 void __RPC_STUB _Command_get_Parameters_Stub(
01540     IRpcStubBuffer *This,
01541     IRpcChannelBuffer *_pRpcChannelBuffer,
01542     PRPC_MESSAGE _pRpcMessage,
01543     DWORD *_pdwStubPhase);
01544 /* [propput] */ HRESULT STDMETHODCALLTYPE _Command_put_CommandType_Proxy(
01545     _ADOCommand __RPC_FAR * This,
01546     /* [in] */ CommandTypeEnum lCmdType);
01547 void __RPC_STUB _Command_put_CommandType_Stub(
01548     IRpcStubBuffer *This,
01549     IRpcChannelBuffer *_pRpcChannelBuffer,
01550     PRPC_MESSAGE _pRpcMessage,
01551     DWORD *_pdwStubPhase);
01552 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_CommandType_Proxy(
01553     _ADOCommand __RPC_FAR * This,
01554     /* [retval][out] */ CommandTypeEnum __RPC_FAR *plCmdType);
01555 void __RPC_STUB _Command_get_CommandType_Stub(
01556     IRpcStubBuffer *This,
01557     IRpcChannelBuffer *_pRpcChannelBuffer,
01558     PRPC_MESSAGE _pRpcMessage,
01559     DWORD *_pdwStubPhase);
01560 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_State_Proxy(
01561     _ADOCommand __RPC_FAR * This,
01562     /* [retval][out] */ LONG __RPC_FAR *plObjState);
01563 void __RPC_STUB _Command_get_State_Stub(
01564     IRpcStubBuffer *This,
01565     IRpcChannelBuffer *_pRpcChannelBuffer,
01566     PRPC_MESSAGE _pRpcMessage,
01567     DWORD *_pdwStubPhase);
01568 /* [propget] */ HRESULT STDMETHODCALLTYPE _Command_get_Name_Proxy(
01569     _ADOCommand __RPC_FAR * This,
01570     /* [retval][out] */ BSTR __RPC_FAR *pbstrName);
01571 void __RPC_STUB _Command_get_Name_Stub(
01572     IRpcStubBuffer *This,
01573     IRpcChannelBuffer *_pRpcChannelBuffer,
01574     PRPC_MESSAGE _pRpcMessage,
01575     DWORD *_pdwStubPhase);
01576 /* [propput] */ HRESULT STDMETHODCALLTYPE _Command_put_Name_Proxy(
01577     _ADOCommand __RPC_FAR * This,
01578     /* [in] */ BSTR bstrName);
01579 void __RPC_STUB _Command_put_Name_Stub(
01580     IRpcStubBuffer *This,
01581     IRpcChannelBuffer *_pRpcChannelBuffer,
01582     PRPC_MESSAGE _pRpcMessage,
01583     DWORD *_pdwStubPhase);
01584 #endif  /* ___Command_INTERFACE_DEFINED__ */
01585 #ifndef ___Connection_INTERFACE_DEFINED__
01586 #define ___Connection_INTERFACE_DEFINED__
01587 /****************************************
01588  * Generated header for interface: _Connection
01589  * at Mon Jul 14 07:56:56 1997
01590  * using MIDL 3.01.75
01591  ****************************************/
01592 /* [object][helpstring][helpcontext][uuid][dual] */
01593 EXTERN_C const IID IID__Connection;
01594 #if defined(__cplusplus) && !defined(CINTERFACE)
01595
01596     interface DECLSPEC_UUID("00000515-0000-0010-8000-00AA006D2EA4")
01597     _ADOConnection : public _ADO
01598     {
01599     public:
01600         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_ConnectionString(
01601             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
01602
01603         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_ConnectionString(
01604             /* [in] */ BSTR bstr) = 0;
01605
01606         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_CommandTimeout(
01607             /* [retval][out] */ LONG __RPC_FAR *plTimeout) = 0;
01608
01609         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_CommandTimeout(
01610             /* [in] */ LONG lTimeout) = 0;
01611
01612         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_ConnectionTimeout(
01613             /* [retval][out] */ LONG __RPC_FAR *plTimeout) = 0;
01614
01615         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_ConnectionTimeout(
01616             /* [in] */ LONG lTimeout) = 0;
01617
01618         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Version(
01619             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
01620
01621         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE Close( void) = 0;
01622
01623         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE Execute(
01624             /* [in] */ BSTR CommandText,
01625             /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
01626             /* [defaultvalue][in] */ long Options,
01627             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppiRset) = 0;
01628
01629         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE BeginTrans(
01630             /* [retval][out] */ long __RPC_FAR *TransactionLevel) = 0;
01631
01632         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE CommitTrans( void) = 0;
01633
01634         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE RollbackTrans( void) = 0;
01635
01636         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Open(
01637             /* [defaultvalue][in] */ BSTR ConnectionString,
01638             /* [defaultvalue][in] */ BSTR UserID,
01639             /* [defaultvalue][in] */ BSTR Password,
01640             /* [defaultvalue][in] */ long Options) = 0;
01641
01642         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Errors(
01643             /* [retval][out] */ ADOErrors __RPC_FAR *__RPC_FAR *ppvObject) = 0;
01644
01645         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_DefaultDatabase(
01646             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
01647
01648         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_DefaultDatabase(
01649             /* [in] */ BSTR bstr) = 0;
01650
01651         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsolationLevel(
01652             /* [retval][out] */ IsolationLevelEnum __RPC_FAR *Level) = 0;
01653
01654         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_IsolationLevel(
01655             /* [in] */ IsolationLevelEnum Level) = 0;
01656
01657         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_Attributes(
01658             /* [retval][out] */ long __RPC_FAR *plAttr) = 0;
01659
01660         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Attributes(
01661             /* [in] */ long lAttr) = 0;
01662
01663         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_CursorLocation(
01664             /* [retval][out] */ CursorLocationEnum __RPC_FAR *plCursorLoc) = 0;
01665
01666         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_CursorLocation(
01667             /* [in] */ CursorLocationEnum lCursorLoc) = 0;
01668
01669         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_Mode(
01670             /* [retval][out] */ ConnectModeEnum __RPC_FAR *plMode) = 0;
01671
01672         virtual /* [helpstring][helpcontext][id][propput] */ HRESULT STDMETHODCALLTYPE put_Mode(
01673             /* [in] */ ConnectModeEnum lMode) = 0;
01674
01675         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Provider(
01676             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
01677
01678         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Provider(
01679             /* [in] */ BSTR Provider) = 0;
01680
01681         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_State(
01682             /* [retval][out] */ LONG __RPC_FAR *plObjState) = 0;
01683
01684         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Cancel( void) = 0;
01685
01686         virtual /* [id] */ HRESULT STDMETHODCALLTYPE OpenSchema(
01687             /* [in] */ SchemaEnum Schema,
01688             /* [optional][in] */ VARIANT Restrictions,
01689             /* [optional][in] */ VARIANT SchemaID,
01690             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *pprset) = 0;
01691
01692     };
01693
01694 #else   /* C style interface */
01695     typedef struct _ConnectionVtbl
01696     {
01697         BEGIN_INTERFACE
01698
01699         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
01700             _ADOConnection __RPC_FAR * This,
01701             /* [in] */ REFIID riid,
01702             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
01703
01704         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
01705             _ADOConnection __RPC_FAR * This);
01706
01707         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
01708             _ADOConnection __RPC_FAR * This);
01709
01710         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
01711             _ADOConnection __RPC_FAR * This,
01712             /* [out] */ UINT __RPC_FAR *pctinfo);
01713
01714         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
01715             _ADOConnection __RPC_FAR * This,
01716             /* [in] */ UINT iTInfo,
01717             /* [in] */ LCID lcid,
01718             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
01719
01720         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
01721             _ADOConnection __RPC_FAR * This,
01722             /* [in] */ REFIID riid,
01723             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
01724             /* [in] */ UINT cNames,
01725             /* [in] */ LCID lcid,
01726             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
01727
01728         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
01729             _ADOConnection __RPC_FAR * This,
01730             /* [in] */ DISPID dispIdMember,
01731             /* [in] */ REFIID riid,
01732             /* [in] */ LCID lcid,
01733             /* [in] */ WORD wFlags,
01734             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
01735             /* [out] */ VARIANT __RPC_FAR *pVarResult,
01736             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
01737             /* [out] */ UINT __RPC_FAR *puArgErr);
01738
01739         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Properties )(
01740             _ADOConnection __RPC_FAR * This,
01741             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
01742
01743         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_ConnectionString )(
01744             _ADOConnection __RPC_FAR * This,
01745             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01746
01747         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_ConnectionString )(
01748             _ADOConnection __RPC_FAR * This,
01749             /* [in] */ BSTR bstr);
01750
01751         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CommandTimeout )(
01752             _ADOConnection __RPC_FAR * This,
01753             /* [retval][out] */ LONG __RPC_FAR *plTimeout);
01754
01755         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CommandTimeout )(
01756             _ADOConnection __RPC_FAR * This,
01757             /* [in] */ LONG lTimeout);
01758
01759         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_ConnectionTimeout )(
01760             _ADOConnection __RPC_FAR * This,
01761             /* [retval][out] */ LONG __RPC_FAR *plTimeout);
01762
01763         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_ConnectionTimeout )(
01764             _ADOConnection __RPC_FAR * This,
01765             /* [in] */ LONG lTimeout);
01766
01767         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Version )(
01768             _ADOConnection __RPC_FAR * This,
01769             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01770
01771         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Close )(
01772             _ADOConnection __RPC_FAR * This);
01773
01774         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Execute )(
01775             _ADOConnection __RPC_FAR * This,
01776             /* [in] */ BSTR CommandText,
01777             /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
01778             /* [defaultvalue][in] */ long Options,
01779             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppiRset);
01780
01781         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginTrans )(
01782             _ADOConnection __RPC_FAR * This,
01783             /* [retval][out] */ long __RPC_FAR *TransactionLevel);
01784
01785         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CommitTrans )(
01786             _ADOConnection __RPC_FAR * This);
01787
01788         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RollbackTrans )(
01789             _ADOConnection __RPC_FAR * This);
01790
01791         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Open )(
01792             _ADOConnection __RPC_FAR * This,
01793             /* [defaultvalue][in] */ BSTR ConnectionString,
01794             /* [defaultvalue][in] */ BSTR UserID,
01795             /* [defaultvalue][in] */ BSTR Password,
01796             /* [defaultvalue][in] */ long Options);
01797
01798         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Errors )(
01799             _ADOConnection __RPC_FAR * This,
01800             /* [retval][out] */ ADOErrors __RPC_FAR *__RPC_FAR *ppvObject);
01801
01802         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_DefaultDatabase )(
01803             _ADOConnection __RPC_FAR * This,
01804             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01805
01806         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_DefaultDatabase )(
01807             _ADOConnection __RPC_FAR * This,
01808             /* [in] */ BSTR bstr);
01809
01810         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_IsolationLevel )(
01811             _ADOConnection __RPC_FAR * This,
01812             /* [retval][out] */ IsolationLevelEnum __RPC_FAR *Level);
01813
01814         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_IsolationLevel )(
01815             _ADOConnection __RPC_FAR * This,
01816             /* [in] */ IsolationLevelEnum Level);
01817
01818         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Attributes )(
01819             _ADOConnection __RPC_FAR * This,
01820             /* [retval][out] */ long __RPC_FAR *plAttr);
01821
01822         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Attributes )(
01823             _ADOConnection __RPC_FAR * This,
01824             /* [in] */ long lAttr);
01825
01826         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CursorLocation )(
01827             _ADOConnection __RPC_FAR * This,
01828             /* [retval][out] */ CursorLocationEnum __RPC_FAR *plCursorLoc);
01829
01830         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CursorLocation )(
01831             _ADOConnection __RPC_FAR * This,
01832             /* [in] */ CursorLocationEnum lCursorLoc);
01833
01834         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Mode )(
01835             _ADOConnection __RPC_FAR * This,
01836             /* [retval][out] */ ConnectModeEnum __RPC_FAR *plMode);
01837
01838         /* [helpstring][helpcontext][id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Mode )(
01839             _ADOConnection __RPC_FAR * This,
01840             /* [in] */ ConnectModeEnum lMode);
01841
01842         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Provider )(
01843             _ADOConnection __RPC_FAR * This,
01844             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01845
01846         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Provider )(
01847             _ADOConnection __RPC_FAR * This,
01848             /* [in] */ BSTR Provider);
01849
01850         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_State )(
01851             _ADOConnection __RPC_FAR * This,
01852             /* [retval][out] */ LONG __RPC_FAR *plObjState);
01853
01854         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Cancel )(
01855             _ADOConnection __RPC_FAR * This);
01856
01857         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OpenSchema )(
01858             _ADOConnection __RPC_FAR * This,
01859             /* [in] */ SchemaEnum Schema,
01860             /* [optional][in] */ VARIANT Restrictions,
01861             /* [optional][in] */ VARIANT SchemaID,
01862             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *pprset);
01863
01864         END_INTERFACE
01865     } _ConnectionVtbl;
01866     interface _Connection
01867     {
01868         CONST_VTBL struct _ConnectionVtbl __RPC_FAR *lpVtbl;
01869     };
01870
01871 #ifdef COBJMACROS
01872 #define _Connection_QueryInterface(This,riid,ppvObject) \
01873     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
01874 #define _Connection_AddRef(This)  \
01875     (This)->lpVtbl -> AddRef(This)
01876 #define _Connection_Release(This) \
01877     (This)->lpVtbl -> Release(This)
01878 #define _Connection_GetTypeInfoCount(This,pctinfo)  \
01879     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
01880 #define _Connection_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
01881     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
01882 #define _Connection_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
01883     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
01884 #define _Connection_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
01885     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
01886 #define _Connection_get_Properties(This,ppvObject)  \
01887     (This)->lpVtbl -> get_Properties(This,ppvObject)
01888 #define _Connection_get_ConnectionString(This,pbstr)  \
01889     (This)->lpVtbl -> get_ConnectionString(This,pbstr)
01890 #define _Connection_put_ConnectionString(This,bstr) \
01891     (This)->lpVtbl -> put_ConnectionString(This,bstr)
01892 #define _Connection_get_CommandTimeout(This,plTimeout)  \
01893     (This)->lpVtbl -> get_CommandTimeout(This,plTimeout)
01894 #define _Connection_put_CommandTimeout(This,lTimeout) \
01895     (This)->lpVtbl -> put_CommandTimeout(This,lTimeout)
01896 #define _Connection_get_ConnectionTimeout(This,plTimeout) \
01897     (This)->lpVtbl -> get_ConnectionTimeout(This,plTimeout)
01898 #define _Connection_put_ConnectionTimeout(This,lTimeout)  \
01899     (This)->lpVtbl -> put_ConnectionTimeout(This,lTimeout)
01900 #define _Connection_get_Version(This,pbstr) \
01901     (This)->lpVtbl -> get_Version(This,pbstr)
01902 #define _Connection_Close(This) \
01903     (This)->lpVtbl -> Close(This)
01904 #define _Connection_Execute(This,CommandText,RecordsAffected,Options,ppiRset) \
01905     (This)->lpVtbl -> Execute(This,CommandText,RecordsAffected,Options,ppiRset)
01906 #define _Connection_BeginTrans(This,TransactionLevel) \
01907     (This)->lpVtbl -> BeginTrans(This,TransactionLevel)
01908 #define _Connection_CommitTrans(This) \
01909     (This)->lpVtbl -> CommitTrans(This)
01910 #define _Connection_RollbackTrans(This) \
01911     (This)->lpVtbl -> RollbackTrans(This)
01912 #define _Connection_Open(This,ConnectionString,UserID,Password,Options) \
01913     (This)->lpVtbl -> Open(This,ConnectionString,UserID,Password,Options)
01914 #define _Connection_get_Errors(This,ppvObject)  \
01915     (This)->lpVtbl -> get_Errors(This,ppvObject)
01916 #define _Connection_get_DefaultDatabase(This,pbstr) \
01917     (This)->lpVtbl -> get_DefaultDatabase(This,pbstr)
01918 #define _Connection_put_DefaultDatabase(This,bstr)  \
01919     (This)->lpVtbl -> put_DefaultDatabase(This,bstr)
01920 #define _Connection_get_IsolationLevel(This,Level)  \
01921     (This)->lpVtbl -> get_IsolationLevel(This,Level)
01922 #define _Connection_put_IsolationLevel(This,Level)  \
01923     (This)->lpVtbl -> put_IsolationLevel(This,Level)
01924 #define _Connection_get_Attributes(This,plAttr) \
01925     (This)->lpVtbl -> get_Attributes(This,plAttr)
01926 #define _Connection_put_Attributes(This,lAttr)  \
01927     (This)->lpVtbl -> put_Attributes(This,lAttr)
01928 #define _Connection_get_CursorLocation(This,plCursorLoc)  \
01929     (This)->lpVtbl -> get_CursorLocation(This,plCursorLoc)
01930 #define _Connection_put_CursorLocation(This,lCursorLoc) \
01931     (This)->lpVtbl -> put_CursorLocation(This,lCursorLoc)
01932 #define _Connection_get_Mode(This,plMode) \
01933     (This)->lpVtbl -> get_Mode(This,plMode)
01934 #define _Connection_put_Mode(This,lMode)  \
01935     (This)->lpVtbl -> put_Mode(This,lMode)
01936 #define _Connection_get_Provider(This,pbstr)  \
01937     (This)->lpVtbl -> get_Provider(This,pbstr)
01938 #define _Connection_put_Provider(This,Provider) \
01939     (This)->lpVtbl -> put_Provider(This,Provider)
01940 #define _Connection_get_State(This,plObjState)  \
01941     (This)->lpVtbl -> get_State(This,plObjState)
01942 #define _Connection_Cancel(This)  \
01943     (This)->lpVtbl -> Cancel(This)
01944 #define _Connection_OpenSchema(This,Schema,Restrictions,SchemaID,pprset)  \
01945     (This)->lpVtbl -> OpenSchema(This,Schema,Restrictions,SchemaID,pprset)
01946 #endif /* COBJMACROS */
01947 #endif  /* C style interface */
01948 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_ConnectionString_Proxy(
01949     _ADOConnection __RPC_FAR * This,
01950     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01951 void __RPC_STUB _Connection_get_ConnectionString_Stub(
01952     IRpcStubBuffer *This,
01953     IRpcChannelBuffer *_pRpcChannelBuffer,
01954     PRPC_MESSAGE _pRpcMessage,
01955     DWORD *_pdwStubPhase);
01956 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_ConnectionString_Proxy(
01957     _ADOConnection __RPC_FAR * This,
01958     /* [in] */ BSTR bstr);
01959 void __RPC_STUB _Connection_put_ConnectionString_Stub(
01960     IRpcStubBuffer *This,
01961     IRpcChannelBuffer *_pRpcChannelBuffer,
01962     PRPC_MESSAGE _pRpcMessage,
01963     DWORD *_pdwStubPhase);
01964 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_CommandTimeout_Proxy(
01965     _ADOConnection __RPC_FAR * This,
01966     /* [retval][out] */ LONG __RPC_FAR *plTimeout);
01967 void __RPC_STUB _Connection_get_CommandTimeout_Stub(
01968     IRpcStubBuffer *This,
01969     IRpcChannelBuffer *_pRpcChannelBuffer,
01970     PRPC_MESSAGE _pRpcMessage,
01971     DWORD *_pdwStubPhase);
01972 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_CommandTimeout_Proxy(
01973     _ADOConnection __RPC_FAR * This,
01974     /* [in] */ LONG lTimeout);
01975 void __RPC_STUB _Connection_put_CommandTimeout_Stub(
01976     IRpcStubBuffer *This,
01977     IRpcChannelBuffer *_pRpcChannelBuffer,
01978     PRPC_MESSAGE _pRpcMessage,
01979     DWORD *_pdwStubPhase);
01980 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_ConnectionTimeout_Proxy(
01981     _ADOConnection __RPC_FAR * This,
01982     /* [retval][out] */ LONG __RPC_FAR *plTimeout);
01983 void __RPC_STUB _Connection_get_ConnectionTimeout_Stub(
01984     IRpcStubBuffer *This,
01985     IRpcChannelBuffer *_pRpcChannelBuffer,
01986     PRPC_MESSAGE _pRpcMessage,
01987     DWORD *_pdwStubPhase);
01988 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_ConnectionTimeout_Proxy(
01989     _ADOConnection __RPC_FAR * This,
01990     /* [in] */ LONG lTimeout);
01991 void __RPC_STUB _Connection_put_ConnectionTimeout_Stub(
01992     IRpcStubBuffer *This,
01993     IRpcChannelBuffer *_pRpcChannelBuffer,
01994     PRPC_MESSAGE _pRpcMessage,
01995     DWORD *_pdwStubPhase);
01996 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_Version_Proxy(
01997     _ADOConnection __RPC_FAR * This,
01998     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
01999 void __RPC_STUB _Connection_get_Version_Stub(
02000     IRpcStubBuffer *This,
02001     IRpcChannelBuffer *_pRpcChannelBuffer,
02002     PRPC_MESSAGE _pRpcMessage,
02003     DWORD *_pdwStubPhase);
02004 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE _Connection_Close_Proxy(
02005     _ADOConnection __RPC_FAR * This);
02006 void __RPC_STUB _Connection_Close_Stub(
02007     IRpcStubBuffer *This,
02008     IRpcChannelBuffer *_pRpcChannelBuffer,
02009     PRPC_MESSAGE _pRpcMessage,
02010     DWORD *_pdwStubPhase);
02011 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE _Connection_Execute_Proxy(
02012     _ADOConnection __RPC_FAR * This,
02013     /* [in] */ BSTR CommandText,
02014     /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
02015     /* [defaultvalue][in] */ long Options,
02016     /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppiRset);
02017 void __RPC_STUB _Connection_Execute_Stub(
02018     IRpcStubBuffer *This,
02019     IRpcChannelBuffer *_pRpcChannelBuffer,
02020     PRPC_MESSAGE _pRpcMessage,
02021     DWORD *_pdwStubPhase);
02022 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE _Connection_BeginTrans_Proxy(
02023     _ADOConnection __RPC_FAR * This,
02024     /* [retval][out] */ long __RPC_FAR *TransactionLevel);
02025 void __RPC_STUB _Connection_BeginTrans_Stub(
02026     IRpcStubBuffer *This,
02027     IRpcChannelBuffer *_pRpcChannelBuffer,
02028     PRPC_MESSAGE _pRpcMessage,
02029     DWORD *_pdwStubPhase);
02030 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE _Connection_CommitTrans_Proxy(
02031     _ADOConnection __RPC_FAR * This);
02032 void __RPC_STUB _Connection_CommitTrans_Stub(
02033     IRpcStubBuffer *This,
02034     IRpcChannelBuffer *_pRpcChannelBuffer,
02035     PRPC_MESSAGE _pRpcMessage,
02036     DWORD *_pdwStubPhase);
02037 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE _Connection_RollbackTrans_Proxy(
02038     _ADOConnection __RPC_FAR * This);
02039 void __RPC_STUB _Connection_RollbackTrans_Stub(
02040     IRpcStubBuffer *This,
02041     IRpcChannelBuffer *_pRpcChannelBuffer,
02042     PRPC_MESSAGE _pRpcMessage,
02043     DWORD *_pdwStubPhase);
02044 /* [id] */ HRESULT STDMETHODCALLTYPE _Connection_Open_Proxy(
02045     _ADOConnection __RPC_FAR * This,
02046     /* [defaultvalue][in] */ BSTR ConnectionString,
02047     /* [defaultvalue][in] */ BSTR UserID,
02048     /* [defaultvalue][in] */ BSTR Password,
02049     /* [defaultvalue][in] */ long Options);
02050 void __RPC_STUB _Connection_Open_Stub(
02051     IRpcStubBuffer *This,
02052     IRpcChannelBuffer *_pRpcChannelBuffer,
02053     PRPC_MESSAGE _pRpcMessage,
02054     DWORD *_pdwStubPhase);
02055 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_Errors_Proxy(
02056     _ADOConnection __RPC_FAR * This,
02057     /* [retval][out] */ ADOErrors __RPC_FAR *__RPC_FAR *ppvObject);
02058 void __RPC_STUB _Connection_get_Errors_Stub(
02059     IRpcStubBuffer *This,
02060     IRpcChannelBuffer *_pRpcChannelBuffer,
02061     PRPC_MESSAGE _pRpcMessage,
02062     DWORD *_pdwStubPhase);
02063 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_DefaultDatabase_Proxy(
02064     _ADOConnection __RPC_FAR * This,
02065     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
02066 void __RPC_STUB _Connection_get_DefaultDatabase_Stub(
02067     IRpcStubBuffer *This,
02068     IRpcChannelBuffer *_pRpcChannelBuffer,
02069     PRPC_MESSAGE _pRpcMessage,
02070     DWORD *_pdwStubPhase);
02071 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_DefaultDatabase_Proxy(
02072     _ADOConnection __RPC_FAR * This,
02073     /* [in] */ BSTR bstr);
02074 void __RPC_STUB _Connection_put_DefaultDatabase_Stub(
02075     IRpcStubBuffer *This,
02076     IRpcChannelBuffer *_pRpcChannelBuffer,
02077     PRPC_MESSAGE _pRpcMessage,
02078     DWORD *_pdwStubPhase);
02079 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_IsolationLevel_Proxy(
02080     _ADOConnection __RPC_FAR * This,
02081     /* [retval][out] */ IsolationLevelEnum __RPC_FAR *Level);
02082 void __RPC_STUB _Connection_get_IsolationLevel_Stub(
02083     IRpcStubBuffer *This,
02084     IRpcChannelBuffer *_pRpcChannelBuffer,
02085     PRPC_MESSAGE _pRpcMessage,
02086     DWORD *_pdwStubPhase);
02087 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_IsolationLevel_Proxy(
02088     _ADOConnection __RPC_FAR * This,
02089     /* [in] */ IsolationLevelEnum Level);
02090 void __RPC_STUB _Connection_put_IsolationLevel_Stub(
02091     IRpcStubBuffer *This,
02092     IRpcChannelBuffer *_pRpcChannelBuffer,
02093     PRPC_MESSAGE _pRpcMessage,
02094     DWORD *_pdwStubPhase);
02095 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_Attributes_Proxy(
02096     _ADOConnection __RPC_FAR * This,
02097     /* [retval][out] */ long __RPC_FAR *plAttr);
02098 void __RPC_STUB _Connection_get_Attributes_Stub(
02099     IRpcStubBuffer *This,
02100     IRpcChannelBuffer *_pRpcChannelBuffer,
02101     PRPC_MESSAGE _pRpcMessage,
02102     DWORD *_pdwStubPhase);
02103 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_Attributes_Proxy(
02104     _ADOConnection __RPC_FAR * This,
02105     /* [in] */ long lAttr);
02106 void __RPC_STUB _Connection_put_Attributes_Stub(
02107     IRpcStubBuffer *This,
02108     IRpcChannelBuffer *_pRpcChannelBuffer,
02109     PRPC_MESSAGE _pRpcMessage,
02110     DWORD *_pdwStubPhase);
02111 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Connection_get_CursorLocation_Proxy(
02112     _ADOConnection __RPC_FAR * This,
02113     /* [retval][out] */ CursorLocationEnum __RPC_FAR *plCursorLoc);
02114 void __RPC_STUB _Connection_get_CursorLocation_Stub(
02115     IRpcStubBuffer *This,
02116     IRpcChannelBuffer *_pRpcChannelBuffer,
02117     PRPC_MESSAGE _pRpcMessage,
02118     DWORD *_pdwStubPhase);
02119 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Connection_put_CursorLocation_Proxy(
02120     _ADOConnection __RPC_FAR * This,
02121     /* [in] */ CursorLocationEnum lCursorLoc);
02122 void __RPC_STUB _Connection_put_CursorLocation_Stub(
02123     IRpcStubBuffer *This,
02124     IRpcChannelBuffer *_pRpcChannelBuffer,
02125     PRPC_MESSAGE _pRpcMessage,
02126     DWORD *_pdwStubPhase);
02127 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_Mode_Proxy(
02128     _ADOConnection __RPC_FAR * This,
02129     /* [retval][out] */ ConnectModeEnum __RPC_FAR *plMode);
02130 void __RPC_STUB _Connection_get_Mode_Stub(
02131     IRpcStubBuffer *This,
02132     IRpcChannelBuffer *_pRpcChannelBuffer,
02133     PRPC_MESSAGE _pRpcMessage,
02134     DWORD *_pdwStubPhase);
02135 /* [helpstring][helpcontext][id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_Mode_Proxy(
02136     _ADOConnection __RPC_FAR * This,
02137     /* [in] */ ConnectModeEnum lMode);
02138 void __RPC_STUB _Connection_put_Mode_Stub(
02139     IRpcStubBuffer *This,
02140     IRpcChannelBuffer *_pRpcChannelBuffer,
02141     PRPC_MESSAGE _pRpcMessage,
02142     DWORD *_pdwStubPhase);
02143 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_Provider_Proxy(
02144     _ADOConnection __RPC_FAR * This,
02145     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
02146 void __RPC_STUB _Connection_get_Provider_Stub(
02147     IRpcStubBuffer *This,
02148     IRpcChannelBuffer *_pRpcChannelBuffer,
02149     PRPC_MESSAGE _pRpcMessage,
02150     DWORD *_pdwStubPhase);
02151 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Connection_put_Provider_Proxy(
02152     _ADOConnection __RPC_FAR * This,
02153     /* [in] */ BSTR Provider);
02154 void __RPC_STUB _Connection_put_Provider_Stub(
02155     IRpcStubBuffer *This,
02156     IRpcChannelBuffer *_pRpcChannelBuffer,
02157     PRPC_MESSAGE _pRpcMessage,
02158     DWORD *_pdwStubPhase);
02159 /* [id][propget] */ HRESULT STDMETHODCALLTYPE _Connection_get_State_Proxy(
02160     _ADOConnection __RPC_FAR * This,
02161     /* [retval][out] */ LONG __RPC_FAR *plObjState);
02162 void __RPC_STUB _Connection_get_State_Stub(
02163     IRpcStubBuffer *This,
02164     IRpcChannelBuffer *_pRpcChannelBuffer,
02165     PRPC_MESSAGE _pRpcMessage,
02166     DWORD *_pdwStubPhase);
02167 /* [id] */ HRESULT STDMETHODCALLTYPE _Connection_Cancel_Proxy(
02168     _ADOConnection __RPC_FAR * This);
02169 void __RPC_STUB _Connection_Cancel_Stub(
02170     IRpcStubBuffer *This,
02171     IRpcChannelBuffer *_pRpcChannelBuffer,
02172     PRPC_MESSAGE _pRpcMessage,
02173     DWORD *_pdwStubPhase);
02174 /* [id] */ HRESULT STDMETHODCALLTYPE _Connection_OpenSchema_Proxy(
02175     _ADOConnection __RPC_FAR * This,
02176     /* [in] */ SchemaEnum Schema,
02177     /* [optional][in] */ VARIANT Restrictions,
02178     /* [optional][in] */ VARIANT SchemaID,
02179     /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *pprset);
02180 void __RPC_STUB _Connection_OpenSchema_Stub(
02181     IRpcStubBuffer *This,
02182     IRpcChannelBuffer *_pRpcChannelBuffer,
02183     PRPC_MESSAGE _pRpcMessage,
02184     DWORD *_pdwStubPhase);
02185 #endif  /* ___Connection_INTERFACE_DEFINED__ */
02186 #ifndef __ADOConnectionConstruction_INTERFACE_DEFINED__
02187 #define __ADOConnectionConstruction_INTERFACE_DEFINED__
02188 /****************************************
02189  * Generated header for interface: ADOConnectionConstruction
02190  * at Mon Jul 14 07:56:56 1997
02191  * using MIDL 3.01.75
02192  ****************************************/
02193 /* [object][uuid][restricted] */
02194 EXTERN_C const IID IID_ADOConnectionConstruction;
02195 #if defined(__cplusplus) && !defined(CINTERFACE)
02196
02197     interface DECLSPEC_UUID("00000516-0000-0010-8000-00AA006D2EA4")
02198     ADOConnectionConstruction : public IUnknown
02199     {
02200     public:
02201         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DSO(
02202             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDSO) = 0;
02203
02204         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Session(
02205             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession) = 0;
02206
02207     };
02208
02209 #else   /* C style interface */
02210     typedef struct ADOConnectionConstructionVtbl
02211     {
02212         BEGIN_INTERFACE
02213
02214         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
02215             ADOConnectionConstruction __RPC_FAR * This,
02216             /* [in] */ REFIID riid,
02217             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
02218
02219         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
02220             ADOConnectionConstruction __RPC_FAR * This);
02221
02222         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
02223             ADOConnectionConstruction __RPC_FAR * This);
02224
02225         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_DSO )(
02226             ADOConnectionConstruction __RPC_FAR * This,
02227             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDSO);
02228
02229         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Session )(
02230             ADOConnectionConstruction __RPC_FAR * This,
02231             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);
02232
02233         END_INTERFACE
02234     } ADOConnectionConstructionVtbl;
02235     interface ADOConnectionConstruction
02236     {
02237         CONST_VTBL struct ADOConnectionConstructionVtbl __RPC_FAR *lpVtbl;
02238     };
02239
02240 #ifdef COBJMACROS
02241 #define ADOConnectionConstruction_QueryInterface(This,riid,ppvObject) \
02242     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
02243 #define ADOConnectionConstruction_AddRef(This)  \
02244     (This)->lpVtbl -> AddRef(This)
02245 #define ADOConnectionConstruction_Release(This) \
02246     (This)->lpVtbl -> Release(This)
02247 #define ADOConnectionConstruction_get_DSO(This,ppDSO) \
02248     (This)->lpVtbl -> get_DSO(This,ppDSO)
02249 #define ADOConnectionConstruction_get_Session(This,ppSession) \
02250     (This)->lpVtbl -> get_Session(This,ppSession)
02251 #endif /* COBJMACROS */
02252 #endif  /* C style interface */
02253 /* [propget] */ HRESULT STDMETHODCALLTYPE ADOConnectionConstruction_get_DSO_Proxy(
02254     ADOConnectionConstruction __RPC_FAR * This,
02255     /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDSO);
02256 void __RPC_STUB ADOConnectionConstruction_get_DSO_Stub(
02257     IRpcStubBuffer *This,
02258     IRpcChannelBuffer *_pRpcChannelBuffer,
02259     PRPC_MESSAGE _pRpcMessage,
02260     DWORD *_pdwStubPhase);
02261 /* [propget] */ HRESULT STDMETHODCALLTYPE ADOConnectionConstruction_get_Session_Proxy(
02262     ADOConnectionConstruction __RPC_FAR * This,
02263     /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);
02264 void __RPC_STUB ADOConnectionConstruction_get_Session_Stub(
02265     IRpcStubBuffer *This,
02266     IRpcChannelBuffer *_pRpcChannelBuffer,
02267     PRPC_MESSAGE _pRpcMessage,
02268     DWORD *_pdwStubPhase);
02269 #endif  /* __ADOConnectionConstruction_INTERFACE_DEFINED__ */
02270 #ifdef __cplusplus
02271 EXTERN_C const CLSID CLSID_Connection;
02272 Connection;
02273 #endif
02274 #ifdef __cplusplus
02275 EXTERN_C const CLSID CLSID_Command;
02276 Command;
02277 #endif
02278 #ifndef ___Recordset_INTERFACE_DEFINED__
02279 #define ___Recordset_INTERFACE_DEFINED__
02280 /****************************************
02281  * Generated header for interface: _Recordset
02282  * at Mon Jul 14 07:56:56 1997
02283  * using MIDL 3.01.75
02284  ****************************************/
02285 /* [object][helpstring][helpcontext][uuid][nonextensible][dual] */
02286 EXTERN_C const IID IID__Recordset;
02287 #if defined(__cplusplus) && !defined(CINTERFACE)
02288
02289     interface DECLSPEC_UUID("0000050E-0000-0010-8000-00AA006D2EA4")
02290     _ADORecordset : public _ADO
02291     {
02292     public:
02293         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_AbsolutePosition(
02294             /* [retval][out] */ PositionEnum __RPC_FAR *pl) = 0;
02295
02296         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AbsolutePosition(
02297             /* [in] */ PositionEnum Position) = 0;
02298
02299         virtual /* [propputref][id] */ HRESULT STDMETHODCALLTYPE putref_ActiveConnection(
02300             /* [in] */ IDispatch __RPC_FAR *pconn) = 0;
02301
02302         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_ActiveConnection(
02303             /* [in] */ VARIANT vConn) = 0;
02304
02305         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_ActiveConnection(
02306             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
02307
02308         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_BOF(
02309             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb) = 0;
02310
02311         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Bookmark(
02312             /* [retval][out] */ VARIANT __RPC_FAR *pvBookmark) = 0;
02313
02314         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Bookmark(
02315             /* [in] */ VARIANT vBookmark) = 0;
02316
02317         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_CacheSize(
02318             /* [retval][out] */ long __RPC_FAR *pl) = 0;
02319
02320         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_CacheSize(
02321             /* [in] */ long CacheSize) = 0;
02322
02323         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_CursorType(
02324             /* [retval][out] */ CursorTypeEnum __RPC_FAR *plCursorType) = 0;
02325
02326         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_CursorType(
02327             /* [in] */ CursorTypeEnum lCursorType) = 0;
02328
02329         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_EOF(
02330             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb) = 0;
02331
02332         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_Fields(
02333             /* [retval][out] */ ADOFields __RPC_FAR *__RPC_FAR *ppvObject) = 0;
02334
02335         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_LockType(
02336             /* [retval][out] */ LockTypeEnum __RPC_FAR *plLockType) = 0;
02337
02338         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_LockType(
02339             /* [in] */ LockTypeEnum lLockType) = 0;
02340
02341         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_MaxRecords(
02342             /* [retval][out] */ long __RPC_FAR *plMaxRecords) = 0;
02343
02344         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_MaxRecords(
02345             /* [in] */ long lMaxRecords) = 0;
02346
02347         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_RecordCount(
02348             /* [retval][out] */ long __RPC_FAR *pl) = 0;
02349
02350         virtual /* [propputref][id] */ HRESULT STDMETHODCALLTYPE putref_Source(
02351             /* [in] */ IDispatch __RPC_FAR *pcmd) = 0;
02352
02353         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Source(
02354             /* [in] */ BSTR bstrConn) = 0;
02355
02356         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Source(
02357             /* [retval][out] */ VARIANT __RPC_FAR *pvSource) = 0;
02358
02359         virtual /* [id] */ HRESULT STDMETHODCALLTYPE AddNew(
02360             /* [optional][in] */ VARIANT FieldList,
02361             /* [optional][in] */ VARIANT Values) = 0;
02362
02363         virtual /* [id] */ HRESULT STDMETHODCALLTYPE CancelUpdate( void) = 0;
02364
02365         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Close( void) = 0;
02366
02367         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Delete(
02368             /* [defaultvalue][in] */ AffectEnum AffectRecords) = 0;
02369
02370         virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetRows(
02371             /* [defaultvalue][in] */ long Rows,
02372             /* [optional][in] */ VARIANT Start,
02373             /* [optional][in] */ VARIANT Fields,
02374             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
02375
02376         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Move(
02377             /* [in] */ long NumRecords,
02378             /* [optional][in] */ VARIANT Start) = 0;
02379
02380         virtual /* [id] */ HRESULT STDMETHODCALLTYPE MoveNext( void) = 0;
02381
02382         virtual /* [id] */ HRESULT STDMETHODCALLTYPE MovePrevious( void) = 0;
02383
02384         virtual /* [id] */ HRESULT STDMETHODCALLTYPE MoveFirst( void) = 0;
02385
02386         virtual /* [id] */ HRESULT STDMETHODCALLTYPE MoveLast( void) = 0;
02387
02388         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Open(
02389             /* [optional][in] */ VARIANT Source,
02390             /* [optional][in] */ VARIANT ActiveConnection,
02391             /* [defaultvalue][in] */ CursorTypeEnum CursorType,
02392             /* [defaultvalue][in] */ LockTypeEnum LockType,
02393             /* [defaultvalue][in] */ LONG Options) = 0;
02394
02395         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Requery(
02396             /* [defaultvalue][in] */ LONG Options) = 0;
02397
02398         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Resync(
02399             /* [defaultvalue][in] */ AffectEnum AffectRecords) = 0;
02400
02401         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Update(
02402             /* [optional][in] */ VARIANT Fields,
02403             /* [optional][in] */ VARIANT Values) = 0;
02404
02405         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AbsolutePage(
02406             /* [retval][out] */ PositionEnum __RPC_FAR *pl) = 0;
02407
02408         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AbsolutePage(
02409             /* [in] */ PositionEnum Page) = 0;
02410
02411         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_EditMode(
02412             /* [retval][out] */ EditModeEnum __RPC_FAR *pl) = 0;
02413
02414         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Filter(
02415             /* [retval][out] */ VARIANT __RPC_FAR *Criteria) = 0;
02416
02417         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Filter(
02418             /* [in] */ VARIANT Criteria) = 0;
02419
02420         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_PageCount(
02421             /* [retval][out] */ long __RPC_FAR *pl) = 0;
02422
02423         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_PageSize(
02424             /* [retval][out] */ long __RPC_FAR *pl) = 0;
02425
02426         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_PageSize(
02427             /* [in] */ long PageSize) = 0;
02428
02429         virtual /* [hidden][propget][id] */ HRESULT STDMETHODCALLTYPE get_Sort(
02430             /* [retval][out] */ BSTR __RPC_FAR *Criteria) = 0;
02431
02432         virtual /* [hidden][propput][id] */ HRESULT STDMETHODCALLTYPE put_Sort(
02433             /* [in] */ BSTR Criteria) = 0;
02434
02435         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Status(
02436             /* [retval][out] */ long __RPC_FAR *pl) = 0;
02437
02438         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_State(
02439             /* [retval][out] */ LONG __RPC_FAR *plObjState) = 0;
02440
02441         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Clone(
02442             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppvObject) = 0;
02443
02444         virtual /* [id] */ HRESULT STDMETHODCALLTYPE UpdateBatch(
02445             /* [defaultvalue][in] */ AffectEnum AffectRecords) = 0;
02446
02447         virtual /* [id] */ HRESULT STDMETHODCALLTYPE CancelBatch(
02448             /* [defaultvalue][in] */ AffectEnum AffectRecords) = 0;
02449
02450         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_CursorLocation(
02451             /* [retval][out] */ CursorLocationEnum __RPC_FAR *plCursorLoc) = 0;
02452
02453         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_CursorLocation(
02454             /* [in] */ CursorLocationEnum lCursorLoc) = 0;
02455
02456         virtual /* [id] */ HRESULT STDMETHODCALLTYPE NextRecordset(
02457             /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
02458             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppiRs) = 0;
02459
02460         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Cancel( void) = 0;
02461
02462         virtual /* [id] */ HRESULT STDMETHODCALLTYPE Supports(
02463             /* [in] */ CursorOptionEnum CursorOptions,
02464             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb) = 0;
02465
02466         virtual /* [hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get_Collect(
02467             /* [in] */ VARIANT Index,
02468             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
02469
02470         virtual /* [hidden][id][propput] */ HRESULT STDMETHODCALLTYPE put_Collect(
02471             /* [in] */ VARIANT Index,
02472             /* [in] */ VARIANT value) = 0;
02473
02474         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_MarshalOptions(
02475             /* [retval][out] */ MarshalOptionsEnum __RPC_FAR *peMarshal) = 0;
02476
02477         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_MarshalOptions(
02478             /* [in] */ MarshalOptionsEnum eMarshal) = 0;
02479
02480         virtual /* [hidden][id] */ HRESULT STDMETHODCALLTYPE Find(
02481             /* [in] */ BSTR Criteria,
02482             /* [defaultvalue][in] */ VARIANT_BOOL SkipCurrent,
02483             /* [defaultvalue][in] */ SearchDirectionEnum SearchDirection,
02484             /* [defaultvalue][in] */ VARIANT Start) = 0;
02485
02486     };
02487
02488 #else   /* C style interface */
02489     typedef struct _RecordsetVtbl
02490     {
02491         BEGIN_INTERFACE
02492
02493         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
02494             _ADORecordset __RPC_FAR * This,
02495             /* [in] */ REFIID riid,
02496             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
02497
02498         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
02499             _ADORecordset __RPC_FAR * This);
02500
02501         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
02502             _ADORecordset __RPC_FAR * This);
02503
02504         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
02505             _ADORecordset __RPC_FAR * This,
02506             /* [out] */ UINT __RPC_FAR *pctinfo);
02507
02508         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
02509             _ADORecordset __RPC_FAR * This,
02510             /* [in] */ UINT iTInfo,
02511             /* [in] */ LCID lcid,
02512             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
02513
02514         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
02515             _ADORecordset __RPC_FAR * This,
02516             /* [in] */ REFIID riid,
02517             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
02518             /* [in] */ UINT cNames,
02519             /* [in] */ LCID lcid,
02520             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
02521
02522         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
02523             _ADORecordset __RPC_FAR * This,
02524             /* [in] */ DISPID dispIdMember,
02525             /* [in] */ REFIID riid,
02526             /* [in] */ LCID lcid,
02527             /* [in] */ WORD wFlags,
02528             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
02529             /* [out] */ VARIANT __RPC_FAR *pVarResult,
02530             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
02531             /* [out] */ UINT __RPC_FAR *puArgErr);
02532
02533         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Properties )(
02534             _ADORecordset __RPC_FAR * This,
02535             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
02536
02537         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_AbsolutePosition )(
02538             _ADORecordset __RPC_FAR * This,
02539             /* [retval][out] */ PositionEnum __RPC_FAR *pl);
02540
02541         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_AbsolutePosition )(
02542             _ADORecordset __RPC_FAR * This,
02543             /* [in] */ PositionEnum Position);
02544
02545         /* [propputref][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *putref_ActiveADOConnection )(
02546             _ADORecordset __RPC_FAR * This,
02547             /* [in] */ IDispatch __RPC_FAR *pconn);
02548
02549         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_ActiveConnection )(
02550             _ADORecordset __RPC_FAR * This,
02551             /* [in] */ VARIANT vConn);
02552
02553         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_ActiveConnection )(
02554             _ADORecordset __RPC_FAR * This,
02555             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
02556
02557         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_BOF )(
02558             _ADORecordset __RPC_FAR * This,
02559             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb);
02560
02561         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Bookmark )(
02562             _ADORecordset __RPC_FAR * This,
02563             /* [retval][out] */ VARIANT __RPC_FAR *pvBookmark);
02564
02565         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Bookmark )(
02566             _ADORecordset __RPC_FAR * This,
02567             /* [in] */ VARIANT vBookmark);
02568
02569         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CacheSize )(
02570             _ADORecordset __RPC_FAR * This,
02571             /* [retval][out] */ long __RPC_FAR *pl);
02572
02573         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CacheSize )(
02574             _ADORecordset __RPC_FAR * This,
02575             /* [in] */ long CacheSize);
02576
02577         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CursorType )(
02578             _ADORecordset __RPC_FAR * This,
02579             /* [retval][out] */ CursorTypeEnum __RPC_FAR *plCursorType);
02580
02581         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CursorType )(
02582             _ADORecordset __RPC_FAR * This,
02583             /* [in] */ CursorTypeEnum lCursorType);
02584
02585         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_EOF )(
02586             _ADORecordset __RPC_FAR * This,
02587             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb);
02588
02589         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Fields )(
02590             _ADORecordset __RPC_FAR * This,
02591             /* [retval][out] */ ADOFields __RPC_FAR *__RPC_FAR *ppvObject);
02592
02593         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_LockType )(
02594             _ADORecordset __RPC_FAR * This,
02595             /* [retval][out] */ LockTypeEnum __RPC_FAR *plLockType);
02596
02597         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_LockType )(
02598             _ADORecordset __RPC_FAR * This,
02599             /* [in] */ LockTypeEnum lLockType);
02600
02601         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_MaxRecords )(
02602             _ADORecordset __RPC_FAR * This,
02603             /* [retval][out] */ long __RPC_FAR *plMaxRecords);
02604
02605         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_MaxRecords )(
02606             _ADORecordset __RPC_FAR * This,
02607             /* [in] */ long lMaxRecords);
02608
02609         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_RecordCount )(
02610             _ADORecordset __RPC_FAR * This,
02611             /* [retval][out] */ long __RPC_FAR *pl);
02612
02613         /* [propputref][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *putref_Source )(
02614             _ADORecordset __RPC_FAR * This,
02615             /* [in] */ IDispatch __RPC_FAR *pcmd);
02616
02617         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Source )(
02618             _ADORecordset __RPC_FAR * This,
02619             /* [in] */ BSTR bstrConn);
02620
02621         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Source )(
02622             _ADORecordset __RPC_FAR * This,
02623             /* [retval][out] */ VARIANT __RPC_FAR *pvSource);
02624
02625         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddNew )(
02626             _ADORecordset __RPC_FAR * This,
02627             /* [optional][in] */ VARIANT FieldList,
02628             /* [optional][in] */ VARIANT Values);
02629
02630         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CancelUpdate )(
02631             _ADORecordset __RPC_FAR * This);
02632
02633         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Close )(
02634             _ADORecordset __RPC_FAR * This);
02635
02636         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Delete )(
02637             _ADORecordset __RPC_FAR * This,
02638             /* [defaultvalue][in] */ AffectEnum AffectRecords);
02639
02640         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRows )(
02641             _ADORecordset __RPC_FAR * This,
02642             /* [defaultvalue][in] */ long Rows,
02643             /* [optional][in] */ VARIANT Start,
02644             /* [optional][in] */ VARIANT Fields,
02645             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
02646
02647         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Move )(
02648             _ADORecordset __RPC_FAR * This,
02649             /* [in] */ long NumRecords,
02650             /* [optional][in] */ VARIANT Start);
02651
02652         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MoveNext )(
02653             _ADORecordset __RPC_FAR * This);
02654
02655         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MovePrevious )(
02656             _ADORecordset __RPC_FAR * This);
02657
02658         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MoveFirst )(
02659             _ADORecordset __RPC_FAR * This);
02660
02661         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MoveLast )(
02662             _ADORecordset __RPC_FAR * This);
02663
02664         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Open )(
02665             _ADORecordset __RPC_FAR * This,
02666             /* [optional][in] */ VARIANT Source,
02667             /* [optional][in] */ VARIANT ActiveConnection,
02668             /* [defaultvalue][in] */ CursorTypeEnum CursorType,
02669             /* [defaultvalue][in] */ LockTypeEnum LockType,
02670             /* [defaultvalue][in] */ LONG Options);
02671
02672         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Requery )(
02673             _ADORecordset __RPC_FAR * This,
02674             /* [defaultvalue][in] */ LONG Options);
02675
02676         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Resync )(
02677             _ADORecordset __RPC_FAR * This,
02678             /* [defaultvalue][in] */ AffectEnum AffectRecords);
02679
02680         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Update )(
02681             _ADORecordset __RPC_FAR * This,
02682             /* [optional][in] */ VARIANT Fields,
02683             /* [optional][in] */ VARIANT Values);
02684
02685         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_AbsolutePage )(
02686             _ADORecordset __RPC_FAR * This,
02687             /* [retval][out] */ PositionEnum __RPC_FAR *pl);
02688
02689         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_AbsolutePage )(
02690             _ADORecordset __RPC_FAR * This,
02691             /* [in] */ PositionEnum Page);
02692
02693         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_EditMode )(
02694             _ADORecordset __RPC_FAR * This,
02695             /* [retval][out] */ EditModeEnum __RPC_FAR *pl);
02696
02697         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Filter )(
02698             _ADORecordset __RPC_FAR * This,
02699             /* [retval][out] */ VARIANT __RPC_FAR *Criteria);
02700
02701         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Filter )(
02702             _ADORecordset __RPC_FAR * This,
02703             /* [in] */ VARIANT Criteria);
02704
02705         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PageCount )(
02706             _ADORecordset __RPC_FAR * This,
02707             /* [retval][out] */ long __RPC_FAR *pl);
02708
02709         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PageSize )(
02710             _ADORecordset __RPC_FAR * This,
02711             /* [retval][out] */ long __RPC_FAR *pl);
02712
02713         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_PageSize )(
02714             _ADORecordset __RPC_FAR * This,
02715             /* [in] */ long PageSize);
02716
02717         /* [hidden][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Sort )(
02718             _ADORecordset __RPC_FAR * This,
02719             /* [retval][out] */ BSTR __RPC_FAR *Criteria);
02720
02721         /* [hidden][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Sort )(
02722             _ADORecordset __RPC_FAR * This,
02723             /* [in] */ BSTR Criteria);
02724
02725         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Status )(
02726             _ADORecordset __RPC_FAR * This,
02727             /* [retval][out] */ long __RPC_FAR *pl);
02728
02729         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_State )(
02730             _ADORecordset __RPC_FAR * This,
02731             /* [retval][out] */ LONG __RPC_FAR *plObjState);
02732
02733         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Clone )(
02734             _ADORecordset __RPC_FAR * This,
02735             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppvObject);
02736
02737         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *UpdateBatch )(
02738             _ADORecordset __RPC_FAR * This,
02739             /* [defaultvalue][in] */ AffectEnum AffectRecords);
02740
02741         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CancelBatch )(
02742             _ADORecordset __RPC_FAR * This,
02743             /* [defaultvalue][in] */ AffectEnum AffectRecords);
02744
02745         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_CursorLocation )(
02746             _ADORecordset __RPC_FAR * This,
02747             /* [retval][out] */ CursorLocationEnum __RPC_FAR *plCursorLoc);
02748
02749         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_CursorLocation )(
02750             _ADORecordset __RPC_FAR * This,
02751             /* [in] */ CursorLocationEnum lCursorLoc);
02752
02753         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *NextADORecordset )(
02754             _ADORecordset __RPC_FAR * This,
02755             /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
02756             /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppiRs);
02757
02758         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Cancel )(
02759             _ADORecordset __RPC_FAR * This);
02760
02761         /* [id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Supports )(
02762             _ADORecordset __RPC_FAR * This,
02763             /* [in] */ CursorOptionEnum CursorOptions,
02764             /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb);
02765
02766         /* [hidden][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Collect )(
02767             _ADORecordset __RPC_FAR * This,
02768             /* [in] */ VARIANT Index,
02769             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
02770
02771         /* [hidden][id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Collect )(
02772             _ADORecordset __RPC_FAR * This,
02773             /* [in] */ VARIANT Index,
02774             /* [in] */ VARIANT value);
02775
02776         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_MarshalOptions )(
02777             _ADORecordset __RPC_FAR * This,
02778             /* [retval][out] */ MarshalOptionsEnum __RPC_FAR *peMarshal);
02779
02780         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_MarshalOptions )(
02781             _ADORecordset __RPC_FAR * This,
02782             /* [in] */ MarshalOptionsEnum eMarshal);
02783
02784         /* [hidden][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Find )(
02785             _ADORecordset __RPC_FAR * This,
02786             /* [in] */ BSTR Criteria,
02787             /* [defaultvalue][in] */ VARIANT_BOOL SkipCurrent,
02788             /* [defaultvalue][in] */ SearchDirectionEnum SearchDirection,
02789             /* [defaultvalue][in] */ VARIANT Start);
02790
02791         END_INTERFACE
02792     } _RecordsetVtbl;
02793     interface _Recordset
02794     {
02795         CONST_VTBL struct _RecordsetVtbl __RPC_FAR *lpVtbl;
02796     };
02797
02798 #ifdef COBJMACROS
02799 #define _Recordset_QueryInterface(This,riid,ppvObject)  \
02800     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
02801 #define _Recordset_AddRef(This) \
02802     (This)->lpVtbl -> AddRef(This)
02803 #define _Recordset_Release(This)  \
02804     (This)->lpVtbl -> Release(This)
02805 #define _Recordset_GetTypeInfoCount(This,pctinfo) \
02806     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
02807 #define _Recordset_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
02808     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
02809 #define _Recordset_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
02810     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
02811 #define _Recordset_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
02812     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
02813 #define _Recordset_get_Properties(This,ppvObject) \
02814     (This)->lpVtbl -> get_Properties(This,ppvObject)
02815 #define _Recordset_get_AbsolutePosition(This,pl)  \
02816     (This)->lpVtbl -> get_AbsolutePosition(This,pl)
02817 #define _Recordset_put_AbsolutePosition(This,Position)  \
02818     (This)->lpVtbl -> put_AbsolutePosition(This,Position)
02819 #define _Recordset_putref_ActiveConnection(This,pconn)  \
02820     (This)->lpVtbl -> putref_ActiveConnection(This,pconn)
02821 #define _Recordset_put_ActiveConnection(This,vConn) \
02822     (This)->lpVtbl -> put_ActiveConnection(This,vConn)
02823 #define _Recordset_get_ActiveConnection(This,pvar)  \
02824     (This)->lpVtbl -> get_ActiveConnection(This,pvar)
02825 #define _Recordset_get_BOF(This,pb) \
02826     (This)->lpVtbl -> get_BOF(This,pb)
02827 #define _Recordset_get_Bookmark(This,pvBookmark)  \
02828     (This)->lpVtbl -> get_Bookmark(This,pvBookmark)
02829 #define _Recordset_put_Bookmark(This,vBookmark) \
02830     (This)->lpVtbl -> put_Bookmark(This,vBookmark)
02831 #define _Recordset_get_CacheSize(This,pl) \
02832     (This)->lpVtbl -> get_CacheSize(This,pl)
02833 #define _Recordset_put_CacheSize(This,CacheSize)  \
02834     (This)->lpVtbl -> put_CacheSize(This,CacheSize)
02835 #define _Recordset_get_CursorType(This,plCursorType)  \
02836     (This)->lpVtbl -> get_CursorType(This,plCursorType)
02837 #define _Recordset_put_CursorType(This,lCursorType) \
02838     (This)->lpVtbl -> put_CursorType(This,lCursorType)
02839 #define _Recordset_get_EOF(This,pb) \
02840     (This)->lpVtbl -> get_EOF(This,pb)
02841 #define _Recordset_get_Fields(This,ppvObject) \
02842     (This)->lpVtbl -> get_Fields(This,ppvObject)
02843 #define _Recordset_get_LockType(This,plLockType)  \
02844     (This)->lpVtbl -> get_LockType(This,plLockType)
02845 #define _Recordset_put_LockType(This,lLockType) \
02846     (This)->lpVtbl -> put_LockType(This,lLockType)
02847 #define _Recordset_get_MaxRecords(This,plMaxRecords)  \
02848     (This)->lpVtbl -> get_MaxRecords(This,plMaxRecords)
02849 #define _Recordset_put_MaxRecords(This,lMaxRecords) \
02850     (This)->lpVtbl -> put_MaxRecords(This,lMaxRecords)
02851 #define _Recordset_get_RecordCount(This,pl) \
02852     (This)->lpVtbl -> get_RecordCount(This,pl)
02853 #define _Recordset_putref_Source(This,pcmd) \
02854     (This)->lpVtbl -> putref_Source(This,pcmd)
02855 #define _Recordset_put_Source(This,bstrConn)  \
02856     (This)->lpVtbl -> put_Source(This,bstrConn)
02857 #define _Recordset_get_Source(This,pvSource)  \
02858     (This)->lpVtbl -> get_Source(This,pvSource)
02859 #define _Recordset_AddNew(This,FieldList,Values)  \
02860     (This)->lpVtbl -> AddNew(This,FieldList,Values)
02861 #define _Recordset_CancelUpdate(This) \
02862     (This)->lpVtbl -> CancelUpdate(This)
02863 #define _Recordset_Close(This)  \
02864     (This)->lpVtbl -> Close(This)
02865 #define _Recordset_Delete(This,AffectRecords) \
02866     (This)->lpVtbl -> Delete(This,AffectRecords)
02867 #define _Recordset_GetRows(This,Rows,Start,Fields,pvar) \
02868     (This)->lpVtbl -> GetRows(This,Rows,Start,Fields,pvar)
02869 #define _Recordset_Move(This,NumRecords,Start)  \
02870     (This)->lpVtbl -> Move(This,NumRecords,Start)
02871 #define _Recordset_MoveNext(This) \
02872     (This)->lpVtbl -> MoveNext(This)
02873 #define _Recordset_MovePrevious(This) \
02874     (This)->lpVtbl -> MovePrevious(This)
02875 #define _Recordset_MoveFirst(This)  \
02876     (This)->lpVtbl -> MoveFirst(This)
02877 #define _Recordset_MoveLast(This) \
02878     (This)->lpVtbl -> MoveLast(This)
02879 #define _Recordset_Open(This,Source,ActiveConnection,CursorType,LockType,Options) \
02880     (This)->lpVtbl -> Open(This,Source,ActiveConnection,CursorType,LockType,Options)
02881 #define _Recordset_Requery(This,Options)  \
02882     (This)->lpVtbl -> Requery(This,Options)
02883 #define _Recordset_Resync(This,AffectRecords) \
02884     (This)->lpVtbl -> Resync(This,AffectRecords)
02885 #define _Recordset_Update(This,Fields,Values) \
02886     (This)->lpVtbl -> Update(This,Fields,Values)
02887 #define _Recordset_get_AbsolutePage(This,pl)  \
02888     (This)->lpVtbl -> get_AbsolutePage(This,pl)
02889 #define _Recordset_put_AbsolutePage(This,Page)  \
02890     (This)->lpVtbl -> put_AbsolutePage(This,Page)
02891 #define _Recordset_get_EditMode(This,pl)  \
02892     (This)->lpVtbl -> get_EditMode(This,pl)
02893 #define _Recordset_get_Filter(This,Criteria)  \
02894     (This)->lpVtbl -> get_Filter(This,Criteria)
02895 #define _Recordset_put_Filter(This,Criteria)  \
02896     (This)->lpVtbl -> put_Filter(This,Criteria)
02897 #define _Recordset_get_PageCount(This,pl) \
02898     (This)->lpVtbl -> get_PageCount(This,pl)
02899 #define _Recordset_get_PageSize(This,pl)  \
02900     (This)->lpVtbl -> get_PageSize(This,pl)
02901 #define _Recordset_put_PageSize(This,PageSize)  \
02902     (This)->lpVtbl -> put_PageSize(This,PageSize)
02903 #define _Recordset_get_Sort(This,Criteria)  \
02904     (This)->lpVtbl -> get_Sort(This,Criteria)
02905 #define _Recordset_put_Sort(This,Criteria)  \
02906     (This)->lpVtbl -> put_Sort(This,Criteria)
02907 #define _Recordset_get_Status(This,pl)  \
02908     (This)->lpVtbl -> get_Status(This,pl)
02909 #define _Recordset_get_State(This,plObjState) \
02910     (This)->lpVtbl -> get_State(This,plObjState)
02911 #define _Recordset_Clone(This,ppvObject)  \
02912     (This)->lpVtbl -> Clone(This,ppvObject)
02913 #define _Recordset_UpdateBatch(This,AffectRecords)  \
02914     (This)->lpVtbl -> UpdateBatch(This,AffectRecords)
02915 #define _Recordset_CancelBatch(This,AffectRecords)  \
02916     (This)->lpVtbl -> CancelBatch(This,AffectRecords)
02917 #define _Recordset_get_CursorLocation(This,plCursorLoc) \
02918     (This)->lpVtbl -> get_CursorLocation(This,plCursorLoc)
02919 #define _Recordset_put_CursorLocation(This,lCursorLoc)  \
02920     (This)->lpVtbl -> put_CursorLocation(This,lCursorLoc)
02921 #define _Recordset_NextRecordset(This,RecordsAffected,ppiRs)  \
02922     (This)->lpVtbl -> NextRecordset(This,RecordsAffected,ppiRs)
02923 #define _Recordset_Cancel(This) \
02924     (This)->lpVtbl -> Cancel(This)
02925 #define _Recordset_Supports(This,CursorOptions,pb)  \
02926     (This)->lpVtbl -> Supports(This,CursorOptions,pb)
02927 #define _Recordset_get_Collect(This,Index,pvar) \
02928     (This)->lpVtbl -> get_Collect(This,Index,pvar)
02929 #define _Recordset_put_Collect(This,Index,value)  \
02930     (This)->lpVtbl -> put_Collect(This,Index,value)
02931 #define _Recordset_get_MarshalOptions(This,peMarshal) \
02932     (This)->lpVtbl -> get_MarshalOptions(This,peMarshal)
02933 #define _Recordset_put_MarshalOptions(This,eMarshal)  \
02934     (This)->lpVtbl -> put_MarshalOptions(This,eMarshal)
02935 #define _Recordset_Find(This,Criteria,SkipCurrent,SearchDirection,Start)  \
02936     (This)->lpVtbl -> Find(This,Criteria,SkipCurrent,SearchDirection,Start)
02937 #endif /* COBJMACROS */
02938 #endif  /* C style interface */
02939 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_AbsolutePosition_Proxy(
02940     _ADORecordset __RPC_FAR * This,
02941     /* [retval][out] */ PositionEnum __RPC_FAR *pl);
02942 void __RPC_STUB _Recordset_get_AbsolutePosition_Stub(
02943     IRpcStubBuffer *This,
02944     IRpcChannelBuffer *_pRpcChannelBuffer,
02945     PRPC_MESSAGE _pRpcMessage,
02946     DWORD *_pdwStubPhase);
02947 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_AbsolutePosition_Proxy(
02948     _ADORecordset __RPC_FAR * This,
02949     /* [in] */ PositionEnum Position);
02950 void __RPC_STUB _Recordset_put_AbsolutePosition_Stub(
02951     IRpcStubBuffer *This,
02952     IRpcChannelBuffer *_pRpcChannelBuffer,
02953     PRPC_MESSAGE _pRpcMessage,
02954     DWORD *_pdwStubPhase);
02955 /* [propputref][id] */ HRESULT STDMETHODCALLTYPE _Recordset_putref_ActiveConnection_Proxy(
02956     _ADORecordset __RPC_FAR * This,
02957     /* [in] */ IDispatch __RPC_FAR *pconn);
02958 void __RPC_STUB _Recordset_putref_ActiveConnection_Stub(
02959     IRpcStubBuffer *This,
02960     IRpcChannelBuffer *_pRpcChannelBuffer,
02961     PRPC_MESSAGE _pRpcMessage,
02962     DWORD *_pdwStubPhase);
02963 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_ActiveConnection_Proxy(
02964     _ADORecordset __RPC_FAR * This,
02965     /* [in] */ VARIANT vConn);
02966 void __RPC_STUB _Recordset_put_ActiveConnection_Stub(
02967     IRpcStubBuffer *This,
02968     IRpcChannelBuffer *_pRpcChannelBuffer,
02969     PRPC_MESSAGE _pRpcMessage,
02970     DWORD *_pdwStubPhase);
02971 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_ActiveConnection_Proxy(
02972     _ADORecordset __RPC_FAR * This,
02973     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
02974 void __RPC_STUB _Recordset_get_ActiveConnection_Stub(
02975     IRpcStubBuffer *This,
02976     IRpcChannelBuffer *_pRpcChannelBuffer,
02977     PRPC_MESSAGE _pRpcMessage,
02978     DWORD *_pdwStubPhase);
02979 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_BOF_Proxy(
02980     _ADORecordset __RPC_FAR * This,
02981     /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb);
02982 void __RPC_STUB _Recordset_get_BOF_Stub(
02983     IRpcStubBuffer *This,
02984     IRpcChannelBuffer *_pRpcChannelBuffer,
02985     PRPC_MESSAGE _pRpcMessage,
02986     DWORD *_pdwStubPhase);
02987 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Bookmark_Proxy(
02988     _ADORecordset __RPC_FAR * This,
02989     /* [retval][out] */ VARIANT __RPC_FAR *pvBookmark);
02990 void __RPC_STUB _Recordset_get_Bookmark_Stub(
02991     IRpcStubBuffer *This,
02992     IRpcChannelBuffer *_pRpcChannelBuffer,
02993     PRPC_MESSAGE _pRpcMessage,
02994     DWORD *_pdwStubPhase);
02995 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_Bookmark_Proxy(
02996     _ADORecordset __RPC_FAR * This,
02997     /* [in] */ VARIANT vBookmark);
02998 void __RPC_STUB _Recordset_put_Bookmark_Stub(
02999     IRpcStubBuffer *This,
03000     IRpcChannelBuffer *_pRpcChannelBuffer,
03001     PRPC_MESSAGE _pRpcMessage,
03002     DWORD *_pdwStubPhase);
03003 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_CacheSize_Proxy(
03004     _ADORecordset __RPC_FAR * This,
03005     /* [retval][out] */ long __RPC_FAR *pl);
03006 void __RPC_STUB _Recordset_get_CacheSize_Stub(
03007     IRpcStubBuffer *This,
03008     IRpcChannelBuffer *_pRpcChannelBuffer,
03009     PRPC_MESSAGE _pRpcMessage,
03010     DWORD *_pdwStubPhase);
03011 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_CacheSize_Proxy(
03012     _ADORecordset __RPC_FAR * This,
03013     /* [in] */ long CacheSize);
03014 void __RPC_STUB _Recordset_put_CacheSize_Stub(
03015     IRpcStubBuffer *This,
03016     IRpcChannelBuffer *_pRpcChannelBuffer,
03017     PRPC_MESSAGE _pRpcMessage,
03018     DWORD *_pdwStubPhase);
03019 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_CursorType_Proxy(
03020     _ADORecordset __RPC_FAR * This,
03021     /* [retval][out] */ CursorTypeEnum __RPC_FAR *plCursorType);
03022 void __RPC_STUB _Recordset_get_CursorType_Stub(
03023     IRpcStubBuffer *This,
03024     IRpcChannelBuffer *_pRpcChannelBuffer,
03025     PRPC_MESSAGE _pRpcMessage,
03026     DWORD *_pdwStubPhase);
03027 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_CursorType_Proxy(
03028     _ADORecordset __RPC_FAR * This,
03029     /* [in] */ CursorTypeEnum lCursorType);
03030 void __RPC_STUB _Recordset_put_CursorType_Stub(
03031     IRpcStubBuffer *This,
03032     IRpcChannelBuffer *_pRpcChannelBuffer,
03033     PRPC_MESSAGE _pRpcMessage,
03034     DWORD *_pdwStubPhase);
03035 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_EOF_Proxy(
03036     _ADORecordset __RPC_FAR * This,
03037     /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb);
03038 void __RPC_STUB _Recordset_get_EOF_Stub(
03039     IRpcStubBuffer *This,
03040     IRpcChannelBuffer *_pRpcChannelBuffer,
03041     PRPC_MESSAGE _pRpcMessage,
03042     DWORD *_pdwStubPhase);
03043 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Fields_Proxy(
03044     _ADORecordset __RPC_FAR * This,
03045     /* [retval][out] */ ADOFields __RPC_FAR *__RPC_FAR *ppvObject);
03046 void __RPC_STUB _Recordset_get_Fields_Stub(
03047     IRpcStubBuffer *This,
03048     IRpcChannelBuffer *_pRpcChannelBuffer,
03049     PRPC_MESSAGE _pRpcMessage,
03050     DWORD *_pdwStubPhase);
03051 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_LockType_Proxy(
03052     _ADORecordset __RPC_FAR * This,
03053     /* [retval][out] */ LockTypeEnum __RPC_FAR *plLockType);
03054 void __RPC_STUB _Recordset_get_LockType_Stub(
03055     IRpcStubBuffer *This,
03056     IRpcChannelBuffer *_pRpcChannelBuffer,
03057     PRPC_MESSAGE _pRpcMessage,
03058     DWORD *_pdwStubPhase);
03059 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_LockType_Proxy(
03060     _ADORecordset __RPC_FAR * This,
03061     /* [in] */ LockTypeEnum lLockType);
03062 void __RPC_STUB _Recordset_put_LockType_Stub(
03063     IRpcStubBuffer *This,
03064     IRpcChannelBuffer *_pRpcChannelBuffer,
03065     PRPC_MESSAGE _pRpcMessage,
03066     DWORD *_pdwStubPhase);
03067 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_MaxRecords_Proxy(
03068     _ADORecordset __RPC_FAR * This,
03069     /* [retval][out] */ long __RPC_FAR *plMaxRecords);
03070 void __RPC_STUB _Recordset_get_MaxRecords_Stub(
03071     IRpcStubBuffer *This,
03072     IRpcChannelBuffer *_pRpcChannelBuffer,
03073     PRPC_MESSAGE _pRpcMessage,
03074     DWORD *_pdwStubPhase);
03075 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_MaxRecords_Proxy(
03076     _ADORecordset __RPC_FAR * This,
03077     /* [in] */ long lMaxRecords);
03078 void __RPC_STUB _Recordset_put_MaxRecords_Stub(
03079     IRpcStubBuffer *This,
03080     IRpcChannelBuffer *_pRpcChannelBuffer,
03081     PRPC_MESSAGE _pRpcMessage,
03082     DWORD *_pdwStubPhase);
03083 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_RecordCount_Proxy(
03084     _ADORecordset __RPC_FAR * This,
03085     /* [retval][out] */ long __RPC_FAR *pl);
03086 void __RPC_STUB _Recordset_get_RecordCount_Stub(
03087     IRpcStubBuffer *This,
03088     IRpcChannelBuffer *_pRpcChannelBuffer,
03089     PRPC_MESSAGE _pRpcMessage,
03090     DWORD *_pdwStubPhase);
03091 /* [propputref][id] */ HRESULT STDMETHODCALLTYPE _Recordset_putref_Source_Proxy(
03092     _ADORecordset __RPC_FAR * This,
03093     /* [in] */ IDispatch __RPC_FAR *pcmd);
03094 void __RPC_STUB _Recordset_putref_Source_Stub(
03095     IRpcStubBuffer *This,
03096     IRpcChannelBuffer *_pRpcChannelBuffer,
03097     PRPC_MESSAGE _pRpcMessage,
03098     DWORD *_pdwStubPhase);
03099 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_Source_Proxy(
03100     _ADORecordset __RPC_FAR * This,
03101     /* [in] */ BSTR bstrConn);
03102 void __RPC_STUB _Recordset_put_Source_Stub(
03103     IRpcStubBuffer *This,
03104     IRpcChannelBuffer *_pRpcChannelBuffer,
03105     PRPC_MESSAGE _pRpcMessage,
03106     DWORD *_pdwStubPhase);
03107 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Source_Proxy(
03108     _ADORecordset __RPC_FAR * This,
03109     /* [retval][out] */ VARIANT __RPC_FAR *pvSource);
03110 void __RPC_STUB _Recordset_get_Source_Stub(
03111     IRpcStubBuffer *This,
03112     IRpcChannelBuffer *_pRpcChannelBuffer,
03113     PRPC_MESSAGE _pRpcMessage,
03114     DWORD *_pdwStubPhase);
03115 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_AddNew_Proxy(
03116     _ADORecordset __RPC_FAR * This,
03117     /* [optional][in] */ VARIANT FieldList,
03118     /* [optional][in] */ VARIANT Values);
03119 void __RPC_STUB _Recordset_AddNew_Stub(
03120     IRpcStubBuffer *This,
03121     IRpcChannelBuffer *_pRpcChannelBuffer,
03122     PRPC_MESSAGE _pRpcMessage,
03123     DWORD *_pdwStubPhase);
03124 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_CancelUpdate_Proxy(
03125     _ADORecordset __RPC_FAR * This);
03126 void __RPC_STUB _Recordset_CancelUpdate_Stub(
03127     IRpcStubBuffer *This,
03128     IRpcChannelBuffer *_pRpcChannelBuffer,
03129     PRPC_MESSAGE _pRpcMessage,
03130     DWORD *_pdwStubPhase);
03131 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Close_Proxy(
03132     _ADORecordset __RPC_FAR * This);
03133 void __RPC_STUB _Recordset_Close_Stub(
03134     IRpcStubBuffer *This,
03135     IRpcChannelBuffer *_pRpcChannelBuffer,
03136     PRPC_MESSAGE _pRpcMessage,
03137     DWORD *_pdwStubPhase);
03138 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Delete_Proxy(
03139     _ADORecordset __RPC_FAR * This,
03140     /* [defaultvalue][in] */ AffectEnum AffectRecords);
03141 void __RPC_STUB _Recordset_Delete_Stub(
03142     IRpcStubBuffer *This,
03143     IRpcChannelBuffer *_pRpcChannelBuffer,
03144     PRPC_MESSAGE _pRpcMessage,
03145     DWORD *_pdwStubPhase);
03146 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_GetRows_Proxy(
03147     _ADORecordset __RPC_FAR * This,
03148     /* [defaultvalue][in] */ long Rows,
03149     /* [optional][in] */ VARIANT Start,
03150     /* [optional][in] */ VARIANT Fields,
03151     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03152 void __RPC_STUB _Recordset_GetRows_Stub(
03153     IRpcStubBuffer *This,
03154     IRpcChannelBuffer *_pRpcChannelBuffer,
03155     PRPC_MESSAGE _pRpcMessage,
03156     DWORD *_pdwStubPhase);
03157 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Move_Proxy(
03158     _ADORecordset __RPC_FAR * This,
03159     /* [in] */ long NumRecords,
03160     /* [optional][in] */ VARIANT Start);
03161 void __RPC_STUB _Recordset_Move_Stub(
03162     IRpcStubBuffer *This,
03163     IRpcChannelBuffer *_pRpcChannelBuffer,
03164     PRPC_MESSAGE _pRpcMessage,
03165     DWORD *_pdwStubPhase);
03166 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_MoveNext_Proxy(
03167     _ADORecordset __RPC_FAR * This);
03168 void __RPC_STUB _Recordset_MoveNext_Stub(
03169     IRpcStubBuffer *This,
03170     IRpcChannelBuffer *_pRpcChannelBuffer,
03171     PRPC_MESSAGE _pRpcMessage,
03172     DWORD *_pdwStubPhase);
03173 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_MovePrevious_Proxy(
03174     _ADORecordset __RPC_FAR * This);
03175 void __RPC_STUB _Recordset_MovePrevious_Stub(
03176     IRpcStubBuffer *This,
03177     IRpcChannelBuffer *_pRpcChannelBuffer,
03178     PRPC_MESSAGE _pRpcMessage,
03179     DWORD *_pdwStubPhase);
03180 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_MoveFirst_Proxy(
03181     _ADORecordset __RPC_FAR * This);
03182 void __RPC_STUB _Recordset_MoveFirst_Stub(
03183     IRpcStubBuffer *This,
03184     IRpcChannelBuffer *_pRpcChannelBuffer,
03185     PRPC_MESSAGE _pRpcMessage,
03186     DWORD *_pdwStubPhase);
03187 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_MoveLast_Proxy(
03188     _ADORecordset __RPC_FAR * This);
03189 void __RPC_STUB _Recordset_MoveLast_Stub(
03190     IRpcStubBuffer *This,
03191     IRpcChannelBuffer *_pRpcChannelBuffer,
03192     PRPC_MESSAGE _pRpcMessage,
03193     DWORD *_pdwStubPhase);
03194 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Open_Proxy(
03195     _ADORecordset __RPC_FAR * This,
03196     /* [optional][in] */ VARIANT Source,
03197     /* [optional][in] */ VARIANT ActiveConnection,
03198     /* [defaultvalue][in] */ CursorTypeEnum CursorType,
03199     /* [defaultvalue][in] */ LockTypeEnum LockType,
03200     /* [defaultvalue][in] */ LONG Options);
03201 void __RPC_STUB _Recordset_Open_Stub(
03202     IRpcStubBuffer *This,
03203     IRpcChannelBuffer *_pRpcChannelBuffer,
03204     PRPC_MESSAGE _pRpcMessage,
03205     DWORD *_pdwStubPhase);
03206 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Requery_Proxy(
03207     _ADORecordset __RPC_FAR * This,
03208     /* [defaultvalue][in] */ LONG Options);
03209 void __RPC_STUB _Recordset_Requery_Stub(
03210     IRpcStubBuffer *This,
03211     IRpcChannelBuffer *_pRpcChannelBuffer,
03212     PRPC_MESSAGE _pRpcMessage,
03213     DWORD *_pdwStubPhase);
03214 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Resync_Proxy(
03215     _ADORecordset __RPC_FAR * This,
03216     /* [defaultvalue][in] */ AffectEnum AffectRecords);
03217 void __RPC_STUB _Recordset_Resync_Stub(
03218     IRpcStubBuffer *This,
03219     IRpcChannelBuffer *_pRpcChannelBuffer,
03220     PRPC_MESSAGE _pRpcMessage,
03221     DWORD *_pdwStubPhase);
03222 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Update_Proxy(
03223     _ADORecordset __RPC_FAR * This,
03224     /* [optional][in] */ VARIANT Fields,
03225     /* [optional][in] */ VARIANT Values);
03226 void __RPC_STUB _Recordset_Update_Stub(
03227     IRpcStubBuffer *This,
03228     IRpcChannelBuffer *_pRpcChannelBuffer,
03229     PRPC_MESSAGE _pRpcMessage,
03230     DWORD *_pdwStubPhase);
03231 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_AbsolutePage_Proxy(
03232     _ADORecordset __RPC_FAR * This,
03233     /* [retval][out] */ PositionEnum __RPC_FAR *pl);
03234 void __RPC_STUB _Recordset_get_AbsolutePage_Stub(
03235     IRpcStubBuffer *This,
03236     IRpcChannelBuffer *_pRpcChannelBuffer,
03237     PRPC_MESSAGE _pRpcMessage,
03238     DWORD *_pdwStubPhase);
03239 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_AbsolutePage_Proxy(
03240     _ADORecordset __RPC_FAR * This,
03241     /* [in] */ PositionEnum Page);
03242 void __RPC_STUB _Recordset_put_AbsolutePage_Stub(
03243     IRpcStubBuffer *This,
03244     IRpcChannelBuffer *_pRpcChannelBuffer,
03245     PRPC_MESSAGE _pRpcMessage,
03246     DWORD *_pdwStubPhase);
03247 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_EditMode_Proxy(
03248     _ADORecordset __RPC_FAR * This,
03249     /* [retval][out] */ EditModeEnum __RPC_FAR *pl);
03250 void __RPC_STUB _Recordset_get_EditMode_Stub(
03251     IRpcStubBuffer *This,
03252     IRpcChannelBuffer *_pRpcChannelBuffer,
03253     PRPC_MESSAGE _pRpcMessage,
03254     DWORD *_pdwStubPhase);
03255 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Filter_Proxy(
03256     _ADORecordset __RPC_FAR * This,
03257     /* [retval][out] */ VARIANT __RPC_FAR *Criteria);
03258 void __RPC_STUB _Recordset_get_Filter_Stub(
03259     IRpcStubBuffer *This,
03260     IRpcChannelBuffer *_pRpcChannelBuffer,
03261     PRPC_MESSAGE _pRpcMessage,
03262     DWORD *_pdwStubPhase);
03263 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_Filter_Proxy(
03264     _ADORecordset __RPC_FAR * This,
03265     /* [in] */ VARIANT Criteria);
03266 void __RPC_STUB _Recordset_put_Filter_Stub(
03267     IRpcStubBuffer *This,
03268     IRpcChannelBuffer *_pRpcChannelBuffer,
03269     PRPC_MESSAGE _pRpcMessage,
03270     DWORD *_pdwStubPhase);
03271 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_PageCount_Proxy(
03272     _ADORecordset __RPC_FAR * This,
03273     /* [retval][out] */ long __RPC_FAR *pl);
03274 void __RPC_STUB _Recordset_get_PageCount_Stub(
03275     IRpcStubBuffer *This,
03276     IRpcChannelBuffer *_pRpcChannelBuffer,
03277     PRPC_MESSAGE _pRpcMessage,
03278     DWORD *_pdwStubPhase);
03279 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_PageSize_Proxy(
03280     _ADORecordset __RPC_FAR * This,
03281     /* [retval][out] */ long __RPC_FAR *pl);
03282 void __RPC_STUB _Recordset_get_PageSize_Stub(
03283     IRpcStubBuffer *This,
03284     IRpcChannelBuffer *_pRpcChannelBuffer,
03285     PRPC_MESSAGE _pRpcMessage,
03286     DWORD *_pdwStubPhase);
03287 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_PageSize_Proxy(
03288     _ADORecordset __RPC_FAR * This,
03289     /* [in] */ long PageSize);
03290 void __RPC_STUB _Recordset_put_PageSize_Stub(
03291     IRpcStubBuffer *This,
03292     IRpcChannelBuffer *_pRpcChannelBuffer,
03293     PRPC_MESSAGE _pRpcMessage,
03294     DWORD *_pdwStubPhase);
03295 /* [hidden][propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Sort_Proxy(
03296     _ADORecordset __RPC_FAR * This,
03297     /* [retval][out] */ BSTR __RPC_FAR *Criteria);
03298 void __RPC_STUB _Recordset_get_Sort_Stub(
03299     IRpcStubBuffer *This,
03300     IRpcChannelBuffer *_pRpcChannelBuffer,
03301     PRPC_MESSAGE _pRpcMessage,
03302     DWORD *_pdwStubPhase);
03303 /* [hidden][propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_Sort_Proxy(
03304     _ADORecordset __RPC_FAR * This,
03305     /* [in] */ BSTR Criteria);
03306 void __RPC_STUB _Recordset_put_Sort_Stub(
03307     IRpcStubBuffer *This,
03308     IRpcChannelBuffer *_pRpcChannelBuffer,
03309     PRPC_MESSAGE _pRpcMessage,
03310     DWORD *_pdwStubPhase);
03311 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Status_Proxy(
03312     _ADORecordset __RPC_FAR * This,
03313     /* [retval][out] */ long __RPC_FAR *pl);
03314 void __RPC_STUB _Recordset_get_Status_Stub(
03315     IRpcStubBuffer *This,
03316     IRpcChannelBuffer *_pRpcChannelBuffer,
03317     PRPC_MESSAGE _pRpcMessage,
03318     DWORD *_pdwStubPhase);
03319 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_State_Proxy(
03320     _ADORecordset __RPC_FAR * This,
03321     /* [retval][out] */ LONG __RPC_FAR *plObjState);
03322 void __RPC_STUB _Recordset_get_State_Stub(
03323     IRpcStubBuffer *This,
03324     IRpcChannelBuffer *_pRpcChannelBuffer,
03325     PRPC_MESSAGE _pRpcMessage,
03326     DWORD *_pdwStubPhase);
03327 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Clone_Proxy(
03328     _ADORecordset __RPC_FAR * This,
03329     /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppvObject);
03330 void __RPC_STUB _Recordset_Clone_Stub(
03331     IRpcStubBuffer *This,
03332     IRpcChannelBuffer *_pRpcChannelBuffer,
03333     PRPC_MESSAGE _pRpcMessage,
03334     DWORD *_pdwStubPhase);
03335 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_UpdateBatch_Proxy(
03336     _ADORecordset __RPC_FAR * This,
03337     /* [defaultvalue][in] */ AffectEnum AffectRecords);
03338 void __RPC_STUB _Recordset_UpdateBatch_Stub(
03339     IRpcStubBuffer *This,
03340     IRpcChannelBuffer *_pRpcChannelBuffer,
03341     PRPC_MESSAGE _pRpcMessage,
03342     DWORD *_pdwStubPhase);
03343 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_CancelBatch_Proxy(
03344     _ADORecordset __RPC_FAR * This,
03345     /* [defaultvalue][in] */ AffectEnum AffectRecords);
03346 void __RPC_STUB _Recordset_CancelBatch_Stub(
03347     IRpcStubBuffer *This,
03348     IRpcChannelBuffer *_pRpcChannelBuffer,
03349     PRPC_MESSAGE _pRpcMessage,
03350     DWORD *_pdwStubPhase);
03351 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_CursorLocation_Proxy(
03352     _ADORecordset __RPC_FAR * This,
03353     /* [retval][out] */ CursorLocationEnum __RPC_FAR *plCursorLoc);
03354 void __RPC_STUB _Recordset_get_CursorLocation_Stub(
03355     IRpcStubBuffer *This,
03356     IRpcChannelBuffer *_pRpcChannelBuffer,
03357     PRPC_MESSAGE _pRpcMessage,
03358     DWORD *_pdwStubPhase);
03359 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_CursorLocation_Proxy(
03360     _ADORecordset __RPC_FAR * This,
03361     /* [in] */ CursorLocationEnum lCursorLoc);
03362 void __RPC_STUB _Recordset_put_CursorLocation_Stub(
03363     IRpcStubBuffer *This,
03364     IRpcChannelBuffer *_pRpcChannelBuffer,
03365     PRPC_MESSAGE _pRpcMessage,
03366     DWORD *_pdwStubPhase);
03367 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_NextRecordset_Proxy(
03368     _ADORecordset __RPC_FAR * This,
03369     /* [optional][out] */ VARIANT __RPC_FAR *RecordsAffected,
03370     /* [retval][out] */ _ADORecordset __RPC_FAR *__RPC_FAR *ppiRs);
03371 void __RPC_STUB _Recordset_NextRecordset_Stub(
03372     IRpcStubBuffer *This,
03373     IRpcChannelBuffer *_pRpcChannelBuffer,
03374     PRPC_MESSAGE _pRpcMessage,
03375     DWORD *_pdwStubPhase);
03376 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Cancel_Proxy(
03377     _ADORecordset __RPC_FAR * This);
03378 void __RPC_STUB _Recordset_Cancel_Stub(
03379     IRpcStubBuffer *This,
03380     IRpcChannelBuffer *_pRpcChannelBuffer,
03381     PRPC_MESSAGE _pRpcMessage,
03382     DWORD *_pdwStubPhase);
03383 /* [id] */ HRESULT STDMETHODCALLTYPE _Recordset_Supports_Proxy(
03384     _ADORecordset __RPC_FAR * This,
03385     /* [in] */ CursorOptionEnum CursorOptions,
03386     /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pb);
03387 void __RPC_STUB _Recordset_Supports_Stub(
03388     IRpcStubBuffer *This,
03389     IRpcChannelBuffer *_pRpcChannelBuffer,
03390     PRPC_MESSAGE _pRpcMessage,
03391     DWORD *_pdwStubPhase);
03392 /* [hidden][id][propget] */ HRESULT STDMETHODCALLTYPE _Recordset_get_Collect_Proxy(
03393     _ADORecordset __RPC_FAR * This,
03394     /* [in] */ VARIANT Index,
03395     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03396 void __RPC_STUB _Recordset_get_Collect_Stub(
03397     IRpcStubBuffer *This,
03398     IRpcChannelBuffer *_pRpcChannelBuffer,
03399     PRPC_MESSAGE _pRpcMessage,
03400     DWORD *_pdwStubPhase);
03401 /* [hidden][id][propput] */ HRESULT STDMETHODCALLTYPE _Recordset_put_Collect_Proxy(
03402     _ADORecordset __RPC_FAR * This,
03403     /* [in] */ VARIANT Index,
03404     /* [in] */ VARIANT value);
03405 void __RPC_STUB _Recordset_put_Collect_Stub(
03406     IRpcStubBuffer *This,
03407     IRpcChannelBuffer *_pRpcChannelBuffer,
03408     PRPC_MESSAGE _pRpcMessage,
03409     DWORD *_pdwStubPhase);
03410 /* [propget][id] */ HRESULT STDMETHODCALLTYPE _Recordset_get_MarshalOptions_Proxy(
03411     _ADORecordset __RPC_FAR * This,
03412     /* [retval][out] */ MarshalOptionsEnum __RPC_FAR *peMarshal);
03413 void __RPC_STUB _Recordset_get_MarshalOptions_Stub(
03414     IRpcStubBuffer *This,
03415     IRpcChannelBuffer *_pRpcChannelBuffer,
03416     PRPC_MESSAGE _pRpcMessage,
03417     DWORD *_pdwStubPhase);
03418 /* [propput][id] */ HRESULT STDMETHODCALLTYPE _Recordset_put_MarshalOptions_Proxy(
03419     _ADORecordset __RPC_FAR * This,
03420     /* [in] */ MarshalOptionsEnum eMarshal);
03421 void __RPC_STUB _Recordset_put_MarshalOptions_Stub(
03422     IRpcStubBuffer *This,
03423     IRpcChannelBuffer *_pRpcChannelBuffer,
03424     PRPC_MESSAGE _pRpcMessage,
03425     DWORD *_pdwStubPhase);
03426 /* [hidden][id] */ HRESULT STDMETHODCALLTYPE _Recordset_Find_Proxy(
03427     _ADORecordset __RPC_FAR * This,
03428     /* [in] */ BSTR Criteria,
03429     /* [defaultvalue][in] */ VARIANT_BOOL SkipCurrent,
03430     /* [defaultvalue][in] */ SearchDirectionEnum SearchDirection,
03431     /* [defaultvalue][in] */ VARIANT Start);
03432 void __RPC_STUB _Recordset_Find_Stub(
03433     IRpcStubBuffer *This,
03434     IRpcChannelBuffer *_pRpcChannelBuffer,
03435     PRPC_MESSAGE _pRpcMessage,
03436     DWORD *_pdwStubPhase);
03437 #endif  /* ___Recordset_INTERFACE_DEFINED__ */
03438 #ifdef __cplusplus
03439 EXTERN_C const CLSID CLSID_Recordset;
03440 Recordset;
03441 #endif
03442 #ifndef __ADORecordsetConstruction_INTERFACE_DEFINED__
03443 #define __ADORecordsetConstruction_INTERFACE_DEFINED__
03444 /****************************************
03445  * Generated header for interface: ADORecordsetConstruction
03446  * at Mon Jul 14 07:56:56 1997
03447  * using MIDL 3.01.75
03448  ****************************************/
03449 /* [object][uuid][restricted] */
03450 EXTERN_C const IID IID_ADORecordsetConstruction;
03451 #if defined(__cplusplus) && !defined(CINTERFACE)
03452
03453     interface DECLSPEC_UUID("00000283-0000-0010-8000-00AA006D2EA4")
03454     ADORecordsetConstruction : public IDispatch
03455     {
03456     public:
03457         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Rowset(
03458             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
03459
03460         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Rowset(
03461             /* [in] */ IUnknown __RPC_FAR *pRowset) = 0;
03462
03463         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Chapter(
03464             /* [retval][out] */ LONG __RPC_FAR *plChapter) = 0;
03465
03466         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Chapter(
03467             /* [in] */ LONG lChapter) = 0;
03468
03469         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RowPosition(
03470             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowPos) = 0;
03471
03472         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RowPosition(
03473             /* [in] */ IUnknown __RPC_FAR *pRowPos) = 0;
03474
03475     };
03476
03477 #else   /* C style interface */
03478     typedef struct ADORecordsetConstructionVtbl
03479     {
03480         BEGIN_INTERFACE
03481
03482         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
03483             ADORecordsetConstruction __RPC_FAR * This,
03484             /* [in] */ REFIID riid,
03485             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
03486
03487         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
03488             ADORecordsetConstruction __RPC_FAR * This);
03489
03490         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
03491             ADORecordsetConstruction __RPC_FAR * This);
03492
03493         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
03494             ADORecordsetConstruction __RPC_FAR * This,
03495             /* [out] */ UINT __RPC_FAR *pctinfo);
03496
03497         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
03498             ADORecordsetConstruction __RPC_FAR * This,
03499             /* [in] */ UINT iTInfo,
03500             /* [in] */ LCID lcid,
03501             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
03502
03503         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
03504             ADORecordsetConstruction __RPC_FAR * This,
03505             /* [in] */ REFIID riid,
03506             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
03507             /* [in] */ UINT cNames,
03508             /* [in] */ LCID lcid,
03509             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
03510
03511         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
03512             ADORecordsetConstruction __RPC_FAR * This,
03513             /* [in] */ DISPID dispIdMember,
03514             /* [in] */ REFIID riid,
03515             /* [in] */ LCID lcid,
03516             /* [in] */ WORD wFlags,
03517             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
03518             /* [out] */ VARIANT __RPC_FAR *pVarResult,
03519             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
03520             /* [out] */ UINT __RPC_FAR *puArgErr);
03521
03522         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Rowset )(
03523             ADORecordsetConstruction __RPC_FAR * This,
03524             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
03525
03526         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Rowset )(
03527             ADORecordsetConstruction __RPC_FAR * This,
03528             /* [in] */ IUnknown __RPC_FAR *pRowset);
03529
03530         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Chapter )(
03531             ADORecordsetConstruction __RPC_FAR * This,
03532             /* [retval][out] */ LONG __RPC_FAR *plChapter);
03533
03534         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Chapter )(
03535             ADORecordsetConstruction __RPC_FAR * This,
03536             /* [in] */ LONG lChapter);
03537
03538         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_RowPosition )(
03539             ADORecordsetConstruction __RPC_FAR * This,
03540             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowPos);
03541
03542         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_RowPosition )(
03543             ADORecordsetConstruction __RPC_FAR * This,
03544             /* [in] */ IUnknown __RPC_FAR *pRowPos);
03545
03546         END_INTERFACE
03547     } ADORecordsetConstructionVtbl;
03548     interface ADORecordsetConstruction
03549     {
03550         CONST_VTBL struct ADORecordsetConstructionVtbl __RPC_FAR *lpVtbl;
03551     };
03552
03553 #ifdef COBJMACROS
03554 #define ADORecordsetConstruction_QueryInterface(This,riid,ppvObject)  \
03555     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
03556 #define ADORecordsetConstruction_AddRef(This) \
03557     (This)->lpVtbl -> AddRef(This)
03558 #define ADORecordsetConstruction_Release(This)  \
03559     (This)->lpVtbl -> Release(This)
03560 #define ADORecordsetConstruction_GetTypeInfoCount(This,pctinfo) \
03561     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
03562 #define ADORecordsetConstruction_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
03563     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
03564 #define ADORecordsetConstruction_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
03565     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
03566 #define ADORecordsetConstruction_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
03567     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
03568 #define ADORecordsetConstruction_get_Rowset(This,ppRowset)  \
03569     (This)->lpVtbl -> get_Rowset(This,ppRowset)
03570 #define ADORecordsetConstruction_put_Rowset(This,pRowset) \
03571     (This)->lpVtbl -> put_Rowset(This,pRowset)
03572 #define ADORecordsetConstruction_get_Chapter(This,plChapter)  \
03573     (This)->lpVtbl -> get_Chapter(This,plChapter)
03574 #define ADORecordsetConstruction_put_Chapter(This,lChapter) \
03575     (This)->lpVtbl -> put_Chapter(This,lChapter)
03576 #define ADORecordsetConstruction_get_RowPosition(This,ppRowPos) \
03577     (This)->lpVtbl -> get_RowPosition(This,ppRowPos)
03578 #define ADORecordsetConstruction_put_RowPosition(This,pRowPos)  \
03579     (This)->lpVtbl -> put_RowPosition(This,pRowPos)
03580 #endif /* COBJMACROS */
03581 #endif  /* C style interface */
03582 /* [propget] */ HRESULT STDMETHODCALLTYPE ADORecordsetConstruction_get_Rowset_Proxy(
03583     ADORecordsetConstruction __RPC_FAR * This,
03584     /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
03585 void __RPC_STUB ADORecordsetConstruction_get_Rowset_Stub(
03586     IRpcStubBuffer *This,
03587     IRpcChannelBuffer *_pRpcChannelBuffer,
03588     PRPC_MESSAGE _pRpcMessage,
03589     DWORD *_pdwStubPhase);
03590 /* [propput] */ HRESULT STDMETHODCALLTYPE ADORecordsetConstruction_put_Rowset_Proxy(
03591     ADORecordsetConstruction __RPC_FAR * This,
03592     /* [in] */ IUnknown __RPC_FAR *pRowset);
03593 void __RPC_STUB ADORecordsetConstruction_put_Rowset_Stub(
03594     IRpcStubBuffer *This,
03595     IRpcChannelBuffer *_pRpcChannelBuffer,
03596     PRPC_MESSAGE _pRpcMessage,
03597     DWORD *_pdwStubPhase);
03598 /* [propget] */ HRESULT STDMETHODCALLTYPE ADORecordsetConstruction_get_Chapter_Proxy(
03599     ADORecordsetConstruction __RPC_FAR * This,
03600     /* [retval][out] */ LONG __RPC_FAR *plChapter);
03601 void __RPC_STUB ADORecordsetConstruction_get_Chapter_Stub(
03602     IRpcStubBuffer *This,
03603     IRpcChannelBuffer *_pRpcChannelBuffer,
03604     PRPC_MESSAGE _pRpcMessage,
03605     DWORD *_pdwStubPhase);
03606 /* [propput] */ HRESULT STDMETHODCALLTYPE ADORecordsetConstruction_put_Chapter_Proxy(
03607     ADORecordsetConstruction __RPC_FAR * This,
03608     /* [in] */ LONG lChapter);
03609 void __RPC_STUB ADORecordsetConstruction_put_Chapter_Stub(
03610     IRpcStubBuffer *This,
03611     IRpcChannelBuffer *_pRpcChannelBuffer,
03612     PRPC_MESSAGE _pRpcMessage,
03613     DWORD *_pdwStubPhase);
03614 /* [propget] */ HRESULT STDMETHODCALLTYPE ADORecordsetConstruction_get_RowPosition_Proxy(
03615     ADORecordsetConstruction __RPC_FAR * This,
03616     /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowPos);
03617 void __RPC_STUB ADORecordsetConstruction_get_RowPosition_Stub(
03618     IRpcStubBuffer *This,
03619     IRpcChannelBuffer *_pRpcChannelBuffer,
03620     PRPC_MESSAGE _pRpcMessage,
03621     DWORD *_pdwStubPhase);
03622 /* [propput] */ HRESULT STDMETHODCALLTYPE ADORecordsetConstruction_put_RowPosition_Proxy(
03623     ADORecordsetConstruction __RPC_FAR * This,
03624     /* [in] */ IUnknown __RPC_FAR *pRowPos);
03625 void __RPC_STUB ADORecordsetConstruction_put_RowPosition_Stub(
03626     IRpcStubBuffer *This,
03627     IRpcChannelBuffer *_pRpcChannelBuffer,
03628     PRPC_MESSAGE _pRpcMessage,
03629     DWORD *_pdwStubPhase);
03630 #endif  /* __ADORecordsetConstruction_INTERFACE_DEFINED__ */
03631 #ifndef __Field_INTERFACE_DEFINED__
03632 #define __Field_INTERFACE_DEFINED__
03633 /****************************************
03634  * Generated header for interface: Field
03635  * at Mon Jul 14 07:56:56 1997
03636  * using MIDL 3.01.75
03637  ****************************************/
03638 /* [object][helpstring][helpcontext][uuid][nonextensible][dual] */
03639 EXTERN_C const IID IID_Field;
03640 #if defined(__cplusplus) && !defined(CINTERFACE)
03641
03642     interface DECLSPEC_UUID("00000505-0000-0010-8000-00AA006D2EA4")
03643     ADOField : public _ADO
03644     {
03645     public:
03646         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_ActualSize(
03647             /* [retval][out] */ long __RPC_FAR *pl) = 0;
03648
03649         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_Attributes(
03650             /* [retval][out] */ long __RPC_FAR *pl) = 0;
03651
03652         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_DefinedSize(
03653             /* [retval][out] */ long __RPC_FAR *pl) = 0;
03654
03655         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_Name(
03656             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
03657
03658         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_Type(
03659             /* [retval][out] */ DataTypeEnum __RPC_FAR *pDataType) = 0;
03660
03661         virtual /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE get_Value(
03662             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
03663
03664         virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Value(
03665             /* [in] */ VARIANT Val) = 0;
03666
03667         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Precision(
03668             /* [retval][out] */ BYTE __RPC_FAR *pbPrecision) = 0;
03669
03670         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_NumericScale(
03671             /* [retval][out] */ BYTE __RPC_FAR *pbNumericScale) = 0;
03672
03673         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE AppendChunk(
03674             /* [in] */ VARIANT Data) = 0;
03675
03676         virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE GetChunk(
03677             /* [in] */ long Length,
03678             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
03679
03680         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_OriginalValue(
03681             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
03682
03683         virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_UnderlyingValue(
03684             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
03685
03686     };
03687
03688 #else   /* C style interface */
03689     typedef struct FieldVtbl
03690     {
03691         BEGIN_INTERFACE
03692
03693         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
03694             ADOField __RPC_FAR * This,
03695             /* [in] */ REFIID riid,
03696             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
03697
03698         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
03699             ADOField __RPC_FAR * This);
03700
03701         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
03702             ADOField __RPC_FAR * This);
03703
03704         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
03705             ADOField __RPC_FAR * This,
03706             /* [out] */ UINT __RPC_FAR *pctinfo);
03707
03708         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
03709             ADOField __RPC_FAR * This,
03710             /* [in] */ UINT iTInfo,
03711             /* [in] */ LCID lcid,
03712             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
03713
03714         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
03715             ADOField __RPC_FAR * This,
03716             /* [in] */ REFIID riid,
03717             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
03718             /* [in] */ UINT cNames,
03719             /* [in] */ LCID lcid,
03720             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
03721
03722         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
03723             ADOField __RPC_FAR * This,
03724             /* [in] */ DISPID dispIdMember,
03725             /* [in] */ REFIID riid,
03726             /* [in] */ LCID lcid,
03727             /* [in] */ WORD wFlags,
03728             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
03729             /* [out] */ VARIANT __RPC_FAR *pVarResult,
03730             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
03731             /* [out] */ UINT __RPC_FAR *puArgErr);
03732
03733         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Properties )(
03734             ADOField __RPC_FAR * This,
03735             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
03736
03737         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_ActualSize )(
03738             ADOField __RPC_FAR * This,
03739             /* [retval][out] */ long __RPC_FAR *pl);
03740
03741         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Attributes )(
03742             ADOField __RPC_FAR * This,
03743             /* [retval][out] */ long __RPC_FAR *pl);
03744
03745         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_DefinedSize )(
03746             ADOField __RPC_FAR * This,
03747             /* [retval][out] */ long __RPC_FAR *pl);
03748
03749         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Name )(
03750             ADOField __RPC_FAR * This,
03751             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
03752
03753         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Type )(
03754             ADOField __RPC_FAR * This,
03755             /* [retval][out] */ DataTypeEnum __RPC_FAR *pDataType);
03756
03757         /* [helpstring][helpcontext][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )(
03758             ADOField __RPC_FAR * This,
03759             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03760
03761         /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )(
03762             ADOField __RPC_FAR * This,
03763             /* [in] */ VARIANT Val);
03764
03765         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Precision )(
03766             ADOField __RPC_FAR * This,
03767             /* [retval][out] */ BYTE __RPC_FAR *pbPrecision);
03768
03769         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_NumericScale )(
03770             ADOField __RPC_FAR * This,
03771             /* [retval][out] */ BYTE __RPC_FAR *pbNumericScale);
03772
03773         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AppendChunk )(
03774             ADOField __RPC_FAR * This,
03775             /* [in] */ VARIANT Data);
03776
03777         /* [helpstring][helpcontext][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetChunk )(
03778             ADOField __RPC_FAR * This,
03779             /* [in] */ long Length,
03780             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03781
03782         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_OriginalValue )(
03783             ADOField __RPC_FAR * This,
03784             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03785
03786         /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_UnderlyingValue )(
03787             ADOField __RPC_FAR * This,
03788             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03789
03790         END_INTERFACE
03791     } FieldVtbl;
03792     interface Field
03793     {
03794         CONST_VTBL struct FieldVtbl __RPC_FAR *lpVtbl;
03795     };
03796
03797 #ifdef COBJMACROS
03798 #define Field_QueryInterface(This,riid,ppvObject) \
03799     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
03800 #define Field_AddRef(This)  \
03801     (This)->lpVtbl -> AddRef(This)
03802 #define Field_Release(This) \
03803     (This)->lpVtbl -> Release(This)
03804 #define Field_GetTypeInfoCount(This,pctinfo)  \
03805     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
03806 #define Field_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
03807     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
03808 #define Field_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
03809     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
03810 #define Field_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
03811     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
03812 #define Field_get_Properties(This,ppvObject)  \
03813     (This)->lpVtbl -> get_Properties(This,ppvObject)
03814 #define Field_get_ActualSize(This,pl) \
03815     (This)->lpVtbl -> get_ActualSize(This,pl)
03816 #define Field_get_Attributes(This,pl) \
03817     (This)->lpVtbl -> get_Attributes(This,pl)
03818 #define Field_get_DefinedSize(This,pl)  \
03819     (This)->lpVtbl -> get_DefinedSize(This,pl)
03820 #define Field_get_Name(This,pbstr)  \
03821     (This)->lpVtbl -> get_Name(This,pbstr)
03822 #define Field_get_Type(This,pDataType)  \
03823     (This)->lpVtbl -> get_Type(This,pDataType)
03824 #define Field_get_Value(This,pvar)  \
03825     (This)->lpVtbl -> get_Value(This,pvar)
03826 #define Field_put_Value(This,Val) \
03827     (This)->lpVtbl -> put_Value(This,Val)
03828 #define Field_get_Precision(This,pbPrecision) \
03829     (This)->lpVtbl -> get_Precision(This,pbPrecision)
03830 #define Field_get_NumericScale(This,pbNumericScale) \
03831     (This)->lpVtbl -> get_NumericScale(This,pbNumericScale)
03832 #define Field_AppendChunk(This,Data)  \
03833     (This)->lpVtbl -> AppendChunk(This,Data)
03834 #define Field_GetChunk(This,Length,pvar)  \
03835     (This)->lpVtbl -> GetChunk(This,Length,pvar)
03836 #define Field_get_OriginalValue(This,pvar)  \
03837     (This)->lpVtbl -> get_OriginalValue(This,pvar)
03838 #define Field_get_UnderlyingValue(This,pvar)  \
03839     (This)->lpVtbl -> get_UnderlyingValue(This,pvar)
03840 #endif /* COBJMACROS */
03841 #endif  /* C style interface */
03842 /* [propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_ActualSize_Proxy(
03843     ADOField __RPC_FAR * This,
03844     /* [retval][out] */ long __RPC_FAR *pl);
03845 void __RPC_STUB Field_get_ActualSize_Stub(
03846     IRpcStubBuffer *This,
03847     IRpcChannelBuffer *_pRpcChannelBuffer,
03848     PRPC_MESSAGE _pRpcMessage,
03849     DWORD *_pdwStubPhase);
03850 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_Attributes_Proxy(
03851     ADOField __RPC_FAR * This,
03852     /* [retval][out] */ long __RPC_FAR *pl);
03853 void __RPC_STUB Field_get_Attributes_Stub(
03854     IRpcStubBuffer *This,
03855     IRpcChannelBuffer *_pRpcChannelBuffer,
03856     PRPC_MESSAGE _pRpcMessage,
03857     DWORD *_pdwStubPhase);
03858 /* [propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_DefinedSize_Proxy(
03859     ADOField __RPC_FAR * This,
03860     /* [retval][out] */ long __RPC_FAR *pl);
03861 void __RPC_STUB Field_get_DefinedSize_Stub(
03862     IRpcStubBuffer *This,
03863     IRpcChannelBuffer *_pRpcChannelBuffer,
03864     PRPC_MESSAGE _pRpcMessage,
03865     DWORD *_pdwStubPhase);
03866 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_Name_Proxy(
03867     ADOField __RPC_FAR * This,
03868     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
03869 void __RPC_STUB Field_get_Name_Stub(
03870     IRpcStubBuffer *This,
03871     IRpcChannelBuffer *_pRpcChannelBuffer,
03872     PRPC_MESSAGE _pRpcMessage,
03873     DWORD *_pdwStubPhase);
03874 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_Type_Proxy(
03875     ADOField __RPC_FAR * This,
03876     /* [retval][out] */ DataTypeEnum __RPC_FAR *pDataType);
03877 void __RPC_STUB Field_get_Type_Stub(
03878     IRpcStubBuffer *This,
03879     IRpcChannelBuffer *_pRpcChannelBuffer,
03880     PRPC_MESSAGE _pRpcMessage,
03881     DWORD *_pdwStubPhase);
03882 /* [helpstring][helpcontext][propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_Value_Proxy(
03883     ADOField __RPC_FAR * This,
03884     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03885 void __RPC_STUB Field_get_Value_Stub(
03886     IRpcStubBuffer *This,
03887     IRpcChannelBuffer *_pRpcChannelBuffer,
03888     PRPC_MESSAGE _pRpcMessage,
03889     DWORD *_pdwStubPhase);
03890 /* [propput][id] */ HRESULT STDMETHODCALLTYPE Field_put_Value_Proxy(
03891     ADOField __RPC_FAR * This,
03892     /* [in] */ VARIANT Val);
03893 void __RPC_STUB Field_put_Value_Stub(
03894     IRpcStubBuffer *This,
03895     IRpcChannelBuffer *_pRpcChannelBuffer,
03896     PRPC_MESSAGE _pRpcMessage,
03897     DWORD *_pdwStubPhase);
03898 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Field_get_Precision_Proxy(
03899     ADOField __RPC_FAR * This,
03900     /* [retval][out] */ BYTE __RPC_FAR *pbPrecision);
03901 void __RPC_STUB Field_get_Precision_Stub(
03902     IRpcStubBuffer *This,
03903     IRpcChannelBuffer *_pRpcChannelBuffer,
03904     PRPC_MESSAGE _pRpcMessage,
03905     DWORD *_pdwStubPhase);
03906 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE Field_get_NumericScale_Proxy(
03907     ADOField __RPC_FAR * This,
03908     /* [retval][out] */ BYTE __RPC_FAR *pbNumericScale);
03909 void __RPC_STUB Field_get_NumericScale_Stub(
03910     IRpcStubBuffer *This,
03911     IRpcChannelBuffer *_pRpcChannelBuffer,
03912     PRPC_MESSAGE _pRpcMessage,
03913     DWORD *_pdwStubPhase);
03914 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE Field_AppendChunk_Proxy(
03915     ADOField __RPC_FAR * This,
03916     /* [in] */ VARIANT Data);
03917 void __RPC_STUB Field_AppendChunk_Stub(
03918     IRpcStubBuffer *This,
03919     IRpcChannelBuffer *_pRpcChannelBuffer,
03920     PRPC_MESSAGE _pRpcMessage,
03921     DWORD *_pdwStubPhase);
03922 /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE Field_GetChunk_Proxy(
03923     ADOField __RPC_FAR * This,
03924     /* [in] */ long Length,
03925     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03926 void __RPC_STUB Field_GetChunk_Stub(
03927     IRpcStubBuffer *This,
03928     IRpcChannelBuffer *_pRpcChannelBuffer,
03929     PRPC_MESSAGE _pRpcMessage,
03930     DWORD *_pdwStubPhase);
03931 /* [propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_OriginalValue_Proxy(
03932     ADOField __RPC_FAR * This,
03933     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03934 void __RPC_STUB Field_get_OriginalValue_Stub(
03935     IRpcStubBuffer *This,
03936     IRpcChannelBuffer *_pRpcChannelBuffer,
03937     PRPC_MESSAGE _pRpcMessage,
03938     DWORD *_pdwStubPhase);
03939 /* [propget][id] */ HRESULT STDMETHODCALLTYPE Field_get_UnderlyingValue_Proxy(
03940     ADOField __RPC_FAR * This,
03941     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
03942 void __RPC_STUB Field_get_UnderlyingValue_Stub(
03943     IRpcStubBuffer *This,
03944     IRpcChannelBuffer *_pRpcChannelBuffer,
03945     PRPC_MESSAGE _pRpcMessage,
03946     DWORD *_pdwStubPhase);
03947 #endif  /* __Field_INTERFACE_DEFINED__ */
03948 #ifndef __Fields_INTERFACE_DEFINED__
03949 #define __Fields_INTERFACE_DEFINED__
03950 /****************************************
03951  * Generated header for interface: Fields
03952  * at Mon Jul 14 07:56:56 1997
03953  * using MIDL 3.01.75
03954  ****************************************/
03955 /* [object][uuid][helpstring][helpcontext][nonextensible][dual] */
03956 EXTERN_C const IID IID_Fields;
03957 #if defined(__cplusplus) && !defined(CINTERFACE)
03958
03959     interface DECLSPEC_UUID("00000506-0000-0010-8000-00AA006D2EA4")
03960     ADOFields : public _ADOCollection
03961     {
03962     public:
03963         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Item(
03964             /* [in] */ VARIANT Index,
03965             /* [retval][out] */ ADOField __RPC_FAR *__RPC_FAR *ppvObject) = 0;
03966
03967     };
03968
03969 #else   /* C style interface */
03970     typedef struct FieldsVtbl
03971     {
03972         BEGIN_INTERFACE
03973
03974         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
03975             ADOFields __RPC_FAR * This,
03976             /* [in] */ REFIID riid,
03977             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
03978
03979         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
03980             ADOFields __RPC_FAR * This);
03981
03982         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
03983             ADOFields __RPC_FAR * This);
03984
03985         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
03986             ADOFields __RPC_FAR * This,
03987             /* [out] */ UINT __RPC_FAR *pctinfo);
03988
03989         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
03990             ADOFields __RPC_FAR * This,
03991             /* [in] */ UINT iTInfo,
03992             /* [in] */ LCID lcid,
03993             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
03994
03995         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
03996             ADOFields __RPC_FAR * This,
03997             /* [in] */ REFIID riid,
03998             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
03999             /* [in] */ UINT cNames,
04000             /* [in] */ LCID lcid,
04001             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
04002
04003         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
04004             ADOFields __RPC_FAR * This,
04005             /* [in] */ DISPID dispIdMember,
04006             /* [in] */ REFIID riid,
04007             /* [in] */ LCID lcid,
04008             /* [in] */ WORD wFlags,
04009             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
04010             /* [out] */ VARIANT __RPC_FAR *pVarResult,
04011             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
04012             /* [out] */ UINT __RPC_FAR *puArgErr);
04013
04014         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Count )(
04015             ADOFields __RPC_FAR * This,
04016             /* [retval][out] */ long __RPC_FAR *c);
04017
04018         /* [id][restricted] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *_NewEnum )(
04019             ADOFields __RPC_FAR * This,
04020             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
04021
04022         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Refresh )(
04023             ADOFields __RPC_FAR * This);
04024
04025         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Item )(
04026             ADOFields __RPC_FAR * This,
04027             /* [in] */ VARIANT Index,
04028             /* [retval][out] */ ADOField __RPC_FAR *__RPC_FAR *ppvObject);
04029
04030         END_INTERFACE
04031     } FieldsVtbl;
04032     interface Fields
04033     {
04034         CONST_VTBL struct FieldsVtbl __RPC_FAR *lpVtbl;
04035     };
04036
04037 #ifdef COBJMACROS
04038 #define Fields_QueryInterface(This,riid,ppvObject)  \
04039     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
04040 #define Fields_AddRef(This) \
04041     (This)->lpVtbl -> AddRef(This)
04042 #define Fields_Release(This)  \
04043     (This)->lpVtbl -> Release(This)
04044 #define Fields_GetTypeInfoCount(This,pctinfo) \
04045     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
04046 #define Fields_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
04047     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
04048 #define Fields_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
04049     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
04050 #define Fields_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
04051     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
04052 #define Fields_get_Count(This,c)  \
04053     (This)->lpVtbl -> get_Count(This,c)
04054 #define Fields__NewEnum(This,ppvObject) \
04055     (This)->lpVtbl -> _NewEnum(This,ppvObject)
04056 #define Fields_Refresh(This)  \
04057     (This)->lpVtbl -> Refresh(This)
04058 #define Fields_get_Item(This,Index,ppvObject) \
04059     (This)->lpVtbl -> get_Item(This,Index,ppvObject)
04060 #endif /* COBJMACROS */
04061 #endif  /* C style interface */
04062 /* [id][propget] */ HRESULT STDMETHODCALLTYPE Fields_get_Item_Proxy(
04063     ADOFields __RPC_FAR * This,
04064     /* [in] */ VARIANT Index,
04065     /* [retval][out] */ ADOField __RPC_FAR *__RPC_FAR *ppvObject);
04066 void __RPC_STUB Fields_get_Item_Stub(
04067     IRpcStubBuffer *This,
04068     IRpcChannelBuffer *_pRpcChannelBuffer,
04069     PRPC_MESSAGE _pRpcMessage,
04070     DWORD *_pdwStubPhase);
04071 #endif  /* __Fields_INTERFACE_DEFINED__ */
04072 #ifndef ___Parameter_INTERFACE_DEFINED__
04073 #define ___Parameter_INTERFACE_DEFINED__
04074 /****************************************
04075  * Generated header for interface: _Parameter
04076  * at Mon Jul 14 07:56:56 1997
04077  * using MIDL 3.01.75
04078  ****************************************/
04079 /* [object][helpstring][helpcontext][uuid][nonextensible][dual] */
04080 EXTERN_C const IID IID__Parameter;
04081 #if defined(__cplusplus) && !defined(CINTERFACE)
04082
04083     interface DECLSPEC_UUID("0000050C-0000-0010-8000-00AA006D2EA4")
04084     _ADOParameter : public _ADO
04085     {
04086     public:
04087         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Name(
04088             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
04089
04090         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_Name(
04091             /* [in] */ BSTR bstr) = 0;
04092
04093         virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_Value(
04094             /* [retval][out] */ VARIANT __RPC_FAR *pvar) = 0;
04095
04096         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Value(
04097             /* [in] */ VARIANT val) = 0;
04098
04099         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Type(
04100             /* [retval][out] */ DataTypeEnum __RPC_FAR *psDataType) = 0;
04101
04102         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_Type(
04103             /* [in] */ DataTypeEnum sDataType) = 0;
04104
04105         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_Direction(
04106             /* [in] */ ParameterDirectionEnum lParmDirection) = 0;
04107
04108         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Direction(
04109             /* [retval][out] */ ParameterDirectionEnum __RPC_FAR *plParmDirection) = 0;
04110
04111         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_Precision(
04112             /* [in] */ BYTE bPrecision) = 0;
04113
04114         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Precision(
04115             /* [retval][out] */ BYTE __RPC_FAR *pbPrecision) = 0;
04116
04117         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_NumericScale(
04118             /* [in] */ BYTE bScale) = 0;
04119
04120         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_NumericScale(
04121             /* [retval][out] */ BYTE __RPC_FAR *pbScale) = 0;
04122
04123         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_Size(
04124             /* [in] */ long l) = 0;
04125
04126         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Size(
04127             /* [retval][out] */ long __RPC_FAR *pl) = 0;
04128
04129         virtual HRESULT STDMETHODCALLTYPE AppendChunk(
04130             /* [in] */ VARIANT Val) = 0;
04131
04132         virtual /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE get_Attributes(
04133             /* [retval][out] */ LONG __RPC_FAR *plParmAttribs) = 0;
04134
04135         virtual /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE put_Attributes(
04136             /* [in] */ LONG lParmAttribs) = 0;
04137
04138     };
04139
04140 #else   /* C style interface */
04141     typedef struct _ParameterVtbl
04142     {
04143         BEGIN_INTERFACE
04144
04145         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
04146             _ADOParameter __RPC_FAR * This,
04147             /* [in] */ REFIID riid,
04148             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
04149
04150         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
04151             _ADOParameter __RPC_FAR * This);
04152
04153         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
04154             _ADOParameter __RPC_FAR * This);
04155
04156         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
04157             _ADOParameter __RPC_FAR * This,
04158             /* [out] */ UINT __RPC_FAR *pctinfo);
04159
04160         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
04161             _ADOParameter __RPC_FAR * This,
04162             /* [in] */ UINT iTInfo,
04163             /* [in] */ LCID lcid,
04164             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
04165
04166         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
04167             _ADOParameter __RPC_FAR * This,
04168             /* [in] */ REFIID riid,
04169             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
04170             /* [in] */ UINT cNames,
04171             /* [in] */ LCID lcid,
04172             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
04173
04174         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
04175             _ADOParameter __RPC_FAR * This,
04176             /* [in] */ DISPID dispIdMember,
04177             /* [in] */ REFIID riid,
04178             /* [in] */ LCID lcid,
04179             /* [in] */ WORD wFlags,
04180             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
04181             /* [out] */ VARIANT __RPC_FAR *pVarResult,
04182             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
04183             /* [out] */ UINT __RPC_FAR *puArgErr);
04184
04185         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Properties )(
04186             _ADOParameter __RPC_FAR * This,
04187             /* [retval][out] */ ADOProperties __RPC_FAR *__RPC_FAR *ppvObject);
04188
04189         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Name )(
04190             _ADOParameter __RPC_FAR * This,
04191             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
04192
04193         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Name )(
04194             _ADOParameter __RPC_FAR * This,
04195             /* [in] */ BSTR bstr);
04196
04197         /* [helpstring][helpcontext][id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )(
04198             _ADOParameter __RPC_FAR * This,
04199             /* [retval][out] */ VARIANT __RPC_FAR *pvar);
04200
04201         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )(
04202             _ADOParameter __RPC_FAR * This,
04203             /* [in] */ VARIANT val);
04204
04205         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Type )(
04206             _ADOParameter __RPC_FAR * This,
04207             /* [retval][out] */ DataTypeEnum __RPC_FAR *psDataType);
04208
04209         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Type )(
04210             _ADOParameter __RPC_FAR * This,
04211             /* [in] */ DataTypeEnum sDataType);
04212
04213         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Direction )(
04214             _ADOParameter __RPC_FAR * This,
04215             /* [in] */ ParameterDirectionEnum lParmDirection);
04216
04217         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Direction )(
04218             _ADOParameter __RPC_FAR * This,
04219             /* [retval][out] */ ParameterDirectionEnum __RPC_FAR *plParmDirection);
04220
04221         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Precision )(
04222             _ADOParameter __RPC_FAR * This,
04223             /* [in] */ BYTE bPrecision);
04224
04225         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Precision )(
04226             _ADOParameter __RPC_FAR * This,
04227             /* [retval][out] */ BYTE __RPC_FAR *pbPrecision);
04228
04229         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_NumericScale )(
04230             _ADOParameter __RPC_FAR * This,
04231             /* [in] */ BYTE bScale);
04232
04233         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_NumericScale )(
04234             _ADOParameter __RPC_FAR * This,
04235             /* [retval][out] */ BYTE __RPC_FAR *pbScale);
04236
04237         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Size )(
04238             _ADOParameter __RPC_FAR * This,
04239             /* [in] */ long l);
04240
04241         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Size )(
04242             _ADOParameter __RPC_FAR * This,
04243             /* [retval][out] */ long __RPC_FAR *pl);
04244
04245         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AppendChunk )(
04246             _ADOParameter __RPC_FAR * This,
04247             /* [in] */ VARIANT Val);
04248
04249         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Attributes )(
04250             _ADOParameter __RPC_FAR * This,
04251             /* [retval][out] */ LONG __RPC_FAR *plParmAttribs);
04252
04253         /* [helpstring][helpcontext][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Attributes )(
04254             _ADOParameter __RPC_FAR * This,
04255             /* [in] */ LONG lParmAttribs);
04256
04257         END_INTERFACE
04258     } _ParameterVtbl;
04259     interface _Parameter
04260     {
04261         CONST_VTBL struct _ParameterVtbl __RPC_FAR *lpVtbl;
04262     };
04263
04264 #ifdef COBJMACROS
04265 #define _Parameter_QueryInterface(This,riid,ppvObject)  \
04266     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
04267 #define _Parameter_AddRef(This) \
04268     (This)->lpVtbl -> AddRef(This)
04269 #define _Parameter_Release(This)  \
04270     (This)->lpVtbl -> Release(This)
04271 #define _Parameter_GetTypeInfoCount(This,pctinfo) \
04272     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
04273 #define _Parameter_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
04274     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
04275 #define _Parameter_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
04276     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
04277 #define _Parameter_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
04278     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
04279 #define _Parameter_get_Properties(This,ppvObject) \
04280     (This)->lpVtbl -> get_Properties(This,ppvObject)
04281 #define _Parameter_get_Name(This,pbstr) \
04282     (This)->lpVtbl -> get_Name(This,pbstr)
04283 #define _Parameter_put_Name(This,bstr)  \
04284     (This)->lpVtbl -> put_Name(This,bstr)
04285 #define _Parameter_get_Value(This,pvar) \
04286     (This)->lpVtbl -> get_Value(This,pvar)
04287 #define _Parameter_put_Value(This,val)  \
04288     (This)->lpVtbl -> put_Value(This,val)
04289 #define _Parameter_get_Type(This,psDataType)  \
04290     (This)->lpVtbl -> get_Type(This,psDataType)
04291 #define _Parameter_put_Type(This,sDataType) \
04292     (This)->lpVtbl -> put_Type(This,sDataType)
04293 #define _Parameter_put_Direction(This,lParmDirection) \
04294     (This)->lpVtbl -> put_Direction(This,lParmDirection)
04295 #define _Parameter_get_Direction(This,plParmDirection)  \
04296     (This)->lpVtbl -> get_Direction(This,plParmDirection)
04297 #define _Parameter_put_Precision(This,bPrecision) \
04298     (This)->lpVtbl -> put_Precision(This,bPrecision)
04299 #define _Parameter_get_Precision(This,pbPrecision)  \
04300     (This)->lpVtbl -> get_Precision(This,pbPrecision)
04301 #define _Parameter_put_NumericScale(This,bScale)  \
04302     (This)->lpVtbl -> put_NumericScale(This,bScale)
04303 #define _Parameter_get_NumericScale(This,pbScale) \
04304     (This)->lpVtbl -> get_NumericScale(This,pbScale)
04305 #define _Parameter_put_Size(This,l) \
04306     (This)->lpVtbl -> put_Size(This,l)
04307 #define _Parameter_get_Size(This,pl)  \
04308     (This)->lpVtbl -> get_Size(This,pl)
04309 #define _Parameter_AppendChunk(This,Val)  \
04310     (This)->lpVtbl -> AppendChunk(This,Val)
04311 #define _Parameter_get_Attributes(This,plParmAttribs) \
04312     (This)->lpVtbl -> get_Attributes(This,plParmAttribs)
04313 #define _Parameter_put_Attributes(This,lParmAttribs)  \
04314     (This)->lpVtbl -> put_Attributes(This,lParmAttribs)
04315 #endif /* COBJMACROS */
04316 #endif  /* C style interface */
04317 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Name_Proxy(
04318     _ADOParameter __RPC_FAR * This,
04319     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
04320 void __RPC_STUB _Parameter_get_Name_Stub(
04321     IRpcStubBuffer *This,
04322     IRpcChannelBuffer *_pRpcChannelBuffer,
04323     PRPC_MESSAGE _pRpcMessage,
04324     DWORD *_pdwStubPhase);
04325 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Name_Proxy(
04326     _ADOParameter __RPC_FAR * This,
04327     /* [in] */ BSTR bstr);
04328 void __RPC_STUB _Parameter_put_Name_Stub(
04329     IRpcStubBuffer *This,
04330     IRpcChannelBuffer *_pRpcChannelBuffer,
04331     PRPC_MESSAGE _pRpcMessage,
04332     DWORD *_pdwStubPhase);
04333 /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Value_Proxy(
04334     _ADOParameter __RPC_FAR * This,
04335     /* [retval][out] */ VARIANT __RPC_FAR *pvar);
04336 void __RPC_STUB _Parameter_get_Value_Stub(
04337     IRpcStubBuffer *This,
04338     IRpcChannelBuffer *_pRpcChannelBuffer,
04339     PRPC_MESSAGE _pRpcMessage,
04340     DWORD *_pdwStubPhase);
04341 /* [id][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Value_Proxy(
04342     _ADOParameter __RPC_FAR * This,
04343     /* [in] */ VARIANT val);
04344 void __RPC_STUB _Parameter_put_Value_Stub(
04345     IRpcStubBuffer *This,
04346     IRpcChannelBuffer *_pRpcChannelBuffer,
04347     PRPC_MESSAGE _pRpcMessage,
04348     DWORD *_pdwStubPhase);
04349 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Type_Proxy(
04350     _ADOParameter __RPC_FAR * This,
04351     /* [retval][out] */ DataTypeEnum __RPC_FAR *psDataType);
04352 void __RPC_STUB _Parameter_get_Type_Stub(
04353     IRpcStubBuffer *This,
04354     IRpcChannelBuffer *_pRpcChannelBuffer,
04355     PRPC_MESSAGE _pRpcMessage,
04356     DWORD *_pdwStubPhase);
04357 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Type_Proxy(
04358     _ADOParameter __RPC_FAR * This,
04359     /* [in] */ DataTypeEnum sDataType);
04360 void __RPC_STUB _Parameter_put_Type_Stub(
04361     IRpcStubBuffer *This,
04362     IRpcChannelBuffer *_pRpcChannelBuffer,
04363     PRPC_MESSAGE _pRpcMessage,
04364     DWORD *_pdwStubPhase);
04365 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Direction_Proxy(
04366     _ADOParameter __RPC_FAR * This,
04367     /* [in] */ ParameterDirectionEnum lParmDirection);
04368 void __RPC_STUB _Parameter_put_Direction_Stub(
04369     IRpcStubBuffer *This,
04370     IRpcChannelBuffer *_pRpcChannelBuffer,
04371     PRPC_MESSAGE _pRpcMessage,
04372     DWORD *_pdwStubPhase);
04373 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Direction_Proxy(
04374     _ADOParameter __RPC_FAR * This,
04375     /* [retval][out] */ ParameterDirectionEnum __RPC_FAR *plParmDirection);
04376 void __RPC_STUB _Parameter_get_Direction_Stub(
04377     IRpcStubBuffer *This,
04378     IRpcChannelBuffer *_pRpcChannelBuffer,
04379     PRPC_MESSAGE _pRpcMessage,
04380     DWORD *_pdwStubPhase);
04381 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Precision_Proxy(
04382     _ADOParameter __RPC_FAR * This,
04383     /* [in] */ BYTE bPrecision);
04384 void __RPC_STUB _Parameter_put_Precision_Stub(
04385     IRpcStubBuffer *This,
04386     IRpcChannelBuffer *_pRpcChannelBuffer,
04387     PRPC_MESSAGE _pRpcMessage,
04388     DWORD *_pdwStubPhase);
04389 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Precision_Proxy(
04390     _ADOParameter __RPC_FAR * This,
04391     /* [retval][out] */ BYTE __RPC_FAR *pbPrecision);
04392 void __RPC_STUB _Parameter_get_Precision_Stub(
04393     IRpcStubBuffer *This,
04394     IRpcChannelBuffer *_pRpcChannelBuffer,
04395     PRPC_MESSAGE _pRpcMessage,
04396     DWORD *_pdwStubPhase);
04397 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_NumericScale_Proxy(
04398     _ADOParameter __RPC_FAR * This,
04399     /* [in] */ BYTE bScale);
04400 void __RPC_STUB _Parameter_put_NumericScale_Stub(
04401     IRpcStubBuffer *This,
04402     IRpcChannelBuffer *_pRpcChannelBuffer,
04403     PRPC_MESSAGE _pRpcMessage,
04404     DWORD *_pdwStubPhase);
04405 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_NumericScale_Proxy(
04406     _ADOParameter __RPC_FAR * This,
04407     /* [retval][out] */ BYTE __RPC_FAR *pbScale);
04408 void __RPC_STUB _Parameter_get_NumericScale_Stub(
04409     IRpcStubBuffer *This,
04410     IRpcChannelBuffer *_pRpcChannelBuffer,
04411     PRPC_MESSAGE _pRpcMessage,
04412     DWORD *_pdwStubPhase);
04413 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Size_Proxy(
04414     _ADOParameter __RPC_FAR * This,
04415     /* [in] */ long l);
04416 void __RPC_STUB _Parameter_put_Size_Stub(
04417     IRpcStubBuffer *This,
04418     IRpcChannelBuffer *_pRpcChannelBuffer,
04419     PRPC_MESSAGE _pRpcMessage,
04420     DWORD *_pdwStubPhase);
04421 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Size_Proxy(
04422     _ADOParameter __RPC_FAR * This,
04423     /* [retval][out] */ long __RPC_FAR *pl);
04424 void __RPC_STUB _Parameter_get_Size_Stub(
04425     IRpcStubBuffer *This,
04426     IRpcChannelBuffer *_pRpcChannelBuffer,
04427     PRPC_MESSAGE _pRpcMessage,
04428     DWORD *_pdwStubPhase);
04429 HRESULT STDMETHODCALLTYPE _Parameter_AppendChunk_Proxy(
04430     _ADOParameter __RPC_FAR * This,
04431     /* [in] */ VARIANT Val);
04432 void __RPC_STUB _Parameter_AppendChunk_Stub(
04433     IRpcStubBuffer *This,
04434     IRpcChannelBuffer *_pRpcChannelBuffer,
04435     PRPC_MESSAGE _pRpcMessage,
04436     DWORD *_pdwStubPhase);
04437 /* [helpstring][helpcontext][propget] */ HRESULT STDMETHODCALLTYPE _Parameter_get_Attributes_Proxy(
04438     _ADOParameter __RPC_FAR * This,
04439     /* [retval][out] */ LONG __RPC_FAR *plParmAttribs);
04440 void __RPC_STUB _Parameter_get_Attributes_Stub(
04441     IRpcStubBuffer *This,
04442     IRpcChannelBuffer *_pRpcChannelBuffer,
04443     PRPC_MESSAGE _pRpcMessage,
04444     DWORD *_pdwStubPhase);
04445 /* [helpstring][helpcontext][propput] */ HRESULT STDMETHODCALLTYPE _Parameter_put_Attributes_Proxy(
04446     _ADOParameter __RPC_FAR * This,
04447     /* [in] */ LONG lParmAttribs);
04448 void __RPC_STUB _Parameter_put_Attributes_Stub(
04449     IRpcStubBuffer *This,
04450     IRpcChannelBuffer *_pRpcChannelBuffer,
04451     PRPC_MESSAGE _pRpcMessage,
04452     DWORD *_pdwStubPhase);
04453 #endif  /* ___Parameter_INTERFACE_DEFINED__ */
04454 #ifdef __cplusplus
04455 EXTERN_C const CLSID CLSID_Parameter;
04456 Parameter;
04457 #endif
04458 #ifndef __Parameters_INTERFACE_DEFINED__
04459 #define __Parameters_INTERFACE_DEFINED__
04460 /****************************************
04461  * Generated header for interface: Parameters
04462  * at Mon Jul 14 07:56:56 1997
04463  * using MIDL 3.01.75
04464  ****************************************/
04465 /* [object][uuid][helpstring][helpcontext][nonextensible][dual] */
04466 EXTERN_C const IID IID_Parameters;
04467 #if defined(__cplusplus) && !defined(CINTERFACE)
04468
04469     interface DECLSPEC_UUID("0000050D-0000-0010-8000-00AA006D2EA4")
04470     ADOParameters : public _ADODynaCollection
04471     {
04472     public:
04473         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Item(
04474             /* [in] */ VARIANT Index,
04475             /* [retval][out] */ _ADOParameter __RPC_FAR *__RPC_FAR *ppvObject) = 0;
04476
04477     };
04478
04479 #else   /* C style interface */
04480     typedef struct ParametersVtbl
04481     {
04482         BEGIN_INTERFACE
04483
04484         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
04485             ADOParameters __RPC_FAR * This,
04486             /* [in] */ REFIID riid,
04487             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
04488
04489         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
04490             ADOParameters __RPC_FAR * This);
04491
04492         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
04493             ADOParameters __RPC_FAR * This);
04494
04495         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
04496             ADOParameters __RPC_FAR * This,
04497             /* [out] */ UINT __RPC_FAR *pctinfo);
04498
04499         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
04500             ADOParameters __RPC_FAR * This,
04501             /* [in] */ UINT iTInfo,
04502             /* [in] */ LCID lcid,
04503             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
04504
04505         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
04506             ADOParameters __RPC_FAR * This,
04507             /* [in] */ REFIID riid,
04508             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
04509             /* [in] */ UINT cNames,
04510             /* [in] */ LCID lcid,
04511             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
04512
04513         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
04514             ADOParameters __RPC_FAR * This,
04515             /* [in] */ DISPID dispIdMember,
04516             /* [in] */ REFIID riid,
04517             /* [in] */ LCID lcid,
04518             /* [in] */ WORD wFlags,
04519             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
04520             /* [out] */ VARIANT __RPC_FAR *pVarResult,
04521             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
04522             /* [out] */ UINT __RPC_FAR *puArgErr);
04523
04524         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Count )(
04525             ADOParameters __RPC_FAR * This,
04526             /* [retval][out] */ long __RPC_FAR *c);
04527
04528         /* [id][restricted] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *_NewEnum )(
04529             ADOParameters __RPC_FAR * This,
04530             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
04531
04532         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Refresh )(
04533             ADOParameters __RPC_FAR * This);
04534
04535         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Append )(
04536             ADOParameters __RPC_FAR * This,
04537             /* [in] */ IDispatch __RPC_FAR *Object);
04538
04539         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Delete )(
04540             ADOParameters __RPC_FAR * This,
04541             /* [in] */ VARIANT Index);
04542
04543         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Item )(
04544             ADOParameters __RPC_FAR * This,
04545             /* [in] */ VARIANT Index,
04546             /* [retval][out] */ _ADOParameter __RPC_FAR *__RPC_FAR *ppvObject);
04547
04548         END_INTERFACE
04549     } ParametersVtbl;
04550     interface Parameters
04551     {
04552         CONST_VTBL struct ParametersVtbl __RPC_FAR *lpVtbl;
04553     };
04554
04555 #ifdef COBJMACROS
04556 #define Parameters_QueryInterface(This,riid,ppvObject)  \
04557     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
04558 #define Parameters_AddRef(This) \
04559     (This)->lpVtbl -> AddRef(This)
04560 #define Parameters_Release(This)  \
04561     (This)->lpVtbl -> Release(This)
04562 #define Parameters_GetTypeInfoCount(This,pctinfo) \
04563     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
04564 #define Parameters_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
04565     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
04566 #define Parameters_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
04567     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
04568 #define Parameters_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
04569     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
04570 #define Parameters_get_Count(This,c)  \
04571     (This)->lpVtbl -> get_Count(This,c)
04572 #define Parameters__NewEnum(This,ppvObject) \
04573     (This)->lpVtbl -> _NewEnum(This,ppvObject)
04574 #define Parameters_Refresh(This)  \
04575     (This)->lpVtbl -> Refresh(This)
04576 #define Parameters_Append(This,Object)  \
04577     (This)->lpVtbl -> Append(This,Object)
04578 #define Parameters_Delete(This,Index) \
04579     (This)->lpVtbl -> Delete(This,Index)
04580 #define Parameters_get_Item(This,Index,ppvObject) \
04581     (This)->lpVtbl -> get_Item(This,Index,ppvObject)
04582 #endif /* COBJMACROS */
04583 #endif  /* C style interface */
04584 /* [id][propget] */ HRESULT STDMETHODCALLTYPE Parameters_get_Item_Proxy(
04585     ADOParameters __RPC_FAR * This,
04586     /* [in] */ VARIANT Index,
04587     /* [retval][out] */ _ADOParameter __RPC_FAR *__RPC_FAR *ppvObject);
04588 void __RPC_STUB Parameters_get_Item_Stub(
04589     IRpcStubBuffer *This,
04590     IRpcChannelBuffer *_pRpcChannelBuffer,
04591     PRPC_MESSAGE _pRpcMessage,
04592     DWORD *_pdwStubPhase);
04593 #endif  /* __Parameters_INTERFACE_DEFINED__ */
04594 #ifndef __Property_INTERFACE_DEFINED__
04595 #define __Property_INTERFACE_DEFINED__
04596 /****************************************
04597  * Generated header for interface: Property
04598  * at Mon Jul 14 07:56:56 1997
04599  * using MIDL 3.01.75
04600  ****************************************/
04601 /* [object][helpstring][helpcontext][uuid][nonextensible][dual] */
04602 EXTERN_C const IID IID_Property;
04603 #if defined(__cplusplus) && !defined(CINTERFACE)
04604
04605     interface DECLSPEC_UUID("00000503-0000-0010-8000-00AA006D2EA4")
04606     ADOProperty : public IDispatch
04607     {
04608     public:
04609         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Value(
04610             /* [retval][out] */ VARIANT __RPC_FAR *pval) = 0;
04611
04612         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Value(
04613             /* [in] */ VARIANT val) = 0;
04614
04615         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Name(
04616             /* [retval][out] */ BSTR __RPC_FAR *pbstr) = 0;
04617
04618         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Type(
04619             /* [retval][out] */ DataTypeEnum __RPC_FAR *ptype) = 0;
04620
04621         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Attributes(
04622             /* [retval][out] */ long __RPC_FAR *plAttributes) = 0;
04623
04624         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Attributes(
04625             /* [in] */ long lAttributes) = 0;
04626
04627     };
04628
04629 #else   /* C style interface */
04630     typedef struct PropertyVtbl
04631     {
04632         BEGIN_INTERFACE
04633
04634         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
04635             ADOProperty __RPC_FAR * This,
04636             /* [in] */ REFIID riid,
04637             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
04638
04639         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
04640             ADOProperty __RPC_FAR * This);
04641
04642         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
04643             ADOProperty __RPC_FAR * This);
04644
04645         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
04646             ADOProperty __RPC_FAR * This,
04647             /* [out] */ UINT __RPC_FAR *pctinfo);
04648
04649         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
04650             ADOProperty __RPC_FAR * This,
04651             /* [in] */ UINT iTInfo,
04652             /* [in] */ LCID lcid,
04653             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
04654
04655         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
04656             ADOProperty __RPC_FAR * This,
04657             /* [in] */ REFIID riid,
04658             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
04659             /* [in] */ UINT cNames,
04660             /* [in] */ LCID lcid,
04661             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
04662
04663         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
04664             ADOProperty __RPC_FAR * This,
04665             /* [in] */ DISPID dispIdMember,
04666             /* [in] */ REFIID riid,
04667             /* [in] */ LCID lcid,
04668             /* [in] */ WORD wFlags,
04669             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
04670             /* [out] */ VARIANT __RPC_FAR *pVarResult,
04671             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
04672             /* [out] */ UINT __RPC_FAR *puArgErr);
04673
04674         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )(
04675             ADOProperty __RPC_FAR * This,
04676             /* [retval][out] */ VARIANT __RPC_FAR *pval);
04677
04678         /* [id][propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )(
04679             ADOProperty __RPC_FAR * This,
04680             /* [in] */ VARIANT val);
04681
04682         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Name )(
04683             ADOProperty __RPC_FAR * This,
04684             /* [retval][out] */ BSTR __RPC_FAR *pbstr);
04685
04686         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Type )(
04687             ADOProperty __RPC_FAR * This,
04688             /* [retval][out] */ DataTypeEnum __RPC_FAR *ptype);
04689
04690         /* [propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Attributes )(
04691             ADOProperty __RPC_FAR * This,
04692             /* [retval][out] */ long __RPC_FAR *plAttributes);
04693
04694         /* [propput] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Attributes )(
04695             ADOProperty __RPC_FAR * This,
04696             /* [in] */ long lAttributes);
04697
04698         END_INTERFACE
04699     } PropertyVtbl;
04700     interface Property
04701     {
04702         CONST_VTBL struct PropertyVtbl __RPC_FAR *lpVtbl;
04703     };
04704
04705 #ifdef COBJMACROS
04706 #define Property_QueryInterface(This,riid,ppvObject)  \
04707     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
04708 #define Property_AddRef(This) \
04709     (This)->lpVtbl -> AddRef(This)
04710 #define Property_Release(This)  \
04711     (This)->lpVtbl -> Release(This)
04712 #define Property_GetTypeInfoCount(This,pctinfo) \
04713     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
04714 #define Property_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
04715     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
04716 #define Property_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
04717     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
04718 #define Property_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
04719     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
04720 #define Property_get_Value(This,pval) \
04721     (This)->lpVtbl -> get_Value(This,pval)
04722 #define Property_put_Value(This,val)  \
04723     (This)->lpVtbl -> put_Value(This,val)
04724 #define Property_get_Name(This,pbstr) \
04725     (This)->lpVtbl -> get_Name(This,pbstr)
04726 #define Property_get_Type(This,ptype) \
04727     (This)->lpVtbl -> get_Type(This,ptype)
04728 #define Property_get_Attributes(This,plAttributes)  \
04729     (This)->lpVtbl -> get_Attributes(This,plAttributes)
04730 #define Property_put_Attributes(This,lAttributes) \
04731     (This)->lpVtbl -> put_Attributes(This,lAttributes)
04732 #endif /* COBJMACROS */
04733 #endif  /* C style interface */
04734 /* [id][propget] */ HRESULT STDMETHODCALLTYPE Property_get_Value_Proxy(
04735     ADOProperty __RPC_FAR * This,
04736     /* [retval][out] */ VARIANT __RPC_FAR *pval);
04737 void __RPC_STUB Property_get_Value_Stub(
04738     IRpcStubBuffer *This,
04739     IRpcChannelBuffer *_pRpcChannelBuffer,
04740     PRPC_MESSAGE _pRpcMessage,
04741     DWORD *_pdwStubPhase);
04742 /* [id][propput] */ HRESULT STDMETHODCALLTYPE Property_put_Value_Proxy(
04743     ADOProperty __RPC_FAR * This,
04744     /* [in] */ VARIANT val);
04745 void __RPC_STUB Property_put_Value_Stub(
04746     IRpcStubBuffer *This,
04747     IRpcChannelBuffer *_pRpcChannelBuffer,
04748     PRPC_MESSAGE _pRpcMessage,
04749     DWORD *_pdwStubPhase);
04750 /* [propget] */ HRESULT STDMETHODCALLTYPE Property_get_Name_Proxy(
04751     ADOProperty __RPC_FAR * This,
04752     /* [retval][out] */ BSTR __RPC_FAR *pbstr);
04753 void __RPC_STUB Property_get_Name_Stub(
04754     IRpcStubBuffer *This,
04755     IRpcChannelBuffer *_pRpcChannelBuffer,
04756     PRPC_MESSAGE _pRpcMessage,
04757     DWORD *_pdwStubPhase);
04758 /* [propget] */ HRESULT STDMETHODCALLTYPE Property_get_Type_Proxy(
04759     ADOProperty __RPC_FAR * This,
04760     /* [retval][out] */ DataTypeEnum __RPC_FAR *ptype);
04761 void __RPC_STUB Property_get_Type_Stub(
04762     IRpcStubBuffer *This,
04763     IRpcChannelBuffer *_pRpcChannelBuffer,
04764     PRPC_MESSAGE _pRpcMessage,
04765     DWORD *_pdwStubPhase);
04766 /* [propget] */ HRESULT STDMETHODCALLTYPE Property_get_Attributes_Proxy(
04767     ADOProperty __RPC_FAR * This,
04768     /* [retval][out] */ long __RPC_FAR *plAttributes);
04769 void __RPC_STUB Property_get_Attributes_Stub(
04770     IRpcStubBuffer *This,
04771     IRpcChannelBuffer *_pRpcChannelBuffer,
04772     PRPC_MESSAGE _pRpcMessage,
04773     DWORD *_pdwStubPhase);
04774 /* [propput] */ HRESULT STDMETHODCALLTYPE Property_put_Attributes_Proxy(
04775     ADOProperty __RPC_FAR * This,
04776     /* [in] */ long lAttributes);
04777 void __RPC_STUB Property_put_Attributes_Stub(
04778     IRpcStubBuffer *This,
04779     IRpcChannelBuffer *_pRpcChannelBuffer,
04780     PRPC_MESSAGE _pRpcMessage,
04781     DWORD *_pdwStubPhase);
04782 #endif  /* __Property_INTERFACE_DEFINED__ */
04783 #ifndef __Properties_INTERFACE_DEFINED__
04784 #define __Properties_INTERFACE_DEFINED__
04785 /****************************************
04786  * Generated header for interface: Properties
04787  * at Mon Jul 14 07:56:56 1997
04788  * using MIDL 3.01.75
04789  ****************************************/
04790 /* [object][uuid][helpstring][helpcontext][nonextensible][dual] */
04791 EXTERN_C const IID IID_Properties;
04792 #if defined(__cplusplus) && !defined(CINTERFACE)
04793
04794     interface DECLSPEC_UUID("00000504-0000-0010-8000-00AA006D2EA4")
04795     ADOProperties : public _ADOCollection
04796     {
04797     public:
04798         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Item(
04799             /* [in] */ VARIANT Index,
04800             /* [retval][out] */ ADOProperty __RPC_FAR *__RPC_FAR *ppvObject) = 0;
04801
04802     };
04803
04804 #else   /* C style interface */
04805     typedef struct PropertiesVtbl
04806     {
04807         BEGIN_INTERFACE
04808
04809         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
04810             ADOProperties __RPC_FAR * This,
04811             /* [in] */ REFIID riid,
04812             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
04813
04814         ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
04815             ADOProperties __RPC_FAR * This);
04816
04817         ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
04818             ADOProperties __RPC_FAR * This);
04819
04820         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )(
04821             ADOProperties __RPC_FAR * This,
04822             /* [out] */ UINT __RPC_FAR *pctinfo);
04823
04824         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )(
04825             ADOProperties __RPC_FAR * This,
04826             /* [in] */ UINT iTInfo,
04827             /* [in] */ LCID lcid,
04828             /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
04829
04830         HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )(
04831             ADOProperties __RPC_FAR * This,
04832             /* [in] */ REFIID riid,
04833             /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
04834             /* [in] */ UINT cNames,
04835             /* [in] */ LCID lcid,
04836             /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
04837
04838         /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )(
04839             ADOProperties __RPC_FAR * This,
04840             /* [in] */ DISPID dispIdMember,
04841             /* [in] */ REFIID riid,
04842             /* [in] */ LCID lcid,
04843             /* [in] */ WORD wFlags,
04844             /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
04845             /* [out] */ VARIANT __RPC_FAR *pVarResult,
04846             /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
04847             /* [out] */ UINT __RPC_FAR *puArgErr);
04848
04849         /* [helpstring][helpcontext][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Count )(
04850             ADOProperties __RPC_FAR * This,
04851             /* [retval][out] */ long __RPC_FAR *c);
04852
04853         /* [id][restricted] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *_NewEnum )(
04854             ADOProperties __RPC_FAR * This,
04855             /* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppvObject);
04856
04857         /* [helpstring][helpcontext] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Refresh )(
04858             ADOProperties __RPC_FAR * This);
04859
04860         /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Item )(
04861             ADOProperties __RPC_FAR * This,
04862             /* [in] */ VARIANT Index,
04863             /* [retval][out] */ ADOProperty __RPC_FAR *__RPC_FAR *ppvObject);
04864
04865         END_INTERFACE
04866     } PropertiesVtbl;
04867     interface Properties
04868     {
04869         CONST_VTBL struct PropertiesVtbl __RPC_FAR *lpVtbl;
04870     };
04871
04872 #ifdef COBJMACROS
04873 #define Properties_QueryInterface(This,riid,ppvObject)  \
04874     (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
04875 #define Properties_AddRef(This) \
04876     (This)->lpVtbl -> AddRef(This)
04877 #define Properties_Release(This)  \
04878     (This)->lpVtbl -> Release(This)
04879 #define Properties_GetTypeInfoCount(This,pctinfo) \
04880     (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
04881 #define Properties_GetTypeInfo(This,iTInfo,lcid,ppTInfo)  \
04882     (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
04883 #define Properties_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)  \
04884     (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
04885 #define Properties_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)  \
04886     (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
04887 #define Properties_get_Count(This,c)  \
04888     (This)->lpVtbl -> get_Count(This,c)
04889 #define Properties__NewEnum(This,ppvObject) \
04890     (This)->lpVtbl -> _NewEnum(This,ppvObject)
04891 #define Properties_Refresh(This)  \
04892     (This)->lpVtbl -> Refresh(This)
04893 #define Properties_get_Item(This,Index,ppvObject) \
04894     (This)->lpVtbl -> get_Item(This,Index,ppvObject)
04895 #endif /* COBJMACROS */
04896 #endif  /* C style interface */
04897 /* [id][propget] */ HRESULT STDMETHODCALLTYPE Properties_get_Item_Proxy(
04898     ADOProperties __RPC_FAR * This,
04899     /* [in] */ VARIANT Index,
04900     /* [retval][out] */ ADOProperty __RPC_FAR *__RPC_FAR *ppvObject);
04901 void __RPC_STUB Properties_get_Item_Stub(
04902     IRpcStubBuffer *This,
04903     IRpcChannelBuffer *_pRpcChannelBuffer,
04904     PRPC_MESSAGE _pRpcMessage,
04905     DWORD *_pdwStubPhase);
04906 #endif  /* __Properties_INTERFACE_DEFINED__ */
04907 #endif /* __ADODB_LIBRARY_DEFINED__ */
04908 /* Additional Prototypes for ALL interfaces */
04909 /* end of Additional Prototypes */
04910 #ifdef __cplusplus
04911 }
04912 #endif
04913 #endif
04914 #define ADOCommand _ADOCommand
04915 #define ADORecordset _ADORecordset
04916 #define ADOParameter _ADOParameter
04917 #define ADOConnection _ADOConnection
04918 #define ADOCollection _ADOCollection
04919 #define ADODynaCollection _ADODynaCollection
04920
04921
04922 #endif // _ADOINT_H_
Generated on Wed Nov 13 2024 16:52:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/comp.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

comp.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENT_
00016 #define _CLASS_CCOMPONENT_
00017
00018 #include "Globals.h"
00019
00020
00021 class CComponentData;                  // References
00022
00023
00024 //---------------------------------------------------------------------------
00025 class CComponent : public IComponent2
00026 {
00027   // Construction/Destruction
00028   public:
00029     CComponent( CComponentData* pParent );
00030     ~CComponent();
00031
00032
00033     /////////////////////////////////////////////////////////////////////////
00034     // Interface IUnknown
00035     //
00036     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00037     STDMETHODIMP_(ULONG) AddRef();
00038     STDMETHODIMP_(ULONG) Release();
00039
00040     /////////////////////////////////////////////////////////////////////////
00041     // Interface IComponent2
00042     //
00043     HRESULT STDMETHODCALLTYPE Initialize
00044             ( /*[in]*/ LPCONSOLE ipConsole );
00045
00046     HRESULT STDMETHODCALLTYPE Notify
00047             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00048               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00049               /*[in]*/ LONG nArg,
00050               /*[in]*/ LONG nParam
00051             );
00052
00053     HRESULT STDMETHODCALLTYPE Destroy
00054             ( /*[in]*/ MMC_COOKIE nCookie );
00055
00056     HRESULT STDMETHODCALLTYPE QueryDataObject
00057             ( /*[in]*/  MMC_COOKIE nCookie,
00058               /*[in]*/  DATA_OBJECT_TYPES nEnumType,
00059               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00060             );
00061
00062     HRESULT STDMETHODCALLTYPE GetResultViewType
00063             ( /*[in]*/  MMC_COOKIE nCookie,
00064               /*[out]*/ LPOLESTR __RPC_FAR* ppViewType,
00065               /*[out]*/ long __RPC_FAR* pViewOptions
00066             );
00067
00068     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00069             ( /*[out][in]*/ RESULTDATAITEM __RPC_FAR* pResultDataItem );
00070
00071     HRESULT STDMETHODCALLTYPE CompareObjects
00072             ( /*[in]*/ LPDATAOBJECT lpDataObjectA,
00073               /*[in]*/ LPDATAOBJECT lpDataObjectB
00074             );
00075
00076     HRESULT STDMETHODCALLTYPE QueryDispatch
00077             ( /*[in] */  MMC_COOKIE  nCookie,
00078               /*[in] */  DATA_OBJECT_TYPES eType,
00079               /*[out]*/  LPDISPATCH* pipDispatch
00080             );
00081
00082     HRESULT STDMETHODCALLTYPE GetResultViewType2
00083             ( /*[in] */    MMC_COOKIE nCookie,
00084               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pRVTinfo
00085             );
00086
00087     HRESULT STDMETHODCALLTYPE RestoreResultView
00088             ( /*[in] */    MMC_COOKIE nCookie,
00089               /*[in,out]*/ PRESULT_VIEW_TYPE_INFO pResultViewType
00090             );
00091
00092
00093
00094   // Private data
00095   private:
00096     ULONG            m_cRef;
00097     HBITMAP          m_hImageStrip16;
00098     HBITMAP          m_hImageStrip32;
00099     IConsole3*       m_ipConsole;
00100     LPCONSOLEVERB    m_ipConsoleVerb;
00101     LPRESULTDATA2    m_ipResultData;
00102     LPHEADERCTRL2    m_ipHeaderCtrl2;
00103     CComponentData*  m_pComponentData;
00104
00105
00106   ///////////////////////////////////////////////////////////////////////////
00107   //  Handlers for notifications which are not delegated
00108   private:
00109     HRESULT  OnAddImages( LPDATAOBJECT ipDataObject, LONG nArg, LONG nParam );
00110
00111
00112   ///////////////////////////////////////////////////////////////////////////
00113   //  Public helpers
00114   public:
00115     HRESULT  GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00116
00117 };
00118
00119 #endif //_CLASS_CCOMPONENT_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/BandObjs/CommBand.h Source File

  • WinUI
  • Shell
  • BandObjs

CommBand.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1997 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          CommBand.h
00013
00014    Description:   CCommBand definitions.
00015
00016 **************************************************************************/
00017
00018 #include <windows.h>
00019 #include <shlobj.h>
00020
00021 #include "Globals.h"
00022
00023 #ifndef COMMBAND_H
00024 #define COMMBAND_H
00025
00026 #define CB_CLASS_NAME (TEXT("CommBandSampleClass"))
00027
00028 /**************************************************************************
00029
00030    CCommBand class definition
00031
00032 **************************************************************************/
00033
00034 class CCommBand : public IDeskBand,
00035                   public IInputObject,
00036                   public IObjectWithSite,
00037                   public IPersistStream
00038 {
00039 protected:
00040    DWORD m_ObjRefCount;
00041
00042 public:
00043    CCommBand();
00044    ~CCommBand();
00045
00046    //IUnknown methods
00047    STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00048    STDMETHODIMP_(DWORD) AddRef();
00049    STDMETHODIMP_(DWORD) Release();
00050
00051    //IOleWindow methods
00052    STDMETHOD (GetWindow) (HWND*);
00053    STDMETHOD (ContextSensitiveHelp) (BOOL);
00054
00055    //IDockingWindow methods
00056    STDMETHOD (ShowDW) (BOOL fShow);
00057    STDMETHOD (CloseDW) (DWORD dwReserved);
00058    STDMETHOD (ResizeBorderDW) (LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
00059
00060    //IDeskBand methods
00061    STDMETHOD (GetBandInfo) (DWORD, DWORD, DESKBANDINFO*);
00062
00063    //IInputObject methods
00064    STDMETHOD (UIActivateIO) (BOOL, LPMSG);
00065    STDMETHOD (HasFocusIO) (void);
00066    STDMETHOD (TranslateAcceleratorIO) (LPMSG);
00067
00068    //IObjectWithSite methods
00069    STDMETHOD (SetSite) (IUnknown*);
00070    STDMETHOD (GetSite) (REFIID, LPVOID*);
00071
00072    //IPersistStream methods
00073    STDMETHOD (GetClassID) (LPCLSID);
00074    STDMETHOD (IsDirty) (void);
00075    STDMETHOD (Load) (LPSTREAM);
00076    STDMETHOD (Save) (LPSTREAM, BOOL);
00077    STDMETHOD (GetSizeMax) (ULARGE_INTEGER*);
00078
00079 private:
00080   BOOL m_bFocus;
00081   HWND m_hwndParent;
00082   HWND m_hWnd;
00083   DWORD m_dwViewMode;
00084    DWORD m_dwBandID;
00085    IInputObjectSite *m_pSite;
00086
00087 private:
00088   void FocusChange(BOOL);
00089    LRESULT OnKillFocus(void);
00090   LRESULT OnSetFocus(void);
00091   static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00092   LRESULT OnPaint(void);
00093   LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
00094    BOOL RegisterAndCreateWindow(void);
00095 };
00096
00097 #endif   //COMMBAND_H
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/FullIME/Global.C Source File

  • WinUI
  • Input
  • Ime
  • FullIME

Global.C

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <imm.h>
00003 #include "FullIME.h"
00004
00005 /************************************************************************
00006 *
00007 * Global data
00008 *
00009 ************************************************************************/
00010
00011 char szSteClass[10];                // window class name
00012 char szSteCandUIClass[12];          // Candidate window class name
00013 char szSteTitle[55];                // window frame title
00014 char szSteCompTitle[ 55 ];          // window composition framw title
00015 char szSteCandTitle[ 55 ];          // window candidate frame title
00016 char szCandClass[ 20 ];             // Candidate window class name
00017 UINT  cxMetrics,                    // aver. character width
00018       cxOverTypeCaret,              // caret width for overtype mode
00019       cyMetrics;                    // character height
00020 int xPos, yPos;                     // caret position
00021 HFONT hfntFixed;                    // fixed-pitch font
00022 HFONT hfntOld;                      // default font holder
00023 BOOL  fInsertMode;                  // insert/overtype mode flag
00024 int CaretWidth;                     // insert/overtype mode caret width
00025 BYTE textbuf[MAXROW][MAXCOL];       // text buffer
00026 int DBCSFillChar;                   // 'Pattern/DBCS' fill character
00027
00028
00029 IMEUIDATA gImeUIData;               // IMEUI's global data.
00030
00031 HKL hCurKL;                         // the current keyboad layout.
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/CacheProxy/cplusplus/proxypluginimpl.cpp Source File

  • Multimedia
  • WindowsMediaServices9
  • CacheProxy
  • cplusplus

proxypluginimpl.cpp

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName:            ProxyPluginImpl.cpp
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011
00012 #include "stdafx.h"
00013
00014 #include <limits.h>
00015 #include "WMSBasicPlugin.h"
00016
00017 #include "nserror.h"
00018 #include "WMSContextNames.h"
00019 #include "ProxyPlugin.h"
00020 #include "ProxyPluginImpl.h"
00021
00022
00023 // Since the plugin supports protocol rollver, we have a hard-coded list of the
00024 // protocols which are supported.  The last entry signifies the end of the array.
00025 LPWSTR g_ProxyProtocols[] = { L"HTTP", L"RTSP", NULL };
00026
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 //
00030 // [CProxyPlugin]
00031 //
00032 /////////////////////////////////////////////////////////////////////////////
00033 CProxyPlugin::CProxyPlugin()
00034 {
00035     m_pICacheProxyServer = NULL;
00036 }
00037
00038
00039
00040 /////////////////////////////////////////////////////////////////////////////
00041 //
00042 // [~CProxyPlugin]
00043 //
00044 /////////////////////////////////////////////////////////////////////////////
00045 CProxyPlugin::~CProxyPlugin()
00046 {
00047 }
00048
00049
00050
00051 /////////////////////////////////////////////////////////////////////////////
00052 //
00053 // [InitializePlugin]
00054 //
00055 /////////////////////////////////////////////////////////////////////////////
00056 HRESULT STDMETHODCALLTYPE
00057 CProxyPlugin::InitializePlugin(
00058                         IWMSContext *pServerContext,
00059                         IWMSNamedValues *pNamedValues,
00060                         IWMSClassObject *pClassFactory
00061                         )
00062 {
00063     HRESULT hr = S_OK;
00064
00065     if( NULL == pNamedValues )
00066     {
00067         return ( E_INVALIDARG );
00068     }
00069
00070     // A pointer to the IWMSCacheProxyServer is located in the server context
00071     // passed into the plugin when it is initialized.  The plugin will need to
00072     // query for this value and store it.
00073
00074     hr = pServerContext->GetAndQueryIUnknownValue(
00075                                     WMS_SERVER_CACHE_MANAGER,
00076                                     WMS_SERVER_CACHE_MANAGER_ID,
00077                                     IID_IWMSCacheProxyServer,
00078                                     ( IUnknown ** ) &m_pICacheProxyServer,
00079                                     0 );
00080     if( ( FAILED( hr ) ) || ( NULL == m_pICacheProxyServer ) )
00081     {
00082         hr = FAILED( hr ) ? hr : E_FAIL;
00083         goto abort;
00084     }
00085
00086 abort:
00087     return( hr );
00088 }
00089
00090
00091
00092 /////////////////////////////////////////////////////////////////////////////
00093 //
00094 // [EnablePlugin]
00095 //
00096 /////////////////////////////////////////////////////////////////////////////
00097 HRESULT STDMETHODCALLTYPE
00098 CProxyPlugin::EnablePlugin( long *pdwFlags, long *pdwHeartbeatPeriod )
00099 {
00100     if( ( NULL == pdwFlags ) || ( NULL == pdwHeartbeatPeriod ) )
00101     {
00102         return( E_INVALIDARG );
00103     }
00104
00105     *pdwFlags = 0;
00106     *pdwHeartbeatPeriod = 0;
00107
00108     return( S_OK );
00109 }
00110
00111
00112
00113 /////////////////////////////////////////////////////////////////////////////
00114 //
00115 // [DisablePlugin]
00116 //
00117 /////////////////////////////////////////////////////////////////////////////
00118 HRESULT STDMETHODCALLTYPE
00119 CProxyPlugin::DisablePlugin()
00120 {
00121     return( S_OK );
00122 }
00123
00124
00125
00126 /////////////////////////////////////////////////////////////////////////////
00127 //
00128 // [ShutdownPlugin]
00129 //
00130 /////////////////////////////////////////////////////////////////////////////
00131 HRESULT STDMETHODCALLTYPE
00132 CProxyPlugin::ShutdownPlugin()
00133 {
00134     if( NULL != m_pICacheProxyServer )
00135     {
00136         m_pICacheProxyServer->Release();
00137         m_pICacheProxyServer = NULL;
00138     }
00139
00140     return( S_OK );
00141 }
00142
00143
00144
00145 /////////////////////////////////////////////////////////////////////////////
00146 //
00147 // [GetCustomAdminInterface]
00148 //
00149 /////////////////////////////////////////////////////////////////////////////
00150 HRESULT STDMETHODCALLTYPE
00151 CProxyPlugin::GetCustomAdminInterface( IDispatch **ppValue )
00152 {
00153     if( NULL == ppValue )
00154     {
00155         return( E_INVALIDARG );
00156     }
00157
00158     *ppValue = NULL;
00159     return( S_OK );
00160 }
00161
00162
00163
00164 /////////////////////////////////////////////////////////////////////////////
00165 //
00166 // [OnHeartbeat]
00167 //
00168 /////////////////////////////////////////////////////////////////////////////
00169 HRESULT STDMETHODCALLTYPE
00170 CProxyPlugin::OnHeartbeat()
00171 {
00172     return( S_OK );
00173 }
00174
00175
00176 /////////////////////////////////////////////////////////////////////////////
00177 //
00178 // [QueryCache]
00179 //
00180 /////////////////////////////////////////////////////////////////////////////
00181 HRESULT STDMETHODCALLTYPE
00182 CProxyPlugin::QueryCache( BSTR bstrOriginUrl,
00183                           IWMSContext *pUserContext,
00184                           IWMSCommandContext *pCommandContext,
00185                           IWMSContext *pPresentationContext,
00186                           long QueryType,
00187                           IWMSCacheProxyCallback *pCallback,
00188                           VARIANT varContext
00189                           )
00190 {
00191     HRESULT hr = S_OK;
00192     COpState *pOpState = NULL;
00193     LPWSTR pszHostName = NULL;
00194
00195     if( ( NULL == bstrOriginUrl) ||
00196         ( NULL == pCommandContext ) ||
00197         ( NULL == pPresentationContext ) ||
00198         ( NULL == pCallback ) )
00199     {
00200         return( E_INVALIDARG );
00201     }
00202
00203     // Since this plugin just supports proxy, we always return (in the callback)
00204     // WMS_CACHE_QUERY_MISS.  If this plugin were also to do caching, this is
00205     // where the cache database would be queried.  If a hit is made, then the
00206     // expiration of the cache entry will be checked, and if it expired a
00207     // freshness check would need to be done.  A freshness check is done
00208     // through CompareContentInformation, an async call.  Rather than waiting
00209     // for the response, the plugin should return from this method and
00210     // call the callback (OnQueryCache) in OnCompareContentInformation.
00211     //
00212     // If OnCompareContentInformation reports the cached entry is up-to-date,
00213     // a hit could be reported.  Otherwise a miss will need to be reported,
00214     // and the plugin will need to wait till QueryCacheMissPolicy.
00215
00216     hr = pCallback->OnQueryCache( hr,
00217                                   WMS_CACHE_QUERY_MISS,
00218                                   NULL,
00219                                   NULL,
00220                                   NULL,
00221                                   varContext );
00222
00223     return( S_OK );
00224 }
00225
00226
00227 /////////////////////////////////////////////////////////////////////////////
00228 //
00229 // [QueryCacheMissPolicy]
00230 //
00231 /////////////////////////////////////////////////////////////////////////////
00232 HRESULT STDMETHODCALLTYPE
00233 CProxyPlugin::QueryCacheMissPolicy( BSTR bstrOriginUrl,
00234                                     IWMSContext *pUserContext,
00235                                     IWMSCommandContext *pCommandContext,
00236                                     IWMSContext *pPresentationContext,
00237                                     IUnknown *pCachePluginContext,
00238                                     long QueryType,
00239                                     IWMSCacheProxyCallback *pCallback,
00240                                     VARIANT varContext
00241                                     )
00242 {
00243     VARIANT varContext2;
00244     COpState *pOpState = NULL;
00245     HRESULT hr = S_OK;
00246     BOOL fRet;
00247
00248     if( ( NULL == bstrOriginUrl) ||
00249         ( NULL == pCommandContext ) ||
00250         ( NULL == pPresentationContext ) ||
00251         ( NULL == pCallback ) )
00252     {
00253         return( E_INVALIDARG );
00254     }
00255
00256     if( QueryType & WMS_CACHE_QUERY_REVERSE_PROXY )
00257     {
00258         hr = pCallback->OnQueryCacheMissPolicy( S_OK,
00259                                                 WMS_CACHE_QUERY_MISS_SKIP,
00260                                                 NULL,
00261                                                 NULL,
00262                                                 NULL,
00263                                                 varContext );
00264         return( hr );
00265     }
00266
00267     if( ( QueryType & WMS_CACHE_QUERY_CACHE_EVENT ) ||
00268         ( QueryType & WMS_CACHE_QUERY_GET_CONTENT_INFO ) )
00269     {
00270         hr = pCallback->OnQueryCacheMissPolicy( S_OK,
00271                                                 WMS_CACHE_QUERY_MISS_FORWARD_REQUEST,
00272                                                 NULL,
00273                                                 NULL,
00274                                                 NULL,
00275                                                 varContext );
00276         return( hr );
00277     }
00278
00279     pOpState = new COpState;
00280     if( NULL == pOpState )
00281     {
00282         return( E_OUTOFMEMORY );
00283     }
00284
00285     pOpState->m_Op = COpState::OP_QUERY_CACHE_MISS_POLICY;
00286     pOpState->m_bstrOriginUrl = bstrOriginUrl;
00287     pOpState->m_pPresentationContext = pPresentationContext;
00288     pOpState->m_pCacheProxyCallback = pCallback;
00289     pOpState->m_varContext = varContext;
00290
00291     pOpState->m_pPresentationContext->AddRef();
00292     pOpState->m_pCacheProxyCallback->AddRef();
00293
00294     if( NULL == pOpState->m_bstrOriginUrl.m_str )
00295     {
00296         pOpState->Release();
00297         return( E_OUTOFMEMORY );
00298     }
00299
00300     fRet = ParseUrl( bstrOriginUrl,
00301                      &pOpState->m_bstrProtocol,
00302                      &pOpState->m_bstrHost,
00303                      &pOpState->m_bstrPath,
00304                      &pOpState->m_wPort );
00305
00306     if( !fRet )
00307     {
00308         pOpState->Release();
00309         return( E_FAIL );
00310     }
00311
00312     // Initiate protocol rollover by calling OnGetContentInformation with an
00313     // appropriate HRESULT
00314
00315     VariantInit( &varContext2 );
00316     V_VT( &varContext2 ) = VT_UNKNOWN;
00317     V_UNKNOWN( &varContext2 ) = (IUnknown *) pOpState;
00318
00319     pOpState->m_dwProtocolIndex = -1;
00320
00321     OnGetContentInformation( NS_E_CONNECTION_FAILURE, NULL, varContext2 );
00322
00323     return( S_OK );
00324 }
00325
00326 /////////////////////////////////////////////////////////////////////////////
00327 //
00328 // [OnGetContentInformation]
00329 //
00330 // IWMSCacheProxyServerCallback
00331 //
00332 /////////////////////////////////////////////////////////////////////////////
00333 HRESULT STDMETHODCALLTYPE
00334 CProxyPlugin::OnGetContentInformation(
00335                     long lHr,
00336                     IWMSContext *pContentInfo,
00337                     VARIANT varContext
00338                     )
00339 {
00340     HRESULT returnHr = (HRESULT) lHr;
00341     HRESULT hr = S_OK;
00342     COpState *pOpState = NULL;
00343     WMS_CACHE_QUERY_MISS_RESPONSE CacheMissPolicy = WMS_CACHE_QUERY_MISS_SKIP;
00344     IWMSDataContainerVersion *pContentVersion = NULL;
00345     CComBSTR bstrUrl;
00346     BOOL fDownload = FALSE;
00347     long lContentType = 0;
00348     DWORD dwCacheFlags;
00349     WCHAR szPort[ 20 ];
00350
00351     if( ( VT_UNKNOWN != V_VT( &varContext ) ) ||
00352         ( NULL == V_UNKNOWN( &varContext ) ) )
00353     {
00354         return( E_INVALIDARG );
00355     }
00356
00357     pOpState = ( COpState *) V_UNKNOWN( &varContext );
00358
00359     if( FAILED( returnHr ) )
00360     {
00361         if( NS_E_CONNECTION_FAILURE == returnHr )
00362         {
00363             // Do protocol rollover
00364             pOpState->m_dwProtocolIndex++;
00365
00366             if( NULL == g_ProxyProtocols[ pOpState->m_dwProtocolIndex ] )
00367             {
00368                 // we have tried all the protocols and failed
00369                 hr = E_NOINTERFACE;
00370                 goto abort;
00371             }
00372
00373             bstrUrl = g_ProxyProtocols[ pOpState->m_dwProtocolIndex ];
00374             bstrUrl.Append( L"://" );
00375             bstrUrl.Append( pOpState->m_bstrHost );
00376
00377             // if we we are using the same protocol requested by the client, then we should
00378             // also use the port specified by the client (if one was specified)
00379             if( ( 0 != pOpState->m_wPort ) &&
00380                 ( 0 == _wcsicmp( g_ProxyProtocols[ pOpState->m_dwProtocolIndex ], pOpState->m_bstrProtocol ) ) )
00381             {
00382                 bstrUrl.Append( L":" );
00383                 bstrUrl.Append( _itow( pOpState->m_wPort, szPort, 10 ) );
00384             }
00385
00386             bstrUrl.Append( L"/" );
00387             bstrUrl.Append( pOpState->m_bstrPath );
00388
00389             hr = m_pICacheProxyServer->GetContentInformation(
00390                                             bstrUrl,
00391                                             pOpState->m_pPresentationContext,
00392                                             this,
00393                                             NULL,
00394                                             (IWMSCacheProxyServerCallback *) this,
00395                                             varContext
00396                                             );
00397             if( FAILED( hr ) )
00398             {
00399                 goto abort;
00400             }
00401
00402             return( S_OK );
00403         }
00404         else if( E_ACCESSDENIED == returnHr )
00405         {
00406             // the origin server requires authentication to provide information about this content.
00407             // since we don't have the credentials, we can either proxy this stream on-demand (in
00408             // which case the player will be prompted for the credentials) or simply fail this request.
00409             // let's opt for proxying the stream.
00410             CacheMissPolicy = WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND;
00411         }
00412         else
00413         {
00414             hr = returnHr;
00415             goto abort;
00416         }
00417     }
00418     else
00419     {
00420         hr = pContentInfo->GetLongValue( WMS_CACHE_CONTENT_INFORMATION_CONTENT_TYPE,
00421                                          WMS_CACHE_CONTENT_INFORMATION_CONTENT_TYPE_ID,
00422                                          (long *) &lContentType,
00423                                          0 );
00424         if( FAILED( hr ) )
00425         {
00426             goto abort;
00427         }
00428
00429         if( WMS_CACHE_CONTENT_TYPE_BROADCAST & lContentType )
00430         {
00431             hr = pContentInfo->GetAndQueryIUnknownValue( WMS_CACHE_CONTENT_INFORMATION_DATA_CONTAINER_VERSION,
00432                                                          WMS_CACHE_CONTENT_INFORMATION_DATA_CONTAINER_VERSION_ID,
00433                                                          IID_IWMSDataContainerVersion,
00434                                                          (IUnknown **) &pContentVersion,
00435                                                          0 );
00436             if( ( FAILED( hr ) ) || ( NULL == pContentVersion ) )
00437             {
00438                 hr = FAILED( hr ) ? hr : E_UNEXPECTED;
00439                 goto abort;
00440             }
00441
00442             hr = pContentVersion->GetCacheFlags( (long *) &dwCacheFlags );
00443             if( FAILED( hr ) )
00444             {
00445                 goto abort;
00446             }
00447
00448             if( dwCacheFlags & WMS_DATA_CONTAINER_VERSION_ALLOW_STREAM_SPLITTING )
00449             {
00450                 CacheMissPolicy = WMS_CACHE_QUERY_MISS_PLAY_BROADCAST;
00451             }
00452             else
00453             {
00454                 CacheMissPolicy = WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND;
00455             }
00456         }
00457         else  // It is an on-demand publishing point
00458         {
00459             CacheMissPolicy = WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND;
00460         }
00461     }
00462
00463     hr = S_OK;
00464
00465     bstrUrl = g_ProxyProtocols[ pOpState->m_dwProtocolIndex ];
00466     bstrUrl.Append( L"://" );
00467     bstrUrl.Append( pOpState->m_bstrHost );
00468
00469     // if we we are using the same protocol requested by the client, then we should
00470     // also use the port specified by the client (if one was specified)
00471     if( ( 0 != pOpState->m_wPort ) &&
00472         ( 0 == _wcsicmp( g_ProxyProtocols[ pOpState->m_dwProtocolIndex ], pOpState->m_bstrProtocol ) ) )
00473     {
00474         bstrUrl.Append( L":" );
00475         bstrUrl.Append( _itow( pOpState->m_wPort, szPort, 10 ) );
00476     }
00477
00478     bstrUrl.Append( L"/" );
00479     bstrUrl.Append( pOpState->m_bstrPath );
00480
00481 abort:
00482     hr = pOpState->m_pCacheProxyCallback->OnQueryCacheMissPolicy( hr,
00483                                                                   CacheMissPolicy,
00484                                                                   bstrUrl,
00485                                                                   NULL,
00486                                                                   pContentInfo,
00487                                                                   pOpState->m_varContext );
00488     if( FAILED( hr ) )
00489     {
00490         hr = S_OK;
00491     }
00492
00493     if( NULL != pOpState )
00494     {
00495         pOpState->Release();
00496     }
00497
00498     if( NULL != pContentVersion )
00499     {
00500         pContentVersion->Release();
00501     }
00502
00503     return( S_OK );
00504 }
00505
00506
00507 /////////////////////////////////////////////////////////////////////////////
00508 //
00509 //
00510 //
00511 /////////////////////////////////////////////////////////////////////////////
00512 BOOL
00513 CProxyPlugin::ParseUrl( BSTR bstrUrl,
00514                         BSTR *pbstrProtocol,
00515                         BSTR *pbstrHost,
00516                         BSTR *pbstrPath,
00517                         WORD *pwPort
00518                         )
00519 {
00520     LPWSTR pszSchemeless;
00521     LPWSTR pszProtocol = L"";
00522     LPWSTR pszHost = L"";
00523     LPWSTR pszPath = L"";
00524     LPWSTR pszUrlCopy = NULL;
00525     LPWSTR pszHostEnd = NULL;;
00526     LPWSTR psz = NULL;;
00527     BOOL fRet = TRUE;
00528
00529     if( ( NULL == bstrUrl ) ||
00530         ( NULL == pbstrProtocol ) ||
00531         ( NULL == pbstrHost ) ||
00532         ( NULL == pbstrPath ) ||
00533         ( NULL == pwPort ) )
00534     {
00535         return( FALSE );
00536     }
00537
00538     *pbstrProtocol = NULL;
00539     *pbstrHost = NULL;
00540     *pbstrPath = NULL;
00541
00542     pszUrlCopy = new WCHAR[ wcslen( bstrUrl ) + 1 ];
00543     if( NULL == pszUrlCopy )
00544     {
00545         fRet = FALSE;
00546         goto done;
00547     }
00548
00549     wcscpy( pszUrlCopy, bstrUrl );
00550
00551     // skip the protocol
00552     pszSchemeless = wcsstr( pszUrlCopy, L"://" );
00553     if( NULL != pszSchemeless )
00554     {
00555         pszProtocol = pszUrlCopy;
00556         *pszSchemeless = L'\0'; // null terminate the protocol name
00557         pszSchemeless += 3;
00558     }
00559     else
00560     {
00561         pszSchemeless = pszUrlCopy;
00562
00563         // Remove any leading '/'.
00564         while ( L'/' == *pszSchemeless )
00565         {
00566             pszSchemeless++;
00567         }
00568     }
00569
00570     pszHost = pszSchemeless;
00571
00572     // find the beginning of the path
00573     psz = wcschr( pszSchemeless, L'/' );
00574     if( NULL != psz )
00575     {
00576         *psz = L'\0'; // null terminate the host name
00577         pszPath = psz + 1;
00578         pszHostEnd = psz;
00579     }
00580     else
00581     {
00582         // there is no path, only the host name
00583         pszHostEnd = pszSchemeless + wcslen( pszSchemeless );
00584     }
00585
00586     // see if a port number was specified at the end of the host name
00587     for( psz = pszHostEnd; psz > pszUrlCopy; psz-- )
00588     {
00589         if( L':' == *psz )
00590         {
00591             *psz = L'\0'; // null terminate the host name
00592             *pwPort = ( WORD ) _wtoi( psz + 1 );
00593             break;
00594         }
00595     }
00596
00597     *pbstrProtocol = SysAllocString( pszProtocol );
00598     if( NULL == *pbstrProtocol )
00599     {
00600         fRet = FALSE;
00601         goto done;
00602     }
00603
00604     *pbstrHost = SysAllocString( pszHost );
00605     if( NULL == *pbstrHost )
00606     {
00607         fRet = FALSE;
00608         goto done;
00609     }
00610
00611     *pbstrPath = SysAllocString( pszPath );
00612     if( NULL == *pbstrPath )
00613     {
00614         fRet = FALSE;
00615         goto done;
00616     }
00617
00618 done:
00619
00620     if( NULL != pszUrlCopy )
00621     {
00622         delete [] pszUrlCopy;
00623     }
00624
00625     if( !fRet )
00626     {
00627         if( NULL != *pbstrProtocol )
00628         {
00629             SysFreeString( *pbstrProtocol );
00630         }
00631
00632         if( NULL != *pbstrHost )
00633         {
00634             SysFreeString( *pbstrHost );
00635         }
00636
00637         if( NULL != *pbstrPath )
00638         {
00639             SysFreeString( *pbstrPath );
00640         }
00641     }
00642
00643     return( fRet );
00644 }
00645
00646
00647
00648
00649
00650 /////////////////////////////////////////////////////////////////////////////
00651 //
00652 // [OnCacheClientClose]
00653 //
00654 /////////////////////////////////////////////////////////////////////////////
00655 HRESULT STDMETHODCALLTYPE
00656 CProxyPlugin::OnCacheClientClose(
00657                         HRESULT resultHr,
00658                         IWMSContext *pUserContext,
00659                         IWMSContext *pPresentationContext
00660                         )
00661 {
00662     return( S_OK );
00663 } // OnCacheClientClose
00664
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_IOCTLARGS Member List

This is the complete list of members for _IOCTLARGS, including all inherited members.
cbBytesReturned | _IOCTLARGS
cbInBuffer | _IOCTLARGS
cbOutBuffer | _IOCTLARGS
dwIoControlCode | _IOCTLARGS
lpvInBuffer | _IOCTLARGS
lpvOutBuffer | _IOCTLARGS
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRefresherMember< T > Member List

This is the complete list of members for CRefresherMember< T >, including all inherited members.
CRefresherMember() | CRefresherMember< T > | [inline]
GetID() | CRefresherMember< T > | [inline]
GetMember() | CRefresherMember< T > | [inline]
m_lID | CRefresherMember< T > | [private]
m_pMember | CRefresherMember< T > | [private]
Reset() | CRefresherMember< T > | [inline]
Set(T *pMember, long lID) | CRefresherMember< T > | [inline]
~CRefresherMember() | CRefresherMember< T > | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSessionDlg Member List

This is the complete list of members for CSessionDlg, including all inherited members.
connectState | CSessionDlg | [private]
count | CSessionDlg | [private]
CSessionDlg(CWnd *pParent=NULL) | CSessionDlg |
DoDataExchange(CDataExchange *pDX) | CSessionDlg | [protected, virtual]
GetSessionID() | CSessionDlg | [private]
IDD enum value | CSessionDlg |
m_serverName | CSessionDlg |
m_sessionList | CSessionDlg |
OnCancel() | CSessionDlg | [protected, virtual]
OnDisconnectSession() | CSessionDlg | [protected]
OnInitDialog() | CSessionDlg | [protected, virtual]
OnLogoffSession() | CSessionDlg | [protected]
OnQuerySession() | CSessionDlg | [protected]
OnRefresh() | CSessionDlg | [protected]
OnSetsession() | CSessionDlg | [protected]
OnVirtualChannel() | CSessionDlg | [protected]
pSessionInfo | CSessionDlg |
Refresh() | CSessionDlg |
serverHandle | CSessionDlg | [private]
serverName | CSessionDlg | [private]
sessionID | CSessionDlg | [private]
SetSessionID() | CSessionDlg | [protected]
WinStationName | CSessionDlg | [private]
Generated on Wed Nov 13 2024 16:57:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

NewDocDlg Member List

This is the complete list of members for NewDocDlg, including all inherited members.
DoDataExchange(CDataExchange *pDX) | NewDocDlg | [protected, virtual]
IDD enum value | NewDocDlg |
m_polytype | NewDocDlg |
m_szText | NewDocDlg |
NewDocDlg(CWnd *pParent=NULL) | NewDocDlg |
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFullConnect Member List

This is the complete list of members for CFullConnect, including all inherited members.
AddPage(CPropPageLite *pCPropPageLite) | CPropSheetLite | [virtual]
AddRecentConfig(WCHAR *pwszConfigName=NULL) | CFullConnect | [virtual]
AddRecentFile(WCHAR *pwszFileName) | CFullConnect | [virtual]
BrowseEnumeratorProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CFullConnect | [static]
CFullConnect(CMainWindow *pCMainWindow) | CFullConnect |
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
CPropSheetLite(TCHAR *ptszTitle=NULL, HICON hIcon=NULL) | CPropSheetLite |
Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CreateProviderInstance(REFIID riid, IUnknown **ppIUnknown, CBase **ppCSource=NULL) | CFullConnect | [virtual]
CRowsetViewerDlg(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CRowsetViewerDlg |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
Display(HWND hWndParent, CEnumerator *pCEnumerator=NULL, ENUMINFO *pEnumInfo=NULL) | CFullConnect | [virtual]
DisplayBrowseEnumInfo(HWND hWnd) | CFullConnect | [virtual]
DoModal(HWND hWndParent, INT nStartPage=0) | CPropSheetLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
FullConnect() | CFullConnect | [virtual]
GetAdvProperties() | CFullConnect | [virtual]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetOptions() | CRowsetViewerDlg | [virtual]
GetPropSets() | CFullConnect | [virtual]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
InitPropCombo(HWND hWndCombo, ULONG cItems, const WIDENAMEMAP *rgNameMap, LPARAM lParam) | CFullConnect | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
LoadDefaults() | CFullConnect | [virtual]
LoadRecentConfig(ULONG iRecentConfig) | CFullConnect | [virtual]
LoadRecentFile(ULONG iRecentFile) | CFullConnect | [virtual]
m_bUnicodeMsg | CWndLite |
m_COptions | CFullConnect |
m_CProperties | CFullConnect |
m_CPropSets | CFullConnect |
m_CProvider | CFullConnect |
m_CSecurity | CFullConnect |
m_EnumInfo | CFullConnect |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_idSource | CFullConnect |
m_listConfigs | CFullConnect |
m_listFiles | CFullConnect |
m_nID | CWndLite |
m_pCEnumerator | CFullConnect |
m_pCMainWindow | CRowsetViewerDlg |
m_pCMDIChild | CRowsetViewerDlg |
m_psHeader | CPropSheetLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
m_wszConfigName | CFullConnect |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
RemoveRecentConfig(WCHAR *pwszConfigName) | CFullConnect | [virtual]
RemoveRecentFile(WCHAR *pwszFileName) | CFullConnect | [virtual]
ResetDefaults() | CFullConnect | [virtual]
SaveDefaults() | CFullConnect | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CFullConnect() | CFullConnect | [virtual]
~CPropSheetLite() | CPropSheetLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:56:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Extens/dataobj.h Source File

  • SysMgmt
  • MMC
  • Extens

dataobj.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPDATAOBJECT_H_
00020 #define _SAMPDATAOBJECT_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024
00025 class CDataObject : public IDataObject
00026 {
00027 private:
00028     ULONG       m_cref;
00029     MMC_COOKIE      m_lCookie;
00030     DATA_OBJECT_TYPES   m_context;
00031
00032 public:
00033     CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context);
00034     ~CDataObject();
00035
00036     ///////////////////////////////
00037     // Interface IUnknown
00038     ///////////////////////////////
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     ///////////////////////////////
00044     // IDataObject methods
00045     ///////////////////////////////
00046     STDMETHODIMP GetDataHere (FORMATETC *pformatetc, STGMEDIUM *pmedium);
00047
00048     // The rest are not implemented
00049     STDMETHODIMP GetData (LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
00050     { return E_NOTIMPL; };
00051
00052     STDMETHODIMP EnumFormatEtc (DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
00053     { return E_NOTIMPL; };
00054
00055     STDMETHODIMP QueryGetData (LPFORMATETC lpFormatetc)
00056     { return E_NOTIMPL; };
00057
00058     STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
00059     { return E_NOTIMPL; };
00060
00061     STDMETHODIMP SetData (LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
00062     { return E_NOTIMPL; };
00063
00064     STDMETHODIMP DAdvise (LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
00065     { return E_NOTIMPL; };
00066
00067     STDMETHODIMP DUnadvise (DWORD dwConnection)
00068     { return E_NOTIMPL; };
00069
00070     STDMETHODIMP EnumDAdvise (LPENUMSTATDATA* ppEnumAdvise)
00071     { return E_NOTIMPL; };
00072
00073     ///////////////////////////////
00074     // Custom Methods
00075     ///////////////////////////////
00076
00077     CDelegationBase *GetBaseNodeObject() {
00078         return (CDelegationBase *)m_lCookie;
00079     }
00080
00081     DATA_OBJECT_TYPES GetContext() {
00082         return m_context;
00083     }
00084
00085 public:
00086     // clipboard formats
00087     static UINT s_cfSZNodeType;
00088     static UINT s_cfDisplayName;
00089     static UINT s_cfNodeType;
00090     static UINT s_cfSnapinClsid;
00091     static UINT s_cfInternal;
00092
00093 };
00094
00095 HRESULT ExtractFromDataObject(IDataObject *lpDataObject,UINT cf,ULONG cb,HGLOBAL *phGlobal);
00096 CDataObject* GetOurDataObject(IDataObject *lpDataObject);
00097 BOOL IsMMCMultiSelectDataObject(IDataObject *lpDataObject);
00098
00099 #endif _SAMPDATAOBJECT_H_
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/DRAWPage.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

DRAWPage.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DRAWPAGE.H
00003
00004   Summary:   Include file for the connectable CODrawPage COM object class.
00005
00006              CODrawPage offers an implementation of a main standard
00007              IUnknown interface (basic COM object features), an
00008              implementation of the standard IConnectionPointContainer
00009              interface (connectable object features), an implementation of
00010              the standard IPersistStorage interface (storage-based
00011              persistent object features), and an implementation of the
00012              custom IDrawPage interface (free-form drawing page features).
00013
00014              For a comprehensive tutorial code tour of this module's
00015              contents and offerings see the tutorial PERDRAW.HTM file.
00016              For more specific technical details on the internal workings
00017              see the comments dispersed throughout the module's source code.
00018
00019   Functions: .
00020
00021   Classes:   CODrawPage.
00022
00023   Origin:    5-20-97: atrent - Editor-inheritance from PAPER.H in
00024              the STOSERVE Tutorial Code Sample.
00025
00026 ----------------------------------------------------------------------------
00027   This file is part of the Microsoft COM Tutorial Code Samples.
00028
00029   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00030
00031   This source code is intended only as a supplement to Microsoft
00032   Development Tools and/or on-line documentation.  See these other
00033   materials for detailed information regarding Microsoft code samples.
00034
00035   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00036   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00037   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00038   PARTICULAR PURPOSE.
00039 ==========================================================================+*/
00040
00041 #if !defined(DRAWPAGE_H)
00042 #define DRAWPAGE_H
00043
00044 #ifdef __cplusplus
00045
00046
00047 // Current format version of Ink Data is 1.0. Thus, the format version
00048 // is a compile-time constant.
00049 #define INKDATA_VERSION20 MAKELONG(0,2)
00050
00051 // InkData allocation sizes for the Dynamic InkData array.
00052 enum
00053 {
00054   INKDATA_ALLOC_INIT = 3200,
00055   INKDATA_ALLOC = 800
00056 };
00057
00058 // The types of Ink Data.
00059 #define INKTYPE_NONE  0
00060 #define INKTYPE_START 1
00061 #define INKTYPE_DRAW  2
00062 #define INKTYPE_STOP  3
00063
00064 // The Ink Data structure.
00065 typedef struct _INKDATA
00066 {
00067   SHORT nType;            // Ink Type.
00068   SHORT nX;               // X-coordinate of ink point.
00069   SHORT nY;               // Y-coordinate of ink point.
00070   SHORT nWidth;           // Ink line width.
00071   COLORREF crColor;       // Ink color.
00072 } INKDATA;
00073
00074
00075 // Properties of our electronic DrawPage.
00076 typedef struct _DRAWPROPS
00077 {
00078   LONG lInkDataVersion;
00079   LONG lInkArraySize;
00080   COLORREF crWinColor;
00081   RECT WinRect;
00082   WCHAR wszTitle[PAGE_TITLE_SIZE];
00083   WCHAR wszAuthor[PAGE_TITLE_SIZE];
00084   WCHAR wszReserved1[PAGE_TITLE_SIZE];
00085 } DRAWPROPS;
00086
00087
00088 // Drawing DrawPage event constants.
00089 enum DRAWPAGE_EVENT
00090 {
00091   DRAWPAGE_EVENT_NONE = 0,
00092   DRAWPAGE_EVENT_LOADED,
00093   DRAWPAGE_EVENT_SAVED,
00094   DRAWPAGE_EVENT_INKSTART,
00095   DRAWPAGE_EVENT_INKDRAW,
00096   DRAWPAGE_EVENT_INKSTOP,
00097   DRAWPAGE_EVENT_CLEARED,
00098   DRAWPAGE_EVENT_RESIZED
00099 };
00100
00101 // Some strings used in compound file storage.
00102
00103 // Name of the stream containing the DrawPage properties.
00104 #define WSZ_DRAWPROPS L"DRAWPROPS"
00105
00106 // Name of the stream containing the DrawPage ink data.
00107 #define WSZ_DRAWDATA L"DRAWDATA"
00108
00109 // User type name for DrawPages.
00110 #define SZ_CLIPUSERTYPE "DrawPage1.0 Drawing"
00111
00112
00113 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00114   ObjectClass: CODrawPage
00115
00116   Summary:     CODrawPage COM objects expose functionality to support
00117                drawing pages. This multiple interface COM Object Class is
00118                achieved via the technique of nested classes.  The
00119                implementation of the various interfaces are nested inside
00120                of the CODrawPage Class.
00121
00122   Interfaces:  IUnknown
00123                  Standard interface providing COM object features.
00124                IConnectionPointContainer
00125                  Standard Connection Point container features rendering
00126                  CODrawPage objects connectable objects.
00127                IPersistStorage
00128                  Standard interface providing features for object
00129                  persistence in compound file storages. Renders
00130                  CODrawPage objects persistent objects.
00131                IDrawPage
00132                  Custom interface providing free-form drawing
00133                  page features.
00134
00135   Aggregation: Yes, CODrawPage COM Objects are aggregatable by passing
00136                a non-NULL pUnkOuter IUnknown pointer into the constructor.
00137 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00138 class CODrawPage : public IUnknown
00139 {
00140   public:
00141     // Main Object Constructor & Destructor.
00142     CODrawPage(IUnknown* pUnkOuter, CServer* pServer);
00143     ~CODrawPage(void);
00144
00145     // A general public method for initializing this newly created
00146     // object. Creates any subordinate arrays, structures, or objects.
00147     // Not exposed as part of an interface. Used in Class Factory.
00148     HRESULT Init(void);
00149
00150     // IUnknown methods. Main object, non-delegating.
00151     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00152     STDMETHODIMP_(ULONG) AddRef(void);
00153     STDMETHODIMP_(ULONG) Release(void);
00154
00155   private:
00156     // We declare nested class interface implementations here.
00157
00158     class CImpIConnectionPointContainer : public IConnectionPointContainer
00159     {
00160       public:
00161         // Interface Implementation Constructor & Destructor.
00162         CImpIConnectionPointContainer(CODrawPage* pCO, IUnknown* pUnkOuter);
00163         ~CImpIConnectionPointContainer(void);
00164
00165         // IUnknown methods.
00166         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00167         STDMETHODIMP_(ULONG) AddRef(void);
00168         STDMETHODIMP_(ULONG) Release(void);
00169
00170         // IConnectionPointContainer methods.
00171         STDMETHODIMP         FindConnectionPoint(REFIID, IConnectionPoint**);
00172         STDMETHODIMP         EnumConnectionPoints(IEnumConnectionPoints**);
00173
00174       private:
00175         // Data private to this interface implementation.
00176         CODrawPage*   m_pCO;          // Parent COM Object back pointer.
00177         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00178     };
00179
00180     class CImpIPersistStorage : public IPersistStorage
00181     {
00182       public:
00183         // Interface Implementation Constructor & Destructor.
00184         CImpIPersistStorage(CODrawPage* pCO, IUnknown* pUnkOuter);
00185         ~CImpIPersistStorage(void);
00186
00187         // IUnknown methods.
00188         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00189         STDMETHODIMP_(ULONG) AddRef(void);
00190         STDMETHODIMP_(ULONG) Release(void);
00191
00192         // IPersistStorage methods.
00193         STDMETHODIMP         GetClassID(CLSID* pClassID);
00194         STDMETHODIMP         IsDirty(void);
00195         STDMETHODIMP         InitNew(IStorage* pIStorage);
00196         STDMETHODIMP         Load(IStorage* pIStorage);
00197         STDMETHODIMP         Save(IStorage* pIStorage, BOOL bSameAsLoad);
00198         STDMETHODIMP         SaveCompleted(IStorage* pIStorage);
00199         STDMETHODIMP         HandsOffStorage(void);
00200
00201       private:
00202         // Data private to this interface implementation.
00203         CODrawPage*   m_pCO;            // Parent COM Object back pointer.
00204         IUnknown*     m_pUnkOuter;      // Outer unknown for Delegation.
00205         IStorage*     m_pIStorage;      // Main DrawPage storage.
00206         IStream*      m_pIStream_Props; // Stream for Drawing Properties.
00207         IStream*      m_pIStream_Data;  // Stream for Drawing Ink Data.
00208     };
00209
00210     class CImpIDrawPage : public IDrawPage
00211     {
00212       public:
00213         // Interface Implementation Constructor & Destructor.
00214         CImpIDrawPage(CODrawPage* pCO, IUnknown* pUnkOuter);
00215         ~CImpIDrawPage(void);
00216
00217         // IUnknown methods.
00218         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00219         STDMETHODIMP_(ULONG) AddRef(void);
00220         STDMETHODIMP_(ULONG) Release(void);
00221
00222         // IDrawPage methods.
00223         STDMETHODIMP         InkStart(
00224                                SHORT nX,
00225                                SHORT nY,
00226                                SHORT nWidth,
00227                                COLORREF crInkColor);
00228         STDMETHODIMP         InkDraw(SHORT nX, SHORT nY);
00229         STDMETHODIMP         InkStop(SHORT nX, SHORT nY);
00230         STDMETHODIMP         Clear(BOOL bSaveNeeded);
00231         STDMETHODIMP         Resize(SHORT nWidth, SHORT nHeight);
00232         STDMETHODIMP         Redraw(void);
00233
00234       private:
00235         // Private utility methods of this interface implementation.
00236         HRESULT NextSlot(void);
00237
00238         // Data private to this interface implementation of IDrawPage.
00239         CODrawPage*   m_pCO;          // Parent COM Object back pointer.
00240         IUnknown*     m_pUnkOuter;    // Outer unknown for Delegation.
00241     };
00242
00243     // Make the otherwise private and nested interface implementations
00244     // friends to COM object instantiations of this CODrawPage
00245     // COM object class.
00246     friend CImpIConnectionPointContainer;
00247     friend CImpIPersistStorage;
00248     friend CImpIDrawPage;
00249
00250     // Private Methods of CODrawPage COM objects.
00251
00252     // Private method of main connectable CODrawPage COM object to
00253     // broadcast event notifications to all connected listening sinks.
00254     HRESULT NotifySinks(
00255               DRAWPAGE_EVENT DrawPageEvent,
00256               SHORT nX,
00257               SHORT nY,
00258               SHORT nInkWidth,
00259               COLORREF crInkColor);
00260
00261     // Private data of CODrawPage COM objects.
00262
00263     // Nested IConnectionPointContainer implementation instantiation.
00264     CImpIConnectionPointContainer m_ImpIConnectionPointContainer;
00265
00266     // Nested IPersistStorage implementation instantiation.
00267     CImpIPersistStorage m_ImpIPersistStorage;
00268
00269     // Nested IDrawPage implementation instantiation. Custom interface.
00270     CImpIDrawPage     m_ImpIDrawPage;
00271
00272     // Main Object reference count.
00273     ULONG             m_cRefs;
00274
00275     // Outer unknown (aggregation & delegation).
00276     IUnknown*         m_pUnkOuter;
00277
00278     // Pointer to this component server's control object.
00279     CServer*          m_pServer;
00280
00281     // The array of connection points for this connectable COM object.
00282     IConnectionPoint* m_aConnectionPoints[MAX_CONNECTION_POINTS];
00283
00284     // The following private data is the working heart of DrawPage objects.
00285     RECT              m_WinRect;        // Current window rectangle.
00286     COLORREF          m_crWinColor;     // Current window background color.
00287     COLORREF          m_crInkColor;     // Current ink color.
00288     SHORT             m_nInkWidth;      // Current ink width.
00289     LONG              m_lInkDataEnd;    // Current end of the ink data.
00290     LONG              m_lInkDataMax;    // Current max end of the ink data.
00291     INKDATA*          m_paInkData;      // Dynamic Ink data array pointer.
00292     DRAWPROPS         m_DrawProps;      // Drawing Page properties.
00293     CLSID             m_ClassID;        // CLSID of this COM Object.
00294     UINT              m_ClipFmt;        // ClipBoard format.
00295     PERSTGSTATE       m_StgState;       // Persistent Storage State.
00296     BOOL              m_bDirty;         // RAM no match file--save needed.
00297 };
00298
00299 #endif // __cplusplus
00300
00301
00302 #endif // DRAWPAGE_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/lrsample/lrsample.CXX Source File

  • WinBase
  • Indexing
  • lrsample

lrsample.CXX

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00005 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 // PARTICULAR PURPOSE.
00007 //
00008 // Copyright (c) Microsoft Corporation. All rights reserved.
00009 //
00010 // PROGRAM:  lrsample.cxx
00011 //
00012 // PURPOSE:  Sample wordbreaker and stemmer.
00013 //
00014 // PLATFORM: Windows 2000 and later
00015 //
00016 //--------------------------------------------------------------------------
00017
00018 #include <stdio.h>
00019 #include <wchar.h>
00020
00021 #include <windows.h>
00022 #include <objidl.h>
00023 #include <indexsrv.h>
00024 #include <cierror.h>
00025 #include <filterr.h>
00026
00027 #include "lrsample.hxx"
00028 #include "filtreg.hxx"
00029 #include "langreg.hxx"
00030
00031 // The CLSID for the wordbreaker
00032
00033 CLSID CLSID_SampleWordBreaker = /* d225281a-7ca9-4a46-ae7d-c63a9d4815d4 */
00034 {
00035     0xd225281a,  0x7ca9, 0x4a46,
00036     {0xae, 0x7d, 0xc6, 0x3a, 0x9d, 0x48, 0x15, 0xd4}
00037 };
00038
00039 // The CLSID of the stemmer
00040
00041 CLSID CLSID_SampleStemmer = /* 0a275611-aa4d-4b39-8290-4baf77703f55 */
00042 {
00043     0x0a275611, 0xaa4d, 0x4b39,
00044     {0x82, 0x90, 0x4b, 0xaf, 0x77, 0x70, 0x3f, 0x55}
00045 };
00046
00047 // Global module refcount
00048
00049 long g_cInstances = 0;
00050 HMODULE g_hModule = 0;
00051
00052 // This is just a simple hard-coded list of words and stem forms.
00053
00054 struct SStemForm
00055 {
00056     USHORT iList; // first index into aStems
00057     USHORT iForm; // second index into aStems
00058 };
00059
00060 const SStemForm aStemForms[] =
00061 {
00062     {  0, 0 },     // abide
00063     {  0, 2 },     // abided
00064     {  0, 4 },     // abides
00065     {  0, 3 },     // abiding
00066     {  0, 1 },     // abode
00067     {  1, 0 },     // bat
00068     {  2, 0 },     // batch
00069     {  2, 2 },     // batched
00070     {  2, 1 },     // batches
00071     {  2, 3 },     // batching
00072     {  1, 1 },     // bats
00073     {  1, 2 },     // batted
00074     {  1, 3 },     // batting
00075     {  3, 0 },     // bear
00076     {  3, 1 },     // bears
00077     {  4, 1 },     // began
00078     {  4, 0 },     // begin
00079     {  4, 3 },     // beginning
00080     {  4, 4 },     // begins
00081     {  4, 2 },     // begun
00082     {  3, 2 },     // bore
00083     {  3, 4 },     // born
00084     {  3, 3 },     // borne
00085     {  5, 0 },     // dance
00086     {  5, 1 },     // danced
00087     {  5, 2 },     // dances
00088     {  5, 3 },     // dancing
00089     {  6, 0 },     // heave
00090     {  6, 1 },     // heaved
00091     {  6, 3 },     // heaves
00092     {  6, 4 },     // heaving
00093     {  7, 0 },     // hero
00094     {  7, 1 },     // heroes
00095     {  6, 2 },     // hove
00096     {  8, 0 },     // keep
00097     {  8, 4 },     // keeping
00098     {  8, 1 },     // keeps
00099     {  8, 2 },     // kept
00100     {  9, 0 },     // misspell
00101     {  9, 1 },     // misspelled
00102     {  9, 3 },     // misspelling
00103     {  9, 4 },     // misspells
00104     {  9, 2 },     // misspelt
00105     { 10, 0 },     // plead
00106     { 10, 1 },     // pleaded
00107     { 10, 3 },     // pleading
00108     { 10, 4 },     // pleads
00109     { 10, 0 },     // pled
00110     { 11, 2 },     // ran
00111     { 11, 0 },     // run
00112     { 11, 3 },     // running
00113     { 11, 1 },     // runs
00114     { 12, 1 },     // swam
00115     { 12, 0 },     // swim
00116     { 12, 3 },     // swimming
00117     { 12, 4 },     // swims
00118     { 12, 2 },     // swum
00119     { 13, 2 },     // underlain
00120     { 13, 1 },     // underlay
00121     { 13, 0 },     // underlie
00122     { 13, 4 },     // underlies
00123     { 13, 3 },     // underlying
00124 };
00125
00126 const ULONG cStemForms = ArraySize( aStemForms );
00127 const ULONG cMaxStemForms = 8;
00128
00129 const WCHAR * aStems[][ cMaxStemForms ] =
00130 {
00131     { L"abide", L"abode", L"abided", L"abiding", L"abides" },     // 0
00132     { L"bat", L"bats", L"batted", L"batting" },                   // 1
00133     { L"batch", L"batches", L"batched", L"batching" },            // 2
00134     { L"bear", L"bears", L"bore", L"borne", L"born" },            // 3
00135     { L"begin", L"began", L"begun", L"beginning", L"begins" },    // 4
00136     { L"dance", L"danced", L"dances", L"dancing" },               // 5
00137     { L"heave", L"heaved", L"hove", L"heaves", L"heaving" },      // 6
00138     { L"hero", L"heroes" },                                       // 7
00139     { L"keep", L"keeps", L"kept", L"keeping" },                   // 8
00140     { L"misspell", L"misspelled", L"misspelt", L"misspelling",
00141       L"misspells" },                                             // 9
00142     { L"plead", L"pleaded", L"pled", L"pleading", L"pleads" },    // 10
00143     { L"run", L"runs", L"ran", L"running" },                      // 11
00144     { L"swim", L"swam", L"swum", L"swimming", L"swims" },         // 12
00145     { L"underlie", L"underlay", L"underlain", L"underlying",
00146       L"underlies" },                                             // 13
00147 };
00148
00149 int __cdecl StemCompare( const void *p1, const void *p2 )
00150 {
00151     SStemForm const * pForm = (SStemForm const *) p2;
00152     WCHAR const * pwcWord = (WCHAR const *) p1;
00153     return wcscmp( pwcWord, aStems[ pForm->iList ][ pForm->iForm ] );
00154 }
00155
00156 //+-------------------------------------------------------------------------
00157 //
00158 //  Function:   IsWordChar
00159 //
00160 //  Synopsis:   Find whether the i'th character in the buffer _pwcChunk
00161 //              is a word character (rather than word break)
00162 //
00163 //  Arguments:  [pwcChunk] -- Characters whose type information is checked
00164 //              [i]        -- Index of character to check
00165 //              [pInfo1]   -- Type 1 information
00166 //              [pInfo3]   -- Type 3 information
00167 //
00168 //  Returns:    TRUE if the character is a word character
00169 //              FALSE if it's a word breaking character
00170 //
00171 //--------------------------------------------------------------------------
00172
00173 __forceinline BOOL IsWordChar(
00174     WCHAR const * pwcChunk,
00175     int           i,
00176     WORD const *  pInfo1,
00177     WORD const *  pInfo3 )
00178 {
00179     // Any alphabetic, digit, or non-spacing character is part of a word
00180
00181     if ( ( 0 != ( pInfo1[i] & ( C1_ALPHA | C1_DIGIT ) ) ) ||
00182          ( 0 != ( pInfo3[i] & C3_NONSPACING ) ) )
00183         return TRUE;
00184
00185     WCHAR c = pwcChunk[i];
00186
00187     // Underscore is part of a word
00188
00189     if ( L'_' == c )
00190         return TRUE;
00191
00192     //
00193     // A non-breaking space followed by a non-spacing character should not
00194     // be a word breaker.
00195     //
00196
00197     if ( 0xa0 == c ) // non breaking space
00198     {
00199         // followed by a non-spacing character (looking ahead is okay)
00200
00201         if ( 0 != ( pInfo3[i+1] & C3_NONSPACING ) )
00202             return TRUE;
00203     }
00204
00205     return FALSE;
00206 } //IsWordChar
00207
00208 //+---------------------------------------------------------------------------
00209 //
00210 //  Function:   ScanChunk
00211 //
00212 //  Synopsis:   For each character find its type information flags
00213 //
00214 //  Arguments:  [pwcChunk] -- Characters whose type information is retrieved
00215 //              [cwc]      -- Number of characters to scan
00216 //              [pInfo1]   -- Type 1 information is written here
00217 //              [pInfo3]   -- Type 3 information is written here
00218 //
00219 //  Returns:    S_OK if successful or an error code
00220 //
00221 //----------------------------------------------------------------------------
00222
00223 HRESULT ScanChunk(
00224     WCHAR const * pwcChunk,
00225     ULONG         cwc,
00226     WORD *        pInfo1,
00227     WORD *        pInfo3 )
00228 {
00229     if ( !GetStringTypeW( CT_CTYPE1,         // POSIX character typing
00230                           pwcChunk,          // Source
00231                           cwc,               // Size of source
00232                           pInfo1 ) )         // Character info 1
00233         return HRESULT_FROM_WIN32( GetLastError() );
00234
00235     if ( !GetStringTypeW( CT_CTYPE3,         // Additional POSIX
00236                           pwcChunk,          // Source
00237                           cwc,               // Size of source
00238                           pInfo3 ) )         // Character info 3
00239         return HRESULT_FROM_WIN32( GetLastError() );
00240
00241     return S_OK;
00242 } //ScanChunk
00243
00244 //+---------------------------------------------------------------------------
00245 //
00246 //  Member:     CSampleWordBreaker::Tokenize
00247 //
00248 //  Synopsis:   Break a block of text into individual words
00249 //
00250 //  Arguments:  [pTextSource]  -- Source of characters to work on
00251 //              [cwc]          -- Number of characters to process
00252 //              [pWordSink]    -- Where to send the words found
00253 //              [cwcProcessed] -- Returns the # of characters tokenized
00254 //
00255 //  Returns:    S_OK if successful or an error code
00256 //
00257 //----------------------------------------------------------------------------
00258
00259 HRESULT CSampleWordBreaker::Tokenize(
00260     TEXT_SOURCE * pTextSource,
00261     ULONG         cwc,
00262     IWordSink *   pWordSink,
00263     ULONG &       cwcProcessed )
00264 {
00265     // Leave space for one (unused) lookahead
00266
00267     WORD aInfo1[ CSampleWordBreaker::cwcAtATime + 1 ];
00268     WORD aInfo3[ CSampleWordBreaker::cwcAtATime + 1 ];
00269
00270     // Initialize this so we can go 1 beyond in IsWordChar()
00271
00272     aInfo3 [ CSampleWordBreaker::cwcAtATime ] = C3_NONSPACING;
00273
00274     // Get a pointer to the text we'll be working on
00275
00276     const WCHAR * pwcChunk = &pTextSource->awcBuffer[ pTextSource->iCur ];
00277
00278     HRESULT hr = ScanChunk( pwcChunk, cwc, aInfo1, aInfo3 );
00279     if ( FAILED( hr ) )
00280         return hr;
00281
00282     BOOL fWordHasZWS = FALSE; // Does the current word have a 0-width-space?
00283     ULONG cwcZWS = 0;         // Length of word minus embedded 0-width-spaces
00284
00285     //
00286     // iBeginWord is the offset into aInfoX of the beginning character of
00287     // a word.  iCur is the first unprocessed character.
00288     // They are indexes into the current block (_pwcChunk).
00289     //
00290
00291     ULONG iBeginWord = 0;
00292     ULONG iCur = 0;
00293
00294     // Temp buffer for a word having zero-width space
00295
00296     WCHAR awcBufZWS[ CSampleWordBreaker::cwcAtATime ];
00297
00298     // Send words from the current block to word sink
00299
00300     while ( iCur < cwc )
00301     {
00302         // Skip whitespace, punctuation, etc.
00303
00304         for (; iCur < cwc; iCur++)
00305             if ( IsWordChar( pwcChunk, iCur, aInfo1, aInfo3 ) )
00306                 break;
00307
00308         // iCur points to a word char or is equal to cwc
00309
00310         iBeginWord = iCur;
00311         if ( iCur < cwc )
00312             iCur++; // we knew it pointed at word character
00313
00314         //
00315         // Find word break. Filter may output Unicode zero-width-space, which
00316         // should be ignored by the wordbreaker.
00317         //
00318
00319         fWordHasZWS = FALSE;
00320         for ( ; iCur < cwc; iCur++ )
00321         {
00322             if ( !IsWordChar( pwcChunk, iCur, aInfo1, aInfo3 ) )
00323             {
00324                 if ( ZERO_WIDTH_SPACE == pwcChunk[iCur] )
00325                     fWordHasZWS = TRUE;
00326                 else
00327                     break;
00328             }
00329         }
00330
00331         if ( fWordHasZWS )
00332         {
00333             // Copy word into awcBufZWS after stripping zero-width-spaces
00334
00335             cwcZWS = 0;
00336             for ( ULONG i = iBeginWord; i < iCur; i++ )
00337             {
00338                 if ( ZERO_WIDTH_SPACE != pwcChunk[i] )
00339                     awcBufZWS[cwcZWS++] = pwcChunk[i];
00340             }
00341         }
00342
00343         // iCur points to a non-word char or is equal to cwc
00344
00345         if ( iCur < cwc )
00346         {
00347             // store the word and its source position
00348
00349             if ( fWordHasZWS )
00350                 hr = pWordSink->PutWord( cwcZWS,
00351                                          awcBufZWS,    // stripped word
00352                                          iCur - iBeginWord,
00353                                          pTextSource->iCur + iBeginWord );
00354             else
00355                 hr = pWordSink->PutWord( iCur - iBeginWord,
00356                                          pwcChunk + iBeginWord, // the word
00357                                          iCur - iBeginWord,
00358                                          pTextSource->iCur + iBeginWord );
00359
00360             if ( FAILED( hr ) )
00361                 return hr;
00362
00363             iCur++; // we knew it pointed at non-word char
00364             iBeginWord = iCur; // in case we exit the loop now
00365         }
00366     } // next word
00367
00368     // End of words in chunk.
00369     // iCur == cwc
00370     // iBeginWord points at beginning of word or == cwc
00371
00372     if ( 0 == iBeginWord )
00373     {
00374         // A single word fills from beginning of this chunk
00375         // to the end. This is either a very long word or
00376         // a short word in a leftover buffer.
00377
00378         // store the word and its source position
00379
00380         if ( fWordHasZWS )
00381             hr = pWordSink->PutWord( cwcZWS,
00382                                      awcBufZWS,          // stripped word
00383                                      iCur,
00384                                      pTextSource->iCur ); // its source pos.
00385         else
00386             hr = pWordSink->PutWord( iCur,
00387                                      pwcChunk,           // the word
00388                                      iCur,
00389                                      pTextSource->iCur ); // its source pos.
00390
00391         if ( FAILED( hr ) )
00392             return hr;
00393
00394         // Position it to not add the word twice.
00395
00396         iBeginWord = iCur;
00397     }
00398
00399     //
00400     // If this is the last chunk from text source, then process the
00401     // last fragment.
00402     //
00403
00404     if ( ( cwc < CSampleWordBreaker::cwcAtATime ) && ( iBeginWord != iCur ) )
00405     {
00406         // store the word and its source position
00407
00408         if ( fWordHasZWS )
00409             hr = pWordSink->PutWord( cwcZWS,
00410                                      awcBufZWS,    // stripped word
00411                                      iCur - iBeginWord,
00412                                      pTextSource->iCur + iBeginWord );
00413         else
00414             hr = pWordSink->PutWord( iCur - iBeginWord,
00415                                      pwcChunk + iBeginWord,  // the word
00416                                      iCur - iBeginWord,
00417                                      pTextSource->iCur + iBeginWord );
00418
00419         if ( FAILED( hr ) )
00420             return hr;
00421
00422         iBeginWord = iCur;
00423     }
00424
00425     cwcProcessed = iBeginWord;
00426     return S_OK;
00427 } //Tokenize
00428
00429 //+---------------------------------------------------------------------------
00430 //
00431 //  Member:     CSampleWordBreaker::BreakText
00432 //
00433 //  Synopsis:   Break a block of text into individual words
00434 //
00435 //  Arguments:  [pTextSource]  -- Source of characters to work on
00436 //              [pWordSink]    -- Where to send the words found
00437 //              [pPhraseSink]  -- Where to send the phrases found (not used)
00438 //
00439 //  Returns:    S_OK if successful or an error code
00440 //
00441 //----------------------------------------------------------------------------
00442
00443 HRESULT STDMETHODCALLTYPE CSampleWordBreaker::BreakText(
00444     TEXT_SOURCE * pTextSource,
00445     IWordSink *   pWordSink,
00446     IPhraseSink * pPhraseSink )
00447 {
00448     // Validate arguments
00449
00450     if ( 0 == pTextSource )
00451         return E_INVALIDARG;
00452
00453     if ( ( 0 == pWordSink ) || ( pTextSource->iCur == pTextSource->iEnd ) )
00454         return S_OK;
00455
00456     if ( pTextSource->iCur > pTextSource->iEnd )
00457         return E_INVALIDARG;
00458
00459     ULONG cwcProcessed;   // # chars actually processed by Tokenize()
00460     HRESULT hr = S_OK;
00461
00462     // Pull text from the text source and tokenize it
00463
00464     do
00465     {
00466         BOOL fFirstTime = TRUE;
00467
00468         while ( pTextSource->iCur < pTextSource->iEnd )
00469         {
00470             ULONG cwc = pTextSource->iEnd - pTextSource->iCur;
00471
00472             // Process in buckets of cwcAtATime only
00473
00474             if ( cwc >= CSampleWordBreaker::cwcAtATime )
00475                 cwc = CSampleWordBreaker::cwcAtATime;
00476             else if ( !fFirstTime )
00477                 break;
00478
00479             hr = Tokenize( pTextSource, cwc, pWordSink, cwcProcessed );
00480             if ( FAILED( hr ) )
00481                 return hr;
00482
00483             pTextSource->iCur += cwcProcessed;
00484             fFirstTime = FALSE;
00485         }
00486
00487         hr = pTextSource->pfnFillTextBuffer( pTextSource );
00488     } while ( SUCCEEDED( hr ) );
00489
00490     //
00491     // If anything failed except for running out of text, report the error.
00492     // Otherwise, for cases like out of memory, files will not get retried or
00493     // reported as failures properly.
00494     //
00495
00496     if ( ( FAILED( hr ) ) &&
00497          ( FILTER_E_NO_MORE_VALUES != hr ) &&
00498          ( FILTER_E_NO_TEXT != hr ) &&
00499          ( FILTER_E_NO_VALUES != hr ) &&
00500          ( FILTER_E_NO_MORE_TEXT != hr ) &&
00501          ( FILTER_E_END_OF_CHUNKS != hr ) &&
00502          ( FILTER_E_EMBEDDING_UNAVAILABLE != hr ) &&
00503          ( WBREAK_E_END_OF_TEXT != hr ) )
00504         return hr;
00505
00506     ULONG cwc = pTextSource->iEnd - pTextSource->iCur;
00507
00508     if ( 0 == cwc )
00509         return S_OK;
00510
00511     return Tokenize( pTextSource, cwc, pWordSink, cwcProcessed );
00512 } //BreakText
00513
00514 //+---------------------------------------------------------------------------
00515 //
00516 //  Member:     CSampleStemmer::GenerateWordForms
00517 //
00518 //  Synopsis:   From the input word, emit the original and alternate forms
00519 //              of the word.
00520 //
00521 //  Arguments:  [pwcInBuf]   -- The original word to stem (not 0-terminated)
00522 //              [cwc]        -- Length in characters of the word
00523 //              [pStemSink]  -- Where to emit the stems
00524 //
00525 //  Returns:    S_OK if successful or an error code
00526 //
00527 //----------------------------------------------------------------------------
00528
00529 HRESULT STDMETHODCALLTYPE CSampleStemmer::GenerateWordForms(
00530     WCHAR const *   pwcInBuf,
00531     ULONG           cwc,
00532     IWordFormSink * pWordFormSink )
00533 {
00534     // Validate the arguments
00535
00536     if ( ( 0 == pwcInBuf ) || ( 0 == pWordFormSink ) )
00537         return E_INVALIDARG;
00538
00539     HRESULT hr = S_OK;
00540
00541     // Look up the word in the simple list of stem forms
00542
00543     SStemForm const * pStemForm = (SStemForm *) bsearch( pwcInBuf,
00544                                                          aStemForms,
00545                                                          cStemForms,
00546                                                          sizeof SStemForm,
00547                                                          StemCompare );
00548
00549     if ( 0 != pStemForm )
00550     {
00551         // Found it, now iterate all the forms
00552
00553         ULONG iList = pStemForm->iList;
00554         ULONG iForm = 0;
00555
00556         while ( 0 != aStems[ iList ][ iForm ] )
00557         {
00558             WCHAR const * pwc = aStems[ iList ][ iForm ];
00559
00560             // Don't emit the original word yet
00561
00562             if ( 0 != wcscmp( pwc, pwcInBuf ) )
00563             {
00564                 hr = pWordFormSink->PutAltWord( pwc,
00565                                                 (ULONG) wcslen( pwc ) );
00566                 if ( FAILED( hr ) )
00567                     return hr;
00568             }
00569
00570             iForm++;
00571         }
00572     }
00573
00574     // Emit the original word
00575
00576     return pWordFormSink->PutWord( pwcInBuf, cwc );
00577 } //StemWord
00578
00579 //+-------------------------------------------------------------------------
00580 //
00581 //  Method:     CLanguageResourceSampleCF::CLanguageResourceSampleCF
00582 //
00583 //  Synopsis:   Language resource class factory constructor
00584 //
00585 //--------------------------------------------------------------------------
00586
00587 CLanguageResourceSampleCF::CLanguageResourceSampleCF() :
00588     _lRefs( 1 )
00589 {
00590     InterlockedIncrement( &g_cInstances );
00591 } //CLanguageResourceSampleCF
00592
00593 //+-------------------------------------------------------------------------
00594 //
00595 //  Method:     CLanguageResourceSampleCF::~CLanguageResourceSampleCF
00596 //
00597 //  Synopsis:   Language resource class factory destructor
00598 //
00599 //--------------------------------------------------------------------------
00600
00601 CLanguageResourceSampleCF::~CLanguageResourceSampleCF()
00602 {
00603     InterlockedDecrement( &g_cInstances );
00604 } //~LanguageResourceSampleCF
00605
00606 //+-------------------------------------------------------------------------
00607 //
00608 //  Method:     CLanguageResourceSampleCF::QueryInterface
00609 //
00610 //  Synopsis:   Rebind to the requested interface
00611 //
00612 //  Arguments:  [riid]      -- IID of new interface
00613 //              [ppvObject] -- New interface * returned here
00614 //
00615 //  Returns:    S_OK if bind succeeded, E_NOINTERFACE if bind failed
00616 //
00617 //--------------------------------------------------------------------------
00618
00619 HRESULT STDMETHODCALLTYPE CLanguageResourceSampleCF::QueryInterface(
00620     REFIID   riid,
00621     void  ** ppvObject )
00622 {
00623     if ( 0 == ppvObject )
00624         return E_INVALIDARG;
00625
00626     if ( IID_IClassFactory == riid )
00627         *ppvObject = (IUnknown *) (IClassFactory *) this;
00628     else if ( IID_IUnknown == riid )
00629         *ppvObject = (IUnknown *) (IPersist *) this;
00630     else
00631     {
00632         *ppvObject = 0;
00633         return E_NOINTERFACE;
00634     }
00635
00636     AddRef();
00637     return S_OK;
00638 } //QueryInterface
00639
00640 //+-------------------------------------------------------------------------
00641 //
00642 //  Method:     CLanguageResourceSampleCF::AddRef
00643 //
00644 //  Synopsis:   Increments the refcount
00645 //
00646 //  Returns:    The new refcount
00647 //
00648 //--------------------------------------------------------------------------
00649
00650 ULONG STDMETHODCALLTYPE CLanguageResourceSampleCF::AddRef()
00651 {
00652     return InterlockedIncrement( &_lRefs );
00653 } //AddRef
00654
00655 //+-------------------------------------------------------------------------
00656 //
00657 //  Method:     CLanguageResourceSampleCF::Release
00658 //
00659 //  Synopsis:   Decrement refcount.  Delete self if necessary.
00660 //
00661 //  Returns:    The new refcount
00662 //
00663 //--------------------------------------------------------------------------
00664
00665 ULONG STDMETHODCALLTYPE CLanguageResourceSampleCF::Release()
00666 {
00667     long lTmp = InterlockedDecrement( &_lRefs );
00668
00669     if ( 0 == lTmp )
00670         delete this;
00671
00672     return lTmp;
00673 } //Release
00674
00675 //+-------------------------------------------------------------------------
00676 //
00677 //  Method:     CLanguageResourceSampleCF::CreateInstance
00678 //
00679 //  Synopsis:   Creates new Language Resource sample object
00680 //
00681 //  Arguments:  [pUnkOuter] -- 'Outer' IUnknown
00682 //              [riid]      -- Interface to bind
00683 //              [ppvObject] -- Interface returned here
00684 //
00685 //  Returns:    S_OK if successful or an appropriate error code
00686 //
00687 //--------------------------------------------------------------------------
00688
00689 HRESULT STDMETHODCALLTYPE CLanguageResourceSampleCF::CreateInstance(
00690     IUnknown * pUnkOuter,
00691     REFIID     riid,
00692     void * *   ppvObject )
00693 {
00694     *ppvObject = 0;
00695
00696     if ( IID_IStemmer == riid )
00697         *ppvObject = new CSampleStemmer();
00698     else if ( IID_IWordBreaker == riid )
00699         *ppvObject = new CSampleWordBreaker();
00700     else
00701         return E_NOINTERFACE;
00702
00703     if ( 0 == *ppvObject )
00704         return E_OUTOFMEMORY;
00705
00706     return S_OK;
00707 } //CreateInstance
00708
00709 //+-------------------------------------------------------------------------
00710 //
00711 //  Method:     CLanguageResourceSampleCF::LockServer
00712 //
00713 //  Synopsis:   Force class factory to remain loaded
00714 //
00715 //  Arguments:  [fLock] -- TRUE if locking, FALSE if unlocking
00716 //
00717 //  Returns:    S_OK
00718 //
00719 //--------------------------------------------------------------------------
00720
00721 HRESULT STDMETHODCALLTYPE CLanguageResourceSampleCF::LockServer( BOOL fLock )
00722 {
00723     if ( fLock )
00724         InterlockedIncrement( &g_cInstances );
00725     else
00726         InterlockedDecrement( &g_cInstances );
00727
00728     return S_OK;
00729 } //LockServer
00730
00731 //+-------------------------------------------------------------------------
00732 //
00733 //  Function:   DllGetClassObject
00734 //
00735 //  Synopsis:   Ole DLL load class routine
00736 //
00737 //  Arguments:  [cid]    -- Class to load
00738 //              [iid]    -- Interface to bind to on class object
00739 //              [ppvObj] -- Interface pointer returned here
00740 //
00741 //  Returns:    Sample language resource class factory
00742 //
00743 //--------------------------------------------------------------------------
00744
00745 extern "C" HRESULT STDMETHODCALLTYPE DllGetClassObject(
00746     REFCLSID cid,
00747     REFIID   iid,
00748     void **  ppvObj )
00749 {
00750     IUnknown * pUnk = 0;
00751     *ppvObj = 0;
00752
00753     if ( CLSID_SampleWordBreaker == cid ||
00754          CLSID_SampleStemmer == cid )
00755     {
00756         pUnk = new CLanguageResourceSampleCF();
00757
00758         if ( 0 == pUnk )
00759             return E_OUTOFMEMORY;
00760     }
00761     else
00762     {
00763         *ppvObj = 0;
00764         return E_NOINTERFACE;
00765     }
00766
00767     HRESULT hr = pUnk->QueryInterface( iid, ppvObj );
00768
00769     pUnk->Release();
00770
00771     return hr;
00772 } //DllGetClassObject
00773
00774 //+-------------------------------------------------------------------------
00775 //
00776 //  Function:   DllCanUnloadNow
00777 //
00778 //  Synopsis:   Notifies DLL to unload (cleanup global resources)
00779 //
00780 //  Returns:    S_OK if it is acceptable for caller to unload DLL.
00781 //              S_FALSE otherwise.
00782 //
00783 //--------------------------------------------------------------------------
00784
00785 extern "C" HRESULT STDMETHODCALLTYPE DllCanUnloadNow( void )
00786 {
00787     if ( 0 == g_cInstances )
00788         return S_OK;
00789
00790     return S_FALSE;
00791 } //DllCanUnloadNow
00792
00793 //+-------------------------------------------------------------------------
00794 //
00795 //  Function:   DllMain
00796 //
00797 //  Synopsis:   Standard main entrypoint for the module.
00798 //
00799 //--------------------------------------------------------------------------
00800
00801 BOOL WINAPI DllMain(
00802     HANDLE hInstance,
00803     DWORD  dwReason,
00804     void * lpReserved )
00805 {
00806     if ( DLL_PROCESS_ATTACH == dwReason )
00807     {
00808         g_hModule = (HMODULE) hInstance;
00809         DisableThreadLibraryCalls( (HINSTANCE) hInstance );
00810     }
00811
00812     return TRUE;
00813 } //DllMain
00814
00815 SLangRegistry const English_Sample_LangRes =
00816 {
00817     L"English_Sample", MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_SAMPLE ),
00818     { L"{d225281a-7ca9-4a46-ae7d-c63a9d4815d4}",
00819       L"English_Sample Word Breaker",
00820       L"lrsample.dll",
00821       L"both" },
00822     { L"{0a275611-aa4d-4b39-8290-4baf77703f55}",
00823       L"English_Sample Stemmer",
00824       L"lrsample.dll",
00825       L"both" }
00826 };
00827
00828 //+-------------------------------------------------------------------------
00829 //
00830 //  Method:     DllRegisterServer
00831 //
00832 //  Synopsis:   Registers the language resources in the registry
00833 //
00834 //--------------------------------------------------------------------------
00835
00836 STDAPI DllRegisterServer()
00837 {
00838     return RegisterALanguageResource( English_Sample_LangRes );
00839 } //DllRegisterServer
00840
00841 //+-------------------------------------------------------------------------
00842 //
00843 //  Method:     DllUnregisterServer
00844 //
00845 //  Synopsis:   Removes the language resources from the registry
00846 //
00847 //--------------------------------------------------------------------------
00848
00849 STDAPI DllUnregisterServer()
00850 {
00851     return UnRegisterALanguageResource( English_Sample_LangRes );
00852 } //DllUnregisterServer
00853
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tphys_connect_info Member List

This is the complete list of members for tphys_connect_info, including all inherited members.
connectionID | tphys_connect_info
resultCode | tphys_connect_info
Generated on Wed Nov 13 2024 16:58:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Create/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Create
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Create.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SClassEntry Member List

This is the complete list of members for SClassEntry, including all inherited members.
pwszClassId | SClassEntry
pwszClassIdDescription | SClassEntry
pwszDescription | SClassEntry
pwszExt | SClassEntry
pwszShortName | SClassEntry
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_FileInfo Member List

This is the complete list of members for _FileInfo, including all inherited members.
hFile | _FileInfo
hMapFile | _FileInfo
lpvMapView | _FileInfo
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_Job Member List

This is the complete list of members for _Job, including all inherited members.
BytesPrinted | _Job
Changed | _Job
dwStatus | _Job
JobId | _Job
PagesPrinted | _Job
pszDocument | _Job
pszOwner | _Job
pszStatus | _Job
Size | _Job
Submitted | _Job
TotalPages | _Job
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CryptoApi/CreateCert/CreateCert.h Source File

  • Security
  • CryptoApi
  • CreateCert

CreateCert.h

Go to the documentation of this file.
00001 //===================================================================
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00003 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00004 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00005 // PURPOSE.
00006 //
00007 // Copyright 1998 - 2000. Microsoft Corporation. All Right Reserved.
00008 // File: CreateCert.h
00009 //
00010 //===================================================================
00011 #ifndef __CreateCert__
00012 #define __CreateCert__
00013
00014 void PrintUsage(void);
00015 BOOL ImportCertificate(
00016          LPSTR szCertFile,
00017          LPSTR szKeyFile,
00018          LPSTR szPassword,
00019          LPSTR szStore,
00020          BOOL bUser,
00021          DWORD dwProviderNum);
00022
00023 BOOL CreateCertificate(
00024          LPSTR szX509,
00025          DWORD dwKeyType,
00026          LPSTR szSigAlg,
00027          WORD wMonths,
00028          DWORD dwCertEnhKeyUsage,
00029          BOOL bCA,
00030          BOOL bUseProv,
00031          DWORD dwProviderNum,
00032          LPSTR szSubjectStore,
00033          BOOL bSubjectUser,
00034          BOOL bSelfSigned,
00035          LPSTR szIssuerName,
00036          LPSTR szIssuerStore,
00037          BOOL bIssuerUser,
00038          BOOL bExport,
00039          LPSTR szCertFile,
00040          LPSTR szKeyFile,
00041          LPSTR szPassword);
00042
00043 PCCERT_CONTEXT FindCertificate(
00044          LPSTR szCertName,
00045          LPSTR szStore,
00046          DWORD dwFlags,
00047          PCRYPT_DATA_BLOB *KeyId,
00048          HCRYPTPROV *hProv,
00049          LPDWORD dwKeyType);
00050
00051 BOOL WINAPI MyCryptEnumProviders(
00052          DWORD dwIndex,
00053          LPDWORD Res,
00054          DWORD dwFlags,
00055          LPDWORD pdwProvType,
00056          LPTSTR szProvName,
00057          LPDWORD pcbProvName);
00058
00059 #endif
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/TextWIN.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

TextWIN.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      TEXTWIN.H
00003
00004   Summary:   Include file for the CTextWin C++ object that encapsulates
00005              the multi-line edit control that displays the edited text for
00006              a text page.
00007
00008   Classes:   CTextWin
00009
00010   Functions: none.
00011
00012   Origin:    5-25-97: atrent - Editor Inheritance from CListWin in
00013              LISTWIN.H
00014
00015 ----------------------------------------------------------------------------
00016   This file is part of the Microsoft COM Tutorial Code Samples.
00017
00018   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00019
00020   This source code is intended only as a supplement to Microsoft
00021   Development Tools and/or on-line documentation.  See these other
00022   materials for detailed information regarding Microsoft code samples.
00023
00024   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00025   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00026   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00027   PARTICULAR PURPOSE.
00028 ==========================================================================+*/
00029
00030 // Don't allow recursive includes of this file.
00031 #ifndef TEXTWIN_H
00032 #define TEXTWIN_H
00033
00034 #define MAX_TEXT_SIZE 4095
00035
00036 // TextWin command IDs.
00037 #define IDC_TEXTWIN 7100
00038
00039 #ifdef __cplusplus
00040
00041
00042 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00043   Class:    CTextWin
00044
00045   Summary:  Class for the text edit control window used for editing
00046             text pages.
00047
00048   Methods:  CTextWin
00049               Constructor.
00050             ~CTextWin
00051               Destructor.
00052             HRESULT Init(HINSTANCE hInst,HWND hWndParent,HWND* phWndEdit);
00053               Create & initialize the text edit control as child window.
00054             HRESULT GetLength(INT* piTextLength);
00055               Get length of current text content in edit control.
00056             HRESULT GetText(WCHAR* pwszText);
00057               Get the text content of the edit control.
00058             HRESULT PutText(WCHAR* pwszText, INT iTextLength);
00059               Puts text content into the text edit control.
00060             HRESULT Resize(INT nWidth, INT nHeight);
00061               Resizes the edit control to a new width and height in pixels.
00062             HRESULT Clear(void);
00063               Clears/deletes all text content in the edit control.
00064             HRESULT EditUndo(void);
00065               Tell text edit control to undo last operation.
00066             HRESULT EditSelectAll(void);
00067               Tell text edit control to select all text in it.
00068             HRESULT EditCut(void);
00069               Tell text edit control to cut selected text to clipboard.
00070             HRESULT EditCopy(void);
00071               Tell text edit control to copy selected text to clipboard.
00072             HRESULT EditPaste(void);
00073               Tell text edit control to paste clipboard contents into
00074               edit control.
00075             HRESULT EditDelete(void);
00076               Tell text edit control to delete currently selected text.
00077 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00078 class CTextWin
00079 {
00080   public:
00081     // Constructor and Destructor.
00082     CTextWin();
00083     ~CTextWin();
00084
00085     // The methods to function the text edit control window.
00086     HRESULT Init(
00087               HINSTANCE hInst,
00088               HWND hWndParent,
00089               HWND* phWndEdit);
00090     HRESULT GetLength(INT* piTextLength);
00091     HRESULT GetText(WCHAR* pwszText);
00092     HRESULT PutText(WCHAR* pwszText, INT iTextLength);
00093     HRESULT Resize(INT nWidth, INT nHeight);
00094     HRESULT Clear(void);
00095     HRESULT EditUndo(void);
00096     HRESULT EditSelectAll(void);
00097     HRESULT EditCut(void);
00098     HRESULT EditCopy(void);
00099     HRESULT EditPaste(void);
00100     HRESULT EditDelete(void);
00101
00102   private:
00103     // Private data members.
00104     HINSTANCE m_hInst;         // App Instance Handle.
00105     HWND m_hWnd;               // Handle of the edit control window.
00106     WORD m_wWidth;             // Window rect width.
00107     WORD m_wHeight;            // Window rect height.
00108 };
00109
00110
00111 #endif //__cplusplus
00112
00113 #endif //TEXTWIN_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/IPRoute/IPRoute.h Source File

  • NetDS
  • IPHelp
  • IPRoute

IPRoute.h

Go to the documentation of this file.
00001 #ifndef _IPROUTE_H
00002 #define _IPROUTE_H
00003
00004 #include <windows.h>
00005 #include <winsock.h>
00006 #include <iphlpapi.h>
00007 #include <assert.h>
00008 #include <stdlib.h>
00009 #include <malloc.h>
00010 #include <stdio.h>
00011 #include <string.h>
00012 #include <limits.h>
00013 #include <iptypes.h>
00014
00015 void DoGetIpForwardTable();
00016 void DoSetIpForwardEntry(char* pszDest, char* pszNetMask, char* pszGateway, char* pszInterface, DWORD dwMetric = 1);
00017 void DoDeleteIpForwardEntry(char* pszDest);
00018 bool InterfaceIdxToInterfaceIp(PMIB_IPADDRTABLE pIpAddrTable, DWORD dwIndex, char str[]);
00019 bool InterfaceIpToIdxAndMask(PMIB_IPADDRTABLE pIpAddrTable, char str[], DWORD& dwIndex, DWORD& dwMask);
00020 DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE& pIpAddrTable, BOOL fOrder = FALSE);
00021 DWORD MyGetIpForwardTable(PMIB_IPFORWARDTABLE& pIpRouteTab, BOOL fOrder = FALSE);
00022 void PrintIpForwardTable(PMIB_IPFORWARDTABLE pIpRouteTable);
00023 #endif
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/cMemb.Cpp Source File

  • Web
  • NetMeeting
  • NMUI

cMemb.Cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMUI.EXE
00003 //  File:       CMEMB.CPP
00004 //  Content:    INmMember Routines
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1995-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016
00017 COBLIST * g_pListUser = NULL  ;
00018 UINT    gcUsers   = 0   ;
00019
00020
00021 //****************************************************************************
00022 //
00023 // PUSER PUserFromINmMember(INmMember * pMember)
00024 //
00025 //****************************************************************************
00026
00027 PUSER PUserFromINmMember(INmMember * pMember)
00028 {
00029   if (NULL != g_pListUser)
00030   {
00031     POSITION pos = g_pListUser->GetHeadPosition();
00032     while (NULL != pos)
00033     {
00034       PUSER pUser = (PUSER) g_pListUser->GetNext(pos);
00035       if  (NULL == pUser)
00036       {
00037         ERROR_MSG(TEXT("PUserFromINmMember: NULL == pUser"));
00038         break;
00039       }
00040
00041       if (pMember == pUser->pMember)
00042         return pUser;
00043     }
00044   }
00045
00046   return NULL;
00047 }
00048
00049
00050 //****************************************************************************
00051 //
00052 // int ItemFromPUser(PUSER pUser)
00053 //
00054 //****************************************************************************
00055
00056 int ItemFromPUser(PUSER pUser)
00057 {
00058   if (NULL == ghwndLView)
00059     return -1;
00060
00061   LV_FINDINFO findInfo;
00062   ZeroMemory(&findInfo, sizeof(findInfo));
00063   findInfo.flags = LVFI_PARAM;
00064     findInfo.lParam = (LPARAM) pUser;
00065     return ListView_FindItem(ghwndLView, -1, &findInfo);
00066 }
00067
00068
00069 //****************************************************************************
00070 //
00071 // PUSER PUserLocal()
00072 //
00073 // Return a pointer to the local user information
00074 //
00075 //****************************************************************************
00076
00077 PUSER PUserLocal()
00078 {
00079   if (NULL != g_pListUser)
00080   {
00081     POSITION pos = g_pListUser->GetHeadPosition();
00082     while (NULL != pos)
00083     {
00084       PUSER pUser = (PUSER) g_pListUser->GetNext(pos);
00085       if  (NULL == pUser)
00086       {
00087         ERROR_MSG(TEXT("PUserLocal: NULL == pUser"));
00088         break;
00089       }
00090
00091       if (pUser->fLocal)
00092         return pUser;
00093     }
00094   }
00095
00096   return NULL;
00097 }
00098
00099 //****************************************************************************
00100 //
00101 // VOID UpdateUserDisplay(PUSER pUser)
00102 //
00103 //****************************************************************************
00104
00105 VOID UpdateUserDisplay(PUSER pUser)
00106 {
00107   if  (NULL == pUser)
00108   {
00109     ERROR_MSG(TEXT("UpdateUserDisplay: NULL == pUser"));
00110     return;
00111   }
00112
00113   int iItem = ItemFromPUser(pUser);
00114   TCHAR sz[MAX_PATH + 1];
00115   ZeroMemory(sz, (MAX_PATH + 1) * sizeof(TCHAR));
00116
00117   ASSERT(NULL != ghwndLView);
00118
00119   _sntprintf(sz, MAX_PATH, TEXT("%d\0"), pUser->uVersion);
00120   ListView_SetItemText(ghwndLView, iItem, ILV_VERSION, sz);
00121
00122   _sntprintf(sz, MAX_PATH, TEXT("%d\0"), pUser->fMcu);
00123   ListView_SetItemText(ghwndLView, iItem, ILV_MCU, sz);
00124
00125   _sntprintf(sz, MAX_PATH, TEXT("%d\0"), pUser->fLocal);
00126   ListView_SetItemText(ghwndLView, iItem, ILV_LOCAL, sz);
00127
00128   _sntprintf(sz, MAX_PATH, TEXT("%X\0"), pUser->m_pChannelAudio);
00129   ListView_SetItemText(ghwndLView, iItem, ILV_AUDIO, sz);
00130
00131   _sntprintf(sz, MAX_PATH, TEXT("%X\0"), pUser->m_pChannelAs);
00132   ListView_SetItemText(ghwndLView, iItem, ILV_AS, sz);
00133
00134   _sntprintf(sz, MAX_PATH, TEXT("%X\0"), pUser->m_pChannelFt);
00135   ListView_SetItemText(ghwndLView, iItem, ILV_FT, sz);
00136
00137   _sntprintf(sz, MAX_PATH, TEXT("%08X\0"), pUser->uchCaps);
00138   ListView_SetItemText(ghwndLView, iItem, ILV_CAPS, sz);
00139
00140   ListView_SetItemText(ghwndLView, iItem, ILV_ADDR,
00141     (NULL == pUser->pszAddr) ? TEXT("?") : pUser->pszAddr);
00142
00143   _sntprintf(sz, MAX_PATH, TEXT("%08X\0"), pUser->uId);
00144   ListView_SetItemText(ghwndLView, iItem, ILV_ID, sz);
00145
00146 }
00147
00148 //****************************************************************************
00149 //
00150 // VOID UpdateUserCount(void)
00151 //
00152 //****************************************************************************
00153
00154 VOID UpdateUserCount(void)
00155 {
00156   TCHAR sz[MAX_PATH + 1];
00157   ZeroMemory(sz, (MAX_PATH + 1) * sizeof(TCHAR));
00158
00159   if (1 == gcUsers)
00160   {
00161     lstrcpyn(sz, TEXT("1 user\0"), MAX_PATH+1);
00162     sz[MAX_PATH] = 0;
00163   }
00164   else
00165     _sntprintf(sz, MAX_PATH, TEXT("%d users\0"), gcUsers);
00166
00167   UpdateStatusBar(sz, IDSBP_USERCOUNT, 0);
00168 }
00169
00170
00171 //****************************************************************************
00172 //
00173 // PUSER AllocUser(INmMember * pMember)
00174 //
00175 //****************************************************************************
00176
00177 PUSER AllocUser(INmMember * pMember)
00178 {
00179   if  (NULL == pMember)
00180   {
00181     ERROR_MSG(TEXT("AllocUser: NULL == pMember"));
00182     return NULL;
00183   }
00184
00185   HRESULT     hr      = NO_ERROR;
00186   BSTR      bstr    = NULL;
00187   INmConference * pConference = NULL;
00188
00189   PUSER pUser = new USER;
00190   if (NULL == pUser)
00191   {
00192     return NULL;
00193   }
00194
00195   ZeroMemory(pUser, sizeof(USER));
00196
00197   pUser->pMember = pMember;
00198   pMember->AddRef();
00199
00200   hr = pMember->GetName(&bstr);
00201   if (FAILED(hr))
00202   {
00203     WARN_MSG(TEXT("Problem with GetName"));
00204   }
00205   else
00206   {
00207     pUser->pszName = PszFromBstr(bstr);
00208     SysFreeString(bstr);
00209   }
00210
00211   hr = pMember->GetAddr(&bstr, &pUser->uType);
00212   if (FAILED(hr))
00213   {
00214     WARN_MSG(TEXT("Problem with GetAddr"));
00215   }
00216   else
00217   {
00218     pUser->pszAddr = PszFromBstr(bstr);
00219     SysFreeString(bstr);
00220   }
00221
00222   hr = pMember->GetNmchCaps(&pUser->uchCaps);
00223   if (FAILED(hr))
00224   {
00225     WARN_MSG(TEXT("Problem with GetNmchCaps"));
00226     pUser->uchCaps = 0;
00227   }
00228
00229   hr = pMember->GetNmVersion(&pUser->uVersion);
00230   if (FAILED(hr))
00231   {
00232     WARN_MSG(TEXT("Problem with GetNmVersion"));
00233     pUser->uVersion = 0;
00234   }
00235
00236   hr = pMember->GetID(&pUser->uId);
00237   if (FAILED(hr))
00238   {
00239     WARN_MSG(TEXT("Problem with GetID"));
00240     pUser->uId = 0;
00241   }
00242
00243   pUser->fLocal = S_OK == pMember->IsSelf();
00244   pUser->fMcu = S_OK == pMember->IsMCU();
00245   pUser->fTop = FALSE;
00246   hr = pMember->GetConference(&pConference);
00247   if (FAILED(hr))
00248   {
00249     WARN_MSG(TEXT("Problem with GetConference"));
00250   }
00251   else
00252   {
00253     INmMember * pMemberTop  = NULL;
00254     if (SUCCEEDED(pConference->GetTopProvider(&pMemberTop)))
00255     {
00256       pUser->fTop = (pMember == pMemberTop);
00257       pMemberTop->Release();
00258     }
00259     pConference->Release();
00260   }
00261
00262   return pUser;
00263 }
00264
00265 //****************************************************************************
00266 //
00267 // VOID FreeUser(PUSER pUser)
00268 //
00269 //****************************************************************************
00270
00271 VOID FreeUser(PUSER pUser)
00272 {
00273   ASSERT(NULL != pUser);
00274   if  (NULL == pUser)
00275   {
00276     ERROR_MSG(TEXT("FreeUser: NULL == pUser"));
00277     return;
00278   }
00279
00280   FreePlpv(&pUser->pszName);
00281   FreePlpv(&pUser->pszAddr);
00282
00283   if (NULL != pUser->pMember)
00284   {
00285     OBJECT_MSG(TEXT("[%08X] member released"), pUser->pMember);
00286     pUser->pMember->Release();
00287     pUser->pMember = NULL;
00288   }
00289
00290   delete pUser;
00291 }
00292
00293
00294 //****************************************************************************
00295 //
00296 // VOID FreeAllUsers(void)
00297 //
00298 //****************************************************************************
00299
00300 VOID FreeAllUsers(void)
00301 {
00302   if (NULL != g_pListUser)
00303   {
00304     while (!g_pListUser->IsEmpty())
00305     {
00306       PUSER pUser = (PUSER) g_pListUser -> GetHead();
00307       if  (NULL == pUser)
00308       {
00309         ERROR_MSG(TEXT("FreeAllUsers: NULL == pUser"));
00310         break;
00311       }
00312
00313       RemoveMember(pUser->pMember);
00314     }
00315   }
00316 }
00317
00318 //****************************************************************************
00319 //
00320 // VOID AddMember(INmMember * pMember)
00321 //
00322 //****************************************************************************
00323
00324 VOID AddMember(INmMember * pMember)
00325 {
00326   PUSER pUser = AllocUser(pMember);
00327   if (NULL == pUser)
00328   {
00329     return;
00330   }
00331
00332   if  (NULL == AddNode(pUser, &g_pListUser))
00333   {
00334     ERROR_MSG(TEXT("AddMember: AddNode returned Null"));
00335     return;
00336   }
00337
00338   LV_ITEM  lvItem;
00339   ZeroMemory(&lvItem, sizeof(LV_ITEM));
00340
00341   lvItem.iItem = gcUsers;
00342   lvItem.mask = LVIF_PARAM | LVIF_TEXT;
00343   lvItem.pszText = pUser->pszName;
00344   lvItem.cchTextMax = lstrlen(pUser->pszName);
00345   lvItem.lParam = (LPARAM) pUser;
00346   ListView_InsertItem(ghwndLView, &lvItem);
00347
00348   gcUsers++;
00349   UpdateUserCount();
00350   UpdateUserDisplay(pUser);
00351
00352   AddUserToUList(pUser, ghwndUList, FALSE);
00353 }
00354
00355 //****************************************************************************
00356 //
00357 // VOID RemoveMember(INmMember * pMember)
00358 //
00359 //****************************************************************************
00360
00361 VOID RemoveMember(INmMember * pMember)
00362 {
00363   if (NULL == g_pListUser)
00364     return;
00365
00366   POSITION pos = g_pListUser->GetHeadPosition();
00367   while (NULL != pos)
00368   {
00369     POSITION posSav = pos;
00370
00371     PUSER pUser = (PUSER) g_pListUser->GetNext(pos);
00372     if  (NULL == pUser)
00373     {
00374       ERROR_MSG(TEXT("RemoveMember: NULL == pUser"));
00375       return;
00376     }
00377
00378     if (pMember == pUser->pMember)
00379     {
00380       RemoveUserFromUList(pUser, ghwndUList);
00381       ListView_DeleteItem(ghwndLView, ItemFromPUser(pUser));
00382       FreeUser(pUser);
00383       pUser = NULL;
00384
00385       g_pListUser->RemoveAt(posSav);
00386
00387       gcUsers--;
00388       UpdateUserCount();
00389       return;
00390     }
00391   }
00392 }
00393
00394 //****************************************************************************
00395 //
00396 // VOID UpdateUserChannel(PUSER pUser, INmChannel * pChannel, NM_MEMBER_NOTIFY uNotify)
00397 //
00398 //****************************************************************************
00399
00400 VOID UpdateUserChannel(PUSER pUser, INmChannel * pChannel, NM_MEMBER_NOTIFY uNotify)
00401 {
00402   ULONG   uch   = 0   ;
00403   //PVOID * ppChannel = NULL  ;
00404
00405   ASSERT(NULL != pChannel);
00406   if  ((NULL == pChannel) || (NULL == pUser))
00407   {
00408     ERROR_MSG(TEXT("UpdateUserChannel: Null parameter passed in"));
00409     return;
00410   }
00411
00412   if (FAILED(pChannel->GetNmch(&uch)))
00413   {
00414     return;
00415   }
00416
00417   if (NM_MEMBER_ADDED == uNotify)
00418   {
00419   switch (uch)
00420   {
00421     case NMCH_AUDIO:
00422     {
00423       INmChannelAudio * pChannelAudio = NULL;
00424       if (SUCCEEDED(pChannel->QueryInterface(IID_INmChannelAudio, (PVOID *) &pChannelAudio)))
00425       {
00426         if  (NULL == pChannelAudio)
00427         {
00428           ERROR_MSG(TEXT("UpdateUserChannel: pChannelAudio == NULL"));
00429           break;
00430         }
00431
00432         if ((S_OK == pChannelAudio->IsIncoming()) != pUser->fLocal)
00433         {
00434           ASSERT((NULL == pUser->m_pChannelAudio) || (pChannelAudio == pUser->m_pChannelAudio));
00435           pUser->m_pChannelAudio = pChannelAudio;
00436         }
00437
00438         pChannelAudio->Release();
00439       }
00440       break;
00441     }
00442
00443     case NMCH_SHARE:
00444       if (NULL == pUser->m_pChannelAs)
00445       {
00446         INmChannelAppShare * pChannelAs = NULL;
00447         if (SUCCEEDED(pChannel->QueryInterface(IID_INmChannelAppShare, (PVOID *) &pChannelAs)))
00448         {
00449           if  (NULL == pChannelAs)
00450           {
00451             ERROR_MSG(TEXT("UpdateUserChannel: pChannelAs == NULL"));
00452             break;
00453           }
00454
00455           pUser->m_pChannelAs = pChannelAs;
00456           pChannelAs->Release();
00457         }
00458       }
00459       break;
00460
00461     case NMCH_FT:
00462       if (NULL == pUser->m_pChannelFt)
00463       {
00464         INmChannelFt * pChannelFt;
00465         if (SUCCEEDED(pChannel->QueryInterface(IID_INmChannelFt, (PVOID *) &pChannelFt)))
00466         {
00467           if  (NULL == pChannelFt)
00468           {
00469             ERROR_MSG(TEXT("UpdateUserChannel: pChannelFt == NULL"));
00470             break;
00471           }
00472
00473           pUser->m_pChannelFt = pChannelFt;
00474           pChannelFt->Release();
00475         }
00476       }
00477       break;
00478
00479     case NMCH_VIDEO:
00480     case NMCH_DATA:
00481     case NMCH_NONE:
00482     case NMCH_ALL:
00483     default:
00484       break;
00485   }
00486   } /* CONFN_MEMBER_ADDED */
00487
00488   UpdateUserDisplay(pUser);
00489 }
00490
00491
00492 //****************************************************************************
00493 //
00494 // VOID UpdateUserInfo(PUSER pUser)
00495 //
00496 //****************************************************************************
00497
00498 VOID UpdateUserInfo(PUSER pUser)
00499 {
00500   if  (NULL == pUser)
00501   {
00502     ERROR_MSG(TEXT("NULL == pUser"));
00503     return;
00504   }
00505
00506   ULONG   ul    = 0;
00507   HRESULT hr    = NO_ERROR;
00508   LPTSTR  psz   = NULL;
00509   BSTR    bstr  = NULL;
00510
00511   INmMember * pMember = pUser->pMember;
00512
00513   hr = pMember->GetName(&bstr);
00514   if (FAILED(hr))
00515   {
00516     WARN_MSG(TEXT("Problem with GetName"));
00517   }
00518   else
00519   {
00520     psz = PszFromBstr(bstr);
00521     SysFreeString(bstr);
00522
00523     if (0 != lstrcmp(pUser->pszName, psz))
00524     {
00525       WARN_MSG(TEXT("Replacing Name [%s] => [%s]"),
00526         (NULL == pUser->pszName) ? TEXT("NULL") : pUser->pszName,
00527         (NULL == psz) ? TEXT("NULL") : psz);
00528     }
00529     FreePlpv(&pUser->pszName);
00530     pUser->pszName = psz;
00531   }
00532
00533   hr = pMember->GetAddr(&bstr, &pUser->uType);
00534   if (FAILED(hr))
00535   {
00536     WARN_MSG(TEXT("Problem with GetAddr"));
00537   }
00538   else
00539   {
00540     psz = PszFromBstr(bstr);
00541     SysFreeString(bstr);
00542
00543     if(NULL != pUser->pszAddr)
00544     {
00545       if (0 != lstrcmp(pUser->pszAddr, psz))
00546       {
00547         WARN_MSG(TEXT("Replacing Addr [%s] => [%s]"),
00548           (NULL == pUser->pszAddr) ? TEXT("NULL") : pUser->pszAddr,
00549           (NULL == psz) ? TEXT("NULL") : psz);
00550       }
00551       FreePlpv(&pUser->pszAddr);
00552     }
00553     pUser->pszAddr = psz;
00554   }
00555
00556   hr = pMember->GetNmchCaps(&ul);
00557   if (FAILED(hr))
00558   {
00559     WARN_MSG(TEXT("Problem with GetNmchCaps"));
00560     pUser->uchCaps = 0;
00561   }
00562   else if (pUser->uchCaps != ul)
00563   {
00564     WARN_MSG(TEXT("Updating uchCaps [%08X] => [%08X]"), pUser->uchCaps, ul);
00565     pUser->uchCaps = ul;
00566   }
00567
00568   hr = pMember->GetNmVersion(&ul);
00569   if (FAILED(hr))
00570   {
00571     WARN_MSG(TEXT("Problem with GetNmVersion"));
00572     pUser->uVersion = 0;
00573   }
00574   else if (pUser->uVersion != ul)
00575   {
00576     WARN_MSG(TEXT("Updating version [%08X] => [%08X]"), pUser->uVersion, ul);
00577     pUser->uchCaps = ul;
00578   }
00579
00580   if (pUser->fLocal != (S_OK == pMember->IsSelf()) )
00581   {
00582     ERROR_MSG(TEXT("Local User status changed?"));
00583   }
00584
00585   if (pUser->fMcu != (S_OK == pMember->IsMCU()))
00586   {
00587     ERROR_MSG(TEXT("MCU status changed?"));
00588   }
00589 }
00590
00591
00592 //****************************************************************************
00593 //
00594 // VOID UpdateConfView(void)
00595 //
00596 //****************************************************************************
00597
00598 VOID UpdateConfView(void)
00599 {
00600   if (NULL == g_pListUser)
00601     return;
00602
00603   POSITION pos = g_pListUser->GetHeadPosition();
00604   while (NULL != pos)
00605   {
00606     PUSER pUser = (PUSER) g_pListUser->GetNext(pos);
00607     UpdateUserInfo(pUser);
00608     UpdateUserDisplay(pUser);
00609   }
00610 }
00611
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/ClUuid/ClUuidc.c Source File

  • NetDS
  • RPC
  • ClUuid

ClUuidc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                        Cluuid Example
00005
00006     FILE:        cluuidc.c
00007
00008     USAGE:       cluuidc  -n network_address
00009                           -p protocol_sequence
00010                           -e endpoint
00011                           -o options
00012                           -s string_displayed_on_server
00013                           -u client object uuid
00014
00015     PURPOSE:     Client side of RPC distributed application
00016
00017     FUNCTIONS:   main() - binds to server and calls remote procedure
00018
00019     COMMENTS:    This distributed application prints a string such as
00020                  "hello, world" on the server. The client manages its
00021                  connection to the server. The client uses the implicit
00022                  binding handle ImpHandle defined in the file cluuid.h.
00023
00024 ****************************************************************************/
00025
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <ctype.h>
00029 #include "cluuid.h"    // header file generated by MIDL compiler
00030
00031 void Usage(char * pszProgramName)
00032 {
00033     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00034     fprintf(stderr, " -p protocol_sequence\n");
00035     fprintf(stderr, " -n network_address\n");
00036     fprintf(stderr, " -e endpoint\n");
00037     fprintf(stderr, " -o options\n");
00038     fprintf(stderr, " -s string\n");
00039     fprintf(stderr, " -u uuid\n");
00040     exit(1);
00041 }
00042
00043 void __cdecl main(int argc, char **argv)
00044 {
00045     RPC_STATUS status;
00046     unsigned char * pszUuid             = NULL;
00047     unsigned char * pszProtocolSequence = "ncacn_np";
00048     unsigned char * pszNetworkAddress   = NULL;
00049     unsigned char * pszEndpoint         = "\\pipe\\cluuid";
00050     unsigned char * pszOptions          = NULL;
00051     unsigned char * pszStringBinding    = NULL;
00052     unsigned char * pszString           = "hello, world";
00053     unsigned long ulCode;
00054     int i;
00055
00056     /* allow the user to override settings with command line switches */
00057     for (i = 1; i < argc; i++) {
00058         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00059             switch (tolower(*(argv[i]+1))) {
00060             case 'p':  // protocol sequence
00061                 pszProtocolSequence = argv[++i];
00062                 break;
00063             case 'n':  // network address
00064                 pszNetworkAddress = argv[++i];
00065                 break;
00066             case 'e':
00067                 pszEndpoint = argv[++i];
00068                 break;
00069             case 'o':
00070                 pszOptions = argv[++i];
00071                 break;
00072             case 's':
00073                 pszString = argv[++i];
00074                 break;
00075             case 'u':
00076                 pszUuid = argv[++i];
00077                 break;
00078             case 'h':
00079             case '?':
00080             default:
00081                 Usage(argv[0]);
00082             }
00083         }
00084         else
00085             Usage(argv[0]);
00086     }
00087
00088     /* Use a convenience function to concatenate the elements of  */
00089     /* the string binding into the proper sequence.               */
00090     status = RpcStringBindingCompose(pszUuid,
00091                                      pszProtocolSequence,
00092                                      pszNetworkAddress,
00093                                      pszEndpoint,
00094                                      pszOptions,
00095                                      &pszStringBinding);
00096     printf("RpcStringBindingCompose returned 0x%x\n", status);
00097     printf("pszStringBinding = %s\n", pszStringBinding);
00098     if (status) {
00099         exit(status);
00100     }
00101
00102     /* Set the binding handle that will be used to bind to the server. */
00103     status = RpcBindingFromStringBinding(pszStringBinding,
00104                                          &ImpHandle);
00105     printf("RpcBindingFromStringBinding returned 0x%x\n", status);
00106     if (status) {
00107         exit(status);
00108     }
00109
00110     printf("Calling the remote procedure 'HelloProc'\n");
00111     printf("  print the string '%s' on the server\n", pszString);
00112
00113     RpcTryExcept {
00114         HelloProc(pszString);  /* make call with user message */
00115         printf("Calling the remote procedure 'Shutdown'\n");
00116         Shutdown();             // shut down the server side
00117     }
00118     RpcExcept(1) {
00119         ulCode = RpcExceptionCode();
00120         printf("Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode);
00121     }
00122     RpcEndExcept
00123
00124     /*  The calls to the remote procedures are complete. */
00125     /*  Free the string and the binding handle           */
00126
00127     status = RpcStringFree(&pszStringBinding);  // remote calls done; unbind
00128     printf("RpcStringFree returned 0x%x\n", status);
00129     if (status) {
00130         exit(status);
00131     }
00132
00133     status = RpcBindingFree(&ImpHandle);  // remote calls done; unbind
00134     printf("RpcBindingFree returned 0x%x\n", status);
00135     if (status) {
00136         exit(status);
00137     }
00138
00139     exit(0);
00140 }
00141
00142
00143 /*********************************************************************/
00144 /*                 MIDL allocate and free                            */
00145 /*********************************************************************/
00146
00147 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00148 {
00149     return(malloc(len));
00150 }
00151
00152 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00153 {
00154     free(ptr);
00155 }
00156
00157
00158 /* end file cluuidc.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/basesnap.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

basesnap.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  This file contains implementations for IClassFactory
00014 //             and the Snap-in's DLL exported functions
00015
00016
00017 #include <ObjBase.h>
00018 #include <InitGuid.h>
00019 #include "Globals.h"
00020 #include "BaseSnap.h"
00021 #include "Registry.h"
00022 #include "PropPageX.h"                 //XPROPPAGE: Change headers
00023
00024
00025 #include "TraceMacro.h"
00026 #undef  MODULESTRING
00027 #define MODULESTRING  _T("BaseSnap")
00028
00029
00030 /////////////////////////////////////////////////////////////////////////////
00031 //  Implementation of IClassFactory for CComponentData
00032
00033 //---------------------------------------------------------------------------
00034 CClassFactory::CClassFactory( FACTORY_TYPE eFactoryType )
00035 {
00036   m_cRef = 0;
00037   m_FactoryType = eFactoryType;
00038
00039   InterlockedIncrement((long*)&g_uObjectCount);
00040 }
00041
00042
00043 //---------------------------------------------------------------------------
00044 CClassFactory::~CClassFactory()
00045 {
00046   InterlockedDecrement((long*)&g_uObjectCount);
00047 }
00048
00049
00050 //---------------------------------------------------------------------------
00051 STDMETHODIMP CClassFactory::QueryInterface
00052 (
00053   REFIID   riid,             //[in]  Identifier of the requested interface
00054   LPVOID*  ppv               //[out] Address of requested interface
00055 )
00056 {
00057   if( NULL == ppv )
00058     return E_FAIL;
00059
00060   HRESULT hResult = E_NOINTERFACE;
00061   *ppv = NULL;
00062
00063   if( IsEqualIID(riid, IID_IUnknown) )
00064   {
00065     *ppv = static_cast<IClassFactory*>(this);
00066   }
00067   else if( IsEqualIID(riid, IID_IClassFactory) )
00068   {
00069     *ppv = static_cast<IClassFactory*>(this);
00070   }
00071
00072   if( *ppv )
00073   {
00074     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00075     hResult = S_OK;
00076   }
00077
00078   return hResult;
00079 }
00080
00081
00082 //---------------------------------------------------------------------------
00083 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00084 {
00085   return InterlockedIncrement( (long*)&m_cRef );
00086 }
00087
00088
00089 //---------------------------------------------------------------------------
00090 STDMETHODIMP_(ULONG) CClassFactory::Release()
00091 {
00092   if( 0 == InterlockedDecrement( (long*)&m_cRef) )
00093   {
00094     delete this;
00095     return 0;
00096   }
00097   return m_cRef;
00098 }
00099
00100 //---------------------------------------------------------------------------
00101 //  Creates an instance of the object type which was passed in the
00102 //  class constructor
00103 //
00104 STDMETHODIMP CClassFactory::CreateInstance
00105 (
00106   LPUNKNOWN  pUnkOuter,      //[in] NULL unless object is part of aggregate
00107   REFIID     riid,           //[in] Reference to interface indentifier
00108   LPVOID*    ppvObj          //[out] Address of requested interface pointer
00109 )
00110 {
00111   HRESULT  hResult = E_FAIL;
00112   void*    pObject = NULL;
00113
00114   if( NULL == ppvObj )
00115     return hResult;
00116
00117   *ppvObj = NULL;
00118
00119   // Our object does does not support aggregation, so we need to
00120   // fail if they ask us to do aggregation.
00121   if( pUnkOuter )
00122     return CLASS_E_NOAGGREGATION;
00123
00124   // Support for providing CSnapinAbout/CComponentData objects
00125   switch( m_FactoryType )
00126   {
00127     case PROPERTYPAGEX:                //XPROPPAGE: Create CExtendPropertySheet
00128       pObject = new CExtendPropertySheet();
00129       break;
00130
00131     default:
00132       pObject = NULL;
00133   }
00134
00135   if( NULL == pObject )                // Failed to create an object
00136     return E_INVALIDARG;               // due to bad argument
00137
00138   // QueryInterface will do the AddRef() for us, don't do it here
00139   hResult = ( (LPUNKNOWN)pObject)->QueryInterface( riid, ppvObj );
00140
00141   if( S_OK != hResult )
00142     delete pObject;
00143
00144   return hResult;
00145 }
00146
00147
00148 //---------------------------------------------------------------------------
00149 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00150 {
00151   if( TRUE == fLock )
00152     InterlockedIncrement((long*)&g_uServerLocks);
00153   else
00154     InterlockedDecrement((long*)&g_uServerLocks);
00155
00156   return S_OK;
00157 }
00158
00159
00160 /////////////////////////////////////////////////////////////////////////////
00161 //  Our Snap-in's exported functions
00162 //
00163
00164 //---------------------------------------------------------------------------
00165 //  Entry point into our Snap-in DLL
00166 //
00167 BOOL WINAPI DllMain
00168 (
00169   HINSTANCE  hInstDLL,         //[in] Handle to DLL module
00170   DWORD      fdwReason,        //[in] Reason for calling function
00171   void*      lpvReserved       //[in] Reserved
00172 )
00173 {
00174   if( DLL_PROCESS_ATTACH == fdwReason )
00175   {
00176      g_hInst = hInstDLL;
00177   }
00178
00179   return TRUE;
00180 }
00181
00182
00183 //---------------------------------------------------------------------------
00184 STDAPI DllGetClassObject
00185 (
00186   REFCLSID   rclsid,         //[in] CLSID for the class object
00187   REFIID     riid,           //[in] Reference to interface identifier
00188   LPVOID     *ppvObj         //[out] Object which recieves interface pointer
00189 )
00190 {
00191   // XPROPPAGE: Test for our class
00192   if( (rclsid != CLSID_CExtendPropertySheet2) )
00193     return CLASS_E_CLASSNOTAVAILABLE;
00194
00195   if( !ppvObj )
00196     return E_FAIL;
00197
00198   *ppvObj = NULL;
00199
00200   // We can only hand out IUnknown and IClassFactory pointers.  Fail
00201   // if caller asks for anything else.
00202   if( !IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory) )
00203     return E_NOINTERFACE;
00204
00205   CClassFactory *pFactory = NULL;
00206
00207   // XPROPPAGE: Create the new class factory.  Pass in the type of object to create
00208   if( rclsid == CLSID_CExtendPropertySheet2 )
00209     pFactory = new CClassFactory(CClassFactory::PROPERTYPAGEX);
00210
00211
00212   HRESULT hResult = pFactory->QueryInterface( riid, ppvObj );
00213
00214   return hResult;
00215 }
00216
00217
00218 //---------------------------------------------------------------------------
00219 STDAPI DllCanUnloadNow(void)
00220 {
00221   if( 0 == g_uObjectCount && 0 == g_uServerLocks )
00222     return S_OK;
00223   else
00224     return S_FALSE;
00225 }
00226
00227
00228 //---------------------------------------------------------------------------
00229 //  XPROPPAGE:  Support only CLSID_CExtendPropertySheet2
00230 //
00231 STDAPI DllRegisterServer()
00232 {
00233   HRESULT hResult = S_FALSE;
00234
00235   do
00236   {
00237     hResult = RegisterServer( g_hInst, CLSID_CExtendPropertySheet2, gtszSNAPIN_NAME );
00238     BREAK_ON_ERROR( hResult );
00239
00240     hResult = RegisterSnapin( CLSID_CExtendPropertySheet2, gtszSNAPIN_NAME, IID_NULL, FALSE );
00241     BREAK_ON_ERROR( hResult );
00242
00243   }while( 0 );
00244
00245   return hResult;
00246 }
00247
00248
00249 //---------------------------------------------------------------------------
00250 //  XPROPPAGE: Support only CLSID_CExtendPropertySheet2
00251 //
00252 STDAPI DllUnregisterServer()
00253 {
00254   if( S_OK == UnregisterServer(CLSID_CExtendPropertySheet2) )
00255     return UnregisterSnapin(CLSID_CExtendPropertySheet2);
00256   else
00257     return E_FAIL;
00258 }
00259
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

APIHook< T > Member List

This is the complete list of members for APIHook< T >, including all inherited members.
_libName | APIHook< T > | [private]
_preAPI | APIHook< T > | [private]
_rValue | APIHook< T > | [private]
APIHook() | APIHook< T > | [private]
APIHook(const T *returnValue, const char *const libraryName, const bool preAPI) | APIHook< T > | [inline]
libName() | APIHook< T > | [inline]
preAPI() | APIHook< T > | [inline]
rValue() | APIHook< T > | [inline]
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Explore.VC/Resource.h Source File

  • Com
  • Administration
  • Explore.VC

Resource.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #define IDM_ABOUTBOX                    0x0010
00018 #define IDD_ABOUTBOX                    100
00019 #define IDS_ABOUTBOX                    101
00020 #define IDD_VCEXPLORE_DIALOG            102
00021 #define IDD_VCEXPLORE                   102
00022 #define IDR_MAINFRAME                   128
00023 #define IDI_LOGO                        131
00024 #define IDD_EXPORT_APPLICATION          132
00025 #define IDD_INSTALL_APPLICATION         133
00026 #define IDD_APP_UTILITY                 134
00027 #define IDD_INSTALL_COMPONENT           135
00028 #define IDD_IMPORT_COMPONENT            136
00029 #define IDD_CONNECT                     137
00030 #define IDD_UTILITIES                   138
00031 #define IDR_TOOLBAR_MAIN                143
00032 #define IDI_APP_ICON                    145
00033 #define IDI_UTILITIES                   149
00034 #define IDI_CONNECT                     150
00035 #define IDI_INSTALL                     151
00036 #define IDI_IMPORT                      152
00037 #define IDI_START                       153
00038 #define IDI_STOP                        154
00039 #define IDI_EXPORT                      155
00040 #define IDC_FRAME_CATALOG_INFO          1001
00041 #define IDC_LABEL_COMPUTER_NAME_DESC    1002
00042 #define IDC_LABEL_COMPUTER_NAME_VALUE   1003
00043 #define IDC_LABEL_COLLECTION_NAME_DESC  1004
00044 #define IDC_LABEL_COLLECTION_NAME_VALUE 1005
00045 #define IDC_FRAME_RELATED_COLLECTIONS   1006
00046 #define IDC_LIST_RELATED_COLLECTIONS    1007
00047 #define IDC_FRAME_PREVIOUS_COLLECTIONS  1008
00048 #define IDC_LIST_PARENT_COLLECTIONS     1009
00049 #define IDC_FRAME_OBJECTS_AND_PROP_INFO 1010
00050 #define IDC_LABEL_OBJECTS_DESC          1011
00051 #define IDC_LABEL_PROPERTIES_DESC2      1012
00052 #define IDC_LIST_OBJECTS                1013
00053 #define IDC_LIST_PROPERTIES             1014
00054 #define IDC_LABEL_PROPERTY_VALUE_DESC   1015
00055 #define IDC_EDIT_PROPERTY_VALUE         1016
00056 #define IDC_BUTTON_SET_PROPERTY         1017
00057 #define IDC_FRAME_EXPORT_CLIENT_ONLY    1018
00058 #define IDC_RADIO_DO_NOT_EXPORT_USERS   1019
00059 #define IDC_RADIO_EXPORT_USERS          1020
00060 #define IDC_RADIO_EXPORT_CLIENTS        1021
00061 #define IDC_CHECK_OVERWRITE_FILES       1022
00062 #define IDC_CHECK_REMOTE_SERVER_INSTALL 1023
00063 #define IDC_EDIT_APPLICATION_ID_VALUE   1024
00064 #define IDC_LABEL_EXPORT_PATH           1025
00065 #define IDC_EDIT_EXPORT_PATH            1026
00066 #define IDC_BUTTON_EXPORT_PATH_SEARCH   1028
00067 #define IDC_FRAME_INSTALL_OPTIONS       1028
00068 #define IDC_RADIO_INSTALL_WITHOUT_USERS 1029
00069 #define IDC_RADIO_INSTALL_WITH_USERS    1030
00070 #define IDC_BUTTON_INSTALL_DIRECTORY_SEARCH 1031
00071 #define IDC_LABEL_APPLICATION_FILE      1032
00072 #define IDC_EDIT_APPLICATION_FILE       1033
00073 #define IDC_LABEL_INSTALL_DIRECTORY     1034
00074 #define IDC_EDIT_INSTALL_DIRECTORY      1035
00075 #define IDC_BUTTON_APPLICATION_FILE_SEARCH 1036
00076 #define IDC_BUTTON_APPLICATON_ID_SEARCH 1037
00077 #define IDC_LABEL_REMOTE_SERVER_NAME    1037
00078 #define IDC_LABEL_APPLICATION           1038
00079 #define IDC_EDIT_REMOTE_SERVER_NAME     1038
00080 #define IDC_COMBO_APPLICATION           1039
00081 #define IDC_LABEL_UID                   1039
00082 #define IDC_LABEL_COMPONENT             1040
00083 #define IDC_EDIT_UID                    1040
00084 #define IDC_EDIT_COMPONENT              1041
00085 #define IDC_LABEL_PWD                   1041
00086 #define IDC_BUTTON_COMPONENT_SEARCH     1042
00087 #define IDC_EDIT_PWD                    1042
00088 #define IDC_LABEL_TYPE_LIBRARY          1043
00089 #define IDC_EDIT_TYPE_LIBRARY           1044
00090 #define IDC_BUTTON_TYPE_LIBRARY         1045
00091 #define IDC_LABEL_PROXY_STUB_DLL        1046
00092 #define IDC_EDIT_PROXY_STUB_DLL         1047
00093 #define IDC_BUTTON_PROXY_STUB_DLL       1048
00094 #define IDC_LABEL_APPLICATION_ID        1049
00095 #define IDC_EDIT_APPLICATION_ID         1050
00096 #define IDC_APPLICATION_TITLE           1051
00097 #define IDC_APPLICATION_VERSION         1052
00098 #define IDC_APPLICATION_COPYRIGHT       1053
00099 #define IDC_APPLICATION_ICON            1054
00100 #define IDC_FRAME_IMPORT_BY             1055
00101 #define IDC_RADIO_PROG_ID               1056
00102 #define IDC_FRAME_UTILITY_OPTIONS       1056
00103 #define IDC_RADIO_CLSID                 1057
00104 #define IDC_RADIO_THIS_COMPUTER         1058
00105 #define IDC_RADIO_REMOTE_COMPUTER       1059
00106 #define IDC_EDIT_REMOTE_COMPUTER_NAME   1060
00107 #define IDC_RADIO_ROUTER                1061
00108 #define IDC_RADIO_JNEC                  1062
00109 #define IDC_RADIO_START                 1063
00110 #define IDC_RADIO_STOP                  1064
00111 #define IDC_RADIO_REFRESH               1065
00112 #define IDC_FRAME_UTILITY_TYPE          1066
00113 #define ID_TBTN_CONNECT                 32772
00114 #define ID_TBTN_REFRESH                 32773
00115 #define ID_TBTN_NEW                     32774
00116 #define ID_TBTN_SAVE                    32775
00117 #define ID_TBTN_DELETE                  32776
00118 #define ID_TBTN_START_APP               32777
00119 #define ID_TBTN_STOP_APP                32778
00120 #define ID_TBTN_INSTALL_APP             32779
00121 #define ID_TBTN_EXPORT_APP              32780
00122 #define ID_TBTN_INSTALL_COMPONENT       32781
00123 #define ID_TBTN_IMPORT_COMPONENT        32782
00124 #define ID_TBTN_UTILITY                 32783
00125 #define ID_TBTN_ABOUT                   32784
00126
00127 // Next default values for new objects
00128 //
00129 #ifdef APSTUDIO_INVOKED
00130 #ifndef APSTUDIO_READONLY_SYMBOLS
00131 #define _APS_NEXT_RESOURCE_VALUE        157
00132 #define _APS_NEXT_COMMAND_VALUE         32785
00133 #define _APS_NEXT_CONTROL_VALUE         1067
00134 #define _APS_NEXT_SYMED_VALUE           101
00135 #endif
00136 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Filter/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Filter
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__913B8270_AFF8_11D2_9A74_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__913B8270_AFF8_11D2_9A74_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__913B8270_AFF8_11D2_9A74_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/common.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

common.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module COMMON.CPP | common global functions
00008 //
00009 //
00010
00011 // Includes ------------------------------------------------------------------
00012
00013 #include "headers.h"
00014
00015
00016 // Code ----------------------------------------------------------------------
00017
00018 // IsEqualDBID ---------------------------------------------------------------
00019 //
00020 // @mfunc Checks equality of two DBIDs
00021 //
00022 // @rdesc
00023 //      @flag  TRUE  | DBID's are the same
00024 //      @flag  FALSE | DBID's differ
00025 //
00026 BOOL IsEqualDBID
00027   (
00028   const DBID * px,
00029   const DBID * py
00030   )
00031 {
00032   if(!px || !py)
00033     return FALSE;
00034
00035   if(px->eKind == py->eKind)
00036   {
00037     switch(px->eKind)
00038     {
00039       case DBKIND_GUID_NAME:
00040         if ((px->uGuid.guid==py->uGuid.guid) &&
00041            px->uName.pwszName==NULL &&
00042            py->uName.pwszName==NULL)
00043            return TRUE;
00044
00045         if ((px->uGuid.guid==py->uGuid.guid) &&
00046           wcscmp((px->uName.pwszName),(py->uName.pwszName))==0 )
00047           return TRUE;
00048         break;
00049
00050       case DBKIND_GUID_PROPID:
00051         if ((px->uGuid.guid == py->uGuid.guid)&&
00052           (px->uName.ulPropid == py->uName.ulPropid))
00053           return TRUE;
00054         break;
00055
00056       case DBKIND_NAME:
00057         if (NULL == px->uName.pwszName || NULL == py->uName.pwszName)
00058           return px->uName.pwszName == py->uName.pwszName;
00059         if (0==wcscmp((px->uName.pwszName),(py->uName.pwszName)))
00060           return TRUE;
00061         break;
00062
00063       case DBKIND_PGUID_NAME:
00064         if ((px->uGuid.pguid) == (py->uGuid.pguid))
00065           return TRUE;
00066         break;
00067
00068       case DBKIND_PGUID_PROPID:
00069         if ((px->uGuid.pguid)==(py->uGuid.pguid)&&
00070           (px->uName.ulPropid == py->uName.ulPropid))
00071           return TRUE;
00072         break;
00073
00074       case DBKIND_PROPID:
00075         if (px->uName.ulPropid == py->uName.ulPropid)
00076           return TRUE;
00077         break;
00078
00079       case DBKIND_GUID:
00080         if (px->uGuid.guid==py->uGuid.guid)
00081           return TRUE;
00082         break;
00083
00084       default:
00085         assert(!"Unhandled Case!");
00086         return FALSE;
00087     }
00088   }
00089
00090   return FALSE;
00091 }
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/AdvReco/AdvReco.cpp Source File

  • TabletPC
  • AdvReco

AdvReco.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //  This is part of the Microsoft Tablet PC Platform SDK
00003 //  Copyright (C) 2002 Microsoft Corporation
00004 //  All rights reserved.
00005 //
00006 //  This source code is only intended as a supplement to the
00007 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00008 //  documentation provided with the Software Development Kit.
00009 //  See these sources for more detailed information.
00010 //
00011 // Module:
00012 //      AdvReco.cpp
00013 //
00014 // Description:
00015 //      This sample demonstrates such advanced features of the
00016 //      Microsoft Tablet PC Automation API used for handwriting
00017 //      recognition, as
00018 //          - enumerating the installed recognzers
00019 //          - creating a recognition context with a specific language
00020 //            recognizer
00021 //          - setting recognition input scopes
00022 //          - using guides to improve the recognition quality
00023 //          - dynamic background recognition
00024 //          - gesture recognition.
00025 //
00026 //      This application is discussed in the Getting Started guide.
00027 //
00028 //      (NOTE: For code simplicity, returned HRESULT is not checked
00029 //             on failure in the places where failures are not critical
00030 //             for the application or very unexpected)
00031 //
00032 //      The interfaces used are:
00033 //      IInkRecognizers, IInkRecognizer, IInkRecoContext,
00034 //      IInkRecognitionResult, IInkRecognitionGuide, IInkGesture
00035 //      IInkCollector, IInkDisp, IInkRenderer, IInkStrokes, IInkStroke
00036 //
00037 // Requirements:
00038 //      One or more handwriting recognizer must be installed on the system;
00039 //      Appropriate Asian fonts need to be installed to output the results
00040 //      of the Asian recognizers.
00041 //
00042 //--------------------------------------------------------------------------
00043
00044 #ifndef _WIN32_WINNT
00045 #define _WIN32_WINNT 0x0500
00046 #endif
00047
00048 // Windows header files
00049 #include <windows.h>
00050 #include <commctrl.h>       // need it to call CreateStatusWindow
00051
00052 // The following definitions may be not found in the old headers installed with VC6,
00053 // so they're copied from the newer headers found in the Microsoft Platform SDK
00054
00055 #ifndef ListView_SetCheckState
00056 #define ListView_SetCheckState(hwndLV, i, fCheck) \
00057 ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck ? 2 : 1)), LVIS_STATEIMAGEMASK)
00058 #endif
00059
00060 #ifndef ListView_GetCheckState
00061 #define ListView_GetCheckState(hwndLV, i) \
00062 ((((UINT)(SNDMSG((hwndLV), LVM_GETITEMSTATE, (WPARAM)(i), LVIS_STATEIMAGEMASK))) >> 12) -1)
00063 #endif
00064
00065 #ifndef MIIM_STRING
00066 #define MIIM_STRING      0x00000040
00067 #endif
00068 #ifndef MIIM_FTYPE
00069 #define MIIM_FTYPE       0x00000100
00070 #endif
00071
00072 // A useful macro to determine the number of elements in the array
00073 #define countof(array)  (sizeof(array)/sizeof(array[0]))
00074
00075 // ATL header files
00076 #include <atlbase.h>        // defines CComModule, CComPtr, CComVariant
00077 CComModule _Module;
00078 #include <atlwin.h>         // defines CWindowImpl
00079 #include <atlcom.h>         // defines IDispEventSimpleImpl
00080
00081 // Headers for Tablet PC Automation interfaces
00082 #include <msinkaut.h>
00083 #include <msinkaut_i.c>
00084 #include <tpcerror.h>
00085
00086 // The application header files
00087 #include "resource.h"       // main symbols, including command ID's
00088 #include "EventSinks.h"     // defines the IInkEventsImpl and IInkRecognitionEventsImpl
00089 #include "ChildWnds.h"      // definitions of the CInkInputWnd and CRecoOutputWnd
00090 #include "AdvReco.h"        // contains the definition of CAddRecoApp
00091
00092 // The names of the supported Input Scopes.
00093 // All these names are used both to create a menu item and
00094 // as the parameter in IInkRecoContext::put_Factoid(name).
00095 const LPOLESTR gc_pwsInputScopes[] = {
00096     L"(!IS_DEFAULT)",
00097     L"(!IS_URL)",
00098     L"(!IS_FILE_FULLFILEPATH)",
00099     L"(!IS_FILE_FILENAME)",
00100     L"(!IS_EMAIL_USERNAME)",
00101     L"(!IS_EMAIL_SMTPEMAILADDRESS)",
00102     L"(!IS_LOGINNAME)",
00103     L"(!IS_PERSONALNAME_FULLNAME)",
00104     L"(!IS_PERSONALNAME_PREFIX)",
00105     L"(!IS_PERSONALNAME_GIVENNAME)",
00106     L"(!IS_PERSONALNAME_MIDDLENAME)",
00107     L"(!IS_PERSONALNAME_SURNAME)",
00108     L"(!IS_PERSONALNAME_SUFFIX)",
00109     L"(!IS_ADDRESS_FULLPOSTALADDRESS)",
00110     L"(!IS_ADDRESS_POSTALCODE)",
00111     L"(!IS_ADDRESS_STREET)",
00112     L"(!IS_ADDRESS_STATEORPROVINCE)",
00113     L"(!IS_ADDRESS_CITY)",
00114     L"(!IS_ADDRESS_COUNTRYNAME)",
00115     L"(!IS_ADDRESS_COUNTRYSHORTNAME)",
00116     L"(!IS_CURRENCY_AMOUNTANDSYMBOL)",
00117     L"(!IS_CURRENCY_AMOUNT)",
00118     L"(!IS_DATE_FULLDATE)",
00119     L"(!IS_DATE_MONTH)",
00120     L"(!IS_DATE_DAY)",
00121     L"(!IS_DATE_YEAR)",
00122     L"(!IS_DATE_MONTHNAME)",
00123     L"(!IS_DATE_DAYNAME)",
00124     L"(!IS_DIGITS)",
00125     L"(!IS_NUMBER)",
00126     L"(!IS_ONECHAR)",
00127     L"(!IS_TELEPHONE_FULLTELEPHONENUMBER)",
00128     L"(!IS_TELEPHONE_COUNTRYCODE)",
00129     L"(!IS_TELEPHONE_AREACODE)",
00130     L"(!IS_TELEPHONE_LOCALNUMBER)",
00131     L"(!IS_TIME_FULLTIME)",
00132     L"(!IS_TIME_HOUR)",
00133     L"(!IS_TIME_MINORSEC)",
00134     L"((0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?-? ?)?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?-? ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9)",
00135     L"(!IS_PERSONALNAME_FULLNAME)|((!IS_PERSONALNAME_PREFIX)? +(!IS_PERSONALNAME_GIVENNAME)+ +(!IS_PERSONALNAME_MIDDLENAME)* +(!IS_PERSONALNAME_SURNAME)+)",
00136     L"MN(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9)(A|B)(!IS_DIGITS)(X|Y)((0|1)*)"
00137 };
00138
00139 // Specifies the maximum allowed length of menu items in the
00140 // input scope menu.  Any items that exceed this value will
00141 // be truncated.
00142 const LONG gc_lMaxInputScopeMenuItemLength = 40;
00143
00144 // The set of the single stroke gestures known to this application
00145 const InkApplicationGesture gc_igtSingleStrokeGestures[] = {
00146     IAG_Scratchout, IAG_Triangle, IAG_Square, IAG_Star, IAG_Check,
00147     IAG_Circle, IAG_DoubleCircle, IAG_Curlicue, IAG_DoubleCurlicue,
00148     IAG_SemiCircleLeft, IAG_SemiCircleRight,
00149     IAG_ChevronUp, IAG_ChevronDown, IAG_ChevronLeft,
00150     IAG_ChevronRight, IAG_Up, IAG_Down, IAG_Left, IAG_Right, IAG_UpDown, IAG_DownUp,
00151     IAG_LeftRight, IAG_RightLeft, IAG_UpLeftLong, IAG_UpRightLong, IAG_DownLeftLong,
00152     IAG_DownRightLong, IAG_UpLeft, IAG_UpRight, IAG_DownLeft, IAG_DownRight, IAG_LeftUp,
00153     IAG_LeftDown, IAG_RightUp, IAG_RightDown, IAG_Tap
00154 };
00155
00156 // The following array of indices to the gc_igtSingleStrokeGestures makes the subset
00157 // of gestures recommended for use in the mixed collection mode (ICM_InkAndGesture)
00158 // (the others still can be used in the mixed mode but it's not recommended because
00159 // of their similarity with some characters).
00160 const UINT gc_nRecommendedForMixedMode[] = {
00161         0 /*Scratchout*/, 3/*Star*/, 6/*Double Circle*/,
00162         7 /*Curlicue*/, 8 /*Double Curlicue*/, 25 /*Down-Left Long*/ };
00163
00164 // The set of the multiple stroke gestures known to this application
00165 const InkApplicationGesture gc_igtMultiStrokeGestures[] = {
00166     IAG_ArrowUp, IAG_ArrowDown, IAG_ArrowLeft,
00167     IAG_ArrowRight, IAG_Exclamation, IAG_DoubleTap
00168 };
00169
00170 // The static members of the event sink templates are initialized here
00171 // (defined in EventSinks.h)
00172
00173 const _ATL_FUNC_INFO IInkRecognitionEventsImpl<CAdvRecoApp>::mc_AtlFuncInfo =
00174         {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_VARIANT, VT_I4}};
00175
00176 const _ATL_FUNC_INFO IInkCollectorEventsImpl<CAdvRecoApp>::mc_AtlFuncInfo[2] = {
00177         {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_UNKNOWN, VT_BOOL|VT_BYREF}},
00178         {CC_STDCALL, VT_EMPTY, 4, {VT_UNKNOWN, VT_UNKNOWN, VT_VARIANT, VT_BOOL|VT_BYREF}}
00179 };
00180
00181 const TCHAR gc_szAppName[] = TEXT("Advanced Recognition");
00182
00183 /////////////////////////////////////////////////////////
00184 //
00185 // WinMain
00186 //
00187 // The WinMain function is called by the system as the
00188 // initial entry point for a Win32-based application.
00189 //
00190 // Parameters:
00191 //        HINSTANCE hInstance,      : [in] handle to current instance
00192 //        HINSTANCE hPrevInstance,  : [in] handle to previous instance
00193 //        LPSTR lpCmdLine,          : [in] command line
00194 //        int nCmdShow              : [in] show state
00195 //
00196 // Return Values (int):
00197 //        0 : The function terminated before entering the message loop.
00198 //        non zero: Value of the wParam when receiving the WM_QUIT message
00199 //
00200 /////////////////////////////////////////////////////////
00201 int APIENTRY WinMain(
00202         HINSTANCE hInstance,
00203         HINSTANCE /*hPrevInstance*/,   // not used here
00204         LPSTR     /*lpCmdLine*/,       // not used here
00205         int       nCmdShow
00206         )
00207 {
00208     int iRet = 0;
00209
00210     // Initialize the COM library and the application module
00211     if (S_OK == ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))
00212     {
00213         _Module.Init(NULL, hInstance);
00214
00215         // Register the common control classes used by the application
00216         INITCOMMONCONTROLSEX icc;
00217         icc.dwSize = sizeof(icc);
00218         icc.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES;
00219         if (TRUE == ::InitCommonControlsEx(&icc))
00220         {
00221             // Call the boilerplate function of the application
00222             iRet = CAdvRecoApp::Run(nCmdShow);
00223         }
00224         else
00225         {
00226             ::MessageBox(NULL, TEXT("Error initializing the common controls."),
00227                          gc_szAppName, MB_ICONERROR | MB_OK);
00228         }
00229
00230         // Release the module and the COM library
00231         _Module.Term();
00232         ::CoUninitialize();
00233     }
00234
00235     return iRet;
00236 }
00237
00238 /////////////////////////////////////////////////////////
00239 //
00240 // CAdvRecoApp::Run
00241 //
00242 // The static CAdvRecoApp::Run is the boilerplate of the application.
00243 // It instantiates and initializes an CAdvRecoApp object and runs the
00244 // application's message loop.
00245 //
00246 // Parameters:
00247 //      int nCmdShow              : [in] show state
00248 //
00249 // Return Values (int):
00250 //      0 : The function terminated before entering the message loop.
00251 //      non zero: Value of the wParam when receiving the WM_QUIT message
00252 //
00253 /////////////////////////////////////////////////////////
00254 int CAdvRecoApp::Run(
00255         int nCmdShow
00256         )
00257 {
00258
00259     CAdvRecoApp theApp;
00260
00261     // Load and update the menu before creating the main window.
00262     // Create menu items for the installed recognizers and for the
00263     // supported input scopes.
00264     HMENU hMenu = theApp.LoadMenu();
00265     if (NULL == hMenu)
00266         return 0;
00267
00268     int iRet;
00269
00270     // Load the icon from the resource and associate it with the window class
00271     WNDCLASSEX& wc = CAdvRecoApp::GetWndClassInfo().m_wc;
00272     wc.hIcon = wc.hIconSm = ::LoadIcon(_Module.GetResourceInstance(),
00273                                        MAKEINTRESOURCE(IDR_APPICON));
00274
00275     // Create the application's main window
00276     if (theApp.Create(NULL, CWindow::rcDefault, gc_szAppName,
00277                       WS_OVERLAPPEDWINDOW, 0, (UINT)hMenu) != NULL)
00278     {
00279         // Initialize the application object:
00280         // Use no guides
00281         theApp.SendMessage(WM_COMMAND, ID_GUIDE_NONE);
00282         // Set input scope to default
00283         theApp.SendMessage(WM_COMMAND, ID_INPUTSCOPE_FIRST);
00284         // Create a recognition context with the default recognizer
00285         theApp.SendMessage(WM_COMMAND, ID_RECOGNIZER_DEFAULT);
00286         // Set the collection mode to ICM_InkOnly
00287         theApp.SendMessage(WM_COMMAND, ID_MODE_INK);
00288
00289         // Show and update the main window
00290         theApp.ShowWindow(nCmdShow);
00291         theApp.UpdateWindow();
00292
00293         // Run the boilerplate message loop
00294         MSG msg;
00295         while (::GetMessage(&msg, NULL, 0, 0) > 0)
00296         {
00297             ::TranslateMessage(&msg);
00298             ::DispatchMessage(&msg);
00299         }
00300         iRet = msg.wParam;
00301     }
00302     else
00303     {
00304         ::MessageBox(NULL, TEXT("Error creating the window"),
00305                      gc_szAppName, MB_ICONERROR | MB_OK);
00306         ::DestroyMenu(hMenu);
00307         iRet = 0;
00308     }
00309
00310     return iRet;
00311 }
00312
00313 // Window message handlers //////////////////////////////
00314
00315 /////////////////////////////////////////////////////////
00316 //
00317 // CAdvRecoApp::OnCreate
00318 //
00319 // This WM_CREATE message handler creates and obtains interface
00320 // pointers to the required Automation objects, sets their
00321 // attributes, creates the child windows and enables pen input.
00322 //
00323 // Parameters:
00324 //      defined in the ATL's macro MESSAGE_HANDLER,
00325 //      none of them is used here
00326 //
00327 // Return Values (LRESULT):
00328 //      always 0
00329 //
00330 /////////////////////////////////////////////////////////
00331 LRESULT CAdvRecoApp::OnCreate(
00332         UINT /*uMsg*/,
00333         WPARAM /*wParam*/,
00334         LPARAM /*lParam*/,
00335         BOOL& /*bHandled*/
00336         )
00337 {
00338     // Create child windows for ink input and recognition output,
00339     // listview controls for the lists of gestures, and a status bar
00340     if (false == CreateChildWindows())
00341         return -1;
00342
00343     HRESULT hr;
00344
00345     // Create an ink collector object.
00346     hr = m_spIInkCollector.CoCreateInstance(CLSID_InkCollector);
00347     if (FAILED(hr))
00348         return -1;
00349
00350     // Get a pointer to the ink object interface.
00351     hr = m_spIInkCollector->get_Ink(&m_spIInkDisp);
00352     if (FAILED(hr))
00353         return -1;
00354
00355     // Get an empty ink strokes collection from the ink object.
00356     // It'll be used as a storage for the ink
00357     hr = m_spIInkDisp->get_Strokes(&m_spIInkStrokes);
00358     if (FAILED(hr))
00359         return -1;
00360
00361     // Establish a connection to the collector's event source.
00362     // Depending on the selected collection mode, the application will be
00363     // listening to either Stroke or Gesture events, or both.
00364     hr = IInkCollectorEventsImpl<CAdvRecoApp>::DispEventAdvise(m_spIInkCollector);
00365     // There is nothing interesting the application can do without events
00366     // from the ink collector
00367     if (FAILED(hr))
00368         return -1;
00369
00370     // Set the recommended subset of gestures
00371     PresetGestures();
00372
00373     // Enable ink input in the m_wndInput window
00374     hr = m_spIInkCollector->put_hWnd((long)m_wndInput.m_hWnd);
00375     if (FAILED(hr))
00376         return -1;
00377     hr = m_spIInkCollector->put_Enabled(VARIANT_TRUE);
00378     if (FAILED(hr))
00379         return -1;
00380
00381     // Create a recognizer guide object
00382     if (SUCCEEDED(m_spIInkRecoGuide.CoCreateInstance(CLSID_InkRecognizerGuide)))
00383     {
00384         _InkRecoGuide irg;
00385         irg.midline = -1;                   // not use midline
00386         irg.cRows = irg.cColumns = 0;       // no guide lines
00387         ::SetRect(&irg.rectWritingBox, 0, 0, mc_iGuideColWidth, mc_iGuideRowHeight);
00388         // Make the guide's DrawnBox a little smaller than the the actual area
00389         // in which a user is expected to draw the ink (WritingBox)
00390         irg.rectDrawnBox = irg.rectWritingBox;
00391         ::InflateRect(&irg.rectDrawnBox, -mc_cxBoxMargin, -mc_cyBoxMargin);
00392
00393         // Set the m_wndInput's guide data
00394         m_wndInput.SetGuide(irg);
00395
00396         // Use IInkRenderer to transform the guide boxes rectangles
00397         // into ink space coordinates
00398         hr = m_spIInkCollector->get_Renderer(&m_spIInkRenderer);
00399         if (SUCCEEDED(hr))
00400         {
00401             HDC hdc = m_wndInput.GetDC();
00402             if (NULL != hdc)
00403             {
00404                 // Convert the guide's writing box
00405                 m_spIInkRenderer->PixelToInkSpace((long)hdc,
00406                                                   &irg.rectWritingBox.left,
00407                                                   &irg.rectWritingBox.top);
00408                 m_spIInkRenderer->PixelToInkSpace((long)hdc,
00409                                                   &irg.rectWritingBox.right,
00410                                                   &irg.rectWritingBox.bottom);
00411                 // and the drawn box
00412                 m_spIInkRenderer->PixelToInkSpace((long)hdc,
00413                                                   &irg.rectDrawnBox.left,
00414                                                   &irg.rectDrawnBox.top);
00415                 m_spIInkRenderer->PixelToInkSpace((long)hdc,
00416                                                   &irg.rectDrawnBox.right,
00417                                                   &irg.rectDrawnBox.bottom);
00418                 // Initialize the guide
00419                 hr = m_spIInkRecoGuide->put_GuideData(irg);
00420                 ReleaseDC(hdc);
00421             }
00422             else
00423             {
00424                 hr = E_FAIL;
00425             }
00426         }
00427
00428         // Don't use m_spIInkRecoGuide if failed to set the guide data
00429         if (FAILED(hr))
00430         {
00431             m_spIInkRecoGuide.Release();
00432         }
00433     }
00434
00435     return 0;
00436 }
00437
00438 /////////////////////////////////////////////////////////
00439 //
00440 // CAdvRecoApp::OnDestroy
00441 //
00442 // The WM_DESTROY message handler.
00443 // Used for clean up and also to post a quit message to
00444 // the application itself.
00445 //
00446 // Parameters:
00447 //      defined in the ATL's macro MESSAGE_HANDLER,
00448 //      none is used here
00449 //
00450 // Return Values (LRESULT):
00451 //      always 0
00452 //
00453 /////////////////////////////////////////////////////////
00454 LRESULT CAdvRecoApp::OnDestroy(
00455         UINT /*uMsg*/,
00456         WPARAM /*wParam*/,
00457         LPARAM /*lParam*/,
00458         BOOL& /*bHandled*/
00459         )
00460 {
00461     // Disable ink input and release the InkCollector object
00462     if (m_spIInkCollector != NULL)
00463     {
00464         IInkCollectorEventsImpl<CAdvRecoApp>::DispEventUnadvise(m_spIInkCollector);
00465         m_spIInkCollector->put_Enabled(VARIANT_FALSE);
00466         m_spIInkCollector.Release();
00467     }
00468
00469     // Detach the strokes collection from the recognition context
00470     // and stop listening to the recognition events
00471     if (m_spIInkRecoContext != NULL)
00472     {
00473         m_spIInkRecoContext->EndInkInput();
00474         IInkRecognitionEventsImpl<CAdvRecoApp>::DispEventUnadvise(m_spIInkRecoContext);
00475         m_spIInkRecoContext.Release();
00476     }
00477
00478     // Release the other objects and collections
00479     m_spIInkRecoGuide.Release();
00480     m_spIInkStrokes.Release();
00481     m_spIInkRecognizers.Release();
00482
00483     // Post a WM_QUIT message to the application's message queue
00484     ::PostQuitMessage(0);
00485
00486     return 0;
00487 }
00488
00489 /////////////////////////////////////////////////////////
00490 //
00491 // CAdvRecoApp::OnSize
00492 //
00493 // The WM_SIZE message handler is needed to update
00494 // the layout of the child windows
00495 //
00496 // Parameters:
00497 //      defined in the ATL's macro MESSAGE_HANDLER,
00498 //      wParam of the WN_SIZE message is the only used here.
00499 //
00500 // Return Values (LRESULT):
00501 //      always 0
00502 //
00503 /////////////////////////////////////////////////////////
00504 LRESULT CAdvRecoApp::OnSize(
00505         UINT /*uMsg*/,
00506         WPARAM wParam,
00507         LPARAM /*lParam*/,
00508         BOOL& /*bHandled*/
00509         )
00510 {
00511     if (wParam != SIZE_MINIMIZED)
00512     {
00513         UpdateLayout();
00514     }
00515     return 0;
00516 }
00517
00518
00519 // InkCollector event handlers ///////////////////////////
00520
00521 /////////////////////////////////////////////////////////
00522 //
00523 // CAdvRecoApp::OnStroke
00524 //
00525 // The _IInkCollectorEvents's Stroke event handler.
00526 // See the Tablet PC Automation API Reference for the
00527 // detailed description of the event and its parameters.
00528 //
00529 // Parameters:
00530 //      IInkCursor* pIInkCursor     : [in] not used here
00531 //      IInkStrokeDisp* pInkStroke  : [in]
00532 //      VARIANT_BOOL* pbCancel      : [in,out] option to cancel the gesture,
00533 //                                    default value is FALSE, not modified here
00534 //
00535 // Return Values (HRESULT):
00536 //      S_OK if succeeded, E_FAIL or E_INVALIDARG otherwise
00537 //
00538 /////////////////////////////////////////////////////////
00539 HRESULT CAdvRecoApp::OnStroke(
00540         IInkCursor* /*pIInkCursor*/,
00541         IInkStrokeDisp* pIInkStroke,
00542         VARIANT_BOOL* pbCancel
00543         )
00544 {
00545     if (NULL == pIInkStroke)
00546         return E_INVALIDARG;
00547
00548     if (m_spIInkStrokes == NULL)
00549         return S_OK;
00550
00551     // Add the new stroke to the collection
00552     HRESULT hr = m_spIInkStrokes->Add(pIInkStroke);
00553     if (SUCCEEDED(hr) && m_spIInkRecoContext != NULL)
00554     {
00555         // Cancel the previous background recognition requests
00556         // which have not been processed yet
00557         m_spIInkRecoContext->StopBackgroundRecognition();
00558
00559         // Update the recognition results
00560         CComVariant vCustomData;    // no custom data
00561         m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);
00562     }
00563     return hr;
00564 }
00565
00566 /////////////////////////////////////////////////////////
00567 //
00568 // CAdvRecoApp::OnGesture
00569 //
00570 // The _IInkCollectorEvents's Gesture event handler.
00571 // See the Tablet PC Automation API Reference for the
00572 // detailed description of the event and its parameters.
00573 //
00574 // Parameters:
00575 //      IInkCursor* pIInkCursor  : [in] not used here
00576 //      IInkStrokes* pInkStrokes : [in] the collection
00577 //      VARIANT vGestures        : [in] safearray of IDispatch interface pointers
00578 //                                 of the recognized  Gesture objects
00579 //      VARIANT_BOOL* pbCancel   : [in,out] option to cancel the gesture,
00580 //                                 default value is FALSE
00581 //
00582 // Return Values (HRESULT):
00583 //      S_OK if succeeded, E_FAIL or E_INVALIDARG otherwise
00584 //
00585 /////////////////////////////////////////////////////////
00586 HRESULT CAdvRecoApp::OnGesture(
00587         IInkCursor* /*pIInkCursor*/,
00588         IInkStrokes* pInkStrokes,
00589         VARIANT vGestures,
00590         VARIANT_BOOL* pbCancel
00591         )
00592 {
00593     if (((VT_ARRAY | VT_DISPATCH) != vGestures.vt) || (NULL == vGestures.parray))
00594         return E_INVALIDARG;
00595     if (0 == vGestures.parray->rgsabound->cElements)
00596         return E_INVALIDARG;
00597
00598     // The gestures in the array are supposed to be ordered by their recognition
00599     // confidence level. This sample picks up the top one.
00600     // NOTE: when in the InkAndGesture collection mode, besides the gestures expected
00601     // by the application there also can come a gesture object with the id IAG_NoGesture
00602     // This application cancels the event if the object with ISG_NoGesture has
00603     // the top confidence level (the first item in the array).
00604     InkApplicationGesture idGesture = IAG_NoGesture;
00605     IDispatch** ppIDispatch;
00606     HRESULT hr = ::SafeArrayAccessData(vGestures.parray, (void HUGEP**)&ppIDispatch);
00607     if (SUCCEEDED(hr))
00608     {
00609         CComQIPtr<IInkGesture> spIInkGesture(ppIDispatch[0]);
00610         if (spIInkGesture != NULL)
00611         {
00612             hr = spIInkGesture->get_Id(&idGesture);
00613         }
00614         ::SafeArrayUnaccessData(vGestures.parray);
00615     }
00616
00617     // Load the name of the gesture from the resource string table
00618     UINT idGestureName;
00619     bool bAccepted;     // will be true, if the gesture is known to this application
00620     if (IAG_NoGesture != idGesture)
00621     {
00622         bAccepted = GetGestureName(idGesture, idGestureName);
00623     }
00624     else    // ignore the event (IAG_NoGesture had the highest confidence level,
00625             // or something has failed
00626     {
00627         bAccepted = false;
00628         idGestureName = 0;
00629     }
00630
00631     // If the current collection mode is ICM_GestureOnly or if we accept
00632     // the gesture, the gesture's strokes will be removed from the ink object,
00633     // So, the window needs to be updated in the strokes' area.
00634     if (ID_MODE_GESTURES == m_nCmdMode || true == bAccepted)
00635     {
00636         // Get the rectangle to update.
00637         RECT rc;
00638         CComPtr<IInkRectangle> spIInkRect;
00639         if (m_spIInkRenderer != NULL
00640             && pInkStrokes != NULL
00641             && SUCCEEDED(pInkStrokes->GetBoundingBox(IBBM_Default, &spIInkRect))
00642             && SUCCEEDED(spIInkRect->GetRectangle(&rc.top, &rc.left,
00643                                                   &rc.bottom, &rc.right)))
00644         {
00645             // Transform the bounding box coordinates from ink space to screen
00646             HDC hdc = m_wndInput.GetDC();
00647             if (NULL != hdc)
00648             {
00649                 if (FAILED(m_spIInkRenderer->InkSpaceToPixel((long)hdc, &rc.left, &rc.top))
00650                     || FAILED(m_spIInkRenderer->InkSpaceToPixel((long)hdc, &rc.right,
00651                                                                 &rc.bottom)))
00652                 {
00653                     // Failed mapping from ink space to screen,
00654                     // update entire client area of the input window
00655                     m_wndInput.GetClientRect(&rc);
00656                 }
00657                 ReleaseDC(hdc);
00658             }
00659             else
00660             {
00661                 // Failed getting an hdc, update entire client area of the input window
00662                 m_wndInput.GetClientRect(&rc);
00663             }
00664         }
00665         else
00666         {
00667             // Failed getting the bounding box, update entire client area of the input window
00668             m_wndInput.GetClientRect(&rc);
00669         }
00670
00671         m_wndInput.InvalidateRect(&rc);
00672     }
00673     else // if something's failed,
00674          // or the gesture is either unknown or unchecked in the list
00675     {
00676         // Reject the gesture. The InkCollector will fire Stroke event(s)
00677         // for the strokes, so they'll be handled in the OnStroke method.
00678         *pbCancel = VARIANT_TRUE;
00679         idGestureName = IDS_GESTURE_UNKNOWN;
00680     }
00681
00682     // Update the results window as well
00683     m_wndResults.SetGestureName(idGestureName);
00684     m_wndResults.Invalidate();
00685
00686     return hr;
00687 }
00688
00689 // Recognition event handlers ////////////////////////////
00690
00691 /////////////////////////////////////////////////////////
00692 //
00693 // CAdvRecoApp::OnRecognitionWithAlternates
00694 //
00695 // The _IInkRecognitionEvents's RecognitionWithAlternates event handler
00696 //
00697 // Parameters:
00698 //      IInkRecognitionResult* pIInkRecoResult  :
00699 //      VARIANT vCustomParam                    : not used here
00700 //      InkRecognitionStatus RecognitionStatus  : not used here
00701 //
00702 // Return Values (HRESULT):
00703 //      S_OK if succeeded, E_FAIL or E_INVALIDARG otherwise
00704 //
00705 /////////////////////////////////////////////////////////
00706 HRESULT CAdvRecoApp::OnRecognitionWithAlternates(
00707         IInkRecognitionResult* pIInkRecoResult,
00708         VARIANT /*vCustomParam*/,
00709         InkRecognitionStatus /*RecognitionStatus*/
00710         )
00711 {
00712     if (NULL == pIInkRecoResult)
00713         return E_INVALIDARG;
00714
00715     // Reset the old results
00716     m_wndResults.ResetResults();
00717
00718     // Get the best lCount results
00719     HRESULT hr;
00720     CComPtr<IInkRecognitionAlternates> spIInkRecoAlternates;
00721     hr = pIInkRecoResult->AlternatesFromSelection(
00722         0,                              // in: selection start
00723         -1,                             // in: selection length; -1 means "up to the last one"
00724         CRecoOutputWnd::mc_iNumResults, // in: the number of alternates we're interested in
00725         &spIInkRecoAlternates           // out: the receiving pointer
00726         );
00727
00728     // Count the returned alternates, it may be less then we asked for
00729     long lCount = 0;
00730     if (SUCCEEDED(hr) && SUCCEEDED(spIInkRecoAlternates->get_Count(&lCount)))
00731     {
00732         // Get the alternate strings
00733         IInkRecognitionAlternate* pIInkRecoAlternate = NULL;
00734         for (LONG iItem = 0; (iItem < lCount) && (iItem < CRecoOutputWnd::mc_iNumResults); iItem++)
00735         {
00736             // Get the alternate string if there is one
00737             if (SUCCEEDED(spIInkRecoAlternates->Item(iItem, &pIInkRecoAlternate)))
00738             {
00739                 BSTR bstr = NULL;
00740                 if (SUCCEEDED(pIInkRecoAlternate->get_String(&bstr)))
00741                 {
00742                     m_wndResults.m_bstrResults[iItem].Attach(bstr);
00743                 }
00744                 pIInkRecoAlternate->Release();
00745             }
00746         }
00747     }
00748
00749     // Update the output window with the new results
00750     m_wndResults.Invalidate();
00751
00752     return S_OK;
00753 }
00754
00755 // Command handlers /////////////////////////////////////
00756
00757 /////////////////////////////////////////////////////////
00758 //
00759 // CAdvRecoApp::OnRecognizer
00760 //
00761 // This command handler is called when user selects a recognizer
00762 // from the "Recognizer" submenu.
00763 //
00764 // Parameters:
00765 //      defined in the ATL's macro COMMAND_RANGE_HANDLER
00766 //      Here only wID - the id of the command associated
00767 //      with the recognizer menu item -  is used.
00768 //
00769 // Return Values (LRESULT):
00770 //      always 0
00771 //
00772 /////////////////////////////////////////////////////////
00773 LRESULT CAdvRecoApp::OnRecognizer(
00774         WORD /*wNotifyCode*/,
00775         WORD wID,
00776         HWND /*hWndCtl*/,
00777         BOOL& /*bHandled*/
00778         )
00779 {
00780     if (m_spIInkRecognizers == NULL || wID == m_nCmdRecognizer)
00781         return 0;
00782
00783     // Get a pointer to the recognizer object from the recognizer collection
00784     // Use DefaultRecognizer method to get a pointer to the default recognizer
00785     // or use index for any other one
00786     HRESULT hr;
00787     CComPtr<IInkRecognizer> spIInkRecognizer;
00788     if (ID_RECOGNIZER_DEFAULT == wID)
00789     {
00790         // The first parameter is the language id, passing 0 means that the language
00791         // id will be retrieved using the user default-locale identifier
00792         hr = m_spIInkRecognizers->GetDefaultRecognizer(0, &spIInkRecognizer);
00793     }
00794     else
00795     {
00796         hr = m_spIInkRecognizers->Item(wID - ID_RECOGNIZER_FIRST, &spIInkRecognizer);
00797     }
00798
00799     // Create new recognition context
00800     if (SUCCEEDED(hr) && UseRecognizer(spIInkRecognizer))
00801     {
00802         // Update the menu and the status bar
00803         UpdateMenuRadioItems(mc_iSubmenuRecognizers, wID, m_nCmdRecognizer);
00804         m_bstrCurRecoName.Empty();
00805         spIInkRecognizer->get_Name(&m_bstrCurRecoName);
00806         UpdateStatusBar();
00807         // Store the selected recognizer's command id
00808         m_nCmdRecognizer = wID;
00809     }
00810
00811     return 0;
00812 }
00813
00814 /////////////////////////////////////////////////////////
00815 //
00816 // CAdvRecoApp::OnInputScopeCoerce
00817 //
00818 // This command handler is called when user checks on or off
00819 // the "Coerce to InputScope’" menu item in the "InputScope" submenu.
00820 //
00821 // Parameters:
00822 //      defined in the ATL's macro COMMAND_ID_HANDLER
00823 //      Only wID - the id of the command associated
00824 //      with the clicked menu item - is used here.
00825 //
00826 // Return Values (LRESULT):
00827 //      always 0
00828 //
00829 /////////////////////////////////////////////////////////
00830 LRESULT CAdvRecoApp::OnInputScopeCoerce(
00831         WORD /*wNotifyCode*/,
00832         WORD wID,
00833         HWND /*hWndCtl*/,
00834         BOOL& /*bHandled*/
00835         )
00836 {
00837     // Ignore the command if the recognition context
00838     // has not been created
00839     if (m_spIInkRecoContext == NULL )
00840         return 0;
00841
00842     // Need to reset the recognition context to modify the property
00843     if (m_spIInkStrokes != NULL)
00844     {
00845         m_spIInkRecoContext->putref_Strokes(NULL);
00846     }
00847
00848     // Reset the RecognitionFlags property of the recognition context
00849     if (FAILED(m_spIInkRecoContext->put_RecognitionFlags (m_bCoerceInputScope?IRM_None:IRM_Coerce)))
00850     {
00851         MessageBox(TEXT("Failed to reset the RecognitionFlags property!"),
00852                          gc_szAppName, MB_ICONERROR | MB_OK);
00853
00854         // Re-attach the stroke collection to the context
00855         if (m_spIInkStrokes != NULL)
00856         {
00857             m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);
00858         }
00859         return 0;
00860     }
00861
00862     m_bCoerceInputScope = !m_bCoerceInputScope;
00863
00864     // Re-attach the stroke collection to the context
00865     if (m_spIInkStrokes != NULL)
00866     {
00867         m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);
00868     }
00869
00870     // Update the recognition results
00871     CComVariant vCustomData;    // no custom data
00872     m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);
00873
00874     // Update the menu item
00875     HMENU hMenu = GetMenu();
00876     if (NULL != hMenu)
00877     {
00878         HMENU hSubMenu = ::GetSubMenu(hMenu, mc_iSubmenuInputScopes);
00879         if (NULL != hSubMenu)
00880         {
00881             ::CheckMenuItem(hSubMenu, wID,
00882                             MF_BYCOMMAND | (m_bCoerceInputScope ? MF_CHECKED : MF_UNCHECKED));
00883         }
00884     }
00885
00886     return 0;
00887 }
00888
00889 /////////////////////////////////////////////////////////
00890 //
00891 // CAdvRecoApp::OnInputScope
00892 //
00893 // This command handler is called when user selects
00894 // a input scope name in the "Input Scope" submenu.
00895 //
00896 // Parameters:
00897 //      defined in the ATL's macro COMMAND_RANGE_HANDLER
00898 //      Only wID - the id of the command associated
00899 //      with the clicked menu item - is used here.
00900 //
00901 // Return Values (LRESULT):
00902 //      always 0
00903 //
00904 /////////////////////////////////////////////////////////
00905 LRESULT CAdvRecoApp::OnInputScope(
00906         WORD /*wNotifyCode*/,
00907         WORD wID,
00908         HWND /*hWndCtl*/,
00909         BOOL& /*bHandled*/
00910         )
00911 {
00912     UINT iInputScope = wID - ID_INPUTSCOPE_FIRST;     // get the index to gc_pwsInputScopes
00913     // Return if user clicks on the currently selected Input Scope menu item or if
00914     // the command id is not in the valid range (shouldn't happen with error free code)
00915     if (wID == m_nCmdInputScope || iInputScope >= countof(gc_pwsInputScopes))
00916         return 0;
00917
00918     // Tell the context to use the Input Scope, by assigning the input scope name
00919     // to the corresponding property of the context.
00920     if (m_spIInkRecoContext != NULL)
00921     {
00922         // Need to reset the recognition context in order to change the property
00923         if (m_spIInkStrokes != NULL)
00924         {
00925             m_spIInkRecoContext->putref_Strokes(NULL);
00926         }
00927
00928         CComBSTR bstrInputScope(gc_pwsInputScopes[iInputScope]);
00929         HRESULT hr = m_spIInkRecoContext->put_Factoid(bstrInputScope);
00930
00931         // Re-attach the stroke collection to the context
00932         if (m_spIInkStrokes != NULL)
00933         {
00934             m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);
00935         }
00936
00937         if (SUCCEEDED(hr))
00938         {
00939             // Update the recognition results
00940             CComVariant vCustomData;    // no custom data
00941             m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);
00942         }
00943         else if (TPC_E_INVALID_PROPERTY == hr) // the input scope is not supported
00944         {
00945             MessageBox(TEXT("This factoid is not supported by the recognizer."),
00946                        gc_szAppName, MB_ICONINFORMATION | MB_OK);
00947             return 0;
00948         }
00949         else
00950         {
00951             MessageBox(TEXT("Failed to set the context's Factoid property!"),
00952                        gc_szAppName, MB_ICONERROR | MB_OK);
00953             return 0;
00954         }
00955     }
00956
00957     // Update the menu and the status bar
00958     UpdateMenuRadioItems(mc_iSubmenuInputScopes, wID, m_nCmdInputScope);
00959     m_nCmdInputScope = wID;
00960     UpdateStatusBar();
00961
00962     return 0;
00963 }
00964
00965 /////////////////////////////////////////////////////////
00966 //
00967 // CAdvRecoApp::OnGuide
00968 //
00969 // This command handler is called when user selects a type
00970 // of the recognition guide in the "Guide" submenu.
00971 //
00972 // Parameters:
00973 //      defined in the ATL's macro COMMAND_RANGE_HANDLER
00974 //      Only wID - the id of the command associated
00975 //      with the clicked menu item - is used here.
00976 //
00977 // Return Values (LRESULT):
00978 //      always 0
00979 //
00980 /////////////////////////////////////////////////////////
00981 LRESULT CAdvRecoApp::OnGuide(
00982         WORD /*wNotifyCode*/,
00983         WORD wID,
00984         HWND /*hWndCtl*/,
00985         BOOL& /*bHandled*/
00986         )
00987 {
00988     // Do nothing, if the InkRecoGuide object was not created,
00989     // or user selected the currently used type of guide.
00990     if (m_spIInkRecoGuide == NULL || wID == m_nCmdGuide)
00991         return 0;
00992
00993     // The sizes of the drawing and writing boxes of the guide were set
00994     // in CAdvRecoApp::OnCreate, when the guide object was created.
00995     // There is no need to modify them in order to switch the guide from
00996     // one type to another. This can be done by setting the guides properties
00997     // Rows and Columns to 0 or not 0.
00998     int cRows = 0, cColumns = 0;
00999     if (ID_GUIDE_LINES == wID || ID_GUIDE_BOXES == wID)
01000     {
01001         cRows = mc_iNumRowsCols;
01002         if (ID_GUIDE_BOXES == wID)
01003         {
01004             cColumns = mc_iNumRowsCols;
01005         }
01006     }
01007
01008     // Put the new values
01009     if (SUCCEEDED(m_spIInkRecoGuide->put_Rows(cRows))
01010         && SUCCEEDED(m_spIInkRecoGuide->put_Columns(cColumns)))
01011     {
01012         HRESULT hr = S_OK;
01013         if (m_spIInkRecoContext != NULL)
01014         {
01015             // Need to reset the recognition context in order to change the property
01016             if (m_spIInkStrokes != NULL)
01017             {
01018                 m_spIInkRecoContext->putref_Strokes(NULL);
01019             }
01020
01021             // Set the updated guide
01022             hr = m_spIInkRecoContext->putref_Guide(m_spIInkRecoGuide);
01023
01024             // Re-attach the stroke collection to the context
01025             if (m_spIInkStrokes != NULL)
01026             {
01027                 m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);
01028             }
01029
01030             // Update the recognition results
01031             CComVariant vCustomData;    // no custom data
01032             m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);
01033         }
01034
01035         if (SUCCEEDED(hr))
01036         {
01037             // Update the input window (this call will force it to redraw the guide).
01038             m_wndInput.SetRowsCols(cRows, cColumns);
01039
01040             // Update the menu
01041             UpdateMenuRadioItems(mc_iSubmenuGuides, wID, m_nCmdGuide);
01042
01043             // store the selected guide's associated command id
01044             m_nCmdGuide = wID;
01045         }
01046         else
01047         {
01048             MessageBox(TEXT("Error setting the guide to the recognition context.\n"),
01049                        gc_szAppName, MB_ICONERROR | MB_OK);
01050         }
01051     }
01052     else
01053     {
01054         MessageBox(TEXT("Error setting the guide's Rows and/or Columns property.\n"),
01055                    gc_szAppName, MB_ICONERROR | MB_OK);
01056     }
01057
01058     return 0;
01059 }
01060
01061 /////////////////////////////////////////////////////////
01062 //
01063 // CAdvRecoApp::OnMode
01064 //
01065 // This command handler is called when user selects
01066 // a different collection mode from the "Mode" submenu.
01067 // NOTE: Changing collection mode has no effect on
01068 //       the recognition results of the existing strokes.
01069 //
01070 // Parameters:
01071 //      defined in the ATL's macro COMMAND_RANGE_HANDLER
01072 //      Only wID - the id of the command associated
01073 //      with the clicked menu item - is used here.
01074 //
01075 // Return Values (LRESULT):
01076 //      always 0
01077 //
01078 /////////////////////////////////////////////////////////
01079 LRESULT CAdvRecoApp::OnMode(
01080         WORD /*wNotifyCode*/,
01081         WORD wID,
01082         HWND /*hWndCtl*/,
01083         BOOL& /*bHandled*/
01084         )
01085 {
01086     // Do nothing, id user selected the same mode.
01087     if (wID == m_nCmdMode)
01088         return 0;
01089
01090     InkCollectionMode icm;
01091     switch (wID)
01092     {
01093         default:
01094             return 0;
01095         case ID_MODE_INK:
01096             icm = ICM_InkOnly;
01097             break;
01098         case ID_MODE_INK_AND_GESTURES:
01099             icm = ICM_InkAndGesture;
01100             break;
01101         case ID_MODE_GESTURES:
01102             icm = ICM_GestureOnly;
01103             break;
01104     }
01105
01106     // Disable input to switch the collection mode
01107     if (m_spIInkCollector != NULL
01108         && SUCCEEDED(m_spIInkCollector->put_Enabled(VARIANT_FALSE)))
01109     {
01110         // Set the new mode
01111         if (SUCCEEDED(m_spIInkCollector->put_CollectionMode(icm)))
01112         {
01113
01114             // Update the menu
01115             UpdateMenuRadioItems(mc_iSubmenuModes, wID, m_nCmdMode);
01116             m_nCmdMode = wID;  // store the selected mode's associated command id
01117
01118             // Show or hide the gesture list views
01119             UpdateLayout();
01120         }
01121         else
01122         {
01123             TCHAR* pszErrorMsg;
01124             if (ID_MODE_INK == m_nCmdMode)
01125             {
01126                 pszErrorMsg = TEXT("Unable to change the CollectionMode property on the ")
01127                               TEXT("InkCollector.\nA possible reason is that the selected ")
01128                               TEXT("mode requires there to be a gesture recognizer installed.");
01129             }
01130             else
01131             {
01132                 pszErrorMsg = TEXT("Unable to change the CollectionMode property ")
01133                               TEXT("on the InkCollector.");
01134             }
01135             MessageBox(pszErrorMsg, gc_szAppName, MB_ICONERROR | MB_OK);
01136         }
01137         // Enable input
01138         if (FAILED(m_spIInkCollector->put_Enabled(VARIANT_TRUE)))
01139         {
01140             MessageBox(TEXT("Error enabling InkCollector after changing collection mode!"),
01141                        gc_szAppName, MB_ICONERROR | MB_OK);
01142         }
01143     }
01144
01145     return 0;
01146 }
01147
01148 /////////////////////////////////////////////////////////
01149 //
01150 // CAdvRecoApp::OnRecognize
01151 //
01152 // This command handler is called when user clicks on "Recognize"
01153 // in the Ink menu.
01154 // It's required for East Asian recognizers to finalize the recognition
01155 //
01156 // Parameters:
01157 //      defined in the ATL's macro COMMAND_ID_HANDLER
01158 //      none of them is used here
01159 //
01160 // Return Values (LRESULT):
01161 //      always 0
01162 //
01163 /////////////////////////////////////////////////////////
01164 LRESULT CAdvRecoApp::OnRecognize(
01165         WORD /*wNotifyCode*/,
01166         WORD /*wID*/,
01167         HWND /*hWndCtl*/,
01168         BOOL& /*bHandled*/
01169         )
01170 {
01171     if (m_spIInkRecoContext != NULL)
01172     {
01173         m_spIInkRecoContext->EndInkInput();
01174
01175         // Recognize
01176         CComPtr<IInkRecognitionResult> spIInkRecoResult;
01177         InkRecognitionStatus ink_reco_status = IRS_NoError;
01178         if (SUCCEEDED(m_spIInkRecoContext->Recognize(&ink_reco_status, &spIInkRecoResult)))
01179         {
01180             CComVariant vCustomData;    // no custom data
01181             OnRecognitionWithAlternates(spIInkRecoResult, vCustomData, ink_reco_status);
01182         }
01183         else
01184         {
01185             MessageBox(TEXT("Error code returned from the context's Recognize method."),
01186                        gc_szAppName, MB_ICONERROR | MB_OK);
01187         }
01188
01189         // Re-attach the stroke collection to the context
01190         if (m_spIInkStrokes != NULL)
01191         {
01192             if (FAILED(m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes)))
01193             {
01194                 MessageBox(TEXT("Failed to attach the stroke collection to the recognition context!"),
01195                            gc_szAppName, MB_ICONERROR | MB_OK);
01196             }
01197         }
01198     }
01199
01200     return 0;
01201 }
01202
01203 /////////////////////////////////////////////////////////
01204 //
01205 // CAdvRecoApp::OnClear
01206 //
01207 // This command handler is called when user clicks on "Clear"
01208 // in the Ink menu. It's supposed to delete the collected ink,
01209 // and update the child windows after that.
01210 //
01211 // Parameters:
01212 //      defined in the ATL's macro COMMAND_ID_HANDLER
01213 //      none of them is used here
01214 //
01215 // Return Values (LRESULT):
01216 //      always 0
01217 //
01218 /////////////////////////////////////////////////////////
01219 LRESULT CAdvRecoApp::OnClear(
01220         WORD /*wNotifyCode*/,
01221         WORD /*wID*/,
01222         HWND /*hWndCtl*/,
01223         BOOL& /*bHandled*/
01224         )
01225 {
01226     if (m_spIInkDisp != NULL)
01227     {
01228         // Delete all strokes from the Ink object, ignore returned value
01229         m_spIInkDisp->DeleteStrokes(0);
01230
01231         // Release the old stroke collection and get an empty one
01232         m_spIInkStrokes.Release();
01233         CComVariant vt(0);
01234         if (FAILED(m_spIInkDisp->CreateStrokes(vt, &m_spIInkStrokes)))
01235         {
01236             MessageBox(TEXT("Failed to get the stroke collection from the Ink object!"),
01237                        gc_szAppName, MB_ICONERROR | MB_OK);
01238         }
01239
01240         // Attach the new stroke collection to the recognition context.
01241         // If get_Strokes has failed, m_spIInkStrokes is NULL, so no
01242         // stroke collection will be attached to the context
01243         if (m_spIInkRecoContext != NULL)
01244         {
01245             if (FAILED(m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes)))
01246             {
01247                 MessageBox(TEXT("Failed to attach the stroke collection to the recognition context!"),
01248                            gc_szAppName, MB_ICONERROR | MB_OK);
01249             }
01250         }
01251     }
01252
01253     // Update the child windows
01254     m_wndResults.ResetResults();    // empties the strings
01255     m_wndResults.Invalidate();
01256     m_wndInput.Invalidate();
01257
01258     return 0;
01259 }
01260
01261
01262 /////////////////////////////////////////////////////////
01263 //
01264 // CAdvRecoApp::OnExit
01265 //
01266 // This command handler is called when user clicks
01267 // on "Exit" in the Ink menu.
01268 //
01269 // Parameters:
01270 //      defined in the ATL's macro COMMAND_ID_HANDLER
01271 //      none of them is used here
01272 //
01273 // Return Values (LRESULT):
01274 //      always 0
01275 //
01276 /////////////////////////////////////////////////////////
01277 LRESULT CAdvRecoApp::OnExit(
01278         WORD /*wNotifyCode*/,
01279         WORD /*wID*/,
01280         HWND /*hWndCtl*/,
01281         BOOL& /*bHandled*/
01282         )
01283 {
01284     // Close the application window
01285     SendMessage(WM_CLOSE);
01286     return 0;
01287 }
01288
01289 // Helper methods //////////////////////////////
01290
01291 /////////////////////////////////////////////////////////
01292 //
01293 // CAdvRecoApp::LoadMenu
01294 //
01295 // This method instantiates an enumerator object for the installed
01296 // recognizers, loads the main menu resource and creates a menu item
01297 // for each recognizer from the collection.
01298 // Also, it fills the Input Scope menu with the items for the supported
01299 // Input Scopes.
01300 //
01301 // Parameters:
01302 //      none
01303 //
01304 // Return Values (HMENU):
01305 //      The return value is a handle of the menu
01306 //      that'll be used for the main window
01307 //
01308 /////////////////////////////////////////////////////////
01309 HMENU CAdvRecoApp::LoadMenu()
01310 {
01311     HRESULT hr = S_OK;
01312
01313     // Create the enumerator for the installed recognizers
01314     hr = m_spIInkRecognizers.CoCreateInstance(CLSID_InkRecognizers);
01315     if (FAILED(hr))
01316         return NULL;
01317
01318     // Get the number of the recognizers known to the system
01319     LONG lCount = 0;
01320     hr = m_spIInkRecognizers->get_Count(&lCount);
01321     if (0 == lCount)
01322     {
01323         ::MessageBox(NULL, TEXT("There are no handwriting recognizers installed.\n")
01324                      TEXT("You need to have at least one in order to run this sample.\nExiting."),
01325                      gc_szAppName, MB_ICONERROR | MB_OK);
01326         return NULL;
01327     }
01328
01329     // Load the menu of the main window
01330     HMENU hMenu = ::LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MENU));
01331     if (NULL == hMenu)
01332         return NULL; // Not normal
01333
01334     MENUITEMINFOW miinfo;
01335     memset(&miinfo, 0, sizeof(miinfo));
01336     miinfo.cbSize = sizeof(miinfo);
01337     miinfo.fMask = MIIM_ID | MIIM_STATE | MIIM_FTYPE | MIIM_STRING;
01338     miinfo.fType = MFT_RADIOCHECK | MFT_STRING;
01339
01340     // Get the submenu id for the recognizers menu.
01341     // This submenu will contain the list of installed recognizers
01342     HMENU hSubMenu = ::GetSubMenu(hMenu, mc_iSubmenuRecognizers);
01343     if (hSubMenu)
01344     {
01345         CComPtr<IInkRecognizer> spIInkRecognizer;
01346
01347         // The ID_RECOGNIZER_FIRST is defined in the resource.h file.
01348         // It's the base id for the commands that fill this submenu
01349         miinfo.wID = ID_RECOGNIZER_FIRST;
01350         miinfo.fState = 0;
01351         for (LONG i = 0; i < lCount; i++, miinfo.wID++)
01352         {
01353             if (FAILED(m_spIInkRecognizers->Item(i, &spIInkRecognizer)))
01354                 continue;
01355
01356             // Filter out non-language recognizers by checking for
01357             // the languages supported by the recognizer - there'll be
01358             // none if it's a gesture or object recognizer.
01359             CComVariant vLanguages;
01360             if (SUCCEEDED(spIInkRecognizer->get_Languages(&vLanguages)))
01361             {
01362                 if ((VT_ARRAY == (VT_ARRAY & vLanguages.vt))            // it should be an array
01363                     && (NULL != vLanguages.parray)
01364                     && (0 < vLanguages.parray->rgsabound[0].cElements)) // with at least one element
01365                 {
01366                     CComBSTR bstrName;
01367                     if (SUCCEEDED(spIInkRecognizer->get_Name(&bstrName)))
01368                     {
01369                         miinfo.dwTypeData = bstrName;
01370                         ::InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &miinfo);
01371                     }
01372                 }
01373                 spIInkRecognizer.Release();
01374             }
01375         }
01376     }
01377
01378     // Get the Input Scope submenu and create command items
01379     // for each input scope name defined in gc_pwsInputScopes[]
01380     hSubMenu = ::GetSubMenu(hMenu, mc_iSubmenuInputScopes);
01381     if (hSubMenu)
01382     {
01383         // The ID_INPUTSCOPE_FIRST is defined in the resource.h file.
01384         // It's the base id for the commands that fill this submenu
01385         miinfo.wID = ID_INPUTSCOPE_FIRST;
01386         miinfo.fState = 0;
01387         lCount = countof(gc_pwsInputScopes);
01388         for(LONG i = 0; i < lCount; i++, miinfo.wID++)
01389         {
01390
01391             // Set the input scope menu item text.  If the text
01392             // length exceeds the maximum allowed value, then truncate
01393             // it and append "...".
01394             if (wcslen(gc_pwsInputScopes[i]) <= gc_lMaxInputScopeMenuItemLength)
01395             {
01396                 miinfo.dwTypeData = gc_pwsInputScopes[i];
01397             }
01398             else
01399             {
01400                 CComBSTR bstrInputScope(gc_lMaxInputScopeMenuItemLength-3, gc_pwsInputScopes[i]);
01401                 bstrInputScope += L"...";
01402                 miinfo.dwTypeData = bstrInputScope;
01403             }
01404
01405             ::InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &miinfo);
01406         }
01407     }
01408
01409     return hMenu;
01410 }
01411
01412
01413 /////////////////////////////////////////////////////////
01414 //
01415 // CAdvRecoApp::UpdateInputScopeMenu
01416 //
01417 // This helper method updates the enabled/disabled state
01418 // of submenus in the InputScope menu.
01419 // It's called whenever the user selects a different
01420 // recognizer. Verification of support for the InputScope
01421 // is accomplished by calling put_Factoid, and checking
01422 // the returned HRESULT.
01423 //
01424 // Parameters:
01425 //      none
01426 //
01427 // Return Values (void):
01428 //      none
01429 //
01430 /////////////////////////////////////////////////////////
01431 void CAdvRecoApp::UpdateInputScopeMenu()
01432 {
01433     HMENU hMenu = GetMenu();
01434     if (NULL != hMenu)
01435     {
01436         HMENU hSubMenu = ::GetSubMenu(hMenu, mc_iSubmenuInputScopes);
01437         if (NULL != hSubMenu)
01438         {
01439             if (m_spIInkRecoContext != NULL)
01440             {
01441                 // Cache the current Factoid property so that we can revert later
01442                 CComBSTR bstrInputScope;
01443                 if (FAILED(m_spIInkRecoContext->get_Factoid(&bstrInputScope)))
01444                 {
01445                     MessageBox(TEXT("Failed to get the context's Factoid property."),
01446                                 gc_szAppName, MB_ICONERROR | MB_OK);
01447                     return;
01448                 }
01449
01450                 // Need to reset the recognition context in order to change the Factoid property
01451                 if (m_spIInkStrokes != NULL)
01452                 {
01453                     m_spIInkRecoContext->putref_Strokes(NULL);
01454                 }
01455
01456                 // Enable or disable the InputScope submenu items
01457                 MENUITEMINFO miinfo;
01458                 memset(&miinfo, 0, sizeof(miinfo));
01459                 miinfo.cbSize = sizeof(miinfo);
01460                 miinfo.fMask = MIIM_STATE;
01461                 miinfo.wID = ID_INPUTSCOPE_FIRST;
01462                 for(LONG i = 0; i < countof(gc_pwsInputScopes); i++, miinfo.wID++)
01463                 {
01464                     CComBSTR bstrTestInputScope(gc_pwsInputScopes[i]);
01465                     HRESULT hr = m_spIInkRecoContext->put_Factoid(bstrTestInputScope);
01466                     if (FAILED(hr))
01467                     {
01468                         miinfo.fState = MFS_DISABLED;
01469                     }
01470                     else
01471                     {
01472                         miinfo.fState = MFS_ENABLED;
01473                     }
01474                     ::SetMenuItemInfo(hSubMenu, miinfo.wID, FALSE, &miinfo);
01475
01476                 }
01477
01478                 // Revert to the cached Factoid property
01479                 if (FAILED(m_spIInkRecoContext->put_Factoid(bstrInputScope)))
01480                 {
01481                     MessageBox(TEXT("Failed to set the context's Factoid property."),
01482                                 gc_szAppName, MB_ICONERROR | MB_OK);
01483                 }
01484
01485                 // Re-attach the stroke collection to the context
01486                 if (m_spIInkStrokes != NULL)
01487                 {
01488                     m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);
01489                 }
01490             }
01491         }
01492     }
01493 }
01494
01495 /////////////////////////////////////////////////////////
01496 //
01497 // CAdvRecoApp::UpdateMenuRadioItems
01498 //
01499 // As it follows from the name, this helper method updates
01500 // the specified radio items in the submenu.
01501 // It's called for the appropriate items, whenever user selects
01502 // a different recognizer, input scope, or guide mode.
01503 //
01504 // Parameters:
01505 //      UINT iSubMenu   : [in] the submenu to make updates in
01506 //      UINT idCheck    : [in] the menu item to check
01507 //      UINT idUncheck  : [in] the menu item to uncheck
01508 //
01509 // Return Values (void):
01510 //      none
01511 //
01512 /////////////////////////////////////////////////////////
01513 void CAdvRecoApp::UpdateMenuRadioItems(
01514         UINT iSubMenu,
01515         UINT idCheck,
01516         UINT idUncheck
01517         )
01518 {
01519     // Update the menu
01520     HMENU hMenu = GetMenu();
01521     if (NULL != hMenu)
01522     {
01523         HMENU hSubMenu = ::GetSubMenu(hMenu, iSubMenu);
01524         if (NULL != hSubMenu)
01525         {
01526             MENUITEMINFO miinfo;
01527             miinfo.cbSize = sizeof(miinfo);
01528             miinfo.fMask = MIIM_STATE | MIIM_FTYPE;
01529             ::GetMenuItemInfo(hSubMenu, idCheck, FALSE, &miinfo);
01530             miinfo.fType |= MFT_RADIOCHECK;
01531             miinfo.fState |= MFS_CHECKED;
01532             ::SetMenuItemInfo(hSubMenu, idCheck, FALSE, &miinfo);
01533             if (0 != idUncheck)
01534             {
01535                 ::GetMenuItemInfo(hSubMenu, idUncheck, FALSE, &miinfo);
01536                 miinfo.fType |= MFT_RADIOCHECK;
01537                 miinfo.fState &= ~MFS_CHECKED;
01538                 ::SetMenuItemInfo(hSubMenu, idUncheck, FALSE, &miinfo);
01539             }
01540         }
01541     }
01542 }
01543
01544 /////////////////////////////////////////////////////////
01545 //
01546 // CAdvRecoApp::UseRecognizer
01547 //
01548 // As it follows from the name, this helper method updates
01549 // the specified radio items in the submenu.
01550 // It's called for the appropriate items, whenever user selects
01551 // a different recognizer, input scope, or guide mode.
01552 //
01553 // Parameters:
01554 //      IInkRecognizer* pIInkRecognizer   : [in] the newly selected recognizer
01555 //
01556 // Return Values (bool):
01557 //      true if succeeded creating new recognition context, false otherwise
01558 //
01559 /////////////////////////////////////////////////////////
01560 bool CAdvRecoApp::UseRecognizer(
01561         IInkRecognizer* pIInkRecognizer
01562         )
01563 {
01564
01565     if (NULL == pIInkRecognizer)
01566         return false;
01567
01568     // Create a new recognition context
01569     CComPtr<IInkRecognizerContext> spNewContext;
01570     HRESULT hr = pIInkRecognizer->CreateRecognizerContext(&spNewContext);
01571     if (FAILED(hr))
01572     {
01573         MessageBox(TEXT("Error creating a new recognition context!"),
01574                    gc_szAppName, MB_ICONERROR | MB_OK);
01575         return false;
01576     }
01577
01578     // Change cursor to the system's Hourglass
01579     HCURSOR hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));
01580
01581     // Detach and release the old context
01582     if (m_spIInkRecoContext != NULL)
01583     {
01584         // Disconnect from the recognition events source
01585         IInkRecognitionEventsImpl<CAdvRecoApp>::DispEventUnadvise(m_spIInkRecoContext);
01586
01587         // Reset and release the recognition context
01588         m_spIInkRecoContext->putref_Strokes(NULL);
01589         m_spIInkRecoContext.Release();
01590     }
01591
01592     // Establish a connection with the recognition context's event source
01593     hr = IInkRecognitionEventsImpl<CAdvRecoApp>::DispEventAdvise(spNewContext);
01594     if (FAILED(hr))
01595     {
01596         MessageBox(TEXT("Error connecting to the recognition context's event source!"),
01597                    gc_szAppName, MB_ICONERROR | MB_OK);
01598     }
01599
01600     // Get the recognizer's capabilities flags.
01601     // (use IRC__DontCare if get_Capabilities fails)
01602     InkRecognizerCapabilities dwCapabilities;
01603     if (FAILED(pIInkRecognizer->get_Capabilities(&dwCapabilities)))
01604     {
01605         dwCapabilities = IRC_DontCare;
01606     }
01607
01608     // Update the Guide menu items
01609     const UINT nGuideCmds[] = {ID_GUIDE_BOXES, ID_GUIDE_LINES, ID_GUIDE_NONE};
01610     const UINT nGuideFlags[] = {IRC_BoxedInput, IRC_LinedInput, IRC_FreeInput};
01611     HMENU hMenu = GetMenu();
01612     HMENU hSubMenu = hMenu ? ::GetSubMenu(hMenu, mc_iSubmenuGuides) : NULL;
01613     UINT nCmdGuid = 0;
01614     for (int i = 0; i < countof(nGuideCmds) && i < countof(nGuideFlags); i++)
01615     {
01616         UINT nFlags;
01617         if (m_spIInkRecoGuide != NULL &&
01618             (((nGuideFlags[i] & dwCapabilities) == nGuideFlags[i])
01619             || ((IRC_DontCare & dwCapabilities) == IRC_DontCare)))
01620         {
01621             nFlags = MF_BYCOMMAND | MF_ENABLED;
01622             if ((0 == nCmdGuid) || (nGuideCmds[i] == m_nCmdGuide))
01623             {
01624                 nCmdGuid = nGuideCmds[i];
01625             }
01626         }
01627         else
01628         {
01629             nFlags = MF_BYCOMMAND | MF_GRAYED;
01630         }
01631         // Update the menu item
01632         if (NULL != hSubMenu)
01633         {
01634             ::EnableMenuItem(hSubMenu, nGuideCmds[i], nFlags);
01635         }
01636     }
01637
01638     // Change the guide selection if the current guide is not supported by the recognizer
01639     if (m_nCmdGuide != nCmdGuid)
01640     {
01641         SendMessage(WM_COMMAND, nCmdGuid);
01642     }
01643
01644     // Set the recognition context properties before attaching the stroke collection to it
01645
01646     // Set the guide
01647     if (m_spIInkRecoGuide != NULL && 0 != m_nCmdGuide)
01648     {
01649         if (FAILED(spNewContext->putref_Guide(m_spIInkRecoGuide)))
01650         {
01651             MessageBox(TEXT("Failed to set guide to the new recognition context!"),
01652                        gc_szAppName, MB_ICONERROR | MB_OK);
01653         }
01654     }
01655
01656     // Clear currently set input scope. -1 is being used to indicate no input scope
01657     m_nCmdInputScope = -1;
01658     m_bCoerceInputScope = false;
01659
01660     // Reset the Input Scope to baseline
01661     CComBSTR bstrFactoid(FACTOID_DEFAULT);
01662     if (FAILED(spNewContext->put_Factoid(bstrFactoid)))
01663     {
01664         MessageBox(TEXT("Failed to set factoid to the new recognition context!"),
01665                          gc_szAppName, MB_ICONERROR | MB_OK);
01666     }
01667
01668     // Attach the stroke collection to the context
01669     hr = spNewContext->putref_Strokes(m_spIInkStrokes);
01670     if (FAILED(hr))
01671     {
01672         MessageBox(TEXT("Error attaching the stroke collection to the new recognition context!"),
01673                    gc_szAppName, MB_ICONERROR | MB_OK);
01674     }
01675
01676     // Use the new context
01677     m_spIInkRecoContext.Attach(spNewContext.Detach());
01678
01679     // Update the radio item check state of the input scope menu
01680     UpdateMenuRadioItems(mc_iSubmenuInputScopes, ID_INPUTSCOPE_FIRST, m_nCmdInputScope);
01681
01682     // Update the enabled/disabled state of the input scope menu
01683     UpdateInputScopeMenu();
01684
01685     // Update the coerce input scope menu item
01686     hSubMenu = hMenu ? ::GetSubMenu(hMenu, mc_iSubmenuInputScopes) : NULL;
01687     if (NULL != hSubMenu)
01688     {
01689         ::CheckMenuItem(hSubMenu, ID_INPUTSCOPE_COERCE, MF_BYCOMMAND | MF_UNCHECKED);
01690     }
01691
01692     // Select an appropriate font for the recognition output
01693     LANGID wLandId = ::GetUserDefaultLangID();
01694     CComVariant vLangIDs;
01695     if (SUCCEEDED(pIInkRecognizer->get_Languages(&vLangIDs)) && NULL != vLangIDs.parray)
01696     {
01697         WORD* pwLIDs;
01698         if (SUCCEEDED(::SafeArrayAccessData(vLangIDs.parray, (void HUGEP**)&pwLIDs)))
01699         {
01700             wLandId = pwLIDs[0];
01701             ::SafeArrayUnaccessData(vLangIDs.parray);
01702         }
01703     }
01704     if (false == m_wndResults.UpdateFont(wLandId))
01705     {
01706         MessageBox(TEXT("Can not find an appropriate font for the selected recognizer.\n")
01707                    TEXT("The default font will be used for text output"), gc_szAppName);
01708     }
01709
01710     // Reset the current results
01711     m_wndResults.ResetResults();
01712     m_wndResults.Invalidate();
01713
01714     // Update the recognition results
01715     CComVariant vCustomData;    // no custom data
01716     m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);
01717
01718     // restore the cursor
01719     ::SetCursor(hCursor);
01720
01721     return true;
01722 }
01723
01724 /////////////////////////////////////////////////////////
01725 //
01726 // CAdvRecoApp::OnLVColumnClick
01727 //
01728 // When user clicks on the column header in either of the gesture
01729 // listview controls, the CAdvRecoApp object receives a WM_NOTIFY
01730 // message that is mapped to this handler for the actual processing.
01731 // The application checks or unchecks all the items in the control
01732 // the notification came from.
01733 //
01734 // Parameters:
01735 //      defined in the ATL's macro NOTIFY_HANDLER
01736 //
01737 // Return Values (LRESULT):
01738 //      always 0
01739 //
01740 /////////////////////////////////////////////////////////
01741 LRESULT CAdvRecoApp::OnLVColumnClick(
01742         int idCtrl,
01743         LPNMHDR /*pnmh*/,
01744         BOOL& bHandled
01745         )
01746 {
01747     if (mc_iSSGestLVId == idCtrl)
01748     {
01749         m_bAllSSGestures = !m_bAllSSGestures;
01750         ListView_SetCheckState(m_hwndSSGestLV, -1, m_bAllSSGestures);
01751     }
01752     else if (mc_iMSGestLVId == idCtrl)
01753     {
01754         m_bAllMSGestures = !m_bAllMSGestures;
01755         ListView_SetCheckState(m_hwndMSGestLV, -1, m_bAllMSGestures);
01756     }
01757     else
01758     {
01759         bHandled = FALSE;
01760     }
01761
01762     return 0;
01763 }
01764
01765 /////////////////////////////////////////////////////////
01766 //
01767 // CAdvRecoApp::OnLVItemChanging
01768 //
01769 // When user checks or unchecks an item in either of the gesture
01770 // listview controls, the state of the item is changing and the CAdvRecoApp
01771 // object receives a WM_NOTIFY message that is mapped to this handler
01772 // for the actual processing.
01773 // The application set or reset the gesture status in the InkCollector.
01774 //
01775 // Parameters:
01776 //      defined in the ATL's macro NOTIFY_HANDLER
01777 //
01778 // Return Values (LRESULT):
01779 //      TRUE to
01780 //
01781 /////////////////////////////////////////////////////////
01782 LRESULT CAdvRecoApp::OnLVItemChanging(
01783         int idCtrl,
01784         LPNMHDR pnmh,
01785         BOOL& /*bHandled*/
01786         )
01787 {
01788     if (m_spIInkCollector == NULL)
01789         return FALSE;
01790
01791     LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh;
01792
01793     LRESULT lRet;
01794
01795     // Ignore all the changes which are not of the item state,
01796     // and the item state changes other then checked/unchecked (LVIS_STATEIMAGEMASK)
01797     if (LVIF_STATE == pnmv->uChanged && 0 != (LVIS_STATEIMAGEMASK & pnmv->uNewState))
01798     {
01799         lRet = TRUE;   // prevent the change if something is wrong
01800         BOOL bChecked = ((LVIS_STATEIMAGEMASK & pnmv->uNewState) >> 12) == 2;
01801         InkApplicationGesture igtGesture = IAG_NoGesture;
01802         if (mc_iSSGestLVId == idCtrl)
01803         {
01804             if (pnmv->iItem >= 0 && pnmv->iItem < countof(gc_igtSingleStrokeGestures))
01805                 igtGesture = gc_igtSingleStrokeGestures[pnmv->iItem];
01806         }
01807         else if (mc_iMSGestLVId == idCtrl)
01808         {
01809             if (pnmv->iItem >= 0 && pnmv->iItem < countof(gc_igtMultiStrokeGestures))
01810                 igtGesture = gc_igtMultiStrokeGestures[pnmv->iItem];
01811         }
01812
01813         if (IAG_NoGesture != igtGesture && SUCCEEDED(
01814             m_spIInkCollector->SetGestureStatus(igtGesture, bChecked ? VARIANT_TRUE : VARIANT_FALSE)))
01815         {
01816             // Allow the change in the control's item state
01817             lRet = FALSE;
01818         }
01819     }
01820     else
01821     {
01822         // Allow all the other changes
01823         lRet = FALSE;
01824     }
01825
01826     return lRet;
01827 }
01828
01829 /////////////////////////////////////////////////////////
01830 //
01831 // CAdvRecoApp::CreateChildWindows
01832 //
01833 // This helper method is called from WM_CREATE message handler.
01834 // The child windows and controls are created and initialized here.
01835 //
01836 // Parameters:
01837 //      none
01838 //
01839 // Return Values (bool):
01840 //      true if the windows have been created successfully,
01841 //      false otherwise
01842 //
01843 /////////////////////////////////////////////////////////
01844 bool CAdvRecoApp::CreateChildWindows()
01845 {
01846     if ((m_wndInput.Create(m_hWnd, CWindow::rcDefault, NULL,
01847                            WS_CHILD, WS_EX_CLIENTEDGE, (UINT)mc_iInputWndId) == NULL)
01848         || (m_wndResults.Create(m_hWnd, CWindow::rcDefault, NULL,
01849                                 WS_CHILD, WS_EX_CLIENTEDGE, (UINT)mc_iOutputWndId) == NULL))
01850     {
01851         return false;
01852     }
01853
01854
01855     HINSTANCE hInst = _Module.GetResourceInstance();
01856
01857     // Create a listview control for the list of the single stroke gestures
01858     m_hwndSSGestLV = ::CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
01859                                       WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT,
01860                                       0, 0, 1, 1,
01861                                       m_hWnd, (HMENU)mc_iSSGestLVId,
01862                                       _Module.GetModuleInstance(), NULL);
01863     if (NULL == m_hwndSSGestLV)
01864         return false;
01865
01866     //
01867     ListView_SetExtendedListViewStyleEx(m_hwndSSGestLV, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
01868
01869     // Create a column
01870     LV_COLUMN lvC;
01871     lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
01872     lvC.fmt = LVCFMT_LEFT;
01873     lvC.iSubItem = 0;
01874     lvC.cx = mc_cxGestLVWidth - 22;
01875     lvC.pszText = TEXT("Single Stroke Gestures");
01876     if (-1 == ListView_InsertColumn(m_hwndSSGestLV, lvC.iSubItem, &lvC))
01877         return false;
01878
01879     // Insert items - the names of the single stroke gestures.
01880     TCHAR szText[100];  // large enough to load a gesture name into
01881     LV_ITEM lvItem;
01882     lvItem.mask = LVIF_TEXT /*| LVIF_IMAGE*/ | LVIF_STATE;
01883     lvItem.state = 0;
01884     lvItem.stateMask = 0;
01885     lvItem.pszText = szText;
01886     lvItem.iSubItem = 0;
01887     for (int i = 0; i < mc_cNumSSGestures; i++)
01888     {
01889         lvItem.iItem = i;
01890         // Load the names from the application resource, there should be
01891         // mc_cNumSSGestures names there with sequential id's starting
01892         // with IDS_SSGESTURE_FIRST
01893         ::LoadString(hInst, IDS_SSGESTURE_FIRST + i, szText, countof(szText));
01894         if (-1 == ListView_InsertItem(m_hwndSSGestLV, &lvItem))
01895             return false;
01896     }
01897
01898
01899     // Create a listview control for the list of the multi-stroke gestures
01900     m_hwndMSGestLV = ::CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
01901                                       WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT,
01902                                       0, 0, 1, 1,
01903                                       m_hWnd, (HMENU)mc_iMSGestLVId,
01904                                       _Module.GetModuleInstance(), NULL);
01905     if (NULL == m_hwndMSGestLV)
01906         return false;
01907     //
01908     ListView_SetExtendedListViewStyleEx(m_hwndMSGestLV, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
01909
01910     // Create a column
01911     lvC.pszText = TEXT("Multiple Stroke Gestures");
01912     ListView_InsertColumn(m_hwndMSGestLV, lvC.iSubItem, &lvC);
01913
01914     // Insert items - the names of the single stroke gestures.
01915     for (i = 0; i < mc_cNumMSGestures; i++)
01916     {
01917         lvItem.iItem = i;
01918         // Load the names from the application resource, there should be
01919         // mc_cNumMSGestures names there with sequential id's starting
01920         // with IDS_MSGESTURE_FIRST
01921         ::LoadString(hInst, IDS_MSGESTURE_FIRST + i, szText, countof(szText));
01922         if (-1 == ListView_InsertItem(m_hwndMSGestLV, &lvItem))
01923             return false;
01924     }
01925
01926     // Create a status bar (Ignore if it fails, the application can live without it).
01927     m_hwndStatusBar = ::CreateStatusWindow(
01928                         WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SBARS_SIZEGRIP,
01929                         NULL, m_hWnd, (UINT)mc_iStatusWndId);
01930     if (NULL != m_hwndStatusBar)
01931     {
01932         ::SendMessage(m_hwndStatusBar,
01933                       WM_SETFONT,
01934                       (LPARAM)::GetStockObject(DEFAULT_GUI_FONT), FALSE);
01935     }
01936
01937     // Update the child windows' positions and sizes so that they cover
01938     // entire client area of the main window.
01939     UpdateLayout();
01940
01941     return true;
01942 }
01943
01944 /////////////////////////////////////////////////////////
01945 //
01946 // CAdvRecoApp::UpdateLayout
01947 //
01948 // This helper method is called when the size of the main
01949 // window has been changed and the child windows' positions
01950 // need to be updated so that they cover entire client area
01951 // of the main window.
01952 //
01953 // Parameters:
01954 //      none
01955 //
01956 // Return Values (void):
01957 //      none
01958 //
01959 /////////////////////////////////////////////////////////
01960 void CAdvRecoApp::UpdateLayout()
01961 {
01962     RECT rect;
01963     GetClientRect(&rect);
01964
01965     // update the size and position of the status bar
01966     if (::IsWindow(m_hwndStatusBar)
01967         && ((DWORD)::GetWindowLong(m_hwndStatusBar, GWL_STYLE) & WS_VISIBLE))
01968     {
01969         ::SendMessage(m_hwndStatusBar, WM_SIZE, 0, 0);
01970         RECT rectStatusBar;
01971         ::GetWindowRect(m_hwndStatusBar, &rectStatusBar);
01972         if (rect.bottom > rectStatusBar.bottom - rectStatusBar.top)
01973         {
01974             rect.bottom -= rectStatusBar.bottom - rectStatusBar.top;
01975         }
01976         else
01977         {
01978             rect.bottom = 0;
01979         }
01980     }
01981
01982     // update the size and position of the gesture listviews
01983     if (::IsWindow(m_hwndSSGestLV) && ::IsWindow(m_hwndMSGestLV))
01984     {
01985         if (ID_MODE_INK != m_nCmdMode)
01986         {
01987             // calculate the rectangle covered by the list views
01988             RECT rcGest = rect;
01989             if (rcGest.right < mc_cxGestLVWidth)
01990             {
01991                 rcGest.left = 0;
01992             }
01993             else
01994             {
01995                 rcGest.left = rcGest.right - mc_cxGestLVWidth;
01996             }
01997
01998             rect.right = rcGest.left;
01999
02000             if (ID_MODE_GESTURES == m_nCmdMode)
02001             {
02002                 int iHeight;
02003                 RECT rcItem;
02004                 if (TRUE == ListView_GetItemRect(m_hwndMSGestLV, 0, &rcItem, LVIR_BOUNDS))
02005                 {
02006                     iHeight = rcItem.top + (rcItem.bottom - rcItem.top)
02007                                             * (countof(gc_igtMultiStrokeGestures) + 1);
02008                 }
02009                 else
02010                 {
02011                     iHeight = (rcGest.bottom - rcGest.top) / 3;
02012                 }
02013
02014                 // show the multiple stroke gesture listview control
02015                 ::SetWindowPos(m_hwndMSGestLV, NULL,
02016                                rcGest.left, rcGest.bottom - iHeight,
02017                                rcGest.right - rcGest.left, iHeight,
02018                                SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
02019                 rcGest.bottom -= iHeight;
02020             }
02021             else if (WS_VISIBLE ==
02022                     (((DWORD)::GetWindowLong(m_hwndMSGestLV, GWL_STYLE)) & WS_VISIBLE))
02023             {
02024                 // hide the multiple stroke gesture listview control
02025                 ::ShowWindow(m_hwndMSGestLV, SW_HIDE);
02026             }
02027
02028             // show the single stroke gesture listview control
02029             ::SetWindowPos(m_hwndSSGestLV, NULL,
02030                            rcGest.left, rcGest.top,
02031                            rcGest.right - rcGest.left, rcGest.bottom - rcGest.top,
02032                            SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
02033         }
02034         else
02035         {
02036             // hide the single stroke gesture listview control
02037             if (WS_VISIBLE ==
02038                     (((DWORD)::GetWindowLong(m_hwndSSGestLV, GWL_STYLE)) & WS_VISIBLE))
02039             {
02040                 ::ShowWindow(m_hwndSSGestLV, SW_HIDE);
02041             }
02042             // hide the multiple stroke gesture listview control
02043             if (WS_VISIBLE ==
02044                     (((DWORD)::GetWindowLong(m_hwndMSGestLV, GWL_STYLE)) & WS_VISIBLE))
02045             {
02046                 ::ShowWindow(m_hwndMSGestLV, SW_HIDE);
02047             }
02048         }
02049     }
02050
02051     // update the size and position of the output window
02052     if (::IsWindow(m_wndResults.m_hWnd))
02053     {
02054         int cyResultsWnd = m_wndResults.GetBestHeight();
02055         if (cyResultsWnd > rect.bottom)
02056         {
02057             cyResultsWnd = rect.bottom;
02058         }
02059         ::SetWindowPos(m_wndResults.m_hWnd, NULL,
02060                        rect.left, rect.bottom - cyResultsWnd,
02061                        rect.right - rect.left, cyResultsWnd - rect.top,
02062                        SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
02063         rect.bottom -= cyResultsWnd;
02064     }
02065
02066     // update the size and position of the ink input window
02067     if (::IsWindow(m_wndInput.m_hWnd))
02068     {
02069         ::SetWindowPos(m_wndInput.m_hWnd, NULL,
02070                        rect.left, rect.top,
02071                        rect.right - rect.left, rect.bottom - rect.top,
02072                        SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
02073     }
02074 }
02075
02076 /////////////////////////////////////////////////////////
02077 //
02078 // CAdvRecoApp::UpdateStatusBar
02079 //
02080 // This helper function outputs the names of the currently selected
02081 // recognizer and input scope to the application's status bar.
02082 //
02083 // Parameters:
02084 //      none
02085 //
02086 // Return Values (void):
02087 //      none
02088 //
02089 /////////////////////////////////////////////////////////
02090 void CAdvRecoApp::UpdateStatusBar()
02091 {
02092     if (NULL == m_hwndStatusBar)
02093         return;
02094
02095     UINT iInputScope = m_nCmdInputScope - ID_INPUTSCOPE_FIRST;
02096     if (iInputScope >= sizeof(gc_pwsInputScopes)/sizeof(gc_pwsInputScopes[0]))
02097     {
02098         iInputScope = 0;
02099     }
02100
02101     CComBSTR bstrStatus(m_bstrCurRecoName);
02102
02103     // If an input scope is set, add to the status bar string
02104     if (m_nCmdInputScope != -1)
02105     {
02106         bstrStatus += L"; Input Scope: ";
02107         bstrStatus += gc_pwsInputScopes[iInputScope];
02108     }
02109
02110     // Set the new text int the status bar
02111     ::SendMessage(m_hwndStatusBar, SB_SETTEXTW, NULL, (LPARAM)bstrStatus.m_str);
02112 }
02113
02114 /////////////////////////////////////////////////////////
02115 //
02116 // CAdvRecoApp::GetGestureName
02117 //
02118 // This helper function returns the resource id of
02119 // the string with the name of the given gesture.
02120 //
02121 // Parameters:
02122 //      InkApplicationGesture idGesture    : [in] the gesture's id
02123 //      UINT& idGestureName         : [out] the id of the string with the the name
02124 //                                    of the gesturein the resource string table
02125 // Return Values (bool):
02126 //      true if the gesture is known to the application, false otherwise
02127 //
02128 /////////////////////////////////////////////////////////
02129 bool CAdvRecoApp::GetGestureName(
02130         InkApplicationGesture igtGesture,
02131         UINT& idGestureName
02132         )
02133 {
02134     idGestureName = IDS_GESTURE_UNKNOWN;
02135
02136     // This function should not be called when the collection mode is ICM_InkOnly
02137     if (ID_MODE_INK == m_nCmdMode)
02138         return false;
02139
02140     // First, try to find the gesture among the single stroke ones
02141     int iCount = countof(gc_igtSingleStrokeGestures);
02142     for (int i = 0; i < iCount; i++)
02143     {
02144         if (gc_igtSingleStrokeGestures[i] == igtGesture)
02145         {
02146             idGestureName = IDS_SSGESTURE_FIRST + i;
02147             break;
02148         }
02149     }
02150
02151     // If this is not a known single stroke gesture and the current collection mode
02152     // is ICM_GestureOnly, this may be a multi-stroke one.
02153     if (i == iCount && ID_MODE_GESTURES == m_nCmdMode)
02154     {
02155         iCount = countof(gc_igtMultiStrokeGestures);
02156         for (i = 0; i < iCount; i++)
02157         {
02158             if (gc_igtMultiStrokeGestures[i] == igtGesture)
02159             {
02160                 idGestureName = IDS_MSGESTURE_FIRST + i;
02161                 break;
02162             }
02163         }
02164     }
02165
02166     return (IDS_GESTURE_UNKNOWN != idGestureName);
02167 }
02168
02169 /////////////////////////////////////////////////////////
02170 //
02171 // CAdvRecoApp::PresetGestures
02172 //
02173 // Sets the status of the recommended subset of gestures
02174 // to TRUE in InkCollector
02175 //
02176 // Parameters:
02177 //      none
02178 //
02179 // Return Values (void):
02180 //      none
02181 //
02182 /////////////////////////////////////////////////////////
02183 void CAdvRecoApp::PresetGestures()
02184 {
02185     // This function should not be called before the listview controls have been created
02186     if (0 == ::IsWindow(m_hwndSSGestLV) || 0 == ::IsWindow(m_hwndMSGestLV))
02187         return;
02188
02189     // Set the status of the single stroke gestures
02190     UINT iNumGestures = countof(gc_igtSingleStrokeGestures);
02191     UINT iNumSubset = countof(gc_nRecommendedForMixedMode);
02192     for (UINT i = 0; i < iNumSubset; i++)
02193     {
02194         if (gc_nRecommendedForMixedMode[i] < iNumGestures)
02195             ListView_SetCheckState(m_hwndSSGestLV, gc_nRecommendedForMixedMode[i], TRUE);
02196     }
02197
02198     // Set the status of the multiple stroke gestures
02199     iNumGestures = countof(gc_igtMultiStrokeGestures);
02200     for (i = 0; i < iNumGestures; i++)
02201     {
02202         ListView_SetCheckState(m_hwndMSGestLV, i, TRUE);
02203     }
02204 }
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cmdichild.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cmdichild.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CMDICHILD.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CMDICHILD_H_
00012 #define _CMDICHILD_H_
00013
00014
00015 //////////////////////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 //////////////////////////////////////////////////////////////////////////////
00019 #include "CDialog.h"
00020 #include "CError.h"
00021 #include "CTrace.h"
00022 #include "CDataLinks.h"
00023 #include "CDataSource.h"
00024 #include "CSession.h"
00025 #include "CCommand.h"
00026 #include "CRowset.h"
00027 #include "CRow.h"
00028 #include "CMultipleResults.h"
00029 #include "CRowPosition.h"
00030 #include "CDataSet.h"
00031 #include "CStream.h"
00032 #include "CBinder.h"
00033
00034
00035 /////////////////////////////////////////////////////////////////////
00036 // CQueryBox
00037 //
00038 /////////////////////////////////////////////////////////////////////
00039 class CQueryBox : public CRichEditLite
00040 {
00041 public:
00042   //constructors
00043   CQueryBox(CMDIChild* pCMDIChild);
00044   virtual ~CQueryBox();
00045
00046   //messages
00047   virtual BOOL  OnRButtonDown(WPARAM fwKeys, REFPOINTS pts);
00048   virtual BOOL  OnContextMenu(HWND hWnd, REFPOINTS pts);
00049   virtual BOOL  OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData);
00050
00051 //protected:
00052   //data
00053   CMDIChild*    m_pCMDIChild;
00054 };
00055
00056
00057 /////////////////////////////////////////////////////////////////////
00058 // CDataGrid
00059 //
00060 /////////////////////////////////////////////////////////////////////
00061 class CDataGrid : public CListViewLite
00062 {
00063 public:
00064   //constructors
00065   CDataGrid(CMDIChild* pCMDIChild);
00066   virtual ~CDataGrid();
00067
00068   //messages
00069   virtual BOOL    OnSize(WPARAM nType, REFPOINTS pts);
00070   virtual BOOL    OnRButtonDown(WPARAM fwKeys, REFPOINTS pts);
00071   virtual BOOL    OnContextMenu(HWND hWnd, REFPOINTS pts);
00072   virtual BOOL    OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData);
00073   virtual BOOL    OnVScroll(int nScrollCode, int nPos, HWND hWnd);
00074
00075   //Overloads
00076   virtual BOOL    OnColumnClick(INT idCtrl, NMLISTVIEW* pNMListView);
00077   virtual BOOL    OnItemActivate(INT idCtrl, NMLISTVIEW* pNMListView);
00078
00079   //Helpers
00080   virtual INDEX   GetSelectedRow(HROW* phRow = NULL, BOOL fValidate = TRUE);
00081   virtual HRESULT   ScrollGrid(DBROWCOUNT cItems);
00082   virtual BOOL    ClearAll(WCHAR* pwszEmptyHeader = NULL);
00083
00084   //Row operations
00085   virtual HRESULT   AddRefRows(INDEX iIndex);
00086   virtual HRESULT   ReleaseRows(INDEX iIndex, BOOL fOnlyValidRows);
00087   virtual HRESULT   ReleaseHeldRows();
00088
00089   virtual HRESULT   DisplayColumnInfo();
00090
00091   virtual HRESULT   RefreshData();
00092   virtual HRESULT   DisplayData(HROW hRow, INDEX iIndex, DBPROPID dwSourceID = DBPROP_IRowset, bool fAlways = FALSE);
00093
00094   virtual HRESULT   RestartPosition();
00095   virtual HRESULT   GetNextRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, BOOL fRetry = FALSE);
00096   virtual HRESULT   DisplayRows(DBROWOFFSET lOffset, DBROWCOUNT cRows, DBCOUNTITEM cRowsObtained, HROW* rghRows, BOOL fAdjustFetchPosition = TRUE);
00097   virtual HRESULT   DisplayFetchPosition(INDEX iIndex, BOOL fLastFetchForward);
00098
00099   //Interface
00100   virtual COptionsSheet*  GetOptions();
00101
00102 //protected:
00103   //data
00104   CMDIChild*      m_pCMDIChild;
00105   INDEX       m_lMaxRows;
00106   INDEX       m_iSelRow;
00107   INDEX       m_iSelCol;
00108
00109   //Cursor
00110   BOOL        m_fLastFetchForward;
00111   DBROWOFFSET     m_lCurPos;
00112 };
00113
00114
00115 /////////////////////////////////////////////////////////////////////
00116 // CMDIChild
00117 //
00118 /////////////////////////////////////////////////////////////////////
00119 class CMDIChild : public CMDIChildLite
00120 {
00121 public:
00122   //constructors
00123   CMDIChild(CMainWindow* pCMainWindow);
00124   virtual ~CMDIChild();
00125
00126   virtual BOOL    OnCreate(LPCREATESTRUCT lpCreateStruct);
00127   virtual BOOL    OnDestroy();
00128   virtual BOOL    OnClose();
00129   virtual BOOL    OnInitialUpdate();
00130   virtual BOOL    AutoPosition(BOOL fDefaultPosition = TRUE);
00131
00132   //Messages
00133   virtual BOOL    OnSize(WPARAM nType, REFPOINTS pts);
00134   virtual BOOL    OnSizing(WPARAM nSide, REFPOINTS pts);
00135   virtual BOOL    OnSetFocus(HWND hWndPrevFocus);
00136   virtual BOOL    OnMDIActivate(BOOL bActivate, HWND hWndActivate, HWND hWndDeactivate);
00137
00138   //Overloads
00139   virtual BOOL    OnCommand(UINT iID, HWND hWndCtrl);
00140   virtual BOOL    OnNotify(INT idCtrl, NMHDR* pNMHDR);
00141   virtual BOOL    OnUpdateCommand(HMENU hMenu, UINT nID, DWORD* pdwFlags);
00142
00143   //members
00144   virtual BOOL    UpdateControls();
00145   virtual HRESULT   UpdateWndTitle();
00146   virtual CBase**   GetObjectAddress(SOURCE eSource = eCUnknown);
00147   virtual CBase*    GetObject(SOURCE eSource = eCUnknown, BOOL fAlways = FALSE);
00148   virtual void    SetConfig(WCHAR* pwszConfig, BOOL fCopy = TRUE);
00149
00150   //Rowset
00151   virtual HRESULT   HandleRowset(CBase* pCSource, IUnknown* pIUnknown, REFIID riid, DWORD dwFlags, REFGUID guidSource, WCHAR* pwszTableName = NULL, BOOL fSchemaRowset = FALSE);
00152
00153   //Dataset
00154   static  INT_PTR WINAPI GetAxisInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00155   static  INT_PTR WINAPI GetAxisRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00156
00157   //ListView
00158   virtual HRESULT   GetListViewValues(HWND hWndNames, HWND hWndValues, CDataAccess* pCDataAccess, CBindings& rBindings, void* pData);
00159
00160   //Child Windows
00161   virtual HRESULT   CreateEnumChild();
00162
00163   //IRowset
00164   virtual HRESULT   ChangeSelectedRow(CBase* pCSource, UINT idSource);
00165   virtual HRESULT   DeleteSelectedRows();
00166   virtual HRESULT   InsertNewRow();
00167   virtual HRESULT   UndoChanges();
00168   virtual HRESULT   UpdateChanges();
00169
00170   //Dialogs
00171   virtual INT_PTR   DisplayDialog(UINT uID, HWND hWndParent, DLGPROC lpDialogFunc, CBase* pCObject, UINT idSource = 0);
00172
00173   //Info Procs
00174   static INT_PTR WINAPI GetColInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00175   static INT_PTR WINAPI GetLiteralInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00176   static INT_PTR WINAPI ProviderInfoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00177
00178   //Transaction Procs
00179   static INT_PTR WINAPI StartTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00180     static INT_PTR WINAPI AbortTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00181     static INT_PTR WINAPI CommitTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00182     static INT_PTR WINAPI SetTransactionOptionsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00183   static INT_PTR WINAPI JoinTransactionProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00184   static INT_PTR WINAPI GetTransactionInfo(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00185   static INT_PTR WINAPI ReleaseTransaction(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00186   virtual BOOL SetupTransactionCombo(HWND hWnd);
00187
00188   //Command Procs
00189   static INT_PTR WINAPI CanConvertProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00190   static INT_PTR WINAPI SetParameterInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00191   static INT_PTR WINAPI GetParameterInfoProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00192   static INT_PTR WINAPI ExecuteProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00193   static INT_PTR WINAPI SetCommandTextProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00194   static INT_PTR WINAPI CommandPersistProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00195
00196   //Rowset Procs
00197   static INT_PTR WINAPI GetNextRowsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00198   static INT_PTR WINAPI GetBindingsProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00199   static INT_PTR WINAPI RowChangeProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00200   static INT_PTR WINAPI ColumnChangeProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00201   static INT_PTR WINAPI OpenRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00202   static INT_PTR WINAPI GetColumnsRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00203   static INT_PTR WINAPI FindNextRowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00204   static INT_PTR WINAPI CreateAccessorProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00205
00206   //Chapters
00207   static INT_PTR WINAPI GetReferencedRowsetProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00208   virtual HRESULT     GetChapteredChild(INDEX iSelectedCol, const DBBINDING* pBinding, REFIID riid = IID_IRowset);
00209
00210   //Row Procs
00211   static INT_PTR WINAPI RowOpenProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00212
00213   //IDBDataSourceAdmin Procs
00214   static INT_PTR WINAPI AdminCreateDataSourceProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00215
00216   //IIndexDefinition Procs
00217   static INT_PTR WINAPI CreateIndexProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00218   static INT_PTR WINAPI DropIndexProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00219
00220   //ITableDefinition Procs
00221   static INT_PTR WINAPI AddColumnProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00222   static INT_PTR WINAPI CreateTableProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00223   static INT_PTR WINAPI DropColumnProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00224   static INT_PTR WINAPI DropTableProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00225
00226   //ITableDefinitionWithCosntraints Procs
00227   static INT_PTR WINAPI DropConstraintProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00228
00229   //IScopedOperations
00230   static INT_PTR WINAPI ISCO_DeleteProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00231   static INT_PTR WINAPI ISCO_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00232
00233   //Interface
00234   virtual COptionsSheet*  GetOptions();
00235
00236   //Backpointers
00237   CMainWindow*      m_pCMainWindow;
00238   CDataSource*      m_pCDataSource;
00239   CSession*       m_pCSession;
00240   CCommand*       m_pCCommand;
00241   CMultipleResults*   m_pCMultipleResults;
00242   CDataAccess*      m_pCDataAccess;
00243
00244   //Controls
00245   CQueryBox*        m_pCQueryBox;
00246   CDataGrid*        m_pCDataGrid;
00247
00248   //Data
00249   WPARAM          m_lastSizedEdge;
00250   static  ULONG     m_iChildWindow;
00251   WCHAR*          m_pwszConfig;
00252
00253   //Properties
00254   CPropSets       m_CDefPropSets;
00255
00256   //Source
00257   CBase*          m_pCSource;
00258   ULONG         m_idSource;
00259 };
00260
00261
00262 #endif //_CMDICHILD_H_
Generated on Wed Nov 13 2024 16:52:07 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFcase/hello.cpp Source File

  • WinUI
  • TSFcase

hello.cpp

Go to the documentation of this file.
00001 //
00002 // hello.cpp
00003 //
00004 // "Hello World" menu item handler.
00005 //
00006
00007 #include "globals.h"
00008 #include "case.h"
00009 #include "editsess.h"
00010
00011 class CHelloEditSession : public CEditSessionBase
00012 {
00013 public:
00014     CHelloEditSession(ITfContext *pContext) : CEditSessionBase(pContext) {}
00015
00016     // ITfEditSession
00017     STDMETHODIMP DoEditSession(TfEditCookie ec);
00018 };
00019
00020 //+---------------------------------------------------------------------------
00021 //
00022 // _Menu_HelloWord
00023 //
00024 // Insert the string "Hello world!" to the focus context.
00025 //----------------------------------------------------------------------------
00026
00027 void CCaseTextService::_Menu_HelloWord(CCaseTextService *_this)
00028 {
00029     ITfDocumentMgr *pFocusDoc;
00030     ITfContext *pContext;
00031     CHelloEditSession *pHelloEditSession;
00032     HRESULT hr;
00033
00034     // get the focus document
00035     if (_this->_pThreadMgr->GetFocus(&pFocusDoc) != S_OK)
00036         return;
00037
00038     // we want the topmost context, since the main doc context could be
00039     // superceded by a modal tip context
00040     if (pFocusDoc->GetTop(&pContext) != S_OK)
00041     {
00042         pContext = NULL;
00043         goto Exit;
00044     }
00045
00046     if (pHelloEditSession = new CHelloEditSession(pContext))
00047     {
00048         // we need a document write lock to insert text
00049         // the CHelloEditSession will do all the work when the
00050         // CHelloEditSession::DoEditSession method is called by the context
00051         pContext->RequestEditSession(_this->_tfClientId, pHelloEditSession, TF_ES_READWRITE | TF_ES_ASYNCDONTCARE, &hr);
00052
00053         pHelloEditSession->Release();
00054     }
00055
00056 Exit:
00057     SafeRelease(pContext);
00058     pFocusDoc->Release();
00059 }
00060
00061 //+---------------------------------------------------------------------------
00062 //
00063 // DoEditSession
00064 //
00065 //----------------------------------------------------------------------------
00066
00067 STDAPI CHelloEditSession::DoEditSession(TfEditCookie ec)
00068 {
00069     InsertTextAtSelection(ec, _pContext, L"Hello world!", (ULONG)wcslen(L"Hello world!"));
00070     return S_OK;
00071 }
00072
00073 //+---------------------------------------------------------------------------
00074 //
00075 // InsertTextAtSelection
00076 //
00077 //----------------------------------------------------------------------------
00078
00079 void InsertTextAtSelection(TfEditCookie ec, ITfContext *pContext, const WCHAR *pchText, ULONG cchText)
00080 {
00081     ITfInsertAtSelection *pInsertAtSelection;
00082     ITfRange *pRange;
00083     TF_SELECTION tfSelection;
00084
00085     // we need a special interface to insert text at the selection
00086     if (pContext->QueryInterface(IID_ITfInsertAtSelection, (void **)&pInsertAtSelection) != S_OK)
00087         return;
00088
00089     // insert the text
00090     if (pInsertAtSelection->InsertTextAtSelection(ec, 0, pchText, cchText, &pRange) != S_OK)
00091         goto Exit;
00092
00093     // update the selection, we'll make it an insertion point just past
00094     // the inserted text.
00095     pRange->Collapse(ec, TF_ANCHOR_END);
00096
00097     tfSelection.range = pRange;
00098     tfSelection.style.ase = TF_AE_NONE;
00099     tfSelection.style.fInterimChar = FALSE;
00100
00101     pContext->SetSelection(ec, 1, &tfSelection);
00102
00103     pRange->Release();
00104
00105 Exit:
00106     pInsertAtSelection->Release();
00107 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_CONFIGURATION_ENTRY Member List

This is the complete list of members for _CONFIGURATION_ENTRY, including all inherited members.
dlsDynamicLocksStore | _CONFIGURATION_ENTRY
dwLogLevel | _CONFIGURATION_ENTRY
dwTraceID | _CONFIGURATION_ENTRY
hActivitySemaphore | _CONFIGURATION_ENTRY
hGlobalHeap | _CONFIGURATION_ENTRY
hLogHandle | _CONFIGURATION_ENTRY
hMgmHandle | _CONFIGURATION_ENTRY
hMgrNotificationEvent | _CONFIGURATION_ENTRY
hRtmHandle | _CONFIGURATION_ENTRY
hRtmNotificationHandle | _CONFIGURATION_ENTRY
hTimerQueue | _CONFIGURATION_ENTRY
igsStats | _CONFIGURATION_ENTRY
iscStatus | _CONFIGURATION_ENTRY
lqEventQueue | _CONFIGURATION_ENTRY
pneNetworkEntry | _CONFIGURATION_ENTRY
reiRtmEntity | _CONFIGURATION_ENTRY
rrpRtmProfile | _CONFIGURATION_ENTRY
rwlLock | _CONFIGURATION_ENTRY
sfSupportFunctions | _CONFIGURATION_ENTRY
ulActivityCount | _CONFIGURATION_ENTRY
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Schema/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Schema
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  Schema.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/omniprov/source/msomniprovsess.h Source File

  • Dataaccess
  • oledb
  • omniprov
  • source

msomniprovsess.h

Go to the documentation of this file.
00001 // Start of file MSOmniProvSession.h
00002 // File : MSOmniProvSession.h
00003 // All of the Schema rowsets object contain hard-coded schema information
00004 //
00005 // Implementation of:
00006 //    CMSOmniProvSession - Session class,
00007 //      CMSOmniProvSessionTRSchemaRowset - DBSCHEMA_TABLES schema rowset,
00008 //      CMSOmniProvSessionColSchemaRowset - DBSCHEMA_COLUMNS schema rowset,
00009 //    CMSOmniProvSessionPTSchemaRowset - DBSCHEMA_PROVIDER_TYPES schema rowset,
00010 //
00011
00012 #ifndef __CMSOmniProvSession_H_
00013 #define __CMSOmniProvSession_H_
00014
00015 #include "resource.h"       // main symbols
00016 #include "MSOmniProvRS.h"
00017
00018 class CMSOmniProvSessionTRSchemaRowset;
00019 class CMSOmniProvSessionColSchemaRowset;
00020 class CMSOmniProvSessionPTSchemaRowset;
00021
00022
00023 // CMSOmniProvSession
00024 class ATL_NO_VTABLE CMSOmniProvSession :
00025   public CComObjectRootEx<CComSingleThreadModel>,
00026   public IGetDataSourceImpl<CMSOmniProvSession>,
00027   public IOpenRowsetImpl<CMSOmniProvSession>,
00028   public ISessionPropertiesImpl<CMSOmniProvSession>,
00029   public IObjectWithSiteSessionImpl<CMSOmniProvSession>,
00030   public IDBSchemaRowsetImpl<CMSOmniProvSession>,
00031   public IDBCreateCommandImpl<CMSOmniProvSession, CMSOmniProvCommand>
00032 {
00033 public:
00034
00035   CMSOmniProvSession()
00036   {
00037   }
00038   HRESULT FinalConstruct()
00039   {
00040     return FInit();
00041   }
00042
00043   STDMETHOD(OpenRowset)(IUnknown *pUnk, DBID *pTID, DBID *pInID, REFIID riid,
00044              ULONG cSets, DBPROPSET rgSets[], IUnknown **ppRowset)
00045   {
00046     CMSOmniProvRowset* pRowset;
00047     return  CreateRowset(pUnk, pTID, pInID, riid, cSets, rgSets, ppRowset, pRowset);
00048   }
00049
00050
00051 BEGIN_PROPSET_MAP(CMSOmniProvSession)
00052   BEGIN_PROPERTY_SET(DBPROPSET_SESSION)
00053     PROPERTY_INFO_ENTRY(SESS_AUTOCOMMITISOLEVELS)
00054   END_PROPERTY_SET(DBPROPSET_SESSION)
00055 END_PROPSET_MAP()
00056 BEGIN_COM_MAP(CMSOmniProvSession)
00057   COM_INTERFACE_ENTRY(IGetDataSource)
00058   COM_INTERFACE_ENTRY(IOpenRowset)
00059   COM_INTERFACE_ENTRY(ISessionProperties)
00060   COM_INTERFACE_ENTRY(IObjectWithSite)
00061   COM_INTERFACE_ENTRY(IDBCreateCommand)
00062   COM_INTERFACE_ENTRY(IDBSchemaRowset)
00063 END_COM_MAP()
00064 BEGIN_SCHEMA_MAP(CMSOmniProvSession)
00065   SCHEMA_ENTRY(DBSCHEMA_TABLES, CMSOmniProvSessionTRSchemaRowset)
00066   SCHEMA_ENTRY(DBSCHEMA_COLUMNS, CMSOmniProvSessionColSchemaRowset)
00067   SCHEMA_ENTRY(DBSCHEMA_PROVIDER_TYPES, CMSOmniProvSessionPTSchemaRowset)  // Base data-types supported
00068 END_SCHEMA_MAP()
00069 };
00070
00071 //      CMSOmniProvSessionTRSchemaRowset - DBSCHEMA_TABLES schema rowset,
00072 class CMSOmniProvSessionTRSchemaRowset :
00073   public CRowsetImpl< CMSOmniProvSessionTRSchemaRowset, CTABLESRow, CMSOmniProvSession,CSimpleArray<CTABLESRow> >
00074 {
00075 public:
00076   HRESULT Execute(LONG* pcRowsAffected, ULONG, const VARIANT*)
00077   {
00078     USES_CONVERSION;
00079     // Currently Hardcoded later on get it from the CStorageClass - Catalog, Schema,Name,Type
00080     CTABLESRow trData;
00081     lstrcpyW(trData.m_szSchema, OLESTR("OmniProv Schema"));
00082     lstrcpyW(trData.m_szCatalog, OLESTR("OmniProv Catalog"));
00083     lstrcpynW(trData.m_szTable, OLESTR("OmniTable"), SIZEOF_MEMBER(CTABLESRow, m_szTable));
00084     lstrcpyW(trData.m_szType, OLESTR("TABLE"));
00085     if (!m_rgRowData.Add(trData))
00086       return E_OUTOFMEMORY;
00087     *pcRowsAffected = 1;
00088     return S_OK;
00089   }
00090   DBSTATUS GetDBStatus(CSimpleRow*, ATLCOLUMNINFO* pInfo)
00091   {
00092     if (pInfo->iOrdinal < 4)
00093       return DBSTATUS_S_OK;
00094     else
00095       return DBSTATUS_S_ISNULL;
00096   }
00097 };
00098
00099 //      CMSOmniProvSessionColSchemaRowset - DBSCHEMA_COLUMNS schema rowset,
00100 class CMSOmniProvSessionColSchemaRowset :
00101   public CRowsetImpl< CMSOmniProvSessionColSchemaRowset, CCOLUMNSRow, CMSOmniProvSession,CSimpleArray<CCOLUMNSRow> >
00102 {
00103   double    m_double;
00104   HCHAPTER  m_hchapter;
00105
00106 public:
00107   HRESULT Execute(LONG* pcRowsAffected, ULONG, const VARIANT*)
00108   {
00109     USES_CONVERSION;
00110     // Currently Hardcoded later on get it from the CStorageClass - Catalog, Schema,Name,Type
00111     CCOLUMNSRow trData[4];   // 4 columns
00112     for(long l=0; l<4;l++)
00113     {
00114       lstrcpyW(trData[l].m_szTableCatalog, OLESTR("OmniProv Catalog"));
00115       lstrcpyW(trData[l].m_szTableSchema, OLESTR("OmniProv Schema"));
00116       lstrcpyW(trData[l].m_szTableName, OLESTR("OmniTable"));
00117       trData[l].m_ulOrdinalPosition = l+1;
00118       trData[l].m_bIsNullable = VARIANT_FALSE;
00119       trData[l].m_bColumnHasDefault = VARIANT_TRUE;
00120       trData[l].m_ulColumnFlags = DBCOLUMNFLAGS_WRITE;  // To write into the columnss
00121       // Currently all the data is static
00122       switch(l)
00123       {
00124       case 0:
00125         trData[l].m_nDataType = DBTYPE_STR;
00126         trData[l].m_ulCharMaxLength = 10;
00127         lstrcpyW(trData[l].m_szColumnName, OLESTR("CustomerID"));
00128         break;
00129       case 1:
00130         trData[l].m_nDataType = DBTYPE_STR;
00131         trData[l].m_ulCharMaxLength = 40;
00132         lstrcpyW(trData[l].m_szColumnName, OLESTR("CustomerName"));
00133         break;
00134       case 2:
00135         trData[l].m_nDataType = DBTYPE_STR;
00136         trData[l].m_ulCharMaxLength = 40;
00137         lstrcpyW(trData[l].m_szColumnName, OLESTR("ItemName "));
00138         break;
00139       case 3: // The Long
00140         trData[l].m_nDataType = DBTYPE_I4;
00141         trData[l].m_nNumericPrecision = 10;
00142         lstrcpyW(trData[l].m_szColumnName, OLESTR("Sale"));
00143       }
00144       m_rgRowData.Add(trData[l]);
00145     }
00146     *pcRowsAffected = l+1;
00147     return S_OK;
00148   }
00149   DBSTATUS GetDBStatus(CSimpleRow*, ATLCOLUMNINFO* pInfo)
00150   {
00151     switch(pInfo->iOrdinal)
00152     {
00153     case 1:
00154     case 2:
00155     case 3:
00156     case 19:
00157     case 20:
00158     case 22:
00159     case 23:
00160     case 25:
00161     case 26:
00162       return DBSTATUS_S_ISNULL;
00163     default:
00164       return DBSTATUS_S_OK;
00165     }
00166   }
00167 };
00168
00169 //    CMSOmniProvSessionPTSchemaRowset - DBSCHEMA_PROVIDER_TYPES schema rowset,
00170 class CMSOmniProvSessionPTSchemaRowset :
00171   public CRowsetImpl< CMSOmniProvSessionPTSchemaRowset, CPROVIDER_TYPERow, CMSOmniProvSession,CSimpleArray<CPROVIDER_TYPERow> >
00172 {
00173 public:
00174     // Supports
00175     // char - DBTYPE_STR
00176      //  long - DBTYPE_I4
00177   HRESULT Execute(LONG* pcRowsAffected, ULONG, const VARIANT*)
00178   {
00179     USES_CONVERSION;
00180     CPROVIDER_TYPERow trData[2];
00181
00182     // DBTYPE_STR
00183     lstrcpyW(trData[0].m_szName, OLESTR("DBTYPE_STR"));
00184     trData[0].m_nType = DBTYPE_STR;
00185     trData[0].m_bIsLong = VARIANT_FALSE;
00186     trData[0].m_bIsNullable = VARIANT_FALSE;
00187     trData[0].m_bCaseSensitive = VARIANT_TRUE;
00188     m_rgRowData.Add(trData[0]);
00189
00190     // DBTYPE_I4
00191     lstrcpyW(trData[1].m_szName, OLESTR("DBTYPE_I4"));
00192     trData[1].m_nType = DBTYPE_I4;
00193     trData[1].m_bIsLong = VARIANT_TRUE;
00194     trData[1].m_bIsNullable = VARIANT_FALSE;
00195     m_rgRowData.Add(trData[1]);
00196
00197     *pcRowsAffected = 2;
00198     return S_OK;
00199   }
00200 };
00201 #endif //__CMSOmniProvSession_H_
00202
00203 // End of file MSOmniProvSession.h
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

fullsvr::ISynchronize Member List

This is the complete list of members for fullsvr::ISynchronize, including all inherited members.
iid | fullsvr::ISynchronize | [static]
Reset() | fullsvr::ISynchronize |
Signal() | fullsvr::ISynchronize |
Wait(int dwFlags, int dwMilliseconds) | fullsvr::ISynchronize |
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Common/Property/Resource.h Source File

  • WinUI
  • Controls
  • Common
  • Property

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by Property.rc
00004 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved
00005 #define IDD_ABOUT_DIALOG                101
00006 #define IDR_MAIN_MENU                   102
00007 #define IDI_BACKCOLOR                   103
00008 #define IDD_BUTTONS                     105
00009 #define IDD_COMBOBOXES                  106
00010 #define IDC_BUTTON2                     1007
00011 #define IDC_RADIO1                      1008
00012 #define IDC_RADIO2                      1009
00013 #define IDC_RADIO3                      1010
00014 #define IDC_CHECK1                      1011
00015 #define IDC_CHECK2                      1012
00016 #define IDC_CHECK3                      1013
00017 #define IDC_COMBO1                      1014
00018 #define IDC_COMBO2                      1015
00019 #define IDC_COMBO3                      1016
00020 #define IDM_EXIT                        2001
00021 #define IDM_MODAL                       2002
00022 #define IDM_MODELESS                    2003
00023 #define IDM_WIZARD                      2004
00024 #define IDM_ABOUT                       2005
00025 #define IDC_STATIC                      -1
00026
00027 // Next default values for new objects
00028 //
00029 #ifdef APSTUDIO_INVOKED
00030 #ifndef APSTUDIO_READONLY_SYMBOLS
00031 #define _APS_NEXT_RESOURCE_VALUE        107
00032 #define _APS_NEXT_COMMAND_VALUE         2006
00033 #define _APS_NEXT_CONTROL_VALUE         1015
00034 #define _APS_NEXT_SYMED_VALUE           101
00035 #endif
00036 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/McastIP/resolve.c Source File

  • NetDS
  • WinSock
  • McastIP

resolve.c

Go to the documentation of this file.
00001 //
00002 // Common routines for resolving addresses and hostnames
00003 //
00004 // Files:
00005 //      resolve.c       - Common routines
00006 //      resolve.h       - Header file for common routines
00007 //
00008 // Description:
00009 //      This file contains common name resolution and name printing
00010 //      functions.
00011 //
00012 // NOTE:
00013 //   From Network Programming for Microsoft Windows, Second Edition
00014 //   by Anthony Jones and James Ohlund.  Copyright 2002.
00015 //   Reproduced by permission of Microsoft Press.  All rights reserved.
00016 //
00017 #include <winsock2.h>
00018 #include <ws2tcpip.h>
00019
00020 // This sample uses the new getaddrinfo/getnameinfo functions which are new to
00021 // Windows XP. To run this sample on older OSes, include the following header
00022 // file which makes it work automagically.
00023 #include <wspiapi.h>
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027
00028 #include "resolve.h"
00029
00030 //
00031 // Function: PrintAddress
00032 //
00033 // Description:
00034 //    This routine takes a SOCKADDR structure and its lenght and prints
00035 //    converts it to a string representation. This string is printed
00036 //    to the console via stdout.
00037 //
00038 int PrintAddress(SOCKADDR *sa, int salen)
00039 {
00040     char    host[NI_MAXHOST],
00041             serv[NI_MAXSERV];
00042     int     hostlen = NI_MAXHOST,
00043             servlen = NI_MAXSERV,
00044             rc;
00045
00046     // Validate argument
00047     if (sa == NULL)
00048         return WSAEFAULT;
00049
00050     rc = getnameinfo(
00051             sa,
00052             salen,
00053             host,
00054             hostlen,
00055             serv,
00056             servlen,
00057             NI_NUMERICHOST | NI_NUMERICSERV
00058             );
00059     if (rc != 0)
00060     {
00061         fprintf(stderr, "%s: getnameinfo failed: %d\n", __FILE__, rc);
00062         return rc;
00063     }
00064
00065     // If the port is zero then don't print it
00066     if (strncmp(serv, "0", 1) != 0)
00067     {
00068         if (sa->sa_family == AF_INET6)
00069             printf("[%s]:%s", host, serv);
00070         else
00071             printf("%s:%s", host, serv);
00072     }
00073     else
00074         printf("%s", host);
00075
00076     return NO_ERROR;
00077 }
00078
00079 //
00080 // Function: FormatAddress
00081 //
00082 // Description:
00083 //    This is similar to the PrintAddress function except that instead of
00084 //    printing the string address to the console, it is formatted into
00085 //    the supplied string buffer.
00086 //
00087 int FormatAddress(SOCKADDR *sa, int salen, char *addrbuf, int addrbuflen)
00088 {
00089     char    host[NI_MAXHOST],
00090             serv[NI_MAXSERV];
00091     int     hostlen = NI_MAXHOST,
00092             servlen = NI_MAXSERV,
00093             rc;
00094
00095     // Validate input
00096     if ((sa == NULL) || (addrbuf == NULL))
00097         return WSAEFAULT;
00098
00099     // Format the name
00100     rc = getnameinfo(
00101             sa,
00102             salen,
00103             host,
00104             hostlen,
00105             serv,
00106             servlen,
00107             NI_NUMERICHOST | NI_NUMERICSERV     // Convert to numeric representation
00108             );
00109     if (rc != 0)
00110     {
00111         fprintf(stderr, "%s: getnameinfo failed: %d\n", __FILE__, rc);
00112         return rc;
00113     }
00114     if ( (strlen(host) + strlen(serv) + 1) > (unsigned)addrbuflen)
00115         return WSAEFAULT;
00116     if (strncmp(serv, "0", 1) != 0)
00117     {
00118         if (sa->sa_family == AF_INET)
00119             _snprintf(addrbuf, addrbuflen-1, "%s:%s", host, serv);
00120         else if (sa->sa_family == AF_INET6)
00121             _snprintf(addrbuf, addrbuflen-1, "[%s]:%s", host, serv);
00122         else
00123             addrbuf[0] = '\0';
00124     }
00125     else
00126     {
00127         _snprintf(addrbuf, addrbuflen-1, "%s", host);
00128     }
00129
00130     return NO_ERROR;
00131 }
00132
00133 //
00134 // Function: ResolveAddress
00135 //
00136 // Description:
00137 //    This routine resolves the specified address and returns a list of addrinfo
00138 //    structure containing SOCKADDR structures representing the resolved addresses.
00139 //    Note that if 'addr' is non-NULL, then getaddrinfo will resolve it whether
00140 //    it is a string listeral address or a hostname.
00141 //
00142 struct addrinfo *ResolveAddress(char *addr, char *port, int af, int type, int proto)
00143 {
00144     struct addrinfo hints,
00145     *res = NULL;
00146     int             rc;
00147
00148     memset(&hints, 0, sizeof(hints));
00149     hints.ai_flags  = ((addr) ? 0 : AI_PASSIVE);
00150     hints.ai_family = af; //((addr) ? AF_UNSPEC : af);
00151     hints.ai_socktype = type;
00152     hints.ai_protocol = proto;
00153
00154     rc = getaddrinfo(
00155             addr,
00156             port,
00157            &hints,
00158            &res
00159             );
00160     if (rc != 0)
00161     {
00162         fprintf(stderr, "Invalid address %s, getaddrinfo failed: %d\n", addr, rc);
00163         return NULL;
00164     }
00165     return res;
00166 }
00167
00168 //
00169 // Function: ReverseLookup
00170 //
00171 // Description:
00172 //    This routine takes a SOCKADDR and does a reverse lookup for the name
00173 //    corresponding to that address.
00174 //
00175 int ReverseLookup(SOCKADDR *sa, int salen, char *buf, int buflen)
00176 {
00177     char    host[NI_MAXHOST];
00178     int     hostlen=NI_MAXHOST,
00179             rc;
00180
00181     // Validate parameters
00182     if ((sa == NULL) || (buf == NULL))
00183         return WSAEFAULT;
00184
00185     rc = getnameinfo(
00186             sa,
00187             salen,
00188             host,
00189             hostlen,
00190             NULL,
00191             0,
00192             0
00193             );
00194     if (rc != 0)
00195     {
00196         fprintf(stderr, "getnameinfo failed: %d\n", rc);
00197         return rc;
00198     }
00199
00200     strncpy(buf, host, buflen-1);
00201
00202     return NO_ERROR;
00203 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/SimpleClient/StdAfx.h Source File

  • SysMgmt
  • WMI
  • VC
  • SimpleClient

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002
00003 //  or project specific include files that are used frequently, but
00004
00005 //      are changed infrequently
00006
00007 //
00008
00009 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00010
00011 #if !defined(AFX_STDAFX_H__4C1DEDFE_F003_11D1_BDD8_00C04F8F8B8D__INCLUDED_)
00012 #define AFX_STDAFX_H__4C1DEDFE_F003_11D1_BDD8_00C04F8F8B8D__INCLUDED_
00013
00014 #if _MSC_VER >= 1000
00015 #pragma once
00016 #endif // _MSC_VER >= 1000
00017
00018 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00019
00020 #include <afxwin.h>         // MFC core and standard components
00021 #include <afxext.h>         // MFC extensions
00022 #include <afxdisp.h>        // MFC OLE automation classes
00023 #ifndef _AFX_NO_AFXCMN_SUPPORT
00024 #include <afxcmn.h>     // MFC support for Windows Common Controls
00025 #endif // _AFX_NO_AFXCMN_SUPPORT
00026
00027 //{{AFX_INSERT_LOCATION}}
00028 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00029
00030 #endif // !defined(AFX_STDAFX_H__4C1DEDFE_F003_11D1_BDD8_00C04F8F8B8D__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRDOComponent Member List

This is the complete list of members for CRDOComponent, including all inherited members.
Activate() | CRDOComponent |
CRDOComponent() | CRDOComponent | [inline]
m_spObjectContext | CRDOComponent |
SimpleQuery(VARIANT *returnval) | CRDOComponent |
STDMETHOD_(BOOL, CanBePooled)() | CRDOComponent |
STDMETHOD_(void, Deactivate)() | CRDOComponent |
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

helper::sampleConstants Member List

This is the complete list of members for helper::sampleConstants, including all inherited members.
CASCADE_EVENT_CLSID | helper::sampleConstants | [static]
CASCADE_EVENT_DLL | helper::sampleConstants | [static]
CASCADE_EVENT_NAME | helper::sampleConstants | [static]
CASCADE_NAME | helper::sampleConstants | [static]
EVENT_CLSID | helper::sampleConstants | [static]
EVENT_NAME | helper::sampleConstants | [static]
INSTALL_FLAG | helper::sampleConstants | [static]
NEW_EVENT_DLL | helper::sampleConstants | [static]
PARALLEL_FLAG | helper::sampleConstants | [static]
PERSIS_EVENT_NAME | helper::sampleConstants | [static]
PERSIS_NAME | helper::sampleConstants | [static]
PERSIST_EVENT_DLL | helper::sampleConstants | [static]
PUBLISHER_NAME | helper::sampleConstants | [static]
SUBSCRIBE_FLAG | helper::sampleConstants | [static]
SUBSCRIBER_NAME | helper::sampleConstants | [static]
TRANSIENT_NAME | helper::sampleConstants | [static]
UNINSTALL_FLAG | helper::sampleConstants | [static]
UNSUBSCRIBE_FLAG | helper::sampleConstants | [static]
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/localres.h Source File

  • SysMgmt
  • MMC
  • Openserv

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSafeRefCount Member List

This is the complete list of members for CSafeRefCount, including all inherited members.
CSafeRefCount() | CSafeRefCount |
DecrementNestCount() | CSafeRefCount |
IncrementNestCount() | CSafeRefCount |
m_cNest | CSafeRefCount | [private]
m_cRefs | CSafeRefCount | [private]
m_fInDelete | CSafeRefCount | [private]
SafeAddRef() | CSafeRefCount |
SafeRelease() | CSafeRefCount |
~CSafeRefCount() | CSafeRefCount | [virtual]
Generated on Wed Nov 13 2024 16:57:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/targtdev.c Source File

  • Com
  • Fundamentals
  • OleStd

targtdev.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 **
00003 **    OLE 2 Standard Utilities
00004 **
00005 **    olestd.c
00006 **
00007 **    This file contains utilities that are useful for dealing with
00008 **    target devices.
00009 **
00010 **    (c) Copyright Microsoft Corp. 1992 - 2000 All Rights Reserved
00011 **
00012 *************************************************************************/
00013
00014 #define STRICT  1
00015 #include "olestd.h"
00016 #ifndef WIN32
00017 #include <print.h>
00018 #endif
00019
00020 /*
00021  * OleStdCreateDC()
00022  *
00023  * Purpose:
00024  *
00025  * Parameters:
00026  *
00027  * Return Value:
00028  *    SCODE  -  S_OK if successful
00029  */
00030 STDAPI_(HDC) OleStdCreateDC(DVTARGETDEVICE FAR* ptd)
00031 {
00032         HDC hdc=NULL;
00033         LPDEVNAMES lpDevNames;
00034         LPDEVMODE lpDevMode;
00035         LPSTR lpszDriverName;
00036         LPSTR lpszDeviceName;
00037         LPSTR lpszPortName;
00038
00039         if (ptd == NULL) {
00040                 hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
00041                 goto errReturn;
00042         }
00043
00044         lpDevNames = (LPDEVNAMES) ptd; // offset for size field
00045
00046         if (ptd->tdExtDevmodeOffset == 0) {
00047                 lpDevMode = NULL;
00048         }else{
00049                 lpDevMode  = (LPDEVMODE) (/*(LPSTR)*/ptd + ptd->tdExtDevmodeOffset);
00050         }
00051
00052         lpszDriverName = (LPSTR) lpDevNames + ptd->tdDriverNameOffset;
00053         lpszDeviceName = (LPSTR) lpDevNames + ptd->tdDeviceNameOffset;
00054         lpszPortName   = (LPSTR) lpDevNames + ptd->tdPortNameOffset;
00055
00056         hdc = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, lpDevMode);
00057
00058 errReturn:
00059         return hdc;
00060 }
00061
00062
00063 /*
00064  * OleStdCreateIC()
00065  *
00066  * Purpose: Same as OleStdCreateDC, except that information context is
00067  *          created, rather than a whole device context.  (CreateIC is
00068  *          used rather than CreateDC).
00069  *          OleStdDeleteDC is still used to delete the information context.
00070  *
00071  * Parameters:
00072  *
00073  * Return Value:
00074  *    SCODE  -  S_OK if successful
00075  */
00076 STDAPI_(HDC) OleStdCreateIC(DVTARGETDEVICE FAR* ptd)
00077 {
00078         HDC hdcIC=NULL;
00079         LPDEVNAMES lpDevNames;
00080         LPDEVMODE lpDevMode;
00081         LPSTR lpszDriverName;
00082         LPSTR lpszDeviceName;
00083         LPSTR lpszPortName;
00084
00085         if (ptd == NULL) {
00086                 hdcIC = CreateIC("DISPLAY", NULL, NULL, NULL);
00087                 goto errReturn;
00088         }
00089
00090         lpDevNames = (LPDEVNAMES) ptd; // offset for size field
00091
00092         lpDevMode  = (LPDEVMODE) (/*(LPSTR)*/ptd + ptd->tdExtDevmodeOffset);
00093
00094         lpszDriverName = (LPSTR) lpDevNames + ptd->tdDriverNameOffset;
00095         lpszDeviceName = (LPSTR) lpDevNames + ptd->tdDeviceNameOffset;
00096         lpszPortName   = (LPSTR) lpDevNames + ptd->tdPortNameOffset;
00097
00098         hdcIC = CreateIC(lpszDriverName, lpszDeviceName, lpszPortName, lpDevMode);
00099
00100 errReturn:
00101         return hdcIC;
00102 }
00103
00104
00105 /*
00106  * OleStdCreateTargetDevice()
00107  *
00108  * Purpose:
00109  *
00110  * Parameters:
00111  *
00112  * Return Value:
00113  *    SCODE  -  S_OK if successful
00114  */
00115 STDAPI_(DVTARGETDEVICE FAR*) OleStdCreateTargetDevice(LPPRINTDLG lpPrintDlg)
00116 {
00117         DVTARGETDEVICE FAR* ptd=NULL;
00118         LPDEVNAMES lpDevNames, pDN;
00119         LPDEVMODE lpDevMode, pDM;
00120         UINT nMaxOffset;
00121         LPSTR pszName;
00122         DWORD dwDevNamesSize, dwDevModeSize, dwPtdSize;
00123
00124         if ((pDN = (LPDEVNAMES)GlobalLock(lpPrintDlg->hDevNames)) == NULL) {
00125                 goto errReturn;
00126         }
00127
00128         if ((pDM = (LPDEVMODE)GlobalLock(lpPrintDlg->hDevMode)) == NULL) {
00129                 goto errReturn;
00130         }
00131
00132         nMaxOffset =  (pDN->wDriverOffset > pDN->wDeviceOffset) ?
00133                 pDN->wDriverOffset : pDN->wDeviceOffset ;
00134
00135         nMaxOffset =  (pDN->wOutputOffset > nMaxOffset) ?
00136                 pDN->wOutputOffset : nMaxOffset ;
00137
00138         pszName = (LPSTR)pDN + nMaxOffset;
00139
00140         dwDevNamesSize = (DWORD)(nMaxOffset+lstrlen(pszName) + 1/* NULL term */);
00141         dwDevModeSize = (DWORD) (pDM->dmSize + pDM->dmDriverExtra);
00142
00143         dwPtdSize = sizeof(DWORD) + dwDevNamesSize + dwDevModeSize;
00144
00145         if ((ptd = (DVTARGETDEVICE FAR*)OleStdMalloc(dwPtdSize)) != NULL) {
00146
00147                 // copy in the info
00148                 ptd->tdSize = (UINT)dwPtdSize;
00149
00150                 lpDevNames = (LPDEVNAMES) &ptd->tdDriverNameOffset;
00151                 _fmemcpy(lpDevNames, pDN, (size_t)dwDevNamesSize);
00152
00153                 lpDevMode=(LPDEVMODE)(/*(LPSTR)*/&ptd->tdDriverNameOffset+dwDevNamesSize);
00154                 _fmemcpy(lpDevMode, pDM, (size_t)dwDevModeSize);
00155
00156                 ptd->tdDriverNameOffset += 4 ;
00157                 ptd->tdDeviceNameOffset += 4 ;
00158                 ptd->tdPortNameOffset   += 4 ;
00159                 ptd->tdExtDevmodeOffset = (UINT)dwDevNamesSize + 4 ;
00160         }
00161
00162 errReturn:
00163         GlobalUnlock(lpPrintDlg->hDevNames);
00164         GlobalUnlock(lpPrintDlg->hDevMode);
00165
00166         return ptd;
00167 }
00168
00169
00170
00171 /*
00172  * OleStdDeleteTargetDevice()
00173  *
00174  * Purpose:
00175  *
00176  * Parameters:
00177  *
00178  * Return Value:
00179  *    SCODE  -  S_OK if successful
00180  */
00181 STDAPI_(BOOL) OleStdDeleteTargetDevice(DVTARGETDEVICE FAR* ptd)
00182 {
00183         BOOL res=TRUE;
00184
00185         if (ptd != NULL) {
00186                 OleStdFree(ptd);
00187         }
00188
00189         return res;
00190 }
00191
00192
00193
00194 /*
00195  * OleStdCopyTargetDevice()
00196  *
00197  * Purpose:
00198  *  duplicate a TARGETDEVICE struct. this function allocates memory for
00199  *  the copy. the caller MUST free the allocated copy when done with it
00200  *  using the standard allocator returned from CoGetMalloc.
00201  *  (OleStdFree can be used to free the copy).
00202  *
00203  * Parameters:
00204  *  ptdSrc      pointer to source TARGETDEVICE
00205  *
00206  * Return Value:
00207  *    pointer to allocated copy of ptdSrc
00208  *    if ptdSrc==NULL then retuns NULL is returned.
00209  *    if ptdSrc!=NULL and memory allocation fails, then NULL is returned
00210  */
00211 STDAPI_(DVTARGETDEVICE FAR*) OleStdCopyTargetDevice(DVTARGETDEVICE FAR* ptdSrc)
00212 {
00213   DVTARGETDEVICE FAR* ptdDest = NULL;
00214
00215   if (ptdSrc == NULL) {
00216         return NULL;
00217   }
00218
00219   if ((ptdDest = (DVTARGETDEVICE FAR*)OleStdMalloc(ptdSrc->tdSize)) != NULL) {
00220         _fmemcpy(ptdDest, ptdSrc, (size_t)ptdSrc->tdSize);
00221   }
00222
00223   return ptdDest;
00224 }
00225
00226
00227 /*
00228  * OleStdCopyFormatEtc()
00229  *
00230  * Purpose:
00231  *  Copies the contents of a FORMATETC structure. this function takes
00232  *  special care to copy correctly copying the pointer to the TARGETDEVICE
00233  *  contained within the source FORMATETC structure.
00234  *  if the source FORMATETC has a non-NULL TARGETDEVICE, then a copy
00235  *  of the TARGETDEVICE will be allocated for the destination of the
00236  *  FORMATETC (petcDest).
00237  *
00238  *  NOTE: the caller MUST free the allocated copy of the TARGETDEVICE
00239  *  within the destination FORMATETC when done with it
00240  *  using the standard allocator returned from CoGetMalloc.
00241  *  (OleStdFree can be used to free the copy).
00242  *
00243  * Parameters:
00244  *  petcDest      pointer to destination FORMATETC
00245  *  petcSrc       pointer to source FORMATETC
00246  *
00247  * Return Value:
00248  *    returns TRUE is copy is successful; retuns FALSE if not successful
00249  */
00250 STDAPI_(BOOL) OleStdCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc)
00251 {
00252   if ((petcDest == NULL) || (petcSrc == NULL)) {
00253         return FALSE;
00254   }
00255
00256   petcDest->cfFormat = petcSrc->cfFormat;
00257   petcDest->ptd      = OleStdCopyTargetDevice(petcSrc->ptd);
00258   petcDest->dwAspect = petcSrc->dwAspect;
00259   petcDest->lindex   = petcSrc->lindex;
00260   petcDest->tymed    = petcSrc->tymed;
00261
00262   return TRUE;
00263
00264 }
00265
00266
00267 // returns 0 for exact match, 1 for no match, -1 for partial match (which is
00268 // defined to mean the left is a subset of the right: fewer aspects, null target
00269 // device, fewer medium).
00270
00271 STDAPI_(int) OleStdCompareFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight)
00272 {
00273         BOOL bExact = TRUE;
00274
00275         if (pFetcLeft->cfFormat != pFetcRight->cfFormat)
00276                 return 1;
00277         else if (!OleStdCompareTargetDevice (pFetcLeft->ptd, pFetcRight->ptd))
00278                 return 1;
00279         if (pFetcLeft->dwAspect == pFetcRight->dwAspect)
00280                 // same aspects; equal
00281                 ;
00282         else if ((pFetcLeft->dwAspect & ~pFetcRight->dwAspect) != 0)
00283                 // left not subset of aspects of right; not equal
00284                 return 1;
00285         else
00286                 // left subset of right
00287                 bExact = FALSE;
00288
00289         if (pFetcLeft->tymed == pFetcRight->tymed)
00290                 // same medium flags; equal
00291                 ;
00292         else if ((pFetcLeft->tymed & ~pFetcRight->tymed) != 0)
00293                 // left not subset of medium flags of right; not equal
00294                 return 1;
00295         else
00296                 // left subset of right
00297                 bExact = FALSE;
00298
00299         return bExact ? 0 : -1;
00300 }
00301
00302
00303
00304 STDAPI_(BOOL) OleStdCompareTargetDevice
00305         (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight)
00306 {
00307         if (ptdLeft == ptdRight)
00308                 // same address of td; must be same (handles NULL case)
00309                 return TRUE;
00310         else if ((ptdRight == NULL) || (ptdLeft == NULL))
00311                 return FALSE;
00312         else if (ptdLeft->tdSize != ptdRight->tdSize)
00313                 // different sizes, not equal
00314                 return FALSE;
00315 #ifdef WIN32
00316         else if (memcmp(ptdLeft, ptdRight, ptdLeft->tdSize) != 0)
00317 #else
00318         else if (_fmemcmp(ptdLeft, ptdRight, (int)ptdLeft->tdSize) != 0)
00319 #endif
00320                 // not same target device, not equal
00321                 return FALSE;
00322
00323         return TRUE;
00324 }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Extension/tutorial/step2/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Extension
  • tutorial
  • step2

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/Methodsub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

Methodsub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __METHODSUB_H__
00018 #define __METHODSUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 typedef list<LONGLONG> TimeStack;
00025 typedef map<ULONG64, TimeStack *> TimeMap;
00026 class CComSpy;
00027
00028 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00029 Class:   CMethodSub
00030 Summary: Method Events Subscriber
00031 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00032 class ATL_NO_VTABLE CMethodSub :
00033   public CSysLCESub,
00034   public IComMethodEvents
00035 {
00036 public:
00037
00038   TimeMap m_map;
00039   CMethodSub(CComSpy * pSpy)
00040   {
00041     m_pSpy = pSpy;
00042   }
00043   CMethodSub()
00044   {
00045     m_pSpy = NULL;
00046   }
00047
00048   DECLARE_NOT_AGGREGATABLE(CMethodSub)
00049   DECLARE_GET_CONTROLLING_UNKNOWN()
00050
00051   BEGIN_COM_MAP(CMethodSub)
00052     COM_INTERFACE_ENTRY(IComMethodEvents)
00053     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00054   END_COM_MAP()
00055
00056   STDMETHODIMP GetEventType(EventEnum * e){*e = Method;return S_OK;}
00057   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_ComServiceEvents;return S_OK;}
00058   STDMETHODIMP GetInterface(IID* iid){*iid = IID_IComMethodEvents;return S_OK;}
00059
00060   STDMETHOD(OnMethodCall)(COMSVCSEVENTINFO * pInfo, ULONG64 oid, REFCLSID cid, REFIID rid, ULONG iMeth);
00061   STDMETHOD(OnMethodReturn)(COMSVCSEVENTINFO * pInfo, ULONG64 oid, REFCLSID cid, REFIID rid, ULONG iMeth, HRESULT hr);
00062   STDMETHOD(OnMethodException)(COMSVCSEVENTINFO * pInfo, ULONG64 oid, REFCLSID cid, REFIID rid, ULONG iMeth);
00063
00064   HRESULT GetClsidOfTypeLib2 (IID * piid, UUID * puuidClsid);
00065   HRESULT GetMethodName (REFIID riid, int iMeth, _TCHAR** ppszMethodName);
00066
00067 };
00068 #endif //__METHODSUB_H__
00069
00070
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPartitionInfo Member List

This is the complete list of members for CPartitionInfo, including all inherited members.
CMgdClusCfgInit(void) | CMgdClusCfgInit |
CMgdClusCfgInit(void) | CMgdClusCfgInit |
CPartitionInfo(const CPartitionInfo &nodeSrc) | CPartitionInfo | [private]
CPartitionInfo(void) | CPartitionInfo |
END_COM_MAP() | CPartitionInfo |
GetCallback(void) | CMgdClusCfgInit | [inline]
GetCallback(void) | CMgdClusCfgInit | [inline]
GetDescription(BSTR *pbstrDescriptionOut) | CPartitionInfo |
GetDisplayName(void) | CMgdClusCfgInit | [inline]
GetDisplayName(void) | CMgdClusCfgInit | [inline]
GetDllName(void) | CMgdClusCfgInit | [inline]
GetDllName(void) | CMgdClusCfgInit | [inline]
GetDriveLetterMappings(SDriveLetterMapping *pdlmDriveLetterUsageOut) | CPartitionInfo |
GetLCID(void) | CMgdClusCfgInit | [inline]
GetLCID(void) | CMgdClusCfgInit | [inline]
GetName(BSTR *pbstrNameOut) | CPartitionInfo |
GetNodeName(void) | CMgdClusCfgInit | [inline]
GetNodeName(void) | CMgdClusCfgInit | [inline]
GetResTypeName(void) | CMgdClusCfgInit | [inline]
GetResTypeName(void) | CMgdClusCfgInit | [inline]
GetSize(ULONG *pcMegaBytes) | CPartitionInfo |
GetUID(BSTR *pbstrUIDOut) | CPartitionInfo |
HrAddLogicalDiskToArray(IWbemClassObject *pDiskIn) | CPartitionInfo | [private]
HrGetFriendlyName(BSTR *pbstrNameOut) | CPartitionInfo |
IPartitionProperties::HrGetFriendlyName(BSTR *pbstrNameOut) | IPartitionProperties |
HrGetLogicalDisks(IWbemClassObject *pPartitionIn) | CPartitionInfo | [private]
HrIsNTFS(void) | CPartitionInfo |
IPartitionProperties::HrIsNTFS(void) | IPartitionProperties |
HrIsThisLogicalDisk(WCHAR cLogicalDisk) | CPartitionInfo |
IPartitionProperties::HrIsThisLogicalDisk(WCHAR cLogicalDiskIn) | IPartitionProperties |
HrLogLogicalDiskInfo(IWbemClassObject *pLogicalDiskIn, BSTR bstrDeviceIDIn) | CPartitionInfo | [private]
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, LPCWSTR pcszReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, UINT idsDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, LPCWSTR pcszReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, LPCWSTR pcszDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSendStatusReport(CLSID clsidTaskMajorIn, CLSID clsidTaskMinorIn, ULONG ulMinIn, ULONG ulMaxIn, ULONG ulCurrentIn, HRESULT hrStatusIn, UINT idsDescriptionIn, UINT idsReferenceIn...) | CMgdClusCfgInit |
HrSetDeviceID(BSTR bstrDeviceIDIn) | CPartitionInfo |
IPartitionProperties::HrSetDeviceID(BSTR bstDeviceIDIn) | IPartitionProperties |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMgdClusCfgInit |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMgdClusCfgInit |
m_bstrDescription | CPartitionInfo | [private]
m_bstrDiskDeviceID | CPartitionInfo | [private]
m_bstrName | CPartitionInfo | [private]
m_bstrUID | CPartitionInfo | [private]
m_cRef | CPartitionInfo | [private]
m_idxNextLogicalDisk | CPartitionInfo | [private]
m_lcid | CPartitionInfo | [private]
m_pIWbemServices | CPartitionInfo | [private]
m_prgLogicalDisks | CPartitionInfo | [private]
m_ulPartitionSize | CPartitionInfo | [private]
operator=(const CPartitionInfo &nodeSrc) | CPartitionInfo | [private]
SetDescription(LPCWSTR bstrDescriptionIn) | CPartitionInfo |
SetDriveLetterMappings(SDriveLetterMapping dlmDriveLetterMappingIn) | CPartitionInfo |
SetName(LPCWSTR bstrNameIn) | CPartitionInfo |
SetWbemObject(IWbemClassObject *pPartitionIn, BOOL *pfRetainObjectOut) | CPartitionInfo |
IWMIObject::SetWbemObject(IWbemClassObject *pObjectIn, BOOL *pfRetainObjectOut) | IWMIObject |
SetWbemServices(IWbemServices *pIWbemServicesIn) | CPartitionInfo |
IWMIServices::SetWbemServices(IWbemServices *pIWbemServicesIn) | IWMIServices |
~CMgdClusCfgInit(void) | CMgdClusCfgInit | [virtual]
~CMgdClusCfgInit(void) | CMgdClusCfgInit | [virtual]
~CPartitionInfo(void) | CPartitionInfo | [virtual]
Generated on Wed Nov 13 2024 16:57:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcComms.h Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcComms.h

Go to the documentation of this file.
00001 #if !defined(AFX_AGENTCTLCOMMANDSEX_H__AB8FEBA3_3841_11D2_8512_00C04FA34A14__INCLUDED_)
00002 #define AFX_AGENTCTLCOMMANDSEX_H__AB8FEBA3_3841_11D2_8512_00C04FA34A14__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
00008
00009 // NOTE: Do not modify the contents of this file.  If this class is regenerated by
00010 //  Microsoft Visual C++, your modifications will be overwritten.
00011
00012
00013 // Dispatch interfaces referenced by this interface
00014 class CAgentCtlCommandEx;
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // CAgentCtlCommandsEx wrapper class
00018
00019 class CAgentCtlCommandsEx : public COleDispatchDriver
00020 {
00021 public:
00022   CAgentCtlCommandsEx() {}    // Calls COleDispatchDriver default constructor
00023   CAgentCtlCommandsEx(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
00024   CAgentCtlCommandsEx(const CAgentCtlCommandsEx& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
00025
00026 // Attributes
00027 public:
00028
00029 // Operations
00030 public:
00031   CAgentCtlCommandEx GetItem(LPCTSTR Name);
00032   CAgentCtlCommandEx Command(LPCTSTR Name);
00033   long GetCount();
00034   CString GetCaption();
00035   void SetCaption(LPCTSTR lpszNewValue);
00036   CString GetVoice();
00037   void SetVoice(LPCTSTR lpszNewValue);
00038   BOOL GetVisible();
00039   void SetVisible(BOOL bNewValue);
00040   LPDISPATCH Add(LPCTSTR Name, const VARIANT& Caption, const VARIANT& Voice, const VARIANT& Enabled, const VARIANT& Visible);
00041   LPDISPATCH Insert(LPCTSTR Name, LPCTSTR RefName, const VARIANT& Before, const VARIANT& Caption, const VARIANT& Voice, const VARIANT& Enabled, const VARIANT& Visible);
00042   void Remove(LPCTSTR Name);
00043   void RemoveAll();
00044   void SetDefaultCommand(LPCTSTR lpszNewValue);
00045   CString GetDefaultCommand();
00046   void SetHelpContextID(long nNewValue);
00047   long GetHelpContextID();
00048   void SetFontName(LPCTSTR lpszNewValue);
00049   CString GetFontName();
00050   long GetFontSize();
00051   void SetFontSize(long nNewValue);
00052   void SetVoiceCaption(LPCTSTR lpszNewValue);
00053   CString GetVoiceCaption();
00054   void SetGlobalVoiceCommandsEnabled(BOOL bNewValue);
00055   BOOL GetGlobalVoiceCommandsEnabled();
00056 };
00057
00058 //{{AFX_INSERT_LOCATION}}
00059 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00060
00061 #endif // !defined(AFX_AGENTCTLCOMMANDSEX_H__AB8FEBA3_3841_11D2_8512_00C04FA34A14__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/registry.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

registry.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef __Registry_H__
00015 #define __Registry_H__
00016
00017 #include <tchar.h>
00018
00019 // This function will register a component in the Registry.
00020 // The component calls this function from its DllRegisterServer function.
00021 HRESULT RegisterServer( HMODULE hModule,
00022                         const CLSID& clsid,
00023                         const _TCHAR* szFriendlyName) ;
00024
00025 // This function will unregister a component.  Components
00026 // call this function from their DllUnregisterServer function.
00027 HRESULT UnregisterServer( const CLSID& clsid ) ;
00028
00029
00030 // This function will register a Snap-In component.  Components
00031 // call this function from their DllRegisterServer function.
00032 HRESULT RegisterSnapin( const CLSID& clsid,            // Class ID
00033                         const _TCHAR* szNameString,    // NameString
00034                         const CLSID& clsidAbout,       // Class Id for About Class
00035                         const BOOL fSupportExtensions = FALSE
00036                       );
00037
00038 HRESULT UnregisterSnapin( const CLSID& clsid );        // Class ID
00039
00040 #endif
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/AdvClient/AdvClient.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • AdvClient

AdvClient.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  HMMSamp.cpp
00006 //
00007 // Description:
00008 //  This file implements the CHMMSampleApp class which
00009 //    is the main class for the tutorial.
00010 //
00011 // History:
00012 //
00013 // **************************************************************************
00014
00015
00016 #include "stdafx.h"
00017 #include <objbase.h>
00018 #include "AdvClient.h"
00019 #include "AdvClientDlg.h"
00020 #include <strsafe.h>
00021
00022 #ifdef _DEBUG
00023 #define new DEBUG_NEW
00024 #undef THIS_FILE
00025 static char THIS_FILE[] = __FILE__;
00026 #endif
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // CHMMSampleApp
00030
00031 BEGIN_MESSAGE_MAP(CHMMSampleApp, CWinApp)
00032   //{{AFX_MSG_MAP(CHMMSampleApp)
00033     // NOTE - the ClassWizard will add and remove mapping macros here.
00034     //    DO NOT EDIT what you see in these blocks of generated code!
00035   //}}AFX_MSG
00036   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00037 END_MESSAGE_MAP()
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // CHMMSampleApp construction
00041
00042 CHMMSampleApp::CHMMSampleApp()
00043 {
00044   // TODO: add construction code here,
00045   // Place all significant initialization in InitInstance
00046 }
00047
00048 /////////////////////////////////////////////////////////////////////////////
00049 // The one and only CHMMSampleApp object
00050
00051 CHMMSampleApp theApp;
00052
00053 // **************************************************************************
00054 //
00055 //  CHMMSampleApp::InitSecurity()
00056 //
00057 // Description:
00058 //    Initializes COM security if DCOM is installed.
00059 // Parameters:
00060 //    None.
00061 //
00062 // Returns:
00063 //    nothing.
00064 //
00065 // Globals accessed:
00066 //    None.
00067 //
00068 // Globals modified:
00069 //    None.
00070 //
00071 //===========================================================================
00072
00073 BOOL CHMMSampleApp::InitSecurity(void)
00074 {
00075   // NOTE: dwAuthnLevel needs to be set to RPC_C_AUTHN_LEVEL_NONE
00076   // if you would like to perform asynchronous WMI operations remotely in
00077   // environments where "Local System" account does not have a network identity
00078   // (such as non-Kerberos environments).
00079   // However, setting dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
00080   // creates a security vulnerability in your client application.
00081   // It is therefore advisable to use semi-synchronous APIs for WMI event
00082   // and data retrieval instead.
00083
00084   HRESULT hres = CoInitializeSecurity(NULL, -1, NULL, NULL,
00085                 RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
00086                 RPC_C_IMP_LEVEL_IMPERSONATE,
00087                                 NULL,
00088                 EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
00089                 NULL);
00090     return SUCCEEDED(hres);
00091 }
00092 // **************************************************************************
00093 //
00094 //  CHMMSampleApp::InitInstance()
00095 //
00096 // Description:
00097 //    Initializes COM then initializes security in a way that allows
00098 //    objectSink to be called.
00099 // Parameters:
00100 //    None.
00101 //
00102 // Returns:
00103 //    whether or not it initialized everything.
00104 //
00105 // Globals accessed:
00106 //    None.
00107 //
00108 // Globals modified:
00109 //    None.
00110 //
00111 //===========================================================================
00112 BOOL CHMMSampleApp::InitInstance()
00113 {
00114   // OLE initialization. This is 'lighter' than OleInitialize()
00115   //  which also setups DnD, etc.
00116   if(SUCCEEDED(CoInitialize(NULL)))
00117   {
00118     if(!InitSecurity())
00119     {
00120       AfxMessageBox(_T("CoInitializeSecurity Failed"));
00121       return FALSE;
00122     }
00123   }
00124   else // didnt CoInitialize()
00125   {
00126     AfxMessageBox(_T("CoInitialize Failed"));
00127     return FALSE;
00128   } // endif OleInitialize()
00129
00130   // Standard initialization
00131   // If you are not using these features and wish to reduce the size
00132   //  of your final executable, you should remove from the following
00133   //  the specific initialization routines you do not need.
00134
00135 #ifdef _AFXDLL
00136   Enable3dControls();     // Call this when using MFC in a shared DLL
00137 #else
00138   Enable3dControlsStatic(); // Call this when linking to MFC statically
00139 #endif
00140
00141   CAdvClientDlg dlg;
00142   m_pMainWnd = &dlg;
00143   INT_PTR nResponse = dlg.DoModal();
00144   if (nResponse == IDOK)
00145   {
00146     // TODO: Place code here to handle when the dialog is
00147     //  dismissed with OK
00148   }
00149   else if (nResponse == IDCANCEL)
00150   {
00151     // TODO: Place code here to handle when the dialog is
00152     //  dismissed with Cancel
00153   }
00154
00155   // Since the dialog has been closed, return FALSE so that we exit the
00156   //  application, rather than start the application's message pump.
00157   return FALSE;
00158 }
00159 // **************************************************************************
00160 //
00161 //  CHMMSampleApp::ExitInstance()
00162 //
00163 // Description:
00164 //    Uninitialize COM.
00165 // Parameters:
00166 //    None.
00167 //
00168 // Returns:
00169 //    the value of the base class's routine.
00170 //
00171 // Globals accessed:
00172 //    None.
00173 //
00174 // Globals modified:
00175 //    None.
00176 //
00177 //===========================================================================
00178 int CHMMSampleApp::ExitInstance()
00179 {
00180   CoUninitialize();
00181
00182   return CWinApp::ExitInstance();
00183 }
00184
00185
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/ADsOpenDSObject.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

ADsOpenDSObject.h

Go to the documentation of this file.
00001 #if !defined(AFX_ADSOPENDSOBJECT_H__60690A52_0936_11D2_A3EC_0080C7D071BF__INCLUDED_)
00002 #define AFX_ADSOPENDSOBJECT_H__60690A52_0936_11D2_A3EC_0080C7D071BF__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007 // ADsOpenDSObject.h : header file
00008 //
00009
00010 /////////////////////////////////////////////////////////////////////////////
00011 // CDlgIADsOpenDSObject dialog
00012
00013 class CDlgIADsOpenDSObject : public CDialog
00014 {
00015 // Construction
00016 public:
00017   CDlgIADsOpenDSObject(LPUNKNOWN pUnk, LPUNKNOWN *ppNew, CWnd* pParent = NULL);   // standard constructor
00018   ~CDlgIADsOpenDSObject();
00019   // Dialog Data
00020   //{{AFX_DATA(CDlgIADsOpenDSObject)
00021   enum { IDD = IDD_IADSOPENDSOBJECT };
00022   CString m_sPassword;
00023   CString m_sUserName;
00024   BOOL  m_bEncrypt;
00025   BOOL  m_bReadOnly;
00026   BOOL  m_bSecured;
00027   BOOL  m_bPrompt;
00028   BOOL  m_bNoAuthentication;
00029   CString m_sADsPath;
00030   BOOL  m_bClearText;
00031   BOOL  m_bFastBind;
00032   BOOL  m_bSealing;
00033   BOOL  m_bSigning;
00034   //}}AFX_DATA
00035
00036
00037 // Overrides
00038   // ClassWizard generated virtual function overrides
00039   //{{AFX_VIRTUAL(CDlgIADsOpenDSObject)
00040   protected:
00041   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00042   //}}AFX_VIRTUAL
00043
00044 // Implementation
00045 protected:
00046   IADsOpenDSObject  *m_pOpenDS;
00047   LPUNKNOWN      *m_ppUnk;
00048
00049   // Generated message map functions
00050   //{{AFX_MSG(CDlgIADsOpenDSObject)
00051   virtual void OnOK();
00052   afx_msg void OnChangeUsername();
00053   virtual BOOL OnInitDialog();
00054   afx_msg void OnChangeADsPath();
00055   //}}AFX_MSG
00056   DECLARE_MESSAGE_MAP()
00057 };
00058
00059 //{{AFX_INSERT_LOCATION}}
00060 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00061
00062 #endif // !defined(AFX_ADSOPENDSOBJECT_H__60690A52_0936_11D2_A3EC_0080C7D071BF__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Proppage/compdata.h Source File

  • SysMgmt
  • MMC
  • Proppage

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData, IExtendPropertySheet2
00028 {
00029     friend class CComponent;
00030
00031 private:
00032     ULONG       m_cref;
00033     LPCONSOLE     m_ipConsole;
00034     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00035
00036     CStaticNode     *m_pStaticNode;
00037
00038 public:
00039     CComponentData();
00040     ~CComponentData();
00041
00042     ///////////////////////////////
00043     // Interface IUnknown
00044     ///////////////////////////////
00045     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046     STDMETHODIMP_(ULONG) AddRef();
00047     STDMETHODIMP_(ULONG) Release();
00048
00049     ///////////////////////////////
00050     // Interface IComponentData
00051     ///////////////////////////////
00052     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053         /* [in] */ LPUNKNOWN pUnknown);
00054
00055         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00056         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00059         /* [in] */ LPDATAOBJECT lpDataObject,
00060         /* [in] */ MMC_NOTIFY_TYPE event,
00061         /* [in] */ LPARAM arg,
00062         /* [in] */ LPARAM param);
00063
00064         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00065
00066     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00067         /* [in] */ MMC_COOKIE cookie,
00068         /* [in] */ DATA_OBJECT_TYPES type,
00069         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00070
00071         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075         /* [in] */ LPDATAOBJECT lpDataObjectA,
00076         /* [in] */ LPDATAOBJECT lpDataObjectB);
00077
00078         //////////////////////////////////
00079         // Interface IExtendPropertySheet2
00080         //////////////////////////////////
00081         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreatePropertyPages(
00082         /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
00083         /* [in] */ LONG_PTR handle,
00084         /* [in] */ LPDATAOBJECT lpIDataObject);
00085
00086         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryPagesFor(
00087         /* [in] */ LPDATAOBJECT lpDataObject);
00088
00089         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetWatermarks(
00090         /* [in] */ LPDATAOBJECT lpIDataObject,
00091         /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
00092         /* [out] */ HBITMAP __RPC_FAR *lphHeader,
00093         /* [out] */ HPALETTE __RPC_FAR *lphPalette,
00094         /* [out] */ BOOL __RPC_FAR *bStretch);
00095 };
00096
00097 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: UDDI/publish/publish.cs Source File

  • UDDI
  • publish

publish.cs

Go to the documentation of this file.
00001 /*=====================================================================
00002   This file is part of the Microsoft UDDI SDK Code Samples.
00003
00004   Copyright (C) Microsoft Corporation.  All rights reserved.
00005
00006 This source code is intended only as a supplement to Microsoft
00007 Development Tools and/or on-line documentation.  See these other
00008 materials for detailed information regarding Microsoft code samples.
00009
00010 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00011 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00012 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00013 PARTICULAR PURPOSE.
00014 =====================================================================*/
00015
00016 using System;
00017 using Microsoft.Uddi;
00018 using Microsoft.Uddi.Businesses;
00019 using Microsoft.Uddi.Extensions;
00020 using Microsoft.Uddi.Services;
00021 using Microsoft.Uddi.TModels;
00022
00023 namespace Microsoft.Uddi.Demo
00024 {
00025   public class Publish
00026   {
00027     static UddiConnection _connection;
00028
00029     /// <summary>
00030     ///   Entry Point
00031     /// </summary>
00032     public static void Main( )
00033     {
00034
00035       //
00036       // Attempt to find the first site listed in Active Directory
00037       //
00038       UddiSiteLocation location = GetFirstLocation( AuthenticationMode.WindowsAuthentication );
00039
00040       //
00041       // Create a location if no location was returned from Active Directory
00042       // These settings use the default access points for UDDI Services and Windows Authentication
00043       // TODO: Update with actual servername
00044       //
00045
00046       string httpServerName = "http://servername/uddi/";
00047       string httpsServerName = "https://servername/uddi/";
00048
00049       if( null == location )
00050       {
00051         location = new UddiSiteLocation(
00052           httpServerName + "inquire.asmx",
00053           httpsServerName + "publish.asmx",
00054           httpServerName + "extension.asmx",
00055           "My Site",
00056           AuthenticationMode.WindowsAuthentication );
00057       }
00058
00059       //
00060       // Create the connection object.
00061       //
00062       _connection = new UddiConnection( location );
00063
00064
00065       Console.WriteLine( "Current Data" );
00066
00067       //
00068       // Display the current entities owned by this publisher
00069       //
00070       DisplayOwnedEntities();
00071
00072       Console.WriteLine( "Saving New Data" );
00073
00074       //
00075       // Create a new Provider.
00076       //
00077       BusinessEntity entity = SaveNewProvider( "My New Provider Name", "Description of my new Provider" );
00078
00079       //
00080       // Add a new Service to that provider
00081       //
00082       AddService( entity, "My New Service", "Description for my new Service" );
00083
00084       Console.WriteLine( "New Data" );
00085
00086       //
00087       // Display the currently owned entities again.
00088       //
00089       DisplayOwnedEntities();
00090
00091       Console.WriteLine( "Taxonomy Data" );
00092
00093       //
00094       // Display the taxonomy information for UddiOrgTypes.
00095       //
00096       DisplayTaxonomy( CommonCanonical.UddiOrgTypes );
00097     }
00098
00099     /// <summary>
00100     ///   Searches Active Directory for Uddi Sites, using the specified Authentication
00101     ///   Mode as criteria for the search.
00102     /// </summary>
00103     /// <param name="mode"> The authentication mode you would like to query for.</param>
00104     /// <returns>The first UddiSiteLocation registered with Active Directory.</returns>
00105     private static UddiSiteLocation GetFirstLocation( AuthenticationMode mode )
00106     {
00107       UddiSiteLocation[] locations = UddiSiteDiscovery.Find( UddiSiteUrlType.All, mode );
00108       if( locations.Length > 0 )
00109         return locations[ 0 ];
00110       else
00111         return null;
00112
00113     }
00114
00115     /// <summary>
00116     ///   Writes information about the current publishers owned data to STDOUT
00117     /// </summary>
00118     private static void DisplayOwnedEntities()
00119     {
00120       GetRegisteredInfo gri = new GetRegisteredInfo();
00121       RegisteredInfo ri = gri.Send( _connection );
00122
00123       foreach( BusinessInfo binfo in ri.BusinessInfos )
00124       {
00125         Console.WriteLine( "Business Entity" );
00126         Console.WriteLine( "\tName: " + binfo.Names[ 0 ].Text );
00127         Console.WriteLine( "\tBusinessKey: " + binfo.BusinessKey );
00128         Console.WriteLine( "\tServiceCount: " + binfo.ServiceInfos.Count );
00129       }
00130       foreach( TModelInfo tinfo in ri.TModelInfos )
00131       {
00132         Console.WriteLine( "Business Entity" );
00133         Console.WriteLine( "\tName: " + tinfo.Name.Text );
00134         Console.WriteLine( "\tTModelKey: " + tinfo.TModelKey );
00135       }
00136
00137     }
00138
00139     /// <summary>
00140     ///   Saves a new BusinessEntity object with the specified name and
00141     ///   description.
00142     /// </summary>
00143     /// <param name="name">Name for the new BusinessEntity.</param>
00144     /// <param name="desc">Description for the new BusinessEntity.</param>
00145     /// <returns>The Resulting BusinessEntity after saving it.</returns>
00146     private static BusinessEntity SaveNewProvider( string name, string desc )
00147     {
00148       BusinessEntity entity = new BusinessEntity();
00149       entity.Names.Add( name );
00150       entity.Descriptions.Add( desc );
00151
00152       SaveBusiness sb = new SaveBusiness( entity );
00153       BusinessDetail detail = sb.Send( _connection );
00154
00155       return detail.BusinessEntities[ 0 ];
00156     }
00157
00158     /// <summary>
00159     ///   Create a service, and save it using the provided BusinessEntity, name, and
00160     ///   description.
00161     /// </summary>
00162     /// <param name="entity">The BusinessEntity that will own this BusinessService.</param>
00163     /// <param name="name">The name for the new BusinessService.</param>
00164     /// <param name="desc">The description for the new BusinessService.</param>
00165     /// <returns>The resulting BusinessService after the save.</returns>
00166     private static BusinessService AddService( BusinessEntity entity, string name, string desc )
00167     {
00168       BusinessService service = new BusinessService();
00169       service.BusinessKey = entity.BusinessKey;
00170       service.Names.Add( name );
00171       service.Descriptions.Add( desc );
00172
00173       SaveService ss = new SaveService( service );
00174       ServiceDetail detail = ss.Send( _connection );
00175
00176       return detail.BusinessServices[ 0 ];
00177     }
00178
00179     /// <summary>
00180     ///   Displays the Taxonomy information for a specified TModelKey.
00181     /// </summary>
00182     /// <param name="key">TModelKey to perferm the Categorization lookup on.</param>
00183     private static void DisplayTaxonomy( string key )
00184     {
00185       Category cat = new Category( key );
00186       cat.RelationshipQualifiers.Add( RelationshipQualifier.root );
00187
00188       GetRelatedCategories grc = new GetRelatedCategories();
00189
00190       grc.Categories.Add( cat );
00191
00192       CategoryList list = grc.Send( _connection );
00193
00194       foreach( CategoryInfo info in list.CategoryInfos )
00195       {
00196         Console.WriteLine( info.TModelKey );
00197         foreach( CategoryValue cv in info.Roots )
00198         {
00199           Console.WriteLine( "\t" + cv.KeyName + "(" + cv.KeyValue + ")" );
00200           DisplayTaxonomyItems( info.TModelKey, cv.KeyValue, 2 );
00201         }
00202       }
00203     }
00204
00205     /// <summary>
00206     ///     Displays the Taxonomy information for a specified TModelKey, begining
00207     ///     at a specified KeyValue.
00208     /// </summary>
00209     /// <param name="key">TModelKey for the the Taxonomy</param>
00210     /// <param name="value">KeyValue to start from.</param>
00211     /// <param name="tabs">Number or \t characters to prepend to the Output.</param>
00212     private static void DisplayTaxonomyItems( string key, string value, int tabs )
00213     {
00214       string line = "";
00215       for( int i = 0;i<tabs;i++ )
00216         line += "\t";
00217
00218
00219       Category cat = new Category( key, value );
00220       cat.RelationshipQualifiers.Add( RelationshipQualifier.child );
00221
00222       GetRelatedCategories grc = new GetRelatedCategories();
00223
00224       grc.Categories.Add( cat );
00225
00226       CategoryList list = grc.Send( _connection );
00227
00228       foreach( CategoryInfo info in list.CategoryInfos )
00229       {
00230         foreach( CategoryValue cv in info.Children )
00231         {
00232           Console.WriteLine( line + cv.KeyName + "(" + cv.KeyValue + ")" );
00233           DisplayTaxonomyItems( key, cv.KeyValue, tabs + 1 );
00234         }
00235       }
00236     }
00237
00238   }
00239 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CInstanceSub Member List

This is the complete list of members for CInstanceSub, including all inherited members.
CInstanceSub(CComSpy *pSpy) | CInstanceSub | [inline]
CInstanceSub() | CInstanceSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetEventClass(LPGUID guid) | CInstanceSub | [inline, virtual]
GetEventType(EventEnum *e) | CInstanceSub | [inline, virtual]
GetInterface(IID *iid) | CInstanceSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnObjectCreate(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, REFCLSID clsid, REFGUID tsid, ULONG64 CtxtID, ULONG64 ObjectID) | CInstanceSub | [inline]
OnObjectDestroy(COMSVCSEVENTINFO *pInfo, ULONG64 CtxtID) | CInstanceSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:56:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Toolbar/guids.h Source File

  • SysMgmt
  • MMC
  • Toolbar

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {88249524-8AD1-11d2-8A0B-000021473128}
00020 DEFINE_GUID(CLSID_CComponentData,
00021             0x88249524, 0x8ad1, 0x11d2, 0x8a, 0xb, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28);
00022
00023 // {88249526-8AD1-11d2-8A0B-000021473128}
00024 DEFINE_GUID(CLSID_CSnapinAbout,
00025             0x88249526, 0x8ad1, 0x11d2, 0x8a, 0xb, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/tapisend/common.h Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • tapisend

common.h

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1999 - 2000  Microsoft Corporation
00004
00005
00006 Module Name:
00007
00008     common.h
00009
00010
00011 Abstract:
00012
00013     include files and declarations used throughout the application
00014
00015 */
00016
00017
00018
00019 #define _WIN32_DCOM
00020
00021
00022 #include <stdio.h>
00023 #include <windows.h>
00024 #include <tapi3.h>
00025
00026 #include <vfw.h>
00027 #include <crtdbg.h>
00028
00029 #include <uuids.h>
00030 #include <Mtype.h>
00031
00032 #include <amstream.h>
00033
00034 #include <vfwmsgs.h>
00035
00036 #include <deque>
00037 #include <strsafe.h>
00038
00039
00040
00041 //
00042 // logging functions
00043 //
00044
00045 void LogMessage(CHAR *pszFormat, ... );
00046
00047 #define LogError LogMessage
00048
00049 void LogFormat(WAVEFORMATEX *pWaveFormat);
00050
00051
00052 //
00053 // memory allocation routines
00054 //
00055
00056 void *AllocateMemory(SIZE_T nMemorySize);
00057
00058 void FreeMemory(void* pMemory);
00059
00060
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Client/BYOTTransaction/BYOTTransaction.Idl Source File

  • Com
  • Services
  • BYOT
  • Client
  • BYOTTransaction

BYOTTransaction.Idl

Go to the documentation of this file.
00001 // ByotTransaction.idl : IDL source for ByotTransaction.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (ByotTransaction.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009   [
00010     object,
00011     uuid(6812A8D0-C6B7-11D2-8482-0080C7A03FC6),
00012     dual,
00013     helpstring("IByotTransaction Interface"),
00014     pointer_default(unique)
00015   ]
00016   interface IByotTransaction : IDispatch
00017   {
00018     [id(1), helpstring("Begins a BYOT Transaction")] HRESULT BeginTransaction();
00019     [id(2), helpstring("Commits the BYOT Transaction")] HRESULT CommitTransaction();
00020     [id(3), helpstring("Aborts the BYOT Transaction")] HRESULT AbortTransaction();
00021     [propget, id(4), helpstring("Retrieves the TIP URL associated with this BYOT Transaction")] HRESULT TipURL([out, retval] BSTR *pVal);
00022   };
00023
00024 [
00025   uuid(F9638B00-C6B6-11D2-8482-0080C7A03FC6),
00026   version(1.0),
00027   helpstring("BYOT Sample ByotTransaction 1.0 Type Library")
00028 ]
00029 library BYOTTRANSACTIONLib
00030 {
00031   importlib("stdole32.tlb");
00032   importlib("stdole2.tlb");
00033
00034   [
00035     uuid(B8B87F20-C6B7-11D2-8482-0080C7A03FC6),
00036     helpstring("ByotTransaction Object Class")
00037   ]
00038   coclass ByotTransObj
00039   {
00040     [default] interface IByotTransaction;
00041   };
00042 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditGlyphs/dlldata.c Source File

  • Web
  • Browser
  • EditGlyphs

dlldata.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 /*********************************************************
00006    DllData file -- generated by MIDL compiler
00007
00008         DO NOT ALTER THIS FILE
00009
00010    This file is regenerated by MIDL on every IDL file compile.
00011
00012    To completely reconstruct this file, delete it and rerun MIDL
00013    on all the IDL files in this DLL, specifying this file for the
00014    /dlldata command line option
00015
00016 *********************************************************/
00017
00018 #define PROXY_DELEGATION
00019
00020 #include <rpcproxy.h>
00021
00022 #ifdef __cplusplus
00023 extern "C"   {
00024 #endif
00025
00026 EXTERN_PROXY_FILE( EdGlyphs )
00027
00028
00029 PROXYFILE_LIST_START
00030 /* Start of list */
00031   REFERENCE_PROXY_FILE( EdGlyphs ),
00032 /* End of list */
00033 PROXYFILE_LIST_END
00034
00035
00036 DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
00037
00038 #ifdef __cplusplus
00039 }  /*extern "C" */
00040 #endif
00041
00042 /* end of generated dlldata file */
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/LogWriter/LogWriter.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest
  • LogWriter

LogWriter.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: LogWriter.cpp
00004
00005 Summary: Implementation of DLL Exports.
00006
00007 ----------------------------------------------------------------------------
00008 This file is part of the Microsoft COM+ Samples.
00009
00010 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00011
00012 This source code is intended only as a supplement to Microsoft
00013 Development Tools and/or on-line documentation. See these other
00014 materials for detailed information regarding Microsoft code samples.
00015
00016 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00017 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00019 PARTICULAR PURPOSE.
00020 ==========================================================================+*/
00021
00022
00023 // Note: Proxy/Stub Information
00024 //      To merge the proxy/stub code into the object DLL, add the file
00025 //      dlldatax.c to the project.  Make sure precompiled headers
00026 //      are turned off for this file, and add _MERGE_PROXYSTUB to the
00027 //      defines for the project.
00028 //
00029 //      If you are not running WinNT4.0 or Win95 with DCOM, then you
00030 //      need to remove the following define from dlldatax.c
00031 //      #define _WIN32_WINNT 0x0500
00032 //
00033 //      Further, if you are running MIDL without /Oicf switch, you also
00034 //      need to remove the following define from dlldatax.c.
00035 //      #define USE_STUBLESS_PROXY
00036 //
00037 //      Modify the custom build rule for LogWriter.idl by adding the following
00038 //      files to the Outputs.
00039 //          LogWriter_p.c
00040 //          dlldata.c
00041 //      To build a separate proxy/stub DLL,
00042 //      run nmake -f LogWriterps.mk in the project directory.
00043
00044 #include "stdafx.h"
00045 #include "resource.h"
00046 #include <initguid.h>
00047 #include "LogWriter.h"
00048 #include "dlldatax.h"
00049
00050 #include "LogWriter_i.c"
00051 #include "LogFile.h"
00052
00053 #ifdef _MERGE_PROXYSTUB
00054 extern "C" HINSTANCE hProxyDll;
00055 #endif
00056
00057 CComModule _Module;
00058
00059 BEGIN_OBJECT_MAP(ObjectMap)
00060 OBJECT_ENTRY(CLSID_LogFile, CLogFile)
00061 END_OBJECT_MAP()
00062
00063 /////////////////////////////////////////////////////////////////////////////
00064 // DLL Entry Point
00065
00066 extern "C"
00067 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00068 {
00069     lpReserved;
00070 #ifdef _MERGE_PROXYSTUB
00071     if (!PrxDllMain(hInstance, dwReason, lpReserved))
00072         return FALSE;
00073 #endif
00074     if (dwReason == DLL_PROCESS_ATTACH)
00075     {
00076         _Module.Init(ObjectMap, hInstance, &LIBID_LOGWRITERLib);
00077         DisableThreadLibraryCalls(hInstance);
00078     }
00079     else if (dwReason == DLL_PROCESS_DETACH)
00080         _Module.Term();
00081     return TRUE;    // ok
00082 }
00083
00084 /////////////////////////////////////////////////////////////////////////////
00085 // Used to determine whether the DLL can be unloaded by OLE
00086
00087 STDAPI DllCanUnloadNow(void)
00088 {
00089 #ifdef _MERGE_PROXYSTUB
00090     if (PrxDllCanUnloadNow() != S_OK)
00091         return S_FALSE;
00092 #endif
00093     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00094 }
00095
00096 /////////////////////////////////////////////////////////////////////////////
00097 // Returns a class factory to create an object of the requested type
00098
00099 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00100 {
00101 #ifdef _MERGE_PROXYSTUB
00102     if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
00103         return S_OK;
00104 #endif
00105     return _Module.GetClassObject(rclsid, riid, ppv);
00106 }
00107
00108 /////////////////////////////////////////////////////////////////////////////
00109 // DllRegisterServer - Adds entries to the system registry
00110
00111 STDAPI DllRegisterServer(void)
00112 {
00113 #ifdef _MERGE_PROXYSTUB
00114     HRESULT hRes = PrxDllRegisterServer();
00115     if (FAILED(hRes))
00116         return hRes;
00117 #endif
00118     // registers object, typelib and all interfaces in typelib
00119     return _Module.RegisterServer(TRUE);
00120 }
00121
00122 /////////////////////////////////////////////////////////////////////////////
00123 // DllUnregisterServer - Removes entries from the system registry
00124
00125 STDAPI DllUnregisterServer(void)
00126 {
00127 #ifdef _MERGE_PROXYSTUB
00128     PrxDllUnregisterServer();
00129 #endif
00130     return _Module.UnregisterServer(TRUE);
00131 }
00132
00133
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/ContextDll.idl Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification

ContextDll.idl

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       ContextDll.idl
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011
00012 // This file will be processed by the MIDL tool to
00013 // produce the type library (ContextDll.tlb) and marshalling code.
00014
00015 cpp_quote("//+-------------------------------------------------------------------------")
00016 cpp_quote("//")
00017 cpp_quote("//  Microsoft Windows Media Technologies")
00018 cpp_quote("//  Copyright (C) Microsoft Corporation. All rights reserved.")
00019 cpp_quote("//")
00020 cpp_quote("//  Automatically generated by Midl from ContextDll.idl")
00021 cpp_quote("//")
00022 cpp_quote("//  DO NOT EDIT THIS FILE.")
00023 cpp_quote("//")
00024 cpp_quote("//--------------------------------------------------------------------------")
00025
00026 import "oaidl.idl";
00027 import "ocidl.idl";
00028
00029
00030 // {763A9744-3A49-4902-B957-027F0C625B78}
00031 cpp_quote( "EXTERN_GUID(LIBID_CONTEXTPLUGINLib, 0x763a9744, 0x3a49, 0x4902, 0xb9, 0x57, 0x2, 0x7f, 0xc, 0x62, 0x5b, 0x78);" )
00032
00033 // {763A9745-3A49-4902-B957-027F0C625B78}
00034 cpp_quote( "EXTERN_GUID(CLSID_WMSContextPlugin, 0x763a9745, 0x3a49, 0x4902, 0xb9, 0x57, 0x2, 0x7f, 0xc, 0x62, 0x5b, 0x78);" )
00035
00036 // {763A9746-3A49-4902-B957-027F0C625B78}
00037 cpp_quote( "EXTERN_GUID(IID_IWMSContextPlugin, 0x763a9746, 0x3a49, 0x4902, 0xb9, 0x57, 0x2, 0x7f, 0xc, 0x62, 0x5b, 0x78);" )
00038
00039 // {763A9747-3A49-4902-B957-027F0C625B78}
00040 cpp_quote( "EXTERN_GUID(IID_IWMSContextAdmin, 0x763a9747, 0x3a49, 0x4902, 0xb9, 0x57, 0x2, 0x7f, 0xc, 0x62, 0x5b, 0x78);" )
00041
00042
00043 typedef [public] enum WMS_CONTEXT_PLUGIN_CONTEXT_TYPE
00044 {
00045     WMS_CONTEXT_PLUGIN_NO_CONTEXT = 0,
00046     WMS_CONTEXT_PLUGIN_USER_CONTEXT = 1,
00047     WMS_CONTEXT_PLUGIN_PRESENTATION_CONTEXT = 2,
00048     WMS_CONTEXT_PLUGIN_COMMAND_REQUEST_CONTEXT = 4,
00049     WMS_CONTEXT_PLUGIN_COMMAND_RESPONSE_CONTEXT = 8
00050 } WMS_CONTEXT_PLUGIN_CONTEXT_TYPE;
00051
00052 [
00053   object,
00054   uuid(763A9746-3A49-4902-B957-027F0C625B78),
00055   helpstring("IWMSContextPlugin"),
00056   pointer_default(unique)
00057 ]
00058 interface IWMSContextPlugin : IUnknown
00059 {
00060 };
00061
00062
00063 [
00064   object,
00065   uuid(763A9747-3A49-4902-B957-027F0C625B78),
00066     dual,
00067     nonextensible,
00068   helpstring("IWMSContextAdmin Interface"),
00069   pointer_default(unique)
00070 ]
00071 interface IWMSContextAdmin : IDispatch
00072 {
00073         [id( 1 ), propget, helpstring("Return/Set the Output Path")] HRESULT
00074     OutputPath( [out, retval] BSTR* retval );
00075         [id( 1 ), propput, helpstring("Return/Set the Output Path")] HRESULT
00076     OutputPath( [in] BSTR value );
00077         [id( 2 ), propget, helpstring("Return/Set the Context Types to Output")] HRESULT
00078     ContextTypes( [out, retval] WMS_CONTEXT_PLUGIN_CONTEXT_TYPE* retval );
00079         [id( 2 ), propput, helpstring("Return/Set the Context Types to Output")] HRESULT
00080     ContextTypes( [in] WMS_CONTEXT_PLUGIN_CONTEXT_TYPE value );
00081 };
00082
00083
00084 [
00085   uuid(763A9744-3A49-4902-B957-027F0C625B78),
00086   version(9.0),
00087   helpstring("WMS Context Plugin 9.0 Type Library")
00088 ]
00089 library CONTEXTPLUGINLib
00090 {
00091   importlib("stdole32.tlb");
00092   importlib("stdole2.tlb");
00093
00094     interface IWMSContextAdmin;
00095 };
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Delete/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Delete
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__441AF0D0_AF3D_11D2_9A73_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__441AF0D0_AF3D_11D2_9A73_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__441AF0D0_AF3D_11D2_9A73_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIDBInfo Member List

This is the complete list of members for CImpIDBInfo, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CDataSource, CImpIDBInfo) | CImpIDBInfo
GetKeywords(LPWSTR *ppwsKeywords) | CImpIDBInfo
GetLiteralInfo(ULONG cLiterals, const DBLITERAL rgLiterals[], ULONG *pcLiteralInfo, DBLITERALINFO **prgLiteralInfo, WCHAR **ppCharBuffer) | CImpIDBInfo
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMChat2/session.cpp Source File

  • Web
  • NetMeeting
  • NMChat2

session.cpp

Go to the documentation of this file.
00001 //****************************************************************************
00002 //  Module:     NMCHAT.EXE
00003 //  File:       SESSION.CPP
00004 //  Content:
00005 //
00006 //
00007 //  Copyright (c) Microsoft Corporation 1999-2002
00008 //
00009 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012 // PARTICULAR PURPOSE.
00013 //****************************************************************************
00014
00015 #include "precomp.h"
00016 #include "nmappstr.h"
00017
00018 //****************************************************************************
00019 //
00020 // Global Varaiables
00021 //
00022 //****************************************************************************
00023
00024 //
00025 // The Applet Session object
00026 //
00027 CAppletSession *g_pSession = NULL;
00028
00029 //
00030 // The global invoke applet information
00031 //
00032 INVOKE_INFO g_InvokeInfo;
00033
00034
00035 //****************************************************************************
00036 //
00037 // Prototypes
00038 //
00039 //****************************************************************************
00040
00041 HRESULT RegisterInvokeInfo(LPSTR pszKey);
00042 LPTSTR PszFromBstr(BSTR bst);
00043
00044
00045 //****************************************************************************
00046 //
00047 // CLASS CAppletSession
00048 //
00049 //****************************************************************************
00050
00051
00052 //****************************************************************************
00053 //
00054 // Constructor
00055 //
00056 //****************************************************************************
00057
00058 CAppletSession::CAppletSession(CApplet *pApplet, IAppletSession *pISession)
00059 :
00060     CRefCount(),
00061     m_pApplet(pApplet),
00062     m_pISession(pISession),
00063     m_dwCookie(0),
00064     m_uidMyself(0),
00065     m_nidMyself(0),
00066     m_sidMyself(0),
00067     m_eidMyself(0),
00068     m_pszMyName(NULL),
00069     m_nDynamicMulticastChannel(0),
00070     m_cMembers(0)
00071 {
00072 //    if(NULL == pApplet || NULL == pISession || NULL == m_pISession)
00073 //  {
00074 //    return E_POINTER;
00075 //  }
00076
00077   ASSERT(NULL != m_pISession);
00078
00079     m_pApplet->AddRef();
00080
00081     //
00082     // Build the join session data structure, which contains object key and
00083     // capabilities if needed.
00084     //
00085     BuildJoinSessionStructure();
00086
00087     //
00088     // Clean the array of members. To simplify the code, we use an array to
00089     // hold all members, and assume that the maximum number of members
00090     // is MAX_MEMBERS.
00091     //
00092     ::ZeroMemory(m_apMembers, sizeof(m_apMembers));
00093
00094     //
00095     // Get the conference ID.
00096     //
00097     HRESULT hr = m_pISession->GetConfID(&m_nConfID);
00098     ASSERT(S_OK == hr);
00099
00100     //
00101     // Query to see if the local node is a top provider or not.
00102     //
00103     hr = m_pISession->IsThisNodeTopProvider(&m_fTopProvider);
00104     ASSERT(S_OK == hr);
00105
00106     //
00107     // Get the INmMember pointers from the conference object.
00108     // We got these INmMember pointers before this session object is created.
00109     //
00110     if (NULL != g_pConferenceNotify)
00111     {
00112         //
00113         // Get the total number of these early-arrival members.
00114         //
00115         ULONG cIMembers = g_pConferenceNotify->GetIMemberCount();
00116
00117         //
00118         // Get the cached array.
00119         //
00120         INmMember **apIMembers = g_pConferenceNotify->GetIMemberArray();
00121
00122         //
00123         // Iterate through the array and retrieve applet independent
00124         // node information.
00125         //
00126         for (ULONG i = 0; i < cIMembers; i++)
00127         {
00128             SetMember(apIMembers[i]);
00129         }
00130
00131         //
00132         // After retrieving all the node information, we release these
00133         // INmMember pointers and clean the array.
00134         //
00135         g_pConferenceNotify->ReleaseIMemberArray();
00136     }
00137 }
00138
00139
00140 //****************************************************************************
00141 //
00142 // Destructor
00143 //
00144 //****************************************************************************
00145
00146 CAppletSession::~CAppletSession(void)
00147 {
00148     delete m_pszMyName;
00149
00150     ASSERT(NULL != m_pISession);
00151     m_pISession->Release();
00152
00153     m_pApplet->Release();
00154 }
00155
00156
00157 //****************************************************************************
00158 //
00159 // Methods from IUnknown
00160 //
00161 //****************************************************************************
00162
00163 ULONG STDMETHODCALLTYPE
00164 CAppletSession::AddRef(void)
00165 {
00166     return CRefCount::AddRef();
00167 }
00168
00169
00170 ULONG STDMETHODCALLTYPE
00171 CAppletSession::Release(void)
00172 {
00173     return CRefCount::Release();
00174 }
00175
00176 HRESULT STDMETHODCALLTYPE
00177 CAppletSession::QueryInterface(REFIID riid, void * *ppvObject)
00178 {
00179     if(NULL == ppvObject)
00180   {
00181     return E_POINTER;
00182   }
00183
00184   HRESULT hr = NO_ERROR;
00185
00186     if (riid == IID_IUnknown)
00187     {
00188         *ppvObject = (IUnknown *)this;
00189     }
00190     else if (riid == IID_IAppletSessionNotify)
00191     {
00192         *ppvObject = (IAppletSessionNotify *)this;
00193     }
00194     else
00195     {
00196         hr = E_NOINTERFACE;
00197         *ppvObject = NULL;
00198     }
00199
00200     if (S_OK == hr)
00201     {
00202         AddRef();
00203     }
00204
00205     return hr;
00206 }
00207
00208
00209 //****************************************************************************
00210 //
00211 // Methods for IAppletSession
00212 //
00213 //****************************************************************************
00214
00215 HRESULT CAppletSession::SendData
00216 (
00217     AppletChannelID     nChannelID,
00218     ULONG               cbBufSize,
00219     BYTE               *pBuffer
00220 )
00221 {
00222     if(NULL == pBuffer)
00223   {
00224     return E_POINTER;
00225   }
00226
00227   //
00228     // If the channel ID is zero, it means a broadcast. We then internally
00229     // change the channel ID to the broadcast channel.
00230     //
00231     if (0 == nChannelID)
00232     {
00233         nChannelID = m_nDynamicMulticastChannel;
00234     }
00235
00236     //
00237     // Send the data now.
00238     //
00239     HRESULT hr = m_pISession->SendData(
00240                          FALSE,         // not uniform send
00241                          nChannelID,    // target channel ID
00242                          APPLET_MEDIUM_PRIORITY,
00243                          cbBufSize,
00244                          pBuffer);
00245     if (SUCCEEDED(hr))
00246     {
00247         ::UiDisplayMsg((LPTSTR) pBuffer, m_pszMyName);
00248     }
00249
00250     return hr;
00251 }
00252
00253
00254 HRESULT CAppletSession::InvokeApplet(void)
00255 {
00256     AppletRequestTag nTag = 0;
00257
00258     //
00259     // Build the applet invoke information.
00260     //
00261     AppletProtocolEntity ape;
00262     ::ZeroMemory(&ape, sizeof(ape));
00263     ape.apExpectedCapabilities = m_JoinSessionReq.apCollapsedCaps;
00264     ape.cExpectedCapabilities = m_JoinSessionReq.cCollapsedCaps;
00265     ape.eStartupChannelType = APPLET_DYNAMIC_MULTICAST_CHANNEL;
00266     ape.fMustBeInvoked = TRUE;
00267     ape.SessionKey = m_JoinSessionReq.SessionKey;
00268
00269     //
00270     // Invoke all. If we want to invoke a specific person, we need to
00271     // specify the count and the array of nodes. If invoking all, we can
00272     // simply put 0 and NULL.
00273     //
00274     HRESULT hr = m_pISession->InvokeApplet(&nTag, &ape, 0, NULL);
00275     ASSERT(S_OK == hr);
00276
00277     return hr;
00278 }
00279
00280
00281 //****************************************************************************
00282 //
00283 // Methods from IAppletSessionNotify
00284 //
00285 //****************************************************************************
00286
00287 HRESULT STDMETHODCALLTYPE
00288 CAppletSession::JoinSessionConfirm
00289 (
00290     HRESULT             hrResult,
00291     AppletUserID        uidMyself,
00292     AppletNodeID        nidMyself,
00293     AppletSessionID     sidMyself,
00294     AppletEntityID      eidMyself,
00295     ULONG               cDynamicChannels,
00296     AppletChannelID     aDynamicChannels[]
00297 )
00298 {
00299     //
00300     // The response to the Join method.
00301     //
00302     if (S_OK == hrResult)
00303     {
00304         //
00305         // This applet is successfully join the conference. We should remember
00306         // applet specific information such as user ID, node ID, entity ID,
00307         // and session ID.
00308         //
00309         m_uidMyself = uidMyself;
00310         m_nidMyself = nidMyself;
00311         m_sidMyself = sidMyself;
00312         m_eidMyself = eidMyself;
00313
00314         //
00315         // We also need to remember the broadcast channel.
00316         //
00317         ASSERT(1 == cDynamicChannels);
00318         m_nDynamicMulticastChannel = aDynamicChannels[0];
00319
00320         //
00321         // Sanity check.
00322         //
00323         ASSERT(0 != m_uidMyself);
00324         ASSERT(0 != m_nidMyself);
00325         ASSERT(0 != m_nDynamicMulticastChannel);
00326
00327         //
00328         // We are ready to send out text. Put in "everyone".
00329         //
00330         ::UiAddMember(NULL);
00331     }
00332     else
00333     {
00334         ASSERT(S_OK == hrResult);
00335     }
00336
00337     return S_OK;
00338 }
00339
00340
00341 HRESULT STDMETHODCALLTYPE
00342 CAppletSession::LeaveSessionIndication
00343 (
00344     AppletReason        eReason,
00345     AppletUserID        uidLeave
00346 )
00347 {
00348     //
00349     // This notification indicates someone (identified by user ID uidLeave)
00350     // just left the conference. This "someone" can be a node or an applet.
00351     // In case of an applet, this applet can be of different kind or same kind.
00352     //
00353     if (uidLeave == m_uidMyself)
00354     {
00355         //
00356         // I am out of the conference now. So, remove "everyone".
00357         //
00358         ::UiRemoveMember(NULL);
00359     }
00360     return S_OK;
00361 }
00362
00363
00364 HRESULT STDMETHODCALLTYPE
00365 CAppletSession::SendDataIndication
00366 (
00367     BOOL                fUniformSend,
00368     AppletUserID        uidInitiator,
00369     AppletChannelID     nChannelID,
00370     AppletPriority      eDataPriority,
00371     AppletOctetString   Data
00372 )
00373 {
00374     //
00375     // I just received data from the person "uidInitiator".
00376     //
00377     ::UiDisplayMsg((LPTSTR) Data.pbValue, GetMemberName(uidInitiator));
00378     return S_OK;
00379 }
00380
00381
00382 HRESULT STDMETHODCALLTYPE
00383 CAppletSession::RosterReportIndication
00384 (
00385     ULONG               cRosters,
00386     AppletRoster      **apAppRosters
00387 )
00388 {
00389     if(NULL == apAppRosters)
00390   {
00391     return E_POINTER;
00392   }
00393
00394   //
00395     // A roster contains information of each participating applet of the same
00396     // kind. The information includes applet IDs and capabilities. In this
00397     // sample code, we do not have capabilities. Therefore, we will only
00398     // retrieve applet IDs.
00399     //
00400
00401     //
00402     // Clear out the InRoster flag of the member objects.
00403     //
00404     for (ULONG i = 0; i < m_cMembers; i++)
00405     {
00406         m_apMembers[i]->ClearInRosterFlag();
00407     }
00408
00409     //
00410     // Iterate through the array of rosters.
00411     //
00412     for (ULONG iRoster = 0; iRoster < cRosters; iRoster++)
00413     {
00414         AppletRoster *pRoster = apAppRosters[iRoster];
00415
00416         //
00417         // Make sure we are in the same session. An applet of the same kind can
00418         // participate multiple sessions.
00419         //
00420         if (pRoster->SessionKey.nSessionID == m_sidMyself)
00421         {
00422             //
00423             // Iterate through the array of applet records.
00424             //
00425             for (ULONG iRecord = 0; iRecord < pRoster->cRecords ; iRecord++)
00426             {
00427                 AppletRecord *pRecord = pRoster->apAppletRecords[iRecord];
00428
00429                 //
00430                 // We only need to keep track of those enrolled actively.
00431                 //
00432                 if (pRecord->fEnrolledActively)
00433                 {
00434                     //
00435                     // Retrieve applet IDs.
00436                     //
00437                     SetMember(pRecord);
00438                 }
00439             } // for iRecord
00440         } // if
00441     } // for iRoster
00442
00443     //
00444     // Iterate through the member array and remove those not in the rosters.
00445     //
00446     i = 0;
00447     while (i < m_cMembers)
00448     {
00449         //
00450         // It is possible that the element is created due to the member
00451         // notification from the conference object. In this case,
00452         // the corresponding entry in the roster may not arrive yet.
00453         // This means that we should not remove this element.
00454         // Therefore, we only remove those with a valid user ID.
00455         //
00456         if (! m_apMembers[i]->IsInRoster() && ! m_apMembers[i]->IsEmptyUID())
00457         {
00458             //
00459             // This element has a valid user ID but does not appear in
00460             // this roster. This means that it must be gone already.
00461             //
00462             delete m_apMembers[i];
00463             m_apMembers[i] = NULL;
00464
00465             //
00466             // Move the last element to this one just deleted.
00467             //
00468             m_apMembers[i] = m_apMembers[--m_cMembers];
00469         }
00470         else
00471         {
00472             i++;
00473         }
00474     }
00475
00476     return S_OK;
00477 }
00478
00479
00480 HRESULT STDMETHODCALLTYPE
00481 CAppletSession::InquireRosterConfirm
00482 (
00483     HRESULT             hrResult,
00484     ULONG               cRosters,
00485     AppletRoster      **apAppRosters
00486 )
00487 {
00488     //
00489     // This is to handle the inquire roster confirmation. In this sample code,
00490     // we do not issue InquireRoster; therefore, we do not need to handle
00491     // this notifcation.
00492     //
00493
00494     //
00495     // The code dealing with this notificaiton is very similar to that of
00496     // CAppletSession::RosterReportIndication.
00497     //
00498
00499     return S_OK;
00500 }
00501
00502
00503 HRESULT STDMETHODCALLTYPE
00504 CAppletSession::InvokeAppletConfirm
00505 (
00506     AppletRequestTag    nReqTag,
00507     HRESULT             hrResult
00508 )
00509 {
00510     //
00511     // Make sure the result is successful.
00512     //
00513     ASSERT(S_OK == hrResult);
00514
00515     return S_OK;
00516 }
00517
00518
00519 HRESULT STDMETHODCALLTYPE
00520 CAppletSession::RegistryConfirm
00521 (
00522     AppletRegistryCommand      eCommand,
00523     HRESULT                    hrResult,
00524     AppletRegistryKey         *pRegistryKey,
00525     AppletRegistryItem        *pRegistryItem,
00526     AppletRegistryEntryOwner  *pEntryOwner,
00527     AppletModificationRights   eRights
00528 )
00529 {
00530     //
00531     // This is to handle the registry confirmation. In this sample code,
00532     // we do not issue RegistryRequest; therefore, we do not need to handle
00533     // this notifcation.
00534     //
00535
00536     return S_OK;
00537 }
00538
00539
00540 HRESULT STDMETHODCALLTYPE
00541 CAppletSession::AllocateHandleConfirm
00542 (
00543     HRESULT             hrResult,
00544     ULONG               nFirstHandle,
00545     ULONG               cHandles
00546 )
00547 {
00548     //
00549     // This is to handle the allocate-handle confirmation. In this sample code,
00550     // we do not issue RegistryRequest with APPLET_ALLOCATE_HANDLE;
00551     // therefore, we do not need to handle this notifcation.
00552     //
00553
00554     return S_OK;
00555 }
00556
00557
00558 HRESULT STDMETHODCALLTYPE
00559 CAppletSession::ChannelConfirm
00560 (
00561     AppletChannelCommand    eCommand,
00562     HRESULT                 hrResult,
00563     AppletChannelID         nChannelID
00564 )
00565 {
00566     //
00567     // This is to handle the channel confirmation. In this sample code,
00568     // we do not issue ChannelRequest; therefore, we do not need to handle
00569     // this notifcation.
00570     //
00571
00572     return S_OK;
00573 }
00574
00575
00576 HRESULT STDMETHODCALLTYPE
00577 CAppletSession::ChannelIndication
00578 (
00579     AppletChannelCommand    eCommand,
00580     AppletChannelID         nChannelID,
00581     AppletReason            eReason,
00582     AppletUserID            uidManager
00583 )
00584 {
00585     //
00586     // This is to handle the channel indication. In this sample code,
00587     // we do not issue ChannelRequest; therefore, we do not need to handle
00588     // this notifcation.
00589     //
00590
00591     return S_OK;
00592 }
00593
00594
00595 HRESULT STDMETHODCALLTYPE
00596 CAppletSession::TokenConfirm
00597 (
00598     AppletTokenCommand      eCommand,
00599     HRESULT                 hrResult,
00600     AppletTokenID           nTokenID
00601 )
00602 {
00603     //
00604     // This is to handle the token confirmation. In this sample code,
00605     // we do not issue TokenRequest; therefore, we do not need to handle
00606     // this notifcation.
00607     //
00608
00609     return S_OK;
00610 }
00611
00612
00613 HRESULT STDMETHODCALLTYPE
00614 CAppletSession::TestTokenConfirm
00615 (
00616     AppletTokenID           nTokenID,
00617     AppletTokenStatus       eStatus
00618 )
00619 {
00620     //
00621     // This is to handle the test-token confirmation. In this sample code,
00622     // we do not issue TokenRequest with APPLET_TEST_TOKEN; therefore,
00623     // we do not need to handle this notifcation.
00624     //
00625
00626     return S_OK;
00627 }
00628
00629
00630 HRESULT STDMETHODCALLTYPE
00631 CAppletSession::TokenIndication
00632 (
00633     AppletTokenCommand      eCommand,
00634     AppletReason            eReason,
00635     AppletTokenID           nTokenID,
00636     AppletUserID            uidInitiator
00637 )
00638 {
00639     //
00640     // This is to handle the token indication. In this sample code,
00641     // we do not issue TokenRequest; therefore, we do not need to handle
00642     // this notifcation.
00643     //
00644
00645     return S_OK;
00646 }
00647
00648
00649 //****************************************************************************
00650 //
00651 // Build Join-Session Structure
00652 //
00653 //****************************************************************************
00654
00655 /*----------------------------------------------------------------------------
00656             Given a guid and a userid, create the appropriate application key.
00657
00658             The key is formated as:
00659             0xB5 0x00 0x53 0x4C  - Microsoft Object Identifier
00660             0x03                 - guid identifier for NM 3.0 applets
00661             <binary guid>        - guid data
00662             <dword node id>      - user node id
00663 ----------------------------------------------------------------------------*/
00664
00665 //
00666 // ------ IMPORTANT ------
00667 //
00668 // This is the constant for the SDK applications that use IApplet and
00669 // IAppletSession. Please do not modify the binary value.
00670 //
00671 static const BYTE c_AppletKeyPrefix[5] = { 0xB5, 0x00, 0x53, 0x4c, 0x03 };
00672
00673 //
00674 // ------ IMPORTANT ------
00675 //
00676 // An SDK application should use its own GUID and change the following GUID.
00677 //
00678 static const GUID c_SampleAppletGuid =
00679     { 0xf178529, 0xed10, 0x11d2,
00680             { 0xad, 0x1c, 0x0, 0xc0, 0x4f, 0x72, 0xdd, 0x47 } };
00681
00682
00683 //
00684 // The global applet key structure.
00685 //
00686 #define MY_KEY_SIZE  (sizeof(c_AppletKeyPrefix) + sizeof(GUID) + sizeof(DWORD))
00687 static BYTE g_AppletKey[MY_KEY_SIZE];
00688
00689 //
00690 // A sample channel resource ID. This can be any binary data.
00691 //
00692 #define DYNAMIC_CHANNEL_RESOURCE_ID     "Sample Chat Dynamic Channel"
00693
00694
00695 void BuildAppletKey(void)
00696 {
00697     //
00698     // Build the applet key.
00699     //
00700     ::ZeroMemory(g_AppletKey, sizeof(g_AppletKey));
00701     ::CopyMemory(g_AppletKey, c_AppletKeyPrefix, sizeof(c_AppletKeyPrefix));
00702     ::CopyMemory(g_AppletKey + sizeof(c_AppletKeyPrefix),
00703                  &c_SampleAppletGuid, sizeof(GUID));
00704 }
00705
00706
00707 void CAppletSession::BuildJoinSessionStructure(void)
00708 {
00709     //
00710     // Clean the structure.
00711     //
00712     ::ZeroMemory(&m_JoinSessionReq, sizeof(m_JoinSessionReq));
00713
00714     //
00715     // We will use dynamic multicast channel which will be created during
00716     // IAppletSession::Join.
00717     //
00718     m_JoinSessionReq.nStartupChannelType = APPLET_DYNAMIC_MULTICAST_CHANNEL;
00719
00720     //
00721     // Build the session key which consists of applet key and session ID.
00722     //
00723     ::BuildAppletKey();
00724     m_JoinSessionReq.SessionKey.AppletProtocolKey.eType =
00725                                         APPLET_H221_NONSTD_KEY;
00726     m_JoinSessionReq.SessionKey.AppletProtocolKey.ostrH221NonStdID.cbStrSize =
00727                                         sizeof(g_AppletKey);
00728     m_JoinSessionReq.SessionKey.AppletProtocolKey.ostrH221NonStdID.pbValue =
00729                                         g_AppletKey;
00730     m_JoinSessionReq.SessionKey.nSessionID = m_sidMyself;
00731
00732     //
00733     // Build registry key for the dynamic multicast channel.
00734     //
00735     ::ZeroMemory(&m_DynChnlRegKey, sizeof(m_DynChnlRegKey));
00736     m_DynChnlRegKey.SessionKey = m_JoinSessionReq.SessionKey;
00737     m_DynChnlRegKey.ostrResourceID.cbStrSize =
00738                                 sizeof(DYNAMIC_CHANNEL_RESOURCE_ID);
00739     m_DynChnlRegKey.ostrResourceID.pbValue =
00740                                 (LPBYTE) DYNAMIC_CHANNEL_RESOURCE_ID;
00741     m_JoinSessionReq.aChannelRegistryKeys = &m_DynChnlRegKey;
00742     m_JoinSessionReq.cDynamicChannels = 1;
00743
00744     //
00745     // Build the static channel array.
00746     //
00747     // In this sample code, we do not use static channels because this sample
00748     // applet is not a standard applet.
00749     //
00750
00751     //
00752     // Build capabilities
00753     //
00754     // In this sample code, we do not use capabilities.
00755     //
00756 }
00757
00758
00759
00760 //****************************************************************************
00761 //
00762 // Register Applet to be invoked in the future.
00763 //
00764 //****************************************************************************
00765
00766 HRESULT RegisterStandardAppletInvokeInfo(AppletLongString *pKey)
00767 {
00768     //
00769     // The format of a standard t120 applet will be as follows.
00770     //  NM_APPLET_KEY\NM_STD_KEY\{8-hex-dot string}
00771     //
00772     char szKey[MAX_PATH + 1];
00773   ::ZeroMemory(szKey, (MAX_PATH + 1) * sizeof(char));
00774
00775   ::_snprintf(szKey, MAX_PATH, "%s\\%s\\%s", NM_APPLET_KEY, NM_STD_KEY_TYPE, "{");
00776
00777     //
00778     // Build the 8-digit hex dot string.
00779     //
00780     LPSTR pszKey = szKey + ::lstrlenA(szKey);
00781     for (ULONG i = 0; i < pKey->nStrLen; i++)
00782     {
00783         ::_snprintf(pszKey, MAX_PATH - ::lstrlenA(szKey), "%08X.", (UINT) pKey->pnValue[i]);
00784         pszKey += ::lstrlenA(pszKey);
00785     }
00786   ::_snprintf(pszKey - 1, 1, "}");
00787
00788     //
00789     // Register the applet information.
00790     //
00791     return ::RegisterInvokeInfo(szKey);
00792 }
00793
00794
00795 HRESULT RegisterNonStandardAppletInvokeInfo(void)
00796 {
00797     //
00798     // Build the applet key.
00799     //
00800     ::BuildAppletKey();
00801
00802     //
00803     // The format of a non-standard t120 applet is as follows.
00804     //  NM_APPLET_KEY\NM_NONSTD_KEY\{2-hex-dot string}
00805     //
00806     char szKey[MAX_PATH + 1];
00807   ::ZeroMemory(szKey, (MAX_PATH + 1) * sizeof(char));
00808
00809   ::_snprintf(szKey, MAX_PATH, "%s\\%s\\%s", NM_APPLET_KEY, NM_NONSTD_KEY_TYPE, "{");
00810
00811     //
00812     // Build the 2-digit hex dot string.
00813     //
00814     LPSTR pszKey = szKey + ::lstrlenA(szKey);
00815     ULONG cbDataSize = sizeof(g_AppletKey);
00816     LPBYTE pbData = g_AppletKey;
00817     for (ULONG i = 0; i < cbDataSize; i++, pbData++)
00818     {
00819     ::_snprintf(pszKey, MAX_PATH - ::lstrlenA(szKey), "%02X.", (UINT) *pbData);
00820         pszKey += ::lstrlenA(pszKey);
00821     }
00822     ::_snprintf(pszKey - 1, 1, "}");
00823
00824     //
00825     // Register the applet information.
00826     //
00827     return ::RegisterInvokeInfo(szKey);
00828 }
00829
00830
00831
00832
00833 HRESULT RegisterInvokeInfo(LPSTR pszKey)
00834 {
00835     if(NULL == pszKey)
00836   {
00837     return E_POINTER;
00838   }
00839
00840   HKEY hKey = NULL;
00841     LONG lRet = 0;
00842     DWORD dwDisposition = 0;
00843     TCHAR szValue[MAX_PATH + 1];
00844   ::ZeroMemory(szValue, (MAX_PATH + 1) * sizeof(TCHAR));
00845
00846   lRet = ::RegCreateKeyEx(
00847                         HKEY_LOCAL_MACHINE,
00848                         pszKey,
00849                         0,
00850                         NULL,
00851                         REG_OPTION_NON_VOLATILE,
00852                         KEY_SET_VALUE,
00853                         NULL,
00854                         &hKey,
00855                         &dwDisposition);
00856
00857     ASSERT(0 == lRet);
00858     ASSERT(NULL != hKey);
00859
00860   if(NULL == hKey)
00861   {
00862     return E_HANDLE;
00863   }
00864
00865     szValue[0] = TEXT('\0');
00866     ::GetModuleFileName(g_hInstExe, szValue, MAX_PATH);
00867     lRet = ::RegSetValueEx(hKey,
00868                            NM_REGVAL_APP_PATH,
00869                            0,
00870                            REG_SZ,
00871                            (LPBYTE) &szValue[0],
00872                            (::lstrlen(szValue) + 1) * sizeof(TCHAR));
00873     ASSERT(0 == lRet);
00874
00875     szValue[0] = TEXT('\0'); // no command line
00876     lRet = ::RegSetValueEx(hKey,
00877                            NM_REGVAL_CMD_LINE,
00878                            0,
00879                            REG_SZ,
00880                            (LPBYTE) &szValue[0],
00881                            (::lstrlen(szValue) + 1) * sizeof(TCHAR));
00882     ASSERT(0 == lRet);
00883
00884     ::GetCurrentDirectory(MAX_PATH, szValue); // default working directory
00885     lRet = ::RegSetValueEx(hKey,
00886                            NM_REGVAL_CURR_DIR,
00887                            0,
00888                            REG_SZ,
00889                            (LPBYTE) &szValue[0],
00890                            (::lstrlen(szValue) + 1) * sizeof(TCHAR));
00891     ASSERT(0 == lRet);
00892
00893     ::lstrcpyn((LPTSTR) &szValue[0], TEXT("Microsoft Corporation"), MAX_PATH + 1);
00894     lRet = ::RegSetValueEx(hKey,
00895                            NM_REGVAL_MANUFACTURER,
00896                            0,
00897                            REG_SZ,
00898                            (LPBYTE) &szValue[0],
00899                            (::lstrlen(szValue) + 1) * sizeof(TCHAR));
00900     ASSERT(0 == lRet);
00901
00902     ::lstrcpyn((LPTSTR) &szValue[0], TEXT("NetMeeting SDK 3.0 Chat Sample Applet"), MAX_PATH + 1);
00903     lRet = ::RegSetValueEx(hKey,
00904                            NM_REGVAL_PRODUCT_NAME,
00905                            0,
00906                            REG_SZ,
00907                            (LPBYTE) &szValue[0],
00908                            (::lstrlen(szValue) + 1) * sizeof(TCHAR));
00909     ASSERT(0 == lRet);
00910
00911     ::lstrcpyn((LPTSTR) &szValue[0], TEXT("SDK Sample using IApplet and IAppletSession"), MAX_PATH + 1);
00912     lRet = ::RegSetValueEx(hKey,
00913                            NM_REGVAL_DESCRIPTION,
00914                            0,
00915                            REG_SZ,
00916                            (LPBYTE) &szValue[0],
00917                            (::lstrlen(szValue) + 1) * sizeof(TCHAR));
00918     ASSERT(0 == lRet);
00919
00920
00921     ::RegFlushKey(hKey);
00922     ::RegCloseKey(hKey);
00923     return S_OK;
00924 }
00925
00926
00927 BOOL GetInvokeInfo(INVOKE_INFO *pInfo)
00928 {
00929   TCHAR szValue[MAX_PATH + 1];
00930   ::ZeroMemory(szValue, (MAX_PATH + 1) * sizeof(TCHAR));
00931
00932     ::ZeroMemory(pInfo, sizeof(*pInfo));
00933
00934     // retrieve conf ID
00935     if (::GetEnvironmentVariable(NM_ENV_CONF_ID, szValue, MAX_PATH))
00936     {
00937         pInfo->nConfID = ::atoi(szValue);
00938     }
00939
00940     // retrieve the node ID of initiator
00941     if (::GetEnvironmentVariable(NM_ENV_NODE_ID, szValue, MAX_PATH))
00942     {
00943         pInfo->nidInitiator = ::atoi(szValue);
00944     }
00945
00946     pInfo->fValid = pInfo->nConfID && pInfo->nidInitiator;
00947     return pInfo->fValid;
00948 }
00949
00950
00951 void CAppletSession::RemoveMember
00952 (
00953     INmMember          *pIMember
00954 )
00955 {
00956     if(NULL == pIMember)
00957   {
00958     return;
00959   }
00960
00961   ULONG nMemberID = 0;
00962     HRESULT hr = pIMember->GetID(&nMemberID);
00963     ASSERT(S_OK == hr);
00964
00965     AppletNodeID nid = (AppletNodeID) nMemberID;
00966     if (nid != m_nidMyself)
00967     {
00968         for (ULONG i = 0; i < m_cMembers; i++)
00969         {
00970             if (m_apMembers[i]->IsSameMemberID(nid))
00971             {
00972                 delete m_apMembers[i];
00973                 m_apMembers[i] = NULL;
00974                 m_apMembers[i] = m_apMembers[--m_cMembers];
00975             }
00976         }
00977     }
00978 }
00979
00980
00981 void CAppletSession::SetMember
00982 (
00983     INmMember          *pIMember
00984 )
00985 {
00986     if(NULL == pIMember)
00987   {
00988     return;
00989   }
00990
00991   ULONG nMemberID = 0;
00992     HRESULT hr = pIMember->GetID(&nMemberID);
00993     ASSERT(S_OK == hr);
00994
00995     AppletNodeID nid = (AppletNodeID) nMemberID;
00996     if (nid != m_nidMyself)
00997     {
00998         CMember *pMember = NULL;
00999         for (ULONG i = 0; i < m_cMembers; i++)
01000         {
01001             pMember = m_apMembers[i];
01002             if (pMember->IsSameMemberID(nid))
01003             {
01004                 if (pMember->IsEmptyMember())
01005                 {
01006                     pMember->SetMember(pIMember);
01007                 }
01008                 return;
01009             }
01010         }
01011
01012         // cound not find it, create a new entry
01013         ASSERT(m_cMembers < MAX_MEMBERS);
01014         pMember = new CMember(pIMember);
01015         if (NULL != pMember)
01016         {
01017             m_apMembers[m_cMembers++] = pMember;
01018         }
01019     }
01020 }
01021
01022
01023 void CAppletSession::SetMember
01024 (
01025     AppletRecord       *pRecord
01026 )
01027 {
01028   if(NULL == pRecord)
01029   {
01030     return;
01031   }
01032
01033     if (pRecord->nAppletUserID != m_uidMyself)
01034     {
01035         CMember *pMember = NULL;
01036         for (ULONG i = 0; i < m_cMembers; i++)
01037         {
01038             pMember = m_apMembers[i];
01039             if (pMember->IsSameUID(pRecord->nAppletUserID))
01040             {
01041                 // this member is already in the list
01042                 pMember->SetInRosterFlag();
01043                 return;
01044             }
01045
01046             if (pMember->IsSameMemberID(pRecord->nNodeID))
01047             {
01048                 if (pMember->IsEmptyUID())
01049                 {
01050                     pMember->SetMember(pRecord);
01051                     pMember->SetInRosterFlag();
01052                 }
01053                 return;
01054             }
01055         }
01056
01057         // cound not find it, create a new entry
01058         ASSERT(m_cMembers < MAX_MEMBERS);
01059         pMember = new CMember(pRecord);
01060         if (NULL != pMember)
01061         {
01062             m_apMembers[m_cMembers++] = pMember;
01063             pMember->SetInRosterFlag();
01064             return;
01065         }
01066     }
01067 }
01068
01069
01070 LPTSTR CAppletSession::GetMemberName
01071 (
01072     AppletUserID        uid
01073 )
01074 {
01075     CMember *pMember = NULL;
01076     for (ULONG i = 0; i < m_cMembers; i++)
01077     {
01078         pMember = m_apMembers[i];
01079         if (pMember->IsSameUID(uid))
01080         {
01081             return m_apMembers[i]->GetName();
01082         }
01083     }
01084     return NULL;
01085 }
01086
01087
01088
01089 //****************************************************************************
01090 //
01091 // CMember
01092 //
01093 //****************************************************************************
01094
01095
01096 CMember::CMember(INmMember *pIMember)
01097 {
01098     Initialize();
01099     SetMember(pIMember, TRUE);
01100 }
01101
01102
01103 CMember::CMember(AppletRecord *pRecord)
01104 {
01105     Initialize();
01106     SetMember(pRecord, TRUE);
01107 }
01108
01109
01110 CMember::~CMember(void)
01111 {
01112     ::UiRemoveMember(this);
01113     delete m_pszMemberName;
01114 }
01115
01116
01117 void CMember::Initialize(void)
01118 {
01119     m_fInRoster = FALSE;
01120     m_pszMemberName = NULL;
01121     m_nidMember = 0;
01122     m_uidMember = 0;
01123     m_eidMember = 0;
01124 }
01125
01126
01127 void CMember::SetMember(INmMember *pIMember, BOOL fFirstTime)
01128 {
01129     ASSERT(NULL != pIMember);
01130   if(NULL == pIMember)
01131   {
01132     return;
01133   }
01134
01135     BSTR bstr = NULL;
01136     HRESULT hr = pIMember->GetName(&bstr);
01137     ASSERT(S_OK == hr);
01138
01139     m_pszMemberName = ::PszFromBstr(bstr);
01140     ::SysFreeString(bstr);
01141
01142     ULONG nMemberID = 0;
01143     hr = pIMember->GetID(&nMemberID);
01144     ASSERT(S_OK == hr);
01145     m_nidMember = (AppletNodeID) nMemberID;
01146
01147     if (! fFirstTime)
01148     {
01149         ::UiAddMember(this);
01150     }
01151 }
01152
01153
01154 void CMember::SetMember(AppletRecord *pRecord, BOOL fFirstTime)
01155 {
01156     if(NULL == pRecord)
01157   {
01158     return;
01159   }
01160
01161   ASSERT(0 == m_uidMember);
01162     ASSERT(0 == m_eidMember);
01163     m_nidMember = pRecord->nNodeID;
01164     m_uidMember = pRecord->nAppletUserID;
01165     m_eidMember = pRecord->nEntityID;
01166
01167     if (! fFirstTime)
01168     {
01169         ::UiAddMember(this);
01170     }
01171 }
01172
01173
01174
01175
01176
01177 //****************************************************************************
01178 //
01179 // LPTSTR PszFromBstr(BSTR bstr)
01180 //
01181 // Converts a BSTR to a LPSTR
01182 //
01183 //****************************************************************************
01184
01185 LPTSTR PszFromBstr(BSTR bstr)
01186 {
01187     LPTSTR psz = NULL;
01188
01189     if (NULL != bstr)
01190     {
01191         int cch = ::WideCharToMultiByte(CP_ACP, 0, (LPWSTR)bstr, -1, NULL, 0, NULL, NULL);
01192         if (cch > 0)
01193         {
01194             psz = new TCHAR[cch+1];
01195             if (NULL != psz)
01196             {
01197         ZeroMemory(psz, sizeof(TCHAR) * (cch + 1));
01198                 ::WideCharToMultiByte(CP_ACP, 0, (LPWSTR)bstr, -1, psz, cch, NULL, NULL);
01199             }
01200         }
01201     }
01202     return psz;
01203 }
01204
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Taskpads/statnode.Cpp Source File

  • SysMgmt
  • MMC
  • Taskpads

statnode.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "StatNode.h"
00021
00022 #include "Space.h"
00023 #include "Sky.h"
00024 #include "People.h"
00025 #include "Land.h"
00026
00027 const GUID CStaticNode::thisGuid = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00028
00029 //==============================================================
00030 //
00031 // CStaticNode implementation
00032 //
00033 //
00034 CStaticNode::CStaticNode()
00035 {
00036     children[0] = new CPeoplePoweredVehicle;
00037     children[1] = new CLandBasedVehicle;
00038     children[2] = new CSkyBasedVehicle;
00039     children[3] = new CSpaceVehicle;
00040 }
00041
00042 CStaticNode::~CStaticNode()
00043 {
00044     for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
00045         if (children[n]) {
00046             delete children[n];
00047         }
00048 }
00049
00050 HRESULT CStaticNode::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
00051 {
00052     SCOPEDATAITEM sdi;
00053
00054     if (!bExpanded) {
00055         // create the child nodes, then expand them
00056         for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
00057             ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
00058             sdi.mask = SDI_STR       |   // Displayname is valid
00059                 SDI_PARAM     |   // lParam is valid
00060                 SDI_IMAGE     |   // nImage is valid
00061                 SDI_OPENIMAGE |   // nOpenImage is valid
00062                 SDI_PARENT    |
00063                 SDI_CHILDREN;
00064
00065             sdi.relativeID  = (HSCOPEITEM)parent;
00066             sdi.nImage      = children[n]->GetBitmapIndex();
00067             sdi.nOpenImage  = INDEX_OPENFOLDER;
00068             sdi.displayname = MMC_CALLBACK;
00069             sdi.lParam      = (LPARAM)children[n];       // The cookie
00070             sdi.cChildren   = (n == 0); // only the first child has children
00071
00072             HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
00073
00074             _ASSERT( SUCCEEDED(hr) );
00075         }
00076     }
00077
00078     return S_OK;
00079 }
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Controls/Common/Property/Property.c Source File

  • WinUI
  • Controls
  • Common
  • Property

Property.c

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright (C) 1993 - 2000  Microsoft Corporation.  All Rights Reserved.
00008
00009    MODULE:     Property.c
00010
00011    PURPOSE:    Source module for the PROPERTY sample application
00012
00013    PLATFORMS:  Windows 95, Windows NT
00014
00015    FUNCTIONS:
00016       WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
00017       InitApplication(HINSTANCE);
00018       InitInstance(HINSTANCE, int);
00019       MainWndProc(HWND, UINT, WPARAM, LPARAM);
00020       About(HWND, UINT, WPARAM, LPARAM);
00021       DoModalPropSheet(HWND);
00022       DoModelessPropSheet(HWND);
00023       DoWizardPropSheet(HWND);
00024       ButtonsDlgProc(HWND, UINT, WPARAM, LPARAM);
00025       ComboDlgProc(HWND, UINT, WPARAM, LPARAM);
00026       PropSheetCallback(HWND, UINT, LPARAM);
00027
00028    COMMENTS:
00029
00030 **************************************************************************/
00031
00032 #define STRICT
00033
00034 /**************************************************************************
00035    Include Files
00036 **************************************************************************/
00037
00038 #include <windows.h>
00039 #include <windowsx.h>
00040 #include <commctrl.h>
00041 #include "property.h"
00042
00043 /**************************************************************************
00044    Local Function Prototypes
00045 **************************************************************************/
00046
00047 int PASCAL       WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
00048 BOOL             InitApplication(HINSTANCE);
00049 BOOL             InitInstance(HINSTANCE, int);
00050 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
00051 INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
00052 INT_PTR          DoModalPropSheet(HWND);
00053 HWND             DoModelessPropSheet(HWND);
00054 INT_PTR          DoWizardPropSheet(HWND);
00055 LRESULT CALLBACK ButtonsDlgProc(HWND, UINT, WPARAM, LPARAM);
00056 LRESULT CALLBACK ComboDlgProc(HWND, UINT, WPARAM, LPARAM);
00057 void CALLBACK    PropSheetCallback(HWND, UINT, LPARAM);
00058
00059 /**************************************************************************
00060    Global Variables
00061 **************************************************************************/
00062
00063 HINSTANCE   g_hInst;
00064 HWND        g_hwndPropSheet,
00065             g_hwndMain;
00066 BOOL        g_bWin95;
00067 TCHAR       g_szClassName[] = TEXT("PropSheetClass");
00068
00069 /**************************************************************************
00070
00071    WinMain()
00072
00073 **************************************************************************/
00074
00075 int PASCAL WinMain(  HINSTANCE hInstance,
00076                      HINSTANCE hPrevInstance,
00077                      LPSTR lpCmdLine,
00078                      int nCmdShow)
00079 {
00080 MSG      msg;
00081
00082 g_hInst = hInstance;
00083
00084 //don't forget this
00085 InitCommonControls();
00086
00087 if(!hPrevInstance)
00088    if(!InitApplication(hInstance))
00089       return FALSE;
00090
00091 if (!InitInstance(hInstance, nCmdShow))
00092    return FALSE;
00093
00094 while(GetMessage(&msg, NULL, 0x00, 0x00))
00095    {
00096    // If the modeless guy is up and is ready to be destroyed
00097    // (PropSheet_GetCurrentPageHwnd returns NULL) then destroy the dialog.
00098
00099    // PropSheet_GetCurrentPageHwnd will return NULL after the OK or Cancel
00100    // button has been pressed and all of the pages have been notified. The
00101    // Apply button doesn't cause this to happen.
00102    if(g_hwndPropSheet && (NULL == PropSheet_GetCurrentPageHwnd(g_hwndPropSheet)))
00103       {
00104       //enable the parent first to prevent another window from becoming the foreground window
00105       EnableWindow(g_hwndMain, TRUE);
00106       DestroyWindow(g_hwndPropSheet);
00107       g_hwndPropSheet = NULL;
00108       }
00109
00110    //use PropSheet_IsDialogMessage instead of IsDialogMessage
00111    if(!PropSheet_IsDialogMessage(g_hwndPropSheet, &msg))
00112       {
00113       TranslateMessage(&msg);
00114       DispatchMessage(&msg);
00115       }
00116    }
00117
00118 return (int)msg.wParam;
00119 }
00120
00121 /**************************************************************************
00122
00123    InitApplication()
00124
00125 **************************************************************************/
00126
00127 BOOL InitApplication(HINSTANCE hInstance)
00128 {
00129 OSVERSIONINFO  os;
00130
00131 ZeroMemory(&os, sizeof(os));
00132 os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00133 GetVersionEx(&os);
00134 if(os.dwMajorVersion >= 4)
00135    g_bWin95 = TRUE;
00136 else
00137    g_bWin95 = FALSE;
00138
00139 if(g_bWin95)
00140    {
00141    WNDCLASSEX  wcex;
00142
00143    ZeroMemory(&wcex, sizeof(wcex));
00144
00145    wcex.cbSize          = sizeof(wcex);
00146    wcex.style           = CS_HREDRAW | CS_VREDRAW;
00147    wcex.lpfnWndProc     = (WNDPROC)MainWndProc;
00148    wcex.cbClsExtra      = 0;
00149    wcex.cbWndExtra      = 0;
00150    wcex.hInstance       = hInstance;
00151    wcex.hIcon           = LoadIcon(NULL, IDI_APPLICATION);
00152    wcex.hCursor         = LoadCursor(NULL, IDC_ARROW);
00153    wcex.hbrBackground   = GetStockObject(WHITE_BRUSH);
00154    wcex.lpszMenuName    = MAKEINTRESOURCE(IDR_MAIN_MENU);
00155    wcex.lpszClassName   = g_szClassName;
00156
00157    return RegisterClassEx(&wcex);
00158    }
00159 else
00160    {
00161    WNDCLASS  wc;
00162
00163    ZeroMemory(&wc, sizeof(wc));
00164
00165    wc.style          = CS_HREDRAW | CS_VREDRAW;
00166    wc.lpfnWndProc    = (WNDPROC)MainWndProc;
00167    wc.cbClsExtra     = 0;
00168    wc.cbWndExtra     = 0;
00169    wc.hInstance      = hInstance;
00170    wc.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
00171    wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
00172    wc.hbrBackground  = GetStockObject(WHITE_BRUSH);
00173    wc.lpszMenuName   = MAKEINTRESOURCE(IDR_MAIN_MENU);
00174    wc.lpszClassName  = g_szClassName;
00175
00176    return RegisterClass(&wc);
00177    }
00178 }
00179
00180 /**************************************************************************
00181
00182    InitInstance()
00183
00184 **************************************************************************/
00185
00186 BOOL InitInstance(   HINSTANCE hInstance,
00187                      int nCmdShow)
00188 {
00189 g_hwndMain = CreateWindowEx(  0,
00190                               g_szClassName,
00191                               TEXT("Property Sheet Application"),
00192                               WS_OVERLAPPEDWINDOW,
00193                               CW_USEDEFAULT,
00194                               CW_USEDEFAULT,
00195                               CW_USEDEFAULT,
00196                               CW_USEDEFAULT,
00197                               NULL,
00198                               NULL,
00199                               hInstance,
00200                               NULL);
00201
00202 if (!g_hwndMain)
00203    {
00204    return FALSE;
00205    }
00206
00207 ShowWindow(g_hwndMain, nCmdShow);
00208 UpdateWindow(g_hwndMain);
00209
00210 return TRUE;
00211 }
00212
00213 /**************************************************************************
00214
00215    MainWndProc()
00216
00217 **************************************************************************/
00218
00219 LRESULT CALLBACK MainWndProc( HWND hWnd,
00220                               UINT uMessage,
00221                               WPARAM wParam,
00222                               LPARAM lParam)
00223 {
00224 switch (uMessage)
00225    {
00226    case WM_CREATE:
00227       break;
00228
00229    case WM_CLOSE:
00230       if(IsWindow(g_hwndPropSheet))
00231          DestroyWindow(g_hwndPropSheet);
00232
00233       DestroyWindow(hWnd);
00234       break;
00235
00236    case WM_DESTROY:
00237       PostQuitMessage(0);
00238       break;
00239
00240    case WM_COMMAND:
00241       switch (GET_WM_COMMAND_ID(wParam, lParam))
00242          {
00243          case IDM_MODAL:
00244             DoModalPropSheet(hWnd);
00245             break;
00246
00247          case IDM_MODELESS:
00248             g_hwndPropSheet = DoModelessPropSheet(hWnd);
00249             break;
00250
00251          case IDM_WIZARD:
00252             DoWizardPropSheet(hWnd);
00253             break;
00254
00255          case IDM_EXIT:
00256             PostMessage(hWnd, WM_CLOSE, 0, 0);
00257             break;
00258
00259          case IDM_ABOUT:
00260             DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT_DIALOG), hWnd, About);
00261             break;
00262          }
00263       return TRUE;
00264
00265    default:
00266       break;
00267    }
00268 return DefWindowProc(hWnd, uMessage, wParam, lParam);
00269 }
00270
00271 /**************************************************************************
00272
00273    About()
00274
00275 **************************************************************************/
00276
00277 INT_PTR CALLBACK About( HWND hWnd,
00278                         UINT uMessage,
00279                         WPARAM wParam,
00280                         LPARAM lParam)
00281 {
00282 switch (uMessage)
00283    {
00284    case WM_INITDIALOG:
00285       return TRUE;
00286
00287    case WM_COMMAND:
00288       switch(wParam)
00289          {
00290          case IDOK:
00291             EndDialog(hWnd, IDOK);
00292             return TRUE;
00293
00294          case IDCANCEL:
00295             EndDialog(hWnd, IDCANCEL);
00296             return TRUE;
00297          }
00298       break;
00299     }
00300
00301 return FALSE;
00302 }
00303
00304 /**************************************************************************
00305
00306    DoModalPropSheet()
00307
00308 **************************************************************************/
00309
00310 INT_PTR DoModalPropSheet(HWND hwndOwner)
00311 {
00312 PROPSHEETPAGE psp[2];
00313 PROPSHEETHEADER psh;
00314
00315 //Fill out the PROPSHEETPAGE data structure for the Background Color sheet
00316 psp[0].dwSize        = sizeof(PROPSHEETPAGE);
00317 psp[0].dwFlags       = PSP_USETITLE;
00318 psp[0].hInstance     = g_hInst;
00319 psp[0].pszTemplate   = MAKEINTRESOURCE(IDD_BUTTONS);
00320 psp[0].pszIcon       = NULL;
00321 psp[0].pfnDlgProc    = ButtonsDlgProc;
00322 psp[0].pszTitle      = TEXT("Buttons");
00323 psp[0].lParam        = 0;
00324
00325 //Fill out the PROPSHEETPAGE data structure for the Client Area Shape sheet
00326 psp[1].dwSize        = sizeof(PROPSHEETPAGE);
00327 psp[1].dwFlags       = PSP_USETITLE;
00328 psp[1].hInstance     = g_hInst;
00329 psp[1].pszTemplate   = MAKEINTRESOURCE(IDD_COMBOBOXES);
00330 psp[1].pszIcon       = NULL;
00331 psp[1].pfnDlgProc    = ComboDlgProc;
00332 psp[1].pszTitle      = TEXT("Combo Boxes");
00333 psp[1].lParam        = 0;
00334
00335 //Fill out the PROPSHEETHEADER
00336 psh.dwSize           = sizeof(PROPSHEETHEADER);
00337 psh.dwFlags          = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
00338 psh.hwndParent       = hwndOwner;
00339 psh.hInstance        = g_hInst;
00340 psh.pszIcon          = MAKEINTRESOURCE(IDI_BACKCOLOR);
00341 psh.pszCaption       = TEXT("Modal Property Sheet");
00342 psh.nPages           = sizeof(psp) / sizeof(PROPSHEETPAGE);
00343 psh.ppsp             = (LPCPROPSHEETPAGE) &psp;
00344 psh.pfnCallback      = (PFNPROPSHEETCALLBACK)PropSheetCallback;
00345
00346 //And finally display the modal property sheet
00347 return PropertySheet(&psh);
00348 }
00349
00350 /**************************************************************************
00351
00352    DoModelessPropSheet()
00353
00354 **************************************************************************/
00355
00356 HWND DoModelessPropSheet(HWND hwndOwner)
00357 {
00358 PROPSHEETPAGE psp[2];
00359 PROPSHEETHEADER psh;
00360
00361 //Fill out the PROPSHEETPAGE data structure for the Background Color sheet
00362 psp[0].dwSize        = sizeof(PROPSHEETPAGE);
00363 psp[0].dwFlags       = PSP_USETITLE;
00364 psp[0].hInstance     = g_hInst;
00365 psp[0].pszTemplate   = MAKEINTRESOURCE(IDD_BUTTONS);
00366 psp[0].pszIcon       = NULL;
00367 psp[0].pfnDlgProc    = ButtonsDlgProc;
00368 psp[0].pszTitle      = TEXT("Buttons");
00369 psp[0].lParam        = 0;
00370
00371 //Fill out the PROPSHEETPAGE data structure for the Client Area Shape sheet
00372 psp[1].dwSize        = sizeof(PROPSHEETPAGE);
00373 psp[1].dwFlags       = PSP_USETITLE;
00374 psp[1].hInstance     = g_hInst;
00375 psp[1].pszTemplate   = MAKEINTRESOURCE(IDD_COMBOBOXES);
00376 psp[1].pszIcon       = NULL;
00377 psp[1].pfnDlgProc    = ComboDlgProc;
00378 psp[1].pszTitle      = TEXT("Combo Boxes");
00379 psp[1].lParam        = 0;
00380
00381 //Fill out the PROPSHEETHEADER
00382 psh.dwSize           = sizeof(PROPSHEETHEADER);
00383 psh.dwFlags          = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK| PSH_MODELESS;
00384 psh.hwndParent       = hwndOwner;
00385 psh.hInstance        = g_hInst;
00386 psh.pszIcon          = MAKEINTRESOURCE(IDI_BACKCOLOR);
00387 psh.pszCaption       = TEXT("Modeless Property Sheet");
00388 psh.nPages           = sizeof(psp) / sizeof(PROPSHEETPAGE);
00389 psh.ppsp             = (LPCPROPSHEETPAGE) &psp;
00390 psh.pfnCallback      = (PFNPROPSHEETCALLBACK)PropSheetCallback;
00391
00392 //disable the parent to prevent another property sheet from being created - this will be re-enabled when the property sheet is destroyed.
00393 EnableWindow(hwndOwner, FALSE);
00394
00395 //And finally display the modeless property sheet. It will be destroyed in our main message loop.
00396 return (HWND)PropertySheet(&psh);
00397 }
00398
00399 /**************************************************************************
00400
00401    DoWizardPropSheet()
00402
00403 **************************************************************************/
00404
00405 INT_PTR DoWizardPropSheet(HWND hwndOwner)
00406 {
00407 PROPSHEETPAGE psp[2];
00408 PROPSHEETHEADER psh;
00409
00410 //Fill out the PROPSHEETPAGE data structure for the Background Color sheet
00411 psp[0].dwSize        = sizeof(PROPSHEETPAGE);
00412 psp[0].dwFlags       = PSP_USETITLE;
00413 psp[0].hInstance     = g_hInst;
00414 psp[0].pszTemplate   = MAKEINTRESOURCE(IDD_BUTTONS);
00415 psp[0].pszIcon       = NULL;
00416 psp[0].pfnDlgProc    = ButtonsDlgProc;
00417 psp[0].pszTitle      = TEXT("Buttons");
00418 psp[0].lParam        = 0;
00419
00420 //Fill out the PROPSHEETPAGE data structure for the Client Area Shape sheet
00421 psp[1].dwSize        = sizeof(PROPSHEETPAGE);
00422 psp[1].dwFlags       = PSP_USETITLE;
00423 psp[1].hInstance     = g_hInst;
00424 psp[1].pszTemplate   = MAKEINTRESOURCE(IDD_COMBOBOXES);
00425 psp[1].pszIcon       = NULL;
00426 psp[1].pfnDlgProc    = ComboDlgProc;
00427 psp[1].pszTitle      = TEXT("Combo Boxes");
00428 psp[1].lParam        = 0;
00429
00430 //Fill out the PROPSHEETHEADER
00431 psh.dwSize           = sizeof(PROPSHEETHEADER);
00432 psh.dwFlags          = PSH_PROPSHEETPAGE | PSH_WIZARD | PSH_USEICONID | PSH_USECALLBACK;
00433 psh.hwndParent       = hwndOwner;
00434 psh.hInstance        = g_hInst;
00435 psh.pszIcon          = MAKEINTRESOURCE(IDI_BACKCOLOR);
00436 psh.pszCaption       = TEXT("Wizard Property Sheet");
00437 psh.nPages           = sizeof(psp) / sizeof(PROPSHEETPAGE);
00438 psh.ppsp             = (LPCPROPSHEETPAGE) &psp;
00439 psh.pfnCallback      = (PFNPROPSHEETCALLBACK)PropSheetCallback;
00440
00441 //And finally display the Wizard property sheet
00442 return PropertySheet(&psh);
00443 }
00444
00445 /**************************************************************************
00446
00447    ButtonsDlgProc()
00448
00449 **************************************************************************/
00450
00451 LRESULT CALLBACK ButtonsDlgProc( HWND hdlg,
00452                                  UINT uMessage,
00453                                  WPARAM wParam,
00454                                  LPARAM lParam)
00455 {
00456 LPNMHDR     lpnmhdr;
00457
00458 switch (uMessage)
00459    {
00460    // on any command notification, tell the property sheet to enable the Apply button
00461    case WM_COMMAND:
00462       PropSheet_Changed(GetParent(hdlg), hdlg);
00463       break;
00464
00465    case WM_NOTIFY:
00466       lpnmhdr = (NMHDR FAR *)lParam;
00467
00468       switch (lpnmhdr->code)
00469          {
00470          case PSN_APPLY:   //sent when OK or Apply button pressed
00471             break;
00472
00473          case PSN_RESET:   //sent when Cancel button pressed
00474             break;
00475
00476          case PSN_SETACTIVE:
00477             //this will be ignored if the property sheet is not a wizard
00478             PropSheet_SetWizButtons(GetParent(hdlg), PSWIZB_NEXT);
00479             break;
00480
00481          default:
00482             break;
00483          }
00484       break;
00485
00486    default:
00487       break;
00488    }
00489
00490 return FALSE;
00491 }
00492
00493 /**************************************************************************
00494
00495    ComboDlgProc()
00496
00497 **************************************************************************/
00498
00499 LRESULT CALLBACK ComboDlgProc(   HWND hdlg,
00500                                  UINT uMessage,
00501                                  WPARAM wParam,
00502                                  LPARAM lParam)
00503 {
00504 LPNMHDR     lpnmhdr;
00505
00506 switch (uMessage)
00507    {
00508    // on any command notification, tell the property sheet to enable the Apply button
00509    case WM_COMMAND:
00510       PropSheet_Changed(GetParent(hdlg), hdlg);
00511       break;
00512
00513    case WM_NOTIFY:
00514       lpnmhdr = (NMHDR FAR *)lParam;
00515
00516       switch (lpnmhdr->code)
00517          {
00518          case PSN_APPLY:   //sent when OK or Apply button pressed
00519             break;
00520
00521          case PSN_RESET:   //sent when Cancel button pressed
00522             break;
00523
00524          case PSN_SETACTIVE:
00525             //this will be ignored if the property sheet is not a wizard
00526             PropSheet_SetWizButtons(GetParent(hdlg), PSWIZB_BACK | PSWIZB_FINISH);
00527             return FALSE;
00528
00529          default:
00530             break;
00531          }
00532       break;
00533
00534    default:
00535    break;
00536    }
00537
00538 return FALSE;
00539 }
00540
00541 /**************************************************************************
00542
00543    PropSheetCallback()
00544
00545 **************************************************************************/
00546
00547 void CALLBACK PropSheetCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
00548 {
00549 switch(uMsg)
00550    {
00551    //called before the dialog is created, hwndPropSheet = NULL, lParam points to dialog resource
00552    case PSCB_PRECREATE:
00553       {
00554       LPDLGTEMPLATE  lpTemplate = (LPDLGTEMPLATE)lParam;
00555
00556       if(!(lpTemplate->style & WS_SYSMENU))
00557          {
00558          lpTemplate->style |= WS_SYSMENU;
00559          }
00560       }
00561       break;
00562
00563    //called after the dialog is created
00564    case PSCB_INITIALIZED:
00565       break;
00566
00567    }
00568 }
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHtmlIFilter Member List

This is the complete list of members for CHtmlIFilter, including all inherited members.
_cAttributes | CHtmlIFilter | [private]
_fFilterContent | CHtmlIFilter | [private]
_fFilterMetaTag | CHtmlIFilter | [private]
_fFilterScriptTag | CHtmlIFilter | [private]
_fNonHtmlFile | CHtmlIFilter | [private]
_htmlElementBag | CHtmlIFilter | [private]
_locale | CHtmlIFilter | [private]
_pAttributes | CHtmlIFilter | [private]
_pHtmlElement | CHtmlIFilter | [private]
_pwszFileName | CHtmlIFilter | [private]
_serialStream | CHtmlIFilter | [private]
_ulChunkID | CHtmlIFilter | [private]
_uRefs | CHtmlIFilterBase | [protected]
AddRef() | CHtmlIFilterBase | [virtual]
BindRegion(FILTERREGION origPos, REFIID riid, void **ppunk) | CHtmlIFilter | [virtual]
ChangeState(CHtmlElement *pHtmlElemNewState) | CHtmlIFilter |
CHtmlIFilter() | CHtmlIFilter |
CHtmlIFilterBase() | CHtmlIFilterBase | [protected]
FFilterContent() | CHtmlIFilter | [inline]
GetChunk(STAT_CHUNK *pStat) | CHtmlIFilter | [virtual]
GetClassID(CLSID *pClassID) | CHtmlIFilter | [virtual]
GetCurFile(LPWSTR *ppszFileName) | CHtmlIFilter | [virtual]
GetCurHtmlElement() | CHtmlIFilter | [inline]
GetLocale() | CHtmlIFilter | [inline]
GetNextChunkId() | CHtmlIFilter |
GetText(ULONG *pcwcOutput, WCHAR *awcBuffer) | CHtmlIFilter | [virtual]
GetValue(PROPVARIANT **ppPropValue) | CHtmlIFilter | [virtual]
Init(ULONG grfFlags, ULONG cAttributes, FULLPROPSPEC const *aAttributes, ULONG *pFlags) | CHtmlIFilter | [virtual]
IsDirty() | CHtmlIFilter | [virtual]
IsNonHtmlFile() | CHtmlIFilter | [private]
IsStopToken(CToken &token) | CHtmlIFilter |
Load(LPCWSTR pszFileName, DWORD dwMode) | CHtmlIFilter | [virtual]
QueryHtmlElement(HtmlTokenType eTokType) | CHtmlIFilter |
QueryInterface(REFIID riid, void **ppvObject) | CHtmlIFilterBase | [virtual]
Release() | CHtmlIFilterBase | [virtual]
Save(LPCWSTR pszFileName, BOOL fRemember) | CHtmlIFilter | [virtual]
SaveCompleted(LPCWSTR pszFileName) | CHtmlIFilter | [virtual]
SetLocale(LCID locale) | CHtmlIFilter | [inline]
~CHtmlIFilter() | CHtmlIFilter |
~CHtmlIFilterBase() | CHtmlIFilterBase | [protected, virtual]
Generated on Wed Nov 13 2024 16:56:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminThreadingModels Member List

This is the complete list of members for comadmin::COMAdminThreadingModels, including all inherited members.
COMAdminThreadingModelApartment | comadmin::COMAdminThreadingModels | [static]
COMAdminThreadingModelBoth | comadmin::COMAdminThreadingModels | [static]
COMAdminThreadingModelFree | comadmin::COMAdminThreadingModels | [static]
COMAdminThreadingModelMain | comadmin::COMAdminThreadingModels | [static]
COMAdminThreadingModelNeutral | comadmin::COMAdminThreadingModels | [static]
COMAdminThreadingModelNotSpecified | comadmin::COMAdminThreadingModels | [static]
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

UDDI::Tools::CategoryTreeView Member List

This is the complete list of members for UDDI::Tools::CategoryTreeView, including all inherited members.
_connection | UDDI::Tools::CategoryTreeView | [private]
CategoryTree_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) | UDDI::Tools::CategoryTreeView | [inline, private]
CategoryTreeView() | UDDI::Tools::CategoryTreeView | [inline]
CategoryTreeView(UddiConnection connection) | UDDI::Tools::CategoryTreeView | [inline]
components | UDDI::Tools::CategoryTreeView | [private]
Connection | UDDI::Tools::CategoryTreeView |
Dispose(bool disposing) | UDDI::Tools::CategoryTreeView | [inline, protected]
GetChildren(CategoryTreeNode node) | UDDI::Tools::CategoryTreeView | [inline, private]
InitializeComponent() | UDDI::Tools::CategoryTreeView | [inline, private]
LoadTModels() | UDDI::Tools::CategoryTreeView | [inline]
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/line.h Source File

  • Begin
  • sdkdiff

line.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 #ifndef __LINE_H__
00012 #define __LINE_H__
00013 /*
00014  * line.h
00015  *
00016  * interface definition for the LINE data type.
00017  *
00018  * a LINE is a data type representing a line of ansi text along with a
00019  * line number.
00020  * a LINE can establish and maintain a link to another line known to be
00021  * the same.
00022  *
00023  * The LINE maintains a copy of the text, a line number associated with it,
00024  * a handle to another linked line, and a hashcode representing the line.
00025  *
00026  * Comparisons between LINEs take note of the global BOOL option flag
00027  * ignore_blanks. If this is TRUE, all spaces and tabs will be ignored during
00028  * the process of comparing two LINEs. If this option changes, each line
00029  * will have to be told by calling line_reset.
00030  */
00031
00032 /* a handle to a line looks like this. neither you nor your compiler needs
00033  * to know what the structure itself looks like.
00034  */
00035 typedef struct fileline FAR * LINE;
00036
00037
00038 /*
00039  * create a new line. space is allocated somewhere in the line object
00040  * for a null-terminated copy of the text passed in.
00041  *
00042  * the line passed in need not be null-terminated (the length of the line
00043  * is one argument) The copy made will be null-terminated.
00044  *
00045  * returns NULL if failed to create the line.
00046  *
00047  * The line number can be any value you wish to associate with the line.
00048  *
00049  * If the list parameter is non-null, the LINE data will be allocated at
00050  * the end of the list (a List_NewLast operation will be done). if list is
00051  * null, the memory will be allocated using HeapAlloc. This also affects
00052  * the behaviour of line_delete
00053  *
00054  * call line_delete to free up memory associated with this line.
00055  */
00056 LINE line_new(LPSTR text, int linelength, LPWSTR pwzText, int cwchText, UINT linenr, LIST list);
00057
00058
00059
00060 /*
00061  * discard a line. free up all memory associated with it.
00062  *
00063  * if the line was allocated on a list (list argument to line_new was non-null),
00064  * the associated memory will be freed, but the LINE itself will not be.
00065  * Otherwise, the line will freed as well.
00066  */
00067 void line_delete(LINE line);
00068
00069
00070 /*
00071  * reset: discard existing hashcode and linked-line information, since
00072  * the ignore_blanks option has changed.
00073  */
00074 void line_reset(LINE line);
00075
00076 /* test if two lines are alike (they have the same text). Takes note of
00077  * ignore_blanks in its comparison. Does not take any note of the line numbers
00078  * associated with each line. Returns TRUE if they are the same.
00079  */
00080 BOOL line_compare(LINE line1, LINE line2);
00081
00082 /* try to link two lines together. Tests the lines to see if they are
00083  * alike, and if so, establishes a link between them and returns TRUE.
00084  * returns FALSE if they are not the same, or if either of them are already
00085  * linked (a LINE can only have one linked line, and it must be mutual).
00086  */
00087 BOOL line_link(LINE line1, LINE line2);
00088
00089 /*
00090  * return a pointer to the text of this line. You get a pointer to the
00091  * LINE's own copy, so don't free it or extend it. If you modify it,
00092  * you will need to call line_reset before any line_compares or line_links.
00093  */
00094 LPSTR line_gettext(LINE line);
00095 LPWSTR line_gettextW(LINE line);
00096
00097 /*
00098  * return the length of the line in characters, expanding tabs. The tabstops
00099  * parameter determines the tabstop width to be used.
00100  *
00101  * This can be used to calculated
00102  * display space needed, but note that the line returned by
00103  * line_gettext() will still have any tabs unexpanded.
00104  */
00105 int line_gettabbedlength(LINE line, int tabstops);
00106
00107 /*
00108  * each line has a hashcode associated with it. This is a 32-bit code
00109  * generated using the hashstring function. It is calculated only once
00110  * for each line (and thus calls to this function are efficient). To force
00111  * a recalculation, call line_reset.
00112  */
00113 DWORD line_gethashcode(LINE line);
00114
00115 /* get the effective text length, ignoring blanks */
00116 int line_gettextlen(LINE line);
00117
00118 /*
00119  * return the handle for the line that is linked to this line, or NULL if
00120  * there isn't one. Lines are either not linked at all, or are mutually
00121  * linked such that
00122  *              line_getlink( line_getlink(myline)) == myline;
00123  */
00124 LINE line_getlink(LINE line);
00125
00126 /* return the line number associated with a line. This can be any 32-bit
00127  * number that was associated with the line when it was created
00128  */
00129 UINT line_getlinenr(LINE line);
00130
00131 /* return TRUE iff line is blank.  NULL => return FALSE */
00132 BOOL line_isblank(LINE line);
00133 #endif
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/ioo.Cpp Source File

  • Com
  • Fundamentals
  • SimpSvr

ioo.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IOO.CPP
00003 //
00004 //    Implementation file for the COleObject Class
00005 //
00006 // Functions:
00007 //
00008 //    See ioo.h for a list of member functions.
00009 //
00010 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "obj.h"
00015 #include "ioo.h"
00016 #include "app.h"
00017 #include "doc.h"
00018
00019 #define VERB_OPEN 1
00020
00021 //**********************************************************************
00022 //
00023 // COleObject::QueryInterface
00024 //
00025 // Purpose:
00026 //
00027 //
00028 // Parameters:
00029 //
00030 //      REFIID riid         -   Interface being queried for.
00031 //
00032 //      LPVOID FAR *ppvObj  -   Out pointer for the interface.
00033 //
00034 // Return Value:
00035 //
00036 //      S_OK            - Success
00037 //      E_NOINTERFACE   - Failure
00038 //
00039 // Function Calls:
00040 //      Function                    Location
00041 //
00042 //      CSimpSvrObj::QueryInterface OBJ.CPP
00043 //
00044 // Comments:
00045 //
00046 //
00047 //********************************************************************
00048
00049 STDMETHODIMP COleObject::QueryInterface ( REFIID riid, LPVOID FAR* ppvObj)
00050 {
00051         OutputDebugString("In COleObject::QueryInterface\r\n");
00052         return m_lpObj->QueryInterface(riid, ppvObj);
00053 }
00054
00055 //**********************************************************************
00056 //
00057 // COleObject::AddRef
00058 //
00059 // Purpose:
00060 //
00061 //      Increments the reference count on COleObject and the "object"
00062 //      object.
00063 //
00064 // Parameters:
00065 //
00066 //      None
00067 //
00068 // Return Value:
00069 //
00070 //      The Reference count on the Object.
00071 //
00072 // Function Calls:
00073 //      Function                    Location
00074 //
00075 //      OuputDebugString            Windows API
00076 //      CSimpSvrObj::AddRef         OBJ.CPP
00077 //
00078 // Comments:
00079 //
00080 //
00081 //********************************************************************
00082
00083 STDMETHODIMP_(ULONG) COleObject::AddRef ()
00084 {
00085         OutputDebugString("In COleObject::AddRef\r\n");
00086         ++m_nCount;
00087         return m_lpObj->AddRef();
00088 }
00089
00090 //**********************************************************************
00091 //
00092 // COleObject::Release
00093 //
00094 // Purpose:
00095 //
00096 //      Decrements the reference count of COleObject and the
00097 //      "object" object.
00098 //
00099 // Parameters:
00100 //
00101 //      None
00102 //
00103 // Return Value:
00104 //
00105 //      The new reference count
00106 //
00107 // Function Calls:
00108 //      Function                    Location
00109 //
00110 //      OutputDebugString           Windows API
00111 //      CSimpSvrObj::Release        OBJ.CPP
00112 //
00113 // Comments:
00114 //
00115 //
00116 //********************************************************************
00117
00118 STDMETHODIMP_(ULONG) COleObject::Release ()
00119 {
00120         OutputDebugString("In COleObject::Release\r\n");
00121         --m_nCount;
00122         return m_lpObj->Release();
00123 }
00124
00125 //**********************************************************************
00126 //
00127 // COleObject::SetClientSite
00128 //
00129 // Purpose:
00130 //
00131 //      Called to notify the object of it's client site.
00132 //
00133 // Parameters:
00134 //
00135 //      LPOLECLIENTSITE pClientSite     - ptr to new client site
00136 //
00137 // Return Value:
00138 //
00139 //      S_OK
00140 //
00141 // Function Calls:
00142 //      Function                    Location
00143 //
00144 //      OutputDebugString           Windows API
00145 //      IOleClientSite::Release     Container
00146 //      IOleClientSite::AddRef      Container
00147 //
00148 // Comments:
00149 //
00150 //
00151 //********************************************************************
00152
00153 STDMETHODIMP COleObject::SetClientSite  ( LPOLECLIENTSITE pClientSite)
00154 {
00155         OutputDebugString("In COleObject::SetClientSite\r\n");
00156
00157         // if we already have a client site, release it.
00158         if (m_lpObj->m_lpOleClientSite)
00159                 {
00160                 m_lpObj->m_lpOleClientSite->Release();
00161                 m_lpObj->m_lpOleClientSite = NULL;
00162                 }
00163
00164         // store copy of the client site.
00165         m_lpObj->m_lpOleClientSite = pClientSite;
00166
00167         // AddRef it so it doesn't go away.
00168         if (m_lpObj->m_lpOleClientSite)
00169                 m_lpObj->m_lpOleClientSite->AddRef();
00170
00171         return S_OK;
00172 }
00173
00174 //**********************************************************************
00175 //
00176 // COleObject::Advise
00177 //
00178 // Purpose:
00179 //
00180 //      Called to set up an advise on the OLE object.
00181 //
00182 // Parameters:
00183 //
00184 //      LPADVISESINK pAdvSink       - ptr to the Advise Sink for notification
00185 //
00186 //      DWORD FAR* pdwConnection    - place to return the connection ID.
00187 //
00188 // Return Value:
00189 //
00190 //      Passed back from IOleAdviseHolder::Advise.
00191 //
00192 // Function Calls:
00193 //      Function                    Location
00194 //
00195 //      OutputDebugString           Windows API
00196 //      CreateOleAdviseHolder       OLE API
00197 //      IOleAdviseHolder::Advise    OLE
00198 //
00199 // Comments:
00200 //
00201 //
00202 //********************************************************************
00203
00204 STDMETHODIMP COleObject::Advise ( LPADVISESINK pAdvSink, DWORD FAR* pdwConnection)
00205 {
00206         OutputDebugString("In COleObject::Advise\r\n");
00207
00208         // if we haven't made an OleAdviseHolder yet, make one.
00209         if (!m_lpObj->m_lpOleAdviseHolder)
00210                 CreateOleAdviseHolder(&m_lpObj->m_lpOleAdviseHolder);
00211
00212         // pass this call onto the OleAdviseHolder.
00213         return m_lpObj->m_lpOleAdviseHolder->Advise(pAdvSink, pdwConnection);
00214 }
00215
00216 //**********************************************************************
00217 //
00218 // COleObject::SetHostNames
00219 //
00220 // Purpose:
00221 //
00222 //      Called to pass strings for Window titles.
00223 //
00224 // Parameters:
00225 //
00226 //      LPCSTR szContainerApp   -   ptr to string describing Container App
00227 //
00228 //      LPCSTR szContainerObj   -   ptr to string describing Object
00229 //
00230 // Return Value:
00231 //
00232 //      S_OK
00233 //
00234 // Function Calls:
00235 //      Function                    Location
00236 //
00237 //      OutputDebugString           Windows API
00238 //
00239 // Comments:
00240 //
00241 //      This routine is called so that the server application can
00242 //      set the window title appropriately.
00243 //
00244 //********************************************************************
00245
00246 //@@WTK WIN32, UNICODE
00247 //STDMETHODIMP COleObject::SetHostNames  ( LPCSTR szContainerApp, LPCSTR szContainerObj)
00248 STDMETHODIMP COleObject::SetHostNames  ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
00249 {
00250         OutputDebugString("In COleObject::SetHostNames\r\n");
00251
00252         return  S_OK;
00253 };
00254
00255 //**********************************************************************
00256 //
00257 // COleObject::DoVerb
00258 //
00259 // Purpose:
00260 //
00261 //      Called by the container application to invoke a verb.
00262 //
00263 // Parameters:
00264 //
00265 //      LONG iVerb                  - The value of the verb to be
00266 //                                    invoked.
00267 //
00268 //      LPMSG lpmsg                 - The message that caused the
00269 //                                    verb to be invoked.
00270 //
00271 //      LPOLECLIENTSITE pActiveSite - Ptr to the active client site.
00272 //
00273 //      LONG lindex                 - Used in extended layout
00274 //
00275 //      HWND hwndParent             - This should be the window handle of
00276 //                                    the window in which we are contained.
00277 //                                    This value could be used to "fake"
00278 //                                    inplace activation in a manner similar
00279 //                                    to Video for Windows in OLE 1.0.
00280 //
00281 //      LPCRECT lprcPosRect         - The rectangle that contains the object
00282 //                                    within hwndParent.  Also used to
00283 //                                    "fake" inplace activation.
00284 //
00285 // Return Value:
00286 //
00287 //      OLE_E_NOTINPLACEACTIVE      - Returned if attempted to undo while not
00288 //                                    inplace active.
00289 //      S_OK
00290 //
00291 // Function Calls:
00292 //      Function                            Location
00293 //
00294 //      OutputDebugString                   Windows API
00295 //      ShowWindow                          Windows API
00296 //      CSimpSvrObj::DoInPlaceActivate      OBJ.CPP
00297 //      CSimpSvrObj::DoInPlaceHide          OBJ.CPP
00298 //      COleObject::OpenEdit                IOO.CPP
00299 //      CSimpSvrDoc::GethDocWnd             DOC.H
00300 //      COleInPlaceObj::InPlaceDeactivate   IOIPO.CPP
00301 //
00302 // Comments:
00303 //
00304 //      Be sure to look at TECHNOTES.WRI included with the OLE
00305 //      SDK for a description of handling the inplace verbs
00306 //      properly.
00307 //
00308 //********************************************************************
00309
00310 STDMETHODIMP COleObject::DoVerb  (  LONG iVerb,
00311                                                                         LPMSG lpmsg,
00312                                                                         LPOLECLIENTSITE pActiveSite,
00313                                                                         LONG lindex,
00314                                                                         HWND hwndParent,
00315                                                                         LPCRECT lprcPosRect)
00316 {
00317         OutputDebugString("In COleObject::DoVerb\r\n");
00318
00319         switch (iVerb)
00320                 {
00321                 case OLEIVERB_SHOW:
00322                 case OLEIVERB_PRIMARY:
00323                         if (m_fOpen)
00324                                 SetFocus(m_lpObj->m_lpDoc->GethAppWnd());
00325                         else if (m_lpObj->DoInPlaceActivate(iVerb) == FALSE)
00326                                 OpenEdit(pActiveSite);
00327                         break;
00328
00329                 case OLEIVERB_UIACTIVATE:
00330                         if (m_fOpen)
00331                                 return  E_FAIL;
00332
00333                         // inplace activate
00334                         if (!m_lpObj->DoInPlaceActivate(iVerb))
00335                                 return  E_FAIL;
00336                         break;
00337
00338                 case OLEIVERB_DISCARDUNDOSTATE:
00339                         // don't have to worry about this situation as we don't
00340                         // support an undo state.
00341                         if (!m_lpObj->m_fInPlaceActive)
00342                                 return OLE_E_NOT_INPLACEACTIVE;
00343                         break;
00344
00345                 case OLEIVERB_HIDE:
00346                         // if inplace active, do an "inplace" hide, otherwise
00347                         // just hide the app window.
00348                         if (m_lpObj->m_fInPlaceActive)
00349                                 {
00350                                 m_lpObj->DeactivateUI();
00351                                 m_lpObj->DoInPlaceHide();
00352                                 }
00353                         else
00354                                 m_lpObj->m_lpDoc->GetApp()->HideAppWnd();
00355                         break;
00356
00357                 case OLEIVERB_OPEN:
00358                 case VERB_OPEN:
00359                         // if inplace active, deactivate
00360                         if (m_lpObj->m_fInPlaceActive)
00361                                 m_lpObj->m_OleInPlaceObject.InPlaceDeactivate();
00362
00363                         // open into another window.
00364                         OpenEdit(pActiveSite);
00365                         break;
00366
00367                 default:
00368                         if (iVerb < 0)
00369                                 return E_FAIL;
00370                 }
00371
00372         return  S_OK;
00373 };
00374
00375 //**********************************************************************
00376 //
00377 // COleObject::GetExtent
00378 //
00379 // Purpose:
00380 //
00381 //      Returns the extent of the object.
00382 //
00383 // Parameters:
00384 //
00385 //      DWORD dwDrawAspect  - The aspect in which to get the size.
00386 //
00387 //      LPSIZEL lpsizel     - Out ptr to return the size.
00388 //
00389 // Return Value:
00390 //
00391 //
00392 //
00393 // Function Calls:
00394 //      Function                        Location
00395 //
00396 //      OutputDebugString               Windows API
00397 //      XformWidthInPixelsToHimetric    OLESTD
00398 //      XformHeightInPixelsToHimetric   OLESTD
00399 //
00400 // Comments:
00401 //
00402 //
00403 //********************************************************************
00404
00405 STDMETHODIMP COleObject::GetExtent  ( DWORD dwDrawAspect, LPSIZEL lpsizel)
00406 {
00407         OutputDebugString("In COleObject::GetExtent\r\n");
00408
00409         SCODE sc = E_FAIL;
00410
00411         // Only DVASPECT_CONTENT is supported....
00412         if (dwDrawAspect == DVASPECT_CONTENT)
00413                 {
00414                 sc = S_OK;
00415
00416                 // return the correct size in HIMETRIC...
00417                 lpsizel->cx = XformWidthInPixelsToHimetric(NULL, m_lpObj->m_size.x);
00418                 lpsizel->cy = XformHeightInPixelsToHimetric(NULL, m_lpObj->m_size.y);
00419                 }
00420
00421         return  sc ;
00422 };
00423
00424 //**********************************************************************
00425 //
00426 // COleObject::Update
00427 //
00428 // Purpose:
00429 //
00430 //      Called to get the most up to date data
00431 //
00432 // Parameters:
00433 //
00434 //      None
00435 //
00436 // Return Value:
00437 //
00438 //      S_OK
00439 //
00440 // Function Calls:
00441 //      Function                            Location
00442 //
00443 //      OutputDebugString                   Windows API
00444 //      IDataAdviseHolder::SendOnDataChange OLE
00445 //
00446 // Comments:
00447 //
00448 //
00449 //********************************************************************
00450
00451 STDMETHODIMP COleObject::Update()
00452 {
00453         OutputDebugString("In COleObject::Update\r\n");
00454
00455         // force an update
00456         m_lpObj->SendOnDataChange();
00457
00458         return  S_OK ;
00459 };
00460
00461 //**********************************************************************
00462 //
00463 // COleObject::Close
00464 //
00465 // Purpose:
00466 //
00467 //      Called when the OLE object needs to be closed
00468 //
00469 // Parameters:
00470 //
00471 //      DWORD dwSaveOption  - Flags to instruct the server how to prompt
00472 //                            the user.
00473 //
00474 // Return Value:
00475 //
00476 //      S_OK
00477 //
00478 // Function Calls:
00479 //      Function                    Location
00480 //
00481 //      OutputDebugString           Windows API
00482 //      CSimpSvrDoc::Close          DOC.CPP
00483 //
00484 // Comments:
00485 //
00486 //
00487 //********************************************************************
00488
00489 STDMETHODIMP COleObject::Close  ( DWORD dwSaveOption)
00490 {
00491         OutputDebugString("In COleObject::Close\r\n");
00492
00493         // delegate to the document object.
00494         m_lpObj->m_lpDoc->Close();
00495
00496         return  S_OK ;
00497 };
00498
00499 //**********************************************************************
00500 //
00501 // COleObject::Unadvise
00502 //
00503 // Purpose:
00504 //
00505 //      Breaks down an OLE advise that has been set up on this object.
00506 //
00507 // Parameters:
00508 //
00509 //      DWORD dwConnection  - Connection that needs to be broken down
00510 //
00511 // Return Value:
00512 //
00513 //      Passed back from IOleAdviseHolder::Unadvise
00514 //
00515 // Function Calls:
00516 //      Function                    Location
00517 //
00518 //      OutputDebugString           Windows API
00519 //      IOleAdviseHolder::Unadvise  OLE
00520 //
00521 // Comments:
00522 //
00523 //
00524 //********************************************************************
00525
00526 STDMETHODIMP COleObject::Unadvise ( DWORD dwConnection)
00527 {
00528         OutputDebugString("In COleObject::Unadvise\r\n");
00529
00530         // pass on to OleAdviseHolder.
00531         return m_lpObj->m_lpOleAdviseHolder->Unadvise(dwConnection);
00532 };
00533
00534 //**********************************************************************
00535 //
00536 // COleObject::EnumVerbs
00537 //
00538 // Purpose:
00539 //
00540 //      Enumerates the verbs associated with this object.
00541 //
00542 // Parameters:
00543 //
00544 //      LPENUMOLEVERB FAR* ppenumOleVerb    - Out ptr in which to return
00545 //                                            the enumerator
00546 //
00547 // Return Value:
00548 //
00549 //      OLE_S_USEREG    - Instructs OLE to use the verbs found in the
00550 //                        REG DB for this server.
00551 //
00552 // Function Calls:
00553 //      Function                    Location
00554 //
00555 //      OutputDebugString           Windows API
00556 //
00557 // Comments:
00558 //
00559 //      In a .DLL, an application cannot return OLE_S_USEREG.  This is
00560 //      due to the fact that the default object handler is not being
00561 //      used, and the container is really making direct function calls
00562 //      into the server .DLL.
00563 //
00564 //********************************************************************
00565
00566 STDMETHODIMP COleObject::EnumVerbs  ( LPENUMOLEVERB FAR* ppenumOleVerb)
00567 {
00568         OutputDebugString("In COleObject::EnumVerbs\r\n");
00569
00570         return  OLE_S_USEREG ;
00571 };
00572
00573 //**********************************************************************
00574 //
00575 // COleObject::GetClientSite
00576 //
00577 // Purpose:
00578 //
00579 //      Called to get the current client site of the object.
00580 //
00581 // Parameters:
00582 //
00583 //      LPOLECLIENTSITE FAR* ppClientSite   - Out ptr in which to return the
00584 //                                            client site.
00585 //
00586 // Return Value:
00587 //
00588 //      S_OK
00589 //
00590 // Function Calls:
00591 //      Function                    Location
00592 //
00593 //      OutputDebugString           Windows API
00594 //
00595 // Comments:
00596 //
00597 //
00598 //********************************************************************
00599
00600 STDMETHODIMP COleObject::GetClientSite  ( LPOLECLIENTSITE FAR* ppClientSite)
00601 {
00602         OutputDebugString("In COleObject::GetClientSite\r\n");
00603         *ppClientSite = m_lpObj->m_lpOleClientSite;
00604         return  S_OK ;
00605 }
00606
00607 //**********************************************************************
00608 //
00609 // COleObject::SetMoniker
00610 //
00611 // Purpose:
00612 //
00613 //      Used to set the objects moniker
00614 //
00615 // Parameters:
00616 //
00617 //      DWORD dwWhichMoniker    - Type of moniker being set
00618 //
00619 //      LPMONIKER pmk           - Pointer to the moniker
00620 //
00621 // Return Value:
00622 //
00623 //
00624 // Function Calls:
00625 //      Function                    Location
00626 //
00627 //      OutputDebugString           Windows API
00628 //
00629 // Comments:
00630 //
00631 //
00632 //********************************************************************
00633
00634 STDMETHODIMP COleObject::SetMoniker  ( DWORD dwWhichMoniker, LPMONIKER pmk)
00635 {
00636         OutputDebugString("In COleObject::SetMoniker\r\n");
00637
00638         LPMONIKER lpmk;
00639
00640         if (! m_lpObj->GetOleClientSite())
00641                 return  E_FAIL;
00642
00643         if (m_lpObj->GetOleClientSite()->GetMoniker (OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_OBJFULL, &lpmk) != NOERROR)
00644                 return  E_FAIL;
00645
00646
00647         if (m_lpObj->GetOleAdviseHolder())
00648                 m_lpObj->GetOleAdviseHolder()->SendOnRename(lpmk);
00649
00650         LPRUNNINGOBJECTTABLE lpRot;
00651
00652         if (GetRunningObjectTable(0, &lpRot) == NOERROR)
00653                 {
00654                 if (m_lpObj->m_dwRegister)
00655                         lpRot->Revoke(m_lpObj->m_dwRegister);
00656
00657                 lpRot->Register(0, m_lpObj, lpmk, &m_lpObj->m_dwRegister);
00658
00659                 lpRot->Release();
00660                 }
00661
00662
00663         return  S_OK ;
00664 };
00665
00666 //**********************************************************************
00667 //
00668 // COleObject::GetMoniker
00669 //
00670 // Purpose:
00671 //
00672 ////
00673 // Parameters:
00674 //
00675 //      DWORD dwAssign          - Assignment for the moniker
00676 //
00677 //      DWORD dwWhichMoniker    - Which moniker to return
00678 //
00679 //      LPMONIKER FAR* ppmk     - An out ptr to return the moniker
00680 //
00681 // Return Value:
00682 //
00683 //
00684 // Function Calls:
00685 //      Function                    Location
00686 //
00687 //      OutputDebugString           Windows API
00688 //
00689 // Comments:
00690 //
00691 //
00692 //********************************************************************
00693
00694 STDMETHODIMP COleObject::GetMoniker  (  DWORD dwAssign, DWORD dwWhichMoniker,
00695                                                                                 LPMONIKER FAR* ppmk)
00696 {
00697         OutputDebugString("In COleObject::GetMoniker\r\n");
00698         // need to NULL the out parameter
00699         *ppmk = NULL;
00700
00701         return m_lpObj->GetOleClientSite()->GetMoniker (OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_OBJFULL, ppmk);
00702 };
00703
00704 //**********************************************************************
00705 //
00706 // COleObject::InitFromData
00707 //
00708 // Purpose:
00709 //
00710 //      Initialize the object from the passed pDataObject.
00711 //
00712 // Parameters:
00713 //
00714 //      LPDATAOBJECT pDataObject    - Pointer to data transfer object
00715 //                                    to be used in the initialization
00716 //
00717 //      BOOL fCreation              - TRUE if the object is currently being
00718 //                                    created.
00719 //
00720 //      DWORD dwReserved            - Reserved
00721 //
00722 // Return Value:
00723 //
00724 //      S_FALSE
00725 //
00726 // Function Calls:
00727 //      Function                    Location
00728 //
00729 //      OutputDebugString           Windows API
00730 //
00731 // Comments:
00732 //
00733 //      We don't support this functionality, so we will always return
00734 //      error.
00735 //
00736 //********************************************************************
00737
00738 STDMETHODIMP COleObject::InitFromData  ( LPDATAOBJECT pDataObject,
00739                                                                                  BOOL fCreation,
00740                                                                                  DWORD dwReserved)
00741 {
00742         OutputDebugString("In COleObject::InitFromData\r\n");
00743
00744         return  S_FALSE ;
00745 };
00746
00747 //**********************************************************************
00748 //
00749 // COleObject::GetClipboardData
00750 //
00751 // Purpose:
00752 //
00753 //      Returns an IDataObject that is the same as doing an OleSetClipboard
00754 //
00755 // Parameters:
00756 //
00757 //      DWORD dwReserved                - Reserved
00758 //
00759 //      LPDATAOBJECT FAR* ppDataObject  - Out ptr for the Data Object.
00760 //
00761 // Return Value:
00762 //
00763 //      OLE_E_NOTSUPPORTED
00764 //
00765 // Function Calls:
00766 //      Function                    Location
00767 //
00768 //      OutputDebugString           Windows API
00769 //
00770 // Comments:
00771 //
00772 //      Support of this method is optional.
00773 //
00774 //********************************************************************
00775
00776 STDMETHODIMP COleObject::GetClipboardData  ( DWORD dwReserved,
00777                                                                                          LPDATAOBJECT FAR* ppDataObject)
00778 {
00779         OutputDebugString("In COleObject::GetClipboardData\r\n");
00780         // NULL the out ptr
00781         *ppDataObject = NULL;
00782         return  E_NOTIMPL ;
00783 };
00784
00785 //**********************************************************************
00786 //
00787 // COleObject::IsUpToDate
00788 //
00789 // Purpose:
00790 //
00791 //      Determines if an object is up to date
00792 //
00793 // Parameters:
00794 //
00795 //      None
00796 //
00797 // Return Value:
00798 //
00799 //      S_OK
00800 //
00801 // Function Calls:
00802 //      Function                    Location
00803 //
00804 //      OutputDebugString           Windows API
00805 //
00806 // Comments:
00807 //
00808 //      Our embedded object is always up to date.  This function is
00809 //      particularly useful in linking situations.
00810 //
00811 //********************************************************************
00812
00813 STDMETHODIMP COleObject::IsUpToDate()
00814 {
00815         OutputDebugString("In COleObject::IsUpToDate\r\n");
00816         return  S_OK ;
00817 };
00818
00819 //**********************************************************************
00820 //
00821 // COleObject::GetUserClassID
00822 //
00823 // Purpose:
00824 //
00825 //      Returns the applications CLSID
00826 //
00827 // Parameters:
00828 //
00829 //      CLSID FAR* pClsid   - Out ptr to return the CLSID
00830 //
00831 // Return Value:
00832 //
00833 //      S_OK
00834 //
00835 // Function Calls:
00836 //      Function                    Location
00837 //
00838 //      OutputDebugString           Windows API
00839 //      CPersistStorage::GetClassID IPS.CPP
00840 //
00841 // Comments:
00842 //
00843 //      This function is just delegated to IPS::GetClassID.
00844 //
00845 //********************************************************************
00846
00847 STDMETHODIMP COleObject::GetUserClassID  ( CLSID FAR* pClsid)
00848 {
00849         OutputDebugString("In COleObject::GetUserClassID\r\n");
00850
00851         m_lpObj->m_PersistStorage.GetClassID(pClsid);
00852         return  S_OK ;
00853 };
00854
00855 //**********************************************************************
00856 //
00857 // COleObject::GetUserType
00858 //
00859 // Purpose:
00860 //
00861 //      Used to get a user presentable id for this object
00862 //
00863 // Parameters:
00864 //
00865 //      DWORD dwFormOfType      - The ID requested
00866 //
00867 //      LPSTR FAR* pszUserType  - Out ptr to return the string
00868 //
00869 // Return Value:
00870 //
00871 //      OLE_S_USEREG    - Use the reg db to get these entries.
00872 //
00873 // Function Calls:
00874 //      Function                    Location
00875 //
00876 //      OutputDebugString           Windows API
00877 //
00878 // Comments:
00879 //
00880 //
00881 //********************************************************************
00882
00883 //@@WTK WIN32, UNICODE
00884 //STDMETHODIMP COleObject::GetUserType  ( DWORD dwFormOfType, LPSTR FAR* pszUserType)
00885 STDMETHODIMP COleObject::GetUserType  ( DWORD dwFormOfType, LPOLESTR FAR* pszUserType)
00886 {
00887         OutputDebugString("In COleObject::GetUserType\r\n");
00888
00889         return  OLE_S_USEREG ;
00890 };
00891
00892 //**********************************************************************
00893 //
00894 // COleObject::SetExtent
00895 //
00896 // Purpose:
00897 //
00898 //      Called to set the extent of the object.
00899 //
00900 // Parameters:
00901 //
00902 //      DWORD dwDrawAspect  - Aspect to have its size set
00903 //
00904 //      LPSIZEL lpsizel     - New size of the object.
00905 //
00906 // Return Value:
00907 //
00908 //      E_NOTIMPL   - This function is not curently implemented.
00909 //
00910 // Function Calls:
00911 //      Function                    Location
00912 //
00913 //      OutputDebugString           Windows API
00914 //
00915 // Comments:
00916 //
00917 //
00918 //********************************************************************
00919
00920 STDMETHODIMP COleObject::SetExtent  ( DWORD dwDrawAspect, LPSIZEL lpsizel)
00921 {
00922         OutputDebugString("In COleObject::SetExtent\r\n");
00923         return  E_NOTIMPL;
00924 };
00925
00926 //**********************************************************************
00927 //
00928 // COleObject::EnumAdvise
00929 //
00930 // Purpose:
00931 //
00932 //      Returns an enumerate which enumerates the outstanding advises
00933 //      associated with this OLE object.
00934 //
00935 // Parameters:
00936 //
00937 //      LPENUMSTATDATA FAR* ppenumAdvise - Out ptr in which to return
00938 //                                         the enumerator.
00939 //
00940 // Return Value:
00941 //
00942 //      Passed on from IOleAdviseHolder::EnumAdvise.
00943 //
00944 // Function Calls:
00945 //      Function                        Location
00946 //
00947 //      OutputDebugString               Windows API
00948 //      IOleAdviseHolder::EnumAdvise    OLE
00949 //
00950 // Comments:
00951 //
00952 //
00953 //********************************************************************
00954
00955 STDMETHODIMP COleObject::EnumAdvise  ( LPENUMSTATDATA FAR* ppenumAdvise)
00956 {
00957         OutputDebugString("In COleObject::EnumAdvise\r\n");
00958         // need to NULL the out parameter
00959         *ppenumAdvise = NULL;
00960
00961         // pass on to the OLE Advise holder.
00962         return m_lpObj->m_lpOleAdviseHolder->EnumAdvise(ppenumAdvise);
00963 };
00964
00965 //**********************************************************************
00966 //
00967 // COleObject::GetMiscStatus
00968 //
00969 // Purpose:
00970 //
00971 //      Return status information about the object
00972 //
00973 // Parameters:
00974 //
00975 //      DWORD dwAspect          - Aspect interested in.
00976 //
00977 //      DWORD FAR* pdwStatus    - Out ptr in which to return the bits.
00978 //
00979 // Return Value:
00980 //
00981 //      CO_E_READREGDB  - Tell the library to use the reg DB.
00982 //
00983 // Function Calls:
00984 //      Function                    Location
00985 //
00986 //      OutputDebugString           Windows API
00987 //
00988 // Comments:
00989 //
00990 //
00991 //********************************************************************
00992
00993 STDMETHODIMP COleObject::GetMiscStatus  ( DWORD dwAspect, DWORD FAR* pdwStatus)
00994 {
00995         OutputDebugString("In COleObject::GetMiscStatus\r\n");
00996         // need to NULL the out parameter
00997         *pdwStatus = NULL;
00998         return  OLE_S_USEREG ;
00999 };
01000
01001 //**********************************************************************
01002 //
01003 // COleObject::SetColorScheme
01004 //
01005 // Purpose:
01006 //
01007 //      Used to set the palette for the object to use.
01008 //
01009 // Parameters:
01010 //
01011 //      LPLOGPALETTE lpLogpal   - Pointer to the LOGPALETTE to be used.
01012 //
01013 // Return Value:
01014 //
01015 //      S_OK
01016 //
01017 // Function Calls:
01018 //      Function                    Location
01019 //
01020 //      OutputDebugString           Windows API
01021 //
01022 // Comments:
01023 //
01024 //      This server ignores this method.
01025 //
01026 //********************************************************************
01027
01028 STDMETHODIMP COleObject::SetColorScheme  ( LPLOGPALETTE lpLogpal)
01029 {
01030         OutputDebugString("In COleObject::SetColorScheme\r\n");
01031         return  S_OK ;
01032 };
01033
01034 //**********************************************************************
01035 //
01036 // COleObject::OpenEdit
01037 //
01038 // Purpose:
01039 //
01040 //      Used to Open the object into a seperate window.
01041 //
01042 // Parameters:
01043 //
01044 //      LPOLECLIENTSITE pActiveSite - Pointer to the Active clientsite.
01045 //
01046 // Return Value:
01047 //
01048 //      None.
01049 //
01050 // Function Calls:
01051 //      Function                        Location
01052 //
01053 //      IOleClientSite::OnShowWindow    Container
01054 //      ShowWindow                      Windows API
01055 //      UpdateWindow                    Windows API
01056 //      OutputDebugString               Windows API
01057 //      CSimpSvrDoc::GethAppWnd         DOC.H
01058 //      CSimpSvrDoc::GethHatchWnd       DOC.H
01059 //
01060 // Comments:
01061 //
01062 //
01063 //********************************************************************
01064
01065 void COleObject::OpenEdit(LPOLECLIENTSITE pActiveSite)
01066 {
01067    if (m_lpObj->GetOleClientSite())
01068            m_lpObj->GetOleClientSite()->ShowObject();
01069
01070
01071         m_fOpen = TRUE;
01072
01073         // tell the site we are opening so the object can be hatched out.
01074         if (m_lpObj->GetOleClientSite())
01075                 m_lpObj->GetOleClientSite()->OnShowWindow(TRUE);
01076
01077
01078         m_lpObj->m_lpDoc->ShowDocWnd();
01079
01080         m_lpObj->m_lpDoc->HideHatchWnd();
01081
01082         // Show app window.
01083         m_lpObj->m_lpDoc->GetApp()->ShowAppWnd();
01084
01085         SetFocus(m_lpObj->m_lpDoc->GethAppWnd());
01086 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/DHCP/DHCPRequest/dhcprequest.cpp Source File

  • NetDS
  • DHCP
  • DHCPRequest

dhcprequest.cpp

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright © 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00008  *
00009  * Author: Stephen R. Husak - Microsoft Developer Support
00010  *
00011  * Abstract:
00012  *    This code demonstrates the use of the DHCP Client Options API -
00013  *    DhcpRequestParams
00014  *
00015  */
00016
00017 /*
00018  * Includes
00019  */
00020 #include <windows.h>      // windows
00021 #include <stdio.h>        // standard i/o
00022 #include <iphlpapi.h>     // ip helper
00023 #include <dhcpcsdk.h>     // dhcp client options api
00024
00025 // initial buffer size for options buffer
00026 #define INITIAL_BUFFER_SIZE 256
00027
00028 /*
00029  * OutputError
00030  *
00031  * retrieves the system message for an error
00032  */
00033 void OutputError(DWORD dwError)
00034 {
00035   LPVOID lpMsgBuf;    // buffer to copy string into (allocated by call)
00036
00037   if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
00038                 FORMAT_MESSAGE_FROM_SYSTEM |
00039                 FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwError,
00040                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00041                 (LPTSTR) &lpMsgBuf, 0, NULL) == 0)
00042     printf("Error Reported: %d GetLastError: %d\n", dwError, GetLastError());
00043   else
00044     {
00045     printf("Error %d: %s\n", dwError, (LPCSTR) lpMsgBuf);
00046
00047     // free the buffer.
00048     LocalFree(lpMsgBuf);
00049     }
00050 }
00051
00052 /*
00053  * DetermineAdapter
00054  *
00055  * NOTE:
00056  *
00057  *    This code retrieves the Adapter Name to use for the DHCP Client API
00058  *    using the IPHelper API.
00059  *
00060  *    NT has a name for the adapter that through this API has device
00061  *    information in front of it followed by a {GUID}, 98 does not and
00062  *    the Index is used instead. So if the string is set to ?? (what it is
00063  *    in 98) we revert to using the string representation of the index.
00064  *
00065  */
00066 LPSTR DetermineAdapter()
00067 {
00068   DWORD dwResult;                            // result of API calls
00069   IP_INTERFACE_INFO * pInfo = NULL;          // adapter information structure
00070   DWORD dwSize = 0;                          // size of required buffer
00071   CHAR szAdapter[MAX_ADAPTER_NAME] = {0};    // the adapter to use
00072   char * ptr;                                // pointer to adapter name
00073
00074   // get buffer size
00075   dwResult = GetInterfaceInfo(NULL, &dwSize);
00076   if (dwResult == ERROR_INSUFFICIENT_BUFFER)
00077     {
00078     // allocate buffer
00079     pInfo = (IP_INTERFACE_INFO *) LocalAlloc(LPTR, dwSize);
00080     if (!pInfo)
00081       {
00082       OutputError(GetLastError());
00083       exit(1);
00084       }
00085
00086     // make the actual call
00087     dwResult = GetInterfaceInfo(pInfo, &dwSize);
00088     if (dwResult != ERROR_SUCCESS)
00089       {
00090       OutputError(GetLastError());
00091       exit(2);
00092       }
00093     }
00094   else
00095     {
00096     OutputError(GetLastError());
00097     exit(3);
00098     }
00099
00100   // convert, parse, and convert back
00101   ptr = NULL;
00102   WideCharToMultiByte(0, 0, pInfo->Adapter[0].Name,
00103                             lstrlenW(pInfo->Adapter[0].Name),
00104                             szAdapter, MAX_ADAPTER_NAME, NULL, NULL);
00105   if (szAdapter[0] != '?')
00106     {
00107     // find the GUID
00108     ptr = strchr(szAdapter, '{');
00109     }
00110
00111   // use index if the pointer is not set
00112   if (!ptr)
00113     {
00114     sprintf(szAdapter, "%ld\0", pInfo->Adapter[0].Index);
00115     ptr = szAdapter;
00116     }
00117
00118   // free what was allocated
00119   if (pInfo)
00120     LocalFree(pInfo);
00121
00122   return ptr;
00123 }
00124
00125 /*
00126  * main
00127  *
00128  * this is where it all happens
00129  */
00130 int main(int argc, char * argv[])
00131 {
00132   DWORD dwResult;                            // result from API call
00133   DWORD dwVersion;                           // API version reported
00134   WCHAR wszAdapter[MAX_ADAPTER_NAME] = {0};  // the adapter name in wide chars
00135   char * ptr = NULL;                         // pointer to adapter name
00136
00137   if (argc > 1)
00138     ptr = argv[1];
00139   else
00140     ptr = DetermineAdapter();
00141
00142   // convert it for the API call
00143   MultiByteToWideChar(0, 0, ptr, (int) strlen(ptr), wszAdapter, MAX_ADAPTER_NAME);
00144
00145   // initialize the DHCP Client Options API
00146   dwResult = DhcpCApiInitialize(&dwVersion);
00147   if (dwResult != 0)
00148     {
00149     OutputError(dwResult);
00150     exit(4);
00151     }
00152   else
00153     printf("DHCP Client Options API version %d\n", dwVersion);
00154
00155   //
00156   // Here the request is set up - since this is an easy example, the request
00157   // is set up statically, however in a real-world scenario this may require
00158   // building the request array in a more 'dynamic' way
00159   //
00160   // Also for this sample we are using two items that are almost always in a
00161   // DHCP configuration. Hence this information is retrieved from the local
00162   // DHCP cache.
00163   //
00164   // the DHCP Client Options API arrays for getting the options
00165   DHCPCAPI_PARAMS requests[2] =
00166               {{0, OPTION_SUBNET_MASK, FALSE, NULL, 0}, // subnet mask
00167                {0, OPTION_ROUTER_ADDRESS, FALSE, NULL, 0}}; // gateway address
00168
00169   // set-up the actual arrays
00170   DHCPCAPI_PARAMS_ARRAY sendarray = {0, NULL};  // we aren't sending anything
00171   DHCPCAPI_PARAMS_ARRAY requestarray = {2, requests}; // we are requesting 2
00172
00173   // buffer variables
00174   DWORD dwSize = INITIAL_BUFFER_SIZE; // size of buffer for options
00175   LPBYTE buffer = NULL;               // buffer for options
00176   IN_ADDR addr;                       // address in return code
00177
00178   printf("Getting DHCP Options on Adapter [%S]\n", wszAdapter);
00179
00180   // loop until buffer is big enough to get the data and then make request
00181   do
00182     {
00183     if (buffer)
00184       LocalFree(buffer);
00185
00186     buffer = (LPBYTE) LocalAlloc(LPTR, dwSize);       // allocate the buffer
00187     if (!buffer)
00188       {
00189       OutputError(GetLastError());
00190       exit(5);
00191       }
00192
00193     // make the request on the adapter
00194     dwResult = DhcpRequestParams(DHCPCAPI_REQUEST_SYNCHRONOUS,
00195                                  NULL,
00196                                  wszAdapter,
00197                                  NULL, sendarray,
00198                                  requestarray,
00199                                  buffer, &dwSize,
00200                                  NULL);
00201     }
00202   while (dwResult == ERROR_MORE_DATA);
00203
00204   // parse out results
00205   if (dwResult == ERROR_SUCCESS)
00206     {
00207
00208     // first check subnet
00209     if (requests[0].nBytesData > 0)
00210       {
00211       memcpy(&addr, (LPVOID) requests[0].Data, 4);
00212       printf("Subnet Mask: %s\n", inet_ntoa(addr));
00213       }
00214     else
00215       printf("Subnet Mask NOT present!\n");
00216
00217     // check for router address
00218     if (requests[1].nBytesData > 0)
00219       {
00220       memcpy(&addr, (LPVOID) requests[1].Data, 4);
00221       printf("Gateway Address: %s\n", inet_ntoa(addr));
00222       }
00223     else
00224       printf("Gateway Address NOT present!\n");
00225     }
00226   else
00227     {
00228     OutputError(dwResult);
00229     }
00230
00231   // free the buffer
00232   if (buffer)
00233     LocalFree(buffer);
00234
00235   // de-init the api
00236   DhcpCApiCleanup();
00237
00238   return 0;
00239 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCNotify/Resource.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCNotify

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by QCNotify.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_ORDER                       101
00007 #define IDR_NOTIFY                      102
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NEXT_RESOURCE_VALUE        201
00014 #define _APS_NEXT_COMMAND_VALUE         32768
00015 #define _APS_NEXT_CONTROL_VALUE         201
00016 #define _APS_NEXT_SYMED_VALUE           103
00017 #endif
00018 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tallmenu/tallmenu.h Source File

  • WinUI
  • tallmenu

tallmenu.h

Go to the documentation of this file.
00001 /*
00002  *  tallmenu.h
00003  */
00004
00005 #define STRICT
00006 #include <windows.h>
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_ACCEPTEXARGS Member List

This is the complete list of members for _ACCEPTEXARGS, including all inherited members.
dwBytesReceived | _ACCEPTEXARGS
dwLocalAddressLength | _ACCEPTEXARGS
dwReceiveDataLength | _ACCEPTEXARGS
dwRemoteAddressLength | _ACCEPTEXARGS
lpOutputBuffer | _ACCEPTEXARGS
sAcceptSocket | _ACCEPTEXARGS
sProviderAcceptSocket | _ACCEPTEXARGS
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/_Connection.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

_Connection.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface _Connection
00019 /** @com.interface(iid=00000550-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface _Connection extends msado15.Connection15
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=0, type=PROPGET, name="ConnectionString", name2="getConnectionString", addFlagsVtable=4)
00027       @com.parameters([type=STRING] return) */
00028   public String getConnectionString();
00029
00030   /** @com.method(vtoffset=6, dispid=0, type=PROPPUT, name="ConnectionString", name2="putConnectionString", addFlagsVtable=4)
00031       @com.parameters([in,type=STRING] pbstr) */
00032   public void setConnectionString(String pbstr);
00033
00034   /** @com.method(vtoffset=7, dispid=2, type=PROPGET, name="CommandTimeout", name2="getCommandTimeout", addFlagsVtable=4)
00035       @com.parameters([type=I4] return) */
00036   public int getCommandTimeout();
00037
00038   /** @com.method(vtoffset=8, dispid=2, type=PROPPUT, name="CommandTimeout", name2="putCommandTimeout", addFlagsVtable=4)
00039       @com.parameters([in,type=I4] plTimeout) */
00040   public void setCommandTimeout(int plTimeout);
00041
00042   /** @com.method(vtoffset=9, dispid=3, type=PROPGET, name="ConnectionTimeout", name2="getConnectionTimeout", addFlagsVtable=4)
00043       @com.parameters([type=I4] return) */
00044   public int getConnectionTimeout();
00045
00046   /** @com.method(vtoffset=10, dispid=3, type=PROPPUT, name="ConnectionTimeout", name2="putConnectionTimeout", addFlagsVtable=4)
00047       @com.parameters([in,type=I4] plTimeout) */
00048   public void setConnectionTimeout(int plTimeout);
00049
00050   /** @com.method(vtoffset=11, dispid=4, type=PROPGET, name="Version", name2="getVersion", addFlagsVtable=4)
00051       @com.parameters([type=STRING] return) */
00052   public String getVersion();
00053
00054   /** @com.method(vtoffset=12, dispid=5, type=METHOD, name="Close", addFlagsVtable=4)
00055       @com.parameters() */
00056   public void Close();
00057
00058   /** @com.method(vtoffset=13, dispid=6, type=METHOD, name="Execute", addFlagsVtable=4)
00059       @com.parameters([in,type=STRING] CommandText, [out,elementType=VARIANT,type=PTR] RecordsAffected, [in,type=I4] Options, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00060   public msado15._Recordset Execute(String CommandText, Variant RecordsAffected, int Options);
00061
00062   /** @com.method(vtoffset=14, dispid=7, type=METHOD, name="BeginTrans", addFlagsVtable=4)
00063       @com.parameters([type=I4] return) */
00064   public int BeginTrans();
00065
00066   /** @com.method(vtoffset=15, dispid=8, type=METHOD, name="CommitTrans", addFlagsVtable=4)
00067       @com.parameters() */
00068   public void CommitTrans();
00069
00070   /** @com.method(vtoffset=16, dispid=9, type=METHOD, name="RollbackTrans", addFlagsVtable=4)
00071       @com.parameters() */
00072   public void RollbackTrans();
00073
00074   /** @com.method(vtoffset=17, dispid=10, type=METHOD, name="Open", addFlagsVtable=4)
00075       @com.parameters([in,type=STRING] ConnectionString, [in,type=STRING] UserID, [in,type=STRING] Password, [in,type=I4] Options) */
00076   public void Open(String ConnectionString, String UserID, String Password, int Options);
00077
00078   /** @com.method(vtoffset=18, dispid=11, type=PROPGET, name="Errors", name2="getErrors", addFlagsVtable=4)
00079       @com.parameters([iid=00000501-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00080   public msado15.Errors getErrors();
00081
00082   /** @com.method(vtoffset=19, dispid=12, type=PROPGET, name="DefaultDatabase", name2="getDefaultDatabase", addFlagsVtable=4)
00083       @com.parameters([type=STRING] return) */
00084   public String getDefaultDatabase();
00085
00086   /** @com.method(vtoffset=20, dispid=12, type=PROPPUT, name="DefaultDatabase", name2="putDefaultDatabase", addFlagsVtable=4)
00087       @com.parameters([in,type=STRING] pbstr) */
00088   public void setDefaultDatabase(String pbstr);
00089
00090   /** @com.method(vtoffset=21, dispid=13, type=PROPGET, name="IsolationLevel", name2="getIsolationLevel", addFlagsVtable=4)
00091       @com.parameters([type=I4] return) */
00092   public int getIsolationLevel();
00093
00094   /** @com.method(vtoffset=22, dispid=13, type=PROPPUT, name="IsolationLevel", name2="putIsolationLevel", addFlagsVtable=4)
00095       @com.parameters([in,type=I4] Level) */
00096   public void setIsolationLevel(int Level);
00097
00098   /** @com.method(vtoffset=23, dispid=14, type=PROPGET, name="Attributes", name2="getAttributes", addFlagsVtable=4)
00099       @com.parameters([type=I4] return) */
00100   public int getAttributes();
00101
00102   /** @com.method(vtoffset=24, dispid=14, type=PROPPUT, name="Attributes", name2="putAttributes", addFlagsVtable=4)
00103       @com.parameters([in,type=I4] plAttr) */
00104   public void setAttributes(int plAttr);
00105
00106   /** @com.method(vtoffset=25, dispid=15, type=PROPGET, name="CursorLocation", name2="getCursorLocation", addFlagsVtable=4)
00107       @com.parameters([type=I4] return) */
00108   public int getCursorLocation();
00109
00110   /** @com.method(vtoffset=26, dispid=15, type=PROPPUT, name="CursorLocation", name2="putCursorLocation", addFlagsVtable=4)
00111       @com.parameters([in,type=I4] plCursorLoc) */
00112   public void setCursorLocation(int plCursorLoc);
00113
00114   /** @com.method(vtoffset=27, dispid=16, type=PROPGET, name="Mode", name2="getMode", addFlagsVtable=4)
00115       @com.parameters([type=I4] return) */
00116   public int getMode();
00117
00118   /** @com.method(vtoffset=28, dispid=16, type=PROPPUT, name="Mode", name2="putMode", addFlagsVtable=4)
00119       @com.parameters([in,type=I4] plMode) */
00120   public void setMode(int plMode);
00121
00122   /** @com.method(vtoffset=29, dispid=17, type=PROPGET, name="Provider", name2="getProvider", addFlagsVtable=4)
00123       @com.parameters([type=STRING] return) */
00124   public String getProvider();
00125
00126   /** @com.method(vtoffset=30, dispid=17, type=PROPPUT, name="Provider", name2="putProvider", addFlagsVtable=4)
00127       @com.parameters([in,type=STRING] pbstr) */
00128   public void setProvider(String pbstr);
00129
00130   /** @com.method(vtoffset=31, dispid=18, type=PROPGET, name="State", name2="getState", addFlagsVtable=4)
00131       @com.parameters([type=I4] return) */
00132   public int getState();
00133
00134   /** @com.method(vtoffset=32, dispid=19, type=METHOD, name="OpenSchema", addFlagsVtable=4)
00135       @com.parameters([in,type=I4] Schema, [in,type=VARIANT] Restrictions, [in,type=VARIANT] SchemaID, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00136   public msado15._Recordset OpenSchema(int Schema, Variant Restrictions, Variant SchemaID);
00137
00138   /** @com.method(vtoffset=33, dispid=21, type=METHOD, name="Cancel", addFlagsVtable=4)
00139       @com.parameters() */
00140   public void Cancel();
00141
00142
00143   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x550, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00144 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/scpext/scpproppage/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • scpext
  • scpproppage

StdAfx.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       StdAfx.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // stdafx.h : include file for standard system include files,
00012 //      or project specific include files that are used frequently,
00013 //      but are changed infrequently
00014
00015 #if !defined(AFX_STDAFX_H__501092D7_8966_11D1_B93C_00A0C9A06D2D__INCLUDED_)
00016 #define AFX_STDAFX_H__501092D7_8966_11D1_B93C_00A0C9A06D2D__INCLUDED_
00017
00018 #if _MSC_VER >= 1000
00019 #pragma once
00020 #endif // _MSC_VER >= 1000
00021
00022 #define STRICT
00023
00024 #include <afxwin.h>
00025 #include <afxdisp.h>
00026 #include "afxdlgs.h"
00027
00028
00029
00030 #define _ATL_APARTMENT_THREADED
00031
00032 #include <activeds.h>
00033 #include <dsadmin.h>
00034
00035 #include <atlbase.h>
00036
00037 #if ( _ATL_VER >= 0x0300 )
00038 #define _ATL_NO_UUIDOF
00039 #endif
00040
00041
00042
00043
00044 class CMyUIExtModule : public CComModule
00045 {
00046 public:
00047   HRESULT WINAPI UpdateRegistryCLSID(const CLSID& clsid, BOOL bRegister);
00048 };
00049
00050 #define DECLARE_REGISTRY_CLSID() \
00051 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
00052 { \
00053     return _Module.UpdateRegistryCLSID(GetObjectCLSID(), bRegister); \
00054 }
00055
00056 extern CMyUIExtModule _Module;
00057
00058 #include <atlcom.h>
00059
00060 #include <activeds.h> // Active Directory Services Interfaces
00061
00062 //{{AFX_INSERT_LOCATION}}
00063 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00064
00065 #endif // !defined(AFX_STDAFX_H__501092D7_8966_11D1_B93C_00A0C9A06D2D__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/SockAuth/Client.cpp Source File

  • Security
  • SSPI
  • SockAuth

Client.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 Module Name:
00006
00007     client.cpp
00008
00009 Abstract:
00010
00011     A command line app that establishes an authenticated connection
00012    with a server.
00013
00014 Revision History:
00015
00016 --*/
00017
00018 #include <windows.h>
00019 #include <winsock.h>
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include "security.h"
00023 #include "comm.h"
00024 #define SECURITY_WIN32
00025 #include "sspi.h"
00026
00027 #define SOCKET_BUFF_SIZE   65536
00028 #define BIG_BUFF           2048
00029 #define SMALL_BUFF         256
00030
00031 BOOL ConnectAuthSocket (SOCKET *s);
00032 BOOL CloseAuthSocket (SOCKET s);
00033 BOOL DoAuthentication (SOCKET s);
00034
00035 static PBYTE g_pInBuf = NULL;
00036 static unsigned short g_usPort = 2000;
00037 static TCHAR g_szPackageName[SMALL_BUFF];
00038 static BOOL  g_fUseConfidentiality = FALSE;
00039 static BOOL  g_fUseIntegrity = FALSE;
00040 static TCHAR g_szServer[SMALL_BUFF] = "";
00041 static TCHAR g_szTarget[SMALL_BUFF] = "";
00042 static TCHAR * g_pTarget = NULL;
00043 static BOOL  g_fVerbose;
00044
00045
00046 void Usage(void)
00047 {
00048
00049    printf ("usage: client -s<server> [ <options> ]\n");
00050    printf ("\n");
00051    printf ("    -h              show usage\n");
00052    printf ("    -s<server>      name of server. (required)\n");
00053    printf ("    -t<targetname>  SPN or security context of server account (req. for Negotiate/Kerb).\n");
00054    printf ("    -p<package>     name of security package.\n");
00055    printf ("    -c              message confidentiality (encryption).\n");
00056    printf ("    -i              message integrity (signing).\n");
00057    printf ("    -v              verbose mode.\n");
00058    printf ("\n");
00059    printf ("  example: client -swinbase -pnegotiate -c\n");
00060
00061 }
00062
00063 void main(int argc, char *argv[])
00064 {
00065
00066    SOCKET s;
00067    DWORD  cbRead;
00068    BYTE   Data[BIG_BUFF];
00069    PCHAR  pMessage;
00070
00071    int    i;
00072    int    iOption;
00073    char   *pszOption;
00074
00075    if(argc <= 1)
00076    {
00077       Usage();
00078       return;
00079    }
00080
00081    // default package is negotiate
00082    //
00083    lstrcpy(g_szPackageName, "Negotiate");
00084
00085    for(i = 1; i < argc; i++)
00086    {
00087       if(argv[i][0] == '/') argv[i][0] = '-';
00088
00089       if(argv[i][0] != '-')
00090       {
00091          printf("**** Invalid argument \"%s\"\n", argv[i]);
00092          Usage();
00093          return;
00094       }
00095       iOption = argv[i][1];
00096       pszOption = &argv[i][2];
00097
00098       switch(iOption)
00099       {
00100       case 'h':
00101          Usage();
00102          return;
00103
00104       case 's':
00105        lstrcpyn(g_szServer, pszOption, SMALL_BUFF);
00106          break;
00107
00108       case 't':
00109          lstrcpyn(g_szTarget, pszOption, SMALL_BUFF);
00110          g_pTarget = g_szTarget;
00111          break;
00112
00113       case 'p':
00114        lstrcpyn(g_szPackageName, pszOption, SMALL_BUFF);
00115          break;
00116
00117       case 'c':
00118          g_fUseConfidentiality = TRUE;
00119          break;
00120
00121       case 'i':
00122          g_fUseIntegrity = TRUE;
00123          break;
00124
00125       case 'v':
00126          g_fVerbose = TRUE;
00127          break;
00128
00129       default:
00130          printf("**** Invalid option \"%S\"\n", argv[i]);
00131          Usage();
00132          return;
00133
00134       }
00135
00136    }
00137
00138    if(!lstrcmp(g_szServer,""))
00139    {
00140       Usage();
00141       return;
00142    }
00143
00144    // initialize
00145    //
00146    if (!InitWinsock ())
00147       exit (EXIT_FAILURE);
00148
00149    if (!InitPackage (g_szPackageName, g_fVerbose))
00150       exit (EXIT_FAILURE);
00151
00152    g_pInBuf = (PBYTE) malloc (SOCKET_BUFF_SIZE);
00153
00154    if (NULL == g_pInBuf)
00155       exit (EXIT_FAILURE);
00156
00157    // connect to server
00158    //
00159    if (!ConnectAuthSocket (&s))
00160    {
00161       exit (EXIT_FAILURE);
00162    }
00163
00164    if (!ReceiveBytes (s, Data, BIG_BUFF, &cbRead) || (cbRead == 0))
00165    {
00166       printf("No response from server, authentication most likely failed\n");
00167    }
00168    else
00169    {
00170       printf ("Authentication Succeeded!\n");
00171
00172       // display the results
00173       //
00174       if(g_fUseConfidentiality)
00175       {
00176          pMessage = (PCHAR) DecryptThis (s, Data, &cbRead);
00177       }
00178       else if(g_fUseIntegrity)
00179       {
00180          pMessage = (PCHAR) VerifyThis (s, Data, &cbRead);
00181       }
00182       else
00183          pMessage = (PCHAR) Data;
00184
00185       printf ("Connected to server as user: %.*s", cbRead, pMessage);
00186    }
00187
00188    printf ("\n");
00189
00190    // terminate
00191    //
00192    CloseAuthSocket (s);
00193
00194    TermPackage ();
00195
00196    TermWinsock ();
00197
00198    if(g_pInBuf)
00199       free (g_pInBuf);
00200
00201    exit (EXIT_SUCCESS);
00202 }
00203
00204 BOOL ConnectAuthSocket (SOCKET *s)
00205 /*++
00206
00207  Routine Description:
00208
00209     Establishes an authenticated socket connection with a server and
00210    initializes any needed security package resources.
00211
00212  Return Value:
00213
00214     Returns TRUE is successful; otherwise FALSE is returned.
00215
00216 --*/
00217 {
00218    SOCKET sockServer;
00219    unsigned long ulAddress;
00220    struct hostent *pHost;
00221    SOCKADDR_IN sin;
00222    DWORD dwRes;
00223
00224    // lookup the address for the server name
00225    //
00226    ulAddress = inet_addr (g_szServer);
00227    if (INADDR_NONE == ulAddress) {
00228       pHost = gethostbyname (g_szServer);
00229       if (NULL == pHost) {
00230          dwRes = GetLastError ();
00231          fprintf (stderr, "Unable to resolve host name: %u\n", dwRes);
00232          return(FALSE);
00233       }
00234
00235       memcpy((char FAR *)&ulAddress, pHost->h_addr, pHost->h_length);
00236    }
00237
00238    // create the socket
00239    //
00240    sockServer = socket (PF_INET, SOCK_STREAM, 0);
00241    if (INVALID_SOCKET == sockServer) {
00242       fprintf (stderr, "Unable to create socket: %u\n", GetLastError ());
00243       return(FALSE);
00244    }
00245
00246    sin.sin_family = AF_INET;
00247    sin.sin_addr.s_addr = ulAddress;
00248    sin.sin_port = htons (g_usPort);
00249
00250    // connect to remote endpoint
00251    //
00252    if (connect (sockServer, (LPSOCKADDR) &sin, sizeof (sin))) {
00253       fprintf (stderr, "connect failed: %u\n", GetLastError ());
00254       closesocket (sockServer);
00255       return(FALSE);
00256    }
00257
00258    // Make this an authenticated connection
00259    //
00260    if (!InitSession (sockServer)) {
00261       closesocket (sockServer);
00262       return(FALSE);
00263    }
00264
00265    if (!DoAuthentication (sockServer)) {
00266       closesocket (sockServer);
00267       return(FALSE);
00268    }
00269
00270    *s = sockServer;
00271
00272    return(TRUE);
00273 }
00274
00275 BOOL CloseAuthSocket (SOCKET s)
00276 /*++
00277
00278  Routine Description:
00279
00280     Closes a socket and releases security resources associated with
00281    the socket
00282
00283  Return Value:
00284
00285     Returns TRUE is successful; otherwise FALSE is returned.
00286
00287 --*/
00288 {
00289    TermSession (s);
00290    shutdown (s, 2);
00291    closesocket (s);
00292    return(TRUE);
00293 }
00294
00295 BOOL DoAuthentication (SOCKET s)
00296 /*++
00297
00298  Routine Description:
00299
00300     Manges the authentication conversation with the server via the
00301     supplied socket handle.
00302
00303  Return Value:
00304
00305     Returns TRUE is successful; otherwise FALSE is returned.
00306
00307 --*/
00308 {
00309    BOOL done = FALSE;
00310    DWORD cbOut = 0;
00311    DWORD cbIn = 0;
00312    ULONG attrib = 0;
00313    PBYTE pOutBuf = NULL;
00314
00315
00316    if (g_fUseConfidentiality)
00317       attrib |= ISC_REQ_CONFIDENTIALITY;
00318
00319    if (g_fUseIntegrity)
00320       attrib |= ISC_REQ_INTEGRITY;
00321
00322    cbOut = 0;
00323
00324    if (!GenClientContext (s, NULL, 0, &pOutBuf, &cbOut, &done, &attrib, g_pTarget))
00325       return(FALSE);
00326
00327    if (!SendMsg (s, pOutBuf, cbOut))
00328       return(FALSE);
00329
00330    // done with package allocated buffer - free it
00331    if(pOutBuf)
00332       FreeContextBuffer(pOutBuf);
00333
00334    while (!done) {
00335
00336       if (!ReceiveMsg (s, g_pInBuf, SOCKET_BUFF_SIZE, &cbIn))
00337          return(FALSE);
00338
00339       cbOut = 0;
00340       pOutBuf = NULL;
00341
00342       if (!GenClientContext (s, g_pInBuf, cbIn, &pOutBuf, &cbOut, &done, &attrib, g_pTarget))
00343          return(FALSE);
00344
00345       if (!SendMsg (s, pOutBuf, cbOut))
00346          return(FALSE);
00347
00348       // done with package allocated buffer - free it
00349       if(pOutBuf)
00350          FreeContextBuffer(pOutBuf);
00351
00352    }
00353
00354    if(g_fVerbose)
00355       printf("Context Attributes = 0x%08x\n", attrib);
00356
00357    // check the context flags and make sure we got what we want
00358    //
00359    if (g_fUseConfidentiality && !(attrib & ISC_RET_CONFIDENTIALITY))
00360    {
00361       fprintf (stderr, "** confidentiality flags not set on context\n");
00362       //
00363       // the application can decide to either terminate the conversation or continue.
00364       // we are going to let the client make these decisions and continue
00365       //
00366       g_fUseConfidentiality = FALSE;
00367    }
00368
00369    if (g_fUseIntegrity && !(attrib & ISC_REQ_INTEGRITY))
00370    {
00371       fprintf (stderr, " ** integrity flags not set on context\n");
00372       //
00373       // the application can decide to either terminate the conversation or continue.
00374       // we are going to let the client make these decisions and continue
00375       //
00376       g_fUseIntegrity = FALSE;
00377    }
00378
00379    return(TRUE);
00380 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_RECV_INFO Member List

This is the complete list of members for _RECV_INFO, including all inherited members.
hEvents | _RECV_INFO
nTotalClients | _RECV_INFO
recvbuf | _RECV_INFO
sd | _RECV_INFO
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/IRecFields.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

IRecFields.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface IRecFields
00019 /** @com.interface(iid=00000563-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface IRecFields extends IUnknown
00021 {
00022   /** @com.method(vtoffset=0, dispid=1, type=METHOD, name="ADOCheck", addFlagsVtable=4)
00023       @com.parameters() */
00024   public void ADOCheck();
00025
00026
00027   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x563, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00028 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • CutCopy

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/DComDraw/DComDraw.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • DComDraw

DComDraw.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      DCOMDRAW.CPP
00003
00004   Summary:   This client loads and accesses the Connectable SharePaper
00005              component provided in a separate out-of-process COM Server
00006              (DCDSERVE built in the sibling DCDSERVE directory). Thus to
00007              run DCOMDRAW you must build DCDSERVE first. This client
00008              application is meant to exercise the DCDSERVE out-of-process
00009              server and to illustrate the use of a shared single COPaper
00010              COM object in a remote server. Distributed COM (DCOM) is
00011              used. The shared COPaper object can store its drawing data in
00012              the structured storage of a single compound file.
00013
00014              The COPaper object maintains logic and data to represent a
00015              white sheet of free-form drawing paper. The behavior is much
00016              like other C++ scribble code samples except that the
00017              DCOMDRAW/DCDSERVE pair are implemented using custom COM
00018              objects, interfaces, and standard COM services. The client
00019              mouse activity is used to draw ink lines on the paper
00020              surface. The COPaper object keeps a memory array of the Ink
00021              data but performs no GUI display. This DCOMDRAW (largely
00022              within the CGuiPaper object) manages the display of the
00023              current drawing data.
00024
00025              There is no GUI behavior in the server--it is all in this
00026              client.  This client instantiates one instance of the
00027              server's COPaper COM object and then allows the user to
00028              use the mouse to draw lines in the client area of the
00029              main window. If other clients are run they access the same
00030              shared drawing even if the server requested is on a remote
00031              machine. DCDSERVE registers its COPaper component so that
00032              there is one shared drawing per machine.
00033
00034              For a comprehensive tutorial code tour of DCOMDRAW's contents
00035              and offerings see the tutorial DCOMDRAW.HTM file. For
00036              more specific technical details on the internal workings see
00037              the comments dispersed throughout the DCOMDRAW source code.
00038              For more details on the DCDSERVE.DLL that DCOMDRAW works with
00039              see the DCDSERVE.HTM file in the main tutorial directory.
00040
00041   Classes:   CMainWindow.
00042
00043   Functions: InitApplication, WinMain
00044
00045   Origin:    8-23-97: atrent - Editor-inheritance from the CONCLIEN source.
00046                [Revised]
00047
00048 ----------------------------------------------------------------------------
00049   This file is part of the Microsoft COM Tutorial Code Samples.
00050
00051   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00052
00053   This source code is intended only as a supplement to Microsoft
00054   Development Tools and/or on-line documentation.  See these other
00055   materials for detailed information regarding Microsoft code samples.
00056
00057   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00058   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00059   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00060   PARTICULAR PURPOSE.
00061 ==========================================================================+*/
00062
00063 /*--------------------------------------------------------------------------
00064   We include WINDOWS.H for all Win32 applications.
00065   We include OLE2.H because we will be calling the COM/OLE Libraries.
00066   We include OLECTL.H because it has definitions for connectable objects.
00067   We include INITGUID.H only once (here) in the entire app because we
00068     will be defining GUIDs and want them as constants in the data segment.
00069   We include COMMDLG.H because we will be using the Open File
00070     and potentially other Common dialogs.
00071   We include APPUTIL.H because we will be building this application using
00072     the convenient Virtual Window and Dialog classes and other
00073     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00074   We include PAPINT.H and PAPGUIDS.H for the common paper-related Interface
00075     class, GUID, and CLSID specifications.
00076   We include GUIPAPER.H because it has the C++ class used for GUI display
00077     of the drawing paper.
00078   We include DCOMDRAW.H because it has class and resource definitions
00079     specific to this DCOMDRAW application.
00080 ---------------------------------------------------------------------------*/
00081 #include <windows.h>
00082 #include <ole2.h>
00083 #include <olectl.h>
00084 #include <initguid.h>
00085 #include <commdlg.h>
00086 #include <apputil.h>
00087 #include <papint.h>
00088 #include <papguids.h>
00089 #include "guipaper.h"
00090 #include "dcomdraw.h"
00091
00092
00093 // Here is a structure for storing the remote server info.
00094 COSERVERINFO g_ServerInfo;
00095 // Storage for the user entered remote machine name.
00096 TCHAR g_szMachineName[MAX_PATH] = TEXT("");
00097 OLECHAR g_wszMachineName[MAX_PATH];
00098
00099
00100 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00101   Method:   CMainWindow::CMainWindow
00102
00103   Summary:  CMainWindow Constructor.
00104
00105   Args:     .
00106
00107   Returns:  .
00108 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00109 CMainWindow::CMainWindow()
00110 {
00111   // Ensure these member variable strings are null strings.
00112   m_szFileName[0] = 0;
00113
00114   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00115   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00116   m_ofnFile.hwndOwner = m_hWnd;
00117   m_ofnFile.hInstance = m_hInst;
00118   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00119   m_ofnFile.lpstrCustomFilter = NULL;
00120   m_ofnFile.nMaxCustFilter = 0;
00121   m_ofnFile.nFilterIndex = 1;
00122   m_ofnFile.lpstrFile = m_szFileName;
00123   m_ofnFile.nMaxFile = MAX_PATH;
00124   m_ofnFile.lpstrInitialDir = TEXT(".");
00125   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00126   m_ofnFile.nMaxFileTitle = MAX_PATH;
00127   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00128   m_ofnFile.lpstrDefExt = NULL;
00129   m_ofnFile.Flags = OFN_HIDEREADONLY;
00130
00131   m_pMsgBox  = NULL;
00132   m_pGuiPaper = NULL;
00133 }
00134
00135
00136 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00137   Method:   CMainWindow::~CMainWindow
00138
00139   Summary:  CMainWindow Destructor.  Destruction of the main window
00140             indicates that the application should quit and thus the
00141             PostQuitMessage API is called.
00142
00143   Args:     .
00144
00145   Returns:  .
00146 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00147 CMainWindow::~CMainWindow()
00148 {
00149   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00150   // message and causes a delete of CMainWindow which in turn causes this
00151   // destructor to run. The WM_DESTROY results when the window is destoyed
00152   // after a close of the window. Prior to exiting the main message loop:
00153
00154   // We delete the CGuiPaper and CMsgBox objects that were made in
00155   // Initinstance.
00156   DELETE_POINTER(m_pGuiPaper);
00157   DELETE_POINTER(m_pMsgBox);
00158
00159   // We then post a WM_QUIT message to cause an exit of the main
00160   // message loop and an exit of this instance of the application.
00161   PostQuitMessage(0);
00162 }
00163
00164
00165 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00166   Method:   CMainWindow::InitInstance
00167
00168   Summary:  Instantiates an instance of the main application window.
00169             This method must be called only once, immediately after
00170             window class construction.  We take care to delete 'this'
00171             CMainWindow if we must return the error condition FALSE.
00172
00173   Args:     HINSTANCE hInstance,
00174               Handle of the application instance.
00175             LPSTR pszCmdLine,
00176               Pointer to the application's invocation command line.
00177             int nCmdShow)
00178               Command to pass to ShowWindow.
00179
00180   Modifies: m_szHelpFile, m_pMsgBox.
00181
00182   Returns:  BOOL.
00183               TRUE if succeeded.
00184               FALSE if failed.
00185 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00186 BOOL CMainWindow::InitInstance(
00187        HINSTANCE hInstance,
00188        LPSTR pszCmdLine,
00189        int nCmdShow)
00190 {
00191   BOOL bOk = FALSE;
00192   HWND hWnd = NULL;
00193   HRESULT hr = E_FAIL;
00194
00195   // Create the Message Box and Message Log objects.
00196   m_pMsgBox = new CMsgBox;
00197
00198   // Create the CGuiPaper C++ object.
00199   m_pGuiPaper = new CGuiPaper;
00200
00201   if (NULL != m_pMsgBox && NULL != m_pGuiPaper)
00202   {
00203     // Note, the Create method sets the m_hWnd member so we don't
00204     // need to set it explicitly here first. Here is the create of this
00205     // window.  Size the window reasonably. Create sets both m_hInst and
00206     // m_hWnd. This creates the main client window.
00207     hWnd = Create(
00208              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00209              TEXT(MAIN_APP_NAME_STR),
00210              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00211                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00212              CW_USEDEFAULT,
00213              CW_USEDEFAULT,
00214              ::GetSystemMetrics(SM_CXSCREEN)*2/5,
00215              ::GetSystemMetrics(SM_CYSCREEN)*2/5,
00216              NULL,
00217              NULL,
00218              hInstance);
00219     if (NULL != hWnd)
00220     {
00221       // Init the new GuiPaper.
00222       bOk = m_pGuiPaper->Init(m_hInst, m_hWnd);
00223       if (bOk)
00224       {
00225         // Ensure the new window is shown on screen and content
00226         // is painted.
00227         ::ShowWindow(m_hWnd, nCmdShow);
00228         ::UpdateWindow(m_hWnd);
00229
00230         // Build a path to where the help file should be (it should be in
00231         // the same directory as the .EXE but with the .HTM extension).
00232         MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00233
00234         // Init the Message Box object.
00235         bOk = m_pMsgBox->Init(m_hInst, m_hWnd);
00236
00237         // Connect the new Paper Sink in this client to receive event
00238         // calls from a COPaper source in the server.
00239         hr = m_pGuiPaper->ConnectPaperSink();
00240         if (SUCCEEDED(hr))
00241         {
00242           // Lock the paper object for drawing by this client. Can't draw
00243           // with mouse until doing this. Set the proper checkmark
00244           // indicator on the menu selections as well.
00245           hr = m_pGuiPaper->Lock(TRUE);
00246           if (SUCCEEDED(hr))
00247           {
00248             // Try to load drawing data from local COPaper's compound file.
00249             hr = m_pGuiPaper->Load();
00250           }
00251           else
00252           {
00253             // Shared drawing already loaded by another client.
00254             // Paint this client's window with the shared drawing.
00255             hr = m_pGuiPaper->PaintWin();
00256           }
00257         }
00258       }
00259     }
00260   }
00261
00262   bOk = SUCCEEDED(hr);
00263
00264   if (!bOk)
00265   {
00266     DELETE_POINTER(m_pMsgBox);
00267     DELETE_POINTER(m_pGuiPaper);
00268   }
00269
00270   return (bOk);
00271 }
00272
00273
00274 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00275   Method:   CMainWindow::DoMenu
00276
00277   Summary:  Dispatch and handle the main menu commands.
00278
00279   Args:     WPARAM wParam,
00280               First message parameter (word sized).
00281             LPARAM lParam)
00282               Second message parameter (long sized).
00283
00284   Modifies: m_ofnFile, ...
00285
00286   Returns:  LRESULT
00287               Standard Windows WindowProc return value.
00288 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00289 LRESULT CMainWindow::DoMenu(
00290           WPARAM wParam,
00291           LPARAM lParam)
00292 {
00293   LRESULT lResult = FALSE;
00294   HRESULT hr;
00295
00296   switch (LOWORD(wParam))
00297   {
00298     //----------------------------------------------------------------------
00299     // Handle File Menu Commands.
00300     //----------------------------------------------------------------------
00301     case IDM_FILE_LOADREMOTE:
00302       // Ask the user for the name of the machine where the remote
00303       // DCDSERVE server is.
00304       hr = m_pGuiPaper->LoadRemote();
00305       if (FAILED(hr))
00306         Beep(2000, 200);
00307       break;
00308     case IDM_FILE_LOADLOCAL:
00309       // Ask COPaper to load the drawing from the local DCDSERVE server.
00310       hr = m_pGuiPaper->LoadLocal();
00311       if (FAILED(hr))
00312         Beep(2000, 200);
00313       break;
00314     case IDM_FILE_SAVE:
00315       // Ask COPaper to save the current shared drawing.
00316       hr = E_FAIL;
00317       if (m_pGuiPaper->Master())
00318         hr = m_pGuiPaper->Save();
00319       if (FAILED(hr))
00320         Beep(2000, 200);
00321       break;
00322     case IDM_FILE_EXIT:
00323       // The user commands us to exit this application so we tell the
00324       // Main window to close itself.
00325       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00326       break;
00327
00328     //----------------------------------------------------------------------
00329     // Handle Draw Menu Choice Commands.
00330     //----------------------------------------------------------------------
00331     case IDM_DRAW_MASTER:
00332       // Lock the paper object for drawing by this client. Can't draw
00333       // with mouse until doing this. This makes this client the master
00334       // client that currently owns the drawing. Drawing activity in the
00335       // master is echoed to any other connected slave clients.
00336       hr = E_FAIL;
00337       if (!m_pGuiPaper->Master())
00338         hr = m_pGuiPaper->Lock(TRUE);
00339       if (FAILED(hr))
00340         Beep(2000, 200);
00341       break;
00342     case IDM_DRAW_SLAVE:
00343       // Unlock the paper object for drawing by this client. This
00344       // makes this client a slave to a separate other master client.
00345       hr = E_FAIL;
00346       if (m_pGuiPaper->Master())
00347         hr = m_pGuiPaper->Lock(FALSE);
00348       if (FAILED(hr))
00349         Beep(2000, 200);
00350       break;
00351     case IDM_DRAW_REDRAW:
00352       // Ask Paper object to redraw its current content.
00353       m_pGuiPaper->ClearWin();
00354       m_pGuiPaper->PaintWin();
00355       break;
00356     case IDM_DRAW_ERASE:
00357       // Ask Paper object to erase its current content and if it can
00358       // Clear drawing display window.
00359       hr = E_FAIL;
00360       if (m_pGuiPaper->Master())
00361         hr = m_pGuiPaper->Erase();
00362       if (FAILED(hr))
00363         Beep(2000, 200);
00364       break;
00365
00366     //----------------------------------------------------------------------
00367     // Handle Pen Menu Commands.
00368     //----------------------------------------------------------------------
00369     case IDM_PEN_COLOR:
00370       // Select Ink drawing color using ChooseColor common dialog.
00371       hr = E_FAIL;
00372       if (m_pGuiPaper->Master())
00373       {
00374         COLORREF crNewColor = m_pGuiPaper->PickColor();
00375         hr = m_pGuiPaper->InkColor(crNewColor);
00376       }
00377       if (FAILED(hr))
00378         Beep(2000, 200);
00379       break;
00380     case IDM_PEN_THIN:
00381       // Select thin Ink width. Set menu check indicator.
00382       hr = E_FAIL;
00383       if (m_pGuiPaper->Master())
00384         hr = m_pGuiPaper->InkWidth(INK_THIN);
00385       if (FAILED(hr))
00386         Beep(2000, 200);
00387       break;
00388     case IDM_PEN_MEDIUM:
00389       // Select medium Ink width. Set menu check indicator.
00390       hr = E_FAIL;
00391       if (m_pGuiPaper->Master())
00392         hr = m_pGuiPaper->InkWidth(INK_MEDIUM);
00393       if (FAILED(hr))
00394         Beep(2000, 200);
00395       break;
00396     case IDM_PEN_THICK:
00397       // Select thick Ink width. Set menu check indicator.
00398       hr = E_FAIL;
00399       if (m_pGuiPaper->Master())
00400         hr = m_pGuiPaper->InkWidth(INK_THICK);
00401       if (FAILED(hr))
00402         Beep(2000, 200);
00403       break;
00404
00405     //----------------------------------------------------------------------
00406     // Handle Help Menu Commands.
00407     //----------------------------------------------------------------------
00408     case IDM_HELP_CONTENTS:
00409       // We have some stubbed support here for bringing up the online
00410       // Help for this application.
00411       ReadHelp(m_hWnd, m_szHelpFile);
00412       break;
00413     case IDM_HELP_TUTORIAL:
00414       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00415       // tutorial narrative file associated with this tutorial code sample.
00416       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00417       break;
00418     case IDM_HELP_TUTSERVER:
00419       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00420       // tutorial narrative file associated with the DCDSERVE COM server.
00421       ReadTutorial(m_hInst, m_hWnd, TEXT(SERVER_TUTFILE_STR));
00422       break;
00423     case IDM_HELP_TUTMARSH:
00424       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00425       // tutorial narrative file associated with the DCDMARSH COM server.
00426       ReadTutorial(m_hInst, m_hWnd, TEXT(MARSHAL_TUTFILE_STR));
00427       break;
00428     case IDM_HELP_READSOURCE:
00429       // Call the APPUTIL utility function ReadSource to allow the
00430       // user to open and read any of the source files of DCOMDRAW.
00431       ReadSource(m_hWnd, &m_ofnFile);
00432       break;
00433     case IDM_HELP_ABOUT:
00434       {
00435         CAboutBox dlgAboutBox;
00436
00437         // Show the standard About Box dialog for this EXE by telling the
00438         // dialog C++ object to show itself by invoking its ShowDialog
00439         // method.  Pass it this EXE instance and the parent window handle.
00440         // Use a dialog resource ID for the dialog template stored in
00441         // this EXE module's resources.
00442         dlgAboutBox.ShowDialog(
00443           m_hInst,
00444           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00445           m_hWnd);
00446       }
00447       break;
00448
00449     default:
00450       // Defer all messages NOT handled here to the Default Window Proc.
00451       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00452       break;
00453   }
00454
00455   return(lResult);
00456 }
00457
00458
00459 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00460   Method:   CDlgLoadRemote::DialogProc
00461
00462   Summary:  Dialog proc for the Remote Load dialog box.  This DialogProc
00463             method definition overrides the same-named pure virtual
00464             function in abstract base class CVirDialog thus giving unique
00465             message dispatching behavior to this derivation of CVirDialog.
00466             The remaining behavior of CDlgRemoteInfo is inherited from
00467             CVirDialog and is common to all CVirDialogs.
00468
00469   Args:     HWND hWndDlg,
00470               Handle to the dialog.
00471             UINT uMsg,
00472               Windows message to dialog.
00473             WPARAM wParam,
00474               First message parameter (word sized).
00475             LPARAM lParam)
00476               Second message parameter (long sized).
00477
00478   Returns:  BOOL.  TRUE if message was handled; FALSE otherwise.
00479 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00480 BOOL CDlgLoadRemote::DialogProc(
00481        HWND hWndDlg,
00482        UINT uMsg,
00483        WPARAM wParam,
00484        LPARAM lParam)
00485 {
00486   BOOL bResult = TRUE;
00487   HWND hCtrl = GetDlgItem(hWndDlg, IDC_EDIT_MACHINE);
00488
00489   switch (uMsg)
00490   {
00491     case WM_INITDIALOG:
00492       SetDlgItemText(hWndDlg, IDC_EDIT_MACHINE, g_szMachineName);
00493       SetFocus(hCtrl);
00494       bResult = FALSE;
00495       break;
00496
00497     case WM_COMMAND:
00498       {
00499         WORD wCmd = LOWORD(wParam);
00500
00501         if (wCmd == IDOK)
00502         {
00503           // Obtain the machine name from the edit control.
00504           GetDlgItemText(hWndDlg, IDC_EDIT_MACHINE, g_szMachineName, MAX_PATH);
00505 #if !defined(UNICODE)
00506           // Convert to WideChar Unicode if we are NOT compiled for Unicode.
00507           AnsiToUc(g_szMachineName, g_wszMachineName, 0);
00508 #endif
00509           ::EndDialog(hWndDlg, IDOK);
00510         }
00511         else if (wCmd == IDCANCEL)
00512           ::EndDialog(hWndDlg, IDCANCEL);
00513       }
00514       break;
00515
00516     default:
00517       bResult = FALSE;
00518       break;
00519   }
00520
00521   return(bResult);
00522 }
00523
00524
00525 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00526   Method:   CMainWindow::WindowProc
00527
00528   Summary:  Main window procedure for this window object.  See CVirWindow
00529             in the APPUTIL library (APPUTIL.CPP) for details on how this
00530             method gets called by the global WindowProc.
00531
00532   Args:     UINT uMsg,
00533               Windows message that is "sent" to this window.
00534             WPARAM wParam,
00535               First message parameter (word sized).
00536             LPARAM lParam)
00537               Second message parameter (long sized).
00538
00539   Returns:  LRESULT
00540               Standard Windows WindowProc return value.
00541 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00542 LRESULT CMainWindow::WindowProc(
00543           UINT uMsg,
00544           WPARAM wParam,
00545           LPARAM lParam)
00546 {
00547   LRESULT lResult = FALSE;
00548
00549   switch (uMsg)
00550   {
00551     case WM_CREATE:
00552       break;
00553
00554     case WM_ACTIVATE:
00555       // If we were newly activated by a mouse click then don't just sit
00556       // there--re-paint. This is needed when another window was topped
00557       // over part of DCOMDRAW and the user then topped DCOMDRAW using
00558       // a mouse click on the visible part of DCOMDRAW. In any case let
00559       // the windows default WindowProc handle this message to set
00560       // keyboard focus to the newly active window.
00561       if (WA_CLICKACTIVE == LOWORD(wParam))
00562         m_pGuiPaper->PaintWin();
00563       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00564       break;
00565
00566     case WM_MEASUREITEM:
00567       // Get setup for painting text in this window. For later evolution.
00568       {
00569         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00570         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00571         lpmis->itemWidth = m_lWidth;
00572         lResult = TRUE;
00573       }
00574
00575     case WM_SIZE:
00576       // Handle a resize of this window.
00577       if (m_pGuiPaper->Master())
00578       {
00579         m_lWidth = LOWORD(lParam);
00580         m_lHeight = HIWORD(lParam);
00581         // Inform CGuiPaper of the change.
00582         m_pGuiPaper->Resize(m_lWidth, m_lHeight);
00583       }
00584       break;
00585
00586     case WM_PAINT:
00587       // If something major happened repaint the whole window.
00588       {
00589         PAINTSTRUCT ps;
00590
00591         if(BeginPaint(m_hWnd, &ps))
00592         {
00593           m_pGuiPaper->PaintWin();
00594           EndPaint(m_hWnd, &ps);
00595         }
00596       }
00597       break;
00598
00599     case WM_LBUTTONDOWN:
00600       // Start sequence of ink drawing to the paper.
00601       if (m_pGuiPaper->Master())
00602         m_pGuiPaper->InkStart(LOWORD(lParam), HIWORD(lParam));
00603       break;
00604
00605     case WM_MOUSEMOVE:
00606       // Draw inking sequence data.
00607       if (m_pGuiPaper->Master())
00608         m_pGuiPaper->InkDraw(LOWORD(lParam), HIWORD(lParam));
00609       break;
00610
00611     case WM_LBUTTONUP:
00612       // Stop an ink drawing sequence.
00613       if (m_pGuiPaper->Master())
00614         m_pGuiPaper->InkStop(LOWORD(lParam), HIWORD(lParam));
00615       break;
00616
00617     case WM_COMMAND:
00618       // Dispatch and handle any Menu command messages received.
00619       lResult = DoMenu(wParam, lParam);
00620       break;
00621
00622     case WM_CHAR:
00623       if (wParam == 0x1b)
00624       {
00625         // Exit this app if user hits ESC key.
00626         ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00627       }
00628       break;
00629
00630     case WM_CLOSE:
00631       // The user selected Close on the main window's System menu
00632       // or Exit on the File menu.
00633       // If there is ink data that has not been saved then ask user
00634       // if it should be saved. If user cancels then cancel the exit.
00635       if (IDCANCEL == m_pGuiPaper->AskSave())
00636         break;
00637     case WM_QUIT:
00638       // If the app is being quit then close any associated help windows.
00639     default:
00640       // Defer all messages NOT handled above to the Default Window Proc.
00641       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00642       break;
00643   }
00644
00645   return(lResult);
00646 }
00647
00648
00649 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00650   Function: UnicodeOk
00651
00652   Summary:  Checks if the platform will handle unicode versions of
00653             Win32 string API calls.
00654
00655   Args:     void
00656
00657   Returns:  BOOL
00658               TRUE if unicode support; FALSE if not.
00659 ------------------------------------------------------------------------F-F*/
00660 BOOL UnicodeOk(void)
00661 {
00662   BOOL bOk = TRUE;
00663   TCHAR szUserName[MAX_STRING_LENGTH];
00664   DWORD dwSize = MAX_STRING_LENGTH;
00665
00666   if (!GetUserName(szUserName, &dwSize))
00667     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00668
00669   return bOk;
00670 }
00671
00672
00673 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00674   Function: InitApplication
00675
00676   Summary:  Initializes the application and registers its main window
00677             class. InitApplication is called only once (in WinMain).
00678
00679   Args:     HINSTANCE hInstance)
00680               Handle to the first instance of the application.
00681
00682   Returns:  BOOL.
00683               TRUE if success.
00684               FALSE if fail.
00685 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00686 BOOL InitApplication(
00687        HINSTANCE hInstance)
00688 {
00689   BOOL bOk;
00690   // The window class for all instances of the main frame window.
00691   WNDCLASSEX wcf;
00692
00693   // Assign the appropriate values for this main frame window class.
00694   wcf.cbSize        = sizeof(WNDCLASSEX);
00695   wcf.cbClsExtra    = 0;            // No per-class extra data.
00696   wcf.cbWndExtra    = 0;            // No per-window extra data.
00697   wcf.hInstance     = hInstance;    // Application module instance.
00698   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00699                                     // APPUTIL for all CVirWindows).
00700   wcf.hCursor       = NULL;                        // Load app cursor.
00701   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00702                                 hInstance,
00703                                 TEXT("AppIcon"));
00704   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00705                                 hInstance,
00706                                 TEXT("AppIcon"),
00707                                 IMAGE_ICON,
00708                                 16, 16,
00709                                 0);
00710   wcf.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // Backgnd color.
00711   wcf.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Class style(s).
00712   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR);   // Class name.
00713   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR);   // Menu name.
00714
00715   // Register the window class and return FALSE if unsuccesful.
00716   bOk = RegisterClassEx(&wcf);
00717
00718   // Zero the g_ServerInfo structure.
00719   memset(&g_ServerInfo, 0, sizeof(COSERVERINFO));
00720
00721   // Init the remote machine name.
00722   g_wszMachineName[0] = 0;
00723 #ifdef UNICODE
00724   g_ServerInfo.pwszName = &g_szMachineName[0];
00725 #else
00726   g_ServerInfo.pwszName = &g_wszMachineName[0];
00727 #endif
00728
00729   return (bOk);
00730 }
00731
00732
00733 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00734   Function: WinMain
00735
00736   Summary:  The Windows main entry point function for this application.
00737             Initializes the application, the COM Libraries, and starts
00738             the main application message loop.
00739
00740   Args:     HINSTANCE hInstance,
00741               Instance handle; a new one for each invocation of this app.
00742             HINSTANCE hPrevInstance,
00743               Instance handle of the previous instance. NULL in Win32.
00744             LPSTR pszCmdLine,
00745               Windows passes a pointer to the application's
00746               invocation command line.
00747             int nCmdShow)
00748               Bits telling the show state of the application.
00749
00750   Returns:  int
00751               msg.wParam (upon exit of message loop).
00752               FALSE if this instance couldn't initialize and run.
00753 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00754 extern "C" int PASCAL WinMain(
00755                         HINSTANCE hInstance,
00756                         HINSTANCE hPrevInstance,
00757                         LPSTR pszCmdLine,
00758                         int nCmdShow)
00759 {
00760   CMainWindow* pWin = NULL;
00761   MSG msg;
00762   HACCEL hAccel;
00763   HRESULT hr;
00764   int iRun = FALSE;
00765
00766   // If we were compiled for UNICODE and the platform seems OK with this
00767   // then proceed.  Else we error and exit the app.
00768   if (UnicodeOk())
00769   {
00770     // Call to initialize the COM Library.  Use the SUCCEEDED macro
00771     // to detect success.  If fail then exit app with error message.
00772     // Tell COM that this client process will use the Single Threaded
00773     // Apartment model.
00774     if (SUCCEEDED(CoInitialize(NULL)))
00775     {
00776       // Ensure that DCOM (Distributed COM) is installed.
00777       if (DComOk())
00778       {
00779         // Initialize for Client process security. Allow COPaper to
00780         // call back into the client (ie, the client can impersonate
00781         // the server identity).
00782         hr = CoInitializeSecurity(
00783                NULL,                        //Points to security descriptor
00784                -1,                          //Count of entries in asAuthSvc
00785                NULL,                        //Array of names to register
00786                NULL,                        //Reserved for future use
00787                RPC_C_AUTHN_LEVEL_NONE,      //Default authentication level
00788                                             // for proxies
00789                RPC_C_IMP_LEVEL_IMPERSONATE, //Default impersonation level
00790                                             // for proxies
00791                NULL,                        //Reserved; must be set to NULL
00792                EOAC_NONE,                   //Additional client or
00793                                             // server-side capabilities
00794                NULL);                       //Reserved for future use
00795         if (SUCCEEDED(hr))
00796         {
00797           // If we succeeded in initializing the COM Library we proceed to
00798           // initialize the application.  If we can't init the application
00799           // then we signal shut down with an error message exit.
00800           iRun = InitApplication(hInstance);
00801           if (iRun)
00802           {
00803             // Assume we'll set iRun to TRUE when initialization is done.
00804             iRun = FALSE;
00805             // We are still go for running so we try to create a nifty new
00806             // CMainWindow object for this app instance.
00807             pWin = new CMainWindow;
00808             if (NULL != pWin)
00809             {
00810               // Now we initialize an instance of the new CMainWindow.
00811               // This includes creating the main window.
00812               if (pWin->InitInstance(hInstance, pszCmdLine, nCmdShow))
00813               {
00814                 // Load the keyboard accelerators from the resources.
00815                 hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
00816                 if (NULL != hAccel)
00817                 {
00818                   // Signal App Initialization is successfully done.
00819                   iRun = TRUE;
00820                 }
00821               }
00822             }
00823           }
00824         }
00825
00826         if (iRun)
00827         {
00828           // If we initialized the app instance properly then we are still
00829           // go for running.  We then start up the main message pump for
00830           // the application.
00831           while (GetMessage(&msg, NULL, 0, 0))
00832           {
00833             if (!TranslateAccelerator(pWin->GetHwnd(), hAccel, &msg))
00834             {
00835               TranslateMessage(&msg);
00836               DispatchMessage(&msg);
00837             }
00838           }
00839
00840           // We also ask COM to unload any unused COM Servers, including our
00841           // friend, DCDSERVE.
00842           CoFreeUnusedLibraries();
00843
00844           // We'll pass to Windows the reason why we exited the message loop.
00845           iRun = (int) msg.wParam;
00846         }
00847         else
00848         {
00849           // We failed to initialize the application. Put up error message
00850           // box saying that application couldn't be initialized.  Parent
00851           // window is desktop (ie, NULL). Exit the failed application
00852           // (ie, by returning FALSE to WinMain).
00853           ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
00854
00855           // Delete the CMainWindow object.
00856           DELETE_POINTER(pWin);
00857         }
00858
00859         // We're exiting this app (either normally or by init failure) so
00860         // shut down the COM Library.
00861         CoUninitialize();
00862       }
00863       else
00864       {
00865         // If DCOM isn't installed then indicate an error
00866         // and exit the app immediately.
00867         ErrorBox(hInstance, NULL, IDS_NODCOM);
00868       }
00869     }
00870     else
00871     {
00872       // We failed to Initialize the COM Library. Put up error message
00873       // box saying that COM Library couldn't be initialized.  Parent
00874       // window is desktop (ie, NULL). Exit the failed application
00875       // (ie, by returning FALSE to WinMain).
00876       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
00877     }
00878   }
00879   else
00880   {
00881     // If we were compiled for UNICODE but the platform has problems with
00882     // this then indicate an error and exit the app immediately.
00883     CHAR szMsg[MAX_STRING_LENGTH];
00884
00885     if (LoadStringA(
00886           hInstance,
00887           IDS_NOUNICODE,
00888           szMsg,
00889           MAX_STRING_LENGTH))
00890     {
00891       MessageBoxA(
00892         NULL,
00893         szMsg,
00894         ERROR_TITLE_STR,
00895         MB_OK | MB_ICONEXCLAMATION);
00896     }
00897   }
00898
00899   return iRun;
00900 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/Cap/StrConv.h Source File

  • Web
  • MSAgent
  • c
  • Cap

StrConv.h

Go to the documentation of this file.
00001 #ifndef _StrConv_h_
00002 #define _StrConv_h_
00003
00004
00005 LPWSTR WINAPI A2WHelper(LPWSTR pwsz, LPCSTR psz, UINT cch) {
00006
00007   _ASSERTE(psz);
00008   _ASSERTE(pwsz);
00009
00010   pwsz[0] = '\0';
00011
00012   MultiByteToWideChar(CP_ACP, 0, psz, -1, pwsz, cch);
00013
00014   return pwsz;
00015 }
00016
00017
00018 LPSTR WINAPI W2AHelper(LPSTR psz, LPCWSTR pwsz, UINT cch) {
00019
00020   _ASSERTE(psz);
00021   _ASSERTE(pwsz);
00022
00023   psz[0] = '\0';
00024
00025   WideCharToMultiByte(CP_ACP, 0, pwsz, -1, psz, cch, NULL, NULL);
00026
00027   return psz;
00028 }
00029
00030
00031 #ifndef _DEBUG
00032 #define USES_CONVERSION int _convert; _convert
00033 #else
00034 #define USES_CONVERSION int _convert = 0
00035 #endif
00036
00037
00038 #ifndef A2WHELPER
00039 #define A2WHELPER A2WHelper
00040 #define W2AHELPER W2AHelper
00041 #endif
00042
00043
00044 #define A2W(psz) (\
00045   ((LPCSTR)psz == NULL) ? NULL : (\
00046     _convert = (lstrlenA(psz)+1),\
00047     A2WHELPER((LPWSTR)alloca(_convert*2), psz, _convert)))
00048
00049 #define W2A(pwsz) (\
00050   ((LPCWSTR)pwsz == NULL) ? NULL : (\
00051     _convert = (lstrlenW(pwsz)+1)*2,\
00052     W2AHELPER((LPSTR)alloca(_convert), pwsz, _convert)))
00053
00054
00055 #define A2CW(psz)   ((LPCWSTR)A2W(psz))
00056 #define W2CA(pwsz)    ((LPCSTR)W2A(pwsz))
00057
00058
00059 #ifdef _UNICODE
00060   #define T2A W2A
00061   #define A2T A2W
00062   inline LPWSTR T2W(LPTSTR lp) { return lp; }
00063   inline LPTSTR W2T(LPWSTR lp) { return lp; }
00064   #define T2CA W2CA
00065   #define A2CT A2CW
00066   inline LPCWSTR T2CW(LPCTSTR lp) { return lp; }
00067   inline LPCTSTR W2CT(LPCWSTR lp) { return lp; }
00068 #else
00069   #define T2W A2W
00070   #define W2T W2A
00071   inline LPSTR T2A(LPTSTR lp) { return lp; }
00072   inline LPTSTR A2T(LPSTR lp) { return lp; }
00073   #define T2CW A2CW
00074   #define W2CT W2CA
00075   inline LPCSTR T2CA(LPCTSTR lp) { return lp; }
00076   inline LPCTSTR A2CT(LPCSTR lp) { return lp; }
00077 #endif
00078
00079
00080 #endif
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CHourglass Member List

This is the complete list of members for CHourglass, including all inherited members.
CHourglass(void) | CHourglass | [inline]
CHourglass(HWND hWnd) | CHourglass | [inline]
m_hCur | CHourglass | [protected]
m_hWndCapture | CHourglass | [protected]
~CHourglass(void) | CHourglass | [inline]
Generated on Wed Nov 13 2024 16:56:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/RealTimeStylusPlugin/C#/RealTimeStylusPluginApp.cs Source File

  • TabletPC
  • RealTimeStylusPlugin
  • C#

RealTimeStylusPluginApp.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2004 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: RealTimeStylusPlugin.cs
00013 //  Real time stylus plugin sample.
00014 //
00015 //  This sample application demonstrates several different types of
00016 //  Real time stylus plugins:
00017 //
00018 // -PacketFilterPlugin: demonstrates packet modification by
00019 //  constraining all x,y packet data within a rectangular area.
00020 // -CustomDynamicRendererPlugin:  demonstrates custom dynamic
00021 //  rendering by drawing a small circle around each x,y.
00022 // -GestureRecognizer:  plugin provided by the Microsoft Tablet PC
00023 //  API, which recognizes application gestures.
00024 // -DynamicRenderer:  plugin provided by the Microsoft Tablet PC
00025 //  API, which renders packet data as it is collected.
00026 //
00027 //  In addition, this sample provides a user interface that
00028 //  enables the user to add/remove and change the order of each
00029 //  plugin in the notification chain.
00030 //
00031 //
00032 //  The features used are: RealTimeStylus, GestureRecognizer,
00033 //  DynamicRenderer, IStylusAsyncPlugin, and IStylusSyncPlugin.
00034 //
00035 //--------------------------------------------------------------------------
00036
00037 using System;
00038 using System.Diagnostics;
00039 using System.Drawing;
00040 using System.Windows.Forms;
00041
00042 // The Microsoft Tablet PC namespaces
00043 using Microsoft.StylusInput;
00044 using Microsoft.StylusInput.PluginData;
00045 using Microsoft.Ink;
00046
00047 // Contains the custom real time stylus plugins used by this
00048 // sample application
00049 using RealTimeStylusPlugins;
00050
00051 namespace RealTimeStylusPluginApp
00052 {
00053
00054     /// <summary>
00055     /// Helper used to store information about a given plugin.
00056     /// </summary>
00057     public struct PluginListItem
00058     {
00059         /// <summary>
00060         /// The real time stylus plugin associated with this class.
00061         /// </summary>
00062         public IStylusSyncPlugin Plugin;
00063
00064         /// <summary>
00065         /// A string containing the description of the plugin.
00066         /// </summary>
00067         public String Description;
00068
00069         /// <summary>
00070         /// Public constructor
00071         /// </summary>
00072         /// <param name="Plugin">The plugin</param>
00073         /// <param name="description">Description of the plugin</param>
00074         public PluginListItem(IStylusSyncPlugin stylusPlugin, String pluginDescription)
00075         {
00076             Plugin = stylusPlugin;
00077             Description = pluginDescription;
00078         }
00079
00080         /// <summary>
00081         /// The description of this plugin
00082         /// </summary>
00083         /// <returns>String that describes this plugin</returns>
00084         override public String ToString()
00085         {
00086             return Description;
00087         }
00088     }
00089
00090     /// <summary>
00091     /// The RealTimeStylusPlugin Sample Application form class.
00092     /// </summary>
00093     public class RealTimeStylusPluginApp : System.Windows.Forms.Form, IStylusAsyncPlugin
00094     {
00095
00096         // Declare the real time stylus.
00097         private RealTimeStylus myRealTimeStylus;
00098
00099         // Declare the graphics object passed to the custom dynamic
00100         // renderer
00101         private Graphics customDynamicRendererGraphics;
00102
00103         #region Standard Template Code
00104         private System.Windows.Forms.GroupBox gbTestArea;
00105         private System.Windows.Forms.Button btnMoveUp;
00106         private System.Windows.Forms.Button btnMoveDown;
00107         private System.Windows.Forms.CheckedListBox chklbPlugins;
00108         private System.Windows.Forms.StatusBar sbGesture;
00109         private System.Windows.Forms.MenuItem miAction;
00110         private System.Windows.Forms.MenuItem miClear;
00111         private System.Windows.Forms.MenuItem miExit;
00112         private System.Windows.Forms.TextBox txtPluginDescription;
00113         private System.Windows.Forms.Label lblPluginList;
00114         private System.Windows.Forms.MainMenu miMain;
00115         private System.Windows.Forms.MenuItem miSeparator;
00116         private System.Windows.Forms.Panel pnlPlugins;
00117
00118
00119
00120         /// <summary>
00121         /// Required designer variable.
00122         /// </summary>
00123         private System.ComponentModel.Container components = null;
00124         #endregion
00125
00126         public RealTimeStylusPluginApp()
00127         {
00128             #region Standard Template Code
00129             //
00130             // Required for Windows Form Designer support
00131             //
00132             InitializeComponent();
00133             #endregion
00134         }
00135
00136         #region Standard Template Code
00137         /// <summary>
00138         /// Clean up any resources being used.
00139         /// </summary>
00140         protected override void Dispose( bool disposing )
00141         {
00142             if( disposing )
00143             {
00144                 if (components != null)
00145                 {
00146                     components.Dispose();
00147                 }
00148             }
00149             base.Dispose( disposing );
00150
00151             // Dispose the graphics objects associated with the
00152             // custom dynamic renderer.
00153             customDynamicRendererGraphics.Dispose();
00154         }
00155         #endregion
00156
00157         #region Windows Form Designer generated code
00158         /// <summary>
00159         /// Required method for Designer support - do not modify
00160         /// the contents of this method with the code editor.
00161         /// </summary>
00162         private void InitializeComponent()
00163         {
00164             this.gbTestArea = new System.Windows.Forms.GroupBox();
00165             this.chklbPlugins = new System.Windows.Forms.CheckedListBox();
00166             this.btnMoveUp = new System.Windows.Forms.Button();
00167             this.btnMoveDown = new System.Windows.Forms.Button();
00168             this.txtPluginDescription = new System.Windows.Forms.TextBox();
00169             this.lblPluginList = new System.Windows.Forms.Label();
00170             this.sbGesture = new System.Windows.Forms.StatusBar();
00171             this.miMain = new System.Windows.Forms.MainMenu();
00172             this.miAction = new System.Windows.Forms.MenuItem();
00173             this.miClear = new System.Windows.Forms.MenuItem();
00174             this.miSeparator = new System.Windows.Forms.MenuItem();
00175             this.miExit = new System.Windows.Forms.MenuItem();
00176             this.pnlPlugins = new System.Windows.Forms.Panel();
00177             this.pnlPlugins.SuspendLayout();
00178             this.SuspendLayout();
00179             //
00180             // gbTestArea
00181             //
00182             this.gbTestArea.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
00183                 | System.Windows.Forms.AnchorStyles.Left)
00184                 | System.Windows.Forms.AnchorStyles.Right);
00185             this.gbTestArea.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00186             this.gbTestArea.Location = new System.Drawing.Point(8, 8);
00187             this.gbTestArea.Name = "gbTestArea";
00188             this.gbTestArea.Size = new System.Drawing.Size(369, 341);
00189             this.gbTestArea.TabIndex = 0;
00190             this.gbTestArea.TabStop = false;
00191             this.gbTestArea.Text = "Test Area";
00192             //
00193             // chklbPlugins
00194             //
00195             this.chklbPlugins.CheckOnClick = true;
00196             this.chklbPlugins.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
00197                 | System.Windows.Forms.AnchorStyles.Left)
00198                 | System.Windows.Forms.AnchorStyles.Right);
00199             this.chklbPlugins.Location = new System.Drawing.Point(11, 111);
00200             this.chklbPlugins.Name = "chklbPlugins";
00201             this.chklbPlugins.Size = new System.Drawing.Size(205, 174);
00202             this.chklbPlugins.TabIndex = 6;
00203             this.chklbPlugins.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.chklbPlugins_ItemCheck);
00204             this.chklbPlugins.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chklbPlugins_MouseDown);
00205             //
00206             // btnMoveUp
00207             //
00208             this.btnMoveUp.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
00209             this.btnMoveUp.Location = new System.Drawing.Point(11, 306);
00210             this.btnMoveUp.Name = "btnMoveUp";
00211             this.btnMoveUp.Size = new System.Drawing.Size(93, 29);
00212             this.btnMoveUp.TabIndex = 7;
00213             this.btnMoveUp.Text = "Move Up";
00214             this.btnMoveUp.Click += new System.EventHandler(this.btnMove_Click);
00215             //
00216             // btnMoveDown
00217             //
00218             this.btnMoveDown.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
00219             this.btnMoveDown.Location = new System.Drawing.Point(124, 306);
00220             this.btnMoveDown.Name = "btnMoveDown";
00221             this.btnMoveDown.Size = new System.Drawing.Size(92, 29);
00222             this.btnMoveDown.TabIndex = 8;
00223             this.btnMoveDown.Text = "Move Down";
00224             this.btnMoveDown.Click += new System.EventHandler(this.btnMove_Click);
00225             //
00226             // txtPluginDescription
00227             //
00228             this.txtPluginDescription.BorderStyle = System.Windows.Forms.BorderStyle.None;
00229             this.txtPluginDescription.Location = new System.Drawing.Point(11, 23);
00230             this.txtPluginDescription.Multiline = true;
00231             this.txtPluginDescription.Name = "txtPluginDescription";
00232             this.txtPluginDescription.ReadOnly = true;
00233             this.txtPluginDescription.Size = new System.Drawing.Size(205, 88);
00234             this.txtPluginDescription.TabIndex = 9;
00235             this.txtPluginDescription.Text = "Packets are processed by the plugins in the order shown in the list.  Also, t" +
00236                 "he plugins can be turned off by unchecking/checking the items.";
00237             //
00238             // lblPluginList
00239             //
00240             this.lblPluginList.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00241             this.lblPluginList.Location = new System.Drawing.Point(1, 3);
00242             this.lblPluginList.Name = "lblPluginList";
00243             this.lblPluginList.Size = new System.Drawing.Size(174, 20);
00244             this.lblPluginList.TabIndex = 10;
00245             this.lblPluginList.Text = "Plugin List";
00246             //
00247             // sbGesture
00248             //
00249             this.sbGesture.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
00250                 | System.Windows.Forms.AnchorStyles.Right);
00251             this.sbGesture.Dock = System.Windows.Forms.DockStyle.None;
00252             this.sbGesture.Location = new System.Drawing.Point(0, 350);
00253             this.sbGesture.Name = "sbGesture";
00254             this.sbGesture.Size = new System.Drawing.Size(614, 27);
00255             this.sbGesture.SizingGrip = false;
00256             this.sbGesture.TabIndex = 6;
00257             //
00258             // miMain
00259             //
00260             this.miMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00261                                                                                    this.miAction});
00262             //
00263             // miAction
00264             //
00265             this.miAction.Index = 0;
00266             this.miAction.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00267                                                                                      this.miClear,
00268                                                                                      this.miSeparator,
00269                                                                                      this.miExit});
00270             this.miAction.Text = "&Action";
00271             //
00272             // miClear
00273             //
00274             this.miClear.Index = 0;
00275             this.miClear.Text = "&Clear";
00276             this.miClear.Click += new System.EventHandler(this.miClear_Click);
00277             //
00278             // miSeparator
00279             //
00280             this.miSeparator.Index = 1;
00281             this.miSeparator.Text = "-";
00282             //
00283             // miExit
00284             //
00285             this.miExit.Index = 2;
00286             this.miExit.Text = "&Exit";
00287             this.miExit.Click += new System.EventHandler(this.miExit_Click);
00288             //
00289             // pnlPlugins
00290             //
00291             this.pnlPlugins.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
00292                 | System.Windows.Forms.AnchorStyles.Right);
00293             this.pnlPlugins.BackColor = System.Drawing.SystemColors.Control;
00294             this.pnlPlugins.Controls.AddRange(new System.Windows.Forms.Control[] {
00295                                                                                      this.lblPluginList,
00296                                                                                      this.txtPluginDescription,
00297                                                                                      this.btnMoveDown,
00298                                                                                      this.btnMoveUp,
00299                                                                                      this.chklbPlugins});
00300             this.pnlPlugins.Location = new System.Drawing.Point(392, 8);
00301             this.pnlPlugins.Name = "pnlPlugins";
00302             this.pnlPlugins.Size = new System.Drawing.Size(216, 346);
00303             this.pnlPlugins.TabIndex = 7;
00304             //
00305             // RealTimeStylusPluginApp
00306             //
00307             this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
00308             this.ClientSize = new System.Drawing.Size(614, 377);
00309             this.Controls.AddRange(new System.Windows.Forms.Control[] {
00310                                                                           this.pnlPlugins,
00311                                                                           this.gbTestArea,
00312                                                                           this.sbGesture});
00313             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
00314             this.MaximizeBox = false;
00315             this.Menu = this.miMain;
00316             this.MinimumSize = new System.Drawing.Size(440, 340);
00317             this.Name = "RealTimeStylusPluginApp";
00318             this.Text = "Real Time Stylus Plugin Sample Application";
00319             this.Load += new System.EventHandler(this.RealTimeStylusPlugin_Load);
00320             this.pnlPlugins.ResumeLayout(false);
00321             this.ResumeLayout(false);
00322
00323         }
00324         #endregion
00325
00326         #region Standard Template Code
00327         /// <summary>
00328         /// The main entry point for the application.
00329         /// </summary>
00330         [STAThread]
00331         static void Main()
00332         {
00333             Application.Run(new RealTimeStylusPluginApp());
00334         }
00335         #endregion
00336
00337         /// <summary>
00338         /// Event Handler from Form Load Event
00339         /// Setup the real time stylus for collection.
00340         /// </summary>
00341         /// <param name="sender">The control that raised the event.</param>
00342         /// <param name="e">The event arguments.</param>
00343         private void RealTimeStylusPlugin_Load(object sender, System.EventArgs e)
00344         {
00345
00346             // Create the real time stylus used to receive stylus notifications
00347             myRealTimeStylus = new RealTimeStylus(gbTestArea, true);
00348
00349             // Store the Graphics object associated with the drawing area.
00350             customDynamicRendererGraphics = gbTestArea.CreateGraphics();
00351
00352             // Create the plugins.  Note that since these are
00353             // synchronous plugins, notification will occur on the
00354             // pen thread.
00355             //
00356             // -PacketFilterPlugin: demonstrates packet modification by
00357             //  constraining all x,y packet data within a rectangular area.
00358             // -CustomDynamicRendererPlugin:  demonstrates custom dynamic
00359             //  rendering by drawing a small circle around each x,y.
00360             // -GestureRecognizer:  plugin provided by the Tablet PC Platform
00361             //  API, which recognizes application gestures.
00362             // -DynamicRenderer:  plugin provided by Tablet PC Platform API,
00363             // which renders packet data as it is collected.
00364
00365             // Create the PacketFilterPlugin
00366             // Note that this custom plugin takes a rectangle in
00367             // ink space coordinates (.01mm = 1 ink space unit), which
00368             // specifies the filter region.  This sample uses a rectangle
00369             // that is centered over the drawing area.
00370             float right  = ((float)gbTestArea.Width*2540.0F)/(float)customDynamicRendererGraphics.DpiX;
00371             float bottom = ((float)gbTestArea.Height*2540.0F)/(float)customDynamicRendererGraphics.DpiY;
00372             Rectangle filterRect = new Rectangle((int)Math.Round(.15F*right),
00373                                                  (int)Math.Round(.15F*bottom),
00374                                                  (int)Math.Round(.7F*right),
00375                                                  (int)Math.Round(.7F*bottom));
00376             IStylusSyncPlugin filterPlugin = new PacketFilterPlugin(filterRect);
00377             chklbPlugins.Items.Add(new PluginListItem(filterPlugin,"PacketFilter"));
00378
00379             // Create the CustomDynamicRendererPlugin
00380             IStylusSyncPlugin rendererPlugin = new CustomDynamicRendererPlugin(customDynamicRendererGraphics);
00381             chklbPlugins.Items.Add(new PluginListItem(rendererPlugin,"CustomDynamicRenderer"));
00382
00383             // Attempt to create the GestureRecognizer plugin.
00384             // An exception will occur if no recognizers are available.
00385             // In this case, the sample proceeds, but does not add the
00386             // gesture recognizer into the list of available plugins.
00387             GestureRecognizer gr = null;
00388             try
00389             {
00390                 gr = new GestureRecognizer();
00391                 ApplicationGesture [] gestures = { ApplicationGesture.AllGestures };
00392                 gr.EnableGestures(gestures);
00393                 chklbPlugins.Items.Add(new PluginListItem(gr,"GestureRecognizer"));
00394             }
00395             catch
00396             {
00397             }
00398
00399             // Create the dynamic renderer used to render the stroke that is
00400             //  currently being collected
00401             DynamicRenderer dr = new DynamicRenderer(gbTestArea);
00402             chklbPlugins.Items.Add(new PluginListItem(dr,"DynamicRenderer"));
00403
00404             // Enable all plugins
00405             for(int i = 0; i < chklbPlugins.Items.Count; i++)
00406             {
00407                 chklbPlugins.SetItemChecked(i,true);
00408             }
00409
00410             // Add this form to the collection of asynchronous plugins.
00411             // The CustomStylusDataAdded notification will be used to
00412             // update the form's UI when an application gesture occurs.
00413             // Since this is an asynchronous plugin, notification will
00414             // occur on the UI thread.
00415             myRealTimeStylus.AsyncPluginCollection.Add(this);
00416
00417             // Enable the RealTimeStylus, GestureRecognizer, and DynamicRenderer
00418             myRealTimeStylus.Enabled = true;
00419             if (gr != null)
00420             {
00421                 gr.Enabled = true;
00422             }
00423             dr.Enabled = true;
00424         }
00425
00426         /// <summary>
00427         /// Private field used to track the last MouseDown event information
00428         /// for use in the chklbPlugins_ItemCheck handler.
00429         /// </summary>
00430         private MouseEventArgs lastMouseDownEventArgs = null;
00431
00432         /// <summary>
00433         /// Event Handler for the checked list box MouseDown Event.
00434         /// Cache the MouseEventArgs for use in the chklbPlugins_ItemCheck handler.
00435         /// </summary>
00436         /// <param name="sender">The control that raised the event.</param>
00437         /// <param name="e">The event arguments.</param>
00438         private void chklbPlugins_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
00439         {
00440             lastMouseDownEventArgs = e;
00441         }
00442
00443         /// <summary>
00444         /// Event Handler from the checked list box ItemCheck Event.
00445         /// Enabled/disable the real time stylus plugin corresponding
00446         /// to the item being checked/unchecked.
00447         /// </summary>
00448         /// <param name="sender">The control that raised the event.</param>
00449         /// <param name="e">The event arguments.</param>
00450         private void chklbPlugins_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
00451         {
00452             // The CheckedListBox CheckOnClick property allows the user
00453             // to toggle the checkbox without first selecting the list item,
00454             // but since the list also allows the user to rearrange the
00455             // items, we only want CheckOnClick to proceed if the user clicks
00456             // on the checkbox itself.
00457             if (lastMouseDownEventArgs != null)
00458             {
00459                 // If we previously cached MouseDownEventArgs, check the MouseDown location.
00460                 bool abortItemCheck = (lastMouseDownEventArgs.X > chklbPlugins.GetItemHeight(e.Index));
00461
00462                 // Reset the cache
00463                 lastMouseDownEventArgs = null;
00464
00465                 // If the MouseDown location is outside the checkbox area, abort.
00466                 if (abortItemCheck)
00467                 {
00468                     e.NewValue = e.CurrentValue;
00469                     return;
00470                 }
00471             }
00472
00473             // Enable/disable the plugin according to its new
00474             // checked value.  A plugin is enabled by inserting
00475             // it into the real time stylus notification chain and it is
00476             // disabled by removing it from the plugin collection.  The dynamic
00477             // renderer is handled specially by setting its enabled
00478             // property.
00479             if(e.Index < chklbPlugins.Items.Count)
00480             {
00481                 if (e.NewValue == CheckState.Checked)
00482                 {
00483                     InsertIntoPluginCollection(e.Index);
00484                 }
00485                 else if (e.NewValue == CheckState.Unchecked)
00486                 {
00487                     RemoveFromPluginCollection(e.Index);
00488                 }
00489             }
00490
00491             // Clear the form
00492             Clear();
00493         }
00494
00495         /// <summary>
00496         /// Event Handler from the Clear Menu Item.
00497         /// Clears the screen.
00498         /// </summary>
00499         /// <param name="sender">The control that raised the event.</param>
00500         /// <param name="e">The event arguments.</param>
00501         private void miClear_Click(object sender, System.EventArgs e)
00502         {
00503             Clear();
00504         }
00505
00506         /// <summary>
00507         /// Event Handler from the Exit Menu Item.
00508         /// Exits the application.
00509         /// </summary>
00510         /// <param name="sender">The control that raised the event.</param>
00511         /// <param name="e">The event arguments.</param>
00512         private void miExit_Click(object sender, System.EventArgs e)
00513         {
00514             Application.Exit();
00515         }
00516
00517         /// <summary>
00518         /// Event Handler from MoveUp and MoveDown Button Click.
00519         /// </summary>
00520         /// <param name="sender"></param>
00521         /// <param name="e"></param>
00522         private void btnMove_Click(object sender, System.EventArgs e)
00523         {
00524             // Declare the current and destination indices of the
00525             // real time stylus plugin being moved.
00526             int currentIndex = chklbPlugins.SelectedIndex;
00527             int destinationIndex = -1;
00528
00529             if ((0 <= currentIndex) && (currentIndex <= chklbPlugins.Items.Count))
00530             {
00531
00532                 // Calculate the destination based on whether move up
00533                 // or down was pressed.
00534                 if (sender == btnMoveUp)
00535                 {
00536                     destinationIndex = currentIndex - 1;
00537                 }
00538                 else
00539                 {
00540                     destinationIndex = currentIndex + 1;
00541                 }
00542
00543                 // The destination index of the plugin being moved must fall
00544                 // within the bounds of the plugin list.
00545                 if ((0 <= destinationIndex) && (destinationIndex < chklbPlugins.Items.Count))
00546                 {
00547                     CheckState checkState = chklbPlugins.GetItemCheckState(currentIndex);
00548
00549                     // If the plugin being moved is currently enabled,
00550                     // remove it from the plugin collection.
00551                     if (CheckState.Checked == checkState)
00552                     {
00553                         RemoveFromPluginCollection(currentIndex);
00554                     }
00555
00556                     // Update the checked list box to reflect the move.
00557                     object item = chklbPlugins.Items[currentIndex];
00558                     chklbPlugins.Items.RemoveAt(currentIndex);
00559                     chklbPlugins.Items.Insert(destinationIndex,item);
00560
00561                     // Restore the selected and checked state of the list item.
00562                     chklbPlugins.SetSelected(destinationIndex, true);
00563                     chklbPlugins.SetItemCheckState(destinationIndex, checkState);
00564                 }
00565             }
00566         }
00567
00568         /// <summary>
00569         /// Helper method to clear the form.
00570         /// </summary>
00571         private void Clear()
00572         {
00573             sbGesture.Text = String.Empty;
00574             this.Refresh();
00575         }
00576
00577         /// <summary>
00578         /// Helper method to find the index where the specified
00579         /// plugin should be inserted.
00580         /// </summary>
00581         /// <param name="index">The index of the plugin.</param>
00582         /// <returns>The index to insert the specified plugin.</returns>
00583         private int FindPrecedingPlugin(int index)
00584         {
00585             int insertAtIndex = 0;
00586
00587             // For each real time stylus plugin preceding
00588             // the specified index, check whether it is currently
00589             // enabled.  If so, update the insert at index.
00590             for (int i = 0; i < index; i++)
00591             {
00592                 if (chklbPlugins.GetItemChecked(i))
00593                 {
00594                     insertAtIndex++;
00595                 }
00596             }
00597
00598             // Return the preceding plugin or null if none found.
00599             return insertAtIndex;
00600         }
00601
00602         /// <summary>
00603         /// Helper method to insert the real time stylus plugin
00604         /// at the specified index into the plugin collection.
00605         /// </summary>
00606         /// <param name="index">The index of the plugin to insert.</param>
00607         private void InsertIntoPluginCollection(int index)
00608         {
00609             // Obtain the index where the plugin should be inserted
00610             int insertAtIndex = FindPrecedingPlugin(index);
00611             IStylusSyncPlugin plugin = ((PluginListItem)chklbPlugins.Items[index]).Plugin;
00612
00613             bool rtsEnabled = myRealTimeStylus.Enabled;
00614             myRealTimeStylus.Enabled = false;
00615             myRealTimeStylus.SyncPluginCollection.Insert(insertAtIndex,plugin);
00616             myRealTimeStylus.Enabled = rtsEnabled;
00617
00618         }
00619
00620         /// <summary>
00621         /// Helper method to remove the real time stylus plugin
00622         /// at the specified index from the plugin collection.
00623         /// </summary>
00624         /// <param name="index">The index of the plugin to remove.</param>
00625         private void RemoveFromPluginCollection(int index)
00626         {
00627             IStylusSyncPlugin plugin = ((PluginListItem)chklbPlugins.Items[index]).Plugin;
00628
00629             bool rtsEnabled = myRealTimeStylus.Enabled;
00630             myRealTimeStylus.Enabled = false;
00631             myRealTimeStylus.SyncPluginCollection.Remove(plugin);
00632             myRealTimeStylus.Enabled = rtsEnabled;
00633         }
00634
00635         #region IStylusAsyncPlugin interface implementation
00636
00637         /// <summary>
00638         /// Informs the implementing object that user data is available.
00639         /// </summary>
00640         /// <param name="sender">The real time stylus associated with the notification</param>
00641         /// <param name="data">The notification data</param>
00642         public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data)
00643         {
00644             // We can identify the kind of custom data via either the Guid or Type.
00645             // For the purpose of this demonstration we will validate both just to be safe.
00646             // For other scenarios either approach is valid.
00647             if (data.CustomDataId == GestureRecognizer.GestureRecognitionDataGuid)
00648             {
00649                 GestureRecognitionData grd = data.Data as GestureRecognitionData;
00650                 if (grd != null)
00651                 {
00652                     if (grd.Count > 0)
00653                     {
00654                         GestureAlternate ga = grd[0];
00655                         sbGesture.Text = "Gesture=" + ga.Id + ", Confidence=" + ga.Confidence;
00656                     }
00657                 }
00658             }
00659         }
00660
00661         /// <summary>
00662         /// Called when the current plugin or the ones previous in the list
00663         /// threw an exception.
00664         /// </summary>
00665         /// <param name="sender">The real time stylus associated with the notification</param>
00666         /// <param name="data">The notification data</param>
00667   public void Error(RealTimeStylus sender, ErrorData data)
00668         {
00669             Debug.Assert(false, null, "An error occurred.  DataId=" + data.DataId + ", " + "Exception=" + data.InnerException);
00670         }
00671
00672         /// <summary>
00673         /// Defines the types of notifications the plugin is interested in.
00674         /// </summary>
00675         public DataInterestMask DataInterest
00676         {
00677             get
00678             {
00679                 return DataInterestMask.CustomStylusDataAdded | DataInterestMask.Error;
00680             }
00681         }
00682
00683         // The remaining interface methods are not used in this sample application.
00684         public void RealTimeStylusDisabled(RealTimeStylus sender, RealTimeStylusDisabledData data) {}
00685         public void RealTimeStylusEnabled(RealTimeStylus sender, RealTimeStylusEnabledData data){}
00686         public void StylusOutOfRange(RealTimeStylus sender, StylusOutOfRangeData data) {}
00687         public void StylusInRange(RealTimeStylus sender, StylusInRangeData data) {}
00688         public void StylusDown(RealTimeStylus sender, StylusDownData data) {}
00689         public void StylusUp(RealTimeStylus sender, StylusUpData data) {}
00690         public void StylusButtonDown(RealTimeStylus sender, StylusButtonDownData data) {}
00691         public void StylusButtonUp(RealTimeStylus sender, StylusButtonUpData data) {}
00692         public void SystemGesture(RealTimeStylus sender, SystemGestureData data){}
00693         public void Packets(RealTimeStylus sender,  PacketsData data) {}
00694         public void InAirPackets(RealTimeStylus sender, InAirPacketsData data){}
00695         public void TabletAdded(RealTimeStylus sender, TabletAddedData data){}
00696         public void TabletRemoved(RealTimeStylus sender, TabletRemovedData data) {}
00697         #endregion
00698
00699     }
00700 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/ClassProv/ClassFac.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • ClassProv

ClassFac.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  CLASSFAC.CPP
00006
00007 //
00008
00009 //  Module: WMI Class provider sample code
00010
00011 //
00012
00013 //  Purpose: Contains the class factory.  This creates objects when
00014
00015 //           connections are requested.
00016
00017 //
00018
00019 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00020 //
00021 //***************************************************************************
00022
00023 #include <objbase.h>
00024 #include "sample.h"
00025
00026 //***************************************************************************
00027 //
00028 // CProvFactory::CProvFactory
00029 // CProvFactory::~CProvFactory
00030 //
00031 // Constructor Parameters:
00032 //  None
00033 //***************************************************************************
00034
00035 CProvFactory::CProvFactory()
00036 {
00037     m_cRef=0L;
00038     return;
00039 }
00040
00041 CProvFactory::~CProvFactory(void)
00042 {
00043     return;
00044 }
00045
00046 //***************************************************************************
00047 //
00048 // CProvFactory::QueryInterface
00049 // CProvFactory::AddRef
00050 // CProvFactory::Release
00051 //
00052 // Purpose: Standard Ole routines needed for all interfaces
00053 //
00054 //***************************************************************************
00055
00056
00057 STDMETHODIMP CProvFactory::QueryInterface(REFIID riid
00058     , PPVOID ppv)
00059 {
00060     *ppv=NULL;
00061
00062     if (IID_IUnknown==riid || IID_IClassFactory==riid)
00063         *ppv=this;
00064
00065     if (NULL!=*ppv)
00066         {
00067         ((LPUNKNOWN)*ppv)->AddRef();
00068         return NOERROR;
00069         }
00070
00071     return E_NOINTERFACE;
00072 }
00073
00074 STDMETHODIMP_(ULONG) CProvFactory::AddRef(void)
00075 {
00076     return ++m_cRef;
00077 }
00078
00079 STDMETHODIMP_(ULONG) CProvFactory::Release(void)
00080 {
00081     ULONG nNewCount = InterlockedDecrement((long *)&m_cRef);
00082     if (0L == nNewCount)
00083         delete this;
00084
00085     return nNewCount;
00086 }
00087
00088 //***************************************************************************
00089 //
00090 // CProvFactory::CreateInstance
00091 //
00092 // Purpose: Instantiates a Locator object returning an interface pointer.
00093 //
00094 // Parameters:
00095 //  pUnkOuter       LPUNKNOWN to the controlling IUnknown if we are
00096 //                  being used in an aggregation.
00097 //  riid            REFIID identifying the interface the caller
00098 //                  desires to have for the new object.
00099 //  ppvObj          PPVOID in which to store the desired
00100 //                  interface pointer for the new object.
00101 //
00102 // Return Value:
00103 //  HRESULT         NOERROR if successful, otherwise E_NOINTERFACE
00104 //                  if we cannot support the requested interface.
00105 //***************************************************************************
00106
00107 STDMETHODIMP CProvFactory::CreateInstance(LPUNKNOWN pUnkOuter
00108     , REFIID riid, PPVOID ppvObj)
00109 {
00110     CClassPro *   pObj;
00111     HRESULT hr;
00112
00113     *ppvObj=NULL;
00114
00115     // This object doesnt support aggregation.
00116
00117     if (NULL!=pUnkOuter)
00118         return CLASS_E_NOAGGREGATION;
00119
00120     // Create the locator object.
00121
00122     pObj=new CClassPro();
00123     if (NULL==pObj)
00124         return E_OUTOFMEMORY;
00125
00126     hr=pObj->QueryInterface(riid, ppvObj);
00127
00128     //Kill the object if initial creation or Init failed.
00129
00130     if (FAILED(hr))
00131         delete pObj;
00132     return hr;
00133 }
00134
00135 //***************************************************************************
00136 //
00137 // CProvFactory::LockServer
00138 //
00139 // Purpose:
00140 //  Increments or decrements the lock count of the DLL.  If the
00141 //  lock count goes to zero and there are no objects, the DLL
00142 //  is allowed to unload.  See DllCanUnloadNow.
00143 //
00144 // Parameters:
00145 //  fLock           BOOL specifying whether to increment or
00146 //                  decrement the lock count.
00147 //
00148 // Return Value:
00149 //  HRESULT         NOERROR always.
00150 //***************************************************************************
00151
00152
00153 STDMETHODIMP CProvFactory::LockServer(BOOL fLock)
00154 {
00155     if (fLock)
00156         InterlockedIncrement(&g_cLock);
00157     else
00158         InterlockedDecrement(&g_cLock);
00159     return NOERROR;
00160 }
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/sky.h Source File

  • SysMgmt
  • MMC
  • Nodes

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025 class CSkyBasedVehicle : public CDelegationBase {
00026 public:
00027     CSkyBasedVehicle() { }
00028
00029     virtual ~CSkyBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00034
00035 public:
00036     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00037     virtual HRESULT GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions);
00038
00039 private:
00040     enum { IDM_NEW_SKY = 3 };
00041
00042     // {2974380F-4C4B-11d2-89D8-000021473128}
00043     static const GUID thisGuid;
00044 };
00045
00046
00047 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Printer/Paint.h Source File

  • Multimedia
  • Gdi
  • Printer

Paint.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /******************************************************************************\
00013 *
00014 *                                PAINT.H
00015 *
00016 \******************************************************************************/
00017
00018 /******************************************************************************\
00019 *                           SYMBOLIC CONSTANTS
00020 \******************************************************************************/
00021
00022 #define BORDER                   5
00023
00024 #define NUM_GRAPHICS_XSLOTS      4
00025 #define NUM_GRAPHICS_YSLOTS      3
00026
00027 #define ERR_MOD_NAME              IDS_ERR_PAINT
00028
00029
00030
00031 /******************************************************************************\
00032 *                                TYPEDEFS
00033 \******************************************************************************/
00034
00035 typedef struct
00036 {
00037   int left;
00038   int top;
00039   int right;
00040   int bottom;
00041
00042 } RECTI, *PRECTI;
00043
00044 typedef struct tagArFonts
00045 {
00046   int        nFonts;
00047   int        cySpace;
00048   HDC        hdc;
00049   LOGFONT    *lf;
00050   TEXTMETRIC *tm;
00051   int        *Type;
00052
00053 } ARFONTS, *PARFONTS;
00054
00055
00056
00057 /******************************************************************************\
00058 *                             GLOBAL VARIABLES
00059 \******************************************************************************/
00060
00061 HDC      hdcGlobal;          // globals utilized by enum fonts funtions
00062 PARFONTS parFontsGlobal;
00063 int      iFace,jFont;
00064 int      nFaces;
00065
00066 int      giDeltaX;           // vars used by Get*GraphicSlot calls
00067 int      giDeltaY;
00068 int      giColumn;
00069
00070
00071
00072 /******************************************************************************\
00073 *                          EXTERNAL VARIABLES
00074 \******************************************************************************/
00075
00076 extern HANDLE ghInst;
00077 extern HWND   ghwndMain;
00078 extern DWORD  gdwGraphicsOptions;
00079 extern int    giMapMode;
00080 extern LONG   glcyMenu;
00081
00082
00083 /******************************************************************************\
00084 *                            FUNCTION PROTOTYPES
00085 \******************************************************************************/
00086
00087 void GetFirstGraphicSlot (LPRECT, PRECTI);
00088 void GetNextGraphicSlot  (PRECTI);
00089
00090 void         DrawFonts     (HDC, LPRECT);
00091 PARFONTS     BuildFontList (HDC);
00092 void         FreeFontList  (PARFONTS);
00093
00094 int CALLBACK MyEnumCount (LPLOGFONT, LPTEXTMETRIC, DWORD, LPVOID);
00095 int CALLBACK MyEnumCopy  (LPLOGFONT, LPTEXTMETRIC, DWORD, LPVOID);
00096 int CALLBACK MyEnumFaces (LPLOGFONT, LPTEXTMETRIC, DWORD, LPVOID);
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/DCOMServer.cpp Source File

  • Com
  • async
  • server

DCOMServer.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "DCOMServer.h"
00018 #include "CFactory.h"
00019 #include "CAsyncTest.h"
00020 #include "CAsyncXXX.h"
00021 #include "Registry.h"
00022 #include "Debug.h"
00023
00024
00025 // Event handle used to signal main thread to exit upon shutdown
00026 extern HANDLE g_CloseEvent;
00027
00028
00029 //
00030 // Constructor
00031 //
00032 #pragma warning(disable : 4355)
00033 CServer::CServer(IUnknown* pUnknownOuter):
00034   CUnknown(pUnknownOuter, "CServer")
00035 {
00036   DEBUGTRACE(_T("In CServer ctor"));
00037 }
00038
00039 //
00040 // Destructor
00041 //
00042 CServer::~CServer()
00043 {
00044   DEBUGTRACE(_T("In CServer dtor"));
00045 }
00046
00047 void __stdcall
00048 CServer::FinalRelease()
00049 {
00050 #if !defined(_DLL_SERVER_)
00051   if (CoReleaseServerProcess() == 0) // Last reference to server time to cleanup and exit
00052 #if defined(_APARTMENT_)
00053     PostQuitMessage(0);
00054 #else // Free Threaded
00055     SetEvent(g_CloseEvent);
00056 #endif // _APARTMENT_
00057 #endif // _DLL_SERVER_
00058   return;
00059 }
00060
00061
00062 HRESULT __stdcall
00063   CServer::NondelegatingQueryInterface(const IID& iid, void** ppv)
00064 {
00065   CHECKPOINTER(ppv);
00066 #if defined(_ASYNC_COM_)
00067   if (iid == IID_ICallFactory)
00068   {
00069     return FinishQI(static_cast<LPCALLFACTORY>(this), iid, ppv);
00070   }
00071 #endif //_ASYNC_COM_
00072   if (iid == IID_ITest)
00073   {
00074     return FinishQI(static_cast<LPTEST>(this), iid, ppv);
00075   }
00076 #if defined(_EVENTSINK_)
00077   else if (iid == IID_IConnectionPointContainer)
00078   {
00079     return FinishQI(static_cast<LPCONNECTIONPOINTCONTAINER>(this), iid, ppv) ;
00080   }
00081 #endif
00082   return CUnknown::NondelegatingQueryInterface(iid, ppv);
00083 }
00084
00085
00086
00087 ///////////////////////////////////////////////////////////
00088 //
00089 // Creation function used by CFactory
00090 //
00091 HRESULT CServer::CreateInstance(IUnknown* pUnknownOuter,
00092                            CUnknown** ppNewComponent)
00093 {
00094   *ppNewComponent = new CServer(pUnknownOuter) ;
00095   DEBUGTRACE(_T("In CServer::CreateInstance\n")) ;
00096   return S_OK ;
00097 }
00098
00099
00100 ///////////////////////////////////////////////////////////
00101 //
00102 // Initialize the component and create the contained component.
00103 //
00104
00105 #if defined(_EVENTSINK_)
00106 EventID g_EventIDs =
00107 { 1, {{&IID_AppEvents}}};
00108 #endif
00109
00110 HRESULT __stdcall
00111 CServer::Init(const CFactoryData *pData)
00112 {
00113 #if defined(_EVENTSINK_)
00114   CConnectionPointContainer::Init(g_EventIDs);
00115 #endif
00116
00117 #if !defined(_DLL_SERVER_)
00118   CoAddRefServerProcess();
00119 #endif // _DLL_SERVER_
00120   return S_OK ;
00121 }
00122
00123
00124
00125 #if defined(_ASYNC_COM_)
00126 /*
00127  * ICallFactory
00128  *
00129  */
00130 HRESULT __stdcall
00131 CServer::CreateCall(REFIID riid1, LPUNKNOWN pUnkCtrl, REFIID riid2, LPUNKNOWN *ppv)
00132 {
00133   DEBUGTRACE(_T("In ICallFactory::CreateCall"));
00134   CHECKPOINTER(ppv);
00135   if (riid1 != IID_AsyncITest)
00136     return E_NOINTERFACE;
00137
00138 #if 0
00139 //testtest
00140   {
00141   LPSYNCHRONIZE   lpSync = NULL;
00142   HRESULT hr = pUnkCtrl->QueryInterface(IID_ISynchronize, reinterpret_cast<PVOID*>(&lpSync));
00143   _ASSERT(SUCCEEDED(hr) && lpSync);
00144   hr = lpSync->Reset(); // this succeeds
00145   RELEASEINTERFACE(lpSync);
00146   }
00147 //testtest
00148 #endif
00149 #pragma warning(disable : 4355)
00150   *ppv = CAsyncXXX<CServer, ITest, CAsyncTest>::Create(pUnkCtrl, riid1, riid2, this, this);
00151
00152   return *ppv != NULL ? S_OK : E_OUTOFMEMORY;
00153 }
00154 #endif //_ASYNC_COM_
00155
00156
00157 /*
00158  * ITest
00159  *
00160  */
00161
00162 #include <stdio.h>
00163 HRESULT __stdcall
00164 CServer::Test1(BSTR bstr)
00165 {
00166   DEBUGTRACE(_T("In CServer::Test1:  string is = %S"), bstr);
00167   printf("In CServer::Test1:  string is = %S\n", bstr);
00168   printf("Send asynchronous signal to client\n");
00169 #if defined(_EVENTSINK_)
00170   HRESULT hr = CConnectionPointContainer::GetConnectionPoint(IID_AppEvents)->SignalEvent();
00171   _ASSERT(SUCCEEDED(hr));
00172 #endif
00173   printf("Leaving CServer::Test1\n");
00174   return SysReAllocString(&bstr, L"Good bye") != 0 ? S_OK : E_OUTOFMEMORY ;
00175 }
00176
00177
00178 HRESULT __stdcall
00179 CServer::Test2(BSTR bstrIn, BSTR *lpbstrOut)
00180 {
00181   DEBUGTRACE(_T("In CServer::Test2:  string is = %S"), bstrIn);
00182   CHECKPOINTER(lpbstrOut);
00183   if (bstrIn)
00184     printf("In CServer::Test2:  string is = %S\n", bstrIn);
00185   *lpbstrOut = SysAllocString(L"Synchronous: Good bye");
00186   return S_OK;
00187 }
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/TextPage.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

TextPage.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      TEXTPAGE.CPP
00003
00004   Summary:   Implementation file for the COTextPage COM Object Class (for
00005              connectable COTextPage COM Objects). COTextPage encapsulates
00006              into a COM object the behavior of a page of editable text.
00007              The client can use the native ITextPage interface to get and
00008              put the text of the text page into the object. No GUI
00009              behavior is provided within COTextPage--it only provides a
00010              persistent data management for the text page.
00011
00012              Connectable object technology is used in COTextPage to notify
00013              connected clients of various events like when a load of new
00014              text data is completed.
00015
00016              COTextPage offers a main standard IUnknown interface (basic
00017              COM object features), the standard IConnectionPointContainer
00018              interface (connectable COM object features), the standard
00019              IPersistStreamInit (Stream persistent object features), and
00020              the custom ITextPage interface (TextPage related features).
00021              This multiple interface COM Object Class is achieved via the
00022              technique of nested classes.  The implementations of the
00023              various interfaces are nested inside the COTextPage Class.
00024
00025              For a comprehensive tutorial code tour of this module's
00026              contents and offerings see the tutorial PERTEXT.HTM
00027              file. For more specific technical details on the internal
00028              workings see the comments dispersed throughout the module's
00029              source code.
00030
00031   Classes:   COTextPage.
00032
00033   Functions: none.
00034
00035   Origin:    5-18-97: atrent - Editor-inheritance from PAPER.CPP in
00036              the STOSERVE Tutorial Code Sample.
00037
00038 ----------------------------------------------------------------------------
00039   This file is part of the Microsoft COM Tutorial Code Samples.
00040
00041   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00042
00043   This source code is intended only as a supplement to Microsoft
00044   Development Tools and/or on-line documentation.  See these other
00045   materials for detailed information regarding Microsoft code samples.
00046
00047   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00048   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00049   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00050   PARTICULAR PURPOSE.
00051 ==========================================================================+*/
00052
00053
00054 /*---------------------------------------------------------------------------
00055   We include WINDOWS.H for all Win32 applications.
00056   We include OLE2.H because we will be calling the COM/OLE Libraries.
00057   We include OLECTL.H because it has definitions for connectable objects.
00058   We include APPUTIL.H because we will be building this application using
00059     the convenient Virtual Window and Dialog classes and other
00060     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00061   We include IPAGES.H and PAGEGUID.H for the common TextPage-related
00062     Interface class, GUID, and CLSID specifications.
00063   We include SERVER.H because it has internal class declarations for
00064     the server's control object.
00065   We include CONNECT.H for object class declarations for the various
00066     connection point and connection COM objects used in PERSERVE.
00067   We include TEXTPAGE.H because it has the COTextPage class declarations.
00068 ---------------------------------------------------------------------------*/
00069 #include <windows.h>
00070 #include <ole2.h>
00071 #include <olectl.h>
00072 #include <apputil.h>
00073 #include <ipages.h>
00074 #include <pageguid.h>
00075 #include "server.h"
00076 #include "connect.h"
00077 #include "textpage.h"
00078
00079
00080 /*---------------------------------------------------------------------------
00081   COTextPage's implementation of its main COM object class including
00082   Constructor, Destructor, QueryInterface, AddRef, and Release.
00083 ---------------------------------------------------------------------------*/
00084
00085 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00086   Method:   COTextPage::COTextPage
00087
00088   Summary:  COTextPage Constructor. Note the member initializers like:
00089             "m_ImpITextPage(this, pUnkOuter)" which is used to pass the
00090             'this' and pUnkOuter pointers of the constructor function to
00091             the constructor in the instantiation of the implementation of
00092             the CImpITextPage interface (which is nested inside this present
00093             COTextPage Object Class). Same technique is used for the other
00094             nested interface implementations.
00095
00096   Args:     IUnknown* pUnkOuter,
00097               Pointer to the the outer Unknown.  NULL means this COM Object
00098               is not being Aggregated.  Non-NULL means it is being created
00099               on behalf of an outside COM object that is reusing it via
00100               aggregation.
00101             CServer* pServer)
00102               Pointer to the server's control object.
00103
00104   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00105
00106   Returns:  void
00107 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00108 COTextPage::COTextPage(
00109   IUnknown* pUnkOuter,
00110   CServer* pServer) :
00111   m_ImpITextPage(this, pUnkOuter),
00112   m_ImpIPersistStreamInit(this, pUnkOuter),
00113   m_ImpIConnectionPointContainer(this, pUnkOuter)
00114 {
00115   UINT i;
00116
00117   // Zero the COM object's reference count.
00118   m_cRefs = 0;
00119
00120   // No AddRef necessary if non-NULL, as we're nested.
00121   m_pUnkOuter = pUnkOuter;
00122
00123   // Assign the pointer to the server control object.
00124   m_pServer = pServer;
00125
00126   // Null all entries in the connection point array.
00127   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00128     m_aConnectionPoints[i] = NULL;
00129
00130   // Now initialize the TextPage itself.
00131   m_pwszPageText = NULL;
00132   m_ClassID = CLSID_TextPage;
00133   m_bInitNew = FALSE;
00134   m_bDirty = TRUE;
00135
00136   return;
00137 }
00138
00139
00140 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00141   Method:   COTextPage::~COTextPage
00142
00143   Summary:  COTextPage Destructor.
00144
00145   Args:     void
00146
00147   Returns:  void
00148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00149 COTextPage::~COTextPage(void)
00150 {
00151   UINT i;
00152   IConnectionPoint* pIConnectionPoint;
00153
00154   // Do final release of the connection point objects.
00155   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00156   {
00157     pIConnectionPoint = m_aConnectionPoints[i];
00158     RELEASE_INTERFACE(pIConnectionPoint);
00159   }
00160
00161   DELETE_POINTER(m_pwszPageText);
00162
00163   return;
00164 }
00165
00166
00167 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00168   Method:   COTextPage::Init
00169
00170   Summary:  COTextPage initialization method.  Create any necessary
00171             arrays, structures, and subordinate objects. Rig connectivity.
00172
00173   Args:     void
00174
00175   Modifies: m_aConnectionPoints.
00176
00177   Returns:  HRESULT
00178               Standard result code. NOERROR for success.
00179 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00180 HRESULT COTextPage::Init(void)
00181 {
00182   HRESULT hr = NOERROR;
00183   COConnectionPoint* pCOConnPt;
00184
00185   // Rig this new COTextPage COM object to be connectable. Assign the
00186   // connection point array. This object's connection points are
00187   // determined at compile time--it currently has only one connection
00188   // point: the CONNPOINT_TEXTPAGESINK connection point. Create a
00189   // connection point object for this and assign it into the array. This
00190   // array could easily grow to support additional connection points in
00191   // the future.
00192
00193   // First try creating a new connection point object. Pass 'this' as the
00194   // pHostObj pointer used by the connection point to pass its AddRef and
00195   // Release calls back to the host connectable object.
00196   pCOConnPt = new COConnectionPoint(this);
00197   if (NULL != pCOConnPt)
00198   {
00199     // If creation succeeded then initialize it (including creating
00200     // its initial dynamic connection array).
00201     hr = pCOConnPt->Init(IID_ITextPageSink);
00202
00203     // If the init succeeded then use QueryInterface to obtain the
00204     // IConnectionPoint interface on the new connection point object.
00205     // The interface pointer is assigned directly into the
00206     // connection point array. The QI also does the needed AddRef.
00207     if (SUCCEEDED(hr))
00208     {
00209       hr = pCOConnPt->QueryInterface(
00210              IID_IConnectionPoint,
00211              (PPVOID)&m_aConnectionPoints[CONNPOINT_TEXTPAGESINK]);
00212     }
00213
00214     if (FAILED(hr))
00215       delete pCOConnPt;
00216   }
00217   else
00218     hr = E_OUTOFMEMORY;
00219
00220   return hr;
00221 }
00222
00223
00224 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00225   Method:   COTextPage::QueryInterface
00226
00227   Summary:  QueryInterface of the COTextPage non-delegating IUnknown
00228             implementation.
00229
00230   Args:     REFIID riid,
00231               [in] GUID of the Interface being requested.
00232             PPVOID ppv)
00233               [out] Address of the caller's pointer variable that will
00234               receive the requested interface pointer.
00235
00236   Returns:  HRESULT
00237               Standard result code. NOERROR for success.
00238 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00239 STDMETHODIMP COTextPage::QueryInterface(
00240                REFIID riid,
00241                PPVOID ppv)
00242 {
00243   HRESULT hr = E_NOINTERFACE;
00244
00245   *ppv = NULL;
00246
00247   if (IID_IUnknown == riid)
00248     *ppv = this;
00249   else if (IID_IConnectionPointContainer == riid)
00250     *ppv = &m_ImpIConnectionPointContainer;
00251   else if (IID_IPersistStreamInit == riid)
00252     *ppv = &m_ImpIPersistStreamInit;
00253   else if (IID_ITextPage == riid)
00254     *ppv = &m_ImpITextPage;
00255
00256   if (NULL != *ppv)
00257   {
00258     // We've handed out a pointer to the interface so obey the COM rules
00259     // and AddRef the reference count.
00260     ((LPUNKNOWN)*ppv)->AddRef();
00261     hr = NOERROR;
00262   }
00263
00264   return (hr);
00265 }
00266
00267
00268 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00269   Method:   COTextPage::AddRef
00270
00271   Summary:  AddRef of the COTextPage non-delegating IUnknown implementation.
00272
00273   Args:     void
00274
00275   Modifies: m_cRefs.
00276
00277   Returns:  ULONG
00278               New value of m_cRefs (COM object's reference count).
00279 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00280 STDMETHODIMP_(ULONG) COTextPage::AddRef(void)
00281 {
00282   ULONG cRefs;
00283
00284   cRefs = ++m_cRefs;
00285
00286   return cRefs;
00287 }
00288
00289
00290 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00291   Method:   COTextPage::Release
00292
00293   Summary:  Release of the COTextPage non-delegating IUnknown implementation.
00294
00295   Args:     void
00296
00297   Modifies: m_cRefs.
00298
00299   Returns:  ULONG
00300               New value of m_cRefs (COM object's reference count).
00301 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00302 STDMETHODIMP_(ULONG) COTextPage::Release(void)
00303 {
00304   ULONG cRefs;
00305
00306   cRefs = --m_cRefs;
00307
00308   if (0 == cRefs)
00309   {
00310     // We've reached a zero reference count for this COM object.
00311     // So we tell the server housing to decrement its global object
00312     // count so that the server will be unloaded if appropriate.
00313     if (NULL != m_pServer)
00314       m_pServer->ObjectsDown();
00315
00316     // We artificially bump the main ref count to prevent reentrancy
00317     // via the main object destructor.  Not really needed in this
00318     // COTextPage but a good practice because we are aggregatable and
00319     // may at some point in the future add something entertaining like
00320     // some Releases to the COTextPage destructor. We relinquish thread
00321     // ownership of this object prior to deleting it--a good practice.
00322     m_cRefs++;
00323     delete this;
00324   }
00325
00326   return cRefs;
00327 }
00328
00329
00330 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00331   Method:   COTextPage::Clear
00332
00333   Summary:  Internal private utility method of this COM object used to
00334             clear the content of the text page.
00335
00336   Args:     BOOL bSaveNeeded
00337               Specifies whether the cleared text page should later be
00338               saved to file. TRUE=>later save needed; FALSE=>later save
00339               not needed.
00340
00341   Modifies: m_pwszPageText.
00342
00343   Returns:  HRESULT
00344               Standard result code. NOERROR for success.
00345 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00346 HRESULT COTextPage::Clear(
00347           BOOL bSaveNeeded)
00348 {
00349   HRESULT hr = NOERROR;
00350
00351   // Zero the text string array.
00352   if (NULL != m_pwszPageText)
00353     memset(m_pwszPageText, 0, TEXTPAGE_V10_MAX * sizeof(WCHAR));
00354
00355   // Set the Page Properties for this version of TextPages.
00356   m_TextProps.ulVersion = TEXTPAGE_VERSION10;
00357   m_TextProps.ulMaxLength = TEXTPAGE_V10_MAX;
00358   m_TextProps.ulLength = 0;
00359
00360   // Mark TextPage as dirty (ie, needs to be saved to file) if specified.
00361   m_bDirty = bSaveNeeded;
00362
00363   return hr;
00364 }
00365
00366
00367 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00368   Method:   COTextPage::NotifySinks
00369
00370   Summary:  Internal utility method of this COM object used to fire event
00371             notification calls to all listening connection sinks in the
00372             client.
00373
00374   Args:     TEXTPAGE_EVENT TextPageEvent
00375               Type of TextPage notification event.
00376
00377   Returns:  HRESULT
00378               Standard result code. NOERROR for success.
00379 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00380 HRESULT COTextPage::NotifySinks(
00381        TEXTPAGE_EVENT TextPageEvent)
00382 {
00383   HRESULT hr = NOERROR;
00384   IConnectionPoint* pIConnectionPoint;
00385   IEnumConnections* pIEnum;
00386   CONNECTDATA ConnData;
00387
00388   // If there was a TextPage event, broadcast appropriate notifications to
00389   // all Sinks connected to each connection point.
00390   if (TEXTPAGE_EVENT_NONE != TextPageEvent)
00391   {
00392     // Here is the section for the TextPageSink connection point--currently
00393     // this is the only connection point offered by COTextPage objects.
00394     pIConnectionPoint = m_aConnectionPoints[CONNPOINT_TEXTPAGESINK];
00395     if (NULL != pIConnectionPoint)
00396     {
00397       pIConnectionPoint->AddRef();
00398       hr = pIConnectionPoint->EnumConnections(&pIEnum);
00399       if (SUCCEEDED(hr))
00400       {
00401         // Loop thru the connection point's connections and if the
00402         // listening connection supports ITextPageSink (ie, TextPageSink
00403         // events) then dispatch the TextPageEvent event notification to
00404         // that sink.
00405         while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
00406         {
00407           ITextPageSink* pITextPageSink;
00408
00409           hr = ConnData.pUnk->QueryInterface(
00410                                 IID_ITextPageSink,
00411                                 (PPVOID)&pITextPageSink);
00412           if (SUCCEEDED(hr))
00413           {
00414             switch (TextPageEvent)
00415             {
00416               case TEXTPAGE_EVENT_LOADED:
00417                 pITextPageSink->Loaded();
00418                 break;
00419               case TEXTPAGE_EVENT_SAVED:
00420                 pITextPageSink->Saved();
00421                 break;
00422               case TEXTPAGE_EVENT_PUT:
00423                 pITextPageSink->Put();
00424                 break;
00425               case TEXTPAGE_EVENT_CLEARED:
00426                 pITextPageSink->Cleared();
00427                 break;
00428               default:
00429                 break;
00430             }
00431             pITextPageSink->Release();
00432           }
00433           ConnData.pUnk->Release();
00434         }
00435         pIEnum->Release();
00436       }
00437       pIConnectionPoint->Release();
00438     }
00439   }
00440
00441   return hr;
00442 }
00443
00444
00445 /*---------------------------------------------------------------------------
00446   COTextPage's nested implementation of the COM standard
00447   IConnectionPointContainer interface including Constructor, Destructor,
00448   QueryInterface, AddRef, Release, FindConnectionPoint, and
00449   EnumConnectionPoints.
00450 ---------------------------------------------------------------------------*/
00451
00452 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00453   Method:   COTextPage::CImpIConnectionPointContainer
00454               ::CImpIConnectionPointContainer
00455
00456   Summary:  Constructor for the CImpIConnectionPointContainer interface
00457             instantiation.
00458
00459   Args:     COTextPage* pCO,
00460               Back pointer to the parent outer object.
00461             IUnknown* pUnkOuter
00462               Pointer to the outer Unknown.  For delegation.
00463
00464   Modifies: m_pCO, m_pUnkOuter.
00465
00466   Returns:  void
00467 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00468 COTextPage::CImpIConnectionPointContainer::CImpIConnectionPointContainer(
00469   COTextPage* pCO,
00470   IUnknown* pUnkOuter)
00471 {
00472   // Init the Main Object Pointer to point to the parent object.
00473   m_pCO = pCO;
00474
00475   // Init the CImpIConnectionPointContainer interface's delegating Unknown
00476   // pointer.  We use the Main Object pointer for IUnknown delegation here
00477   // if we are not being aggregated.  If we are being aggregated we use
00478   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00479   // pointer assignment requires no AddRef because the
00480   // CImpIConnectionPointContainer lifetime is quaranteed by the lifetime
00481   // of the parent object in which CImpIConnectionPointContainer is
00482   // nested.
00483   if (NULL == pUnkOuter)
00484     m_pUnkOuter = pCO;
00485   else
00486     m_pUnkOuter = pUnkOuter;
00487
00488   return;
00489 }
00490
00491
00492 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00493   Method:   COTextPage::CImpIConnectionPointContainer
00494               ::~CImpIConnectionPointContainer
00495
00496   Summary:  Destructor for the CImpIConnectionPointContainer interface
00497             instantiation.
00498
00499   Args:     void
00500
00501   Returns:  void
00502 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00503 COTextPage::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
00504 {
00505   return;
00506 }
00507
00508
00509 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00510   Method:   COTextPage::CImpIConnectionPointContainer::QueryInterface
00511
00512   Summary:  The QueryInterface IUnknown member of this ITextPage interface
00513             implementation that delegates to m_pUnkOuter, whatever it is.
00514
00515   Args:     REFIID riid,
00516               [in] GUID of the Interface being requested.
00517             PPVOID ppv)
00518               [out] Address of the caller's pointer variable that will
00519               receive the requested interface pointer.
00520
00521   Returns:  HRESULT
00522               Standard result code. NOERROR for success.
00523               Returned by the delegated outer QueryInterface call.
00524 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00525 STDMETHODIMP COTextPage::CImpIConnectionPointContainer::QueryInterface(
00526                REFIID riid,
00527                PPVOID ppv)
00528 {
00529   // Delegate this call to the outer object's QueryInterface.
00530   return m_pUnkOuter->QueryInterface(riid, ppv);
00531 }
00532
00533
00534 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00535   Method:   COTextPage::CImpIConnectionPointContainer::AddRef
00536
00537   Summary:  The AddRef IUnknown member of this ITextPage interface
00538             implementation that delegates to m_pUnkOuter, whatever it is.
00539
00540   Args:     void
00541
00542   Returns:  ULONG
00543               Returned by the delegated outer AddRef call.
00544 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00545 STDMETHODIMP_(ULONG) COTextPage::CImpIConnectionPointContainer::AddRef(void)
00546 {
00547   // Delegate this call to the outer object's AddRef.
00548   return m_pUnkOuter->AddRef();
00549 }
00550
00551
00552 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00553   Method:   COTextPage::CImpIConnectionPointContainer::Release
00554
00555   Summary:  The Release IUnknown member of this ITextPage interface
00556             implementation that delegates to m_pUnkOuter, whatever it is.
00557
00558   Args:     void
00559
00560   Returns:  ULONG
00561               Returned by the delegated outer Release call.
00562 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00563 STDMETHODIMP_(ULONG) COTextPage::CImpIConnectionPointContainer::Release(void)
00564 {
00565   // Delegate this call to the outer object's Release.
00566   return m_pUnkOuter->Release();
00567 }
00568
00569
00570 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00571   Method:   COTextPage::CImpIConnectionPointContainer::FindConnectionPoint
00572
00573   Summary:  Given an IID for a connection point sink find and return the
00574             interface pointer for that connection point sink.
00575
00576   Args:     REFIID riid
00577               Reference to an IID
00578             IConnectionPoint** ppConnPt
00579               Address of the caller's IConnectionPoint interface pointer
00580               variable that will receive the requested interface pointer.
00581
00582   Returns:  HRESULT
00583               Standard result code. NOERROR for success.
00584 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00585 STDMETHODIMP COTextPage::CImpIConnectionPointContainer::FindConnectionPoint(
00586                REFIID riid,
00587                IConnectionPoint** ppConnPt)
00588 {
00589   HRESULT hr = E_NOINTERFACE;
00590   IConnectionPoint* pIConnPt;
00591
00592   // NULL the output variable.
00593   *ppConnPt = NULL;
00594
00595   pIConnPt = m_pCO->m_aConnectionPoints[CONNPOINT_TEXTPAGESINK];
00596   if (NULL != pIConnPt)
00597   {
00598     // This connectable COTextPage object currently has only the
00599     // TextPage Sink connection point. If the associated interface is
00600     // requested, use QI to get the Connection Point interface and
00601     // perform the needed AddRef.
00602     if (IID_ITextPageSink == riid)
00603       hr = pIConnPt->QueryInterface(
00604                        IID_IConnectionPoint,
00605                        (PPVOID)ppConnPt);
00606   }
00607
00608   return hr;
00609 }
00610
00611
00612 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00613   Method:   COTextPage::CImpIConnectionPointContainer::EnumConnectionPoints
00614
00615   Summary:  Return Enumerator for the connectable object's contained
00616             connection points.
00617
00618   Args:     IEnumConnectionPoints** ppIEnum
00619               Address of the caller's Enumerator interface pointer
00620               variable. An output variable that will receive a pointer to
00621               the connection point enumerator COM object.
00622
00623   Returns:  HRESULT
00624               Standard result code. NOERROR for success.
00625 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00626 STDMETHODIMP COTextPage::CImpIConnectionPointContainer::EnumConnectionPoints(
00627                IEnumConnectionPoints** ppIEnum)
00628 {
00629   HRESULT hr = NOERROR;
00630   IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
00631   COEnumConnectionPoints* pCOEnum;
00632   UINT i;
00633
00634   // Zero the output interface pointer.
00635   *ppIEnum = NULL;
00636
00637   // Make a copy on the stack of the array of connection point
00638   // interfaces. The copy is used below in the creation of the new
00639   // Enumerator object.
00640   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00641     aConnPts[i] = (IConnectionPoint*)m_pCO->m_aConnectionPoints[i];
00642
00643   // Create a Connection Point enumerator COM object for the connection
00644   // points offered by this COTextPage object. Pass 'this' to be used to
00645   // hook the lifetime of the host object to the life time of this
00646   // enumerator object.
00647   pCOEnum = new COEnumConnectionPoints(this);
00648   if (NULL != pCOEnum)
00649   {
00650     // Use the array copy to Init the new Enumerator COM object.
00651     // Set the initial Enumerator index to 0.
00652     hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
00653     if (SUCCEEDED(hr))
00654     {
00655       // QueryInterface to return the requested interface pointer.
00656       // An AddRef will be conveniently done by the QI.
00657       if (SUCCEEDED(hr))
00658         hr = pCOEnum->QueryInterface(
00659                         IID_IEnumConnectionPoints,
00660                         (PPVOID)ppIEnum);
00661     }
00662   }
00663   else
00664     hr = E_OUTOFMEMORY;
00665
00666   return hr;
00667 }
00668
00669
00670 /*---------------------------------------------------------------------------
00671   COTextPage's nested implementation of the COM standard
00672   IPersistStreamInit interface including Constructor, Destructor,
00673   QueryInterface, AddRef, Release, GetClassID, IsDirty, Load, Save,
00674   GetSizeMax, and InitNew.
00675 ---------------------------------------------------------------------------*/
00676
00677 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00678   Method:   COTextPage::CImpIPersistStreamInit::CImpIPersistStreamInit
00679
00680   Summary:  Constructor for the CImpIPersistStreamInit interface
00681             instantiation.
00682
00683   Args:     COTextPage* pCO,
00684               Back pointer to the parent outer object.
00685             IUnknown* pUnkOuter
00686               Pointer to the outer Unknown.  For delegation.
00687
00688   Modifies: m_pCO, m_pUnkOuter.
00689
00690   Returns:  void
00691 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00692 COTextPage::CImpIPersistStreamInit::CImpIPersistStreamInit(
00693   COTextPage* pCO,
00694   IUnknown* pUnkOuter)
00695 {
00696   // Init the Main Object Pointer to point to the parent object.
00697   m_pCO = pCO;
00698
00699   // Init the CImpIPersistStreamInit interface's delegating IUnknown
00700   // pointer.  We use the Main Object pointer for IUnknown delegation here
00701   // if we are not being aggregated.  If we are being aggregated we use
00702   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00703   // pointer assignment requires no AddRef because the
00704   // pIPersistStreamInit lifetime is quaranteed by the lifetime of the
00705   // parent object in which CImpIPersistStreamInit is nested.
00706   if (NULL == pUnkOuter)
00707     m_pUnkOuter = pCO;
00708   else
00709     m_pUnkOuter = pUnkOuter;
00710
00711   return;
00712 }
00713
00714
00715 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00716   Method:   COTextPage::CImpIPersistStreamInit::~CImpIPersistStreamInit
00717
00718   Summary:  Destructor for the CImpIPersistStreamIint interface
00719             instantiation.
00720
00721   Args:     void
00722
00723   Returns:  void
00724 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00725 COTextPage::CImpIPersistStreamInit::~CImpIPersistStreamInit(void)
00726 {
00727   return;
00728 }
00729
00730
00731 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00732   Method:   COTextPage::CImpIPersistStreamInit::QueryInterface
00733
00734   Summary:  The QueryInterface IUnknown member of this interface
00735             implementation that delegates to m_pUnkOuter, whatever it is.
00736
00737   Args:     REFIID riid,
00738               [in] GUID of the Interface being requested.
00739             PPVOID ppv)
00740               [out] Address of the caller's pointer variable that will
00741               receive the requested interface pointer.
00742
00743   Returns:  HRESULT
00744               Standard result code. NOERROR for success.
00745               Returned by the delegated outer QueryInterface call.
00746 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00747 STDMETHODIMP COTextPage::CImpIPersistStreamInit::QueryInterface(
00748                REFIID riid,
00749                PPVOID ppv)
00750 {
00751   // Delegate this call to the outer object's QueryInterface.
00752   return m_pUnkOuter->QueryInterface(riid, ppv);
00753 }
00754
00755
00756 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00757   Method:   COTextPage::CImpIPersistStreamInit::AddRef
00758
00759   Summary:  The AddRef IUnknown member of this interface implementation
00760             that delegates to m_pUnkOuter, whatever it is.
00761
00762   Args:     void
00763
00764   Returns:  ULONG
00765               Returned by the delegated outer AddRef call.
00766 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00767 STDMETHODIMP_(ULONG) COTextPage::CImpIPersistStreamInit::AddRef(void)
00768 {
00769   // Delegate this call to the outer object's AddRef.
00770   return m_pUnkOuter->AddRef();
00771 }
00772
00773
00774 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00775   Method:   COTextPage::CImpIPersistStreamInit::Release
00776
00777   Summary:  The Release IUnknown member of this interface implementation
00778             that delegates to m_pUnkOuter, whatever it is.
00779
00780   Args:     void
00781
00782   Returns:  ULONG
00783               Returned by the delegated outer Release call.
00784 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00785 STDMETHODIMP_(ULONG) COTextPage::CImpIPersistStreamInit::Release(void)
00786 {
00787   // Delegate this call to the outer object's Release.
00788   return m_pUnkOuter->Release();
00789 }
00790
00791
00792 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00793   Method:   COTextPage::CImpIPersistStreamInit::GetClassID
00794
00795   Summary:  A method inherited from IPersist. Get the Class ID of this
00796             COM object.
00797
00798   Args:     CLSID* pClassID
00799               [out] Address of variable to hold Class ID.
00800
00801   Returns:  HRESULT
00802               Standard result code. NOERROR for success.
00803 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00804 STDMETHODIMP COTextPage::CImpIPersistStreamInit::GetClassID(
00805                CLSID* pClassID)
00806 {
00807   HRESULT hr = E_POINTER;
00808
00809   if (NULL != pClassID)
00810   {
00811     // Use overloaded '=' operator to copy the Class ID to caller.
00812     *pClassID = m_pCO->m_ClassID;
00813     hr = NOERROR;
00814   }
00815
00816   return hr;
00817 }
00818
00819
00820 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00821   Method:   COTextPage::CImpIPersistStreamInit::IsDirty
00822
00823   Summary:  Called to determine if changes were made to this COM object
00824             since it was last loaded or initialized.
00825
00826   Args:     none.
00827
00828   Returns:  HRESULT
00829               Standard result code. S_OK if dirty; S_FALSE if not.
00830 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00831 STDMETHODIMP COTextPage::CImpIPersistStreamInit::IsDirty(
00832                void)
00833 {
00834   HRESULT hr;
00835
00836   hr = m_pCO->m_bDirty ? S_OK : S_FALSE;
00837
00838   return hr;
00839 }
00840
00841
00842 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00843   Method:   COTextPage::CImpIPersistStreamInit::Load
00844
00845   Summary:  Asks this COM object to load its persistent data from the
00846             specified stream at the current seek pointer. This function
00847             assumes the seek pointer is the same as it was before Save
00848             was last called. This function must leave the seek pointer
00849             the same as it was after Save was last completed regardless
00850             of success or failure. This function should not keep a copy
00851             of pIStream in the COM object after it completes.
00852
00853             Load is called INSTEAD of InitNew when this COM object already
00854             has a persistent state stored in a stream. Notifies all other
00855             connected clients when the load is complete.
00856
00857   Args:     IStream* pIStream
00858               IStream interface pointer for stream to load from. This
00859               COM object must NOT retain a copy of this IStream pointer
00860               after this call completes.
00861
00862   Returns:  HRESULT
00863               Standard result code. NOERROR for success. E_UNEXPECTED if
00864               an InitNew or Load has already been called.
00865 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00866 STDMETHODIMP COTextPage::CImpIPersistStreamInit::Load(
00867                IStream* pIStream)
00868 {
00869   HRESULT hr = E_POINTER;
00870   ULONG ulToRead, ulReadIn;
00871   TEXTPROPS NewProps;
00872   WCHAR* pwszPageText;
00873
00874   if (NULL != pIStream)
00875   {
00876     if (!m_pCO->m_bInitNew)
00877     {
00878       // We have the TextPage data stream. First read the TextPage
00879       // Properties.
00880       ulToRead = sizeof(TEXTPROPS);
00881       hr = pIStream->Read(
00882                        &NewProps,
00883                        ulToRead,
00884                        &ulReadIn);
00885       if (SUCCEEDED(hr) && ulToRead != ulReadIn)
00886         hr = E_FAIL;
00887       if (SUCCEEDED(hr))
00888       {
00889         // Deal with the different versions.
00890         switch (NewProps.ulVersion)
00891         {
00892           case TEXTPAGE_VERSION10:
00893             if (NewProps.ulMaxLength <= TEXTPAGE_V10_MAX)
00894             {
00895               // Allocate an page text array big enough for the largest
00896               // text page.
00897               pwszPageText = new WCHAR[(ULONG) NewProps.ulMaxLength];
00898               if (NULL != pwszPageText)
00899               {
00900                 m_pCO->m_pwszPageText = pwszPageText;
00901                 // First zero the page text area.
00902                 memset(
00903                   pwszPageText,
00904                   0,
00905                   NewProps.ulMaxLength * sizeof(WCHAR));
00906                 ulToRead = NewProps.ulLength * sizeof(WCHAR);
00907                 if (ulToRead >= 0 && ulToRead < (ULONG)NewProps.ulMaxLength)
00908                 {
00909                   // Now read in the complete text page.
00910                   hr = pIStream->Read(
00911                          pwszPageText,
00912                          ulToRead,
00913                          &ulReadIn);
00914                   if (SUCCEEDED(hr) && ulToRead != ulReadIn)
00915                     hr = E_FAIL;
00916                   if (SUCCEEDED(hr))
00917                   {
00918                     // Copy the new properties into current properties.
00919                     memcpy(
00920                       &m_pCO->m_TextProps,
00921                       &NewProps,
00922                       sizeof(TEXTPROPS));
00923
00924                     // We are loaded and clean (ie, COTextPage data
00925                     // matches file data). Clear dirty flag.
00926                     m_pCO->m_bDirty = FALSE;
00927                   }
00928                 }
00929                 else
00930                   hr = E_FAIL;
00931               }
00932               else
00933                 hr = E_OUTOFMEMORY;
00934             }
00935             break;
00936           default:
00937             hr = E_FAIL;  // Bad version.
00938             break;
00939         }
00940       }
00941     }
00942     else
00943       hr = E_UNEXPECTED;
00944   }
00945
00946   // Notify all other connected clients that TextPage is now loaded.
00947   // If we didn't load then clear to a safe, empty text page.
00948   if (SUCCEEDED(hr))
00949     m_pCO->NotifySinks(TEXTPAGE_EVENT_LOADED);
00950   else
00951     m_pCO->Clear(TRUE);
00952
00953   return hr;
00954 }
00955
00956
00957 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00958   Method:   COTextPage::CImpIPersistStreamInit::Save
00959
00960   Summary:  Called to save the persistent data of this COM object to a
00961             stream using the specified IStream interface. This call stores
00962             data from the current seek pointer offset. On exit from this
00963             method the seek pointer is assumed to be just past the end of
00964             the data saved. This allows a series of contiguous persistent
00965             objects to be saved into the same stream. Notifies all other
00966             connected clients when the save is complete.
00967
00968   Args:     IStream* pIStream
00969               IStream interface pointer for stream to load from. This
00970               COM object must NOT retain a copy of this IStream pointer
00971               after the function completes.
00972             BOOL bClearDirty
00973               Determines if this method should clear the COM object's
00974               dirty flag. If bClearDirty is TRUE then clear the dirty
00975               flag.
00976
00977   Returns:  HRESULT
00978               Standard result code. NOERROR for success.
00979 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00980 STDMETHODIMP COTextPage::CImpIPersistStreamInit::Save(
00981                IStream* pIStream,
00982                BOOL bClearDirty)
00983 {
00984   HRESULT hr = E_POINTER;
00985   ULONG ulToWrite, ulWritten;
00986
00987   if (NULL != pIStream)
00988   {
00989     // Got a stream. Now write data into it.
00990
00991     // First write TEXTPROPS structure.
00992     ulToWrite = sizeof(TEXTPROPS);
00993     hr = pIStream->Write(&m_pCO->m_TextProps, ulToWrite, &ulWritten);
00994     if (SUCCEEDED(hr) && ulToWrite != ulWritten)
00995       hr = STG_E_CANTSAVE;
00996     if (SUCCEEDED(hr))
00997     {
00998       // Now write the complete page text data.
00999       ulToWrite = m_pCO->m_TextProps.ulLength * sizeof(WCHAR);
01000       hr = pIStream->Write(m_pCO->m_pwszPageText, ulToWrite, &ulWritten);
01001       if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01002         hr = STG_E_CANTSAVE;
01003       if (SUCCEEDED(hr))
01004       {
01005         // Clear this COM object's dirty flag if instructed.
01006         if (bClearDirty)
01007           m_pCO->m_bDirty = FALSE;
01008       }
01009     }
01010   }
01011
01012   // Notify all other connected clients that TextPage is now saved.
01013   if (SUCCEEDED(hr))
01014     m_pCO->NotifySinks(TEXTPAGE_EVENT_SAVED);
01015
01016   return hr;
01017 }
01018
01019
01020 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01021   Method:   COTextPage::CImpIPersistStreamInit::GetSizeMax
01022
01023   Summary:  Called to obtain the maximum possible total size of the
01024             chunks of data that could be saved when Save is next called.
01025
01026   Args:     ULARGE_INTEGER* pcbSize
01027               Address of the caller's variable to receive the size (bytes).
01028
01029   Returns:  HRESULT
01030               Standard result code. NOERROR for success.
01031 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01032 STDMETHODIMP COTextPage::CImpIPersistStreamInit::GetSizeMax(
01033                ULARGE_INTEGER* pcbSize)
01034 {
01035   HRESULT hr = E_POINTER;
01036   ULONG ulMax = m_pCO->m_TextProps.ulMaxLength;
01037
01038   if (NULL != pcbSize)
01039   {
01040     ULISet32(*pcbSize, sizeof(TEXTPROPS) + (ulMax * sizeof(WCHAR)));
01041     hr = NOERROR;
01042   }
01043
01044   return hr;
01045 }
01046
01047
01048 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01049   Method:   COTextPage::CImpIPersistStreamInit::InitNew
01050
01051   Summary:  Called to tell the object that it has been newly created and
01052             has no existing persistent state already stored.
01053
01054             InitNew is called INSTEAD of Load when the new object instance
01055             must be initialized with brand new data rather than with
01056             persistent data previously saved in a stream.
01057
01058   Args:     none.
01059
01060   Modifies: m_pwszPageText, m_aConnectionPoints.
01061
01062   Returns:  HRESULT
01063               Standard result code. NOERROR for success.
01064 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01065 STDMETHODIMP COTextPage::CImpIPersistStreamInit::InitNew(
01066                void)
01067 {
01068   HRESULT hr = E_FAIL;
01069   WCHAR* pwszPageText;
01070
01071   if (!m_pCO->m_bInitNew)
01072   {
01073     // There is no previous persistent data for this COTextPage object.
01074     // Create and init a new set of persistence data for an empty text page.
01075
01076     // Allocate an page text array big enough for the largest text page.
01077     // This maximum is hard-coded here for this Version 1.0 of Text Pages.
01078     pwszPageText = new WCHAR[(LONG) TEXTPAGE_V10_MAX];
01079     if (NULL != pwszPageText)
01080     {
01081       m_pCO->m_pwszPageText = pwszPageText;
01082       // Use the private Clear method to clear the new text array and to
01083       // set the Page Properties structure appropriately. Also sets dirty.
01084       hr = m_pCO->Clear(TRUE);
01085       m_pCO->m_bInitNew = TRUE;
01086     }
01087     else
01088       hr = E_OUTOFMEMORY;
01089   }
01090   else
01091     hr = E_UNEXPECTED;
01092
01093   return hr;
01094 }
01095
01096
01097 /*---------------------------------------------------------------------------
01098   COTextPage's nested implementation of the custom ITextPage interface
01099   including Constructor, Destructor, QueryInterface, AddRef, Release,
01100   GetFirst, GetNext, Add, Delete, and Clear.
01101 ---------------------------------------------------------------------------*/
01102
01103 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01104   Method:   COTextPage::CImpITextPage::CImpITextPage
01105
01106   Summary:  Constructor for the CImpITextPage interface instantiation.
01107
01108   Args:     COTextPage* pCO,
01109               Back pointer to the parent outer object.
01110             IUnknown* pUnkOuter
01111               Pointer to the outer Unknown.  For delegation.
01112
01113   Modifies: m_pCO, m_pUnkOuter.
01114
01115   Returns:  void
01116 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01117 COTextPage::CImpITextPage::CImpITextPage(
01118   COTextPage* pCO,
01119   IUnknown* pUnkOuter)
01120 {
01121   // Init the Main Object Pointer to point to the parent object.
01122   m_pCO = pCO;
01123
01124   // Init the CImpITextPage interface's delegating IUnknown pointer.  We
01125   // use the Main Object pointer for IUnknown delegation here if we are
01126   // not being aggregated.  If we are being aggregated we use the supplied
01127   // pUnkOuter for IUnknown delegation.  In either case the pointer
01128   // assignment requires no AddRef because the CImpITextPage lifetime is
01129   // quaranteed by the lifetime of the parent object in which
01130   // CImpITextPage is nested.
01131   if (NULL == pUnkOuter)
01132     m_pUnkOuter = pCO;
01133   else
01134     m_pUnkOuter = pUnkOuter;
01135
01136   return;
01137 }
01138
01139
01140 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01141   Method:   COTextPage::CImpITextPage::~CImpITextPage
01142
01143   Summary:  Destructor for the CImpITextPage interface instantiation.
01144
01145   Args:     void
01146
01147   Returns:  void
01148 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01149 COTextPage::CImpITextPage::~CImpITextPage(void)
01150 {
01151
01152   return;
01153 }
01154
01155
01156 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01157   Method:   COTextPage::CImpITextPage::QueryInterface
01158
01159   Summary:  The QueryInterface IUnknown member of this ITextPage interface
01160             implementation that delegates to m_pUnkOuter, whatever it is.
01161
01162   Args:     REFIID riid,
01163               [in] GUID of the Interface being requested.
01164             PPVOID ppv)
01165               [out] Address of the caller's pointer variable that will
01166               receive the requested interface pointer.
01167
01168   Returns:  HRESULT
01169               Standard result code. NOERROR for success.
01170               Returned by the delegated outer QueryInterface call.
01171 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01172 STDMETHODIMP COTextPage::CImpITextPage::QueryInterface(
01173                REFIID riid,
01174                PPVOID ppv)
01175 {
01176   // Delegate this call to the outer object's QueryInterface.
01177   return m_pUnkOuter->QueryInterface(riid, ppv);
01178 }
01179
01180
01181 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01182   Method:   COTextPage::CImpITextPage::AddRef
01183
01184   Summary:  The AddRef IUnknown member of this ITextPage interface
01185             implementation that delegates to m_pUnkOuter, whatever it is.
01186
01187   Args:     void
01188
01189   Returns:  ULONG
01190               Returned by the delegated outer AddRef call.
01191 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01192 STDMETHODIMP_(ULONG) COTextPage::CImpITextPage::AddRef(void)
01193 {
01194   // Delegate this call to the outer object's AddRef.
01195   return m_pUnkOuter->AddRef();
01196 }
01197
01198
01199 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01200   Method:   COTextPage::CImpITextPage::Release
01201
01202   Summary:  The Release IUnknown member of this ITextPage interface
01203             implementation that delegates to m_pUnkOuter, whatever it is.
01204
01205   Args:     void
01206
01207   Returns:  ULONG
01208               Returned by the delegated outer Release call.
01209 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01210 STDMETHODIMP_(ULONG) COTextPage::CImpITextPage::Release(void)
01211 {
01212   // Delegate this call to the outer object's Release.
01213   return m_pUnkOuter->Release();
01214 }
01215
01216
01217 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01218   Method:   COTextPage::CImpITextPage::GetLength
01219
01220   Summary:  Get the current length (in WCHARs) of the text page.
01221
01222   Args:     INT* piLength
01223               Address of the caller's variable that is assigned the length.
01224
01225   Returns:  HRESULT
01226               Standard result code. NOERROR for success.
01227 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01228 STDMETHODIMP COTextPage::CImpITextPage::GetLength(
01229                INT* piLength)
01230 {
01231   HRESULT hr = E_POINTER;
01232
01233   if (NULL != piLength)
01234   {
01235     *piLength = (INT) m_pCO->m_TextProps.ulLength;
01236     hr = NOERROR;
01237   }
01238
01239   return hr;
01240 }
01241
01242
01243 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01244   Method:   COTextPage::CImpITextPage::GetText
01245
01246   Summary:  Get the current page text held in this object.
01247
01248   Args:     WCHAR* pwszPageText
01249               Address of a wide character string to receive the text
01250               data of the text page.
01251
01252   Returns:  HRESULT
01253               Standard result code. NOERROR for success. E_POINTER if
01254               NULL passed for the output string pointer.
01255 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01256 STDMETHODIMP COTextPage::CImpITextPage::GetText(
01257                WCHAR* pwszPageText)
01258 {
01259   HRESULT hr = E_POINTER;
01260
01261   if (NULL != pwszPageText && NULL != m_pCO->m_pwszPageText)
01262   {
01263     // Copy the Text Page's text to the caller.
01264     memcpy(
01265       pwszPageText,
01266       m_pCO->m_pwszPageText,
01267       m_pCO->m_TextProps.ulLength * sizeof(WCHAR));
01268     hr = NOERROR;
01269   }
01270
01271   return hr;
01272 }
01273
01274
01275 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01276   Method:   COTextPage::CImpITextPage::PutText
01277
01278   Summary:  Put specified text into the Text Page COM object. This does
01279             not save the text persistently.
01280
01281   Args:     WCHAR* pwszPageText,
01282               Address of the wide character string to put into the text
01283               page.
01284             INT iLength)
01285               Length in wide characters of the string.
01286
01287   Returns:  HRESULT
01288               Standard result code. NOERROR for success. E_POINTER if
01289               NULL passed for the input string.
01290 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01291 STDMETHODIMP COTextPage::CImpITextPage::PutText(
01292                WCHAR* pwszPageText,
01293                INT iLength)
01294 {
01295   HRESULT hr = E_POINTER;
01296
01297   if (NULL != pwszPageText && NULL != m_pCO->m_pwszPageText)
01298   {
01299     if (iLength < (INT) m_pCO->m_TextProps.ulMaxLength)
01300     {
01301       // Copy the Caller's text into the text page.
01302       memcpy(
01303         m_pCO->m_pwszPageText,
01304         pwszPageText,
01305         iLength * sizeof(WCHAR));
01306
01307       // Set the new current length.
01308       m_pCO->m_TextProps.ulLength = (ULONG)iLength;
01309
01310       // Mark TextPage as dirty. Subsequent save to file is needed.
01311       m_pCO->m_bDirty = TRUE;
01312
01313       // Notify all other connected clients that the new text was
01314       // put into the COTextPage object.
01315       m_pCO->NotifySinks(TEXTPAGE_EVENT_PUT);
01316
01317       hr = NOERROR;
01318     }
01319     else
01320       hr = E_FAIL;
01321   }
01322
01323   return hr;
01324 }
01325
01326
01327 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01328   Method:   COTextPage::CImpITextPage::Clear
01329
01330   Summary:  Clears the entire text page. Sets dirty flag if specified.
01331             Reassigns the page properties as appropriate. Notifies clients
01332             of this event.
01333
01334   Args:     BOOL bSaveNeeded
01335               Specifies whether the cleared text page should later be
01336               saved to file. TRUE=>later save needed; FALSE=>later save
01337               not needed.
01338
01339   Returns:  HRESULT
01340               Standard result code. NOERROR for success.
01341 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01342 STDMETHODIMP COTextPage::CImpITextPage::Clear(
01343                BOOL bSaveNeeded)
01344 {
01345   HRESULT hr = E_FAIL;
01346
01347   hr = m_pCO->Clear(bSaveNeeded);
01348
01349   // Notify all other connected clients that the list was cleared.
01350   if (SUCCEEDED(hr))
01351     m_pCO->NotifySinks(TEXTPAGE_EVENT_CLEARED);
01352
01353   return hr;
01354 }
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/compdata.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

compdata.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #include "Globals.h"
00015 #include "Comp.h"
00016 #include "CompData.h"
00017 #include "DataObj.h"
00018 #include "Resource.h"
00019
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CComponentData")
00024
00025
00026 /////////////////////////////////////////////////////////////////////////////
00027 // Construction/Destruction
00028
00029
00030 //---------------------------------------------------------------------------
00031 //  This constructor is called when the Snap-in is selected from the
00032 //  Add/Remove dialog.  Build our static node and load the required
00033 //  clipformats before MMC calls us.
00034 //
00035 CComponentData::CComponentData()
00036 {
00037   // Do not assume only one instance of IComponentData implementation is created.
00038
00039
00040     m_cRef                = 0;
00041     m_ipConsoleNameSpace  = NULL;
00042     m_ipConsole           = NULL;
00043     m_ipScopeImage        = NULL;
00044
00045     // Increment this so DllCanUnloadNow works correctly
00046     InterlockedIncrement((long*)&g_uObjectCount);
00047
00048     NODE_PROPERTIES NodeProps;
00049     ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00050     wcscpy( NodeProps.szNodeName, gwszROOT_NODE_NAME );
00051
00052     NodeProps.pParentObject  = NULL;
00053     NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(this);
00054
00055     m_pStaticNode = new CStaticNode;
00056     m_pStaticNode->Initialize( &NodeProps );
00057
00058     InitClipboardFormats();
00059 }
00060
00061 //---------------------------------------------------------------------------
00062 CComponentData::~CComponentData()
00063 {
00064   if( NULL != m_pStaticNode )
00065   {
00066     delete m_pStaticNode;
00067     m_pStaticNode = NULL;
00068   }
00069
00070   // All done, decrement object count so the dll can be unloaded
00071   InterlockedDecrement((long*)&g_uObjectCount);
00072 }
00073
00074
00075 /////////////////////////////////////////////////////////////////////////////
00076 // IUnknown implementation
00077
00078 //---------------------------------------------------------------------------
00079 //  Must add support for IExtendContextMenu & IComponentData2 here
00080 //
00081 STDMETHODIMP CComponentData::QueryInterface
00082 (
00083   REFIID   riid,       //[in] Identifier of the requested interface
00084   LPVOID   *ppv        //[out] Address of requested interface
00085 )
00086 {
00087   if( !ppv )
00088     return E_FAIL;
00089
00090   *ppv = NULL;
00091
00092   if( IsEqualIID(riid, IID_IUnknown) )
00093     *ppv = static_cast<IComponentData*>(this);
00094   else if( IsEqualIID(riid, IID_IComponentData) )
00095     *ppv = static_cast<IComponentData*>(this);
00096   else if( IsEqualIID(riid, IID_IComponentData2) )
00097     *ppv = static_cast<IComponentData2*>(this);
00098   else if( IsEqualIID(riid, IID_IExtendContextMenu) )
00099     *ppv = static_cast<IExtendContextMenu*>(this);
00100
00101
00102   if( *ppv )
00103   {
00104     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00105     return S_OK;
00106   }
00107
00108   return E_NOINTERFACE;
00109 }
00110
00111 //---------------------------------------------------------------------------
00112 STDMETHODIMP_(ULONG) CComponentData::AddRef()
00113 {
00114   return InterlockedIncrement((LONG*)&m_cRef);
00115 }
00116
00117 //---------------------------------------------------------------------------
00118 STDMETHODIMP_(ULONG) CComponentData::Release()
00119 {
00120   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00121   {
00122     delete this;
00123     return 0;
00124   }
00125
00126   return m_cRef;
00127 }
00128
00129 /////////////////////////////////////////////////////////////////////////////
00130 // Interface IComponentData2
00131
00132 //---------------------------------------------------------------------------
00133 //  Called when the user selects the Snap-in from the scope pane.
00134 //  This is where we QI and cache interfaces we will use later.  These
00135 //  interfaces are for future use since they are not used in this sample
00136 //
00137 HRESULT CComponentData::Initialize
00138 (
00139   LPUNKNOWN pUnknown         //[in] Pointer to the console's IUnknown
00140 )
00141 {
00142   HRESULT hResult = S_FALSE;
00143                              // Fail to initialize if we can't get the
00144   do                         // interfaces we need to cache
00145   {
00146     hResult = pUnknown->QueryInterface(IID_IConsoleNameSpace2, (void**)&m_ipConsoleNameSpace);
00147     BREAK_ON_ERROR( hResult );
00148
00149     hResult = pUnknown->QueryInterface(IID_IConsole3, (void**)&m_ipConsole);
00150     BREAK_ON_ERROR( hResult );
00151
00152     // Add the images for the scope tree
00153     LPIMAGELIST ipScopeImage = NULL;
00154     hResult = m_ipConsole->QueryScopeImageList(&ipScopeImage);
00155     BREAK_ON_ERROR( hResult );
00156
00157     // Load the bitmaps from the dll
00158     HBITMAP hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16) );
00159     if( NULL == hImageStrip16 )
00160     {
00161       hResult = S_FALSE;
00162       continue;
00163     }
00164
00165     HBITMAP hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32) );
00166     if( NULL == hImageStrip32)
00167     {
00168       hResult = S_FALSE;
00169       continue;
00170     }
00171
00172     // Set the images
00173     hResult = ipScopeImage->ImageListSetStrip( (LONG_PTR*)hImageStrip16,
00174                                                (LONG_PTR*)hImageStrip32,
00175                                                0,
00176                                                RGB(0,255,0)
00177                                              );
00178     BREAK_ON_ERROR( hResult );
00179
00180     SAFE_RELEASE( ipScopeImage      ); // Release these here.  IComponent
00181     SAFE_FREE_BITMAP( hImageStrip16 ); // will get an MMCN_ADD_IMAGES when
00182     SAFE_FREE_BITMAP( hImageStrip32 ); // the console needs them again.
00183   }
00184   while( 0 );
00185
00186   return hResult;
00187 }
00188
00189 //---------------------------------------------------------------------------
00190 //  Called by the console every time we need to create a new result view.
00191 //  There can be several different result views. Aside from the default one
00192 //  created when the Snap-in initializes, additional ones are created by
00193 //  selecting "New window from here" in MMC's user interface.
00194 //
00195 HRESULT CComponentData::CreateComponent
00196 (
00197   LPCOMPONENT __RPC_FAR* ppComponent   //[out] Points to new IComponent class
00198 )
00199 {
00200   *ppComponent = NULL;
00201
00202   // Pass the new CComponent a pointer to it's parent
00203   CComponent* pComponent = new CComponent( this );
00204
00205   if( NULL == pComponent )
00206     return E_OUTOFMEMORY;
00207
00208   return pComponent->QueryInterface( IID_IComponent, (void**)ppComponent );
00209 }
00210
00211 //---------------------------------------------------------------------------
00212 //  Handles notification events from MMC
00213 //
00214 HRESULT CComponentData::Notify
00215 (
00216   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00217   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00218   LONG             nArg,           //[in] Depends on the notification type
00219   LONG             nParam          //[in] Depends on the notification type
00220 )
00221 {
00222   TRACE_EVENT( _T("Notify"), MmcEvent );  // Provides trace output
00223
00224   HRESULT hResult = S_FALSE;
00225   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00226   if( NULL == pNode )
00227     return hResult;
00228
00229   switch( MmcEvent )
00230   {
00231     case MMCN_EXPAND:
00232       hResult = pNode->OnExpand( ipDataObject, nArg, nParam, (LONG_PTR)this );
00233       break;
00234
00235     case MMCN_REMOVE_CHILDREN:
00236       hResult = pNode->OnRemoveChildren( ipDataObject, nArg, nParam, (LONG_PTR)this );
00237       break;
00238
00239     case MMCN_PRELOAD:                 // Function not implemented
00240     case MMCN_PROPERTY_CHANGE:         // Function not implemented
00241     case MMCN_DELETE:                  // Function not implemented
00242     case MMCN_RENAME:                  // Function not implemented
00243     default:
00244       break;
00245   }
00246
00247   return hResult;
00248 }
00249
00250 //---------------------------------------------------------------------------
00251 //  This is where we release any cached interface pointers or any
00252 //  allocated resources.
00253 //
00254 HRESULT CComponentData::Destroy( void)
00255 {
00256   SAFE_RELEASE( m_ipScopeImage       );
00257   SAFE_RELEASE( m_ipConsoleNameSpace );
00258   SAFE_RELEASE( m_ipConsole          );
00259
00260   return S_OK;
00261 }
00262
00263 //---------------------------------------------------------------------------
00264 //  MMC provides a NULL cookie for the static/root node.  In this sample
00265 //  we don't pass that on, instead we use the pointer to our static node
00266 //  object which handles notifications
00267 //
00268 HRESULT CComponentData::QueryDataObject
00269 (
00270   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00271   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00272   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00273 )
00274 {
00275   HRESULT  hResult   = S_FALSE;
00276   INT_PTR  TmpCookie = 0;
00277
00278   CDataObject* pNewObject = new CDataObject();
00279
00280   (0 == nCookie) ? TmpCookie = (INT_PTR)m_pStaticNode : TmpCookie = nCookie;
00281   pNewObject->SetPrivateData( TmpCookie, (ULONG)nEnumType );
00282
00283   if( NULL == pNewObject )
00284     hResult = E_OUTOFMEMORY;
00285   else
00286     hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00287
00288   return hResult;
00289 }
00290
00291 //---------------------------------------------------------------------------
00292 //  Delegate the call to the static node object
00293 //
00294 HRESULT CComponentData::GetDisplayInfo
00295 (
00296   SCOPEDATAITEM* pScopeDataItem    //[out][in] Points to a SCOPEDATAITEM struct
00297 )
00298 {
00299   _ASSERT( NULL != pScopeDataItem );
00300   HRESULT hResult = S_OK;
00301
00302   // The console will only ask for the name string
00303   if(  pScopeDataItem->mask & SDI_STR )
00304   {
00305     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(pScopeDataItem->lParam);
00306     hResult = pNode->GetDisplayInfo( pScopeDataItem );
00307   }
00308
00309   return hResult;
00310 }
00311
00312 //---------------------------------------------------------------------------
00313 HRESULT CComponentData::CompareObjects
00314 (
00315   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00316   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00317 )
00318 {
00319   return E_NOTIMPL;
00320 }
00321
00322
00323 //---------------------------------------------------------------------------
00324 HRESULT CComponentData::QueryDispatch
00325 (
00326   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00327   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00328   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00329 )
00330 {
00331   return E_NOTIMPL;
00332 }
00333
00334
00335 /////////////////////////////////////////////////////////////////////////////
00336 // Interface IExtendContextMenu
00337
00338 //---------------------------------------------------------------------------
00339 HRESULT CComponentData::AddMenuItems
00340 (
00341   LPDATAOBJECT ipDataObject,         //[in]
00342   LPCONTEXTMENUCALLBACK ipCallback,  //[in]
00343   long __RPC_FAR* pInsertionAllowed  //[out-in]
00344 )
00345 {
00346   _ASSERT( NULL != ipCallback );
00347   HRESULT hResult = S_FALSE;
00348
00349   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00350   if( NULL != pNode )
00351     hResult = pNode->AddMenuItems( ipCallback, pInsertionAllowed );
00352
00353   return hResult;
00354 }
00355
00356 //---------------------------------------------------------------------------
00357 //  Delegates user events to the nodes
00358 //
00359 HRESULT CComponentData::Command
00360 (
00361   long         lCommandID,   //[in] Identifier of the menu item
00362   LPDATAOBJECT ipDataObject  //[in] DataObject for selected node
00363 )
00364 {
00365   HRESULT hResult = S_OK;
00366
00367   CBaseNode* pNode = ExtractBaseNodePtr( ipDataObject );
00368   if( NULL != pNode )
00369     hResult = pNode->Command( lCommandID );
00370
00371   return hResult;
00372 }
00373
00374
00375 /////////////////////////////////////////////////////////////////////////////
00376 //  Helper methods
00377
00378 //---------------------------------------------------------------------------
00379 HRESULT CComponentData::GetInterface
00380 (
00381   DWORD     dwRequestedInterface,  //[in] Request flag
00382   LONG_PTR* ppInterface            //[in-out] Interface pointer to return
00383 )
00384 {
00385   _ASSERT( NULL != ppInterface );
00386   HRESULT hResult = S_OK;
00387
00388   switch( dwRequestedInterface )
00389   {
00390     case REQUEST_ICONSOLENAMESPACE:
00391       _ASSERT( NULL != m_ipConsoleNameSpace );
00392       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleNameSpace);
00393       break;
00394
00395     case REQUEST_ICONSOLE:
00396       _ASSERT( NULL != m_ipConsole );
00397       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00398       break;
00399
00400     default:
00401       hResult = S_FALSE;
00402       *ppInterface = NULL;
00403       break;
00404   }
00405
00406   return hResult;
00407 }
00408
00409
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminCatalogCollection Member List

This is the complete list of members for comadmin::COMAdminCatalogCollection, including all inherited members.
Add() | comadmin::COMAdminCatalogCollection |
clsid | comadmin::COMAdminCatalogCollection | [static]
get_NewEnum() | comadmin::COMAdminCatalogCollection |
getAddEnabled() | comadmin::COMAdminCatalogCollection |
GetCollection(String bstrCollName, Variant varObjectKey) | comadmin::COMAdminCatalogCollection |
getCount() | comadmin::COMAdminCatalogCollection |
getDataStoreMajorVersion() | comadmin::COMAdminCatalogCollection |
getDataStoreMinorVersion() | comadmin::COMAdminCatalogCollection |
getItem(int lIndex) | comadmin::COMAdminCatalogCollection |
getName() | comadmin::COMAdminCatalogCollection |
getRemoveEnabled() | comadmin::COMAdminCatalogCollection |
GetUtilInterface() | comadmin::COMAdminCatalogCollection |
iid | comadmin::COMAdminCatalogCollection | [static]
Populate() | comadmin::COMAdminCatalogCollection |
PopulateByKey(com.ms.com.SafeArray aKeys) | comadmin::COMAdminCatalogCollection |
PopulateByQuery(String bstrQueryString, int lQueryType) | comadmin::COMAdminCatalogCollection |
Remove(int lIndex) | comadmin::COMAdminCatalogCollection |
SaveChanges() | comadmin::COMAdminCatalogCollection |
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCNotify/QCNotify.Idl Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCNotify

QCNotify.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      QCNotify.idl
00003   Summary:   Interfaces for Queued Components Order Entry Sample 1
00004   Classes:   Declared: Notify
00005   Origin:    Implementation of case study in Queued Components specification.
00006 ----------------------------------------------------------------------------
00007   Copyright 1992 - 1998 Microsoft Corporation, All rights reserved.
00008
00009     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010     ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012     PARTICULAR PURPOSE
00013 ==========================================================================+*/
00014
00015 #include "mtxattr.h"  // For TRANSACTION_REQUIRED
00016
00017 import "oaidl.idl";
00018
00019 // Shipping Status - used between Ship and Notify components
00020
00021 typedef [public] enum _ShipStatus
00022 {
00023   ssUnprocessed   = 0,  // as yet unprocessed
00024   ssShipped     = 1,  // item is on its way
00025   ssBackOrdered   = 2,  // item ordered from supplier
00026   ssNotStocked    = 3,  // we no longer stock this item
00027   ssUnrecognizedItem  = 4   // item identifier not recognized
00028 } ShipStatus;
00029
00030
00031 /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
00032   Interface: INotify
00033   Summary:   Returns shipping status from Shipping component to requesting client
00034   Methods:   HRESULT CustomerId - sets Customer Identifier property
00035        HRESULT OrderId - sets Order Identifier property
00036        HRESULT LineItem - returns status about one line item
00037              HRESULT ProcessOrder - Completes order
00038 I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
00039
00040 [
00041   helpstring("INotify Interface"), uuid(6DD1E6EF-28C1-11D2-B5B6-00C04FC340EE),
00042   object, dual, nonextensible, hidden, pointer_default(unique),
00043   QUEUEABLE
00044 ]
00045 interface INotify : IDispatch
00046 {
00047   [id(1), propput] HRESULT CustomerId([in] long lCustomerId);
00048   [id(2), propput] HRESULT OrderId([in] long lOrderId);
00049   [id(3)] HRESULT LineItem([in] long lItemId, [in] long lQuantity, [in] ShipStatus shipStatus);
00050   [id(4)] HRESULT Process([in] long lFlags);
00051 }
00052
00053 [
00054   uuid(6DD1E6DC-28C1-11D2-B5B6-00C04FC340EE),
00055   version(1.0),
00056   helpstring("QCNotify 1.0 Type Library")
00057 ]
00058
00059 // Library and classes
00060
00061 library QCNOTIFYLib
00062 {
00063   importlib("stdole2.tlb");
00064
00065 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00066   ObjectClass: Notify
00067   Summary:     created by shipping department to update shipping status
00068   Interfaces:  IUnknown     Standard COM object interface
00069                INotify      The order being notified
00070   Aggregation: Not supported
00071 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00072
00073   [
00074     helpstring("Notify Class"), uuid(6DD1E6F0-28C1-11D2-B5B6-00C04FC340EE),
00075     TRANSACTION_REQUIRED
00076   ]
00077   coclass Notify { [default] interface INotify; };
00078 };
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/PoolWrap/PoolWrap.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • PoolWrap

PoolWrap.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: PoolWrap.cpp
00006
00007 Abstract:
00008
00009     Wrapper to provide a queue and thread pool for ISAPI extensions
00010
00011 Author:
00012
00013     ISAPI developer (Microsoft employee)
00014
00015 --*/
00016
00017 #define _WIN32_WINNT 0x0500
00018
00019 #include <stdio.h>
00020 #include <stdarg.h>
00021 #include <windows.h>
00022 #include <httpext.h>
00023 #include "PoolWrap.h"
00024
00025 //
00026 // Definitions
00027 //
00028
00029 #define DEFAULT_THREADS            5
00030 #define DEFAULT_QUEUE             10
00031 #define LOG_MAX_LINE            1024
00032 #define RESPONSE_MAX_BUFFER     1024
00033
00034 //
00035 // Globals
00036 //
00037
00038 // Thread pool
00039 HANDLE *                    g_pThreads = NULL;
00040 HANDLE                      g_hCompletionPort = NULL;
00041 LONG                        g_ItemsInQueue = 0;
00042 LONG                        g_QueueSize = 0;
00043 DWORD                       g_NumThreads = 0;
00044 BOOL                        g_UseThreadPool = TRUE;
00045 CHAR                        g_QueueFullResponse[RESPONSE_MAX_BUFFER+1] = {0};
00046 CHAR                        g_QueueFullHeaders[RESPONSE_MAX_BUFFER+1] = {0};
00047 DWORD                       g_cchQueueFullResponse;
00048 DWORD                       g_cchQueueFullHeaders;
00049
00050 // Initialization verification
00051 BOOL                        g_InitSuccess = TRUE;
00052 DWORD                       g_InitResultCode = ERROR_SUCCESS;
00053
00054 // Logging
00055 HANDLE                      g_hLogFile = INVALID_HANDLE_VALUE;
00056 CRITICAL_SECTION            g_LogFileLock;
00057 BOOL                        g_EnableLogging = TRUE;
00058
00059 // Statistics
00060 LONG                        g_QueueFullPages = 0;
00061 LONG                        g_TotalRequests = 0;
00062
00063 //
00064 // Wrapper function declarations
00065 //
00066
00067 BOOL
00068 WINAPI
00069 GetExtensionVersionWrapper(
00070     HSE_VERSION_INFO *  pVer
00071     );
00072
00073 DWORD
00074 WINAPI
00075 HttpExtensionProcWrapper(
00076     EXTENSION_CONTROL_BLOCK *   pecb
00077     );
00078
00079 BOOL
00080 WINAPI
00081 TerminateExtensionWrapper(
00082     DWORD   dwFlags
00083     );
00084
00085 //
00086 // Thread pool and queue functions
00087 //
00088
00089 BOOL
00090 InitThreadPool(
00091     DWORD   dwQueueSize,
00092     DWORD   dwNumThreads
00093     );
00094
00095 VOID
00096 ShutdownThreadPool(
00097     VOID
00098     );
00099
00100 BOOL
00101 QueueRequest(
00102     EXTENSION_CONTROL_BLOCK *   pecb
00103     );
00104
00105 DWORD
00106 WINAPI
00107 WorkerThreadProc(
00108     VOID *  pVoid
00109     );
00110
00111 //
00112 // Send error functions
00113 //
00114
00115 DWORD
00116 SendExtensionInitFailed(
00117     EXTENSION_CONTROL_BLOCK *   pecb
00118     );
00119
00120 DWORD
00121 SendQueueFull(
00122     EXTENSION_CONTROL_BLOCK *   pecb
00123     );
00124
00125 BOOL
00126 SendThreadInitFailed(
00127     EXTENSION_CONTROL_BLOCK *   pecb,
00128     DWORD                       dwError
00129     );
00130
00131 //
00132 // Helper functions
00133 //
00134
00135 BOOL
00136 AllocateAndFormatErrorMessage(
00137     DWORD   dwError,
00138     LPSTR * ppBuffer
00139     );
00140
00141 //
00142 // Function implementations
00143 //
00144
00145 BOOL
00146 WINAPI
00147 GetExtensionVersionWrapper(
00148     HSE_VERSION_INFO *  pVer
00149     )
00150 /*++
00151
00152 Purpose:
00153
00154     This function wraps GetExtensionVersion.  If GetExtensionVersion
00155     succeeds, this wrapper then creates a thread pool and queue for
00156     processing requests.
00157
00158 Arguments:
00159
00160     pVer - poins to extension version info structure
00161
00162 Returns:
00163
00164     Always returns TRUE.  In the event of a FALSE return from
00165     GetExtensionVersion, or an error creating the thread pool,
00166     the result code will be stored.  Any requests to this extension
00167     will then return an error page.
00168
00169 --*/
00170 {
00171     CHAR    szPath[MAX_PATH+1] = {0};
00172     CHAR    szLogFile[MAX_PATH+1] = {0};
00173     LPSTR   pCursor;
00174
00175     //
00176     // Before doing anything, get the path to this extension.  This
00177     // will be used to find the INI file and open the log file.
00178     //
00179     // Note that we'll avoid crashing if an error occurs during this
00180     // phase of initialization, but we don't have any way of logging
00181     // errors until we open the log file (and if we fail to open the
00182     // log file, we won't ever be able to log errors.)
00183     //
00184
00185     GetModuleFileName(
00186         GetModuleHandle( MODULE_NAME ),
00187         szPath,
00188         MAX_PATH
00189         );
00190
00191     pCursor = strrchr( szPath, '.' );
00192
00193     if ( pCursor )
00194     {
00195         *pCursor = '\0';
00196
00197         //
00198         // Set the log file name
00199         //
00200
00201         strcpy( szLogFile, szPath );
00202         strcat( szLogFile, ".log" );
00203
00204         //
00205         // Now tweak the path so that it points
00206         // to the INI file for this extension
00207         //
00208
00209         strcat( szPath, ".ini" );
00210     }
00211
00212     //
00213     // Check to see if logging is enabled
00214     //
00215
00216     g_EnableLogging = GetPrivateProfileInt(
00217         "ThreadPool",
00218         "EnableLogging",
00219         1, // Enable logging TRUE by default
00220         szPath
00221         );
00222
00223     if ( g_EnableLogging )
00224     {
00225         //
00226         // Open the log file.  We'll allow read sharing so that the log
00227         // can be read while the extension is running.  Don't bother to
00228         // check for error, since we couldn't report it, and the
00229         // IsapiWriteLog function is smart enough to deal with it.
00230         //
00231         // In the event of a successful call, though, we will set the
00232         // last error to ERROR_SUCCESS, in case CreateFile set it to
00233         // ERROR_ALREADY_EXISTS.
00234         //
00235
00236         g_hLogFile = CreateFile(
00237             szLogFile,
00238             GENERIC_WRITE,
00239             FILE_SHARE_READ,
00240             NULL,
00241             OPEN_ALWAYS,
00242             FILE_ATTRIBUTE_NORMAL,
00243             NULL
00244             );
00245     }
00246
00247     //
00248     // Initialize the log file lock.  From now on, the IsapiWriteLog
00249     // function is available for use.
00250     //
00251
00252     if ( g_hLogFile != INVALID_HANDLE_VALUE )
00253     {
00254         SetLastError( ERROR_SUCCESS );
00255         InitializeCriticalSection( &g_LogFileLock );
00256     }
00257
00258     //
00259     // Call the "real" GetExtensionVersion
00260     //
00261
00262     g_InitSuccess = GetExtensionVersion( pVer );
00263
00264     if ( g_InitSuccess == FALSE )
00265     {
00266         goto InitFailed;
00267     }
00268
00269     //
00270     // Read thread pool settings from INI file
00271     //
00272
00273     g_UseThreadPool = GetPrivateProfileInt(
00274         "ThreadPool",
00275         "UseThreadPool",
00276         1, // UseThreadPool = TRUE by default
00277         szPath
00278         );
00279
00280     if ( g_UseThreadPool == 0 )
00281     {
00282         //
00283         // Don't initialize the thread pool, just return TRUE
00284         //
00285
00286         IsapiWriteLog(
00287             "Extension %s configured to not use thread pool.\r\n",
00288             MODULE_NAME
00289             );
00290
00291         return TRUE;
00292     }
00293
00294     g_NumThreads = GetPrivateProfileInt(
00295         "ThreadPool",
00296         "NumThreads",
00297         0,
00298         szPath
00299         );
00300
00301     g_QueueSize = GetPrivateProfileInt(
00302         "ThreadPool",
00303         "QueueSize",
00304         0,
00305         szPath
00306         );
00307
00308     //
00309     // A zero value for either g_NumThreads or g_Queue size means that
00310     // we should use the defaults.  Also, don't let the number of threads
00311     // exceed the queue size.
00312     //
00313
00314     if ( g_NumThreads == 0 )
00315     {
00316         g_NumThreads = DEFAULT_THREADS;
00317     }
00318
00319     if ( g_QueueSize == 0 )
00320     {
00321         g_QueueSize = DEFAULT_QUEUE;
00322     }
00323
00324     if ( g_NumThreads > static_cast<DWORD>( g_QueueSize ) )
00325     {
00326         g_NumThreads = g_QueueSize;
00327     }
00328
00329     //
00330     // Build the "queue full" response.  Since this is supposed to
00331     // happen when the server is busy, we'll create it here at init
00332     // time, so that we only have to blast it out at run time.
00333     //
00334
00335     _snprintf(
00336         g_QueueFullResponse,
00337         RESPONSE_MAX_BUFFER,
00338         "<html>\r\n"
00339         "<head><title> Extension '%s.dll' too busy </title></head>\r\n"
00340         "<h1> Extension '%s.dll' Too Busy. </h1>\r\n"
00341         "<hr>\r\n"
00342         "Extension '%s.dll' is too busy right now.  Please try your "
00343         "request again in a few minutes.\r\n"
00344         "</html>",
00345         MODULE_NAME,
00346         MODULE_NAME,
00347         MODULE_NAME
00348         );
00349
00350     g_cchQueueFullResponse = strlen( g_QueueFullResponse );
00351
00352     _snprintf(
00353         g_QueueFullHeaders,
00354         RESPONSE_MAX_BUFFER,
00355         "Content-Type: text/html\r\n"
00356         "Content-Length: %d\r\n"
00357         "\r\n",
00358         g_cchQueueFullResponse
00359         );
00360
00361     g_cchQueueFullHeaders = strlen( g_QueueFullHeaders );
00362
00363     //
00364     // Initialize the pool and queue
00365     //
00366
00367     g_InitSuccess = InitThreadPool( g_QueueSize, g_NumThreads );
00368
00369     if ( g_InitSuccess == FALSE )
00370     {
00371         goto InitFailed;
00372     }
00373
00374     IsapiWriteLog(
00375         "Successfully initialized thread pool. QueueSize=%d, "
00376         "NumThreads=%d.\r\n",
00377         g_QueueSize,
00378         g_NumThreads
00379         );
00380
00381     //
00382     // That's it, we're ready to go
00383     //
00384
00385     return TRUE;
00386
00387 InitFailed:
00388
00389     g_InitResultCode = GetLastError();
00390
00391     IsapiWriteLog(
00392         "Attempt to initialize %s.dll failed with error %d.\r\n",
00393         MODULE_NAME,
00394         g_InitResultCode
00395         );
00396
00397     return TRUE;
00398 }
00399
00400 DWORD
00401 WINAPI
00402 HttpExtensionProcWrapper(
00403     EXTENSION_CONTROL_BLOCK *   pecb
00404     )
00405 /*++
00406
00407 Purpose:
00408
00409     This function handles queuing requests to be picked up by
00410     worker threads.  Before processing, it checks for a successful
00411     initialization.  If initialization failed, it sends back an
00412     error page to the client.  If it cannot successfully queue the
00413     request, it will return a "busy" page to the client (since the
00414     only practical reason for a queue failure is that the queue is
00415     full).
00416
00417 Arguments:
00418
00419     pecb - A pointer to the EXTENSION_CONTROL_BLOCK for this request
00420
00421 Returns:
00422
00423     One of the HSE_STATUS result codes
00424
00425 --*/
00426 {
00427     BOOL    fResult;
00428
00429     InterlockedIncrement( &g_TotalRequests );
00430
00431     //
00432     // First, check to see if the extension initialized OK.
00433     //
00434
00435     if ( g_InitSuccess == FALSE )
00436     {
00437         return SendExtensionInitFailed( pecb );
00438     }
00439
00440     //
00441     // Check to see if we are using the thread pool.  If not,
00442     // then just call the "real" HttpExtensionProc
00443     //
00444
00445     if ( g_UseThreadPool == FALSE )
00446     {
00447         return HttpExtensionProc( pecb );
00448     }
00449
00450     //
00451     // Now attempt to queue the request.  If not successful,
00452     // send the "too busy" page.
00453     //
00454
00455     fResult = QueueRequest( pecb );
00456
00457     if ( fResult == FALSE )
00458     {
00459         return SendQueueFull( pecb );
00460     }
00461
00462     //
00463     // Ok, so the request has been queued.  Return HSE_STATUS_PENDING
00464     // now.
00465     //
00466
00467     return HSE_STATUS_PENDING;
00468 }
00469
00470 BOOL
00471 WINAPI
00472 TerminateExtensionWrapper(
00473     DWORD   dwFlags
00474     )
00475 /*++
00476
00477 Purpose:
00478
00479     This function wraps TerminateExtension.  After calling
00480     TerminateExtension, it cleans up the queue and thread pool
00481     for this extension.
00482
00483     Note that the TerminateExtension function implies that it
00484     is possible for an extension to refuse terminatation.  This
00485     feature was never implemented, so this wrapper always
00486     returns TRUE.
00487
00488 Arguments:
00489
00490     dwFlags - Inidication that termination is optional (note
00491               that this will never happen)
00492
00493 Returns:
00494
00495     Always returns TRUE.
00496
00497 --*/
00498 {
00499     IsapiWriteLog(
00500         "Extension %s.dll terminating.\r\n",
00501         MODULE_NAME
00502         );
00503
00504     //
00505     // Call the "real" TerminateExtension.  We don't need
00506     // its return value
00507     //
00508
00509     TerminateExtension( dwFlags );
00510
00511     //
00512     // Clean up the thread pool
00513     //
00514
00515     ShutdownThreadPool();
00516
00517     //
00518     // Close the log file
00519     //
00520
00521     if ( g_hLogFile != INVALID_HANDLE_VALUE )
00522     {
00523         CloseHandle( g_hLogFile );
00524         g_hLogFile = INVALID_HANDLE_VALUE;
00525
00526         DeleteCriticalSection( &g_LogFileLock );
00527     }
00528
00529     return TRUE;
00530 }
00531
00532 BOOL
00533 InitThreadPool(
00534     DWORD   dwQueueSize,
00535     DWORD   dwNumThreads
00536     )
00537 /*++
00538
00539 Purpose:
00540
00541     This function initializes the thread pool and queue to the
00542     specified sizes
00543
00544 Arguments:
00545
00546     dwQueueSize  - The size of the request queue
00547     dwNumThreads - The number of threads in the pool
00548
00549 Returns:
00550
00551     TRUE on success, FALSE on failure
00552
00553 --*/
00554 {
00555     DWORD   dwError = ERROR_SUCCESS;
00556     DWORD   dwThreadId;
00557     DWORD   x;
00558
00559     //
00560     // If not using a thread pool, return now
00561     //
00562
00563     if ( g_UseThreadPool == FALSE )
00564     {
00565         SetLastError( ERROR_INVALID_PARAMETER );
00566         return FALSE;
00567     }
00568
00569     //
00570     // Initialize the queue item count
00571     //
00572
00573     g_ItemsInQueue = 0;
00574
00575     //
00576     // Allocate storage for the thread handles
00577     //
00578
00579     g_pThreads = reinterpret_cast<HANDLE*>( LocalAlloc(
00580         LPTR,
00581         g_NumThreads * sizeof( HANDLE * )
00582         ) );
00583
00584     if ( g_pThreads == NULL )
00585     {
00586         IsapiWriteLog(
00587             "Insufficient memory to allocate thread handle storage.\r\n"
00588             );
00589
00590         SetLastError( ERROR_NOT_ENOUGH_MEMORY );
00591
00592         goto InitFailed;
00593     }
00594
00595     //
00596     // Create the completion port for the thread pool
00597     //
00598
00599     g_hCompletionPort = CreateIoCompletionPort(
00600         INVALID_HANDLE_VALUE,
00601         NULL,
00602         0,
00603         0
00604         );
00605
00606     if ( g_hCompletionPort == NULL )
00607     {
00608         IsapiWriteLog(
00609             "Error %d occured creating the pool's completion port.\r\n",
00610             GetLastError()
00611             );
00612
00613         goto InitFailed;
00614     }
00615
00616     //
00617     // Create the threads
00618     //
00619
00620     for ( x = 0; x < g_NumThreads; x++ )
00621     {
00622         g_pThreads[x] = CreateThread(
00623             NULL,               // Security attributes
00624             0,                  // Stack size
00625             WorkerThreadProc,   // Start routine
00626             NULL,               // Parameter
00627             0,                  // Creation flags
00628             &dwThreadId         // ThreadId
00629             );
00630
00631         if ( g_pThreads[x] == NULL )
00632         {
00633             IsapiWriteLog(
00634                 "Error %d occured creating pool thread #%d.\r\n",
00635                 GetLastError(),
00636                 x
00637                 );
00638
00639             goto InitFailed;
00640         }
00641     }
00642
00643     return TRUE;
00644
00645 InitFailed:
00646
00647     dwError = GetLastError();
00648
00649     //
00650     // ShutdownThreadPool is smart enough to clean up a partially
00651     // initialized pool.
00652     //
00653
00654     ShutdownThreadPool();
00655
00656     SetLastError( dwError );
00657
00658     return FALSE;
00659 }
00660
00661 VOID
00662 ShutdownThreadPool(
00663     VOID
00664     )
00665 /*++
00666
00667 Purpose:
00668
00669     This function shuts down the thread pool and queue and deallocates
00670     any existing associated structures
00671
00672 Arguments:
00673
00674     None
00675
00676 Returns:
00677
00678     None
00679
00680 --*/
00681 {
00682     DWORD   dwBlockIndex;
00683     DWORD   dwThreadsRemaining;
00684     DWORD   dwWaitCount;
00685     DWORD   x;
00686
00687     //
00688     // If we're not using the thread pool, do nothing
00689     //
00690
00691     if ( g_UseThreadPool == FALSE )
00692     {
00693         return;
00694     }
00695
00696     //
00697     // If the completion port has been created and we have threads,
00698     // post completions with a NULL LPOVERLAPPED for each thread in
00699     // the pool, and delete it.  By setting LPOVERLAPPED to NULL,
00700     // we are signalling the threads that it's time to quit.
00701     //
00702
00703     if ( g_hCompletionPort )
00704     {
00705         if ( g_pThreads != NULL )
00706         {
00707             for ( x = 0; x < g_NumThreads; x++ )
00708             {
00709                 PostQueuedCompletionStatus(
00710                     g_hCompletionPort,
00711                     0,
00712                     0,
00713                     NULL
00714                     );
00715             }
00716         }
00717
00718         CloseHandle( g_hCompletionPort );
00719         g_hCompletionPort = NULL;
00720     }
00721
00722     if ( g_pThreads == NULL )
00723     {
00724         //
00725         // If no threads - we're done
00726         //
00727
00728         goto Done;
00729     }
00730
00731     //
00732     // Now wait for each of the threads to exit.  Note that we'll wait
00733     // an infinite amount of time here.
00734     //
00735     // There are only two conditions in which we'd expect to see
00736     // ShutdownThreadPool called: in the event of an init failure, or
00737     // when the TerminateExtension is called by the server.  In each
00738     // of these cases, we expect that all of the pool threads are
00739     // idle (TerminateExtension isn't called until all pending requests
00740     // are cleaned up).  As a result, we expect them to exit very
00741     // quickly.
00742     //
00743     // The only real action we could take in the event some thread
00744     // didn't exit would be to terminate it.  TerminateThread is documented
00745     // to be a dangerous function in that it leaks lots of resources, and
00746     // doesn't allow the thread to complete any work it's doing.  As such,
00747     // the remedy would be as bad as the problem - the process would be
00748     // in a potentially unstable state.  Consequently, we'll make no
00749     // attempt to recover from a thread that doesn't exit.
00750     //
00751
00752     dwBlockIndex = 0;
00753     dwThreadsRemaining = g_NumThreads;
00754
00755     while ( dwThreadsRemaining )
00756     {
00757         dwWaitCount =
00758             ( dwThreadsRemaining < MAXIMUM_WAIT_OBJECTS ) ?
00759             dwThreadsRemaining :
00760             MAXIMUM_WAIT_OBJECTS;
00761
00762         WaitForMultipleObjects(
00763             dwWaitCount,
00764             g_pThreads + ( dwBlockIndex * MAXIMUM_WAIT_OBJECTS ),
00765             TRUE,
00766             INFINITE
00767             );
00768
00769         dwThreadsRemaining -= dwWaitCount;
00770         dwBlockIndex++;
00771     }
00772
00773     //
00774     // Close our handles for each thread
00775     //
00776
00777     for ( x = 0; x < g_NumThreads; x++ )
00778     {
00779         CloseHandle( g_pThreads[x] );
00780         g_pThreads[x] = NULL;
00781     }
00782
00783     //
00784     // Finally, deallocate the thread handle storage buffer
00785     //
00786
00787     LocalFree( g_pThreads );
00788     g_pThreads = NULL;
00789
00790 Done:
00791
00792     g_QueueSize = 0;
00793     g_NumThreads = 0;
00794     g_ItemsInQueue = 0;
00795
00796     return;
00797 }
00798
00799 BOOL
00800 QueueRequest(
00801     EXTENSION_CONTROL_BLOCK *   pecb
00802     )
00803 /*++
00804
00805 Purpose:
00806
00807     This function queues a request and signals the pool so that it
00808     can be picked up by the next available thread
00809
00810 Arguments:
00811
00812     pecb - The EXTENSION_CONTROL_BLOCK for the request to be queued
00813
00814 Returns:
00815
00816     TRUE on success, FALSE on failure
00817
00818 --*/
00819 {
00820     LONG    lItems;
00821     BOOL    fResult;
00822
00823     //
00824     // Can't do this if not using the thread pool
00825     //
00826
00827     if ( g_UseThreadPool == FALSE )
00828     {
00829         SetLastError( ERROR_INVALID_PARAMETER );
00830         return FALSE;
00831     }
00832
00833     //
00834     // Increment the number of items in the queue.  If this call
00835     // pushes us over the limit, then back down the count and return
00836     // FALSE
00837     //
00838
00839     lItems = InterlockedIncrement( &g_ItemsInQueue );
00840
00841     if ( lItems > g_QueueSize )
00842     {
00843         InterlockedDecrement( &g_ItemsInQueue );
00844
00845         //
00846         // If we return ERROR_SUCCESS and FALSE, then the caller knows
00847         // that the queue is full.
00848         //
00849
00850         SetLastError( ERROR_SUCCESS );
00851
00852         return FALSE;
00853     }
00854
00855     //
00856     // Post a completion for this action.  This will release a pool
00857     // thread.  Note that we are overloading LPOVERLAPPED to pass
00858     // the EXTENSION_CONTROL_BLOCK to the worker thread.
00859     //
00860
00861     fResult = PostQueuedCompletionStatus(
00862         g_hCompletionPort,
00863         0,
00864         0,
00865         reinterpret_cast<LPOVERLAPPED>( pecb )
00866         );
00867
00868     if ( fResult == FALSE )
00869     {
00870         IsapiWriteLog(
00871             "Failed to post completion.  Error %d.\r\n",
00872             GetLastError()
00873             );
00874
00875         InterlockedDecrement( &g_ItemsInQueue );
00876
00877         return FALSE;
00878     }
00879
00880     return TRUE;
00881 }
00882
00883 DWORD
00884 WINAPI
00885 WorkerThreadProc(
00886     VOID *  pVoid
00887     )
00888 /*++
00889
00890 Purpose:
00891
00892     This function implements the worker thread loop that dispatches
00893     calls to the "real" HttpExtensionProc.
00894
00895 Arguments:
00896
00897     pVoid - Required by CreateThread; not used.
00898
00899 Returns:
00900
00901     Always returns 0
00902
00903 --*/
00904 {
00905     EXTENSION_CONTROL_BLOCK *   pecb;
00906     HANDLE                      hToken = NULL;
00907     DWORD                       cbIo;
00908     DWORD                       dwKey;
00909     DWORD                       dwInitResultCode = ERROR_SUCCESS;
00910     DWORD                       dwThreadId;
00911     DWORD                       dwError;
00912     DWORD                       HseResult;
00913     BOOL                        fInitSuccess = TRUE;
00914     BOOL                        fCompletionResult = TRUE;
00915
00916     dwThreadId = GetCurrentThreadId();
00917
00918     //
00919     // Call the thread initialization function
00920     //
00921
00922     fInitSuccess = InitThread();
00923
00924     if ( fInitSuccess == FALSE )
00925     {
00926         dwInitResultCode = GetLastError();
00927
00928         IsapiWriteLog(
00929             "Attempt to initialized thread %d failed.  Error %d.\r\n",
00930             dwThreadId,
00931             dwInitResultCode
00932             );
00933     }
00934
00935     while ( TRUE )
00936     {
00937         //
00938         // Wait for some work
00939         //
00940
00941         fCompletionResult = GetQueuedCompletionStatus(
00942             g_hCompletionPort,
00943             &cbIo,
00944             &dwKey,
00945             reinterpret_cast<LPOVERLAPPED*>( &pecb ),
00946             INFINITE
00947             );
00948
00949         dwError = GetLastError();
00950
00951         //
00952         // Before doing anything else, back down the queue item count
00953         //
00954
00955         InterlockedDecrement( &g_ItemsInQueue );
00956
00957         if ( fCompletionResult == FALSE )
00958         {
00959             IsapiWriteLog(
00960                 "Thread %d: GetQueuedCompletionStatus failed with error %d. "
00961                 "Thread will terminate.\r\n",
00962                 dwThreadId,
00963                 dwError
00964                 );
00965
00966             break;
00967         }
00968
00969         //
00970         // If pecb is NULL, then we are supposed to exit the thread, else
00971         // we'll process the request.
00972         //
00973
00974         if ( pecb == NULL )
00975         {
00976             break;
00977         }
00978
00979         //
00980         // If the thread initialization failed, return an error to the
00981         // client
00982         //
00983
00984         if ( fInitSuccess == FALSE )
00985         {
00986             SendThreadInitFailed( pecb, dwInitResultCode );
00987             continue;
00988         }
00989
00990         //
00991         // Impersonate the authenticated user
00992         //
00993
00994         pecb->ServerSupportFunction(
00995             pecb->ConnID,
00996             HSE_REQ_GET_IMPERSONATION_TOKEN,
00997             &hToken,
00998             NULL,
00999             NULL
01000             );
01001
01002         ImpersonateLoggedOnUser( &hToken );
01003
01004         //
01005         // Finally, call into the "real" HttpExtensionProc.  If it returns
01006         // HSE_STATUS_PENDING, then we're done.  Otherwise, we'll need to
01007         // call HSE_REQ_DONE_WITH_SESSION and pass along the result.
01008         //
01009         // Note that there is a potential incompatibility with the
01010         // HSE_STATUS_PENDING case.  Specifically, IIS cleans up the ECB in
01011         // such a way that both HttpExtensionProc must return, and
01012         // HSE_REQ_DONE_WITH_SESSION must be called (assuming a pending
01013         // extension) before IIS frees the ECB.
01014         //
01015         // If this wrapper is used with an extension that depends on this
01016         // protection from IIS, then a potential crash could occur in the
01017         // "real" HttpExtensionProc if DONE_WITH_SESSION occurs before it
01018         // returns with HSE_STATUS_PENDING.  This is because the wrapper
01019         // already returned STATUS_PENDING before we get here.  Thus, the
01020         // ECB will get freed immediately upon DONE_WITH_SESSION, even if
01021         // the "real" HttpExtensionProc hasn't returned yet.
01022         //
01023         // This won't be a problem if the "real" HttpExtensionProc doesn't
01024         // touch the ECB after DONE_WITH_SESSION could potentially be
01025         // called.
01026         //
01027         // And just a final note that any extension that already returns
01028         // HSE_STATUS_PENDING is not a good candidate to be wrapped by
01029         // PoolWrap, since it's already asynchronous in nature.
01030         //
01031
01032         HseResult = HttpExtensionProc( pecb );
01033
01034         RevertToSelf();
01035         hToken = NULL;
01036
01037         if ( HseResult == HSE_STATUS_PENDING )
01038         {
01039             continue;
01040         }
01041
01042         pecb->ServerSupportFunction(
01043             pecb->ConnID,
01044             HSE_REQ_DONE_WITH_SESSION,
01045             &HseResult,
01046             NULL,
01047             NULL
01048             );
01049
01050         //
01051         // Done, just let the thread loop around and wait again.
01052         //
01053     }
01054
01055     //
01056     // Uninitialize the thread
01057     //
01058
01059     UninitThread();
01060
01061     return 0;
01062 }
01063
01064 BOOL
01065 IsapiWriteLog(
01066     LPSTR   szString,
01067     ...
01068     )
01069 /*++
01070
01071 Purpose:
01072
01073     This function writes a line to the log for this extension using
01074     printf-style formatting.
01075
01076 Arguments:
01077
01078     szString - The format string
01079     ...      - Additional arguments
01080
01081 Returns:
01082
01083     TRUE on success, FALSE on failure
01084
01085 --*/
01086 {
01087     SYSTEMTIME  st;
01088     CHAR        szCookedString[LOG_MAX_LINE+1];
01089     CHAR        szTime[32];
01090     CHAR        szDate[32];
01091     CHAR        szTimeStamp[64];
01092     INT         cchCookedString;
01093     DWORD       cbToWrite;
01094     va_list     args;
01095     BOOL        fResult;
01096
01097     //
01098     // If we don't have a log file handle, just return
01099     //
01100
01101     if ( g_hLogFile == INVALID_HANDLE_VALUE )
01102     {
01103         SetLastError( ERROR_FILE_NOT_FOUND );
01104         return FALSE;
01105     }
01106
01107     //
01108     // Apply formatting to the string
01109     //
01110
01111     va_start( args, szString );
01112
01113     cchCookedString = _vsnprintf(
01114         szCookedString,
01115         LOG_MAX_LINE,
01116         szString,
01117         args
01118         );
01119
01120     va_end(args);
01121
01122     //
01123     // Generate the time stamp
01124     //
01125
01126     GetLocalTime( &st );
01127
01128   GetTimeFormat(
01129         LOCALE_SYSTEM_DEFAULT,
01130         0,
01131         &st,
01132         "HH':'mm':'ss",
01133         szTime,
01134         32
01135         );
01136
01137   GetDateFormat(
01138         LOCALE_SYSTEM_DEFAULT,
01139         0,
01140         &st,
01141         "ddd',' MMM dd yyyy",
01142         szDate,
01143         32
01144         );
01145
01146     wsprintf( szTimeStamp, "[%s - %s] ", szDate, szTime );
01147
01148     //
01149     // Acquire the lock and write out the log entry
01150     //
01151
01152     EnterCriticalSection( &g_LogFileLock );
01153
01154     SetFilePointer( g_hLogFile, 0, NULL, FILE_END );
01155
01156     cbToWrite = strlen( szTimeStamp );
01157
01158     WriteFile(
01159         g_hLogFile,
01160         szTimeStamp,
01161         cbToWrite,
01162         &cbToWrite,
01163         NULL
01164         );
01165
01166     cbToWrite = cchCookedString;
01167
01168     fResult = WriteFile(
01169         g_hLogFile,
01170         szCookedString,
01171         cbToWrite,
01172         &cbToWrite,
01173         NULL
01174         );
01175
01176     LeaveCriticalSection( &g_LogFileLock );
01177
01178   return fResult;
01179 }
01180
01181 DWORD
01182 SendExtensionInitFailed(
01183     EXTENSION_CONTROL_BLOCK *   pecb
01184     )
01185 /*++
01186
01187 Purpose:
01188
01189     Sends back a message to the client in the event that initialization
01190     of this extension failed.
01191
01192 Arguments:
01193
01194     pecb - Pointer to the EXTENSION_CONTROL_BLOCK for this request
01195
01196 Returns:
01197
01198     HSE_STATUS_ERROR
01199
01200 --*/
01201 {
01202     HSE_SEND_HEADER_EX_INFO HeaderInfo;
01203     CHAR                    szResponse[RESPONSE_MAX_BUFFER+1] = {0};
01204     CHAR                    szHeaders[RESPONSE_MAX_BUFFER+1] = {0};
01205     CHAR                    szDefaultError[64] = {0};
01206     LPSTR                   szTranslatedError = NULL;\
01207     LPSTR                   szError = NULL;
01208     DWORD                   cbToWrite;
01209     DWORD                   cchResponse;
01210     DWORD                   cchError;
01211     BOOL                    fResult;
01212
01213     //
01214     // Build the response and error information
01215     //
01216
01217     _snprintf(
01218         szResponse,
01219         RESPONSE_MAX_BUFFER,
01220         "<html>\r\n"
01221         "<head><title> Extension '%s.dll' not initialized </title></head>\r\n"
01222         "<h1> Extension '%s.dll' Not Initialized. </h1>\r\n"
01223         "Extension '%s.dll' failed to initialize with the following error. "
01224         "Please notify the administrator for this site."
01225         "<hr>\r\n",
01226         MODULE_NAME,
01227         MODULE_NAME,
01228         MODULE_NAME
01229         );
01230
01231     cchResponse = strlen( szResponse );
01232
01233     fResult = AllocateAndFormatErrorMessage(
01234         g_InitResultCode,
01235         &szTranslatedError
01236         );
01237
01238     if ( fResult == FALSE )
01239     {
01240         _snprintf(
01241             szDefaultError,
01242             63,
01243             "%d (0x%08x)\r\n"
01244             "</html>",
01245             g_InitResultCode,
01246             g_InitResultCode
01247             );
01248
01249         szError = szDefaultError;
01250     }
01251     else
01252     {
01253         szError = szTranslatedError;
01254     }
01255
01256     cchError = strlen( szError );
01257
01258     //
01259     // Send the response to the client
01260     //
01261
01262     _snprintf(
01263         szHeaders,
01264         RESPONSE_MAX_BUFFER,
01265         "Content-Type: text/html\r\n"
01266         "Content-Length: %d\r\n"
01267         "\r\n",
01268         cchResponse + cchError
01269         );
01270
01271     HeaderInfo.pszStatus = "500 Server Error";
01272     HeaderInfo.pszHeader = szHeaders;
01273     HeaderInfo.cchStatus = strlen( HeaderInfo.pszStatus );
01274     HeaderInfo.cchHeader = strlen( HeaderInfo.pszHeader );
01275     HeaderInfo.fKeepConn = TRUE;
01276
01277     pecb->ServerSupportFunction(
01278         pecb->ConnID,
01279         HSE_REQ_SEND_RESPONSE_HEADER_EX,
01280         &HeaderInfo,
01281         NULL,
01282         NULL
01283         );
01284
01285     cbToWrite = cchResponse;
01286
01287     pecb->WriteClient(
01288         pecb->ConnID,
01289         szResponse,
01290         &cbToWrite,
01291         HSE_IO_SYNC
01292         );
01293
01294     cbToWrite = cchError;
01295
01296     pecb->WriteClient(
01297         pecb->ConnID,
01298         szError,
01299         &cbToWrite,
01300         HSE_IO_SYNC
01301         );
01302
01303     //
01304     // Clean up the formatted error if we got it
01305     //
01306
01307     if ( szTranslatedError != NULL )
01308     {
01309         LocalFree( szTranslatedError );
01310         szTranslatedError = NULL;
01311     }
01312
01313     return HSE_STATUS_ERROR;
01314 }
01315
01316 DWORD
01317 SendQueueFull(
01318     EXTENSION_CONTROL_BLOCK *   pecb
01319     )
01320 /*++
01321
01322 Purpose:
01323
01324     Sends back a "too busy" message to the client.  Note that
01325     all of the parts of the response were created at extension
01326     init time, so that we can just blast the result back to the
01327     client (since presumably, the server is really busy when
01328     this function is called.)
01329
01330 Arguments:
01331
01332     pecb - Pointer to the EXTENSION_CONTROL_BLOCK for this request
01333
01334 Returns:
01335
01336     HSE_STATUS_ERROR
01337
01338 --*/
01339 {
01340     HSE_SEND_HEADER_EX_INFO HeaderInfo;
01341     DWORD                   cbToWrite;
01342
01343     InterlockedIncrement( &g_QueueFullPages );
01344
01345     HeaderInfo.pszStatus = "500 Server Error";
01346     HeaderInfo.cchStatus = 16; // length of "500 Server Error"
01347     HeaderInfo.pszHeader = g_QueueFullHeaders;
01348     HeaderInfo.cchHeader = g_cchQueueFullHeaders;
01349     HeaderInfo.fKeepConn = TRUE;
01350
01351     cbToWrite = g_cchQueueFullResponse;
01352
01353     pecb->ServerSupportFunction(
01354         pecb->ConnID,
01355         HSE_REQ_SEND_RESPONSE_HEADER_EX,
01356         &HeaderInfo,
01357         NULL,
01358         NULL
01359         );
01360
01361     pecb->WriteClient(
01362         pecb->ConnID,
01363         g_QueueFullResponse,
01364         &cbToWrite,
01365         HSE_IO_SYNC
01366         );
01367
01368     return HSE_STATUS_ERROR;
01369 }
01370
01371 BOOL
01372 SendThreadInitFailed(
01373     EXTENSION_CONTROL_BLOCK *   pecb,
01374     DWORD                       dwError
01375     )
01376 /*++
01377
01378 Purpose:
01379
01380     Sends a response back to the client indicating that the
01381     thread failed to initialize.
01382
01383 Arguments:
01384
01385     pecb     - Pointer to the EXTENSION_CONTROL_BLOCK for the request
01386     dwError  - The initialization error
01387
01388 Returns:
01389
01390     TRUE on success, FALSE on failure
01391
01392 --*/
01393 {
01394     HSE_SEND_HEADER_EX_INFO HeaderInfo;
01395     CHAR                    szResponse[RESPONSE_MAX_BUFFER+1] = {0};
01396     CHAR                    szHeaders[RESPONSE_MAX_BUFFER+1] = {0};
01397     CHAR                    szDefaultError[64] = {0};
01398     LPSTR                   szTranslatedError = NULL;\
01399     LPSTR                   szError = NULL;
01400     DWORD                   cbToWrite;
01401     DWORD                   cchResponse;
01402     DWORD                   cchError;
01403     DWORD                   HseResult;
01404     BOOL                    fResult;
01405
01406     //
01407     // Build the response and error information
01408     //
01409
01410     _snprintf(
01411         szResponse,
01412         RESPONSE_MAX_BUFFER,
01413         "<html>\r\n"
01414         "<head><title> Extension '%s.dll' error. </title></head>\r\n"
01415         "<h1> Extension '%s.dll' failed to fully initialize. </h1>\r\n"
01416         "Extension '%s.dll': Thread %d failed to initialize with the "
01417         "following error.  Please notify the administrator for this site."
01418         "<hr>\r\n",
01419         MODULE_NAME,
01420         MODULE_NAME,
01421         MODULE_NAME,
01422         GetCurrentThreadId()
01423         );
01424
01425     cchResponse = strlen( szResponse );
01426
01427     fResult = AllocateAndFormatErrorMessage(
01428         dwError,
01429         &szTranslatedError
01430         );
01431
01432     if ( fResult == FALSE )
01433     {
01434         _snprintf(
01435             szDefaultError,
01436             63,
01437             "%d (0x%08x)\r\n"
01438             "</html>",
01439             dwError,
01440             dwError
01441             );
01442
01443         szError = szDefaultError;
01444     }
01445     else
01446     {
01447         szError = szTranslatedError;
01448     }
01449
01450     cchError = strlen( szError );
01451
01452     //
01453     // Send the response to the client
01454     //
01455
01456     _snprintf(
01457         szHeaders,
01458         RESPONSE_MAX_BUFFER,
01459         "Content-Type: text/html\r\n"
01460         "Content-Length: %d\r\n"
01461         "\r\n",
01462         cchResponse + cchError
01463         );
01464
01465     HeaderInfo.pszStatus = "500 Server Error";
01466     HeaderInfo.pszHeader = szHeaders;
01467     HeaderInfo.cchStatus = strlen( HeaderInfo.pszStatus );
01468     HeaderInfo.cchHeader = strlen( HeaderInfo.pszHeader );
01469     HeaderInfo.fKeepConn = TRUE;
01470
01471     pecb->ServerSupportFunction(
01472         pecb->ConnID,
01473         HSE_REQ_SEND_RESPONSE_HEADER_EX,
01474         &HeaderInfo,
01475         NULL,
01476         NULL
01477         );
01478
01479     cbToWrite = cchResponse;
01480
01481     pecb->WriteClient(
01482         pecb->ConnID,
01483         szResponse,
01484         &cbToWrite,
01485         HSE_IO_SYNC
01486         );
01487
01488     cbToWrite = cchError;
01489
01490     pecb->WriteClient(
01491         pecb->ConnID,
01492         szError,
01493         &cbToWrite,
01494         HSE_IO_SYNC
01495         );
01496
01497     //
01498     // Since this error is always called on pending request,
01499     // we need to call DONE_WITH_SESSION
01500     //
01501
01502     HseResult = HSE_STATUS_ERROR;
01503
01504     pecb->ServerSupportFunction(
01505         pecb->ConnID,
01506         HSE_REQ_DONE_WITH_SESSION,
01507         &HseResult,
01508         NULL,
01509         NULL
01510         );
01511
01512     //
01513     // Clean up the formatted error if we got it
01514     //
01515
01516     if ( szTranslatedError != NULL )
01517     {
01518         LocalFree( szTranslatedError );
01519         szTranslatedError = NULL;
01520     }
01521
01522     return TRUE;
01523 }
01524
01525 BOOL
01526 AllocateAndFormatErrorMessage(
01527     DWORD   dwError,
01528     LPSTR * ppBuffer
01529     )
01530 /*++
01531
01532 Purpose:
01533
01534     Maps an error code into a text message into a new buffer.
01535     The caller needs to free the buffer with LocalFree when done.
01536
01537 Arguments:
01538
01539     dwError  - The error to map.
01540     ppBuffer - Upon successful return, the error text buffer
01541
01542 Returns:
01543
01544     TRUE on success, FALSE on failure
01545
01546 --*/
01547 {
01548     BOOL    fResult;
01549
01550     fResult = FormatMessage(
01551         FORMAT_MESSAGE_ALLOCATE_BUFFER |
01552         FORMAT_MESSAGE_IGNORE_INSERTS |
01553         FORMAT_MESSAGE_FROM_SYSTEM,
01554         NULL,
01555         dwError,
01556         0,
01557         reinterpret_cast<CHAR*>( ppBuffer ),
01558         0,
01559         NULL
01560         );
01561
01562     IsapiWriteLog(
01563         "FormatMessage failed. Error %d.\r\n",
01564         GetLastError()
01565         );
01566
01567     return fResult;
01568 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/pchsample.h Source File

  • NetDS
  • RRas
  • ip

pchsample.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\pchsample.h
00008
00009 Abstract:
00010
00011     The file contains precompiled header for PIM-SM
00012
00013 --*/
00014
00015 #ifndef _PCHSAMPLE_H_
00016 #define _PCHSAMPLE_H_
00017
00018 // DO NOT CHANGE ORDER UNLESS YOU KNOW WHAT YOU ARE DOING
00019
00020 //#include <windows.h>            // Include file for Windows applications
00021
00022 #undef FD_SETSIZE
00023 #define FD_SETSIZE  256         // Max sockets a WinSock application can use
00024 #include <winsock2.h>           // Interface to WinSock 2 API
00025 #include <ws2tcpip.h>           // WinSock 2 Extension for TCP/IP protocols
00026
00027 #include <routprot.h>           // Interface to Router Manager
00028 #include <rtmv2.h>              // Interface to Routing Table Manager v2
00029 #include <iprtrmib.h>           // MIB variables handled by Router Manager
00030 #include <mgm.h>                // Interface to Multicast Group Manager
00031
00032 #include <mprerror.h>           // Router specific error codes
00033 #include <rtutils.h>            // Utility functions (Log, Trace, ...)
00034
00035 #include <stdio.h>
00036 #include <wchar.h>
00037
00038 #include "ipsamplerm.h"
00039
00040 #include "list.h"               // List Implementation
00041 #include "hashtable.h"          // HashTable Implementation
00042 #include "sync.h"               // ReadWriteLock, LockedList Implementation
00043
00044 #include "log.h"                // Localizable log messages
00045 #include "defs.h"               // IPADDRESS, Memory, Trace, Log
00046 #include "utils.h"              // Utilities
00047
00048 #include "packet.h"             // Packet implementation
00049 #include "socket.h"             // Socket Functions
00050 #include "networkentry.h"
00051 #include "networkmgr.h"
00052 #include "configentry.h"
00053 #include "configmgr.h"
00054 #include "mibmgr.h"
00055
00056 #include "rtmapi.h"
00057 #include "rtmapi.h"
00058
00059 #endif // _PCHSAMPLE_H_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/upnp/GenericUCP/CPP/resource.h Source File

  • NetDS
  • upnp
  • GenericUCP
  • CPP

resource.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation
00004
00005
00006 --*/
00007 //{{NO_DEPENDENCIES}}
00008 // Microsoft Developer Studio generated include file.
00009 // Used by GenericUCP.rc
00010 //
00011 #define IDM_ABOUTBOX                    0x0010
00012 #define IDD_ABOUTBOX                    100
00013 #define IDS_ABOUTBOX                    101
00014 #define IDD_GENERICUCP_DIALOG           102
00015 #define IDR_MAINFRAME                   128
00016 #define IDR_MENUGC                      130
00017 #define IDD_DEVPROP_DIALOG              139
00018 #define IDC_COMBOFIND                   1001
00019 #define IDC_COMBODEVICE                 1002
00020 #define IDC_COMBOSERVICE                1003
00021 #define IDC_INVOKEACTION                1032
00022 #define IDC_CLOSE                       1033
00023 #define IDC_QUERYVARIABLE               1034
00024 #define IDC_VIEWSCPD                    1035
00025 #define IDC_PRESENTATION                1036
00026 #define IDC_DEVPROP                     1037
00027 #define IDC_DISCOVERY                   1038
00028 #define IDC_SCPDURL                     1039
00029 #define IDC_ACTIONOUTARGUMENT           1040
00030 #define IDC_ACTIONINARGUMENT            1041
00031 #define IDC_FINDBYTYPE                  1042
00032 #define IDC_FINDBYUDN                   1043
00033 #define IDC_ASYNCFIND                   1044
00034 #define IDC_ACTIONNAME                  1045
00035 #define IDC_STATUS                      1046
00036 #define IDC_EVENTS                      1047
00037 #define IDC_EDITSERIALNUMBER            1048
00038 #define IDC_VARIABLENAME                1048
00039 #define IDC_EDITUPC                     1049
00040 #define IDC_EDITMODELURL                1050
00041 #define IDC_EDITMODELDESCRIPTION        1051
00042 #define IDC_EDITMODELNUMBER             1052
00043 #define IDC_EDITMODELNAME               1053
00044 #define IDC_EDITMANUFACTURERURL         1054
00045 #define IDC_EDITMANUFACTURER            1055
00046 #define IDC_EDITPRESENTATIONURL         1056
00047 #define IDC_EDITDEVICETYPE              1057
00048 #define IDC_EDITFRIENDLYNAME            1058
00049 #define IDC_EDITUDN                     1059
00050 #define IDC_OK                          1060
00051
00052 // Next default values for new objects
00053 //
00054 #ifdef APSTUDIO_INVOKED
00055 #ifndef APSTUDIO_READONLY_SYMBOLS
00056 #define _APS_NEXT_RESOURCE_VALUE        140
00057 #define _APS_NEXT_COMMAND_VALUE         32774
00058 #define _APS_NEXT_CONTROL_VALUE         1061
00059 #define _APS_NEXT_SYMED_VALUE           106
00060 #endif
00061 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSet Member List

This is the complete list of members for CSet, including all inherited members.
In(WORD iChar)=0 CSet [pure virtual]
Generated on Wed Nov 13 2024 16:57:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/DoServer/OLEObj.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • DoServer

OLEObj.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /**************************************************************************
00019
00020   File:          OleObj.h
00021
00022   Description:   COleObject definitions.
00023
00024 **************************************************************************/
00025
00026 #ifndef OLEOBJECT_H
00027 #define OLEOBJECT_H
00028
00029 /**************************************************************************
00030 #include statements
00031 **************************************************************************/
00032
00033 #include "DOServer.h"
00034
00035 /**************************************************************************
00036
00037   COleObject class definition
00038
00039 **************************************************************************/
00040
00041 class COleDocument;
00042
00043 class COleObject : public IOleObject
00044 {
00045 private:
00046   COleDocument   *m_pOleDoc;
00047   BOOL           m_fOpen;
00048
00049 public:
00050   COleObject::COleObject(COleDocument *pOleDoc);
00051   COleObject::~COleObject();
00052
00053   //IUnknown methods
00054   STDMETHODIMP QueryInterface(REFIID, LPVOID*);
00055   STDMETHODIMP_(ULONG) AddRef();
00056   STDMETHODIMP_(ULONG) Release();
00057
00058   //IOleObject methods
00059   STDMETHODIMP SetClientSite(LPOLECLIENTSITE);
00060   STDMETHODIMP Advise(LPADVISESINK, LPDWORD);
00061   STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR);
00062   STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
00063   STDMETHODIMP GetExtent(DWORD, LPSIZEL);
00064   STDMETHODIMP Update();
00065   STDMETHODIMP Close(DWORD);
00066   STDMETHODIMP Unadvise(DWORD);
00067   STDMETHODIMP EnumVerbs(LPENUMOLEVERB*);
00068   STDMETHODIMP GetClientSite(LPOLECLIENTSITE*);
00069   STDMETHODIMP SetMoniker(DWORD, LPMONIKER);
00070   STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER*);
00071   STDMETHODIMP InitFromData(LPDATAOBJECT, BOOL, DWORD);
00072   STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT*);
00073   STDMETHODIMP IsUpToDate();
00074   STDMETHODIMP GetUserClassID(CLSID*);
00075   STDMETHODIMP GetUserType(DWORD, LPOLESTR*);
00076   STDMETHODIMP SetExtent(DWORD, LPSIZEL);
00077   STDMETHODIMP EnumAdvise(LPENUMSTATDATA*);
00078   STDMETHODIMP GetMiscStatus(DWORD, LPDWORD);
00079   STDMETHODIMP SetColorScheme(LPLOGPALETTE);
00080
00081 };
00082
00083 #endif   //OLEOBJECT_H
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/stdpal.h Source File

  • Com
  • Fundamentals
  • OleStd

stdpal.h

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------
00002 |   stdpal.h
00003 |
00004 |   Standard App Palette useful for OLE applications.  v 1.01
00005 |
00006 |   #include this file in the same file as HpalCreateAppPalette
00007 |
00008 |   NOTE:  Palette MUST be created with HpalCreateAppPalette
00009 |
00010 |   Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 |
00012 -----------------------------------------------------------------------*/
00013
00014
00015 #ifndef CSCONST
00016 #if (defined(FLAT) || defined(__TURBOC__))
00017 #define CSCONST(type) type const
00018 #else
00019 #define CSCONST(type) type _based(_segname("_CODE")) const
00020 #endif
00021 #endif
00022
00023 CSCONST(unsigned char) palSVGA[256][3] =
00024   {
00025   // R     G     B
00026   {0x00, 0x00, 0x00}, // 0 Sys Black  gray 0
00027   {0x80, 0x00, 0x00}, // 1 Sys Dk Red
00028   {0x00, 0x80, 0x00}, // 2 Sys Dk Green
00029   {0x80, 0x80, 0x00}, // 3 Sys Dk Yellow
00030   {0x00, 0x00, 0x80}, // 4 Sys Dk Blue
00031   {0x80, 0x00, 0x80}, // 5 Sys Dk Violet
00032   {0x00, 0x80, 0x80}, // 6 Sys Dk Cyan
00033   {0xc0, 0xc0, 0xc0}, // 7 Sys Lt Grey    gray 192
00034   {0xc0, 0xdc, 0xc0}, // 8 Sys 8
00035   {0xa6, 0xca, 0xf0}, // 9 Sys 9 (the first 10 are fixed by Windows)
00036
00037   {0x80, 0x00, 0x00}, // 10 Sys Dk Red repeat
00038   {0x00, 0x80, 0x00}, // 11 Sys Dk Green repeat
00039   {0x80, 0x80, 0x00}, // 12 Sys Dk Yellow repeat
00040   {0x00, 0x00, 0x80}, // 13 Sys Dk Blue repeat
00041   {0x80, 0x00, 0x80}, // 14 Sys Dk Violet repeat
00042   {0x00, 0x80, 0x80}, // 15 Sys Dk Cyan repeat
00043   {0x80, 0x80, 0x80}, // 16 Sys Dk Grey repeat    gray 128
00044   {0x80, 0x80, 0xff}, // 17 Excel Chart Fill 1
00045   {0x80, 0x20, 0x60}, // 18 Excel Chart Fill 2
00046   {0xff, 0xff, 0xc0}, // 19 Excel Chart Fill 3
00047   {0xa0, 0xe0, 0xe0}, // 20 Excel Chart Fill 4
00048   {0x60, 0x00, 0x80}, // 21 Excel Chart Fill 4
00049   {0xff, 0x80, 0x80}, // 22 Excel Chart Fill 6
00050   {0x00, 0x80, 0xc0}, // 23 Excel Chart Fill 7
00051   {0xc0, 0xc0, 0xff}, // 24 Excel Chart Fill 8
00052   {0x00, 0xcf, 0xff}, // 25 Excel clrt entry
00053   {0x69, 0xff, 0xff}, // 26 Excel clrt entry
00054   {0xe0, 0xff, 0xe0}, // 27 Excel clrt entry
00055   {0xdd, 0x9c, 0xb3}, // 28 Excel clrt entry
00056   {0xb3, 0x8f, 0xee}, // 29 Excel clrt entry
00057   {0x2a, 0x6f, 0xf9}, // 30 Excel clrt entry
00058   {0x3f, 0xb8, 0xcd}, // 31 Excel clrt entry
00059   {0x48, 0x84, 0x36}, // 32 Excel clrt entry
00060   {0x95, 0x8c, 0x41}, // 33 Excel clrt entry
00061   {0x8e, 0x5e, 0x42}, // 34 Excel clrt entry
00062   {0xa0, 0x62, 0x7a}, // 35 Excel clrt entry
00063   {0x62, 0x4f, 0xac}, // 36 Excel clrt entry
00064   {0x1d, 0x2f, 0xbe}, // 37 Excel clrt entry
00065   {0x28, 0x66, 0x76}, // 38 Excel clrt entry
00066   {0x00, 0x45, 0x00}, // 39 Excel clrt entry
00067   {0x45, 0x3e, 0x01}, // 40 Excel clrt entry
00068   {0x6a, 0x28, 0x13}, // 41 Excel clrt entry
00069   {0x85, 0x39, 0x6a}, // 42 Excel clrt entry
00070   {0x4a, 0x32, 0x85}, // 43 Excel clrt entry
00071   {0x04, 0x04, 0x04}, // 44   gray 4
00072   {0x08, 0x08, 0x08}, // 45   gray 8
00073   {0x0c, 0x0c, 0x0c}, // 46   gray 12
00074   {0x11, 0x11, 0x11}, // 47   gray 17
00075   {0x16, 0x16, 0x16}, // 48   gray 22
00076   {0x1c, 0x1c, 0x1c}, // 49   gray 28
00077   {0x22, 0x22, 0x22}, // 50   gray 34
00078   {0x29, 0x29, 0x29}, // 51   gray 41
00079   {0x30, 0x30, 0x30}, // 52   gray 48
00080   {0x5f, 0x5f, 0x5f}, // 53 swapped so inversions look good   gray 95
00081   {0x55, 0x55, 0x55}, // 54 swapped so inversions look good   gray 85
00082   {0x4d, 0x4d, 0x4d}, // 55 swapped so inversions look good   gray 77
00083   {0x42, 0x42, 0x42}, // 56 swapped so inversions look good   gray 66
00084   {0x39, 0x39, 0x39}, // 57 swapped so inversions look good   gray 57
00085   {0x00, 0x07, 0x00}, // 58
00086   {0x0d, 0x00, 0x00}, // 59
00087   {0xb7, 0x99, 0x81}, // 60
00088   {0x84, 0x99, 0xb4}, // 61
00089   {0xbd, 0xbd, 0x90}, // 62
00090   {0x7f, 0x7f, 0x60}, // 63
00091   {0x60, 0x60, 0x7f}, // 64
00092   {0x00, 0x0e, 0x00}, // 65
00093   {0x1b, 0x00, 0x00}, // 66
00094   {0x28, 0x00, 0x00}, // 67
00095   {0x08, 0x09, 0x2b}, // 68
00096   {0x00, 0x1d, 0x00}, // 69
00097   {0x39, 0x00, 0x00}, // 70
00098   {0x00, 0x00, 0x9b}, // 71
00099   {0x00, 0x25, 0x00}, // 72
00100   {0x49, 0x00, 0x00}, // 73
00101   {0x11, 0x11, 0x3b}, // 74
00102   {0x00, 0x2f, 0x00}, // 75
00103   {0x5d, 0x00, 0x00}, // 76
00104   {0x17, 0x17, 0x45}, // 77
00105   {0x00, 0x3a, 0x00}, // 78
00106   {0x49, 0x11, 0x11}, // 79
00107   {0x1c, 0x1c, 0x53}, // 80
00108   {0x00, 0x16, 0xff}, // 81
00109   {0x2b, 0x00, 0xff}, // 82
00110   {0x21, 0x21, 0x6c}, // 83
00111   {0x59, 0x14, 0x14}, // 84
00112   {0x00, 0x51, 0x00}, // 85
00113   {0x47, 0x1a, 0x6a}, // 86
00114   {0x19, 0x32, 0x67}, // 87
00115   {0x00, 0x61, 0x00}, // 88
00116   {0x00, 0x31, 0xff}, // 89
00117   {0x61, 0x00, 0xff}, // 90
00118   {0x53, 0x20, 0x7b}, // 91
00119   {0x16, 0x43, 0x67}, // 92
00120   {0x2e, 0x2e, 0xe2}, // 93
00121   {0x26, 0x59, 0x16}, // 94
00122   {0x51, 0x46, 0x04}, // 95
00123   {0x68, 0x2e, 0x49}, // 96
00124   {0x07, 0x52, 0x8f}, // 97
00125   {0x6a, 0x18, 0xb8}, // 98
00126   {0x90, 0x23, 0x15}, // 99
00127   {0x00, 0x53, 0xff}, // 100
00128   {0xa3, 0x00, 0xff}, // 101
00129   {0x6a, 0x4a, 0x12}, // 102
00130   {0x75, 0x33, 0x6c}, // 103
00131   {0x4a, 0x41, 0x9a}, // 104
00132   {0x37, 0x65, 0x0b}, // 105
00133   {0xa4, 0x2c, 0x15}, // 106
00134   {0x83, 0x1f, 0xb1}, // 107
00135   {0x4e, 0x2c, 0xff}, // 108
00136   {0x20, 0x51, 0xb6}, // 109
00137   {0x08, 0x64, 0x92}, // 110
00138   {0x6f, 0x56, 0x0b}, // 111
00139   {0x59, 0x43, 0xad}, // 112
00140   {0x36, 0x72, 0x12}, // 113
00141   {0xb0, 0x33, 0x17}, // 114
00142   {0x00, 0xa1, 0x00}, // 115
00143   {0x77, 0x5f, 0x1f}, // 116
00144   {0x89, 0x47, 0x71}, // 117
00145   {0xb0, 0x43, 0x1c}, // 118
00146   {0xb7, 0x2d, 0x7d}, // 119
00147   {0x00, 0x86, 0x95}, // 120
00148   {0x7a, 0x6e, 0x23}, // 121
00149   {0x26, 0x9f, 0x00}, // 122
00150   {0x73, 0xa9, 0x01}, // 123
00151   {0x00, 0x00, 0x00}, // 124 free 0   gray 0
00152   {0x00, 0x00, 0x00}, // 125 free 2   gray 0
00153   {0x00, 0x00, 0x00}, // 126 free 4   gray 0
00154   {0x00, 0x00, 0x00}, // 127 free 6   gray 0
00155   {0x00, 0x00, 0x00}, // 128 free 7   gray 0
00156   {0x00, 0x00, 0x00}, // 129 free 5   gray 0
00157   {0x00, 0x00, 0x00}, // 130 free 3   gray 0
00158   {0x00, 0x00, 0x00}, // 131 free 1   gray 0
00159   {0x00, 0xca, 0x00}, // 132
00160   {0xac, 0x5b, 0x01}, // 133
00161   {0x20, 0x1d, 0xc2}, // 134
00162   {0x94, 0x52, 0x70}, // 135
00163   {0x24, 0xaa, 0x4c}, // 136
00164   {0x0a, 0x94, 0x89}, // 137
00165   {0x36, 0x6e, 0x7b}, // 138
00166   {0x44, 0x75, 0x90}, // 139
00167   {0xff, 0x00, 0xa8}, // 140
00168   {0x00, 0x71, 0xff}, // 141
00169   {0xdf, 0x00, 0xff}, // 142
00170   {0x56, 0x91, 0x4a}, // 143
00171   {0x34, 0x48, 0xf8}, // 144
00172   {0xcc, 0x32, 0x82}, // 145
00173   {0xe4, 0x41, 0x70}, // 146
00174   {0x68, 0xca, 0x01}, // 147
00175   {0x36, 0xbc, 0x42}, // 148
00176   {0x00, 0x9a, 0xff}, // 149
00177   {0x96, 0x22, 0xb7}, // 150
00178   {0x85, 0x7d, 0x33}, // 151
00179   {0x25, 0xb7, 0x8c}, // 152
00180   {0x36, 0x5a, 0xed}, // 153
00181   {0x5c, 0xff, 0x00}, // 154
00182   {0xff, 0x48, 0x00}, // 155
00183   {0x22, 0x9b, 0xa2}, // 156
00184   {0x42, 0xcf, 0x4d}, // 157
00185   {0xc2, 0x58, 0x52}, // 158
00186   {0x20, 0xd3, 0x95}, // 159
00187   {0xa5, 0x24, 0xe0}, // 160
00188   {0x73, 0x56, 0xb5}, // 161
00189   {0xa9, 0xa9, 0x00}, // 162
00190   {0xd0, 0x6f, 0x3c}, // 163
00191   {0x67, 0x9f, 0x58}, // 164
00192   {0x89, 0xcf, 0x0b}, // 165
00193   {0xff, 0xac, 0x00}, // 166
00194   {0xa7, 0x2e, 0xfe}, // 167
00195   {0xe2, 0x59, 0x7f}, // 168
00196   {0x4c, 0xdc, 0x67}, // 169
00197   {0xff, 0x18, 0xff}, // 170
00198   {0x3a, 0x7d, 0xff}, // 171
00199   {0xb1, 0xd0, 0x18}, // 172
00200   {0xc7, 0xff, 0x00}, // 173
00201   {0xff, 0xe2, 0x00}, // 174
00202   {0xdf, 0x9a, 0x3d}, // 175
00203   {0x56, 0x81, 0x9f}, // 176
00204   {0xc6, 0x43, 0xba}, // 177
00205   {0xaf, 0x71, 0x8b}, // 178
00206   {0x38, 0xa2, 0xc9}, // 179
00207   {0xd1, 0x53, 0xce}, // 180
00208   {0xff, 0x9a, 0x65}, // 181
00209   {0x46, 0xca, 0xdb}, // 182
00210   {0xff, 0x4d, 0xff}, // 183
00211   {0xc8, 0xe9, 0x6a}, // 184
00212   {0x4c, 0xde, 0xe0}, // 185
00213   {0xff, 0x98, 0xff}, // 186
00214   {0xdf, 0xc0, 0x82}, // 187
00215   {0xe9, 0xec, 0xa5}, // 188
00216   {0xf5, 0xf6, 0xcd}, // 189
00217   {0xff, 0xd0, 0xff}, // 190
00218   {0xb1, 0xac, 0x5a}, // 191
00219   {0x63, 0x91, 0xae}, // 192
00220   {0x22, 0x4c, 0x65}, // 193
00221   {0x8d, 0x4e, 0x3f}, // 194
00222   {0x50, 0x70, 0x70}, // 195
00223   {0xd0, 0xff, 0xff}, // 196
00224   {0xff, 0xe7, 0xff}, // 197
00225   {0x69, 0x69, 0x69}, // 198  gray 105
00226   {0x77, 0x77, 0x77}, // 199  gray 119
00227   {0x86, 0x86, 0x86}, // 200  gray 134
00228   {0x96, 0x96, 0x96}, // 201  gray 150
00229   {0x9d, 0x9d, 0x9d}, // 202  gray 157
00230   {0xa4, 0xa4, 0xa4}, // 203  gray 164
00231   {0xb2, 0xb2, 0xb2}, // 204  gray 178
00232   {0xcb, 0xcb, 0xcb}, // 205  gray 203
00233   {0xd7, 0xd7, 0xd7}, // 206  gray 215
00234   {0xdd, 0xdd, 0xdd}, // 207  gray 221
00235   {0xe3, 0xe3, 0xe3}, // 208  gray 227
00236   {0xea, 0xea, 0xea}, // 209  gray 234
00237   {0xf1, 0xf1, 0xf1}, // 210  gray 241
00238   {0xf8, 0xf8, 0xf8}, // 211  gray 248
00239   {0xb2, 0xc1, 0x66}, // 212
00240   {0x80, 0xbf, 0x78}, // 213
00241   {0xc6, 0xf0, 0xf0}, // 214
00242   {0xb2, 0xa4, 0xff}, // 215
00243   {0xff, 0xb3, 0xff}, // 216
00244   {0xd1, 0x8e, 0xa3}, // 217
00245   {0xc3, 0xdc, 0x37}, // 218
00246   {0xa0, 0x9e, 0x54}, // 219
00247   {0x76, 0xae, 0x70}, // 220
00248   {0x78, 0x9e, 0xc1}, // 221
00249   {0x83, 0x64, 0xbf}, // 222
00250   {0xa4, 0x83, 0xd3}, // 223
00251   {0xd1, 0x3f, 0x32}, // 224
00252   {0xff, 0x7d, 0x00}, // 225
00253   {0x44, 0x78, 0x23}, // 226
00254   {0x24, 0x5f, 0x60}, // 227
00255   {0x0e, 0x0e, 0x2c}, // 228
00256   {0xbe, 0x00, 0x00}, // 229
00257   {0xff, 0x1f, 0x00}, // 230
00258   {0x31, 0x39, 0x00}, // 231
00259   {0xd9, 0x85, 0x3e}, // 232
00260   {0x02, 0x77, 0x85}, // 233
00261   {0xb0, 0xd8, 0x81}, // 234
00262   {0x56, 0x21, 0x1d}, // 235
00263   {0x00, 0x00, 0x30}, // 236
00264   {0x88, 0xc8, 0xb3}, // 237
00265   {0xa0, 0x79, 0x00}, // 238
00266   {0xc0, 0xc0, 0xc0}, // 239 Sys Dk Grey repeat inversion gray 192
00267   {0xea, 0x70, 0x81}, // 240
00268   {0x51, 0xf1, 0x69}, // 241
00269   {0xff, 0xff, 0x80}, // 242
00270   {0x91, 0x74, 0xcd}, // 243
00271   {0xff, 0x7c, 0xff}, // 244
00272   {0xa2, 0xff, 0xff}, // 245
00273
00274   {0xff, 0xfb, 0xf0}, // 246 Sys Reserved
00275   {0xa0, 0xa0, 0xa4}, // 247 Sys Reserved
00276   {0x80, 0x80, 0x80}, // 248 Sys Lt Gray  gray 128
00277   {0xff, 0x00, 0x00}, // 249 Sys Red
00278   {0x00, 0xff, 0x00}, // 250 Sys Green
00279   {0xff, 0xff, 0x00}, // 251 Sys Yellow
00280   {0x00, 0x00, 0xff}, // 252 Sys Blue
00281   {0xff, 0x00, 0xff}, // 253 Sys Violet
00282   {0x00, 0xff, 0xff}, // 254 Sys Cyan
00283   {0xff, 0xff, 0xff} // 255 Sys White gray 255
00284   };
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/Xmit/Xmitu.h Source File

  • NetDS
  • RPC
  • Data
  • Xmit

Xmitu.h

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                         xmit Example
00005
00006     FILE:       xmitu.h
00007
00008     PURPOSE:    Function prototypes for functions in xmitu.c
00009
00010 ****************************************************************************/
00011
00012 #ifndef _XMITU_H_
00013 #define _XMITU_H_
00014
00015
00016 DOUBLE_LINK_TYPE *
00017 InsertNewNode(
00018     short sValue,
00019     DOUBLE_LINK_TYPE * pPrevious
00020     );
00021
00022 void
00023 ArrayWalkProc(
00024     DOUBLE_XMIT_TYPE * pArray
00025     );
00026
00027 void
00028 ListWalkProc(
00029     DOUBLE_LINK_TYPE * pList
00030     );
00031
00032
00033 void __RPC_USER
00034 DOUBLE_LINK_TYPE_to_xmit(
00035      DOUBLE_LINK_TYPE __RPC_FAR *             pList,
00036      DOUBLE_XMIT_TYPE __RPC_FAR * __RPC_FAR * ppArray
00037      );
00038
00039 void __RPC_USER
00040 DOUBLE_LINK_TYPE_from_xmit(
00041      DOUBLE_XMIT_TYPE __RPC_FAR * pArray,
00042      DOUBLE_LINK_TYPE __RPC_FAR * pList);
00043
00044 void __RPC_USER
00045 DOUBLE_LINK_TYPE_free_inst(
00046     DOUBLE_LINK_TYPE __RPC_FAR * pList
00047     );
00048
00049 void __RPC_USER
00050 DOUBLE_LINK_TYPE_free_xmit(
00051     DOUBLE_XMIT_TYPE __RPC_FAR * pArray
00052     );
00053
00054
00055 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len);
00056
00057 void __RPC_USER midl_user_free(void __RPC_FAR * ptr);
00058
00059
00060 #endif
00061
00062 /* end file xmitu.h */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/StringFormatEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

StringFormatEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: StringFormatEnum
00019
00020 public class StringFormatEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adClipString = 2;
00023 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PRTDATA Member List

This is the complete list of members for _PRTDATA, including all inherited members.
bFit2Wnd | _PRTDATA
hMetaf | _PRTDATA
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Pipes/LocalServer/component.hxx Source File

  • Com
  • Fundamentals
  • Pipes
  • LocalServer

component.hxx

Go to the documentation of this file.
00001 #include "ISimpleInterface.h"
00002 #include <objbase.h>
00003 #include <iostream.h>
00004
00005
00006 class CSimpleClass: ISimpleInterface
00007 {
00008    private:
00009
00010       ULONG m_cRef;
00011
00012    public:
00013
00014    CSimpleClass();
00015    ~CSimpleClass();
00016
00017    STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
00018    STDMETHODIMP_(ULONG) AddRef(void);
00019    STDMETHODIMP_(ULONG) Release(void);
00020
00021    STDMETHODIMP InPipeSample(IPipeLong *pInPipe);
00022    STDMETHODIMP OutPipeSample(IPipeLong **pOutPipe);
00023    STDMETHODIMP InOutPipeSample(IPipeLong **ppInOutPipe);
00024    STDMETHODIMP InInOutPipesSample(IPipeLong *pInPipe1, IPipeLong *pInPipe2,
00025                                    IPipeLong **ppOutPipe);
00026 };
00027
00028
00029 class CFactory: public IClassFactory
00030 {
00031    private:
00032
00033       ULONG m_cRef;
00034
00035    public:
00036
00037    CFactory();
00038    ~CFactory();
00039
00040    STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
00041    STDMETHODIMP_(ULONG) AddRef(void);
00042    STDMETHODIMP_(ULONG) Release(void);
00043
00044    STDMETHODIMP CreateInstance(IUnknown* pUnkwnOuter, REFIID riid, void** ppv);
00045    STDMETHODIMP LockServer(BOOL bLock);
00046
00047 };
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/globals.h Source File

  • SysMgmt
  • MMC
  • WMI

globals.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _MMC_GLOBALS_H
00020 #define _MMC_GLOBALS_H
00021
00022 #include <tchar.h>
00023
00024 #ifndef STRINGS_ONLY
00025         #define IDM_BUTTON1    0x100
00026         #define IDM_BUTTON2    0x101
00027
00028         extern HINSTANCE g_hinst;
00029         extern ULONG g_uObjects;
00030
00031         #define OBJECT_CREATED InterlockedIncrement((long *)&g_uObjects);
00032         #define OBJECT_DESTROYED InterlockedDecrement((long *)&g_uObjects);
00033
00034         // uncomment the following #define to enable message cracking
00035         // #define MMC_CRACK_MESSAGES
00036         void MMCN_Crack(BOOL bComponentData,
00037                                         IDataObject *pDataObject,
00038                                         IComponentData *pCompData,
00039                                         IComponent *pComp,
00040                                         MMC_NOTIFY_TYPE event,
00041                                         LPARAM arg,
00042                                         LPARAM param);
00043 #endif
00044
00045 //=--------------------------------------------------------------------------=
00046 // allocates a temporary buffer that will disappear when it goes out of scope
00047 // NOTE: be careful of that -- make sure you use the string in the same or
00048 // nested scope in which you created this buffer. people should not use this
00049 // class directly.  use the macro(s) below.
00050 //
00051 class TempBuffer {
00052   public:
00053     TempBuffer(ULONG cBytes) {
00054         m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
00055         m_fHeapAlloc = (cBytes > 120);
00056     }
00057     ~TempBuffer() {
00058         if (m_pBuf && m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
00059     }
00060     void *GetBuffer() {
00061         return m_pBuf;
00062     }
00063
00064   private:
00065     void *m_pBuf;
00066     // we'll use this temp buffer for small cases.
00067     //
00068     char  m_szTmpBuf[120];
00069     unsigned m_fHeapAlloc:1;
00070 };
00071
00072 //=--------------------------------------------------------------------------=
00073 // string helpers.
00074 //
00075 // given a _TCHAR, copy it into a wide buffer.
00076 // be careful about scoping when using this macro!
00077 //
00078 // how to use the below two macros:
00079 //
00080 //  ...
00081 //  LPTSTR pszT;
00082 //  pszT = MyGetTStringRoutine();
00083 //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
00084 //  MyUseWideStringRoutine(pwsz);
00085 //  ...
00086 #ifdef UNICODE
00087 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00088     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00089     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00090     lstrcpyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), tstr); \
00091     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00092 #else // ANSI
00093 #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
00094     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00095     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00096     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00097     MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
00098     LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
00099 #endif
00100
00101 #ifdef UNICODE
00102 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00103     long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
00104     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00105     lstrcpyW((LPWSTR)ptrname, tstr)
00106 #else // ANSI
00107 #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
00108     long __cch##ptrname = (lstrlenA(tstr) + 1);\
00109     long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
00110     LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
00111     MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
00112 #endif
00113
00114 //
00115 // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
00116 // have to be declared, and no clean up must be done.
00117 //
00118 // * 2 for DBCS handling in below length computation
00119 //
00120 #ifdef UNICODE
00121 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00122     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00123     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00124     lstrcpyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), widestr); \
00125     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00126 #else // ANSI
00127 #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
00128     long __l##ptrname = (wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
00129     TempBuffer __TempBuffer##ptrname(__l##ptrname); \
00130     WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
00131     LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
00132 #endif
00133
00134 #endif // _MMC_GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/devicenode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

devicenode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CDeviceNode class.
00014 //
00015
00016
00017 #include "DeviceNode.h"
00018 #include "CompData.h"
00019 #include "Comp.h"
00020                              // Tracing stuff
00021 #include "TraceMacro.h"
00022 #undef  MODULESTRING
00023 #define MODULESTRING  _T("CDeviceNode")
00024
00025
00026
00027 // Initialize our static GUID just once
00028 GUID CDeviceNode::thisGUID = CLSID_DeviceNode;
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 // Construction/Destruction
00033
00034 CDeviceNode::CDeviceNode()
00035 {
00036   m_SDI.mask        = DEFAULT_SDI_MASK;
00037   m_SDI.displayname = MMC_CALLBACK;
00038   m_SDI.cChildren   = 1;              // Determines if the '+' is displayed
00039   m_SDI.lParam      = reinterpret_cast<LPARAM>(this);
00040
00041   m_hParentNode     = NULL;
00042   m_dwAttributes    = 0;
00043   m_wzStatus        = NULL;
00044   m_pCompData       = NULL;
00045 }
00046
00047
00048 CDeviceNode::~CDeviceNode()
00049 {
00050 }
00051
00052 //---------------------------------------------------------------------------
00053 HRESULT CDeviceNode::Initialize( NODE_PROPERTIES* pNodeProps )
00054 {
00055   _ASSERT( NULL != pNodeProps );
00056
00057   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00058   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00059   wcscpy( pszTmp, pNodeProps->szNodeName );
00060   if( NULL != m_pwszNodeName )
00061     CoTaskMemFree( m_pwszNodeName );
00062
00063   m_pwszNodeName = pszTmp;
00064   m_pCompData = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00065
00066   RefreshNodeList();                   // Add child nodes
00067                                        // and set images
00068
00069   if( pNodeProps->dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00070   {
00071     m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00072     m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00073     m_dwAttributes   |= ATTRIBUTE_BACKUP_DEVICE;
00074   }
00075   else
00076   {
00077     m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00078     m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00079     m_dwAttributes   |= ~ATTRIBUTE_BACKUP_DEVICE;
00080   }
00081
00082   m_wzStatus      = L"Online";    // Node successfully initialized
00083   m_bOnlineStatus = STATUS_ONLINE;
00084
00085   return S_OK;
00086 }
00087
00088
00089 /////////////////////////////////////////////////////////////////////////////
00090 // Implementation of virtual methods
00091
00092
00093 //---------------------------------------------------------------------------
00094 HRESULT CDeviceNode::GetResultViewType2
00095 (
00096   MMC_COOKIE             nCookie,  //[in] Identifier of object
00097   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00098 )
00099 {
00100   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00101   if( NULL == pszDescStr )
00102     return E_OUTOFMEMORY;
00103
00104   wcscpy( pszDescStr, L"DefaultListView" );
00105   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00106
00107   return S_OK;
00108 }
00109
00110 //---------------------------------------------------------------------------
00111 HRESULT CDeviceNode::GetDisplayInfo
00112 (
00113   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00114 )
00115 {
00116   _ASSERT( NULL != pSDI );
00117   pSDI->displayname = m_pwszNodeName;
00118
00119   return S_OK;
00120 }
00121
00122 //---------------------------------------------------------------------------
00123 HRESULT CDeviceNode::GetDisplayInfo
00124 (
00125   RESULTDATAITEM* pRDI
00126 )
00127 {
00128   _ASSERT( NULL != pRDI );
00129
00130   HRESULT hResult = S_OK;
00131
00132   if( pRDI->mask & RDI_STR )         // Console is requesting strings...
00133   {                                  // for each column
00134     switch( pRDI->nCol )
00135     {
00136       case 0:
00137         pRDI->str = m_pwszNodeName;
00138         break;
00139
00140       case 1:                        // Attributes not supported yet
00141         pRDI->str = m_wzStatus;
00142         break;
00143
00144       default:
00145         hResult = S_FALSE;
00146         TRACE_VAL(_T("GetDisplayInfo"), _T("Column"), pRDI->nCol );
00147         break;
00148     }
00149   }
00150   if( pRDI->mask & RDI_IMAGE )       // Looking for an image?
00151   {
00152     pRDI->nImage = m_SDI.nImage;
00153   }
00154
00155   TRACE_HRESULT(_T("GetDisplayInfo"), hResult );
00156   return hResult;
00157
00158 }
00159
00160 /////////////////////////////////////////////////////////////////////////////
00161 // Implementation of notification handlers
00162
00163
00164 //---------------------------------------------------------------------------
00165 HRESULT CDeviceNode::OnSelect
00166 (
00167   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00168   LPARAM        nArg,          //[in] Bools for context & selection state
00169   LPARAM        nParam,        //[in] Not used
00170   LONG_PTR      pComponent     //[in] Points calling CComponent
00171 )
00172 {
00173   HRESULT hResult = S_FALSE;
00174
00175   // Not setting verbs for this node
00176
00177   //TRACE_HRESULT(_T("OnSelect"), hResult );
00178   return hResult;
00179 }
00180
00181
00182 //---------------------------------------------------------------------------
00183 HRESULT CDeviceNode::OnShow
00184 (
00185   LPDATAOBJECT  ipDataObject,  //[in] Points to selected node
00186   LPARAM        nArg,          //[in] TRUE if node was selcted
00187   LPARAM        nParam,        //[in] HSCOPEITEM of selected/deselected item
00188   LONG_PTR      pComponent     //[in] Points to calling IComponent
00189 )
00190 {
00191   HRESULT  hResult = S_FALSE;
00192
00193   CComponent* pComp = reinterpret_cast<CComponent*>(pComponent);
00194
00195   LPHEADERCTRL2  ipHeaderCtrl = NULL;
00196   hResult = pComp->GetInterface( REQUEST_IHEADERCTRL, (LONG_PTR*)&ipHeaderCtrl );
00197   if( S_OK != hResult )
00198    return hResult;
00199
00200   LPRESULTDATA  ipResultData = NULL;
00201   hResult = pComp->GetInterface( REQUEST_IRESULTDATA, (LONG_PTR*)&ipResultData );
00202   if( S_OK != hResult )
00203    return hResult;
00204
00205   if( TRUE == nArg )  // Selecting a scope node
00206   {
00207     do
00208     {
00209       hResult = ipHeaderCtrl->InsertColumn( 0, L"Folder Name", 0, 150 );
00210       BREAK_ON_ERROR( hResult );
00211
00212       hResult = ipHeaderCtrl->InsertColumn( 1, L"Attributes", 0, 150 );
00213       BREAK_ON_ERROR( hResult );
00214
00215       hResult = ipResultData->ModifyViewStyle( MMC_NOSORTHEADER, (MMC_RESULT_VIEW_STYLE)NULL );
00216       BREAK_ON_ERROR( hResult );
00217
00218     }while(0);
00219   }
00220   else // not handling deselect notifications
00221   {
00222   }
00223
00224   //TRACE_HRESULT(_T("OnShow"), hResult );
00225   return hResult;
00226 }
00227
00228 //---------------------------------------------------------------------------
00229 HRESULT CDeviceNode::OnExpand
00230 (
00231   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00232   LPARAM         nArg,         //[in] TRUE if node was selcted
00233   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00234   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00235 )
00236 {
00237   HRESULT hResult = S_FALSE;
00238
00239   // Cache HSCOPEITEM of Parent
00240   m_hParentNode = static_cast<HSCOPEITEM>(nParam);
00241
00242   if( NULL == m_pCompData )
00243     m_pCompData = reinterpret_cast<CComponentData*>(pCompData);
00244
00245   // Request an IConsoleNameSpace2 pointer from CComponentData
00246   LPCONSOLENAMESPACE2 ipCNS = NULL;
00247   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE, (LONG_PTR*)&ipCNS );
00248   if( S_OK != hResult )
00249     return hResult;
00250
00251   hResult = DeleteChildItems( ipCNS );
00252   hResult = InsertChildItems( ipCNS );
00253
00254   //TRACE_HRESULT( _T("OnExpand"), hResult );
00255   return hResult;
00256 }
00257
00258
00259 //---------------------------------------------------------------------------
00260 HRESULT CDeviceNode::OnRemoveChildren
00261 (
00262   LPDATAOBJECT   ipDataObject, //[in] Points to selected data object
00263   LPARAM         nArg,         //[in] TRUE if node was selcted
00264   LPARAM         nParam,       //[in] HSCOPEITEM of selected/deselected item
00265   LONG_PTR       pCompData     //[in] Points to calling CComponentData
00266 )
00267 {
00268   HRESULT hResult = S_FALSE;
00269
00270   POSITION   Pos   = m_NodeList.GetHeadPosition();
00271   LPBASENODE pNode = NULL;
00272   while( Pos )                         // Delete everything...
00273   {
00274     pNode = m_NodeList.GetNext( Pos );
00275     hResult = pNode->OnRemoveChildren( ipDataObject, nArg, nParam, pCompData );
00276     delete pNode;
00277   }
00278
00279   m_NodeList.RemoveAll();            // Cleans up the list
00280
00281   TRACE_HRESULT( _T("OnRemoveChildren"), hResult );
00282   return hResult;
00283
00284 }
00285
00286
00287 /////////////////////////////////////////////////////////////////////////////
00288 //  Private Helpers
00289
00290 //---------------------------------------------------------------------------
00291 HRESULT CDeviceNode::DeleteChildItems
00292 (
00293   LPCONSOLENAMESPACE2 ipCNS      //[in] IConsoleNameSpace pointer
00294 )
00295 {
00296   _ASSERT( NULL != ipCNS );
00297
00298   POSITION    Pos     = m_NodeList.GetHeadPosition();
00299   HSCOPEITEM  hItem   = NULL;
00300   LPBASENODE  pNode   = NULL;
00301   HRESULT     hResult = S_FALSE;
00302
00303   while( Pos )                         // Delete everything...
00304   {
00305     pNode = m_NodeList.GetNext( Pos );
00306     hItem = (HSCOPEITEM)pNode->m_SDI.ID;
00307     if( 0 != hItem )
00308       hResult = ipCNS->DeleteItem( hItem, TRUE );
00309   }
00310
00311   return hResult;
00312 }
00313
00314
00315 //---------------------------------------------------------------------------
00316 HRESULT CDeviceNode::InsertChildItems
00317 (
00318   LPCONSOLENAMESPACE2 ipCNS      //[in] IConsoleNameSpace pointer
00319 )
00320 {
00321   _ASSERT( NULL != ipCNS );
00322   _ASSERT( NULL != m_hParentNode );
00323
00324   HRESULT    hResult = S_FALSE;
00325   POSITION   Pos     = m_NodeList.GetHeadPosition();
00326   LPBASENODE pNode   = NULL;
00327
00328   while( Pos )
00329   {
00330     pNode   = m_NodeList.GetNext( Pos );
00331     pNode->m_SDI.relativeID = m_hParentNode;
00332     hResult = ipCNS->InsertItem( &pNode->m_SDI );
00333   }
00334
00335   return hResult;
00336 }
00337
00338
00339 //---------------------------------------------------------------------------
00340 //  Only add one child node in this sample
00341 //
00342 HRESULT CDeviceNode::RefreshNodeList()
00343 {
00344   NODE_PROPERTIES NodeProps;
00345   NodeProps.pComponentData = reinterpret_cast<LONG_PTR>(m_pCompData);
00346   NodeProps.pParentObject  = reinterpret_cast<LONG_PTR>(this);
00347   NodeProps.dwAttributes   = 0;
00348
00349   WCHAR  szNames[1][32];
00350   wcscpy( szNames[0], L"Root Folder" );
00351
00352   RemoveChildNodes();                  // Clean the node list
00353
00354   LPBASENODE pNode = NULL;
00355   for( DWORD i = 0; i < 1; i++ )
00356   {
00357     wcscpy( NodeProps.szNodeName, szNames[i] );
00358     pNode = new CFolderNode;
00359     pNode->Initialize( &NodeProps );
00360     m_NodeList.AddTail( pNode );
00361   }
00362
00363   return S_OK;
00364 }
00365
00366 //---------------------------------------------------------------------------
00367 //  We do this instead of just calling RemoveAll() because our list contains
00368 //  CBaseNode pointers and so RemoveAll() does not call the destructor for
00369 //  the derived class object.
00370 //
00371 VOID CDeviceNode::RemoveChildNodes()
00372 {
00373   LPBASENODE pNode = NULL;
00374   POSITION   Pos   = m_NodeList.GetHeadPosition();
00375   while( Pos )
00376   {
00377     pNode = m_NodeList.GetNext( Pos );
00378     delete pNode;
00379   }
00380   m_NodeList.RemoveAll();              // Clean the list
00381 }
00382
00383 /////////////////////////////////////////////////////////////////////////////
00384 //  Public helpers
00385
00386 //---------------------------------------------------------------------------
00387 VOID CDeviceNode::ToggleStatus()
00388 {
00389   // First we have to set the image indexes according to the Online Status
00390   // and the device type
00391   //
00392   if( STATUS_ONLINE == m_bOnlineStatus )
00393   {
00394     m_bOnlineStatus = STATUS_OFFLINE;
00395     m_wzStatus      = L"Offline";
00396     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00397     {
00398       m_SDI.nImage      = IMG_DEVICE_OFFLINE;
00399       m_SDI.nOpenImage  = IMG_DEVICE_OFFLINE;
00400     }
00401     else
00402     {
00403       m_SDI.nImage      = IMG_DRIVE_OFFLINE;
00404       m_SDI.nOpenImage  = IMG_DRIVE_OFFLINE;
00405     }
00406   }
00407   else
00408   {
00409     m_bOnlineStatus = STATUS_ONLINE;
00410     m_wzStatus      = L"Online";
00411     if( m_dwAttributes & ATTRIBUTE_BACKUP_DEVICE )
00412     {
00413       m_SDI.nImage      = IMG_DEVICE_DEFAULT;
00414       m_SDI.nOpenImage  = IMG_DEVICE_DEFAULT;
00415     }
00416     else
00417     {
00418       m_SDI.nImage      = IMG_DRIVE_DEFAULT;
00419       m_SDI.nOpenImage  = IMG_DRIVE_DEFAULT;
00420     }
00421   }
00422   // This is a scope node, so GetDisplayInfo will only ask for images for
00423   // this node when it is in the Result Pane.  To change the image for the
00424   // the Scope Pane we need to call IConsoleNameSpace::SetItem().  This
00425   // call forces the scope node to be redrawn.
00426   //
00427   SCOPEDATAITEM  sdi;
00428   ZeroMemory( &sdi, sizeof(SCOPEDATAITEM) );
00429   sdi.mask        = SDI_IMAGE | SDI_OPENIMAGE ;
00430   sdi.ID          = m_SDI.ID;
00431   sdi.nImage      = m_SDI.nImage;
00432   sdi.nOpenImage  = m_SDI.nOpenImage;
00433
00434   // Request an IConsoleNameSpace pointer from CComponentData
00435   HRESULT  hResult = S_FALSE;
00436   LPCONSOLENAMESPACE2 ipCNS = NULL;
00437   hResult = m_pCompData->GetInterface( REQUEST_ICONSOLENAMESPACE, (LONG*)&ipCNS );
00438   if( S_OK == hResult )
00439     hResult = ipCNS->SetItem( &sdi );
00440
00441 }
00442
00443
00444 /////////////////////////////////////////////////////////////////////////////
00445 //  Support for Context Menus
00446
00447 //---------------------------------------------------------------------------
00448 //  Devices can only add a folder
00449 //
00450 HRESULT CDeviceNode::AddMenuItems
00451 (
00452   LPCONTEXTMENUCALLBACK ipCallback,  //[in] Pointer to an IContextMenuCallback
00453   long __RPC_FAR* pInsertionAllowed  //[in-out] Insertion flags
00454 )
00455 {
00456   _ASSERT( NULL != ipCallback );
00457   HRESULT hResult = S_FALSE;
00458
00459   static CONTEXTMENUITEM ctxMenu[2];
00460     ctxMenu[0].lCommandID        = IDM_NEW_FOLDER;
00461     ctxMenu[0].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
00462     ctxMenu[0].fFlags            = MF_GRAYED;
00463     ctxMenu[0].fSpecialFlags     = 0;
00464     ctxMenu[0].strName           = L"New Folder...";
00465     ctxMenu[0].strStatusBarText  = L"Add a new folder";
00466
00467     ctxMenu[1].lCommandID        = IDM_TOGGLE_STATUS;
00468     ctxMenu[1].lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
00469     ctxMenu[1].fFlags            = 0;
00470     ctxMenu[1].fSpecialFlags     = 0;
00471     ctxMenu[1].strName           = L"Toggle Online Status";
00472     ctxMenu[1].strStatusBarText  = L"Toggles the device status";
00473
00474
00475   // Add the Add new folder command
00476   if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
00477   {
00478     hResult = ipCallback->AddItem( &ctxMenu[0] );
00479   }
00480
00481   // Add the Toggle item to the Task menu if allowed...
00482   if( CCM_INSERTIONALLOWED_TOP & *pInsertionAllowed )
00483   {
00484     hResult = ipCallback->AddItem( &ctxMenu[1] );
00485   }
00486
00487   return hResult;
00488 }
00489
00490 //---------------------------------------------------------------------------
00491 HRESULT CDeviceNode::Command
00492 (
00493   long lCommandID          //[in] Indentifier for menu ID
00494 )
00495 {
00496   HRESULT hResult = S_OK;
00497
00498   switch( lCommandID )
00499   {
00500     case IDM_TOGGLE_STATUS:
00501     {
00502       ToggleStatus();
00503       break;
00504     }
00505     case IDM_NEW_FOLDER:
00506     {
00507       // Not handling this command in this sample
00508       break;
00509     }
00510     default:
00511       hResult = S_FALSE;
00512       break;
00513
00514   }
00515   return hResult;
00516 }
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

HtmlPropIFilterCF Member List

This is the complete list of members for HtmlPropIFilterCF, including all inherited members.
_lRefs | HtmlPropIFilterCF | [protected]
AddRef() | HtmlPropIFilterCF |
CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject) | HtmlPropIFilterCF |
DllGetClassObject(REFCLSID cid, REFIID iid, void **ppvObj) | HtmlPropIFilterCF | [friend]
HtmlPropIFilterCF() | HtmlPropIFilterCF |
LockServer(BOOL fLock) | HtmlPropIFilterCF |
QueryInterface(REFIID riid, void **ppvObject) | HtmlPropIFilterCF |
Release() | HtmlPropIFilterCF |
~HtmlPropIFilterCF() | HtmlPropIFilterCF | [protected]
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoClien/SINK.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoClien

SINK.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SINK.CPP
00003
00004   Summary:   Implementation file for the COPaperSink COM Object Class.
00005              Connectable object notifications are handled by COPaperSink.
00006
00007              COPaperSink offers a main IUnknown interface and the custom
00008              IPaperSink interface (with the drawing Paper related event
00009              features). This multiple interface COM Object Class is
00010              achieved via the technique of nested classes.  The
00011              implementation of the IPaperSink interface is nested inside
00012              the COPaperSink Class.
00013
00014              For a comprehensive tutorial code tour of this module's
00015              contents and offerings see the tutorial STOCLIEN.HTM
00016              file. For more specific technical details on the internal
00017              workings see the comments dispersed throughout the module's
00018              source code.
00019
00020   Classes:   COPaperSink.
00021
00022   Functions: none.
00023
00024   Origin:    6-10-96: atrent - Editor-inheritance from BALL.CPP in
00025              the CONSERVE Tutorial Code Sample.
00026
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042
00043 /*---------------------------------------------------------------------------
00044   We include WINDOWS.H for all Win32 applications.
00045   We include OLE2.H because we will be calling the COM/OLE Libraries.
00046   We include OLECTL.H because it has definitions for connectable objects.
00047   We include APPUTIL.H because we will be building this application using
00048     the convenient Virtual Window and Dialog classes and other
00049     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00050   We include IPAPER.H and PAPGUIDS.H for the common paper-related
00051     Interface class, GUID, and CLSID specifications.
00052   We include PAPFILE.H because it has the C++ class used for compound file
00053     storage of drawing paper data.
00054   We include GUIPAPER.H because it declares the class for the main C++
00055     object that can service the Sink events.
00056   We include SINK.H because it has the class COPaperSink declarations.
00057 ---------------------------------------------------------------------------*/
00058 #include <windows.h>
00059 #include <ole2.h>
00060 #include <olectl.h>
00061 #include <apputil.h>
00062 #include <ipaper.h>
00063 #include <papguids.h>
00064 #include "papfile.h"
00065 #include "guipaper.h"
00066 #include "sink.h"
00067
00068
00069 /*---------------------------------------------------------------------------
00070   COPaperSink's implementation of its main COM object class including
00071   Constructor, Destructor, QueryInterface, AddRef, and Release.
00072 ---------------------------------------------------------------------------*/
00073
00074 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00075   Method:   COPaperSink::COPaperSink
00076
00077   Summary:  COPaperSink Constructor. Note the member initializer:
00078             "m_ImpIPaperSink(this, pUnkOuter)" which is used to pass the
00079             'this' and pUnkOuter pointers of this constructor function to
00080             the constructor in the instantiation of the implementation of
00081             the CImpIPaperSink interface (which is nested inside this
00082             present COPaperSink Object Class).
00083
00084   Args:     IUnknown* pUnkOuter,
00085               Pointer to the the outer Unknown.  NULL means this COM Object
00086               is not being Aggregated.  Non NULL means it is being created
00087               on behalf of an outside COM object that is reusing it via
00088               aggregation.
00089             CGuiPaper* pGuiPaper)
00090               Pointer to the main C++ object that can service the PaperSink
00091               events.
00092
00093   Modifies: m_cRefs, m_pUnkOuter, m_pGuiPaper.
00094
00095   Returns:  void
00096 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00097 COPaperSink::COPaperSink(
00098   IUnknown* pUnkOuter,
00099   CGuiPaper* pGuiPaper) :
00100   m_ImpIPaperSink(this, pUnkOuter)
00101 {
00102   // Zero the COM object's reference count.
00103   m_cRefs = 0;
00104
00105   // No AddRef necessary if non-NULL, as we're nested.
00106   m_pUnkOuter = pUnkOuter;
00107
00108   // Assign the pointer to the Sink service C++ object.
00109   m_pGuiPaper = pGuiPaper;
00110
00111   return;
00112 }
00113
00114
00115 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00116   Method:   COPaperSink::~COPaperSink
00117
00118   Summary:  COPaperSink Destructor.
00119
00120   Args:     void
00121
00122   Returns:  void
00123 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00124 COPaperSink::~COPaperSink(void)
00125 {
00126   return;
00127 }
00128
00129
00130 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00131   Method:   COPaperSink::QueryInterface
00132
00133   Summary:  QueryInterface of the COPaperSink non-delegating
00134             IUnknown implementation.
00135
00136   Args:     REFIID riid,
00137               [in] GUID of the Interface being requested.
00138             PPVOID ppv)
00139               [out] Address of the caller's pointer variable that will
00140               receive the requested interface pointer.
00141
00142   Returns:  HRESULT
00143 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00144 STDMETHODIMP COPaperSink::QueryInterface(
00145                REFIID riid,
00146                PPVOID ppv)
00147 {
00148   HRESULT hr = E_NOINTERFACE;
00149
00150   *ppv = NULL;
00151
00152   if (IID_IUnknown == riid)
00153     *ppv = this;
00154   else if (IID_IPaperSink == riid)
00155     *ppv = &m_ImpIPaperSink;
00156
00157   if (NULL != *ppv)
00158   {
00159     // We've handed out a pointer to the interface so obey the COM rules
00160     // and AddRef the reference count.
00161     ((LPUNKNOWN)*ppv)->AddRef();
00162     hr = NOERROR;
00163   }
00164
00165
00166   return (hr);
00167 }
00168
00169
00170 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00171   Method:   COPaperSink::AddRef
00172
00173   Summary:  AddRef of the COPaperSink non-delegating IUnknown
00174             implementation.
00175
00176   Args:     void
00177
00178   Modifies: m_cRefs.
00179
00180   Returns:  ULONG
00181               New value of m_cRefs (COM object's reference count).
00182 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00183 STDMETHODIMP_(ULONG) COPaperSink::AddRef(void)
00184 {
00185   ULONG cRefs;
00186
00187   cRefs = ++m_cRefs;
00188
00189   return cRefs;
00190 }
00191
00192
00193 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00194   Method:   COPaperSink::Release
00195
00196   Summary:  Release of the COPaperSink non-delegating IUnknown
00197             implementation.
00198
00199   Args:     void
00200
00201   Modifies: m_cRefs.
00202
00203   Returns:  ULONG
00204               New value of m_cRefs (COM object's reference count).
00205 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00206 STDMETHODIMP_(ULONG) COPaperSink::Release(void)
00207 {
00208   ULONG cRefs;
00209
00210   cRefs = --m_cRefs;
00211
00212   if (0 == cRefs)
00213   {
00214     // We artificially bump the main ref count to prevent reentrancy
00215     // via the main object destructor.  Not really needed in this
00216     // COPaperSink but a good practice because we are aggregatable and
00217     // may at some point in the future add something entertaining like
00218     // some Releases to the COPaperSink destructor.
00219     m_cRefs++;
00220     delete this;
00221   }
00222
00223   return cRefs;
00224 }
00225
00226
00227 /*---------------------------------------------------------------------------
00228   COPaperSink's nested implementation of the IPaperSink interface
00229   including Constructor, Destructor, QueryInterface, AddRef, Release,
00230   Locked, Unlocked, Loaded, Saved, InkStart, InkDraw, InkStop, Erased,
00231   and Resized. Methods in this interface are called by COM objects on
00232   the server side to send notifications to the client.
00233 ---------------------------------------------------------------------------*/
00234
00235 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00236   Method:   COPaperSink::CImpIPaperSink::CImpIPaperSink
00237
00238   Summary:  Constructor for the CImpIPaperSink interface instantiation.
00239
00240   Args:     COPaperSink* pBackObj,
00241               Back pointer to the parent outer object.
00242             IUnknown* pUnkOuter
00243               Pointer to the outer Unknown.  For delegation.
00244
00245   Modifies: m_pBackObj, m_pUnkOuter.
00246
00247   Returns:  void
00248 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00249 COPaperSink::CImpIPaperSink::CImpIPaperSink(
00250   COPaperSink* pBackObj,
00251   IUnknown* pUnkOuter)
00252 {
00253   // Init the Back Object Pointer to point to the parent object.
00254   m_pBackObj = pBackObj;
00255
00256   // Init the CImpIPaperSink interface's delegating Unknown pointer.  We
00257   // use the Back Object pointer for IUnknown delegation here if we are
00258   // not being aggregated.  If we are being aggregated we use the supplied
00259   // pUnkOuter for IUnknown delegation.  In either case the pointer
00260   // assignment requires no AddRef because the CImpIPaperSink lifetime is
00261   // quaranteed by the lifetime of the parent object in which
00262   // CImpIPaperSink is nested.
00263   if (NULL == pUnkOuter)
00264     m_pUnkOuter = pBackObj;
00265   else
00266     m_pUnkOuter = pUnkOuter;
00267
00268   return;
00269 }
00270
00271
00272 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00273   Method:   COPaperSink::CImpIPaperSink::~CImpIPaperSink
00274
00275   Summary:  Destructor for the CImpIPaperSink interface instantiation.
00276
00277   Args:     void
00278
00279   Returns:  void
00280 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00281 COPaperSink::CImpIPaperSink::~CImpIPaperSink(void)
00282 {
00283   return;
00284 }
00285
00286
00287 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00288   Method:   COPaperSink::CImpIPaperSink::QueryInterface
00289
00290   Summary:  The QueryInterface IUnknown member of this IPaperSink interface
00291             implementation that delegates to m_pUnkOuter, whatever it is.
00292
00293   Args:     REFIID riid,
00294               [in] GUID of the Interface being requested.
00295             PPVOID ppv)
00296               [out] Address of the caller's pointer variable that will
00297               receive the requested interface pointer.
00298
00299   Returns:  HRESULT
00300               Returned by the delegated outer QueryInterface call.
00301 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00302 STDMETHODIMP COPaperSink::CImpIPaperSink::QueryInterface(
00303                REFIID riid,
00304                PPVOID ppv)
00305 {
00306   // Delegate this call to the outer object's QueryInterface.
00307   return m_pUnkOuter->QueryInterface(riid, ppv);
00308 }
00309
00310
00311 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00312   Method:   COPaperSink::CImpIPaperSink::AddRef
00313
00314   Summary:  The AddRef IUnknown member of this IPaperSink interface
00315             implementation that delegates to m_pUnkOuter, whatever it is.
00316
00317   Args:     void
00318
00319   Returns:  ULONG
00320               Returned by the delegated outer AddRef call.
00321 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00322 STDMETHODIMP_(ULONG) COPaperSink::CImpIPaperSink::AddRef(void)
00323 {
00324   // Delegate this call to the outer object's AddRef.
00325   return m_pUnkOuter->AddRef();
00326 }
00327
00328
00329 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00330   Method:   COPaperSink::CImpIPaperSink::Release
00331
00332   Summary:  The Release IUnknown member of this IPaperSink interface
00333             implementation that delegates to m_pUnkOuter, whatever it is.
00334
00335   Args:     void
00336
00337   Returns:  ULONG
00338               Returned by the delegated outer Release call.
00339 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00340 STDMETHODIMP_(ULONG) COPaperSink::CImpIPaperSink::Release(void)
00341 {
00342   // Delegate this call to the outer object's Release.
00343   return m_pUnkOuter->Release();
00344 }
00345
00346
00347 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00348   Method:   COPaperSink::CImpIPaperSink::Locked
00349
00350   Summary:  The COPaper object was locked by a client.
00351
00352   Args:     void
00353
00354   Returns:  HRESULT
00355               Standard result code. NOERROR for success.
00356 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00357 STDMETHODIMP COPaperSink::CImpIPaperSink::Locked(
00358                void)
00359 {
00360   HRESULT hr = E_NOTIMPL;
00361
00362   // For future evolution.
00363
00364   return hr;
00365 }
00366
00367
00368 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00369   Method:   COPaperSink::CImpIPaperSink::Unlocked
00370
00371   Summary:  The COPaper object was Unlocked by a client.
00372
00373   Args:     void
00374
00375   Returns:  HRESULT
00376               Standard result code. NOERROR for success.
00377 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00378 STDMETHODIMP COPaperSink::CImpIPaperSink::Unlocked(
00379                void)
00380 {
00381   HRESULT hr = E_NOTIMPL;
00382
00383   // For future evolution.
00384
00385   return hr;
00386 }
00387
00388
00389 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00390   Method:   COPaperSink::CImpIPaperSink::Loaded
00391
00392   Summary:  The COPaper object's ink drawing data was loaded from a
00393             client's compound file.
00394
00395   Args:     void
00396
00397   Returns:  HRESULT
00398               Standard result code. NOERROR for success.
00399 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00400 STDMETHODIMP COPaperSink::CImpIPaperSink::Loaded(
00401                void)
00402 {
00403   HRESULT hr;
00404
00405   // We have been notified that a load was done. Thus, a whole new array
00406   // of ink data must be displayed in a cleared window of this client.
00407   m_pBackObj->m_pGuiPaper->ClearWin();
00408   hr = m_pBackObj->m_pGuiPaper->PaintWin();
00409
00410   return hr;
00411 }
00412
00413
00414 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00415   Method:   COPaperSink::CImpIPaperSink::Saved
00416
00417   Summary:  The COPaper object's drawing paper data was saved to a
00418             client's compound file.
00419
00420   Args:     void
00421
00422   Returns:  HRESULT
00423               Standard result code. NOERROR for success.
00424 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00425 STDMETHODIMP COPaperSink::CImpIPaperSink::Saved(
00426                void)
00427 {
00428   HRESULT hr = E_NOTIMPL;
00429
00430   // For future evolution.
00431
00432   return hr;
00433 }
00434
00435
00436 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00437   Method:   COPaperSink::CImpIPaperSink::InkStart
00438
00439   Summary:  Client is being told to start a display ink drawing sequence.
00440
00441   Args:     SHORT nX,
00442               X coordinate of the start point.
00443             SHORT nY,
00444               Y coordinate of the start point.
00445             SHORT nWidth,
00446               Ink Width in pixels.
00447             COLORREF crInkColor)
00448               RGB Ink color to be used in the subsequent inking sequence.
00449
00450   Returns:  HRESULT
00451               Standard result code. NOERROR for success.
00452 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00453 STDMETHODIMP COPaperSink::CImpIPaperSink::InkStart(
00454                                             SHORT nX,
00455                                             SHORT nY,
00456                                             SHORT nWidth,
00457                                             COLORREF crInkColor)
00458 {
00459   // Turn off ink saving to the COPaper object.
00460   m_pBackObj->m_pGuiPaper->InkSaving(FALSE);
00461
00462   // Play the data back to the CGuiPaper for display only.
00463   m_pBackObj->m_pGuiPaper->InkWidth(nWidth);
00464   m_pBackObj->m_pGuiPaper->InkColor(crInkColor);
00465   m_pBackObj->m_pGuiPaper->InkStart(nX, nY);
00466
00467   return NOERROR;
00468 }
00469
00470
00471 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00472   Method:   COPaperSink::CImpIPaperSink::InkDraw
00473
00474   Summary:  Client is being told to draw/display ink drawing sequence data.
00475
00476   Args:     SHORT nX,
00477               X coordinate of the start point.
00478             SHORT nY,
00479               Y coordinate of the start point.
00480
00481   Returns:  HRESULT
00482               Standard result code. NOERROR for success.
00483 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00484 STDMETHODIMP COPaperSink::CImpIPaperSink::InkDraw(
00485                                             SHORT nX,
00486                                             SHORT nY)
00487 {
00488   // Play the data back to the CGuiPaper for display only.
00489   m_pBackObj->m_pGuiPaper->InkDraw(nX, nY);
00490
00491   return NOERROR;
00492 }
00493
00494
00495 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00496   Method:   COPaperSink::CImpIPaperSink::InkStop
00497
00498   Summary:  Client is being told to stop an ink drawing sequence.
00499
00500   Args:     SHORT nX,
00501               X coordinate of the start point.
00502             SHORT nY,
00503               Y coordinate of the start point.
00504
00505   Returns:  HRESULT
00506               Standard result code. NOERROR for success.
00507 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00508 STDMETHODIMP COPaperSink::CImpIPaperSink::InkStop(
00509                                             SHORT nX,
00510                                             SHORT nY)
00511 {
00512   // Stop the play of the data back to the CGuiPaper for display.
00513   m_pBackObj->m_pGuiPaper->InkStop(nX, nY);
00514
00515   // Turn Ink Data saving back on.
00516   m_pBackObj->m_pGuiPaper->InkSaving(TRUE);
00517
00518   return NOERROR;
00519 }
00520
00521
00522 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00523   Method:   COPaperSink::CImpIPaperSink::Erased
00524
00525   Summary:  The COPaper object's drawing paper data was erased by a client.
00526
00527   Args:     void
00528
00529   Returns:  HRESULT
00530               Standard result code. NOERROR for success.
00531 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00532 STDMETHODIMP COPaperSink::CImpIPaperSink::Erased(
00533                void)
00534 {
00535   HRESULT hr = E_NOTIMPL;
00536
00537   // For future evolution.
00538
00539   return hr;
00540 }
00541
00542
00543 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00544   Method:   COPaperSink::CImpIPaperSink::Resized
00545
00546   Summary:  The COPaper object's drawing rectangle was resized by a client.
00547
00548   Args:     SHORT nWidth,
00549               Rectangle width in pixels.
00550             SHORT nHeight)
00551               Rectangle height in pixels.
00552
00553   Returns:  HRESULT
00554               Standard result code. NOERROR for success.
00555 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00556 STDMETHODIMP COPaperSink::CImpIPaperSink::Resized(
00557                SHORT nWidth,
00558                SHORT nHeight)
00559 {
00560   HRESULT hr = E_NOTIMPL;
00561
00562   // For future evolution.
00563
00564   return hr;
00565 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMSOmniProvSessionColSchemaRowset Member List

This is the complete list of members for CMSOmniProvSessionColSchemaRowset, including all inherited members.
Execute(LONG *pcRowsAffected, ULONG, const VARIANT *) | CMSOmniProvSessionColSchemaRowset | [inline]
GetDBStatus(CSimpleRow *, ATLCOLUMNINFO *pInfo) | CMSOmniProvSessionColSchemaRowset | [inline]
m_double | CMSOmniProvSessionColSchemaRowset | [private]
m_hchapter | CMSOmniProvSessionColSchemaRowset | [private]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCOrder/StdAfx.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCOrder

StdAfx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Stdafx.h
00003   Summary:   Standard header
00004   Classes:   None
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #if !defined(AFX_STDAFX_H__6DD1E6C6_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_)
00023 #define AFX_STDAFX_H__6DD1E6C6_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_
00024
00025 #if _MSC_VER >= 1000
00026 #pragma once
00027 #endif // _MSC_VER >= 1000
00028
00029 #define STRICT
00030
00031
00032 #define _WIN32_WINNT 0x0500
00033 #define _ATL_APARTMENT_THREADED
00034
00035
00036 #include <atlbase.h>
00037 //You may derive a class from CComModule and use it if you want to override
00038 //something, but do not change the name of _Module
00039 extern CComModule _Module;
00040 #include <atlcom.h>
00041
00042 //{{AFX_INSERT_LOCATION}}
00043 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00044
00045 #include <crtdbg.h>
00046 #include <comsvcs.h>
00047 #include <stdlib.h>
00048 #include <vector>
00049 #include <comdef.h>
00050
00051 #endif // !defined(AFX_STDAFX_H__6DD1E6C6_28C1_11D2_B5B6_00C04FC340EE__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/wia/GetImage/EventCallback.cpp Source File

  • Multimedia
  • wia
  • GetImage

EventCallback.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) Microsoft Corporation. All rights reserved.
00004
00005 --*/
00006
00007 #include "stdafx.h"
00008 #include "resource.h"
00009
00010 #include "WiaWrap.h"
00011 #include "EventCallback.h"
00012
00013 namespace WiaWrap
00014 {
00015
00016 //////////////////////////////////////////////////////////////////////////
00017 //
00018 // CEventCallback::CEventCallback
00019 //
00020
00021 CEventCallback::CEventCallback()
00022 {
00023     m_cRef = 0;
00024     m_nNumDevices = 0;
00025 }
00026
00027 //////////////////////////////////////////////////////////////////////////
00028 //
00029 // CEventCallback::QueryInterface
00030 //
00031
00032 STDMETHODIMP CEventCallback::QueryInterface(REFIID iid, LPVOID *ppvObj)
00033 {
00034     if (ppvObj == NULL)
00035     {
00036       return E_POINTER;
00037     }
00038
00039     if (iid == IID_IUnknown)
00040     {
00041       *ppvObj = (IUnknown *) this;
00042     }
00043     else if (iid == IID_IWiaEventCallback)
00044     {
00045       *ppvObj = (IWiaEventCallback *) this;
00046     }
00047     else
00048     {
00049         *ppvObj = NULL;
00050         return E_NOINTERFACE;
00051     }
00052
00053   AddRef();
00054     return S_OK;
00055 }
00056
00057 //////////////////////////////////////////////////////////////////////////
00058 //
00059 // CEventCallback::AddRef
00060 //
00061
00062 STDMETHODIMP_(ULONG) CEventCallback::AddRef()
00063 {
00064     return InterlockedIncrement(&m_cRef);
00065 }
00066
00067 //////////////////////////////////////////////////////////////////////////
00068 //
00069 // CEventCallback::Release
00070 //
00071
00072 STDMETHODIMP_(ULONG) CEventCallback::Release()
00073 {
00074     LONG cRef = InterlockedDecrement(&m_cRef);
00075
00076     if (cRef == 0)
00077     {
00078         delete this;
00079     }
00080
00081     return cRef;
00082 }
00083
00084 //////////////////////////////////////////////////////////////////////////
00085 //
00086 // CEventCallback::ImageEventCallback
00087 //
00088
00089 STDMETHODIMP CEventCallback::ImageEventCallback(
00090     LPCGUID pEventGuid,
00091     BSTR    bstrEventDescription,
00092     BSTR    bstrDeviceID,
00093     BSTR    bstrDeviceDescription,
00094     DWORD   dwDeviceType,
00095     BSTR    bstrFullItemName,
00096     ULONG  *pulEventType,
00097     ULONG   ulReserved
00098 )
00099 {
00100     return WiaGetNumDevices(NULL, &m_nNumDevices);
00101 }
00102
00103 //////////////////////////////////////////////////////////////////////////
00104 //
00105 // CEventCallback::Register
00106 //
00107
00108 HRESULT CEventCallback::Register()
00109 {
00110     HRESULT hr;
00111
00112     // Create a connection to the local WIA device manager
00113
00114     CComPtr<IWiaDevMgr> pWiaDevMgr;
00115
00116     hr = pWiaDevMgr.CoCreateInstance(CLSID_WiaDevMgr);
00117
00118     if (FAILED(hr))
00119     {
00120         return hr;
00121     }
00122
00123     // Register the callback interface
00124
00125     hr = pWiaDevMgr->RegisterEventCallbackInterface(
00126         0,
00127         NULL,
00128         &WIA_EVENT_DEVICE_CONNECTED,
00129         this,
00130         &m_pConnectEventObject
00131     );
00132
00133     if (FAILED(hr))
00134     {
00135         return hr;
00136     }
00137
00138     hr = pWiaDevMgr->RegisterEventCallbackInterface(
00139         0,
00140         NULL,
00141         &WIA_EVENT_DEVICE_DISCONNECTED,
00142         this,
00143         &m_pDisconnectEventObject
00144     );
00145
00146     if (FAILED(hr))
00147     {
00148         return hr;
00149     }
00150
00151     // Get the current count of all the WIA devices on the system
00152
00153     hr = WiaGetNumDevices(pWiaDevMgr, &m_nNumDevices);
00154
00155     if (FAILED(hr))
00156     {
00157         return hr;
00158     }
00159
00160     return S_OK;
00161 }
00162
00163 //////////////////////////////////////////////////////////////////////////
00164 //
00165 // CEventCallback::GetNumDevices
00166 //
00167
00168 ULONG CEventCallback::GetNumDevices() const
00169 {
00170     return m_nNumDevices;
00171 }
00172
00173 }; // namespace WiaWrap
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/client/main.cpp Source File

  • NetDS
  • RRas
  • rqs
  • client

main.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //      File:       main.cpp
00004 //
00005 //      Synopsis:   Main file for ras quarantine removal utility (client)
00006 //
00007 //      Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //+--------------------------------------------------------------------------
00010
00011 #define MBCS
00012 #include "rasutil.h"
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <limits.h>
00016 #include <ras.h>
00017 #include <raserror.h>
00018
00019 //
00020 //  Define the Ras Version 4.01 RASCONN struct
00021 //
00022 #ifdef _WIN64
00023 #include <pshpack4.h>
00024 #endif
00025
00026 #define RASCONN_V401_A struct tagRASCONN_V401_A
00027 RASCONN_V401_A
00028 {
00029     DWORD    dwSize;
00030     HRASCONN hrasconn;
00031     CHAR     szEntryName[ RAS_MaxEntryName + 1 ];
00032     CHAR     szDeviceType[ RAS_MaxDeviceType + 1 ];
00033     CHAR     szDeviceName[ RAS_MaxDeviceName + 1 ];
00034     CHAR     szPhonebook [ MAX_PATH ];
00035     DWORD    dwSubEntry;
00036 };
00037
00038 #ifdef _WIN64
00039 #include <poppack.h>
00040 #endif
00041
00042 //+--------------------------------------------------------------------------
00043 //
00044 // Synopsis: Common tracing api.
00045 //
00046 //+--------------------------------------------------------------------------
00047 VOID
00048 RqcTrace(
00049     IN LPSTR pszTrace,
00050     IN ...)
00051 {
00052     va_list arglist;
00053     CHAR szTemp[256];
00054
00055     szTemp[0] = 0;
00056
00057     va_start(arglist, pszTrace);
00058     _vsnprintf(szTemp, sizeof(szTemp)/sizeof(szTemp[0]) - 1, pszTrace, arglist);
00059     va_end(arglist);
00060
00061     szTemp[255] = '\0'; // make sure to NULL terminate as _vsnprintf doesn't guarantee that
00062
00063     OutputDebugString(szTemp);
00064     OutputDebugString(TEXT("\n"));
00065 }
00066
00067 //+--------------------------------------------------------------------------
00068 //
00069 // Synopsis: Get the Client IP Address and the Server IP Address for the
00070 //           specified connection.
00071 //
00072 //+--------------------------------------------------------------------------
00073 BOOL IsNT4OrBetter()
00074 {
00075     OSVERSIONINFO oviVersion;
00076     BOOL bReturn = FALSE;
00077
00078     ZeroMemory(&oviVersion,sizeof(oviVersion));
00079     oviVersion.dwOSVersionInfoSize = sizeof(oviVersion);
00080
00081     if (GetVersionEx(&oviVersion))
00082     {
00083         if ((oviVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
00084             (oviVersion.dwMajorVersion >= 4))
00085         {
00086             bReturn = TRUE;
00087         }
00088     }
00089
00090     return bReturn;
00091 }
00092
00093 //+--------------------------------------------------------------------------
00094 //
00095 // Synopsis: Find the given connection name in the list of RASCONN structs
00096 //
00097 //+--------------------------------------------------------------------------
00098 HRASCONN FindConnectionByName (LPRASCONNA pRasConn, DWORD dwCount, LPTSTR pszConnection)
00099 {
00100     HRASCONN hConnection = NULL;
00101
00102     if (pRasConn && pszConnection)
00103     {
00104         for (DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++)
00105         {
00106             //
00107             //  Increment the array index manually since we could have a v4.0 RASCONNA
00108             //  struct or a v4.1 RASCONNA struct.
00109             //
00110             LPRASCONNA pTmpRasConn = (LPRASCONNA)((BYTE*)pRasConn + (pRasConn->dwSize)*dwIndex);
00111
00112             if (0 == lstrcmpi(pszConnection, pTmpRasConn->szEntryName))
00113             {
00114                 //
00115                 //  We have one complication though...  On certain platforms both
00116                 //  parts of a double dial CM connection (dialup part and tunnel part)
00117                 //  have the same name.  We can tell the difference by looking at the
00118                 //  phonebook parameter.  If it has _CMPhone as the phonebook file name
00119                 //  then we know it is actually the dialup part of the double dial connection.
00120                 //
00121                 if (IsNT4OrBetter())
00122                 {
00123                     TCHAR szFileName[_MAX_FNAME];
00124
00125                     _splitpath(((RASCONN_V401_A*)pTmpRasConn)->szPhonebook, NULL, NULL, szFileName, NULL);
00126
00127                     if (0 != lstrcmpi(TEXT("_cmphone"), szFileName))
00128                     {
00129                         //
00130                         //  Okay, we have a match
00131                         //
00132                         hConnection = pTmpRasConn->hrasconn;
00133                         break;
00134                     }
00135                 }
00136                 else
00137                 {
00138                     //
00139                     //  Okay, we have a match
00140                     //
00141                     hConnection = pTmpRasConn->hrasconn;
00142                     break;
00143                 }
00144             }
00145         }
00146     }
00147
00148     return hConnection;
00149 }
00150
00151 //+--------------------------------------------------------------------------
00152 //
00153 // Synopsis: Get the Client IP Address and the Server IP Address for the
00154 //           specified connection.
00155 //
00156 //+--------------------------------------------------------------------------
00157 DWORD GetClientAndServerAddresses(LPTSTR pszConnectionName, LPTSTR pszTunnelConnectionName, OUT LPTSTR pszClientIpAddress, UINT cchClientIpAddress, OUT LPTSTR pszServerIpAddress, UINT cchServerIpAddress)
00158 {
00159     //
00160     //  Check inputs
00161     //
00162     if ((NULL == pszConnectionName) || (NULL == pszTunnelConnectionName) || (NULL == pszClientIpAddress) || (NULL == pszServerIpAddress) || (0 == cchClientIpAddress) || (0 == cchServerIpAddress))
00163     {
00164         return ERROR_INVALID_PARAMETER;
00165     }
00166
00167     pszClientIpAddress[0] = TEXT('\0');
00168     pszServerIpAddress[0] = TEXT('\0');
00169
00170     //
00171     //  First we need to call loadlibrary on RasApi32.dll and then get the function addresses for
00172     //  RasEnumConnections and RasGetProjectionInfo
00173     //
00174     DWORD dwRet = ERROR_SUCCESS;
00175     HMODULE hRasApi32 = NULL;
00176     LPRASCONNA pRasConn = NULL;
00177     typedef DWORD (WINAPI *pfnRasEnumConnectionsSpec)(LPRASCONNA, LPDWORD, LPDWORD);
00178     typedef DWORD (WINAPI *pfnRasGetProjectionInfoSpec)(HRASCONN, RASPROJECTION, LPVOID, LPDWORD);
00179
00180     pfnRasEnumConnectionsSpec pfnRasEnumConnections = NULL;
00181     pfnRasGetProjectionInfoSpec pfnRasGetProjectionInfo = NULL;
00182
00183     __try
00184     {
00185         hRasApi32 = LoadLibrary("rasapi32.dll");
00186
00187         if (hRasApi32)
00188         {
00189             pfnRasEnumConnections = (pfnRasEnumConnectionsSpec)GetProcAddress(hRasApi32, "RasEnumConnectionsA");
00190             pfnRasGetProjectionInfo = (pfnRasGetProjectionInfoSpec)GetProcAddress(hRasApi32, "RasGetProjectionInfoA");
00191
00192             if ((NULL == pfnRasEnumConnections) || (NULL == pfnRasGetProjectionInfo))
00193             {
00194                 dwRet = ERROR_PROC_NOT_FOUND;
00195                 __leave;
00196             }
00197         }
00198         else
00199         {
00200             dwRet = GetLastError();
00201             __leave;
00202         }
00203
00204         //
00205         //  Okay, now call EnumRasConnections to get a list of active connections
00206         //
00207         DWORD dwCount = 0;
00208         DWORD dwSizeOfRasConn = IsNT4OrBetter() ? sizeof(RASCONN_V401_A) : sizeof(RASCONNA);
00209         DWORD dwSize = dwSizeOfRasConn;
00210
00211         do
00212         {
00213             LocalFree(pRasConn);
00214
00215             pRasConn = (RASCONNA*)LocalAlloc(LMEM_ZEROINIT, dwSize);
00216
00217             if (pRasConn)
00218             {
00219                 pRasConn->dwSize = dwSizeOfRasConn;
00220
00221                 dwRet = pfnRasEnumConnections(pRasConn, &dwSize, &dwCount);
00222
00223                 if ((ERROR_BUFFER_TOO_SMALL != dwRet) && (ERROR_SUCCESS != dwRet))
00224                 {
00225                     //
00226                     //  RAS error, bail.
00227                     //
00228                     __leave;
00229                 }
00230             }
00231             else
00232             {
00233                 dwRet = ERROR_NOT_ENOUGH_MEMORY;
00234                 __leave;
00235             }
00236
00237         } while (ERROR_BUFFER_TOO_SMALL == dwRet);
00238
00239         //
00240         //  Okay, so now we have a buffer of connections.  Let's look
00241         //  through them for a match to the passed in connection name.
00242         //  Figure out if we are looking for the tunnel connection name
00243         //  or the dialup connection name
00244         //
00245         LPTSTR pszConnection = pszTunnelConnectionName;
00246         HRASCONN hConnection = NULL;
00247
00248         if (0 == lstrcmpi(pszTunnelConnectionName, TEXT("NULL")))
00249         {
00250             pszConnection = pszConnectionName;
00251         }
00252         //else use pszTunnelConnectionName as saved above
00253
00254         hConnection = FindConnectionByName (pRasConn, dwCount, pszConnection);
00255
00256         //
00257         //  Okay, now we have the right connection so we can call RasGetProjectionInfo to actually get the data we want
00258         //
00259         if (hConnection)
00260         {
00261             RASPROJECTION RasProj = RASP_PppIp;
00262             RASPPPIP RasPPPIP;
00263             DWORD dwBufSize = sizeof(RASPPPIP);
00264
00265             ZeroMemory(&RasPPPIP, dwBufSize);
00266             RasPPPIP.dwSize = dwBufSize;
00267
00268             dwRet = pfnRasGetProjectionInfo(hConnection, RASP_PppIp, (PVOID)&RasPPPIP, &dwBufSize);
00269
00270             if (ERROR_SUCCESS == dwRet)
00271             {
00272                 lstrcpyn(pszClientIpAddress, RasPPPIP.szIpAddress, cchClientIpAddress);
00273                 lstrcpyn(pszServerIpAddress, RasPPPIP.szServerIpAddress, cchClientIpAddress);
00274             }
00275         }
00276         else
00277         {
00278             dwRet = ERROR_NO_CONNECTION;
00279             __leave;
00280         }
00281
00282     }
00283
00284     __finally
00285     {
00286         if (hRasApi32)
00287         {
00288             FreeLibrary(hRasApi32);
00289         }
00290
00291         LocalFree(pRasConn);
00292     }
00293
00294     if (ERROR_SUCCESS != dwRet)
00295     {
00296         RqcTrace("GetClientAndServerAddresses failed with error = %d", dwRet);
00297     }
00298
00299     return dwRet;
00300 }
00301
00302 //+--------------------------------------------------------------------------
00303 //
00304 // Synopsis: Returns a properly formatted username and domain pair.  This
00305 //           with be one of the following:
00306 //
00307 //           "domain\username"
00308 //           "username"
00309 //
00310 //           It is the caller's responsibility to free the returned buffer.
00311 //           Note that we also append the colon separator (:).
00312 //
00313 //+--------------------------------------------------------------------------
00314 PCHAR GenerateUserName(PCHAR pszUsername, PCHAR pszDomain)
00315 {
00316     BOOL bHaveUserName = pszUsername && (0 != lstrcmpi(pszUsername, "NULL"));
00317     BOOL bHaveDomain = pszDomain && (0 != lstrcmpi(pszDomain, "NULL"));
00318
00319     //  Allocate the maximum amount of memory we will need.  Note that
00320     //  we add 3 extra, one for the \, one for the :, and one for the null
00321     //  terminator.
00322     //
00323     PCHAR pszReturn = (PCHAR)RuAlloc(3 + (bHaveDomain ? (UINT)strlen(pszDomain) : 0) + (bHaveUserName ? (UINT)strlen(pszUsername) : 0), TRUE);
00324     if (pszReturn)
00325     {
00326         if (bHaveUserName)
00327         {
00328             if (bHaveDomain)
00329             {
00330                 // return domain + \ + username
00331                 sprintf(pszReturn, "%s\\%s:", pszDomain, pszUsername);
00332             }
00333             else
00334             {
00335                // return dup of username
00336                 sprintf(pszReturn, "%s:", pszUsername);
00337             }
00338         }
00339     }
00340
00341     return pszReturn;
00342 }
00343
00344 //+--------------------------------------------------------------------------
00345 //
00346 // Synopsis: Prints a usage message for the command line of rqc.exe.
00347 //
00348 //+--------------------------------------------------------------------------
00349 void PrintUsage(char *argv[ ])
00350 {
00351     printf("\nRemote Access Quarantine Client\n");
00352
00353     printf("\nUsage:\n\n");
00354     printf("%s <ConnName> <TunnelConnName> <Port> <Domain> <Username> <String>\n\n", argv[0]);
00355     printf("  ConnName:\t\tthe name of the RAS connection on this host\n");
00356     printf("  TunnelConnName:\tthe name of the RAS tunnel connection on this host\n");
00357     printf("  Port:\t\t\tthe port to send the quarantine string to\n");
00358     printf("  Domain:\t\tthe domain of the connecting user\n");
00359     printf("  Username:\t\tthe username of the connecting user\n");
00360     printf("  String:\t\tthe string to send\n");
00361     printf("\n");
00362
00363     printf("%s /?\t\t\n\n  Display this help\n", argv[0]);
00364 }
00365
00366 //+--------------------------------------------------------------------------
00367 //
00368 // Synopsis: Main routine
00369 //
00370 //  Usage:  rqc <ConnectionName> <TunnelConnectionName> <port> <domain> <username> <string>
00371 //
00372 //    ConnectionName:       the name of the RAS connection on this host
00373 //    TunnelConnectionName:     the name of the RAS tunnel connection on this host
00374 //    port:         the port to send the quarantine string
00375 //    domain:         the domain of the user
00376 //    username:                 the username of the connecting user
00377 //    string:       the string to send
00378 //
00379 //  Note:  For the ConnectionName and TunnelConnectionName parameters, you will
00380 //         only have both if doing a double dial connection (dialup connection
00381 //         to the internet and a tunnel connection over it).  If you do not have
00382 //         both, then the text "NULL" should be passed for the unused parameter.
00383 //         See the GetClientAndServerAddresses function for more information
00384 //         on how these parameters are used.
00385 //
00386 //+--------------------------------------------------------------------------
00387 int
00388 __cdecl
00389 main(
00390     int argc,
00391     char *argv[ ],
00392     char *envp[ ])
00393 {
00394     HRESULT hr;
00395     RuSocket Socket;
00396     ULONG ulPort;
00397     UINT uiStringSize, uiBufSize, uiSizeOrig;
00398     CHAR pszResponse[4], pszPrefix[64];
00399     INT iRet;
00400
00401     PCHAR pszConnectionName, pszTunnelConnectionName, pszPort;
00402     PCHAR pszDomain, pszUsername, pszString;
00403     PCHAR pszUsernameAndDomain = NULL;
00404     CHAR szMyIp[RAS_MaxIpAddress + 1];
00405     CHAR szDstIp[RAS_MaxIpAddress + 1];
00406
00407     //
00408     //  Check to see if they asked for a usage message
00409     //
00410     if ((argc == 2) && (strcmp(argv[1], "/?") == 0))
00411     {
00412         PrintUsage(argv);
00413         return -1;
00414     }
00415
00416     //
00417     //  Make sure we got the required number of arguments
00418     //
00419     if (argc < 7)
00420     {
00421         return -1;
00422     }
00423
00424     // Save the input params
00425     //
00426     pszConnectionName = argv[1];
00427     pszTunnelConnectionName = argv[2];
00428     pszPort = argv[3];
00429     pszDomain = argv[4];
00430     pszUsername = argv[5];
00431     pszString = argv[6];
00432
00433
00434     iRet = -1;
00435
00436     // Get the client and server IP's
00437     //
00438     if (ERROR_SUCCESS != GetClientAndServerAddresses(pszConnectionName,
00439                                                      pszTunnelConnectionName,
00440                                                      szMyIp,
00441                                                      sizeof(szMyIp)/sizeof(szMyIp[0]),
00442                                                      szDstIp,
00443                                                      sizeof(szDstIp)/sizeof(szDstIp[0])))
00444     {
00445         RqcTrace("GetClientAndServerAddresses failed!");
00446         iRet = -1;
00447         goto exit;
00448     }
00449
00450     //  Generate the username and domain string
00451     //
00452     pszUsernameAndDomain = GenerateUserName(pszUsername, pszDomain);
00453
00454     if (NULL == pszUsernameAndDomain)
00455     {
00456         RqcTrace("GenerateUserName failed!");
00457         iRet = -1;
00458         goto exit;
00459     }
00460
00461     // Calculate the sizes
00462     //
00463     uiStringSize = (UINT)strlen(pszString) + (UINT)(strlen(pszUsernameAndDomain)) + 1;
00464
00465     if ((uiStringSize == 0) || (uiStringSize > 1024))
00466     {
00467         RqcTrace("Invalid string length. %d", uiStringSize);
00468         iRet = -1;
00469         goto exit;
00470     }
00471     uiBufSize = uiStringSize + 3;       // 3 = len(":1:")
00472
00473     // Initialize the socket library
00474     //
00475     RqcTrace("Initializing sockets api");
00476     hr = RuSocket::Initialize();
00477     if (S_OK != hr)
00478     {
00479         RqcTrace("Unable to use sockets. %1!d!", hr);
00480         iRet = -1;
00481         goto exit;
00482     }
00483
00484     // Covert the port over
00485     //
00486     ulPort = (UINT) atoi(pszPort);
00487     if ((ulPort == 0) || (ulPort == ULONG_MAX) || (ulPort > 65 * 1024))
00488     {
00489         RqcTrace("Invalid port.  %d", ulPort);
00490         goto exit;
00491     }
00492
00493     // Open the socket
00494     //
00495     RqcTrace("Opening socket...");
00496     hr = Socket.Open(ulPort, szDstIp, szMyIp);
00497     if (S_OK != hr)
00498     {
00499         RqcTrace("Unable to open socket 0x%x", hr);
00500         iRet = 1;
00501         goto exit;
00502     }
00503
00504     // Send the prefix.  Size:1:
00505     //
00506     RqcTrace("Writing prefix...");
00507     sprintf(pszPrefix, "%04d:1:", uiBufSize);
00508     uiSizeOrig = uiBufSize = (UINT)strlen(pszPrefix);
00509     hr = Socket.Write((BYTE*)pszPrefix, &uiBufSize);
00510     if ((S_OK != hr) || (uiSizeOrig != uiBufSize))
00511     {
00512         RqcTrace(
00513             "Can't write prefix 0x%x, %d %d",
00514             hr,
00515             uiBufSize,
00516             uiSizeOrig);
00517         iRet = 1;
00518         goto exit;
00519     }
00520
00521     //
00522     // Send the Username and Domain
00523     RqcTrace("Writing username...");
00524     uiSizeOrig = uiBufSize = (UINT)strlen(pszUsernameAndDomain);
00525     hr = Socket.Write((BYTE*)pszUsernameAndDomain, &uiBufSize);
00526     if ((S_OK != hr) || (uiSizeOrig != uiBufSize))
00527     {
00528         RqcTrace(
00529             "Can't write the username 0x%x, %d %d",
00530             hr,
00531             uiBufSize,
00532             uiSizeOrig);
00533
00534         iRet = 1;
00535         goto exit;
00536     }
00537
00538     // Send the string
00539     //
00540     RqcTrace("Writing version string...");
00541     uiSizeOrig = uiBufSize = (UINT)strlen(pszString) + 1;
00542     hr = Socket.Write((BYTE*)pszString, &uiBufSize);
00543     if ((S_OK != hr) || (uiSizeOrig != uiBufSize))
00544     {
00545         RqcTrace(
00546             "Can't write string 0x%x, %d %d",
00547             hr,
00548             uiBufSize,
00549             uiSizeOrig);
00550
00551         iRet = 1;
00552         goto exit;
00553     }
00554
00555     // Receive the response
00556     //
00557     RqcTrace("Reading response...");
00558     ZeroMemory(pszResponse, sizeof(pszResponse));
00559     uiSizeOrig = uiBufSize = sizeof(pszResponse) - 1;
00560     hr = Socket.Read((BYTE*)pszResponse, &uiBufSize);
00561     if ((S_OK != hr) || (uiSizeOrig != uiBufSize))
00562     {
00563         RqcTrace(
00564             "Can't read, 0x%x, %d %d",
00565             hr,
00566             uiBufSize,
00567             uiSizeOrig);
00568
00569         goto exit;
00570     }
00571
00572     RqcTrace("Response: %s", pszResponse);
00573
00574     if (strcmp(pszResponse, "Ok") == 0)
00575     {
00576         iRet = 0;
00577     }
00578     else if (strcmp(pszResponse, "No") == 0)
00579     {
00580         iRet = 2;
00581     }
00582
00583 exit:
00584     RuFree(pszUsernameAndDomain);
00585     RqcTrace("Closing socket...");
00586     Socket.Close();
00587     RqcTrace("Cleanup socket api...");
00588     RuSocket::Cleanup();
00589
00590     return iRet;
00591 }
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/CacheProxy/cplusplus/Resource.h Source File

  • Multimedia
  • WindowsMediaServices9
  • CacheProxy
  • cplusplus

Resource.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 //
00003 // Microsoft Windows Media
00004 // Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 // FileName:            Resource.h
00007 //
00008 // Abstract:
00009 //
00010 //*****************************************************************************
00011
00012 #pragma once
00013 //{{NO_DEPENDENCIES}}
00014 // Microsoft Developer Studio generated include file.
00015 // Used by ProxyPlugin.rc
00016 //
00017 #define IDS_PROJNAME                    100
00018 #define IDR_PROXYPLUGIN                 101
00019
00020 // Next default values for new objects
00021 //
00022 #ifdef APSTUDIO_INVOKED
00023 #ifndef APSTUDIO_READONLY_SYMBOLS
00024 #define _APS_NEXT_RESOURCE_VALUE        201
00025 #define _APS_NEXT_COMMAND_VALUE         32768
00026 #define _APS_NEXT_CONTROL_VALUE         201
00027 #define _APS_NEXT_SYMED_VALUE           102
00028 #endif
00029 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Connection15.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Connection15.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Connection15
00019 /** @com.interface(iid=00000515-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Connection15 extends msado15._ADO
00021 {
00022   /** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
00023       @com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00024   public msado15.Properties getProperties();
00025
00026   /** @com.method(vtoffset=5, dispid=0, type=PROPGET, name="ConnectionString", name2="getConnectionString", addFlagsVtable=4)
00027       @com.parameters([type=STRING] return) */
00028   public String getConnectionString();
00029
00030   /** @com.method(vtoffset=6, dispid=0, type=PROPPUT, name="ConnectionString", name2="putConnectionString", addFlagsVtable=4)
00031       @com.parameters([in,type=STRING] pbstr) */
00032   public void setConnectionString(String pbstr);
00033
00034   /** @com.method(vtoffset=7, dispid=2, type=PROPGET, name="CommandTimeout", name2="getCommandTimeout", addFlagsVtable=4)
00035       @com.parameters([type=I4] return) */
00036   public int getCommandTimeout();
00037
00038   /** @com.method(vtoffset=8, dispid=2, type=PROPPUT, name="CommandTimeout", name2="putCommandTimeout", addFlagsVtable=4)
00039       @com.parameters([in,type=I4] plTimeout) */
00040   public void setCommandTimeout(int plTimeout);
00041
00042   /** @com.method(vtoffset=9, dispid=3, type=PROPGET, name="ConnectionTimeout", name2="getConnectionTimeout", addFlagsVtable=4)
00043       @com.parameters([type=I4] return) */
00044   public int getConnectionTimeout();
00045
00046   /** @com.method(vtoffset=10, dispid=3, type=PROPPUT, name="ConnectionTimeout", name2="putConnectionTimeout", addFlagsVtable=4)
00047       @com.parameters([in,type=I4] plTimeout) */
00048   public void setConnectionTimeout(int plTimeout);
00049
00050   /** @com.method(vtoffset=11, dispid=4, type=PROPGET, name="Version", name2="getVersion", addFlagsVtable=4)
00051       @com.parameters([type=STRING] return) */
00052   public String getVersion();
00053
00054   /** @com.method(vtoffset=12, dispid=5, type=METHOD, name="Close", addFlagsVtable=4)
00055       @com.parameters() */
00056   public void Close();
00057
00058   /** @com.method(vtoffset=13, dispid=6, type=METHOD, name="Execute", addFlagsVtable=4)
00059       @com.parameters([in,type=STRING] CommandText, [out,elementType=VARIANT,type=PTR] RecordsAffected, [in,type=I4] Options, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00060   public msado15._Recordset Execute(String CommandText, Variant RecordsAffected, int Options);
00061
00062   /** @com.method(vtoffset=14, dispid=7, type=METHOD, name="BeginTrans", addFlagsVtable=4)
00063       @com.parameters([type=I4] return) */
00064   public int BeginTrans();
00065
00066   /** @com.method(vtoffset=15, dispid=8, type=METHOD, name="CommitTrans", addFlagsVtable=4)
00067       @com.parameters() */
00068   public void CommitTrans();
00069
00070   /** @com.method(vtoffset=16, dispid=9, type=METHOD, name="RollbackTrans", addFlagsVtable=4)
00071       @com.parameters() */
00072   public void RollbackTrans();
00073
00074   /** @com.method(vtoffset=17, dispid=10, type=METHOD, name="Open", addFlagsVtable=4)
00075       @com.parameters([in,type=STRING] ConnectionString, [in,type=STRING] UserID, [in,type=STRING] Password, [in,type=I4] Options) */
00076   public void Open(String ConnectionString, String UserID, String Password, int Options);
00077
00078   /** @com.method(vtoffset=18, dispid=11, type=PROPGET, name="Errors", name2="getErrors", addFlagsVtable=4)
00079       @com.parameters([iid=00000501-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00080   public msado15.Errors getErrors();
00081
00082   /** @com.method(vtoffset=19, dispid=12, type=PROPGET, name="DefaultDatabase", name2="getDefaultDatabase", addFlagsVtable=4)
00083       @com.parameters([type=STRING] return) */
00084   public String getDefaultDatabase();
00085
00086   /** @com.method(vtoffset=20, dispid=12, type=PROPPUT, name="DefaultDatabase", name2="putDefaultDatabase", addFlagsVtable=4)
00087       @com.parameters([in,type=STRING] pbstr) */
00088   public void setDefaultDatabase(String pbstr);
00089
00090   /** @com.method(vtoffset=21, dispid=13, type=PROPGET, name="IsolationLevel", name2="getIsolationLevel", addFlagsVtable=4)
00091       @com.parameters([type=I4] return) */
00092   public int getIsolationLevel();
00093
00094   /** @com.method(vtoffset=22, dispid=13, type=PROPPUT, name="IsolationLevel", name2="putIsolationLevel", addFlagsVtable=4)
00095       @com.parameters([in,type=I4] Level) */
00096   public void setIsolationLevel(int Level);
00097
00098   /** @com.method(vtoffset=23, dispid=14, type=PROPGET, name="Attributes", name2="getAttributes", addFlagsVtable=4)
00099       @com.parameters([type=I4] return) */
00100   public int getAttributes();
00101
00102   /** @com.method(vtoffset=24, dispid=14, type=PROPPUT, name="Attributes", name2="putAttributes", addFlagsVtable=4)
00103       @com.parameters([in,type=I4] plAttr) */
00104   public void setAttributes(int plAttr);
00105
00106   /** @com.method(vtoffset=25, dispid=15, type=PROPGET, name="CursorLocation", name2="getCursorLocation", addFlagsVtable=4)
00107       @com.parameters([type=I4] return) */
00108   public int getCursorLocation();
00109
00110   /** @com.method(vtoffset=26, dispid=15, type=PROPPUT, name="CursorLocation", name2="putCursorLocation", addFlagsVtable=4)
00111       @com.parameters([in,type=I4] plCursorLoc) */
00112   public void setCursorLocation(int plCursorLoc);
00113
00114   /** @com.method(vtoffset=27, dispid=16, type=PROPGET, name="Mode", name2="getMode", addFlagsVtable=4)
00115       @com.parameters([type=I4] return) */
00116   public int getMode();
00117
00118   /** @com.method(vtoffset=28, dispid=16, type=PROPPUT, name="Mode", name2="putMode", addFlagsVtable=4)
00119       @com.parameters([in,type=I4] plMode) */
00120   public void setMode(int plMode);
00121
00122   /** @com.method(vtoffset=29, dispid=17, type=PROPGET, name="Provider", name2="getProvider", addFlagsVtable=4)
00123       @com.parameters([type=STRING] return) */
00124   public String getProvider();
00125
00126   /** @com.method(vtoffset=30, dispid=17, type=PROPPUT, name="Provider", name2="putProvider", addFlagsVtable=4)
00127       @com.parameters([in,type=STRING] pbstr) */
00128   public void setProvider(String pbstr);
00129
00130   /** @com.method(vtoffset=31, dispid=18, type=PROPGET, name="State", name2="getState", addFlagsVtable=4)
00131       @com.parameters([type=I4] return) */
00132   public int getState();
00133
00134   /** @com.method(vtoffset=32, dispid=19, type=METHOD, name="OpenSchema", addFlagsVtable=4)
00135       @com.parameters([in,type=I4] Schema, [in,type=VARIANT] Restrictions, [in,type=VARIANT] SchemaID, [iid=00000556-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00136   public msado15._Recordset OpenSchema(int Schema, Variant Restrictions, Variant SchemaID);
00137
00138
00139   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x515, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00140 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADQI/ADQI.h Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADQI

ADQI.h

Go to the documentation of this file.
00001 // ADQI.h : main header file for the ADQI application
00002 //
00003
00004 #if !defined(AFX_ADQI_H__8170976F_0672_11D2_B218_0000F87A6B50__INCLUDED_)
00005 #define AFX_ADQI_H__8170976F_0672_11D2_B218_0000F87A6B50__INCLUDED_
00006
00007 #if _MSC_VER >= 1000
00008 #pragma once
00009 #endif // _MSC_VER >= 1000
00010
00011 #ifndef __AFXWIN_H__
00012   #error include 'stdafx.h' before including this file for PCH
00013 #endif
00014
00015 #include "resource.h"   // main symbols
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CADQIApp:
00019 // See ADQI.cpp for the implementation of this class
00020 //
00021
00022 #define App ((CADQIApp*)AfxGetApp())
00023 class CADQIApp : public CWinApp
00024 {
00025 public:
00026   CADQIApp();
00027   HRESULT ADsOpenObject( LPWSTR pszPath, REFIID riid, void**pUnk );
00028   void SetCredentials( LPCTSTR pszUserName, DWORD dwFlag );
00029
00030
00031 // Overrides
00032   // ClassWizard generated virtual function overrides
00033   //{{AFX_VIRTUAL(CADQIApp)
00034   public:
00035   virtual BOOL InitInstance();
00036   //}}AFX_VIRTUAL
00037
00038   protected:
00039     CComBSTR m_sUserName;
00040     DWORD    m_dwFlag;
00041
00042
00043 // Implementation
00044
00045   //{{AFX_MSG(CADQIApp)
00046     // NOTE - the ClassWizard will add and remove member functions here.
00047     //    DO NOT EDIT what you see in these blocks of generated code !
00048   //}}AFX_MSG
00049   DECLARE_MESSAGE_MAP()
00050 };
00051
00052
00053 /////////////////////////////////////////////////////////////////////////////
00054
00055 //{{AFX_INSERT_LOCATION}}
00056 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00057
00058 #endif // !defined(AFX_ADQI_H__8170976F_0672_11D2_B218_0000F87A6B50__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/backgrnd.h Source File

  • SysMgmt
  • MMC
  • Nodes

backgrnd.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _BACKGROUND_H
00021 #define _BACKGROUND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CBackground : public CDelegationBase {
00026 public:
00027     CBackground(int id) : m_itemId(NULL), m_id(id) { }
00028     virtual ~CBackground() {}
00029
00030     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00031     virtual const GUID & getNodeType() { return thisGuid; }
00032     virtual const int GetBitmapIndex() { return INDEX_BACKGROUND; }
00033
00034     void SetHandle(HSCOPEITEM itemId) { m_itemId = itemId; }
00035     HSCOPEITEM GetHandle() { return m_itemId; }
00036
00037 private:
00038     enum { IDM_NEW_BACKGROUND = 6 };
00039
00040     static const GUID thisGuid;
00041     int m_id;
00042     HSCOPEITEM m_itemId;
00043 };
00044
00045 class CBackgroundFolder : public CDelegationBase {
00046 public:
00047     CBackgroundFolder();
00048     virtual ~CBackgroundFolder();
00049
00050     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Background Objects"); }
00051     virtual const GUID & getNodeType() { return thisGuid; }
00052     virtual const int GetBitmapIndex() { return INDEX_BACKGROUND; }
00053
00054 public:
00055     // virtual functions go here (for MMCN_*)
00056     virtual HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00057     virtual HRESULT OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect);
00058     virtual HRESULT OnAddImages(IImageList *pImageList, HSCOPEITEM hsi);
00059     virtual HRESULT OnRefresh();
00060
00061 private:
00062     enum { MAX_CHILDREN = 30 };
00063
00064     CBackground *m_children[MAX_CHILDREN];
00065
00066     HWND m_backgroundHwnd;
00067
00068     static const GUID thisGuid;
00069
00070     static LRESULT CALLBACK WindowProc(
00071           HWND hwnd,      // handle to window
00072           UINT uMsg,      // message identifier
00073           WPARAM wParam,  // first message parameter
00074           LPARAM lParam   // second message parameter
00075         );
00076
00077     static DWORD WINAPI ThreadProc(
00078       LPVOID lpParameter   // thread data
00079     );
00080
00081     DWORD m_threadId;
00082     HANDLE m_thread;
00083     bool m_running;
00084
00085     IConsoleNameSpace *m_pConsoleNameSpace;
00086     HSCOPEITEM m_scopeitem;
00087     void AddItem(int id);
00088
00089     CRITICAL_SECTION m_critSect;
00090
00091     void StopThread();
00092     void StartThread();
00093
00094     bool m_bSelected;
00095     bool m_bViewUpdated;
00096 };
00097
00098
00099 #endif // _BACKGROUND_H
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagDELETELOGERRORMSG Member List

This is the complete list of members for _tagDELETELOGERRORMSG, including all inherited members.
dwReserved | _tagDELETELOGERRORMSG
ErrorID | _tagDELETELOGERRORMSG
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_USER_INFO Member List

This is the complete list of members for _USER_INFO, including all inherited members.
achNTUserName | _USER_INFO
achNTUserPassword | _USER_INFO
achPassword | _USER_INFO
achUserName | _USER_INFO
ListEntry | _USER_INFO
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CADVCGENApp Member List

This is the complete list of members for CADVCGENApp, including all inherited members.
AppInitialize(HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *pszCmdLine, INT nCmdShow) | CAppLite |
CADVCGENApp() | CADVCGENApp |
CAppLite(UINT nAppID) | CAppLite |
CWinApp() | CWinApp |
ExitInstance() | CWinApp | [virtual]
InitInstance() | CADVCGENApp | [virtual]
m_hInstance | CAppLite |
m_hPrevInstance | CAppLite |
m_hWndModeless | CAppLite | [static]
m_nAppID | CAppLite |
m_nCmdShow | CAppLite |
m_pCMainWindow | CAppLite | [static]
m_pCMallocSpy | CWinApp |
m_pszCmdLine | CAppLite |
Run() | CAppLite | [virtual]
~CAppLite() | CAppLite | [virtual]
~CWinApp() | CWinApp | [virtual]
Generated on Wed Nov 13 2024 16:55:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

MYTOOLINFO Member List

This is the complete list of members for MYTOOLINFO, including all inherited members.
bState | MYTOOLINFO
bStyle | MYTOOLINFO
idCommand | MYTOOLINFO
idString | MYTOOLINFO
iImage | MYTOOLINFO
uImageSet | MYTOOLINFO
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/Imp_Draw/LoginDlg.h Source File

  • NetDS
  • MessageQueuing
  • Imp_Draw

LoginDlg.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011
00012 //
00013 // logindlg.h : header file
00014 //
00015
00016
00017 /////////////////////////////////////////////////////////////////////////////
00018 // CLoginDlg dialog
00019
00020 class CLoginDlg : public CDialog
00021 {
00022 // Construction
00023 public:
00024   CLoginDlg(CWnd* pParent = NULL);   // standard constructor
00025
00026 // Dialog Data
00027   //{{AFX_DATA(CLoginDlg)
00028   enum { IDD = IDD_LOGIN };
00029   CString m_strLogin;
00030   //}}AFX_DATA
00031
00032
00033 // Overrides
00034   // ClassWizard generated virtual function overrides
00035   //{{AFX_VIRTUAL(CLoginDlg)
00036   protected:
00037   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00038   //}}AFX_VIRTUAL
00039
00040 // Implementation
00041 protected:
00042
00043   // Generated message map functions
00044   //{{AFX_MSG(CLoginDlg)
00045     // NOTE: the ClassWizard will add member functions here
00046   //}}AFX_MSG
00047   DECLARE_MESSAGE_MAP()
00048 };
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMonitor Member List

This is the complete list of members for CMonitor, including all inherited members.
AddRef() | CMonitor |
CMonitor() | CMonitor | [inline]
JobError(IBackgroundCopyJob *pJob, IBackgroundCopyError *pError) | CMonitor |
JobModification(IBackgroundCopyJob *pJob, DWORD dwReserved) | CMonitor |
JobTransferred(IBackgroundCopyJob *pJob) | CMonitor |
m_lRefCount | CMonitor | [private]
ProcessReply(IBackgroundCopyJob *pJob) | CMonitor | [private]
QueryInterface(REFIID riid, LPVOID *ppvObj) | CMonitor |
Release() | CMonitor |
~CMonitor() | CMonitor | [inline]
Generated on Wed Nov 13 2024 16:56:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

vcacct::CGetReceipt Member List

This is the complete list of members for vcacct::CGetReceipt, including all inherited members.
clsid | vcacct::CGetReceipt | [static]
GetNextReceipt() | vcacct::CGetReceipt |
iid | vcacct::CGetReceipt | [static]
Generated on Wed Nov 13 2024 16:58:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/BYOT/Client/BYOTTransaction/StdAfx.Cpp Source File

  • Com
  • Services
  • BYOT
  • Client
  • BYOTTransaction

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AppUtil/AppUtil.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • AppUtil

AppUtil.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      APPUTIL.H
00003
00004   Summary:   Include file for the general application utility classes
00005              and functions offered by the APPUTIL library.  APPUTIL is
00006              meant to be statically linked to applications that want
00007              to exploit it.
00008
00009              For a comprehensive tutorial code tour of APPUTIL's
00010              contents and offerings see the tutorial APPUTIL.HTM file.
00011              For more specific details on the internal workings see the
00012              comments dispersed throughout the APPUTIL source code.
00013
00014   Classes:   CVirWindow, CVirDialog, CAboutBox, CDelayBox, CMsgBox, CMsgLog,
00015              CSendLog, CThreaded.
00016
00017   Functions: WindowProc, DialogProc, SkipAnsi, FileExist, MakeFamilyPath,
00018              GetExeName, CmdExec, HrMsg, HrMsgId, ReadHelp, ReadTutorial,
00019              GoWeb, ReadSource, OutputDebugFmt, DComOk, lRandom, AnsiToUc,
00020              UcToAnsi, A_StringFromGUID2, A_WriteFmtUserTypeStg,
00021              A_StgIsStorageFile, A_StgCreateDocfile, A_StgOpenStorage,
00022              DelayBox, ErrorBox, CreateColorScalePalette, PaintWindow,
00023              GetErrorMsg.
00024
00025   Origin:    8-28-97: atrent - Revised (based on WINHLPRS by stevebl).
00026
00027 ----------------------------------------------------------------------------
00028   This file is part of the Microsoft COM Tutorial Code Samples.
00029
00030   Copyright (C) 1995 - 2002 Microsoft Corporation.  All rights reserved.
00031
00032   This source code is intended only as a supplement to Microsoft
00033   Development Tools and/or on-line documentation.  See these other
00034   materials for detailed information regarding Microsoft code samples.
00035
00036   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00037   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00038   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00039   PARTICULAR PURPOSE.
00040 ==========================================================================+*/
00041
00042 // Don't allow recursive includes of this file.
00043 #ifndef APPUTIL_H
00044 #define APPUTIL_H
00045
00046
00047 /*--------------------------------------------------------------------------
00048   The following pragma disables the C4355 warning which reads:
00049
00050   "'this': used in base member initializer list."
00051
00052   This warning is triggered by the nested interface implementation
00053   classes--a coding technique used throughout the sample series. The
00054   warning says: "The 'this' pointer is only valid within nonstatic member
00055   functions, but was used in the initializer list for a base class. This
00056   is a level 1 warning when Microsoft extensions are enabled (/Ze) but a
00057   level 4 warning otherwise."  The initializer technique is necessary for
00058   the coding of nested class interface implementations. See COMOBJ.HTM for
00059   details on the technique.
00060 --------------------------------------------------------------------------*/
00061 #pragma warning( disable : 4355 )
00062
00063
00064 // Needed #include for assertion checking
00065 #include <assert.h>
00066
00067
00068 // Convenient typedefs.
00069 #ifndef PPVOID
00070 typedef LPVOID* PPVOID;
00071 #endif
00072
00073
00074 // Convenient macros.
00075
00076 #define DELETE_POINTER(p)\
00077 {\
00078   if (NULL != p)\
00079   {\
00080     delete p;\
00081     p = NULL;\
00082   }\
00083 }
00084
00085 #define RELEASE_INTERFACE(p)\
00086 {\
00087   IUnknown* pTmp = (IUnknown*)p;\
00088   p = NULL;\
00089   if (NULL != pTmp)\
00090     pTmp->Release();\
00091 }
00092
00093 // An enumeration of persistent storage states for use in the
00094 // implementation of IPersistStorage.
00095 typedef enum
00096 {
00097   PERS_UNINIT = 0,  // Uninitialized.
00098   PERS_SCRIBBLE,    // Write     permitted; Read     permitted.
00099   PERS_NOSCRIBBLE,  // Write NOT permitted; Read     permitted.
00100   PERS_HANDSOFF     // Write NOT permitted; Read NOT permitted.
00101 } PERSTGSTATE;
00102
00103 // PCRTTHREADPROC is a type for pointer variables that hold addresses of
00104 // C-RunTime thread procedures.
00105 typedef unsigned (WINAPI *PCRTTHREADPROC)(LPVOID pThreadProc);
00106
00107 #define GETINSTANCE(hWnd)   (HANDLE)GetWindowLong(hWnd,GWL_HINSTANCE)
00108 #define GETCLASSBRUSH(hWnd) (HBRUSH)GetClassLong(hWnd,GCL_HBRBACKGROUND)
00109
00110
00111 // Some General defines for Message Boxes and Dialogs
00112 #define GUID_SIZE 128
00113 #define MAX_STRING_LENGTH 256
00114 #define MAX_LINE_NUM 99999
00115 #define MAX_LINE_CHARS 5
00116 #define DEBUG_FMT_CHARS 8
00117 #define MAXLOGST MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS
00118 #define MAX_LOG_LINES 500
00119 #define DELAYBOX_DURATION 3000
00120
00121 #define COLOR_SCALE_RED     1
00122 #define COLOR_SCALE_GREEN   2
00123 #define COLOR_SCALE_BLUE    3
00124 #define COLOR_SCALE_GRAY    4
00125
00126 #define EDITOR_EXE_STR "notepad.exe "
00127 #define TUTORIAL_EXE_STR "tutorial.exe "
00128 #define OFN_SOURCEFILES_STR "Source Files (*.CPP;*.H;*.RC;*.C;*.MAK;*.TXT;*.)\0*.CPP;*.H;*.RC;*.C;*.MAK;*.TXT;makefile\0"
00129 #define OFN_SOURCETITLE_STR "Open Source File"
00130 #define NOTICE_TITLE_STR "-Notice-"
00131 #define ERROR_TITLE_STR "-Error-"
00132 #define NOCOM_ERROR_STR "Can't Init COM."
00133 #define NOEDITOR_ERROR_STR "Can't run editor."
00134 #define NOTUTORIAL_ERROR_STR "Can't run tutorial."
00135 #define NOTXT_ERROR_STR "Can't find .TXT file."
00136 #define NOHTM_ERROR_STR "Can't find .HTM file."
00137 #define NOBROWSE_ERROR_STR "Can't run browser."
00138 #define ASSERTFAIL_ERROR_STR "Assertion Failed."
00139 #define HELP_FILE_EXT    ".htm"
00140 #define HTML_FILE_EXT    ".htm"
00141 #define TXT_FILE_EXT     ".txt"
00142 #define LICENSE_FILE_EXT ".lic"
00143
00144
00145 #ifdef __cplusplus
00146 // If compiling under C++ Ensure that Windows callbacks are
00147 // undecorated extern C calls.
00148 extern "C" {
00149 #endif
00150
00151
00152 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00153   Function: WindowProc
00154
00155   Summary:  Standard WindowProc callback function that forwards Windows
00156             messages on to the CVirWindow::WindowProc method.  This
00157             Window procedure expects that it will receive a "this"
00158             pointer as the lpCreateParams member passed as part of the
00159             WM_NCCREATE message.  It saves the "this" pointer in the
00160             GWL_USERDATA field of the window structure.
00161
00162   Args:     HWND hWnd,
00163               Window handle
00164             UINT uMsg,
00165               Windows message
00166             WPARAM wParam,
00167               First message parameter (word sized)
00168             LPARAM lParam);
00169               Second message parameter (long sized)
00170
00171   Returns:  LRESULT.  Windows window procedure callback return value.
00172 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00173 LRESULT CALLBACK WindowProc(
00174                    HWND hWnd,
00175                    UINT uMsg,
00176                    WPARAM wParam,
00177                    LPARAM lParam);
00178
00179
00180 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00181   Function: DialogProc
00182
00183   Summary:  The general dialog procedure callback function.  Used by all
00184             CVirDialog class objects.  This procedure is the DialogProc
00185             registered for all dialogs created with the CVirDialog class.
00186             It uses the parameter passed with the WM_INITDIALOG message
00187             to identify the dialog classes' "this" pointer which it then
00188             stores in the window structure's GWL_USERDATA field.
00189             All subsequent messages can then be forwarded on to the
00190             correct dialog class's DialogProc method by using the pointer
00191             stored in the GWL_USERDATA field.
00192
00193   Args:     HWND hWndDlg,
00194               Handle of dialog box.
00195             UINT uMsg,
00196               Message
00197             WPARAM wParam,
00198               First message parameter (word sized).
00199             LPARAM lParam);
00200               Second message parameter (long sized).
00201
00202   Returns:  BOOL.  Return of the CVirDialog::DialogProc method.
00203 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00204 BOOL CALLBACK DialogProc(
00205                 HWND hWndDlg,
00206                 UINT uMsg,
00207                 WPARAM wParam,
00208                 LPARAM lParam);
00209
00210
00211 #ifdef __cplusplus
00212 }
00213
00214
00215 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00216   Class:    CVirWindow
00217
00218   Summary:  Abstract base class for wrapping a window.
00219
00220             This class allows a window to be cleanly wrapped in a
00221             c++ class.  Specifically, it provides a way for a c++ class
00222             to use one of its methods as a WindowProc, giving it a "this"
00223             pointer and allowing it to have direct access to all of its
00224             private members.
00225
00226   Methods:  Create:
00227               Maps to Windows' CreateWindow function.
00228             WindowProc:
00229               Pure virtual WindowProc for the window.
00230             Gethwnd:
00231               Get the handle to the window.
00232             CVirWindow:
00233               Constructor.
00234             ~CVirWindow:
00235               Destructor.
00236 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00237 class CVirWindow
00238 {
00239 public:
00240   // Constructor
00241   CVirWindow()
00242   {
00243     m_hInst = NULL;
00244     m_hWnd = NULL;
00245   };
00246
00247   // Destructor
00248   virtual ~CVirWindow(){};
00249
00250   // Envelopes the Windows' CreateWindow function call.
00251   HWND Create(
00252          LPTSTR lpszClassName,   // Address of registered class name
00253          LPTSTR lpszWindowName,  // Address of window name
00254          DWORD dwStyle,          // Window style
00255          int x,                  // Horizontal position of window
00256          int y,                  // Vertical position of window
00257          int nWidth,             // Window width
00258          int nHeight,            // Window height
00259          HWND hWndParent,        // Handle of parent or owner window
00260          HMENU hMenu,            // Handle of menu, or child window identifier
00261          HINSTANCE hInst);       // Handle of application instance
00262
00263   // Get the protected handle of this window.
00264   HWND GetHwnd(void)
00265   {
00266     return(m_hWnd);
00267   }
00268
00269   // WindowProc is a pure virtual member function and MUST be over-ridden
00270   // in any derived classes.
00271   virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
00272
00273 protected:
00274   // Application instance handle.
00275   HINSTANCE m_hInst;
00276   // Handle of this window.
00277   HWND m_hWnd;
00278
00279   // Tell the compiler that the outside WindowProc callback is a friend
00280   // of this class and can get at its protected data members.
00281   friend LRESULT CALLBACK ::WindowProc(
00282                               HWND hWnd,
00283                               UINT uMsg,
00284                               WPARAM wParam,
00285                               LPARAM lParam);
00286 };
00287
00288
00289 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00290   Class:    CVirDialog
00291
00292   Summary:  Abstract base class for wrapping a Windows dialog box window.
00293
00294             This class allows a dialog box to be cleanly wrapped in
00295             a c++ class.  Specifically, it provides a way for a c++ class
00296             to use one of its methods as a DialogProc, giving it a "this"
00297             pointer and allowing it to have direct access to all of its
00298             private members.
00299
00300   Methods:  ShowDialog:
00301               Maps to Windows' DialogBox function.
00302             GetHwnd:
00303               Get the handle to the dialog window.
00304             DialogProc:
00305               Pure virtual DialogProc for the dialog box
00306             ~CVirDialog:
00307               Destructor
00308 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00309 class CVirDialog
00310 {
00311 public:
00312   // Constructor
00313   CVirDialog()
00314   {
00315     m_hInst = NULL;
00316     m_hWnd = NULL;
00317   };
00318
00319   // Destructor
00320   virtual ~CVirDialog(){};
00321
00322   // ShowDialog creates the Dialog (using the DialogBoxParam API).
00323   virtual int ShowDialog(
00324                 HINSTANCE hInst,
00325                 LPTSTR lpszTemplate,
00326                 HWND hWndOwner);
00327
00328   // DialogProc is a pure virtual member function and MUST be over-ridden
00329   // in any derived classes.
00330   virtual BOOL DialogProc(
00331                  HWND hWndDlg,
00332                  UINT uMsg,
00333                  WPARAM wParam,
00334                  LPARAM lParam) = 0;
00335
00336 protected:
00337   HINSTANCE m_hInst;
00338   HWND m_hWnd;
00339
00340   // Tell the compiler that the outside DialogProc callback is a friend
00341   // of this class and can get at its protected data members.
00342   friend BOOL CALLBACK ::DialogProc(
00343                            HWND hWndDlg,
00344                            UINT uMsg,
00345                            WPARAM wParam,
00346                            LPARAM lParam);
00347 };
00348
00349
00350 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00351   Class:    CAboutBox
00352
00353   Summary:  A class that implements a common About Dialog Box
00354             functionality for the APPUTIL library.
00355
00356   Methods:  DialogProc
00357               Dialog procedure
00358 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00359 class CAboutBox: public CVirDialog
00360 {
00361 public:
00362   // This DialogProc method definition overrides the same-named pure
00363   // virtual function in abstract base class CVirDialog thus giving
00364   // AboutBox-unique message dispatching behavior to this derivation
00365   // of CVirDialog.  The remaining behavior of CAboutBox is inherited
00366   // from CVirDialog and is common to all CVirDialogs.
00367   BOOL DialogProc(
00368          HWND hWndDlg,
00369          UINT uMsg,
00370          WPARAM wParam,
00371          LPARAM lParam);
00372 };
00373
00374
00375 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00376   Class:    CDelayBox
00377
00378   Summary:  A class that implements a common Dialog Box functionality for
00379             the APPUTIL library. This dialog box has no buttons and and
00380             appears on screen for 8 seconds.
00381
00382   Methods:  DialogProc
00383               Dialog procedure
00384 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00385 class CDelayBox: public CVirDialog
00386 {
00387 public:
00388   // This DialogProc method definition overrides the same-named pure
00389   // virtual function in abstract base class CVirDialog thus giving
00390   // AboutBox-unique message dispatching behavior to this derivation
00391   // of CVirDialog.  The remaining behavior of CAboutBox is inherited
00392   // from CVirDialog and is common to all CVirDialogs.
00393   BOOL DialogProc(
00394          HWND hWndDlg,
00395          UINT uMsg,
00396          WPARAM wParam,
00397          LPARAM lParam);
00398 };
00399
00400
00401 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00402   Function: DelayBox
00403
00404   Summary:  Uses the specified dialog template from the caller's resources
00405             and shows a buttonless dialog message box that remains on
00406             screen for about 3 seconds.
00407
00408   Args:     HINSTANCE hInst,
00409               Handle of the module instance.  Needed to specify the
00410               module instance for fetching the dialog template resource
00411               (ie, from either a host EXE or DLL).
00412             LPTSTR pszTemplate,
00413               Identifies the dialog box template.
00414             HWND hwndOwner)
00415               Handle of the owner window. NULL for desktop.
00416
00417   Returns:  void
00418 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00419 void DelayBox(
00420       HINSTANCE hInst,
00421       LPTSTR pszTemplate,
00422       HWND hWndOwner);
00423
00424
00425 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00426   Function: ErrorBox
00427
00428   Summary:  The ErrorBox function displays an error message dialog box. It
00429             displays an error message string in the dialog that is
00430             specified in the call by a resource ID.
00431
00432   Args:     HINSTANCE hInst,
00433               Handle of the module instance.  Needed to specify the
00434               module instance for fetching the specified string resource.
00435             HWND hwndOwner,
00436               Handle of the owner window. NULL for desktop.
00437             INT iStringID
00438               Resource ID of the error message sting.
00439
00440   Returns:  void
00441 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00442 void ErrorBox(
00443       HINSTANCE hInst,
00444       HWND hWndOwner,
00445       INT iStringID);
00446
00447
00448 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00449   Class:    CMsgBox
00450
00451   Summary:  Class for showing messages in a Message Box dialog.  Uses the
00452             standard Windows MessageBox function but retrieves the box
00453             title and message strings from the application's resources
00454             using specified resource IDs.  These message boxes have only
00455             an OK button.
00456
00457   Methods:  Init
00458               Initializes the owner window and the module instance.
00459             Error
00460               Shows a message string in an Error MessageBox Dialog.
00461             ErrorID
00462               Shows a resource message string in an Error MessageBox Dialog.
00463             Note
00464               Shows a message string in a Notice MessageBox Dialog.
00465             NoteID
00466               Shows a resource message string in a Notice MessageBox Dialog.
00467             NoteFmt
00468               Shows a printf-style formatted message string in a Notice
00469               MessageBox Dialog.
00470             NoteFmtID
00471               Shows a printf-style formatted resource message string in a
00472               Notice MessageBox Dialog.
00473 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00474 class CMsgBox
00475 {
00476 public:
00477   // Constructor.
00478   CMsgBox()
00479   {
00480     m_hInst = 0;
00481     m_hWndOwner = 0;
00482   };
00483
00484   BOOL Init(HINSTANCE hInst, HWND hWndOwner);
00485   int  Error(LPTSTR szMsg);
00486   int  ErrorID(UINT uMsgID);
00487   int  Note(LPTSTR szMsg);
00488   int  NoteID(UINT uMsgID);
00489   int  NoteFmt(LPTSTR szFmtMsg, ...);
00490   int  NoteFmtID(UINT uMsgID, ...);
00491
00492 private:
00493   // Remember the App Instance Handle.
00494   HINSTANCE m_hInst;
00495   // Remember the Owner Window Handle.
00496   HWND m_hWndOwner;
00497 };
00498
00499
00500 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00501   Class:    CMsgLog
00502
00503   Summary:  Class for logging messages to a Listbox.  This is for tutorial
00504             code samples that employ debug messages to announce internal
00505             activity in the code being studied.  When used, this Message
00506             Log listbox occupies the entire client area of the parent
00507             window.  The various message output functions use string
00508             resource IDs to retrieve the message strings from the app's
00509             resources.
00510
00511   Methods:  Create
00512               Creates the Trace Message Log ListBox window.
00513             Logging
00514               Toggles logging on or off.
00515             Msg
00516               Logs a message as a separate line.
00517             MsgFmt
00518               Logs a printf-style formated message as a separate line.
00519             Resize
00520               Resizes the listbox to a new width and height.
00521             Clear
00522               Clears all logged messages from the message log.
00523             CMsgLog
00524               Constructor.
00525             ~CMsgLog
00526               Destructor.
00527 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00528 class CMsgLog
00529 {
00530 public:
00531   // Constructor.
00532   CMsgLog()
00533   {
00534     m_hInstLog = 0;
00535     m_hWndLog = 0;
00536     m_bChild = FALSE;
00537     m_bLogging = FALSE;
00538     m_hLogData = 0;
00539   };
00540
00541   BOOL Create(HINSTANCE hInst, HWND hWndParent, BOOL bChild);
00542   BOOL Logging(BOOL bLogging);
00543   BOOL Msg(LPTSTR szMsg);
00544   BOOL MsgFmt(LPTSTR szFmtMsg, ...);
00545   BOOL MsgID(int iMsgID);
00546   BOOL MsgFmtID(int iFmtID, ...);
00547   BOOL Resize(int nWidth, int nHeight);
00548   BOOL Clear(void);
00549   BOOL Copy(void);
00550
00551 private:
00552   // Remember the App Instance Handle.
00553   HINSTANCE m_hInstLog;
00554   // Remember the handle of the listbox window.
00555   HWND m_hWndLog;
00556   // Remember if CMsgLog was created as child window.
00557   BOOL m_bChild;
00558   // Remember whether logging or not.
00559   BOOL m_bLogging;
00560   // Remember the global handle to clipboard data.
00561   HGLOBAL m_hLogData;
00562 };
00563
00564
00565 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00566   Class:    CSendLog
00567
00568   Summary:  Class for logging messages to a CMsgLog facility in another
00569             application process. This is for tutorial code samples that
00570             employ debug messages to announce internal activity in the
00571             code being studied.  Uses the WM_COPYDATA message of the
00572             Win32 SendMessage API.
00573
00574   Methods:  CreateServerLog
00575               Initializes the SendLog facility and creates the Trace
00576               Message Log ListBox window shown in the local server app.
00577             SetClient
00578               Sets destination client window handle.
00579             LogToServer
00580               Set whether logging is to local server or to client.
00581             Msg
00582               Logs a message as a separate line.
00583             MsgFmt
00584               Logs a printf-style formated message as a separate line.
00585             Resize
00586               Resizes the listbox to a new width and height.
00587             Clear
00588               Clears all logged messages from the message log.
00589             CSendLog
00590               Constructor.
00591             ~CSendLog
00592               Destructor.
00593 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00594 class CSendLog
00595 {
00596 public:
00597   // Constructor.
00598   CSendLog()
00599   {
00600     m_hInstSender = 0;
00601     m_hWndSender = 0;
00602     m_hWndReceiver = 0;
00603     m_hWndListBox = 0;
00604     m_bLogToServer = FALSE;
00605     m_bChild = FALSE;
00606     m_hLogData = 0;
00607   };
00608
00609   BOOL CreateServerLog(HINSTANCE hInst, HWND hWndParent, BOOL bChild);
00610   BOOL SetClient(HINSTANCE hInstSender, HWND hWndSender, HWND hWndReceiver);
00611   BOOL LogToServer(BOOL bLogToServer);
00612   BOOL Msg(LPTSTR szMsg);
00613   BOOL MsgFmt(LPTSTR szFmtMsg, ...);
00614   BOOL MsgID(int iMsgID);
00615   BOOL MsgFmtID(int iFmtID, ...);
00616   BOOL Resize(int nWidth, int nHeight);
00617   BOOL Clear(void);
00618   BOOL Copy(void);
00619
00620 private:
00621   // Remember the Sender App Instance Handle.
00622   HINSTANCE m_hInstSender;
00623   // Remember the handle of the sending application main window.
00624   HWND m_hWndSender;
00625   // Remember the handle of the destination receiving window.
00626   HWND m_hWndReceiver;
00627   // Remember the handle of the server's listbox window.
00628   HWND m_hWndListBox;
00629   // Boolean for logging to client or logging to server.
00630   BOOL m_bLogToServer;
00631   // Remember if CMsgLog was created as child window.
00632   BOOL m_bChild;
00633   // Remember the global handle to clipboard data.
00634   HGLOBAL m_hLogData;
00635 };
00636
00637
00638 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00639   Class:    CThreaded
00640
00641   Summary:  Derive a class from this class to provide multi-threaded
00642             access to objects of the derived class. This is a utility
00643             base class providing useful methods for achieving mutually
00644             exclusive access to data in objects of the derived class.
00645
00646   Methods:  OwnThis
00647               Blocks executing thread until access to this object is
00648               permitted at which point the thread "owns" this object.
00649             UnOwnThis
00650               Executed by owning thread to relinquish ownership of
00651               this object.
00652             CThreaded
00653               Constructor. Creates mutex to govern mutually exclusive
00654               access to data in this object by multiple threads.
00655             ~CThreaded
00656               Destructor. Destroys mutex.
00657 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00658 class CThreaded
00659 {
00660   protected:
00661     // Variables for providing mutually exclusive access by multiple
00662     // threads to objects of classes derived from this class.
00663     HANDLE m_hOwnerMutex;
00664     BOOL   m_bOwned;
00665
00666   public:
00667     // Methods.
00668     CThreaded(void) :
00669       m_hOwnerMutex(CreateMutex(0,FALSE,0)),
00670       m_bOwned(FALSE)
00671     {
00672     };
00673
00674     ~CThreaded(void)
00675     {
00676       // Close down the mutex.
00677       CloseHandle(m_hOwnerMutex);
00678     };
00679
00680     // The following virtual functions have overriding definitions in
00681     // the derived class to provide convenient trace logging. Rely on
00682     // the below default definitions for non-tutorial applications.
00683
00684     virtual BOOL OwnThis(void)
00685     {
00686       BOOL bOwned = FALSE;
00687
00688       if (WAIT_OBJECT_0 == WaitForSingleObject(m_hOwnerMutex, INFINITE))
00689         m_bOwned = bOwned = TRUE;
00690
00691       return bOwned;
00692     };
00693
00694     virtual void UnOwnThis(void)
00695     {
00696       if (m_bOwned)
00697       {
00698         m_bOwned = FALSE;
00699         ReleaseMutex(m_hOwnerMutex);
00700       }
00701
00702       return;
00703     };
00704 };
00705
00706
00707 #endif //__cplusplus
00708
00709
00710
00711 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00712   Function: AnsiToUc
00713
00714   Summary:  Convert an ANSI 'multibyte' string into a UNICODE 'wide
00715             character' string.
00716
00717   Args:     LPSTR pszAnsi
00718               Pointer to a caller's null terminated input ANSI string.
00719             LPWSTR pwszUc
00720               Pointer to a caller's output UNICODE wide string buffer.
00721             int cch
00722               Size of pwszUc in number of wide characters.  Must be greater
00723               than 0.
00724
00725   Returns:  HRESULT
00726               Standard result code. NOERROR for success.
00727 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00728 HRESULT AnsiToUc(
00729           LPSTR pszAnsi,
00730           LPWSTR pszUc,
00731           int cch);
00732
00733
00734 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00735   Function: UcToAnsi
00736
00737   Summary:  Convert a UNICODE 'wide character' input string to an output
00738             ANSI 'multi-byte' string.
00739
00740   Args:     LPWSTR pwszUc
00741               Pointer to a caller's input UNICODE wide string.
00742             LPSTR pszAnsi
00743               Pointer to a caller's output ANSI string.
00744             int cch
00745               Size of pszAnsi in number of characters.  Must be greater than
00746               0.
00747
00748   Returns:  HRESULT
00749               Standard result code. NOERROR for success.
00750 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00751 HRESULT UcToAnsi(
00752           LPWSTR pwszUc,
00753           LPSTR pszAnsi,
00754           int cch);
00755
00756
00757 /*---------------------------------------------------------------------------
00758   Here are some surrogate API macro prototypes--all names begin with A_.
00759   These are for use when the code sample is being compiled for ANSI
00760   strings (the default) and the calls they stand in place of only support
00761   UNICODE (thus forcing some string conversions from ANSI to UNICODE
00762   before the real call is made inside the surrogate). For example, if
00763   UNICODE is NOT defined during the compile then any calls in the samples
00764   to the StringFromGUID2 function are actually changed (by the below
00765   macros) into calls to an A_StringFromGUID2 function implemented in
00766   APPUTIL. This function accepts the ANSI input string pointer, calls the
00767   actual StringFromGUID2 call, and does the necessary Unicode to ANSI
00768   conversion. Other A_ calls will convert input ANSI strings to Unicode
00769   strings prior to calling the actual COM/OLE function.
00770 ---------------------------------------------------------------------------*/
00771 #if !defined(UNICODE)
00772
00773 STDAPI A_StringFromGUID2(REFGUID, LPSTR, int);
00774
00775 STDAPI A_WriteFmtUserTypeStg(IStorage*, CLIPFORMAT, LPSTR);
00776
00777 STDAPI A_StgIsStorageFile(LPSTR);
00778 STDAPI A_StgCreateDocfile(LPSTR, DWORD, DWORD, IStorage**);
00779 STDAPI A_StgOpenStorage(LPSTR, IStorage*, DWORD, SNB, DWORD, IStorage**);
00780
00781 #if !defined(_NOANSIMACROS_)
00782
00783 #undef StringFromGUID2
00784 #define StringFromGUID2(a, b, c) A_StringFromGUID2(a, b, c)
00785
00786 #undef WriteFmtUserTypeStg
00787 #define WriteFmtUserTypeStg(a, b, c) A_WriteFmtUserTypeStg(a, b, c)
00788
00789 #undef StgIsStorageFile
00790 #define StgIsStorageFile(a) A_StgIsStorageFile(a)
00791
00792 #undef StgCreateDocfile
00793 #define StgCreateDocfile(a, b, c, d) A_StgCreateDocfile(a, b, c, d)
00794
00795 #undef StgOpenStorage
00796 #define StgOpenStorage(a, b, c, d, e, f) A_StgOpenStorage(a, b, c, d, e, f)
00797
00798 #endif
00799
00800 #endif
00801
00802
00803 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00804   Function: DComOk
00805
00806   Summary:  Determine if DCOM (Distributed COM) can be used. It can if it
00807             is installed and is enabled on the current machine.
00808
00809   Args:     void
00810
00811   Returns:  BOOL
00812               TRUE - DCOM installed and enabled; FALSE - NOT.
00813 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00814 BOOL DComOk(void);
00815
00816
00817 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00818   Function: lRandom
00819
00820   Summary:  Simple random number generator. Returns a random DWORD.
00821
00822   Args:     void
00823
00824   Returns:  DWORD
00825               Random number.
00826 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00827 DWORD lRandom(void);
00828
00829
00830 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00831   Function: CreateColorScalePalette
00832
00833   Summary:  This function creates a palette representing the scale values
00834             of a particular RGB color.  A gray-scale palette can also be
00835             created.
00836
00837   Args:     HDC hDC,
00838               Handle to device context.
00839             int nColor
00840               New color.
00841
00842   Returns:  HPALETTE
00843               Handle to new pallete.
00844 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00845 HPALETTE CreateColorScalePalette(HWND hDC, int nColor);
00846
00847
00848 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00849   Function: PaintWindow
00850
00851   Summary:  This function is used to wash the background of a window.
00852
00853   Args:     HWND hWnd,
00854               Window handle.
00855             int nColor
00856               New window color.
00857
00858   Returns:  void.
00859 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00860 VOID PaintWindow(HWND hWnd, int nColor);
00861
00862
00863 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00864   Function: SkipAnsi
00865
00866   Summary:  Utility function to scan an input ANSI string and either skips
00867             white characters or skips non-white characters.
00868
00869   Args;     LPSTR psz,
00870               Input ANSI string to be scanned.
00871             BOOL bSkipWhite
00872               Input boolean determining whether to skip white space
00873               or not.  TRUE means skip white space; FALSE means skip
00874               non-white chars.
00875
00876   Returns:  LPSTR
00877               String pointer after the skip (ANSI)
00878 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00879 LPSTR SkipAnsi(
00880          LPSTR psz,
00881          BOOL bSkipWhite);
00882
00883
00884 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00885   Function: FileExist
00886
00887   Summary:  Function to test for the existance of a file.
00888
00889   Args:     TCHAR* szFileName
00890               String pointer to file's path/name.
00891
00892   Returns:  BOOL.  TRUE if file exists; FALSE if not.
00893 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00894 BOOL FileExist(TCHAR *szFileName);
00895
00896
00897 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00898   Function: MakeFamilyPath
00899
00900   Summary:  Function to make a family file/path/name string using the
00901             detetected pathname of the current executable module.
00902
00903   Args:     HINSTANCE hInst
00904               Handle to the module intstance.
00905             TCHAR* pszNewPath
00906               String pointer to the new path/name.
00907             TCHAR* pszFileExt
00908               String pointer to the filename extension for the new path.
00909
00910   Returns:  BOOL.  TRUE if success; FALSE if not.
00911 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00912 BOOL MakeFamilyPath(
00913        HINSTANCE hInst,
00914        TCHAR* pszNewPath,
00915        TCHAR* pszFileExt);
00916
00917
00918 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00919   Function: GetExeName
00920
00921   Summary:  Function to get the executable file name of the current
00922             module. Makes names like: MyApp.EXE or MyDll.DLL.
00923
00924   Args:     HINSTANCE hInst
00925               Handle to the module intstance.
00926             TCHAR* pszExeName
00927               String pointer to the new executable file name.
00928               A char string allocated by user.
00929
00930   Returns:  BOOL.  TRUE if success; FALSE if not.
00931 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00932 BOOL GetExeName(
00933        HINSTANCE hInst,
00934        TCHAR* pszExeName);
00935
00936
00937 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00938   Function: CmdExec
00939
00940   Summary:  Execute an EXE Win32 program by creating a process and
00941             running the specified EXE in it.  A Unicode version of
00942             WinExec that always has SW_SHOW.
00943
00944   Args:     LPTSTR szCmd,
00945               Entire command line (eg, "notepad.exe mytext.txt")
00946
00947   Returns:  BOOL
00948               TRUE if succeed; FALSE if fail.
00949 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00950 BOOL CmdExec(
00951        LPTSTR szCmd);
00952
00953
00954 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00955   Function: HrMsg
00956
00957   Summary:  HRESULT Error Message box. Takes standard result code,
00958             looks it up in the system tables, and shows a message
00959             box with the error code (in hex) and the associated
00960             system message.
00961
00962   Args:     HWND hWndOwner,
00963               Handle to owner parent window.
00964             LPTSTR pszTitle
00965               User message string (eg, designating the attempted function).
00966               Appears in the dialog title bar.
00967             HRESULT hr
00968               Standard return code.
00969
00970   Returns:  void
00971 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00972 void HrMsg(
00973        HWND hWndOwner,
00974        LPTSTR pszTitle,
00975        HRESULT hr);
00976
00977
00978 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00979   Function: HrMsgId
00980
00981   Summary:  HRESULT Error Message box using string resource ID. Takes
00982             standard result code, looks it up in the system tables, and
00983             shows a message box with the error code (in hex) and the
00984             associated system message. An additional user message string
00985             (specified as a resource ID) is also shown.
00986
00987   Args:     HINSTANCE hInst,
00988               Handle of the module instance.  Needed to specify the
00989               module instance for fetching the specified string resource.
00990             HWND hwndOwner,
00991               Handle of the owner window. NULL for desktop.
00992             INT iStringID
00993               Resource ID of error message string. Appears in the
00994               dialog title bar.
00995             HRESULT hr,
00996               Standard result code.
00997
00998   Returns:  void
00999 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01000 void HrMsgId(
01001       HINSTANCE hInst,
01002       HWND hWndOwner,
01003       INT iStringID,
01004       HRESULT hr);
01005
01006
01007 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01008   Function: ReadHelp
01009
01010   Summary:  The ReadHelp function is a general help reader for
01011             applications. It uses the shell to run the reader application
01012             associated with the extension of the specified file/path name.
01013             For example, if the family-named file name is MYAPP.HTM, then
01014             the web browser will be used to read the HTML help file.
01015
01016   Args:     HWND hWndOwner,
01017               Handle to owner parent window.
01018             LPTSTR pszHelpFile,
01019               Pointer to the help file/path name string.
01020
01021   Returns:  void
01022 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01023 void ReadHelp(
01024        HWND hWndOwner,
01025        LPTSTR pszHelpFile);
01026
01027
01028 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01029   Function: ReadTutorial
01030
01031   Summary:  The ReadTutorial function is for use by tutorial code sample
01032             applications that study themselves. This function uses simple
01033             Hyperlinking to launch the web browser to read an HTML web
01034             page that contains a tutorial covering the sample. If no HTM
01035             file (in a sibling or parent directory) is specified, this
01036             function assumes a family-named <sample>.HTM tutorial HTML
01037             file that is located next to the main .EXE file of the
01038             application calling ReadTutorial. "Family-named" means that if
01039             the EXE program calling this function is MYAPP.EXE then the
01040             associated family-named HTML file is constructed as MYAPP.HTM.
01041
01042   Args:     HINSTANCE hInst,
01043               Handle of the executable module instance.
01044             HWND hWndOwner,
01045               Handle to owner parent window.
01046             LPTSTR pszHTMLFile,
01047               Pointer to an optional HTML FileName string. If this pointer
01048               is NULL, then the family-named file is assumed for the HTML
01049               file and is assumed to be located next to the main .EXE file
01050               of the program executing this function. Non-NULL values are
01051               of the form "MySiblingDirectory\MyHTMLFile.HTM" or of the
01052               form "MyHTMLFileInTheParentDirectory.HTM". Special non-NULL
01053               values beginning with '.' (eg. ".HTM" or ".ASP") specify
01054               that the family-named file is assumed to be located in the
01055               parent directory. In this case, the specified file extension
01056               is used.
01057
01058   Returns:  void
01059 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01060 void ReadTutorial(
01061        HINSTANCE hInst,
01062        HWND hWndOwner,
01063        LPTSTR pszHTMLFile);
01064
01065
01066 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01067   Function: GoWeb
01068
01069   Summary:  General utility function to launch a web browser on a
01070             specified HTML file via either a URL or a full file path/name.
01071
01072   Args:     HINSTANCE hInst,
01073               Handle of the executable module instance.
01074             LPSTR pszTarget
01075               Pointer to the Target specification string (must be ANSI).
01076               If null then call the ReadTutorial function. If pszTarget
01077               starts with '//' then the target is assumed to be a www URL
01078               trailer of the form: //www.microsoft.com. If any other
01079               string, then it is assumed to be a full path/file name.
01080
01081   Returns:  void
01082 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01083 void GoWeb(
01084        HINSTANCE hInst,
01085        LPSTR pszTarget);
01086
01087
01088 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01089   Function: ReadSource
01090
01091   Summary:  For use by code sample applications that study themselves
01092             as it were.  This function allows you to select one of the
01093             source files of this code sample and launch a reader to
01094             edit/read it.  NOTEPAD.EXE is the default editor/reader.
01095             You can change this by changing EDITOR_FILE_STR in
01096             APPUTIL.H above.
01097
01098   Args:     HWND hWndOwner
01099               Handle of parent window.
01100             OPENFILENAME* pofn,
01101               Pointer to the Open File Name Common Dialog structure.
01102
01103   Returns:  void
01104 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01105 void ReadSource(
01106        HWND hWndOwner,
01107        OPENFILENAME* pOfn);
01108
01109
01110 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01111   Function: OutputDebugFmt
01112
01113   Summary:  Wraps the Win32 OutputDebugString API call to provide
01114             printf-style formatted (and variable argument) output.
01115
01116   Args:     LPTSTR szFmt,
01117               Format string.
01118             [...]
01119               Arguments to match those specified in the format string.
01120
01121   Returns:  void
01122 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01123 void OutputDebugFmt(
01124        LPTSTR szFmt,
01125        ...);
01126
01127
01128 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01129   Function: GetErrorMsg
01130
01131   Summary:  Accepts a Win32 error code and retrieves a human readable
01132             system message for it.
01133
01134   Args:     HRESULT hr
01135               SCODE error code.
01136             LPTSTR pszMsg
01137               Pointer string where message will be placed.
01138             UINT uiSize
01139               Max size of the msg string.
01140
01141   Returns:  BOOL
01142               TRUE if hr was error; FALSE if not.
01143 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01144 BOOL GetErrorMsg(
01145        HRESULT hr,
01146        LPTSTR pszMsg,
01147        UINT uiSize);
01148
01149
01150 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01151   Function: SetRegKeyValue
01152
01153   Summary:  Internal utility function to set a Key, Subkey, and value
01154             in the system Registry.
01155
01156   Args:     LPTSTR pszKey,
01157             LPTSTR pszSubkey,
01158             LPTSTR pszValue)
01159
01160   Returns:  BOOL
01161               TRUE if success; FALSE if not.
01162 ------------------------------------------------------------------------F-F*/
01163 BOOL SetRegKeyValue(
01164        LPTSTR pszKey,
01165        LPTSTR pszSubkey,
01166        LPTSTR pszValue);
01167
01168
01169 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01170   Function: AddRegNamedValue
01171
01172   Summary:  Internal utility function to add a named data value to an
01173             existing Key (with optional Subkey) in the system Registry
01174             under HKEY_CLASSES_ROOT.
01175
01176   Args:     LPTSTR pszKey,
01177             LPTSTR pszSubkey,
01178             LPTSTR pszValueName,
01179             LPTSTR pszValue)
01180
01181   Returns:  BOOL
01182               TRUE if success; FALSE if not.
01183 ------------------------------------------------------------------------F-F*/
01184 BOOL AddRegNamedValue(
01185        LPTSTR pszKey,
01186        LPTSTR pszSubkey,
01187        LPTSTR pszValueName,
01188        LPTSTR pszValue);
01189
01190 #if defined(_UNICODE)
01191 #define lstrncat(strDest,strSource,count) wcsncat(strDest,strSource,count)
01192 #else
01193 #define lstrncat(strDest,strSource,count) strncat(strDest,strSource,count)
01194 #endif // _UNICODE
01195
01196 #define TID GetCurrentThreadId()
01197
01198 #if defined(DEBUG)
01199
01200 //Basic debug and logging macros
01201
01202 // Output debug string; literal or variable.
01203 // Note the assertion checking to make sure that we don't exceed the size
01204 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01205 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01206 #define ODS(sMsg) \
01207 {\
01208   TCHAR szDebug[MAXLOGST];\
01209   OutputDebugFmt(TEXT("%s"),TEXT(sMsg));\
01210   assert(__LINE__ <= MAX_LINE_NUM);\
01211   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01212    < MAXLOGST);\
01213   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01214   OutputDebugString(szDebug);\
01215 }
01216
01217 // Output debug string formatted; one argument.
01218 // Note the assertion checking to make sure that we don't exceed the size
01219 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01220 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01221 #define ODF1(sFmt,x) \
01222 {\
01223   TCHAR szDebug[MAXLOGST];\
01224   OutputDebugFmt(TEXT(sFmt),x);\
01225   assert(__LINE__ <= MAX_LINE_NUM);\
01226   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01227    < MAXLOGST);\
01228   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01229   OutputDebugString(szDebug);\
01230 }
01231
01232 // Output debug string formatted; two argument.
01233 // Note the assertion checking to make sure that we don't exceed the size
01234 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01235 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01236 #define ODF2(sFmt,x,y) \
01237 {\
01238   TCHAR szDebug[MAXLOGST];\
01239   OutputDebugFmt(TEXT(sFmt),x,y);\
01240   assert(__LINE__ <= MAX_LINE_NUM);\
01241   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01242    < MAXLOGST);\
01243   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01244   OutputDebugString(szDebug);\
01245 }
01246
01247 // Output debug string formatted; three argument.
01248 // Note the assertion checking to make sure that we don't exceed the size
01249 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01250 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01251 #define ODF3(sFmt,x,y,z) \
01252 {\
01253   TCHAR szDebug[MAXLOGST];\
01254   OutputDebugFmt(TEXT(sFmt),x,y,z);\
01255   assert(__LINE__ <= MAX_LINE_NUM);\
01256   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01257    < MAXLOGST);\
01258   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01259   OutputDebugString(szDebug);\
01260 }
01261
01262 // Check condition and Output assertion failed message to debugger.
01263 #define ASSERT(condition) \
01264 {\
01265   if (!(condition))\
01266     ODS(TEXT("Assertion Failed"));\
01267 }
01268
01269 // Check standard HRESULT for error and put up message box if error.
01270 // Two arguments. Pfx = Prefix msg string; Ec = error code.
01271 // Eg: CKHR("MyFunction:",hr);
01272 // Note the assertion checking to make sure that we don't exceed the size
01273 // of szMsg.  This is a valid assertion to make since MAXLOGST is defined
01274 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01275 #define CKHR(Pfx,Ec) \
01276 {\
01277   TCHAR szMsg[MAXLOGST];\
01278   if (GetErrorMsg(Ec,szMsg,MAX_PATH))\
01279   {\
01280     HrMsg(NULL,TEXT(Pfx),Ec);\
01281     assert(__LINE__ <= MAX_LINE_NUM);\
01282     assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01283      < MAXLOGST);\
01284     wsprintf(szMsg, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01285     OutputDebugString(szMsg);\
01286   }\
01287 }
01288
01289 // Log debug string (output both to Message Log and to Debugger)
01290 // Note the assertion checking to make sure that we don't exceed the size
01291 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01292 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01293 #define LOG(sMsg) \
01294 {\
01295   TCHAR szDebug[MAXLOGST];\
01296   if (NULL!=g_pMsgLog)\
01297     g_pMsgLog->Msg(TEXT(sMsg));\
01298   assert(__LINE__ <= MAX_LINE_NUM);\
01299   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01300    < MAXLOGST);\
01301   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01302   OutputDebugString(szDebug);\
01303 }
01304
01305 // Log debug string (output both to Message Log and to Debugger).
01306 // One argument.
01307 // Note the assertion checking to make sure that we don't exceed the size
01308 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01309 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01310 #define LOGF1(sFmt,x) \
01311 {\
01312   TCHAR szDebug[MAXLOGST];\
01313   if (NULL!=g_pMsgLog)\
01314     g_pMsgLog->MsgFmt(TEXT(sFmt),x);\
01315   assert(__LINE__ <= MAX_LINE_NUM);\
01316   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01317    < MAXLOGST);\
01318   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01319   OutputDebugString(szDebug);\
01320 }
01321
01322 // Log debug string (output both to Message Log and to Debugger).
01323 // Two argument.
01324 // Note the assertion checking to make sure that we don't exceed the size
01325 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01326 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01327 #define LOGF2(sFmt,x,y) \
01328 {\
01329   TCHAR szDebug[MAXLOGST];\
01330   if (NULL!=g_pMsgLog)\
01331     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y);\
01332   assert(__LINE__ <= MAX_LINE_NUM);\
01333   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01334    < MAXLOGST);\
01335   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01336   OutputDebugString(szDebug);\
01337 }
01338
01339 // Log debug string (output both to Message Log and to Debugger).
01340 // Three argument.
01341 // Note the assertion checking to make sure that we don't exceed the size
01342 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01343 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01344 #define LOGF3(sFmt,x,y,z) \
01345 {\
01346   TCHAR szDebug[MAXLOGST];\
01347   if (NULL!=g_pMsgLog)\
01348     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y,z);\
01349   assert(__LINE__ <= MAX_LINE_NUM);\
01350   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01351    < MAXLOGST);\
01352   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01353   OutputDebugString(szDebug);\
01354 }
01355
01356 // Log error message string (output both to Message Log and to Debugger).
01357 // Two arguments. Pfx = Prefix msg string; Ec = error code.
01358 // Eg: LOGERROR("MyFunction:",hr);
01359 // Note the assertion checking to make sure that we don't exceed the size
01360 // of szMsg.  This is a valid assertion to make since MAXLOGST is defined
01361 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01362 #define LOGERROR(Pfx,Ec) \
01363 {\
01364   TCHAR szMsg[MAXLOGST];\
01365   if (NULL!=g_pMsgLog && GetErrorMsg(Ec,szMsg,MAX_PATH))\
01366   {\
01367     g_pMsgLog->MsgFmt(TEXT("%s Error=0x%X: %s"),TEXT(Pfx),Ec,szMsg);\
01368     assert(__LINE__ <= MAX_LINE_NUM);\
01369     assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01370      < MAXLOGST);\
01371     wsprintf(szMsg, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01372     OutputDebugString(szMsg);\
01373   }\
01374 }
01375
01376 // Log debug string (output both to Message Log and to Debugger).
01377 // Use a string resource ID to retrieve the display string.
01378 // Note the assertion checking to make sure that we don't exceed the size
01379 // of szDebug.  This is a valid assertion to make since MAXLOGST is defined
01380 // as MAX_PATH + MAX_LINE_CHARS + DEBUG_FMT_CHARS.
01381 #define LOGID(id) \
01382 {\
01383   TCHAR szDebug[MAXLOGST];\
01384   if (NULL!=g_pMsgLog)\
01385     g_pMsgLog->MsgID(id);\
01386   assert(__LINE__ <= MAX_LINE_NUM);\
01387   assert(strlen((LPTSTR)__FILE__) + DEBUG_FMT_CHARS + MAX_LINE_CHARS\
01388    < MAXLOGST);\
01389   wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
01390   OutputDebugString(szDebug);\
01391 }
01392
01393 // Log assertion failure.
01394 #define LOGASSERT(condition) \
01395 {\
01396   if (!(condition))\
01397     LOGID(IDS_ASSERT_FAIL);\
01398 }
01399
01400 #else  // !defined(DEBUG)
01401
01402 #define ODS(x)
01403
01404 #define ODF1(sFmt,x)
01405
01406 #define ODF2(sFmt,x,y)
01407
01408 #define ODF3(sFmt,x,y,z)
01409
01410 #define ASSERT(condition)
01411
01412 #define CKHR(Pfx,Ec)
01413
01414 #define LOG(sMsg) \
01415 {\
01416   if (NULL!=g_pMsgLog)\
01417     g_pMsgLog->Msg(TEXT(sMsg));\
01418 }
01419
01420 // Log debug string (output both to Message Log and not to Debugger).
01421 // One argument.
01422 #define LOGF1(sFmt,x) \
01423 {\
01424   if (NULL!=g_pMsgLog)\
01425     g_pMsgLog->MsgFmt(TEXT(sFmt),x);\
01426 }
01427
01428 // Log debug string (output both to Message Log and not to Debugger).
01429 // Two argument.
01430 #define LOGF2(sFmt,x,y) \
01431 {\
01432   if (NULL!=g_pMsgLog)\
01433     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y);\
01434 }
01435
01436 // Log debug string (output both to Message Log and not to Debugger).
01437 // Three argument.
01438 #define LOGF3(sFmt,x,y,z) \
01439 {\
01440   if (NULL!=g_pMsgLog)\
01441     g_pMsgLog->MsgFmt(TEXT(sFmt),x,y,z);\
01442 }
01443
01444 // Log error message string (output both to Message Log and not to Debugger).
01445 // Two arguments. Pfx = Prefix msg string; Ec = error code.
01446 // Eg: LOGERROR("MyFunction:",hr);
01447 #define LOGERROR(Pfx,Ec) \
01448 {\
01449   TCHAR szMsg[MAX_PATH];\
01450   if (NULL!=g_pMsgLog && GetErrorMsg(Ec,szMsg,MAX_PATH))\
01451     g_pMsgLog->MsgFmt(TEXT("%s Error=0x%X: %s"),TEXT(Pfx),Ec,szMsg);\
01452 }
01453
01454 // Log debug string (output both to Message Log and not to Debugger).
01455 // Use a string resource ID to retrieve the display string.
01456 #define LOGID(id) \
01457 {\
01458   if (NULL!=g_pMsgLog)\
01459     g_pMsgLog->MsgID(id);\
01460 }
01461
01462 // Log assertion failure.
01463 #define LOGASSERT(condition)\
01464 {\
01465   if (!(condition))\
01466     LOGID(IDS_ASSERT_FAIL);\
01467 }
01468
01469 #endif // DEBUG
01470
01471 #endif //APPUTIL_H
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/guids.h Source File

  • SysMgmt
  • MMC
  • CutCopy

guids.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 // {C30C5B42-1913-11d3-9A38-0080C7258072}
00020 DEFINE_GUID(CLSID_CComponentData,
00021       0xc30c5b42, 0x1913, 0x11d3, 0x9a, 0x38, 0x0, 0x80, 0xc7, 0x25, 0x80, 0x72);
00022
00023 // {C99D3D80-1913-11d3-9A38-0080C7258072}
00024 DEFINE_GUID(CLSID_CSnapinAbout,
00025       0xc99d3d80, 0x1913, 0x11d3, 0x9a, 0x38, 0x0, 0x80, 0xc7, 0x25, 0x80, 0x72);
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Encode/CrlDist.Cpp Source File

  • Security
  • CertServices
  • Encode

CrlDist.Cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        crldist.cpp
00007 //
00008 // Contents:    Cert Server Extension Encoding/Decoding implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013
00014 #pragma hdrstop
00015
00016 #include <assert.h>
00017 #include "resource.h"
00018 #include "crldist.h"
00019 #include "celib.h"
00020
00021
00022 //+--------------------------------------------------------------------------
00023 // CCertEncodeCRLDistInfo::~CCertEncodeCRLDistInfo -- destructor
00024 //
00025 // free memory associated with this instance
00026 //+--------------------------------------------------------------------------
00027
00028 CCertEncodeCRLDistInfo::~CCertEncodeCRLDistInfo()
00029 {
00030     _Cleanup();
00031 }
00032
00033
00034 //+--------------------------------------------------------------------------
00035 // CCertEncodeCRLDistInfo::_Cleanup -- release all resources
00036 //
00037 // free memory associated with this instance
00038 //+--------------------------------------------------------------------------
00039
00040 VOID
00041 CCertEncodeCRLDistInfo::_Cleanup()
00042 {
00043     if (NULL != m_aValue)
00044     {
00045   if (!m_fConstructing)
00046   {
00047       if (NULL != m_DecodeInfo)
00048       {
00049     LocalFree(m_DecodeInfo);
00050     m_DecodeInfo = NULL;
00051       }
00052   }
00053   else
00054   {
00055       CRL_DIST_POINT *pDistPoint;
00056       CRL_DIST_POINT *pDistPointEnd;
00057
00058       for (pDistPoint = m_aValue, pDistPointEnd = &m_aValue[m_cValue];
00059      pDistPoint < pDistPointEnd;
00060      pDistPoint++)
00061       {
00062     CERT_ALT_NAME_ENTRY *pName;
00063     CERT_ALT_NAME_ENTRY *pNameEnd;
00064
00065     pName = pDistPoint->DistPointName.FullName.rgAltEntry;
00066     if (NULL != pName)
00067     {
00068         for (pNameEnd = &pName[pDistPoint->DistPointName.FullName.cAltEntry];
00069        pName < pNameEnd;
00070        pName++)
00071         {
00072       if (NULL != pName->pwszURL) // test arbitrary union arm
00073       {
00074           LocalFree(pName->pwszURL);
00075       }
00076         }
00077         LocalFree(pDistPoint->DistPointName.FullName.rgAltEntry);
00078     }
00079       }
00080       LocalFree(m_aValue);
00081   }
00082   m_aValue = NULL;
00083     }
00084     assert(NULL == m_DecodeInfo);
00085     m_fConstructing = FALSE;
00086 }
00087
00088
00089 //+--------------------------------------------------------------------------
00090 // CCertEncodeCRLDistInfo::_MapDistPoint -- map a distribution point
00091 //
00092 //+--------------------------------------------------------------------------
00093
00094 HRESULT
00095 CCertEncodeCRLDistInfo::_MapDistPoint(
00096     IN BOOL fEncode,
00097     IN LONG DistPointIndex,
00098     OUT LONG **ppNameCount,
00099     OUT CERT_ALT_NAME_ENTRY ***ppaName)
00100 {
00101     HRESULT hr = S_OK;
00102     CRL_DIST_POINT *pDistPoint;
00103
00104     if (fEncode)
00105     {
00106   pDistPoint = m_fConstructing? m_aValue : NULL;
00107     }
00108     else
00109     {
00110   pDistPoint = m_aValue;
00111     }
00112
00113     if (NULL == pDistPoint)
00114     {
00115   hr = E_INVALIDARG;
00116   ceERRORPRINTLINE("bad parameter", hr);
00117   goto error;
00118     }
00119
00120     if (m_cValue <= DistPointIndex)
00121     {
00122   ceERRORPRINTLINE("bad DistPointIndex parameter", hr);
00123   hr = E_INVALIDARG;
00124   goto error;
00125     }
00126     *ppNameCount =
00127   (LONG *) &pDistPoint[DistPointIndex].DistPointName.FullName.cAltEntry;
00128     *ppaName = &pDistPoint[DistPointIndex].DistPointName.FullName.rgAltEntry;
00129
00130 error:
00131     return(hr);
00132 }
00133
00134
00135 //+--------------------------------------------------------------------------
00136 // CCertEncodeCRLDistInfo::_MapName -- map a name
00137 //
00138 //+--------------------------------------------------------------------------
00139
00140 HRESULT
00141 CCertEncodeCRLDistInfo::_MapName(
00142     IN BOOL fEncode,
00143     IN LONG DistPointIndex,
00144     IN LONG NameIndex,
00145     OUT CERT_ALT_NAME_ENTRY **ppName)
00146 {
00147     HRESULT hr;
00148     LONG *pNameCount;
00149     CERT_ALT_NAME_ENTRY **paName;
00150
00151     if (NULL == ppName)
00152     {
00153   hr = E_POINTER;
00154         ceERRORPRINTLINE("NULL parm", hr);
00155   goto error;
00156     }
00157
00158     hr = _MapDistPoint(fEncode, DistPointIndex, &pNameCount, &paName);
00159     if (S_OK != hr)
00160     {
00161   ceERRORPRINTLINE("_MapDistPoint", hr);
00162   goto error;
00163     }
00164     if (*pNameCount <= NameIndex)
00165     {
00166   ceERRORPRINTLINE("bad NameIndex parameter", hr);
00167   hr = E_INVALIDARG;
00168   goto error;
00169     }
00170     *ppName = &(*paName)[NameIndex];
00171
00172 error:
00173     return(hr);
00174 }
00175
00176
00177 //+--------------------------------------------------------------------------
00178 // CCertEncodeCRLDistInfo::Decode -- Decode CRLDistInfo
00179 //
00180 // Returns S_OK on success.
00181 //+--------------------------------------------------------------------------
00182
00183 STDMETHODIMP
00184 CCertEncodeCRLDistInfo::Decode(
00185     /* [in] */ BSTR const strBinary)
00186 {
00187     HRESULT hr = S_OK;
00188     DWORD cbCRLDist;
00189
00190     _Cleanup();
00191
00192     if (NULL == strBinary)
00193     {
00194         hr = E_POINTER;
00195   ceERRORPRINTLINE("NULL parm", hr);
00196   goto error;
00197     }
00198
00199     // Decode CRL_DIST_POINTS_INFO:
00200
00201     if (!ceDecodeObject(
00202         X509_ASN_ENCODING,
00203         X509_CRL_DIST_POINTS,
00204         (BYTE *) strBinary,
00205         SysStringByteLen(strBinary),
00206         FALSE,
00207         (VOID **) &m_DecodeInfo,
00208         &cbCRLDist))
00209     {
00210   hr = ceHLastError();
00211   ceERRORPRINTLINE("ceDecodeObject", hr);
00212   goto error;
00213     }
00214
00215     m_aValue = m_DecodeInfo->rgDistPoint;
00216     m_cValue = m_DecodeInfo->cDistPoint;
00217
00218 error:
00219     if (S_OK != hr)
00220     {
00221   _Cleanup();
00222     }
00223     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::Decode"));
00224 }
00225
00226
00227 //+--------------------------------------------------------------------------
00228 // CCertEncodeCRLDistInfo::GetDistPointCount -- Get the Distribution Name Count
00229 //
00230 // Returns S_OK on success.
00231 //+--------------------------------------------------------------------------
00232
00233 STDMETHODIMP
00234 CCertEncodeCRLDistInfo::GetDistPointCount(
00235     /* [out, retval] */ LONG __RPC_FAR *pDistPointCount)
00236 {
00237     HRESULT hr = E_INVALIDARG;
00238
00239     if (NULL == m_aValue)
00240     {
00241   ceERRORPRINTLINE("bad parameter", hr);
00242   goto error;
00243     }
00244
00245     if (NULL == pDistPointCount)
00246     {
00247         hr = E_POINTER;
00248   ceERRORPRINTLINE("NULL parm", hr);
00249   goto error;
00250     }
00251
00252     *pDistPointCount = m_cValue;
00253     hr = S_OK;
00254
00255 error:
00256     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetDistPointCount"));
00257 }
00258
00259
00260 //+--------------------------------------------------------------------------
00261 // CCertEncodeCRLDistInfo::GetNameCount -- Get a Name Count
00262 //
00263 // Returns S_OK on success.
00264 //+--------------------------------------------------------------------------
00265
00266 STDMETHODIMP
00267 CCertEncodeCRLDistInfo::GetNameCount(
00268     /* [in] */ LONG DistPointIndex,
00269     /* [out, retval] */ LONG __RPC_FAR *pNameCount)
00270 {
00271     HRESULT hr;
00272     LONG *pCount;
00273     CERT_ALT_NAME_ENTRY **paName;
00274
00275     if (NULL == pNameCount)
00276     {
00277         hr = E_POINTER;
00278   ceERRORPRINTLINE("NULL parm", hr);
00279   goto error;
00280     }
00281
00282     hr = _MapDistPoint(FALSE, DistPointIndex, &pCount, &paName);
00283     if (S_OK != hr)
00284     {
00285   ceERRORPRINTLINE("_MapDistPoint", hr);
00286   goto error;
00287     }
00288     if (NULL == *paName)
00289     {
00290   hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
00291   ceERRORPRINTLINE("uninitialized", hr);
00292   goto error;
00293     }
00294     *pNameCount = *pCount;
00295
00296 error:
00297     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetNameCount"));
00298 }
00299
00300
00301 //+--------------------------------------------------------------------------
00302 // CCertEncodeCRLDistInfo::GetNameChoice -- Get a Name Choice
00303 //
00304 // Returns S_OK on success.
00305 //+--------------------------------------------------------------------------
00306
00307 STDMETHODIMP
00308 CCertEncodeCRLDistInfo::GetNameChoice(
00309     /* [in] */ LONG DistPointIndex,
00310     /* [in] */ LONG NameIndex,
00311     /* [out, retval] */ LONG __RPC_FAR *pNameChoice)
00312 {
00313     HRESULT hr;
00314     CERT_ALT_NAME_ENTRY *pName;
00315
00316     if (NULL == pNameChoice)
00317     {
00318         hr = E_POINTER;
00319   ceERRORPRINTLINE("NULL parm", hr);
00320   goto error;
00321     }
00322
00323     hr = _MapName(FALSE, DistPointIndex, NameIndex, &pName);
00324     if (S_OK != hr)
00325     {
00326   ceERRORPRINTLINE("_MapName", hr);
00327   goto error;
00328     }
00329     *pNameChoice = pName->dwAltNameChoice;
00330     if (0 == pName->dwAltNameChoice)
00331     {
00332   hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
00333   ceERRORPRINTLINE("uninitialized", hr);
00334   goto error;
00335     }
00336
00337 error:
00338     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetNameChoice"));
00339 }
00340
00341
00342 //+--------------------------------------------------------------------------
00343 // CCertEncodeCRLDistInfo::GetName -- Get a Name
00344 //
00345 // Returns S_OK on success.
00346 //+--------------------------------------------------------------------------
00347
00348 STDMETHODIMP
00349 CCertEncodeCRLDistInfo::GetName(
00350     /* [in] */ LONG DistPointIndex,
00351     /* [in] */ LONG NameIndex,
00352     /* [out, retval] */ BSTR __RPC_FAR *pstrName)
00353 {
00354     HRESULT hr;
00355     CERT_ALT_NAME_ENTRY *pName;
00356     WCHAR const *pwsz = NULL;
00357     char const *psz = NULL;
00358
00359     if (NULL == pstrName)
00360     {
00361   hr = E_POINTER;
00362   ceERRORPRINTLINE("NULL parm", hr);
00363   goto error;
00364     }
00365     ceFreeBstr(pstrName);
00366     hr = _MapName(FALSE, DistPointIndex, NameIndex, &pName);
00367     if (S_OK != hr)
00368     {
00369   ceERRORPRINTLINE("_MapName", hr);
00370   goto error;
00371     }
00372
00373     switch (pName->dwAltNameChoice)
00374     {
00375   case CERT_ALT_NAME_RFC822_NAME:
00376       pwsz = pName->pwszRfc822Name;
00377       break;
00378
00379   case CERT_ALT_NAME_DNS_NAME:
00380       pwsz = pName->pwszDNSName;
00381       break;
00382
00383   case CERT_ALT_NAME_URL:
00384       pwsz = pName->pwszURL;
00385       break;
00386
00387   case CERT_ALT_NAME_REGISTERED_ID:
00388       psz = pName->pszRegisteredID;
00389       break;
00390
00391   //case CERT_ALT_NAME_DIRECTORY_NAME:
00392   //case CERT_ALT_NAME_OTHER_NAME:
00393   //case CERT_ALT_NAME_X400_ADDRESS:
00394   //case CERT_ALT_NAME_EDI_PARTY_NAME:
00395   //case CERT_ALT_NAME_IP_ADDRESS:
00396   default:
00397       assert(0 == pName->dwAltNameChoice);
00398       hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
00399       ceERRORPRINTLINE("uninitialized", hr);
00400       goto error;
00401     }
00402
00403     // we'd better assure 1 and only 1 of these is non null
00404
00405     if ((NULL != pwsz) ^ (NULL == psz))
00406     {
00407        hr = E_UNEXPECTED;
00408        _JumpError(hr, error, "((NULL != pwsz) ^ (NULL == psz))");
00409     }
00410
00411     hr = E_OUTOFMEMORY;
00412     if (NULL != pwsz)
00413     {
00414   if (!ceConvertWszToBstr(pstrName, pwsz, -1))
00415   {
00416       ceERRORPRINTLINE("no memory", hr);
00417       goto error;
00418   }
00419     }
00420     else
00421     {
00422   assert(NULL != psz);
00423   if (!ceConvertSzToBstr(pstrName, psz, -1))
00424   {
00425       ceERRORPRINTLINE("no memory", hr);
00426       goto error;
00427   }
00428     }
00429     hr = S_OK;
00430
00431 error:
00432     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetName"));
00433 }
00434
00435
00436 //+--------------------------------------------------------------------------
00437 // CCertEncodeCRLDistInfo::Reset -- clear out data
00438 //
00439 // Returns S_OK on success.
00440 //+--------------------------------------------------------------------------
00441
00442 STDMETHODIMP
00443 CCertEncodeCRLDistInfo::Reset(
00444     /* [in] */ LONG DistPointCount)
00445 {
00446     HRESULT hr = S_OK;
00447
00448     _Cleanup();
00449     m_fConstructing = TRUE;
00450     if (CENCODEMAX < DistPointCount || 0 > DistPointCount)
00451     {
00452   hr = E_INVALIDARG;
00453   ceERRORPRINTLINE("bad count parameter", hr);
00454   goto error;
00455     }
00456
00457     m_aValue = (CRL_DIST_POINT *) LocalAlloc(
00458         LMEM_FIXED | LMEM_ZEROINIT,
00459         DistPointCount * sizeof(m_aValue[0]));
00460     if (NULL == m_aValue)
00461     {
00462   hr = E_OUTOFMEMORY;
00463   ceERRORPRINTLINE("LocalAlloc", hr);
00464   goto error;
00465     }
00466     m_cValue = DistPointCount;
00467
00468 error:
00469     if (S_OK != hr)
00470     {
00471   _Cleanup();
00472     }
00473     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::Reset"));
00474 }
00475
00476
00477 //+--------------------------------------------------------------------------
00478 // CCertEncodeCRLDistInfo::SetNameCount -- Set the Name Count
00479 //
00480 // Returns S_OK on success.
00481 //+--------------------------------------------------------------------------
00482
00483 STDMETHODIMP
00484 CCertEncodeCRLDistInfo::SetNameCount(
00485     /* [in] */ LONG DistPointIndex,
00486     /* [in] */ LONG NameCount)
00487 {
00488     HRESULT hr;
00489     LONG *pNameCount;
00490     CERT_ALT_NAME_ENTRY **paName;
00491
00492     hr = E_INVALIDARG;
00493     if (!m_fConstructing)
00494     {
00495   ceERRORPRINTLINE("bad parameter", hr);
00496   goto error;
00497     }
00498     if (CENCODEMAX < NameCount || 0 > NameCount)
00499     {
00500   ceERRORPRINTLINE("bad count parameter", hr);
00501   goto error;
00502     }
00503
00504     hr = _MapDistPoint(FALSE, DistPointIndex, &pNameCount, &paName);
00505     if (S_OK != hr)
00506     {
00507   ceERRORPRINTLINE("_MapDistPoint", hr);
00508   goto error;
00509     }
00510     if (0 != *pNameCount || NULL != *paName)
00511     {
00512   hr = E_INVALIDARG;
00513   ceERRORPRINTLINE("bad parameter", hr);
00514   goto error;
00515     }
00516
00517     *paName = (CERT_ALT_NAME_ENTRY *) LocalAlloc(
00518         LMEM_FIXED | LMEM_ZEROINIT,
00519         NameCount * sizeof(CERT_ALT_NAME_ENTRY));
00520     if (NULL == *paName)
00521     {
00522   hr = E_OUTOFMEMORY;
00523   ceERRORPRINTLINE("LocalAlloc", hr);
00524   goto error;
00525     }
00526     *pNameCount = NameCount;
00527
00528 error:
00529     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::SetNameCount"));
00530 }
00531
00532
00533 //+--------------------------------------------------------------------------
00534 // CCertEncodeCRLDistInfo::SetNameEntry -- Set a Name Netry
00535 //
00536 // Returns S_OK on success.
00537 //+--------------------------------------------------------------------------
00538
00539 STDMETHODIMP
00540 CCertEncodeCRLDistInfo::SetNameEntry(
00541     /* [in] */ LONG DistPointIndex,
00542     /* [in] */ LONG NameIndex,
00543     /* [in] */ LONG NameChoice,
00544     /* [in] */ BSTR const strName)
00545 {
00546     HRESULT hr;
00547     CERT_ALT_NAME_ENTRY *pName;
00548     WCHAR **ppwsz = NULL;
00549     char **ppsz = NULL;
00550
00551     if (NULL == strName)
00552     {
00553   hr = E_POINTER;
00554   ceERRORPRINTLINE("NULL parm", hr);
00555   goto error;
00556     }
00557     if (!m_fConstructing)
00558     {
00559   hr = E_INVALIDARG;
00560   ceERRORPRINTLINE("bad parameter", hr);
00561   goto error;
00562     }
00563
00564     hr = _MapName(TRUE, DistPointIndex, NameIndex, &pName);
00565     if (S_OK != hr)
00566     {
00567   ceERRORPRINTLINE("_MapName", hr);
00568   goto error;
00569     }
00570
00571     if (NULL != pName->pwszURL)
00572     {
00573   hr = E_INVALIDARG;
00574   ceERRORPRINTLINE("bad parameter", hr);
00575   goto error;
00576     }
00577
00578     switch (NameChoice)
00579     {
00580   case CERT_ALT_NAME_RFC822_NAME:
00581       ppwsz = &pName->pwszRfc822Name;
00582       break;
00583
00584   case CERT_ALT_NAME_DNS_NAME:
00585       ppwsz = &pName->pwszDNSName;
00586       break;
00587
00588   case CERT_ALT_NAME_URL:
00589       ppwsz = &pName->pwszURL;
00590       break;
00591
00592   case CERT_ALT_NAME_REGISTERED_ID:
00593       hr = ceVerifyObjId(strName);
00594       if (S_OK != hr)
00595       {
00596     ceERRORPRINTLINE("ceVerifyObjId", hr);
00597     goto error;
00598       }
00599       ppsz = &pName->pszRegisteredID;
00600       break;
00601
00602   //case CERT_ALT_NAME_DIRECTORY_NAME:
00603   //case CERT_ALT_NAME_OTHER_NAME:
00604   //case CERT_ALT_NAME_X400_ADDRESS:
00605   //case CERT_ALT_NAME_EDI_PARTY_NAME:
00606   //case CERT_ALT_NAME_IP_ADDRESS:
00607     }
00608     if (NULL != ppwsz)
00609     {
00610   if (NULL != *ppwsz)
00611   {
00612       hr = E_INVALIDARG;
00613       ceERRORPRINTLINE("string already set", hr);
00614       goto error;
00615   }
00616   hr = ceVerifyAltNameString(NameChoice, strName);
00617   if (S_OK != hr)
00618   {
00619       ceERRORPRINTLINE("ceVerifyAltNameString", hr);
00620       goto error;
00621   }
00622   *ppwsz = ceDuplicateString(strName);
00623   if (NULL == *ppwsz)
00624   {
00625       hr = E_OUTOFMEMORY;
00626       ceERRORPRINTLINE("ceDuplicateString", hr);
00627       goto error;
00628   }
00629     }
00630     else if (NULL != ppsz)
00631     {
00632   if (NULL != *ppsz)
00633   {
00634       hr = E_INVALIDARG;
00635       ceERRORPRINTLINE("string already set", hr);
00636       goto error;
00637   }
00638   if (!ceConvertWszToSz(ppsz, strName, -1))
00639   {
00640       hr = E_OUTOFMEMORY;
00641       ceERRORPRINTLINE("ceConvertWszToSz", hr);
00642       goto error;
00643   }
00644     }
00645     else
00646     {
00647   hr = E_INVALIDARG;
00648   ceERRORPRINTLINE("bad NameChoice parameter", hr);
00649   goto error;
00650     }
00651     pName->dwAltNameChoice = NameChoice;
00652
00653 error:
00654     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::SetNameEntry"));
00655 }
00656
00657
00658 //+--------------------------------------------------------------------------
00659 // CCertEncodeCRLDistInfo::_VerifyNames -- Verify names
00660 //
00661 // Returns S_OK on success.
00662 //+--------------------------------------------------------------------------
00663
00664 BOOL
00665 CCertEncodeCRLDistInfo::_VerifyNames(
00666     IN LONG DistPointIndex)
00667 {
00668     HRESULT hr;
00669     BOOL fOk = FALSE;
00670     LONG Count;
00671     LONG *pNameCount;
00672     LONG i;
00673     CERT_ALT_NAME_ENTRY **paName;
00674
00675     assert(m_fConstructing);
00676
00677     hr = _MapDistPoint(TRUE, DistPointIndex, &pNameCount, &paName);
00678     if (S_OK != hr)
00679     {
00680   ceERRORPRINTLINE("_MapDistPoint", hr);
00681   goto error;
00682     }
00683     Count = *pNameCount;
00684     if (0 != Count)
00685     {
00686   CERT_ALT_NAME_ENTRY *pName;
00687
00688   pName = *paName;
00689   assert(NULL != pName);
00690   for (i = 0; i < Count; pName++, i++)
00691   {
00692       if (NULL == pName->pwszURL)   // test arbitrary union arm
00693       {
00694     hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00695     ceERRORPRINTLINE("uninitialized name", hr);
00696     goto error;
00697       }
00698   }
00699     }
00700     fOk = TRUE;
00701
00702 error:
00703     return(fOk);
00704 }
00705
00706
00707 //+--------------------------------------------------------------------------
00708 // CCertEncodeCRLDistInfo::Encode -- Encode CRLDistInfo
00709 //
00710 // Returns S_OK on success.
00711 //+--------------------------------------------------------------------------
00712
00713 STDMETHODIMP
00714 CCertEncodeCRLDistInfo::Encode(
00715     /* [out, retval] */ BSTR __RPC_FAR *pstrBinary)
00716 {
00717     HRESULT hr = S_OK;
00718     CRL_DIST_POINTS_INFO CRLDistInfo;
00719     BYTE *pbEncoded = NULL;
00720     DWORD cbEncoded;
00721     LONG i;
00722
00723     CRLDistInfo.cDistPoint = m_cValue;
00724     CRLDistInfo.rgDistPoint = m_aValue;
00725
00726     if (NULL == pstrBinary)
00727     {
00728   hr = E_POINTER;
00729   ceERRORPRINTLINE("NULL parm", hr);
00730   goto error;
00731     }
00732     ceFreeBstr(pstrBinary);
00733     if (!m_fConstructing || NULL == m_aValue)
00734     {
00735   hr = E_INVALIDARG;
00736   ceERRORPRINTLINE("bad parameter", hr);
00737   goto error;
00738     }
00739
00740     for (i = 0; i < m_cValue; i++)
00741     {
00742   m_aValue[i].DistPointName.dwDistPointNameChoice =
00743       CRL_DIST_POINT_FULL_NAME;
00744
00745   // Verify all entries are initialized:
00746
00747   if (!_VerifyNames(i))
00748   {
00749       hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
00750       ceERRORPRINTLINE("uninitialized name", hr);
00751       goto error;
00752   }
00753     }
00754
00755     // Encode CRL_DIST_POINTS_INFO:
00756
00757     if (!ceEncodeObject(
00758         X509_ASN_ENCODING,
00759         X509_CRL_DIST_POINTS,
00760         &CRLDistInfo,
00761         0,
00762         FALSE,
00763         &pbEncoded,
00764         &cbEncoded))
00765     {
00766   hr = ceHLastError();
00767   ceERRORPRINTLINE("ceEncodeObject", hr);
00768   goto error;
00769     }
00770     if (!ceConvertWszToBstr(pstrBinary, (WCHAR const *) pbEncoded, cbEncoded))
00771     {
00772   hr = E_OUTOFMEMORY;
00773   ceERRORPRINTLINE("ceConvertWszToBstr", hr);
00774   goto error;
00775     }
00776
00777 error:
00778     if (NULL != pbEncoded)
00779     {
00780   LocalFree(pbEncoded);
00781     }
00782     return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::Encode"));
00783 }
00784
00785
00786 //+--------------------------------------------------------------------------
00787 // CCertEncodeCRLDistInfo::_SetErrorInfo -- set error object information
00788 //
00789 // Returns passed HRESULT
00790 //+--------------------------------------------------------------------------
00791
00792 HRESULT
00793 CCertEncodeCRLDistInfo::_SetErrorInfo(
00794     IN HRESULT hrError,
00795     IN WCHAR const *pwszDescription)
00796 {
00797     assert(FAILED(hrError) || S_OK == hrError || S_FALSE == hrError);
00798     if (FAILED(hrError))
00799     {
00800   HRESULT hr;
00801
00802   hr = ceDispatchSetErrorInfo(
00803           hrError,
00804           pwszDescription,
00805           wszCLASS_CERTENCODECRLDISTINFO,
00806           &IID_ICertEncodeCRLDistInfo);
00807   assert(hr == hrError);
00808     }
00809     return(hrError);
00810 }
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/appinfo.Cpp Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

appinfo.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "stdafx.h"
00018 #include "AppInfo.h"
00019
00020 #include "ComSpyCtl.h"
00021 #include "ComSpyAudit.h"
00022 #include "CComSpy.h"
00023 #include <algorithm>
00024
00025 #include "SysLCESub.h"    // Includes for all the event consumers.
00026 #include "AppSub.h"     // Implement App Events
00027 #include "InstanceSub.h"  // Implement Instance Events
00028 #include "EvtStoreSub.h"  // Implement COM+ Event System Events
00029 #include "TxSub.h"      // Implement Transaction Events
00030 #include "ObjSub.h"     // Implement Object Events
00031 #include "MethodSub.h"    // Implement Method Events
00032 #include "ResourceSub.h"  // Implement Resource Events
00033 #include "SecuritySub.h"  // Implement Security Events
00034 #include "ThreadSub.h"    // Implement Thread Events
00035 #include "UserSub.h"    // Implement User Defined Events
00036 #include "ObjConstSub.h"  // Implement Object Construction Events
00037 #include "ObjPoolSub.h"   // Implement Object Pool Events
00038 #include "ObjPool2Sub.h"  // Implement more Object Pool Events
00039 #include "ActivitySub.h"  // Implement Activity Events
00040 #include "IdentitySub.h"  // Implement Identity Events
00041 #include "QCSub.h"      // Implement Queued Components Events
00042 #include "ExceptionSub.h" // Implement Exception Events
00043 #include "crmsub.h"     // Implement CRM Events
00044 #include "lbsub.h"      // Implement COM+ Load Balancing Events
00045
00046
00047
00048 // -----------------------------------------------------------------------------
00049 // Method:  CAppInfo::Initialze(...)
00050 // Params:  pSpy: Pointer to a CComSpy object.
00051 // Returns: (None)
00052 // Purpose: Initialize the class and create the Event Subscriber MAP.
00053 // -----------------------------------------------------------------------------
00054 void CAppInfo::Initialze(CComSpy * pSpy)
00055 {
00056   m_EventMap = new SUBSCRIBERMAP;
00057   m_bReadyForDelete = false;
00058   m_pSpy = pSpy;
00059 };
00060
00061
00062
00063 // -----------------------------------------------------------------------------
00064 // Method:  CAppInfo::CAppInfo(...)
00065 // Params:  sAppName: A string representing 'All Applications'
00066 //        pSpy:     Pointer to a CComSpy object.
00067 // Returns: (None)
00068 // Purpose: Constructor for the special, NoFilter instance of this class.
00069 // -----------------------------------------------------------------------------
00070 CAppInfo::CAppInfo(LPTSTR sAppName, CComSpy * pSpy)
00071 {
00072   Initialze(pSpy);
00073   m_sAppName = sAppName;
00074   m_FilterType = NoFilter;
00075   m_sAppID = _T("");
00076   m_PID = 0;
00077 };
00078
00079
00080
00081 // -----------------------------------------------------------------------------
00082 // Method:  CAppInfo::CAppInfo(...)
00083 // Params:  sAppName: A string representing 'All Applications'
00084 //        pSpy:     Pointer to a CComSpy object.
00085 //        nPID:     ProcessID for this running app.
00086 // Returns: (None)
00087 // Purpose: Constructor for the Running Application version of this object.
00088 // -----------------------------------------------------------------------------
00089 CAppInfo::CAppInfo(LPTSTR sAppName, CComSpy * pSpy, long nPID)
00090 {
00091   Initialze(pSpy);
00092   m_sAppName = sAppName;
00093   m_FilterType = ProcessID;
00094   m_sAppID = _T("");
00095   m_PID = nPID;
00096 };
00097
00098
00099
00100 // -----------------------------------------------------------------------------
00101 // Method:  CAppInfo::CAppInfo(...)
00102 // Params:  sAppName: String representing the AppName.
00103 //        pSpy:     Pointer to a CComSpy object.
00104 //        sAppID:   String representing AppID (a formatted GUID)
00105 // Returns: (None)
00106 // Purpose: Constructor for the standard case of filtering by AppID.
00107 //        Note that the COM+ Filtering does not want a Application Name, but
00108 //        instead wants an Application ID as a GUID.
00109 // -----------------------------------------------------------------------------
00110 CAppInfo::CAppInfo(LPTSTR sAppName, CComSpy * pSpy, LPTSTR sAppID)
00111 {
00112   Initialze(pSpy);
00113   m_sAppName = sAppName;
00114   m_FilterType = AppID;
00115   m_sAppID = sAppID;
00116   m_PID = 0;
00117 };
00118
00119
00120
00121 // -----------------------------------------------------------------------------
00122 // Method:  CAppInfo::~CAppInfo()
00123 // Params:  (None)
00124 // Returns: (None)
00125 // Purpose: Destructor for the CAppInfo class.  Remove All Subscriptions.
00126 //        and delete the map.
00127 // ToDo:    Do we need to empty this Map first?
00128 // -----------------------------------------------------------------------------
00129 CAppInfo::~CAppInfo()
00130 {
00131   bool bResult = RemoveAllSubscriptions();
00132   delete m_EventMap;
00133   m_EventMap = NULL;
00134  }
00135
00136
00137
00138 // -----------------------------------------------------------------------------
00139 // Method:  CAppInfo::RemoveAllSubscriptions()
00140 // Params:  (None)
00141 // Returns: True always
00142 // Purpose: Remove all subscriptions held by this Application object. Iterate
00143 //        through the event map and free each.
00144 //  Note:   We must call Release() because these are COM objects.
00145 // -----------------------------------------------------------------------------
00146 bool CAppInfo::RemoveAllSubscriptions()
00147 {
00148   SUBSCRIBERMAP::iterator item;
00149   ICOMSysLCE * pSubscriber = NULL;
00150
00151   // Iterate through the list of Events to delete them all.
00152   item = m_EventMap->begin();
00153   while (item != m_EventMap->end())
00154   {
00155     pSubscriber = (*item).second;
00156     if (pSubscriber)
00157     {
00158       pSubscriber->Uninstall();
00159       pSubscriber->Release();
00160       pSubscriber = NULL;
00161     }
00162     item = m_EventMap->erase(item);
00163   };
00164
00165   return true;
00166 }
00167
00168
00169
00170 // -----------------------------------------------------------------------------
00171 // Method:  CAppInfo::AddSubscription(...)
00172 // Params:  e: The EventEnum that we want to subscribe to. (eg. Method)
00173 // Returns: true if the subscription was added successfully.
00174 // Purpose: To create an Interface pointer to the appropriate Subscription
00175 //        type within COM+. These all derive from IComSysLCE, so we use
00176 //        the polymorphism to do this. Once we have the specific interface
00177 //        required, we then determine which filter (if any) to use and we
00178 //        Install the filter.
00179 // -----------------------------------------------------------------------------
00180 bool CAppInfo::AddSubscription(EventEnum e)
00181 {
00182   USES_CONVERSION;
00183
00184   HRESULT hr;
00185   ICOMSysLCE* pSubscriber = NULL;
00186
00187   if (IsSubscribed(e))
00188     return false;
00189
00190   switch (e)
00191   {
00192     // Hack note: The QI will do our AddRef
00193     case Application:
00194     {
00195       CComObject <CAppSub> * pSub;
00196       hr = CComObject<CAppSub>::CreateInstance(&pSub);
00197       _ASSERTE(pSub);
00198       pSub->SetSpyObj(m_pSpy);
00199       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00200       break;
00201     }
00202     case Thread:
00203     {
00204       CComObject <CThreadSub> * pSub;
00205       hr = CComObject<CThreadSub>::CreateInstance(&pSub);
00206       _ASSERTE(pSub);
00207       pSub -> SetSpyObj(m_pSpy);
00208       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00209       break;
00210     }
00211     case Instance:
00212     {
00213       CComObject <CInstanceSub> * pSub;
00214       hr = CComObject<CInstanceSub>::CreateInstance(&pSub);
00215       _ASSERTE(pSub);
00216       pSub -> SetSpyObj(m_pSpy);
00217       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00218       break;
00219     }
00220     case Transaction:
00221     {
00222       CComObject <CTxSub> * pSub;
00223       hr = CComObject<CTxSub>::CreateInstance(&pSub);
00224       _ASSERTE(pSub);
00225       pSub -> SetSpyObj(m_pSpy);
00226       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00227       break;
00228     }
00229     case Method:
00230     {
00231       CComObject <CMethodSub> * pSub;
00232       hr = CComObject<CMethodSub>::CreateInstance(&pSub);
00233       _ASSERTE(pSub);
00234       pSub -> SetSpyObj(m_pSpy);
00235       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00236       break;
00237     }
00238     case Object:
00239     {
00240       CComObject <CObjSub> * pSub;
00241       hr = CComObject<CObjSub>::CreateInstance(&pSub);
00242       _ASSERTE(pSub);
00243       pSub -> SetSpyObj(m_pSpy);
00244       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00245       break;
00246     }
00247     case Resource:
00248     {
00249       CComObject <CResourceSub> * pSub;
00250       hr = CComObject<CResourceSub>::CreateInstance(&pSub);
00251       _ASSERTE(pSub);
00252       pSub -> SetSpyObj(m_pSpy);
00253       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00254       break;
00255     }
00256     case User:
00257     {
00258       CComObject <CUserSub> * pSub;
00259       hr = CComObject<CUserSub>::CreateInstance(&pSub);
00260       _ASSERTE(pSub);
00261       pSub -> SetSpyObj(m_pSpy);
00262       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00263       break;
00264     }
00265     case Security:
00266     {
00267       CComObject <CSecuritySub> * pSub;
00268       hr = CComObject<CSecuritySub>::CreateInstance(&pSub);
00269       _ASSERTE(pSub);
00270       pSub -> SetSpyObj(m_pSpy);
00271       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00272       break;
00273     }
00274     case ObjectConstruction:
00275     {
00276       CComObject <CObjConstSub> * pSub;
00277       hr = CComObject<CObjConstSub>::CreateInstance(&pSub);
00278       _ASSERTE(pSub);
00279       pSub -> SetSpyObj(m_pSpy);
00280       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00281       break;
00282     }
00283     case ObjectPool:
00284     {
00285       CComObject <CObjPoolSub> * pSub;
00286       hr = CComObject<CObjPoolSub>::CreateInstance(&pSub);
00287       _ASSERTE(pSub);
00288       pSub -> SetSpyObj(m_pSpy);
00289       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00290       break;
00291     }
00292     case ObjectPool2:
00293     {
00294       CComObject <CObjPool2Sub> * pSub;
00295       hr = CComObject<CObjPool2Sub>::CreateInstance(&pSub);
00296       _ASSERTE(pSub);
00297       pSub -> SetSpyObj(m_pSpy);
00298       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00299       break;
00300     }
00301     case Activity:
00302     {
00303       CComObject <CActivitySub> * pSub;
00304       hr = CComObject<CActivitySub>::CreateInstance(&pSub);
00305       _ASSERTE(pSub);
00306       pSub -> SetSpyObj(m_pSpy);
00307       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00308       break;
00309     }
00310     case Identity:
00311     {
00312       CComObject <CIdentitySub> * pSub;
00313       hr = CComObject<CIdentitySub>::CreateInstance(&pSub);
00314       _ASSERTE(pSub);
00315       pSub -> SetSpyObj(m_pSpy);
00316       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00317       break;
00318     }
00319     case QC:
00320     {
00321       CComObject <CQCSub> * pSub;
00322       hr = CComObject<CQCSub>::CreateInstance(&pSub);
00323       _ASSERTE(pSub);
00324       pSub -> SetSpyObj(m_pSpy);
00325       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00326       break;
00327     }
00328     case Exception:
00329     {
00330       CComObject <CExceptionSub> * pSub;
00331       hr = CComObject<CExceptionSub>::CreateInstance(&pSub);
00332       _ASSERTE(pSub);
00333       pSub -> SetSpyObj(m_pSpy);
00334       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00335       break;
00336     }
00337     case CRM:
00338     {
00339       CComObject <CCRMSub> * pSub;
00340       hr = CComObject<CCRMSub>::CreateInstance(&pSub);
00341       _ASSERTE(pSub);
00342       pSub -> SetSpyObj(m_pSpy);
00343       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00344       break;
00345     }
00346     //Events generated by system process
00347     case EventStore:
00348     {
00349       CComObject <CEvtStoreSub> * pSub;
00350       hr = CComObject<CEvtStoreSub>::CreateInstance(&pSub);
00351       _ASSERTE(pSub);
00352       pSub -> SetSpyObj(m_pSpy);
00353       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00354       break;
00355     }
00356     case LoadBalancing:
00357     {
00358       CComObject <CLBSub> * pSub;
00359       hr = CComObject<CLBSub>::CreateInstance(&pSub);
00360       _ASSERTE(pSub);
00361       pSub -> SetSpyObj(m_pSpy);
00362       pSub -> QueryInterface(IID_ICOMSysLCE, (void **)&pSubscriber);
00363       break;
00364     }
00365     default:
00366       ATLTRACE(L"Object type not implemented yet\n");
00367       _ASSERTE(0);
00368       break;
00369   }
00370
00371   // We've successfully created the Subscriber interface.
00372   if (pSubscriber)
00373   {
00374     CComBSTR  bstrPropertyName;
00375     CComVariant vPropertyValue;
00376     BSTR*   pbstrPropertyName;
00377
00378     // Set the filter strings according to the object type.
00379     switch (m_FilterType)
00380     {
00381     case ProcessID:
00382       TCHAR convBuff[ 32 ];
00383       _itot( m_PID, convBuff, 10 );
00384
00385       vPropertyValue = convBuff;
00386       bstrPropertyName = _T("ProcessId");
00387       pbstrPropertyName = (BSTR*)&bstrPropertyName;
00388       break;
00389     case AppID:
00390       bstrPropertyName = _T("AppId");
00391       vPropertyValue = m_sAppID;
00392       pbstrPropertyName = (BSTR*)&bstrPropertyName;
00393       break;
00394     case NoFilter:
00395       // If this is a filtertype of All Apps, then pass NULL.
00396       pbstrPropertyName = NULL;
00397       vPropertyValue = _T("");
00398       break;
00399     default:
00400       _ASSERTE(0);
00401     };
00402
00403     // Register the subscription.
00404     pSubscriber->Install(pbstrPropertyName, vPropertyValue);
00405
00406     // Add the event Subscription to the MAP.
00407     (*m_EventMap)[e] = pSubscriber;
00408   };
00409
00410   return true;
00411 };
00412
00413
00414
00415 // -----------------------------------------------------------------------------
00416 // Method:  CAppInfo::RemoveAllSubscriptions()
00417 // Params:  e: The EventEnum to remove the subscription for.
00418 // Returns: true if the subscrioption was removed.
00419 // Purpose: Remove the Event Subscription for a given EventEnum.
00420 //  Note:   We must call Release() because these are COM objects.
00421 // -----------------------------------------------------------------------------
00422 bool CAppInfo::RemoveSubscription(EventEnum e)
00423 {
00424   ICOMSysLCE * pSubscriber = NULL;
00425
00426   if (!IsSubscribed(e))
00427     return false;
00428
00429   // Get the Subscriber interface pointer.
00430   pSubscriber = (*m_EventMap)[e];
00431   if (pSubscriber)
00432   {
00433     pSubscriber->Uninstall();
00434     pSubscriber->Release();
00435     pSubscriber = NULL;
00436     m_EventMap->erase(e);
00437     return true;
00438   };
00439
00440   return false;
00441 }
00442
00443
00444
00445 // -----------------------------------------------------------------------------
00446 // Method:  CAppInfo::IsSubscribed(...)
00447 // Params:  e: the EventEnum to check
00448 // Returns: True if the given Event is currently subscribed to, otherwise False.
00449 // Purpose: Check whether or not this Application is subscribed to an event.
00450 // -----------------------------------------------------------------------------
00451 bool CAppInfo::IsSubscribed(EventEnum e)
00452 {
00453   ICOMSysLCE * pSubscriber = NULL;
00454   pSubscriber = (*m_EventMap)[e];
00455   bool bResult = pSubscriber ? true : false;
00456   pSubscriber = NULL;
00457   return bResult;
00458 };
00459
00460
00461
00462 // -----------------------------------------------------------------------------
00463 // Method:  CAppInfo::IsSubscribedToAny()
00464 // Params:  (None)
00465 // Returns: True if any Event is currently subscribed to, otherwise False.
00466 // Purpose: Check whether or not this Application is subscribed to any events.
00467 // -----------------------------------------------------------------------------
00468 bool CAppInfo::IsSubscribedToAny()
00469 {
00470   long nSubs = 0;
00471   SUBSCRIBERMAP::iterator item;
00472   ICOMSysLCE * pSubscriber = NULL;
00473   for (item = m_EventMap->begin(); item != m_EventMap->end(); ++item)
00474   {
00475     pSubscriber = (*item).second;
00476     if (pSubscriber)
00477       nSubs++;
00478   };
00479   return (nSubs > 0) ? true : false;
00480 };
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/MethProv/MethProv.h Source File

  • SysMgmt
  • WMI
  • VC
  • MethProv

MethProv.h

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  methprov.h
00006
00007 //
00008
00009 //  Module: WMI Method Test Provider code
00010
00011 //
00012
00013 //  Purpose: Method Provider Test Header File.
00014
00015 //
00016
00017 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00018 //
00019 //***************************************************************************
00020
00021 #ifndef _methprov_H_
00022 #define _methprov_H_
00023
00024 #include "wbemidl.h"
00025
00026 typedef LPVOID * PPVOID;
00027
00028 //security helper:
00029 DWORD GetCurrentImpersonationLevel ();
00030
00031
00032 // Provider interfaces are provided by objects of this class
00033
00034
00035 class CMethodPro : public IWbemServices, public IWbemProviderInit
00036     {
00037     protected:
00038         ULONG              m_cRef;         //Object reference count
00039         IWbemServices *  m_pWbemSvcs;
00040         IWbemClassObject* m_pOutClass;
00041      public:
00042         CMethodPro();
00043         ~CMethodPro(void);
00044
00045         //Non-delegating object IUnknown
00046
00047         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00048         STDMETHODIMP_(ULONG) AddRef(void);
00049         STDMETHODIMP_(ULONG) Release(void);
00050
00051         STDMETHOD(GetTypeInfoCount)(THIS_ UINT FAR* pctinfo){return WBEM_E_NOT_SUPPORTED;};
00052
00053         STDMETHOD(GetTypeInfo)(
00054            THIS_
00055            UINT itinfo,
00056            LCID lcid,
00057            ITypeInfo FAR* FAR* pptinfo){return WBEM_E_NOT_SUPPORTED;};
00058
00059         STDMETHOD(GetIDsOfNames)(
00060           THIS_
00061           REFIID riid,
00062           OLECHAR FAR* FAR* rgszNames,
00063           UINT cNames,
00064           LCID lcid,
00065           DISPID FAR* rgdispid){return WBEM_E_NOT_SUPPORTED;};
00066
00067         STDMETHOD(Invoke)(
00068           THIS_
00069           DISPID dispidMember,
00070           REFIID riid,
00071           LCID lcid,
00072           WORD wFlags,
00073           DISPPARAMS FAR* pdispparams,
00074           VARIANT FAR* pvarResult,
00075           EXCEPINFO FAR* pexcepinfo,
00076           UINT FAR* puArgErr){return WBEM_E_NOT_SUPPORTED;};
00077
00078
00079         //IWbemProviderInit
00080
00081         HRESULT STDMETHODCALLTYPE Initialize(
00082              /* [in] */ LPWSTR pszUser,
00083              /* [in] */ LONG lFlags,
00084              /* [in] */ LPWSTR pszNamespace,
00085              /* [in] */ LPWSTR pszLocale,
00086              /* [in] */ IWbemServices *pNamespace,
00087              /* [in] */ IWbemContext *pCtx,
00088              /* [in] */ IWbemProviderInitSink *pInitSink
00089                         );
00090
00091         //IWbemServices
00092
00093     HRESULT STDMETHODCALLTYPE OpenNamespace(
00094             /* [in] */ const BSTR Namespace,
00095             /* [in] */ long lFlags,
00096             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00097             /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
00098             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) {return WBEM_E_NOT_SUPPORTED;};
00099
00100         HRESULT STDMETHODCALLTYPE CancelAsyncCall(
00101             /* [in] */ IWbemObjectSink __RPC_FAR *pSink) {return WBEM_E_NOT_SUPPORTED;};
00102
00103         HRESULT STDMETHODCALLTYPE QueryObjectSink(
00104             /* [in] */ long lFlags,
00105             /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00106
00107         HRESULT STDMETHODCALLTYPE GetObject(
00108             /* [in] */ const BSTR ObjectPath,
00109             /* [in] */ long lFlags,
00110             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00111             /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
00112             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00113
00114         HRESULT STDMETHODCALLTYPE GetObjectAsync(
00115             /* [in] */ const BSTR ObjectPath,
00116             /* [in] */ long lFlags,
00117             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00118             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;}
00119
00120         HRESULT STDMETHODCALLTYPE PutClass(
00121             /* [in] */ IWbemClassObject __RPC_FAR *pObject,
00122             /* [in] */ long lFlags,
00123             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00124             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00125
00126         HRESULT STDMETHODCALLTYPE PutClassAsync(
00127             /* [in] */ IWbemClassObject __RPC_FAR *pObject,
00128             /* [in] */ long lFlags,
00129             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00130             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00131
00132         HRESULT STDMETHODCALLTYPE DeleteClass(
00133             /* [in] */ const BSTR Class,
00134             /* [in] */ long lFlags,
00135             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00136             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00137
00138         HRESULT STDMETHODCALLTYPE DeleteClassAsync(
00139             /* [in] */ const BSTR Class,
00140             /* [in] */ long lFlags,
00141             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00142             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00143
00144         HRESULT STDMETHODCALLTYPE CreateClassEnum(
00145             /* [in] */ const BSTR Superclass,
00146             /* [in] */ long lFlags,
00147             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00148             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00149
00150         HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
00151             /* [in] */ const BSTR Superclass,
00152             /* [in] */ long lFlags,
00153             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00154             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00155
00156         HRESULT STDMETHODCALLTYPE PutInstance(
00157             /* [in] */ IWbemClassObject __RPC_FAR *pInst,
00158             /* [in] */ long lFlags,
00159             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00160             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00161
00162         HRESULT STDMETHODCALLTYPE PutInstanceAsync(
00163             /* [in] */ IWbemClassObject __RPC_FAR *pInst,
00164             /* [in] */ long lFlags,
00165             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00166             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00167
00168         HRESULT STDMETHODCALLTYPE DeleteInstance(
00169             /* [in] */ const BSTR ObjectPath,
00170             /* [in] */ long lFlags,
00171             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00172             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00173
00174         HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
00175             /* [in] */ const BSTR ObjectPath,
00176             /* [in] */ long lFlags,
00177             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00178             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00179
00180         HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
00181             /* [in] */ const BSTR Class,
00182             /* [in] */ long lFlags,
00183             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00184             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00185
00186         HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
00187             /* [in] */ const BSTR Class,
00188             /* [in] */ long lFlags,
00189             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00190             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;}
00191
00192         HRESULT STDMETHODCALLTYPE ExecQuery(
00193             /* [in] */ const BSTR QueryLanguage,
00194             /* [in] */ const BSTR Query,
00195             /* [in] */ long lFlags,
00196             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00197             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00198
00199         HRESULT STDMETHODCALLTYPE ExecQueryAsync(
00200             /* [in] */ const BSTR QueryLanguage,
00201             /* [in] */ const BSTR Query,
00202             /* [in] */ long lFlags,
00203             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00204             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00205
00206         HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
00207             /* [in] */ const BSTR QueryLanguage,
00208             /* [in] */ const BSTR Query,
00209             /* [in] */ long lFlags,
00210             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00211             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00212
00213         HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
00214             /* [in] */ const BSTR QueryLanguage,
00215             /* [in] */ const BSTR Query,
00216             /* [in] */ long lFlags,
00217             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00218             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00219
00220         // Supported !!!!
00221
00222         HRESULT STDMETHODCALLTYPE ExecMethod( const BSTR, const BSTR, long, IWbemContext*,
00223             IWbemClassObject*, IWbemClassObject**, IWbemCallResult**){return WBEM_E_NOT_SUPPORTED;}
00224
00225         HRESULT STDMETHODCALLTYPE ExecMethodAsync( const BSTR, const BSTR, long,
00226             IWbemContext*, IWbemClassObject*, IWbemObjectSink*);
00227
00228
00229 };
00230
00231 typedef CMethodPro *PCMethodPro;
00232
00233 // This class is the class factory for CMethodPro objects.
00234
00235 class CProvFactory : public IClassFactory
00236     {
00237     protected:
00238         ULONG           m_cRef;
00239
00240     public:
00241         CProvFactory(void);
00242         ~CProvFactory(void);
00243
00244         //IUnknown members
00245         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00246         STDMETHODIMP_(ULONG) AddRef(void);
00247         STDMETHODIMP_(ULONG) Release(void);
00248
00249         //IClassFactory members
00250         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
00251                                  , PPVOID);
00252         STDMETHODIMP         LockServer(BOOL);
00253     };
00254
00255 typedef CProvFactory *PCProvFactory;
00256
00257
00258
00259 // These variables keep track of when the module can be unloaded
00260
00261 extern long       g_cObj;
00262 extern long       g_cLock;
00263
00264 #endif
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFtNotify Member List

This is the complete list of members for CFtNotify, including all inherited members.
AddRef(void) | CFtNotify |
RefCount::AddRef(void) | RefCount |
CFtNotify() | CFtNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
CNotify(void) | CNotify |
Connect(IUnknown *pUnk) | CFtNotify |
CNotify::Connect(IUnknown *pUnk, REFIID riid, IUnknown *pUnkN) | CNotify |
Disconnect(void) | CFtNotify |
FtUpdate(CONFN uNotify, INmFt *pFt) | CFtNotify |
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
GetPunk() | CNotify | [inline]
MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember) | CFtNotify |
NmUI(CONFN uNotify) | CFtNotify |
QueryInterface(REFIID riid, PVOID *ppvObj) | CFtNotify |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
RefCount() | RefCount |
Release(void) | CFtNotify |
RefCount::Release(void) | RefCount |
~CFtNotify() | CFtNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~CNotify() | CNotify |
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
~RefCount() | RefCount | [virtual]
Generated on Wed Nov 13 2024 16:56:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

ISAPI_STRINGW Member List

This is the complete list of members for ISAPI_STRINGW, including all inherited members.
_Buffer | ISAPI_STRINGW | [private]
Append(WCHAR *szStringW, DWORD cchStringW=0) | ISAPI_STRINGW |
AppendA(CHAR *szString, DWORD cchString=0) | ISAPI_STRINGW |
CalcLen(VOID) | ISAPI_STRINGW |
Copy(WCHAR *szStringW, DWORD cchStringW=0) | ISAPI_STRINGW |
CopyA(CHAR *szString, DWORD cchString=0) | ISAPI_STRINGW |
CopyAToOffset(CHAR *szString, DWORD cchString, DWORD cchOffset) | ISAPI_STRINGW | [private]
CopyToOffset(WCHAR *szStringW, DWORD cchStringW, DWORD cchOffset) | ISAPI_STRINGW | [private]
ISAPI_STRINGW(DWORD dwMaxAlloc=0) | ISAPI_STRINGW |
Printf(WCHAR *szStringW,...) | ISAPI_STRINGW |
QueryBufferSize(VOID) | ISAPI_STRINGW |
QueryCB(VOID) | ISAPI_STRINGW |
QueryCCH(VOID) | ISAPI_STRINGW |
QueryMaxAlloc(VOID) | ISAPI_STRINGW |
QueryStr(VOID) | ISAPI_STRINGW |
ResizeBuffer(DWORD cbSize) | ISAPI_STRINGW |
SetLen(DWORD cchNewLength) | ISAPI_STRINGW |
SetMaxAlloc(DWORD dwMaxAlloc) | ISAPI_STRINGW |
Vsprintf(WCHAR *szFormatW, va_list args) | ISAPI_STRINGW |
~ISAPI_STRINGW() | ISAPI_STRINGW | [virtual]
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/resource.h Source File

  • SysMgmt
  • MMC
  • Nameext

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Resources.rc
00004 //
00005 #define IDS_HELPFILE                    1
00006 #define IDS_SNAPINDESC                  2
00007 #define IDS_NAME                        3
00008 #define IDS_SNAPINNAME                  6
00009 #define IDS_ABOUTNAME                   9
00010 #define IDI_ICON1                       108
00011 #define IDB_SMOPEN                      111
00012 #define IDB_SMBMP                       112
00013 #define IDB_LGBMP                       113
00014 #define IDR_SMICONS                     120
00015 #define IDR_LGICONS                     121
00016 #define IDB_ROCKET                      40004
00017 #define IDB_CAR                         40005
00018 #define IDB_PLANE                       40006
00019 #define IDB_BIKE                        40007
00020 #define IDB_ROCKET2                     40008
00021 #define IDB_CAR2                        40009
00022 #define IDB_PLANE2                      40010
00023 #define IDB_BIKE2                       40011
00024 #define IDB_CLOSED2                     40012
00025 #define IDB_OPEN2                       40013
00026 #define IDB_CLOSED                      40014
00027 #define IDB_OPEN                        40015
00028
00029 // Next default values for new objects
00030 //
00031 #ifdef APSTUDIO_INVOKED
00032 #ifndef APSTUDIO_READONLY_SYMBOLS
00033 #define _APS_NEXT_RESOURCE_VALUE        114
00034 #define _APS_NEXT_COMMAND_VALUE         40016
00035 #define _APS_NEXT_CONTROL_VALUE         1000
00036 #define _APS_NEXT_SYMED_VALUE           101
00037 #endif
00038 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerClien/RESDEF.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerClien

RESDEF.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      RESDEF.H
00003
00004   Summary:   Resource include file for the PERCLIEN code sample
00005              application. Contains definitions of the application's menu,
00006              string, and other resource IDs.
00007
00008              For a comprehensive tutorial code tour of PERCLIEN's contents
00009              and offerings see the tutorial PERCLIEN.HTM file. For more
00010              specific technical details on the internal workings see the
00011              comments dispersed throughout the PERCLIEN source code.
00012
00013   Classes:   none.
00014
00015   Functions: none.
00016
00017   Origin:    5-25-97: atrent - Editor-inheritance from STOCLIEN source.
00018
00019 ----------------------------------------------------------------------------
00020   This file is part of the Microsoft COM Tutorial Code Samples.
00021
00022   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00023
00024   This source code is intended only as a supplement to Microsoft
00025   Development Tools and/or on-line documentation.  See these other
00026   materials for detailed information regarding Microsoft code samples.
00027
00028   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00029   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00030   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00031   PARTICULAR PURPOSE.
00032 ==========================================================================+*/
00033
00034 #if !defined(RESDEF_H)
00035 #define RESDEF_H
00036
00037 // Main Window Class String Macros.
00038 #define MAIN_APP_NAME_STR           "PERCLIEN: "
00039 #define MAIN_WINDOW_TITLE_STR       "PERCLIEN: perclien.pag"
00040 #define MAIN_WINDOW_CLASS_NAME_STR  "PERCLIENWindow"
00041 #define MAIN_WINDOW_CLASS_MENU_STR  "PERCLIENMenu"
00042 #define NOFILE_STR                  "No File Open"
00043
00044 // File Name String Macros.
00045 #define SERVER_PERSERVE_STR          "perserve.htm"
00046 #define SERVER_PERTEXT_STR           "pertext.htm"
00047 #define SERVER_PERDRAW_STR           "perdraw.htm"
00048
00049 // OpenFile-related String Macros.
00050 #define OFN_DEFAULTFILES_STR "All Files (*.*)\0*.*\0"
00051 #define OFN_DEFAULTTITLE_STR "Open File"
00052
00053 // Main Page List Client Application Menu Command Identifiers.
00054 // File Menu.
00055 #define IDM_FILE_NEW                1000
00056 #define IDM_FILE_OPEN               1001
00057 #define IDM_FILE_SAVE               1002
00058 #define IDM_FILE_SAVEAS             1003
00059 #define IDM_FILE_EXIT               1004
00060 // Page Menu.
00061 #define IDM_PAGE_OPEN               1100
00062 #define IDM_PAGE_TITLE              1101
00063 #define IDM_PAGE_DELETE             1102
00064 #define IDM_PAGE_NEWTEXT            1103
00065 #define IDM_PAGE_NEWDRAW            1104
00066 // Help Menu.
00067 #define IDM_HELP_CONTENTS           1900
00068 #define IDM_HELP_TUTORIAL           1901
00069 #define IDM_HELP_PERSERVE           1902
00070 #define IDM_HELP_PERTEXT            1903
00071 #define IDM_HELP_PERDRAW            1904
00072 #define IDM_HELP_READSOURCE         1905
00073 #define IDM_HELP_ABOUT              1906
00074
00075 // Dialog and Control IDs.
00076 #define IDD_PAGE_PROPS              5000
00077 #define IDC_STATIC_PGTITLE          5001
00078 #define IDC_EDIT_PGTITLE            5002
00079
00080 // Error-related String Identifiers.
00081 #define IDS_COMINITFAILED           9000
00082 #define IDS_APPINITFAILED           9001
00083 #define IDS_NOUNICODE               9002
00084 #define IDS_NOSERVER                9003
00085 #define IDS_OUTOFMEMORY             9004
00086 #define IDS_TOOMANYOPEN             9005
00087 #define IDS_PAGEFULL                9006
00088 #define IDS_OPENTEXTPAGE            9007
00089 #define IDS_OPENDRAWPAGE            9008
00090 #define IDS_NOTIMPLEMENTED          9009
00091
00092 #define IDS_ASSERT_FAIL             9300
00093
00094 // Notice-related String Identifiers.
00095 #define IDS_TEXT_PAGE               9500
00096 #define IDS_DRAW_PAGE               9501
00097 #define IDS_FILE_CHANGED            9502
00098 #define IDS_ASK_SAVE                9503
00099 #define IDS_OFN_PAGFILES            9504
00100 #define IDS_OFN_PAGOPEN             9505
00101 #define IDS_OFN_PAGSAVE             9506
00102
00103 // Text Window definitions.
00104
00105 #define TEXT_WINDOW_NAME_STR        "PERCLIEN Text: "
00106 #define TEXT_WINDOW_CLASS_NAME_STR  "TextWindow"
00107 #define TEXT_WINDOW_CLASS_MENU_STR  "TextMenu"
00108
00109 // Text Window Text Menu.
00110 #define IDM_TEXT_SAVE               2200
00111 #define IDM_TEXT_CLEAR              2201
00112 #define IDM_TEXT_EXIT               2202
00113
00114 // Text Window Edit Menu.
00115 #define IDM_EDIT_UNDO               2300
00116 #define IDM_EDIT_SELECTALL          2301
00117 #define IDM_EDIT_CUT                2302
00118 #define IDM_EDIT_COPY               2303
00119 #define IDM_EDIT_PASTE              2304
00120 #define IDM_EDIT_DELETE             2305
00121
00122 // Text Window Help Menu.
00123 #define IDM_THELP_CONTENTS          2400
00124 #define IDM_THELP_TUTORIAL          2401
00125 #define IDM_THELP_TUTSERVER         2402
00126 #define IDM_THELP_READSOURCE        2403
00127 #define IDM_THELP_ABOUT             2404
00128
00129 // Draw Window definitions.
00130
00131 #define DRAW_WINDOW_NAME_STR        "PERCLIEN Drawing: "
00132 #define DRAW_WINDOW_CLASS_NAME_STR  "DrawWindow"
00133 #define DRAW_WINDOW_CLASS_MENU_STR  "DrawMenu"
00134
00135 // Draw Menu Command Identifiers.
00136 #define IDM_DRAW_SAVE               2700
00137 #define IDM_DRAW_CLEAR              2701
00138 #define IDM_DRAW_EXIT               2702
00139 // Pen Menu.
00140 #define IDM_PEN_COLOR               2800
00141 #define IDM_PEN_THIN                2801
00142 #define IDM_PEN_MEDIUM              2802
00143 #define IDM_PEN_THICK               2803
00144 // Help Menu.
00145 #define IDM_DHELP_CONTENTS          2900
00146 #define IDM_DHELP_TUTORIAL          2901
00147 #define IDM_DHELP_TUTSERVER         2962
00148 #define IDM_DHELP_READSOURCE        2903
00149 #define IDM_DHELP_ABOUT             2904
00150
00151
00152 #endif // RESDEF_H
Generated on Wed Nov 13 2024 16:51:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/filerepsecure/prof.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • filerepsecure

prof.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright Microsoft Corp. 1992 - 2001
00003
00004     Server Profiling Routines
00005
00006     FILE: Prof.cpp
00007
00008     PURPOSE: Routines for profiling server system services.
00009
00010     FUNCTIONS:
00011         ProfOpenLog - Opens the profile log file and prepares to
00012     take timings.
00013   ProfRecordTime - Records the time of an event.
00014   ProfCloseLog - Writes the profiling data to the file
00015     and closes it.
00016
00017     COMMENTS: See the header file for function info.
00018         These routines depend on the existence of a high-resolution
00019     performance counter.
00020
00021 */
00022
00023 #include <windows.h>
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <process.h>
00027 #include <tchar.h>
00028
00029 #include "Prof.h"
00030 #include "Service.h"
00031 #include "common.h"
00032
00033 // Handle to the profile log file.
00034 HANDLE hProfLog = NULL;
00035
00036 // Counters for the timings.
00037 LARGE_INTEGER lpStartTime, lpCurrentTime, lpFrequency;
00038
00039 // The profile log text data.
00040 // Profile log gets acumulated in this string first, and then
00041 // gets written out when the log gets closed.
00042 TCHAR PROF_LOG[PROF_LOG_MAX_SIZE];
00043
00044 // Current size of the profile log.
00045 UINT nProfLogSize = 0;
00046
00047 // This is the maximum size of the log entry without the
00048 // user-specified message.  It is basically the size of a string
00049 // with an integer and a float.
00050 #define MAX_ENTRY_SIZE_NOMSG (32)
00051
00052 HANDLE hProfMutex;
00053
00054 VOID ProfOpenLog(LPTSTR LogFileName) {
00055
00056     // Create the mutex.
00057     if ((hProfMutex = CreateMutex(NULL,
00058           FALSE,
00059           TEXT("ProfMutex"))) == INVALID_HANDLE_VALUE) {
00060   RaiseException(GetLastError(), 0, 0, NULL);
00061         return;
00062     }
00063
00064     // Open the profiling log.
00065     if ((hProfLog = CreateFile(LogFileName,
00066              GENERIC_WRITE,
00067              0,
00068              NULL,
00069              CREATE_ALWAYS,
00070              FILE_ATTRIBUTE_NORMAL,
00071              NULL)) == INVALID_HANDLE_VALUE) {
00072   RaiseException(GetLastError(), 0, 0, NULL);
00073         return;
00074     }
00075
00076     // Get the current time.
00077     if (QueryPerformanceCounter(&lpStartTime) == FALSE) {
00078   RaiseException(GetLastError(), 0, 0, NULL);
00079         return;
00080     }
00081
00082     // Get the frequency.
00083     if (QueryPerformanceFrequency(&lpFrequency) == FALSE) {
00084   RaiseException(GetLastError(), 0, 0, NULL);
00085         return;
00086     }
00087 }
00088
00089 VOID ProfRecordTime(UINT id, LPTSTR msg) {
00090     FLOAT dt;
00091
00092     if (WaitForSingleObject(hProfMutex, INFINITE) == WAIT_FAILED) {
00093   RaiseException(GetLastError(), 0, 0, NULL);
00094   return;
00095     }
00096
00097     // Write the entry only if there is enough space left in
00098     // the log.
00099     if (nProfLogSize < PROF_LOG_MAX_SIZE - (MAX_ENTRY_SIZE_NOMSG + _tcslen(msg))) {
00100   if (QueryPerformanceCounter(&lpCurrentTime) == FALSE) {
00101       RaiseException(GetLastError(), 0, 0, NULL);
00102       return;
00103   }
00104
00105   // Get the time stamp for the event.
00106   dt = (FLOAT)(lpCurrentTime.QuadPart - lpStartTime.QuadPart)/(FLOAT)(lpFrequency.QuadPart);
00107
00108   // Append the entry to the log.
00109   nProfLogSize+=_stprintf(&PROF_LOG[nProfLogSize], TEXT("%d %s %f\n"), id, msg, dt);
00110     }
00111
00112     if (ReleaseMutex(hProfMutex) == FALSE) {
00113   RaiseException(GetLastError(), 0, 0, NULL);
00114   return;
00115     }
00116 }
00117
00118 VOID ProfCloseLog(VOID) {
00119     ULONG cbWritten;
00120     DWORD status;
00121
00122     // Close the mutex.
00123     // Here we make the assumption that no outside functions will use
00124     // the mutex anymore.  This should be valid, since all the profiling data
00125     // has been written.
00126     status = CloseHandle(hProfMutex);
00127     ASSERTE(status);
00128
00129     // Write out the profile log.
00130     if(!WriteFile(hProfLog,
00131       (LPVOID)PROF_LOG,
00132       nProfLogSize*sizeof(TCHAR),
00133       &cbWritten,
00134       NULL)) {
00135
00136   RaiseException(GetLastError(), 0, 0, NULL);
00137   return;
00138     }
00139
00140     // Close the profile log.
00141     if (hProfLog != NULL && hProfLog != INVALID_HANDLE_VALUE) {
00142         status = CloseHandle(hProfLog);
00143         ASSERTE(status);
00144     }
00145 }
00146
00147 // end Prof.cpp
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/lrsample/filtreg.hxx Source File

  • WinBase
  • Indexing
  • lrsample

filtreg.hxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (c) Microsoft Corporation. All rights reserved.
00005 //
00006 // File:        RegSrv.hxx
00007 //
00008 // Contents:    Macros for Self-registration of Filters
00009 //
00010 // Functions:   Macros to create DllRegisterServer, DllUnregisterServer
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 #pragma once
00015
00016 #include <olectl.h>
00017
00018 //
00019 // Structure to define classes (.doc, .xls, etc.)
00020 //
00021
00022 struct SClassEntry
00023 {
00024     WCHAR const * pwszExt;                  // (ex: .doc)  May be null
00025     WCHAR const * pwszShortName;            // (ex: Word.Document.8)
00026     WCHAR const * pwszDescription;          // (ex: Microsoft Word Document)
00027     WCHAR const * pwszClassId;              // (ex: {00020906-0000-0000-C000-000000000046})
00028     WCHAR const * pwszClassIdDescription;   // (ex: Microsoft Word Document)
00029 };
00030
00031 //
00032 // Structure to define persistent handler entry.
00033 //
00034
00035 struct SHandlerEntry
00036 {
00037     WCHAR const * pwszClassId;
00038     WCHAR const * pwszClassIdDescription;
00039     WCHAR const * pwszClassIdFilter;
00040 };
00041
00042 //
00043 // Structure to define filter class
00044 //
00045
00046 struct SFilterEntry
00047 {
00048     WCHAR const * pwszClassId;
00049     WCHAR const * pwszClassIdDescription;
00050     WCHAR const * pwszDLL;
00051     WCHAR const * pwszThreadingModel;
00052 };
00053
00054 //
00055 // Sample use of the three structures
00056 //
00057 //
00058 // SClassEntry const aClasses[] = { { L".doc", L"Word.Document.8",
00059 //                                    L"Microsoft Word Document",
00060 //                                    L"{00020906-0000-0000-C000-000000000046}",
00061 //                                    L"Microsoft Word Document" },
00062 //
00063 //                                  { 0, L"Word.Document.6",
00064 //                                    L"Microsoft Word 6.0 - 7.0 Document",
00065 //                                    L"{00020900-0000-0000-C000-000000000046}",
00066 //                                    L"Microsoft Word 6.0 - 7.0 Document" }
00067 //                                };
00068 //
00069 // SHandlerEntry const OfficeHandler = { L"{98de59a0-d175-11cd-a7bd-00006b827d94}",
00070 //                                       L"Microsoft Office Persistent Handler",
00071 //                                       L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}" };
00072 //
00073 // SFilterEntry const OfficeFilter = { L"{f07f3920-7b8c-11cf-9be8-00aa004b9986}",
00074 //                                     L"Microsoft Office Filter",
00075 //                                     L"OffFilt.dll",
00076 //                                     0 };
00077 //
00078
00079 //
00080 // Function prototypes
00081 //
00082
00083 inline long RegisterACLSID( SClassEntry const & Class,
00084                             WCHAR const * pwszPHandler,
00085                             WCHAR const * pwszClassId = 0,
00086                             BOOL fAppendOnly = FALSE,
00087                             BOOL fAppendDesc = TRUE );
00088
00089 inline long RegisterAClass( SClassEntry const & Class,
00090                             WCHAR const * pwszPHandler,
00091                             WCHAR const * pwszShortName = 0,
00092                             BOOL fAppendOnly = FALSE );
00093
00094 inline long RegisterAClassAndExt( SClassEntry const & Class,
00095                                   WCHAR const * pwszPHandler,
00096                                   BOOL fAppendOnly = FALSE,
00097                                   BOOL fBlastExistingPersistentHandler = TRUE );
00098
00099 //+---------------------------------------------------------------------------
00100 //
00101 //  Function:   BuildKeyValues, private
00102 //
00103 //  Effects:    Given array of key, value, key, value, ... adds the entries
00104 //              under CLSID as:
00105 //
00106 //                  Key1 : <NO NAME> Value1
00107 //                    Key2 : <NO NAME> Value2
00108 //                      :
00109 //                      :
00110 //
00111 //  Arguments:  [awszKeyValues] -- Keys and values
00112 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00113 //
00114 //  Returns:    ERROR_SUCCESS on success
00115 //
00116 //  Notes:      The *value* entries can be null, signifying no value at a
00117 //              given level.
00118 //
00119 //----------------------------------------------------------------------------
00120
00121 inline long BuildKeyValues( WCHAR const * const * awszKeyValues, unsigned cKeyValues )
00122 {
00123     WCHAR wcTemp[MAX_PATH];
00124     wcscpy( wcTemp, L"CLSID" );
00125
00126     long dwError;
00127     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00128     unsigned i = 0;
00129
00130     do
00131     {
00132         if ( INVALID_HANDLE_VALUE != hKey )
00133         {
00134             RegCloseKey( hKey );
00135             hKey = (HKEY)INVALID_HANDLE_VALUE;
00136         }
00137
00138         wcscat( wcTemp, L"\\" );
00139         wcscat( wcTemp, awszKeyValues[i] );
00140
00141         DWORD  dwDisposition;
00142
00143         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00144                                    wcTemp,               // Sub key
00145                                    0,                    // Reserved
00146                                    0,                    // Class
00147                                    0,                    // Flags
00148                                    KEY_ALL_ACCESS,       // Access
00149                                    0,                    // Security
00150                                    &hKey,                // Handle
00151                                    &dwDisposition );     // Disposition
00152
00153         if ( ERROR_SUCCESS != dwError )
00154             break;
00155
00156         i++;
00157
00158         if ( 0 != awszKeyValues[i] )
00159             dwError = RegSetValueExW( hKey,                     // Key
00160                                       0,                        // Name
00161                                       0,                        // Reserved
00162                                       REG_SZ,                   // Type
00163                                       (BYTE *)awszKeyValues[i], // Value
00164                                       (DWORD) ( (1 + wcslen(awszKeyValues[i]) ) * sizeof(WCHAR) ) );
00165
00166         if ( ERROR_SUCCESS != dwError )
00167             break;
00168
00169         i++;
00170     }
00171     while ( i < cKeyValues );
00172
00173     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00174         RegCloseKey( hKey );
00175
00176     return dwError;
00177 }
00178
00179 //+---------------------------------------------------------------------------
00180 //
00181 //  Function:   AddThreadingModel
00182 //
00183 //  Synopsis:   Adds the threading model value to the CLSID\\GUID\\InProcServer32
00184 //              key
00185 //
00186 //  Arguments:  [wszClsId] - ClassId of the inproc server.
00187 //              [wszThreadingModel] -- 0 (for single threaded) or one of
00188 //                                     Apartment, Free, or Both
00189 //
00190 //  History:    3-07-97   srikants   Created
00191 //
00192 //----------------------------------------------------------------------------
00193
00194 inline long AddThreadingModel( WCHAR const * wszClsId,
00195                                WCHAR const * wszThreadingModel )
00196 {
00197     WCHAR wcTemp[MAX_PATH];
00198     wcscpy( wcTemp, L"CLSID" );
00199     wcscat( wcTemp, L"\\" );
00200     wcscat( wcTemp, wszClsId );
00201     wcscat( wcTemp, L"\\" );
00202     wcscat( wcTemp, L"InprocServer32" );
00203
00204     long dwError;
00205     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00206     unsigned i = 0;
00207
00208     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00209                              wcTemp,               // Sub key
00210                              0,                    // Reserved
00211                              KEY_ALL_ACCESS,       // Access
00212                              &hKey );              // Handle
00213
00214     if ( ERROR_SUCCESS != dwError )
00215         return dwError;
00216
00217     if ( 0 != wszThreadingModel )
00218         dwError = RegSetValueExW( hKey,                   // Key
00219                                   L"ThreadingModel",      // Name
00220                                   0,                      // Reserved
00221                                   REG_SZ,                 // Type
00222                                   (BYTE *) wszThreadingModel,  // Value
00223                                   (DWORD) ( (wcslen(wszThreadingModel) + 1) * sizeof WCHAR ) );
00224     else
00225         RegDeleteValueW( hKey,                   // Key
00226                          L"ThreadingModel" );    // Name
00227
00228     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00229         RegCloseKey( hKey );
00230
00231     return dwError;
00232 }
00233
00234 //+---------------------------------------------------------------------------
00235 //
00236 //  Function:   DestroyKeyValues, private
00237 //
00238 //  Effects:    Given array of key, value, key, value from AddKeyValues,
00239 //              removes the keys.
00240 //
00241 //  Arguments:  [awszKeyValues] -- Keys and values
00242 //              [cKeyValues]    -- Number of entries in array.  Must be even.
00243 //
00244 //  Returns:    ERROR_SUCCESS on success
00245 //
00246 //----------------------------------------------------------------------------
00247
00248 inline long DestroyKeyValues( WCHAR const * const * awszKeyValues, int cKeyValues )
00249 {
00250     WCHAR wcTemp[MAX_PATH];
00251
00252     //
00253     // Build path to deepest component
00254     //
00255
00256     wcscpy( wcTemp, L"CLSID" );
00257     int i = 0;
00258
00259     do
00260     {
00261         wcscat( wcTemp, L"\\" );
00262         wcscat( wcTemp, awszKeyValues[i] );
00263
00264         i += 2;
00265     }
00266     while ( i < cKeyValues );
00267
00268     //
00269     // Remove components in reverse order
00270     //
00271
00272     long dwError = ERROR_SUCCESS;
00273     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
00274
00275     unsigned cc = (unsigned) wcslen( wcTemp );
00276
00277     for ( i -= 2; i >= 0; i -= 2 )
00278     {
00279         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00280                                  wcTemp,               // Sub key
00281                                  0,                    // Reserved
00282                                  KEY_ALL_ACCESS,       // Access
00283                                  &hKey );              // Handle
00284
00285         if ( ERROR_SUCCESS != dwError )
00286             break;
00287
00288         #if 0  // Values deleted by RegDeleteKeyW
00289         //
00290         // Delete value, if there is one.
00291         //
00292
00293         if ( 0 != awszKeyValues[i+1] )
00294             dwError = RegDeleteValueW( hKey, 0 );
00295
00296         if ( ERROR_SUCCESS != dwError )
00297             break;
00298         #endif // 0
00299
00300         //
00301         // Delete subkey, if there is one.
00302         //
00303
00304         if ( i+2 < cKeyValues )
00305             dwError = RegDeleteKeyW( hKey, awszKeyValues[i+2] );
00306
00307         if ( ERROR_SUCCESS != dwError )
00308             break;
00309
00310         //
00311         // Close key and truncate string to next component.
00312         //
00313
00314         if ( INVALID_HANDLE_VALUE != hKey )
00315         {
00316             RegCloseKey( hKey );
00317             hKey = (HKEY)INVALID_HANDLE_VALUE;
00318         }
00319
00320         cc -= (unsigned) wcslen( awszKeyValues[i] );
00321         cc--;
00322
00323         wcTemp[cc] = 0;
00324     }
00325
00326     //
00327     // Remove the final top key
00328     //
00329
00330     if ( ERROR_SUCCESS == dwError )
00331     {
00332         do
00333         {
00334             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00335                                      wcTemp,               // Sub key -- "CLSID"
00336                                      0,                    // Reserved
00337                                      KEY_ALL_ACCESS,       // Access
00338                                      &hKey );              // Handle
00339
00340             if ( ERROR_SUCCESS != dwError )
00341                 break;
00342
00343             //
00344             // Delete subkey
00345             //
00346
00347             dwError = RegDeleteKeyW( hKey, awszKeyValues[0] );
00348
00349         } while ( FALSE );
00350     }
00351
00352     return dwError;
00353 }
00354
00355 //+---------------------------------------------------------------------------
00356 //
00357 //  Function:   RegisterAClassAndExt, private
00358 //
00359 //  Synopsis:   Registers a class, extensions (optional) and a persistent handler.
00360 //
00361 //  Arguments:  [Class]        -- Class description
00362 //              [pwszPHandler] -- Persistent handler for class
00363 //
00364 //  Returns:    ERROR_SUCCESS on success
00365 //
00366 //  Notes:      Class is only registered if similar class does not already
00367 //              exist.  Persistent handler is always registered for class.
00368 //
00369 //----------------------------------------------------------------------------
00370
00371 inline long RegisterAClassAndExt( SClassEntry const & Class,
00372                                   WCHAR const * pwszPHandler,
00373                                   BOOL fAppendOnly,
00374                                   BOOL fBlastExistingPersistentHandler )
00375 {
00376     WCHAR wcTemp[MAX_PATH];
00377
00378     long dwError = NO_ERROR;
00379     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00380
00381     do
00382     {
00383         //
00384         // First, the optional extension entry
00385         //
00386
00387         DWORD dwDisposition;
00388         DWORD dwType;
00389         DWORD dwSize;
00390
00391         if ( 0 == Class.pwszExt )
00392         {
00393             //
00394             // Build up named entry
00395             //
00396
00397             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00398                 return ERROR_INSUFFICIENT_BUFFER;
00399
00400             wcscpy( wcTemp, Class.pwszShortName );
00401         }
00402         else
00403         {
00404             if ( wcslen( Class.pwszExt ) >= MAX_PATH )
00405                 return ERROR_INSUFFICIENT_BUFFER;
00406
00407             wcscpy( wcTemp, Class.pwszExt );
00408
00409             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00410                                        wcTemp,               // Sub key
00411                                        0,                    // Reserved
00412                                        0,                    // Class
00413                                        0,                    // Flags
00414                                        KEY_ALL_ACCESS,       // Access
00415                                        0,                    // Security
00416                                        &hKey,                // Handle
00417                                        &dwDisposition );     // Disposition
00418             if ( ERROR_SUCCESS != dwError )
00419                 break;
00420
00421             //
00422             // Write or read class association
00423             //
00424
00425             BOOL fSetValue = TRUE;
00426
00427             if ( REG_OPENED_EXISTING_KEY == dwDisposition )
00428             {
00429                 dwSize = sizeof(wcTemp);
00430
00431                 dwError = RegQueryValueExW( hKey,            // Key handle
00432                                             0,               // Name
00433                                             0,               // Reserved
00434                                             &dwType,         // Datatype
00435                                             (BYTE *)wcTemp,  // Data returned here
00436                                             &dwSize );       // Size of data
00437
00438                 if ( ERROR_SUCCESS == dwError )
00439                 {
00440                     fSetValue = FALSE;
00441
00442                     if ( REG_SZ != dwType )
00443                         dwError = E_FAIL;
00444                 }
00445                 else if ( ERROR_FILE_NOT_FOUND == dwError )
00446                 {
00447                     //
00448                     // This is ok, but we need to remember that the
00449                     // combination of wcTemp[0] == 0 && fAppendOnly means
00450                     // don't try to register the class.
00451                     //
00452
00453                     wcTemp[0] = 0;
00454                     dwError = ERROR_SUCCESS;
00455                 }
00456             }
00457
00458             if ( fSetValue && !fAppendOnly )
00459             {
00460                 dwError = RegSetValueExW( hKey,                        // Key
00461                                           0,                           // Name
00462                                           0,                           // Reserved
00463                                           REG_SZ,                      // Type
00464                                           (BYTE *)Class.pwszShortName, // Value
00465                                           (DWORD) ( (1 + wcslen(Class.pwszShortName) ) * sizeof(WCHAR) ) );
00466
00467                 wcTemp[0] = 0;
00468             }
00469
00470             if ( ERROR_SUCCESS != dwError )
00471                 break;
00472
00473             //
00474             // Write the persistent handler key
00475             //
00476
00477             HKEY hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00478
00479             dwError = RegCreateKeyExW( hKey,                 // Root
00480                                        L"PersistentHandler", // Sub key
00481                                        0,                    // Reserved
00482                                        0,                    // Class
00483                                        0,                    // Flags
00484                                        KEY_ALL_ACCESS,       // Access
00485                                        0,                    // Security
00486                                        &hKey2,               // Handle
00487                                        &dwDisposition );     // Disposition
00488
00489             if ( ERROR_SUCCESS != dwError )
00490                 break;
00491
00492             if ( fBlastExistingPersistentHandler ||
00493                  ( REG_OPENED_EXISTING_KEY != dwDisposition ) )
00494                 dwError = RegSetValueExW( hKey2,                 // Key
00495                                           0,                     // Name
00496                                           0,                     // Reserved
00497                                           REG_SZ,                // Type
00498                                           (BYTE *)pwszPHandler,  // Value
00499                                           (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00500
00501             if ( (HKEY)INVALID_HANDLE_VALUE != hKey2 )
00502             {
00503                 RegCloseKey( hKey2 );
00504                 hKey2 = (HKEY)INVALID_HANDLE_VALUE;
00505             }
00506         }
00507
00508         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00509         {
00510             RegCloseKey( hKey );
00511             hKey = (HKEY)INVALID_HANDLE_VALUE;
00512         }
00513
00514         if ( ERROR_SUCCESS != dwError )
00515             break;
00516
00517         //
00518         // Here, wcTemp may contain the key name for the named entry (ex: Word.Document.8)
00519         //
00520
00521         if ( wcTemp[0] != 0 || !fAppendOnly )
00522             dwError = RegisterAClass( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00523
00524     } while( FALSE );
00525
00526     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00527     {
00528         RegCloseKey( hKey );
00529         hKey = (HKEY)INVALID_HANDLE_VALUE;
00530     }
00531
00532     return dwError;
00533 }
00534
00535 //+---------------------------------------------------------------------------
00536 //
00537 //  Function:   RegisterAClass, private
00538 //
00539 //  Synopsis:   Registers a class and a persistent handler.
00540 //
00541 //  Arguments:  [Class]        -- Class description
00542 //              [pwszPHandler] -- Persistent handler for class
00543 //              [pwszClass]    -- If non 0, used instead of class from [Class]
00544 //
00545 //  Returns:    ERROR_SUCCESS on success
00546 //
00547 //  Notes:      Class is only registered if similar class does not already
00548 //              exist.  Persistent handler is always registered for class.
00549 //
00550 //----------------------------------------------------------------------------
00551
00552 inline long RegisterAClass( SClassEntry const & Class,
00553                             WCHAR const * pwszPHandler,
00554                             WCHAR const * pwszShortName,
00555                             BOOL fAppendOnly )
00556 {
00557     WCHAR wcTemp[MAX_PATH];
00558
00559     long dwError;
00560     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00561
00562     if ( 0 == pwszShortName )
00563     {
00564         if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00565             return ERROR_INSUFFICIENT_BUFFER;
00566
00567         wcscpy( wcTemp, Class.pwszShortName );
00568     }
00569     else
00570     {
00571         if ( wcslen( pwszShortName ) >= MAX_PATH )
00572             return ERROR_INSUFFICIENT_BUFFER;
00573
00574         wcscpy( wcTemp, pwszShortName );
00575     }
00576
00577     do
00578     {
00579         DWORD dwDisposition;
00580         DWORD dwType;
00581         DWORD dwSize;
00582
00583         //
00584         // Here, wcTemp contains the key name for the named entry (ex: Word.Document.8)
00585         //
00586
00587         if ( fAppendOnly )
00588         {
00589             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00590                                      wcTemp,               // Sub key
00591                                      0,                    // Reserved
00592                                      KEY_ALL_ACCESS,       // Access
00593                                      &hKey );              // Handle
00594
00595             if ( ERROR_SUCCESS != dwError)
00596             {
00597                 //
00598                 // Not opening the key at all is legit.
00599                 //
00600
00601                 if ( ERROR_FILE_NOT_FOUND == dwError )
00602                     dwError = ERROR_SUCCESS;
00603
00604                 break;
00605             }
00606
00607             dwDisposition = REG_OPENED_EXISTING_KEY;
00608         }
00609         else
00610         {
00611             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00612                                        wcTemp,               // Sub key
00613                                        0,                    // Reserved
00614                                        0,                    // Class
00615                                        0,                    // Flags
00616                                        KEY_ALL_ACCESS,       // Access
00617                                        0,                    // Security
00618                                        &hKey,                // Handle
00619                                        &dwDisposition );     // Disposition
00620
00621             if ( ERROR_SUCCESS != dwError )
00622                 break;
00623         }
00624
00625         //
00626         // If needed, write the description, but only for non-overrides.
00627         //
00628
00629         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszShortName )
00630         {
00631             dwError = RegSetValueExW( hKey,                          // Key
00632                                       0,                             // Name
00633                                       0,                             // Reserved
00634                                       REG_SZ,                        // Type
00635                                       (BYTE *)Class.pwszDescription, // Value
00636                                       (DWORD) ( (1 + wcslen(Class.pwszDescription) ) * sizeof(WCHAR) ) );
00637
00638             if ( wcslen( Class.pwszShortName ) >= MAX_PATH )
00639                 return ERROR_INSUFFICIENT_BUFFER;
00640
00641             wcscpy( wcTemp, Class.pwszShortName );
00642
00643             if ( ERROR_SUCCESS != dwError )
00644                 break;
00645         }
00646
00647         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00648         {
00649             RegCloseKey( hKey );
00650             hKey = (HKEY)INVALID_HANDLE_VALUE;
00651         }
00652
00653         //
00654         // Write or read ClassId
00655         //
00656
00657         wcscat( wcTemp, L"\\CLSID" );
00658
00659         if ( fAppendOnly )
00660         {
00661             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00662                                      wcTemp,               // Sub key
00663                                      0,                    // Reserved
00664                                      KEY_ALL_ACCESS,       // Access
00665                                      &hKey );              // Handle
00666
00667             if ( ERROR_SUCCESS != dwError)
00668             {
00669                 //
00670                 // Not opening the key at all is legit.
00671                 //
00672
00673                 if ( ERROR_FILE_NOT_FOUND == dwError )
00674                     dwError = ERROR_SUCCESS;
00675
00676                 break;
00677             }
00678
00679             dwDisposition = REG_OPENED_EXISTING_KEY;
00680         }
00681         else
00682         {
00683             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00684                                        wcTemp,               // Sub key
00685                                        0,                    // Reserved
00686                                        0,                    // Class
00687                                        0,                    // Flags
00688                                        KEY_ALL_ACCESS,       // Access
00689                                        0,                    // Security
00690                                        &hKey,                // Handle
00691                                        &dwDisposition );     // Disposition
00692
00693             if ( ERROR_SUCCESS != dwError )
00694                 break;
00695         }
00696
00697         dwSize = sizeof(wcTemp);
00698
00699         dwError = RegQueryValueExW( hKey,                // Key handle
00700                                     0,                   // Name
00701                                     0,                   // Reserved
00702                                     &dwType,             // Datatype
00703                                     (BYTE *)(wcTemp),    // Data returned here
00704                                     &dwSize );           // Size of data
00705
00706         if ( ERROR_SUCCESS != dwError )
00707         {
00708             if ( ERROR_FILE_NOT_FOUND == dwError )
00709             {
00710                 //
00711                 // Don't set a class id in append mode.
00712                 //
00713
00714                 if ( fAppendOnly )
00715                 {
00716                     dwError = ERROR_SUCCESS;
00717                     break;
00718                 }
00719
00720                 dwError = RegSetValueExW( hKey,                          // Key
00721                                           0,                             // Name
00722                                           0,                             // Reserved
00723                                           REG_SZ,                        // Type
00724                                           (BYTE *)Class.pwszClassId,     // Value
00725                                           (DWORD) ( (1 + wcslen(Class.pwszClassId) ) * sizeof(WCHAR) ) );
00726
00727                 wcTemp[0] = 0; // Default to class from Class structure
00728
00729                 if ( ERROR_SUCCESS != dwError )
00730                     break;
00731             }
00732             else
00733                 break;
00734         }
00735         else
00736         {
00737             if ( REG_SZ != dwType )
00738                 dwError = E_FAIL;
00739         }
00740
00741         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00742         {
00743             RegCloseKey( hKey );
00744             hKey = (HKEY)INVALID_HANDLE_VALUE;
00745         }
00746
00747         if ( ERROR_SUCCESS != dwError )
00748             break;
00749
00750         //
00751         // Here, wcTemp contains the {class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00752         //
00753
00754         dwError = RegisterACLSID( Class, pwszPHandler, (0 == wcTemp[0]) ? 0 : wcTemp, fAppendOnly );
00755
00756     } while( FALSE );
00757
00758     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00759     {
00760         RegCloseKey( hKey );
00761         hKey = (HKEY)INVALID_HANDLE_VALUE;
00762     }
00763
00764     return dwError;
00765 }
00766
00767 //+---------------------------------------------------------------------------
00768 //
00769 //  Function:   RegisterACLSID, private
00770 //
00771 //  Synopsis:   Registers a CLSID / persistent handler.
00772 //
00773 //  Arguments:  [Class]        -- Class description
00774 //              [pwszPHandler] -- Persistent handler for class
00775 //              [pwszClassId]  -- If non 0, used instead of class id from [Class]
00776 //              [fAppendOnly]  -- TRUE --> CLSID should not be created
00777 //              [fAppendDesc]  -- TRUE --> Class description should be added.
00778 //                                         Only applies if [fAppendOnly] is FALSE
00779 //
00780 //  Returns:    ERROR_SUCCESS on success
00781 //
00782 //  Notes:      Class id is only registered if similar class does not already
00783 //              exist.  Persistent handler is always registered for class.
00784 //
00785 //----------------------------------------------------------------------------
00786
00787 inline long RegisterACLSID( SClassEntry const & Class,
00788                             WCHAR const * pwszPHandler,
00789                             WCHAR const * pwszClassId,
00790                             BOOL fAppendOnly,
00791                             BOOL fAppendDesc )
00792 {
00793     WCHAR wcTemp[MAX_PATH];
00794
00795     long dwError;
00796     HKEY  hKey = (HKEY)INVALID_HANDLE_VALUE;
00797
00798     wcscpy( wcTemp, L"CLSID\\" );
00799
00800     if ( 0 == pwszClassId )
00801         wcscat( wcTemp, Class.pwszClassId );
00802     else
00803         wcscat( wcTemp, pwszClassId );
00804
00805     do
00806     {
00807         DWORD dwDisposition;
00808
00809         //
00810         // Here, wcTemp contains the CLSID\{class id} (ex: CLSID\{00020906-0000-0000-C000-000000000046})
00811         //
00812
00813         if ( fAppendOnly )
00814         {
00815             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00816                                      wcTemp,               // Sub key
00817                                      0,                    // Reserved
00818                                      KEY_ALL_ACCESS,       // Access
00819                                      &hKey );              // Handle
00820
00821             if ( ERROR_SUCCESS != dwError)
00822             {
00823                 //
00824                 // Not opening the key at all is legit.
00825                 //
00826
00827                 if ( ERROR_FILE_NOT_FOUND == dwError )
00828                     dwError = ERROR_SUCCESS;
00829
00830                 break;
00831             }
00832
00833             dwDisposition = REG_OPENED_EXISTING_KEY;
00834         }
00835         else
00836         {
00837             dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00838                                        wcTemp,               // Sub key
00839                                        0,                    // Reserved
00840                                        0,                    // Class
00841                                        0,                    // Flags
00842                                        KEY_ALL_ACCESS,       // Access
00843                                        0,                    // Security
00844                                        &hKey,                // Handle
00845                                        &dwDisposition );     // Disposition
00846         }
00847
00848         if ( ERROR_SUCCESS != dwError )
00849             break;
00850
00851         //
00852         // If needed, write the description, but not for override class.
00853         //
00854
00855         if ( REG_CREATED_NEW_KEY == dwDisposition && 0 == pwszClassId && fAppendDesc )
00856         {
00857             dwError = RegSetValueExW( hKey,                                 // Key
00858                                       0,                                    // Name
00859                                       0,                                    // Reserved
00860                                       REG_SZ,                               // Type
00861                                       (BYTE *)Class.pwszClassIdDescription, // Value
00862                                       (DWORD) ( (1 + wcslen(Class.pwszClassIdDescription) ) * sizeof(WCHAR) ) );
00863
00864             if ( ERROR_SUCCESS != dwError )
00865                 break;
00866         }
00867
00868         if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00869         {
00870             RegCloseKey( hKey );
00871             hKey = (HKEY)INVALID_HANDLE_VALUE;
00872         }
00873
00874         //
00875         // Always write persistent handler.
00876         //
00877
00878         wcscat( wcTemp, L"\\PersistentHandler" );
00879
00880         dwError = RegCreateKeyExW( HKEY_CLASSES_ROOT,    // Root
00881                                    wcTemp,               // Sub key
00882                                    0,                    // Reserved
00883                                    0,                    // Class
00884                                    0,                    // Flags
00885                                    KEY_ALL_ACCESS,       // Access
00886                                    0,                    // Security
00887                                    &hKey,                // Handle
00888                                    &dwDisposition );     // Disposition
00889
00890         if ( ERROR_SUCCESS != dwError )
00891             break;
00892
00893         dwError = RegSetValueExW( hKey,                  // Key
00894                                   0,                     // Name
00895                                   0,                     // Reserved
00896                                   REG_SZ,                // Type
00897                                   (BYTE *)pwszPHandler,  // Value
00898                                   (DWORD) ( (1 + wcslen(pwszPHandler) ) * sizeof(WCHAR) ) );
00899
00900     } while( FALSE );
00901
00902     if ( (HKEY)INVALID_HANDLE_VALUE != hKey )
00903     {
00904         RegCloseKey( hKey );
00905         hKey = (HKEY)INVALID_HANDLE_VALUE;
00906     }
00907
00908     return dwError;
00909 }
00910
00911 //+---------------------------------------------------------------------------
00912 //
00913 //  Function:   RemoveAClassName, private
00914 //
00915 //  Synopsis:   Removes all references to class name (ex: Word.Document.8)
00916 //
00917 //  Arguments:  [pwszClass] -- Class Name
00918 //
00919 //  Returns:    ERROR_SUCCESS on success
00920 //
00921 //----------------------------------------------------------------------------
00922
00923 inline long RemoveAClassName( WCHAR * pwszClass )
00924 {
00925     //
00926     // First, delete class name entry.
00927     //
00928
00929     long dwEnum = ERROR_SUCCESS;    // The enumerator
00930     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
00931
00932     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
00933
00934     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00935                                   0,                    // Sub key
00936                                   0,                    // Reserved
00937                                   KEY_ALL_ACCESS,       // Access
00938                                   &hKeyEnum );          // Handle
00939
00940
00941     if ( ERROR_SUCCESS == dwError )
00942     {
00943         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClass );
00944
00945         //
00946         // Now enumerate all classes entries, looking for the clsid
00947         //
00948
00949         DWORD dwIndex = 0;
00950
00951         while ( ERROR_SUCCESS == dwEnum )
00952         {
00953             WCHAR wcTemp[MAX_PATH];
00954             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
00955             FILETIME ftUnused;
00956
00957             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
00958                                     dwIndex,                // Index of registry subkey
00959                                     wcTemp,                 // Buffer for name
00960                                     &dwSize,                // Size of buffer / key
00961                                     0,                      // Reserved
00962                                     0,                      // Class (unused)
00963                                     0,                      // Class size (unused)
00964                                     &ftUnused );            // Filetime (unused)
00965
00966             dwIndex++;
00967
00968             if ( ERROR_SUCCESS == dwEnum )
00969             {
00970                 HKEY hKey;
00971
00972                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
00973                                          wcTemp,               // Sub key
00974                                          0,                    // Reserved
00975                                          KEY_ALL_ACCESS,       // Access
00976                                          &hKey );              // Handle
00977
00978                 if ( ERROR_SUCCESS == dwError )
00979                 {
00980                     WCHAR wcTemp2[MAX_PATH];
00981                     DWORD dwType;
00982
00983                     dwSize = sizeof(wcTemp2);
00984
00985                     dwError = RegQueryValueExW( hKey,                // Key handle
00986                                                 0,                   // Name
00987                                                 0,                   // Reserved
00988                                                 &dwType,             // Datatype
00989                                                 (BYTE *)wcTemp2,     // Data returned here
00990                                                 &dwSize );           // Size of data
00991
00992                     RegCloseKey( hKey );
00993
00994                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClass ) )
00995                     {
00996                         //
00997                         // Always delete the value
00998                         //
00999
01000                         if ( ERROR_SUCCESS == dwIgnore )
01001                             dwIgnore = RegDeleteValueW( hKey, 0 );
01002                         else
01003                             RegDeleteValueW( hKey, 0 );
01004
01005                         //
01006                         // Any other key(s)?
01007                         //
01008
01009                         dwSize = sizeof(wcTemp) / sizeof wcTemp[0];
01010
01011                         DWORD dw2 = RegEnumKeyExW( hKey,                   // Handle of key
01012                                                    0,                      // Index of registry subkey
01013                                                    wcTemp,                 // Buffer for name
01014                                                    &dwSize,                // Size of buffer / key
01015                                                    0,                      // Reserved
01016                                                    0,                      // Class (unused)
01017                                                    0,                      // Class size (unused)
01018                                                    &ftUnused );            // Filetime (unused)
01019
01020                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01021                         {
01022                             if ( ERROR_SUCCESS == dwIgnore )
01023                                 dwIgnore = RegDeleteKeyW( hKeyEnum, wcTemp );
01024                             else
01025                                 RegDeleteKeyW( hKeyEnum, wcTemp );
01026
01027                             dwIndex = 0;
01028                         }
01029
01030                     }
01031                     else
01032                         dwError = ERROR_SUCCESS;  // Just didn't have a null key (or no match)
01033                 }
01034             }
01035         }
01036     }
01037
01038     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01039         dwError = dwEnum;
01040
01041     if ( ERROR_SUCCESS != dwError )
01042         return dwError;
01043     else
01044         return dwIgnore;
01045 }
01046
01047 //+---------------------------------------------------------------------------
01048 //
01049 //  Function:   RemoveAClass, private
01050 //
01051 //  Synopsis:   Removes all references to class
01052 //
01053 //  Arguments:  [pwszClass] -- Class
01054 //
01055 //  Returns:    ERROR_SUCCESS on success
01056 //
01057 //----------------------------------------------------------------------------
01058
01059 inline long RemoveAClass( WCHAR * pwszClassId )
01060 {
01061     //
01062     // First, delete class entry.
01063     //
01064
01065     long dwIgnore = ERROR_SUCCESS;  // For non-fatal errors
01066     long dwEnum = ERROR_SUCCESS;    // For enumerator
01067
01068     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01069
01070     long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01071                                   L"CLSID",             // Sub key
01072                                   0,                    // Reserved
01073                                   KEY_ALL_ACCESS,       // Access
01074                                   &hKeyEnum );          // Handle
01075
01076     if ( ERROR_SUCCESS == dwError )
01077     {
01078         dwIgnore = RegDeleteKeyW( hKeyEnum, pwszClassId );
01079
01080         RegCloseKey( hKeyEnum );
01081
01082         long dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01083                                       0,                    // Sub key
01084                                       0,                    // Reserved
01085                                       KEY_ALL_ACCESS,       // Access
01086                                       &hKeyEnum );          // Handle
01087     }
01088
01089     if ( ERROR_SUCCESS == dwError )
01090     {
01091         //
01092         // Now enumerate all classes entries, looking for the clsid
01093         //
01094
01095         DWORD dwIndex = 0;
01096
01097         while ( ERROR_SUCCESS == dwEnum )
01098         {
01099             WCHAR wcTemp[MAX_PATH];
01100             DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01101             FILETIME ftUnused;
01102
01103             dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01104                                     dwIndex,                // Index of registry subkey
01105                                     wcTemp,                 // Buffer for name
01106                                     &dwSize,                // Size of buffer / key
01107                                     0,                      // Reserved
01108                                     0,                      // Class (unused)
01109                                     0,                      // Class size (unused)
01110                                     &ftUnused );            // Filetime (unused)
01111
01112             dwIndex++;
01113
01114             if ( ERROR_SUCCESS == dwEnum )
01115             {
01116                 wcscat( wcTemp, L"\\CLSID" );
01117
01118                 HKEY hKey;
01119
01120                 dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01121                                          wcTemp,               // Sub key
01122                                          0,                    // Reserved
01123                                          KEY_ALL_ACCESS,       // Access
01124                                          &hKey );              // Handle
01125
01126                 if ( ERROR_SUCCESS == dwError )
01127                 {
01128                     WCHAR wcTemp2[MAX_PATH];
01129                     DWORD dwType;
01130
01131                     dwSize = sizeof(wcTemp2);
01132
01133                     dwError = RegQueryValueExW( hKey,                // Key handle
01134                                                 0,                   // Name
01135                                                 0,                   // Reserved
01136                                                 &dwType,             // Datatype
01137                                                 (BYTE *)wcTemp2,     // Data returned here
01138                                                 &dwSize );           // Size of data
01139
01140                     RegCloseKey( hKey );
01141
01142                     if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, pwszClassId ) )
01143                     {
01144                         wcTemp[ wcslen(wcTemp) - wcslen( L"\\CLSID" ) ] = 0;
01145
01146                         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01147                                                  wcTemp,               // Sub key
01148                                                  0,                    // Reserved
01149                                                  KEY_ALL_ACCESS,       // Access
01150                                                  &hKey );              // Handle
01151
01152                         if ( ERROR_SUCCESS == dwError )
01153                         {
01154                             if ( ERROR_SUCCESS == dwIgnore )
01155                                 dwIgnore = RegDeleteKeyW( hKey, L"CLSID" );
01156                             else
01157                                 RegDeleteKeyW( hKey, L"CLSID" );
01158
01159                             dwIndex = 0;
01160                         }
01161
01162                         //
01163                         // If there are no more entries, then the class name can be deleted
01164                         //
01165
01166                         dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]);
01167
01168                         long dw2 = RegEnumKeyExW( hKey,               // Handle of key
01169                                                   0,                  // Index of registry subkey
01170                                                   wcTemp,             // Buffer for name
01171                                                   &dwSize,            // Size of buffer / key
01172                                                   0,                  // Reserved
01173                                                   0,                  // Class (unused)
01174                                                   0,                  // Class size (unused)
01175                                                   &ftUnused );        // Filetime (unused)
01176
01177                         RegCloseKey( hKey );
01178
01179                         if ( ERROR_NO_MORE_ITEMS == dw2 )
01180                             RemoveAClassName( wcTemp );
01181                     }
01182                 }
01183                 else
01184                     dwError = ERROR_SUCCESS;  // Just didn't have CLSID
01185             }
01186         }
01187     }
01188
01189     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01190         dwError = dwEnum;
01191
01192     if ( ERROR_SUCCESS != dwError )
01193         return dwError;
01194     else
01195         return dwIgnore;
01196 }
01197
01198 //+---------------------------------------------------------------------------
01199 //
01200 //  Function:   RegisterAHandler, private
01201 //
01202 //  Synopsis:   Registers a persistent handler in registry
01203 //
01204 //  Arguments:  [Handler] -- Persistent handler
01205 //
01206 //  Returns:    ERROR_SUCCESS on success
01207 //
01208 //----------------------------------------------------------------------------
01209
01210 inline long RegisterAHandler( SHandlerEntry const & Handler )
01211 {
01212     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01213                                     Handler.pwszClassIdDescription,
01214                                     L"PersistentAddinsRegistered",
01215                                     0,
01216                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01217                                     Handler.pwszClassIdFilter };
01218
01219     return BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01220 }
01221
01222 //+---------------------------------------------------------------------------
01223 //
01224 //  Function:   RegisterAFilter, private
01225 //
01226 //  Synopsis:   Registers a filter in registry
01227 //
01228 //  Arguments:  [Filter] -- IFilter implementation
01229 //
01230 //  Returns:    ERROR_SUCCESS on success
01231 //
01232 //----------------------------------------------------------------------------
01233
01234 inline long RegisterAFilter( SFilterEntry const & Filter )
01235 {
01236     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01237                                     Filter.pwszClassIdDescription,
01238                                     L"InprocServer32",
01239                                     Filter.pwszDLL };
01240
01241     long retVal = BuildKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01242     if ( ERROR_SUCCESS == retVal )
01243         retVal = AddThreadingModel( Filter.pwszClassId, Filter.pwszThreadingModel );
01244
01245     return retVal;
01246 }
01247
01248 //+---------------------------------------------------------------------------
01249 //
01250 //  Function:   UnRegisterAHandler, private
01251 //
01252 //  Synopsis:   Unregisters a persistent handler, including class entries.
01253 //
01254 //  Arguments:  [Handler] -- Persistent handler
01255 //
01256 //  Returns:    ERROR_SUCCESS on success
01257 //
01258 //----------------------------------------------------------------------------
01259
01260 inline long UnRegisterAHandler( SHandlerEntry const & Handler )
01261 {
01262     WCHAR const * aKeyValues[6] = { Handler.pwszClassId,
01263                                     Handler.pwszClassIdDescription,
01264                                     L"PersistentAddinsRegistered",
01265                                     0,
01266                                     L"{89BCB740-6119-101A-BCB7-00DD010655AF}",  // IID_IFilter
01267                                     Handler.pwszClassIdFilter };
01268
01269     //
01270     // dwIgnore is used to record non-fatal errors
01271     //
01272
01273     long dwIgnore = DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01274     long dwError = ERROR_SUCCESS;
01275
01276     //
01277     // Now, enumerate all classes and delete any persistent handler entries.
01278     //
01279
01280     HKEY hKeyEnum = (HKEY)INVALID_HANDLE_VALUE;
01281
01282     long dwEnum = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01283                                  L"CLSID",              // Sub key
01284                                  0,                    // Reserved
01285                                  KEY_ALL_ACCESS,       // Access
01286                                  &hKeyEnum );          // Handle
01287
01288     DWORD dwIndex = 0;
01289
01290     while ( ERROR_SUCCESS == dwEnum )
01291     {
01292         WCHAR wcTemp[MAX_PATH];
01293
01294         wcscpy( wcTemp, L"CLSID\\" );
01295         unsigned cc = (unsigned) wcslen( wcTemp );
01296
01297         DWORD dwSize = sizeof(wcTemp)/sizeof(wcTemp[0]) - cc;
01298         FILETIME ftUnused;
01299
01300         dwEnum = RegEnumKeyExW( hKeyEnum,               // Handle of key
01301                                 dwIndex,                // Index of registry subkey
01302                                 wcTemp + cc,            // Buffer for name
01303                                 &dwSize,                // Size of buffer / key
01304                                 0,                      // Reserved
01305                                 0,                      // Class (unused)
01306                                 0,                      // Class size (unused)
01307                                 &ftUnused );            // Filetime (unused)
01308
01309         dwIndex++;
01310
01311         //
01312         // Does the key have a persistent handler?
01313         //
01314
01315         if ( ERROR_SUCCESS == dwEnum )
01316         {
01317             wcscat( wcTemp, L"\\PersistentHandler" );
01318
01319             HKEY hKey;
01320
01321             dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01322                                      wcTemp,               // Sub key
01323                                      0,                    // Reserved
01324                                      KEY_ALL_ACCESS,       // Access
01325                                      &hKey );              // Handle
01326
01327             if ( ERROR_SUCCESS == dwError )
01328             {
01329                 //
01330                 // Is this the persistent handler we're looking for?
01331                 //
01332
01333                 WCHAR wcTemp2[MAX_PATH];
01334                 DWORD dwType;
01335
01336                 dwSize = sizeof(wcTemp2);
01337
01338                 dwError = RegQueryValueExW( hKey,                // Key handle
01339                                             0,                   // Name
01340                                             0,                   // Reserved
01341                                             &dwType,             // Datatype
01342                                             (BYTE *)wcTemp2,     // Data returned here
01343                                             &dwSize );           // Size of data
01344
01345                 RegCloseKey( hKey );
01346
01347                 if ( ERROR_SUCCESS == dwError && 0 == _wcsicmp( wcTemp2, Handler.pwszClassId ) )
01348                 {
01349                     wcTemp[ wcslen(wcTemp) - wcslen( L"\\PersistentHandler" ) ] = 0;
01350
01351                     dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01352                                              wcTemp,               // Sub key
01353                                              0,                    // Reserved
01354                                              KEY_ALL_ACCESS,       // Access
01355                                              &hKey );              // Handle
01356
01357                     if ( ERROR_SUCCESS == dwError )
01358                     {
01359                         if ( ERROR_SUCCESS == dwIgnore )
01360                             dwIgnore = RegDeleteKeyW( hKey, L"PersistentHandler" );
01361                         else
01362                             RegDeleteKeyW( hKey, L"PersistentHandler" );
01363
01364                         dwIndex = 0; // Start over again
01365                     }
01366
01367                     //
01368                     // If that was the *only* entry under the clsid, then the class can be
01369                     // removed.
01370                     //
01371
01372                     dwSize = sizeof(wcTemp2)/sizeof(wcTemp2[0]);
01373
01374                     long dw2 = RegEnumKeyExW( hKey,             // Handle of key
01375                                               0,                // Index of registry subkey
01376                                               wcTemp2,          // Buffer for name
01377                                               &dwSize,          // Size of buffer / key
01378                                               0,                // Reserved
01379                                               0,                // Class (unused)
01380                                               0,                // Class size (unused)
01381                                               &ftUnused );      // Filetime (unused)
01382
01383                     RegCloseKey( hKey );
01384
01385                     if ( ERROR_NO_MORE_ITEMS == dw2 )
01386                         RemoveAClass( wcTemp + wcslen( L"CLSID\\" ) );
01387                 }
01388                 else
01389                 {
01390                     //
01391                     // Didn't have persistent handler null key.  Odd but not fatal.
01392                     // Or, key didn't match target.
01393                     //
01394
01395                     dwIgnore = dwError;
01396                     dwError = ERROR_SUCCESS;
01397                 }
01398
01399             }
01400             else
01401                 dwError = ERROR_SUCCESS;  // Just didn't have persistent handler
01402         }
01403     }
01404
01405     if ( (HKEY)INVALID_HANDLE_VALUE != hKeyEnum )
01406         RegCloseKey( hKeyEnum );
01407
01408     if ( ERROR_NO_MORE_ITEMS != dwEnum )
01409         dwError = dwEnum;
01410
01411     if ( ERROR_SUCCESS != dwError )
01412         return dwError;
01413     else
01414         return dwIgnore;
01415 }
01416
01417 //+---------------------------------------------------------------------------
01418 //
01419 //  Function:   UnRegisterAnExt, private
01420 //
01421 //  Synopsis:   Unregisters a filter extension
01422 //
01423 //  Arguments:  [Class] -- Class description to unregister
01424 //
01425 //  Returns:    ERROR_SUCCESS on success
01426 //
01427 //----------------------------------------------------------------------------
01428
01429 inline long UnRegisterAnExt( SClassEntry const & Class )
01430 {
01431     HKEY hKey = (HKEY)INVALID_HANDLE_VALUE;
01432     DWORD dwError;
01433
01434     do
01435     {
01436         dwError = RegOpenKeyExW( HKEY_CLASSES_ROOT,    // Root
01437                                  Class.pwszExt,        // Sub key -- "CLSID"
01438                                  0,                    // Reserved
01439                                  KEY_ALL_ACCESS,       // Access
01440                                  &hKey );              // Handle
01441
01442         if ( ERROR_SUCCESS != dwError )
01443             break;
01444
01445         dwError = RegDeleteKeyW( hKey, L"PersistentHandler" );
01446
01447     } while ( FALSE );
01448
01449     if ( INVALID_HANDLE_VALUE != hKey )
01450     {
01451         RegCloseKey( hKey );
01452         hKey = (HKEY)INVALID_HANDLE_VALUE;
01453     }
01454
01455     return dwError;
01456 }
01457
01458 //+---------------------------------------------------------------------------
01459 //
01460 //  Function:   UnRegisterAFilter, private
01461 //
01462 //  Synopsis:   Unregisters a filter
01463 //
01464 //  Arguments:  [Filter] -- IFilter implementation
01465 //
01466 //  Returns:    ERROR_SUCCESS on success
01467 //
01468 //----------------------------------------------------------------------------
01469
01470 inline long UnRegisterAFilter( SFilterEntry const & Filter )
01471 {
01472     WCHAR const * aKeyValues[4] = { Filter.pwszClassId,
01473                                     Filter.pwszClassIdDescription,
01474                                     L"InprocServer32",
01475                                     Filter.pwszDLL };
01476
01477     return DestroyKeyValues( aKeyValues, sizeof(aKeyValues)/sizeof(aKeyValues[0]) );
01478 }
01479
01480 //+---------------------------------------------------------------------------
01481 //
01482 //  Function:   DllUnregisterServer
01483 //
01484 //  Synopsis:   Self-unregistration
01485 //
01486 //----------------------------------------------------------------------------
01487
01488 //+---------------------------------------------------------------------------
01489 //
01490 //  Function:   DllRegisterServer
01491 //
01492 //  Synopsis:   Self-registration
01493 //
01494 //  Notes:      There are two versions here.  Version 1 registers only
01495 //              extensions.  Version 2 registers extensions and
01496 //              [nameless] Class IDs.
01497 //
01498 //----------------------------------------------------------------------------
01499
01500 #define DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, fBlastExistingPersistentHandler )  \
01501                                                                \
01502 STDAPI Name##UnregisterServer()                                \
01503 {                                                              \
01504     /*                                                         \
01505      * Always remove Persistent Handler and Filter entries     \
01506      */                                                        \
01507                                                                \
01508     long dwError = UnRegisterAHandler( Handler );              \
01509                                                                \
01510     if ( ERROR_SUCCESS == dwError )                            \
01511         dwError = UnRegisterAFilter( Filter );                 \
01512     else                                                       \
01513         UnRegisterAFilter( Filter );                           \
01514                                                                \
01515     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01516     {                                                          \
01517         if ( ERROR_SUCCESS == dwError )                        \
01518             dwError = UnRegisterAnExt( aClasses[i] );          \
01519         else                                                   \
01520              UnRegisterAnExt( aClasses[i] );                   \
01521     }                                                          \
01522                                                                \
01523     if ( ERROR_SUCCESS == dwError )                            \
01524         return S_OK;                                           \
01525     else                                                       \
01526         return S_FALSE;                                        \
01527 }                                                              \
01528                                                                \
01529 STDAPI Name##RegisterServer()                                  \
01530 {                                                              \
01531     /*                                                         \
01532      * Always create Persistent Handler and Filter entries     \
01533      */                                                        \
01534                                                                \
01535     long dwError = RegisterAHandler( Handler );                \
01536                                                                \
01537     /*                                                         \
01538      * First, register the CLSID and persistent handler,       \
01539      * then work back to the class description and the         \
01540      * extension. This ensures we cover all possible           \
01541      * mappings.                                               \
01542      *                                                         \
01543      */                                                        \
01544                                                                \
01545     OSVERSIONINFO Version;                                     \
01546     Version.dwOSVersionInfoSize = sizeof(Version);             \
01547                                                                \
01548     BOOL fAppendOnly = FALSE;                                  \
01549                                                                \
01550     if ( GetVersionEx( &Version ) &&                           \
01551          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01552          Version.dwMajorVersion >= 5 )                         \
01553     {                                                          \
01554         fAppendOnly = TRUE;                                    \
01555     }                                                          \
01556                                                                \
01557     if ( ERROR_SUCCESS == dwError )                            \
01558         dwError = RegisterAFilter( Filter );                   \
01559                                                                \
01560     if ( ERROR_SUCCESS == dwError )                            \
01561         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01562             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01563                                                                \
01564     if ( ERROR_SUCCESS == dwError )                            \
01565         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01566             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01567                                                                \
01568     if ( ERROR_SUCCESS == dwError )                            \
01569         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01570             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly, fBlastExistingPersistentHandler );                     \
01571                                                                \
01572     if ( ERROR_SUCCESS == dwError )                            \
01573         return S_OK;                                           \
01574     else                                                       \
01575         return SELFREG_E_CLASS;                                \
01576 }
01577
01578
01579 #define DEFINE_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01580     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, TRUE )  \
01581
01582
01583 #define DEFINE_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01584     DEFINE_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01585
01586 #define DEFINE_SOFT_REGISTERFILTER( Name, Handler, Filter, aClasses )  \
01587     DEFINE_REGISTERFILTERBASE( Name, Handler, Filter, aClasses, FALSE )  \
01588
01589 #define DEFINE_SOFT_DLLREGISTERFILTER( Handler, Filter, aClasses )  \
01590     DEFINE_SOFT_REGISTERFILTER( Dll, Handler, Filter, aClasses )
01591
01592
01593 //
01594 // Version 2 (for NT 4 support where all the extra registry goo is required).
01595 //
01596
01597 #define DEFINE_REGISTERFILTER2( Name, Handler, Filter, aClasses )  \
01598                                                                \
01599 STDAPI Name##UnregisterServer()                                \
01600 {                                                              \
01601     /*                                                         \
01602      * Always remove Persistent Handler and Filter entries     \
01603      */                                                        \
01604                                                                \
01605     long dwError = UnRegisterAHandler( Handler );              \
01606                                                                \
01607     if ( ERROR_SUCCESS == dwError )                            \
01608         dwError = UnRegisterAFilter( Filter );                 \
01609     else                                                       \
01610         UnRegisterAFilter( Filter );                           \
01611                                                                \
01612     for ( unsigned i = 0; i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01613     {                                                          \
01614         if ( ERROR_SUCCESS == dwError )                        \
01615             dwError = UnRegisterAnExt( aClasses[i] );          \
01616         else                                                   \
01617             UnRegisterAnExt( aClasses[i] );                    \
01618     }                                                          \
01619                                                                \
01620     if ( ERROR_SUCCESS == dwError )                            \
01621         return S_OK;                                           \
01622     else                                                       \
01623         return S_FALSE;                                        \
01624 }                                                              \
01625                                                                \
01626 STDAPI Name##RegisterServer()                                  \
01627 {                                                              \
01628     /*                                                         \
01629      * Always create Persistent Handler and Filter entries     \
01630      */                                                        \
01631                                                                \
01632     long dwError = RegisterAHandler( Handler );                \
01633                                                                \
01634     /*                                                         \
01635      * First, register the CLSID and persistent handler,       \
01636      * then work back to the class description and the         \
01637      * extension. This ensures we cover all possible           \
01638      * mappings.                                               \
01639      *                                                         \
01640      */                                                        \
01641                                                                \
01642     OSVERSIONINFO Version;                                     \
01643     Version.dwOSVersionInfoSize = sizeof(Version);             \
01644                                                                \
01645     BOOL fAppendOnly = FALSE;                                  \
01646                                                                \
01647     if ( GetVersionEx( &Version ) &&                           \
01648          Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&      \
01649          Version.dwMajorVersion >= 5 )                         \
01650     {                                                          \
01651         fAppendOnly = TRUE;                                    \
01652     }                                                          \
01653                                                                \
01654     if ( ERROR_SUCCESS == dwError )                            \
01655         dwError = RegisterAFilter( Filter );                   \
01656                                                                \
01657     if ( ERROR_SUCCESS == dwError )                            \
01658         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01659             dwError = RegisterACLSID( aClasses[i], Handler.pwszClassId, 0, FALSE, FALSE );                \
01660                                                                \
01661     if ( ERROR_SUCCESS == dwError )                            \
01662         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01663             dwError = RegisterAClass( aClasses[i], Handler.pwszClassId, 0, fAppendOnly );                        \
01664                                                                \
01665     if ( ERROR_SUCCESS == dwError )                            \
01666         for ( unsigned i = 0; ERROR_SUCCESS == dwError && i < sizeof(aClasses)/sizeof(aClasses[0]); i++ ) \
01667             dwError = RegisterAClassAndExt( aClasses[i], Handler.pwszClassId, fAppendOnly );                     \
01668                                                                \
01669     if ( ERROR_SUCCESS == dwError )                            \
01670         return S_OK;                                           \
01671     else                                                       \
01672         return SELFREG_E_CLASS;                                \
01673 }
01674
01675
01676
01677
01678 #define DEFINE_DLLREGISTERFILTER2( Handler, Filter, aClasses )  \
01679     DEFINE_REGISTERFILTER2( Dll, Handler, Filter, aClasses )
01680
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRTCAVSession Member List

This is the complete list of members for CRTCAVSession, including all inherited members.
CRTCAVSession() | CRTCAVSession |
CRTCSession() | CRTCSession |
CRTCWin class | CRTCAVSession | [friend]
DeliverClient(RTC_CLIENT_EVENT_TYPE enEventType) | CRTCAVSession | [protected, virtual]
DeliverIntensity(RTC_AUDIO_DEVICE enDevice, long lLevel) | CRTCAVSession | [protected, virtual]
DeliverMedia(long lMediaType, RTC_MEDIA_EVENT_TYPE enType, RTC_MEDIA_EVENT_REASON enReason) | CRTCAVSession | [protected, virtual]
DeliverMessage(IRTCParticipant *pParticipant, BSTR bstrContentType, BSTR bstrMessage) | CRTCSession | [protected, virtual]
DeliverParticipantState(IRTCParticipant *pParticipant, RTC_PARTICIPANT_STATE enState) | CRTCSession | [protected, virtual]
DeliverSessionState(RTC_SESSION_STATE enState) | CRTCSession | [protected, virtual]
DeliverUserStatus(IRTCParticipant *pParticipant, RTC_MESSAGING_USER_STATUS enStatus) | CRTCSession | [protected, virtual]
DoMute(RTC_AUDIO_DEVICE enDevice) | CRTCAVSession | [protected]
DoVolume(RTC_AUDIO_DEVICE enDevice, long lVolume) | CRTCAVSession | [protected]
m_enState | CRTCSession | [protected]
m_fShowPrev | CRTCAVSession | [protected]
m_fShowRecv | CRTCAVSession | [protected]
m_hMicLevel | CRTCAVSession | [protected]
m_hMicMute | CRTCAVSession | [protected]
m_hMicText | CRTCAVSession | [protected]
m_hMicVol | CRTCAVSession | [protected]
m_hPrevVideoParent | CRTCAVSession | [protected, static]
m_hRecvVideoParent | CRTCAVSession | [protected, static]
m_hSpkLevel | CRTCAVSession | [protected]
m_hSpkMute | CRTCAVSession | [protected]
m_hSpkText | CRTCAVSession | [protected]
m_hSpkVol | CRTCAVSession | [protected]
m_hStatusBar | CRTCSession | [protected]
m_hWnd | CRTCSession | [protected]
m_lPrevHeight | CRTCAVSession | [protected]
m_lPrevWidth | CRTCAVSession | [protected]
m_lRecvHeight | CRTCAVSession | [protected]
m_lRecvWidth | CRTCAVSession | [protected]
m_pSession | CRTCSession | [protected]
m_pWin | CRTCSession | [protected]
m_Singleton | CRTCAVSession | [protected, static]
OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCSession | [protected, virtual]
OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCAVSession | [protected]
OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCAVSession | [protected, virtual]
OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCAVSession | [protected, virtual]
OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCAVSession | [protected]
OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCAVSession | [protected, virtual]
RegisterClass() | CRTCAVSession | [static]
SetStatusText(PWSTR szText) | CRTCSession | [protected]
ShowAudio() | CRTCAVSession | [protected]
ShowMessageBox(PWSTR szText) | CRTCSession | [protected]
ShowVideo(RTC_VIDEO_DEVICE enDevice, BOOL fShow) | CRTCAVSession | [protected]
WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | CRTCAVSession | [static]
~CRTCAVSession() | CRTCAVSession |
~CRTCSession() | CRTCSession |
Generated on Wed Nov 13 2024 16:57:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

icmpv6_hdr Member List

This is the complete list of members for icmpv6_hdr, including all inherited members.
icmp6_checksum | icmpv6_hdr
icmp6_code | icmpv6_hdr
icmp6_type | icmpv6_hdr
Generated on Wed Nov 13 2024 16:57:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_MEMORY_ALLOC_BLOCK Member List

This is the complete list of members for _MEMORY_ALLOC_BLOCK, including all inherited members.
pNext _MEMORY_ALLOC_BLOCK
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ADOStreamConstruction Member List

This is the complete list of members for msado15::ADOStreamConstruction, including all inherited members.
getStream() | msado15::ADOStreamConstruction |
iid | msado15::ADOStreamConstruction | [static]
setStream(IUnknown ppStm) | msado15::ADOStreamConstruction |
Generated on Wed Nov 13 2024 16:58:11 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi2/TapiComm/TapiInfo.c Source File

  • NetDS
  • Tapi
  • Tapi2
  • TapiComm

TapiInfo.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE: TapiInfo.c
00009 //
00010 //  PURPOSE: Handles all Pretty Printing functions for the TapiComm sample.
00011 //
00012 //  EXPORTED FUNCTIONS:  These functions are for use by other modules.
00013 //
00014 //      All of these pretty print to the debugging output.
00015 //    OutputDebugLineCallback       - Calls FormatLineCallback.
00016 //    OutputDebugLineError          - Calls OutputDebugLineErrorFileLine.
00017 //    OutputDebugLastError          - Calls OutputDebugLineErrorFileLine.
00018 //    OutputDebugPrintf             - Calls wsprintf
00019 //    OutputDebugLineErrorFileLine  - Calls FormatLineError
00020 //    OutputDebugLastErrorFileLine  - Calls FormatLastError
00021 //
00022 //      All of these functions pretty print to a string buffer.
00023 //    FormatLineError               - Prints a LINEERR
00024 //    FormatLastError               - Prints a GetLastError error.
00025 //    FormatLineCallback            - Prints a lineCallbackFunc message.
00026 //
00027 //  INTERNAL FUNCTION:  These functions are for this module only.
00028 //    strBinaryArrayAppend          - prints a binary flag array to a buffer.
00029
00030 #include <windows.h>
00031 #include <tapi.h>
00032 #include "TapiInfo.h"
00033
00034 // Maximum length of all internal string buffers.
00035 #define MAXOUTPUTSTRINGLENGTH 4096
00036
00037 // define to make accessing arrays easy.
00038 #define sizeofArray(pArray) (sizeof(pArray) / sizeof((pArray)[0]))
00039
00040
00041 //*****************************************
00042 // Internal prototypes.
00043 //*****************************************
00044
00045 static long strBinaryArrayAppend(LPSTR pszOutputBuffer, DWORD dwFlags,
00046      LPSTR szStringArray[], DWORD dwSizeofStringArray);
00047
00048
00049
00050 //*****************************************
00051 // Global arrays for interpreting TAPI constants.
00052 //*****************************************
00053
00054 LPSTR pszLineErrorNameArray[] =
00055 {
00056 "",
00057 "LINEERR_ALLOCATED",
00058 "LINEERR_BADDEVICEID",
00059 "LINEERR_BEARERMODEUNAVAIL",
00060 "LINEERR Unused constant, ERROR!!",
00061 "LINEERR_CALLUNAVAIL",
00062 "LINEERR_COMPLETIONOVERRUN",
00063 "LINEERR_CONFERENCEFULL",
00064 "LINEERR_DIALBILLING",
00065 "LINEERR_DIALDIALTONE",
00066 "LINEERR_DIALPROMPT",
00067 "LINEERR_DIALQUIET",
00068 "LINEERR_INCOMPATIBLEAPIVERSION",
00069 "LINEERR_INCOMPATIBLEEXTVERSION",
00070 "LINEERR_INIFILECORRUPT",
00071 "LINEERR_INUSE",
00072 "LINEERR_INVALADDRESS",
00073 "LINEERR_INVALADDRESSID",
00074 "LINEERR_INVALADDRESSMODE",
00075 "LINEERR_INVALADDRESSSTATE",
00076 "LINEERR_INVALAPPHANDLE",
00077 "LINEERR_INVALAPPNAME",
00078 "LINEERR_INVALBEARERMODE",
00079 "LINEERR_INVALCALLCOMPLMODE",
00080 "LINEERR_INVALCALLHANDLE",
00081 "LINEERR_INVALCALLPARAMS",
00082 "LINEERR_INVALCALLPRIVILEGE",
00083 "LINEERR_INVALCALLSELECT",
00084 "LINEERR_INVALCALLSTATE",
00085 "LINEERR_INVALCALLSTATELIST",
00086 "LINEERR_INVALCARD",
00087 "LINEERR_INVALCOMPLETIONID",
00088 "LINEERR_INVALCONFCALLHANDLE",
00089 "LINEERR_INVALCONSULTCALLHANDLE",
00090 "LINEERR_INVALCOUNTRYCODE",
00091 "LINEERR_INVALDEVICECLASS",
00092 "LINEERR_INVALDEVICEHANDLE",
00093 "LINEERR_INVALDIALPARAMS",
00094 "LINEERR_INVALDIGITLIST",
00095 "LINEERR_INVALDIGITMODE",
00096 "LINEERR_INVALDIGITS",
00097 "LINEERR_INVALEXTVERSION",
00098 "LINEERR_INVALGROUPID",
00099 "LINEERR_INVALLINEHANDLE",
00100 "LINEERR_INVALLINESTATE",
00101 "LINEERR_INVALLOCATION",
00102 "LINEERR_INVALMEDIALIST",
00103 "LINEERR_INVALMEDIAMODE",
00104 "LINEERR_INVALMESSAGEID",
00105 "LINEERR Unused constant, ERROR!!",
00106 "LINEERR_INVALPARAM",
00107 "LINEERR_INVALPARKID",
00108 "LINEERR_INVALPARKMODE",
00109 "LINEERR_INVALPOINTER",
00110 "LINEERR_INVALPRIVSELECT",
00111 "LINEERR_INVALRATE",
00112 "LINEERR_INVALREQUESTMODE",
00113 "LINEERR_INVALTERMINALID",
00114 "LINEERR_INVALTERMINALMODE",
00115 "LINEERR_INVALTIMEOUT",
00116 "LINEERR_INVALTONE",
00117 "LINEERR_INVALTONELIST",
00118 "LINEERR_INVALTONEMODE",
00119 "LINEERR_INVALTRANSFERMODE",
00120 "LINEERR_LINEMAPPERFAILED",
00121 "LINEERR_NOCONFERENCE",
00122 "LINEERR_NODEVICE",
00123 "LINEERR_NODRIVER",
00124 "LINEERR_NOMEM",
00125 "LINEERR_NOREQUEST",
00126 "LINEERR_NOTOWNER",
00127 "LINEERR_NOTREGISTERED",
00128 "LINEERR_OPERATIONFAILED",
00129 "LINEERR_OPERATIONUNAVAIL",
00130 "LINEERR_RATEUNAVAIL",
00131 "LINEERR_RESOURCEUNAVAIL",
00132 "LINEERR_REQUESTOVERRUN",
00133 "LINEERR_STRUCTURETOOSMALL",
00134 "LINEERR_TARGETNOTFOUND",
00135 "LINEERR_TARGETSELF",
00136 "LINEERR_UNINITIALIZED",
00137 "LINEERR_USERUSERINFOTOOBIG",
00138 "LINEERR_REINIT",
00139 "LINEERR_ADDRESSBLOCKED",
00140 "LINEERR_BILLINGREJECTED",
00141 "LINEERR_INVALFEATURE",
00142 "LINEERR_NOMULTIPLEINSTANCE"
00143 };
00144
00145
00146 LPSTR psz_dwMsg[] = {
00147     "LINE_ADDRESSSTATE",
00148     "LINE_CALLINFO",
00149     "LINE_CALLSTATE",
00150     "LINE_CLOSE",
00151     "LINE_DEVSPECIFIC",
00152     "LINE_DEVSPECIFICFEATURE",
00153     "LINE_GATHERDIGITS",
00154     "LINE_GENERATE",
00155     "LINE_LINEDEVSTATE",
00156     "LINE_MONITORDIGITS",
00157     "LINE_MONITORMEDIA",
00158     "LINE_MONITORTONE",
00159     "LINE_REPLY",
00160     "LINE_REQUEST",
00161     "PHONE_BUTTON",
00162     "PHONE_CLOSE",
00163     "PHONE_DEVSPECIFIC",
00164     "PHONE_REPLY",
00165     "PHONE_STATE",
00166     "LINE_CREATE",
00167     "PHONE_CREATE"
00168 };
00169
00170
00171 LPSTR pszfLINEADDRESSSTATE[] =
00172 {
00173     "Unknown LINEADDRESSSTATE information",
00174     "LINEADDRESSSTATE_OTHER",
00175     "LINEADDRESSSTATE_DEVSPECIFIC",
00176     "LINEADDRESSSTATE_INUSEZERO",
00177     "LINEADDRESSSTATE_INUSEONE",
00178     "LINEADDRESSSTATE_INUSEMANY",
00179     "LINEADDRESSSTATE_NUMCALLS",
00180     "LINEADDRESSSTATE_FORWARD",
00181     "LINEADDRESSSTATE_TERMINALS",
00182     "LINEADDRESSSTATE_CAPSCHANGE"
00183 };
00184
00185
00186 LPSTR pszfLINECALLINFOSTATE[] =
00187 {
00188     "Unknown LINECALLINFOSTATE state",
00189     "LINECALLINFOSTATE_OTHER",
00190     "LINECALLINFOSTATE_DEVSPECIFIC",
00191     "LINECALLINFOSTATE_BEARERMODE",
00192     "LINECALLINFOSTATE_RATE",
00193     "LINECALLINFOSTATE_MEDIAMODE",
00194     "LINECALLINFOSTATE_APPSPECIFIC",
00195     "LINECALLINFOSTATE_CALLID",
00196     "LINECALLINFOSTATE_RELATEDCALLID",
00197     "LINECALLINFOSTATE_ORIGIN",
00198     "LINECALLINFOSTATE_REASON",
00199     "LINECALLINFOSTATE_COMPLETIONID",
00200     "LINECALLINFOSTATE_NUMOWNERINCR",
00201     "LINECALLINFOSTATE_NUMOWNERDECR",
00202     "LINECALLINFOSTATE_NUMMONITORS",
00203     "LINECALLINFOSTATE_TRUNK",
00204     "LINECALLINFOSTATE_CALLERID",
00205     "LINECALLINFOSTATE_CALLEDID",
00206     "LINECALLINFOSTATE_CONNECTEDID",
00207     "LINECALLINFOSTATE_REDIRECTIONID",
00208     "LINECALLINFOSTATE_REDIRECTINGID",
00209     "LINECALLINFOSTATE_DISPLAY",
00210     "LINECALLINFOSTATE_USERUSERINFO",
00211     "LINECALLINFOSTATE_HIGHLEVELCOMP",
00212     "LINECALLINFOSTATE_LOWLEVELCOMP",
00213     "LINECALLINFOSTATE_CHARGINGINFO",
00214     "LINECALLINFOSTATE_TERMINAL",
00215     "LINECALLINFOSTATE_DIALPARAMS",
00216     "LINECALLINFOSTATE_MONITORMODES"
00217 };
00218
00219
00220 LPSTR pszfLINECALLSTATE[] =
00221 {
00222     "Unknown LINECALLSTATE state",
00223     "LINECALLSTATE_IDLE",
00224     "LINECALLSTATE_OFFERING",
00225     "LINECALLSTATE_ACCEPTED",
00226     "LINECALLSTATE_DIALTONE",
00227     "LINECALLSTATE_DIALING",
00228     "LINECALLSTATE_RINGBACK",
00229     "LINECALLSTATE_BUSY",
00230     "LINECALLSTATE_SPECIALINFO",
00231     "LINECALLSTATE_CONNECTED",
00232     "LINECALLSTATE_PROCEEDING",
00233     "LINECALLSTATE_ONHOLD",
00234     "LINECALLSTATE_CONFERENCED",
00235     "LINECALLSTATE_ONHOLDPENDCONF",
00236     "LINECALLSTATE_ONHOLDPENDTRANSFER",
00237     "LINECALLSTATE_DISCONNECTED",
00238     "LINECALLSTATE_UNKNOWN"
00239 };
00240
00241
00242 LPSTR pszfLINEDIALTONEMODE[] =
00243 {
00244     "Unknown LINEDIALTONE information",
00245     "LINEDIALTONEMODE_NORMAL",
00246     "LINEDIALTONEMODE_SPECIAL",
00247     "LINEDIALTONEMODE_INTERNAL",
00248     "LINEDIALTONEMODE_EXTERNAL",
00249     "LINEDIALTONEMODE_UNKNOWN",
00250     "LINEDIALTONEMODE_UNAVAIL"
00251 };
00252
00253
00254 LPSTR pszfLINEBUSYMODE[] =
00255 {
00256     "Unknown LINEBUSYMODE information",
00257     "LINEBUSYMODE_STATION",
00258     "LINEBUSYMODE_TRUNK",
00259     "LINEBUSYMODE_UNKNOWN",
00260     "LINEBUSYMODE_UNAVAIL"
00261 };
00262
00263
00264 LPSTR pszfLINESPECIALINFO[] =
00265 {
00266     "Unknown LINESPECIALINFO information",
00267     "LINESPECIALINFO_NOCIRCUIT",
00268     "LINESPECIALINFO_CUSTIRREG",
00269     "LINESPECIALINFO_REORDER",
00270     "LINESPECIALINFO_UNKNOWN",
00271     "LINESPECIALINFO_UNAVAIL"
00272 };
00273
00274
00275 LPSTR pszfLINEDISCONNECTED[] =
00276 {
00277     "Unknown LINEDISCONNECTED information",
00278     "LINEDISCONNECTMODE_NORMAL",
00279     "LINEDISCONNECTMODE_UNKNOWN",
00280     "LINEDISCONNECTMODE_REJECT",
00281     "LINEDISCONNECTMODE_PICKUP",
00282     "LINEDISCONNECTMODE_FORWARDED",
00283     "LINEDISCONNECTMODE_BUSY",
00284     "LINEDISCONNECTMODE_NOANSWER",
00285     "LINEDISCONNECTMODE_BADADDRESS",
00286     "LINEDISCONNECTMODE_UNREACHABLE",
00287     "LINEDISCONNECTMODE_CONGESTION",
00288     "LINEDISCONNECTMODE_INCOMPATIBLE",
00289     "LINEDISCONNECTMODE_UNAVAIL",
00290     "LINEDISCONNECTMODE_NODIALTONE"
00291 };
00292
00293
00294 LPSTR pszfLINECALLPRIVILEGE[] =
00295 {
00296     "No change to LINECALLPRIVILEGE",
00297     "LINECALLPRIVILEGE_NONE",
00298     "LINECALLPRIVILEGE_MONITOR",
00299     "LINECALLPRIVILEGE_OWNER"
00300 };
00301
00302
00303 LPSTR pszfLINEGATHERTERM[] =
00304 {
00305     "Unknown LINEGATHERTERM message",
00306     "LINEGATHERTERM_BUFFERFULL",
00307     "LINEGATHERTERM_TERMDIGIT",
00308     "LINEGATHERTERM_FIRSTTIMEOUT",
00309     "LINEGATHERTERM_INTERTIMEOUT",
00310     "LINEGATHERTERM_CANCEL"
00311 };
00312
00313
00314 LPSTR pszfLINEGENERATETERM[] =
00315 {
00316     "Unknown LINEGENERATETERM message",
00317     "LINEGENERATETERM_DONE",
00318     "LINEGENERATETERM_CANCEL"
00319 };
00320
00321
00322 LPSTR pszfLINEDEVSTATE[] =
00323 {
00324     "Unknown LINEDEVESTATE state",
00325     "LINEDEVSTATE_OTHER",
00326     "LINEDEVSTATE_RINGING",
00327     "LINEDEVSTATE_CONNECTED",
00328     "LINEDEVSTATE_DISCONNECTED",
00329     "LINEDEVSTATE_MSGWAITON",
00330     "LINEDEVSTATE_MSGWAITOFF",
00331     "LINEDEVSTATE_INSERVICE",
00332     "LINEDEVSTATE_OUTOFSERVICE",
00333     "LINEDEVSTATE_MAINTENANCE",
00334     "LINEDEVSTATE_OPEN",
00335     "LINEDEVSTATE_CLOSE",
00336     "LINEDEVSTATE_NUMCALLS",
00337     "LINEDEVSTATE_NUMCOMPLETIONS",
00338     "LINEDEVSTATE_TERMINALS",
00339     "LINEDEVSTATE_ROAMMODE",
00340     "LINEDEVSTATE_BATTERY",
00341     "LINEDEVSTATE_SIGNAL",
00342     "LINEDEVSTATE_DEVSPECIFIC",
00343     "LINEDEVSTATE_REINIT",
00344     "LINEDEVSTATE_LOCK",
00345     "LINEDEVSTATE_CAPSCHANGE",
00346     "LINEDEVSTATE_CONFIGCHANGE",
00347     "LINEDEVSTATE_TRANSLATECHANGE",
00348     "LINEDEVSTATE_COMPLCANCEL",
00349     "LINEDEVSTATE_REMOVED"
00350 };
00351
00352
00353 LPSTR pszfLINEDIGITMODE[] =
00354 {
00355     "Unknown LINEDIGITMODE mode",
00356     "LINEDIGITMODE_PULSE",
00357     "LINEDIGITMODE_DTMF",
00358     "LINEDIGITMODE_DTMFEND"
00359 };
00360
00361
00362 LPSTR pszfLINEMEDIAMODE[] =
00363 {
00364     "Unknown LINEMEDIAMODE mode",
00365     "UnUsed LINEMEDIAMODE mode, ERROR!!",
00366     "LINEMEDIAMODE_UNKNOWN",
00367     "LINEMEDIAMODE_INTERACTIVEVOICE",
00368     "LINEMEDIAMODE_AUTOMATEDVOICE",
00369     "LINEMEDIAMODE_DATAMODEM",
00370     "LINEMEDIAMODE_G3FAX",
00371     "LINEMEDIAMODE_TDD",
00372     "LINEMEDIAMODE_G4FAX",
00373     "LINEMEDIAMODE_DIGITALDATA",
00374     "LINEMEDIAMODE_TELETEX",
00375     "LINEMEDIAMODE_VIDEOTEX",
00376     "LINEMEDIAMODE_TELEX",
00377     "LINEMEDIAMODE_MIXED",
00378     "LINEMEDIAMODE_ADSI",
00379     "LINEMEDIAMODE_VOICEVIEW"
00380 };
00381
00382
00383 LPSTR pszfLINEREQUESTMODE[] =
00384 {
00385     "Unknown LINEREQUESTMODE message",
00386     "LINEREQUESTMODE_MAKECALL",
00387     "LINEREQUESTMODE_MEDIACALL",
00388     "LINEREQUESTMODE_DROP"
00389 };
00390
00391
00392 //
00393 //  MACRO: OutputDebugLineError(long, LPSTR)
00394 //
00395 //  PURPOSE: Pretty print a line error to the debugging output.
00396 //
00397 //  PARAMETERS:
00398 //    lLineError - Actual error code to decipher.
00399 //    pszPrefix  - String to prepend to the printed message.
00400 //
00401 //  RETURN VALUE:
00402 //    none
00403 //
00404 //  COMMENTS:
00405 //    This macro is actually defined in the .h file.
00406 //    It will take a LINEERR error, turn it into a human
00407 //    readable string, prepend pszPrefix (so you
00408 //    can tag your errors), append __FILE__ and __LINE__
00409 //    and print it to the debugging output.
00410
00411 //    This macro is just a wrapper around OutputDebugLineErrorFileLine
00412 //    that is necessary to get proper values for __FILE__ and __LINE__.
00413 //
00414 //
00415
00416
00417 /*
00418 #define OuputDebugLineError(lLineError, pszPrefix) \
00419     OutputDebugLineErrorFileLine(lLineError, pszPrefix,\
00420         __FILE__, __LINE__)
00421 */
00422
00423 //
00424 //  FUNCTION: OutputDebugLineErrorFileLine(..)
00425 //
00426 //  PURPOSE: Pretty print a line error to the debugging output.
00427 //
00428 //  PARAMETERS:
00429 //    lLineError  - Actual error code to decipher.
00430 //    pszPrefix   - String to prepend to the printed message.
00431 //    szFileName  - Filename the error occured in.
00432 //    nLineNumber - Line number the error occured at.
00433 //
00434 //  RETURN VALUE:
00435 //    none
00436 //
00437 //  COMMENTS:
00438 //    This is the actual function that OutputDebugLineError
00439 //    expands to.  Its not likely to be usefull except
00440 //    through the OutputDebugLineError macro, or to print
00441 //    errors without line and file information.
00442 //
00443 //    If szFileName == NULL, then the File and Line are not printed.
00444 //
00445 //    Note that there is an internal string length limit of
00446 //    MAXOUTPUTSTRINGLENGTH.  If this length is exceeded,
00447 //    the behavior will be the same as wsprintf, although
00448 //    it will be undetectable.  *KEEP szPrefix SHORT!*
00449 //
00450 //
00451
00452 void OutputDebugLineErrorFileLine(
00453     long lLineError, LPSTR szPrefix,
00454     LPSTR szFileName, DWORD nLineNumber)
00455 {
00456     LPSTR szLineError;
00457     char szOutputLineError[MAXOUTPUTSTRINGLENGTH];
00458
00459     if (szPrefix == NULL)
00460         szPrefix = "";
00461
00462     // Pretty print the error message.
00463     szLineError = FormatLineError(lLineError, NULL, 0);
00464
00465     // The only reason FormatLineError should fail is "Out of memory".
00466     if (szLineError == NULL)
00467     {
00468         if (szFileName == NULL)
00469             wsprintf(szOutputLineError, "%sOut of memory", szPrefix);
00470         else
00471             wsprintf(szOutputLineError,
00472                 "%sOut of memory in file %s, line %d\r\n",
00473                 szPrefix, szFileName, nLineNumber);
00474
00475         OutputDebugString(szOutputLineError);
00476
00477         return;
00478     }
00479
00480     // If szFileName, then use it; else don't.
00481     if (szFileName != NULL)
00482     {
00483         wsprintf(szOutputLineError,
00484             "%sTapi Line Error: \"%s\" in File \"%s\", Line %d\r\n",
00485             szPrefix, szLineError, szFileName, nLineNumber);
00486     }
00487     else
00488     {
00489         wsprintf(szOutputLineError,
00490             "%sTapi Line Error: \"%s\"\r\n",
00491             szPrefix, szLineError);
00492     }
00493
00494     // Pointer returned from FormatLineError *must* be freed!
00495     LocalFree(szLineError);
00496
00497     // Print it!
00498     OutputDebugString(szOutputLineError);
00499
00500     return;
00501 }
00502
00503
00504 //
00505 //  FUNCTION: FormatLineError(long, LPSTR, DWORD)
00506 //
00507 //  PURPOSE: Pretty print a line error to a string.
00508 //
00509 //  PARAMETERS:
00510 //    lLineError           - Actual error code to decipher.
00511 //    szOutputBuffer       - String buffer to pretty print to.
00512 //    dwSizeofOutputBuffer - Size of String buffer.
00513 //
00514 //  RETURN VALUE:
00515 //    Returns the buffer printed to.
00516 //
00517 //  COMMENTS:
00518 //    If szOutputBuffer isn't big enough to hold the whole string,
00519 //    then the string gets truncated to fit the buffer.
00520 //
00521 //    If szOutputBuffer == NULL, then dwSizeofOutputBuffer
00522 //    is ignored, a buffer 'big enough' is LocalAlloc()d and
00523 //    a pointer to it is returned.  However, its *very* important
00524 //    that this pointer be LocalFree()d by the calling application.
00525 //
00526 //
00527
00528 LPSTR FormatLineError(long lLineError,
00529     LPSTR szOutputBuffer, DWORD dwSizeofOutputBuffer)
00530 {
00531     char szUnknownLineError[256];
00532     LPSTR szLineError;
00533     int nSizeofLineError;
00534     long lErrorIndex;
00535     DWORD * pdwLineError;
00536
00537     // Strip off the high bit to make the error code positive.
00538     pdwLineError = &lLineError;
00539     lErrorIndex = (long) (0x7FFFFFFF & *pdwLineError);
00540
00541     // Is it an unknown error?
00542     if ((lErrorIndex >= sizeofArray(pszLineErrorNameArray)) ||
00543         (lErrorIndex < 0))
00544     {
00545         nSizeofLineError =
00546             wsprintf(szUnknownLineError, "Unknown TAPI line error code: 0x%lx",
00547                 lLineError);
00548         szLineError = szUnknownLineError;
00549     }
00550     else
00551     {
00552         szLineError = pszLineErrorNameArray[lErrorIndex];
00553         nSizeofLineError = (int) strlen(szLineError);
00554     }
00555
00556     // allocate a buffer if necessary
00557     if (szOutputBuffer == NULL)
00558     {
00559         szOutputBuffer = (LPSTR) LocalAlloc(LPTR, nSizeofLineError + 1);
00560         if (szOutputBuffer == NULL)
00561             return NULL;
00562     }
00563     else // truncate string if it won't fit in the specified buffer.
00564     {
00565         if ((DWORD) nSizeofLineError >= dwSizeofOutputBuffer)
00566             nSizeofLineError = dwSizeofOutputBuffer - 1;
00567     }
00568
00569     // Put the string into the buffer and null terminate.
00570     memcpy(szOutputBuffer, szLineError, nSizeofLineError);
00571     szOutputBuffer[nSizeofLineError] = '\0';
00572
00573     return szOutputBuffer;
00574 }
00575
00576
00577 //
00578 //  MACRO: OutputDebugLastError(DWORD, LPSTR)
00579 //
00580 //  PURPOSE: Pretty print a system error to the debugging output.
00581 //
00582 //  PARAMETERS:
00583 //    dwLastError - Actual error code to decipher.
00584 //    pszPrefix   - String to prepend to the printed message.
00585 //
00586 //  RETURN VALUE:
00587 //    none
00588 //
00589 //  COMMENTS:
00590 //    This macro is actually defined in the .h file.
00591 //    It will take an error that was retrieved by GetLastError(),
00592 //    turn it into a human readable string, prepend pszPrefix
00593 //    (so you can tag your errors), append __FILE__ and __LINE__
00594 //    and print it to the debugging output.
00595 //
00596 //    This macro is just a wrapper around OutputDebugLastErrorFileLine
00597 //    that is necessary to get proper values for __FILE__ and __LINE__.
00598 //
00599 //
00600
00601 /*
00602 #define OuputDebugLastError(dwLastError, pszPrefix) \
00603     OutputDebugLastErrorFileLine(dwLastError, pszPrefix,\
00604         __FILE__, __LINE__)
00605 */
00606
00607
00608 //
00609 //  FUNCTION: OutputDebugLastErrorFileLine(..)
00610 //
00611 //  PURPOSE: Pretty print a line error to the debugging output.
00612 //
00613 //  PARAMETERS:
00614 //    dwLastError - Actual error code to decipher.
00615 //    pszPrefix   - String to prepend to the printed message.
00616 //    szFileName  - Filename the error occured in.
00617 //    nLineNumber - Line number the error occured at.
00618 //
00619 //  RETURN VALUE:
00620 //    none
00621 //
00622 //  COMMENTS:
00623 //    This is the actual function that OutputDebugLastError
00624 //    expands to.  Its not likely to be usefull except
00625 //    through the OutputDebugLastError macro or to print
00626 //    errors without line and file information.
00627 //
00628 //    If szFileName == NULL, then the File and Line are not printed.
00629 //
00630 //    Note that there is an internal string length limit of
00631 //    MAXOUTPUTSTRINGLENGTH.  If this length is exceeded,
00632 //    the behavior will be the same as wsprintf, although
00633 //    it will be undetectable.  *KEEP szPrefix SHORT!*
00634 //
00635 //
00636
00637 void OutputDebugLastErrorFileLine(
00638     DWORD dwLastError, LPSTR szPrefix,
00639     LPSTR szFileName, DWORD nLineNumber)
00640 {
00641     LPSTR szLastError;
00642     char szOutputLastError[MAXOUTPUTSTRINGLENGTH];
00643
00644     if (szPrefix == NULL)
00645         szPrefix = "";
00646
00647     // Pretty print the error.
00648     szLastError = FormatLastError(dwLastError, NULL, 0);
00649
00650     // The only reason FormatLastError should fail is "Out of memory".
00651     if (szLastError == NULL)
00652     {
00653         if (szFileName == NULL)
00654             wsprintf(szOutputLastError, "%sOut of memory\r\n", szPrefix);
00655         else
00656             wsprintf(szOutputLastError, "%sOut of memory in file %s, line %d\r\n",
00657                 szPrefix, szFileName, nLineNumber);
00658
00659         OutputDebugString(szOutputLastError);
00660
00661         return;
00662     }
00663
00664     // If szFileName, then use it; else don't.
00665     if (szFileName != NULL)
00666     {
00667         wsprintf(szOutputLastError,
00668             "%sGetLastError returned: \"%s\" in File \"%s\", Line %d\r\n",
00669             szPrefix, szLastError, szFileName, nLineNumber);
00670     }
00671     else
00672     {
00673         wsprintf(szOutputLastError,
00674             "%sGetLastError returned: \"%s\"\r\n",
00675             szPrefix, szLastError);
00676     }
00677
00678     // Pointer returned from FormatLineError *must* be freed!
00679     LocalFree(szLastError);
00680
00681     // Print it!
00682     OutputDebugString(szOutputLastError);
00683     return;
00684 }
00685
00686
00687 //
00688 //  FUNCTION: FormatLastError(DWORD, LPSTR, DWORD)
00689 //
00690 //  PURPOSE: Pretty print a system error to a string.
00691 //
00692 //  PARAMETERS:
00693 //    dwLastError          - Actual error code to decipher.
00694 //    szOutputBuffer       - String buffer to pretty print to.
00695 //    dwSizeofOutputBuffer - Size of String buffer.
00696 //
00697 //  RETURN VALUE:
00698 //    Returns the buffer printed to.
00699 //
00700 //  COMMENTS:
00701 //    If szOutputBuffer isn't big enough to hold the whole string,
00702 //    then the string gets truncated to fit the buffer.
00703 //
00704 //    If szOutputBuffer == NULL, then dwSizeofOutputBuffer
00705 //    is ignored, a buffer 'big enough' is LocalAlloc()d and
00706 //    a pointer to it is returned.  However, its *very* important
00707 //    that this pointer be LocalFree()d by the calling application.
00708 //
00709 //
00710
00711 LPSTR FormatLastError(DWORD dwLastError,
00712     LPSTR szOutputBuffer, DWORD dwSizeofOutputBuffer)
00713 {
00714     DWORD dwRetFM;
00715     DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM;
00716
00717     // Should we allocate a buffer?
00718     if (szOutputBuffer == NULL)
00719     {
00720         // Actually, we make FormatMessage allocate the buffer, if needed.
00721         dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER;
00722
00723         // minimum size FormatMessage should allocate.
00724         dwSizeofOutputBuffer = 1;
00725     }
00726
00727     // Make FormatMessage pretty print the system error.
00728     dwRetFM = FormatMessage(
00729         dwFlags, NULL, dwLastError,
00730         MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
00731         (LPTSTR) &szOutputBuffer, dwSizeofOutputBuffer,
00732         NULL);
00733
00734     // FormatMessage failed to print the error.
00735     if (dwRetFM == 0)
00736     {
00737         DWORD dwGetLastError;
00738         LPSTR szFormatMessageError;
00739
00740         dwGetLastError = GetLastError();
00741
00742         // If we asked FormatMessage to allocate a buffer, then it
00743         // might have allocated one.  Lets be safe and LocalFree it.
00744         if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
00745         {
00746             __try
00747             {
00748                 LocalFree(szOutputBuffer);
00749             }
00750             __except(EXCEPTION_EXECUTE_HANDLER)
00751             {
00752                 // Actually, we do nothing for this fault.  If
00753                 // there was a fault, it meant the buffer wasn't
00754                 // allocated, and the LocalFree was unnecessary.
00755                 ;
00756             }
00757
00758             szOutputBuffer = LocalAlloc(LPTR, MAXOUTPUTSTRINGLENGTH);
00759             dwSizeofOutputBuffer = MAXOUTPUTSTRINGLENGTH;
00760
00761             if (szOutputBuffer == NULL)
00762             {
00763                 OutputDebugString("Out of memory trying to FormatLastError\r\n");
00764                 return NULL;
00765             }
00766         }
00767
00768         szFormatMessageError =
00769             FormatLastError(dwGetLastError, NULL, 0);
00770
00771         if (szFormatMessageError == NULL)
00772             return NULL;
00773
00774         wsprintf(szOutputBuffer,
00775             "FormatMessage failed on error 0x%lx for the following reason: %s",
00776             dwLastError, szFormatMessageError);
00777
00778         LocalFree(szFormatMessageError);
00779     }
00780
00781     return szOutputBuffer;
00782 }
00783
00784
00785 //
00786 //  FUNCTION: OutputDebugLineCallback(...)
00787 //
00788 //  PURPOSE: Pretty print a message passed into a lineCallbackFunc.
00789 //
00790 //  PARAMETERS:
00791 //    Standard lineCallbackFunc parameters.
00792 //
00793 //  RETURN VALUE:
00794 //    none.
00795 //
00796 //  COMMENTS:
00797 //
00798 //    This function takes all of the parameters passed into a
00799 //    lineCallbackFunc callback function, and pretty prints the
00800 //    meaning of the message.  It then prints the result to
00801 //    the debugging output.
00802 //
00803 //
00804
00805 void OutputDebugLineCallback(
00806     DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
00807     DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
00808 {
00809     char szOutputBuff[MAXOUTPUTSTRINGLENGTH];
00810
00811     FormatLineCallback(szOutputBuff,
00812         dwDevice, dwMsg, dwCallbackInstance,
00813         dwParam1, dwParam2, dwParam3);
00814
00815     strcat(szOutputBuff,"\r\n");
00816
00817     OutputDebugString(szOutputBuff);
00818 }
00819
00820
00821 //
00822 //  FUNCTION: FormatLineCallback(...)
00823 //
00824 //  PURPOSE: Pretty prints into a buffer a lineCallbackFunc message.
00825 //
00826 //  PARAMETERS:
00827 //    Standard lineCallbackFunc parameters.
00828 //
00829 //  RETURN VALUE:
00830 //    The pointer to the buffer that has the resulting string.
00831 //
00832 //  COMMENTS:
00833 //
00834 //    This function takes all of the parameters passed into a
00835 //    lineCallbackFunc callback function, and pretty prints the
00836 //    meaning of the message.  It then returns the pointer to
00837 //    the buffer containing this string.
00838 //
00839 //    If szOutputBuffer == NULL, then a buffer is LocalAlloc()d
00840 //    and returned.  However, it is *very* important that this buffer
00841 //    is LocalFree()d.
00842 //
00843
00844 LPSTR FormatLineCallback(LPSTR szOutputBuffer,
00845     DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
00846     DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
00847 {
00848     long lBufferIndex = 0;
00849
00850     // Allocate the buffer if necessary.
00851     if (szOutputBuffer == NULL)
00852     {
00853         szOutputBuffer = (LPSTR) LocalAlloc(LPTR, MAXOUTPUTSTRINGLENGTH);
00854
00855         if (szOutputBuffer == NULL)
00856             return NULL;
00857     }
00858
00859     // Is this a known message?
00860     if (dwMsg >= sizeofArray(psz_dwMsg))
00861     {
00862         wsprintf(szOutputBuffer, "lineCallback: Unknown dwMsg: '0x%lx', "
00863             "dwDevice: '0x%lx', dwCallbackInstance: '0x%lx', "
00864             "dwParam1: '0x%lx', dwParam2: '0x%lx', dwParam3: '0x%lx'", dwMsg,
00865             dwDevice, dwCallbackInstance, dwParam1, dwParam2, dwParam3);
00866         return szOutputBuffer;
00867     }
00868
00869     // Lets start pretty printing.
00870     lBufferIndex +=
00871         wsprintf(szOutputBuffer, "lineCallback: %s; dwDevice: '0x%lx'; ",
00872             psz_dwMsg[dwMsg], dwDevice);
00873
00874     // Which message was it?  And start decoding it!
00875     // How the message is decoded depends entirely on the message.
00876     // READ THE HELP FILES if you more information on this.
00877     switch(dwMsg)
00878     {
00879         case LINE_ADDRESSSTATE:
00880         {
00881             lBufferIndex +=
00882                 wsprintf(&(szOutputBuffer[lBufferIndex]),
00883                     "Address ID: 0x%lx, Address State: ", dwParam1);
00884
00885             lBufferIndex +=
00886                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00887                     dwParam2,
00888                     pszfLINEADDRESSSTATE, sizeofArray(pszfLINEADDRESSSTATE));
00889
00890             break;
00891         }
00892
00893         case LINE_CALLINFO:
00894         {
00895             lBufferIndex +=
00896                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00897                     dwParam1,
00898                     pszfLINECALLINFOSTATE, sizeofArray(pszfLINECALLINFOSTATE));
00899
00900             break;
00901         }
00902
00903         case LINE_CALLSTATE:
00904         {
00905
00906             lBufferIndex +=
00907                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00908                     dwParam3,
00909                     pszfLINECALLPRIVILEGE, sizeofArray(pszfLINECALLPRIVILEGE));
00910             lBufferIndex +=
00911                 wsprintf(&(szOutputBuffer[lBufferIndex]),
00912                     "; ");
00913
00914             lBufferIndex +=
00915                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00916                     dwParam1,
00917                     pszfLINECALLSTATE, sizeofArray(pszfLINECALLSTATE));
00918
00919             switch(dwParam1)
00920             {
00921                 case LINECALLSTATE_DIALTONE:
00922                 {
00923                     lBufferIndex +=
00924                         wsprintf(&(szOutputBuffer[lBufferIndex]),
00925                             ": ");
00926
00927                     lBufferIndex +=
00928                         strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00929                         dwParam2,
00930                         pszfLINEDIALTONEMODE, sizeofArray(pszfLINEDIALTONEMODE));
00931
00932                     break;
00933                 }
00934
00935                 case LINECALLSTATE_BUSY:
00936                 {
00937                     lBufferIndex +=
00938                         wsprintf(&(szOutputBuffer[lBufferIndex]),
00939                             ": ");
00940
00941                     lBufferIndex +=
00942                         strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00943                         dwParam2,
00944                         pszfLINEBUSYMODE, sizeofArray(pszfLINEBUSYMODE));
00945
00946                     break;
00947                 }
00948
00949                 case LINECALLSTATE_SPECIALINFO:
00950                 {
00951                     lBufferIndex +=
00952                         wsprintf(&(szOutputBuffer[lBufferIndex]),
00953                             ": ");
00954
00955                     lBufferIndex +=
00956                         strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00957                         dwParam2,
00958                         pszfLINESPECIALINFO, sizeofArray(pszfLINESPECIALINFO));
00959
00960                     break;
00961                 }
00962
00963                 case LINECALLSTATE_DISCONNECTED:
00964                 {
00965                     lBufferIndex +=
00966                         wsprintf(&(szOutputBuffer[lBufferIndex]),
00967                             ": ");
00968
00969                     lBufferIndex +=
00970                         strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
00971                         dwParam2,
00972                         pszfLINEDISCONNECTED, sizeofArray(pszfLINEDISCONNECTED));
00973
00974                     break;
00975                 }
00976
00977                 case LINECALLSTATE_CONFERENCED:
00978                 {
00979                     lBufferIndex +=
00980                         wsprintf(&(szOutputBuffer[lBufferIndex]),
00981                             ": Parent conference call handle: 0x%lx", dwParam2);
00982
00983                     break;
00984                 }
00985             }
00986
00987             break;
00988         }
00989
00990         case LINE_CLOSE:
00991             break;
00992
00993         case LINE_DEVSPECIFIC:
00994             break;
00995
00996         case LINE_DEVSPECIFICFEATURE:
00997             break;
00998
00999         case LINE_GATHERDIGITS:
01000         {
01001             lBufferIndex +=
01002                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01003                     dwParam1,
01004                     pszfLINEGATHERTERM, sizeofArray(pszfLINEGATHERTERM));
01005
01006             break;
01007         }
01008
01009         case LINE_GENERATE:
01010         {
01011             lBufferIndex +=
01012                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01013                     dwParam1,
01014                     pszfLINEGENERATETERM, sizeofArray(pszfLINEGENERATETERM));
01015
01016             break;
01017         }
01018
01019         case LINE_LINEDEVSTATE:
01020         {
01021             lBufferIndex +=
01022                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01023                     dwParam1,
01024                     pszfLINEDEVSTATE, sizeofArray(pszfLINEDEVSTATE));
01025
01026             switch(dwParam1)
01027             {
01028                 case LINEDEVSTATE_RINGING:
01029                     lBufferIndex +=
01030                         wsprintf(&(szOutputBuffer[lBufferIndex]),
01031                             "; Ring Mode: 0x%lx, Ring Count: %lu"
01032                             ,dwParam2, dwParam3);
01033                     break;
01034
01035                 case LINEDEVSTATE_REINIT:
01036                 {
01037                     switch(dwParam2)
01038                     {
01039                         case LINE_CREATE:
01040                             lBufferIndex +=
01041                                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01042                                     "; ReInit reason: LINE_CREATE, "
01043                                         "New Line Device ID '0x%lx'"
01044                                     , dwParam3);
01045                             break;
01046
01047                         case LINE_LINEDEVSTATE:
01048                             lBufferIndex +=
01049                                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01050                                     "; ReInit reason: LINE_LINEDEVSTATE, ");
01051
01052                             lBufferIndex +=
01053                                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01054                                     dwParam3,
01055                                     pszfLINEDEVSTATE, sizeofArray(pszfLINEDEVSTATE));
01056
01057                             break;
01058
01059                         case 0:
01060                             break;
01061                         default:
01062                             lBufferIndex +=
01063                                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01064                                     "; ReInit reason: %s, dwParam3: 0x%lx"
01065                                     ,psz_dwMsg[dwParam2], dwParam3);
01066                             break;
01067
01068                     }
01069
01070                     break;
01071                 }
01072
01073                 default:
01074                     break;
01075             }
01076
01077             break;
01078         }
01079
01080         case LINE_MONITORDIGITS:
01081         {
01082             lBufferIndex +=
01083                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01084                 dwParam2,
01085                 pszfLINEDIGITMODE, sizeofArray(pszfLINEDIGITMODE));
01086
01087             lBufferIndex +=
01088                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01089                     ", Received: '%c'", LOBYTE(LOWORD(dwParam1)));
01090
01091             break;
01092         }
01093
01094         case LINE_MONITORMEDIA:
01095         {
01096             lBufferIndex +=
01097                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01098                     dwParam1,
01099                     pszfLINEMEDIAMODE, sizeofArray(pszfLINEMEDIAMODE));
01100
01101             break;
01102         }
01103
01104         case LINE_MONITORTONE:
01105         {
01106             lBufferIndex +=
01107                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01108                     "AppSpecific tone '%lu'", dwParam1);
01109             break;
01110         }
01111
01112         case LINE_REPLY:
01113         {
01114             if (dwParam2 == 0)
01115             {
01116                 lBufferIndex +=
01117                     wsprintf(&(szOutputBuffer[lBufferIndex]),
01118                         "Request ID: 0x%lx; Successful reply!", dwParam1);
01119             }
01120             else
01121             {
01122                 char szTmpBuff[256];
01123
01124                 FormatLineError((long) dwParam2, szTmpBuff, 255);
01125
01126                 lBufferIndex +=
01127                     wsprintf(&(szOutputBuffer[lBufferIndex]),
01128                         "Request ID: 0x%lx; UnSuccessful reply; %s",
01129                         dwParam1, szTmpBuff);
01130             }
01131
01132             break;
01133         }
01134
01135         case LINE_REQUEST:
01136         {
01137             lBufferIndex +=
01138                 strBinaryArrayAppend(&(szOutputBuffer[lBufferIndex]),
01139                 dwParam1,
01140                 pszfLINEREQUESTMODE, sizeofArray(pszfLINEREQUESTMODE));
01141
01142             switch(dwParam1)
01143             {
01144                 case LINEREQUESTMODE_DROP:
01145                 {
01146                     char szHwndName[1024];
01147
01148                     SendMessage((HWND)(DWORD_PTR) dwParam2, WM_GETTEXT, 1024, (LPARAM) szHwndName);
01149
01150                     lBufferIndex +=
01151                         wsprintf(&(szOutputBuffer[lBufferIndex]),
01152                             ": hwnd dropping = 0x%lx, \"%s\"; wRequestID = %u",
01153                             dwParam2, szHwndName, LOWORD(dwParam3));
01154                     break;
01155                 }
01156                 default:
01157                     break;
01158             }
01159
01160             break;
01161         }
01162
01163         case LINE_CREATE:
01164         {
01165             lBufferIndex +=
01166                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01167                     "New Line Device ID '0x%lx'", dwParam1);
01168             break;
01169         }
01170
01171         case PHONE_CREATE:
01172         {
01173             lBufferIndex +=
01174                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01175                     "New Phone Device ID '0x%lx'", dwParam1);
01176             break;
01177         }
01178
01179         default:
01180             lBufferIndex +=
01181                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01182                     "dwParam1: 0x%lx , dwParam2: 0x%lx , dwParam3: 0x%lx",
01183                     dwParam1, dwParam2, dwParam3);
01184             break;
01185
01186     } // End switch(dwMsg)
01187
01188     // return that pointer!
01189     return szOutputBuffer;
01190
01191 }
01192
01193
01194 //
01195 //  FUNCTION: strBinaryArrayAppend(LPSTR, DWORD, LPSTR *, DWORD)
01196 //
01197 //  PURPOSE: Takes a bitmapped DWORD, an array representing that
01198 //    binary mapping, and pretty prints it to a buffer.
01199 //
01200 //  PARAMETERS:
01201 //    szOutputBuffer      - Buffer to print to.
01202 //    dwFlags             - Binary mapped flags to interpret.
01203 //    szStringArray       - Array of strings.
01204 //    dwSizeofStringArray - number of elements in szStringArray.
01205
01206 //
01207 //  RETURN VALUE:
01208 //    The number of characters printed into szOutputBuffer.
01209 //
01210 //  COMMENTS:
01211 //
01212 //    This function takes dwFlags and checks each bit.  If the
01213 //    bit is set, the appropriate string (taken from szStringArray)
01214 //    is printed to the szOutputBuffer string buffer.  If there were
01215 //    more bits set in the string than elements in the array, and error
01216 //    is also tagged on the end.
01217 //
01218 //    This function is intended to be used only within the TapiInfo module.
01219 //
01220
01221 static long strBinaryArrayAppend(LPSTR szOutputBuffer, DWORD dwFlags,
01222      LPSTR szStringArray[], DWORD dwSizeofStringArray)
01223 {
01224     DWORD dwIndex = 1, dwPower = 1;
01225     long lBufferIndex = 0;
01226     BOOL bFirst = TRUE;
01227
01228     // The zeroth element in every bitmapped array is the "unknown" or
01229     // "unchanged" message.
01230     if (dwFlags == 0)
01231     {
01232         lBufferIndex =
01233             wsprintf(szOutputBuffer, "%s", szStringArray[0]);
01234         return lBufferIndex;
01235     }
01236
01237     // iterate through the flags and check each one.
01238     while(dwIndex < dwSizeofStringArray)
01239     {
01240         // If we find one, print it.
01241         if (dwFlags & dwPower)
01242             // Seporate each printing with a ", " except the first one.
01243             if (bFirst)
01244             {
01245                 lBufferIndex +=
01246                     wsprintf(&(szOutputBuffer[lBufferIndex]),
01247                         "%s", szStringArray[dwIndex]);
01248                 bFirst = FALSE;
01249             }
01250             else
01251                 lBufferIndex +=
01252                     wsprintf(&(szOutputBuffer[lBufferIndex]),
01253                         ", %s", szStringArray[dwIndex]);
01254
01255         dwIndex ++;
01256         dwFlags &= ~dwPower;  // clear it so we know we checked it.
01257         dwPower *= 2;
01258     }
01259
01260     // If there are any flags left, they were not in the array.
01261     if (dwFlags)
01262     {
01263         if (bFirst)
01264             lBufferIndex +=
01265                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01266                     "Unknown flags '0x%lx'", dwFlags);
01267         else
01268             lBufferIndex +=
01269                 wsprintf(&(szOutputBuffer[lBufferIndex]),
01270                     ", Unknown flags '0x%lx'", dwFlags);
01271     }
01272
01273     // how many did we print into the buffer?
01274     return lBufferIndex;
01275 }
01276
01277
01278
01279 //
01280 //  FUNCTION: OutputDebugPrintf(LPCSTR, ...)
01281 //
01282 //  PURPOSE: wsprintf to the debugging output.
01283 //
01284 //  PARAMETERS:
01285 //    Exactly the same as wsprintf.
01286 //
01287 //  RETURN VALUE:
01288 //    none.
01289 //
01290 //  COMMENTS:
01291 //
01292 //    This function takes exactly the same parameters as wsprintf and
01293 //    prints the results to the debugging output.
01294 //
01295
01296 void __cdecl OutputDebugPrintf(LPCSTR lpszFormat, ...)
01297 {
01298     char szOutput[MAXOUTPUTSTRINGLENGTH];
01299     va_list v1;
01300     DWORD dwSize;
01301
01302     va_start(v1, lpszFormat);
01303
01304     dwSize = wvsprintf(szOutput, lpszFormat, v1);
01305
01306     if (szOutput[dwSize-1] != '\n')
01307         strcat(szOutput, "\r\n");
01308
01309     OutputDebugString(szOutput);
01310 }
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/LockTypeEnum.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

LockTypeEnum.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: LockTypeEnum
00019
00020 public class LockTypeEnum extends com.ms.wfc.core.Enum
00021 {
00022   public static final short adLockUnspecified = -1;
00023   public static final short adLockReadOnly = 1;
00024   public static final short adLockPessimistic = 2;
00025   public static final short adLockOptimistic = 3;
00026   public static final short adLockBatchOptimistic = 4;
00027 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Common/altassrt.Cxx Source File

  • Com
  • Fundamentals
  • Common

altassrt.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright 1992 - 2000 Microsoft Corporation.
00005 //
00006 //  File:       altassrt.cxx
00007 //
00008 //  Contents:   Assertion routines for the SDK
00009 //
00010 //  Functions:  NTSDKAssert
00011 //              PopUpError
00012 //
00013 //----------------------------------------------------------------------------
00014
00015 #include <stdarg.h>
00016 #include <stdio.h>
00017
00018 // ensure that this module always compiles with DEBUG settings.
00019 #undef  NDEBUG
00020
00021 #include "assert.h"
00022
00023 int
00024 PopUpError(
00025     char const *szMsg,
00026     int iLine,
00027     char const *szFile);
00028
00029 extern "C"
00030 {
00031
00032 # ifdef WIN32
00033 #  undef FAR
00034 #  undef NEAR
00035 # else
00036 #  define MessageBoxA MessageBox
00037 # endif
00038
00039 # include <windows.h>
00040 }
00041
00042 //+---------------------------------------------------------------------------
00043 //
00044 //  Function:   PopUpAssert
00045 //
00046 //  Synopsis:   Display assertion information
00047 //
00048 //  Effects:    Called when an assertion is hit.
00049 //
00050 //  History:    8-19-94   stevebl   Created
00051 //
00052 //----------------------------------------------------------------------------
00053
00054 void _CRTAPI1
00055 PopUpAssert(
00056     void * szFile,
00057     int iLine,
00058     void * szMessage)
00059 {
00060     int id = PopUpError((char const *)szMessage,iLine, (char const *) szFile);
00061
00062     if (id == IDCANCEL)
00063     {
00064 #ifdef WIN32
00065         DebugBreak();
00066 #else
00067         _asm int 3;
00068 #endif
00069     }
00070 }
00071
00072 //+------------------------------------------------------------
00073 // Function:    PopUpError
00074 //
00075 // Synopsis:    Displays a dialog box using provided text,
00076 //              and presents the user with the option to
00077 //              continue or cancel.
00078 //
00079 // Arguments:
00080 //      szMsg --        The string to display in main body of dialog
00081 //      iLine --        Line number of file in error
00082 //      szFile --       Filename of file in error
00083 //
00084 // Returns:
00085 //      IDCANCEL --     User selected the CANCEL button
00086 //      IDOK     --     User selected the OK button
00087 //-------------------------------------------------------------
00088
00089 int
00090 PopUpError(
00091     char const *szMsg,
00092     int iLine,
00093     char const *szFile)
00094 {
00095
00096     int id;
00097     static char szAssertCaption[128];
00098     static char szModuleName[128];
00099
00100     DWORD tid = GetCurrentThreadId();
00101     DWORD pid = GetCurrentProcessId();
00102     char * pszModuleName;
00103
00104     if (GetModuleFileNameA(NULL, szModuleName, 128))
00105     {
00106         pszModuleName = strrchr(szModuleName, '\\');
00107         if (!pszModuleName)
00108         {
00109             pszModuleName = szModuleName;
00110         }
00111         else
00112         {
00113             pszModuleName++;
00114         }
00115     }
00116     else
00117     {
00118         pszModuleName = "Unknown";
00119     }
00120
00121     sprintf(szAssertCaption,"Process: %s File: %s line %u, thread id %d.%d",
00122         pszModuleName, szFile, iLine, pid, tid);
00123
00124
00125     DWORD dwMessageFlags = MB_SETFOREGROUND | MB_TASKMODAL |
00126                            MB_ICONEXCLAMATION | MB_OKCANCEL;
00127
00128     id = MessageBoxA(NULL,
00129                      (char *) szMsg,
00130                      (LPSTR) szAssertCaption,
00131                      dwMessageFlags);
00132
00133     // If id == 0, then an error occurred.  There are two possibilities
00134     // that can cause the error:  Access Denied, which means that this
00135     // process does not have access to the default desktop, and everything
00136     // else (usually out of memory).  Oh well.
00137
00138     return id;
00139 }
00140
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/regdb.c Source File

  • Com
  • Fundamentals
  • OleStd

regdb.c

Go to the documentation of this file.
00001 /*
00002  *  REGDB.C
00003  *
00004  *  Functions to query the registration database
00005  *
00006  *  OleStdGetMiscStatusOfClass
00007  *  OleStdGetDefaultFileFormatOfClass
00008  *  OleStdGetAuxUserType
00009  *  OleStdGetUserTypeOfClass
00010  *
00011  *    (c) Copyright Microsoft Corp. 1992 - 2000 All Rights Reserved
00012  *
00013  */
00014
00015 #define STRICT  1
00016 #include "olestd.h"
00017 #include "common.h"
00018 #include <ctype.h>
00019
00020 OLEDBGDATA
00021
00022
00023 // Replacement for stdlib atol,
00024 // which didn't work and doesn't take far pointers.
00025 // Must be tolerant of leading spaces.
00026 //
00027 //
00028 static LONG Atol(LPSTR lpsz)
00029 {
00030    signed int sign = +1;
00031    UINT base = 10;
00032    LONG l = 0;
00033
00034    if (NULL==lpsz)
00035    {
00036       OleDbgAssert (0);
00037       return 0;
00038    }
00039    while (isspace(*lpsz))
00040       lpsz++;
00041
00042    if (*lpsz=='-')
00043    {
00044       lpsz++;
00045       sign = -1;
00046    }
00047    if (lpsz[0]=='0' && lpsz[1]=='x')
00048    {
00049       base = 16;
00050       lpsz+=2;
00051    }
00052
00053    if (base==10)
00054    {
00055       while (isdigit(*lpsz))
00056       {
00057          l = l * base + *lpsz - '0';
00058          lpsz++;
00059       }
00060    }
00061    else
00062    {
00063       OleDbgAssert (base==16);
00064       while (isxdigit(*lpsz))
00065       {
00066          l = l * base + isdigit(*lpsz) ? *lpsz - '0' : toupper(*lpsz) - 'A' + 10;
00067          lpsz++;
00068       }
00069    }
00070    return l * sign;
00071 }
00072
00073
00074
00075 /*
00076  * OleStdGetUserTypeOfClass(REFCLSID, LPSTR, UINT, HKEY)
00077  *
00078  * Purpose:
00079  *  Returns the user type (human readable class name) of the specified class.
00080  *
00081  * Parameters:
00082  *  rclsid          pointer to the clsid to retrieve user type of.
00083  *  lpszUserType    pointer to buffer to return user type in.
00084  *  cch             length of buffer pointed to by lpszUserType
00085  *  hKey            hKey for reg db - if this is NULL, then we
00086  *                   open and close the reg db within this function.  If it
00087  *                   is non-NULL, then we assume it's a valid key to the
00088  *                   \ root and use it without closing it. (useful
00089  *                   if you're doing lots of reg db stuff).
00090  *
00091  * Return Value:
00092  *  UINT            Number of characters in returned string.  0 on error.
00093  *
00094  */
00095 STDAPI_(UINT) OleStdGetUserTypeOfClass(REFCLSID rclsid, LPOLESTR lpszUserType, UINT cch, HKEY hKey)
00096 {
00097
00098    LONG     dw;
00099    LONG     lRet;
00100    LPOLESTR lpszCLSID, lpszProgID;
00101    char     lpszAnsiCLSID[256], lpszAnsiProgID[256];
00102    BOOL     fFreeProgID = FALSE;
00103    BOOL     bCloseRegDB = FALSE;
00104    char     szKey[128];
00105    LPMALLOC lpIMalloc;
00106    char     lpszAnsiUserType[256];
00107
00108    if (!lpszUserType)
00109       return 0;
00110
00111    *lpszUserType = '\0';
00112    if (hKey == NULL)
00113    {
00114
00115     //Open up the root key.
00116     lRet=RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
00117
00118     if ((LONG)ERROR_SUCCESS!=lRet)
00119       return (UINT)FALSE;
00120
00121     bCloseRegDB = TRUE;
00122    }
00123
00124    // Get a string containing the class name
00125    StringFromCLSID(rclsid, &lpszCLSID);
00126
00127    W2A (lpszCLSID, lpszAnsiCLSID, 256);
00128    wsprintf(szKey, "CLSID\\%s", lpszAnsiCLSID);
00129
00130
00131    dw=cch;
00132    lRet = RegQueryValue(hKey, szKey, lpszAnsiUserType, &dw);
00133    A2W (lpszAnsiUserType, lpszUserType, cch);
00134
00135    if ((LONG)ERROR_SUCCESS!=lRet) {
00136       // Load 'Unknown Source' and 'Unknown Type' strings
00137       dw = (LONG)LoadString(ghInst, (UINT)IDS_PSUNKNOWNTYPE, lpszAnsiUserType, cch);
00138       A2W (lpszAnsiUserType, lpszUserType, cch);
00139    }
00140
00141    if ( ((LONG)ERROR_SUCCESS!=lRet) && (CoIsOle1Class(rclsid)) )
00142    {
00143      // We've got an OLE 1.0 class, so let's try to get the user type
00144      // name from the ProgID entry.
00145
00146      ProgIDFromCLSID(rclsid, &lpszProgID);
00147      fFreeProgID = TRUE;
00148
00149      dw = cch;
00150      W2A (lpszProgID, lpszAnsiProgID, 256);
00151      lRet = RegQueryValue(hKey, lpszAnsiProgID, lpszAnsiUserType, &dw);
00152      A2W (lpszAnsiUserType, lpszUserType, cch);
00153
00154      if ((LONG)ERROR_SUCCESS != lRet)
00155       dw = 0;
00156    }
00157
00158
00159    if (NOERROR == CoGetMalloc(MEMCTX_TASK, &lpIMalloc))
00160    {
00161       if (fFreeProgID)
00162        lpIMalloc->lpVtbl->Free(lpIMalloc, (LPVOID)lpszProgID);
00163
00164       lpIMalloc->lpVtbl->Free(lpIMalloc, (LPVOID)lpszCLSID);
00165       lpIMalloc->lpVtbl->Release(lpIMalloc);
00166    }
00167
00168    if (bCloseRegDB)
00169      RegCloseKey(hKey);
00170
00171    return (UINT)dw;
00172
00173 }
00174
00175
00176
00177 /*
00178  * OleStdGetAuxUserType(RCLSID, WORD, LPSTR, int, HKEY)
00179  *
00180  * Purpose:
00181  *  Returns the specified AuxUserType from the reg db.
00182  *
00183  * Parameters:
00184  *  rclsid          pointer to the clsid to retrieve aux user type of.
00185  *  hKey            hKey for reg db - if this is NULL, then we
00186  *                   open and close the reg db within this function.  If it
00187  *                   is non-NULL, then we assume it's a valid key to the
00188  *                   \ root and use it without closing it. (useful
00189  *                   if you're doing lots of reg db stuff).
00190  *  wAuxUserType    which aux user type field to look for.  In 4/93 release
00191  *                  2 is short name and 3 is exe name.
00192  *  lpszUserType    pointer to buffer to return user type in.
00193  *  cch             length of buffer pointed to by lpszUserType
00194  *
00195  * Return Value:
00196  *  UINT            Number of characters in returned string.  0 on error.
00197  *
00198  */
00199 STDAPI_(UINT) OleStdGetAuxUserType(REFCLSID rclsid,
00200                            WORD     wAuxUserType,
00201                            LPOLESTR lpszAuxUserType,
00202                            int      cch,
00203                            HKEY     hKey)
00204 {
00205    HKEY     hThisKey;
00206    BOOL     fCloseRegDB = FALSE;
00207    LONG     dw;
00208    LRESULT  lRet;
00209    LPOLESTR lpszCLSID;
00210    char     lpszAnsiCLSID[256];
00211    char     lpszAnsiAuxUserType[256];
00212    LPMALLOC lpIMalloc;
00213    char     szKey[OLEUI_CCHKEYMAX];
00214    char     szTemp[32];
00215
00216    lpszAnsiAuxUserType[0] = '\0';
00217
00218    if (NULL == hKey)
00219    {
00220      lRet = RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hThisKey);
00221
00222      if (ERROR_SUCCESS != lRet)
00223         return 0;
00224    }
00225    else
00226      hThisKey = hKey;
00227
00228    StringFromCLSID(rclsid, &lpszCLSID);
00229    W2A (lpszCLSID, lpszAnsiCLSID, 256);
00230
00231    lstrcpy(szKey, "CLSID\\");
00232    lstrcat(szKey, lpszAnsiCLSID);
00233    wsprintf(szTemp, "\\AuxUserType\\%d", wAuxUserType);
00234    lstrcat(szKey, szTemp);
00235
00236    dw = cch;
00237
00238    lRet = RegQueryValue(hThisKey, szKey, lpszAnsiAuxUserType, &dw);
00239
00240    if (ERROR_SUCCESS != lRet) {
00241     dw = 0;
00242     lpszAuxUserType[0] = '\0';
00243    }
00244
00245
00246    if (fCloseRegDB)
00247      RegCloseKey(hThisKey);
00248
00249    if (NOERROR == CoGetMalloc(MEMCTX_TASK, &lpIMalloc))
00250    {
00251       lpIMalloc->lpVtbl->Free(lpIMalloc, (LPVOID)lpszCLSID);
00252       lpIMalloc->lpVtbl->Release(lpIMalloc);
00253    }
00254
00255    A2W (lpszAnsiAuxUserType, lpszAuxUserType, cch);
00256    return (UINT)dw;
00257 }
00258
00259
00260
00261 /*
00262  * OleStdGetMiscStatusOfClass(REFCLSID, HKEY)
00263  *
00264  * Purpose:
00265  *  Returns the value of the misc status for the given clsid.
00266  *
00267  * Parameters:
00268  *  rclsid          pointer to the clsid to retrieve user type of.
00269  *  hKey            hKey for reg db - if this is NULL, then we
00270  *                   open and close the reg db within this function.  If it
00271  *                   is non-NULL, then we assume it's a valid key to the
00272  *                   \\CLSID root and use it without closing it. (useful
00273  *                   if you're doing lots of reg db stuff).
00274  *
00275  * Return Value:
00276  *  BOOL            TRUE on success, FALSE on failure.
00277  *
00278  */
00279 STDAPI_(BOOL) OleStdGetMiscStatusOfClass(REFCLSID rclsid, HKEY hKey, DWORD FAR * lpdwValue)
00280 {
00281    DWORD dw;
00282    LONG  lRet;
00283    LPOLESTR lpszCLSID;
00284    char     lpszAnsiCLSID[256];
00285    char  szKey[268];
00286    char  szMiscStatus[OLEUI_CCHKEYMAX];
00287    BOOL  bCloseRegDB = FALSE;
00288
00289    if (hKey == NULL)
00290    {
00291
00292     //Open up the root key.
00293     lRet=RegOpenKey(HKEY_CLASSES_ROOT, "CLSID", &hKey);
00294
00295     if ((LONG)ERROR_SUCCESS!=lRet)
00296       return FALSE;
00297
00298     bCloseRegDB = TRUE;
00299    }
00300
00301    // Get a string containing the class name
00302    StringFromCLSID(rclsid, &lpszCLSID);
00303    W2A (lpszCLSID, lpszAnsiCLSID, 256);
00304
00305    // Construct key
00306    lstrcpy(szKey, lpszAnsiCLSID);
00307    lstrcat(szKey, "\\MiscStatus");
00308
00309
00310    dw=OLEUI_CCHKEYMAX;
00311    lRet = RegQueryValue(hKey, szKey, /*(LPSTR)*/szMiscStatus, &dw);
00312
00313    if ((LONG)ERROR_SUCCESS!=lRet)
00314    {
00315       OleStdFreeString(lpszCLSID, NULL);
00316
00317       if (bCloseRegDB)
00318         RegCloseKey(hKey);
00319
00320       return FALSE;
00321
00322    }
00323
00324    *lpdwValue = Atol(/*(LPSTR)*/szMiscStatus);
00325
00326    OleStdFreeString(lpszCLSID, NULL);
00327
00328    if (bCloseRegDB)
00329      RegCloseKey(hKey);
00330
00331    return TRUE;
00332
00333
00334 }
00335
00336
00337 /*
00338  * CLIPFORMAT OleStdGetDefaultFileFormatOfClass(REFCLSID, HKEY)
00339  *
00340  * Purpose:
00341  *  Returns the default file format of the specified class.
00342  *  this is entered in REGDB as follows:
00343  *      CLSID\{...}\DataFormats\DefaultFile = <cfFmt>
00344  *
00345  * Parameters:
00346  *  rclsid          pointer to the clsid to retrieve user type of.
00347  *  hKey            hKey for reg db- if this is NULL, then we
00348  *                   open and close the reg db within this function.  If it
00349  *                   is non-NULL, then we assume it's a valid key to the
00350  *                   \ root and use it without closing it. (useful
00351  *                   if you're doing lots of reg db stuff).
00352  *
00353  * Return Value:
00354  *  cfFmt   -- DefaultFile format
00355  *  NULL    -- failed to get default file format
00356  *
00357  */
00358 STDAPI_(CLIPFORMAT) OleStdGetDefaultFileFormatOfClass(
00359       REFCLSID        rclsid,
00360       HKEY            hKey
00361 )
00362 {
00363    CLIPFORMAT cfFmt = 0;
00364    DWORD dw;
00365    LONG  lRet;
00366    LPOLESTR lpszCLSID;
00367    char     lpszAnsiCLSID[256];
00368    BOOL  bCloseRegDB = FALSE;
00369    char  szKey[128];
00370    char  szDefaultFile[OLEUI_CCHKEYMAX];
00371    BOOL  bStatus = TRUE;
00372
00373
00374    if (hKey == NULL)
00375    {
00376
00377     //Open up the root key.
00378     lRet=RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
00379
00380     if ((LONG)ERROR_SUCCESS!=lRet)
00381       return 0;
00382
00383     bCloseRegDB = TRUE;
00384    }
00385
00386
00387    // Get a string containing the class name
00388    StringFromCLSID(rclsid, &lpszCLSID);
00389    W2A (lpszCLSID, lpszAnsiCLSID, 256);
00390
00391    // Construct key
00392    wsprintf(szKey, "CLSID\\%s\\DataFormats\\DefaultFile", lpszCLSID);
00393    OleStdFreeString(lpszCLSID, NULL);
00394
00395    dw=OLEUI_CCHKEYMAX;
00396    lRet = RegQueryValue(hKey, szKey, /*(LPSTR)*/szDefaultFile, (LONG FAR *)&dw);
00397
00398    if ((LONG)ERROR_SUCCESS!=lRet)
00399       bStatus = FALSE;
00400    else {
00401       /* if the format is a number, then it should refer to one of the
00402       **    standard Windows formats.
00403       */
00404       if (isdigit(szDefaultFile[0]))
00405          cfFmt = (CLIPFORMAT)Atol(szDefaultFile);
00406       else
00407          cfFmt = RegisterClipboardFormat(szDefaultFile);
00408    }
00409
00410    if (bCloseRegDB)
00411      RegCloseKey(hKey);
00412
00413    return cfFmt;
00414 }
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/ImeMenu.c Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

ImeMenu.c

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      IMEMENU.C                                                     */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #include <windows.h>
00010 #include <commdlg.h>
00011 #include <commctrl.h>
00012 #include <imm.h>
00013 #include "resource.h"
00014 #include "imeapps.h"
00015
00016 LPDWORD lpdwIDTable = NULL;
00017 int nIDTable = 0;
00018
00019 /**********************************************************************/
00020 /*                                                                    */
00021 /*    EndMenuItemIDTable()                                            */
00022 /*                                                                    */
00023 /**********************************************************************/
00024 void EndMenuItemIDTable()
00025 {
00026     if (lpdwIDTable)
00027     {
00028         GlobalFree((HANDLE)lpdwIDTable);
00029         lpdwIDTable = NULL;
00030     }
00031
00032     nIDTable = 0;
00033 }
00034
00035 /**********************************************************************/
00036 /*                                                                    */
00037 /*    InitMenuItemIDTable()                                           */
00038 /*                                                                    */
00039 /**********************************************************************/
00040 void InitMenuItemIDTable()
00041 {
00042     EndMenuItemIDTable();
00043     lpdwIDTable = GlobalAlloc(GPTR, 100 * 2 * sizeof(DWORD));
00044 }
00045
00046 /**********************************************************************/
00047 /*                                                                    */
00048 /*    AddIDTableEntry()                                               */
00049 /*                                                                    */
00050 /**********************************************************************/
00051 void AddIDTableEntry(UINT wID, DWORD dwItemData)
00052 {
00053     *(lpdwIDTable+(nIDTable*2)) = wID;
00054     *(lpdwIDTable+(nIDTable*2)+1) = dwItemData;
00055     nIDTable++;
00056 }
00057
00058 /**********************************************************************/
00059 /*                                                                    */
00060 /*    FindItemData()                                                  */
00061 /*                                                                    */
00062 /**********************************************************************/
00063 DWORD FindItemData(UINT wID)
00064 {
00065     int i;
00066     for (i = 0; i < nIDTable ; i++)
00067     {
00068         if (*(lpdwIDTable+(i*2)) == wID)
00069         {
00070             return *(lpdwIDTable+(i*2)+1);
00071         }
00072     }
00073     return 0;
00074 }
00075
00076
00077 /**********************************************************************/
00078 /*                                                                    */
00079 /*    FillMenuItemInfo()                                              */
00080 /*                                                                    */
00081 /**********************************************************************/
00082 void FillMenuItemInfo(HWND hWnd, HIMC hIMC, LPMENUITEMINFO lpmii, LPMYIMEMENUITEMINFO lpIme, BOOL fRight)
00083 {
00084     FillMemory((PVOID)lpmii, sizeof(MENUITEMINFO), 0);
00085     lpmii->cbSize = sizeof(MENUITEMINFO);
00086     lpmii->fMask = 0;
00087
00088     // Set fType;
00089     if (lpIme->fType)
00090     {
00091         lpmii->fMask |= MIIM_TYPE;
00092         lpmii->fType = 0;
00093
00094         if (lpIme->fType & IMFT_RADIOCHECK)
00095         {
00096             lpmii->fType |= MFT_RADIOCHECK;
00097         }
00098
00099         if (lpIme->fType & IMFT_SEPARATOR)
00100         {
00101             lpmii->fType |= MFT_SEPARATOR;
00102         }
00103
00104     }
00105
00106     lpmii->fMask |= MIIM_ID;
00107     lpmii->wID = lpIme->wID + IDM_STARTIMEMENU;
00108
00109     if (lpIme->fType & IMFT_SUBMENU)
00110     {
00111         lpmii->fMask |= MIIM_SUBMENU;
00112         lpmii->hSubMenu = CreateImeMenu(hWnd, hIMC, lpIme, fRight);
00113     }
00114
00115     lpmii->fMask |= MIIM_STATE;
00116     lpmii->fState = lpIme->fState;
00117
00118     if (lpIme->hbmpChecked &&  lpIme->hbmpUnchecked)
00119     {
00120        lpmii->fMask |= MIIM_CHECKMARKS;
00121        lpmii->hbmpChecked = lpIme->hbmpChecked;
00122        lpmii->hbmpUnchecked = lpIme->hbmpUnchecked;
00123     }
00124
00125
00126     lpmii->fMask |= MIIM_DATA;
00127     lpmii->dwItemData = lpIme->dwItemData;
00128
00129     if (lpIme->hbmpItem)
00130     {
00131        lpmii->fMask |= MIIM_BITMAP;
00132        lpmii->hbmpItem = lpIme->hbmpItem;
00133     }
00134
00135
00136 #ifdef USEWAPI
00137     {
00138         BOOL bUDC;
00139         int i;
00140         char   szTemp[IMEMENUITEM_STRING_SIZE] = {0};
00141
00142         i = WideCharToMultiByte(CP_ACP,
00143                                 0,
00144                                 lpIme->szString,
00145                                 (int)wcslen(lpIme->szString),
00146                                 szTemp,
00147                                 IMEMENUITEM_STRING_SIZE,
00148                                 (LPSTR)NULL,
00149                                 &bUDC);
00150         szTemp[i] = '\0';
00151
00152         if (lstrlen(szTemp))
00153         {
00154             lpmii->fMask |= MIIM_STRING;
00155             lstrcpyn((LPSTR)lpIme->szString, szTemp, IMEMENUITEM_STRING_SIZE-1);
00156             lpmii->dwTypeData = (LPSTR)lpIme->szString;
00157             lpmii->cch = lstrlen((LPSTR)lpIme->szString);
00158         }
00159     }
00160 #else
00161     if (lstrlen(lpIme->szString))
00162     {
00163         lpmii->fMask |= MIIM_STRING;
00164         lpmii->dwTypeData = lpIme->szString;
00165         lpmii->cch = lstrlen(lpIme->szString);
00166     }
00167 #endif
00168
00169 }
00170
00171 /**********************************************************************/
00172 /*                                                                    */
00173 /*    CreateImeMenu()                                                 */
00174 /*                                                                    */
00175 /**********************************************************************/
00176 HMENU CreateImeMenu(HWND hWnd, HIMC hIMC, LPMYIMEMENUITEMINFO lpImeParentMenu, BOOL fRight)
00177 {
00178     HMENU hMenu = NULL;
00179     DWORD dwSize, dwNum, dwI;
00180     MENUITEMINFO mii = {0};
00181     LPMYIMEMENUITEMINFO lpImeMenu = NULL;
00182
00183
00184     dwNum = MyImmGetImeMenuItems(hIMC, fRight ? IGIMIF_RIGHTMENU : 0,
00185                                  IGIMII_CMODE |
00186                                  IGIMII_SMODE |
00187                                  IGIMII_CONFIGURE |
00188                                  IGIMII_TOOLS |
00189                                  IGIMII_HELP |
00190                                  IGIMII_OTHER,
00191                                  lpImeParentMenu, NULL, 0);
00192
00193     if (!dwNum)
00194     {
00195         return 0;
00196     }
00197
00198
00199
00200     dwSize = dwNum * sizeof(MYIMEMENUITEMINFO);
00201
00202     lpImeMenu = (LPMYIMEMENUITEMINFO)GlobalAlloc(GPTR, dwSize);
00203
00204     dwNum = MyImmGetImeMenuItems(hIMC, fRight ? IGIMIF_RIGHTMENU : 0,
00205                                  IGIMII_CMODE |
00206                                  IGIMII_SMODE |
00207                                  IGIMII_CONFIGURE |
00208                                  IGIMII_TOOLS |
00209                                  IGIMII_HELP |
00210                                  IGIMII_OTHER,
00211                                  lpImeParentMenu, lpImeMenu, dwSize);
00212
00213
00214     hMenu = CreatePopupMenu();
00215
00216     for (dwI = 0 ; dwI < dwNum; dwI++)
00217     {
00218         AddIDTableEntry(lpImeMenu->wID, lpImeMenu->dwItemData);
00219         FillMenuItemInfo(hWnd, hIMC, &mii, lpImeMenu + dwI, fRight);
00220         InsertMenuItem(hMenu, dwI, TRUE, &mii);
00221     }
00222
00223     GlobalFree((HANDLE)lpImeMenu);
00224
00225
00226     return hMenu;
00227 }
00228
00229
00230
00231
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

mib_entry Member List

This is the complete list of members for mib_entry, including all inherited members.
Access | mib_entry
MibFunc | mib_entry
MibNext | mib_entry
Oid | mib_entry
Storage | mib_entry
Type | mib_entry
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/row.h Source File

  • Dataaccess
  • oledb
  • sampprov

row.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module ROW.H | ROW base object and contained interface
00008 // definitions
00009 //
00010 //
00011
00012 #ifndef _ROW_H_
00013 #define _ROW_H_
00014
00015
00016 #include "baseobj.h"
00017
00018 // #defines ------------------------------------------------------------------
00019
00020 // number of extra columns supported on a row object
00021 #define EXTRA_COLUMNS     1
00022 // The default stream is the first extra column
00023 #define DEFAULT_STREAM      0
00024 #define DEFAULT_STREAM_ORDINAL  1
00025
00026 // Forward declarations ------------------------------------------------------
00027
00028 class CImpIRow;
00029 class CImpIColumnsInfo;
00030 class CImpIConvertType;
00031 class CImpIGetSession;
00032 class CImpIRowChange;
00033
00034 typedef CImpIRow*     PIMPIROW;
00035 typedef CImpIColumnsInfo* PIMPICOLUMNSINFO;
00036 typedef CImpIConvertType* PIMPCONVERTTYPE;
00037 typedef CImpIGetSession*  PIMPIGETSESSION;
00038 typedef CImpIRowChange*   PIMPIROWCHANGE;
00039
00040
00041 // Classes -------------------------------------------------------------------
00042
00043 //----------------------------------------------------------------------------
00044 // @class CRow | Row object. Containing class for all interfaces on the Row
00045 // Object
00046 //
00047 class CRow : public CBaseObj          //@base public | CBaseObj
00048 {
00049   //  Contained interfaces are friends
00050   friend class CImpIRow;
00051   friend class CImpIColumnsInfo;
00052   friend class CImpIConvertType;
00053   friend class CImpIGetSession;
00054   friend class CImpIRowChange;
00055
00056   // Stream object interfaces are friends
00057   // since stream objects always have implicit rowset context
00058   friend class CStream;
00059
00060   protected: //@access protected
00061     //@cmember parent Object (either Rowset or Session)
00062     CBaseObj *            m_pParentObj;
00063     //@cmember associated Row Handle
00064     HROW              m_hRow;
00065     //@cmember File Manipulation Class
00066     CFileIO *           m_pFileio;
00067     //@cmember Row buffer size
00068     DBLENGTH            m_cbRowSize;
00069     //@cmember ptr to the row buffer
00070     BYTE *              m_pRowBuff;
00071     //@cmember count of Extra columns
00072     DBORDINAL           m_cExtraCols;
00073     //@cmember array of Extra dbcolumninfo structs
00074     DBCOLUMNINFO          m_rgExtracolinfo[EXTRA_COLUMNS];
00075
00076     // Interface and OLE Variables
00077
00078     //@cmember Reference count
00079     DBREFCOUNT            m_cRef;
00080     //@cmember Contained IRow
00081     PIMPIROW            m_pIRow;
00082     //@cmember Contained IColumnsInfo
00083     PIMPICOLUMNSINFO        m_pIColumnsInfo;
00084     //@cmember Contained IConvertType
00085     PIMPICONVERTTYPE        m_pIConvertType;
00086     //@cmember Contained IGetSession
00087     PIMPIGETSESSION         m_pIGetSession;
00088     //@cmember Contained IRowChange
00089     PIMPIROWCHANGE          m_pIRowChange;
00090
00091   public: //@access public
00092     //@cmember Constructor
00093     CRow(LPUNKNOWN);
00094     //@cmember Destructor
00095     virtual ~CRow(void);
00096
00097     //@cmember Init row object that is a part of a rowset
00098     BOOL      FInit(CRowset*);
00099     //@cmember Init row object that is a result of a direct bind
00100     BOOL      FInit(CDBSession*, CFileIO*, DBCOUNTITEM);
00101     //@cmember Set the row object row handle value
00102     STDMETHODIMP  SetRowHandle(HROW);
00103     //@cmember Return m_pFileio
00104     CFileIO *   GetFileObj();
00105     //@cmember Return underlying ROWBUFF
00106     ROWBUFF *   GetRowBuff();
00107     //@cmember Return true if columnID is valid
00108     BOOL      GetColumnOrdinal(CFileIO*, DBID*, DBORDINAL*);
00109     //@cmember Return m_cExtraCols
00110     inline DBORDINAL    GetExtraColCount() { return m_cExtraCols; };
00111     //@cmember Return
00112     inline DBCOLUMNINFO * GetExtraColumnInfo() { return m_rgExtracolinfo; };
00113
00114     //  Object's base IUnknown
00115     //@cmember Request an Interface
00116     STDMETHODIMP        QueryInterface(REFIID, LPVOID *);
00117     //@cmember Increments the Reference count
00118     STDMETHODIMP_(DBREFCOUNT) AddRef(void);
00119     //@cmember Decrements the Reference count
00120     STDMETHODIMP_(DBREFCOUNT) Release(void);
00121 };
00122
00123
00124 //----------------------------------------------------------------------------
00125 // @class CImpIRow | Contained IRow class
00126 //
00127 class CImpIRow : public IRow    //@base public | IRow
00128 {
00129   private: //@access private
00130     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRow)
00131
00132   public: //@access public
00133     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRow, CImpIRow);
00134     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00135
00136     //  IRow members
00137     //@cmember GetColumns Method
00138     STDMETHODIMP GetColumns(DBORDINAL cColumns, DBCOLUMNACCESS rgColumns[]);
00139
00140     //@cmember GetSourceRowset Method
00141     STDMETHODIMP GetSourceRowset(REFIID riid, IUnknown ** ppRowset, HROW * phRow);
00142
00143     //@cmember Open Method
00144     STDMETHODIMP Open
00145           (
00146             IUnknown *  pIUnkOuter,
00147             DBID *    pColumnID,
00148             REFGUID   rguidColumnType,
00149             DWORD   dwBindFlags,
00150             REFIID    riid,
00151             IUnknown ** ppUnk
00152           );
00153 };
00154
00155
00156 //----------------------------------------------------------------------------
00157 // @class CImpIGetSession | Contained IGetSession class
00158 //
00159 class CImpIGetSession : public IGetSession    //@base public | IGetSession
00160 {
00161   private: //@access private
00162     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRow)
00163
00164   public: //@access public
00165     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRow, CImpIGetSession);
00166     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00167
00168     //  IGetSession members
00169     //@cmember GetSessionMethod
00170         STDMETHODIMP  GetSession(REFIID riid, IUnknown ** ppSession);
00171 };
00172
00173
00174 //----------------------------------------------------------------------------
00175 // @class CImpIRowChange | Contained IRowChange class
00176 //
00177 class CImpIRowChange : public IRowChange    //@base public | IRowChange
00178 {
00179   private: //@access private
00180     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRow)
00181
00182   public: //@access public
00183     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRow, CImpIRowChange);
00184     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00185
00186     // IRowChange members
00187     //@cmember SetColumns method
00188     STDMETHODIMP SetColumns(DBORDINAL cColumns, DBCOLUMNACCESS rgColumns[]);
00189 };
00190
00191
00192 #endif //_ROW_H_
00193
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authentication/MSVSubAuth/SubAuth.c Source File

  • Security
  • Authentication
  • MSVSubAuth

SubAuth.c

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1987 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010     subauth.c
00011
00012 Abstract:
00013     Sample SubAuthentication Package.
00014
00015 Environment:
00016     User mode only.
00017     Contains NT-specific code.
00018     Requires ANSI C extensions: slash-slash comments, long external names.
00019
00020 --*/
00021
00022
00023 #if ( _MSC_VER >= 800 )
00024 #pragma warning ( 3 : 4100 ) // enable "Unreferenced formal parameter"
00025 #pragma warning ( 3 : 4219 ) // enable "trailing ',' used for variable argument list"
00026 #endif
00027
00028 #include <windef.h>
00029 #include <windows.h>
00030 #include <lmcons.h>
00031 #include <lmaccess.h>
00032 #include <lmapibuf.h>
00033 #include <subauth.h>
00034
00035
00036 BOOLEAN
00037 EqualComputerName(
00038     IN PUNICODE_STRING String1,
00039     IN PUNICODE_STRING String2
00040     );
00041
00042 NTSTATUS
00043 QuerySystemTime (
00044     OUT PLARGE_INTEGER SystemTime
00045     );
00046
00047
00048 BOOL
00049 GetPasswordExpired(
00050     IN LARGE_INTEGER PasswordLastSet,
00051     IN LARGE_INTEGER MaxPasswordAge
00052     );
00053
00054 NTSTATUS
00055 AccountRestrictions(
00056     IN ULONG UserRid,
00057     IN PUNICODE_STRING LogonWorkStation,
00058     IN PUNICODE_STRING WorkStations,
00059     IN PLOGON_HOURS LogonHours,
00060     OUT PLARGE_INTEGER LogoffTime,
00061     OUT PLARGE_INTEGER KickoffTime
00062     );
00063
00064 LARGE_INTEGER
00065 NetpSecondsToDeltaTime(
00066     IN ULONG Seconds
00067     );
00068
00069 VOID
00070 InitUnicodeString(
00071     OUT PUNICODE_STRING DestinationString,
00072     IN PCWSTR SourceString OPTIONAL
00073     );
00074
00075 VOID
00076 CopyUnicodeString(
00077     OUT PUNICODE_STRING DestinationString,
00078     IN PUNICODE_STRING SourceString OPTIONAL
00079     );
00080
00081
00082
00083 NTSTATUS
00084 NTAPI
00085 Msv1_0SubAuthenticationRoutine (
00086     IN NETLOGON_LOGON_INFO_CLASS LogonLevel,
00087     IN PVOID LogonInformation,
00088     IN ULONG Flags,
00089     IN PUSER_ALL_INFORMATION UserAll,
00090     OUT PULONG WhichFields,
00091     OUT PULONG UserFlags,
00092     OUT PBOOLEAN Authoritative,
00093     OUT PLARGE_INTEGER LogoffTime,
00094     OUT PLARGE_INTEGER KickoffTime
00095 )
00096 /*++
00097
00098 Routine Description:
00099
00100     The subauthentication routine does client/server specific authentication
00101     of a user. The credentials of the user are passed in addition to all the
00102     information from SAM defining the user. This routine decides whether to
00103     let the user log on.
00104
00105
00106 Arguments:
00107
00108     LogonLevel -- Specifies the level of information given in
00109         LogonInformation.
00110
00111     LogonInformation -- Specifies the description for the user
00112         logging on.  The LogonDomainName field should be ignored.
00113
00114     Flags - Flags describing the circumstances of the logon.
00115
00116         MSV1_0_PASSTHRU -- This is a PassThru authenication.  (i.e., the
00117             user isn't connecting to this machine.)
00118         MSV1_0_GUEST_LOGON -- This is a retry of the logon using the GUEST
00119             user account.
00120
00121     UserAll -- The description of the user as returned from SAM.
00122
00123     WhichFields -- Returns which fields from UserAllInfo are to be written
00124         back to SAM.  The fields will only be written if MSV returns success
00125         to it's caller.  Only the following bits are valid.
00126
00127         USER_ALL_PARAMETERS - Write UserAllInfo->Parameters back to SAM.  If
00128             the size of the buffer is changed, Msv1_0SubAuthenticationRoutine
00129             must delete the old buffer using MIDL_user_free() and reallocate the
00130             buffer using MIDL_user_allocate().
00131
00132     UserFlags -- Returns UserFlags to be returned from LsaLogonUser in the
00133         LogonProfile.  The following bits are currently defined:
00134
00135
00136             LOGON_GUEST -- This was a guest logon
00137             LOGON_NOENCRYPTION -- The caller didn't specify encrypted credentials
00138
00139         SubAuthentication packages should restrict themselves to returning
00140         bits in the high order byte of UserFlags.  However, this convention
00141         isn't enforced giving the SubAuthentication package more flexibility.
00142
00143     Authoritative -- Returns whether the status returned is an
00144         authoritative status which should be returned to the original
00145         caller.  If not, this logon request may be tried again on another
00146         domain controller.  This parameter is returned regardless of the
00147         status code.
00148
00149     LogoffTime - Receives the time at which the user should log off the
00150         system.  This time is specified as a GMT relative NT system time.
00151
00152     KickoffTime - Receives the time at which the user should be kicked
00153         off the system. This time is specified as a GMT relative system
00154         time.  Specify, a full scale positive number if the user isn't to
00155         be kicked off.
00156
00157 Return Value:
00158
00159     STATUS_SUCCESS: if there was no error.
00160
00161     STATUS_NO_SUCH_USER: The specified user has no account.
00162     STATUS_WRONG_PASSWORD: The password was invalid.
00163
00164     STATUS_INVALID_INFO_CLASS: LogonLevel is invalid.
00165     STATUS_ACCOUNT_LOCKED_OUT: The account is locked out
00166     STATUS_ACCOUNT_DISABLED: The account is disabled
00167     STATUS_ACCOUNT_EXPIRED: The account has expired.
00168     STATUS_PASSWORD_MUST_CHANGE: Account is marked as Password must change
00169         on next logon.
00170     STATUS_PASSWORD_EXPIRED: The Password is expired.
00171     STATUS_INVALID_LOGON_HOURS - The user is not authorized to log on at
00172         this time.
00173     STATUS_INVALID_WORKSTATION - The user is not authorized to log on to
00174         the specified workstation.
00175
00176 --*/
00177 {
00178     NTSTATUS Status;
00179     ULONG UserAccountControl;
00180     LARGE_INTEGER LogonTime;
00181     UNICODE_STRING LocalWorkstation;
00182
00183     PNETLOGON_NETWORK_INFO LogonNetworkInfo;
00184
00185
00186     //
00187     // Check whether the SubAuthentication package supports this type
00188     //  of logon.
00189     //
00190
00191     *Authoritative = TRUE;
00192     *UserFlags = 0;
00193     *WhichFields = 0;
00194
00195     (VOID) QuerySystemTime( &LogonTime );
00196
00197     switch ( LogonLevel ) {
00198     case NetlogonInteractiveInformation:
00199     case NetlogonServiceInformation:
00200
00201         //
00202         // This SubAuthentication package only supports network logons.
00203         //
00204
00205         return STATUS_INVALID_INFO_CLASS;
00206
00207     case NetlogonNetworkInformation:
00208
00209         //
00210         // This SubAuthentication package doesn't support access via machine
00211         // accounts.
00212         //
00213
00214         UserAccountControl = USER_NORMAL_ACCOUNT;
00215
00216         //
00217         // Local user (Temp Duplicate) accounts are only used on the machine
00218         // being directly logged onto.
00219         // (Nor are interactive or service logons allowed to them.)
00220         //
00221
00222         if ( (Flags & MSV1_0_PASSTHRU) == 0 ) {
00223             UserAccountControl |= USER_TEMP_DUPLICATE_ACCOUNT;
00224         }
00225
00226         LogonNetworkInfo = (PNETLOGON_NETWORK_INFO) LogonInformation;
00227
00228         break;
00229
00230     default:
00231         *Authoritative = TRUE;
00232         return STATUS_INVALID_INFO_CLASS;
00233     }
00234
00235
00236
00237
00238     //
00239     // If the account type isn't allowed,
00240     //  Treat this as though the User Account doesn't exist.
00241     //
00242
00243     if ( (UserAccountControl & UserAll->UserAccountControl) == 0 ) {
00244         *Authoritative = FALSE;
00245         Status = STATUS_NO_SUCH_USER;
00246         goto Cleanup;
00247     }
00248
00249     //
00250     // This SubAuthentication package doesn't allow guest logons.
00251     //
00252     if ( Flags & MSV1_0_GUEST_LOGON ) {
00253         *Authoritative = FALSE;
00254         Status = STATUS_NO_SUCH_USER;
00255         goto Cleanup;
00256     }
00257
00258
00259
00260     //
00261     // Ensure the account isn't locked out.
00262     //
00263
00264     if ( UserAll->UserId != DOMAIN_USER_RID_ADMIN &&
00265          (UserAll->UserAccountControl & USER_ACCOUNT_AUTO_LOCKED) ) {
00266
00267         //
00268         // Since the UI strongly encourages admins to disable user
00269         // accounts rather than delete them.  Treat disabled acccount as
00270         // non-authoritative allowing the search to continue for other
00271         // accounts by the same name.
00272         //
00273         if ( UserAll->UserAccountControl & USER_ACCOUNT_DISABLED ) {
00274             *Authoritative = FALSE;
00275         } else {
00276             *Authoritative = TRUE;
00277         }
00278         Status = STATUS_ACCOUNT_LOCKED_OUT;
00279         goto Cleanup;
00280     }
00281
00282
00283     //
00284     // Check the password.
00285     //
00286
00287     if ( FALSE /* VALIDATE THE USER'S PASSWORD HERE */ ) {
00288
00289         Status = STATUS_WRONG_PASSWORD;
00290
00291         //
00292         // Since the UI strongly encourages admins to disable user
00293         // accounts rather than delete them.  Treat disabled acccount as
00294         // non-authoritative allowing the search to continue for other
00295         // accounts by the same name.
00296         //
00297         if ( UserAll->UserAccountControl & USER_ACCOUNT_DISABLED ) {
00298             *Authoritative = FALSE;
00299         } else {
00300             *Authoritative = TRUE;
00301         }
00302
00303         goto Cleanup;
00304     }
00305
00306     //
00307     // Prevent some things from effecting the Administrator user
00308     //
00309
00310     if (UserAll->UserId == DOMAIN_USER_RID_ADMIN) {
00311
00312         //
00313         //  The administrator account doesn't have a forced logoff time.
00314         //
00315
00316         LogoffTime->HighPart = 0x7FFFFFFF;
00317         LogoffTime->LowPart = 0xFFFFFFFF;
00318
00319         KickoffTime->HighPart = 0x7FFFFFFF;
00320         KickoffTime->LowPart = 0xFFFFFFFF;
00321
00322     } else {
00323
00324         //
00325         // Check if the account is disabled.
00326         //
00327
00328         if ( UserAll->UserAccountControl & USER_ACCOUNT_DISABLED ) {
00329             //
00330             // Since the UI strongly encourages admins to disable user
00331             // accounts rather than delete them.  Treat disabled acccount as
00332             // non-authoritative allowing the search to continue for other
00333             // accounts by the same name.
00334             //
00335             *Authoritative = FALSE;
00336             Status = STATUS_ACCOUNT_DISABLED;
00337             goto Cleanup;
00338         }
00339
00340         //
00341         // Check if the account has expired.
00342         //
00343
00344         if ( UserAll->AccountExpires.QuadPart != 0 &&
00345              LogonTime.QuadPart >= UserAll->AccountExpires.QuadPart ) {
00346             *Authoritative = TRUE;
00347             Status = STATUS_ACCOUNT_EXPIRED;
00348             goto Cleanup;
00349         }
00350
00351 #if 1
00352
00353     //
00354     //  If your using SAM's password expiration date, use this code, otherwise
00355     //  use the code below and supply your own password set date...
00356     //
00357
00358         //
00359         // The password is valid, check to see if the password is expired.
00360         //  (SAM will have appropriately set PasswordMustChange to reflect
00361         //  USER_DONT_EXPIRE_PASSWORD)
00362         //
00363         // If the password checked above is not the SAM password, you may
00364         // want to consider not checking the SAM password expiration times here.
00365         //
00366
00367         if ( LogonTime.QuadPart >= UserAll->PasswordMustChange.QuadPart ) {
00368
00369             if ( UserAll->PasswordLastSet.QuadPart == 0 ) {
00370                 Status = STATUS_PASSWORD_MUST_CHANGE;
00371             } else {
00372                 Status = STATUS_PASSWORD_EXPIRED;
00373             }
00374             *Authoritative = TRUE;
00375             goto Cleanup;
00376         }
00377
00378 #else
00379
00380         //
00381         // Response is correct. So, check if the password has expired or not
00382         //
00383
00384         if (! (UserAll->UserAccountControl & USER_DONT_EXPIRE_PASSWORD)) {
00385             LARGE_INTEGER MaxPasswordAge;
00386             MaxPasswordAge.HighPart = 0x7FFFFFFF;
00387             MaxPasswordAge.LowPart = 0xFFFFFFFF;
00388
00389             //
00390             // PasswordDateSet should be modified to hold the last date the
00391             // user's password was set.
00392             //
00393
00394             PasswordDateSet.LowPart = 0;
00395             PasswordDateSet.HighPart = 0;
00396
00397             if ( GetPasswordExpired( PasswordDateSet,
00398                         MaxPasswordAge )) {
00399
00400                 Status = STATUS_PASSWORD_EXPIRED;
00401                 goto Cleanup;
00402             }
00403         }
00404
00405 #endif
00406
00407
00408 #if 1
00409
00410     //
00411     // Validate the workstation the user logged on from.
00412     //
00413     // Ditch leading \\ on workstation name before passing it to SAM.
00414     //
00415
00416     LocalWorkstation = LogonNetworkInfo->Identity.Workstation;
00417     if ( LocalWorkstation.Length > 0 &&
00418          LocalWorkstation.Buffer[0] == L'\\' &&
00419          LocalWorkstation.Buffer[1] == L'\\' ) {
00420         LocalWorkstation.Buffer += 2;
00421         LocalWorkstation.Length -= 2*sizeof(WCHAR);
00422         LocalWorkstation.MaximumLength -= 2*sizeof(WCHAR);
00423     }
00424
00425
00426     //
00427     //  To validate the user's logon hours as SAM does it, use this code,
00428     //  otherwise, supply your own checks below this code.
00429     //
00430
00431     Status = AccountRestrictions( UserAll->UserId,
00432                                   &LocalWorkstation,
00433                                   (PUNICODE_STRING) &UserAll->WorkStations,
00434                                   &UserAll->LogonHours,
00435                                   LogoffTime,
00436                                   KickoffTime );
00437
00438     if ( !NT_SUCCESS( Status )) {
00439         goto Cleanup;
00440     }
00441
00442 #else
00443
00444         //
00445         // Validate the user's logon hours.
00446         //
00447
00448         if ( TRUE /* VALIDATE THE LOGON HOURS */ ) {
00449
00450
00451             //
00452             // All times are allowed, so there's no logoff
00453             // time.  Return forever for both logofftime and
00454             // kickofftime.
00455             //
00456
00457             LogoffTime->HighPart = 0x7FFFFFFF;
00458             LogoffTime->LowPart = 0xFFFFFFFF;
00459
00460             KickoffTime->HighPart = 0x7FFFFFFF;
00461             KickoffTime->LowPart = 0xFFFFFFFF;
00462         } else {
00463             Status = STATUS_INVALID_LOGON_HOURS;
00464             *Authoritative = TRUE;
00465             goto Cleanup;
00466         }
00467 #endif
00468
00469         //
00470         // Validate if the user can log on from this workstation.
00471         //  (Supply subauthentication package specific code here.)
00472
00473         if ( LogonNetworkInfo->Identity.Workstation.Buffer == NULL ) {
00474             Status = STATUS_INVALID_WORKSTATION;
00475             *Authoritative = TRUE;
00476             goto Cleanup;
00477         }
00478     }
00479
00480
00481     //
00482     // The user is valid.
00483     //
00484
00485     *Authoritative = TRUE;
00486     Status = STATUS_SUCCESS;
00487
00488     //
00489     // Cleanup up before returning.
00490     //
00491
00492 Cleanup:
00493
00494     return Status;
00495
00496 }  // Msv1_0SubAuthenticationRoutine
00497
00498
00499
00500
00501 BOOL
00502 GetPasswordExpired (
00503     IN LARGE_INTEGER PasswordLastSet,
00504     IN LARGE_INTEGER MaxPasswordAge
00505     )
00506
00507 /*++
00508
00509 Routine Description:
00510
00511     This routine returns true if the password is expired, false otherwise.
00512
00513 Arguments:
00514
00515     PasswordLastSet - Time when the password was last set for this user.
00516
00517     MaxPasswordAge - Maximum password age for any password in the domain.
00518
00519 Return Value:
00520
00521     Returns true if password is expired.  False if not expired.
00522
00523 --*/
00524 {
00525     LARGE_INTEGER PasswordMustChange;
00526     NTSTATUS Status;
00527     BOOLEAN rc;
00528     LARGE_INTEGER TimeNow;
00529
00530     //
00531     // Compute the expiration time as the time the password was
00532     // last set plus the maximum age.
00533     //
00534
00535     if ( PasswordLastSet.QuadPart < 0 || MaxPasswordAge.QuadPart > 0 ) {
00536
00537         rc = TRUE;      // default for invalid times is that it is expired.
00538
00539     } else {
00540
00541         __try {
00542
00543             PasswordMustChange.QuadPart =
00544                 PasswordLastSet.QuadPart - MaxPasswordAge.QuadPart;
00545             //
00546             // Limit the resultant time to the maximum valid absolute time
00547             //
00548
00549             if ( PasswordMustChange.QuadPart < 0 ) {
00550
00551                 rc = FALSE;
00552
00553             } else {
00554
00555                 Status = QuerySystemTime( &TimeNow );
00556                 if (NT_SUCCESS(Status)) {
00557
00558                     if ( TimeNow.QuadPart >= PasswordMustChange.QuadPart ) {
00559                         rc = TRUE;
00560
00561                     } else {
00562
00563                         rc = FALSE;
00564                     }
00565                 } else {
00566                     rc = FALSE;     // won't fail if QuerySystemTime failed.
00567                 }
00568             }
00569
00570         } __except(EXCEPTION_EXECUTE_HANDLER) {
00571
00572             rc = TRUE;
00573         }
00574     }
00575
00576     return rc;
00577
00578 }  // GetPasswordExpired
00579
00580
00581 NTSTATUS
00582 QuerySystemTime (
00583     OUT PLARGE_INTEGER SystemTime
00584     )
00585
00586 /*++
00587
00588 Routine Description:
00589
00590     This function returns the absolute system time. The time is in units of
00591     100nsec ticks since the base time which is midnight January 1, 1601.
00592
00593 Arguments:
00594
00595     SystemTime - Supplies the address of a variable that will receive the
00596         current system time.
00597
00598 Return Value:
00599
00600     STATUS_SUCCESS is returned if the service is successfully executed.
00601
00602     STATUS_ACCESS_VIOLATION is returned if the output parameter for the
00603         system time cannot be written.
00604
00605 --*/
00606
00607 {
00608     SYSTEMTIME CurrentTime;
00609
00610     GetSystemTime( &CurrentTime );
00611
00612     if ( !SystemTimeToFileTime( &CurrentTime, (LPFILETIME) SystemTime ) ) {
00613         return STATUS_ACCESS_VIOLATION;
00614     }
00615
00616     return STATUS_SUCCESS;
00617 }
00618
00619 NTSTATUS
00620 SampMatchworkstation(
00621     IN PUNICODE_STRING LogonWorkStation,
00622     IN PUNICODE_STRING WorkStations
00623     )
00624
00625 /*++
00626
00627 Routine Description:
00628
00629     Check if the given workstation is a member of the list of workstations
00630     given.
00631
00632
00633 Arguments:
00634
00635     LogonWorkStations - UNICODE name of the workstation that the user is
00636         trying to log into.
00637
00638     WorkStations - API list of workstations that the user is allowed to
00639         log into.
00640
00641
00642 Return Value:
00643
00644
00645     STATUS_SUCCESS - The user is allowed to log into the workstation.
00646
00647
00648
00649 --*/
00650 {
00651     PWCHAR          WorkStationName;
00652     UNICODE_STRING  Unicode;
00653     NTSTATUS        NtStatus;
00654     WCHAR           Buffer[256];
00655     USHORT          LocalBufferLength = 256;
00656     UNICODE_STRING  WorkStationsListCopy;
00657     BOOLEAN         BufferAllocated = FALSE;
00658     PWCHAR          TmpBuffer;
00659
00660     //
00661     // Local workstation is always allowed
00662     // If WorkStations field is 0 everybody is allowed
00663     //
00664
00665     if ( ( LogonWorkStation == NULL ) ||
00666         ( LogonWorkStation->Length == 0 ) ||
00667         ( WorkStations->Length == 0 ) ) {
00668
00669         return( STATUS_SUCCESS );
00670     }
00671
00672     //
00673     // Assume failure; change status only if we find the string.
00674     //
00675
00676     NtStatus = STATUS_INVALID_WORKSTATION;
00677
00678     //
00679     // WorkStationApiList points to our current location in the list of
00680     // WorkStations.
00681     //
00682
00683     if ( WorkStations->Length > LocalBufferLength ) {
00684
00685         WorkStationsListCopy.Buffer = LocalAlloc( 0, WorkStations->Length );
00686         BufferAllocated = TRUE;
00687
00688         if ( WorkStationsListCopy.Buffer == NULL ) {
00689             NtStatus = STATUS_INSUFFICIENT_RESOURCES;
00690             return( NtStatus );
00691         }
00692
00693         WorkStationsListCopy.MaximumLength = WorkStations->Length;
00694
00695     } else {
00696
00697         WorkStationsListCopy.Buffer = Buffer;
00698         WorkStationsListCopy.MaximumLength = LocalBufferLength;
00699     }
00700
00701     CopyUnicodeString( &WorkStationsListCopy, WorkStations );
00702
00703     //
00704     // wcstok requires a string the first time it's called, and NULL
00705     // for all subsequent calls.  Use a temporary variable so we
00706     // can do this.
00707     //
00708
00709     TmpBuffer = WorkStationsListCopy.Buffer;
00710
00711     while( WorkStationName = wcstok(TmpBuffer, L",") ) {
00712
00713         TmpBuffer = NULL;
00714         InitUnicodeString( &Unicode, WorkStationName );
00715         if (EqualComputerName( &Unicode, LogonWorkStation )) {
00716             NtStatus = STATUS_SUCCESS;
00717             break;
00718         }
00719     }
00720
00721     if ( BufferAllocated ) {
00722         LocalFree( WorkStationsListCopy.Buffer );
00723     }
00724
00725     return( NtStatus );
00726 }
00727
00728 NTSTATUS
00729 AccountRestrictions(
00730     IN ULONG UserRid,
00731     IN PUNICODE_STRING LogonWorkStation,
00732     IN PUNICODE_STRING WorkStations,
00733     IN PLOGON_HOURS LogonHours,
00734     OUT PLARGE_INTEGER LogoffTime,
00735     OUT PLARGE_INTEGER KickoffTime
00736     )
00737
00738 /*++
00739
00740 Routine Description:
00741
00742     Validate a user's ability to log on at this time and at the workstation
00743     being logged onto.
00744
00745
00746 Arguments:
00747
00748     UserRid - The user id of the user to operate on.
00749
00750     LogonWorkStation - The name of the workstation the logon is being
00751         attempted at.
00752
00753     WorkStations - The list of workstations the user may log on to.  This
00754         information comes from the user's account information.  It must
00755         be in API list format.
00756
00757     LogonHours - The times the user may logon.  This information comes
00758         from the user's account information.
00759
00760     LogoffTime - Receives the time at which the user should log off the
00761         system.
00762
00763     KickoffTime - Receives the time at which the user should be kicked
00764         off the system.
00765
00766
00767 Return Value:
00768
00769
00770     STATUS_SUCCESS - Logon is permitted.
00771
00772     STATUS_INVALID_LOGON_HOURS - The user is not authorized to log on at
00773         this time.
00774
00775     STATUS_INVALID_WORKSTATION - The user is not authorized to log on to
00776         the specified workstation.
00777
00778
00779 --*/
00780 {
00781
00782     static BOOLEAN GetForceLogoff = TRUE;
00783     static LARGE_INTEGER ForceLogoff = { 0x7fffffff, 0xFFFFFFF};
00784
00785 #define MILLISECONDS_PER_WEEK 7 * 24 * 60 * 60 * 1000
00786
00787     SYSTEMTIME              CurrentTimeFields;
00788     LARGE_INTEGER           CurrentTime, CurrentUTCTime;
00789     LARGE_INTEGER           MillisecondsIntoWeekXUnitsPerWeek;
00790     LARGE_INTEGER           LargeUnitsIntoWeek;
00791     LARGE_INTEGER           Delta100Ns;
00792     NTSTATUS                NtStatus = STATUS_SUCCESS;
00793     ULONG                   CurrentMsIntoWeek;
00794     ULONG                   LogoffMsIntoWeek;
00795     ULONG                   DeltaMs;
00796     ULONG                   MillisecondsPerUnit;
00797     ULONG                   CurrentUnitsIntoWeek;
00798     ULONG                   LogoffUnitsIntoWeek;
00799     USHORT                  i;
00800     TIME_ZONE_INFORMATION   TimeZoneInformation;
00801     DWORD TimeZoneId;
00802     LARGE_INTEGER           BiasIn100NsUnits;
00803     LONG                    BiasInMinutes;
00804
00805
00806
00807     //
00808     // Only check for users other than the builtin ADMIN
00809     //
00810
00811     if ( UserRid != DOMAIN_USER_RID_ADMIN) {
00812
00813         //
00814         // Scan to make sure the workstation being logged into is in the
00815         // list of valid workstations - or if the list of valid workstations
00816         // is null, which means that all are valid.
00817         //
00818
00819         NtStatus = SampMatchworkstation( LogonWorkStation, WorkStations );
00820
00821         if ( NT_SUCCESS( NtStatus ) ) {
00822
00823             //
00824             // Check to make sure that the current time is a valid time to log
00825             // on in the LogonHours.
00826             //
00827             // We need to validate the time taking into account whether we are
00828             // in daylight savings time or standard time.  Thus, if the logon
00829             // hours specify that we are able to log on between 9am and 5pm,
00830             // this means 9am to 5pm standard time during the standard time
00831             // period, and 9am to 5pm daylight savings time when in the
00832             // daylight savings time.  Since the logon hours stored by SAM are
00833             // independent of daylight savings time, we need to add in the
00834             // difference between standard time and daylight savings time to
00835             // the current time before checking whether this time is a valid
00836             // time to log on.  Since this difference (or bias as it is called)
00837             // is actually held in the form
00838             //
00839             // Standard time = Daylight savings time + Bias
00840             //
00841             // the Bias is a negative number.  Thus we actually subtract the
00842             // signed Bias from the Current Time.
00843
00844             //
00845             // First, get the Time Zone Information.
00846             //
00847
00848             TimeZoneId = GetTimeZoneInformation(
00849                              (LPTIME_ZONE_INFORMATION) &TimeZoneInformation
00850                              );
00851
00852             //
00853             // Next, get the appropriate bias (signed integer in minutes) to subtract from
00854             // the Universal Time Convention (UTC) time returned by NtQuerySystemTime
00855             // to get the local time.  The bias to be used depends whether we're
00856             // in Daylight Savings time or Standard Time as indicated by the
00857             // TimeZoneId parameter.
00858             //
00859             // local time  = UTC time - bias in 100Ns units
00860             //
00861
00862             switch (TimeZoneId) {
00863
00864             case TIME_ZONE_ID_UNKNOWN:
00865
00866                 //
00867                 // There is no differentiation between standard and
00868                 // daylight savings time.  Proceed as for Standard Time
00869                 //
00870
00871                 BiasInMinutes = TimeZoneInformation.StandardBias;
00872                 break;
00873
00874             case TIME_ZONE_ID_STANDARD:
00875
00876                 BiasInMinutes = TimeZoneInformation.StandardBias;
00877                 break;
00878
00879             case TIME_ZONE_ID_DAYLIGHT:
00880
00881                 BiasInMinutes = TimeZoneInformation.DaylightBias;
00882                 break;
00883
00884             default:
00885
00886                 //
00887                 // Something is wrong with the time zone information.  Fail
00888                 // the logon request.
00889                 //
00890
00891                 NtStatus = STATUS_INVALID_LOGON_HOURS;
00892                 break;
00893             }
00894
00895             if (NT_SUCCESS(NtStatus)) {
00896
00897                 //
00898                 // Convert the Bias from minutes to 100ns units
00899                 //
00900
00901                 BiasIn100NsUnits.QuadPart = ((LONGLONG)BiasInMinutes)
00902                                             * 60 * 10000000;
00903
00904                 //
00905                 // Get the UTC time in 100Ns units used by Windows Nt.  This
00906                 // time is GMT.
00907                 //
00908
00909                 NtStatus = QuerySystemTime( &CurrentUTCTime );
00910             }
00911
00912             if ( NT_SUCCESS( NtStatus ) ) {
00913
00914                 CurrentTime.QuadPart = CurrentUTCTime.QuadPart -
00915                               BiasIn100NsUnits.QuadPart;
00916
00917                 FileTimeToSystemTime( (PFILETIME)&CurrentTime, &CurrentTimeFields );
00918
00919                 CurrentMsIntoWeek = (((( CurrentTimeFields.wDayOfWeek * 24 ) +
00920                                        CurrentTimeFields.wHour ) * 60 +
00921                                        CurrentTimeFields.wMinute ) * 60 +
00922                                        CurrentTimeFields.wSecond ) * 1000 +
00923                                        CurrentTimeFields.wMilliseconds;
00924
00925                 MillisecondsIntoWeekXUnitsPerWeek.QuadPart =
00926                     ((LONGLONG)CurrentMsIntoWeek) *
00927                     ((LONGLONG)LogonHours->UnitsPerWeek);
00928
00929                 LargeUnitsIntoWeek.QuadPart =
00930                     MillisecondsIntoWeekXUnitsPerWeek.QuadPart / ((ULONG) MILLISECONDS_PER_WEEK);
00931
00932                 CurrentUnitsIntoWeek = LargeUnitsIntoWeek.LowPart;
00933
00934                 if ( !( LogonHours->LogonHours[ CurrentUnitsIntoWeek / 8] &
00935                     ( 0x01 << ( CurrentUnitsIntoWeek % 8 ) ) ) ) {
00936
00937                     NtStatus = STATUS_INVALID_LOGON_HOURS;
00938
00939                 } else {
00940
00941                     //
00942                     // Determine the next time that the user is NOT supposed to be logged
00943                     // in, and return that as LogoffTime.
00944                     //
00945
00946                     i = 0;
00947                     LogoffUnitsIntoWeek = CurrentUnitsIntoWeek;
00948
00949                     do {
00950
00951                         i++;
00952
00953                         LogoffUnitsIntoWeek = ( LogoffUnitsIntoWeek + 1 ) % LogonHours->UnitsPerWeek;
00954
00955                     } while ( ( i <= LogonHours->UnitsPerWeek ) &&
00956                         ( LogonHours->LogonHours[ LogoffUnitsIntoWeek / 8 ] &
00957                         ( 0x01 << ( LogoffUnitsIntoWeek % 8 ) ) ) );
00958
00959                     if ( i > LogonHours->UnitsPerWeek ) {
00960
00961                         //
00962                         // All times are allowed, so there's no logoff
00963                         // time.  Return forever for both LogoffTime and
00964                         // KickoffTime.
00965                         //
00966
00967                         LogoffTime->HighPart = 0x7FFFFFFF;
00968                         LogoffTime->LowPart = 0xFFFFFFFF;
00969
00970                         KickoffTime->HighPart = 0x7FFFFFFF;
00971                         KickoffTime->LowPart = 0xFFFFFFFF;
00972
00973                     } else {
00974
00975                         //
00976                         // LogoffUnitsIntoWeek points at which time unit the
00977                         // user is to log off.  Calculate actual time from
00978                         // the unit, and return it.
00979                         //
00980                         // CurrentTimeFields already holds the current
00981                         // time for some time during this week; just adjust
00982                         // to the logoff time during this week and convert
00983                         // to time format.
00984                         //
00985
00986                         MillisecondsPerUnit = MILLISECONDS_PER_WEEK / LogonHours->UnitsPerWeek;
00987
00988                         LogoffMsIntoWeek = MillisecondsPerUnit * LogoffUnitsIntoWeek;
00989
00990                         if ( LogoffMsIntoWeek < CurrentMsIntoWeek ) {
00991
00992                             DeltaMs = MILLISECONDS_PER_WEEK - ( CurrentMsIntoWeek - LogoffMsIntoWeek );
00993
00994                         } else {
00995
00996                             DeltaMs = LogoffMsIntoWeek - CurrentMsIntoWeek;
00997                         }
00998
00999                         Delta100Ns.QuadPart = (LONGLONG) DeltaMs * 10000;
01000
01001                         LogoffTime->QuadPart = CurrentUTCTime.QuadPart +
01002                                       Delta100Ns.QuadPart;
01003
01004                         //
01005                         // Grab the domain's ForceLogoff time.
01006                         //
01007
01008                         if ( GetForceLogoff ) {
01009                             NET_API_STATUS NetStatus;
01010                             LPUSER_MODALS_INFO_0 UserModals0;
01011
01012                             NetStatus = NetUserModalsGet( NULL,
01013                                                           0,
01014                                                           (LPBYTE *)&UserModals0 );
01015
01016                             if ( NetStatus == 0 ) {
01017                                 GetForceLogoff = FALSE;
01018
01019                                 ForceLogoff = NetpSecondsToDeltaTime( UserModals0->usrmod0_force_logoff );
01020
01021                                 NetApiBufferFree( UserModals0 );
01022                             }
01023                         }
01024                         //
01025                         // Subtract Domain->ForceLogoff from LogoffTime, and return
01026                         // that as KickoffTime.  Note that Domain->ForceLogoff is a
01027                         // negative delta.  If its magnitude is sufficiently large
01028                         // (in fact, larger than the difference between LogoffTime
01029                         // and the largest positive large integer), we'll get overflow
01030                         // resulting in a KickOffTime that is negative.  In this
01031                         // case, reset the KickOffTime to this largest positive
01032                         // large integer (i.e. "never") value.
01033                         //
01034
01035
01036                         KickoffTime->QuadPart = LogoffTime->QuadPart - ForceLogoff.QuadPart;
01037
01038                         if (KickoffTime->QuadPart < 0) {
01039
01040                             KickoffTime->HighPart = 0x7FFFFFFF;
01041                             KickoffTime->LowPart = 0xFFFFFFFF;
01042                         }
01043                     }
01044                 }
01045             }
01046         }
01047
01048     } else {
01049
01050         //
01051         // Never kick administrators off
01052         //
01053
01054         LogoffTime->HighPart  = 0x7FFFFFFF;
01055         LogoffTime->LowPart   = 0xFFFFFFFF;
01056         KickoffTime->HighPart = 0x7FFFFFFF;
01057         KickoffTime->LowPart  = 0xFFFFFFFF;
01058     }
01059
01060
01061     return( NtStatus );
01062 }
01063
01064 LARGE_INTEGER
01065 NetpSecondsToDeltaTime(
01066     IN ULONG Seconds
01067     )
01068
01069 /*++
01070
01071 Routine Description:
01072
01073     Convert a number of seconds to an NT delta time specification
01074
01075 Arguments:
01076
01077     Seconds - a positive number of seconds
01078
01079 Return Value:
01080
01081     Returns the NT Delta time.  NT delta time is a negative number
01082         of 100ns units.
01083
01084 --*/
01085
01086 {
01087     LARGE_INTEGER DeltaTime;
01088     LARGE_INTEGER LargeSeconds;
01089     LARGE_INTEGER Answer;
01090
01091     //
01092     // Special case TIMEQ_FOREVER (return a full scale negative)
01093     //
01094
01095     if ( Seconds == TIMEQ_FOREVER ) {
01096         DeltaTime.LowPart = 0;
01097         DeltaTime.HighPart = (LONG) 0x80000000;
01098
01099     //
01100     // Convert seconds to 100ns units simply by multiplying by 10000000.
01101     //
01102     // Convert to delta time by negating.
01103     //
01104
01105     } else {
01106
01107         LargeSeconds.LowPart = Seconds;
01108         LargeSeconds.HighPart = 0;
01109
01110         Answer.QuadPart = LargeSeconds.QuadPart * 10000000;
01111
01112           if ( Answer.QuadPart < 0 ) {
01113             DeltaTime.LowPart = 0;
01114             DeltaTime.HighPart = (LONG) 0x80000000;
01115         } else {
01116             DeltaTime.QuadPart = -Answer.QuadPart;
01117         }
01118
01119     }
01120
01121     return DeltaTime;
01122
01123 } // NetpSecondsToDeltaTime
01124
01125
01126 BOOLEAN
01127 EqualComputerName(
01128     IN PUNICODE_STRING String1,
01129     IN PUNICODE_STRING String2
01130     )
01131 /*++
01132
01133 Routine Description:
01134
01135     Compare two computer names for equality.
01136
01137 Arguments:
01138
01139     String1 - Name of first computer.
01140     String2 - Name of second computer.
01141
01142 Return Value:
01143
01144     TRUE if the names, converted to OEM, compare case-insensitively,
01145     FALSE if they don't compare or can't be converted to OEM.
01146
01147 --*/
01148 {
01149     WCHAR Computer1[CNLEN+1];
01150     WCHAR Computer2[CNLEN+1];
01151     CHAR OemComputer1[CNLEN+1];
01152     CHAR OemComputer2[CNLEN+1];
01153
01154     //
01155     // Make sure the names are not too long
01156     //
01157
01158     if ((String1->Length > CNLEN*sizeof(WCHAR)) ||
01159         (String2->Length > CNLEN*sizeof(WCHAR))) {
01160         return(FALSE);
01161
01162     }
01163
01164     //
01165     // Copy them to null terminated strings
01166     //
01167
01168     CopyMemory(
01169         Computer1,
01170         String1->Buffer,
01171         String1->Length
01172         );
01173     Computer1[String1->Length/sizeof(WCHAR)] = L'\0';
01174
01175     CopyMemory(
01176         Computer2,
01177         String2->Buffer,
01178         String2->Length
01179         );
01180     Computer2[String2->Length/sizeof(WCHAR)] = L'\0';
01181
01182     //
01183     // Convert the computer names to OEM
01184     //
01185
01186     if (!CharToOemW(
01187             Computer1,
01188             OemComputer1
01189             )) {
01190         return(FALSE);
01191     }
01192
01193     if (!CharToOemW(
01194             Computer2,
01195             OemComputer2
01196             )) {
01197         return(FALSE);
01198     }
01199
01200     //
01201     // Do a case insensitive comparison of the oem computer names.
01202     //
01203
01204     if (lstrcmpiA(OemComputer1, OemComputer2) == 0)
01205     {
01206         return(TRUE);
01207     }
01208     else
01209     {
01210         return(FALSE);
01211     }
01212 }
01213
01214 VOID
01215 InitUnicodeString(
01216     OUT PUNICODE_STRING DestinationString,
01217     IN PCWSTR SourceString OPTIONAL
01218     )
01219
01220 /*++
01221
01222 Routine Description:
01223
01224     The InitUnicodeString function initializes an NT counted
01225     unicode string.  The DestinationString is initialized to point to
01226     the SourceString and the Length and MaximumLength fields of
01227     DestinationString are initialized to the length of the SourceString,
01228     which is zero if SourceString is not specified.
01229
01230 Arguments:
01231
01232     DestinationString - Pointer to the counted string to initialize
01233
01234     SourceString - Optional pointer to a null terminated unicode string that
01235         the counted string is to point to.
01236
01237
01238 Return Value:
01239
01240     None.
01241
01242 --*/
01243
01244 {
01245     ULONG Length;
01246
01247     DestinationString->Buffer = (PWSTR)SourceString;
01248     if (SourceString != NULL) {
01249         Length = (ULONG)(wcslen( SourceString ) * sizeof( WCHAR ));
01250         DestinationString->Length = (USHORT)Length;
01251         DestinationString->MaximumLength = (USHORT)(Length + sizeof(UNICODE_NULL));
01252         }
01253     else {
01254         DestinationString->MaximumLength = 0;
01255         DestinationString->Length = 0;
01256         }
01257 }
01258
01259 VOID
01260 CopyUnicodeString(
01261     OUT PUNICODE_STRING DestinationString,
01262     IN PUNICODE_STRING SourceString OPTIONAL
01263     )
01264
01265 /*++
01266
01267 Routine Description:
01268
01269     The CopyString function copies the SourceString to the
01270     DestinationString.  If SourceString is not specified, then
01271     the Length field of DestinationString is set to zero.  The
01272     MaximumLength and Buffer fields of DestinationString are not
01273     modified by this function.
01274
01275     The number of bytes copied from the SourceString is either the
01276     Length of SourceString or the MaximumLength of DestinationString,
01277     whichever is smaller.
01278
01279 Arguments:
01280
01281     DestinationString - Pointer to the destination string.
01282
01283     SourceString - Optional pointer to the source string.
01284
01285 Return Value:
01286
01287     None.
01288
01289 --*/
01290
01291 {
01292     UNALIGNED WCHAR *src, *dst;
01293     ULONG n;
01294
01295     if (SourceString != NULL) {
01296         dst = DestinationString->Buffer;
01297         src = SourceString->Buffer;
01298         n = SourceString->Length;
01299         if ((USHORT)n > DestinationString->MaximumLength) {
01300             n = DestinationString->MaximumLength;
01301         }
01302
01303         DestinationString->Length = (USHORT)n;
01304         CopyMemory(dst, src, n);
01305         if (DestinationString->Length < DestinationString->MaximumLength) {
01306             dst[n / sizeof(WCHAR)] = UNICODE_NULL;
01307         }
01308
01309     } else {
01310         DestinationString->Length = 0;
01311     }
01312
01313     return;
01314 }
01315
01316
01317 NTSTATUS
01318 NTAPI
01319 Msv1_0SubAuthenticationFilter (
01320     IN NETLOGON_LOGON_INFO_CLASS LogonLevel,
01321     IN PVOID LogonInformation,
01322     IN ULONG Flags,
01323     IN PUSER_ALL_INFORMATION UserAll,
01324     OUT PULONG WhichFields,
01325     OUT PULONG UserFlags,
01326     OUT PBOOLEAN Authoritative,
01327     OUT PLARGE_INTEGER LogoffTime,
01328     OUT PLARGE_INTEGER KickoffTime
01329 )
01330 {
01331     return( Msv1_0SubAuthenticationRoutine(
01332                 LogonLevel,
01333                 LogonInformation,
01334                 Flags,
01335                 UserAll,
01336                 WhichFields,
01337                 UserFlags,
01338                 Authoritative,
01339                 LogoffTime,
01340                 KickoffTime
01341                 ) );
01342 }
01343 // subauth.c eof
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/RSM/inc/stl.h Source File

  • WinBase
  • IO
  • RSM
  • inc

stl.h

Go to the documentation of this file.
00001 /*
00002  *  This is a part of the Microsoft Source Code Samples.
00003
00004  *
00005  *  This sample code shows the usage of some portions
00006  *  of the RSM API.
00007  *
00008  *  Return codes are, for the most part, not checked in
00009  *  this code. See the Programmer's reference for error
00010  *  return information.
00011  *
00012  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00013  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00014  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00015  * PARTICULAR PURPOSE.
00016  *
00017  * Copyright 1997 - 1998 Microsoft Corporation.  All Rights Reserved.
00018  */
00019
00020 /*
00021  *  Definition of the "Simple Tape Label"
00022  *
00023  */
00024 #ifndef _STL_DEFS_H
00025 #define _STL_DEFS_H
00026
00027
00028 // make sure we are byte aligned ...
00029 #pragma pack(1)
00030
00031 #define STL_LABEL_LabelType L"Simple Tape Label (STL)"
00032 #define STL_LABEL_LabelTypeSize sizeof (STL_LABEL_LabelType)
00033
00034 #define STL_LABEL_Version L"2.60"
00035 #define STL_LABEL_VersionSize sizeof(STL_LABEL_Version)
00036
00037 #define STL_LABEL_Vendor L"Microsoft Corporation"
00038 #define STL_LABEL_VendorSize sizeof(STL_LABEL_Vendor)
00039
00040 #define STL_LABEL_TimeStampSize 40 // Must be even to hold UNICODE string
00041
00042 #define STL_LABEL_Application L"RSM Sample App"
00043 #define STL_LABEL_ApplicationSize sizeof(STL_LABEL_Application)
00044
00045 #define STL_LABEL_TapeNameSize 256 // Must be even to hold UNICODE string
00046
00047 #define STL_LABEL_MediaIDBlank L"{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
00048 #define STL_LABEL_MediaIDSize sizeof(STL_LABEL_MediaIDBlank)
00049
00050 typedef struct
00051 {
00052   BYTE  LabelType[STL_LABEL_LabelTypeSize];
00053   BYTE  LabelVersion[STL_LABEL_VersionSize];
00054   BYTE  Vendor[STL_LABEL_VendorSize];
00055   BYTE  TimeStamp[STL_LABEL_TimeStampSize];
00056   BYTE  Application[STL_LABEL_ApplicationSize];
00057   BYTE  TapeName[STL_LABEL_TapeNameSize];
00058   BYTE  MediaID[STL_LABEL_MediaIDSize];
00059 } STL_LABEL;
00060
00061 #endif
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/Pch.h Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

Pch.h

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <commdlg.h>
00003 #include <commctrl.h>
00004 #include <imm.h>
00005 #include "resource.h"
00006 #include "imeapps.h"
00007
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Range/Range.h Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Range

Range.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*=========================================================================
00019 OVERVIEW OF INTERFACE
00020
00021 The client calls HttpReadRequest to specify the URL, a callback function,
00022 and an optional array of read ranges.  First, the callback will be notified
00023 of the http response code, content length, last modified time, whether
00024 ranges are supported by the server, and whether the file is from the cache.
00025 Next, it may be called repeatedly with data which must be processed during the
00026 call.  Finally, it will indicate completion and an error if any.  Within the
00027 callback, a client can initiate a new HttpReadRequest and/or return FALSE to
00028 stop the current request.
00029
00030 All ActiveX controls can use this interface.  Other applications must satisfy
00031 some requirements due to an implicit dependency on URL moniker.  The client
00032 thread must have a message loop.  Before calling HttpReadRequest, the client
00033 process must have called CoInitialize or OleInitialize.  After exiting the
00034 message loop, the client process must call CoUninitialize or OleUninitialize.
00035 ===========================================================================*/
00036
00037 #ifndef _RANGE_
00038 #define _RANGE_
00039
00040 #include <windows.h>
00041 #include <objbase.h>
00042
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046
00047 // ===========================================================================
00048 // Callback parameter structure and prototype
00049 // ===========================================================================
00050
00051 // Callback Types:
00052 typedef enum
00053 {
00054   REQUESTCB_STARTED  = 0,
00055   REQUESTCB_DATA     = 1,
00056   REQUESTCB_DONE     = 2,
00057 }
00058   HTTP_REQUESTCB_TYPE;
00059
00060 #pragma warning(push)
00061 #pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
00062 // Callback parameters: valid only during the current call.
00063 typedef struct
00064 {
00065   DWORD  cbStruct;       // will be sizeof(HTTP_CALLBACK_PARAM)
00066     DWORD  dwRequestCtx;   // context passed in to HttpReadRequest
00067     HTTP_REQUESTCB_TYPE CallbackType;   // callback type as defined above
00068
00069     union
00070     {
00071         struct // fields used if CallbackType == REQUESTCB_STARTED
00072     {
00073         DWORD       fdwRequestFlags;  // fields as defined below
00074         DWORD       dwResponseCode;   // status code (0 if unknown)
00075         SYSTEMTIME* pstLastModified;  // last modified (NULL if unknown)
00076             DWORD       dwContentLength;  // content length (0 if unknown)
00077     };
00078
00079         struct // fields used if CallbackType == REQUESTCB_DATA
00080         {
00081         DWORD       dwDataOffset;     // offset of data
00082         LPVOID      lpDataBuffer;     // pointer to data
00083         DWORD       cbDataLength;     // amount of data
00084     };
00085
00086     struct // fields used if CallbackType == REQUESTCB_DONE
00087     {
00088             HRESULT     hrRequest;        // values defined in urlmon.h
00089     };
00090   };
00091 }
00092   HTTP_REQUESTCB_PARAM, *PHTTP_REQUESTCB_PARAM;
00093 #pragma warning(pop)
00094
00095 // Fields for HTTP_REQUESTCB_PARAM.fdwRequestFlags:
00096 #define HTTP_REQUEST_FROM_CACHE       1
00097 #define HTTP_REQUEST_ACCEPT_RANGES    2
00098
00099 // Callback function supplied by client:
00100 typedef BOOL (*PFN_REQUESTCB) (PHTTP_REQUESTCB_PARAM);
00101
00102 // ===========================================================================
00103 // HttpReadRequest parameter structure and prototype
00104 // ===========================================================================
00105
00106 // Structure for specifying a read range:
00107 typedef struct
00108 {
00109   DWORD dwOffset;     // offset of data within the URL
00110   DWORD dwSize;       // amount of data (0 means until end of file)
00111 }
00112   HTTP_REQUEST_RANGE, *PHTTP_REQUEST_RANGE;
00113
00114 // Read request parameters must remain valid until REQUEST_COMPLETE:
00115 typedef struct
00116 {
00117   DWORD               cbStruct;        // must be sizeof(HTTP_REQUEST_PARAM)
00118   LPVOID              punkOuter;       // controlling IUnknown (may be NULL)
00119     PCSTR               pszUrl;          // URL to request via http
00120   PFN_REQUESTCB       pfnRequestCB;    // request callback function
00121     DWORD               dwRequestCtx;    // context to pass to callback
00122
00123     // Optional fields for specifying ranges, otherwise set all to 0:
00124     PHTTP_REQUEST_RANGE pRanges;                // array of read ranges
00125     DWORD               cRanges;                // number of ranges
00126     SYSTEMTIME*         pstUnlessModifiedSince; // unless-modified-since time
00127 }
00128   HTTP_REQUEST_PARAM, *PHTTP_REQUEST_PARAM;
00129
00130 // Function called by client to initiate http read request.
00131 BOOL HttpReadRequest    (PHTTP_REQUEST_PARAM); // try cache first
00132 BOOL HttpReadFromServer (PHTTP_REQUEST_PARAM); // bypass cache
00133
00134 #ifdef __cplusplus
00135 } // extern "C" {
00136 #endif
00137
00138 #endif // _RANGE_
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkClipboard/AssemblyInfo.cs Source File

  • TabletPC
  • InkClipboard

AssemblyInfo.cs

Go to the documentation of this file.
00001 using System.Reflection;
00002 using System.Runtime.CompilerServices;
00003
00004 //
00005 // General Information about an assembly is controlled through the following
00006 // set of attributes. Change these attribute values to modify the information
00007 // associated with an assembly.
00008 //
00009 [assembly: AssemblyTitle("Ink Clipboard Sample Application")]
00010 [assembly: AssemblyCompany("Microsoft Corporation")]
00011 [assembly: AssemblyProduct("Microsoft (R) Windows (R) Operating System")]
00012 [assembly: AssemblyCopyright("Copyright (c) 1998-2003 Microsoft Corporation.")]
00013 [assembly: AssemblyTrademark("Microsoft (R) is a registered trademark of Microsoft Corporation. Windows (R) is a registered trademark of Microsoft Corporation.")]
00014 [assembly: AssemblyCulture("")]
00015
00016 //
00017 // Version information for an assembly consists of the following four values:
00018 //
00019 //      Major Version
00020 //      Minor Version
00021 //      Build Number
00022 //      Revision
00023 //
00024 // You can specify all the values or you can default the Revision and Build Numbers
00025 // by using the '*' as shown below:
00026
00027 //[assembly: AssemblyVersion("1.0.*")]
00028
00029 //
00030 // In order to sign your assembly you must specify a key to use. Refer to the
00031 // Microsoft .NET Framework documentation for more information on assembly signing.
00032 //
00033 // Use the attributes below to control which key is used for signing.
00034 //
00035 // Notes:
00036 //   (*) If no key is specified, the assembly is not signed.
00037 //   (*) KeyName refers to a key that has been installed in the Crypto Service
00038 //       Provider (CSP) on your machine. KeyFile refers to a file which contains
00039 //       a key.
00040 //   (*) If the KeyFile and the KeyName values are both specified, the
00041 //       following processing occurs:
00042 //       (1) If the KeyName can be found in the CSP, that key is used.
00043 //       (2) If the KeyName does not exist and the KeyFile does exist, the key
00044 //           in the KeyFile is installed into the CSP and used.
00045 //   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
00046 //       When specifying the KeyFile, the location of the KeyFile should be
00047 //       relative to the project output directory which is
00048 //       %Project Directory%\obj<configuration>. For example, if your KeyFile is
00049 //       located in the project directory, you would specify the AssemblyKeyFile
00050 //       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
00051 //   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
00052 //       documentation for more information on this.
00053 //
00054 [assembly: AssemblyDelaySign(false)]
00055 [assembly: AssemblyKeyFile("")]
00056 [assembly: AssemblyKeyName("")]
Generated on Wed Nov 13 2024 16:52:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ExeSkel/ExeSkel.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ExeSkel

ExeSkel.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      EXESKEL.CPP
00003
00004   Summary:   Implementation file for the general .EXE application skeleton
00005              that can be used as a point of departure for more complex COM
00006              Win32 applications.  It is used as a skeletal base for the
00007              COM Tutorial series of code samples.
00008
00009              For a comprehensive tutorial code tour of EXESKEL's contents
00010              and offerings see the tutorial EXESKEL.HTM file. For more
00011              specific technical details on the internal workings see the
00012              comments dispersed throughout the EXESKEL source code.
00013
00014   Classes:   CMainWindow
00015
00016   Functions: InitApplication, WinMain
00017
00018   Origin:    8-38-97: atrent - Revised. Based on DFVIEW by stevebl.
00019
00020 ----------------------------------------------------------------------------
00021   This file is part of the Microsoft COM Tutorial Code Samples.
00022
00023   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00024
00025   This source code is intended only as a supplement to Microsoft
00026   Development Tools and/or on-line documentation.  See these other
00027   materials for detailed information regarding Microsoft code samples.
00028
00029   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00030   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00032   PARTICULAR PURPOSE.
00033 ==========================================================================+*/
00034
00035 /*---------------------------------------------------------------------------
00036   We include WINDOWS.H for all Win32 applications.
00037   We include OLE2.H because we will be calling the COM
00038     Library's CoInitialize and CoUnInitialize calls.
00039   We include COMMDLG.H because we will be using the Open File and
00040     potentially other Common dialogs.
00041   We include APPUTIL.H because we will be building this application using
00042     the convenient Virtual Window and Dialog classes and other
00043     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00044   We include EXESKEL.H because it has class and resource definitions
00045     specific to this EXESKEL application.
00046 ---------------------------------------------------------------------------*/
00047 #include <windows.h>
00048 #include <ole2.h>
00049 #include <commdlg.h>
00050 #include <apputil.h>
00051 #include "exeskel.h"
00052
00053
00054 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00055   Method:   CMainWindow::CMainWindow
00056
00057   Summary:  CMainWindow Constructor.
00058
00059   Args:     .
00060
00061   Modifies: .
00062
00063   Returns:  .
00064 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00065 CMainWindow::CMainWindow()
00066 {
00067   // Ensure these member variable strings are null strings.
00068   m_szFileName[0] = 0;
00069   m_szFileTitle[0] = 0;
00070
00071   // Fill in the Common Dialog's OPENFILENAME structure.
00072   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00073   m_ofnFile.hwndOwner = m_hWnd;
00074   m_ofnFile.hInstance = m_hInst;
00075   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00076   m_ofnFile.lpstrCustomFilter = NULL;
00077   m_ofnFile.nMaxCustFilter = 0;
00078   m_ofnFile.nFilterIndex = 1;
00079   m_ofnFile.lpstrFile = m_szFileName;
00080   m_ofnFile.nMaxFile = MAX_PATH;
00081   m_ofnFile.lpstrInitialDir = TEXT(".");
00082   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00083   m_ofnFile.nMaxFileTitle = MAX_PATH;
00084   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00085   m_ofnFile.lpstrDefExt = NULL;
00086   m_ofnFile.Flags = OFN_HIDEREADONLY;
00087
00088   // Null the Message object pointer.
00089   m_pMsgBox = NULL;
00090 }
00091
00092
00093 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00094   Method:   CMainWindow::~CMainWindow
00095
00096   Summary:  CMainWindow Destructor.  Destruction of the main window
00097             indicates that the application should quit and thus the
00098             PostQuitMessage API is called.
00099
00100   Args:     .
00101
00102   Modifies: .
00103
00104   Returns:  .
00105 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00106 CMainWindow::~CMainWindow()
00107 {
00108   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00109   // message and causes a delete of CMainWindow which in turn causes this
00110   // destructor to run. The WM_DESTROY results when the window is destoyed
00111   // after a close of the window. Prior to exiting the main message loop
00112   // we delete the CMsgBox object that was made in Initinstance.
00113   DELETE_POINTER(m_pMsgBox);
00114
00115   // We then post a WM_QUIT message to cause an exit of the main thread's
00116   // message loop and an exit of this instance of the application.
00117   PostQuitMessage(0);
00118 }
00119
00120
00121 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00122   Method:   CMainWindow::InitInstance
00123
00124   Summary:  Instantiates an instance of the main application window.
00125             This method must be called only once, immediately after
00126             window class construction.  We take care to delete 'this'
00127             CMainWindow if we must return the error condition FALSE.
00128
00129   Args:     HINSTANCE hInstance,
00130               Handle of the application instance.
00131             int nCmdShow)
00132               Command to pass to ShowWindow.
00133
00134   Modifies: m_szHelpFile, m_pMsgBox.
00135
00136   Returns:  BOOL.
00137               TRUE if succeeded.
00138               FALSE if failed.
00139 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00140 BOOL CMainWindow::InitInstance(
00141        HINSTANCE hInstance,
00142        int nCmdShow)
00143 {
00144   BOOL bResult = FALSE;
00145   HWND hWnd;
00146
00147   // Create the Message Box object.
00148   m_pMsgBox = new CMsgBox;
00149
00150   if (NULL != m_pMsgBox)
00151   {
00152     // Note, the Create method sets the m_hWnd member so we don't
00153     //   need to set it explicitly here first.
00154
00155     // Here is the create of this window.  Size the window reasonably.
00156     //   Create sets both m_hInst and m_hWnd.
00157     hWnd = Create(
00158              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00159              TEXT(MAIN_WINDOW_TITLE_STR),
00160              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00161                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00162              CW_USEDEFAULT,
00163              CW_USEDEFAULT,
00164              ::GetSystemMetrics(SM_CXSCREEN)*2/5,
00165              ::GetSystemMetrics(SM_CYSCREEN)*2/5,
00166              NULL,
00167              NULL,
00168              hInstance);
00169     if (hWnd)
00170     {
00171       // Ensure the new window is shown on screen and its content is painted.
00172       ::ShowWindow(m_hWnd, nCmdShow);
00173       ::UpdateWindow(m_hWnd);
00174
00175       // Build a path to where the help file should be (it should be in
00176       // the same directory as the .EXE but with the .HTM extension).
00177       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00178
00179       // Init the Message Box object and signal we succeeded initializing
00180       // the application.
00181       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00182         bResult = TRUE;
00183     }
00184   }
00185
00186   if (!bResult)
00187   {
00188     if (m_pMsgBox)
00189       delete m_pMsgBox;
00190     // If Create failed then hWnd == NULL and the window create failed.
00191     // This means that the WM_NCCREATE returned a -1 (failure) and
00192     // Windows sends the WM_DESTROY message to the window and an object
00193     // of the CVirWindow class destroys itself whenever it receives
00194     // the WM_DESTROY message.  So in that case we don't need to
00195     // delete 'this'.  We delete 'this' if we succeeded in creating the
00196     // window but failed in some other way in this initialization.
00197     if (hWnd)
00198       delete this;
00199   }
00200
00201   return (bResult);
00202 }
00203
00204
00205 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00206   Method:   CMainWindow::DoMenu
00207
00208   Summary:  Member function to dispatch and handle the main menu commands.
00209
00210   Args:     WPARAM wParam,
00211               First message parameter (word sized).
00212             LPARAM lParam)
00213               Second message parameter (long sized).
00214
00215   Modifies: m_ofnFile.
00216
00217   Returns:  LRESULT
00218               Standard Windows WindowProc return value.
00219 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00220 LRESULT CMainWindow::DoMenu(
00221           WPARAM wParam,
00222           LPARAM lParam)
00223 {
00224   LRESULT lResult = FALSE;
00225
00226   switch (LOWORD(wParam))
00227   {
00228     case IDM_FILE_EXIT:
00229       // The user commands us to exit this application so we tell the
00230       // Main window to close itself.
00231       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00232       break;
00233
00234     case IDM_HELP_CONTENTS:
00235       // We have some stubbed support here for bringing up the online
00236       // Help for this application.
00237       ReadHelp(m_hWnd, m_szHelpFile);
00238       break;
00239
00240     case IDM_HELP_TUTORIAL:
00241       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00242       // tutorial narrative file associated with this tutorial code sample.
00243       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00244       break;
00245
00246     case IDM_HELP_READSOURCE:
00247       // Call the APPUTIL utility function ReadSource to allow the
00248       // user to open and read any of the source files of EXESKEL.
00249       ReadSource(m_hWnd, &m_ofnFile);
00250       break;
00251
00252     case IDM_HELP_ABOUT:
00253       {
00254         CAboutBox dlgAboutBox;
00255
00256         // Show the standard About Box dialog for this EXE by telling the
00257         // dialog C++ object to show itself by invoking its ShowDialog
00258         // method.  Pass it this EXE instance and the parent window handle.
00259         // Use a dialog resource ID for the dialog template stored in
00260         // this EXE module's resources.
00261         dlgAboutBox.ShowDialog(
00262           m_hInst,
00263           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00264           m_hWnd);
00265       }
00266       break;
00267
00268     default:
00269       // Defer all messages NOT handled here to the Default Window Proc.
00270       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00271       break;
00272   }
00273
00274   return(lResult);
00275 }
00276
00277
00278 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00279   Method:   CMainWindow::WindowProc
00280
00281   Summary:  Main window procedure for this window object.  See CVirWindow
00282             in the APPUTIL library (APPUTIL.CPP) for details on how this
00283             method gets called by the global WindowProc.
00284
00285   Args:     UINT uMsg,
00286               Windows message that is "sent" to this window.
00287             WPARAM wParam,
00288               First message parameter (word sized).
00289             LPARAM lParam)
00290               Second message parameter (long sized).
00291
00292   Modifies: ...
00293
00294   Returns:  LRESULT
00295               Standard Windows WindowProc return value.
00296 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00297 LRESULT CMainWindow::WindowProc(
00298           UINT uMsg,
00299           WPARAM wParam,
00300           LPARAM lParam)
00301 {
00302   LRESULT lResult = FALSE;
00303
00304   switch (uMsg)
00305   {
00306     case WM_CREATE:
00307       {
00308         // Setup for painting text in this window.
00309         HDC hdc = GetDC(m_hWnd);
00310         ::GetTextMetrics(hdc, &m_tm);
00311         ::ReleaseDC(m_hWnd, hdc);
00312       }
00313       break;
00314
00315     case WM_MEASUREITEM:
00316       // Get setup for painting text in this window.
00317       {
00318         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00319         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00320         lpmis->itemWidth = m_wWidth;
00321         lResult = TRUE;
00322       }
00323
00324     case WM_SIZE:
00325       // Handle a resize of this window.
00326       m_wWidth = LOWORD(lParam);
00327       m_wHeight = HIWORD(lParam);
00328       break;
00329
00330     case WM_COMMAND:
00331       // Dispatch and handle any Menu command messages received.
00332       lResult = DoMenu(wParam, lParam);
00333       break;
00334
00335     case WM_CLOSE:
00336       // The user selected Close on the main window's System menu
00337       // or Exit on the File menu.
00338     case WM_QUIT:
00339       // If the app is being quit then close any associated help windows.
00340     default:
00341       // Defer all messages NOT handled here to the Default Window Proc.
00342       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00343       break;
00344   }
00345
00346   return(lResult);
00347 }
00348
00349
00350 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00351   Function: UnicodeOk
00352
00353   Summary:  Checks if the platform will handle unicode versions of
00354             Win32 string API calls.
00355
00356   Args:     void
00357
00358   Returns:  BOOL
00359               TRUE if unicode support; FALSE if not.
00360 ------------------------------------------------------------------------F-F*/
00361 BOOL UnicodeOk(void)
00362 {
00363   BOOL bOk = TRUE;
00364   TCHAR szUserName[MAX_STRING_LENGTH];
00365   DWORD dwSize = MAX_STRING_LENGTH;
00366
00367   if (!GetUserName(szUserName, &dwSize))
00368     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00369
00370   return bOk;
00371 }
00372
00373
00374 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00375   Function: InitApplication
00376
00377   Summary:  Initializes the application and registers its main window
00378             class. InitApplication is called only once (in WinMain).
00379
00380   Args:     HINSTANCE hInstance)
00381               Handle to the first instance of the application.
00382
00383   Returns:  BOOL.
00384               TRUE if success.
00385               FALSE if fail.
00386 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00387 BOOL InitApplication(
00388        HINSTANCE hInstance)
00389 {
00390   BOOL bOk;
00391   // The window class for all instances of the main frame window.
00392   WNDCLASSEX wcf;
00393
00394   // Assign the appropriate values for this main frame window class.
00395   wcf.cbSize        = sizeof(WNDCLASSEX);
00396   wcf.cbClsExtra    = 0;            // No per-class extra data.
00397   wcf.cbWndExtra    = 0;            // No per-window extra data.
00398   wcf.hInstance     = hInstance;    // Application module instance.
00399   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
00400                                     // APPUTIL for all CVirWindows).
00401   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
00402   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
00403                                 hInstance,
00404                                 TEXT("AppIcon"));
00405   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
00406                                 hInstance,
00407                                 TEXT("AppIcon"),
00408                                 IMAGE_ICON,
00409                                 16, 16,
00410                                 0);
00411   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
00412   wcf.style         = CS_HREDRAW | CS_VREDRAW;          // Class style(s).
00413   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
00414   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
00415
00416   // Register the window class and return FALSE if unsuccesful.
00417   bOk = RegisterClassEx(&wcf);
00418
00419   return (bOk);
00420 }
00421
00422
00423 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00424   Function: WinMain
00425
00426   Summary:  The Windows main entry point function for this application.
00427             Initializes the application, the COM Libraries, and starts
00428             the main application message loop.
00429
00430   Args:     HINSTANCE hInstance,
00431               Instance handle; a new one for each invocation of this app.
00432             HINSTANCE hPrevInstance,
00433               Instance handle of the previous instance. NULL in Win32.
00434             LPSTR lpCmdLine,
00435               Windows passes a pointer to the application's
00436               invocation command line.
00437             int nCmdShow)
00438               Bits telling the show state of the application.
00439
00440   Returns:  int
00441               msg.wParam (upon exit of message loop).
00442               FALSE if this instance couldn't initialize and run.
00443 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00444 extern "C" int PASCAL WinMain(
00445                         HINSTANCE hInstance,
00446                         HINSTANCE hPrevInstance,
00447                         LPSTR lpCmdLine,
00448                         int nCmdShow)
00449 {
00450   CMainWindow* pWin = NULL;
00451   MSG msg;
00452   HACCEL hAccel;
00453   int iRun = FALSE;
00454
00455   // If we were compiled for UNICODE and the platform seems OK with this
00456   // then proceed.  Else we error and exit the app.
00457   if (UnicodeOk())
00458   {
00459     // Call to initialize the COM Library.  Use the SUCCEEDED macro
00460     // to detect success.  If fail then exit app with error message.
00461     if (SUCCEEDED(CoInitialize(NULL)))
00462     {
00463       // If we succeeded in initializing the COM Library we proceed to
00464       // initialize the application.  If we can't init the application
00465       // then we signal shut down with an error message exit.
00466       iRun = InitApplication(hInstance);
00467
00468       if (iRun)
00469       {
00470         // Assume we'll set iRun to TRUE when initialization is done.
00471         iRun = FALSE;
00472         // We are still go for running so we try to create a nifty new
00473         // CMainWindow object for this app instance.
00474         pWin = new CMainWindow;
00475         if (NULL != pWin)
00476         {
00477           // Now we initialize an instance of the new CMainWindow.
00478           // This includes creating the main window.
00479           if (pWin->InitInstance(hInstance, nCmdShow))
00480           {
00481             // Load the keyboard accelerators from the resources.
00482             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
00483             if (NULL != hAccel)
00484             {
00485               // Signal App Initialization is successfully done.
00486               iRun = TRUE;
00487             }
00488           }
00489         }
00490       }
00491
00492       if (iRun)
00493       {
00494         // If we initialized the app instance properly then we are still
00495         // go for running.  We then start up the main message pump for
00496         // the application.
00497         while (GetMessage(&msg, NULL, 0, 0))
00498         {
00499           if (!TranslateAccelerator(
00500                  pWin->GetHwnd(),
00501                  hAccel,
00502                  &msg))
00503           {
00504             TranslateMessage(&msg);
00505             DispatchMessage(&msg);
00506           }
00507         }
00508
00509         // We'll pass to Windows the reason why we exited the message loop.
00510         iRun = msg.wParam;
00511       }
00512       else
00513       {
00514         // We failed to initialize the application. Put up error message
00515         // box saying that application couldn't be initialized.  Parent
00516         // window is desktop (ie, NULL). Exit the failed application
00517         // (ie, by returning FALSE to WinMain).
00518         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
00519
00520         // Delete the CMainWindow object.
00521         DELETE_POINTER(pWin);
00522       }
00523
00524       // We're exiting this app (either normally or by init failure) so
00525       // shut down the COM Library.
00526       CoUninitialize();
00527     }
00528     else
00529     {
00530       // We failed to Initialize the COM Library. Put up error message box
00531       // saying that COM Library couldn't be initialized.  Parent window
00532       // is desktop (ie, NULL). Exit the failed application (ie, by
00533       // returning FALSE to WinMain).
00534       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
00535     }
00536   }
00537   else
00538   {
00539     // If we were compiled for UNICODE but the platform has problems with
00540     // this then indicate an error and exit the app immediately.
00541     CHAR szMsg[MAX_STRING_LENGTH];
00542
00543     if (LoadStringA(
00544           hInstance,
00545           IDS_UNICODEFAIL,
00546           szMsg,
00547           MAX_STRING_LENGTH))
00548     {
00549       MessageBoxA(
00550         NULL,
00551         szMsg,
00552         ERROR_TITLE_STR,
00553         MB_OK | MB_ICONEXCLAMATION);
00554     }
00555   }
00556
00557   return iRun;
00558 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/CmdLineConsumer/Consumer.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • CmdLineConsumer

Consumer.Cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002
00003 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  Consumer.cpp
00006 //
00007 // Description:
00008 //      Event consumer class implementation
00009 //
00010 // History:
00011 //
00012 // **************************************************************************
00013
00014 #include "stdafx.h"
00015 #include "Consumer.h"
00016 #include <objbase.h>
00017 #include <strsafe.h>
00018
00019 CConsumer::CConsumer(CListBox *pOutputList)
00020 {
00021   m_cRef = 0L;
00022   m_pOutputList = pOutputList;
00023 }
00024
00025 CConsumer::~CConsumer()
00026 {
00027 }
00028
00029 STDMETHODIMP CConsumer::QueryInterface(REFIID riid, LPVOID FAR *ppv)
00030 {
00031     *ppv=NULL;
00032
00033     if (riid == IID_IUnknown || riid == IID_IWbemUnboundObjectSink)
00034         *ppv=this;
00035
00036     if (*ppv != NULL)
00037     {
00038         ((LPUNKNOWN)*ppv)->AddRef();
00039         return NOERROR;
00040     }
00041
00042     return E_NOINTERFACE;
00043 }
00044
00045 STDMETHODIMP_(ULONG) CConsumer::AddRef(void)
00046 {
00047     return ++m_cRef;
00048 }
00049
00050 STDMETHODIMP_(ULONG) CConsumer::Release(void)
00051 {
00052     if (--m_cRef != 0L)
00053         return m_cRef;
00054
00055     delete this;
00056     return 0L;
00057 }
00058
00059 STDMETHODIMP CConsumer::IndicateToConsumer(IWbemClassObject *pLogicalConsumer,
00060                       long lNumObjects,
00061                       IWbemClassObject **ppObjects)
00062 {
00063 /* for easy reference.
00064 #define SW_HIDE             0
00065 #define SW_SHOWNORMAL       1
00066 #define SW_NORMAL           1
00067 #define SW_SHOWMINIMIZED    2
00068 #define SW_SHOWMAXIMIZED    3
00069 #define SW_MAXIMIZE         3
00070 #define SW_SHOWNOACTIVATE   4
00071 #define SW_SHOW             5
00072 #define SW_MINIMIZE         6
00073 #define SW_SHOWMINNOACTIVE  7
00074 #define SW_SHOWNA           8
00075 #define SW_RESTORE          9
00076 #define SW_SHOWDEFAULT      10
00077 */
00078
00079   // NOTE: If this routine returns a failure code, including
00080   // GPFs from called routines, CIMOM will recreate the object
00081   // and call here again. If you see this routine being called
00082   // twice for every indication, it means this routine is
00083   // returning a failure code somehow. Especially watch the
00084   // AddRef()/Release() semantics for the embedded object.
00085   // If they're too low, you'll return a GPF.
00086   CString clMyBuff;
00087   BSTR tgtProp = NULL;
00088   BSTR showProp = NULL;
00089   BSTR tgt = NULL;
00090   UINT showWindow = SW_SHOWNORMAL;
00091   VARIANT pVal, pVal1;
00092   CString appName;
00093
00094   VariantInit(&pVal);
00095   VariantInit(&pVal1);
00096
00097   TRACE(_T("Indicate() called\n"));
00098
00099   tgtProp = SysAllocString(L"cmdLine");
00100   if (!tgtProp)
00101         return E_OUTOFMEMORY;
00102
00103   showProp = SysAllocString(L"ShowWindow");
00104   if (!showProp)
00105         return E_OUTOFMEMORY;
00106
00107   // clear my output buffer.
00108   clMyBuff.Empty();
00109
00110   //--------------------------------
00111   // NOTICE that I only call once per call, not once per object passed since
00112   //  I dont care what object caused the event anyway.
00113
00114   // get the 'Item' property out of the embedded object.
00115   if((pLogicalConsumer->Get(tgtProp, 0L, &pVal, NULL, NULL) == S_OK) &&
00116     (pLogicalConsumer->Get(showProp, 0L, &pVal1, NULL, NULL) == S_OK))
00117   {
00118     // pull out the command.
00119     tgt = V_BSTR(&pVal);
00120
00121     //if the application name does not contain any slashes,
00122     //assume it is in the System directory
00123     if (appName.Find('\\') < 0 &&
00124       appName.Find('/') < 0)
00125     {
00126       TCHAR tchSystemInfo[MAX_PATH + 1];
00127             if (GetSystemDirectory(tchSystemInfo, MAX_PATH+1)!= 0)
00128       {
00129         appName += tchSystemInfo;
00130         appName += _T("\\");
00131         appName += tgt;
00132       }
00133     }
00134     else  //full path must have been specified, pass it on to CreateProcess
00135     {
00136       appName += tgt;
00137     }
00138
00139     // take onto the display line.
00140     clMyBuff = _T("cmdLine will run: ");
00141     clMyBuff += appName;
00142
00143     // how to run the program.
00144     showWindow = (UINT)V_UI1(&pVal1);
00145
00146     // call CreateProcess
00147     STARTUPINFO si;
00148     memset(&si, 0, sizeof(si));
00149     si.cb          = sizeof(si);
00150     si.dwFlags     = STARTF_USESHOWWINDOW;
00151     si.wShowWindow = (unsigned short)showWindow;
00152
00153     PROCESS_INFORMATION pi;
00154     memset(&pi, 0, sizeof(pi));
00155     if (!CreateProcess(appName, NULL, NULL, NULL, FALSE,
00156               0, NULL, NULL, &si, &pi))
00157     {
00158       DWORD lastErr = GetLastError();
00159       TCHAR msg[100];
00160       _itot(lastErr, msg, 10);
00161       CString errMsg = _T("CreateProcess failed. Error ");
00162       errMsg +=(LPCTSTR)&msg[0];
00163
00164       m_pOutputList->AddString(errMsg);
00165     }
00166     else
00167     {
00168       // output the buffer.
00169       m_pOutputList->AddString(clMyBuff);
00170
00171       //IMPORTANT: remember to close handles after the spawned process
00172       //has signalled its completion:
00173
00174       //CloseHandle(pi.hProcess);
00175             //CloseHandle(pi.hThread);
00176     }
00177   }
00178   else
00179   {
00180     TRACE(_T("Get() cmdLine failed\n"));
00181   }
00182
00183   SysFreeString(tgtProp);
00184   VariantClear(&pVal);
00185
00186   TRACE(_T("walked indication list\n"));
00187
00188   return S_OK;
00189 }
00190
00191 // **************************************************************************
00192 //
00193 //  ErrorString()
00194 //
00195 // Description:
00196 //    Converts an HRESULT to a displayable string.
00197 //
00198 // Parameters:
00199 //    hRes (in) - HRESULT to be converted.
00200 //
00201 // Returns:
00202 //    ptr to displayable string.
00203 //
00204 // Globals accessed:
00205 //    None.
00206 //
00207 // Globals modified:
00208 //    None.
00209 //
00210 //===========================================================================
00211 LPCTSTR CConsumer::ErrorString(HRESULT hRes)
00212 {
00213     TCHAR szBuffer2[19];
00214   static TCHAR szBuffer[24];
00215   LPCTSTR psz;
00216
00217   switch(hRes)
00218     {
00219     case WBEM_NO_ERROR:
00220     psz = _T("WBEM_NO_ERROR");
00221     break;
00222     case WBEM_S_FALSE:
00223     psz = _T("WBEM_S_FALSE");
00224     break;
00225     case WBEM_S_NO_MORE_DATA:
00226     psz = _T("WBEM_S_NO_MORE_DATA");
00227     break;
00228   case WBEM_E_FAILED:
00229     psz = _T("WBEM_E_FAILED");
00230     break;
00231   case WBEM_E_NOT_FOUND:
00232     psz = _T("WBEM_E_NOT_FOUND");
00233     break;
00234   case WBEM_E_ACCESS_DENIED:
00235     psz = _T("WBEM_E_ACCESS_DENIED");
00236     break;
00237   case WBEM_E_PROVIDER_FAILURE:
00238     psz = _T("WBEM_E_PROVIDER_FAILURE");
00239     break;
00240   case WBEM_E_TYPE_MISMATCH:
00241     psz = _T("WBEM_E_TYPE_MISMATCH");
00242     break;
00243   case WBEM_E_OUT_OF_MEMORY:
00244     psz = _T("WBEM_E_OUT_OF_MEMORY");
00245     break;
00246   case WBEM_E_INVALID_CONTEXT:
00247     psz = _T("WBEM_E_INVALID_CONTEXT");
00248     break;
00249   case WBEM_E_INVALID_PARAMETER:
00250     psz = _T("WBEM_E_INVALID_PARAMETER");
00251     break;
00252   case WBEM_E_NOT_AVAILABLE:
00253     psz = _T("WBEM_E_NOT_AVAILABLE");
00254     break;
00255   case WBEM_E_CRITICAL_ERROR:
00256     psz = _T("WBEM_E_CRITICAL_ERROR");
00257     break;
00258   case WBEM_E_INVALID_STREAM:
00259     psz = _T("WBEM_E_INVALID_STREAM");
00260     break;
00261   case WBEM_E_NOT_SUPPORTED:
00262     psz = _T("WBEM_E_NOT_SUPPORTED");
00263     break;
00264   case WBEM_E_INVALID_SUPERCLASS:
00265     psz = _T("WBEM_E_INVALID_SUPERCLASS");
00266     break;
00267   case WBEM_E_INVALID_NAMESPACE:
00268     psz = _T("WBEM_E_INVALID_NAMESPACE");
00269     break;
00270   case WBEM_E_INVALID_OBJECT:
00271     psz = _T("WBEM_E_INVALID_OBJECT");
00272     break;
00273   case WBEM_E_INVALID_CLASS:
00274     psz = _T("WBEM_E_INVALID_CLASS");
00275     break;
00276   case WBEM_E_PROVIDER_NOT_FOUND:
00277     psz = _T("WBEM_E_PROVIDER_NOT_FOUND");
00278     break;
00279   case WBEM_E_INVALID_PROVIDER_REGISTRATION:
00280     psz = _T("WBEM_E_INVALID_PROVIDER_REGISTRATION");
00281     break;
00282   case WBEM_E_PROVIDER_LOAD_FAILURE:
00283     psz = _T("WBEM_E_PROVIDER_LOAD_FAILURE");
00284     break;
00285   case WBEM_E_INITIALIZATION_FAILURE:
00286     psz = _T("WBEM_E_INITIALIZATION_FAILURE");
00287     break;
00288   case WBEM_E_TRANSPORT_FAILURE:
00289     psz = _T("WBEM_E_TRANSPORT_FAILURE");
00290     break;
00291   case WBEM_E_INVALID_OPERATION:
00292     psz = _T("WBEM_E_INVALID_OPERATION");
00293     break;
00294   case WBEM_E_INVALID_QUERY:
00295     psz = _T("WBEM_E_INVALID_QUERY");
00296     break;
00297   case WBEM_E_INVALID_QUERY_TYPE:
00298     psz = _T("WBEM_E_INVALID_QUERY_TYPE");
00299     break;
00300   case WBEM_E_ALREADY_EXISTS:
00301     psz = _T("WBEM_E_ALREADY_EXISTS");
00302     break;
00303     case WBEM_S_ALREADY_EXISTS:
00304         psz = _T("WBEM_S_ALREADY_EXISTS");
00305         break;
00306     case WBEM_S_RESET_TO_DEFAULT:
00307         psz = _T("WBEM_S_RESET_TO_DEFAULT");
00308         break;
00309     case WBEM_S_DIFFERENT:
00310         psz = _T("WBEM_S_DIFFERENT");
00311         break;
00312     case WBEM_E_OVERRIDE_NOT_ALLOWED:
00313         psz = _T("WBEM_E_OVERRIDE_NOT_ALLOWED");
00314         break;
00315     case WBEM_E_PROPAGATED_QUALIFIER:
00316         psz = _T("WBEM_E_PROPAGATED_QUALIFIER");
00317         break;
00318     case WBEM_E_PROPAGATED_PROPERTY:
00319         psz = _T("WBEM_E_PROPAGATED_PROPERTY");
00320         break;
00321     case WBEM_E_UNEXPECTED:
00322         psz = _T("WBEM_E_UNEXPECTED");
00323         break;
00324     case WBEM_E_ILLEGAL_OPERATION:
00325         psz = _T("WBEM_E_ILLEGAL_OPERATION");
00326         break;
00327     case WBEM_E_CANNOT_BE_KEY:
00328         psz = _T("WBEM_E_CANNOT_BE_KEY");
00329         break;
00330     case WBEM_E_INCOMPLETE_CLASS:
00331         psz = _T("WBEM_E_INCOMPLETE_CLASS");
00332         break;
00333     case WBEM_E_INVALID_SYNTAX:
00334         psz = _T("WBEM_E_INVALID_SYNTAX");
00335         break;
00336     case WBEM_E_NONDECORATED_OBJECT:
00337         psz = _T("WBEM_E_NONDECORATED_OBJECT");
00338         break;
00339     case WBEM_E_READ_ONLY:
00340         psz = _T("WBEM_E_READ_ONLY");
00341         break;
00342     case WBEM_E_PROVIDER_NOT_CAPABLE:
00343         psz = _T("WBEM_E_PROVIDER_NOT_CAPABLE");
00344         break;
00345     case WBEM_E_CLASS_HAS_CHILDREN:
00346         psz = _T("WBEM_E_CLASS_HAS_CHILDREN");
00347         break;
00348     case WBEM_E_CLASS_HAS_INSTANCES:
00349         psz = _T("WBEM_E_CLASS_HAS_INSTANCES");
00350         break;
00351     case WBEM_E_QUERY_NOT_IMPLEMENTED:
00352         psz = _T("WBEM_E_QUERY_NOT_IMPLEMENTED");
00353         break;
00354     case WBEM_E_ILLEGAL_NULL:
00355         psz = _T("WBEM_E_ILLEGAL_NULL");
00356         break;
00357     case WBEM_E_INVALID_QUALIFIER_TYPE:
00358         psz = _T("WBEM_E_INVALID_QUALIFIER_TYPE");
00359         break;
00360     case WBEM_E_INVALID_PROPERTY_TYPE:
00361         psz = _T("WBEM_E_INVALID_PROPERTY_TYPE");
00362         break;
00363     case WBEM_E_VALUE_OUT_OF_RANGE:
00364         psz = _T("WBEM_E_VALUE_OUT_OF_RANGE");
00365         break;
00366     case WBEM_E_CANNOT_BE_SINGLETON:
00367         psz = _T("WBEM_E_CANNOT_BE_SINGLETON");
00368         break;
00369   default:
00370     _itot(hRes, szBuffer2, 16);
00371     StringCbCopy(szBuffer, sizeof(szBuffer),_T("0x"));
00372       StringCbCat(szBuffer, sizeof(szBuffer), szBuffer2);
00373     psz = szBuffer;
00374   }
00375   return psz;
00376 }
00377
Generated on Wed Nov 13 2024 16:52:39 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/IMEApps/Wapi.h Source File

  • WinUI
  • Input
  • Ime
  • IMEApps

Wapi.h

Go to the documentation of this file.
00001 /* Unicode/Ansi stubs */
00002 #ifdef USEWAPI
00003 typedef LPWSTR            LPMYSTR;
00004 typedef WCHAR             MYCHAR;
00005 #define MYTEXT(x)         L ## x
00006 #define Mylstrlen(x)      lstrlenW(x)
00007 #define Mylstrcpy(x, y)   MylstrcpyW((x), (y))
00008 #define Mylstrcat(x, y)   MylstrcatW((x), (y))
00009 #define Mylstrcmp(x, y)   MylstrcmpW((x), (y))
00010 #define MyCharPrev(x, y)  MyCharPrevW((x), (y))
00011 #define MyCharNext(x)     MyCharNextW(x)
00012 #define LPMYIMEMENUITEMINFO LPIMEMENUITEMINFOW
00013 #define MYIMEMENUITEMINFO IMEMENUITEMINFOW
00014 #define MyImmGetImeMenuItems  ImmGetImeMenuItemsW
00015 #define MyImmGetCompositionString ImmGetCompositionStringW
00016 #else
00017 typedef LPTSTR            LPMYSTR;
00018 typedef TCHAR             MYCHAR;
00019 #define MYTEXT(x)         x
00020 #define Mylstrlen(x)      lstrlen(x)
00021 #define Mylstrcpy(x, y)   lstrcpy((x), (y))
00022 #define Mylstrcat(x, y)   lstrcat((x), (y))
00023 #define Mylstrcmp(x, y)   lstrcmp((x), (y))
00024 #define MyCharPrev(x, y)  AnsiPrev((x), (y))
00025 #define MyCharNext(x)     AnsiNext(x)
00026 #define LPMYIMEMENUITEMINFO LPIMEMENUITEMINFO
00027 #define MYIMEMENUITEMINFO IMEMENUITEMINFO
00028 #define MyImmGetImeMenuItems  ImmGetImeMenuItems
00029 #define MyImmGetCompositionString ImmGetCompositionString
00030 #endif
00031
00032 #ifdef USEWAPI
00033 int WINAPI MylstrcmpW(LPWSTR lp0, LPWSTR lp1);
00034 int WINAPI MylstrcpyW(LPWSTR lp0, LPWSTR lp1);
00035 int WINAPI MylstrcatW(LPWSTR lp0, LPWSTR lp1);
00036 LPWSTR WINAPI MyCharPrevW(LPWSTR lpStart, LPWSTR lpCur);
00037 LPWSTR WINAPI MyCharNextW(LPWSTR lp);
00038 #endif
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CMyEvictListener Member List

This is the complete list of members for CMyEvictListener, including all inherited members.
CMyEvictListener(void) | CMyEvictListener | [protected]
EvictNotify(LPCWSTR pcszNodeNameIn) | CMyEvictListener |
Initialize(IUnknown *punkCallbackIn, LCID lcidIn) | CMyEvictListener |
m_lcid | CMyEvictListener | [private]
m_piccCallback | CMyEvictListener | [private]
~CMyEvictListener(void) | CMyEvictListener | [protected]
Generated on Wed Nov 13 2024 16:56:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/registry.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

registry.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <assert.h>
00021
00022 #include "Registry.h"
00023
00024 #define STRINGS_ONLY
00025 #include "globals.h"
00026
00027 ////////////////////////////////////////////////////////
00028 //
00029 // Internal helper functions prototypes
00030 //
00031
00032 // Set the given key and its value.
00033 BOOL setKeyAndValue(const _TCHAR* pszPath,
00034                     const _TCHAR* szSubkey,
00035                     const _TCHAR* szValue) ;
00036
00037 // Set the given key and its value in the MMC Snapin location
00038 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00039                           const _TCHAR* szSubkey,
00040                           const _TCHAR* szName,
00041                           const _TCHAR* szValue);
00042
00043 // Set the given valuename under the key to value
00044 BOOL setValue(const _TCHAR* szKey,
00045               const _TCHAR* szValueName,
00046               const _TCHAR* szValue);
00047
00048 // Delete szKeyChild and all of its descendents.
00049 LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
00050
00051 ////////////////////////////////////////////////////////
00052 //
00053 // Constants
00054 //
00055
00056 // Size of a CLSID as a string
00057 //const int CLSID_STRING_SIZE = 39 ;
00058
00059 /////////////////////////////////////////////////////////
00060 //
00061 // Public function implementation
00062 //
00063
00064 //
00065 // Register the component in the registry.
00066 //
00067 HRESULT RegisterServer(HMODULE hModule,            // DLL module handle
00068                        const CLSID& clsid,         // Class ID
00069                        const _TCHAR* szFriendlyName)       //   IDs
00070 {
00071     // Get server location.
00072     _TCHAR szModule[512] ;
00073     DWORD dwResult =
00074         ::GetModuleFileName(hModule,
00075         szModule,
00076         sizeof(szModule)/sizeof(_TCHAR)) ;
00077
00078     assert(dwResult != 0) ;
00079
00080     // Get CLSID
00081     LPOLESTR wszCLSID = NULL ;
00082     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00083
00084     assert(SUCCEEDED(hr)) ;
00085
00086   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00087
00088     // Build the key CLSID\\{...}
00089     _TCHAR szKey[64] ;
00090     _tcscpy(szKey, _T("CLSID\\")) ;
00091   _tcscat(szKey, pszCLSID) ;
00092
00093     // Add the CLSID to the registry.
00094     setKeyAndValue(szKey, NULL, szFriendlyName) ;
00095
00096     // Add the server filename subkey under the CLSID key.
00097     setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
00098
00099     // set the threading model
00100     _tcscat(szKey, _T("\\InprocServer32"));
00101     setValue(szKey, _T("ThreadingModel"), _T("Apartment"));
00102
00103     // Free memory.
00104     CoTaskMemFree(wszCLSID) ;
00105
00106     return S_OK ;
00107 }
00108
00109 //
00110 // Remove the component from the registry.
00111 //
00112 LONG UnregisterServer(const CLSID& clsid)       //   IDs
00113 {
00114     // Get CLSID
00115     LPOLESTR wszCLSID = NULL ;
00116     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00117
00118
00119     // Build the key CLSID\\{...}
00120     _TCHAR szKey[64] ;
00121     _tcscpy(szKey, _T("CLSID\\")) ;
00122
00123   MAKE_TSTRPTR_FROMWIDE(pszT, wszCLSID);
00124   _tcscat(szKey, pszT) ;
00125
00126     // Delete the CLSID Key - CLSID\{...}
00127     LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
00128     assert((lResult == ERROR_SUCCESS) ||
00129          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00130
00131     // Free memory.
00132     CoTaskMemFree(wszCLSID) ;
00133
00134     return S_OK ;
00135 }
00136
00137 //
00138 // Register the snap-in in the registry.
00139 //
00140 HRESULT RegisterSnapin(const CLSID& clsid,         // Class ID
00141                        const _TCHAR* szNameString,   // NameString
00142                        const CLSID& clsidAbout,   // Class Id for About Class
00143                        const BOOL fSupportExtensions)
00144 {
00145     // Get CLSID
00146     LPOLESTR wszCLSID = NULL ;
00147     LPOLESTR wszAboutCLSID = NULL;
00148     HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
00149
00150     if (IID_NULL != clsidAbout)
00151         hr = StringFromCLSID(clsidAbout, &wszAboutCLSID);
00152
00153   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00154   MAKE_TSTRPTR_FROMWIDE(pszAboutCLSID, wszAboutCLSID);
00155
00156
00157     // Add the CLSID to the registry.
00158     setSnapInKeyAndValue(pszCLSID, NULL, _T("NameString"), szNameString) ;
00159     setSnapInKeyAndValue(pszCLSID, _T("StandAlone"), NULL, NULL);
00160     if (IID_NULL != clsidAbout)
00161         setSnapInKeyAndValue(pszCLSID, NULL, _T("About"), pszAboutCLSID);
00162
00163     if (fSupportExtensions) {
00164         // Build the key NodeType
00165         setSnapInKeyAndValue(pszCLSID, _T("NodeTypes"), NULL, NULL);
00166
00167         _TCHAR szKey[64] ;
00168         _tcscpy(szKey, pszCLSID) ;
00169         _tcscat(szKey, _T("\\NodeTypes")) ;
00170         setSnapInKeyAndValue(szKey, pszCLSID, NULL, NULL);
00171     }
00172
00173     // Free memory.
00174     CoTaskMemFree(wszCLSID) ;
00175     if (IID_NULL != clsidAbout)
00176         CoTaskMemFree(wszAboutCLSID);
00177
00178     return S_OK ;
00179 }
00180
00181 //
00182 // Unregister the snap-in in the registry.
00183 //
00184 HRESULT UnregisterSnapin(const CLSID& clsid)         // Class ID
00185 {
00186     _TCHAR szKeyBuf[1024];
00187     LPOLESTR wszCLSID = NULL;
00188
00189     // Get CLSID
00190     HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
00191   MAKE_TSTRPTR_FROMWIDE(pszCLSID, wszCLSID);
00192
00193     // Load the buffer with the Snap-In Location
00194     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00195
00196     // Copy keyname into buffer.
00197     _tcscat(szKeyBuf, _T("\\"));
00198     _tcscat(szKeyBuf, pszCLSID);
00199
00200     // Delete the CLSID Key - CLSID\{...}
00201     LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
00202     assert((lResult == ERROR_SUCCESS) ||
00203          (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
00204
00205     // free the memory
00206     CoTaskMemFree(wszCLSID);
00207
00208     return S_OK;
00209 }
00210
00211 //
00212 // Delete a key and all of its descendents.
00213 //
00214 LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
00215                         const _TCHAR* lpszKeyChild)  // Key to delete
00216 {
00217     // Open the child.
00218     HKEY hKeyChild ;
00219     LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
00220         KEY_ALL_ACCESS, &hKeyChild) ;
00221     if (lRes != ERROR_SUCCESS)
00222     {
00223         return lRes ;
00224     }
00225
00226     // Enumerate all of the decendents of this child.
00227     FILETIME time ;
00228     _TCHAR szBuffer[256] ;
00229     DWORD dwSize = 256 ;
00230     while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
00231         NULL, NULL, &time) == S_OK)
00232     {
00233         // Delete the decendents of this child.
00234         lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
00235         if (lRes != ERROR_SUCCESS)
00236         {
00237             // Cleanup before exiting.
00238             RegCloseKey(hKeyChild) ;
00239             return lRes;
00240         }
00241         dwSize = 256 ;
00242     }
00243
00244     // Close the child.
00245     RegCloseKey(hKeyChild) ;
00246
00247     // Delete this child.
00248     return RegDeleteKey(hKeyParent, lpszKeyChild) ;
00249 }
00250
00251 //
00252 // Create a key and set its value.
00253 //   - This helper function was borrowed and modifed from
00254 //     Kraig Brockschmidt's book Inside OLE.
00255 //
00256 BOOL setKeyAndValue(const _TCHAR* szKey,
00257                     const _TCHAR* szSubkey,
00258                     const _TCHAR* szValue)
00259 {
00260     HKEY hKey;
00261     _TCHAR szKeyBuf[1024] ;
00262
00263     // Copy keyname into buffer.
00264     _tcscpy(szKeyBuf, szKey) ;
00265
00266     // Add subkey name to buffer.
00267     if (szSubkey != NULL)
00268     {
00269         _tcscat(szKeyBuf, _T("\\")) ;
00270         _tcscat(szKeyBuf, szSubkey ) ;
00271     }
00272
00273     // Create and open key and subkey.
00274     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00275         szKeyBuf,
00276         0, NULL, REG_OPTION_NON_VOLATILE,
00277         KEY_ALL_ACCESS, NULL,
00278         &hKey, NULL) ;
00279     if (lResult != ERROR_SUCCESS)
00280     {
00281         return FALSE ;
00282     }
00283
00284     // Set the Value.
00285     if (szValue != NULL)
00286     {
00287         RegSetValueEx(hKey, NULL, 0, REG_SZ,
00288             (BYTE *)szValue,
00289             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00290     }
00291
00292     RegCloseKey(hKey) ;
00293     return TRUE ;
00294 }
00295
00296 //
00297 // Open a key value and set it
00298 //
00299 BOOL setValue(const _TCHAR* szKey,
00300               const _TCHAR* szValueName,
00301               const _TCHAR* szValue)
00302 {
00303     HKEY hKey;
00304     _TCHAR szKeyBuf[1024] ;
00305
00306     // Copy keyname into buffer.
00307     _tcscpy(szKeyBuf, szKey) ;
00308
00309     // Create and open key and subkey.
00310     long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
00311         szKeyBuf,
00312         0, NULL, REG_OPTION_NON_VOLATILE,
00313         KEY_ALL_ACCESS, NULL,
00314         &hKey, NULL) ;
00315     if (lResult != ERROR_SUCCESS)
00316     {
00317         return FALSE ;
00318     }
00319
00320     // Set the Value.
00321     if (szValue != NULL)
00322     {
00323         RegSetValueEx(hKey, szValueName, 0, REG_SZ,
00324             (BYTE *)szValue,
00325             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00326     }
00327
00328     RegCloseKey(hKey) ;
00329     return TRUE ;
00330 }
00331
00332 //
00333 // Create a key and set its value.
00334 //   - This helper function was borrowed and modifed from
00335 //     Kraig Brockschmidt's book Inside OLE.
00336 //
00337 BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
00338                           const _TCHAR* szSubkey,
00339                           const _TCHAR* szName,
00340                           const _TCHAR* szValue)
00341 {
00342     HKEY hKey;
00343     _TCHAR szKeyBuf[1024] ;
00344
00345     // Load the buffer with the Snap-In Location
00346     _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
00347
00348     // Copy keyname into buffer.
00349     _tcscat(szKeyBuf, _T("\\")) ;
00350     _tcscat(szKeyBuf, szKey) ;
00351
00352     // Add subkey name to buffer.
00353     if (szSubkey != NULL)
00354     {
00355         _tcscat(szKeyBuf, _T("\\")) ;
00356         _tcscat(szKeyBuf, szSubkey ) ;
00357     }
00358
00359     // Create and open key and subkey.
00360     long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
00361         szKeyBuf,
00362         0, NULL, REG_OPTION_NON_VOLATILE,
00363         KEY_ALL_ACCESS, NULL,
00364         &hKey, NULL) ;
00365     if (lResult != ERROR_SUCCESS)
00366     {
00367         return FALSE ;
00368     }
00369
00370     // Set the Value.
00371     if (szValue != NULL)
00372     {
00373         RegSetValueEx(hKey, szName, 0, REG_SZ,
00374             (BYTE *)szValue,
00375             (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
00376     }
00377
00378     RegCloseKey(hKey) ;
00379     return TRUE ;
00380 }
00381
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/rds/handler/vc/util.h Source File

  • Dataaccess
  • rds
  • handler
  • vc

util.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File:    util.h
00004 //
00005 // Copyright: Copyright (c) 1991-1999 Microsoft Corporation
00006 //
00007 // Contents:  Definition of class CUtil
00008 //
00009 // Comments:
00010 //
00011 //-----------------------------------------------------------------------------
00012
00013 #ifndef UTIL_H
00014 #define UTIL_H
00015
00016 #include <assert.h>
00017
00018 #define UTIL_NOACCESS   0
00019 #define UTIL_READONLY   2
00020 #define UTIL_READWRITE  3
00021
00022 void ThrowHR(HRESULT hr);
00023
00024
00025 const DWORD CUtilString_padsize = 1024;
00026
00027 class CUtilString   // Never write directly into buffers returned, unless fAllowStomping is true!
00028 {
00029 public:
00030   CUtilString(bool fAllowStomping = false)
00031   {
00032     Clear();
00033     m_fAllowStomping = fAllowStomping;
00034   }
00035   ~CUtilString() { Free(); }
00036   CUtilString(const WCHAR* s, bool fAllowStomping = false)
00037   {
00038     Clear();
00039     *this = s;
00040     m_fAllowStomping = fAllowStomping;
00041   }
00042   CUtilString(const CHAR* s, bool fAllowStomping = false)
00043   {
00044     Clear();
00045     *this = s;
00046     m_fAllowStomping = fAllowStomping;
00047   }
00048   operator WCHAR*()
00049   {
00050     return m_pwszVal;
00051   }
00052   operator CHAR*()
00053   {
00054     if (!m_pwszVal)
00055       return NULL;
00056     assert(m_fAllowStomping || m_dwCurLen == wcslen(m_pwszVal));
00057     if (!m_fDirty && !m_fAllowStomping)
00058       return m_pszVal;
00059     m_fDirty = false;
00060     delete [] m_pszVal;
00061     DWORD len = WideCharToMultiByte(CP_ACP, 0, m_pwszVal, -1, 0, 0, 0, 0);
00062     m_pszVal = new CHAR[len+1];
00063     if (WideCharToMultiByte(CP_ACP, 0, m_pwszVal, -1, m_pszVal, len, 0, 0) == 0)
00064       m_pszVal[0] = '\0';
00065     return m_pszVal;
00066   }
00067   CUtilString& operator=(const CUtilString& s)
00068   {
00069     return operator=(s.m_pwszVal);
00070   }
00071   CUtilString& operator=(const WCHAR* s)
00072   {
00073     Free();
00074     if (s)
00075     {
00076       m_dwCurLen = wcslen(s);
00077       m_dwMaxLen = m_dwCurLen + CUtilString_padsize;
00078       m_pwszVal = new WCHAR[m_dwMaxLen+1];
00079       wcscpy(m_pwszVal, s);
00080       assert(m_dwCurLen == wcslen(m_pwszVal));
00081     }
00082     return *this;
00083   }
00084   CUtilString& operator+=(const WCHAR* s)
00085   {
00086     if (!s)
00087       return *this;
00088     if (!m_pwszVal)
00089       return operator=(s);
00090     if (m_fAllowStomping)
00091       m_dwCurLen = wcslen(m_pwszVal);
00092     assert(m_dwCurLen == wcslen(m_pwszVal));
00093     m_fDirty = true;
00094     DWORD len = wcslen(s);
00095     if ((m_dwCurLen+len) > m_dwMaxLen)
00096     {
00097       m_dwMaxLen = m_dwCurLen + len + CUtilString_padsize;
00098       WCHAR * pwsz = new WCHAR[m_dwMaxLen+1];
00099       wcscpy(pwsz, m_pwszVal);
00100       delete [] m_pwszVal;
00101       m_pwszVal = pwsz;
00102     }
00103     wcscpy(m_pwszVal+m_dwCurLen, s);
00104     m_dwCurLen += len;
00105     assert(m_dwCurLen == wcslen(m_pwszVal));
00106     return *this;
00107   }
00108   CUtilString& operator=(const CHAR* s)
00109   {
00110     Free();
00111     if (s)
00112     {
00113       m_dwCurLen = MultiByteToWideChar(CP_ACP, 0, s, -1, 0, 0);
00114       if (m_dwCurLen)
00115       {
00116         m_dwCurLen--;
00117         m_dwMaxLen = m_dwCurLen + CUtilString_padsize;
00118         m_pwszVal = new WCHAR[m_dwMaxLen+1];
00119         if (MultiByteToWideChar(CP_ACP, 0, s, -1, m_pwszVal, m_dwMaxLen+1) == 0)
00120         {
00121           m_pwszVal[0] = L'\0';
00122           m_dwCurLen = 0;
00123         }
00124         assert(m_dwCurLen == wcslen(m_pwszVal));
00125       }
00126     }
00127     return *this;
00128   }
00129   void Free() { delete [] m_pwszVal; delete [] m_pszVal; Clear(); }
00130   void Clear() { m_pwszVal = NULL; m_pszVal = NULL; m_dwCurLen = 0; m_dwMaxLen = 0; m_fDirty = true; m_fAllowStomping = false; }
00131
00132 private:
00133   WCHAR *m_pwszVal;
00134   CHAR *m_pszVal;
00135   DWORD m_dwCurLen;
00136   DWORD m_dwMaxLen;
00137   bool m_fDirty;
00138   bool m_fAllowStomping;
00139 };
00140
00141
00142 class CUtil
00143 {
00144 public:
00145   CUtil();
00146   ~CUtil();
00147   void SetIniFile(BSTR args);
00148   void SetSql(BSTR str);
00149   void SetConn(BSTR conn);
00150   inline WCHAR *GetSql()  { return (WCHAR *)m_bstrSql; }
00151   inline WCHAR *GetConn()  { return (WCHAR *)m_bstrConn; }
00152   inline BOOL HasReadAccess()  { return (m_lAccess >= UTIL_READONLY); }
00153   inline BOOL HasWriteAccess()  { return (m_lAccess == UTIL_READWRITE); }
00154   void RaiseError(HRESULT hr);
00155   inline CHAR * GetUsername()  { return m_pszUsername; }
00156
00157 private:
00158   void SubstituteParameters(CUtilString &RetVal, CHAR * str, WCHAR * params);  // NOTE: this function is destructive to the "params" buffer.
00159   CHAR * GetIniString(CHAR * section, CHAR * key);
00160   void SetSection(void);
00161   void ParseConn(WCHAR * conn);
00162
00163   // INI file
00164   CUtilString m_bstrIniFile;
00165   CHAR * m_pszLastIniString;
00166   ULONG m_cLastIniString;
00167
00168   // Username variables.
00169   CHAR * m_pszUsername;
00170
00171   // SQL variables.
00172   CUtilString m_bstrSqlSection;
00173   CUtilString m_bstrSql;
00174
00175   // Connection variables.
00176   CUtilString m_bstrSectionName;
00177   CUtilString m_bstrSectionConn;
00178   CUtilString m_bstrSectionUserlist;
00179   CUtilString m_bstrConn;
00180   CUtilString m_bstrDatasource;
00181   long m_lAccess;
00182 };
00183
00184
00185 class CUtilBSTR
00186 {
00187 public:
00188   CUtilBSTR(WCHAR *s) { m_bstr = SysAllocString(s); }
00189   ~CUtilBSTR() { SysFreeString(m_bstr); }
00190   operator BSTR() { return m_bstr; }
00191 private:
00192   BSTR m_bstr;
00193 };
00194
00195
00196 template <class T>
00197 class CUtilComPtr
00198 {
00199 public:
00200   CUtilComPtr() { m_p = NULL; }
00201   ~CUtilComPtr() { if (m_p) m_p->Release(); }
00202   operator T*() { return m_p; }
00203   T** operator&() { assert(m_p==NULL); return &m_p; }
00204   T * Detach() { T * p = m_p; m_p = NULL; return p; }
00205 private:
00206   T * m_p;
00207 };
00208
00209
00210 #endif
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/Utility.Cpp Source File

  • WinUI
  • Shell
  • SampView

Utility.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Utility.cpp
00013
00014    Description:   Utility function implementation
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "Utility.h"
00023 #include "ShlFldr.h"
00024 #include "resource.h"
00025 #include "Commands.h"
00026 #include <ShellApi.h>
00027 #include <shlwapi.h>
00028
00029 /**************************************************************************
00030    global variables
00031 **************************************************************************/
00032
00033 #define MAIN_KEY_STRING          (TEXT("Software\\SampleView"))
00034 #define VALUE_STRING             (TEXT("Display Settings"))
00035 #define DISPLAY_SETTINGS_COUNT   1
00036
00037 /**************************************************************************
00038
00039    CompareItems()
00040
00041 **************************************************************************/
00042
00043 int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
00044 {
00045 CShellFolder  *pFolder = (CShellFolder*)lpData;
00046
00047 if(!pFolder)
00048    return 0;
00049
00050 HRESULT  hr = pFolder->CompareIDs(0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2);
00051
00052 return (SHORT)HRESULT_CODE(hr);
00053 }
00054
00055 /**************************************************************************
00056
00057    SaveGlobalSettings()
00058
00059 **************************************************************************/
00060
00061 BOOL SaveGlobalSettings(void)
00062 {
00063 HKEY  hKey;
00064 LONG  lResult;
00065 DWORD dwDisp;
00066
00067 lResult = RegCreateKeyEx(  HKEY_CURRENT_USER,
00068                            MAIN_KEY_STRING,
00069                            0,
00070                            NULL,
00071                            REG_OPTION_NON_VOLATILE,
00072                            KEY_ALL_ACCESS,
00073                            NULL,
00074                            &hKey,
00075                            &dwDisp);
00076
00077 if(lResult != ERROR_SUCCESS)
00078    return FALSE;
00079
00080 //create an array to put our data in
00081 DWORD dwArray[DISPLAY_SETTINGS_COUNT];
00082 dwArray[0] = g_nColumn;
00083
00084 //save the last printer selected
00085 lResult = RegSetValueEx(   hKey,
00086                            VALUE_STRING,
00087                            0,
00088                            REG_BINARY,
00089                            (LPBYTE)dwArray,
00090                            sizeof(dwArray));
00091
00092 RegCloseKey(hKey);
00093
00094 if(lResult != ERROR_SUCCESS)
00095    return FALSE;
00096
00097 return TRUE;
00098 }
00099
00100 /**************************************************************************
00101
00102    GetGlobalSettings()
00103
00104 **************************************************************************/
00105
00106 VOID GetGlobalSettings(VOID)
00107 {
00108 LPITEMIDLIST   pidl = NULL;
00109
00110 g_nColumn = INITIAL_COLUMN_SIZE;
00111
00112 LoadString(g_hInst, IDS_EXT_TITLE, g_szExtTitle, TITLE_SIZE);
00113
00114 *g_szStoragePath = 0;
00115 SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
00116
00117 if(pidl)
00118    {
00119    IMalloc *pMalloc;
00120
00121    SHGetPathFromIDList(pidl, g_szStoragePath);
00122
00123    SHGetMalloc(&pMalloc);
00124    if(pMalloc)
00125       {
00126       pMalloc->Free(pidl);
00127       pMalloc->Release();
00128       }
00129    }
00130 else
00131    {
00132    GetWindowsDirectory(g_szStoragePath, MAX_PATH);
00133    }
00134
00135 SmartAppendBackslash(g_szStoragePath, MAX_PATH);
00136 StrCatBuff(g_szStoragePath, g_szExtTitle, MAX_PATH);
00137 SmartAppendBackslash(g_szStoragePath, MAX_PATH);
00138 CreateDirectory(g_szStoragePath, NULL);
00139
00140 HKEY     hKey;
00141 LRESULT  lResult;
00142 lResult = RegOpenKeyEx( HKEY_CURRENT_USER,
00143                         MAIN_KEY_STRING,
00144                         0,
00145                         KEY_ALL_ACCESS,
00146                         &hKey);
00147
00148 if(lResult != ERROR_SUCCESS)
00149    return;
00150
00151 //create an array to put our data in
00152 DWORD dwArray[DISPLAY_SETTINGS_COUNT];
00153 DWORD dwType;
00154 DWORD dwSize = sizeof(dwArray);
00155
00156 //get the saved data
00157 lResult = RegQueryValueEx( hKey,
00158                            VALUE_STRING,
00159                            NULL,
00160                            &dwType,
00161                            (LPBYTE)dwArray,
00162                            &dwSize);
00163
00164 RegCloseKey(hKey);
00165
00166 if(lResult != ERROR_SUCCESS)
00167    return;
00168
00169 g_nColumn = dwArray[0];
00170 }
00171
00172 /**************************************************************************
00173
00174    CreateImageLists()
00175
00176 **************************************************************************/
00177
00178 VOID CreateImageLists(VOID)
00179 {
00180 int   cx;
00181 int   cy;
00182
00183 cx = GetSystemMetrics(SM_CXSMICON);
00184 cy = GetSystemMetrics(SM_CYSMICON);
00185
00186 if(g_himlSmall)
00187    ImageList_Destroy(g_himlSmall);
00188
00189 //set the small image list
00190 g_himlSmall = ImageList_Create(cx, cy, ILC_COLORDDB | ILC_MASK, 3, 0);
00191
00192 if(g_himlSmall)
00193    {
00194    HICON       hIcon;
00195    TCHAR       szFolder[MAX_PATH];
00196    SHFILEINFO  sfi;
00197
00198    //add the item icon
00199    hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAINICON), IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR);
00200    ImageList_AddIcon(g_himlSmall, hIcon);
00201
00202    //add the closed folder icon
00203    GetWindowsDirectory(szFolder, MAX_PATH);
00204    SHGetFileInfo( szFolder,
00205                   0,
00206                   &sfi,
00207                   sizeof(sfi),
00208                   SHGFI_ICON | SHGFI_SMALLICON);
00209    ImageList_AddIcon(g_himlSmall, sfi.hIcon);
00210
00211    //add the open folder icon
00212    SHGetFileInfo( szFolder,
00213                   0,
00214                   &sfi,
00215                   sizeof(sfi),
00216                   SHGFI_ICON | SHGFI_SMALLICON | SHGFI_OPENICON);
00217    ImageList_AddIcon(g_himlSmall, sfi.hIcon);
00218    }
00219
00220 if(g_himlLarge)
00221    ImageList_Destroy(g_himlLarge);
00222
00223 cx = GetSystemMetrics(SM_CXICON);
00224 cy = GetSystemMetrics(SM_CYICON);
00225
00226 //set the large image list
00227 g_himlLarge = ImageList_Create(cx, cy, ILC_COLORDDB | ILC_MASK, 4, 0);
00228
00229 if(g_himlLarge)
00230    {
00231    HICON       hIcon;
00232    TCHAR       szFolder[MAX_PATH];
00233    SHFILEINFO  sfi;
00234
00235    //add the item icon
00236    hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAINICON), IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR);
00237    ImageList_AddIcon(g_himlLarge, hIcon);
00238
00239    //add the closed folder icon
00240    GetWindowsDirectory(szFolder, MAX_PATH);
00241    ZeroMemory(&sfi, sizeof(sfi));
00242    SHGetFileInfo( szFolder,
00243                   0,
00244                   &sfi,
00245                   sizeof(sfi),
00246                   SHGFI_ICON);
00247    ImageList_AddIcon(g_himlLarge, sfi.hIcon);
00248
00249    //add the open folder icon
00250    GetWindowsDirectory(szFolder, MAX_PATH);
00251    ZeroMemory(&sfi, sizeof(sfi));
00252    SHGetFileInfo( szFolder,
00253                   0,
00254                   &sfi,
00255                   sizeof(sfi),
00256                   SHGFI_ICON | SHGFI_OPENICON);
00257    ImageList_AddIcon(g_himlLarge, sfi.hIcon);
00258    }
00259
00260 }
00261
00262 /**************************************************************************
00263
00264    DestroyImageLists()
00265
00266 **************************************************************************/
00267
00268 VOID DestroyImageLists(VOID)
00269 {
00270 if(g_himlSmall)
00271    ImageList_Destroy(g_himlSmall);
00272
00273 if(g_himlLarge)
00274    ImageList_Destroy(g_himlLarge);
00275 }
00276
00277 /**************************************************************************
00278
00279    WideCharToLocal()
00280
00281 **************************************************************************/
00282
00283 int WideCharToLocal(LPTSTR pLocal, LPCWSTR pWide, DWORD dwChars)
00284 {
00285 *pLocal = 0;
00286
00287 #ifdef UNICODE
00288 lstrcpyn(pLocal, pWide, dwChars);
00289 #else
00290 WideCharToMultiByte( CP_ACP,
00291                      0,
00292                      pWide,
00293                      -1,
00294                      pLocal,
00295                      dwChars,
00296                      NULL,
00297                      NULL);
00298 #endif
00299
00300 return lstrlen(pLocal);
00301 }
00302
00303 /**************************************************************************
00304
00305    LocalToWideChar()
00306
00307 **************************************************************************/
00308
00309 int LocalToWideChar(LPWSTR pWide, LPCTSTR pLocal, DWORD dwChars)
00310 {
00311 *pWide = 0;
00312
00313 #ifdef UNICODE
00314 lstrcpyn(pWide, pLocal, dwChars);
00315 #else
00316 MultiByteToWideChar( CP_ACP,
00317                      0,
00318                      pLocal,
00319                      -1,
00320                      pWide,
00321                      dwChars);
00322 #endif
00323
00324 return lstrlenW(pWide);
00325 }
00326
00327 /**************************************************************************
00328
00329    LocalToAnsi()
00330
00331 **************************************************************************/
00332
00333 int LocalToAnsi(LPSTR pAnsi, LPCTSTR pLocal, DWORD dwChars)
00334 {
00335 *pAnsi = 0;
00336
00337 #ifdef UNICODE
00338 WideCharToMultiByte( CP_ACP,
00339                      0,
00340                      pLocal,
00341                      -1,
00342                      pAnsi,
00343                      dwChars,
00344                      NULL,
00345                      NULL);
00346 #else
00347 lstrcpyn(pAnsi, pLocal, dwChars);
00348 #endif
00349
00350 return lstrlenA(pAnsi);
00351 }
00352
00353 /**************************************************************************
00354
00355    SmartAppendBackslash()
00356
00357 **************************************************************************/
00358
00359 VOID SmartAppendBackslash(LPTSTR pszPath, DWORD cchPath)
00360 {
00361 if(*(pszPath + lstrlen(pszPath) - 1) != '\\')
00362    StrCatBuff(pszPath, TEXT("\\"), cchPath);
00363 }
00364
00365 /**************************************************************************
00366
00367    BuildDataFileName()
00368
00369 **************************************************************************/
00370
00371 int BuildDataFileName(LPTSTR pszDataFile, LPCTSTR pszPath, DWORD dwChars)
00372 {
00373 if(dwChars < (DWORD)(lstrlen(pszPath) + 1 + lstrlen(c_szDataFile)))
00374    return 0;
00375
00376 lstrcpyn(pszDataFile, pszPath, dwChars);
00377 SmartAppendBackslash(pszDataFile, dwChars);
00378 StrCatBuff(pszDataFile, c_szDataFile, dwChars);
00379
00380 return lstrlen(pszDataFile);
00381 }
00382
00383 /**************************************************************************
00384
00385    AnsiToLocal()
00386
00387 **************************************************************************/
00388
00389 int AnsiToLocal(LPTSTR pLocal, LPSTR pAnsi, DWORD dwChars)
00390 {
00391 *pLocal = 0;
00392
00393 #ifdef UNICODE
00394 MultiByteToWideChar( CP_ACP,
00395                      0,
00396                      pAnsi,
00397                      -1,
00398                      pLocal,
00399                      dwChars);
00400 #else
00401 lstrcpyn(pLocal, pAnsi, dwChars);
00402 #endif
00403
00404 return lstrlen(pLocal);
00405 }
00406
00407 /**************************************************************************
00408
00409    GetTextFromSTRRET()
00410
00411 **************************************************************************/
00412
00413 BOOL GetTextFromSTRRET( IMalloc * pMalloc,
00414                         LPSTRRET pStrRet,
00415                         LPCITEMIDLIST pidl,
00416                         LPTSTR pszText,
00417                         DWORD dwSize)
00418 {
00419 if(IsBadReadPtr(pStrRet, sizeof(UINT)))
00420    return FALSE;
00421
00422 if(IsBadWritePtr(pszText, dwSize))
00423    return FALSE;
00424
00425 switch(pStrRet->uType)
00426    {
00427    case STRRET_CSTR:
00428       AnsiToLocal(pszText, pStrRet->cStr, dwSize);
00429       break;
00430
00431    case STRRET_OFFSET:
00432       lstrcpyn(pszText, (LPTSTR)(((LPBYTE)pidl) + pStrRet->uOffset), dwSize);
00433       break;
00434
00435    case STRRET_WSTR:
00436       {
00437       WideCharToLocal(pszText, pStrRet->pOleStr, dwSize);
00438
00439       if(!pMalloc)
00440          {
00441          SHGetMalloc(&pMalloc);
00442          }
00443       else
00444          {
00445          pMalloc->AddRef();
00446          }
00447       if(pMalloc)
00448          {
00449          pMalloc->Free(pStrRet->pOleStr);
00450          pMalloc->Release();
00451          }
00452       }
00453       break;
00454
00455    default:
00456       return FALSE;
00457    }
00458
00459 return TRUE;
00460 }
00461
00462 /**************************************************************************
00463
00464    IsViewWindow()
00465
00466 **************************************************************************/
00467
00468 BOOL IsViewWindow(HWND hWnd)
00469 {
00470 if(!hWnd)
00471    return FALSE;
00472
00473 TCHAR szClass[MAX_PATH] = TEXT("");
00474
00475 GetClassName(hWnd, szClass, MAX_PATH);
00476
00477 if(0 == lstrcmpi(szClass, NS_CLASS_NAME))
00478    return TRUE;
00479
00480 return FALSE;
00481 }
00482
00483 /**************************************************************************
00484
00485    DeleteDirectory()
00486
00487 **************************************************************************/
00488
00489 BOOL DeleteDirectory(LPCTSTR pszDir)
00490 {
00491 BOOL              fReturn = FALSE;
00492 HANDLE            hFind;
00493 WIN32_FIND_DATA   wfd;
00494 TCHAR             szTemp[MAX_PATH];
00495
00496 lstrcpyn(szTemp, pszDir, ARRAYSIZE(szTemp));
00497 SmartAppendBackslash(szTemp, ARRAYSIZE(szTemp));
00498 StrCatBuff(szTemp, TEXT("*.*"), ARRAYSIZE(szTemp));
00499 hFind = FindFirstFile(szTemp, &wfd);
00500
00501 if(INVALID_HANDLE_VALUE != hFind)
00502    {
00503    do
00504       {
00505       if(lstrcmpi(wfd.cFileName, TEXT(".")) &&
00506          lstrcmpi(wfd.cFileName, TEXT("..")))
00507          {
00508          //build the path of the directory or file found
00509          lstrcpyn(szTemp, pszDir, ARRAYSIZE(szTemp));
00510          SmartAppendBackslash(szTemp, ARRAYSIZE(szTemp));
00511          StrCatBuff(szTemp, wfd.cFileName, ARRAYSIZE(szTemp));
00512
00513          if(FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
00514             {
00515             //we found a directory - call this function recursively
00516             DeleteDirectory(szTemp);
00517             }
00518          else
00519             {
00520             /*
00521             We found a file. Only delete the data file to prevent us from
00522             deleteting something that the user has placed in the folder.
00523             */
00524             if(0 == lstrcmpi(wfd.cFileName, c_szDataFile))
00525                {
00526                DeleteFile(szTemp);
00527                }
00528             }
00529          }
00530       }
00531    while(FindNextFile(hFind, &wfd));
00532
00533    FindClose(hFind);
00534
00535    /*
00536    If this fails it means the directory is not empty, so just remove our
00537    attributes so the enumerator won't see it.
00538    */
00539    fReturn = RemoveDirectory(pszDir);
00540    if(!fReturn)
00541       {
00542       DWORD dwAttr = GetFileAttributes(pszDir);
00543       dwAttr &= ~FILTER_ATTRIBUTES;
00544       fReturn = SetFileAttributes(pszDir, dwAttr);
00545       }
00546    }
00547
00548 return fReturn;
00549 }
00550
00551 /**************************************************************************
00552
00553    CreatePrivateClipboardData()
00554
00555 **************************************************************************/
00556
00557 HGLOBAL CreatePrivateClipboardData( LPITEMIDLIST pidlParent,
00558                                     LPITEMIDLIST *aPidls,
00559                                     UINT uItemCount,
00560                                     BOOL fCut)
00561 {
00562 HGLOBAL        hGlobal = NULL;
00563 LPPRIVCLIPDATA pData;
00564 UINT           iCurPos;
00565 UINT           cbPidl;
00566 UINT           i;
00567 CPidlMgr       *pPidlMgr;
00568
00569 pPidlMgr = new CPidlMgr();
00570
00571 if(!pPidlMgr)
00572    return NULL;
00573
00574 //get the size of the parent folder's PIDL
00575 cbPidl = pPidlMgr->GetSize(pidlParent);
00576
00577 //get the total size of all of the PIDLs
00578 for(i = 0; i < uItemCount; i++)
00579    {
00580    cbPidl += pPidlMgr->GetSize(aPidls[i]);
00581    }
00582
00583 /*
00584 Find the end of the PRIVCLIPDATA structure. This is the size of the
00585 PRIVCLIPDATA structure itself (which includes one element of aoffset) plus the
00586 additional number of elements in aoffset.
00587 */
00588 iCurPos = sizeof(PRIVCLIPDATA) + (uItemCount * sizeof(UINT));
00589
00590 /*
00591 Allocate the memory for the PRIVCLIPDATA structure and it's variable length members.
00592 */
00593 hGlobal = GlobalAlloc(GHND | GMEM_SHARE, (DWORD)
00594          (iCurPos +        // size of the PRIVCLIPDATA structure and the additional aoffset elements
00595          (cbPidl + 1)));   // size of the pidls
00596
00597 if (NULL == hGlobal)
00598    return (hGlobal);
00599
00600 pData = (LPPRIVCLIPDATA)GlobalLock(hGlobal);
00601
00602 if(pData)
00603    {
00604    pData->fCut = fCut;
00605    pData->cidl = uItemCount + 1;
00606    pData->aoffset[0] = iCurPos;
00607
00608    //add the PIDL for the parent folder
00609    cbPidl = pPidlMgr->GetSize(pidlParent);
00610    CopyMemory((LPBYTE)(pData) + iCurPos, (LPBYTE)pidlParent, cbPidl);
00611    iCurPos += cbPidl;
00612
00613    for(i = 0; i < uItemCount; i++)
00614       {
00615       //get the size of the PIDL
00616       cbPidl = pPidlMgr->GetSize(aPidls[i]);
00617
00618       //fill out the members of the PRIVCLIPDATA structure.
00619       pData->aoffset[i + 1] = iCurPos;
00620
00621       //copy the contents of the PIDL
00622       CopyMemory((LPBYTE)(pData) + iCurPos, (LPBYTE)aPidls[i], cbPidl);
00623
00624       //set up the position of the next PIDL
00625       iCurPos += cbPidl;
00626       }
00627
00628    GlobalUnlock(hGlobal);
00629    }
00630
00631 delete pPidlMgr;
00632
00633 return (hGlobal);
00634 }
00635
00636 /**************************************************************************
00637
00638    CreateShellIDList()
00639
00640 **************************************************************************/
00641
00642 HGLOBAL CreateShellIDList( LPITEMIDLIST pidlParent,
00643                            LPITEMIDLIST *aPidls,
00644                            UINT uItemCount)
00645 {
00646 HGLOBAL        hGlobal = NULL;
00647 LPIDA          pData;
00648 UINT           iCurPos;
00649 UINT           cbPidl;
00650 UINT           i;
00651 CPidlMgr       *pPidlMgr;
00652
00653 pPidlMgr = new CPidlMgr();
00654
00655 if(!pPidlMgr)
00656    return NULL;
00657
00658 //get the size of the parent folder's PIDL
00659 cbPidl = pPidlMgr->GetSize(pidlParent);
00660
00661 //get the total size of all of the PIDLs
00662 for(i = 0; i < uItemCount; i++)
00663    {
00664    cbPidl += pPidlMgr->GetSize(aPidls[i]);
00665    }
00666
00667 /*
00668 Find the end of the CIDA structure. This is the size of the
00669 CIDA structure itself (which includes one element of aoffset) plus the
00670 additional number of elements in aoffset.
00671 */
00672 iCurPos = sizeof(CIDA) + (uItemCount * sizeof(UINT));
00673
00674 /*
00675 Allocate the memory for the CIDA structure and it's variable length members.
00676 */
00677 hGlobal = GlobalAlloc(GHND | GMEM_SHARE, (DWORD)
00678          (iCurPos +        // size of the CIDA structure and the additional aoffset elements
00679          (cbPidl + 1)));   // size of the pidls
00680
00681 if (NULL == hGlobal)
00682    return (hGlobal);
00683
00684 pData = (LPIDA)GlobalLock(hGlobal);
00685
00686 if(pData)
00687    {
00688    pData->cidl = uItemCount + 1;
00689    pData->aoffset[0] = iCurPos;
00690
00691    //add the PIDL for the parent folder
00692    cbPidl = pPidlMgr->GetSize(pidlParent);
00693    CopyMemory((LPBYTE)(pData) + iCurPos, (LPBYTE)pidlParent, cbPidl);
00694    iCurPos += cbPidl;
00695
00696    for(i = 0; i < uItemCount; i++)
00697       {
00698       //get the size of the PIDL
00699       cbPidl = pPidlMgr->GetSize(aPidls[i]);
00700
00701       //fill out the members of the CIDA structure.
00702       pData->aoffset[i + 1] = iCurPos;
00703
00704       //copy the contents of the PIDL
00705       CopyMemory((LPBYTE)(pData) + iCurPos, (LPBYTE)aPidls[i], cbPidl);
00706
00707       //set up the position of the next PIDL
00708       iCurPos += cbPidl;
00709       }
00710
00711    GlobalUnlock(hGlobal);
00712    }
00713
00714 delete pPidlMgr;
00715
00716 return (hGlobal);
00717 }
00718
00719 /**************************************************************************
00720
00721    ItemDataDlgProc()
00722
00723 **************************************************************************/
00724
00725 BOOL CALLBACK ItemDataDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00726 {
00727 static LPTSTR  pszData;
00728
00729 switch(uMsg)
00730    {
00731    case WM_INITDIALOG:
00732       pszData = (LPTSTR)lParam;
00733       if(IsBadWritePtr((LPVOID)pszData, MAX_DATA))
00734          {
00735          EndDialog(hWnd, IDCANCEL);
00736          break;
00737          }
00738
00739       SendDlgItemMessage(hWnd, IDC_DATA, EM_LIMITTEXT, MAX_DATA - 1, 0);
00740
00741       SetDlgItemText(hWnd, IDC_DATA, pszData);
00742       break;
00743
00744    case WM_COMMAND:
00745       switch(GET_WM_COMMAND_ID(wParam, lParam))
00746          {
00747          case IDCANCEL:
00748             EndDialog(hWnd, IDCANCEL);
00749             break;
00750
00751          case IDOK:
00752             GetDlgItemText(hWnd, IDC_DATA, pszData, MAX_DATA);
00753             EndDialog(hWnd, IDOK);
00754             break;
00755
00756          }
00757       break;
00758
00759    default:
00760       break;
00761    }
00762
00763 return FALSE;
00764 }
00765
00766 /**************************************************************************
00767
00768    GetViewInterface()
00769
00770 **************************************************************************/
00771
00772 LPVOID GetViewInterface(HWND hWnd)
00773 {
00774 IUnknown *pRet = NULL;
00775
00776 if(IsViewWindow(hWnd))
00777    {
00778    pRet = (IUnknown*)GetWindowLongPtr(hWnd, VIEW_POINTER_OFFSET);
00779    }
00780
00781 if(pRet)
00782    pRet->AddRef();
00783
00784 return (LPVOID)pRet;
00785 }
00786
00787 /**************************************************************************
00788
00789    AddViewMenuItems()
00790
00791 **************************************************************************/
00792
00793 UINT AddViewMenuItems(  HMENU hMenu,
00794                         UINT uOffset,
00795                         UINT uInsertBefore,
00796                         BOOL fByPosition)
00797 {
00798 MENUITEMINFO   mii;
00799 TCHAR          szText[MAX_PATH] = TEXT("");
00800 UINT           uAdded = 0;
00801
00802 ZeroMemory(&mii, sizeof(mii));
00803 mii.cbSize = sizeof(mii);
00804
00805 //add the view menu items at the correct position in the menu
00806 LoadString(g_hInst, IDS_VIEW_LARGE, szText, sizeof(szText));
00807 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
00808 mii.fType = MFT_STRING;
00809 mii.fState = MFS_ENABLED;
00810 mii.dwTypeData = szText;
00811 mii.wID = uOffset + IDM_VIEW_LARGE;
00812 InsertMenuItem(hMenu, uInsertBefore, fByPosition, &mii);
00813
00814 uAdded++;
00815
00816 LoadString(g_hInst, IDS_VIEW_SMALL, szText, sizeof(szText));
00817 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
00818 mii.fType = MFT_STRING;
00819 mii.fState = MFS_ENABLED;
00820 mii.dwTypeData = szText;
00821 mii.wID = uOffset + IDM_VIEW_SMALL;
00822 InsertMenuItem(hMenu, uInsertBefore, fByPosition, &mii);
00823
00824 uAdded++;
00825
00826 LoadString(g_hInst, IDS_VIEW_LIST, szText, sizeof(szText));
00827 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
00828 mii.fType = MFT_STRING;
00829 mii.fState = MFS_ENABLED;
00830 mii.dwTypeData = szText;
00831 mii.wID = uOffset + IDM_VIEW_LIST;
00832 InsertMenuItem(hMenu, uInsertBefore, fByPosition, &mii);
00833
00834 uAdded++;
00835
00836 LoadString(g_hInst, IDS_VIEW_DETAILS, szText, sizeof(szText));
00837 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
00838 mii.fType = MFT_STRING;
00839 mii.fState = MFS_ENABLED;
00840 mii.dwTypeData = szText;
00841 mii.wID = uOffset + IDM_VIEW_DETAILS;
00842 InsertMenuItem(hMenu, uInsertBefore, fByPosition, &mii);
00843
00844 uAdded++;
00845
00846 return uAdded;
00847 }
00848
00849 /**************************************************************************
00850
00851    AddFileMenuItems()
00852
00853 **************************************************************************/
00854
00855 UINT AddFileMenuItems(  HMENU hMenu,
00856                         UINT uOffset,
00857                         UINT uInsertBefore,
00858                         BOOL fByPosition)
00859 {
00860 //add the file menu items
00861 TCHAR          szText[MAX_PATH] = TEXT("");
00862 MENUITEMINFO   mii;
00863 HMENU          hPopup;
00864 UINT           uAdded = 0;
00865
00866 hPopup = CreatePopupMenu();
00867
00868 if(hPopup)
00869    {
00870    ZeroMemory(&mii, sizeof(mii));
00871    mii.cbSize = sizeof(mii);
00872
00873    LoadString(g_hInst, IDS_NEW_FOLDER, szText, sizeof(szText));
00874    mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
00875    mii.fType = MFT_STRING;
00876    mii.fState = MFS_ENABLED;
00877    mii.dwTypeData = szText;
00878    mii.wID = uOffset + IDM_NEW_FOLDER;
00879    InsertMenuItem(hPopup, (UINT)-1, FALSE, &mii);
00880
00881    LoadString(g_hInst, IDS_NEW_ITEM, szText, sizeof(szText));
00882    mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
00883    mii.fType = MFT_STRING;
00884    mii.fState = MFS_ENABLED;
00885    mii.dwTypeData = szText;
00886    mii.wID = uOffset + IDM_NEW_ITEM;
00887    InsertMenuItem(hPopup, (UINT)-1, FALSE, &mii);
00888
00889    LoadString(g_hInst, IDS_NEW, szText, sizeof(szText));
00890    mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE | MIIM_SUBMENU;
00891    mii.fType = MFT_STRING;
00892    mii.fState = MFS_ENABLED;
00893    mii.dwTypeData = szText;
00894    mii.wID = uOffset + IDM_NEW;
00895    mii.hSubMenu = hPopup;
00896    InsertMenuItem(hMenu, uInsertBefore, fByPosition, &mii);
00897
00898    uAdded++;
00899    }
00900
00901 return uAdded;
00902 }
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CThreadSub Member List

This is the complete list of members for CThreadSub, including all inherited members.
CSysLCESub() | CSysLCESub | [inline]
CThreadSub(CComSpy *pSpy) | CThreadSub | [inline]
CThreadSub() | CThreadSub | [inline]
GetEventClass(LPGUID guid) | CThreadSub | [inline, virtual]
GetEventType(EventEnum *e) | CThreadSub | [inline, virtual]
GetInterface(IID *iid) | CThreadSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnThreadAssignApartment(COMSVCSEVENTINFO *pInfo, REFGUID guidActivity, ULONG64 AptId) | CThreadSub | [inline]
OnThreadBindToApartment(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 AptID, DWORD dwActCnt, DWORD dwLowCnt) | CThreadSub | [inline]
OnThreadStart(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, DWORD dwThread, DWORD dwThreadCnt) | CThreadSub | [inline]
OnThreadTerminate(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, DWORD dwThread, DWORD dwThreadCnt) | CThreadSub | [inline]
OnThreadUnassignApartment(COMSVCSEVENTINFO *pInfo, ULONG64 AptId) | CThreadSub | [inline]
OnThreadUnBind(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 AptID, DWORD dwActCnt) | CThreadSub | [inline]
OnThreadWorkEnque(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 MsgWorkID, DWORD dwQueueLen) | CThreadSub | [inline]
OnThreadWorkPrivate(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 MsgWorkID) | CThreadSub | [inline]
OnThreadWorkPublic(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 MsgWorkID, DWORD dwQueueLen) | CThreadSub | [inline]
OnThreadWorkRedirect(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 MsgWorkID, DWORD dwQueueLen, ULONG64 ThreadNum) | CThreadSub | [inline]
OnThreadWorkReject(COMSVCSEVENTINFO *pInfo, ULONG64 ThreadID, ULONG64 MsgWorkID, DWORD dwQueueLen) | CThreadSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:57:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Input/Ime/MultiUI/MultiUI.h Source File

  • WinUI
  • Input
  • Ime
  • MultiUI

MultiUI.h

Go to the documentation of this file.
00001 /**********************************************************************/
00002 /*                                                                    */
00003 /*      MULTCON.H  - Dispatch IME Sub Task                            */
00004 /*                                                                    */
00005 /*      Copyright (c) 1995 - 2000  Microsoft Corporation                     */
00006 /*                                                                    */
00007 /**********************************************************************/
00008
00009 #define WMCOMMANDWPARAM(w) LOWORD(w)
00010
00011 #define DEFIMC1     0
00012 #define DEFIMC2     1
00013 #define IMC1        2
00014 #define IMC2        3
00015 #define IMCUI1      4
00016 #define IMCUI2      5
00017
00018 #define MAXSIZE_STR             1024
00019
00020 #define WNDEXTRA_NOUINOIMC      8
00021 #define WNDEXTRA_NOUIOWNIMC     12
00022 #define WNDEXTRA_OWNUIOWNIMC    16
00023
00024 #define MYGWL_FONT   0
00025 #define MYGWL_STR    4
00026 #define MYGWL_IMC    8
00027 #define MYGWL_IMEWND 12
00028
00029 extern HANDLE hInst;
00030 extern HWND hWndMain;
00031
00032 extern HWND hWndDef1;
00033 extern HWND hWndDef2;
00034 extern HWND hWndIMC1;
00035 extern HWND hWndIMC2;
00036 extern HWND hWndIMCUI1;
00037 extern HWND hWndIMCUI2;
00038
00039 /* multiui.c */
00040 int  APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
00041 BOOL InitApplication(HANDLE);
00042 BOOL InitInstance(HANDLE, int);
00043 LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
00044
00045 /* dlgs.c     */
00046 BOOL AboutDlg(HWND, UINT, WPARAM, LPARAM);
00047
00048 /* multiwnd.c */
00049 LRESULT CALLBACK NoUINoIMCWndProc(HWND, UINT, WPARAM, LPARAM);
00050 LRESULT CALLBACK NoUIOwnIMCWndProc(HWND, UINT, WPARAM, LPARAM);
00051 LRESULT CALLBACK OwnUIOwnIMCWndProc(HWND, UINT, WPARAM, LPARAM);
00052 HFONT GetDefaultGUIFont(void);
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/Authorization/SecurObj/Main.h Source File

  • Security
  • Authorization
  • SecurObj

Main.h

Go to the documentation of this file.
00001 /*
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1997 - 2000.  Microsoft Corporation.  All rights reserved.
00008 */
00009
00010 #if !defined (INC_MAIN_H)
00011 #define INC_MAIN_H
00012
00013 #include <windows.h>
00014 #include <commctrl.h>
00015
00016 // Access rights for our private objects
00017 #define ACCESS_READ     1
00018 #define ACCESS_MODIFY   2
00019 #define ACCESS_DELETE   4
00020
00021
00022 #define ACCESS_ALL  ACCESS_READ | ACCESS_MODIFY | ACCESS_DELETE
00023
00024 typedef struct tagObject {
00025    PSECURITY_DESCRIPTOR pSD;
00026    BOOL                 fContainer;
00027    struct tagObject     *Parent;
00028    struct tagObject     *Objects;
00029    HTREEITEM            hTreeItem;
00030 } OBJECT, *POBJECT;
00031
00032
00033
00034 // Main.cpp
00035 BOOL InitApplication(HANDLE);
00036 BOOL InitInstance(HANDLE, int);
00037 BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
00038
00039 // Security.cpp
00040
00041 // Private Object functions
00042 BOOL CheckAccess( POBJECT pObject, HANDLE hToken );
00043 PSECURITY_DESCRIPTOR GetCreatorSD(WORD wIndex);
00044 POBJECT NewObject( POBJECT pContainer, BOOL fContainer, WORD wIndex );
00045
00046 // Security Context functions
00047 HANDLE GetClientToken( WORD wIndex );
00048 HANDLE GetClientImpToken( WORD wIndex );
00049 PSECURITY_DESCRIPTOR GetClientDescriptor( WORD wIndex );
00050 BOOL NewLogon( HINSTANCE, WORD );
00051 void GetLogonName( WORD wIndex, WCHAR szUser[] );
00052 BOOL DefaultUser( void );
00053 BOOL CALLBACK LogonDlgProc (HWND hwnd, UINT msg,
00054                      WPARAM wParam,  LPARAM lParam);
00055
00056 // PrivOjSI.cpp
00057 extern "C"
00058 HRESULT
00059 CreateObjSecurityInfo(DWORD dwFlags,           // e.g. SI_EDIT_ALL | SI_ADVANCED | SI_CONTAINER
00060                       PSECURITY_DESCRIPTOR *ppSD,        // Program defined structure for objects
00061                       LPSECURITYINFO *ppObjSI,
00062                       WORD wClient,           // Index for client token
00063                       LPCWSTR pszServerName,  // Name of server on which SIDs will be resolved
00064                       BOOL    fContainer);     // This is the only way to name my generic objects
00065
00066
00067
00068 #endif // INC_MAIN_H
00069
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Pickle/Picklt/Picklt.Idl Source File

  • NetDS
  • RPC
  • Pickle
  • Picklt

Picklt.Idl

Go to the documentation of this file.
00001 [ uuid (B75AF600-9CF4-11CD-A076-08002B2BD711),
00002   version(1.0),
00003   pointer_default(unique)
00004 ]
00005 interface type_pickle
00006 {
00007
00008 const short ARR_SIZE =  4;
00009 const short BUFSIZE = 1024;
00010
00011 typedef struct _OBJECT1 {
00012     long            al[ARR_SIZE];
00013     unsigned short  s;
00014     } OBJECT1;
00015
00016 /* This is the top level type to be serialized. See the ACF file */
00017
00018 typedef struct _OBJECT2 {
00019     unsigned short      sData;
00020     OBJECT1 *           pObject1;
00021     } OBJECT2;
00022
00023 }
00024 
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/async/server/CEnumXXX.cpp Source File

  • Com
  • async
  • server

CEnumXXX.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "Debug.h"
00018
00019 template<class T, class ELT_T, class IFACE>
00020 CEnumXXX<T, ELT_T, IFACE>::CEnumXXX(LPUNKNOWN lpUnk, REFIID iid, DWORD nCount)
00021     : m_lpunk(lpUnk), m_iid(iid), m_cRef(0), m_iCur(0), m_cELT(nCount), m_prgELT(NULL)
00022 {
00023   _ASSERT(m_lpunk);
00024 }
00025
00026 template<class T, class ELT_T, class IFACE>
00027 CEnumXXX<T, ELT_T, IFACE>::~CEnumXXX()
00028 {
00029   RELEASEINTERFACE(m_lpunk);  // Release the strong lock on the container interface add in the call to QI
00030   delete [] m_prgELT;
00031 }
00032
00033
00034 template<class T, class ELT_T, class IFACE>
00035 T* __stdcall CEnumXXX<T, ELT_T, IFACE>::Create(LPUNKNOWN lpUnk, DWORD nCount, ELT_T* elemlist)
00036 {
00037   T* penum = new T(lpUnk, nCount);
00038   if ( penum && penum->Init(elemlist))
00039     return penum;
00040   else
00041   {
00042     delete penum;
00043     return NULL;
00044   }
00045 }
00046
00047
00048
00049 template<class T, class ELT_T, class IFACE>
00050 bool __stdcall CEnumXXX<T, ELT_T, IFACE>::Init(ELT_T *elemlist)
00051 {
00052 #if 0
00053   m_prgELT = new ELT_T[m_cELT];
00054   if (!m_prgELT)
00055     return false;
00056
00057   for (DWORD i = 0; i < m_cELT; i++)
00058     m_prgELT[i] = elemlist[i];
00059 #endif
00060
00061 /*
00062  * Note this can be a shallow copy since CEnumXXX maintains a refcount on the "owner"
00063  * of this class _and_ the "owner" agrees never to free the memory until it _itself_
00064  * is destroyed. A typical useage will be this
00065  *
00066  *  CEnumConnectionPoints *penum = CEnumConnectionPoints::Create(this, m_cCP, elemlist);
00067   HRESULT hr = penum->QueryInterface(IID_IEnumConnectionPoints, reinterpret_cast<PVOID*>(ppenum));
00068  *
00069  * Each time this class returns an interface via QueryInterface it will addref the "owners"
00070  * lpUnk pointer. There by assuring that the memory passed in is valid for the life of this interface.
00071  */
00072   _ASSERT(elemlist);
00073   m_prgELT = elemlist;
00074   return true;
00075 }
00076
00077
00078 /* What I do is in the implementation of CEnumXXX::QueryInterface() AddRef the container. The container
00079  * passees in it's IUnknown as a constructor parameter. This will maintain a strong look on the container.
00080  * When the refcount drops to zero in CEnumXXX::Release() this will call CEnumXXX::FinalRelease()
00081  * which will then release the last strong lock on the container. If this is not done then I could orphan this
00082  * enumerator i.e.
00083  *
00084  * pDataObject->EnumFormatEtc(DATA_GET, &pEnumFmt);
00085  * pDataObject->Release();
00086  *
00087  * pEnumFmt is now orphaned. Perhaps this is just plain a bug on the users part; I don't know but it does
00088  * follow the Fetch, Use, Release methodology of COM
00089  */
00090 template<class T, class ELT_T, class IFACE>
00091 HRESULT __stdcall CEnumXXX<T, ELT_T, IFACE>::QueryInterface(REFIID iid, PVOID *ppv)
00092 {
00093 #if defined(_DEBUG)
00094   LPWSTR lpstrIID;
00095   StringFromIID(iid, &lpstrIID);
00096   DEBUGTRACE(_TEXT("CEnumXXX::QueryInterface has been asked for %S"), lpstrIID);
00097   CoTaskMemFree(lpstrIID);
00098 #endif
00099
00100   CHECKPOINTER(ppv);
00101
00102   if (iid == IID_IUnknown || iid == m_iid)
00103   {
00104     *ppv = reinterpret_cast<IFACE*>(this);
00105     static_cast<LPUNKNOWN>(*ppv)->AddRef();
00106     return S_OK;
00107   }
00108   else
00109   {
00110     *ppv = NULL;
00111     return E_NOINTERFACE;
00112   }
00113 }
00114
00115 template<class T, class ELT_T, class IFACE>
00116 ULONG __stdcall CEnumXXX<T, ELT_T, IFACE>::AddRef()
00117 {
00118   DEBUGTRACE(_T("In CEnumXXX::AddRef refcounts = %i"), m_cRef+1);
00119 /*
00120  * Need to AddRef the Container since it owns the list of elements to be enumerated
00121  */
00122   m_lpunk->AddRef();  // Add a strong lock on the container interface
00123   return InterlockedIncrement(reinterpret_cast<PLONG>(&m_cRef));
00124 }
00125
00126
00127 template<class T, class ELT_T, class IFACE>
00128 ULONG __stdcall CEnumXXX<T, ELT_T, IFACE>::Release()
00129 {
00130   _ASSERT(m_cRef > 0); // not thread safe
00131   DEBUGTRACE(_T("In CEnumXXX::Release refcounts = %i"), m_cRef-1);
00132
00133   if (InterlockedDecrement(reinterpret_cast<PLONG>(&m_cRef)) == 0)
00134   {
00135     FinalRelease();
00136     delete this;
00137     return 0;
00138   }
00139   m_lpunk->Release(); // Release strong lock added in by the AddRef()
00140   return m_cRef;
00141 }
00142
00143 template<class T, class ELT_T, class IFACE>
00144 void __stdcall CEnumXXX<T, ELT_T, IFACE>::FinalRelease()
00145 {
00146   DEBUGTRACE(_T("CEnumXXX::FinalRelease"));
00147 }
00148
00149 template<class T, class ELT_T, class IFACE>
00150 HRESULT __stdcall CEnumXXX<T, ELT_T, IFACE>::Next(ULONG celt, ELT_T* rgelt, PULONG pceltFetched)
00151 {
00152   HRESULT hr;
00153
00154   if (celt == 0 || (!pceltFetched && celt > 1))
00155     return E_INVALIDARG;
00156
00157   CHECKPOINTER(rgelt);
00158
00159   if (celt > m_cELT - m_iCur)
00160   {
00161     celt = m_cELT - m_iCur;
00162     celt == 0 ? (hr = E_FAIL) : (hr = S_FALSE);
00163   }
00164   else
00165     hr = S_OK;
00166
00167   DWORD i,j;
00168   T* pT = static_cast<T*>(this);
00169
00170   for (j=0, i=m_iCur; j < celt; i++,j++)
00171   {
00172     CHECKPOINTER(&rgelt[j]);
00173     if (!pT->Copy(&rgelt[j], m_prgELT[i])) // the semantics of Copy are entirely determined by the object being enumerated
00174       return E_FAIL;
00175   }
00176   m_iCur = i;
00177   if (pceltFetched)
00178     *pceltFetched = j;
00179
00180   return hr;
00181 }
00182
00183 template<class T, class ELT_T, class IFACE>
00184 HRESULT __stdcall CEnumXXX<T, ELT_T, IFACE>::Skip(ULONG celt)
00185 {
00186   HRESULT hr;
00187   if (celt + m_iCur > m_cELT)
00188   {
00189     m_iCur = m_cELT;
00190     hr = S_FALSE;
00191   }
00192   else
00193   {
00194     m_iCur += celt;
00195     hr = S_OK;
00196   }
00197   return hr;
00198 }
00199
00200 template<class T, class ELT_T, class IFACE>
00201 HRESULT __stdcall CEnumXXX<T, ELT_T, IFACE>::Reset(void)
00202 {
00203   m_iCur = 0;
00204   return S_OK;
00205 }
00206
00207 template<class T, class ELT_T, class IFACE>
00208 HRESULT __stdcall CEnumXXX<T, ELT_T, IFACE>::Clone(IFACE **ppenum)
00209 {
00210   CHECKPOINTER(ppenum);
00211
00212   ELT_T* prgELT = new ELT_T[m_cELT];
00213   if (!prgELT)
00214     return E_OUTOFMEMORY;
00215
00216   for (DWORD i = 0; i < m_cELT; i++)
00217     prgELT[i] = m_prgELT[i];
00218
00219   T* penum = Create(m_lpunk, m_cELT, prgELT);
00220   return penum->QueryInterface(m_iid, reinterpret_cast<PVOID*>(ppenum));
00221 }
00222
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Binding/vc/Binding.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Binding
  • vc

Binding.cpp

Go to the documentation of this file.
00001 // Binding.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "stdio.h"
00006 #include "activeds.h"
00007
00008
00009 int main(int argc, char* argv[])
00010 {
00011   CoInitialize(NULL);
00012
00013
00014   HRESULT hr;
00015   IADs *pADs = NULL;
00016   /////////////////////////////////////////
00017   // Binding as currently logged on user
00018   ////////////////////////////////////////
00019   hr = ADsGetObject( L"WinNT://INDEPENDENCE/JSmith,user", IID_IADs, (void**) &pADs );
00020
00021   if ( !SUCCEEDED(hr) )
00022   {
00023     return hr;
00024   }
00025
00026   //... do some operations here
00027   pADs->Release(); // Do not forget to release when you're done.
00028
00029
00030   /////////////////////////////////////////
00031   // Binding with alternate credentials
00032   ////////////////////////////////////////
00033   hr = ADsOpenObject(L"WinNT://INDEPENDENCE/JSmith,user", L"Administrator", L"secret", ADS_SECURE_AUTHENTICATION, IID_IADs, (void**) &pADs );
00034   if ( !SUCCEEDED(hr) )
00035   {
00036     return hr;
00037   }
00038
00039   //...
00040   // Make sure you release it after use
00041   pADs->Release();
00042
00043
00044
00045   CoUninitialize();
00046   return 0;
00047 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

WATCHER_DATA Member List

This is the complete list of members for WATCHER_DATA, including all inherited members.
bstrName | WATCHER_DATA
bstrURI | WATCHER_DATA
fAddBuddy | WATCHER_DATA
fAllow | WATCHER_DATA
Generated on Wed Nov 13 2024 16:58:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Search/vc/StdAfx.h Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Search
  • vc

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__03FC61A0_AFF6_11D2_9A74_0080C7A2DC6B__INCLUDED_)
00007 #define AFX_STDAFX_H__03FC61A0_AFF6_11D2_9A74_0080C7A2DC6B__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013
00014 // TODO: reference additional headers your program requires here
00015
00016 //{{AFX_INSERT_LOCATION}}
00017 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00018
00019 #endif // !defined(AFX_STDAFX_H__03FC61A0_AFF6_11D2_9A74_0080C7A2DC6B__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/WinHlprs/strmHelp.Cxx Source File

  • Com
  • Fundamentals
  • WinHlprs

strmHelp.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright Microsoft Corporation.
00005 //
00006 //  File:       strmhelp.cxx
00007 //
00008 //  Contents:   Routines for writting variables to a stream in an
00009 //              architecture independent manner.
00010 //
00011 //  Classes:
00012 //
00013 //  Functions:  WriteDouble
00014 //              ReadDouble
00015 //              SizeDouble
00016 //
00017 //  History:    4-26-94   stevebl   Created
00018 //
00019 //----------------------------------------------------------------------------
00020
00021 #include <windows.h>
00022 #include <ole2.h>
00023 #include "strmhelp.h"
00024 #include <stdio.h>
00025
00026 #define MAX_SIZE 128
00027
00028 //+---------------------------------------------------------------------------
00029 //
00030 //  Function:   SizeDouble
00031 //
00032 //  Synopsis:   returns the maximum number of bytes that WriteDouble will
00033 //              take to write a double to an IStream
00034 //
00035 //  Arguments:  none
00036 //
00037 //  Returns:    maximum number of bytes needed to write a double to an IStream
00038 //
00039 //  History:    4-26-94   stevebl   Created
00040 //
00041 //----------------------------------------------------------------------------
00042
00043 DWORD SizeDouble(void)
00044 {
00045     return(MAX_SIZE);
00046 }
00047
00048 //+---------------------------------------------------------------------------
00049 //
00050 //  Function:   WriteDouble
00051 //
00052 //  Synopsis:   rrites a double to an OLE stream in a machine independent manner
00053 //
00054 //  Arguments:  [pstm]       - pointer to an IStream
00055 //              [d]          - the double to be written
00056 //              [pcbWritten] - pointer to the number of bytes actually written
00057 //                             (may be NULL)
00058 //
00059 //  Returns:    same return values as IStream::Write
00060 //
00061 //  History:    4-26-94   stevebl   Created
00062 //
00063 //----------------------------------------------------------------------------
00064
00065 HRESULT WriteDouble(IStream * pstm, double d, ULONG FAR * pcbWritten)
00066 {
00067     char szTemp[MAX_SIZE];
00068     sprintf(szTemp,"%.100lg", d);
00069     size_t cch = strlen(szTemp);
00070     return(pstm->Write(szTemp, (ULONG)(cch + 1), pcbWritten));
00071 }
00072
00073 //+---------------------------------------------------------------------------
00074 //
00075 //  Function:   ReadDouble
00076 //
00077 //  Synopsis:   reads a double from an OLE stream in a machine independent
00078 //              manner
00079 //
00080 //  Arguments:  [pstm]    - pointer to an IStream
00081 //              [pd]      - pointer to the double to be read
00082 //              [pcbRead] - pointer to the number of bytes actually read
00083 //                          (may be NULL)
00084 //
00085 //  Returns:    same return values as IStream::Read
00086 //
00087 //  History:    4-26-94   stevebl   Created
00088 //
00089 //----------------------------------------------------------------------------
00090
00091 HRESULT ReadDouble(IStream * pstm, double * pd, ULONG FAR * pcbRead)
00092 {
00093     HRESULT hr;
00094     char szTemp[MAX_SIZE];
00095     ULONG cbRead;
00096     DWORD cch = 0;
00097     do
00098     {
00099         hr = pstm->Read(&szTemp[cch], sizeof(char), &cbRead);
00100         if (pcbRead && SUCCEEDED(hr))
00101         {
00102             pcbRead += cbRead;
00103         }
00104
00105     } while (SUCCEEDED(hr) && szTemp[cch++]);
00106     if (SUCCEEDED(hr))
00107     {
00108         sscanf(szTemp, "%lf",pd);
00109     }
00110     return(hr);
00111 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COLUMNDATA Member List

This is the complete list of members for COLUMNDATA, including all inherited members.
bData | COLUMNDATA
dwLength | COLUMNDATA
dwStatus | COLUMNDATA
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/netshell/subcontext.cpp Source File

  • NetDS
  • netshell

subcontext.cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft Netsh Sample.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #include "nshsamp.h"
00018
00019 extern SAMPLE_HELPER_DATA g_OnlineData;
00020 extern SAMPLE_HELPER_DATA g_OfflineData;
00021 extern PSAMPLE_HELPER_DATA g_CurrentData;
00022 extern HANDLE g_hModule;
00023
00024 DWORD WINAPI
00025 HandleShowErrorCommand(
00026 IN      LPCWSTR pwszMachine,
00027 IN OUT  LPWSTR  *ppwcArguments,
00028 IN      DWORD   dwCurrentIndex,
00029 IN      DWORD   dwArgCount,
00030 IN      DWORD   dwFlags,
00031 IN      LPCVOID pvData,
00032 OUT     BOOL    *pbDone)
00033 {
00034     DWORD dwRet = ERROR_SHOW_USAGE;
00035     DWORD dwNumArgs = dwArgCount - dwCurrentIndex;
00036
00037     //
00038     // If there are args for us to process..
00039     //
00040     if (dwNumArgs)
00041     {
00042         dwRet = ERROR_OKAY;
00043
00044         for (DWORD i = dwCurrentIndex; i < dwArgCount; i++)
00045         {
00046             ULONG ulErrorNumber = wcstoul(ppwcArguments[i], NULL, 10);
00047             if (!ulErrorNumber)
00048             {
00049                 ulErrorNumber = wcstoul(ppwcArguments[i], NULL, 16);
00050             }
00051
00052             //
00053             // Use PrintError's first type of functionality, that being
00054             // printing out system error messages, be they netsh error
00055             // messages, (see netsh.h), ras errors, mpr errors, or win32
00056             // errors.
00057             //
00058             PrintMessage(L"%1!u!: ", ulErrorNumber);
00059             //
00060             // Pad the PrintError call with some extra zero's - this will prevent us from AV'ing
00061             // if we try to look at an error string that requires extra inputs.  (Hack, but
00062             // since it is expected that you know which error string you are outputting, it's
00063             // unavoidable.)
00064             //
00065             if (!PrintError(0, ulErrorNumber, 0, 0, 0, 0, 0, 0))
00066             {
00067                 //
00068                 // PrintError returns 0 if something didn't work (usually means
00069                 // invalid error id), so we can use its other function, which
00070                 // is to print out error messages from a given module.  Note that
00071                 // this is essentially the same functionality as
00072                 // PrintMessageFromModule.
00073                 //
00074                 PrintError(g_hModule, ERR_INVALID_ERROR_CODE, ulErrorNumber, ulErrorNumber);
00075             }
00076         }
00077     }
00078
00079     return dwRet;
00080 }
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CTIMER Member List

This is the complete list of members for CTIMER, including all inherited members.
CTIMER() | CTIMER | [inline]
m_liFreq | CTIMER |
m_sStart | CTIMER |
m_sStop | CTIMER |
OutputTime() | CTIMER | [inline]
Start() | CTIMER | [inline]
Stop() | CTIMER | [inline]
Generated on Wed Nov 13 2024 16:57:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/rtcsample/StdAfx.cpp Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • rtcsample

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  rtcsample.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Spy/ComSpyCtl/lbsub.h Source File

  • Com
  • Administration
  • Spy
  • ComSpyCtl

lbsub.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017 #ifndef __LBSUB_H__
00018 #define __LBSUB_H__
00019
00020 #include "resource.h"       // main symbols
00021
00022 CComBSTR GuidToBstr(REFGUID guid);
00023
00024 class CComSpy;
00025
00026 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00027 Class:   CLBSub
00028 Summary: Load Balancing Events Subscriber
00029 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00030 class ATL_NO_VTABLE CLBSub :
00031   public CSysLCESub,
00032   public ILBEvents
00033 {
00034 public:
00035   CLBSub(CComSpy * pSpy)
00036   {
00037     m_pSpy = pSpy;
00038   }
00039
00040   CLBSub()
00041   {
00042     m_pSpy = NULL;
00043   }
00044
00045   DECLARE_NOT_AGGREGATABLE(CLBSub)
00046   DECLARE_GET_CONTROLLING_UNKNOWN()
00047
00048   BEGIN_COM_MAP(CLBSub)
00049     COM_INTERFACE_ENTRY(ILBEvents)
00050     COM_INTERFACE_ENTRY_CHAIN(CSysLCESub)
00051   END_COM_MAP()
00052
00053   STDMETHODIMP GetEventType(EventEnum * e){*e = LoadBalancing;return S_OK;}
00054   STDMETHODIMP GetEventClass(LPGUID guid){*guid = CLSID_LBEvents;return S_OK;}
00055   STDMETHODIMP GetInterface(IID* iid){*iid = IID_ILBEvents;return S_OK;}
00056
00057   ////////////////
00058   STDMETHODIMP TargetUp (BSTR bstrServerName, BSTR bstrClsidEng)
00059   {
00060     LONGLONG perfCount = 0;
00061     ::QueryPerformanceCounter( (LARGE_INTEGER *)&perfCount );
00062
00063     m_pSpy -> AddEventToList(perfCount, OLESTR("Target Up"), OLESTR("COM+ Load Balancing"));
00064     m_pSpy -> AddParamValueToList(L"ServerName", bstrServerName);
00065     m_pSpy -> AddParamValueToList(L"Engine ID", bstrClsidEng);
00066
00067     IF_AUDIT_DO(TargetUp)(perfCount,bstrServerName,bstrClsidEng);
00068
00069     return S_OK;
00070   }
00071
00072
00073   STDMETHODIMP TargetDown (BSTR bstrServerName, BSTR bstrClsidEng)
00074   {
00075     LONGLONG perfCount = 0;
00076     ::QueryPerformanceCounter( (LARGE_INTEGER *)&perfCount );
00077
00078     m_pSpy -> AddEventToList(perfCount, OLESTR("Target Down"), OLESTR("COM+ Load Balancing"));
00079     m_pSpy -> AddParamValueToList(L"ServerName", bstrServerName);
00080     m_pSpy -> AddParamValueToList(L"Engine ID", bstrClsidEng);
00081
00082     IF_AUDIT_DO(TargetDown)(perfCount,bstrServerName,bstrClsidEng);
00083
00084     return S_OK;
00085   }
00086
00087   STDMETHODIMP EngineDefined (BSTR bstrPropName, VARIANT *varPropValue, BSTR bstrClsidEng)
00088   {
00089     //This event has not been implemented yet and will be active in the future.
00090     return S_OK;
00091   }
00092
00093 };
00094
00095 #endif //__LBSUB_H__
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAgentCtlCharacters Member List

This is the complete list of members for CAgentCtlCharacters, including all inherited members.
CAgentCtlCharacters() | CAgentCtlCharacters | [inline]
CAgentCtlCharacters(LPDISPATCH pDispatch) | CAgentCtlCharacters | [inline]
CAgentCtlCharacters(const CAgentCtlCharacters &dispatchSrc) | CAgentCtlCharacters | [inline]
Character(LPCTSTR CharacterID) | CAgentCtlCharacters |
GetItem(LPCTSTR CharacterID) | CAgentCtlCharacters |
Load(LPCTSTR CharacterID, const VARIANT &LoadKey) | CAgentCtlCharacters |
Unload(LPCTSTR CharacterID) | CAgentCtlCharacters |
Generated on Wed Nov 13 2024 16:55:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/IPRenew/IPRenew.Cpp Source File

  • NetDS
  • IPHelp
  • IPRenew

IPRenew.Cpp

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1996 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \******************************************************************************/
00010
00011 /*
00012 Module Name:
00013
00014     iprenew.cpp
00015
00016 Abstract:
00017
00018     This module illustrates how to programmatically release and renew IP addresses
00019     obtained through DHCP.  This program also demonstrates how to retrieve existing
00020     network adapter configuration information.
00021
00022     IP address assignment from DHCP can be updated using the IpRenewAddress() and
00023     IpReleaseAddress() IP Helper APIs.  These APIs require you to understand adapter
00024     index numbers.  In Windows, every network adapter has a unique index ID.  Adapter
00025     index IDs can be retrieved using the GetAdaptersInfo() IP Helper API.  This program
00026     features a list option that displays current network adapter configuration
00027     information showing all adapters index numbers associated with their corresponding
00028     network adaptors.
00029
00030     To execute this application, simply build the application using the Visual C++
00031     Nmake.exe program generation facility.  An iprenew.exe program should result.
00032     Execute the iprenew.exe with the following parameters:
00033
00034     Iprenew.exe [ -l ] [ -r<index id> ] [ -n<index id> ]
00035
00036         -l List adapters with corresponding index ID information
00037         -r Release IP address for adapter index ID
00038         -n Renew IP address for adapter index ID
00039
00040 Author:
00041
00042     Jim Ohlund 21-Apr-98
00043
00044 Revision History:
00045
00046 */
00047
00048
00049 #include <windows.h>
00050 #include <iphlpapi.h>
00051 #include <stdio.h>
00052
00053 void Usage(void) {
00054     printf("Usage: Iprenew [ -l ] [ -r<index id> ] [ -n<index id>]\n\n"
00055             "\t -l List adapters with corresponding index ID information\n"
00056             "\t -r Release IP address for adapter index ID\n"
00057             "\t -n Renew IP address for adapter index ID\n");
00058 }
00059
00060 void main(int argc, char *argv[])
00061 {
00062     DWORD InterfaceInfoSize = 0;
00063     PIP_INTERFACE_INFO pInterfaceInfo;
00064     DWORD Err;
00065     INT i;
00066     PIP_ADAPTER_INFO pAdapterInfo, pAdapt;
00067     DWORD AdapterInfoSize = 0;
00068     DWORD Index = (DWORD) -1;
00069     BOOL OptList = FALSE;
00070     BOOL OptRelease = FALSE;
00071     BOOL OptRenew = FALSE;
00072
00073     if (argc < 2)
00074     {
00075         Usage();
00076         return;
00077     }
00078     for (i = 1; i < argc; i++)
00079     {
00080         if ((argv[i][0] == '-') || (argv[i][0] == '/'))
00081         {
00082             switch(tolower(argv[i][1]))
00083             {
00084                 case 'l':
00085                     OptList = TRUE;
00086                     break;
00087                 case 'r':
00088                     OptRelease = TRUE;
00089                     if (strlen(argv[i]) > 2)
00090                         Index = atoi(&argv[i][2]);
00091                     break;
00092                 case 'n':
00093                     OptRenew = TRUE;
00094                     if (strlen(argv[i]) > 2)
00095                         Index = atoi(&argv[i][2]);
00096                     break;
00097                 default:
00098                     Usage();
00099                     return;
00100                 }
00101         }
00102         else
00103         {
00104             Usage();
00105             return;
00106         }
00107     }
00108
00109     // Check options
00110     if ((OptRelease && Index == -1) || (OptRenew && Index == -1))
00111     {
00112         Usage();
00113         return;
00114     }
00115
00116     if (OptList)
00117     {
00118         if ((Err = GetAdaptersInfo(NULL, &AdapterInfoSize)) != 0)
00119         {
00120             if (Err != ERROR_BUFFER_OVERFLOW)
00121             {
00122                 printf("GetAdaptersInfo sizing failed with error %d\n", Err);
00123                 return;
00124             }
00125         }
00126
00127         // Allocate memory from sizing information
00128         if ((pAdapterInfo = (PIP_ADAPTER_INFO) GlobalAlloc(GPTR, AdapterInfoSize)) == NULL)
00129         {
00130             printf("Memory allocation error\n");
00131             return;
00132         }
00133
00134         // Get actual adapter information
00135         if ((Err = GetAdaptersInfo(pAdapterInfo, &AdapterInfoSize)) != 0)
00136         {
00137             printf("GetAdaptersInfo failed with error %d\n", Err);
00138             return;
00139         }
00140
00141         pAdapt = pAdapterInfo;
00142
00143         printf("Index     Adapter\n");
00144         while (pAdapt)
00145         {
00146             printf("%-10.i%s\n", pAdapt->Index, pAdapt->Description);
00147             pAdapt = pAdapt->Next;
00148         }
00149     }
00150
00151     if ((Err = GetInterfaceInfo(NULL, &InterfaceInfoSize)) != 0)
00152     {
00153         if (Err != ERROR_INSUFFICIENT_BUFFER)
00154         {
00155             printf("GetInterfaceInfo sizing failed with error %d\n", Err);
00156             return;
00157         }
00158     }
00159
00160     // Allocate memory from sizing information
00161     if ((pInterfaceInfo = (PIP_INTERFACE_INFO) GlobalAlloc(GPTR, InterfaceInfoSize)) == NULL)
00162     {
00163         printf("Memory allocation error\n");
00164         return;
00165     }
00166
00167     // Get actual adapter information
00168     if ((Err = GetInterfaceInfo(pInterfaceInfo, &InterfaceInfoSize)) != 0)
00169     {
00170         printf("GetInterfaceInfo failed with error %d\n", Err);
00171         return;
00172     }
00173
00174
00175     if (OptRelease)
00176     {
00177         for (i = 0; i < pInterfaceInfo->NumAdapters; i++)
00178             if (Index == pInterfaceInfo->Adapter[i].Index)
00179             {
00180                 if ((Err = IpReleaseAddress(&pInterfaceInfo->Adapter[i])) != 0)
00181                 {
00182                     printf("IpReleaseAddress failed with error %d\n", Err);
00183                     return;
00184                 }
00185                 break;
00186             }
00187     }
00188
00189
00190     if (OptRenew)
00191     {
00192         for (i = 0; i < pInterfaceInfo->NumAdapters; i++)
00193             if (Index == pInterfaceInfo->Adapter[i].Index)
00194             {
00195                 if ((Err = IpRenewAddress(&pInterfaceInfo->Adapter[i])) != 0)
00196                 {
00197                     printf("IpRenewAddress failed with error %d\n", Err);
00198                     return;
00199                 }
00200                 break;
00201             }
00202     }
00203 }
00204
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCompImportDlg Member List

This is the complete list of members for CCompImportDlg, including all inherited members.
CCompImportDlg(CWnd *pParent=NULL) | CCompImportDlg |
DoDataExchange(CDataExchange *pDX) | CCompImportDlg | [protected, virtual]
IDD enum value | CCompImportDlg |
LoadAppCombo() | CCompImportDlg | [private]
m_cboApplications | CCompImportDlg |
m_edtID | CCompImportDlg |
m_hIcon | CCompImportDlg | [protected]
m_lblComponentDesc | CCompImportDlg |
m_nImportType | CCompImportDlg | [private]
m_pCatalog | CCompImportDlg | [private]
OnClose() | CCompImportDlg | [protected]
OnCLSID() | CCompImportDlg | [protected]
OnInitDialog() | CCompImportDlg | [protected, virtual]
OnOK() | CCompImportDlg | [protected, virtual]
OnProgID() | CCompImportDlg | [protected]
ReleaseCatalog() | CCompImportDlg | [private]
set_Catalog(ICOMAdminCatalog *pCatalog) | CCompImportDlg |
Generated on Wed Nov 13 2024 16:55:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Object/CallAs/Server.Cxx Source File

  • Com
  • Fundamentals
  • Object
  • CallAs

Server.Cxx

Go to the documentation of this file.
00001 /****************************************************************************
00002                        Microsoft RPC
00003                 Copyright Microsoft Corp. 1992-2000
00004                   object call_as Example
00005
00006     FILE:       server.cxx
00007
00008     USAGE:      server  - note that this is auto-loaded by the client
00009                           requesting this server, and exits at completion
00010
00011     PURPOSE:    Server side of RPC distributed application
00012
00013     FUNCTIONS:  main() - binds to server and calls remote procedure
00014
00015     COMMENTS:   This version of the Ole2 distributed application that
00016                 prints "hello, world" (or other string) on the server
00017                 features a non-rpcable custom interface being remoted with
00018                 [call_as].
00019
00020                 It provides a class factory to manufacture a server object,
00021                 and the implementation of the callas server object
00022
00023 ****************************************************************************/
00024
00025 #define INC_OLE2
00026 #include <windows.h>
00027 #include <stdio.h>
00028 #include <assert.h>
00029 #include "callas.h"
00030
00031 unsigned long   ObjectCount         = 0;
00032 BOOL            fClassRegistered    = FALSE;
00033 DWORD           dwHandle            = 0;
00034
00035 // this is the CLSID for the class factory for the server
00036
00037 const CLSID CLSID_CallAs
00038     = {0xf9246030,0x9f33,0x11cd,{0xb2,0x3f,0x00,0xaa,0x00,0x33,0x9c,0xce}};
00039
00040 IClassFactory *GetCallAsFactory();
00041
00042
00043
00044
00045 // here are some convenient inline functions to reduce the casting involved
00046 // with having the RefCount be unsigned instead of signed, and pass by
00047 // reference
00048
00049 inline
00050 unsigned long
00051 IncrementRefCount( unsigned long & RefCount )
00052     {
00053     return InterlockedIncrement( (long *) &RefCount );
00054     }
00055
00056 inline
00057 unsigned long
00058 DecrementRefCount( unsigned long & RefCount )
00059     {
00060     return InterlockedDecrement( (long *) &RefCount );
00061     }
00062
00063
00064
00065
00066
00067
00068
00069 // this is the class factory for the CCallAs server
00070 // it manufactures CCallAs server objects in response to a CreateInstance
00071 // call
00072
00073 class CCallAsFactory : public IClassFactory
00074
00075 {
00076 public:
00077     // note that the virtual methods must exactly match the set for
00078     // the IClassFactory in the idl (and callas.h)
00079     unsigned long    RefCount;
00080
00081                             CCallAsFactory()
00082                                 {
00083                                 RefCount    = 0;
00084                                 }
00085
00086         HRESULT STDMETHODCALLTYPE QueryInterface(
00087                 REFIID iid,
00088             void **ppv);
00089
00090         ULONG STDMETHODCALLTYPE AddRef();
00091
00092         ULONG STDMETHODCALLTYPE Release();
00093
00094         HRESULT STDMETHODCALLTYPE CreateInstance(
00095             IUnknown *punkOuter,
00096             REFIID riid,
00097             void **ppv);
00098
00099    HRESULT STDMETHODCALLTYPE LockServer(
00100         BOOL fLock );
00101 };
00102
00103 // allocate a static classfactory to avoid construction races if
00104 // we were multithreaded.
00105 CCallAsFactory       gCallAsClassFactory;
00106
00107
00108
00109
00110
00111 class CCallAs   : public IHelloCallAs
00112
00113 {
00114
00115     unsigned long    RefCount;
00116
00117 public:
00118
00119     // remoted functions (virtual)
00120
00121         HRESULT STDMETHODCALLTYPE QueryInterface(
00122                 REFIID iid,
00123             void **ppv);
00124
00125         ULONG STDMETHODCALLTYPE AddRef();
00126
00127         ULONG STDMETHODCALLTYPE Release();
00128
00129         MyBoolean __stdcall HelloProc(
00130             unsigned char *pszString);
00131
00132         // local functions
00133         // constructor
00134                             CCallAs()
00135                                 {
00136                                 RefCount    = 0;
00137                                 }
00138
00139     void    *   operator new( size_t s )
00140                                 {
00141                                 return CoTaskMemAlloc( s );
00142                                 }
00143
00144     void        operator delete( void * pv )
00145                                 {
00146                                 CoTaskMemFree( pv );
00147                                 }
00148
00149 };
00150
00151
00152 //+---------------------------------------------------------------------------
00153 //
00154 //  Function:   main
00155 //
00156 //  Synopsis:
00157 //
00158 //  Arguments:
00159 //
00160 //  Returns:    void
00161 //
00162 //  Modifies:   nothing
00163 //
00164 //  Notes:      none
00165 //
00166 //----------------------------------------------------------------------------
00167
00168 void _cdecl main()
00169 {
00170     HRESULT hr;
00171     MSG msg;
00172         IClassFactory *pClassFactory;
00173
00174     //
00175     // Initialize OLE before calling any other OLE functions.
00176     //
00177
00178     hr = CoInitialize(NULL);
00179
00180     if( FAILED(hr))
00181     {
00182             printf("Server: CoInitialize failed(%x)\n",hr);
00183         return;
00184     }
00185
00186         pClassFactory = GetCallAsFactory();
00187
00188         hr = CoRegisterClassObject(CLSID_CallAs,
00189                                                (IUnknown *) pClassFactory,
00190                                                CLSCTX_LOCAL_SERVER,
00191                                                REGCLS_SINGLEUSE,
00192                                                &dwHandle);
00193
00194         pClassFactory->Release();
00195
00196         if (FAILED(hr))
00197             printf("Server: CoRegisterClassObject failed %x\n", hr);
00198         else
00199         {
00200                 fClassRegistered = TRUE;
00201
00202             // message loop
00203         while (GetMessage(&msg, NULL, 0, 0))
00204         {
00205                 TranslateMessage(&msg);
00206                 DispatchMessage(&msg);
00207         }
00208         }
00209     CoUninitialize();
00210
00211     return;
00212 }
00213
00214 //+-------------------------------------------------------------------------
00215 //
00216 //  Method:     GetCallAsFactory
00217 //
00218 //  Synopsis:   Get an IClassFactory * for the CallAs class.
00219 //
00220 //--------------------------------------------------------------------------
00221 IClassFactory *GetCallAsFactory()
00222 {
00223     // increment the file object count the first time it is created
00224         if(gCallAsClassFactory.RefCount == 0)
00225         {
00226                 IncrementRefCount(gCallAsClassFactory.RefCount);
00227                 IncrementRefCount(ObjectCount);
00228         }
00229         else
00230         {
00231                 IncrementRefCount(gCallAsClassFactory.RefCount);
00232         }
00233         return &gCallAsClassFactory;
00234 }
00235
00236 //+-------------------------------------------------------------------------
00237 //
00238 //  Method:     CCallAsFactory::QueryInterface, public
00239 //
00240 //  Synopsis:   Query for an interface on the class factory.
00241 //
00242 //  Derivation: IUnknown
00243 //
00244 //--------------------------------------------------------------------------
00245 HRESULT STDMETHODCALLTYPE
00246 CCallAsFactory::QueryInterface (
00247     REFIID iid,
00248     void **ppv )
00249 {
00250     HRESULT hr = E_NOINTERFACE;
00251
00252         assert(ppv);
00253
00254     *ppv = 0;
00255     if ( IsEqualGUID( iid, IID_IUnknown) ||
00256          IsEqualGUID( iid, IID_IClassFactory ) )
00257     {
00258         *ppv = this;
00259                 AddRef();
00260             hr = S_OK;
00261     }
00262
00263     return hr;
00264 }
00265 //+-------------------------------------------------------------------------
00266 //
00267 //  Method:     CCallAsFactory::AddRef, public
00268 //
00269 //  Synopsis:   Increment DLL reference counts
00270 //
00271 //  Derivation: IUnknown
00272 //
00273 //      Notes: We have a single instance of the CCallAsFactory.
00274 //
00275 //--------------------------------------------------------------------------
00276 ULONG STDMETHODCALLTYPE
00277 CCallAsFactory::AddRef()
00278 {
00279     IncrementRefCount(RefCount);
00280         return RefCount;
00281 }
00282
00283 //+-------------------------------------------------------------------------
00284 //
00285 //  Method:     CCallAsFactory::Release, public
00286 //
00287 //  Synopsis:   Decrement DLL reference count
00288 //
00289 //  Derivation: IUnknown
00290 //
00291 //--------------------------------------------------------------------------
00292 ULONG STDMETHODCALLTYPE
00293 CCallAsFactory::Release()
00294 {
00295         long t;
00296         unsigned long count;
00297
00298     t = DecrementRefCount(RefCount);
00299
00300         if(t == 0)
00301         {
00302                 count = 0;
00303                 //decrement the object count
00304                 if(DecrementRefCount(ObjectCount) == 0)
00305                 {
00306                         //The last object has been destroyed.
00307                         PostQuitMessage(0);
00308                 }
00309         }
00310         else
00311                 count = RefCount;
00312
00313     return count;
00314 }
00315
00316 //+-------------------------------------------------------------------------
00317 //
00318 //  Method:     CCallAsFactory::CreateInstance, public
00319 //
00320 //  Synopsis:   Create an instance of CCallAs.
00321 //
00322 //--------------------------------------------------------------------------
00323 HRESULT STDMETHODCALLTYPE
00324 CCallAsFactory::CreateInstance
00325 (
00326     IUnknown *punkOuter,
00327     REFIID riid,
00328     void **ppv
00329 )
00330 {
00331     HRESULT hr = E_OUTOFMEMORY;
00332         CCallAs *pCallAs;
00333
00334         assert(ppv);
00335
00336         *ppv = 0;
00337
00338         if(fClassRegistered == TRUE)
00339         {
00340                 fClassRegistered = FALSE;
00341                 CoRevokeClassObject(dwHandle);
00342         }
00343
00344         pCallAs = new CCallAs();
00345         if(pCallAs)
00346         {
00347             // invoke the constructor
00348                 *pCallAs = CCallAs();
00349
00350                 //increment the object count.
00351                 //The object count will keep this process alive until all
00352                 //objects are released.
00353                 IncrementRefCount(ObjectCount);
00354                 hr = pCallAs->QueryInterface( riid, ppv);
00355         }
00356
00357     return hr;
00358 }
00359
00360 //+-------------------------------------------------------------------------
00361 //
00362 //  Method:     CCallAsFactory::LockServer, public
00363 //
00364 //  Synopsis:   Lock the server in memory (by adding an extra reference)
00365 //
00366 //--------------------------------------------------------------------------
00367 HRESULT STDMETHODCALLTYPE
00368 CCallAsFactory::LockServer(
00369         BOOL fLock )
00370 {
00371     if ( fLock )
00372             IncrementRefCount( ObjectCount );
00373         else
00374             DecrementRefCount( ObjectCount );
00375
00376         return S_OK;
00377
00378 }
00379
00380 //+-------------------------------------------------------------------------
00381 //
00382 //  Method:     CCallAs::QueryInterface, public
00383 //
00384 //  Synopsis:   Query for an interface on the class factory.
00385 //
00386 //  Derivation: IUnknown
00387 //
00388 //--------------------------------------------------------------------------
00389 HRESULT STDMETHODCALLTYPE
00390 CCallAs::QueryInterface (
00391     REFIID iid,
00392     void **ppv )
00393 {
00394     HRESULT hr = E_NOINTERFACE;
00395
00396         assert(ppv);
00397
00398     *ppv = 0;
00399     if ( IsEqualGUID( iid, IID_IUnknown ) ||
00400          IsEqualGUID( iid, IID_IHelloCallAs ) )
00401     {
00402         *ppv = this;
00403                 AddRef();
00404             hr = S_OK;
00405     }
00406
00407     return hr;
00408 }
00409 //+-------------------------------------------------------------------------
00410 //
00411 //  Method:     CCallAs::AddRef, public
00412 //
00413 //  Synopsis:   Increment reference count
00414 //
00415 //  Derivation: IUnknown
00416 //
00417 //--------------------------------------------------------------------------
00418 ULONG STDMETHODCALLTYPE
00419 CCallAs::AddRef()
00420 {
00421     IncrementRefCount(RefCount);
00422         return RefCount;
00423 }
00424
00425 //+-------------------------------------------------------------------------
00426 //
00427 //  Method:     CCallAs::Release, public
00428 //
00429 //  Synopsis:   Decrement DLL reference count
00430 //
00431 //  Derivation: IUnknown
00432 //
00433 //--------------------------------------------------------------------------
00434 ULONG STDMETHODCALLTYPE
00435 CCallAs::Release()
00436 {
00437         long t;
00438         unsigned long count;
00439
00440     t = DecrementRefCount(RefCount);
00441
00442         if(t == 0)
00443         {
00444                 count = 0;
00445
00446                 //decrement the object count
00447                 if(DecrementRefCount(ObjectCount) == 0)
00448                 {
00449                         //The last object has been destroyed.
00450                         PostQuitMessage(0);
00451                 }
00452                 delete this;
00453         }
00454         else
00455                 count = RefCount;
00456
00457     return count;
00458 }
00459
00460 //+---------------------------------------------------------------------------
00461 //
00462 //  Function:   CCallAs::HelloProc()
00463 //
00464 //  Synopsis:   Displays the specified string
00465 //
00466 //  Arguments:  void
00467 //
00468 //  Returns:    Success.
00469 //
00470 //  Modifies:   nothing
00471 //
00472 //  Notes:      none
00473 //
00474 //----------------------------------------------------------------------------
00475 MyBoolean __stdcall
00476 CCallAs::HelloProc(unsigned char *pszString)
00477 {
00478     printf("HelloProc: %s \n", pszString);
00479     printf(" <pausing for 5 sec>\n");
00480     // pretend to be busy computing for a bit
00481     Sleep( 5000 ); // 5000 msec = 5 sec
00482
00483     return TRUE;
00484 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Hello/Helloc.c Source File

  • NetDS
  • RPC
  • Hello

Helloc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                        Hello Example
00005
00006     FILE:       helloc.c
00007
00008     USAGE:      helloc  -n network_address
00009                         -p protocol_sequence
00010                         -e endpoint
00011                         -o options
00012                         -s string_displayed_on_server
00013
00014     PURPOSE:    Client side of RPC distributed application
00015
00016     FUNCTIONS:  main() - binds to server and calls remote procedure
00017
00018     COMMENTS:   This version of the distributed application that
00019                 prints "hello, world" (or other string) on the server
00020                 features a client that manages its connection to the
00021                 server. It uses the binding handle hello_IfHandle,
00022                 defined in the file hello.h.
00023
00024 ****************************************************************************/
00025
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <ctype.h>
00029 #include "hello.h"    // header file generated by MIDL compiler
00030
00031 void Usage(char * pszProgramName)
00032 {
00033     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00034     fprintf(stderr, " -p protocol_sequence\n");
00035     fprintf(stderr, " -n network_address\n");
00036     fprintf(stderr, " -e endpoint\n");
00037     fprintf(stderr, " -o options\n");
00038     fprintf(stderr, " -s string\n");
00039     exit(1);
00040 }
00041
00042 void __cdecl main(int argc, char **argv)
00043 {
00044     RPC_STATUS status;
00045     unsigned char * pszUuid             = NULL;
00046     unsigned char * pszProtocolSequence = "ncacn_np";
00047     unsigned char * pszNetworkAddress   = NULL;
00048     unsigned char * pszEndpoint         = "\\pipe\\hello";
00049     unsigned char * pszOptions          = NULL;
00050     unsigned char * pszStringBinding    = NULL;
00051     unsigned char * pszString           = "hello, world";
00052     unsigned long ulCode;
00053     int i;
00054
00055     /* allow the user to override settings with command line switches */
00056     for (i = 1; i < argc; i++) {
00057         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00058             switch (tolower(*(argv[i]+1))) {
00059             case 'p':  // protocol sequence
00060                 pszProtocolSequence = argv[++i];
00061                 break;
00062             case 'n':  // network address
00063                 pszNetworkAddress = argv[++i];
00064                 break;
00065             case 'e':  // endpoint
00066                 pszEndpoint = argv[++i];
00067                 break;
00068             case 'o':
00069                 pszOptions = argv[++i];
00070                 break;
00071             case 's':
00072                 pszString = argv[++i];
00073                 break;
00074             case 'h':
00075             case '?':
00076             default:
00077                 Usage(argv[0]);
00078             }
00079         }
00080         else
00081             Usage(argv[0]);
00082     }
00083
00084     /* Use a convenience function to concatenate the elements of */
00085     /* the string binding into the proper sequence.              */
00086     status = RpcStringBindingCompose(pszUuid,
00087                                      pszProtocolSequence,
00088                                      pszNetworkAddress,
00089                                      pszEndpoint,
00090                                      pszOptions,
00091                                      &pszStringBinding);
00092     printf("RpcStringBindingCompose returned 0x%x\n", status);
00093     printf("pszStringBinding = %s\n", pszStringBinding);
00094     if (status) {
00095         exit(status);
00096     }
00097
00098     /* Set the binding handle that will be used to bind to the server. */
00099     status = RpcBindingFromStringBinding(pszStringBinding,
00100                                          &hello_IfHandle);
00101     printf("RpcBindingFromStringBinding returned 0x%x\n", status);
00102     if (status) {
00103         exit(status);
00104     }
00105
00106     printf("Calling the remote procedure 'HelloProc'\n");
00107     printf("Print the string '%s' on the server\n", pszString);
00108
00109     RpcTryExcept {
00110         HelloProc(pszString);  // make call with user message
00111         printf("Calling the remote procedure 'Shutdown'\n");
00112         Shutdown();  // shut down the server side
00113     }
00114     RpcExcept(1) {
00115         ulCode = RpcExceptionCode();
00116         printf("Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode);
00117     }
00118     RpcEndExcept
00119
00120     /*  The calls to the remote procedures are complete. */
00121     /*  Free the string and the binding handle           */
00122     status = RpcStringFree(&pszStringBinding);  // remote calls done; unbind
00123     printf("RpcStringFree returned 0x%x\n", status);
00124     if (status) {
00125         exit(status);
00126     }
00127
00128     status = RpcBindingFree(&hello_IfHandle);  // remote calls done; unbind
00129     printf("RpcBindingFree returned 0x%x\n", status);
00130     if (status) {
00131         exit(status);
00132     }
00133
00134     exit(0);
00135
00136 }  // end main()
00137
00138
00139 /*********************************************************************/
00140 /*                 MIDL allocate and free                            */
00141 /*********************************************************************/
00142
00143 void  __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00144 {
00145     return(malloc(len));
00146 }
00147
00148 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00149 {
00150     free(ptr);
00151 }
00152
00153 /* end file helloc.c */
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EdAnnotator/AnnotatorProject/EDAnnotator_p.c Source File

  • Web
  • Browser
  • EdAnnotator
  • AnnotatorProject

EDAnnotator_p.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 /* this ALWAYS GENERATED file contains the proxy stub code */
00006
00007
00008 /* File created by MIDL compiler version 5.01.0164 */
00009 /* at Fri Jul 07 09:59:00 2000
00010  */
00011 /* Compiler settings for C:\workshop\samples\browser\EDAnnotator\EDAnnotator.idl:
00012     Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
00013     error checks: allocation ref bounds_check enum stub_data
00014 */
00015 //@@MIDL_FILE_HEADING(  )
00016
00017 #define USE_STUBLESS_PROXY
00018
00019
00020 /* verify that the <rpcproxy.h> version is high enough to compile this file*/
00021 #ifndef __REDQ_RPCPROXY_H_VERSION__
00022 #define __REQUIRED_RPCPROXY_H_VERSION__ 440
00023 #endif
00024
00025
00026 #include "rpcproxy.h"
00027 #ifndef __RPCPROXY_H_VERSION__
00028 #error this stub requires an updated version of <rpcproxy.h>
00029 #endif // __RPCPROXY_H_VERSION__
00030
00031
00032 #include "EDAnnotator.h"
00033
00034 #define TYPE_FORMAT_STRING_SIZE   21
00035 #define PROC_FORMAT_STRING_SIZE   101
00036
00037 typedef struct _MIDL_TYPE_FORMAT_STRING
00038     {
00039     short          Pad;
00040     unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
00041     } MIDL_TYPE_FORMAT_STRING;
00042
00043 typedef struct _MIDL_PROC_FORMAT_STRING
00044     {
00045     short          Pad;
00046     unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
00047     } MIDL_PROC_FORMAT_STRING;
00048
00049
00050 extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
00051 extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
00052
00053
00054 /* Standard interface: __MIDL_itf_EDAnnotator_0000, ver. 0.0,
00055    GUID={0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} */
00056
00057
00058 /* Object interface: IUnknown, ver. 0.0,
00059    GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
00060
00061
00062 /* Object interface: IDispatch, ver. 0.0,
00063    GUID={0x00020400,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
00064
00065
00066 /* Object interface: IAnnotator, ver. 0.0,
00067    GUID={0xFB422822,0x6FA5,0x4B38,{0x9E,0x17,0xF2,0x8A,0xFF,0xEB,0x6E,0x10}} */
00068
00069
00070 extern const MIDL_STUB_DESC Object_StubDesc;
00071
00072
00073 extern const MIDL_SERVER_INFO IAnnotator_ServerInfo;
00074
00075 #pragma code_seg(".orpc")
00076
00077 static const MIDL_STUB_DESC Object_StubDesc =
00078     {
00079     0,
00080     NdrOleAllocate,
00081     NdrOleFree,
00082     0,
00083     0,
00084     0,
00085     0,
00086     0,
00087     __MIDL_TypeFormatString.Format,
00088     1, /* -error bounds_check flag */
00089     0x20000, /* Ndr library version */
00090     0,
00091     0x50100a4, /* MIDL Version 5.1.164 */
00092     0,
00093     0,
00094     0,  /* notify & notify_flag routine table */
00095     1,  /* Flags */
00096     0,  /* Reserved3 */
00097     0,  /* Reserved4 */
00098     0   /* Reserved5 */
00099     };
00100
00101 static const unsigned short IAnnotator_FormatStringOffsetTable[] =
00102     {
00103     (unsigned short) -1,
00104     (unsigned short) -1,
00105     (unsigned short) -1,
00106     (unsigned short) -1,
00107     0,
00108     28,
00109     50,
00110     78
00111     };
00112
00113 static const MIDL_SERVER_INFO IAnnotator_ServerInfo =
00114     {
00115     &Object_StubDesc,
00116     0,
00117     __MIDL_ProcFormatString.Format,
00118     &IAnnotator_FormatStringOffsetTable[-3],
00119     0,
00120     0,
00121     0,
00122     0
00123     };
00124
00125 static const MIDL_STUBLESS_PROXY_INFO IAnnotator_ProxyInfo =
00126     {
00127     &Object_StubDesc,
00128     __MIDL_ProcFormatString.Format,
00129     &IAnnotator_FormatStringOffsetTable[-3],
00130     0,
00131     0,
00132     0
00133     };
00134
00135 CINTERFACE_PROXY_VTABLE(11) _IAnnotatorProxyVtbl =
00136 {
00137     &IAnnotator_ProxyInfo,
00138     &IID_IAnnotator,
00139     IUnknown_QueryInterface_Proxy,
00140     IUnknown_AddRef_Proxy,
00141     IUnknown_Release_Proxy ,
00142     0 /* (void *)-1 /* IDispatch::GetTypeInfoCount */ ,
00143     0 /* (void *)-1 /* IDispatch::GetTypeInfo */ ,
00144     0 /* (void *)-1 /* IDispatch::GetIDsOfNames */ ,
00145     0 /* IDispatch_Invoke_Proxy */ ,
00146     (void *)-1 /* IAnnotator::AttachAnnotator */ ,
00147     (void *)-1 /* IAnnotator::DetachAnnotator */ ,
00148     (void *)-1 /* IAnnotator::ShowCommentGlyphs */ ,
00149     (void *)-1 /* IAnnotator::AddComment */
00150 };
00151
00152
00153 static const PRPC_STUB_FUNCTION IAnnotator_table[] =
00154 {
00155     STUB_FORWARDING_FUNCTION,
00156     STUB_FORWARDING_FUNCTION,
00157     STUB_FORWARDING_FUNCTION,
00158     STUB_FORWARDING_FUNCTION,
00159     NdrStubCall2,
00160     NdrStubCall2,
00161     NdrStubCall2,
00162     NdrStubCall2
00163 };
00164
00165 CInterfaceStubVtbl _IAnnotatorStubVtbl =
00166 {
00167     &IID_IAnnotator,
00168     &IAnnotator_ServerInfo,
00169     11,
00170     &IAnnotator_table[-3],
00171     CStdStubBuffer_DELEGATING_METHODS
00172 };
00173
00174 #pragma data_seg(".rdata")
00175
00176 #if !defined(__RPC_WIN32__)
00177 #error  Invalid build platform for this stub.
00178 #endif
00179
00180 #if !(TARGET_IS_NT40_OR_LATER)
00181 #error You need a Windows NT 4.0 or later to run this stub because it uses these features:
00182 #error   -Oif or -Oicf, more than 64 delegated procs, float, double or hyper in -Oif or -Oicf, more than 32 methods in the interface.
00183 #error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
00184 #error This app will die there with the RPC_X_WRONG_STUB_VERSION error.
00185 #endif
00186
00187
00188 static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
00189     {
00190         0,
00191         {
00192
00193   /* Procedure AttachAnnotator */
00194
00195       0x33,   /* FC_AUTO_HANDLE */
00196       0x6c,   /* Old Flags:  object, Oi2 */
00197 /*  2 */  NdrFcLong( 0x0 ), /* 0 */
00198 /*  6 */  NdrFcShort( 0x7 ),  /* 7 */
00199 #ifndef _ALPHA_
00200 /*  8 */  NdrFcShort( 0xc ),  /* x86, MIPS, PPC Stack size/offset = 12 */
00201 #else
00202       NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */
00203 #endif
00204 /* 10 */  NdrFcShort( 0x0 ),  /* 0 */
00205 /* 12 */  NdrFcShort( 0x8 ),  /* 8 */
00206 /* 14 */  0x6,    /* Oi2 Flags:  clt must size, has return, */
00207       0x2,    /* 2 */
00208
00209   /* Parameter pDoc */
00210
00211 /* 16 */  NdrFcShort( 0xb ),  /* Flags:  must size, must free, in, */
00212 #ifndef _ALPHA_
00213 /* 18 */  NdrFcShort( 0x4 ),  /* x86, MIPS, PPC Stack size/offset = 4 */
00214 #else
00215       NdrFcShort( 0x8 ),  /* Alpha Stack size/offset = 8 */
00216 #endif
00217 /* 20 */  NdrFcShort( 0x2 ),  /* Type Offset=2 */
00218
00219   /* Return value */
00220
00221 /* 22 */  NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
00222 #ifndef _ALPHA_
00223 /* 24 */  NdrFcShort( 0x8 ),  /* x86, MIPS, PPC Stack size/offset = 8 */
00224 #else
00225       NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
00226 #endif
00227 /* 26 */  0x8,    /* FC_LONG */
00228       0x0,    /* 0 */
00229
00230   /* Procedure DetachAnnotator */
00231
00232 /* 28 */  0x33,   /* FC_AUTO_HANDLE */
00233       0x6c,   /* Old Flags:  object, Oi2 */
00234 /* 30 */  NdrFcLong( 0x0 ), /* 0 */
00235 /* 34 */  NdrFcShort( 0x8 ),  /* 8 */
00236 #ifndef _ALPHA_
00237 /* 36 */  NdrFcShort( 0x8 ),  /* x86, MIPS, PPC Stack size/offset = 8 */
00238 #else
00239       NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
00240 #endif
00241 /* 38 */  NdrFcShort( 0x0 ),  /* 0 */
00242 /* 40 */  NdrFcShort( 0x8 ),  /* 8 */
00243 /* 42 */  0x4,    /* Oi2 Flags:  has return, */
00244       0x1,    /* 1 */
00245
00246   /* Return value */
00247
00248 /* 44 */  NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
00249 #ifndef _ALPHA_
00250 /* 46 */  NdrFcShort( 0x4 ),  /* x86, MIPS, PPC Stack size/offset = 4 */
00251 #else
00252       NdrFcShort( 0x8 ),  /* Alpha Stack size/offset = 8 */
00253 #endif
00254 /* 48 */  0x8,    /* FC_LONG */
00255       0x0,    /* 0 */
00256
00257   /* Procedure ShowCommentGlyphs */
00258
00259 /* 50 */  0x33,   /* FC_AUTO_HANDLE */
00260       0x6c,   /* Old Flags:  object, Oi2 */
00261 /* 52 */  NdrFcLong( 0x0 ), /* 0 */
00262 /* 56 */  NdrFcShort( 0x9 ),  /* 9 */
00263 #ifndef _ALPHA_
00264 /* 58 */  NdrFcShort( 0xc ),  /* x86, MIPS, PPC Stack size/offset = 12 */
00265 #else
00266       NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */
00267 #endif
00268 /* 60 */  NdrFcShort( 0x8 ),  /* 8 */
00269 /* 62 */  NdrFcShort( 0x8 ),  /* 8 */
00270 /* 64 */  0x4,    /* Oi2 Flags:  has return, */
00271       0x2,    /* 2 */
00272
00273   /* Parameter bShow */
00274
00275 /* 66 */  NdrFcShort( 0x48 ), /* Flags:  in, base type, */
00276 #ifndef _ALPHA_
00277 /* 68 */  NdrFcShort( 0x4 ),  /* x86, MIPS, PPC Stack size/offset = 4 */
00278 #else
00279       NdrFcShort( 0x8 ),  /* Alpha Stack size/offset = 8 */
00280 #endif
00281 /* 70 */  0x8,    /* FC_LONG */
00282       0x0,    /* 0 */
00283
00284   /* Return value */
00285
00286 /* 72 */  NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
00287 #ifndef _ALPHA_
00288 /* 74 */  NdrFcShort( 0x8 ),  /* x86, MIPS, PPC Stack size/offset = 8 */
00289 #else
00290       NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
00291 #endif
00292 /* 76 */  0x8,    /* FC_LONG */
00293       0x0,    /* 0 */
00294
00295   /* Procedure AddComment */
00296
00297 /* 78 */  0x33,   /* FC_AUTO_HANDLE */
00298       0x6c,   /* Old Flags:  object, Oi2 */
00299 /* 80 */  NdrFcLong( 0x0 ), /* 0 */
00300 /* 84 */  NdrFcShort( 0xa ),  /* 10 */
00301 #ifndef _ALPHA_
00302 /* 86 */  NdrFcShort( 0x8 ),  /* x86, MIPS, PPC Stack size/offset = 8 */
00303 #else
00304       NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
00305 #endif
00306 /* 88 */  NdrFcShort( 0x0 ),  /* 0 */
00307 /* 90 */  NdrFcShort( 0x8 ),  /* 8 */
00308 /* 92 */  0x4,    /* Oi2 Flags:  has return, */
00309       0x1,    /* 1 */
00310
00311   /* Return value */
00312
00313 /* 94 */  NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
00314 #ifndef _ALPHA_
00315 /* 96 */  NdrFcShort( 0x4 ),  /* x86, MIPS, PPC Stack size/offset = 4 */
00316 #else
00317       NdrFcShort( 0x8 ),  /* Alpha Stack size/offset = 8 */
00318 #endif
00319 /* 98 */  0x8,    /* FC_LONG */
00320       0x0,    /* 0 */
00321
00322       0x0
00323         }
00324     };
00325
00326 static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
00327     {
00328         0,
00329         {
00330       NdrFcShort( 0x0 ),  /* 0 */
00331 /*  2 */
00332       0x2f,   /* FC_IP */
00333       0x5a,   /* FC_CONSTANT_IID */
00334 /*  4 */  NdrFcLong( 0x332c4425 ),  /* 858539045 */
00335 /*  8 */  NdrFcShort( 0x26cb ), /* 9931 */
00336 /* 10 */  NdrFcShort( 0x11d0 ), /* 4560 */
00337 /* 12 */  0xb4,   /* 180 */
00338       0x83,   /* 131 */
00339 /* 14 */  0x0,    /* 0 */
00340       0xc0,   /* 192 */
00341 /* 16 */  0x4f,   /* 79 */
00342       0xd9,   /* 217 */
00343 /* 18 */  0x1,    /* 1 */
00344       0x19,   /* 25 */
00345
00346       0x0
00347         }
00348     };
00349
00350 const CInterfaceProxyVtbl * _EDAnnotator_ProxyVtblList[] =
00351 {
00352     ( CInterfaceProxyVtbl *) &_IAnnotatorProxyVtbl,
00353     0
00354 };
00355
00356 const CInterfaceStubVtbl * _EDAnnotator_StubVtblList[] =
00357 {
00358     ( CInterfaceStubVtbl *) &_IAnnotatorStubVtbl,
00359     0
00360 };
00361
00362 PCInterfaceName const _EDAnnotator_InterfaceNamesList[] =
00363 {
00364     "IAnnotator",
00365     0
00366 };
00367
00368 const IID *  _EDAnnotator_BaseIIDList[] =
00369 {
00370     &IID_IDispatch,
00371     0
00372 };
00373
00374
00375 #define _EDAnnotator_CHECK_IID(n) IID_GENERIC_CHECK_IID( _EDAnnotator, pIID, n)
00376
00377 int __stdcall _EDAnnotator_IID_Lookup( const IID * pIID, int * pIndex )
00378 {
00379
00380     if(!_EDAnnotator_CHECK_IID(0))
00381         {
00382         *pIndex = 0;
00383         return 1;
00384         }
00385
00386     return 0;
00387 }
00388
00389 const ExtendedProxyFileInfo EDAnnotator_ProxyFileInfo =
00390 {
00391     (PCInterfaceProxyVtblList *) & _EDAnnotator_ProxyVtblList,
00392     (PCInterfaceStubVtblList *) & _EDAnnotator_StubVtblList,
00393     (const PCInterfaceName * ) & _EDAnnotator_InterfaceNamesList,
00394     (const IID ** ) & _EDAnnotator_BaseIIDList,
00395     & _EDAnnotator_IID_Lookup,
00396     1,
00397     2,
00398     0, /* table of [async_uuid] interfaces */
00399     0, /* Filler1 */
00400     0, /* Filler2 */
00401     0  /* Filler3 */
00402 };
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/Deb/DebMisc.c Source File

  • WinBase
  • Debug
  • Deb

DebMisc.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00009
00010 *       This source code is only intended as a supplement to
00011 *       Microsoft Development Tools and/or WinHelp documentation.
00012 *       See these sources for detailed information regarding the
00013 *       Microsoft samples programs.
00014
00015 MODULE    : DEBMisc.C
00016 PURPOSE   : Miscellaneous support functions for the Debug Event Browser
00017 FUNCTIONS :
00018   StartDebuggee()               - starts a new debuggee process
00019   AttachToDebuggee()            - attaches to an existing process
00020   EnumProcessListFunc()         - enumeration func for active processes
00021   GetDebuggeeFileName()         - get the name of a debugee file to open
00022   ChooseNewFont()               - choose a new font
00023   ChooseNewBackColor()          - choose a new background color
00024   MakeCommonDebugEventString()  - create common debug event info string
00025   CreateTextButtonBar()         - create a text button bar
00026   CreateIconWindow()            - creates the icon window in the dialog
00027   GetPrivateProfileSettings()   - gets stored profile settings
00028   WritePrivateProfileSettings() - stores default settings in profile
00029   WritePrivateProfileInt()      - opposite of GetPrivateProfileInt()
00030   UpdateMenuSettings()          - update menu check marks
00031   OutOfMemoryMessageBox()       - displays an out of memory message box
00032   MaxDebuggeesMessageBox()      - displays max debuggees exceeded
00033   ErrorMessageBox()             - displays an error message box
00034   SubclassWindow()              - generic window subclass func
00035   SendWmSizeMessage()           - sends WM_SIZE with current size
00036   GetPathFromFullPathName()     - extracts path from a pathname
00037   CopyListBoxToClipboard()      - copies a listbox into the clipboard
00038   ListBoxInsert()               - insert a string into a listbox
00039   ListBoxPrintF()               - printf for listboxes
00040   StringPrintF()                - formats a string buffer
00041   StringAppendF()               - appends a formated string
00042 COMMENTS  :
00043
00044 \******************************************************************************/
00045 #define   STRICT               // enable strict typing
00046 #include <Windows.H>           // required for all Windows applications
00047 #include <stdio.h>
00048 #include <tchar.h>
00049 #include <strsafe.h>           // The Safe String Fuctions
00050 #include <CommDlg.H>           // GetOpenFileName(), ChooseFont(), etc.
00051 #include <Dlgs.H>              // templates and defines for the common dialogs
00052 #include <StdArg.H>            // va_list, va_start()
00053
00054 #include "LinkList.H"          //
00055 #include "ToolBar.H"           //
00056 #include "DEBMisc.H"           //
00057
00058
00059 // ************************************************************************
00060 // FUNCTION : StartDebuggee( LPTSTR, HWND )
00061 // PURPOSE  : starts a new debuggee process given a filename
00062 // COMMENTS :
00063 //   Return TRUE on success else FALSE.
00064 // ************************************************************************
00065 BOOL
00066 StartDebuggee( LPTSTR lpszDebuggeeFileName, HWND hWndListBox )
00067 {
00068   static PDEB_STARTUP_INFO pDebStartupInfo;
00069   static BOOL              fFirstTime = TRUE;
00070
00071   static TCHAR szDebuggeeTitle[128];
00072
00073   HANDLE hDebugEventThread;
00074   DWORD  idDebugEventThread;
00075
00076   //-- Load resource strings and init the OpenFileName struct
00077   //   (do this only one time)
00078   if( fFirstTime ) {
00079     fFirstTime = FALSE;
00080     LoadString( 0L, IDS_OFN_DEBUGGEE_TITLE, szDebuggeeTitle,
00081       sizeof(szDebuggeeTitle)/sizeof(TCHAR) );
00082   }
00083
00084   //-- allocate the Debuggee Information structure
00085   pDebStartupInfo = 0L;
00086   pDebStartupInfo = (PDEB_STARTUP_INFO) VirtualAlloc(
00087                                     pDebStartupInfo,
00088                                     sizeof( DEB_STARTUP_INFO ),
00089                                     MEM_RESERVE | MEM_COMMIT,
00090                                     PAGE_READWRITE );
00091
00092   //-- init the StartupInfo struct
00093   (pDebStartupInfo->StartupInfo).cb          = sizeof( STARTUPINFO );
00094   (pDebStartupInfo->StartupInfo).lpDesktop   = 0L;
00095   (pDebStartupInfo->StartupInfo).lpTitle     = szDebuggeeTitle;
00096   (pDebStartupInfo->StartupInfo).dwX         = 0;
00097   (pDebStartupInfo->StartupInfo).dwY         = 0;
00098   (pDebStartupInfo->StartupInfo).dwXSize     = 0;
00099   (pDebStartupInfo->StartupInfo).dwYSize     = 0;
00100   (pDebStartupInfo->StartupInfo).dwFlags     = 0L;
00101   (pDebStartupInfo->StartupInfo).wShowWindow = SW_SHOWDEFAULT;
00102
00103   (pDebStartupInfo->ProcessInfo).hProcess = 0L;
00104
00105   //-- init other debuggee info
00106   pDebStartupInfo->fActive       = FALSE;
00107   pDebStartupInfo->dwProcessId   = 0L;
00108   pDebStartupInfo->lpstrFileName = 0L;
00109   pDebStartupInfo->lpstrPathName = lpszDebuggeeFileName;
00110   pDebStartupInfo->hWndListBox   = hWndListBox;
00111
00112   //-- now start and detach the debug event processing thread
00113   if( !( hDebugEventThread = CreateThread(
00114                                (LPSECURITY_ATTRIBUTES) 0L,
00115                                (DWORD) 0,
00116                                (LPTHREAD_START_ROUTINE) DebugEventThread,
00117                                (LPVOID) pDebStartupInfo,
00118                                0L,
00119                                (LPDWORD) &idDebugEventThread) ) ) {
00120
00121     VirtualFree( pDebStartupInfo, 0, MEM_RELEASE );
00122     return( FALSE );
00123   }
00124   else{
00125     CloseHandle( hDebugEventThread );
00126   }
00127
00128   return( TRUE );
00129 }
00130
00131
00132 // ************************************************************************
00133 // FUNCTION : AttachToDebuggee( DWORD, HWND )
00134 // PURPOSE  : attaches to a currently running process
00135 // COMMENTS :
00136 //   Return TRUE on success else FALSE.
00137 // ************************************************************************
00138 BOOL
00139 AttachToDebuggee( DWORD dwProcessId, HWND hWndListBox )
00140 {
00141   static PDEB_STARTUP_INFO pDebStartupInfo;
00142   static BOOL              fFirstTime = TRUE;
00143
00144   static TCHAR szDebuggeeTitle[128];
00145
00146   HANDLE hDebugEventThread;
00147   DWORD  idDebugEventThread;
00148
00149   //-- Load resource strings and init the OpenFileName struct
00150   //   (do this only one time)
00151   if( fFirstTime ) {
00152     fFirstTime = FALSE;
00153     LoadString( 0L, IDS_OFN_DEBUGGEE_TITLE, szDebuggeeTitle,
00154       sizeof(szDebuggeeTitle)/sizeof(TCHAR) );
00155   }
00156
00157   //-- allocate the Debuggee Information structure
00158   pDebStartupInfo = 0L;
00159   pDebStartupInfo = (PDEB_STARTUP_INFO) VirtualAlloc(
00160                                     pDebStartupInfo,
00161                                     sizeof( DEB_STARTUP_INFO ),
00162                                     MEM_RESERVE | MEM_COMMIT,
00163                                     PAGE_READWRITE );
00164
00165   //-- init the StartupInfo struct
00166   (pDebStartupInfo->StartupInfo).cb          = sizeof( STARTUPINFO );
00167   (pDebStartupInfo->StartupInfo).lpDesktop   = 0L;
00168   (pDebStartupInfo->StartupInfo).lpTitle     = szDebuggeeTitle;
00169   (pDebStartupInfo->StartupInfo).dwX         = 0;
00170   (pDebStartupInfo->StartupInfo).dwY         = 0;
00171   (pDebStartupInfo->StartupInfo).dwXSize     = 0;
00172   (pDebStartupInfo->StartupInfo).dwYSize     = 0;
00173   (pDebStartupInfo->StartupInfo).dwFlags     = 0L;
00174   (pDebStartupInfo->StartupInfo).wShowWindow = SW_SHOWDEFAULT;
00175
00176   (pDebStartupInfo->ProcessInfo).hProcess = 0L;
00177
00178   //-- init other debuggee info
00179   pDebStartupInfo->fActive       = TRUE;
00180   pDebStartupInfo->dwProcessId   = dwProcessId;
00181   pDebStartupInfo->lpstrFileName = 0L;
00182   pDebStartupInfo->lpstrPathName = 0L;
00183   pDebStartupInfo->hWndListBox   = hWndListBox;
00184
00185   //-- now start and detach the debug event processing thread
00186   if( !( hDebugEventThread = CreateThread(
00187                                (LPSECURITY_ATTRIBUTES) 0L,
00188                                (DWORD) 0,
00189                                (LPTHREAD_START_ROUTINE) DebugEventThread,
00190                                (LPVOID) pDebStartupInfo,
00191                                0L,
00192                                (LPDWORD) &idDebugEventThread) ) ) {
00193
00194     VirtualFree( pDebStartupInfo, 0, MEM_RELEASE );
00195     return( FALSE );
00196   }
00197   else{
00198     CloseHandle( hDebugEventThread );
00199   }
00200
00201   return( TRUE );
00202 }
00203
00204
00205 // ************************************************************************
00206 // FUNCTION : EnumProcessListFunc( HWND, LPARAM )
00207 // PURPOSE  : Callback function for EnumWindows
00208 // COMMENTS : Inserts found window title strings into the listbox.
00209 //            Return !0L to continue enumeration.
00210 // ************************************************************************
00211 BOOL CALLBACK
00212 EnumProcessListFunc( HWND hWnd, LPARAM lParam )
00213 {
00214   static DWORD dwCurrentProcessId;
00215   static BOOL  fFirstTime = TRUE;
00216   static LONG  MaxStrLen  = 0;
00217   static TCHAR TextBuffer[256];
00218
00219   if( fFirstTime ) {
00220     fFirstTime = FALSE;
00221     dwCurrentProcessId = GetCurrentProcessId();
00222   }
00223
00224   if( hWnd ) {
00225     GetWindowText( hWnd, (LPTSTR) &TextBuffer, sizeof(TextBuffer)/sizeof(TCHAR) );
00226     if( *TextBuffer ) {
00227       DWORD  dwProcessId;
00228
00229       GetWindowThreadProcessId( hWnd, &dwProcessId );
00230       if( dwProcessId != dwCurrentProcessId ) {
00231         LRESULT Index;
00232         HWND hWndListBox = (HWND) lParam;
00233
00234         Index = ListBoxInsert( hWndListBox, &MaxStrLen, TextBuffer );
00235         SendMessage( hWndListBox, LB_SETITEMDATA, (WPARAM) Index,
00236           (LPARAM) dwProcessId );
00237       }
00238     }
00239   }
00240
00241   return( TRUE );
00242 }
00243
00244
00245 // ************************************************************************
00246 // FUNCTION : GetDebuggeeFileName( LPTSTR, HWND )
00247 // PURPOSE  : Get the name of a debugee file to open.
00248 // COMMENTS :
00249 //   Return TRUE on success else FALSE.
00250 // ************************************************************************
00251 BOOL
00252 GetDebuggeeFileName( LPTSTR lpszDebuggeeFileName, HWND hWnd )
00253 {
00254   static BOOL  fFirstTime = TRUE;
00255   static TCHAR szFilter[128]         = TEXT("");
00256   static TCHAR szTitle[64]           = TEXT("");
00257   static TCHAR szFileTitle[MAX_PATH] = TEXT("");
00258   static TCHAR szFile[MAX_PATH]      = TEXT("");
00259   static TCHAR szDefExt[8]           = TEXT("");
00260   static OPENFILENAME OpenFileName;
00261
00262   //-- Load resource strings and init the OpenFileName struct
00263   //   (do this only one time)
00264   if( fFirstTime ) {
00265     static UINT FilterNameLen;
00266
00267     fFirstTime = FALSE;
00268     FilterNameLen = (UINT) LoadString( 0L, IDS_OFN_FILTERNAME,
00269                              szFilter, sizeof(szFilter)/sizeof(TCHAR) );
00270     FilterNameLen++;
00271     LoadString( 0L, IDS_OFN_FILTER, &szFilter[FilterNameLen],
00272       sizeof(szFilter)/sizeof(TCHAR)-FilterNameLen );
00273     LoadString( 0L, IDS_OFN_TITLE, szTitle, sizeof(szTitle)/sizeof(TCHAR) );
00274
00275     OpenFileName.lStructSize       = sizeof(OPENFILENAME);
00276     OpenFileName.hwndOwner         = hWnd;
00277     OpenFileName.hInstance         = (HANDLE) 0L;
00278     OpenFileName.lpstrFilter       = szFilter;
00279     OpenFileName.lpstrCustomFilter = 0L;
00280     OpenFileName.nMaxCustFilter    = 0L;
00281     OpenFileName.nFilterIndex      = 1L;
00282     OpenFileName.lpstrFile         = szFile;
00283     OpenFileName.nMaxFile          = sizeof(szFile)/sizeof(TCHAR);
00284     OpenFileName.lpstrFileTitle    = szFileTitle;
00285     OpenFileName.nMaxFileTitle     = sizeof(szFileTitle)/sizeof(TCHAR);
00286     OpenFileName.lpstrInitialDir   = (Profile.fSavedDirectory ? Profile.szInitialDir : 0L);
00287     OpenFileName.lpstrTitle        = (LPTSTR) szTitle;
00288     OpenFileName.Flags             = OFN_HIDEREADONLY;
00289     OpenFileName.nFileOffset       = (WORD) 0L;
00290     OpenFileName.nFileExtension    = (WORD) 0L;
00291     OpenFileName.lpstrDefExt       = szDefExt;
00292     OpenFileName.lCustData         = 0L;
00293     OpenFileName.lpfnHook          = (LPOFNHOOKPROC) 0L;
00294     OpenFileName.lpTemplateName    = (LPTSTR) 0L;
00295   }
00296
00297   if( !GetOpenFileName( &OpenFileName ) ) {
00298     return( FALSE );
00299   }
00300
00301   //-- store recent directory by stripping off the EXE name from the full path
00302   GetPathFromFullPathName( (LPTSTR) OpenFileName.lpstrFile, Profile.szInitialDir,
00303     sizeof(Profile.szInitialDir)/sizeof(TCHAR) );
00304
00305   //-- copy name to return buffer
00306   lstrcpyn( lpszDebuggeeFileName, OpenFileName.lpstrFile, MAX_PATH );
00307
00308   return( TRUE );
00309 }
00310
00311
00312 // ************************************************************************
00313 // FUNCTION : ChooseFontHookProc(  )
00314 // PURPOSE  : Disable the Effects group and its contents
00315 // COMMENTS :
00316 // ************************************************************************
00317 LRESULT CALLBACK
00318 ChooseFontHookProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
00319 {
00320   UNREFERENCED_PARAMETER( lParam );
00321   UNREFERENCED_PARAMETER( wParam );
00322
00323   switch( uMsg ) {
00324
00325     case WM_INITDIALOG:
00326       ShowWindow( GetDlgItem(hDlg, grp1), SW_HIDE );
00327       ShowWindow( GetDlgItem(hDlg, chx1), SW_HIDE );
00328       ShowWindow( GetDlgItem(hDlg, chx2), SW_HIDE );
00329       break;
00330
00331   }
00332
00333   return( FALSE );
00334 }
00335
00336
00337 // ************************************************************************
00338 // FUNCTION : ChooseNewFont( HWND )
00339 // PURPOSE  : Choose a new font for a listbox
00340 // COMMENTS : Return TRUE on success else FALSE
00341 // ************************************************************************
00342 BOOL
00343 ChooseNewFont( HWND hWndListBox )
00344 {
00345   static CHOOSEFONT ChooseFontStruct;
00346   static BOOL       fFirstTime = TRUE;
00347   HFONT             hFont;
00348
00349   if( fFirstTime ) {
00350     fFirstTime = FALSE;
00351
00352     ChooseFontStruct.lStructSize    = sizeof( CHOOSEFONT );
00353     ChooseFontStruct.hwndOwner      = hWndListBox;
00354     ChooseFontStruct.hDC            = (HDC) 0L;
00355     ChooseFontStruct.lpLogFont      = &(Profile.LogFont);
00356     ChooseFontStruct.iPointSize     = (INT) 0L;
00357     ChooseFontStruct.Flags          = CF_INITTOLOGFONTSTRUCT |
00358                                       CF_SCREENFONTS | CF_EFFECTS |
00359                                       CF_ENABLEHOOK;
00360     ChooseFontStruct.rgbColors      = Profile.rgbForeColor;
00361     ChooseFontStruct.lCustData      = 0L;
00362     ChooseFontStruct.lpfnHook       = (LPCFHOOKPROC) ChooseFontHookProc;
00363     ChooseFontStruct.lpTemplateName = (LPTSTR) 0L;
00364     ChooseFontStruct.hInstance      = (HANDLE) 0L;
00365     ChooseFontStruct.lpszStyle      = (LPTSTR) 0L;
00366     ChooseFontStruct.nFontType      = SCREEN_FONTTYPE;
00367     ChooseFontStruct.nSizeMin       = (INT) 0L;
00368     ChooseFontStruct.nSizeMax       = (INT) 0L;
00369   }
00370
00371   if( ChooseFont( &ChooseFontStruct ) ) {
00372     HDC    hDC;
00373
00374     hFont = CreateFontIndirect( &(Profile.LogFont) );
00375     hDC = GetDC( hWndListBox );
00376     SelectObject( hDC, hFont );
00377     Profile.rgbForeColor = ChooseFontStruct.rgbColors;
00378     InvalidateRect( hWndListBox, 0L, TRUE );
00379     SendMessage( hWndListBox, WM_CTLCOLORLISTBOX, (DWORD_PTR) hDC,
00380       (LONG_PTR) hWndListBox );
00381     SendMessage( hWndListBox, WM_SETFONT, (DWORD_PTR) hFont, TRUE );
00382     ReleaseDC( hWndListBox, hDC );
00383   }
00384
00385   return( TRUE );
00386 }
00387
00388
00389 // ************************************************************************
00390 // FUNCTION : ChooseNewBackColor( HWND )
00391 // PURPOSE  : Choose the background color for a listbox
00392 // COMMENTS : Return TRUE on success else FALSE
00393 // ************************************************************************
00394 BOOL
00395 ChooseNewBackColor( HWND hWndListBox )
00396 {
00397   static BOOL        fFirstTime = TRUE;
00398   static CHOOSECOLOR ChooseColorStruct;
00399   static DWORD       dwCustColors[16];
00400
00401   if( fFirstTime ) {
00402     int i;
00403
00404     fFirstTime = FALSE;
00405
00406     //-- set the custom colors to white
00407     for( i = 0; i < 16; i++ )
00408       dwCustColors[i] = RGB(255,255,255);
00409
00410     ChooseColorStruct.lStructSize    = sizeof( CHOOSECOLOR );
00411     ChooseColorStruct.hwndOwner      = hWndListBox;
00412     ChooseColorStruct.hInstance      = (HANDLE) 0L;
00413     ChooseColorStruct.rgbResult      = Profile.rgbBackColor;
00414     ChooseColorStruct.lpCustColors   = (LPDWORD) dwCustColors;
00415     ChooseColorStruct.Flags          = CC_RGBINIT;
00416     ChooseColorStruct.lCustData      = 0L;
00417     ChooseColorStruct.lpfnHook       = (LPCCHOOKPROC) 0L;
00418     ChooseColorStruct.lpTemplateName = (LPTSTR) 0L;
00419   }
00420
00421   if( ChooseColor( &ChooseColorStruct ) ) {
00422     HDC    hDC;
00423
00424     Profile.rgbBackColor = (COLORREF) ChooseColorStruct.rgbResult;
00425     hDC = GetDC( hWndListBox );
00426     SendMessage( hWndListBox, WM_CTLCOLORLISTBOX, (DWORD_PTR) hDC,
00427       (LONG_PTR) hWndListBox );
00428     ReleaseDC( hWndListBox, hDC );
00429     InvalidateRect( hWndListBox, 0L, TRUE );
00430   }
00431
00432   return( TRUE );
00433 }
00434
00435
00436 // ************************************************************************
00437 // FUNCTION : MakeCommonDebugEventString( LPTSTR, DWORD, LPDEBUG_EVENT )
00438 // PURPOSE  : Fill in the Debug Event information into a string buffer
00439 // COMMENTS : The string buffer contains the information common to all
00440 //            debug events ( PID, TID ).
00441 // ************************************************************************
00442 BOOL
00443 MakeCommonDebugEventString( LPTSTR lpszBuffer, DWORD cchBuffer, LPDEBUG_EVENT lpDebugEvent )
00444 {
00445   StringPrintF( lpszBuffer, cchBuffer, TEXT( "PID:0x%X \t TID:0x%X \t " ),
00446     lpDebugEvent->dwProcessId, lpDebugEvent->dwThreadId );
00447
00448   return( TRUE );
00449 }
00450
00451
00452 // ************************************************************************
00453 // FUNCTION : CreateTextButtonBar( HWND, LPINT )
00454 // PURPOSE  : Creates a Text Button Bar from the resource strings.
00455 // COMMENTS : Returns window handle to the created text button bar
00456 // ************************************************************************
00457 HWND
00458 CreateTextButtonBar( HWND hWndParent, LPINT lpTextButtonBarHeight )
00459 {
00460   TEXTBUTTON   TextButton[9];
00461   static TCHAR szButtonOpen[32];
00462   static TCHAR szButtonAttach[32];
00463   static TCHAR szButtonCut[32];
00464   static TCHAR szButtonCopy[32];
00465   static TCHAR szButtonDelete[32];
00466   static TCHAR szButtonHelp[32];
00467
00468   LoadString( 0L, IDS_BUTTON_OPEN,   szButtonOpen,   sizeof(szButtonOpen)/sizeof(TCHAR)   );
00469   LoadString( 0L, IDS_BUTTON_ATTACH, szButtonAttach, sizeof(szButtonAttach)/sizeof(TCHAR) );
00470   LoadString( 0L, IDS_BUTTON_CUT,    szButtonCut,    sizeof(szButtonCut)/sizeof(TCHAR)    );
00471   LoadString( 0L, IDS_BUTTON_COPY,   szButtonCopy,   sizeof(szButtonCopy)/sizeof(TCHAR)   );
00472   LoadString( 0L, IDS_BUTTON_DELETE, szButtonDelete, sizeof(szButtonDelete)/sizeof(TCHAR) );
00473   LoadString( 0L, IDS_BUTTON_HELP,   szButtonHelp,   sizeof(szButtonHelp)/sizeof(TCHAR)   );
00474
00475   TextButton[0].lpButtonText = szButtonOpen;
00476   TextButton[0].idButton     = IDM_FILE_OPEN;
00477   TextButton[0].hWndButton   = 0L;
00478
00479   TextButton[1].lpButtonText = szButtonAttach;
00480   TextButton[1].idButton     = IDM_FILE_ATTACH;
00481   TextButton[1].hWndButton   = 0L;
00482
00483   TextButton[2].lpButtonText = 0L;
00484   TextButton[2].idButton     = TB_SPACE;
00485   TextButton[2].hWndButton   = 0L;
00486
00487   TextButton[3].lpButtonText = szButtonCut;
00488   TextButton[3].idButton     = IDM_EDIT_CUT;
00489   TextButton[3].hWndButton   = 0L;
00490
00491   TextButton[4].lpButtonText = szButtonCopy;
00492   TextButton[4].idButton     = IDM_EDIT_COPY;
00493   TextButton[4].hWndButton   = 0L;
00494
00495   TextButton[5].lpButtonText = szButtonDelete;
00496   TextButton[5].idButton     = IDM_EDIT_DELETE;
00497   TextButton[5].hWndButton   = 0L;
00498
00499   TextButton[6].lpButtonText = 0L;
00500   TextButton[6].idButton     = TB_SPACE;
00501   TextButton[6].hWndButton   = 0L;
00502
00503   TextButton[7].lpButtonText = szButtonHelp;
00504   TextButton[7].idButton     = IDM_HELP_CONTENTS;
00505   TextButton[7].hWndButton   = 0L;
00506
00507   TextButton[8].lpButtonText = (LPTSTR) 0L;
00508   TextButton[8].idButton     = (INT)   0L;
00509   TextButton[8].hWndButton   = (HWND)  0L;
00510
00511   return( TextButtonBar( hWndParent, TextButton, lpTextButtonBarHeight ) );
00512 }
00513
00514
00515 // ************************************************************************
00516 // FUNCTION : CreateIconWindow( HWND, LPCTSTR )
00517 // PURPOSE  :
00518 // COMMENTS :
00519 // ************************************************************************
00520 HWND
00521 CreateIconWindow( HWND hDlg, LPCTSTR lpstrIcon )
00522 {
00523   return ( CreateWindow( TEXT( "static" ), lpstrIcon,
00524              WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_ICON,
00525              7, 5, 0, 0,
00526              hDlg, 0L, GetModuleHandle( 0L ), 0L ) );
00527 }
00528
00529
00530 // ************************************************************************
00531 // FUNCTION : GetPrivateProfileSettings( LPCTSTR, LPCTSTR, PPROFILE )
00532 // PURPOSE  : Retrieves the stored preferences and options from the
00533 //            profile (registry)
00534 // COMMENTS :
00535 // ************************************************************************
00536 BOOL
00537 GetPrivateProfileSettings( LPCTSTR lpszAppTitle, LPCTSTR lpszIniPathName,
00538   PPROFILE pProfile )
00539 {
00540   pProfile->xPos       = (INT) GetPrivateProfileInt(  lpszAppTitle, TEXT( "xPos" ),       CW_USEDEFAULT, lpszIniPathName );
00541   pProfile->yPos       = (INT) GetPrivateProfileInt(  lpszAppTitle, TEXT( "yPos" ),       CW_USEDEFAULT, lpszIniPathName );
00542   pProfile->nWidth     = (INT) GetPrivateProfileInt(  lpszAppTitle, TEXT( "nWidth" ),     CW_USEDEFAULT, lpszIniPathName );
00543   pProfile->nHeight    = (INT) GetPrivateProfileInt(  lpszAppTitle, TEXT( "nHeight" ),    CW_USEDEFAULT, lpszIniPathName );
00544   pProfile->fMaximized = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fMaximized" ), (INT) FALSE,   lpszIniPathName );
00545   pProfile->fMinimized = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fMinimized" ), (INT) FALSE,   lpszIniPathName );
00546
00547   pProfile->fToolBar         = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fToolBar" ),         (INT) TRUE,  lpszIniPathName );
00548   pProfile->fSavedDirectory  = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fSavedDirectory" ),  (INT) TRUE,  lpszIniPathName );
00549   GetPrivateProfileString( lpszAppTitle, TEXT( "szInitialDir" ), 0L, pProfile->szInitialDir,
00550     sizeof( pProfile->szInitialDir )/sizeof(TCHAR), lpszIniPathName );
00551
00552   pProfile->LogFont.lfHeight         = (LONG) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfHeight" ),         (INT) 13   ,       lpszIniPathName );
00553   pProfile->LogFont.lfWidth          = (LONG) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfWidth" ),          (INT) 0    ,       lpszIniPathName );
00554   pProfile->LogFont.lfWeight         = (LONG) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfWeight" ),         (INT) 400  ,       lpszIniPathName );
00555   pProfile->LogFont.lfItalic         = (BYTE) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfItalic" ),         (INT) FALSE,       lpszIniPathName );
00556   pProfile->LogFont.lfUnderline      = (BYTE) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfUnderline" ),      (INT) FALSE,       lpszIniPathName );
00557   pProfile->LogFont.lfStrikeOut      = (BYTE) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfStrikeOut" ),      (INT) FALSE,       lpszIniPathName );
00558   pProfile->LogFont.lfPitchAndFamily = (BYTE) GetPrivateProfileInt( lpszAppTitle, TEXT( "lfPitchAndFamily" ), (INT) FF_DONTCARE, lpszIniPathName );
00559   GetPrivateProfileString( lpszAppTitle, TEXT( "lfFaceName" ), TEXT( "System" ), pProfile->LogFont.lfFaceName,
00560     LF_FACESIZE, lpszIniPathName );
00561   pProfile->rgbForeColor = (COLORREF) GetPrivateProfileInt( lpszAppTitle, TEXT( "rgbForeColor" ),
00562                             (INT) GetSysColor(COLOR_WINDOWTEXT), lpszIniPathName );
00563   pProfile->rgbBackColor = (COLORREF) GetPrivateProfileInt( lpszAppTitle, TEXT( "rgbBackColor" ),
00564                             (INT) GetSysColor(COLOR_WINDOW), lpszIniPathName );
00565
00566   pProfile->fClearOnNew      = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fClearOnNew" ),      (INT) TRUE,  lpszIniPathName );
00567   pProfile->fVerbose         = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fVerbose" ),         (INT) FALSE, lpszIniPathName );
00568   pProfile->fShowSymbols     = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fShowSymbols" ),     (INT) FALSE, lpszIniPathName );
00569   pProfile->DebugMode        = (LONG) GetPrivateProfileInt( lpszAppTitle, TEXT( "DebugMode" ),        (INT) DEBUG_PROCESS        , lpszIniPathName );
00570   pProfile->DebuggeePriority = (LONG) GetPrivateProfileInt( lpszAppTitle, TEXT( "DebuggeePriority" ), (INT) NORMAL_PRIORITY_CLASS, lpszIniPathName );
00571   pProfile->DebugErrorLevel  = (DWORD) GetPrivateProfileInt( lpszAppTitle, TEXT( "DebugErrorLevel" ), (INT) 0, lpszIniPathName );
00572   pProfile->fSavePreferences = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fSavePreferences" ), (INT) FALSE, lpszIniPathName );
00573
00574   pProfile->fSaveOnExit      = (BOOL) GetPrivateProfileInt( lpszAppTitle, TEXT( "fSaveOnExit" ),      (INT) TRUE,  lpszIniPathName );
00575
00576   return( TRUE );
00577 }
00578
00579
00580 // ************************************************************************
00581 // FUNCTION : WritePrivateProfileSettings( LPCTSTR, LPCTSTR, PPROFILE )
00582 // PURPOSE  : Saves the preferences and options to the profile (registry)
00583 // COMMENTS :
00584 // ************************************************************************
00585 BOOL
00586 WritePrivateProfileSettings( LPCTSTR lpszAppTitle, LPCTSTR lpszIniPathName,
00587   PPROFILE pProfile )
00588 {
00589   if( pProfile->fSaveOnExit ) {
00590     WritePrivateProfileInt( lpszAppTitle, TEXT( "xPos" ),       (INT) pProfile->xPos,       lpszIniPathName );
00591     WritePrivateProfileInt( lpszAppTitle, TEXT( "yPos" ),       (INT) pProfile->yPos,       lpszIniPathName );
00592     WritePrivateProfileInt( lpszAppTitle, TEXT( "nWidth" ),     (INT) pProfile->nWidth,     lpszIniPathName );
00593     WritePrivateProfileInt( lpszAppTitle, TEXT( "nHeight" ),    (INT) pProfile->nHeight,    lpszIniPathName );
00594     WritePrivateProfileInt( lpszAppTitle, TEXT( "fMaximized" ), (INT) pProfile->fMaximized, lpszIniPathName );
00595     WritePrivateProfileInt( lpszAppTitle, TEXT( "fMinimized" ), (INT) pProfile->fMinimized, lpszIniPathName );
00596
00597     WritePrivateProfileInt( lpszAppTitle, TEXT( "fToolBar" ),         (INT) pProfile->fToolBar,         lpszIniPathName );
00598     WritePrivateProfileInt( lpszAppTitle, TEXT( "fSavedDirectory" ),  (INT) pProfile->fSavedDirectory,  lpszIniPathName );
00599     WritePrivateProfileString( lpszAppTitle, TEXT( "szInitialDir" ), pProfile->szInitialDir, lpszIniPathName );
00600
00601     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfHeight" ),         (INT) pProfile->LogFont.lfHeight,         lpszIniPathName );
00602     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfWidth" ),          (INT) pProfile->LogFont.lfWidth,          lpszIniPathName );
00603     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfWeight" ),         (INT) pProfile->LogFont.lfWeight,         lpszIniPathName );
00604     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfItalic" ),         (INT) pProfile->LogFont.lfItalic,         lpszIniPathName );
00605     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfUnderline" ),      (INT) pProfile->LogFont.lfUnderline,      lpszIniPathName );
00606     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfStrikeOut" ),      (INT) pProfile->LogFont.lfStrikeOut,      lpszIniPathName );
00607     WritePrivateProfileInt( lpszAppTitle, TEXT( "lfPitchAndFamily" ), (INT) pProfile->LogFont.lfPitchAndFamily, lpszIniPathName );
00608     WritePrivateProfileString( lpszAppTitle, TEXT( "lfFaceName" ), pProfile->LogFont.lfFaceName, lpszIniPathName );
00609     WritePrivateProfileInt( lpszAppTitle, TEXT( "rgbForeColor" ), (INT) pProfile->rgbForeColor, lpszIniPathName );
00610     WritePrivateProfileInt( lpszAppTitle, TEXT( "rgbBackColor" ), (INT) pProfile->rgbBackColor, lpszIniPathName );
00611
00612     if( pProfile->fSavePreferences ) {
00613       WritePrivateProfileInt( lpszAppTitle, TEXT( "fClearOnNew" ),  (INT) pProfile->fClearOnNew,  lpszIniPathName );
00614       WritePrivateProfileInt( lpszAppTitle, TEXT( "fVerbose" ),     (INT) pProfile->fVerbose,     lpszIniPathName );
00615       WritePrivateProfileInt( lpszAppTitle, TEXT( "fShowSymbols" ), (INT) pProfile->fShowSymbols, lpszIniPathName );
00616       WritePrivateProfileInt( lpszAppTitle, TEXT( "DebugMode" ),        (INT) pProfile->DebugMode,        lpszIniPathName );
00617       WritePrivateProfileInt( lpszAppTitle, TEXT( "DebuggeePriority" ), (INT) pProfile->DebuggeePriority, lpszIniPathName );
00618       WritePrivateProfileInt( lpszAppTitle, TEXT( "DebugErrorLevel" ), (INT) pProfile->DebugErrorLevel, lpszIniPathName );
00619     }
00620     WritePrivateProfileInt( lpszAppTitle, TEXT( "fSavePreferences" ), (INT) pProfile->fSavePreferences, lpszIniPathName );
00621   }
00622   WritePrivateProfileInt( lpszAppTitle, TEXT( "fSaveOnExit" ), (INT) pProfile->fSaveOnExit, lpszIniPathName );
00623
00624   return( TRUE );
00625 }
00626
00627
00628 // ************************************************************************
00629 // FUNCTION: WritePrivateProfileInt( LPCTSTR, LPCTSTR, INT, LPCTSTR )
00630 // PURPOSE : Writes the value of an integer from a specified keyname within
00631 //           a specified section of the Private Profile
00632 // COMMENTS: Matched pair to GetPrivateProfileInt
00633 // ************************************************************************
00634 BOOL
00635 WritePrivateProfileInt( LPCTSTR lpAppName, LPCTSTR lpKeyName, INT Value, LPCTSTR lpFileName )
00636 {
00637   TCHAR ValBuf[16];
00638
00639   StringCbPrintf( ValBuf,sizeof(ValBuf) ,TEXT( "%i" ), Value);
00640
00641   return( WritePrivateProfileString( lpAppName, lpKeyName, ValBuf, lpFileName ) );
00642 }
00643
00644
00645 // ************************************************************************
00646 // FUNCTION : UpdateMenuSettings( HWND )
00647 // PURPOSE  : Adds check marks to active menu items
00648 // COMMENTS :
00649 // ************************************************************************
00650 BOOL
00651 UpdateMenuSettings( HWND hWnd )
00652 {
00653   if( Profile.fToolBar )
00654     CheckMenuItem( GetMenu(hWnd), IDM_OPTIONS_TOOLBAR, MF_CHECKED );
00655   if( Profile.fSavedDirectory )
00656     CheckMenuItem( GetMenu(hWnd), IDM_OPTIONS_SAVEDDIR, MF_CHECKED );
00657   if( Profile.fSaveOnExit )
00658     CheckMenuItem( GetMenu(hWnd), IDM_OPTIONS_SAVEONEXIT, MF_CHECKED );
00659
00660   return( TRUE );
00661 }
00662
00663
00664 // ************************************************************************
00665 // FUNCTION : OutOfMemoryMessageBox( HWND )
00666 // PURPOSE  : If called, displays an "Out of Memory" message box
00667 // COMMENTS :
00668 // ************************************************************************
00669 BOOL
00670 OutOfMemoryMessageBox( HWND hWndOwner )
00671 {
00672   MessageBox(
00673     hWndOwner,
00674     TEXT( "Out of Memory" ),
00675     TEXT( "Memory Error" ),
00676     MB_ICONSTOP | MB_APPLMODAL );
00677
00678   return( TRUE );
00679 }
00680
00681
00682 // ************************************************************************
00683 // FUNCTION : MaxDebuggeesMessageBox( HWND )
00684 // PURPOSE  : If called, displays an "Max Debuggees" message box
00685 // COMMENTS :
00686 // ************************************************************************
00687 BOOL
00688 MaxDebuggeesMessageBox( HWND hWndOwner )
00689 {
00690   MessageBox( hWndOwner,
00691     TEXT( "This build of the Debug Event Browser\n" )
00692     TEXT( "is limited to debugging only one debuggee\n" )
00693     TEXT( "at a time." ),
00694     TEXT( "Cannot Open Debuggee" ),
00695     MB_OK | MB_ICONEXCLAMATION );
00696
00697   return( TRUE );
00698 }
00699
00700
00701 // ========================================================================
00702 // helper functions
00703 // ========================================================================
00704
00705
00706 // ************************************************************************
00707 // FUNCTION : ErrorMessageBox( LPCTSTR, LPCTSTR, LPCTSTR, INT )
00708 // PURPOSE  : Displays an error message box with various error information
00709 //            and allows the user to terminate or continue the process.
00710 //            For a Win32 Application, GetLastError and FormatMessage are
00711 //            used to retrieve the last API error code and error message.
00712 // COMMENTS :
00713 // ************************************************************************
00714 BOOL
00715 ErrorMessageBox( LPCTSTR lpszText, LPCTSTR lpszTitle, LPCTSTR lpszFile,
00716   INT Line )
00717 {
00718   #define ERROR_BUFFER_SIZE 512
00719
00720   static TCHAR Format[] =
00721     TEXT( "%s\n\n"                                  )
00722     TEXT( "-- Error Information --\n"               )
00723     TEXT( "File : %s\n"                             )
00724     TEXT( "Line : %d\n"                             )
00725     TEXT( "Error Number : %d\n"                     )
00726     TEXT( "Error Message : %s\n"                    )
00727     TEXT( "\n"                                      )
00728     TEXT( "Press OK to terminate this application." );
00729
00730   LPTSTR lpFormatMessageBuffer;
00731   DWORD  dwFormatMessage;
00732   DWORD  dwGetLastError;
00733   HLOCAL hMessageBoxBuffer;
00734   LPVOID lpMessageBoxBuffer;
00735
00736   //-- perform a simple check on the needed buffer size
00737   if( lstrlen(lpszText) > (ERROR_BUFFER_SIZE - lstrlen(Format)) )
00738     return( FALSE );
00739
00740   //-- allocate the message box buffer
00741   hMessageBoxBuffer  = LocalAlloc( LMEM_MOVEABLE, ERROR_BUFFER_SIZE );
00742   lpMessageBoxBuffer = LocalLock( hMessageBoxBuffer );
00743
00744   //-- get the system error and system error message
00745   dwGetLastError = GetLastError();
00746   dwFormatMessage = FormatMessage(
00747                       FORMAT_MESSAGE_ALLOCATE_BUFFER
00748                       | FORMAT_MESSAGE_FROM_SYSTEM,
00749                       0L, dwGetLastError, LANG_NEUTRAL,
00750                       (LPTSTR) &lpFormatMessageBuffer, 0, 0L );
00751   if( !dwFormatMessage )
00752     lpFormatMessageBuffer = TEXT("FormatMessage() failed!");
00753
00754   //-- format the error messge box string
00755   if (StringCbPrintf( lpMessageBoxBuffer, sizeof(lpMessageBoxBuffer), Format, lpszText, lpszFile, Line,
00756         dwGetLastError, lpFormatMessageBuffer ) > 0)
00757   {
00758     // -- display the error and allow the user to terminate or continue
00759     if( MessageBox( 0L, lpMessageBoxBuffer, lpszTitle,
00760           MB_APPLMODAL | MB_ICONSTOP | MB_OKCANCEL )
00761       == IDOK )
00762       ExitProcess( 0 );
00763   }
00764
00765   //-- free all buffers
00766   if( dwFormatMessage )
00767     LocalFree( (HLOCAL) lpFormatMessageBuffer );
00768   LocalFree( (HLOCAL) hMessageBoxBuffer );
00769
00770   return( TRUE );
00771 }
00772
00773
00774
00775 // ************************************************************************
00776 // FUNCTION : SubclassWindow( HWND, WNDPROC )
00777 // PURPOSE  : Subclasses a window procedure
00778 // COMMENTS : Returns the old window procedure
00779 // ************************************************************************
00780 WNDPROC
00781 SubclassWindow( HWND hWnd, WNDPROC NewWndProc)
00782 {
00783   WNDPROC OldWndProc;
00784
00785   OldWndProc = (WNDPROC) GetWindowLongPtr( hWnd, GWLP_WNDPROC );
00786   SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR) NewWndProc );
00787
00788   return OldWndProc;
00789 }
00790
00791
00792 // ************************************************************************
00793 // FUNCTION : SendWmSizeMessage( HWND )
00794 // PURPOSE  : Sends a WM_SIZE message containing the current size
00795 // COMMENTS : Forces a WM_SIZE message without actually changing the size
00796 // ************************************************************************
00797 LRESULT
00798 SendWmSizeMessage( HWND hWnd )
00799 {
00800   RECT Rect;
00801
00802   if( !GetClientRect( hWnd, &Rect ) )
00803     return( FALSE );
00804
00805   return( SendMessage( hWnd, WM_SIZE, SIZENORMAL,
00806             MAKELONG( Rect.right - Rect.left, Rect.bottom - Rect.top) ) );
00807 }
00808
00809
00810 // ************************************************************************
00811 // FUNCTION : GetPathFromFullPathName( LPCTSTR, LPTSTR, UINT )
00812 // PURPOSE  : Extracts the path given a full pathname
00813 // COMMENTS :
00814 // ************************************************************************
00815 UINT
00816 GetPathFromFullPathName( LPCTSTR lpFullPathName, LPTSTR lpPathBuffer,
00817   UINT nPathBufferLength )
00818 {
00819   UINT nLength;
00820   int i, j;
00821
00822   if( (nLength = (UINT) lstrlen( lpFullPathName ) ) >= nPathBufferLength )
00823     return( nLength );
00824
00825   StringCbCopy( lpPathBuffer, sizeof(lpPathBuffer), lpFullPathName );
00826
00827   for( j = 0, i = nLength; (UINT)j < nLength;
00828                   j += IsDBCSLeadByte(lpPathBuffer[j]) ? 2 : 1){
00829       if( lpPathBuffer[j] == '\\' || lpPathBuffer[j] == ':' ){
00830           i = j;
00831       }
00832   }
00833   if( lpPathBuffer[i] == ':' )
00834     lpPathBuffer[i+1] = '\0';
00835   else
00836     lpPathBuffer[i] = '\0';
00837
00838   return( (UINT) i );
00839 }
00840
00841
00842 // ************************************************************************
00843 // FUNCTION : CopyListBoxToClipboard( HWND, LONG )
00844 // PURPOSE  : Copies the entire contents of a listbox into the clipboard.
00845 // COMMENTS : Returns TRUE on success, FALSE otherwise
00846 // ************************************************************************
00847 BOOL
00848 CopyListBoxToClipboard( HWND hWndListBox, LONG MaxStrLen )
00849 {
00850   LPTSTR  lpDataBuffer;
00851   HGLOBAL hDataBuffer;
00852
00853   TCHAR  TempBuffer[256];
00854   DWORD  dwItemCount;
00855   DWORD  Count;
00856   LRESULT   StrLen;
00857   DWORD  dwMemSize;
00858
00859   dwItemCount = (DWORD) SendMessage( hWndListBox, LB_GETCOUNT, 0 , 0 );
00860   dwMemSize = dwItemCount * (DWORD) MaxStrLen;
00861
00862   //-- limit the size copied to the clipboard
00863   if( dwMemSize > 0xFFFFF )
00864     dwMemSize = 0xFFFFF;
00865
00866   if( !(hDataBuffer = GlobalAlloc( GMEM_DDESHARE, dwMemSize ) ) ) {
00867     OutOfMemoryMessageBox( GetFocus() );
00868     return( FALSE );
00869   }
00870   if( !(lpDataBuffer = (LPTSTR) GlobalLock( hDataBuffer ) ) ) {
00871     GlobalFree( hDataBuffer );
00872     OutOfMemoryMessageBox( GetFocus() );
00873     return( FALSE );
00874   }
00875
00876   *lpDataBuffer = '\0';
00877
00878   for( Count = 0; Count < dwItemCount; Count++ ) {
00879     StrLen = SendMessage( hWndListBox, LB_GETTEXTLEN, Count, 0L );
00880     if( StrLen > (sizeof(TempBuffer)/sizeof(TCHAR)-3) )
00881       continue;
00882     if( lstrlen(lpDataBuffer) + StrLen > (dwMemSize/sizeof(TCHAR)-3))
00883         break;
00884     StrLen = SendMessage( hWndListBox, LB_GETTEXT, Count, (LPARAM) TempBuffer );
00885     TempBuffer[StrLen]   = '\r';
00886     TempBuffer[StrLen+1] = '\n';
00887     TempBuffer[StrLen+2] = '\0';
00888     StringCbCat( lpDataBuffer, sizeof(lpDataBuffer),TempBuffer );
00889   }
00890
00891   GlobalUnlock( hDataBuffer );
00892
00893   if( !OpenClipboard( hWndListBox ) ) {
00894     Sleep( 250 );  // wait a quarter second and try again.
00895     if( !OpenClipboard( hWndListBox ) ) {
00896       MessageBox( GetFocus(),
00897         TEXT( "Could not open the Clipboard!" ),
00898         TEXT( "Cannot Open Clipboard" ),
00899         MB_ICONSTOP | MB_APPLMODAL );
00900       GlobalFree( hDataBuffer );
00901       return( FALSE );
00902     }
00903   }
00904   if( !EmptyClipboard() ) {
00905     MessageBox( GetFocus(),
00906       TEXT( "Could not empty the Clipboard!" ),
00907       TEXT( "Cannot Empty Clipboard" ),
00908       MB_ICONSTOP | MB_APPLMODAL );
00909     GlobalFree( hDataBuffer );
00910     return( FALSE );
00911   }
00912   if( !SetClipboardData( CF_TEXT, hDataBuffer ) ) {
00913     MessageBox( GetFocus(),
00914       TEXT( "Could not copy data to the Clipboard!" ),
00915       TEXT( "Cannot Set Clipboard Data" ),
00916       MB_ICONSTOP | MB_APPLMODAL );
00917     GlobalFree( hDataBuffer );
00918     return( FALSE );
00919   }
00920   CloseClipboard();
00921
00922   return( TRUE );
00923 }
00924
00925
00926 // ************************************************************************
00927 // FUNCTION : ListBoxInsert( HWND, LPLONG, LPCTSTR )
00928 // PURPOSE  : Inserts the string into the listbox.
00929 // COMMENTS : Returns the index of the string inserted
00930 // ************************************************************************
00931 LRESULT
00932 ListBoxInsert( HWND hWndListBox, LPLONG lpMaxStrLen, LPCTSTR lpszString )
00933 {
00934   static LONG MaxTextExtent = 0;
00935
00936   LRESULT     Index;
00937
00938   if( lpszString == 0L ) {
00939     MaxTextExtent = 0;
00940     SendMessage( hWndListBox, LB_SETHORIZONTALEXTENT, 0, 0 );
00941     return( 0 );
00942   }
00943
00944   if( hWndListBox != 0L ) {
00945     HDC  hDC;
00946     SIZE Size;
00947     LONG StrLen;
00948
00949     if( (StrLen = lstrlen( lpszString)) > *lpMaxStrLen )
00950       *lpMaxStrLen = StrLen;
00951     hDC = GetDC( hWndListBox );
00952     GetTextExtentPoint( hDC, lpszString, StrLen, &Size );
00953     ReleaseDC( hWndListBox, hDC );
00954     if( Size.cx > MaxTextExtent ) {
00955       MaxTextExtent = Size.cx;
00956       SendMessage( hWndListBox, LB_SETHORIZONTALEXTENT, (WPARAM) (MaxTextExtent*1.1), 0 );
00957     }
00958     Index = SendMessage( hWndListBox, LB_ADDSTRING, 0, (LPARAM) lpszString );
00959     SendMessage( hWndListBox, LB_SETCURSEL, Index, 0 );
00960   }
00961
00962   return( Index );
00963 }
00964
00965
00966 // ************************************************************************
00967 // FUNCTION : ListBoxPrintF( HWND, LPCTSTR, ... )
00968 // PURPOSE  : Inserts the string format into the listbox.
00969 // COMMENTS : Returns the index of the last string inserted
00970 // ************************************************************************
00971 LRESULT
00972 ListBoxPrintF( HWND hWndListBox, LPCTSTR szFormat, ... )
00973 {
00974   static TCHAR szBuffer[ 1024 ];
00975
00976   va_list  valist;
00977   LRESULT  Index;
00978   LPTSTR   lpCurrentString, lpCurrentChar;
00979
00980   va_start( valist, szFormat );
00981   StringCchVPrintf( szBuffer, sizeof(szBuffer)/sizeof(TCHAR), szFormat, valist );
00982   szBuffer[sizeof(szBuffer)/sizeof(TCHAR) - 1] = 0;
00983   va_end( valist );
00984
00985   //-- insert strings line-by-line
00986   for( lpCurrentString = lpCurrentChar = szBuffer; *lpCurrentChar != '\0'; ) {
00987     if( *lpCurrentChar == '\n' ) {
00988       LPTSTR lpNextChar = CharNext( lpCurrentChar );
00989       *lpCurrentChar = '\0';
00990       Index = ListBoxInsert( hWndListBox, &(Global.MaxStrLen), lpCurrentString );
00991       lpCurrentString = lpCurrentChar = lpNextChar;
00992     }
00993     else
00994       lpCurrentChar = CharNext( lpCurrentChar );
00995   }
00996   Index = ListBoxInsert( hWndListBox, &(Global.MaxStrLen), lpCurrentString );
00997
00998   return( Index );
00999 }
01000
01001
01002 // ************************************************************************
01003 // FUNCTION : StringPrintF( LPTSTR, DWORD, LPCTSTR, ... )
01004 // PURPOSE  : Formats a string buffer according to the format-control
01005 //            string.  This function is wsprintf but the return
01006 //            values is a pointer to the string instead of the count.
01007 // COMMENTS :
01008 // ************************************************************************
01009 LPTSTR
01010 StringPrintF( LPTSTR lpString, DWORD cchString, LPCTSTR szFormat, ...  )
01011 {
01012   va_list valist;
01013
01014   va_start( valist, szFormat );
01015   StringCchVPrintf( lpString, cchString, szFormat, valist );
01016   lpString[cchString - 1] = 0;
01017   va_end( valist );
01018
01019   return( lpString );
01020 }
01021
01022
01023 // ************************************************************************
01024 // FUNCTION : StringAppendF( LPTSTR, DWORD, LPCTSTR, ... )
01025 // PURPOSE  : Append a variable number of characters and values to the end
01026 //            of an existing string buffer according to the format string
01027 //            (which uses standard printf() formating notation).
01028 // COMMENTS :
01029 // ************************************************************************
01030 BOOL
01031 StringAppendF( LPTSTR lpszBuffer, DWORD cchBuffer, LPCTSTR szFormat, ... )
01032 {
01033   static TCHAR szLgBuffer[1024];
01034
01035   va_list valist;
01036   int n, cur, left;
01037
01038   //-- add event specific information
01039   va_start( valist, szFormat );
01040   n = StringCchVPrintf( szLgBuffer, sizeof(szLgBuffer)/sizeof(TCHAR),
01041                    szFormat, valist );
01042   if (n < 1)
01043   {
01044       szLgBuffer[sizeof(szLgBuffer)/sizeof(TCHAR) - 1] = 0;
01045       n = sizeof(szLgBuffer)/sizeof(TCHAR);
01046   }
01047   va_end( valist );
01048
01049   //-- append information to the string buffer
01050   cur = lstrlen(lpszBuffer);
01051   left = (int)cchBuffer - cur;
01052   if (n > left)
01053   {
01054       n = left;
01055   }
01056   lstrcpyn( lpszBuffer + cur, szLgBuffer, n );
01057
01058   return( TRUE );
01059 }
Generated on Wed Nov 13 2024 16:52:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCShip2/StdAfx.Cpp Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCShip2

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/IpxChat.c Source File

  • NetDS
  • WinSock
  • IpxChat

IpxChat.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   ipxchat.c
00009 //
00010 //  PURPOSE:   Implement the windows procedure for the main application
00011 //    windows.  Also implement the generic message and command dispatchers.
00012 //
00013 //  FUNCTIONS:
00014 //    WndProc           - Processes messages for the main window.
00015 //    MsgCreate         - Initializes Edit Controls for text input/output.
00016 //    MsgSize           - Adjusts size of Edit Controls when window is resized.
00017 //    MsgSetfocus       - Keeps window focus on edit control instead of parent.
00018 //    MsgDataready      - Reads data from incoming IPC mechanism.
00019 //    MsgRefreshdisplay - Refills Inbox edit control text contents
00020 //    MsgDisconnected   - Cleans up connection killed by other side
00021 //    MsgCommand        - Handle the WM_COMMAND messages for the main window.
00022 //    MsgDestroy        - Handles the WM_DESTROY message by calling
00023 //                        PostQuitMessage().
00024 //    CmdOutbox         - Handles messages from Outbox edit control.
00025 //    CmdDisconnected   - Disconnects current connection
00026 //    CmdExit           - Handles the file exit command by calling destroy
00027 //                        window on the main window.
00028 //
00029 //  COMMENTS:
00030 //
00031
00032 #include "globals.h"            // prototypes specific to this application
00033 #include <windows.h>            // required for all Windows applications
00034 #include <windowsx.h>
00035
00036
00037
00038
00039 // Main window message table definition.
00040 MSD rgmsd[] =
00041 {
00042     {WM_CREATE,         MsgCreate},
00043     {WM_SIZE,           MsgSize},
00044     {WM_SETFOCUS,       MsgSetfocus},
00045     {WM_COMMAND,        MsgCommand},
00046     {WM_DESTROY,        MsgDestroy},
00047     {MW_DATAREADY,      MsgDataready},
00048     {MW_DISCONNECTED,   MsgDisconnected},
00049     {MW_DISPLAYREFRESH, MsgRefreshdisplay}
00050 };
00051
00052 MSDI msdiMain =
00053 {
00054     sizeof(rgmsd) / sizeof(MSD),
00055     rgmsd,
00056     edwpWindow
00057 };
00058
00059
00060 // Main window command table definition.
00061 CMD rgcmd[] =
00062 {
00063     {IDM_CONNECT,    CmdConnect},
00064     {IDM_LISTEN,     CmdListen},
00065     {IDM_EXIT,       CmdExit},
00066     {IDM_ABOUT,      CmdAbout},
00067     {ID_OUTBOX,      CmdOutbox},
00068     {IDM_DISCONNECT, CmdDisconnect}
00069 };
00070
00071 CMDI cmdiMain =
00072 {
00073     sizeof(rgcmd) / sizeof(CMD),
00074     rgcmd,
00075     edwpWindow
00076 };
00077
00078
00079 //
00080 //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
00081 //
00082 //  PURPOSE:  Processes messages for the main window.
00083 //
00084 //  PARAMETERS:
00085 //    hwnd     - window handle
00086 //    uMessage - message number
00087 //    wparam   - additional information (dependant on message number)
00088 //    lparam   - additional information (dependant on message number)
00089 //
00090 //  RETURN VALUE:
00091 //    The return value depends on the message number.  If the message
00092 //    is implemented in the message dispatch table, the return value is
00093 //    the value returned by the message handling function.  Otherwise,
00094 //    the return value is the value returned by the default window procedure.
00095 //
00096 //  COMMENTS:
00097 //    Call the DispMessage() function with the main window's message dispatch
00098 //    information (msdiMain) and the message specific information.
00099 //
00100
00101 LRESULT CALLBACK WndProc(HWND   hwnd,
00102                          UINT   uMessage,
00103                          WPARAM wparam,
00104                          LPARAM lparam)
00105 {
00106     return DispMessage(&msdiMain, hwnd, uMessage, wparam, lparam);
00107 }
00108
00109 //
00110 //  FUNCTION: MsgCreate(HWND, UINT, WPARAM, LPARAM)
00111 //
00112 //  PURPOSE: Creates Inbox and Outbox Edit controls
00113 //
00114 //  PARAMETERS:
00115 //
00116 //    hwnd      - Window handle
00117 //    uMessage  - Message number (Unused)
00118 //    wparam    - Extra data     (Unused)
00119 //    lparam    - Extra data     (Unused)
00120 //
00121 //  RETURN VALUE:
00122 //
00123 //    Always returns 0 - Message handled
00124 //
00125 //  COMMENTS:
00126 //
00127 //
00128
00129 LRESULT MsgCreate(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00130 {
00131     // Create Edit control for typing to be sent to server
00132     if (NULL == (hOutWnd = CreateWindow("EDIT",
00133                            NULL,
00134                            WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |
00135                            ES_MULTILINE | ES_AUTOVSCROLL,
00136                            0,0,0,0,
00137                            hwnd,
00138                            (HMENU) ID_OUTBOX,
00139                            (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE),
00140                            0)))
00141         return FALSE;
00142     // Create Edit control for typing to be received from server
00143     if (NULL == (hInWnd = CreateWindow("EDIT",
00144                           NULL,
00145                           WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |
00146                           ES_MULTILINE | ES_AUTOVSCROLL,
00147                           0,0,0,0,
00148                           hwnd,
00149                           (HMENU) ID_INBOX,
00150                           (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE),
00151                           0)))
00152         return FALSE;
00153
00154     return TRUE;
00155 }
00156
00157 //
00158 //  FUNCTION: MsgSize(HWND, UINT, WPARAM, LPARAM)
00159 //
00160 //  PURPOSE: Adjust Size of Inbox and Outbox Edit controls
00161 //
00162 //  PARAMETERS:
00163 //
00164 //    hwnd      - Window handle
00165 //    uMessage  - Message number (Unused)
00166 //    wparam    - Extra data     (Unused)
00167 //    lparam    - Parent Window Size
00168 //
00169 //  RETURN VALUE:
00170 //
00171 //    Always returns 0 - Message handled
00172 //
00173 //  COMMENTS:
00174 //
00175 //
00176
00177 LRESULT MsgSize(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00178 {
00179     // Size OutBox Edit Control
00180     if (FALSE == MoveWindow(hOutWnd,
00181                1,1,                    // Upper Left Corner
00182                LOWORD(lparam) - 2,         // Width of Parent Window
00183                (HIWORD(lparam) / 2) - 2 ,     // Half the height of Parent
00184                TRUE))                  // repaint
00185         return FALSE;
00186
00187     // Size Inbox Edit Control
00188     if(FALSE == MoveWindow(hInWnd,
00189                1, (HIWORD(lparam) / 2) + 1,  // Half Way down right side
00190                LOWORD(lparam) - 2,         // Width of Parent Window
00191                (HIWORD(lparam) / 2) - 2,      // Half the height of Parent
00192                TRUE))                  // repaint
00193         return FALSE;
00194
00195     return TRUE;
00196 }
00197
00198 //
00199 //  FUNCTION: MsgSetfocus(HWND, UINT, WPARAM, LPARAM)
00200 //
00201 //  PURPOSE: Keeps Window focus on edit control
00202 //
00203 //  PARAMETERS:
00204 //
00205 //    hwnd      - Window handle
00206 //    uMessage  - Message number (Unused)
00207 //    wparam    - Extra data     (Unused)
00208 //    lparam    - Extra data     (Unused)
00209 //
00210 //  RETURN VALUE:
00211 //
00212 //    Always returns 0 - Message handled
00213 //
00214 //  COMMENTS:
00215 //
00216 //
00217
00218 LRESULT MsgSetfocus(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00219 {
00220     if(NULL == SetFocus(hOutWnd))  // Don't let main window have focus
00221         return FALSE;
00222
00223     return TRUE;
00224 }
00225
00226 //
00227 //  FUNCTION: MsgDataready(HWND, UINT, WPARAM, LPARAM)
00228 //
00229 //  PURPOSE: Read data and post message to display data
00230 //
00231 //  PARAMETERS:
00232 //
00233 //    hwnd      - Window handle
00234 //    uMessage  - Message number (Unused)
00235 //    wparam    - forwarded to ReceiveInBox
00236 //    lparam    - forwarded to ReceiveInBox
00237 //
00238 //  RETURN VALUE:
00239 //
00240 //    Always returns 0 - Message handled
00241 //
00242 //  COMMENTS:
00243 //
00244 //
00245
00246 LRESULT MsgDataready(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00247 {
00248     // Call protocol specific program to Read data and put in szRcvBuf
00249     if(ReceiveInBox(hwnd, wparam, lparam, szRcvBuf, sizeof(szRcvBuf)))
00250     {
00251         PostMessage(hwnd, MW_DISPLAYREFRESH, 0, 0);
00252     }
00253     return TRUE;
00254 }
00255 //
00256 //  FUNCTION: MsgRefreshdisplay(HWND, UINT, WPARAM, LPARAM)
00257 //
00258 //  PURPOSE: Display socket data in inbox
00259 //
00260 //  PARAMETERS:
00261 //
00262 //    hwnd      - Window handle
00263 //    uMessage  - Message number (Unused)
00264 //    wparam    - Extra Data     (Unused)
00265 //    lparam    - Extra Data     (Unused)
00266 //
00267 //  RETURN VALUE:
00268 //
00269 //    Always returns 0 - Message handled
00270 //
00271 //  COMMENTS:
00272 //
00273 //
00274
00275 LRESULT MsgRefreshdisplay(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00276 {
00277     MSG peekmsg;
00278
00279     // Don't bother displaying if there is already another update queued
00280     if(PeekMessage(&peekmsg, hwnd, MW_DATAREADY, MW_DISPLAYREFRESH, PM_NOREMOVE))
00281     {
00282        return TRUE;
00283     }
00284     // Put data in szRcvBuf in InBox
00285     SendDlgItemMessage(hwnd,
00286                        ID_INBOX,
00287                        EM_SETSEL,
00288                        0,-1);
00289     SendDlgItemMessage(hwnd,
00290                        ID_INBOX,
00291                        EM_REPLACESEL,
00292                        0,
00293                        (LPARAM)szRcvBuf);
00294     return TRUE;
00295 }
00296
00297 //
00298 //  FUNCTION: MsgDisconnected(HWND, UINT, WPARAM, LPARAM)
00299 //
00300 //  PURPOSE: Cleanup connection dropped from other side
00301 //
00302 //  PARAMETERS:
00303 //
00304 //    hwnd      - Window handle
00305 //    uMessage  - Message number (Unused)
00306 //    wparam    - Extra data     (Unused)
00307 //    lparam    - Extra data     (Unused)
00308 //
00309 //  RETURN VALUE:
00310 //
00311 //    Always returns 0 - Message handled
00312 //
00313 //  COMMENTS:
00314 //
00315 //
00316
00317 LRESULT MsgDisconnected(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00318 {
00319     HMENU hmenu;
00320
00321     // Let the user know
00322     MessageBox(hwnd,
00323                "Connection Disconnected",
00324                "Chat Dialog Stopped",
00325                MB_OK);
00326     // Protocol Specific Cleanup
00327     CleanUp();
00328     // Fix menus
00329     if(NULL == (hmenu = GetMenu(hwnd)))
00330         return FALSE;
00331     if(FALSE == EnableMenuItem(hmenu, IDM_CONNECT, MF_ENABLED))
00332         return FALSE;
00333     if(FALSE == EnableMenuItem(hmenu, IDM_LISTEN, MF_ENABLED))
00334         return FALSE;
00335     if(FALSE == EnableMenuItem(hmenu, IDM_DISCONNECT, MF_GRAYED))
00336         return FALSE;
00337     if(FALSE == SetWindowText(hwnd, szTitle))
00338         return FALSE;
00339
00340     return TRUE;
00341 }
00342
00343 //
00344 //  FUNCTION: MsgCommand(HWND, UINT, WPARAM, LPARAM)
00345 //
00346 //  PURPOSE: Handle the WM_COMMAND messages for the main window.
00347 //
00348 //  PARAMETERS:
00349 //    hwnd     - window handle
00350 //    uMessage - WM_COMMAND (Unused)
00351 //    GET_WM_COMMAND_ID(wparam, lparam)   - Command identifier
00352 //    GET_WM_COMMAND_HWND(wparam, lparam) - Control handle
00353 //
00354 //  RETURN VALUE:
00355 //    The return value depends on the message number.  If the message
00356 //    is implemented in the message dispatch table, the return value is
00357 //    the value returned by the message handling function.  Otherwise,
00358 //    the return value is the value returned by the default window procedure.
00359 //
00360 //  COMMENTS:
00361 //    Call the DispCommand() function with the main window's command dispatch
00362 //    information (cmdiMain) and the command specific information.
00363 //
00364
00365 LRESULT MsgCommand(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00366 {
00367     return DispCommand(&cmdiMain, hwnd, wparam, lparam);
00368 }
00369
00370
00371 //
00372 //  FUNCTION: MsgDestroy(HWND, UINT, WPARAM, LPARAM)
00373 //
00374 //  PURPOSE: Calls PostQuitMessage().
00375 //
00376 //  PARAMETERS:
00377 //
00378 //    hwnd      - Window handle  (Unused)
00379 //    uMessage  - Message number (Unused)
00380 //    wparam    - Extra data     (Unused)
00381 //    lparam    - Extra data     (Unused)
00382 //
00383 //  RETURN VALUE:
00384 //
00385 //    Always returns 0 - Message handled
00386 //
00387 //  COMMENTS:
00388 //
00389 //
00390
00391 LRESULT MsgDestroy(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
00392 {
00393     PostQuitMessage(0);
00394     return 0;
00395 }
00396
00397 //
00398 //  FUNCTION: CmdOutbox(HWND, WORD, WORD, HWND)
00399 //
00400 //  PURPOSE: Handle messages from Outbox--Send data if EN_CHANGE
00401 //
00402 //  PARAMETERS:
00403 //    hwnd     - The window.
00404 //    wCommand - ID_OUTBOX (unused)
00405 //    wNotify  - Notification number (unused)
00406 //    hwndCtrl - NULL (unused)
00407 //
00408 //  RETURN VALUE:
00409 //    Always returns 0 - command handled.
00410 //
00411 //  COMMENTS:
00412 //
00413 //
00414
00415 LRESULT CmdOutbox(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00416 {
00417     int cSendLen;
00418
00419     if (wNotify != EN_CHANGE)  // We only care if text has changed
00420     {
00421         return 0;
00422     }
00423     // Text has changed!  Put OutBox's text in szSndBuf
00424     cSendLen = GetDlgItemText(hwnd,
00425                               ID_OUTBOX,
00426                               szSndBuf,
00427                               sizeof(szSndBuf));
00428
00429     // Do protocol specific send
00430     SendOutBox(szSndBuf, cSendLen);
00431     return 0;
00432 }
00433
00434 //
00435 //  FUNCTION: CmdDisconnect(HWND, WORD, WORD, HWND)
00436 //
00437 //  PURPOSE: Cut off session and fix menus appropriately
00438 //
00439 //  PARAMETERS:
00440 //    hwnd     - The window.
00441 //    wCommand - ID_OUTBOX (unused)
00442 //    wNotify  - Notification number (unused)
00443 //    hwndCtrl - NULL (unused)
00444 //
00445 //  RETURN VALUE:
00446 //    Always returns 0 - command handled.
00447 //
00448 //  COMMENTS:
00449 //
00450 //
00451
00452 LRESULT CmdDisconnect(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00453 {
00454     HMENU hmenu;
00455
00456     // Protocol Specific cleanup
00457     CleanUp();
00458
00459     // Fix menus
00460     if(NULL == (hmenu = GetMenu(hwnd)))
00461         return 1;
00462     if(FALSE == EnableMenuItem(hmenu, IDM_CONNECT, MF_ENABLED))
00463         return 1;
00464     if(FALSE == EnableMenuItem(hmenu, IDM_LISTEN, MF_ENABLED))
00465         return 1;
00466     if(FALSE == EnableMenuItem(hmenu, IDM_DISCONNECT, MF_GRAYED))
00467         return 1;
00468     if(FALSE == SetWindowText(hwnd, szTitle))
00469         return 1;
00470
00471     return 0;
00472 }
00473
00474 //
00475 //  FUNCTION: CmdExit(HWND, WORD, WORD, HWND)
00476 //
00477 //  PURPOSE: Exit the application.
00478 //
00479 //  PARAMETERS:
00480 //    hwnd     - The window.
00481 //    wCommand - IDM_EXIT            (unused)
00482 //    wNotify  - Notification number (unused)
00483 //    hwndCtrl - NULL                (unused)
00484 //
00485 //  RETURN VALUE:
00486 //    Always returns 0 - command handled.
00487 //
00488 //  COMMENTS:
00489 //
00490 //
00491
00492 LRESULT CmdExit(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00493 {
00494     if(FALSE == DestroyWindow(hwnd))
00495         return 1;
00496
00497     return 0;
00498 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_EAPCB Member List

This is the complete list of members for _EAPCB, including all inherited members.
aszIdentity | _EAPCB
aszPassword | _EAPCB
bRecvPacketId | _EAPCB
dwIdExpected | _EAPCB
dwInitialPacketId | _EAPCB
dwResult | _EAPCB
dwSizeOfDataFromInteractiveUI | _EAPCB
EapState | _EAPCB
fAuthenticator | _EAPCB
fFlags | _EAPCB
pDataFromInteractiveUI | _EAPCB
pMPPEKeyAttributes | _EAPCB
pUIContext | _EAPCB
pUserAttributes | _EAPCB
pWorkBuffer | _EAPCB
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/CallBackClient/callbackclient.h Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • CallBackClient

callbackclient.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: CallBackClient.h
00004
00005 Summary:  Declaration of CCallBack
00006
00007 ----------------------------------------------------------------------------
00008
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021
00022 ==========================================================================+*/
00023
00024 #ifndef __CALLBACKCLIENT_H_
00025 #define __CALLBACKCLIENT_H_
00026
00027 #include "FullSvr_i.c"
00028
00029 HRESULT WINAPI QueryFunc(void*,REFIID,LPVOID*,DWORD_PTR); //forward decl
00030
00031 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00032   Class:       CCallBack
00033   Summary:     this COM object cannot be created externally, and is used only
00034          to recieve a call back on completion of a non-blocking method
00035          call
00036   Interfaces:  ISynchronize
00037   Aggregation: Supported
00038 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00039 class ATL_NO_VTABLE CCallBack :
00040   public CComObjectRootEx<CComSingleThreadModel>,
00041   public ISynchronize
00042 {
00043 public:
00044   CCallBack()
00045   {
00046     m_pCallObjUnk = NULL;
00047   }
00048
00049   HRESULT FinalConstruct(){
00050     //Create contained sync object
00051     return CoCreateInstance(CLSID_ManualResetEvent,NULL,CLSCTX_INPROC_SERVER,IID_ISynchronize,(void**)&smartPtrISynchronize.p);
00052   }
00053
00054   HRESULT FinalRelease(){
00055     //Release the call object
00056     if(m_pCallObjUnk) m_pCallObjUnk->Release();
00057     return S_OK;
00058   }
00059
00060 DECLARE_GET_CONTROLLING_UNKNOWN();
00061
00062 DECLARE_AGGREGATABLE(CCallBack);
00063
00064 DECLARE_PROTECT_FINAL_CONSTRUCT()
00065
00066 BEGIN_COM_MAP(CCallBack)
00067   COM_INTERFACE_ENTRY(ISynchronize)
00068   COM_INTERFACE_ENTRY_FUNC_BLIND(0, QueryFunc )//Pass QI to QueryFunc
00069 END_COM_MAP()
00070
00071 private:
00072   CComPtr<ISynchronize> smartPtrISynchronize;//contained synch object
00073   IUnknown * m_pCallObjUnk;//Call objects IUnknown
00074
00075   STDMETHOD(CallBack)();
00076
00077 public:
00078
00079   STDMETHOD(StartCall)(int i, int j);
00080   STDMETHOD(MyQuery)(REFIID riid,LPVOID* ppv);
00081
00082 //ISynchronize
00083   STDMETHOD(Signal)();
00084   STDMETHOD(Reset)();
00085   STDMETHOD(Wait)(DWORD flags,DWORD timeout);
00086
00087
00088 };
00089
00090 #endif // __CALLBACKCLIENT_H
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/security/security.cpp Source File

  • SysMgmt
  • WMI
  • VC
  • security

security.cpp

Go to the documentation of this file.
00001 // **************************************************************************
00002 //
00003 // Copyright (c) Microsoft Corporation, All Rights Reserved
00004 //
00005 // File:  Security.cpp
00006 //
00007 // Description:
00008 //        WMI Client Security Sample.  This sample shows how various how to
00009 // handle various DCOM security issues.  In particular, it shows how to call
00010 // CoSetProxyBlanket in order to deal with common situations.  The sample also
00011 // shows how to access the security descriptors that wmi uses to control
00012 // namespace access. The sample also demonstrates how to use Credential Manager API for
00013 // password prompting: this functionality is only implemented on Windows XP and above.
00014 // Therefore, you will need to remove CredUI code to make the sample compile and build on Win2k.
00015 //
00016 // **************************************************************************
00017
00018 #include <objbase.h>
00019 #include <windows.h>
00020 #include <stdio.h>
00021 #include <wbemidl.h>
00022 #include <comdef.h>
00023 #include <wincred.h>
00024 #include <strsafe.h>
00025
00026 WCHAR wPath[MAX_PATH];
00027 WCHAR wServerName[MAX_PATH];
00028 WCHAR wNameSpace[MAX_PATH];
00029 WCHAR wFullUserName[CREDUI_MAX_USERNAME_LENGTH + 1];
00030 WCHAR wPassWord[CREDUI_MAX_PASSWORD_LENGTH + 1];
00031
00032 bool bPassWordSet = false;
00033 bool bUserNameSet = false;
00034
00035 void __stdcall _com_issue_error(HRESULT){}
00036
00037 //***************************************************************************
00038 //
00039 // DisplayOptions
00040 //
00041 // Purpose: Displays the command line options.
00042 //
00043 //***************************************************************************
00044
00045 void DisplayOptions()
00046 {
00047     printf("\nThis application demonstrates various DCOM security issues.  It \n"
00048             "will connect up to the namespace and enumerate the top level classes\n"
00049             "and will also dump the security descriptor used to control access to the namespace.\n\n"
00050       "usage: Security [-S:<Server>] -N:<WMINamespace>\n"
00051             "              -S:<Server>             Optional Server Name. If not provided, local machine is assumed\n"
00052             "              -N:<WMINamespace>       WMI Namespace name\n"
00053       "Example; c:>Security -S:serverName -N:root\\default\n"
00054             );
00055     return;
00056 }
00057
00058 //***************************************************************************
00059 //
00060 // ProcessArguments
00061 //
00062 // Purpose: Processes command line arguments.  Returns FALSE if there is a
00063 // problem, or if user just wants help.
00064 //
00065 //***************************************************************************
00066
00067 BOOL ProcessArguments(int iArgCnt, WCHAR ** argv)
00068 {
00069     if(iArgCnt < 2)
00070         return FALSE;
00071
00072     wPath[0] = 0;
00073     wFullUserName[0] = 0;
00074   memset(wServerName, NULL, sizeof(wServerName));
00075   memset(wNameSpace, NULL, sizeof(wNameSpace));
00076
00077     for(int iCnt = 1; iCnt <= iArgCnt-1 ; iCnt++)
00078     {
00079         WCHAR * pArg = argv[iCnt];
00080         if(pArg[0] != '-')
00081             return FALSE;
00082         switch (pArg[1])
00083         {
00084             case L's':
00085             case L'S':
00086                 StringCbCopyW(wServerName, sizeof(wServerName), pArg+3);
00087                 break;
00088             case L'n':
00089             case L'N':
00090                 StringCbCopyW(wNameSpace, sizeof(wNameSpace), pArg+3);
00091                 break;
00092             default:
00093                 return FALSE;
00094         }
00095     }
00096
00097     return TRUE;
00098 }
00099
00100 //***************************************************************************
00101 //
00102 // SetProxySecurity
00103 //
00104 // Purpose: Calls CoSetProxyBlanket in order to control the security on a
00105 // particular interface proxy.
00106 //
00107 //***************************************************************************
00108
00109 HRESULT SetProxySecurity(IUnknown * pProxy)
00110 {
00111     HRESULT hr;
00112     DWORD dwAuthnSvc, dwAuthzSvc ,dwAuthnLevel, dwImpLevel, dwCapabilities;
00113     RPC_AUTH_IDENTITY_HANDLE * pAuthInfo = NULL;
00114
00115     //  There are various reasons to set security.  An application that can
00116     //  call CoInitializeSecurity and doesnt use an alternative user\password,
00117     //  need not bother with call CoSetProxyBlanket.  There are at least
00118     //  three cases that do need it though.
00119     //
00120     //  1) Dlls cannot call CoInitializeSecurity and will need to call it just
00121     //     to raise the impersonation level.  This does NOT require that the
00122     //     RPC_AUTH_IDENTITY_HANDLE to be set nor does this require setting
00123     //     it on the IUnknown pointer.
00124     //  2) Any time that an alternative user\password are set as is the case
00125     //     in this simple sample.  Note that it is necessary in that case to
00126     //     also set the information on the IUnknown.
00127     //  3) If the caller has a thread token from a remote call to itself and
00128     //     it wants to use that identity.  That would be the case of an RPC/COM
00129     //     server which is handling a call from one of its clients and it wants
00130     //     to use the client's identity in calls to WMI.  In this case, then
00131     //     the RPC_AUTH_IDENTITY_HANDLE does not need to be set, but the
00132     //     dwCapabilities arguement should be set for cloaking.  This is also
00133     //     required for the IUnknown pointer.
00134
00135
00136     if(bPassWordSet == false && bUserNameSet == false)
00137     {
00138         // In this case, nothing needs to be done.  But for the sake of
00139         // example the code will set the impersonation level.
00140
00141         // For backwards compatibility, retrieve the previous authentication level, so
00142         // we can echo-back the value when we set the blanket
00143
00144         hr = CoQueryProxyBlanket(
00145             pProxy,           //Location for the proxy to query
00146             &dwAuthnSvc,      //Location for the current authentication service
00147             &dwAuthzSvc,      //Location for the current authorization service
00148             NULL,             //Location for the current principal name
00149             &dwAuthnLevel,    //Location for the current authentication level
00150             &dwImpLevel,      //Location for the current impersonation level
00151             NULL,             //Location for the value passed to IClientSecurity::SetBlanket
00152             &dwCapabilities   //Location for flags indicating further capabilities of the proxy
00153                 );
00154         if(FAILED(hr))
00155             return hr;
00156         hr = CoSetProxyBlanket(pProxy, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, COLE_DEFAULT_PRINCIPAL, dwAuthnLevel,
00157             RPC_C_IMP_LEVEL_IMPERSONATE, COLE_DEFAULT_AUTHINFO, EOAC_DEFAULT);
00158         return hr;
00159     }
00160     else
00161     {
00162         // The user\password was set, it is necessary to call CoSetProxyBlanket
00163
00164         COAUTHIDENTITY authident;
00165         pAuthInfo = NULL;
00166
00167         // For backwards compatibility, retrieve the previous authentication level, so
00168         // we can echo-back the value when we set the blanket
00169
00170         hr = CoQueryProxyBlanket(
00171             pProxy,           //Location for the proxy to query
00172             &dwAuthnSvc,      //Location for the current authentication service
00173             &dwAuthzSvc,      //Location for the current authorization service
00174             NULL,             //Location for the current principal name
00175             &dwAuthnLevel,    //Location for the current authentication level
00176             &dwImpLevel,      //Location for the current impersonation level
00177             NULL,             //Location for the value passed to IClientSecurity::SetBlanket
00178             &dwCapabilities   //Location for flags indicating further capabilities of the proxy
00179                 );
00180
00181         memset((void *)&authident,0,sizeof(COAUTHIDENTITY));
00182
00183         // note that this assumes NT.  Win9X would fill in the field with
00184         // ascii and then use SEC_WINNT_AUTH_IDENTITY_ANSI flag instead
00185
00186         WCHAR wUserName[ CREDUI_MAX_USERNAME_LENGTH + 1];
00187         WCHAR wDomainName[CRED_MAX_DOMAIN_TARGET_NAME_LENGTH + 1];
00188         memset(wUserName, NULL, sizeof(wUserName));
00189     memset(wDomainName, NULL, sizeof(wDomainName));
00190         bool bDomainNameSet = false;
00191
00192         if(bUserNameSet)
00193         {
00194
00195             // Note that the user name may be in the form domain\user.  If so, split it up
00196
00197       DWORD dwRes = CredUIParseUserNameW(wFullUserName,
00198         wUserName, sizeof(wUserName)/sizeof(WCHAR),
00199         wDomainName, sizeof(wDomainName)/sizeof(WCHAR));
00200
00201       if (dwRes != NO_ERROR)
00202       {
00203         printf ("Could not parse user name.\n");
00204         return E_FAIL;
00205       }
00206
00207             authident.UserLength = (ULONG)wcslen(wUserName);
00208             authident.User = (LPWSTR)wUserName;
00209
00210         }
00211         if(wcslen(wDomainName) > 0)
00212         {
00213             authident.DomainLength = (ULONG)wcslen(wDomainName);
00214             authident.Domain = (LPWSTR)wDomainName;
00215         }
00216         if(bPassWordSet)
00217         {
00218             authident.PasswordLength = (ULONG)wcslen(wPassWord);
00219             authident.Password = (LPWSTR)wPassWord;
00220         }
00221         authident.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
00222
00223
00224         hr = CoSetProxyBlanket(pProxy, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, COLE_DEFAULT_PRINCIPAL, dwAuthnLevel,
00225             RPC_C_IMP_LEVEL_IMPERSONATE, &authident, EOAC_DEFAULT);
00226         if(FAILED(hr))
00227             return hr;
00228
00229         // There is a remote IUnknown interface that lurks behind IUnknown.
00230         // If that is not set, then the Release call can return access denied.
00231
00232         IUnknown * pUnk = NULL;
00233         hr = pProxy->QueryInterface(IID_IUnknown, (void **)&pUnk);
00234         if(FAILED(hr))
00235             return hr;
00236         hr = CoSetProxyBlanket(pUnk, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, COLE_DEFAULT_PRINCIPAL, dwAuthnLevel,
00237             RPC_C_IMP_LEVEL_IMPERSONATE, &authident, EOAC_DEFAULT);
00238         pUnk->Release();
00239         return hr;
00240     }
00241 }
00242
00243 //***************************************************************************
00244 //
00245 // ListClasses
00246 //
00247 // Purpose: Lists the classes.
00248 //
00249 //***************************************************************************
00250
00251 void ListClasses(IWbemServices *pNamespace)
00252 {
00253     HRESULT hr;
00254     IEnumWbemClassObject *pEnum = NULL;
00255
00256     hr = pNamespace->CreateClassEnum(NULL, 0, NULL, &pEnum);
00257     if(SUCCEEDED(hr))
00258     {
00259
00260         // Note that even though security was set on the namespace pointer, it must
00261         // also be set on this pointer since COM will revert back to the default
00262         // settings for any new pointers!
00263
00264         hr = SetProxySecurity(pEnum);
00265         if(SUCCEEDED(hr))
00266         {
00267             IWbemClassObject* Array[1];
00268             Array[0] = NULL;
00269             ULONG uRet = 0;
00270             while (SUCCEEDED(hr = pEnum->Next(10000, 1, Array, &uRet)) && Array[0])
00271             {
00272                 // Note that IWbemClassObjects are inproc and thus have no proxy.
00273                 // Therefore, they never need CoSetProxyBlanket.
00274
00275                 BSTR strText;
00276                 IWbemClassObject* pObj = Array[0];
00277                 hr = pObj->GetObjectText(0, &strText);
00278
00279                 if(SUCCEEDED(hr) && strText)
00280                 {
00281                     printf("\nGot class %S", strText);
00282                     SysFreeString(strText);
00283                 }
00284                 pObj->Release();
00285                 Array[0] = NULL;
00286             }
00287         }
00288         else
00289             printf("\nFAILED TO SET SECURITY FOR ENUMERATOR!!!!! hr = 0x%x", hr);
00290         pEnum->Release();
00291     }
00292 }
00293
00294 //***************************************************************************
00295 //
00296 // DumpAce
00297 //
00298 // Purpose: Dumps information in an ACE. Note that this is simple cook book
00299 // code.  There are many available wrappers to do this sort of thing.
00300 //
00301 //***************************************************************************
00302
00303 void DumpAce(ACCESS_ALLOWED_ACE * pAce)
00304 {
00305     printf("\n Ace, type=0x%x, flags=0x%x, mask=0x%x",
00306         pAce->Header.AceType, pAce->Header.AceFlags, pAce->Mask);
00307
00308     PSID pSid = 0;
00309     SID_NAME_USE use;
00310     WCHAR wcUser[100], wcDomain[100];
00311     DWORD dwNameSize = sizeof(wcUser)/ sizeof(WCHAR);
00312   DWORD dwDomainSize =  sizeof(wcDomain)/ sizeof(WCHAR);
00313     pSid = &pAce->SidStart;
00314     if(LookupAccountSidW(
00315             NULL,              // name of local or remote computer
00316             pSid,              // security identifier
00317             wcUser,            // account name buffer
00318             &dwNameSize,       // size of account name buffer
00319             wcDomain,          // domain name
00320             &dwDomainSize,     // size of domain name buffer
00321             &use))
00322         printf(" User name = %S, Domain name = %S", wcUser, wcDomain);
00323 }
00324
00325 //***************************************************************************
00326 //
00327 // DumpSD
00328 //
00329 // Purpose: Dumps information in a security descriptor.  Note that this is
00330 // simple cook book code.  There are many available wrappers to do this sort
00331 // of thing.
00332 //
00333 //***************************************************************************
00334
00335 void DumpSD(PSECURITY_DESCRIPTOR pSD)
00336 {
00337     DWORD dwSize = GetSecurityDescriptorLength(pSD);
00338     printf("\nSecurity Descriptor is of size %d", dwSize);
00339
00340     BOOL DaclPresent, DaclDefaulted;
00341     PACL pDacl;
00342     if(GetSecurityDescriptorDacl(pSD, &DaclPresent,
00343                 &pDacl, &DaclDefaulted) && DaclPresent)
00344     {
00345
00346         // Dump the aces
00347
00348         ACL_SIZE_INFORMATION inf;
00349         DWORD dwNumAces;
00350         if(GetAclInformation(
00351             pDacl,
00352             &inf,
00353             sizeof(ACL_SIZE_INFORMATION),
00354             AclSizeInformation
00355             ))
00356         {
00357             dwNumAces = inf.AceCount;
00358             printf("\nThe DACL has %d ACEs", dwNumAces);
00359             for(DWORD dwCnt = 0; dwCnt < dwNumAces; dwCnt++)
00360             {
00361                 ACCESS_ALLOWED_ACE * pAce;
00362                 if(GetAce(pDacl, dwCnt, (LPVOID *)&pAce))
00363                     DumpAce(pAce);
00364             }
00365         }
00366     }
00367 }
00368
00369 //***************************************************************************
00370 //
00371 // StoreSD
00372 //
00373 // Purpose: Writes back the ACL which controls access to the namespace.
00374 //
00375 //***************************************************************************
00376
00377
00378 bool StoreSD(IWbemServices * pSession, PSECURITY_DESCRIPTOR pSD)
00379 {
00380     bool bRet = false;
00381     HRESULT hr;
00382
00383   if (!IsValidSecurityDescriptor(pSD))
00384     return false;
00385
00386     // Get the class object
00387
00388     IWbemClassObject * pClass = NULL;
00389     _bstr_t InstPath(L"__systemsecurity=@");
00390     _bstr_t ClassPath(L"__systemsecurity");
00391     hr = pSession->GetObject(ClassPath, 0, NULL, &pClass, NULL);
00392     if(FAILED(hr))
00393         return false;
00394
00395     // Get the input parameter class
00396
00397     _bstr_t MethName(L"SetSD");
00398     IWbemClassObject * pInClassSig = NULL;
00399     hr = pClass->GetMethod(MethName,0, &pInClassSig, NULL);
00400     pClass->Release();
00401     if(FAILED(hr))
00402         return false;
00403
00404     // spawn an instance of the input parameter class
00405
00406     IWbemClassObject * pInArg = NULL;
00407     pInClassSig->SpawnInstance(0, &pInArg);
00408     pInClassSig->Release();
00409     if(FAILED(hr))
00410         return false;
00411
00412
00413     // move the SD into a variant.
00414
00415     SAFEARRAY FAR* psa;
00416     SAFEARRAYBOUND rgsabound[1];    rgsabound[0].lLbound = 0;
00417     long lSize = GetSecurityDescriptorLength(pSD);
00418     rgsabound[0].cElements = lSize;
00419     psa = SafeArrayCreate( VT_UI1, 1 , rgsabound );
00420     if(psa == NULL)
00421     {
00422         pInArg->Release();
00423         return false;
00424     }
00425
00426     char * pData = NULL;
00427     hr = SafeArrayAccessData(psa, (void HUGEP* FAR*)&pData);
00428     if(FAILED(hr))
00429     {
00430         pInArg->Release();
00431         return false;
00432     }
00433
00434     memcpy(pData, pSD, lSize);
00435
00436     SafeArrayUnaccessData(psa);
00437     _variant_t var;
00438     var.vt = VT_I4|VT_ARRAY;
00439     var.parray = psa;
00440
00441     // put the property
00442
00443     hr = pInArg->Put(L"SD" , 0, &var, 0);
00444     if(FAILED(hr))
00445     {
00446         pInArg->Release();
00447         return false;
00448     }
00449
00450     // Execute the method
00451
00452     IWbemClassObject * pOutParams = NULL;
00453     hr = pSession->ExecMethod(InstPath,
00454             MethName,
00455             0,
00456             NULL, pInArg,
00457             NULL, NULL);
00458     if(FAILED(hr))
00459         printf("\nPut failed, returned 0x%x",hr);
00460
00461     return bRet;
00462 }
00463
00464 //***************************************************************************
00465 //
00466 // ReadACL
00467 //
00468 // Purpose: Reads the ACL which controls access to the namespace.
00469 //
00470 //***************************************************************************
00471
00472 bool ReadACL(IWbemServices *pNamespace)
00473 {
00474     bool bRet = false;
00475     _bstr_t InstPath(L"__systemsecurity=@");
00476     _bstr_t MethName(L"GetSD");
00477     IWbemClassObject * pOutParams = NULL;
00478
00479     // The security descriptor is returned via the GetSD method
00480
00481     HRESULT hr = pNamespace->ExecMethod(InstPath,
00482             MethName,
00483             0,
00484             NULL, NULL,
00485             &pOutParams, NULL);
00486     if(SUCCEEDED(hr))
00487     {
00488
00489         // The output parameters has a property which has the descriptor
00490
00491         _bstr_t prop(L"sd");
00492         _variant_t var;
00493         hr = pOutParams->Get(prop, 0, &var, NULL, NULL);
00494         if(SUCCEEDED(hr))
00495         {
00496             if(var.vt != (VT_ARRAY | VT_UI1))
00497                 return false;
00498             SAFEARRAY * psa = var.parray;
00499             PSECURITY_DESCRIPTOR pSD;
00500             hr = SafeArrayAccessData(psa, (void HUGEP* FAR*)&pSD);
00501             if(hr != 0)
00502                 return false;
00503
00504             // Dump out some information
00505
00506             DumpSD(pSD);
00507
00508             // Given that the security desciptor is now present, the code could use standard
00509             // nt functions to add or remove ace's.  There are also various libraries available
00510             // that can make the job a bit easier.  This sample does not change the security
00511             // descriptor, but does write it back unchanged as an example.
00512
00513             StoreSD(pNamespace, pSD);
00514             SafeArrayUnaccessData(psa);
00515             bRet = true;
00516         }
00517     }
00518     return bRet;
00519 }
00520
00521 //***************************************************************************
00522 //
00523 // main
00524 //
00525 // Purpose: Main entry point.
00526 //
00527 //***************************************************************************
00528
00529 BOOL g_bInProc = FALSE;
00530
00531 int wmain(int iArgCnt, WCHAR ** argv)
00532 {
00533
00534     if(!ProcessArguments(iArgCnt, argv))
00535     {
00536         DisplayOptions();
00537         return 1;
00538   }
00539
00540   if (wcslen(wServerName) > 0)
00541   {
00542
00543
00544     //prompt for credentials for a remote connection
00545
00546     DWORD dwRes = CredUICmdLinePromptForCredentialsW(
00547                   (const WCHAR *) wServerName, NULL, 0,
00548                   wFullUserName, sizeof(wFullUserName)/sizeof(WCHAR),
00549                   wPassWord, sizeof(wPassWord)/sizeof(WCHAR),
00550                   FALSE,
00551                   CREDUI_FLAGS_EXCLUDE_CERTIFICATES | CREDUI_FLAGS_DO_NOT_PERSIST );
00552
00553     if (dwRes != NO_ERROR)
00554     {
00555       printf("Failed to retrieve credentials: error %d. Using the default credentials.", dwRes);
00556     }
00557
00558     bUserNameSet = bPassWordSet = (dwRes == NO_ERROR);
00559
00560   }
00561   else
00562   {
00563     //no server name passed in, assume local
00564     StringCbCopyW(wServerName, sizeof(wPath), L".");
00565   }
00566
00567   StringCbCopyW(wPath, sizeof(wPath), L"\\\\");
00568   StringCbCatW(wPath, sizeof(wPath),  wServerName);
00569   StringCbCatW(wPath, sizeof(wPath),  L"\\");
00570   StringCbCatW(wPath, sizeof(wPath),  wNameSpace);
00571
00572     IWbemLocator *pLocator = NULL;
00573     IWbemServices *pNamespace = 0;
00574     IWbemClassObject * pClass = NULL;
00575
00576     // Initialize COM.
00577
00578     HRESULT hr = CoInitialize(0);
00579   if (FAILED(hr))
00580   {
00581       printf("\nCoInitialize returned 0x%x:", hr);
00582     return 1;
00583   }
00584
00585     // This sets the default impersonation level to "Impersonate" which is what WMI
00586   // providers will generally require.
00587     //
00588     // DLLs cannot call this function.  To bump up the impersonation level, they must
00589     // call CoSetProxyBlanket which is illustrated later on.
00590   //
00591   //  When using asynchronous WMI API's remotely in an environment where the "Local System" account
00592   //  has no network identity (such as non-Kerberos domains), the authentication level of
00593   //  RPC_C_AUTHN_LEVEL_NONE is needed. However, lowering the authentication level to
00594   //  RPC_C_AUTHN_LEVEL_NONE makes your application less secure. It is wise to
00595   //  use semi-synchronous API's for accessing WMI data and events instead of the asynchronous ones.
00596
00597     hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
00598                                 RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
00599                                 RPC_C_IMP_LEVEL_IMPERSONATE,
00600                                 NULL,
00601                 EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
00602                 0);
00603   if (FAILED(hr))
00604   {
00605       printf("\nCoInitializeSecurity returned 0x%x:", hr);
00606     return 1;
00607   }
00608
00609     hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
00610             IID_IWbemLocator, (LPVOID *) &pLocator);
00611
00612   if (FAILED(hr))
00613   {
00614       printf("\nCoCreateInstance for CLSID_WbemLocator returned 0x%x:", hr);
00615     return 1;
00616   }
00617
00618     hr = pLocator->ConnectServer(wPath,
00619                     (bUserNameSet) ? wFullUserName : NULL,
00620                     (bPassWordSet) ? wPassWord : NULL,
00621                     NULL, 0, NULL, NULL, &pNamespace);
00622     if(FAILED(hr))
00623     {
00624         wprintf(L"\nConnectServer  to %s failed, hr = 0x%x", wPath, hr);
00625     }
00626     else
00627     {
00628         printf("\nConnection succeeded");
00629         hr = SetProxySecurity(pNamespace);
00630         if(SUCCEEDED(hr))
00631         {
00632             ListClasses(pNamespace);
00633             ReadACL(pNamespace);
00634         }
00635         pNamespace->Release();
00636     }
00637     CoUninitialize();
00638     printf("\nTerminating normally");
00639     return 0;
00640 }
00641
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ColumnProvider/columnprovider.Cpp Source File

  • WinUI
  • Shell
  • ColumnProvider

columnprovider.Cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  ColumnProvider.cpp
00011 //
00012 //      Implementation of the CColumnProvider class.
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #include "ShortName.h"
00017 #include "ColumnProvider.h"
00018 #include "Resource.h"
00019
00020 #define NUM_COLUMNS 2
00021
00022 #define STR_FMTID_ShortFilename TEXT("{706005E1-0888-11D3-B1C2-00600893AD51}")
00023 GUID FMTID_ShortFilename = {0x706005E1, 0x0888, 0x11D3, {0xB1, 0xC2, 0x00, 0x60, 0x08, 0x93, 0xAD, 0x51}};
00024
00025 #define STR_FMTID_FullPath TEXT("{706005E2-0888-11D3-B1C2-00600893AD51}")
00026 GUID FMTID_FullPath = {0x706005E2, 0x0888, 0x11D3, {0xB1, 0xC2, 0x00, 0x60, 0x08, 0x93, 0xAD, 0x51}};
00027
00028 SHCOLUMNINFO sci[NUM_COLUMNS] =
00029 {
00030     {{0}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR | SHCOLSTATE_SECONDARYUI, TEXT("Short Filename"), TEXT("Displays the 8.3 filename.")},
00031     {{0}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR | SHCOLSTATE_SECONDARYUI, TEXT("Short Pathname"), TEXT("Displays the 8.3 pathname to the file or folder.")}
00032 };
00033
00034 //////////////////////////////////////////////////////////////////////
00035 // Construction/Destruction
00036 //////////////////////////////////////////////////////////////////////
00037
00038 CColumnProvider::CColumnProvider()
00039 {
00040     m_nRefCount = 0;
00041     nDllRefCount++;
00042
00043     sci[0].scid.fmtid = FMTID_ShortFilename;
00044     sci[1].scid.fmtid = FMTID_FullPath;
00045 }
00046
00047 CColumnProvider::~CColumnProvider()
00048 {
00049     nDllRefCount--;
00050 }
00051
00052
00053 //////////////////////////////////////////////////////////////////////
00054 //  IUnknown Methods
00055 //////////////////////////////////////////////////////////////////////
00056 STDMETHODIMP CColumnProvider::QueryInterface(REFIID riid, LPVOID *ppvObject)
00057 {
00058     HRESULT hr = E_NOINTERFACE;
00059
00060     *ppvObject = NULL;
00061     if (IsEqualIID (riid, IID_IUnknown) || IsEqualIID (riid, IID_IColumnProvider))
00062     {
00063         *ppvObject = (LPVOID)(LPCLASSFACTORY) this;
00064     }
00065
00066     if (*ppvObject != NULL)
00067     {
00068         ((LPUNKNOWN)*ppvObject)->AddRef ();
00069         hr = S_OK;
00070     }
00071     return hr;
00072 }
00073
00074 STDMETHODIMP_(ULONG) CColumnProvider::AddRef()
00075 {
00076     m_nRefCount++;
00077     return m_nRefCount;
00078 }
00079
00080 STDMETHODIMP_(ULONG) CColumnProvider::Release()
00081 {
00082     if (--m_nRefCount == 0)
00083     {
00084         delete this;
00085         return 0;
00086     }
00087     return m_nRefCount;
00088 }
00089
00090
00091 //////////////////////////////////////////////////////////////////////
00092 //  IColumnProvider Methods
00093 //////////////////////////////////////////////////////////////////////
00094 STDMETHODIMP CColumnProvider::Initialize (LPCSHCOLUMNINIT psci)
00095 {
00096     //
00097     //  Perform any needed initialization here
00098     //
00099     return S_OK;
00100 }
00101
00102 STDMETHODIMP CColumnProvider::GetColumnInfo (DWORD dwIndex, LPSHCOLUMNINFO psci)
00103 {
00104     //
00105     //  Return information on each column we support. Return S_FALSE
00106     //  to indicate that we have returned information on all our
00107     //  columns. GetColumnInfo will be called repeatedly until S_FALSE
00108     //  or an error is returned
00109     //
00110     if (dwIndex >= NUM_COLUMNS)
00111         return S_FALSE;
00112
00113     psci->scid.fmtid = sci[dwIndex].scid.fmtid;
00114     psci->scid.pid = sci[dwIndex].scid.pid;
00115
00116     psci->vt = sci[dwIndex].vt;
00117
00118     psci->fmt = sci[dwIndex].fmt;
00119
00120     psci->cChars = sci[dwIndex].cChars;
00121
00122     psci->csFlags = sci[dwIndex].csFlags;
00123
00124     lstrcpyn (psci->wszTitle, sci[dwIndex].wszTitle, ARRAYSIZE(psci->wszTitle));
00125     lstrcpyn (psci->wszDescription, sci[dwIndex].wszDescription, ARRAYSIZE(psci->wszDescription));
00126     return S_OK;
00127 }
00128
00129
00130 STDMETHODIMP CColumnProvider::GetItemData (LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvartData)
00131 {
00132   VARIANT varTemp;
00133   HRESULT hresult = S_FALSE;
00134     //
00135     //  The shell is asking for data for an item in one of our
00136     //  columns. Verify that a correct format ID has been passed and
00137     //  return the proper information
00138     //
00139     WCHAR wszShortPath[MAX_PATH];
00140
00141     //
00142     // Get the short path name for the file/folder
00143     //
00144     if (GetShortPathName (pscd->wszFile, wszShortPath, MAX_PATH)) {
00145
00146       //
00147       // Is the text for the short filename column is being requested
00148       //
00149       if (IsEqualGUID (pscid->fmtid, FMTID_ShortFilename) && pscid->pid == 0)
00150   {
00151     //
00152     // Don't do anything for directories
00153     //
00154     if (!(pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
00155
00156       varTemp.vt =  VT_BSTR;
00157       varTemp.bstrVal = SysAllocString (PathFindFileName (wszShortPath));
00158       if (varTemp.bstrVal) {
00159         *pvartData = varTemp;
00160         hresult = S_OK;
00161       } else {
00162         hresult = E_OUTOFMEMORY;
00163       }
00164     }
00165   }
00166     }
00167     //
00168     // Is the text for the short pathname column is being requested
00169     //
00170     else if (IsEqualGUID (pscid->fmtid, FMTID_FullPath) && pscid->pid == 0)
00171     {
00172       varTemp.vt =  VT_BSTR;
00173       varTemp.bstrVal = SysAllocString (wszShortPath);
00174       if (varTemp.bstrVal) {
00175   *pvartData = varTemp;
00176   hresult = S_OK;
00177       } else {
00178   hresult = E_OUTOFMEMORY;
00179       }
00180     }
00181
00182     return hresult;
00183 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/sync.h Source File

  • NetDS
  • RRas
  • ip

sync.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\sync.h
00008
00009 Abstract:
00010
00011     The file contains the READ_WRITE_LOCK definition which allows
00012     multiple-reader/single-writer.
00013
00014 --*/
00015
00016 #ifndef _SYNC_H_
00017 #define _SYNC_H_
00018
00019 //
00020 // type definition for READ_WRITE_LOCK
00021 //
00022
00023 typedef struct _READ_WRITE_LOCK
00024 {
00025     CRITICAL_SECTION    RWL_ReadWriteBlock;
00026     LONG                RWL_ReaderCount;
00027     HANDLE              RWL_ReaderDoneEvent;
00028 } READ_WRITE_LOCK, *PREAD_WRITE_LOCK;
00029
00030
00031
00032 DWORD
00033 CreateReadWriteLock(
00034     PREAD_WRITE_LOCK pRWL);
00035
00036 VOID
00037 DeleteReadWriteLock(
00038     PREAD_WRITE_LOCK pRWL);
00039
00040 VOID
00041 AcquireReadLock(
00042     PREAD_WRITE_LOCK pRWL);
00043
00044 VOID
00045 ReleaseReadLock(
00046     PREAD_WRITE_LOCK pRWL);
00047
00048 VOID
00049 AcquireWriteLock(
00050     PREAD_WRITE_LOCK pRWL);
00051
00052 VOID
00053 ReleaseWriteLock(
00054     PREAD_WRITE_LOCK pRWL);
00055
00056
00057
00058 //
00059 // macro functions for manipulating a read-write lock
00060 //
00061
00062 #define CREATE_READ_WRITE_LOCK(pRWL)                                \
00063     CreateReadWriteLock(pRWL)
00064 #define DELETE_READ_WRITE_LOCK(pRWL)                                \
00065     DeleteReadWriteLock(pRWL)
00066 #define READ_WRITE_LOCK_CREATED(pRWL)                               \
00067     ((pRWL)->RWL_ReaderDoneEvent != NULL)
00068
00069 #define ACQUIRE_READ_LOCK(pRWL)                                     \
00070     AcquireReadLock(pRWL)
00071 #define RELEASE_READ_LOCK(pRWL)                                     \
00072     ReleaseReadLock(pRWL)
00073 #define ACQUIRE_WRITE_LOCK(pRWL)                                    \
00074     AcquireWriteLock(pRWL)
00075 #define RELEASE_WRITE_LOCK(pRWL)                                    \
00076     ReleaseWriteLock(pRWL)
00077
00078 // atomic.  works since a critical section can be entered recursively.
00079 #define WRITE_LOCK_TO_READ_LOCK(pRWL)                               \
00080 {                                                                   \
00081     ACQUIRE_READ_LOCK(pRWL);                                        \
00082     RELEASE_WRITE_LOCK(pRWL);                                       \
00083 }
00084
00085
00086 //
00087 // type definition for generic locked list
00088 // access is sychronized with a critical section
00089 //
00090
00091 typedef struct _LOCKED_LIST
00092 {
00093     CRITICAL_SECTION    lock;
00094     LIST_ENTRY          head;
00095     DWORD               created;
00096 } LOCKED_LIST, *PLOCKED_LIST;
00097
00098 //
00099 //  VOID
00100 //  INITIALIZE_LOCKED_LIST (
00101 //      PLOCKED_LIST   pLL
00102 //      );
00103 //
00104 #define INITIALIZE_LOCKED_LIST(pLL)                                 \
00105 {                                                                   \
00106     do                                                              \
00107     {                                                               \
00108         __try {                                                     \
00109             InitializeCriticalSection(&((pLL)->lock));              \
00110         }                                                           \
00111         __except (EXCEPTION_EXECUTE_HANDLER) {                      \
00112             break;                                                  \
00113         }                                                           \
00114         InitializeListHead(&((pLL)->head));                         \
00115         (pLL)->created = 0x12345678;                                \
00116     } while (FALSE);                                                \
00117 }
00118
00119 //
00120 //  BOOL
00121 //  LOCKED_LIST_INITIALIZED (
00122 //      PLOCKED_LIST    pLL
00123 //      );
00124 //
00125 #define LOCKED_LIST_INITIALIZED(pLL)                                \
00126      ((pLL)->created == 0x12345678)
00127
00128 //
00129 //  VOID
00130 //  DELETE_LOCKED_LIST (
00131 //      PLOCKED_LIST    pLL,
00132 //      VOID(*FreeFunction)(PLIST_ENTRY)
00133 //      );
00134 //
00135 #define DELETE_LOCKED_LIST(pLL, FreeFunction)                       \
00136 {                                                                   \
00137      (pLL)->created = 0;                                            \
00138      FreeList(&((pLL)->head), FreeFunction);                        \
00139      DeleteCriticalSection(&(pLL)->lock);                           \
00140 }
00141
00142 #define ACQUIRE_LIST_LOCK(pLL)                                      \
00143      EnterCriticalSection(&(pLL)->lock)
00144
00145 #define RELEASE_LIST_LOCK(pLL)                                      \
00146      LeaveCriticalSection(&(pLL)->lock)
00147
00148
00149
00150 #define LOCKED_QUEUE    LOCKED_LIST
00151 #define PLOCKED_QUEUE   PLOCKED_LIST
00152
00153
00154 #define INITIALIZE_LOCKED_QUEUE(pLQ)                                \
00155      INITIALIZE_LOCKED_LIST(pLQ)
00156 #define LOCKED_QUEUE_INITIALIZED(pLQ)                               \
00157      LOCKED_LIST_INITIALIZED(pLQ)
00158 #define DELETE_LOCKED_QUEUE(pLQ, FreeFunction)                      \
00159      DELETE_LOCKED_LIST(pLQ, FreeFunction)
00160 #define ACQUIRE_QUEUE_LOCK(pLQ)                                     \
00161      ACQUIRE_LIST_LOCK(pLQ)
00162 #define RELEASE_QUEUE_LOCK(pLQ)                                     \
00163      RELEASE_LIST_LOCK(pLQ)
00164
00165
00166
00167 //
00168 // type definition for DYNAMIC_READWRITE_LOCK
00169 //
00170 typedef struct _DYNAMIC_READWRITE_LOCK {
00171     READ_WRITE_LOCK     rwlLock;
00172     union
00173     {
00174         ULONG           ulCount;    // number of waiting threads
00175         LIST_ENTRY      leLink;     // link in list of free locks
00176     };
00177 } DYNAMIC_READWRITE_LOCK, *PDYNAMIC_READWRITE_LOCK;
00178
00179 //
00180 // type definition of DYNAMIC_LOCKS_STORE
00181 // store of free dynamic locks that can be allocated as required.
00182 //
00183 typedef struct _DYNAMIC_LOCKS_STORE {
00184     HANDLE              hHeap;
00185
00186     LOCKED_LIST         llFreeLocksList;
00187
00188     ULONG               ulCountAllocated;
00189     ULONG               ulCountFree;
00190 } DYNAMIC_LOCKS_STORE, *PDYNAMIC_LOCKS_STORE;
00191
00192
00193
00194 // if more than DYNAMIC_LOCKS_HIGH_THRESHOLD locks are
00195 // allocated then any locks that are freed are destroyed
00196 #define DYNAMIC_LOCKS_HIGH_THRESHOLD 7
00197
00198 #define DYNAMIC_LOCKS_STORE_INITIALIZED(pStore)                     \
00199     (LOCKED_LIST_INITIALIZED(&(pStore)->llFreeLocksList))
00200
00201 typedef enum { READ_MODE, WRITE_MODE } LOCK_MODE;
00202
00203 DWORD
00204 InitializeDynamicLocksStore (
00205     PDYNAMIC_LOCKS_STORE    pStore,
00206     HANDLE                  hHeap
00207     );
00208
00209 DWORD
00210 DeInitializeDynamicLocksStore (
00211     PDYNAMIC_LOCKS_STORE    pStore
00212     );
00213
00214 DWORD
00215 AcquireDynamicReadwriteLock (
00216     PDYNAMIC_READWRITE_LOCK *ppLock,
00217     LOCK_MODE               lmMode,
00218     PDYNAMIC_LOCKS_STORE    pStore
00219     );
00220
00221 VOID
00222 ReleaseDynamicReadwriteLock (
00223     PDYNAMIC_READWRITE_LOCK *ppLock,
00224     LOCK_MODE               lmMode,
00225     PDYNAMIC_LOCKS_STORE    pStore
00226     );
00227
00228 #endif // _SYNC_H_
00229
00230
00231
00232
00233
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/Server/Resource.h Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • Server

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by server.rc
00004 //
00005 #define IDS_PROJNAME                    100
00006 #define IDR_Server                      100
00007 #define IDS_MONITORSERVER_DESC     101
00008 #define IDR_MonitorServer          102
00009
00010 // Next default values for new objects
00011 //
00012 #ifdef APSTUDIO_INVOKED
00013 #ifndef APSTUDIO_READONLY_SYMBOLS
00014 #define _APS_NEXT_RESOURCE_VALUE        201
00015 #define _APS_NEXT_COMMAND_VALUE         32768
00016 #define _APS_NEXT_CONTROL_VALUE         201
00017 #define _APS_NEXT_SYMED_VALUE           103
00018 #endif
00019 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/MethProv/MethProv.Cpp Source File

  • SysMgmt
  • WMI
  • VC
  • MethProv

MethProv.Cpp

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  METHPROV.CPP
00006
00007 //
00008
00009 //  Module: WMI Method provider sample code
00010
00011 //
00012
00013 //  Purpose: Defines the CMethodPro class.  An object of this class is
00014
00015 //           created by the class factory for each connection.
00016
00017 //
00018
00019 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00020 //
00021 //***************************************************************************
00022
00023 #define _WIN32_DCOM
00024
00025 #include <objbase.h>
00026 #include "methprov.h"
00027 #include <process.h>
00028 #include <wbemidl.h>
00029 #include <stdio.h>
00030
00031
00032 //***************************************************************************
00033 //
00034 // CMethodPro::CMethodPro
00035 // CMethodPro::~CMethodPro
00036 //
00037 //***************************************************************************
00038
00039 CMethodPro::CMethodPro()
00040 {
00041     InterlockedIncrement(&g_cObj);
00042     return;
00043
00044 }
00045
00046 CMethodPro::~CMethodPro(void)
00047 {
00048     InterlockedDecrement(&g_cObj);
00049     return;
00050 }
00051
00052 //***************************************************************************
00053 //
00054 // CMethodPro::QueryInterface
00055 // CMethodPro::AddRef
00056 // CMethodPro::Release
00057 //
00058 // Purpose: IUnknown members for CMethodPro object.
00059 //***************************************************************************
00060
00061
00062 STDMETHODIMP CMethodPro::QueryInterface(REFIID riid, PPVOID ppv)
00063 {
00064     *ppv=NULL;
00065
00066     if (IID_IUnknown==riid || IID_IWbemServices == riid || IID_IWbemProviderInit==riid)
00067        if(riid== IID_IWbemServices){
00068           *ppv=(IWbemServices*)this;
00069        }
00070
00071        if(IID_IUnknown==riid || riid== IID_IWbemProviderInit){
00072           *ppv=(IWbemProviderInit*)this;
00073        }
00074
00075
00076     if (NULL!=*ppv) {
00077         AddRef();
00078         return NOERROR;
00079         }
00080     else
00081         return E_NOINTERFACE;
00082 }
00083
00084
00085 STDMETHODIMP_(ULONG) CMethodPro::AddRef(void)
00086 {
00087     return ++m_cRef;
00088 }
00089
00090 STDMETHODIMP_(ULONG) CMethodPro::Release(void)
00091 {
00092     ULONG nNewCount = InterlockedDecrement((long *)&m_cRef);
00093     if (0L == nNewCount)
00094         delete this;
00095
00096     return nNewCount;
00097 }
00098
00099 /***********************************************************************
00100 *                                                                      *
00101 *CMethodPro::Initialize                                                *
00102 *                                                                      *
00103 *Purpose: This is the implementation of IWbemProviderInit. The method  *
00104 * is need to initialize with CIMOM.                                    *
00105 *                                                                      *
00106 ***********************************************************************/
00107 STDMETHODIMP CMethodPro::Initialize(LPWSTR pszUser, LONG lFlags,
00108                                     LPWSTR pszNamespace, LPWSTR pszLocale,
00109                                     IWbemServices *pNamespace,
00110                                     IWbemContext *pCtx,
00111                                     IWbemProviderInitSink *pInitSink)
00112 {
00113
00114     if(! pNamespace)
00115   {
00116       pInitSink->SetStatus(WBEM_E_FAILED , 0);
00117   }
00118   else
00119   {
00120     m_pWbemSvcs = pNamespace;
00121       m_pWbemSvcs->AddRef();
00122     pInitSink->SetStatus(WBEM_S_INITIALIZED, 0);
00123   }
00124
00125
00126     return WBEM_S_NO_ERROR;
00127 }
00128
00129
00130
00131 /************************************************************************
00132 *                                                                       *
00133 *CMethodPro::ExecMethodAsync                                            *
00134 *                                                                       *
00135 *Purpose: This is the Async function implementation.                    *
00136 *         The only method supported in this sample is named Echo.  It   *
00137 *         takes an input string, copies it to the output and returns the*
00138 *         length.  The mof definition is                                *
00139 *                                                                       *
00140 *    [dynamic: ToInstance, provider("MethProv")]class MethProvSamp      *
00141 *    {                                                                  *
00142 *         [implemented, static]                                         *
00143 *            uint32 Echo([IN]string sInArg="default",                   *
00144 *                [out] string sOutArg);                                 *
00145 *    };                                                                 *
00146 *                                                                       *
00147 ************************************************************************/
00148
00149 STDMETHODIMP CMethodPro::ExecMethodAsync(const BSTR ObjectPath, const BSTR MethodName,
00150             long lFlags, IWbemContext* pCtx, IWbemClassObject* pInParams,
00151             IWbemObjectSink* pResultSink)
00152 {
00153   // Do some minimal error checking.  This code only support the
00154     // method "Echo" as defined in the mof.  A routine could support
00155     // more than on method
00156
00157     if(_wcsicmp(MethodName, L"Echo"))
00158         return WBEM_E_INVALID_PARAMETER;
00159
00160     IWbemClassObject * pClass = NULL;
00161     IWbemClassObject * pOutClass = NULL;
00162     IWbemClassObject* pOutParams = NULL;
00163
00164
00165   // Impersonate the client: in this simple sample, no protected resources are accessed,
00166   // but the provider normally needs to perform any operations in the security context
00167   // of the client
00168   HRESULT hr = CoImpersonateClient () ;
00169
00170   if ( FAILED ( hr ) )
00171   {
00172     pResultSink->SetStatus ( 0 , hr , NULL , NULL ) ;
00173     return hr ;
00174   }
00175
00176   //  Check to see if call is at lower than RPC_C_IMP_LEVEL_IMPERSONATE level. If that's the case,
00177   //  the provider will not be able to impersonate the client to access the protected resources.
00178
00179   DWORD t_CurrentImpersonationLevel = GetCurrentImpersonationLevel () ;
00180   if ( t_CurrentImpersonationLevel < RPC_C_IMP_LEVEL_IMPERSONATE )
00181   {
00182     //  Revert before we perform any operations
00183     CoRevertToSelf () ;
00184
00185     hr = WBEM_E_ACCESS_DENIED;
00186     pResultSink->SetStatus ( 0 , hr , NULL , NULL ) ;
00187     return hr ;
00188   }
00189
00190
00191     // Allocate some BSTRs
00192
00193     BSTR ClassName = SysAllocString(L"MethProvSamp");
00194   if (!ClassName)
00195   {
00196     CoRevertToSelf();
00197     pResultSink->SetStatus ( 0 , WBEM_E_OUT_OF_MEMORY , NULL , NULL ) ;
00198     return hr ;
00199   }
00200
00201     BSTR InputArgName = SysAllocString(L"sInArg");
00202   if (!InputArgName)
00203   {
00204     SysFreeString(ClassName);
00205     CoRevertToSelf();
00206     pResultSink->SetStatus ( 0 , WBEM_E_OUT_OF_MEMORY , NULL , NULL ) ;
00207     return hr ;
00208   }
00209
00210     BSTR OutputArgName = SysAllocString(L"sOutArg");
00211   if (!OutputArgName)
00212   {
00213     SysFreeString(ClassName);
00214     SysFreeString(InputArgName);
00215     CoRevertToSelf();
00216     pResultSink->SetStatus ( 0 , WBEM_E_OUT_OF_MEMORY , NULL , NULL ) ;
00217     return hr ;
00218   }
00219     BSTR retValName = SysAllocString(L"ReturnValue");
00220   if (!retValName)
00221   {
00222     SysFreeString(ClassName);
00223     SysFreeString(InputArgName);
00224     SysFreeString(OutputArgName);
00225     CoRevertToSelf();
00226     pResultSink->SetStatus ( 0 , WBEM_E_OUT_OF_MEMORY , NULL , NULL ) ;
00227     return hr ;
00228   }
00229
00230     // Get the class object, this is hard coded and matches the class
00231     // in the MOF.  A more sophisticated example would parse the
00232     // ObjectPath to determine the class and possibly the instance.
00233
00234     hr = m_pWbemSvcs->GetObject(ClassName, 0, pCtx, &pClass, NULL);
00235   if(hr != S_OK)
00236   {
00237      pResultSink->SetStatus(0,hr, NULL, NULL);
00238      return WBEM_S_NO_ERROR;
00239   }
00240
00241
00242     // This method returns values, and so create an instance of the
00243     // output argument class.
00244
00245     hr = pClass->GetMethod(MethodName, 0, NULL, &pOutClass);
00246     pOutClass->SpawnInstance(0, &pOutParams);
00247
00248     // Copy the input argument into the output object
00249
00250     VARIANT var;
00251     VariantInit(&var);    // Get the input argument
00252     pInParams->Get(InputArgName, 0, &var, NULL, NULL);
00253
00254     // put it into the output object
00255
00256     pOutParams->Put(OutputArgName , 0, &var, 0);
00257     long lLen = (long)wcslen(var.bstrVal);    VariantClear(&var);    var.vt = VT_I4;
00258     var.lVal = lLen;    // special name for return value.
00259     pOutParams->Put(retValName , 0, &var, 0);
00260
00261     // Send the output object back to the client via the sink. Then
00262     // release the pointers and free the strings.
00263
00264     hr = pResultSink->Indicate(1, &pOutParams);
00265     pOutParams->Release();
00266     pOutClass->Release();
00267     pClass->Release();
00268     SysFreeString(ClassName);
00269     SysFreeString(InputArgName);
00270     SysFreeString(OutputArgName);
00271     SysFreeString(retValName);
00272
00273     // all done now, set the status
00274     hr = pResultSink->SetStatus(0,WBEM_S_NO_ERROR,NULL,NULL);
00275     return WBEM_S_NO_ERROR;
00276 }
00277
00278 /******************************************************************************
00279  *
00280  *  Name: GetCurrentImpersonationLevel
00281  *
00282  *
00283  *  Description:
00284  *
00285  *      Get COM impersonation level of caller.
00286  *
00287  *****************************************************************************/
00288
00289 DWORD GetCurrentImpersonationLevel ()
00290 {
00291   DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00292
00293     HANDLE t_ThreadToken = NULL ;
00294
00295     BOOL t_Status = OpenThreadToken (
00296
00297     GetCurrentThread() ,
00298     TOKEN_QUERY,
00299     TRUE,
00300     &t_ThreadToken
00301   ) ;
00302
00303     if ( t_Status )
00304     {
00305     SECURITY_IMPERSONATION_LEVEL t_Level = SecurityAnonymous ;
00306     DWORD t_Returned = 0 ;
00307
00308     t_Status = GetTokenInformation (
00309
00310       t_ThreadToken ,
00311       TokenImpersonationLevel ,
00312       & t_Level ,
00313       sizeof ( SECURITY_IMPERSONATION_LEVEL ) ,
00314       & t_Returned
00315     ) ;
00316
00317     CloseHandle ( t_ThreadToken ) ;
00318
00319     if ( t_Status == FALSE )
00320     {
00321       t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00322     }
00323     else
00324     {
00325       switch ( t_Level )
00326       {
00327         case SecurityAnonymous:
00328         {
00329           t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00330         }
00331         break ;
00332
00333         case SecurityIdentification:
00334         {
00335           t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
00336         }
00337         break ;
00338
00339         case SecurityImpersonation:
00340         {
00341           t_ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE ;
00342         }
00343         break ;
00344
00345         case SecurityDelegation:
00346         {
00347           t_ImpersonationLevel = RPC_C_IMP_LEVEL_DELEGATE ;
00348         }
00349         break ;
00350
00351         default:
00352         {
00353           t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00354         }
00355         break ;
00356       }
00357     }
00358   }
00359   else
00360   {
00361         ULONG t_LastError = GetLastError () ;
00362
00363         if ( t_LastError == ERROR_NO_IMPERSONATION_TOKEN || t_LastError == ERROR_NO_TOKEN )
00364         {
00365             t_ImpersonationLevel = RPC_C_IMP_LEVEL_DELEGATE ;
00366         }
00367         else
00368     {
00369       if ( t_LastError == ERROR_CANT_OPEN_ANONYMOUS )
00370       {
00371         t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00372       }
00373       else
00374       {
00375         t_ImpersonationLevel = RPC_C_IMP_LEVEL_ANONYMOUS ;
00376       }
00377     }
00378     }
00379
00380   return t_ImpersonationLevel ;
00381 }
00382
Generated on Wed Nov 13 2024 16:52:40 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/simple/resource.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • simple

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Resource.rc
00004 //
00005 #define IDS_HELPFILE                    1
00006 #define IDS_SNAPINDESC                  2
00007 #define IDS_NAME                        3
00008 #define IDS_SNAPINNAME                  6
00009 #define IDS_ABOUTNAME                   9
00010 #define IDI_ICON1                       108
00011 #define IDR_SMICONS                     120
00012 #define IDR_LGICONS                     121
00013 #define IDB_ROCKET                      40004
00014 #define IDB_CAR                         40005
00015 #define IDB_PLANE                       40006
00016 #define IDB_BIKE                        40007
00017 #define IDB_ROCKET2                     40008
00018 #define IDB_CAR2                        40009
00019 #define IDB_PLANE2                      40010
00020 #define IDB_BIKE2                       40011
00021 #define IDB_CLOSED2                     40012
00022 #define IDB_OPEN2                       40013
00023 #define IDB_CLOSED                      40014
00024 #define IDB_OPEN                        40015
00025
00026 // Next default values for new objects
00027 //
00028 #ifdef APSTUDIO_INVOKED
00029 #ifndef APSTUDIO_READONLY_SYMBOLS
00030 #define _APS_NEXT_RESOURCE_VALUE        108
00031 #define _APS_NEXT_COMMAND_VALUE         40016
00032 #define _APS_NEXT_CONTROL_VALUE         1000
00033 #define _APS_NEXT_SYMED_VALUE           101
00034 #endif
00035 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/AppBar/PropSht.c Source File

  • WinUI
  • Shell
  • AppBar

PropSht.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1993 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:     PropSheet.c
00009 //
00010 //  PURPOSE:    Handles retrieving application properties from the user.
00011 //
00012 //  PLATFORMS:  Windows 95, Windows 98, Windows 2000, Windows NT 4.0
00013 //
00014 //  FUNCTIONS:
00015 //      ShowOptions()           - Creates the property sheet
00016 //      OptionsPageProc()       - Options page callback procedure
00017 //      Options_OnInitDialog()  - Initialize the options page
00018 //      Options_OnDestroy()     - Handles cleaning up the option page
00019 //      Options_OnCommand()     - Updates the picture in response to commands
00020 //      Options_OnNotify()      - Handles property sheet notifications
00021 //
00022
00023 #include <windows.h>
00024 #include <windowsx.h>
00025 #include <commctrl.h>
00026 #include "globals.h"
00027 #include "resource.h"
00028 #include "appbar.h"
00029
00030
00031 //////////////////////////////////////////////////////////////////////////////
00032 // Global variables visible only to this file
00033
00034 static POPTIONS pOptions;       // Appbar options used throughout the options
00035                                 // property page.
00036 static HWND hwndAppbar;         // Appbar window handle
00037
00038
00039 //////////////////////////////////////////////////////////////////////////////
00040 // Local Prototypes
00041
00042 BOOL CALLBACK OptionsPageProc(HWND hwnd, UINT uMsg, WPARAM wParam,
00043                               LPARAM lParam);
00044 void Options_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
00045 BOOL Options_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam);
00046 void Options_OnDestroy(HWND hwnd);
00047 LRESULT Options_OnNotify(HWND hwnd, int idFrom, LPNMHDR pnmhdr);
00048
00049
00050
00051 //
00052 //  FUNCTION:   ShowOptions(HWND)
00053 //
00054 //  PURPOSE:    Creates and displays the appbar's property sheet.
00055 //
00056 //  PARAMETERS:
00057 //      hwndParent - Handle to the parent window for the prop sheet.
00058 //
00059
00060 void ShowOptions(HWND hwndParent)
00061 {
00062     PROPSHEETPAGE psp[2];
00063     PROPSHEETHEADER psh;
00064
00065     // Store the window handle of the appbar so we can send it commands
00066     // when the options change
00067     hwndAppbar = hwndParent;
00068
00069     // Initialize the memory
00070     ZeroMemory(psp, sizeof(PROPSHEETPAGE) * 2);
00071
00072     // Fill out the property sheet pages
00073     psp[0].dwSize      = sizeof(PROPSHEETPAGE);
00074     psp[0].dwFlags     = PSP_USETITLE;
00075     psp[0].hInstance   = g_hInstance;
00076     psp[0].pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS);
00077     psp[0].pszTitle    = TEXT("AppBar Options");
00078     psp[0].pfnDlgProc  = (DLGPROC)OptionsPageProc;
00079     psp[0].lParam      = (LPARAM)((POPTIONS)GetAppbarData(hwndParent));
00080
00081     // Now fill out the property sheet header
00082     psh.dwSize = sizeof(PROPSHEETHEADER);
00083     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
00084     psh.hwndParent = hwndParent;
00085     psh.hInstance = g_hInstance;
00086     psh.pszCaption = TEXT("AppBar");
00087     psh.nPages = 1;
00088     psh.ppsp = psp;
00089
00090     // Finally display the property sheet
00091     PropertySheet(&psh);
00092     return;
00093 }
00094
00095
00096 //
00097 //  FUNCTION:   OptionsPageProc(HWND, UINT, WPARAM, LPARAM)
00098 //
00099 //  PURPOSE:    Dispatches messages for the options property page.
00100 //
00101
00102 BOOL CALLBACK OptionsPageProc(HWND hwnd, UINT uMsg, WPARAM wParam,
00103                               LPARAM lParam)
00104 {
00105     switch (uMsg)
00106     {
00107         case WM_INITDIALOG:
00108             return (BOOL)HANDLE_WM_INITDIALOG(hwnd, wParam,
00109                                               lParam, Options_OnInitDialog);
00110
00111         case WM_COMMAND:
00112             HANDLE_WM_COMMAND(hwnd, wParam, lParam,
00113                               Options_OnCommand);
00114             return (TRUE);
00115
00116         case WM_DESTROY:
00117             HANDLE_WM_DESTROY(hwnd, wParam, lParam,
00118                               Options_OnDestroy);
00119             return (TRUE);
00120
00121         case WM_NOTIFY:
00122             HANDLE_WM_NOTIFY(hwnd, wParam, lParam, Options_OnNotify);
00123             return (TRUE);
00124
00125     }
00126
00127     return (0);
00128 }
00129
00130
00131 //
00132 //  FUNCTION:   Options_OnInitDialog(HWND, HWND, LPARAM)
00133 //
00134 //  PURPOSE:    Handles initialization of the property page.
00135 //
00136 //  PARAMETERS:
00137 //      hwnd      - Handle of the property page window.
00138 //      hwndFocus - Child window that will receive focus if the function
00139 //                  returns TRUE.
00140 //      lParam    - Will contain a pointer to the appbar OPTIONS struct.
00141 //
00142 //  RETURN VALUE:
00143 //      Returns TRUE to set the focus to the child window contained in the
00144 //      hwndFocus parameter.  Returns FALSE to set the focus ourselves.
00145 //
00146
00147 BOOL Options_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
00148 {
00149     PROPSHEETPAGE *ppsp;
00150     RECT rc;
00151     HBITMAP hbmpBase;
00152     HBITMAP hbmpAppbar;
00153     HBITMAP hbmpWindow;
00154     APPBARDATA abd;
00155     HWND hwndAutohide;
00156
00157     // Get the pointer to the OPTIONS struct from the lParam
00158     ppsp = (PROPSHEETPAGE *)lParam;
00159     pOptions = (POPTIONS)ppsp->lParam;
00160
00161     // Load and set the picture for the base image
00162     hbmpBase = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BASE));
00163     if (!hbmpBase)
00164     {
00165         ErrorHandler();
00166         EndDialog(hwnd, 0);
00167     }
00168
00169     SendDlgItemMessage(hwnd, IDC_PICTURE, STM_SETIMAGE, IMAGE_BITMAP,
00170                        (LPARAM) hbmpBase);
00171
00172     // Set the pictures for the rest of the static controls, move them
00173     // into position, and hide them
00174     hbmpAppbar = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_APPBAR));
00175     hbmpWindow = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_WINDOW));
00176     if (!hbmpAppbar || !hbmpWindow)
00177     {
00178         ErrorHandler();
00179         EndDialog(hwnd, 0);
00180     }
00181
00182     SendDlgItemMessage(hwnd, IDC_APPBAR, STM_SETIMAGE, IMAGE_BITMAP,
00183                        (LPARAM) hbmpAppbar);
00184     SendDlgItemMessage(hwnd, IDC_WINDOW, STM_SETIMAGE, IMAGE_BITMAP,
00185                        (LPARAM) hbmpWindow);
00186
00187     // Get the position of the picture and convert to client coordiates
00188     GetWindowRect(GetDlgItem(hwnd, IDC_PICTURE), &rc);
00189     ScreenToClient(hwnd, (LPPOINT)&rc);
00190
00191     SetWindowPos(GetDlgItem(hwnd, IDC_APPBAR), GetDlgItem(hwnd, IDC_PICTURE),
00192                  rc.left + 2, rc.top + 69, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
00193
00194     SetWindowPos(GetDlgItem(hwnd, IDC_WINDOW), GetDlgItem(hwnd, IDC_APPBAR),
00195                  rc.left + 212, rc.top + 69, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
00196
00197     // Set the values of the controls based on the values in OPTIONS
00198     Button_SetCheck(GetDlgItem(hwnd, IDC_AUTOHIDE), pOptions->fAutoHide);
00199     Button_SetCheck(GetDlgItem(hwnd, IDC_ONTOP), pOptions->fOnTop);
00200
00201     if (pOptions->fAutoHide)
00202         ShowWindow(GetDlgItem(hwnd, IDC_APPBAR), SW_HIDE);
00203     if (pOptions->fOnTop)
00204         ShowWindow(GetDlgItem(hwnd, IDC_WINDOW), SW_HIDE);
00205
00206     // Check the autohide window for this side.  Since only one appbar can be
00207     // auto hidden on each side of the screen, we should disable this check box
00208     // if we can't autohide.
00209     abd.cbSize = sizeof(APPBARDATA);
00210     abd.hWnd = hwndAppbar;
00211     abd.uEdge = pOptions->uSide;
00212
00213     hwndAutohide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
00214     if ((hwndAutohide != NULL) && (hwndAutohide != hwndAppbar))
00215         EnableWindow(GetDlgItem(hwnd, IDC_AUTOHIDE), FALSE);
00216
00217     return (FALSE);
00218 }
00219
00220
00221 //
00222 //  FUNCTION:   Options_OnCommand(HWND, int, HWND, UINT)
00223 //
00224 //  PURPOSE:    Handles the command messages for the options page.
00225 //
00226 //  PARAMETERS:
00227 //      hwnd        - handle of the window receiving the message
00228 //      id          - identifier of the command
00229 //      hwndCtl     - handle of the control sending the message)
00230 //      codeNotify  - specifies the notification code if the message is from
00231 //                    a control
00232 //
00233 //  COMMENTS:
00234 //      codeNotify is 1 if from an accelerator, 0 if from a menu.
00235 //      If the message is not from a control hwndCtl is NULL.
00236 //
00237
00238 void Options_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
00239 {
00240     switch (id)
00241     {
00242         case IDC_AUTOHIDE:
00243             // First let the property sheet know somethings changed
00244             PropSheet_Changed(GetParent(hwnd), hwnd);
00245
00246             // Now update the picture
00247             if (Button_GetCheck(hwndCtl))
00248                 ShowWindow(GetDlgItem(hwnd, IDC_APPBAR), SW_HIDE);
00249             else
00250                 ShowWindow(GetDlgItem(hwnd, IDC_APPBAR), SW_SHOW);
00251
00252             break;
00253
00254         case IDC_ONTOP:
00255             // First let the property sheet know somethings changed
00256             PropSheet_Changed(GetParent(hwnd), hwnd);
00257
00258             // Now update the picture
00259             if (Button_GetCheck(hwndCtl))
00260                 ShowWindow(GetDlgItem(hwnd, IDC_WINDOW), SW_HIDE);
00261             else
00262                 ShowWindow(GetDlgItem(hwnd, IDC_WINDOW), SW_SHOW);
00263
00264             break;
00265     }
00266 }
00267
00268
00269 //
00270 //  FUNCTION:   Options_OnDestroy(HWND)
00271 //
00272 //  PURPOSE:    Clean up the GDI objects we created in the OnInitDialog.
00273 //
00274 //  PARAMETERS:
00275 //      hwnd    - Handle of the options property page.
00276 //
00277
00278 void Options_OnDestroy(HWND hwnd)
00279 {
00280     HBITMAP hbmp;
00281
00282     hbmp = (HBITMAP) SendDlgItemMessage(hwnd, IDC_PICTURE, STM_GETIMAGE,
00283                                         IMAGE_BITMAP, 0L);
00284     if (hbmp)
00285         DeleteObject(hbmp);
00286
00287     hbmp = (HBITMAP) SendDlgItemMessage(hwnd, IDC_APPBAR, STM_GETIMAGE,
00288                                         IMAGE_BITMAP, 0L);
00289     if (hbmp)
00290         DeleteObject(hbmp);
00291
00292     hbmp = (HBITMAP) SendDlgItemMessage(hwnd, IDC_WINDOW, STM_GETIMAGE,
00293                                         IMAGE_BITMAP, 0L);
00294     if (hbmp)
00295         DeleteObject(hbmp);
00296 }
00297
00298
00299 //
00300 //  FUNCTION:   Options_OnNotify(HWND, int, LPNMHDR)
00301 //
00302 //  PURPOSE:    Handles updating the appbar states when the user either presses
00303 //              the "Apply" button or the "OK" button.
00304 //
00305 //  PARAMETERS:
00306 //      hwnd    - handle of the window receiving the notification
00307 //      idCtl   - identifies the control sending the notification
00308 //      pnmh    - points to a NMHDR struct with more inforamation regarding the
00309 //                notification
00310 //
00311 //  RETURN VALUE:
00312 //      Always zero.
00313 //
00314
00315 LRESULT Options_OnNotify(HWND hwnd, int idFrom, LPNMHDR pnmhdr)
00316 {
00317     BOOL fCheck;
00318
00319     switch (pnmhdr->code)
00320     {
00321         case PSN_APPLY:
00322             // Check to see if the options have changed.  If so, send
00323             // the appropriate command to the appbar
00324             fCheck = (BOOL) Button_GetCheck(GetDlgItem(hwnd, IDC_AUTOHIDE));
00325             if (pOptions->fAutoHide != fCheck)
00326             {
00327                 if (AppBar_SetAutoHide(hwndAppbar, fCheck))
00328                     pOptions->fAutoHide = fCheck;
00329             }
00330
00331             // If the Always-On-Top setting has changed update the appbar state
00332             fCheck = (BOOL) Button_GetCheck(GetDlgItem(hwnd, IDC_ONTOP));
00333             if (pOptions->fOnTop != fCheck)
00334             {
00335                 pOptions->fOnTop = fCheck;
00336                 AppBar_SetAlwaysOnTop(hwndAppbar, fCheck);
00337             }
00338
00339             SetDlgMsgResult(hwnd, WM_NOTIFY, PSNRET_NOERROR);
00340             break;
00341     }
00342
00343     return (0);
00344 }
00345
00346
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerText/Connect.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerText

Connect.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.CPP
00003
00004   Summary:   Implementation file for the connection points (and their
00005              connections) offered by the connectable objects in the
00006              PERTEXT server sample. COM objects are implemented for
00007              Connection Point Enumerators, Connection Points, and
00008              Connection Enumerators.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial PERTEXT.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Functions: none.
00020
00021   Origin:    5-12-97: atrent - Editor inheritance from STOSERVE
00022              Tutorial Code Sample. Very little change was required.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039
00040 /*---------------------------------------------------------------------------
00041   We include WINDOWS.H for all Win32 applications.
00042   We include OLE2.H because we will be calling the COM/OLE Libraries.
00043   We include OLECTL.H because it has definitions for connectable objects.
00044   We include APPUTIL.H because we will be building this application using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IPAGES.H and PAGEGUID.H for the common page-related
00048     Interface class, GUID, and CLSID specifications.
00049   We include SERVER.H because it has internal class declarations
00050     for the server housing for the components in this DLL.
00051   We include CONNECT.H for object class declarations for the various
00052     connection point and connection COM objects used in PERTEXT.
00053   We include TEXTPAGE.H because it has the class COEnumConnectionPoints
00054     declarations as well as the COTextPage class declaration.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <olectl.h>
00059 #include <apputil.h>
00060 #include <ipages.h>
00061 #include <pageguid.h>
00062 #include "server.h"
00063 #include "connect.h"
00064 #include "textpage.h"
00065
00066
00067 /*---------------------------------------------------------------------------
00068   COEnumConnectionPoints's implementation of its main COM object class
00069   including Constructor, Destructor, QueryInterface, AddRef, Release,
00070   Next, Skip, Reset, and Clone.
00071 ---------------------------------------------------------------------------*/
00072
00073 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00074   Method:   COEnumConnectionPoints::COEnumConnectionPoints
00075
00076   Summary:  COEnumConnectionPoints Constructor.
00077
00078   Args:     IUnknown* pHostObj
00079               Pointer to the host object whose connection points are
00080               being enumerated.
00081
00082   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnPts, and m_paConnPts.
00083
00084   Returns:  void
00085 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00086 COEnumConnectionPoints::COEnumConnectionPoints(
00087   IUnknown* pHostObj)
00088 {
00089   // Zero the COM object's reference count.
00090   m_cRefs = 0;
00091
00092   // Assign the Host Object pointer.
00093   m_pHostObj = pHostObj;
00094
00095   // Initialize the Connection Point enumerator variables.
00096   m_iEnumIndex = 0;
00097   m_cConnPts = 0;
00098   m_paConnPts = NULL;
00099
00100   return;
00101 }
00102
00103
00104 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00105   Method:   COEnumConnectionPoints::~COEnumConnectionPoints
00106
00107   Summary:  COEnumConnectionPoints Destructor.
00108
00109   Args:     void
00110
00111   Modifies: m_paConnPts.
00112
00113   Returns:  void
00114 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00115 COEnumConnectionPoints::~COEnumConnectionPoints(void)
00116 {
00117   if (NULL != m_paConnPts)
00118   {
00119     UINT i;
00120
00121     // Release all the connection point interface pointers.
00122     for (i=0; i<m_cConnPts; i++)
00123       if (NULL != m_paConnPts[i])
00124         m_paConnPts[i]->Release();
00125
00126     // Delete the array of interface pointers.
00127     delete [] m_paConnPts;
00128   }
00129
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   COEnumConnectionPoints::Init
00136
00137   Summary:  COEnumConnectionPoints Initialization method.  Create any
00138             necessary arrays, structures, and objects.
00139
00140   Args:     ULONG cConnPts,
00141               Number of Connections Points.
00142             IConnectionPoint** paConnPts,
00143               Pointer to array of connection point interface pointers.
00144             ULONG iEnumIndex
00145               The initial Enumerator index value.
00146
00147   Modifies: m_cConnPts, m_paConnPts, m_iEnumIndex.
00148
00149   Returns:  HRESULT
00150               Standard result code. NOERROR for success.
00151 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00152 HRESULT COEnumConnectionPoints::Init(
00153           ULONG cConnPts,
00154           IConnectionPoint** paConnPts,
00155           ULONG iEnumIndex)
00156 {
00157   HRESULT hr = NOERROR;
00158   UINT i;
00159
00160   // Remember the number of Connection points.
00161   m_cConnPts = cConnPts;
00162
00163   // Remember the initial enumerator index.
00164   m_iEnumIndex = iEnumIndex;
00165
00166   // Create a copy of the array of connection points and keep it inside
00167   // this enumerator COM object.
00168   m_paConnPts = new IConnectionPoint* [(UINT) cConnPts];
00169
00170   // Fill the array copy with the IConnectionPoint interface pointers from
00171   // the array passed. AddRef for each new Interface pointer copy made.
00172   if (NULL != m_paConnPts)
00173   {
00174     for (i=0; i<cConnPts; i++)
00175     {
00176       m_paConnPts[i] = paConnPts[i];
00177       m_paConnPts[i]->AddRef();
00178     }
00179   }
00180   else
00181     hr = E_OUTOFMEMORY;
00182
00183   return (hr);
00184 }
00185
00186
00187 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00188   Method:   COEnumConnectionPoints::QueryInterface
00189
00190   Summary:  QueryInterface of the COEnumConnectionPoints non-delegating
00191             IUnknown implementation.
00192
00193   Args:     REFIID riid,
00194               [in] GUID of the Interface being requested.
00195             PPVOID ppv)
00196               [out] Address of the caller's pointer variable that will
00197               receive the requested interface pointer.
00198
00199   Returns:  HRESULT
00200 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00201 STDMETHODIMP COEnumConnectionPoints::QueryInterface(
00202                REFIID riid,
00203                PPVOID ppv)
00204 {
00205   HRESULT hr = E_NOINTERFACE;
00206
00207   *ppv = NULL;
00208
00209   // The IEnumConnectionPoints interface is implemented directly in
00210   // this COM object rather than being a nested interface implementation.
00211   if (IID_IUnknown == riid || IID_IEnumConnectionPoints == riid)
00212     *ppv = (LPVOID)this;
00213
00214   if (NULL != *ppv)
00215   {
00216     // We've handed out a pointer to the interface so obey the COM rules
00217     // and AddRef the reference count.
00218     ((LPUNKNOWN)*ppv)->AddRef();
00219     hr = NOERROR;
00220   }
00221
00222   return (hr);
00223 }
00224
00225
00226 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00227   Method:   COEnumConnectionPoints::AddRef
00228
00229   Summary:  AddRef of the COEnumConnectionPoints non-delegating IUnknown
00230             implementation.
00231
00232   Args:     void
00233
00234   Modifies: m_cRefs.
00235
00236   Returns:  ULONG
00237               New value of m_cRefs (COM object's reference count).
00238 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00239 STDMETHODIMP_(ULONG) COEnumConnectionPoints::AddRef(void)
00240 {
00241   ULONG cRefs;
00242
00243   cRefs = ++m_cRefs;
00244
00245   // Also AddRef the host object to ensure it stays around as long as
00246   // this enumerator.
00247   m_pHostObj->AddRef();
00248
00249   return cRefs;
00250 }
00251
00252
00253 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00254   Method:   COEnumConnectionPoints::Release
00255
00256   Summary:  Release of the COEnumConnectionPoints non-delegating IUnknown
00257             implementation.
00258
00259   Args:     void
00260
00261   Modifies: m_cRefs.
00262
00263   Returns:  ULONG
00264               New value of m_cRefs (COM object's reference count).
00265 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00266 STDMETHODIMP_(ULONG) COEnumConnectionPoints::Release(void)
00267 {
00268   ULONG cRefs;
00269
00270   // Pass this release along to the Host object being enumerated.
00271   m_pHostObj->Release();
00272
00273   cRefs = --m_cRefs;
00274
00275   if (0 == cRefs)
00276   {
00277     // We artificially bump the main ref count to prevent reentrancy via
00278     // the main object destructor.
00279     m_cRefs++;
00280     delete this;
00281   }
00282
00283   return cRefs;
00284 }
00285
00286
00287 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00288   Method:   COEnumConnectionPoints::Next
00289
00290   Summary:  The Next member method of this IEnumConnectionPoints interface
00291             implementation. Called by outside clients of a
00292             COEnumConnectionPoints object to request that a number of next
00293             connection point interface pointers be deposited into an array
00294             supplied by the caller.
00295
00296   Args:     ULONG cReq
00297               Number of connection points requested for return (starting at
00298               the current Enumerator index).
00299             IConnectionPoint** paConnPts,
00300               Pointer to a caller's output array that will receive the
00301               enumerated IConnectionPoint interface pointers.
00302             ULONG* cEnumerated)
00303               Pointer to a ULONG variable that will contain the number of
00304               connection points actually enumerated by this call.
00305
00306   Returns:  HRESULT
00307               Standard result code. NOERROR for success.
00308 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00309 STDMETHODIMP COEnumConnectionPoints::Next(
00310                ULONG cReq,
00311                IConnectionPoint** paConnPts,
00312                ULONG* pcEnumerated)
00313 {
00314   HRESULT hr = NOERROR;
00315   ULONG cRet = 0;
00316
00317   // Make sure the argument values passed are valid.
00318   if (NULL != m_paConnPts)
00319   {
00320     if (NULL != paConnPts)
00321     {
00322       if (NULL != *paConnPts && m_iEnumIndex < m_cConnPts)
00323       {
00324         if (NULL != pcEnumerated)
00325           *pcEnumerated = 0L;
00326         else
00327           if (1L != cReq)
00328             hr = E_POINTER;
00329       }
00330       else
00331         hr = S_FALSE;
00332     }
00333     else
00334       hr = E_POINTER;
00335   }
00336   else
00337     hr = S_FALSE;
00338
00339   if (SUCCEEDED(hr))
00340   {
00341     // Starting at the current Enumerator index, loop to assign the
00342     // requested number of output connection point interface pointers.
00343     for (; m_iEnumIndex < m_cConnPts && cReq > 0;
00344            paConnPts++, cRet++, cReq--)
00345     {
00346       // Assign from the inside Enumerator array to the specified receiving
00347       // array.
00348       *paConnPts = m_paConnPts[m_iEnumIndex++];
00349       // After assigning a copy of an IConnectionPoint pointer, AddRef it.
00350       if (NULL != *paConnPts)
00351         (*paConnPts)->AddRef();
00352     }
00353
00354     // Assign the output number of connection points enumerated.
00355     if (NULL != pcEnumerated)
00356       *pcEnumerated = cRet;
00357   }
00358
00359   return hr;
00360 }
00361
00362
00363 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00364   Method:   COEnumConnectionPoints::Skip
00365
00366   Summary:  The Skip member method of this IEnumConnectionPoints interface
00367             implementation. Starting at the current Enumerator index, skip
00368             the specified number of connection point items.
00369
00370   Args:     ULONG cSkip
00371               Number of Connection Point items to skip.
00372
00373   Returns:  HRESULT
00374               Standard result code. NOERROR for success.
00375 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00376 STDMETHODIMP COEnumConnectionPoints::Skip(
00377                ULONG cSkip)
00378 {
00379   HRESULT hr = NOERROR;
00380
00381   // If there really is a connection point array and the requested
00382   // amount of skip does not exceed the number of connection points,
00383   // then bump the index by the requested skip amount.
00384   if (NULL != m_paConnPts && (m_iEnumIndex + cSkip) < m_cConnPts)
00385     m_iEnumIndex += cSkip;
00386   else
00387     hr = S_FALSE;
00388
00389   return hr;
00390 }
00391
00392
00393 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00394   Method:   COEnumConnectionPoints::Reset
00395
00396   Summary:  The Reset member method of the IEnumConnectionPoints interface
00397             implementation. Resets the Enumeration index to the first
00398             connection point item in the array.
00399
00400   Args:     void.
00401
00402   Returns:  HRESULT
00403               Standard result code. NOERROR for success.
00404 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00405 STDMETHODIMP COEnumConnectionPoints::Reset(
00406                void)
00407 {
00408   // Zero the main Enumerator index.
00409   m_iEnumIndex = 0;
00410
00411   return NOERROR;
00412 }
00413
00414
00415 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00416   Method:   COEnumConnectionPoints::Clone
00417
00418   Summary:  The Clone member method of this IEnumConnectionPoints
00419             interface implementation. Creates a new clone of this entire
00420             Connection Point enumerator COM object.
00421
00422   Args:     IEnumConnectionPoints** ppIEnum
00423               Address of the caller's output pointer variable that will
00424               receive the IEnumConnectionPoints interface pointer of the
00425               new enumerator clone.
00426
00427   Returns:  HRESULT
00428               Standard result code. NOERROR for success.
00429 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00430 STDMETHODIMP COEnumConnectionPoints::Clone(
00431                IEnumConnectionPoints** ppIEnum)
00432 {
00433   HRESULT hr;
00434   COEnumConnectionPoints* pCOEnum;
00435
00436   // NULL the output variable first.
00437   *ppIEnum = NULL;
00438
00439   // Create the Clone Enumerator COM object.
00440   pCOEnum = new COEnumConnectionPoints(m_pHostObj);
00441   if (NULL != pCOEnum)
00442   {
00443     // Initialize it with same values as in this existing enumerator.
00444     hr = pCOEnum->Init(m_cConnPts, m_paConnPts, m_iEnumIndex);
00445     if (SUCCEEDED(hr))
00446     {
00447       // QueryInterface to return the requested interface pointer.
00448       // An AddRef will be conveniently done by the QI.
00449       if (SUCCEEDED(hr))
00450         hr = pCOEnum->QueryInterface(
00451                         IID_IEnumConnectionPoints,
00452                         (PPVOID)ppIEnum);
00453     }
00454   }
00455   else
00456     hr = E_OUTOFMEMORY;
00457
00458   return hr;
00459 }
00460
00461
00462 /*---------------------------------------------------------------------------
00463   COConnectionPoint's implementation of its main COM object class
00464   including Constructor, Destructor, QueryInterface, AddRef, Release,
00465   GetConnectionInterface, GetConnectionPointContainer, Advise, Unadvise,
00466   and EnumConnections.
00467 ---------------------------------------------------------------------------*/
00468
00469 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00470   Method:   COConnectionPoint::COConnectionPoint
00471
00472   Summary:  COConnectionPoint Constructor.
00473
00474   Args:     IUnknown* pHostObj
00475               Pointer to IUnknown of the connectable object offering this
00476               connection point.
00477
00478   Returns:  void
00479 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00480 COConnectionPoint::COConnectionPoint(
00481   IUnknown* pHostObj)
00482 {
00483   // Zero the COM object's reference count.
00484   m_cRefs = 0;
00485
00486   // Remember an IUnknown pointer to the connectable object that offers
00487   // this connection point. Since this connection point object's lifetime
00488   // is geared to that of the connectable object there is no need to
00489   // AddRef the following copied pointer to the connectable object.
00490   m_pHostObj = pHostObj;
00491
00492   // Initialize the Connection Point variables.
00493   m_dwNextCookie = COOKIE_START_VALUE;
00494   m_uiMaxIndex = 0;
00495   m_cConnections = 0;
00496   m_paConnections = NULL;
00497
00498   return;
00499 }
00500
00501
00502 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00503   Method:   COConnectionPoint::~COConnectionPoint
00504
00505   Summary:  COConnectionPoint Destructor.
00506
00507   Args:     void
00508
00509   Modifies: m_paConnections.
00510
00511   Returns:  void
00512 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00513 COConnectionPoint::~COConnectionPoint(void)
00514 {
00515   UINT i;
00516   IUnknown* pUnk;
00517
00518   if (NULL != m_paConnections)
00519   {
00520     // Release all the connection sink interface pointers.
00521     for (i=0; i<m_uiMaxIndex; i++)
00522     {
00523       pUnk = m_paConnections[i].pUnk;
00524       if (NULL != pUnk)
00525         pUnk->Release();
00526     }
00527
00528     // Delete the array of interface pointers.
00529     delete [] m_paConnections;
00530   }
00531
00532   return;
00533 }
00534
00535
00536 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00537   Method:   COConnectionPoint::Init
00538
00539   Summary:  COConnectionPoint Initialization method.  Create any
00540             necessary arrays, structures, and subordinate objects.
00541
00542   Args:     REFIID riid
00543               Reference to the IID of the Sink interface associated with
00544               this connection point.
00545
00546   Returns:  HRESULT
00547               Standard result code. NOERROR for success.
00548 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00549 HRESULT COConnectionPoint::Init(
00550           REFIID riid)
00551 {
00552   HRESULT hr = NOERROR;
00553   CONNECTDATA* paConns;
00554
00555   // Keep a copy of the reference to the IID of the sink interface
00556   // associated with this connection point. Needed for later
00557   // use by the GetConnectionInterface method.
00558   m_iidSink = riid;
00559
00560   // Build the initial dynamic array for connections.
00561   paConns = new CONNECTDATA[ALLOC_CONNECTIONS];
00562   if (NULL != paConns)
00563   {
00564     // Zero the array.
00565     memset(paConns, 0, ALLOC_CONNECTIONS * sizeof(CONNECTDATA));
00566
00567     // Rig this connection point object so that it will use the
00568     // new internal array of connections.
00569     m_uiMaxIndex = ALLOC_CONNECTIONS;
00570     m_paConnections = paConns;
00571   }
00572   else
00573     hr = E_OUTOFMEMORY;
00574
00575   return (hr);
00576 }
00577
00578
00579 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00580   Method:   COConnectionPoint::QueryInterface
00581
00582   Summary:  QueryInterface of the COConnectionPoint non-delegating
00583             IUnknown implementation.
00584
00585   Args:     REFIID riid,
00586               [in] GUID of the Interface being requested.
00587             PPVOID ppv)
00588               [out] Address of the caller's pointer variable that will
00589               receive the requested interface pointer.
00590
00591   Returns:  HRESULT
00592 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00593 STDMETHODIMP COConnectionPoint::QueryInterface(
00594                REFIID riid,
00595                PPVOID ppv)
00596 {
00597   HRESULT hr = E_NOINTERFACE;
00598
00599   *ppv = NULL;
00600
00601   // The IConnectionPoint interface is implemented directly in this
00602   // COM object rather than being a nested interface implementation.
00603   if (IID_IUnknown == riid || IID_IConnectionPoint == riid)
00604     *ppv = (LPVOID)this;
00605
00606   if (NULL != *ppv)
00607   {
00608     // We've handed out a pointer to the interface so obey the COM rules
00609     // and AddRef the reference count.
00610     ((LPUNKNOWN)*ppv)->AddRef();
00611     hr = NOERROR;
00612   }
00613
00614   return (hr);
00615 }
00616
00617
00618 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00619   Method:   COConnectionPoint::AddRef
00620
00621   Summary:  AddRef of the COConnectionPoint non-delegating IUnknown
00622             implementation.
00623
00624   Args:     void
00625
00626   Modifies: m_cRefs.
00627
00628   Returns:  ULONG
00629               New value of m_cRefs (COM object's reference count).
00630 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00631 STDMETHODIMP_(ULONG) COConnectionPoint::AddRef(void)
00632 {
00633   ULONG cRefs;
00634
00635   cRefs = ++m_cRefs;
00636
00637   return cRefs;
00638 }
00639
00640
00641 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00642   Method:   COConnectionPoint::Release
00643
00644   Summary:  Release of the COConnectionPoint non-delegating IUnknown
00645             implementation.
00646
00647   Args:     void
00648
00649   Modifies: m_cRefs.
00650
00651   Returns:  ULONG
00652               New value of m_cRefs (COM object's reference count).
00653 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00654 STDMETHODIMP_(ULONG) COConnectionPoint::Release(void)
00655 {
00656   ULONG cRefs;
00657
00658   cRefs = --m_cRefs;
00659
00660   if (0 == cRefs)
00661   {
00662     // We artificially bump the main ref count to prevent reentrancy via
00663     // the main object destructor. We relinquish thread ownership of this
00664     // object prior to deleting it--a good practice.
00665     m_cRefs++;
00666     delete this;
00667   }
00668
00669   return cRefs;
00670 }
00671
00672
00673 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00674   Method:   COConnectionPoint::GetSlot
00675
00676   Summary:  An internal private utility member method to obtain a free
00677             slot in the dynamic connections array. GetSlot will expand the
00678             dynamic array for more entries if needed.
00679
00680   Args:     UINT* puiFreeSlot
00681               Address of an output variable to receive the free slot index.
00682
00683   Modifies: m_uiMaxIndex, m_paConnections.
00684
00685   Returns:  HRESULT
00686               Standard result code. NOERROR for success.
00687 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00688 HRESULT COConnectionPoint::GetSlot(
00689           UINT* puiFreeSlot)
00690 {
00691   HRESULT hr = NOERROR;
00692   BOOL bOpen = FALSE;
00693   UINT i;
00694   CONNECTDATA* paConns;
00695
00696   // Zero the output variable.
00697   *puiFreeSlot = 0;
00698
00699   // Loop to find an empty slot.
00700   for (i=0; i<m_uiMaxIndex; i++)
00701   {
00702     if (m_paConnections[i].dwCookie == 0)
00703     {
00704       // We found an open empty slot.
00705       *puiFreeSlot = i;
00706       bOpen = TRUE;
00707       break;
00708     }
00709   }
00710
00711   if (!bOpen)
00712   {
00713     // We didn't find an existing open slot in the array--it's full.
00714     // Expand the array by ALLOC_CONNECTIONS entries and assign the
00715     // appropriate output index.
00716     paConns = new CONNECTDATA[m_uiMaxIndex + ALLOC_CONNECTIONS];
00717     if (NULL != paConns)
00718     {
00719       // Copy the content of the old full array to the new larger array.
00720       for (i=0; i<m_uiMaxIndex; i++)
00721       {
00722         paConns[i].pUnk = m_paConnections[i].pUnk;
00723         paConns[i].dwCookie = m_paConnections[i].dwCookie;
00724       }
00725
00726       // Zero (ie mark as empty) the expanded portion of the new array.
00727       for (i=m_uiMaxIndex; i<m_uiMaxIndex+ALLOC_CONNECTIONS; i++)
00728       {
00729         paConns[i].pUnk = NULL;
00730         paConns[i].dwCookie = 0;
00731       }
00732
00733       // New larger array is ready--delete the old array.
00734       delete [] m_paConnections;
00735
00736       // Rig the connection point to use the new larger array.
00737       m_paConnections = paConns;
00738
00739       // Assign the output free slot as first entry in new expanded area.
00740       *puiFreeSlot = m_uiMaxIndex;
00741
00742       // Calculate the new max index.
00743       m_uiMaxIndex += ALLOC_CONNECTIONS;
00744     }
00745     else
00746       hr = E_OUTOFMEMORY;
00747   }
00748
00749   return hr;
00750 }
00751
00752
00753 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00754   Method:   COConnectionPoint::FindSlot
00755
00756   Summary:  An internal private utility member method to find an existing
00757             slot (identified by the specified dwCookie value) in the
00758             dynamic connections array.
00759
00760   Args:     DWORD dwCookie,
00761               The connection key (cookie) to find.
00762             UINT* puiSlot)
00763               Address of an output variable to receive the slot index.
00764
00765   Returns:  HRESULT
00766               Standard result code. NOERROR for success.
00767 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00768 HRESULT COConnectionPoint::FindSlot(
00769           DWORD dwCookie,
00770           UINT* puiSlot)
00771 {
00772   HRESULT hr = CONNECT_E_NOCONNECTION;
00773   UINT i;
00774
00775   // Loop to find the Cookie.
00776   for (i=0; i<m_uiMaxIndex; i++)
00777   {
00778     if (dwCookie == m_paConnections[i].dwCookie)
00779     {
00780       // If a cookie match is found, assign the output slot index.
00781       *puiSlot = i;
00782       hr = NOERROR;
00783       break;
00784     }
00785   }
00786
00787   return hr;
00788 }
00789
00790
00791 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00792   Method:   COConnectionPoint::GetConnectionInterface
00793
00794   Summary:  The GetConnectionInterface member method of this
00795             IConnectionPoint interface implementation. Called to get the
00796             IID of the Sink interface associated with this connection
00797             point.
00798
00799   Args:     IID* piidSink
00800               Pointer to the IID of the associated sink interface.
00801
00802   Returns:  HRESULT
00803               Standard result code. NOERROR for success.
00804 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00805 STDMETHODIMP COConnectionPoint::GetConnectionInterface(
00806                IID* piidSink)
00807 {
00808   HRESULT hr = NOERROR;
00809
00810   if (NULL != piidSink)
00811     *piidSink = m_iidSink;
00812   else
00813     hr = E_POINTER;
00814
00815   return hr;
00816 }
00817
00818
00819 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00820   Method:   COConnectionPoint::GetConnectionPointContainer
00821
00822   Summary:  The GetConnectionPointContainer member method of this
00823             IConnectionPoint interface implementation. Called to get the
00824             connection point container that contains this connection
00825             point.
00826
00827   Args:     IConnectionPointContainer** ppConnPtCon
00828               Address of the pointer variable that will recieve the
00829               IConnectionPointContainer interface pointer.
00830
00831   Returns:  HRESULT
00832               Standard result code. NOERROR for success.
00833 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00834 STDMETHODIMP COConnectionPoint::GetConnectionPointContainer(
00835                IConnectionPointContainer** ppConnPtCon)
00836 {
00837   HRESULT hr;
00838
00839   // Use QueryInterface to get the interface pointer and to perform the
00840   // needed AddRef on the returned pointer.
00841   hr = m_pHostObj->QueryInterface(
00842                      IID_IConnectionPointContainer,
00843                      (PPVOID) ppConnPtCon);
00844
00845   return hr;
00846 }
00847
00848
00849 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00850   Method:   COConnectionPoint::Advise
00851
00852   Summary:  The Advise member method of this IConnectionPoint interface
00853             implementation. Called by clients to establish a connection of
00854             their sink to this connection point.
00855
00856   Args:     IUnknown* pUnkSink
00857               IUnknown interface pointer of the Sink object in the client.
00858             DWORD* pdwCookie
00859               Pointer to a DWORD in the client that will receive a unique
00860               key used by the client to refer to the connection established
00861               by this Advise call.
00862
00863   Returns:  HRESULT
00864               Standard result code. NOERROR for success.
00865 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00866 STDMETHODIMP COConnectionPoint::Advise(
00867                IUnknown* pUnkSink,
00868                DWORD* pdwCookie)
00869 {
00870   HRESULT hr = NOERROR;
00871   UINT uiFreeSlot = 0;
00872   IUnknown* pISink = NULL;
00873
00874   // Zero the output connection key.
00875   *pdwCookie = 0;
00876
00877   // Get the specific associated client Sink interface that this
00878   // connection point expects to use for notifications.
00879   hr = pUnkSink->QueryInterface(m_iidSink, (PPVOID)&pISink);
00880   if (SUCCEEDED(hr))
00881   {
00882     // Store the specific sink interface in this connection point's
00883     // array of live connections. First find a free slot (expand the
00884     // array if needed).
00885     hr = GetSlot(&uiFreeSlot);
00886     if (SUCCEEDED(hr))
00887     {
00888       // Assign the new slot with the connection entry.
00889       m_paConnections[uiFreeSlot].pUnk = pISink;
00890       m_paConnections[uiFreeSlot].dwCookie = m_dwNextCookie;
00891
00892       // Assign the output Cookie value.
00893       *pdwCookie = m_dwNextCookie;
00894
00895       // Increment the Cookie counter.
00896       m_dwNextCookie++;
00897
00898       // Increment the number of live connections.
00899       m_cConnections++;
00900     }
00901   }
00902   else if (hr == E_NOINTERFACE)
00903   {
00904      // The sink does not support m_iidSink.
00905      hr = CONNECT_E_CANNOTCONNECT;
00906   }
00907
00908   return hr;
00909 }
00910
00911
00912 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00913   Method:   COConnectionPoint::Unadvise
00914
00915   Summary:  The Unadvise member method of this IConnectionPoint interface
00916             implementation. Called by clients to disconnect a connection
00917             of their sink to this connection point. The connection is
00918             identified by the dwCookie argument (obtained by a previous
00919             Advise call).
00920
00921   Args:     DWORD dwCookie
00922               Connection key that was obtained by a previous Advise call.
00923
00924   Returns:  HRESULT
00925               Standard result code. NOERROR for success.
00926 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00927 STDMETHODIMP COConnectionPoint::Unadvise(
00928                DWORD dwCookie)
00929 {
00930   HRESULT hr = NOERROR;
00931   UINT uiSlot;
00932
00933   if (0 != dwCookie)
00934   {
00935     hr = FindSlot(dwCookie, &uiSlot);
00936     if (SUCCEEDED(hr))
00937     {
00938       // Release the sink interface.
00939       RELEASE_INTERFACE(m_paConnections[uiSlot].pUnk);
00940
00941       // Mark the array entry as empty.
00942       m_paConnections[uiSlot].dwCookie = 0;
00943
00944       // Decrement the number of live connections.
00945       m_cConnections--;
00946     }
00947   }
00948   else
00949     hr = E_INVALIDARG;
00950
00951   return hr;
00952 }
00953
00954
00955 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00956   Method:   COConnectionPoint::EnumConnections
00957
00958   Summary:  The EnumConnections member method of this IConnectionPoint
00959             interface implementation. Called to obtain an IEnumConnections
00960             enumerator interface that can be used to enumerate the
00961             connections of this connection point.
00962
00963   Args:     IEnumConnections** ppIEnum
00964               Address of the caller's output pointer variable that will
00965               receive the enumerator IEnumConnections interface pointer.
00966
00967   Returns:  HRESULT
00968               Standard result code. NOERROR for success.
00969 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00970 STDMETHODIMP COConnectionPoint::EnumConnections(
00971                IEnumConnections** ppIEnum)
00972 {
00973   HRESULT hr = OLE_E_NOCONNECTION;
00974   CONNECTDATA* paConns;
00975   COEnumConnections* pCOEnum;
00976   UINT i,j;
00977
00978   // Zero the output enumerator interface pointer.
00979   *ppIEnum = NULL;
00980
00981   if (0 != m_cConnections)
00982   {
00983     // Create an array of CONNECTDATA structures.
00984     paConns = new CONNECTDATA[(UINT)m_cConnections];
00985     if (NULL != paConns)
00986     {
00987       for (i=0, j=0; i<m_uiMaxIndex && j<m_cConnections; i++)
00988       {
00989         // Copy non-empty entries only.
00990         if (0 != m_paConnections[i].dwCookie)
00991         {
00992           // Assign the occupied entry.
00993           paConns[j].pUnk = (IUnknown*)m_paConnections[i].pUnk;
00994           paConns[j].dwCookie = m_paConnections[i].dwCookie;
00995           j++;
00996         }
00997       }
00998
00999       // Create a new COM object for enumerating connections. Pass
01000       // 'this' as a pHostObj pointer used later to ensure the host
01001       // connection point object stays alive as long as the enumerator
01002       // that enumerates connections to that connection point.
01003       pCOEnum = new COEnumConnections(this);
01004       if (NULL != pCOEnum)
01005       {
01006         // Use the previously constructed (paConns) array of connections
01007         // to init the new COEnumConnections COM object. The Init will
01008         // build yet another internal copy of this array. Set the
01009         // initial enumerator index to 0.
01010         hr = pCOEnum->Init(m_cConnections, paConns, 0);
01011
01012         // QueryInterface to return the requested interface pointer.
01013         // An AddRef will be conveniently done by the QI.
01014         if (SUCCEEDED(hr))
01015           hr = pCOEnum->QueryInterface(
01016                           IID_IEnumConnections,
01017                           (PPVOID)ppIEnum);
01018       }
01019       else
01020         hr = E_OUTOFMEMORY;
01021
01022       // We're done with the locally constructed array copy--delete it.
01023       delete [] paConns;
01024     }
01025     else
01026       hr = E_OUTOFMEMORY;
01027   }
01028
01029   return hr;
01030 }
01031
01032
01033 /*---------------------------------------------------------------------------
01034   COEnumConnections's implementation of its main COM object class
01035   including Constructor, Destructor, QueryInterface, AddRef, Release,
01036   Next, Skip, Reset, and Clone.
01037 ---------------------------------------------------------------------------*/
01038
01039 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01040   Method:   COEnumConnections::COEnumConnections
01041
01042   Summary:  COEnumConnections Constructor.
01043
01044   Args:     IUnknown* pHostObj
01045               Pointer to IUnknown interface of the host Connection Point
01046               COM object whose connections are being enumerated.
01047
01048   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnections,
01049             and m_paConnections.
01050
01051   Returns:  void
01052 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01053 COEnumConnections::COEnumConnections(
01054   IUnknown* pHostObj)
01055 {
01056   // Zero the COM object's reference count.
01057   m_cRefs = 0;
01058
01059   // Assign the Host Object pointer.
01060   m_pHostObj = pHostObj;
01061
01062   // Initialize the Connection Point enumerator variables.
01063   m_iEnumIndex = 0;
01064   m_cConnections = 0;
01065   m_paConnections = NULL;
01066
01067   return;
01068 }
01069
01070
01071 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01072   Method:   COEnumConnections::~COEnumConnections
01073
01074   Summary:  COEnumConnections Destructor.
01075
01076   Args:     void
01077
01078   Modifies: m_paConnections.
01079
01080   Returns:  void
01081 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01082 COEnumConnections::~COEnumConnections(void)
01083 {
01084   if (NULL != m_paConnections)
01085   {
01086     UINT i;
01087
01088     // Release all the connected sink interface pointers.
01089     for (i=0; i<m_cConnections; i++)
01090       m_paConnections[i].pUnk->Release();
01091
01092     // Delete the array of connections.
01093     delete [] m_paConnections;
01094   }
01095
01096   return;
01097 }
01098
01099
01100 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01101   Method:   COEnumConnections::Init
01102
01103   Summary:  COEnumConnections Initialization method.  Create any
01104             necessary arrays, structures, and objects.
01105
01106   Args:     ULONG cConnections
01107               Number of Connections.
01108             CONNECTDATA* paConnections,
01109               Pointer to array of connections.
01110             ULONG iEnumIndex
01111               The Enumerator index initial value.
01112
01113   Modifies: m_cConnections, m_paConnections, m_pHostObj, m_iEnumIndex.
01114
01115   Returns:  HRESULT
01116               Standard result code. NOERROR for success.
01117 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01118 HRESULT COEnumConnections::Init(
01119           ULONG cConnections,
01120           CONNECTDATA* paConnections,
01121           ULONG iEnumIndex)
01122 {
01123   HRESULT hr = NOERROR;
01124   UINT i;
01125
01126   // Remember the number of live Connections.
01127   m_cConnections = cConnections;
01128
01129   // Remember the initial enumerator index.
01130   m_iEnumIndex = iEnumIndex;
01131
01132   // Create a copy of the array of connections and keep it inside
01133   // this enumerator COM object.
01134   m_paConnections = new CONNECTDATA [(UINT) cConnections];
01135
01136   // Fill the array copy with the connection data from the connections
01137   // array passed. AddRef for each new sink Interface pointer copy made.
01138   if (NULL != m_paConnections)
01139   {
01140     for (i=0; i<cConnections; i++)
01141     {
01142       m_paConnections[i] = paConnections[i];
01143       m_paConnections[i].pUnk->AddRef();
01144     }
01145   }
01146   else
01147     hr = E_OUTOFMEMORY;
01148
01149   return (hr);
01150 }
01151
01152
01153 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01154   Method:   COEnumConnections::QueryInterface
01155
01156   Summary:  QueryInterface of the COEnumConnections non-delegating
01157             IUnknown implementation.
01158
01159   Args:     REFIID riid,
01160               [in] GUID of the Interface being requested.
01161             PPVOID ppv)
01162               [out] Address of the caller's pointer variable that will
01163               receive the requested interface pointer.
01164
01165   Returns:  HRESULT
01166 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01167 STDMETHODIMP COEnumConnections::QueryInterface(
01168                REFIID riid,
01169                PPVOID ppv)
01170 {
01171   HRESULT hr = E_NOINTERFACE;
01172
01173   *ppv = NULL;
01174
01175   // The IEnumConnections interface is implemented directly in this
01176   // COM object rather than being a nested interface implementation.
01177   if (IID_IUnknown == riid || IID_IEnumConnections == riid)
01178     *ppv = (LPVOID)this;
01179
01180   if (NULL != *ppv)
01181   {
01182     // We've handed out a pointer to the interface so obey the COM rules
01183     // and AddRef the reference count.
01184     ((LPUNKNOWN)*ppv)->AddRef();
01185     hr = NOERROR;
01186   }
01187
01188   return (hr);
01189 }
01190
01191
01192 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01193   Method:   COEnumConnections::AddRef
01194
01195   Summary:  AddRef of the COEnumConnections non-delegating IUnknown
01196             implementation.
01197
01198   Args:     void
01199
01200   Modifies: m_cRefs.
01201
01202   Returns:  ULONG
01203               New value of m_cRefs (COM object's reference count).
01204 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01205 STDMETHODIMP_(ULONG) COEnumConnections::AddRef(void)
01206 {
01207   ULONG cRefs;
01208
01209   cRefs = ++m_cRefs;
01210
01211   // Also AddRef the host object to ensure it stays around as long as
01212   // this enumerator.
01213   m_pHostObj->AddRef();
01214
01215   return cRefs;
01216 }
01217
01218
01219 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01220   Method:   COEnumConnections::Release
01221
01222   Summary:  Release of the COEnumConnections non-delegating IUnknown
01223             implementation.
01224
01225   Args:     void
01226
01227   Modifies: m_cRefs.
01228
01229   Returns:  ULONG
01230               New value of m_cRefs (COM object's reference count).
01231 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01232 STDMETHODIMP_(ULONG) COEnumConnections::Release(void)
01233 {
01234   ULONG cRefs;
01235
01236   // Pass this release along to the Host object being enumerated.
01237   m_pHostObj->Release();
01238
01239   cRefs = --m_cRefs;
01240
01241   if (0 == cRefs)
01242   {
01243     // We artificially bump the main ref count to prevent reentrancy via
01244     // the main object destructor.
01245     m_cRefs++;
01246     delete this;
01247   }
01248
01249   return cRefs;
01250 }
01251
01252
01253 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01254   Method:   COEnumConnections::Next
01255
01256   Summary:  The Next member method of this IEnumConnections interface
01257             implementation. Called by outside clients of a
01258             COEnumConnections object to request a number of next
01259             connections be returned in an array supplied by the caller.
01260
01261   Args:     ULONG cReq
01262               Number of connection points requested for return (starting at
01263               the current Enumerator index).
01264             CONNECTDATA* paConnections,
01265               Pointer to a caller's output array that will receive the
01266               enumerated connection data structures.
01267             ULONG* pcEnumerated)
01268               Pointer to a ULONG variable that will contain the number of
01269               connection points actually enumerated by this call.
01270
01271   Returns:  HRESULT
01272               Standard result code. NOERROR for success.
01273 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01274 STDMETHODIMP COEnumConnections::Next(
01275                ULONG cReq,
01276                CONNECTDATA* paConnections,
01277                ULONG* pcEnumerated)
01278 {
01279   HRESULT hr = NOERROR;
01280   ULONG cRet = 0;
01281
01282   // Make sure the argument values passed are valid.
01283   if (NULL != m_paConnections)
01284   {
01285     if (NULL != paConnections)
01286     {
01287       if (m_iEnumIndex < m_cConnections)
01288       {
01289         if (NULL != pcEnumerated)
01290           *pcEnumerated = 0L;
01291         else
01292           if (1L != cReq)
01293             hr = E_POINTER;
01294       }
01295       else
01296         hr = S_FALSE;
01297     }
01298     else
01299       hr = E_POINTER;
01300   }
01301   else
01302     hr = S_FALSE;
01303
01304   if (SUCCEEDED(hr))
01305   {
01306     // Starting at the current Enumerator index, loop to assign the
01307     // requested number of output connection data structures.
01308     for (; m_iEnumIndex < m_cConnections && cReq > 0;
01309            paConnections++, m_iEnumIndex++, cRet++, cReq--)
01310     {
01311       // Because we are assigning a copy of a connection's data, AddRef
01312       // its sink interface pointer.
01313       if (NULL != m_paConnections[m_iEnumIndex].pUnk)
01314         m_paConnections[m_iEnumIndex].pUnk->AddRef();
01315
01316       // Assign a connection's data from the inside Enumerator array to
01317       // the specified output receiving array.
01318       *paConnections = m_paConnections[m_iEnumIndex];
01319     }
01320
01321     // Assign the output number of connections enumerated.
01322     if (NULL != pcEnumerated)
01323       *pcEnumerated = cRet;
01324   }
01325
01326   return hr;
01327 }
01328
01329
01330 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01331   Method:   COEnumConnections::Skip
01332
01333   Summary:  The Skip member method of this IEnumConnections interface
01334             implementation. Starting at the current Enumerator index, skip
01335             the specified number of connection items.
01336
01337   Args:     ULONG cSkip
01338               Number of Connection items to skip.
01339
01340   Returns:  HRESULT
01341               Standard result code. NOERROR for success.
01342 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01343 STDMETHODIMP COEnumConnections::Skip(
01344                ULONG cSkip)
01345 {
01346   HRESULT hr = NOERROR;
01347
01348   // If there really is a connection array and the requested
01349   // amount of skip does not exceed the number of connections,
01350   // then bump the index by the requested skip amount.
01351   if (NULL != m_paConnections && (m_iEnumIndex + cSkip) < m_cConnections)
01352     m_iEnumIndex += cSkip;
01353   else
01354     hr = S_FALSE;
01355
01356   return hr;
01357 }
01358
01359
01360 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01361   Method:   COEnumConnections::Reset
01362
01363   Summary:  The Reset member method of the IEnumConnections interface
01364             implementation. Resets the Enumeration index to the first
01365             connection item in the array.
01366
01367   Args:     void.
01368
01369   Returns:  HRESULT
01370               Standard result code. NOERROR for success.
01371 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01372 STDMETHODIMP COEnumConnections::Reset(
01373                void)
01374 {
01375   // Zero the main Enumerator index.
01376   m_iEnumIndex = 0;
01377
01378   return NOERROR;
01379 }
01380
01381
01382 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01383   Method:   COEnumConnections::Clone
01384
01385   Summary:  The Clone member method of this IEnumConnections interface
01386             implementation. Creates a new clone of this entire Connection
01387             enumerator COM object and returns a pointer to its
01388             IEnumConnections interface.
01389
01390   Args:     IEnumConnections** ppIEnum
01391               Address of the caller's output pointer variable that will
01392               receive the IEnumConnections interface pointer of the
01393               new enumerator clone.
01394
01395   Returns:  HRESULT
01396               Standard result code. NOERROR for success.
01397 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01398 STDMETHODIMP COEnumConnections::Clone(
01399                IEnumConnections** ppIEnum)
01400 {
01401   HRESULT hr;
01402   COEnumConnections* pCOEnum;
01403
01404   // NULL the output variable first.
01405   *ppIEnum = NULL;
01406
01407   // Create the Clone Enumerator COM object.
01408   pCOEnum = new COEnumConnections(m_pHostObj);
01409   if (NULL != pCOEnum)
01410   {
01411     // Initialize it with same values as in this existing enumerator.
01412     hr = pCOEnum->Init(m_cConnections, m_paConnections, m_iEnumIndex);
01413     if (SUCCEEDED(hr))
01414     {
01415       // QueryInterface to return the requested interface pointer.
01416       // An AddRef will be conveniently done by the QI.
01417       if (SUCCEEDED(hr))
01418         hr = pCOEnum->QueryInterface(
01419                         IID_IEnumConnections,
01420                         (PPVOID)ppIEnum);
01421     }
01422   }
01423   else
01424     hr = E_OUTOFMEMORY;
01425
01426   return hr;
01427 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/cenum.h Source File

  • Dataaccess
  • oledb
  • rowsetviewer

cenum.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CENUM.H
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 #ifndef _CENUM_H_
00012 #define _CENUM_H_
00013
00014
00015 ///////////////////////////////////////////////////////////////
00016 // Includes
00017 //
00018 ///////////////////////////////////////////////////////////////
00019 #include "CBase.h"
00020 #include "CDataSource.h"
00021
00022
00023 ///////////////////////////////////////////////////////////////
00024 // Defines
00025 //
00026 ///////////////////////////////////////////////////////////////
00027 struct ENUMINFO
00028 {
00029   WCHAR     wszName[MAX_NAME_LEN];
00030   WCHAR     wszParseName[MAX_NAME_LEN];
00031   WCHAR     wszDescription[MAX_NAME_LEN];
00032   USHORT      eType;
00033   VARIANT_BOOL  fIsParent;
00034 };
00035
00036
00037
00038 /////////////////////////////////////////////////////////////////
00039 // CEnumerator class
00040 //
00041 /////////////////////////////////////////////////////////////////
00042 class CEnumerator : public CPropertiesBase
00043 {
00044 public:
00045   //Constructors
00046   CEnumerator(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild = NULL);
00047   virtual ~CEnumerator();
00048
00049   //IUnknown Helpers
00050   virtual HRESULT     AutoQI(DWORD dwCreateOpts);
00051   virtual HRESULT     AutoRelease();
00052   virtual IUnknown**    GetInterfaceAddress(REFIID riid);
00053
00054   //Pure Virtual
00055   virtual WCHAR*      GetObjectName()     { return L"Enumerator";     }
00056   virtual UINT      GetObjectMenu()     { return IDM_ENUMERATORMENU;  }
00057   virtual LONG      GetObjectImage()    { return IMAGE_OBJECTS;     }
00058   virtual REFIID      GetDefaultInterface() { return IID_ISourcesRowset;  }
00059   virtual WCHAR*      GetObjectDesc();
00060   virtual void      OnDefOperation();
00061
00062   //Connection
00063   virtual HRESULT     CreateInstance(CAggregate* pCAggregate, REFCLSID clsid, DWORD dwCLSCTX, REFIID riid, IUnknown** ppIUnknown, WCHAR* pwszRemoteServer = NULL);
00064   virtual HRESULT     ParseDisplayName(WCHAR* pwszParseName, DWORD dwCLSCTX, REFIID riid, IUnknown** ppIUnknown, CBase** ppCSource, DWORD dwConnectOpts = 0, WCHAR* pwszRemoteServer = NULL);
00065   virtual HRESULT     GetSourcesRowset(CAggregate* pCAggregate, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown);
00066
00067   virtual HRESULT     Create(REFCLSID clsid);
00068   virtual HRESULT     EnumerateInfo(ULONG* pcEnumInfo, ENUMINFO** prgEnumInfo);
00069   virtual HRESULT     CreateEnumInfo(REFCLSID clsid = GUID_NULL, BOOL fRefresh = FALSE);
00070
00071   //[MANDATORY]
00072   ISourcesRowset*     m_pISourcesRowset;        //Enumerator interface
00073   IParseDisplayName*    m_pIParseDisplayName;     //Enumerator interface
00074
00075   //[OPTIONAL]
00076
00077   //Enumerator ProvierInfo
00078   ULONG         m_cEnumInfo;
00079   ENUMINFO*       m_rgEnumInfo;
00080 };
00081
00082
00083 #endif  //_CENUM_H_
Generated on Wed Nov 13 2024 16:52:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Data/repas/Repasc.c Source File

  • NetDS
  • RPC
  • Data
  • repas

Repasc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                        repas Example
00005
00006     FILE:       repasc.c
00007
00008     USAGE:      repasc  -n network_address
00009                        -p protocol_sequence
00010                        -e endpoint
00011                        -o options
00012                        -c count of elements in linked list
00013                        -v value of first element in linked list
00014                        -d delta between values in linked list
00015
00016     PURPOSE:    Client side of RPC distributed application.
00017                 This sample demonstrates the represent_as example.
00018                 A char string is sent over the network as a unicode string.
00019
00020     RELATED:    repass.c - server main
00021                 repasp.c - remote procedures
00022                 repascu.c - client utility procedures
00023
00024     FUNCTIONS:  main() - bind to server and call remote procedure
00025
00026     COMMENTS:   This sample program generates a client and server can share
00027                 an interface, but one side can use a different representation
00028                 than the other.
00029
00030                 The client side in this example does all operations using
00031                 character strings, and the server side does all operations
00032                 using UNICODE strings.  Two procedures are provided, one
00033                 defined with ASCII strings, one with UNICODE strings.
00034                 The wire format reflects these definitions, yet the client
00035                 and server see pure ASCII and pure UNICODE respectively.
00036
00037                 The [represent_as] attribute (used in the client and server
00038                 side acf files) requires the four user-supplied functions
00039                 whose names start with the name of the transmitted type
00040                 (in the client side's case: WCHAR_STRING)
00041
00042                 The [in, out] attributes applied to remote procedure
00043                 parameters require the two user-supplied functions
00044                 midl_user_allocate and midl_user_free.
00045
00046                 The other functions are utilities that are used to
00047                 build or display the data structures.
00048
00049
00050 ****************************************************************************/
00051
00052 #include <stdlib.h>
00053 #include <stdio.h>
00054 #include <ctype.h>
00055 #include "repasc.h"    // client's side header file generated by MIDL compiler
00056
00057 #define PURPOSE \
00058 "This Microsoft RPC Version 2.0 sample program demonstrates\n\
00059 the use of the [represent_as] attribute. For more information\n\
00060 about the attributes and the RPC API functions, see the\n\
00061 RPC programming guide and reference.\n\n"
00062
00063 #define MAX_ELEMENTS 50
00064
00065 void Usage(char * pszProgramName)
00066 {
00067     fprintf(stderr, "%s", PURPOSE);
00068     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00069     fprintf(stderr, " -p protocol_sequence\n");
00070     fprintf(stderr, " -n network_address\n");
00071     fprintf(stderr, " -e endpoint\n");
00072     fprintf(stderr, " -o options\n");
00073     fprintf(stderr, " -c count_of_elements\n");
00074     fprintf(stderr, " -v value\n");
00075     fprintf(stderr, " -d delta\n");
00076     exit(1);
00077 }
00078
00079 void __cdecl main(int argc, char **argv)
00080 {
00081     RPC_STATUS status;
00082     unsigned char * pszUuid             = NULL;
00083     unsigned char * pszProtocolSequence = "ncacn_np";
00084     unsigned char * pszNetworkAddress   = NULL;
00085     unsigned char * pszEndpoint         = "\\pipe\\repas";
00086     unsigned char * pszOptions          = NULL;
00087     unsigned char * pszStringBinding    = NULL;
00088     int i;
00089     int cElements = 10;
00090     short sValue = 100;
00091     short sDelta = 10;
00092
00093     char    FirstBuffer[100];
00094
00095     /* allow the user to override settings with command line switches */
00096     for (i = 1; i < argc; i++) {
00097         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00098             switch (tolower(*(argv[i]+1))) {
00099             case 'p':  // protocol sequence
00100                 pszProtocolSequence = argv[++i];
00101                 break;
00102             case 'n':  // network address
00103                 pszNetworkAddress = argv[++i];
00104                 break;
00105             case 'e':
00106                 pszEndpoint = argv[++i];
00107                 break;
00108             case 'o':
00109                 pszOptions = argv[++i];
00110                 break;
00111             case 'c':
00112                 cElements = atoi(argv[++i]);
00113                 if (cElements > MAX_ELEMENTS)
00114                     cElements = MAX_ELEMENTS;
00115                 break;
00116             case 'v':
00117                 sValue = (short)atoi(argv[++i]);
00118                 break;
00119             case 'd':
00120                 sDelta = (short)atoi(argv[++i]);
00121                 break;
00122             case 'h':
00123             case '?':
00124             default:
00125                 Usage(argv[0]);
00126             }
00127         }
00128         else
00129             Usage(argv[0]);
00130     }
00131
00132     /* Use a convenience function to concatenate the elements of the string */
00133     /* binding into the syntax needed by RpcBindingFromStringBinding.       */
00134     status = RpcStringBindingCompose(pszUuid,
00135                                      pszProtocolSequence,
00136                                      pszNetworkAddress,
00137                                      pszEndpoint,
00138                                      pszOptions,
00139                                      &pszStringBinding);
00140     printf("RpcStringBindingCompose returned 0x%x\n", status);
00141     printf("pszStringBinding = %s\n", pszStringBinding);
00142     if (status) {
00143         exit(status);
00144     }
00145
00146     /* Set the binding handle that will be used to bind to the server. */
00147     status = RpcBindingFromStringBinding(pszStringBinding,
00148                                          &hrepas);
00149     printf("RpcBindingFromStringBinding returned 0x%x\n", status);
00150     if (status) {
00151         exit(status);
00152     }
00153
00154     RpcTryExcept {
00155         // initialize a string to be shipped
00156         strcpy(FirstBuffer,"This ASCII string is sent from the client to the server as UNICODE");
00157
00158         printf("\nThe Client side is about to send:\n\"%s\"\n\n", FirstBuffer );
00159
00160         printf("Calling the remote procedure 'ModifyMyWString'\n");
00161         // note that the client sees the interface using ascii, not unicode
00162         ModifyMyWString( &FirstBuffer );
00163         printf("The Client side got back:\n\"%s\"\n\n", FirstBuffer );
00164
00165
00166         // initialize a string to be shipped
00167         strcpy(FirstBuffer,"And this ASCII string is sent from the client to the server as ASCII");
00168
00169         printf("The Client side is about to send:\n\"%s\"\n\n", FirstBuffer );
00170         printf("Calling the remote procedure 'ModifyMyString'\n");
00171         // note that the client sees the interface using ascii
00172         ModifyMyString( &FirstBuffer );
00173         printf("The Client side got back:\n\"%s\"\n\n", FirstBuffer );
00174
00175         printf("Calling the remote procedure 'Shutdown'\n");
00176         Shutdown();  // shut down the server side
00177     }
00178     RpcExcept(1) {
00179         printf("Runtime reported exception %ld\n", RpcExceptionCode() );
00180     }
00181     RpcEndExcept
00182
00183     /* The calls to the remote procedures are complete.            */
00184     /* Free the string and the binding handle using RPC API calls. */
00185     status = RpcStringFree(&pszStringBinding);
00186     printf("RpcStringFree returned 0x%x\n", status);
00187     if (status) {
00188         exit(status);
00189     }
00190
00191     status = RpcBindingFree(&hrepas);
00192     printf("RpcBindingFree returned 0x%x\n", status);
00193     if (status) {
00194         exit(status);
00195     }
00196
00197     exit(0);
00198
00199 }  // end main()
00200
00201 /* end file repasc.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/customdrawbuttondlg/CustomDrawButtonDlg.h Source File

  • WinUI
  • Shell
  • customdrawbuttondlg

CustomDrawButtonDlg.h

Go to the documentation of this file.
00001 #pragma once
00002
00003 #include "resource.h"
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/HelpDll/helpdll.Cpp Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • HelpDll

helpdll.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #include "stdafx.h"
00019 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00020   Function: DllMain
00021 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00022
00023 BOOL WINAPI DllMain(HMODULE hModule,DWORD dwReason,LPVOID lpReserved){
00024   UNREFERENCED_PARAMETER(lpReserved);
00025   if (dwReason == DLL_PROCESS_ATTACH){
00026     DisableThreadLibraryCalls(hModule);
00027   };
00028   return TRUE;
00029 }
00030
00031 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00032   Function: GetCallObject
00033   Summary:  This function passes non automation compliant parameters through
00034       to the call factory
00035   Args:     The call factory and the arguments to CreateCall
00036   Returns:  HRESULT - the result of CreateCall
00037 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00038 extern "C" __declspec(dllexport) __stdcall GetCallObject(ICallFactory* pCf,
00039           REFIID riid1,
00040           IUnknown* pUnkOuter,
00041           REFIID riid2,
00042           IUnknown** ppv ) {
00043   return  pCf->CreateCall(riid1,pUnkOuter,riid2,ppv);
00044 }
00045
00046 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00047   Function: WaitCallObject
00048   Summary:  Allows the VB client to call ISynchronize::Wait on the call object
00049   Returns:  HRESULT - the result of Wait
00050 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00051 extern "C" __declspec(dllexport) __stdcall WaitCallObject(ISynchronize* pSync,
00052               DWORD dwMilli){
00053     return pSync->Wait(0, dwMilli);
00054 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/CrmDebug/DllDatax.c Source File

  • Com
  • Services
  • Crm
  • CrmDebug

DllDatax.c

Go to the documentation of this file.
00001 // wrapper for dlldata.c
00002
00003 #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
00004
00005 #define REGISTER_PROXY_DLL //DllRegisterServer, etc.
00006
00007 #if !defined(_WIN32_WINNT)
00008 #define _WIN32_WINNT 0x0500
00009 #endif // !defined(_WIN32_WINNT)
00010 #define USE_STUBLESS_PROXY  //defined only with MIDL switch /Oicf
00011
00012 #pragma comment(lib, "rpcndr.lib")
00013 #pragma comment(lib, "rpcns4.lib")
00014 #pragma comment(lib, "rpcrt4.lib")
00015
00016 #define DllMain       PrxDllMain
00017 #define DllRegisterServer PrxDllRegisterServer
00018 #define DllUnregisterServer PrxDllUnregisterServer
00019 #define DllGetClassObject   PrxDllGetClassObject
00020 #define DllCanUnloadNow     PrxDllCanUnloadNow
00021
00022 #include "dlldata.c"
00023 #include "CrmDebug_p.c"
00024
00025 #ifdef _NOPROXY //no midl generated dlldata.c
00026
00027 #define STRICT 1
00028 #include <ole2.h>
00029
00030 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00031 {return TRUE;}
00032
00033 STDAPI PrxDllCanUnloadNow(void){return S_OK;}
00034
00035 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00036 {return CLASS_E_CLASSNOTAVAILABLE;}
00037
00038 STDAPI PrxDllRegisterServer(void){return S_OK;}
00039
00040 STDAPI PrxDllUnregisterServer(void){return S_OK;}
00041
00042 #endif //!PROXY_DELEGATION
00043
00044 #endif //_MERGE_PROXYSTUB
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Exit/C++/Windows.Net/atl.cpp Source File

  • Security
  • CertServices
  • Exit
  • C++
  • Windows.Net

atl.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 1999
00005 //
00006 // File:        atl.cpp
00007 //
00008 // Contents:    ActiveX Template Library COM support
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include <pch.cpp>
00013
00014 #pragma hdrstop
00015
00016 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Simple/compdata.h Source File

  • SysMgmt
  • MMC
  • Simple

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include <objidl.h>
00024 #include "DeleBase.h"
00025 #include "StatNode.h"
00026 #include "Comp.h"
00027
00028 class CComponentData : public IComponentData,
00029 IPersistStream
00030 {
00031     friend class CComponent;
00032
00033 private:
00034     ULONG       m_cref;
00035     LPCONSOLE     m_ipConsole;
00036     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00037
00038     CStaticNode     *m_pStaticNode;
00039
00040 public:
00041     CComponentData();
00042     ~CComponentData();
00043
00044     ///////////////////////////////
00045     // Interface IUnknown
00046     ///////////////////////////////
00047     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00048     STDMETHODIMP_(ULONG) AddRef();
00049     STDMETHODIMP_(ULONG) Release();
00050
00051     ///////////////////////////////
00052     // Interface IComponentData
00053     ///////////////////////////////
00054     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00055         /* [in] */ LPUNKNOWN pUnknown);
00056
00057         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00058         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00059
00060         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00061         /* [in] */ LPDATAOBJECT lpDataObject,
00062         /* [in] */ MMC_NOTIFY_TYPE event,
00063         /* [in] */ LPARAM arg,
00064         /* [in] */ LPARAM param);
00065
00066         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00067
00068     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00069         /* [in] */ MMC_COOKIE cookie,
00070         /* [in] */ DATA_OBJECT_TYPES type,
00071         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00072
00073         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00074         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00075
00076         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00077         /* [in] */ LPDATAOBJECT lpDataObjectA,
00078         /* [in] */ LPDATAOBJECT lpDataObjectB);
00079
00080
00081         ///////////////////////////////
00082         // Interface IPersistStream
00083         ///////////////////////////////
00084         virtual HRESULT STDMETHODCALLTYPE GetClassID(
00085         /* [out] */ CLSID __RPC_FAR *pClassID);
00086
00087         virtual HRESULT STDMETHODCALLTYPE IsDirty( void);
00088
00089     virtual HRESULT STDMETHODCALLTYPE Load(
00090         /* [unique][in] */ IStream __RPC_FAR *pStm);
00091
00092         virtual HRESULT STDMETHODCALLTYPE Save(
00093         /* [unique][in] */ IStream __RPC_FAR *pStm,
00094         /* [in] */ BOOL fClearDirty);
00095
00096         virtual HRESULT STDMETHODCALLTYPE GetSizeMax(
00097         /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbSize);
00098 };
00099
00100 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/nameext.h Source File

  • SysMgmt
  • MMC
  • Nameext

nameext.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _CNamespaceExtension_H_
00020 #define _CNamespaceExtension_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024 #include <crtdbg.h>
00025 #include "DeleBase.h"
00026 #include "globals.h"
00027 #include "resource.h"
00028 #include "LocalRes.h"
00029
00030 class CComponentData : public IComponentData,
00031 IExtendContextMenu
00032
00033 {
00034     friend class CComponent;
00035
00036 private:
00037     ULONG               m_cref;
00038     LPCONSOLE           m_ipConsole;
00039     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00040
00041     HRESULT ExtractObjectTypeGUID( IDataObject* piDataObject, GUID* pguidObjectType );
00042     HRESULT ExtractSnapInCLSID( IDataObject* piDataObject, CLSID* pclsidSnapin );
00043     HRESULT ExtractString( IDataObject *piDataObject, CLIPFORMAT cfClipFormat, _TCHAR *pstr, DWORD cchMaxLength);
00044     HRESULT ExtractData( IDataObject* piDataObject, CLIPFORMAT cfClipFormat, BYTE* pbData, DWORD cbData );
00045
00046     enum { NUMBER_OF_CHILDREN = 1 };
00047     CDelegationBase *children[1];
00048
00049   // clipboard format
00050     static UINT s_cfDisplayName;
00051     static UINT s_cfSnapInCLSID;
00052     static UINT s_cfNodeType;
00053
00054     // {2974380F-4C4B-11d2-89D8-000021473128}
00055     static const GUID skybasedvehicleGuid;
00056
00057
00058 public:
00059     CComponentData();
00060     ~CComponentData();
00061
00062   const GUID & getPrimaryNodeType() { return skybasedvehicleGuid; }
00063     HRESULT OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent);
00064
00065
00066     ///////////////////////////////
00067     // Interface IUnknown
00068     ///////////////////////////////
00069     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00070     STDMETHODIMP_(ULONG) AddRef();
00071     STDMETHODIMP_(ULONG) Release();
00072
00073     ///////////////////////////////
00074     // Interface IComponentData
00075     ///////////////////////////////
00076     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00077         /* [in] */ LPUNKNOWN pUnknown);
00078
00079         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00080         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00081
00082         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00083         /* [in] */ LPDATAOBJECT lpDataObject,
00084         /* [in] */ MMC_NOTIFY_TYPE event,
00085         /* [in] */ LPARAM arg,
00086         /* [in] */ LPARAM param);
00087
00088         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00089
00090     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00091         /* [in] */ MMC_COOKIE cookie,
00092         /* [in] */ DATA_OBJECT_TYPES type,
00093         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00094
00095         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00096         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00097
00098         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00099         /* [in] */ LPDATAOBJECT lpDataObjectA,
00100         /* [in] */ LPDATAOBJECT lpDataObjectB);
00101
00102         ///////////////////////////////
00103         // Interface IExtendContextMenu
00104         ///////////////////////////////
00105         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddMenuItems(
00106         /* [in] */ LPDATAOBJECT piDataObject,
00107         /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
00108         /* [out][in] */ long __RPC_FAR *pInsertionAllowed);
00109
00110         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Command(
00111         /* [in] */ long lCommandID,
00112         /* [in] */ LPDATAOBJECT piDataObject);
00113
00114
00115 public:
00116     static HBITMAP m_pBMapSm;
00117     static HBITMAP m_pBMapLg;
00118
00119 protected:
00120     static void LoadBitmaps() {
00121         m_pBMapSm = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_SMICONS));
00122         m_pBMapLg = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDR_LGICONS));
00123     }
00124
00125     BOOL bExpanded;
00126 };
00127
00128 #endif _CNamespaceExtension_H_
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/AppBar/AppBar.h Source File

  • WinUI
  • Shell
  • AppBar

AppBar.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1993 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:     appbar.h
00009 //
00010 //  PURPOSE:    Contains prototypes and constants for appbar.c.
00011 //
00012 //  PLATFORMS:  Windows 95, Windows 98, Windows 2000, Windows NT 4.0
00013 //
00014
00015
00016 //////////////////////////////////////////////////////////////////////////////
00017 // Constants and Enumerations
00018
00019 #define CX_DEFWIDTH   80
00020 #define CY_DEFHEIGHT  60
00021
00022 #define IDT_AUTOHIDE  1
00023 #define IDT_AUTOUNHIDE  2
00024
00025 #define APPBAR_TOP    0
00026 #define APPBAR_BOTTOM 1
00027 #define APPBAR_LEFT   2
00028 #define APPBAR_RIGHT  3
00029
00030
00031 //////////////////////////////////////////////////////////////////////////////
00032 // Types
00033
00034 typedef struct tagOPTIONS
00035 {
00036   BOOL fAutoHide;
00037   BOOL fOnTop;
00038   BOOL fHiding;
00039   UINT uSide;
00040   DWORD cxWidth;
00041   DWORD cyHeight;
00042   RECT rcEdges[4];
00043 } OPTIONS, *POPTIONS;
00044
00045
00046 //////////////////////////////////////////////////////////////////////////////
00047 // Global Variables
00048
00049 extern BOOL g_fAppRegistered;
00050 extern RECT g_rcAppBar;
00051
00052
00053 //////////////////////////////////////////////////////////////////////////////
00054 // Prototypes
00055
00056 void AppBar_Size(HWND);
00057 void AppBar_QueryPos(HWND, LPRECT);
00058 void AppBar_QuerySetPos(UINT, LPRECT, PAPPBARDATA, BOOL);
00059 void AppBar_Callback(HWND, UINT, WPARAM, LPARAM);
00060 void AppBar_PosChanged(PAPPBARDATA);
00061 BOOL AppBar_SetAutoHide(HWND hwnd, BOOL fHide);
00062 BOOL AppBar_UnRegister(HWND hwnd);
00063 BOOL AppBar_Register(HWND hwnd);
00064 BOOL AppBar_SetSide(HWND hwnd, UINT uSide);
00065 void AppBar_SetAlwaysOnTop(HWND hwnd, BOOL fOnTop);
00066 void AppBar_Hide(HWND hwnd);
00067 void AppBar_UnHide(HWND hwnd);
00068 void AppBar_SetAutoHideTimer(HWND hwnd);
00069 void AppBar_SetAutoUnhideTimer(HWND hwnd);
00070 POPTIONS GetAppbarData(HWND);
00071
00072
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/rowsetviewer/crowposition.cpp Source File

  • Dataaccess
  • oledb
  • rowsetviewer

crowposition.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB RowsetViewer
00003 // Copyright (C) 1994 - 1999 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module CROWPOSITION.CPP
00008 //
00009 //-----------------------------------------------------------------------------------
00010
00011 //////////////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 //////////////////////////////////////////////////////////////////////////////
00015 #include "Headers.h"
00016
00017
00018 /////////////////////////////////////////////////////////////////
00019 // CRowPosition::CRowPosition
00020 //
00021 /////////////////////////////////////////////////////////////////
00022 CRowPosition::CRowPosition(CMainWindow* pCMainWindow, CMDIChild* pCMDIChild)
00023   : CContainerBase(eCRowPosition, pCMainWindow, pCMDIChild)
00024 {
00025   //RowPosition
00026   m_pIRowPosition         = NULL;//RowPosition Interface
00027
00028   //Extra Interfaces
00029   m_dwCookieRowPos        = 0;
00030 }
00031
00032
00033 /////////////////////////////////////////////////////////////////
00034 // CRowPosition::~CRowPosition
00035 //
00036 /////////////////////////////////////////////////////////////////
00037 CRowPosition::~CRowPosition()
00038 {
00039   ReleaseObject(0);
00040 }
00041
00042
00043 /////////////////////////////////////////////////////////////////
00044 // IUnknown** CRowPosition::GetInterfaceAddress
00045 //
00046 /////////////////////////////////////////////////////////////////
00047 IUnknown** CRowPosition::GetInterfaceAddress(REFIID riid)
00048 {
00049   HANDLE_GETINTERFACE(IRowPosition);
00050
00051   //Otherwise delegate
00052   return CContainerBase::GetInterfaceAddress(riid);
00053 }
00054
00055 /////////////////////////////////////////////////////////////////
00056 // CRowPosition::AutoRelease
00057 //
00058 /////////////////////////////////////////////////////////////////
00059 HRESULT CRowPosition::AutoRelease()
00060 {
00061   //RowPosition
00062   RELEASE_INTERFACE(IRowPosition);
00063
00064   //Don't Unadvise the Listeners until the Rowset goes away.
00065   //We want to receive and Display the ROWSET_RELEASE notifications
00066   UnadviseListener(IID_IRowPositionChange, &m_dwCookieRowPos);
00067
00068   //Delegate
00069   return CContainerBase::AutoRelease();
00070 }
00071
00072
00073 ////////////////////////////////////////////////////////////////
00074 // CRowPosition::AutoQI
00075 //
00076 /////////////////////////////////////////////////////////////////
00077 HRESULT CRowPosition::AutoQI(DWORD dwCreateOpts)
00078 {
00079   //Delegate First so we have IConnectionPointContainer
00080   CContainerBase::AutoQI(dwCreateOpts);
00081
00082   //[MANDATORY] Obtain [mandatory] interfaces
00083   if(dwCreateOpts & CREATE_QI_MANDATORY)
00084   {
00085     OBTAIN_INTERFACE(IRowPosition);
00086   }
00087
00088   //AutoQI
00089   if(dwCreateOpts & CREATE_QI_OPTIONAL)
00090   {
00091   }
00092
00093   //Advise Listeners
00094   AdviseListener(IID_IRowPositionChange, &m_dwCookieRowPos);
00095   return S_OK;
00096 }
00097
00098
00099 ////////////////////////////////////////////////////////////////
00100 // CRowPosition::Initialize
00101 //
00102 /////////////////////////////////////////////////////////////////
00103 HRESULT CRowPosition::Initialize(IUnknown* pIUnkRowset)
00104 {
00105   HRESULT hr = S_OK;
00106
00107   //Initialize
00108   XTEST(hr = m_pIRowPosition->Initialize(pIUnkRowset));
00109   TESTC(TRACE_METHOD(hr, L"IRowPosition::Initialize(0x%p)", pIUnkRowset));
00110
00111 CLEANUP:
00112   return hr;
00113 }
00114
00115
00116 ////////////////////////////////////////////////////////////////
00117 // CRowPosition::GetRowset
00118 //
00119 /////////////////////////////////////////////////////////////////
00120 HRESULT CRowPosition::GetRowset(REFIID riid, IUnknown** ppIUnknown)
00121 {
00122   HRESULT hr = S_OK;
00123
00124   if(m_pIRowPosition)
00125   {
00126     //IRowPosition::GetRowset
00127     XTEST(hr = m_pIRowPosition->GetRowset(riid, ppIUnknown));
00128     TESTC(TRACE_METHOD(hr, L"IRowPosition::GetRowset(%s, &0x%p)", GetInterfaceName(riid), ppIUnknown ? *ppIUnknown : NULL));
00129   }
00130
00131 CLEANUP:
00132   return hr;
00133 }
00134
00135
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSimpSvrDoc Member List

This is the complete list of members for CSimpSvrDoc, including all inherited members.
ClearObj() | CSimpSvrDoc | [inline]
Close() | CSimpSvrDoc |
Create(CSimpSvrApp FAR *lpApp, LPRECT lpRect, HWND hWnd) | CSimpSvrDoc | [static]
CreateObject(REFIID riid, LPVOID FAR *ppvObject) | CSimpSvrDoc |
CSafeRefCount() | CSafeRefCount |
CSimpSvrDoc() | CSimpSvrDoc |
CSimpSvrDoc(CSimpSvrApp FAR *lpApp, HWND hWnd) | CSimpSvrDoc |
DecrementNestCount() | CSafeRefCount |
GetApp() | CSimpSvrDoc | [inline]
GethAppWnd() | CSimpSvrDoc | [inline]
GethDocWnd() | CSimpSvrDoc | [inline]
GethHatchWnd() | CSimpSvrDoc | [inline]
GetObj() | CSimpSvrDoc | [inline]
HideDocWnd() | CSimpSvrDoc |
HideHatchWnd() | CSimpSvrDoc |
IncrementNestCount() | CSafeRefCount |
lAddVerbs() | CSimpSvrDoc |
lButtonDown(WPARAM wParam, LPARAM lParam) | CSimpSvrDoc |
Load(LPSTR lpszFileName) | CSimpSvrDoc |
lResizeDoc(LPRECT lpRect) | CSimpSvrDoc |
m_fClosing | CSimpSvrDoc | [private]
m_hDocWnd | CSimpSvrDoc | [private]
m_hHatchWnd | CSimpSvrDoc | [private]
m_lpApp | CSimpSvrDoc | [private]
m_lpObj | CSimpSvrDoc | [private]
PaintDoc(HDC hDC) | CSimpSvrDoc |
QueryInterface(REFIID riid, LPVOID FAR *ppvObj) | CSimpSvrDoc |
SafeAddRef() | CSafeRefCount |
SafeRelease() | CSafeRefCount |
SetStatusText() | CSimpSvrDoc |
ShowDocWnd() | CSimpSvrDoc |
ShowHatchWnd() | CSimpSvrDoc |
STDMETHODIMP_(ULONG) AddRef() | CSimpSvrDoc |
STDMETHODIMP_(ULONG) Release() | CSimpSvrDoc |
~CSafeRefCount() | CSafeRefCount | [virtual]
~CSimpSvrDoc() | CSimpSvrDoc |
Generated on Wed Nov 13 2024 16:57:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcRDO/rdocomponent.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcRDO

rdocomponent.h

Go to the documentation of this file.
00001 //==============================================================================
00002 // Filename: RDOComponent.h
00003 //
00004 // Description: Declaration of the CRDOComponent
00005 //
00006 // This file is part of the Microsoft COM+ Samples
00007 //
00008 // Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved
00009 //
00010 // This source code is intended only as a supplement to Microsoft
00011 // Development Tools and/or on-line documentation.  See these other
00012 // materials for detailed information reagrding Microsoft code samples.
00013 //
00014 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00015 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 // PARTICULAR PURPOSE.
00018 //
00019 //==============================================================================
00020
00021
00022
00023 #ifndef __RDOCOMPONENT_H_
00024 #define __RDOCOMPONENT_H_
00025
00026 #include "resource.h"       // main symbols
00027 #include <comsvcs.h>
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CRDOComponent
00031 class ATL_NO_VTABLE CRDOComponent :
00032   public CComObjectRootEx<CComSingleThreadModel>,
00033   public CComCoClass<CRDOComponent, &CLSID_RDOComponent>,
00034   public IObjectControl,
00035   public IDispatchImpl<IRDOComponent, &IID_IRDOComponent, &LIBID_RDOKBLib>
00036 {
00037 public:
00038   CRDOComponent()
00039   {
00040   }
00041
00042 DECLARE_REGISTRY_RESOURCEID(IDR_RDOCOMPONENT)
00043 DECLARE_NOT_AGGREGATABLE(CRDOComponent)
00044
00045 BEGIN_COM_MAP(CRDOComponent)
00046   COM_INTERFACE_ENTRY(IRDOComponent)
00047   COM_INTERFACE_ENTRY(IObjectControl)
00048   COM_INTERFACE_ENTRY(IDispatch)
00049 END_COM_MAP()
00050
00051 // IObjectControl
00052 public:
00053   STDMETHOD(Activate)();
00054   STDMETHOD_(BOOL, CanBePooled)();
00055   STDMETHOD_(void, Deactivate)();
00056
00057   CComPtr<IObjectContext> m_spObjectContext;
00058
00059 // IRDOComponent
00060 public:
00061   STDMETHOD(SimpleQuery)(/*[in, out]*/ VARIANT * returnval);
00062 };
00063
00064 #endif //__RDOCOMPONENT_H_
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinNT/WxForm/WxForm.c Source File

  • Multimedia
  • Gdi
  • WinNT
  • WxForm

WxForm.c

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /**************************************************************************\
00013 *  wxform.c -- sample program demonstrating the new "World Transform."
00014 *
00015 *  design:  There are a few global handles or pointers in this application,
00016 *   and different routines to operate on them.  The obvious case of this
00017 *   is the three window handles and their associated window procedures.
00018 *   There is also a unique pointer to a track object and a routine to
00019 *   operate on it (i.e. doTrackObject).  All communication is accomplished
00020 *   by sending messages between these procedures.  Each window procedure,
00021 *   and the track object procedure, operate on some set of messages which
00022 *   include some of the standard Windows messages, and also miscellaneous
00023 *   "WM_USER" messages (c.f. wxform.h).
00024 \**************************************************************************/
00025
00026 #include <windows.h>
00027 #include <string.h>
00028 #include <stdio.h>
00029 #include <math.h>
00030 #include <limits.h>
00031 #include "wxform.h"
00032
00033
00034 //
00035 // function prototype for looking up string resources
00036 //
00037
00038 LPTSTR GetStringRes (int);
00039
00040
00041
00042 /**************************************************************************\
00043 *
00044 *  function:  WinMain()
00045 *
00046 *  input parameters:  c.f. generic sample
00047 *
00048 \**************************************************************************/
00049 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00050                      LPSTR lpCmdLine, int nCmdShow)
00051 {
00052     MSG   msg;
00053     HICON hicon;
00054
00055     UNREFERENCED_PARAMETER( lpCmdLine );
00056
00057
00058     //
00059     // Detect platform and exit gracefully if not Windows NT.
00060     //
00061
00062     {
00063       OSVERSIONINFO osvi;
00064       osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
00065
00066       GetVersionEx (&osvi);
00067       if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) {
00068         MessageBox (NULL,
00069           GetStringRes (IDS_NTONLY),
00070           "wxform", MB_OK | MB_ICONSTOP);
00071         return 0;
00072       }
00073     }
00074
00075
00076     /* Check for previous instance.  If none, then register class. */
00077     if (!hPrevInstance) {
00078         WNDCLASS  wc;
00079
00080         wc.style = 0;
00081         wc.lpfnWndProc = (WNDPROC)MainWndProc;
00082
00083         wc.cbClsExtra = 0;
00084         wc.cbWndExtra = 0;
00085         wc.hInstance = hInstance;
00086         wc.hIcon = LoadIcon(hInstance, "TransformIcon");
00087         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00088         wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
00089         wc.lpszMenuName =  NULL;
00090         wc.lpszClassName = "wxform";
00091
00092         if (!RegisterClass(&wc)) return (FALSE);
00093     }  /* class registered o.k. */
00094
00095
00096     /* Create the main window.  Return false if CreateWindow() fails */
00097     hInst = hInstance;
00098
00099     hwndMain = CreateWindow(
00100         "wxform",
00101         GetStringRes (IDS_WINDOWTITLE),
00102         WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
00103         CW_USEDEFAULT,
00104         CW_USEDEFAULT,
00105         CW_USEDEFAULT,
00106         CW_USEDEFAULT,
00107         NULL,
00108         NULL,
00109         hInstance,
00110         NULL);
00111
00112     if (!hwndMain) return (FALSE);
00113     ShowWindow(hwndMain, nCmdShow);
00114     UpdateWindow(hwndMain);
00115
00116
00117     /* create a new track object and paint it for the first time. */
00118     ptoRect = doTrackObject(NULL, TROB_NEW, hwndMain, 0);
00119     doTrackObject(ptoRect, TROB_PAINT, hwndMain, 0);
00120
00121
00122     /* load and display dialog for the world transform matrix.
00123      *  then fill its entry fields.  Also, get the HICON from the
00124      *  main window and fill it into the dialog's class structure
00125      *  for this application.
00126      */
00127     hwndTransform = CreateDialog(hInst, "TransformDlg",
00128                                  hwndMain, (DLGPROC)TransformDlgProc);
00129     hicon = (HICON) (DWORD_PTR) GetClassLongPtr (hwndMain, GCLP_HICON);
00130     SetClassLongPtr (hwndTransform, GCLP_HICON, (LONG) (DWORD_PTR) hicon);
00131     showTransform = TRUE;
00132     SendMessage (hwndTransform, WM_PUTUPFLOATS, 0, (LONG_PTR) &ptoRect->xfmChange);
00133
00134     /* load and display the dialog for the mouse position.
00135      *  minimize it initially.
00136      */
00137     hwndMouse = CreateDialog(hInst, "MouseDlg",
00138                              hwndMain, (DLGPROC)MouseDlgProc);
00139     ShowWindow (hwndMouse, SW_SHOWMINIMIZED);
00140     showMouse = FALSE;
00141
00142
00143     /* load and display the dialog with the direct manipulation help.
00144      *  minimize it initially.   (Don't need a unique window procedure.)
00145      */
00146     hwndHelp = CreateDialog(hInst, "helpDlg", hwndMain, NULL);
00147     ShowWindow (hwndHelp, SW_SHOWMINIMIZED);
00148
00149
00150
00151     /* Loop getting messages and dispatching them. */
00152     while (GetMessage(&msg,NULL, 0,0)) {
00153       if (!IsDialogMessage (hwndTransform, &msg))
00154       if (!IsDialogMessage (hwndMouse, &msg))
00155       if (!IsDialogMessage (hwndHelp, &msg)){
00156         TranslateMessage(&msg);
00157         DispatchMessage(&msg);
00158       }
00159     }
00160     return (int)(msg.wParam);
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 /**************************************************************************\
00172 *
00173 *  function:  MainWndProc()
00174 *
00175 *  input parameters:  normal window procedure parameters.
00176 *
00177 *  global variables:
00178 *   hwndTransform,
00179 *   hwndMouse - information dialog box window handles.
00180 *   showTransform,
00181 *   showMouse - Booleans recording the retore/minimize state of the dialogs.
00182 *   ptoRect   - pointer to track object in middle of screen.
00183 *
00184 \**************************************************************************/
00185 LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00186 {
00187 static HANDLE hPenGrid;
00188
00189   switch (message) {
00190
00191     /**********************************************************************\
00192     *  WM_CREATE
00193     *
00194     * create a pen for later use.
00195     \**********************************************************************/
00196     case WM_CREATE:
00197       hPenGrid  = CreatePen (PS_SOLID, 1, GRIDCOLOR);
00198     break;
00199
00200
00201
00202     /**********************************************************************\
00203     *  WM_DESTROY
00204     *
00205     * Complement of WM_CREATE.  send the track object the delete messages,
00206     *  then call PostQuitMessage.
00207     \**********************************************************************/
00208     case WM_DESTROY:
00209       DeleteObject(hPenGrid);
00210       doTrackObject(ptoRect, TROB_DELETE, hwnd, lParam);
00211       PostQuitMessage(0);
00212     break;
00213
00214
00215
00216     /**********************************************************************\
00217     *  WM_SIZE
00218     *
00219     * Invalidate the whole window because we reset the origin on paint
00220     *  messages according to the size.  Also, send the track object a
00221     *  message so that it will also change its HDC's viewport origin.
00222     \**********************************************************************/
00223     case WM_SIZE:
00224         InvalidateRect (hwnd, NULL, TRUE);
00225         doTrackObject (ptoRect, TROB_CENTER, hwnd, lParam);
00226     break;
00227
00228
00229
00230     /**********************************************************************\
00231     *  WM_PAINT
00232     *
00233     * First invalidate the whole window (forces the object to be painted
00234     *  fresh, and thus it won't XOR its old self out).  Then draw the
00235     *  grid and finally draw the object.
00236     \**********************************************************************/
00237     case WM_PAINT : {
00238       PAINTSTRUCT ps;
00239       HDC hdc;
00240       RECT  rect;
00241       POINT point;
00242       int i;
00243
00244       InvalidateRect (hwnd, NULL, TRUE);
00245
00246       hdc = BeginPaint(hwnd, &ps);
00247
00248       CenterOrigin (hwnd, hdc);
00249       GetClientRect (hwnd, &rect);
00250       GetViewportOrgEx(hdc, &point);
00251       OffsetRect(&rect, -point.x, -point.y );
00252
00253
00254       /* Draw vertical lines.  Draw three at the origin. */
00255       SelectObject(hdc, hPenGrid);
00256       for (i = 0; i<= rect.right; i+=TICKSPACE){
00257         MoveToEx (hdc, i, rect.top, NULL);
00258         LineTo (hdc, i, rect.bottom);
00259         MoveToEx (hdc, -i, rect.top, NULL);
00260         LineTo (hdc, -i, rect.bottom);
00261       }
00262       MoveToEx (hdc, -1, rect.top, NULL);
00263       LineTo (hdc, -1, rect.bottom);
00264       MoveToEx (hdc, 1, rect.top, NULL);
00265       LineTo (hdc, 1, rect.bottom);
00266
00267
00268       /* Draw horizontal lines.  Draw three at the origin. */
00269       for (i = 0; i<= rect.bottom; i+=TICKSPACE){
00270         MoveToEx (hdc, rect.left, i, NULL);
00271         LineTo (hdc, rect.right, i);
00272         MoveToEx (hdc, rect.left, -i, NULL);
00273         LineTo (hdc, rect.right, -i);
00274       }
00275       MoveToEx (hdc, rect.left, -1, NULL);
00276       LineTo (hdc, rect.right, -1);
00277       MoveToEx (hdc, rect.left, 1, NULL);
00278       LineTo (hdc, rect.right, 1);
00279
00280       doTrackObject(ptoRect, TROB_PAINT, hwnd, lParam);
00281
00282       EndPaint (hwnd, &ps);
00283     } break;
00284
00285
00286
00287     /**********************************************************************\
00288     *  WM_LBUTTONDOWN & WM_RBUTTONDOWN
00289     * On button down messages, hittest on the track object, and if
00290     *  it returns true, then send these messages to the track object.
00291     \**********************************************************************/
00292     case WM_RBUTTONDOWN:
00293     case WM_LBUTTONDOWN:
00294       if (doTrackObject(ptoRect, TROB_HITTEST, hwnd, lParam))
00295          doTrackObject(ptoRect, message, hwnd, lParam);
00296     break;
00297
00298
00299
00300     /**********************************************************************\
00301     *  WM_LBUTTONUP & WM_RBUTTONDOWN & MW_MOUSEMOVE
00302     * If the track object is in a "tracking mode" then send it these messages.
00303     *  If the transform dialog is not minimized, fill it with numbers.
00304     *  If the mouse dialog is not minimized, fill it with numbers.
00305     \**********************************************************************/
00306     case WM_RBUTTONUP:
00307     case WM_LBUTTONUP:
00308     case WM_MOUSEMOVE:
00309       if (ptoRect->Mode) {
00310         doTrackObject(ptoRect, message, hwnd, lParam);
00311         if (showTransform)
00312           SendMessage (hwndTransform, WM_PUTUPFLOATS, 0,
00313                        (LONG_PTR) &ptoRect->xfmChange);
00314       }
00315
00316       if (showMouse)
00317         SendMessage (hwndMouse, WM_PUTUPFLOATS, (DWORD_PTR) hwnd, lParam);
00318
00319     break;
00320
00321
00322   } /* end switch */
00323   return (DefWindowProc(hwnd, message, wParam, lParam));
00324 }
00325
00326
00327
00328
00329
00330
00331 /**************************************************************************\
00332 *
00333 *  function:  TransformDlgProc()
00334 *
00335 *  input parameters:  normal window procedure parameters.
00336 *
00337 *  global variables:
00338 *   showTransform  - TRUE if window is restored, FALSE if minimized.
00339 *       maintain the value in this routine for other windows' use.
00340 *   ptoRect - pointer to the track object.
00341 *   showMouse, hwndMain.
00342 *
00343 *  nonstandard messages:
00344 *   WM_PUTUPFLOATS - fill the entry fields with the contents of an XFORM.
00345 \**************************************************************************/
00346 LRESULT CALLBACK TransformDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00347 {
00348 XFORM  xform;
00349 char buffer[MAXCHARS];
00350
00351
00352   switch (message) {
00353
00354
00355     /**********************************************************************\
00356     *  WM_INITDIALOG
00357     *
00358     * Fill the entry fields with sensible original values.
00359     \**********************************************************************/
00360     case WM_INITDIALOG:
00361       SetDlgItemText(hwnd, IDD_13, "0");
00362       SetDlgItemText(hwnd, IDD_23, "0");
00363       SetDlgItemText(hwnd, IDD_33, "1");
00364     return TRUE;
00365
00366
00367     /******************************************************************\
00368     *  WM_PUTUPFLOATS
00369     *
00370     *  lParam - pointer to an XFORM structure.
00371     *   fill the entry fields with the XFORM values.
00372     \******************************************************************/
00373     case WM_PUTUPFLOATS: {
00374       PXFORM pxform;
00375       pxform = (PXFORM) lParam;
00376
00377       _snprintf (buffer, MAXCHARS -1, FORMATFLOAT,pxform->eM11);
00378       SetDlgItemText(hwnd, IDD_EM11, buffer);
00379       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT,pxform->eM12);
00380       SetDlgItemText(hwnd, IDD_EM12, buffer);
00381       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT,pxform->eDx);
00382       SetDlgItemText(hwnd, IDD_EDX, buffer);
00383
00384       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT,pxform->eM21);
00385       SetDlgItemText(hwnd, IDD_EM21, buffer);
00386       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT,pxform->eM22);
00387       SetDlgItemText(hwnd, IDD_EM22, buffer);
00388       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT,pxform->eDy);
00389       SetDlgItemText(hwnd, IDD_EDY, buffer);
00390
00391     } return FALSE;
00392
00393
00394
00395     /******************************************************************\
00396     *  WM_SIZE
00397     *
00398     *  toggle the global variable keeping track of the iconized state
00399     *   of this window.
00400     \******************************************************************/
00401     case WM_SIZE :
00402       if (wParam == SIZEICONIC)
00403         showTransform = FALSE;
00404       else {
00405         showTransform = TRUE;
00406         SendMessage (hwnd, WM_PUTUPFLOATS, 0, (LONG_PTR) &ptoRect->xfmChange);
00407       }
00408     return FALSE;
00409
00410
00411     case WM_COMMAND:
00412       /******************************************************************\
00413       *  WM_COMMAND,  IDD_SETXFORM
00414       *
00415       *  take the values from the entry field, fill them into an XFORM
00416       *   structure and then send the track object the message to use
00417       *   these values.  Finally, reformat and repaint the entry fields.
00418       \******************************************************************/
00419       if (LOWORD(wParam) == IDD_SETXFORM) {
00420         GetDlgItemText(hwnd, IDD_EM11, buffer, MAXCHARS);
00421         xform.eM11 = (float) atof (buffer);
00422         GetDlgItemText(hwnd, IDD_EM12, buffer, MAXCHARS);
00423         xform.eM12 = (float) atof (buffer);
00424         GetDlgItemText(hwnd, IDD_EDX, buffer, MAXCHARS);
00425         xform.eDx = (float) atof (buffer);
00426
00427         GetDlgItemText(hwnd, IDD_EM21, buffer, MAXCHARS);
00428         xform.eM21 = (float) atof (buffer);
00429         GetDlgItemText(hwnd, IDD_EM22, buffer, MAXCHARS);
00430         xform.eM22 = (float) atof (buffer);
00431         GetDlgItemText(hwnd, IDD_EDY, buffer, MAXCHARS);
00432         xform.eDy = (float) atof (buffer);
00433
00434         // HACK.  The WM_SIZE here is used to flush the GDI buffer in order
00435         //  to eliminate a very strange bug whereby DPtoLP() doesn't work.
00436         if (showMouse) SendMessage (hwndMain, WM_SIZE, 0,0);
00437
00438
00439         doTrackObject (ptoRect, TROB_SETXFORM, hwnd, (LONG_PTR) &xform);
00440         SendMessage (hwnd, WM_PUTUPFLOATS, 0, (LONG_PTR) &xform);
00441
00442
00443       /******************************************************************\
00444       *  WM_COMMAND,  IDD_IDENTITY
00445       *
00446       *  fill a local XFORM structure with the identity matrix.  Now
00447       *   send the track object the message to use these values.
00448       *   Finally, reformat and repaint the entry fields.
00449       \******************************************************************/
00450       } else if (LOWORD(wParam) == IDD_IDENTITY) {
00451         xform.eM11 =
00452         xform.eM22 =  (float) 1.0;
00453         xform.eDx  =
00454         xform.eDy  =
00455         xform.eM12 =
00456         xform.eM21 =  (float) 0.0;
00457
00458         // HACK.  The WM_SIZE here is used to flush the GDI buffer in order
00459         //  to eliminate a very strange bug whereby DPtoLP() doesn't work.
00460         if (showMouse) SendMessage (hwndMain, WM_SIZE, 0,0);
00461
00462         doTrackObject (ptoRect, TROB_SETXFORM, hwnd, (LONG_PTR) &xform);
00463         SendMessage (hwnd, WM_PUTUPFLOATS, 0, (LONG_PTR) &xform);
00464       } /* end WM_COMMAND */
00465     return FALSE;
00466
00467
00468   } /* end switch */
00469   return FALSE;
00470 }
00471
00472
00473
00474
00475
00476 /**************************************************************************\
00477 *
00478 *  function:  MouseDlgProc()
00479 *
00480 *
00481 *  global variables:
00482 *   showMouse  -- TRUE if window is restored, FALSE if minimized.
00483 *       maintain the value in this routine for other windows' use.
00484 *   ptoRect - pointer to the track object.  Needed for DPtoLP()
00485 *
00486 *  nonstandard messages:
00487 *   WM_PUTUPFLOATS - fill the entry fields with the mouse position.
00488 *
00489 \**************************************************************************/
00490 LRESULT CALLBACK MouseDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00491 {
00492 char buffer[MAXCHARS];
00493
00494   switch (message) {
00495
00496     /******************************************************************\
00497     *  WM_PUTUPFLOATS
00498     *
00499     *  wParam - contains the hwnd for the main window.
00500     *  lParam - contains the mouse position in device coordinates.
00501     *           (c.f. WM_MOUSEMOVE)
00502     \******************************************************************/
00503     case WM_PUTUPFLOATS: {
00504       POINT pScreen, pWorld;
00505       HWND hwndM;
00506
00507       hwndM = (HWND) wParam;
00508       pScreen.x = pWorld.x = LOWORD(lParam);
00509       pScreen.y = pWorld.y  = HIWORD(lParam);
00510
00511       _snprintf (buffer, MAXCHARS - 1, "%d", pScreen.x);
00512       SetDlgItemText(hwnd, IDD_DEVICEX, buffer);
00513       _snprintf (buffer, MAXCHARS - 1, "%d", pScreen.y);
00514       SetDlgItemText(hwnd, IDD_DEVICEY, buffer);
00515
00516       ClientToScreen (hwndM, &pScreen);
00517       _snprintf (buffer, MAXCHARS - 1, "%d", pScreen.x);
00518       SetDlgItemText(hwnd, IDD_SCREENX, buffer);
00519       _snprintf (buffer, MAXCHARS - 1, "%d", pScreen.y);
00520       SetDlgItemText(hwnd, IDD_SCREENY, buffer);
00521
00522       DPtoLP (ptoRect->hdc, &pWorld, 1);
00523       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT, (float) pWorld.x);
00524       SetDlgItemText(hwnd, IDD_WORLDX , buffer);
00525       _snprintf (buffer, MAXCHARS - 1, FORMATFLOAT, (float) pWorld.y);
00526       SetDlgItemText(hwnd, IDD_WORLDY , buffer);
00527
00528     } return FALSE;
00529
00530
00531
00532     /******************************************************************\
00533     *  WM_SIZE
00534     *
00535     *  toggle the global variable keeping track of the iconized state
00536     *   of this window.
00537     \******************************************************************/
00538     case WM_SIZE :
00539       if (wParam == SIZEICONIC)
00540         showMouse = FALSE;
00541       else
00542         showMouse = TRUE;
00543     return FALSE;
00544
00545   }
00546   return FALSE;
00547 }
00548
00549
00550
00551
00552
00553
00554 /**************************************************************************\
00555 *  function:  CenterOrigin()
00556 *
00557 *  input parameters:
00558 *   hwnd - window with client we want the center of.
00559 *   hdc - device context which we set the Viewport origin of.
00560 *
00561 \**************************************************************************/
00562 VOID CenterOrigin (HWND hwnd, HDC hdc)
00563 {
00564 RECT  rect;
00565 POINT center;
00566
00567     GetClientRect (hwnd, &rect);
00568     center.x = rect.right / 2;
00569     center.y = rect.bottom /2;
00570
00571     SetViewportOrgEx (hdc, center.x, center.y, NULL);
00572     return;
00573 }
00574
00575
00576
00577
00578
00579
00580 /**************************************************************************\
00581 *
00582 *  function:  doTrackObject()
00583 *
00584 *  input parameters:
00585 *   pto -  pointer to a track object.
00586 *   msg -  message selecting what action to take.  Values may include WM_*'s
00587 *           (see case statements below for more information.)
00588 *   hwnd - Window handle for the window the track object exists within.
00589 *   lParam - Usually fourth param to window proc. varies based on msg.
00590 *
00591 *  global variables:  none.
00592 *
00593 *  coordinate spaces:  There are three coordinate spaces of interest here,
00594 *   and this routine is frequently switching between them...
00595 *
00596 *           WORLD                   DEVICE                  SCREEN
00597 *
00598 *      object coordinates       input mouse pos       used w/ SetCursorPos()
00599 *         (pto->rect)          (lParam for WM_*)
00600 *
00601 *             ----->  LPtoDP() ---->    ----> ClientToScreen() -->
00602 *             <-----  DPtoLP() <----    <---- ScreenToClient() <--
00603 *
00604 *   in addition, the HDC has an offset origin.  Device coordinates for the
00605 *   mouse (lParam) never take this into account, but it is necessary to
00606 *   translate them in order to get direct manipulation right.
00607 *
00608 \**************************************************************************/
00609 PTrackObject doTrackObject(PTrackObject pto, int msg, HWND hwnd, LONG_PTR lParam)
00610 {
00611   if ((pto == NULL) && (msg != TROB_NEW))  return NULL;
00612
00613   switch (msg) {
00614
00615
00616     /**********************************************************************\
00617     *  TROB_NEW
00618     *
00619     * Allocate new PTrackObject structure.  Fill in default values
00620     *  for the fields of the structure.  Set up the HDC correctly.
00621     * return - pointer to the new object.
00622     \**********************************************************************/
00623     case  TROB_NEW: {
00624         PTrackObject  ptobj;
00625
00626         /* with LPTR returned value is a pointer. */
00627         ptobj = (PTrackObject) LocalAlloc (LPTR, sizeof (TrackObject));
00628     if (!ptobj)
00629       return NULL;
00630
00631         /* initialize the HDC and other fields. */
00632         ptobj->hdc = GetDC(hwnd);
00633         SetGraphicsMode (ptobj->hdc, GM_ADVANCED);
00634         SetROP2(ptobj->hdc, R2_NOT);
00635         SelectObject (ptobj->hdc, GetStockObject (NULL_BRUSH));
00636         SelectObject(ptobj->hdc, CreatePen (PS_SOLID, 2, (COLORREF) 0x01000009));
00637         ptobj->Mode = TMNONE;
00638         doTrackObject (ptobj, TROB_CENTER, hwnd, lParam);
00639         GetWorldTransform (ptobj->hdc, &(ptobj->xfmChange));
00640
00641         /* initialize the size. */
00642         ptobj->rect.top = ptobj->rect.left = 0;
00643         ptobj->rect.bottom = ptobj->rect.right = TICKSPACE*5;
00644
00645         return (ptobj);
00646     }
00647
00648
00649     /**********************************************************************\
00650     *  TROB_DELETE
00651     *
00652     * Delete the pen that we created, release the DC,
00653     *  free up the memory allocated for the object.
00654     \**********************************************************************/
00655     case  TROB_DELETE:
00656         DeleteObject (SelectObject (pto->hdc, GetStockObject (BLACK_PEN)));
00657         doTrackObject (pto, TROB_PAINT, hwnd, lParam);
00658         ReleaseDC (hwnd, pto->hdc);
00659     if (pto)
00660       LocalFree (LocalHandle ((LPSTR)pto));   /* Only free the memory if the pointer is valid */
00661     return NULL;
00662
00663
00664
00665     /**********************************************************************\
00666     *  TROB_CENTER
00667     *
00668     * Called in order to reset the view port origin in the track objects
00669     *  hdc whenever the client window changes size.  This hdc is thus kept
00670     *  synchronized with the hdc that the axes are painted into.
00671     \**********************************************************************/
00672     case TROB_CENTER: {
00673         CenterOrigin (hwnd, pto->hdc);
00674         return (pto);
00675     }
00676
00677
00678
00679     /**********************************************************************\
00680     *  TROB_PAINT
00681     *
00682     * Paint the object into its hdc.  Called half the time to erase
00683     *  the object, and half the time to redraw it.
00684     \**********************************************************************/
00685     case TROB_PAINT: {
00686         Rectangle (pto->hdc, pto->rect.left+1, pto->rect.top+1,
00687                              pto->rect.left+INC, pto->rect.top+INC);
00688
00689         Rectangle (pto->hdc, pto->rect.left, pto->rect.top,
00690                              pto->rect.right, pto->rect.bottom);
00691     } return NULL;
00692
00693
00694
00695     /**********************************************************************\
00696     *  TROB_SETXFORM
00697     *
00698     * lParam - pointer to the new transform.
00699     *  set the new transform into the HDC, then update xfmChange.
00700     \**********************************************************************/
00701     case TROB_SETXFORM: {
00702         doTrackObject (pto, TROB_PAINT, hwnd, lParam);
00703         SetWorldTransform(pto->hdc, (PXFORM) lParam);
00704         GetWorldTransform(pto->hdc, &pto->xfmChange);
00705         doTrackObject (pto, TROB_PAINT, hwnd, lParam);
00706     } return NULL;
00707
00708
00709
00710     /**********************************************************************\
00711     *  TROB_HITTEST
00712     *
00713     * Check the point sent in in the lParam to see if it lays within
00714     *  the bounds of the objects defining rectangle.
00715     * return - pointer to the object iff the point is in rectangle,
00716     *  otherwise return NULL.
00717     \**********************************************************************/
00718     case TROB_HITTEST:{
00719         POINT  mouWorld;
00720         mouWorld.x = LOWORD(lParam);
00721         mouWorld.y = HIWORD(lParam);
00722
00723         DPtoLP (pto->hdc, &mouWorld, 1);
00724
00725         if (PtInRect (&pto->rect, mouWorld))  return pto;
00726         else  return NULL;
00727     }
00728
00729
00730
00731     /**********************************************************************\
00732     *  WM_LBUTTONDOWN &  WM_RBUTTONDOWN
00733     *
00734     * Capture the mouse, set the tracking mode depending on the mouse
00735     *  location in world coordinates, reset the mouse position.
00736     *
00737     \**********************************************************************/
00738     case WM_LBUTTONDOWN:
00739     case WM_RBUTTONDOWN: {
00740       POINT  newmouScreen;
00741       POINT  mouWorld;
00742
00743       mouWorld.x = LOWORD(lParam);
00744       mouWorld.y = HIWORD(lParam);
00745       DPtoLP (pto->hdc, &mouWorld, 1);
00746
00747       /* upper left hand corner. right button is no-op. */
00748       if ((mouWorld.x <= (pto->rect.right  / 2)) &&
00749           (mouWorld.y <= (pto->rect.bottom / 2))) {
00750           if (msg == WM_RBUTTONDOWN) return NULL;
00751           pto->Mode = TMMOVE;
00752           newmouScreen.x = pto->rect.left;
00753           newmouScreen.y = pto->rect.top;
00754
00755       /* lower left hand corner */
00756       } else if ((mouWorld.x <= (pto->rect.right  / 2)) &&
00757           (mouWorld.y > (pto->rect.bottom / 2))) {
00758
00759           pto->Mode = (msg == WM_RBUTTONDOWN) ? TMSHEARY : TMSIZEY;
00760           newmouScreen.x = pto->rect.left;
00761           newmouScreen.y = pto->rect.bottom;
00762
00763       /* upper right hand corner */
00764       } else if ((mouWorld.x > (pto->rect.right  / 2)) &&
00765           (mouWorld.y <= (pto->rect.bottom / 2))) {
00766
00767           pto->Mode = (msg == WM_RBUTTONDOWN) ? TMSHEARX : TMSIZEX;
00768           newmouScreen.x = pto->rect.right;
00769           newmouScreen.y = pto->rect.top;
00770
00771       /* lower right hand corner */
00772       } else if ((mouWorld.x > (pto->rect.right  / 2)) &&
00773           (mouWorld.y > (pto->rect.bottom / 2))) {
00774
00775           pto->Mode = (msg == WM_RBUTTONDOWN) ? TMROTATE : TMSIZEXY;
00776           newmouScreen.x = pto->rect.right;
00777           newmouScreen.y = pto->rect.bottom;
00778       }
00779
00780       SetCapture(hwnd);
00781       LPtoDP (pto->hdc, &newmouScreen, 1);
00782       ClientToScreen (hwnd, &newmouScreen);
00783       SetCursorPos (newmouScreen.x,newmouScreen.y);
00784
00785       GetWorldTransform (pto->hdc, &pto->xfmDown);
00786     } return NULL;
00787
00788
00789
00790     /**********************************************************************\
00791     *  WM_MOUSEMOVE
00792     *
00793     * this is where almost all of the interesting calculation is done.
00794     *  First clip the mouse location to be in client rectangle, then
00795     *  call MouseMove() to handle the different tracking modes.
00796     \**********************************************************************/
00797     case WM_MOUSEMOVE: {
00798       RECT  rect;
00799       GetClientRect (hwnd, &rect);
00800
00801       if ((short) LOWORD(lParam) < (short)rect.left)
00802         lParam = MAKELONG ((WORD)rect.left, HIWORD(lParam));
00803
00804       if (LOWORD(lParam) > (WORD)rect.right)
00805         lParam = MAKELONG ((WORD)rect.right, HIWORD(lParam));
00806
00807       if ((short) HIWORD(lParam) < (short)rect.top)
00808         lParam = MAKELONG (LOWORD(lParam), (WORD)rect.top);
00809
00810       if (HIWORD(lParam) > (WORD)rect.bottom)
00811         lParam = MAKELONG (LOWORD(lParam),(WORD)rect.bottom);
00812
00813       MouseMove (pto, msg, hwnd, lParam);
00814
00815     } return NULL;
00816
00817
00818
00819     /**********************************************************************\
00820     *  WM_RBUTTONUP & WM_LBUTTONUP
00821     *
00822     * simply release the mouse capture, and set the mode to TMNONE.
00823     \**********************************************************************/
00824     case WM_RBUTTONUP:
00825     case WM_LBUTTONUP: {
00826       if (pto->Mode) {
00827          ReleaseCapture();
00828          pto->Mode = TMNONE;
00829       }
00830     } return NULL;
00831
00832   }  /* end switch(msg) */
00833
00834   return NULL;    /* Default option; do nothing */
00835 }
00836
00837
00838
00839
00840
00841
00842 /**************************************************************************\
00843 *  function:  MouseMove()
00844 *
00845 *  input parameters:
00846 *   pto -  pointer to a track object.
00847 *   msg -  not used.
00848 *   hwnd - Window handle for the window the track object exists within.
00849 *   lParam - Usually fourth param to window proc. varies based on msg.
00850 *
00851 *  The tracking behavior which the user observers when moving the mouse
00852 *   is based on the current tracking mode of the object.  This is usually
00853 *   determined on the mouse down event (c.f. TM*).  First erase the old
00854 *   object, then figure out the change to the transform matrix, finally
00855 *   change the world transform matrix and redraw the object.
00856 *
00857 *  Tranform:
00858 *    (    eM11        eM12        0   )
00859 *    (    eM21        eM22        0   )
00860 *    (    eDx         eDy         1   )
00861 *
00862 *   xDevice = (xWorld * eM11) + (yWorld * eM21) + eDx
00863 *   yDevice = (xWorld * eM12) + (yWorld * eM22) + eDy
00864 *
00865 *   In this routine the Device (mouse location) and World (rectangle corner)
00866 *   points are known.  Therefore, the two equations above are solved for
00867 *   the desired matrix entry value (e.g. eM11, 1M12, ... eDy).  The tracking
00868 *   mode determines which one of these entries may be changed.  E.g. scaling
00869 *   in X modifies eM11 while shearing in X modifies eM12.  So rather than
00870 *   using the world transform to map from world to device points, we are
00871 *   back-computing the proper contents of the world transform.
00872 *
00873 \**************************************************************************/
00874 VOID MouseMove(PTrackObject pto, int msg, HWND hwnd, LONG_PTR lParam)
00875 {
00876 POINT  mouWorld, mouDevice, orgDevice;
00877
00878     UNREFERENCED_PARAMETER(msg);
00879
00880     doTrackObject(pto, TROB_PAINT, hwnd, lParam);
00881     mouDevice.x = mouWorld.x = LOWORD(lParam);
00882     mouDevice.y = mouWorld.y = HIWORD(lParam);
00883
00884     SetWorldTransform(pto->hdc, &pto->xfmDown);
00885     DPtoLP (pto->hdc, &mouWorld, 1);
00886
00887     /* offset the mouse device point for the viewport's origin. */
00888     GetViewportOrgEx (pto->hdc, &orgDevice);
00889     mouDevice.x -= orgDevice.x;
00890     mouDevice.y -= orgDevice.y;
00891
00892     GetWorldTransform(pto->hdc, &pto->xfmChange);
00893
00894     switch (pto->Mode) {
00895       /*******************************************************\
00896       *    (     1         xShear       0   )
00897       *    (     0           1          0   )
00898       *    (     0           0          1   )
00899       *
00900       * xWorld = rect.left == 0;
00901       \*******************************************************/
00902       case TMSHEARX: {
00903         pto->xfmChange.eM12 = (float) mouDevice.y;
00904         pto->xfmChange.eM12 -=pto->xfmChange.eDy;
00905         pto->xfmChange.eM12 /=(float) pto->rect.right ;
00906         SetWorldTransform (pto->hdc, &pto->xfmChange);
00907       } break;
00908
00909
00910       /*******************************************************\
00911       *    (     1           0          0   )
00912       *    (   yShear        1          0   )
00913       *    (     0           0          1   )
00914       *
00915       * yWorld = rect.top == 0;
00916       \*******************************************************/
00917       case TMSHEARY: {
00918         pto->xfmChange.eM21 = (float) mouDevice.x;
00919         pto->xfmChange.eM21 -=pto->xfmChange.eDx;
00920         pto->xfmChange.eM21 /=(float) pto->rect.bottom ;
00921         SetWorldTransform (pto->hdc, &pto->xfmChange);
00922
00923       } break;
00924
00925
00926       /*******************************************************\
00927       *    (   cos(a)      -sin(a)      0   )
00928       *    (   sin(a)       cos(a)      0   )
00929       *    (     0           0          1   )
00930       *
00931       * a == rotation angle.  Since mouse in in lower right,
00932       *  we need to shift this back 45 degrees (assuming that
00933       *  straight down is 0 degrees).  Thus we actually compute
00934       *  cos(a) = cos(b - 45) = cos(b)sin(45) + cos(45)sin(45)
00935       *  where b is angle from the origin to the mouse (x,y)
00936       *  cos(45) = sin(45) ~= 0.707107
00937       *  cos(b) = y/r    sin(b) = x/r
00938       *
00939       \*******************************************************/
00940       case TMROTATE: {
00941         float r;
00942
00943         /* translate back to the origin. */
00944         pto->xfmChange.eDx = pto->xfmChange.eDy = (float)0.0;
00945         SetWorldTransform (pto->hdc, &pto->xfmChange);
00946
00947         /* rotate about the origin. */
00948         r = (float) sqrt( (double)(mouWorld.x * mouWorld.x) +
00949                           (double)(mouWorld.y * mouWorld.y));
00950
00951         pto->xfmChange.eM11 = (float) mouWorld.y / r;
00952         pto->xfmChange.eM11 += (float) mouWorld.x / r;
00953         pto->xfmChange.eM11 *= (float) 0.707107;
00954         pto->xfmChange.eM22 = pto->xfmChange.eM11;
00955
00956         pto->xfmChange.eM12 = (float) mouWorld.y / r;
00957         pto->xfmChange.eM12 -= (float) mouWorld.x / r;
00958         pto->xfmChange.eM12 *= (float) 0.707107;
00959         pto->xfmChange.eM21 = -pto->xfmChange.eM12;
00960
00961         pto->xfmChange.eDx = pto->xfmChange.eDy = (float)0.0;
00962
00963         ModifyWorldTransform (pto->hdc, &pto->xfmChange, MWT_RIGHTMULTIPLY);
00964
00965         /* translate back to the original offset. */
00966         pto->xfmChange.eM11 =
00967         pto->xfmChange.eM22 = (float) 1.0;
00968         pto->xfmChange.eM12 =
00969         pto->xfmChange.eM21 = (float) 0.0;
00970
00971         pto->xfmChange.eDx = pto->xfmDown.eDx;
00972         pto->xfmChange.eDy = pto->xfmDown.eDy;
00973         ModifyWorldTransform (pto->hdc, &pto->xfmChange, MWT_RIGHTMULTIPLY);
00974         GetWorldTransform (pto->hdc, &pto->xfmChange);
00975       } break;
00976
00977
00978       /*******************************************************\
00979       *    (  Size X         0          0   )
00980       *    (     0        Size Y        0   )
00981       *    (     0           0          1   )
00982       *
00983       \*******************************************************/
00984       case TMSIZEXY: {
00985         pto->xfmChange.eM11 = (float) mouDevice.x;
00986         pto->xfmChange.eM11 -=pto->xfmChange.eDx;
00987         pto->xfmChange.eM11 -=((float) pto->rect.bottom * pto->xfmChange.eM21);
00988         pto->xfmChange.eM11 /=(float) pto->rect.right ;
00989
00990         pto->xfmChange.eM22 = (float) mouDevice.y;
00991         pto->xfmChange.eM22 -=pto->xfmChange.eDy;
00992         pto->xfmChange.eM22 -=((float) pto->rect.right  * pto->xfmChange.eM12);
00993         pto->xfmChange.eM22 /=(float) pto->rect.bottom ;
00994         SetWorldTransform (pto->hdc, &pto->xfmChange);
00995       } break;
00996
00997
00998       /*******************************************************\
00999       *    (  Size X         0          0   )
01000       *    (     0           1          0   )
01001       *    (     0           0          1   )
01002       *
01003       * yWorld = rect.top == 0;
01004       \*******************************************************/
01005       case TMSIZEX: {
01006         pto->xfmChange.eM11 = (float) mouDevice.x;
01007         pto->xfmChange.eM11 -=pto->xfmChange.eDx;
01008         pto->xfmChange.eM11 /=(float) pto->rect.right ;
01009         SetWorldTransform (pto->hdc, &pto->xfmChange);
01010       } break;
01011
01012
01013       /*******************************************************\
01014       *    (     1           0          0   )
01015       *    (     0        Size Y        0   )
01016       *    (     0           0          1   )
01017       *
01018       * xWorld = rect.left == 0;
01019       \*******************************************************/
01020       case TMSIZEY: {
01021         pto->xfmChange.eM22 = (float) mouDevice.y;
01022         pto->xfmChange.eM22 -=pto->xfmChange.eDy;
01023         pto->xfmChange.eM22 /=(float) pto->rect.bottom ;
01024         SetWorldTransform (pto->hdc, &pto->xfmChange);
01025       } break;
01026
01027
01028       /*******************************************************\
01029       *    (     1           0          0   )
01030       *    (     0           1          0   )
01031       *    (   Move x      Move y       1   )
01032       *
01033       * xWorld = rect.left == 0;
01034       * yWorld = rect.top == 0;
01035       \*******************************************************/
01036       case TMMOVE: {
01037         pto->xfmChange.eDx = (float) mouDevice.x ;
01038         pto->xfmChange.eDy = (float) mouDevice.y ;
01039         SetWorldTransform (pto->hdc, &pto->xfmChange);
01040       } break;
01041     } /* end switch */
01042
01043     doTrackObject(pto, TROB_PAINT, hwnd, lParam);
01044
01045     return;
01046  }
01047
01048
01049
01050
01051
01052 /******************************************************************************\
01053 *
01054 *  FUNCTION:    GetStringRes (int id INPUT ONLY)
01055 *
01056 *  COMMENTS:    Load the resource string with the ID given, and return a
01057 *               pointer to it.  Notice that the buffer is common memory so
01058 *               the string must be used before this call is made a second time.
01059 *
01060 \******************************************************************************/
01061
01062 LPTSTR   GetStringRes (int id)
01063 {
01064   static TCHAR buffer[MAX_PATH];
01065
01066   buffer[0]=0;
01067   LoadString (GetModuleHandle (NULL), id, buffer, MAX_PATH);
01068   return buffer;
01069 }
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/context.cpp Source File

  • WinUI
  • tsfapp

context.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          Context.cpp
00013
00014    Description:   ITfContextOwnerCompositionSink Implementation
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "TSFEdit.h"
00023
00024 /**************************************************************************
00025
00026    CTSFEditWnd::OnStartComposition()
00027
00028 **************************************************************************/
00029
00030 STDMETHODIMP CTSFEditWnd::OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk)
00031 {
00032     OutputDebugString(TEXT("CTSFEditWnd::OnStartComposition\n"));
00033
00034     *pfOk = TRUE;
00035
00036     if(m_cCompositions >= MAX_COMPOSITIONS)
00037     {
00038         //can't handle any more compositions
00039         *pfOk = FALSE;
00040         return S_OK;
00041     }
00042
00043     m_cCompositions++;
00044
00045     //increment the reference count
00046     pComposition->AddRef();
00047
00048     //find an empty slot to put the composition pointer in
00049     ULONG i;
00050     for(i = 0; i < MAX_COMPOSITIONS; i++)
00051     {
00052         if(NULL == m_rgCompositions[i])
00053         {
00054             m_rgCompositions[i] = pComposition;
00055             break;
00056         }
00057     }
00058
00059     _UpdateStatusBar();
00060
00061     return S_OK;
00062 }
00063
00064 /**************************************************************************
00065
00066    CTSFEditWnd::OnUpdateComposition()
00067
00068 **************************************************************************/
00069
00070 STDMETHODIMP CTSFEditWnd::OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew)
00071 {
00072     OutputDebugString(TEXT("CTSFEditWnd::OnUpdateComposition\n"));
00073
00074     _UpdateStatusBar();
00075
00076     return S_OK;
00077 }
00078
00079 /**************************************************************************
00080
00081    CTSFEditWnd::OnEndComposition()
00082
00083 **************************************************************************/
00084
00085 STDMETHODIMP CTSFEditWnd::OnEndComposition(ITfCompositionView *pComposition)
00086 {
00087     OutputDebugString(TEXT("CTSFEditWnd::OnEndComposition\n"));
00088
00089     //find the composition pointer in the array
00090     ULONG i;
00091     for(i = 0; i < MAX_COMPOSITIONS; i++)
00092     {
00093         if(pComposition == m_rgCompositions[i])
00094         {
00095             m_rgCompositions[i]->Release();
00096             m_rgCompositions[i] = NULL;
00097
00098             m_cCompositions--;
00099             break;
00100         }
00101     }
00102
00103     _UpdateStatusBar();
00104
00105     return S_OK;
00106 }
00107
00108
00109 /**************************************************************************
00110
00111   CTSFEditWnd::_TerminateAllCompositions()
00112
00113 **************************************************************************/
00114
00115 HRESULT CTSFEditWnd::_TerminateAllCompositions(void)
00116 {
00117     HRESULT hr;
00118     ITfContextOwnerCompositionServices *pCompServices;
00119
00120     //get the ITfContextOwnerCompositionServices interface pointer
00121     hr = m_pContext->QueryInterface(IID_ITfContextOwnerCompositionServices, (LPVOID*)&pCompServices);
00122     if(SUCCEEDED(hr))
00123     {
00124         //passing NULL terminates all compositions
00125         hr = pCompServices->TerminateComposition(NULL);
00126
00127         pCompServices->Release();
00128     }
00129
00130     return hr;
00131 }
00132
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/PersistATL/persistatl.Idl Source File

  • Com
  • Services
  • Events
  • EventNews
  • PersistATL

persistatl.Idl

Go to the documentation of this file.
00001 // PersistATL.idl : IDL source for PersistATL.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (PersistATL.tlb) and marshalling code.
00006
00007 import "oaidl.idl";
00008 import "ocidl.idl";
00009 import "..\include\news.idl";
00010
00011 [
00012   uuid(04A47040-A5D3-11D2-AD4D-0080C7BFF6DB),
00013   version(1.0),
00014   helpstring("PersistATL 1.0 Type Library")
00015 ]
00016 library PERSISTATLLib
00017 {
00018   importlib("stdole32.tlb");
00019   importlib("stdole2.tlb");
00020
00021   [
00022     uuid(6B834DA0-A5D3-11D2-AD4D-0080C7BFF6DB),
00023     helpstring("NewsEvent Class")
00024   ]
00025   coclass NewsEvent
00026   {
00027     [default] interface INewsEvent;
00028   };
00029 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/extensions/Chunk/ctetest.h Source File

  • Web
  • iis
  • extensions
  • Chunk

ctetest.h

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1997-2002 Microsoft Corporation
00003
00004   Module Name:
00005
00006     ctetest.h
00007
00008   Abstract:
00009
00010     This header files contains the common routines used for
00011     Chunked Transfer Encoding ISAPI Extension DLL sample.
00012 */
00013
00014 #ifndef _CTETEST_H
00015 #define _CTETEST_H
00016
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021 #include <httpext.h>
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024
00025 // see cte_enc.c for details
00026
00027 typedef struct CTE_ENCODER_STRUCT * HCTE_ENCODER;
00028
00029 HCTE_ENCODER CteBeginWrite(IN EXTENSION_CONTROL_BLOCK *pECB, IN DWORD dwChunkSize);
00030
00031 BOOL CteWrite(IN HCTE_ENCODER h, IN PVOID pData, IN DWORD cbData);
00032
00033 BOOL CteEndWrite(IN HCTE_ENCODER h);
00034
00035 #ifdef __cplusplus
00036 }
00037 #endif
00038
00039 #endif // _CTETEST_H
00040
00041
00042
00043
00044
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/CMallSpy/CMallSpy.Hxx Source File

  • Com
  • Fundamentals
  • CMallSpy

CMallSpy.Hxx

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 //+---------------------------------------------------------------------
00019 //
00020 //  File:       cmallspy.hxx
00021 //
00022 //  Contents:   CMallocSpy definitions
00023 //
00024 //----------------------------------------------------------------------
00025
00026
00027
00028
00029 class CMallocSpy : public IMallocSpy
00030 {
00031 public:
00032     CMallocSpy(void);
00033     ~CMallocSpy(void);
00034
00035     // IUnknown methods
00036     STDMETHOD(QueryInterface) (REFIID riid, LPVOID *ppUnk);
00037     STDMETHOD_(ULONG, AddRef) (void);
00038     STDMETHOD_(ULONG, Release) (void);
00039
00040
00041     // IMallocSpy methods
00042     STDMETHOD_(SIZE_T, PreAlloc) (SIZE_T cbRequest);
00043     STDMETHOD_(void *, PostAlloc) (void *pActual);
00044
00045     STDMETHOD_(void *, PreFree) (void *pRequest, BOOL fSpyed);
00046     STDMETHOD_(void, PostFree) (BOOL fSpyed);
00047
00048     STDMETHOD_(SIZE_T, PreRealloc) (void *pRequest, SIZE_T cbRequest,
00049                                    void **ppNewRequest, BOOL fSpyed);
00050     STDMETHOD_(void *, PostRealloc) (void *pActual, BOOL fSpyed);
00051
00052     STDMETHOD_(void *, PreGetSize) (void *pRequest, BOOL fSpyed);
00053     STDMETHOD_(SIZE_T, PostGetSize) (SIZE_T cbActual, BOOL fSpyed);
00054
00055     STDMETHOD_(void *, PreDidAlloc) (void *pRequest, BOOL fSpyed);
00056     STDMETHOD_(BOOL, PostDidAlloc) (void *pRequest, BOOL fSpyed, BOOL fActual);
00057
00058     STDMETHOD_(void, PreHeapMinimize) (void);
00059     STDMETHOD_(void, PostHeapMinimize) (void);
00060
00061
00062 private:
00063     ULONG    m_cRef;
00064     SIZE_T   m_cbRequest;
00065
00066 };
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IPHelp/EnableRouter/enablerouter.c Source File

  • NetDS
  • IPHelp
  • EnableRouter

enablerouter.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 *
00006 *       THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00007 *       ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00008 *       THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00009 *       PARTICULAR PURPOSE.
00010 \******************************************************************************/
00011
00012 #include <windows.h>
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <time.h>
00016
00017 #define RETURN_SUCCESS  0
00018 #define RETURN_FAILURE  1
00019 #define MAX_STRLEN    128
00020
00021 #define SUCCESS_PRINT(X,Y,Z)  { \
00022                 printf("%s: %s SUCCEEDED: Return %lu: line %d\n",X,Y,Z, __LINE__); \
00023                 fflush(stdout); \
00024                 }
00025
00026 #define FAIL_PRINT(X,Y,Z) { \
00027               printf("%s: %s FAILED: Error %lu: line %d\n",X,Y,Z, __LINE__); \
00028               fflush(stdout); \
00029               }
00030
00031 HINSTANCE Hinstance;
00032 DWORD Error, Count, dwThreadId;
00033 HANDLE Handle, hThread;
00034 OVERLAPPED Overlapped, OverlappedUnenableRouter;
00035 INT i;
00036 DWORD (WINAPI* EnableRouter)(PHANDLE, LPOVERLAPPED);
00037 DWORD (WINAPI* UnenableRouter)(LPOVERLAPPED, LPDWORD);
00038
00039 // prototypes
00040 void CommandLineUsage(void);
00041 DWORD WINAPI NullHandleCase(LPVOID);
00042 DWORD WINAPI NullOverlappedCase(LPVOID);
00043 DWORD WINAPI AllNullParamCase(LPVOID);
00044 int UnreadableRand(size_t length, char szTestNumber[MAX_STRLEN]);
00045 int UnwriteableRand(size_t length, char szTestNumber[MAX_STRLEN]);
00046
00047 int __cdecl
00048 main(
00049     int argc,
00050     char* argv[]
00051     )
00052 {
00053   Hinstance = LoadLibrary(TEXT("IPHLPAPI.DLL"));
00054     if (!Hinstance)
00055   {
00056         printf("LoadLibrary: %d\n", GetLastError());
00057     return RETURN_FAILURE;
00058     }
00059   else
00060   {
00061     EnableRouter =
00062       (DWORD (WINAPI*)(PHANDLE, LPOVERLAPPED))
00063         GetProcAddress(Hinstance, "EnableRouter");
00064     UnenableRouter =
00065       (DWORD (WINAPI*)(LPOVERLAPPED, LPDWORD))
00066         GetProcAddress(Hinstance, "UnenableRouter");
00067     if (!EnableRouter || !UnenableRouter)
00068     {
00069       printf("GetProcAddress: %d\n", GetLastError());
00070       return RETURN_FAILURE;
00071     }
00072   }
00073
00074 // Step through one iteration if there are no command line switches
00075
00076   if (argc < 2)
00077   {
00078     ZeroMemory(&Overlapped, sizeof(Overlapped));
00079     Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00080     if (!Overlapped.hEvent)
00081     {
00082       printf("CreateEvent: %d\n", GetLastError());
00083       return RETURN_FAILURE;
00084     }
00085     else
00086     {
00087       Error = EnableRouter(&Handle, &Overlapped);
00088       if (Error != ERROR_IO_PENDING)
00089       {
00090         printf("EnableRouter: %d\n", Error);
00091         return RETURN_FAILURE;
00092       }
00093       else
00094       {
00095         printf("Press <Enter> to disable routing");
00096         getchar();
00097         Error = UnenableRouter(&Overlapped, &Count);
00098         if (Error)
00099         {
00100           printf("UnenableRouter: %d\n", Error);
00101           return RETURN_FAILURE;
00102         }
00103         else
00104         {
00105           printf("UnenableRouter: %d references left\n", Count);
00106         }
00107       }
00108       CloseHandle(Overlapped.hEvent);
00109     }
00110     FreeLibrary(Hinstance);
00111     return RETURN_SUCCESS;
00112   }
00113
00114 // Loop continuously for the 'stress' command line switch
00115
00116   if ((argv[1][0] == 's') || (argv[1][0] == 'S'))
00117   {
00118     i = 1;
00119     while (TRUE)
00120     {
00121       ZeroMemory(&Overlapped, sizeof(Overlapped));
00122       Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00123       if (!Overlapped.hEvent)
00124       {
00125         printf("CreateEvent: %d\n", GetLastError());
00126         return RETURN_FAILURE;
00127       }
00128       else
00129       {
00130         Error = EnableRouter(&Handle, &Overlapped);
00131         if (Error != ERROR_IO_PENDING)
00132         {
00133           printf("EnableRouter: %d\n", Error);
00134         }
00135         else
00136         {
00137           Error = UnenableRouter(&Overlapped, &Count);
00138           if (Error)
00139           {
00140             printf("UnenableRouter: %d\n", Error);
00141           }
00142           else
00143           {
00144             if ((i % 100) == 0)
00145             {
00146               printf("Enable/UnenableRouter Stress: %d iterations\n", i);
00147             }
00148             i++;
00149           }
00150         }
00151         CloseHandle(Overlapped.hEvent);
00152       }
00153     }
00154     FreeLibrary(Hinstance);
00155     return RETURN_SUCCESS;
00156   }
00157
00158 // Run the API regressions for the 'regress' command line switch
00159
00160   if ((argv[1][0] == 'r') || (argv[1][0] == 'R'))
00161   {
00162     srand( (unsigned)time( NULL ) );
00163     rand();        // throw out the first number because of its predictability
00164
00165 // Regression test EnableRouter()
00166
00167     printf("\n\n\tRegression tests for EnableRouter()\n\n");
00168
00169 // Test 1: Do not zero memory for the Overlapped structure
00170
00171     printf("\nRegression Test 1: Do not zero memory for the Overlapped structure\n");
00172
00173     printf("\nRegression Test 1: ZeroMemory(&Overlapped, sizeof(Overlapped)) NOT called\n");
00174
00175     Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00176     if (!Overlapped.hEvent)
00177     {
00178       FAIL_PRINT("Regression Test 1", "CreateEvent", GetLastError());
00179     }
00180     else
00181     {
00182       SUCCESS_PRINT("Regression Test 1", "CreateEvent", GetLastError());
00183       Error = EnableRouter(&Handle, &Overlapped);
00184       if (Error != ERROR_IO_PENDING)
00185       {
00186         FAIL_PRINT("Regression Test 1", "EnableRouter", Error);
00187       }
00188       else
00189       {
00190         SUCCESS_PRINT("Regression Test 1", "EnableRouter", Error);
00191         Error = UnenableRouter(&Overlapped, &Count);
00192         if (Error)
00193         {
00194           FAIL_PRINT("Regression Test 1", "UnenableRouter", Error);
00195         }
00196         else
00197         {
00198           SUCCESS_PRINT("Regression Test 1", "UnenableRouter", Error);
00199           printf("Regression Test 1: UnenableRouter: %d references left\n", Count);
00200         }
00201       }
00202       CloseHandle(Overlapped.hEvent);
00203     }
00204
00205 // Test 2: Overlapped.hEvent is zero
00206
00207     printf("\nRegression Test 2: Set Overlapped.hEvent equal to zero\n");
00208
00209     printf("\nRegression Test 2: Overlapped.hEvent = 0\n");
00210
00211     ZeroMemory(&Overlapped, sizeof(Overlapped));
00212     Overlapped.hEvent = 0;
00213     Error = EnableRouter(&Handle, &Overlapped);
00214     if (Error != ERROR_IO_PENDING)
00215     {
00216       FAIL_PRINT("Regression Test 2", "EnableRouter", Error);
00217     }
00218     else
00219     {
00220       SUCCESS_PRINT("Regression Test 2", "EnableRouter", Error);
00221       Error = UnenableRouter(&Overlapped, &Count);
00222       if (Error)
00223       {
00224         FAIL_PRINT("Regression Test 2", "UnenableRouter", Error);
00225       }
00226       else
00227       {
00228         SUCCESS_PRINT("Regression Test 2", "UnenableRouter", Error);
00229         printf("Regression Test 2: UnenableRouter: %d references left\n", Count);
00230       }
00231     }
00232
00233 // Test 3: Pass NULL parameters to EnableRouter()
00234
00235     printf("\nRegression Test 3: Pass NULL parameters to EnableRouter()\n");
00236
00237     printf("\nRegression Test 3.1: EnableRouter(NULL, &Overlapped)\n");
00238
00239     hThread = NULL;
00240     dwThreadId = 0;
00241     hThread = CreateThread(NULL, 0, NullHandleCase, NULL, CREATE_SUSPENDED, &dwThreadId);
00242     if (hThread == NULL)
00243     {
00244       FAIL_PRINT("Regression Test 3.1", "CreateThread", GetLastError());
00245     }
00246     else
00247     {
00248       Error = ResumeThread(hThread);
00249       if (Error == 0xFFFFFFFF)
00250       {
00251         FAIL_PRINT("Regression Test 3.1", "ResumeThread", GetLastError());
00252       }
00253       else
00254       {
00255         Error = WaitForSingleObject(hThread, 10000);  // wait 10 seconds for thread to complete
00256         if ((Error == WAIT_FAILED) || (Error == WAIT_ABANDONED))
00257         {
00258           FAIL_PRINT("Regression Test 3.1", "WaitForSingleObject", GetLastError());
00259         }
00260         if (Error == WAIT_OBJECT_0)
00261         {
00262           FAIL_PRINT("Regression Test 3.1", "WaitForSingleObject", GetLastError());
00263           printf("Regression Test 3.1: WAIT_OBJECT_0 was unexpected\n");
00264         }
00265         if (Error == WAIT_TIMEOUT)
00266         {
00267           SUCCESS_PRINT("Regression Test 3.1", "WaitForSingleObject", Error);
00268           printf("Regression Test 3.1: WAIT_TIMEOUT was expected\n");
00269         }
00270       }
00271       CloseHandle(hThread);
00272     }
00273
00274     printf("\nRegression Test 3.2: EnableRouter(&Handle, NULL)\n");
00275
00276     hThread = NULL;
00277     dwThreadId = 0;
00278     hThread = CreateThread(NULL, 0, NullOverlappedCase, NULL, CREATE_SUSPENDED, &dwThreadId);
00279     if (hThread == NULL)
00280     {
00281       FAIL_PRINT("Regression Test 3.2", "CreateThread", GetLastError());
00282     }
00283     else
00284     {
00285       Error = ResumeThread(hThread);
00286       if (Error == 0xFFFFFFFF)
00287       {
00288         FAIL_PRINT("Regression Test 3.2", "ResumeThread", GetLastError());
00289       }
00290       else
00291       {
00292         Error = WaitForSingleObject(hThread, 10000);  // wait 10 seconds for thread to complete
00293         if ((Error == WAIT_FAILED) || (Error == WAIT_ABANDONED))
00294         {
00295           FAIL_PRINT("Regression Test 3.2", "WaitForSingleObject", GetLastError());
00296         }
00297         if (Error == WAIT_OBJECT_0)
00298         {
00299           FAIL_PRINT("Regression Test 3.2", "WaitForSingleObject", GetLastError());
00300           printf("Regression Test 3.2: WAIT_OBJECT_0 was unexpected\n");
00301         }
00302         if (Error == WAIT_TIMEOUT)
00303         {
00304           SUCCESS_PRINT("Regression Test 3.2", "WaitForSingleObject", Error);
00305           printf("Regression Test 3.2: WAIT_TIMEOUT was expected\n");
00306         }
00307       }
00308       CloseHandle(hThread);
00309     }
00310
00311     printf("\nRegression Test 3.3: EnableRouter(NULL, NULL)\n");
00312
00313     hThread = NULL;
00314     dwThreadId = 0;
00315     hThread = CreateThread(NULL, 0, AllNullParamCase, NULL, CREATE_SUSPENDED, &dwThreadId);
00316     if (hThread == NULL)
00317     {
00318       FAIL_PRINT("Regression Test 3.3", "CreateThread", GetLastError());
00319     }
00320     else
00321     {
00322       Error = ResumeThread(hThread);
00323       if (Error == 0xFFFFFFFF)
00324       {
00325         FAIL_PRINT("Regression Test 3.3", "ResumeThread", GetLastError());
00326       }
00327       else
00328       {
00329         Error = WaitForSingleObject(hThread, 10000);  // wait 10 seconds for thread to complete
00330         if ((Error == WAIT_FAILED) || (Error == WAIT_ABANDONED))
00331         {
00332           FAIL_PRINT("Regression Test 3.3", "WaitForSingleObject", GetLastError());
00333         }
00334         if (Error == WAIT_OBJECT_0)
00335         {
00336           FAIL_PRINT("Regression Test 3.3", "WaitForSingleObject", GetLastError());
00337           printf("Regression Test 3.3: WAIT_OBJECT_0 was unexpected\n");
00338         }
00339         if (Error == WAIT_TIMEOUT)
00340         {
00341           SUCCESS_PRINT("Regression Test 3.3", "WaitForSingleObject", Error);
00342           printf("Regression Test 3.3: WAIT_TIMEOUT was expected\n");
00343         }
00344       }
00345       CloseHandle(hThread);
00346     }
00347
00348 // Test 4: Pass bad pointers, unreadable or unwriteable, to EnableRouter()
00349
00350     printf("\nRegression Test 4: Pass bad pointers to EnableRouter()\n");
00351
00352     printf("\nRegression Test 4.1: EnableRouter((unwriteable pointer), &Overlapped)\n");
00353
00354     ZeroMemory(&Overlapped, sizeof(Overlapped));
00355     Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00356     if (!Overlapped.hEvent)
00357     {
00358       FAIL_PRINT("Regression Test 4.1", "CreateEvent", GetLastError());
00359     }
00360     else
00361     {
00362       SUCCESS_PRINT("Regression Test 4.1", "CreateEvent", GetLastError());
00363       Error = EnableRouter((HANDLE *)UnwriteableRand(sizeof(Handle), "Regression Test 4.1"), &Overlapped);
00364       if (Error == ERROR_INVALID_PARAMETER)
00365       {
00366         SUCCESS_PRINT("Regression Test 4.1", "EnableRouter", Error);
00367         printf("Regression Test 4.1: ERROR_INVALID_PARAMETER was expected\n");
00368       }
00369       else
00370       {
00371         if (Error == ERROR_IO_PENDING)
00372         {
00373           FAIL_PRINT("Regression Test 4.1", "EnableRouter", Error);
00374           printf("Regression Test 4.1: ERROR_IO_PENDING was unexpected\n");
00375           Error = UnenableRouter(&Overlapped, &Count);
00376           if (Error)
00377           {
00378             FAIL_PRINT("Regression Test 4.1", "UnenableRouter", Error);
00379           }
00380           else
00381           {
00382             SUCCESS_PRINT("Regression Test 4.1", "UnenableRouter", Error);
00383             printf("Regression Test 4.1: UnenableRouter: %d references left\n", Count);
00384           }
00385         }
00386         else
00387         {
00388           FAIL_PRINT("Regression Test 4.1", "EnableRouter", Error);
00389           printf("Regression Test 4.1: This ERROR?? was unexpected\n");
00390         }
00391       }
00392       CloseHandle(Overlapped.hEvent);
00393     }
00394
00395     printf("\nRegression Test 4.2: EnableRouter(&Handle, (unreadable pointer))\n");
00396
00397     ZeroMemory(&Overlapped, sizeof(Overlapped));
00398     Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00399     if (!Overlapped.hEvent)
00400     {
00401       FAIL_PRINT("Regression Test 4.2", "CreateEvent", GetLastError());
00402     }
00403     else
00404     {
00405       SUCCESS_PRINT("Regression Test 4.2", "CreateEvent", GetLastError());
00406       Error = EnableRouter(&Handle, (OVERLAPPED *)UnreadableRand(sizeof(Overlapped), "Regression Test 4.2"));
00407       if (Error == ERROR_INVALID_PARAMETER)
00408       {
00409         SUCCESS_PRINT("Regression Test 4.2", "EnableRouter", Error);
00410         printf("Regression Test 4.2: ERROR_INVALID_PARAMETER was expected\n");
00411       }
00412       else
00413       {
00414         if (Error == ERROR_IO_PENDING)
00415         {
00416           FAIL_PRINT("Regression Test 4.2", "EnableRouter", Error);
00417           printf("Regression Test 4.2: ERROR_IO_PENDING was unexpected\n");
00418           Error = UnenableRouter(&Overlapped, &Count);
00419           if (Error)
00420           {
00421             FAIL_PRINT("Regression Test 4.2", "UnenableRouter", Error);
00422           }
00423           else
00424           {
00425             SUCCESS_PRINT("Regression Test 4.2", "UnenableRouter", Error);
00426             printf("Regression Test 4.2: UnenableRouter: %d references left\n", Count);
00427           }
00428         }
00429         else
00430         {
00431           FAIL_PRINT("Regression Test 4.2", "EnableRouter", Error);
00432           printf("Regression Test 4.2: This ERROR?? was unexpected\n");
00433         }
00434       }
00435       CloseHandle(Overlapped.hEvent);
00436     }
00437
00438     printf("\nRegression Test 4.3: EnableRouter((unwritable pointer), (unreadable pointer))\n");
00439
00440     ZeroMemory(&Overlapped, sizeof(Overlapped));
00441     Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00442     if (!Overlapped.hEvent)
00443     {
00444       FAIL_PRINT("Regression Test 4.3", "CreateEvent", GetLastError());
00445     }
00446     else
00447     {
00448       SUCCESS_PRINT("Regression Test 4.3", "CreateEvent", GetLastError());
00449       Error = EnableRouter((HANDLE *)UnwriteableRand(sizeof(Handle), "Regression Test 4.3"),
00450                 (OVERLAPPED *)UnreadableRand(sizeof(Overlapped), "Regression Test 4.3"));
00451       if (Error == ERROR_INVALID_PARAMETER)
00452       {
00453         SUCCESS_PRINT("Regression Test 4.3", "EnableRouter", Error);
00454         printf("Regression Test 4.3: ERROR_INVALID_PARAMETER was expected\n");
00455       }
00456       else
00457       {
00458         if (Error == ERROR_IO_PENDING)
00459         {
00460           FAIL_PRINT("Regression Test 4.3", "EnableRouter", Error);
00461           printf("Regression Test 4.3: ERROR_IO_PENDING was unexpected\n");
00462           Error = UnenableRouter(&Overlapped, &Count);
00463           if (Error)
00464           {
00465             FAIL_PRINT("Regression Test 4.3", "UnenableRouter", Error);
00466           }
00467           else
00468           {
00469             SUCCESS_PRINT("Regression Test 4.3", "UnenableRouter", Error);
00470             printf("Regression Test 4.3: UnenableRouter: %d references left\n", Count);
00471           }
00472         }
00473         else
00474         {
00475           FAIL_PRINT("Regression Test 4.3", "EnableRouter", Error);
00476           printf("Regression Test 4.3: This ERROR?? was unexpected\n");
00477         }
00478       }
00479       CloseHandle(Overlapped.hEvent);
00480     }
00481
00482 // Regression test UnenableRouter()
00483
00484     printf("\n\n\tRegression tests for UnenableRouter()\n\n");
00485
00486 // Test 5: Use an Overlapped that is different from the one used for EnableRouter
00487
00488     printf("\nRegression Test 5: Use a different Overlapped than the one used for EnableRouter\n");
00489
00490     printf("\nRegression Test 5: Declare OVERLAPPED OverlappedUnenableRouter\n");
00491
00492     ZeroMemory(&Overlapped, sizeof(Overlapped));
00493     Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00494     if (!Overlapped.hEvent)
00495     {
00496       FAIL_PRINT("Regression Test 5", "CreateEvent", GetLastError());
00497     }
00498     else
00499     {
00500       SUCCESS_PRINT("Regression Test 5", "CreateEvent", GetLastError());
00501       Error = EnableRouter(&Handle, &Overlapped);
00502       if (Error != ERROR_IO_PENDING)
00503       {
00504         FAIL_PRINT("Regression Test 5", "EnableRouter", Error);
00505       }
00506       else
00507       {
00508         SUCCESS_PRINT("Regression Test 5", "EnableRouter", Error);
00509         ZeroMemory(&OverlappedUnenableRouter, sizeof(OverlappedUnenableRouter));
00510         OverlappedUnenableRouter.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00511         if (!OverlappedUnenableRouter.hEvent)
00512         {
00513           FAIL_PRINT("Regression Test 5", "CreateEvent", GetLastError());
00514         }
00515         else
00516         {
00517           SUCCESS_PRINT("Regression Test 5", "CreateEvent", GetLastError());
00518           Error = UnenableRouter(&OverlappedUnenableRouter, &Count);
00519           if (Error)
00520           {
00521             FAIL_PRINT("Regression Test 5", "UnenableRouter", Error);
00522           }
00523           else
00524           {
00525             SUCCESS_PRINT("Regression Test 5", "UnenableRouter", Error);
00526             printf("Regression Test 5: UnenableRouter: %d references left\n", Count);
00527           }
00528           CloseHandle(OverlappedUnenableRouter.hEvent);
00529         }
00530       }
00531       CloseHandle(Overlapped.hEvent);
00532     }
00533
00534
00535     FreeLibrary(Hinstance);
00536     return RETURN_SUCCESS;
00537   }
00538   CommandLineUsage();
00539   FreeLibrary(Hinstance);
00540   return RETURN_FAILURE;
00541 }
00542
00543 void
00544 CommandLineUsage(
00545                  void
00546                  )
00547 {
00548    fprintf( stderr, "\nEnableRouter [stress, regress]\n\n" );
00549    fprintf( stderr, "  'enablerouter' with no parameters will step through one iteration of\n" );
00550    fprintf( stderr, "                 enabling and disabling the router\n\n" );
00551    fprintf( stderr, "  'enablerouter stress' will enable and disable the router in an infinite loop\n\n" );
00552    fprintf( stderr, "  'enablerouter regress' will perform the EnableRouter() and UnenableRouter()\n" );
00553    fprintf( stderr, "                         regression tests\n\n" );
00554    fprintf( stderr, "  Any other parameter will display this help message\n\n" );
00555 }
00556
00557 DWORD WINAPI
00558 NullHandleCase(
00559          LPVOID lpNotUsed
00560          )
00561 {
00562   ZeroMemory(&Overlapped, sizeof(Overlapped));
00563   Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00564   if (!Overlapped.hEvent)
00565   {
00566     FAIL_PRINT("Regression Test 3.1", "CreateEvent", GetLastError());
00567   }
00568   else
00569   {
00570     SUCCESS_PRINT("Regression Test 3.1", "CreateEvent", GetLastError());
00571     printf("Regression Test 3.1: Call to EnableRouter(NULL, &Overlapped) is expected to block\n");
00572     Error = EnableRouter(NULL, &Overlapped);
00573     if (Error != ERROR_IO_PENDING)
00574     {
00575       FAIL_PRINT("Regression Test 3.1", "EnableRouter", Error);
00576     }
00577     else
00578     {
00579       SUCCESS_PRINT("Regression Test 3.1", "EnableRouter", Error);
00580       Error = UnenableRouter(&Overlapped, &Count);
00581       if (Error)
00582       {
00583         FAIL_PRINT("Regression Test 3.1", "UnenableRouter", Error);
00584       }
00585       else
00586       {
00587         SUCCESS_PRINT("Regression Test 3.1", "UnenableRouter", Error);
00588         printf("Regression Test 3.1: UnenableRouter: %d references left\n", Count);
00589       }
00590     }
00591     CloseHandle(Overlapped.hEvent);
00592   }
00593   return RETURN_FAILURE;
00594 }
00595
00596 DWORD WINAPI
00597 NullOverlappedCase(
00598            LPVOID lpNotUsed
00599            )
00600 {
00601   ZeroMemory(&Overlapped, sizeof(Overlapped));
00602   Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00603   if (!Overlapped.hEvent)
00604   {
00605     FAIL_PRINT("Regression Test 3.2", "CreateEvent", GetLastError());
00606   }
00607   else
00608   {
00609     SUCCESS_PRINT("Regression Test 3.2", "CreateEvent", GetLastError());
00610     printf("Regression Test 3.2: Call to EnableRouter(&Handle, NULL) is expected to block\n");
00611     Error = EnableRouter(&Handle, NULL);
00612     if (Error != ERROR_IO_PENDING)
00613     {
00614       FAIL_PRINT("Regression Test 3.2", "EnableRouter", Error);
00615     }
00616     else
00617     {
00618       SUCCESS_PRINT("Regression Test 3.2", "EnableRouter", Error);
00619       Error = UnenableRouter(&Overlapped, &Count);
00620       if (Error)
00621       {
00622         FAIL_PRINT("Regression Test 3.2", "UnenableRouter", Error);
00623       }
00624       else
00625       {
00626         SUCCESS_PRINT("Regression Test 3.2", "UnenableRouter", Error);
00627         printf("Regression Test 3.2: UnenableRouter: %d references left\n", Count);
00628       }
00629     }
00630     CloseHandle(Overlapped.hEvent);
00631   }
00632   return RETURN_FAILURE;
00633 }
00634
00635 DWORD WINAPI
00636 AllNullParamCase(
00637          LPVOID lpNotUsed
00638          )
00639 {
00640   ZeroMemory(&Overlapped, sizeof(Overlapped));
00641   Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00642   if (!Overlapped.hEvent)
00643   {
00644     FAIL_PRINT("Regression Test 3.3", "CreateEvent", GetLastError());
00645   }
00646   else
00647   {
00648     SUCCESS_PRINT("Regression Test 3.3", "CreateEvent", GetLastError());
00649     printf("Regression Test 3.3: Call to EnableRouter(NULL, NULL) is expected to block\n");
00650     Error = EnableRouter(NULL, NULL);
00651     if (Error != ERROR_IO_PENDING)
00652     {
00653       FAIL_PRINT("Regression Test 3.3", "EnableRouter", Error);
00654     }
00655     else
00656     {
00657       SUCCESS_PRINT("Regression Test 3.3", "EnableRouter", Error);
00658       Error = UnenableRouter(&Overlapped, &Count);
00659       if (Error)
00660       {
00661         FAIL_PRINT("Regression Test 3.3", "UnenableRouter", Error);
00662       }
00663       else
00664       {
00665         SUCCESS_PRINT("Regression Test 3.3", "UnenableRouter", Error);
00666         printf("Regression Test 3.3: UnenableRouter: %d references left\n", Count);
00667       }
00668     }
00669     CloseHandle(Overlapped.hEvent);
00670   }
00671   return RETURN_FAILURE;
00672 }
00673
00674 int UnreadableRand(
00675            size_t length, char szTestNumber[MAX_STRLEN]
00676            )
00677 // This Function returns a number, which when interpreted as a pointer is not readable
00678 {
00679     int RandVal;
00680   for (i = 1; i < 5001; i++)
00681     {
00682       RandVal = rand();
00683     if (IsBadReadPtr((CONST VOID *)RandVal, (UINT)length) != 0)
00684     {
00685       printf("%s: Returning an UNREADABLE pointer\n", szTestNumber);
00686       return RandVal;
00687     }
00688     }
00689   printf("%s: Returning a READABLE pointer\n", szTestNumber);
00690     return RandVal;
00691 }
00692
00693 int UnwriteableRand(
00694           size_t length, char szTestNumber[MAX_STRLEN]
00695           )
00696 // This Function returns a number, which when interpreted as a pointer is not writeable
00697 {
00698     int RandVal;
00699   for (i = 1; i < 5001; i++)
00700     {
00701       RandVal = rand();
00702     if (IsBadWritePtr((LPVOID)RandVal, (UINT)length) != 0)
00703     {
00704       printf("%s: Returning an UNWRITEABLE pointer\n", szTestNumber);
00705       return RandVal;
00706     }
00707     }
00708     printf("%s: Returning a WRITEABLE pointer\n", szTestNumber);
00709   return RandVal;
00710 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/adddevicedlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

adddevicedlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddDeviceDlg.cpp:  Implementation of the CAddDeviceDlg class.
00015 //
00016
00017
00018
00019 #include "AddDeviceDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddDeviceDlg::CAddDeviceDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddDeviceDlg::~CAddDeviceDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddDeviceDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00055   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00056
00057   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00060   lResult = SendMessage( hBackupCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00061   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00062
00063   lResult = SetWindowText( hDevNameCtrl, _T("") );
00064   SetFocus( hDevNameCtrl );
00065
00066   return 0;
00067 }
00068
00069 //---------------------------------------------------------------------------
00070 LRESULT CAddDeviceDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00071 {
00072   LRESULT          lResult = 0;
00073   NODE_PROPERTIES  NodeProps;
00074
00075   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00076
00077   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00078   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00079   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00080   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00081   HWND hBackupCtrl   = GetDlgItem( hDlg, IDC_BACKUP_FLAG   );
00082   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00083
00084   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00086
00087   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00089
00090   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00092
00093   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00094     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00095
00096   if( BST_CHECKED == SendMessage( hBackupCtrl, BM_GETCHECK, 0, 0 ) )
00097     NodeProps.dwAttributes |= ATTRIBUTE_BACKUP_DEVICE;
00098
00099   // Convert to wide characters here for all platforms.  This is the node name
00100   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00101   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00102   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00103   // Probably a good idea to check for NULL name strings here
00104
00105   // This message passes the user supplied info to the Static Node
00106   SendMessage( m_hParentWnd, WM_ADDNEW_NODE, (WPARAM)&NodeProps, 0 );
00107
00108   // Now tell the static node we are deleting ourselves so the
00109   // context menu option can be enabled
00110   SendMessage( m_hParentWnd, WM_DIALOG_CLOSED, 0, 0 );
00111
00112   // Call the base class to shut down the dialog
00113   CBaseDialog::OnOK( hDlg, wParam, lParam );
00114   return 0;
00115 }
00116
00117 /////////////////////////////////////////////////////////////////////////////
00118 //  Virtual function implementations
00119
00120 //---------------------------------------------------------------------------
00121 BOOL CAddDeviceDlg::ProcessMessage
00122 (
00123   HWND     hDlg,           //[in] Handle to dialog box
00124   UINT     uMsg,           //[in] Message
00125   WPARAM   wParam,         //[in] First message parameter
00126   LPARAM   lParam          //[in] Second message parameter
00127 )
00128 {
00129   LRESULT lResult = 0;
00130
00131   switch( uMsg )
00132   {
00133     case WM_INITDIALOG:
00134       lResult = OnInitDialog( hDlg, wParam, lParam );
00135       break;
00136
00137     case WM_DESTROY:
00138       lResult = OnDestroy( hDlg, wParam, lParam );
00139       break;
00140
00141     case WM_NCDESTROY:
00142       lResult = OnNcDestroy( hDlg, wParam, lParam );
00143       break;
00144
00145     case WM_CLOSE:
00146       // Not overriding WM_CLOSE and IDCANCEL so we must send
00147       // WM_DIALOG_CLOSED before calling the base class or else
00148       // the context menu will stay grayed
00149       SendMessage( m_hParentWnd, WM_DIALOG_CLOSED, 0, 0 );
00150       lResult = OnClose( hDlg, wParam, lParam );
00151       break;
00152
00153     case WM_COMMAND:
00154       switch( wParam )
00155       {
00156         case IDOK:
00157           lResult = OnOK( hDlg, wParam, lParam );
00158           break;
00159
00160         case IDCANCEL:
00161           SendMessage( m_hParentWnd, WM_DIALOG_CLOSED, 0, 0 );
00162           lResult = OnCancel( hDlg, wParam, lParam );
00163           break;
00164
00165         default:
00166           break;
00167       }
00168     default:
00169       break;
00170   }
00171   return (BOOL)lResult;
00172 }
00173
00174
00175
Generated on Wed Nov 13 2024 16:52:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/vcAcct/CGetReceipt.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • vcAcct

CGetReceipt.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc19.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\mssdk\samples\com\Services\Transaction\SampleBank\vcacct\release\vcacct.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package vcacct;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.class(classid=A81260B2-DDC8-11D0-B5A0-00C04FB957D8,DynamicCasts)
00019     @com.interface(iid=A81260B1-DDC8-11D0-B5A0-00C04FB957D8, thread=AUTO, type=DUAL) */
00020 public class CGetReceipt implements IUnknown,com.ms.com.NoAutoScripting,vcacct.IGetReceipt
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=METHOD, name="GetNextReceipt", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public native int GetNextReceipt();
00025
00026
00027   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0xa81260b1, (short)0xddc8, (short)0x11d0, (byte)0xb5, (byte)0xa0, (byte)0x0, (byte)0xc0, (byte)0x4f, (byte)0xb9, (byte)0x57, (byte)0xd8);
00028
00029   public static final com.ms.com._Guid clsid = new com.ms.com._Guid((int)0xa81260b2, (short)0xddc8, (short)0x11d0, (byte)0xb5, (byte)0xa0, (byte)0x0, (byte)0xc0, (byte)0x4f, (byte)0xb9, (byte)0x57, (byte)0xd8);
00030 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CConsumer Member List

This is the complete list of members for CConsumer, including all inherited members.
CConsumer(CListBox *pOutputList) | CConsumer |
CConsumer(CListBox *pOutputList) | CConsumer |
ErrorString(HRESULT hRes) | CConsumer | [private]
ErrorString(HRESULT hRes) | CConsumer | [private]
IndicateToConsumer(IWbemClassObject *pLogicalConsumer, long lNumObjects, IWbemClassObject **ppObjects) | CConsumer |
IndicateToConsumer(IWbemClassObject *pLogicalConsumer, long lNumObjects, IWbemClassObject **ppObjects) | CConsumer |
m_cRef | CConsumer | [private]
m_pOutputList | CConsumer | [private]
QueryInterface(REFIID, LPVOID *) | CConsumer |
QueryInterface(REFIID, LPVOID *) | CConsumer |
STDMETHODIMP_(ULONG) AddRef(void) | CConsumer |
STDMETHODIMP_(ULONG) Release(void) | CConsumer |
STDMETHODIMP_(ULONG) AddRef(void) | CConsumer |
STDMETHODIMP_(ULONG) Release(void) | CConsumer |
ValueToString(VARIANT *pValue, WCHAR **pbuf) | CConsumer | [private]
~CConsumer() | CConsumer |
~CConsumer() | CConsumer |
Generated on Wed Nov 13 2024 16:55:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/about.h Source File

  • SysMgmt
  • MMC
  • Multisel

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/basesnap.h Source File

  • SysMgmt
  • MMC
  • CutCopy

basesnap.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018 #ifndef _BASESNAP_H_
00019 #define _BASESNAP_H_
00020
00021 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
00022 STDAPI DllCanUnloadNow(void);
00023
00024 ULONG g_uObjects = 0;
00025 ULONG g_uSrvLock = 0;
00026
00027 class CClassFactory : public IClassFactory
00028 {
00029 private:
00030     ULONG m_cref;
00031
00032 public:
00033     enum FACTORY_TYPE {COMPONENT = 0, ABOUT = 1};
00034
00035     CClassFactory(FACTORY_TYPE factoryType);
00036     ~CClassFactory();
00037
00038     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00039     STDMETHODIMP_(ULONG) AddRef();
00040     STDMETHODIMP_(ULONG) Release();
00041
00042     STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
00043     STDMETHODIMP LockServer(BOOL);
00044
00045 private:
00046     FACTORY_TYPE m_factoryType;
00047 };
00048
00049 #endif _BASESNAP_H_
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/multichan/dlgdest.cpp Source File

  • Multimedia
  • Audio
  • multichan

dlgdest.cpp

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) Microsoft Corportation. All rights reserved.
00003 */
00004
00005 // DlgDest.cpp : implementation file
00006 //
00007
00008 #include "stdafx.h"
00009 #include "multichan.h"
00010 #include "DlgDest.h"
00011 #include "dlgsrc.h"
00012 #include "childview.h"
00013 #include <initguid.h>
00014 #include <mmreg.h>
00015 #include <msacm.h>
00016
00017 #ifdef _DEBUG
00018 #define new DEBUG_NEW
00019 #undef THIS_FILE
00020 static char THIS_FILE[] = __FILE__;
00021 #endif
00022
00023
00024 /*
00025  *  CDlgDest
00026  *  MFC stuff
00027  */
00028
00029 /////////////////////////////////////////////////////////////////////////////
00030 // CDlgDest dialog
00031 void
00032 CDlgDest::DoDataExchange
00033 (
00034   CDataExchange* pDX
00035 )
00036 {
00037   CDialog::DoDataExchange(pDX);
00038   //{{AFX_DATA_MAP(CDlgDest)
00039   DDX_Control(pDX, IDC_SPEAKERFLAGS, m_cChannelMask);
00040   DDX_Control(pDX, IDC_AVEBITS, m_cAveBitsPerSec);
00041   DDX_Control(pDX, IDC_REMIX, m_cRemix);
00042   DDX_Control(pDX, IDC_EDIT_VALIDBITS, m_cValidBits);
00043   DDX_Control(pDX, IDC_CHANNELS, m_cChannels);
00044   DDX_Control(pDX, IDC_OUTPUT, m_cOutput);
00045   DDX_Control(pDX, IDC_COMBO_BITDEPTH, m_comboBitDepth);
00046   DDX_Control(pDX, IDC_COMBO_SAMPLERATE, m_comboSampleRate);
00047   DDX_Control(pDX, IDC_COMBO_WAVEFORMAT, m_comboFormat);
00048   DDX_Control(pDX, IDC_PLAY, m_butPlay);
00049     DDX_Control(pDX, IDC_STOP, m_butStop);
00050   DDX_Text(pDX, IDC_EDIT_VALIDBITS, m_wValidBitsPerSample);
00051   DDV_MinMaxUInt(pDX, m_wValidBitsPerSample, 0, 65535);
00052   DDX_Text(pDX, IDC_SPEAKERFLAGS, m_strChannelMask);
00053   //}}AFX_DATA_MAP
00054 }
00055
00056
00057 BEGIN_MESSAGE_MAP(CDlgDest, CDialog)
00058   //{{AFX_MSG_MAP(CDlgDest)
00059   ON_BN_CLICKED(IDC_REMIX, OnRemix)
00060   ON_BN_CLICKED(IDC_PLAY, OnPlay)
00061     ON_BN_CLICKED(IDC_STOP, OnStop)
00062   ON_CBN_SELENDOK(IDC_COMBO_SAMPLERATE, OnComboSamplerate)
00063   ON_CBN_SELENDOK(IDC_COMBO_WAVEFORMAT, OnComboWaveformat)
00064   ON_CBN_SELENDOK(IDC_COMBO_BITDEPTH, OnComboBitdepth)
00065   ON_EN_KILLFOCUS(IDC_EDIT_VALIDBITS, OnEditValidbits)
00066   ON_WM_CTLCOLOR()
00067   ON_WM_LBUTTONDOWN()
00068   ON_WM_LBUTTONUP()
00069   ON_WM_MOUSEMOVE()
00070   //}}AFX_MSG_MAP
00071 END_MESSAGE_MAP()
00072
00073 /*
00074  *  CDlgDest
00075  *  construction
00076  */
00077
00078 // ----------------------------------------------------------------------------------
00079 // constructor
00080 // ----------------------------------------------------------------------------------
00081 CDlgDest::CDlgDest
00082 (
00083   CWnd* pParent /*=NULL*/
00084 )
00085   : CDialog(CDlgDest::IDD, pParent),
00086     m_pwndParent(pParent),
00087     m_pbData(NULL),
00088     m_fPlayable(FALSE),
00089     m_fDragging(FALSE),
00090   m_cbData( 0 ),
00091     m_lpwhdr( 0 )
00092 {
00093   //{{AFX_DATA_INIT(CDlgDest)
00094   m_wValidBitsPerSample = 0;
00095   m_strChannelMask = _T("0x00000000");
00096   //}}AFX_DATA_INIT
00097
00098     m_wfExt.Format.wFormatTag = WAVE_FORMAT_PCM;
00099     m_wfExt.Format.cbSize = 0;
00100     m_wfExt.Format.wBitsPerSample = 16;
00101     m_wfExt.Format.nChannels = 0;
00102     m_wfExt.Format.nBlockAlign = 4;
00103     m_wfExt.Format.nSamplesPerSec = 44100;
00104     m_wfExt.Format.nAvgBytesPerSec = m_wfExt.Format.nBlockAlign * m_wfExt.Format.nSamplesPerSec;
00105     m_wfExt.Samples.wValidBitsPerSample = 16;
00106     m_wfExt.dwChannelMask = 0;
00107     m_wfExt.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
00108     m_wValidBitsPerSample = m_wfExt.Samples.wValidBitsPerSample;
00109 }
00110
00111 // ----------------------------------------------------------------------------------
00112 // destructor
00113 // ----------------------------------------------------------------------------------
00114 CDlgDest::~CDlgDest
00115 ()
00116 {
00117   SafeLocalFree( m_pbData );
00118     SafeLocalFree( m_lpwhdr );
00119 }
00120
00121 // ----------------------------------------------------------------------------------
00122 // Create
00123 // ----------------------------------------------------------------------------------
00124 void
00125 CDlgDest::Create
00126 (
00127     void
00128 )
00129 {
00130     CDialog::Create(CDlgDest::IDD, m_pwndParent);
00131 }
00132
00133 // ----------------------------------------------------------------------------------
00134 // OnInitDialog
00135 // ----------------------------------------------------------------------------------
00136 // ----------------------------------------------------------------------------------
00137 CONST_GUID_REP cgrFormats[] =
00138 {
00139     &GUID_NULL,                 "GUID_NULL",
00140     &KSDATAFORMAT_SUBTYPE_PCM,  "KSDATAFORMAT_SUBTYPE_PCM"
00141 };
00142
00143 UINT    rgnSampleRate[] = { 8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000 };
00144 UINT    rgnBitDepth[] = { 8, 16, 24, 32 };
00145
00146 BOOL
00147 CDlgDest::OnInitDialog
00148 ()
00149 {
00150   CDialog::OnInitDialog();
00151
00152     int c,i;
00153
00154     i = m_comboFormat.AddString("WAVE_FORMAT_PCM");
00155     m_comboFormat.SetItemData(i, WAVE_FORMAT_PCM);
00156     i = m_comboFormat.AddString("WAVE_FORMAT_EXTENSIBLE");
00157     m_comboFormat.SetItemData(i, WAVE_FORMAT_EXTENSIBLE);
00158
00159     char sz[10];
00160     for(c = 0; c < ARRAY_ELEMENTS(rgnSampleRate); c++)
00161     {
00162         _snprintf(sz, 10, "%d", rgnSampleRate[c]);
00163         i = m_comboSampleRate.AddString(sz);
00164         m_comboSampleRate.SetItemData(i, rgnSampleRate[c]);
00165     }
00166
00167     for(c = 0; c < ARRAY_ELEMENTS(rgnBitDepth); c++)
00168     {
00169         _snprintf(sz, 10, "%d", rgnBitDepth[c]);
00170         i = m_comboBitDepth.AddString(sz);
00171         m_comboBitDepth.SetItemData(i, rgnBitDepth[c]);
00172     }
00173
00174     m_comboSampleRate.SelectString(0, "44100");
00175     m_comboBitDepth.SelectString(0, "16");
00176     m_comboFormat.SelectString(0, "WAVE_FORMAT_PCM");
00177
00178   return TRUE;  // return TRUE unless you set the focus to a control
00179                 // EXCEPTION: OCX Property Pages should return FALSE
00180 }
00181
00182 /*
00183  *  CDlgDest
00184  *  operations
00185  */
00186
00187 // ----------------------------------------------------------------------------------
00188 // OnRemix
00189 //  traverses the list of source channels and mixes them according to the user settings
00190 // ----------------------------------------------------------------------------------
00191 void
00192 CDlgDest::OnRemix
00193 ()
00194 {
00195     CDlgSrc * pdlgSrc   = 0;
00196     ULONG       cMaxSamples = 0;
00197     UINT        nSample;
00198     ULONG       cbSample;
00199
00200     // move over, bacon
00201     SafeLocalFree(m_pbData);
00202
00203     //
00204     // update UI
00205     //
00206     Update();
00207
00208     //
00209     // determine the max number of samples
00210     //
00211     ULONG   cSamplesSrcThisFormat = 0;
00212   for
00213   (
00214     POSITION  pos = g_listSources.GetHeadPosition();
00215     pos;
00216   )
00217     {
00218         pdlgSrc = g_listSources.GetNext(pos);
00219
00220         cSamplesSrcThisFormat = MulDiv(
00221                       m_wfExt.Format.nSamplesPerSec,
00222                       pdlgSrc->m_cSamples,
00223                       pdlgSrc->m_wfx.nSamplesPerSec
00224                   );
00225         cMaxSamples = max(cMaxSamples, cSamplesSrcThisFormat);
00226     }
00227
00228     //
00229   //  determine the length of the buffer required
00230   //
00231     cbSample = m_wfExt.Format.nChannels * m_wfExt.Format.wBitsPerSample / 8;
00232     m_cbData = cbSample * cMaxSamples;
00233     m_pbData = (PBYTE)LocalAlloc(LPTR, m_cbData);
00234     if( 0 == m_pbData)
00235   {
00236     MessageBox( "Insufficient memory to complete the task.", "MultiChan : Error", MB_OK | MB_ICONSTOP );
00237     return;
00238   }
00239
00240     //
00241     // copy data from each src to the dst
00242     //
00243
00244     MMRESULT        mmRes;
00245     HACMSTREAM      has;
00246     ULONG           cbConversion;
00247     PVOID           pvConversion;
00248     ACMSTREAMHEADER ash;
00249     ULONG           cSamplesOut;
00250     BOOL            fRes = FALSE;
00251     WAVEFORMATEX    wfxConversion;
00252
00253   wfxConversion.wFormatTag    = WAVE_FORMAT_PCM;
00254   wfxConversion.cbSize      = 0;
00255   wfxConversion.nChannels     = 1;
00256   wfxConversion.nSamplesPerSec  = m_wfExt.Format.nSamplesPerSec;
00257   wfxConversion.wBitsPerSample  = m_wfExt.Format.wBitsPerSample;
00258   wfxConversion.nBlockAlign   = wfxConversion.wBitsPerSample / 8;
00259   wfxConversion.nAvgBytesPerSec = wfxConversion.nBlockAlign * wfxConversion.nSamplesPerSec;
00260
00261   //
00262   // for each SRC (src dialog), convert it's buffer into 1 channel of the Dst format
00263   //
00264   for
00265   (
00266       pos = g_listSources.GetHeadPosition();
00267     pos;
00268   )
00269     {
00270         pdlgSrc = g_listSources.GetNext(pos);
00271
00272         //
00273         // first, convert dlg format to dest format using ACM
00274         //
00275
00276         // open an appropriate ACM driver
00277         mmRes =
00278             acmStreamOpen
00279             (
00280                 &has,
00281                 NULL,
00282                 &pdlgSrc->m_wfx,
00283                 &wfxConversion,
00284                 NULL,   //wFilter,
00285                 NULL,
00286                 0,
00287                 ACM_STREAMOPENF_NONREALTIME
00288             );
00289
00290         if(!TrapMMError(mmRes, "acmStreamOpen"))
00291             break;
00292
00293     //
00294         //  how big a buffer do we need to convert this one channel?
00295     //  in any case, acm overestimates the size of the buffer needed
00296     //  if the acm size is used when copying we will exceed the boundaries of our allocated m_pbData
00297     //
00298         mmRes =
00299             acmStreamSize
00300             (
00301                 has,
00302                 pdlgSrc->m_cbData,
00303                 &cbConversion,
00304                 ACM_STREAMSIZEF_SOURCE
00305             );
00306
00307         if(!TrapMMError(mmRes, "acmStreamSize"))
00308             break;
00309
00310         // alloc
00311         pvConversion = LocalAlloc(LPTR, cbConversion);
00312         if(!(fRes = (pvConversion != NULL)))
00313         {
00314             MessageBox("Not enough memory for ACM operation", "MultiChan : Error!", MB_ICONEXCLAMATION | MB_OK);
00315             break;
00316         }
00317
00318         // be prepared!
00319     ZeroMemory(&ash, sizeof(ACMSTREAMHEADER));
00320     ash.cbStruct  = sizeof(ACMSTREAMHEADER);
00321     ash.pbSrc   = (PBYTE)pdlgSrc->m_pvData;
00322     ash.cbSrcLength = pdlgSrc->m_cbData;
00323     ash.pbDst   = (PBYTE)pvConversion;
00324     ash.cbDstLength = cbConversion;
00325
00326         mmRes = acmStreamPrepareHeader(has, &ash, 0);
00327         if(!TrapMMError(mmRes, "acmStreamPrepareHeader"))
00328             break;
00329
00330         // do it
00331         mmRes = acmStreamConvert(has, &ash, 0);
00332         if(!TrapMMError(mmRes, "acmStreamConvert"))
00333             break;
00334
00335         // clean up
00336         mmRes = acmStreamUnprepareHeader(has, &ash, 0) |
00337                 acmStreamClose(has, 0);
00338         if(!TrapMMError(mmRes, "acmStreamUnprepareHeader"))
00339             break;
00340
00341         //
00342         // now copy the data from conversion buffer to final output buffer
00343         //
00344         cSamplesOut = ( cbConversion > m_cbData ) ?
00345             ( m_cbData / wfxConversion.nBlockAlign ) :
00346             ( cbConversion / wfxConversion.nBlockAlign );
00347
00348         switch(wfxConversion.nBlockAlign)
00349         {
00350             case 1:     // 8-bit
00351             {
00352                 // stagger dest
00353                 PBYTE   pbDst = m_pbData + pdlgSrc->m_nChannel;
00354                 PBYTE   pbSrc = (PBYTE)pvConversion;
00355
00356                 for(nSample = 0; nSample < cSamplesOut; nSample++)
00357                 {
00358                     *pbDst = *pbSrc++;
00359                     pbDst += m_wfExt.Format.nChannels;
00360                 }
00361
00362                 break;
00363             }
00364
00365             case 2:     // 16-bit
00366             {
00367                 // stagger dest
00368                 PUSHORT pusDst = ((PUSHORT)m_pbData) + pdlgSrc->m_nChannel;
00369                 PUSHORT pusSrc = (PUSHORT)pvConversion;
00370
00371                 for(nSample = 0; nSample < cSamplesOut; nSample++)
00372                 {
00373                     *pusDst = *pusSrc++;
00374                     pusDst += m_wfExt.Format.nChannels;
00375                 }
00376
00377                 break;
00378             }
00379
00380             case 3:     // 24-bit
00381             {
00382                 typedef struct {
00383                     BYTE b[3];
00384                 } S24BITS, *PS24BITS;
00385
00386                 // stagger dest
00387                 PS24BITS psDst = ((PS24BITS)m_pbData) + pdlgSrc->m_nChannel;
00388                 PS24BITS psSrc = (PS24BITS)pvConversion;
00389
00390                 for(nSample = 0; nSample < cSamplesOut; nSample++)
00391                 {
00392                     *psDst = *psSrc++;
00393                     psDst += m_wfExt.Format.nChannels;
00394                 }
00395
00396                 break;
00397             }
00398
00399             default:
00400                 ASSERT(0);
00401         }
00402
00403         // clean up
00404         SafeLocalFree( pvConversion );
00405   }
00406
00407     if(fRes)
00408     {
00409         // make playable
00410         m_fPlayable = TRUE;
00411         m_butPlay.EnableWindow(m_fPlayable);
00412     }
00413 }
00414
00415 // ----------------------------------------------------------------------------------
00416 // OnPlay
00417 // ----------------------------------------------------------------------------------
00418 void
00419 CDlgDest::OnPlay
00420 ()
00421 {
00422   MMRESULT  mmRes       = MMSYSERR_NOERROR;
00423
00424     //
00425     //  must not be in use
00426     //
00427     ASSERT( 0 == g_hwo );
00428
00429     if( 0 == m_lpwhdr )
00430     {
00431         m_lpwhdr = ( LPWAVEHDR )LocalAlloc( LPTR, sizeof( WAVEHDR ) );
00432         if( 0 == m_lpwhdr )
00433         {
00434             MessageBox( "Insufficient memory for rendering !", "MultiChan : Error", MB_ICONEXCLAMATION | MB_OK );
00435             return;
00436         }
00437     }
00438
00439   m_lpwhdr->dwBufferLength = m_cbData;
00440     m_lpwhdr->lpData = ( char * )m_pbData;
00441
00442     //
00443     //  open wave device
00444     //
00445     mmRes = waveOutOpen(    &g_hwo,             //  handle of the output device
00446                             WAVE_MAPPER,          //  as appropriate
00447                             ( WAVEFORMATEX* )&m_wfExt,    //  describe what's next
00448                             ( DWORD_PTR )WavePlayFileCB,  //  the callback
00449                             ( DWORD_PTR )this,        //  object issuing the request
00450                             CALLBACK_FUNCTION       //  callback via function
00451                        );
00452   if(TrapMMError(mmRes, "waveOutOpen"))
00453   {
00454         //
00455         //  prepare the header
00456         //
00457     mmRes = waveOutPrepareHeader(g_hwo, m_lpwhdr, sizeof(WAVEHDR));
00458     if(TrapMMError(mmRes, "waveOutPrepareHeader"))
00459     {
00460             //
00461             //  revert playable state
00462             //
00463             WaveTogglePlayback( WAVE_TOGGLE_DESTINATION, WAVE_TOGGLE_DISABLE );
00464
00465             //
00466             //  start singing
00467             //
00468       mmRes = waveOutWrite(g_hwo, m_lpwhdr, sizeof(WAVEHDR));
00469       TrapMMError(mmRes, "waveOutWrite");
00470
00471         }       //  prepare header
00472     }           //  open
00473 }               //  OnPlay
00474
00475 // ----------------------------------------------------------------------------------
00476 // OnStop
00477 // ----------------------------------------------------------------------------------
00478 void
00479 CDlgDest::OnStop
00480 ()
00481 {
00482     MMRESULT    mmRes       = MMSYSERR_NOERROR;
00483
00484     //
00485     //  ensure validity
00486     //
00487     ASSERT( g_hwo );
00488     ASSERT( !m_fPlayable );
00489
00490     //
00491     //  stop playback
00492     //
00493     mmRes = waveOutReset( g_hwo );
00494     TrapMMError( mmRes, "waveOutReset" );
00495
00496 }   //  OnStop
00497
00498 //
00499 //  RecalcDependant
00500 //
00501 void
00502 CDlgDest::RecalcDependantVariables
00503 ()
00504 {
00505     m_wfExt.Format.nBlockAlign    = m_wfExt.Format.wBitsPerSample * m_wfExt.Format.nChannels / 8;
00506     m_wfExt.Format.nAvgBytesPerSec  = m_wfExt.Format.nBlockAlign * m_wfExt.Format.nSamplesPerSec;
00507
00508   // update UI
00509     char sz[100];
00510     _snprintf(sz, 100, "%d", m_wfExt.Format.nAvgBytesPerSec);
00511     SetDlgItemText(IDC_AVEBITS, sz);
00512 }
00513
00514
00515 /*
00516  *  CDlgDest
00517  *  UI operations
00518  */
00519
00520
00521 // ----------------------------------------------------------------------------------
00522 // track combobox changes
00523 // ----------------------------------------------------------------------------------
00524 void
00525 CDlgDest::OnComboSamplerate
00526 ()
00527 {
00528     m_wfExt.Format.nSamplesPerSec = ( DWORD )m_comboSampleRate.GetItemData(m_comboSampleRate.GetCurSel());
00529     RecalcDependantVariables();
00530 }
00531
00532 void
00533 CDlgDest::OnComboBitdepth
00534 ()
00535 {
00536     m_wfExt.Format.wBitsPerSample = (USHORT)m_comboBitDepth.GetItemData(m_comboBitDepth.GetCurSel());
00537     m_wfExt.Samples.wValidBitsPerSample = min(m_wfExt.Samples.wValidBitsPerSample, m_wfExt.Format.wBitsPerSample);
00538     m_wValidBitsPerSample = m_wfExt.Samples.wValidBitsPerSample;
00539     RecalcDependantVariables();
00540     UpdateData(FALSE);      // update m_wValidBitsPerSample display
00541 }
00542
00543 void
00544 CDlgDest::OnComboWaveformat
00545 ()
00546 {
00547     m_wfExt.Format.wFormatTag = (WORD)m_comboFormat.GetItemData(m_comboFormat.GetCurSel());
00548     switch(m_wfExt.Format.wFormatTag)
00549     {
00550         case WAVE_FORMAT_PCM:
00551             m_wfExt.Format.cbSize = 0;
00552             break;
00553
00554         case WAVE_FORMAT_IEEE_FLOAT:
00555             m_wfExt.Format.cbSize = 0;
00556             break;
00557
00558         case WAVE_FORMAT_EXTENSIBLE:
00559             m_wfExt.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
00560             break;
00561
00562         default:
00563             MessageBox("Format type not supported", "MultiChan : Warning", MB_ICONWARNING | MB_OK);
00564             break;
00565     }
00566 }
00567
00568 // ----------------------------------------------------------------------------------
00569 // Update
00570 // ----------------------------------------------------------------------------------
00571 void
00572 CDlgDest::Update
00573 ()
00574 {
00575     // update dwChannelMask
00576     CDlgSrc*    pdlgSrc   = 0;
00577     BOOL        fGotSources = (0 != g_listSources.GetCount() );
00578
00579     m_cRemix.EnableWindow( fGotSources );
00580     m_cValidBits.EnableWindow( fGotSources );
00581     m_cChannels.EnableWindow( fGotSources );
00582     m_cOutput.EnableWindow( fGotSources );
00583     m_comboBitDepth.EnableWindow( fGotSources );
00584     m_comboSampleRate.EnableWindow( fGotSources );
00585     m_cAveBitsPerSec.EnableWindow( fGotSources );
00586     m_cChannelMask.EnableWindow( fGotSources );
00587     m_comboFormat.EnableWindow( fGotSources );
00588     m_butPlay.EnableWindow( fGotSources  && m_pbData );
00589     m_butStop.EnableWindow( !fGotSources  );
00590
00591     //
00592     //  setting channel mask - if SPEAKER_NOT_SPECIFIED, don't mind
00593     //
00594     m_wfExt.dwChannelMask = 0;
00595
00596   for
00597   (
00598     POSITION    pos   = g_listSources.GetHeadPosition();
00599     pos;
00600   )
00601   {
00602         //
00603     //  iterative step
00604     //
00605     pdlgSrc = g_listSources.GetNext(pos);
00606
00607         if( !(SPEAKER_NOT_SPECIFIED & pdlgSrc->m_dwChannelMask) )
00608             m_wfExt.dwChannelMask |= pdlgSrc->m_dwChannelMask;
00609   } //  for
00610
00611     m_wfExt.dwChannelMask &= 0x7fffffff;        //  correct any deviations
00612
00613   //
00614   // set up a proper WAVEFORMATEXTENSIBLE (number of channels = the number of SRC dialogs that were created)
00615   //
00616   m_wfExt.Format.nChannels = (WORD)g_listSources.GetCount();
00617   if(m_wfExt.Format.nChannels > 2)
00618   {
00619     m_wfExt.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
00620     m_wfExt.Format.cbSize   = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
00621     m_comboFormat.SelectString(0, "WAVE_FORMAT_EXTENSIBLE");
00622   }
00623
00624   RecalcDependantVariables();
00625   m_wValidBitsPerSample = m_wfExt.Samples.wValidBitsPerSample;
00626
00627   // update UI
00628   char sz[100];
00629   _snprintf(sz, 100, "%d", m_wfExt.Format.nChannels);
00630   SetDlgItemText(IDC_CHANNELS, sz);
00631
00632   m_strChannelMask.Format("0x%08x", m_wfExt.dwChannelMask);
00633   UpdateData(FALSE);
00634
00635 }
00636
00637 void
00638 CDlgDest::OnEditValidbits
00639 ()
00640 {
00641     UpdateData(TRUE);
00642     m_wfExt.Samples.wValidBitsPerSample = LOWORD(m_wValidBitsPerSample);
00643 }
00644
00645 // ----------------------------------------------------------------------------------
00646 // dummy implementations to prevent dlgs from disappearing when user hits enter or esc
00647 // ----------------------------------------------------------------------------------
00648 void CDlgDest::OnOK()
00649 {
00650     // do nothing
00651 }
00652
00653 void CDlgDest::OnCancel()
00654 {
00655     // do nothing
00656 }
00657
00658 HBRUSH
00659 CDlgDest::OnCtlColor
00660 (
00661   CDC*  pDC,
00662   CWnd* pWnd,
00663   UINT  nCtlColor
00664 )
00665 {
00666   HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
00667
00668     if((nCtlColor == CTLCOLOR_STATIC))
00669     {
00670         if(pWnd->m_hWnd == m_cOutput.m_hWnd)
00671         {
00672             pDC->SetBkColor(GetSysColor(COLOR_ACTIVECAPTION));
00673             pDC->SetTextColor(GetSysColor(COLOR_CAPTIONTEXT));
00674             return GetSysColorBrush(COLOR_ACTIVECAPTION);
00675         }
00676     }
00677
00678   return hbr;
00679 }
00680
00681 void
00682 CDlgDest::OnLButtonDown
00683 (
00684   UINT  nFlags,
00685   CPoint  point
00686 )
00687 {
00688   RECT    rcClient;
00689
00690     m_cOutput.GetClientRect(&rcClient);
00691     m_cOutput.MapWindowPoints(this, &rcClient);
00692     m_fDragging = PtInRect(&rcClient, point);
00693
00694     if(m_fDragging)
00695     {
00696         SetCapture();
00697         m_fDragging = TRUE;
00698         m_ptPosInCaption = point;
00699     }
00700
00701     CDialog::OnLButtonDown(nFlags, point);
00702
00703     SetFocus();
00704     SetWindowPos(&wndTop, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
00705 }
00706
00707 void
00708 CDlgDest::OnLButtonUp
00709 (
00710   UINT  nFlags,
00711   CPoint  point
00712 )
00713 {
00714   m_fDragging = FALSE;
00715     ReleaseCapture();
00716
00717   CDialog::OnLButtonUp(nFlags, point);
00718 }
00719
00720 void
00721 CDlgDest::OnMouseMove
00722 (
00723   UINT  nFlags,
00724   CPoint  point
00725 )
00726 {
00727   RECT    rcClientParent;
00728
00729     GetParent()->GetClientRect(&rcClientParent);
00730     GetParent()->MapWindowPoints(this, &rcClientParent);
00731     if(PtInRect(&rcClientParent, point))
00732     {
00733         if(m_fDragging)
00734         {
00735             CRect   rcWindow;
00736             CRect   rcParent;
00737             CPoint  pt(point.x - m_ptPosInCaption.x, point.y - m_ptPosInCaption.y);
00738
00739             GetWindowRect(&rcWindow);
00740             GetParent()->GetWindowRect(&rcParent);
00741
00742             rcWindow.OffsetRect(pt);
00743             rcWindow -= rcParent.TopLeft();
00744
00745             SetWindowPos(NULL, rcWindow.left, rcWindow.top, 0,0, SWP_NOZORDER | SWP_NOSIZE);
00746         }
00747     }
00748     else
00749     {
00750         ReleaseCapture();
00751         m_fDragging = FALSE;
00752     }
00753 }
00754
00755 /*
00756  *  CDlgDest
00757  *  message processing
00758  */
00759
00760
00761 LRESULT
00762 CDlgDest::WindowProc
00763 (
00764     UINT    nMessage,
00765     WPARAM  wParam,
00766     LPARAM  lParam
00767 )
00768 {
00769     MMRESULT    mmRes = MMSYSERR_NOERROR;
00770
00771     switch( nMessage )
00772     {
00773         case    WM_START_PLAYBACK:
00774             {
00775                 break;
00776             }
00777         case    WM_STOP_PLAYBACK:
00778             {
00779                 //
00780                 //  revert playable state
00781                 //
00782                 WaveTogglePlayback( WAVE_TOGGLE_DESTINATION, WAVE_TOGGLE_ALLOW );
00783
00784                 //
00785                 //  unprepare and release
00786                 //
00787                 mmRes = waveOutUnprepareHeader( g_hwo, m_lpwhdr, sizeof( WAVEHDR ) );
00788                 if( TrapMMError( mmRes, "waveOutUnprepareHeader" ) )
00789                 {
00790                     mmRes = waveOutClose( g_hwo );
00791                     TrapMMError( mmRes, "waveOutClose" );
00792
00793                     g_hwo = 0;
00794                 }
00795
00796                 break;
00797             }
00798     }
00799     return( CWnd::WindowProc( nMessage, wParam, lParam ) );
00800 }
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleApt/OleApt.Cpp Source File

  • Com
  • Fundamentals
  • OleApt

OleApt.Cpp

Go to the documentation of this file.
00001 // ===========================================================================
00002 // File: O L E A P T . C P P
00003 //
00004 //  Demonstrates OLE Apartment model threading. "Apartment" is essentially
00005 // just a way of describing a thread with a message queue that supports OLE/COM
00006 // objects. Objects within an apartment are reentrant in only the traditional
00007 // Windows sense, identically to single-threaded OLE. That is to say that
00008 // operations which yield to the message queue can cause further messages to
00009 // be sent to any objects within the apartment. Apartment model threading simply
00010 // allows there to be more than one "apartment" where previously there was
00011 // only one: the main application thread.
00012 //
00013 //  This program is both a client and an server. It launches as a client
00014 // by default, registering its executable as a server and creating another
00015 // instance of itself to be the server.
00016 //
00017 //  The client does nothing interesting and is always shown as a minimized
00018 // window. It simply creates an instance of its worker COM object in the
00019 // server. When it shuts down, it releases its reference to the object,
00020 // which is reflected in the server's UI.
00021 //
00022 //  The server registers a class-factory on the main application thread and
00023 // also spawns several worker threads. When requests arrive from clients to
00024 // create instances of the class, the server class-factory picks a worker
00025 // thread for the object (simply allocating them round-robin to the workers)
00026 // and then goes through the process of having the object created within the
00027 // thread and properly marshalled from the worker thread back to the class-
00028 // factory where it can be returned to the caller. Note that this marshalling
00029 // to the main thread is fairly transient, it lasts for creation only:
00030 // subsequent calls from the client to the object go straight from the client's
00031 // process into the worker apartment.
00032 //
00033 //  The only mechanisms used here above-and-beyond NT 3.5 are:
00034 //   * Ability to call CoInitialize() in multiple threads
00035 //   * The use of the new marshalling flag, MSHCTX_INPROC, to marshall
00036 //     pointers between threads
00037 //
00038 //  This sample may be compiled as UNICODE for the NT 3.51 beta, or as Ansi
00039 // (listed here) to run on both the NT 3.51 beta and the Windows 95 M8 Beta.
00040 //
00041 // Copyright 1995 - 2000 Microsoft Corporation.  All Rights Reserved.
00042 // ===========================================================================
00043
00044 // %%Includes: ---------------------------------------------------------------
00045 #define INC_OLE2
00046 #define STRICT
00047 #include <windows.h>
00048 #include <initguid.h>
00049 #include <stdio.h>
00050
00051 // %%Constants: --------------------------------------------------------------
00052 #define cServerThreads  5
00053 #define szWindowClass   TEXT("OLEAPT_CLASS")
00054 #define szTitleServer   TEXT("SERVER: OLE Apartment Sample")
00055 #define szTitleClient   TEXT("CLIENT: OLE Apartment Sample")
00056 #define szCloseQuery    TEXT("Client references still exist. Are you sure you want to close?")
00057 #define COINIT_APARTMENTTHREADED    2
00058 const LARGE_INTEGER     bZero = {0,0};
00059
00060 // %%Guids: ------------------------------------------------------------------
00061 DEFINE_GUID(CLSID_CObject, 0x5c06abc0, 0x2dcd, 0x11ce, 0x84, 0x17, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
00062
00063 // %%Classes: ----------------------------------------------------------------
00064 // the class-factory object exists in the main application apartment/thread
00065 // and is used to create instances of the worker objects on worker threads.
00066 class CClassFactory : public IClassFactory
00067     {
00068   // IClassFactory
00069     STDMETHODIMP            QueryInterface(REFIID iid, void **ppv);
00070     STDMETHODIMP_(ULONG)    AddRef(void)    { return mcRef++; }
00071     STDMETHODIMP_(ULONG)    Release(void)   { if (--mcRef == 0) { delete this; return 0; } return mcRef; }
00072     STDMETHODIMP            CreateInstance(LPUNKNOWN punkOuter, REFIID iid, LPVOID FAR *ppv);
00073     STDMETHODIMP            LockServer(BOOL fLock);
00074
00075   // data members
00076     ULONG   mcRef;
00077
00078   // constructors/destructors
00079   public:
00080     CClassFactory() { mcRef = 1; }
00081     };
00082
00083 // this worker object is simple: it simply supports IUnknown. more interesting
00084 // interfaces can be readily added here and implemented for the worker.
00085 class CObject : public IUnknown
00086     {
00087   // IUnknown
00088     STDMETHODIMP            QueryInterface(REFIID iid, void **ppv);
00089     STDMETHODIMP_(ULONG)    AddRef(void)    { return mcRef++; }
00090     STDMETHODIMP_(ULONG)    Release(void);
00091
00092   // data members
00093     ULONG   mcRef;
00094
00095   // constructors/destructors
00096   public:
00097     CObject() { mcRef = 1; }
00098     };
00099
00100 // %%Globals: ----------------------------------------------------------------
00101 BOOL        vfServer;                       // is this instance a server or client?
00102 HANDLE      vrghThread[cServerThreads];     // worker thread handles
00103 DWORD       vrgtid[cServerThreads];         // worker thread id's
00104 HANDLE      vrghEvent[cServerThreads];      // creation event for each worker
00105 INT         vrgcObjects[cServerThreads];    // # of objects created on each thread
00106 HANDLE      vhEventServer;                  // creation-complete event for class-factory
00107 CClassFactory   vclassfactory;
00108 UINT        viNextThread;                   // next worker to create an object on
00109 LPUNKNOWN   vpunkService;                   // client's x-process reference to its
00110                                             //  worker object in the server
00111 HWND        vhwndMain;
00112 LPSTREAM    vpstmMarshalling;               // scratch stream used for cross-apt marshalling
00113 HRESULT     vhrThreadStatus;                // signals status to class-factory
00114
00115 // %%Prototypes: -------------------------------------------------------------
00116 LRESULT CALLBACK    MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
00117 LRESULT             ServerThreadProc(LPARAM lParam);
00118 BOOL                FAutoRegister(HINSTANCE hinst);
00119
00120 // ---------------------------------------------------------------------------
00121 // %%Function: MainWndProc
00122 //  Window procedure for both client and server versions of the sample. Clients
00123 // display nothing, server displays statistics about
00124 // ---------------------------------------------------------------------------
00125  LRESULT CALLBACK
00126 MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00127 {
00128     LRESULT lresult = TRUE;
00129
00130     switch (message)
00131         {
00132         case WM_QUERYOPEN:
00133             // clients must stay minimized
00134             return vfServer;
00135
00136         case WM_PAINT:
00137             {
00138             HDC hdc;
00139             PAINTSTRUCT ps;
00140             int i;
00141
00142             if ((hdc = BeginPaint(hwnd, &ps)) != NULL)
00143                 {
00144                 if (vfServer)
00145                     {
00146                     for (i=0; i<cServerThreads; i++)
00147                         {
00148                         TCHAR    rgch[200];
00149
00150                         wsprintf(rgch, TEXT("Thread #%d: %d objects"), i, vrgcObjects[i]);
00151                         TextOut(hdc, 20, 10+(i*25), rgch, lstrlen(rgch));
00152                         }
00153                     }
00154                 }
00155             EndPaint(hwnd, &ps);
00156             }
00157             break;
00158
00159
00160         case WM_DESTROY:
00161             PostQuitMessage(0);
00162             break;
00163
00164         case WM_CLOSE:
00165             // check for clients and prompt in the UI.
00166             if (vfServer)
00167                 {
00168                 for (int i=0; i<cServerThreads; i++)
00169                     {
00170                     if (vrgcObjects[i] > 0)
00171                         {
00172                         if (MessageBox(hwnd, szCloseQuery,
00173                                 szTitleServer, MB_YESNO) == IDNO)
00174                             return FALSE;
00175                         else
00176                             break;
00177                         }
00178                     }
00179                 }
00180
00181         default:
00182             return DefWindowProc(hwnd, message, wParam, lParam);
00183         }
00184
00185     return lresult;
00186 }  // MainWndProc
00187
00188 // ---------------------------------------------------------------------------
00189 // %%Function: WinMain
00190 //  Initialization, main message-pump for clients and servers.
00191 // ---------------------------------------------------------------------------
00192  int PASCAL
00193 WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR szCmdLine, int nCmdShow)
00194 {
00195     WNDCLASS wndclass;
00196     HRESULT hr;
00197     int     i;
00198     DWORD   dwRegister = 0;
00199     MSG     msg;
00200
00201     // parse the command-line
00202     if (szCmdLine)
00203         {
00204         LPSTR   sz = strtok(szCmdLine, " \t");
00205
00206         vfServer = (sz && !strcmpi(sz, "-Embedding"));
00207         }
00208
00209     // initialize COM
00210     hr = CoInitialize(NULL);
00211     if (FAILED(hr))
00212         {
00213         MessageBeep(0);
00214         return hr;
00215         }
00216
00217     // register the CObject class in the registry so
00218     // that the client can create instances of the server
00219     if (!FAutoRegister(hinst))
00220         {
00221         hr = GetLastError();
00222         goto LCleanup;
00223         }
00224
00225     if (vfServer)
00226         {
00227         // create the threads and synchronization events
00228         // which the server will need
00229         for (i=0; i<cServerThreads; i++)
00230             {
00231             TCHAR    rgch[32];
00232
00233             // create the thread suspended so its event can be
00234             // created using its thread-id and it will be able to
00235             // use it as soon as it runs
00236             vrghThread[i] = CreateThread(NULL,
00237                 0,
00238                 (LPTHREAD_START_ROUTINE)&ServerThreadProc,
00239                 0,
00240                 CREATE_SUSPENDED,
00241                 &vrgtid[i]);
00242             if (vrghThread[i] == NULL)
00243                 {
00244                 hr = GetLastError();
00245                 goto LCleanup;
00246                 }
00247
00248             // a thread can use its thread-id to OpenEvent this existing
00249             // event at any time. it can also look for its thread-id in
00250             // vrgtid[] to determine its index for use with vrghEvent.
00251             // this event signals to a worker thread to create a new CObject
00252             wsprintf(rgch, TEXT("Thread_%d"), vrgtid[i]);
00253             vrghEvent[i] = CreateEvent(NULL, FALSE, FALSE, rgch);
00254             if (vrghEvent[i] == NULL)
00255                 {
00256                 hr = GetLastError();
00257                 goto LCleanup;
00258                 }
00259
00260             // now that the event is available, let the thread run
00261             ResumeThread(vrghThread[i]);
00262             }
00263
00264         // this signals the status of a worker threads creation after
00265         // receiving its create signal via vrghEvent[i]
00266         vhEventServer = CreateEvent(NULL, FALSE, FALSE, TEXT("Server"));
00267         if (vhEventServer == NULL)
00268             {
00269             hr = GetLastError();
00270             goto LCleanup;
00271             }
00272
00273         // register the class-factory with COM
00274         hr = CoRegisterClassObject(CLSID_CObject,
00275             (IUnknown *)&vclassfactory,
00276             CLSCTX_LOCAL_SERVER,
00277             REGCLS_MULTIPLEUSE,
00278             &dwRegister);
00279         if (FAILED(hr))
00280             goto LCleanup;
00281
00282         // create an IStream to be used for marshalling new objects between
00283         // the worker and the CClassFactory
00284         hr = CreateStreamOnHGlobal(NULL, TRUE, &vpstmMarshalling);
00285         if (FAILED(hr))
00286             goto LCleanup;
00287         }
00288     else
00289         {
00290         // this is the client case: create an instance of the service object
00291         // in the server
00292         hr = CoCreateInstance(CLSID_CObject,
00293             NULL,
00294             CLSCTX_LOCAL_SERVER,
00295             IID_IUnknown,
00296             (void**)&vpunkService);
00297         if (FAILED(hr))
00298             goto LCleanup;
00299         }
00300
00301     // create the client and server UI
00302     memset(&wndclass, 0, sizeof(wndclass));
00303     wndclass.lpszClassName = szWindowClass;
00304     wndclass.style = CS_HREDRAW | CS_VREDRAW;
00305     wndclass.lpfnWndProc = MainWndProc;
00306     wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
00307     wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
00308     wndclass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
00309     wndclass.hInstance = hinst;
00310
00311     if (!RegisterClass(&wndclass) ||
00312         (vhwndMain = CreateWindow(szWindowClass,
00313             vfServer ? szTitleServer : szTitleClient,
00314             WS_OVERLAPPEDWINDOW,
00315             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
00316             HWND_DESKTOP, NULL, hinst, NULL)) == NULL)
00317         {
00318         hr = GetLastError();
00319         goto LCleanup;
00320         }
00321
00322     // display clients as minimized, server as a normal window
00323     ShowWindow(vhwndMain, vfServer ? nCmdShow : SW_SHOWMINNOACTIVE);
00324
00325     while (GetMessage(&msg, NULL, 0, 0))
00326         {
00327         TranslateMessage(&msg);
00328         DispatchMessage(&msg);
00329         }
00330     hr = (int) msg.wParam;
00331
00332 LCleanup:
00333     if (hr != S_OK)
00334         MessageBeep(0);
00335     if (vfServer)
00336         {
00337         // we explicitly don't clean up threads and events
00338         if (dwRegister != 0)
00339             CoRevokeClassObject(dwRegister);
00340         if (vpstmMarshalling != NULL)
00341             vpstmMarshalling->Release();
00342         }
00343     else
00344         {
00345         // this is the client case: make sure to release the service
00346         if (vpunkService != NULL)
00347             vpunkService->Release();
00348         }
00349
00350     CoUninitialize();
00351     return hr;
00352 }  // WinMain
00353
00354 // ---------------------------------------------------------------------------
00355 // %%Function: FAutoRegister
00356 //  Registers the CObject class in the registry.
00357 // ---------------------------------------------------------------------------
00358  BOOL
00359 FAutoRegister(HINSTANCE hinst)
00360 {
00361     static TCHAR szClassDesc[] = TEXT("Ole Apartments Sample");
00362     static TCHAR szCLSIDEntry[] = TEXT("CLSID\\{5c06abc0-2dcd-11ce-8417-00aa00389b71}");
00363     TCHAR       szBuf[512];
00364     TCHAR       szPath[512];
00365     HKEY        hkeyT = NULL;
00366
00367     // install the OLEPerf OLE1/OLE2 compatibility sections
00368     if ((RegSetValue(HKEY_CLASSES_ROOT, szCLSIDEntry, REG_SZ, szClassDesc,
00369             lstrlen(szClassDesc)) != ERROR_SUCCESS) ||
00370         (RegCreateKey(HKEY_CLASSES_ROOT, szCLSIDEntry, &hkeyT)
00371             != ERROR_SUCCESS) ||
00372         !GetModuleFileName(hinst, szBuf, sizeof(szBuf)))
00373         return FALSE;
00374     lstrcpyn(szPath, szBuf, sizeof(szPath)/sizeof(TCHAR));
00375     if (RegSetValue(hkeyT, TEXT("LocalServer32"), REG_SZ, szBuf, lstrlen(szBuf))
00376             != ERROR_SUCCESS)
00377         goto LErrExit;
00378     RegCloseKey(hkeyT);
00379     return TRUE;
00380 LErrExit:
00381     RegCloseKey(hkeyT);
00382     return FALSE;
00383 }  // FAutoRegister
00384
00385 // ===========================================================================
00386 //                          C C L A S S F A C T O R Y
00387 // ===========================================================================
00388
00389 // ---------------------------------------------------------------------------
00390 // %%Function: CClassFactory::QueryInterface
00391 //  Returns a new reference of the specified iid-type to a CClassFactory.
00392 // ---------------------------------------------------------------------------
00393  STDMETHODIMP
00394 CClassFactory::QueryInterface(REFIID iid, void **ppv)
00395 {
00396     *ppv = NULL;
00397
00398     if (iid == IID_IClassFactory || iid == IID_IUnknown)
00399         {
00400         *ppv = (IClassFactory *)this;
00401         }
00402     if (*ppv != NULL)
00403         {
00404         AddRef();
00405         return S_OK;
00406         }
00407     return E_NOINTERFACE;
00408 }  // CClassFactory::QueryInterface
00409
00410 // ---------------------------------------------------------------------------
00411 // %%Function: CClassFactory::CreateInstance
00412 //  Creates a new instance of a CObject on the next worker thread.
00413 // ---------------------------------------------------------------------------
00414  STDMETHODIMP
00415 CClassFactory::CreateInstance(LPUNKNOWN punkOuter, REFIID iid, void **ppv)
00416 {
00417     LPUNKNOWN   punk;
00418     HRESULT     hr;
00419
00420     *ppv = NULL;
00421     if (punkOuter != NULL)
00422         return CLASS_E_NOAGGREGATION;
00423
00424     // trigger the worker thread that we want to create an object
00425     SetEvent(vrghEvent[viNextThread]);
00426
00427     // now wait for the object to signal its completion
00428     WaitForSingleObject(vhEventServer, INFINITE);
00429
00430     // once the worker thread signals completion, vhrThreadStatus
00431     // lets us know if the creation process was successful, and if
00432     // vpstmMarshalling creates a marshalled interface pointer
00433     if (FAILED(vhrThreadStatus))
00434         return vhrThreadStatus;
00435
00436     // unmarshal an IUnknown from the scratch stream. if unmarshaling
00437     // fails, it takes care of releasing the object inside the marshal-data
00438     hr = vpstmMarshalling->Seek(bZero, STREAM_SEEK_SET, NULL);
00439     if (FAILED(hr))
00440         return hr;
00441     hr = CoUnmarshalInterface(vpstmMarshalling, IID_IUnknown, (void **)&punk);
00442     if (FAILED(hr))
00443         return hr;
00444
00445     // get a reference to the interface asked for
00446     hr = punk->QueryInterface(iid, ppv);
00447     punk->Release();
00448
00449     viNextThread++;
00450     viNextThread %= cServerThreads;
00451
00452     return hr;
00453 }  // CClassFactory::CreateInstance
00454
00455  STDMETHODIMP
00456 CClassFactory::LockServer(BOOL fLock)
00457 {
00458     // there's no need to support this for this sample
00459     return E_FAIL;
00460 }  // CClassFactory::LockServer
00461
00462
00463 // ===========================================================================
00464 //                               C O B J E C T
00465 // ===========================================================================
00466
00467 // ---------------------------------------------------------------------------
00468 // %%Function: ServerThreadProc
00469 //  The worker thread function. Handles messages for objects of its thread/apt
00470 // and creates new objects.
00471 // ---------------------------------------------------------------------------
00472  LRESULT
00473 ServerThreadProc(LPARAM lParam)
00474 {
00475     HRESULT hr;
00476     MSG     msg;
00477     int     iThread;
00478
00479     // figure out which thread this is: it needs its synchronization event
00480     for (iThread=0; iThread<cServerThreads; iThread++)
00481         {
00482         if (vrgtid[iThread] == GetCurrentThreadId())
00483             break;
00484         }
00485     if (iThread==cServerThreads)
00486         return E_UNEXPECTED;
00487
00488     // initialize COM
00489     hr = CoInitialize(NULL);
00490     if (FAILED(hr))
00491         {
00492         MessageBeep(0);
00493         return hr;
00494         }
00495
00496     // apartment message/event loop
00497     // (see SDK documentation for MsgWaitForMultipleObjects)
00498     // here worker message loops last forever. in situations without a
00499     // static number of worker threads, the loop could easily be terminated by
00500     // WM_QUITs sent from the main thread which might manage the worker thread
00501     // pool more carefully.
00502     while (TRUE)
00503         {
00504         DWORD dwWaitResult;
00505
00506         // wait for any message sent or posted to this queue
00507         // or for one of the passed handles to become signaled
00508         dwWaitResult = MsgWaitForMultipleObjects(1, &vrghEvent[iThread],
00509             FALSE, INFINITE, QS_ALLINPUT);
00510
00511         // result tells us the type of event we have:
00512         // a message or a signaled handle
00513
00514         // if there are one or more messages in the queue ...
00515         if (dwWaitResult == (WAIT_OBJECT_0 + 1))
00516             {
00517             // dispatch all of the messages in this next loop
00518             // (here is where we'd check for WM_QUITs to end this
00519             // worker thread if we wanted to)
00520             while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
00521                 DispatchMessage(&msg);
00522             }
00523         else
00524             {
00525             // this thread was signaled to create a new object
00526             try
00527                 {
00528                 LPUNKNOWN   punk;
00529
00530                 // create a new CObject
00531                 punk = (IUnknown *)new CObject;
00532                 if (punk == NULL)
00533                     throw E_OUTOFMEMORY;
00534
00535                 hr = vpstmMarshalling->Seek(bZero, STREAM_SEEK_SET, NULL);
00536                 if (FAILED(hr))
00537                     throw hr;
00538                 hr = CoMarshalInterface(vpstmMarshalling,
00539                     IID_IUnknown,
00540                     punk,
00541                     MSHCTX_INPROC,
00542                     NULL,
00543                     MSHLFLAGS_NORMAL);
00544                 if (FAILED(hr))
00545                     throw hr;
00546
00547                 // punk is now referenced by its marshal-data in vpstmMarshalling.
00548                 // we release our local reference here so the unmarshaller will
00549                 // have the sole reference. a common mistake is to forget this
00550                 // release and end up with orphaned objects in the server.
00551                 punk->Release();
00552
00553                 // modify the global state -- the # of objects/thread -- which is
00554                 // displayed in the server UI
00555                 vrgcObjects[iThread]++;
00556                 InvalidateRect(vhwndMain, NULL, TRUE);
00557
00558                 vhrThreadStatus = S_OK;
00559                 }
00560             catch (HRESULT hr)
00561                 {
00562                 vhrThreadStatus = hr;
00563                 }
00564             SetEvent(vhEventServer);
00565             }
00566
00567         }
00568
00569     CoUninitialize();
00570     return msg.wParam;
00571 }  // ServerThreadProc
00572
00573 // ---------------------------------------------------------------------------
00574 // %%Function: CObject::QueryInterface
00575 //  Returns a new reference of the specified iid-type to a CObject.
00576 // ---------------------------------------------------------------------------
00577  STDMETHODIMP
00578 CObject::QueryInterface(REFIID iid, void **ppv)
00579 {
00580     *ppv = NULL;
00581
00582     if (iid == IID_IUnknown)
00583         {
00584         *ppv = (IUnknown *)this;
00585         }
00586     if (*ppv != NULL)
00587         {
00588         AddRef();
00589         return S_OK;
00590         }
00591     return E_NOINTERFACE;
00592 }  // CObject::QueryInterface
00593
00594 // ---------------------------------------------------------------------------
00595 // %%Function: CObject::Release
00596 //  Handles releases of references to a CObject. Purpose here is to have code
00597 // which alters the global state which is displayed in the servers UI.
00598 // ---------------------------------------------------------------------------
00599  STDMETHODIMP_(ULONG)
00600 CObject::Release(void)
00601 {
00602     if (--mcRef == 0)
00603         {
00604         // change the global server state -- the # of objects/thread --
00605         // reflected in the server UI
00606         for (int i=0; i<cServerThreads; i++)
00607             {
00608             if (vrgtid[i] == GetCurrentThreadId())
00609                 {
00610                 vrgcObjects[i]--;
00611                 InvalidateRect(vhwndMain, NULL, TRUE);
00612                 break;
00613                 }
00614             }
00615
00616         delete this;
00617         return 0;
00618         }
00619     return mcRef;
00620 }  // CObject::Release
00621
00622 // EOF =======================================================================
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::COMAdminCatalog Member List

This is the complete list of members for comadmin::COMAdminCatalog, including all inherited members.
BackupREGDB(String bstrBackupFilePath) | comadmin::COMAdminCatalog |
clsid | comadmin::COMAdminCatalog | [static]
Connect(String bstrConnectString) | comadmin::COMAdminCatalog |
ExportApplication(String bstrApplIdOrName, String bstrApplicationFile, int lOptions) | comadmin::COMAdminCatalog |
GetCollection(String bstrCollName) | comadmin::COMAdminCatalog |
GetCollectionByQuery(String bstrCollName, com.ms.com.SafeArray aQuery) | comadmin::COMAdminCatalog |
GetEventClassesForIID(String bstrIID, com.ms.com.SafeArray varCLSIDS, com.ms.com.SafeArray varProgIDs, com.ms.com.SafeArray varDescriptions) | comadmin::COMAdminCatalog |
getMajorVersion() | comadmin::COMAdminCatalog |
getMinorVersion() | comadmin::COMAdminCatalog |
GetMultipleComponentsInfo(String bstrApplIdOrName, com.ms.com.SafeArray varFileNames, com.ms.com.SafeArray varCLSIDS, com.ms.com.SafeArray varClassNames, com.ms.com.SafeArray varFileFlags, com.ms.com.SafeArray varComponentFlags) | comadmin::COMAdminCatalog |
iid | comadmin::COMAdminCatalog | [static]
ImportComponent(String bstrApplIdOrName, String bstrCLSIDOrProgId) | comadmin::COMAdminCatalog |
InstallApplication(String bstrApplicationFile, String bstrDestinationDirectory, int lOptions, String bstrUserId, String bstrPassword, String bstrRSN) | comadmin::COMAdminCatalog |
InstallComponent(String bstrApplIdOrName, String bstrDLL, String bstrTLB, String bstrPSDLL) | comadmin::COMAdminCatalog |
InstallEventClass(String bstrApplIdOrName, String bstrDLL, String bstrTLB, String bstrPSDLL) | comadmin::COMAdminCatalog |
InstallMultipleComponents(String bstrApplIdOrName, com.ms.com.SafeArray varFileNames, com.ms.com.SafeArray varCLSIDS) | comadmin::COMAdminCatalog |
InstallMultipleEventClasses(String bstrApplIdOrName, com.ms.com.SafeArray varFileNames, com.ms.com.SafeArray varCLSIDS) | comadmin::COMAdminCatalog |
QueryApplicationFile(String bstrApplicationFile, String[] bstrApplicationName, String[] bstrApplicationDescription, boolean[] bHasUsers, boolean[] bIsProxy, com.ms.com.SafeArray varFileNames) | comadmin::COMAdminCatalog |
RefreshComponents() | comadmin::COMAdminCatalog |
RefreshRouter() | comadmin::COMAdminCatalog |
Reserved1() | comadmin::COMAdminCatalog |
Reserved2() | comadmin::COMAdminCatalog |
RestoreREGDB(String bstrBackupFilePath) | comadmin::COMAdminCatalog |
ServiceCheck(int lService) | comadmin::COMAdminCatalog |
ShutdownApplication(String bstrApplIdOrName) | comadmin::COMAdminCatalog |
StartApplication(String bstrApplIdOrName) | comadmin::COMAdminCatalog |
StartRouter() | comadmin::COMAdminCatalog |
StopRouter() | comadmin::COMAdminCatalog |
Generated on Wed Nov 13 2024 16:58:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/AcAudio.h Source File

  • Web
  • MSAgent
  • c
  • CapMFC

AcAudio.h

Go to the documentation of this file.
00001 #ifndef _ACAudio_h_
00002 #define _ACAudio_h_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007
00008
00009 // Machine generated IDispatch wrapper class(es) created with ClassWizard
00010 /////////////////////////////////////////////////////////////////////////////
00011 // CAgentCtlAudioObject wrapper class
00012
00013 class CAgentCtlAudioObject : public COleDispatchDriver
00014 {
00015 public:
00016   CAgentCtlAudioObject() {}   // Calls COleDispatchDriver default constructor
00017   CAgentCtlAudioObject(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
00018   CAgentCtlAudioObject(const CAgentCtlAudioObject& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
00019
00020 // Attributes
00021 public:
00022
00023 // Operations
00024 public:
00025   BOOL GetEnabled();
00026   BOOL GetSoundEffects();
00027 };
00028
00029
00030 #endif
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::CursorOptionEnum Member List

This is the complete list of members for msado15::CursorOptionEnum, including all inherited members.
adAddNew | msado15::CursorOptionEnum | [static]
adApproxPosition | msado15::CursorOptionEnum | [static]
adBookmark | msado15::CursorOptionEnum | [static]
adDelete | msado15::CursorOptionEnum | [static]
adFind | msado15::CursorOptionEnum | [static]
adHoldRecords | msado15::CursorOptionEnum | [static]
adIndex | msado15::CursorOptionEnum | [static]
adMovePrevious | msado15::CursorOptionEnum | [static]
adNotify | msado15::CursorOptionEnum | [static]
adResync | msado15::CursorOptionEnum | [static]
adSeek | msado15::CursorOptionEnum | [static]
adUpdate | msado15::CursorOptionEnum | [static]
adUpdateBatch | msado15::CursorOptionEnum | [static]
Generated on Wed Nov 13 2024 16:58:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/MyMemberSetChangeListener/StdAfx.h Source File

  • WinBase
  • Cluster
  • Win2003
  • MyMemberSetChangeListener

StdAfx.h

Go to the documentation of this file.
00001 //
00002 // stdafx.h : include file for standard system include files,
00003 //      or project specific include files that are used frequently,
00004 //      but are changed infrequently
00005 //
00006
00007 #pragma once
00008
00009 #define STRICT
00010 #ifndef _WIN32_WINNT
00011 #define _WIN32_WINNT 0x0502
00012 #endif
00013 #define _ATL_APARTMENT_THREADED
00014
00015 #include <atlbase.h>
00016 //You may derive a class from CComModule and use it if you want to override
00017 //something, but do not change the name of _Module
00018 extern CComModule _Module;
00019 #include <atlcom.h>
00020
00021 // Interface definitions for IClusCfgMemberSetChangeListener
00022 #include <ClusCfgServer.h>
00023
00024 // Categories and ClusCfg GUIDS
00025 #include <ClusCfgGuids.h>
00026
00027 // Safe string functions
00028 #include <strsafe.h>
00029
00030 //{{AFX_INSERT_LOCATION}}
00031 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00032
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/WinNT/PlgBlt/BitMap.h Source File

  • Multimedia
  • Gdi
  • WinNT
  • PlgBlt

BitMap.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1992 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 /* bitmap.h  */
00013
00014 /* function prototypes */
00015 VOID DrawBitmap (HDC, HBITMAP);
00016 HBITMAP GetBitmap (HDC, HANDLE, BOOL);
Generated on Wed Nov 13 2024 16:52:14 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/capicom/cpp/isapiCertPolicy/isapiCertPolicy.h Source File

  • Security
  • capicom
  • cpp
  • isapiCertPolicy

isapiCertPolicy.h

Go to the documentation of this file.
00001 #if !defined(AFX_ISAPICERTPOLICY_H__1E90AFFB_FEEA_4CE0_A3CA_5DDB665CA990__INCLUDED_)
00002 #define AFX_ISAPICERTPOLICY_H__1E90AFFB_FEEA_4CE0_A3CA_5DDB665CA990__INCLUDED_
00003
00004 // ISAPICERTPOLICY.H - Header file for your Internet Server
00005 //    isapiCertPolicy Filter
00006
00007 #include "resource.h"
00008
00009
00010 class CIsapiCertPolicyFilter : public CHttpFilter
00011 {
00012 public:
00013     CIsapiCertPolicyFilter();
00014     ~CIsapiCertPolicyFilter();
00015
00016 // Overrides
00017     // ClassWizard generated virtual function overrides
00018         // NOTE - the ClassWizard will add and remove member functions here.
00019         //    DO NOT EDIT what you see in these blocks of generated code !
00020     //{{AFX_VIRTUAL(CIsapiCertPolicyFilter)
00021 public:
00022     virtual BOOL GetFilterVersion(PHTTP_FILTER_VERSION pVer);
00023     virtual DWORD OnAuthentication(CHttpFilterContext* pCtxt, PHTTP_FILTER_AUTHENT pAuthent);
00024
00025 private:
00026     static BOOL MatchIssuerThumbprint(
00027         CAPICOM::ICertificate2Ptr Cert);
00028
00029     static BOOL MatchExtendedKeyUsage(
00030         CAPICOM::IEKUPtr EKU, BOOL *pfMatchOid);
00031
00032     static BOOL MatchExtendedKeyUsage(CAPICOM::ICertificate2Ptr Cert);
00033     static BOOL CheckCertPolicy(const _bstr_t &bstrCert);
00034
00035     //}}AFX_VIRTUAL
00036
00037     //{{AFX_MSG(CIsapiCertPolicyFilter)
00038     //}}AFX_MSG
00039 };
00040
00041 //{{AFX_INSERT_LOCATION}}
00042 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00043
00044 #endif // !defined(AFX_ISAPICERTPOLICY_H__1E90AFFB_FEEA_4CE0_A3CA_5DDB665CA990__INCLUDED)
Generated on Wed Nov 13 2024 16:52:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagENTRY Member List

This is the complete list of members for tagENTRY, including all inherited members.
dwVal | tagENTRY
szName | tagENTRY
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/prsample/main.cpp Source File

  • Dataaccess
  • oledb
  • prsample

main.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 // Microsoft OLE DB Programmer's Reference Sample
00003 // Copyright (C) 1998 By Microsoft Corporation.
00004 //
00005 // @doc
00006 //
00007 // @module MAIN.CPP
00008 //
00009 //---------------------------------------------------------------------------
00010
00011
00012 /////////////////////////////////////////////////////////////////
00013 // Includes
00014 //
00015 /////////////////////////////////////////////////////////////////
00016 #define DBINITCONSTANTS   // Store all OLE DB consts inside this .obj file
00017 #include "prsample.h"   // Programmer's Reference Sample includes
00018
00019
00020 /////////////////////////////////////////////////////////////////
00021 // Globals
00022 //
00023 /////////////////////////////////////////////////////////////////
00024 DWORD g_dwFlags = USE_PROMPTDATASOURCE | DISPLAY_METHODCALLS;
00025
00026
00027 /////////////////////////////////////////////////////////////////
00028 // main
00029 //
00030 //  This is a simple OLE DB application that will display a
00031 //  rowset and will allow basic navigation of that rowset by the
00032 //  user.
00033 //
00034 //  In the sample, functions that begin with 'my' are implemented
00035 //  in the sample code; all other functions are either OLE DB
00036 //  methods or are standard system methods. In addition, two
00037 //  macros are used repeatedly throughout the sample:
00038 //   - CHECK_HR(hr)  - this macro goes to the CLEANUP label if
00039 //     FAILED(hr), where hr is usually a method call
00040 //   - XCHECK_HR(hr) - this macro prints the string
00041 //     representation of hr to stderr and if FAILED(hr), attempts
00042 //     to obtain and display any extended error information
00043 //     posted by the last method call, then jumps to the CLEANUP
00044 //     label
00045 //
00046 //  This is the entry point for the sample. This function will:
00047 //   - parse command line arguments passed to the sample
00048 //   - display appropriate instructions based on these arguments
00049 //   - create an OLE DB DataSource object for a user-chosen
00050 //     provider
00051 //   - create an OLE DB Session object from the provider's
00052 //     DataSource object
00053 //   - create an OLE DB Rowset object, over a table specified by
00054 //     the user, from the provider's Session object
00055 //   - display the rowset data and will allow the user to
00056 //     navigate over the rowset
00057 //
00058 /////////////////////////////////////////////////////////////////
00059 int main()
00060 {
00061   HRESULT         hr;
00062   IUnknown *        pUnkDataSource        = NULL;
00063   IUnknown *        pUnkSession         = NULL;
00064   IUnknown *        pUnkRowset          = NULL;
00065
00066   // Parse command line arguments, if any; this will update
00067   // the value of g_dwFlags as appropriate for the arguments
00068   if( !myParseCommandLine() )
00069     return EXIT_FAILURE;
00070
00071   // Display instructions for the given command line arguments
00072   myDisplayInstructions();
00073
00074   // Initialize OLE
00075   hr = CoInitialize(NULL);
00076   if( FAILED(hr) )
00077     return EXIT_FAILURE;
00078
00079   // Create the Data Source object using the OLE DB service components
00080   CHECK_HR(hr = myCreateDataSource(&pUnkDataSource));
00081
00082   // Create a Session object from the Data Source object
00083   CHECK_HR(hr = myCreateSession(pUnkDataSource, &pUnkSession));
00084
00085   // Create a Rowset object from the Session object, either directly
00086   // from the Session or through a Command object
00087   CHECK_HR(hr = myCreateRowset(pUnkSession, &pUnkRowset));
00088
00089   // Display the Rowset object data to the user
00090   CHECK_HR(hr = myDisplayRowset(pUnkRowset, NULL, 0, NULL));
00091
00092 CLEANUP:
00093   if( pUnkRowset )
00094     pUnkRowset->Release();
00095   if( pUnkSession )
00096     pUnkSession->Release();
00097   if( pUnkDataSource )
00098     pUnkDataSource->Release();
00099
00100   CoUninitialize();
00101
00102   if( FAILED(hr) )
00103     return EXIT_FAILURE;
00104
00105   return EXIT_SUCCESS;
00106 }
00107
00108
00109 /////////////////////////////////////////////////////////////////
00110 // myParseCommandLine
00111 //
00112 //  This function parses the application's command line arguments
00113 //  and sets the appropriate bits in g_dwFlags. If an invalid
00114 //  argument is encountered, a usage message is displayed and
00115 //  the function returns FALSE; otherwise TRUE is returned.
00116 //
00117 /////////////////////////////////////////////////////////////////
00118 BOOL myParseCommandLine
00119   (
00120   void
00121   )
00122 {
00123   int           iArg;
00124   CHAR *          psz;
00125
00126   // Set the locale for all C runtime functions
00127   setlocale(LC_ALL, ".ACP");
00128
00129   // Go through each command line argument and set the appropriate
00130   // bits in g_dwFlags, depending on the chosen options
00131   for( iArg = 1; iArg < __argc; iArg++ )
00132   {
00133     // Inspect the current argument string
00134     psz = __argv[iArg];
00135
00136     // Valid options begin with '-' or '/'
00137     if( psz[0] == '-' || psz[0] == '/' )
00138     {
00139       // The next character is the option
00140       switch( tolower(psz[1]) )
00141       {
00142       case 'u':
00143         // Use the service components UI to prompt for and create
00144         // the DataSource object; the enumerator is not used
00145         g_dwFlags |= USE_PROMPTDATASOURCE;
00146         g_dwFlags &= ~USE_ENUMERATOR;
00147         continue;
00148       case 'e':
00149         // Use the enumerator to select the provider, then use
00150         // IDataInitialize to create the DataSource object;
00151         // don't use the UI to prompt for the DataSource
00152         g_dwFlags |= USE_ENUMERATOR;
00153         g_dwFlags &= ~USE_PROMPTDATASOURCE;
00154         continue;
00155       case 'c':
00156         // Use ICommand instead of IOpenRowset
00157         g_dwFlags |= USE_COMMAND;
00158         continue;
00159       case 'b':
00160         // Use ISequentialStream to fetch BLOB column data
00161         g_dwFlags |= USE_ISEQSTREAM;
00162         continue;
00163       case 'n':
00164         // Don't display method call strings as part of
00165         // the extended error checking macro
00166         g_dwFlags &= ~DISPLAY_METHODCALLS;
00167         continue;
00168       }
00169     }
00170
00171     // Invalid argument; show the usage flags to the user
00172     fprintf(stderr, "Usage: %s [-u] [-e] [-c] [-b] [-n]\n\nWhere:\n\t" \
00173       "u = Use the Microsoft Data Links UI " \
00174         "to create the DataSource\n\t" \
00175       "e = Use the Enumerator and IDataInitialize " \
00176         "to create the DataSource\n\t" \
00177       "c = Use ICommand instead of IOpenRowset to create the Rowset\n\t" \
00178       "b = Use ISequentialStream for BLOB columns\n\t" \
00179       "n = Don't display method call strings\n",
00180       __argv[0]);
00181
00182     return FALSE;
00183   }
00184
00185   return TRUE;
00186 }
00187
00188
00189 /////////////////////////////////////////////////////////////////
00190 // myDisplayInstructions
00191 //
00192 //  This function asks the user whether they would like
00193 //  instructions displayed for the application. If so, it
00194 //  displays the instructions appropriate to the flags set
00195 //  in g_dwFlags.
00196 //
00197 /////////////////////////////////////////////////////////////////
00198 void myDisplayInstructions
00199   (
00200   void
00201   )
00202 {
00203   CHAR          ch;
00204
00205   // Display header and ask the user if they want instructions
00206   printf("\nOLE DB Programmer's Reference Sample\n" \
00207        "====================================\n\n");
00208   printf("Display instructions [Y or N]? ");
00209   do
00210   {
00211     ch = myGetChar();
00212   }
00213   while( ch != 'y' && ch != 'n' );
00214   printf("%c\n\n", ch);
00215
00216   // No instructions, so we're done
00217   if( ch == 'n' )
00218     return;
00219
00220   // Display basic instructions
00221   printf("This application is a simple OLE DB sample that will display\n" \
00222        "a rowset and will allow basic navigation of that rowset by\n" \
00223        "the user. The application will perform the following steps:\n\n");
00224
00225   // Display DataSource creation instructions
00226   if( g_dwFlags & USE_PROMPTDATASOURCE )
00227   {
00228     printf(" - Creates a DataSource object through the Microsoft Data\n" \
00229          "   Links UI. This allows the user to select the OLE DB\n" \
00230          "   provider to use and to set connection properties.\n");
00231   }
00232   else
00233   {
00234     printf(" - Creates a DataSource object through IDataInitialize::\n" \
00235          "   CreateDBInstance, which allows the OLE DB service\n" \
00236          "   component manager to add additional functionality to\n" \
00237          "   the provider as requested. The user will select the\n" \
00238          "   provider to use from a rowset obtained from the OLE DB\n" \
00239          "   enumerator.\n");
00240   }
00241
00242   // Display Session creation and table-selection instructions
00243   printf(" - Creates a Session object from the DataSource object.\n");
00244   printf(" - If the provider supports the schema rowset interface,\n" \
00245        "   creates a TABLES schema rowset and allows the user to\n" \
00246        "   select a table name from this rowset.\n");
00247
00248   // Display Rowset creation instructions
00249   if( g_dwFlags & USE_COMMAND )
00250   {
00251     printf(" - Creates a Command object from the Session object and\n" \
00252          "   allows the user to specify command text for this Command,\n" \
00253          "   then executes the command to create the final rowset.\n");
00254   }
00255   else
00256   {
00257     printf(" - Creates the final rowset over the table specified by the\n" \
00258          "   user.\n");
00259   }
00260
00261   printf(" - Displays this rowset and allows the user to perform basic\n" \
00262        "   navigation of that rowset.\n\n");
00263
00264   // Wait for the user to press a key before continuing
00265   printf("Press a key to continue...");
00266   myGetChar();
00267   printf("\n\n");
00268 }
00269
00270
00271
00272 /////////////////////////////////////////////////////////////////
00273 // myGetInputFromUser
00274 //
00275 //  This function prompts the user with the contents of pwszFmt
00276 //  and any accompanying variable arguments, then gets a string
00277 //  as input from the user. If the string is non-empty, it is
00278 //  copied into pwszInput and the function returns TRUE;
00279 //  otherwise this function returns FALSE.
00280 //
00281 /////////////////////////////////////////////////////////////////
00282 BOOL myGetInputFromUser
00283   (
00284   LPWSTR          pwszInput,
00285   LPCWSTR         pwszFmt,
00286   ...
00287   )
00288 {
00289   va_list         vargs;
00290   WCHAR         wszBuffer[MAX_NAME_LEN + 1] = {0};
00291
00292   // Create the string with variable arguments...
00293   va_start(vargs, pwszFmt);
00294   _vsnwprintf(wszBuffer, MAX_NAME_LEN, pwszFmt, vargs);
00295   va_end(vargs);
00296
00297   // Output the string...
00298   wprintf(wszBuffer);
00299
00300   // Now get the Input from the user...
00301   _getws(wszBuffer);
00302   if( wszBuffer[0] )
00303   {
00304     wcscpy(pwszInput, wszBuffer);
00305     return TRUE;
00306   }
00307
00308   return FALSE;
00309 }
00310
00311
00312 /////////////////////////////////////////////////////////////////
00313 // myGetChar
00314 //
00315 //  This function gets a character from the keyboard and
00316 //  converts it to lowercase before returning it.
00317 //
00318 /////////////////////////////////////////////////////////////////
00319 CHAR myGetChar
00320   (
00321   void
00322   )
00323 {
00324   CHAR          ch;
00325
00326   // Get a character from the keyboard
00327   ch = _getch();
00328
00329   // Re-read for the actual key value if necessary
00330   if( !ch || ch == 0xE0 )
00331     ch = _getch();
00332
00333   return tolower(ch);
00334 }
Generated on Wed Nov 13 2024 16:51:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDimmer Member List

This is the complete list of members for CDimmer, including all inherited members.
CDimmer() | CDimmer | [inline]
CDimmer() | CDimmer | [inline]
CDimmer() | CDimmer |
descriptionDoc | CDimmer | [private]
GetServiceObject(BSTR bstrUDN, BSTR bstrServiceId, IDispatch **ppdispService) | CDimmer | [inline]
GetServiceObject(BSTR bstrUDN, BSTR bstrServiceId, IDispatch **ppdispService) | CDimmer | [inline]
GetServiceObject(BSTR bstrUDN, BSTR bstrServiceId, IDispatch **ppdispService) | CDimmer |
Initialize(BSTR bstrXMLDesc, BSTR bstrDeviceIdentifier, BSTR bstrInitString) | CDimmer | [inline]
Initialize(BSTR bstrXMLDesc, BSTR bstrDeviceIdentifier, BSTR bstrInitString) | CDimmer | [inline]
Initialize(BSTR bstrXMLDesc, BSTR deviceID, BSTR bstrInitString) | CDimmer |
pDisPtrs | CDimmer | [private]
serviceIDDeviceMap | CDimmer | [private]
UDNmapping | CDimmer | [private]
~CDimmer() | CDimmer |
Generated on Wed Nov 13 2024 16:56:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/PerDraw/Connect.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • PerDraw

Connect.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONNECT.CPP
00003
00004   Summary:   Implementation file for the connection points (and their
00005              connections) offered by the connectable objects in the
00006              PERDRAW server sample. COM objects are implemented for
00007              Connection Point Enumerators, Connection Points, and
00008              Connection Enumerators.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial PERDRAW.HTM
00012              file. For more specific technical details on the internal
00013              workings see the comments dispersed throughout the module's
00014              source code.
00015
00016   Classes:   COEnumConnectionPoints, COConnectionPoint, and
00017              COEnumConnections.
00018
00019   Functions: none.
00020
00021   Origin:    5-20-97: atrent - Editor inheritance from STOSERVE
00022              Tutorial Code Sample. Very little change was required.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039
00040 /*---------------------------------------------------------------------------
00041   We include WINDOWS.H for all Win32 applications.
00042   We include OLE2.H because we will be calling the COM/OLE Libraries.
00043   We include OLECTL.H because it has definitions for connectable objects.
00044   We include APPUTIL.H because we will be building this application using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IPAGES.H and PAGEGUID.H for the common page-related
00048     Interface class, GUID, and CLSID specifications.
00049   We include SERVER.H because it has internal class declarations and
00050     resource ID definitions specific for this DLL.
00051   We include CONNECT.H for object class declarations for the various
00052     connection point and connection COM objects used in CONSERVE.
00053   We include DRAWPAGE.H because it has the class COEnumConnectionPoints
00054     declarations as well as the CODrawPage class declaration.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <olectl.h>
00059 #include <apputil.h>
00060 #include <ipages.h>
00061 #include <pageguid.h>
00062 #include "server.h"
00063 #include "connect.h"
00064 #include "drawpage.h"
00065
00066
00067 /*---------------------------------------------------------------------------
00068   COEnumConnectionPoints's implementation of its main COM object class
00069   including Constructor, Destructor, QueryInterface, AddRef, Release,
00070   Next, Skip, Reset, and Clone.
00071 ---------------------------------------------------------------------------*/
00072
00073 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00074   Method:   COEnumConnectionPoints::COEnumConnectionPoints
00075
00076   Summary:  COEnumConnectionPoints Constructor.
00077
00078   Args:     IUnknown* pHostObj
00079               Pointer to the host object whose connection points are
00080               being enumerated.
00081
00082   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnPts, and m_paConnPts.
00083
00084   Returns:  void
00085 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00086 COEnumConnectionPoints::COEnumConnectionPoints(
00087   IUnknown* pHostObj)
00088 {
00089   // Zero the COM object's reference count.
00090   m_cRefs = 0;
00091
00092   // Assign the Host Object pointer.
00093   m_pHostObj = pHostObj;
00094
00095   // Initialize the Connection Point enumerator variables.
00096   m_iEnumIndex = 0;
00097   m_cConnPts = 0;
00098   m_paConnPts = NULL;
00099
00100   return;
00101 }
00102
00103
00104 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00105   Method:   COEnumConnectionPoints::~COEnumConnectionPoints
00106
00107   Summary:  COEnumConnectionPoints Destructor.
00108
00109   Args:     void
00110
00111   Modifies: m_paConnPts.
00112
00113   Returns:  void
00114 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00115 COEnumConnectionPoints::~COEnumConnectionPoints(void)
00116 {
00117   if (NULL != m_paConnPts)
00118   {
00119     UINT i;
00120
00121     // Release all the connection point interface pointers.
00122     for (i=0; i<m_cConnPts; i++)
00123       if (NULL != m_paConnPts[i])
00124         m_paConnPts[i]->Release();
00125
00126     // Delete the array of interface pointers.
00127     delete [] m_paConnPts;
00128   }
00129
00130   return;
00131 }
00132
00133
00134 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00135   Method:   COEnumConnectionPoints::Init
00136
00137   Summary:  COEnumConnectionPoints Initialization method.  Create any
00138             necessary arrays, structures, and objects.
00139
00140   Args:     ULONG cConnPts,
00141               Number of Connections Points.
00142             IConnectionPoint** paConnPts,
00143               Pointer to array of connection point interface pointers.
00144             ULONG iEnumIndex
00145               The initial Enumerator index value.
00146
00147   Modifies: m_cConnPts, m_paConnPts, m_iEnumIndex.
00148
00149   Returns:  HRESULT
00150               Standard result code. NOERROR for success.
00151 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00152 HRESULT COEnumConnectionPoints::Init(
00153           ULONG cConnPts,
00154           IConnectionPoint** paConnPts,
00155           ULONG iEnumIndex)
00156 {
00157   HRESULT hr = NOERROR;
00158   UINT i;
00159
00160   // Remember the number of Connection points.
00161   m_cConnPts = cConnPts;
00162
00163   // Remember the initial enumerator index.
00164   m_iEnumIndex = iEnumIndex;
00165
00166   // Create a copy of the array of connection points and keep it inside
00167   // this enumerator COM object.
00168   m_paConnPts = new IConnectionPoint* [(UINT) cConnPts];
00169
00170   // Fill the array copy with the IConnectionPoint interface pointers from
00171   // the array passed. AddRef for each new Interface pointer copy made.
00172   if (NULL != m_paConnPts)
00173   {
00174     for (i=0; i<cConnPts; i++)
00175     {
00176       m_paConnPts[i] = paConnPts[i];
00177       m_paConnPts[i]->AddRef();
00178     }
00179   }
00180   else
00181     hr = E_OUTOFMEMORY;
00182
00183   return (hr);
00184 }
00185
00186
00187 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00188   Method:   COEnumConnectionPoints::QueryInterface
00189
00190   Summary:  QueryInterface of the COEnumConnectionPoints non-delegating
00191             IUnknown implementation.
00192
00193   Args:     REFIID riid,
00194               [in] GUID of the Interface being requested.
00195             PPVOID ppv)
00196               [out] Address of the caller's pointer variable that will
00197               receive the requested interface pointer.
00198
00199   Returns:  HRESULT
00200 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00201 STDMETHODIMP COEnumConnectionPoints::QueryInterface(
00202                REFIID riid,
00203                PPVOID ppv)
00204 {
00205   HRESULT hr = E_NOINTERFACE;
00206
00207   *ppv = NULL;
00208
00209   // The IEnumConnectionPoints interface is implemented directly in
00210   // this COM object rather than being a nested interface implementation.
00211   if (IID_IUnknown == riid || IID_IEnumConnectionPoints == riid)
00212     *ppv = (LPVOID)this;
00213
00214   if (NULL != *ppv)
00215   {
00216     // We've handed out a pointer to the interface so obey the COM rules
00217     // and AddRef the reference count.
00218     ((LPUNKNOWN)*ppv)->AddRef();
00219     hr = NOERROR;
00220   }
00221
00222   return (hr);
00223 }
00224
00225
00226 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00227   Method:   COEnumConnectionPoints::AddRef
00228
00229   Summary:  AddRef of the COEnumConnectionPoints non-delegating IUnknown
00230             implementation.
00231
00232   Args:     void
00233
00234   Modifies: m_cRefs.
00235
00236   Returns:  ULONG
00237               New value of m_cRefs (COM object's reference count).
00238 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00239 STDMETHODIMP_(ULONG) COEnumConnectionPoints::AddRef(void)
00240 {
00241   ULONG cRefs;
00242
00243   cRefs = ++m_cRefs;
00244
00245   // Also AddRef the host object to ensure it stays around as long as
00246   // this enumerator.
00247   m_pHostObj->AddRef();
00248
00249   return cRefs;
00250 }
00251
00252
00253 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00254   Method:   COEnumConnectionPoints::Release
00255
00256   Summary:  Release of the COEnumConnectionPoints non-delegating IUnknown
00257             implementation.
00258
00259   Args:     void
00260
00261   Modifies: m_cRefs.
00262
00263   Returns:  ULONG
00264               New value of m_cRefs (COM object's reference count).
00265 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00266 STDMETHODIMP_(ULONG) COEnumConnectionPoints::Release(void)
00267 {
00268   ULONG cRefs;
00269
00270   // Pass this release along to the Host object being enumerated.
00271   m_pHostObj->Release();
00272
00273   cRefs = --m_cRefs;
00274
00275   if (0 == cRefs)
00276   {
00277     // We artificially bump the main ref count to prevent reentrancy via
00278     // the main object destructor.
00279     m_cRefs++;
00280     delete this;
00281   }
00282
00283   return cRefs;
00284 }
00285
00286
00287 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00288   Method:   COEnumConnectionPoints::Next
00289
00290   Summary:  The Next member method of this IEnumConnectionPoints interface
00291             implementation. Called by outside clients of a
00292             COEnumConnectionPoints object to request that a number of next
00293             connection point interface pointers be deposited into an array
00294             supplied by the caller.
00295
00296   Args:     ULONG cReq
00297               Number of connection points requested for return (starting at
00298               the current Enumerator index).
00299             IConnectionPoint** paConnPts,
00300               Pointer to a caller's output array that will receive the
00301               enumerated IConnectionPoint interface pointers.
00302             ULONG* cEnumerated)
00303               Pointer to a ULONG variable that will contain the number of
00304               connection points actually enumerated by this call.
00305
00306   Returns:  HRESULT
00307               Standard result code. NOERROR for success.
00308 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00309 STDMETHODIMP COEnumConnectionPoints::Next(
00310                ULONG cReq,
00311                IConnectionPoint** paConnPts,
00312                ULONG* pcEnumerated)
00313 {
00314   HRESULT hr = NOERROR;
00315   ULONG cRet = 0;
00316
00317   // Make sure the argument values passed are valid.
00318   if (NULL != m_paConnPts)
00319   {
00320     if (NULL != paConnPts)
00321     {
00322       if (NULL != *paConnPts && m_iEnumIndex < m_cConnPts)
00323       {
00324         if (NULL != pcEnumerated)
00325           *pcEnumerated = 0L;
00326         else
00327           if (1L != cReq)
00328             hr = E_POINTER;
00329       }
00330       else
00331         hr = S_FALSE;
00332     }
00333     else
00334       hr = E_POINTER;
00335   }
00336   else
00337     hr = S_FALSE;
00338
00339   if (SUCCEEDED(hr))
00340   {
00341     // Starting at the current Enumerator index, loop to assign the
00342     // requested number of output connection point interface pointers.
00343     for (; m_iEnumIndex < m_cConnPts && cReq > 0;
00344            paConnPts++, cRet++, cReq--)
00345     {
00346       // Assign from the inside Enumerator array to the specified receiving
00347       // array.
00348       *paConnPts = m_paConnPts[m_iEnumIndex++];
00349       // After assigning a copy of an IConnectionPoint pointer, AddRef it.
00350       if (NULL != *paConnPts)
00351         (*paConnPts)->AddRef();
00352     }
00353
00354     // Assign the output number of connection points enumerated.
00355     if (NULL != pcEnumerated)
00356       *pcEnumerated = cRet;
00357   }
00358
00359   return hr;
00360 }
00361
00362
00363 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00364   Method:   COEnumConnectionPoints::Skip
00365
00366   Summary:  The Skip member method of this IEnumConnectionPoints interface
00367             implementation. Starting at the current Enumerator index, skip
00368             the specified number of connection point items.
00369
00370   Args:     ULONG cSkip
00371               Number of Connection Point items to skip.
00372
00373   Returns:  HRESULT
00374               Standard result code. NOERROR for success.
00375 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00376 STDMETHODIMP COEnumConnectionPoints::Skip(
00377                ULONG cSkip)
00378 {
00379   HRESULT hr = NOERROR;
00380
00381   // If there really is a connection point array and the requested
00382   // amount of skip does not exceed the number of connection points,
00383   // then bump the index by the requested skip amount.
00384   if (NULL != m_paConnPts && (m_iEnumIndex + cSkip) < m_cConnPts)
00385     m_iEnumIndex += cSkip;
00386   else
00387     hr = S_FALSE;
00388
00389   return hr;
00390 }
00391
00392
00393 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00394   Method:   COEnumConnectionPoints::Reset
00395
00396   Summary:  The Reset member method of the IEnumConnectionPoints interface
00397             implementation. Resets the Enumeration index to the first
00398             connection point item in the array.
00399
00400   Args:     void.
00401
00402   Returns:  HRESULT
00403               Standard result code. NOERROR for success.
00404 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00405 STDMETHODIMP COEnumConnectionPoints::Reset(
00406                void)
00407 {
00408   // Zero the main Enumerator index.
00409   m_iEnumIndex = 0;
00410
00411   return NOERROR;
00412 }
00413
00414
00415 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00416   Method:   COEnumConnectionPoints::Clone
00417
00418   Summary:  The Clone member method of this IEnumConnectionPoints
00419             interface implementation. Creates a new clone of this entire
00420             Connection Point enumerator COM object.
00421
00422   Args:     IEnumConnectionPoints** ppIEnum
00423               Address of the caller's output pointer variable that will
00424               receive the IEnumConnectionPoints interface pointer of the
00425               new enumerator clone.
00426
00427   Returns:  HRESULT
00428               Standard result code. NOERROR for success.
00429 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00430 STDMETHODIMP COEnumConnectionPoints::Clone(
00431                IEnumConnectionPoints** ppIEnum)
00432 {
00433   HRESULT hr;
00434   COEnumConnectionPoints* pCOEnum;
00435
00436   // NULL the output variable first.
00437   *ppIEnum = NULL;
00438
00439   // Create the Clone Enumerator COM object.
00440   pCOEnum = new COEnumConnectionPoints(m_pHostObj);
00441   if (NULL != pCOEnum)
00442   {
00443     // Initialize it with same values as in this existing enumerator.
00444     hr = pCOEnum->Init(m_cConnPts, m_paConnPts, m_iEnumIndex);
00445     if (SUCCEEDED(hr))
00446     {
00447       // QueryInterface to return the requested interface pointer.
00448       // An AddRef will be conveniently done by the QI.
00449       if (SUCCEEDED(hr))
00450         hr = pCOEnum->QueryInterface(
00451                         IID_IEnumConnectionPoints,
00452                         (PPVOID)ppIEnum);
00453     }
00454   }
00455   else
00456     hr = E_OUTOFMEMORY;
00457
00458   return hr;
00459 }
00460
00461
00462 /*---------------------------------------------------------------------------
00463   COConnectionPoint's implementation of its main COM object class
00464   including Constructor, Destructor, QueryInterface, AddRef, Release,
00465   GetConnectionInterface, GetConnectionPointContainer, Advise, Unadvise,
00466   and EnumConnections.
00467 ---------------------------------------------------------------------------*/
00468
00469 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00470   Method:   COConnectionPoint::COConnectionPoint
00471
00472   Summary:  COConnectionPoint Constructor.
00473
00474   Args:     IUnknown* pHostObj
00475               Pointer to IUnknown of the connectable object offering this
00476               connection point.
00477
00478   Returns:  void
00479 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00480 COConnectionPoint::COConnectionPoint(
00481   IUnknown* pHostObj)
00482 {
00483   // Zero the COM object's reference count.
00484   m_cRefs = 0;
00485
00486   // Remember an IUnknown pointer to the connectable object that offers
00487   // this connection point. Since this connection point object's lifetime
00488   // is geared to that of the connectable object there is no need to
00489   // AddRef the following copied pointer to the connectable object.
00490   m_pHostObj = pHostObj;
00491
00492   // Initialize the Connection Point variables.
00493   m_dwNextCookie = COOKIE_START_VALUE;
00494   m_uiMaxIndex = 0;
00495   m_cConnections = 0;
00496   m_paConnections = NULL;
00497
00498   return;
00499 }
00500
00501
00502 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00503   Method:   COConnectionPoint::~COConnectionPoint
00504
00505   Summary:  COConnectionPoint Destructor.
00506
00507   Args:     void
00508
00509   Modifies: m_paConnections.
00510
00511   Returns:  void
00512 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00513 COConnectionPoint::~COConnectionPoint(void)
00514 {
00515   UINT i;
00516   IUnknown* pUnk;
00517
00518   if (NULL != m_paConnections)
00519   {
00520     // Release all the connection sink interface pointers.
00521     for (i=0; i<m_uiMaxIndex; i++)
00522     {
00523       pUnk = m_paConnections[i].pUnk;
00524       if (NULL != pUnk)
00525         pUnk->Release();
00526     }
00527
00528     // Delete the array of interface pointers.
00529     delete [] m_paConnections;
00530   }
00531
00532   return;
00533 }
00534
00535
00536 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00537   Method:   COConnectionPoint::Init
00538
00539   Summary:  COConnectionPoint Initialization method.  Create any
00540             necessary arrays, structures, and subordinate objects.
00541
00542   Args:     REFIID riid
00543               Reference to the IID of the Sink interface associated with
00544               this connection point.
00545
00546   Returns:  HRESULT
00547               Standard result code. NOERROR for success.
00548 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00549 HRESULT COConnectionPoint::Init(
00550           REFIID riid)
00551 {
00552   HRESULT hr = NOERROR;
00553   CONNECTDATA* paConns;
00554
00555   // Keep a copy of the reference to the IID of the sink interface
00556   // associated with this connection point. Needed for later
00557   // use by the GetConnectionInterface method.
00558   m_iidSink = riid;
00559
00560   // Build the initial dynamic array for connections.
00561   paConns = new CONNECTDATA[ALLOC_CONNECTIONS];
00562   if (NULL != paConns)
00563   {
00564     // Zero the array.
00565     memset(paConns, 0, ALLOC_CONNECTIONS * sizeof(CONNECTDATA));
00566
00567     // Rig this connection point object so that it will use the
00568     // new internal array of connections.
00569     m_uiMaxIndex = ALLOC_CONNECTIONS;
00570     m_paConnections = paConns;
00571   }
00572   else
00573     hr = E_OUTOFMEMORY;
00574
00575   return (hr);
00576 }
00577
00578
00579 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00580   Method:   COConnectionPoint::QueryInterface
00581
00582   Summary:  QueryInterface of the COConnectionPoint non-delegating
00583             IUnknown implementation.
00584
00585   Args:     REFIID riid,
00586               [in] GUID of the Interface being requested.
00587             PPVOID ppv)
00588               [out] Address of the caller's pointer variable that will
00589               receive the requested interface pointer.
00590
00591   Returns:  HRESULT
00592               Standard result code. NOERROR for success.
00593 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00594 STDMETHODIMP COConnectionPoint::QueryInterface(
00595                REFIID riid,
00596                PPVOID ppv)
00597 {
00598   HRESULT hr = E_NOINTERFACE;
00599
00600   *ppv = NULL;
00601
00602   // The IConnectionPoint interface is implemented directly in this
00603   // COM object rather than being a nested interface implementation.
00604   if (IID_IUnknown == riid || IID_IConnectionPoint == riid)
00605     *ppv = (LPVOID)this;
00606
00607   if (NULL != *ppv)
00608   {
00609     // We've handed out a pointer to the interface so obey the COM rules
00610     // and AddRef the reference count.
00611     ((LPUNKNOWN)*ppv)->AddRef();
00612     hr = NOERROR;
00613   }
00614
00615   return (hr);
00616 }
00617
00618
00619 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00620   Method:   COConnectionPoint::AddRef
00621
00622   Summary:  AddRef of the COConnectionPoint non-delegating IUnknown
00623             implementation.
00624
00625   Args:     void
00626
00627   Modifies: m_cRefs.
00628
00629   Returns:  ULONG
00630               New value of m_cRefs (COM object's reference count).
00631 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00632 STDMETHODIMP_(ULONG) COConnectionPoint::AddRef(void)
00633 {
00634   ULONG cRefs;
00635
00636   cRefs = ++m_cRefs;
00637
00638   return cRefs;
00639 }
00640
00641
00642 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00643   Method:   COConnectionPoint::Release
00644
00645   Summary:  Release of the COConnectionPoint non-delegating IUnknown
00646             implementation.
00647
00648   Args:     void
00649
00650   Modifies: m_cRefs.
00651
00652   Returns:  ULONG
00653               New value of m_cRefs (COM object's reference count).
00654 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00655 STDMETHODIMP_(ULONG) COConnectionPoint::Release(void)
00656 {
00657   ULONG cRefs;
00658
00659   cRefs = --m_cRefs;
00660
00661   if (0 == cRefs)
00662   {
00663     // We artificially bump the main ref count to prevent reentrancy via
00664     // the main object destructor. We relinquish thread ownership of this
00665     // object prior to deleting it--a good practice.
00666     m_cRefs++;
00667     delete this;
00668   }
00669
00670   return cRefs;
00671 }
00672
00673
00674 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00675   Method:   COConnectionPoint::GetSlot
00676
00677   Summary:  An internal private utility member method to obtain a free
00678             slot in the dynamic connections array. GetSlot will expand the
00679             dynamic array for more entries if needed.
00680
00681   Args:     UINT* puiFreeSlot
00682               Address of an output variable to receive the free slot index.
00683
00684   Modifies: m_uiMaxIndex, m_paConnections.
00685
00686   Returns:  HRESULT
00687               Standard result code. NOERROR for success.
00688 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00689 HRESULT COConnectionPoint::GetSlot(
00690           UINT* puiFreeSlot)
00691 {
00692   HRESULT hr = NOERROR;
00693   BOOL bOpen = FALSE;
00694   UINT i;
00695   CONNECTDATA* paConns;
00696
00697   // Zero the output variable.
00698   *puiFreeSlot = 0;
00699
00700   // Loop to find an empty slot.
00701   for (i=0; i<m_uiMaxIndex; i++)
00702   {
00703     if (m_paConnections[i].dwCookie == 0)
00704     {
00705       // We found an open empty slot.
00706       *puiFreeSlot = i;
00707       bOpen = TRUE;
00708       break;
00709     }
00710   }
00711
00712   if (!bOpen)
00713   {
00714     // We didn't find an existing open slot in the array--it's full.
00715     // Expand the array by ALLOC_CONNECTIONS entries and assign the
00716     // appropriate output index.
00717     paConns = new CONNECTDATA[m_uiMaxIndex + ALLOC_CONNECTIONS];
00718     if (NULL != paConns)
00719     {
00720       // Copy the content of the old full array to the new larger array.
00721       for (i=0; i<m_uiMaxIndex; i++)
00722       {
00723         paConns[i].pUnk = m_paConnections[i].pUnk;
00724         paConns[i].dwCookie = m_paConnections[i].dwCookie;
00725       }
00726
00727       // Zero (ie mark as empty) the expanded portion of the new array.
00728       for (i=m_uiMaxIndex; i<m_uiMaxIndex+ALLOC_CONNECTIONS; i++)
00729       {
00730         paConns[i].pUnk = NULL;
00731         paConns[i].dwCookie = 0;
00732       }
00733
00734       // New larger array is ready--delete the old array.
00735       delete [] m_paConnections;
00736
00737       // Rig the connection point to use the new larger array.
00738       m_paConnections = paConns;
00739
00740       // Assign the output free slot as first entry in new expanded area.
00741       *puiFreeSlot = m_uiMaxIndex;
00742
00743       // Calculate the new max index.
00744       m_uiMaxIndex += ALLOC_CONNECTIONS;
00745     }
00746     else
00747       hr = E_OUTOFMEMORY;
00748   }
00749
00750   return hr;
00751 }
00752
00753
00754 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00755   Method:   COConnectionPoint::FindSlot
00756
00757   Summary:  An internal private utility member method to find an existing
00758             slot (identified by the specified dwCookie value) in the
00759             dynamic connections array.
00760
00761   Args:     DWORD dwCookie,
00762               The connection key (cookie) to find.
00763             UINT* puiSlot)
00764               Address of an output variable to receive the slot index.
00765
00766   Returns:  HRESULT
00767               Standard result code. NOERROR for success.
00768 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00769 HRESULT COConnectionPoint::FindSlot(
00770           DWORD dwCookie,
00771           UINT* puiSlot)
00772 {
00773   HRESULT hr = CONNECT_E_NOCONNECTION;
00774   UINT i;
00775
00776   // Loop to find the Cookie.
00777   for (i=0; i<m_uiMaxIndex; i++)
00778   {
00779     if (dwCookie == m_paConnections[i].dwCookie)
00780     {
00781       // If a cookie match is found, assign the output slot index.
00782       *puiSlot = i;
00783       hr = NOERROR;
00784       break;
00785     }
00786   }
00787
00788   return hr;
00789 }
00790
00791
00792 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00793   Method:   COConnectionPoint::GetConnectionInterface
00794
00795   Summary:  The GetConnectionInterface member method of this
00796             IConnectionPoint interface implementation. Called to get the
00797             IID of the Sink interface associated with this connection
00798             point.
00799
00800   Args:     IID* piidSink
00801               Pointer to the IID of the associated sink interface.
00802
00803   Returns:  HRESULT
00804               Standard result code. NOERROR for success.
00805 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00806 STDMETHODIMP COConnectionPoint::GetConnectionInterface(
00807                IID* piidSink)
00808 {
00809   HRESULT hr = NOERROR;
00810
00811   if (NULL != piidSink)
00812     *piidSink = m_iidSink;
00813   else
00814     hr = E_POINTER;
00815
00816   return hr;
00817 }
00818
00819
00820 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00821   Method:   COConnectionPoint::GetConnectionPointContainer
00822
00823   Summary:  The GetConnectionPointContainer member method of this
00824             IConnectionPoint interface implementation. Called to get the
00825             connection point container that contains this connection
00826             point.
00827
00828   Args:     IConnectionPointContainer** ppConnPtCon
00829               Address of the pointer variable that will recieve the
00830               IConnectionPointContainer interface pointer.
00831
00832   Returns:  HRESULT
00833               Standard result code. NOERROR for success.
00834 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00835 STDMETHODIMP COConnectionPoint::GetConnectionPointContainer(
00836                IConnectionPointContainer** ppConnPtCon)
00837 {
00838   HRESULT hr;
00839
00840   // Use QueryInterface to get the interface pointer and to perform the
00841   // needed AddRef on the returned pointer.
00842   hr = m_pHostObj->QueryInterface(
00843                      IID_IConnectionPointContainer,
00844                      (PPVOID) ppConnPtCon);
00845
00846   return hr;
00847 }
00848
00849
00850 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00851   Method:   COConnectionPoint::Advise
00852
00853   Summary:  The Advise member method of this IConnectionPoint interface
00854             implementation. Called by clients to establish a connection of
00855             their sink to this connection point.
00856
00857   Args:     IUnknown* pUnkSink
00858               IUnknown interface pointer of the Sink object in the client.
00859             DWORD* pdwCookie
00860               Pointer to a DWORD in the client that will receive a unique
00861               key used by the client to refer to the connection established
00862               by this Advise call.
00863
00864   Returns:  HRESULT
00865               Standard result code. NOERROR for success.
00866 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00867 STDMETHODIMP COConnectionPoint::Advise(
00868                IUnknown* pUnkSink,
00869                DWORD* pdwCookie)
00870 {
00871   HRESULT hr = NOERROR;
00872   UINT uiFreeSlot = 0;
00873   IUnknown* pISink = NULL;
00874
00875   // Zero the output connection key.
00876   *pdwCookie = 0;
00877
00878   // Get the specific associated client Sink interface that this
00879   // connection point expects to use for notifications.
00880   hr = pUnkSink->QueryInterface(m_iidSink, (PPVOID)&pISink);
00881   if (SUCCEEDED(hr))
00882   {
00883     // Store the specific sink interface in this connection point's
00884     // array of live connections. First find a free slot (expand the
00885     // array if needed).
00886     hr = GetSlot(&uiFreeSlot);
00887     if (SUCCEEDED(hr))
00888     {
00889       // Assign the new slot with the connection entry.
00890       m_paConnections[uiFreeSlot].pUnk = pISink;
00891       m_paConnections[uiFreeSlot].dwCookie = m_dwNextCookie;
00892
00893       // Assign the output Cookie value.
00894       *pdwCookie = m_dwNextCookie;
00895
00896       // Increment the Cookie counter.
00897       m_dwNextCookie++;
00898
00899       // Increment the number of live connections.
00900       m_cConnections++;
00901     }
00902   }
00903   else if (hr == E_NOINTERFACE)
00904   {
00905      // The sink does not support m_iidSink.
00906      hr = CONNECT_E_CANNOTCONNECT;
00907   }
00908
00909   return hr;
00910 }
00911
00912
00913 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00914   Method:   COConnectionPoint::Unadvise
00915
00916   Summary:  The Unadvise member method of this IConnectionPoint interface
00917             implementation. Called by clients to disconnect a connection
00918             of their sink to this connection point. The connection is
00919             identified by the dwCookie argument (obtained by a previous
00920             Advise call).
00921
00922   Args:     DWORD dwCookie
00923               Connection key that was obtained by a previous Advise call.
00924
00925   Returns:  HRESULT
00926               Standard result code. NOERROR for success.
00927 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00928 STDMETHODIMP COConnectionPoint::Unadvise(
00929                DWORD dwCookie)
00930 {
00931   HRESULT hr = NOERROR;
00932   UINT uiSlot;
00933
00934   if (0 != dwCookie)
00935   {
00936     hr = FindSlot(dwCookie, &uiSlot);
00937     if (SUCCEEDED(hr))
00938     {
00939       // Release the sink interface.
00940       RELEASE_INTERFACE(m_paConnections[uiSlot].pUnk);
00941
00942       // Mark the array entry as empty.
00943       m_paConnections[uiSlot].dwCookie = 0;
00944
00945       // Decrement the number of live connections.
00946       m_cConnections--;
00947     }
00948   }
00949   else
00950     hr = E_INVALIDARG;
00951
00952   return hr;
00953 }
00954
00955
00956 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00957   Method:   COConnectionPoint::EnumConnections
00958
00959   Summary:  The EnumConnections member method of this IConnectionPoint
00960             interface implementation. Called to obtain an IEnumConnections
00961             enumerator interface that can be used to enumerate the
00962             connections of this connection point.
00963
00964   Args:     IEnumConnections** ppIEnum
00965               Address of the caller's output pointer variable that will
00966               receive the enumerator IEnumConnections interface pointer.
00967
00968   Returns:  HRESULT
00969               Standard result code. NOERROR for success.
00970 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00971 STDMETHODIMP COConnectionPoint::EnumConnections(
00972                IEnumConnections** ppIEnum)
00973 {
00974   HRESULT hr = OLE_E_NOCONNECTION;
00975   CONNECTDATA* paConns;
00976   COEnumConnections* pCOEnum;
00977   UINT i,j;
00978
00979   // Zero the output enumerator interface pointer.
00980   *ppIEnum = NULL;
00981
00982   if (0 != m_cConnections)
00983   {
00984     // Create an array of CONNECTDATA structures.
00985     paConns = new CONNECTDATA[(UINT)m_cConnections];
00986     if (NULL != paConns)
00987     {
00988       for (i=0, j=0; i<m_uiMaxIndex && j<m_cConnections; i++)
00989       {
00990         // Copy non-empty entries only.
00991         if (0 != m_paConnections[i].dwCookie)
00992         {
00993           // Assign the occupied entry.
00994           paConns[j].pUnk = (IUnknown*)m_paConnections[i].pUnk;
00995           paConns[j].dwCookie = m_paConnections[i].dwCookie;
00996           j++;
00997         }
00998       }
00999
01000       // Create a new COM object for enumerating connections. Pass
01001       // 'this' as a pHostObj pointer used later to ensure the host
01002       // connection point object stays alive as long as the enumerator
01003       // that enumerates connections to that connection point.
01004       pCOEnum = new COEnumConnections(this);
01005       if (NULL != pCOEnum)
01006       {
01007         // Use the previously constructed (paConns) array of connections
01008         // to init the new COEnumConnections COM object. The Init will
01009         // build yet another internal copy of this array. Set the
01010         // initial enumerator index to 0.
01011         hr = pCOEnum->Init(m_cConnections, paConns, 0);
01012
01013         // QueryInterface to return the requested interface pointer.
01014         // An AddRef will be conveniently done by the QI.
01015         if (SUCCEEDED(hr))
01016           hr = pCOEnum->QueryInterface(
01017                  IID_IEnumConnections,
01018                  (PPVOID)ppIEnum);
01019       }
01020       else
01021         hr = E_OUTOFMEMORY;
01022
01023       // We're done with the locally constructed array copy--delete it.
01024       delete [] paConns;
01025     }
01026     else
01027       hr = E_OUTOFMEMORY;
01028   }
01029
01030   return hr;
01031 }
01032
01033
01034 /*---------------------------------------------------------------------------
01035   COEnumConnections's implementation of its main COM object class
01036   including Constructor, Destructor, QueryInterface, AddRef, Release,
01037   Next, Skip, Reset, and Clone.
01038 ---------------------------------------------------------------------------*/
01039
01040 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01041   Method:   COEnumConnections::COEnumConnections
01042
01043   Summary:  COEnumConnections Constructor.
01044
01045   Args:     IUnknown* pHostObj
01046               Pointer to IUnknown interface of the host Connection Point
01047               COM object whose connections are being enumerated.
01048
01049   Modifies: m_cRefs, m_pHostObj, m_iEnumIndex, m_cConnections,
01050             and m_paConnections.
01051
01052   Returns:  void
01053 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01054 COEnumConnections::COEnumConnections(
01055   IUnknown* pHostObj)
01056 {
01057   // Zero the COM object's reference count.
01058   m_cRefs = 0;
01059
01060   // Assign the Host Object pointer.
01061   m_pHostObj = pHostObj;
01062
01063   // Initialize the Connection Point enumerator variables.
01064   m_iEnumIndex = 0;
01065   m_cConnections = 0;
01066   m_paConnections = NULL;
01067
01068   return;
01069 }
01070
01071
01072 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01073   Method:   COEnumConnections::~COEnumConnections
01074
01075   Summary:  COEnumConnections Destructor.
01076
01077   Args:     void
01078
01079   Modifies: m_paConnections.
01080
01081   Returns:  void
01082 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01083 COEnumConnections::~COEnumConnections(void)
01084 {
01085   if (NULL != m_paConnections)
01086   {
01087     UINT i;
01088
01089     // Release all the connected sink interface pointers.
01090     for (i=0; i<m_cConnections; i++)
01091       m_paConnections[i].pUnk->Release();
01092
01093     // Delete the array of connections.
01094     delete [] m_paConnections;
01095   }
01096
01097   return;
01098 }
01099
01100
01101 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01102   Method:   COEnumConnections::Init
01103
01104   Summary:  COEnumConnections Initialization method.  Create any
01105             necessary arrays, structures, and objects.
01106
01107   Args:     ULONG cConnections
01108               Number of Connections.
01109             CONNECTDATA* paConnections,
01110               Pointer to array of connections.
01111             ULONG iEnumIndex
01112               The Enumerator index initial value.
01113
01114   Modifies: m_cConnections, m_paConnections, m_pHostObj, m_iEnumIndex.
01115
01116   Returns:  HRESULT
01117               Standard result code. NOERROR for success.
01118 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01119 HRESULT COEnumConnections::Init(
01120           ULONG cConnections,
01121           CONNECTDATA* paConnections,
01122           ULONG iEnumIndex)
01123 {
01124   HRESULT hr = NOERROR;
01125   UINT i;
01126
01127   // Remember the number of live Connections.
01128   m_cConnections = cConnections;
01129
01130   // Remember the initial enumerator index.
01131   m_iEnumIndex = iEnumIndex;
01132
01133   // Create a copy of the array of connections and keep it inside
01134   // this enumerator COM object.
01135   m_paConnections = new CONNECTDATA [(UINT) cConnections];
01136
01137   // Fill the array copy with the connection data from the connections
01138   // array passed. AddRef for each new sink Interface pointer copy made.
01139   if (NULL != m_paConnections)
01140   {
01141     for (i=0; i<cConnections; i++)
01142     {
01143       m_paConnections[i] = paConnections[i];
01144       m_paConnections[i].pUnk->AddRef();
01145     }
01146   }
01147   else
01148     hr = E_OUTOFMEMORY;
01149
01150   return (hr);
01151 }
01152
01153
01154 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01155   Method:   COEnumConnections::QueryInterface
01156
01157   Summary:  QueryInterface of the COEnumConnections non-delegating
01158             IUnknown implementation.
01159
01160   Args:     REFIID riid,
01161               [in] GUID of the Interface being requested.
01162             PPVOID ppv)
01163               [out] Address of the caller's pointer variable that will
01164               receive the requested interface pointer.
01165
01166   Returns:  HRESULT
01167               Standard result code. NOERROR for success.
01168 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01169 STDMETHODIMP COEnumConnections::QueryInterface(
01170                REFIID riid,
01171                PPVOID ppv)
01172 {
01173   HRESULT hr = E_NOINTERFACE;
01174
01175   *ppv = NULL;
01176
01177   // The IEnumConnections interface is implemented directly in
01178   // this COM object rather than being a nested interface implementation.
01179   if (IID_IUnknown == riid || IID_IEnumConnections == riid)
01180     *ppv = (LPVOID)this;
01181
01182   if (NULL != *ppv)
01183   {
01184     // We've handed out a pointer to the interface so obey the COM rules
01185     // and AddRef the reference count.
01186     ((LPUNKNOWN)*ppv)->AddRef();
01187     hr = NOERROR;
01188   }
01189
01190   return (hr);
01191 }
01192
01193
01194 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01195   Method:   COEnumConnections::AddRef
01196
01197   Summary:  AddRef of the COEnumConnections non-delegating IUnknown
01198             implementation.
01199
01200   Args:     void
01201
01202   Modifies: m_cRefs.
01203
01204   Returns:  ULONG
01205               New value of m_cRefs (COM object's reference count).
01206 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01207 STDMETHODIMP_(ULONG) COEnumConnections::AddRef(void)
01208 {
01209   ULONG cRefs;
01210
01211   cRefs = ++m_cRefs;
01212
01213   // Also AddRef the host object to ensure it stays around as long as
01214   // this enumerator.
01215   m_pHostObj->AddRef();
01216
01217   return cRefs;
01218 }
01219
01220
01221 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01222   Method:   COEnumConnections::Release
01223
01224   Summary:  Release of the COEnumConnections non-delegating IUnknown
01225             implementation.
01226
01227   Args:     void
01228
01229   Modifies: m_cRefs.
01230
01231   Returns:  ULONG
01232               New value of m_cRefs (COM object's reference count).
01233 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01234 STDMETHODIMP_(ULONG) COEnumConnections::Release(void)
01235 {
01236   ULONG cRefs;
01237
01238   // Pass this release along to the Host object being enumerated.
01239   m_pHostObj->Release();
01240
01241   cRefs = --m_cRefs;
01242
01243   if (0 == cRefs)
01244   {
01245     // We artificially bump the main ref count to prevent reentrancy via
01246     // the main object destructor.
01247     m_cRefs++;
01248     delete this;
01249   }
01250
01251   return cRefs;
01252 }
01253
01254
01255 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01256   Method:   COEnumConnections::Next
01257
01258   Summary:  The Next member method of this IEnumConnections interface
01259             implementation. Called by outside clients of a
01260             COEnumConnections object to request a number of next
01261             connections be returned in an array supplied by the caller.
01262
01263   Args:     ULONG cReq
01264               Number of connection points requested for return (starting at
01265               the current Enumerator index).
01266             CONNECTDATA* paConnections,
01267               Pointer to a caller's output array that will receive the
01268               enumerated connection data structures.
01269             ULONG* pcEnumerated)
01270               Pointer to a ULONG variable that will contain the number of
01271               connection points actually enumerated by this call.
01272
01273   Returns:  HRESULT
01274               Standard result code. NOERROR for success.
01275 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01276 STDMETHODIMP COEnumConnections::Next(
01277                ULONG cReq,
01278                CONNECTDATA* paConnections,
01279                ULONG* pcEnumerated)
01280 {
01281   HRESULT hr = NOERROR;
01282   ULONG cRet = 0;
01283
01284   // Make sure the argument values passed are valid.
01285   if (NULL != m_paConnections)
01286   {
01287     if (NULL != paConnections)
01288     {
01289       if (m_iEnumIndex < m_cConnections)
01290       {
01291         if (NULL != pcEnumerated)
01292           *pcEnumerated = 0L;
01293         else
01294           if (1L != cReq)
01295             hr = E_POINTER;
01296       }
01297       else
01298         hr = S_FALSE;
01299     }
01300     else
01301       hr = E_POINTER;
01302   }
01303   else
01304     hr = S_FALSE;
01305
01306   if (SUCCEEDED(hr))
01307   {
01308     // Starting at the current Enumerator index, loop to assign the
01309     // requested number of output connection data structures.
01310     for (; m_iEnumIndex < m_cConnections && cReq > 0;
01311            paConnections++, m_iEnumIndex++, cRet++, cReq--)
01312     {
01313       // Because we are assigning a copy of a connection's data, AddRef
01314       // its sink interface pointer.
01315       if (NULL != m_paConnections[m_iEnumIndex].pUnk)
01316         m_paConnections[m_iEnumIndex].pUnk->AddRef();
01317
01318       // Assign a connection's data from the inside Enumerator array to
01319       // the specified output receiving array.
01320       *paConnections = m_paConnections[m_iEnumIndex];
01321     }
01322
01323     // Assign the output number of connections enumerated.
01324     if (NULL != pcEnumerated)
01325       *pcEnumerated = cRet;
01326   }
01327
01328   return hr;
01329 }
01330
01331
01332 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01333   Method:   COEnumConnections::Skip
01334
01335   Summary:  The Skip member method of this IEnumConnections interface
01336             implementation. Starting at the current Enumerator index, skip
01337             the specified number of connection items.
01338
01339   Args:     ULONG cSkip
01340               Number of Connection items to skip.
01341
01342   Returns:  HRESULT
01343               Standard result code. NOERROR for success.
01344 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01345 STDMETHODIMP COEnumConnections::Skip(
01346                ULONG cSkip)
01347 {
01348   HRESULT hr = NOERROR;
01349
01350   // If there really is a connection array and the requested
01351   // amount of skip does not exceed the number of connections,
01352   // then bump the index by the requested skip amount.
01353   if (NULL != m_paConnections && (m_iEnumIndex + cSkip) < m_cConnections)
01354     m_iEnumIndex += cSkip;
01355   else
01356     hr = S_FALSE;
01357
01358   return hr;
01359 }
01360
01361
01362 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01363   Method:   COEnumConnections::Reset
01364
01365   Summary:  The Reset member method of the IEnumConnections interface
01366             implementation. Resets the Enumeration index to the first
01367             connection item in the array.
01368
01369   Args:     void.
01370
01371   Returns:  HRESULT
01372               Standard result code. NOERROR for success.
01373 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01374 STDMETHODIMP COEnumConnections::Reset(
01375                void)
01376 {
01377   // Zero the main Enumerator index.
01378   m_iEnumIndex = 0;
01379
01380   return NOERROR;
01381 }
01382
01383
01384 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01385   Method:   COEnumConnections::Clone
01386
01387   Summary:  The Clone member method of this IEnumConnections interface
01388             implementation. Creates a new clone of this entire Connection
01389             enumerator COM object and returns a pointer to its
01390             IEnumConnections interface.
01391
01392   Args:     IEnumConnections** ppIEnum
01393               Address of the caller's output pointer variable that will
01394               receive the IEnumConnections interface pointer of the
01395               new enumerator clone.
01396
01397   Returns:  HRESULT
01398               Standard result code. NOERROR for success.
01399 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01400 STDMETHODIMP COEnumConnections::Clone(
01401                IEnumConnections** ppIEnum)
01402 {
01403   HRESULT hr;
01404   COEnumConnections* pCOEnum;
01405
01406   // NULL the output variable first.
01407   *ppIEnum = NULL;
01408
01409   // Create the Clone Enumerator COM object.
01410   pCOEnum = new COEnumConnections(m_pHostObj);
01411   if (NULL != pCOEnum)
01412   {
01413     // Initialize it with same values as in this existing enumerator.
01414     hr = pCOEnum->Init(m_cConnections, m_paConnections, m_iEnumIndex);
01415     if (SUCCEEDED(hr))
01416     {
01417       // QueryInterface to return the requested interface pointer.
01418       // An AddRef will be conveniently done by the QI.
01419       if (SUCCEEDED(hr))
01420         hr = pCOEnum->QueryInterface(
01421                         IID_IEnumConnections,
01422                         (PPVOID)ppIEnum);
01423     }
01424   }
01425   else
01426     hr = E_OUTOFMEMORY;
01427
01428   return hr;
01429 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/OpenQDlg.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

OpenQDlg.Cpp

Go to the documentation of this file.
00001 // --------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation.  All rights reserved
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // --------------------------------------------------------------------
00011 //
00012 // OpenQDlg.cpp : implementation file
00013 //
00014
00015
00016
00017
00018 #include "stdafx.h"
00019 #include "MQApitst.h"
00020 #include "OpenQDlg.h"
00021
00022 #ifdef _DEBUG
00023 #define new DEBUG_NEW
00024 #undef THIS_FILE
00025 static char THIS_FILE[] = __FILE__;
00026 #endif
00027
00028 /////////////////////////////////////////////////////////////////////////////
00029 // COpenQueueDialog dialog
00030
00031
00032 COpenQueueDialog::COpenQueueDialog(CArray <ARRAYQ*, ARRAYQ*>* pStrArray, CWnd* pParent /*=NULL*/)
00033   : CDialog(COpenQueueDialog::IDD, pParent)
00034 {
00035   m_pStrArray = pStrArray;
00036
00037   //{{AFX_DATA_INIT(COpenQueueDialog)
00038   m_szPathName = _T("");
00039   m_szFormatName = _T("");
00040   m_iAccessRight = 0;
00041   //}}AFX_DATA_INIT
00042 }
00043
00044
00045 void COpenQueueDialog::DoDataExchange(CDataExchange* pDX)
00046 {
00047   CDialog::DoDataExchange(pDX);
00048   //{{AFX_DATA_MAP(COpenQueueDialog)
00049   DDX_Control(pDX, IDC_FORMATNAME_COMBO2, m_FormatNameCB);
00050   DDX_Control(pDX, IDC_PATHNAME_COMBO, m_PathNameCB);
00051   DDX_CBString(pDX, IDC_PATHNAME_COMBO, m_szPathName);
00052   DDV_MaxChars(pDX, m_szPathName, 128);
00053   DDX_CBString(pDX, IDC_FORMATNAME_COMBO2, m_szFormatName);
00054   DDV_MaxChars(pDX, m_szFormatName, 4000);
00055   DDX_Radio(pDX, IDC_RADIO1, m_iAccessRight);
00056   //}}AFX_DATA_MAP
00057 }
00058
00059
00060 BEGIN_MESSAGE_MAP(COpenQueueDialog, CDialog)
00061   //{{AFX_MSG_MAP(COpenQueueDialog)
00062   ON_CBN_SELCHANGE(IDC_FORMATNAME_COMBO2, OnSelchangeFormatnameCombo2)
00063   ON_CBN_SELCHANGE(IDC_PATHNAME_COMBO, OnSelchangePathnameCombo)
00064   ON_CBN_EDITUPDATE(IDC_FORMATNAME_COMBO2, OnEditupdateFormatnameCombo2)
00065   ON_CBN_EDITUPDATE(IDC_PATHNAME_COMBO, OnEditupdatePathnameCombo)
00066   //}}AFX_MSG_MAP
00067 END_MESSAGE_MAP()
00068
00069 /////////////////////////////////////////////////////////////////////////////
00070 // COpenQueueDialog message handlers
00071
00072 BOOL COpenQueueDialog::OnInitDialog()
00073 {
00074   CDialog::OnInitDialog();
00075
00076   // TODO: Add extra initialization here
00077
00078   int i;
00079   for  (i=0 ; i<m_pStrArray->GetSize() ; i++)
00080   {
00081     VERIFY (m_PathNameCB.AddString((*m_pStrArray)[i]->szPathName) != CB_ERR);
00082     VERIFY (m_FormatNameCB.AddString((*m_pStrArray)[i]->szFormatName) != CB_ERR);
00083
00084   }
00085
00086     if (m_PathNameCB.GetCount() > 0) m_PathNameCB.SetCurSel(0);
00087     if (m_FormatNameCB.GetCount() > 0) m_FormatNameCB.SetCurSel(0);
00088
00089     return TRUE;  // return TRUE unless you set the focus to a control
00090                 // EXCEPTION: OCX Property Pages should return FALSE
00091 }
00092
00093
00094 void COpenQueueDialog::GetFormatName(TCHAR szFormatName[])
00095 {
00096   ASSERT(szFormatName != NULL);
00097
00098   _tcsncpy (szFormatName, m_szFormatName, MAX_Q_FORMATNAME_LEN-1);
00099   szFormatName[MAX_Q_FORMATNAME_LEN-1] = '\0';
00100 }
00101
00102
00103 void COpenQueueDialog::OnSelchangePathnameCombo()
00104 {
00105   m_FormatNameCB.SetCurSel(m_PathNameCB.GetCurSel());
00106 }
00107
00108 void COpenQueueDialog::OnSelchangeFormatnameCombo2()
00109 {
00110   m_PathNameCB.SetCurSel(m_FormatNameCB.GetCurSel());
00111 }
00112
00113
00114 void COpenQueueDialog::OnEditupdateFormatnameCombo2()
00115 {
00116   m_PathNameCB.SetCurSel(OPENQDLG_CLEAR_COMBOBOX);
00117 }
00118
00119
00120
00121 void COpenQueueDialog::OnEditupdatePathnameCombo()
00122 {
00123   m_FormatNameCB.SetCurSel(OPENQDLG_CLEAR_COMBOBOX);
00124 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CResTypeData Member List

This is the complete list of members for CResTypeData, including all inherited members.
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItem(IWCContextMenuCallback *piCallbackIn, UINT nMenuItem, UINT nMenuItemDesc, UINT nBaseID, ULONG uFlags) | CObjData | [protected, virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CResTypeData | [virtual]
AddContextMenuItems(IWCContextMenuCallback *piCallbackIn) | CResTypeData | [virtual]
CObjData(void) | CObjData | [inline]
CObjData(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
Cot(void) | CObjData | [inline]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CObjData | [inline, virtual]
GetPropertySheetPages(CRuntimeClass ***ppaPropSheetsOut) | CObjData | [inline, virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CObjData | [inline, virtual]
GetWizardPages(CRuntimeClass ***ppaWizardPagesOut) | CObjData | [inline, virtual]
HrInitialize(IUnknown *piDataIn) | CResTypeData | [protected, virtual]
HrInitialize(IUnknown *piDataIn) | CResTypeData | [protected, virtual]
InvokeCommand(ULONG nCommandIDIn) | CResTypeData | [virtual]
InvokeCommand(ULONG nCommandIDIn) | CResTypeData | [virtual]
m_cot | CObjData | [protected]
m_fSupportedType | CResTypeData | [private]
m_rgprtcPSPages | CObjData | [protected]
m_rgprtcWizPages | CObjData | [protected]
m_strName | CObjData | [protected]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
S_HrCreateObject(IUnknown *piDataIn, CObjData **ppodOut) | CObjData | [static]
StrName(void) | CObjData | [inline, virtual]
StrName(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
~CObjData(void) | CObjData | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::ResyncEnum Member List

This is the complete list of members for msado15::ResyncEnum, including all inherited members.
adResyncAllValues | msado15::ResyncEnum | [static]
adResyncUnderlyingValues | msado15::ResyncEnum | [static]
Generated on Wed Nov 13 2024 16:58:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/General/ADsError/ADsError.cpp Source File

  • NetDS
  • ADSI
  • samples
  • General
  • ADsError

ADsError.cpp

Go to the documentation of this file.
00001 // ADsError.cpp : Implementation of DLL Exports.
00002
00003
00004 // Note: Proxy/Stub Information
00005 //      To build a separate proxy/stub DLL,
00006 //      run nmake -f ADsErrorps.mk in the project directory.
00007
00008 #include "stdafx.h"
00009 #include "resource.h"
00010 #include <initguid.h>
00011 #include "ADsError.h"
00012
00013 #include "ADsError_i.c"
00014 #include "IADsError.h"
00015
00016
00017 CComModule _Module;
00018
00019 BEGIN_OBJECT_MAP(ObjectMap)
00020 OBJECT_ENTRY(CLSID_ADsError, ADsError)
00021 END_OBJECT_MAP()
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // DLL Entry Point
00025
00026 extern "C"
00027 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
00028 {
00029     if (dwReason == DLL_PROCESS_ATTACH)
00030     {
00031         _Module.Init(ObjectMap, hInstance, &LIBID_ADSERRORLib);
00032         DisableThreadLibraryCalls(hInstance);
00033     }
00034     else if (dwReason == DLL_PROCESS_DETACH)
00035         _Module.Term();
00036     return TRUE;    // ok
00037 }
00038
00039 /////////////////////////////////////////////////////////////////////////////
00040 // Used to determine whether the DLL can be unloaded by OLE
00041
00042 STDAPI DllCanUnloadNow(void)
00043 {
00044     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
00045 }
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048 // Returns a class factory to create an object of the requested type
00049
00050 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00051 {
00052     return _Module.GetClassObject(rclsid, riid, ppv);
00053 }
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // DllRegisterServer - Adds entries to the system registry
00057
00058 STDAPI DllRegisterServer(void)
00059 {
00060     // registers object, typelib and all interfaces in typelib
00061     return _Module.RegisterServer(TRUE);
00062 }
00063
00064 /////////////////////////////////////////////////////////////////////////////
00065 // DllUnregisterServer - Removes entries from the system registry
00066
00067 STDAPI DllUnregisterServer(void)
00068 {
00069     return _Module.UnregisterServer(TRUE);
00070 }
00071
00072
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/precomp.cpp Source File

  • WinUI
  • TSFmark

precomp.cpp

Go to the documentation of this file.
00001 //
00002 // precomp.cpp
00003 //
00004 // Stub for vc precompiled header.
00005 //
00006
00007 #include "globals.h"
Generated on Wed Nov 13 2024 16:52:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_BEZBUFFER Member List

This is the complete list of members for _BEZBUFFER, including all inherited members.
pPts _BEZBUFFER
Generated on Wed Nov 13 2024 16:55:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/View.Cxx Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

View.Cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // File: View.Cxx
00003 //
00004 // Classes:
00005 //      CClientCanvas - Device context for client area
00006 //      CPrintCanvas  - Device context for printing
00007 //
00008 //      CView          - Base class for Views
00009 //      CScrollaleView - Scrollable View
00010 //      CFullPageView  - NonScrollable FullPage View
00011 //
00012 // History: 22-Jan-1993 Asmusf  Created
00013 //
00014 // Copyright 1993 - 2000 Microsoft Corp. All Rights reserved
00015 //
00016 //--------------------------------------------------------------------
00017 #include <windows.h>
00018 #include <windowsx.h>
00019 #include <commdlg.h>
00020 #include "app.h"
00021 #include "view.hxx"
00022 #include "grid.hxx"
00023
00024 //+--------------------------------------------------------
00025 // Class:       CView
00026 //
00027 // Purpose:     Standard fixed View for printing, or base class
00028 //
00029 // History:     22-Jan-1993     asmusf  created
00030 //----------------------------------------------------------
00031 CView::CView(int cx, int cy)
00032 {
00033         _iScale = 100;        // percentage magnification
00034         _ptOrg.x = 0;         // 0..(PAGEWIDTH - widht of window)
00035         _ptOrg.y = 0;         // 0..(PAGEHEIGHT - height of window)
00036         _ptScroll.x = 0;      // 0..PAGEWIDTH
00037         _ptScroll.y = 0;      // 0..PAGEHEIGHT
00038         _size.cx = cx;        // width of window (dev. coord)
00039         _size.cy = cy;        // widht of window (dev. coord)
00040 }
00041
00042 void CView::SetSize( int cx, int cy)
00043 {
00044         _size.cx = cx;
00045         _size.cy = cy;
00046 }
00047
00048 void CView::Invalidate(HWND hwnd, LPRECT lpRect)
00049 {
00050         InvalidateRect(hwnd, lpRect, TRUE);
00051 }
00052
00053 BOOL CView::Paint(CCanvas& canvas, CModel * _pModel, RECT rc)
00054 {
00055
00056         // Scale using MapMode = logical TWIPS
00057         canvas.Scale(_iScale);
00058
00059         // Client rect in logical coordinates
00060         _ptClient.x=_size.cx;
00061         _ptClient.y=_size.cy;
00062         canvas.DPtoLP(&_ptClient);
00063
00064         // Adjust GDIwindow origin, set _ptOrg
00065         Scroll(canvas);
00066
00067         // ClipRectangle in logical coordinates
00068         POINT pt;
00069         pt.x = rc.left; pt.y = rc.top;
00070         canvas.DPtoLP(&pt);
00071         rc.left = pt.x; rc.top = pt.y;
00072
00073         pt.x = rc.right; pt.y = rc.bottom;
00074         canvas.DPtoLP(&pt);
00075         rc.right = pt.x; rc.bottom = pt.y;
00076
00077
00078         // Paint
00079         _pModel->Paint(canvas, rc);
00080
00081         return TRUE;  // screen Paints don't fail
00082 }
00083
00084 UINT CView::Hittest(CCanvas& canvas, POINT ptTest, CModel * _pModel)
00085 {
00086
00087         // Scale using MapMode = logical TWIPS
00088         canvas.Scale(_iScale);
00089
00090         // Client rect in logical coordinates
00091         _ptClient.x=_size.cx;
00092         _ptClient.y=_size.cy;
00093         canvas.DPtoLP(&_ptClient);
00094
00095         // Adjust GDIwindow origin, set _ptOrg
00096         Scroll(canvas);
00097
00098         // Hittest
00099
00100         canvas.DPtoLP(&ptTest);
00101         return _pModel->Hittest( ptTest);
00102 }
00103
00104 void CView::Scroll(CCanvas &canvas)
00105 {
00106         int dx=MulDiv(_ptClient.x,_ptScroll.x,PAGEWIDTH);
00107         int dy=MulDiv(_ptClient.y,_ptScroll.y,PAGEHEIGHT);
00108
00109         // Adjust GDIwindow origin, set _ptOrg
00110         _ptOrg.x = _ptScroll.x-dx;
00111         _ptOrg.y = _ptScroll.y-dy;
00112
00113         canvas.Scroll(_ptOrg.x, _ptOrg.y);
00114 }
00115
00116 //+--------------------------------------------------------
00117 // Class:       CScrollableView
00118 //
00119 // Purpose:     View for scrollable window
00120 //
00121 // History:     22-Jan-1993     asmusf  created
00122 //----------------------------------------------------------
00123 void CScrollableView::SetHScrollPos(HWND hwnd, WPARAM wParam, LPARAM lParam, CModel * pModel)
00124 {
00125     CScreenCanvas canvas(hwnd);
00126     int nScrollPos = GetScrollPos( hwnd, SB_HORZ );
00127     canvas.Scale(_iScale);
00128
00129
00130     SIZE size;
00131     pModel->GetLineSize(&size);
00132
00133     // scroll position relative to page dimension
00134     switch (wParam)
00135     {
00136     case SB_LINEUP:
00137          nScrollPos -= 2 * size.cx;
00138          break;
00139     case SB_LINEDOWN:
00140          nScrollPos += 2 * size.cx;
00141          break;
00142
00143     case SB_PAGEUP:
00144          nScrollPos -= _ptClient.x; // size of Window in log coord
00145          break;
00146
00147     case SB_PAGEDOWN:
00148          nScrollPos += _ptClient.x;
00149          break;
00150
00151     case SB_THUMBPOSITION:
00152          nScrollPos = LOWORD(lParam);
00153          break;
00154
00155     default:
00156          break;
00157     }
00158
00159     nScrollPos = max( 0, min (nScrollPos, PAGEWIDTH));
00160
00161     POINT pt;
00162     pt.x =  GetScrollPos( hwnd, SB_HORZ ) - nScrollPos;
00163     if( pt.x )
00164     {
00165         SetScrollPos(hwnd, SB_HORZ, nScrollPos, TRUE );
00166
00167         pt.y = 0;
00168         canvas.LPtoDP(&pt);
00169
00170         pt.x -= MulDiv( _ptClient.x, pt.x, PAGEWIDTH);
00171         ScrollWindow(hwnd, pt.x, pt.y, NULL, NULL );
00172     }
00173     _ptScroll.x = nScrollPos;
00174 }
00175
00176 void CScrollableView::SetVScrollPos(HWND hwnd, WPARAM wParam, LPARAM lParam, CModel * pModel)
00177 {
00178     CScreenCanvas canvas(hwnd);
00179     int nScrollPos = GetScrollPos( hwnd, SB_VERT );
00180     canvas.Scale(_iScale);
00181
00182     SIZE size;
00183     pModel->GetLineSize(&size);
00184
00185     // scroll position relative to page dimension
00186     switch (wParam)
00187     {
00188     case SB_LINEUP:
00189          nScrollPos -= 2 * size.cy;
00190          break;
00191     case SB_LINEDOWN:
00192          nScrollPos += 2 * size.cy;
00193          break;
00194
00195     case SB_PAGEUP:
00196          nScrollPos -= _ptClient.y; // size of Window in log coord
00197          break;
00198
00199     case SB_PAGEDOWN:
00200          nScrollPos += _ptClient.y;
00201          break;
00202
00203     case SB_THUMBPOSITION:
00204          nScrollPos = LOWORD(lParam);
00205          break;
00206
00207     default:
00208          break;
00209     }
00210
00211     nScrollPos = max( 0, min (nScrollPos, PAGEHEIGHT));
00212
00213     POINT pt;
00214     pt.y =  GetScrollPos( hwnd, SB_VERT ) - nScrollPos;
00215     if( pt.y )
00216     {
00217         SetScrollPos(hwnd, SB_VERT, nScrollPos, TRUE );
00218
00219         pt.x = 0;
00220         canvas.LPtoDP(&pt);
00221
00222         pt.y -= MulDiv( _ptClient.y, pt.y, PAGEHEIGHT);
00223         ScrollWindow(hwnd, pt.x, pt.y, NULL, NULL );
00224     }
00225     _ptScroll.y = nScrollPos;
00226 }
00227
00228 //+--------------------------------------------------------
00229 // Class:       CPrintCanvas
00230 //
00231 // Purpose:     Device Context for Printing
00232 //
00233 // History:     22-Jan-1993     asmusf  created
00234 //----------------------------------------------------------
00235
00236 // fully inline //
00237
00238 //+--------------------------------------------------------
00239 // Class:       CPrintRequest
00240 //
00241 // Purpose:     Print Job selection and parameters
00242 //
00243 // History:     22-Jan-1993     asmusf  created
00244 //----------------------------------------------------------
00245 CPrintAux PrGlobal;     // global flags for printing control
00246
00247 CPrintRequest::CPrintRequest(HWND hwnd, UINT nMinPage, UINT nMaxPage ) :
00248         _hwnd(hwnd),
00249         _hdc(0),
00250         _hDevNames(0)
00251 {
00252     PRINTDLG pd;
00253
00254     pd.lStructSize= sizeof(PRINTDLG);
00255     pd.hwndOwner=NULL;
00256     pd.hDevMode=NULL;
00257     pd.hDevNames=NULL;
00258     pd.hDC;
00259     pd.nFromPage = 0xFFFF; // cause initial blank field
00260     pd.nToPage   = 0xFFFF; // in dialog
00261     pd.nMinPage= (WORD)nMinPage;
00262     pd.nMaxPage= (WORD)nMaxPage;
00263     pd.nCopies=1;
00264     pd.hInstance=NULL;
00265     pd.lCustData=0L;
00266     pd.lpfnPrintHook=NULL;
00267     pd.lpfnSetupHook=NULL;
00268     pd.lpPrintTemplateName=NULL;
00269     pd.lpSetupTemplateName=NULL;
00270     pd.hPrintTemplate=NULL;
00271     pd.hSetupTemplate=NULL;
00272
00273     pd.Flags = PD_RETURNDEFAULT;
00274
00275     if( PrintDlg(&pd) )
00276     {
00277         pd.Flags = PD_SELECTION | PD_HIDEPRINTTOFILE | PD_RETURNDC;
00278         if( PrintDlg( &pd ) )
00279         {
00280              if(pd.Flags & PD_PAGENUMS)
00281              {
00282                  _nFromPage = pd.nFromPage;
00283                  _nToPage = pd.nToPage;
00284              }
00285              else if (pd.Flags & PD_SELECTION )
00286              {
00287                  _nFromPage = _nToPage = 0xFFFF;
00288              }
00289              else   // all non empty pages
00290              {
00291                  _nFromPage = nMinPage;
00292                  _nToPage = nMaxPage;
00293              }
00294              _hdc = pd.hDC;
00295              _hDevNames = pd.hDevNames;
00296
00297              if( pd.hDevMode )
00298              {
00299                 GlobalFree (pd.hDevMode);
00300              }
00301              _status = PREQ_SUCCESS;
00302              return;
00303         }
00304         else
00305         {
00306             _status = PREQ_ERROR;
00307             return;
00308         }
00309     }
00310
00311     _status = PREQ_CANCEL;
00312 }
00313
00314 CPrintRequest:: ~CPrintRequest()
00315 {
00316     if( _hDevNames )
00317     {
00318         GlobalFree( _hDevNames );
00319     }
00320
00321     if( _hdc )
00322     {
00323         DeleteDC(_hdc );
00324     }
00325 }
00326
00327 UINT CPrintRequest::Print(HINSTANCE hInst, CCanvas &canvas, CModel *pModel)
00328 {
00329
00330      // needs to become app & font name....
00331      static TCHAR szMessage [] = TEXT("Grid: Printing") ;
00332
00333      TCHAR szCaption[30];
00334
00335      BOOL       fError = PREQ_SUCCESS ;
00336      ABORTPROC  lpfnAbortProc;
00337      DLGPROC    lpfnPrintDlgProc ;
00338      short      cxPage, cyPage ;
00339
00340      cxPage = (short)GetDeviceCaps (canvas, HORZRES) ;
00341      cyPage = (short)GetDeviceCaps (canvas, VERTRES) ;
00342
00343      // disable user input to main window
00344      EnableWindow (_hwnd, FALSE) ;
00345
00346      lpfnPrintDlgProc = (DLGPROC) MakeProcInstance ((FARPROC) PrintDlgProc, hInst) ;
00347
00348      LoadString(hInst, IDS_MSGCAPTION, szCaption, 30);
00349      PrGlobal._bUserAbort = FALSE ;
00350      PrGlobal._hDlgPrint =
00351                 CreateDialogParam (hInst, TEXT("PrintDlgBox"), _hwnd,
00352                                 lpfnPrintDlgProc, (LPARAM) szCaption) ;
00353
00354      lpfnAbortProc = (ABORTPROC) MakeProcInstance ((FARPROC) AbortProc, hInst) ;
00355
00356      SetAbortProc(canvas, lpfnAbortProc);
00357
00358      DOCINFO docinfo;
00359      docinfo.cbSize = sizeof(DOCINFO);
00360      docinfo.lpszDocName = szMessage;
00361      docinfo.lpszOutput = NULL;
00362
00363      if (Escape (canvas, STARTDOC, sizeof szMessage - 1, (LPCSTR)szMessage, NULL) > 0)
00364      //if (StartDoc(canvas, &docinfo) > 0)
00365      {
00366           UINT fuFormat;
00367           pModel->GetFormat(fuFormat);
00368           pModel->SetFormat(fuFormat | PAGEPRINT|PAGEELEMS);
00369           UINT iSavePage = pModel->GetPage();
00370
00371
00372           // create printer view to
00373           CView  View(cxPage, cyPage);
00374
00375
00376           if( _nToPage == 0xFFFF || _nFromPage == 0xFFFF )
00377           {
00378                 _nToPage =   pModel->GetPage()+1;
00379                 _nFromPage = pModel->GetPage()+1;
00380           }
00381
00382           for( ; _nFromPage <= _nToPage && ! fError; _nFromPage++ )
00383           {
00384              if (pModel->IsModelPageUsed(_nFromPage-1))
00385              {
00386                 if( StartPage(canvas) < 0 )
00387                     {
00388                         fError = PREQ_ERRSTARTPAGE ;
00389                         break;
00390                     }
00391                 pModel->SetPage(_nFromPage-1);  // <- pages are 0 based in Model
00392                 RECT rc;
00393                 rc.left = rc.top = 0;
00394                 rc.right= cxPage;
00395                 rc.bottom = cyPage;
00396                 View.Paint (canvas, pModel, rc) ;
00397
00398                 if ( EndPage(canvas) < 0)
00399                     {
00400                         fError = PREQ_ERRENDPAGE ;
00401                     }
00402         }
00403           }
00404           if( !fError )
00405           {
00406                EndDoc(canvas);
00407           }
00408           // restore screen format
00409           pModel->SetPage(iSavePage);
00410           pModel->SetFormat(fuFormat);
00411      }
00412      else
00413      {
00414           fError = PREQ_ERRSTARTDOC ;
00415      }
00416
00417      if (!PrGlobal._bUserAbort)
00418      {
00419           EnableWindow (_hwnd, TRUE) ;
00420           DestroyWindow (PrGlobal._hDlgPrint) ;
00421      }
00422
00423      FreeProcInstance ((FARPROC)lpfnPrintDlgProc) ;
00424      FreeProcInstance ((FARPROC)lpfnAbortProc) ;
00425
00426      if( PrGlobal._bUserAbort )
00427      {
00428         fError |= PREQ_USERABORT;
00429      }
00430
00431      return fError ;
00432 }
00433
00434
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/LSP/install.h Source File

  • NetDS
  • WinSock
  • LSP

install.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module Name: provider.h
00009 //
00010 // Description:
00011 //
00012 //    This sample illustrates how to develop a layered service provider that is
00013 //    capable of counting all bytes transmitted through a TCP/IP socket.
00014 //
00015 //    This file contains all datatypes and function prototypes used
00016 //    throughout this project.
00017 //
00018 #ifndef _INSTALL_H_
00019 #define _INSTALL_H_
00020
00021 #include <ws2spi.h>
00022
00023 //
00024 // GUID corresponding to our provider
00025 //
00026 extern GUID           ProviderGuid;
00027
00028 //
00029 // Our LSP DLL name
00030 //
00031 extern WCHAR         *ProviderPath;
00032
00033 //
00034 // For 64-bit systems, we need to know which catalog to operate on
00035 //
00036 typedef enum
00037 {
00038     LspCatalogBoth = 0,
00039     LspCatalog32Only,
00040     LspCatalog64Only
00041 } WINSOCK_CATALOG;
00042
00043 //
00044 // Provider.cpp prototypes
00045 //
00046 LPWSAPROTOCOL_INFOW EnumerateProviders(WINSOCK_CATALOG Catalog, LPINT TotalProtocols);
00047 void                FreeProviders(LPWSAPROTOCOL_INFOW ProtocolInfo);
00048 void                PrintProtocolInfo(WSAPROTOCOL_INFOW *ProtocolInfo);
00049
00050 #endif
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/help/compdata.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • help

compdata.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #ifndef _CLASS_CCOMPONENTDATA_
00016 #define _CLASS_CCOMPONENTDATA_
00017
00018
00019 #include "Globals.h"
00020 #include "BaseNode.h"
00021
00022 class  CStaticNode;           // References
00023
00024 //---------------------------------------------------------------------------
00025 class CComponentData : public IComponentData2,
00026                               IExtendContextMenu,
00027                               ISnapinHelp2
00028 {
00029   private:
00030     ULONG                m_cRef;
00031     LPCONSOLE3           m_ipConsole;
00032     LPCONSOLENAMESPACE2  m_ipConsoleNameSpace2;
00033     LPIMAGELIST          m_ipScopeImage;     // Caching the image list
00034     CStaticNode*         m_pStaticNode;
00035     HSCOPEITEM           m_hStaticNode;
00036     HBITMAP              m_hImageStrip16;
00037     HBITMAP              m_hImageStrip32;
00038     LPOLESTR             m_pszwHelpPath;     //MMC_HELP: Cached help path
00039
00040   public:
00041     CComponentData();
00042     ~CComponentData();
00043
00044   ///////////////////////////////////////////////////////////////////////////
00045   // Interface IUnknown
00046   public:
00047     STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppv );
00048     STDMETHODIMP_(ULONG) AddRef();
00049     STDMETHODIMP_(ULONG) Release();
00050
00051   ///////////////////////////////////////////////////////////////////////////
00052   // Interface IComponentData2
00053   public:
00054     HRESULT STDMETHODCALLTYPE Initialize
00055             ( /*[in]*/ LPUNKNOWN pUnknown );
00056
00057     HRESULT STDMETHODCALLTYPE CreateComponent
00058             ( /*[out]*/ LPCOMPONENT __RPC_FAR* ppComponent);
00059
00060     HRESULT STDMETHODCALLTYPE Notify
00061             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00062               /*[in]*/ MMC_NOTIFY_TYPE MmcEvent,
00063               /*[in]*/ LPARAM nArg,
00064               /*[in]*/ LPARAM nParam
00065             );
00066
00067     HRESULT STDMETHODCALLTYPE Destroy( void);
00068
00069     HRESULT STDMETHODCALLTYPE QueryDataObject
00070             ( /*[in]*/  MMC_COOKIE uCookie,
00071               /*[in]*/  DATA_OBJECT_TYPES nEnumType,
00072               /*[out]*/ LPDATAOBJECT __RPC_FAR* ppDataObject
00073             );
00074
00075     HRESULT STDMETHODCALLTYPE GetDisplayInfo
00076             ( /*[out][in]*/ SCOPEDATAITEM __RPC_FAR* pScopeDataItem );
00077
00078     HRESULT STDMETHODCALLTYPE CompareObjects
00079             ( /*[in]*/ LPDATAOBJECT ipDataObjectA,
00080               /*[in]*/ LPDATAOBJECT ipDataObjectB
00081             );
00082
00083     HRESULT STDMETHODCALLTYPE QueryDispatch
00084             ( /*[in] */  MMC_COOKIE  nCookie,
00085               /*[in] */  DATA_OBJECT_TYPES eType,
00086               /*[out]*/  LPDISPATCH* pipDispatch
00087             );
00088
00089   ///////////////////////////////////////////////////////////////////////////
00090   // Interface IExtendContextMenu
00091   public:
00092     HRESULT STDMETHODCALLTYPE AddMenuItems
00093             ( /*[in]*/ LPDATAOBJECT ipDataObject,
00094               /*[in]*/ LPCONTEXTMENUCALLBACK ipCallback,
00095               /*[out,in]*/ long __RPC_FAR* pInsertionAllowed
00096             );
00097
00098     HRESULT STDMETHODCALLTYPE Command
00099             ( /*[in]*/ long lCommandID,
00100               /*[in]*/ LPDATAOBJECT piDataObject
00101             );
00102
00103   ///////////////////////////////////////////////////////////////////////////
00104   // Interface ISnapinHelp
00105   public:
00106     HRESULT STDMETHODCALLTYPE GetHelpTopic( /*[in]*/ LPOLESTR* lpHelpFilePath );
00107     HRESULT STDMETHODCALLTYPE GetLinkedTopics( /*[in]*/ LPOLESTR* lpHelpFilePath )
00108                               { return E_NOTIMPL; }
00109
00110   // Pulic helper methods
00111   public:
00112     CStaticNode* GetStaticNode() { return m_pStaticNode;  }
00113     LPOLESTR     GetHelpPath();
00114     HRESULT      GetInterface( DWORD dwRequestedInterface,  LONG_PTR* ppInterface );
00115
00116 };
00117
00118 #endif //_CLASS_CCOMPONENTDATA_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/PoolTest/StdAfx.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • PoolTest

StdAfx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #ifdef _ATL_STATIC_REGISTRY
00008 #include <statreg.h>
00009 #include <statreg.cpp>
00010 #endif
00011
00012 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPack Member List

This is the complete list of members for CPack, including all inherited members.
BuildRemoteUrl(IN LPCWSTR wszUploadDir, IN LPCWSTR wszTempFile, OUT WCHAR *wszRemoteUrl, DWORD cbRemoteUrl) | CPack | [private]
CloseTempFile() | CPack | [private]
CPack() | CPack |
GetFileName() | CPack |
m_hFile | CPack | [private]
m_pwszFilename | CPack | [private]
m_wszTempFile | CPack | [private]
OpenTempFile() | CPack | [private]
PackText(LPCWSTR wszText) | CPack |
Upload(LPCWSTR wszJobName, LPCWSTR wszRemoteFile, BOOL fRequireUploadReply) | CPack |
WriteWCharAsUTF8(LPCWSTR wszText, DWORD cCharsToWrite) | CPack | [private]
WriteWCharAsUTF8(LPCWSTR wszText) | CPack | [private]
WriteXMLString(LPCWSTR wszText) | CPack | [private]
~CPack() | CPack |
Generated on Wed Nov 13 2024 16:57:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/registry.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

registry.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014 #ifndef __Registry_H__
00015 #define __Registry_H__
00016
00017 #include <tchar.h>
00018
00019 // This function will register a component in the Registry.
00020 // The component calls this function from its DllRegisterServer function.
00021 HRESULT RegisterServer( HMODULE hModule,
00022                         const CLSID& clsid,
00023                         const TCHAR* szFriendlyName) ;
00024
00025 // This function will unregister a component.  Components
00026 // call this function from their DllUnregisterServer function.
00027 HRESULT UnregisterServer( const CLSID& clsid ) ;
00028
00029
00030 // This function will register a Snap-In component.  Components
00031 // call this function from their DllRegisterServer function.
00032 HRESULT RegisterSnapin( const CLSID& clsid,            // Class ID
00033                         const TCHAR* szNameString,     // NameString
00034                         const CLSID& clsidAbout,       // Class Id for About Class
00035                         const BOOL fSupportExtensions = FALSE
00036                       );
00037
00038 HRESULT UnregisterSnapin( const CLSID& clsid );        // Class ID
00039
00040 #endif //__Registry_H__
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CQueryDlg Member List

This is the complete list of members for CQueryDlg, including all inherited members.
BytesReturned | CQueryDlg |
CQueryDlg(CWnd *pParent=NULL) | CQueryDlg |
DoDataExchange(CDataExchange *pDX) | CQueryDlg | [protected, virtual]
IDD enum value | CQueryDlg |
m_displayInfo | CQueryDlg |
m_querySession | CQueryDlg |
m_serverName | CQueryDlg |
m_sessionInfo | CQueryDlg |
OnCancel() | CQueryDlg | [protected, virtual]
OnDblclkQuerySession() | CQueryDlg | [protected]
OnInitDialog() | CQueryDlg | [protected, virtual]
OnQuery() | CQueryDlg | [protected]
pSessionInfo | CQueryDlg |
serverHandle | CQueryDlg | [private]
serverName | CQueryDlg | [private]
Generated on Wed Nov 13 2024 16:57:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/rtc/Client/CPP/RTCIncoming/Resource.h Source File

  • NetDS
  • rtc
  • Client
  • CPP
  • RTCIncoming

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by RTCIncoming.rc
00004 //
00005 #define IDM_ABOUTBOX                    0x0010
00006 #define IDD_ABOUTBOX                    100
00007 #define IDS_ABOUTBOX                    101
00008 #define IDD_RTCINCOMING_DIALOG          102
00009 #define IDR_MAINFRAME                   128
00010 #define IDC_CHECKAUTO                   1000
00011 #define IDC_ANSWER                      1002
00012 #define IDC_DISCONNECT                  1003
00013 #define IDC_LOCAL                       1005
00014 #define IDC_EXIT                        1006
00015 #define IDC_STATUS                      1007
00016 #define IDC_VRECV                       1009
00017 #define IDC_VSEND                       1010
00018
00019 // Next default values for new objects
00020 //
00021 #ifdef APSTUDIO_INVOKED
00022 #ifndef APSTUDIO_READONLY_SYMBOLS
00023 #define _APS_NEXT_RESOURCE_VALUE        129
00024 #define _APS_NEXT_COMMAND_VALUE         32771
00025 #define _APS_NEXT_CONTROL_VALUE         1012
00026 #define _APS_NEXT_SYMED_VALUE           101
00027 #endif
00028 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/comp.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

comp.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "Comp.h"
00017 #include "CompData.h"
00018 #include "DataObj.h"
00019 #include "Resource.h"
00020 #include "StaticNode.h"
00021
00022 #include "VirtualFile.h"
00023
00024                              // Tracing stuff
00025 #include "TraceMacro.h"
00026 #undef  MODULESTRING
00027 #define MODULESTRING  _T("CComponent")
00028
00029
00030 //---------------------------------------------------------------------------
00031 //  Our default constuctor provides a pointer to the parent CComponentData
00032 //  class which we cache for use in later samples.
00033 //
00034 CComponent::CComponent
00035 (
00036   CComponentData*  pParent   //[in] Points to parent object
00037 )
00038 {
00039   _ASSERT( NULL != pParent );
00040
00041   m_cRef           = 0;
00042   m_ipConsole      = NULL;
00043   m_ipConsoleVerb  = NULL;
00044   m_ipResultData   = NULL;
00045   m_ipHeaderCtrl   = NULL;
00046   m_pComponentData = pParent;
00047   m_pScopeCookie   = NULL;
00048
00049 }
00050
00051 //---------------------------------------------------------------------------
00052 CComponent::~CComponent()
00053 {
00054 }
00055
00056 /////////////////////////////////////////////////////////////////////////////
00057 //  Implementation of IUnknown
00058
00059 //---------------------------------------------------------------------------
00060 STDMETHODIMP CComponent::QueryInterface
00061 (
00062   REFIID   riid,       //[in]  Identifier of the requested interface
00063   LPVOID   *ppv        //[out] Address of requested interface
00064 )
00065 {
00066   if( !ppv )
00067     return E_FAIL;
00068
00069   *ppv = NULL;
00070
00071   if( IsEqualIID(riid, IID_IUnknown) )
00072     *ppv = static_cast<IComponent*>(this);
00073   else if( IsEqualIID(riid, IID_IComponent) )
00074     *ppv = static_cast<IComponent*>(this);
00075   else if( IsEqualIID(riid, IID_IComponent2) )
00076     *ppv = static_cast<IComponent2*>(this);
00077   else if( IsEqualIID(riid, IID_INodeProperties) )
00078     *ppv = static_cast<INodeProperties*>(this);
00079
00080   if( *ppv )
00081   {
00082     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00083     return S_OK;
00084   }
00085
00086   return E_NOINTERFACE;
00087 }
00088
00089 //---------------------------------------------------------------------------
00090 STDMETHODIMP_(ULONG) CComponent::AddRef()
00091 {
00092   return InterlockedIncrement((LONG*)&m_cRef);
00093 }
00094
00095 //---------------------------------------------------------------------------
00096 STDMETHODIMP_(ULONG) CComponent::Release()
00097 {
00098   if( InterlockedDecrement((LONG*)&m_cRef) == 0 )
00099   {
00100     delete this;
00101     return 0;
00102   }
00103   return m_cRef;
00104 }
00105
00106 /////////////////////////////////////////////////////////////////////////////
00107 // Implementation of IComponent
00108
00109 //---------------------------------------------------------------------------
00110 STDMETHODIMP CComponent::Initialize
00111 (
00112   LPCONSOLE ipConsole    //[in] Points to the console's IUnknown
00113 )
00114 {
00115   HRESULT hResult = S_FALSE;
00116
00117   do
00118   {
00119     hResult = ipConsole->QueryInterface( IID_IConsole3,(VOID**)&m_ipConsole );
00120     BREAK_ON_ERROR( hResult );
00121
00122     hResult = m_ipConsole->QueryConsoleVerb( &m_ipConsoleVerb );
00123     BREAK_ON_ERROR( hResult );
00124
00125     hResult = m_ipConsole->QueryInterface( IID_IResultData,(VOID**)&m_ipResultData );
00126     BREAK_ON_ERROR( hResult );
00127
00128     hResult = m_ipConsole->QueryInterface( IID_IHeaderCtrl2,(VOID**)&m_ipHeaderCtrl );
00129     BREAK_ON_ERROR( hResult );
00130
00131   }while( 0 );
00132
00133   TRACE_HRESULT(_T("Initialize"), hResult );
00134   return hResult;
00135 }
00136
00137
00138 //---------------------------------------------------------------------------
00139 STDMETHODIMP CComponent::Notify
00140 (
00141   LPDATAOBJECT     ipDataObject,   //[in] Points to the selected data object
00142   MMC_NOTIFY_TYPE  MmcEvent,       //[in] Identifies action taken by user
00143   LPARAM           nArg,           //[in] Depends on the notification type
00144   LPARAM           nParam          //[in] Depends on the notification type
00145 )
00146 {
00147   HRESULT hResult = S_FALSE;       // Return this for unhandled notifications
00148   TRACE_EVENT( _T("Notify"), MmcEvent );
00149
00150   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00151   if( NULL == pNode )
00152     return E_FAIL;
00153
00154
00155   switch( MmcEvent )
00156   {
00157     case MMCN_ADD_IMAGES:
00158       hResult = OnAddImages( ipDataObject, nArg, nParam );
00159       break;
00160
00161     case MMCN_SELECT:
00162       hResult = pNode->OnSelect( ipDataObject, nArg, nParam, (LONG_PTR)this );
00163       break;
00164
00165     // Need to cache the current scope node cookie so result nodes can
00166     // enumerate thier items in the correct window when multiple windows
00167     // are used.
00168     case MMCN_SHOW:
00169       hResult = pNode->OnShow( ipDataObject, nArg, nParam, (LONG_PTR)this );
00170       if( TRUE == nArg )
00171         m_pScopeCookie = (LONG_PTR)ExtractBaseNodePtr(ipDataObject);
00172       else
00173         m_pScopeCookie = NULL;
00174
00175       break;
00176
00177     case MMCN_VIEW_CHANGE:
00178       hResult = pNode->OnViewChange( ipDataObject, nArg, nParam, (LONG_PTR)this );
00179       break;
00180
00181     case MMCN_RENAME:
00182       hResult = pNode->OnRename( ipDataObject, nArg, nParam, (LONG_PTR)this );
00183       break;
00184
00185     case MMCN_DELETE:
00186       hResult = pNode->OnDelete( ipDataObject, nArg, nParam, (LONG_PTR)this );
00187       break;
00188
00189     default:
00190       break;
00191   }
00192   return hResult;
00193 }
00194
00195 //---------------------------------------------------------------------------
00196 STDMETHODIMP CComponent::Destroy
00197 (
00198   MMC_COOKIE nCookie   //[in] Not used
00199 )
00200 {
00201   SAFE_RELEASE( m_ipConsole     );
00202   SAFE_RELEASE( m_ipHeaderCtrl  );
00203   SAFE_RELEASE( m_ipResultData  );
00204   SAFE_RELEASE( m_ipConsoleVerb );
00205
00206   return S_OK;
00207 }
00208
00209 //---------------------------------------------------------------------------
00210 STDMETHODIMP CComponent::QueryDataObject
00211 (
00212   MMC_COOKIE              nCookie,     //[in]  Indentifier of the selected node
00213   DATA_OBJECT_TYPES       nEnumType,   //[in]  Context in which this object was created
00214   LPDATAOBJECT __RPC_FAR* ppDataObject //[out] Points to data object we create
00215 )
00216 {
00217   _ASSERT( NULL != nCookie );
00218   HRESULT hResult = S_FALSE;
00219
00220   CDataObject* pNewObject = new CDataObject();
00221   if( NULL == pNewObject )
00222     return E_OUTOFMEMORY;
00223
00224   pNewObject->SetPrivateData( nCookie, (ULONG)nEnumType );
00225
00226   hResult = pNewObject->QueryInterface( IID_IDataObject, (void**)ppDataObject );
00227
00228   return hResult;
00229 }
00230
00231 //---------------------------------------------------------------------------
00232 //  This method is only called if the Snap-in does not support IComponent2
00233 //
00234 STDMETHODIMP CComponent::GetResultViewType
00235 (
00236   MMC_COOKIE          nCookie,     //[in]  Indentifier of selected node
00237   LPOLESTR __RPC_FAR* ppViewType,  //[out] Points to view type string
00238   long __RPC_FAR*     pViewOptions //[out] Points to MMC_VIEW_OPTIONS enumeration
00239 )
00240 {
00241   return E_NOTIMPL;
00242 }
00243
00244
00245 //---------------------------------------------------------------------------
00246 STDMETHODIMP CComponent::GetDisplayInfo
00247 (
00248   RESULTDATAITEM __RPC_FAR* pResultDataItem  //[in-out] Result item struct
00249 )
00250 {
00251   _ASSERT( NULL != pResultDataItem );
00252   _ASSERT( NULL != pResultDataItem->lParam );
00253
00254   HRESULT  hResult = S_FALSE;
00255
00256   LPBASENODE pNode = reinterpret_cast<LPBASENODE>(pResultDataItem->lParam);
00257   hResult = pNode->GetDisplayInfo( pResultDataItem );
00258
00259   //TRACE_HRESULT( _T("GetDisplayInfo"), hResult );
00260   return hResult;
00261 }
00262
00263 //---------------------------------------------------------------------------
00264 STDMETHODIMP CComponent::CompareObjects
00265 (
00266   LPDATAOBJECT ipDataObjectA,    //[in] First data object to compare
00267   LPDATAOBJECT ipDataObjectB     //[in] Second data object to compare
00268 )
00269 {
00270   return E_NOTIMPL;
00271 }
00272
00273 //---------------------------------------------------------------------------
00274 HRESULT CComponent::QueryDispatch
00275 (
00276   MMC_COOKIE         nCookie,    //[in]  Item for which IDispatch is requested
00277   DATA_OBJECT_TYPES  eType,      //[in]  Context of item
00278   LPDISPATCH*        pipDispatch //[out] IDispatch pointer
00279 )
00280 {
00281   return E_NOTIMPL;
00282 }
00283
00284 //---------------------------------------------------------------------------
00285 //  If we support IComponent2 this method is called to set the view type
00286 //  parameters.
00287 //
00288 HRESULT CComponent::GetResultViewType2
00289 (
00290   MMC_COOKIE             nCookie,  //[in] Identifier of object
00291   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00292 )
00293 {
00294   HRESULT hResult = S_FALSE;
00295
00296   if( NULL == nCookie )
00297   {
00298     CStaticNode* pNode = m_pComponentData->GetStaticNode();
00299     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00300   }
00301   else
00302   {
00303     CBaseNode* pNode = reinterpret_cast<CBaseNode*>(nCookie);
00304     hResult = pNode->GetResultViewType2( nCookie, pRVTinfo );
00305   }
00306
00307   TRACE_HRESULT(_T("GetResultViewType2"), hResult );
00308   return hResult;
00309 }
00310
00311
00312 //---------------------------------------------------------------------------
00313 HRESULT CComponent::RestoreResultView
00314 (
00315   MMC_COOKIE             nCookie,  //[in] Identifier of object
00316   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00317 )
00318 {
00319   return E_NOTIMPL;
00320 }
00321
00322
00323 /////////////////////////////////////////////////////////////////////////////
00324 // Interface INodeProperties
00325
00326
00327 //---------------------------------------------------------------------------
00328 HRESULT CComponent::GetProperty
00329 (
00330   LPDATAOBJECT ipDataObject,     //[in]  Selected data object
00331   BSTR         bstrPropertyName, //[in]  Name of the property being retrieved
00332   PBSTR        pbstrProperty     //[out] Text value for the property
00333 )
00334 {
00335   _ASSERT( NULL != ipDataObject );
00336   if( NULL == pbstrProperty )            // Must have valid pointer
00337     return E_INVALIDARG;
00338
00339   HRESULT hResult = S_FALSE;
00340
00341   LPBASENODE pNode = ExtractBaseNodePtr( ipDataObject );
00342   if( NULL != pNode )
00343     hResult = pNode->GetProperty( bstrPropertyName, pbstrProperty );
00344
00345   return hResult;
00346 }
00347
00348
00349 /////////////////////////////////////////////////////////////////////////////
00350 //  Notification handlers
00351
00352
00353 //---------------------------------------------------------------------------
00354 HRESULT CComponent::OnAddImages
00355 (
00356   LPDATAOBJECT ipDataObject, //[in] Points to the selected data object
00357   LONG         nArg,         //[in] Pointer to IImageList
00358   LONG         nParam        //[in] HSCOPEITEM of selected/deselected item
00359 )
00360 {
00361   HRESULT hResult = S_FALSE;
00362
00363   HBITMAP hImageStrip16 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_16));
00364   HBITMAP hImageStrip32 = ::LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NODEIMAGES_32));
00365
00366   if( NULL != nArg )           // May get this when shutting down
00367   {
00368     IImageList* ipImageList = reinterpret_cast<IImageList*>(nArg);
00369     hResult = ipImageList->ImageListSetStrip( (LONG_PTR*)hImageStrip16,
00370                                               (LONG_PTR*)hImageStrip32,
00371                                               0,
00372                                               RGB(0,255,0)
00373                                             );
00374   }
00375
00376   SAFE_FREE_BITMAP( hImageStrip16 );
00377   SAFE_FREE_BITMAP( hImageStrip32 );
00378
00379   TRACE_HRESULT(_T("OnAddImages"), hResult );
00380   return hResult;
00381 }
00382
00383 /////////////////////////////////////////////////////////////////////////////
00384 //  Public helper methods
00385
00386 //---------------------------------------------------------------------------
00387 //  Supplies interfaces to node objects.
00388 //
00389 HRESULT CComponent::GetInterface
00390 (
00391   DWORD dwRequestedInterface,  //[in] Request flag
00392   LONG_PTR* ppInterface        //[in-out] Interface pointer to return
00393 )
00394 {
00395   _ASSERT( NULL != ppInterface );
00396   HRESULT hResult = S_OK;
00397
00398   switch( dwRequestedInterface )
00399   {
00400     case REQUEST_ICONSOLE:
00401       _ASSERT( NULL != m_ipConsole );
00402       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsole);
00403       break;
00404
00405     case REQUEST_ICONSOLEVERB:
00406       _ASSERT( NULL != m_ipConsoleVerb );
00407       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipConsoleVerb);
00408       break;
00409
00410     case REQUEST_IRESULTDATA:
00411       _ASSERT( NULL != m_ipResultData );
00412       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipResultData);
00413       break;
00414
00415     case REQUEST_IHEADERCTRL:
00416       _ASSERT( NULL != m_ipHeaderCtrl );
00417       *ppInterface = reinterpret_cast<LONG_PTR>(m_ipHeaderCtrl);
00418       break;
00419
00420     default:
00421       hResult = S_FALSE;
00422       *ppInterface = NULL;
00423       break;
00424   }
00425   return hResult;
00426 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptClien/AptClien.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptClien

AptClien.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      APTCLIEN.CPP
00003
00004   Summary:   The main purpose of this application is to exercise the
00005              APTSERVE apartment threaded local server.
00006
00007              Based largely on the LOCCLIEN.EXE application code, this
00008              module is meant to use COM to load and access some COM
00009              components in a separate Apartment model Local EXE COM Server
00010              (APTSERVE built in the sibling APTSERVE directory).  Thus to
00011              run APTCLIEN you must build APTSERVE first.  Like LOCCLIEN,
00012              this app composes its own native composite COM object,
00013              COUtilityCruiseCar. In this client application,
00014              COUtilityCruiseCar is constructed by containment reuse of the
00015              existing COCruiseCar COM component (provided by the
00016              APTSERVE.EXE local server). This application augments that
00017              existing component with a native implementation of the
00018              IUtility interface.  Thus, this application showcases
00019              composition through containment of an existing composite
00020              object that is itself constructed via containment.
00021
00022              Also like LOCCLIEN this client application separately
00023              instantiates the other car-related objects of APTSERVE and
00024              exercises them (ie, for Car, UtilityCar, CruiseCar, and
00025              UtilityCruiseCar).  To this end, APTCLIEN provides a set of
00026              menus for these Car related objects with selections for the
00027              respective methods of the Interfaces exposed by those COM
00028              Objects.
00029
00030              Like LOCCLIEN, this local client/server pair achieves logging
00031              of internal server behavior in the client's logging display.
00032
00033              For a comprehensive tutorial code tour of APTCLIEN's
00034              contents and offerings see the tutorial APTCLIEN.HTM file.
00035              For more specific technical details on the internal workings
00036              see the comments dispersed throughout the APTCLIEN source code.
00037              For more details on the APTSERVE.EXE that APTCLIEN works with
00038              see the APTSERVE.HTM file in the main tutorial directory.
00039
00040   Classes:   CMainWindow
00041
00042   Functions: InitApplication, WinMain
00043
00044   Origin:    3-20-96: atrent - Editor-inheritance from LOCCLIEN source.
00045
00046 ----------------------------------------------------------------------------
00047   This file is part of the Microsoft COM Tutorial Code Samples.
00048
00049   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00050
00051   This source code is intended only as a supplement to Microsoft
00052   Development Tools and/or on-line documentation.  See these other
00053   materials for detailed information regarding Microsoft code samples.
00054
00055   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00056   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00057   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00058   PARTICULAR PURPOSE.
00059 ==========================================================================+*/
00060
00061 /*--------------------------------------------------------------------------
00062   We include WINDOWS.H for all Win32 applications.
00063   We include OLE2.H because we will make calls to the COM/OLE libraries.
00064   We include INITGUID.H only once (here) in the entire app because we
00065     will be defining GUIDs and want them as constants in the data segment.
00066   We include COMMDLG.H because we will be using the Open File and
00067     potentially other Common dialogs.
00068   We include APPUTIL.H because we will be building this application using
00069     the convenient Virtual Window and Dialog classes and other
00070     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00071   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00072     class, GUID, and CLSID specifications.
00073   We include APTCLIEN.H because it has class and resource definitions
00074     specific to this APTCLIEN application.
00075   We include UTCRUCAR.H because it has COUtilityCar object class.
00076 ---------------------------------------------------------------------------*/
00077 #include <windows.h>
00078 #include <ole2.h>
00079 #include <initguid.h>
00080 #include <commdlg.h>
00081 #include <apputil.h>
00082 #include <micars.h>
00083 #include <carguids.h>
00084 #include "aptclien.h"
00085 #include "utcrucar.h"
00086
00087
00088 // Here is a pointer for use by the global Trace Message logging macros.
00089 CMsgLog* g_pMsgLog = NULL;
00090
00091
00092 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00093   Method:   CMainWindow::CMainWindow
00094
00095   Summary:  CMainWindow Constructor.
00096
00097   Args:     .
00098
00099   Modifies: ...
00100
00101   Returns:  .
00102 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00103 CMainWindow::CMainWindow()
00104 {
00105   // Ensure these member variable strings are null strings.
00106   m_szFileName[0] = 0;
00107   m_szFileTitle[0] = 0;
00108
00109   // Fill in the Open File Name Common Dialog's OPENFILENAME structure.
00110   m_ofnFile.lStructSize = sizeof(OPENFILENAME);
00111   m_ofnFile.hwndOwner = m_hWnd;
00112   m_ofnFile.hInstance = m_hInst;
00113   m_ofnFile.lpstrFilter = TEXT(OFN_DEFAULTFILES_STR);
00114   m_ofnFile.lpstrCustomFilter = NULL;
00115   m_ofnFile.nMaxCustFilter = 0;
00116   m_ofnFile.nFilterIndex = 1;
00117   m_ofnFile.lpstrFile = m_szFileName;
00118   m_ofnFile.nMaxFile = MAX_PATH;
00119   m_ofnFile.lpstrInitialDir = TEXT(".");
00120   m_ofnFile.lpstrFileTitle = m_szFileTitle;
00121   m_ofnFile.nMaxFileTitle = MAX_PATH;
00122   m_ofnFile.lpstrTitle = TEXT(OFN_DEFAULTTITLE_STR);
00123   m_ofnFile.lpstrDefExt = NULL;
00124   m_ofnFile.Flags = OFN_HIDEREADONLY;
00125
00126   m_pCar = NULL;
00127   m_pUtilityCar = NULL;
00128   m_pCruiseCar = NULL;
00129   m_pUtilityCruiseCar = NULL;
00130
00131   // Null the Message object pointers.
00132   m_pMsgBox = NULL;
00133   m_pMsgLog = NULL;
00134 }
00135
00136
00137 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00138   Method:   CMainWindow::~CMainWindow
00139
00140   Summary:  CMainWindow Destructor.  Destruction of the main window
00141             indicates that the application should quit and thus the
00142             PostQuitMessage API is called.
00143
00144   Args:     .
00145
00146   Modifies: .
00147
00148   Returns:  .
00149 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00150 CMainWindow::~CMainWindow()
00151 {
00152   // CMainWindow is derived from CVirWindow which traps the WM_DESTROY
00153   // message and causes a delete of CMainWindow which in turn causes this
00154   // destructor to run. The WM_DESTROY results when the window is destoyed
00155   // after a close of the window. Prior to exiting the main message loop:
00156
00157   // We release any and all of the pointers to instantiated COM objects.
00158   RELEASE_INTERFACE(m_pCar);
00159   RELEASE_INTERFACE(m_pUtilityCar);
00160   RELEASE_INTERFACE(m_pCruiseCar);
00161   RELEASE_INTERFACE(m_pUtilityCruiseCar);
00162
00163   // We delete the CMsgBox and CMsgLog objects that were made in
00164   // Initinstance.
00165   DELETE_POINTER(m_pMsgBox);
00166   DELETE_POINTER(m_pMsgLog);
00167
00168   // We then post a WM_QUIT message to cause an exit of the main thread's
00169   // message loop and an exit of this instance of the application.
00170   PostQuitMessage(0);
00171 }
00172
00173
00174 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00175   Method:   CMainWindow::GetInterface
00176
00177   Summary:  Convenience method that wraps the QueryInterface call
00178             and accepts a main COM object IUnknown pointer as an argument.
00179
00180   Args:     IUnknown* pObj,
00181               Pointer to the COM Object we are getting an interface on.
00182             REFIID riid,
00183               The GUID for the interface that we are seeking.
00184             PPVOID ppv)
00185               Address of the caller's pointer variable that will
00186               receive the requested interface pointer.
00187
00188   Modifies: .
00189
00190   Returns:  BOOL.
00191               TRUE if succeeded.
00192               FALSE if failed.
00193 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00194 BOOL CMainWindow::GetInterface(
00195        IUnknown* pObj,
00196        REFIID riid,
00197        PPVOID ppv)
00198 {
00199   BOOL bResult = FALSE;
00200   HRESULT hr;
00201
00202   *ppv=NULL;
00203
00204   if (NULL != pObj)
00205   {
00206     LOG("C: --Obtaining Interface Pointer.");
00207     hr = pObj->QueryInterface(riid, ppv);
00208
00209     if (FAILED(hr))
00210     {
00211       LOGERROR("C: ???? QueryInterface", hr);
00212     }
00213     else
00214     {
00215       LOGF1("C: Interface obtained. *ppv=0x%X", *ppv);
00216       bResult = TRUE;
00217     }
00218   }
00219   else
00220   {
00221     LOG("C: ???? Create an object first.");
00222   }
00223
00224   return (bResult);
00225 }
00226
00227
00228 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00229   Method:   CMainWindow::DoMenu
00230
00231   Summary:  Dispatch and handle the main menu commands.
00232
00233   Args:     WPARAM wParam,
00234               First message parameter (word sized).
00235             LPARAM lParam)
00236               Second message parameter (long sized).
00237
00238   Modifies: m_ofnFile, ...
00239
00240   Returns:  LRESULT
00241               Standard Windows WindowProc return value.
00242 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00243 LRESULT CMainWindow::DoMenu(
00244           WPARAM wParam,
00245           LPARAM lParam)
00246 {
00247   LRESULT lResult = FALSE;
00248   HRESULT hr;
00249   HMENU hMenu  = ::GetMenu(m_hWnd);
00250   // Here are some interface pointers used to call methods on
00251   // our COUtilityCar, COCruiseCar, and COUtilityCruiseCar COM objects.
00252   ICar* pICar;
00253   IUtility* pIUtility;
00254   ICruise* pICruise;
00255
00256   switch (LOWORD(wParam))
00257   {
00258     //----------------------------------------------------------------------
00259     // Handle File Menu Commands.
00260     //----------------------------------------------------------------------
00261     case IDM_FILE_EXIT:
00262       // The user commands us to exit this application so we tell the
00263       // Main window to close itself.
00264       ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
00265       break;
00266
00267     //----------------------------------------------------------------------
00268     // Handle Car Menu Commands.
00269     //----------------------------------------------------------------------
00270     case IDM_CAR_CREATE:
00271       LOG("C: === Car Menu: Create.");
00272       if (NULL == m_pCar)
00273       {
00274         // Call COM service to create an instance.
00275         hr = CoCreateInstance(
00276                CLSID_AptCar,
00277                NULL,
00278                CLSCTX_LOCAL_SERVER,
00279                IID_IUnknown,
00280                (PPVOID)&m_pCar);
00281         if (SUCCEEDED(hr))
00282         {
00283           ::CheckMenuItem(
00284               hMenu,
00285               IDM_CAR_CREATE,
00286               MF_BYCOMMAND | MF_CHECKED);
00287         }
00288         else
00289         {
00290           LOGERROR("C: ???? CoCreateInstance",hr);
00291         }
00292       }
00293       else
00294         LOG("C: ???? Car already exists.");
00295       break;
00296     case IDM_CAR_RELEASE:
00297       LOG("C: === Car Menu: Release.");
00298       if (NULL != m_pCar)
00299       {
00300         RELEASE_INTERFACE(m_pCar);
00301         // We ask COM to unload any unused COM Servers.
00302         CoFreeUnusedLibraries();
00303         ::CheckMenuItem(
00304             hMenu,
00305             IDM_CAR_CREATE,
00306             MF_BYCOMMAND | MF_UNCHECKED);
00307       }
00308       else
00309         LOG("C: ???? No Car to Release.");
00310       break;
00311     case IDM_CAR_SHIFT:
00312       LOG("C: === Car Menu: ICar::Shift");
00313       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00314       {
00315         LOG("C: --Calling pICar->Shift");
00316         pICar->Shift(1);
00317         LOG("C: --Releasing pICar");
00318         pICar->Release();
00319       }
00320       break;
00321     case IDM_CAR_CLUTCH:
00322       LOG("C: === Car Menu: ICar::Clutch");
00323       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00324       {
00325         LOG("C: --Calling pICar->Clutch");
00326         pICar->Clutch(100);
00327         LOG("C: --Releasing pICar");
00328         pICar->Release();
00329       }
00330       break;
00331     case IDM_CAR_SPEED:
00332       LOG("C: === Car Menu: ICar::Speed");
00333       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00334       {
00335         LOG("C: --Calling pICar->Speed");
00336         pICar->Speed(20);
00337         LOG("C: --Releasing pICar");
00338         pICar->Release();
00339       }
00340       break;
00341     case IDM_CAR_STEER:
00342       LOG("C: === Car Menu: ICar::Steer");
00343       if (GetInterface(m_pCar, IID_ICar, (PPVOID)&pICar))
00344       {
00345         LOG("C: --Calling pICar->Steer");
00346         pICar->Steer(0);
00347         LOG("C: --Releasing pICar");
00348         pICar->Release();
00349       }
00350       break;
00351
00352     //----------------------------------------------------------------------
00353     // Handle UtilityCar Menu Commands.
00354     //----------------------------------------------------------------------
00355     case IDM_UCAR_CREATE:
00356       LOG("C: === UtilityCar Menu: Create.");
00357       if (NULL == m_pUtilityCar)
00358       {
00359         // Call COM service to create an instance.
00360         hr = CoCreateInstance(
00361                CLSID_AptUtilityCar,
00362                NULL,
00363                CLSCTX_LOCAL_SERVER,
00364                IID_IUnknown,
00365                (PPVOID)&m_pUtilityCar);
00366         if (SUCCEEDED(hr))
00367         {
00368           ::CheckMenuItem(
00369               hMenu,
00370               IDM_UCAR_CREATE,
00371               MF_BYCOMMAND | MF_CHECKED);
00372         }
00373         else
00374         {
00375           LOGERROR("C: ???? CoCreateInstance",hr);
00376         }
00377       }
00378       else
00379         LOG("C: ???? UtilityCar already exists.");
00380       break;
00381     case IDM_UCAR_RELEASE:
00382       LOG("C: === UtilityCar Menu: Release.");
00383       if (NULL != m_pUtilityCar)
00384       {
00385         RELEASE_INTERFACE(m_pUtilityCar);
00386         // We ask COM to unload any unused COM Servers.
00387         CoFreeUnusedLibraries();
00388         ::CheckMenuItem(
00389             hMenu,
00390             IDM_UCAR_CREATE,
00391             MF_BYCOMMAND | MF_UNCHECKED);
00392       }
00393       else
00394         LOG("C: ???? No UtilityCar to Release.");
00395       break;
00396     case IDM_UCAR_SHIFT:
00397       LOG("C: === UtilityCar Menu: ICar::Shift");
00398       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00399       {
00400         LOG("C: --Calling pICar->Shift");
00401         pICar->Shift(2);
00402         LOG("C: --Releasing pICar");
00403         pICar->Release();
00404       }
00405       break;
00406     case IDM_UCAR_CLUTCH:
00407       LOG("C: === UtilityCar Menu: ICar::Clutch");
00408       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00409       {
00410         LOG("C: --Calling pICar->Clutch");
00411         pICar->Clutch(100);
00412         LOG("C: --Releasing pICar");
00413         pICar->Release();
00414       }
00415       break;
00416     case IDM_UCAR_SPEED:
00417       LOG("C: === UtilityCar Menu: ICar::Speed");
00418       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00419       {
00420         LOG("C: --Calling pICar->Speed");
00421         pICar->Speed(30);
00422         LOG("C: --Releasing pICar");
00423         pICar->Release();
00424       }
00425       break;
00426     case IDM_UCAR_STEER:
00427       LOG("C: === UtilityCar Menu: ICar::Steer");
00428       if (GetInterface(m_pUtilityCar, IID_ICar, (PPVOID)&pICar))
00429       {
00430         LOG("C: --Calling pICar->Steer");
00431         pICar->Steer(10);
00432         LOG("C: --Releasing pICar");
00433         pICar->Release();
00434       }
00435       break;
00436     case IDM_UCAR_OFFROAD:
00437       LOG("C: === UtilityCar Menu: IUtility::Offroad");
00438       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00439       {
00440         LOG("C: --Calling pIUtility->Offroad");
00441         pIUtility->Offroad(1);
00442         LOG("C: --Releasing pIUtility");
00443         pIUtility->Release();
00444       }
00445       break;
00446     case IDM_UCAR_WINCH:
00447       LOG("C: === UtilityCar Menu: IUtility::Winch");
00448       if (GetInterface(m_pUtilityCar, IID_IUtility, (PPVOID)&pIUtility))
00449       {
00450         LOG("C: --Calling pIUtility->Winch");
00451         pIUtility->Winch(0);
00452         LOG("C: --Releasing pIUtility");
00453         pIUtility->Release();
00454       }
00455       break;
00456
00457     //----------------------------------------------------------------------
00458     // Handle CruiseCar Menu Commands.
00459     //----------------------------------------------------------------------
00460     case IDM_CCAR_CREATE:
00461       LOG("C: === CruiseCar Menu: Create.");
00462       if (NULL == m_pCruiseCar)
00463       {
00464         // Call COM service to create an instance.
00465         hr = CoCreateInstance(
00466                CLSID_AptCruiseCar,
00467                NULL,
00468                CLSCTX_LOCAL_SERVER,
00469                IID_IUnknown,
00470                (PPVOID)&m_pCruiseCar);
00471         if (SUCCEEDED(hr))
00472         {
00473           ::CheckMenuItem(
00474               hMenu,
00475               IDM_CCAR_CREATE,
00476               MF_BYCOMMAND | MF_CHECKED);
00477         }
00478         else
00479         {
00480           LOGERROR("C: ???? CoCreateInstance",hr);
00481         }
00482       }
00483       else
00484         LOG("C: ???? CruiseCar already exists.");
00485       break;
00486     case IDM_CCAR_RELEASE:
00487       LOG("C: === CruiseCar Menu: Release.");
00488       if (NULL != m_pCruiseCar)
00489       {
00490         RELEASE_INTERFACE(m_pCruiseCar);
00491         // We ask COM to unload any unused COM Servers.
00492         CoFreeUnusedLibraries();
00493         ::CheckMenuItem(
00494             hMenu,
00495             IDM_CCAR_CREATE,
00496             MF_BYCOMMAND | MF_UNCHECKED);
00497       }
00498       else
00499         LOG("C: ???? No CruiseCar to Release.");
00500       break;
00501     case IDM_CCAR_SHIFT:
00502       LOG("C: === CruiseCar Menu: ICar::Shift");
00503       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00504       {
00505         LOG("C: --Calling pICar->Shift");
00506         pICar->Shift(4);
00507         LOG("C: --Releasing pICar");
00508         pICar->Release();
00509       }
00510       break;
00511     case IDM_CCAR_CLUTCH:
00512       LOG("C: === CruiseCar Menu: ICar::Clutch");
00513       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00514       {
00515         LOG("C: --Calling pICar->Clutch");
00516         pICar->Clutch(100);
00517         LOG("C: --Releasing pICar");
00518         pICar->Release();
00519       }
00520       break;
00521     case IDM_CCAR_SPEED:
00522       LOG("C: === CruiseCar Menu: ICar::Speed");
00523       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00524       {
00525         LOG("C: --Calling pICar->Speed");
00526         pICar->Speed(60);
00527         LOG("C: --Releasing pICar");
00528         pICar->Release();
00529       }
00530       break;
00531     case IDM_CCAR_STEER:
00532       LOG("C: === CruiseCar Menu: ICar::Steer");
00533       if (GetInterface(m_pCruiseCar, IID_ICar, (PPVOID)&pICar))
00534       {
00535         LOG("C: --Calling pICar->Steer");
00536         pICar->Steer(0);
00537         LOG("C: --Releasing pICar");
00538         pICar->Release();
00539       }
00540       break;
00541     case IDM_CCAR_ENGAGE:
00542       LOG("C: === CruiseCar Menu: ICruise::Engage");
00543       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00544       {
00545         LOG("C: --Calling pICruise->Engage");
00546         pICruise->Engage(TRUE);
00547         LOG("C: --Releasing pICruise");
00548         pICruise->Release();
00549       }
00550       break;
00551     case IDM_CCAR_ADJUST:
00552       LOG("C: === CruiseCar Menu: ICruise::Adjust");
00553       if (GetInterface(m_pCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00554       {
00555         LOG("C: --Calling pICruise->Adjust");
00556         pICruise->Adjust(FALSE);
00557         LOG("C: --Releasing pICruise");
00558         pICruise->Release();
00559       }
00560       break;
00561
00562     //----------------------------------------------------------------------
00563     // Handle UtilityCruiseCar Menu Commands.
00564     //----------------------------------------------------------------------
00565     case IDM_UCRU_CREATE:
00566       LOG("C: === UtilityCruiseCar Menu: Create.");
00567       if (NULL == m_pUtilityCruiseCar)
00568       {
00569         // Call a create function to create an instance.
00570         hr = CreateUtilityCruiseCar(
00571                NULL,
00572                IID_IUnknown,
00573                (PPVOID)&m_pUtilityCruiseCar);
00574         if (SUCCEEDED(hr))
00575         {
00576           ::CheckMenuItem(
00577               hMenu,
00578               IDM_UCRU_CREATE,
00579               MF_BYCOMMAND | MF_CHECKED);
00580         }
00581         else
00582           LOG("C: ???? UtilityCruiseCar creation failed.");
00583       }
00584       else
00585         LOG("C: ???? UtilityCruiseCar already exists.");
00586       break;
00587     case IDM_UCRU_RELEASE:
00588       LOG("C: === UtilityCruiseCar Menu: Release.");
00589       if (NULL != m_pUtilityCruiseCar)
00590       {
00591         RELEASE_INTERFACE(m_pUtilityCruiseCar);
00592         // We ask COM to unload any unused COM Servers.
00593         CoFreeUnusedLibraries();
00594         ::CheckMenuItem(
00595             hMenu,
00596             IDM_UCRU_CREATE,
00597             MF_BYCOMMAND | MF_UNCHECKED);
00598       }
00599       else
00600         LOG("C: ???? No UtilityCruiseCar to Release.");
00601       break;
00602     case IDM_UCRU_SHIFT:
00603       LOG("C: === UtilityCruiseCar Menu: ICar::Shift");
00604       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00605       {
00606         LOG("C: --Calling pICar->Shift");
00607         pICar->Shift(1);
00608         LOG("C: --Releasing pICar");
00609         pICar->Release();
00610       }
00611       break;
00612     case IDM_UCRU_CLUTCH:
00613       LOG("C: === UtilityCruiseCar Menu: ICar::Clutch");
00614       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00615       {
00616         LOG("C: --Calling pICar->Clutch");
00617         pICar->Clutch(80);
00618         LOG("C: --Releasing pICar");
00619         pICar->Release();
00620       }
00621       break;
00622     case IDM_UCRU_SPEED:
00623       LOG("C: === UtilityCruiseCar Menu: ICar::Speed");
00624       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00625       {
00626         LOG("C: --Calling pICar->Speed");
00627         pICar->Speed(10);
00628         LOG("C: --Releasing pICar");
00629         pICar->Release();
00630       }
00631       break;
00632     case IDM_UCRU_STEER:
00633       LOG("C: === UtilityCruiseCar Menu: ICar::Steer");
00634       if (GetInterface(m_pUtilityCruiseCar, IID_ICar, (PPVOID)&pICar))
00635       {
00636         LOG("C: --Calling pICar->Steer");
00637         pICar->Steer(10);
00638         LOG("C: --Releasing pICar");
00639         pICar->Release();
00640       }
00641       break;
00642     case IDM_UCRU_ENGAGE:
00643       LOG("C: === UtilityCruiseCar Menu: ICruise::Engage");
00644       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00645       {
00646         LOG("C: --Calling pICruise->Engage");
00647         pICruise->Engage(FALSE);
00648         LOG("C: --Releasing pICruise");
00649         pICruise->Release();
00650       }
00651       break;
00652     case IDM_UCRU_ADJUST:
00653       LOG("C: === UtilityCruiseCar Menu: ICruise::Adjust");
00654       if (GetInterface(m_pUtilityCruiseCar, IID_ICruise, (PPVOID)&pICruise))
00655       {
00656         LOG("C: --Calling pICruise->Adjust");
00657         pICruise->Adjust(FALSE);
00658         LOG("C: --Releasing pICruise");
00659         pICruise->Release();
00660       }
00661       break;
00662     case IDM_UCRU_OFFROAD:
00663       LOG("C: === UtilityCruiseCar Menu: IUtility::Offroad");
00664       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00665       {
00666         LOG("C: --Calling pIUtility->Offroad");
00667         pIUtility->Offroad(3);
00668         LOG("C: --Releasing pIUtility");
00669         pIUtility->Release();
00670       }
00671       break;
00672     case IDM_UCRU_WINCH:
00673       LOG("C: === UtilityCruiseCar Menu: IUtility::Winch");
00674       if (GetInterface(m_pUtilityCruiseCar, IID_IUtility, (PPVOID)&pIUtility))
00675       {
00676         LOG("C: --Calling pIUtility->Winch");
00677         pIUtility->Winch(0);
00678         LOG("C: --Releasing pIUtility");
00679         pIUtility->Release();
00680       }
00681       break;
00682
00683     //----------------------------------------------------------------------
00684     // Handle Log Menu Commands.
00685     //----------------------------------------------------------------------
00686     case IDM_LOG_LOGCLEAR:
00687       // Clear the message log.
00688       m_pMsgLog->Clear();
00689       // Use macro to log messages.
00690       LOGID(IDS_START_MESSAGE_LOG);
00691       break;
00692     case IDM_LOG_LOGGING:
00693       // Toggle the state of the Message Logging.
00694       // Toggle the checkmark indicator on the menu selection as well.
00695       {
00696         HMENU hMenu  = ::GetMenu(m_hWnd);
00697         BOOL bLogging = ::GetMenuState(
00698                             hMenu,
00699                             IDM_LOG_LOGGING,
00700                             MF_BYCOMMAND) & MF_CHECKED;
00701         if (bLogging)
00702         {
00703           m_pMsgLog->Logging(FALSE);
00704           ::CheckMenuItem(
00705               hMenu,
00706               IDM_LOG_LOGGING,
00707               MF_BYCOMMAND | MF_UNCHECKED);
00708         }
00709         else
00710         {
00711           m_pMsgLog->Logging(TRUE);
00712           ::CheckMenuItem(
00713               hMenu,
00714               IDM_LOG_LOGGING,
00715               MF_BYCOMMAND | MF_CHECKED);
00716         }
00717       }
00718       break;
00719     case IDM_LOG_COPYCLIP:
00720       // Copy trace message log to clipboard.
00721       m_pMsgLog->Copy();
00722       break;
00723
00724     //----------------------------------------------------------------------
00725     // Handle Help Menu Commands.
00726     //----------------------------------------------------------------------
00727     case IDM_HELP_CONTENTS:
00728       // We have some stubbed support here for bringing up the online
00729       // Help for this application.
00730       ReadHelp(m_hWnd, m_szHelpFile);
00731       break;
00732     case IDM_HELP_TUTORIAL:
00733       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00734       // tutorial narrative file associated with this tutorial code sample.
00735       ReadTutorial(m_hInst, m_hWnd, TEXT(HTML_FILE_EXT));
00736       break;
00737     case IDM_HELP_TUTSERVER:
00738       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00739       // tutorial narrative file associated with the COM server.
00740       ReadTutorial(m_hInst, m_hWnd, TEXT(SERVER_TUTFILE_STR));
00741       break;
00742     case IDM_HELP_TUTMARSHAL:
00743       // Call the APPUTIL utility function, ReadTutorial, to Browse the HTML
00744       // tutorial narrative file associated with the COM marshaling server.
00745       ReadTutorial(m_hInst, m_hWnd, TEXT(MARSHAL_TUTFILE_STR));
00746       break;
00747     case IDM_HELP_READSOURCE:
00748       // Call the APPUTIL utility function ReadSource to allow the
00749       // user to open and read any of the source files of APTCLIEN.
00750       ReadSource(m_hWnd, &m_ofnFile);
00751       break;
00752     case IDM_HELP_ABOUT:
00753       {
00754         CAboutBox dlgAboutBox;
00755
00756         LOG("C: === Help Menu: About APTCLIEN.");
00757         // Show the standard About Box dialog for this EXE by telling the
00758         // dialog C++ object to show itself by invoking its ShowDialog
00759         // method.  Pass it this EXE instance and the parent window handle.
00760         // Use a dialog resource ID for the dialog template stored in
00761         // this EXE module's resources.
00762         dlgAboutBox.ShowDialog(
00763           m_hInst,
00764           MAKEINTRESOURCE(IDM_HELP_ABOUT),
00765           m_hWnd);
00766       }
00767       break;
00768     case IDM_HELP_ABOUTSERVER:
00769       {
00770         // Post a message to the Server to show its AboutBox dialog.
00771         LOG("C: === Help Menu: About APTSERVE.");
00772
00773         HWND hWnd = FindWindow(NULL, TEXT(SERVER_WINDOW_TITLE_STR));
00774         if (NULL != hWnd)
00775           PostMessage(hWnd, WM_COMMAND, IDM_HELP_ABOUT, NULL);
00776       }
00777       break;
00778
00779     default:
00780       // Defer all messages NOT handled here to the Default Window Proc.
00781       lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
00782       break;
00783   }
00784
00785   return(lResult);
00786 }
00787
00788
00789 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00790   Method:   CMainWindow::InitInstance
00791
00792   Summary:  Instantiates an instance of the main application window.
00793             This method must be called only once, immediately after
00794             window class construction.  We take care to delete 'this'
00795             CMainWindow if we must return the error condition FALSE.
00796
00797   Args:     HINSTANCE hInstance,
00798               Handle of the application instance.
00799             int nCmdShow)
00800               Command to pass to ShowWindow.
00801
00802   Modifies: m_szHelpFile, m_pMsgBox, m_pMsgLog.
00803
00804   Returns:  BOOL.
00805               TRUE if succeeded.
00806               FALSE if failed.
00807 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00808 BOOL CMainWindow::InitInstance(
00809        HINSTANCE hInstance,
00810        int nCmdShow)
00811 {
00812   BOOL bOk = FALSE;
00813   HWND hWnd;
00814
00815   // Create the Message Box and Message Log objects.
00816   m_pMsgBox = new CMsgBox;
00817   m_pMsgLog = new CMsgLog;
00818
00819   if (NULL != m_pMsgBox && NULL != m_pMsgLog)
00820   {
00821     // Note, the Create method sets the m_hWnd member so we don't
00822     // need to set it explicitly here first.
00823
00824     // Here is the create of this window.  Size the window reasonably.
00825     // Create sets both m_hInst and m_hWnd.
00826     hWnd = Create(
00827              TEXT(MAIN_WINDOW_CLASS_NAME_STR),
00828              TEXT(MAIN_WINDOW_TITLE_STR),
00829              WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
00830                | WS_MAXIMIZEBOX | WS_THICKFRAME,
00831              CW_USEDEFAULT,
00832              CW_USEDEFAULT,
00833              ::GetSystemMetrics(SM_CXSCREEN)*3/5,
00834              ::GetSystemMetrics(SM_CYSCREEN)*3/5,
00835              NULL,
00836              NULL,
00837              hInstance);
00838     if (hWnd)
00839     {
00840       // Ensure the new window is shown on screen and its content is painted.
00841       ::ShowWindow(m_hWnd, nCmdShow);
00842       ::UpdateWindow(m_hWnd);
00843
00844       // Build a path to where the help file should be (it should be in
00845       // the same directory as the .EXE but with the .HTM extension.
00846       MakeFamilyPath(hInstance, m_szHelpFile, TEXT(HELP_FILE_EXT));
00847
00848       // Init the Message Box object.
00849       if (m_pMsgBox->Init(m_hInst, m_hWnd))
00850       {
00851         // Create the Trace Message Log ListBox as a child window that
00852         // fits the client area of the Main Window (the TRUE 3rd argument
00853         // specifies such an inside child). If you want the Trace Message
00854         // Log in a separate (but owned) window, then pass a FALSE instead
00855         // for the 3rd argument.
00856         if (m_pMsgLog->Create(m_hInst, m_hWnd, TRUE))
00857         {
00858           // Assign the global MsgLog pointer.
00859           g_pMsgLog = m_pMsgLog;
00860           // Use macro to log an initial start messsage.
00861           LOGID(IDS_START_MESSAGE_LOG);
00862           bOk = TRUE;
00863         }
00864       }
00865     }
00866   }
00867
00868   if (!bOk)
00869   {
00870     DELETE_POINTER(m_pMsgBox);
00871     DELETE_POINTER(m_pMsgLog);
00872   }
00873
00874   return (bOk);
00875 }
00876
00877
00878 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00879   Method:   CMainWindow::WindowProc
00880
00881   Summary:  Main window procedure for this window object.  See CVirWindow
00882             in the APPUTIL library (APPUTIL.CPP) for details on how this
00883             method gets called by the global WindowProc.
00884
00885   Args:     UINT uMsg,
00886               Windows message that is "sent" to this window.
00887             WPARAM wParam,
00888               First message parameter (word sized).
00889             LPARAM lParam)
00890               Second message parameter (long sized).
00891
00892   Modifies: ...
00893
00894   Returns:  LRESULT
00895               Standard Windows WindowProc return value.
00896 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00897 LRESULT CMainWindow::WindowProc(
00898           UINT uMsg,
00899           WPARAM wParam,
00900           LPARAM lParam)
00901 {
00902   LRESULT lResult = FALSE;
00903
00904   switch (uMsg)
00905   {
00906     case WM_CREATE:
00907       {
00908         // Setup for painting text in this window.
00909         HDC hdc = GetDC(m_hWnd);
00910         ::GetTextMetrics(hdc, &m_tm);
00911         ::ReleaseDC(m_hWnd, hdc);
00912       }
00913       break;
00914
00915     case WM_MEASUREITEM:
00916       // Get setup for painting text in this window.
00917       {
00918         LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
00919         lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading;
00920         lpmis->itemWidth = m_wWidth;
00921         lResult = TRUE;
00922       }
00923
00924     case WM_SIZE:
00925       // Handle a resize of this window.
00926       m_wWidth = LOWORD(lParam);
00927       m_wHeight = HIWORD(lParam);
00928       // Resize the Message Log ListBox
00929       m_pMsgLog->Resize(m_wWidth, m_wHeight);
00930       break;
00931
00932     case WM_COMMAND:
00933       // Dispatch and handle any Menu command messages received.
00934       lResult = DoMenu(wParam, lParam);
00935       break;
00936
00937     case WM_COPYDATA:
00938       // We have been sent a trace log message from a server.
00939       // Log it to our own Client's display.
00940       {
00941         LPTSTR pszMsg = (LPTSTR)((COPYDATASTRUCT*)lParam)->lpData;
00942         g_pMsgLog->Msg(pszMsg);
00943         #if defined(DEBUG)
00944         // Bump to next line in the debugger output window.
00945         ::OutputDebugString(TEXT("\r\n"));
00946         #endif
00947       }
00948       break;
00949
00950     case WM_CLOSE:
00951       // The user selected Close on the main window's System menu
00952       // or Exit on the File menu.
00953     case WM_QUIT:
00954       // If the app is being quit then close any associated help windows.
00955     default:
00956       // Defer all messages NOT handled here to the Default Window Proc.
00957       lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
00958       break;
00959   }
00960
00961   return(lResult);
00962 }
00963
00964
00965 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00966   Function: UnicodeOk
00967
00968   Summary:  Checks if the platform will handle unicode versions of
00969             Win32 string API calls.
00970
00971   Args:     void
00972
00973   Modifies: .
00974
00975   Returns:  BOOL
00976               TRUE if unicode support; FALSE if not.
00977 ------------------------------------------------------------------------F-F*/
00978 BOOL UnicodeOk(void)
00979 {
00980   BOOL bOk = TRUE;
00981   TCHAR szUserName[MAX_STRING_LENGTH];
00982   DWORD dwSize = MAX_STRING_LENGTH;
00983
00984   if (!GetUserName(szUserName, &dwSize))
00985     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00986
00987   return bOk;
00988 }
00989
00990
00991 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00992   Function: InitApplication
00993
00994   Summary:  Initializes the application and registers its main window
00995             class. InitApplication is called only once (in WinMain).
00996
00997   Args:     HINSTANCE hInstance)
00998               Handle to the first instance of the application.
00999
01000   Modifies: .
01001
01002   Returns:  BOOL.
01003               TRUE if success.
01004               FALSE if fail.
01005 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01006 BOOL InitApplication(
01007        HINSTANCE hInstance)
01008 {
01009   BOOL bOk;
01010   // The window class for all instances of the main frame window.
01011   WNDCLASSEX wcf;
01012
01013   // Assign the appropriate values for this main frame window class.
01014   wcf.cbSize        = sizeof(WNDCLASSEX);
01015   wcf.cbClsExtra    = 0;            // No per-class extra data.
01016   wcf.cbWndExtra    = 0;            // No per-window extra data.
01017   wcf.hInstance     = hInstance;    // Application module instance.
01018   wcf.lpfnWndProc   = &WindowProc;  // Global Window Procedure (defined in
01019                                     // APPUTIL for all CVirWindows).
01020   wcf.hCursor       = LoadCursor(NULL, IDC_ARROW); // Load app cursor.
01021   wcf.hIcon         = (HICON) LoadIcon(            // Load app icon.
01022                                 hInstance,
01023                                 TEXT("AppIcon"));
01024   wcf.hIconSm       = (HICON) LoadImage(           // Load small icon.
01025                                 hInstance,
01026                                 TEXT("AppIcon"),
01027                                 IMAGE_ICON,
01028                                 16, 16,
01029                                 0);
01030   wcf.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);  // Default backgnd color.
01031   wcf.style         = CS_HREDRAW | CS_VREDRAW;     // Class style(s).
01032   wcf.lpszClassName = TEXT(MAIN_WINDOW_CLASS_NAME_STR); // Class name.
01033   wcf.lpszMenuName  = TEXT(MAIN_WINDOW_CLASS_MENU_STR); // Menu name.
01034
01035   // Register the window class and return FALSE if unsuccesful.
01036   bOk = RegisterClassEx(&wcf);
01037
01038   return (bOk);
01039 }
01040
01041
01042 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
01043   Function: WinMain
01044
01045   Summary:  The Windows main entry point function for this application.
01046             Initializes the application, the COM Libraries, and starts
01047             the main application message loop.
01048
01049   Args:     HINSTANCE hInstance,
01050               Instance handle; a new one for each invocation of this app.
01051             HINSTANCE hPrevInstance,
01052               Instance handle of the previous instance. NULL in Win32.
01053             LPSTR lpCmdLine,
01054               Windows passes a pointer to the application's
01055               invocation command line.
01056             int nCmdShow)
01057               Bits telling the show state of the application.
01058
01059   Modifies: .
01060
01061   Returns:  int
01062               msg.wParam (upon exit of message loop).
01063               FALSE if this instance couldn't initialize and run.
01064 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
01065 extern "C" int PASCAL WinMain(
01066                         HINSTANCE hInstance,
01067                         HINSTANCE hPrevInstance,
01068                         LPSTR lpCmdLine,
01069                         int nCmdShow)
01070 {
01071   CMainWindow* pWin = NULL;
01072   MSG msg;
01073   HACCEL hAccel;
01074   int iRun = FALSE;
01075
01076   // If we were compiled for UNICODE and the platform seems OK with this
01077   // then proceed.  Else we error and exit the app.
01078   if (UnicodeOk())
01079   {
01080     // Call to initialize the COM Library.  Use the SUCCEEDED macro
01081     // to detect success.  If fail then exit app with error message.
01082     if (SUCCEEDED(CoInitialize(NULL)))
01083     {
01084       // If we succeeded in initializing the COM Library we proceed to
01085       // initialize the application.  If we can't init the application
01086       // then we signal shut down with an error message exit.
01087       iRun = InitApplication(hInstance);
01088       if (iRun)
01089       {
01090         // Assume we'll set iRun to TRUE when initialization is done.
01091         iRun = FALSE;
01092         // We are still go for running so we try to create a nifty new
01093         // CMainWindow object for this app instance.
01094         pWin = new CMainWindow;
01095         if (NULL != pWin)
01096         {
01097           // Now we initialize an instance of the new CMainWindow.
01098           // This includes creating the main window.
01099           if (pWin->InitInstance(hInstance, nCmdShow))
01100           {
01101             // Load the keyboard accelerators from the resources.
01102             hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
01103             if (NULL != hAccel)
01104             {
01105               // Signal App Initialization is successfully done.
01106               iRun = TRUE;
01107             }
01108           }
01109         }
01110       }
01111
01112       if (iRun)
01113       {
01114         // If we initialized the app instance properly then we are still
01115         // go for running.  We then start up the main message pump for
01116         // the application.
01117         while (GetMessage(&msg, NULL, 0, 0))
01118         {
01119           if (!TranslateAccelerator(
01120                  pWin->GetHwnd(),
01121                  hAccel,
01122                  &msg))
01123           {
01124             TranslateMessage(&msg);
01125             DispatchMessage(&msg);
01126           }
01127         }
01128
01129         // We ask COM to unload any unused COM Servers.
01130         CoFreeUnusedLibraries();
01131
01132         // We'll pass to Windows the reason why we exited the message loop.
01133         iRun = (int) msg.wParam;
01134       }
01135       else
01136       {
01137         // We failed to initialize the application. Put up error message
01138         // box saying that application couldn't be initialized.  Parent
01139         // window is desktop (ie, NULL). Exit the failed application
01140         // (ie, by returning FALSE to WinMain).
01141         ErrorBox(hInstance, NULL, IDS_APPINITFAILED);
01142
01143         // Delete the CMainWindow object.
01144         DELETE_POINTER(pWin);
01145       }
01146
01147       // We're exiting this app (either normally or by init failure) so
01148       // shut down the COM Library.
01149       CoUninitialize();
01150     }
01151     else
01152     {
01153       // We failed to Initialize the COM Library. Put up error message box
01154       // saying that COM Library couldn't be initialized.  Parent window
01155       // is desktop (ie, NULL). Exit the failed application (ie, by
01156       // returning FALSE to WinMain).
01157       ErrorBox(hInstance, NULL, IDS_COMINITFAILED);
01158     }
01159   }
01160   else
01161   {
01162     // If we were compiled for UNICODE but the platform has problems with
01163     // this then indicate an error and exit the app immediately.
01164     CHAR szMsg[MAX_STRING_LENGTH];
01165
01166     if (LoadStringA(
01167           hInstance,
01168           IDS_NOUNICODE,
01169           szMsg,
01170           MAX_STRING_LENGTH))
01171     {
01172       MessageBoxA(
01173         NULL,
01174         szMsg,
01175         ERROR_TITLE_STR,
01176         MB_OK | MB_ICONEXCLAMATION);
01177     }
01178   }
01179
01180   return iRun;
01181 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/AptServe/Server.h Source File

  • Com
  • Fundamentals
  • TutSamp
  • AptServe

Server.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      SERVER.H
00003
00004   Summary:   Internal include file for the APTSERVE.EXE local server code
00005              sample.  Contains class declarations, resource IDs and string
00006              macros for internal use in constructing this EXE as a local
00007              COM component server using Apartment model multi-threading.
00008              Declares the CServer server control object class.
00009
00010              For a comprehensive tutorial code tour of this module's
00011              contents and offerings see the tutorial APTSERVE.HTM file.
00012              For more specific technical details on the internal workings
00013              see the comments dispersed throughout the module's source code.
00014
00015   Classes:   CServer.
00016
00017   Functions: none
00018
00019   Origin:    3-11-97: atrent - Editor-inheritance from SERVER.H in
00020                the LOCSERVE Tutorial Code Sample. [Revised]
00021
00022 ----------------------------------------------------------------------------
00023   This file is part of the Microsoft COM Tutorial Code Samples.
00024
00025   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00026
00027   This source code is intended only as a supplement to Microsoft
00028   Development Tools and/or on-line documentation.  See these other
00029   materials for detailed information regarding Microsoft code samples.
00030
00031   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00032   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00033   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00034   PARTICULAR PURPOSE.
00035 ==========================================================================+*/
00036
00037
00038 #if !defined(SERVER_H)
00039 #define SERVER_H
00040
00041 #ifdef __cplusplus
00042
00043 // Period to wait for all apartment threads to exit/terminate (8 seconds).
00044 #define LONG_WAIT 8000
00045
00046 // Appartment Thread Initialization data.
00047 enum { NUM_APARTMENTS = 3 };
00048 enum { APTCAR = 0, APTUTILITYCAR = 1, APTCRUISECAR = 2 };
00049 struct APT_INIT_DATA
00050 {
00051   REFCLSID rclsid;
00052   IUnknown* pcf;
00053
00054   // Member initializer MUST be used here because VC++ 4.0+ is strict
00055   // about const and reference (&) types like REFCLSID that need to
00056   // be initialized in this app.  For example, VC++ 4.x will not permit
00057   // a simple assignment of rclsid in the constructor.
00058   APT_INIT_DATA(REFCLSID rclsidi) : rclsid(rclsidi)
00059   {
00060     pcf = NULL;
00061   };
00062
00063   ~APT_INIT_DATA() {};
00064 };
00065
00066
00067 /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
00068   Class:    CServer
00069
00070   Summary:  Class to encapsulate control of this COM server (eg, handle
00071             Lock and Object counting, encapsulate otherwise global data).
00072             Govern server and Apartment lifetimes.
00073
00074   Methods:  none
00075 C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
00076 class CServer : public CThreaded
00077 {
00078   public:
00079     CServer(void);
00080     ~CServer(void);
00081
00082     void Lock(void);
00083     void Unlock(void);
00084     void ObjectsUp(void);
00085     void ObjectsDown(void);
00086     BOOL OpenFactories(void);
00087     BOOL CloseFactories(void);
00088
00089     // CThreaded method overrides.
00090     BOOL OwnThis(void);
00091     void UnOwnThis(void);
00092
00093     // A place to store the server's instance handle.
00094     HINSTANCE m_hInstServer;
00095
00096     // A place to store the server's main window.
00097     HWND      m_hWndServer;
00098
00099     // Global Server living Object count.
00100     LONG      m_cObjects;
00101
00102     // Global Server Client Lock count.
00103     LONG      m_cLocks;
00104
00105     // Some member variables to store pointers to Class Factories.
00106     IUnknown* m_pCFCar;
00107     IUnknown* m_pCFUtilityCar;
00108     IUnknown* m_pCFCruiseCar;
00109
00110     // Pointers to Apartment init data structures.
00111     APT_INIT_DATA* m_paiAptCar;
00112     APT_INIT_DATA* m_paiAptUtilityCar;
00113     APT_INIT_DATA* m_paiAptCruiseCar;
00114
00115     // Some member variables to store apartment thread ids.
00116     DWORD     m_dwAptCar;
00117     DWORD     m_dwAptUtilityCar;
00118     DWORD     m_dwAptCruiseCar;
00119
00120     // An array of handles to the apartment threads.
00121     HANDLE    m_hApts[NUM_APARTMENTS];
00122 };
00123
00124 #endif // __cplusplus
00125
00126 // Allow other internal APTSERVE modules to get at the globals.
00127 extern CServer*  g_pServer;
00128 extern CSendLog* g_pMsgLog;
00129
00130 #endif // SERVER_H
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ConServe/ConServe.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ConServe

ConServe.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CONSERVE.CPP
00003
00004   Summary:   Implementation file for a DLL COM Component server providing
00005              a Ball-related COM Component: DllSndBall. Access to Class
00006              Factories is provided in this module.  This server also
00007              supports self registration and unregistration. CONSERVE is a
00008              thread-safe server for the COBall COM objects.
00009
00010              For a comprehensive tutorial code tour of CONSERVE's contents
00011              and offerings see the tutorial CONSERVE.HTM file. For more
00012              specific technical details on the internal workings see the
00013              comments dispersed throughout the CONSERVE source code. For
00014              more details see CONCLIEN.HTM in the main tutorial directory.
00015
00016   Classes:   none.
00017
00018   Functions: DllMain, DllGetClassObject, DllCanUnloadNow, DllRegisterServer,
00019              DllUnregisterServer.
00020
00021   Origin:    4-6-96: atrent - Editor-inheritance from DLLSERVE.CPP in
00022                the DLLSERVE Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will be calling the COM/OLE Libraries.
00042   We include INITGUID.H only once (here) in the entire DLL because we
00043     will be defining GUIDs and want them as constants in the data segment.
00044   We include APPUTIL.H because we will be building this DLL using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include IBALL.H and BALLGUID.H for the common ball-related
00048     Interface class, GUID, and CLSID specifications.
00049   We include CONSERVE.H because it has the _DLLEXPORT_ controlled import
00050     and export specifications.
00051   We include SERVER.H because it has the necessary internal class and
00052     resource definitions for this DLL.
00053   We include FACTORY.H because it has the necessary internal class factory
00054     declarations for this DLL component server.
00055 ---------------------------------------------------------------------------*/
00056 #include <windows.h>
00057 #include <ole2.h>
00058 #include <initguid.h>
00059 #include <apputil.h>
00060 #include <iBall.h>
00061 #include <ballguid.h>
00062 #define _DLLEXPORT_
00063 #include "conserve.h"
00064 #include "server.h"
00065 #include "factory.h"
00066
00067
00068 // Global variable definitions. Some Initialized in DllMain() below.
00069
00070 // We encapsulate the control of this COM server (eg, lock and object
00071 // counting) in a server control C++ object.  Here is it's pointer.
00072 CServer* g_pServer = NULL;
00073
00074
00075 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00076   Function: UnicodeOk
00077
00078   Summary:  Checks if the platform will handle unicode versions of
00079             Win32 string API calls.
00080
00081   Args:     void
00082
00083   Returns:  BOOL
00084               TRUE if unicode support; FALSE if not.
00085 ------------------------------------------------------------------------F-F*/
00086 BOOL UnicodeOk(void)
00087 {
00088   BOOL bOk = TRUE;
00089   TCHAR szUserName[MAX_STRING_LENGTH];
00090   DWORD dwSize = MAX_STRING_LENGTH;
00091
00092   if (!GetUserName(szUserName, &dwSize))
00093     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00094
00095   return bOk;
00096 }
00097
00098
00099 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00100   Function: DllMain
00101
00102   Summary:  Just as WinMain is for an EXE application, this DllMain
00103             function is the main entry point for this DLL.  It is called
00104             when the DLL is loaded by a process, and when new threads are
00105             created by a process that has already loaded this DLL.
00106             DllMain is also called when threads of a process that has
00107             loaded the DLL exit cleanly and when the process itself
00108             unloads the DLL.
00109
00110             If you want to use C runtime libraries, keep this function
00111             named "DllMain" and you won't have to do anything special to
00112             initialize the runtime libraries.
00113
00114             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
00115             to determine if the DLL should remain loaded, or should be
00116             immediately unloaded depending upon whether the DLL could be
00117             initialized properly.  For all other values of fdwReason, the
00118             return value is ignored.
00119
00120   Args:     HINSTANCE hDLLInst,
00121               Instance handle of the DLL.
00122             DWORD fdwReason,
00123               Process attach/detach or thread attach/detach.
00124               Reason for calling.
00125             LPVOID lpvReserved)
00126               Reserved and not used.
00127
00128   Returns:  BOOL,
00129               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
00130               TRUE  -  Used to signify that the DLL should remain loaded.
00131               FALSE -  Used to signify that the DLL should be
00132                 immediately unloaded.
00133 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00134 BOOL WINAPI DllMain(
00135               HINSTANCE hDllInst,
00136               DWORD fdwReason,
00137               LPVOID lpvReserved)
00138 {
00139   BOOL bResult = TRUE;
00140
00141   // Dispatch this main call based on the reason it was called.
00142   switch (fdwReason)
00143   {
00144     case DLL_PROCESS_ATTACH:
00145       // The DLL is being loaded for the first time by a given process.
00146       // Perform per-process initialization here.  If the initialization
00147       // is successful, return TRUE; if unsuccessful, return FALSE.
00148       bResult = FALSE;
00149       if (UnicodeOk())
00150       {
00151         // Instantiate the CServer utility class.
00152         g_pServer = new CServer;
00153         if (NULL != g_pServer)
00154         {
00155           // Remember the DLL Instance handle.
00156           g_pServer->m_hDllInst = hDllInst;
00157           bResult = TRUE;
00158         }
00159       }
00160       break;
00161
00162     case DLL_PROCESS_DETACH:
00163       // The DLL is being unloaded by a given process.  Do any
00164       // per-process clean up here, such as undoing what was done in
00165       // DLL_PROCESS_ATTACH.  The return value is ignored.
00166       DELETE_POINTER(g_pServer);
00167       break;
00168
00169     case DLL_THREAD_ATTACH:
00170       // A thread is being created in a process that has already loaded
00171       // this DLL.  Perform any per-thread initialization here.  The
00172       // return value is ignored.
00173       break;
00174
00175     case DLL_THREAD_DETACH:
00176       // A thread is exiting cleanly in a process that has already
00177       // loaded this DLL.  Perform any per-thread clean up here.  The
00178       // return value is ignored.
00179       break;
00180
00181     default:
00182       break;
00183   }
00184
00185   return (bResult);
00186 }
00187
00188
00189 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00190   Function: DllGetClassObject
00191
00192   Summary:  The standard exported function that the COM service library
00193             uses to obtain an object class of the class factory for a
00194             specified component provided by this server DLL.
00195
00196   Args:     REFCLSID rclsid,
00197               [in] The CLSID of the requested Component.
00198             REFIID riid,
00199               [in] GUID of the requested interface on the Class Factory.
00200             PPVOID ppv)
00201               [out] Address of the caller's pointer variable that will
00202               receive the requested interface pointer.
00203
00204   Returns:  HRESULT
00205               E_FAIL if requested component isn't supported.
00206               E_OUTOFMEMORY if out of memory.
00207               Error code out of the QueryInterface.
00208 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00209 STDAPI DllGetClassObject(
00210          REFCLSID rclsid,
00211          REFIID riid,
00212          PPVOID ppv)
00213 {
00214   HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
00215   IUnknown* pCob = NULL;
00216
00217   if (CLSID_DllSndBall == rclsid)
00218   {
00219     hr = E_OUTOFMEMORY;
00220     pCob = new CFBall(NULL, g_pServer);
00221   }
00222
00223   if (NULL != pCob)
00224   {
00225     g_pServer->ObjectsUp();
00226     hr = pCob->QueryInterface(riid, ppv);
00227     if (FAILED(hr))
00228     {
00229       g_pServer->ObjectsDown();
00230       DELETE_POINTER(pCob);
00231     }
00232   }
00233
00234   return hr;
00235 }
00236
00237
00238 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00239   Function: DllCanUnloadNow
00240
00241   Summary:  The standard exported function that the COM service library
00242             uses to determine if this server DLL can be unloaded.
00243
00244   Args:     void.
00245
00246   Returns:  HRESULT
00247               S_OK if this DLL server can be unloaded.
00248               S_FALSE if this DLL can not be unloaded.
00249 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00250 STDAPI DllCanUnloadNow(void)
00251 {
00252   HRESULT hr;
00253
00254   // We return S_OK of there are no longer any living objects AND
00255   // there are no outstanding client locks on this server.
00256   hr = g_pServer->CanUnloadNow();
00257
00258   return hr;
00259 }
00260
00261
00262 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00263   Function: DllRegisterServer
00264
00265   Summary:  The standard exported function that can be called to command
00266             this DLL server to register itself in the system registry.
00267
00268   Args:     void.
00269
00270   Returns:  HRESULT
00271               NOERROR
00272 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00273 STDAPI DllRegisterServer(void)
00274 {
00275   HRESULT  hr = NOERROR;
00276   TCHAR    szID[GUID_SIZE+1];
00277   TCHAR    szCLSID[GUID_SIZE+32];
00278   TCHAR    szModulePath[MAX_PATH];
00279
00280   // Obtain the path to this module's executable file for later use.
00281   GetModuleFileName(
00282     g_pServer->m_hDllInst,
00283     szModulePath,
00284     sizeof(szModulePath)/sizeof(TCHAR));
00285
00286   /*-------------------------------------------------------------------------
00287     Create registry entries for the DllSndBall Component.
00288   -------------------------------------------------------------------------*/
00289   // Create some base key strings.
00290   StringFromGUID2(CLSID_DllSndBall, szID, GUID_SIZE);
00291   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00292   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00293
00294   // Create ProgID keys.
00295   SetRegKeyValue(
00296     TEXT("CTS.DllSndBall.1"),
00297     NULL,
00298     TEXT("DllSndBall Component - CONSERVE Code Sample"));
00299   SetRegKeyValue(
00300     TEXT("CTS.DllSndBall.1"),
00301     TEXT("CLSID"),
00302     szID);
00303
00304   // Create VersionIndependentProgID keys.
00305   SetRegKeyValue(
00306     TEXT("CTS.DllSndBall"),
00307     NULL,
00308     TEXT("DllSndBall Component - CONSERVE Code Sample"));
00309   SetRegKeyValue(
00310     TEXT("CTS.DllSndBall"),
00311     TEXT("CurVer"),
00312     TEXT("CTS.DllSndBall.1"));
00313   SetRegKeyValue(
00314     TEXT("CTS.DllSndBall"),
00315     TEXT("CLSID"),
00316     szID);
00317
00318   // Create entries under CLSID.
00319   SetRegKeyValue(
00320     szCLSID,
00321     NULL,
00322     TEXT("DllSndBall Component - CONSERVE Code Sample"));
00323   SetRegKeyValue(
00324     szCLSID,
00325     TEXT("ProgID"),
00326     TEXT("CTS.DllSndBall.1"));
00327   SetRegKeyValue(
00328     szCLSID,
00329     TEXT("VersionIndependentProgID"),
00330     TEXT("CTS.DllSndBall"));
00331   SetRegKeyValue(
00332     szCLSID,
00333     TEXT("NotInsertable"),
00334     NULL);
00335   SetRegKeyValue(
00336     szCLSID,
00337     TEXT("InprocServer32"),
00338     szModulePath);
00339   AddRegNamedValue(
00340     szCLSID,
00341     TEXT("InprocServer32"),
00342     TEXT("ThreadingModel"),
00343     TEXT("Apartment"));
00344
00345   return hr;
00346 }
00347
00348
00349 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00350   Function: DllUnregisterServer
00351
00352   Summary:  The standard exported function that can be called to command
00353             this DLL server to unregister itself from the system Registry.
00354
00355   Args:     void.
00356
00357   Returns:  HRESULT
00358               NOERROR
00359 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00360 STDAPI DllUnregisterServer(void)
00361 {
00362   HRESULT  hr = NOERROR;
00363   TCHAR    szID[GUID_SIZE+1];
00364   TCHAR    szCLSID[GUID_SIZE+32];
00365   TCHAR    szTemp[MAX_PATH+GUID_SIZE];
00366
00367   /*-------------------------------------------------------------------------
00368     Delete registry entries for the SndBall Component.
00369   -------------------------------------------------------------------------*/
00370   //Create some base key strings.
00371   StringFromGUID2(CLSID_DllSndBall, szID, GUID_SIZE);
00372   lstrcpyn(szCLSID, TEXT("CLSID\\"), sizeof(szCLSID)/sizeof(TCHAR));
00373   lstrncat(szCLSID, szID, sizeof(szCLSID)/sizeof(TCHAR) - lstrlen(szCLSID));
00374
00375   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllSndBall\\CurVer"));
00376   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllSndBall\\CLSID"));
00377   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllSndBall"));
00378
00379   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllSndBall.1\\CLSID"));
00380   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.DllSndBall.1"));
00381
00382   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
00383   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00384
00385   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
00386   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00387
00388   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
00389   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00390
00391   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
00392   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
00393
00394   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
00395
00396   return hr;
00397 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: TabletPC/InkErase/C#/InkErase.cs Source File

  • TabletPC
  • InkErase
  • C#

InkErase.cs

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 //
00003 //  This is part of the Microsoft Tablet PC Platform SDK
00004 //  Copyright (C) 2002 Microsoft Corporation
00005 //  All rights reserved.
00006 //
00007 //  This source code is only intended as a supplement to the
00008 //  Microsoft Tablet PC Platform SDK Reference and related electronic
00009 //  documentation provided with the Software Development Kit.
00010 //  See these sources for more detailed information.
00011 //
00012 //  File: InkErase.cs
00013 //  Simple Ink Erasing Sample Application
00014 //
00015 //  This sample program demonstrates how to erase ink using hit
00016 //  testing.  It has the following modes:
00017 //
00018 //  1.  Ink:  Allows the user to ink strokes.
00019 //  2.  Erase at Cusps:  Displays the cusps as red points drawn over the
00020 //      strokes.  The application reports a hit when the mouse is pressed
00021 //      and a circular region around the cursor intersects the stroke.
00022 //      When a hit occurs, the application splits the stroke at the
00023 //      cusps on either side of the hit and erases the corresponding stroke
00024 //      segment.
00025 //  3.  Erase at Intersections:  Same as 2, except stroke intersections
00026 //      are used.
00027 //  4.  Erase Strokes:  Uses hit testing to determine which strokes to delete.
00028 //
00029 //  This sample application supports the inverted pen - if the
00030 //  pen is inverted in Ink mode, stroke erasing is performed.
00031 //
00032 //  The features used are:  InkCollector, Ink hit testing,
00033 //  deleting and splitting strokes, finding cusps and intersections,
00034 //  and using the inverted pen.
00035 //
00036 //--------------------------------------------------------------------------
00037 using System;
00038 using System.Drawing;
00039 using System.Windows.Forms;
00040
00041 // The Ink namespace, which contains the Tablet PC Platform API
00042 using Microsoft.Ink;
00043
00044 namespace InkErase
00045 {
00046
00047     /// <summary>
00048     /// Enumeration of all possible application modes:
00049     ///
00050     ///   Ink:             The user is drawing new strokes
00051     ///   CuspErase:       The user is erasing at cusps
00052     ///   IntersectErase:  The user is erasing at intersections
00053     ///   StrokeErase:     The user is erasing strokes
00054     ///
00055     /// </summary>
00056     public enum ApplicationMode
00057     {
00058         Ink,
00059         CuspErase,
00060         IntersectErase,
00061         StrokeErase
00062     }
00063
00064     /// <summary>
00065     /// Summary description for InkErase.
00066     /// </summary>
00067     public class InkErase : System.Windows.Forms.Form
00068     {
00069     // Declare the Ink Collector object
00070         private InkCollector myInkCollector;
00071
00072         // Declare constant for the pen width used by this application.
00073         // Note that this constant is in high metric units (1 unit = .01mm)
00074         private const float MediumInkWidth = 100;
00075
00076         // Declare constant for the size of the hit test circle radius.
00077         // Note that this constant is in high metric units (1 unit = .01mm)
00078         private const float HitTestRadius = 30;
00079
00080         // Delcare constant for the radius of the painted cusp/intersection points
00081         private const int StrokePointRadius = 3;
00082
00083         // Declare constant for the index of the x and y packet values
00084         private const int XPacketIndex = 0;
00085         private const int YPacketIndex = 1;
00086
00087         // The current application mode:  inking, cusp erasing,
00088         // intersection erasing, or stroke erasing
00089         ApplicationMode mode = ApplicationMode.Ink;
00090
00091         #region Standard Template Code
00092
00093         private System.Windows.Forms.MenuItem miMainMode;
00094         private System.Windows.Forms.MenuItem miInk;
00095         private System.Windows.Forms.MenuItem miMainAction;
00096         private System.Windows.Forms.MenuItem miClear;
00097         private System.Windows.Forms.MenuItem miExit;
00098         private System.Windows.Forms.MenuItem miIntersectErase;
00099         private System.Windows.Forms.MenuItem miStrokeErase;
00100         private System.Windows.Forms.MainMenu miMain;
00101         private System.Windows.Forms.MenuItem miCuspErase;
00102         private System.Windows.Forms.MenuItem miSeparator;
00103         private System.ComponentModel.Container components = null;
00104         #endregion
00105
00106         /// <summary>
00107         /// The InkErase Sample Application form class
00108         /// </summary>
00109         public InkErase()
00110         {
00111             #region Standard Template Code
00112             //
00113             // Required for Windows Form Designer support
00114             //
00115             InitializeComponent();
00116             #endregion
00117         }
00118
00119         #region Standard Template Code
00120         /// <summary>
00121         /// Clean up any resources being used.
00122         /// </summary>
00123         protected override void Dispose( bool disposing )
00124         {
00125             if( disposing )
00126             {
00127                 if (components != null)
00128                 {
00129                     components.Dispose();
00130                 }
00131             }
00132             base.Dispose( disposing );
00133         }
00134         #endregion
00135
00136     #region Windows Form Designer generated code
00137         /// <summary>
00138         /// Required method for Designer support - do not modify
00139         /// the contents of this method with the code editor.
00140         /// </summary>
00141         private void InitializeComponent()
00142         {
00143             this.miMain = new System.Windows.Forms.MainMenu();
00144             this.miMainAction = new System.Windows.Forms.MenuItem();
00145             this.miClear = new System.Windows.Forms.MenuItem();
00146             this.miSeparator = new System.Windows.Forms.MenuItem();
00147             this.miExit = new System.Windows.Forms.MenuItem();
00148             this.miMainMode = new System.Windows.Forms.MenuItem();
00149             this.miInk = new System.Windows.Forms.MenuItem();
00150             this.miCuspErase = new System.Windows.Forms.MenuItem();
00151             this.miIntersectErase = new System.Windows.Forms.MenuItem();
00152             this.miStrokeErase = new System.Windows.Forms.MenuItem();
00153             //
00154             // miMain
00155             //
00156             this.miMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00157                                                                                    this.miMainAction,
00158                                                                                    this.miMainMode});
00159             //
00160             // miMainAction
00161             //
00162             this.miMainAction.Index = 0;
00163             this.miMainAction.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00164                                                                                          this.miClear,
00165                                                                                          this.miSeparator,
00166                                                                                          this.miExit});
00167             this.miMainAction.Text = "&Action";
00168             //
00169             // miClear
00170             //
00171             this.miClear.Index = 0;
00172             this.miClear.Text = "&Clear";
00173             this.miClear.Click += new System.EventHandler(this.miClear_Click);
00174             //
00175             // miSeparator
00176             //
00177             this.miSeparator.Index = 1;
00178             this.miSeparator.Text = "-";
00179             //
00180             // miExit
00181             //
00182             this.miExit.Index = 2;
00183             this.miExit.Text = "E&xit";
00184             this.miExit.Click += new System.EventHandler(this.miExit_Click);
00185             //
00186             // miMainMode
00187             //
00188             this.miMainMode.Index = 1;
00189             this.miMainMode.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00190                                                                                        this.miInk,
00191                                                                                        this.miCuspErase,
00192                                                                                        this.miIntersectErase,
00193                                                                                        this.miStrokeErase});
00194             this.miMainMode.Text = "&Mode";
00195             //
00196             // miInk
00197             //
00198             this.miInk.Checked = true;
00199             this.miInk.Index = 0;
00200             this.miInk.RadioCheck = true;
00201             this.miInk.Shortcut = System.Windows.Forms.Shortcut.CtrlI;
00202             this.miInk.Text = "&Ink";
00203             this.miInk.Click += new System.EventHandler(this.miInk_Click);
00204             //
00205             // miCuspErase
00206             //
00207             this.miCuspErase.Index = 1;
00208             this.miCuspErase.RadioCheck = true;
00209             this.miCuspErase.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
00210             this.miCuspErase.Text = "Erase at &Cusps";
00211             this.miCuspErase.Click += new System.EventHandler(this.miCuspErase_Click);
00212             //
00213             // miIntersectErase
00214             //
00215             this.miIntersectErase.Index = 2;
00216             this.miIntersectErase.RadioCheck = true;
00217             this.miIntersectErase.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
00218             this.miIntersectErase.Text = "Erase at I&ntersections";
00219             this.miIntersectErase.Click += new System.EventHandler(this.miIntersectErase_Click);
00220             //
00221             // miStrokeErase
00222             //
00223             this.miStrokeErase.Index = 3;
00224             this.miStrokeErase.RadioCheck = true;
00225             this.miStrokeErase.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
00226             this.miStrokeErase.Text = "Erase &Strokes";
00227             this.miStrokeErase.Click += new System.EventHandler(this.miStrokeErase_Click);
00228             //
00229             // InkErase
00230             //
00231             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00232             this.ClientSize = new System.Drawing.Size(292, 267);
00233             this.Menu = this.miMain;
00234             this.Name = "InkErase";
00235             this.Text = "InkErase";
00236             this.Load += new System.EventHandler(this.InkErase_Load);
00237             this.Paint += new System.Windows.Forms.PaintEventHandler(this.InkErase_OnPaint);
00238             this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.InkErase_OnMouseMove);
00239
00240         }
00241     #endregion
00242
00243         #region Standard Template Code
00244         /// <summary>
00245         /// The main entry point for the application.
00246         /// </summary>
00247         [STAThread]
00248         static void Main()
00249         {
00250             Application.Run(new InkErase());
00251         }
00252         #endregion
00253
00254         /// <summary>
00255         /// Event Handle from form's Load event
00256         /// </summary>
00257         /// <param name="sender">The control that raised the event.</param>
00258         /// <param name="e">The event arguments.</param>
00259         private void InkErase_Load(object sender, System.EventArgs e)
00260         {
00261             // Start the application in inking mode
00262             mode = ApplicationMode.Ink;
00263
00264             // Create a new ink collector and assign it to this form's window
00265             myInkCollector = new InkCollector(Handle);
00266
00267             // Turn off auto-redrawing since this sample application
00268             // needs to display the stroke cusps as red points over the strokes.
00269             // If autoredraw is enabled, the strokes will be drawn over
00270             // the red points, which will make the cusps hard to see.
00271             myInkCollector.AutoRedraw = false;
00272
00273             // Set the pen width to be a medium width
00274             myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;
00275
00276             // Hook event handle for Cursor down event to myInkCollector_CursorDown.
00277             // This is necessary since the application needs to check if the cursor
00278             // is inverted and use the result to determine the visibility of the ink.
00279             myInkCollector.CursorDown += new InkCollectorCursorDownEventHandler(myInkCollector_CursorDown);
00280
00281             // Hook event handle for NewPackets event to myInkCollector_NewPackets.
00282             // This is necessary since the application needs to examine new packets
00283             // when the cursor is inverted and use them to determine whether
00284             // any strokes should be erased.
00285             myInkCollector.NewPackets += new InkCollectorNewPacketsEventHandler(myInkCollector_NewPackets);
00286
00287             // Hook event handle for the Stroke event to myInkCollector_Stroke.
00288             // This is necessary since the application needs to cancel strokes drawn
00289             // while the cursor is inverted.
00290             myInkCollector.Stroke += new InkCollectorStrokeEventHandler(myInkCollector_Stroke);
00291
00292             // Turn the ink collector on
00293             myInkCollector.Enabled = true;
00294         }
00295
00296         /// <summary>
00297         /// Event Handle from MouseMove event.
00298         /// </summary>
00299         /// <param name="sender">The control that raised the event.</param>
00300         /// <param name="e">The event arguments.</param>
00301         private void InkErase_OnMouseMove(object sender, MouseEventArgs e)
00302         {
00303             // If the application is in erase mode and a mouse button is
00304             // pressed, perform a hit test to determine which stroke segments
00305             // to erase (if any).
00306             if ( (ApplicationMode.Ink != mode) && (MouseButtons.None != MouseButtons) )
00307             {
00308                 Point pt = new Point(e.X, e.Y);
00309
00310                 // Convert the specified point from pixel to ink space coordinates
00311                 myInkCollector.Renderer.PixelToInkSpace(this.Handle, ref pt);
00312
00313                 switch(mode)
00314                 {
00315                     case ApplicationMode.CuspErase:
00316                         EraseAtCusps(pt);
00317                         break;
00318                     case ApplicationMode.IntersectErase:
00319                         EraseAtIntersections(pt);
00320                         break;
00321                     case ApplicationMode.StrokeErase:
00322                         EraseStrokes(pt,null);
00323                         break;
00324                 }
00325             }
00326         }
00327
00328         /// <summary>
00329         /// Event Handle from Paint event.  It is necessary to handle the
00330         /// paint event since this sample needs to draw red points to indicate
00331         /// the strokes' cusps.
00332         /// </summary>
00333         /// <param name="sender">The control that raised the event.</param>
00334         /// <param name="e">The event arguments.</param>
00335         private void InkErase_OnPaint(object sender, PaintEventArgs e)
00336         {
00337             // Get the strokes to paint from the ink
00338             Strokes strokesToPaint = myInkCollector.Ink.Strokes;
00339
00340             // Draw the strokes - note that it is necessary to manually
00341             // paint the strokes since auto-redrawing is set to false.
00342             myInkCollector.Renderer.Draw(e.Graphics, strokesToPaint);
00343
00344             switch (mode)
00345             {
00346                 case ApplicationMode.CuspErase:
00347                     PaintCusps(e.Graphics, strokesToPaint);
00348                     break;
00349                 case ApplicationMode.IntersectErase:
00350                     PaintIntersections(e.Graphics, strokesToPaint);
00351                     break;
00352             }
00353         }
00354
00355         /// <summary>
00356         /// Event Handle from Action->Clear menu.
00357         /// </summary>
00358         /// <param name="sender">The control that raised the event.</param>
00359         /// <param name="e">The event arguments.</param>
00360         private void miClear_Click(object sender, System.EventArgs e)
00361         {
00362             Strokes strokesToDelete = myInkCollector.Ink.Strokes;
00363
00364             // Check to ensure that the ink collector isn't currently
00365             // in the middle of a stroke before clearing the ink.
00366             // Deleting a stroke that is currently being collected
00367             // will result in an error condition.
00368             if (!myInkCollector.CollectingInk)
00369             {
00370                 myInkCollector.Ink.DeleteStrokes(strokesToDelete);
00371
00372                 miInk_Click(sender, e);
00373             }
00374             else
00375             {
00376                 MessageBox.Show("Cannot clear ink while the ink collector is busy.");
00377             }
00378         }
00379
00380         /// <summary>
00381         /// Event Handle from Action->Exit menu.
00382         /// </summary>
00383         /// <param name="sender">The control that raised the event.</param>
00384         /// <param name="e">The event arguments.</param>
00385         private void miExit_Click(object sender, System.EventArgs e)
00386         {
00387             myInkCollector.Enabled = false;
00388             Application.Exit();
00389         }
00390
00391         /// <summary>
00392         /// Event Handle from Mode->Ink menu.
00393         /// </summary>
00394         /// <param name="sender">The control that raised the event.</param>
00395         /// <param name="e">The event arguments.</param>
00396         private void miInk_Click(object sender, System.EventArgs e)
00397         {
00398             UpdateApplicationMode(ApplicationMode.Ink);
00399         }
00400
00401         /// <summary>
00402         /// Event Handle from Mode->Cusp Erase menu.
00403         /// </summary>
00404         /// <param name="sender">The control that raised the event.</param>
00405         /// <param name="e">The event arguments.</param>
00406         private void miCuspErase_Click(object sender, System.EventArgs e)
00407         {
00408             UpdateApplicationMode(ApplicationMode.CuspErase);
00409         }
00410
00411         /// <summary>
00412         /// Event Handle from Mode->Intersect Erase menu.
00413         /// </summary>
00414         /// <param name="sender">The control that raised the event.</param>
00415         /// <param name="e">The event arguments.</param>
00416         private void miIntersectErase_Click(object sender, System.EventArgs e)
00417         {
00418              UpdateApplicationMode(ApplicationMode.IntersectErase);
00419         }
00420
00421         /// <summary>
00422         /// Event Handle from Mode->Stroke Erase menu.
00423         /// </summary>
00424         /// <param name="sender">The control that raised the event.</param>
00425         /// <param name="e">The event arguments.</param>
00426         private void miStrokeErase_Click(object sender, System.EventArgs e)
00427         {
00428             UpdateApplicationMode(ApplicationMode.StrokeErase);
00429         }
00430
00431         /// <summary>
00432         /// Helper method to update the application mode
00433         /// </summary>
00434         /// <param name="newMode">The new mode</param>
00435         private void UpdateApplicationMode(ApplicationMode newMode)
00436         {
00437             // Turn on/off the ink collector
00438             myInkCollector.Enabled = (ApplicationMode.Ink == newMode);
00439
00440             // Update the state of the Ink and Erase menu items
00441             miInk.Checked = (ApplicationMode.Ink == newMode);
00442             miCuspErase.Checked  = (ApplicationMode.CuspErase == newMode);
00443             miIntersectErase.Checked = (ApplicationMode.IntersectErase == newMode);
00444             miStrokeErase.Checked = (ApplicationMode.StrokeErase == newMode);
00445
00446             mode = newMode;
00447
00448             Refresh();
00449         }
00450
00451         /// <summary>
00452         ///  Event Handle from Cursor event
00453         /// </summary>
00454         /// <param name="sender">The control that raised the event.</param>
00455         /// <param name="e">The event arguments.</param>
00456         public void myInkCollector_CursorDown(object sender, InkCollectorCursorDownEventArgs e)
00457         {
00458             // If the pen is inverted, this application will perform stroke
00459             // erasing; since we do not want to show the pen while the user
00460             // is erasing, make this stroke transparent.
00461             if (e.Cursor.Inverted)
00462             {
00463                 e.Stroke.DrawingAttributes.Transparency = 255;
00464             }
00465         }
00466
00467         /// <summary>
00468         /// Event Handler from Ink Collector's NewPackets event
00469         ///
00470         /// This event is fired when the Ink Collector receives
00471         /// new packet data.
00472         /// </summary>
00473         /// <param name="sender">The control that raised the event.</param>
00474         /// <param name="e">The event arguments.</param>
00475         private void myInkCollector_NewPackets(object sender, InkCollectorNewPacketsEventArgs e)
00476         {
00477             // If the cursor is inverted
00478             if (e.Cursor.Inverted)
00479             {
00480
00481                 // retrieve the size of each packet
00482                 int packetSize = e.Stroke.PacketSize;
00483
00484                 Point pt = Point.Empty;
00485
00486                 // Perform a hit test with each point and delete
00487                 // the hit strokes
00488                 for (int i = 0; i < e.PacketCount; i++)
00489                 {
00490                     // retrieve the x and y packet values
00491                     pt.X = e.PacketData[i*packetSize+XPacketIndex];
00492                     pt.Y = e.PacketData[i*packetSize+YPacketIndex];
00493
00494                     EraseStrokes(pt,e.Stroke);
00495                 }
00496             }
00497         }
00498
00499         /// <summary>
00500         ///  Event Handle from Stroke event
00501         /// </summary>
00502         /// <param name="sender">The control that raised the event.</param>
00503         /// <param name="e">The event arguments.</param>
00504         public void myInkCollector_Stroke(object sender, InkCollectorStrokeEventArgs e )
00505         {
00506             if (e.Cursor.Inverted)
00507             {
00508                 e.Cancel = true;
00509             }
00510         }
00511
00512         /// <summary>
00513         /// Helper method to paint the stroke collection's cusps
00514         /// </summary>
00515         /// <param name="g">The graphics object to use for painting</param>
00516         /// <param name="strokesToPaint">The collection of strokes to paint</param>
00517         private void PaintCusps(Graphics g, Strokes strokesToPaint)
00518         {
00519             // now draw PolylineCusp points
00520             foreach (Stroke currentStroke in strokesToPaint)
00521             {
00522
00523                 // Retrieve the cusps of the stroke.  The cusps mark the points where
00524                 // the stroke changes direction abruptly.  A segment is defined as the
00525                 // points between two cusps.
00526                 int[] cusps = currentStroke.PolylineCusps;
00527
00528                 // Draw each cusp in the stroke
00529                 foreach (int i in cusps)
00530                 {
00531
00532                     // Get the X, Y position of the cusp
00533                     Point pt = currentStroke.GetPoint(i);
00534
00535                     // Convert the X, Y position to Window based pixel coordinates
00536                     myInkCollector.Renderer.InkSpaceToPixel(g, ref pt);
00537
00538                     // Draw a red circle as the cusp position
00539                     g.DrawEllipse(Pens.Red, pt.X-3, pt.Y-3, 6, 6);
00540                 }
00541             }
00542         }
00543
00544         /// <summary>
00545         /// Helper method to paint the stroke collection's intersections
00546         /// </summary>
00547         /// <param name="g">The graphics object to use for painting</param>
00548         /// <param name="strokesToPaint">The collection of strokes to paint</param>
00549         private void PaintIntersections(Graphics g, Strokes strokesToPaint)
00550         {
00551             // Draw the intersections of each stroke as little red circles
00552             foreach (Stroke currentStroke in strokesToPaint)
00553             {
00554
00555                 // Get the intersections of the stroke
00556                 float[] intersections = currentStroke.FindIntersections(strokesToPaint);
00557
00558                 Point[] points = currentStroke.GetPoints();
00559
00560                 // Draw each intersection in the stroke
00561                 foreach (float fi in intersections)
00562                 {
00563                     // Get the point before the FINDEX
00564                     Point ptIntersect = currentStroke.GetPoint((int)fi);
00565
00566                     // Find the fractional part of the FINDEX
00567                     float fiFraction = fi - (int)fi;
00568
00569                     // if the fi does not have a fractional part, we have already
00570                     // found the intersection point.  Otherwise, use the FINDEX to
00571                     // calculate the interpolated intersection point on the stroke
00572                     if (fiFraction > 0.0f)
00573                     {
00574                         Point ptNextIntersect = currentStroke.GetPoint((int)fi + 1);
00575                         ptIntersect.X += (int)((ptNextIntersect.X - ptIntersect.X) * fiFraction);
00576                         ptIntersect.Y += (int)((ptNextIntersect.Y - ptIntersect.Y) * fiFraction);
00577
00578                     }
00579
00580                     // Convert the X, Y position to Window based pixel coordinates
00581                     myInkCollector.Renderer.InkSpaceToPixel(g, ref ptIntersect);
00582
00583                     // Draw a red circle as the intersection position
00584                     g.DrawEllipse(Pens.Red, ptIntersect.X-3, ptIntersect.Y-3, 6, 6);
00585                 }
00586             }
00587         }
00588
00589         /// <summary>
00590         /// Helper method that performs a hit test using the specified point.
00591         /// When a hit occurs, the application splits the stroke at the cusps
00592         /// on either side of the hit and erases the corresponding stroke segment.
00593         /// </summary>
00594         /// <param name="pt">The point to use for hit testing.</param>
00595         private void EraseAtCusps(Point pt)
00596         {
00597
00598             // Declare the collection of strokes returned from HitTest
00599             Strokes strokesHit = null;
00600
00601             // Use HitTest to find the collection of strokes that are intersected
00602             // by the point.  The HitTestRadius constant is used to specify the
00603             // radius of the hit test circle in ink space coordinates (1 unit = .01mm).
00604       strokesHit = myInkCollector.Ink.HitTest(pt, HitTestRadius);
00605
00606             // Loop over each stroke returned from the hit test to determine
00607             // which portion to erase...
00608             foreach (Stroke currentStroke in strokesHit)
00609             {
00610
00611                 // Retrieve the cusps of the stroke.  The cusps mark the points where
00612                 // the stroke changes direction abruptly.  A segment is defined as the
00613                 // points between two cusps.
00614                 int[] cusps = currentStroke.PolylineCusps;
00615
00616                 // If there are 1 or two cusps, it's a single stroke - delete the
00617                 // entire stroke.
00618                 if (cusps.Length <= 2)
00619                 {
00620                     myInkCollector.Ink.DeleteStroke(currentStroke);
00621                 }
00622
00623                 // If there are more than 2 cusps, determine which cusps bound the
00624                 // hit-tested portion of the stroke, split the stroke at these cusps,
00625                 // and delete the stroke that defines the segment we hit-tested.
00626                 else
00627                 {
00628                     // Get the FINDEX of the nearest point on the stroke.  An FINDEX
00629                     // is a float value representing a location somewhere between two
00630                     // points in the stroke.  For instance, 0.0 is the first point in
00631                     // the stroke. 1.0 is the second point in the stroke. 0.5 is halfway
00632                     // between the first and second points.
00633                     float findex = currentStroke.NearestPoint(pt);
00634
00635                     // Declare the stroke segment to delete
00636                     Stroke strokeToDelete = null;
00637
00638                     // Cycle through each cusp of the stroke to determine
00639                     // which cusps bound the hit-tested portion of the stroke...
00640                     for(int i = cusps.Length-2; i>=0; i--)
00641                     {
00642                         // If this cusp is less than the findex, then split
00643                         // the stroke at this cusp and the cusp immediately
00644                         // after it
00645                         if (cusps[i]<=findex)
00646                         {
00647                             // Provided we aren't at the end of the stroke, split at
00648                             // cusp i+1.
00649                             if (i < (cusps.Length-2))
00650                             {
00651                                 strokeToDelete = currentStroke.Split(cusps[i+1]);
00652                             }
00653
00654                             // If the hit occurred between the first and second cusp,
00655                             // delete the stroke.  Keep in mind that the stroke has
00656                             // already been split at index 1, so the delete will only
00657                             // remove the beginning portion of the stroke (as desired).
00658                             if (i==0)
00659                             {
00660                                 myInkCollector.Ink.DeleteStroke(currentStroke);
00661                             }
00662                             // Otherwise, split the stroke at the current cusp and
00663                             // delete the result.  Keep in mind that the stroke has
00664                             // already been split at index i+1, so the delete will
00665                             // remove the segment from cusp i to i+1.
00666                             else
00667                             {
00668                                 strokeToDelete = currentStroke.Split(cusps[i]);
00669                                 myInkCollector.Ink.DeleteStroke(strokeToDelete);
00670                             }
00671
00672                             break;
00673                         }
00674                     }
00675                 }
00676             }
00677
00678             if (strokesHit.Count > 0)
00679             {
00680                 // Repaint the screen to reflect the change
00681                 this.Refresh();
00682             }
00683         }
00684
00685         /// <summary>
00686         /// Helper method that performs a hit test using the specified point.
00687         /// When a hit occurs, the application splits the stroke at the intersections
00688         /// on either side of the hit and erases the corresponding stroke segment.
00689         /// </summary>
00690         /// <param name="pt">The point to use for hit testing.</param>
00691         private void EraseAtIntersections(Point pt)
00692         {
00693
00694             // Use HitTest to find the collection of strokes that are intersected
00695             // by the point.  The HitTestRadius constant is used to specify the
00696             // radius of the hit test circle in ink space coordinates (1 unit = .01mm).
00697             Strokes strokesHit = myInkCollector.Ink.HitTest(pt, HitTestRadius);
00698
00699             // Loop over each stroke returned from the hit test to determine
00700             // which portion to erase...
00701             foreach (Stroke currentStroke in strokesHit)
00702             {
00703
00704                 // Retrieve the intersection of the stroke.
00705                 float[] intersections = currentStroke.FindIntersections(myInkCollector.Ink.Strokes);
00706
00707                 // If there aren't any intersections, delete the entire stroke.
00708                 if (intersections.Length <= 0)
00709                 {
00710                     myInkCollector.Ink.DeleteStroke(currentStroke);
00711                 }
00712
00713                 // If there is at least one intersection, determine which
00714                 // intersections bound the hit-tested portion of the stroke,
00715                 // split the stroke at these intersections, and delete the stroke
00716                 // that defines the segment we hit-tested.
00717                 else
00718                 {
00719                     // Get the FINDEX of the nearest point on the stroke.  An FINDEX
00720                     // is a float value representing a location somewhere between two
00721                     // points in the stroke.  For instance, 0.0 is the first point in
00722                     // the stroke. 1.0 is the second point in the stroke. 0.5 is halfway
00723                     // between the first and second points.
00724                     float findex = currentStroke.NearestPoint(pt);
00725
00726                     // If the hit occured before the first intersection, split the stroke
00727                     // at the current intersection and delete the beginning of the
00728                     // stroke
00729                     if (findex < intersections[0])
00730                     {
00731                         currentStroke.Split (intersections[0]);
00732                         myInkCollector.Ink.DeleteStroke(currentStroke);
00733                     }
00734                     else
00735                     {
00736                         // Declare the stroke segment to delete
00737                         Stroke strokeToDelete = null;
00738
00739                         // Cycle through each intersection of the stroke to determine
00740                         // which intersections bound the hit-tested portion of the stroke...
00741                         for(int i = intersections.Length-1; i>=0; i--)
00742                         {
00743
00744                             // If this intersection is less than the findex, the intersection
00745                             // occurs between this intersection and the one after it
00746                             if (intersections[i]<=findex)
00747                             {
00748                                 // Provided we aren't at the end of the stroke, split at
00749                                 // intersection i+1.
00750                                 if (i < (intersections.Length-1))
00751                                 {
00752                                     strokeToDelete = currentStroke.Split(intersections[i+1]);
00753                                 }
00754
00755                                 // Split the stroke at the current intersection.  Keep in
00756                                 // mind that the stroke has already been split at index i+1,
00757                                 // so the delete will remove the segment from intersection i
00758                                 // to i+1.
00759                                 strokeToDelete = currentStroke.Split(intersections[i]);
00760                                 myInkCollector.Ink.DeleteStroke(strokeToDelete);
00761
00762                                 break;
00763                             }
00764                         }
00765                     }
00766                 }
00767             }
00768
00769             if (strokesHit.Count > 0)
00770             {
00771                 // Repaint the screen to reflect the change
00772                 this.Refresh();
00773             }
00774         }
00775
00776         /// <summary>
00777         /// Helper method that performs a hit test using the specified point.
00778         /// It deletes all strokes that were hit by the point
00779         /// </summary>
00780         /// <param name="pt">The point to use for hit testing</param>
00781         private void EraseStrokes(Point pt, Stroke currentStroke)
00782         {
00783
00784             // Use HitTest to find the collection of strokes that are intersected
00785             // by the point.  The HitTestRadius constant is used to specify the
00786             // radius of the hit test circle in ink space coordinates (1 unit = .01mm).
00787             Strokes strokesHit = myInkCollector.Ink.HitTest(pt, HitTestRadius);
00788
00789             if (null!=currentStroke && strokesHit.Contains(currentStroke))
00790             {
00791                 strokesHit.Remove(currentStroke);
00792             }
00793
00794             // Delete all strokes that were hit by the point
00795             myInkCollector.Ink.DeleteStrokes(strokesHit);
00796
00797             if (strokesHit.Count > 0)
00798             {
00799                 // Repaint the screen to reflect the change
00800                 this.Refresh();
00801             }
00802         }
00803     }
00804 }
Generated on Wed Nov 13 2024 16:52:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditHost/BrowserHost.h Source File

  • Web
  • Browser
  • EditHost

BrowserHost.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 // BrowserHost.h : Declaration of the CBrowserHost
00006
00007 #ifndef __BROWSERHOST_H_
00008 #define __BROWSERHOST_H_
00009
00010 #include "resource.h"    // main symbols
00011 #include <commctrl.h>
00012 #include <atlwin.h>
00013 #include <exdisp.h>
00014 #include <mshtml.h>
00015
00016 /////////////////////////////////////////////////////////////////////////////
00017 // CBrowserHost
00018 class ATL_NO_VTABLE CBrowserHost :
00019   public CComObjectRootEx<CComSingleThreadModel>,
00020   public CComCoClass<CBrowserHost, &CLSID_BrowserHost>,
00021   public IDispatchImpl<IBrowserHost, &IID_IBrowserHost, &LIBID_EDHOSTLib>,
00022   public CWindowImpl<CBrowserHost>,
00023   public IOleClientSite,
00024   public IOleInPlaceSite,
00025   public IServiceProvider
00026 {
00027 public:
00028   CBrowserHost();
00029
00030 DECLARE_REGISTRY_RESOURCEID(IDR_BROWSERHOST)
00031
00032 DECLARE_PROTECT_FINAL_CONSTRUCT()
00033
00034 BEGIN_COM_MAP(CBrowserHost)
00035   COM_INTERFACE_ENTRY(IBrowserHost)
00036   COM_INTERFACE_ENTRY(IDispatch)
00037   COM_INTERFACE_ENTRY(IOleClientSite)
00038   COM_INTERFACE_ENTRY(IOleWindow)
00039   COM_INTERFACE_ENTRY(IOleInPlaceSite)
00040   COM_INTERFACE_ENTRY(IServiceProvider)
00041   COM_INTERFACE_ENTRY2(DWebBrowserEvents2, IDispatch)
00042 END_COM_MAP()
00043
00044 BEGIN_MSG_MAP(CAtlBrCon)
00045   MESSAGE_HANDLER(WM_CREATE,    OnCreate)
00046   MESSAGE_HANDLER(WM_NCDESTROY, OnNCDestroy)
00047   MESSAGE_HANDLER(WM_SIZE,      OnSize)
00048   MESSAGE_HANDLER(WM_KEYDOWN,   OnKeydown)
00049
00050   // Button Commands
00051   COMMAND_ID_HANDLER(ID_BUTTON1, OnButton1)
00052   COMMAND_ID_HANDLER(ID_BUTTON2, OnButton2)
00053   COMMAND_ID_HANDLER(ID_BUTTON3, OnButton3)
00054   COMMAND_ID_HANDLER(ID_BUTTON4, OnButton4)
00055   COMMAND_ID_HANDLER(ID_BUTTON5, OnButton5)
00056
00057   ALT_MSG_MAP(1) // For subclassed windows - m_wndUrlCombo &m_wndIncrementCombo
00058 END_MSG_MAP()
00059
00060 // IBrowserHost
00061 public:
00062   STDMETHOD(GetHwnd)(long* phwnd);
00063   STDMETHOD(Run)();
00064
00065 protected:
00066   BOOL  m_bEnableCtxMenus;
00067   DWORD m_dwDLControl;
00068   DWORD m_dwCookie;
00069   DWORD m_dwDocHostUIFlags;
00070   DWORD m_dwDocHostUIDblClk;
00071   BOOL  m_bInPlaceActive;
00072   BOOL  m_bAtlBrowserHelp;
00073   BOOL  m_bButton2Down;
00074   BOOL  m_bButton3Down;
00075   BOOL  m_bButton4Down;
00076   BOOL  m_bButton5Down;
00077   LONG  m_lSnapIncrement;
00078   CContainedWindow m_wndUrlCombo;
00079   CContainedWindow m_wndIncrementCombo;
00080   CWindow m_wndStatusBar;
00081   CWindow m_wndToolBar;
00082   LONG m_lGridCookie;
00083
00084   CComQIPtr<IGrid, &IID_IGrid> m_spGrid;
00085   CComQIPtr<ISnap, &IID_ISnap> m_spSnap;
00086
00087
00088   CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> m_spWebBrowser;
00089   CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> m_spDoc;
00090   CComQIPtr<IOleInPlaceObject, &IID_IOleInPlaceObject> m_spInPlaceObject;
00091   CComQIPtr<IOleCommandTarget, &IID_IOleCommandTarget> m_spOleCmdTarg;
00092
00093   LRESULT OnCreate(UINT, WPARAM, LPARAM, BOOL&);
00094   LRESULT OnSize(UINT, WPARAM, LPARAM, BOOL&);
00095   LRESULT OnNCDestroy(UINT, WPARAM, LPARAM, BOOL&);
00096   LRESULT OnKeydown(UINT, WPARAM wParam, LPARAM lParam, BOOL&);
00097
00098
00099   LRESULT OnButton1(WORD, WORD, HWND, BOOL&);
00100   LRESULT OnButton2(WORD, WORD, HWND, BOOL&);
00101   LRESULT OnButton3(WORD, WORD, HWND, BOOL&);
00102   LRESULT OnButton4(WORD, WORD, HWND, BOOL&);
00103   LRESULT OnButton5(WORD, WORD, HWND, BOOL&);
00104
00105   STDMETHOD(Stop)();
00106
00107 private:
00108   void CreateToolbar();
00109 public:
00110
00111 // IDispatch Methods
00112 private:
00113   STDMETHOD(Invoke)(DISPID dispidMember,
00114             REFIID riid,
00115             LCID lcid,
00116             WORD wFlags,
00117             DISPPARAMS* pdispparams,
00118             VARIANT * pvarResult,
00119             EXCEPINFO* pexcepinfo,
00120             UINT* puArgErr);
00121
00122 // IOleWindow
00123 private:
00124   STDMETHOD(GetWindow)(HWND *phwnd)
00125   {
00126      *phwnd = m_hWnd;
00127     return S_OK;
00128   }
00129
00130    STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode) {return E_NOTIMPL;}
00131
00132 // IOleInPlaceSite
00133 private:
00134   STDMETHOD(CanInPlaceActivate)() {return S_OK;}
00135
00136   STDMETHOD(OnInPlaceActivate)()
00137   {
00138       m_bInPlaceActive = TRUE;
00139       return S_OK;
00140   }
00141
00142   STDMETHOD(GetWindowContext)(IOleInPlaceFrame** ppFrame,
00143                 IOleInPlaceUIWindow** ppDoc,
00144                 LPRECT lprcPosRect,
00145                 LPRECT lprcClipRect,
00146                 LPOLEINPLACEFRAMEINFO lpFrameInfo)
00147   {
00148     GetClientRect(lprcPosRect);
00149     GetClientRect(lprcClipRect);
00150     return S_OK;
00151   }
00152
00153   STDMETHOD(OnInPlaceDeactivate)()
00154   {
00155     m_bInPlaceActive = FALSE;
00156     return S_OK;
00157   }
00158
00159   STDMETHOD(OnUIActivate)() {return E_NOTIMPL;}
00160   STDMETHOD(Scroll)(SIZE scrollExtant) {return E_NOTIMPL;}
00161   STDMETHOD(OnUIDeactivate)(BOOL fUndoable) {return E_NOTIMPL;}
00162   STDMETHOD(DiscardUndoState)() {return E_NOTIMPL;}
00163   STDMETHOD(DeactivateAndUndo)( void) {return E_NOTIMPL;}
00164   STDMETHOD(OnPosRectChange)(LPCRECT lprcPosRect) {return E_NOTIMPL;}
00165
00166 // IOleClientSite Methods
00167 private:
00168   STDMETHOD(SaveObject)(void) {return E_NOTIMPL;}
00169   STDMETHOD(GetMoniker)(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) {return E_NOTIMPL;}
00170   STDMETHOD(GetContainer)(IOleContainer **ppContainer) {return E_NOTIMPL;}
00171   STDMETHOD(ShowObject)(void) {return E_NOTIMPL;}
00172   STDMETHOD(OnShowWindow)(BOOL fShow) {return E_NOTIMPL;}
00173   STDMETHOD(RequestNewObjectLayout)(void) {return E_NOTIMPL;}
00174
00175 // IServiceProvider
00176   STDMETHOD(QueryService)(REFGUID guidService, REFIID riid, void **ppv);
00177 };
00178
00179 #endif //__BROWSERHOST_H_
Generated on Wed Nov 13 2024 16:52:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_SP_OPTIONS Member List

This is the complete list of members for _SP_OPTIONS, including all inherited members.
bMulticast | _SP_OPTIONS
bQos | _SP_OPTIONS
iProtocol | _SP_OPTIONS
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/vcAcct/IMoveMoney.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • vcAcct

IMoveMoney.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc19.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\mssdk\samples\com\Services\Transaction\SampleBank\vcacct\release\vcacct.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package vcacct;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface IMoveMoney
00019 /** @com.interface(iid=04CF0B77-1989-11D0-B917-0080C7394688, thread=AUTO, type=DUAL) */
00020 public interface IMoveMoney extends IUnknown
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=METHOD, name="Perform", addFlagsVtable=4)
00023       @com.parameters([in,type=I4] lPrimeAccount, [in,type=I4] lSecondAccount, [in,type=I4] lAmount, [in,type=I4] lTranType, [type=STRING] return) */
00024   public String Perform(int lPrimeAccount, int lSecondAccount, int lAmount, int lTranType);
00025
00026
00027   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x4cf0b77, (short)0x1989, (short)0x11d0, (byte)0xb9, (byte)0x17, (byte)0x0, (byte)0x80, (byte)0xc7, (byte)0x39, (byte)0x46, (byte)0x88);
00028 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CStringData Member List

This is the complete list of members for CStringData, including all inherited members.
data() | CStringData | [inline]
nAllocLength | CStringData |
nDataLength | CStringData |
nRefs | CStringData |
Generated on Wed Nov 13 2024 16:57:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagAppletOctetString Member List

This is the complete list of members for tagAppletOctetString, including all inherited members.
cbStrSize | tagAppletOctetString
pbValue | tagAppletOctetString
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/InstProv/Sample.h Source File

  • SysMgmt
  • WMI
  • VC
  • InstProv

Sample.h

Go to the documentation of this file.
00001 //***************************************************************************
00002
00003 //
00004
00005 //  sample.h
00006
00007 //
00008
00009 //  Module: WMI Instance provider sample code
00010
00011 //
00012
00013 //  Purpose: Genral purpose include file.
00014
00015 //
00016
00017 // Copyright (c)  Microsoft Corporation, All Rights Reserved
00018 //
00019 //***************************************************************************
00020
00021 #ifndef _sample_H_
00022 #define _sample_H_
00023
00024 #include <wbemprov.h>
00025
00026 typedef LPVOID * PPVOID;
00027
00028 // Provider interfaces are provided by objects of this class
00029
00030 class CInstPro : public IWbemServices, public IWbemProviderInit
00031     {
00032     protected:
00033         ULONG              m_cRef;         //Object reference count
00034         IWbemServices *  m_pNamespace;
00035      public:
00036         CInstPro(BSTR ObjectPath = NULL, BSTR User = NULL, BSTR Password = NULL, IWbemContext * pCtx=NULL);
00037         ~CInstPro(void);
00038
00039         //Non-delegating object IUnknown
00040
00041         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00042         STDMETHODIMP_(ULONG) AddRef(void);
00043         STDMETHODIMP_(ULONG) Release(void);
00044
00045                 //IWbemProviderInit
00046
00047         HRESULT STDMETHODCALLTYPE Initialize(
00048              /* [in] */ LPWSTR pszUser,
00049              /* [in] */ LONG lFlags,
00050              /* [in] */ LPWSTR pszNamespace,
00051              /* [in] */ LPWSTR pszLocale,
00052              /* [in] */ IWbemServices *pNamespace,
00053              /* [in] */ IWbemContext *pCtx,
00054              /* [in] */ IWbemProviderInitSink *pInitSink
00055                         );
00056
00057         SCODE GetByPath( BSTR Path, IWbemClassObject FAR* FAR* pObj, IWbemContext  *pCtx);
00058
00059         //IWbemServices
00060
00061       HRESULT STDMETHODCALLTYPE OpenNamespace(
00062             /* [in] */ const BSTR Namespace,
00063             /* [in] */ long lFlags,
00064             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00065             /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
00066             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) {return WBEM_E_NOT_SUPPORTED;};
00067
00068         HRESULT STDMETHODCALLTYPE CancelAsyncCall(
00069             /* [in] */ IWbemObjectSink __RPC_FAR *pSink) {return WBEM_E_NOT_SUPPORTED;};
00070
00071         HRESULT STDMETHODCALLTYPE QueryObjectSink(
00072             /* [in] */ long lFlags,
00073             /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00074
00075         HRESULT STDMETHODCALLTYPE GetObject(
00076             /* [in] */ const BSTR ObjectPath,
00077             /* [in] */ long lFlags,
00078             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00079             /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
00080             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00081
00082         HRESULT STDMETHODCALLTYPE GetObjectAsync(
00083             /* [in] */ const BSTR ObjectPath,
00084             /* [in] */ long lFlags,
00085             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00086             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
00087
00088         HRESULT STDMETHODCALLTYPE PutClass(
00089             /* [in] */ IWbemClassObject __RPC_FAR *pObject,
00090             /* [in] */ long lFlags,
00091             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00092             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00093
00094         HRESULT STDMETHODCALLTYPE PutClassAsync(
00095             /* [in] */ IWbemClassObject __RPC_FAR *pObject,
00096             /* [in] */ long lFlags,
00097             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00098             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00099
00100         HRESULT STDMETHODCALLTYPE DeleteClass(
00101             /* [in] */ const BSTR Class,
00102             /* [in] */ long lFlags,
00103             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00104             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00105
00106         HRESULT STDMETHODCALLTYPE DeleteClassAsync(
00107             /* [in] */ const BSTR Class,
00108             /* [in] */ long lFlags,
00109             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00110             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00111
00112         HRESULT STDMETHODCALLTYPE CreateClassEnum(
00113             /* [in] */ const BSTR Superclass,
00114             /* [in] */ long lFlags,
00115             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00116             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00117
00118         HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
00119             /* [in] */ const BSTR Superclass,
00120             /* [in] */ long lFlags,
00121             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00122             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00123
00124         HRESULT STDMETHODCALLTYPE PutInstance(
00125             /* [in] */ IWbemClassObject __RPC_FAR *pInst,
00126             /* [in] */ long lFlags,
00127             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00128             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00129
00130         HRESULT STDMETHODCALLTYPE PutInstanceAsync(
00131             /* [in] */ IWbemClassObject __RPC_FAR *pInst,
00132             /* [in] */ long lFlags,
00133             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00134             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00135
00136         HRESULT STDMETHODCALLTYPE DeleteInstance(
00137             /* [in] */ const BSTR ObjectPath,
00138             /* [in] */ long lFlags,
00139             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00140             /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
00141
00142         HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
00143             /* [in] */ const BSTR ObjectPath,
00144             /* [in] */ long lFlags,
00145             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00146             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00147
00148         HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
00149             /* [in] */ const BSTR Class,
00150             /* [in] */ long lFlags,
00151             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00152             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00153
00154         HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
00155             /* [in] */ const BSTR Class,
00156             /* [in] */ long lFlags,
00157             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00158             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
00159
00160         HRESULT STDMETHODCALLTYPE ExecQuery(
00161             /* [in] */ const BSTR QueryLanguage,
00162             /* [in] */ const BSTR Query,
00163             /* [in] */ long lFlags,
00164             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00165             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00166
00167         HRESULT STDMETHODCALLTYPE ExecQueryAsync(
00168             /* [in] */ const BSTR QueryLanguage,
00169             /* [in] */ const BSTR Query,
00170             /* [in] */ long lFlags,
00171             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00172             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00173
00174         HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
00175             /* [in] */ const BSTR QueryLanguage,
00176             /* [in] */ const BSTR Query,
00177             /* [in] */ long lFlags,
00178             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00179             /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
00180
00181         HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
00182             /* [in] */ const BSTR QueryLanguage,
00183             /* [in] */ const BSTR Query,
00184             /* [in] */ long lFlags,
00185             /* [in] */ IWbemContext __RPC_FAR *pCtx,
00186             /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
00187
00188         HRESULT STDMETHODCALLTYPE ExecMethod( const BSTR, const BSTR, long, IWbemContext*,
00189             IWbemClassObject*, IWbemClassObject**, IWbemCallResult**) {return WBEM_E_NOT_SUPPORTED;}
00190
00191         HRESULT STDMETHODCALLTYPE ExecMethodAsync( const BSTR, const BSTR, long,
00192             IWbemContext*, IWbemClassObject*, IWbemObjectSink*) {return WBEM_E_NOT_SUPPORTED;}
00193
00194 };
00195
00196 typedef CInstPro *PCInstPro;
00197
00198 // This class is the class factory for CInstPro objects.
00199
00200 class CProvFactory : public IClassFactory
00201     {
00202     protected:
00203         ULONG           m_cRef;
00204
00205     public:
00206         CProvFactory(void);
00207         ~CProvFactory(void);
00208
00209         //IUnknown members
00210         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
00211         STDMETHODIMP_(ULONG) AddRef(void);
00212         STDMETHODIMP_(ULONG) Release(void);
00213
00214         //IClassFactory members
00215         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
00216                                  , PPVOID);
00217         STDMETHODIMP         LockServer(BOOL);
00218     };
00219
00220 typedef CProvFactory *PCProvFactory;
00221
00222
00223
00224 // These variables keep track of when the module can be unloaded
00225
00226 extern long       g_cObj;
00227 extern long       g_cLock;
00228
00229 // General purpose utilities.
00230
00231 DWORD GetCurrentImpersonationLevel ();
00232
00233
00234 SCODE CreateInst( IWbemServices * pNamespace, LPWSTR pKey, long lVal,
00235                                              IWbemClassObject ** pNewInst,
00236                                              WCHAR * pwcClassName,
00237                        IWbemContext  *pCtx);
00238
00239 typedef struct {
00240    WCHAR * pwcKey;
00241    long lValue;
00242    } InstDef;
00243
00244 extern InstDef MyDefs[];
00245 extern long glNumInst;
00246
00247
00248 #endif
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/viewex/guids.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • viewex

guids.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Note that the GUIDs for CComponentData and CSnapinAbout are different
00014 //  from the ScopeNode project.  The Node GUIDs can stay the same since
00015 //  they are not really COM objects.
00016
00017
00018 #ifndef _VIEWEXTENSION_PROJECT_GUIDS_
00019 #define _VIEWEXTENSION_PROJECT_GUIDS_
00020
00021 // {3bbefb8e-8122-4b0a-b54e-05dd4d6aa02c}
00022 DEFINE_GUID( CLSID_CComponentData,
00023              0x3bbefb8e, 0x8122, 0x4b0a, 0xb5, 0x4e, 0x05, 0xdd, 0x4d, 0x6a, 0xa0, 0x2c);
00024
00025
00026 // {96dd4604-48f2-402d-8255-f7423dec1990}
00027 DEFINE_GUID( CLSID_CSnapinAbout,
00028              0x96dd4604, 0x48f2, 0x402d, 0x82, 0x55, 0xf7, 0x42, 0x3d, 0xec, 0x19, 0x90);
00029
00030
00031 // {520F23F9-775D-4015-B437-98A24B9D085E}
00032 DEFINE_GUID( CLSID_DeviceNode,
00033              0x520F23f9, 0x775D, 0x4015, 0xB4, 0x37, 0x98, 0xA2, 0x4B, 0x9D, 0x8, 0x5E);
00034
00035
00036 // {520F23FA-775D-4015-B437-98A24B9D085E}
00037 DEFINE_GUID( CLSID_CFolderNode,
00038              0x520F23fA, 0x775D, 0x4015, 0xb4, 0x37, 0x98, 0xA2, 0x4B, 0x9D, 0x8, 0x5E);
00039
00040 // {f0091c49-c869-4941-a81c-c719ad8174cc}
00041 DEFINE_GUID( CLSID_CVirtualFile,
00042              0xf0091c49, 0xc869, 0x4941, 0xa8, 0x1c, 0xc7, 0x19, 0xad, 0x81, 0x74, 0xcc);
00043
00044
00045 #endif //_VIEWEXTENSION_PROJECT_GUIDS_
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/SyncMgr/SyncDir/Guid.h Source File

  • NetDS
  • SyncMgr
  • SyncDir

Guid.h

Go to the documentation of this file.
00001 #ifndef _GUIDDECL_
00002 #define _GUIDDECL_
00003
00004 // DEFINE A NEW CLSID FOR EACH HANDLER
00005 // {97484BA5-26C7-11d1-9A39-0020AFDA97B0}
00006
00007 DEFINE_GUID(CLSID_SyncMgrHandler,0x97484ba5, 0x26c7, 0x11d1, 0x9a, 0x39, 0x0, 0x20, 0xaf, 0xda, 0x97, 0xb0);
00008
00009 #endif _GUIDDECL_
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAuthenticateAdmin Member List

This is the complete list of members for CAuthenticateAdmin, including all inherited members.
CAuthenticateAdmin() | CAuthenticateAdmin | [inline]
Initialize(CAuthenticatePlugin *pPlugin) | CAuthenticateAdmin |
InterfaceSupportsErrorInfo(REFIID riid) | CAuthenticateAdmin |
m_pAuthenticatePlugin | CAuthenticateAdmin | [private]
Generated on Wed Nov 13 2024 16:55:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/ShellIconOverlay/IcnOvrly.Cpp Source File

  • WinUI
  • Shell
  • ShellIconOverlay

IcnOvrly.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1999 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          IcnOvrly.cpp
00013
00014    Description:
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "IcnOvrly.h"
00023 #include <olectl.h>
00024 #include <shlguid.h>
00025 #include <shlwapi.h>
00026
00027 /**************************************************************************
00028    private function prototypes
00029 **************************************************************************/
00030
00031 extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
00032
00033 /**************************************************************************
00034    global variables
00035 **************************************************************************/
00036
00037 HINSTANCE   g_hInst;
00038 DWORD       g_DllRefCount;
00039
00040 #define STR_EXT_TITLE   TEXT("Sample Shell Icon Overlay Identifier")
00041 #define STR_REG_PATH    TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers")
00042
00043 /**************************************************************************
00044
00045    DllMain
00046
00047 **************************************************************************/
00048
00049 extern "C" BOOL WINAPI DllMain(  HINSTANCE hInstance,
00050                                  DWORD dwReason,
00051                                  LPVOID lpReserved)
00052 {
00053 switch(dwReason)
00054    {
00055    case DLL_PROCESS_ATTACH:
00056       g_hInst = hInstance;
00057       break;
00058
00059    case DLL_PROCESS_DETACH:
00060       //MessageBeep(MB_OK);
00061       break;
00062    }
00063
00064 return TRUE;
00065 }
00066
00067 /**************************************************************************
00068
00069    DllCanUnloadNow
00070
00071 **************************************************************************/
00072
00073 STDAPI DllCanUnloadNow(void)
00074 {
00075 return ((g_DllRefCount == 0) ? S_OK : S_FALSE);
00076 }
00077
00078 /**************************************************************************
00079
00080    DllGetClassObject
00081
00082 **************************************************************************/
00083
00084 STDAPI DllGetClassObject(  REFCLSID rclsid,
00085                            REFIID riid,
00086                            LPVOID *ppReturn)
00087 {
00088 *ppReturn = NULL;
00089
00090 //if we don't support this classid, return the proper error code
00091 if(!IsEqualCLSID(rclsid, CLSID_SampleShellIconOverlay))
00092    return CLASS_E_CLASSNOTAVAILABLE;
00093
00094 //create a CClassFactory object and check it for validity
00095 CClassFactory *pClassFactory = new CClassFactory();
00096 if(NULL == pClassFactory)
00097    return E_OUTOFMEMORY;
00098
00099 //get the QueryInterface return for our return value
00100 HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn);
00101
00102 //call Release to decement the ref count - creating the object set it to one
00103 //and QueryInterface incremented it - since its being used externally (not by
00104 //us), we only want the ref count to be 1
00105 pClassFactory->Release();
00106
00107 //return the result from QueryInterface
00108 return hResult;
00109 }
00110
00111 ///////////////////////////////////////////////////////////////////////////
00112 //
00113 // CClassFactory member function
00114 //
00115
00116 /**************************************************************************
00117
00118    CClassFactory::CClassFactory
00119
00120 **************************************************************************/
00121
00122 CClassFactory::CClassFactory()
00123 {
00124 m_ObjRefCount = 1;
00125 g_DllRefCount++;
00126 }
00127
00128 /**************************************************************************
00129
00130    CClassFactory::~CClassFactory
00131
00132 **************************************************************************/
00133
00134 CClassFactory::~CClassFactory()
00135 {
00136 g_DllRefCount--;
00137 }
00138
00139 /**************************************************************************
00140
00141    CClassFactory::QueryInterface
00142
00143 **************************************************************************/
00144
00145 STDMETHODIMP CClassFactory::QueryInterface(   REFIID riid,
00146                                              LPVOID FAR * ppReturn)
00147 {
00148 if(IsEqualIID(riid, IID_IUnknown))
00149    {
00150    *ppReturn = (LPUNKNOWN)(LPCLASSFACTORY)this;
00151    m_ObjRefCount++;
00152    return S_OK;
00153    }
00154
00155 if(IsEqualIID(riid, IID_IClassFactory))
00156    {
00157    *ppReturn = (LPCLASSFACTORY)this;
00158    m_ObjRefCount++;
00159    return S_OK;
00160    }
00161
00162 *ppReturn = NULL;
00163 return E_NOINTERFACE;
00164 }
00165
00166 /**************************************************************************
00167
00168    CClassFactory::AddRef
00169
00170 **************************************************************************/
00171
00172 STDMETHODIMP_(DWORD) CClassFactory::AddRef()
00173 {
00174 return ++m_ObjRefCount;
00175 }
00176
00177
00178 /**************************************************************************
00179
00180    CClassFactory::Release
00181
00182 **************************************************************************/
00183
00184 STDMETHODIMP_(DWORD) CClassFactory::Release()
00185 {
00186 if(--m_ObjRefCount ==0)
00187    delete this;
00188
00189 return m_ObjRefCount;
00190 }
00191
00192 /**************************************************************************
00193
00194    CClassFactory::CreateInstance
00195
00196 **************************************************************************/
00197
00198 STDMETHODIMP CClassFactory::CreateInstance(  LPUNKNOWN pUnknown,
00199                                              REFIID riid,
00200                                              LPVOID FAR * ppObject)
00201 {
00202 *ppObject = NULL;
00203
00204 if(pUnknown != NULL)
00205    return CLASS_E_NOAGGREGATION;
00206
00207 //add implementation specific code here
00208 CShellIconOverlayID *psioid = new CShellIconOverlayID;
00209 if(NULL == psioid)
00210    return E_OUTOFMEMORY;
00211
00212 //get the QueryInterface return for our return value
00213 HRESULT hResult = psioid->QueryInterface(riid, ppObject);
00214
00215 //call Release to decement the ref count
00216 psioid->Release();
00217
00218 //return the result from QueryInterface
00219 return hResult;
00220
00221 }
00222
00223 /**************************************************************************
00224
00225    CClassFactory::LockServer
00226
00227 **************************************************************************/
00228
00229 STDMETHODIMP CClassFactory::LockServer(BOOL)
00230 {
00231 return E_NOTIMPL;
00232 }
00233
00234 /**************************************************************************
00235
00236    CShellIconOverlayID::CShellIconOverlayID()
00237
00238 **************************************************************************/
00239
00240 CShellIconOverlayID::CShellIconOverlayID()
00241 {
00242 m_ObjRefCount = 1;
00243 g_DllRefCount++;
00244 }
00245
00246 /**************************************************************************
00247
00248    CShellIconOverlayID::~CShellIconOverlayID()
00249
00250 **************************************************************************/
00251
00252 CShellIconOverlayID::~CShellIconOverlayID()
00253 {
00254 g_DllRefCount--;
00255 }
00256
00257 ///////////////////////////////////////////////////////////////////////////
00258 //
00259 // IUnknown Implementation
00260 //
00261
00262 /**************************************************************************
00263
00264    CShellIconOverlayID::QueryInterface
00265
00266 **************************************************************************/
00267
00268 STDMETHODIMP CShellIconOverlayID::QueryInterface(  REFIID riid,
00269                                                    LPVOID *ppReturn)
00270 {
00271 *ppReturn = NULL;
00272
00273 //IUnknown
00274 if(IsEqualIID(riid, IID_IUnknown))
00275    {
00276    *ppReturn = this;
00277    }
00278
00279 //IContextMenu
00280 else if(IsEqualIID(riid, IID_IShellIconOverlayIdentifier))
00281    {
00282    *ppReturn = (IShellIconOverlayIdentifier*)this;
00283    }
00284
00285 if(*ppReturn)
00286    {
00287    (*(LPUNKNOWN*)ppReturn)->AddRef();
00288    return S_OK;
00289    }
00290
00291 return E_NOINTERFACE;
00292 }
00293
00294 /**************************************************************************
00295
00296    CShellIconOverlayID::AddRef
00297
00298 **************************************************************************/
00299
00300 STDMETHODIMP_(DWORD) CShellIconOverlayID::AddRef()
00301 {
00302 return ++m_ObjRefCount;
00303 }
00304
00305
00306 /**************************************************************************
00307
00308    CShellIconOverlayID::Release
00309
00310 **************************************************************************/
00311
00312 STDMETHODIMP_(DWORD) CShellIconOverlayID::Release()
00313 {
00314 if(--m_ObjRefCount == 0)
00315    delete this;
00316
00317 return m_ObjRefCount;
00318 }
00319
00320 ///////////////////////////////////////////////////////////////////////////
00321 //
00322 // IShellIconOverlayIdentifier Implementation
00323 //
00324
00325 /**************************************************************************
00326
00327    CShellIconOverlayID::IsMemberOf()
00328
00329    Called when a file or folder object is about to be displayed. Return
00330    S_OK to use the overlay icon for this object or S_FALSE to not use the
00331    overlay icon for this object.
00332
00333 **************************************************************************/
00334
00335 STDMETHODIMP CShellIconOverlayID::IsMemberOf(   LPCWSTR pwszPath,
00336                                                 DWORD dwAttr)
00337 {
00338 TCHAR szPath[MAX_PATH];
00339 WideCharToLocal(szPath, pwszPath, MAX_PATH);
00340
00341 //display the overlay icon for files with the .TXT extension
00342 LPTSTR   pszExt = PathFindExtension(szPath);
00343 if(pszExt && (0 == lstrcmpi(pszExt, TEXT(".txt"))))
00344    return S_OK;
00345
00346 return S_FALSE;
00347 }
00348
00349 /**************************************************************************
00350
00351    CShellIconOverlayID::GetOverlayInfo()
00352
00353    Called when the overlay icon identifier object is initialized. The object
00354    will normally remain active for the life of the shell. This method is
00355    called only once for each overlay identifier registered. This method
00356    supplies the source file name and index, if required, of the overlay
00357    icon for this object. If the icon source file only contains one icon,
00358    it is not necessary to to add ISIOI_ICONINDEX to pdwFlags.
00359
00360 **************************************************************************/
00361
00362 STDMETHODIMP CShellIconOverlayID::GetOverlayInfo(  LPWSTR pwszIconFile,
00363                                                    int cchMax,
00364                                                    LPINT pIndex,
00365                                                    LPDWORD pdwFlags)
00366 {
00367 if(IsBadWritePtr(pIndex, sizeof(int)))
00368    return E_INVALIDARG;
00369
00370 if(IsBadWritePtr(pdwFlags, sizeof(DWORD)))
00371    return E_INVALIDARG;
00372
00373 TCHAR szModule[MAX_PATH];
00374
00375 GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule));
00376
00377 LocalToWideChar(pwszIconFile, szModule, cchMax);
00378
00379 *pIndex = 0;
00380
00381 *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
00382
00383 return S_OK;
00384 }
00385
00386 /**************************************************************************
00387
00388    CShellIconOverlayID::GetPriority()
00389
00390    Called to obtain the priority if there are conflicts between more than
00391    one overlay icon. The shell can only display one overlay icon for an
00392    object, so if more than one overlay should be displayed for an object,
00393    then the priority is used to determine which overlay should be used.
00394
00395 **************************************************************************/
00396
00397 STDMETHODIMP CShellIconOverlayID::GetPriority(LPINT pPriority)
00398 {
00399 if(IsBadWritePtr(pPriority, sizeof(int)))
00400    return E_INVALIDARG;
00401
00402 *pPriority = 0;
00403
00404 return S_OK;
00405 }
00406
00407 /**************************************************************************
00408
00409    DllRegisterServer
00410
00411 **************************************************************************/
00412
00413 typedef struct{
00414    HKEY  hRootKey;
00415    LPTSTR lpszSubKey;
00416    LPTSTR lpszValueName;
00417    LPTSTR lpszData;
00418 }REGSTRUCT, *LPREGSTRUCT;
00419
00420 STDAPI DllRegisterServer(void)
00421 {
00422 int      i;
00423 HKEY     hKey;
00424 LRESULT  lResult;
00425 DWORD    dwDisp;
00426 TCHAR    szSubKey[MAX_PATH];
00427 TCHAR    szCLSID[MAX_PATH];
00428 TCHAR    szModule[MAX_PATH];
00429 LPWSTR   pwsz;
00430
00431 //get the CLSID in string form
00432 StringFromIID(CLSID_SampleShellIconOverlay, &pwsz);
00433
00434 if(pwsz)
00435    {
00436    WideCharToLocal(szCLSID, pwsz, ARRAYSIZE(szCLSID));
00437
00438    //free the string
00439    LPMALLOC pMalloc;
00440    CoGetMalloc(1, &pMalloc);
00441    if(pMalloc)
00442       {
00443       pMalloc->Free(pwsz);
00444       pMalloc->Release();
00445       }
00446    }
00447
00448 //get this DLL's path and file name
00449 GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule));
00450
00451 //register the CLSID entries
00452 REGSTRUCT ClsidEntries[] = {  HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s"),                                    NULL,                   STR_EXT_TITLE,
00453                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),                    NULL,                   TEXT("%s"),
00454                               HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),                    TEXT("ThreadingModel"), TEXT("Apartment"),
00455                               NULL,                NULL,                                                NULL,                   NULL};
00456
00457 for(i = 0; ClsidEntries[i].hRootKey; i++)
00458    {
00459    //Create the sub key string.
00460    wsprintf(szSubKey, ClsidEntries[i].lpszSubKey, szCLSID);
00461
00462    lResult = RegCreateKeyEx(  ClsidEntries[i].hRootKey,
00463                               szSubKey,
00464                               0,
00465                               NULL,
00466                               REG_OPTION_NON_VOLATILE,
00467                               KEY_WRITE,
00468                               NULL,
00469                               &hKey,
00470                               &dwDisp);
00471
00472    if(NOERROR == lResult)
00473       {
00474       TCHAR szData[MAX_PATH] = TEXT("");
00475
00476       //if necessary, create the value string
00477       wsprintf(szData, ClsidEntries[i].lpszData, szModule);
00478
00479       lResult = RegSetValueEx(   hKey,
00480                                  ClsidEntries[i].lpszValueName,
00481                                  0,
00482                                  REG_SZ,
00483                                  (LPBYTE)szData,
00484                                  lstrlen(szData) + 1);
00485
00486       RegCloseKey(hKey);
00487       }
00488    else
00489       return SELFREG_E_CLASS;
00490    }
00491
00492 //register the shell icon overlay identifier
00493 wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
00494 lResult = RegCreateKeyEx(  HKEY_LOCAL_MACHINE,
00495                            szSubKey,
00496                            0,
00497                            NULL,
00498                            REG_OPTION_NON_VOLATILE,
00499                            KEY_WRITE,
00500                            NULL,
00501                            &hKey,
00502                            &dwDisp);
00503
00504 if(NOERROR == lResult)
00505    {
00506    //Create the value string.
00507    lResult = RegSetValueEx(   hKey,
00508                               NULL,
00509                               0,
00510                               REG_SZ,
00511                               (LPBYTE)szCLSID,
00512                               (lstrlen(szCLSID) + 1) * sizeof(TCHAR));
00513
00514    RegCloseKey(hKey);
00515    }
00516 else
00517    return SELFREG_E_CLASS;
00518
00519 //If running on NT, register the extension as approved.
00520 OSVERSIONINFO  osvi;
00521
00522 osvi.dwOSVersionInfoSize = sizeof(osvi);
00523 GetVersionEx(&osvi);
00524
00525 if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
00526    {
00527    lstrcpyn( szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), ARRAYSIZE(szSubKey));
00528
00529    lResult = RegCreateKeyEx(  HKEY_LOCAL_MACHINE,
00530                               szSubKey,
00531                               0,
00532                               NULL,
00533                               REG_OPTION_NON_VOLATILE,
00534                               KEY_WRITE,
00535                               NULL,
00536                               &hKey,
00537                               &dwDisp);
00538
00539    if(NOERROR == lResult)
00540       {
00541       TCHAR szData[MAX_PATH];
00542
00543       //Create the value string.
00544       lstrcpyn(szData, STR_EXT_TITLE, ARRAYSIZE(szData));
00545
00546       lResult = RegSetValueEx(   hKey,
00547                                  szCLSID,
00548                                  0,
00549                                  REG_SZ,
00550                                  (LPBYTE)szData,
00551                                  (lstrlen(szData) + 1) * sizeof(TCHAR));
00552
00553       RegCloseKey(hKey);
00554       }
00555    else
00556       return SELFREG_E_CLASS;
00557    }
00558
00559 return S_OK;
00560 }
00561
00562 /**************************************************************************
00563
00564    DllUnregisterServer()
00565
00566 **************************************************************************/
00567
00568 STDAPI DllUnregisterServer(VOID)
00569 {
00570 LPWSTR   pwsz;
00571 TCHAR    szCLSID[MAX_PATH];
00572 TCHAR    szSubKey[MAX_PATH];
00573
00574 //get the CLSID in string form
00575 StringFromIID(CLSID_SampleShellIconOverlay, &pwsz);
00576
00577 if(pwsz)
00578    {
00579    WideCharToLocal(szCLSID, pwsz, ARRAYSIZE(szCLSID));
00580
00581    //free the string
00582    LPMALLOC pMalloc;
00583    CoGetMalloc(1, &pMalloc);
00584    if(pMalloc)
00585       {
00586       pMalloc->Free(pwsz);
00587       pMalloc->Release();
00588       }
00589    }
00590 else
00591    {
00592    return E_FAIL;
00593    }
00594
00595 //delete the namespace extension entries
00596 wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
00597 DeleteEntireKey(HKEY_LOCAL_MACHINE, szSubKey);
00598
00599 //delete the object's registry entries
00600 wsprintf(szSubKey, TEXT("CLSID\\%s"), szCLSID);
00601 DeleteEntireKey(HKEY_CLASSES_ROOT, szSubKey);
00602
00603 //delete the approved extensions on NT
00604 OSVERSIONINFO  osvi;
00605
00606 osvi.dwOSVersionInfoSize = sizeof(osvi);
00607 GetVersionEx(&osvi);
00608
00609 if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
00610    {
00611    LRESULT  lResult;
00612    HKEY     hKey;
00613
00614    lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
00615                            TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
00616                            0,
00617                            KEY_SET_VALUE,
00618                            &hKey);
00619
00620    if(NOERROR == lResult)
00621       {
00622       lResult = RegDeleteValue(hKey, STR_EXT_TITLE);
00623
00624       RegCloseKey(hKey);
00625       }
00626    else
00627       return SELFREG_E_CLASS;
00628    }
00629
00630 return S_OK;
00631 }
00632
00633 /**************************************************************************
00634
00635    DeleteEntireKey()
00636
00637 **************************************************************************/
00638
00639 BOOL DeleteEntireKey(HKEY hKey, LPTSTR pszSubKey)
00640 {
00641 LRESULT  lResult;
00642 HKEY     hEnumKey;
00643
00644 lResult = RegOpenKeyEx( hKey,
00645                         pszSubKey,
00646                         0,
00647                         KEY_ENUMERATE_SUB_KEYS,
00648                         &hEnumKey);
00649
00650 if(NOERROR == lResult)
00651    {
00652    TCHAR szKey[MAX_PATH];
00653    DWORD dwSize = MAX_PATH;
00654
00655    while(ERROR_SUCCESS == RegEnumKeyEx(hEnumKey, 0, szKey, &dwSize, NULL, NULL, NULL, NULL))
00656       {
00657       DeleteEntireKey(hEnumKey, szKey);
00658
00659       dwSize = MAX_PATH;
00660       }
00661
00662    RegCloseKey(hEnumKey);
00663    }
00664 else
00665    {
00666    return FALSE;
00667    }
00668
00669 RegDeleteKey(hKey, pszSubKey);
00670
00671 return TRUE;
00672 }
00673
00674 /**************************************************************************
00675
00676    WideCharToLocal()
00677
00678 **************************************************************************/
00679
00680 int WideCharToLocal(LPTSTR pLocal, LPCWSTR pWide, DWORD dwChars)
00681 {
00682 *pLocal = 0;
00683
00684 #ifdef UNICODE
00685 lstrcpyn(pLocal, pWide, dwChars);
00686 #else
00687 WideCharToMultiByte( CP_ACP,
00688                      0,
00689                      pWide,
00690                      -1,
00691                      pLocal,
00692                      dwChars,
00693                      NULL,
00694                      NULL);
00695 #endif
00696
00697 return lstrlen(pLocal);
00698 }
00699
00700 /**************************************************************************
00701
00702    LocalToWideChar()
00703
00704 **************************************************************************/
00705
00706 int LocalToWideChar(LPWSTR pWide, LPCTSTR pLocal, DWORD dwChars)
00707 {
00708 *pWide = 0;
00709
00710 #ifdef UNICODE
00711 lstrcpyn(pWide, pLocal, dwChars);
00712 #else
00713 MultiByteToWideChar( CP_ACP,
00714                      0,
00715                      pLocal,
00716                      -1,
00717                      pWide,
00718                      dwChars);
00719 #endif
00720
00721 return lstrlenW(pWide);
00722 }
00723
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

complist Member List

This is the complete list of members for complist, including all inherited members.
items | complist
left | complist
right | complist
Generated on Wed Nov 13 2024 16:57:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/StrOut/Client.c Source File

  • NetDS
  • RPC
  • StrOut

Client.c

Go to the documentation of this file.
00001 /*************************************************************************
00002                     Copyright Microsoft Corp. 1992 - 2000
00003                         Remote Machine strout sample
00004
00005   FILE      :   client.c
00006
00007   USAGE     :   client  -n network_address
00008                         -p protocol_sequence
00009                         -e endpoint
00010                         -o options
00011
00012   PURPOSE   :   Client side of the RPC distributed application strout.
00013
00014   COMMENTS  :   This program shows how to call remote procedures that
00015                 allocate memory for a two dimensional array (an array of
00016                 character pointers). It calls the server that allocates
00017                 memory to store all the environment strings in, and copies
00018                 the environment variables to this memory. The client then
00019                 displays all the data on the client machine.
00020
00021                 Since this program uses the implicit binding method, some
00022                 of the binding handling must be done at the client side
00023 *************************************************************************/
00024
00025 #include "strout.h"     /* Generated by the midl compiler               */
00026 #include "common.h"     /* Definitions that are common to all files     */
00027
00028
00029 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00030 /*  Procedure   :   void Usage(_TUCHAR *)                               */
00031 /*  Desc        :   This procedure prints out an error message if the   */
00032 /*                  command line arguments are wrong                    */
00033 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00034 void Usage(_TUCHAR * pszProgramName)
00035 {
00036     _tprintf(TEXT("USAGE : %s [-option]\n"), pszProgramName);
00037     _tprintf(TEXT("Options : -n Network Address\n"));
00038     _tprintf(TEXT("          -p Protocol Sequence\n"));
00039     _tprintf(TEXT("          -e Endpoint\n"));
00040     _tprintf(TEXT("          -o Options\n"));
00041     exit(EXECUTION_FAILED);
00042 }
00043
00044
00045 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00046 /* The client main program                                              */
00047 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00048 int main(int argc, char *argv[])
00049 {
00050     RPC_STATUS nStatus;     /* Return value from the RPC calls          */
00051     unsigned int
00052         nIdx,               /* Counter in loops                         */
00053         nNumArgs;           /* Number of commandline arguments          */
00054     unsigned long
00055         nNumLines = 0;      /* Number of lines in the environment block */
00056     str *pEnvBlock;         /* Pointer to an array of string pointers   */
00057
00058     // These variables are used for the implicit binding
00059     _TUCHAR *pszUuid            = NULL;
00060     _TUCHAR *pszProtocolSequence= PROTOCOL_SEQUENCE;
00061     _TUCHAR *pszNetworkAddress  = NULL;
00062     _TUCHAR *pszEndpoint        = END_POINT;
00063     _TUCHAR *pszOptions         = NULL;
00064     _TUCHAR *pszStringBinding   = NULL;
00065
00066     /* Get a common handle on the command line arguments for both       */
00067     /* UNICODE and ASCII                                                */
00068 #ifdef _UNICODE
00069     LPWSTR  *szArglist = CommandLineToArgvW(GetCommandLine(), &nNumArgs);
00070     if (NULL == szArglist)
00071     {
00072         _tprintf(TEXT("SERVER.C : CommandLineToArgW failed"));
00073         exit(EXECUTION_FAILED);
00074     }
00075 #else
00076     char **szArglist= argv;
00077     nNumArgs = argc;
00078 #endif
00079
00080     /* Allow the user to override settings with commandline switches    */
00081     for (nIdx = 1; nIdx < nNumArgs; nIdx++)
00082     {
00083         if ((_tcscmp(szArglist[nIdx], TEXT("-n")) == 0) ||
00084             (_tcscmp(szArglist[nIdx], TEXT("-N")) == 0))
00085         {
00086             pszNetworkAddress = szArglist[++nIdx];
00087         }
00088         else if((_tcscmp(szArglist[nIdx], TEXT("-p")) == 0) ||
00089             (_tcscmp(szArglist[nIdx], TEXT("-P")) == 0))
00090         {
00091             pszProtocolSequence = szArglist[++nIdx];
00092         }
00093         else if((_tcscmp(szArglist[nIdx], TEXT("-e")) == 0) ||
00094                 (_tcscmp(szArglist[nIdx], TEXT("-e")) == 0))
00095         {
00096             pszEndpoint = szArglist[++nIdx];
00097         }
00098         else if((_tcscmp(szArglist[nIdx], TEXT("-o")) == 0) ||
00099                 (_tcscmp(szArglist[nIdx], TEXT("-O")) == 0))
00100         {
00101             pszOptions = szArglist[++nIdx];
00102         }
00103         else
00104         {
00105             Usage(szArglist[0]);
00106         }
00107     }
00108
00109
00110     /* Since we are using implicit binding, we need to do some binding  */
00111     /* from the client side as well.                                    */
00112     /* Use a function to concatenate the elements of the string         */
00113     /* binding into the proper sequence                                 */
00114     nStatus = RpcStringBindingCompose(
00115         pszUuid,
00116         pszProtocolSequence,
00117         pszNetworkAddress,
00118         pszEndpoint,
00119         pszOptions,
00120         &pszStringBinding);
00121     EXIT_IF_FAIL(nStatus, "RpcStringBindingCompose");
00122
00123     /* Set the binding handle that will be used to bind to the server   */
00124     nStatus = RpcBindingFromStringBinding(
00125         pszStringBinding,
00126         &global_strout_sample_handle);      /* The global handle used   */
00127     EXIT_IF_FAIL(nStatus, "RpcBindingFromStringBinding");
00128
00129     /* Initialize the pointer to NULL */
00130     pEnvBlock = NULL;
00131
00132     RpcTryExcept                /* Catch any exception that occurs      */
00133     {
00134         /* Call the remote procedure */
00135         _tprintf(TEXT("Calling the remote procedure \'GetRemoteEnv\' \n"));
00136         GetRemoteEnv(&nNumLines, &pEnvBlock);
00137     }
00138     RpcExcept(DO_EXCEPTION)
00139     {
00140         _tprintf(TEXT("Run-time exception %08X = %d in %s\n"),
00141             RpcExceptionCode(), RpcExceptionCode(), TEXT(__FILE__));
00142         exit(EXECUTION_FAILED);
00143     }
00144     RpcEndExcept
00145
00146
00147     /* Print out the result */
00148     _tprintf(TEXT("There are %d environment variables\n"), nNumLines);
00149     _tprintf(TEXT("They are:\n"));
00150     for (nIdx = 0; nIdx < nNumLines; nIdx++)
00151     {
00152         _tprintf(TEXT("\t%s\n"), pEnvBlock[nIdx]);
00153     }
00154
00155
00156     // Deallocate all the memory used for the EnvBlock
00157     for (nIdx = 0; nIdx < nNumLines; nIdx++)
00158     {
00159         midl_user_free(pEnvBlock[nIdx]);
00160     }
00161     midl_user_free(pEnvBlock);
00162
00163     // Deallocate the memory used for the ARGLIST if using UNICODE
00164 #ifdef _UNICODE
00165     if (NULL != szArglist)
00166         free(szArglist);
00167 #endif
00168
00169     /* When the call is done, shut down the server application */
00170     ShutDown();
00171
00172     return (EXECUTION_OK);
00173 }
00174
00175
00176
00177 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00178 /* Procedure    :   midl_user_allocate() and midl_user_free()           */
00179 /* Desc.        :   These procedure are declared in the header file     */
00180 /*                  generated by the midl compiler. These procedures    */
00181 /*                  should be used for all memory allocation and        */
00182 /*                  deallocation.                                       */
00183 /*                  These procedures are also called by the stub code to*/
00184 /*                  allocate and free memory.                           */
00185 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00186 void __RPC_FAR * __RPC_API midl_user_allocate(size_t nLen)
00187 {
00188     return (malloc(nLen));
00189 }
00190
00191 void __RPC_API midl_user_free(void __RPC_FAR * lpvPointer)
00192 {
00193     if (lpvPointer != NULL)
00194         free (lpvPointer);
00195 }
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Openserv/land.h Source File

  • SysMgmt
  • MMC
  • Openserv

land.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _LAND_H
00021 #define _LAND_H
00022
00023 #include "DeleBase.h"
00024
00025 class CLandBasedVehicle : public CDelegationBase {
00026 public:
00027     CLandBasedVehicle() { }
00028
00029     virtual ~CLandBasedVehicle() {}
00030
00031     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Land-based Vehicles"); }
00032     virtual const GUID & getNodeType() { return thisGuid; }
00033     virtual const int GetBitmapIndex() { return INDEX_LANDICON; }
00034
00035 private:
00036     enum { IDM_NEW_LAND = 2 };
00037
00038     // {2974380E-4C4B-11d2-89D8-000021473128}
00039     static const GUID thisGuid;
00040 };
00041
00042
00043 #endif // _LAND_H
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/ClipBookServer/ClipBook Server/ClRes.h Source File

  • WinBase
  • Cluster
  • Win2003
  • ClipBookServer
  • ClipBook Server

ClRes.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      ClRes.h
00007 //
00008 //  Implementation File:
00009 //      ClRes.cpp
00010 //
00011 //  Description:
00012 //      Main header file for the resource DLL for ClipBook Server (ClipBook Server).
00013 //
00014 //  Author:
00015 //      <name> (<e-mail name>) Mmmm DD, 2003
00016 //
00017 //  Revision History:
00018 //
00019 //  Notes:
00020 //
00021 /////////////////////////////////////////////////////////////////////////////
00022
00023 #pragma once
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Include Files
00027 /////////////////////////////////////////////////////////////////////////////
00028
00029 #define UNICODE 1
00030 #define _UNICODE 1
00031 #define _ATL_APARTMENT_THREADED
00032 #ifndef _WIN32_WINNT
00033 #define _WIN32_WINNT 0x0502
00034 #endif
00035
00036 #pragma warning( disable : 4127 )   // conditional expression is constant (BEGIN_COM_MAP)
00037 #pragma warning( disable : 4505 )   // unreferenced local function has been removed
00038 #pragma warning( disable : 4511 )   // copy constructor could not be generated
00039 #pragma warning( disable : 4514 )   // unreferenced inline function has been removed
00040 #pragma warning( disable : 4710 )   // function not expanded / function '<x>' not inlined
00041
00042 #pragma warning( push )
00043
00044 //
00045 // ATL includes
00046 //
00047 #include <atlbase.h>
00048
00049 extern CComModule _Module;
00050
00051 #include <atlcom.h>
00052
00053 //
00054 // These two include files contain all ClusCfg interface definitions and CATIDs
00055 //
00056 #include <ClusCfgServer.h>
00057 #include <ClusCfgGuids.h>
00058
00059 //
00060 // MgdResource.h is generated from MgdResource.idl.
00061 //
00062 #include "MgdResource.h"
00063 #include "resource.h"
00064
00065 #include <windows.h>
00066 #include <clusapi.h>
00067 #include <resapi.h>
00068 #include <stdio.h>
00069 #include <strsafe.h>
00070 #include <assert.h>
00071 #pragma warning( pop )
00072
00073 #include "StringUtils.h"
00074 #include "guids.h"
00075
00076 /////////////////////////////////////////////////////////////////////////////
00077 // ClipBook Server Definitions
00078 /////////////////////////////////////////////////////////////////////////////
00079
00080 //
00081 // This is the name of the cluster resource type.
00082 //
00083
00084 #define RESTYPE_NAME        L"ClipBook Server"
00085
00086 //
00087 // This is the dll name.
00088 //
00089
00090 #define RESTYPE_DLL_NAME    L"ClipBook Server.dll"
00091
00092 //
00093 // This is the name of the service this resource type controls.
00094 //
00095
00096 #define CLIPBOOKSERVER_SVCNAME   L"ClipSrv"
00097
00098 BOOL WINAPI ClipBookServerDllMain(
00099       HINSTANCE hDllHandleIn
00100     , DWORD     nReasonIn
00101     , LPVOID    ReservedIn
00102     );
00103
00104 DWORD WINAPI ClipBookServerStartup(
00105       LPCWSTR                       pwszResourceTypeIn
00106     , DWORD                         nMinVersionSupportedIn
00107     , DWORD                         nMaxVersionSupportedIn
00108     , PSET_RESOURCE_STATUS_ROUTINE  pfnSetResourceStatusIn
00109     , PLOG_EVENT_ROUTINE            pfnLogEventIn
00110     , PCLRES_FUNCTION_TABLE *       pFunctionTableOut
00111     );
00112
00113 /////////////////////////////////////////////////////////////////////////////
00114 // General Definitions
00115 /////////////////////////////////////////////////////////////////////////////
00116
00117 #define RESOURCE_TYPE_IP_ADDRESS    L"IP Address"
00118 #define RESOURCE_TYPE_NETWORK_NAME  L"Network Name"
00119
00120 #define DBG_PRINT printf
00121
00122 /////////////////////////////////////////////////////////////////////////////
00123 // Global Variables and Prototypes
00124 /////////////////////////////////////////////////////////////////////////////
00125
00126 //
00127 // Event Logging routine.
00128 //
00129
00130 extern PLOG_EVENT_ROUTINE g_pfnLogEvent;
00131
00132 //
00133 // Resource Status routine for pending Online and Offline calls.
00134 //
00135
00136 extern PSET_RESOURCE_STATUS_ROUTINE g_pfnSetResourceStatus;
00137
00138 //
00139 // Handle to Service Control Manager set by the first Open resource call.
00140 //
00141
00142 extern SC_HANDLE g_schSCMHandle;
00143
00144
00145 /////////////////////////////////////////////////////////////////////////////
00146 // Macro Definitions
00147 /////////////////////////////////////////////////////////////////////////////
00148
00149 #ifndef RTL_NUMBER_OF
00150 #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
00151 #endif
00152
00153 //
00154 // COM Macros to gain type checking.
00155 //
00156
00157 #if !defined( TypeSafeParams )
00158 #define TypeSafeParams( _interface, _ppunk ) \
00159     IID_##_interface, reinterpret_cast< void ** >( static_cast< _interface ** >( _ppunk ) )
00160 #endif // !defined( TypeSafeParams )
00161
00162 #if !defined( TypeSafeQI )
00163 #define TypeSafeQI( _interface, _ppunk ) \
00164     QueryInterface( TypeSafeParams( _interface, _ppunk ) )
00165 #endif // !defined( TypeSafeQI )
Generated on Wed Nov 13 2024 16:52:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_IMEUIDATA Member List

This is the complete list of members for _IMEUIDATA, including all inherited members.
fdwProperty | _IMEUIDATA
hListCand | _IMEUIDATA
hListCandMem | _IMEUIDATA
ImeState | _IMEUIDATA
uCompLen | _IMEUIDATA
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CS2Dialog Member List

This is the complete list of members for CS2Dialog, including all inherited members.
CDialogBase(HWND hWnd, HINSTANCE hInst) | CDialogBase |
CS2Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy *pTableCopy) | CS2Dialog |
Destroy() | CDialogBase | [virtual]
Display() | CS2Dialog | [virtual]
DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CS2Dialog | [static]
GetPrimaryKeys() | CS2Dialog | [virtual]
InitControls() | CS2Dialog | [virtual]
m_hInst | CDialogBase |
m_hWnd | CDialogBase |
m_pCTableCopy | CS2Dialog |
RecordSelectedIndexes(HWND hWnd) | CS2Dialog | [virtual]
RefreshControls() | CS2Dialog | [virtual]
ResetIndexList(HWND hWnd) | CS2Dialog | [virtual]
~CDialogBase() | CDialogBase | [virtual]
~CS2Dialog() | CS2Dialog | [virtual]
Generated on Wed Nov 13 2024 16:57:15 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/FileRep/FileRepAsyncPipe/FileRepServerProc.cpp Source File

  • NetDS
  • RPC
  • FileRep
  • FileRepAsyncPipe

FileRepServerProc.cpp

Go to the documentation of this file.
00001 /*
00002
00003     File Replication Sample
00004     Server System Service
00005
00006     FILE: FileRepServerProc.cpp
00007
00008     PURPOSE: Remote procedures for server system service
00009
00010     FUNCTIONS:
00011
00012     COMMENTS:
00013
00014 */
00015
00016 #include "common.h"
00017
00018 #include <stdlib.h>
00019 #include <stdio.h>
00020 #include <stddef.h>
00021 #include <tchar.h>
00022 #include <string.h>
00023 #include <time.h>
00024
00025 // header file generated by MIDL compiler
00026 #include "FileRepServer.h"
00027
00028 // Declarations for service routines.
00029 #include "Service.h"
00030
00031 #ifdef DEBUG2
00032 #include "DbgMsg.h"
00033 #endif
00034
00035 extern HANDLE ServerCompletionPort;
00036 extern LONG nThreadsAtServerCompletionPort;
00037
00038 #define ServerCompletionPortTimeout (20*1000)
00039
00040
00041 typedef enum tSReqState {
00042     StateArrived,
00043     StateQueued,
00044     StateActive
00045 } SReqState;
00046
00047 typedef enum {
00048   IoFileRep,
00049   IoPipe,
00050   IoFile
00051 } IoCompletionType;
00052
00053 typedef enum {
00054   Activate,
00055   Read,
00056   Push,
00057   Wait,
00058 } ActionType;
00059
00060 #ifdef DEBUG1
00061 unsigned nServerReqs = 0;
00062 #endif
00063
00064 //
00065 // Packages up the variables to be passed
00066 // to the processing thread.
00067 //
00068 typedef struct tSReq{
00069
00070     handle_t hFileRepClient;
00071     HANDLE hTokenHandle;
00072
00073     HANDLE hLocalFile;
00074
00075     LPTSTR LocalFileName;
00076
00077     // Set when we are impersonating the client.
00078     BOOL bImpersonating;
00079
00080     // Priority of this request.
00081     UINT Pri;
00082
00083     // User SID.
00084     PSID pSID;
00085
00086     SReqState State;
00087
00088     // The out-pipe we use to pull data from the server.
00089     ASYNC_CHAR_PIPE_TYPE *OutPipe;
00090
00091     // The async handle for the call to RemoteOpen.
00092     RPC_ASYNC_STATE *Async;
00093
00094     BYTE pbReadBuf[PULL_BUFSIZE];
00095
00096     LONG FileReadPos;
00097     ULONG PushSize;
00098
00099     OVERLAPPED FileOl;
00100
00101     ActionType Action;
00102
00103     CRITICAL_SECTION Lock;
00104
00105     BOOL bPushOutstanding;
00106     BOOL bReadOutstanding;
00107     BOOL bBuf;
00108
00109     ULONG cbRead;
00110
00111     // Set when all the non-null pushes have been dispatched.
00112     // This happens after reading the last segment of the file
00113     // and calling a push for it.  What remains to be done
00114     // is waiting for notification for the last data push and issuing a
00115     // NULL push.
00116     BOOL bLastDataPushIssued;
00117
00118     // Set when all of the file reads have completed.
00119     BOOL bReadsDone;
00120
00121     // Set when issuing the last push of 0 length.
00122     BOOL bNullPush;
00123
00124     // Set when a pull fails and RPC runtime cleans up the call.
00125     // There is no need to call Cancel after that.
00126     BOOL fCallInvalidated;
00127
00128     // We use this wariable to set an error code so that
00129     // ServerShutdownRequest can know whether an error has occurred.
00130     // If no error occurred, the async call will be completed.
00131     // Otherwise it will be cancelled.
00132     DWORD Status;
00133
00134 } SReq;
00135
00136
00137 //
00138 // Handles the requests placed on req queue and active req queue
00139 // and returns when no requests are available.
00140 //
00141 SReq* FindSReq(void) {
00142
00143 #ifdef DEBUG2
00144     TCHAR Msg[MSG_SIZE];
00145 #endif
00146
00147     SReq *pReq = NULL;
00148
00149     //
00150     // We will now go and check if the request or the active request sets of queues have anything that we
00151     // can service.  If they do not, then this thread can terminate.
00152     //
00153
00154     // Check if the request queues have anything on them.  If they do,
00155     // pick a request off the highest priority queue and handle it, but only if we
00156     // are not handling enough of those requests already.
00157     for (UINT pri = NumPriGroups; pri > 0; pri--) {
00158       pReq = (SReq *) QueueRemove(ServerReqQueues[pri-1]);
00159       if (pReq != NULL) {
00160         break;
00161       }
00162     }
00163
00164     if (pReq != NULL) {
00165
00166 #ifdef DEBUG2
00167       _stprintf(Msg, TEXT("RequestFile: Took req %p off Req queue %p\n"), pReq, ServerReqQueues[pReq->Pri]);
00168       DbgMsgRecord(Msg);
00169 #endif
00170
00171       if (CounterIncrement(pServerActiveReqCounters[pReq->Pri])) {
00172         if (QueueHashIncrementCounter(ServerActiveReqHashCounters[pReq->Pri], pReq->pSID)) {
00173 #ifdef DEBUG2
00174           _stprintf(Msg, TEXT("Incremented ServerActiveReqCounters[%d] and ServerActiveReqHashCounters[%d]\n"), pReq->Pri, pReq->Pri);
00175           DbgMsgRecord(Msg);
00176 #endif
00177           // The request now resides on a new queue.
00178           CounterDecrement(pServerReqCounters[pReq->Pri]);
00179 #ifdef DEBUG2
00180           _stprintf(Msg, TEXT("Decremented ServerReqCounters[%d]\n"), pReq->Pri);
00181           DbgMsgRecord(Msg);
00182 #endif
00183           pReq->State = StateActive;
00184
00185 #ifdef DEBUG2
00186           _stprintf(Msg, TEXT("RequestFile: Handling active req %p\n"), pReq);
00187           DbgMsgRecord(Msg);
00188 #endif
00189           return pReq;
00190
00191         }
00192         else {
00193           // There were too many requests for a given SID, place the request back
00194           // onto the queue.
00195
00196           // Don't forget to decrement the counter for the group!
00197           CounterDecrement(pServerActiveReqCounters[pReq->Pri]);
00198
00199           QueueAdd(ServerReqQueues[pReq->Pri], pReq, TRUE);
00200
00201 #ifdef DEBUG2
00202           _stprintf(Msg, TEXT("Too many active requests for a SID\n"));
00203           DbgMsgRecord(Msg);
00204           _stprintf(Msg, TEXT("RequestFile: Put req %p onto Req queue %p\n"), pReq, ServerReqQueues[pReq->Pri]);
00205           DbgMsgRecord(Msg);
00206 #endif
00207         }
00208       }
00209       else {
00210         // There were too many active requests for the user group, place the request back
00211         // onto the queue.
00212
00213         QueueAdd(ServerReqQueues[pReq->Pri], pReq, TRUE);
00214
00215 #ifdef DEBUG2
00216         _stprintf(Msg, TEXT("Too many active requests for priority %d\n"), pReq->Pri);
00217         DbgMsgRecord(Msg);
00218         _stprintf(Msg, TEXT("RequestFile: Put req %p onto Req queue %p\n"), pReq, ServerReqQueues[pReq->Pri]);
00219         DbgMsgRecord(Msg);
00220 #endif
00221       }
00222     }
00223
00224     return NULL;
00225 }
00226
00227 VOID FindAndActivateSReq(VOID) {
00228     DWORD status;
00229
00230     tSReq *pReq = FindSReq();
00231
00232     if (pReq) {
00233
00234 #ifdef DEBUG1
00235       QueueAdd(ServerActiveReqQueue, pReq, TRUE);
00236 #endif
00237
00238       // All that is requeired to activate the request is to queue a completion
00239       // packet with Activate key and the Req as Overlapped.
00240       status = PostQueuedCompletionStatus(ServerCompletionPort,
00241                                           0,
00242                                           IoFileRep,
00243                                           (LPOVERLAPPED)pReq);
00244       ASSERT(status);
00245     }
00246 }
00247
00248 //
00249 // Closes the file handle and frees all thread data if an error occured
00250 // in one of the following functions.
00251 //
00252 VOID ServerShutdownRequest(SReq *pReq) {
00253     DWORD status;
00254     RPC_STATUS rpcstatus;
00255
00256
00257 #ifdef DEBUG2
00258     TCHAR Msg[MSG_SIZE];
00259
00260     DbgMsgRecord(TEXT("-> ServerShutdownRequest\n"));
00261 #endif
00262
00263     ASSERT(pReq != NULL);
00264
00265 #ifdef DEBUG1
00266 nServerReqs--;
00267 #endif
00268
00269
00270     // We are actually deleting a request, pick a new one from the queue.
00271     FindAndActivateSReq();
00272
00273     // Stop impersonating if we are.
00274     // The first thing we do in handling a request is impersonating the client.
00275     if (pReq->bImpersonating) {
00276       rpcstatus = RpcRevertToSelf();
00277       if (rpcstatus != RPC_S_OK) {
00278         AddToMessageLogProcFailureEEInfo(TEXT("ServerShutdownRequest: RpcRevertToSelf"), rpcstatus);
00279       }
00280     }
00281
00282     // Complete or cancel the async call, depending on whether an error
00283     // has occurred.
00284     if (pReq->Status && !pReq->fCallInvalidated) {
00285       RpcAsyncAbortCall(pReq->Async,
00286                         TRUE);
00287     }
00288     else {
00289       RpcAsyncCompleteCall(pReq->Async,
00290                            &status);
00291     }
00292
00293     // Check that hLocalFile has been initialized and that initialization
00294     // was successful.
00295     if (pReq->hLocalFile != NULL && pReq->hLocalFile != INVALID_HANDLE_VALUE) {
00296       status = CloseHandle(pReq->hLocalFile);
00297       ASSERT(status != 0);
00298     }
00299
00300     if (pReq->LocalFileName != NULL) {
00301       AutoHeapFree(pReq->LocalFileName);
00302     }
00303
00304     // Check if any of the counters need to be decremented
00305     // since we are removing the request.
00306     if (pReq->State == StateQueued) {
00307       CounterDecrement(pServerReqCounters[pReq->Pri]);
00308 #ifdef DEBUG2
00309       _stprintf(Msg, TEXT("Decremented ServerReqCounters[%d]\n"), pReq->Pri);
00310       DbgMsgRecord(Msg);
00311 #endif
00312     }
00313     if (pReq->State == StateActive) {
00314       CounterDecrement(pServerActiveReqCounters[pReq->Pri]);
00315       QueueHashDecrementCounter(ServerActiveReqHashCounters[pReq->Pri], pReq->pSID);
00316 #ifdef DEBUG2
00317       _stprintf(Msg, TEXT("Decremented ServerActiveReqCounters[%d] and ServerActiveReqHashCounters[%d]\n"), pReq->Pri, pReq->Pri);
00318       DbgMsgRecord(Msg);
00319 #endif
00320
00321 #ifdef DEBUG1
00322       QueueRemoveData(ServerActiveReqQueue, pReq);
00323 #endif
00324     }
00325
00326     if (pReq->hTokenHandle != NULL) {
00327       status = CloseHandle(pReq->hTokenHandle);
00328       ASSERT(status != NULL);
00329     }
00330
00331     if (pReq->pSID != NULL) {
00332       AutoHeapFree(pReq->pSID);
00333     }
00334
00335     if (pReq->Lock.DebugInfo) {
00336       DeleteCriticalSection(&pReq->Lock);
00337     }
00338
00339     AutoHeapFree(pReq);
00340
00341 #ifdef DEBUG2
00342     DbgMsgRecord(TEXT("<- ServerShutdownRequest\n"));
00343 #endif
00344 }
00345
00346 //
00347 // Handles a request taken off req queue.
00348 // Returns TRUE on sucess.
00349 //
00350 BOOL HandleSReq(tSReq *pReq) {
00351
00352 #ifndef NO_SEC
00353     // We need to impersonate the user that has issued the
00354     // remote call.
00355     // We want to impersonate as soon as possible to minimise
00356     // the amount of resources that can be consumed by an attack.
00357     if (ImpersonateLoggedOnUser(pReq->hTokenHandle) == 0) {
00358         pReq->Status = GetLastError();
00359         ServerShutdownRequest(pReq);
00360         AddToMessageLogProcFailure(TEXT("HandleReq: ImpersonateLoggedOnUser"), GetLastError());
00361         return FALSE;
00362     }
00363     pReq->bImpersonating = TRUE;
00364 #endif
00365
00366     // Attempt to open the local file.
00367     if ((pReq->hLocalFile = CreateFile(pReq->LocalFileName,
00368                             GENERIC_READ,
00369                             FILE_SHARE_READ,
00370                             NULL,
00371                             OPEN_EXISTING,
00372                             FILE_FLAG_OVERLAPPED,
00373                             NULL)) == INVALID_HANDLE_VALUE) {
00374         pReq->Status = GetLastError();
00375         ServerShutdownRequest(pReq);
00376         AddToMessageLogProcFailure(TEXT("HandleReq: CreateFile"), GetLastError());
00377         return FALSE;
00378     }
00379
00380 #ifndef NO_SEC
00381     // We need to stop impersonating before putting this request back into
00382     // a queue or quitting.
00383     if (RevertToSelf() == 0) {
00384         AddToMessageLogProcFailure(TEXT("HandleReq: RevertToSelf"), GetLastError());
00385     }
00386     pReq->bImpersonating = FALSE;
00387 #endif
00388
00389     // Initialize the request fileds for throtteling the IO
00390
00391     pReq->FileOl.Offset = 0;
00392     pReq->FileOl.OffsetHigh = 0;
00393     pReq->FileOl.hEvent = NULL;
00394
00395     pReq->Async->u.IOC.dwCompletionKey = IoPipe;
00396     pReq->Async->u.IOC.lpOverlapped = (LPOVERLAPPED) pReq;
00397
00398     pReq->bLastDataPushIssued = FALSE;
00399     pReq->bReadsDone = FALSE;
00400     pReq->bNullPush = FALSE;
00401
00402     pReq->Async->Flags = RPC_C_NOTIFY_ON_SEND_COMPLETE;
00403     pReq->Async->UserInfo = pReq;
00404     pReq->Async->NotificationType = RpcNotificationTypeIoc;
00405     pReq->Async->u.IOC.hIOPort = ServerCompletionPort;
00406
00407     // Link this file to the client requests's IO completion port:
00408     if ((ServerCompletionPort = CreateIoCompletionPort (pReq->hLocalFile,
00409                                                         ServerCompletionPort,
00410                                                         IoFile,
00411                                                         0)) == NULL) {
00412         AddToMessageLogProcFailure(TEXT("HandleActiveReq: CreateIoCompletionPort"), GetLastError());
00413         return FALSE;
00414     }
00415
00416     pReq->bReadOutstanding = FALSE;
00417     pReq->bPushOutstanding = FALSE;
00418     pReq->bBuf = FALSE;
00419
00420     // Init the critsec.
00421     if (InitializeCriticalSectionAndSpinCount(&pReq->Lock, 10) == 0) {
00422         AddToMessageLogProcFailure(TEXT("HandleActiveReq: InitializeCriticalSectionAndSpinCount"), GetLastError());
00423         return FALSE;
00424     }
00425
00426     return TRUE;
00427 }
00428
00429 //
00430 // Handles a request taken off active req queue
00431 //
00432 VOID SServiceRequests(VOID) {
00433     tSReq *pReq;
00434
00435 #ifdef DEBUG2
00436     TCHAR Msg[MSG_SIZE];
00437 #endif
00438
00439     DWORD dwNumberOfBytesTransferred;
00440     DWORD dwCompletionKey;
00441     OVERLAPPED *lpOverlapped;
00442
00443     ActionType Action = Wait;
00444
00445     while(TRUE) {
00446
00447       //
00448       // Read data from file.
00449       //
00450       if (Action == Read) {
00451
00452         EnterCriticalSection(&pReq->Lock);
00453
00454         ASSERT(!pReq->bBuf);
00455         ASSERT(!pReq->bReadOutstanding);
00456
00457
00458         // We did not read anything yet.
00459         pReq->cbRead = 0;
00460
00461         pReq->bReadOutstanding = TRUE;
00462
00463 #ifdef DEBUG2
00464         _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: reading file for req %p\n"), GetCurrentThreadId(), pReq);
00465         DbgMsgRecord(Msg);
00466 #endif
00467
00468         if(!ReadFile(pReq->hLocalFile, pReq->pbReadBuf, PUSH_BUFSIZE, &pReq->cbRead, &pReq->FileOl)) {
00469           if (GetLastError() != ERROR_IO_PENDING) {
00470             AddToMessageLogProcFailure(TEXT("HandleActiveSReq: WriteFile"), GetLastError());
00471             pReq->Status = GetLastError();
00472
00473             LeaveCriticalSection(&pReq->Lock);
00474
00475             ServerShutdownRequest(pReq);
00476
00477             Action = Wait;
00478           }
00479         }
00480
00481         Action = Wait;
00482
00483         LeaveCriticalSection(&pReq->Lock);
00484       }
00485
00486       //
00487       // Push the data to the client.
00488       //
00489       else if (Action == Push) {
00490
00491         EnterCriticalSection(&pReq->Lock);
00492
00493 #ifdef DEBUG2
00494         _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: pushing a buffer for req %p\n"), GetCurrentThreadId(), pReq);
00495         DbgMsgRecord(Msg);
00496 #endif
00497
00498         // Doing a regular Push for the data read from the file.
00499         if (!pReq->bNullPush) {
00500           ASSERT(!pReq->bReadOutstanding);
00501           ASSERT(!pReq->bPushOutstanding);
00502           ASSERT(pReq->bBuf);
00503
00504           pReq->bPushOutstanding = TRUE;
00505
00506
00507           pReq->Status = ((WINAPI_MY_PIPE_PUSH) pReq->OutPipe->push)(pReq->OutPipe->state, (char *)pReq->pbReadBuf, pReq->cbRead);
00508
00509           pReq->bBuf = FALSE;
00510
00511           if(pReq->Status != RPC_S_OK) {
00512             pReq->bReadsDone = TRUE;
00513             pReq->bPushOutstanding = FALSE;
00514             pReq->fCallInvalidated = TRUE;
00515
00516             if (pReq->bReadOutstanding == FALSE) {
00517               LeaveCriticalSection(&pReq->Lock);
00518               ServerShutdownRequest(pReq);
00519
00520               Action = Wait;
00521             }
00522             else
00523               LeaveCriticalSection(&pReq->Lock);
00524           }
00525           else {
00526
00527             if (!pReq->bReadsDone)
00528               Action = Read;
00529             else {
00530               Action = Wait;
00531               pReq->bLastDataPushIssued = TRUE;
00532             }
00533
00534             LeaveCriticalSection(&pReq->Lock);
00535           }
00536         }
00537
00538         // Doing a "NULL" push to signal the end of the pipe out-stream.
00539         else {
00540           ASSERT(!pReq->bReadOutstanding);
00541           ASSERT(!pReq->bPushOutstanding);
00542           ASSERT(!pReq->bBuf);
00543
00544           pReq->bPushOutstanding = TRUE;
00545
00546
00547           WINAPI_MY_PIPE_PUSH pPush = (WINAPI_MY_PIPE_PUSH) pReq->OutPipe->push;
00548
00549           pReq->Status = pPush(pReq->OutPipe->state, NULL, 0);
00550
00551           if(pReq->Status != RPC_S_OK) {
00552             pReq->fCallInvalidated = TRUE;
00553             LeaveCriticalSection(&pReq->Lock);
00554             ServerShutdownRequest(pReq);
00555
00556             Action = Wait;
00557             }
00558           else {
00559             Action = Wait;
00560             LeaveCriticalSection(&pReq->Lock);
00561           }
00562         }
00563       }
00564
00565       //
00566       // Wait on the completion port.
00567       //
00568       else if (Action == Wait) {
00569
00570         InterlockedIncrement(&nThreadsAtServerCompletionPort);
00571
00572         ASSERT(nThreadsAtServerCompletionPort >= 0);
00573
00574 #ifdef DEBUG2
00575         _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: waiting on a completion port\n"), GetCurrentThreadId());
00576         DbgMsgRecord(Msg);
00577 #endif
00578
00579         if (!GetQueuedCompletionStatus(ServerCompletionPort,
00580                                        &dwNumberOfBytesTransferred,
00581                                        (PULONG_PTR)&dwCompletionKey,
00582                                        &lpOverlapped,
00583                                        ServerCompletionPortTimeout)) {
00584
00585           LONG nThreads = InterlockedDecrement(&nThreadsAtServerCompletionPort);
00586
00587           if (GetLastError() == WAIT_TIMEOUT) {
00588
00589
00590 #ifdef DEBUG2
00591             _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: timed out waiting on a completion port\n"), GetCurrentThreadId());
00592             DbgMsgRecord(Msg);
00593 #endif
00594
00595             if (nThreads != 0) {
00596               return;
00597             }
00598             else {
00599               continue;
00600             }
00601           }
00602           else {
00603             AddToMessageLogProcFailure(TEXT("SServiceRequests: GetQueuedCompletionStatus"), GetLastError());
00604
00605             Action = Wait;
00606           }
00607         }
00608
00609         else {
00610
00611           // If this is the last thread to come off a completion port,
00612           // spin up an extra worker thread.
00613           if (InterlockedDecrement(&nThreadsAtServerCompletionPort) == 0) {
00614             HANDLE hThread;
00615             ULONG ThreadIdentifier;
00616             DWORD status;
00617
00618             if ((hThread = CreateThread(NULL,
00619                                         0,
00620                                         (LPTHREAD_START_ROUTINE) SServiceRequests,
00621                                         NULL,
00622                                         0,
00623                                         &ThreadIdentifier)) == NULL) {
00624
00625               // If creating a thread fails there is really nothing that we
00626               // we can do.  Just continue.
00627               AddToMessageLogProcFailure(TEXT("SServiceRequests: CreateThread"), GetLastError());
00628             }
00629             else {
00630               // Unless we close a handle to the thread, it will remain in the
00631               // system even after its execution has terminated.
00632               status = CloseHandle(hThread);
00633               ASSERT(status != 0);
00634             }
00635           }
00636
00637           ASSERT(nThreadsAtServerCompletionPort >= 0);
00638
00639
00640           //
00641           // Received file IO completion.
00642           //
00643           if (dwCompletionKey == IoFile) {
00644
00645             pReq = (SReq *) ((size_t)lpOverlapped - offsetof(SReq, FileOl));
00646
00647 #ifdef DEBUG2
00648             _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: completed File IO for req %p\n"), GetCurrentThreadId(), pReq);
00649             DbgMsgRecord(Msg);
00650 #endif
00651
00652             EnterCriticalSection(&pReq->Lock);
00653
00654
00655             pReq->cbRead = dwNumberOfBytesTransferred;
00656
00657
00658             ASSERT(pReq->bReadOutstanding);
00659             ASSERT(!pReq->bBuf);
00660
00661             pReq->bReadOutstanding = FALSE;
00662             pReq->bBuf = TRUE;
00663
00664             ASSERT(!pReq->bLastDataPushIssued);
00665
00666             if(pReq->Status != RPC_S_OK) {
00667               LeaveCriticalSection(&pReq->Lock);
00668               ServerShutdownRequest(pReq);
00669
00670               Action = Wait;
00671             }
00672             else {
00673
00674               // If we read less then we asked, then EOF has been reached.
00675               if (pReq->cbRead != PUSH_BUFSIZE) {
00676
00677                 pReq->bReadsDone = TRUE;
00678
00679                 // If we read 0 bytes, then the previous data push has been
00680                 // the last one.  So the last data push has already been issued.
00681                 if (pReq->cbRead == 0) {
00682                   pReq->bLastDataPushIssued = TRUE;
00683
00684                   // If there are no outstanding pushes, we can do a NULL push.
00685                   if (pReq->bPushOutstanding == FALSE) {
00686                     pReq->bNullPush = TRUE;
00687                   }
00688                 }
00689               }
00690
00691               pReq->FileOl.Offset += pReq->cbRead;
00692
00693               // We have at most one outstanding push, since RPC runtime
00694               // guarantees proper notification if there are no more then
00695               // one push outstanding.
00696               if (pReq->bPushOutstanding == TRUE)
00697                 Action = Wait;
00698               else
00699                 Action = Push;
00700
00701               LeaveCriticalSection(&pReq->Lock);
00702             }
00703
00704           }
00705
00706           //
00707           // Received pipe IO completion.
00708           //
00709           else if(dwCompletionKey == IoPipe) {
00710
00711 #ifdef DEBUG2
00712             _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: completed Pipe IO for req %p\n"), GetCurrentThreadId(), pReq);
00713             DbgMsgRecord(Msg);
00714 #endif
00715
00716             pReq = (SReq *) lpOverlapped;
00717
00718             EnterCriticalSection(&pReq->Lock);
00719
00720
00721             if (pReq->Async->Event != RpcSendComplete) {
00722               ASSERT(0);
00723             }
00724
00725             ASSERT(pReq->bPushOutstanding);
00726
00727             pReq->bPushOutstanding = FALSE;
00728
00729             // The completion of the NULL push terminates the request.
00730             // The reuest is now handled.
00731             if (pReq->bNullPush) {
00732               LeaveCriticalSection(&pReq->Lock);
00733               ServerShutdownRequest(pReq);
00734
00735               Action = Wait;
00736             }
00737
00738             // This is a regular data push.
00739             else {
00740
00741               // If there is a read outstanding, wait for it to complete
00742               // since we do not have any other data to push at present.
00743               if (pReq->bReadOutstanding)
00744                 Action = Wait;
00745
00746               // If there is a buffer to send, push it.
00747               else if (pReq->bBuf)
00748                 Action = Push;
00749
00750               // If the this is the completion of the last data push, then
00751               // we just need to do the NULL push.
00752               else if (pReq->bLastDataPushIssued) {
00753                 Action = Push;
00754                 pReq->bNullPush = TRUE;
00755               }
00756
00757               else {
00758                 /*ASSERT(0);*/Action = Wait;
00759               }
00760
00761               LeaveCriticalSection(&pReq->Lock);
00762             }
00763
00764           }
00765
00766           //
00767           // Received an internal FileRep IO completion.
00768           //
00769           else if(dwCompletionKey == IoFileRep) {
00770             pReq = (SReq *) lpOverlapped;
00771
00772
00773 #ifdef DEBUG2
00774             _stprintf(Msg, TEXT("THREAD %d: SServiceRequests: completed FileRep internal IO for req %p\n"), GetCurrentThreadId(), pReq);
00775             DbgMsgRecord(Msg);
00776 #endif
00777
00778             // This is a signal to handle a new request.
00779             // If the request can be activated, then handle it.
00780             if(HandleSReq(pReq)) {
00781               Action = Read;
00782             }
00783             // Otherwise, do event.
00784             else {
00785               Action = Wait;
00786             }
00787           }
00788
00789           else {
00790             ASSERT(0);
00791           }
00792         }
00793       }
00794
00795       else {
00796         ASSERT(0);
00797       }
00798     }
00799 }
00800
00801 void s_RemoteReadAsyncPipe(PRPC_ASYNC_STATE pAsync,
00802                            handle_t hFileRepClient,
00803                            TCHAR FileName[128],
00804                            ASYNC_CHAR_PIPE_TYPE *OutPipe) {
00805
00806     int nReply = 1;
00807
00808     unsigned long ecount = 0;
00809
00810     SReq *pReq = NULL;
00811
00812     TCHAR Msg[MSG_SIZE];
00813
00814 #ifdef DEBUG2
00815     DbgMsgRecord(TEXT("-> s_RemoteReadAsyncPipe\n"));
00816 #endif
00817
00818     if((pReq = (SReq *) AutoHeapAlloc(sizeof(SReq))) == NULL) {
00819         AddRpcEEInfoAndRaiseException(ERROR_OUTOFMEMORY, TEXT("RequestFile: AutoHeapAlloc failed"));
00820         return;
00821     }
00822
00823     // Set pReq' fields to NULL so that we will know
00824     // in ServerShutdownRequest which ones have been initialized.
00825     pReq->hFileRepClient = hFileRepClient;
00826
00827     pReq->hTokenHandle = NULL;
00828
00829     pReq->hLocalFile = NULL;
00830     pReq->bImpersonating = FALSE;
00831     pReq->Pri = 0;
00832     pReq->State = StateArrived;
00833
00834     pReq->pSID = NULL;
00835
00836     pReq->Status = 0;
00837
00838     pReq->Lock.DebugInfo = NULL;
00839
00840     // The out-pipe we use to pull data from the server.
00841     pReq->OutPipe = OutPipe;
00842
00843     // The async handle for the call to RemoteOpen.
00844     pReq->Async = pAsync;
00845
00846
00847     pReq->fCallInvalidated = FALSE;
00848
00849 #ifdef DEBUG1
00850     nServerReqs++;
00851 #endif
00852
00853     if ((pReq->LocalFileName = (LPTSTR) AutoHeapAlloc((_tcslen(FileName)+1) * sizeof(TCHAR))) == NULL) {
00854         pReq->Status = GetLastError();
00855         ServerShutdownRequest(pReq);
00856         AddRpcEEInfoAndRaiseException(ERROR_OUTOFMEMORY, TEXT("RequestFile: AutoHeapAlloc failed"));
00857         return;
00858     }
00859     CopyMemory(pReq->LocalFileName, FileName, (_tcslen(FileName)+1) * sizeof(TCHAR));
00860
00861     //
00862     // Check that we are not exceeding the bound on the number
00863     // of concurrent requests for this user's priority group.
00864     // And update the number of such requests.
00865     //
00866
00867 #ifndef NO_SEC
00868     RPC_STATUS rpcstatus;
00869
00870     // Impersonate the caller so that we can get the caller's SID
00871     if ((rpcstatus = RpcImpersonateClient(pReq->hFileRepClient)) != RPC_S_OK) {
00872         pReq->Status = GetLastError();
00873         ServerShutdownRequest(pReq);
00874         AddRpcEEInfoAndRaiseException(rpcstatus, TEXT("RequestFile: RpcImpersonateClient failed"));
00875         return;
00876     }
00877     pReq->bImpersonating = TRUE;
00878
00879     // We need to write down the access token for the user so that
00880     // we can use it for impersonation later when the client binding handle
00881     // gets deallocated.
00882     if (OpenThreadToken(GetCurrentThread(),
00883                         TOKEN_QUERY | TOKEN_IMPERSONATE,
00884                         TRUE,
00885                         &pReq->hTokenHandle) == 0) {
00886
00887         pReq->Status = GetLastError();
00888         ServerShutdownRequest(pReq);
00889         AddRpcEEInfoAndRaiseException(GetLastError(), TEXT("RequestFile: OpenThreadToken failed"));
00890         return;
00891     }
00892
00893     // Determine current user's priority level.  This corresponds to the
00894     // priority level of the callee, since we are impersonating.
00895     pReq->Pri = GetCurrentUserPriority();
00896
00897     // Write down the SID for the user.
00898     pReq->pSID = GetUserSID();
00899
00900     // Stop impersonating.  We got what we wanted.
00901     if ((rpcstatus = RpcRevertToSelf()) != RPC_S_OK) {
00902         pReq->bImpersonating = FALSE;
00903
00904         pReq->Status = GetLastError();
00905         ServerShutdownRequest(pReq);
00906         AddRpcEEInfoAndRaiseException(rpcstatus, TEXT("RequestFile: RpcRevertToSelf failed"));
00907         return;
00908     }
00909     pReq->bImpersonating = FALSE;
00910
00911 #else
00912
00913     pReq->Pri = 1;
00914
00915     unsigned SidLength = GetLengthSid(pAnonSID);
00916     if ((pReq->pSID = AutoHeapAlloc(SidLength)) == NULL) {
00917         pReq->Status = GetLastError();
00918         ServerShutdownRequest(pReq);
00919         AddRpcEEInfoAndRaiseException(GetLastError(), TEXT("RequestFile: AutoHeapAlloc failed"));
00920         return;
00921     }
00922
00923     if (CopySid(SidLength, pReq->pSID, pAnonSID) == 0) {
00924         pReq->Status = GetLastError();
00925         ServerShutdownRequest(pReq);
00926         AddRpcEEInfoAndRaiseException(GetLastError(), TEXT("RequestFile: CopySID failed"));
00927         return;
00928     }
00929
00930 #endif
00931
00932 #ifdef DEBUG2
00933     _stprintf(Msg, TEXT("RequestFile: Pri=%d for req %p\n"), pReq->Pri, pReq);
00934     DbgMsgRecord(Msg);
00935 #endif
00936
00937     // If there are no workers ot handle the request, create one.
00938
00939     HANDLE hThread;
00940     ULONG ThreadIdentifier;
00941     DWORD status;
00942
00943     if (nThreadsAtServerCompletionPort < 1) {
00944
00945       // Go service some requests, remember that you are
00946       // an RPC thread.
00947       if ((hThread = CreateThread(NULL,
00948                                   0,
00949                                   (LPTHREAD_START_ROUTINE) SServiceRequests,
00950                                   NULL,
00951                                   0,
00952                                   &ThreadIdentifier)) == NULL) {
00953
00954         pReq->Status = GetLastError();
00955         ServerShutdownRequest(pReq);
00956         AddToMessageLogProcFailure(TEXT("SServiceRequests: CreateThread"), GetLastError());
00957         return;
00958       }
00959
00960       // Unless we close a handle to the thread, it will remain in the
00961       // system even after its execution has terminated.
00962       status = CloseHandle(hThread);
00963       ASSERT(status != 0);
00964     }
00965
00966     // We need to place request onto the queue only after we know that there is someone
00967     // who will actually be able to pick it up.  Thus, we need to create the thread first.
00968
00969     // Increment the counter for the number of concurrent requests.
00970     if (!CounterIncrement(pServerReqCounters[pReq->Pri])) {
00971
00972         pReq->Status = GetLastError();
00973         ServerShutdownRequest(pReq);
00974         // We have to raise exception after deallocating the data
00975         // since there is a possibility that a client thread
00976         // will retry and will attempt to open this local file
00977         // while it's previous request is still holding a lock.
00978         // This has been actually hit on an overloaded system.
00979         AddRpcEEInfoAndRaiseException(RPC_S_SERVER_TOO_BUSY, TEXT("RequestFile: CounterIncrement failed"));
00980         return;
00981     }
00982 #ifdef DEBUG2
00983     _stprintf(Msg, TEXT("Incremented ServerReqCounters[%d]\n"), pReq->Pri);
00984     DbgMsgRecord(Msg);
00985 #endif
00986
00987     pReq->State = StateQueued;
00988
00989 #ifdef DEBUG2
00990     _stprintf(Msg, TEXT("RequestFile: Put req %p onto Req queue %p\n"), pReq, ServerReqQueues[pReq->Pri]);
00991     DbgMsgRecord(Msg);
00992 #endif
00993
00994     // Place the request onto the queue.
00995     QueueAdd(ServerReqQueues[pReq->Pri], pReq, TRUE);
00996
00997     // After this point the request can be deleted.  Do not touch it.
00998
00999     // Now if we can, find a queued request and activate it.
01000     FindAndActivateSReq();
01001
01002 #ifdef DEBUG2
01003     DbgMsgRecord(TEXT("<- RequestFile\n"));
01004 #endif
01005
01006     return;
01007 }
01008
01009 // end FileRepServerProc.cpp
01010
01011
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/rqs/inc/rustring.h Source File

  • NetDS
  • RRas
  • rqs
  • inc

rustring.h

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 //  File:       RuString.h
00004 //
00005 //  Synopsis:   String helper functions
00006 //
00007 //  Copyright   (c) Microsoft Corporation.  All rights reserved.
00008 //
00009 //---------------------------------------------------------------------------
00010
00011 #pragma once
00012
00013 #ifndef __RuString_h
00014 #define __RuString_h
00015
00016 //----------------------------------------------------------------------------
00017 //
00018 //                              Narrow <-> Wide conversions
00019 //
00020 //----------------------------------------------------------------------------
00021
00022 PSTR
00023 RuStringDupWtoA(
00024     IN      PWSTR   psz
00025 );
00026
00027 PWSTR
00028 RuStringDupAtoW(
00029     IN      PSTR    pszansi
00030 );
00031
00032
00033 #endif // __RuString_h
00034
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/about.h Source File

  • SysMgmt
  • MMC
  • Nameext

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/datasource.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

datasource.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1995-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module DATASOURCE.CPP
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////
00015 #include "WinMain.h"
00016 #include "Common.h"
00017 #include "DataSource.h"
00018 #include "msdaguid.h" //CLSID_OLEDB_ENUMERATOR
00019
00020
00021 /////////////////////////////////////////////////////////////////
00022 // CDataSource::CDataSource
00023 //
00024 /////////////////////////////////////////////////////////////////
00025 CDataSource::CDataSource()
00026 {
00027   //OLEDB Interfaces
00028   m_pIDBInitialize    = NULL; //DataSource
00029   m_pIOpenRowset      = NULL; //Session
00030   m_pIDBSchemaRowset    = NULL; //Session
00031   m_pITableDefinition   = NULL; //Session
00032   m_pIIndexDefinition   = NULL; //Session
00033   m_pICommandText     = NULL; //Command
00034
00035   //ProviderInfo
00036   m_pwszProviderName    = NULL; //Pointer into m_rgProviderInfo.wszName
00037   m_pwszProviderParseName = NULL; //Pointer into m_rgProviderInfo.wszParseName
00038   m_pwszProviderFileName  = NULL; //DBPROP_PROVIDERNAME
00039   m_pwszProviderVer   = NULL; //DBPROP_PROVIDERVER
00040   m_pwszProviderOLEDBVer  = NULL; //DBPROP_PROVIDEROLEDBVER
00041
00042   //Enumerator ProvierInfo
00043   m_cProviderInfo     = 0;
00044   m_rgProviderInfo    = NULL;
00045   m_pIParseDisplayName  = NULL; //Enumerator
00046
00047   //Properties
00048   m_fReadOnly       = TRUE; //DBPROP_DATASOURCEREADONLY
00049   m_fPrimaryKeysSupported = FALSE;//DBPROP_SQLSUPPORT
00050   m_fMultipleParamSets    = FALSE;//DBPROP_MULTIPLEPARAMSETS
00051   m_fIRowsetChange    = FALSE;//DBPROP_IRowsetChange
00052   m_fIRowsetUpdate    = FALSE;//DBPROP_IRowsetUpdate
00053   m_dwStorageObjects    = 0;  //DBPROP_STRUCTUREDSTORAGE
00054
00055   m_pwszCatalog     = NULL; //DBPROP_CURRENTCATALOG
00056   m_pwszCatalogTerm   = NULL; //DBPROP_CATALOGTERM
00057   m_pwszCatalogLocation = NULL; //DBPROP_CATALOGLOCATION
00058   m_pwszSchemaTerm    = NULL; //DBPROP_SCHEMATERM
00059   m_pwszTableTerm     = NULL; //DBPROP_TABLETERM
00060
00061   //DataSource Info
00062   m_ulActiveSessions    = 0;  //DBPROP_ACTIVESESSIONS
00063   m_pwszDataSource    = NULL; //DBPROP_DATASOURCENAME
00064   m_pwszDBMS        = NULL; //DBPROP_DBMSNAME
00065   m_pwszDBMSVer     = NULL; //DBPROP_DBMSVER
00066
00067   m_fConnected = FALSE;
00068 }
00069
00070 /////////////////////////////////////////////////////////////////
00071 // CDataSource::~CDataSource
00072 //
00073 /////////////////////////////////////////////////////////////////
00074 CDataSource::~CDataSource()
00075 {
00076   Disconnect();
00077
00078   //Enumerator ProviderInfo
00079   m_cProviderInfo     = 0;
00080   SAFE_FREE(m_rgProviderInfo);
00081   SAFE_RELEASE(m_pIParseDisplayName);
00082 }
00083
00084
00085 /////////////////////////////////////////////////////////////////
00086 // BOOL CDataSource::IsConnected
00087 //
00088 /////////////////////////////////////////////////////////////////
00089 BOOL CDataSource::IsConnected()
00090 {
00091   return m_fConnected;
00092 }
00093
00094
00095 /////////////////////////////////////////////////////////////////
00096 // BOOL CDataSource::IsSimilar
00097 //
00098 /////////////////////////////////////////////////////////////////
00099 BOOL CDataSource::IsSimilar(CDataSource* pCDataSource)
00100 {
00101   ASSERT(pCDataSource);
00102
00103   //Must be Connected to compare
00104   if(!IsConnected() || !pCDataSource->IsConnected())
00105     return FALSE;
00106
00107   ASSERT(m_pwszDBMS && pCDataSource->m_pwszDBMS);
00108   ASSERT(m_pwszDBMSVer && pCDataSource->m_pwszDBMSVer);
00109
00110   //Similiar: Must be the same DBMS and Version
00111   if(wcscmp(m_pwszDBMS, pCDataSource->m_pwszDBMS)==0 &&
00112     wcscmp(m_pwszDBMSVer, pCDataSource->m_pwszDBMSVer)==0)
00113     return TRUE;
00114
00115   return FALSE;
00116 }
00117
00118
00119 /////////////////////////////////////////////////////////////////
00120 // BOOL CDataSource::IsEqual
00121 //
00122 /////////////////////////////////////////////////////////////////
00123 BOOL CDataSource::IsEqual(CDataSource* pCDataSource)
00124 {
00125   ASSERT(pCDataSource);
00126
00127   //Must be Connected to compare
00128   if(!IsConnected() || !pCDataSource->IsConnected())
00129     return FALSE;
00130
00131   ASSERT(m_pwszCatalog && pCDataSource->m_pwszCatalog);
00132   ASSERT(m_pwszDBMS && pCDataSource->m_pwszDBMS);
00133   ASSERT(m_pwszDBMSVer && pCDataSource->m_pwszDBMSVer);
00134
00135   //Equal:
00136   //Must have same Catalog, DBMS, Version
00137   //Note, Don't have to have the same DataSource Name (an access
00138   //database can have multiple names for the same file)
00139   if(wcscmp(m_pwszCatalog, pCDataSource->m_pwszCatalog)==0 &&
00140     wcscmp(m_pwszDBMS, pCDataSource->m_pwszDBMS)==0 &&
00141     wcscmp(m_pwszDBMSVer, pCDataSource->m_pwszDBMSVer)==0)
00142     return TRUE;
00143
00144   return FALSE;
00145 }
00146
00147
00148 /////////////////////////////////////////////////////////////////
00149 // BOOL CDataSource::Disconnect
00150 //
00151 /////////////////////////////////////////////////////////////////
00152 BOOL CDataSource::Disconnect()
00153 {
00154   //Interfaces
00155   SAFE_RELEASE(m_pIDBInitialize);
00156   SAFE_RELEASE(m_pIOpenRowset);
00157   SAFE_RELEASE(m_pIDBSchemaRowset);
00158   SAFE_RELEASE(m_pITableDefinition);
00159   SAFE_RELEASE(m_pIIndexDefinition);
00160   SAFE_RELEASE(m_pICommandText);
00161
00162   //Properties
00163   SAFE_FREE(m_pwszCatalog);
00164   SAFE_FREE(m_pwszCatalogTerm);
00165   SAFE_FREE(m_pwszCatalogLocation);
00166   SAFE_FREE(m_pwszSchemaTerm);
00167   SAFE_FREE(m_pwszTableTerm);
00168   SAFE_FREE(m_pwszDataSource);
00169   SAFE_FREE(m_pwszDBMS);
00170   SAFE_FREE(m_pwszDBMSVer);
00171
00172   SAFE_FREE(m_pwszProviderFileName);
00173   SAFE_FREE(m_pwszProviderVer);
00174   SAFE_FREE(m_pwszProviderOLEDBVer);
00175
00176   m_fConnected = FALSE;
00177   return TRUE;
00178 }
00179
00180
00181 /////////////////////////////////////////////////////////////////
00182 // BOOL CDataSource::Connect
00183 //
00184 /////////////////////////////////////////////////////////////////
00185 HRESULT CDataSource::Connect(HWND hWnd, CDataSource* pCDataSource)
00186 {
00187   ASSERT(hWnd);
00188
00189   HRESULT       hr;
00190   ULONG               cPropSets = 0;
00191   DBPROPSET*      rgPropSets = NULL;
00192
00193   IDBProperties*    pIDBProperties = NULL;
00194   IDBCreateSession*   pIDBCreateSession = NULL;
00195
00196   //Local interface pointers, until we have a connection
00197   IDBInitialize*    pIDBInitialize = NULL;
00198   IOpenRowset*    pIOpenRowset = NULL;
00199   IDBCreateCommand*   pIDBCreateCommand = NULL;
00200   ICommandText*   pICommandText = NULL;
00201
00202   ULONG chEaten = 0;
00203   IMoniker* pIMoniker = NULL;
00204
00205
00206   //if there is no provider chosen pick something from the enumerator
00207   if(pCDataSource == NULL)
00208   {
00209     //if there is an enumerator
00210     if (m_pIParseDisplayName)
00211     {
00212       //Get the IDBInitalize interface
00213       //Could just do a CoCreateInstance on the Provider CLSID, but since were using
00214       //The enumerator, we can be a more general app by using IParseDisplayName
00215       ASSERT(m_pwszProviderParseName);
00216       XTESTC(hr = m_pIParseDisplayName->ParseDisplayName(NULL, m_pwszProviderParseName, &chEaten, &pIMoniker));
00217       XTESTC(hr = BindMoniker(pIMoniker, 0, IID_IDBInitialize, (void**)&pIDBInitialize));
00218     }
00219     else
00220     {
00221       //if there is no ParseDisplay name there was no enumerator
00222       //so let try whatever the user typed in if something was typed in
00223       if (m_pwszProviderName)
00224       {
00225         CLSID clsid;
00226         hr = CLSIDFromProgID(m_pwszProviderName, &clsid);
00227
00228         if(SUCCEEDED(hr))
00229         {
00230           XTESTC(hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize, (void**)&pIDBInitialize));
00231         }
00232       }
00233     }
00234   }
00235   else
00236   {
00237     //get what was chosen
00238     CLSID clsid;
00239     XTESTC(hr = CLSIDFromProgID(m_pwszProviderName, &clsid));
00240     if (S_OK  == hr)
00241     {
00242       XTESTC(hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize, (void**)&pIDBInitialize));
00243     }
00244     else
00245     {
00246       goto CLEANUP;
00247     }
00248   }
00249
00250   //DBPROP_INIT_HWND
00251   if(IsSettableProperty(pIDBInitialize, DBPROP_INIT_HWND, DBPROPSET_DBINIT))
00252     SetProperty(DBPROP_INIT_HWND, DBPROPSET_DBINIT, &cPropSets, &rgPropSets, DBTYPE_I4, (LONG)hWnd);
00253   //DBPROP_INIT_PROMPT
00254   if(IsSettableProperty(pIDBInitialize, DBPROP_INIT_PROMPT, DBPROPSET_DBINIT))
00255     SetProperty(DBPROP_INIT_PROMPT, DBPROPSET_DBINIT, &cPropSets, &rgPropSets, DBTYPE_I2, DBPROMPT_COMPLETE);
00256   //DBPROP_INIT_MODE
00257   if(IsSettableProperty(pIDBInitialize, DBPROP_INIT_MODE, DBPROPSET_DBINIT))
00258     SetProperty(DBPROP_INIT_MODE, DBPROPSET_DBINIT, &cPropSets, &rgPropSets, DBTYPE_I4, DB_MODE_READWRITE | DB_MODE_SHARE_DENY_WRITE);
00259
00260   //Set the DataSource Properties
00261   //IDBProperties is a MANDATORY interface, if error try and Initialize anyway
00262   XTEST(hr = pIDBInitialize->QueryInterface(IID_IDBProperties, (void **)&pIDBProperties));
00263   XTEST(hr = pIDBProperties->SetProperties(cPropSets, rgPropSets));
00264
00265   //Initailize
00266   XTESTC(hr = pIDBInitialize->Initialize());
00267
00268   //Get the Session Object
00269   XTESTC(hr = pIDBInitialize->QueryInterface(IID_IDBCreateSession, (void **)&pIDBCreateSession));
00270
00271   //Create the SessionObject
00272   XTESTC(hr = pIDBCreateSession->CreateSession(NULL, IID_IOpenRowset, (IUnknown**)&pIOpenRowset));
00273
00274   //Get the CommandText object - If supported
00275   if(SUCCEEDED(pIOpenRowset->QueryInterface(IID_IDBCreateCommand, (void**)&pIDBCreateCommand)))
00276     XTESTC(hr = pIDBCreateCommand->CreateCommand(NULL, IID_ICommandText, (IUnknown**)&pICommandText));
00277
00278   //Do away with any previous connections
00279   Disconnect();
00280
00281   //If we have made it this far, we are successfully connected,
00282   m_fConnected = TRUE;
00283
00284   //Save the new connection interfaces
00285   SAFE_ADDREF(pIDBInitialize);
00286   m_pIDBInitialize = pIDBInitialize;
00287
00288   SAFE_ADDREF(pIOpenRowset);
00289   m_pIOpenRowset  = pIOpenRowset;
00290
00291   SAFE_ADDREF(pICommandText);
00292   m_pICommandText = pICommandText;
00293
00294   //Obtain ITableDefinition/IIndexDefintion if supported
00295   pIOpenRowset->QueryInterface(IID_ITableDefinition, (void**)&m_pITableDefinition);
00296   pIOpenRowset->QueryInterface(IID_IIndexDefinition, (void**)&m_pIIndexDefinition);
00297   pIOpenRowset->QueryInterface(IID_IDBSchemaRowset,  (void**)&m_pIDBSchemaRowset);
00298
00299   //Now get the connection properties
00300   QTESTC(hr = GetConnectionProps());
00301
00302 CLEANUP:
00303   FreeProperties(cPropSets, rgPropSets);
00304
00305   //Release Interfaces
00306   SAFE_RELEASE(pIDBInitialize);
00307   SAFE_RELEASE(pIDBProperties);
00308   SAFE_RELEASE(pIDBCreateSession);
00309   SAFE_RELEASE(pIOpenRowset);
00310   SAFE_RELEASE(pIDBCreateCommand);
00311   SAFE_RELEASE(pICommandText);
00312   SAFE_RELEASE(pIMoniker);
00313   return hr;
00314 }
00315
00316
00317
00318 /////////////////////////////////////////////////////////////////////////////
00319 // HRESULT CDataSource::GetConnectionProps
00320 //
00321 /////////////////////////////////////////////////////////////////////////////
00322 HRESULT CDataSource::GetConnectionProps()
00323 {
00324   HRESULT hr = S_OK;
00325   DWORD dwSqlSupport = 0;
00326
00327   //DBPROP_CURRENTCATALOG
00328   hr = GetProperty(m_pIDBInitialize, DBPROP_CURRENTCATALOG,
00329               DBPROPSET_DATASOURCE, &m_pwszCatalog);
00330
00331   //DBPROP_CATALOGTERM
00332   hr = GetProperty(m_pIDBInitialize, DBPROP_CATALOGTERM,
00333               DBPROPSET_DATASOURCEINFO, &m_pwszCatalogTerm);
00334   if(!m_pwszCatalogTerm[0])
00335   {
00336     SAFE_FREE(m_pwszCatalogTerm);
00337     m_pwszCatalogTerm = wcsDuplicate(L"Catalog");
00338   }
00339
00340
00341   //DBPROP_CATALOGLOCATION
00342   hr = GetProperty(m_pIDBInitialize, DBPROP_CATALOGLOCATION,
00343               DBPROPSET_DATASOURCEINFO, &m_pwszCatalogLocation);
00344
00345   //DBPROP_SCHEMATERM
00346   hr = GetProperty(m_pIDBInitialize, DBPROP_SCHEMATERM,
00347               DBPROPSET_DATASOURCEINFO, &m_pwszSchemaTerm);
00348   if(!m_pwszSchemaTerm[0])
00349   {
00350     SAFE_FREE(m_pwszSchemaTerm);
00351     m_pwszSchemaTerm = wcsDuplicate(L"Schema");
00352   }
00353
00354   //DBPROP_TABLETERM
00355   hr = GetProperty(m_pIDBInitialize, DBPROP_TABLETERM,
00356               DBPROPSET_DATASOURCEINFO, &m_pwszTableTerm);
00357   if(!m_pwszTableTerm[0])
00358   {
00359     SAFE_FREE(m_pwszTableTerm);
00360     m_pwszTableTerm = wcsDuplicate(L"Table");
00361   }
00362
00363   //DBPROP_ACTIVESESSIONS
00364   hr = GetProperty(m_pIDBInitialize, DBPROP_ACTIVESESSIONS,
00365               DBPROPSET_DATASOURCEINFO, &m_ulActiveSessions);
00366
00367   //DBPROP_DATASOURCENAME
00368   hr = GetProperty(m_pIDBInitialize, DBPROP_DATASOURCENAME,
00369               DBPROPSET_DATASOURCEINFO, &m_pwszDataSource);
00370
00371   //DBPROP_DBMSNAME
00372   hr = GetProperty(m_pIDBInitialize, DBPROP_DBMSNAME,
00373               DBPROPSET_DATASOURCEINFO, &m_pwszDBMS);
00374
00375   //DBPROP_DBMSVER
00376   hr = GetProperty(m_pIDBInitialize, DBPROP_DBMSVER,
00377               DBPROPSET_DATASOURCEINFO, &m_pwszDBMSVer);
00378
00379   //DBPROP_DATASOURCEREADONLY
00380   hr = GetProperty(m_pIDBInitialize, DBPROP_DATASOURCEREADONLY,
00381               DBPROPSET_DATASOURCEINFO, &m_fReadOnly);
00382
00383   //DBPROP_PROVIDERNAME
00384   hr = GetProperty(m_pIDBInitialize, DBPROP_PROVIDERNAME,
00385               DBPROPSET_DATASOURCEINFO, &m_pwszProviderFileName);
00386
00387   //DBPROP_PROVIDERVER
00388   hr = GetProperty(m_pIDBInitialize, DBPROP_PROVIDERVER,
00389               DBPROPSET_DATASOURCEINFO, &m_pwszProviderVer);
00390
00391   //DBPROP_PROVIDEROLEDBVER
00392   hr = GetProperty(m_pIDBInitialize, DBPROP_PROVIDEROLEDBVER,
00393               DBPROPSET_DATASOURCEINFO, &m_pwszProviderOLEDBVer);
00394
00395   //DBPROP_MULTIPLEPARAMSETS
00396   hr = GetProperty(m_pIDBInitialize, DBPROP_MULTIPLEPARAMSETS,
00397               DBPROPSET_DATASOURCEINFO, &m_fMultipleParamSets);
00398
00399   //DBPROP_STRUCTUREDSTORAGE
00400   hr = GetProperty(m_pIDBInitialize, DBPROP_STRUCTUREDSTORAGE,
00401               DBPROPSET_DATASOURCEINFO, &m_dwStorageObjects);
00402
00403   //DBPROP_SQLSUPPORT
00404   hr = GetProperty(m_pIDBInitialize, DBPROP_SQLSUPPORT,
00405               DBPROPSET_DATASOURCEINFO, &dwSqlSupport);
00406
00407   //Are PrimaryKeys supported
00408   m_fPrimaryKeysSupported = dwSqlSupport & DBPROPVAL_SQL_ANSI89_IEF;
00409
00410   //DBPROP_IRowsetChange
00411   m_fIRowsetChange = FALSE;
00412   if(IsSupportedProperty(m_pIDBInitialize, DBPROP_IRowsetChange, DBPROPSET_ROWSET))
00413     m_fIRowsetChange = TRUE;
00414
00415   //DBPROP_IRowsetUpdate
00416   m_fIRowsetUpdate = FALSE;
00417   if(IsSupportedProperty(m_pIDBInitialize, DBPROP_IRowsetUpdate, DBPROPSET_ROWSET))
00418     m_fIRowsetUpdate = TRUE;
00419
00420   return S_OK;
00421 }
00422
00423
00424 /////////////////////////////////////////////////////////////////////////////
00425 // HRESULT CDataSource::GetProviders
00426 //
00427 /////////////////////////////////////////////////////////////////////////////
00428 HRESULT CDataSource::GetProviders()
00429 {
00430   HRESULT hr;
00431
00432   HROW* rghRows = NULL;
00433   ULONG cRowsObtained = 0;
00434   IRowset* pIRowset = NULL;
00435
00436   IAccessor* pIAccessor = NULL;
00437   HACCESSOR hAccessor = DB_NULL_HACCESSOR;
00438
00439   //Release Previous ProviderInfo
00440   m_cProviderInfo = 0;
00441   SAFE_FREE(m_rgProviderInfo);
00442   ISourcesRowset* pISourcesRowset = NULL;
00443
00444   // Bind the user and table name for the list
00445   const static ULONG cBindings = 4;
00446   const static DBBINDING rgBindings[cBindings] =
00447     {
00448       1,
00449       offsetof(PROVIDERINFO, wszName),
00450       0,
00451       0,
00452       NULL,
00453       NULL,
00454       NULL,
00455       DBPART_VALUE,
00456       DBMEMOWNER_CLIENTOWNED,
00457       DBPARAMIO_NOTPARAM,
00458       MAX_NAME_LEN,
00459       0,
00460       DBTYPE_WSTR,
00461       0,
00462       0,
00463
00464       2,
00465       offsetof(PROVIDERINFO, wszParseName),
00466       0,
00467       0,
00468       NULL,
00469       NULL,
00470       NULL,
00471       DBPART_VALUE,
00472       DBMEMOWNER_CLIENTOWNED,
00473       DBPARAMIO_NOTPARAM,
00474       MAX_NAME_LEN,
00475       0,
00476       DBTYPE_WSTR,
00477       0,
00478       0,
00479
00480       3,
00481       offsetof(PROVIDERINFO, wszDescription),
00482       0,
00483       0,
00484       NULL,
00485       NULL,
00486       NULL,
00487       DBPART_VALUE,
00488       DBMEMOWNER_CLIENTOWNED,
00489       DBPARAMIO_NOTPARAM,
00490       MAX_NAME_LEN,
00491       0,
00492       DBTYPE_WSTR,
00493       0,
00494       0,
00495
00496       4,
00497       offsetof(PROVIDERINFO, wType),
00498       0,
00499       0,
00500       NULL,
00501       NULL,
00502       NULL,
00503       DBPART_VALUE,
00504       DBMEMOWNER_CLIENTOWNED,
00505       DBPARAMIO_NOTPARAM,
00506       sizeof(DBTYPE),
00507       0,
00508       DBTYPE_UI2,
00509       0,
00510       0,
00511   };
00512
00513
00514   //Initialize the OLE DB Enumerator and Obtain rowset
00515   hr = CoCreateInstance(CLSID_OLEDB_ENUMERATOR, NULL, CLSCTX_INPROC_SERVER, IID_ISourcesRowset, (void**)&pISourcesRowset);
00516   if (REGDB_E_CLASSNOTREG == hr)
00517   {
00518     //if there is no enumerator, horse'em
00519
00520     //Alloc room for ProviderInfo
00521     m_cProviderInfo++;
00522     SAFE_REALLOC(m_rgProviderInfo, PROVIDERINFO, m_cProviderInfo);
00523     memset(&m_rgProviderInfo[0], 0, sizeof(PROVIDERINFO));
00524
00525     wcscpy(m_rgProviderInfo[0].wszName,L"MSDASQL");
00526     wcscpy(m_rgProviderInfo[0].wszParseName,L"{c8b522cb-5cf3-11ce-ade5-00aa0044773d}");
00527     wcscpy(m_rgProviderInfo[0].wszDescription,L"Microsoft OLE DB Provider for ODBC Drivers");
00528     m_rgProviderInfo[0].wType = DBSOURCETYPE_DATASOURCE;
00529
00530     return hr;
00531   }
00532
00533   XTESTC(hr);
00534   XTESTC(hr = pISourcesRowset->GetSourcesRowset(NULL, IID_IRowset, 0, NULL, (IUnknown**)&pIRowset));
00535
00536   //Create Accessor
00537   XTESTC(hr = pIRowset->QueryInterface(IID_IAccessor, (void **)&pIAccessor));
00538   XTESTC(hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, cBindings, rgBindings, 0, &hAccessor, NULL));
00539
00540   //Obtain IParseDisplayName interface
00541   XTESTC(hr = pISourcesRowset->QueryInterface(IID_IParseDisplayName, (void**)&m_pIParseDisplayName));
00542
00543   //Loop through the entire returned rowet
00544   while(TRUE)
00545   {
00546     XTESTC(hr = pIRowset->GetNextRows(NULL, 0, MAX_BLOCK_SIZE, &cRowsObtained, &rghRows));
00547
00548     //ENDOFROWSET
00549     if(cRowsObtained==0)
00550       break;
00551
00552     //Alloc room for ProviderInfo (in chunks)
00553     SAFE_REALLOC(m_rgProviderInfo, PROVIDERINFO, m_cProviderInfo + cRowsObtained);
00554     memset(&m_rgProviderInfo[m_cProviderInfo], 0, sizeof(PROVIDERINFO)*cRowsObtained);
00555
00556     //Loop over rows obtained and get ProviderInfo
00557     for(ULONG i=0; i<cRowsObtained; i++)
00558     {
00559       //Get the Data
00560       XTESTC(hr = pIRowset->GetData(rghRows[i], hAccessor, (void*)&m_rgProviderInfo[m_cProviderInfo]));
00561
00562       //Only interested in DATASOURCEs, not other ENUMERATORs
00563       if(m_rgProviderInfo[m_cProviderInfo].wType == DBSOURCETYPE_DATASOURCE)
00564         m_cProviderInfo++;
00565     }
00566
00567     //Release all the rows
00568     XTESTC(hr = pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL));
00569     SAFE_FREE(rghRows);
00570   }
00571
00572 CLEANUP:
00573   if(hAccessor && pIAccessor)
00574     XTEST(pIAccessor->ReleaseAccessor(hAccessor,NULL));
00575
00576   SAFE_RELEASE(pISourcesRowset);
00577   SAFE_RELEASE(pIRowset);
00578   SAFE_RELEASE(pIAccessor);
00579   SAFE_FREE(rghRows);
00580   return hr;
00581 }
00582
00583
Generated on Wed Nov 13 2024 16:52:04 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Tbarext/tbarext.h Source File

  • SysMgmt
  • MMC
  • Tbarext

tbarext.h

Go to the documentation of this file.
00001
00002 //==============================================================;
00003 //
00004 //  This source code is only intended as a supplement to existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _CToolBarExtension_H_
00021 #define _CToolBarExtension_H_
00022
00023 #include <tchar.h>
00024 #include <mmc.h>
00025
00026 class CToolBarExtension : public IExtendControlbar
00027 {
00028
00029 private:
00030     ULONG     m_cref;
00031
00032     IControlbar*    m_ipControlBar;
00033     IToolbar*       m_ipToolbar;
00034
00035     enum STATUS {RUNNING, PAUSED, STOPPED} iStatus;
00036
00037     HRESULT ExtractObjectTypeGUID( IDataObject* piDataObject, GUID* pguidObjectType );
00038     HRESULT ExtractSnapInCLSID( IDataObject* piDataObject, CLSID* pclsidSnapin );
00039     HRESULT ExtractString( IDataObject *piDataObject,CLIPFORMAT cfClipFormat, WCHAR *pstr, DWORD cchMaxLength);
00040     HRESULT ExtractData( IDataObject *piDataObject,CLIPFORMAT cfClipFormat, BYTE *pbData, DWORD cbData );
00041
00042   HRESULT SetToolbarButtons(STATUS iVehicleStatus);
00043
00044     // clipboard format
00045     static UINT s_cfDisplayName;
00046     static UINT s_cfSnapInCLSID;
00047     static UINT s_cfNodeType;
00048
00049 public:
00050     CToolBarExtension();
00051     ~CToolBarExtension();
00052
00053     ///////////////////////////////
00054     // Interface IUnknown
00055     ///////////////////////////////
00056     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00057     STDMETHODIMP_(ULONG) AddRef();
00058     STDMETHODIMP_(ULONG) Release();
00059
00060     ///////////////////////////////
00061     // Interface IExtendControlBar
00062     ///////////////////////////////
00063     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetControlbar(
00064     /* [in] */ LPCONTROLBAR pControlbar);
00065
00066     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE ControlbarNotify(
00067     /* [in] */ MMC_NOTIFY_TYPE event,
00068     /* [in] */ LPARAM arg,
00069     /* [in] */ LPARAM param);
00070
00071   public:
00072     IToolbar *getToolbar() { return m_ipToolbar; }
00073 };
00074
00075
00076 #endif _CToolBarExtension_H_
00077
00078
00079
00080
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/atl.cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

atl.cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1997 - 1999
00006 //
00007 //  File:       atl.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // stdafx.cpp: source file that includes just the standard includes
00012 // stdafx.pch will be the pre-compiled header
00013 // stdafx.obj will contain the pre-compiled type information
00014
00015 #include <pch.cpp>
00016
00017 #pragma hdrstop
00018
00019 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Multisel/comp.Cpp Source File

  • SysMgmt
  • MMC
  • Multisel

comp.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "Comp.h"
00020 #include "CompData.h"
00021 #include "Space.h"
00022 #include "DataObj.h"
00023 #include <commctrl.h>       // Needed for button styles...
00024 #include <crtdbg.h>
00025 #include <stdio.h>        // needed for _stprintf
00026 #include "globals.h"
00027 #include "resource.h"
00028 #include "DeleBase.h"
00029 #include "CompData.h"
00030
00031 CComponent::CComponent(CComponentData *pParent)
00032 : m_pParent(pParent), m_cref(0), m_ipConsole(NULL), m_pLastNode(NULL)
00033 {
00034     OBJECT_CREATED
00035 }
00036
00037 CComponent::~CComponent()
00038 {
00039     OBJECT_DESTROYED
00040 }
00041
00042 STDMETHODIMP CComponent::QueryInterface(REFIID riid, LPVOID *ppv)
00043 {
00044     if (!ppv)
00045         return E_FAIL;
00046
00047     *ppv = NULL;
00048
00049     if (IsEqualIID(riid, IID_IUnknown))
00050         *ppv = static_cast<IComponent *>(this);
00051     else if (IsEqualIID(riid, IID_IComponent))
00052         *ppv = static_cast<IComponent *>(this);
00053     else if (IsEqualIID(riid, IID_IResultOwnerData))
00054         *ppv = static_cast<IResultOwnerData *>(this);
00055
00056     if (*ppv)
00057     {
00058         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00059         return S_OK;
00060     }
00061
00062     return E_NOINTERFACE;
00063 }
00064
00065 STDMETHODIMP_(ULONG) CComponent::AddRef()
00066 {
00067     return InterlockedIncrement((LONG *)&m_cref);
00068 }
00069
00070 STDMETHODIMP_(ULONG) CComponent::Release()
00071 {
00072     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00073     {
00074         delete this;
00075         return 0;
00076     }
00077     return m_cref;
00078
00079 }
00080
00081 ///////////////////////////////
00082 // Interface IComponent
00083 ///////////////////////////////
00084 STDMETHODIMP CComponent::Initialize(
00085                                     /* [in] */ LPCONSOLE lpConsole)
00086 {
00087     HRESULT hr = S_OK;
00088
00089     // Save away all the interfaces we'll need.
00090     // Fail if we can't QI the required interfaces.
00091
00092     m_ipConsole = lpConsole;
00093     m_ipConsole->AddRef();
00094
00095     return hr;
00096 }
00097
00098 STDMETHODIMP CComponent::Notify(
00099                                 /* [in] */ LPDATAOBJECT lpDataObject,
00100                                 /* [in] */ MMC_NOTIFY_TYPE event,
00101                                 /* [in] */ LPARAM arg,
00102                                 /* [in] */ LPARAM param)
00103 {
00104     MMCN_Crack(FALSE, lpDataObject, NULL, this, event, arg, param);
00105
00106     HRESULT hr = S_FALSE;
00107
00108   // MMCN_VIEW_CHANGE
00109
00110   if (MMCN_VIEW_CHANGE == event) {
00111     switch (param) {//arg holds the data. For a scope item, this is the
00112             //item's HSCOPEITEM. For a result item, this is
00113             //the item's nId value, but we don't use it
00114
00115             //param holds the hint passed to IConsole::UpdateAllViews.
00116             //hint is a value of the UPDATE_VIEWS_HINT enumeration
00117
00118       case UPDATE_SCOPEITEM:
00119         hr = m_ipConsole->SelectScopeItem( (HSCOPEITEM)arg );
00120         _ASSERT( S_OK == hr);
00121         break;
00122       case UPDATE_RESULTITEM:
00123         CDelegationBase *base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00124         hr = base->OnUpdateItem(m_ipConsole, (long)arg, RESULT);
00125         break;
00126     }
00127
00128     return S_OK;
00129   }
00130
00131   //Remaining notifications
00132
00133   CDelegationBase *base = GetOurDataObject(lpDataObject)->GetBaseNodeObject();
00134
00135     switch (event)
00136   {
00137     case MMCN_SHOW:
00138         hr = base->OnShow(m_ipConsole, (BOOL)arg, (HSCOPEITEM)param);
00139         break;
00140
00141     case MMCN_ADD_IMAGES:
00142         hr = base->OnAddImages((IImageList *)arg, (HSCOPEITEM)param);
00143         break;
00144
00145     case MMCN_SELECT:
00146
00147     //check for multiselection
00148     if ( MMC_MULTI_SELECT_COOKIE == GetOurDataObject(lpDataObject)->GetCookie() )
00149     {
00150       if ( (BOOL)LOWORD(arg) == 0 && (BOOL)HIWORD(arg) == 1 )
00151       {
00152         //We need the cookie of any of the multiselection items
00153         //to enable the delete verb for all the items.
00154         MMC_COOKIE ourCookie = GetOurDataObject(lpDataObject)->GetMultiSelectCookie(0);
00155
00156         base = reinterpret_cast<CDelegationBase *>(ourCookie);
00157         hr = base->OnSelect(m_ipConsole, (BOOL)LOWORD(arg), (BOOL)HIWORD(arg));
00158       }
00159
00160       return hr;
00161     }
00162
00163     else
00164       hr = base->OnSelect(m_ipConsole, (BOOL)LOWORD(arg), (BOOL)HIWORD(arg));
00165         break;
00166
00167     case MMCN_REFRESH:
00168     hr = base->OnRefresh(m_pParent->m_ipConsole);
00169         break;
00170
00171     case MMCN_DELETE:
00172
00173     //check for multiselection. if true, delete each item
00174     if ( MMC_MULTI_SELECT_COOKIE == GetOurDataObject(lpDataObject)->GetCookie() )
00175     {
00176
00177       int n = 0;
00178       MMC_COOKIE ourCookie;
00179
00180       while ( ourCookie = GetOurDataObject(lpDataObject)->GetMultiSelectCookie(n) )
00181       {
00182         base = reinterpret_cast<CDelegationBase *>(ourCookie);
00183         hr = base->OnDelete(m_ipConsole);
00184         n++;
00185         //Uncomment the following line to display a message box
00186         //for each item deletion.
00187         //DisplayMessageBox(base);
00188       }
00189     }
00190
00191     else
00192     {
00193       //select item deletion
00194       hr = base->OnDelete(m_ipConsole);
00195     }
00196
00197     //Now call IConsole::UpdateAllViews to redraw all views
00198     //owned by the parent scope item. OnRefresh already does
00199     //this for us, so use it.
00200     //Do this for both multiselection and single selection
00201     hr = base->OnRefresh(m_pParent->m_ipConsole);
00202
00203     break;
00204
00205     case MMCN_RENAME:
00206         hr = base->OnRename((LPOLESTR)param);
00207
00208     //Now call IConsole::UpdateAllViews to redraw the item in all views.
00209     hr = m_pParent->m_ipConsole->UpdateAllViews(lpDataObject, 0, UPDATE_RESULTITEM);
00210     _ASSERT( S_OK == hr);
00211
00212     break;
00213
00214     }//end switch
00215
00216     return hr;
00217 }
00218
00219 STDMETHODIMP CComponent::Destroy(
00220                                  /* [in] */ MMC_COOKIE cookie)
00221 {
00222     if (m_ipConsole) {
00223         m_ipConsole->Release();
00224         m_ipConsole = NULL;
00225     }
00226
00227     return S_OK;
00228 }
00229
00230
00231 STDMETHODIMP CComponent::QueryDataObject(
00232                                          /* [in] */ MMC_COOKIE cookie,
00233                                          /* [in] */ DATA_OBJECT_TYPES type,
00234                                          /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
00235 {
00236     HRESULT hr;
00237
00238   CDataObject *pObj = NULL;
00239     CDelegationBase *pBase = NULL;
00240
00241     //Use The IS_SPECIAL_COOKIE macro to see if cookie is a special cookie
00242     if ( IS_SPECIAL_COOKIE (cookie) ) {
00243       if ( MMC_MULTI_SELECT_COOKIE == cookie) {
00244
00245       pObj = new CDataObject(cookie, type);
00246
00247       if (!pObj)
00248         return E_OUTOFMEMORY;
00249
00250       //create the multiselection data object
00251       hr = GetCurrentSelections(pObj);
00252       _ASSERT( SUCCEEDED(hr) );
00253
00254       hr = pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00255       _ASSERT( SUCCEEDED(hr) );
00256
00257       return hr;
00258
00259       }
00260     }
00261
00262     //Remaining code for "regular" cookies, and for the next item
00263     //during a multiselection
00264
00265         if (IsBadReadPtr((void *)cookie, sizeof(CDelegationBase))) {
00266                 if (NULL == m_pLastNode)
00267                         return E_FAIL;
00268
00269                 pBase = m_pLastNode->GetChildPtr((int)cookie);
00270         } else {
00271                 pBase = (cookie == 0) ? m_pParent->m_pStaticNode : (CDelegationBase *)cookie;
00272         }
00273
00274         if (pBase == NULL)
00275                 return E_FAIL;
00276
00277     pObj = new CDataObject((MMC_COOKIE)pBase, type);
00278
00279     if (!pObj)
00280         return E_OUTOFMEMORY;
00281
00282     pObj->QueryInterface(IID_IDataObject, (void **)ppDataObject);
00283
00284     return S_OK;
00285 }
00286
00287 STDMETHODIMP CComponent::GetResultViewType(
00288                                            /* [in] */ MMC_COOKIE cookie,
00289                                            /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00290                                            /* [out] */ long __RPC_FAR *pViewOptions)
00291 {
00292     CDelegationBase *base = m_pLastNode = (CDelegationBase *)cookie;
00293
00294     //
00295     // Ask for default listview.
00296     //
00297     if (base == NULL)
00298     {
00299         *pViewOptions = MMC_VIEW_OPTIONS_NONE;
00300         *ppViewType = NULL;
00301     }
00302     else
00303         return base->GetResultViewType(ppViewType, pViewOptions);
00304
00305     return S_OK;
00306 }
00307
00308 STDMETHODIMP CComponent::GetDisplayInfo(
00309                                         /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
00310 {
00311     HRESULT hr = S_OK;
00312     CDelegationBase *base = NULL;
00313
00314     // if they are asking for the RDI_STR we have one of those to give
00315
00316     if (pResultDataItem->lParam) {
00317         base = (CDelegationBase *)pResultDataItem->lParam;
00318         if (pResultDataItem->mask & RDI_STR) {
00319                         LPCTSTR pszT = base->GetDisplayName(pResultDataItem->nCol);
00320                         MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
00321             pResultDataItem->str = pszW;
00322         }
00323
00324         if (pResultDataItem->mask & RDI_IMAGE) {
00325             pResultDataItem->nImage = base->GetBitmapIndex();
00326         }
00327     } else {
00328         m_pLastNode->GetChildColumnInfo(pResultDataItem);
00329     }
00330
00331     return hr;
00332 }
00333
00334
00335 STDMETHODIMP CComponent::CompareObjects(
00336                                         /* [in] */ LPDATAOBJECT lpDataObjectA,
00337                                         /* [in] */ LPDATAOBJECT lpDataObjectB)
00338 {
00339     CDelegationBase *baseA = GetOurDataObject(lpDataObjectA)->GetBaseNodeObject();
00340     CDelegationBase *baseB = GetOurDataObject(lpDataObjectB)->GetBaseNodeObject();
00341
00342     // compare the object pointers
00343     if (baseA->GetCookie() == baseB->GetCookie())
00344         return S_OK;
00345
00346     return S_FALSE;
00347 }
00348
00349 ///////////////////////////////
00350 // Interface IComponent
00351 ///////////////////////////////
00352 STDMETHODIMP CComponent::FindItem(
00353 /* [in] */ LPRESULTFINDINFO pFindInfo,
00354 /* [out] */ int __RPC_FAR *pnFoundIndex)
00355 {
00356     return E_NOTIMPL;
00357 }
00358
00359 STDMETHODIMP CComponent::CacheHint(
00360 /* [in] */ int nStartIndex,
00361 /* [in] */ int nEndIndex)
00362 {
00363     return E_NOTIMPL;
00364 }
00365
00366 STDMETHODIMP CComponent::SortItems(
00367 /* [in] */ int nColumn,
00368 /* [in] */ DWORD dwSortOptions,
00369 /* [in] */ LPARAM lUserParam)
00370 {
00371     return E_NOTIMPL;
00372 }
00373
00374
00375 ///////////////////////////////////////////
00376 // GetCurrentSelections() finds the currently
00377 // selected result items and the data object
00378 // passed to it with their cookie values.
00379 // The multi-select cookie is cached so that
00380 // we don't have to calculate multiselection
00381 // dataobject for other notifications.
00382 // It is destroyed at appropriate time.
00383 ///////////////////////////////////////////
00384
00385 HRESULT CComponent::GetCurrentSelections(CDataObject *pMultiSelectDataObject)
00386 {
00387
00388   HRESULT hr = S_FALSE;
00389
00390   //GetCurrentSelections only works for multiselection data objects
00391   if ( !( MMC_MULTI_SELECT_COOKIE == GetOurDataObject(pMultiSelectDataObject)->GetCookie() ) )
00392     return hr = E_INVALIDARG;
00393
00394   IResultData *pResultData = NULL;
00395
00396   hr = m_ipConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
00397   _ASSERT( SUCCEEDED(hr) );
00398
00399     RESULTDATAITEM rdi;
00400
00401   BOOL isLastSelected = FALSE;
00402   int nIndex = -1;
00403   int nIndexCookies = 0;
00404
00405   while (!isLastSelected)
00406   {
00407     ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
00408     rdi.mask  = RDI_STATE;    // nState is valid
00409     rdi.nCol  = 0;
00410     rdi.nIndex  = nIndex;     // nIndex == -1 to start at first item
00411     rdi.nState  = LVIS_SELECTED;  // only interested in selected items
00412
00413
00414     hr = pResultData->GetNextItem(&rdi);
00415     _ASSERT( SUCCEEDED(hr) );
00416
00417     if (rdi.nIndex != -1) {
00418
00419       //rdi is the RESULTDATAITEM of a selected item. add its
00420       //lParam to the pCookies array of the pMultiSelectDataObject data object
00421
00422       _ASSERT( nIndexCookies < 20 ); // MAX_COOKIES == 20
00423       pMultiSelectDataObject->AddMultiSelectCookie(nIndexCookies, rdi.lParam);
00424       nIndexCookies++;
00425       nIndex = rdi.nIndex;
00426     }
00427
00428     else
00429       isLastSelected = TRUE;
00430
00431   }
00432
00433   pResultData->Release();
00434
00435   return hr;
00436
00437 }
00438
00439 void CComponent::DisplayMessageBox(CDelegationBase* base)
00440 {
00441
00442    _TCHAR szVehicle[128];
00443     static _TCHAR buf[128];
00444
00445   _stprintf(buf, _T("%s"), base->GetDisplayName() );
00446
00447   wsprintf(szVehicle, _T("%s deleted"), buf);
00448
00449   int ret = 0;
00450   MAKE_WIDEPTR_FROMTSTR_ALLOC(wszVehicle, szVehicle);
00451   m_ipConsole->MessageBox(wszVehicle,
00452      L"Vehicle command", MB_OK | MB_ICONINFORMATION, &ret);
00453
00454   return;
00455 }
Generated on Wed Nov 13 2024 16:52:31 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/error.h Source File

  • Dataaccess
  • oledb
  • tablecopy

error.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module ERROR.H
00008 //
00009 //-----------------------------------------------------------------------------
00010 #ifndef _ERROR_H_
00011 #define _ERROR_H_
00012
00013
00014 ///////////////////////////////////////////////////////////////
00015 // Includes
00016 //
00017 ///////////////////////////////////////////////////////////////
00018 #include "common.h"
00019
00020
00021
00022 ////////////////////////////////////////////////////////////////////////////
00023 // Extened Error Info
00024 //
00025 ////////////////////////////////////////////////////////////////////////////
00026 WCHAR* GetErrorName(HRESULT hr);
00027
00028 //Get ISQLErrorInfo
00029 HRESULT GetSqlErrorInfo(ULONG iRecord, IErrorRecords* pIErrorRecords, BSTR* pBstr);
00030
00031 //Get IErrorRecords
00032 HRESULT GetErrorRecords(ULONG* pcRecords, IErrorRecords** ppIErrorRecords);
00033 HRESULT DisplayErrorRecords(HWND hWnd, ULONG cRecords, IErrorRecords* pIErrorRecords, WCHAR* pwszFile = L"Unknown", ULONG ulLine = 0);
00034
00035 HRESULT DisplayAllErrors(HWND hWnd, HRESULT hr, WCHAR* pwszFile = L"Unknown", ULONG ulLine = 0);
00036
00037 #endif  //_ERROR_H_
Generated on Wed Nov 13 2024 16:52:08 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/proppagex/tracemacro.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • proppagex

tracemacro.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include "Globals.h"
00016 #include "TraceMacro.h"
00017 #include <StdIo.h>             // Needed for sprintf on Win98
00018
00019
00020 //---------------------------------------------------------------------------
00021 //  Function implementations
00022 //
00023
00024 //---------------------------------------------------------------------------
00025 //  Provides trace output for HRESULTs in hex.
00026 //
00027 VOID Trace_HR
00028 (
00029   LPCTSTR pszClass,        //[in] Class name for message
00030   LPCTSTR pszFunction,     //[in] Function name for message
00031   HRESULT hr               //[in] HRESULT to display as a value
00032 )
00033 {
00034 #ifdef _DEBUG
00035
00036   TCHAR  szBuffer[512];
00037   TCHAR  szFormat[] = _T("%s::%s-> Returned 0x%X\n");
00038   INT    nChars     = 0;
00039
00040   nChars = _stprintf( szBuffer, szFormat, pszClass, pszFunction, hr );
00041   _ASSERTE( nChars < sizeof(szBuffer) );
00042
00043   OutputDebugString( szBuffer );
00044
00045 #endif
00046 } //end Trace_HR()
00047
00048
00049 //---------------------------------------------------------------------------
00050 //  Provides trace output for user defined numeric values in the form:
00051 //    "CClassName::MyFunctionName-> UserDefinedValueString = 99"
00052 //
00053 VOID Trace_Value
00054 (
00055   LPCTSTR pszClass,        //[in] Class name for message
00056   LPCTSTR pszFunction,     //[in] Function name for message
00057   LPCTSTR pszValueName,    //[in] Value name for message
00058   LONG    nValue           //[in] Numeric value for message
00059 )
00060 {
00061 #ifdef _DEBUG
00062
00063   TCHAR  szBuffer[512];
00064   TCHAR  szFormat[] = _T("%s::%s-> %s = %u\n");
00065   INT    nChars     = 0;
00066
00067   nChars = _stprintf( szBuffer,
00068                       szFormat,
00069                       pszClass,
00070                       pszFunction,
00071                       pszValueName,
00072                       nValue
00073                     );
00074   _ASSERTE( nChars < sizeof(szBuffer) );
00075
00076   OutputDebugString( szBuffer );
00077
00078 #endif
00079 } //end Trace_Value()
00080
00081
00082 //---------------------------------------------------------------------------
00083 //  Provides trace output which shows the class name, function name, and
00084 //  a string which maps to an MMC notification.
00085 //
00086 VOID Trace_Event
00087 (
00088   LPCTSTR pszClass,        //[in] Class name for message
00089   LPCTSTR pszFunction,     //[in] Event name for message
00090   LONG    nEvent           //[in] Event code to map to string
00091 )
00092 {
00093 #ifdef _DEBUG
00094
00095   TCHAR  szEventStr[22];
00096   TCHAR  szBuffer[512];
00097   TCHAR  szFormat[] = _T("%s::%s-> Event = %s\n");
00098   INT    nChars     = 0;
00099
00100   MapEvent( nEvent, szEventStr );
00101
00102   nChars = _stprintf( szBuffer,
00103                       szFormat,
00104                       pszClass,
00105                       pszFunction,
00106                       szEventStr
00107                     );
00108   _ASSERTE( nChars < sizeof(szBuffer) );
00109
00110   OutputDebugString( szBuffer );
00111
00112 #endif
00113 } //end Trace_Event()
00114
00115 //---------------------------------------------------------------------------
00116 //  Provides trace output which shows the class name and function name
00117 //
00118 VOID Trace_Start
00119 (
00120   LPCTSTR pszClass,        //[in] Class name for message
00121   LPCTSTR pszFunction      //[in] Event name for message
00122 )
00123 {
00124 #ifdef _DEBUG
00125
00126   TCHAR  szBuffer[512];
00127   TCHAR  szFormat[] = _T("%s::%s-> Started \n");
00128   INT    nChars     = 0;
00129
00130   nChars = _stprintf( szBuffer,
00131                       szFormat,
00132                       pszClass,
00133                       pszFunction
00134                     );
00135   _ASSERTE( nChars < sizeof(szBuffer) );
00136
00137   OutputDebugString( szBuffer );
00138
00139 #endif
00140 } //end Trace_Start()
00141
00142
00143
00144 //---------------------------------------------------------------------------
00145 // Provides human readable output for notifications
00146 //
00147 VOID MapEvent( LONG Event, LPTSTR szEventStr )
00148 {
00149 #ifdef _DEBUG
00150
00151   switch( Event )
00152   {
00153     case 0x8001:
00154       _tcscpy( szEventStr, _T("MMCN_ACTIVATE       ") );
00155       break;
00156
00157     case 0x8002:
00158       _tcscpy( szEventStr, _T("MMCN_ADD_IMAGES     ") );
00159       break;
00160
00161     case 0x8003:
00162       _tcscpy( szEventStr, _T("MMCN_BTN_CLICK      ") );
00163       break;
00164
00165     case 0x8004:
00166       _tcscpy( szEventStr, _T("MMCN_CLICK          ") );
00167       break;
00168
00169     case 0x8005:
00170       _tcscpy( szEventStr, _T("MMCN_COLUMN_CLICK   ") );
00171       break;
00172
00173     case 0x8006:
00174       _tcscpy( szEventStr, _T("MMCN_CONTEXTMENU    ") );
00175       break;
00176
00177     case 0x8007:
00178       _tcscpy( szEventStr, _T("MMCN_CUTORMOVE      ") );
00179       break;
00180
00181     case 0x8008:
00182       _tcscpy( szEventStr, _T("MMCN_DBLCLICK       ") );
00183       break;
00184
00185     case 0x8009:
00186       _tcscpy( szEventStr, _T("MMCN_DELETE         ") );
00187       break;
00188
00189     case 0x800A:
00190       _tcscpy( szEventStr, _T("MMCN_DESELECT_ALL   ") );
00191       break;
00192
00193     case 0x800B:
00194       _tcscpy( szEventStr, _T("MMCN_EXPAND         ") );
00195       break;
00196
00197     case 0x800C:
00198       _tcscpy( szEventStr, _T("MMCN_HELP           ") );
00199       break;
00200
00201     case 0x800D:
00202       _tcscpy( szEventStr, _T("MMCN_MENU_BTNCLICK  ") );
00203       break;
00204
00205     case 0x800E:
00206       _tcscpy( szEventStr, _T("MMCN_MINIMIZED      ") );
00207       break;
00208
00209     case 0x800F:
00210       _tcscpy( szEventStr, _T("MMCN_PASTE          ") );
00211       break;
00212
00213     case 0x8010:
00214       _tcscpy( szEventStr, _T("MMCN_PROPERTY_CHANGE") );
00215       break;
00216
00217     case 0x8011:
00218       _tcscpy( szEventStr, _T("MMCN_QUERY_PASTE    ") );
00219       break;
00220
00221     case 0x8012:
00222       _tcscpy( szEventStr, _T("MMCN_REFRESH        ") );
00223       break;
00224
00225     case 0x8013:
00226       _tcscpy( szEventStr, _T("MMCN_REMOVE_CHILDREN") );
00227       break;
00228
00229     case 0x8014:
00230       _tcscpy( szEventStr, _T("MMCN_RENAME         ") );
00231       break;
00232
00233     case 0x8015:
00234       _tcscpy( szEventStr, _T("MMCN_SELECT         ") );
00235       break;
00236
00237     case 0x8016:
00238       _tcscpy( szEventStr, _T("MMCN_SHOW           ") );
00239       break;
00240
00241     case 0x8017:
00242       _tcscpy( szEventStr, _T("MMCN_VIEW_CHANGE    ") );
00243       break;
00244
00245     case 0x8018:
00246       _tcscpy( szEventStr, _T("MMCN_SNAPINHELP     ") );
00247       break;
00248
00249     case 0x8019:
00250       _tcscpy( szEventStr, _T("MMCN_CONTEXTHELP    ") );
00251       break;
00252
00253     case 0x801A:
00254       _tcscpy( szEventStr, _T("MMCN_INITOCX        ") );
00255       break;
00256
00257     case 0x8021:
00258       _tcscpy( szEventStr, _T("MMCN_EXPANDSYNC     ") );
00259       break;
00260
00261     default:
00262       _stprintf( szEventStr, _T("0x%X"), Event );
00263       break;
00264   }
00265
00266 #endif
00267 } //end MapEvent()
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/WindowsMediaServices9/EventNotification/Resource.h Source File

  • Multimedia
  • WindowsMediaServices9
  • EventNotification

Resource.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows Media Technologies
00004 //  Copyright (C) Microsoft Corporation. All rights reserved.
00005 //
00006 //  File:       Resource.h
00007 //
00008 //  Contents:
00009 //
00010 //--------------------------------------------------------------------------
00011 #pragma once
00012 //{{NO_DEPENDENCIES}}
00013 // Microsoft Developer Studio generated include file.
00014 // Used by ContextDll.rc
00015 //
00016 #define EVENT_LENGTH                    4
00017 #define IDS_PROJNAME                    100
00018 #define IDR_CONTEXTPLUGIN               101
00019
00020 // Next default values for new objects
00021 //
00022 #ifdef APSTUDIO_INVOKED
00023 #ifndef APSTUDIO_READONLY_SYMBOLS
00024 #define _APS_NEXT_RESOURCE_VALUE        201
00025 #define _APS_NEXT_COMMAND_VALUE         32768
00026 #define _APS_NEXT_CONTROL_VALUE         201
00027 #define _APS_NEXT_SYMED_VALUE           102
00028 #endif
00029 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CToken Member List

This is the complete list of members for CToken, including all inherited members.
_eTokenType | CToken | [private]
_fStartToken | CToken | [private]
_guidPropset | CToken | [private]
_propid | CToken | [private]
GetTokenType() | CToken | [inline]
IsMatchProperty(CFullPropSpec &propSpec) | CToken |
IsStartToken() | CToken | [inline]
SetPropid(PROPID propid) | CToken | [inline]
SetPropset(GUID guidPropset) | CToken | [inline]
SetStartTokenFlag(BOOL fStart) | CToken | [inline]
SetTokenType(HtmlTokenType eTokType) | CToken | [inline]
Generated on Wed Nov 13 2024 16:57:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_UNICODE_STRING Member List

This is the complete list of members for _UNICODE_STRING, including all inherited members.
Buffer | _UNICODE_STRING
Length | _UNICODE_STRING
MaximumLength | _UNICODE_STRING
Generated on Wed Nov 13 2024 16:55:27 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/doc.Cpp Source File

  • Com
  • Fundamentals
  • SimpDnd

doc.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: DOC.CPP
00003 //
00004 //      Implementation file for CSimpleDoc.
00005 //
00006 // Functions:
00007 //
00008 //      See DOC.H for Class Definition
00009 //
00010 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "iocs.h"
00015 #include "ias.h"
00016 #include "app.h"
00017 #include "site.h"
00018 #include "doc.h"
00019 #include "idt.h"
00020 #include "dxferobj.h"
00021
00022 //**********************************************************************
00023 //
00024 // CSimpleDoc::Create
00025 //
00026 // Purpose:
00027 //
00028 //      Creation for the CSimpleDoc Class
00029 //
00030 // Parameters:
00031 //
00032 //      CSimpleApp FAR * lpApp  -   Pointer to the CSimpleApp Class
00033 //
00034 //      LPRECT lpRect           -   Client area rect of "frame" window
00035 //
00036 //      HWND hWnd               -   Window Handle of "frame" window
00037 //
00038 // Return Value:
00039 //
00040 //      None
00041 //
00042 // Function Calls:
00043 //      Function                    Location
00044 //
00045 //      StgCreateDocfile            OLE API
00046 //      RegisterDragDrop            OLE API
00047 //      CoLockObjectExternal        OLE API
00048 //      CreateWindow                Windows API
00049 //      ShowWindow                  Windows API
00050 //      UpdateWindow                Windows API
00051 //
00052 // Comments:
00053 //
00054 //      This routine was added so that failure could be returned
00055 //      from object creation.
00056 //
00057 //********************************************************************
00058
00059 CSimpleDoc FAR * CSimpleDoc::Create(CSimpleApp FAR *lpApp, LPRECT lpRect,HWND hWnd)
00060 {
00061         CSimpleDoc FAR * lpTemp = new CSimpleDoc(lpApp, hWnd);
00062
00063         if (!lpTemp)
00064                 return NULL;
00065
00066         // create storage for the doc.
00067         HRESULT hErr = StgCreateDocfile (
00068                 NULL,       // generate temp name
00069                 STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
00070                 0, &lpTemp->m_lpStorage);
00071
00072         if (hErr != NOERROR)
00073                 goto error;
00074
00075         // create the document Window
00076         lpTemp->m_hDocWnd = CreateWindow(
00077                         "SimpDndDocWClass",
00078                         NULL,
00079                         WS_CHILD | WS_CLIPCHILDREN,
00080                         lpRect->left,
00081                         lpRect->top,
00082                         lpRect->right,
00083                         lpRect->bottom,
00084                         hWnd,
00085                         NULL,
00086                         lpApp->m_hInst,
00087                         NULL);
00088
00089         if (!lpTemp->m_hDocWnd)
00090                 goto error;
00091
00092         ShowWindow(lpTemp->m_hDocWnd, SW_SHOWNORMAL);  // Show the window
00093         UpdateWindow(lpTemp->m_hDocWnd);               // Sends WM_PAINT message
00094
00095         // Ensable InsertObject menu choice
00096         EnableMenuItem( lpApp->m_hEditMenu, 1, MF_BYPOSITION | MF_ENABLED);
00097         // Disable Copy menu choice
00098         EnableMenuItem( lpApp->m_hEditMenu, 0, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
00099
00100         // It is *REQUIRED* to hold a strong LOCK on the object that is
00101         // registered as drop target. this call will result in at least one
00102         // ref count held on our document. later in CSimpleDoc::Close we will
00103         // unlock this lock which will make our document's ref count go to 0.
00104         // when the document's ref count goes to 0, it will be deleted.
00105         CoLockObjectExternal (&lpTemp->m_DropTarget, TRUE, 0);
00106
00107         // Register our window as a DropTarget
00108         RegisterDragDrop(lpTemp->m_hDocWnd, &lpTemp->m_DropTarget);
00109         lpTemp->m_fRegDragDrop = TRUE;
00110
00111         return (lpTemp);
00112
00113 error:
00114         delete (lpTemp);
00115         return NULL;
00116
00117 }
00118
00119 //**********************************************************************
00120 //
00121 // CSimpleDoc::Close
00122 //
00123 // Purpose:
00124 //
00125 //      Close CSimpleDoc object.
00126 //      when the document's reference count goes to 0, the document
00127 //      will be destroyed.
00128 //
00129 // Parameters:
00130 //
00131 //
00132 // Return Value:
00133 //
00134 //      None
00135 //
00136 // Function Calls:
00137 //      Function                    Location
00138 //
00139 //      RevokeDragDrop              OLE API
00140 //      CoLockObjectExternal        OLE API
00141 //      OleFlushClipboard           OLE API
00142 //      ShowWindow                  Windows API
00143 //
00144 // Comments:
00145 //
00146 //********************************************************************
00147
00148 void CSimpleDoc::Close(void)
00149 {
00150         OutputDebugString("In CSimpleDoc::Close\r\n");
00151         CStabilize stabilize(this);
00152         ShowWindow(m_hDocWnd, SW_HIDE);  // Hide the window
00153
00154         // Remove our data transfer object from clipboard if it is there.
00155         //  this will leave HGLOBAL based data behind on the clipboard
00156         //  including OLE 1.0 compatibility formats.
00157         OleFlushClipboard();
00158
00159         // Revoke our window as a DropTarget
00160         if (m_fRegDragDrop) {
00161                 RevokeDragDrop(m_hDocWnd);
00162                 m_fRegDragDrop = FALSE;
00163         }
00164
00165         // Close the OLE object in our document
00166         if (m_lpSite)
00167                 m_lpSite->CloseOleObject();
00168
00169         // Unlock the lock added in CSimpleDoc::Create. this will make
00170         // the document's ref count go to 0, and the document will be deleted.
00171         CoLockObjectExternal (&m_DropTarget, FALSE, TRUE);
00172 }
00173
00174 //**********************************************************************
00175 //
00176 // CSimpleDoc::CSimpleDoc
00177 //
00178 // Purpose:
00179 //
00180 //      Constructor for the CSimpleDoc Class
00181 //
00182 // Parameters:
00183 //
00184 //      CSimpleApp FAR * lpApp  -   Pointer to the CSimpleApp Class
00185 //
00186 //      HWND hWnd               -   Window Handle of "frame" window
00187 //
00188 // Return Value:
00189 //
00190 //      None
00191 //
00192 // Function Calls:
00193 //      Function                    Location
00194 //
00195 //      OutputDebugString           Windows API
00196 //      GetMenu                     Windows API
00197 //      GetSubMenu                  Windows API
00198 //
00199 // Comments:
00200 //
00201 //********************************************************************
00202 #pragma warning(disable : 4355)  // turn off this warning.  This warning
00203                                                                 // tells us that we are passing this in
00204                                                                 // an initializer, before "this" is through
00205                                                                 // initializing.  This is ok, because
00206                                                                 // we just store the ptr in the other
00207                                                                 // constructor
00208
00209 CSimpleDoc::CSimpleDoc(CSimpleApp FAR * lpApp,HWND hWnd)
00210                 : m_DropTarget(this), m_DropSource(this)
00211 #pragma warning (default : 4355)  // Turn the warning back on
00212 {
00213         OutputDebugString("In CSimpleDoc's Constructor\r\n");
00214         m_lpApp = lpApp;
00215         m_lpSite = NULL;
00216         // set up menu handles
00217         lpApp->m_hMainMenu = GetMenu(hWnd);
00218         lpApp->m_hFileMenu = GetSubMenu(lpApp->m_hMainMenu, 0);
00219         lpApp->m_hEditMenu = GetSubMenu(lpApp->m_hMainMenu, 1);
00220         lpApp->m_hHelpMenu = GetSubMenu(lpApp->m_hMainMenu, 2);
00221         lpApp->m_hCascadeMenu = NULL;
00222         m_fModifiedMenu = FALSE;
00223
00224         // drag/drop related stuff
00225         m_fRegDragDrop = FALSE;       // is doc registered as drop target?
00226         m_fLocalDrag = FALSE;         // is doc source of the drag
00227         m_fLocalDrop = FALSE;         // was doc target of the drop
00228         m_fCanDropCopy = FALSE;       // is Drag/Drop copy/move possible?
00229         m_fCanDropLink = FALSE;       // is Drag/Drop link possible?
00230         m_fDragLeave = FALSE;         // has drag left
00231         m_fPendingDrag = FALSE;       // LButtonDown--possible drag pending
00232         m_ptButDown.x = m_ptButDown.y = 0; // LButtonDown coordinates
00233 }
00234
00235 //**********************************************************************
00236 //
00237 // CSimpleDoc::~CSimpleDoc
00238 //
00239 // Purpose:
00240 //
00241 //      Destructor for CSimpleDoc
00242 //
00243 // Parameters:
00244 //
00245 //      None
00246 //
00247 // Return Value:
00248 //
00249 //      None
00250 //
00251 // Function Calls:
00252 //      Function                    Location
00253 //
00254 //      OutputDebugString           Windows API
00255 //      CSimpleSite::Release        SITE.CPP
00256 //      IStorage::Release           OLE API
00257 //
00258 // Comments:
00259 //
00260 //********************************************************************
00261
00262 CSimpleDoc::~CSimpleDoc()
00263 {
00264         OutputDebugString("In CSimpleDoc's Destructor\r\n");
00265
00266         // Release all pointers we hold to the OLE object. also release
00267         // the ref count added in CSimpleSite::Create. this will make
00268         // the Site's ref count go to 0, and the Site will be deleted.
00269         if (m_lpSite) {
00270                 m_lpSite->UnloadOleObject();
00271                 m_lpSite->Release();
00272                 m_lpSite = NULL;
00273         }
00274
00275         // Release the Storage
00276         if (m_lpStorage) {
00277                 m_lpStorage->Release();
00278                 m_lpStorage = NULL;
00279         }
00280
00281         // if the edit menu was modified, remove the menu item and
00282         // destroy the popup if it exists
00283         if (m_fModifiedMenu)
00284                 {
00285                 int nCount = GetMenuItemCount(m_lpApp->m_hEditMenu);
00286                 RemoveMenu(m_lpApp->m_hEditMenu, nCount-1, MF_BYPOSITION);
00287                 if (m_lpApp->m_hCascadeMenu)
00288                         DestroyMenu(m_lpApp->m_hCascadeMenu);
00289                 }
00290
00291         DestroyWindow(m_hDocWnd);
00292 }
00293
00294
00295 //**********************************************************************
00296 //
00297 // CSimpleDoc::QueryInterface
00298 //
00299 // Purpose:
00300 //
00301 //      Return a pointer to a requested interface
00302 //
00303 // Parameters:
00304 //
00305 //      REFIID riid         -   ID of interface to be returned
00306 //      LPVOID FAR* ppvObj  -   Location to return the interface
00307 //
00308 // Return Value:
00309 //
00310 //      S_OK                -   Interface supported
00311 //      E_NOINTERFACE       -   Interface NOT supported
00312 //
00313 // Function Calls:
00314 //      Function                    Location
00315 //
00316 //      OutputDebugString           Windows API
00317 //                   OLE API
00318 //
00319 // Comments:
00320 //
00321 //********************************************************************
00322
00323 STDMETHODIMP CSimpleDoc::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00324 {
00325         OutputDebugString("In CSimpleDoc::QueryInterface\r\n");
00326
00327         *ppvObj = NULL;     // must set out pointer parameters to NULL
00328
00329         // looking for IUnknown
00330         if ( riid == IID_IUnknown)
00331                 {
00332                 AddRef();
00333                 *ppvObj = this;
00334                 return S_OK;
00335                 }
00336
00337         // looking for IDropTarget
00338         if ( riid == IID_IDropTarget)
00339                 {
00340                 m_DropTarget.AddRef();
00341                 *ppvObj=&m_DropTarget;
00342                 return S_OK;
00343                 }
00344
00345         // looking for IDropSource
00346         if ( riid == IID_IDropSource)
00347                 {
00348                 m_DropSource.AddRef();
00349                 *ppvObj=&m_DropSource;
00350                 return S_OK;
00351                 }
00352
00353         // Not a supported interface
00354         return E_NOINTERFACE;
00355 }
00356
00357 //**********************************************************************
00358 //
00359 // CSimpleDoc::AddRef
00360 //
00361 // Purpose:
00362 //
00363 //      Increments the document reference count
00364 //
00365 // Parameters:
00366 //
00367 //      None
00368 //
00369 // Return Value:
00370 //
00371 //      UINT    -   The current reference count on the document
00372 //
00373 // Function Calls:
00374 //      Function                    Location
00375 //
00376 //      OutputDebugString           Windows API
00377 //      CSimpleApp::AddRef          APP.CPP
00378 //
00379 // Comments:
00380 //
00381 //********************************************************************
00382
00383 STDMETHODIMP_(ULONG) CSimpleDoc::AddRef()
00384 {
00385         OutputDebugString("In CSimpleDoc::AddRef\r\n");
00386         return SafeAddRef();
00387 }
00388
00389 //**********************************************************************
00390 //
00391 // CSimpleDoc::Release
00392 //
00393 // Purpose:
00394 //
00395 //      Decrements the document reference count
00396 //
00397 // Parameters:
00398 //
00399 //      None
00400 //
00401 // Return Value:
00402 //
00403 //      UINT    -   The current reference count on the document
00404 //
00405 // Function Calls:
00406 //      Function                    Location
00407 //
00408 //      OutputDebugString           Windows API
00409 //
00410 // Comments:
00411 //
00412 //********************************************************************
00413
00414 STDMETHODIMP_(ULONG) CSimpleDoc::Release()
00415 {
00416         OutputDebugString("In CSimpleDoc::Release\r\n");
00417
00418         return SafeRelease();
00419 }
00420
00421 //**********************************************************************
00422 //
00423 // CSimpleDoc::InsertObject
00424 //
00425 // Purpose:
00426 //
00427 //      Inserts a new object to this document
00428 //
00429 // Parameters:
00430 //
00431 //      None
00432 //
00433 // Return Value:
00434 //
00435 //      None
00436 //
00437 // Function Calls:
00438 //      Function                    Location
00439 //
00440 //      CSimpleSite::CSimpleSite    SITE.CPP
00441 //      CSimpleSite::InitObject     SITE.CPP
00442 //      memset                      C Runtime
00443 //      OleUIInsertObject           OUTLUI function
00444 //      CSimpleDoc::DisableInsertObject DOC.CPP
00445 //
00446 // Comments:
00447 //
00448 //      This implementation only allows one object to be inserted
00449 //      into a document.  Once the object has been inserted, then
00450 //      the Insert Object menu choice is greyed out, to prevent
00451 //      the user from inserting another.
00452 //
00453 //********************************************************************
00454
00455 void CSimpleDoc::InsertObject()
00456 {
00457         OLEUIINSERTOBJECT io;
00458         CStabilize stabilize(this);
00459         UINT iret;
00460         //@@WTK WIN32, UNICODE
00461         //char szFile[OLEUI_CCHPATHMAX];
00462         char szFile[OLEUI_CCHPATHMAX];
00463
00464         m_lpSite = CSimpleSite::Create(this);
00465
00466         // clear the structure
00467         _fmemset(&io, 0, sizeof(OLEUIINSERTOBJECT));
00468
00469         // fill the structure
00470         io.cbStruct = sizeof(OLEUIINSERTOBJECT);
00471         io.dwFlags = IOF_SELECTCREATENEW |
00472                                         IOF_DISABLELINK | IOF_DISABLEDISPLAYASICON |
00473                                         IOF_CREATENEWOBJECT | IOF_CREATEFILEOBJECT;
00474         io.hWndOwner = m_hDocWnd;
00475         io.lpszCaption = "Insert Object";
00476         io.iid = IID_IOleObject;
00477         io.oleRender = OLERENDER_DRAW;
00478         io.lpIOleClientSite = &m_lpSite->m_OleClientSite;
00479         io.lpIStorage = m_lpSite->m_lpObjStorage;
00480         io.ppvObj = (LPVOID FAR *)&m_lpSite->m_lpOleObject;
00481         io.lpszFile = szFile;
00482         io.cchFile = sizeof(szFile) / sizeof *szFile;
00483         _fmemset(szFile, 0, sizeof(szFile));
00484
00485         // call OUTLUI to do all the hard work
00486         iret = OleUIInsertObject(&io);
00487
00488         if (iret == OLEUI_OK)
00489                 {
00490                 m_lpSite->InitObject((BOOL)(io.dwFlags & IOF_SELECTCREATENEW));
00491                 // disable Insert Object menu item
00492                 DisableInsertObject();
00493                 }
00494         else
00495                 {
00496                 m_lpSite->Release();
00497                 m_lpSite = NULL;
00498                 m_lpStorage->Revert();
00499                 }
00500
00501 }
00502
00503 //**********************************************************************
00504 //
00505 // CSimpleDoc::lResizeDoc
00506 //
00507 // Purpose:
00508 //
00509 //      Resizes the document
00510 //
00511 // Parameters:
00512 //
00513 //      LPRECT lpRect   -   The size of the client are of the "frame"
00514 //                          Window.
00515 //
00516 // Return Value:
00517 //
00518 //      NULL
00519 //
00520 // Function Calls:
00521 //      Function                                Location
00522 //
00523 //      MoveWindow                              Windows API
00524 //
00525 // Comments:
00526 //
00527 //********************************************************************
00528
00529 long CSimpleDoc::lResizeDoc(LPRECT lpRect)
00530 {
00531         MoveWindow(
00532                         m_hDocWnd,
00533                         lpRect->left, lpRect->top,
00534                         lpRect->right, lpRect->bottom, TRUE);
00535
00536         return NULL;
00537 }
00538
00539 //**********************************************************************
00540 //
00541 // CSimpleDoc::lAddVerbs
00542 //
00543 // Purpose:
00544 //
00545 //      Adds the objects verbs to the edit menu.
00546 //
00547 // Parameters:
00548 //
00549 //      None
00550 //
00551 // Return Value:
00552 //
00553 //      NULL
00554 //
00555 // Function Calls:
00556 //      Function                    Location
00557 //
00558 //      GetMenuItemCount            Windows API
00559 //      OleUIAddVerbMenu            OUTLUI function
00560 //
00561 // Comments:
00562 //
00563 //********************************************************************
00564
00565 long CSimpleDoc::lAddVerbs(void)
00566 {
00567         CStabilize stabilize(this);
00568         // m_fModifiedMenu is TRUE if the menu has already been modified
00569         // once.  Since we only support one obect every time the application
00570         // is run, then once the menu is modified, it doesn't have
00571         // to be done again.
00572         if (m_lpSite && !m_fModifiedMenu)
00573                 {
00574                 int nCount = GetMenuItemCount(m_lpApp->m_hEditMenu);
00575
00576                 OleUIAddVerbMenu ( m_lpSite->m_lpOleObject,
00577                                                    NULL,
00578                                                    m_lpApp->m_hEditMenu,
00579                                                    nCount + 1,
00580                                                    IDM_VERB0,
00581                                                    0,           // no maximum verb IDM enforced
00582                                                    FALSE,
00583                                                    1,
00584                                                    &m_lpApp->m_hCascadeMenu);
00585
00586                 m_fModifiedMenu = TRUE;
00587                 }
00588         return (NULL);
00589 }
00590
00591 //**********************************************************************
00592 //
00593 // CSimpleDoc::PaintDoc
00594 //
00595 // Purpose:
00596 //
00597 //      Paints the Document
00598 //
00599 // Parameters:
00600 //
00601 //      HDC hDC -   hDC of the document Window
00602 //
00603 // Return Value:
00604 //
00605 //      None
00606 //
00607 // Function Calls:
00608 //      Function                    Location
00609 //
00610 //      CSimpleSite::PaintObj       SITE.CPP
00611 //
00612 // Comments:
00613 //
00614 //********************************************************************
00615
00616 void CSimpleDoc::PaintDoc (HDC hDC)
00617 {
00618         CStabilize stabilize(this);
00619         // if we supported multiple objects, then we would enumerate
00620         // the objects and call paint on each of them from here.
00621
00622         if (m_lpSite)
00623                 m_lpSite->PaintObj(hDC);
00624
00625 }
00626
00627 //**********************************************************************
00628 //
00629 // CSimpleDoc::DisableInsertObject
00630 //
00631 // Purpose:
00632 //
00633 //      Disable the ability to insert a new object in this document.
00634 //
00635 // Parameters:
00636 //
00637 //      None
00638 //
00639 // Return Value:
00640 //
00641 //      None
00642 //
00643 // Function Calls:
00644 //      Function                    Location
00645 //
00646 //      RevokeDragDrop              OLE API
00647 //      EnableMenuItem              Windows API
00648 //
00649 // Comments:
00650 //
00651 //      This implementation only allows one object to be inserted
00652 //      into a document.  Once the object has been inserted, then
00653 //      the Insert Object menu choice is greyed out, to prevent
00654 //      the user from inserting another. Also we revoke ourself as
00655 //      a potential drop target.
00656 //
00657 //********************************************************************
00658
00659 void CSimpleDoc::DisableInsertObject(void)
00660 {
00661         // Disable InsertObject menu choice
00662         EnableMenuItem( m_lpApp->m_hEditMenu, 1, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
00663         // Enable Copy menu choice
00664         EnableMenuItem( m_lpApp->m_hEditMenu, 0, MF_BYPOSITION | MF_ENABLED);
00665
00666         // We no longer accept dropping of objects
00667         if (m_fRegDragDrop) {
00668                 RevokeDragDrop(m_hDocWnd);
00669                 m_fRegDragDrop = FALSE;
00670         }
00671 }
00672
00673 //**********************************************************************
00674 //
00675 // CSimpleDoc::CopyObjectToClip
00676 //
00677 // Purpose:
00678 //
00679 //      Copy the embedded OLE object to the clipboard
00680 //
00681 // Parameters:
00682 //
00683 //      None
00684 //
00685 // Return Value:
00686 //
00687 //      None
00688 //
00689 // Function Calls:
00690 //      Function                    Location
00691 //
00692 //      CDataXferObj::Create        DXFEROBJ.CPP
00693 //      CDataXferObj::QueryInterface DXFEROBJ.CPP
00694 //      OleSetClipboard             OLE API
00695 //
00696 // Comments:
00697 //
00698 //      This implementation only allows one object to be inserted
00699 //      into a document.  Once the object has been inserted, then
00700 //      the Copy menu choice is enabled.
00701 //
00702 //********************************************************************
00703
00704 void CSimpleDoc::CopyObjectToClip(void)
00705 {
00706         LPDATAOBJECT lpDataObj;
00707
00708         // Create a data transfer object by cloning the existing OLE object
00709         CDataXferObj FAR* pDataXferObj = CDataXferObj::Create(m_lpSite,NULL);
00710         if (! pDataXferObj) {
00711                 MessageBox(NULL,"Out-of-memory","SimpDnD",MB_SYSTEMMODAL|MB_ICONHAND);
00712                 return;
00713         }
00714         // initially obj is created with 0 refcnt. this QI will make it go to 1.
00715         pDataXferObj->QueryInterface(IID_IDataObject, (LPVOID FAR*)&lpDataObj);
00716
00717         // put out data transfer object on the clipboard. this API will AddRef.
00718         OleSetClipboard(lpDataObj);
00719
00720         // Give ownership of data transfer object to clipboard
00721         pDataXferObj->Release();
00722 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/DiskCleanupHandler/EmptyVolumeCache.h Source File

  • WinUI
  • Shell
  • DiskCleanupHandler

EmptyVolumeCache.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 //
00003 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 //  PARTICULAR PURPOSE.
00007 //
00008 //  Copyright (C) 1999 - 2000  Microsoft Corporation.  All rights reserved.
00009 //
00010 //  EmptyVolumeCache.h
00011 //
00012 //      Interface for the CEmptyVolumeCache class.
00013 //
00014 //////////////////////////////////////////////////////////////////////
00015
00016 #ifndef _EMPTYVOLUMECAHCE_H_INCLUDED
00017 #define _EMPTYVOLUMECAHCE_H_INCLUDED
00018
00019 #if _MSC_VER > 1000
00020 #pragma once
00021 #endif // _MSC_VER > 1000
00022
00023 class CEmptyVolumeCache : public IEmptyVolumeCache2
00024 {
00025 public:
00026     // Constructor/Destructor
00027     CEmptyVolumeCache ();
00028     ~CEmptyVolumeCache ();
00029
00030     // IUnknown methods
00031     STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObject);
00032     STDMETHODIMP_(ULONG) AddRef (VOID);
00033     STDMETHODIMP_(ULONG) Release (VOID);
00034
00035     // IEmptyVolumeCache methods
00036     STDMETHODIMP Deactivate (LPDWORD pdwFlags);
00037     STDMETHODIMP GetSpaceUsed (DWORDLONG *pdwSpaceUsed, IEmptyVolumeCacheCallBack *picb);
00038     STDMETHODIMP Initialize (HKEY hKey, LPCWSTR pcwszVolume, LPWSTR *ppwszDisplayName,
00039                              LPWSTR *ppwszDescription, DWORD *pdwFlags);
00040     STDMETHODIMP Purge (DWORDLONG dwSpaceToFree, IEmptyVolumeCacheCallBack *picb);
00041     STDMETHODIMP ShowProperties (HWND hWnd);
00042
00043     // IEmptyVolumeCache2 methods
00044     STDMETHODIMP InitializeEx (HKEY hKey, LPCWSTR pcwszVolume, LPCWSTR pcwszKeyName,
00045                                LPWSTR *ppwszDisplayName, LPWSTR *ppwszDescription,
00046                                LPWSTR *ppwszBtnText, DWORD *pdwFlags);
00047
00048 private:
00049     ULONG m_nRefCount;
00050 };
00051
00052 #endif // _EMPTYVOLUMECAHCE_H_INCLUDED
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

comadmin::ICatalogObject Member List

This is the complete list of members for comadmin::ICatalogObject, including all inherited members.
getKey() | comadmin::ICatalogObject |
getName() | comadmin::ICatalogObject |
getValid() | comadmin::ICatalogObject |
getValue(String bstrPropName) | comadmin::ICatalogObject |
iid | comadmin::ICatalogObject | [static]
IsPropertyReadOnly(String bstrPropName) | comadmin::ICatalogObject |
IsPropertyWriteOnly(String bstrPropName) | comadmin::ICatalogObject |
setValue(String bstrPropName, Variant retval) | comadmin::ICatalogObject |
Generated on Wed Nov 13 2024 16:58:06 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Crm/IDL/icrmFiles.Idl Source File

  • Com
  • Services
  • Crm
  • IDL

icrmFiles.Idl

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: ICrmFiles.idl
00004
00005 ----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009
00010
00011 Copyright (C) 1995-1998 Microsoft Corporation. All rights reserved.
00012
00013
00014
00015 This source code is intended only as a supplement to Microsoft
00016
00017 Development Tools and/or on-line documentation. See these other
00018
00019 materials for detailed information regarding Microsoft code samples.
00020
00021
00022
00023 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00024
00025 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00026
00027 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00028
00029 PARTICULAR PURPOSE.
00030
00031 ==========================================================================+*/
00032
00033 // ICrmFiles.idl : Interfaces common to VC and VJ implementations
00034 //
00035
00036 #include "mtxattr.h"
00037
00038 import "oaidl.idl";
00039 import "ocidl.idl";
00040
00041 // ICrmFilesWorker
00042 [
00043   object,
00044   uuid(43A7D836-B492-11D1-82F1-00A0C91EEDE9),
00045   dual,
00046   helpstring("ICrmFilesWorker Interface"),
00047   pointer_default(unique)
00048 ]
00049 interface ICrmFilesWorker : IDispatch
00050   {
00051     [helpstring("method CreateFile")] HRESULT CreateFile([in] BSTR bstrFileName);
00052     [helpstring("method DeleteFile")] HRESULT DeleteFile([in] BSTR bstrFileName);
00053   };
00054
00055 // ICrmFilesCompensator
00056 [
00057   object,
00058   uuid(43A7D838-B492-11D1-82F1-00A0C91EEDE9),
00059   dual,
00060   helpstring("ICrmFilesCompensator Interface"),
00061   pointer_default(unique)
00062 ]
00063 interface ICrmFilesCompensator : IDispatch
00064   {
00065   };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/compdata.h Source File

  • SysMgmt
  • MMC
  • About

compdata.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMPDATA_H_
00020 #define _SAMPCOMPDATA_H_
00021
00022 #include <mmc.h>
00023 #include "DeleBase.h"
00024 #include "StatNode.h"
00025 #include "Comp.h"
00026
00027 class CComponentData : public IComponentData
00028 {
00029     friend class CComponent;
00030
00031 private:
00032     ULONG       m_cref;
00033     LPCONSOLE     m_ipConsole;
00034     LPCONSOLENAMESPACE  m_ipConsoleNameSpace;
00035
00036     CStaticNode     *m_pStaticNode;
00037
00038 public:
00039     CComponentData();
00040     ~CComponentData();
00041
00042     ///////////////////////////////
00043     // Interface IUnknown
00044     ///////////////////////////////
00045     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00046     STDMETHODIMP_(ULONG) AddRef();
00047     STDMETHODIMP_(ULONG) Release();
00048
00049     ///////////////////////////////
00050     // Interface IComponentData
00051     ///////////////////////////////
00052     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00053         /* [in] */ LPUNKNOWN pUnknown);
00054
00055         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreateComponent(
00056         /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent);
00057
00058         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00059         /* [in] */ LPDATAOBJECT lpDataObject,
00060         /* [in] */ MMC_NOTIFY_TYPE event,
00061         /* [in] */ LPARAM arg,
00062         /* [in] */ LPARAM param);
00063
00064         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy( void);
00065
00066     virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00067         /* [in] */ MMC_COOKIE cookie,
00068         /* [in] */ DATA_OBJECT_TYPES type,
00069         /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00070
00071         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072         /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem);
00073
00074         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075         /* [in] */ LPDATAOBJECT lpDataObjectA,
00076         /* [in] */ LPDATAOBJECT lpDataObjectB);
00077 };
00078
00079 #endif _SAMPCOMPDATA_H_
Generated on Wed Nov 13 2024 16:52:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/StoServe/PAPER.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • StoServe

PAPER.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      PAPER.CPP
00003
00004   Summary:   Implementation file for the COPaper COM Object Class (for
00005              connectable COPaper COM Objects). This module provides a
00006              thread-safe virtual drawing Paper object. COPaper
00007              encapsulates into a COM object the behavior of an electronic
00008              sheet of white drawing paper. The client can use the native
00009              IPaper interface to draw free-form ink lines on the paper
00010              surface. No GUI behavior is provided within COPaper--it only
00011              provides the semantics of the virtual paper sheet and manages
00012              the ink data for the drawing done there. It also can store
00013              and load the paper data contents to and from an IStorage
00014              given by the client.
00015
00016              APPUTIL's CThreaded OwnThis technology is used in COPaper to
00017              ensure mutually exclusive access by contending multiple
00018              client threads.
00019
00020              Connectable object technology is used in COPaper to notify
00021              connected clients of various events like when a load of new
00022              data is completed.
00023
00024              COPaper offers a main standard IUnknown interface (basic COM
00025              object features), the standard IConnectionPointContainer
00026              interface (connectable COM object features), and the custom
00027              IPaper interface (drawing Paper related features). This
00028              multiple interface COM Object Class is achieved via the
00029              technique of nested classes.  The implementations of the
00030              IConnectionPointContainer and IPaper interfaces are nested
00031              inside the COPaper Class.
00032
00033              For a comprehensive tutorial code tour of this module's
00034              contents and offerings see the tutorial STOSERVE.HTM
00035              file. For more specific technical details on the internal
00036              workings see the comments dispersed throughout the module's
00037              source code.
00038
00039   Classes:   COPaper.
00040
00041   Functions: none.
00042
00043   Origin:    6-10-96: atrent - Editor-inheritance from BALL.CPP in
00044              the CONSERVE Tutorial Code Sample.
00045
00046 ----------------------------------------------------------------------------
00047   This file is part of the Microsoft COM Tutorial Code Samples.
00048
00049   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00050
00051   This source code is intended only as a supplement to Microsoft
00052   Development Tools and/or on-line documentation.  See these other
00053   materials for detailed information regarding Microsoft code samples.
00054
00055   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00056   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00057   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00058   PARTICULAR PURPOSE.
00059 ==========================================================================+*/
00060
00061
00062 /*---------------------------------------------------------------------------
00063   We include WINDOWS.H for all Win32 applications.
00064   We include OLE2.H because we will be calling the COM/OLE Libraries.
00065   We include OLECTL.H because it has definitions for connectable objects.
00066   We include APPUTIL.H because we will be building this application using
00067     the convenient Virtual Window and Dialog classes and other
00068     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00069   We include IPAPER.H and PAPGUIDS.H for the common Paper-related
00070     Interface class, GUID, and CLSID specifications.
00071   We include SERVER.H because it has internal class declarations for
00072     the server's control object.
00073   We include CONNECT.H for object class declarations for the various
00074     connection point and connection COM objects used in STOSERVE.
00075   We include PAPER.H because it has the COPaper class declarations.
00076 ---------------------------------------------------------------------------*/
00077 #include <windows.h>
00078 #include <ole2.h>
00079 #include <olectl.h>
00080 #include <apputil.h>
00081 #include <ipaper.h>
00082 #include <papguids.h>
00083 #include "server.h"
00084 #include "connect.h"
00085 #include "paper.h"
00086
00087
00088 /*---------------------------------------------------------------------------
00089   COPaper's implementation of its main COM object class including
00090   Constructor, Destructor, and the QueryInterface, AddRef, and Release
00091   methods of the principal IUnknown interface.
00092 ---------------------------------------------------------------------------*/
00093
00094 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00095   Method:   COPaper::COPaper
00096
00097   Summary:  COPaper Constructor. Note the member initializer:
00098             "m_ImpIPaper(this, pUnkOuter)" which is used to pass the
00099             'this' and pUnkOuter pointers of the constructor function to
00100             the constructor in the instantiation of the implementation of
00101             the CImpIPaper interface (which is nested inside this present
00102             COPaper Object Class). Same technique is used for the
00103             m_ImpIConnectionPointContainer nested interface
00104             implementation.
00105
00106   Args:     IUnknown* pUnkOuter,
00107               Pointer to the the outer IUnknown.  NULL means this COM Object
00108               is not being Aggregated.  Non NULL means it is being created
00109               on behalf of an outside COM object that is reusing it via
00110               aggregation.
00111             CServer* pServer)
00112               Pointer to the server's control object.
00113
00114   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00115
00116   Returns:  void
00117 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00118 COPaper::COPaper(
00119   IUnknown* pUnkOuter,
00120   CServer* pServer) :
00121   m_ImpIPaper(this, pUnkOuter),
00122   m_ImpIConnectionPointContainer(this, pUnkOuter)
00123 {
00124   UINT i;
00125
00126   // Zero the COM object's reference count.
00127   m_cRefs = 0;
00128
00129   // No AddRef necessary if non-NULL, as we're nested.
00130   m_pUnkOuter = pUnkOuter;
00131
00132   // Assign the pointer to the server control object.
00133   m_pServer = pServer;
00134
00135   // Null all entries in the connection point array.
00136   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00137     m_aConnectionPoints[i] = NULL;
00138
00139   return;
00140 }
00141
00142
00143 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00144   Method:   COPaper::~COPaper
00145
00146   Summary:  COPaper Destructor.
00147
00148   Args:     void
00149
00150   Returns:  void
00151 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00152 COPaper::~COPaper(void)
00153 {
00154   UINT i;
00155   IConnectionPoint* pIConnectionPoint;
00156
00157   // Do final release of the connection point objects.
00158   // If this isn't the final release, then the client has an outstanding
00159   // unbalanced reference to a connection point and a memory leak may
00160   // likely result because the host COPaper object is now going away yet
00161   // a connection point for this host object will not end up deleting
00162   // itself (and its connections array).
00163   for (i=0; i<MAX_CONNECTION_POINTS; i++)
00164   {
00165     pIConnectionPoint = m_aConnectionPoints[i];
00166     RELEASE_INTERFACE(pIConnectionPoint);
00167   }
00168
00169   return;
00170 }
00171
00172
00173 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00174   Method:   COPaper::Init
00175
00176   Summary:  COPaper initialization method.  Create any necessary arrays,
00177             structures, and subordinate objects.
00178
00179   Args:     void
00180
00181   Modifies: m_aConnectionPoints.
00182
00183   Returns:  HRESULT
00184               Standard result code. NOERROR for success.
00185 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00186 HRESULT COPaper::Init(void)
00187 {
00188   HRESULT hr = NOERROR;
00189   COConnectionPoint* pCOConnPt;
00190
00191   // Rig this COPaper COM object to be connectable. Assign the connection
00192   // point array. This object's connection points are determined at
00193   // compile time--it currently has only one connection point:
00194   // the CONNPOINT_PAPERSINK connection point. Create a connection
00195   // point object for this and assign it into the array. This array could
00196   // easily grow to support additional connection points in the future.
00197
00198   // First try creating a new connection point object. Pass 'this' as the
00199   // pHostObj pointer used by the connection point to pass its AddRef and
00200   // Release calls back to the host connectable object.
00201   pCOConnPt = new COConnectionPoint(this);
00202   if (NULL != pCOConnPt)
00203   {
00204     // If creation succeeded then initialize it (including creating
00205     // its initial dynamic connection array).
00206     hr = pCOConnPt->Init(IID_IPaperSink);
00207
00208     // If the init succeeded then use QueryInterface to obtain the
00209     // IConnectionPoint interface on the new connection point object.
00210     // The interface pointer is assigned directly into the
00211     // connection point array. The QI also does the needed AddRef.
00212     if (SUCCEEDED(hr))
00213       hr = pCOConnPt->QueryInterface(
00214                         IID_IConnectionPoint,
00215                         (PPVOID)&m_aConnectionPoints[CONNPOINT_PAPERSINK]);
00216   }
00217   else
00218     hr = E_OUTOFMEMORY;
00219
00220   return hr;
00221 }
00222
00223
00224 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00225   Method:   COPaper::QueryInterface
00226
00227   Summary:  QueryInterface of the COPaper non-delegating IUnknown
00228             implementation.
00229
00230   Args:     REFIID riid,
00231               [in] GUID of the Interface being requested.
00232             PPVOID ppv)
00233               [out] Address of the caller's pointer variable that will
00234               receive the requested interface pointer.
00235
00236   Returns:  HRESULT
00237               Standard result code. NOERROR for success.
00238 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00239 STDMETHODIMP COPaper::QueryInterface(
00240                REFIID riid,
00241                PPVOID ppv)
00242 {
00243   HRESULT hr = E_NOINTERFACE;
00244
00245   *ppv = NULL;
00246
00247   if (IID_IUnknown == riid)
00248     *ppv = this;
00249   else if (IID_IPaper == riid)
00250     *ppv = &m_ImpIPaper;
00251   else if (IID_IConnectionPointContainer == riid)
00252     *ppv = &m_ImpIConnectionPointContainer;
00253
00254   if (NULL != *ppv)
00255   {
00256     // We've handed out a pointer to the interface so obey the COM rules
00257     // and AddRef the reference count.
00258     ((LPUNKNOWN)*ppv)->AddRef();
00259     hr = NOERROR;
00260   }
00261
00262   return (hr);
00263 }
00264
00265
00266 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00267   Method:   COPaper::AddRef
00268
00269   Summary:  AddRef of the COPaper non-delegating IUnknown implementation.
00270
00271   Args:     void
00272
00273   Modifies: m_cRefs.
00274
00275   Returns:  ULONG
00276               New value of m_cRefs (COM object's reference count).
00277 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00278 STDMETHODIMP_(ULONG) COPaper::AddRef(void)
00279 {
00280   ULONG cRefs;
00281
00282   if (OwnThis())
00283   {
00284     cRefs = ++m_cRefs;
00285
00286     UnOwnThis();
00287   }
00288
00289   return cRefs;
00290 }
00291
00292
00293 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00294   Method:   COPaper::Release
00295
00296   Summary:  Release of the COPaper non-delegating IUnknown implementation.
00297
00298   Args:     void
00299
00300   Modifies: m_cRefs.
00301
00302   Returns:  ULONG
00303               New value of m_cRefs (COM object's reference count).
00304 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00305 STDMETHODIMP_(ULONG) COPaper::Release(void)
00306 {
00307   ULONG cRefs;
00308
00309   if (OwnThis())
00310   {
00311     cRefs = --m_cRefs;
00312
00313     if (0 == cRefs)
00314     {
00315       // We've reached a zero reference count for this COM object.
00316       // So we tell the server housing to decrement its global object
00317       // count so that the server will be unloaded if appropriate.
00318       if (NULL != m_pServer)
00319         m_pServer->ObjectsDown();
00320
00321       // We artificially bump the main ref count to prevent reentrancy
00322       // via the main object destructor.  Not really needed in this
00323       // COPaper but a good practice because we are aggregatable and
00324       // may at some point in the future add something entertaining like
00325       // some Releases to the COPaper destructor. We relinquish thread
00326       // ownership of this object prior to deleting it--a good practice.
00327       m_cRefs++;
00328       UnOwnThis();
00329       delete this;
00330     }
00331     else
00332       UnOwnThis();
00333   }
00334
00335   return cRefs;
00336 }
00337
00338
00339 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00340   Method:   COPaper::NotifySinks
00341
00342   Summary:  Internal utility method of this COM object used to fire event
00343             notification calls to all listening connection sinks in the
00344             client.
00345
00346   Args:     PAPER_EVENT PaperEvent
00347               Type of notification event.
00348             SHORT nX
00349               X cordinate. Value is 0 unless event needs it.
00350             SHORT nY
00351               Y cordinate. Value is 0 unless event needs it.
00352             SHORT nInkWidth
00353               Ink Width. Value is 0 unless event needs it.
00354             SHORT crInkColor
00355               COLORREF RGB color value. Value is 0 unless event needs it.
00356
00357   Returns:  HRESULT
00358               Standard result code. NOERROR for success.
00359 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00360 HRESULT COPaper::NotifySinks(
00361        PAPER_EVENT PaperEvent,
00362        SHORT nX,
00363        SHORT nY,
00364        SHORT nInkWidth,
00365        COLORREF crInkColor)
00366 {
00367   HRESULT hr = NOERROR;
00368   IConnectionPoint* pIConnectionPoint;
00369   IEnumConnections* pIEnum;
00370   CONNECTDATA ConnData;
00371
00372   // If there was a paper event, broadcast appropriate notifications to
00373   // all Sinks connected to each connection point.
00374   if (PAPER_EVENT_NONE != PaperEvent)
00375   {
00376     // Here is the section for the PaperSink connection point--currently
00377     // this is the only connection point offered by COPaper objects.
00378     pIConnectionPoint = m_aConnectionPoints[CONNPOINT_PAPERSINK];
00379     if (NULL != pIConnectionPoint)
00380     {
00381       pIConnectionPoint->AddRef();
00382       hr = pIConnectionPoint->EnumConnections(&pIEnum);
00383       if (SUCCEEDED(hr))
00384       {
00385         // Loop thru the connection point's connections and if the
00386         // listening connection supports IPaperSink (ie, PaperSink events)
00387         // then dispatch the PaperEvent event notification to that sink.
00388         while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
00389         {
00390           IPaperSink* pIPaperSink;
00391
00392           hr = ConnData.pUnk->QueryInterface(
00393                                 IID_IPaperSink,
00394                                 (PPVOID)&pIPaperSink);
00395           if (SUCCEEDED(hr))
00396           {
00397             switch (PaperEvent)
00398             {
00399               case PAPER_EVENT_LOCKED:
00400                 pIPaperSink->Locked();
00401                 break;
00402               case PAPER_EVENT_UNLOCKED:
00403                 pIPaperSink->Unlocked();
00404                 break;
00405               case PAPER_EVENT_LOADED:
00406                 pIPaperSink->Loaded();
00407                 break;
00408               case PAPER_EVENT_SAVED:
00409                 pIPaperSink->Saved();
00410                 break;
00411               case PAPER_EVENT_INKSTART:
00412                 pIPaperSink->InkStart(nX, nY, nInkWidth, crInkColor);
00413                 break;
00414               case PAPER_EVENT_INKDRAW:
00415                 pIPaperSink->InkDraw(nX, nY);
00416                 break;
00417               case PAPER_EVENT_INKSTOP:
00418                 pIPaperSink->InkStop(nX, nY);
00419                 break;
00420               case PAPER_EVENT_ERASED:
00421                 pIPaperSink->Erased();
00422                 break;
00423               case PAPER_EVENT_RESIZED:
00424                 pIPaperSink->Resized(nX, nY);
00425                 break;
00426               default:
00427                 break;
00428             }
00429             pIPaperSink->Release();
00430           }
00431           ConnData.pUnk->Release();
00432         }
00433         pIEnum->Release();
00434       }
00435       pIConnectionPoint->Release();
00436     }
00437   }
00438
00439   return hr;
00440 }
00441
00442
00443 /*---------------------------------------------------------------------------
00444   COPaper's nested implementation of the COM standard
00445   IConnectionPointContainer interface including Constructor, Destructor,
00446   QueryInterface, AddRef, Release, FindConnectionPoint, and
00447   EnumConnectionPoints.
00448 ---------------------------------------------------------------------------*/
00449
00450 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00451   Method:   COPaper::CImpIConnectionPointContainer
00452               ::CImpIConnectionPointContainer
00453
00454   Summary:  Constructor for the CImpIConnectionPointContainer interface
00455             instantiation.
00456
00457   Args:     COPaper* pBackObj,
00458               Back pointer to the parent outer COM object.
00459             IUnknown* pUnkOuter
00460               Pointer to the outer Unknown.  For delegation.
00461
00462   Modifies: m_pBackObj, m_pUnkOuter.
00463
00464   Returns:  void
00465 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00466 COPaper::CImpIConnectionPointContainer::CImpIConnectionPointContainer(
00467   COPaper* pBackObj,
00468   IUnknown* pUnkOuter)
00469 {
00470   // Init the Back Object Pointer to point to the parent object.
00471   m_pBackObj = pBackObj;
00472
00473   // Init the CImpIConnectionPointContainer interface's delegating Unknown
00474   // pointer.  We use the Back Object pointer for IUnknown delegation here
00475   // if we are not being aggregated.  If we are being aggregated we use
00476   // the supplied pUnkOuter for IUnknown delegation.  In either case the
00477   // pointer assignment requires no AddRef because the
00478   // CImpIConnectionPointContainer lifetime is quaranteed by the lifetime
00479   // of the parent object in which CImpIConnectionPointContainer is
00480   // nested.
00481   if (NULL == pUnkOuter)
00482     m_pUnkOuter = pBackObj;
00483   else
00484     m_pUnkOuter = pUnkOuter;
00485
00486   return;
00487 }
00488
00489
00490 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00491   Method:   COPaper::CImpIConnectionPointContainer
00492               ::~CImpIConnectionPointContainer
00493
00494   Summary:  Destructor for the CImpIConnectionPointContainer interface
00495             instantiation.
00496
00497   Args:     void
00498
00499   Returns:  void
00500 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00501 COPaper::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
00502 {
00503   return;
00504 }
00505
00506
00507 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00508   Method:   COPaper::CImpIConnectionPointContainer::QueryInterface
00509
00510   Summary:  The QueryInterface IUnknown member of this interface
00511             implementation that delegates to m_pUnkOuter, whatever it is.
00512
00513   Args:     REFIID riid,
00514               [in] GUID of the Interface being requested.
00515             PPVOID ppv)
00516               [out] Address of the caller's pointer variable that will
00517               receive the requested interface pointer.
00518
00519   Returns:  HRESULT
00520               Standard result code. NOERROR for success.
00521               Returned by the delegated outer QueryInterface call.
00522 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00523 STDMETHODIMP COPaper::CImpIConnectionPointContainer::QueryInterface(
00524                REFIID riid,
00525                PPVOID ppv)
00526 {
00527   // Delegate this call to the outer object's QueryInterface.
00528   return m_pUnkOuter->QueryInterface(riid, ppv);
00529 }
00530
00531
00532 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00533   Method:   COPaper::CImpIConnectionPointContainer::AddRef
00534
00535   Summary:  The AddRef IUnknown member of this interface implementation
00536             that delegates to m_pUnkOuter, whatever it is.
00537
00538   Args:     void
00539
00540   Returns:  ULONG
00541               Returned by the delegated outer AddRef call.
00542 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00543 STDMETHODIMP_(ULONG) COPaper::CImpIConnectionPointContainer::AddRef(void)
00544 {
00545   // Delegate this call to the outer object's AddRef.
00546   return m_pUnkOuter->AddRef();
00547 }
00548
00549
00550 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00551   Method:   COPaper::CImpIConnectionPointContainer::Release
00552
00553   Summary:  The Release IUnknown member of this interface implementation
00554             that delegates to m_pUnkOuter, whatever it is.
00555
00556   Args:     void
00557
00558   Returns:  ULONG
00559               Returned by the delegated outer Release call.
00560 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00561 STDMETHODIMP_(ULONG) COPaper::CImpIConnectionPointContainer::Release(void)
00562 {
00563   // Delegate this call to the outer object's Release.
00564   return m_pUnkOuter->Release();
00565 }
00566
00567
00568 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00569   Method:   COPaper::CImpIConnectionPointContainer::FindConnectionPoint
00570
00571   Summary:  Given an IID for a connection point sink find and return the
00572             interface pointer for that connection point sink.
00573
00574   Args:     REFIID riid
00575               Reference to an IID
00576             IConnectionPoint** ppConnPt
00577               Address of the caller's IConnectionPoint interface pointer
00578               variable that will receive the requested interface pointer.
00579
00580   Returns:  HRESULT
00581               Standard result code. NOERROR for success.
00582 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00583 STDMETHODIMP COPaper::CImpIConnectionPointContainer::FindConnectionPoint(
00584                REFIID riid,
00585                IConnectionPoint** ppConnPt)
00586 {
00587   HRESULT hr = E_NOINTERFACE;
00588   IConnectionPoint* pIConnPt;
00589
00590   if (OwnThis())
00591   {
00592     // NULL the output variable.
00593     *ppConnPt = NULL;
00594
00595     pIConnPt = m_pBackObj->m_aConnectionPoints[CONNPOINT_PAPERSINK];
00596     if (NULL != pIConnPt)
00597     {
00598       // This connectable COPaper object currently has only the Paper Sink
00599       // connection point. If the associated interface is requested,
00600       // use QI to get the Connection Point interface and perform the
00601       // needed AddRef.
00602       if (IID_IPaperSink == riid)
00603         hr = pIConnPt->QueryInterface(
00604                          IID_IConnectionPoint,
00605                          (PPVOID)ppConnPt);
00606     }
00607
00608     UnOwnThis();
00609   }
00610
00611   return hr;
00612 }
00613
00614
00615 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00616   Method:   COPaper::CImpIConnectionPointContainer::EnumConnectionPoints
00617
00618   Summary:  Return Enumerator for the connectable object's contained
00619             connection points.
00620
00621   Args:     IEnumConnectionPoints** ppIEnum
00622               Address of the caller's Enumerator interface pointer
00623               variable. An output variable that will receive a pointer to
00624               the connection point enumerator COM object.
00625
00626   Returns:  HRESULT
00627               Standard result code. NOERROR for success.
00628 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00629 STDMETHODIMP COPaper::CImpIConnectionPointContainer::EnumConnectionPoints(
00630                        IEnumConnectionPoints** ppIEnum)
00631 {
00632   HRESULT hr = NOERROR;
00633   IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
00634   COEnumConnectionPoints* pCOEnum;
00635   UINT i;
00636
00637   if (OwnThis())
00638   {
00639     // Zero the output interface pointer.
00640     *ppIEnum = NULL;
00641
00642     // Make a copy on the stack of the array of connection point
00643     // interfaces. The copy is used below in the creation of the new
00644     // Enumerator object.
00645     for (i=0; i<MAX_CONNECTION_POINTS; i++)
00646       aConnPts[i] = (IConnectionPoint*)m_pBackObj->m_aConnectionPoints[i];
00647
00648     // Create a Connection Point enumerator COM object for the connection
00649     // points offered by this COPaper object. Pass 'this' to be used to
00650     // hook the lifetime of the host object to the life time of this
00651     // enumerator object.
00652     pCOEnum = new COEnumConnectionPoints(this);
00653     if (NULL != pCOEnum)
00654     {
00655       // Use the array copy to Init the new Enumerator COM object.
00656       // Set the initial Enumerator index to 0.
00657       hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
00658       if (SUCCEEDED(hr))
00659       {
00660         // QueryInterface to return the requested interface pointer.
00661         // An AddRef will be conveniently done by the QI.
00662         if (SUCCEEDED(hr))
00663           hr = pCOEnum->QueryInterface(
00664                           IID_IEnumConnectionPoints,
00665                           (PPVOID)ppIEnum);
00666       }
00667     }
00668     else
00669       hr = E_OUTOFMEMORY;
00670
00671     UnOwnThis();
00672   }
00673
00674   return hr;
00675 }
00676
00677
00678 /*---------------------------------------------------------------------------
00679   COPaper's nested implementation of the custom IPaper interface including
00680   Constructor, Destructor, QueryInterface, AddRef, Release, Init, Lock,
00681   Unlock, Load, Save, InkStart, InkDraw, InkStop, Erase, Resize, and
00682   Redraw.
00683 ---------------------------------------------------------------------------*/
00684
00685 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00686   Method:   COPaper::CImpIPaper::CImpIPaper
00687
00688   Summary:  Constructor for the CImpIPaper interface instantiation.
00689
00690   Args:     COPaper* pBackObj,
00691               Back pointer to the parent outer COM object.
00692             IUnknown* pUnkOuter
00693               Pointer to the outer Unknown.  For delegation.
00694
00695   Modifies: m_pBackObj, m_pUnkOuter.
00696
00697   Returns:  void
00698 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00699 COPaper::CImpIPaper::CImpIPaper(
00700   COPaper* pBackObj,
00701   IUnknown* pUnkOuter)
00702 {
00703   // Init the Back Object Pointer to point to the parent object.
00704   m_pBackObj = pBackObj;
00705
00706   // Init the CImpIPaper interface's delegating Unknown pointer.  We use
00707   // the Back Object pointer for IUnknown delegation here if we are not
00708   // being aggregated.  If we are being aggregated we use the supplied
00709   // pUnkOuter for IUnknown delegation.  In either case the pointer
00710   // assignment requires no AddRef because the CImpIPaper lifetime is
00711   // quaranteed by the lifetime of the parent object in which
00712   // CImpIPaper is nested.
00713   if (NULL == pUnkOuter)
00714     m_pUnkOuter = pBackObj;
00715   else
00716     m_pUnkOuter = pUnkOuter;
00717
00718   // Now initialize the living heart of this virtual Paper entity.
00719   m_ClipBdFmt    = 0;
00720   m_bLocked      = FALSE;
00721   m_cLockKey     = 0;
00722   m_crWinColor   = RGB(255,255,255); // White
00723   m_crInkColor   = RGB(0,0,0);       // Black
00724   m_nInkWidth    = 2;                // 2 pixels wide (thin).
00725   m_lInkDataEnd  = 0;                // Current drawing data end.
00726   m_lInkDataMax  = 0;                // Upper bound to m_lInkDataEnd.
00727   m_paInkData    = NULL;             // Points to Ink data array.
00728
00729   return;
00730 }
00731
00732
00733 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00734   Method:   COPaper::CImpIPaper::~CImpIPaper
00735
00736   Summary:  Destructor for the CImpIPaper interface instantiation.
00737
00738   Args:     void
00739
00740   Returns:  void
00741 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00742 COPaper::CImpIPaper::~CImpIPaper(void)
00743 {
00744   INKDATA* paInkData;
00745
00746   // NULL the pointer first and then delete the entire ink data array.
00747   paInkData = m_paInkData;
00748   m_paInkData = NULL;
00749   if (NULL != paInkData)
00750     delete [] paInkData;
00751
00752   return;
00753 }
00754
00755
00756 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00757   Method:   COPaper::CImpIPaper::QueryInterface
00758
00759   Summary:  The QueryInterface IUnknown member of this IPaper interface
00760             implementation that delegates to m_pUnkOuter, whatever it is.
00761
00762   Args:     REFIID riid,
00763               [in] GUID of the Interface being requested.
00764             PPVOID ppv)
00765               [out] Address of the caller's pointer variable that will
00766               receive the requested interface pointer.
00767
00768   Returns:  HRESULT
00769               Standard result code. NOERROR for success.
00770               Returned by the delegated outer QueryInterface call.
00771 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00772 STDMETHODIMP COPaper::CImpIPaper::QueryInterface(
00773                REFIID riid,
00774                PPVOID ppv)
00775 {
00776   // Delegate this call to the outer object's QueryInterface.
00777   return m_pUnkOuter->QueryInterface(riid, ppv);
00778 }
00779
00780
00781 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00782   Method:   COPaper::CImpIPaper::AddRef
00783
00784   Summary:  The AddRef IUnknown member of this IPaper interface
00785             implementation that delegates to m_pUnkOuter, whatever it is.
00786
00787   Args:     void
00788
00789   Returns:  ULONG
00790               Returned by the delegated outer AddRef call.
00791 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00792 STDMETHODIMP_(ULONG) COPaper::CImpIPaper::AddRef(void)
00793 {
00794   // Delegate this call to the outer object's AddRef.
00795   return m_pUnkOuter->AddRef();
00796 }
00797
00798
00799 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00800   Method:   COPaper::CImpIPaper::Release
00801
00802   Summary:  The Release IUnknown member of this IPaper interface
00803             implementation that delegates to m_pUnkOuter, whatever it is.
00804
00805   Args:     void
00806
00807   Returns:  ULONG
00808               Returned by the delegated outer Release call.
00809 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00810 STDMETHODIMP_(ULONG) COPaper::CImpIPaper::Release(void)
00811 {
00812   // Delegate this call to the outer object's Release.
00813   return m_pUnkOuter->Release();
00814 }
00815
00816
00817 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00818   Method:   COPaper::CImpIPaper::InitPaper
00819
00820   Summary:  The InitPaper member method of the IPaper interface
00821             implementation. Called by outside clients of a COPaper object
00822             to initialize this electronic paper object.
00823
00824   Args:     RECT* pWinRect
00825               The initial drawing window rectangle. An [in,out] argument.
00826             BOOL* pbFirst
00827               A return value indicating TRUE if this the first client;
00828               FALSE otherwise. If FALSE caller should set its window
00829               size to the value pointed to by the returned *pWinRect.
00830
00831   Returns:  HRESULT
00832               Standard result code. NOERROR for success.
00833 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00834 STDMETHODIMP COPaper::CImpIPaper::InitPaper(
00835                RECT* pWinRect,
00836                BOOL* pbFirst)
00837 {
00838   HRESULT hr = E_FAIL;
00839   INKDATA* paInkData;
00840
00841   if (OwnThis())
00842   {
00843     if (0 == m_lInkDataMax)
00844     {
00845       // Tell caller this is first client to Init.
00846       if (NULL != pbFirst)
00847         *pbFirst = TRUE;
00848
00849       // Build the initial dynamic array of InkData.
00850       paInkData = new INKDATA[(LONG) INKDATA_ALLOC_INIT];
00851       if (NULL != paInkData)
00852       {
00853         // Zero the array.
00854         memset(paInkData, 0, INKDATA_ALLOC_INIT * sizeof(INKDATA));
00855
00856         // Rig this Paper object so that it can use the Ink Data array.
00857         m_lInkDataMax = INKDATA_ALLOC_INIT;
00858         m_paInkData = paInkData;
00859
00860         // Assign window rect values from initial client.
00861         m_WinRect.left = pWinRect->left;
00862         m_WinRect.top = pWinRect->top;
00863         m_WinRect.right = pWinRect->right;
00864         m_WinRect.bottom = pWinRect->bottom;
00865         hr = NOERROR;
00866       }
00867       else
00868         hr = E_OUTOFMEMORY;
00869     }
00870     else
00871     {
00872       // If not the first Init.
00873       // Assign client's output rect values.
00874       pWinRect->left = m_WinRect.left;
00875       pWinRect->top = m_WinRect.top;
00876       pWinRect->right = m_WinRect.right;
00877       pWinRect->bottom = m_WinRect.bottom;
00878
00879       // Tell caller to set his window size.
00880       if (NULL != pbFirst)
00881         *pbFirst = FALSE;
00882     }
00883
00884     // Zero the Paper Properties structure. Init the ink data version.
00885     memset(&m_PaperProperties, 0, sizeof(PAPER_PROPERTIES));
00886     m_PaperProperties.lInkDataVersion = INKDATA_VERSION10;
00887
00888     // Register a clipboard format for these COPaper things.
00889     m_ClipBdFmt = RegisterClipboardFormat(TEXT(CLIPBDFMT_STR));
00890
00891     UnOwnThis();
00892   }
00893
00894   return hr;
00895 }
00896
00897
00898 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00899   Method:   COPaper::CImpIPaper::Lock
00900
00901   Summary:  The Lock member method of the IPaper interface implementation.
00902             Called by outside clients of a COPaper object to lock their
00903             ownership of the Paper object. Returns a lock key identifier.
00904             COPaper is coded for eventual use in a multi-threaded multi-
00905             client situation where the Lock and Unlock methods permit
00906             a client to lock its use of a single COPaper object.
00907
00908   Args:     SHORT* pnLockKey
00909               Address of a short variable to receive the LockKey.
00910
00911   Returns:  HRESULT
00912               Standard result code. NOERROR for success.
00913 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00914 STDMETHODIMP COPaper::CImpIPaper::Lock(
00915                SHORT* pnLockKey)
00916 {
00917   HRESULT hr = E_FAIL;
00918
00919   if (OwnThis())
00920   {
00921     if (!m_bLocked)
00922     {
00923       // If the paper is not currently locked then increment the LockKey
00924       // counter and assign the output variable the new value. Set paper
00925       // object's lock state to TRUE.
00926       *pnLockKey = ++m_cLockKey;
00927       m_bLocked = TRUE;
00928       hr = NOERROR;
00929     }
00930
00931     UnOwnThis();
00932   }
00933
00934   // Notify all other connected clients that Paper is now locked.
00935   if (SUCCEEDED(hr))
00936     m_pBackObj->NotifySinks(PAPER_EVENT_LOCKED, 0, 0, 0, 0);
00937
00938   return hr;
00939 }
00940
00941
00942 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00943   Method:   COPaper::CImpIPaper::Unlock
00944
00945   Summary:  The Unlock member method of the IPaper interface
00946             implementation. Called by outside clients of a COPaper object
00947             to relinquish their exclusive ownership of the paper object.
00948
00949   Args:     SHORT nLockKey
00950               The lock key previously obtained in a Lock call.
00951
00952   Returns:  HRESULT
00953               Standard result code. NOERROR for success.
00954 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00955 STDMETHODIMP COPaper::CImpIPaper::Unlock(
00956                SHORT nLockKey)
00957 {
00958   HRESULT hr = E_FAIL;
00959
00960   if (OwnThis())
00961   {
00962     if (m_bLocked)
00963     {
00964       // If the paper is currently locked then set to unlocked state.
00965       ++m_cLockKey;
00966       m_bLocked = FALSE;
00967       hr = NOERROR;
00968     }
00969
00970     UnOwnThis();
00971   }
00972
00973   // Notify all other connected clients that Paper is now unlocked.
00974   if (SUCCEEDED(hr))
00975     m_pBackObj->NotifySinks(PAPER_EVENT_UNLOCKED, 0, 0, 0, 0);
00976
00977   return hr;
00978 }
00979
00980
00981 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00982   Method:   COPaper::CImpIPaper::Load
00983
00984   Summary:  The Load member method of the IPaper interface implementation.
00985             Called by outside clients of a COPaper object to Load a new
00986             set of ink drawing data onto the Paper surface. Notifies
00987             all other connected clients when the load is complete.
00988
00989   Args:     SHORT nLockKey
00990               The lock key previously obtained in a Lock call.
00991             IStorage* pIStorage
00992               Interface pointer for the client's compound file storage.
00993
00994   Returns:  HRESULT
00995               Standard result code. NOERROR for success.
00996 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00997 STDMETHODIMP COPaper::CImpIPaper::Load(
00998                SHORT nLockKey,
00999                IStorage* pIStorage)
01000 {
01001   HRESULT hr = E_FAIL;
01002   IStream* pIStream;
01003   INKDATA* paInkData;
01004   ULONG ulToRead, ulReadIn;
01005   LONG lNewArraySize;
01006   PAPER_PROPERTIES NewProps;
01007
01008   if (OwnThis())
01009   {
01010     if (m_bLocked && m_cLockKey == nLockKey && NULL != pIStorage)
01011     {
01012       // Open the "PAPERDATA" stream where the paper data is stored.
01013       hr = pIStorage->OpenStream(
01014              STREAM_PAPERDATA_USTR,
01015              0,
01016              STGM_READ | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
01017              0,
01018              &pIStream);
01019       if (SUCCEEDED(hr))
01020       {
01021         // We have the paper data stream. First read the Paper Properties.
01022         ulToRead = sizeof(PAPER_PROPERTIES);
01023         hr = pIStream->Read(
01024                          &NewProps,
01025                          ulToRead,
01026                          &ulReadIn);
01027         if (SUCCEEDED(hr) && ulToRead != ulReadIn)
01028           hr = E_FAIL;
01029         if (SUCCEEDED(hr))
01030         {
01031           // Deal with the different versions of ink data format.
01032           switch (NewProps.lInkDataVersion)
01033           {
01034             case INKDATA_VERSION10:
01035               // Allocate an ink data array big enough--add some extra too.
01036               lNewArraySize = NewProps.lInkArraySize + INKDATA_ALLOC;
01037               paInkData = new INKDATA[(LONG) lNewArraySize];
01038               if (NULL != paInkData)
01039               {
01040                 // Delete the entire old ink data array.
01041                 delete [] m_paInkData;
01042
01043                 // Assign the new array.
01044                 m_paInkData = paInkData;
01045                 m_lInkDataMax = lNewArraySize;
01046
01047                 // Now read the complete array of Ink Data.
01048                 ulToRead = NewProps.lInkArraySize * sizeof(INKDATA);
01049                 hr = pIStream->Read(m_paInkData, ulToRead, &ulReadIn);
01050                 if (SUCCEEDED(hr) && ulToRead != ulReadIn)
01051                   hr = E_FAIL;
01052                 if (SUCCEEDED(hr))
01053                 {
01054                   // Rig COPaper to use the PAPER_PROPERTIES info.
01055                   m_lInkDataEnd = NewProps.lInkArraySize-1;
01056                   m_crWinColor = NewProps.crWinColor;
01057                   m_WinRect.right = NewProps.WinRect.right;
01058                   m_WinRect.bottom = NewProps.WinRect.bottom;
01059
01060                   // Copy the new properties into current properties.
01061                   memcpy(
01062                     &m_PaperProperties,
01063                     &NewProps,
01064                     sizeof(PAPER_PROPERTIES));
01065                 }
01066               }
01067               else
01068                 hr = E_OUTOFMEMORY;
01069               break;
01070             default:
01071               hr = E_FAIL;  // Bad version.
01072               break;
01073           }
01074         }
01075
01076         // We are done with the stream so release it.
01077         pIStream->Release();
01078       }
01079     }
01080
01081     UnOwnThis();
01082   }
01083
01084   // Notify all other connected clients that Paper is now loaded.
01085   // If we didn't load then erase to a safe, empty ink data array.
01086   if (SUCCEEDED(hr))
01087     m_pBackObj->NotifySinks(PAPER_EVENT_LOADED, 0, 0, 0, 0);
01088   else
01089     Erase(nLockKey);
01090
01091   return hr;
01092 }
01093
01094
01095 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01096   Method:   COPaper::CImpIPaper::Save
01097
01098   Summary:  The Save member method of the IPaper interface implementation.
01099             Called by outside clients of a COPaper object to Save the
01100             current set of ink drawing data from the Paper surface to
01101             a client-specified compound file storage. Notifies
01102             all other connected clients when the save is complete.
01103
01104   Args:     SHORT nLockKey
01105               The lock key previously obtained in a Lock call.
01106             IStorage* pIStorage
01107               Interface pointer for the client's compound file storage.
01108
01109   Returns:  HRESULT
01110               Standard result code. NOERROR for success.
01111 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01112 STDMETHODIMP COPaper::CImpIPaper::Save(
01113                SHORT nLockKey,
01114                IStorage* pIStorage)
01115 {
01116   HRESULT hr = E_FAIL;
01117   IStream* pIStream;
01118   ULONG ulToWrite, ulWritten;
01119
01120   if (OwnThis())
01121   {
01122     if (m_bLocked && m_cLockKey == nLockKey && NULL != pIStorage)
01123     {
01124       // First use COM service to mark this compound file as one that is
01125       // handled by our server component, DllPaper.
01126       WriteClassStg(pIStorage, CLSID_DllPaper);
01127
01128       // Use COM Service to write user-readable clipboard format into
01129       // the compound file.
01130       WriteFmtUserTypeStg(pIStorage, m_ClipBdFmt, TEXT(CLIPBDFMT_STR));
01131
01132       // Create the stream to be used for the actual paper data.
01133       // Call it "PAPERDATA".
01134       hr = pIStorage->CreateStream(
01135              STREAM_PAPERDATA_USTR,
01136              STGM_CREATE | STGM_WRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE,
01137              0,
01138              0,
01139              &pIStream);
01140       if (SUCCEEDED(hr))
01141       {
01142         // Got a stream. Now write data into it.
01143         // First write PAPER_PROPERTIES structure.
01144         m_PaperProperties.lInkArraySize = m_lInkDataEnd+1;
01145         m_PaperProperties.crWinColor = m_crWinColor;
01146         m_PaperProperties.WinRect.right = m_WinRect.right;
01147         m_PaperProperties.WinRect.bottom = m_WinRect.bottom;
01148         ulToWrite = sizeof(PAPER_PROPERTIES);
01149         hr = pIStream->Write(&m_PaperProperties, ulToWrite, &ulWritten);
01150         if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01151           hr = STG_E_CANTSAVE;
01152         if (SUCCEEDED(hr))
01153         {
01154           // Now write the complete array of Ink Data.
01155           ulToWrite = m_PaperProperties.lInkArraySize * sizeof(INKDATA);
01156           hr = pIStream->Write(m_paInkData, ulToWrite, &ulWritten);
01157           if (SUCCEEDED(hr) && ulToWrite != ulWritten)
01158             hr = STG_E_CANTSAVE;
01159         }
01160
01161         // We are done with the stream so release it.
01162         pIStream->Release();
01163       }
01164     }
01165
01166     UnOwnThis();
01167   }
01168
01169   // Notify all other connected clients that Paper is now saved.
01170   if (SUCCEEDED(hr))
01171     m_pBackObj->NotifySinks(PAPER_EVENT_SAVED, 0, 0, 0, 0);
01172
01173   return hr;
01174 }
01175
01176
01177 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01178   Method:   COPaper::CImpIPaper::NextSlot
01179
01180   Summary:  An internal private utility member method to increment to the
01181             next slot in the dynamic Ink Data array. NextSlot will expand
01182             the dynamic array for more entries if needed. To guarantee
01183             thread safety, this private method should always be called
01184             within the protection of a bracketed OwnThis, UnOwnThis pair.
01185
01186   Args:     void
01187
01188   Modifies: m_lInkDataEnd, m_lInkDataMax, m_paInkData.
01189
01190   Returns:  HRESULT
01191               Standard result code. NOERROR for success.
01192 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01193 HRESULT COPaper::CImpIPaper::NextSlot(
01194                                void)
01195 {
01196   HRESULT hr = NOERROR;
01197   LONG lInkDataEnd = m_lInkDataEnd + 1;
01198   INKDATA* paInkData;
01199
01200   if (lInkDataEnd >= m_lInkDataMax)
01201   {
01202     // No more room in Ink Data array. Allocate new space.
01203     paInkData = new INKDATA[(LONG) (m_lInkDataMax + INKDATA_ALLOC)];
01204     if (NULL != paInkData)
01205     {
01206       // Copy the content of the old full array to the new larger array.
01207       memcpy(paInkData, m_paInkData, lInkDataEnd * sizeof(INKDATA));
01208
01209       // Zero (& mark as empty) the expanded portion of the new array.
01210       memset(&paInkData[lInkDataEnd], 0, INKDATA_ALLOC * sizeof(INKDATA));
01211
01212       // New larger array is ready--delete the old array.
01213       delete [] m_paInkData;
01214
01215       // Rig the to use the new larger array.
01216       m_paInkData = paInkData;
01217
01218       // Calculate the new max index.
01219       m_lInkDataMax += INKDATA_ALLOC;
01220     }
01221     else
01222       hr = E_OUTOFMEMORY;
01223   }
01224
01225   if (SUCCEEDED(hr))
01226     m_lInkDataEnd = lInkDataEnd;
01227
01228   return hr;
01229 }
01230
01231
01232 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01233   Method:   COPaper::CImpIPaper::InkStart
01234
01235   Summary:  The InkStart member method of the IPaper interface
01236             implementation. Called by outside clients of a COPaper object
01237             to start an ink drawing sequence.
01238
01239   Args:     SHORT nLockKey
01240               The lock key previously obtained in a Lock call.
01241             SHORT nX,
01242               The X coordinate of the ink point.
01243             SHORT nY,
01244               The Y coordinate of the ink point.
01245             SHORT nInkWidth,
01246               The width of the ink in pixels.
01247             COLORREF crInkColor);
01248               The new ink color--an RGB COLORREF color.
01249
01250   Returns:  HRESULT
01251               Standard result code. NOERROR for success.
01252 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01253 STDMETHODIMP COPaper::CImpIPaper::InkStart(
01254                SHORT nLockKey,
01255                SHORT nX,
01256                SHORT nY,
01257                SHORT nInkWidth,
01258                COLORREF crInkColor)
01259 {
01260   HRESULT hr = E_FAIL;
01261
01262   if (OwnThis())
01263   {
01264     if (m_bLocked && m_cLockKey == nLockKey)
01265     {
01266       hr = NextSlot();
01267       if (SUCCEEDED(hr))
01268       {
01269         // Add the new item to the Ink Data Array.
01270         m_paInkData[m_lInkDataEnd].nType = INKTYPE_START;
01271         m_paInkData[m_lInkDataEnd].nX = nX;
01272         m_paInkData[m_lInkDataEnd].nY = nY;
01273         m_paInkData[m_lInkDataEnd].nWidth = nInkWidth;
01274         m_paInkData[m_lInkDataEnd].crColor = crInkColor;
01275         m_nInkWidth = nInkWidth;
01276         m_crInkColor = crInkColor;
01277       }
01278     }
01279
01280     UnOwnThis();
01281   }
01282
01283   return hr;
01284 }
01285
01286
01287 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01288   Method:   COPaper::CImpIPaper::InkDraw
01289
01290   Summary:  The InkDraw member method of the IPaper interface
01291             implementation. Called by outside clients of a COPaper object
01292             to "draw" ink data into an inking sequence.
01293
01294   Args:     SHORT nLockKey
01295               The lock key previously obtained in a Lock call.
01296             SHORT nX,
01297               The X coordinate of the ink point.
01298             SHORT nY,
01299               The Y coordinate of the ink point.
01300
01301   Returns:  HRESULT
01302               Standard result code. NOERROR for success.
01303 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01304 STDMETHODIMP COPaper::CImpIPaper::InkDraw(
01305                SHORT nLockKey,
01306                SHORT nX,
01307                SHORT nY)
01308 {
01309   HRESULT hr = E_FAIL;
01310
01311   if (OwnThis())
01312   {
01313     if (m_bLocked && m_cLockKey == nLockKey)
01314     {
01315       hr = NextSlot();
01316       if (SUCCEEDED(hr))
01317       {
01318         // Add the new item to the Ink Data Array.
01319         m_paInkData[m_lInkDataEnd].nType = INKTYPE_DRAW;
01320         m_paInkData[m_lInkDataEnd].nX = nX;
01321         m_paInkData[m_lInkDataEnd].nY = nY;
01322         m_paInkData[m_lInkDataEnd].nWidth = m_nInkWidth;
01323         m_paInkData[m_lInkDataEnd].crColor = m_crInkColor;
01324       }
01325     }
01326
01327     UnOwnThis();
01328   }
01329
01330   return hr;
01331 }
01332
01333
01334 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01335   Method:   COPaper::CImpIPaper::InkStop
01336
01337   Summary:  The InkStop member method of the IPaper interface
01338             implementation. Called by outside clients of a COPaper object
01339             to stop the current ink drawing sequence.
01340
01341   Args:     SHORT nLockKey
01342               The lock key previously obtained in a Lock call.
01343             SHORT nX,
01344               The X coordinate of the ink point.
01345             SHORT nY,
01346               The Y coordinate of the ink point.
01347
01348   Returns:  HRESULT
01349               Standard result code. NOERROR for success.
01350 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01351 STDMETHODIMP COPaper::CImpIPaper::InkStop(
01352                SHORT nLockKey,
01353                SHORT nX,
01354                SHORT nY)
01355 {
01356   HRESULT hr = E_FAIL;
01357
01358   if (OwnThis())
01359   {
01360     if (m_bLocked && m_cLockKey == nLockKey)
01361     {
01362       hr = NextSlot();
01363       if (SUCCEEDED(hr))
01364       {
01365         // Add the new item to the Ink Data Array.
01366         m_paInkData[m_lInkDataEnd].nType = INKTYPE_STOP;
01367         m_paInkData[m_lInkDataEnd].nX = nX;
01368         m_paInkData[m_lInkDataEnd].nY = nY;
01369         m_paInkData[m_lInkDataEnd].nWidth = m_nInkWidth;
01370         m_paInkData[m_lInkDataEnd].crColor = m_crInkColor;
01371       }
01372     }
01373
01374     UnOwnThis();
01375   }
01376
01377   return hr;
01378 }
01379
01380
01381 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01382   Method:   COPaper::CImpIPaper::Erase
01383
01384   Summary:  The Erase member method of the IPaper interface
01385             implementation. Called by outside clients of a COPaper object
01386             to erase the drawn ink content of the paper object. Notifies
01387             all connected clients of the event.
01388
01389   Args:     SHORT nLockKey
01390               The lock key previously obtained in a Lock call.
01391
01392   Returns:  HRESULT
01393               Standard result code. NOERROR for success.
01394 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01395 STDMETHODIMP COPaper::CImpIPaper::Erase(
01396                SHORT nLockKey)
01397 {
01398   HRESULT hr = E_FAIL;
01399   LONG i;
01400
01401   if (OwnThis())
01402   {
01403     if (m_bLocked && m_cLockKey == nLockKey)
01404     {
01405       if (m_lInkDataEnd > 0 && NULL != m_paInkData)
01406       {
01407         // Loop thru the current Ink Data array and mark each
01408         // item as erased.
01409         for (i=0; i<m_lInkDataMax; i++)
01410           m_paInkData[i].nType = INKTYPE_NONE;
01411
01412         // Reset the Ink Data End index to 0.
01413         m_lInkDataEnd = 0;
01414         hr = NOERROR;
01415       }
01416     }
01417
01418     UnOwnThis();
01419   }
01420
01421   // Notify all other connected clients of the erase.
01422   if (SUCCEEDED(hr))
01423     m_pBackObj->NotifySinks(PAPER_EVENT_ERASED, 0, 0, 0, 0);
01424
01425   return hr;
01426 }
01427
01428
01429 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01430   Method:   COPaper::CImpIPaper::Resize
01431
01432   Summary:  The Resize member method of the IPaper interface
01433             implementation. Called by outside clients of a COPaper object
01434             to resize the drawing rectangle of the paper object. Notifies
01435             all connected clients of the event and passes them the new
01436             rectangle size.
01437
01438   Args:     SHORT nLockKey
01439               The lock key previously obtained in a Lock call.
01440             SHORT nWidth,
01441               The new rectangle width in pixels.
01442             SHORT nHeight
01443               The new rectangle height in pixels.
01444
01445   Returns:  HRESULT
01446               Standard result code. NOERROR for success.
01447 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01448 STDMETHODIMP COPaper::CImpIPaper::Resize(
01449                SHORT nLockKey,
01450                SHORT nWidth,
01451                SHORT nHeight)
01452 {
01453   HRESULT hr = E_FAIL;
01454
01455   if (OwnThis())
01456   {
01457     if (m_bLocked && m_cLockKey == nLockKey)
01458     {
01459       m_WinRect.top = 0;
01460       m_WinRect.left = 0;
01461       m_WinRect.right = nWidth;
01462       m_WinRect.bottom = nHeight;
01463       hr = NOERROR;
01464     }
01465
01466     UnOwnThis();
01467   }
01468
01469   // Notify all other connected clients of the resize.
01470   if (SUCCEEDED(hr))
01471     m_pBackObj->NotifySinks(
01472                   PAPER_EVENT_RESIZED,
01473                   nWidth,
01474                   nHeight,
01475                   0,
01476                   0);
01477
01478   return hr;
01479 }
01480
01481
01482 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
01483   Method:   COPaper::CImpIPaper::Redraw
01484
01485   Summary:  The Redraw member method of the IPaper interface
01486             implementation. Called by outside clients of a COPaper object
01487             to resend all of the paper object's current ink data to all
01488             connected clients for a redraw of the content in each.
01489
01490   Args:     SHORT nLockKey
01491               The lock key previously obtained in a Lock call.
01492
01493   Returns:  HRESULT
01494               Standard result code. NOERROR for success.
01495 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
01496 STDMETHODIMP COPaper::CImpIPaper::Redraw(
01497                SHORT nLockKey)
01498 {
01499   HRESULT hr = E_FAIL;
01500   IConnectionPoint* pIConnectionPoint;
01501   IEnumConnections* pIEnum;
01502   CONNECTDATA ConnData;
01503   SHORT nInkType;
01504   LONG i;
01505
01506   if (OwnThis())
01507   {
01508     if (m_bLocked && m_cLockKey == nLockKey)
01509     {
01510       // Broadcast InkData notifications to all Sinks connected to
01511       // each connection point.
01512
01513       // Here is the section for the PaperSink connection point--currently
01514       // this is the only connection point offered by COPaper objects.
01515       pIConnectionPoint = m_pBackObj->m_aConnectionPoints[CONNPOINT_PAPERSINK];
01516       if (NULL != pIConnectionPoint)
01517       {
01518         pIConnectionPoint->AddRef();
01519         hr = pIConnectionPoint->EnumConnections(&pIEnum);
01520         if (SUCCEEDED(hr))
01521         {
01522           // Loop thru the connection point's connections and if the
01523           // listening connection supports IPaperSink (ie, PaperSink
01524           // events) then send all the current Paper's Ink Data to it.
01525           while (NOERROR == pIEnum->Next(1, &ConnData, NULL))
01526           {
01527             IPaperSink* pIPaperSink = NULL;
01528
01529             hr = ConnData.pUnk->QueryInterface(
01530                                   IID_IPaperSink,
01531                                   (PPVOID)&pIPaperSink);
01532             if (SUCCEEDED(hr))
01533             {
01534               // Loop thru all the Ink Data and send it to this connected
01535               // client sink.
01536               for (i=0; i<m_lInkDataEnd+1; i++)
01537               {
01538                 nInkType = m_paInkData[i].nType;
01539                 switch (nInkType)
01540                 {
01541                   case INKTYPE_START:
01542                     pIPaperSink->InkStart(
01543                                    m_paInkData[i].nX,
01544                                    m_paInkData[i].nY,
01545                                    m_paInkData[i].nWidth,
01546                                    m_paInkData[i].crColor);
01547                     break;
01548                   case INKTYPE_DRAW:
01549                     pIPaperSink->InkDraw(
01550                                    m_paInkData[i].nX,
01551                                    m_paInkData[i].nY);
01552                     break;
01553                   case INKTYPE_STOP:
01554                     pIPaperSink->InkStop(
01555                                    m_paInkData[i].nX,
01556                                    m_paInkData[i].nY);
01557                     break;
01558                   default:
01559                     break;
01560                 }
01561               }
01562               pIPaperSink->Release();
01563             }
01564             ConnData.pUnk->Release();
01565           }
01566           pIEnum->Release();
01567         }
01568         pIConnectionPoint->Release();
01569       }
01570     }
01571
01572     UnOwnThis();
01573   }
01574
01575   return hr;
01576 }
Generated on Wed Nov 13 2024 16:51:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/sendto/sendto.h Source File

  • WinUI
  • sendto

sendto.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  *  SendTo.h
00004  *
00005  *  Copyright (c) 1997 Microsoft Corporation.  All rights reserved.
00006  *
00007  *       This source code is only intended as a supplement to
00008  *       Microsoft Development Tools, q.v. for detailed
00009  *       information regarding the Microsoft samples programs.
00010  *
00011  *  Abstract:
00012  *
00013  *      Common header file for the Send To sample.
00014  *
00015  *****************************************************************************/
00016
00017 #define STRICT
00018 #define _WIN32_WINDOWS 0x0400
00019 #include <windows.h>
00020 #ifndef RC_INVOKED
00021 #include <windowsx.h>
00022 #include <shlobj.h>
00023 #include <commdlg.h>
00024 #endif
00025
00026 #define IDM_OPEN                0x0100
00027 #define IDM_SENDTOPOPUP         0x0101
00028
00029 #define IDM_SENDTOFIRST         0x0200
00030 #define IDM_SENDTOLAST          0x02FF
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CStatusBarLite Member List

This is the complete list of members for CStatusBarLite, including all inherited members.
CheckDlgButton(INT iResourceID, UINT uCheck) | CWndLite | [inline]
Create(HWND hWndParent, UINT nID, WCHAR *pwszText=L"", DWORD dwStyle=WS_CHILD|WS_VISIBLE) | CStatusBarLite | [virtual]
CWndLite::Create(HWND hWndParent, WCHAR *pwszClassName, WCHAR *pwszWindowName, UINT uID, DWORD dwStyle=WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|WS_HSCROLL, DWORD dwExStyle=WS_EX_CLIENTEDGE, int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWndLite | [virtual]
CreateIndirect(HWND hWndParent, UINT nID=0) | CWndLite | [virtual]
CStatusBarLite() | CStatusBarLite |
CWndLite(HWND hWndParent=NULL, UINT nID=0) | CWndLite |
DestroyWindow() | CWndLite | [virtual]
EnableWindow(BOOL bEnable=TRUE) | CWndLite | [inline]
GetDlgItem(INT iResourceID) | CWndLite | [inline]
GetFont() | CWndLite | [inline]
GetWindowPlacement() | CWndLite | [inline]
GetWindowText() | CWndLite | [inline]
GetWindowText(WCHAR *pwszBuffer, ULONG ulMaxSize) | CWndLite | [inline]
GetWnd() | CWndLite | [inline]
HandleMenuPos(HMENU hMenu, UINT uPos, DWORD *pdwFlags) | CWndLite | [virtual]
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
IsDestroyed() | CWndLite | [inline, virtual]
IsDlgButtonChecked(INT iResourceID) | CWndLite | [inline]
IsVisible() | CWndLite | [inline]
m_bUnicodeMsg | CWndLite |
m_hWnd | CWndLite |
m_hWndParent | CWndLite |
m_nID | CWndLite |
m_pSubClassProc | CWndLite |
m_pwszClassName | CWndLite |
m_wndPlacement | CWndLite |
OnActivate(UINT fActive, UINT fMinimized, HWND hWndPrevious) | CWndLite | [virtual]
OnChar(TCHAR chCharCode, LPARAM lKeyData) | CWndLite | [virtual]
OnClose() | CWndLite | [virtual]
OnCommand(UINT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnCommandNotify(INT wNotifyCode, INT iID, HWND hWndCtrl) | CWndLite | [virtual]
OnContextMenu(HWND hWnd, REFPOINTS pts) | CWndLite | [virtual]
OnCreate(CREATESTRUCT *pCREATESTRUCT) | CWndLite | [virtual]
OnDblclk(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnDestroy() | CWndLite | [virtual]
OnDropFiles(HDROP hDrop) | CWndLite | [virtual]
OnHScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
OnInitialUpdate() | CWndLite | [virtual]
OnInitMenuPopup(HMENU hMenu, UINT uPos, BOOL fSysMenu) | CWndLite | [virtual]
OnKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnLButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnLButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnMenuSelect(UINT uID) | CWndLite | [virtual]
OnMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnMove(REFPOINTS pts) | CWndLite | [virtual]
OnNCButtonDown(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNCMouseMove(WPARAM nHittest, REFPOINTS pts) | CWndLite | [virtual]
OnNotify(INT idCtrl, NMHDR *pNMHDR) | CWndLite | [virtual]
OnRButtonDown(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnRButtonUp(WPARAM fwKeys, REFPOINTS pts) | CWndLite | [virtual]
OnSetCursor(HWND hWnd, INT nHittest, INT nMouseMsg) | CWndLite | [virtual]
OnSetFocus(HWND hWndPrevFocus) | CWndLite | [virtual]
OnSize(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSizing(WPARAM nType, REFPOINTS pts) | CWndLite | [virtual]
OnSysCommand(WPARAM nCmdType, REFPOINTS pts) | CWndLite | [virtual]
OnSysKeyDown(WPARAM nVirtKey, LPARAM lKeyData) | CWndLite | [virtual]
OnTimer(WPARAM nIDEvent) | CWndLite | [virtual]
OnUpdateCommand(HMENU hMenu, UINT nID, DWORD *pdwFlags) | CWndLite | [virtual]
OnVScroll(int nScrollCode, int nPos, HWND hWnd) | CWndLite | [virtual]
PreCreateWindow(CREATESTRUCTW &cs) | CWndLite | [virtual]
SetFocus() | CWndLite | [inline]
SetFont(HFONT hFont) | CWndLite | [inline]
SetParts(int nParts, int *pWidths) | CStatusBarLite | [inline, virtual]
SetText(WCHAR *pwszText, int nPane, int nType) | CStatusBarLite | [inline, virtual]
SetWindowPlacement() | CWndLite | [inline]
SetWindowText(WCHAR *pwszString) | CWndLite | [inline]
ShowWindow(UINT nCmdShow) | CWndLite | [inline]
SubClassWindow(WNDPROC pWndProc) | CWndLite | [virtual]
UnhandledMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [virtual]
UpdateWindow() | CWndLite | [inline]
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CWndLite | [static]
~CStatusBarLite() | CStatusBarLite | [virtual]
~CWndLite() | CWndLite | [virtual]
Generated on Wed Nov 13 2024 16:57:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_tagSHOWERRORCOMPLETEDMSG Member List

This is the complete list of members for _tagSHOWERRORCOMPLETEDMSG, including all inherited members.
cbNumItems | _tagSHOWERRORCOMPLETEDMSG
hr | _tagSHOWERRORCOMPLETEDMSG
pItemIDs | _tagSHOWERRORCOMPLETEDMSG
Generated on Wed Nov 13 2024 16:55:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/ADO/ADOVCGEN/advcgendlg.h Source File

  • Dataaccess
  • ADO
  • ADOVCGEN

advcgendlg.h

Go to the documentation of this file.
00001 // ADVCGENDlg.h : header file
00002 //
00003 //{{AFX_INCLUDES()
00004 #include "ADOHeader.h"
00005 #include "datagrid.h"
00006 //}}AFX_INCLUDES
00007
00008 #if !defined(AFX_ADVCGENDLG_H__202C1C4E_0C5C_4307_8CD3_FDDD43571792__INCLUDED_)
00009 #define AFX_ADVCGENDLG_H__202C1C4E_0C5C_4307_8CD3_FDDD43571792__INCLUDED_
00010
00011 #if _MSC_VER > 1000
00012 #pragma once
00013 #endif // _MSC_VER > 1000
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CADVCGENDlg dialog
00017
00018 class CADVCGENDlg : public CDialog
00019 {
00020 // Construction
00021 public:
00022   void DataRefresh(BOOL bflag);
00023   // ADO specific variables
00024   _bstr_t connStr;
00025   ado20::_ConnectionPtr conn;
00026   ado20::_RecordsetPtr    dataRs;  // Data Recordset Object
00027   ado20::_RecordsetPtr    schemaRs;
00028   HRESULT hr;
00029
00030   // ADO specific functions
00031   void RestrictionsOnOpenSchema(_variant_t &restrictions,int lenCtr, _variant_t *criteriaValues);
00032   _bstr_t VarToBstr(_variant_t varT);
00033   void OutputIntoDataGrid(char *buffer);
00034
00035   CADVCGENDlg(CWnd* pParent = NULL);  // standard constructor
00036   ~CADVCGENDlg(); // standard Destructor
00037
00038 // Dialog Data
00039   //{{AFX_DATA(CADVCGENDlg)
00040   enum { IDD = IDD_ADVCGEN_DIALOG };
00041   CDataGrid m_DataGridDisplay;
00042   CListBox  m_TableListBox;
00043   CButton m_SchemaInfo;
00044   CEdit  m_SQLEditBox;
00045   //}}AFX_DATA
00046
00047   // ClassWizard generated virtual function overrides
00048   //{{AFX_VIRTUAL(CADVCGENDlg)
00049   protected:
00050   virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support
00051   //}}AFX_VIRTUAL
00052
00053 // Implementation
00054 protected:
00055   HICON m_hIcon;
00056
00057   // Generated message map functions
00058   //{{AFX_MSG(CADVCGENDlg)
00059   virtual BOOL OnInitDialog();
00060   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
00061   afx_msg void OnPaint();
00062   afx_msg HCURSOR OnQueryDragIcon();
00063   afx_msg void OnXecute();
00064   afx_msg void OnBuild();
00065   afx_msg void OnExit();
00066   afx_msg void OnChangeTableList();
00067   //}}AFX_MSG
00068   DECLARE_MESSAGE_MAP()
00069 };
00070
00071 //{{AFX_INSERT_LOCATION}}
00072 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00073
00074 #endif // !defined(AFX_ADVCGENDLG_H__202C1C4E_0C5C_4307_8CD3_FDDD43571792__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userproppage/util.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userproppage

util.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       util.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 #ifndef _UTIL_H
00012 #define _UTIL_H
00013
00014 #define BYTE_OFFSET(base, offset) (((LPBYTE)base)+offset)
00015
00016 HRESULT SetStringAttribute(IADs* pIADs, LPCWSTR lpszAttr, LPCWSTR lpszVal, BOOL bPostCommit=FALSE);
00017 HRESULT GetStringAttribute(IADs* pIADs, LPCWSTR lpszAttr, CString& szVal);
00018
00019
00020
00021 HRESULT SetByteArrayAsOctetString(IADs* pIADs, LPCWSTR lpszAttr, BYTE* pByteArray, DWORD dwSize);
00022
00023 BOOL LoadFileAsByteArray(PWSTR pszPath, LPBYTE* ppByteArray, DWORD* pdwSize);
00024
00025
00026 ///////////////////////////////////////////////////////////////
00027 // CThumbNailPhotoHolder
00028
00029 class CThumbNailPhotoHolder
00030 {
00031 public:
00032   CThumbNailPhotoHolder()
00033   {
00034     m_hWndFileNameEdit = NULL;
00035     m_hWndPictureControl = NULL;
00036
00037     m_pPictureArray = NULL;
00038     m_dwPictureSize = 0x0;
00039   }
00040   ~CThumbNailPhotoHolder()
00041   {
00042     _Clear();
00043   }
00044
00045   // public interface
00046   void Initialize(HWND hWndFileNameEdit, HWND hWndPictureControl)
00047   {
00048     ASSERT(::IsWindow(hWndFileNameEdit));
00049     ASSERT(::IsWindow(hWndPictureControl));
00050
00051     m_hWndFileNameEdit = hWndFileNameEdit;
00052     m_hWndPictureControl = hWndPictureControl;
00053   }
00054
00055   HRESULT Read(IADs* pIADs);
00056   HRESULT Write(IADs* pIADs);
00057
00058   HRESULT Read(IDirectoryObject* pDirObj);
00059   HRESULT Write(IDirectoryObject* pDirObj);
00060
00061   BOOL Change(HWND hWndOwner);
00062   BOOL Clear();
00063
00064
00065 private:
00066
00067   // helper functions
00068   void _Clear()
00069   {
00070     if (m_pPictureArray != NULL)
00071     {
00072       ASSERT(m_dwPictureSize != NULL);
00073       delete m_pPictureArray;
00074       m_pPictureArray = NULL;
00075       m_dwPictureSize = 0x0;
00076     }
00077   }
00078   void _SetPictureControl(HBITMAP hBitmap)
00079   {
00080     ::SendMessage(m_hWndPictureControl, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBitmap);
00081     if (hBitmap != NULL)
00082       return;
00083     ::ShowWindow(m_hWndPictureControl, FALSE);
00084     ::ShowWindow(m_hWndPictureControl, TRUE);
00085   }
00086
00087   BOOL _DisplayPicture(LPCWSTR lpszPath);
00088
00089   void _WriteHelper(HRESULT hr);
00090
00091   // member variables
00092   HWND m_hWndFileNameEdit;
00093   HWND m_hWndPictureControl;
00094
00095   BYTE*                     m_pPictureArray;
00096   DWORD                     m_dwPictureSize;
00097 };
00098
00099
00100
00101
00102
00103 #endif // _UTIL_H
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Audio/MidiPlyr/SEQ.h Source File

  • Multimedia
  • Audio
  • MidiPlyr

SEQ.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *
00003 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 *  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
00006 *  A PARTICULAR PURPOSE.
00007 *
00008 *  Copyright 1993 - 2000 Microsoft Corporation. All Rights Reserved.
00009 *
00010 ******************************************************************************
00011 *
00012 * Seq.H
00013 *
00014 * Public include file for sequencer interface.
00015 *
00016 *****************************************************************************/
00017
00018 #ifndef _SEQ_
00019 #define _SEQ_
00020
00021 #include "global.h"
00022 #include "smf.h"
00023
00024 #define  VERSION_MINOR              0x00
00025 #define  VERSION_MAJOR              0x04
00026 #define  SEQ_VERSION                ((DWORD)(WORD)((BYTE)VERSION_MINOR | (((WORD)(BYTE)VERSION_MAJOR) << 8)))
00027
00028 #define SEQ_F_EOF           0x00000001L
00029 #define SEQ_F_COLONIZED     0x00000002L
00030 #define SEQ_F_WAITING       0x00000004L
00031
00032 #define SEQ_S_NOFILE        0
00033 #define SEQ_S_OPENED        1
00034 #define SEQ_S_PREROLLING    2
00035 #define SEQ_S_PREROLLED     3
00036 #define SEQ_S_PLAYING       4
00037 #define SEQ_S_PAUSED        5
00038 #define SEQ_S_STOPPING      6
00039 #define SEQ_S_RESET         7
00040
00041 #define MMSG_DONE                   (WM_USER+20)
00042
00043 typedef struct tag_preroll
00044 {
00045     TICKS       tkBase;
00046     TICKS       tkEnd;
00047 }   PREROLL,
00048     FAR *LPPREROLL;
00049
00050 typedef struct tag_seq NEAR* PSEQ;
00051 typedef struct tag_seq
00052 {
00053     DWORD       cBuffer;            /* Number of streaming buffers to alloc         */
00054     DWORD       cbBuffer;           /* Size of each streaming buffer                */
00055     LPSTR       pstrFile;           /* Pointer to filename to open                  */
00056     UINT        uDeviceID;          /* Requested MIDI device ID for MMSYSTEM        */
00057     UINT        uMCIDeviceID;       /* Our MCI device ID given to us                */
00058     UINT        uMCITimeFormat;     /* Current time format                          */
00059     UINT        uMCITimeDiv;        /* MCI_SEQ_DIV_xxx for current file             */
00060   HWND    hWnd;       /* Where to post MMSG_DONE when done playing  */
00061
00062     UINT        uState;             /* Sequencer state (SEQ_S_xxx)                  */
00063     TICKS       tkLength;           /* Length of longest track                      */
00064     DWORD       cTrk;               /* Number of tracks                             */
00065     MMRESULT    mmrcLastErr;        /* Error return from last sequencer operation   */
00066
00067     PSEQ        pNext;              /* Link to next PSEQ                            */
00068     HSMF        hSmf;               /* Handle to open file                          */
00069     HMIDIOUT    hmidi;              /* Handle to open MIDI device                   */
00070     DWORD       dwTimeDivision;     /* File time division                           */
00071
00072     LPBYTE      lpbAlloc;           /* Streaming buffers -- initial allocation      */
00073     LPMIDIHDR   lpmhFree;           /* Streaming buffers -- free list               */
00074     LPMIDIHDR   lpmhPreroll;        /* Streaming buffers -- preroll buffer          */
00075     DWORD       cbPreroll;          /* Streaming buffers -- size of lpmhPreroll     */
00076     UINT        uBuffersInMMSYSTEM; /* Streaming buffers -- in use                  */
00077
00078     TICKS       tkBase;             /* Where playback started from in stream        */
00079     TICKS       tkEnd;              /* Where playback should end                    */
00080
00081     DWORD       fdwSeq;             /* Various sequencer flags                      */
00082
00083 }   SEQ,
00084     NEAR *PSEQ;
00085
00086 /* sequence.c
00087 */
00088
00089 MMRESULT FNLOCAL seqAllocBuffers(
00090     PSEQ                pseq);
00091
00092 VOID FNLOCAL seqFreeBuffers(
00093     PSEQ                pseq);
00094
00095 MMRESULT FNLOCAL seqOpenFile(
00096     PSEQ                pseq);
00097
00098 MMRESULT FNLOCAL seqCloseFile(
00099     PSEQ                pseq);
00100
00101 MMRESULT FNLOCAL seqPreroll(
00102     PSEQ                pseq,
00103     LPPREROLL           lppreroll);
00104
00105 MMRESULT FNLOCAL seqStart(
00106     PSEQ                pseq);
00107
00108 MMRESULT FNLOCAL seqPause(
00109     PSEQ                pseq);
00110
00111 MMRESULT FNLOCAL seqRestart(
00112     PSEQ                pseq);
00113
00114 MMRESULT FNLOCAL seqStop(
00115     PSEQ                pseq);
00116
00117 MMRESULT FNLOCAL seqTime(
00118     PSEQ                pseq,
00119     PTICKS              pTicks);
00120
00121 TICKS FNLOCAL seqMillisecsToTicks(
00122     PSEQ                pseq,
00123     DWORD               msOffset);
00124
00125 DWORD FNLOCAL seqTicksToMillisecs(
00126     PSEQ                pseq,
00127     TICKS               tkOffset);
00128
00129 #endif
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_PER_SOCKET_CONTEXT Member List

This is the complete list of members for _PER_SOCKET_CONTEXT, including all inherited members.
fnAcceptEx | _PER_SOCKET_CONTEXT
pCtxtBack | _PER_SOCKET_CONTEXT
pCtxtForward | _PER_SOCKET_CONTEXT
pIOContext | _PER_SOCKET_CONTEXT
Socket | _PER_SOCKET_CONTEXT
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CWindow Member List

This is the complete list of members for CWindow, including all inherited members.
_hwnd | CWindow | [protected]
CWindow() | CWindow | [inline]
CWindow(LPTSTR caption, LPTSTR lpszClassName, HINSTANCE hInstance, int cx=CW_USEDEFAULT, int cy=CW_USEDEFAULT) | CWindow | [inline]
operator HWND() | CWindow | [inline]
Show(int nCmdShow) | CWindow | [inline]
Generated on Wed Nov 13 2024 16:57:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/iocp/IocpServer.h Source File

  • NetDS
  • WinSock
  • iocp

IocpServer.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1998 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      iocpserver.h
00010 //
00011
00012 #ifndef IOCPSERVER_H
00013 #define IOCPSERVER_H
00014
00015 #include <mswsock.h>
00016
00017 #define DEFAULT_PORT        "5001"
00018 #define MAX_BUFF_SIZE       8192
00019 #define MAX_WORKER_THREAD   16
00020
00021 typedef enum _IO_OPERATION {
00022     ClientIoAccept,
00023     ClientIoRead,
00024     ClientIoWrite
00025 } IO_OPERATION, *PIO_OPERATION;
00026
00027 //
00028 // data to be associated for every I/O operation on a socket
00029 //
00030 typedef struct _PER_IO_CONTEXT {
00031     WSAOVERLAPPED               Overlapped;
00032     char                        Buffer[MAX_BUFF_SIZE];
00033     WSABUF                      wsabuf;
00034     int                         nTotalBytes;
00035     int                         nSentBytes;
00036     IO_OPERATION                IOOperation;
00037     SOCKET                      SocketAccept;
00038
00039     struct _PER_IO_CONTEXT      *pIOContextForward;
00040 } PER_IO_CONTEXT, *PPER_IO_CONTEXT;
00041
00042 //
00043 // For AcceptEx, the IOCP key is the PER_SOCKET_CONTEXT for the listening socket,
00044 // so we need to another field SocketAccept in PER_IO_CONTEXT. When the outstanding
00045 // AcceptEx completes, this field is our connection socket handle.
00046 //
00047
00048 //
00049 // data to be associated with every socket added to the IOCP
00050 //
00051 typedef struct _PER_SOCKET_CONTEXT {
00052     SOCKET                      Socket;
00053
00054     LPFN_ACCEPTEX               fnAcceptEx;
00055
00056   //
00057     //linked list for all outstanding i/o on the socket
00058   //
00059     PPER_IO_CONTEXT             pIOContext;
00060     struct _PER_SOCKET_CONTEXT  *pCtxtBack;
00061     struct _PER_SOCKET_CONTEXT  *pCtxtForward;
00062 } PER_SOCKET_CONTEXT, *PPER_SOCKET_CONTEXT;
00063
00064 BOOL ValidOptions(int argc, char *argv[]);
00065
00066 BOOL WINAPI CtrlHandler(
00067     DWORD dwEvent
00068     );
00069
00070 BOOL CreateListenSocket(void);
00071
00072 BOOL CreateAcceptSocket(
00073     BOOL fUpdateIOCP
00074     );
00075
00076 DWORD WINAPI WorkerThread (
00077     LPVOID WorkContext
00078     );
00079
00080 PPER_SOCKET_CONTEXT UpdateCompletionPort(
00081     SOCKET s,
00082     IO_OPERATION ClientIo,
00083     BOOL bAddToList
00084     );
00085 //
00086 // bAddToList is FALSE for listening socket, and TRUE for connection sockets.
00087 // As we maintain the context for listening socket in a global structure, we
00088 // don't need to add it to the list.
00089 //
00090
00091 VOID CloseClient (
00092     PPER_SOCKET_CONTEXT lpPerSocketContext,
00093     BOOL bGraceful
00094     );
00095
00096 PPER_SOCKET_CONTEXT CtxtAllocate(
00097     SOCKET s,
00098     IO_OPERATION ClientIO
00099     );
00100
00101 VOID CtxtListFree(
00102     );
00103
00104 VOID CtxtListAddTo (
00105     PPER_SOCKET_CONTEXT lpPerSocketContext
00106     );
00107
00108 VOID CtxtListDeleteFrom(
00109     PPER_SOCKET_CONTEXT lpPerSocketContext
00110     );
00111
00112 #endif
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/VCAcct/Resource.h Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • VCAcct

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by Account.rc
00004 //
00005 #define IDS_ACCOUNT_DESC                1
00006 #define IDR_Account                     1
00007 #define IDS_MOVEMONEY_DESC              2
00008 #define IDR_MoveMoney                   2
00009 #define IDS_UPDATERECEIPT_DESC          114
00010 #define IDR_UpdateReceipt               115
00011 #define IDS_GETRECEIPT_DESC             116
00012 #define IDR_GetReceipt                  117
00013 #define IDS_UPDATERECEIPT_DESC1         118
00014 #define IDR_UpdateReceipt1              119
00015
00016 // Next default values for new objects
00017 //
00018 #ifdef APSTUDIO_INVOKED
00019 #ifndef APSTUDIO_READONLY_SYMBOLS
00020 #define _APS_NEXT_RESOURCE_VALUE        201
00021 #define _APS_NEXT_COMMAND_VALUE         32768
00022 #define _APS_NEXT_CONTROL_VALUE         201
00023 #define _APS_NEXT_SYMED_VALUE           120
00024 #endif
00025 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/dataobj.Cpp Source File

  • SysMgmt
  • MMC
  • WMI

dataobj.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include "DataObj.h"
00020 #include "guids.h"
00021 #include "DeleBase.h"
00022
00023 //
00024 // This is the minimum set of clipboard formats we must implement.
00025 // MMC uses these to get necessary information from our snapin about
00026 // our nodes.
00027 //
00028
00029 // we need to do this to get around MMC.IDL - it explicitly defines
00030 // the clipboard formats as WCHAR types...
00031 #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
00032 #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
00033 #define _T_CCF_SZNODETYPE _T("CCF_SZNODETYPE")
00034 #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
00035
00036 #define _T_CCF_INTERNAL_SNAPIN _T("{2479DB32-5276-11d2-94F5-00C04FB92EC2}")
00037
00038     // These are the clipboard formats that we must supply at a minimum.
00039     // mmc.h actually defined these. We can make up our own to use for
00040     // other reasons. We don't need any others at this time.
00041 UINT CDataObject::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
00042 UINT CDataObject::s_cfNodeType    = RegisterClipboardFormat(_T_CCF_NODETYPE);
00043 UINT CDataObject::s_cfSZNodeType  = RegisterClipboardFormat(_T_CCF_SZNODETYPE);
00044 UINT CDataObject::s_cfSnapinClsid = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
00045 UINT CDataObject::s_cfInternal    = RegisterClipboardFormat(_T_CCF_INTERNAL_SNAPIN);
00046
00047
00048 CDataObject::CDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES context)
00049 : m_lCookie(cookie), m_context(context), m_cref(0)
00050 {
00051 }
00052
00053 CDataObject::~CDataObject()
00054 {
00055 }
00056
00057 ///////////////////////
00058 // IUnknown implementation
00059 ///////////////////////
00060
00061 STDMETHODIMP CDataObject::QueryInterface(REFIID riid, LPVOID *ppv)
00062 {
00063     if (!ppv)
00064         return E_FAIL;
00065
00066     *ppv = NULL;
00067
00068     if (IsEqualIID(riid, IID_IUnknown))
00069         *ppv = static_cast<IDataObject *>(this);
00070     else if (IsEqualIID(riid, IID_IDataObject))
00071         *ppv = static_cast<IDataObject *>(this);
00072
00073     if (*ppv)
00074     {
00075         reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00076         return S_OK;
00077     }
00078
00079     return E_NOINTERFACE;
00080 }
00081
00082 STDMETHODIMP_(ULONG) CDataObject::AddRef()
00083 {
00084     return InterlockedIncrement((LONG *)&m_cref);
00085 }
00086
00087 STDMETHODIMP_(ULONG) CDataObject::Release()
00088 {
00089     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00090     {
00091         delete this;
00092         return 0;
00093     }
00094     return m_cref;
00095
00096 }
00097
00098 /////////////////////////////////////////////////////////////////////////////
00099 // IDataObject implementation
00100 //
00101 HRESULT CDataObject::GetDataHere(
00102                                  FORMATETC *pFormatEtc,     // [in]  Pointer to the FORMATETC structure
00103                                  STGMEDIUM *pMedium         // [out] Pointer to the STGMEDIUM structure
00104                                  )
00105 {
00106     const   CLIPFORMAT cf = pFormatEtc->cfFormat;
00107     IStream *pStream = NULL;
00108
00109     CDelegationBase *base = GetBaseNodeObject();
00110
00111     HRESULT hr = CreateStreamOnHGlobal( pMedium->hGlobal, FALSE, &pStream );
00112     if ( FAILED(hr) )
00113         return hr;                       // Minimal error checking
00114
00115     hr = DV_E_FORMATETC;                 // Unknown format
00116
00117     if (cf == s_cfDisplayName) {
00118         const _TCHAR *pszName = base->GetDisplayName();
00119
00120                 MAKE_WIDEPTR_FROMTSTR(wszName, pszName);
00121
00122                 // get length of original string and convert it accordingly
00123         ULONG ulSizeofName = lstrlen(pszName);
00124         ulSizeofName++;                      // Count null character
00125         ulSizeofName *= sizeof(WCHAR);
00126
00127         hr = pStream->Write(wszName, ulSizeofName, NULL);
00128     } else if (cf == s_cfNodeType) {
00129         const GUID *pGUID = (const GUID *)&base->getNodeType();
00130
00131         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00132     } else if (cf == s_cfSZNodeType) {
00133         LPOLESTR szGuid;
00134         hr = StringFromCLSID(base->getNodeType(), &szGuid);
00135
00136         if (SUCCEEDED(hr)) {
00137             hr = pStream->Write(szGuid, wcslen(szGuid), NULL);
00138             CoTaskMemFree(szGuid);
00139         }
00140     } else if (cf == s_cfSnapinClsid) {
00141         const GUID *pGUID = NULL;
00142         pGUID = &CLSID_CComponentData;
00143
00144         hr = pStream->Write(pGUID, sizeof(GUID), NULL);
00145     } else if (cf == s_cfInternal) {
00146         // we are being asked to get our this pointer from the IDataObject interface
00147         // only our own snap-in objects will know how to do this.
00148         CDataObject *pThis = this;
00149         hr = pStream->Write( &pThis, sizeof(CDataObject*), NULL );
00150     }
00151
00152     pStream->Release();
00153
00154     return hr;
00155 }
00156
00157 /////////////////////////////////////////////////////////////////////////////
00158 // Global helper functions to help work with dataobjects and
00159 // clipboard formats
00160
00161
00162 //---------------------------------------------------------------------------
00163 //  Returns the current object based on the s_cfInternal clipboard format
00164 //
00165 CDataObject* GetOurDataObject (
00166                                LPDATAOBJECT lpDataObject      // [in] IComponent pointer
00167                                )
00168 {
00169     HRESULT       hr      = S_OK;
00170     CDataObject *pSDO     = NULL;
00171
00172   // check to see if the data object is a special data object.
00173   if ( IS_SPECIAL_DATAOBJECT (lpDataObject) )
00174   {
00175     //Code for handling a special data object goes here.
00176
00177     //Note that the MMC SDK samples do not handle
00178     //special data objects, so we exit if we get one.
00179     return NULL;
00180   }
00181
00182     STGMEDIUM stgmedium = { TYMED_HGLOBAL,  NULL  };
00183     FORMATETC formatetc = { CDataObject::s_cfInternal, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
00184
00185     // Allocate memory for the stream
00186     stgmedium.hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(CDataObject *));
00187
00188     if (!stgmedium.hGlobal)     {
00189         hr = E_OUTOFMEMORY;
00190     }
00191
00192     if SUCCEEDED(hr)
00193         // Attempt to get data from the object
00194         hr = lpDataObject->GetDataHere( &formatetc, &stgmedium );
00195
00196     // stgmedium now has the data we need
00197     if (SUCCEEDED(hr))  {
00198         pSDO = *(CDataObject **)(stgmedium.hGlobal);
00199     }
00200
00201     // if we have memory free it
00202     if (stgmedium.hGlobal)
00203         GlobalFree(stgmedium.hGlobal);
00204
00205     return pSDO;
00206
00207 } // end GetOurDataObject()
00208
Generated on Wed Nov 13 2024 16:51:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows.Net/request.cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows.Net

request.cpp

Go to the documentation of this file.
00001 //+--------------------------------------------------------------------------
00002 //
00003 // Microsoft Windows
00004 // Copyright (C) Microsoft Corporation, 1996 - 2000
00005 //
00006 // File:        request.cpp
00007 //
00008 // Contents:    Cert Server Policy Module implementation
00009 //
00010 //---------------------------------------------------------------------------
00011
00012 #include "pch.cpp"
00013 #pragma hdrstop
00014
00015 #include <assert.h>
00016 #include "celib.h"
00017 #include "policy.h"
00018 #include "module.h"
00019
00020
00021 HRESULT
00022 ReqInitialize(
00023     IN ICertServerPolicy *pServer)
00024 {
00025     HRESULT hr;
00026
00027     hr = S_OK;
00028
00029     return(hr);
00030 }
00031
00032
00033 VOID
00034 ReqCleanup()
00035 {
00036 }
00037
00038
00039 CRequestInstance::~CRequestInstance()
00040 {
00041     _Cleanup();
00042 }
00043
00044
00045 VOID
00046 CRequestInstance::_Cleanup()
00047 {
00048     if (NULL != m_strTemplateName)
00049     {
00050         SysFreeString(m_strTemplateName);
00051         m_strTemplateName = NULL;
00052     }
00053     if (NULL != m_strTemplateObjId)
00054     {
00055         SysFreeString(m_strTemplateObjId);
00056         m_strTemplateObjId = NULL;
00057     }
00058 }
00059
00060
00061
00062
00063 static WCHAR const *s_apwszCATypes[] =
00064 {
00065     wszCERTTYPE_SUBORDINATE_CA,
00066     wszCERTTYPE_CROSS_CA,
00067 };
00068
00069 //+--------------------------------------------------------------------------
00070 // CRequestInstance::Initialize
00071 //
00072 // Returns S_OK on success.
00073 //+--------------------------------------------------------------------------
00074
00075 HRESULT
00076 CRequestInstance::Initialize(
00077     IN CCertPolicySample *pPolicy,
00078     IN ICertServerPolicy *pServer,
00079     OUT BOOL *pfEnableEnrolleeExtensions)
00080 {
00081     HRESULT hr;
00082     HRESULT hrTemplate = S_OK;
00083     CERT_TEMPLATE_EXT *pTemplate = NULL;
00084     CERT_NAME_VALUE *pName = NULL;
00085     BSTR strTemplateObjId = NULL; // from V2 template extension
00086     BSTR strTemplateName = NULL;  // from V1 template extension
00087     BSTR strTemplateRA = NULL;    // from request attributes
00088     WCHAR const *pwszTemplateName;
00089     WCHAR const *pwszTemplateObjId;
00090     WCHAR const *pwszV1TemplateClass;
00091     VARIANT varValue;
00092     DWORD cbType;
00093     DWORD i;
00094     BOOL fConflict;
00095     BOOL f;
00096     BOOL fTemplateMissing;
00097     BOOL fRAObjId = FALSE;
00098
00099     VariantInit(&varValue);
00100     *pfEnableEnrolleeExtensions = TRUE
00101         ;
00102
00103     m_pPolicy = pPolicy;
00104     m_fCA = FALSE;
00105
00106
00107     // Retrieve the template ObjId from the V2 cert template info extension
00108
00109     m_dwTemplateMajorVersion = 0;
00110     m_dwTemplateMinorVersion = 0;
00111     hr = polGetCertificateExtension(
00112           pServer,
00113           TEXT(szOID_CERTIFICATE_TEMPLATE),
00114           PROPTYPE_BINARY,
00115           &varValue);
00116     _PrintIfErrorStr2(
00117     hr,
00118     "Policy:polGetCertificateExtension",
00119     TEXT(szOID_CERTIFICATE_TEMPLATE),
00120     CERTSRV_E_PROPERTY_EMPTY);
00121     if (S_OK == hr)
00122     {
00123         // There was a cert type indicator.
00124         // varValue points to an encoded string
00125
00126         if (VT_BSTR != varValue.vt)
00127   {
00128       hr = E_INVALIDARG;
00129       _JumpError(hr, error, "Policy:varValue.vt");
00130   }
00131         if (!ceDecodeObject(
00132         X509_ASN_ENCODING,
00133         X509_CERTIFICATE_TEMPLATE,
00134         (BYTE *) varValue.bstrVal,
00135         SysStringByteLen(varValue.bstrVal),
00136         FALSE,
00137         (VOID **) &pTemplate,
00138         &cbType))
00139         {
00140             hr = ceHLastError();
00141       _JumpError(hr, error, "Policy:ceDecodeObject");
00142         }
00143   if (!ceConvertSzToBstr(&strTemplateObjId, pTemplate->pszObjId, -1))
00144   {
00145             hr = E_OUTOFMEMORY;
00146       _JumpError(hr, error, "Policy:ceConvertSzToBstr");
00147         }
00148   m_dwTemplateMajorVersion = pTemplate->dwMajorVersion;
00149   m_dwTemplateMinorVersion = pTemplate->dwMinorVersion;
00150   DBGPRINT((
00151       fDebug,
00152       pTemplate->fMinorVersion?
00153     "Extension Template Info: %ws V%u.%u\n" :
00154     "Extension Template Info: %ws V%u%\n",
00155       strTemplateObjId,
00156       m_dwTemplateMajorVersion,
00157       m_dwTemplateMinorVersion));
00158     }
00159     VariantClear(&varValue);
00160
00161     // Retrieve template Name from the V1 cert template name extension
00162
00163     hr = polGetCertificateExtension(
00164           pServer,
00165           TEXT(szOID_ENROLL_CERTTYPE_EXTENSION),
00166           PROPTYPE_BINARY,
00167           &varValue);
00168     _PrintIfErrorStr2(
00169     hr,
00170     "Policy:polGetCertificateExtension",
00171     TEXT(szOID_ENROLL_CERTTYPE_EXTENSION),
00172     CERTSRV_E_PROPERTY_EMPTY);
00173     if (S_OK == hr)
00174     {
00175         // There was a cert type indicator.
00176         // varValue points to an encoded string
00177
00178         if (VT_BSTR != varValue.vt)
00179   {
00180       hr = E_INVALIDARG;
00181       _JumpError(hr, error, "Policy:varValue.vt");
00182   }
00183         if (!ceDecodeObject(
00184         X509_ASN_ENCODING,
00185         X509_UNICODE_ANY_STRING,
00186         (BYTE *) varValue.bstrVal,
00187         SysStringByteLen(varValue.bstrVal),
00188         FALSE,
00189         (VOID **) &pName,
00190         &cbType))
00191         {
00192             hr = ceHLastError();
00193       _JumpError(hr, error, "Policy:ceDecodeObject");
00194         }
00195         strTemplateName = SysAllocString((WCHAR *) pName->Value.pbData);
00196         if (NULL == strTemplateName)
00197         {
00198             hr = E_OUTOFMEMORY;
00199       _JumpError(hr, error, "Policy:SysAllocString");
00200         }
00201   DBGPRINT((fDebug, "Extension Template: %ws\n", strTemplateName));
00202     }
00203
00204     fConflict = FALSE;
00205     fTemplateMissing = FALSE;
00206
00207     // Retrieve the template from the request attributes
00208
00209     hr = polGetRequestAttribute(pServer, wszPROPCERTTEMPLATE, &strTemplateRA);
00210     if (S_OK != hr)
00211     {
00212   _PrintErrorStr2(
00213         hr,
00214         "Policy:polGetRequestAttribute",
00215         wszPROPCERTTEMPLATE,
00216         CERTSRV_E_PROPERTY_EMPTY);
00217   hr = S_OK;
00218
00219
00220     }
00221     else
00222     {
00223   DBGPRINT((fDebug, "Attribute Template: %ws\n", strTemplateRA));
00224   if (NULL != strTemplateObjId &&
00225       !_TemplateNamesMatch(strTemplateObjId, strTemplateRA, &f))
00226   {
00227       fConflict = TRUE;
00228       if (f)
00229       {
00230     fTemplateMissing = TRUE;
00231       }
00232   }
00233   if (NULL != strTemplateName &&
00234       !_TemplateNamesMatch(strTemplateName, strTemplateRA, &f))
00235   {
00236       fConflict = TRUE;
00237       if (f)
00238       {
00239     fTemplateMissing = TRUE;
00240       }
00241   }
00242   hr = ceVerifyObjId(strTemplateRA);
00243   fRAObjId = S_OK == hr;
00244     }
00245
00246     if (NULL != strTemplateObjId &&
00247   NULL != strTemplateName &&
00248   !_TemplateNamesMatch(strTemplateObjId, strTemplateName, &f))
00249     {
00250   fConflict = TRUE;
00251   if (f)
00252   {
00253       fTemplateMissing = TRUE;
00254   }
00255     }
00256
00257     if (fConflict)
00258     {
00259   hrTemplate = CERTSRV_E_TEMPLATE_CONFLICT;
00260   if (NULL != strTemplateObjId)
00261   {
00262       _PrintErrorStr(
00263       hrTemplate,
00264       "Policy:Extension Template ObjId",
00265       strTemplateObjId);
00266   }
00267   if (NULL != strTemplateName)
00268   {
00269       _PrintErrorStr(
00270       hrTemplate,
00271       "Policy:Extension Template Name",
00272       strTemplateName);
00273   }
00274   if (NULL != strTemplateRA)
00275   {
00276       _PrintErrorStr(
00277       hrTemplate,
00278       "Policy:Attribute Template",
00279       strTemplateRA);
00280   }
00281     }
00282
00283     pwszTemplateName = strTemplateName;
00284     pwszTemplateObjId = strTemplateObjId;
00285     if (fRAObjId)
00286     {
00287   if (NULL == pwszTemplateObjId)
00288   {
00289       pwszTemplateObjId = strTemplateRA;
00290   }
00291     }
00292     else
00293     {
00294   if (NULL == pwszTemplateName)
00295   {
00296       pwszTemplateName = strTemplateRA;
00297   }
00298     }
00299
00300
00301     {
00302   if (NULL != pwszTemplateName)
00303   {
00304       for (i = 0; i < ARRAYSIZE(s_apwszCATypes); i++)
00305       {
00306     if (0 == celstrcmpiL(s_apwszCATypes[i], pwszTemplateName))
00307     {
00308         m_fCA = TRUE;
00309         break;
00310     }
00311       }
00312   }
00313     }
00314     hr = SetTemplateName(pServer, pwszTemplateName, pwszTemplateObjId);
00315     _JumpIfError(hr, error, "Policy:SetTemplateName");
00316
00317     pwszV1TemplateClass = pwszTemplateName;
00318
00319
00320     hr = pPolicy->AddV1TemplateNameExtension(pServer, pwszV1TemplateClass);
00321     _JumpIfError(hr, error, "AddTemplateNameExtension");
00322
00323 error:
00324     if (S_OK != hrTemplate)
00325     {
00326   hr = hrTemplate;  // override secondary errors
00327
00328     }
00329     VariantClear(&varValue);
00330
00331     if (NULL != pName)
00332     {
00333         LocalFree(pName);
00334     }
00335     if (NULL != pTemplate)
00336     {
00337         LocalFree(pTemplate);
00338     }
00339     if (NULL != strTemplateObjId)
00340     {
00341         SysFreeString(strTemplateObjId);
00342     }
00343     if (NULL != strTemplateName)
00344     {
00345         SysFreeString(strTemplateName);
00346     }
00347     if (NULL != strTemplateRA)
00348     {
00349         SysFreeString(strTemplateRA);
00350     }
00351     return(hr);
00352 }
00353
00354
00355
00356
00357 BOOL
00358 CRequestInstance::_TemplateNamesMatch(
00359     IN WCHAR const *pwszTemplateName1,
00360     IN WCHAR const *pwszTemplateName2,
00361     OUT BOOL *pfTemplateMissing)
00362 {
00363     HRESULT hr1;
00364     HRESULT hr2;
00365     BOOL fMatch = TRUE;
00366
00367     *pfTemplateMissing = FALSE;
00368
00369     if (0 == celstrcmpiL(pwszTemplateName1, pwszTemplateName2))
00370     {
00371   goto done;  // identical names
00372     }
00373
00374     {
00375   hr1 = ceVerifyObjId(pwszTemplateName1);
00376   hr2 = ceVerifyObjId(pwszTemplateName2);
00377   if ((S_OK == hr1) ^ (S_OK == hr2))
00378   {
00379       goto done;
00380   }
00381     }
00382     fMatch = FALSE;
00383
00384 done:
00385     return(fMatch);
00386 }
00387
00388
00389 //+--------------------------------------------------------------------------
00390 // CRequestInstance::SetTemplateName
00391 //
00392 // Returns S_OK on success.
00393 //+--------------------------------------------------------------------------
00394
00395 HRESULT
00396 CRequestInstance::SetTemplateName(
00397     IN ICertServerPolicy *pServer,
00398     IN OPTIONAL WCHAR const *pwszTemplateName,
00399     IN OPTIONAL WCHAR const *pwszTemplateObjId)
00400 {
00401     HRESULT hr;
00402     BSTR strProp = NULL;
00403     BSTR strTemplateName = NULL;
00404
00405     if (NULL != pwszTemplateName)
00406     {
00407   m_strTemplateName = SysAllocString(pwszTemplateName);
00408   if (NULL == m_strTemplateName)
00409   {
00410       hr = E_OUTOFMEMORY;
00411       _JumpError(hr, error, "Policy:SysAllocString");
00412   }
00413   strTemplateName = m_strTemplateName;
00414     }
00415
00416     if (NULL != pwszTemplateObjId)
00417     {
00418   m_strTemplateObjId = SysAllocString(pwszTemplateObjId);
00419   if (NULL == m_strTemplateObjId)
00420   {
00421       hr = E_OUTOFMEMORY;
00422       _JumpError(hr, error, "Policy:SysAllocString");
00423   }
00424   strTemplateName = m_strTemplateObjId;
00425     }
00426
00427     if (NULL != strTemplateName)
00428     {
00429   VARIANT var;
00430
00431   strProp = SysAllocString(wszPROPCERTIFICATETEMPLATE);
00432   if (NULL == strProp)
00433   {
00434       hr = E_OUTOFMEMORY;
00435       _JumpError(hr, error, "Policy:SysAllocString");
00436   }
00437
00438   var.vt = VT_BSTR;
00439   var.bstrVal = strTemplateName;
00440
00441   hr = pServer->SetCertificateProperty(strProp, PROPTYPE_STRING, &var);
00442   _JumpIfError(hr, error, "Policy:SetCertificateProperty");
00443     }
00444     hr = S_OK;
00445
00446 error:
00447     if (NULL != strProp)
00448     {
00449   SysFreeString(strProp);
00450     }
00451     return(hr);
00452 }
00453
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/Open.h Source File

  • WinUI
  • CommDlg
  • CDTest

Open.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 BOOL bDoOpenDlg ;
00007
00008
00009
00010 OPENFILENAME ofn ;
00011
00012 #define MAXBUF 300
00013
00014 #define MAXFILTERS     10
00015 #define MAXCUSTFILTER  MAXBUF
00016 #define FILENAMESIZE   MAXBUF
00017 #define FILETITLESIZE  MAXBUF
00018 #define DLGTITLESIZE   MAXBUF
00019 #define INITDIRSIZE    MAXBUF
00020 #define DEFEXTSIZE     40
00021 #define TEMPNAMESIZE   30
00022
00023 INT_PTR APIENTRY OpenFunc(HWND, UINT, WPARAM, LPARAM) ;
00024 void FillOpenDlg(HWND, LPOPENFILENAME) ;
00025 void InitOpenStruct(HWND, LPOPENFILENAME) ;
00026 void GetOpenDlg(HWND, LPOPENFILENAME) ;
00027 void InitFilterString(void) ;
00028 void InitCustFilterString(void) ;
00029
00030 TCHAR szFileTitle[FILETITLESIZE]  ;
00031 TCHAR szDlgTitle[DLGTITLESIZE]    ;
00032 TCHAR szFileName[FILENAMESIZE]    ;
00033 TCHAR szInitialDir[INITDIRSIZE]   ;
00034 TCHAR szDefExt[DEFEXTSIZE]        ;
00035 TCHAR szTempName[TEMPNAMESIZE]    ;
00036
00037 TCHAR szFilterInits[MAXFILTERS][30] ;
00038 TCHAR szFilterString[MAXBUF] ;
00039 LPTSTR lpszFilterString ;
00040
00041 TCHAR  szCustFiltInits[3][30] ;
00042 TCHAR  szCustFilterString[MAXBUF] ;
00043 LPTSTR lpszCustFilterString ;
00044
00045
00046 DWORD dwFlags ;
00047
00048
00049 void DoOpenDialog(HWND) ;
00050
00051
00052 #define ID_FILTERO                   400
00053 #define ID_CUSTFILTO                 401
00054 #define ID_MAXCUSTFILTO              402
00055 #define ID_FILTINDEXO                403
00056 #define ID_SZFILEO                   404
00057 #define ID_MAXSZFILEO                405
00058 #define ID_SZFILETITLEO              406
00059 #define ID_MAXSZFILETITLEO           407
00060 #define ID_SZINITDIRO                408
00061 #define ID_SZTITLEO                  409
00062 #define ID_FLAGSO                    410
00063 #define ID_FILEOFFO                  411
00064 #define ID_FILEEXTO                  412
00065 #define ID_SZDEFEXTO                 413
00066 #define ID_ERRORO                    414
00067 #define ID_RETURNO                   415
00068 #define ID_OPENDIALOG                606
00069 #define ID_STRUCTSIZEO               416
00070 #define ID_HWNDOWNERO                417
00071 #define ID_HINSTANCEO                418
00072 #define ID_CUSTDATAO                 419
00073 #define ID_HOOKO                     420
00074 #define ID_TEMPLATEO                 421
00075 #define ID_ADD1O                     422
00076 #define ID_ADD2O                     423
00077 #define ID_CLEAR1O                   424
00078 #define ID_CLEAR2O                   425
00079 #define ID_RESETOPEN                 601
00080 #define ID_NULLSTRUCTO               602
00081 #define ID_USEHINSTO                 607
00082 #define ID_MULTIOPEN                 608
00083 #define ID_FILEPREVIEW               609
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tag_smf Member List

This is the complete list of members for tag_smf, including all inherited members.
cbImage | tag_smf
cbPendingUserEvent | tag_smf
cTempoMap | tag_smf
cTempoMapAlloc | tag_smf
dwFormat | tag_smf
dwPendingUserEvent | tag_smf
dwTimeDivision | tag_smf
dwTracks | tag_smf
fdwSMF | tag_smf
hpbImage | tag_smf
hpbPendingUserEvent | tag_smf
htask | tag_smf
hTempoMap | tag_smf
pTempoMap | tag_smf
rTracks | tag_smf
szName | tag_smf
tkLength | tag_smf
tkPosition | tag_smf
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/pre.h Source File

  • Com
  • Fundamentals
  • SimpSvr

pre.h

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: pre.h
00003 //
00004 //      Used for precompiled headers
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00007 //**********************************************************************
00008
00009 #if !defined( _PRE_H_)
00010 #define _PRE_H_
00011
00012 #include <windows.h>
00013 #include <ole2.h>
00014 #include <olestd.h>
00015 #include <assert.h>
00016 #include <string.h>
00017 #include "simpsvr.h"
00018 #include "resource.h"
00019 #include <ole2ver.h>
00020
00021
00022 #endif
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

SPINCUBEINFO Member List

This is the complete list of members for SPINCUBEINFO, including all inherited members.
fCurrentXRotation | SPINCUBEINFO
fCurrentXRotationInc | SPINCUBEINFO
fCurrentYRotation | SPINCUBEINFO
fCurrentYRotationInc | SPINCUBEINFO
fCurrentZRotation | SPINCUBEINFO
fCurrentZRotationInc | SPINCUBEINFO
hbmCompat | SPINCUBEINFO
hbmSave | SPINCUBEINFO
hdcCompat | SPINCUBEINFO
iCurrentXTranslation | SPINCUBEINFO
iCurrentXTranslationInc | SPINCUBEINFO
iCurrentYTranslation | SPINCUBEINFO
iCurrentYTranslationInc | SPINCUBEINFO
iCurrentZTranslation | SPINCUBEINFO
iCurrentZTranslationInc | SPINCUBEINFO
iOptions | SPINCUBEINFO
rcCubeBoundary | SPINCUBEINFO
Generated on Wed Nov 13 2024 16:57:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/CascadeEvent/Cascadeec/CascadeEC.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • CascadeEvent
  • Cascadeec

CascadeEC.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("C:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /javatlb /c2j /creg /xh /wfc  /w /xi /X:rkc /l "C:\DOCUME~1\a-sunilc\LOCALS~1\Temp\jvc11E.tmp" /nologo /d "D:\ComPlusSamples\Source\LCE\CascadeEvent" "D:\ComPlusSamples\Source\LCE\CascadeEvent\CascadeEC.tlb")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package cascadeec;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 /** @com.register(clsid=8CE4A9E0-0FC1-11D3-925A-0080C7C30D72, typelib=7508F170-0FC1-11D3-925A-0080C7C30D72, version="1.0", description="Cascade Class")*/
00019 public class CascadeEC implements IUnknown,com.ms.com.NoAutoScripting,cascadeec.INewsEventDefault
00020 {
00021   public void NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL)
00022   {
00023   }
00024
00025   public void ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow)
00026   {
00027   }
00028
00029   public void LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate)
00030   {
00031   }
00032
00033 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/MessageQueuing/MqApiTst/MainFrm.Cpp Source File

  • NetDS
  • MessageQueuing
  • MqApiTst

MainFrm.Cpp

Go to the documentation of this file.
00001     // --------------------------------------------------------------------
00002     //
00003     //  Copyright (c) Microsoft Corporation.  All rights reserved
00004     //
00005     // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006     // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007     // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008     // PARTICULAR PURPOSE.
00009     //
00010     // --------------------------------------------------------------------
00011
00012
00013     /* ************************************************************************ */
00014     /*                                                                          */
00015     /* Main file of the application MQ API test.                                */
00016     /*                                                                          */
00017     /* ************************************************************************ */
00018
00019     //
00020     // MainFrm.cpp : implementation of the CMainFrame class
00021     //
00022
00023
00024
00025     #include "stdafx.h"
00026     #include "MQApitst.h"
00027     #include <afxtempl.h>
00028
00029     #include "MainFrm.h"
00030     #include "CrQDlg.h"
00031     #include "DelQDlg.h"
00032     #include "OpenQDlg.h"
00033     #include "ClosQDlg.h"
00034     #include "SendMDlg.h"
00035     #include "RecvMDlg.h"
00036     #include "RecWDlg.h"
00037     #include "LocatDlg.h"
00038
00039     #ifdef _DEBUG
00040     #define new DEBUG_NEW
00041     #undef THIS_FILE
00042     static char THIS_FILE[] = __FILE__;
00043     #endif
00044
00045     LPSTR UnicodeStringToAnsiString(LPCWSTR lpcsUnicode)
00046     {
00047       LPSTR lpAnsiString = NULL;
00048
00049       if (lpcsUnicode)
00050       {
00051         DWORD dwSize = wcstombs(NULL, lpcsUnicode, 0);
00052         lpAnsiString = new char[dwSize+1];
00053         size_t rc = wcstombs(lpAnsiString, lpcsUnicode, dwSize);
00054         if (rc == (size_t)(-1))
00055         {
00056           AfxMessageBox(_T("An unsupported wide character was encountered. Exiting..."));
00057           exit(1);
00058         }
00059         lpAnsiString[dwSize] = '\0';
00060       }
00061
00062       return lpAnsiString;
00063     }
00064
00065     void AnsiStringToUnicode(LPWSTR lpsUnicode, LPSTR  lpsAnsi, DWORD  nSize)
00066     {
00067       if (lpsUnicode == NULL)
00068       {
00069         return;
00070       }
00071
00072       ASSERT(lpsAnsi != NULL);
00073
00074       size_t rc = mbstowcs(lpsUnicode, lpsAnsi, nSize);
00075       if (rc == (size_t)(-1))
00076       {
00077         AfxMessageBox(_T("An unsupported wide character was encountered. Exiting..."));
00078         exit(1);
00079       }
00080
00081       if (lpsUnicode[nSize-1] != L'\0')
00082         lpsUnicode[nSize] = L'\0';
00083     }
00084
00085     #ifdef UNICODE
00086     #define _mqscpy(dest, src)  ASSERT(src != NULL); \
00087                   wcsncpy (dest, src, BUFFERSIZE-1); \
00088                   dest[BUFFERSIZE-1] = '\0';
00089
00090     #else
00091     #define _mqscpy(dest, src)  ASSERT(src != NULL); \
00092                   AnsiStringToUnicode(dest, src, _tcslen(src)+1);
00093
00094     #endif
00095
00096     BOOL GetTextualSid(
00097       PSID pSid,          // Binary SID
00098       LPTSTR TextualSID,  // Buffer for textual representation of an SID
00099       LPDWORD dwBufferLen // Required/provided size of the textual SID buffer
00100       )
00101     {
00102       PSID_IDENTIFIER_AUTHORITY psia;
00103       DWORD dwSubAuthorities;
00104       DWORD dwSidRev = SID_REVISION;
00105       DWORD dwCounter;
00106       DWORD dwSidSize;
00107
00108       // Obtain the identifier-authority value in the SID.
00109       psia = &((SID *)pSid)->IdentifierAuthority;
00110
00111       // Obtain the number of subauthorities in the SID.
00112       dwSubAuthorities = (DWORD)((SID *)pSid)->SubAuthorityCount;
00113
00114       //
00115       // Compute the buffer length.
00116       // S-SID_REVISION + identifier authority + subauthorities + NULL
00117       //
00118       dwSidSize = (15 + 12 + (12 * dwSubAuthorities) + 1) * sizeof(TCHAR);
00119
00120       //
00121       // Check the buffer length provided.
00122       // If it is not large enough, indicate the proper size and call SetLastError.
00123       //
00124       if (*dwBufferLen < dwSidSize)
00125       {
00126         *dwBufferLen = dwSidSize;
00127         SetLastError(ERROR_INSUFFICIENT_BUFFER);
00128         return FALSE;
00129       }
00130
00131       //
00132       // Obtain a textual representation of S-SID_REVISION.
00133       //
00134       TextualSID += _stprintf(TextualSID, TEXT("S-%lu-"), dwSidRev );
00135
00136       //
00137       // Obtain a textual representation of the identifier-authority value.
00138       //
00139       if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) )
00140       {
00141         TextualSID += _stprintf(TextualSID,
00142               TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
00143               (USHORT)psia->Value[0],
00144               (USHORT)psia->Value[1],
00145               (USHORT)psia->Value[2],
00146               (USHORT)psia->Value[3],
00147               (USHORT)psia->Value[4],
00148               (USHORT)psia->Value[5]);
00149       }
00150       else
00151       {
00152         TextualSID += _stprintf(TextualSID, TEXT("%lu"),
00153               (ULONG)(psia->Value[5]      )   +
00154               (ULONG)(psia->Value[4] <<  8)   +
00155               (ULONG)(psia->Value[3] << 16)   +
00156               (ULONG)(psia->Value[2] << 24)   );
00157       }
00158
00159       //
00160       // Loop through the subauthorities.
00161       //
00162       for (dwCounter=0 ; dwCounter < dwSubAuthorities ; dwCounter++)
00163       {
00164         TextualSID += _stprintf(TextualSID, TEXT("-%lu"),
00165               ((SID *)pSid)->SubAuthority[ dwCounter] );
00166       }
00167
00168       return TRUE;
00169     }
00170
00171     /////////////////////////////////////////////////////////////////////////////
00172     // CMainFrame
00173
00174     IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
00175
00176     BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
00177        //{{AFX_MSG_MAP(CMainFrame)
00178        ON_WM_CREATE()
00179        ON_COMMAND(ID_API_CREATE_QUEUE, OnApiCreateQueue)
00180        ON_COMMAND(ID_API_DELETE_QUEUE, OnApiDeleteQueue)
00181        ON_COMMAND(ID_API_OPEN_QUEUE, OnApiOpenQueue)
00182        ON_COMMAND(ID_API_CLOSE_QUEUE, OnApiCloseQueue)
00183        ON_COMMAND(ID_API_SEND_MESSAGE, OnApiSendMessage)
00184        ON_COMMAND(ID_API_RECEIVE_MESSAGE, OnApiReceiveMessage)
00185        ON_COMMAND(ID_API_LOCATE, OnApiLocate)
00186        //}}AFX_MSG_MAP
00187     END_MESSAGE_MAP()
00188
00189     static UINT indicators[] =
00190     {
00191        ID_SEPARATOR,           // status line indicator
00192        ID_INDICATOR_CAPS,
00193        ID_INDICATOR_NUM,
00194        ID_INDICATOR_SCRL,
00195     };
00196
00197     /////////////////////////////////////////////////////////////////////////////
00198     // CMainFrame construction/destruction
00199
00200     CMainFrame::CMainFrame()
00201     {
00202        // TODO: Add member initialization code here.
00203     }
00204
00205     CMainFrame::~CMainFrame()
00206     {
00207     }
00208
00209     int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
00210     {
00211       if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
00212         return -1;
00213
00214       if (!m_wndToolBar.Create(this) ||
00215         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
00216       {
00217         TRACE0("The attempt to load the toolbar failed.\n");
00218         return -1;
00219       }
00220
00221       if (!m_wndStatusBar.Create(this) ||
00222         !m_wndStatusBar.SetIndicators(indicators,
00223         sizeof(indicators)/sizeof(UINT)))
00224       {
00225         TRACE0("The attempt to create the toolbar or set its indicators failed.\n");
00226         return -1;
00227       }
00228
00229       // TODO: Remove this if you don't want tool tips or a resizeable toolbar.
00230       m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
00231         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00232
00233       // TODO: Delete these three lines if you don't want the toolbar to
00234       //  be dockable.
00235       m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
00236       EnableDocking(CBRS_ALIGN_ANY);
00237       DockControlBar(&m_wndToolBar);
00238
00239       return 0;
00240     }
00241
00242     BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
00243     {
00244       // TODO: Modify the Window class or styles here by modifying
00245       //  the CREATESTRUCT cs.
00246
00247       return CFrameWnd::PreCreateWindow(cs);
00248     }
00249
00250     /////////////////////////////////////////////////////////////////////////////
00251     // CMainFrame diagnostics
00252
00253     #ifdef _DEBUG
00254     void CMainFrame::AssertValid() const
00255     {
00256       CFrameWnd::AssertValid();
00257     }
00258
00259     void CMainFrame::Dump(CDumpContext& dc) const
00260     {
00261       CFrameWnd::Dump(dc);
00262     }
00263
00264     #endif //_DEBUG
00265
00266     /////////////////////////////////////////////////////////////////////////////
00267     // CMainFrame message handlers
00268
00269     #define MAXINDEX 31
00270
00271
00272     /* ************************************************************************ */
00273     /*                        RemoveFromPathNameArray                           */
00274     /* ************************************************************************ */
00275     /* This function goes through the path name array and compares a given      */
00276     /* path name to the path names of the items in the array.                   */
00277     /* If a match is found, the item is removed from the array and the function */
00278     /* returns a pointer to the item; otherwise, a NULL pointer is returned.    */
00279     /* ************************************************************************ */
00280     ARRAYQ* CMainFrame::RemoveFromPathNameArray(TCHAR *szFormatPathName)
00281     {
00282       int Index;
00283       int MaxIndex = m_PathNameArray.GetSize();
00284       ARRAYQ* pQueue;
00285
00286       //
00287       // Loop through the path name array.
00288       //
00289       for (Index=0; Index<MaxIndex; Index++)
00290       {
00291         if (m_PathNameArray[Index]->bFormatNameOnly==TRUE)
00292         {
00293           if (_tcscmp(szFormatPathName, m_PathNameArray[Index]->szFormatName) == 0)
00294           {
00295             //
00296             // A match was found.
00297             //
00298             pQueue = m_PathNameArray[Index];
00299             m_PathNameArray.RemoveAt(Index);
00300             return pQueue;
00301           }
00302         }
00303         else
00304         {
00305           if (_tcscmp(szFormatPathName, m_PathNameArray[Index]->szPathName) == 0)
00306           {
00307             //
00308             // A match was found.
00309             //
00310             pQueue = m_PathNameArray[Index];
00311             m_PathNameArray.RemoveAt(Index);
00312             return pQueue;
00313           }
00314         }
00315       }
00316       return NULL; // No match was found.
00317     }
00318
00319     /* ************************************************************************ */
00320     /*                             CleanPathNameArray                           */
00321     /* ************************************************************************ */
00322     /* This function goes through the path name array and deletes all the       */
00323     /* items in it. The function frees the allocated memory.                    */
00324     /* ************************************************************************ */
00325     void CMainFrame::CleanPathNameArray()
00326     {
00327       ARRAYQ* pQueue;
00328
00329       while (m_PathNameArray.GetSize() > 0)
00330       {
00331         pQueue = m_PathNameArray[0];
00332         m_PathNameArray.RemoveAt(0);
00333         delete pQueue;
00334       }
00335     }
00336
00337     /* ************************************************************************ */
00338     /*                        RemoveFromOpenedQueuePathNameArray                */
00339     /* ************************************************************************ */
00340     /* This function goes through the open queue path name array and compares   */
00341     /* a given path name to the path names of the items in the array.           */
00342     /* If a match is found, the item is removed from the array and the function */
00343     /* returns a pointer to the item; otherwise, a NULL pointer is returned.    */
00344     /* ************************************************************************ */
00345     ARRAYQ* CMainFrame::RemoveFromOpenedQueuePathNameArray(TCHAR *szFormatPathName)
00346     {
00347       int Index;
00348       int MaxIndex = m_OpenedQueuePathNameArray.GetSize();
00349       ARRAYQ* pQueue;
00350
00351       //
00352       // Loop through the open queue path name array.
00353       //
00354       for (Index=0; Index<MaxIndex; Index++)
00355       {
00356         if (m_OpenedQueuePathNameArray[Index]->bFormatNameOnly==TRUE)
00357         {
00358           if (_tcscmp(szFormatPathName, m_OpenedQueuePathNameArray[Index]->szFormatName) == 0)
00359           {
00360             pQueue = m_OpenedQueuePathNameArray[Index];
00361             m_OpenedQueuePathNameArray.RemoveAt(Index);
00362             return pQueue;
00363           }
00364         }
00365         else
00366         {
00367           if (_tcscmp(szFormatPathName, m_OpenedQueuePathNameArray[Index]->szPathName) == 0)
00368           {
00369             //
00370             // A match was found.
00371             //
00372             pQueue = m_OpenedQueuePathNameArray[Index];
00373             m_OpenedQueuePathNameArray.RemoveAt(Index);
00374             return pQueue;
00375           }
00376         }
00377       }
00378       return NULL; // No match was found.
00379     }
00380
00381     /* ************************************************************************ */
00382     /*                           IsOpenedQueueArrayEmpty                        */
00383     /* ************************************************************************ */
00384     /* This function checks whether the size of the open queue path name array  */
00385     /* is equal to or less than zero and, if so, it returns TRUE; otherwise,    */
00386     /* it returns FALSE.                                                        */
00387     /* ************************************************************************ */
00388     BOOL CMainFrame::IsOpenedQueueArrayEmpty()
00389     {
00390       if (m_OpenedQueuePathNameArray.GetSize() <= 0)
00391       {
00392         return TRUE;
00393       }
00394       else
00395       {
00396         return FALSE;
00397       }
00398     }
00399
00400     /* ************************************************************************ */
00401     /*                        MoveToOpenedQueuePathNameArray                    */
00402     /* ************************************************************************ */
00403     /* This function moves an item from the path name array to the open queue   */
00404     /* path name array. It also it updates the handle and the access rights to  */
00405     /* the moved queue.                                                         */
00406     /* ************************************************************************ */
00407     void CMainFrame::MoveToOpenedQueuePathNameArray(TCHAR *szPathName,TCHAR *szFormatName,
00408                             QUEUEHANDLE hQueue, DWORD dwAccess)
00409     {
00410       ARRAYQ* pQueue=NULL;
00411       //check whether pQueue is listed in the Located Queue.
00412       pQueue = RemoveFromPathNameArray(szPathName);
00413       //if not found in located Q:Allocated new ARRAYQ.
00414       if (pQueue==NULL)
00415       {
00416         pQueue=new ARRAYQ;
00417         if (pQueue==NULL)
00418         {
00419           AfxMessageBox(_T("Could not Allocate memory in function CMainFrame::MoveToOpenedQueuePathNameArray. Exiting"));
00420           exit (1);
00421         }
00422         _tcsncpy(pQueue->szFormatName,szFormatName,MAX_Q_PATHNAME_LEN-1);
00423         pQueue->szFormatName[MAX_Q_PATHNAME_LEN-1] = '\0';
00424         _tcsncpy(pQueue->szPathName,szPathName,MAX_Q_PATHNAME_LEN-1);
00425         pQueue->szFormatName[MAX_Q_PATHNAME_LEN-1] = '\0';
00426         if (_tcscmp(pQueue->szPathName,_T(""))==0)
00427         {
00428           pQueue->bFormatNameOnly=true;
00429         }
00430       }
00431       pQueue->hHandle = hQueue;                     // add Queue Handle.
00432       pQueue->dwAccess = dwAccess;                  // add Queue Access rights.
00433
00434       Add2OpenedQueuePathNameArray(pQueue);
00435     }
00436
00437     /* ************************************************************************ */
00438     /*                              MoveToPathNameArray                         */
00439     /* ************************************************************************ */
00440     /* This function moves an item from the open queue path name array to the   */
00441     /* path name array.                                                         */
00442     /* ************************************************************************ */
00443     void CMainFrame::MoveToPathNameArray(TCHAR *pszPathName)
00444     {
00445       ARRAYQ* pQueue;
00446
00447       pQueue = RemoveFromOpenedQueuePathNameArray(pszPathName);
00448       Add2PathNameArray(pQueue);
00449     }
00450
00451     /* ************************************************************************ */
00452     /*                             UpdatePathNameArrays                         */
00453     /* ************************************************************************ */
00454     /* This function goes through the open queue path name array, and for every */
00455     /* item in it, it checks whether the item is found in the path name array   */
00456     /* as well. If so, the function removes the item from the path name array.  */
00457     /* ************************************************************************ */
00458     void CMainFrame::UpdatePathNameArrays()
00459     {
00460       int PathNameIndex;
00461       int OpenedPathNameIndex;
00462       int MaxOpenedPathNameIndex = m_OpenedQueuePathNameArray.GetSize();
00463       ARRAYQ* pQueue;
00464
00465       //
00466       // Loop through the open queue path name array.
00467       //
00468       for (OpenedPathNameIndex=0; OpenedPathNameIndex<MaxOpenedPathNameIndex; OpenedPathNameIndex++)
00469       {
00470         for (PathNameIndex=0; PathNameIndex<m_PathNameArray.GetSize(); PathNameIndex++)
00471         {
00472           if (_tcscmp(m_OpenedQueuePathNameArray[OpenedPathNameIndex]->szPathName,
00473             m_PathNameArray[PathNameIndex]->szPathName) == 0)
00474           {
00475             //
00476             // A match was found, so remove it from path name array.
00477             //
00478             pQueue = m_PathNameArray[PathNameIndex];
00479             m_PathNameArray.RemoveAt(PathNameIndex);
00480             delete pQueue;
00481             //
00482             // Get out of the inner for loop.
00483             //
00484             break;
00485           }
00486         }
00487       }
00488     }
00489
00490
00491     /* ************************************************************************ */
00492     /*                              GetQueueHandle                              */
00493     /* ************************************************************************ */
00494     /* This function goes through the open queue path name array and retrieves  */
00495     /* the handle to the queue which matches a given path name. If no mathch    */
00496     /* is found, the function returns FALSE.                                    */
00497     /* ************************************************************************ */
00498     BOOL CMainFrame::GetQueueHandle(TCHAR *szPathFormatName,QUEUEHANDLE* phClosedQueueHandle)
00499     {
00500       int Index;
00501       int MaxIndex = m_OpenedQueuePathNameArray.GetSize();
00502       ARRAYQ* pQueue;
00503
00504       //
00505       // Loop through the open queue path name array.
00506       //
00507       for (Index = 0; Index<MaxIndex; Index++)
00508       {
00509         if (m_OpenedQueuePathNameArray[Index]->bFormatNameOnly==TRUE)
00510         {
00511           if (_tcscmp(szPathFormatName, m_OpenedQueuePathNameArray[Index]->szFormatName)==0)
00512           {
00513             //
00514             // A match was found.
00515             //
00516             pQueue = m_OpenedQueuePathNameArray[Index];
00517             *phClosedQueueHandle = pQueue->hHandle;
00518             return TRUE;
00519           }
00520         }
00521         else
00522         {
00523
00524           if (_tcscmp(szPathFormatName, m_OpenedQueuePathNameArray[Index]->szPathName)==0)
00525           {
00526             //
00527             // A match was found.
00528             //
00529             pQueue = m_OpenedQueuePathNameArray[Index];
00530             *phClosedQueueHandle = pQueue->hHandle;
00531             return TRUE;
00532           }
00533         }
00534       }
00535       return FALSE; // No match was found.
00536     }
00537
00538     /* ************************************************************************ */
00539     /*                       TranslatePathNameToFormatName                      */
00540     /* ************************************************************************ */
00541     /* This function goes retrieves the Format Name using the MSMQ API          */
00542     /* MQPathNameToFormatName. if no format name is found, the function checks  */
00543     /* whether format name was given.                     */
00544     /* returns TRUE is succeeded or FALSE if not                */
00545     /* ************************************************************************ */
00546     BOOL CMainFrame::TranslatePathNameToFormatName(TCHAR *szPathName,TCHAR *szFormatName)
00547     {
00548       //
00549       //check valid parameters
00550       //
00551       if (szPathName==NULL)
00552       {
00553         return FALSE;
00554       }
00555       DWORD dwFormatNameSize=MAX_Q_FORMATNAME_LEN;
00556       HRESULT hr;
00557
00558 #ifdef UNICODE
00559       hr = MQPathNameToFormatName(szPathName,szFormatName,&dwFormatNameSize);
00560 #else
00561       WCHAR szwPathName[MAX_Q_FORMATNAME_LEN]={0};
00562       WCHAR szwFormatName[MAX_Q_FORMATNAME_LEN]={0};
00563
00564       size_t rc = mbstowcs(szwPathName,szPathName,MAX_Q_FORMATNAME_LEN-1);
00565       if (rc == (size_t)(-1))
00566       {
00567         AfxMessageBox(_T("An unsupported wide character was encountered. Exiting..."));
00568         exit(1);
00569       }
00570
00571       hr = MQPathNameToFormatName(szwPathName,szwFormatName,&dwFormatNameSize);
00572       wcstombs(szFormatName,szwFormatName,MAX_Q_FORMATNAME_LEN);
00573
00574 #endif
00575       if (FAILED(hr))
00576       {
00577         if (IsFormatName(szPathName)==TRUE)
00578         {
00579           _tcsncpy(szFormatName,szPathName,MAX_Q_PATHNAME_LEN);
00580           return TRUE;
00581
00582         }
00583         return FALSE;
00584       }
00585       return TRUE;
00586
00587     }
00588
00589
00590     /* ************************************************************************ */
00591     /*                         DisplayPathNameArray                             */
00592     /* ************************************************************************ */
00593     /* This function goes through the path name array and prints it to sreeen.  */
00594     /* ************************************************************************ */
00595     void CMainFrame::DisplayPathNameArray()
00596     {
00597       int Index;
00598       int MaxIndex = m_PathNameArray.GetSize();
00599       TCHAR szMsgBuffer[BUFFERSIZE];
00600
00601       _stprintf(szMsgBuffer, TEXT("   Located Queues :"));
00602       PrintToScreen(szMsgBuffer);
00603       //
00604       // Loop through the path name array.
00605       //
00606       for (Index=0; Index<MaxIndex; Index++)
00607       {
00608         //
00609         // Print the path names or format names.
00610         //
00611
00612         if (m_PathNameArray[Index]->bFormatNameOnly==TRUE)
00613         {
00614           _stprintf(szMsgBuffer, TEXT("\t%d. %s"),Index+1, m_PathNameArray[Index]->szFormatName);
00615           PrintToScreen(szMsgBuffer);
00616
00617         }
00618         else
00619         {
00620           _stprintf(szMsgBuffer, TEXT("\t%d. %s"),Index+1, m_PathNameArray[Index]->szPathName);
00621           PrintToScreen(szMsgBuffer);
00622         }
00623       }
00624     }
00625
00626     /* ************************************************************************ */
00627     /*                    DisplayOpenedQueuePathNameArray                       */
00628     /* ************************************************************************ */
00629     /* This function goes through the open queue path name array and prints it  */
00630     /* to screen.                                                               */
00631     /* ************************************************************************ */
00632     void CMainFrame::DisplayOpenedQueuePathNameArray()
00633     {
00634       int Index;
00635       int MaxIndex = m_OpenedQueuePathNameArray.GetSize();
00636       TCHAR szMsgBuffer[BUFFERSIZE];
00637
00638       _stprintf(szMsgBuffer, TEXT("   Currently Opened Queues :"));
00639       PrintToScreen(szMsgBuffer);
00640       //
00641       // Loop through the open queue path name array.
00642       //
00643       for (Index=0; Index<MaxIndex; Index++)
00644       {
00645         //
00646         // Print the path names or format names.
00647         //
00648
00649         if (m_OpenedQueuePathNameArray[Index]->bFormatNameOnly==TRUE)
00650         {
00651           _stprintf(szMsgBuffer, TEXT("\t%d. %s"),Index+1, m_OpenedQueuePathNameArray[Index]->szFormatName);
00652           PrintToScreen(szMsgBuffer);
00653
00654         }
00655         else
00656         {
00657
00658           _stprintf(szMsgBuffer, TEXT("\t%d. %s"),Index+1, m_OpenedQueuePathNameArray[Index]->szPathName);
00659           PrintToScreen(szMsgBuffer);
00660         }
00661       }
00662     }
00663
00664     /* ************************************************************************ */
00665     /*                          GetMsgClassStatus                               */
00666     /* ************************************************************************ */
00667     /* This function sets the proper status string based on a given MQMSG class.*/
00668     /* ************************************************************************ */
00669
00670     struct
00671     {
00672       unsigned short  mclass;
00673       LPTSTR          pszDescription;
00674     } StringClass[] =
00675       {
00676       { MQMSG_CLASS_NORMAL, TEXT("The Message was received successfully.")},
00677       { MQMSG_CLASS_ACK_REACH_QUEUE, TEXT("The REACH QUEUE ACK Message was read successfully.")},
00678       { MQMSG_CLASS_ACK_RECEIVE, TEXT("The RECEIVE ACK Message was read successfully.")},
00679       { MQMSG_CLASS_NACK_BAD_DST_Q, TEXT("The DESTINATION QUEUE HANDLE INVALID Nack Message was read successfully.")},
00680       { MQMSG_CLASS_NACK_RECEIVE_TIMEOUT, TEXT("The TIME TO RECEIVE EXPIRED Nack Message was read successfully.")},
00681       { MQMSG_CLASS_NACK_REACH_QUEUE_TIMEOUT, TEXT("The TIME TO REACH QUEUE EXPIRED Nack Message was read successfully.")},
00682       { MQMSG_CLASS_NACK_Q_EXCEED_QUOTA, TEXT("The QUEUE IS FULL Nack Message was read successfully.")},
00683       { MQMSG_CLASS_NACK_ACCESS_DENIED, TEXT("The SENDER HAVE NO SEND ACCESS RIGHTS ON QUEUE Nack Message was read successfully.")},
00684       { MQMSG_CLASS_NACK_HOP_COUNT_EXCEEDED, TEXT("The HOP COUNT EXCEEDED Nack Message was read successfully.")},
00685       { MQMSG_CLASS_NACK_BAD_SIGNATURE, TEXT("The MESSAGE RECEIVED WITH BAD SIGNATURE Nack Message was read successfully.")},
00686       { MQMSG_CLASS_NACK_BAD_ENCRYPTION, TEXT("The MSG COULD NOT DECRYPTED Nack Message was read successfully.")},
00687       { MQMSG_CLASS_NACK_COULD_NOT_ENCRYPT, TEXT("The SOURCE QM COULD NOT ENCRYPT MSG FOR DEST QM Nack Message was read successfully.")},
00688       { 0, NULL}
00689       };
00690
00691     void CMainFrame::ClassToString(unsigned short MsgClass,LPTSTR pszStatus)
00692     {
00693       //
00694       // Loop through the StringClass array to find MsgClass.
00695       //
00696       ASSERT(pszStatus != NULL);
00697
00698       DWORD dwIndex = 0;
00699       while (StringClass[dwIndex].pszDescription != NULL)
00700       {
00701         if (StringClass[dwIndex].mclass == MsgClass)
00702         {
00703           _tcsncpy(pszStatus, StringClass[dwIndex].pszDescription, BUFFERSIZE*2 -1);
00704           pszStatus[BUFFERSIZE*2 -1] = '\0';
00705           return;
00706         }
00707         dwIndex++;
00708       }
00709
00710       //
00711       // MsgClass was not found, so print the default error.
00712       //
00713       _stprintf(pszStatus,TEXT("The NACK (0x%X) message was read successfully."), MsgClass);
00714     }
00715
00716
00717     /* ************************************************************************ */
00718     /*                            OnApiCreateQueue                              */
00719     /* ************************************************************************ */
00720     /* This function opens a dialog box and asks the user for the queue's       */
00721     /* path name and label. Then it creates the specified queue.                */
00722     /*                                                                          */
00723     /* Uses: MQCreateQueue.                                                     */
00724     /* ************************************************************************ */
00725     void CMainFrame::OnApiCreateQueue()
00726     {
00727       // TODO: Add your command handler code here.
00728
00729       TCHAR szMsgBuffer[BUFFERSIZE];
00730
00731       MQQUEUEPROPS QueueProps;
00732       MQPROPVARIANT aVariant[MAXINDEX];
00733       QUEUEPROPID aPropId[MAXINDEX];
00734       DWORD PropIdCount = 0;
00735       HRESULT hr;
00736
00737       PSECURITY_DESCRIPTOR pSecurityDescriptor;
00738
00739       TCHAR szPathNameBuffer[MAX_Q_PATHNAME_LEN];
00740       TCHAR szFormatNameBuffer[MAX_Q_FORMATNAME_LEN];
00741       TCHAR szLabelBuffer[MAX_Q_PATHNAME_LEN];
00742       DWORD dwFormatNameBufferLength = MAX_Q_FORMATNAME_LEN;
00743
00744
00745       //
00746       // Display the Create Queue dialog box.
00747       //
00748       CCreateQueueDialog CreateQueueDialog;
00749
00750       if(CreateQueueDialog.DoModal() == IDCANCEL)
00751       {
00752         return;
00753       }
00754       CreateQueueDialog.GetPathName(szPathNameBuffer);
00755       CreateQueueDialog.GetLabel(szLabelBuffer);
00756
00757       //
00758       // Get the input fields from the dialog box
00759       // and prepare the property array PROPVARIANT.
00760       //
00761
00762
00763       //
00764       // Set the PROPID_Q_PATHNAME property.
00765       //
00766       aPropId[PropIdCount] = PROPID_Q_PATHNAME;    // PropId
00767       aVariant[PropIdCount].vt = VT_LPWSTR;        // Type
00768       aVariant[PropIdCount].pwszVal = new WCHAR[MAX_Q_PATHNAME_LEN];
00769       _mqscpy(aVariant[PropIdCount].pwszVal, szPathNameBuffer); // Value
00770
00771       PropIdCount++;
00772
00773       //
00774       // Set the PROPID_Q_LABEL property.
00775       //
00776       aPropId[PropIdCount] = PROPID_Q_LABEL;    // PropId
00777       aVariant[PropIdCount].vt = VT_LPWSTR;     // Type
00778       aVariant[PropIdCount].pwszVal = new WCHAR[MAX_Q_PATHNAME_LEN];
00779       _mqscpy(aVariant[PropIdCount].pwszVal, szLabelBuffer); // Value
00780
00781       PropIdCount++;
00782
00783
00784       //
00785       // Initialize the MQEUEUPROPS structure.
00786       //
00787       QueueProps.cProp = PropIdCount;           //Number of properties
00788       QueueProps.aPropID = aPropId;             //Identifiers of properties
00789       QueueProps.aPropVar = aVariant;           // Value of properties
00790       QueueProps.aStatus = NULL;                //No error reports
00791
00792       //
00793       // No security is defined (default).
00794       //
00795       pSecurityDescriptor = NULL;
00796
00797       //
00798       // Create the queue.
00799       //
00800     #ifdef UNICODE
00801       hr = MQCreateQueue(
00802           pSecurityDescriptor,            //Security
00803           &QueueProps,                    //Queue properties
00804           szFormatNameBuffer,             //Output: Format name
00805           &dwFormatNameBufferLength       //Output: Format name length
00806           );
00807     #else
00808       WCHAR szwFormatNameBuffer[MAX_Q_FORMATNAME_LEN];
00809       hr = MQCreateQueue(
00810           pSecurityDescriptor,            //Security
00811           &QueueProps,                    //Queue properties
00812           szwFormatNameBuffer,            //Output: Format name
00813           &dwFormatNameBufferLength       //Output: Format name length
00814           );
00815
00816       if (SUCCEEDED(hr))
00817       {
00818         size_t rc =wcstombs(szFormatNameBuffer, szwFormatNameBuffer, dwFormatNameBufferLength);
00819         if (rc == (size_t)(-1))
00820         {
00821           AfxMessageBox("An unsupported wide character was encountered. Exiting...");
00822           exit(1);
00823         }
00824       }
00825     #endif
00826
00827       if (FAILED(hr))
00828       {
00829         //
00830         // An error occurred, so display a message.
00831         //
00832         _stprintf(szMsgBuffer, TEXT("MQCreateQueue failed. Error code: 0x%x."),hr);
00833         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
00834       }
00835       else
00836       {
00837         //
00838         // Success was achieved, so write to the edit control.
00839         //
00840         _stprintf(szMsgBuffer, TEXT("The queue %s was created successfully. ( FormatName: %s )"),
00841           szPathNameBuffer, szFormatNameBuffer);
00842         PrintToScreen(szMsgBuffer);
00843
00844         //
00845         // Add the new queue to the path name array.
00846         //
00847         ARRAYQ* pNewQueue = new ARRAYQ;
00848         if (pNewQueue == NULL)
00849           return;
00850
00851         //
00852         // Save the path name and the format name in the ARRAYQ structure.
00853         //
00854         _tcsncpy (pNewQueue->szPathName, szPathNameBuffer, MAX_Q_PATHNAME_LEN-1);
00855         pNewQueue->szPathName[MAX_Q_PATHNAME_LEN-1] = '\0';
00856
00857         _tcsncpy (pNewQueue->szFormatName, szFormatNameBuffer, MAX_Q_FORMATNAME_LEN-1);
00858         pNewQueue->szFormatName[MAX_Q_FORMATNAME_LEN-1] = '\0';
00859
00860         Add2PathNameArray(pNewQueue);
00861
00862       }
00863
00864       //
00865       // Free the allocated memory.
00866       //
00867       delete   aVariant[0].pwszVal;
00868       delete   aVariant[1].pwszVal;
00869     }
00870
00871     /* ************************************************************************ */
00872     /*                            OnApiDeleteQueue                              */
00873     /* ************************************************************************ */
00874     /* This function opens a dialog box and asks the user for the queue's       */
00875     /* path name. Then it deletes the specified queue.                          */
00876     /*                                                                          */
00877     /* Uses: MQDeleteQueue.                                                     */
00878     /* ************************************************************************ */
00879     void CMainFrame::OnApiDeleteQueue()
00880     {
00881       // TODO: Add your command handler code here.
00882       TCHAR szPathNameBuffer[MAX_Q_PATHNAME_LEN];
00883       TCHAR szFormatNameBuffer[MAX_Q_PATHNAME_LEN];
00884       TCHAR szMsgBuffer[BUFFERSIZE];
00885
00886       HRESULT hr;
00887
00888       DWORD dwFormatNameBufferLength = MAX_Q_PATHNAME_LEN;
00889
00890       CDeleteQueueDialog DeleteQueueDialog(&m_PathNameArray);
00891
00892       //
00893       // Display the Delete Queue dialog box.
00894       //
00895       if (DeleteQueueDialog.DoModal() == IDCANCEL)
00896       {
00897         return;
00898       }
00899
00900       DeleteQueueDialog.GetPathName(szPathNameBuffer);
00901
00902       //
00903       // Translate the path name to a format name using the ARRAYQ array.
00904       //
00905       if (TranslatePathNameToFormatName(szPathNameBuffer, szFormatNameBuffer) == FALSE)
00906       {
00907         //
00908         // An error occurred, so display a message.
00909         //
00910         _stprintf(szMsgBuffer, TEXT("The queue was not found."));
00911         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
00912         return;
00913       }
00914
00915       //
00916       // Delete the queue.
00917       //
00918     #ifdef UNICODE
00919       hr = MQDeleteQueue(szFormatNameBuffer);  // Format name of the queue to be deleted
00920     #else
00921       WCHAR szwFormatNameBuffer[MAX_Q_FORMATNAME_LEN];
00922       size_t rc = mbstowcs(szwFormatNameBuffer, szFormatNameBuffer, _tcslen(szFormatNameBuffer)+1);
00923       if (rc == (size_t)(-1))
00924       {
00925         AfxMessageBox("An unsupported wide character was encountered. Exiting...");
00926         exit(1);
00927       }
00928       hr = MQDeleteQueue(szwFormatNameBuffer);  // Format name of the queue to be deleted
00929     #endif
00930
00931       if (FAILED(hr))
00932       {
00933         //
00934         // An error occurred, so display a message.
00935         //
00936         _stprintf(szMsgBuffer, TEXT("MQDeleteQueue failed. Error code: 0x%x."),hr);
00937         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
00938       }
00939       else
00940       {
00941         //
00942         // Success was achieved, so write in the edit control.
00943         //
00944         _stprintf(szMsgBuffer, TEXT("The queue %s was deleted successfully."), szPathNameBuffer);
00945         PrintToScreen(szMsgBuffer);
00946         //
00947         // Delete the name from the path name array.
00948         //
00949         ARRAYQ* DeletedQueue = RemoveFromPathNameArray(szPathNameBuffer);
00950         if (DeletedQueue != NULL)
00951         {
00952           delete DeletedQueue;
00953         }
00954       }
00955     }
00956
00957     /* ************************************************************************ */
00958     /*                             OnApiOpenQueue                               */
00959     /* ************************************************************************ */
00960     /* This function opens a dialog box and asks the user for the queue's       */
00961     /* path name. Then it opens the specified queue.                             */
00962     /*                                                                          */
00963     /* Uses: MQOpenQueue.                                                       */
00964     /* ************************************************************************ */
00965     void CMainFrame::OnApiOpenQueue()
00966     {
00967       // TODO: Add your command handler code here.
00968       TCHAR szPathNameBuffer[MAX_Q_PATHNAME_LEN];
00969       TCHAR szFormatNameBuffer[MAX_Q_PATHNAME_LEN];
00970       TCHAR szAccessBuffer[ACCESSBUFFERSIZE];
00971       TCHAR szMsgBuffer[BUFFERSIZE];
00972       WCHAR szwFormatNameBuffer[MAX_Q_FORMATNAME_LEN]={0};
00973       DWORD dwFormatNameSize=MAX_Q_FORMATNAME_LEN;
00974       HRESULT hrFormatName;
00975       HRESULT hrPathName;
00976
00977       DWORD dwFormatNameBufferLength = MAX_Q_PATHNAME_LEN;
00978       DWORD dwAccess;
00979
00980       QUEUEHANDLE hQueue;
00981
00982       COpenQueueDialog OpenQueueDialog(&m_PathNameArray);
00983
00984       //
00985       // Display the Open Queue dialog box.
00986       //
00987       if (OpenQueueDialog.DoModal() == IDCANCEL)
00988       {
00989         return;
00990       }
00991
00992       OpenQueueDialog.GetPathName(szPathNameBuffer);
00993       OpenQueueDialog.GetFormatName(szFormatNameBuffer);
00994       dwAccess = OpenQueueDialog.GetAccess();
00995       //
00996       // Set the access buffer string.
00997       //
00998       switch (dwAccess)
00999       {
01000       case (MQ_RECEIVE_ACCESS | MQ_SEND_ACCESS):
01001
01002         _tcsncpy(szAccessBuffer, TEXT("MQ_RECEIVE_ACCESS, MQ_SEND_ACCESS."), 34);
01003         szAccessBuffer[34] = '\0';
01004         break;
01005
01006       case MQ_RECEIVE_ACCESS:
01007
01008         _tcsncpy(szAccessBuffer, TEXT("MQ_RECEIVE_ACCESS."), 18);
01009         szAccessBuffer[18] = '\0';
01010         break;
01011
01012       case MQ_SEND_ACCESS:
01013
01014         _tcsncpy(szAccessBuffer, TEXT("MQ_SEND_ACCESS."), 15);
01015         szAccessBuffer[15] = '\0';
01016         break;
01017
01018       default:
01019
01020         _tcsncpy(szAccessBuffer, TEXT("NONE."), 5);
01021         szAccessBuffer[5] = '\0';
01022         break;
01023       }
01024
01025       //Try Open The Q. using format name given.
01026
01027 #ifdef UNICODE
01028       hrFormatName = MQOpenQueue(szFormatNameBuffer,dwAccess,0,&hQueue);
01029 #else
01030       size_t rc = mbstowcs(szwFormatNameBuffer, szFormatNameBuffer, _tcslen(szFormatNameBuffer)+1);
01031       if (rc == (size_t)(-1))
01032       {
01033         AfxMessageBox("An unsupported wide character was encountered. Exiting...");
01034         exit(1);
01035       }
01036
01037       hrFormatName = MQOpenQueue(
01038           szwFormatNameBuffer,    // Format name of the queue to be opened.
01039           dwAccess,               // Access rights to the queue.
01040           0,                      // No exclusive receive.
01041           &hQueue                 // OUT: handle to the opened queue.
01042           );
01043
01044 #endif
01045       //
01046       //If failed to open Q. using format name,open The Q. using path name given.
01047       //
01048       if (FAILED(hrFormatName))
01049       {
01050
01051 #ifdef UNICODE
01052         //Traslate PathName to FormatName
01053         MQPathNameToFormatName(szPathNameBuffer,szwFormatNameBuffer,&dwFormatNameSize);
01054         //Open The Q.
01055         hrPathName = MQOpenQueue(szwFormatNameBuffer,dwAccess,0,&hQueue);
01056 #else
01057         WCHAR szwPathNameBuffer[MAX_Q_FORMATNAME_LEN]={0};
01058
01059         size_t rc = mbstowcs(szwPathNameBuffer, szPathNameBuffer, _tcslen(szPathNameBuffer)+1);
01060         if (rc == (size_t)(-1))
01061         {
01062           AfxMessageBox("An unsupported wide character was encountered. Exiting...");
01063           exit(1);
01064         }
01065
01066         MQPathNameToFormatName(szwPathNameBuffer,szwFormatNameBuffer,&dwFormatNameSize);
01067
01068         hrPathName = MQOpenQueue(
01069             szwFormatNameBuffer,    // Format name of the queue to be opened.
01070             dwAccess,               // Access rights to the queue.
01071             0,                      // No exclusive receive.
01072             &hQueue                 // OUT: handle to the opened queue.
01073             );
01074
01075 #endif
01076
01077       }
01078
01079       //Results
01080       if (FAILED(hrPathName)&&FAILED(hrFormatName))
01081       {
01082
01083       //
01084       // An error occurred, so display a message.
01085       //
01086         if (szFormatNameBuffer[0]!=0)
01087         {
01088           _stprintf(szMsgBuffer, TEXT("MQOpenQueue failed. Error code: 0x%x."),hrFormatName);
01089         }
01090         else
01091         {
01092           _stprintf(szMsgBuffer, TEXT("MQOpenQueue failed. Error code: 0x%x."),hrPathName);
01093         }
01094         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01095
01096       }
01097       else
01098       {
01099         //
01100         // Success was achieved, so write in the edit control.
01101         //
01102         _stprintf(szMsgBuffer,
01103           TEXT("The queue %s was opened successfully.\r\n\tQueueHandle: 0x%x\r\n\tQueue Access : %s"),
01104           szPathNameBuffer,
01105           (UINT)hQueue,
01106           szAccessBuffer);
01107         PrintToScreen(szMsgBuffer);
01108
01109         //
01110         // Move the queue to the array of opened queue path names.
01111         //
01112
01113         MoveToOpenedQueuePathNameArray(szPathNameBuffer,szFormatNameBuffer,hQueue, dwAccess);
01114       }
01115
01116     }
01117
01118     /* ************************************************************************ */
01119     /*                            OnApiCloseQueue                               */
01120     /* ************************************************************************ */
01121     /* This function opens a dialog box and asks the user for the queue's       */
01122     /* path name. Then it closes the specified queue.                           */
01123     /*                                                                          */
01124     /* Uses: MQCloseQueue.                                                      */
01125     /* ************************************************************************ */
01126     void CMainFrame::OnApiCloseQueue()
01127     {
01128
01129       TCHAR szPathNameBuffer[MAX_Q_PATHNAME_LEN];
01130       TCHAR szMsgBuffer[BUFFERSIZE];
01131
01132       HRESULT hr;
01133
01134       DWORD dwFormatNameBufferLength = MAX_Q_PATHNAME_LEN;
01135
01136       QUEUEHANDLE hClosedQueueHandle;
01137
01138       //
01139       // Display the Close Queue dialog box.
01140       //
01141       CCloseQueueDialog CloseQueueDialog(&m_OpenedQueuePathNameArray);
01142
01143       if (CloseQueueDialog.DoModal() == IDCANCEL)
01144       {
01145         return;
01146       }
01147
01148       CloseQueueDialog.GetPathName(szPathNameBuffer);
01149
01150       //
01151       // Get the handle of the queue to be closed.
01152       //
01153       if (GetQueueHandle(szPathNameBuffer, &hClosedQueueHandle) == FALSE)
01154       {
01155         //
01156         // An error occurred, so display a message.
01157         //
01158         _stprintf(szMsgBuffer, TEXT("The queue could not be closed because it was not opened before."));
01159         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01160         return;
01161       }
01162
01163       //
01164       // Close the queue.
01165       //
01166       hr = MQCloseQueue(hClosedQueueHandle);   // The handle of the queue to be closed is passed.
01167       if (FAILED(hr))
01168       {
01169         //
01170         // An error occurred, so display a message.
01171         //
01172         _stprintf(szMsgBuffer, TEXT("MQCloseQueue failed. Error code: 0x%x."),hr);
01173         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01174       }
01175       else
01176       {
01177         //
01178         // Success was achieved, so write in the edit control.
01179         //
01180         _stprintf(szMsgBuffer, TEXT("The queue %s was closed successfully."), szPathNameBuffer);
01181         PrintToScreen(szMsgBuffer);
01182         //
01183         // Move the queue from the open queue path name array to the path name array.
01184         //
01185         MoveToPathNameArray(szPathNameBuffer);
01186       }
01187     }
01188
01189     /* ************************************************************************ */
01190     /*                            OnApiSendMessage                              */
01191     /* ************************************************************************ */
01192     /* This function opens a dialog box and asks the user for the queue's path  */
01193     /* name and some message properties. Then it sends the message to the       */
01194     /* specified queue.                                                         */
01195     /*                                                                          */
01196     /* Uses: MQSendMessage.                                                     */
01197     /* ************************************************************************ */
01198
01199     //
01200     // Declare two static buffers to hold the last message body and label for the next time.
01201     //
01202     TCHAR szLastMessageBody[BUFFERSIZE];
01203     TCHAR szLastMessageLabel[BUFFERSIZE];
01204
01205     void CMainFrame::OnApiSendMessage()
01206     {
01207       // TODO: Add your command handler code here.
01208
01209       TCHAR szPathNameBuffer[MAX_Q_PATHNAME_LEN]={0};
01210       TCHAR szAdminPathNameBuffer[MAX_Q_PATHNAME_LEN]={0};
01211       TCHAR szAdminFormatNameBuffer[MAX_Q_FORMATNAME_LEN]={0};
01212       TCHAR szMsgBuffer[BUFFERSIZE]={0};
01213
01214       MQMSGPROPS MsgProps;
01215       MQPROPVARIANT aVariant[MAXINDEX];
01216       MSGPROPID aPropId[MAXINDEX];
01217       DWORD PropIdCount = 0;
01218
01219       HRESULT hr;
01220
01221       unsigned char bPriority;
01222       unsigned char bDelivery;
01223       unsigned char bJournal;
01224       unsigned char bDeadLetter;
01225       unsigned char bAuthenticated;
01226       unsigned char bEncrypted;
01227       unsigned char bAcknowledge;
01228
01229       WCHAR szMessageBodyBuffer [BUFFERSIZE];
01230       WCHAR szMessageLabelBuffer[BUFFERSIZE];
01231       DWORD dwTimeToReachQueue;
01232       DWORD dwTimeToBeReceived;
01233
01234       QUEUEHANDLE hQueue;
01235
01236       CSendMessageDialog SendMessageDialog(&m_OpenedQueuePathNameArray);
01237
01238       //
01239       // Display the Send Message dialog box.
01240       //
01241       if (SendMessageDialog.DoModal() == IDCANCEL)
01242       {
01243         return;
01244       }
01245
01246       //
01247       // Retrieve the properties from the dialog box.
01248       //
01249       SendMessageDialog.GetPathName(szPathNameBuffer);
01250       SendMessageDialog.GetAdminPathName(szAdminPathNameBuffer);
01251       bPriority = SendMessageDialog.GetPriority();
01252       bDelivery = SendMessageDialog.GetDelivery();
01253       bJournal = SendMessageDialog.GetJournal();
01254       bDeadLetter = SendMessageDialog.GetDeadLetter();
01255       bAuthenticated = SendMessageDialog.GetAuthenticated();
01256       bEncrypted = SendMessageDialog.GetEncrypted();
01257       bAcknowledge = SendMessageDialog.GetAcknowledge();
01258       SendMessageDialog.GetMessageBody(szLastMessageBody);
01259       SendMessageDialog.GetMessageLabel(szLastMessageLabel);
01260       dwTimeToReachQueue = SendMessageDialog.GetTimeToReachQueue();
01261       dwTimeToBeReceived = SendMessageDialog.GetTimeToBeReceived();
01262
01263       //
01264       // Update the properties of the last message.
01265       //
01266       _mqscpy(szMessageBodyBuffer, szLastMessageBody);
01267       _mqscpy(szMessageLabelBuffer, szLastMessageLabel);
01268
01269       //
01270       // Get the target queue handle.
01271       //
01272       if (GetQueueHandle(szPathNameBuffer, &hQueue) == FALSE)
01273       {
01274         //
01275         // An error occurred, so display a message.
01276         //
01277         _stprintf(szMsgBuffer, TEXT("GetQueueHandle failed. Queue not opened yet."));
01278         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01279         return;
01280       }
01281
01282       //
01283       // Get the administration queue format name.
01284       //
01285       if (szAdminPathNameBuffer[0] != 0)
01286       {
01287         if (TranslatePathNameToFormatName(szAdminPathNameBuffer, szAdminFormatNameBuffer) == FALSE)
01288         {
01289           //
01290           // An error occurred, so display a message.
01291           //
01292           _stprintf(szMsgBuffer, TEXT("TranslatePathNameToFormatName failed, Queue has not been opened yet."));
01293           MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01294           return;
01295         }
01296       }
01297
01298       //
01299       // Prepare the property array PROPVARIANT.
01300       //
01301
01302       //
01303       // Set the PROPID_M_PRIORITY property.
01304       //
01305       aPropId[PropIdCount] = PROPID_M_PRIORITY;    // PropId
01306       aVariant[PropIdCount].vt = VT_UI1;           // Type
01307       aVariant[PropIdCount].bVal = bPriority;      // Value
01308
01309       PropIdCount++;
01310
01311       //
01312       // Set the PROPID_M_DELIVERY property.
01313       //
01314       aPropId[PropIdCount] = PROPID_M_DELIVERY;    // PropId
01315       aVariant[PropIdCount].vt = VT_UI1;           // Type
01316       aVariant[PropIdCount].bVal = bDelivery;      // Value
01317
01318       PropIdCount++;
01319
01320       //
01321       // Set the PROPID_M_ACKNOWLEDGE property.
01322       //
01323       aPropId[PropIdCount] = PROPID_M_ACKNOWLEDGE; // PropId
01324       aVariant[PropIdCount].vt = VT_UI1;           // Type
01325       aVariant[PropIdCount].bVal = bAcknowledge;   // Value
01326
01327       PropIdCount++;
01328
01329       //
01330       // Set the PROPID_M_BODY property.
01331       //
01332       aPropId[PropIdCount] = PROPID_M_BODY;                  // PropId
01333       aVariant[PropIdCount].vt = VT_VECTOR|VT_UI1;           // Type
01334       aVariant[PropIdCount].caub.cElems =
01335         (wcslen(szMessageBodyBuffer) + 1) * sizeof(WCHAR); // Value
01336       aVariant[PropIdCount].caub.pElems = (unsigned char *)szMessageBodyBuffer;
01337
01338       PropIdCount++;
01339
01340       //
01341       // Set the PROPID_M_LABEL property.
01342       //
01343       aPropId[PropIdCount] = PROPID_M_LABEL;                  // PropId
01344       aVariant[PropIdCount].vt = VT_LPWSTR;                   // Type
01345       aVariant[PropIdCount].pwszVal = szMessageLabelBuffer;     // Value
01346
01347       PropIdCount++;
01348
01349       //
01350       // Set the PROPID_M_TIME_TO_REACH_QUEUE property.
01351       //
01352       aPropId[PropIdCount] = PROPID_M_TIME_TO_REACH_QUEUE;    // PropId
01353       aVariant[PropIdCount].vt = VT_UI4;                      // Type
01354       aVariant[PropIdCount].ulVal = dwTimeToReachQueue;       // Value
01355
01356       PropIdCount++;
01357
01358       //
01359       // Set the PROPID_M_TIME_TO_BE_RECEIVED property.
01360       //
01361       aPropId[PropIdCount] = PROPID_M_TIME_TO_BE_RECEIVED;    // PropId
01362       aVariant[PropIdCount].vt = VT_UI4;                      // Type
01363       aVariant[PropIdCount].ulVal = dwTimeToBeReceived;       // Value
01364
01365       PropIdCount++;
01366
01367
01368       if (bJournal || bDeadLetter)
01369       {
01370         //
01371         // Set the PROPID_M_JOURNAL property.
01372         //
01373         aPropId[PropIdCount] = PROPID_M_JOURNAL;            // PropId
01374         aVariant[PropIdCount].vt = VT_UI1;                  // Type
01375
01376         if (bJournal)
01377           aVariant[PropIdCount].bVal = MQMSG_JOURNAL;
01378         else
01379           aVariant[PropIdCount].bVal = 0;
01380         if (bDeadLetter)
01381           aVariant[PropIdCount].bVal |= MQMSG_DEADLETTER;
01382
01383         PropIdCount++;
01384       }
01385
01386
01387       if (bAuthenticated)
01388       {
01389         //
01390         // Set the PROPID_M_AUTH_LEVEL property.
01391         //
01392         aPropId[PropIdCount] = PROPID_M_AUTH_LEVEL;            // PropId
01393         aVariant[PropIdCount].vt = VT_UI4;                     // Type
01394         aVariant[PropIdCount].ulVal = MQMSG_AUTH_LEVEL_ALWAYS; // Value
01395
01396         PropIdCount++;
01397       }
01398
01399       if (bEncrypted)
01400       {
01401         //
01402         // Set the PROPID_M_ENCRYPTION_ALG property.
01403         //
01404         aPropId[PropIdCount] = PROPID_M_PRIV_LEVEL;                 // PropId
01405         aVariant[PropIdCount].vt = VT_UI4;                          // Type
01406         aVariant[PropIdCount].ulVal = MQMSG_PRIV_LEVEL_BODY_BASE;   // Value
01407
01408         PropIdCount++;
01409       }
01410
01411
01412       //
01413       // Set the PROPID_M_ADMIN_QUEUE property.
01414       //
01415       if (szAdminFormatNameBuffer[0] != 0)
01416       {
01417         aPropId[PropIdCount] = PROPID_M_ADMIN_QUEUE;               // PropId
01418         aVariant[PropIdCount].vt = VT_LPWSTR;                      // Type
01419       #ifdef UNICODE
01420         aVariant[PropIdCount].pwszVal = szAdminFormatNameBuffer;   // Value
01421       #else
01422         WCHAR szwAdminFormatNameBuffer[MAX_Q_FORMATNAME_LEN];
01423         size_t rc = mbstowcs(szwAdminFormatNameBuffer,
01424                 szAdminFormatNameBuffer,
01425                 _tcslen(szAdminFormatNameBuffer)+1);
01426         if (rc == (size_t)(-1))
01427         {
01428           AfxMessageBox("An unsupported wide character was encountered. Exiting...");
01429           exit(1);
01430         }
01431         aVariant[PropIdCount].pwszVal = szwAdminFormatNameBuffer;  // Value
01432       #endif
01433
01434       PropIdCount++;
01435       }
01436       //
01437       // Initialize the MQMSGPROPS structure.
01438       //
01439       MsgProps.cProp = PropIdCount;       // Number of properties
01440       MsgProps.aPropID = aPropId;         // Identifiers of properties
01441       MsgProps.aPropVar = aVariant;       // Value of properties
01442       MsgProps.aStatus  = NULL;           // No error report
01443
01444       //
01445       // Send the message.
01446       //
01447       hr = MQSendMessage(
01448           hQueue,                     // Handle to the queue.
01449           &MsgProps,                  // Message properties to be sent
01450           NULL                        // No transaction
01451           );
01452
01453       if (FAILED(hr))
01454       {
01455         //
01456         // An error occurred, so display a message.
01457         //
01458         _stprintf(szMsgBuffer, TEXT("MQSendMessage failed. Error code: 0x%x."),hr);
01459         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01460       }
01461       else
01462       {
01463         //
01464         // Success was achieved, so write in the edit control.
01465         //
01466         _stprintf(szMsgBuffer, TEXT("The Message \"%s\" was sent successfully."), szLastMessageLabel);
01467         PrintToScreen(szMsgBuffer);
01468       }
01469     }
01470
01471     /* ************************************************************************ */
01472     /*                           OnApiReceiveMessage                            */
01473     /* ************************************************************************ */
01474     /* This function opens a dialog box and asks the user for the queue's       */
01475     /* path name and the time to wait for the message. Then it tries to get a   */
01476     /* message from the specified queue within the given time.                  */
01477     /*                                                                          */
01478     /* Uses: MQReceiveMessage, MQFreeMemory.                                    */
01479     /* ************************************************************************ */
01480     void CMainFrame::OnApiReceiveMessage()
01481     {
01482       TCHAR szPathNameBuffer[MAX_Q_PATHNAME_LEN];
01483       TCHAR szMsgBuffer[2*BUFFERSIZE];
01484       TCHAR szDomainName[BUFFERSIZE];
01485        TCHAR szAccountName[BUFFERSIZE];
01486       DWORD dwActNameSize = sizeof(szAccountName);
01487       DWORD dwDomNameSize = sizeof(szDomainName);
01488       TCHAR szTextSid[BUFFERSIZE];
01489       DWORD dwTextSidSize = sizeof(szTextSid);
01490       BYTE  blobBuffer[BUFFERSIZE];
01491
01492       MQMSGPROPS MsgProps;
01493       MQPROPVARIANT aVariant[MAXINDEX];
01494       MSGPROPID aPropId[MAXINDEX];
01495       DWORD PropIdCount = 0;
01496
01497       HRESULT hr;
01498
01499       WCHAR szMessageLabelBuffer[BUFFERSIZE];
01500       DWORD dwTimeout;
01501
01502       QUEUEHANDLE hQueue;
01503
01504       CReceiveWaitDialog    WaitDialog;
01505       CReceiveMessageDialog ReceiveMessageDialog(&m_OpenedQueuePathNameArray);
01506
01507       //
01508       // Display the Receive Message dialog box.
01509       //
01510       if (ReceiveMessageDialog.DoModal() == IDCANCEL)
01511       {
01512         return;
01513       }
01514
01515       ReceiveMessageDialog.DestroyWindow();
01516       ReceiveMessageDialog.GetPathName(szPathNameBuffer);
01517
01518       //
01519       // Get the queue handle.
01520       //
01521       if (GetQueueHandle(szPathNameBuffer, &hQueue) == FALSE)
01522       {
01523         //
01524         // An error occurred, so display a message.
01525         //
01526         _stprintf(szMsgBuffer, TEXT("GetQueueHandle failed. The queue was not found in array of opened queues."));
01527         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01528         return;
01529       }
01530
01531       //
01532       // Retrieve the properties form the dialog box.
01533       //
01534       dwTimeout = ReceiveMessageDialog.GetTimeout();
01535
01536
01537       //
01538       // Prepare the property array PROPVARIANT of
01539       // message properties that we want to receive.
01540       //
01541
01542       //
01543       // Set the PROPID_M_BODY property.
01544       //
01545       aPropId[PropIdCount] = PROPID_M_BODY;                                // PropId
01546       aVariant[PropIdCount].vt = VT_VECTOR|VT_UI1;                         // Type
01547       aVariant[PropIdCount].caub.cElems = ReceiveMessageDialog.GetBodySize();
01548       aVariant[PropIdCount].caub.pElems = (unsigned char *) new
01549                      char [ aVariant[PropIdCount].caub.cElems ];
01550
01551       int iBodyIndex = PropIdCount;
01552       PropIdCount++;
01553
01554       //
01555       // Set the PROPID_M_LABEL property.
01556       //
01557       aPropId[PropIdCount] = PROPID_M_LABEL;                   // PropId
01558       aVariant[PropIdCount].vt = VT_LPWSTR;                    // Type
01559       aVariant[PropIdCount].pwszVal = szMessageLabelBuffer;
01560
01561       PropIdCount++;
01562
01563       //
01564       // Set the PROPID_M_PRIORITY property.
01565       //
01566       aPropId[PropIdCount] = PROPID_M_PRIORITY;               // PropId
01567       aVariant[PropIdCount].vt = VT_UI1;                      // Type
01568
01569       PropIdCount++;
01570
01571       //
01572       // Set the PROPID_M_CLASS property.
01573       //
01574       aPropId[PropIdCount] = PROPID_M_CLASS;                  // PropId
01575       aVariant[PropIdCount].vt = VT_UI2;                      // Type
01576
01577       PropIdCount++;
01578
01579       //
01580       // Set the PROPID_M_AUTHENTICATED property.
01581       //
01582       aPropId[PropIdCount] = PROPID_M_AUTHENTICATED;          // PropId
01583       aVariant[PropIdCount].vt = VT_UI1;                      // Type
01584
01585       PropIdCount++;
01586
01587       //
01588       // Set the PROPID_M_SENDERID property.
01589       //
01590       aPropId[PropIdCount] = PROPID_M_SENDERID;               // PropId
01591       aVariant[PropIdCount].vt = VT_UI1|VT_VECTOR;            // Type
01592       aVariant[PropIdCount].blob.pBlobData = blobBuffer;
01593       aVariant[PropIdCount].blob.cbSize = sizeof(blobBuffer);
01594
01595       PropIdCount++;
01596
01597       //
01598       // Set the PROPID_M_PRIV_LEVEL property.
01599       //
01600       aPropId[PropIdCount] = PROPID_M_PRIV_LEVEL;             // PropId
01601       aVariant[PropIdCount].vt = VT_UI4;                      // Type
01602
01603       PropIdCount++;
01604
01605       //
01606       // Set the PROPID_M_LABEL_LEN property.
01607       //
01608       aPropId[PropIdCount] = PROPID_M_LABEL_LEN;              // PropId
01609       aVariant[PropIdCount].vt = VT_UI4;                      // Type
01610       aVariant[PropIdCount].ulVal = BUFFERSIZE;               // Value
01611
01612       PropIdCount++;
01613
01614
01615       //
01616       // Initialize the MQMSGPROPS structure.
01617       //
01618       MsgProps.cProp = PropIdCount;       // Number of properties
01619       MsgProps.aPropID = aPropId;         // Identifiers of properties
01620       MsgProps.aPropVar = aVariant;       // Value of properties
01621       MsgProps.aStatus  = NULL;           // No error report
01622
01623       //
01624       // Display a message window until the message is received from the queue.
01625       //
01626       WaitDialog.Create(IDD_WAIT_DIALOG,pMainView);
01627       WaitDialog.ShowWindow(SW_SHOWNORMAL);
01628       WaitDialog.UpdateWindow();
01629       WaitDialog.CenterWindow();
01630       pMainView->RedrawWindow();
01631
01632       //
01633       // Receive the message.
01634       //
01635       hr = MQReceiveMessage(
01636              hQueue,               // Handle to the queue
01637              dwTimeout,            // Max time (msec) to wait for the message
01638              MQ_ACTION_RECEIVE,    // Action
01639              &MsgProps,            // Properties to retrieve
01640              NULL,                 // No OVERLAPPED structure
01641              NULL,                 // No callback function
01642              NULL,                 // No cursor
01643              NULL                  // No transaction
01644              );
01645
01646       WaitDialog.ShowWindow(SW_HIDE);
01647
01648
01649       if(hr == MQ_ERROR_IO_TIMEOUT)
01650       {
01651         _stprintf(szMsgBuffer, TEXT("MQReceiveMessage failed, The time-out period expired."));
01652         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01653       }
01654       else if(hr != MQ_OK)
01655       {
01656         //
01657         // An error occurred, so display a message.
01658         //
01659         _stprintf(szMsgBuffer, TEXT("MQReceiveMessage failed. Error code: 0x%x."),hr);
01660         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01661       }
01662       else
01663       {
01664         //
01665         // Success was achieved, so write in the edit control.
01666         //
01667         ClassToString(aVariant[3].uiVal,szMsgBuffer);
01668         PrintToScreen(szMsgBuffer);
01669
01670         //
01671         // Print some of the message properties.
01672         //
01673     #ifdef UNICODE
01674         _stprintf(szMsgBuffer, TEXT("\tLabel: %s"), (WCHAR *)(aVariant[1].pwszVal));
01675     #else
01676         {
01677           PCHAR lpLable = UnicodeStringToAnsiString((WCHAR *)(aVariant[1].pwszVal));
01678           _stprintf(szMsgBuffer, TEXT("\tLabel: %s"), lpLable);
01679           delete [] lpLable;
01680         }
01681     #endif
01682         PrintToScreen(szMsgBuffer);
01683
01684         //
01685         // Print the body only if the message is not an acknowledgment or report message.
01686         // (This is done because there is no message body in acknowledgment messages.)
01687         //
01688         if (aVariant[3].bVal == MQMSG_CLASS_NORMAL)
01689         {
01690     #ifdef UNICODE
01691           _stprintf(szMsgBuffer, TEXT("\tBody : %s"), (WCHAR *)(aVariant[0].caub.pElems));
01692     #else
01693           {
01694             PCHAR pBody = UnicodeStringToAnsiString((WCHAR *)(aVariant[0].caub.pElems));
01695             _stprintf(szMsgBuffer, TEXT("\tBody : %s"), pBody);
01696             delete [] pBody;
01697           }
01698     #endif
01699           PrintToScreen(szMsgBuffer);
01700         }
01701
01702         _stprintf(szMsgBuffer, TEXT("\tPriority : %d"), aVariant[2].bVal);
01703         PrintToScreen(szMsgBuffer);
01704
01705
01706         //
01707         // Print Sender ID
01708         //
01709         //
01710         // See if we're running on NT or Win95.
01711         //
01712         OSVERSIONINFO OsVerInfo;
01713
01714         OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
01715         GetVersionEx(&OsVerInfo);
01716
01717         if (OsVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
01718         {
01719           //
01720           //  On NT
01721           //
01722           SID_NAME_USE peUse;
01723           if (LookupAccountSid(NULL,
01724                      blobBuffer,
01725                      szAccountName,
01726                      &dwActNameSize,
01727                      szDomainName,
01728                      &dwDomNameSize,
01729                      &peUse) )
01730           {
01731             _stprintf(szMsgBuffer, TEXT("\tUser: %s\\%s"), szDomainName, szAccountName);
01732             PrintToScreen(szMsgBuffer);
01733           }
01734         }
01735         else
01736         {
01737           //
01738           // LookupAccountSid is not implemented on Win95,
01739           // Instead print the textual SID.
01740           //
01741           if ( GetTextualSid((PSID)blobBuffer, szTextSid, &dwTextSidSize))
01742           {
01743             _stprintf(szMsgBuffer, TEXT("\tUser SID : %s"), szTextSid);
01744             PrintToScreen(szMsgBuffer);
01745           }
01746         }
01747         //
01748         // Print "authenticated" or "not authenticated."
01749         //
01750         if (aVariant[4].bVal)
01751           PrintToScreen(TEXT("\tMessage is authenticated."));
01752         else
01753           PrintToScreen(TEXT("\tMessage is not authenticated."));
01754
01755
01756         //
01757         // Print "encrypted" or "not encrypted."
01758         //
01759         if (aVariant[6].ulVal)
01760           PrintToScreen(TEXT("\tMessage is encrypted."));
01761         else
01762           PrintToScreen(TEXT("\tMessage is not Encrypted."));
01763        }
01764
01765        delete aVariant[ iBodyIndex ].caub.pElems;
01766     }
01767
01768     /* ************************************************************************ */
01769     /*                               OnApiLocate                                */
01770     /* ************************************************************************ */
01771     /* This function opens a dialog box and asks the user to give a label. Then */
01772     /* it locates all the queues in the DS with a matching label.               */
01773     /* The function updates the path name array with those queues.              */
01774     /*                                                                          */
01775     /* Uses: MQLocateBegin, MQLocateNext, MQLocateEnd,                          */
01776     /*       MQInstanceToFormatName, MQFreeMemory.                              */
01777     /* ************************************************************************ */
01778     void CMainFrame::OnApiLocate()
01779     {
01780       // TODO: Add your command handler code here.
01781       TCHAR szMsgBuffer[BUFFERSIZE];
01782       TCHAR szLabelBuffer[BUFFERSIZE];
01783
01784       HRESULT hr;
01785
01786       MQPROPERTYRESTRICTION PropertyRestriction;
01787       MQRESTRICTION  Restriction;
01788       MQCOLUMNSET    Column;
01789       QUEUEPROPID    aPropId[2]; // only two properties to retrieve
01790       HANDLE         hEnum;
01791       DWORD       cQueue;
01792       MQPROPVARIANT   aPropVar[MAX_VAR] = {0};
01793       ARRAYQ*         pArrayQ;
01794       DWORD       i;
01795       DWORD           dwColumnCount = 0;
01796       DWORD dwFormatNameLength = MAX_Q_FORMATNAME_LEN;
01797
01798       CLocateDialog LocateDialog;
01799
01800       //
01801       // Display the Receive Message dialog box.
01802       //
01803       if (LocateDialog.DoModal() == IDCANCEL)
01804       {
01805         return;
01806       }
01807
01808       //
01809       // Retrieve the label from the dialog box.
01810       //
01811       LocateDialog.GetLabel(szLabelBuffer);
01812
01813       //
01814       // Clean the path name array before locating queues.
01815       //
01816       CleanPathNameArray();
01817
01818       //
01819       // Prepare parameters for locating queues.
01820       //
01821
01822       //
01823       // Prepare a property restriction.
01824       // Restriction: All queues with PROPID_Q_LABEL equal to "MQ API test."
01825       //
01826       PropertyRestriction.rel = PREQ;
01827       PropertyRestriction.prop = PROPID_Q_LABEL;
01828       PropertyRestriction.prval.vt = VT_LPWSTR;
01829     #ifdef UNICODE
01830       PropertyRestriction.prval.pwszVal = szLabelBuffer;
01831     #else
01832       DWORD size = _tcslen(szLabelBuffer) +1;
01833       PropertyRestriction.prval.pwszVal = new WCHAR[size];
01834       AnsiStringToUnicode(PropertyRestriction.prval.pwszVal, szLabelBuffer,size);
01835     #endif
01836
01837       //
01838       // Prepare a restriction with one property restriction.
01839       //
01840       Restriction.cRes = 1;
01841       Restriction.paPropRes = &PropertyRestriction;
01842
01843       //
01844       // Specify the properties that should be returned by the query.
01845       // Only the path name is important.
01846       //
01847       aPropId[dwColumnCount] = PROPID_Q_PATHNAME;
01848       dwColumnCount++;
01849
01850       aPropId[dwColumnCount] = PROPID_Q_INSTANCE;
01851       dwColumnCount++;
01852
01853       Column.cCol = dwColumnCount;
01854       Column.aCol = aPropId;
01855
01856       //
01857       // Run the query to locate the queues.
01858       //
01859       hr = MQLocateBegin(
01860           NULL,           // Start search at the top.
01861           &Restriction,   // Restriction
01862           &Column,        // Properties to be retrieved
01863           NULL,           // No sort order
01864           &hEnum          // Enumeration handle
01865           );
01866
01867       if(FAILED(hr))
01868       {
01869         //
01870         // An error occurred, so display a message.
01871         //
01872         _stprintf(szMsgBuffer,
01873           TEXT("MQLocateBegin failed. Error code: 0x%x."),hr);
01874         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01875         return;
01876       }
01877
01878       //
01879       // Get the results.
01880       //
01881       cQueue = MAX_VAR;
01882
01883       //
01884       // If cQueue == 0, no Variants were retrieved in the last call to MQLocateNext.
01885       //
01886       while (cQueue != 0)
01887       {
01888         hr = MQLocateNext(
01889             hEnum,      // Handle returned by MQLocateBegin
01890             &cQueue,    // Size of aPropVar
01891             aPropVar    // OUT: an array of MQPROPVARIANT for receiving the results
01892             );
01893
01894         if(FAILED(hr))
01895         {
01896           //
01897           // An error occurred, so display a message.
01898           //
01899           _stprintf(szMsgBuffer,
01900             TEXT("MQLocateNext failed. Error code: 0x%x."),hr);
01901           MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01902           return;
01903         }
01904
01905         for (i=0; i<cQueue; i++)
01906         {
01907           //
01908           // Add the new path names to the path name array.
01909           //
01910           pArrayQ = new ARRAYQ;
01911           if (!pArrayQ)
01912             return;
01913
01914     #ifdef UNICODE
01915           wcsncpy (pArrayQ->szPathName, aPropVar[i].pwszVal, MAX_Q_PATHNAME_LEN-1);
01916           pArrayQ->szPathName[MAX_Q_PATHNAME_LEN - 1] = '\0';
01917
01918     #else
01919           size_t rc = wcstombs(pArrayQ->szPathName, aPropVar[i].pwszVal, MAX_Q_PATHNAME_LEN-1);
01920           if (rc == (size_t)(-1))
01921           {
01922             AfxMessageBox("An unsupported wide character was encountered. Ignoring queue.");
01923             MQFreeMemory(aPropVar[i].pwszVal);
01924             i = i + 1;
01925             delete pArrayQ;
01926             continue;
01927           }
01928     #endif
01929
01930
01931           //
01932           // Free the memory allocated by MSMQ.
01933           //
01934           MQFreeMemory(aPropVar[i].pwszVal);
01935
01936
01937           //
01938           // Move to the next property.
01939           //
01940           i = i + 1;
01941
01942           //
01943           // Get the format name of the queue and add the queue to the path name array.
01944           //
01945     #ifdef UNICODE
01946           hr = MQInstanceToFormatName(aPropVar[i].puuid, pArrayQ->szFormatName, &dwFormatNameLength);
01947     #else
01948           WCHAR szwFormatNameBuffer[MAX_Q_FORMATNAME_LEN];
01949           hr = MQInstanceToFormatName(aPropVar[i].puuid, szwFormatNameBuffer, &dwFormatNameLength);
01950           if (SUCCEEDED(hr))
01951           {
01952             size_t rwc = wcstombs(pArrayQ->szFormatName, szwFormatNameBuffer, dwFormatNameLength);
01953             if (rwc == (size_t)(-1))
01954             {
01955               AfxMessageBox("An unsupported wide character was encountered. Exiting...");
01956               exit(1);
01957             }
01958           }
01959     #endif
01960
01961           if(FAILED(hr))
01962           {
01963             //
01964             // An error occurred, so display a message.
01965             //
01966             _stprintf (szMsgBuffer,
01967               TEXT("MQInstanceToFormatName failed. Error code: 0x%x."),hr);
01968             MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01969           }
01970
01971           //
01972           // Add the new queue to the path name array.
01973           //
01974           Add2PathNameArray(pArrayQ);
01975         }
01976       }
01977
01978       //
01979       // End the locate operation.
01980       //
01981       hr = MQLocateEnd(hEnum);   // handle returned by MQLocateBegin
01982       if(FAILED(hr))
01983       {
01984         //
01985         // An error occurred, so display a message.
01986         //
01987         _stprintf (szMsgBuffer,
01988           TEXT("MQLocateEnd failed. Error code: 0x%x."),hr);
01989         MessageBox(szMsgBuffer, TEXT("ERROR"), MB_OK);
01990         return;
01991       }
01992
01993       //
01994       // Display the queues found during the query.
01995       //
01996       _stprintf (szMsgBuffer, TEXT("Locate Operation completed successfully"));
01997       PrintToScreen(szMsgBuffer);
01998       UpdatePathNameArrays();
01999       DisplayPathNameArray();
02000       DisplayOpenedQueuePathNameArray();
02001     }
02002
02003     /* ************************************************************************ */
02004     /*                           OnUpdateFrameTitle                             */
02005     /* ************************************************************************ */
02006     void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
02007     {
02008       SetWindowText (TEXT("MQ API test"));
02009     }
02010
02011
02012 BOOL CMainFrame::IsFormatName(TCHAR *pszName)
02013 {
02014   int Index;
02015   int MaxIndex = m_OpenedQueuePathNameArray.GetSize();
02016
02017   for (Index=0; Index<MaxIndex; Index++)
02018   {
02019     if (_tcscmp(pszName, m_OpenedQueuePathNameArray[Index]->szFormatName) == 0)
02020     {
02021       return TRUE;
02022     }
02023   }
02024
02025   MaxIndex=m_PathNameArray.GetSize();
02026   for (Index=0; Index<MaxIndex; Index++)
02027   {
02028     if (_tcscmp(pszName, m_PathNameArray[Index]->szFormatName) == 0)
02029     {
02030       return TRUE;
02031     }
02032   }
02033   return FALSE;
02034 }
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nodes/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • Nodes

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CGetReceipt Member List

This is the complete list of members for CGetReceipt, including all inherited members.
CGetReceipt() | CGetReceipt | [inline]
CGetReceipt() | CGetReceipt | [inline]
GetNextReceipt(OUT long *plReceiptNo) | CGetReceipt |
GetNextReceipt(OUT long *plReceiptNo) | CGetReceipt |
InterfaceSupportsErrorInfo(REFIID riid) | CGetReceipt |
InterfaceSupportsErrorInfo(REFIID riid) | CGetReceipt |
Generated on Wed Nov 13 2024 16:56:37 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/About/basesnap.Cpp Source File

  • SysMgmt
  • MMC
  • About

basesnap.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #include <objbase.h>
00020 #include <olectl.h>
00021 #include <initguid.h>
00022 #include "guids.h"
00023 #include "basesnap.h"
00024 #include "Comp.h"
00025 #include "CompData.h"
00026 #include "About.h"
00027 #include "Registry.h"
00028
00029 // our globals
00030 HINSTANCE g_hinst;
00031
00032 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
00033                     DWORD fdwReason,
00034                     void* lpvReserved)
00035 {
00036
00037     if (fdwReason == DLL_PROCESS_ATTACH) {
00038         g_hinst = hinstDLL;
00039     }
00040
00041     return TRUE;
00042 }
00043
00044
00045 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
00046 {
00047     if ((rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout))
00048         return CLASS_E_CLASSNOTAVAILABLE;
00049
00050
00051     if (!ppvObj)
00052         return E_FAIL;
00053
00054     *ppvObj = NULL;
00055
00056     // We can only hand out IUnknown and IClassFactory pointers.  Fail
00057     // if they ask for anything else.
00058     if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
00059         return E_NOINTERFACE;
00060
00061     CClassFactory *pFactory = NULL;
00062
00063     // make the factory passing in the creation function for the type of object they want
00064     if (rclsid == CLSID_CComponentData)
00065         pFactory = new CClassFactory(CClassFactory::COMPONENT);
00066     else if (rclsid == CLSID_CSnapinAbout)
00067         pFactory = new CClassFactory(CClassFactory::ABOUT);
00068
00069     if (NULL == pFactory)
00070         return E_OUTOFMEMORY;
00071
00072     HRESULT hr = pFactory->QueryInterface(riid, ppvObj);
00073
00074     return hr;
00075 }
00076
00077 STDAPI DllCanUnloadNow(void)
00078 {
00079     if (g_uObjects == 0 && g_uSrvLock == 0)
00080         return S_OK;
00081     else
00082         return S_FALSE;
00083 }
00084
00085
00086 CClassFactory::CClassFactory(FACTORY_TYPE factoryType)
00087 : m_cref(0), m_factoryType(factoryType)
00088 {
00089     OBJECT_CREATED
00090 }
00091
00092 CClassFactory::~CClassFactory()
00093 {
00094     OBJECT_DESTROYED
00095 }
00096
00097 STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppv)
00098 {
00099     if (!ppv)
00100         return E_FAIL;
00101
00102     *ppv = NULL;
00103
00104     if (IsEqualIID(riid, IID_IUnknown))
00105         *ppv = static_cast<IClassFactory *>(this);
00106     else
00107         if (IsEqualIID(riid, IID_IClassFactory))
00108             *ppv = static_cast<IClassFactory *>(this);
00109
00110         if (*ppv)
00111         {
00112             reinterpret_cast<IUnknown *>(*ppv)->AddRef();
00113             return S_OK;
00114         }
00115
00116         return E_NOINTERFACE;
00117 }
00118
00119 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00120 {
00121     return InterlockedIncrement((LONG *)&m_cref);
00122 }
00123
00124 STDMETHODIMP_(ULONG) CClassFactory::Release()
00125 {
00126     if (InterlockedDecrement((LONG *)&m_cref) == 0)
00127     {
00128         delete this;
00129         return 0;
00130     }
00131     return m_cref;
00132 }
00133
00134 STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID * ppvObj)
00135 {
00136     HRESULT  hr;
00137     void* pObj;
00138
00139     if (!ppvObj)
00140         return E_FAIL;
00141
00142     *ppvObj = NULL;
00143
00144     // Our object does does not support aggregation, so we need to
00145     // fail if they ask us to do aggregation.
00146     if (pUnkOuter)
00147         return CLASS_E_NOAGGREGATION;
00148
00149     if (COMPONENT == m_factoryType) {
00150         pObj = new CComponentData();
00151     } else {
00152         pObj = new CSnapinAbout();
00153     }
00154
00155     if (!pObj)
00156         return E_OUTOFMEMORY;
00157
00158     // QueryInterface will do the AddRef() for us, so we do not
00159     // do it in this function
00160     hr = ((LPUNKNOWN)pObj)->QueryInterface(riid, ppvObj);
00161
00162     if (FAILED(hr))
00163         delete pObj;
00164
00165     return hr;
00166 }
00167
00168 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00169 {
00170     if (fLock)
00171         InterlockedIncrement((LONG *)&g_uSrvLock);
00172     else
00173         InterlockedDecrement((LONG *)&g_uSrvLock);
00174
00175     return S_OK;
00176 }
00177
00178 //////////////////////////////////////////////////////////
00179 //
00180 // Exported functions
00181 //
00182
00183
00184 //
00185 // Server registration
00186 //
00187 STDAPI DllRegisterServer()
00188 {
00189     HRESULT hr = SELFREG_E_CLASS;
00190     _TCHAR szName[256];
00191     _TCHAR szSnapInName[256];
00192
00193     LoadString(g_hinst, IDS_NAME, szName, (sizeof szName)/(sizeof szName[0]));
00194     LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, (sizeof szSnapInName)/(sizeof szSnapInName[0]));
00195
00196     _TCHAR szAboutName[256];
00197
00198     LoadString(g_hinst, IDS_ABOUTNAME, szAboutName, (sizeof szAboutName)/(sizeof szAboutName[0]));
00199
00200     // register our CoClasses
00201     hr = RegisterServer(g_hinst,
00202         CLSID_CComponentData,
00203         szName);
00204
00205     if SUCCEEDED(hr)
00206         hr = RegisterServer(g_hinst,
00207         CLSID_CSnapinAbout,
00208         szAboutName);
00209
00210     // place the registry information for SnapIns
00211     if SUCCEEDED(hr)
00212         hr = RegisterSnapin(CLSID_CComponentData, szSnapInName, CLSID_CSnapinAbout, FALSE);
00213
00214     return hr;
00215 }
00216
00217
00218 STDAPI DllUnregisterServer()
00219 {
00220     if (UnregisterServer(CLSID_CComponentData) == S_OK)
00221         return UnregisterSnapin(CLSID_CComponentData);
00222     else
00223         return E_FAIL;
00224 }
00225
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Shell/SampView/ExtrIcon.Cpp Source File

  • WinUI
  • Shell
  • SampView

ExtrIcon.Cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 1998 - 2000 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          ExtrIcon.cpp
00013
00014    Description:   Implements CExtractIcon.
00015
00016 **************************************************************************/
00017
00018 /**************************************************************************
00019    #include statements
00020 **************************************************************************/
00021
00022 #include "ExtrIcon.h"
00023
00024 /**************************************************************************
00025
00026    CExtractIcon::CExtractIcon()
00027
00028 **************************************************************************/
00029
00030 CExtractIcon::CExtractIcon(LPCITEMIDLIST pidl)
00031 {
00032 g_DllRefCount++;
00033
00034 m_pPidlMgr = new CPidlMgr();
00035 if(!m_pPidlMgr)
00036    {
00037    delete this;
00038    return;
00039    }
00040
00041 m_pidl = m_pPidlMgr->Copy(pidl);
00042
00043 m_ObjRefCount = 1;
00044 }
00045
00046 /**************************************************************************
00047
00048    CExtractIcon::~CExtractIcon()
00049
00050 **************************************************************************/
00051
00052 CExtractIcon::~CExtractIcon()
00053 {
00054 if(m_pidl)
00055    {
00056    m_pPidlMgr->Delete(m_pidl);
00057    m_pidl = NULL;
00058    }
00059
00060 if(m_pPidlMgr)
00061    {
00062    delete m_pPidlMgr;
00063    }
00064
00065 g_DllRefCount--;
00066 }
00067
00068 ///////////////////////////////////////////////////////////////////////////
00069 //
00070 // IUnknown Implementation
00071 //
00072
00073 /**************************************************************************
00074
00075    CExtractIcon::QueryInterface
00076
00077 **************************************************************************/
00078
00079 STDMETHODIMP CExtractIcon::QueryInterface(REFIID riid, LPVOID *ppReturn)
00080 {
00081 *ppReturn = NULL;
00082
00083 //IUnknown
00084 if(IsEqualIID(riid, IID_IUnknown))
00085    {
00086    *ppReturn = this;
00087    }
00088
00089 //IExtractIcon
00090 else if(IsEqualIID(riid, IID_IExtractIcon))
00091    {
00092    *ppReturn = (IExtractIcon*)this;
00093    }
00094
00095 if(*ppReturn)
00096    {
00097    (*(LPUNKNOWN*)ppReturn)->AddRef();
00098    return S_OK;
00099    }
00100
00101 return E_NOINTERFACE;
00102 }
00103
00104 /**************************************************************************
00105
00106    CExtractIcon::AddRef
00107
00108 **************************************************************************/
00109
00110 STDMETHODIMP_(DWORD) CExtractIcon::AddRef()
00111 {
00112 return ++m_ObjRefCount;
00113 }
00114
00115 /**************************************************************************
00116
00117    CExtractIcon::Release
00118
00119 **************************************************************************/
00120
00121 STDMETHODIMP_(DWORD) CExtractIcon::Release()
00122 {
00123 if(--m_ObjRefCount == 0)
00124    {
00125    delete this;
00126    return 0;
00127    }
00128
00129 return m_ObjRefCount;
00130 }
00131
00132 ///////////////////////////////////////////////////////////////////////////
00133 //
00134 // IExtractIcon Implementation
00135 //
00136
00137 /**************************************************************************
00138
00139    CExtractIcon::GetIconLocation()
00140
00141 **************************************************************************/
00142
00143 STDMETHODIMP CExtractIcon::GetIconLocation(  UINT uFlags,
00144                                              LPTSTR szIconFile,
00145                                              UINT cchMax,
00146                                              LPINT piIndex,
00147                                              LPUINT puFlags)
00148 {
00149 //tell the shell to always call Extract
00150 *puFlags = GIL_NOTFILENAME;
00151
00152 //the pidl is either a value or a folder, so find out which it is
00153 if(m_pPidlMgr->IsFolder(m_pPidlMgr->GetLastItem(m_pidl)))
00154    {
00155    //its a folder
00156    if(uFlags & GIL_OPENICON)
00157       {
00158       //tell Extract to return the open folder icon
00159       *piIndex = ICON_INDEX_FOLDEROPEN;
00160       }
00161    else
00162       {
00163       //tell Extract to return the closed folder icon
00164       *piIndex = ICON_INDEX_FOLDER;
00165       }
00166    }
00167 else
00168    {
00169    //its not a folder
00170    *piIndex = ICON_INDEX_ITEM;  //tell Extract to return the item icon
00171    }
00172
00173 return S_OK;
00174 }
00175
00176 /**************************************************************************
00177
00178    CExtractIcon::Extract()
00179
00180 **************************************************************************/
00181
00182 STDMETHODIMP CExtractIcon::Extract( LPCTSTR pszFile,
00183                                     UINT nIconIndex,
00184                                     HICON *phiconLarge,
00185                                     HICON *phiconSmall,
00186                                     UINT nIconSize)
00187 {
00188 *phiconLarge = ImageList_GetIcon(g_himlLarge, nIconIndex, ILD_TRANSPARENT);
00189 *phiconSmall = ImageList_GetIcon(g_himlSmall, nIconIndex, ILD_TRANSPARENT);
00190
00191 return S_OK;
00192 }
00193
Generated on Wed Nov 13 2024 16:52:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RRas/ip/ipsample.c Source File

  • NetDS
  • RRas
  • ip

ipsample.c

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 1999 - 2000 Microsoft Corporation
00004
00005 Module Name:
00006
00007     sample\ipsample.c
00008
00009 Abstract:
00010
00011     The file contains the entry point to the ip sample protocol's dll.
00012
00013 --*/
00014
00015 #include "pchsample.h"
00016 #pragma hdrstop
00017
00018 #define SAMPLEAPI __declspec(dllexport)
00019 #include "ipsample.h"
00020
00021 BOOL
00022 WINAPI
00023 DllMain(
00024     IN  HINSTANCE hInstance,
00025     IN  DWORD dwReason,
00026     IN  PVOID pvImpLoad
00027     )
00028
00029 /*++
00030
00031 Routine Description
00032     DLL entry and exit point handler.
00033     It calls CE_Initialize to initialize the configuration entry...
00034     It calls CD_Cleanup to cleanup the configuration entry...
00035
00036 Locks
00037     None
00038
00039 Arguments
00040     hInstance   Instance handle of DLL
00041     dwReason    Reason function called
00042     pvImpLoad   Implicitly loaded DLL?
00043
00044 Return Value
00045     TRUE        Successfully loaded DLL
00046
00047 --*/
00048
00049 {
00050     BOOL bError = TRUE;
00051
00052     UNREFERENCED_PARAMETER(hInstance);
00053     UNREFERENCED_PARAMETER(pvImpLoad);
00054
00055     switch(dwReason)
00056     {
00057         case DLL_PROCESS_ATTACH:
00058             DisableThreadLibraryCalls(hInstance);
00059             bError = (CE_Create(&g_ce) is NO_ERROR) ? TRUE : FALSE;
00060
00061             break;
00062
00063         case DLL_PROCESS_DETACH:
00064             CE_Destroy(&g_ce);
00065
00066             break;
00067
00068         default:
00069
00070             break;
00071     }
00072
00073     return bError;
00074 }
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/ISAPI_6.0/DumpRequestInfo/DumpRequestInfo.cpp Source File

  • Web
  • iis
  • ISAPI_6.0
  • DumpRequestInfo

DumpRequestInfo.cpp

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (c) 2003  Microsoft Corporation
00004
00005 Module Name: DumpRequestInfo.cpp
00006
00007 Abstract:
00008
00009     ISAPI extension that dumps all information from
00010     an HTTP request.
00011
00012     This sample also demonstrates use of the ISAREQUEST
00013     object to asynchronously send a buffered response.
00014
00015 Author:
00016
00017     ISAPI developer (Microsoft employee), October 2002
00018
00019 --*/
00020
00021 #ifndef _WIN32_WINNT
00022 #define _WIN32_WINNT 0x0500
00023 #endif
00024
00025 #include <windows.h>
00026 #include <IsapiTools.h>
00027
00028 //
00029 // An array of server variables
00030 //
00031 // Note that this list comprises all of the available
00032 // built-in server variables in the original release
00033 // of IIS 6.
00034 //
00035
00036 #define MAX_VAR_NAME    64
00037
00038 CHAR    g_rgVariableList[][MAX_VAR_NAME] = { "APP_POOL_ID",
00039                                              "APPL_MD_PATH",
00040                                              "APPL_PHYSICAL_PATH",
00041                                              "AUTH_PASSWORD",
00042                                              "AUTH_TYPE",
00043                                              "AUTH_USER",
00044                                              "CACHE_URL",
00045                                              "CERT_COOKIE",
00046                                              "CERT_FLAGS",
00047                                              "CERT_ISSUER",
00048                                              "CERT_KEYSIZE",
00049                                              "CERT_SECRETKEYSIZE",
00050                                              "CERT_SERIALNUMBER",
00051                                              "CERT_SERVER_ISSUER",
00052                                              "CERT_SERVER_SUBJECT",
00053                                              "CERT_SUBJECT",
00054                                              "CONTENT_LENGTH",
00055                                              "CONTENT_TYPE",
00056                                              "GATEWAY_INTERFACE",
00057                                              "HTTP_CFG_ENC_CAPS",
00058                                              "HTTP_URL",
00059                                              "HTTP_METHOD",
00060                                              "HTTP_VERSION",
00061                                              "HTTPS",
00062                                              "HTTPS_KEYSIZE",
00063                                              "HTTPS_SECRETKEYSIZE",
00064                                              "HTTPS_SERVER_ISSUER",
00065                                              "HTTPS_SERVER_SUBJECT",
00066                                              "INSTANCE_ID",
00067                                              "INSTANCE_META_PATH",
00068                                              "LOCAL_ADDR",
00069                                              "LOGON_USER",
00070                                              "PATH_INFO",
00071                                              "PATH_TRANSLATED",
00072                                              "QUERY_STRING",
00073                                              "REMOTE_ADDR",
00074                                              "REMOTE_HOST",
00075                                              "REMOTE_PORT",
00076                                              "REMOTE_USER",
00077                                              "REQUEST_METHOD",
00078                                              "SCRIPT_NAME",
00079                                              "SCRIPT_TRANSLATED",
00080                                              "SERVER_NAME",
00081                                              "SERVER_PORT",
00082                                              "SERVER_PORT_SECURE",
00083                                              "SERVER_PROTOCOL",
00084                                              "SERVER_SOFTWARE",
00085                                              "UNENCODED_URL",
00086                                              "UNMAPPED_REMOTE_USER",
00087                                              "URL",
00088                                              "" };
00089
00090 //
00091 // A simple 500 response we can send in the case of error
00092 //
00093
00094 CHAR    g_szErrorResponse[] = "<html>\r\n"
00095                               "<head> <title> DumpRequestInfo.dll "
00096                               "</title> </head>\r\n"
00097                               "<h1> DumpRequestInfo.dll </h1>\r\n"
00098                               "<hr>\r\n"
00099                               "The server was unable to process "
00100                               "your request.\r\n"
00101                               "</html>";
00102
00103
00104 //
00105 // Set some local definitions and prototypes
00106 //
00107
00108 #define MAX_BUFFERED_RESPONSE_SIZE 128*1024
00109 #define MAX_ALLOWED_ENTITY_SIZE    120*1024
00110
00111 VOID
00112 WINAPI
00113 AsyncCompletion(
00114     EXTENSION_CONTROL_BLOCK *   pecb,
00115     VOID *                      pContext,
00116     DWORD                       cbIO,
00117     DWORD                       cbError
00118     );
00119
00120 DWORD
00121 ProcessRequest(
00122     ISAPI_REQUEST * pRequest
00123     );
00124
00125 BOOL
00126 WriteEcbDump(
00127     ISAPI_REQUEST * pRequest
00128     );
00129
00130 BOOL
00131 WriteServerVariables(
00132     ISAPI_REQUEST * pRequest
00133     );
00134
00135 BOOL
00136 WriteRequestHeaders(
00137     ISAPI_REQUEST * pRequest
00138     );
00139
00140 BOOL
00141 WriteRequestEntity(
00142     ISAPI_REQUEST * pRequest
00143     );
00144
00145 //
00146 // ISAPI entry point implementations
00147 //
00148
00149 BOOL
00150 WINAPI
00151 GetExtensionVersion(
00152     HSE_VERSION_INFO *  pVer
00153     )
00154 /*++
00155
00156 Purpose:
00157
00158     Entry point for ISAPI extension initialization.  Required.
00159
00160     This function will be called exactly once in the lifetime
00161     of the extension, at initialization time.  This function is
00162     a useful point to do complex initialization tasks.  This
00163     function is called outside of the system loader lock, so
00164     it does not have the same restrictions as DllMain.
00165
00166 Arguments:
00167
00168     pVer - points to extension version info structure
00169
00170 Returns:
00171
00172     TRUE on success, FALSE on failure.
00173
00174     Note that in the case of FALSE, IIS will call GetLastError()
00175     and return an error page to the client.  The entity body of
00176     the page may be textual if the FormatMessage API can resolve
00177     it, or it may just be an error number if FormatMessage can't
00178     resolve it.
00179
00180 --*/
00181 {
00182     //
00183     // Tell IIS which version of ISAPI this extension was build from.
00184     //
00185
00186     pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
00187                                          HSE_VERSION_MAJOR);
00188
00189     //
00190     // Report the description string for this extension.  Ensure
00191     // that it does not exceed the maximum length and is NULL
00192     // terminated.
00193     //
00194
00195     strncpy( pVer->lpszExtensionDesc,
00196              "DumpRequestInfo Sample ISAPI Extension",
00197              HSE_MAX_EXT_DLL_NAME_LEN );
00198
00199     pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
00200
00201     //
00202     // Return TRUE if we successfully initialized.
00203     //
00204
00205   return TRUE;
00206 }
00207
00208 DWORD
00209 WINAPI
00210 HttpExtensionProc(
00211     EXTENSION_CONTROL_BLOCK *   pecb
00212     )
00213 /*++
00214
00215 Purpose:
00216
00217     Entry point for ISAPI requests.  Required.
00218
00219     This function is called once per request.  The EXTENSION_CONTROL_BLOCK
00220     passed in contains information and function pointers sufficient to
00221     interact with the server during this processing.
00222
00223     Note that, once HttpExtensionProc is called, it is the responsibility
00224     of the extension to send back any data that the client should receive.
00225     IIS will not automatically generate any response, even in the case of
00226     HSE_STATUS_ERROR once the request has progressed to the point where
00227     this function is called.
00228
00229     Also note that you should not make any blocking calls or do long-running
00230     operations within this function.  To allow efficient scaling of your
00231     server, you should consider creating a pool of private threads to handle
00232     the requests.  In that case, the implementation of this function would
00233     be just to add the pecb to a queue and return HSE_STATUS_PENDING.  The
00234     threads in the pool would be responsible for dequeing a pecb and calling
00235     HSE_REQ_DONE_WITH_SESSION when they are finished processing it.
00236
00237 Arguments:
00238
00239     pecb - pointer to the extenstion control block
00240
00241 Returns:
00242
00243     HSE_STATUS_SUCCESS - Indicates successful request.
00244     HSE_STATUS_ERROR   - Indicates failed request.
00245     HSE_STATUS_PENDING - Indicates that processing of the request
00246                          should continue after this function returns.
00247                          It HSE_STATUS_PENDING is used, it is necessary
00248                          that HSE_REQ_DONE_WITH_SESSION is called
00249                          exactly once when processing is completed for
00250                          the request.
00251
00252 --*/
00253 {
00254     ISAPI_REQUEST * pRequest;
00255
00256     pRequest = new ISAPI_REQUEST( pecb );
00257
00258     //
00259     // If we Fail to allocate the ISAREQUEST object.  The
00260     // best we can do now is to manually send an error
00261     // to the client.
00262     //
00263
00264     if ( !pRequest )
00265     {
00266         DWORD   cbErrorResponse;
00267
00268         //
00269         // Set the size of the response.  Note that HTTP entity bodies
00270         // are not NULL terminated.
00271         //
00272
00273         cbErrorResponse = sizeof( g_szErrorResponse ) - 1;
00274
00275         //
00276         // Set the ECB's status member to correctly log this
00277         // failure as a 500.
00278         //
00279
00280         pecb->dwHttpStatusCode = 500;
00281
00282         //
00283         // Send the response.  There is no real need to check
00284         // for an error here, as there is nothing we can do
00285         // to recover.
00286         //
00287
00288         pecb->ServerSupportFunction( pecb->ConnID,
00289                                      HSE_REQ_SEND_RESPONSE_HEADER,
00290                                      "500 Server Error",
00291                                      NULL,
00292                                      (DWORD*)"Content-Type: text/html\r\n"
00293                                      "\r\n" );
00294
00295         pecb->WriteClient( pecb->ConnID,
00296                            g_szErrorResponse,
00297                            &cbErrorResponse,
00298                            HSE_IO_SYNC );
00299
00300         return HSE_STATUS_ERROR;
00301     }
00302
00303     return ProcessRequest( pRequest );
00304 }
00305
00306 //
00307 // Local function implementations
00308 //
00309
00310 VOID
00311 WINAPI
00312 AsyncCompletion(
00313     EXTENSION_CONTROL_BLOCK *   pecb,
00314     VOID *                      pContext,
00315     DWORD                       cbIO,
00316     DWORD                       cbError
00317     )
00318 /*++
00319
00320 Purpose:
00321
00322     Handles cleaning up the request when the asynchronous
00323     TRANSMIT_FILE call completes.  Since the ISAREQUEST
00324     destructor takes care of cleaning up the ISAPI pieces,
00325     we basically just need to delete it here.
00326
00327     Note that in the case of TRANSMIT_FILE, cbIO will
00328     reflect the number of file bytes sent, not including
00329     head and tail bytes.  Since ISAREQUEST::AsyncTransmitBufferedResponse
00330     works by using TRANSMIT_FILE with a NULL file handle,
00331     we expect that cbIO will be zero.
00332
00333     Also, note that we will clean up the request any differently
00334     if an error occurs in transmission, so we don't need to
00335     check the cbError member.
00336
00337 Arguments:
00338
00339     pecb     - pointer to the extenstion control block
00340     pContext - pointer to the I/O context (the ISAREQUEST in our case)
00341     cbIO     - the number of file bytes associated with the I/O
00342     cbError  - if non-zero, the code associated with any error in
00343                transmission
00344
00345 Returns:
00346
00347     None
00348
00349 --*/
00350 {
00351     delete (ISAPI_REQUEST*)pContext;
00352 }
00353
00354 DWORD
00355 ProcessRequest(
00356     ISAPI_REQUEST * pRequest
00357     )
00358 /*++
00359
00360 Purpose:
00361
00362     Does the main work of processing the request
00363
00364 Arguments:
00365
00366     pRequest - the ISAREQUEST object created in HttpExtensionProc
00367
00368 Returns:
00369
00370     An HSE_STATUS code
00371
00372 --*/
00373 {
00374     //
00375     // Set the maximum response that we are willing to send
00376     //
00377
00378     pRequest->SetMaxResponseBufferSize( MAX_BUFFERED_RESPONSE_SIZE );
00379
00380     //
00381     // Begin building the response buffer
00382     //
00383
00384     if ( !pRequest->AddHeaderToBufferedResponse( "Content-Type",
00385                                                  "text/html" ) )
00386     {
00387         goto Failed;
00388     }
00389
00390     if ( !pRequest->PrintfToResponseBuffer( "<html>\r\n"
00391                                             "<head> <title> DumpRequestInfo "
00392                                             "</title> </head>\r\n"
00393                                             "<h1> DumpRequestInfo.dll </h1>\r\n"
00394                                             "<hr>\r\n" ) )
00395     {
00396         goto Failed;
00397     }
00398
00399     //
00400     // Dump the parts of the request into the response buffer
00401     //
00402
00403     if ( !WriteEcbDump( pRequest ) )
00404     {
00405         goto Failed;
00406     }
00407
00408     if ( !WriteServerVariables( pRequest ) )
00409     {
00410         goto Failed;
00411     }
00412
00413     if ( !WriteRequestHeaders( pRequest ) )
00414     {
00415         goto Failed;
00416     }
00417
00418     if ( !WriteRequestEntity( pRequest ) )
00419     {
00420         goto Failed;
00421     }
00422
00423     //
00424     // Complete the response buffer
00425     //
00426
00427     if ( !pRequest->PrintfToResponseBuffer( "</html>" ) )
00428     {
00429         goto Failed;
00430     }
00431
00432     //
00433     // Transmit the response to the client.  If this call succeeds,
00434     // then we must assume that the completion will occur immediately
00435     // and clean up the request.  We must therefore avoid touching
00436     // pRequest and return HSE_STATUS_PENDING unless the call fails.
00437     //
00438
00439     if ( pRequest->AsyncTransmitBufferedResponse( AsyncCompletion ) )
00440     {
00441         return HSE_STATUS_PENDING;
00442     }
00443
00444     //
00445     // Fall through to error handler
00446     //
00447
00448 Failed:
00449
00450     //
00451     // Send a 500 response to the client
00452     //
00453
00454     pRequest->SyncWriteCompleteResponse( "500 Server Error",
00455                                          "Content-Type: text/html\r\n\r\n",
00456                                          g_szErrorResponse );
00457
00458     return HSE_STATUS_ERROR;
00459 }
00460
00461 BOOL
00462 WriteEcbDump(
00463     ISAPI_REQUEST * pRequest
00464     )
00465 /*++
00466
00467 Purpose:
00468
00469     Writes EXTENSION_CONTROL_BLOCK data into response buffer
00470
00471 Arguments:
00472
00473     pRequest - the ISAREQUEST object created in HttpExtensionProc
00474
00475 Returns:
00476
00477     An HSE_STATUS code
00478
00479 --*/
00480 {
00481     EXTENSION_CONTROL_BLOCK *   pecb;
00482     BOOL                        fRet;
00483
00484     pecb = pRequest->QueryEcb();
00485
00486     fRet = pRequest->PrintfToResponseBuffer(
00487         "<h1> Dump of "
00488         "EXTENSION_CONTROL_BLOCK: </h1>\r\n"
00489         "<pre>\r\n"
00490         "cbSize             = %d\r\n"
00491         "dwVersion          = %08x\r\n"
00492         "ConnID             = %p\r\n"
00493         "dwHttpStatusCode   = %d\r\n"
00494         "cbTotalBytes       = %d\r\n"
00495         "cbAvailable        = %d\r\n"
00496         "lpbData            = %p\r\n"
00497         "lpszLogData        = %s\r\n"
00498         "lpszMethod         = %s\r\n"
00499         "lpszQueryString    = %s\r\n"
00500         "lpszPathInfo       = %s\r\n"
00501         "lpszPathTranslated = %s\r\n"
00502         "lpszContentType    = %s\r\n"
00503         "</pre>\r\n"
00504         "<hr>\r\n",
00505         pecb->cbSize,
00506         pecb->dwVersion,
00507         pecb->ConnID,
00508         pecb->dwHttpStatusCode,
00509         pecb->cbTotalBytes,
00510         pecb->cbAvailable,
00511         pecb->lpbData,
00512         pecb->lpszLogData,
00513         pecb->lpszMethod,
00514         pecb->lpszQueryString,
00515         pecb->lpszPathInfo,
00516         pecb->lpszPathTranslated,
00517         pecb->lpszContentType );
00518
00519     return fRet;
00520 }
00521
00522 BOOL
00523 WriteServerVariables(
00524     ISAPI_REQUEST * pRequest
00525     )
00526 /*++
00527
00528 Purpose:
00529
00530     Writes server variable data into response buffer
00531
00532 Arguments:
00533
00534     pRequest - the ISAREQUEST object created in HttpExtensionProc
00535
00536 Returns:
00537
00538     An HSE_STATUS code
00539
00540 --*/
00541 {
00542     ISAPI_STRING    strValue;
00543     DWORD           x = 0;
00544     BOOL            fResult;
00545
00546     //
00547     // Write the start of the server variable output
00548     //
00549
00550     if ( !pRequest->PrintfToResponseBuffer( "<h1> Server Variable Dump "
00551                                             "</h1>\r\n"
00552                                             "<pre>\r\n" ) )
00553     {
00554         return FALSE;
00555     }
00556
00557     //
00558     // Loop through all of the server variables and
00559     // write them to the output buffer
00560     //
00561
00562     while ( g_rgVariableList[x] &&
00563             g_rgVariableList[x][0] != '\0' )
00564     {
00565         fResult = pRequest->GetServerVariable( g_rgVariableList[x],
00566                                                &strValue );
00567
00568         if ( fResult )
00569         {
00570             if ( !pRequest->PrintfToResponseBuffer( "%20s = %s\r\n",
00571                                                     g_rgVariableList[x],
00572                                                     strValue.QueryStr() ) )
00573             {
00574                 return FALSE;
00575             }
00576         }
00577         else
00578         {
00579             if ( !pRequest->PrintfToResponseBuffer( "%20s = *** Error %d ***\r\n",
00580                                                     g_rgVariableList[x],
00581                                                     GetLastError() ) )
00582             {
00583                 return FALSE;
00584             }
00585         }
00586
00587         x++;
00588     }
00589
00590     //
00591     // Write the final part of the server variable output
00592     //
00593
00594     if ( !pRequest->PrintfToResponseBuffer( "</pre>\r\n"
00595                                             "<hr>\r\n" ) )
00596     {
00597         return FALSE;
00598     }
00599
00600     return TRUE;
00601 }
00602
00603 BOOL
00604 WriteRequestHeaders(
00605     ISAPI_REQUEST * pRequest
00606     )
00607 /*++
00608
00609 Purpose:
00610
00611     Writes request header data into response buffer
00612
00613 Arguments:
00614
00615     pRequest - the ISAREQUEST object created in HttpExtensionProc
00616
00617 Returns:
00618
00619     An HSE_STATUS code
00620
00621 --*/
00622 {
00623     ISAPI_STRING    strHeaders;
00624
00625     //
00626     // Write the start of the request header output
00627     //
00628
00629     if ( !pRequest->PrintfToResponseBuffer( "<h1> Request Header Dump "
00630                                             "</h1>\r\n"
00631                                             "<pre>\r\n" ) )
00632     {
00633         return FALSE;
00634     }
00635
00636     //
00637     // Get ALL_RAW, which contains the data as the client sent it
00638     //
00639
00640     if ( !pRequest->GetServerVariable( "ALL_RAW",
00641                                        &strHeaders ) )
00642     {
00643         return FALSE;
00644     }
00645
00646     if ( !pRequest->PrintfToResponseBuffer( strHeaders.QueryStr() ) )
00647     {
00648         return FALSE;
00649     }
00650
00651     //
00652     // Write the final part of the request header output
00653     //
00654
00655     if ( !pRequest->PrintfToResponseBuffer( "</pre>\r\n"
00656                                             "<hr>\r\n" ) )
00657     {
00658         return FALSE;
00659     }
00660
00661     return TRUE;
00662 }
00663
00664 BOOL
00665 WriteRequestEntity(
00666     ISAPI_REQUEST * pRequest
00667     )
00668 /*++
00669
00670 Purpose:
00671
00672     Writes request entity data into response buffer
00673
00674 Arguments:
00675
00676     pRequest - the ISAREQUEST object created in HttpExtensionProc
00677
00678 Returns:
00679
00680     An HSE_STATUS code
00681
00682 --*/
00683 {
00684     ISAPI_BUFFER    buffEntity( MAX_ALLOWED_ENTITY_SIZE );
00685
00686     //
00687     // If there is no entity, then just return
00688     //
00689
00690     if ( pRequest->QueryEcb()->cbTotalBytes == 0 )
00691     {
00692         return TRUE;
00693     }
00694
00695     //
00696     // Write the start of the entity output
00697     //
00698
00699     if ( !pRequest->PrintfToResponseBuffer( "<h1> Request Entity Dump "
00700                                             "</h1>\r\n"
00701                                             "<pre>\r\n" ) )
00702     {
00703         return FALSE;
00704     }
00705
00706     if ( !pRequest->ReadAllEntity( &buffEntity ) )
00707     {
00708         //
00709         // If the entity is too large for our buffer,
00710         // we'll just print something to that effect
00711         //
00712
00713         if ( GetLastError() != ERROR_NOT_ENOUGH_MEMORY )
00714         {
00715             return FALSE;
00716         }
00717
00718         if ( !pRequest->PrintfToResponseBuffer( "*** Entity Too Large "
00719                                                 "***\r\n" ) )
00720         {
00721             return FALSE;
00722         }
00723     }
00724
00725     //
00726     // Since we're not writing a formatted string, use the append
00727     // function instead of the write function.  Not only is this
00728     // higher performance, but it does not depend on the current
00729     // maximum write size.
00730     //
00731
00732     if ( !pRequest->AddDataToResponseBuffer( buffEntity.QueryPtr(),
00733                                              buffEntity.QueryDataSize() ) )
00734     {
00735         return FALSE;
00736     }
00737
00738     //
00739     // Write the final part of the request entity output
00740     //
00741
00742     if ( !pRequest->PrintfToResponseBuffer( "</pre>\r\n"
00743                                             "<hr>\r\n" ) )
00744     {
00745         return FALSE;
00746     }
00747
00748     return TRUE;
00749 }
Generated on Wed Nov 13 2024 16:52:44 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_EAP_NAME_DIALOG Member List

This is the complete list of members for _EAP_NAME_DIALOG, including all inherited members.
awszIdentity | _EAP_NAME_DIALOG
awszPassword | _EAP_NAME_DIALOG
Generated on Wed Nov 13 2024 16:55:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CRequestInstance Member List

This is the complete list of members for CRequestInstance, including all inherited members.
_Cleanup() | CRequestInstance | [private]
_SetFlagsProperty(IN ICertServerPolicy *pServer, IN WCHAR const *pwszPropName, IN DWORD dwFlags) | CRequestInstance | [private]
_TemplateNamesMatch(IN WCHAR const *pwszTemplateName1, IN WCHAR const *pwszTemplateName2, OUT BOOL *pfTemplateMissing) | CRequestInstance | [private]
CRequestInstance() | CRequestInstance | [inline]
GetPolicy() | CRequestInstance | [inline]
GetTemplateName() | CRequestInstance | [inline]
GetTemplateObjId() | CRequestInstance | [inline]
Initialize(IN CCertPolicySample *pPolicy, IN ICertServerPolicy *pServer, OUT BOOL *pfEnableEnrolleeExtensions) | CRequestInstance |
IsCARequest() | CRequestInstance | [inline]
m_dwTemplateMajorVersion | CRequestInstance | [private]
m_dwTemplateMinorVersion | CRequestInstance | [private]
m_fCA | CRequestInstance | [private]
m_pPolicy | CRequestInstance | [private]
m_strTemplateName | CRequestInstance | [private]
m_strTemplateObjId | CRequestInstance | [private]
SetTemplateName(IN ICertServerPolicy *pServer, IN OPTIONAL WCHAR const *pwszTemplateName, IN OPTIONAL WCHAR const *pwszTemplateObjId) | CRequestInstance |
~CRequestInstance() | CRequestInstance |
Generated on Wed Nov 13 2024 16:57:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/FreeObject/StdAfx.h Source File

  • Com
  • Services
  • Concurrency
  • SyncComp
  • FreeObject

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__83BBBCC1_F430_11D2_A10A_0080C71F306F__INCLUDED_)
00006 #define AFX_STDAFX_H__83BBBCC1_F430_11D2_A10A_0080C71F306F__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 #define MUTEX_NAME "ComSyncFreeObject"
00025
00026 //{{AFX_INSERT_LOCATION}}
00027 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00028
00029 #endif // !defined(AFX_STDAFX_H__83BBBCC1_F430_11D2_A10A_0080C71F306F__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Fields.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Fields.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Fields
00019 /** @com.interface(iid=00000564-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Fields extends msado15.Fields20
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=PROPGET, name="Count", name2="getCount", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int getCount();
00025
00026   /** @com.method(vtoffset=5, dispid=4294967292, type=METHOD, name="_NewEnum", addFlagsVtable=4)
00027       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00028   public IUnknown _NewEnum();
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=METHOD, name="Refresh", addFlagsVtable=4)
00031       @com.parameters() */
00032   public void Refresh();
00033
00034   /** @com.method(vtoffset=7, dispid=0, type=PROPGET, name="Item", name2="getItem", addFlagsVtable=4)
00035       @com.parameters([in,type=VARIANT] Index, [iid=0000054C-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00036   public msado15.Field getItem(Variant Index);
00037
00038   /** @com.method(vtoffset=8, dispid=1610874880, type=METHOD, name="_Append", addFlagsVtable=4)
00039       @com.parameters([in,type=STRING] Name, [in,type=I4] Type, [in,type=I4] DefinedSize, [in,type=I4] Attrib) */
00040   public void _Append(String Name, int Type, int DefinedSize, int Attrib);
00041
00042   /** @com.method(vtoffset=9, dispid=1610874881, type=METHOD, name="Delete", addFlagsVtable=4)
00043       @com.parameters([in,type=VARIANT] Index) */
00044   public void Delete(Variant Index);
00045
00046   /** @com.method(vtoffset=10, dispid=1610940416, type=METHOD, name="Append", addFlagsVtable=4)
00047       @com.parameters([in,type=STRING] Name, [in,type=I4] Type, [in,type=I4] DefinedSize, [in,type=I4] Attrib, [in,type=VARIANT] FieldValue) */
00048   public void Append(String Name, int Type, int DefinedSize, int Attrib, Variant FieldValue);
00049
00050   /** @com.method(vtoffset=11, dispid=1610940417, type=METHOD, name="Update", addFlagsVtable=4)
00051       @com.parameters() */
00052   public void Update();
00053
00054
00055   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x564, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00056 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/sky.h Source File

  • SysMgmt
  • MMC
  • Nameext

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include "DeleBase.h"
00024
00025
00026 class CPlane : public CDelegationBase {
00027 public:
00028     CPlane(_TCHAR *szName, int id, LONG lWeight, LONG lHeight, LONG lPayload);
00029
00030     virtual ~CPlane();
00031
00032     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00033     virtual const GUID & getNodeType() { return thisGuid; }
00034     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00035
00036 public:
00037     // virtual functions go here (for MMCN_*)
00038     virtual HRESULT OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed);
00039     virtual HRESULT OnMenuCommand(IConsole *pConsole, long lCommandID);
00040
00041 private:
00042     // {2AF5EBCF-6ADC-11d3-9155-00C04F65B3F9}
00043     static const GUID thisGuid;
00044
00045     _TCHAR *szName;
00046     LONG   lWeight;
00047     LONG   lHeight;
00048     LONG   lPayload;
00049     int    nId;
00050     enum {RUNNING, PAUSED, STOPPED} iStatus;
00051     enum { IDM_START_SKY = 100, IDM_PAUSE_SKY, IDM_STOP_SKY };
00052 };
00053
00054
00055 class CSkyVehicle : public CDelegationBase {
00056 public:
00057     CSkyVehicle(int i);
00058     virtual ~CSkyVehicle() {}
00059
00060     // virtual functions go here (for MMCN_*)
00061     virtual HRESULT OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem);
00062     virtual HRESULT OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed);
00063     virtual HRESULT OnMenuCommand(IConsole *pConsole, long lCommandID);
00064     virtual const _TCHAR *GetDisplayName(int nCol = 0);
00065     virtual const GUID & getNodeType() { return thisGuid; }
00066     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00067
00068 private:
00069
00070     enum { IDM_NEW_SKY = 2 };
00071
00072   // {BD518283-6A2E-11d3-9154-00C04F65B3F9}
00073     static const GUID thisGuid;
00074
00075     enum { NUMBER_OF_CHILDREN = 4 };
00076     CPlane *children[NUMBER_OF_CHILDREN];
00077
00078     int id;
00079 };
00080
00081 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/about/staticnode.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • about

staticnode.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     Implementation of the CStaticNode class.
00014 //
00015
00016 #include "StaticNode.h"
00017
00018
00019 // Initialize our static GUID just once
00020 GUID CStaticNode::thisGUID = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00021
00022
00023 /////////////////////////////////////////////////////////////////////////////
00024 // Construction/Destruction
00025
00026 CStaticNode::CStaticNode()
00027 {
00028   m_pCompData = NULL;
00029 }
00030
00031
00032 CStaticNode::~CStaticNode()
00033 {
00034 }
00035
00036 //---------------------------------------------------------------------------
00037 HRESULT CStaticNode::Initialize( NODE_PROPERTIES* pNodeProps )
00038 {
00039   _ASSERT( NULL != pNodeProps );
00040   _ASSERT( NULL != pNodeProps->pComponentData );
00041
00042   UINT   nLen   = wcslen( pNodeProps->szNodeName ) + 1;
00043   LPWSTR pszTmp = (LPWSTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
00044   wcscpy( pszTmp, pNodeProps->szNodeName );
00045   if( NULL != m_pwszNodeName )
00046     CoTaskMemFree( m_pwszNodeName );
00047
00048   m_pwszNodeName = pszTmp;
00049   m_pCompData    = reinterpret_cast<CComponentData*>(pNodeProps->pComponentData);
00050
00051   return S_OK;
00052 }
00053
00054
00055 /////////////////////////////////////////////////////////////////////////////
00056 // Implementation of virtual methods
00057
00058
00059 //---------------------------------------------------------------------------
00060 //  The minimum implementation of this method is to return the
00061 //  Persistable View Description string.  This string must be allocated
00062 //  with CoTaskMemAlloc.  The console will free the string.
00063 //
00064 HRESULT CStaticNode::GetResultViewType2
00065 (
00066   MMC_COOKIE             nCookie,  //[in] Identifier of object
00067   PRESULT_VIEW_TYPE_INFO pRVTinfo  //[in,out] ViewTypeInfo struct
00068 )
00069 {
00070   LPOLESTR pszDescStr = (LPOLESTR)CoTaskMemAlloc( sizeof(L"DefaultListView")+1 );
00071   if( NULL == pszDescStr )
00072     return E_OUTOFMEMORY;
00073
00074   wcscpy( pszDescStr, L"DefaultListView" );
00075   pRVTinfo->pstrPersistableViewDescription = pszDescStr;
00076
00077   return S_OK;
00078 }
00079
00080 //---------------------------------------------------------------------------
00081 HRESULT CStaticNode::GetDisplayInfo
00082 (
00083   SCOPEDATAITEM* pSDI        //[in][out] Points to SCOPEDATAITEM
00084 )
00085 {
00086   _ASSERT( NULL != pSDI );
00087   pSDI->displayname = m_pwszNodeName;
00088
00089   return S_OK;
00090 }
00091
00092 //---------------------------------------------------------------------------
00093 HRESULT CStaticNode::GetDisplayInfo
00094 (
00095   RESULTDATAITEM* pRDI
00096 )
00097 {
00098
00099   return S_FALSE;
00100 }
00101
00102 /////////////////////////////////////////////////////////////////////////////
00103 // Implementation of notification handlers
00104
00105
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CapJ Member List

This is the complete list of members for CapJ, including all inherited members.
aboutMenu | CapJ | [package]
aboutMenu_click(Object sender, Event e) | CapJ | [inline, private]
agent1 | CapJ | [package]
agent1_agentPropertyChange(Object sender, Event e) | CapJ | [inline, private]
agent1_command(Object sender, agentctl.Agent.CommandEvent e) | CapJ | [inline, private]
agent1_move(Object sender, agentctl.Agent.MoveEvent e) | CapJ | [inline, private]
AnimationsLabel | CapJ | [package]
AnimationsListBox | CapJ | [package]
AnimationsListBox_doubleClick(Object source, Event e) | CapJ | [inline, private]
AutoHide | CapJ | [package]
AutoPace | CapJ | [package]
CapJ() | CapJ | [inline]
CapJ_activate(Object source, Event e) | CapJ | [inline, private]
CapJ_closing(Object source, CancelEvent e) | CapJ | [inline, private]
CapJ_deactivate(Object source, Event e) | CapJ | [inline, private]
components | CapJ | [package]
dispose() | CapJ | [inline]
exitMenu | CapJ | [package]
exitMenu_click(Object sender, Event e) | CapJ | [inline]
fileMenu | CapJ | [package]
GetForegroundWindow() | CapJ | [private, static]
GetWindowText(int hWnd, StringBuffer text, int nMaxCount) | CapJ | [private, static]
helpMenu | CapJ | [package]
initForm() | CapJ | [inline, private]
kpszCharacterWindowTitle | CapJ | [private]
kpszOptionsWindowTitle | CapJ | [private]
kpszRecentFilesItem | CapJ | [private]
kpszRecentFilesSubkey | CapJ | [private]
LoadCharacter(String path) | CapJ | [inline, private]
m_pCharacter | CapJ | [private]
main(String args[]) | CapJ | [inline, static]
mainMenu1 | CapJ | [package]
MakeEllipsisPath(String pszPath, int iMaxLength) | CapJ | [inline, private]
MAX_RECENT_FILENAME | CapJ | [private]
MAX_RECENT_FILES | CapJ | [private]
menuItem1 | CapJ | [package]
Move | CapJ | [package]
Move_click(Object source, Event e) | CapJ | [inline, private]
OnListDblClick(Object sender, Event e) | CapJ | [inline, private]
OnRecentFile(int iFile) | CapJ | [inline, private]
openMenu | CapJ | [package]
openMenu_click(Object source, Event e) | CapJ | [inline, private]
PlayButton | CapJ | [package]
PlayButton_click(Object sender, Event e) | CapJ | [inline, private]
PositionLabel | CapJ | [package]
recent1 | CapJ | [package]
recent1_click(Object source, Event e) | CapJ | [inline, private]
recent2 | CapJ | [package]
recent2_click(Object source, Event e) | CapJ | [inline, private]
recent3 | CapJ | [package]
recent3_click(Object source, Event e) | CapJ | [inline, private]
recent4 | CapJ | [package]
recent4_click(Object source, Event e) | CapJ | [inline, private]
recentSeparator | CapJ | [package]
SizeToText | CapJ | [package]
SpeakButton | CapJ | [package]
SpeakButton_click(Object source, Event e) | CapJ | [inline, private]
SpeakText | CapJ | [package]
SpeechOutputLabel | CapJ | [package]
StopBeforePlay | CapJ | [package]
StopButton | CapJ | [package]
StopButton_click(Object source, Event e) | CapJ | [inline, private]
UpdateRecentFiles(String pszFilename) | CapJ | [inline, private]
UseBalloon | CapJ | [package]
UseBalloon_click(Object source, Event e) | CapJ | [inline, private]
UserHid | CapJ | [private]
UserHidViaCharacterMenu | CapJ | [private]
UseSfx | CapJ | [package]
UseSfx_click(Object source, Event e) | CapJ | [inline, private]
X | CapJ | [package]
XLabel | CapJ | [package]
Y | CapJ | [package]
YLabel | CapJ | [package]
Generated on Wed Nov 13 2024 16:55:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/crtsess.cpp Source File

  • Dataaccess
  • oledb
  • sampprov

crtsess.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module CRTSESS.CPP | IDBCreateSession interface implementation
00008 //
00009
00010 // Includes ------------------------------------------------------------------
00011
00012 #include "headers.h"
00013
00014
00015 // Code ----------------------------------------------------------------------
00016
00017 // CImpIDBCreateSession::CreateSession ------------------------------------------------
00018 //
00019 // @mfunc Creates a new DB Session object from the DSO, and returns the
00020 // requested interface on the newly created object.
00021 //
00022 // @rdesc HRESULT
00023 //      @flag S_OK                  | The method succeeded.
00024 //      @flag E_INVALIDARG          | ppDBSession was NULL
00025 //      @flag DB_E_NOAGGREGATION    | pUnkOuter was not NULL (this object does not support
00026 //                                    being aggregated)
00027 //      @flag E_FAIL                | Provider-specific error. This provider can only create
00028 //                                    one DBSession
00029 //      @flag E_OUTOFMEMORY         | Out of memory
00030 //      @flag E_NOINTERFACE         | Could not obtain requested interface on DBSession object
00031 //
00032 STDMETHODIMP CImpIDBCreateSession::CreateSession
00033 (
00034     IUnknown*   pUnkOuter,  //@parm IN | Controlling IUnknown if being aggregated
00035     REFIID      riid,       //@parm IN | The ID of the interface
00036     IUnknown**  ppDBSession //@parm OUT | A pointer to memory in which to return the interface pointer
00037 )
00038 {
00039   //
00040   // Asserts
00041     //
00042   assert(m_pObj);
00043
00044     //
00045     // Check in-params and NULL out-params in case of error
00046     //
00047     if( !ppDBSession )
00048         return (E_INVALIDARG);
00049
00050     *ppDBSession = NULL;
00051
00052     //
00053   // Check to see if the DSO is Uninitialized
00054     //
00055   if( !m_pObj->m_fDSOInitialized )
00056         return (E_UNEXPECTED);
00057
00058     //
00059     // This Data Source object can only create 1 DBSession...
00060     //
00061     if( m_pObj->m_fDBSessionCreated )
00062         return (DB_E_OBJECTCREATIONLIMITREACHED);
00063
00064     //
00065   // We do not allow any other iid than IID_IUnknown for aggregation
00066     //
00067   if( pUnkOuter && riid != IID_IUnknown )
00068     return (DB_E_NOAGGREGATION);
00069
00070     //
00071     // Open a DBSession object
00072     //
00073     CDBSession* pDBSession = new CDBSession(pUnkOuter);
00074
00075     if( !pDBSession || !pDBSession->FInit(m_pObj) )
00076   {
00077         SAFE_DELETE(pDBSession);
00078         return (E_OUTOFMEMORY);
00079   }
00080
00081     //
00082     // Get requested interface pointer on DBSession
00083     //
00084     HRESULT hr=pDBSession->QueryInterface(riid, (void **)ppDBSession);
00085
00086     if( FAILED(hr) )
00087   {
00088         SAFE_DELETE(pDBSession);
00089     return (hr);
00090   }
00091
00092   m_pObj->m_fDBSessionCreated = TRUE;
00093     return (hr);
00094 }
00095
00096
00097
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CMenu/localres.h Source File

  • SysMgmt
  • MMC
  • CMenu

localres.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef __LocalResource_H__
00020 #define __LocalResource_H__
00021
00022 #define INDEX_NONE          -1
00023 #define INDEX_SPACEICON     0
00024 #define INDEX_LANDICON      1
00025 #define INDEX_SKYICON       2
00026 #define INDEX_PEOPLEICON    3
00027 #define INDEX_CLOSEDFOLDER  4
00028 #define INDEX_OPENFOLDER    5
00029
00030
00031 #endif // __LocalResource_H__
Generated on Wed Nov 13 2024 16:52:34 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/Secure/secClnt.h Source File

  • Com
  • Fundamentals
  • DCom
  • Secure

secClnt.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by SECCLNT.RC
00004 //
00005 #define IDD_SECCLNT                     101
00006 #define IDC_MACHINENAME                 1000
00007 #define IDC_CREATE                      1001
00008 #define IDC_RELEASE                     1002
00009 #define IDC_PROXY_AUTHNLEVEL            1003
00010 #define IDC_PROXY_IMPLEVEL              1004
00011 #define IDC_INITIALIZE                  1005
00012 #define IDC_CLIENT_AUTHNLEVEL           1007
00013 #define IDC_CLIENT_IMPLEVEL             1008
00014 #define IDC_SERVER_CLASS                1009
00015 #define IDC_PROXY_PRINCIPLENAME         1010
00016 #define IDC_CHOOSECOLOR                 1011
00017 #define IDC_USERNAME                    1013
00018 #define IDC_PROXY_AUTHN                 1014
00019 #define IDC_PROXY_AUTHZ                 1015
00020 #define IDC_COMBO1                      1016
00021 #define IDC_COLOR                       1017
00022
00023 // Next default values for new objects
00024 //
00025 #ifdef APSTUDIO_INVOKED
00026 #ifndef APSTUDIO_READONLY_SYMBOLS
00027 #define _APS_NO_MFC                     1
00028 #define _APS_NEXT_RESOURCE_VALUE        102
00029 #define _APS_NEXT_COMMAND_VALUE         40001
00030 #define _APS_NEXT_CONTROL_VALUE         1018
00031 #define _APS_NEXT_SYMED_VALUE           101
00032 #endif
00033 #endif
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Snmp/WSnmp/WSnmpUtil.h Source File

  • NetDS
  • Snmp
  • WSnmp

WSnmpUtil.h

Go to the documentation of this file.
00001 //****************************************************************
00002 //
00003 // header file for wsnmputil.cpp utility.
00004 //
00005 //****************************************************************
00006 #ifndef _WSNMP_UTIL_
00007 #define _WSNMP_UTIL_ 1
00008
00009
00010 //**************************************************************************
00011 //
00012 //  definitions.
00013 //
00014 //**************************************************************************
00015
00016 #define        WM_SNMP_INCOMING    (WM_USER + 1)
00017 #define        WM_SNMP_DONE        (WM_USER + 2)
00018 #define        NOTIFICATION_CLASS  "SNMPUTIL NOTIFICATION CLASS"
00019 #define        SNMP_FAILURE(s)     ((s) == SNMPAPI_FAILURE)
00020 #define        BUFFER_LEN          255
00021 #define        MAXENTITYSTRLEN     128
00022 #define        IPADDRLEN           4
00023 #define        MINVARBINDLEN       2
00024 #define        SYSUPTIMEINDEX      0
00025 #define        SNMPTRAPOIDINDEX    1
00026 #define        DEFAULT_ADDRESS_IP  "127.0.0.1"
00027 #define        CMD_LINE_ARGS       255      // maximum command line arguments
00028 #define        MAX_GETBLK_OIDS     10
00029 #define        MAX_BUFFER_LEN      2048
00030
00031 // defintions that define the operation we are about to do.
00032
00033 #define        GET                 1
00034 #define        GET_NEXT            2
00035 #define        WALK                3
00036 #define        SET                 4
00037 #define        TRAP                5
00038 #define        GET_BULK            6
00039 #define        SUB_TREE            7
00040
00041
00042 //**************************************************************************
00043 //
00044 //  Structure definitions.
00045 //
00046 //**************************************************************************
00047
00048 typedef struct _SNMP_MGR_SESSION
00049 {
00050
00051  HSNMP_SESSION     hSnmpSession;     // handle to winsnmp session
00052  HSNMP_ENTITY      hAgentEntity;     // handle to agent entity
00053  HSNMP_ENTITY      hManagerEntity;   // handle to manager entity
00054  HSNMP_CONTEXT     hViewContext;     // handle to view context
00055  HSNMP_PDU         hPdu;             // handle to snmp pdu
00056  HSNMP_VBL         hVbl;             // handle to var bind list
00057  HWND              hWnd;             // handle to window
00058
00059  smiINT32          nPduType;         // current pdu type
00060  smiINT32          nRequestId;       // current request id
00061  smiINT32          nError;           // last system error
00062  smiINT32          nErrorStatus;     // error status
00063  smiINT32          nErrorIndex;      // error index
00064
00065 } SNMP_MGR_SESSION, *PSNMP_MGR_SESSION;
00066
00067
00068 //****************************************************************
00069 //
00070 // global vars.
00071 //
00072 //****************************************************************
00073
00074 class GlobalVars
00075 {
00076 public:
00077     GlobalVars( )
00078     {
00079         nTimeOut        = 6000;
00080         nRetries        = 3;
00081         nRequestId      = 1;
00082         oidCount        = 0;
00083         pAgentStrAddr   = NULL;
00084         pAgentCommunity = NULL;
00085         pSetValue       = NULL;
00086         fDone           = FALSE;           // default
00087         version         = FALSE;           // Use v1 by default;
00088         doSet           = FALSE;           // dont do set by default.
00089     }
00090
00091     ~GlobalVars( ) { }
00092     HINSTANCE    g_hInst;                     // module handle.
00093     smiINT32     oidCount;                    // number of Oids.
00094     smiINT32     operation;                   // define the operation
00095     smiINT32     nTimeOut;                    // timeout in milli-seconds
00096     smiINT32     nRetries;                    // number of retries
00097     smiINT32     nRequestId;                  // request id.
00098     smiVALUE     value;                       // encapsulate in global vars
00099     smiOID       startOid;                    // starting OID.
00100     smiOID       oid;                         // oid from the command line.
00101     smiINT       non_repeaters;               // non_repeaters field of SNMP_PDU_GETBULK
00102     smiINT       max_repetitions;             // max_repetitions field of SNMP_PDU_GETBULK
00103     BOOL         doSet;                       // should we do a set?
00104     BOOL         fDone;                       // A bool var
00105     BOOL         version;                     // if TRUE -> v2C else use v1.
00106     CHAR         *pAgentStrAddr;              // pointer to agent string
00107     CHAR         *pSetValue;                  // pointer to the SET value in ASCII
00108     CHAR         *pAgentCommunity;            // pointer to agent community string
00109     CHAR         *pszOid[ CMD_LINE_ARGS ];    // pointer to OID string
00110     struct       sockaddr_in agentSockAddr;   // agent string converted to proper address.
00111
00112 };
00113
00114 extern GlobalVars    gVars;
00115
00116 //****************************************************************
00117 //
00118 // function prototypes.
00119 //
00120 //****************************************************************
00121
00122 //
00123 // following functions are defined in wsnmputil.cpp
00124 //
00125 BOOL    OpenWinSNMPSession( PSNMP_MGR_SESSION pSession );
00126 BOOL    CloseWinSNMPSession( PSNMP_MGR_SESSION pSession );
00127 BOOL    CreateNotificationWindow( PSNMP_MGR_SESSION pSession );
00128 BOOL    DestroyNotificationWindow( PSNMP_MGR_SESSION pSession );
00129 LRESULT CALLBACK    NotificationWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
00130 BOOL    ProcessNotification( PSNMP_MGR_SESSION pSession );
00131 BOOL    WaitForTraps( PSNMP_MGR_SESSION pSession );
00132 BOOL    ProcessAgentResponse( PSNMP_MGR_SESSION pSession );
00133
00134 BOOL    CreateVbl( PSNMP_MGR_SESSION pSession, smiOID *pOid, smiVALUE * pValue  );
00135 void    FreeVblandPdu( PSNMP_MGR_SESSION pSession );
00136 BOOL    CreatePduSendRequest( PSNMP_MGR_SESSION pSession, smiVALUE *pValue );
00137
00138 //
00139 // following functions are defined in helper.cpp
00140 //
00141 void    Usage( );
00142 void    PrintDbgMessage( LPSTR, ... );
00143 BOOL    ConvertTexttoIp( char *agentAddress );
00144 BOOL    ParseCommandLine( int argc, char **argv );
00145 void    ConvertStringToSmiValue( smiVALUE *pValue );
00146 void    PrintOidValue( smiVALUE *value );
00147 BOOL    PrintVarBind( PSNMP_MGR_SESSION pSession );
00148 void    ParseAndPrintv2Trap( PSNMP_MGR_SESSION pSession );
00149
00150
00151 #endif
00152
Generated on Wed Nov 13 2024 16:52:21 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagEnhKeyUsage Member List

This is the complete list of members for tagEnhKeyUsage, including all inherited members.
dwCount | tagEnhKeyUsage
dwValue | tagEnhKeyUsage
szUsage | tagEnhKeyUsage
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

MEMICONDIRENTRY Member List

This is the complete list of members for MEMICONDIRENTRY, including all inherited members.
bColorCount | MEMICONDIRENTRY
bHeight | MEMICONDIRENTRY
bReserved | MEMICONDIRENTRY
bWidth | MEMICONDIRENTRY
dwBytesInRes | MEMICONDIRENTRY
nID | MEMICONDIRENTRY
wBitCount | MEMICONDIRENTRY
wPlanes | MEMICONDIRENTRY
Generated on Wed Nov 13 2024 16:57:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Administration/Explore.VC/AppInstallDlg.Cpp Source File

  • Com
  • Administration
  • Explore.VC

AppInstallDlg.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018
00019 #include "stdafx.h"
00020 #include "VCExplore.h"
00021 #include "AppInstallDlg.h"
00022
00023 #ifdef _DEBUG
00024 #define new DEBUG_NEW
00025 #undef THIS_FILE
00026 static char THIS_FILE[] = __FILE__;
00027 #endif
00028
00029
00030 #define APP_INSTALL_TYPE_UNDEFINED    -1
00031 #define APP_INSTALL_TYPE_WITHOUT_USERS  0
00032 #define APP_INSTALL_TYPE_WITH_USERS   1
00033
00034
00035 /////////////////////////////////////////////////////////////////////////////
00036 // CAppInstallDlg dialog
00037
00038
00039 CAppInstallDlg::CAppInstallDlg(CWnd* pParent /*=NULL*/)
00040   : CDialog(CAppInstallDlg::IDD, pParent)
00041 {
00042   //{{AFX_DATA_INIT(CAppInstallDlg)
00043     // NOTE: the ClassWizard will add member initialization here
00044   //}}AFX_DATA_INIT
00045
00046   // Load the dialogs icon resource
00047   m_hIcon = AfxGetApp()->LoadIcon(IDI_INSTALL);
00048
00049   // Initialize the members
00050   m_pCatalog = NULL;
00051   m_nInstallType = APP_INSTALL_TYPE_UNDEFINED;
00052   m_bOverwriteFiles = false;
00053   m_bRemoteInstall = false;
00054 }
00055
00056
00057 void CAppInstallDlg::DoDataExchange(CDataExchange* pDX)
00058 {
00059   CDialog::DoDataExchange(pDX);
00060   //{{AFX_DATA_MAP(CAppInstallDlg)
00061   DDX_Control(pDX, IDC_EDIT_UID, m_edtUID);
00062   DDX_Control(pDX, IDC_EDIT_PWD, m_edtPWD);
00063   DDX_Control(pDX, IDC_EDIT_REMOTE_SERVER_NAME, m_edtRemoteServerName);
00064   DDX_Control(pDX, IDC_EDIT_INSTALL_DIRECTORY, m_edtInstallDir);
00065   DDX_Control(pDX, IDC_EDIT_APPLICATION_FILE, m_edtAppFile);
00066   //}}AFX_DATA_MAP
00067
00068 }
00069
00070
00071 BEGIN_MESSAGE_MAP(CAppInstallDlg, CDialog)
00072   //{{AFX_MSG_MAP(CAppInstallDlg)
00073   ON_WM_CLOSE()
00074   ON_BN_CLICKED(IDC_BUTTON_APPLICATION_FILE_SEARCH, OnAppFileSearch)
00075   ON_BN_CLICKED(IDC_BUTTON_INSTALL_DIRECTORY_SEARCH, OnInstallDirSearch)
00076   ON_BN_CLICKED(IDC_RADIO_INSTALL_WITH_USERS, OnInstallWithUsers)
00077   ON_BN_CLICKED(IDC_RADIO_INSTALL_WITHOUT_USERS, OnInstallWithoutUsers)
00078   ON_BN_CLICKED(IDC_CHECK_OVERWRITE_FILES, OnOverwriteFiles)
00079   ON_BN_CLICKED(IDC_CHECK_REMOTE_SERVER_INSTALL, OnRemoteServerInstall)
00080   //}}AFX_MSG_MAP
00081 END_MESSAGE_MAP()
00082
00083 /////////////////////////////////////////////////////////////////////////////
00084 // CAppInstallDlg message handlers
00085
00086 void CAppInstallDlg::set_Catalog(ICOMAdminCatalog *pCatalog)
00087 {
00088   // Only can have one Catalog object reference... release all prior references before assignment
00089   ReleaseCatalog();
00090
00091   // Assign the new Catalog reference
00092   m_pCatalog = pCatalog;
00093 }
00094
00095 void CAppInstallDlg::OnClose()
00096 {
00097   // Release the reference to the Catalog object if needed
00098   ReleaseCatalog();
00099
00100   CDialog::OnClose();
00101 }
00102
00103 void CAppInstallDlg::OnOK()
00104 {
00105   // Continue only if we have a valid Catalog pointer
00106   if (NULL != m_pCatalog)
00107   {
00108     long  lOptions = 0;
00109
00110     // Determine the install options
00111     if (m_nInstallType == APP_INSTALL_TYPE_WITHOUT_USERS)
00112       lOptions = lOptions | COMAdminInstallNoUsers;
00113     else
00114       lOptions = lOptions | COMAdminInstallUsers;
00115
00116     if (m_bOverwriteFiles)
00117       lOptions = lOptions | COMAdminInstallForceOverwriteOfFiles;
00118
00119     // Extract method parameters from the UI
00120     int nAppFileLength = m_edtAppFile.GetWindowTextLength() + 1;
00121     char* pAppFileBuf = new char[nAppFileLength];
00122     m_edtAppFile.GetWindowText(pAppFileBuf, nAppFileLength);
00123     _bstr_t bstrAppFile = pAppFileBuf;
00124     delete [] pAppFileBuf;
00125
00126     int nInstallDirLength = m_edtInstallDir.GetWindowTextLength() + 1;
00127     char* pInstallDirBuf = new char[nInstallDirLength];
00128     m_edtInstallDir.GetWindowText(pInstallDirBuf, nInstallDirLength);
00129     _bstr_t bstrInstallDir = pInstallDirBuf;
00130     delete [] pInstallDirBuf;
00131
00132     HRESULT hr = 0;
00133     // Perform local vs. remote server install
00134     if (m_bRemoteInstall)
00135     {
00136       int nUIDLength = m_edtUID.GetWindowTextLength() + 1;
00137       char* pUIDBuf = new char[nUIDLength];
00138       m_edtUID.GetWindowText(pUIDBuf, nUIDLength);
00139       _bstr_t bstrUID = pUIDBuf;
00140       delete [] pUIDBuf;
00141
00142       int nPWDLength = m_edtPWD.GetWindowTextLength() + 1;
00143       char* pPWDBuf = new char[nPWDLength];
00144       m_edtPWD.GetWindowText(pPWDBuf, nPWDLength);
00145       _bstr_t bstrPWD = pPWDBuf;
00146       delete [] pPWDBuf;
00147
00148       int nRSNLength = m_edtRemoteServerName.GetWindowTextLength() + 1;
00149       char* pRSNBuf = new char[nRSNLength];
00150       m_edtRemoteServerName.GetWindowText(pRSNBuf, nRSNLength);
00151       _bstr_t bstrRSN = pRSNBuf;
00152       delete [] pRSNBuf;
00153
00154       // Attempt a remote server install
00155       hr = m_pCatalog->InstallApplication(bstrAppFile,
00156                         bstrInstallDir,
00157                         lOptions,
00158                         bstrUID,
00159                         bstrPWD,
00160                         bstrRSN);
00161     }
00162     else
00163     {
00164       // Attempt a local install
00165       hr = m_pCatalog->InstallApplication(bstrAppFile,
00166                         bstrInstallDir,
00167                         lOptions,
00168                         NULL,
00169                         NULL,
00170                         NULL);
00171     }
00172
00173     // Validate success/fail of attempted app install
00174     if FAILED(hr)
00175       MessageBox("Failed to install the specified application.\n\nPress OK to continue.",
00176             "Error",
00177             (MB_OK | MB_ICONERROR));
00178   }
00179   else
00180     MessageBox("Invalid Catalog reference.\n\nNo processing will be performed.\n\nPress OK to continue.",
00181           "Error",
00182           (MB_OK | MB_ICONERROR));
00183
00184   // Release the Catalog reference
00185   ReleaseCatalog();
00186
00187   CDialog::OnOK();
00188 }
00189
00190 void CAppInstallDlg::ReleaseCatalog()
00191 {
00192   // Release the reference to the Catalog object if needed
00193   if (NULL != m_pCatalog)
00194     m_pCatalog->Release();
00195 }
00196
00197 void CAppInstallDlg::OnAppFileSearch()
00198 {
00199   OPENFILENAME ofn;
00200   char pFilePath[256];
00201   char pFileTitle[256];
00202
00203   // Setup of OPENFILENAME structure
00204   ofn.lStructSize = sizeof(OPENFILENAME);
00205     ofn.hwndOwner = m_hWnd;
00206     ofn.hInstance = NULL;
00207     ofn.lpstrFilter = "All Files (*.*)\0*.*\0\0";
00208     ofn.lpstrCustomFilter = (LPSTR) NULL;
00209     ofn.nMaxCustFilter = 0;
00210     ofn.nFilterIndex = 1;
00211     pFilePath[0] = '\0';
00212     ofn.lpstrFile = pFilePath;
00213     ofn.nMaxFile = sizeof(pFilePath);
00214     ofn.lpstrFileTitle = pFileTitle;
00215     ofn.nMaxFileTitle = sizeof(pFileTitle);
00216     ofn.lpstrInitialDir = NULL;
00217   ofn.lpstrTitle = "Select Application to install";
00218     ofn.Flags = (OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST);
00219     ofn.lpstrDefExt = "DLL";
00220     ofn.nFileOffset = 0;
00221     ofn.nFileExtension = 0;
00222     ofn.lCustData = 0;
00223
00224   // Invoke the file open common dialog
00225   GetOpenFileName(&ofn);
00226
00227   // Update the value in the control
00228   m_edtAppFile.SetWindowText(ofn.lpstrFile);
00229 }
00230
00231 void CAppInstallDlg::OnInstallDirSearch()
00232 {
00233   OPENFILENAME ofn;
00234   char pFilePath[256];
00235   char pFileTitle[256];
00236
00237   // Setup of OPENFILENAME structure
00238   ofn.lStructSize = sizeof(OPENFILENAME);
00239     ofn.hwndOwner = m_hWnd;
00240     ofn.hInstance = NULL;
00241     ofn.lpstrFilter = "All Files (*.*)\0*.*\0\0";
00242     ofn.lpstrCustomFilter = (LPSTR) NULL;
00243     ofn.nMaxCustFilter = 0;
00244     ofn.nFilterIndex = 1;
00245     pFilePath[0] = '\0';
00246     ofn.lpstrFile = pFilePath;
00247     ofn.nMaxFile = sizeof(pFilePath);
00248     ofn.lpstrFileTitle = pFileTitle;
00249     ofn.nMaxFileTitle = sizeof(pFileTitle);
00250     ofn.lpstrInitialDir = NULL;
00251   ofn.lpstrTitle = "Select the install directory";
00252     ofn.Flags = (OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST);
00253     ofn.lpstrDefExt = "DLL";
00254     ofn.nFileOffset = 0;
00255     ofn.nFileExtension = 0;
00256     ofn.lCustData = 0;
00257
00258   // Invoke the file open common dialog
00259   GetOpenFileName(&ofn);
00260
00261   // Update the value in the control
00262   m_edtInstallDir.SetWindowText(ofn.lpstrFile);
00263 }
00264
00265 BOOL CAppInstallDlg::OnInitDialog()
00266 {
00267   CDialog::OnInitDialog();
00268
00269   // Set the dialog's icon resource
00270   SetIcon(m_hIcon, true);     // 32x32 icon
00271   SetIcon(m_hIcon, false);    // 16x16 icon
00272
00273   // Select and set default export type
00274   CheckRadioButton(IDC_RADIO_INSTALL_WITHOUT_USERS, IDC_RADIO_INSTALL_WITH_USERS, IDC_RADIO_INSTALL_WITHOUT_USERS);
00275
00276   // Set the import type and description to match the current selection
00277   OnInstallWithoutUsers();
00278
00279   // Set the state of the Remote Server Install control group
00280   ToggleRemoteServerState(false);
00281
00282   return TRUE;  // return TRUE unless you set the focus to a control
00283                 // EXCEPTION: OCX Property Pages should return FALSE
00284 }
00285
00286 void CAppInstallDlg::OnInstallWithUsers()
00287 {
00288   // Set the install type
00289   m_nInstallType = APP_INSTALL_TYPE_WITHOUT_USERS;
00290 }
00291
00292 void CAppInstallDlg::OnInstallWithoutUsers()
00293 {
00294   // Set the install type
00295   m_nInstallType = APP_INSTALL_TYPE_WITH_USERS;
00296 }
00297
00298 void CAppInstallDlg::OnOverwriteFiles()
00299 {
00300   // Toggle the overwrite flag
00301   m_bOverwriteFiles = !m_bOverwriteFiles;
00302 }
00303
00304 void CAppInstallDlg::ToggleRemoteServerState(bool Flag)
00305 {
00306   // Clear the controls and toggle it's state
00307   m_edtRemoteServerName.SetSel(0, -1, false);
00308   m_edtRemoteServerName.Clear();
00309   m_edtRemoteServerName.EnableWindow(Flag);
00310
00311   m_edtUID.SetSel(0, -1, false);
00312   m_edtUID.Clear();
00313   m_edtUID.EnableWindow(Flag);
00314
00315   m_edtPWD.SetSel(0, -1, false);
00316   m_edtPWD.Clear();
00317   m_edtPWD.EnableWindow(Flag);
00318 }
00319
00320 void CAppInstallDlg::OnRemoteServerInstall()
00321 {
00322   // Toggle the variable used to manage the Remote Server Install group
00323   m_bRemoteInstall = !m_bRemoteInstall;
00324
00325   // Toggle the UI to reflect the new state of the control group
00326   ToggleRemoteServerState(m_bRemoteInstall);
00327 }
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

XBStr Member List

This is the complete list of members for XBStr, including all inherited members.
_p | XBStr | [private]
Acquire() | XBStr | [inline]
Acquire() | XBStr | [inline]
Free() | XBStr | [inline]
Free() | XBStr | [inline]
GetPointer() const | XBStr | [inline]
GetPointer() const | XBStr | [inline]
IsNull() const | XBStr | [inline]
IsNull() const | XBStr | [inline]
Set(BSTR pOleStr) | XBStr | [inline]
Set(BSTR pOleStr) | XBStr | [inline]
SetText(WCHAR const *pStr) | XBStr | [inline]
XBStr(BSTR p=0) | XBStr | [inline]
XBStr(XBStr &x) | XBStr | [inline]
XBStr(BSTR p=0) | XBStr | [inline]
XBStr(XBStr &x) | XBStr | [inline]
~XBStr() | XBStr | [inline]
~XBStr() | XBStr | [inline]
Generated on Wed Nov 13 2024 16:58:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/contextmenu/about.h Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • contextmenu

about.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:     This class implements ISnapinAbout
00014
00015
00016
00017 #ifndef _CLASS_CSNAPINABOUT_
00018 #define _CLASS_CSNAPINABOUT_
00019
00020 #include <mmc.h>
00021
00022
00023 //---------------------------------------------------------------------------
00024 class CSnapinAbout : public ISnapinAbout
00025 {
00026   private:
00027     ULONG       m_cRef;
00028     HBITMAP     m_hSmallImage;
00029     HBITMAP     m_hLargeImage;
00030     HBITMAP     m_hOpenImage;
00031     HICON       m_hAppIcon;
00032
00033   public:
00034     CSnapinAbout();
00035     ~CSnapinAbout();
00036
00037     /////////////////////////////////////////////////////////////////////////
00038     // Interface IUnknown
00039     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00040     STDMETHODIMP_(ULONG) AddRef();
00041     STDMETHODIMP_(ULONG) Release();
00042
00043     /////////////////////////////////////////////////////////////////////////
00044     // Interface ISnapinAbout
00045     STDMETHODIMP GetSnapinDescription(/*[out]*/ LPOLESTR* pszDescription );
00046
00047     STDMETHODIMP GetProvider(/*[out]*/ LPOLESTR* pszProvider );
00048
00049     STDMETHODIMP GetSnapinVersion(/*[out]*/ LPOLESTR* pszVersion);
00050
00051     STDMETHODIMP GetSnapinImage(/*[out]*/ HICON* hAppIcon );
00052
00053     STDMETHODIMP GetStaticFolderImage
00054                  (/*[out]*/ HBITMAP*  hSmallImage,
00055                   /*[out]*/ HBITMAP*  hOpenImage,
00056                   /*[out]*/ HBITMAP*  hLargeImage,
00057                   /*[out]*/ COLORREF* cMask
00058                  );
00059 };
00060
00061 #endif _CLASS_CSNAPINABOUT_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Pipes/Client/client.cxx Source File

  • Com
  • Fundamentals
  • Pipes
  • Client

client.cxx

Go to the documentation of this file.
00001 /* Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00002  *
00003  *
00004  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00005  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00006  * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00007 */
00008
00009 #include <objbase.h>
00010 #include <conio.h>
00011 #include <tchar.h>
00012 #include <iostream.h>
00013 #include "ISimpleInterface.h"
00014
00015 #include "..\include\pipe.hxx"
00016
00017 LPTSTR   g_szMessage;
00018
00019 typedef enum _options { PIPE_AS_IN_PARAMETER=1, PIPE_AS_OUT_PARAMETER,
00020                 PIPE_AS_IN_OUT_PARAMETER, PIPES_AS_IN_IN_OUT_PARAMETERS
00021               } clOption;
00022
00023 void usage()
00024 {
00025    cout << endl << "Usage: client <OPTION>" << endl << endl
00026            << "OPTION : PIPE_AS_IN_PARAMETER | PIPE_AS_OUT_PARAMETER | "
00027            << " PIPE_AS_IN_OUT_PARAMETER | PIPES_AS_IN_IN_OUT_PARAMETERS "
00028            << endl << endl;
00029    return;
00030 }
00031
00032 int map(char *szOption)
00033 {
00034    int option=0;
00035    if (!strcmp(szOption, "PIPE_AS_IN_PARAMETER")) { option=1; }
00036    else if (!strcmp(szOption,"PIPE_AS_OUT_PARAMETER")) { option=2; }
00037    else if (!strcmp(szOption,"PIPE_AS_IN_OUT_PARAMETER")) { option=3; }
00038    else if (!strcmp(szOption,"PIPES_AS_IN_IN_OUT_PARAMETERS")) { option=4; }
00039    else { option=0; }
00040    return option;
00041 }
00042
00043 void Message(HRESULT hr)
00044 {
00045     if (HRESULT_FACILITY(hr) == FACILITY_WINDOWS)
00046         hr = HRESULT_CODE(hr);
00047
00048     FormatMessage(
00049         FORMAT_MESSAGE_ALLOCATE_BUFFER |
00050         FORMAT_MESSAGE_FROM_SYSTEM,
00051         NULL,
00052         hr,
00053         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00054         (LPTSTR)&g_szMessage,
00055         0,
00056         NULL);
00057 }
00058
00059 int CreateInstance(ISimpleInterface **ppSI)
00060 {
00061    HRESULT hr = S_OK;
00062    hr=CoInitializeEx(NULL, COINIT_MULTITHREADED);
00063    hr=CoCreateInstance(CLSID_SimpleClass,0,CLSCTX_LOCAL_SERVER,IID_ISimpleInterface, (void**)&(*ppSI));
00064    if (FAILED(hr)) {
00065       Message(hr);
00066       MessageBox(NULL, g_szMessage, TEXT("CLIENT : COCREATEINSTANCE ERROR"), MB_SETFOREGROUND);
00067       CoUninitialize();
00068       return 0;
00069    }
00070    return 1;
00071 }
00072
00073 inline void cleanup()
00074 {
00075    //CoFreeUnusedLibraries();
00076    CoUninitialize();
00077 }
00078
00079 /**********************************************************
00080 * PIPE_AS_IN_PARAMETER option
00081 **********************************************************/
00082
00083 void pipe_in()
00084 {
00085    HRESULT hr = S_OK;
00086    cout << endl << "***** Running [In] Pipe Example *****" << endl << endl;
00087
00088    // Create an instance of the simple class
00089    ISimpleInterface* pSI=NULL;
00090    if (!CreateInstance(&pSI)) { return; }
00091
00092    // The client needs to Create a pipe
00093    CSamplePipe* pInPipe = new CSamplePipe();
00094    pInPipe->AddRef();
00095    // Pass the pipe to the server as an 'in' parameter.
00096    // Since the client implements both Pull and Push operations,
00097    // the server can use these callbacks.
00098    hr=pSI->InPipeSample(pInPipe);
00099    if (FAILED(hr)) {
00100       MessageBox(NULL, TEXT("InPipe couldn't be used by the server/callee"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00101    }
00102    else
00103    {
00104       cout << endl << "InPipe was successfully used by the server/callee." << endl;
00105    }
00106
00107    // Resource management
00108    hr=pInPipe->Release();
00109    hr=pSI->Release();
00110    pInPipe=NULL;
00111    pSI=NULL;
00112    cleanup();
00113    return;
00114 }
00115
00116 /************************************************************
00117 * PIPE_AS_OUT_PARAMETER option
00118 ************************************************************/
00119
00120 void pipe_out()
00121 {
00122    HRESULT hr = S_OK;
00123    cout << endl << "***** Running [Out] Pipe Example *****" << endl << endl;
00124
00125    // Create an instance of the simple class
00126    ISimpleInterface* pSI=NULL;
00127    if (!CreateInstance(&pSI)) { return; }
00128
00129    // The server will create the pipe
00130    IPipeLong *pOutPipe=NULL;
00131
00132    // Get the pipe from the server as an 'out' parameter.
00133    // Since the server implements both Pull and Push operations,
00134    // the client can use these callbacks.
00135    hr=pSI->OutPipeSample(&pOutPipe);
00136    if (FAILED(hr)) {
00137       MessageBox(NULL, TEXT("Invalid OutPipe returned by the server"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00138       cleanup(); return;
00139    }
00140
00141    /*
00142    ** Drain in (PULL) the pipe.
00143    */
00144
00145    cout << "OPERATION: PULLing one sequence from the OutPipe" << endl;
00146    ULONG lPulled=0;
00147    LONG *buffer1 = new LONG[2000 + 1];
00148
00149    hr=GenericPull(pOutPipe, buffer1, &lPulled, 0);
00150    if (FAILED(hr)) {
00151       MessageBox(NULL, TEXT("PULL FAILED ON OUTPIPE"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00152       cleanup(); return;
00153    }
00154    else {
00155       cout << "RESULT: success !"
00156            << endl << endl;
00157    }
00158
00159    /*
00160    ** PUSH 500 elements to the pipe.
00161    */
00162    cout << "OPERATION: PUSHing one sequence to the OutPipe" << endl;
00163
00164    LONG *buffer2 = new LONG[2000 + 1];
00165
00166    hr=GenericPush(pOutPipe, buffer2, 500);
00167    if (FAILED(hr)) {
00168       MessageBox(NULL, TEXT("PUSH FAILED ON OUTPIPE"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00169       cleanup(); return;
00170    }
00171
00172    /*
00173    ** Push 0 to close this sequence
00174    */
00175
00176    hr=GenericPush(pOutPipe, buffer2, 0);
00177    if (FAILED(hr)) {
00178       MessageBox(NULL, TEXT("PUSH FAILED ON OUTPIPE"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00179       cleanup(); return;
00180    }
00181    else {
00182       cout << "RESULT: success !"
00183            << endl << endl;
00184    }
00185
00186    // Resource management
00187    pOutPipe->Release();
00188    hr=pSI->Release();
00189    cleanup();
00190    return;
00191 }
00192
00193 /******************************************************************
00194 * PIPE_AS_IN_OUT_PARAMETER option
00195 *****************************************************************/
00196
00197 void pipe_in_out()
00198 {
00199    cout << endl << "***** Running [In,Out] Pipe Example *****" << endl << endl;
00200    HRESULT hr = S_OK;
00201
00202    // Create an instance of the simple class
00203    ISimpleInterface* pSI;
00204    if (!CreateInstance(&pSI)) { return; }
00205
00206    // The client needs to Create a pipe
00207    IPipeLong* pInOutPipe;
00208
00209    pInOutPipe = new CSamplePipe();
00210
00211    // Pass the pipe to the server as an 'in,out' parameter.
00212    // Since the client implements both Pull and Push operations,
00213    // the server can use these callbacks.
00214    pInOutPipe->AddRef();
00215    hr=pSI->InOutPipeSample(&pInOutPipe);
00216    if (FAILED(hr)) {
00217       MessageBox(NULL, TEXT("InOutPipe invalid on return from server"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00218       hr=pSI->Release();
00219       cleanup(); return;
00220    }
00221
00222    // Use the returned Pipe now
00223
00224    /*
00225    ** Drain in (PULL) the pipe.
00226    */
00227    cout << "OPERATION: PULLing one sequence from the InOutPipe" << endl;
00228    ULONG lPulled=0;
00229    LONG *buffer1 = new LONG[2000 + 1];
00230
00231    hr=GenericPull(pInOutPipe, buffer1, &lPulled, 0);
00232    if (FAILED(hr)) {
00233       MessageBox(NULL, TEXT("PULL FAILED ON INOUTPIPE"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00234       cleanup(); return;
00235    }
00236    else {
00237       cout << "RESULT: success !"
00238            << endl << endl;
00239    }
00240
00241    // Resource management
00242    pInOutPipe->Release();
00243    hr=pSI->Release();
00244    cleanup();
00245    return;
00246 }
00247
00248 /******************************************************************
00249 * PIPES_AS_IN_IN_OUT_PARAMETERS option
00250 *****************************************************************/
00251
00252 void pipes_in_in_out()
00253 {
00254    cout << endl << "***** Running [In] [In] [Out] Example *****" << endl;
00255
00256    HRESULT hr = S_OK;
00257
00258    // Create an instance of the simple class
00259    ISimpleInterface* pSI;
00260    if (!CreateInstance(&pSI)) { return; }
00261
00262    // The client needs to Create In pipes
00263    IPipeLong* pInPipe1=NULL;
00264    IPipeLong* pInPipe2=NULL;
00265    IPipeLong* pOutPipe=NULL;
00266
00267    // The client needs to Create In pipes
00268    pInPipe1 = new CSamplePipe();
00269    pInPipe2 = new CSamplePipe();
00270
00271    // Pass the pipes to the server as an 'in' parameter.
00272    // Since the client implements both Pull and Push operations,
00273    // the server can use these callbacks.
00274    hr=pSI->InInOutPipesSample(pInPipe1,pInPipe2,&pOutPipe);
00275    if (FAILED(hr)) {
00276   MessageBox(NULL, TEXT("Pipes couldn't be used by the server/callee"), TEXT("CLIENT: ERROR"), MB_SETFOREGROUND);
00277    }
00278    else
00279    {
00280       cout << endl << "Pipes were successfully used by the server/callee." << endl;
00281    }
00282
00283    // Resource management
00284    pInPipe1->Release();
00285    pInPipe1 = NULL;
00286    pInPipe2->Release();
00287    pInPipe2 = NULL;
00288    pOutPipe->Release();
00289    pOutPipe=NULL;
00290    hr=pSI->Release();
00291    pSI = NULL;
00292    cleanup();
00293
00294    return;
00295 }
00296
00297
00298 /********************************************************
00299 ** Main function for the client
00300 *********************************************************/
00301
00302 int main(int argc, char *argv[])
00303 {
00304    if (argc != 2) { usage(); return -1; }
00305
00306    int option;
00307    char* szOption=new char[strlen(argv[1])+1];
00308    strcpy(szOption, argv[1]);
00309
00310    // Map input option to desired switch value
00311    option=map(szOption);
00312
00313    // Execute the appropriate function
00314    switch (option)
00315    {
00316       case PIPE_AS_IN_PARAMETER:          pipe_in();
00317                   break;
00318       case PIPE_AS_OUT_PARAMETER:         pipe_out();
00319                   break;
00320       case PIPE_AS_IN_OUT_PARAMETER:      pipe_in_out();
00321                   break;
00322       case PIPES_AS_IN_IN_OUT_PARAMETERS: pipes_in_in_out();
00323             break;
00324       default:                            usage();
00325                               break;
00326    };
00327    return 0;
00328 };
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/PlugTransport/iplgxprt.idl Source File

  • Web
  • NetMeeting
  • PlugTransport

iplgxprt.idl

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright 1995 - 2002 Microsoft Corporation. All Rights Reserved.
00004 //
00005 //----------------------------------------------------------------------------
00006 import "oaidl.idl";
00007 import "ocidl.idl";
00008
00009
00010 #define UUID_IPluggableTransport        FB7045F0-A4DC-11D2-B724-00104BC51339
00011
00012
00013
00014 ////////////////////////////////////////////////////////////////////////////////////////
00015 //  NOTE NOTE: this is taken from AxCore.idl
00016 // Win32 HANDLEs have to be cast to these as the MIDL compiler doesn't
00017 // like the HANDLE type or in fact anything remotely associated with
00018 // them. If this ever gets ported to a MAC environment then these will
00019 // have to become an alertable synchronisation object that it supports
00020 typedef unsigned int HCOMMDEV;
00021 typedef unsigned int HEVENT;
00022
00023
00024 typedef enum tagPLUGXPRT_FRAMING
00025 {
00026     FRAMING_LEGACY_PSTN     = 0,    // legacy PSTN framing
00027     FRAMING_X224            = 1,    // X224 Connect + X224 Data Transfer
00028 }
00029     PLUGXPRT_FRAMING;
00030
00031
00032 typedef enum tagPLUGXPRT_CALL_TYPE
00033 {
00034     PLUGXPRT_UNKNOWN_CALL_TYPE  = 0,
00035     PLUGXPRT_CALLER             = 1,
00036     PLUGXPRT_CALLEE             = 2,
00037 }
00038     PLUGXPRT_CALL_TYPE;
00039
00040
00041 typedef enum tagPLUGXPRT_PSTN_CALL_CONTROL
00042 {
00043     PLUGXPRT_PSTN_CALL_CONTROL_PORT_HANDLE    = 0,  // default, for normal PSTN
00044     PLUGXPRT_PSTN_CALL_CONTROL_MANUAL         = 1,  // for legacy null modem
00045 }
00046     PLUGXPRT_PSTN_CALL_CONTROL;
00047
00048
00049
00050 typedef struct tagPLUGXPRT_PARAMETERS
00051 {
00052     ULONG       cbStructSize;                       // size of this structure, must be initialized
00053     DWORD       dwFlags;                            // valid fields defined below
00054     /* PSTN framing */
00055     PLUGXPRT_PSTN_CALL_CONTROL  eCallControl;       // PSTN call control
00056     ULONG       cbReadFileBufferSize;               // 10K default; must be no less than 1K
00057     ULONG       cbPhysicalLayerSendBufferSize;      //  1K default; must be no less than the default
00058     ULONG       cbPhysicalLayerReceiveBufferSize;   // 10K default; must be no less than 1K
00059     ULONG       cMaximumT200TimeoutsInQ922;         //   5 default; must be no less than the default
00060     ULONG       nT203TimeoutInQ922;                 // must be no less than the default, which is
00061                                                     // 30000 for PLUGXPRT_PSTN_CALL_CONTROL_PORT_HANDLE,
00062                                                     //   600 for PLUGXPRT_PSTN_CALL_CONTROL_MANUAL
00063     /* X.224 framing */
00064     // ...nothing so far...
00065 }
00066     PLUGXPRT_PARAMETERS;
00067
00068 cpp_quote("#define PSTN_PARAM__CALL_CONTROL                      0x0001")
00069 cpp_quote("#define PSTN_PARAM__READ_FILE_BUFFER_SIZE             0x0002")
00070 cpp_quote("#define PSTN_PARAM__PHYSICAL_LAYER_SEND_BUFFER_SIZE   0x0004")
00071 cpp_quote("#define PSTN_PARAM__PHSYICAL_LAYER_RECV_BUFFER_SIZE   0x0008")
00072 cpp_quote("#define PSTN_PARAM__MAX_T200_TIMEOUT_COUNT_IN_Q922    0x0010")
00073 cpp_quote("#define PSTN_PARAM__T203_TIMEOUT_IN_Q922              0x0020")
00074
00075
00076
00077 [
00078     object,
00079     uuid(UUID_IPluggableTransport),
00080     pointer_default(unique)
00081 ]
00082 interface IPluggableTransport : IUnknown
00083 {
00084     HRESULT CreateConnection(
00085         [out] BSTR             *pbstrConnectionID,      // For placing a call and closing connection
00086         [in] PLUGXPRT_CALL_TYPE eCaller,                // caller vs callee
00087         [in] DWORD              dwProcessID,            // Used for DuplicateHandle
00088         [in] HCOMMDEV           hCommLink,              // Handle to communications file handle
00089         [in] HEVENT             hevtDataAvailable,      // Ready To Read event ( data avail )
00090         [in] HEVENT             hevtWriteReady,         // Ready To Write event
00091         [in] HEVENT             hevtConnectionClosed,   // Connection closed ( unexpectedly???)
00092         [in] PLUGXPRT_FRAMING   eFraming,               // framing of bits sent on link
00093         [in] PLUGXPRT_PARAMETERS *pParams               // OPTIONAL framing specific parameters
00094     );
00095
00096     HRESULT CloseConnection(
00097         [in] BSTR               bstrConnectionID);
00098
00099     HRESULT EnableWinsock( );
00100
00101     HRESULT DisableWinsock( );
00102 };
00103
00104
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Concurrency/SyncComp/SyncComp.Idl Source File

  • Com
  • Services
  • Concurrency
  • SyncComp

SyncComp.Idl

Go to the documentation of this file.
00001 // SyncComp.idl : IDL source for SyncComp.dll
00002 // This is just here so we can use the ATL Wizards
00003 //
00004
00005 library DummyLib
00006 {
00007 };
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

BROWSER_CONFIG Member List

This is the complete list of members for BROWSER_CONFIG, including all inherited members.
fEnableProxyFailover | BROWSER_CONFIG
fProxyAutoDiscovery | BROWSER_CONFIG
nFailureRetries | BROWSER_CONFIG
nTimeLimit | BROWSER_CONFIG
pwszEmbeddedLinks | BROWSER_CONFIG
pwszHomePage | BROWSER_CONFIG
Generated on Wed Nov 13 2024 16:55:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/GridFont/Resource.h Source File

  • Multimedia
  • Gdi
  • Fonts
  • GridFont

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Visual C++ generated include file.
00003 // Used by APP.RC
00004 //
00005 #define IDC_PROPLIST                    1000
00006 #define IDM_SHOWPROP                    40001
00007 #define IDC_STATIC                      -1
00008
00009 // Next default values for new objects
00010 //
00011 #ifdef APSTUDIO_INVOKED
00012 #ifndef APSTUDIO_READONLY_SYMBOLS
00013 #define _APS_NO_MFC                     1
00014 #define _APS_NEXT_RESOURCE_VALUE        102
00015 #define _APS_NEXT_COMMAND_VALUE         40002
00016 #define _APS_NEXT_CONTROL_VALUE         1001
00017 #define _APS_NEXT_SYMED_VALUE           101
00018 #endif
00019 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCertManageExitModuleSample Member List

This is the complete list of members for CCertManageExitModuleSample, including all inherited members.
CCertManageExitModuleSample() | CCertManageExitModuleSample | [inline]
CCertManageExitModuleSample() | CCertManageExitModuleSample | [inline]
Configure(const BSTR strConfig, BSTR strStorageLocation, LONG dwFlags) | CCertManageExitModuleSample |
Configure(const BSTR strConfig, BSTR strStorageLocation, LONG dwFlags) | CCertManageExitModuleSample |
~CCertManageExitModuleSample() | CCertManageExitModuleSample | [inline]
~CCertManageExitModuleSample() | CCertManageExitModuleSample | [inline]
Generated on Wed Nov 13 2024 16:55:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

persistatl::NewsEvent Member List

This is the complete list of members for persistatl::NewsEvent, including all inherited members.
iid | persistatl::INewsEventDefault | [static]
LongQuote(String Symbol, double BidPrice, double AskPrice, String LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow, int AskSize, int BidSize, double OpenPrice, double ClosePrice, String CloseDate) | persistatl::NewsEvent | [inline]
NewsFlash(double dtTimeStamp, String Symbol, String Headline, String URL) | persistatl::NewsEvent | [inline]
ShortQuote(String Symbol, double BidPrice, double AskPrice, double LastTradeTime, double LastTradePrice, double NetChange, double DailyHigh, double DailyLow) | persistatl::NewsEvent | [inline]
Generated on Wed Nov 13 2024 16:58:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/DataAccess/DataAcADO/StdAfx.h Source File

  • Com
  • Services
  • Transaction
  • DataAccess
  • DataAcADO

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__FD6AF2C7_E380_11D0_823B_00AA00A3F13E__INCLUDED_)
00006 #define AFX_STDAFX_H__FD6AF2C7_E380_11D0_823B_00AA00A3F13E__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 #define STRICT
00013
00014
00015 #if !defined(_WIN32_WINNT)
00016 #define _WIN32_WINNT 0x0500
00017 #endif // !defined(_WIN32_WINNT)
00018
00019 #define _ATL_APARTMENT_THREADED
00020
00021
00022 #include <atlbase.h>
00023 //You may derive a class from CComModule and use it if you want to override
00024 //something, but do not change the name of _Module
00025 extern CComModule _Module;
00026 #include <atlcom.h>
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00030
00031 #endif // !defined(AFX_STDAFX_H__FD6AF2C7_E380_11D0_823B_00AA00A3F13E__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNewsJAVA/ComAdmin/COMAdminServiceOptions.java Source File

  • Com
  • Services
  • Events
  • EventNewsJAVA
  • ComAdmin

COMAdminServiceOptions.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc6EA.tmp" /nologo /d "D:\Documents and Settings\a-joest\Desktop\Sunil" "A:\comadmin.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package comadmin;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Enum: COMAdminServiceOptions
00019
00020 public interface COMAdminServiceOptions
00021 {
00022   public static final int COMAdminServiceLoadBalanceRouter = 1;
00023 }
Generated on Wed Nov 13 2024 16:51:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/Dt_Dll2/Dt_Dll.Hpp Source File

  • NetDS
  • WinSock
  • Dt_Dll2

Dt_Dll.Hpp

Go to the documentation of this file.
00001 // Filename  : dt_dll.hpp
00002 // Abstract  : This header defines the various DT API hook codes.
00003 // Author    : Jeffrey C. Venable, Sr.
00004 // Copyright : THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
00005 //             WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
00006 //             INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
00007 //             MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00008 //             Copyright (C) 1998 - 2001,  Microsoft Corporation.
00009 //             All rights reserved.
00010
00011 #if !defined(DT_DLL_HPP)
00012 #define DT_DLL_HPP
00013
00014     #define DTCODE_accept                              1
00015     #define DTCODE_bind                                2
00016     #define DTCODE_closesocket                         3
00017     #define DTCODE_connect                             4
00018     #define DTCODE_getpeername                         5
00019     #define DTCODE_getsockname                         6
00020     #define DTCODE_getsockopt                          7
00021     #define DTCODE_htonl                               8
00022     #define DTCODE_htons                               9
00023     #define DTCODE_ioctlsocket                        10
00024     #define DTCODE_listen                             11
00025     #define DTCODE_ntohl                              12
00026     #define DTCODE_ntohs                              13
00027     #define DTCODE_recv                               14
00028     #define DTCODE_recvfrom                           15
00029     #define DTCODE_select                             16
00030     #define DTCODE_send                               17
00031     #define DTCODE_sendto                             18
00032     #define DTCODE_setsockopt                         19
00033     #define DTCODE_shutdown                           20
00034     #define DTCODE_socket                             21
00035     #define DTCODE_WSAAccept                          22
00036     #define DTCODE_WSAAsyncSelect                     23
00037     #define DTCODE_WSACancelBlockingCall              24
00038     #define DTCODE_WSACleanup                         25
00039     #define DTCODE_WSACloseEvent                      26
00040     #define DTCODE_WSAConnect                         27
00041     #define DTCODE_WSACreateEvent                     28
00042     #define DTCODE_WSADuplicateSocketA                29
00043     #define DTCODE_WSAEnumNetworkEvents               30
00044     #define DTCODE_WSAEnumProtocolsA                  31
00045     #define DTCODE_WSAEventSelect                     32
00046     #define DTCODE_WSAGetLastError                    33
00047     #define DTCODE_WSAGetOverlappedResult             34
00048     #define DTCODE_WSAGetQOSByName                    35
00049     #define DTCODE_WSAHtonl                           36
00050     #define DTCODE_WSAHtons                           37
00051     #define DTCODE_WSAIoctl                           38
00052     #define DTCODE_WSAIsBlocking                      39
00053     #define DTCODE_WSAJoinLeaf                        40
00054     #define DTCODE_WSANtohl                           41
00055     #define DTCODE_WSANtohs                           42
00056     #define DTCODE_WSARecv                            43
00057     #define DTCODE_WSARecvDisconnect                  44
00058     #define DTCODE_WSARecvFrom                        45
00059     #define DTCODE_WSAResetEvent                      46
00060     #define DTCODE_WSASend                            47
00061     #define DTCODE_WSASendDisconnect                  48
00062     #define DTCODE_WSASendTo                          49
00063     #define DTCODE_WSASetBlockingHook                 50
00064     #define DTCODE_WSASetEvent                        51
00065     #define DTCODE_WSASetLastError                    52
00066     #define DTCODE_WSASocketA                         53
00067     #define DTCODE_WSAStartup                         54
00068     #define DTCODE_WSAUnhookBlockingHook              55
00069     #define DTCODE_WSAWaitForMultipleEvents           56
00070     #define DTCODE_gethostbyaddr                      57
00071     #define DTCODE_gethostbyname                      58
00072     #define DTCODE_gethostname                        59
00073     #define DTCODE_getprotobyname                     60
00074     #define DTCODE_getprotobynumber                   61
00075     #define DTCODE_getservbyname                      62
00076     #define DTCODE_getservbyport                      63
00077     #define DTCODE_inet_addr                          64
00078     #define DTCODE_inet_ntoa                          65
00079     #define DTCODE_WSAAsyncGetHostByAddr              66
00080     #define DTCODE_WSAAsyncGetHostByName              67
00081     #define DTCODE_WSAAsyncGetProtoByName             68
00082     #define DTCODE_WSAAsyncGetProtoByNumber           69
00083     #define DTCODE_WSAAsyncGetServByName              70
00084     #define DTCODE_WSAAsyncGetServByPort              71
00085     #define DTCODE_WSACancelAsyncRequest              72
00086     #define DTCODE_WSPAccept                          73
00087     #define DTCODE_WSPAsyncSelect                     74
00088     #define DTCODE_WSPBind                            75
00089     #define DTCODE_WSPCancelBlockingCall              76
00090     #define DTCODE_WSPCleanup                         77
00091     #define DTCODE_WSPCloseSocket                     78
00092     #define DTCODE_WSPConnect                         79
00093     #define DTCODE_WSPDuplicateSocket                 80
00094     #define DTCODE_WSPEnumNetworkEvents               81
00095     #define DTCODE_WSPEventSelect                     82
00096     #define DTCODE_WSPGetOverlappedResult             83
00097     #define DTCODE_WSPGetPeerName                     84
00098     // #define DTCODE_WSPGetProcTable                 85
00099     #define DTCODE_WSPGetSockName                     86
00100     #define DTCODE_WSPGetSockOpt                      87
00101     #define DTCODE_WSPGetQOSByName                    88
00102     #define DTCODE_WSPIoctl                           89
00103     #define DTCODE_WSPJoinLeaf                        90
00104     #define DTCODE_WSPListen                          91
00105     #define DTCODE_WSPRecv                            92
00106     #define DTCODE_WSPRecvDisconnect                  93
00107     #define DTCODE_WSPRecvFrom                        94
00108     #define DTCODE_WSPSelect                          95
00109     #define DTCODE_WSPSend                            96
00110     #define DTCODE_WSPSendDisconnect                  97
00111     #define DTCODE_WSPSendTo                          98
00112     #define DTCODE_WSPSetSockOpt                      99
00113     #define DTCODE_WSPShutdown                       100
00114     #define DTCODE_WSPSocket                         101
00115     #define DTCODE_WSPStartup                        102
00116     #define DTCODE_WPUCloseEvent                     103
00117     #define DTCODE_WPUCloseSocketHandle              104
00118     #define DTCODE_WPUCreateEvent                    105
00119     #define DTCODE_WPUCreateSocketHandle             106
00120     #define DTCODE_WSCDeinstallProvider              107
00121     #define DTCODE_WSCInstallProvider                108
00122     #define DTCODE_WPUModifyIFSHandle                109
00123     #define DTCODE_WPUQueryBlockingCallback          110
00124     #define DTCODE_WPUQuerySocketHandleContext       111
00125     #define DTCODE_WPUQueueApc                       112
00126     #define DTCODE_WPUResetEvent                     113
00127     #define DTCODE_WPUSetEvent                       114
00128     #define DTCODE_WSCEnumProtocols                  115
00129     #define DTCODE_WPUGetProviderPath                116
00130     #define DTCODE_WPUPostMessage                    117
00131     #define DTCODE_WPUFDIsSet                        118
00132     #define DTCODE_WSADuplicateSocketW               119
00133     #define DTCODE_WSAEnumProtocolsW                 120
00134     #define DTCODE_WSASocketW                        121
00135     #define DTCODE___WSAFDIsSet                      122
00136     #define DTCODE_WSAAddressToStringA               123
00137     #define DTCODE_WSAAddressToStringW               124
00138     #define DTCODE_WSAStringToAddressA               125
00139     #define DTCODE_WSAStringToAddressW               126
00140     #define DTCODE_WSALookupServiceBeginA            127
00141     #define DTCODE_WSALookupServiceBeginW            128
00142     #define DTCODE_WSALookupServiceNextA             129
00143     #define DTCODE_WSALookupServiceNextW             130
00144     #define DTCODE_WSALookupServiceEnd               131
00145     // #define DTCODE_WSAGetAddressByNameA           132
00146     // #define DTCODE_WSAGetAddressByNameW           133
00147     #define DTCODE_WSAInstallServiceClassA           134
00148     #define DTCODE_WSAInstallServiceClassW           135
00149     #define DTCODE_WSASetServiceA                    136
00150     #define DTCODE_WSASetServiceW                    137
00151     #define DTCODE_WSARemoveServiceClass             138
00152     #define DTCODE_WSAGetServiceClassInfoA           139
00153     #define DTCODE_WSAGetServiceClassInfoW           140
00154     #define DTCODE_WSAEnumNameSpaceProvidersA        141
00155     #define DTCODE_WSAEnumNameSpaceProvidersW        142
00156     #define DTCODE_WSAGetServiceClassNameByClassIdA  143
00157     #define DTCODE_WSAGetServiceClassNameByClassIdW  144
00158     #define DTCODE_NSPAddressToString                145
00159     #define DTCODE_NSPStringToAddress                146
00160     #define DTCODE_NSPLookupServiceBegin             147
00161     #define DTCODE_NSPLookupServiceNext              148
00162     #define DTCODE_NSPLookupServiceEnd               149
00163     #define DTCODE_NSPGetAddressByName               150
00164     #define DTCODE_NSPInstallServiceClass            151
00165     #define DTCODE_NSPSetService                     152
00166     #define DTCODE_NSPRemoveServiceClass             153
00167     #define DTCODE_NSPGetServiceClassInfo            154
00168     // #define DTCODE_NSPEnumNameSpaceProviders      155
00169     #define DTCODE_NSPGetServiceClassNameByClassId   156
00170     #define DTCODE_WSCGetProviderPath                157
00171     #define DTCODE_WSCInstallNameSpace               158
00172     #define DTCODE_WSCUnInstallNameSpace             159
00173     #define DTCODE_WSCEnableNSProvider               160
00174     #define DTCODE_WSPAddressToString                161
00175     #define DTCODE_WSPStringToAddress                162
00176     #define DTCODE_WSANSPIoctl                       163
00177     #define DTCODE_NSPIoctl                          164
00178     #define DTCODE_WPUCompleteOverlappedRequest      165
00179     #define DTCODE_WSAProviderConfigChange           166
00180     #define DTCODE_WSCWriteProviderOrder             167
00181     #define DTCODE_WSCWriteNameSpaceOrder            168
00182     #define DTCODE_WSCUpdateProvider                 169
00183     #define DTCODE_getaddrinfo                       170
00184     #define DTCODE_getnameinfo                       171
00185     #define DTCODE_freeaddrinfo                      172
00186     #define DTCODE_NSPStartup                        173
00187     #define DTCODE_WPUOpenCurrentThread              174
00188     #define DTCODE_WPUCloseThread                    175
00189
00190 #if !defined(_WIN64)
00191
00192     #define MAX_DTCODE DTCODE_WPUCloseThread
00193
00194 #else
00195
00196     #define DTCODE_WSCEnumProtocols32                176
00197     #define DTCODE_WSCInstallProvider64_32           177
00198     #define DTCODE_WSCDeinstallProvider32            178
00199     #define DTCODE_WSCGetProviderPath32              179
00200     #define DTCODE_WSCUpdateProvider32               180
00201     #define DTCODE_WSCWriteProviderOrder32           181
00202     #define DTCODE_WSCEnumNameSpaceProviders32       182
00203     #define DTCODE_WSCInstallNameSpace32             183
00204     #define DTCODE_WSCUnInstallNameSpace32           184
00205     #define DTCODE_WSCEnableNSProvider32             185
00206     #define DTCODE_WSCWriteNameSpaceOrder32          186
00207
00208     #define MAX_DTCODE DTCODE_WSCWriteNameSpaceOrder32
00209
00210 #endif // defined(_WIN64)
00211
00212 #endif // DT_DLL_HPP
Generated on Wed Nov 13 2024 16:52:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CCompInstallDlg Member List

This is the complete list of members for CCompInstallDlg, including all inherited members.
CCompInstallDlg(CWnd *pParent=NULL) | CCompInstallDlg |
DoDataExchange(CDataExchange *pDX) | CCompInstallDlg | [protected, virtual]
IDD enum value | CCompInstallDlg |
LoadAppCombo() | CCompInstallDlg | [private]
m_cboApplications | CCompInstallDlg |
m_edtComponent | CCompInstallDlg |
m_edtProxyStub | CCompInstallDlg |
m_edtTypeLib | CCompInstallDlg |
m_hIcon | CCompInstallDlg | [protected]
m_pCatalog | CCompInstallDlg | [private]
OnClose() | CCompInstallDlg | [protected]
OnComponentSearch() | CCompInstallDlg | [protected]
OnInitDialog() | CCompInstallDlg | [protected, virtual]
OnOK() | CCompInstallDlg | [protected, virtual]
OnProxyStubDll() | CCompInstallDlg | [protected]
OnTypeLibrary() | CCompInstallDlg | [protected]
ReleaseCatalog() | CCompInstallDlg | [private]
set_Catalog(ICOMAdminCatalog *pCatalog) | CCompInstallDlg |
Generated on Wed Nov 13 2024 16:55:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CBrush Member List

This is the complete list of members for CBrush, including all inherited members.
_canvas | CBrush | [protected]
_hBrush | CBrush | [protected]
_hBrushOld | CBrush | [protected]
CBrush(CCanvas &canvas, int iStyle=BS_NULL, COLORREF color=RGB(0, 0, 0)) | CBrush | [inline]
~CBrush() | CBrush | [inline]
Generated on Wed Nov 13 2024 16:55:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSamplePipe Member List

This is the complete list of members for CSamplePipe, including all inherited members.
CSamplePipe() | CSamplePipe |
m_cRef | CSamplePipe | [protected]
m_dwInPipeSent | CSamplePipe | [protected]
m_dwOutPipeRcvd | CSamplePipe | [protected]
m_nPullSeq | CSamplePipe | [protected]
m_nPushSeq | CSamplePipe | [protected]
m_pBuffer | CSamplePipe | [protected]
Pull(long *buf, ULONG cRequest, ULONG *pcReturned) | CSamplePipe |
Push(long *buf, ULONG cSent) | CSamplePipe |
QueryInterface(REFIID iid, void **ppv) | CSamplePipe |
STDMETHODIMP_(ULONG) AddRef(void) | CSamplePipe |
STDMETHODIMP_(ULONG) Release(void) | CSamplePipe |
~CSamplePipe() | CSamplePipe |
Generated on Wed Nov 13 2024 16:57:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

msado15::DataTypeEnum Member List

This is the complete list of members for msado15::DataTypeEnum, including all inherited members.
adBigInt | msado15::DataTypeEnum | [static]
adBinary | msado15::DataTypeEnum | [static]
adBoolean | msado15::DataTypeEnum | [static]
adBSTR | msado15::DataTypeEnum | [static]
adChapter | msado15::DataTypeEnum | [static]
adChar | msado15::DataTypeEnum | [static]
adCurrency | msado15::DataTypeEnum | [static]
adDate | msado15::DataTypeEnum | [static]
adDBDate | msado15::DataTypeEnum | [static]
adDBFileTime | msado15::DataTypeEnum | [static]
adDBTime | msado15::DataTypeEnum | [static]
adDBTimeStamp | msado15::DataTypeEnum | [static]
adDecimal | msado15::DataTypeEnum | [static]
adDouble | msado15::DataTypeEnum | [static]
adEmpty | msado15::DataTypeEnum | [static]
adError | msado15::DataTypeEnum | [static]
adFileTime | msado15::DataTypeEnum | [static]
adGUID | msado15::DataTypeEnum | [static]
adIDispatch | msado15::DataTypeEnum | [static]
adInteger | msado15::DataTypeEnum | [static]
adIUnknown | msado15::DataTypeEnum | [static]
adLongVarBinary | msado15::DataTypeEnum | [static]
adLongVarChar | msado15::DataTypeEnum | [static]
adLongVarWChar | msado15::DataTypeEnum | [static]
adNumeric | msado15::DataTypeEnum | [static]
adPropVariant | msado15::DataTypeEnum | [static]
adSingle | msado15::DataTypeEnum | [static]
adSmallInt | msado15::DataTypeEnum | [static]
adTinyInt | msado15::DataTypeEnum | [static]
adUnsignedBigInt | msado15::DataTypeEnum | [static]
adUnsignedInt | msado15::DataTypeEnum | [static]
adUnsignedSmallInt | msado15::DataTypeEnum | [static]
adUnsignedTinyInt | msado15::DataTypeEnum | [static]
adUserDefined | msado15::DataTypeEnum | [static]
adVarBinary | msado15::DataTypeEnum | [static]
adVarChar | msado15::DataTypeEnum | [static]
adVariant | msado15::DataTypeEnum | [static]
adVarNumeric | msado15::DataTypeEnum | [static]
adVarWChar | msado15::DataTypeEnum | [static]
adWChar | msado15::DataTypeEnum | [static]
Generated on Wed Nov 13 2024 16:58:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Menubtn/sky.Cpp Source File

  • SysMgmt
  • MMC
  • Menubtn

sky.Cpp

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #include "Sky.h"
00021
00022 const GUID CSkyBasedVehicle::thisGuid = { 0x2974380f, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
00023
00024 //==============================================================
00025 //
00026 // CSkyBasedVehicle implementation
00027 //
00028 //
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/IAS/MapName/radutil.c Source File

  • NetDS
  • IAS
  • MapName

radutil.c

Go to the documentation of this file.
00001 /* Copyright (c) Microsoft Corporation. All rights reserved. */
00002
00003 #include "windows.h"
00004 #include "radutil.h"
00005 #include "multisz.h"
00006
00007 LPVOID
00008 WINAPI
00009 RadiusAlloc(
00010    SIZE_T dwBytes
00011    )
00012 {
00013    return HeapAlloc(GetProcessHeap(), 0, dwBytes);
00014 }
00015
00016
00017 VOID
00018 WINAPI
00019 RadiusFree(
00020    LPVOID lpMem
00021    )
00022 {
00023    HeapFree(GetProcessHeap(), 0, lpMem);
00024 }
00025
00026
00027 DWORD
00028 WINAPI
00029 RadiusFindFirstIndex(
00030    PRADIUS_ATTRIBUTE_ARRAY pAttrs,
00031    DWORD dwAttrType
00032    )
00033 {
00034    DWORD dwIndex, dwSize;
00035    const RADIUS_ATTRIBUTE *pAttr;
00036
00037    if (pAttrs == NULL)
00038    {
00039       return RADIUS_ATTR_NOT_FOUND;
00040    }
00041
00042    /* Get the number of attributes in the array */
00043    dwSize = pAttrs->GetSize(pAttrs);
00044
00045    /* Iterate through the array ... */
00046    for (dwIndex = 0; dwIndex < dwSize; ++dwIndex)
00047    {
00048       /* ... looking for the first attribute that matches the type. */
00049       pAttr = pAttrs->AttributeAt(pAttrs, dwIndex);
00050       if (pAttr->dwAttrType == dwAttrType)
00051       {
00052          return dwIndex;
00053       }
00054    }
00055
00056    return RADIUS_ATTR_NOT_FOUND;
00057 }
00058
00059
00060 const RADIUS_ATTRIBUTE*
00061 WINAPI
00062 RadiusFindFirstAttribute(
00063    PRADIUS_ATTRIBUTE_ARRAY pAttrs,
00064    DWORD dwAttrType
00065    )
00066 {
00067    DWORD dwIndex;
00068
00069    dwIndex = RadiusFindFirstIndex(pAttrs, dwAttrType);
00070
00071    if (dwIndex != RADIUS_ATTR_NOT_FOUND)
00072    {
00073       return pAttrs->AttributeAt(pAttrs, dwIndex);
00074    }
00075    else
00076    {
00077       return NULL;
00078    }
00079 }
00080
00081
00082 DWORD
00083 WINAPI
00084 RadiusReplaceFirstAttribute(
00085    PRADIUS_ATTRIBUTE_ARRAY pAttrs,
00086    const RADIUS_ATTRIBUTE* pSrc
00087    )
00088 {
00089    DWORD dwIndex;
00090
00091    if ((pAttrs == NULL) || (pSrc == NULL))
00092    {
00093       return ERROR_INVALID_PARAMETER;
00094    }
00095
00096    dwIndex = RadiusFindFirstIndex(pAttrs, pSrc->dwAttrType);
00097
00098    if (dwIndex != RADIUS_ATTR_NOT_FOUND)
00099    {
00100       /* It already exists, so overwrite the existing attribute. */
00101       return pAttrs->SetAt(pAttrs, dwIndex, pSrc);
00102    }
00103    else
00104    {
00105       /* It doesn't exist, so add it to the end of the array. */
00106       return pAttrs->Add(pAttrs, pSrc);
00107    }
00108
00109 }
00110
00111
00112 HRESULT
00113 WINAPI
00114 RadiusExtensionInstall(
00115     HMODULE hModule,
00116     LPCWSTR pwszType,
00117     BOOL fInstall
00118     )
00119 {
00120    LONG lResult;
00121    HKEY hKey;
00122    DWORD nChar, dwError;
00123    WCHAR wszFileName[MAX_PATH];
00124    MULTI_SZ value;
00125    LPWSTR pwszSelf;
00126
00127    if ((hModule == NULL) || (pwszType == NULL))
00128    {
00129       return ERROR_INVALID_PARAMETER;
00130    }
00131
00132    /* Retrieve the full path to the extension DLL. */
00133    nChar = GetModuleFileNameW(
00134               hModule,
00135               wszFileName,
00136               MAX_PATH
00137               );
00138    if (nChar == 0)
00139    {
00140       dwError = GetLastError();
00141       return HRESULT_FROM_WIN32(dwError);
00142    }
00143
00144    /* Open or create the parameters key. */
00145    lResult = RegCreateKeyExW(
00146                 HKEY_LOCAL_MACHINE,
00147                 AUTHSRV_PARAMETERS_KEY_W,
00148                 0,
00149                 NULL,
00150                 REG_OPTION_NON_VOLATILE,
00151                 (KEY_QUERY_VALUE | KEY_SET_VALUE),
00152                 NULL,
00153                 &hKey,
00154                 NULL
00155                 );
00156    if (lResult != NO_ERROR)
00157    {
00158       return HRESULT_FROM_WIN32(lResult);
00159    }
00160
00161    /* Read the current registered extensions DLLs. */
00162    lResult = MultiSzQuery(
00163                 &value,
00164                 hKey,
00165                 pwszType
00166                 );
00167    switch (lResult)
00168    {
00169       case NO_ERROR:
00170       case ERROR_FILE_NOT_FOUND:
00171       case ERROR_INVALID_DATA:
00172          break;
00173
00174       default:
00175          RegCloseKey(hKey);
00176          return HRESULT_FROM_WIN32(lResult);
00177    }
00178
00179    /* Is this DLL currently registered? */
00180    pwszSelf = MultiSzFind(&value, wszFileName);
00181
00182    if (fInstall)
00183    {
00184       if (pwszSelf == NULL)
00185       {
00186          /* We're installing and we're not currently registered, so we have to
00187           * add ourself to the list of DLLs. */
00188          lResult = MultiSzAppend(&value, wszFileName);
00189          if (lResult == NO_ERROR)
00190          {
00191             lResult = MultiSzSet(&value, hKey, pwszType);
00192          }
00193       }
00194       else
00195       {
00196          /* The DLL is already registered -- nothing to do.  */
00197          lResult = NO_ERROR;
00198       }
00199    }
00200    else
00201    {
00202       if (pwszSelf != NULL)
00203       {
00204          /* We're uninstalling and we're currently registered, so we have to
00205           * remove ourself from the list of DLLs. */
00206          MultiSzErase(&value, pwszSelf);
00207          if (value.nChar > 1)
00208          {
00209             lResult = MultiSzSet(&value, hKey, pwszType);
00210          }
00211          else
00212          {
00213             lResult = RegDeleteValueW(hKey, pwszType);
00214          }
00215       }
00216       else
00217       {
00218          /* The DLL isn't registered -- nothing to do. */
00219          lResult = NO_ERROR;
00220       }
00221    }
00222
00223    /* Clean up the MULTI_SZ. */
00224    MultiSzFree(&value);
00225
00226    return HRESULT_FROM_WIN32(lResult);
00227 }
Generated on Wed Nov 13 2024 16:52:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/SSPI/HttpAuth/Proto.H Source File

  • Security
  • SSPI
  • HttpAuth

Proto.H

Go to the documentation of this file.
00001 /*++
00002 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 PARTICULAR PURPOSE.
00006
00007 Copyright (C) 1995 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009 Module Name:
00010     proto.h
00011
00012 Abstract:
00013     prototypes
00014
00015 Environment:
00016     Internet
00017
00018 --*/
00019
00020 BOOL
00021 HttpGetSocket(
00022     char * Verb,
00023     char * Server,
00024     char * URL,
00025     BOOL   DisplayHeaders,
00026     DWORD  ClientDataSize,
00027     PSTR   pszUserName,
00028     PSTR   pszPassword,
00029     PSTR   pszStore,
00030     PSTR   pszPref );
Generated on Wed Nov 13 2024 16:52:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CImpIColumnsInfo Member List

This is the complete list of members for CImpIColumnsInfo, including all inherited members.
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIColumnsInfo) | CImpIColumnsInfo
GetColumnInfo(DBORDINAL *, DBCOLUMNINFO **, WCHAR **) | CImpIColumnsInfo
MapColumnIDs(DBORDINAL, const DBID rgColumnIDs[], DBORDINAL rgColumns[]) | CImpIColumnsInfo
Generated on Wed Nov 13 2024 16:56:41 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/Include/assert.h Source File

  • Com
  • Fundamentals
  • Include

assert.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright 1992 - 2000 Microsoft Corporation.
00005 //
00006 //  File:       assert.h
00007 //
00008 //  Contents:   private definition of assert, used by NT SDK OLE2 samples
00009 //
00010 //  History:    8-19-94   stevebl   Created
00011 //
00012 //----------------------------------------------------------------------------
00013
00014 /*
00015  * Conditional macro definition for function calling type and variable type
00016  * qualifiers.
00017  */
00018 #if   ( (_MSC_VER >= 800) && (_M_IX86 >= 300) )
00019
00020 /*
00021  * Definitions for MS C8-32 (386/486) compiler
00022  */
00023 #ifndef _CRTAPI1
00024 #define _CRTAPI1 __cdecl
00025 #endif
00026 #ifndef _CRTAPI2
00027 #define _CRTAPI2 __cdecl
00028 #endif
00029
00030 #else
00031
00032 /*
00033  * Other compilers (e.g., MIPS)
00034  */
00035 #ifndef _CRTAPI1
00036 #define _CRTAPI1
00037 #endif
00038 #ifndef _CRTAPI2
00039 #define _CRTAPI2
00040 #endif
00041
00042 #endif
00043
00044 #undef  assert
00045
00046 #ifdef NDEBUG
00047
00048 #define assert(exp)     ((void)0)
00049
00050 #else
00051
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 void _CRTAPI1
00056 PopUpAssert(
00057     void * szFile,
00058     int iLine,
00059     void * szMessage);
00060 #ifdef __cplusplus
00061 }
00062 #endif
00063
00064
00065 #define assert(exp) (void)( (exp) || (PopUpAssert(__FILE__, __LINE__, #exp), 0) )
00066 #define _assert(exp, file, line) PopUpAssert(file, line, exp)
00067
00068
00069 #endif  /* NDEBUG */
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp2/QCShip2/Ship2.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp2
  • QCShip2

Ship2.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Ship2.h
00003   Summary:   Declaration of COShip2 class
00004   Classes:   Declared: COShip2
00005   Origin:    Implementation of case study in Queued Components specification
00006 ----------------------------------------------------------------------------
00007   Copyright 1992 - 2000 Microsoft Corporation, All rights reserved.
00008
00009     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00010     ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00011     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00012     PARTICULAR PURPOSE
00013 ==========================================================================+*/
00014
00015 #ifndef __SHIP2_H_
00016 #define __SHIP2_H_
00017
00018 #include "resource.h"       // main symbols
00019 #include "..\QCNotify\QCNotify.h"
00020
00021 /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
00022   ObjectClass: COShip2
00023   Summary:     Writes order to shipping database.
00024          Assigns shipping status to each line item.
00025          Creates Notify object to inform requestor of shipping status.
00026   Interfaces:  IUnknown       Standard COM object feature interface
00027                IDispatch      Automation interface
00028              IShip2       Represents an order
00029   Aggregation: Not supported
00030 O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
00031
00032 class ATL_NO_VTABLE COShip2 :
00033   public CComObjectRootEx<CComSingleThreadModel>,
00034   public CComCoClass<COShip2, &CLSID_Ship2>,
00035   public IDispatchImpl<IShip2, &IID_IShip2, &LIBID_QCSHIP2Lib>
00036 {
00037 public:
00038   COShip2() : m_lCustomerId(0), m_lOrderId(0)
00039   {
00040   }
00041
00042 DECLARE_REGISTRY_RESOURCEID(IDR_SHIP2)
00043 DECLARE_NOT_AGGREGATABLE(COShip2)
00044
00045 BEGIN_COM_MAP(COShip2)
00046   COM_INTERFACE_ENTRY(IShip2)
00047   COM_INTERFACE_ENTRY(IDispatch)
00048 END_COM_MAP()
00049
00050 public: // IOrder
00051   STDMETHOD(Process)(long lFlags, IUnknown *punk);
00052   STDMETHOD(LineItem)(long lItemId, long lQuantity);
00053   STDMETHOD(put_OrderId)(long lOrderId);
00054   STDMETHOD(put_CustomerId)(long lCustomerId);
00055
00056 private:
00057   long          m_lCustomerId;
00058   long          m_lOrderId;
00059   std::vector<long>   m_veclItemId;
00060   std::vector<long>   m_veclQuantity;
00061   std::vector<ShipStatus> m_vecShipStatus;
00062
00063   HRESULT   WriteShipDB();
00064   HRESULT   NotifyRequestor(long lFlags, IUnknown *punkNotify);
00065   HRESULT   InvokeNotifyIDispatch(IUnknown * punk, long lFlags);
00066   HRESULT   InvokeNotifyVtable(IUnknown * punk, long lFlags);
00067   ShipStatus  RandomShipStatus();
00068 };
00069
00070 #endif //__SHIP2_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/VJQuery/VJQuery.java Source File

  • WinBase
  • Indexing
  • VJQuery

VJQuery.java

Go to the documentation of this file.
00001 // VJQuery.java
00002
00003 //+-------------------------------------------------------------------------
00004 //
00005 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00006 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00007 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00008 // PARTICULAR PURPOSE.
00009 //
00010 // Copyright 1998-1999, Microsoft Corporation.  All Rights Reserved.
00011 //
00012 // PROGRAM: VJQuery
00013 //
00014 // PURPOSE: Illustrates using Visual J++ and ADO to execute
00015 //      SQL queries with Indexing Service.
00016 //
00017 // PLATFORM: Windows 2000
00018 //
00019 //--------------------------------------------------------------------------
00020
00021 // NOTE: The com.ms.wfc imports will become just wfc imports for distribution.
00022
00023 import com.ms.wfc.*;
00024 import com.ms.wfc.core.*;
00025 import com.ms.wfc.data.*;
00026 import com.ms.com.*;
00027
00028 /**
00029  * This class can take a variable number of parameters on the command
00030  * line. Program execution begins with the main() method. The class
00031  * constructor is not invoked unless an object of type 'VJQuery'
00032  * created in the main() method.
00033  */
00034 public class VJQuery
00035 {
00036     /**
00037      * The main entry point for the application.
00038      *
00039      * @param args Array of parameters passed to the application
00040      * via the command line.
00041      */
00042     public static void main (String[] args)
00043     {
00044
00045         // Parse arguments.
00046         if ( ( 0 == args.length ) ||
00047              ( 1 == args.length && args[0].equalsIgnoreCase("-?") ) )
00048         {
00049             Usage();
00050         }
00051         else
00052         {
00053             Query Q = new Query();
00054
00055             if ( args[0].equalsIgnoreCase("-s") )
00056             {
00057                 String S = args[1];
00058
00059                 for ( int i = 2; i < args.length; i++ )
00060                     S = S + " " + args[i];
00061
00062                 S = StripEndQuotes(S);
00063
00064                 Q.SetRawSql( S );
00065             }
00066             else
00067             {
00068                 String S = args[0];
00069
00070                 for ( int i = 1; i < args.length; i++ )
00071                         S = S + " " + args[i];
00072
00073                 S = StripEndQuotes(S);
00074
00075                 Q.SetSqlWhere( S );
00076             }
00077
00078             try
00079             {
00080
00081                 // Run Query.
00082                 Q.Execute();
00083
00084                 // Display the result.
00085                 Q.Display( System.out );
00086             }
00087             catch( com.ms.wfc.data.AdoException e )
00088             {
00089                 System.out.println( "Caught " + e.getErrorNumber() );
00090             }
00091         }
00092
00093         try
00094         {
00095             System.out.println( "Press enter to continue..." );
00096             System.in.read();
00097         }
00098         catch( java.io.IOException e )
00099         {
00100         }
00101     }
00102
00103     //+-------------------------------------------------------------------------
00104     //
00105     //  Method:     VJQuery::StripEndQuotes
00106     //
00107     //  Synopsis:   Removes beginning and ending quotes.
00108     //
00109     //  Arguments:  [S] -- String to strip.
00110     //
00111     //  Returns:    [S], sans initial and final quotes, if any.
00112     //
00113     //--------------------------------------------------------------------------
00114
00115     static String StripEndQuotes( String S )
00116     {
00117         if ( S.indexOf("\"") == 0 )
00118             S = S.substring(1, S.length() - 1);
00119
00120         if ( S.lastIndexOf("\"") == S.length() - 1 )
00121             S = S.substring(0, S.length() - 1);
00122
00123         return S;
00124     }
00125
00126     //+-------------------------------------------------------------------------
00127     //
00128     //  Method:     VJQuery::Usage
00129     //
00130     //  Synopsis:   Usage message.
00131     //
00132     //--------------------------------------------------------------------------
00133
00134     static void Usage()
00135     {
00136     System.out.println( "Usage: VJQuery [-s] [<Query>]" );
00137         System.out.println( "       <Query>  WHERE clause or complete SELECT statement" );
00138         System.out.println( "       -s       <Query> is complete SELECT statement" );
00139     }
00140 }
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/fax/PrintSdi/MainFrm.h Source File

  • NetDS
  • fax
  • PrintSdi

MainFrm.h

Go to the documentation of this file.
00001 // MainFrm.h : interface of the CMainFrame class
00002 //
00003 /////////////////////////////////////////////////////////////////////////////
00004
00005 #if !defined(AFX_MAINFRM_H__55689547_8B6C_11D1_B7AE_000000000000__INCLUDED_)
00006 #define AFX_MAINFRM_H__55689547_8B6C_11D1_B7AE_000000000000__INCLUDED_
00007
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #endif // _MSC_VER >= 1000
00011
00012 class CMainFrame : public CFrameWnd
00013 {
00014 protected: // create from serialization only
00015   CMainFrame();
00016   DECLARE_DYNCREATE(CMainFrame)
00017
00018 // Attributes
00019 public:
00020
00021 // Operations
00022 public:
00023
00024 // Overrides
00025   // ClassWizard generated virtual function overrides
00026   //{{AFX_VIRTUAL(CMainFrame)
00027   virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
00028   //}}AFX_VIRTUAL
00029
00030 // Implementation
00031 public:
00032   virtual ~CMainFrame();
00033 #ifdef _DEBUG
00034   virtual void AssertValid() const;
00035   virtual void Dump(CDumpContext& dc) const;
00036 #endif
00037
00038 // Generated message map functions
00039 protected:
00040   //{{AFX_MSG(CMainFrame)
00041     // NOTE - the ClassWizard will add and remove member functions here.
00042     //    DO NOT EDIT what you see in these blocks of generated code!
00043   //}}AFX_MSG
00044   DECLARE_MESSAGE_MAP()
00045 };
00046
00047 /////////////////////////////////////////////////////////////////////////////
00048
00049 //{{AFX_INSERT_LOCATION}}
00050 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00051
00052 #endif // !defined(AFX_MAINFRM_H__55689547_8B6C_11D1_B7AE_000000000000__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/PrintJob/errors.h Source File

  • Multimedia
  • Gdi
  • PrintJob

errors.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 * PARTICULAR PURPOSE.
00006 *
00007 *  Copyright (C) 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00008 *
00009 *   FILE:   Errors.H
00010 *
00011 *   PURPOSE:    Implements an Error display box that conveniently shows
00012 *       the user what Win32 Error was reported.
00013 *
00014 *   FUNCTIONS:
00015 *       ErrorBox() - Displays a MessageBox() with a formatted version of
00016 *                    the Win32 Error code passed in. Handy, but not
00017 *                    terribly user friendly.
00018 *
00019 ******************************************************************************/
00020
00021 void ErrorBox( DWORD dwError, LPCSTR lpszString );
00022
00023 /* end of header file Errors.h */
00024
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

_NETWORK_ENTRY Member List

This is the complete list of members for _NETWORK_ENTRY, including all inherited members.
leIndexSortedList | _NETWORK_ENTRY
phtInterfaceTable | _NETWORK_ENTRY
rwlLock | _NETWORK_ENTRY
Generated on Wed Nov 13 2024 16:55:25 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CEnumTASK Member List

This is the complete list of members for CEnumTASK, including all inherited members.
CEnumTASK(MMC_TASK *pTaskList, ULONG nTasks) | CEnumTASK |
Clone(IEnumTASK __RPC_FAR *__RPC_FAR *ppenum) | CEnumTASK | [virtual]
m_cref | CEnumTASK | [private]
m_CurrTask | CEnumTASK | [private]
m_pTaskList | CEnumTASK | [private]
m_TaskCount | CEnumTASK | [private]
Next(ULONG celt, MMC_TASK __RPC_FAR *rgelt, ULONG __RPC_FAR *pceltFetched) | CEnumTASK | [virtual]
QueryInterface(REFIID riid, LPVOID *ppv) | CEnumTASK |
Reset(void) | CEnumTASK | [virtual]
Skip(ULONG celt) | CEnumTASK | [virtual]
STDMETHODIMP_(ULONG) AddRef() | CEnumTASK |
STDMETHODIMP_(ULONG) Release() | CEnumTASK |
~CEnumTASK() | CEnumTASK | [virtual]
Generated on Wed Nov 13 2024 16:56:29 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

IWMIObject Member List

This is the complete list of members for IWMIObject, including all inherited members.
SetWbemObject(IWbemClassObject *pObjectIn, BOOL *pfRetainObjectOut) IWMIObject
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Dynept/Dynepts.c Source File

  • NetDS
  • RPC
  • Dynept

Dynepts.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                        dynept Example
00005
00006     FILE:       dynepts.c
00007
00008     USAGE:      dynepts  -p protocol_sequence
00009                          -m max calls
00010                          -n min calls
00011                          -f flag for RpcServerListen
00012
00013     PURPOSE:    Server side of RPC distributed application dynept
00014
00015     FUNCTIONS:  main() - registers server as RPC server
00016
00017     COMMENTS:   This version of the distributed application that prints
00018                 "What a dynamic world" (or other string) on the server
00019                 features a client that manages its connection to the server.
00020                 It uses the binding handle dynept_IfHandle, defined in
00021                 the file dynept.h.
00022
00023 ****************************************************************************/
00024
00025 #include <stdlib.h>
00026 #include <stdio.h>
00027 #include <ctype.h>
00028 #include "dynept.h"    // header file generated by MIDL compiler
00029
00030 #define PURPOSE \
00031 "This Microsoft RPC Version 2.0 sample program demonstrates\n\
00032 the use of dynamic endpoints. For more information\n\
00033 about the attributes and the RPC API functions, see the\n\
00034 RPC programming guide and reference.\n\n"
00035
00036 void Usage(char * pszProgramName)
00037 {
00038     fprintf(stderr, "%s", PURPOSE);
00039     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00040     fprintf(stderr, " -p protocol_sequence\n");
00041     fprintf(stderr, " -m maxcalls\n");
00042     fprintf(stderr, " -n mincalls\n");
00043     fprintf(stderr, " -f flag_wait_op\n");
00044     exit(1);
00045 }
00046
00047 /* main:  register the interface, start listening for clients */
00048 void __cdecl main(int argc, char * argv[])
00049 {
00050     RPC_STATUS status;
00051     RPC_BINDING_VECTOR * pBindingVector = NULL;
00052     unsigned char * pszProtocolSequence = "ncacn_np";
00053     unsigned char * pszSecurity         = NULL;
00054     unsigned int    cMinCalls           = 1;
00055     unsigned int    cMaxCalls           = 20;
00056     unsigned int    fDontWait           = FALSE;
00057     unsigned int    fRegistered         = 0;
00058     unsigned int    fEndpoint           = 0;
00059     int i;
00060
00061     /* allow the user to override settings with command line switches */
00062     for (i = 1; i < argc; i++) {
00063         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00064             switch (tolower(*(argv[i]+1))) {
00065             case 'p':  // protocol sequence
00066                 pszProtocolSequence = argv[++i];
00067                 break;
00068             case 'm':
00069                 cMaxCalls = (unsigned int) atoi(argv[++i]);
00070                 break;
00071             case 'n':
00072                 cMinCalls = (unsigned int) atoi(argv[++i]);
00073                 break;
00074             case 'f':
00075                 fDontWait = (unsigned int) atoi(argv[++i]);
00076                 break;
00077             case 'h':
00078             case '?':
00079             default:
00080                 Usage(argv[0]);
00081             }
00082         }
00083         else
00084             Usage(argv[0]);
00085     }
00086
00087     status = RpcServerUseProtseq(pszProtocolSequence,
00088                                  cMaxCalls,
00089                                  pszSecurity);  // Security descriptor
00090     printf("RpcServerUseProtseq returned 0x%x\n", status);
00091     if (status) {
00092         goto cleanup;
00093     }
00094
00095     status = RpcServerRegisterIf(dynept_ServerIfHandle,  // interface to register
00096                                  NULL,   // MgrTypeUuid
00097                                  NULL);  // MgrEpv; null means use default
00098     printf("RpcServerRegisterIf returned 0x%x\n", status);
00099     if (status) {
00100         goto cleanup;
00101     }
00102     else
00103         fRegistered = 1;
00104
00105     status = RpcServerInqBindings(&pBindingVector);
00106     printf("RpcServerInqBindings returned 0x%x\n", status);
00107     if (status) {
00108         goto cleanup;
00109     }
00110
00111     status = RpcEpRegister( dynept_ServerIfHandle,
00112                             pBindingVector,
00113                             NULL,
00114                             "" );
00115     printf("RpcEpRegister returned: 0x%x\n", status);
00116     if (status) {
00117         goto cleanup;
00118     }
00119     else
00120         fEndpoint = 1;
00121
00122     printf("Calling RpcServerListen\n");
00123     status = RpcServerListen(cMinCalls,
00124                              cMaxCalls,
00125                              fDontWait);
00126     printf("RpcServerListen returned: 0x%x\n", status);
00127     if (status) {
00128         goto cleanup;
00129     }
00130
00131     if (fDontWait) {
00132         printf("Calling RpcMgmtWaitServerListen\n");
00133         status = RpcMgmtWaitServerListen();  // wait operation
00134         printf("RpcMgmtWaitServerListen returned: 0x%x\n", status);
00135     }
00136
00137   cleanup:
00138
00139     if ( fEndpoint )
00140     {
00141         status = RpcEpUnregister(dynept_ServerIfHandle,
00142                                  pBindingVector,
00143                                  NULL);
00144         printf( "RpcEpUnregister returned 0x%x\n", status);
00145     }
00146
00147     if ( pBindingVector )
00148     {
00149         status = RpcBindingVectorFree(&pBindingVector);
00150         printf( "RpcBindingVectorFree returned 0x%x\n", status);
00151     }
00152
00153     if ( fRegistered )
00154     {
00155         printf("Calling RpcServerUnregisterIf\n");
00156         status = RpcServerUnregisterIf(NULL, NULL, FALSE);
00157         printf("RpcServerUnregisterIf returned 0x%x\n", status);
00158     }
00159
00160     exit (status);
00161
00162 }  // end main()
00163
00164
00165 /*********************************************************************/
00166 /*                MIDL allocate and free                             */
00167 /*********************************************************************/
00168
00169 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
00170 {
00171     return(malloc(len));
00172 }
00173
00174 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
00175 {
00176     free(ptr);
00177 }
00178
00179 /* end file dynepts.c */
Generated on Wed Nov 13 2024 16:52:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/internetpublishing/ippsample/StdAfx.Cpp Source File

  • Dataaccess
  • oledb
  • internetpublishing
  • ippsample

StdAfx.Cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004   TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005   PARTICULAR PURPOSE.
00006
00007   Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009   stdafx.cpp
00010
00011   source file for building the pre-compiled header.
00012 ------------------------------------------------------------------------------*/
00013
00014 // stdafx.cpp : source file that includes just the standard includes
00015 //  sample1.pch will be the pre-compiled header
00016 //  stdafx.obj will contain the pre-compiled type information
00017
00018 #include "stdafx.h"
00019
00020 // TODO: reference any additional headers you need in STDAFX.H
00021 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/basesnap.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

basesnap.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //  Abstract:  This file contains implementations for IClassFactory
00014 //             and the Snap-in's DLL exported functions
00015
00016
00017 #include <ObjBase.h>
00018 #include <InitGuid.h>
00019 #include "Globals.h"
00020 #include "BaseSnap.h"
00021 #include "CompData.h"
00022 #include "About.h"
00023 #include "Registry.h"
00024
00025
00026 #include "TraceMacro.h"
00027 #undef  MODULESTRING
00028 #define MODULESTRING  _T("BaseSnap")
00029
00030
00031 /////////////////////////////////////////////////////////////////////////////
00032 //  Implementation of IClassFactory for CComponentData
00033
00034 //---------------------------------------------------------------------------
00035 CClassFactory::CClassFactory( FACTORY_TYPE eFactoryType )
00036 {
00037   m_cRef = 0;
00038   m_FactoryType = eFactoryType;
00039
00040   InterlockedIncrement((long*)&g_uObjectCount);
00041 }
00042
00043
00044 //---------------------------------------------------------------------------
00045 CClassFactory::~CClassFactory()
00046 {
00047   InterlockedDecrement((long*)&g_uObjectCount);
00048 }
00049
00050
00051 //---------------------------------------------------------------------------
00052 STDMETHODIMP CClassFactory::QueryInterface
00053 (
00054   REFIID   riid,             //[in] Identifier of the requested interface
00055   LPVOID*  ppv               //[out] Address of requested interface
00056 )
00057 {
00058   if( NULL == ppv )
00059     return E_FAIL;
00060
00061   HRESULT hResult = E_NOINTERFACE;
00062   *ppv = NULL;
00063
00064   if( IsEqualIID(riid, IID_IUnknown) )
00065   {
00066     *ppv = static_cast<IClassFactory*>(this);
00067   }
00068   else if( IsEqualIID(riid, IID_IClassFactory) )
00069   {
00070     *ppv = static_cast<IClassFactory*>(this);
00071   }
00072
00073   if( *ppv )
00074   {
00075     reinterpret_cast<IUnknown*>(*ppv)->AddRef();
00076     hResult = S_OK;
00077   }
00078
00079   return hResult;
00080 }
00081
00082
00083 //---------------------------------------------------------------------------
00084 STDMETHODIMP_(ULONG) CClassFactory::AddRef()
00085 {
00086   return InterlockedIncrement( (long*)&m_cRef );
00087 }
00088
00089
00090 //---------------------------------------------------------------------------
00091 STDMETHODIMP_(ULONG) CClassFactory::Release()
00092 {
00093   if( 0 == InterlockedDecrement( (long*)&m_cRef) )
00094   {
00095     delete this;
00096     return 0;
00097   }
00098   return m_cRef;
00099 }
00100
00101 //---------------------------------------------------------------------------
00102 //  Creates an instance of the object type which was passed in the
00103 //  class constructor
00104 //
00105 STDMETHODIMP CClassFactory::CreateInstance
00106 (
00107   LPUNKNOWN  pUnkOuter,      //[in] NULL unless object is part of aggregate
00108   REFIID     riid,           //[in] Reference to interface indentifier
00109   LPVOID*    ppvObj          //[out] Address of requested interface pointer
00110 )
00111 {
00112   HRESULT  hResult = E_FAIL;
00113   void*    pObject = NULL;
00114
00115   if( NULL == ppvObj )
00116     return hResult;
00117
00118   *ppvObj = NULL;
00119
00120   // Our object does does not support aggregation, so we need to
00121   // fail if they ask us to do aggregation.
00122   if( pUnkOuter )
00123     return CLASS_E_NOAGGREGATION;
00124
00125   // Support for providing CSnapinAbout/CComponentData objects
00126   switch( m_FactoryType )
00127   {
00128     case COMPONENTDATA:
00129       pObject = new CComponentData();
00130       break;
00131
00132     case ABOUT:
00133       pObject = new CSnapinAbout();
00134       break;
00135
00136     default:
00137       pObject = NULL;
00138   }
00139
00140   if( NULL == pObject )                // Failed to create an object
00141     return E_INVALIDARG;               // due to bad argument
00142
00143   // QueryInterface will do the AddRef() for us, don't do it here
00144   hResult = ( (LPUNKNOWN)pObject)->QueryInterface( riid, ppvObj );
00145
00146   if( S_OK != hResult )
00147     delete pObject;
00148
00149   return hResult;
00150 }
00151
00152
00153 //---------------------------------------------------------------------------
00154 STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
00155 {
00156   if( TRUE == fLock )
00157     InterlockedIncrement((long*)&g_uServerLocks);
00158   else
00159     InterlockedDecrement((long*)&g_uServerLocks);
00160
00161   return S_OK;
00162 }
00163
00164
00165 /////////////////////////////////////////////////////////////////////////////
00166 //  Our Snap-in's exported functions
00167 //
00168
00169 //---------------------------------------------------------------------------
00170 //  Entry point into our Snap-in DLL
00171 //
00172 BOOL WINAPI DllMain
00173 (
00174   HINSTANCE  hInstDLL,         //[in] Handle to DLL module
00175   DWORD      fdwReason,        //[in] Reason for calling function
00176   void*      lpvReserved       //[in] Reserved
00177 )
00178 {
00179   if( DLL_PROCESS_ATTACH == fdwReason )
00180   {
00181      g_hInst = hInstDLL;
00182   }
00183
00184   return TRUE;
00185 }
00186
00187
00188 //---------------------------------------------------------------------------
00189 STDAPI DllGetClassObject
00190 (
00191   REFCLSID   rclsid,         //[in] CLSID for the class object
00192   REFIID     riid,           //[in] Reference to interface identifier
00193   LPVOID     *ppvObj         //[out] Object which recieves interface pointer
00194 )
00195 {
00196   // Test for CSnapinAbout
00197   if( (rclsid != CLSID_CComponentData) && (rclsid != CLSID_CSnapinAbout) )
00198     return CLASS_E_CLASSNOTAVAILABLE;
00199
00200   if( !ppvObj )
00201     return E_FAIL;
00202
00203   *ppvObj = NULL;
00204
00205   // We can only hand out IUnknown and IClassFactory pointers.  Fail
00206   // if caller asks for anything else.
00207   if( !IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory) )
00208     return E_NOINTERFACE;
00209
00210   CClassFactory *pFactory = NULL;
00211
00212   // Create the new class factory.  Pass in the type of object to create
00213   if( rclsid == CLSID_CComponentData )
00214     pFactory = new CClassFactory(CClassFactory::COMPONENTDATA);
00215   else if( rclsid == CLSID_CSnapinAbout )
00216     pFactory = new CClassFactory(CClassFactory::ABOUT);
00217
00218
00219   HRESULT hResult = pFactory->QueryInterface( riid, ppvObj );
00220
00221   return hResult;
00222 }
00223
00224
00225 //---------------------------------------------------------------------------
00226 STDAPI DllCanUnloadNow(void)
00227 {
00228   if( 0 == g_uObjectCount && 0 == g_uServerLocks )
00229     return S_OK;
00230   else
00231     return S_FALSE;
00232 }
00233
00234
00235 //---------------------------------------------------------------------------
00236 STDAPI DllRegisterServer()
00237 {
00238   HRESULT hResult = S_FALSE;
00239
00240   do
00241   { // Support ISnapinAbout
00242     hResult = RegisterServer( g_hInst, CLSID_CSnapinAbout, gtszABOUT_NAME );
00243     BREAK_ON_ERROR( hResult );
00244
00245     hResult = RegisterServer( g_hInst, CLSID_CComponentData, gtszSNAPIN_NAME );
00246     BREAK_ON_ERROR( hResult );
00247
00248     hResult = RegisterSnapin( CLSID_CComponentData, gtszSNAPIN_NAME, CLSID_CSnapinAbout, FALSE );
00249     BREAK_ON_ERROR( hResult );
00250
00251   }while( 0 );
00252
00253   return hResult;
00254 }
00255
00256
00257 //---------------------------------------------------------------------------
00258 STDAPI DllUnregisterServer()
00259 {
00260   if( S_OK != UnregisterServer( CLSID_CComponentData )  ||
00261       S_OK != UnregisterServer( CLSID_CSnapinAbout   )  ||
00262       S_OK != UnregisterSnapin( CLSID_CComponentData )
00263     )
00264     return E_UNEXPECTED;
00265   else
00266     return S_OK;
00267 }
00268
Generated on Wed Nov 13 2024 16:52:30 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/gutilsrc.h Source File

  • Begin
  • sdkdiff

gutilsrc.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010 #ifndef __GUTILSRC_H__
00011 #define __GUTILSRC_H__
00012
00013 #define IDC_LPAGENR   102
00014
00015 #define IDC_LFNAME    201
00016 #define IDC_FNAME     202
00017 #define IDC_PROMPT    203
00018 #define IDC_LFILES    204
00019 #define IDC_LSDIR     205
00020 #define IDC_SDIR      206
00021 #define IDC_LDIRS     207
00022 #define IDC_FILES     208
00023 #define IDC_DIRS      209
00024 #define IDC_OPEN      210
00025 #define IDC_CANCEL    211
00026
00027 #define IDD_GUTILS_LABEL     301
00028 #define IDD_GUTILS_FILE      302
00029
00030 #define IDS_MEMORY_ALLOC_FAIL  401
00031 #define IDS_OUT_OF_MEMORY      402
00032 #define IDS_PAGE_STR           403
00033 #endif
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpSvr/icf.Cpp Source File

  • Com
  • Fundamentals
  • SimpSvr

icf.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: ICF.CPP
00003 //
00004 //    Implementation file for the CClassFactory Class
00005 //
00006 // Functions:
00007 //
00008 //    See icf.h for a list of member functions.
00009 //
00010 // Copyright 1993 - 2000 Microsoft Corporation. All rights reserved.
00011 //**********************************************************************
00012
00013 #include "pre.h"
00014 #include "app.h"
00015 #include "doc.h"
00016 #include "icf.h"
00017
00018 //**********************************************************************
00019 //
00020 // CClassFactory::QueryInterface
00021 //
00022 // Purpose:
00023 //
00024 //
00025 // Parameters:
00026 //
00027 //      REFIID riid         -   Interface being queried for.
00028 //
00029 //      LPVOID FAR *ppvObj  -   Out pointer for the interface.
00030 //
00031 // Return Value:
00032 //
00033 //      S_OK            - Success
00034 //      E_NOINTERFACE   - Failure
00035 //
00036 // Function Calls:
00037 //      Function                    Location
00038 //
00039 //      CSimpSvrApp::QueryInterface APP.CPP
00040 //
00041 // Comments:
00042 //
00043 //
00044 //********************************************************************
00045
00046 STDMETHODIMP CClassFactory::QueryInterface  ( REFIID riid, LPVOID FAR* ppvObj)
00047 {
00048   OutputDebugString("In CClassFactory::QueryInterface\r\n");
00049
00050   SCODE sc = S_OK;
00051
00052   if ( (riid == IID_IUnknown) ||
00053      (riid == IID_IClassFactory) )
00054     *ppvObj = this;
00055   else
00056     {
00057     *ppvObj = NULL;
00058     sc = E_NOINTERFACE;
00059     }
00060
00061   if (*ppvObj)
00062     ((LPUNKNOWN)*ppvObj)->AddRef();
00063
00064   // pass it on to the Application object
00065   return sc;
00066 };
00067
00068 //**********************************************************************
00069 //
00070 // CClassFactory::AddRef
00071 //
00072 // Purpose:
00073 //
00074 //      Increments the reference count on CClassFactory and the application
00075 //      object.
00076 //
00077 // Parameters:
00078 //
00079 //      None
00080 //
00081 // Return Value:
00082 //
00083 //      The Reference count on CClassFactory
00084 //
00085 // Function Calls:
00086 //      Function                    Location
00087 //
00088 //      OuputDebugString            Windows API
00089 //
00090 // Comments:
00091 //
00092 //
00093 //********************************************************************
00094
00095
00096 STDMETHODIMP_(ULONG) CClassFactory::AddRef ()
00097 {
00098   OutputDebugString("In CClassFactory::AddRef\r\n");
00099
00100   return ++m_nCount;
00101 };
00102
00103 //**********************************************************************
00104 //
00105 // CClassFactory::Release
00106 //
00107 // Purpose:
00108 //
00109 //      Decrements the reference count of CClassFactory and the
00110 //      application object.
00111 //
00112 // Parameters:
00113 //
00114 //      None
00115 //
00116 // Return Value:
00117 //
00118 //      The new reference count
00119 //
00120 // Function Calls:
00121 //      Function                    Location
00122 //
00123 //      OutputDebugString           Windows API
00124 //
00125 // Comments:
00126 //
00127 //
00128 //********************************************************************
00129
00130
00131 STDMETHODIMP_(ULONG) CClassFactory::Release ()
00132 {
00133   OutputDebugString("In CClassFactory::Release\r\n");
00134
00135   if (--m_nCount == 0) {
00136     delete this;
00137         return 0;
00138     }
00139
00140   return m_nCount;
00141 };
00142
00143
00144 //**********************************************************************
00145 //
00146 // CClassFactory::CreateInstance
00147 //
00148 // Purpose:
00149 //
00150 //      Instantiates a new OLE object
00151 //
00152 // Parameters:
00153 //
00154 //      LPUNKNOWN pUnkOuter     - Pointer to the controlling unknown
00155 //
00156 //      REFIID riid             - The interface type to fill in ppvObject
00157 //
00158 //      LPVOID FAR* ppvObject   - Out pointer for the object
00159 //
00160 // Return Value:
00161 //
00162 //      S_OK                    - Creation was successful
00163 //      CLASS_E_NOAGGREGATION   - Tried to be created as part of an aggregate
00164 //
00165 //
00166 // Function Calls:
00167 //      Function                    Location
00168 //
00169 //      OutputDebugString           Windows API
00170 //      CSimpSvrDoc::CreateObject   DOC.CPP
00171 //
00172 // Comments:
00173 //
00174 //
00175 //********************************************************************
00176
00177 STDMETHODIMP CClassFactory::CreateInstance ( LPUNKNOWN pUnkOuter,
00178                 REFIID riid,
00179                 LPVOID FAR* ppvObject)
00180 {
00181   HRESULT hErr;
00182
00183   OutputDebugString("In CClassFactory::CreateInstance\r\n");
00184
00185   // need to NULL the out parameter
00186   *ppvObject = NULL;
00187
00188   // we don't support aggregation...
00189   if (pUnkOuter)
00190     {
00191     hErr = CLASS_E_NOAGGREGATION;
00192     goto error;
00193     }
00194
00195   hErr = m_lpApp->m_lpDoc->CreateObject(riid, ppvObject);
00196
00197 error:
00198   return hErr;
00199 };
00200
00201 //**********************************************************************
00202 //
00203 // CClassFactory::LockServer
00204 //
00205 // Purpose:
00206 //
00207 //
00208 // Parameters:
00209 //
00210 //      BOOL fLock      - TRUE to lock the server, FALSE to unlock it
00211 //
00212 // Return Value:
00213 //
00214 //      S_OK
00215 //
00216 // Function Calls:
00217 //      Function                    Location
00218 //
00219 //      OutputDebugString           Windows API
00220 //      CoLockObjectExternal        OLE API
00221 //                   OLE API
00222 //
00223 // Comments:
00224 //
00225 //
00226 //********************************************************************
00227
00228
00229 STDMETHODIMP CClassFactory::LockServer ( BOOL fLock)
00230 {
00231   OutputDebugString("In CClassFactory::LockServer\r\n");
00232   CoLockObjectExternal(m_lpApp, fLock, TRUE);
00233
00234   return  S_OK;
00235 };
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/ViewDIB/Resource.h Source File

  • Multimedia
  • Gdi
  • ViewDIB

Resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by ViewDIB.rc
00004 //
00005 #define IDM_EXIT                        102
00006 #define IDM_ABOUT                       105
00007 #define IDM_LOADDIB                     106
00008 #define IDM_PRINT                       109
00009 #define IDM_COPY                        110
00010 #define IDM_PASTE                       111
00011 #define IDM_DIBINFO                     112
00012 #define IDM_CD1BPP                      113
00013 #define IDM_CD4BPP                      114
00014 #define IDM_CD8BPP                      115
00015 #define IDM_CD15BPP                     116
00016 #define IDM_CD16BPP                     117
00017 #define IDM_CD24BPP                     118
00018 #define IDM_CD32BPP                     119
00019 #define IDM_SAVEDIB                     121
00020 #define IDC_STATIC                      -1
00021
00022 // Next default values for new objects
00023 //
00024 #ifdef APSTUDIO_INVOKED
00025 #ifndef APSTUDIO_READONLY_SYMBOLS
00026 #define _APS_NEXT_RESOURCE_VALUE        103
00027 #define _APS_NEXT_COMMAND_VALUE         122
00028 #define _APS_NEXT_CONTROL_VALUE         1004
00029 #define _APS_NEXT_SYMED_VALUE           101
00030 #endif
00031 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Debug/Deb/ToolBar.h Source File

  • WinBase
  • Debug
  • Deb

ToolBar.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00004 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00005 TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00006 PARTICULAR PURPOSE.
00007
00008 Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
00009
00010 *       This source code is only intended as a supplement to
00011 *       Microsoft Development Tools and/or WinHelp documentation.
00012 *       See these sources for detailed information regarding the
00013 *       Microsoft samples programs.
00014 \******************************************************************************/
00015
00016 #ifndef TOOLBAR_H
00017
00018  #define TOOLBAR_H
00019
00020  #define TB_SPACE 0xFFFFFFFF
00021
00022  //-- typedefs
00023  typedef struct TEXTBUTTON_STRUCT {
00024            LPTSTR lpButtonText;   // The string that appears on the button
00025            INT    idButton;       // This id is sent to the window proc
00026            HWND   hWndButton;     // The returned window handle of the button
00027          } TEXTBUTTON, *LPTEXTBUTTON;
00028
00029  //-- prototypes
00030  HWND TextButtonBar( HWND, LPTEXTBUTTON, LPINT );
00031
00032 #endif // TOOLBAR_H
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/WtsApi/WtsApi/ServerDlg.h Source File

  • WinBase
  • WtsApi
  • WtsApi

ServerDlg.h

Go to the documentation of this file.
00001 //  Copyright 1995-1999, Citrix Systems Inc.
00002 //  Copyright (c) 1997 - 2000  Microsoft Corporation
00003 #if !defined(AFX_SERVERDLG_H__C090CEFA_303B_11D1_8310_00C04FBEFCDA__INCLUDED_)
00004 #define AFX_SERVERDLG_H__C090CEFA_303B_11D1_8310_00C04FBEFCDA__INCLUDED_
00005
00006 #if _MSC_VER >= 1000
00007 #pragma once
00008 #endif // _MSC_VER >= 1000
00009
00010 #include <wtsapi32.h>
00011
00012 // ServerDlg.h : header file
00013 //
00014
00015 /////////////////////////////////////////////////////////////////////////////
00016 // CServerDlg dialog
00017
00018 class CServerDlg : public CDialog
00019 {
00020 // Construction
00021 public:
00022   BOOL domainFlag;
00023   CString serverName;
00024   DWORD count;
00025   PWTS_SERVER_INFO pServerInfo;
00026
00027   // standard constructor
00028   CServerDlg(CWnd* pParent = NULL);
00029
00030 // Dialog Data
00031   //{{AFX_DATA(CServerDlg)
00032   enum { IDD = IDD_SERVERDLG };
00033   CComboBox m_serverList2;
00034   CEdit m_domainName;
00035   //}}AFX_DATA
00036
00037
00038 // Overrides
00039   // ClassWizard generated virtual function overrides
00040   //{{AFX_VIRTUAL(CServerDlg)
00041   protected:
00042   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00043   //}}AFX_VIRTUAL
00044
00045 // Implementation
00046 protected:
00047
00048   // Generated message map functions
00049   //{{AFX_MSG(CServerDlg)
00050   virtual BOOL OnInitDialog();
00051   virtual void OnOK();
00052   afx_msg void OnDropdownServerList2();
00053   afx_msg void OnChangeDomainName();
00054   //}}AFX_MSG
00055   DECLARE_MESSAGE_MAP()
00056 private:
00057 };
00058
00059 //{{AFX_INSERT_LOCATION}}
00060 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00061
00062 #endif // !defined(AFX_SERVERDLG_H__C090CEFA_303B_11D1_8310_00C04FBEFCDA__INCLUDED_)
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/ActiveDocument/Framer/Framer.Cpp Source File

  • Com
  • Fundamentals
  • ActiveDocument
  • Framer

Framer.Cpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 /*
00019  * FRAMER.CPP
00020  * Document Objects Framer
00021  *
00022  * Sample to demonstrate in-place activation of a DocObject--also
00023  * activates normal embeddings in separate windows.
00024  *
00025  */
00026
00027
00028 #define INITGUID
00029 #include "framer.h"
00030
00031
00032 /*
00033  * WinMain
00034  *
00035  * Purpose:
00036  *  Main entry point of application.  Should register the app class
00037  *  if a previous instance has not done so and do any other one-time
00038  *  initializations.
00039  */
00040
00041 int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrev
00042     , LPSTR pszCmdLine, int nCmdShow)
00043     {
00044     PCFrame         pFR;
00045     WPARAM          wRet = 0;
00046
00047     //Attempt to allocate and initialize the application
00048     pFR=new CFrame(hInst, hPrev, pszCmdLine, nCmdShow);
00049
00050     if (NULL==pFR)
00051         return 0;
00052
00053     //If we can initialize pFR, start chugging messages
00054     if (pFR->Init(CMENUS, CW_USEDEFAULT, CW_USEDEFAULT
00055         , CW_USEDEFAULT, CW_USEDEFAULT))
00056         wRet=pFR->MessageLoop();
00057
00058     delete pFR;
00059     return (int)wRet;
00060     }
00061
00062
00063
00064 /*
00065  * CFrame::CFrame
00066  * CFrame::~CFrame
00067  *
00068  * Constructor Parameters:
00069  *  hInst           HINSTANCE from WinMain
00070  *  hInstPrev       HINSTANCE from WinMain
00071  *  pszCmdLine      LPSTR from WinMain
00072  *  nCmdShow        int from WinMain
00073  */
00074
00075 CFrame::CFrame(HINSTANCE hInst, HINSTANCE hInstPrev
00076     , LPSTR pszCmdLine, int nCmdShow)
00077     {
00078   UNREFERENCED_PARAMETER(pszCmdLine);
00079     m_hInst=hInst;
00080     m_hWnd=NULL;
00081     m_hInstPrev=hInstPrev;
00082     m_nCmdShow=nCmdShow;
00083
00084     m_phMenu=NULL;
00085     m_hAccel=NULL;
00086     m_hWndClient=NULL;
00087
00088     m_fInitialized=FALSE;
00089     m_pIStorage=NULL;
00090     m_dwIDCounter=0;
00091
00092     m_hMenuOrg=NULL;
00093     m_hMenuTop=NULL;
00094   m_hMenuHelp=NULL;
00095   m_fInObjectHelp=FALSE;
00096   m_fUsingOurHelp=FALSE;
00097
00098     m_fHaveObject=FALSE;
00099   m_hWndObj=NULL;
00100
00101     m_pSite=NULL;
00102     m_fOurMenuShowing=TRUE;
00103     SetRect(&m_bwIP, 0, 0, 0, 0);
00104     m_fInContextHelp=FALSE;
00105     m_pIOleIPActiveObject=NULL;
00106
00107     return;
00108     }
00109
00110
00111
00112 CFrame::~CFrame(void)
00113     {
00114     if (NULL!=m_hWndClient)
00115         DestroyWindow(m_hWndClient);
00116
00117     //Frees the temp file.
00118     ReleaseInterface(m_pIStorage);
00119
00120     //m_pSite cleaned up in Close
00121
00122     //Accelerators freed automatically.
00123
00124   //Destroy the special help menu
00125   if (NULL!=m_hMenuHelp)
00126     DestroyMenu(m_hMenuHelp);
00127
00128     //Free the menu handle array
00129     if (NULL!=m_phMenu)
00130         delete []((UINT *)m_phMenu);
00131
00132     if (m_fInitialized)
00133         OleUninitialize();
00134
00135     return;
00136     }
00137
00138
00139 /*
00140  * CFrame::Init
00141  *
00142  * Purpose:
00143  *  Initializer for a CFrame object containing anything prone to
00144  *  failure.
00145  *
00146  * Parameters:
00147  *  cMenus          UINT number of menus on the frame
00148  *  x, y, cx, cy    int location and size of frame window
00149  *
00150  * Return Value:
00151  *  BOOL            TRUE if initialization succeeded, FALSE
00152  *                  otherwise. If FALSE is returned, the caller must
00153  *                  guarantee that the destructor is called promptly
00154  *                  to insure cleanup.
00155  */
00156
00157 BOOL CFrame::Init(UINT cMenus, int x, int y, int cx, int cy)
00158     {
00159     HMENU               hMenu;
00160     UINT                uTemp;
00161     RECT                rc;
00162
00163     //1.  Initialize OLE
00164     if (SUCCEEDED(OleInitialize(NULL)))
00165         m_fInitialized=TRUE;
00166     else
00167         return FALSE;
00168
00169
00170     //2.  Register window classes
00171     if (NULL==m_hInstPrev)
00172         {
00173         if (!RegisterAllClasses())
00174             return FALSE;
00175         }
00176
00177
00178     //3.  Create the main window and client-area window
00179     m_hWnd=CreateWindow(SZCLASSFRAME, TEXT("DocObject Framer")
00180         , WS_MINIMIZEBOX | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
00181         , x, y, cx, cy, NULL, NULL, m_hInst, this);
00182
00183     if (NULL==m_hWnd)
00184         return FALSE;
00185
00186     GetClientRect(m_hWnd, &rc);
00187
00188     m_hWndClient=CreateWindow(SZCLASSCLIENT, SZCLASSCLIENT
00189         , WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_CLIPSIBLINGS
00190         , rc.left, rc.top, rc.right-rc.left
00191         , rc.bottom-rc.top, m_hWnd, NULL, m_hInst, this);
00192
00193     if (NULL==m_hWndClient)
00194         return FALSE;
00195
00196     //4. Allocate menu array for use with in-place menu merging.
00197     m_phMenu=new HMENU[cMenus];
00198     hMenu=GetMenu(m_hWnd);
00199     m_hMenuOrg=hMenu;
00200
00201     for (uTemp=0; uTemp < cMenus; uTemp++)
00202         m_phMenu[uTemp]=GetSubMenu(hMenu, uTemp);
00203
00204   //Also load the special help menu
00205   m_hMenuHelp=LoadMenu(m_hInst
00206     , MAKEINTRESOURCE(IDR_MENUHELP));
00207
00208     //5.  Load accelerators
00209     m_hAccel=LoadAccelerators(m_hInst
00210         , MAKEINTRESOURCE(IDR_ACCELERATORS));
00211
00212     if (NULL==m_hAccel)
00213         return FALSE;
00214
00215
00216     //6.  Make us all visible.
00217     ShowWindow(m_hWnd, m_nCmdShow);
00218     UpdateWindow(m_hWnd);
00219
00220
00221     /*
00222      * 7.  Create a temp file for all embedded files.  Note that in this
00223      *     sample we don't save any changes to DocObjects because we
00224    *     don't manage any storage directly.
00225    */
00226     if (FAILED(StgCreateDocfile(NULL, STGM_TRANSACTED | STGM_READWRITE
00227         | STGM_SHARE_EXCLUSIVE | STGM_CREATE| STGM_DELETEONRELEASE
00228         , 0, &m_pIStorage)))
00229         return FALSE;
00230
00231     return TRUE;
00232     }
00233
00234
00235
00236
00237
00238 /*
00239  * CFrame::RegisterAllClasses
00240  *
00241  * Purpose:
00242  *  Registers all classes used in this application.
00243  *
00244  * Return Value:
00245  *  BOOL            TRUE if registration succeeded, FALSE otherwise.
00246  */
00247
00248 BOOL CFrame::RegisterAllClasses(void)
00249     {
00250     WNDCLASS        wc;
00251
00252     //Field that are the same for all windows.
00253     wc.style         = CS_HREDRAW | CS_VREDRAW;
00254     wc.hInstance     = m_hInst;
00255     wc.cbClsExtra    = 0;
00256
00257     //Register the Frame window
00258     wc.lpfnWndProc   = FrameWndProc;
00259     wc.cbWndExtra    = CBFRAMEWNDEXTRA;
00260     wc.hIcon         = LoadIcon(m_hInst, TEXT("Icon"));
00261     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00262     wc.hbrBackground = NULL;
00263     wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU);
00264     wc.lpszClassName = SZCLASSFRAME;
00265
00266     if (!RegisterClass(&wc))
00267         return FALSE;
00268
00269
00270     //Register the do-nothing Client window
00271     wc.lpfnWndProc   = ClientWndProc;
00272     wc.cbWndExtra    = CBCLIENTWNDEXTRA;
00273     wc.hIcon         = NULL;
00274     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00275     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00276     wc.lpszMenuName  = NULL;
00277     wc.lpszClassName = SZCLASSCLIENT;
00278
00279     if (!RegisterClass(&wc))
00280         return FALSE;
00281
00282     return TRUE;
00283     }
00284
00285
00286
00287
00288 /*
00289  * CFrame::OnCommand
00290  *
00291  * Purpose:
00292  *  WM_COMMAND handler for the frame window so derivations can
00293  *  process their messages and then pass the standard commands (like
00294  *  file open and save) on to the base class.
00295  *
00296  * Parameters:
00297  *  hWnd            HWND of the frame window.
00298  *  wParam          WPARAM of the message.
00299  *  lParam          LPARAM of the message.
00300  *
00301  * Return Value:
00302  *  LRESULT         Return value for the message.
00303  */
00304
00305 LRESULT CFrame::OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
00306     {
00307     TCHAR           szFile[MAX_PATH];
00308     BOOL            fOK;
00309     PCHourglass     pHour;
00310     WORD            wID=LOWORD(wParam);
00311
00312     switch (wID)
00313         {
00314         case IDM_FILEOPEN:
00315             /*
00316              * This will be disabled if we already have an object.
00317              * User must File/Close first to get back here.
00318              *
00319              * Otherwise open the File/Open dialog
00320              */
00321             szFile[0]=0;
00322             if (!OpenDialog(szFile, MAX_PATH))
00323                 return 0L;
00324
00325             pHour=new CHourglass;
00326             fOK=CreateObject(szFile);
00327             delete pHour;
00328             return 0;
00329
00330
00331         case IDM_FILECLOSE:
00332             Close();
00333             break;
00334
00335
00336         case IDM_FILEEXIT:
00337             PostMessage(hWnd, WM_CLOSE, 0, 0L);
00338             break;
00339
00340
00341         case IDM_HELPABOUT:
00342             DialogBox(m_hInst, MAKEINTRESOURCE(IDD_ABOUT)
00343                 , m_hWnd, (DLGPROC)AboutProc);
00344             break;
00345
00346
00347         case IDM_ENTERCONTEXTHELP:
00348         case IDM_ESCAPECONTEXTHELP:
00349             //Notify the object on entry and exit.
00350             ContextSensitiveHelp(IDM_ENTERCONTEXTHELP==wID);
00351             break;
00352
00353
00354         default:
00355            return DefWindowProc(hWnd, WM_COMMAND, wParam, lParam);
00356
00357         }
00358
00359     return 0L;
00360     }
00361
00362
00363
00364
00365
00366 /*
00367  * CFrame::OpenDialog
00368  *
00369  * Purpose:
00370  *  Invokes the COMMDLG.DLL GetOpenFileName dialog and retrieves
00371  *  a filename for saving or opening.
00372  *
00373  * Parameters:
00374  *  pszFile         LPTSTR buffer to receive the entered filename.
00375  *  cchFile         UINT length of pszFile
00376  *
00377  * Return Value:
00378  *  BOOL            TRUE if the function retrieved a filename,
00379  *                  FALSE if the user pressed CANCEL.
00380  */
00381
00382 BOOL CFrame::OpenDialog(LPTSTR pszFile, UINT cchFile)
00383     {
00384     OPENFILENAME        ofn;
00385     static TCHAR        szFilter[80]=TEXT("All Files (*.*)\0*.*\0\0");
00386     BOOL                fRet;
00387    #ifdef DEBUG
00388     DWORD               dwErr;
00389    #endif
00390
00391     if (NULL==pszFile)
00392         return FALSE;
00393
00394     memset(&ofn, 0, sizeof(OPENFILENAME));
00395     ofn.lStructSize      =sizeof(OPENFILENAME);
00396     ofn.hwndOwner        =m_hWnd;
00397
00398     ofn.lpstrFilter      =szFilter;
00399     ofn.nFilterIndex     =1L;
00400
00401     ofn.lpstrTitle       =NULL;
00402     ofn.lpstrFile        =pszFile;
00403     ofn.nMaxFile         =cchFile;
00404
00405     ofn.lpstrDefExt      =TEXT("*");
00406     ofn.Flags            =OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
00407
00408     fRet=GetOpenFileName(&ofn);
00409
00410    #ifdef DEBUG
00411     dwErr=CommDlgExtendedError();
00412    #endif
00413     return fRet;
00414     }
00415
00416
00417
00418 /*
00419  * CFrame::CreateObject
00420  *
00421  * Purpose:
00422  *  Creates a site and has it create an object based on a filename.
00423  *
00424  * Parameters:
00425  *  pszFile         LPTSTR pointing to the filename from which to
00426  *                  create the object.
00427  *
00428  * Return Value:
00429  *  BOOL            TRUE if successful, FALSE otherwise.
00430  */
00431
00432 BOOL CFrame::CreateObject(LPTSTR pszFile)
00433     {
00434     m_pSite=new CSite(++m_dwIDCounter, m_hWndClient, this);
00435
00436     if (NULL==m_pSite)
00437         return FALSE;
00438
00439     m_pSite->AddRef();  //So we can free with Release
00440
00441     /*
00442      * Now tell the site to create an object in it using the filename
00443      * and the storage we opened.  The site will create a sub-storage
00444      * for the doc object's use.
00445      */
00446     if (!m_pSite->Create(pszFile, m_pIStorage))
00447         return FALSE;
00448
00449     m_fHaveObject=TRUE;
00450
00451     //We created the thing, now activate it with "Show"
00452     m_pSite->Activate(OLEIVERB_SHOW);
00453
00454   //Force repaint to show "have object" message
00455   InvalidateRect(m_hWndClient, NULL, TRUE);
00456   UpdateWindow(m_hWndClient);
00457     return TRUE;
00458     }
00459
00460
00461
00462 /*
00463  * CFrame::Close
00464  *
00465  * Purpose:
00466  *  Handles File/Close by freeing the object and resetting the
00467  *  application state.
00468  *
00469  * Parameters:
00470  *  None
00471  *
00472  * Return Value:
00473  *  None
00474  */
00475
00476 void CFrame::Close(void)
00477     {
00478   RECT  rc;
00479
00480     if (NULL!=m_pSite)
00481         {
00482     CSite *pSite=m_pSite;        //Prevents reentry
00483     m_pSite=NULL;
00484
00485         pSite->Close(FALSE);         //Frees the object
00486         pSite->Destroy(m_pIStorage); //Cleans up the storage
00487         pSite->Release();            //Frees the site
00488         }
00489
00490   m_fHaveObject=FALSE;
00491     SetRect(&m_bwIP, 0, 0, 0, 0);
00492
00493   GetClientRect(m_hWnd, &rc);
00494   ResizeClientWindow(rc.left, rc.top, rc.right-rc.left
00495     , rc.bottom-rc.top);
00496
00497   //Force repaint to remove "have object" message
00498   InvalidateRect(m_hWndClient, NULL, TRUE);
00499   UpdateWindow(m_hWndClient);
00500
00501     return;
00502     }
00503
00504
00505 /*
00506  * CFrame::ResizeClientWindow
00507  *
00508  * Purpose:
00509  *  Resizes the client-area window according to current toolbar sizes
00510  *  and the frame window size.
00511  *
00512  * Parameters:
00513  *  x,y,cx,cy   UINT origin and dimensions of the window
00514  *
00515  * Return Value:
00516  *  None
00517  */
00518
00519 void CFrame::ResizeClientWindow(UINT x, UINT y, UINT cx, UINT cy)
00520   {
00521   SetWindowPos(m_hWndClient, NULL, x, y, cx, cy
00522         , SWP_NOZORDER | SWP_NOACTIVATE);
00523
00524     //Tell the site to tell the object.
00525   if (NULL!=m_pSite)
00526       m_pSite->UpdateObjectRects();
00527
00528   return;
00529   }
00530
00531
00532 /*
00533  * CFrame::MessageLoop
00534  *
00535  * Purpose:
00536  *  Spins in a standard message loop (with accelerators) until
00537  *  WM_QUIT is found after which it returns.
00538  *
00539  * Return Value:
00540  *  WPARAM          Contents of msg.wParam from WM_QUIT.
00541  */
00542
00543 WPARAM CFrame::MessageLoop(void)
00544     {
00545     MSG     msg;
00546
00547     while (GetMessage(&msg, NULL, 0,0 ))
00548         {
00549         //Always give the object first crack at translation.
00550         if (NULL!=m_pIOleIPActiveObject)
00551             {
00552             HRESULT     hr;
00553
00554             hr=m_pIOleIPActiveObject->TranslateAccelerator(&msg);
00555
00556             //If the object translated the accelerator, we're done
00557             if (NOERROR==hr)
00558                 continue;
00559             }
00560
00561         if (!::TranslateAccelerator(m_hWnd, m_hAccel, &msg))
00562             {
00563             TranslateMessage(&msg);
00564             DispatchMessage(&msg);
00565             }
00566         }
00567
00568     return msg.wParam;
00569     }
00570
00571
00572
00573 /*
00574  * FrameWndProc
00575  *
00576  * Purpose:
00577  *  Frame window class procedure that allows a derivation of these
00578  *  classes to hook and process any messages desired.  Otherwise this
00579  *  handles standard commands as well as the status line and menus.
00580  */
00581
00582 LRESULT APIENTRY FrameWndProc(HWND hWnd, UINT iMsg
00583     , WPARAM wParam, LPARAM lParam)
00584     {
00585     PCFrame         pFR;
00586     RECT            rc;
00587     HMENU           hMenu;
00588
00589     pFR=(PCFrame)GetWindowLongPtr(hWnd, FRAMEWL_STRUCTURE);
00590
00591     switch (iMsg)
00592         {
00593         case WM_NCCREATE:
00594             pFR=(PCFrame)((LPCREATESTRUCT)lParam)->lpCreateParams;
00595
00596             SetWindowLongPtr(hWnd, FRAMEWL_STRUCTURE, (LONG_PTR)pFR);
00597             return DefWindowProc(hWnd, iMsg, wParam, lParam);
00598
00599         case WM_DESTROY:
00600             PostQuitMessage(0);
00601             break;
00602
00603         case WM_CLOSE:
00604             pFR->Close();
00605             DestroyWindow(hWnd);
00606             break;
00607
00608         case WM_ERASEBKGND:
00609             //Client area window always manages painting
00610             return FALSE;
00611
00612         case WM_SIZE:
00613             //Tell the in-place object about the new frame size
00614             GetClientRect(hWnd, &rc);
00615
00616             if (NULL!=pFR->m_pIOleIPActiveObject)
00617                 pFR->m_pIOleIPActiveObject->ResizeBorder(&rc, pFR, TRUE);
00618
00619             /*
00620              * Resize the client, which is done in all cases since this window
00621        * is the parent of the DocObject, plus we need to tell the
00622        * DocObject of the new size through IOleDocumentView::SetRect.
00623        */
00624             rc.left  +=pFR->m_bwIP.left;
00625             rc.right -=pFR->m_bwIP.right;
00626             rc.top   +=pFR->m_bwIP.top;
00627             rc.bottom-=pFR->m_bwIP.bottom;
00628
00629       pFR->ResizeClientWindow(rc.left, rc.top, rc.right-rc.left
00630         , rc.bottom-rc.top);
00631
00632             break;
00633
00634
00635         case WM_SETFOCUS:
00636             if (NULL!=pFR->m_pIOleIPActiveObject)
00637                 {
00638                 HWND    hWndObj;
00639
00640                 pFR->m_pIOleIPActiveObject->GetWindow(&hWndObj);
00641                 SetFocus(hWndObj);
00642                 }
00643
00644             return TRUE;
00645
00646
00647     case WM_INITMENU:
00648       pFR->m_fInObjectHelp=FALSE;
00649       break;
00650
00651
00652     case WM_MENUSELECT:
00653         {
00654         UINT fuFlags=(UINT)HIWORD(wParam);
00655         UINT uItem=(UINT)LOWORD(wParam);
00656
00657         if (MF_POPUP & fuFlags)
00658           {
00659           /*
00660            * If we're inside our m_hMenuHelp, and uItem is
00661            * not zero (first item on the menu, which is ours),
00662            * then we must be in an object-supplied menu.
00663            *
00664            * Therefore we set our flag and forward the message
00665            * as well as others that occur later.  Otherwise we
00666            * clear the flag so we get messages again.
00667            */
00668           if (NULL!=pFR->m_hMenuHelp
00669             && (HMENU)lParam==pFR->m_hMenuHelp)
00670             {
00671             pFR->m_fInObjectHelp=(0!=uItem);
00672
00673             if (pFR->m_fInObjectHelp)
00674               SendMessage(pFR->m_hWndObj, iMsg, wParam, lParam);
00675             }
00676           }
00677         else
00678           {
00679           //Forward the message on
00680           if (pFR->m_fInObjectHelp)
00681             {
00682             SendMessage(pFR->m_hWndObj, iMsg, wParam, lParam);
00683             break;
00684             }
00685           }
00686         }
00687       break;
00688
00689     case WM_INITMENUPOPUP:
00690       /*
00691        * If we're in the object's Help menu, forward to
00692        * the object received in IOleInPlaceFrame::SetActiveObject
00693        */
00694       if (pFR->m_fInObjectHelp && NULL!=pFR->m_hWndObj)
00695         SendMessage(pFR->m_hWndObj, iMsg, wParam, lParam);
00696
00697
00698       //Skip the system menu
00699             if (TRUE==(BOOL)HIWORD(lParam))
00700                 break;
00701
00702         /*
00703              * If we have an object, enable Close, otherwise
00704              * enable Open.
00705              */
00706             hMenu=(HMENU)wParam;
00707
00708             if (hMenu==pFR->m_phMenu[0])
00709                 {
00710                 UINT uTempE=MF_BYCOMMAND | MF_ENABLED;
00711                 UINT uTempD=MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
00712
00713                 EnableMenuItem(hMenu, IDM_FILEOPEN
00714                     , pFR->m_fHaveObject ? uTempD : uTempE);
00715                 EnableMenuItem(hMenu, IDM_FILECLOSE
00716                     , pFR->m_fHaveObject ? uTempE : uTempD);
00717                 }
00718
00719             break;
00720
00721         case WM_COMMAND:
00722       if (pFR->m_fInObjectHelp)
00723         {
00724         SendMessage(pFR->m_hWndObj, iMsg, wParam, lParam);
00725         break;
00726         }
00727       else
00728               return pFR->OnCommand(hWnd, wParam, lParam);
00729
00730     case WM_ACTIVATEAPP:
00731       if (NULL!=pFR->m_pIOleIPActiveObject)
00732         {
00733         HRESULT hr;
00734         hr=pFR->m_pIOleIPActiveObject->OnFrameWindowActivate((BOOL)wParam);
00735         }
00736       break;
00737
00738         default:
00739             return DefWindowProc(hWnd, iMsg, wParam, lParam);
00740         }
00741
00742     return 0L;
00743     }
00744
00745
00746
00747 /*
00748  * ClientWndProc
00749  *
00750  * Purpose:
00751  *  Client window class procedure that's only used to paint a
00752  *  message when we have a non-DocObject open.  Otherwise this
00753  *  is completely hidden.
00754  */
00755
00756 LRESULT APIENTRY ClientWndProc(HWND hWnd, UINT iMsg
00757     , WPARAM wParam, LPARAM lParam)
00758     {
00759     PCFrame         pFR;
00760   PAINTSTRUCT   ps;
00761
00762     pFR=(PCFrame)GetWindowLongPtr(hWnd, CLIENTWL_STRUCTURE);
00763
00764     switch (iMsg)
00765         {
00766         case WM_NCCREATE:
00767             pFR=(PCFrame)((LPCREATESTRUCT)lParam)->lpCreateParams;
00768
00769             SetWindowLongPtr(hWnd, CLIENTWL_STRUCTURE, (LONG_PTR)pFR);
00770             return DefWindowProc(hWnd, iMsg, wParam, lParam);
00771
00772         case WM_PAINT:
00773       BeginPaint(hWnd, &ps);
00774
00775       if (pFR->m_fHaveObject)
00776         {
00777         static TCHAR szMsg[]={TEXT("A non-DocObject is open or loaded. Use File/Close to destroy it.")};
00778
00779         SetBkColor(ps.hdc, GetSysColor(COLOR_WINDOW));
00780         TextOut(ps.hdc, 0, 0, szMsg, lstrlen(szMsg));
00781         }
00782
00783       EndPaint(hWnd, &ps);
00784             break;
00785
00786         default:
00787             return DefWindowProc(hWnd, iMsg, wParam, lParam);
00788         }
00789
00790     return 0L;
00791     }
00792
00793
00794
00795
00796
00797 /*
00798  * AboutProc
00799  *
00800  * Purpose:
00801  *  Dialog procedure for the omnipresent About box.
00802  *
00803  * Parameters:
00804  *  The standard.
00805  *
00806  * Return Value:
00807  *  The value to be returned through the DialogBox call that
00808  *  created the dialog.
00809  *
00810  */
00811
00812 BOOL APIENTRY AboutProc(HWND hDlg, UINT iMsg
00813     , WPARAM wParam, LPARAM lParam)
00814     {
00815   UNREFERENCED_PARAMETER(lParam);
00816     switch (iMsg)
00817         {
00818         case WM_INITDIALOG:
00819             return TRUE;
00820
00821         case WM_COMMAND:
00822             switch (LOWORD(wParam))
00823                 {
00824                 case IDOK:
00825                     EndDialog(hDlg, TRUE);
00826                 }
00827             break;
00828         }
00829     return FALSE;
00830     }
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840 /*
00841  * IUnknown implementation
00842  */
00843
00844
00845 /*
00846  * CFrame::QueryInterface
00847  * CFrame::AddRef
00848  * CFrame::Release
00849  */
00850
00851 STDMETHODIMP CFrame::QueryInterface(REFIID riid, void **ppv)
00852     {
00853     /*
00854      * We only know IOleInPlaceFrame and its base interfaces as well
00855      * as a bogus IOleCommandTarget to make PowerPoint happy.
00856    */
00857     *ppv=NULL;
00858
00859     if (IID_IUnknown==riid || IID_IOleInPlaceUIWindow==riid
00860         || IID_IOleWindow==riid || IID_IOleInPlaceFrame==riid)
00861         *ppv=(IOleInPlaceFrame *)this;
00862
00863   if (IID_IOleCommandTarget==riid)
00864         *ppv=(IOleCommandTarget *)this;
00865
00866     if (NULL!=*ppv)
00867         {
00868         ((LPUNKNOWN)*ppv)->AddRef();
00869         return NOERROR;
00870         }
00871
00872     return E_NOINTERFACE;
00873     }
00874
00875
00876 STDMETHODIMP_(ULONG) CFrame::AddRef(void)
00877     {
00878     return ++m_cRef;
00879     }
00880
00881 STDMETHODIMP_(ULONG) CFrame::Release(void)
00882     {
00883     //Nothing special happening here--frame's life if user-controlled.
00884     return --m_cRef;
00885     }
00886
00887
00888 /*
00889  * IOleInPlaceFrame implementation
00890  */
00891
00892
00893 /*
00894  * CFrame::GetWindow
00895  *
00896  * Purpose:
00897  *  Retrieves the handle of the window associated with the object
00898  *  on which this interface is implemented.
00899  *
00900  * Parameters:
00901  *  phWnd           HWND * in which to store the window handle.
00902  *
00903  * Return Value:
00904  *  HRESULT         NOERROR if successful, E_FAIL if there is no
00905  *                  window.
00906  */
00907
00908 STDMETHODIMP CFrame::GetWindow(HWND *phWnd)
00909     {
00910     *phWnd=m_hWnd;
00911     return NOERROR;
00912     }
00913
00914
00915
00916
00917 /*
00918  * CFrame::ContextSensitiveHelp
00919  *
00920  * Purpose:
00921  *  Instructs the object on which this interface is implemented to
00922  *  enter or leave a context-sensitive help mode.
00923  *
00924  * Parameters:
00925  *  fEnterMode      BOOL TRUE to enter the mode, FALSE otherwise.
00926  *
00927  * Return Value:
00928  *  HRESULT         NOERROR
00929  */
00930
00931 STDMETHODIMP CFrame::ContextSensitiveHelp(BOOL fEnterMode)
00932     {
00933     /*
00934      * Don't bother if there is no active object since we don't do
00935      * context help on our own.
00936      */
00937     if (NULL==m_pIOleIPActiveObject)
00938         return NOERROR;
00939
00940     //If the state changes, notify the active object.
00941     if (m_fInContextHelp!=fEnterMode)
00942         {
00943         m_fInContextHelp=fEnterMode;
00944         m_pIOleIPActiveObject->ContextSensitiveHelp(fEnterMode);
00945         }
00946
00947     return NOERROR;
00948     }
00949
00950
00951
00952
00953 /*
00954  * CFrame::GetBorder
00955  *
00956  * Purpose:
00957  *  Returns the rectangle in which the container is willing to
00958  *  negotiate about an object's adornments.
00959  *
00960  * Parameters:
00961  *  prcBorder       LPRECT in which to store the rectangle.
00962  *
00963  * Return Value:
00964  *  HRESULT         NOERROR if all is well, INPLACE_E_NOTOOLSPACE
00965  *                  if there is no negotiable space.
00966  */
00967
00968 STDMETHODIMP CFrame::GetBorder(LPRECT prcBorder)
00969     {
00970     if (NULL==prcBorder)
00971         return E_INVALIDARG;
00972
00973     //We return all the client area space
00974     GetClientRect(m_hWnd, prcBorder);
00975     return NOERROR;
00976     }
00977
00978
00979
00980
00981 /*
00982  * CFrame::RequestBorderSpace
00983  *
00984  * Purpose:
00985  *  Asks the container if it can surrender the amount of space
00986  *  in pBW that the object would like for it's adornments.  The
00987  *  container does nothing but validate the spaces on this call.
00988  *
00989  * Parameters:
00990  *  pBW             LPCBORDERWIDTHS containing the requested space.
00991  *                  The values are the amount of space requested
00992  *                  from each side of the relevant window.
00993  *
00994  * Return Value:
00995  *  HRESULT         NOERROR if we can give up space,
00996  *                  INPLACE_E_NOTOOLSPACE otherwise.
00997  */
00998
00999 STDMETHODIMP CFrame::RequestBorderSpace(LPCBORDERWIDTHS pBW)
01000     {
01001   UNREFERENCED_PARAMETER(pBW);
01002     //Framer has no border space restrictions
01003     return NOERROR;
01004     }
01005
01006
01007
01008
01009 /*
01010  * CFrame::SetBorderSpace
01011  *
01012  * Purpose:
01013  *  Called when the object now officially requests that the
01014  *  container surrender border space it previously allowed
01015  *  in RequestBorderSpace.  The container should resize windows
01016  *  appropriately to surrender this space.
01017  *
01018  * Parameters:
01019  *  pBW             LPCBORDERWIDTHS containing the amount of space
01020  *                  from each side of the relevant window that the
01021  *                  object is now reserving.
01022  *
01023  * Return Value:
01024  *  HRESULT         NOERROR
01025  */
01026
01027 STDMETHODIMP CFrame::SetBorderSpace(LPCBORDERWIDTHS pBW)
01028     {
01029     RECT            rc;
01030
01031     /*
01032      * Since we have no tools, we can accept anything the object sends
01033      * and must therefore adjust the client-area window accordingly.
01034      */
01035
01036     /*
01037      * If pBW is NULL, the object is not interested in tools, so we
01038      * don't have to do anything.  In either case we need to save
01039      * the toolspace allocations in order to resize the client window
01040      * correctly.
01041      */
01042     if (NULL==pBW)
01043         {
01044         if (!m_fOurMenuShowing)
01045             SetMenu(NULL, NULL, NULL);
01046
01047         SetRect(&m_bwIP, 0, 0, 0, 0);
01048         GetClientRect( m_hWnd, &rc );
01049         }
01050     else
01051         {
01052         GetClientRect(m_hWnd, &rc);
01053         rc.left  +=pBW->left;
01054         rc.right -=pBW->right;
01055         rc.top   +=pBW->top;
01056         rc.bottom-=pBW->bottom;
01057
01058         m_bwIP=*pBW;
01059         }
01060
01061   ResizeClientWindow(rc.left, rc.top, rc.right-rc.left
01062     , rc.bottom-rc.top);
01063
01064     return NOERROR;
01065     }
01066
01067
01068
01069
01070 /*
01071  * CFrame::SetActiveObject
01072  *
01073  * Purpose:
01074  *  Provides the container with the object's IOleInPlaceActiveObject
01075  *  pointer
01076  *
01077  * Parameters:
01078  *  pIIPActiveObj   LPOLEINPLACEACTIVEOBJECT of interest.
01079  *  pszObj          LPCOLESTR naming the object.  Not used.
01080  *
01081  * Return Value:
01082  *  HRESULT         NOERROR
01083  */
01084
01085 STDMETHODIMP CFrame::SetActiveObject
01086     (LPOLEINPLACEACTIVEOBJECT pIIPActiveObj, LPCOLESTR pszObj)
01087     {
01088   UNREFERENCED_PARAMETER(pszObj);
01089     if (NULL!=m_pIOleIPActiveObject)
01090         m_pIOleIPActiveObject->Release();
01091
01092     //NULLs m_pIOleIPActiveObject if pIIPActiveObj is NULL
01093     m_pIOleIPActiveObject=pIIPActiveObj;
01094
01095     if (NULL!=m_pIOleIPActiveObject)
01096         m_pIOleIPActiveObject->AddRef();
01097
01098   m_pIOleIPActiveObject->GetWindow(&m_hWndObj);
01099     return NOERROR;
01100     }
01101
01102
01103
01104
01105 /*
01106  * CFrame::InsertMenus
01107  *
01108  * Purpose:
01109  *  Instructs the container to place its in-place menu items where
01110  *  necessary in the given menu and to fill in elements 0, 2, and 4
01111  *  of the OLEMENUGROUPWIDTHS array to indicate how many top-level
01112  *  items are in each group.
01113  *
01114  * Parameters:
01115  *  hMenu           HMENU in which to add popups.
01116  *  pMGW            LPOLEMENUGROUPWIDTHS in which to store the
01117  *                  width of each container menu group.
01118  *
01119  * Return Value:
01120  *  HRESULT         NOERROR
01121  */
01122
01123 STDMETHODIMP CFrame::InsertMenus(HMENU hMenu
01124     , LPOLEMENUGROUPWIDTHS pMGW)
01125     {
01126   //Copy our File menu into the shared menu.
01127     InsertMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, (UINT_PTR)m_phMenu[0]
01128         , TEXT("&File"));
01129
01130     pMGW->width[0]=1;
01131     pMGW->width[2]=0;
01132     pMGW->width[4]=0;
01133
01134   /*
01135    * Add the special help menu which is the first item in
01136    * the m_hMenuHelp popup that's sitting around.
01137    */
01138   InsertMenu(hMenu, 1, MF_BYPOSITION | MF_POPUP
01139       , (UINT_PTR)m_hMenuHelp, TEXT("&Help"));
01140
01141   //Tell the object we added our Help menu
01142   pMGW->width[5]=1;
01143     return NOERROR;
01144     }
01145
01146
01147
01148
01149 /*
01150  * CFrame::SetMenu
01151  *
01152  * Purpose:
01153  *  Instructs the container to replace whatever menu it's currently
01154  *  using with the given menu and to call OleSetMenuDescritor so OLE
01155  *  knows to whom to dispatch messages.
01156  *
01157  * Parameters:
01158  *  hMenu           HMENU to show.
01159  *  hOLEMenu        HOLEMENU to the menu descriptor.
01160  *  hWndObj         HWND of the active object to which messages are
01161  *                  dispatched.
01162  *
01163  * Return Value:
01164  *  HRESULT         NOERROR
01165  */
01166
01167 STDMETHODIMP CFrame::SetMenu(HMENU hMenu, HOLEMENU hOLEMenu
01168     , HWND hWndObj)
01169     {
01170     HRESULT         hr;
01171
01172     /*
01173      * Our responsibilities here are to put the menu on the frame
01174      * window and call OleSetMenuDescriptor.
01175      */
01176
01177     if (NULL==hMenu)
01178         {
01179         //Prevent redundant calls, or debug warnings on startup.
01180         if (NULL==m_hMenuTop)
01181             return NOERROR;
01182
01183         hMenu=m_hMenuTop;
01184         m_hMenuTop=NULL;
01185         m_fOurMenuShowing=TRUE;
01186         }
01187     else
01188         {
01189         m_hMenuTop=m_hMenuOrg;
01190         m_fOurMenuShowing=FALSE;
01191
01192     /*
01193      * Check if our Help menu has anything added to it.  If so, then
01194      * remember to forward menu messages.  If not, remove the Help
01195      * menu altogether (destroying it after removing our normal Help
01196      * popup, as we also do in RemoveMenus.
01197      */
01198     if (CHELPITEMS!=GetMenuItemCount(m_hMenuHelp))
01199       m_fUsingOurHelp=TRUE;
01200     else
01201       {
01202       UINT  i, cItems;
01203
01204       cItems=GetMenuItemCount(hMenu);
01205
01206       //Find m_hMenuHelp in the menu and remove it.
01207       for (i=0; i < cItems; i++)
01208         {
01209         if (GetSubMenu(hMenu, i)==m_hMenuHelp)
01210           {
01211           RemoveMenu(hMenu, i, MF_BYPOSITION);
01212           break;
01213           }
01214         }
01215       }
01216         }
01217
01218     if (NULL!=hMenu)
01219         ::SetMenu(m_hWnd, hMenu);
01220
01221     DrawMenuBar(m_hWnd);
01222
01223     hr=OleSetMenuDescriptor(hOLEMenu, m_hWnd, hWndObj, NULL, NULL);
01224     return hr;
01225     }
01226
01227
01228
01229
01230 /*
01231  * CFrame::RemoveMenus
01232  *
01233  * Purpose:
01234  *  Asks the container to remove any menus it put into hMenu in
01235  *  InsertMenus.
01236  *
01237  * Parameters:
01238  *  hMenu           HMENU from which to remove the container's
01239  *                  items.
01240  *
01241  * Return Value:
01242  *  HRESULT         NOERROR
01243  */
01244
01245 STDMETHODIMP CFrame::RemoveMenus(HMENU hMenu)
01246     {
01247     int         cItems, i, j;
01248     HMENU       hMenuT;
01249
01250   /*
01251      * To be defensive, loop through this menu removing anything
01252      * we recognize (that is, anything in m_phMenu) just in case
01253      * the server didn't clean it up right.  At least we can
01254      * give ourselves the prophylactic benefit.
01255      */
01256
01257     if (NULL==hMenu)
01258         return NOERROR;
01259
01260     cItems=GetMenuItemCount(hMenu);
01261
01262     /*
01263      * Walk backwards down the menu.  For each popup, see if it
01264      * matches any other popup we know about, and if so, remove
01265      * it from the shared menu.
01266      */
01267     for (i=cItems; i >=0; i--)
01268         {
01269         hMenuT=GetSubMenu(hMenu, i);
01270
01271         for (j=0; j <= CMENUS; j++)
01272             {
01273       //Remove any owned popup, or our special help menu
01274             if (hMenuT==m_phMenu[j]
01275                 || (hMenuT==m_hMenuHelp && m_hMenuHelp!=NULL))
01276                 RemoveMenu(hMenu, i, MF_BYPOSITION);
01277             }
01278         }
01279
01280   m_fUsingOurHelp=FALSE;
01281
01282     //The menu should now be empty.
01283     return NOERROR;
01284     }
01285
01286
01287
01288
01289 /*
01290  * CFrame::SetStatusText
01291  *
01292  * Purpose:
01293  *  Asks the container to place some text in a status line, if one
01294  *  exists.  If the container does not have a status line it
01295  *  should return E_FAIL here in which case the object could
01296  *  display its own.
01297  *
01298  * Parameters:
01299  *  pszText         LPCOLESTR to display.
01300  *
01301  * Return Value:
01302  *  HRESULT         NOERROR if successful, S_TRUNCATED if not all
01303  *                  of the text could be displayed, or E_FAIL if
01304  *                  the container has no status line.
01305  */
01306
01307 STDMETHODIMP CFrame::SetStatusText(LPCOLESTR pszText)
01308     {
01309   UNREFERENCED_PARAMETER(pszText);
01310     //We have no status line...
01311     return E_NOTIMPL;
01312     }
01313
01314
01315
01316 /*
01317  * CFrame::EnableModeless
01318  *
01319  * Purpose:
01320  *  Instructs the container to show or hide any modeless popup
01321  *  windows that it may be using.
01322  *
01323  * Parameters:
01324  *  fEnable         BOOL indicating to enable/show the windows
01325  *                  (TRUE) or to hide them (FALSE).
01326  *
01327  * Return Value:
01328  *  HRESULT         NOERROR
01329  */
01330
01331 STDMETHODIMP CFrame::EnableModeless(BOOL fEnable)
01332     {
01333   UNREFERENCED_PARAMETER(fEnable);
01334     return NOERROR;
01335     }
01336
01337
01338
01339
01340 /*
01341  * CFrame::TranslateAccelerator
01342  *
01343  * Purpose:
01344  *  When dealing with an in-place object from an EXE server, this
01345  *  is called to give the container a chance to process accelerators
01346  *  after the server has looked at the message.
01347  *
01348  * Parameters:
01349  *  pMSG            LPMSG for the container to examine.
01350  *  wID             WORD the identifier in the container's
01351  *                  accelerator table (from IOleInPlaceSite
01352  *                  ::GetWindowContext) for this message (OLE does
01353  *                  some translation before calling).
01354  *
01355  * Return Value:
01356  *  HRESULT         NOERROR if the keystroke was used,
01357  *                  S_FALSE otherwise.
01358  */
01359
01360 STDMETHODIMP CFrame::TranslateAccelerator(LPMSG pMSG, WORD wID)
01361     {
01362   UNREFERENCED_PARAMETER(pMSG);
01363     /*
01364      * wID already has anything translated from m_hAccel for us,
01365      * so we can just check for the commands we want and process
01366      * them instead of calling TranslateAccelerator which would be
01367      * redundant and which also has a possibility of dispatching to
01368      * the wrong window.
01369      */
01370     if (IDM_ENTERCONTEXTHELP==wID || IDM_ESCAPECONTEXTHELP==wID)
01371         {
01372         //wID properly expands to 32-bits
01373         OnCommand(m_hWnd, (WPARAM)wID, 0L);
01374         return NOERROR;
01375         }
01376
01377     return S_FALSE;
01378     }
01379
01380
01381 /*
01382  * IOleCommandTarget methods, provided to make PowerPoint happy
01383  * with this frame.
01384  */
01385
01386 STDMETHODIMP CFrame::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds
01387     , OLECMD *prgCmds, OLECMDTEXT *pCmdText)
01388   {
01389   UNREFERENCED_PARAMETER(pguidCmdGroup);
01390   UNREFERENCED_PARAMETER(cCmds);
01391   UNREFERENCED_PARAMETER(prgCmds);
01392   UNREFERENCED_PARAMETER(pCmdText);
01393   return OLECMDERR_E_UNKNOWNGROUP;
01394   }
01395
01396 STDMETHODIMP CFrame::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvaIn, VARIANTARG *pvaOut)
01397   {
01398   UNREFERENCED_PARAMETER(pguidCmdGroup);
01399   UNREFERENCED_PARAMETER(nCmdID);
01400   UNREFERENCED_PARAMETER(nCmdexecopt);
01401   UNREFERENCED_PARAMETER(pvaIn);
01402   UNREFERENCED_PARAMETER(pvaOut);
01403   return OLECMDERR_E_UNKNOWNGROUP;
01404   }
01405
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/tapirecv/avifilewriter.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • tapirecv

avifilewriter.cpp

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1999 - 2000  Microsoft Corporation
00004
00005 Module Name:
00006
00007     AVIFileWriter.cpp
00008
00009 Abstract:
00010
00011     Implementation of CAVIFileWriter class
00012
00013 */
00014
00015
00016 #include "common.h"
00017 #include "AVIFileWriter.h"
00018
00019
00020 ///////////////////////////////////////////////////////////////////////////////
00021 //
00022 // CAVIFileWriter::CAVIFileWriter
00023 //
00024 ///////////////////////////////////////////////////////////////////////////////
00025
00026 CAVIFileWriter::CAVIFileWriter()
00027     :m_pAVIFile(NULL),
00028     m_pAudioStream(NULL),
00029     m_nSampleSize(0)
00030 {
00031
00032     LogMessage("CAVIFileWriter::CAVIFileWriter");
00033
00034 }
00035
00036
00037 ///////////////////////////////////////////////////////////////////////////////
00038 //
00039 // CAVIFileWriter::Initialize
00040 //
00041 // initialize avi library. attempt to create a file with the given name and
00042 // format.
00043 //
00044 // if file creation fails, subsequent calls to write will fail.
00045 //
00046 ///////////////////////////////////////////////////////////////////////////////
00047
00048 HRESULT CAVIFileWriter::Initialize(IN const CHAR *pszFileName,
00049                                    IN const WAVEFORMATEX &WaveFormat)
00050 {
00051
00052     HRESULT hr = S_OK;
00053
00054
00055     //
00056     // if initialization fails, the object's stream and file will be NULL, so
00057     // subsequent Write() calls will fail
00058     //
00059
00060
00061     //
00062     // would do a better argument checking in a real-life application
00063     //
00064
00065     _ASSERTE(pszFileName);
00066
00067
00068     //
00069     // log file name and requested wave format
00070     //
00071
00072
00073     LogMessage("CAVIFileWriter::Initialize started.");
00074
00075     LogMessage("    file [%s] ", pszFileName);
00076
00077     LogFormat(&WaveFormat);
00078
00079
00080     //
00081     // initialize avi file library.
00082     // when done with it, call AVIFileExit should be called on the same thread
00083     //
00084
00085     AVIFileInit();
00086
00087
00088     //
00089     // create file
00090     //
00091
00092     hr = AVIFileOpen(&m_pAVIFile,
00093                      pszFileName,
00094                      OF_WRITE | OF_CREATE | OF_SHARE_DENY_WRITE,
00095                      NULL);
00096
00097     if (FAILED(hr))
00098     {
00099         LogError("CAVIFileWriter::Initialize Failed to create file %s",
00100                  pszFileName);
00101
00102         m_pAVIFile = NULL;
00103
00104         return hr;
00105     }
00106
00107
00108     //
00109     // fill in stream information
00110     //
00111
00112     AVISTREAMINFO StreamInfo;
00113
00114     memset(&StreamInfo, 0, sizeof(StreamInfo));
00115
00116     StreamInfo.fccType = streamtypeAUDIO;
00117     StreamInfo.dwQuality = (DWORD)-1;
00118     m_nSampleSize = StreamInfo.dwSampleSize = WaveFormat.nBlockAlign;
00119
00120     // ignore the return code -- we will have a null-terminated string no
00121     // matter what.
00122     StringCbCopy(&StreamInfo.szName[0], 64, "test audio stream");
00123
00124
00125     //
00126     // add an audio stream to the file
00127     //
00128
00129     hr = AVIFileCreateStream(m_pAVIFile, &m_pAudioStream, &StreamInfo);
00130
00131     if (FAILED(hr))
00132     {
00133         LogError("CAVIFileWriter::CAVIFileWriter "
00134                  "failed to create audio stream");
00135
00136         AVIFileRelease(m_pAVIFile);
00137         m_pAVIFile = NULL;
00138
00139         return hr;
00140     }
00141
00142
00143     //
00144     // set format for the stream
00145     //
00146
00147     hr = AVIStreamSetFormat(m_pAudioStream,
00148                             0,
00149                             (void*)&WaveFormat,
00150                             sizeof(WaveFormat) + WaveFormat.cbSize);
00151
00152     if ( FAILED(hr))
00153     {
00154         LogError("Failed to set stream format");
00155
00156         AVIFileRelease(m_pAVIFile);
00157         m_pAVIFile = NULL;
00158
00159         AVIStreamRelease(m_pAudioStream);
00160         m_pAudioStream = NULL;
00161
00162         return hr;
00163     }
00164
00165     LogMessage("CAVIFileWriter::Initialize succeeded");
00166
00167     return S_OK;
00168
00169 }
00170
00171
00172 ///////////////////////////////////////////////////////////////////////////////
00173 //
00174 // CAVIFileWriter::~CAVIFileWriter
00175 //
00176 // if the file and stream were open, close them.
00177 //
00178 // uninitialize AVI library
00179 //
00180 ///////////////////////////////////////////////////////////////////////////////
00181
00182 CAVIFileWriter::~CAVIFileWriter()
00183 {
00184
00185     LogMessage("CAVIFileWriter::~CAVIFileWriter started");
00186
00187
00188     if (NULL != m_pAudioStream)
00189     {
00190         AVIStreamRelease(m_pAudioStream);
00191         m_pAudioStream = NULL;
00192     }
00193
00194
00195     if (NULL != m_pAVIFile)
00196     {
00197         AVIFileRelease(m_pAVIFile);
00198         m_pAVIFile = NULL;
00199     }
00200
00201
00202     //
00203     // uninitialize avi file libraries
00204     //
00205
00206     AVIFileExit();
00207
00208     LogMessage("CAVIFileWriter::~CAVIFileWriter finished");
00209
00210 }
00211
00212
00213 ///////////////////////////////////////////////////////////////////////////////
00214 //
00215 // CAVIFileWriter::Write
00216 //
00217 // write the buffer into the open stream. return the number of bytes recorded.
00218 //
00219 // return S_OK on success, error code on failure
00220 //
00221 ///////////////////////////////////////////////////////////////////////////////
00222
00223 HRESULT CAVIFileWriter::Write(IN BYTE *pBuffer,
00224                               IN ULONG nBytesToWrite,
00225                               IN OUT ULONG *pnBytesWritten)
00226 {
00227
00228     if ( (NULL == m_pAudioStream) || (NULL == m_pAVIFile))
00229     {
00230         LogError("CAVIFileWriter::Write file or stream is not open");
00231
00232         return E_UNEXPECTED;
00233     }
00234
00235
00236     //
00237     // AVIStreamWrite wants the number of samples we are recording
00238     //
00239
00240     LONG nSamples2Write = nBytesToWrite / m_nSampleSize;
00241
00242
00243     //
00244     // write to file until dumped the whole buffer of until failure
00245     //
00246
00247     HRESULT hr = S_OK;
00248
00249     ULONG nTotalBytesWritten = 0;
00250
00251
00252     while ((hr == S_OK) && (nTotalBytesWritten < nBytesToWrite))
00253     {
00254
00255         //
00256         // bytes and samples written with the call
00257         //
00258
00259         LONG nBytesWritten = 0;
00260
00261         LONG nSamplesWritten = 0;
00262
00263         hr = AVIStreamWrite(m_pAudioStream,
00264                             -1,              // append at the end of the stream
00265                             nSamples2Write,  // how many samples to write
00266                             pBuffer,         // where the data is
00267                             nBytesToWrite,   // how much data do we have
00268                             AVIIF_KEYFRAME,  // self-sufficient data
00269                             &nSamplesWritten,// how many samples were written
00270                             &nBytesWritten); // how many bytes were written
00271
00272
00273         //
00274         // keep track of how many bytes made it into the file
00275         //
00276
00277         nTotalBytesWritten += nBytesWritten;
00278
00279     }
00280
00281
00282     //
00283     // will return the number of bytes written
00284     //
00285
00286     if (NULL != pnBytesWritten)
00287     {
00288         *pnBytesWritten = nTotalBytesWritten;
00289     }
00290
00291
00292     //
00293     // either dumped the whole buffer or failed.
00294     //
00295
00296     if (FAILED(hr))
00297     {
00298
00299         LogError("CAVIFileWriter::Write Failed to write buffer hr = 0x%lx, "
00300                  "wrote %ld bytes", hr, nTotalBytesWritten);
00301     }
00302     else
00303     {
00304
00305         LogMessage("CAVIFileWriter::Write Succeeded. Wrote %ld bytes",
00306                     nTotalBytesWritten);
00307     }
00308
00309     return hr;
00310
00311 }
Generated on Wed Nov 13 2024 16:52:23 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/CutCopy/comp.h Source File

  • SysMgmt
  • MMC
  • CutCopy

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent, IResultOwnerData
00025 {
00026 private:
00027     ULONG       m_cref;
00028
00029     IConsole          *m_ipConsole;
00030
00031   class CComponentData *m_pParent;
00032     class CDelegationBase *m_pLastNode;
00033
00034     public:
00035         CComponent(CComponentData *pParent);
00036         ~CComponent();
00037
00038         ///////////////////////////////
00039         // Interface IUnknown
00040         ///////////////////////////////
00041         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042         STDMETHODIMP_(ULONG) AddRef();
00043         STDMETHODIMP_(ULONG) Release();
00044
00045         ///////////////////////////////
00046         // Interface IComponent
00047         ///////////////////////////////
00048         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00049             /* [in] */ LPCONSOLE lpConsole);
00050
00051             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00052             /* [in] */ LPDATAOBJECT lpDataObject,
00053             /* [in] */ MMC_NOTIFY_TYPE event,
00054             /* [in] */ LPARAM arg,
00055             /* [in] */ LPARAM param);
00056
00057             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00058             /* [in] */ MMC_COOKIE cookie);
00059
00060             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00061             /* [in] */ MMC_COOKIE cookie,
00062             /* [in] */ DATA_OBJECT_TYPES type,
00063             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00064
00065             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00066             /* [in] */ MMC_COOKIE cookie,
00067             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00068             /* [out] */ long __RPC_FAR *pViewOptions);
00069
00070             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00071             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00072
00073             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00074             /* [in] */ LPDATAOBJECT lpDataObjectA,
00075             /* [in] */ LPDATAOBJECT lpDataObjectB);
00076
00077         ///////////////////////////////
00078         // Interface IComponent
00079         ///////////////////////////////
00080             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE FindItem(
00081             /* [in] */ LPRESULTFINDINFO pFindInfo,
00082             /* [out] */ int __RPC_FAR *pnFoundIndex);
00083
00084             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CacheHint(
00085             /* [in] */ int nStartIndex,
00086             /* [in] */ int nEndIndex);
00087
00088             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SortItems(
00089             /* [in] */ int nColumn,
00090             /* [in] */ DWORD dwSortOptions,
00091             /* [in] */ LPARAM lUserParam);
00092 };
00093
00094 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/addvfiledlg.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

addvfiledlg.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013 //
00014 //  AddVFileDlg.cpp:  Implementation of the CAddVFileDlg class.
00015 //
00016
00017
00018
00019 #include "AddVFileDlg.h"
00020 #include "Globals.h"
00021 #include "Resource.h"        // Control IDs
00022 #include "BaseNode.h"        // NODE_PROPERTIES struct
00023
00024 /////////////////////////////////////////////////////////////////////////////
00025 //  Construction-Destruction
00026
00027 //---------------------------------------------------------------------------
00028 //
00029 CAddVFileDlg::CAddVFileDlg( ULONG nTemplate, HWND pParentWnd )
00030              : CBaseDialog( nTemplate )
00031 {
00032   _ASSERT( NULL != pParentWnd );
00033   m_hParentWnd = pParentWnd;
00034
00035 }
00036
00037 CAddVFileDlg::~CAddVFileDlg()
00038 {
00039 }
00040
00041 /////////////////////////////////////////////////////////////////////////////
00042 //  Message handlers
00043
00044
00045 //---------------------------------------------------------------------------
00046 LRESULT CAddVFileDlg::OnInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
00047 {
00048   LRESULT lResult = 0;
00049
00050   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00051   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00052   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00053   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00054   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00055
00056   lResult = SendMessage( hArchiveCtrl,  BM_SETCHECK, BST_UNCHECKED, 0 );
00057   lResult = SendMessage( hHiddenCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00058   lResult = SendMessage( hLockedCtrl,   BM_SETCHECK, BST_UNCHECKED, 0 );
00059   lResult = SendMessage( hReadOnlyCtrl, BM_SETCHECK, BST_UNCHECKED, 0 );
00060
00061   lResult = SetWindowText( hDevNameCtrl, _T("") );
00062   SetFocus( hDevNameCtrl );
00063
00064   return 0;
00065 }
00066
00067 //---------------------------------------------------------------------------
00068 LRESULT CAddVFileDlg::OnOK( HWND hDlg, WPARAM wParam, LPARAM lParam )
00069 {
00070   LRESULT          lResult = 0;
00071   NODE_PROPERTIES  NodeProps;
00072
00073   ZeroMemory( &NodeProps, sizeof(NODE_PROPERTIES) );
00074
00075   HWND hArchiveCtrl  = GetDlgItem( hDlg, IDC_ARCHIVE_ATTR  );
00076   HWND hHiddenCtrl   = GetDlgItem( hDlg, IDC_HIDDEN_ATTR   );
00077   HWND hLockedCtrl   = GetDlgItem( hDlg, IDC_LOCKED_ATTR   );
00078   HWND hReadOnlyCtrl = GetDlgItem( hDlg, IDC_READONLY_ATTR );
00079   HWND hDevNameCtrl  = GetDlgItem( hDlg, IDC_DEVNAME_EDIT  );
00080
00081   if( BST_CHECKED == SendMessage( hArchiveCtrl, BM_GETCHECK, 0, 0 ) )
00082     NodeProps.dwAttributes |= ATTRIBUTE_DATA_ARCHIVE;
00083
00084   if( BST_CHECKED == SendMessage( hHiddenCtrl, BM_GETCHECK, 0, 0 ) )
00085     NodeProps.dwAttributes |= ATTRIBUTE_DATA_HIDDEN;
00086
00087   if( BST_CHECKED == SendMessage( hLockedCtrl, BM_GETCHECK, 0, 0 ) )
00088     NodeProps.dwAttributes |= ATTRIBUTE_DATA_LOCKED;
00089
00090   if( BST_CHECKED == SendMessage( hReadOnlyCtrl, BM_GETCHECK, 0, 0 ) )
00091     NodeProps.dwAttributes |= ATTRIBUTE_DATA_READONLY;
00092
00093
00094   // Convert to wide characters here for all platforms.  This is the node name
00095   TCHAR szBuff[ MAX_NAME_LEN ] = {0};
00096   GetWindowText( hDevNameCtrl, szBuff, MAX_NAME_LEN );
00097   CopyT2W( NodeProps.szNodeName, szBuff, MAX_NAME_LEN);
00098   // Probably a good idea to check for NULL name strings here
00099
00100   // This message passes the user supplied info to the Static Node
00101   SendMessage( m_hParentWnd, WM_ADD_VIRTUALFILE, (WPARAM)&NodeProps, 0 );
00102
00103   // Now tell the static node we are deleting ourselves so the
00104   // context menu option can be enabled
00105   SendMessage( m_hParentWnd, WM_VIRTUALFILE_CLOSED, 0, 0 );
00106
00107   // Call the base class to shut down the dialog
00108   CBaseDialog::OnOK( hDlg, wParam, lParam );
00109   return 0;
00110 }
00111
00112 /////////////////////////////////////////////////////////////////////////////
00113 //  Virtual function implementations
00114
00115 //---------------------------------------------------------------------------
00116 BOOL CAddVFileDlg::ProcessMessage
00117 (
00118   HWND     hDlg,           //[in] Handle to dialog box
00119   UINT     uMsg,           //[in] Message
00120   WPARAM   wParam,         //[in] First message parameter
00121   LPARAM   lParam          //[in] Second message parameter
00122 )
00123 {
00124   LRESULT lResult = 0;
00125
00126   switch( uMsg )
00127   {
00128     case WM_INITDIALOG:
00129       lResult = OnInitDialog( hDlg, wParam, lParam );
00130       break;
00131
00132     case WM_DESTROY:
00133       lResult = OnDestroy( hDlg, wParam, lParam );
00134       break;
00135
00136     case WM_NCDESTROY:
00137       lResult = OnNcDestroy( hDlg, wParam, lParam );
00138       break;
00139
00140     case WM_CLOSE:
00141       // Not overriding WM_CLOSE and IDCANCEL so we must send
00142       // WM_DEVICENODE_CLOSED before calling the base class or else
00143       // the context menu will stay grayed
00144       SendMessage( m_hParentWnd, WM_VIRTUALFILE_CLOSED, 0, 0 );
00145       lResult = OnClose( hDlg, wParam, lParam );
00146       break;
00147
00148     case WM_COMMAND:
00149       switch( wParam )
00150       {
00151         case IDOK:
00152           lResult = OnOK( hDlg, wParam, lParam );
00153           break;
00154
00155         case IDCANCEL:
00156           SendMessage( m_hParentWnd, WM_VIRTUALFILE_CLOSED, 0, 0 );
00157           lResult = OnCancel( hDlg, wParam, lParam );
00158           break;
00159
00160         default:
00161           break;
00162       }
00163     default:
00164       break;
00165   }
00166   return (BOOL)lResult;
00167 }
00168
00169
00170
Generated on Wed Nov 13 2024 16:52:38 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/ATMEvent/ATMEvent.h Source File

  • NetDS
  • WinSock
  • ATMEvent

ATMEvent.h

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright (C) 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00007 //
00008 // Module:
00009 //      atmevent.h
00010 //
00011 // Abstract:
00012 //      Definitions and prototypes specific to this application
00013 //
00014 // Author:
00015 //      Barry R. Butterklee
00016 //
00017
00018 #ifndef ATMEVENT_H
00019 #define ATMEVENT_H
00020
00021
00022 #include <winsock2.h>
00023 #include <ws2atm.h>
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026
00027 #define Malloc(x) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x))
00028 #define Free(x) HeapFree(GetProcessHeap(),0,(x))
00029
00030
00031 // +1 included for string termination character
00032 #define MAX_ATM_INTERFACE_LEN 41
00033
00034 typedef enum
00035 {
00036     CMD_SENDER,
00037     CMD_RECEIVER,
00038     CMD_ENUMERATOR
00039 } CMD_TYPE;
00040
00041
00042 typedef struct _OPTIONS
00043 {
00044     CMD_TYPE        cmd;
00045     CHAR            szLocalInterface[MAX_ATM_INTERFACE_LEN];
00046     CHAR            szRemoteInterface[MAX_ATM_INTERFACE_LEN];
00047     int             nRepeat;
00048     CHAR            fillchar;
00049     int             nBufSize;
00050     CHAR *          buf;
00051     DWORD           dwSleep;
00052     DWORD           dwSleepClose;
00053     DWORD           dwTotalClients;
00054     WSAPROTOCOL_INFO protocolInfo;
00055 } OPTIONS;
00056
00057
00058
00059 extern VOID Receiver(
00060                     OPTIONS *pOptions);
00061
00062 extern VOID Sender(
00063                   OPTIONS *pOptions);
00064
00065 extern VOID Enumerator(
00066                       OPTIONS *pOptions);
00067
00068 extern void PrintQos(
00069                     QOS *qos,
00070                     CHAR *lpszIndent);
00071
00072 #endif
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDeskBand Member List

This is the complete list of members for CDeskBand, including all inherited members.
CDeskBand() | CDeskBand |
CloseDW(DWORD dwReserved) | CDeskBand |
ContextSensitiveHelp(BOOL) | CDeskBand |
FocusChange(BOOL) | CDeskBand | [private]
GetBandInfo(DWORD, DWORD, DESKBANDINFO *) | CDeskBand |
GetClassID(LPCLSID) | CDeskBand |
GetCommandString(UINT_PTR, UINT, LPUINT, LPSTR, UINT) | CDeskBand |
GetSite(REFIID, LPVOID *) | CDeskBand |
GetSizeMax(ULARGE_INTEGER *) | CDeskBand |
GetWindow(HWND *) | CDeskBand |
HasFocusIO(void) | CDeskBand |
InvokeCommand(LPCMINVOKECOMMANDINFO) | CDeskBand |
IsDirty(void) | CDeskBand |
Load(LPSTREAM) | CDeskBand |
m_bFocus | CDeskBand | [private]
m_dwBandID | CDeskBand | [private]
m_dwViewMode | CDeskBand | [private]
m_hWnd | CDeskBand | [private]
m_hwndParent | CDeskBand | [private]
m_ObjRefCount | CDeskBand | [protected]
m_pSite | CDeskBand | [private]
OnCommand(WPARAM wParam, LPARAM lParam) | CDeskBand | [private]
OnKillFocus(void) | CDeskBand | [private]
OnPaint(void) | CDeskBand | [private]
OnSetFocus(void) | CDeskBand | [private]
OnSize(LPARAM) | CDeskBand | [private]
QueryContextMenu(HMENU, UINT, UINT, UINT, UINT) | CDeskBand |
QueryInterface(REFIID, LPVOID *) | CDeskBand |
RegisterAndCreateWindow(void) | CDeskBand | [private]
ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) | CDeskBand |
Save(LPSTREAM, BOOL) | CDeskBand |
SetSite(IUnknown *) | CDeskBand |
ShowDW(BOOL fShow) | CDeskBand |
STDMETHODIMP_(DWORD) AddRef() | CDeskBand |
STDMETHODIMP_(DWORD) Release() | CDeskBand |
TranslateAcceleratorIO(LPMSG) | CDeskBand |
UIActivateIO(BOOL, LPMSG) | CDeskBand |
WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) | CDeskBand | [private, static]
~CDeskBand() | CDeskBand |
Generated on Wed Nov 13 2024 16:56:19 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

NIDeque_c< T > Member List

This is the complete list of members for NIDeque_c< T >, including all inherited members.
GetFromBack(T &data) | NIDeque_c< T > |
GetFromFront(T &data) | NIDeque_c< T > |
InsertIntoBack(T data) | NIDeque_c< T > |
InsertIntoFront(T data) | NIDeque_c< T > |
IsEmpty() | NIDeque_c< T > |
NIDeque_c() | NIDeque_c< T > |
NIDequeIter_c< T > class | NIDeque_c< T > | [friend]
RemoveFromBack(T &data) | NIDeque_c< T > |
RemoveFromFront(T &data) | NIDeque_c< T > |
Root | NIDeque_c< T > | [private]
Tail | NIDeque_c< T > | [private]
~NIDeque_c() | NIDeque_c< T > |
Generated on Wed Nov 13 2024 16:57:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Begin/sdkdiff/scandir.h Source File

  • Begin
  • sdkdiff

scandir.h

Go to the documentation of this file.
00001 /*
00002  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005  * PARTICULAR PURPOSE.
00006  *
00007  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
00008  */
00009
00010
00011 #ifndef __SCANDIR_H__
00012 #define __SCANDIR_H__
00013 /*
00014  *
00015  * scandir
00016  *
00017  *
00018  * scan a directory tree and build a sorted list of filenames within that
00019  * tree.
00020  *
00021  * the dir_buildlist function will scan the directories and files
00022  * and return DIRLIST handle.
00023  *
00024  * calls to dir_firstitem and dir_nextitem will traverse the files in the
00025  * listing in alphabetic order, returning a DIRITEM handle. This handle
00026  * can be queried for the associated filename, filesize and checksum.
00027  *
00028  * calls to dir_firstitem and dir_nextitem will only show files, not
00029  * directories, and will traverse the list in alphabetic order
00030  * within a directory, and contents of subdirectories in
00031  * alphabetic order within a directory. Within one directory, we traverse the
00032  * files before listing the contents of the subdirectories.
00033  *
00034  * if the bSum argument is true, we checksum each readable file during the
00035  * initial scan. If this is false, we will checksum the file on demand (during
00036  * the first call to  dir_getchecksum). if the file is not readable, the
00037  * checksum will be 0.
00038  *
00039  */
00040
00041  /* handle to the list of files scanned */
00042 typedef struct dirlist FAR * DIRLIST;
00043
00044 /* handle to one item within the list of files */
00045 typedef struct diritem FAR * DIRITEM;
00046
00047
00048 /*
00049  * scan the given directory for files, and return NULL if unsuccessful,
00050  * or a DIRLIST handle to the items if successful. If bSums is true,
00051  * checksum each file found.
00052  *
00053  * if pathname is not a directory, we return NULL. if it is a directory, but
00054  * contains no files, we return a valid handle to an empty list.
00055  *
00056  * If bOnDemand is TRUE, the list will scanned as necessary to fulfil
00057  * dir_firstitem/dir_nextitem requests. If this is false, the
00058  * list will be fully built before the dir_buildlist function returns.
00059  */
00060 DIRLIST dir_buildlist(LPSTR pathname, BOOL bSum, BOOL bOnDemand);
00061
00062 void dir_setotherdirlist(DIRLIST dl, DIRLIST otherdl);
00063
00064 /*
00065  * build/append a directory list.
00066  *
00067  * If bSums is true, checksum each file found.
00068  *
00069  * if pathname is not a directory, we add it to the list.
00070  * if it is a directory, it gets ignored.
00071  */
00072 BOOL dir_appendlist(DIRLIST *pdl, LPCSTR pathname, BOOL bSum, int *psequence);
00073
00074 /* call this to delete this list, all the items in it and all the
00075  * associated memory
00076  */
00077 void dir_delete(DIRLIST list);
00078
00079
00080 /* was this list built from a filename or a directory ? This function
00081  * will return TRUE if the initial argument to the dir_buildlist()
00082  * function.
00083  */
00084 BOOL dir_isfile(DIRLIST list);
00085
00086
00087 /* return the first file in the list in alphabetic order. will return
00088  * null if no files found
00089  */
00090 DIRITEM dir_firstitem(DIRLIST list);
00091
00092 /* return the next file in the list in alphabetic order, or null if no
00093  * more files
00094  */
00095 DIRITEM dir_nextitem(DIRLIST list, DIRITEM previtem, BOOL fDeep);
00096
00097 /*
00098  * Return a handle to the DIRLIST given a handle to the DIRITEM within it.
00099  *
00100  */
00101 DIRLIST dir_getlist(DIRITEM item);
00102
00103
00104 // get the name of this file, relative to the DIRLIST root.
00105 LPSTR dir_getrelname(DIRITEM item);
00106
00107 // get the absolute path to the dirlist root directory
00108 LPSTR dir_getrootpath(DIRLIST dl);
00109
00110 // get a description text for this dirlist
00111 LPSTR dir_getrootdescription(DIRLIST dl);
00112
00113 // set custom description (instead of using calculated one)
00114 void dir_setdescription(DIRLIST dl, LPCSTR psz);
00115
00116
00117
00118 /* free memory created by a previous call to dir_getrelname */
00119 void dir_freerelname(DIRITEM item, LPSTR relname);
00120
00121 /* free memory possibly created by a call to dir_getroot_*  */
00122 void dir_freerootpath(DIRLIST dl, LPSTR rootname);
00123 void dir_freerootdescription(DIRLIST dl, LPSTR rootname);
00124
00125 /*
00126  * get an open-able name for the file. This will be the same as the fullname.
00127  */
00128 LPSTR dir_getopenname(DIRITEM item);
00129
00130 /*
00131  * free up memory created by a call to dir_getopenname(). This *may*
00132  * cause the file to be deleted if it was a temporary copy.
00133  */
00134 void dir_freeopenname(DIRITEM item, LPSTR openname);
00135
00136
00137 /*
00138  * open the file and return a read-only handle to it.
00139  * close file using dir_closefile
00140  */
00141 HANDLE dir_openfile(DIRITEM item);
00142
00143 /*
00144  * close a file opened by dir_openfile. This *may* cause the file to be
00145  * deleted if it was a temporary local copy
00146  */
00147 void dir_closefile(DIRITEM item, HANDLE fh);
00148
00149
00150 /* return a checksum for this file. If one has not yet been calculated
00151  * for this file, open the file and calculate it.
00152  * if the file was unreadable, this returns 0.
00153  */
00154 DWORD dir_getchecksum(DIRITEM item);
00155
00156 /* Redo everything to do with checksums, size, etc */
00157 void dir_rescanfile(DIRITEM di);
00158
00159 /* return a TRUE iff item has a valid checksum */
00160 BOOL dir_validchecksum(DIRITEM item);
00161
00162 // return false if there is some error accessing this file
00163 BOOL dir_fileerror(DIRITEM item);
00164
00165 /* return the (lower 32 bits) of the file size, as scanned at the
00166  * call to dir_buildlist
00167  */
00168 long dir_getfilesize(DIRITEM item);
00169
00170 /* return the file attributes, as scanned at the call to dir_buildlist
00171  */
00172 DWORD dir_getattr(DIRITEM item);
00173
00174 /* MUST CALL dir_startcopy first and dir_endcopy after.
00175  * create a copy of the file, in the new root directory. creates sub-dirs as
00176  * necessary.
00177  *
00178  * returns TRUE for success and FALSE for failure.
00179  */
00180 BOOL dir_copy(DIRITEM item, LPSTR newroot, BOOL HitReadOnly, BOOL IgnoreAttributes);
00181
00182 /* Call this before starting copying */
00183 BOOL dir_startcopy(DIRLIST dl);
00184
00185
00186 /* call this after copying.  Negative retcode = number of bad files
00187    else retcode = number of file copied (all good).
00188 */
00189 int dir_endcopy(DIRLIST dl);
00190
00191 /* Build the real path from item and newroot into newpath.
00192  * Create directories as needed so that it is valid.
00193  */
00194 BOOL dir_MakeValidPath(LPSTR newpath, DIRITEM item, LPSTR newroot);
00195
00196 /*
00197  * useful routine exported for other users
00198  * returns TRUE if path is a valid directory
00199  */
00200 BOOL dir_isvaliddir(LPCSTR path);
00201
00202 /*
00203  * returns TRUE if the DIRLIST parameter has a wildcard specified
00204  */
00205 BOOL dir_iswildcard(DIRLIST);
00206
00207 /*
00208  * compares two relnames that are both based on wildcard DIRLISTs. if the
00209  * directories match, then the filenames are compared after removing
00210  * the fixed portion of the name - thus comparing only the
00211  * wildcard portion.
00212  */
00213 int dir_compwildcard(DIRLIST dleft, DIRLIST dright, LPSTR lname, LPSTR rname);
00214
00215 /*
00216  * compares two DIRITEMs, based on a sequence number rather than filenames.
00217  */
00218 BOOL dir_compsequencenumber(DIRITEM dleft, DIRITEM dright, int *pcmpvalue);
00219
00220 #ifndef WIN32
00221     /* FILETIME structure from WIN32 */
00222     typedef struct _FILETIME { /* ft */
00223         DWORD dwLowDateTime;
00224         DWORD dwHighDateTime;
00225     } FILETIME;
00226 #define CONST const
00227
00228 long CompareFileTime( CONST FILETIME * lpft1,  /* address of first file time */
00229                       CONST FILETIME * lpft2  /* address of second file time */
00230                     );
00231 #endif
00232
00233 /* return the file time (last write time) (set during scanning), (0,0) if invalid */
00234 FILETIME dir_GetFileTime(DIRITEM cur);
00235
00236 #endif
Generated on Wed Nov 13 2024 16:51:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Security/CertServices/Policy/C++/Windows2000/Atl.Cpp Source File

  • Security
  • CertServices
  • Policy
  • C++
  • Windows2000

Atl.Cpp

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1997 - 2000
00006 //
00007 //  File:       atl.cpp
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // stdafx.cpp: source file that includes just the standard includes
00012 // stdafx.pch will be the pre-compiled header
00013 // stdafx.obj will contain the pre-compiled type information
00014
00015 #include <pch.cpp>
00016
00017 #pragma hdrstop
00018
00019 #include <atlimpl.cpp>
Generated on Wed Nov 13 2024 16:52:28 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/networking/httpauth/httpauth.cpp Source File

  • Web
  • networking
  • httpauth

httpauth.cpp

Go to the documentation of this file.
00001 // ===========================================================================
00002 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 // PARTICULAR PURPOSE.
00006 //
00007 // Copyright 2000 Microsoft Corporation.  All Rights Reserved.
00008 // ===========================================================================
00009 #define STRSAFE_WITH_GETS
00010 #include <windows.h>
00011 #include <stdio.h>
00012 #include <fcntl.h>
00013 #include <io.h>
00014 #include <wininet.h>
00015 #include <strsafe.h>
00016
00017 //==============================================================================
00018 BOOL NeedAuth (HINTERNET hRequest)
00019 {
00020     // Get status code.
00021     DWORD dwStatus;
00022     DWORD cbStatus = sizeof(dwStatus);
00023     HttpQueryInfo
00024     (
00025         hRequest,
00026         HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_STATUS_CODE,
00027         &dwStatus,
00028         &cbStatus,
00029         NULL
00030     );
00031     fprintf (stderr, "Status: %d\n", dwStatus);
00032
00033     // Look for 401 or 407.
00034     DWORD dwFlags;
00035     switch (dwStatus)
00036     {
00037         case HTTP_STATUS_DENIED:
00038             dwFlags = HTTP_QUERY_WWW_AUTHENTICATE;
00039             break;
00040         case HTTP_STATUS_PROXY_AUTH_REQ:
00041             dwFlags = HTTP_QUERY_PROXY_AUTHENTICATE;
00042             break;
00043         default:
00044             return FALSE;
00045     }
00046
00047     // Enumerate the authentication types.
00048     BOOL fRet;
00049     char szScheme[64];
00050     DWORD dwIndex = 0;
00051     do
00052     {
00053         DWORD cbScheme = sizeof(szScheme);
00054         fRet = HttpQueryInfo
00055             (hRequest, dwFlags, szScheme, &cbScheme, &dwIndex);
00056         if (fRet)
00057             fprintf (stderr, "Found auth scheme: %s\n", szScheme);
00058     }
00059         while (fRet);
00060
00061     return TRUE;
00062 }
00063
00064
00065 //==============================================================================
00066 DWORD DoCustomUI (HINTERNET hConnect, HINTERNET hRequest)
00067 {
00068     // Prompt for username and password.
00069     char  szUser[64], szPass[64];
00070     fprintf (stderr, "Enter Username: ");
00071     if(FAILED(StringCchGetsA(szUser, 64)))
00072         return ERROR_INTERNET_LOGIN_FAILURE;
00073     fprintf (stderr, "Enter Password: ");
00074     if(FAILED(StringCchGetsA(szPass, 64)))
00075         return ERROR_INTERNET_LOGIN_FAILURE;
00076
00077     // Set the values in the handle.
00078     InternetSetOption
00079         (hConnect, INTERNET_OPTION_USERNAME, szUser, sizeof(szUser));
00080     InternetSetOption
00081         (hConnect, INTERNET_OPTION_PASSWORD, szPass, sizeof(szPass));
00082
00083     // Drain the socket.
00084     BYTE bBuf[1000];
00085     DWORD cbBuf = sizeof(bBuf);
00086     DWORD cbRead;
00087     while (InternetReadFile (hRequest, bBuf, cbBuf, &cbRead) && cbRead);
00088
00089     return ERROR_INTERNET_FORCE_RETRY;
00090 }
00091
00092
00093 //==============================================================================
00094 int main (int argc, char **argv)
00095 {
00096     HINTERNET hInternet = NULL;
00097     HINTERNET hConnect  = NULL;
00098     HINTERNET hRequest  = NULL;
00099     PSTR pszErr = NULL;
00100     BOOL fRet;
00101
00102 #define CHECK_ERROR(cond, err) if (!(cond)) {pszErr=(err); goto done;}
00103
00104     // Check usage.
00105     if (argc < 2)
00106     {
00107         fprintf (stderr, "Usage:   httpauth [-c] <server> [<object> [<user> [<pass>]]]\n");
00108         fprintf (stderr, "  -c: Use custom UI to prompt for user/pass");
00109         exit (1);
00110     }
00111
00112     // Parse arguments.
00113     BOOL fAllowCustomUI = FALSE;
00114     if (argc >= 2 && argv[1][0] == '-')
00115     {
00116         fAllowCustomUI = TRUE;
00117         argv++;
00118         argc--;
00119     }
00120     PSTR pszHost   = argv[1];
00121     PSTR pszObject = argc >= 3 ? argv[2] : "/";
00122     PSTR pszUser   = argc >= 4 ? argv[3] : NULL;
00123     PSTR pszPass   = argc >= 5 ? argv[4] : NULL;
00124
00125     // Initialize wininet.
00126     hInternet = InternetOpen
00127     (
00128         "HttpAuth Sample",            // app name
00129         INTERNET_OPEN_TYPE_PRECONFIG, // access type
00130         NULL,                         // proxy server
00131         0,                            // proxy port
00132         0                             // flags
00133     );
00134     CHECK_ERROR (hInternet, "InternetOpen");
00135
00136     // Connect to host.
00137     hConnect = InternetConnect
00138     (
00139         hInternet,                    // wininet handle,
00140         pszHost,                      // host
00141         0,                            // port
00142         pszUser,                      // user
00143         NULL,                         // pass
00144         INTERNET_SERVICE_HTTP,        // service
00145         0,                            // flags
00146         0                             // context
00147     );
00148     CHECK_ERROR (hConnect, "InternetConnect");
00149
00150     if (pszPass)
00151     {
00152         // Work around InternetConnect disallowing empty passwords.
00153         InternetSetOption (hConnect, INTERNET_OPTION_PASSWORD,
00154             pszPass, lstrlen(pszPass)+1);
00155     }
00156
00157     // Create request.
00158     hRequest = HttpOpenRequest
00159     (
00160         hConnect,                     // connect handle
00161         "GET",                        // request method
00162         pszObject,                    // object name
00163         NULL,                         // version
00164         NULL,                         // referrer
00165         NULL,                         // accept types
00166         INTERNET_FLAG_KEEP_CONNECTION // flags: keep-alive
00167              | INTERNET_FLAG_RELOAD,  // flags: bypass cache
00168         0                             // context
00169     );
00170     CHECK_ERROR (hRequest, "HttpOpenRequest");
00171
00172 resend:
00173
00174     // Send request.
00175     fRet = HttpSendRequest
00176     (
00177         hRequest,                     // request handle
00178         "",                           // header string
00179         0,                            // header length
00180         NULL,                         // post data
00181         0                             // post length
00182     );
00183
00184     // Handle any authentication dialogs.
00185     if (NeedAuth(hRequest) && fAllowCustomUI)
00186     {
00187         if (DoCustomUI (hConnect, hRequest) == ERROR_INTERNET_FORCE_RETRY)
00188             goto resend;
00189     }
00190     else
00191     {
00192         DWORD dwErr;
00193         dwErr = InternetErrorDlg
00194         (
00195             GetDesktopWindow(),
00196             hRequest,
00197             fRet ? ERROR_SUCCESS : GetLastError(),
00198             FLAGS_ERROR_UI_FILTER_FOR_ERRORS  |
00199                 FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS |
00200                 FLAGS_ERROR_UI_FLAGS_GENERATE_DATA,
00201             NULL
00202         );
00203
00204         if (dwErr == ERROR_INTERNET_FORCE_RETRY)
00205             goto resend;
00206     }
00207
00208     // Dump some bytes.
00209     BYTE bBuf[1024];
00210     DWORD cbBuf;
00211     DWORD cbRead;
00212     cbBuf = sizeof(bBuf);
00213     _setmode( _fileno( stdout ), _O_BINARY );
00214     while (InternetReadFile (hRequest, bBuf, cbBuf, &cbRead) && cbRead)
00215         fwrite (bBuf, 1, cbRead, stdout);
00216
00217 done: // Clean up.
00218
00219     if (pszErr)
00220         fprintf (stderr, "Failed on %s, last error %d\n", pszErr, GetLastError());
00221     if (hRequest)
00222         InternetCloseHandle (hRequest);
00223     if (hConnect)
00224         InternetCloseHandle (hConnect);
00225     if (hInternet)
00226         InternetCloseHandle (hInternet);
00227     return 0;
00228 }
00229
Generated on Wed Nov 13 2024 16:52:46 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

NIDequeIter_c< T > Member List

This is the complete list of members for NIDequeIter_c< T >, including all inherited members.
Back(T &data) | NIDequeIter_c< T > |
Current | NIDequeIter_c< T > | [private]
First(T &data) | NIDequeIter_c< T > |
GetCurrent() | NIDequeIter_c< T > | [inline, protected]
GetNIDeque() | NIDequeIter_c< T > | [inline, protected]
Initialize(NIDeque_c< T > &ANIDeque) | NIDequeIter_c< T > |
Last(T &data) | NIDequeIter_c< T > |
Next(T &data) | NIDequeIter_c< T > |
NIDeque | NIDequeIter_c< T > | [private]
NIDequeIter_c() | NIDequeIter_c< T > |
NIDequeIter_c(NIDeque_c< T > &ANIDeque) | NIDequeIter_c< T > |
Remove(T &data) | NIDequeIter_c< T > |
RemoveData(NILNode_c< T > *cptr, T &data) | NIDequeIter_c< T > | [private]
Replace(T &src, T chg) | NIDequeIter_c< T > |
~NIDequeIter_c() | NIDequeIter_c< T > |
Generated on Wed Nov 13 2024 16:57:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Security/VC/VCSecuritySampleCLASS.h Source File

  • Com
  • Services
  • Security
  • VC

VCSecuritySampleCLASS.h

Go to the documentation of this file.
00001 // VCSecuritySampleClass.h : Declaration of the CVCSecuritySampleClass
00002
00003 #ifndef __VCSECURITYSAMPLECLASS_H_
00004 #define __VCSECURITYSAMPLECLASS_H_
00005
00006 #include "resource.h"       // main symbols
00007
00008 /////////////////////////////////////////////////////////////////////////////
00009 // CVCSecuritySampleClass
00010 class ATL_NO_VTABLE CVCSecuritySampleClass :
00011   public CComObjectRootEx<CComSingleThreadModel>,
00012   public CComCoClass<CVCSecuritySampleClass, &CLSID_VCSecuritySampleClass>,
00013   public IDispatchImpl<IVCSecuritySampleClass, &IID_IVCSecuritySampleClass, &LIBID_VCSECURITYSAMPLELib>
00014 {
00015 public:
00016   CVCSecuritySampleClass()
00017   {
00018   }
00019
00020 DECLARE_REGISTRY_RESOURCEID(IDR_VCSECURITYSAMPLECLASS)
00021
00022 BEGIN_COM_MAP(CVCSecuritySampleClass)
00023   COM_INTERFACE_ENTRY(IVCSecuritySampleClass)
00024   COM_INTERFACE_ENTRY(IDispatch)
00025 END_COM_MAP()
00026
00027 // IVCSecuritySampleClass
00028 public:
00029   STDMETHOD(WhoAmI)(/*[out, retval]*/ BSTR*);
00030   STDMETHOD(AmIAnAdministrator)(/*[out, retval]*/ short*);
00031 };
00032
00033 #endif //__VCSECURITYSAMPLECLASS_H_
Generated on Wed Nov 13 2024 16:51:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CPaintCanvas Member List

This is the complete list of members for CPaintCanvas, including all inherited members.
_hdc | CCanvas | [protected]
_hwnd | CPaintCanvas | [protected]
_paint | CPaintCanvas | [protected]
CCanvas() | CCanvas | [inline]
Char(int x, int y, TCHAR ch) | CCanvas | [inline]
Circle(int x, int y, int r) | CCanvas | [inline]
Clear(RECT &rect) | CCanvas | [inline]
CPaintCanvas(HWND hwnd) | CPaintCanvas | [inline]
DPtoLP(LPPOINT lppt) | CCanvas | [inline]
GetRect() | CPaintCanvas | [inline]
Init(HDC hdc) | CCanvas | [inline, protected]
Line(COORD x1, COORD y1, COORD x2, COORD y2) | CCanvas | [inline]
LPtoDP(LPPOINT lppt) | CCanvas | [inline]
operator HDC() | CCanvas | [inline]
RCText(LPRECT lprc, LPTSTR buf, int cBuf) | CCanvas | [inline]
Scale(UINT iScale) | CCanvas | [inline]
Scroll(int dx, int dy) | CCanvas | [inline]
Text(int x, int y, LPTSTR buf, int cBuf) | CCanvas | [inline]
TextAlign(WORD aligntype) | CCanvas | [inline]
~CPaintCanvas() | CPaintCanvas | [inline]
Generated on Wed Nov 13 2024 16:57:02 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/WMI/about.h Source File

  • SysMgmt
  • MMC
  • WMI

about.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPABOUT_H_
00020 #define _SAMPABOUT_H_
00021
00022 #include <tchar.h>
00023 #include <mmc.h>
00024
00025 class CSnapinAbout : public ISnapinAbout
00026 {
00027 private:
00028     ULONG       m_cref;
00029     HBITMAP       m_hSmallImage;
00030     HBITMAP       m_hLargeImage;
00031     HBITMAP       m_hSmallImageOpen;
00032     HICON       m_hAppIcon;
00033
00034 public:
00035     CSnapinAbout();
00036     ~CSnapinAbout();
00037
00038     ///////////////////////////////
00039     // Interface IUnknown
00040     ///////////////////////////////
00041     STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00042     STDMETHODIMP_(ULONG) AddRef();
00043     STDMETHODIMP_(ULONG) Release();
00044
00045     ///////////////////////////////
00046     // Interface ISnapinAbout
00047     ///////////////////////////////
00048     STDMETHODIMP GetSnapinDescription(
00049         /* [out] */ LPOLESTR *lpDescription);
00050
00051         STDMETHODIMP GetProvider(
00052         /* [out] */ LPOLESTR *lpName);
00053
00054         STDMETHODIMP GetSnapinVersion(
00055         /* [out] */ LPOLESTR *lpVersion);
00056
00057         STDMETHODIMP GetSnapinImage(
00058         /* [out] */ HICON *hAppIcon);
00059
00060         STDMETHODIMP GetStaticFolderImage(
00061         /* [out] */ HBITMAP *hSmallImage,
00062         /* [out] */ HBITMAP *hSmallImageOpen,
00063         /* [out] */ HBITMAP *hLargeImage,
00064         /* [out] */ COLORREF *cMask);
00065
00066         ///////////////////////////////
00067         // Private Interface
00068         ///////////////////////////////
00069 private:
00070     HRESULT CSnapinAbout::AllocOleStr(
00071         LPOLESTR *lpDest,
00072         _TCHAR *szBuffer);
00073 };
00074
00075 #endif _SAMPABOUT_H_
Generated on Wed Nov 13 2024 16:51:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/Fonts/FontView/FontView.h Source File

  • Multimedia
  • Gdi
  • Fonts
  • FontView

FontView.h

Go to the documentation of this file.
00001
00002 /******************************************************************************\
00003 *       This is a part of the Microsoft Source Code Samples.
00004 *       Copyright 1993 - 2000 Microsoft Corporation.
00005 *       All rights reserved.
00006 *       This source code is only intended as a supplement to
00007 *       Microsoft Development Tools and/or WinHelp documentation.
00008 *       See these sources for detailed information regarding the
00009 *       Microsoft samples programs.
00010 \******************************************************************************/
00011
00012 #define IDM_SYSMENU  666
00013
00014 #define IDM_FILE        100
00015 #define IDM_NEW             IDM_FILE+1
00016 #define IDM_OPEN            IDM_FILE+2
00017 #define IDM_CLOSE           IDM_FILE+3
00018 #define IDM_SAVE            IDM_FILE+4
00019 #define IDM_SAVEAS          IDM_FILE+5
00020 #define IDM_PRINT           IDM_FILE+6
00021 #define IDM_PRINTSET        IDM_FILE+7
00022 #define IDM_EXIT            IDM_FILE+8
00023
00024 #define IDM_EDIT        110
00025 #define IDM_UNDO            IDM_EDIT+1
00026 #define IDM_CUT             IDM_EDIT+2
00027 #define IDM_COPY            IDM_EDIT+3
00028 #define IDM_PASTE           IDM_EDIT+4
00029 #define IDM_DELETE          IDM_EDIT+5
00030 #define IDM_FIND            IDM_EDIT+6
00031 #define IDM_REPLACE         IDM_EDIT+7
00032
00033 #define IDM_VIEW        120
00034 #define IDM_CHARSET         IDM_VIEW+1
00035 #define IDM_GLYPH           IDM_VIEW+2
00036 #define IDM_TOOLBAR         IDM_VIEW+3
00037 #define IDM_STATUSBAR       IDM_VIEW+4
00038
00039 #define IDM_DIALOG        130
00040 #define IDM_CREATEFONT      IDM_DIALOG+1
00041 #define IDM_TEXTMETRIC      IDM_DIALOG+2
00042 #define IDM_ENUMFONTS       IDM_DIALOG+3
00043 #define IDM_OUTLINEMETRICS  IDM_DIALOG+4
00044
00045 #define IDM_HELP        140
00046 #define IDM_HELP_CONTENTS   IDM_HELP+1
00047 #define IDM_HELP_INDEX      IDM_HELP+2
00048 #define IDM_HELP_OVERVIEW   IDM_HELP+3
00049 #define IDM_HELP_GLOSSARY   IDM_HELP+4
00050 #define IDM_HELP_TUTORIAL   IDM_HELP+5
00051 #define IDM_HELP_DEMO       IDM_HELP+6
00052 #define IDM_HELP_HELP       IDM_HELP+7
00053 #define IDM_ABOUT           IDM_HELP+8
00054
00055 #define ID_TOOLBAR      150
00056 #define ID_CREATEPARAM      ID_TOOLBAR+1
00057 #define ID_CREATEVALUE      ID_TOOLBAR+2
00058 #define ID_ZOOM                         ID_TOOLBAR+3
00059
00060 #define ID_STATUSBAR    160
00061 #define ID_MENUFIELD        ID_STATUSBAR+1
00062 #define ID_TIMEFIELD        ID_STATUSBAR+2
00063 #define ID_NUMFIELD         ID_STATUSBAR+3
00064 #define ID_OVRFIELD         ID_STATUSBAR+4
00065 #define ID_SCROLLFIELD      ID_STATUSBAR+5
00066 #define ID_CAPSFIELD        ID_STATUSBAR+6
00067
00068 #define CFP_BASE        200
00069 #define CFP_HEIGHT          CFP_BASE+0
00070 #define CFP_WIDTH           CFP_BASE+1
00071 #define CFP_ESCAPEMENT      CFP_BASE+2
00072 #define CFP_ORIENTATION     CFP_BASE+3
00073 #define CFP_WEIGHT          CFP_BASE+4
00074 #define CFP_ITALIC          CFP_BASE+5
00075 #define CFP_UNDERLINE       CFP_BASE+6
00076 #define CFP_STRIKEOUT       CFP_BASE+7
00077 #define CFP_CHARSET         CFP_BASE+8
00078 #define CFP_OUTPUTPRECISION CFP_BASE+9
00079 #define CFP_CLIPPRECISION   CFP_BASE+10
00080 #define CFP_QUALITY         CFP_BASE+11
00081 #define CFP_PITCH           CFP_BASE+12
00082 #define CFP_FAMILY          CFP_BASE+13
00083 #define CFP_FACENAME        CFP_BASE+14
00084
00085 #define CFD_BASE        220
00086 #define CFD_HEIGHT          CFD_BASE+0
00087 #define CFD_WIDTH           CFD_BASE+1
00088 #define CFD_ESCAPEMENT      CFD_BASE+2
00089 #define CFD_ORIENTATION     CFD_BASE+3
00090 #define CFD_WEIGHT          CFD_BASE+4
00091 #define CFD_ITALIC          CFD_BASE+5
00092 #define CFD_UNDERLINE       CFD_BASE+6
00093 #define CFD_STRIKEOUT       CFD_BASE+7
00094 #define CFD_CHARSET         CFD_BASE+8
00095 #define CFD_OUTPUTPRECISION CFD_BASE+9
00096 #define CFD_CLIPPRECISION   CFD_BASE+10
00097 #define CFD_QUALITY         CFD_BASE+11
00098 #define CFD_PITCHANDFAMILY  CFD_BASE+12
00099 #define CFD_FACENAME        CFD_BASE+13
00100
00101 #define CFD_DEFAULT         CFD_BASE+14
00102
00103 #define TMD_BASE        240
00104 #define TMD_HEIGHT          TMD_BASE+0
00105 #define TMD_ASCENT          TMD_BASE+1
00106 #define TMD_DESCENT         TMD_BASE+2
00107 #define TMD_INTERNAL        TMD_BASE+3
00108 #define TMD_EXTERNAL        TMD_BASE+4
00109 #define TMD_AVEWIDTH        TMD_BASE+5
00110 #define TMD_MAXWIDTH        TMD_BASE+6
00111 #define TMD_WEIGHT          TMD_BASE+7
00112 #define TMD_ITALIC          TMD_BASE+8
00113 #define TMD_UNDERLINE       TMD_BASE+9
00114 #define TMD_STRUCKOUT       TMD_BASE+10
00115 #define TMD_FIRSTCHAR       TMD_BASE+11
00116 #define TMD_LASTCHAR        TMD_BASE+12
00117 #define TMD_DEFAULTCHAR     TMD_BASE+13
00118 #define TMD_BREAKCHAR       TMD_BASE+14
00119 #define TMD_PITCHANDFAMILY  TMD_BASE+15
00120 #define TMD_CHARSET         TMD_BASE+16
00121 #define TMD_OVERHANG        TMD_BASE+17
00122 #define TMD_DIGITIZEDASPECTX TMD_BASE+18
00123 #define TMD_DIGITIZEDASPECTY TMD_BASE+19
00124
00125 #define TMD_SET             TMD_BASE+20
00126
00127
00128 #define ED_BASE         260
00129 #define ED_PREV             ED_BASE+0
00130 #define ED_NEXT             ED_BASE+1
00131 #define ED_TYPE             ED_BASE+2
00132 #define ED_SET              ED_BASE+3
00133 #define ED_HEX              ED_BASE+4
00134 #define ED_SAMPLE           ED_BASE+5
Generated on Wed Nov 13 2024 16:52:12 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/PrintJob/resource.h Source File

  • Multimedia
  • Gdi
  • PrintJob

resource.h

Go to the documentation of this file.
00001 //{{NO_DEPENDENCIES}}
00002 // Microsoft Developer Studio generated include file.
00003 // Used by PrintJob.rc
00004 //
00005 #define IDS_COLUMN1                     1
00006 #define IDS_COLUMN2                     2
00007 #define IDS_COLUMN3                     3
00008 #define IDS_COLUMN4                     4
00009 #define IDS_COLUMN5                     5
00010 #define IDS_COLUMN6                     6
00011 #define IDR_PRINTJOB                    101
00012 #define IDI_APP                         102
00013 #define IDD_ABOUTBOX                    103
00014 #define IDD_SELECTPRINTER               106
00015 #define IDR_COLUMNWIDTHS                109
00016 #define IDR_COLUMNCOUNT                 111
00017 #define IDC_FILEDESCRIPTION             1000
00018 #define IDC_PRODUCTVERSION              1001
00019 #define IDC_LEGALCOPYRIGHT              1002
00020 #define IDC_COMPANYNAME                 1003
00021 #define IDC_LEGALTRADEMARKS             1004
00022 #define IDC_EDITSELECTPRINTER           1005
00023 #define IDC_LISTVIEW                    1006
00024 #define IDM_NEW                         40001
00025 #define IDM_OPEN                        40002
00026 #define IDM_SAVE                        40003
00027 #define IDM_SAVEAS                      40004
00028 #define IDM_PRINT                       40005
00029 #define IDM_PRINTSETUP                  40006
00030 #define IDM_EXIT                        40007
00031 #define IDM_UNDO                        40008
00032 #define IDM_CUT                         40009
00033 #define IDM_COPY                        40010
00034 #define IDM_PASTE                       40011
00035 #define IDM_LINK                        40012
00036 #define IDM_LINKS                       40013
00037 #define IDM_HELPCONTENTS                40014
00038 #define IDM_HELPSEARCH                  40015
00039 #define IDM_HELPHELP                    40016
00040 #define IDM_ABOUT                       40017
00041 #define ID_FILE_REFRESH                 40018
00042 #define IDM_SELECTPRINTER               40019
00043 #define IDM_PRINTERNOTIFICATION         40020
00044 #define IDC_STATIC                      -1
00045
00046 // Next default values for new objects
00047 //
00048 #ifdef APSTUDIO_INVOKED
00049 #ifndef APSTUDIO_READONLY_SYMBOLS
00050 #define _APS_NO_MFC                     1
00051 #define _APS_NEXT_RESOURCE_VALUE        113
00052 #define _APS_NEXT_COMMAND_VALUE         40021
00053 #define _APS_NEXT_CONTROL_VALUE         1007
00054 #define _APS_NEXT_SYMED_VALUE           104
00055 #endif
00056 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/LocServe/CAR.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • LocServe

CAR.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      CAR.CPP
00003
00004   Summary:   Implementation file for the COCar COM Object Class (for
00005              aggregatable Car COM Objects).
00006
00007              COCar offers a main IUnknown interface and the ICar
00008              interface (Car-related features).  This multiple interface
00009              COM Object Class is achieved via the technique of nested
00010              classes.  The implementation of the ICar interface is
00011              nested inside of the COCar Class.
00012
00013              For a comprehensive tutorial code tour of this module's
00014              contents and offerings see the tutorial LOCSERVE.HTM file.
00015              For more specific technical details on the internal workings
00016              see the comments dispersed throughout the module's source code.
00017
00018   Classes:   COCar.
00019
00020   Functions: none.
00021
00022   Origin:    11-14-95: atrent - Editor-inheritance from CAR.CPP in
00023                the DLLSERVE Tutorial Code Sample.
00024
00025 ----------------------------------------------------------------------------
00026   This file is part of the Microsoft COM Tutorial Code Samples.
00027
00028   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00029
00030   This source code is intended only as a supplement to Microsoft
00031   Development Tools and/or on-line documentation.  See these other
00032   materials for detailed information regarding Microsoft code samples.
00033
00034   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00035   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00036   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00037   PARTICULAR PURPOSE.
00038 ==========================================================================+*/
00039
00040
00041 /*---------------------------------------------------------------------------
00042   We include WINDOWS.H for all Win32 applications.
00043   We include OLE2.H because we will be calling the COM/OLE Libraries.
00044   We include APPUTIL.H because we will be building this application using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include MICARS.H and CARGUIDS.H for the common car-related Interface
00048     class, GUID, and CLSID specifications.
00049   We include SERVER.H because it has internal class declarations and
00050     resource ID definitions specific for this executable.
00051   We include CAR.H because it has the class COCar declarations.
00052 ---------------------------------------------------------------------------*/
00053 #include <windows.h>
00054 #include <ole2.h>
00055 #include <apputil.h>
00056 #include <micars.h>
00057 #include <carguids.h>
00058 #include "server.h"
00059 #include "car.h"
00060
00061
00062 /*---------------------------------------------------------------------------
00063   COCar's implementation of its main COM object class including
00064   Constructor, Destructor, QueryInterface, AddRef, and Release.
00065 ---------------------------------------------------------------------------*/
00066
00067 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00068   Method:   COCar::COCar
00069
00070   Summary:  COCar Constructor. Note the member initializer:
00071             "m_ImpICar(this, pUnkOuter)" which is used to pass the 'this'
00072             and pUnkOuter pointers of this constructor function to the
00073             constructor in the instantiation of the implementation of
00074             the CImpICar interface (which is nested inside this present
00075             COCar Object Class).
00076
00077   Args:     IUnknown* pUnkOuter,
00078               Pointer to the the outer Unknown.  NULL means this COM Object
00079               is not being Aggregated.  Non NULL means it is being created
00080               on behalf of an outside COM object that is reusing it via
00081               aggregation.
00082             CServer* pServer)
00083               Pointer to the server's control object.
00084
00085   Modifies: m_cRefs, m_pUnkOuter, m_pServer.
00086
00087   Returns:  void
00088 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00089 COCar::COCar(
00090   IUnknown* pUnkOuter,
00091   CServer* pServer) :
00092   m_ImpICar(this, pUnkOuter)
00093 {
00094   // Zero the COM object's reference count.
00095   m_cRefs = 0;
00096
00097   // No AddRef necessary if non-NULL, as we're nested.
00098   m_pUnkOuter = pUnkOuter;
00099
00100   // Assign the pointer to the server control object.
00101   m_pServer = pServer;
00102
00103   LOGF1("L: COCar Constructor. m_pUnkOuter=0x%X.", m_pUnkOuter);
00104
00105   return;
00106 }
00107
00108
00109 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00110   Method:   COCar::~COCar
00111
00112   Summary:  COCar Destructor.
00113
00114   Args:     void
00115
00116   Modifies: .
00117
00118   Returns:  void
00119 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00120 COCar::~COCar(void)
00121 {
00122   LOG("L: COCar::Destructor.");
00123
00124   return;
00125 }
00126
00127
00128 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00129   Method:   COCar::QueryInterface
00130
00131   Summary:  QueryInterface of the COCar non-delegating
00132             IUnknown implementation.
00133
00134   Args:     REFIID riid,
00135               [in] GUID of the Interface being requested.
00136             PPVOID ppv)
00137               [out] Address of the caller's pointer variable that will
00138               receive the requested interface pointer.
00139
00140   Modifies: .
00141
00142   Returns:  HRESULT
00143 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00144 STDMETHODIMP COCar::QueryInterface(
00145                REFIID riid,
00146                PPVOID ppv)
00147 {
00148   HRESULT hr = E_NOINTERFACE;
00149   *ppv = NULL;
00150
00151   if (IID_IUnknown == riid)
00152   {
00153     *ppv = this;
00154     LOG("L: COCar::QueryInterface. 'this' pIUnknown returned.");
00155   }
00156   else if (IID_ICar == riid)
00157   {
00158     *ppv = &m_ImpICar;
00159     LOG("L: COCar::QueryInterface. pICar returned.");
00160   }
00161
00162   if (NULL != *ppv)
00163   {
00164     // We've handed out a pointer to the interface so obey the COM rules
00165     //   and AddRef the reference count.
00166     ((LPUNKNOWN)*ppv)->AddRef();
00167     hr = NOERROR;
00168   }
00169
00170   return (hr);
00171 }
00172
00173
00174 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00175   Method:   COCar::AddRef
00176
00177   Summary:  AddRef of the COCar non-delegating IUnknown implementation.
00178
00179   Args:     void
00180
00181   Modifies: m_cRefs.
00182
00183   Returns:  ULONG
00184               New value of m_cRefs (COM object's reference count).
00185 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00186 STDMETHODIMP_(ULONG) COCar::AddRef(void)
00187 {
00188   m_cRefs++;
00189
00190   LOGF1("L: COCar::AddRef. New cRefs=%i.", m_cRefs);
00191
00192   return m_cRefs;
00193 }
00194
00195
00196 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00197   Method:   COCar::Release
00198
00199   Summary:  Release of the COCar non-delegating IUnknown implementation.
00200
00201   Args:     void
00202
00203   Modifies: m_cRefs.
00204
00205   Returns:  ULONG
00206               New value of m_cRefs (COM object's reference count).
00207 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00208 STDMETHODIMP_(ULONG) COCar::Release(void)
00209 {
00210   ULONG cRefs;
00211   m_cRefs--;
00212   cRefs = m_cRefs;
00213
00214   LOGF1("L: COCar::Release. New cRefs=%i.", m_cRefs);
00215
00216   if (0 == m_cRefs)
00217   {
00218     CServer* pServer = m_pServer;
00219     // We artificially bump the main ref count to prevent reentrancy
00220     // via the main object destructor.  Not really needed in this
00221     // COCar but a good practice because we are aggregatable and
00222     // may at some point in the future add something entertaining like
00223     // some Releases to the COCar destructor.
00224     m_cRefs++;
00225     delete this;
00226
00227     // We've reached a zero reference count for this COM object.
00228     // So we tell the server housing to decrement its global object
00229     // count so that the server will be unloaded if appropriate.
00230     if (NULL != pServer)
00231       pServer->ObjectsDown();
00232   }
00233
00234   return cRefs;
00235 }
00236
00237
00238 /*---------------------------------------------------------------------------
00239   COCar's nested implementation of the ICar interface including
00240   Constructor, Destructor, QueryInterface, AddRef, Release,
00241   Shift, Clutch, Speed, and Steer.
00242 ---------------------------------------------------------------------------*/
00243
00244 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00245   Method:   COCar::CImpICar::CImpICar
00246
00247   Summary:  Constructor for the CImpICar interface instantiation.
00248
00249   Args:     COCar* pBackObj,
00250               Back pointer to the parent outer object.
00251             IUnknown* pUnkOuter
00252               Pointer to the outer Unknown.  For delegation.
00253
00254   Modifies: m_cRefI, m_pBackObj, m_pUnkOuter.
00255
00256   Returns:  void
00257 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00258 COCar::CImpICar::CImpICar(
00259   COCar* pBackObj,
00260   IUnknown* pUnkOuter)
00261 {
00262   // Init the Interface Ref Count (used for debugging only).
00263   m_cRefI = 0;
00264
00265   // Init the Back Object Pointer to point to the parent object.
00266   m_pBackObj = pBackObj;
00267
00268   // Init the CImpICar interface's delegating Unknown pointer.  We use
00269   // the Back Object pointer for IUnknown delegation here if we are not
00270   // being aggregated.  If we are being aggregated we use the supplied
00271   // pUnkOuter for IUnknown delegation.  In either case the pointer
00272   // assignment requires no AddRef because the CImpICar lifetime is
00273   // quaranteed by the lifetime of the parent object in which
00274   // CImpICar is nested.
00275   if (NULL == pUnkOuter)
00276   {
00277     m_pUnkOuter = pBackObj;
00278     LOG("L: COCar::CImpICar Constructor. Non-Aggregating.");
00279   }
00280   else
00281   {
00282     m_pUnkOuter = pUnkOuter;
00283     LOG("L: COCar::CImpICar Constructor. Aggregating.");
00284   }
00285
00286   return;
00287 }
00288
00289
00290 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00291   Method:   COCar::CImpICar::~CImpICar
00292
00293   Summary:  Destructor for the CImpICar interface instantiation.
00294
00295   Args:     void
00296
00297   Modifies: .
00298
00299   Returns:  void
00300 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00301 COCar::CImpICar::~CImpICar(void)
00302 {
00303   LOG("L: COCar::CImpICar Destructor.");
00304
00305   return;
00306 }
00307
00308
00309 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00310   Method:   COCar::CImpICar::QueryInterface
00311
00312   Summary:  The QueryInterface IUnknown member of this ICar interface
00313             implementation that delegates to m_pUnkOuter, whatever it is.
00314
00315   Args:     REFIID riid,
00316               [in] GUID of the Interface being requested.
00317             PPVOID ppv)
00318               [out] Address of the caller's pointer variable that will
00319               receive the requested interface pointer.
00320
00321   Modifies: .
00322
00323   Returns:  HRESULT
00324               Returned by the delegated outer QueryInterface call.
00325 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00326 STDMETHODIMP COCar::CImpICar::QueryInterface(
00327                REFIID riid,
00328                PPVOID ppv)
00329 {
00330   LOG("L: COCar::CImpICar::QueryInterface. Delegating.");
00331
00332   // Delegate this call to the outer object's QueryInterface.
00333   return m_pUnkOuter->QueryInterface(riid, ppv);
00334 }
00335
00336
00337 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00338   Method:   COCar::CImpICar::AddRef
00339
00340   Summary:  The AddRef IUnknown member of this ICar interface
00341             implementation that delegates to m_pUnkOuter, whatever it is.
00342
00343   Args:     void
00344
00345   Modifies: m_cRefI.
00346
00347   Returns:  ULONG
00348               Returned by the delegated outer AddRef call.
00349 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00350 STDMETHODIMP_(ULONG) COCar::CImpICar::AddRef(void)
00351 {
00352   // Increment the Interface Reference Count.
00353   ++m_cRefI;
00354
00355   LOGF1("L: COCar::CImpICar::Addref. Delegating. New cI=%i.", m_cRefI);
00356
00357   // Delegate this call to the outer object's AddRef.
00358   return m_pUnkOuter->AddRef();
00359 }
00360
00361
00362 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00363   Method:   COCar::CImpICar::Release
00364
00365   Summary:  The Release IUnknown member of this ICar interface
00366             implementation that delegates to m_pUnkOuter, whatever it is.
00367
00368   Args:     void
00369
00370   Modifies: .
00371
00372   Returns:  ULONG
00373               Returned by the delegated outer Release call.
00374 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00375 STDMETHODIMP_(ULONG) COCar::CImpICar::Release(void)
00376 {
00377   // Decrement the Interface Reference Count.
00378   --m_cRefI;
00379
00380   LOGF1("L: COCar::CImpICar::Release. Delegating. New cI=%i.", m_cRefI);
00381
00382   // Delegate this call to the outer object's Release.
00383   return m_pUnkOuter->Release();
00384 }
00385
00386
00387 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00388   Method:   COCar::CImpICar::Shift
00389
00390   Summary:  The Shift member method of this ICar interface implementation.
00391             A simple empty method on a COCar COM object for tutorial
00392             purposes.  Presumably if this Car object were modeling
00393             a real Car then the Shift method would shift to the specified
00394             gear.
00395
00396   Args:     short nGear
00397               0 - Neutral; 1 - 5 First 5 forward gears; 6 - Reverse.
00398
00399   Modifies: .
00400
00401   Returns:  HRESULT
00402               NOERROR
00403 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00404 STDMETHODIMP COCar::CImpICar::Shift(
00405                short nGear)
00406 {
00407   LOGF1("L: COCar::CImpICar::Shift. Called. nGear=%i.",nGear);
00408
00409   return NOERROR;
00410 }
00411
00412
00413 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00414   Method:   COCar::CImpICar::Clutch
00415
00416   Summary:  The Clutch member method of this ICar interface implementation.
00417             A simple empty method on a COCar COM object for tutorial
00418             purposes.  Presumably if this Car object were modeling
00419             a real Car then the Clutch method would engage the clutch the
00420             specified amount.
00421
00422   Args:     short nEngaged)
00423               Percent clutch is engaged (0 to 100%).
00424
00425   Modifies: .
00426
00427   Returns:  HRESULT
00428               NOERROR
00429 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00430 STDMETHODIMP COCar::CImpICar::Clutch(
00431                short nEngaged)
00432 {
00433   LOGF1("L: COCar::CImpICar::Clutch. Called. nEngaged=%i.",nEngaged);
00434
00435   return NOERROR;
00436 }
00437
00438
00439 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00440   Method:   COCar::CImpICar::Speed
00441
00442   Summary:  The Speed member method of this ICar interface implementation.
00443             A simple empty method on a COCar COM object for tutorial
00444             purposes.  Presumably if this Car object were modeling
00445             a real Car then this method would accelerate/brake to bring
00446             the car to the specified speed.
00447
00448   Args:     short nMph
00449               New speed in miles per hour.
00450
00451   Modifies: .
00452
00453   Returns:  HRESULT
00454               NOERROR
00455 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00456 STDMETHODIMP COCar::CImpICar::Speed(
00457                short nMph)
00458 {
00459   LOGF1("L: COCar::CImpICar::Speed. Called. nMph=%i.",nMph);
00460
00461   return NOERROR;
00462 }
00463
00464
00465 /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
00466   Method:   COCar::CImpICar::Steer
00467
00468   Summary:  The Steer member method of this ICar interface implementation.
00469             A simple empty method on a COCar COM object for tutorial
00470             purposes.  Presumably if this Car object were modeling
00471             a real Car then the Steer method would set the steering
00472             angle of the Car.
00473
00474   Args:     short nAngle)
00475               0 degrees straight ahead, -45 Full left, +45 Full right.
00476
00477   Modifies: .
00478
00479   Returns:  HRESULT
00480               NOERROR
00481 M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
00482 STDMETHODIMP COCar::CImpICar::Steer(
00483                short nAngle)
00484 {
00485   LOGF1("L: COCar::CImpICar::Steer. Called. nAngle=%i.",nAngle);
00486
00487   return NOERROR;
00488 }
Generated on Wed Nov 13 2024 16:51:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/Parameters.java Source File

  • Com
  • Services
  • Transaction
  • SampleBank
  • vjAcct
  • MsAdo15

Parameters.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.2918
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc  /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package msado15;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // Dual interface Parameters
00019 /** @com.interface(iid=0000050D-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
00020 public interface Parameters extends msado15._DynaCollection
00021 {
00022   /** @com.method(vtoffset=4, dispid=1610743808, type=PROPGET, name="Count", name2="getCount", addFlagsVtable=4)
00023       @com.parameters([type=I4] return) */
00024   public int getCount();
00025
00026   /** @com.method(vtoffset=5, dispid=4294967292, type=METHOD, name="_NewEnum", addFlagsVtable=4)
00027       @com.parameters([iid=00000000-0000-0000-C000-000000000046,thread=AUTO,type=OBJECT] return) */
00028   public IUnknown _NewEnum();
00029
00030   /** @com.method(vtoffset=6, dispid=1610743810, type=METHOD, name="Refresh", addFlagsVtable=4)
00031       @com.parameters() */
00032   public void Refresh();
00033
00034   /** @com.method(vtoffset=7, dispid=1610809344, type=METHOD, name="Append", addFlagsVtable=4)
00035       @com.parameters([in,iid=00020400-0000-0000-C000-000000000046,thread=AUTO,type=DISPATCH] Object) */
00036   public void Append(Object Object);
00037
00038   /** @com.method(vtoffset=8, dispid=1610809345, type=METHOD, name="Delete", addFlagsVtable=4)
00039       @com.parameters([in,type=VARIANT] Index) */
00040   public void Delete(Variant Index);
00041
00042   /** @com.method(vtoffset=9, dispid=0, type=PROPGET, name="Item", name2="getItem", addFlagsVtable=4)
00043       @com.parameters([in,type=VARIANT] Index, [iid=0000050C-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
00044   public msado15._Parameter getItem(Variant Index);
00045
00046
00047   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x50d, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
00048 }
Generated on Wed Nov 13 2024 16:52:00 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/odbc/quiktest/autotest.h Source File

  • Dataaccess
  • odbc
  • quiktest

autotest.h

Go to the documentation of this file.
00001 //*---------------------------------------------------------------------------------
00002 //|  Title:   AUTOTEST.H
00003 //|
00004 //| This file contains constants and prototypes required to compile an
00005 //| Auto Test DLL.
00006 //*---------------------------------------------------------------------------------
00007 #ifndef AUTOTEST_DEFS
00008 #define AUTOTEST_DEFS
00009
00010 #include <windows.h>
00011 #include <stdlib.h>
00012 #include <string.h>
00013 #include "sql.h"
00014 #include "sqlext.h"
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif  /* __cplusplus */
00019
00020
00021 extern HINSTANCE  hLoadedInst;
00022
00023
00024 //----------------------------------------------------------------------------------
00025 //    Defines and Macros
00026 //----------------------------------------------------------------------------------
00027 #define TEST_ABORTED            (-1)
00028
00029 #define AUTO_MAX_TEST_NAME        35
00030 #define AUTO_MAX_TESTCASE_NAME    35
00031 #define AUTO_MAX_TESTDESC_NAME    75
00032
00033 #define MAXFLUSH              300
00034 #define MAX_USER_INFO           50
00035 #define MAX_KEYWORD_LEN         149
00036
00037 #ifdef WIN32
00038 #define EXTFUNCDECL           _stdcall
00039 #define EXTFUN                _stdcall
00040 #else
00041 #define EXTFUNCDECL
00042 #define EXTFUN                __export FAR PASCAL
00043 #endif
00044
00045
00046 #define InitTest(lps)                             \
00047 {   lps->cErrors=0; }
00048 #define AbortTest(lps)                              \
00049 { lps->cErrors=TEST_ABORTED; }
00050
00051 #define     AllocateMemory(cb)  \
00052                 (GlobalLock(GlobalAlloc((GMEM_FIXED | GMEM_ZEROINIT), (cb))))
00053 #ifdef WIN32
00054 #define     ReleaseMemory(lp)   \
00055            (GlobalUnlock((HGLOBAL)GlobalHandle(lp)), (BOOL)GlobalFree((HGLOBAL)GlobalHandle(lp)))
00056 #else
00057 #define     ReleaseMemory(lp)   \
00058                 (GlobalUnlock(((HGLOBAL)LOWORD(GlobalHandle(SELECTOROF(lp))))), \
00059                 (BOOL)GlobalFree(((HGLOBAL)LOWORD(GlobalHandle(SELECTOROF(lp))))))
00060 #endif
00061
00062 #define NumItems(s) (sizeof(s) / sizeof(s[0]))
00063
00064 // Following will access bit number pos in a bit array and return
00065 //    TRUE if it is set, FALSE if it is not
00066 #define CQBITS (sizeof(UINT) * 8)
00067 #define getqbit(lpa, pos) \
00068   (lpa[((pos) / CQBITS)] & (1 << ((pos) - (CQBITS * ((pos) / CQBITS)))))
00069 #define GETBIT(p1,p2) getqbit(p1,(p2)-1)
00070
00071
00072
00073 //
00074 // This structure contains the information found in the .INI file for a
00075 //  data source.  The filled out structure is in turn passed to AutoTestFunc
00076 //  to drive the individual tests.
00077 //
00078 typedef struct tagSERVERINFO {
00079   HWND      hwnd;               // Output edit window
00080   TCHAR       szLogFile[_MAX_PATH];   // Output log file
00081   HENV      henv;               // .EXE's henv
00082   HDBC      hdbc;               // .EXE's hdbc
00083   HSTMT     hstmt;              // .EXE's hstmt
00084
00085   // The following items are gathered from the .INI file and may be defined
00086   //    via the "Manage Test Sources" menu item from ODBC Test
00087   TCHAR       szSource[SQL_MAX_DSN_LENGTH+1];
00088   TCHAR       szValidServer0[SQL_MAX_DSN_LENGTH+1];
00089   TCHAR       szValidLogin0[MAX_USER_INFO+1];
00090   TCHAR       szValidPassword0[MAX_USER_INFO+1];
00091   TCHAR     szKeywords[MAX_KEYWORD_LEN+1];
00092
00093   // Following are used for run-time
00094   UINT FAR *  rglMask;              // Run test mask
00095   int       failed;             // Track failures on a test case basis
00096   int       cErrors;              // Count of errors
00097   BOOL      fDebug;             // TRUE if debugging is to be enabled
00098   BOOL      fScreen;              // TRUE if test output goes to screen
00099   BOOL      fLog;               // TRUE if test output goes to log
00100   BOOL      fIsolate;           // TRUE to isolate output
00101   UDWORD    vCursorLib;           // Value for SQL_ODBC_CURSOR on SQLSetConnectOption
00102   HINSTANCE hLoadedInst;          // Instance handle of loaded test
00103
00104   // Following are used for buffering output to edit window
00105   TCHAR     szBuff[MAXFLUSH];       // Hold temporary results
00106   UINT      cBuff;              // Number of TCHARs in szBuff
00107   } SERVERINFO;
00108 typedef SERVERINFO FAR * lpSERVERINFO;
00109
00110
00111 //----------------------------------------------------------------------------------
00112 // Function prototypes
00113 //----------------------------------------------------------------------------------
00114 BOOL EXTFUNCDECL FAR szLogPrintf(lpSERVERINFO lps, BOOL fForce, LPTSTR szFmt, ...);
00115 int EXTFUNCDECL FAR szMessageBox(HWND hwnd, UINT style, LPTSTR szTitle, LPTSTR szFmt, ...);
00116 LPTSTR EXTFUN GetRCString(HINSTANCE hInst, LPTSTR buf, int cbbuf, UINT ids);
00117
00118
00119 #ifdef __cplusplus
00120 }
00121 #endif
00122
00123 #endif
00124
00125
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/IO/RSM/app/app_utls.cpp Source File

  • WinBase
  • IO
  • RSM
  • app

app_utls.cpp

Go to the documentation of this file.
00001 /*
00002  *  This is a part of the Microsoft Source Code Samples.
00003  *  Copyright 1996 - 1998 Microsoft Corporation.
00004  *  All rights reserved.
00005  *
00006  *  This sample code shows the usage of some portions
00007  *  of the NTMS API.
00008  *
00009  *  Return codes are, for the most part, not checked in
00010  *  this code. See the Programmer's reference for error
00011  *  return information.
00012  *
00013  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00014  * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00015  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00016  * PARTICULAR PURPOSE.
00017  *
00018  * Copyright 1997 - 1998 Microsoft Corporation.  All Rights Reserved. *
00019  */
00020 #include <stdio.h>
00021 #include <windows.h>
00022 #include <iostream.h>
00023 #include <ntmsapi.h>
00024
00025
00026 static NTMS_GUID globalPoolID, globalMediaID;
00027
00028
00029 // in a real app the following functions use a database or some such
00030 // thing to persist these GUIDs across app invocations.
00031
00032   void
00033 persistPoolID(NTMS_GUID guid)
00034 {
00035   globalPoolID = guid;
00036 }
00037
00038   NTMS_GUID
00039 recallPoolID()
00040 {
00041   return globalPoolID;
00042 }
00043
00044   void
00045 persistMediaID(NTMS_GUID guid)
00046 {
00047   globalMediaID = guid;
00048 }
00049
00050   NTMS_GUID
00051 recallMediaID()
00052 {
00053   return globalMediaID;
00054 }
00055
Generated on Wed Nov 13 2024 16:52:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

tagDataStruct Member List

This is the complete list of members for tagDataStruct, including all inherited members.
cb | tagDataStruct
data | tagDataStruct
date | tagDataStruct
sChar | tagDataStruct
sdouble | tagDataStruct
sdword | tagDataStruct
sfloat | tagDataStruct
sword | tagDataStruct
time | tagDataStruct
timestamp | tagDataStruct
uChar | tagDataStruct
udword | tagDataStruct
uword | tagDataStruct
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/MSAgent/c/CapMFC/StdAfx.h Source File

  • Web
  • MSAgent
  • c
  • CapMFC

StdAfx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //  or project specific include files that are used frequently, but
00003 //      are changed infrequently
00004 //
00005
00006 #if !defined(AFX_STDAFX_H__AB8FEB9C_3841_11D2_8512_00C04FA34A14__INCLUDED_)
00007 #define AFX_STDAFX_H__AB8FEB9C_3841_11D2_8512_00C04FA34A14__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00013 #define VC_EXTRALEAN    // Exclude rarely-used stuff from Windows headers
00014
00015 #include <afxwin.h>         // MFC core and standard components
00016 #include <afxext.h>         // MFC extensions
00017 #include <afxdisp.h>        // MFC Automation classes
00018
00019 #if _MSC_VER >= 1200
00020 #include <afxdtctl.h>   // MFC support for Internet Explorer 4 Common Controls
00021 #endif
00022
00023 #ifndef _AFX_NO_AFXCMN_SUPPORT
00024 #include <afxcmn.h>     // MFC support for Windows Common Controls
00025 #endif // _AFX_NO_AFXCMN_SUPPORT
00026
00027
00028 //{{AFX_INSERT_LOCATION}}
00029 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00030
00031 #include <malloc.h>
00032
00033 // Agent Control Wrapper Headers generated by Class Wizard
00034
00035 #include "ACEx.h"
00036 #include "ACChars.h"
00037 #include "ACChar.h"
00038 #include "ACBall.h"
00039 #include "ACAnim.h"
00040 #include "ACComms.h"
00041 #include "ACUser.h"
00042 #include "ACReq.h"
00043 #include "ACProp.h"
00044 #include "ACAudio.h"
00045
00046 // Agent Control Header
00047
00048 #include "AgtCtl.h"
00049
00050 // Agent Server Header (need only for visibility causes)
00051
00052 #include "AgtSvr.h"
00053
00054 #endif // !defined(AFX_STDAFX_H__AB8FEB9C_3841_11D2_8512_00C04FA34A14__INCLUDED_)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/DComPerm/DComPerm.h Source File

  • Com
  • Fundamentals
  • DCom
  • DComPerm

DComPerm.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // This file is part of the Microsoft COM+ Samples.
00004 //
00005 // Copyright (C) 1995-2000 Microsoft Corporation. All rights reserved.
00006 //
00007 // This source code is intended only as a supplement to Microsoft
00008 // Development Tools and/or on-line documentation. See these other
00009 // materials for detailed information regarding Microsoft code samples.
00010 //
00011 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00012 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00013 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00014 // PARTICULAR PURPOSE.
00015 //
00016 // ----------------------------------------------------------------------------
00017
00018 #define GUIDSTR_MAX 38
00019
00020 #ifndef STR2UNI
00021
00022 #define STR2UNI(unistr, regstr) \
00023         mbstowcs (unistr, regstr, strlen (regstr)+1);
00024
00025 #define UNI2STR(regstr, unistr) \
00026         wcstombs (regstr, unistr, wcslen (unistr)+1);
00027
00028 #endif
00029
00030 #define ACE_TYPE_ALL (-1L)
00031
00032 #define SIZE_NAME_BUFFER 256
00033 #define SIZE_MSG_BUFFER 256
00034
00035 #define SDTYPE_MACHINE_LAUNCH     (0x1L)
00036 #define SDTYPE_MACHINE_ACCESS     (0x2L)
00037 #define SDTYPE_DEFAULT_LAUNCH     (0x4L)
00038 #define SDTYPE_DEFAULT_ACCESS     (0x8L)
00039 #define SDTYPE_APPLICATION_LAUNCH (0x10L)
00040 #define SDTYPE_APPLICATION_ACCESS (0x20L)
00041
00042 #define SDTYPE_ACCESS (SDTYPE_MACHINE_ACCESS|SDTYPE_DEFAULT_ACCESS|SDTYPE_APPLICATION_ACCESS)
00043
00044 #ifndef COM_RIGHTS_EXECUTE_LOCAL
00045 #define COM_RIGHTS_EXECUTE_LOCAL  0x2
00046 #endif
00047 #ifndef COM_RIGHTS_EXECUTE_REMOTE
00048 #define COM_RIGHTS_EXECUTE_REMOTE 0x4
00049 #endif
00050 #ifndef COM_RIGHTS_ACTIVATE_LOCAL
00051 #define COM_RIGHTS_ACTIVATE_LOCAL 0x8
00052 #endif
00053 #ifndef COM_RIGHTS_ACTIVATE_REMOTE
00054 #define COM_RIGHTS_ACTIVATE_REMOTE 0x10
00055 #endif
00056
00057
00058 //
00059 // Wrappers
00060 //
00061 DWORD
00062 ListMachineAccessACL();
00063
00064 DWORD
00065 ListMachineLaunchACL();
00066
00067 DWORD
00068 ListDefaultAccessACL();
00069
00070 DWORD
00071 ListDefaultLaunchACL();
00072
00073 DWORD
00074 ListAppIDAccessACL (
00075     LPTSTR AppID
00076     );
00077
00078 DWORD
00079 ListAppIDLaunchACL (
00080     LPTSTR AppID
00081     );
00082
00083 DWORD
00084 ChangeMachineAccessACL (
00085     LPTSTR tszPrincipal,
00086     BOOL fSetPrincipal,
00087     BOOL fPermit,
00088     DWORD dwAccessMask
00089     );
00090
00091 DWORD
00092 ChangeMachineLaunchAndActivateACL (
00093     LPTSTR tszPrincipal,
00094     BOOL fSetPrincipal,
00095     BOOL fPermit,
00096     DWORD dwAccessMask
00097     );
00098
00099 DWORD
00100 ChangeDefaultAccessACL (
00101     LPTSTR Principal,
00102     BOOL SetPrincipal,
00103     BOOL Permit,
00104     DWORD dwAccessMask
00105     );
00106
00107 DWORD
00108 ChangeDefaultLaunchAndActivateACL (
00109     LPTSTR Principal,
00110     BOOL SetPrincipal,
00111     BOOL Permit,
00112     DWORD dwAccessMask
00113     );
00114
00115 DWORD
00116 ChangeAppIDAccessACL (
00117     LPTSTR AppID,
00118     LPTSTR Principal,
00119     BOOL SetPrincipal,
00120     BOOL Permit,
00121     DWORD dwAccessMask
00122     );
00123
00124 DWORD
00125 ChangeAppIDLaunchAndActivateACL (
00126     LPTSTR AppID,
00127     LPTSTR Principal,
00128     BOOL SetPrincipal,
00129     BOOL Permit,
00130     DWORD dwAccessMask
00131     );
00132
00133 DWORD GetRunAsPassword (
00134     LPTSTR AppID,
00135     LPTSTR Password
00136     );
00137
00138 DWORD SetRunAsPassword (
00139     LPTSTR AppID,
00140     LPTSTR Principal,
00141     LPTSTR Password
00142     );
00143
00144 DWORD GetRunAsPassword (
00145     LPTSTR AppID,
00146     LPTSTR Password
00147     );
00148
00149 DWORD SetRunAsPassword (
00150     LPTSTR AppID,
00151     LPTSTR Password
00152     );
00153
00154 //
00155 // Internal functions
00156 //
00157
00158 DWORD
00159 CreateNewSD (
00160     SECURITY_DESCRIPTOR **SD
00161     );
00162
00163 DWORD
00164 SetAclDefaults(
00165     PACL pDacl,
00166     DWORD dwSDType
00167     );
00168
00169 DWORD
00170 MakeSDAbsolute (
00171     PSECURITY_DESCRIPTOR OldSD,
00172     PSECURITY_DESCRIPTOR *NewSD
00173     );
00174
00175 DWORD
00176 SetNamedValueSD (
00177     HKEY RootKey,
00178     LPTSTR KeyName,
00179     LPTSTR ValueName,
00180     SECURITY_DESCRIPTOR *SD
00181     );
00182
00183 DWORD
00184 GetNamedValueSD (
00185     HKEY RootKey,
00186     LPTSTR KeyName,
00187     LPTSTR ValueName,
00188     SECURITY_DESCRIPTOR **SD,
00189     BOOL *NewSD
00190     );
00191
00192 DWORD
00193 ListNamedValueSD (
00194     HKEY hkeyRoot,
00195     LPTSTR tszKeyName,
00196     LPTSTR tszValueName,
00197     DWORD dwSDType
00198     );
00199
00200 DWORD
00201 AddPrincipalToNamedValueSD (
00202     HKEY RootKey,
00203     LPTSTR KeyName,
00204     LPTSTR ValueName,
00205     LPTSTR Principal,
00206     BOOL Permit,
00207     DWORD dwAccessMask,
00208     DWORD dwSDType
00209     );
00210
00211 DWORD
00212 UpdatePrincipalInNamedValueSD (
00213     HKEY hkeyRoot,
00214     LPTSTR tszKeyName,
00215     LPTSTR tszValueName,
00216     LPTSTR tszPrincipal,
00217     DWORD dwAccessMask,
00218     BOOL fRemove,
00219     DWORD fAceType
00220     );
00221
00222 DWORD
00223 RemovePrincipalFromNamedValueSD (
00224     HKEY RootKey,
00225     LPTSTR KeyName,
00226     LPTSTR ValueName,
00227     LPTSTR Principal,
00228     DWORD fAceType
00229     );
00230
00231 BOOL
00232 IsLegacySecurityModel ();
00233
00234 DWORD
00235 GetCurrentUserSID (
00236     PSID *Sid
00237     );
00238
00239 DWORD
00240 GetPrincipalSID (
00241     LPTSTR Principal,
00242     PSID *Sid
00243     );
00244
00245 DWORD
00246 CopyACL (
00247     PACL paclOld,
00248     PACL paclNew
00249     );
00250
00251 DWORD
00252 AddAccessDeniedACEToACL (
00253     PACL *paclOrig,
00254     DWORD dwPermissionMask,
00255     LPTSTR tszPrincipal
00256     );
00257
00258 DWORD
00259 AddAccessAllowedACEToACL (
00260     PACL *paclOrig,
00261     DWORD dwAccessMask,
00262     LPTSTR tszPrincipal
00263     );
00264
00265 DWORD
00266 UpdatePrincipalInACL (
00267     PACL paclOrig,
00268     LPTSTR tszPrincipal,
00269     DWORD dwAccessMask,
00270     BOOL fRemove,
00271     DWORD fAceType
00272     );
00273
00274 DWORD
00275 RemovePrincipalFromACL (
00276     PACL paclOrig,
00277     LPTSTR tszPrincipal,
00278     DWORD fAceType
00279     );
00280
00281 void
00282 ListACL (
00283     PACL Acl,
00284     DWORD dwSDType
00285     );
00286
00287 DWORD
00288 SetAccountRights (
00289     LPTSTR User,
00290     LPTSTR Privilege
00291     );
00292
00293 //
00294 // Utility Functions
00295 //
00296
00297 LPTSTR
00298 SystemMessage (
00299     LPTSTR szBuffer,
00300     DWORD cbBuffer,
00301     HRESULT hr
00302     );
00303
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/SimpDnd/ias.Cpp Source File

  • Com
  • Fundamentals
  • SimpDnd

ias.Cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 // File name: IAS.CPP
00003 //
00004 //      Implementation file of CAdviseSink
00005 //
00006 //
00007 // Functions:
00008 //
00009 //      See IAS.H for Class Definition
00010 //
00011 // Copyright 1992 - 2000 Microsoft Corporation. All rights reserved.
00012 //**********************************************************************
00013
00014 #include "pre.h"
00015 #include "iocs.h"
00016 #include "ias.h"
00017 #include "app.h"
00018 #include "site.h"
00019 #include "doc.h"
00020
00021 //**********************************************************************
00022 //
00023 // CAdviseSink::QueryInterface
00024 //
00025 // Purpose:
00026 //
00027 //      Returns a pointer to a requested interface.
00028 //
00029 // Parameters:
00030 //
00031 //      REFIID riid         - The requested interface
00032 //
00033 //      LPVOID FAR* ppvObj  - Place to return the interface
00034 //
00035 // Return Value:
00036 //
00037 //      HRESULT from CSimpleSite::QueryInterface
00038 //
00039 // Function Calls:
00040 //      Function                    Location
00041 //
00042 //      CSimpleSite::QueryInterface SITE.CPP
00043 //      OutputDebugString           Windows API
00044 //
00045 // Comments:
00046 //
00047 //      This function simply delegates to the Object class, which is
00048 //      aware of the supported interfaces.
00049 //
00050 //********************************************************************
00051
00052 STDMETHODIMP CAdviseSink::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
00053 {
00054   OutputDebugString("In IAS::QueryInterface\r\n");
00055
00056   // delegate to the document Object
00057   return m_pSite->QueryInterface(riid, ppvObj);
00058 }
00059
00060 //**********************************************************************
00061 //
00062 // CAdviseSink::AddRef
00063 //
00064 // Purpose:
00065 //
00066 //      Increments the reference count on this interface
00067 //
00068 // Parameters:
00069 //
00070 //      None
00071 //
00072 // Return Value:
00073 //
00074 //      The current reference count on this interface.
00075 //
00076 // Function Calls:
00077 //      Function                    Location
00078 //
00079 //      CSimpleSite::AddReff        SITE.CPP
00080 //      OutputDebugString           Windows API
00081 //
00082 // Comments:
00083 //
00084 //      This function adds one to the ref count of the interface,
00085 //      and calls then calls CSimpleSite to increment its ref.
00086 //      count.
00087 //
00088 //********************************************************************
00089
00090 STDMETHODIMP_(ULONG) CAdviseSink::AddRef()
00091 {
00092   OutputDebugString("In IAS::AddRef\r\n");
00093
00094   // increment the interface reference count (for debugging only)
00095   ++m_nCount;
00096
00097   // delegate to the container Site
00098   return m_pSite->AddRef();
00099 }
00100
00101 //**********************************************************************
00102 //
00103 // CAdviseSink::Release
00104 //
00105 // Purpose:
00106 //
00107 //      Decrements the reference count on this interface
00108 //
00109 // Parameters:
00110 //
00111 //      None
00112 //
00113 // Return Value:
00114 //
00115 //      The current reference count on this interface.
00116 //
00117 // Function Calls:
00118 //      Function                    Location
00119 //
00120 //      CSimpleSite::Release        SITE.CPP
00121 //      OutputDebugString           Windows API
00122 //
00123 // Comments:
00124 //
00125 //      This function subtracts one from the ref count of the interface,
00126 //      and calls then calls CSimpleSite to decrement its ref.
00127 //      count.
00128 //
00129 //********************************************************************
00130
00131 STDMETHODIMP_(ULONG) CAdviseSink::Release()
00132 {
00133   OutputDebugString("In IAS::Release\r\n");
00134
00135   // decrement the interface reference count (for debugging only)
00136   m_nCount--;
00137
00138   // delegate to the container Site
00139   return m_pSite->Release();
00140 }
00141
00142 //**********************************************************************
00143 //
00144 // CAdviseSink::OnDataChange
00145 //
00146 // Purpose:
00147 //
00148 //      Not Implemented (needs to be stubbed out)
00149 //
00150 // Parameters:
00151 //
00152 //      Not Implemented (needs to be stubbed out)
00153 //
00154 // Return Value:
00155 //
00156 //      Not Implemented (needs to be stubbed out)
00157 //
00158 // Function Calls:
00159 //      Function                    Location
00160 //
00161 //      OutputDebugString           Windows API
00162 //
00163 // Comments:
00164 //
00165 //      Not Implemented (needs to be stubbed out)
00166 //
00167 //********************************************************************
00168
00169 STDMETHODIMP_(void) CAdviseSink::OnDataChange (FORMATETC FAR* pFormatetc, STGMEDIUM FAR* pStgmed)
00170 {
00171   OutputDebugString("In IAS::OnDataChange\r\n");
00172 }
00173
00174 //**********************************************************************
00175 //
00176 // CAdviseSink::OnViewChange
00177 //
00178 // Purpose:
00179 //
00180 //      Notifies us that the view has changed and needs to be updated.
00181 //
00182 // Parameters:
00183 //
00184 //      DWORD dwAspect  - Aspect that has changed
00185 //
00186 //      LONG lindex     - Index that has changed
00187 //
00188 // Return Value:
00189 //
00190 //      None
00191 //
00192 // Function Calls:
00193 //      Function                    Location
00194 //
00195 //      OutputDebugString           Windows API
00196 //      InvalidateRect              Windows API
00197 //      IViewObject2::GetExtent     Object
00198 //
00199 // Comments:
00200 //
00201 //********************************************************************
00202
00203 STDMETHODIMP_(void) CAdviseSink::OnViewChange (DWORD dwAspect, LONG lindex)
00204 {
00205   LPVIEWOBJECT2 lpViewObject2;
00206   OutputDebugString("In IAS::OnViewChange\r\n");
00207
00208   // get a pointer to IViewObject2
00209   HRESULT hErr = m_pSite->m_lpOleObject->QueryInterface(
00210       IID_IViewObject2,(LPVOID FAR *)&lpViewObject2);
00211
00212   if (hErr == NOERROR) {
00213     // get extent of the object
00214     // NOTE: this method will never be remoted; it can be called w/i this async method
00215     lpViewObject2->GetExtent(DVASPECT_CONTENT, -1 , NULL, &m_pSite->m_sizel);
00216     lpViewObject2->Release();
00217   }
00218
00219   InvalidateRect(m_pSite->m_lpDoc->m_hDocWnd, NULL, TRUE);
00220 }
00221
00222 //**********************************************************************
00223 //
00224 // CAdviseSink::OnRename
00225 //
00226 // Purpose:
00227 //
00228 //      Not Implemented (needs to be stubbed out)
00229 //
00230 // Parameters:
00231 //
00232 //      Not Implemented (needs to be stubbed out)
00233 //
00234 // Return Value:
00235 //
00236 //      Not Implemented (needs to be stubbed out)
00237 //
00238 // Function Calls:
00239 //      Function                    Location
00240 //
00241 //      OutputDebugString           Windows API
00242 //
00243 // Comments:
00244 //
00245 //      Not Implemented (needs to be stubbed out)
00246 //
00247 //********************************************************************
00248
00249 STDMETHODIMP_(void) CAdviseSink::OnRename (LPMONIKER pmk)
00250 {
00251   OutputDebugString("In IAS::OnRename\r\n");
00252 }
00253
00254 //**********************************************************************
00255 //
00256 // CAdviseSink::OnSave
00257 //
00258 // Purpose:
00259 //
00260 //      Not Implemented (needs to be stubbed out)
00261 //
00262 // Parameters:
00263 //
00264 //      Not Implemented (needs to be stubbed out)
00265 //
00266 // Return Value:
00267 //
00268 //      Not Implemented (needs to be stubbed out)
00269 //
00270 // Function Calls:
00271 //      Function                    Location
00272 //
00273 //      OutputDebugString           Windows API
00274 //
00275 // Comments:
00276 //
00277 //      Not Implemented (needs to be stubbed out)
00278 //
00279 //********************************************************************
00280
00281 STDMETHODIMP_(void) CAdviseSink::OnSave ()
00282 {
00283   OutputDebugString("In IAS::OnSave\r\n");
00284 }
00285
00286 //**********************************************************************
00287 //
00288 // CAdviseSink::OnClose
00289 //
00290 // Purpose:
00291 //
00292 //      Not Implemented (needs to be stubbed out)
00293 //
00294 // Parameters:
00295 //
00296 //      Not Implemented (needs to be stubbed out)
00297 //
00298 // Return Value:
00299 //
00300 //      Not Implemented (needs to be stubbed out)
00301 //
00302 // Function Calls:
00303 //      Function                    Location
00304 //
00305 //      OutputDebugString           Windows API
00306 //
00307 // Comments:
00308 //
00309 //      Not Implemented (needs to be stubbed out)
00310 //
00311 //********************************************************************
00312
00313 STDMETHODIMP_(void) CAdviseSink::OnClose()
00314 {
00315   OutputDebugString("In IAS::OnClose\r\n");
00316 }
Generated on Wed Nov 13 2024 16:51:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/Browser/EditFeatures/dlldata.c Source File

  • Web
  • Browser
  • EditFeatures

dlldata.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Microsoft Corporation.  All rights reserved.
00003  */
00004
00005 /*********************************************************
00006    DllData file -- generated by MIDL compiler
00007
00008         DO NOT ALTER THIS FILE
00009
00010    This file is regenerated by MIDL on every IDL file compile.
00011
00012    To completely reconstruct this file, delete it and rerun MIDL
00013    on all the IDL files in this DLL, specifying this file for the
00014    /dlldata command line option
00015
00016 *********************************************************/
00017
00018 #define PROXY_DELEGATION
00019
00020 #include <rpcproxy.h>
00021
00022 #ifdef __cplusplus
00023 extern "C"   {
00024 #endif
00025
00026 EXTERN_PROXY_FILE( EdCommands )
00027
00028
00029 PROXYFILE_LIST_START
00030 /* Start of list */
00031   REFERENCE_PROXY_FILE( EdCommands ),
00032 /* End of list */
00033 PROXYFILE_LIST_END
00034
00035
00036 DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
00037
00038 #ifdef __cplusplus
00039 }  /*extern "C" */
00040 #endif
00041
00042 /* end of generated dlldata file */
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/IpxChat/About.c Source File

  • NetDS
  • WinSock
  • IpxChat

About.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00004 // PARTICULAR PURPOSE.
00005 //
00006 // Copyright 1993 - 2000 Microsoft Corporation.  All Rights Reserved.
00007 //
00008 //  MODULE:   about.c
00009 //
00010 //  PURPOSE:   Displays the "About" dialog box
00011 //
00012 //  FUNCTIONS:
00013 //    CmdAbout        - Displays the "About" dialog box
00014 //    About           - Processes messages for "About" dialog box.
00015 //    MsgAboutInit    - To initialize the about box with version info
00016 //                      from resources.
00017 //    MsgAboutCommand - Process WM_COMMAND message sent to the about box.
00018 //    CmdAboutDone    - Free the about box and related data.
00019 //
00020 //  COMMENTS:
00021 //
00022 //
00023
00024 #include "globals.h"            // prototypes specific to this application
00025 #include <windows.h>            // required for all Windows applications
00026 #include <windowsx.h>
00027
00028
00029
00030 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
00031 LRESULT MsgAboutInit(HWND, UINT, WPARAM, LPARAM);
00032 LRESULT MsgAboutCommand(HWND, UINT, WPARAM, LPARAM);
00033 LRESULT CmdAboutDone(HWND, WORD, WORD, HWND);
00034
00035 // About dialog message table definition.
00036 MSD rgmsdAbout[] =
00037 {
00038     {WM_COMMAND,    MsgAboutCommand},
00039     {WM_INITDIALOG, MsgAboutInit}
00040 };
00041
00042 MSDI msdiAbout =
00043 {
00044     sizeof(rgmsdAbout) / sizeof(MSD),
00045     rgmsdAbout,
00046     edwpNone
00047 };
00048
00049 // About dialog command table definition.
00050 CMD rgcmdAbout[] =
00051 {
00052     {IDOK,     CmdAboutDone},
00053     {IDCANCEL, CmdAboutDone}
00054 };
00055
00056 CMDI cmdiAbout =
00057 {
00058     sizeof(rgcmdAbout) / sizeof(CMD),
00059     rgcmdAbout,
00060     edwpNone
00061 };
00062
00063 // Module specific "globals"  Used when a variable needs to be
00064 // accessed in more than on handler function.
00065
00066 HFONT hFontCopyright;
00067
00068 //
00069 //  FUNCTION: CmdAbout(HWND, WORD, WORD, HWND)
00070 //
00071 //  PURPOSE: Displays the "About" dialog box
00072 //
00073 //  PARAMETERS:
00074 //    hwnd      - Window handle
00075 //    wCommand  - IDM_ABOUT (unused)
00076 //    wNotify   - Notification number (unused)
00077 //    hwndCtrl  - NULL (unused)
00078 //
00079 //  RETURN VALUE:
00080 //
00081 //    Always returns 0 - Message handled
00082 //
00083 //  COMMENTS:
00084 //    To process the IDM_ABOUT message, call DialogBox() to display the
00085 //    about dialog box.
00086
00087 LRESULT CmdAbout(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00088 {
00089     DialogBox(hInst, "AboutBox", hwnd, (DLGPROC)About);
00090     return 0;
00091 }
00092
00093
00094 //
00095 //  FUNCTION: About(HWND, UINT, WPARAM, LPARAM)
00096 //
00097 //  PURPOSE:  Processes messages for "About" dialog box.
00098 //
00099 //  PARAMETERS:
00100 //    hdlg - window handle of the dialog box
00101 //    wMessage - type of message
00102 //    wparam - message-specific information
00103 //    lparam - message-specific information
00104 //
00105 //  RETURN VALUE:
00106 //    TRUE - message handled
00107 //    FALSE - message not handled
00108 //
00109 //  COMMENTS:
00110 //
00111 //     Display version information from the version section of the
00112 //     application resource.
00113 //
00114 //     Wait for user to click on "Ok" button, then close the dialog box.
00115 //
00116
00117 LRESULT CALLBACK About(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
00118 {
00119     return DispMessage(&msdiAbout, hdlg, uMessage, wparam, lparam);
00120 }
00121
00122
00123 //
00124 //  FUNCTION: MsgAboutInit(HWND, UINT, WPARAM, LPARAM)
00125 //
00126 //  PURPOSE: To initialize the about box with version info from resources.
00127 //
00128 //  PARAMETERS:
00129 //    hwnd - The window handing the message.
00130 //    uMessage - The message number. (unused).
00131 //    wparam - Message specific data (unused).
00132 //    lparam - Message specific data (unused).
00133 //
00134 //  RETURN VALUE:
00135 //    Always returns 0 - message handled.
00136 //
00137 //  COMMENTS:
00138 //    Uses the version apis to retrieve version information for
00139 //    each of the static text boxes in the about box.
00140 //
00141
00142 LRESULT MsgAboutInit(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
00143 {
00144     #define POINTSIZE 8
00145
00146     char  szFullPath[256];
00147     DWORD dwVerHnd;
00148     DWORD dwVerInfoSize;
00149     HDC   hDC;
00150     int   iLogPixelsY, iPointSize;
00151
00152     // Center the dialog over the application window
00153     CenterWindow(hdlg, GetWindow(hdlg, GW_OWNER));
00154
00155     // Set the copyright font to something smaller than default
00156     hDC = GetDC(hdlg);
00157     iLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
00158     ReleaseDC(hdlg, hDC);
00159     iPointSize = MulDiv(iLogPixelsY, POINTSIZE, 72);
00160     iPointSize *= -1;
00161
00162     hFontCopyright = CreateFont(iPointSize,
00163                                 0, 0, 0,
00164                                 FW_DONTCARE,
00165                                 0, 0, 0, 0,
00166                                 0, 0, 0, 0,
00167                                 "System");
00168
00169     SendDlgItemMessage(hdlg,
00170                        IDD_VERLAST,
00171                        WM_SETFONT,
00172                        (WPARAM)hFontCopyright,
00173                        0L);
00174
00175     // Get version information from the application
00176     GetModuleFileName(hInst, szFullPath, sizeof(szFullPath));
00177     dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
00178     if (dwVerInfoSize)
00179     {
00180         // If we were able to get the information, process it:
00181         HANDLE  hMem;
00182         LPVOID  lpvMem;
00183         char    szGetName[256];
00184         int     cchRoot;
00185         int     i;
00186
00187         hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
00188         lpvMem = GlobalLock(hMem);
00189         GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
00190         StringCchCopy(szGetName,256,"\\StringFileInfo\\040904E4\\");
00191         cchRoot = lstrlen(szGetName);
00192
00193         // Walk through the dialog items that we want to replace:
00194         for (i = IDD_VERFIRST; i <= IDD_VERLAST; i++)
00195         {
00196             BOOL  fRet;
00197             UINT  cchVer = 0;
00198             LPSTR lszVer = NULL;
00199             char  szResult[256];
00200
00201             GetDlgItemText(hdlg, i, szResult, sizeof(szResult));
00202             StringCchCopy(&szGetName[cchRoot],256,szResult);
00203             fRet = VerQueryValue(lpvMem, szGetName, &lszVer, &cchVer);
00204
00205             if (fRet && cchVer && lszVer)
00206             {
00207                 // Replace dialog item text with version info
00208                 StringCchCopy(szResult,256,lszVer);
00209                 SetDlgItemText(hdlg, i, szResult);
00210             }
00211         }
00212         GlobalUnlock(hMem);
00213         GlobalFree(hMem);
00214     }
00215     return TRUE;
00216 }
00217
00218 //
00219 //  FUNCTION: MsgAboutCommand(HWND, UINT, WPARAM, LPARAM)
00220 //
00221 //  PURPOSE: Process WM_COMMAND message sent to the about box.
00222 //
00223 //  PARAMETERS:
00224 //    hwnd - The window handing the message.
00225 //    uMessage - The message number. (unused).
00226 //    wparam - Message specific data (unused).
00227 //    lparam - Message specific data (unused).
00228 //
00229 //  RETURN VALUE:
00230 //    Always returns 0 - message handled.
00231 //
00232 //  COMMENTS:
00233 //    Uses this DipsCommand function defined in wndproc.c combined
00234 //    with the cmdiAbout structure defined in this file to handle
00235 //    the command messages for the about dialog box.
00236 //
00237
00238 LRESULT MsgAboutCommand(HWND   hwnd,
00239                         UINT   uMessage,
00240                         WPARAM wparam,
00241                         LPARAM lparam)
00242 {
00243     return DispCommand(&cmdiAbout, hwnd, wparam, lparam);
00244 }
00245
00246 //
00247 //  FUNCTION: CmdAboutDone(HWND, WORD, HWND)
00248 //
00249 //  PURPOSE: Free the about box and related data.
00250 //
00251 //  PARAMETERS:
00252 //    hwnd - The window handling the command.
00253 //    wCommand - The command to be handled (unused).
00254 //    wNotify   - Notification number (unused)
00255 //    hwndCtrl - NULL (unused).
00256 //
00257 //  RETURN VALUE:
00258 //    Always returns TRUE.
00259 //
00260 //  COMMENTS:
00261 //    Calls EndDialog to finish the dialog session.
00262 //
00263
00264 LRESULT CmdAboutDone(HWND hdlg, WORD wCommand, WORD wNotify, HWND hwndCtrl)
00265 {
00266     if (hFontCopyright)
00267        DeleteObject(hFontCopyright);
00268
00269     EndDialog(hdlg, TRUE);          // Exit the dialog
00270     return TRUE;
00271 }
00272
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/CommDlg/CDTest/DevMode.h Source File

  • WinUI
  • CommDlg
  • CDTest

DevMode.h

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corp.
00004 *       All rights not expressly granted in the SDK license are reserved.
00005 \******************************************************************************/
00006 #define ID_DEVMODEDIALOG            710
00007
00008 #define ID_DMDRIVERDATA               118
00009 #define ID_ADD1DM                     119
00010 #define ID_CLEAR1DM                   120
00011 #define ID_DMDEVNAME                  121
00012 #define ID_DMSPECVER                  122
00013 #define ID_DMSIZEDEV                  123
00014 #define ID_DMDRIVERVER                124
00015 #define ID_DMDRIVEREXTRA              125
00016 #define ID_DMPAPERSIZE                128
00017 #define ID_DMPAPERLENGTH              129
00018 #define ID_DMPAPERWIDTH               130
00019 #define ID_DMSCALE                    131
00020 #define ID_DMCOPIES                   132
00021 #define ID_DMDEFAULTSOURCE            133
00022 #define ID_DMPRINTQUALITY             134
00023 #define ID_DMCOLOR                    135
00024 #define ID_DMDUPLEX                   136
00025 #define ID_DMORIENTATION              137
00026 #define ID_DMRESETDEV                 127
00027 #define ID_DMFIELDS                   117
00028 #define ID_DMCOLLATE                  138
00029 #define ID_DMFORMNAME                 141
00030 #define ID_DMBITSPERPEL               142
00031 #define ID_DMPELSWIDTH                146
00032 #define ID_DMPELSHEIGHT               147
00033 #define ID_DMDISPLAYFREQ              148
Generated on Wed Nov 13 2024 16:52:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Events/EventNews/CascadeEC/stdafx.h Source File

  • Com
  • Services
  • Events
  • EventNews
  • CascadeEC

stdafx.h

Go to the documentation of this file.
00001 // stdafx.h : include file for standard system include files,
00002 //      or project specific include files that are used frequently,
00003 //      but are changed infrequently
00004
00005 #if !defined(AFX_STDAFX_H__81998B21_0FC1_11D3_925A_0080C7C30D72__INCLUDED_)
00006 #define AFX_STDAFX_H__81998B21_0FC1_11D3_925A_0080C7C30D72__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #define STRICT
00013 #ifndef _WIN32_WINNT
00014 #define _WIN32_WINNT 0x0500
00015 #endif
00016 #define _ATL_APARTMENT_THREADED
00017
00018 #include <atlbase.h>
00019 //You may derive a class from CComModule and use it if you want to override
00020 //something, but do not change the name of _Module
00021 extern CComModule _Module;
00022 #include <atlcom.h>
00023
00024 //{{AFX_INSERT_LOCATION}}
00025 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00026
00027 #endif // !defined(AFX_STDAFX_H__81998B21_0FC1_11D3_925A_0080C7C30D72__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Queued_Components/QCSamp1/QCShip/StdAfx.h Source File

  • Com
  • Services
  • Queued_Components
  • QCSamp1
  • QCShip

StdAfx.h

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      Stdafx.h
00003   Summary:   Standard header
00004   Classes:   None
00005 -----------------------------------------------------------------------------
00006
00007 This file is part of the Microsoft COM+ Samples.
00008
00009 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00010
00011 This source code is intended only as a supplement to Microsoft
00012 Development Tools and/or on-line documentation. See these other
00013 materials for detailed information regarding Microsoft code samples.
00014
00015 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00018 PARTICULAR PURPOSE.
00019
00020 ==========================================================================+*/
00021
00022 #if !defined(AFX_STDAFX_H__6DD1E6D3_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_)
00023 #define AFX_STDAFX_H__6DD1E6D3_28C1_11D2_B5B6_00C04FC340EE__INCLUDED_
00024
00025 #if _MSC_VER >= 1000
00026 #pragma once
00027 #endif // _MSC_VER >= 1000
00028
00029 #define STRICT
00030
00031
00032 #define _WIN32_WINNT 0x0500
00033 #define _ATL_APARTMENT_THREADED
00034
00035
00036 #include <atlbase.h>
00037 //You may derive a class from CComModule and use it if you want to override
00038 //something, but do not change the name of _Module
00039 extern CComModule _Module;
00040 #include <atlcom.h>
00041
00042 //{{AFX_INSERT_LOCATION}}
00043 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
00044
00045 #include <crtdbg.h>
00046 #include <comsvcs.h>
00047 #include <stdlib.h>
00048 #include <vector>
00049 #include <comdef.h>
00050
00051 #endif // !defined(AFX_STDAFX_H__6DD1E6D3_28C1_11D2_B5B6_00C04FC340EE__INCLUDED)
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/Tapi/Tapi3/Cpp/tapisend/avifilereader.cpp Source File

  • NetDS
  • Tapi
  • Tapi3
  • Cpp
  • tapisend

avifilereader.cpp

Go to the documentation of this file.
00001 /*
00002
00003 Copyright (c) 1999 - 2000  Microsoft Corporation
00004
00005
00006 Module Name:
00007
00008     AVIFileReader.cpp
00009
00010
00011 Abstract:
00012
00013     Implementation of CAVIFileReader class
00014
00015 */
00016
00017 #include "common.h"
00018 #include "AVIFileReader.h"
00019
00020
00021 ///////////////////////////////////////////////////////////////////////////////
00022 //
00023 // CAVIFileReader::CAVIFileReader
00024 //
00025 ///////////////////////////////////////////////////////////////////////////////
00026
00027 CAVIFileReader::CAVIFileReader()
00028     :m_pAudioStream(NULL),
00029     m_pWaveFormat(NULL),
00030     m_nSamplesReadSoFar(0)
00031 {
00032     LogMessage("CAVIFileReader::CAVIFileReader");
00033 }
00034
00035
00036
00037 ///////////////////////////////////////////////////////////////////////////////
00038 //
00039 // CAVIFileReader::Initialize
00040 //
00041 // open the first audio stream contained in file pszFileName.
00042 // if successful, also get the stream's format
00043 //
00044 // if the file does not exist, is not valid, or does not contain
00045 // any audio streams, subsequent calls to Read() will fail
00046 //
00047 ///////////////////////////////////////////////////////////////////////////////
00048
00049 HRESULT CAVIFileReader::Initialize(IN char *pszFileName)
00050 {
00051
00052     HRESULT hr = S_OK;
00053
00054
00055     //
00056     // would do better argument checking in a real-life application
00057     //
00058
00059     _ASSERTE(pszFileName);
00060
00061
00062     //
00063     // log file name and requested wave format
00064     //
00065
00066     LogMessage("CAVIFileReader::Initialize started. file [%s]",
00067                 pszFileName);
00068
00069
00070     //
00071     // initialize avi file library. AVIFileExit should be called on the same
00072     // thread when AVI library is no longer needed
00073     //
00074     // AVIFileExit is called in the destructor.
00075     //
00076     // Assuption: instances of CAVIFileReader are initialized and destroyed on
00077     // the same thread
00078     //
00079
00080     AVIFileInit();
00081
00082
00083     //
00084     // open the first audio stream in the file
00085     //
00086
00087     hr = AVIStreamOpenFromFile(&m_pAudioStream,
00088                                pszFileName,
00089                                streamtypeAUDIO,
00090                                0,
00091                                OF_READ | OF_SHARE_DENY_WRITE,
00092                                NULL);
00093
00094     if (FAILED(hr))
00095     {
00096         LogError("CAVIFileReader::Initialize "
00097                  "Failed to open stream from the file");
00098
00099         m_pAudioStream = NULL;
00100
00101         return hr;
00102     }
00103
00104
00105     //
00106     // read the size of the stream's format
00107     //
00108
00109     LONG nFormatSize = 0;
00110
00111     hr = AVIStreamReadFormat(m_pAudioStream, 0, NULL, &nFormatSize);
00112
00113     if ( FAILED(hr) || (0 == nFormatSize) )
00114     {
00115         LogError("CAVIFileReader::Initialize"
00116                  "Failed to get stream format's size");
00117
00118         m_pAudioStream->Release();
00119         m_pAudioStream = NULL;
00120
00121         return E_FAIL;
00122     }
00123
00124
00125     //
00126     // allocate memory for audio format. keep it in a waveformatex structure.
00127     // if the structure returned is waveformat, still allocate waveformatex
00128     //
00129
00130     nFormatSize = max((LONG)sizeof(WAVEFORMATEX), nFormatSize);
00131
00132     m_pWaveFormat = (WAVEFORMATEX*)AllocateMemory(nFormatSize);
00133
00134     if (NULL == m_pWaveFormat)
00135     {
00136         LogError("CAVIFileReader::Initialize "
00137                  "Failed to allocate memory for wave format, size %ld",
00138                  nFormatSize);
00139
00140         m_pAudioStream->Release();
00141         m_pAudioStream = NULL;
00142
00143         return E_OUTOFMEMORY;
00144
00145     }
00146
00147
00148     //
00149     // read stream format into allocated structure
00150     //
00151
00152     hr = AVIStreamReadFormat(m_pAudioStream, 0, m_pWaveFormat, &nFormatSize);
00153
00154     if (FAILED(hr))
00155     {
00156         LogError("CAVIFileReader::Initialize "
00157                  "Failed to read stream format");
00158
00159         m_pAudioStream->Release();
00160         m_pAudioStream = NULL;
00161
00162         FreeMemory(m_pWaveFormat);
00163         m_pWaveFormat = NULL;
00164
00165         return hr;
00166     }
00167
00168
00169     //
00170     // log stream's format
00171     //
00172
00173     LogMessage("CAVIFileReader::CAVIFileReader stream opened");
00174     LogFormat(m_pWaveFormat);
00175
00176
00177     LogMessage("CAVIFileReader::CAVIFileReader finished");
00178
00179     return S_OK;
00180 }
00181
00182
00183 ///////////////////////////////////////////////////////////////////////////////
00184 //
00185 // CAVIFileReader::~CAVIFileReader
00186 //
00187 // if we succeeded opening the stream, close it now.
00188 //
00189 ///////////////////////////////////////////////////////////////////////////////
00190
00191 CAVIFileReader::~CAVIFileReader()
00192 {
00193     LogMessage("CAVIFileReader::~CAVIFileReader started");
00194
00195     if (NULL != m_pAudioStream)
00196     {
00197         AVIStreamRelease(m_pAudioStream);
00198         m_pAudioStream = NULL;
00199     }
00200
00201     if (NULL != m_pWaveFormat)
00202     {
00203         FreeMemory(m_pWaveFormat);
00204         m_pWaveFormat = NULL;
00205     }
00206
00207
00208     //
00209     // AVIFileExit must be called on the same thread as AVIFileInit.
00210     // therefore this object must be created and deleted on the same thread
00211     //
00212
00213     AVIFileExit();
00214
00215     LogMessage("CAVIFileReader::~CAVIFileReader completed");
00216 }
00217
00218
00219 ///////////////////////////////////////////////////////////////////////////////
00220 //
00221 // CAVIFileReader::Read
00222 //
00223 // read the open stream, at the current stream position,
00224 // into the supplied buffer of specified length.
00225 // return the number of bytes read
00226 //
00227 // returns: S_OK if succeded, S_FALSE if no more data, failure if failed.
00228 //
00229 ///////////////////////////////////////////////////////////////////////////////
00230
00231 HRESULT CAVIFileReader::Read( IN     BYTE *pBuffer,
00232                               IN     LONG nBufferSize,
00233                               IN OUT LONG *pBytesRead)
00234 {
00235
00236
00237     //
00238     // don't return garbage
00239     //
00240
00241     *pBytesRead = 0;
00242
00243
00244     //
00245     // fail if the file is not open
00246     //
00247
00248     if (NULL == m_pWaveFormat)
00249     {
00250
00251         //
00252         // file is not open
00253         //
00254
00255         LogError("CAVIFileReader::Read file is not open");
00256
00257         return E_FAIL;
00258     }
00259
00260
00261
00262     HRESULT hr = E_FAIL;
00263
00264
00265     //
00266     // read data into the user-supplied buffer, starting with the current
00267     // stream position
00268     //
00269
00270     LONG nSamplesRead = 0;
00271
00272     hr = AVIStreamRead(m_pAudioStream,
00273                         m_nSamplesReadSoFar,
00274                         AVISTREAMREAD_CONVENIENT,
00275                         pBuffer,
00276                         nBufferSize,
00277                         pBytesRead,
00278                         &nSamplesRead);
00279
00280     if (FAILED(hr))
00281     {
00282         LogError("CAVIFileReader::Read AVIStreamRead failed");
00283
00284         *pBytesRead = 0;
00285
00286         return hr;
00287     }
00288
00289
00290     //
00291     // keep track of how many samples we have read, so we know where
00292     // to start next time
00293     //
00294
00295     m_nSamplesReadSoFar += nSamplesRead;
00296
00297     if (*pBytesRead == 0)
00298     {
00299         LogMessage("CAVIFileReader::Read no more data in the file");
00300
00301         return S_FALSE;
00302     }
00303
00304
00305     LogMessage("CAVIFileReader::Read read %ld bytes (%ld samples)",
00306                 *pBytesRead, nSamplesRead);
00307
00308     return S_OK;
00309 }
00310
00311
00312 ///////////////////////////////////////////////////////////////////////////////
00313 //
00314 // CAVIFileReader::GetFormat
00315 //
00316 // returns the wave format structure. the caller is responsible for
00317 // freeing the structure by calling FreeMemory()
00318 //
00319 // returns S_OK if success or E_FAIL if the file failed to open
00320 //
00321 ///////////////////////////////////////////////////////////////////////////////
00322
00323 HRESULT CAVIFileReader::GetFormat(OUT WAVEFORMATEX **ppWaveFormat)
00324 {
00325
00326     HRESULT hr = E_FAIL;
00327
00328
00329     //
00330     // don't return garbage
00331     //
00332
00333     *ppWaveFormat = NULL;
00334
00335
00336     //
00337     // fail if the file is not open
00338     //
00339
00340     if (NULL == m_pWaveFormat)
00341     {
00342
00343         //
00344         // file is not open
00345         //
00346
00347         LogError("CAVIFileReader::GetFormat file is not open");
00348
00349         return E_FAIL;
00350     }
00351
00352
00353     //
00354     // allocate memory for wave format structure
00355     //
00356
00357     WAVEFORMATEX *pWaveFormat =
00358         (WAVEFORMATEX *)AllocateMemory( sizeof(WAVEFORMATEX) +
00359                                 m_pWaveFormat->cbSize);
00360
00361     if (NULL == pWaveFormat)
00362     {
00363
00364         LogError("CAVIFileReader::GetFormat "
00365                  "failed to allocate memory for wave format structure");
00366
00367         return E_OUTOFMEMORY;
00368     }
00369
00370
00371     //
00372     // copy wave format structure into allocated memory
00373     //
00374
00375     CopyMemory(pWaveFormat,
00376                m_pWaveFormat,
00377                sizeof(WAVEFORMATEX) + m_pWaveFormat->cbSize);
00378
00379     *ppWaveFormat = pWaveFormat;
00380
00381     return S_OK;
00382 }
Generated on Wed Nov 13 2024 16:52:24 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/iis/Components/Cpp/Simple/CatlSmpl.Idl Source File

  • Web
  • iis
  • Components
  • Cpp
  • Simple

CatlSmpl.Idl

Go to the documentation of this file.
00001 // CATLSmpl.idl : IDL source for CATLSmpl.dll
00002 //
00003
00004 // This file will be processed by the MIDL tool to
00005 // produce the type library (CATLSmpl.tlb) and marshalling code.
00006
00007     [
00008         object,
00009         uuid(61CECB2B-68D3-11D0-8AE3-00C0F00AE35A),
00010         dual,
00011         helpstring("ISimple Interface"),
00012         pointer_default(unique),
00013         oleautomation
00014     ]
00015     interface ISimple : IDispatch
00016     {
00017         import "oaidl.idl";
00018
00019         [propget, id(1), helpstring("Get MyProperty's value")]
00020         HRESULT myProperty([out,retval] BSTR* pbstrOutValue);
00021
00022         [propput, id(1), helpstring("Set MyProperty's value")]
00023         HRESULT myProperty([in] BSTR bstrInValue);
00024
00025         [id(2), helpstring("Convert argument to uppercase")]
00026         HRESULT myMethod([in] BSTR bstrIn, [out, retval] BSTR* pbstrOut);
00027     };
00028
00029
00030
00031 [
00032     uuid(61CECB29-68D3-11D0-8AE3-00C0F00AE35A),
00033     version(1.0),
00034     helpstring("IISSample CATLSmpl Object Library")
00035 ]
00036 library CATLSmpl
00037 {
00038     importlib("stdole32.tlb");
00039
00040     [
00041         uuid(61CECB2F-68D3-11D0-8AE3-00C0F00AE35A),
00042         helpstring("Simple Class")
00043     ]
00044     coclass CSimple
00045     {
00046         [default] interface ISimple;
00047     };
00048
00049 };
Generated on Wed Nov 13 2024 16:52:43 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Web/NetMeeting/NMUI/IMSConf2.Idl Source File

  • Web
  • NetMeeting
  • NMUI

IMSConf2.Idl

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright 1995 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 //  Contents:   Conferencing Services Object interfaces
00006 //
00007 //----------------------------------------------------------------------------
00008
00009 cpp_quote("//+-------------------------------------------------------------------------")
00010 cpp_quote("//")
00011 cpp_quote("//  Microsoft Windows")
00012 cpp_quote("//  Copyright 1995-1999 Microsoft Corporation. All Rights Reserved.")
00013 cpp_quote("//")
00014 cpp_quote("//  File: imsconf2.h")
00015 cpp_quote("//")
00016 cpp_quote("//--------------------------------------------------------------------------")
00017
00018 //////////////////////////////////////////////////////////////////////////////////
00019 // GUID usage:
00020 //
00021 // {068B0700-718C-11d0-8B1A-00A0C91BC90E} - {068B08FF-718C-11d0-8B1A-00A0C91BC90E}
00022 //
00023
00024 import "objidl.idl";
00025 import "oleidl.idl";
00026 import "oaidl.idl";
00027
00028 interface INmManager;
00029 interface INmManagerNotify;
00030 interface INmSysInfo;
00031 interface INmMember;
00032 interface INmCall;
00033 interface INmCallNotify;
00034 interface INmConference;
00035 interface INmConferenceNotify;
00036 interface INmChannel;
00037 interface INmChannelNotify;
00038 interface INmChannelData;
00039 interface INmChannelDataNotify;
00040 interface INmChannelFt;
00041 interface INmChannelFtNotify;
00042 interface INmChannelVideo;
00043 interface INmChannelVideoNotify;
00044 interface INmChannelAudio;
00045 interface INmChannelAudioNotify;
00046 interface INmChannelAppShare;
00047 interface INmChannelAppShareNotify;
00048 interface INmFt;
00049 interface INmSharableApp;
00050 interface IEnumNmConference;
00051 interface IEnumNmMember;
00052 interface IEnumNmChannel;
00053 interface IEnumNmCall;
00054 interface IEnumNmSharableApp;
00055
00056
00057 cpp_quote("")
00058 cpp_quote("////////////////////////////////////////////////////////////////////////////")
00059 cpp_quote("//")
00060 cpp_quote("// Constants")
00061 cpp_quote("")
00062
00063
00064 cpp_quote("// NetMeeting Channel Types")
00065 cpp_quote("#define NMCH_NONE                     0x00000000")
00066 cpp_quote("#define NMCH_DATA                     0x00000001")
00067 cpp_quote("#define NMCH_AUDIO                    0x00000002")
00068 cpp_quote("#define NMCH_VIDEO                    0x00000004")
00069 cpp_quote("#define NMCH_SHARE                    0x00000010")
00070 cpp_quote("#define NMCH_FT                       0x00000020")
00071 cpp_quote("#define NMCH_ALL                      0x0000FFFF")
00072 cpp_quote("#define NMCH_SECURE                   0x00010000")
00073
00074 cpp_quote("")
00075 cpp_quote("// Initialization options")
00076 cpp_quote("#define NM_INIT_NORMAL                0x00000000")
00077 cpp_quote("#define NM_INIT_CONTROL               0x00000001")
00078 cpp_quote("#define NM_INIT_NO_LAUNCH             0x00000002")
00079 cpp_quote("#define NM_INIT_BACKGROUND            0x00000005")
00080
00081 cpp_quote("")
00082 cpp_quote("// INmChannelDataNotify.DataReceived dwFlags")
00083 cpp_quote("#define NM_DF_BROADCAST               0x00000010") // data was broadcast to everyone
00084 cpp_quote("#define NM_DF_PRIVATE                 0x00000020") // data was private
00085 cpp_quote("#define NM_DF_SEGMENT_END             0x00000040") // end of data block
00086 cpp_quote("#define NM_DF_SEGMENT_BEGIN           0x00000080") // start of data block
00087
00088 cpp_quote("")
00089 cpp_quote("// Audio")
00090 cpp_quote("#define NM_MAX_AUDIO_LEVEL            0x0000FFFF")
00091
00092 cpp_quote("")
00093 cpp_quote("// Video")
00094 cpp_quote("#define NM_VIDEO_NO_AUTOSIZE          0x00000000")
00095 cpp_quote("#define NM_VIDEO_SMALL                0x00000001")
00096 cpp_quote("#define NM_VIDEO_MEDIUM               0x00000002")
00097 cpp_quote("#define NM_VIDEO_LARGE                0x00000004")
00098 cpp_quote("#define NM_VIDEO_MIN_QUALITY          0x00000000")
00099 cpp_quote("#define NM_VIDEO_MAX_QUALITY          0x0000001F")
00100 cpp_quote("#define NM_VIDEO_SOURCE_DIALOG        0x00000001")
00101 cpp_quote("#define NM_VIDEO_FORMAT_DIALOG        0x00000002")
00102
00103 cpp_quote("")
00104 cpp_quote("// Version Numbers")
00105 cpp_quote("#define NM_VER_UNKNOWN                0x00000000")
00106 cpp_quote("#define NM_VER_1                      0x00000001")
00107 cpp_quote("#define NM_VER_2                      0x00000002")
00108 cpp_quote("#define NM_VER_NetMeeting2_11         0x00000003")
00109 cpp_quote("#define NM_VER_NetMeeting3            0x00000004")
00110 cpp_quote("#define NM_VER_FUTURE                 0x0000000F")
00111 cpp_quote("")
00112
00113
00114 cpp_quote("")
00115 cpp_quote("// User Categories")
00116 cpp_quote("#define NM_CATEGORY_PERSONAL          0x00000001")
00117 cpp_quote("#define NM_CATEGORY_BUSINESS          0x00000002")
00118 cpp_quote("#define NM_CATEGORY_ADULT             0x00000004")
00119 cpp_quote("")
00120
00121 cpp_quote("")
00122 cpp_quote("////////////////////////////////////////////////////////////////////////////")
00123 cpp_quote("//  Error Codes")
00124 cpp_quote("")
00125 cpp_quote("#define NM_E(e) (0x81000000UL | (ULONG) (e))")
00126 cpp_quote("")
00127 cpp_quote("enum {")
00128
00129 cpp_quote("")
00130 cpp_quote("// NetMeeting specific error codes")
00131 cpp_quote("//")
00132 cpp_quote("  NM_S_NEXT_CONFERENCE          = ((ULONG) 0x0201),") // INmSysInfo.SetProperty
00133 cpp_quote("  NM_S_ON_RESTART               = ((ULONG) 0x0202),") // INmSysInfo.SetProperty
00134 cpp_quote("")
00135
00136 cpp_quote("")
00137 cpp_quote("// Call specific error codes")
00138 cpp_quote("//")
00139 cpp_quote("  NM_CALLERR_NOT_INITIALIZED    = NM_E(0x0100),") // Local system not initialized
00140 cpp_quote("  NM_CALLERR_MEDIA              = NM_E(0x0101),") // Invalid channel/media types
00141 cpp_quote("  NM_CALLERR_NAME_RESOLUTION    = NM_E(0x0102),") // Name resolution failed
00142 cpp_quote("  NM_CALLERR_PASSWORD           = NM_E(0x0103),") // Invalid conference password
00143 cpp_quote("  NM_CALLERR_CONFERENCE_NAME    = NM_E(0x0104),") // Problem with the conference name
00144 cpp_quote("  NM_CALLERR_IN_CONFERENCE      = NM_E(0x0105),") // Remote system is in a conference
00145 cpp_quote("  NM_CALLERR_NOT_FOUND          = NM_E(0x0106),") // User/Address not found
00146 cpp_quote("  NM_CALLERR_MCU                = NM_E(0x0107),") // Can't invite MCU into existing conference
00147 cpp_quote("  NM_CALLERR_REJECTED           = NM_E(0x0108),") // Remote system rejected the request
00148 cpp_quote("  NM_CALLERR_AUDIO              = NM_E(0x0109),") // Audio connection failed
00149 cpp_quote("  NM_CALLERR_AUDIO_LOCAL        = NM_E(0x010A),") // Local audio device already in use
00150 cpp_quote("  NM_CALLERR_AUDIO_REMOTE       = NM_E(0x010B),") // Remote audio device in use
00151 cpp_quote("  NM_CALLERR_ALREADY_CALLING    = NM_E(0x01FD),") // Already calling this person
00152 cpp_quote("  NM_CALLERR_LOOPBACK           = NM_E(0x01FE),") // Called Local Machine
00153 cpp_quote("  NM_CALLERR_UNKNOWN            = NM_E(0x01FF),") // Unknown call error
00154 cpp_quote("")
00155 cpp_quote("// other error codes")
00156 cpp_quote("//")
00157 cpp_quote("  NM_E_NOT_INITIALIZED          = NM_E(0x0200),") // INmManager not Initialized
00158 cpp_quote("  NM_E_CHANNEL_ALREADY_EXISTS   = NM_E(0x0201),") // Data channel already exists
00159 cpp_quote("  NM_E_NO_T120_CONFERENCE       = NM_E(0x0202),") // Not in a T.120 data conference
00160 cpp_quote("  NM_E_NOT_ACTIVE               = NM_E(0x0203),") // NetMeeting is not running
00161 cpp_quote("  NM_E_FILE_TOO_BIG             = NM_E(0x0204),") // The file we attempted to send is too big
00162 cpp_quote("  NM_E_USER_CANCELED_SETUP    = NM_E(0x0205),") // User canceled NetMeeting setup wizard
00163 cpp_quote("  NM_E_ALREADY_RUNNING      = NM_E(0x0206),") // This means that NetMeeting is already running
00164 cpp_quote("  NM_E_SHARING_NOT_AVAILABLE    = NM_E(0x0207),") // This means that Shring is not available
00165 cpp_quote("};")
00166 cpp_quote("")
00167
00168 typedef enum tagNmConferenceState{
00169     NM_CONFERENCE_IDLE                           = 0,
00170     NM_CONFERENCE_WAITING                        = 1,
00171     NM_CONFERENCE_INITIALIZING                   = 2,
00172     NM_CONFERENCE_ACTIVE                         = 3,
00173 } NM_CONFERENCE_STATE;
00174
00175 typedef enum tagNmCallType{
00176     NM_CALL_DEFAULT                              = 0,
00177     NM_CALL_T120                                 = 1,
00178     NM_CALL_H323                                 = 2,
00179 } NM_CALL_TYPE;
00180
00181 typedef enum tagNmAddrType{
00182     NM_ADDR_UNKNOWN                              = 0,
00183     NM_ADDR_IP                                   = 1,
00184     NM_ADDR_MACHINENAME                          = 2,
00185     NM_ADDR_PSTN                                 = 3,
00186     NM_ADDR_ULS                                  = 4,
00187     NM_ADDR_H323_GATEWAY                         = 5,
00188     NM_ADDR_CALLTO                               = 6,
00189     NM_ADDR_T120_TRANSPORT                       = 7,
00190 } NM_ADDR_TYPE;
00191
00192 typedef enum tagNmCallState{
00193     NM_CALL_INVALID                              = 0,
00194     NM_CALL_INIT                                 = 1,
00195     NM_CALL_RING                                 = 2,
00196     NM_CALL_SEARCH                               = 3,
00197     NM_CALL_WAIT                                 = 4,
00198     NM_CALL_ACCEPTED                             = 5,
00199     NM_CALL_REJECTED                             = 6,
00200     NM_CALL_CANCELED                             = 7,
00201 } NM_CALL_STATE;
00202
00203 typedef enum tagNmMemberNotify{
00204     NM_MEMBER_ADDED                              = 0,
00205     NM_MEMBER_REMOVED                            = 1,
00206     NM_MEMBER_UPDATED                            = 2,
00207 } NM_MEMBER_NOTIFY;
00208
00209 typedef enum tagNmChannelNotify{
00210     NM_CHANNEL_ADDED                             = 0,
00211     NM_CHANNEL_REMOVED                           = 1,
00212     NM_CHANNEL_UPDATED                           = 2,
00213 } NM_CHANNEL_NOTIFY;
00214
00215 typedef enum tagNmFtState{
00216     NM_FT_INVALID                                = 0,
00217     NM_FT_SENDING                                = 1,
00218     NM_FT_RECEIVING                              = 2,
00219     NM_FT_COMPLETE                               = 3,
00220 } NM_FT_STATE;
00221
00222 typedef enum tagNmAudioState{
00223     NM_AUDIO_IDLE                                = 0,
00224     NM_AUDIO_LOCAL_PAUSED                        = 1,
00225     NM_AUDIO_TRANSFERRING                        = 3,
00226 } NM_AUDIO_STATE;
00227
00228 typedef enum tagNmAudProp{
00229     NM_AUDPROP_LEVEL                             = 1,
00230     NM_AUDPROP_PAUSE                             = 2,
00231 } NM_AUDPROP;
00232
00233 typedef enum tagNmVideoState{
00234     NM_VIDEO_IDLE                                = 0,
00235     NM_VIDEO_LOCAL_PAUSED                        = 1,
00236     NM_VIDEO_PREVIEWING                          = 2,
00237     NM_VIDEO_TRANSFERRING                        = 3,
00238     NM_VIDEO_BOTH_PAUSED                         = 5,
00239     NM_VIDEO_REMOTE_PAUSED                       = 7,
00240 } NM_VIDEO_STATE;
00241
00242 typedef enum tagNmVidProp{
00243     NM_VIDPROP_PAUSE                             = 1,
00244     NM_VIDPROP_WINDOW_AUTO_SIZE                  = 2,
00245     NM_VIDPROP_WINDOW_SIZE                       = 3,
00246     NM_VIDPROP_WINDOW_POSITION                   = 4,
00247     NM_VIDPROP_WINDOW_TOP_MOST                   = 5,
00248     NM_VIDPROP_WINDOW_VISIBLE                    = 6,
00249     NM_VIDPROP_IMAGE_PREFERRED_SIZE              = 7,
00250     NM_VIDPROP_IMAGE_QUALITY                     = 8,
00251     NM_VIDPROP_CAMERA_DIALOG                     = 9,
00252 } NM_VIDPROP;
00253
00254 typedef enum tagNmShareState{
00255     NM_SHARE_UNKNOWN                             = 0,
00256     NM_SHARE_WORKING_ALONE                       = 1,
00257     NM_SHARE_COLLABORATING                       = 2,
00258     NM_SHARE_IN_CONTROL                          = 3,
00259 } NM_SHARE_STATE;
00260
00261 typedef enum tagNmShAppState{
00262     NM_SHAPP_NOT_SHARED                          = 0,
00263     NM_SHAPP_SHARED                              = 1,
00264 } NM_SHAPP_STATE;
00265
00266 typedef enum tagNmSysProp{
00267     NM_SYSPROP_EMAIL_NAME                        = 1,
00268     NM_SYSPROP_SERVER_NAME                       = 2,
00269     NM_SYSPROP_RESOLVE_NAME                      = 3,
00270     NM_SYSPROP_FIRST_NAME                        = 4,
00271     NM_SYSPROP_LAST_NAME                         = 5,
00272     NM_SYSPROP_USER_NAME                         = 6,
00273     NM_SYSPROP_USER_CITY                         = 7,
00274     NM_SYSPROP_USER_COUNTRY                      = 8,
00275     NM_SYSPROP_USER_COMMENTS                     = 9,
00276     NM_SYSPROP_USER_CATEGORY                     = 10,
00277     NM_SYSPROP_USER_PHONENUM                     = 11,
00278     NM_SYSPROP_USER_LOCATION                     = 12,
00279     NM_SYSPROP_H323_GATEWAY                      = 20,
00280     NM_SYSPROP_H323_GATEWAY_ENABLE               = 21,
00281     NM_SYSPROP_INSTALL_DIRECTORY                 = 50,
00282     NM_SYSPROP_APP_NAME                          = 51,
00283     NM_SYSPROP_LOGGED_ON                         = 69,
00284     NM_SYSPROP_IS_RUNNING                        = 100,
00285     NM_SYSPROP_IN_CONFERENCE                     = 101,
00286   NM_SYSPROP_BUILD_VER             = 200,
00287   NM_SYSPROP_DISABLE_H323            = 201,
00288   NM_SYSPROP_DISABLE_INITIAL_ILS_LOGON     = 202
00289 } NM_SYSPROP;
00290
00291 typedef enum tagConfn{
00292
00293 // File Transfer
00294     CONFN_FT_UI                                  = 0x000211,
00295     CONFN_FT_OFFERED                             = 0x000212,
00296     CONFN_FT_STARTED                             = 0x000213,
00297     CONFN_FT_PROGRESS                            = 0x000214,
00298     CONFN_FT_COMPLETE                            = 0x000215,
00299     CONFN_FT_CANCELED                            = 0x000216,
00300 // Sharing
00301     CONFN_CLICK_CONTROL                          = 0x000220,
00302     CONFN_CLICK_OBSCURE                          = 0x000221,
00303     CONFN_CLICK_REMOTE_NOT_COLLABORATING         = 0x000222,
00304     CONFN_CLICK_LOCAL_NOT_COLLABORATING          = 0x000223,
00305
00306 // Call control
00307     CONFN_CALL_INCOMPATIBLE                      = 0x000400,
00308     CONFN_CALL_OLDER                             = 0x000401,
00309     CONFN_CALL_NEWER                             = 0x000402,
00310     CONFN_CALL_IGNORED                           = 0x000403,
00311     CONFN_CALL_FAILED                            = 0x000404,
00312     CONFN_CALL_IN_CONFERENCE                     = 0x000405,
00313
00314 // Manager notifications
00315     CONFN_NM_STARTED                             = 0x000600,
00316     CONFN_NM_STOPPED                             = 0x000601,
00317
00318 } CONFN;
00319
00320
00321
00322 // INmObject constants
00323 typedef enum NM_APPID {
00324   NM_APPID_CHAT       = 1,
00325   NM_APPID_WHITEBOARD     = 2,
00326   NM_APPID_T126_WHITEBOARD  = 3,
00327   NM_APPID_FILE_TRANSFER    = 4,
00328   NM_APPID_APPSHARING     = 5
00329
00330 } NM_APPID;
00331
00332 typedef enum NM_VUI {
00333   NM_VUI_CHECK = 0,
00334   NM_VUI_SHOW = 1
00335 } NM_VUI;
00336
00337 //--------------------------------------------------------------------------
00338 // INmManager Interface
00339 [
00340     object,
00341     uuid(068B0701-718C-11d0-8B1A-00A0C91BC90E),
00342     pointer_default(unique)
00343 ]
00344 interface INmManager : IUnknown
00345 {
00346     typedef [unique] INmManager *LPNMMANAGER;
00347
00348   [local]
00349     HRESULT Initialize(
00350         [in, out] ULONG * puOptions, // Can be NULL
00351         [in, out] ULONG * puchCaps); // Can be NULL
00352
00353   [call_as(Initialize)]
00354   HRESULT RemoteInitialize(
00355     [in, out] ULONG * puOptions,
00356         [in, out] ULONG * puchCaps);
00357
00358     HRESULT GetSysInfo(
00359         [out] INmSysInfo **ppSysInfo);
00360
00361     HRESULT EnumConference(
00362         [out] IEnumNmConference **ppEnum);
00363
00364   [local]
00365     HRESULT CreateConference(
00366         [out] INmConference **ppConference,
00367         [in] BSTR bstrName,
00368         [in] BSTR bstrPassword,
00369         [in] ULONG uchCaps);
00370
00371   [call_as(CreateConference)]
00372     HRESULT RemoteCreateConference(
00373         [out] INmConference **ppConference,
00374         [in] BSTR bstrName,
00375         [in] BSTR bstrPassword,
00376         [in] ULONG uchCaps);
00377
00378
00379     HRESULT EnumCall(
00380         [out] IEnumNmCall **ppEnum);
00381
00382   [local]
00383     HRESULT CreateCall(
00384         [out] INmCall **ppCall,   // Can be NULL
00385         [in] NM_CALL_TYPE callType,
00386         [in] NM_ADDR_TYPE addrType,
00387         [in] BSTR bstrAddr,
00388         [in] INmConference * pConference);
00389
00390   [call_as(CreateCall)]
00391     HRESULT RemoteCreateCall(
00392         [out] INmCall **ppCall,
00393         [in] NM_CALL_TYPE callType,
00394         [in] NM_ADDR_TYPE addrType,
00395         [in] BSTR bstrAddr,
00396         [in] INmConference * pConference);
00397
00398   [local]
00399     HRESULT CallConference(
00400         [out] INmCall **ppCall,
00401         [in] NM_CALL_TYPE callType,
00402         [in] NM_ADDR_TYPE addrType,
00403         [in] BSTR bstrAddr,
00404         [in] BSTR bstrName,
00405         [in] BSTR bstrPassword);
00406
00407   [call_as(CallConference)]
00408     HRESULT RemoteCallConference(
00409         [out] INmCall **ppCall,
00410         [in] NM_CALL_TYPE callType,
00411         [in] NM_ADDR_TYPE addrType,
00412         [in] BSTR bstrAddr,
00413         [in] BSTR bstrName,
00414         [in] BSTR bstrPassword);
00415
00416 }
00417
00418 //--------------------------------------------------------------------------
00419 // INmManagerNotify Interface
00420 [
00421     object,
00422     uuid(068B0702-718C-11d0-8B1A-00A0C91BC90E),
00423     pointer_default(unique)
00424 ]
00425 interface INmManagerNotify : IUnknown
00426 {
00427     typedef [unique] INmManagerNotify *LPNMMANAGERNOTIFY;
00428
00429     HRESULT NmUI(
00430         [in] CONFN uNotify);
00431
00432     HRESULT ConferenceCreated(
00433         [in] INmConference *pConference);
00434
00435     HRESULT CallCreated(
00436         [in] INmCall *pCall);
00437 }
00438
00439
00440 //--------------------------------------------------------------------------
00441 // INmSysInfo Interface
00442 [
00443   local,
00444     object,
00445     uuid(068B0703-718C-11d0-8B1A-00A0C91BC90E),
00446     pointer_default(unique)
00447 ]
00448 interface INmSysInfo : IUnknown
00449 {
00450     typedef [unique] INmSysInfo *LPNMSYSINFO;
00451
00452     HRESULT IsInstalled(
00453         void);
00454
00455     HRESULT GetProperty(
00456         [in] NM_SYSPROP uProp,
00457         [out] BSTR *pbstrName);
00458
00459     HRESULT SetProperty(
00460         [in] NM_SYSPROP uProp,
00461         [in] BSTR bstrName);
00462
00463     HRESULT GetUserData(
00464         [in] REFGUID rguid,
00465         [out] BYTE **ppb,
00466         [out] ULONG *pcb);
00467
00468     HRESULT SetUserData(
00469         [in] REFGUID rguid,
00470         [in] BYTE *pb,
00471         [in] ULONG cb);
00472
00473     HRESULT GetNmApp(
00474         [in] REFGUID rguid,
00475         [out] BSTR *pbstrApplication,
00476         [out] BSTR *pbstrCommandLine,
00477         [out] BSTR *pbstrDirectory);
00478
00479     HRESULT SetNmApp(
00480         [in] REFGUID rguid,
00481         [in] BSTR bstrApplication,
00482         [in] BSTR bstrCommandLine,
00483         [in] BSTR bstrDirectory);
00484
00485     HRESULT GetNmchCaps(
00486         [out] ULONG *pchCaps);
00487
00488     HRESULT GetLaunchInfo(
00489         [out] INmConference **ppConference, // Can be NULL
00490         [out] INmMember **ppMember);    // Can be NULL
00491
00492 }
00493
00494
00495 //--------------------------------------------------------------------------
00496 // INmCall Interface
00497 [
00498     object,
00499     uuid(068B0704-718C-11d0-8B1A-00A0C91BC90E),
00500     pointer_default(unique)
00501 ]
00502 interface INmCall : IUnknown
00503 {
00504     typedef [unique] INmCall *LPNMCALL;
00505
00506     HRESULT IsIncoming(
00507         void);
00508
00509     HRESULT GetState(
00510         [out] NM_CALL_STATE *pState);
00511
00512     HRESULT GetName(
00513         [out] BSTR *pbstrName);
00514
00515     HRESULT GetAddr(
00516         [out] BSTR *pbstrAddr,
00517         [out] NM_ADDR_TYPE *puType);
00518
00519     HRESULT GetUserData(
00520         [in] REFGUID rguid,
00521         [out, size_is(,*pcb)] BYTE **ppb,
00522         [out] ULONG *pcb);
00523
00524     HRESULT GetConference(
00525         [out] INmConference **ppConference);
00526
00527     HRESULT Accept(
00528         void);
00529
00530     HRESULT Reject(
00531         void);
00532
00533     HRESULT Cancel(
00534         void);
00535 }
00536
00537 //--------------------------------------------------------------------------
00538 // INmCallNotify Interface
00539 [
00540     object,
00541     uuid(068B0705-718C-11d0-8B1A-00A0C91BC90E),
00542     pointer_default(unique)
00543 ]
00544 interface INmCallNotify : IUnknown
00545 {
00546     HRESULT NmUI(
00547         [in] CONFN uNotify);
00548
00549     HRESULT StateChanged(
00550         [in] NM_CALL_STATE uState);
00551
00552     HRESULT Failed(
00553         [in] ULONG uError);
00554
00555     HRESULT Accepted(
00556         [in] INmConference *pConference);
00557 }
00558
00559 //--------------------------------------------------------------------------
00560 // INmConference Interface
00561 [
00562     object,
00563     uuid(068B0710-718C-11d0-8B1A-00A0C91BC90E),
00564     pointer_default(unique)
00565 ]
00566 interface INmConference : IUnknown
00567 {
00568     typedef [unique] INmConference *LPNMCONFERENCE;
00569
00570     HRESULT GetName(
00571         [out] BSTR *pbstrName);
00572
00573     HRESULT GetID(
00574         [out] ULONG *puID);
00575
00576     HRESULT GetState(
00577         [out] NM_CONFERENCE_STATE *pState);
00578
00579     HRESULT GetNmchCaps(
00580         [out] ULONG *puchCaps);
00581
00582     HRESULT GetTopProvider(
00583         [out] INmMember **ppMember);
00584
00585     HRESULT EnumMember(
00586         [out] IEnumNmMember **ppEnum);
00587
00588     HRESULT GetMemberCount(
00589         [out] ULONG * puCount);
00590
00591     HRESULT EnumChannel(
00592         [out] IEnumNmChannel **ppEnum);
00593
00594     HRESULT GetChannelCount(
00595         [out] ULONG * puCount);
00596
00597   [local]
00598     HRESULT CreateDataChannel(
00599         [out] INmChannelData **ppChannel, // Can be NULL
00600         [in] REFGUID rguid);
00601
00602   [call_as(CreateDataChannel)]
00603     HRESULT RemoteCreateDataChannel(
00604         [out] INmChannelData **ppChannel,
00605         [in] REFGUID rguid);
00606
00607
00608     HRESULT IsHosting(
00609         void);
00610
00611     HRESULT Host(
00612         void);
00613
00614     HRESULT Leave(
00615         void);
00616
00617     HRESULT LaunchRemote(
00618         [in] REFGUID rguid,
00619         [in] INmMember *pMember);
00620 }
00621
00622 //--------------------------------------------------------------------------
00623 // INmConferenceNotify Interface
00624 [
00625     object,
00626     uuid(068B0711-718C-11d0-8B1A-00A0C91BC90E),
00627     pointer_default(unique)
00628 ]
00629 interface INmConferenceNotify : IUnknown
00630 {
00631     HRESULT NmUI(
00632         [in] CONFN uNotify);
00633
00634     HRESULT StateChanged(
00635         [in] NM_CONFERENCE_STATE uState);
00636
00637     HRESULT MemberChanged(
00638         [in] NM_MEMBER_NOTIFY uNotify,
00639         [in] INmMember *pMember);
00640
00641     HRESULT ChannelChanged(
00642         [in] NM_CHANNEL_NOTIFY uNotify,
00643         [in] INmChannel *pChannel);
00644 }
00645
00646 //--------------------------------------------------------------------------
00647 // INmMember Interface
00648 [
00649     object,
00650     uuid(068B0712-718C-11d0-8B1A-00A0C91BC90E),
00651     pointer_default(unique)
00652 ]
00653 interface INmMember : IUnknown
00654 {
00655     HRESULT GetName(
00656         [out] BSTR *pbstrName);
00657
00658     HRESULT GetID(
00659         [out] ULONG *puID);
00660
00661     HRESULT GetNmVersion(
00662         [out] ULONG *puVersion);
00663
00664     HRESULT GetAddr(
00665         [out] BSTR *pbstrAddr,
00666         [out] NM_ADDR_TYPE *puType);
00667
00668     HRESULT GetUserData(
00669         [in] REFGUID rguid,
00670         [out, size_is(,*pcb)] BYTE **ppb,
00671         [out] ULONG *pcb);
00672
00673     HRESULT GetConference(
00674         [out] INmConference **ppConference);
00675
00676     HRESULT GetNmchCaps(
00677         [out] ULONG *puchCaps);
00678
00679     HRESULT GetShareState(
00680         [out] NM_SHARE_STATE *puState);
00681
00682     HRESULT IsSelf(
00683         void);
00684
00685     HRESULT IsMCU(
00686         void);
00687
00688     HRESULT Eject(
00689         void);
00690 }
00691
00692
00693 //--------------------------------------------------------------------------
00694 // INmChannel Interface
00695 [
00696     object,
00697     uuid(068B0720-718C-11d0-8B1A-00A0C91BC90E),
00698     pointer_default(unique)
00699 ]
00700 interface INmChannel : IUnknown
00701 {
00702     HRESULT IsSameAs(
00703         [in] INmChannel *pChannel);
00704
00705     HRESULT IsActive(
00706         void);
00707
00708     HRESULT SetActive(
00709         [in] BOOL fActive);
00710
00711     HRESULT GetConference(
00712         [out] INmConference **ppConference);
00713
00714     HRESULT GetInterface(
00715         [out] IID *piid);
00716
00717     HRESULT GetNmch(
00718         [out] ULONG *puCh);
00719
00720     HRESULT EnumMember(
00721         [out] IEnumNmMember **ppEnum);
00722
00723     HRESULT GetMemberCount(
00724         [out] ULONG * puCount);
00725 }
00726
00727
00728 //--------------------------------------------------------------------------
00729 // INmChannelNotify Interface
00730 [
00731     object,
00732     uuid(068B0721-718C-11d0-8B1A-00A0C91BC90E),
00733     pointer_default(unique)
00734 ]
00735 interface INmChannelNotify : IUnknown
00736 {
00737     HRESULT NmUI(
00738         [in] CONFN uNotify);
00739
00740     HRESULT MemberChanged(
00741         [in] NM_MEMBER_NOTIFY uNotify,
00742         [in] INmMember *pMember);
00743 }
00744
00745
00746 //--------------------------------------------------------------------------
00747 // INmChannelData Interface
00748 [
00749     object,
00750     uuid(068B0722-718C-11d0-8B1A-00A0C91BC90E),
00751     pointer_default(unique)
00752 ]
00753 interface INmChannelData : INmChannel
00754 {
00755     HRESULT GetGuid(
00756         [out] GUID *pguid);
00757
00758     HRESULT SendData(
00759         [in] INmMember *pMember,
00760         [in] ULONG uSize,
00761         [in, size_is(uSize)] byte *pvBuffer,
00762         [in] ULONG uOptions);
00763 }
00764
00765
00766 //--------------------------------------------------------------------------
00767 // INmChannelDataNotify Interface
00768 [
00769     object,
00770     uuid(068B0723-718C-11d0-8B1A-00A0C91BC90E),
00771     pointer_default(unique)
00772 ]
00773 interface INmChannelDataNotify : INmChannelNotify
00774 {
00775     HRESULT DataSent(
00776         [in] INmMember *pMember,
00777         [in] ULONG uSize,
00778         [in, size_is(uSize)] byte *pvBuffer);
00779
00780     HRESULT DataReceived(
00781         [in] INmMember *pMember,
00782         [in] ULONG uSize,
00783         [in, size_is(uSize)] byte *pvBuffer,
00784         [in] ULONG dwFlags);
00785 }
00786
00787
00788 //--------------------------------------------------------------------------
00789 // INmChannelAudio Interface
00790 [
00791     object,
00792     uuid(068B0724-718C-11d0-8B1A-00A0C91BC90E),
00793     pointer_default(unique)
00794 ]
00795 interface INmChannelAudio : INmChannel
00796 {
00797     HRESULT IsIncoming(
00798         void);
00799
00800     HRESULT GetState(
00801         [out] NM_AUDIO_STATE *puState);
00802
00803     HRESULT GetProperty(
00804         [in] NM_AUDPROP uID,
00805         [out] ULONG *puValue);
00806
00807     HRESULT SetProperty(
00808         [in] NM_AUDPROP uID,
00809         [in] ULONG uValue);
00810 }
00811
00812 //--------------------------------------------------------------------------
00813 // INmChannelAudioNotify Interface
00814 [
00815     object,
00816     uuid(068B0725-718C-11d0-8B1A-00A0C91BC90E),
00817     pointer_default(unique)
00818 ]
00819 interface INmChannelAudioNotify : INmChannelNotify
00820 {
00821     HRESULT StateChanged(
00822         [in] NM_AUDIO_STATE uState);
00823
00824     HRESULT PropertyChanged(
00825         [in] DWORD dwReserved);
00826 }
00827
00828
00829 //--------------------------------------------------------------------------
00830 // INmChannelVideo Interface
00831 [
00832     object,
00833     uuid(068B0726-718C-11d0-8B1A-00A0C91BC90E),
00834     pointer_default(unique)
00835 ]
00836 interface INmChannelVideo : INmChannel
00837 {
00838     HRESULT IsIncoming(
00839         void);
00840
00841     HRESULT GetState(
00842         [out] NM_VIDEO_STATE *puState);
00843
00844     HRESULT GetProperty(
00845         [in] NM_VIDPROP uID,
00846         [out] ULONG *puValue);
00847
00848     HRESULT SetProperty(
00849         [in] NM_VIDPROP uID,
00850         [in] ULONG uValue);
00851 }
00852
00853
00854 //--------------------------------------------------------------------------
00855 // INmChannelVideoNotify Interface
00856 [
00857     object,
00858     uuid(068B0727-718C-11d0-8B1A-00A0C91BC90E),
00859     pointer_default(unique)
00860 ]
00861 interface INmChannelVideoNotify : INmChannelNotify
00862 {
00863     HRESULT StateChanged(
00864         [in] NM_VIDEO_STATE uState);
00865
00866     HRESULT PropertyChanged(
00867         [in] DWORD dwReserved);
00868 }
00869
00870
00871
00872
00873 //--------------------------------------------------------------------------
00874 // INmChannelFt Interface
00875 [
00876     object,
00877     uuid(068B0728-718C-11d0-8B1A-00A0C91BC90E),
00878     pointer_default(unique)
00879 ]
00880 interface INmChannelFt : INmChannel
00881 {
00882   [local]
00883     HRESULT SendFile(
00884         [out] INmFt **ppFt,     // Can be NULL
00885         [in] INmMember *pMember,
00886         [in] BSTR bstrFile,
00887         [in] ULONG uOptions);
00888
00889   [call_as(SendFile)]
00890     HRESULT RemoteSendFile(
00891         [out] INmFt **ppFt,
00892         [in] INmMember *pMember,
00893         [in] BSTR bstrFile,
00894         [in] ULONG uOptions);
00895
00896
00897   [local]
00898     HRESULT SetReceiveFileDir(
00899         [in] BSTR bstrDir);
00900
00901   [call_as(SetReceiveFileDir)]
00902     HRESULT RemoteSetReceiveFileDir(
00903         [in] BSTR bstrDir);
00904
00905     HRESULT GetReceiveFileDir(
00906         [out] BSTR *pbstrDir);
00907 }
00908
00909
00910 //--------------------------------------------------------------------------
00911 // INmChannelFtNotify Interface
00912 [
00913     object,
00914     uuid(068B0729-718C-11d0-8B1A-00A0C91BC90E),
00915     pointer_default(unique)
00916 ]
00917 interface INmChannelFtNotify : INmChannelNotify
00918 {
00919     HRESULT FtUpdate(
00920         [in] CONFN uNotify,
00921         [in] INmFt *pFt);
00922 }
00923
00924
00925 //--------------------------------------------------------------------------
00926 // INmFt Interface
00927 [
00928     object,
00929     uuid(068B0732-718C-11d0-8B1A-00A0C91BC90E),
00930     pointer_default(unique)
00931 ]
00932 interface INmFt : IUnknown
00933 {
00934     HRESULT IsIncoming(
00935         void);
00936
00937     HRESULT GetState(
00938         [out] NM_FT_STATE *puState);
00939
00940     HRESULT GetName(
00941         [out] BSTR *pbstrName);
00942
00943     HRESULT GetSize(
00944         [out] ULONG *puBytes);
00945
00946     HRESULT GetBytesTransferred(
00947         [out] ULONG *puBytes);
00948
00949     HRESULT GetMember(
00950         [out] INmMember **ppMember);
00951
00952     HRESULT Cancel(
00953         void);
00954 }
00955
00956
00957 //--------------------------------------------------------------------------
00958 // INmChannelAppShare Interface
00959 [
00960     object,
00961     uuid(068B072A-718C-11d0-8B1A-00A0C91BC90E),
00962     pointer_default(unique)
00963 ]
00964 interface INmChannelAppShare : INmChannel
00965 {
00966     HRESULT GetState(
00967         [out] NM_SHARE_STATE *puState);
00968
00969     HRESULT SetState(
00970         [in] NM_SHARE_STATE uState);
00971
00972     HRESULT EnumSharableApp(
00973         [out] IEnumNmSharableApp **ppEnum);
00974 }
00975
00976 //--------------------------------------------------------------------------
00977 // INmChannelAppShareNotify Interface
00978 [
00979     object,
00980     uuid(068B072B-718C-11d0-8B1A-00A0C91BC90E),
00981     pointer_default(unique)
00982 ]
00983 interface INmChannelAppShareNotify : INmChannelNotify
00984 {
00985     HRESULT StateChanged(
00986         [in] NM_SHAPP_STATE uState,
00987         [in] INmSharableApp *pApp);
00988 }
00989
00990
00991 //--------------------------------------------------------------------------
00992 // INmSharableApp Interface
00993 [
00994     object,
00995     uuid(068B0734-718C-11d0-8B1A-00A0C91BC90E),
00996     pointer_default(unique)
00997 ]
00998 interface INmSharableApp : IUnknown
00999 {
01000     HRESULT GetName(
01001         [out] BSTR *pbstrName);
01002
01003     HRESULT GetHwnd(
01004         [out] HWND * phwnd);
01005
01006      HRESULT GetState(
01007         [out] NM_SHAPP_STATE *puState);
01008
01009      HRESULT SetState(
01010         [in] NM_SHAPP_STATE uState);
01011 }
01012
01013
01014
01015 cpp_quote("")
01016 cpp_quote("////////////////////////////////////////////////////////////////////////////")
01017 cpp_quote("//  Enumerator Definitions")
01018
01019
01020 //--------------------------------------------------------------------------
01021 // IEnumNmConference Interface
01022 [
01023     object,
01024     uuid(068B0741-718C-11d0-8B1A-00A0C91BC90E),
01025     pointer_default(unique)
01026 ]
01027 interface IEnumNmConference : IUnknown
01028 {
01029   [local]
01030     HRESULT Next(
01031         [in] ULONG cConference,
01032         [out] INmConference **rgpConference,
01033         [out] ULONG *pcFetched);
01034
01035   [call_as(Next)]
01036     HRESULT RemoteNext(
01037         [in] ULONG cConference,
01038         [out, size_is(cConference), length_is(*pcFetched) ] INmConference **rgpConference,
01039         [out] ULONG *pcFetched,
01040     [out] ULONG *pcItems,
01041     [in] BOOL bGetNumberRemaining);
01042
01043     HRESULT Skip(
01044         [in] ULONG cConference);
01045
01046     HRESULT Reset();
01047
01048     HRESULT Clone(
01049         [out] IEnumNmConference **ppEnum);
01050 }
01051
01052
01053 //--------------------------------------------------------------------------
01054 // IEnumNmMember Interface
01055 [
01056     object,
01057     uuid(068B0742-718C-11d0-8B1A-00A0C91BC90E),
01058     pointer_default(unique)
01059 ]
01060 interface IEnumNmMember : IUnknown
01061 {
01062   [local]
01063     HRESULT Next(
01064         [in] ULONG cMember,
01065         [out] INmMember **rgpMember,
01066         [out] ULONG *pcFetched);
01067
01068   [call_as(Next)]
01069     HRESULT RemoteNext(
01070         [in] ULONG cMember,
01071         [out, size_is(cMember), length_is(*pcFetched) ] INmMember **rgpMember,
01072         [out] ULONG *pcFetched,
01073     [out] ULONG *pcItems,
01074     [in] BOOL bGetNumberRemaining);
01075
01076     HRESULT Skip(
01077         [in] ULONG cMember);
01078
01079     HRESULT Reset();
01080
01081     HRESULT Clone(
01082         [out] IEnumNmMember **ppEnum);
01083 }
01084
01085
01086 //--------------------------------------------------------------------------
01087 // IEnumNmChannel Interface
01088 [
01089     object,
01090     uuid(068B0743-718C-11d0-8B1A-00A0C91BC90E),
01091     pointer_default(unique)
01092 ]
01093 interface IEnumNmChannel : IUnknown
01094 {
01095   [local]
01096     HRESULT Next(
01097         [in] ULONG cChannel,
01098         [out, size_is(cChannel), length_is(*pcFetched)] INmChannel **rgpChannel,
01099         [out] ULONG *pcFetched);
01100
01101   [call_as(Next)]
01102     HRESULT RemoteNext(
01103         [in] ULONG cChannel,
01104         [out, size_is(cChannel), length_is(*pcFetched)] INmChannel **rgpChannel,
01105         [out] ULONG *pcFetched,
01106     [out] ULONG *pcItems,
01107     [in] BOOL bGetNumberRemaining);
01108
01109     HRESULT Skip(
01110         [in] ULONG cChannel);
01111
01112     HRESULT Reset();
01113
01114     HRESULT Clone(
01115         [out] IEnumNmChannel **ppEnum);
01116 }
01117
01118
01119 //--------------------------------------------------------------------------
01120 // IEnumNmCall Interface
01121 [
01122     object,
01123     uuid(068B0744-718C-11d0-8B1A-00A0C91BC90E),
01124     pointer_default(unique)
01125 ]
01126 interface IEnumNmCall : IUnknown
01127 {
01128   [local]
01129   HRESULT Next(
01130         [in] ULONG cCall,
01131         [out] INmCall **rgpCall,
01132         [out] ULONG *pcFetched);
01133
01134   [call_as(Next)]
01135     HRESULT RemoteNext(
01136         [in] ULONG cCall,
01137         [out, size_is(cCall), length_is(*pcFetched)] INmCall **rgpCall,
01138         [out] ULONG *pcFetched,
01139     [out] ULONG *pcItems,
01140     [in] BOOL bGetNumberRemaining);
01141
01142     HRESULT Skip(
01143         [in] ULONG cCall);
01144
01145     HRESULT Reset();
01146
01147     HRESULT Clone(
01148         [out] IEnumNmCall **ppEnum);
01149 }
01150
01151
01152 //--------------------------------------------------------------------------
01153 // IEnumNmSharableApp Interface
01154 [
01155     object,
01156     uuid(068B0745-718C-11d0-8B1A-00A0C91BC90E),
01157     pointer_default(unique)
01158 ]
01159 interface IEnumNmSharableApp : IUnknown
01160 {
01161   [local]
01162     HRESULT Next(
01163         [in] ULONG cApp,
01164         [out] INmSharableApp **rgpApp,
01165         [out] ULONG *pcFetched);
01166
01167   [call_as(Next)]
01168     HRESULT RemoteNext(
01169         [in] ULONG cApp,
01170         [out, size_is(cApp), length_is(*pcFetched)] INmSharableApp **rgpApp,
01171         [out] ULONG *pcFetched,
01172     [out] ULONG *pcItems,
01173     [in] BOOL bGetNumberRemaining);
01174
01175     HRESULT Skip(
01176         [in] ULONG cApp);
01177
01178     HRESULT Reset();
01179
01180     HRESULT Clone(
01181         [out] IEnumNmSharableApp **ppEnum);
01182 }
01183
01184 [
01185   object,
01186   uuid(068B0780-718C-11d0-8B1A-00A0C91BC90E), // IID_INmObject
01187   pointer_default(unique)
01188 ]
01189 interface INmObject : IUnknown
01190 {
01191   HRESULT CallDialog([in] long hwnd, [in] int options);
01192
01193   HRESULT ShowLocal([in] NM_APPID appId);
01194
01195   [local]
01196   HRESULT VerifyUserInfo([in] long hwnd, [in] NM_VUI options);
01197
01198   [call_as(VerifyUserInfo)]
01199   HRESULT RemoteVerifyUserInfo([in] long hwnd, [in] NM_VUI options);
01200
01201 };
01202
01203 [
01204     uuid(068B07FF-718C-11d0-8B1A-00A0C91BC90E),
01205     version(1.0),
01206     helpstring("NmManager 2.0 Type Library")
01207 ]
01208 library NmManager
01209 {
01210
01211     [
01212         uuid(068B0700-718C-11d0-8B1A-00A0C91BC90E),
01213         helpstring("NetMeeting Manager")
01214     ]
01215     coclass NmManager
01216     {
01217         [default] interface INmManager;
01218     };
01219 };
Generated on Wed Nov 13 2024 16:52:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CContextPlugin Member List

This is the complete list of members for CContextPlugin, including all inherited members.
CContextPlugin() | CContextPlugin |
CreateArrayOfEvents(VARIANT *pvarEvents, WMS_EVENT_TYPE *pWMSEvents, long nNumEvents) | CContextPlugin | [private]
DisablePlugin() | CContextPlugin |
DumpContextInformation(LPCWSTR wstrEventType, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandContext) | CContextPlugin | [private]
EnablePlugin(long *pdwFlags, long *pdwHeartbeatPeriod) | CContextPlugin |
GetContextTypes(WMS_CONTEXT_PLUGIN_CONTEXT_TYPE *wmsContexts) | CContextPlugin | [inline]
GetCustomAdminInterface(IDispatch **ppValue) | CContextPlugin |
GetHandledEvents(VARIANT *pvarHandledEvents) | CContextPlugin |
GetOutputPath(BSTR *pbstrOutputPath) | CContextPlugin |
InitializePlugin(IWMSContext *pServerContext, IWMSNamedValues *pNamedValues, IWMSClassObject *pClassFactory) | CContextPlugin |
LoadConfigValues() | CContextPlugin | [private]
m_bstrOutputPath | CContextPlugin | [private]
m_pNamedValues | CContextPlugin | [private]
m_pServer | CContextPlugin | [private]
m_wmsContexts | CContextPlugin | [private]
OnEvent(WMS_EVENT *pEvent, IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin |
OnHeartbeat() | CContextPlugin |
OnNotifyBeginUserSession(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyCache(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyClose(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyConnect(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyCreateDistributionDataPath(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyDescribe(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyDestroyDistributionDataPath(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyDisconnect(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyEndUserSession(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyGetParameter(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyLimitChange(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyLimitHit(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyLog(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyOpen(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyPause(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyPlay(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyPlaylist(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyPlugin(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyPublishingPoint(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyRemoteCacheClose(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyRemoteCacheLog(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyRemoteCacheOpen(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifySelectStreams(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyServer(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifySetParameter(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyStop(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
OnNotifyValidatePushDistribution(IWMSContext *pUserCtx, IWMSContext *pPresentationCtx, IWMSCommandContext *pCommandCtx) | CContextPlugin | [private]
s_CommandContextHintValues | CContextPlugin | [private, static]
s_PresentationContextHintValues | CContextPlugin | [private, static]
s_UserContextHintValues | CContextPlugin | [private, static]
s_wstrNamedValueContextTypes | CContextPlugin | [private, static]
s_wstrNamedValueOutputPath | CContextPlugin | [private, static]
SaveConfigValues() | CContextPlugin | [private]
SetContextTypes(WMS_CONTEXT_PLUGIN_CONTEXT_TYPE wmsContexts) | CContextPlugin | [inline]
SetOutputPath(BSTR bstrOutputPath) | CContextPlugin |
ShutdownPlugin() | CContextPlugin |
WriteContextInformation(HANDLE hFile, IWMSContext *pContext) | CContextPlugin | [private]
~CContextPlugin() | CContextPlugin |
Generated on Wed Nov 13 2024 16:55:57 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Tools/EntityProxy/DataServices/resultset.Cpp Source File

  • Com
  • Tools
  • EntityProxy
  • DataServices

resultset.Cpp

Go to the documentation of this file.
00001 // Resultset.cpp : Implementation of CResultset
00002 #include "stdafx.h"
00003 #include "Data.h"
00004 #include "Entity.h"
00005 #include "Resultset.h"
00006
00007 /////////////////////////////////////////////////////////////////////////////
00008 // CResultset
00009
00010 STDMETHODIMP CResultset::InterfaceSupportsErrorInfo(REFIID riid)
00011 {
00012   static const IID* arr[] =
00013   {
00014     &IID_IResultset
00015   };
00016   for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
00017   {
00018     if (::InlineIsEqualGUID(*arr[i],riid))
00019       return S_OK;
00020   }
00021   return S_FALSE;
00022 }
00023
00024 STDMETHODIMP CResultset::Count(long* pCount)
00025 {
00026   HRESULT hr = S_OK;
00027
00028   *pCount = m_nCount;
00029
00030   return hr;
00031 }
00032
00033 STDMETHODIMP CResultset::_NewEnum(IUnknown** pVal)
00034 {
00035   HRESULT hr;
00036   IUnknown *pThisUnk;
00037
00038   if (pVal == NULL)
00039     return E_POINTER;
00040   *pVal = NULL;
00041
00042   if (m_pVar == NULL)
00043   {
00044     m_pVar = new CFastVariant[m_nCount];
00045   }
00046
00047   for (int n = 0; n < m_nCount; n++)
00048   {
00049     IEntityData *pEntity;
00050
00051     get_Record(n + 1, &pEntity);
00052
00053     m_pVar[n] = pEntity;
00054   }
00055
00056   typedef CComObject<CComEnum<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT> > > enumvar;
00057   enumvar* pEnumVar = new enumvar;
00058   _ASSERTE(pEnumVar);
00059
00060   hr = QueryInterface(IID_IUnknown, (void**)&pThisUnk);
00061
00062   if (SUCCEEDED(hr))
00063   {
00064     hr = pEnumVar->Init(&m_pVar[0], &m_pVar[m_nCount], pThisUnk, AtlFlagNoCopy);
00065   }
00066   if (SUCCEEDED(hr))
00067   {
00068     hr = pEnumVar->QueryInterface(IID_IEnumVARIANT, (void**)pVal);
00069     pThisUnk->Release();
00070   }
00071   if (FAILED(hr))
00072     delete pEnumVar;
00073   return hr;
00074 }
00075
00076 STDMETHODIMP CResultset::get_Record(long nIndex, IEntityData **ppEntity)
00077 {
00078   HRESULT hr = S_OK;
00079   if (nIndex < 1)
00080   {
00081     hr = DISP_E_BADINDEX;
00082   }
00083   else
00084   {
00085     CStaticEntity *spEntity = GetEntity(nIndex - 1);
00086
00087     if (spEntity->m_wszReadStoredProc == L"")
00088       spEntity->m_wszReadStoredProc = m_wszReadStoredProc;
00089
00090     if (spEntity->m_wszUpdateStoredProc == L"")
00091       spEntity->m_wszUpdateStoredProc = m_wszUpdateStoredProc;
00092
00093     if (spEntity->m_wszDeleteStoredProc == L"")
00094       spEntity->m_wszDeleteStoredProc = m_wszDeleteStoredProc;
00095
00096     if (spEntity->m_wszInsertStoredProc == L"")
00097       spEntity->m_wszInsertStoredProc = m_wszInsertStoredProc;
00098
00099     if (spEntity->m_wszKeyField == L"")
00100       spEntity->m_wszKeyField = m_wszKeyField;
00101
00102     hr = spEntity->QueryInterface(IID_IEntityData, (void**)ppEntity);
00103   }
00104   return hr;
00105 }
00106 /*
00107 CStaticEntity *CResultset::GetEntity(long nIndex)
00108 {
00109   CStaticEntity *pEntity = NULL;
00110   if (nIndex >= 0)
00111   {
00112     int nEntity = nIndex % ENTITY_PER_BANK;
00113     int nBank = (nIndex - nEntity) / ENTITY_PER_BANK;
00114
00115     if (nIndex >= m_nCount)
00116       m_nCount = nIndex + 1;
00117
00118     if (nBank >= m_nBankCount)
00119     {
00120       m_nBankCount++;
00121       m_pEntity[m_nBankCount - 1] = new CStaticEntity[ENTITY_PER_BANK];
00122     }
00123     pEntity = &m_pEntity[nBank][nEntity];
00124   }
00125   return pEntity;
00126 }
00127 */
00128 CStaticEntity *CResultset::GetEntity(long nIndex)
00129 {
00130   CStaticEntity *pEntity = NULL;
00131   if (nIndex >= 0)
00132   {
00133     if (nIndex >= m_nCount)
00134     {
00135       m_nCount = nIndex + 1;
00136       m_pEntity[nIndex] = new CStaticEntity;
00137       m_pEntity[nIndex]->AddRef();
00138     }
00139     pEntity = m_pEntity[nIndex];
00140   }
00141   return pEntity;
00142 }
00143
00144 HRESULT CResultset::Initialise(long nRows)
00145 {
00146   m_nCount = 0;
00147
00148   if (m_pVar != NULL)
00149   {
00150     delete [] m_pVar;
00151     m_pVar = NULL;
00152   }
00153
00154   return S_OK;
00155 }
00156
00157 void CResultset::DeleteEntity(long nIndex)
00158 {
00159   if (nIndex >= 0 && nIndex < m_nCount)
00160   {
00161     m_pEntity[nIndex]->Release();
00162 //    delete m_pEntity[nIndex];
00163   }
00164 }
00165
00166 void CResultset::SetCount(long nCount)
00167 {
00168   m_nCount = nCount;
00169 }
Generated on Wed Nov 13 2024 16:52:01 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CODBCData Member List

This is the complete list of members for CODBCData, including all inherited members.
ActivateData(IObjectContext *pObjectContext) | CPooledData | [inline, protected]
BindResultMetaData(FieldMetaData **ppMetaData, short *pCount) | CODBCData | [protected, virtual]
CanConnectionBePooled(void) | CPooledData | [inline, protected, virtual]
CloseCurrentStatement() | CODBCData | [protected, virtual]
CODBCData() | CODBCData | [inline, protected]
ConstructData(IDispatch *pUnk) | CPooledData | [inline, protected]
CPooledData() | CPooledData | [inline, protected]
DeactivateData(void) | CODBCData | [inline, protected, virtual]
Enlist(IObjectContext *pObjectContext, const CLSID &clsid, const IID &iid) | CODBCData | [private, virtual]
ExecuteSQL(LPCWSTR wszSQL, long *pResult=NULL) | CODBCData | [protected, virtual]
FetchData() | CODBCData | [inline, protected, virtual]
GetConnection(BSTR sDsn, BOOL bUseObjectPool) | CODBCData | [private]
GetODBCError(char *szError) | CODBCData | [private]
m_bConstructed | CPooledData | [protected]
m_bObjectPooled | CPooledData | [protected]
m_bShouldEnlist | CPooledData | [protected]
m_hdbc | CODBCData | [private]
m_henv | CODBCData | [private]
m_hstmt | CODBCData | [private]
m_spObjectContext | CPooledData | [protected]
m_txuow | CPooledData | [protected]
m_wszConnection | CODBCData | [protected]
ManualConstruct(BSTR ConstructString)=0 | CPooledData | [protected, pure virtual]
ManualConstructData(BSTR strConstruct) | CODBCData | [inline, protected]
NextResultsetData(long *pResult) | CODBCData | [protected, virtual]
QueryEnlist(const CLSID &clsid, const IID &iid) | CPooledData | [inline, protected, virtual]
~CODBCData() | CODBCData | [inline, protected]
~CPooledData() | CPooledData | [inline, protected]
Generated on Wed Nov 13 2024 16:56:58 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CServerDlg Member List

This is the complete list of members for CServerDlg, including all inherited members.
count | CServerDlg |
CServerDlg(CWnd *pParent=NULL) | CServerDlg |
DoDataExchange(CDataExchange *pDX) | CServerDlg | [protected, virtual]
domainFlag | CServerDlg |
IDD enum value | CServerDlg |
m_domainName | CServerDlg |
m_serverList2 | CServerDlg |
OnChangeDomainName() | CServerDlg | [protected]
OnDropdownServerList2() | CServerDlg | [protected]
OnInitDialog() | CServerDlg | [protected, virtual]
OnOK() | CServerDlg | [protected, virtual]
pServerInfo | CServerDlg |
serverName | CServerDlg |
Generated on Wed Nov 13 2024 16:57:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/WMI/VC/decoupled/Instance_Provider/Include/Resource.h Source File

  • SysMgmt
  • WMI
  • VC
  • decoupled
  • Instance_Provider
  • Include

Resource.h

Go to the documentation of this file.
00001 /*++
00002
00003 Copyright (C)  Microsoft Corporation
00004
00005 Module Name:
00006
00007   Resource.h
00008
00009 Abstract:
00010
00011
00012 History:
00013
00014 --*/
00015
00016 //{{NO_DEPENDENCIES}}
00017 // Microsoft Developer Studio generated include file.
00018 // Used by propprov.rc
00019 //
00020
00021 // Next default values for new objects
00022 //
00023 #ifdef APSTUDIO_INVOKED
00024 #ifndef APSTUDIO_READONLY_SYMBOLS
00025 #define _APS_NO_MFC                     1
00026 #define _APS_NEXT_RESOURCE_VALUE        101
00027 #define _APS_NEXT_COMMAND_VALUE         40001
00028 #define _APS_NEXT_CONTROL_VALUE         1000
00029 #define _APS_NEXT_SYMED_VALUE           101
00030 #endif
00031 #endif
Generated on Wed Nov 13 2024 16:51:42 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/OleStd/malspy.h Source File

  • Com
  • Fundamentals
  • OleStd

malspy.h

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //  Copyright (C) Microsoft Corporation, 1993 - 2000.
00005 //
00006 //  File:       malspy.h
00007 //
00008 //  Contents:   CMallocSpy definitions
00009 //
00010 //----------------------------------------------------------------------
00011
00012 BOOL InitializeMallocSpy(void);
00013
00014 void UninitializeMallocSpy(void);
00015
Generated on Wed Nov 13 2024 16:51:52 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/activedir/createuser/vc/UserProps.h Source File

  • NetDS
  • ADSI
  • samples
  • activedir
  • createuser
  • vc

UserProps.h

Go to the documentation of this file.
00001
00002 #ifndef __USERPROPS_H
00003 #define __USERPROPS_H
00004
00005 BOOL MapMandatoryUserAttribToType(LPWSTR pwszAttrib,LPWSTR *ppwszRetAttType, LPWSTR *ppwszRetAttribMultiOrSingle);
00006 BOOL MapOptionalUserAttribToType(LPWSTR pwszAttrib,LPWSTR *ppwszRetAttType, LPWSTR *ppwszRetAttribMultiOrSingle);
00007 BOOL MapUserAttribToType(LPWSTR pwszAttrib,LPWSTR *ppwszRetAttType, LPWSTR *ppwszRetAttribMultiOrSingle);
00008
00009 ADSTYPE MapAdsTypeFromString(LPWSTR pwszAdsType);
00010
00011 ADSTYPE MapTypeToADSTYPE(LPWSTR pwszName);
00012
00013
00014
00015 #endif
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

FieldVtbl Member List

This is the complete list of members for FieldVtbl, including all inherited members.
cNames | FieldVtbl
Data | FieldVtbl
dispIdMember | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *QueryInterface)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *Invoke)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Properties)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_ActualSize)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Attributes)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_DefinedSize)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Name)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Type)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Value)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *put_Value)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_Precision)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_NumericScale)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *AppendChunk)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *GetChunk)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_OriginalValue)(ADOField __RPC_FAR *This | FieldVtbl
HRESULT(STDMETHODCALLTYPE __RPC_FAR *get_UnderlyingValue)(ADOField __RPC_FAR *This | FieldVtbl
iTInfo | FieldVtbl
lcid | FieldVtbl
lcid | FieldVtbl
lcid | FieldVtbl
Length | FieldVtbl
pbNumericScale | FieldVtbl
pbPrecision | FieldVtbl
pbstr | FieldVtbl
pctinfo | FieldVtbl
pDataType | FieldVtbl
pDispParams | FieldVtbl
pExcepInfo | FieldVtbl
pl | FieldVtbl
ppTInfo | FieldVtbl
ppvObject | FieldVtbl
ppvObject | FieldVtbl
puArgErr | FieldVtbl
pvar | FieldVtbl
pvar | FieldVtbl
pVarResult | FieldVtbl
rgDispId | FieldVtbl
rgszNames | FieldVtbl
riid | FieldVtbl
riid | FieldVtbl
riid | FieldVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *AddRef)(ADOField __RPC_FAR *This) | FieldVtbl
ULONG(STDMETHODCALLTYPE __RPC_FAR *Release)(ADOField __RPC_FAR *This) | FieldVtbl
Val | FieldVtbl
wFlags | FieldVtbl
Generated on Wed Nov 13 2024 16:57:49 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/mmc2.0/multisel/registry.cpp Source File

  • SysMgmt
  • MMC
  • mmc2.0
  • multisel

registry.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This source code is only intended as a supplement to existing
00004 //  Microsoft documentation.
00005 //
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00007 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00008 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00009 //  PURPOSE.
00010 //
00011 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00012 //
00013
00014
00015 #include <ObjBase.h>
00016 #include "Registry.h"
00017 #include "Globals.h"
00018
00019
00020 #include "TraceMacro.h"
00021 #undef  MODULESTRING
00022 #define MODULESTRING  _T("Registry")
00023
00024
00025 /////////////////////////////////////////////////////////////////////////////
00026 // Internal helper functions prototypes
00027
00028
00029 // Set the given key and its value.
00030 HRESULT SetKeyAndValue( const TCHAR* pszPath, const TCHAR* szSubkey, const TCHAR* szValue);
00031
00032 // Set the given key and its value in the MMC Snapin location
00033 HRESULT SetSnapInKeyAndValue( const TCHAR* szKey, const TCHAR* szSubkey, const TCHAR* szName, const TCHAR* szValue );
00034
00035 // Set the given valuename under the key to value
00036 HRESULT SetValue( const TCHAR* szKey, const TCHAR* szValueName, const TCHAR* szValue);
00037
00038 // Delete szKeyChild and all of its descendents.
00039 HRESULT RecursiveDeleteKey( HKEY hKeyParent, const TCHAR* szKeyChild );
00040
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 // Public function implementation
00044
00045
00046 //---------------------------------------------------------------------------
00047 //  Register the component in the registry.  This is the minimalist way
00048 //  to register a component, you may want to add keys for ProgID.
00049 //
00050 HRESULT RegisterServer
00051 (
00052   HMODULE        hModule,          //[in] DLL module handle
00053   const CLSID&   clsid,            //[in] Class ID
00054   const TCHAR*   szFriendlyName    //[in] Name string
00055 )
00056 {
00057   // Get server location.
00058   TCHAR    szModule[512] ;
00059   TCHAR*   pszCLSID = NULL;
00060   LPOLESTR wszCLSID = NULL ;
00061   HRESULT  hResult  = S_FALSE;
00062
00063   DWORD dwResult = ::GetModuleFileName( hModule,
00064                                         szModule,
00065                                         sizeof(szModule)/sizeof(TCHAR)
00066                                       );
00067   if( 0 == dwResult ) return HRESULT_FROM_WIN32( dwResult );
00068
00069   do                         // Fail unless we complete everything
00070   {
00071     // Get CLSID string in wide char
00072     hResult = StringFromCLSID( clsid, &wszCLSID ) ;
00073     if( S_OK != hResult )
00074     {
00075       CoTaskMemFree( wszCLSID );
00076       BREAK_ON_ERROR( hResult );
00077     }
00078
00079     W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00080     CoTaskMemFree( wszCLSID );           // Through with wide version
00081
00082     TCHAR szKey[64];                     // Build the CLSID key string CLSID\\{...}
00083     _tcscpy( szKey, _T("CLSID\\") );
00084     _tcscat( szKey, pszCLSID );
00085
00086     // Add the CLSID to the registry.
00087     hResult = SetKeyAndValue( szKey, NULL, szFriendlyName );
00088     BREAK_ON_ERROR( hResult );
00089
00090     // Add the server filename subkey under the CLSID key.
00091     hResult = SetKeyAndValue( szKey, _T("InprocServer32"), szModule );
00092     BREAK_ON_ERROR( hResult );
00093
00094     // Set the threading model
00095     _tcscat( szKey, _T("\\InprocServer32") );
00096     hResult = SetValue( szKey, _T("ThreadingModel"), _T("Apartment") );
00097     BREAK_ON_ERROR( hResult );
00098
00099   }while( 0 );
00100
00101   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00102
00103   return hResult;
00104 }
00105
00106
00107 //---------------------------------------------------------------------------
00108 // Remove the component from the registry.
00109 //
00110 LONG UnregisterServer
00111 (
00112   const CLSID& clsid         //[in] Class ID of component to remove
00113 )
00114 {
00115   HRESULT hResult = S_OK;
00116
00117   // Allocate the CLSID string
00118   LPOLESTR wszCLSID = NULL ;
00119   hResult = StringFromCLSID( clsid, &wszCLSID );
00120   if( S_OK != hResult )
00121   {
00122     CoTaskMemFree( wszCLSID );
00123     return hResult;
00124   }
00125
00126   // Build the key CLSID\\{...}
00127   TCHAR szKey[64];
00128   _tcscpy( szKey, _T("CLSID\\") );
00129
00130   TCHAR* pszCLSID = NULL;
00131   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00132   CoTaskMemFree( wszCLSID );           // Through with wide version
00133
00134   _tcscat( szKey, pszCLSID );
00135   CoTaskMemFree( pszCLSID );           // Through with TCHAR version
00136
00137   // Delete the CLSID Key - CLSID\{...}
00138   LONG lResult = RecursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );
00139   if( ERROR_SUCCESS != lResult )
00140     hResult = HRESULT_FROM_WIN32( lResult );
00141
00142   return hResult;
00143 }
00144
00145 //---------------------------------------------------------------------------
00146 // Register the snap-in in the registry.
00147 //
00148 HRESULT RegisterSnapin
00149 (
00150   const  CLSID&  clsid,              //[in] Class ID
00151   const  TCHAR*  szNameString,       //[in] NameString
00152   const  CLSID&  clsidAbout,         //[in] Class Id for About Class
00153   const  BOOL    bSupportExtensions  //[in] TRUE if we support extensions
00154 )
00155 {
00156   HRESULT hResult = S_FALSE;
00157   TCHAR*  pszSnapCLSID = NULL;         // Needed for TCHAR version of the ClassID
00158
00159   // If any part of this process fails, jump out of the loop and return
00160   // the error code
00161   do
00162   {
00163     // Allocate the CLSID string
00164     LPOLESTR wszSnapCLSID  = NULL ;
00165     hResult = StringFromCLSID( clsid, &wszSnapCLSID ) ;
00166     if( S_OK != hResult )
00167     {
00168        CoTaskMemFree( wszSnapCLSID );
00169        continue;
00170     }
00171
00172     W2T( &pszSnapCLSID, wszSnapCLSID );  // W2T is defined in Globals.h
00173     CoTaskMemFree( wszSnapCLSID );       // Through with wide version
00174
00175     // Add the Snap-in's CLSID to the registry
00176     hResult = SetSnapInKeyAndValue( pszSnapCLSID, NULL, _T("NameString"), szNameString );
00177     BREAK_ON_ERROR( hResult );
00178
00179     hResult = SetSnapInKeyAndValue( pszSnapCLSID, _T("StandAlone"), NULL, NULL );
00180     BREAK_ON_ERROR( hResult );
00181
00182     // Add registry information for ISnapinAbout if we support it
00183     LPOLESTR wszAboutCLSID = NULL;
00184     TCHAR*   pszAboutCLSID = NULL;
00185     if( IID_NULL != clsidAbout )
00186     {
00187       hResult = StringFromCLSID( clsidAbout, &wszAboutCLSID );
00188       if( S_OK != hResult )
00189       {
00190         CoTaskMemFree( wszAboutCLSID ); // Free this memory before exiting
00191         continue;
00192       }
00193
00194       W2T( &pszAboutCLSID, wszAboutCLSID );
00195       hResult = SetSnapInKeyAndValue( pszSnapCLSID, NULL, _T("About"), pszAboutCLSID );
00196       CoTaskMemFree( wszAboutCLSID );
00197       CoTaskMemFree( pszAboutCLSID );
00198       BREAK_ON_ERROR( hResult );
00199     }
00200
00201     if( TRUE == bSupportExtensions )     // Build the NodeTypesKey
00202     {
00203       hResult = SetSnapInKeyAndValue( pszSnapCLSID, _T("NodeTypes"), NULL, NULL );
00204       BREAK_ON_ERROR( hResult );
00205       TCHAR szKey[64];
00206       _tcscpy( szKey, pszSnapCLSID );
00207       _tcscat(szKey, _T("\\NodeTypes"));
00208       hResult = SetSnapInKeyAndValue( szKey, pszSnapCLSID, NULL, NULL );
00209       BREAK_ON_ERROR( hResult );
00210     }
00211   }while( 0 );
00212
00213   CoTaskMemFree( pszSnapCLSID);
00214   return hResult;
00215 }
00216
00217
00218 //---------------------------------------------------------------------------
00219 // Unregister the snap-in in the registry.
00220 //
00221 HRESULT UnregisterSnapin
00222 (
00223   const CLSID& clsid         //[in] Class ID of object to unregister
00224 )
00225 {
00226   HRESULT hResult = S_OK;
00227
00228   TCHAR    szKeyBuf[1024];
00229   LPOLESTR wszCLSID = NULL;
00230   TCHAR*   pszCLSID = NULL;        // Needed for TCHAR version of the ClassID
00231
00232   // Get CLSID as a wide string
00233   hResult = StringFromCLSID( clsid, &wszCLSID );
00234   if( S_OK != hResult )
00235   {
00236     CoTaskMemFree( wszCLSID );
00237     return hResult;
00238   }
00239
00240   W2T( &pszCLSID, wszCLSID );          // W2T is defined in Globals.h
00241   CoTaskMemFree( wszCLSID );           // Through with wide version
00242
00243   // Load the buffer with the Snap-In Location
00244   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00245
00246   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00247   _tcscat( szKeyBuf, pszCLSID );
00248
00249   // Delete the CLSID Key - CLSID\{...}
00250   LONG lResult = RecursiveDeleteKey( HKEY_LOCAL_MACHINE, szKeyBuf );
00251   if( ERROR_SUCCESS != lResult )
00252     hResult = HRESULT_FROM_WIN32( lResult );
00253
00254   CoTaskMemFree( pszCLSID );
00255   return hResult;
00256 }
00257
00258 //---------------------------------------------------------------------------
00259 // Delete a key and all of its descendents.
00260 //
00261 HRESULT RecursiveDeleteKey
00262 (
00263   HKEY          hKeyParent,    //[in] Parent of key to delete
00264   const TCHAR*  lpszKeyChild   //[in] Key to delete
00265 )
00266 {
00267   // Open the child.
00268   HKEY hKeyChild = NULL;
00269   LONG lResult   = ERROR_SUCCESS;
00270
00271   do                     // We go to all this trouble to prevent any
00272   {                      // possibility of exiting while leaving a key open
00273
00274     lResult = RegOpenKeyEx( hKeyParent,
00275                             lpszKeyChild,
00276                             0,
00277                             KEY_ALL_ACCESS,
00278                             &hKeyChild
00279                           );
00280     if( ERROR_SUCCESS != lResult )
00281       continue;
00282
00283     // Enumerate all of the decendents of this child.
00284     FILETIME time;
00285     _TCHAR szBuffer[256];
00286     DWORD dwSize = 256;
00287     while( S_OK == RegEnumKeyEx(hKeyChild,0,szBuffer,&dwSize,NULL,NULL,NULL,&time) )
00288     {
00289       // Delete the decendents of this child.
00290       lResult = RecursiveDeleteKey( hKeyChild, szBuffer );
00291       if( ERROR_SUCCESS != lResult )
00292       {
00293         continue;
00294       }
00295       dwSize = 256;
00296     }
00297   }while( 0 );
00298
00299   RegCloseKey( hKeyChild );            // Always try to close the child
00300                                        // then delete this child.
00301   return RegDeleteKey( hKeyParent, lpszKeyChild );
00302 }
00303
00304 //---------------------------------------------------------------------------
00305 // Create a Registry Key and set its value.
00306 //   - This helper function was borrowed and modifed from
00307 //     Kraig Brockschmidt's book Inside OLE.
00308 //
00309 HRESULT SetKeyAndValue
00310 (
00311   const TCHAR*  szKey,       //[in] Parent key
00312   const TCHAR*  szSubkey,    //[in] Child key
00313   const TCHAR*  szValue      //[in] Value to set
00314 )
00315 {
00316   HKEY hKey = NULL;
00317   HRESULT hResult = S_FALSE;
00318   TCHAR szKeyBuf[1024];
00319
00320   // Copy keyname into buffer.
00321   _tcscpy( szKeyBuf, szKey );
00322
00323   // Add subkey name to buffer.
00324   if( NULL != szSubkey )
00325   {
00326     _tcscat( szKeyBuf, _T("\\") );
00327     _tcscat( szKeyBuf, szSubkey );
00328   }
00329
00330   do                     // We go to all this trouble to prevent any
00331   {                      // possibility of exiting while leaving a key open
00332
00333     // Create and open key and subkey.
00334     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT,
00335                                    szKeyBuf,
00336                                    0,
00337                                    NULL,
00338                                    REG_OPTION_NON_VOLATILE,
00339                                    KEY_ALL_ACCESS,
00340                                    NULL,
00341                                    &hKey,
00342                                    NULL
00343                                  );
00344     if( ERROR_SUCCESS != lResult )
00345     {
00346       hResult = HRESULT_FROM_WIN32( lResult );
00347       continue;
00348     }
00349
00350     if( NULL != szValue )    // Now set the value
00351     {
00352       hResult = RegSetValueEx( hKey,
00353                                NULL,
00354                                0,
00355                                REG_SZ,
00356                                (BYTE*)szValue,
00357                                BYTE_SIZE( szValue )    // BYTE_SIZE is in Globals.h
00358                              );
00359       BREAK_ON_ERROR( hResult );
00360     }
00361   }while( 0 );
00362
00363   RegCloseKey( hKey );       // Always try to close the key
00364   return hResult;
00365 }
00366
00367
00368 //---------------------------------------------------------------------------
00369 // Open a key value and set it
00370 //
00371 HRESULT SetValue
00372 (
00373   const TCHAR*  szKey,         //[in] Parent key
00374   const TCHAR*  szValueName,   //[in] Name of value
00375   const TCHAR*  szValue        //[in] Value in string format
00376 )
00377 {
00378   HKEY    hKey = NULL;
00379   HRESULT hResult = S_FALSE;
00380   TCHAR szKeyBuf[1024];
00381
00382   // Copy keyname into buffer.
00383   _tcscpy( szKeyBuf, szKey );
00384
00385   do                     // We go to all this trouble to prevent any
00386   {                      // possibility of exiting while leaving a key open
00387
00388     // Create and open key and subkey.
00389     long lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT ,
00390                                    szKeyBuf,
00391                                    0,
00392                                    NULL,
00393                                    REG_OPTION_NON_VOLATILE,
00394                                    KEY_ALL_ACCESS,
00395                                    NULL,
00396                                    &hKey,
00397                                    NULL
00398                                  );
00399     if( ERROR_SUCCESS != lResult )
00400     {
00401       hResult = HRESULT_FROM_WIN32( lResult );
00402       continue;
00403     }
00404
00405     if( NULL != szValue )    // Now set the value
00406     {
00407       hResult = RegSetValueEx( hKey,
00408                                szValueName,
00409                                0,
00410                                REG_SZ,
00411                                (BYTE*)szValue,
00412                                BYTE_SIZE( szValue )
00413                              );
00414       BREAK_ON_ERROR( hResult );
00415     }
00416   }while( 0 );
00417
00418   RegCloseKey( hKey );       //Always attempt to close the key
00419   return hResult;
00420 }
00421
00422
00423 //---------------------------------------------------------------------------
00424 // Create a key and set its value.
00425 //   - This helper function was borrowed and modifed from
00426 //     Kraig Brockschmidt's book Inside OLE.
00427 //
00428 HRESULT SetSnapInKeyAndValue
00429 (
00430   const TCHAR*  szKey,       //[in] Parent key
00431   const TCHAR*  szSubkey,    //[in] Child key
00432   const TCHAR*  szName,      //[in] Value name
00433   const TCHAR*  szValue      //[in] Value in string format
00434 )
00435 {
00436   HKEY    hKey = NULL;
00437   HRESULT hResult = S_FALSE;
00438   TCHAR   szKeyBuf[1024];
00439
00440   // Load the buffer with the Snap-In Location
00441   _tcscpy( szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\SnapIns") );
00442
00443   _tcscat( szKeyBuf, _T("\\") );       // Copy keyname into buffer.
00444   _tcscat( szKeyBuf, szKey );
00445
00446   if( NULL != szSubkey )               // Add subkey name to buffer.
00447   {
00448     _tcscat( szKeyBuf, _T("\\") );
00449     _tcscat( szKeyBuf, szSubkey );
00450   }
00451
00452   do                     // We go to all this trouble to prevent any
00453   {                      // possibility of exiting while leaving a key open
00454
00455     // Create and open key and subkey.
00456     long lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
00457                                    szKeyBuf,
00458                                    0,
00459                                    NULL,
00460                                    REG_OPTION_NON_VOLATILE,
00461                                    KEY_ALL_ACCESS,
00462                                    NULL,
00463                                    &hKey,
00464                                    NULL
00465                                  );
00466     if( ERROR_SUCCESS != lResult )     // Will return S_FALSE
00467       continue;
00468
00469     // Set the Value.
00470     if( szValue != NULL )
00471     {
00472       hResult = RegSetValueEx( hKey,
00473                                szName,
00474                                0,
00475                                REG_SZ,
00476                                (BYTE*)szValue,
00477                                BYTE_SIZE(szValue)
00478                              );
00479       BREAK_ON_ERROR( hResult );
00480     }
00481     else
00482     {                        // Got this far so everything is OK.
00483       hResult = S_OK;
00484     }
00485   }while( 0 );
00486
00487   RegCloseKey( hKey );       //Always attempt to close the key
00488   return hResult;
00489 }
00490
Generated on Wed Nov 13 2024 16:51:47 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Services/Object_Pooling/OPBankSample/Account.VC/stdafx.Cpp Source File

  • Com
  • Services
  • Object_Pooling
  • OPBankSample
  • Account.VC

stdafx.Cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  stdafx.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 #include <initguid.h>
00008 #ifdef _ATL_STATIC_REGISTRY
00009 #include <statreg.h>
00010 #include <statreg.cpp>
00011 #endif
00012
00013 #include <atlimpl.cpp>
00014
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/AsyncCalls/JavaClient/FullSvr/AsyncIFullServ.java Source File

  • Com
  • Fundamentals
  • AsyncCalls
  • JavaClient
  • FullSvr

AsyncIFullServ.java

Go to the documentation of this file.
00001 //
00002 // Auto-generated using JActiveX.EXE 5.00.3167.1
00003 //   ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe"   /w /xi /X:rkc /l "D:\DOCUME~1\a-joest\LOCALS~1\Temp\jvc958.tmp" /nologo /d "D:\mssdk\Samples\COM\Fundamentals\AsyncCalls\JavaClient" "D:\mssdk\Samples\COM\Fundamentals\AsyncCalls\FullSvr\Debug\FullSvr.exe")
00004 //
00005 // WARNING: Do not remove the comments that include "@com" directives.
00006 // This source file must be compiled by a @com-aware compiler.
00007 // If you are using the Microsoft Visual J++ compiler, you must use
00008 // version 1.02.3920 or later. Previous versions will not issue an error
00009 // but will not generate COM-enabled class files.
00010 //
00011
00012 package fullsvr;
00013
00014 import com.ms.com.*;
00015 import com.ms.com.IUnknown;
00016 import com.ms.com.Variant;
00017
00018 // VTable-only interface AsyncIFullServ
00019 /** @com.interface(iid=D3140113-D43F-4718-9119-EF62D631F2AB, thread=AUTO) */
00020 public interface AsyncIFullServ extends IUnknown
00021 {
00022   /** @com.method(vtoffset=0, addFlagsVtable=4)
00023       @com.parameters([in,type=I4] i, [in,type=I4] j) */
00024   public void Begin_Sum(int i, int j);
00025
00026   /** @com.method(vtoffset=1, addFlagsVtable=4)
00027       @com.parameters([type=I4] return) */
00028   public int Finish_Sum();
00029
00030
00031   public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0xd3140113, (short)0xd43f, (short)0x4718, (byte)0x91, (byte)0x19, (byte)0xef, (byte)0x62, (byte)0xd6, (byte)0x31, (byte)0xf2, (byte)0xab);
00032 }
Generated on Wed Nov 13 2024 16:51:50 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/Read/vc/Read.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • Read
  • vc

Read.cpp

Go to the documentation of this file.
00001 // Read.cpp : Defines the entry point for the console application.
00002 //
00003
00004 #include "stdafx.h"
00005 #include "stdio.h"
00006 #include "activeds.h"
00007
00008
00009 int main(int argc, char* argv[])
00010 {
00011   HRESULT hr;
00012   IADs *pUsr=NULL;
00013
00014
00015   CoInitialize(NULL);
00016
00017   ////////////////////////////////////
00018   // Bind to a directory object
00019   /////////////////////////////////////
00020   hr = ADsGetObject(L"WinNT://INDEPENDENCE/Administrator,user", IID_IADs, (void**) &pUsr );
00021     if ( !SUCCEEDED(hr) )
00022     {
00023         return 0;
00024     }
00025
00026
00027   ///////////////////////////////////
00028   // Get a single value attribute
00029   ////////////////////////////////////
00030   VARIANT var;
00031   VariantInit(&var);
00032
00033
00034   hr = pUsr->Get(L"FullName", &var );
00035   if ( SUCCEEDED(hr) )
00036   {
00037     printf("FullName: %S\n", V_BSTR(&var) );
00038     VariantClear(&var);
00039   }
00040
00041   if ( pUsr )
00042   {
00043     pUsr->Release();
00044   }
00045
00046
00047
00048   ///////////////////////////////////////////////////////
00049   // Get a multi value attribute from a service object
00050   /////////////////////////////////////////////////////////
00051   IADs *pSvc = NULL;
00052
00053   hr = ADsGetObject(L"WinNT://INDEPENDENCE/ANDYHAR11/Browser,service", IID_IADs, (void**) &pSvc );
00054   if ( !SUCCEEDED(hr) )
00055   {
00056     return hr;
00057   }
00058
00059   hr = pSvc->Get(L"Dependencies", &var );
00060   if ( SUCCEEDED(hr) )
00061   {
00062     LONG lstart, lend;
00063     SAFEARRAY  *sa = V_ARRAY( &var );
00064     VARIANT varItem;
00065
00066     // Get the lower and upper bound
00067       hr = SafeArrayGetLBound( sa, 1, &lstart );
00068                      hr = SafeArrayGetUBound( sa, 1, &lend );
00069
00070     // Now iterate and print the content
00071     VariantInit(&varItem);
00072     printf("Getting service dependencies using IADs :\n");
00073     for ( long idx=lstart; idx < lend; idx++ )
00074     {
00075       hr = SafeArrayGetElement( sa, &idx, &varItem );
00076       printf("%S ", V_BSTR(&varItem));
00077       VariantClear(&varItem);
00078     }
00079     printf("\n");
00080
00081     VariantClear(&var);
00082   }
00083
00084   // Clean-up
00085   if ( pSvc )
00086   {
00087     pSvc->Release();
00088   }
00089
00090
00091
00092
00093   ///////////////////////////////////////////////////////////
00094   // Using IDirectoryObject to get a multivalue attribute
00095   // Note: NOT all providers support this interface
00096   ////////////////////////////////////////////////////////////
00097   IDirectoryObject  *pDirObject=NULL;
00098   ADS_ATTR_INFO   *pAttrInfo=NULL;
00099   DWORD       dwReturn;
00100   LPWSTR        pAttrNames[]={L"objectClass" };
00101   DWORD       dwNumAttr=sizeof(pAttrNames)/sizeof(LPWSTR);
00102
00103   hr = ADsGetObject(L"LDAP://CN=Administrator,CN=Users,DC=testDom1,DC=testDom2,DC=microsoft,DC=com",
00104                   IID_IDirectoryObject,
00105             (void**) &pDirObject );
00106
00107   if ( !SUCCEEDED(hr) )
00108   {
00109     return 0;
00110   }
00111
00112
00113
00114   // Now get the attribute
00115   hr = pDirObject->GetObjectAttributes( pAttrNames,
00116                       dwNumAttr,
00117                                           &pAttrInfo,
00118                                           &dwReturn );
00119   if ( SUCCEEDED(hr) )
00120   {
00121     printf("Getting the objectClass multivalue attribute using IDirectoryObject :\n");
00122     for (DWORD val=0; val < pAttrInfo->dwNumValues; val++, pAttrInfo->pADsValues++)
00123         {
00124                 printf("  %S\n", pAttrInfo->pADsValues->CaseIgnoreString);
00125         }
00126     FreeADsMem(pAttrInfo);
00127   }
00128
00129   //Clean up
00130   pDirObject->Release();
00131
00132
00133   CoUninitialize();
00134   return 0;
00135 }
Generated on Wed Nov 13 2024 16:52:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/sky.h Source File

  • SysMgmt
  • MMC
  • ActiveX

sky.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _SKY_H
00021 #define _SKY_H
00022
00023 #include <mmc.h>
00024 #include "DeleBase.h"
00025
00026 class CSkyBasedVehicle : public CDelegationBase {
00027 public:
00028     CSkyBasedVehicle(CComponentData *pComponentData = NULL)
00029     { m_pComponentData = pComponentData;  }
00030
00031     virtual ~CSkyBasedVehicle() {}
00032
00033     virtual const _TCHAR *GetDisplayName(int nCol = 0) { return _T("Sky-based Vehicles"); }
00034     virtual const GUID & getNodeType() { return thisGuid; }
00035     virtual const int GetBitmapIndex() { return INDEX_SKYICON; }
00036
00037 private:
00038     enum { IDM_NEW_SKY = 3 };
00039
00040     // {2974380F-4C4B-11d2-89D8-000021473128}
00041     static const GUID thisGuid;
00042 };
00043
00044 #endif // _SKY_H
Generated on Wed Nov 13 2024 16:52:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

COleDocumentView Member List

This is the complete list of members for COleDocumentView, including all inherited members.
ActivateInPlace() | COleDocumentView | [private]
ActivateUI() | COleDocumentView | [private]
ApplyViewState(IStream *) | COleDocumentView |
Clone(IOleInPlaceSite *, IOleDocumentView **) | COleDocumentView |
CloseView(DWORD) | COleDocumentView |
COleDocument class | COleDocumentView | [friend]
COleDocumentView(COleDocument *) | COleDocumentView |
COleInPlaceActiveObject class | COleDocumentView | [friend]
CreateViewWindow() | COleDocumentView | [private]
DeactivateInPlace() | COleDocumentView | [private]
DeactivateUI() | COleDocumentView | [private]
GetDocument(IUnknown **) | COleDocumentView |
GetInPlaceSite(IOleInPlaceSite **) | COleDocumentView |
GetRect(LPRECT) | COleDocumentView |
m_fInPlaceActive | COleDocumentView | [private]
m_FrameInfo | COleDocumentView | [private]
m_fUIActive | COleDocumentView | [private]
m_hOleMenu | COleDocumentView | [private]
m_hSharedMenu | COleDocumentView | [private]
m_hwndView | COleDocumentView | [private]
m_mgw | COleDocumentView | [private]
m_pInPlaceFrame | COleDocumentView | [private]
m_pInPlaceSite | COleDocumentView | [private]
m_pInPlaceUIWindow | COleDocumentView | [private]
m_pOleDoc | COleDocumentView | [private]
m_Rect | COleDocumentView | [private]
MergeMenus(void) | COleDocumentView | [private]
OnCommand(UINT, UINT, HWND) | COleDocumentView | [private]
OnCreate(void) | COleDocumentView | [private]
OnPaint(void) | COleDocumentView | [private]
Open(void) | COleDocumentView |
QueryInterface(REFIID, LPVOID *) | COleDocumentView |
RemoveMenus(void) | COleDocumentView | [private]
SaveViewState(IStream *) | COleDocumentView |
SetInPlaceSite(IOleInPlaceSite *) | COleDocumentView |
SetRect(LPRECT) | COleDocumentView |
SetRectComplex(LPRECT, LPRECT, LPRECT, LPRECT) | COleDocumentView |
Show(BOOL) | COleDocumentView |
STDMETHODIMP_(DWORD) AddRef() | COleDocumentView |
STDMETHODIMP_(DWORD) Release() | COleDocumentView |
UIActivate(BOOL) | COleDocumentView |
UpdateMenu(HMENU) | COleDocumentView | [private]
ViewWndProc(HWND, UINT, WPARAM, LPARAM) | COleDocumentView | [private, static]
~COleDocumentView() | COleDocumentView |
Generated on Wed Nov 13 2024 16:56:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/tablecopy/step4.cpp Source File

  • Dataaccess
  • oledb
  • tablecopy

step4.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Microsoft OLE DB TABLECOPY Sample
00003 // Copyright (C) 1991-2000 Microsoft Corporation
00004 //
00005 // @doc
00006 //
00007 // @module STEP4.CPP
00008 //
00009 //-----------------------------------------------------------------------------
00010
00011 /////////////////////////////////////////////////////////////////////
00012 // Includes
00013 //
00014 /////////////////////////////////////////////////////////////////////
00015 #include "wizard.h"
00016 #include "common.h"
00017 #include "tablecopy.h"
00018 #include "table.h"
00019
00020
00021 /////////////////////////////////////////////////////////////////////
00022 // Defines
00023 //
00024 /////////////////////////////////////////////////////////////////////
00025 //Enum Type Header for the ListView controls
00026 enum COL_HEADERS
00027 {
00028   //IDL_FROM_TYPES
00029   //ID_TO_TYPES
00030   COL_COLNAME     = 0,  //ColInfo.pwszName
00031   COL_COLTYPENAME   = 1,  //TypeInfo.pwszTypeName
00032   COL_COLTYPE     = 2,  //ColInfo.wType
00033   COL_COLORDINAL    = 3,  //ColInfo.iOrdinal
00034   COL_COLSIZE     = 4,  //ColInfo.ulColumnSize
00035   COL_COLPREC     = 5,  //ColInfo.bPrecision
00036   COL_COLSCALE    = 6,  //ColInfo.bScale
00037   COL_COLISFIXED    = 7,  //ColInfo.dwFlags ISFIXEDLENGTH
00038   COL_COLISLONG   = 8,  //ColInfo.dwFlags ISLONG
00039   COL_COLISNULLABLE = 9,  //ColInfo.dwFlags ISNULLABLE
00040   COL_COLWRITE    =10,  //ColInfo.dwFlags WRITE
00041   COL_COLISROWID    =11,  //ColInfo.dwFlags ISROWID
00042   COL_COLISROWVER   =12,  //ColInfo.dwFlags ISROWVER
00043 };
00044
00045 enum EICON
00046 {
00047   ICON_COLUMN     = 0,
00048   ICON_READONLY   = 1,
00049   ICON_LONG     = 2,
00050 };
00051
00052 /////////////////////////////////////////////////////////////////////
00053 // CS4Dialog::CS4Dialog
00054 //
00055 /////////////////////////////////////////////////////////////////////
00056 CS4Dialog::CS4Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pCTableCopy)
00057   : CDialogBase(hWnd, hInst)
00058 {
00059   ASSERT(pCTableCopy);
00060   m_pCTableCopy = pCTableCopy;
00061 }
00062
00063
00064 /////////////////////////////////////////////////////////////////////
00065 // CS4Dialog::~CS4Dialog
00066 //
00067 /////////////////////////////////////////////////////////////////////
00068 CS4Dialog::~CS4Dialog()
00069 {
00070 }
00071
00072
00073 /////////////////////////////////////////////////////////////////////////////
00074 // ULONG CS4Dialog::Display
00075 //
00076 /////////////////////////////////////////////////////////////////////////////
00077 ULONG CS4Dialog::Display()
00078 {
00079   return DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_OPTIONS), NULL, DlgProc, (LPARAM)this);
00080 }
00081
00082
00083 /////////////////////////////////////////////////////////////////////
00084 // CS4Dialog::DlgProc
00085 //
00086 /////////////////////////////////////////////////////////////////////
00087 BOOL WINAPI CS4Dialog::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00088 {
00089   switch(msg)
00090   {
00091     case WM_INITDIALOG:
00092     {
00093       Busy();
00094       //Store the "this" pointer, since this is a static method
00095       CS4Dialog* pThis = (CS4Dialog*)lParam;
00096       SetWindowLong(hWnd, GWL_USERDATA, (LONG)pThis);
00097
00098       //On INIT we know we have a valid hWnd to store
00099       pThis->m_hWnd = hWnd;
00100
00101       pThis->InitControls();
00102       CenterDialog(hWnd);
00103       pThis->m_pCTableCopy->m_pCWizard->DestroyPrevStep(WIZ_STEP4);
00104       return HANDLED_MSG;
00105     }
00106
00107     case WM_COMMAND:
00108     {
00109       //Obtain the "this" pointer
00110       CS4Dialog* pThis = (CS4Dialog*)GetWindowLong(hWnd, GWL_USERDATA);
00111
00112       // All buttons are handled the same way
00113       switch(GET_WM_COMMAND_ID(wParam, lParam))
00114       {
00115         case IDX_COPY_TABLE:
00116         case IDX_COPY_INDEXES:
00117         case IDX_SHOW_SQL:
00118
00119         case IDR_ALL_ROWS:
00120         case IDR_ROW_COUNT:
00121         case IDR_PARAM_SETS:
00122         case IDR_INSERTROW_IMMEDIATE:
00123         case IDR_INSERTROW_BUFFERED:
00124         case IDR_BLOB_SIZE:
00125         case IDR_ISEQ_STREAM:
00126           Busy();
00127           pThis->RefreshControls();
00128           return HANDLED_MSG;
00129
00130
00131         case IDOK:
00132           Busy();
00133           if(!pThis->RefreshControls())
00134             return HANDLED_MSG;
00135
00136           pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_TYPES);
00137                   return HANDLED_MSG;
00138
00139         case IDB_PREV:
00140           Busy();
00141           if(!pThis->RefreshControls())
00142             return HANDLED_MSG;
00143
00144           pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP3);
00145                   return HANDLED_MSG;
00146
00147         case IDCANCEL:
00148           Busy();
00149                   EndDialog(hWnd, GET_WM_COMMAND_ID(wParam, lParam));
00150                   return HANDLED_MSG;
00151       }
00152     }
00153   }
00154
00155   return UNHANDLED_MSG;
00156 }
00157
00158
00159 /////////////////////////////////////////////////////////////////////////////
00160 // BOOL CS4Dialog::InitControls
00161 //
00162 /////////////////////////////////////////////////////////////////////////////
00163 BOOL CS4Dialog::InitControls()
00164 {
00165   CDataSource* pCToDataSource = m_pCTableCopy->m_pCToTable->m_pCDataSource;
00166
00167   //IDX_COPY_TABLE (default-checked)
00168   EnableWindow(GetDlgItem(m_hWnd, IDX_COPY_TABLE), pCToDataSource->m_pICommandText || pCToDataSource->m_pITableDefinition);
00169   CheckDlgButton(m_hWnd, IDX_COPY_TABLE, m_pCTableCopy->m_fCopyTables);
00170   wSetDlgItemText(m_hWnd, IDX_COPY_TABLE, pCToDataSource->m_pwszTableTerm);
00171
00172   //IDX_COPY_INDEXES (default-checked)
00173   EnableWindow(GetDlgItem(m_hWnd, IDX_COPY_INDEXES), pCToDataSource->m_pICommandText || pCToDataSource->m_pIIndexDefinition);
00174   CheckDlgButton(m_hWnd, IDX_COPY_INDEXES, m_pCTableCopy->m_fCopyIndexes);
00175
00176   //IDX_COPY_PRIMARYKEYS (default-checked)
00177   EnableWindow(GetDlgItem(m_hWnd, IDX_COPY_PRIMARYKEYS), pCToDataSource->m_fPrimaryKeysSupported);
00178   CheckDlgButton(m_hWnd, IDX_COPY_PRIMARYKEYS, m_pCTableCopy->m_fCopyPrimaryKeys);
00179
00180   //IDX_SHOW_SQL (checked)
00181   EnableWindow(GetDlgItem(m_hWnd, IDX_SHOW_SQL), pCToDataSource->m_pICommandText != NULL);
00182   CheckDlgButton(m_hWnd, IDX_SHOW_SQL, m_pCTableCopy->m_fShowQuery);
00183
00184   //IDR_ALL_ROWS (default)
00185   //IDR_MAX_ROWS
00186   CheckRadioButton(m_hWnd, IDR_ALL_ROWS, IDR_ROW_COUNT, m_pCTableCopy->m_dwRowOpt);
00187   wSetDlgItemText(m_hWnd, IDE_ROW_COUNT, L"%lu", m_pCTableCopy->m_ulMaxRows);
00188
00189   //IDR_PARAM_SETS (default)
00190   //If multiple param sets are not supported by this driver, select only 1 set
00191   if(!pCToDataSource->m_fMultipleParamSets)
00192     m_pCTableCopy->m_ulParamSets = 1;
00193   if (pCToDataSource->m_pICommandText == NULL)
00194   {
00195     m_pCTableCopy->m_dwInsertOpt = IDR_INSERTROW_IMMEDIATE;
00196     EnableWindow(GetDlgItem(m_hWnd, IDR_PARAM_SETS), FALSE);
00197   }
00198   CheckRadioButton(m_hWnd, IDR_PARAM_SETS, IDR_INSERTROW_BUFFERED, m_pCTableCopy->m_dwInsertOpt);
00199   wSetDlgItemText(m_hWnd, IDE_PARAM_SETS, L"%lu", m_pCTableCopy->m_ulParamSets);
00200
00201   //Enable IDR_INSERTROW_IMMEDIATE radio button if supported by the provider
00202   EnableWindow(GetDlgItem(m_hWnd, IDR_INSERTROW_IMMEDIATE), pCToDataSource->m_fIRowsetChange);
00203
00204   //Enable IDR_INSERTROW_BUFFERED radio button if supported by the provider
00205   EnableWindow(GetDlgItem(m_hWnd, IDR_INSERTROW_BUFFERED), pCToDataSource->m_fIRowsetUpdate);
00206
00207   //IDR_BLOB_SIZE (default)
00208   //IDR_ISEQ_STREAM
00209   EnableWindow(GetDlgItem(m_hWnd, IDR_ISEQ_STREAM), pCToDataSource->m_dwStorageObjects & DBPROPVAL_SS_ISEQUENTIALSTREAM);
00210   CheckRadioButton(m_hWnd, IDR_BLOB_SIZE, IDR_ISEQ_STREAM, m_pCTableCopy->m_dwBlobOpt);
00211   wSetDlgItemText(m_hWnd, IDE_BLOB_SIZE, L"%lu", m_pCTableCopy->m_ulBlobSize);
00212
00213   //Limit the TextLength of the Edit Controls to 10 chars
00214   SendDlgItemMessage(m_hWnd, IDE_ROW_COUNT, EM_LIMITTEXT, (WPARAM)10, 0L);
00215   SendDlgItemMessage(m_hWnd, IDE_PARAM_SETS, EM_LIMITTEXT, (WPARAM)10, 0L);
00216   SendDlgItemMessage(m_hWnd, IDE_BLOB_SIZE, EM_LIMITTEXT, (WPARAM)10, 0L);
00217
00218   //Only allow "NEXT" button if Some form of INSERT is supported
00219   EnableWindow(GetDlgItem(m_hWnd, IDOK), pCToDataSource->m_pICommandText || pCToDataSource->m_pITableDefinition);
00220
00221   // Refresh the controls
00222   RefreshControls();
00223   return TRUE;
00224 }
00225
00226
00227
00228 /////////////////////////////////////////////////////////////////////////////
00229 // BOOL CS4Dialog::RefreshControls
00230 //
00231 /////////////////////////////////////////////////////////////////////////////
00232 BOOL CS4Dialog::RefreshControls()
00233 {
00234   // IDE_ROW_COUNT Get the Copy options first so we can check the row count if given.
00235   if(IsDlgButtonChecked(m_hWnd, IDR_ROW_COUNT))
00236   {
00237     m_pCTableCopy->m_dwRowOpt = IDR_ROW_COUNT;
00238     EnableWindow(GetDlgItem(m_hWnd, IDE_ROW_COUNT), TRUE);
00239   }
00240   else
00241   {
00242     m_pCTableCopy->m_dwRowOpt = IDR_ALL_ROWS;
00243     EnableWindow(GetDlgItem(m_hWnd, IDE_ROW_COUNT), FALSE);
00244   }
00245
00246   //Verify IDE_ROW_COUNT has legal value
00247   if(!GetEditBoxValue(GetDlgItem(m_hWnd, IDE_ROW_COUNT), 1, LONG_MAX, &m_pCTableCopy->m_ulMaxRows))
00248     return FALSE;
00249
00250   //IDE_PARAM_SETS Get the Insert ParamSets options
00251   if(IsDlgButtonChecked(m_hWnd, IDR_PARAM_SETS))
00252   {
00253     m_pCTableCopy->m_dwInsertOpt = IDR_PARAM_SETS;
00254     EnableWindow(GetDlgItem(m_hWnd, IDE_PARAM_SETS), m_pCTableCopy->m_pCToTable->m_pCDataSource->m_fMultipleParamSets);
00255   }
00256   else if(IsDlgButtonChecked(m_hWnd, IDR_INSERTROW_IMMEDIATE))
00257   {
00258     //IDR_INSERTROW_IMMEDIATE
00259     m_pCTableCopy->m_dwInsertOpt = IDR_INSERTROW_IMMEDIATE;
00260     EnableWindow(GetDlgItem(m_hWnd, IDE_PARAM_SETS), FALSE);
00261   }
00262   else
00263   {
00264     //IDR_INSERTROW_IMMEDIATE
00265     m_pCTableCopy->m_dwInsertOpt = IDR_INSERTROW_BUFFERED;
00266     EnableWindow(GetDlgItem(m_hWnd, IDE_PARAM_SETS), FALSE);
00267   }
00268
00269   //Verify IDE_PARAM_SETS has legal value
00270   if(!GetEditBoxValue(GetDlgItem(m_hWnd, IDE_PARAM_SETS), 1, LONG_MAX, &m_pCTableCopy->m_ulParamSets))
00271     return FALSE;
00272
00273   //IDE_BLOB_SIZE Get the Insert ParamSets options
00274   if(IsDlgButtonChecked(m_hWnd, IDR_BLOB_SIZE))
00275   {
00276     m_pCTableCopy->m_dwBlobOpt = IDR_BLOB_SIZE;
00277     EnableWindow(GetDlgItem(m_hWnd, IDE_BLOB_SIZE), TRUE);
00278   }
00279   else
00280   {
00281     m_pCTableCopy->m_dwBlobOpt = IDR_ISEQ_STREAM;
00282     EnableWindow(GetDlgItem(m_hWnd, IDE_BLOB_SIZE), FALSE);
00283   }
00284
00285   //Verify IDE_BLOB_SIZE has legal value
00286   if(!GetEditBoxValue(GetDlgItem(m_hWnd, IDE_BLOB_SIZE), 1, MAX_COL_SIZE, &m_pCTableCopy->m_ulBlobSize))
00287     return FALSE;
00288
00289   // Get Create options
00290   m_pCTableCopy->m_fCopyTables = IsDlgButtonChecked(m_hWnd, IDX_COPY_TABLE);
00291   m_pCTableCopy->m_fCopyIndexes = IsDlgButtonChecked(m_hWnd, IDX_COPY_INDEXES);
00292   m_pCTableCopy->m_fCopyPrimaryKeys = IsDlgButtonChecked(m_hWnd, IDX_COPY_PRIMARYKEYS);
00293
00294   // Set other Options
00295   m_pCTableCopy->m_fShowQuery = IsDlgButtonChecked(m_hWnd, IDX_SHOW_SQL);
00296   return TRUE;
00297 }
00298
00299
00300 /////////////////////////////////////////////////////////////////////
00301 // CTypesDialog::CTypesDialog
00302 //
00303 /////////////////////////////////////////////////////////////////////
00304 CTypesDialog::CTypesDialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pCTableCopy)
00305   : CDialogBase(hWnd, hInst)
00306 {
00307   ASSERT(pCTableCopy);
00308   m_pCTableCopy = pCTableCopy;
00309 }
00310
00311
00312 /////////////////////////////////////////////////////////////////////
00313 // CTypesDialog::~CTypesDialog
00314 //
00315 /////////////////////////////////////////////////////////////////////
00316 CTypesDialog::~CTypesDialog()
00317 {
00318 }
00319
00320
00321 /////////////////////////////////////////////////////////////////////////////
00322 // ULONG CTypesDialog::Display
00323 //
00324 /////////////////////////////////////////////////////////////////////////////
00325 ULONG CTypesDialog::Display()
00326 {
00327   return DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_DATA_TYPES), NULL, DlgProc, (LPARAM)this);
00328 }
00329
00330
00331 /////////////////////////////////////////////////////////////////////
00332 // CTypesDialog::DlgProc
00333 //
00334 /////////////////////////////////////////////////////////////////////
00335 BOOL WINAPI CTypesDialog::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00336 {
00337   switch(msg)
00338   {
00339     case WM_INITDIALOG:
00340     {
00341       Busy();
00342       //Store the "this" pointer, since this is a static method
00343       CTypesDialog* pThis = (CTypesDialog*)lParam;
00344       SetWindowLong(hWnd, GWL_USERDATA, (LONG)pThis);
00345
00346       //On INIT we know we have a valid hWnd to store
00347       CenterDialog(hWnd);
00348       pThis->m_hWnd = hWnd;
00349
00350       //Tell TableCopy to Map the Types from the Source->Target
00351       //If MapTypes fails, start over, (ie: same as hitting OK)
00352       if(FAILED(pThis->m_pCTableCopy->MapTypes()))
00353       {
00354         EndDialog(hWnd, 0);
00355         return UNHANDLED_MSG;
00356       }
00357
00358       pThis->InitControls();
00359       pThis->RefreshControls();
00360
00361       // Now Display the lists of Mappings
00362       pThis->ResetTypeLists();
00363       pThis->m_pCTableCopy->m_pCWizard->DestroyPrevStep(WIZ_TYPES);
00364       return HANDLED_MSG;
00365     }
00366
00367     // Now look for WM_NOTIFY messages
00368     case WM_NOTIFY:
00369     {
00370       if(wParam == IDL_FROM_TYPES || wParam == IDL_TO_TYPES)
00371       {
00372         //Obtain the "this" pointer
00373         CTypesDialog* pThis = (CTypesDialog*)GetWindowLong(hWnd, GWL_USERDATA);
00374         NM_LISTVIEW* pListView = (NM_LISTVIEW*)lParam;
00375
00376         switch(pListView->hdr.code)
00377         {
00378           case LVN_ITEMCHANGED:
00379           {
00380             if(pListView->uNewState & LVNI_FOCUSED &&
00381               pListView->uNewState & LVNI_SELECTED)
00382             {
00383               if(wParam == IDL_FROM_TYPES)
00384               {
00385                 Busy();
00386                 SyncSibling(GetDlgItem(hWnd,IDL_TO_TYPES), GetDlgItem(hWnd,IDL_FROM_TYPES));
00387                       return HANDLED_MSG;
00388               }
00389
00390               if(wParam == IDL_TO_TYPES)
00391               {
00392                 Busy();
00393                 SyncSibling(GetDlgItem(hWnd,IDL_FROM_TYPES), GetDlgItem(hWnd,IDL_TO_TYPES));
00394                         return HANDLED_MSG;
00395               }
00396               return UNHANDLED_MSG; //No return Value
00397             }
00398             return UNHANDLED_MSG;
00399           }//case LVN_ITEMCHANGED
00400         }
00401         return UNHANDLED_MSG;
00402       }//IDL_TABLES
00403       return UNHANDLED_MSG;
00404     }//WM_NOTIFY
00405
00406     case WM_COMMAND:
00407     {
00408       // All buttons are handled the same way
00409
00410       //Obtain the "this" pointer
00411       CTypesDialog* pThis = (CTypesDialog*)GetWindowLong(hWnd, GWL_USERDATA);
00412
00413       switch(GET_WM_COMMAND_ID(wParam, lParam))
00414       {
00415                 case IDOK:
00416           //Now copy the Tables
00417           pThis->m_pCTableCopy->CopyTables();
00418
00419           Busy();
00420           pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP1);
00421                   return HANDLED_MSG;
00422
00423         case IDB_PREV:
00424           Busy();
00425           pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP4);
00426                   return HANDLED_MSG;
00427
00428         case IDCANCEL:
00429           Busy();
00430           EndDialog(hWnd, GET_WM_COMMAND_ID(wParam, lParam));
00431                   return HANDLED_MSG;
00432       }
00433     }
00434   }
00435
00436   return UNHANDLED_MSG;
00437 }
00438
00439
00440 /////////////////////////////////////////////////////////////////////////////
00441 // BOOL CTypesDialog::InitControls
00442 //
00443 /////////////////////////////////////////////////////////////////////////////
00444 BOOL CTypesDialog::InitControls()
00445 {
00446   HWND hWndFrom = GetDlgItem(m_hWnd, IDL_FROM_TYPES);
00447   HWND hWndTo = GetDlgItem(m_hWnd, IDL_TO_TYPES);
00448
00449   CDataSource* pCFromDataSource = m_pCTableCopy->m_pCFromTable->m_pCDataSource;
00450   CDataSource* pCToDataSource = m_pCTableCopy->m_pCToTable->m_pCDataSource;
00451
00452   //CONNECT_STRING
00453   wSetDlgItemText(m_hWnd, IDT_FROM_CONNECT, wsz_TYPES_STRING_,
00454     pCFromDataSource->m_pwszProviderName,
00455     pCFromDataSource->m_pwszDataSource,
00456     pCFromDataSource->m_pwszTableTerm,
00457     m_pCTableCopy->m_pCFromTable->m_wszQualTableName);
00458
00459   //CONNECT_STRING
00460   wSetDlgItemText(m_hWnd, IDT_TO_CONNECT, wsz_TYPES_STRING_,
00461     pCToDataSource->m_pwszProviderName,
00462     pCToDataSource->m_pwszDataSource,
00463     pCToDataSource->m_pwszTableTerm,
00464     m_pCTableCopy->m_pCToTable->m_wszQualTableName);
00465
00466   //Create the Col ImageList
00467   HIMAGELIST hColImageList = ImageList_Create(16, 16, ILC_MASK, 1, 0 );
00468
00469   //IDI_COLUMN - normal column icon
00470   HICON hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_COLUMN));
00471   ImageList_AddIcon(hColImageList, hIcon);
00472   //IDI_COLUMNREAD - read-only column icon
00473   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_COLUMNREAD));
00474   ImageList_AddIcon(hColImageList, hIcon);
00475   //IDI_COLUMNLONG - long column icon
00476   hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_COLUMNLONG));
00477   ImageList_AddIcon(hColImageList, hIcon);
00478
00479   //Set image list to the Table Window
00480   ListView_SetImageList(hWndFrom, hColImageList, LVSIL_SMALL);
00481   ListView_SetImageList(hWndTo, hColImageList, LVSIL_SMALL);
00482
00483   //Use Extended ListView Styles!
00484   SendMessage(hWndFrom, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
00485   SendMessage(hWndTo, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES);
00486
00487   //Source ListView COLUMNS
00488   LV_InsertColumn(hWndFrom, COL_COLNAME,    "ColName");
00489   LV_InsertColumn(hWndFrom, COL_COLTYPENAME,  "TypeName");
00490   LV_InsertColumn(hWndFrom, COL_COLTYPE,    "Type");
00491   LV_InsertColumn(hWndFrom, COL_COLSIZE,    "Size");
00492   LV_InsertColumn(hWndFrom, COL_COLORDINAL,   "Ordinal");
00493   LV_InsertColumn(hWndFrom, COL_COLPREC,    "Precision");
00494   LV_InsertColumn(hWndFrom, COL_COLSCALE,   "Scale");
00495   LV_InsertColumn(hWndFrom, COL_COLISFIXED,   "ISFIXED");
00496   LV_InsertColumn(hWndFrom, COL_COLISLONG,    "ISLONG");
00497   LV_InsertColumn(hWndFrom, COL_COLISNULLABLE,  "ISNULLABLE");
00498   LV_InsertColumn(hWndFrom, COL_COLWRITE,   "WRITE");
00499   LV_InsertColumn(hWndFrom, COL_COLISROWID,   "ISROWID");
00500   LV_InsertColumn(hWndFrom, COL_COLISROWVER,  "ISROWVER");
00501
00502   //Target ListView COLUMNS
00503   LV_InsertColumn(hWndTo,   COL_COLNAME,    "ColName");
00504   LV_InsertColumn(hWndTo,   COL_COLTYPENAME,  "TypeName");
00505   LV_InsertColumn(hWndTo,   COL_COLTYPE,    "Type");
00506   LV_InsertColumn(hWndTo,   COL_COLSIZE,    "Size");
00507   LV_InsertColumn(hWndTo,   COL_COLORDINAL,   "Ordinal");
00508   LV_InsertColumn(hWndTo,   COL_COLPREC,    "Precision");
00509   LV_InsertColumn(hWndTo,   COL_COLSCALE,   "Scale");
00510   LV_InsertColumn(hWndTo,   COL_COLISFIXED,   "ISFIXED");
00511   LV_InsertColumn(hWndTo,   COL_COLISLONG,    "ISLONG");
00512   LV_InsertColumn(hWndTo,   COL_COLISNULLABLE,  "ISNULLABLE");
00513   LV_InsertColumn(hWndTo,   COL_COLWRITE,   "WRITE");
00514   LV_InsertColumn(hWndTo,   COL_COLISROWID,   "ISROWID");
00515   LV_InsertColumn(hWndTo,   COL_COLISROWVER,  "ISROWVER");
00516
00517   //AutoSize all columns
00518   for(ULONG i=0; i<=COL_COLISROWVER; i++)
00519   {
00520     SendMessage(hWndFrom, LVM_SETCOLUMNWIDTH, (WPARAM)i,    (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
00521     SendMessage(hWndTo, LVM_SETCOLUMNWIDTH, (WPARAM)i,    (LPARAM)LVSCW_AUTOSIZE_USEHEADER);
00522   }
00523   return TRUE;
00524 }
00525
00526 /////////////////////////////////////////////////////////////////////////////
00527 // BOOL CTypesDialog::RefreshControls
00528 //
00529 /////////////////////////////////////////////////////////////////////////////
00530 BOOL CTypesDialog::RefreshControls()
00531 {
00532   return TRUE;
00533 }
00534
00535 /////////////////////////////////////////////////////////////////////////////
00536 // BOOL CTypesDialog::ResetTypeLists
00537 //
00538 /////////////////////////////////////////////////////////////////////////////
00539 BOOL CTypesDialog::ResetTypeLists()
00540 {
00541   HWND    hWndFrom;       // From data types
00542   HWND    hWndTo;         // To data types
00543
00544   WCHAR   wszBuffer[MAX_NAME_LEN];
00545   CHAR    szBuffer[MAX_NAME_LEN];
00546
00547   CTable* pCFromTable = m_pCTableCopy->m_pCFromTable;
00548   CTable* pCToTable = m_pCTableCopy->m_pCToTable;
00549
00550   // Get window handles to speed up the population
00551   hWndFrom = GetDlgItem(m_hWnd, IDL_FROM_TYPES);
00552   hWndTo   = GetDlgItem(m_hWnd, IDL_TO_TYPES);
00553
00554   // Now populate each list
00555   for(ULONG i=0;  i<pCFromTable->m_cColumns; i++)
00556   {
00557     COLDESC* pCFromColDesc = &pCFromTable->m_rgColDesc[i];
00558     COLDESC* pCToColDesc = &pCToTable->m_rgColDesc[i];
00559
00560     //COLNAME (item)
00561     ConvertToMBCS(pCFromColDesc->wszColName, szBuffer, MAX_NAME_LEN);
00562     LV_InsertItem(hWndFrom, i, COL_COLNAME, szBuffer, 0, pCFromColDesc->dwFlags & (DBCOLUMNFLAGS_WRITE | DBCOLUMNFLAGS_WRITEUNKNOWN) ? ((pCFromColDesc->dwFlags & DBCOLUMNFLAGS_ISLONG) ? ICON_LONG : ICON_COLUMN) : ICON_READONLY);
00563     ConvertToMBCS(pCToColDesc->wszColName, szBuffer, MAX_NAME_LEN);
00564     LV_InsertItem(hWndTo, i, COL_COLNAME, szBuffer, 0, pCToColDesc->dwFlags & (DBCOLUMNFLAGS_WRITE | DBCOLUMNFLAGS_WRITEUNKNOWN) ? ((pCToColDesc->dwFlags & DBCOLUMNFLAGS_ISLONG) ? ICON_LONG : ICON_COLUMN) : ICON_READONLY);
00565
00566     //COLTYPENAME (subitem)
00567     pCFromTable->GetTypeNameAndParams(i, wszBuffer);
00568     ConvertToMBCS(wszBuffer, szBuffer, MAX_NAME_LEN);
00569     LV_InsertItem(hWndFrom, i, COL_COLTYPENAME, szBuffer);
00570     pCToTable->GetTypeNameAndParams(i, wszBuffer);
00571     ConvertToMBCS(wszBuffer, szBuffer, MAX_NAME_LEN);
00572     LV_InsertItem(hWndTo, i, COL_COLTYPENAME, szBuffer);
00573
00574     //COLTYPE (subitem)
00575     ConvertToMBCS(GetDBTypeName(pCFromColDesc->wType), szBuffer, MAX_NAME_LEN);
00576     LV_InsertItem(hWndFrom, i, COL_COLTYPE, szBuffer);
00577     ConvertToMBCS(GetDBTypeName(pCToColDesc->wType), szBuffer, MAX_NAME_LEN);
00578     LV_InsertItem(hWndTo, i, COL_COLTYPE, szBuffer);
00579
00580     //Ordinal (SubItem)
00581     sprintf(szBuffer, "%d", pCFromColDesc->iOrdinal);
00582     LV_InsertItem(hWndFrom, i, COL_COLORDINAL, szBuffer);
00583     sprintf(szBuffer, "%d", pCToColDesc->iOrdinal);
00584     LV_InsertItem(hWndTo, i, COL_COLORDINAL, szBuffer);
00585
00586     //ColumnSize (SubItem)
00587     sprintf(szBuffer, "%d", pCFromColDesc->ulColumnSize);
00588     LV_InsertItem(hWndFrom, i, COL_COLSIZE, szBuffer);
00589     sprintf(szBuffer, "%d", pCToColDesc->ulColumnSize);
00590     LV_InsertItem(hWndTo, i, COL_COLSIZE, szBuffer);
00591
00592     //Precision (SubItem)
00593     sprintf(szBuffer, "%d", pCFromColDesc->bPrecision);
00594     LV_InsertItem(hWndFrom, i, COL_COLPREC, szBuffer);
00595     sprintf(szBuffer, "%d", pCToColDesc->bPrecision);
00596     LV_InsertItem(hWndTo, i, COL_COLPREC, szBuffer);
00597
00598     //Scale (SubItem)
00599     sprintf(szBuffer, "%d", pCFromColDesc->bScale);
00600     LV_InsertItem(hWndFrom, i, COL_COLSCALE, szBuffer);
00601     sprintf(szBuffer, "%d", pCToColDesc->bScale);
00602     LV_InsertItem(hWndTo, i, COL_COLSCALE, szBuffer);
00603
00604     //ISFIXED (SubItem)
00605     LV_InsertItem(hWndFrom, i, COL_COLISFIXED, pCFromColDesc->dwFlags & DBCOLUMNFLAGS_ISFIXEDLENGTH ? "TRUE" : "FALSE");
00606     LV_InsertItem(hWndTo, i, COL_COLISFIXED, pCToColDesc->dwFlags & DBCOLUMNFLAGS_ISFIXEDLENGTH ? "TRUE" : "FALSE");
00607
00608     //ISLONG (SubItem)
00609     LV_InsertItem(hWndFrom, i, COL_COLISLONG, pCFromColDesc->dwFlags & DBCOLUMNFLAGS_ISLONG ? "TRUE" : "FALSE");
00610     LV_InsertItem(hWndTo, i, COL_COLISLONG, pCToColDesc->dwFlags & DBCOLUMNFLAGS_ISLONG ? "TRUE" : "FALSE");
00611
00612     //ISNULLABLE (SubItem)
00613     LV_InsertItem(hWndFrom, i, COL_COLISNULLABLE, pCFromColDesc->dwFlags & DBCOLUMNFLAGS_ISNULLABLE ? "TRUE" : "FALSE");
00614     LV_InsertItem(hWndTo, i, COL_COLISNULLABLE, pCToColDesc->dwFlags & DBCOLUMNFLAGS_ISNULLABLE ? "TRUE" : "FALSE");
00615
00616     //WRITE (SubItem)
00617     LV_InsertItem(hWndFrom, i, COL_COLWRITE, pCFromColDesc->dwFlags & (DBCOLUMNFLAGS_WRITE | DBCOLUMNFLAGS_WRITEUNKNOWN) ? "TRUE" : "FALSE");
00618     LV_InsertItem(hWndTo, i, COL_COLWRITE, pCToColDesc->dwFlags & (DBCOLUMNFLAGS_WRITE | DBCOLUMNFLAGS_WRITEUNKNOWN) ? "TRUE" : "FALSE");
00619
00620     //ISROWID (SubItem)
00621     LV_InsertItem(hWndFrom, i, COL_COLISROWID, pCFromColDesc->dwFlags & DBCOLUMNFLAGS_ISROWID ? "TRUE" : "FALSE");
00622     LV_InsertItem(hWndTo, i, COL_COLISROWID, pCToColDesc->dwFlags & DBCOLUMNFLAGS_ISROWID ? "TRUE" : "FALSE");
00623
00624     //ISROWVER (SubItem)
00625     LV_InsertItem(hWndFrom, i, COL_COLISROWVER, pCFromColDesc->dwFlags & DBCOLUMNFLAGS_ISROWVER ? "TRUE" : "FALSE");
00626     LV_InsertItem(hWndTo, i, COL_COLISROWVER, pCToColDesc->dwFlags & DBCOLUMNFLAGS_ISROWVER ? "TRUE" : "FALSE");
00627   }
00628
00629   return TRUE;
00630 }
00631
00632
Generated on Wed Nov 13 2024 16:52:10 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/tsfapp/tsfwnd.h Source File

  • WinUI
  • tsfapp

tsfwnd.h

Go to the documentation of this file.
00001 /**************************************************************************
00002    THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
00003    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005    PARTICULAR PURPOSE.
00006
00007    Copyright 2001 Microsoft Corporation.  All Rights Reserved.
00008 **************************************************************************/
00009
00010 /**************************************************************************
00011
00012    File:          TSFWnd.h
00013
00014    Description:   CTSFMainWnd Class Declaration
00015
00016 **************************************************************************/
00017
00018 #ifndef TSFMAINWND_H
00019 #define TSFMAINWND_H
00020
00021 /**************************************************************************
00022    #include statements
00023 **************************************************************************/
00024
00025 #include <windows.h>
00026 #include <windowsx.h>
00027 #include <msctf.h>
00028 #include "resource.h"
00029 #include "TSFEdit.h"
00030
00031 /**************************************************************************
00032    global variables and definitions
00033 **************************************************************************/
00034
00035 /**************************************************************************
00036
00037    CTSFMainWnd class definition
00038
00039 **************************************************************************/
00040
00041 class CTSFMainWnd
00042 {
00043 private:
00044     HINSTANCE       m_hInst;
00045     HWND            m_hWnd;
00046     CTSFEditWnd     *m_pTSFEditWnd;
00047     TfClientId      m_tfClientID;
00048
00049 public:
00050     CTSFMainWnd(HINSTANCE hInstance);
00051     ~CTSFMainWnd();
00052
00053     BOOL Initialize(int nCmdShow);
00054
00055 private:
00056     static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
00057     void _CleanupEditWnd(BOOL fNuke);
00058     LRESULT _OnCreate(VOID);
00059     LRESULT _OnDestroy(VOID);
00060     LRESULT _OnCommand(WORD, WORD, HWND);
00061     LRESULT _OnSetFocus(VOID);
00062     LRESULT _OnKillFocus(VOID);
00063     LRESULT _OnNotify(UINT, LPNMHDR);
00064     LRESULT _OnSize(WORD, WORD);
00065     LRESULT _OnActivate(WPARAM);
00066     LRESULT _OnInitMenuPopup(WPARAM, LPARAM);
00067     BOOL _GetFileName(HWND hwndOwner, LPTSTR lpszFileName, ULONG uChars, BOOL fOpen);
00068
00069 };
00070
00071 #endif   //TSFMAINWND_H
Generated on Wed Nov 13 2024 16:52:56 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CFontSet Member List

This is the complete list of members for CFontSet, including all inherited members.
CFontSet(HWND hwnd, HFONT hfont) | CFontSet |
In(WORD iChar)=0 | CSet | [pure virtual]
Generated on Wed Nov 13 2024 16:56:33 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/WinSock/McastIP/Mcastws1.c Source File

  • NetDS
  • WinSock
  • McastIP

Mcastws1.c

Go to the documentation of this file.
00001 // Sample: IPv4/6 Multicasting using Setsockopt
00002 //
00003 // File:
00004 //      mcastws1.c      - this file
00005 //      resolve.c       - common name resolution routines
00006 //      resolve.h       - header file for common name resolution routines
00007 //
00008 // Purpose:
00009 //    This sample illustrates IP multicasting using the Winsock 1
00010 //    method of joining and leaving an multicast group.  This sample
00011 //    may be invoked as either a sender or a receiver. This sample works
00012 //    with both IPv4 and IPv6 multicasting but does not include support
00013 //    for the IPv4 source multicasting.
00014 //
00015 //    One of the advantages of using the setsockopt over WSAJoinLeaf is
00016 //    the ability to join multiple multicast groups on a single socket
00017 //    which is not possible with WSAJoinLeaf.
00018 //
00019 //    Also note that because we include winsock2.h we must link with
00020 //    ws2_32.lib and not with wsock32.lib.
00021 //
00022 // Compile:
00023 //    cl -o mcastws1 mcastws1.c resolve.c ws2_32.lib
00024 //
00025 // Command Line Options/Parameters
00026 //    mcastws1.exe [-s] [-m str] [-p int] [-i str] [-b str] [-l] [-n int]
00027 //       -b str    Local interface to bind to
00028 //       -c        Connect to multicast address before sending?
00029 //       -i str    Local interface to use for the multicast join
00030 //       -j        Don't join the multicast group (sender only)
00031 //       -l        Disable the loopback
00032 //       -m str    Multicast string address to join
00033 //       -n int    Number of messages to send or receive
00034 //       -p int    Port number to use
00035 //       -r        Use raw sockets
00036 //       -s        Act as sender; otherwise receive data
00037 //       -t int    Multicast TTL
00038 //       -u        Set SO_REUSEADDR on socket
00039 //       -z int    Buffer size (in bytes)
00040 //
00041 // NOTE:
00042 //   From Network Programming for Microsoft Windows, Second Edition
00043 //   by Anthony Jones and James Ohlund.  Copyright 2002.
00044 //   Reproduced by permission of Microsoft Press.  All rights reserved.
00045 //
00046 #include <winsock2.h>
00047 #include <ws2tcpip.h>
00048 #include <stdio.h>
00049 #include <stdlib.h>
00050
00051
00052 // This sample uses the new getaddrinfo/getnameinfo functions which are new to
00053 // Windows XP. To run this sample on older OSes, include the following header
00054 // file which makes it work automagically.
00055
00056 #include <wspiapi.h>
00057
00058 #include "resolve.h"
00059
00060 #define MCASTADDRV4    "234.5.6.7"
00061 #define MCASTADDRV6    "ff12::1"
00062 #define MCASTPORT      "25000"
00063 #define BUFSIZE        1024
00064 #define DEFAULT_COUNT  500
00065 #define DEFAULT_TTL    8
00066
00067 BOOL  bSender=FALSE,            // Act as sender?
00068       bConnect=FALSE,           // Connect before sending?
00069       bLoopBack=FALSE,          // Loopback parameter specified?
00070       bDontJoin=FALSE,          // Specifies whether to join the multicast group
00071       bReuseAddr=FALSE;         // Set SO_REUSEADDR
00072 int   gSocketType=SOCK_DGRAM,   // datagram
00073       gProtocol=IPPROTO_UDP,    // UDP
00074       gLoopBack=0,              // Disable loopback?
00075       gCount=DEFAULT_COUNT,     // Number of messages to send/receive
00076       gTtl=DEFAULT_TTL,         // Multicast TTL value
00077       gBufferSize=BUFSIZE;      // Buffer size for send/recv
00078 char *gBindAddr=NULL,           // Address to bind socket to (default is 0.0.0.0 or ::)
00079      *gInterface=NULL,          // Interface to join the multicast group on
00080      *gMulticast=MCASTADDRV4,   // Multicast group to join
00081      *gPort=MCASTPORT;          // Port number to use
00082
00083 //
00084 // Function: usage
00085 //
00086 // Description:
00087 //    Print usage information and exit.
00088 //
00089 void usage(char *progname)
00090 {
00091     printf("usage: %s -s -m str -p int -i str -l -n int\n",
00092         progname);
00093     printf(" -b str String address to bind to\n");
00094     printf(" -c     Connect before sending?\n");
00095     printf(" -i str Local interface to join groups\n");
00096     printf(" -j     Don't join the multicast group\n");
00097     printf(" -l 0/1 Turn on/off loopback\n");
00098     printf(" -m str Multicast address string to join\n");
00099     printf(" -n int Number of messages to send/receive\n");
00100     printf(" -p int Port number to use\n");
00101     printf("          The default port is: %s\n", MCASTPORT);
00102     printf(" -r     Use raw sockets\n");
00103     printf(" -s     Act as server (send data); otherwise\n");
00104     printf("          receive data.\n");
00105     printf(" -t int Set multicast TTL\n");
00106     printf(" -u     Set SO_REUSEADDR\n");
00107     printf(" -z int Size of the send/recv buffer\n");
00108     ExitProcess(-1);
00109 }
00110
00111 //
00112 // Function: ValidateArgs
00113 //
00114 // Description
00115 //    Parse the command line arguments and set some global flags
00116 //    depeding on the values.
00117 //
00118 void ValidateArgs(int argc, char **argv)
00119 {
00120     int      i;
00121
00122     for(i=1; i < argc ;i++)
00123     {
00124         if ((argv[i][0] == '-') || (argv[i][0] == '/'))
00125         {
00126             switch (tolower(argv[i][1]))
00127             {
00128                 case 'b':        // Address to bind to
00129                     if (i+1 >= argc)
00130                         usage(argv[0]);
00131                     gBindAddr = argv[++i];
00132                     break;
00133                 case 'c':        // Connect socket
00134                     bConnect = TRUE;
00135                     break;
00136                 case 'i':        // local interface to use
00137                     if (i+1 >= argc)
00138                         usage(argv[0]);
00139                     gInterface = argv[++i];
00140                     break;
00141                 case 'j':       // Don't join multicast group
00142                     bDontJoin = TRUE;
00143                     break;
00144                 case 'l':        // Disable loopback?
00145                     if (i+1 >= argc)
00146                         usage(argv[0]);
00147                     bLoopBack = TRUE;
00148                     gLoopBack = atoi(argv[++i]);
00149                     break;
00150                 case 'm':        // multicast group to join
00151                     if (i+1 >= argc)
00152                         usage(argv[0]);
00153                     gMulticast = argv[++i];
00154                     break;
00155                 case 'n':        // Number of messages to send/recv
00156                     if (i+1 >= argc)
00157                         usage(argv[0]);
00158                     gCount = atoi(argv[++i]);
00159                     break;
00160                 case 'p':        // Port number to use
00161                     if (i+1 >= argc)
00162                         usage(argv[0]);
00163                     gPort = argv[++i];
00164                     break;
00165                 case 'r':        // use raw sockets
00166                     gSocketType = SOCK_RAW;
00167                     break;
00168                 case 's':        // sender
00169                     bSender = TRUE;
00170                     break;
00171                 case 't':        // Multicast ttl
00172                     if (i+1 >= argc)
00173                         usage(argv[0]);
00174                     gTtl = atoi(argv[++i]);
00175                     break;
00176                 case 'u':
00177                     bReuseAddr = TRUE;
00178                     break;
00179                 case 'z':        // Buffer size for send/recv
00180                     if (i+1 >= argc)
00181                         usage(argv[0]);
00182                     gBufferSize = atol(argv[++i]);
00183                     break;
00184                 default:
00185                     usage(argv[0]);
00186                     break;
00187             }
00188         }
00189     }
00190     return;
00191 }
00192
00193 //
00194 // Function: JoinMulticastGroup
00195 //
00196 // Description:
00197 //    This function joins the multicast socket on the specified multicast
00198 //    group. The structures for IPv4 and IPv6 multicast joins are slightly
00199 //    different which requires different handlers. For IPv6 the scope-ID
00200 //    (interface index) is specified for the local interface whereas for IPv4
00201 //    the actual IPv4 address of the interface is given.
00202 //
00203 int JoinMulticastGroup(SOCKET s, struct addrinfo *group, struct addrinfo *iface)
00204 {
00205     struct ip_mreq   mreqv4;
00206     struct ipv6_mreq mreqv6;
00207     char            *optval=NULL;
00208     int              optlevel,
00209                      option,
00210                      optlen,
00211                      rc;
00212
00213     rc = NO_ERROR;
00214     if (group->ai_family == AF_INET)
00215     {
00216         // Setup the v4 option values and ip_mreq structure
00217         optlevel = IPPROTO_IP;
00218         option   = IP_ADD_MEMBERSHIP;
00219         optval   = (char *)& mreqv4;
00220         optlen   = sizeof(mreqv4);
00221
00222         mreqv4.imr_multiaddr.s_addr = ((SOCKADDR_IN *)group->ai_addr)->sin_addr.s_addr;
00223         mreqv4.imr_interface.s_addr = ((SOCKADDR_IN *)iface->ai_addr)->sin_addr.s_addr;
00224
00225     }
00226     else if (group->ai_family == AF_INET6)
00227     {
00228         // Setup the v6 option values and ipv6_mreq structure
00229         optlevel = IPPROTO_IPV6;
00230         option   = IPV6_ADD_MEMBERSHIP;
00231         optval   = (char *) &mreqv6;
00232         optlen   = sizeof(mreqv6);
00233
00234         mreqv6.ipv6mr_multiaddr = ((SOCKADDR_IN6 *)group->ai_addr)->sin6_addr;
00235         mreqv6.ipv6mr_interface = ((SOCKADDR_IN6 *)iface->ai_addr)->sin6_scope_id;
00236     }
00237     else
00238     {
00239         fprintf(stderr, "Attemtping to join multicast group for invalid address family!\n");
00240         rc = SOCKET_ERROR;
00241     }
00242     if (rc != SOCKET_ERROR)
00243     {
00244         // Join the group
00245         rc = setsockopt(
00246                 s,
00247                 optlevel,
00248                 option,
00249                 optval,
00250                 optlen
00251                 );
00252         if (rc == SOCKET_ERROR)
00253         {
00254             fprintf(stderr, "JoinMulticastGroup: setsockopt failed: %d\n", WSAGetLastError());
00255         }
00256         else
00257         {
00258             printf("Joined group: ");
00259             PrintAddress(group->ai_addr, group->ai_addrlen);
00260             printf("\n");
00261         }
00262     }
00263     return rc;
00264 }
00265
00266 //
00267 // Function: SetSendInterface
00268 //
00269 // Description:
00270 //    This routine sets the send (outgoing) interface of the socket.
00271 //    Again, for v4 the IP address is used to specify the interface while
00272 //    for v6 its the scope-ID.
00273 //
00274 int SetSendInterface(SOCKET s, struct addrinfo *iface)
00275 {
00276     char *optval=NULL;
00277     int   optlevel,
00278           option,
00279           optlen,
00280           rc;
00281
00282     rc = NO_ERROR;
00283     if (iface->ai_family == AF_INET)
00284     {
00285         // Setup the v4 option values
00286         optlevel = IPPROTO_IP;
00287         option   = IP_MULTICAST_IF;
00288         optval   = (char *) &((SOCKADDR_IN *)iface->ai_addr)->sin_addr.s_addr;
00289         optlen   = sizeof(((SOCKADDR_IN *)iface->ai_addr)->sin_addr.s_addr);
00290     }
00291     else if (iface->ai_family == AF_INET6)
00292     {
00293         // Setup the v6 option values
00294         optlevel = IPPROTO_IPV6;
00295         option   = IPV6_MULTICAST_IF;
00296         optval   = (char *) &((SOCKADDR_IN6 *)iface->ai_addr)->sin6_scope_id;
00297         optlen   = sizeof(((SOCKADDR_IN6 *)iface->ai_addr)->sin6_scope_id);
00298     }
00299     else
00300     {
00301         fprintf(stderr, "Attemtping to set sent interface for invalid address family!\n");
00302         rc = SOCKET_ERROR;
00303     }
00304
00305     // Set send IF
00306     if (rc != SOCKET_ERROR)
00307     {
00308         // Set the send interface
00309         rc = setsockopt(
00310                 s,
00311                 optlevel,
00312                 option,
00313                 optval,
00314                 optlen
00315                        );
00316         if (rc == SOCKET_ERROR)
00317         {
00318             fprintf(stderr, "setsockopt failed: %d\n", WSAGetLastError());
00319         }
00320         else
00321         {
00322             printf("Set sending interface to: ");
00323             PrintAddress(iface->ai_addr, iface->ai_addrlen);
00324             printf("\n");
00325         }
00326     }
00327     return rc;
00328 }
00329
00330 //
00331 // Function: SetMulticastTtl
00332 //
00333 // Description:
00334 //    This routine sets the multicast TTL value for the socket.
00335 //
00336 int SetMulticastTtl(SOCKET s, int af, int ttl)
00337 {
00338     char *optval=NULL;
00339     int   optlevel,
00340           option,
00341           optlen,
00342           rc;
00343
00344     rc = NO_ERROR;
00345     if (af == AF_INET)
00346     {
00347         // Set the options for V4
00348         optlevel = IPPROTO_IP;
00349         option   = IP_MULTICAST_TTL;
00350         optval   = (char *) &ttl;
00351         optlen   = sizeof(ttl);
00352     }
00353     else if (af == AF_INET6)
00354     {
00355         // Set the options for V6
00356         optlevel = IPPROTO_IPV6;
00357         option   = IPV6_MULTICAST_HOPS;
00358         optval   = (char *) &ttl;
00359         optlen   = sizeof(ttl);
00360     }
00361     else
00362     {
00363         fprintf(stderr, "Attemtping to set TTL for invalid address family!\n");
00364         rc = SOCKET_ERROR;
00365     }
00366     if (rc != SOCKET_ERROR)
00367     {
00368         // Set the TTL value
00369         rc = setsockopt(
00370                 s,
00371                 optlevel,
00372                 option,
00373                 optval,
00374                 optlen
00375                 );
00376         if (rc == SOCKET_ERROR)
00377         {
00378             fprintf(stderr, "SetMulticastTtl: setsockopt failed: %d\n", WSAGetLastError());
00379         }
00380         else
00381         {
00382             printf("Set multicast ttl to: %d\n", ttl);
00383         }
00384     }
00385     return rc;
00386 }
00387
00388 //
00389 // Function: SetMulticastLoopBack
00390 //
00391 // Description:
00392 //    This function enabled or disables multicast loopback. If loopback is enabled
00393 //    (and the socket is a member of the destination multicast group) then the
00394 //    data will be placed in the receive queue for the socket such that if a
00395 //    receive is posted on the socket its own data will be read. For this sample
00396 //    it doesn't really matter as if invoked as the sender, no data is read.
00397 //
00398 int SetMulticastLoopBack(SOCKET s, int af, int loopval)
00399 {
00400     char *optval=NULL;
00401     int   optlevel,
00402           option,
00403           optlen,
00404           rc;
00405
00406     rc = NO_ERROR;
00407     if (af == AF_INET)
00408     {
00409         // Set the v4 options
00410         optlevel = IPPROTO_IP;
00411         option   = IP_MULTICAST_LOOP;
00412         optval   = (char *) &loopval;
00413         optlen   = sizeof(loopval);
00414     }
00415     else if (af == AF_INET6)
00416     {
00417         // Set the v6 options
00418         optlevel = IPPROTO_IPV6;
00419         option   = IPV6_MULTICAST_LOOP;
00420         optval   = (char *) &loopval;
00421         optlen   = sizeof(loopval);
00422     }
00423     else
00424     {
00425         fprintf(stderr, "Attemtping to set multicast loopback for invalid address family!\n");
00426         rc = SOCKET_ERROR;
00427     }
00428     if (rc != SOCKET_ERROR)
00429     {
00430         // Set the multpoint loopback
00431         rc = setsockopt(
00432                 s,
00433                 optlevel,
00434                 option,
00435                 optval,
00436                 optlen
00437                 );
00438         if (rc == SOCKET_ERROR)
00439         {
00440             fprintf(stderr, "SetMulticastLoopBack: setsockopt failed: %d\n", WSAGetLastError());
00441         }
00442         else
00443         {
00444             printf("Setting multicast loopback to: %d\n", loopval);
00445         }
00446     }
00447     return rc;
00448 }
00449
00450 //
00451 // Function: main
00452 //
00453 // Description:
00454 //    Parse the command line arguments, load the Winsock library,
00455 //    create a socket and join the multicast group. If set as a
00456 //    sender then begin sending messages to the multicast group;
00457 //    otherwise, call recvfrom() to read messages send to the
00458 //    group.
00459 //
00460 int __cdecl main(int argc, char **argv)
00461 {
00462     WSADATA             wsd;
00463     SOCKET              s=INVALID_SOCKET;
00464     struct addrinfo    *resmulti=NULL,
00465                        *resbind=NULL,
00466                        *resif=NULL;
00467     char               *buf=NULL;
00468     int                 rc,
00469                         i=0;
00470
00471     // Parse the command line
00472     ValidateArgs(argc, argv);
00473
00474     // Load Winsock
00475     if ((rc = WSAStartup(MAKEWORD(1, 1), &wsd)) != 0)
00476     {
00477         fprintf(stderr, "WSAStartup failed: %d\n", rc);
00478         return -1;
00479     }
00480
00481     // Resolve the multicast address
00482     resmulti = ResolveAddress(gMulticast, gPort, AF_UNSPEC, SOCK_DGRAM, gProtocol);
00483     if (resmulti == NULL)
00484     {
00485         fprintf(stderr, "Unable to convert multicast address '%s': %d\n",
00486                 gMulticast, WSAGetLastError());
00487         goto cleanup;
00488     }
00489
00490     // Resolve the binding address
00491     resbind = ResolveAddress(gBindAddr, (bSender ? "0" : gPort), resmulti->ai_family, resmulti->ai_socktype, resmulti->ai_protocol);
00492     if (resbind == NULL)
00493     {
00494         fprintf(stderr, "Unable to convert bind address '%s': %d\n",
00495                 gBindAddr, WSAGetLastError());
00496         goto cleanup;
00497     }
00498
00499     // Resolve the multicast interface
00500     resif   = ResolveAddress(gInterface, "0", resmulti->ai_family, resmulti->ai_socktype, resmulti->ai_protocol);
00501     if (resif == NULL)
00502     {
00503         fprintf(stderr, "Unable to convert interface address '%s': %d\n",
00504                 gInterface, WSAGetLastError());
00505         goto cleanup;
00506     }
00507     //
00508     // Create the socket. In Winsock 1 you don't need any special
00509     // flags to indicate multicasting.
00510     //
00511     s = socket(resmulti->ai_family, resmulti->ai_socktype, resmulti->ai_protocol);
00512     if (s == INVALID_SOCKET)
00513     {
00514         fprintf(stderr, "socket failed with: %d\n", WSAGetLastError());
00515         goto cleanup;
00516     }
00517
00518     if (bReuseAddr)
00519     {
00520         int     optval;
00521
00522         optval = 1;
00523         rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval));
00524         if (rc == SOCKET_ERROR)
00525         {
00526             fprintf(stderr, "setsockopt(SO_REUSEADDR) failed: %d\n", WSAGetLastError());
00527             goto cleanup;
00528         }
00529     }
00530
00531     //
00532     // Bind the socket to the local interface. This is done so we
00533     // can receive data
00534     //
00535     rc = bind(s, resbind->ai_addr, resbind->ai_addrlen);
00536     if (rc == SOCKET_ERROR)
00537     {
00538         fprintf(stderr, "bind failed: %d\n", WSAGetLastError());
00539         goto cleanup;
00540     }
00541     printf("Binding to ");
00542     PrintAddress(resbind->ai_addr, resbind->ai_addrlen);
00543     printf("\n");
00544
00545     // Join the multicast group if specified
00546     if (bDontJoin == FALSE)
00547     {
00548         rc = JoinMulticastGroup(s, resmulti, resif);
00549         if (rc == SOCKET_ERROR)
00550         {
00551             fprintf(stderr, "Unable to join multicast group!\n");
00552             goto cleanup;
00553         }
00554     }
00555
00556     // Set the send (outgoing) interface
00557     rc = SetSendInterface(s, resif);
00558     if (rc == SOCKET_ERROR)
00559     {
00560         fprintf(stderr, "Unable to set multicast send interface\n");
00561         goto cleanup;
00562     }
00563
00564     // Set the TTL to something else. The default TTL is one.
00565     rc = SetMulticastTtl(s, resmulti->ai_family, gTtl);
00566     if (rc == SOCKET_ERROR)
00567     {
00568         fprintf(stderr, "Unable to set multicast TTL\n");
00569         goto cleanup;
00570     }
00571
00572     // Disable the loopback if selected. Note that on NT4 and Win95
00573     // you cannot disable it.
00574     if (bLoopBack)
00575     {
00576         rc = SetMulticastLoopBack(s, resmulti->ai_family, gLoopBack);
00577         if (rc == SOCKET_ERROR)
00578         {
00579             fprintf(stderr, "Unable to set multicast loopback flag\n");
00580             goto cleanup;
00581         }
00582     }
00583
00584     //
00585     // When using sendto on an IPv6 multicast socket, the scope id needs
00586     // to be zero.
00587     //
00588     if ((bSender) && (resmulti->ai_family == AF_INET6))
00589         ((SOCKADDR_IN6 *)resmulti->ai_addr)->sin6_scope_id = 0;
00590
00591     if (bConnect)
00592     {
00593         rc = connect(s, resmulti->ai_addr, resmulti->ai_addrlen);
00594         if (rc == SOCKET_ERROR)
00595         {
00596             fprintf(stderr, "connect failed: %d\n", WSAGetLastError());
00597             goto cleanup;
00598         }
00599     }
00600
00601     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, gBufferSize);
00602     if (buf == NULL)
00603     {
00604         fprintf(stderr, "HeapAlloc failed: %d\n", GetLastError());
00605         goto cleanup;
00606     }
00607
00608     if (!bSender)           // receiver
00609     {
00610         SOCKADDR_STORAGE safrom;
00611         int              fromlen;
00612
00613         // Receive the specified number of messages
00614         for(i=0; i < gCount ;i++)
00615         {
00616             fromlen = sizeof(safrom);
00617             rc = recvfrom(
00618                     s,
00619                     buf,
00620                     gBufferSize,
00621                     0,
00622                    (SOCKADDR *)&safrom,
00623                    &fromlen
00624                    );
00625             if (rc == SOCKET_ERROR)
00626             {
00627                 fprintf(stderr, "recvfrom failed with: %d\n", WSAGetLastError());
00628                 break;
00629             }
00630
00631             printf("read %d bytes from <", rc);
00632             PrintAddress((SOCKADDR *)&safrom, fromlen);
00633             printf(">\n");
00634         }
00635     }
00636     else                    // sender
00637     {
00638         memset(buf, '^', gBufferSize);
00639
00640         // Send some data
00641         for(i=0; i < gCount ; i++)
00642         {
00643             rc = sendto(
00644                     s,
00645                     buf,
00646                     gBufferSize,
00647                     0,
00648                     resmulti->ai_addr,
00649                     resmulti->ai_addrlen
00650                     );
00651             if (rc == SOCKET_ERROR)
00652             {
00653                 fprintf(stderr, "sendto failed with: %d\n", WSAGetLastError());
00654                 break;
00655             }
00656
00657             printf("SENT %d bytes to ", rc);
00658             PrintAddress(resmulti->ai_addr, resmulti->ai_addrlen);
00659             printf("\n");
00660
00661             Sleep(500);
00662         }
00663     }
00664
00665 cleanup:
00666     //
00667     // Clean up allocations and sockets
00668     //
00669     if (buf)
00670         HeapFree(GetProcessHeap(), 0, buf);
00671
00672     if (resmulti)
00673         freeaddrinfo(resmulti);
00674     if (resbind)
00675         freeaddrinfo(resbind);
00676     if (resif)
00677         freeaddrinfo(resif);
00678
00679     if (s != INVALID_SOCKET)
00680         closesocket(s);
00681
00682     WSACleanup();
00683     return 0;
00684 }
Generated on Wed Nov 13 2024 16:52:26 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSCPPageGeneral Member List

This is the complete list of members for CSCPPageGeneral, including all inherited members.
Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) | CPropertyPage |
Apply() | CPropertyPage |
CPropertyPage(REFCLSID clsid, INT iDialogID) | CPropertyPage |
CSCPPageGeneral(CSCPWiz *pWizExt) | CSCPPageGeneral | [inline]
Deactivate() | CPropertyPage |
DEFINE_ADDREF_RELEASE | CPropertyPage |
DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [static]
GetClassID(CLSID __RPC_FAR *pClassID) | CPropertyPage | [inline]
GetPageInfo(PROPPAGEINFO __RPC_FAR *pPageInfo) | CPropertyPage | [inline, virtual]
GetSummaryInfo(CString &szSummary) | CSCPPageGeneral |
HandleMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | CPropertyPage | [virtual]
Help(LPCOLESTR pszHelpDir) | CPropertyPage | [inline]
IDD enum value | CSCPPageGeneral |
InitNew(void) | CPropertyPage | [inline]
IsPageDirty() | CPropertyPage |
Load(IPropertyBag __RPC_FAR *pPropBag, IErrorLog __RPC_FAR *pErrorLog) | CPropertyPage | [inline]
m_bNeedCreate | CSCPPageGeneral | [private]
m_clsid | CPropertyPage | [protected]
m_cRef | CPropertyPage | [protected]
m_hWnd | CPropertyPage | [protected]
m_iDialogID | CPropertyPage | [protected]
m_pIPropertyPageSite | CPropertyPage | [protected]
m_pWizExt | CSCPPageGeneral | [private]
m_szName | CSCPPageGeneral | [private]
m_szServiceClassName | CSCPPageGeneral | [private]
m_szServiceDNSName | CSCPPageGeneral | [private]
m_szServiceDNSNameType | CSCPPageGeneral | [private]
Move(LPCRECT pRect) | CPropertyPage |
OnDNSNameChange() | CSCPPageGeneral |
OnDNSNameTypeChange() | CSCPPageGeneral |
OnInitDialog() | CSCPPageGeneral | [virtual]
OnKillActive() | CSCPPageGeneral | [virtual]
OnNameChange() | CSCPPageGeneral |
OnServiceClassChange() | CSCPPageGeneral |
OnSetActive() | CSCPPageGeneral | [virtual]
QueryInterface(REFIID riid, LPVOID *ppv) | CPropertyPage |
Save(IPropertyBag __RPC_FAR *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) | CPropertyPage | [inline]
SetObjects(ULONG cObjects, IUnknown __RPC_FAR *__RPC_FAR *ppUnk) | CPropertyPage | [inline]
SetPageSite(IPropertyPageSite *pPageSite) | CPropertyPage |
SetWizardButtons() | CSCPPageGeneral |
Show(UINT nCmdShow) | CPropertyPage |
TranslateAccelerator(MSG *pMsg) | CPropertyPage |
~CPropertyPage() | CPropertyPage | [virtual]
~CSCPPageGeneral() | CSCPPageGeneral | [inline, virtual]
Generated on Wed Nov 13 2024 16:57:18 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

LineData Member List

This is the complete list of members for LineData, including all inherited members.
linepos | LineData
pdata | LineData
Generated on Wed Nov 13 2024 16:57:53 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/ActiveX/comp.h Source File

  • SysMgmt
  • MMC
  • ActiveX

comp.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to existing Microsoft documentation.
00004 //
00005 //
00006 //
00007 //
00008 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00011 //  PURPOSE.
00012 //
00013 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00014 //
00015 //
00016 //
00017 //==============================================================;
00018
00019 #ifndef _SAMPCOMP_H_
00020 #define _SAMPCOMP_H_
00021
00022 #include <mmc.h>
00023
00024 class CComponent : public IComponent
00025 {
00026 private:
00027     ULONG       m_cref;
00028
00029     IConsole*   m_ipConsole;
00030     IDisplayHelp* m_ipDisplayHelp;
00031     IControlbar*    m_ipControlBar;
00032
00033     class CComponentData *m_pComponentData;
00034
00035     public:
00036         CComponent(CComponentData *parent);
00037         ~CComponent();
00038
00039         ///////////////////////////////
00040         // Interface IUnknown
00041         ///////////////////////////////
00042         STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
00043         STDMETHODIMP_(ULONG) AddRef();
00044         STDMETHODIMP_(ULONG) Release();
00045
00046         ///////////////////////////////
00047         // Interface IComponent
00048         ///////////////////////////////
00049         virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Initialize(
00050             /* [in] */ LPCONSOLE lpConsole);
00051
00052             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Notify(
00053             /* [in] */ LPDATAOBJECT lpDataObject,
00054             /* [in] */ MMC_NOTIFY_TYPE event,
00055             /* [in] */ LPARAM arg,
00056             /* [in] */ LPARAM param);
00057
00058             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE Destroy(
00059             /* [in] */ MMC_COOKIE cookie);
00060
00061             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryDataObject(
00062             /* [in] */ MMC_COOKIE cookie,
00063             /* [in] */ DATA_OBJECT_TYPES type,
00064             /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject);
00065
00066             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetResultViewType(
00067             /* [in] */ MMC_COOKIE cookie,
00068             /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
00069             /* [out] */ long __RPC_FAR *pViewOptions);
00070
00071             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetDisplayInfo(
00072             /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem);
00073
00074             virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CompareObjects(
00075             /* [in] */ LPDATAOBJECT lpDataObjectA,
00076             /* [in] */ LPDATAOBJECT lpDataObjectB);
00077 };
00078
00079 #endif _SAMPCOMP_H_
Generated on Wed Nov 13 2024 16:52:32 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/Resource/DynDlg/DynDlg.c Source File

  • WinUI
  • Resource
  • DynDlg

DynDlg.c

Go to the documentation of this file.
00001 /******************************************************************************\
00002 *       This is a part of the Microsoft Source Code Samples.
00003 *       Copyright 1993 - 2000 Microsoft Corporation.
00004 *       All rights reserved.
00005 *       This source code is only intended as a supplement to
00006 *       Microsoft Development Tools and/or WinHelp documentation.
00007 *       See these sources for detailed information regarding the
00008 *       Microsoft samples programs.
00009 \******************************************************************************/
00010
00011 #include <windows.h>
00012 #include "dyndlg.h"
00013
00014 LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM);
00015 LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM );
00016
00017 DWORD Create1 (HWND);
00018 DWORD Create2 (HWND);
00019
00020 WORD* lpwAlign (WORD*);
00021 int nCopyAnsiToWideChar (WORD*, PTSTR);
00022
00023 HINSTANCE ghInst;
00024
00025
00026 /**************************************************************************\
00027 *
00028 *  function:  WinMain ()
00029 *
00030 *  input parameters:  c.f. generic sample
00031 *
00032 \**************************************************************************/
00033 int WINAPI WinMain (
00034     HINSTANCE hInstance,
00035     HINSTANCE hPrevInstance,
00036     LPSTR lpCmdLine,
00037     int nCmdShow )
00038 {
00039     HWND      hwnd     = NULL;
00040     MSG       msg      = {0};
00041     HANDLE    hLibrary = NULL;
00042     WNDCLASS  wc       = {0};
00043     BOOL      bSuccess = TRUE;
00044     BOOL      bRet     = FALSE;
00045
00046     ghInst = hInstance;
00047
00048
00049     wc.lpfnWndProc   = (WNDPROC)MainWndProc;
00050     wc.hInstance     = hInstance;
00051     wc.hIcon         = LoadIcon(hInstance, TEXT("dyndlgIcon"));
00052     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
00053     wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
00054     wc.lpszMenuName  = TEXT("dyndlgMenu");
00055     wc.lpszClassName = TEXT("dyndlg");
00056
00057     if (0 == RegisterClass(&wc))
00058     {
00059         bSuccess = FALSE;
00060         goto exit_func;
00061     }
00062
00063
00064     /* Create the main window.  Return false if CreateWindow() fails */
00065     hwnd = CreateWindow(
00066         TEXT("dyndlg"),
00067         TEXT("DynDlg"),
00068         WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE,
00069         CW_USEDEFAULT, 0,
00070         CW_USEDEFAULT, 0,
00071         NULL, NULL, hInstance, NULL);
00072
00073     if (NULL == hwnd)
00074     {
00075         bSuccess = FALSE;
00076         goto exit_func;
00077     }
00078
00079
00080     /*
00081      * Load SPINCUBE.DLL containing the custom control.
00082      * The above library should be present in the current directory
00083      *
00084      * Generally it is better to pass an absolute path to LoadLibrary.
00085      * Otherwise the API might attempt to load a DLL from the current PATH,
00086      * which presents a potential security breach. Refer to MSDN
00087      * for the documentation on the SearchPath function for the search
00088      * strategy used by the operating system.
00089      */
00090     hLibrary = LoadLibrary (TEXT("SPINCUBE.DLL"));
00091
00092     if (NULL == hLibrary)
00093     {
00094         if (PRIMARYLANGID(GetUserDefaultLangID ()) == LANG_JAPANESE)
00095         {
00096             MessageBox (hwnd, TEXT("LoadLibrary (SPINCUBE.DLL) ‚ªŽ¸”s‚µ‚Ü‚µ‚½B"),
00097                         TEXT("ƒGƒ‰[, ‚±‚ÌƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚Í spincube ‚ª•K—v‚Å‚·"),
00098                         MB_OK | MB_ICONEXCLAMATION);
00099         }
00100         else
00101         {
00102             MessageBox (hwnd, TEXT("LoadLibrary (SPINCUBE.DLL) failed"),
00103                         TEXT("Error, this app requires spincube."),
00104                         MB_OK | MB_ICONEXCLAMATION);
00105         }
00106     }
00107
00108
00109     /* Demo: Just for fun, start out with one of the dialogs created. */
00110     PostMessage (hwnd, WM_COMMAND, IDM_DIALOG2, 0);
00111
00112
00113     ShowWindow (hwnd, SW_SHOWNORMAL);
00114     UpdateWindow (hwnd);
00115
00116
00117     /* Loop getting messages and dispatching them. */
00118     while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
00119     {
00120         if (bRet == -1)
00121         {
00122             bSuccess = FALSE;
00123             goto exit_func;
00124         }
00125         else
00126         {
00127             TranslateMessage(&msg);
00128             DispatchMessage(&msg);
00129         }
00130     }
00131
00132
00133     if (NULL != hLibrary)
00134     {
00135         bSuccess = FreeLibrary (hLibrary);
00136     }
00137
00138
00139 exit_func:
00140     if (TRUE == bSuccess)
00141     {
00142         return (int)(msg.wParam);
00143     }
00144     else
00145     {
00146         return 0;
00147     }
00148 }
00149
00150
00151 /***************************************************************************\
00152 *    FUNCTION: MainWndProc
00153 \***************************************************************************/
00154 LRESULT CALLBACK MainWndProc (
00155     HWND hwnd,
00156     UINT message,
00157     WPARAM wParam,
00158     LPARAM lParam )
00159 {
00160     BOOL bRetDWP = TRUE;
00161
00162     switch (message)
00163     {
00164         /**********************************************************************\
00165         *  Menu item support.
00166         *
00167         \**********************************************************************/
00168         case WM_COMMAND:
00169             switch (LOWORD(wParam))
00170             {
00171                 case IDM_EXIT:
00172                     PostQuitMessage (0);
00173                     break;
00174
00175                 case IDM_DIALOG1:
00176                     Create1 (hwnd);
00177                     break;
00178
00179                 case IDM_DIALOG2:
00180                     Create2 (hwnd);
00181                     break;
00182
00183                 case IDM_HELP:
00184                     WinHelp (hwnd, TEXT("dyndlg.hlp"), HELP_INDEX, 0L);
00185                     break;
00186
00187                 case IDM_ABOUT:
00188                     DialogBox (GetModuleHandle(NULL), TEXT("aboutBox"), hwnd, (DLGPROC)About);
00189                     bRetDWP = FALSE;
00190                     break;
00191             }
00192             break;  /* end wm_command */
00193
00194         case WM_DESTROY:
00195             WinHelp ( hwnd,  TEXT("dyndlg.hlp"), (UINT) HELP_QUIT, 0L );
00196             PostQuitMessage (0);
00197             break;
00198     }
00199
00200
00201     if (bRetDWP)
00202     {
00203         return DefWindowProc (hwnd, message, wParam, lParam);
00204     }
00205     else
00206     {
00207         return 0;
00208     }
00209 }
00210
00211
00212 /****************************************************************************
00213     FUNCTION: About
00214 ****************************************************************************/
00215 LRESULT CALLBACK About (
00216     HWND hwnd,
00217     UINT message,
00218     WPARAM wParam,
00219     LPARAM lParam)
00220 {
00221     BOOL bRet = FALSE;
00222
00223
00224     if (message == WM_INITDIALOG)
00225     {
00226         bRet = TRUE;
00227     }
00228
00229     if ((message == WM_COMMAND) && (LOWORD(wParam) == IDOK))
00230     {
00231         EndDialog (hwnd, TRUE);
00232         bRet = TRUE;
00233     }
00234
00235     if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
00236     {
00237         EndDialog (hwnd, TRUE);
00238         bRet = TRUE;
00239     }
00240
00241
00242     return (LRESULT)bRet;
00243 }
00244
00245
00246
00247
00248 /****************************************************************************
00249     Create the first dialog dynamically.  Notice that we are NOT using
00250     structures here because too many of the fields are of variable length.
00251     Instead, just allocate some memory to play with, and start filling in
00252     the data at that pointer.
00253
00254     p - pointer which is moved down through the DLGTEMPLATE information.
00255     pdlgtemplate - pointer to the TOP of the DLGTEMPLATE information.
00256
00257     Here we create a simple dialog with one item.  The dialog has a title,
00258     the item has text, and the item class is specified by ordinal.  There
00259     is no font information.
00260
00261     In case of error the function returns the error code obtained by calling
00262     GetLastError. Otherwise the function returns ERROR_SUCCESS
00263 ****************************************************************************/
00264 DWORD Create1 (
00265     HWND hwnd )
00266 {
00267     WORD*   p = NULL;
00268     WORD*   pdlgtemplate = NULL;
00269     int     nchar;
00270     DWORD   lStyle;
00271     INT_PTR pSize = 1000;
00272     DWORD   error = ERROR_SUCCESS;
00273
00274
00275     /* allocate some memory to play with  */
00276     p = (PWORD) LocalAlloc (LPTR, pSize);
00277     if (NULL == p)
00278     {
00279         error = GetLastError ();
00280         goto exit_func;
00281     }
00282
00283     pdlgtemplate = p;
00284
00285
00286     /* start to fill in the dlgtemplate information.  addressing by WORDs */
00287     lStyle = DS_MODALFRAME | WS_CAPTION | WS_SYSMENU | WS_VISIBLE;
00288
00289     *p++ = LOWORD (lStyle);
00290     *p++ = HIWORD (lStyle);
00291     *p++ = 0;          // LOWORD (lExtendedStyle)
00292     *p++ = 0;          // HIWORD (lExtendedStyle)
00293     *p++ = 1;          // NumberOfItems
00294     *p++ = 10;         // x
00295     *p++ = 10;         // y
00296     *p++ = 100;        // cx
00297     *p++ = 100;        // cy
00298     *p++ = 0;          // Menu
00299     *p++ = 0;          // Class
00300
00301
00302     pSize -= (p - pdlgtemplate);
00303     pSize /= 2;
00304
00305     /* copy the title of the dialog */
00306     if (PRIMARYLANGID(GetUserDefaultLangID ()) == LANG_JAPANESE)
00307     {
00308         nchar = nCopyAnsiToWideChar (p, TEXT("ƒ^ƒCƒgƒ‹ 1"));
00309     }
00310     else
00311     {
00312         nchar = nCopyAnsiToWideChar (p, TEXT("Title 1"));
00313     }
00314     p += nchar;
00315
00316
00317     /* add in the wPointSize and szFontName here iff the DS_SETFONT bit on */
00318     /* make sure the first item starts on a DWORD boundary */
00319     p = lpwAlign (p);
00320
00321
00322     /* now start with the first item */
00323     lStyle = BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD;
00324
00325     *p++ = LOWORD (lStyle);
00326     *p++ = HIWORD (lStyle);
00327     *p++ = 0;          // LOWORD (lExtendedStyle)
00328     *p++ = 0;          // HIWORD (lExtendedStyle)
00329     *p++ = 10;         // x
00330     *p++ = 70;         // y
00331     *p++ = 80;         // cx
00332     *p++ = 20;         // cy
00333     *p++ = IDOK;       // ID
00334
00335     /* fill in class i.d. Button in this case */
00336     *p++ = (WORD)0xffff;
00337     *p++ = (WORD)0x0080;
00338
00339     /* copy the text of the first item */
00340     nchar = nCopyAnsiToWideChar (p, TEXT("OK"));
00341     p += nchar;
00342
00343     *p++ = 0;  // advance pointer over nExtraStuff WORD
00344
00345     if (NULL == CreateDialogIndirect (ghInst, (LPDLGTEMPLATE) pdlgtemplate, hwnd, (DLGPROC) About))
00346     {
00347         error = GetLastError ();
00348     }
00349
00350     if (NULL != LocalFree (pdlgtemplate))
00351     {
00352         error = GetLastError ();
00353         DebugBreak ();
00354     }
00355
00356
00357 exit_func:
00358     return error;
00359 }
00360
00361
00362
00363
00364 /****************************************************************************
00365     Create the second dialog dynamically.
00366
00367     Here we create a dialog which has font information (DS_SETFONT),
00368     and which has two items with the item class specified by name.
00369
00370     In case of error the function returns the error code obtained by calling
00371     GetLastError. Otherwise the function returns ERROR_SUCCESS
00372 ****************************************************************************/
00373 DWORD Create2 (
00374     HWND hwnd )
00375 {
00376     WORD* p = NULL;
00377     WORD* pdlgtemplate = NULL;
00378     int   nchar;
00379     DWORD lStyle;
00380     DWORD error = ERROR_SUCCESS;
00381
00382     /* allocate some memory to play with  */
00383     p = (PWORD) LocalAlloc (LPTR, 1000);
00384     if (NULL == p)
00385     {
00386         error = GetLastError ();
00387         DebugBreak ();
00388         goto exit_func;
00389     }
00390     pdlgtemplate = p;
00391
00392
00393     /* start to fill in the dlgtemplate information.  addressing by WORDs */
00394     lStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_SETFONT;
00395     *p++ = LOWORD (lStyle);
00396     *p++ = HIWORD (lStyle);
00397     *p++ = 0;          // LOWORD (lExtendedStyle)
00398     *p++ = 0;          // HIWORD (lExtendedStyle)
00399     *p++ = 2;          // NumberOfItems
00400     *p++ = 210;        // x
00401     *p++ = 10;         // y
00402     *p++ = 100;        // cx
00403     *p++ = 100;        // cy
00404     *p++ = 0;          // Menu
00405     *p++ = 0;          // Class
00406
00407
00408     /* copy the title of the dialog */
00409     if (PRIMARYLANGID(GetUserDefaultLangID ()) == LANG_JAPANESE)
00410     {
00411         nchar = nCopyAnsiToWideChar (p, TEXT("ƒ^ƒCƒgƒ‹ 2"));
00412     }
00413     else
00414     {
00415         nchar = nCopyAnsiToWideChar (p, TEXT("Title 2"));
00416     }
00417     p += nchar;
00418
00419     /* Font information because of DS_SETFONT */
00420     *p++ = 18;     // point size
00421     nchar = nCopyAnsiToWideChar (p, TEXT("Times New Roman"));  // Face name
00422     p += nchar;
00423
00424
00425     /* make sure the first item starts on a DWORD boundary */
00426     p = lpwAlign (p);
00427
00428     /* now start with the first item */
00429     lStyle = BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
00430     *p++ = LOWORD (lStyle);
00431     *p++ = HIWORD (lStyle);
00432     *p++ = 0;          // LOWORD (lExtendedStyle)
00433     *p++ = 0;          // HIWORD (lExtendedStyle)
00434     *p++ = 10;         // x
00435     *p++ = 60;         // y
00436     *p++ = 80;         // cx
00437     *p++ = 20;         // cy
00438     *p++ = IDOK;       // ID
00439
00440
00441     /* fill in class i.d., this time by name */
00442     nchar = nCopyAnsiToWideChar (p, TEXT("BUTTON"));
00443     p += nchar;
00444
00445
00446     /* copy the text of the first item */
00447     nchar = nCopyAnsiToWideChar (p, TEXT("OK"));
00448     p += nchar;
00449
00450     *p++ = 0;  // advance pointer over nExtraStuff WORD
00451
00452     /* make sure the second item starts on a DWORD boundary */
00453     p = lpwAlign (p);
00454
00455 #define SS_INMOTION 0x0002  /* from spincube.h */
00456     lStyle = WS_VISIBLE | WS_CHILD | SS_INMOTION;
00457     *p++ = LOWORD (lStyle);
00458     *p++ = HIWORD (lStyle);
00459     *p++ = 0;          // LOWORD (lExtendedStyle)
00460     *p++ = 0;          // HIWORD (lExtendedStyle)
00461     *p++ = 20;         // x
00462     *p++ = 5;          // y
00463     *p++ = 65;         // cx
00464     *p++ = 45;         // cy
00465     *p++ = 57;         // ID
00466
00467
00468     /* fill in class i.d., this time by name */
00469
00470     /***** CUSTOM CONTROL
00471     * Fill in the class name that is specified in the DLL
00472     *  See the \q_a\samples\spincube sample for the source to this.
00473     *****/
00474     nchar = nCopyAnsiToWideChar (p, TEXT("Spincube"));
00475     p += nchar;
00476
00477     /* copy the text of the second item, null terminate the string. */
00478     nchar = nCopyAnsiToWideChar (p, TEXT(""));
00479     p += nchar;
00480
00481     *p++ = 0;  // advance pointer over nExtraStuff WORD
00482
00483     if (NULL == CreateDialogIndirect (ghInst, (LPDLGTEMPLATE) pdlgtemplate, hwnd, (DLGPROC) About))
00484     {
00485         error = GetLastError ();
00486     }
00487
00488     if (NULL != LocalFree (pdlgtemplate))
00489     {
00490         error = GetLastError ();
00491         DebugBreak ();
00492     }
00493
00494 exit_func:
00495     return error;
00496 }
00497
00498
00499
00500
00501 /****************************************************************************
00502     Helper routine.  Take an input pointer, return closest
00503      pointer that is aligned on a DWORD (4 byte) boundary.
00504 ****************************************************************************/
00505 WORD* lpwAlign (
00506     WORD* pIn )
00507 {
00508     DWORD_PTR ul;
00509
00510     ul = (DWORD_PTR) pIn;
00511     ul +=3;
00512     ul >>=2;
00513     ul <<=2;
00514     return (WORD*) ul;
00515 }
00516
00517
00518
00519 /****************************************************************************
00520     Helper routine.  Takes second parameter as Ansi string, copies
00521      it to first parameter as wide character (16-bits / char) string,
00522      and returns integer number of wide characters (words) in string
00523      (including the trailing wide char NULL).
00524 ****************************************************************************/
00525 int nCopyAnsiToWideChar (
00526     WORD* pWCStr,
00527     PTSTR pAnsiIn )
00528 {
00529 #ifdef UNICODE
00530     return lstrlen(lstrcpy(pWCStr, pAnsiIn)) + 1;
00531 #else
00532     int cchAnsi = lstrlen(pAnsiIn);
00533     return MultiByteToWideChar(GetACP(), MB_PRECOMPOSED,
00534                                pAnsiIn, cchAnsi, pWCStr, cchAnsi) + 1;
00535 #endif
00536 }
Generated on Wed Nov 13 2024 16:52:54 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/internetpublishing/ippsample/Guids.Cpp Source File

  • Dataaccess
  • oledb
  • internetpublishing
  • ippsample

Guids.Cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
00004   TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005   PARTICULAR PURPOSE.
00006
00007   Copyright (C) 1998 - 2000.  Microsoft Corporation.  All rights reserved.
00008
00009   guids.cpp
00010
00011   All the code for the sample.
00012
00013 ------------------------------------------------------------------------------*/
00014 // By default, the oledb.h file declares all of its constants as extern.
00015 // By defining "DBINITCONSTANTS" before including it, the values will be
00016 // supplied so that the linker will not complain about unresolved externals.
00017 // We need to do this once and exactly once -- everywhere else we include
00018 // the file should not have DBINITCONSTANTS defined.
00019 #define OLEDBVER 0x0250
00020
00021 #include "stdafx.h"
00022
00023 #define DBINITCONSTANTS
00024 #include <oledb.h>
00025
00026 #define INITGUID
00027 #include <initguid.h>
00028 #include <msdaipp.h>
Generated on Wed Nov 13 2024 16:52:03 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/fileidx.h Source File

  • Dataaccess
  • oledb
  • sampprov

fileidx.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module FILEIDX.H | Class Definitions for CFileIdx Class
00008 //
00009 //
00010 #ifndef _FILEIDX_H_
00011 #define _FILEIDX_H_
00012 #include <windows.h>
00013
00014 //--------------------------------------------------------------------
00015 // @struct FILEDEX | Simple structure used to maintain file offset and
00016 // deletion status for the rows.
00017 //
00018 typedef struct {
00019   ULONG ulOffset;     //@field Offset into file
00020   BYTE  bStatus;      //@field Deletion Status
00021   } FILEDEX, FAR * LPFILEDEX;
00022
00023
00024 //--------------------------------------------------------------------
00025 // @class CFileIdx | Manages the array of offsets into a file.  This
00026 // maintains whether the row has been deleted and where the row begins.
00027 //
00028 // @hungarian
00029 //
00030 class CFileIdx
00031 {
00032 private: //@access private
00033   //@cmember Array of Offset and Status flags
00034   LPFILEDEX m_rgDex;
00035   //@cmember Current number of rows allocated
00036   DBCOUNTITEM m_ulDexCnt;
00037   //@cmember Reallocation Routine
00038   BOOL ReAlloc(DBCOUNTITEM ulRows);
00039
00040 public: //@access public
00041   //@cmember Class Constructor
00042   CFileIdx(void);
00043   //@cmember Class Destructor
00044   ~CFileIdx(void);
00045   //@cmember Initialization Routine
00046   BOOL fInit(void);
00047   //@cmember Sets file offset of a particular index
00048   BOOL SetIndex(DBCOUNTITEM ulDex, ULONG ulOffset);
00049   //@cmember Sets the delete flag for a particular row
00050   BOOL DeleteRow(DBCOUNTITEM ulDex);
00051   //@cmember Has the Row been deleted
00052   BOOL IsDeleted(DBCOUNTITEM ulDex);
00053   //@cmember Returns the offset in the file for a particular row
00054   ULONG GetRowOffset(DBCOUNTITEM ulDex);
00055 };
00056
00057
00058 #endif
00059
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Multimedia/Gdi/PrintJob/threads.c Source File

  • Multimedia
  • Gdi
  • PrintJob

threads.c

Go to the documentation of this file.
00001 /******************************************************************************
00002 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
00003 * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
00004 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00005 *  PARTICULAR PURPOSE.
00006 *
00007 *  Copyright (C) 1999 - 2000  Microsoft Corporation.  All Rights Reserved.
00008 *
00009     FILE:   Threads.C
00010
00011     PURPOSE:    Implements the thread related functions for the PrintJob
00012       sample.
00013
00014     FUNCTIONS:
00015         CreateThreadSyncResources() - Creates synchronziation resources.
00016
00017         DestroyThreadSyncResources() - Destroys synchronization resources.
00018
00019         PollingUpdate() - Thread entry for watching queues by polling.
00020
00021         StartPolling() - Creates a thread using PollingUpdate to show a printer
00022                          queue.
00023
00024         StartNotifications() - Creates a thread using NotificationsUpdate to
00025                                get and show changes to a printer queue.
00026
00027         NotificationUpdate() - Thread Entry point for Printer Change Notifications
00028
00029         ActiveUpdateThread() - Test for a running update thread.
00030
00031         StopUpdateThread() - Shuts down and update thread.
00032
00033         TriggerUpdateThreadRefresh() - Signals update thread to refresh.
00034 *
00035 ******************************************************************************/
00036
00037
00038 #define STRICT
00039 #include <windows.h>
00040 #include <process.h>
00041 #include "Threads.h"
00042 #include "Queue.h"
00043 #include "QueList.h"
00044 #include "Errors.h"
00045 #include "QueCore.h"
00046
00047
00048 /* Thread synchronization globals */
00049 DWORD   g_nPollIntervalms = 1500;       /* milliseconds polling resolution */
00050 HANDLE  g_hTerminateEvent = NULL;       /* Signalling event for thread to terminate. */
00051 HANDLE  g_hForceRefreshEvent = NULL;    /* Signal for thread to wakeup and refresh */
00052 BOOL    fCloseApp = FALSE;              /* If true, the thread should post a WM_CLOSE */
00053
00054 /* Thread parameters */
00055 typedef struct _threadparameters
00056 {
00057     HWND    hWnd;                       /* the main aplication window */
00058     HANDLE  hPrinter;                   /* the printer to watch */
00059     HANDLE  hPrevThread;                /* The previous thread to be closed */
00060 } THREADPARAM;
00061
00062
00063 /******************************************************************************
00064
00065   FUNCTION: CreateThreadSyncResources( void )
00066
00067   PURPOSE:  On application initialization this should be called to create all
00068             the resources needed to synchronize the threads.
00069
00070   COMMENTS:
00071             Creates: g_hForceRefreshEvent, g_hTerminateEvent.
00072
00073 ******************************************************************************/
00074
00075 BOOL CreateThreadSyncResources(void)
00076 {
00077     /* Initialize Resources */
00078     g_hForceRefreshEvent = g_hTerminateEvent = NULL;
00079
00080
00081     /*
00082      * Create thread termination resource
00083      * If signaled, our worker thread must exit.
00084      * The resource is created initially signaled so that
00085      * we can use it to test for a running thread.
00086      */
00087     g_hTerminateEvent = CreateEvent(NULL,       /* no inheritance */
00088                                     TRUE,       /* Reset is manual */
00089                                     TRUE,       /* Initially signaled */
00090                                     "UpdateThreadTerminateEvent");
00091     if (!g_hTerminateEvent)
00092         goto Fail;
00093
00094     /*
00095      * Create thread refresh trigger resource
00096      * If signaled, our worker thread must immediately refresh.
00097      * The resource is created not initially signaled so that
00098      * it does not trigger a superflouos update.
00099      */
00100     g_hForceRefreshEvent = CreateEvent(NULL,        /* no inheritance */
00101                                     TRUE,       /* Reset is manual */
00102                                     FALSE,      /* Initially signaled */
00103                                     "UpdateThreadRefreshEvent");
00104     if (!g_hForceRefreshEvent)
00105         goto Fail;
00106
00107     return TRUE;
00108
00109 Fail:
00110     DestroyThreadSyncResources();
00111     return FALSE;
00112
00113 } /* end of function CreateThreadSyncResources */
00114
00115
00116 /******************************************************************************
00117
00118   FUNCTION: DestroyThreadSyncResources( void )
00119
00120   PURPOSE:  On application shutdown this should be called to destroy all
00121             the resources needed to synchronize the threads.
00122
00123   COMMENTS:
00124             Destroys: g_hForceRefreshEvent, g_hTerminateEvent.
00125
00126 ******************************************************************************/
00127
00128 BOOL DestroyThreadSyncResources(void)
00129 {
00130     if (g_hTerminateEvent)
00131         CloseHandle(g_hTerminateEvent);
00132     if (g_hForceRefreshEvent)
00133         CloseHandle(g_hForceRefreshEvent);
00134     return TRUE;
00135
00136 } /* end of DestroyThreadSyncResources */
00137
00138
00139 /******************************************************************************
00140
00141   FUNCTION: PollingUpdate( DWORD )
00142
00143   PURPOSE:  Thread entry point for performing printer queue updates using
00144             a polling algorithm.
00145
00146   COMMENTS:
00147             This thread uses WaitForMultipleObjects to wake up every
00148             g_nPollIntervalms milliseconds and refresh the contents of our
00149             printer queue.
00150
00151             It terminates on g_hTerminateEvent.
00152
00153             DWORD is a handle to global memory formated as a THREADPARAM
00154             structure.
00155
00156 ******************************************************************************/
00157
00158 unsigned __stdcall PollingUpdate(void *pParameters)
00159 {
00160     THREADPARAM ThreadParam;    /* what we are to work with */
00161     THREADPARAM *pThreadParam;
00162     QUEUEDATA   Queue;          /* To keep our copy of the print queue */
00163     HANDLE      Handles[2];     /* one for refresh, one for terminate */
00164     HGLOBAL     hParameters;
00165
00166     /* Transfer parameters to the thread's stack and free global memory */
00167     hParameters = (HGLOBAL)pParameters;
00168     pThreadParam = (THREADPARAM *)GlobalLock((HGLOBAL)hParameters);
00169     ThreadParam = *pThreadParam;
00170
00171     /* we do not intend to pass anything back to the application so free memory */
00172     GlobalUnlock((HGLOBAL)hParameters);
00173     GlobalFree((HGLOBAL)hParameters);
00174
00175     /* Terminate and Wait for previous thread to close down before we continue */
00176     if (ThreadParam.hPrevThread)
00177     {
00178         StopUpdateThread(ThreadParam.hPrevThread, FALSE);
00179         WaitForSingleObject(ThreadParam.hPrevThread, INFINITE);
00180         CloseHandle(ThreadParam.hPrevThread);
00181     }
00182
00183     /* reinitialize the Termination Event so we don't exit the polling loop */
00184     ResetEvent(g_hTerminateEvent);
00185
00186     /* initialize our Queue data structure*/
00187     ZeroMemory(&Queue, sizeof(Queue));
00188     Queue.Printer.hPrinter = ThreadParam.hPrinter;
00189
00190     /* setup for WaitForMultipleObjects */
00191     Handles[0] = g_hTerminateEvent;
00192     Handles[1] = g_hForceRefreshEvent;
00193     /*
00194      * Loop until we are told to quit, waiting each time by
00195      * the polling interval.
00196      */
00197     do {
00198         /* Setup for refresh override */
00199         ResetEvent(g_hForceRefreshEvent);
00200
00201         /* Get the data and show it */
00202         Refresh(ThreadParam.hWnd, &Queue);
00203
00204         /* Wait for a terminate event, a refresh event, or the polling period */
00205         WaitForMultipleObjects(2, Handles, FALSE, g_nPollIntervalms);
00206
00207     /* Keep going as long as we have not been told to quit! */
00208     } while (WaitForSingleObject(g_hTerminateEvent, 0) != WAIT_OBJECT_0);
00209
00210
00211     /* Cleanup */
00212     ClosePrinter(ThreadParam.hPrinter);
00213     FreeQueueData(&Queue);
00214
00215     /* Thread posts the close message at the request of the Window Procedure
00216      * so application will attempt to close down again and succeed since the
00217      * thread has died.
00218      * We close down the app this way in order to avoid messaging deadlocks
00219      * by having the Window Procedure wait on this thread to exit.
00220      */
00221     if (fCloseApp)
00222         PostMessage(ThreadParam.hWnd, WM_CLOSE, 0, 0);
00223
00224     return TRUE;
00225
00226 } /* end of Thread entry point function PollingUpdate */
00227
00228
00229 /******************************************************************************
00230
00231   FUNCTION: StartPolling( HWND, HANDLE, HANDLE )
00232
00233   PURPOSE:  Creates a thread which polls for all changes to a printer queue.
00234
00235   COMMENTS:
00236             HWND is the main application window handle followed by a HANDLE to
00237             the opened printer and the HANDLE to any previous thread.
00238
00239             This function creates the polling thread and returns immediately.
00240             The thread entry point is NotificationUpdate().
00241
00242             The return value is the handle to the created thread.
00243
00244 ******************************************************************************/
00245
00246 HANDLE StartPolling(HWND hWnd, HANDLE hPrinter, HANDLE hPrevThread)
00247 {
00248     UINT       ThreadID;
00249     THREADPARAM *pThreadParam;
00250     HGLOBAL     hParam;
00251     HANDLE      hThread;
00252
00253     /* create parameters to thread */
00254     hParam = GlobalAlloc(GHND, sizeof(THREADPARAM));
00255     pThreadParam = (THREADPARAM *)GlobalLock(hParam);
00256     pThreadParam->hWnd = hWnd;               /* Main application Window */
00257     pThreadParam->hPrinter = hPrinter;       /* Printer now owned by thread */
00258     pThreadParam->hPrevThread = hPrevThread; /* Previous thread to terminate */
00259     GlobalUnlock(hParam);
00260
00261     /* Thread is responsible for deleteing the Global memory containing the
00262      * parameters.
00263      * The thread is responsible for closing the printer
00264      * and the thread is responsible for killing & closing the previous thread
00265      * It also is responsible for closing the application if it is asked.
00266      *
00267      * Note we use _beginthreadex from the runtime library to avoid problems
00268      * between the run time library and the OS CreateThread
00269      */
00270     hThread = (HANDLE)_beginthreadex(NULL,
00271                     0,
00272                     PollingUpdate,
00273                     (void *)hParam,
00274                     1,
00275                     &ThreadID);
00276
00277     return hThread;
00278
00279 } /* end of function StartPolling */
00280
00281
00282 /******************************************************************************
00283
00284   FUNCTION: StartNotifications( HWND, HANDLE, HANDLE )
00285
00286   PURPOSE:  Creates a thread which uses Printer Change Notifications to be
00287             alerted when changes occur to a printer queue.
00288
00289   COMMENTS:
00290             HWND is the main application window handle followed by a HANDLE to
00291             the opened printer and the HANDLE to any previous thread.
00292
00293             This function creates the thread and returns immediately.
00294             The thread entry point is NotificationUpdate().
00295
00296             The return value is the handle to the created thread.
00297
00298 ******************************************************************************/
00299
00300 HANDLE StartNotifications(HWND hWnd, HANDLE hPrinter, HANDLE hPrevThread)
00301 {
00302     UINT        ThreadID;
00303     THREADPARAM *pThreadParam;
00304     HGLOBAL     hParam;
00305     HANDLE      hThread;
00306
00307     /* create parameters to thread */
00308     hParam = GlobalAlloc(GHND, sizeof(THREADPARAM));
00309     pThreadParam = (THREADPARAM *)GlobalLock(hParam);
00310     pThreadParam->hWnd = hWnd;
00311     pThreadParam->hPrinter = hPrinter;
00312     pThreadParam->hPrevThread = hPrevThread;
00313     GlobalUnlock(hParam);
00314
00315     /* Thread is responsible for deleteing the Global memory containing the
00316      * parameters.
00317      * The thread is responsible for closing the printer
00318      * and the thread is responsible for killing & closing the previous thread
00319      * It also is responsible for closing the application if it is asked.
00320      *
00321      * Note we use _beginthreadex from the runtime library to avoid problems
00322      * between the run time library and the OS CreateThread
00323      */
00324     hThread = (HANDLE)_beginthreadex(NULL,
00325                     0,
00326                     NotificationUpdate,
00327                     (void *)hParam,
00328                     1,
00329                     &ThreadID);
00330     return hThread;
00331
00332 } /* end of function StartNotifications */
00333
00334
00335 /******************************************************************************
00336
00337   FUNCTION: NotificationUpdate( DWORD )
00338
00339   PURPOSE:  Thread entry point for using Printer Change Notifications to be
00340             alerted when changes occur to a printer queue.
00341
00342   COMMENTS:
00343             The DWORD contains a handle to global memory formated as a
00344             THREADPARAM structure.
00345
00346 ******************************************************************************/
00347
00348 unsigned __stdcall NotificationUpdate(void *pParameters)
00349 {
00350     THREADPARAM             ThreadParam;            /* Parameters for the thread */
00351     THREADPARAM *           pThreadParam;
00352     HANDLE                  hPrinterNotification;   /* The PrinterChangeNotification object */
00353     HANDLE                  Handles[3];             /* Array of objects waited on in the loop */
00354     HGLOBAL                 hParam;
00355     DWORD                   WaitResult;             /* High level info from the PrinterChangeNotification */
00356     DWORD                   OldFlags;               /* Temporary variable */
00357     PRINTER_NOTIFY_INFO *   pNotification = NULL;   /* The stuff that changed to cause the notification */
00358     WORD                    JobFields[] =
00359         {                                   /* Job Fields we want notifications for */
00360         JOB_NOTIFY_FIELD_STATUS,            /* Status bits */
00361         JOB_NOTIFY_FIELD_STATUS_STRING,     /* Status String */
00362         JOB_NOTIFY_FIELD_DOCUMENT,          /* Document Name */
00363         JOB_NOTIFY_FIELD_USER_NAME,         /* Name of Documents owner */
00364         JOB_NOTIFY_FIELD_TOTAL_PAGES,       /* Total pages in the job */
00365         JOB_NOTIFY_FIELD_PAGES_PRINTED,     /* # of pages of the job that have printed */
00366         JOB_NOTIFY_FIELD_SUBMITTED,         /* The time and date job was submitted */
00367         JOB_NOTIFY_FIELD_BYTES_PRINTED,     /* # of bytes sent to printer */
00368         JOB_NOTIFY_FIELD_TOTAL_BYTES        /* Total bytes in the print job */
00369         };
00370     WORD                    PrinterFields[] =
00371         {
00372         PRINTER_NOTIFY_FIELD_STATUS,        /* Status bits of printer queue */
00373         PRINTER_NOTIFY_FIELD_CJOBS,         /* # of jobs in printer queue */
00374         PRINTER_NOTIFY_FIELD_PRINTER_NAME,  /* Name of the printer queue */
00375         PRINTER_NOTIFY_FIELD_SERVER_NAME,   /* Name of the server when the queue is remote */
00376         PRINTER_NOTIFY_FIELD_SHARE_NAME     /* The queue's sharename */
00377         };
00378
00379     PRINTER_NOTIFY_OPTIONS_TYPE Notifications[2] =
00380         {                                   /* The notification we want to be notified of */
00381             {
00382                 JOB_NOTIFY_TYPE,            /* We want notifications on print jobs */
00383                 0,
00384                 0,
00385                 0,
00386                 sizeof(JobFields)/sizeof(JobFields[0]), /* We specified 9 fields in the JobFields array */
00387                 NULL            /* Precisely which fields we want notifications for */
00388             },
00389             {
00390                 PRINTER_NOTIFY_TYPE,        /* We want notification on the printer queue too */
00391                 0,
00392                 0,
00393                 0,
00394                 sizeof(PrinterFields)/sizeof(PrinterFields[0]), /* How many printer fields? */
00395                 NULL            /* Precisely what printer fields we want */
00396             }
00397         };
00398
00399     PRINTER_NOTIFY_OPTIONS NotificationOptions =
00400         {
00401             2,                                  /* Version of structure, see docs */
00402             PRINTER_NOTIFY_OPTIONS_REFRESH,     /* Options for FindNextPrinterChangeNotification */
00403             2,                                  /* # of Printer_Notify_Info structures */
00404             NULL                          /* What we want notifications of */
00405         };
00406
00407
00408     QUEUEDATA               Queue;              /* Our copy of the printer queue's data */
00409
00410   Notifications[0].pFields = JobFields;
00411   Notifications[1].pFields = PrinterFields;
00412   NotificationOptions.pTypes = Notifications;
00413
00414     /*
00415      * Transfer parameters to the thread's stack and
00416      * free the global memory
00417      */
00418     hParam = (HGLOBAL)pParameters;
00419     pThreadParam = (THREADPARAM *)GlobalLock((HGLOBAL)hParam);
00420     ThreadParam = *pThreadParam;
00421
00422     /*
00423      * we do not intend to pass anything back to the
00424      * application so free the memory used to get us Params.
00425      */
00426     GlobalUnlock((HGLOBAL)hParam);
00427     GlobalFree((HGLOBAL)hParam);
00428
00429     /* Terminate and Wait for previous thread to close down before we continue */
00430     if (ThreadParam.hPrevThread)
00431     {
00432         StopUpdateThread(ThreadParam.hPrevThread, FALSE);
00433         WaitForSingleObject(ThreadParam.hPrevThread, INFINITE);
00434         CloseHandle(ThreadParam.hPrevThread);
00435     }
00436
00437     /* reinitialize the Termination Event so we can proceed */
00438     ResetEvent(g_hTerminateEvent);
00439
00440     hPrinterNotification = FindFirstPrinterChangeNotification(
00441         ThreadParam.hPrinter,           /* The printer of interest */
00442         PRINTER_CHANGE_DELETE_JOB,      /* We need to know when a job is removed */
00443         0,                              /* reserved */
00444         &NotificationOptions);          /* The details of what notifications that are needed */
00445
00446     /* Check for an error */
00447     if (hPrinterNotification == INVALID_HANDLE_VALUE)
00448     {
00449         ErrorBox(GetLastError(), "FindFirstPrinterChangeNotification");
00450         return 0;
00451     }
00452
00453
00454     /*
00455      * Loop on the Notifications, a terminate event, or a refresh event
00456      */
00457
00458     /* setup for a WaitForMultipleObjects */
00459     Handles[0] = hPrinterNotification;
00460     Handles[1] = g_hTerminateEvent;
00461     Handles[2] = g_hForceRefreshEvent;
00462
00463     /* Initialize for our local data structure */
00464     ZeroMemory(&Queue, sizeof(Queue));
00465     Queue.Printer.hPrinter = ThreadParam.hPrinter;
00466
00467     /* Initialize the display and our local copy of the printer queue data */
00468     Refresh(ThreadParam.hWnd, &Queue);
00469
00470     /*
00471      * Loop while we are stilling waiting on Notifications.
00472      */
00473     while (hPrinterNotification != INVALID_HANDLE_VALUE)
00474     {
00475         /* wait for a printer notification, terminate event, or refresh event */
00476         WaitForMultipleObjects(3, Handles, FALSE, INFINITE);
00477
00478         /* check to see if the thread needs to quit. */
00479         if (WaitForSingleObject(g_hTerminateEvent, 0) == WAIT_OBJECT_0)
00480         {
00481             /* This should be the only way out of the loop */
00482             FindClosePrinterChangeNotification(hPrinterNotification);
00483             hPrinterNotification = INVALID_HANDLE_VALUE;
00484         }
00485
00486         /* or check to see if the notification object for the printer queue is signaled */
00487         else if (WaitForSingleObject(hPrinterNotification, 0) == WAIT_OBJECT_0)
00488         {
00489             /* get the changes and reset the notification */
00490             if (!FindNextPrinterChangeNotification(hPrinterNotification,
00491                 &WaitResult,            /* for the PRINTER_CHANGE_DELETE_JOB notice */
00492                 &NotificationOptions,   /* The notifications */
00493                 &pNotification))        /* address of pointer that gets what changed */
00494             {
00495                 ErrorBox(GetLastError(), "FindNextPrinterChangeNotification");
00496             }
00497
00498             /* Did a notification overflow occur? */
00499             if (pNotification && pNotification->Flags & PRINTER_NOTIFY_INFO_DISCARDED)
00500             {
00501                 /* An overflow of notifications occured, must refresh to continue */
00502
00503                 OldFlags = NotificationOptions.Flags;
00504
00505                 NotificationOptions.Flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
00506
00507                 FreePrinterNotifyInfo(pNotification);
00508                 if (!FindNextPrinterChangeNotification(hPrinterNotification,
00509                     &WaitResult,
00510                     &NotificationOptions,
00511                     &pNotification))
00512                 {
00513                     ErrorBox(GetLastError(), "FindNextPrinterChangeNotification refresh call.");
00514                 }
00515                 NotificationOptions.Flags = OldFlags;
00516
00517                 /* Start Over with Refreshed Data */
00518                 Refresh(ThreadParam.hWnd, &Queue);
00519
00520             }
00521
00522             /* process the notification of changes */
00523             if (WaitResult & PRINTER_CHANGE_DELETE_JOB)
00524             {
00525                 /* a job was deleted so start over clean */
00526                 Refresh(ThreadParam.hWnd, &Queue);
00527             }
00528             else
00529             {
00530                 /* track and show the changes */
00531                 RefreshFromNotification(ThreadParam.hWnd, &Queue, pNotification);
00532             }
00533             FreePrinterNotifyInfo(pNotification);
00534             pNotification = NULL;
00535         }
00536
00537         /* Or, maybe the user wants to refresh the view of the print queue */
00538         else if (WaitForSingleObject(g_hForceRefreshEvent, 0) == WAIT_OBJECT_0)
00539         {
00540             Refresh(ThreadParam.hWnd, &Queue);
00541             ResetEvent(g_hForceRefreshEvent);
00542         }
00543
00544
00545     }
00546
00547     /* Done watching for notifications, cleanup */
00548     ClosePrinter(ThreadParam.hPrinter);
00549     FreeQueueData(&Queue);
00550
00551     /* Thread posts the close message when the application is going away so the
00552      * the application willattempt to close down again and succeed since the
00553      * thread has died.
00554      */
00555     if (fCloseApp)
00556         PostMessage(ThreadParam.hWnd, WM_CLOSE, 0, 0);
00557
00558     return TRUE;
00559
00560 } /* end of Thread entry point function NotificationUpdate */
00561
00562
00563 /******************************************************************************
00564
00565   FUNCTION: ActiveUpdateThread( void )
00566
00567   PURPOSE:  Test to see if a thread is currently running.
00568
00569   COMMENTS:
00570             g_hTerminateEvent is created initially signaled and it is left
00571             signaled whenver a thread exits. It is not signaled only when a
00572             thread is running.
00573
00574 ******************************************************************************/
00575
00576 BOOL ActiveUpdateThread(void)
00577 {
00578     /* let the caller know if a thread is running */
00579     return !(WaitForSingleObject(g_hTerminateEvent, 0) == WAIT_OBJECT_0);
00580
00581 } /* end of ActiveUpdateThread */
00582
00583
00584 /******************************************************************************
00585
00586   FUNCTION: StopUpdateThread( HANDLE, BOOL )
00587
00588   PURPOSE:  Signals the current update thread to shutdown.
00589
00590   COMMENTS:
00591             If BOOL is TRUE it is a signal to the thread that is shutting
00592             down that it also needs to shutdown the application with WM_CLOSE.
00593
00594 ******************************************************************************/
00595
00596 BOOL StopUpdateThread(HANDLE hThread, BOOL fCloseAppNow)
00597 {
00598     /* No thread running? */
00599     if (!hThread)
00600         return FALSE;
00601
00602     /* Should we close the application too? */
00603     fCloseApp = fCloseAppNow;
00604
00605     /* tell thread to quit */
00606     SetEvent(g_hTerminateEvent);
00607
00608     return TRUE;
00609
00610 } /* end of StopNotifications function */
00611
00612
00613 /******************************************************************************
00614
00615   FUNCTION: TriggerUpdateThreadRefresh( void )
00616
00617   PURPOSE:  Tells an update thread to refresh the printer queue contents.
00618
00619   COMMENTS:
00620             The g_hForceFrefreshEvent is signaled which triggers the update
00621             thread into refreshing the contents of the entire queue.
00622
00623 ******************************************************************************/
00624
00625 BOOL TriggerUpdateThreadRefresh(void)
00626 {
00627     /* Signal the event that forces a refresh of the display /*/
00628     return SetEvent(g_hForceRefreshEvent);
00629
00630 } /* end of TriggerUpdateThreadRefresh function */
00631
00632 /* end of source file Threads.C */
Generated on Wed Nov 13 2024 16:52:13 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Indexing/IFilter/InputTag.Cxx Source File

  • WinBase
  • Indexing
  • IFilter

InputTag.Cxx

Go to the documentation of this file.
00001 //+---------------------------------------------------------------------------
00002 //
00003 //  Copyright (c) Microsoft Corporation. All rights reserved.
00004 //
00005 //  File:       inputtag.cxx
00006 //
00007 //  Contents:   Parsing algorithm for input tag in Html
00008 //
00009 //  Classes:    CInputTag
00010 //
00011 //----------------------------------------------------------------------------
00012
00013 #include <pch.cxx>
00014 #pragma hdrstop
00015
00016 #include <inputtag.hxx>
00017 #include <htmlguid.hxx>
00018 #include <ntquery.h>
00019
00020 //+-------------------------------------------------------------------------
00021 //
00022 //  Method:     CInputTag::CInputTag
00023 //
00024 //  Synopsis:   Constructor
00025 //
00026 //  Arguments:  [htmlIFilter]    -- Html IFilter
00027 //              [serialStream]   -- Input stream
00028 //
00029 //--------------------------------------------------------------------------
00030
00031 CInputTag::CInputTag( CHtmlIFilter& htmlIFilter,
00032                       CSerialStream& serialStream )
00033     : CHtmlElement(htmlIFilter, serialStream),
00034       _pwcValueBuf(0),
00035       _cValueChars(0),
00036       _cValueCharsFiltered(0)
00037 {
00038 }
00039
00040
00041
00042 //+-------------------------------------------------------------------------
00043 //
00044 //  Method:     CInputTag::GetChunk
00045 //
00046 //  Synopsis:   Gets the next chunk and returns chunk information in pStat
00047 //
00048 //  Arguments:  [pStat] -- chunk information returned here
00049 //
00050 //--------------------------------------------------------------------------
00051
00052 SCODE CInputTag::GetChunk( STAT_CHUNK * pStat )
00053 {
00054     SCODE sc = SwitchToNextHtmlElement( pStat );
00055
00056     return sc;
00057 }
00058
00059
00060
00061 //+-------------------------------------------------------------------------
00062 //
00063 //  Method:     CInputTag::GetText
00064 //
00065 //  Synopsis:   Retrieves text from current chunk
00066 //
00067 //  Arguments:  [pcwcOutput] -- count of UniCode characters in buffer
00068 //              [awcBuffer]  -- buffer for text
00069 //
00070 //--------------------------------------------------------------------------
00071
00072 SCODE CInputTag::GetText( ULONG *pcwcOutput, WCHAR *awcBuffer )
00073 {
00074     ULONG cCharsRemaining = _cValueChars - _cValueCharsFiltered;
00075
00076     if ( cCharsRemaining == 0 )
00077     {
00078         *pcwcOutput = 0;
00079         return FILTER_E_NO_MORE_TEXT;
00080     }
00081
00082     if ( *pcwcOutput < cCharsRemaining )
00083     {
00084         RtlCopyMemory( awcBuffer,
00085                        _pwcValueBuf + _cValueCharsFiltered,
00086                        *pcwcOutput * sizeof(WCHAR) );
00087         _cValueCharsFiltered += *pcwcOutput;
00088
00089         return S_OK;
00090     }
00091     else
00092     {
00093         RtlCopyMemory( awcBuffer,
00094                        _pwcValueBuf + _cValueCharsFiltered,
00095                        cCharsRemaining * sizeof(WCHAR) );
00096         _cValueCharsFiltered += cCharsRemaining;
00097         *pcwcOutput = cCharsRemaining;
00098
00099         return FILTER_S_LAST_TEXT;
00100     }
00101 }
00102
00103
00104
00105 //+-------------------------------------------------------------------------
00106 //
00107 //  Method:     CInputTag::InitStatChunk
00108 //
00109 //  Synopsis:   Initializes the STAT_CHUNK
00110 //
00111 //  Arguments:  [pStat] -- STAT_CHUNK to initialize
00112 //
00113 //--------------------------------------------------------------------------
00114
00115 void CInputTag::InitStatChunk( STAT_CHUNK *pStat )
00116 {
00117     _cValueCharsFiltered = 0;
00118
00119     pStat->idChunk = _htmlIFilter.GetNextChunkId();
00120     pStat->flags = CHUNK_TEXT;
00121     pStat->locale = _htmlIFilter.GetLocale();
00122     pStat->attribute.guidPropSet = CLSID_Storage;
00123     pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
00124     pStat->attribute.psProperty.propid = PID_STG_CONTENTS;
00125     pStat->breakType = CHUNK_EOS;
00126     pStat->idChunkSource = pStat->idChunk;
00127     pStat->cwcStartSource = 0;
00128     pStat->cwcLenSource = 0;
00129
00130     _scanner.ReadTagIntoBuffer();
00131
00132     //
00133     // Check input type
00134     //
00135     WCHAR *pwcType;
00136     unsigned cwcType;
00137     _scanner.ScanTagBuffer( L"type=\"", pwcType, cwcType );
00138
00139     if ( cwcType == 6           // 6 == wcslen( L"hidden" )
00140          && _wcsnicmp( pwcType, L"hidden", 6 ) == 0 )
00141     {
00142         //
00143         // Input is hidden, so don't output value field
00144         //
00145         _pwcValueBuf = 0;
00146         _cValueChars = 0;
00147
00148         return;
00149     }
00150
00151     //
00152     // Read the value field
00153     //
00154     _scanner.ScanTagBuffer( L"value=\"", _pwcValueBuf, _cValueChars );
00155 }
Generated on Wed Nov 13 2024 16:52:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CSCP Member List

This is the complete list of members for CSCP, including all inherited members.
AddPages(LPFNADDPROPSHEETPAGE pAddPageProc, LPARAM lParam) | CSCP |
CSCP() | CSCP | [inline]
DECLARE_REGISTRY_CLSID() | CSCP |
Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObject, HKEY hKeyID) | CSCP |
m_pProppageUIBindingInfo | CSCP | [private]
m_pProppageUIGeneral | CSCP | [private]
m_pProppageUIKeywords | CSCP | [private]
m_spDataObj | CSCP | [private]
ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam) | CSCP |
~CSCP() | CSCP | [inline]
Generated on Wed Nov 13 2024 16:57:17 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Dataaccess/oledb/sampprov/accessor.h Source File

  • Dataaccess
  • oledb
  • sampprov

accessor.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------
00002 // Microsoft OLE DB Sample Provider
00003 // (C) Copyright 1991 - 1999 Microsoft Corporation. All Rights Reserved.
00004 //
00005 // @doc
00006 //
00007 // @module ACCESSOR.H | CImpIAccessor object implementing the IAccessor interface.
00008 //
00009 //
00010 #ifndef _ACCESSOR_H_
00011 #define _ACCESSOR_H_
00012
00013
00014 //----------------------------------------------------------------------------
00015 // @class CImpIAccessor | Contained IAccessor class
00016 //
00017 class CImpIAccessor : public IAccessor    //@base public | IAccessor
00018 {
00019   //  Immediate user objects are friends
00020   friend class CImpIAccessor;
00021   friend class CRowset;
00022   friend class CCommand;
00023
00024   private: //@access private
00025     DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CBaseObj)
00026
00027     //@cmember array of accessor ptrs
00028     LPEXTBUFFER m_pextbufferAccessor;
00029
00030   public: //@access public
00031     DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CBaseObj, CImpIAccessor);
00032
00033     //@cmember Initialization Routine
00034     STDMETHODIMP  FInit(BOOL fUnderRowset);
00035
00036     DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
00037
00038     //@cmember Increment Reference count on accessor
00039     STDMETHODIMP  AddRefAccessor(HACCESSOR hAccessor, DBREFCOUNT* pcRefCounts);
00040     //@cmember CreateAccessor Method
00041       STDMETHODIMP  CreateAccessor(DBACCESSORFLAGS, DBCOUNTITEM, const DBBINDING rgBindings[], DBLENGTH, HACCESSOR*, DBBINDSTATUS rgStatus[]);
00042     //@cmember GetBindings Method
00043     STDMETHODIMP  GetBindings(HACCESSOR, DBACCESSORFLAGS*, DBCOUNTITEM*, DBBINDING**);
00044     //@cmember ReleaseAccessor Method
00045     STDMETHODIMP  ReleaseAccessor(HACCESSOR, DBREFCOUNT*);
00046      //@cmember CopyAccessors Method
00047     STDMETHODIMP  CopyAccessors(LPEXTBUFFER pextbufferAccessor);
00048 };
00049
00050
00051 #endif _ACCESSOR_H_
Generated on Wed Nov 13 2024 16:52:09 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/Start/First/vc/StdAfx.cpp Source File

  • NetDS
  • ADSI
  • samples
  • Start
  • First
  • vc

StdAfx.cpp

Go to the documentation of this file.
00001 // stdafx.cpp : source file that includes just the standard includes
00002 //  First.pch will be the pre-compiled header
00003 //  stdafx.obj will contain the pre-compiled type information
00004
00005 #include "stdafx.h"
00006
00007 // TODO: reference any additional headers you need in STDAFX.H
00008 // and not in this file
Generated on Wed Nov 13 2024 16:51:45 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/ADSI/samples/DSUI/userext/userwizard/wizext.h Source File

  • NetDS
  • ADSI
  • samples
  • DSUI
  • userext
  • userwizard

wizext.h

Go to the documentation of this file.
00001 //+-------------------------------------------------------------------------
00002 //
00003 //  Microsoft Windows
00004 //
00005 //  Copyright (C) Microsoft Corporation, 1999 - 2000
00006 //
00007 //  File:       wizext.h
00008 //
00009 //--------------------------------------------------------------------------
00010
00011 // WizExt.h : Declaration of the CWizExtUser
00012
00013 #ifndef __WIZEXT_H_
00014 #define __WIZEXT_H_
00015
00016 #include "resource.h"       // main symbols
00017 #include "userwizard.h"
00018 #include "ExtPageUser.h"
00019
00020
00021 ////////////////////////////////////////////////////////////////////////////////
00022 // CWizExtUser
00023 //
00024 // This class implements the interface needed for a secondary wizard extension
00025 // for DS Admin.
00026 //
00027 ////////////////////////////////////////////////////////////////////////////////
00028
00029 class /*ATL_NO_VTABLE*/ CWizExtUser :
00030   public CComObjectRootEx<CComSingleThreadModel>,
00031   public IDsAdminNewObjExt,
00032   public CComCoClass<CWizExtUser, &CLSID_WizExtUser>
00033 {
00034 public:
00035   CWizExtUser()
00036   {
00037     m_hObjClassIcon = NULL;
00038   }
00039
00040   ~CWizExtUser()
00041   {
00042     if (m_pExtPageUser != NULL)
00043       delete m_pExtPageUser;
00044   }
00045
00046
00047 BEGIN_COM_MAP(CWizExtUser)
00048   COM_INTERFACE_ENTRY(IDsAdminNewObjExt)
00049 END_COM_MAP()
00050
00051
00052 public:
00053   DECLARE_REGISTRY_CLSID();
00054
00055   //
00056   // IDsAdminNewObjExt interface
00057   //
00058   STDMETHOD(Initialize)(IADsContainer* pADsContainerObj,
00059                         IADs* pADsCopySource,
00060                         LPCWSTR lpszClassName,
00061                         IDsAdminNewObj* pDsAdminNewObj,
00062                         LPDSA_NEWOBJ_DISPINFO pDispInfo);
00063
00064   STDMETHOD(AddPages)(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
00065   STDMETHOD(SetObject)(IADs* pADsObj);
00066   STDMETHOD(WriteData)(HWND hWnd, ULONG uContext);
00067   STDMETHOD(OnError)(HWND hWnd, HRESULT hr, ULONG uContext);
00068   STDMETHOD(GetSummaryInfo)(BSTR* pBstrText);
00069
00070   //
00071   // Helper functions
00072   //
00073   HRESULT WriteDataHelper();
00074
00075   //
00076   // accessor functions
00077   //
00078   IADs* GetObj() { return m_spADsObj;}
00079   void SetObj(IADs* pADsObj) { m_spADsObj = pADsObj;}
00080   IADsContainer* GetContainer() { return m_spADsContainerObj;}
00081   IDsAdminNewObj* GetIDsAdminNewObj() { return m_spDsAdminNewObj;}
00082
00083   IADs* GetCopySourceObj() { return m_spADsCopySourceObj;}
00084
00085   LPCWSTR GetClassName() { return m_szClassName;}
00086   LPCWSTR GetContainerCanonicalName() { return m_szContCanonicalName;}
00087   HICON   GetClassIcon() { return m_hObjClassIcon;}
00088   LPCWSTR GetTitle() { return m_szTitle;}
00089   void GetDefaultSummary(CString& s);
00090
00091 private:
00092   //
00093   // container for object creation, passed to IDsAdminNewObjExt::Initialize()
00094   //
00095   CComPtr<IADsContainer> m_spADsContainerObj;
00096
00097   //
00098   // object under creation, passed to IDsAdminNewObjExt::SetObject()
00099   //
00100   CComPtr<IADs> m_spADsObj;
00101
00102   //
00103   // if present, cached pointer to the source (for copy operation)
00104   //
00105   CComPtr<IADs> m_spADsCopySourceObj;
00106
00107   //
00108   // interface to the DS admin Object creation site
00109   //
00110   CComPtr<IDsAdminNewObj> m_spDsAdminNewObj;
00111
00112 protected:
00113   //
00114   // class name the extension called for, passed to IDsAdminNewObjExt::Initialize()
00115   //
00116   CString m_szClassName;
00117
00118   //
00119   // display information passed to ::Initialize() in the LPDSA_NEWOBJ_DISPINFO struct
00120   //
00121   CString m_szTitle;
00122   CString m_szContCanonicalName;
00123   HICON   m_hObjClassIcon;
00124
00125   //
00126   // The class that handles the user interface for the extension
00127   //
00128   CExtPageUser* m_pExtPageUser;
00129 };
00130
00131
00132 #endif //_WIZEXT_H
Generated on Wed Nov 13 2024 16:52:16 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinUI/TSFmark/globals.h Source File

  • WinUI
  • TSFmark

globals.h

Go to the documentation of this file.
00001 //
00002 // globals.h
00003 //
00004 // Global variable declarations.
00005 //
00006
00007 #ifndef GLOBALS_H
00008 #define GLOBALS_H
00009
00010 #include <windows.h>
00011 #include <ole2.h>
00012 #include <olectl.h>
00013 #include <assert.h>
00014 #include "msctf.h"
00015
00016 LONG DllAddRef();
00017 LONG DllRelease();
00018
00019 BOOL AdviseSink(IUnknown *pSource, IUnknown *pSink, REFIID riid, DWORD *pdwCookie);
00020 void UnadviseSink(IUnknown *pSource, DWORD *pdwCookie);
00021
00022 BOOL AdviseSingleSink(TfClientId tfClientId, IUnknown *pSource, IUnknown *pSink, REFIID riid);
00023 void UnadviseSingleSink(TfClientId tfClientId, IUnknown *pSource, REFIID riid);
00024
00025 BOOL IsRangeCovered(TfEditCookie ec, ITfRange *pRangeTest, ITfRange *pRangeCover);
00026
00027 BOOL IsEqualUnknown(IUnknown *interface1, IUnknown *interface2);
00028
00029 #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
00030
00031 #define MARK_LANGID    MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
00032
00033 #define MARK_DESC    L"Mark Text Service"
00034 #define MARK_DESC_A   "Mark Text Service"
00035 #define MARK_MODEL   TEXT("Apartment")
00036
00037 #define LANGBAR_ITEM_DESC L"Mark Menu" // max 32 chars!
00038
00039 #define MARK_ICON_INDEX  0
00040
00041 #define SafeRelease(punk)       \
00042 {                               \
00043     if ((punk) != NULL)         \
00044     {                           \
00045         (punk)->Release();      \
00046     }                           \
00047 }
00048
00049 #define SafeReleaseClear(punk)  \
00050 {                               \
00051     if ((punk) != NULL)         \
00052     {                           \
00053         (punk)->Release();      \
00054         (punk) = NULL;          \
00055     }                           \
00056 }
00057
00058 //+---------------------------------------------------------------------------
00059 //
00060 // SafeStringCopy
00061 //
00062 // Copies a string from one buffer to another.  wcsncpy does not always
00063 // null-terminate the destination buffer; this function does.
00064 //----------------------------------------------------------------------------
00065
00066 inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc)
00067 {
00068     if (cchMax > 0)
00069     {
00070         wcsncpy(pchDst, pchSrc, cchMax);
00071         pchDst[cchMax-1] = '\0';
00072     }
00073 }
00074
00075 extern HINSTANCE g_hInst;
00076
00077 extern LONG g_cRefDll;
00078
00079 extern CRITICAL_SECTION g_cs;
00080
00081 extern const CLSID c_clsidMarkTextService;
00082 extern const GUID c_guidMarkProfile;
00083 extern const GUID c_guidLangBarItemButton;
00084 extern const GUID c_guidMarkDisplayAttribute;
00085 extern const GUID c_guidMarkContextCompartment;
00086 extern const GUID c_guidMarkGlobalCompartment;
00087 extern const GUID c_guidCaseProperty;
00088 extern const GUID c_guidCustomProperty;
00089
00090 #endif // GLOBALS_H
Generated on Wed Nov 13 2024 16:52:22 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: WinBase/Cluster/Win2003/FileShareSample/File Share SampleEx/PropList.cpp Source File

  • WinBase
  • Cluster
  • Win2003
  • FileShareSample
  • File Share SampleEx

PropList.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  Copyright (c) 2003 <company name>
00004 //
00005 //  Module Name:
00006 //      PropList.cpp
00007 //
00008 //  Description:
00009 //      Implementation of the CClusPropList class.
00010 //
00011 //  Author:
00012 //      <name> (<e-mail name>) Mmmm DD, 2003
00013 //
00014 //  Revision History:
00015 //
00016 //  Notes:
00017 //
00018 /////////////////////////////////////////////////////////////////////////////
00019
00020
00021 #include "stdafx.h"
00022 #include "PropList.h"
00023 #include <StrSafe.h>
00024
00025 #ifdef _DEBUG
00026 #ifdef __AFX_H__
00027 #define new DEBUG_NEW
00028 #undef THIS_FILE
00029 static char THIS_FILE[] = __FILE__;
00030 #endif // __AFX_H__
00031 #endif
00032
00033 #ifndef __AFX_H__
00034 class CMemoryException
00035 {
00036 public:
00037     void Delete( void ) { }
00038
00039 }; //*** class CMemoryException
00040 #endif // __AFX_H__
00041
00042 /////////////////////////////////////////////////////////////////////////////
00043 // Constant Definitions
00044 /////////////////////////////////////////////////////////////////////////////
00045
00046 const int BUFFER_GROWTH_FACTOR = 256;
00047
00048 //////////////////////////////////////////////////////////////////////////////
00049 // Globals
00050 //////////////////////////////////////////////////////////////////////////////
00051
00052
00053 //////////////////////////////////////////////////////////////////////////////
00054 // String comparison routines
00055 //////////////////////////////////////////////////////////////////////////////
00056
00057
00058 /////////////////////////////////////////////////////////////////////////////
00059 //++
00060 //
00061 //  WrapCompareString
00062 //
00063 //  Description:
00064 //      Wraps the call to CompareString
00065 //
00066 //  Arguments:
00067 //      fCaseSensitive      TRUE for a case sensitive compare
00068 //                          FALSE for a case insensitive compare
00069 //      pcwszString1In      The first string.
00070 //      cch1In              The count of characters in the first string.
00071 //                          If -1 then it's assumed to be null-terminated.
00072 //      pcwszString2In      The second string.
00073 //      cchIn               The count of characters in the second string.
00074 //                          If -1 then it's assumed to be null-terminated.
00075 //
00076 //  Return Value:
00077 //       0  Strings are equal.
00078 //     > 0  String1 greater than String2.
00079 //     < 0  String1 less than String2.
00080 //
00081 //--
00082 /////////////////////////////////////////////////////////////////////////////
00083 int
00084 WrapCompareString(
00085       BOOL      fCaseSensitive
00086     , LPCWSTR   pcwszString1In
00087     , size_t    cch1In
00088     , LPCWSTR   pcwszString2In
00089     , size_t    cch2In
00090     )
00091 {
00092     int nRet;
00093
00094     nRet = CompareStringW(
00095               LOCALE_SYSTEM_DEFAULT
00096             , fCaseSensitive ? 0 : NORM_IGNORECASE
00097             , pcwszString1In
00098             , static_cast< DWORD >( cch1In )
00099             , pcwszString2In
00100             , static_cast< DWORD >( cch2In )
00101             );
00102
00103     return nRet - CSTR_EQUAL; // CSTR_LT < CSTR_EQUAL < CSTR_GT
00104
00105 } // *** WrapCompareString
00106
00107 //
00108 // Full string compares.
00109 //
00110
00111 int
00112 IBSTRCompareW(
00113       BSTR  bstrString1In
00114     , BSTR  bstrString2In
00115     )
00116 {
00117     return WrapCompareString(
00118                   FALSE
00119                 , static_cast< LPCWSTR >( bstrString1In )
00120                 , SysStringLen( bstrString1In )
00121                 , static_cast< LPCWSTR >( bstrString2In )
00122                 , SysStringLen( bstrString2In )
00123                 );
00124 } //*** IBSTRCompareW
00125
00126 int
00127 BSTRCompareW(
00128       BSTR  bstrString1In
00129     , BSTR  bstrString2In
00130     )
00131 {
00132     return WrapCompareString(
00133                   TRUE
00134                 , static_cast< LPCWSTR >( bstrString1In )
00135                 , SysStringLen( bstrString1In )
00136                 , static_cast< LPCWSTR >( bstrString2In )
00137                 , SysStringLen( bstrString2In )
00138                 );
00139 } //*** BSTRCompareW
00140
00141 int
00142 IStringCompareW(
00143       LPCWSTR pcwszString1In
00144     , LPCWSTR pcwszString2In
00145     )
00146 {
00147     return WrapCompareString(
00148                   FALSE
00149                 , pcwszString1In
00150                 , static_cast< size_t >( -1 )
00151                 , pcwszString2In
00152                 , static_cast< size_t >( -1 )
00153             );
00154 } //*** IStringCompareW
00155
00156 int
00157 StringCompareW(
00158       LPCWSTR pcwszString1In
00159     , LPCWSTR pcwszString2In
00160     )
00161 {
00162     return WrapCompareString(
00163                   TRUE
00164                 , pcwszString1In
00165                 , static_cast< size_t >( -1 )
00166                 , pcwszString2In
00167                 , static_cast< size_t >( -1 )
00168                 );
00169 } //*** StringCompareW
00170
00171 int
00172 IStringCompareW(
00173       LPCWSTR   pcwszString1In
00174     , size_t    cch1In
00175     , LPCWSTR   pcwszString2In
00176     , size_t    cch2In
00177     )
00178 {
00179     return WrapCompareString(
00180                   FALSE
00181                 , pcwszString1In
00182                 , cch1In
00183                 , pcwszString2In
00184                 , cch2In
00185                 );
00186 } //*** IStringCompareW
00187
00188 int
00189 StringCompareW(
00190       LPCWSTR   pcwszString1In
00191     , size_t    cch1In
00192     , LPCWSTR   pcwszString2In
00193     , size_t    cch2In
00194     )
00195 {
00196     return WrapCompareString(
00197                   TRUE
00198                 , pcwszString1In
00199                 , cch1In
00200                 , pcwszString2In
00201                 , cch2In
00202                 );
00203 } //*** StringCompareW
00204
00205 //
00206 // Partial string compares.  They use whichever one's length is shortest
00207 // if both are specified or the NBSTR routines are used.
00208 //
00209
00210 int
00211 NIBSTRCompareW(
00212       BSTR  bstrString1In
00213     , BSTR  bstrString2In
00214     )
00215 {
00216     size_t cchMin;
00217
00218     cchMin = min( SysStringLen( bstrString1In ), SysStringLen( bstrString2In ) );
00219
00220     return WrapCompareString(
00221                   FALSE
00222                 , static_cast< LPCWSTR >( bstrString1In )
00223                 , cchMin
00224                 , static_cast< LPCWSTR >( bstrString2In )
00225                 , cchMin
00226                 );
00227 } //*** NIBSTRCompareW
00228
00229 int
00230 NBSTRCompareW(
00231       BSTR  bstrString1In
00232     , BSTR  bstrString2In
00233     )
00234 {
00235     size_t cchMin;
00236
00237     cchMin = min( SysStringLen( bstrString1In ), SysStringLen( bstrString2In ) );
00238
00239     return WrapCompareString(
00240                   TRUE
00241                 , static_cast< LPCWSTR >( bstrString1In )
00242                 , cchMin
00243                 , static_cast< LPCWSTR >( bstrString2In )
00244                 , cchMin
00245                 );
00246 } //*** NBSTRCompareW
00247
00248 int
00249 NIStringCompareW(
00250       LPCWSTR   pcwszString1In
00251     , LPCWSTR   pcwszString2In
00252     , size_t    cchIn
00253     )
00254 {
00255     return WrapCompareString(
00256                   FALSE
00257                 , pcwszString1In
00258                 , cchIn
00259                 , pcwszString2In
00260                 , cchIn
00261                 );
00262 } //*** NIStringCompareW
00263
00264 int
00265 NStringCompareW(
00266       LPCWSTR   pcwszString1In
00267     , LPCWSTR   pcwszString2In
00268     , size_t    cchIn
00269     )
00270 {
00271     return WrapCompareString(
00272                   TRUE
00273                 , pcwszString1In
00274                 , cchIn
00275                 , pcwszString2In
00276                 , cchIn
00277                 );
00278 } //*** NIStringCompareW
00279
00280 int
00281 NIStringCompareW(
00282       LPCWSTR   pcwszString1In
00283     , size_t    cch1In
00284     , LPCWSTR   pcwszString2In
00285     , size_t    cch2In
00286     )
00287 {
00288     return WrapCompareString(
00289                   FALSE
00290                 , pcwszString1In
00291                 , min( cch1In, cch2In )
00292                 , pcwszString2In
00293                 , min( cch1In, cch2In )
00294                 );
00295 } //*** NIStringCompareW
00296
00297 int
00298 NStringCompareW(
00299       LPCWSTR   pcwszString1In
00300     , size_t    cch1In
00301     , LPCWSTR   pcwszString2In
00302     , size_t    cch2In
00303     )
00304 {
00305     return WrapCompareString(
00306                   TRUE
00307                 , pcwszString1In
00308                 , min( cch1In, cch2In )
00309                 , pcwszString2In
00310                 , min( cch1In, cch2In )
00311                 );
00312 } //*** NStringCompareW
00313
00314 /////////////////////////////////////////////////////////////////////////////
00315 //++
00316 //
00317 //  CchMultiSz
00318 //
00319 //  Description:
00320 //      Length of all of the substrings of a multisz string minus the final NULL.
00321 //
00322 //      (i.e., includes the nulls of the substrings, excludes the final null)
00323 //      multiszlen( "abcd\0efgh\0\0" => 5 + 5 = 10
00324 //
00325 //  Arguments:
00326 //      pszIn     The string to get the length of.
00327 //
00328 //  Return Value:
00329 //      Count of characters in the multisz or 0 if empty.
00330 //
00331 //--
00332 /////////////////////////////////////////////////////////////////////////////
00333 static size_t
00334 CchMultiSz(
00335     LPCWSTR pszIn
00336     )
00337 {
00338     ASSERT( pszIn != NULL );
00339
00340     size_t  cchTotal = 0;
00341     size_t  cchChars = 0;
00342
00343     while ( *pszIn != L'\0' )
00344     {
00345         cchChars = lstrlenW( pszIn ) + 1;
00346
00347         cchTotal += cchChars;
00348         pszIn += cchChars;
00349     } // while: pointer not stopped on EOS
00350
00351     return cchTotal;
00352
00353 } //*** CchMultiSz
00354
00355 /////////////////////////////////////////////////////////////////////////////
00356 //++
00357 //
00358 //  NCompareMultiSz
00359 //
00360 //  Description:
00361 //      Compare two MULTI_SZ buffers.
00362 //
00363 //  Arguments:
00364 //      pszSourceIn   The source string.
00365 //      pszTargetIn   The target string.
00366 //
00367 //  Return Value:
00368 //      If the string pointed to by pszSource is less than the string pointed
00369 //      to by pszTarget, the return value is negative. If the string pointed
00370 //      to by pszSource is greater than the string pointed to by pszTarget,
00371 //      the return value is positive. If the strings are equal, the return value
00372 //      is zero.
00373 //
00374 //--
00375 /////////////////////////////////////////////////////////////////////////////
00376 static int NCompareMultiSz(
00377       LPCWSTR pszSourceIn
00378     , LPCWSTR pszTargetIn
00379     )
00380 {
00381     ASSERT( pszSourceIn != NULL );
00382     ASSERT( pszTargetIn != NULL );
00383
00384     while ( ( *pszSourceIn != L'\0' ) && ( *pszTargetIn != L'\0') )
00385     {
00386         //
00387         // Move to end of strings.
00388         //
00389
00390         while ( ( *pszSourceIn != L'\0' ) && ( *pszTargetIn != L'\0') && ( *pszSourceIn == *pszTargetIn ) )
00391         {
00392             ++pszSourceIn;
00393             ++pszTargetIn;
00394         } // while: pointer not stopped on EOS
00395
00396         //
00397         // If strings are the same, skip past terminating NUL.
00398         // Otherwise exit the loop.
00399
00400         if ( ( *pszSourceIn == L'\0' ) && ( *pszTargetIn == L'\0') )
00401         {
00402             ++pszSourceIn;
00403             ++pszTargetIn;
00404         } // if: both stopped on EOS
00405         else
00406         {
00407             break;
00408         } // else: stopped because something is not equal -- we are done.
00409
00410     } // while: pointer not stopped on EOS
00411
00412     return *pszSourceIn - *pszTargetIn;
00413
00414 } //*** NCompareMultiSz
00415
00416 /////////////////////////////////////////////////////////////////////////////
00417 // CClusPropValueList class
00418 /////////////////////////////////////////////////////////////////////////////
00419
00420 #ifdef __AFX_H__
00421 IMPLEMENT_DYNAMIC( CClusPropValueList, CObject );
00422 #endif // __AFX_H__
00423
00424 /////////////////////////////////////////////////////////////////////////////
00425 //++
00426 //
00427 //  CClusPropValueList::ScMoveToFirstValue
00428 //
00429 //  Description:
00430 //      Move the cursor to the first value in the value list.
00431 //
00432 //  Arguments:
00433 //      None.
00434 //
00435 //  Return Value:
00436 //      ERROR_SUCCESS   Position moved to the first value successfully.
00437 //
00438 //--
00439 /////////////////////////////////////////////////////////////////////////////
00440 DWORD
00441 CClusPropValueList::ScMoveToFirstValue( void )
00442 {
00443     ASSERT( m_cbhValueList.pb != NULL );
00444
00445     DWORD   sc;
00446
00447     m_cbhCurrentValue = m_cbhValueList;
00448     m_cbDataLeft = m_cbDataSize;
00449     m_fAtEnd = FALSE;
00450
00451     if ( m_cbhCurrentValue.pSyntax->dw == CLUSPROP_SYNTAX_ENDMARK )
00452     {
00453         sc = ERROR_NO_MORE_ITEMS;
00454     } // if: no items in the value list
00455     else
00456     {
00457         sc = ERROR_SUCCESS;
00458     } // else: items exist in the value list
00459
00460     return sc;
00461
00462 } //*** CClusPropValueList::ScMoveToFirstValue
00463
00464 /////////////////////////////////////////////////////////////////////////////
00465 //++
00466 //
00467 //  CClusPropValueList::ScMoveToNextValue
00468 //
00469 //  Description:
00470 //      Move the cursor to the next value in the list.
00471 //
00472 //  Arguments:
00473 //      None.
00474 //
00475 //  Return Value:
00476 //      ERROR_SUCCESS       Position moved to the next value successfully.
00477 //      ERROR_NO_MORE_ITEMS Already at the end of the list.
00478 //      ERROR_INVALID_DATA  Not enough data in the buffer.
00479 //
00480 //--
00481 /////////////////////////////////////////////////////////////////////////////
00482 DWORD
00483 CClusPropValueList::ScMoveToNextValue( void )
00484 {
00485     ASSERT( m_cbhCurrentValue.pb != NULL );
00486
00487     DWORD                   sc     = ERROR_NO_MORE_ITEMS;
00488     size_t                  cbDataSize;
00489     CLUSPROP_BUFFER_HELPER  cbhCurrentValue;
00490
00491     cbhCurrentValue = m_cbhCurrentValue;
00492
00493     //
00494     // Don't try to move if we're already at the end.
00495     //
00496
00497     if ( m_fAtEnd )
00498     {
00499         goto Cleanup;
00500     } // if: already at the end of the list
00501
00502     //
00503     // Make sure the buffer is big enough for the value header.
00504     //
00505
00506     if ( m_cbDataLeft < sizeof( *cbhCurrentValue.pValue ) )
00507     {
00508         sc = ERROR_INVALID_DATA;
00509         goto Cleanup;
00510     } // if: not enough data left
00511
00512     //
00513     // Calculate how much to advance buffer pointer.
00514     //
00515
00516     cbDataSize = sizeof( *cbhCurrentValue.pValue )
00517                 + ALIGN_CLUSPROP( cbhCurrentValue.pValue->cbLength );
00518
00519     //
00520     // Make sure the buffer is big enough for the value header,
00521     // the data itself, and the endmark.
00522     //
00523
00524     if ( m_cbDataLeft < cbDataSize + sizeof( CLUSPROP_SYNTAX ) )
00525     {
00526         sc = ERROR_INVALID_DATA;
00527         goto Cleanup;
00528     } // if: not enough data left
00529
00530     //
00531     // Move past the current value to the next value's syntax.
00532     //
00533
00534     cbhCurrentValue.pb += cbDataSize;
00535
00536     //
00537     // This test will ensure that the value is always valid since we won't
00538     // advance if the next thing is the endmark.
00539     //
00540
00541     if ( cbhCurrentValue.pSyntax->dw != CLUSPROP_SYNTAX_ENDMARK )
00542     {
00543         m_cbhCurrentValue = cbhCurrentValue;
00544         m_cbDataLeft -= cbDataSize;
00545         sc = ERROR_SUCCESS;
00546     } // if: next value's syntax is not the endmark
00547     else
00548     {
00549         m_fAtEnd = TRUE;
00550     } // else: next value's syntax is the endmark
00551
00552 Cleanup:
00553
00554     return sc;
00555
00556 } //*** CClusPropValueList::ScMoveToNextValue
00557
00558 /////////////////////////////////////////////////////////////////////////////
00559 //++
00560 //
00561 //  CClusPropValueList::ScCheckIfAtLastValue
00562 //
00563 //  Description:
00564 //      Indicate whether we are on the last value in the list or not.
00565 //
00566 //  Arguments:
00567 //      None.
00568 //
00569 //  Return Value:
00570 //      ERROR_SUCCESS       Not currently at the last value in the list.
00571 //      ERROR_NO_MORE_ITEMS Currently at the last value in the list.
00572 //      ERROR_INVALID_DATA  Not enough data in the buffer.
00573 //
00574 //--
00575 /////////////////////////////////////////////////////////////////////////////
00576 DWORD
00577 CClusPropValueList::ScCheckIfAtLastValue( void )
00578 {
00579     ASSERT( m_cbhCurrentValue.pb != NULL );
00580
00581     DWORD                   sc = ERROR_SUCCESS;
00582     CLUSPROP_BUFFER_HELPER  cbhCurrentValue;
00583     size_t                  cbDataSize = 0;
00584
00585     cbhCurrentValue = m_cbhCurrentValue;
00586
00587     //
00588     // Don't try to recalculate if we already know
00589     // we're at the end of the list.
00590     //
00591
00592     if ( m_fAtEnd )
00593     {
00594         goto Cleanup;
00595     } // if: already at the end of the list
00596
00597     //
00598     // Make sure the buffer is big enough for the value header.
00599     //
00600
00601     if ( m_cbDataLeft < sizeof( *cbhCurrentValue.pValue ) )
00602     {
00603         sc = ERROR_INVALID_DATA;
00604         goto Cleanup;
00605     } // if: not enough data left
00606
00607     //
00608     // Calculate how much to advance buffer pointer.
00609     //
00610
00611     cbDataSize = sizeof( *cbhCurrentValue.pValue )
00612                 + ALIGN_CLUSPROP( cbhCurrentValue.pValue->cbLength );
00613
00614     //
00615     // Make sure the buffer is big enough for the value header,
00616     // the data itself, and the endmark.
00617     //
00618
00619     if ( m_cbDataLeft < cbDataSize + sizeof( CLUSPROP_SYNTAX ) )
00620     {
00621         sc = ERROR_INVALID_DATA;
00622         goto Cleanup;
00623     } // if: not enough data left
00624
00625     //
00626     // Move past the current value to the next value's syntax.
00627     //
00628
00629     cbhCurrentValue.pb += cbDataSize;
00630
00631     //
00632     // We are on the last value if the next thing after this value
00633     // is an endmark.
00634     //
00635
00636     if ( cbhCurrentValue.pSyntax->dw == CLUSPROP_SYNTAX_ENDMARK )
00637     {
00638         sc = ERROR_NO_MORE_ITEMS;
00639     } // if: next value's syntax is the endmark
00640
00641 Cleanup:
00642
00643     return sc;
00644
00645 } //*** CClusPropValueList::ScCheckIfAtLastValue
00646
00647 /////////////////////////////////////////////////////////////////////////////
00648 //++
00649 //
00650 //  CClusPropValueList::ScAllocValueList
00651 //
00652 //  Description:
00653 //      Allocate a value list buffer that's big enough to hold the next
00654 //      value.
00655 //
00656 //  Arguments:
00657 //      cbMinimumIn   Minimum size of the value list.
00658 //
00659 //  Return Value:
00660 //      None.
00661 //
00662 //--
00663 /////////////////////////////////////////////////////////////////////////////
00664 DWORD
00665 CClusPropValueList::ScAllocValueList(
00666     size_t cbMinimumIn
00667     )
00668 {
00669     ASSERT( cbMinimumIn > 0 );
00670
00671     DWORD   sc = ERROR_SUCCESS;
00672     size_t  cbTotal = 0;
00673
00674     //
00675     // Add the size of the item count and final endmark.
00676     //
00677
00678     cbMinimumIn += sizeof( CLUSPROP_VALUE );
00679     cbTotal = m_cbDataSize + cbMinimumIn;
00680
00681     if ( m_cbBufferSize < cbTotal )
00682     {
00683         PBYTE   _pbNewValuelist = NULL;
00684
00685         cbMinimumIn = max( BUFFER_GROWTH_FACTOR, cbMinimumIn );
00686         cbTotal = m_cbDataSize + cbMinimumIn;
00687
00688         //
00689         // Allocate and zero a new buffer.
00690         //
00691
00692         _pbNewValuelist = new BYTE[ cbTotal ];
00693         if ( _pbNewValuelist != NULL )
00694         {
00695             ZeroMemory( _pbNewValuelist, cbTotal );
00696
00697             //
00698             // If there was a previous buffer, copy it and the delete it.
00699             //
00700
00701             if ( m_cbhValueList.pb != NULL )
00702             {
00703                 if ( m_cbDataSize != 0 )
00704                 {
00705                     CopyMemory( _pbNewValuelist, m_cbhValueList.pb, m_cbDataSize );
00706                 } // if: data already exists in buffer
00707
00708                 delete [] m_cbhValueList.pb;
00709                 m_cbhCurrentValue.pb = _pbNewValuelist + (m_cbhCurrentValue.pb - m_cbhValueList.pb);
00710             } // if: there was a previous buffer
00711             else
00712             {
00713                 m_cbhCurrentValue.pb = _pbNewValuelist + sizeof( DWORD ); // move past prop count
00714             } // else: no previous buffer
00715
00716             //
00717             // Save the new buffer.
00718             //
00719
00720             m_cbhValueList.pb = _pbNewValuelist;
00721             m_cbBufferSize = cbTotal;
00722         } // if: allocation succeeded
00723         else
00724         {
00725             sc = ERROR_NOT_ENOUGH_MEMORY;
00726         } // else: allocation failed
00727     } // if: buffer isn't big enough
00728
00729     return sc;
00730
00731 } //*** CClusPropValueList::ScAllocValueList
00732
00733 /////////////////////////////////////////////////////////////////////////////
00734 //++
00735 //
00736 //  CClusPropValueList::ScGetResourceValueList
00737 //
00738 //  Description:
00739 //      Get value list of a resource.
00740 //
00741 //  Arguments:
00742 //      hResourceIn     Handle for the resource to get properties from.
00743 //      dwControlCodeIn Control code for the request.
00744 //      hHostNodeIn     Handle for the node to direct this request to.
00745 //                      Defaults to NULL.
00746 //      lpBufferIn      Input buffer for the request.  Defaults to NULL.
00747 //      cbBufferIn      Size of the input buffer.  Defaults to 0.
00748 //
00749 //  Return Value:
00750 //      None.
00751 //
00752 //--
00753 /////////////////////////////////////////////////////////////////////////////
00754 DWORD
00755 CClusPropValueList::ScGetResourceValueList(
00756       HRESOURCE hResourceIn
00757     , DWORD     dwControlCodeIn
00758     , HNODE     hHostNodeIn
00759     , LPVOID    lpBufferIn
00760     , size_t    cbBufferIn
00761     )
00762 {
00763     ASSERT( hResourceIn != NULL );
00764     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
00765             == ( CLUS_OBJECT_RESOURCE << CLUSCTL_OBJECT_SHIFT ) );
00766
00767     DWORD   sc = ERROR_SUCCESS;
00768     DWORD   cb = 512;
00769
00770     //
00771     // Overwrite anything that may be in the buffer.
00772     // Allows this class instance to be reused.
00773     //
00774
00775     m_cbDataSize = 0;
00776
00777     //
00778     // Get values.
00779     //
00780
00781     sc = ScAllocValueList( cb );
00782     if ( sc == ERROR_SUCCESS )
00783     {
00784         sc = ClusterResourceControl(
00785                         hResourceIn,
00786                         hHostNodeIn,
00787                         dwControlCodeIn,
00788                         lpBufferIn,
00789                         static_cast< DWORD >( cbBufferIn ),
00790                         m_cbhValueList.pb,
00791                         static_cast< DWORD >( m_cbBufferSize ),
00792                         &cb
00793                         );
00794         if ( sc == ERROR_MORE_DATA )
00795         {
00796             sc = ScAllocValueList( cb );
00797             if ( sc == ERROR_SUCCESS )
00798             {
00799                 sc = ClusterResourceControl(
00800                                 hResourceIn,
00801                                 hHostNodeIn,
00802                                 dwControlCodeIn,
00803                                 lpBufferIn,
00804                                 static_cast< DWORD >( cbBufferIn ),
00805                                 m_cbhValueList.pb,
00806                                 static_cast< DWORD >( m_cbBufferSize ),
00807                                 &cb
00808                                 );
00809             } // if: ScAllocValueList succeeded
00810         } // if: buffer too small
00811     } // if: ScAllocValueList succeeded
00812
00813     if ( sc != ERROR_SUCCESS )
00814     {
00815         DeleteValueList();
00816     } // if: error getting properties.
00817     else
00818     {
00819         m_cbDataSize = static_cast< size_t >( cb );
00820         m_cbDataLeft = static_cast< size_t >( cb );
00821     } // else: no errors
00822
00823     return sc;
00824
00825 } //*** CClusPropValueList::ScGetResourceValueList
00826
00827 /////////////////////////////////////////////////////////////////////////////
00828 //++
00829 //
00830 //  CClusPropValueList::ScGetResourceTypeValueList
00831 //
00832 //  Description:
00833 //      Get value list of a resource type.
00834 //
00835 //  Arguments:
00836 //      hClusterIn          Handle for the cluster in which the resource
00837 //                          type resides.
00838 //      pwszResTypeNameIn   Name of the resource type.
00839 //      dwControlCodeIn     Control code for the request.
00840 //      hHostNodeIn         Handle for the node to direct this request to.
00841 //                          Defaults to NULL.
00842 //      lpBufferIn          Input buffer for the request.  Defaults to NULL.
00843 //      cbBufferIn          Size of the input buffer.  Defaults to 0.
00844 //
00845 //  Return Value:
00846 //      None.
00847 //
00848 //--
00849 /////////////////////////////////////////////////////////////////////////////
00850 DWORD
00851 CClusPropValueList::ScGetResourceTypeValueList(
00852       HCLUSTER  hClusterIn
00853     , LPCWSTR   pwszResTypeNameIn
00854     , DWORD     dwControlCodeIn
00855     , HNODE     hHostNodeIn
00856     , LPVOID    lpBufferIn
00857     , size_t    cbBufferIn
00858     )
00859 {
00860     ASSERT( hClusterIn != NULL );
00861     ASSERT( pwszResTypeNameIn != NULL );
00862     ASSERT( *pwszResTypeNameIn != L'\0' );
00863     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
00864             == ( CLUS_OBJECT_RESOURCE_TYPE << CLUSCTL_OBJECT_SHIFT ) );
00865
00866     DWORD   sc = ERROR_SUCCESS;
00867     DWORD   cb = 512;
00868
00869     //
00870     // Overwrite anything that may be in the buffer.
00871     // Allows this class instance to be reused.
00872     //
00873
00874     m_cbDataSize = 0;
00875
00876     //
00877     // Get values.
00878     //
00879
00880     sc = ScAllocValueList( cb );
00881     if ( sc == ERROR_SUCCESS )
00882     {
00883         sc = ClusterResourceTypeControl(
00884                         hClusterIn,
00885                         pwszResTypeNameIn,
00886                         hHostNodeIn,
00887                         dwControlCodeIn,
00888                         lpBufferIn,
00889                         static_cast< DWORD >( cbBufferIn ),
00890                         m_cbhValueList.pb,
00891                         static_cast< DWORD >( m_cbBufferSize ),
00892                         &cb
00893                         );
00894         if ( sc == ERROR_MORE_DATA )
00895         {
00896             sc = ScAllocValueList( cb );
00897             if ( sc == ERROR_SUCCESS )
00898             {
00899                 sc = ClusterResourceTypeControl(
00900                                 hClusterIn,
00901                                 pwszResTypeNameIn,
00902                                 hHostNodeIn,
00903                                 dwControlCodeIn,
00904                                 lpBufferIn,
00905                                 static_cast< DWORD >( cbBufferIn ),
00906                                 m_cbhValueList.pb,
00907                                 static_cast< DWORD >( m_cbBufferSize ),
00908                                 &cb
00909                                 );
00910             } // if: ScAllocValueList succeeded
00911         } // if: buffer too small
00912     } // if: ScAllocValueList succeeded
00913
00914     if ( sc != ERROR_SUCCESS )
00915     {
00916         DeleteValueList();
00917     } // if: error getting properties.
00918     else
00919     {
00920         m_cbDataSize = static_cast< size_t >( cb );
00921         m_cbDataLeft = static_cast< size_t >( cb );
00922     } // else: no errors
00923
00924     return sc;
00925
00926 } //*** CClusPropValueList::ScGetResourceTypeValueList
00927
00928
00929 //*************************************************************************//
00930
00931
00932 /////////////////////////////////////////////////////////////////////////////
00933 // CClusPropList class
00934 /////////////////////////////////////////////////////////////////////////////
00935
00936 #ifdef __AFX_H__
00937 IMPLEMENT_DYNAMIC( CClusPropList, CObject );
00938 #endif // __AFX_H__
00939
00940 /////////////////////////////////////////////////////////////////////////////
00941 //++
00942 //
00943 //  CClusPropList::ScCopy
00944 //
00945 //  Description:
00946 //      Copy a property list.  This function is equivalent to an assignment
00947 //      operator.  Since this operation can fail, no assignment operator is
00948 //      provided.
00949 //
00950 //  Arguments:
00951 //      pcplPropListIn    The proplist to copy into this instance.
00952 //      cbPropListIn      The total size of the prop list.
00953 //
00954 //  Return Value:
00955 //      Win32 status code.
00956 //
00957 //--
00958 /////////////////////////////////////////////////////////////////////////////
00959 DWORD
00960 CClusPropList::ScCopy(
00961       const PCLUSPROP_LIST  pcplPropListIn
00962     , size_t                cbPropListIn
00963     )
00964 {
00965     ASSERT( pcplPropListIn != NULL );
00966
00967     DWORD   sc = ERROR_SUCCESS;
00968
00969     //
00970     // Clean up any vestiges of a previous prop list.
00971     //
00972
00973     if ( m_cbhPropList.pb != NULL )
00974     {
00975         DeletePropList();
00976     } // if: the current list is not empty
00977
00978     //
00979     // Allocate the new property list buffer.  If successful,
00980     // copy the source list.
00981     //
00982
00983     m_cbhPropList.pb = new BYTE[ cbPropListIn ];
00984     if ( m_cbhPropList.pb != NULL )
00985     {
00986         CopyMemory( m_cbhPropList.pList, pcplPropListIn, cbPropListIn );
00987         m_cbBufferSize = cbPropListIn;
00988         m_cbDataSize   = cbPropListIn;
00989         m_cbDataLeft   = cbPropListIn;
00990         sc = ScMoveToFirstProperty();
00991     } // if: new succeeded
00992     else
00993     {
00994         sc = ERROR_NOT_ENOUGH_MEMORY;
00995     } // else:
00996
00997     return sc;
00998
00999 } //*** CClusPropList::ScCopy
01000
01001 /////////////////////////////////////////////////////////////////////////////
01002 //++
01003 //
01004 //  CClusPropList::ScAppend
01005 //
01006 //  Description:
01007 //      Append to a property list.
01008 //
01009 //  Arguments:
01010 //      rclPropListIn    The proplist to append onto this instance.
01011 //
01012 //  Return Value:
01013 //      Win32 status code.
01014 //
01015 //--
01016 /////////////////////////////////////////////////////////////////////////////
01017 DWORD
01018 CClusPropList::ScAppend(
01019     const CClusPropList & rclPropListIn
01020     )
01021 {
01022     DWORD   sc = ERROR_SUCCESS;
01023     size_t  cbPropertyCountOffset = 0;
01024     size_t  cbIncrement = 0;
01025     size_t  cbDataLeft = 0;
01026     PBYTE   pbsrc = NULL;
01027     PBYTE   pbdest = NULL;
01028
01029     //
01030     //  Compute the number of bytes to get past the count of properties that
01031     //  is at the head of the list.  This is typically sizeof DWORD.
01032     //
01033
01034     cbPropertyCountOffset = sizeof( m_cbhPropList.pList->nPropertyCount );
01035
01036     //
01037     //  Compute the allocation increment.  This is used when growing our buffer
01038     //  and is the amount of data to copy from the passed in list.  This includes
01039     //  the trailing endmark.  m_cbDataSize does not include the leading property
01040     //  count DWORD.
01041     //
01042
01043     cbIncrement = rclPropListIn.m_cbDataSize;
01044
01045     //
01046     //  How much space remains in our current buffer?
01047     //
01048
01049     cbDataLeft = m_cbBufferSize - m_cbDataSize;
01050
01051     //
01052     //  If the size of the list to append is larger than what we have remaining
01053     //  then we need to grow the list.
01054     //
01055
01056     if ( cbIncrement > cbDataLeft )
01057     {
01058         sc = ScAllocPropList( m_cbDataSize + cbIncrement );
01059         if ( sc != ERROR_SUCCESS )
01060         {
01061             goto Cleanup;
01062         } // if:
01063     } // if:
01064
01065     pbdest = (PBYTE) &m_cbhPropList.pb[ cbPropertyCountOffset + m_cbDataSize ];
01066
01067     pbsrc = (PBYTE) &rclPropListIn.m_cbhPropList.pList->PropertyName;
01068
01069     CopyMemory( pbdest, pbsrc, cbIncrement );
01070
01071     //
01072     //  Grow our data size to match our new size.
01073     //
01074
01075     m_cbDataSize += cbIncrement;
01076
01077     //
01078     //  Increment our property count to include the count of properties appended to the end
01079     //  of our buffer.
01080     //
01081
01082     m_cbhPropList.pList->nPropertyCount += rclPropListIn.m_cbhPropList.pList->nPropertyCount;
01083
01084 Cleanup:
01085
01086     return sc;
01087
01088 } //*** CClusPropList::ScAppend
01089
01090 ////////////////////////////////////////////////////////////////////////////
01091 //++
01092 //
01093 //  CClusPropList::ScMoveToFirstProperty
01094 //
01095 //  Description:
01096 //      Move the cursor to the first propery in the list.
01097 //
01098 //  Arguments:
01099 //      None.
01100 //
01101 //  Return Value:
01102 //      ERROR_SUCCESS       Position moved to the first property successfully.
01103 //      ERROR_NO_MORE_ITEMS There are no properties in the list.
01104 //      ERROR_INVALID_DATA  Not enough data in the buffer.
01105 //
01106 //--
01107 /////////////////////////////////////////////////////////////////////////////
01108 DWORD
01109 CClusPropList::ScMoveToFirstProperty( void )
01110 {
01111     ASSERT( m_cbhPropList.pb != NULL );
01112     ASSERT( m_cbDataSize >= sizeof( m_cbhPropList.pList->nPropertyCount ) );
01113
01114     DWORD                   sc;
01115     size_t                  cbDataLeft;
01116     size_t                  cbDataSize;
01117     CLUSPROP_BUFFER_HELPER  cbhCurrentValue;
01118
01119     //
01120     // Make sure the buffer is big enough for the list header.
01121     //
01122
01123     if ( m_cbDataSize < sizeof( m_cbhPropList.pList->nPropertyCount ) )
01124     {
01125         sc = ERROR_INVALID_DATA;
01126         goto Cleanup;
01127     } // if: not enough data
01128
01129     //
01130     // Set the property counter to the number of properties in the list.
01131     //
01132
01133     m_nPropsRemaining = m_cbhPropList.pList->nPropertyCount;
01134
01135     //
01136     // Point the name pointer to the first name in the list.
01137     //
01138
01139     m_cbhCurrentPropName.pName = &m_cbhPropList.pList->PropertyName;
01140     m_cbDataLeft = m_cbDataSize - sizeof( m_cbhPropList.pList->nPropertyCount );
01141
01142     //
01143     // Check to see if there are any properties in the list.
01144     //
01145
01146     if ( m_nPropsRemaining == 0 )
01147     {
01148         sc = ERROR_NO_MORE_ITEMS;
01149         goto Cleanup;
01150     } // if: no properties in the list
01151
01152     //
01153     // Make sure the buffer is big enough for the first property name.
01154     //
01155
01156     if ( m_cbDataLeft < sizeof( *m_cbhCurrentPropName.pName ) )
01157     {
01158         sc = ERROR_INVALID_DATA;
01159         goto Cleanup;
01160     } // if: not enough data left
01161
01162     //
01163     // Calculate how much to advance the buffer pointer.
01164     //
01165
01166     cbDataSize = sizeof( *m_cbhCurrentPropName.pName )
01167                 + ALIGN_CLUSPROP( m_cbhCurrentPropName.pName->cbLength );
01168
01169     //
01170     // Make sure the buffer is big enough for the name header
01171     // and the data itself.
01172     //
01173
01174     if ( m_cbDataLeft < cbDataSize )
01175     {
01176         sc = ERROR_INVALID_DATA;
01177         goto Cleanup;
01178     } // if: not enough data left
01179
01180     //
01181     // Point the value buffer to the first value in the list.
01182     //
01183
01184     cbhCurrentValue.pb = m_cbhCurrentPropName.pb + cbDataSize;
01185     cbDataLeft = m_cbDataLeft - cbDataSize;
01186     m_pvlValues.Init( cbhCurrentValue, cbDataLeft );
01187
01188     //
01189     // Indicate we are successful.
01190     //
01191
01192     sc = ERROR_SUCCESS;
01193
01194 Cleanup:
01195
01196     return sc;
01197
01198 } //*** CClusPropList::ScMoveToFirstProperty
01199
01200 /////////////////////////////////////////////////////////////////////////////
01201 //++
01202 //
01203 //  CClusPropList::ScMoveToNextProperty
01204 //
01205 //  Description:
01206 //      Move the cursor to the next property in the list.
01207 //
01208 //  Arguments:
01209 //      None.
01210 //
01211 //  Return Value:
01212 //      ERROR_SUCCESS       Position moved to the next property successfully.
01213 //      ERROR_NO_MORE_ITEMS Already at the end of the list.
01214 //      ERROR_INVALID_DATA  Not enough data in the buffer.
01215 //
01216 //--
01217 /////////////////////////////////////////////////////////////////////////////
01218 DWORD
01219 CClusPropList::ScMoveToNextProperty( void )
01220 {
01221     ASSERT( m_cbhPropList.pb != NULL );
01222     ASSERT( m_pvlValues.CbhValueList().pb != NULL );
01223
01224     DWORD                   sc = ERROR_SUCCESS;
01225     size_t                  cbNameSize = 0;
01226     size_t                  cbDataLeft = 0;
01227     size_t                  cbDataSize = 0;
01228     CLUSPROP_BUFFER_HELPER  cbhCurrentValue;
01229     CLUSPROP_BUFFER_HELPER  cbhPropName;
01230
01231     cbhCurrentValue = m_pvlValues;
01232     cbDataLeft = m_pvlValues.CbDataLeft();
01233
01234     //
01235     // If we aren't already at the last property, attempt to move to the next one.
01236     //
01237
01238     sc = ScCheckIfAtLastProperty();
01239     if ( sc != ERROR_SUCCESS )
01240     {
01241         goto Cleanup;
01242     } // if: already at the last property (probably)
01243
01244     //
01245     // Make sure the buffer is big enough for the value header.
01246     //
01247
01248     if ( cbDataLeft < sizeof( *cbhCurrentValue.pValue ) )
01249     {
01250         sc = ERROR_INVALID_DATA;
01251         goto Cleanup;
01252     } // if: not enough data left
01253
01254     //
01255     // Careful!  Add offset only to cbhCurrentValue.pb.  Otherwise
01256     // pointer arithmetic will give undesirable results.
01257     //
01258
01259     while ( cbhCurrentValue.pSyntax->dw != CLUSPROP_SYNTAX_ENDMARK )
01260     {
01261         //
01262         // Make sure the buffer is big enough for the value
01263         // and an endmark.
01264         //
01265
01266         cbDataSize = sizeof( *cbhCurrentValue.pValue )
01267                     + ALIGN_CLUSPROP( cbhCurrentValue.pValue->cbLength );
01268         if ( cbDataLeft < cbDataSize + sizeof( *cbhCurrentValue.pSyntax ) )
01269         {
01270             sc = ERROR_INVALID_DATA;
01271             goto Cleanup;
01272         } // if: not enough data left
01273
01274         //
01275         // Advance past the value.
01276         //
01277
01278         cbhCurrentValue.pb += cbDataSize;
01279         cbDataLeft -= cbDataSize;
01280     } // while: not at endmark
01281
01282     if ( sc != ERROR_SUCCESS )
01283     {
01284         goto Cleanup;
01285     } // if: error occurred in loop
01286
01287     //
01288     // Advanced past the endmark.
01289     // Size check already performed in above loop.
01290     //
01291
01292     cbDataSize = sizeof( *cbhCurrentValue.pSyntax );
01293     cbhCurrentValue.pb += cbDataSize;
01294     cbDataLeft -= cbDataSize;
01295
01296     //
01297     // Point the name pointer to the next name in the list.
01298     //
01299
01300     cbhPropName = cbhCurrentValue;
01301     ASSERT( cbDataLeft == m_cbDataSize - (cbhPropName.pb - m_cbhPropList.pb) );
01302
01303     //
01304     // Calculate the size of the name with header.
01305     // Make sure the buffer is big enough for the name and an endmark.
01306     //
01307
01308     if ( cbDataLeft < sizeof( *cbhPropName.pName ) )
01309     {
01310         sc = ERROR_INVALID_DATA;
01311         goto Cleanup;
01312     } // if: not enough data
01313
01314     cbNameSize = sizeof( *cbhPropName.pName )
01315                 + ALIGN_CLUSPROP( cbhPropName.pName->cbLength );
01316
01317     if ( cbDataLeft < cbNameSize + sizeof( CLUSPROP_SYNTAX ) )
01318     {
01319         sc = ERROR_INVALID_DATA;
01320         goto Cleanup;
01321     } // if: not enough data
01322
01323     //
01324     // Point the value buffer to the first value in the list.
01325     //
01326
01327     cbhCurrentValue.pb = cbhPropName.pb + cbNameSize;
01328     m_cbhCurrentPropName = cbhPropName;
01329     m_cbDataLeft = cbDataLeft - cbNameSize;
01330     m_pvlValues.Init( cbhCurrentValue, m_cbDataLeft );
01331
01332     //
01333     // We've successfully advanced to the next property,
01334     // so there is now one fewer property remaining.
01335     //
01336
01337     --m_nPropsRemaining;
01338     ASSERT( m_nPropsRemaining >= 1 );
01339
01340     sc = ERROR_SUCCESS;
01341
01342 Cleanup:
01343
01344     return sc;
01345
01346 } //*** CClusPropList::ScMoveToNextProperty
01347
01348 /////////////////////////////////////////////////////////////////////////////
01349 //++
01350 //
01351 //  CClusPropList::ScMoveToPropertyByName
01352 //
01353 //  Description:
01354 //      Find the passed in property name in the proplist.  Note that the
01355 //      cursor is reset to the beginning at the beginning of the routine and
01356 //      the current state of the cursor is lost.
01357 //
01358 //  Arguments:
01359 //      pwszPropNameIn    Name of the property
01360 //
01361 //  Return Value:
01362 //      ERROR_SUCCESS if the property was found, other Win32 code if not.
01363 //
01364 //--
01365 /////////////////////////////////////////////////////////////////////////////
01366 DWORD
01367 CClusPropList::ScMoveToPropertyByName(
01368     LPCWSTR pwszPropNameIn
01369     )
01370 {
01371     ASSERT( m_cbhPropList.pb != NULL );
01372
01373     DWORD   sc = ERROR_SUCCESS;
01374
01375     sc = ScMoveToFirstProperty();
01376     if ( sc == ERROR_SUCCESS )
01377     {
01378         do
01379         {
01380             //
01381             // See if this is the specified property.  If so, we're done.
01382             //
01383
01384             if ( IStringCompareW( m_cbhCurrentPropName.pName->sz, pwszPropNameIn ) == 0 )
01385             {
01386                 break;
01387             } // if: property found
01388
01389             //
01390             // Advance to the next property.
01391             //
01392
01393             sc = ScMoveToNextProperty();   // No because we expect an error when at the d
01394
01395         } while ( sc == ERROR_SUCCESS );   // do-while: not end of list
01396     } // if: successfully moved to the first property
01397
01398     return sc;
01399
01400 } //*** ClusPropList::ScMoveToPropertyByName( LPCWSTR )
01401
01402 /////////////////////////////////////////////////////////////////////////////
01403 //++
01404 //
01405 //  CClusPropList::ScAllocPropList
01406 //
01407 //  Description:
01408 //      Allocate a property list buffer that's big enough to hold the next
01409 //      property.
01410 //
01411 //  Arguments:
01412 //      cbMinimumIn   Minimum size of the property list.
01413 //
01414 //  Return Value:
01415 //      ERROR_SUCCESS
01416 //      ERROR_NOT_ENOUGH_MEMORY
01417 //      Other Win32 error codes
01418 //
01419 //--
01420 /////////////////////////////////////////////////////////////////////////////
01421 DWORD
01422 CClusPropList::ScAllocPropList(
01423     size_t cbMinimumIn
01424     )
01425 {
01426     ASSERT( cbMinimumIn > 0 );
01427
01428     DWORD   sc = ERROR_SUCCESS;
01429     size_t  cbTotal = 0;
01430
01431     //
01432     // Add the size of the item count and final endmark.
01433     //
01434
01435     cbMinimumIn += sizeof( CLUSPROP_VALUE );
01436     cbTotal = m_cbDataSize + cbMinimumIn;
01437
01438     if ( m_cbBufferSize < cbTotal )
01439     {
01440         PBYTE   pbNewProplist = NULL;
01441
01442         cbMinimumIn = max( BUFFER_GROWTH_FACTOR, cbMinimumIn );
01443         cbTotal = m_cbDataSize + cbMinimumIn;
01444
01445         //
01446         // Allocate and zero a new buffer.
01447         //
01448
01449         pbNewProplist = new BYTE[ cbTotal ];
01450         if ( pbNewProplist != NULL )
01451         {
01452             ZeroMemory( pbNewProplist, cbTotal );
01453
01454             //
01455             // If there was a previous buffer, copy it and the delete it.
01456             //
01457
01458             if ( m_cbhPropList.pb != NULL )
01459             {
01460                 if ( m_cbDataSize != 0 )
01461                 {
01462                     CopyMemory( pbNewProplist, m_cbhPropList.pb, m_cbDataSize );
01463                 } // if: data already exists in buffer
01464
01465                 delete [] m_cbhPropList.pb;
01466                 m_cbhCurrentProp.pb = pbNewProplist + (m_cbhCurrentProp.pb - m_cbhPropList.pb);
01467             } // if: there was a previous buffer
01468             else
01469             {
01470                 m_cbhCurrentProp.pb = pbNewProplist + sizeof( DWORD ); // move past prop count
01471             } // else: no previous buffer
01472
01473             //
01474             // Save the new buffer.
01475             //
01476
01477             m_cbhPropList.pb = pbNewProplist;
01478             m_cbBufferSize = cbTotal;
01479         } // if: allocation succeeded
01480         else
01481         {
01482             sc = ERROR_NOT_ENOUGH_MEMORY;
01483         } // else: allocation failed
01484     } // if: buffer isn't big enough
01485
01486     return sc;
01487
01488 } //*** CClusPropList::ScAllocPropList
01489
01490 /////////////////////////////////////////////////////////////////////////////
01491 //++
01492 //
01493 //  CClusPropList::ScAddProp
01494 //
01495 //  Description:
01496 //      Add a string property to a property list if it has changed.
01497 //
01498 //  Arguments:
01499 //      pwszNameIn        Name of the property.
01500 //      pwszValueIn       Value of the property to set in the list.
01501 //      pwszPrevValueIn   Previous value of the property.
01502 //
01503 //  Return Value:
01504 //      ERROR_SUCCESS or other Win32 error code.
01505 //
01506 //--
01507 /////////////////////////////////////////////////////////////////////////////
01508 DWORD
01509 CClusPropList::ScAddProp(
01510       LPCWSTR   pwszNameIn
01511     , LPCWSTR   pwszValueIn
01512     , LPCWSTR   pwszPrevValueIn
01513     )
01514 {
01515     ASSERT( pwszNameIn != NULL );
01516
01517     DWORD                   sc = ERROR_SUCCESS;
01518     BOOL                    fValuesDifferent = TRUE;
01519     PCLUSPROP_PROPERTY_NAME pName = NULL;
01520     PCLUSPROP_SZ            pValue = NULL;
01521
01522     if ( ( pwszPrevValueIn != NULL ) && ( IStringCompareW( pwszValueIn, pwszPrevValueIn ) == 0 ) )
01523     {
01524         fValuesDifferent = FALSE;
01525     } // if: we have a prev value and the values are the same
01526
01527     //
01528     // If we should always add, or if the new value and the previous value
01529     // are not equal, add the property to the property list.
01530     //
01531
01532     if ( m_fAlwaysAddProp || fValuesDifferent )
01533     {
01534         size_t  cbNameSize;
01535         size_t  cbDataSize;
01536         size_t  cbValueSize = 0;
01537
01538         //
01539         // Calculate sizes and make sure we have a property list.
01540         //
01541
01542         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
01543                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
01544
01545         cbDataSize = (lstrlenW( pwszValueIn ) + 1) * sizeof( *pwszValueIn );
01546
01547         cbValueSize = sizeof( CLUSPROP_SZ )
01548                     + ALIGN_CLUSPROP( cbDataSize )
01549                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
01550
01551         sc = ScAllocPropList( cbNameSize + cbValueSize );
01552         if ( sc == ERROR_SUCCESS )
01553         {
01554             //
01555             // Set the property name.
01556             //
01557
01558             pName = m_cbhCurrentProp.pName;
01559             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
01560             m_cbhCurrentProp.pb += cbNameSize;
01561
01562             //
01563             // Set the property value.
01564             //
01565
01566             pValue = m_cbhCurrentProp.pStringValue;
01567             CopyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, pwszValueIn, cbDataSize );
01568             m_cbhCurrentProp.pb += cbValueSize;
01569
01570             //
01571             // Increment the property count and buffer size.
01572             //
01573
01574             m_cbhPropList.pList->nPropertyCount++;
01575             m_cbDataSize += cbNameSize + cbValueSize;
01576         } // if: ScAllocPropList successfully grew the proplist
01577
01578     } // if: the value has changed
01579
01580     return sc;
01581
01582 } //*** CClusPropList::ScAddProp( LPCWSTR )
01583
01584 /////////////////////////////////////////////////////////////////////////////
01585 //++
01586 //
01587 //  CClusPropList::ScAddMultiSzProp
01588 //
01589 //  Description:
01590 //      Add a string property to a property list if it has changed.
01591 //
01592 //  Arguments:
01593 //      pwszNameIn        Name of the property.
01594 //      pwszValueIn       Value of the property to set in the list.
01595 //      pwszPrevValueIn   Previous value of the property.
01596 //
01597 //  Return Value:
01598 //      ERROR_SUCCESS or other Win32 error code.
01599 //
01600 //--
01601 /////////////////////////////////////////////////////////////////////////////
01602 DWORD
01603 CClusPropList::ScAddMultiSzProp(
01604       LPCWSTR   pwszNameIn
01605     , LPCWSTR   pwszValueIn
01606     , LPCWSTR   pwszPrevValueIn
01607     )
01608 {
01609     ASSERT( pwszNameIn != NULL );
01610
01611     DWORD                   sc = ERROR_SUCCESS;
01612     BOOL                    fValuesDifferent = TRUE;
01613     PCLUSPROP_PROPERTY_NAME pName = NULL;
01614     PCLUSPROP_MULTI_SZ      pValue = NULL;
01615
01616     if ( ( pwszPrevValueIn != NULL ) && ( NCompareMultiSz( pwszValueIn, pwszPrevValueIn ) == 0 ) )
01617     {
01618         fValuesDifferent = FALSE;
01619     } // if: we have a prev value and the values are the same
01620
01621     //
01622     // If we should always add, or if the new value and the previous value
01623     // are not equal, add the property to the property list.
01624     //
01625
01626     if ( m_fAlwaysAddProp || fValuesDifferent )
01627     {
01628         size_t  cbNameSize;
01629         size_t  cbDataSize;
01630         size_t  cbValueSize;
01631
01632         //
01633         // Calculate sizes and make sure we have a property list.
01634         //
01635
01636         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
01637                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
01638
01639         cbDataSize = static_cast< DWORD >( (CchMultiSz( pwszValueIn ) + 1) * sizeof( *pwszValueIn ) );
01640
01641         cbValueSize = sizeof( CLUSPROP_SZ )
01642                     + ALIGN_CLUSPROP( cbDataSize )
01643                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
01644
01645         sc = ScAllocPropList( cbNameSize + cbValueSize );
01646         if ( sc == ERROR_SUCCESS )
01647         {
01648             //
01649             // Set the property name.
01650             //
01651
01652             pName = m_cbhCurrentProp.pName;
01653             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
01654             m_cbhCurrentProp.pb += cbNameSize;
01655
01656             //
01657             // Set the property value.
01658             //
01659
01660             pValue = m_cbhCurrentProp.pMultiSzValue;
01661             CopyMultiSzProp( pValue, CLUSPROP_TYPE_LIST_VALUE, pwszValueIn, cbDataSize );
01662             m_cbhCurrentProp.pb += cbValueSize;
01663
01664             //
01665             // Increment the property count and buffer size.
01666             //
01667
01668             m_cbhPropList.pList->nPropertyCount++;
01669             m_cbDataSize += cbNameSize + cbValueSize;
01670         } // if: ScAllocPropList successfully grew the proplist
01671     } // if: the value has changed
01672
01673     return sc;
01674
01675 } //*** CClusPropList::ScAddMultiSzProp( LPCWSTR )
01676
01677 /////////////////////////////////////////////////////////////////////////////
01678 //++
01679 //
01680 //  CClusPropList::ScAddExpandSzProp
01681 //
01682 //  Description:
01683 //      Add an EXPAND_SZ string property to a property list if it has changed.
01684 //
01685 //  Arguments:
01686 //      pwszNameIn        Name of the property.
01687 //      pwszValueIn       Value of the property to set in the list.
01688 //      pwszPrevValueIn   Previous value of the property.
01689 //
01690 //  Return Value:
01691 //      None.
01692 //
01693 //--
01694 /////////////////////////////////////////////////////////////////////////////
01695 DWORD
01696 CClusPropList::ScAddExpandSzProp(
01697       LPCWSTR   pwszNameIn
01698     , LPCWSTR   pwszValueIn
01699     , LPCWSTR   pwszPrevValueIn
01700     )
01701 {
01702     ASSERT( pwszNameIn != NULL );
01703
01704     DWORD                   sc = ERROR_SUCCESS;
01705     BOOL                    fValuesDifferent = TRUE;
01706     PCLUSPROP_PROPERTY_NAME pName = NULL;
01707     PCLUSPROP_SZ            pValue = NULL;
01708
01709     if ( ( pwszPrevValueIn != NULL ) && ( IStringCompareW( pwszValueIn, pwszPrevValueIn ) == 0 ) )
01710     {
01711         fValuesDifferent = FALSE;
01712     } // if: we have a prev value and the values are the same
01713
01714     //
01715     // If we should always add, or if the new value and the previous value
01716     // are not equal, add the property to the property list.
01717     //
01718
01719     if ( m_fAlwaysAddProp || fValuesDifferent )
01720     {
01721         size_t  cbNameSize = 0;
01722         size_t  cbDataSize = 0;
01723         size_t  cbValueSize = 0;
01724
01725         //
01726         // Calculate sizes and make sure we have a property list.
01727         //
01728
01729         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
01730                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
01731
01732         cbDataSize = (lstrlenW( pwszValueIn ) + 1) * sizeof( *pwszValueIn );
01733
01734         cbValueSize = sizeof( CLUSPROP_SZ )
01735                     + ALIGN_CLUSPROP( cbDataSize )
01736                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
01737
01738         sc = ScAllocPropList( cbNameSize + cbValueSize );
01739         if ( sc == ERROR_SUCCESS )
01740         {
01741             //
01742             // Set the property name.
01743             //
01744
01745             pName = m_cbhCurrentProp.pName;
01746             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
01747             m_cbhCurrentProp.pb += cbNameSize;
01748
01749             //
01750             // Set the property value.
01751             //
01752
01753             pValue = m_cbhCurrentProp.pStringValue;
01754             CopyExpandSzProp( pValue, CLUSPROP_TYPE_LIST_VALUE, pwszValueIn, cbDataSize );
01755             m_cbhCurrentProp.pb += cbValueSize;
01756
01757             //
01758             // Increment the property count and buffer size.
01759             //
01760
01761             m_cbhPropList.pList->nPropertyCount++;
01762             m_cbDataSize += cbNameSize + cbValueSize;
01763         } // if: ScAllocPropList successfully grew the proplist
01764     } // if: the value has changed
01765
01766     return sc;
01767
01768 } //*** CClusPropList::ScAddExpandSzProp( LPCWSTR )
01769
01770 /////////////////////////////////////////////////////////////////////////////
01771 //++
01772 //
01773 //  CClusPropList::ScAddProp
01774 //
01775 //  Description:
01776 //      Add a DWORD property to a property list if it has changed.
01777 //
01778 //  Arguments:
01779 //      pwszNameIn        Name of the property.
01780 //      nValueIn          Value of the property to set in the list.
01781 //      nPrevValueIn      Previous value of the property.
01782 //
01783 //  Return Value:
01784 //      None.
01785 //
01786 //--
01787 /////////////////////////////////////////////////////////////////////////////
01788 DWORD
01789 CClusPropList::ScAddProp(
01790       LPCWSTR   pwszNameIn
01791     , DWORD     nValueIn
01792     , DWORD     nPrevValueIn
01793     )
01794 {
01795     ASSERT( pwszNameIn != NULL );
01796
01797     DWORD                   sc = ERROR_SUCCESS;
01798     PCLUSPROP_PROPERTY_NAME pName = NULL;
01799     PCLUSPROP_DWORD         pValue = NULL;
01800
01801     if ( m_fAlwaysAddProp || ( nValueIn != nPrevValueIn ) )
01802     {
01803         size_t  cbNameSize = 0;
01804         size_t  cbValueSize = 0;
01805
01806         //
01807         // Calculate sizes and make sure we have a property list.
01808         //
01809
01810         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
01811                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
01812
01813         cbValueSize = sizeof( CLUSPROP_DWORD )
01814                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
01815
01816         sc = ScAllocPropList( cbNameSize + cbValueSize );
01817         if ( sc == ERROR_SUCCESS )
01818         {
01819             //
01820             // Set the property name.
01821             //
01822
01823             pName = m_cbhCurrentProp.pName;
01824             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
01825             m_cbhCurrentProp.pb += cbNameSize;
01826
01827             //
01828             // Set the property value.
01829             //
01830
01831             pValue = m_cbhCurrentProp.pDwordValue;
01832             CopyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, nValueIn );
01833             m_cbhCurrentProp.pb += cbValueSize;
01834
01835             //
01836             // Increment the property count and buffer size.
01837             //
01838
01839             m_cbhPropList.pList->nPropertyCount++;
01840             m_cbDataSize += cbNameSize + cbValueSize;
01841         } // if: ScAllocPropList successfully grew the proplist
01842     } // if: the value has changed
01843
01844     return sc;
01845
01846 } //*** CClusPropList::ScAddProp( DWORD )
01847
01848 /////////////////////////////////////////////////////////////////////////////
01849 //++
01850 //
01851 //  CClusPropList::ScAddProp
01852 //
01853 //  Description:
01854 //      Add a LONG property to a property list if it has changed.
01855 //
01856 //  Arguments:
01857 //      pwszNameIn        Name of the property.
01858 //      nValueIn          Value of the property to set in the list.
01859 //      nPrevValueIn      Previous value of the property.
01860 //
01861 //  Return Value:
01862 //      None.
01863 //
01864 //--
01865 /////////////////////////////////////////////////////////////////////////////
01866 DWORD CClusPropList::ScAddProp(
01867       LPCWSTR  pwszNameIn
01868     , LONG     nValueIn
01869     , LONG     nPrevValueIn
01870     )
01871 {
01872     ASSERT( pwszNameIn != NULL );
01873
01874     DWORD                   sc = ERROR_SUCCESS;
01875     PCLUSPROP_PROPERTY_NAME pName = NULL;
01876     PCLUSPROP_LONG          pValue = NULL;
01877
01878     if ( m_fAlwaysAddProp || ( nValueIn != nPrevValueIn ) )
01879     {
01880         size_t  cbNameSize = 0;
01881         size_t  cbValueSize = 0;
01882
01883         //
01884         // Calculate sizes and make sure we have a property list.
01885         //
01886
01887         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
01888                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
01889
01890         cbValueSize = sizeof( CLUSPROP_LONG )
01891                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
01892
01893         sc = ScAllocPropList( cbNameSize + cbValueSize );
01894         if ( sc == ERROR_SUCCESS )
01895         {
01896             //
01897             // Set the property name.
01898             //
01899
01900             pName = m_cbhCurrentProp.pName;
01901             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
01902             m_cbhCurrentProp.pb += cbNameSize;
01903
01904             //
01905             // Set the property value.
01906             //
01907
01908             pValue = m_cbhCurrentProp.pLongValue;
01909             CopyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, nValueIn );
01910             m_cbhCurrentProp.pb += cbValueSize;
01911
01912             //
01913             // Increment the property count and buffer size.
01914             //
01915
01916             m_cbhPropList.pList->nPropertyCount++;
01917             m_cbDataSize += cbNameSize + cbValueSize;
01918         } // if: ScAllocPropList successfully grew the proplist
01919     } // if: the value has changed
01920
01921     return sc;
01922
01923 } //*** CClusPropList::ScAddProp( LONG )
01924
01925 /////////////////////////////////////////////////////////////////////////////
01926 //++
01927 //
01928 //  CClusPropList::ScAddProp
01929 //
01930 //  Description:
01931 //      Add a binary property to a property list if it has changed.
01932 //
01933 //  Arguments:
01934 //      pwszNameIn        Name of the property.
01935 //      pbValueIn         Value of the property to set in the list.
01936 //      cbValueIn         Count of bytes in pbValueIn.
01937 //      pbPrevValueIn     Previous value of the property.
01938 //      cbPrevValueIn     Count of bytes in pbPrevValueIn.
01939 //
01940 //  Return Value:
01941 //      None.
01942 //
01943 //--
01944 /////////////////////////////////////////////////////////////////////////////
01945 DWORD
01946 CClusPropList::ScAddProp(
01947       LPCWSTR               pwszNameIn
01948     , const unsigned char * pbValueIn
01949     , size_t                cbValueIn
01950     , const unsigned char * pbPrevValueIn
01951     , size_t                cbPrevValueIn
01952     )
01953 {
01954     ASSERT( pwszNameIn != NULL );
01955
01956     DWORD                   sc = ERROR_SUCCESS;
01957     BOOL                    _fChanged = FALSE;
01958     PCLUSPROP_PROPERTY_NAME pName = NULL;
01959     PCLUSPROP_BINARY        pValue = NULL;
01960
01961     //
01962     // Determine if the buffer has changed.
01963     //
01964
01965     if ( m_fAlwaysAddProp || (cbValueIn != cbPrevValueIn) )
01966     {
01967         _fChanged = TRUE;
01968     } // if: always adding the property or the value size changed
01969     else if ( ( cbValueIn != 0 ) && ( cbPrevValueIn != 0 ) )
01970     {
01971         _fChanged = memcmp( pbValueIn, pbPrevValueIn, cbValueIn ) != 0;
01972     } // else if: value length changed
01973
01974     if ( _fChanged )
01975     {
01976         size_t  cbNameSize = 0;
01977         size_t  cbValueSize = 0;
01978
01979         //
01980         // Calculate sizes and make sure we have a property list.
01981         //
01982
01983         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
01984                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
01985
01986         cbValueSize = sizeof( CLUSPROP_BINARY )
01987                     + ALIGN_CLUSPROP( cbValueIn )
01988                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
01989
01990         sc = ScAllocPropList( cbNameSize + cbValueSize );
01991         if ( sc == ERROR_SUCCESS )
01992         {
01993             //
01994             // Set the property name.
01995             //
01996
01997             pName = m_cbhCurrentProp.pName;
01998             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
01999             m_cbhCurrentProp.pb += cbNameSize;
02000
02001             //
02002             // Set the property value.
02003             //
02004
02005             pValue = m_cbhCurrentProp.pBinaryValue;
02006             CopyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, pbValueIn, cbValueIn );
02007             m_cbhCurrentProp.pb += cbValueSize;
02008
02009             //
02010             // Increment the property count and buffer size.
02011             //
02012
02013             m_cbhPropList.pList->nPropertyCount++;
02014             m_cbDataSize += cbNameSize + cbValueSize;
02015         } // if: ScAllocPropList successfully grew the proplist
02016     } // if: the value has changed
02017
02018     return sc;
02019
02020 } //*** CClusPropList::ScAddProp( const unsigned char * )
02021
02022 /////////////////////////////////////////////////////////////////////////////
02023 //++
02024 //
02025 //  CClusPropList::ScAddProp
02026 //
02027 //  Routine Description:
02028 //      Add a ULONGLONG property to a property list if it has changed.
02029 //
02030 //  Arguments:
02031 //      pwszNameIn        Name of the property.
02032 //      ullValueIn        Value of the property to set in the list.
02033 //      ullPrevValueIn    Previous value of the property.
02034 //
02035 //  Return Value:
02036 //      ERROR_SUCCESS or other Win32 error codes.
02037 //
02038 //--
02039 /////////////////////////////////////////////////////////////////////////////
02040 DWORD
02041 CClusPropList::ScAddProp(
02042       LPCWSTR   pwszNameIn
02043     , ULONGLONG ullValueIn
02044     , ULONGLONG ullPrevValueIn
02045     )
02046 {
02047     ASSERT( pwszNameIn != NULL );
02048
02049     DWORD                       sc = ERROR_SUCCESS;
02050     PCLUSPROP_PROPERTY_NAME     pName = NULL;
02051     PCLUSPROP_ULARGE_INTEGER    pValue = NULL;
02052
02053     if ( m_fAlwaysAddProp || ( ullValueIn != ullPrevValueIn ) )
02054     {
02055         size_t  cbNameSize = 0;
02056         size_t  cbValueSize = 0;
02057
02058         //
02059         // Calculate sizes and make sure we have a property list.
02060         //
02061
02062         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
02063                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
02064
02065         cbValueSize = sizeof( CLUSPROP_ULARGE_INTEGER )
02066                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
02067
02068         sc = ScAllocPropList( cbNameSize + cbValueSize );
02069         if ( sc == ERROR_SUCCESS )
02070         {
02071             //
02072             // Set the property name.
02073             //
02074
02075             pName = m_cbhCurrentProp.pName;
02076             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
02077             m_cbhCurrentProp.pb += cbNameSize;
02078
02079             //
02080             // Set the property value.
02081             //
02082
02083             pValue = m_cbhCurrentProp.pULargeIntegerValue;
02084             CopyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, ullValueIn );
02085             m_cbhCurrentProp.pb += cbValueSize;
02086
02087             //
02088             // Increment the property count and buffer size.
02089             //
02090
02091             m_cbhPropList.pList->nPropertyCount++;
02092             m_cbDataSize += cbNameSize + cbValueSize;
02093         } // if: ScAllocPropList successfully grew the proplist
02094     } // if: the value has changed
02095
02096     return sc;
02097
02098 } //*** CClusPropList::ScAddProp( ULONGLONG )
02099
02100 /////////////////////////////////////////////////////////////////////////////
02101 //++
02102 //
02103 //  CClusPropList::ScAddProp
02104 //
02105 //  Routine Description:
02106 //      Add a LONGLONG property to a property list if it has changed.
02107 //
02108 //  Arguments:
02109 //      pwszNameIn        Name of the property.
02110 //      llValueIn         Value of the property to set in the list.
02111 //      llPrevValueIn     Previous value of the property.
02112 //
02113 //  Return Value:
02114 //      ERROR_SUCCESS or other Win32 status codes.
02115 //
02116 //--
02117 /////////////////////////////////////////////////////////////////////////////
02118 DWORD
02119 CClusPropList::ScAddProp(
02120       LPCWSTR      pwszNameIn
02121     , LONGLONG     llValueIn
02122     , LONGLONG     llPrevValueIn
02123     )
02124 {
02125     ASSERT( pwszNameIn != NULL );
02126
02127     DWORD                       sc = ERROR_SUCCESS;
02128     PCLUSPROP_PROPERTY_NAME     pName = NULL;
02129     PCLUSPROP_LARGE_INTEGER     pValue = NULL;
02130
02131     if ( m_fAlwaysAddProp || ( llValueIn != llPrevValueIn ) )
02132     {
02133         size_t  cbNameSize = 0;
02134         size_t  cbValueSize = 0;
02135
02136         //
02137         // Calculate sizes and make sure we have a property list.
02138         //
02139
02140         cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
02141                     + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
02142
02143         cbValueSize = sizeof( CLUSPROP_LARGE_INTEGER )
02144                     + sizeof( CLUSPROP_SYNTAX ); // value list endmark
02145
02146         sc = ScAllocPropList( cbNameSize + cbValueSize );
02147         if ( sc == ERROR_SUCCESS )
02148         {
02149             //
02150             // Set the property name.
02151             //
02152
02153             pName = m_cbhCurrentProp.pName;
02154             CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
02155             m_cbhCurrentProp.pb += cbNameSize;
02156
02157             //
02158             // Set the property value.
02159             //
02160
02161             pValue = m_cbhCurrentProp.pLargeIntegerValue;
02162             CopyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, llValueIn );
02163             m_cbhCurrentProp.pb += cbValueSize;
02164
02165             //
02166             // Increment the property count and buffer size.
02167             //
02168
02169             m_cbhPropList.pList->nPropertyCount++;
02170             m_cbDataSize += cbNameSize + cbValueSize;
02171         } // if: ScAllocPropList successfully grew the proplist
02172     } // if: the value has changed
02173
02174     return sc;
02175
02176 } //*** CClusPropList::ScAddProp( LONGLONG )
02177
02178 /////////////////////////////////////////////////////////////////////////////
02179 //++
02180 //
02181 //  CClusPropList::ScSetPropToDefault
02182 //
02183 //  Description:
02184 //      Add a property to the property list so that it will revert to its
02185 //      default value.
02186 //
02187 //  Arguments:
02188 //      pwszNameIn          Name of the property.
02189 //      cpfPropFormatIn     Format of property
02190 //
02191 //  Return Value:
02192 //      ERROR_SUCCESS or other Win32 status codes.
02193 //
02194 //--
02195 /////////////////////////////////////////////////////////////////////////////
02196 DWORD
02197 CClusPropList::ScSetPropToDefault(
02198       LPCWSTR                   pwszNameIn
02199     , CLUSTER_PROPERTY_FORMAT   cpfPropFormatIn
02200     )
02201 {
02202     ASSERT( pwszNameIn != NULL );
02203
02204     DWORD                   sc = ERROR_SUCCESS;
02205     size_t                  cbNameSize = 0;
02206     size_t                  cbValueSize = 0;
02207     PCLUSPROP_PROPERTY_NAME pName = NULL;
02208     PCLUSPROP_VALUE         pValue = NULL;
02209
02210     //
02211     //  Calculate sizes and make sure we have a property list.
02212     //
02213
02214     cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
02215                 + ALIGN_CLUSPROP( (lstrlenW( pwszNameIn ) + 1) * sizeof( *pwszNameIn ) );
02216
02217     cbValueSize = sizeof( CLUSPROP_BINARY )
02218                 + sizeof( CLUSPROP_SYNTAX ); // value list endmark
02219
02220     sc = ScAllocPropList( cbNameSize + cbValueSize );
02221     if ( sc == ERROR_SUCCESS )
02222     {
02223         //
02224         // Set the property name.
02225         //
02226
02227         pName = m_cbhCurrentProp.pName;
02228         CopyProp( pName, CLUSPROP_TYPE_NAME, pwszNameIn );
02229         m_cbhCurrentProp.pb += cbNameSize;
02230
02231         //
02232         // Set the property value.
02233         //
02234
02235         pValue = m_cbhCurrentProp.pValue;
02236         CopyEmptyProp( pValue, CLUSPROP_TYPE_LIST_VALUE, cpfPropFormatIn );
02237         m_cbhCurrentProp.pb += cbValueSize;
02238
02239         //
02240         // Increment the property count and buffer size.
02241         //
02242
02243         m_cbhPropList.pList->nPropertyCount++;
02244         m_cbDataSize += cbNameSize + cbValueSize;
02245     } // if:
02246
02247     return sc;
02248
02249 } //*** CClusPropList::ScSetPropToDefault
02250
02251 /////////////////////////////////////////////////////////////////////////////
02252 //++
02253 //
02254 //  CClusPropList::CopyProp
02255 //
02256 //  Description:
02257 //      Copy a string property to a property structure.
02258 //
02259 //  Arguments:
02260 //      ppropOut      Property structure to fill.
02261 //      cptPropTypeIn Type of string.
02262 //      pszIn         String to copy.
02263 //      cbSzIn        Count of bytes in pwsz string.  If specified as 0,
02264 //                    the the length will be determined by a call to strlen.
02265 //
02266 //  Return Value:
02267 //      None.
02268 //
02269 //--
02270 /////////////////////////////////////////////////////////////////////////////
02271 void
02272 CClusPropList::CopyProp(
02273       PCLUSPROP_SZ          ppropOut
02274     , CLUSTER_PROPERTY_TYPE cptPropTypeIn
02275     , LPCWSTR               pszIn
02276     , size_t                cbSzIn        // = 0
02277     )
02278 {
02279     ASSERT( ppropOut != NULL );
02280     ASSERT( pszIn != NULL );
02281
02282     CLUSPROP_BUFFER_HELPER  cbhProps;
02283     HRESULT                 hr = S_OK;
02284
02285     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_SZ;
02286     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02287
02288     if ( cbSzIn == 0 )
02289     {
02290         cbSzIn = (lstrlenW( pszIn ) + 1) * sizeof( *pszIn );
02291     } // if: zero size specified
02292
02293     ASSERT( cbSzIn == (lstrlenW( pszIn ) + 1) * sizeof( *pszIn ) );
02294
02295     ppropOut->cbLength = static_cast< DWORD >( cbSzIn );
02296
02297     hr = StringCbCopyW( ppropOut->sz, cbSzIn, pszIn );
02298     if ( SUCCEEDED( hr ) )
02299     {
02300         //
02301         // Set an endmark.
02302         //
02303
02304         cbhProps.pStringValue = ppropOut;
02305         cbhProps.pb += sizeof( *cbhProps.pStringValue ) + ALIGN_CLUSPROP( cbSzIn );
02306         cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02307     } // if:
02308
02309 } //*** CClusPropList::CopyProp
02310
02311 /////////////////////////////////////////////////////////////////////////////
02312 //++
02313 //
02314 //  CClusPropList::CopyMultiSzProp
02315 //
02316 //  Description:
02317 //      Copy a MULTI_SZ string property to a property structure.
02318 //
02319 //  Arguments:
02320 //      ppropOut      Property structure to fill.
02321 //      cptPropTypeIn Type of string.
02322 //      pszIn         String to copy.
02323 //      cbSzIn        Count of bytes in pszIn string.  If specified as 0,
02324 //                    the the length will be determined by calls to strlen.
02325 //
02326 //  Return Value:
02327 //      None.
02328 //
02329 //--
02330 /////////////////////////////////////////////////////////////////////////////
02331 void
02332 CClusPropList::CopyMultiSzProp(
02333       PCLUSPROP_MULTI_SZ    ppropOut
02334     , CLUSTER_PROPERTY_TYPE cptPropTypeIn
02335     , LPCWSTR               pszIn
02336     , size_t                cbSzIn
02337     )
02338 {
02339     ASSERT( ppropOut != NULL );
02340     ASSERT( pszIn != NULL );
02341
02342     CLUSPROP_BUFFER_HELPER  cbhProps;
02343
02344     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_MULTI_SZ;
02345     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02346
02347     if ( cbSzIn == 0 )
02348     {
02349         cbSzIn = (CchMultiSz( pszIn ) + 1) * sizeof( *pszIn );
02350     } // if: zero size specified
02351
02352     ASSERT( cbSzIn == (CchMultiSz( pszIn ) + 1) * sizeof( *pszIn ) );
02353
02354     ppropOut->cbLength = static_cast< DWORD >( cbSzIn );
02355     CopyMemory( ppropOut->sz, pszIn, cbSzIn );
02356
02357     //
02358     // Set an endmark.
02359     //
02360
02361     cbhProps.pMultiSzValue = ppropOut;
02362     cbhProps.pb += sizeof( *cbhProps.pMultiSzValue ) + ALIGN_CLUSPROP( cbSzIn );
02363     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02364
02365 } //*** CClusPropList::CopyMultiSzProp
02366
02367 /////////////////////////////////////////////////////////////////////////////
02368 //++
02369 //
02370 //  CClusPropList::CopyExpandSzProp
02371 //
02372 //  Description:
02373 //      Copy an EXPAND_SZ string property to a property structure.
02374 //
02375 //  Arguments:
02376 //      ppropOut      Property structure to fill.
02377 //      cptPropTypeIn Type of string.
02378 //      pszIn         String to copy.
02379 //      cbSzIn        Count of bytes in pszIn string.
02380 //
02381 //  Return Value:
02382 //      None.
02383 //
02384 //--
02385 /////////////////////////////////////////////////////////////////////////////
02386 void
02387 CClusPropList::CopyExpandSzProp(
02388       PCLUSPROP_SZ          ppropOut
02389     , CLUSTER_PROPERTY_TYPE cptPropTypeIn
02390     , LPCWSTR               pszIn
02391     , size_t                cbSzIn
02392     )
02393 {
02394     ASSERT( ppropOut != NULL );
02395     ASSERT( pszIn != NULL );
02396
02397     CLUSPROP_BUFFER_HELPER  cbhProps;
02398     HRESULT                 hr = S_OK;
02399
02400     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_EXPAND_SZ;
02401     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02402
02403     if ( cbSzIn == 0 )
02404     {
02405         cbSzIn = (lstrlenW( pszIn ) + 1) * sizeof( *pszIn );
02406     } // if: cbSzIn == 0
02407
02408     ASSERT( cbSzIn == (lstrlenW( pszIn ) + 1) * sizeof( *pszIn ) );
02409
02410     ppropOut->cbLength = static_cast< DWORD >( cbSzIn );
02411
02412     hr = StringCbCopyW( ppropOut->sz, cbSzIn, pszIn );
02413     if ( SUCCEEDED( hr ) )
02414     {
02415         //
02416         // Set an endmark.
02417         //
02418
02419         cbhProps.pStringValue = ppropOut;
02420         cbhProps.pb += sizeof( *cbhProps.pStringValue ) + ALIGN_CLUSPROP( cbSzIn );
02421         cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02422     } // if:
02423
02424 } //*** CClusPropList::CopyExpandSzProp
02425
02426 /////////////////////////////////////////////////////////////////////////////
02427 //++
02428 //
02429 //  CClusPropList::CopyProp
02430 //
02431 //  Description:
02432 //      Copy a DWORD property to a property structure.
02433 //
02434 //  Arguments:
02435 //      ppropOut      Property structure to fill.
02436 //      cptPropTypeIn Type of DWORD.
02437 //      nValueIn      Property value to copy.
02438 //
02439 //  Return Value:
02440 //      None.
02441 //
02442 //--
02443 /////////////////////////////////////////////////////////////////////////////
02444 void
02445 CClusPropList::CopyProp(
02446       PCLUSPROP_DWORD       ppropOut
02447     , CLUSTER_PROPERTY_TYPE cptPropTypeIn
02448     , DWORD                 nValueIn
02449     )
02450 {
02451     ASSERT( ppropOut != NULL );
02452
02453     CLUSPROP_BUFFER_HELPER  cbhProps;
02454
02455     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_DWORD;
02456     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02457     ppropOut->cbLength = sizeof( DWORD );
02458     ppropOut->dw = nValueIn;
02459
02460     //
02461     // Set an endmark.
02462     //
02463
02464     cbhProps.pDwordValue = ppropOut;
02465     cbhProps.pb += sizeof( *cbhProps.pDwordValue );
02466     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02467
02468 } //*** CClusPropList::CopyProp( DWORD )
02469
02470 /////////////////////////////////////////////////////////////////////////////
02471 //++
02472 //
02473 //  CClusPropList::CopyProp
02474 //
02475 //  Description:
02476 //      Copy a LONG property to a property structure.
02477 //
02478 //  Arguments:
02479 //      ppropOut      Property structure to fill.
02480 //      cptPropTypeIn Type of LONG.
02481 //      nValueIn      Property value to copy.
02482 //
02483 //  Return Value:
02484 //      None.
02485 //
02486 //--
02487 /////////////////////////////////////////////////////////////////////////////
02488 void
02489 CClusPropList::CopyProp(
02490       PCLUSPROP_LONG        ppropOut
02491     , CLUSTER_PROPERTY_TYPE cptPropTypeIn
02492     , LONG                  nValueIn
02493     )
02494 {
02495     ASSERT( ppropOut != NULL );
02496
02497     CLUSPROP_BUFFER_HELPER  cbhProps;
02498
02499     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_LONG;
02500     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02501     ppropOut->cbLength = sizeof( DWORD );
02502     ppropOut->l = nValueIn;
02503
02504     //
02505     // Set an endmark.
02506     //
02507
02508     cbhProps.pLongValue = ppropOut;
02509     cbhProps.pb += sizeof( *cbhProps.pLongValue );
02510     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02511
02512 } //*** CClusPropList::CopyProp( LONG )
02513
02514 /////////////////////////////////////////////////////////////////////////////
02515 //++
02516 //
02517 //  CClusPropList::CopyProp
02518 //
02519 //  Description:
02520 //      Copy a ULONGLONG property to a property structure.
02521 //
02522 //  Arguments:
02523 //      ppropOut        Property structure to fill.
02524 //      cptPropTypeIn   Type of LONG.
02525 //      ullValueIn      Property value to copy.
02526 //
02527 //  Return Value:
02528 //      None.
02529 //
02530 //--
02531 /////////////////////////////////////////////////////////////////////////////
02532 void
02533 CClusPropList::CopyProp(
02534       PCLUSPROP_ULARGE_INTEGER  ppropOut
02535     , CLUSTER_PROPERTY_TYPE     cptPropTypeIn
02536     , ULONGLONG                 ullValueIn
02537     )
02538 {
02539     ASSERT( ppropOut != NULL );
02540
02541     CLUSPROP_BUFFER_HELPER  cbhProps;
02542
02543     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_ULARGE_INTEGER;
02544     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02545     ppropOut->cbLength = sizeof( ULONGLONG );
02546
02547     //
02548     // ppropOut may not have the correct alignment for large ints; copy as two
02549     // DWORDs to be safe
02550     //
02551
02552     ppropOut->li.u = ((ULARGE_INTEGER *)&ullValueIn)->u;
02553
02554     //
02555     // Set an endmark.
02556     //
02557
02558     cbhProps.pULargeIntegerValue = ppropOut;
02559     cbhProps.pb += sizeof( *cbhProps.pULargeIntegerValue );
02560     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02561
02562 } //*** CClusPropList::CopyProp( ULONGLONG )
02563
02564 /////////////////////////////////////////////////////////////////////////////
02565 //++
02566 //
02567 //  CClusPropList::CopyProp
02568 //
02569 //  Description:
02570 //      Copy a LONGLONG property to a property structure.
02571 //
02572 //  Arguments:
02573 //      ppropOut        Property structure to fill.
02574 //      cptPropTypeIn   Type of LONG.
02575 //      llValueIn       Property value to copy.
02576 //
02577 //  Return Value:
02578 //      None.
02579 //
02580 //--
02581 /////////////////////////////////////////////////////////////////////////////
02582 void
02583 CClusPropList::CopyProp(
02584       PCLUSPROP_LARGE_INTEGER   ppropOut
02585     , CLUSTER_PROPERTY_TYPE     cptPropTypeIn
02586     , LONGLONG                  llValueIn
02587     )
02588 {
02589     ASSERT( ppropOut != NULL );
02590
02591     CLUSPROP_BUFFER_HELPER  cbhProps;
02592
02593     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_LARGE_INTEGER;
02594     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02595     ppropOut->cbLength = sizeof( LONGLONG );
02596
02597     //
02598     // ppropOut may not have the correct alignment for large ints; copy as two
02599     // DWORDs to be safe
02600     //
02601
02602     ppropOut->li.u = ((LARGE_INTEGER *)&llValueIn)->u;
02603
02604     //
02605     // Set an endmark.
02606     //
02607
02608     cbhProps.pLargeIntegerValue = ppropOut;
02609     cbhProps.pb += sizeof( *cbhProps.pLargeIntegerValue );
02610     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02611
02612 } //*** CClusPropList::CopyProp( LONGLONG )
02613
02614 /////////////////////////////////////////////////////////////////////////////
02615 //++
02616 //
02617 //  CClusPropList::CopyProp
02618 //
02619 //  Description:
02620 //      Copy a binary property to a property structure.
02621 //
02622 //  Arguments:
02623 //      ppropOut        Property structure to fill.
02624 //      cptPropTypeIn   Type of string.
02625 //      pbValueIn       Block to copy.
02626 //      cbValueIn       Count of bytes in pb buffer.
02627 //
02628 //  Return Value:
02629 //      None.
02630 //
02631 //--
02632 /////////////////////////////////////////////////////////////////////////////
02633 void
02634 CClusPropList::CopyProp(
02635       PCLUSPROP_BINARY      ppropOut
02636     , CLUSTER_PROPERTY_TYPE cptPropTypeIn
02637     , const unsigned char * pbValueIn
02638     , size_t                cbValueIn
02639     )
02640 {
02641     ASSERT( ppropOut != NULL );
02642
02643     CLUSPROP_BUFFER_HELPER  cbhProps;
02644
02645     ppropOut->Syntax.wFormat = CLUSPROP_FORMAT_BINARY;
02646     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02647     ppropOut->cbLength = static_cast< DWORD >( cbValueIn );
02648
02649     if ( cbValueIn > 0 )
02650     {
02651         CopyMemory( ppropOut->rgb, pbValueIn, cbValueIn );
02652     } // if: non-zero data length
02653
02654     //
02655     // Set an endmark.
02656     //
02657
02658     cbhProps.pBinaryValue = ppropOut;
02659     cbhProps.pb += sizeof( *cbhProps.pStringValue ) + ALIGN_CLUSPROP( cbValueIn );
02660     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02661
02662 } //*** CClusPropList::CopyProp( PBYTE )
02663
02664 /////////////////////////////////////////////////////////////////////////////
02665 //++
02666 //
02667 //  CClusPropList::CopyEmptyProp
02668 //
02669 //  Description:
02670 //      Copy an empty property to a property structure.
02671 //
02672 //  Arguments:
02673 //      ppropOut            Property structure to fill.
02674 //      cptPropTypeIn       Type of property.
02675 //      cpfPropFormatIn     Format of property.
02676 //
02677 //  Return Value:
02678 //      None.
02679 //
02680 //--
02681 /////////////////////////////////////////////////////////////////////////////
02682 void
02683 CClusPropList::CopyEmptyProp(
02684       PCLUSPROP_VALUE           ppropOut
02685     , CLUSTER_PROPERTY_TYPE     cptPropTypeIn
02686     , CLUSTER_PROPERTY_FORMAT   cptPropFmt
02687     )
02688 {
02689     ASSERT( ppropOut != NULL );
02690
02691     CLUSPROP_BUFFER_HELPER  cbhProps;
02692
02693     ppropOut->Syntax.wFormat = static_cast< WORD >( cptPropFmt );
02694     ppropOut->Syntax.wType = static_cast< WORD >( cptPropTypeIn );
02695     ppropOut->cbLength = 0;
02696
02697     //
02698     // Set an endmark.
02699     //
02700
02701     cbhProps.pValue = ppropOut;
02702     cbhProps.pb += sizeof( *cbhProps.pValue );
02703     cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
02704
02705 } //*** CClusPropList::CopyEmptyProp
02706
02707 /////////////////////////////////////////////////////////////////////////////
02708 //++
02709 //
02710 //  CClusPropList::ScGetNodeProperties
02711 //
02712 //  Description:
02713 //      Get properties on a node.
02714 //
02715 //  Arguments:
02716 //      hNodeIn           Handle for the node to get properties from.
02717 //      dwControlCodeIn   Control code for the request.
02718 //      hHostNodeIn       Handle for the node to direct this request to.
02719 //                        Defaults to NULL.
02720 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
02721 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
02722 //
02723 //  Return Value:
02724 //      None.
02725 //
02726 //--
02727 /////////////////////////////////////////////////////////////////////////////
02728 DWORD
02729 CClusPropList::ScGetNodeProperties(
02730       HNODE     hNodeIn
02731     , DWORD     dwControlCodeIn
02732     , HNODE     hHostNodeIn
02733     , LPVOID    lpBufferIn              // = NULL
02734     , size_t    cbBufferIn              // = 0
02735     )
02736 {
02737     ASSERT( hNodeIn != NULL );
02738     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
02739             == ( CLUS_OBJECT_NODE << CLUSCTL_OBJECT_SHIFT ) );
02740
02741     DWORD   sc = ERROR_SUCCESS;
02742     DWORD   cbProps = 256;
02743
02744     //
02745     // Overwrite anything that may be in the buffer.
02746     // Allows this class instance to be reused.
02747     //
02748
02749     m_cbDataSize = 0;
02750
02751     //
02752     // Get properties.
02753     //
02754
02755     sc = ScAllocPropList( cbProps );
02756     if ( sc == ERROR_SUCCESS )
02757     {
02758         sc = ClusterNodeControl(
02759                           hNodeIn
02760                         , hHostNodeIn
02761                         , dwControlCodeIn
02762                         , lpBufferIn
02763                         , static_cast< DWORD >( cbBufferIn )
02764                         , m_cbhPropList.pb
02765                         , static_cast< DWORD >( m_cbBufferSize )
02766                         , &cbProps
02767                         );
02768         if ( sc == ERROR_MORE_DATA )
02769         {
02770             sc = ScAllocPropList( cbProps );
02771             if ( sc == ERROR_SUCCESS )
02772             {
02773                 sc = ClusterNodeControl(
02774                                   hNodeIn
02775                                 , hHostNodeIn
02776                                 , dwControlCodeIn
02777                                 , lpBufferIn
02778                                 , static_cast< DWORD >( cbBufferIn )
02779                                 , m_cbhPropList.pb
02780                                 , static_cast< DWORD >( m_cbBufferSize )
02781                                 , &cbProps
02782                                 );
02783             } // if: ScAllocPropList succeeded
02784         } // if: buffer too small
02785     } // if: ScAllocPropList succeeded
02786
02787     if ( sc != ERROR_SUCCESS )
02788     {
02789         DeletePropList();
02790     } // if: error getting properties.
02791     else
02792     {
02793         m_cbDataSize = static_cast< size_t >( cbProps );
02794         m_cbDataLeft = static_cast< size_t >( cbProps );
02795     } // else: no errors
02796
02797     return sc;
02798
02799 } //*** CClusPropList::ScGetNodeProperties
02800
02801 /////////////////////////////////////////////////////////////////////////////
02802 //++
02803 //
02804 //  CClusPropList::ScGetGroupProperties
02805 //
02806 //  Description:
02807 //      Get properties on a group.
02808 //
02809 //  Arguments:
02810 //      hGroupIn          Handle for the group to get properties from.
02811 //      dwControlCodeIn   Control code for the request.
02812 //      hHostNodeIn       Handle for the node to direct this request to.
02813 //                        Defaults to NULL.
02814 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
02815 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
02816 //
02817 //  Return Value:
02818 //      None.
02819 //
02820 //--
02821 /////////////////////////////////////////////////////////////////////////////
02822 DWORD
02823 CClusPropList::ScGetGroupProperties(
02824       HGROUP    hGroupIn
02825     , DWORD     dwControlCodeIn
02826     , HNODE     hHostNodeIn
02827     , LPVOID    lpBufferIn          // = NULL
02828     , size_t    cbBufferIn          // = 0
02829     )
02830 {
02831     ASSERT( hGroupIn != NULL );
02832     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
02833             == ( CLUS_OBJECT_GROUP << CLUSCTL_OBJECT_SHIFT ) );
02834
02835     DWORD   sc = ERROR_SUCCESS;
02836     DWORD   cbProps = 256;
02837
02838     //
02839     // Overwrite anything that may be in the buffer.
02840     // Allows this class instance to be reused.
02841     //
02842
02843     m_cbDataSize = 0;
02844
02845     //
02846     // Get properties.
02847     //
02848
02849     sc = ScAllocPropList( cbProps );
02850     if ( sc == ERROR_SUCCESS )
02851     {
02852         sc = ClusterGroupControl(
02853                           hGroupIn
02854                         , hHostNodeIn
02855                         , dwControlCodeIn
02856                         , lpBufferIn
02857                         , static_cast< DWORD >( cbBufferIn )
02858                         , m_cbhPropList.pb
02859                         , static_cast< DWORD >( m_cbBufferSize )
02860                         , &cbProps
02861                         );
02862         if ( sc == ERROR_MORE_DATA )
02863         {
02864             sc = ScAllocPropList( cbProps );
02865             if ( sc == ERROR_SUCCESS )
02866             {
02867                 sc = ClusterGroupControl(
02868                                   hGroupIn
02869                                 , hHostNodeIn
02870                                 , dwControlCodeIn
02871                                 , lpBufferIn
02872                                 , static_cast< DWORD >( cbBufferIn )
02873                                 , m_cbhPropList.pb
02874                                 , static_cast< DWORD >( m_cbBufferSize )
02875                                 , &cbProps
02876                                 );
02877             } // if: ScAllocPropList succeeded
02878         } // if: buffer too small
02879     } // if: ScAllocPropList succeeded
02880
02881     if ( sc != ERROR_SUCCESS )
02882     {
02883         DeletePropList();
02884     } // if: error getting properties.
02885     else
02886     {
02887         m_cbDataSize = static_cast< size_t >( cbProps );
02888         m_cbDataLeft = static_cast< size_t >( cbProps );
02889     } // else: no errors
02890
02891     return sc;
02892
02893 } //*** CClusPropList::ScGetGroupProperties
02894
02895 /////////////////////////////////////////////////////////////////////////////
02896 //++
02897 //
02898 //  CClusPropList::ScGetResourceProperties
02899 //
02900 //  Description:
02901 //      Get properties on a resource.
02902 //
02903 //  Arguments:
02904 //      hResourceIn       Handle for the resource to get properties from.
02905 //      dwControlCodeIn   Control code for the request.
02906 //      hHostNodeIn       Handle for the node to direct this request to.
02907 //                        Defaults to NULL.
02908 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
02909 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
02910 //
02911 //  Return Value:
02912 //      None.
02913 //
02914 //--
02915 /////////////////////////////////////////////////////////////////////////////
02916 DWORD
02917 CClusPropList::ScGetResourceProperties(
02918       HRESOURCE hResourceIn
02919     , DWORD     dwControlCodeIn
02920     , HNODE     hHostNodeIn
02921     , LPVOID    lpBufferIn          // = NULL
02922     , size_t    cbBufferIn          // = 0
02923     )
02924 {
02925     ASSERT( hResourceIn != NULL );
02926     ASSERT( ( dwControlCodeIn & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
02927             == ( CLUS_OBJECT_RESOURCE << CLUSCTL_OBJECT_SHIFT ) );
02928
02929     DWORD   sc = ERROR_SUCCESS;
02930     DWORD   cbProps = 256;
02931
02932     //
02933     // Overwrite anything that may be in the buffer.
02934     // Allows this class instance to be reused.
02935     //
02936
02937     m_cbDataSize = 0;
02938
02939     //
02940     // Get properties.
02941     //
02942
02943     sc = ScAllocPropList( cbProps );
02944     if ( sc == ERROR_SUCCESS )
02945     {
02946         sc = ClusterResourceControl(
02947                           hResourceIn
02948                         , hHostNodeIn
02949                         , dwControlCodeIn
02950                         , lpBufferIn
02951                         , static_cast< DWORD >( cbBufferIn )
02952                         , m_cbhPropList.pb
02953                         , static_cast< DWORD >( m_cbBufferSize )
02954                         , &cbProps
02955                         );
02956         if ( sc == ERROR_MORE_DATA )
02957         {
02958             sc = ScAllocPropList( cbProps );
02959             if ( sc == ERROR_SUCCESS )
02960             {
02961                 sc = ClusterResourceControl(
02962                                   hResourceIn
02963                                 , hHostNodeIn
02964                                 , dwControlCodeIn
02965                                 , lpBufferIn
02966                                 , static_cast< DWORD >( cbBufferIn )
02967                                 , m_cbhPropList.pb
02968                                 , static_cast< DWORD >( m_cbBufferSize )
02969                                 , &cbProps
02970                                 );
02971             } // if: ScAllocPropList succeeded
02972         } // if: buffer too small
02973     } // if: ScAllocPropList succeeded
02974
02975     if ( sc != ERROR_SUCCESS )
02976     {
02977         DeletePropList();
02978     } // if: error getting properties.
02979     else
02980     {
02981         m_cbDataSize = static_cast< size_t >( cbProps );
02982         m_cbDataLeft = static_cast< size_t >( cbProps );
02983     } // else: no errors
02984
02985     return sc;
02986
02987 } //*** CClusPropList::ScGetResourceProperties
02988
02989 /////////////////////////////////////////////////////////////////////////////
02990 //++
02991 //
02992 //  CClusPropList::ScGetResourceTypeProperties
02993 //
02994 //  Description:
02995 //      Get properties on a resource type.
02996 //
02997 //  Arguments:
02998 //      hClusterIn        Handle for the cluster in which the resource
02999 //                        type resides.
03000 //      pwszResTypeNameIn Name of the resource type.
03001 //      dwControlCodeIn   Control code for the request.
03002 //      hHostNodeIn       Handle for the node to direct this request to.
03003 //                        Defaults to NULL.
03004 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
03005 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
03006 //
03007 //  Return Value:
03008 //      None.
03009 //
03010 //--
03011 /////////////////////////////////////////////////////////////////////////////
03012 DWORD
03013 CClusPropList::ScGetResourceTypeProperties(
03014       HCLUSTER  hClusterIn
03015     , LPCWSTR   pwszResTypeNameIn
03016     , DWORD     dwControlCodeIn
03017     , HNODE     hHostNodeIn
03018     , LPVOID    lpBufferIn          // = NULL
03019     , size_t    cbBufferIn          // = 0
03020     )
03021 {
03022     ASSERT( hClusterIn != NULL );
03023     ASSERT( pwszResTypeNameIn != NULL );
03024     ASSERT( *pwszResTypeNameIn != L'\0' );
03025     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
03026             == ( CLUS_OBJECT_RESOURCE_TYPE << CLUSCTL_OBJECT_SHIFT ) );
03027
03028     DWORD   sc = ERROR_SUCCESS;
03029     DWORD   cbProps = 256;
03030
03031     //
03032     // Overwrite anything that may be in the buffer.
03033     // Allows this class instance to be reused.
03034     //
03035
03036     m_cbDataSize = 0;
03037
03038     //
03039     // Get properties.
03040     //
03041
03042     sc = ScAllocPropList( cbProps );
03043     if ( sc == ERROR_SUCCESS )
03044     {
03045         sc = ClusterResourceTypeControl(
03046                           hClusterIn
03047                         , pwszResTypeNameIn
03048                         , hHostNodeIn
03049                         , dwControlCodeIn
03050                         , lpBufferIn
03051                         , static_cast< DWORD >( cbBufferIn )
03052                         , m_cbhPropList.pb
03053                         , static_cast< DWORD >( m_cbBufferSize )
03054                         , &cbProps
03055                         );
03056         if ( sc == ERROR_MORE_DATA )
03057         {
03058             sc = ScAllocPropList( cbProps );
03059             if ( sc == ERROR_SUCCESS )
03060             {
03061                 sc = ClusterResourceTypeControl(
03062                                   hClusterIn
03063                                 , pwszResTypeNameIn
03064                                 , hHostNodeIn
03065                                 , dwControlCodeIn
03066                                 , lpBufferIn
03067                                 , static_cast< DWORD >( cbBufferIn )
03068                                 , m_cbhPropList.pb
03069                                 , static_cast< DWORD >( m_cbBufferSize )
03070                                 , &cbProps
03071                                 );
03072             } // if: ScAllocPropList succeeded
03073         } // if: buffer too small
03074     } // if: ScAllocPropList succeeded
03075
03076     if ( sc != ERROR_SUCCESS )
03077     {
03078         DeletePropList();
03079     } // if: error getting properties.
03080     else
03081     {
03082         m_cbDataSize = static_cast< size_t >( cbProps );
03083         m_cbDataLeft = static_cast< size_t >( cbProps );
03084     } // else: no errors
03085
03086     return sc;
03087
03088 } //*** CClusPropList::ScGetResourceTypeProperties
03089
03090 /////////////////////////////////////////////////////////////////////////////
03091 //++
03092 //
03093 //  CClusPropList::ScGetNetworkProperties
03094 //
03095 //  Description:
03096 //      Get properties on a network.
03097 //
03098 //  Arguments:
03099 //      hNetworkIn        Handle for the network to get properties from.
03100 //      dwControlCodeIn   Control code for the request.
03101 //      hHostNodeIn       Handle for the node to direct this request to.
03102 //                        Defaults to NULL.
03103 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
03104 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
03105 //
03106 //  Return Value:
03107 //      None.
03108 //
03109 //--
03110 /////////////////////////////////////////////////////////////////////////////
03111 DWORD
03112 CClusPropList::ScGetNetworkProperties(
03113       HNETWORK  hNetworkIn
03114     , DWORD     dwControlCodeIn
03115     , HNODE     hHostNodeIn
03116     , LPVOID    lpBufferIn              // = NULL
03117     , size_t    cbBufferIn              // = 0
03118     )
03119 {
03120     ASSERT( hNetworkIn != NULL );
03121     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
03122             == ( CLUS_OBJECT_NETWORK << CLUSCTL_OBJECT_SHIFT ) );
03123
03124     DWORD   sc = ERROR_SUCCESS;
03125     DWORD   cbProps = 256;
03126
03127     //
03128     // Overwrite anything that may be in the buffer.
03129     // Allows this class instance to be reused.
03130     //
03131
03132     m_cbDataSize = 0;
03133
03134     //
03135     // Get properties.
03136     //
03137     sc = ScAllocPropList( cbProps );
03138     if ( sc == ERROR_SUCCESS )
03139     {
03140         sc = ClusterNetworkControl(
03141                           hNetworkIn
03142                         , hHostNodeIn
03143                         , dwControlCodeIn
03144                         , lpBufferIn
03145                         , static_cast< DWORD >( cbBufferIn )
03146                         , m_cbhPropList.pb
03147                         , static_cast< DWORD >( m_cbBufferSize )
03148                         , &cbProps
03149                         );
03150         if ( sc == ERROR_MORE_DATA )
03151         {
03152             sc = ScAllocPropList( cbProps );
03153             if ( sc == ERROR_SUCCESS )
03154             {
03155                 sc = ClusterNetworkControl(
03156                                   hNetworkIn
03157                                 , hHostNodeIn
03158                                 , dwControlCodeIn
03159                                 , lpBufferIn
03160                                 , static_cast< DWORD >( cbBufferIn )
03161                                 , m_cbhPropList.pb
03162                                 , static_cast< DWORD >( m_cbBufferSize )
03163                                 , &cbProps
03164                                 );
03165             } // if: ScAllocPropList succeeded
03166         } // if: buffer too small
03167     } // if: ScAllocPropList succeeded
03168
03169     if ( sc != ERROR_SUCCESS )
03170     {
03171         DeletePropList();
03172     } // if: error getting private properties.
03173     else
03174     {
03175         m_cbDataSize = static_cast< size_t >( cbProps );
03176         m_cbDataLeft = static_cast< size_t >( cbProps );
03177     } // else: no errors
03178
03179     return sc;
03180
03181 } //*** CClusPropList::ScGetNetworkProperties
03182
03183 /////////////////////////////////////////////////////////////////////////////
03184 //++
03185 //
03186 //  CClusPropList::ScGetNetInterfaceProperties
03187 //
03188 //  Description:
03189 //      Get properties on a network interface.
03190 //
03191 //  Arguments:
03192 //      hNetInterfaceIn   Handle for the network interface to get properties from.
03193 //      dwControlCodeIn   Control code for the request.
03194 //      hHostNodeIn       Handle for the node to direct this request to.
03195 //                        Defaults to NULL.
03196 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
03197 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
03198 //
03199 //  Return Value:
03200 //      None.
03201 //
03202 //--
03203 /////////////////////////////////////////////////////////////////////////////
03204 DWORD
03205 CClusPropList::ScGetNetInterfaceProperties(
03206       HNETINTERFACE hNetInterfaceIn
03207     , DWORD         dwControlCodeIn
03208     , HNODE         hHostNodeIn
03209     , LPVOID        lpBufferIn              // = NULL
03210     , size_t        cbBufferIn              // = 0
03211     )
03212 {
03213     ASSERT( hNetInterfaceIn != NULL );
03214     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
03215             == ( CLUS_OBJECT_NETINTERFACE << CLUSCTL_OBJECT_SHIFT ) );
03216
03217     DWORD   sc = ERROR_SUCCESS;
03218     DWORD   cbProps = 256;
03219
03220     //
03221     // Overwrite anything that may be in the buffer.
03222     // Allows this class instance to be reused.
03223     //
03224
03225     m_cbDataSize = 0;
03226
03227     //
03228     // Get properties.
03229     //
03230
03231     sc = ScAllocPropList( cbProps );
03232     if ( sc == ERROR_SUCCESS )
03233     {
03234         sc = ClusterNetInterfaceControl(
03235                           hNetInterfaceIn
03236                         , hHostNodeIn
03237                         , dwControlCodeIn
03238                         , lpBufferIn
03239                         , static_cast< DWORD >( cbBufferIn )
03240                         , m_cbhPropList.pb
03241                         , static_cast< DWORD >( m_cbBufferSize )
03242                         , &cbProps
03243                         );
03244         if ( sc == ERROR_MORE_DATA )
03245         {
03246             sc = ScAllocPropList( cbProps );
03247             if ( sc == ERROR_SUCCESS )
03248             {
03249                 sc = ClusterNetInterfaceControl(
03250                                   hNetInterfaceIn
03251                                 , hHostNodeIn
03252                                 , dwControlCodeIn
03253                                 , lpBufferIn
03254                                 , static_cast< DWORD >( cbBufferIn )
03255                                 , m_cbhPropList.pb
03256                                 , static_cast< DWORD >( m_cbBufferSize )
03257                                 , &cbProps
03258                                 );
03259             } // if: ScAllocPropList succeeded
03260         } // if: buffer too small
03261     } // if: ScAllocPropList succeeded
03262
03263     if ( sc != ERROR_SUCCESS )
03264     {
03265         DeletePropList();
03266     } // if: error getting private properties.
03267     else
03268     {
03269         m_cbDataSize = static_cast< size_t >( cbProps );
03270         m_cbDataLeft = static_cast< size_t >( cbProps );
03271     } // else: no errors
03272
03273     return sc;
03274
03275 } //*** CClusPropList::ScGetNetInterfaceProperties
03276
03277
03278 /////////////////////////////////////////////////////////////////////////////
03279 //++
03280 //
03281 //  CClusPropList::ScGetClusterProperties
03282 //
03283 //  Description:
03284 //      Get properties on a cluster.
03285 //
03286 //  Arguments:
03287 //      hClusterIn        Handle for the cluster to get properties from.
03288 //      dwControlCodeIn   Control code for the request.
03289 //      hHostNodeIn       Handle for the node to direct this request to.
03290 //                        Defaults to NULL.
03291 //      lpBufferIn        Input buffer for the request.  Defaults to NULL.
03292 //      cbBufferIn        Size of the input buffer.  Defaults to 0.
03293 //
03294 //  Return Value:
03295 //      None.
03296 //
03297 //--
03298 /////////////////////////////////////////////////////////////////////////////
03299 DWORD
03300 CClusPropList::ScGetClusterProperties(
03301       HCLUSTER  hClusterIn
03302     , DWORD     dwControlCodeIn
03303     , HNODE     hHostNodeIn
03304     , LPVOID    lpBufferIn              // = NULL
03305     , size_t    cbBufferIn              // = 0
03306     )
03307 {
03308     ASSERT( hClusterIn != NULL );
03309     ASSERT( ( dwControlCodeIn & ( CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT ) )
03310             == ( CLUS_OBJECT_CLUSTER << CLUSCTL_OBJECT_SHIFT ) );
03311
03312     DWORD   sc = ERROR_SUCCESS;
03313     DWORD   cbProps = 256;
03314
03315     //
03316     // Overwrite anything that may be in the buffer.
03317     // Allows this class instance to be reused.
03318     //
03319
03320     m_cbDataSize = 0;
03321
03322     //
03323     // Get properties.
03324     //
03325
03326     sc = ScAllocPropList( cbProps );
03327     if ( sc == ERROR_SUCCESS )
03328     {
03329         sc = ClusterControl(
03330                           hClusterIn
03331                         , hHostNodeIn
03332                         , dwControlCodeIn
03333                         , lpBufferIn
03334                         , static_cast< DWORD >( cbBufferIn )
03335                         , m_cbhPropList.pb
03336                         , static_cast< DWORD >( m_cbBufferSize )
03337                         , &cbProps
03338                         );
03339         if ( sc == ERROR_MORE_DATA )
03340         {
03341             sc = ScAllocPropList( cbProps );
03342             if ( sc == ERROR_SUCCESS )
03343             {
03344                 sc = ClusterControl(
03345                                   hClusterIn
03346                                 , hHostNodeIn
03347                                 , dwControlCodeIn
03348                                 , lpBufferIn
03349                                 , static_cast< DWORD >( cbBufferIn )
03350                                 , m_cbhPropList.pb
03351                                 , static_cast< DWORD >( m_cbBufferSize )
03352                                 , &cbProps
03353                                 );
03354             } // if: ScAllocPropList succeeded
03355         } // if: buffer too small
03356     } // if: ScAllocPropList succeeded
03357
03358     if ( sc != ERROR_SUCCESS )
03359     {
03360         DeletePropList();
03361     } // if: error getting private properties.
03362     else
03363     {
03364         m_cbDataSize = static_cast< size_t >( cbProps );
03365         m_cbDataLeft = static_cast< size_t >( cbProps );
03366     } // else: no errors
03367
03368     return sc;
03369
03370 } //*** CClusPropList::ScGetClusterProperties
Generated on Wed Nov 13 2024 16:52:48 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDBAuthAdmin Member List

This is the complete list of members for CDBAuthAdmin, including all inherited members.
AddUser(BSTR bstrUserName) | CDBAuthAdmin |
CDBAuthAdmin() | CDBAuthAdmin | [inline]
GetUsers(BSTR *pbstrUserNames) | CDBAuthAdmin |
Initialize(CDBAuthPlugin *pPlugin) | CDBAuthAdmin |
InterfaceSupportsErrorInfo(REFIID riid) | CDBAuthAdmin |
m_pDBAuthPlugin | CDBAuthAdmin | [private]
RemoveUser(BSTR bstrUserName) | CDBAuthAdmin |
VerifyUser(BSTR bstrUserName, VARIANT_BOOL *pbFound) | CDBAuthAdmin |
~CDBAuthAdmin() | CDBAuthAdmin | [inline]
Generated on Wed Nov 13 2024 16:56:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/TutSamp/ComObj/ComObj.Cpp Source File

  • Com
  • Fundamentals
  • TutSamp
  • ComObj

ComObj.Cpp

Go to the documentation of this file.
00001 /*+==========================================================================
00002   File:      COMOBJ.CPP
00003
00004   Summary:   Implementation file for a primitive DLL server providing
00005              several Car-related COM Objects.  This is not a full-blown
00006              COM Server.  Rather it is a primitive COM Object server
00007              offering the following COM objects: Car, UtilityCar, and
00008              CruiseCar.  Appropriate create functions are exported from
00009              this DLL: CreateCar, CreateUtilityCar, and CreateCruiseCar.
00010
00011              For a comprehensive tutorial code tour of COMOBJ's
00012              contents and offerings see the tutorial COMOBJ.HTM file.
00013              For more specific technical details on the internal workings
00014              see the comments dispersed throughout the COMOBJ source code.
00015
00016   Classes:   none.
00017
00018   Functions: DllMain, ComObjInitMsgLog, ComObjAboutBox, CreateCar,
00019              CreateUtilityCar, CreateCruiseCar
00020
00021   Origin:    8-20-95: atrent - Editor-inheritance from DLLSKEL.CPP in
00022                the DLLSKEL Tutorial Code Sample.
00023
00024 ----------------------------------------------------------------------------
00025   This file is part of the Microsoft COM Tutorial Code Samples.
00026
00027   Copyright (C) 1995 - 2000 Microsoft Corporation.  All rights reserved.
00028
00029   This source code is intended only as a supplement to Microsoft
00030   Development Tools and/or on-line documentation.  See these other
00031   materials for detailed information regarding Microsoft code samples.
00032
00033   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00034   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00036   PARTICULAR PURPOSE.
00037 ==========================================================================+*/
00038
00039 /*---------------------------------------------------------------------------
00040   We include WINDOWS.H for all Win32 applications.
00041   We include OLE2.H because we will make calls to the COM/OLE Libraries.
00042   We include INITGUID.H only once (here) in the entire DLL because we
00043     will be defining GUIDs and want them as constants in the data segment.
00044   We include APPUTIL.H because we will be building this DLL using
00045     the convenient Virtual Window and Dialog classes and other
00046     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
00047   We include ICARS.H and CARGUIDS.H for the common car-related Interface
00048     class, GUID, and CLSID specifications.
00049   We include COMOBJI.H because it has the necessary internal class and
00050     resource definitions for this DLL.
00051   We include COMOBJ.H because it has the necessary DLLENTRY function
00052     prototypes.  The _DLLEXPORT_ #define is used to tell COMOBJ.H to
00053     define the appropriate functions as exported from this DLL.
00054     Otherwise, COMOBJ.H is included by users of this DLL who do not
00055     define _DLLEXPORT_ so that the appropriate functions are then
00056     declared as imports rather than defined as exports.  COMOBJ.H also
00057     has the necessary interface declarations for ICar, IUtility, and ICruise.
00058   We include CAR.H, UTILCAR,H, and, CRUCAR.H for the object class
00059     declarations for the COCar, COUtilityCar, and COCruiseCar COM objects.
00060 ---------------------------------------------------------------------------*/
00061 #include <windows.h>
00062 #include <ole2.h>
00063 #include <initguid.h>
00064 #include <apputil.h>
00065 #include <icars.h>
00066 #include <carguids.h>
00067 #include "comobji.h"
00068 #define _DLLEXPORT_
00069 #include "comobj.h"
00070 #include "car.h"
00071 #include "utilcar.h"
00072 #include "crucar.h"
00073
00074
00075 // Global variable definitions. Initialized in DllMain() below.
00076
00077 // Here is a pointer for use by the global Debug Message logging macros.
00078 // Set by the ComObjInitMsgLog function call from an outside EXE user.
00079 CMsgLog* g_pMsgLog;
00080
00081 // We encapsulate most of the global data for clarity.  Here is a
00082 // global pointer to the DllData object.
00083 CDllData* g_pDll;
00084
00085
00086 /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00087   Function: UnicodeOk
00088
00089   Summary:  Checks if the platform will handle unicode versions of
00090             Win32 string API calls.
00091
00092   Args:     void
00093
00094   Returns:  BOOL
00095               TRUE if unicode support; FALSE if not.
00096 ------------------------------------------------------------------------F-F*/
00097 BOOL UnicodeOk(void)
00098 {
00099   BOOL bOk = TRUE;
00100   TCHAR szUserName[MAX_STRING_LENGTH];
00101   DWORD dwSize = MAX_STRING_LENGTH;
00102
00103   if (!GetUserName(szUserName, &dwSize))
00104     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
00105
00106   return bOk;
00107 }
00108
00109
00110 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00111   Function: DllMain
00112
00113   Summary:  Like WinMain is for an EXE application, this DllMain function
00114             is the main entry point for this DLL.  It is called when the
00115             DLL is loaded by a process, and when new threads are created
00116             by a process that has already loaded this DLL.  DllMain is also
00117             called when threads of a process that has loaded the DLL exit
00118             cleanly and when the process itself unloads the DLL.
00119
00120             If you want to use C runtime libraries, keep this function
00121             named "DllMain" and you won't have to do anything special to
00122             initialize the runtime libraries.
00123
00124             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
00125             to determine if the DLL should remain loaded, or should be
00126             immediately unloaded depending upon whether the DLL could be
00127             initialized properly.  For all other values of fdwReason,
00128             the return value is ignored.
00129
00130   Args:     HINSTANCE hDLLInst,
00131               Instance handle of the DLL.
00132             DWORD fdwReason,
00133               Process attach/detach or thread attach/detach.
00134               Reason for calling.
00135             LPVOID lpvReserved)
00136               Reserved and not used.
00137
00138   Returns:  BOOL,
00139               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
00140               TRUE  -  Used to signify that the DLL should remain loaded.
00141               FALSE -  Used to signify that the DLL should be
00142                 immediately unloaded.
00143 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00144 BOOL WINAPI DllMain(
00145               HINSTANCE hDllInst,
00146               DWORD fdwReason,
00147               LPVOID lpvReserved)
00148 {
00149   BOOL bResult = TRUE;
00150
00151   // Dispatch this main call based on the reason it was called.
00152   switch (fdwReason)
00153   {
00154     case DLL_PROCESS_ATTACH:
00155       // The DLL is being loaded for the first time by a given process.
00156       // Perform per-process initialization here.  If the initialization
00157       // is successful, return TRUE; if unsuccessful, return FALSE.
00158       bResult = FALSE;
00159       if (UnicodeOk())
00160       {
00161         // Instantiate a DLL global data encapsulator class.
00162         g_pDll = new CDllData;
00163         if (NULL != g_pDll)
00164         {
00165           // Remember the DLL Instance handle.
00166           g_pDll->hDllInst = hDllInst;
00167           // Create a MsgBox object.
00168           g_pDll->pMsgBox = new CMsgBox;
00169           if (NULL != g_pDll->pMsgBox)
00170             bResult = TRUE;
00171         }
00172       }
00173       break;
00174
00175     case DLL_PROCESS_DETACH:
00176       // The DLL is being unloaded by a given process.  Do any
00177       // per-process clean up here, such as undoing what was done in
00178       // DLL_PROCESS_ATTACH.  The return value is ignored.
00179       if (NULL != g_pDll)
00180       {
00181         DELETE_POINTER(g_pDll->pMsgBox);
00182         DELETE_POINTER(g_pDll);
00183       }
00184       break;
00185
00186     case DLL_THREAD_ATTACH:
00187       // A thread is being created in a process that has already loaded
00188       // this DLL.  Perform any per-thread initialization here.  The
00189       // return value is ignored.
00190       break;
00191
00192     case DLL_THREAD_DETACH:
00193       // A thread is exiting cleanly in a process that has already
00194       // loaded this DLL.  Perform any per-thread clean up here.  The
00195       // return value is ignored.
00196       break;
00197
00198     default:
00199       break;
00200   }
00201
00202   return (bResult);
00203 }
00204
00205
00206 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00207   Function: ComObjInitMsgLog
00208
00209   Summary:  Initialize a pointer inside this DLL to an outside EXE's
00210             Message Log facility.  We want to see LOG macro output used
00211             inside this DLL in the host EXE's message log window.
00212
00213   Args:     CMsgLog* pMsgLog
00214               Pointer to a message log object.
00215
00216   Returns:  BOOL
00217               TRUE.
00218 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00219 DLLENTRY BOOL WINAPI ComObjInitMsgLog(
00220                        CMsgLog* pMsgLog)
00221 {
00222   // Set up a pointer to the host EXE's Message Log facility so that any
00223   // LOG macros used in this DLL will log to the host EXE's log window.
00224   g_pMsgLog = pMsgLog;
00225
00226   LOG("D: --- COMOBJ.DLL now logging ---");
00227
00228   return TRUE;
00229 }
00230
00231
00232 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00233   Function: ComObjAboutBox
00234
00235   Summary:  One of the exported service functions of this DLL.  In this
00236             simple code sample, ComObjAboutBox showcases use of the
00237             CAboutBox class (from the APPUTIL utility library).  It also
00238             illustrates how to implement this dialog using resources
00239             stored in this DLL itself.
00240
00241   Args:     HWND hWnd)
00242               Handle of window that is to be parent of the dialog window.
00243
00244   Returns:  BOOL,
00245               Always returns TRUE.
00246 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00247 DLLENTRY BOOL WINAPI ComObjAboutBox(
00248                        HWND hWnd)
00249 {
00250   // Define one of those nifty APPUTIL CAboutBox modal dialog objects.
00251   CAboutBox dlgAboutBox;
00252
00253   // Show the standard About Box dialog for this DLL by telling the dialog
00254   // C++ object to show itself by invoking its ShowDialog method.
00255   // Pass it this DLL instance and the parent window handle.  Use a dialog
00256   // resource ID for the dialog stored in this DLL module's resources.
00257   dlgAboutBox.ShowDialog(
00258     g_pDll->hDllInst,
00259     MAKEINTRESOURCE(IDD_ABOUTBOX),
00260     hWnd);
00261
00262   return TRUE;
00263 }
00264
00265
00266 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00267   Function: CreateCar
00268
00269   Summary:  Creates an instance of the COCar COM object class
00270             returning a requested interface pointer.
00271
00272   Args:     IUnknown* pUnkOuter,
00273               Pointer the outer Unknown interface.  Non NULL implies
00274               that the new COM object is being created via an
00275               aggregation with an Outer object.  NULL implies that the
00276               object is not being created via aggregation.
00277             REFIID riid,
00278               The GUID of the interface requested on the new COM Object.
00279             PPVOID ppv)
00280               Address of the caller's pointer variable that will
00281               receive the requested interface pointer.
00282
00283   Returns:  HRESULT
00284               NOERROR if successful, CLASS_E_NOAGREGATION if IUnknown is
00285               not requested with non-NULL pUnkOuter, or other errors as
00286               appropriate.
00287 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00288 DLLENTRY HRESULT WINAPI CreateCar(
00289                           IUnknown* pUnkOuter,
00290                           REFIID riid,
00291                           PPVOID ppv)
00292 {
00293   HRESULT hr;
00294   COCar* pCob;
00295
00296   LOGF1("D: CreateCar. pUnkOuter=0x%X.",pUnkOuter);
00297
00298   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00299   // the COM rules state the IUnknown interface MUST also be concomitantly
00300   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00301   // an error must be returned indicating that no aggregate creation of
00302   // the COCar COM Object can be performed.
00303   if (NULL != pUnkOuter && riid != IID_IUnknown)
00304     hr = CLASS_E_NOAGGREGATION;
00305   else
00306   {
00307     // Instantiate a CCar COM Object.
00308     pCob = new COCar(pUnkOuter);
00309
00310     // We QueryInterface this new COM Object not only to deposit the
00311     // requested interface pointer into the caller's pointer variable,
00312     // but to also automatically bump the Reference Count on the new
00313     // COM Object after handing out this reference to it.
00314     if (NULL != pCob)
00315       hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00316     else
00317       hr = E_OUTOFMEMORY;
00318   }
00319
00320   if (SUCCEEDED(hr))
00321     LOGF1("D: CreateCar Succeeded. *ppv=0x%X.",*ppv);
00322
00323   return hr;
00324 }
00325
00326
00327 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00328   Function: CreateUtilityCar
00329
00330   Summary:  Creates an instance of the COUtilityCar COM object class
00331             returning a requested interface pointer. COUtilityCar uses the
00332             Containment reuse technique to incorporate COCar features
00333             (ie, ICar implementation) into its Interface offerings
00334             (ie, IUnknown, ICar, and IUtility).
00335
00336   Args:     IUnknown* pUnkOuter,
00337               Pointer the outer Unknown interface.  Non NULL implies
00338               that the new COM object is being created via an
00339               aggregation with an Outer object.  NULL implies that the
00340               object is not being created via aggregation.
00341             REFIID riid,
00342               The GUID of the interface requested on the new COM Object.
00343             PPVOID ppv)
00344               Address of the caller's pointer variable that will
00345               receive the requested interface pointer.
00346
00347   Returns:  HRESULT
00348               NOERROR if successful, CLASS_E_NOAGREGATION if IUnknown is
00349               not requested with non-NULL pUnkOuter, or other errors as
00350               appropriate.
00351 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00352 DLLENTRY HRESULT WINAPI CreateUtilityCar(
00353                           IUnknown* pUnkOuter,
00354                           REFIID riid,
00355                           PPVOID ppv)
00356 {
00357   HRESULT hr;
00358   COUtilityCar* pCob;
00359
00360   LOGF1("D: CreateUtilityCar. pUnkOuter=0x%X.",pUnkOuter);
00361
00362   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00363   // the COM rules state the IUnknown interface MUST also be concomitantly
00364   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00365   // an error must be returned indicating that no aggregate creation of
00366   // the COUtilityCar COM Object can be performed.
00367   if (NULL != pUnkOuter && riid != IID_IUnknown)
00368     hr = CLASS_E_NOAGGREGATION;
00369   else
00370   {
00371     // Instantiate a CUtilityCar COM Object.
00372     pCob = new COUtilityCar(pUnkOuter);
00373     if (NULL != pCob)
00374     {
00375       // If we have succeeded in instantiating the COUtilityCar object
00376       // we initialize it to set up any subordinate objects (ie, via
00377       // containment or aggregation).
00378       hr = pCob->Init();
00379       if (SUCCEEDED(hr))
00380       {
00381         // We QueryInterface this new COM Object not only to deposit the
00382         // requested interface pointer into the caller's pointer variable,
00383         // but to also automatically bump the Reference Count on the new
00384         // COM Object after handing out this reference to it.
00385         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00386       }
00387     }
00388     else
00389       hr = E_OUTOFMEMORY;
00390   }
00391
00392   if (SUCCEEDED(hr))
00393     LOGF1("D: CreateUtilityCar Succeeded. *ppv=0x%X.",*ppv);
00394
00395   return hr;
00396 }
00397
00398
00399 /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
00400   Function: CreateCruiseCar
00401
00402   Summary:  Creates an instance of the COCruiseCar COM object class
00403             returning a requested interface pointer. COCruiseCar uses the
00404             Aggregation reuse technique to incorporate COCar features
00405             (ie, ICar implementation) into its Interface offerings
00406             (ie, IUnknown, ICar, and ICruise).  With this aggregation,
00407             the ICar interface is not implemented in COCruiseCar.  It is
00408             instead solely implemented in a COCar object that
00409             CreateCruiseCar instantiates.  That COCar's ICar implementation
00410             is used directly in this aggregation.
00411
00412   Args:     IUnknown* pUnkOuter,
00413               Pointer the outer Unknown interface.  Non NULL implies
00414               that the new COM object is being created via an
00415               aggregation with an Outer object.  NULL implies that the
00416               object is not being created via aggregation.
00417             REFIID riid,
00418               The GUID of the interface requested on the new COM Object.
00419             PPVOID ppv)
00420               Address of the caller's pointer variable that will
00421               receive the requested interface pointer.
00422
00423   Returns:  HRESULT
00424               NOERROR if successful, CLASS_E_NOAGREGATION if IUnknown is
00425               not requested with non-NULL pUnkOuter, or other errors as
00426               appropriate.
00427 F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
00428 DLLENTRY HRESULT WINAPI CreateCruiseCar(
00429                           IUnknown* pUnkOuter,
00430                           REFIID riid,
00431                           PPVOID ppv)
00432 {
00433   HRESULT hr;
00434   COCruiseCar* pCob;
00435
00436   LOGF1("D: CreateCruiseCar. pUnkOuter=0x%X.",pUnkOuter);
00437
00438   // If the creation call is requesting aggregation (pUnkOuter != NULL),
00439   // the COM rules state the IUnknown interface MUST also be concomitantly
00440   // be requested.  If it is not so requested (riid != IID_IUnknown) then
00441   // an error must be returned indicating that no aggregate creation of
00442   // the COCruiseCar COM Object can be performed.
00443   if (NULL != pUnkOuter && riid != IID_IUnknown)
00444     hr = CLASS_E_NOAGGREGATION;
00445   else
00446   {
00447     // Instantiate a COCruiseCar COM Object.
00448     pCob = new COCruiseCar(pUnkOuter);
00449     if (NULL != pCob)
00450     {
00451       // If we have succeeded in instantiating the COCruiseCar object
00452       // we initialize it to set up any subordinate objects (ie, via
00453       // containment or aggregation).
00454       hr = pCob->Init();
00455       if (SUCCEEDED(hr))
00456       {
00457         // We QueryInterface this new COM Object not only to deposit the
00458         // requested interface pointer into the caller's pointer variable,
00459         // but to also automatically bump the Reference Count on the new
00460         // COM Object after handing out this reference to it.
00461         hr = pCob->QueryInterface(riid, (PPVOID)ppv);
00462       }
00463     }
00464     else
00465       hr = E_OUTOFMEMORY;
00466   }
00467
00468   if (SUCCEEDED(hr))
00469     LOGF1("D: CreateCruiseCar Succeeded. *ppv=0x%X.",*ppv);
00470
00471   return hr;
00472 }
Generated on Wed Nov 13 2024 16:51:55 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CAppSub Member List

This is the complete list of members for CAppSub, including all inherited members.
CAppSub() | CAppSub | [inline]
CAppSub(CComSpy *pSpy) | CAppSub | [inline]
CSysLCESub() | CSysLCESub | [inline]
GetEventClass(LPGUID guid) | CAppSub | [inline, virtual]
GetEventType(EventEnum *e) | CAppSub | [inline, virtual]
GetInterface(IID *iid) | CAppSub | [inline, virtual]
Install(BSTR *PropertyName, VARIANT PropertyValue) | CSysLCESub |
m_pSpy | CSysLCESub | [protected]
m_SubscriptionGuid | CSysLCESub | [protected]
OnAppActivation(COMSVCSEVENTINFO *pInfo, GUID guidApp) | CAppSub | [inline]
OnAppForceShutdown(COMSVCSEVENTINFO *pInfo, GUID guidApp) | CAppSub | [inline]
OnAppShutdown(COMSVCSEVENTINFO *pInfo, GUID guidApp) | CAppSub | [inline]
SetSpyObj(CComSpy *pSpy) | CSysLCESub | [inline]
Uninstall() | CSysLCESub |
Generated on Wed Nov 13 2024 16:55:35 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CDataSource Member List

This is the complete list of members for CDataSource, including all inherited members.
Abort(HCHAPTER hChapter, DBASYNCHOP eOperation) | CAsynchBase | [virtual]
AdminCreateDataSource(CAggregate *pCAggregate, ULONG cPropSets, DBPROPSET *rgPropSets, REFIID riid, IUnknown **ppIUnknown) | CDataSource | [virtual]
AdviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
AutoQI(DWORD dwCreateOpts) | CDataSource | [virtual]
AutoRelease() | CDataSource | [virtual]
CAsynchBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CAsynchBase |
CBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CBase |
CBaseObj(EBaseObjectType botVal) | CBaseObj | [protected]
CContainerBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CContainerBase |
CDataSource(CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CDataSource |
CDataSource(LPUNKNOWN) | CDataSource |
CDataSource() | CDataSource |
CDBSession class | CDataSource | [friend]
CImpIDBCreateSession class | CDataSource | [friend]
CImpIDBInfo class | CDataSource | [friend]
CImpIDBInitialize class | CDataSource | [friend]
CImpIDBProperties class | CDataSource | [friend]
CImpIPersist class | CDataSource | [friend]
CImpIServiceProvider class | CDataSource | [friend]
Connect(HWND hWnd, CDataSource *pCDataSource=NULL) | CDataSource | [virtual]
CPropertiesBase(SOURCE eObjectType, CMainWindow *pCMainWindow, CMDIChild *pCMDIChild=NULL) | CPropertiesBase |
CreateObject(CBase *pCSource, REFIID riid, IUnknown *pIUnknown, DWORD dwCreateOpts=-1) | CBase | [virtual]
CreateSession(CAggregate *pCAggregate, REFIID riid, IUnknown **ppIUnknown) | CDataSource | [virtual]
Disconnect() | CDataSource | [virtual]
DisplayObject() | CBase | [virtual]
FindConnectionPoint(REFIID riid, IConnectionPoint **ppIConnectionPoint) | CContainerBase | [virtual]
FInit(void) | CDataSource |
GetBaseObjectType() | CBaseObj | [inline]
GetBaseType() | CBase | [inline]
GetClassID(CLSID *pclsid, WCHAR **ppwszProgID=NULL) | CDataSource | [virtual]
GetConnectionProps() | CDataSource | [virtual]
GetDefaultInterface() | CDataSource | [inline, virtual]
GetFilePath(void) | CDataSource | [inline]
GetInterface(REFIID riid) | CBase | [virtual]
GetInterfaceAddress(REFIID riid) | CDataSource | [virtual]
GetObjectDesc() | CDataSource | [virtual]
GetObjectImage() | CDataSource | [inline, virtual]
GetObjectMenu() | CDataSource | [inline, virtual]
GetObjectName() | CDataSource | [inline, virtual]
GetObjectType() | CBase | [inline]
GetOptions() | CBase | [virtual]
GetOuterUnknown() | CBaseObj | [inline]
GetParent(SOURCE eSource) | CBase | [virtual]
GetProviders() | CDataSource | [virtual]
GetStatus(HCHAPTER hChapter, DBASYNCHOP eOperation, DBCOUNTITEM *pulProgress, DBCOUNTITEM *pulProgressMax, DBASYNCHPHASE *peAsynchPhase, LPOLESTR *ppwszStatusText) | CAsynchBase | [virtual]
Initialize() | CAsynchBase | [virtual]
IsConnected() | CDataSource | [virtual]
IsEqual(CDataSource *pCDataSource) | CDataSource | [virtual]
IsInitialized() | CAsynchBase | [inline, virtual]
IsSameObject(IUnknown *pIUnkObject) | CBase | [virtual]
IsSimilar(CDataSource *pCDataSource) | CDataSource | [virtual]
m_cProviderInfo | CDataSource |
m_cRef | CDataSource | [protected]
m_cstrDataSource | CDataSource |
m_cstrDBMS | CDataSource |
m_cstrDBMSVer | CDataSource |
m_cstrProviderDesc | CDataSource |
m_cstrProviderName | CDataSource |
m_dwCLSCTX | CBase |
m_dwCookieAsynchNotify | CAsynchBase |
m_dwStorageObjects | CDataSource |
m_eBaseClass | CBase | [protected]
m_eObjectType | CBase | [protected]
m_fConnected | CDataSource |
m_fDBSessionCreated | CDataSource | [protected]
m_fDSOInitialized | CDataSource | [protected]
m_fInitialized | CAsynchBase |
m_fIRowsetChange | CDataSource |
m_fIRowsetUpdate | CDataSource |
m_fMultipleParamSets | CDataSource |
m_fPrimaryKeysSupported | CDataSource |
m_fReadOnly | CDataSource |
m_guidSource | CBase |
m_hTreeItem | CBase |
m_lDataSourceType | CDataSource |
m_pCMainWindow | CBase |
m_pCMDIChild | CBase |
m_pCParent | CBase |
m_pIAggregate | CBase |
m_pICommandText | CDataSource |
m_pIConnectionPointContainer | CContainerBase |
m_pIDBAsynchStatus | CAsynchBase |
m_pIDBCreateSession | CDataSource |
m_pIDBCreateSession | CDataSource | [protected]
m_pIDBDataSourceAdmin | CDataSource |
m_pIDBInfo | CDataSource |
m_pIDBInfo | CDataSource | [protected]
m_pIDBInitialize | CDataSource | [protected]
m_pIDBInitialize | CDataSource |
m_pIDBProperties | CDataSource | [protected]
m_pIDBSchemaRowset | CDataSource |
m_pIIndexDefinition | CDataSource |
m_pIOpenRowset | CDataSource |
m_pIParseDisplayName | CDataSource |
m_pIPersist | CDataSource |
m_pIPersist | CDataSource | [protected]
m_pIPersistFile | CDataSource |
m_pIService | CBase |
m_pIServiceProvider | CDataSource |
m_pIServiceProvider | CDataSource | [protected]
m_pISupportErrorInfo | CBase |
m_pITableDefinition | CDataSource |
m_pIUnknown | CBase |
m_pUnkOuter | CDataSource |
CBaseObj::m_pUnkOuter | CBaseObj | [protected]
m_pUtilProp | CDataSource | [protected]
m_pwszCatalog | CDataSource |
m_pwszCatalogLocation | CDataSource |
m_pwszCatalogTerm | CDataSource |
m_pwszDataSource | CDataSource |
m_pwszDBMS | CDataSource |
m_pwszDBMSVer | CDataSource |
m_pwszProviderFileName | CDataSource |
m_pwszProviderName | CDataSource |
m_pwszProviderOLEDBVer | CDataSource |
m_pwszProviderParseName | CDataSource |
m_pwszProviderVer | CDataSource |
m_pwszSchemaTerm | CDataSource |
m_pwszTableTerm | CDataSource |
m_rgProviderInfo | CDataSource |
m_strObjectDesc | CBase | [protected]
m_ulActiveSessions | CDataSource |
m_wszPath | CDataSource | [protected]
ObjectAddRef() | CBase | [virtual]
ObjectQI(REFIID riid, IUnknown **ppIUnknown) | CBase | [virtual]
ObjectRelease() | CBase | [virtual]
OnDefOperation() | CBase | [virtual]
OpenFile(WCHAR *pwszFileName, CFileIO **ppCFileIO) | CDataSource |
QueryInterface(REFIID, LPVOID *) | CDataSource |
CPropertiesBase::QueryInterface(REFIID riid, void **ppvObject) | CBase |
ReleaseChildren() | CBase | [virtual]
ReleaseObject(ULONG ulExpectedRefCount=0) | CBase | [virtual]
RemoveSession(void) | CDataSource | [inline]
SetInterface(REFIID riid, IUnknown *pIUnknown) | CBase | [virtual]
SetObjectDesc(WCHAR *pwszDescription, BOOL fCopy=TRUE) | CBase | [virtual]
SetProperties(ULONG cPropSets, DBPROPSET *rgPropSets) | CPropertiesBase | [virtual]
STDMETHODIMP_(DBREFCOUNT) AddRef(void) | CDataSource |
STDMETHODIMP_(DBREFCOUNT) Release(void) | CDataSource |
CPropertiesBase::STDMETHODIMP_(ULONG) AddRef() | CBase |
UnadviseListener(REFIID riid, DWORD *pdwCookie) | CContainerBase | [virtual]
Uninitialize() | CAsynchBase | [virtual]
~CAsynchBase() | CAsynchBase | [virtual]
~CBase() | CBase | [virtual]
~CBaseObj() | CBaseObj | [virtual]
~CContainerBase() | CContainerBase | [virtual]
~CDataSource() | CDataSource | [virtual]
~CDataSource(void) | CDataSource |
~CDataSource() | CDataSource | [virtual]
~CPropertiesBase() | CPropertiesBase | [virtual]
Generated on Wed Nov 13 2024 16:56:05 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

TableHdr Member List

This is the complete list of members for TableHdr, including all inherited members.
fixedcols | TableHdr
fixedrows | TableHdr
fixedselectable | TableHdr
hseparator | TableHdr
id | TableHdr
ncols | TableHdr
nrows | TableHdr
props | TableHdr
selectmode | TableHdr
sendscroll | TableHdr
vseparator | TableHdr
Generated on Wed Nov 13 2024 16:57:59 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: NetDS/RPC/Pickle/Picklt/Pickltc.c Source File

  • NetDS
  • RPC
  • Pickle
  • Picklt

Pickltc.c

Go to the documentation of this file.
00001 /****************************************************************************
00002                    Microsoft RPC Version 2.0
00003            Copyright Microsoft Corp. 1992 - 2000
00004                       picklt Example
00005
00006     FILE:       pickltc.c
00007
00008     USAGE:      pickltc  -f filename  (file to write to/read from)
00009                          -d           (serialization direction: decode)
00010                          -e           (serialization direction: encode)
00011                          -i           (incremental serialization on)
00012
00013     PURPOSE:    The only side of RPC application
00014
00015     FUNCTIONS:  main() - serializes data to or from a file
00016
00017     COMMENTS:   Data type serialization is demonstrated here
00018
00019 ****************************************************************************/
00020
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include "picklt.h"    // header file generated by MIDL compiler
00024
00025 #define PURPOSE \
00026 "This Microsoft RPC Version 2.0 sample program demonstrates\n\
00027 the use of the [encode,decode] attributes. For more information\n\
00028 about the attributes and RPC API functions, see the RPC programming\n\
00029 guide and reference.\n\n"
00030
00031 /*  ------------------------------------------------------------------------ */
00032 /*  Used for incremental style only. */
00033
00034 void __RPC_USER PicAlloc( void * pState, char ** ppBuf, unsigned int * pCount);
00035 void __RPC_USER PicWrite( void * pState, char *  pBuf,  unsigned int Count);
00036 void __RPC_USER PicRead ( void * pState, char ** pBuf,  unsigned int * pCount);
00037
00038 typedef struct PickleControlBlock
00039 {
00040     unsigned char *         pMemBuffer;
00041     unsigned char *         pBufferStart;
00042     unsigned long           LastSize;
00043 } PickleControlBlock;
00044
00045 static PickleControlBlock                 UserState;
00046 static PickleControlBlock * pUserState = &UserState;
00047 /*  ------------------------------------------------------------------------ */
00048
00049 void Usage(char * pszProgramName)
00050 {
00051     fprintf(stderr, "%s", PURPOSE);
00052     fprintf(stderr, "Usage:  %s\n", pszProgramName);
00053     fprintf(stderr, " -d\n");
00054     fprintf(stderr, " -e\n");
00055     fprintf(stderr, " -ffilename\n");
00056     fprintf(stderr, " -i \n");
00057     exit(1);
00058 }
00059
00060 void DumpData(
00061     char * pszComment,
00062     OBJECT2 * pObject2 )
00063 {
00064     int i;
00065
00066     printf( "\n%s\n", pszComment );
00067
00068     printf( "\tObject2");
00069     printf( "\n\t\t%x", pObject2->sData );
00070     printf( "\n\t\t%p", pObject2->pObject1 );
00071
00072     if ( pObject2->pObject1 )
00073         {
00074         OBJECT1 * pObject1 = pObject2->pObject1;
00075
00076         printf( "\n\tObject1");
00077         for (i=0; i < ARR_SIZE; i++)
00078             {
00079             if ( (i % 5) == 0 )
00080                 printf( "\n\t\t");
00081             printf( "%08xl  ", pObject1->al[i] );
00082             }
00083         printf( "\n\t\t%x\n", pObject1->s );
00084         }
00085
00086     printf( "\n" );
00087 }
00088
00089 void WriteDataToFile(
00090     char *          pszFileName,
00091     char *          pbBuffer,
00092     unsigned long   ulSizeToWrite )
00093 {
00094     FILE *      pFile;
00095     size_t      Count;
00096
00097     if ( pszFileName ) {
00098
00099         pFile = fopen( pszFileName, "w+b" );
00100         if ( pFile == NULL ) {
00101             printf("Cannot open the file for writing\n");
00102             exit(1);
00103             }
00104
00105         Count = sizeof(long);
00106         if ( fwrite( &ulSizeToWrite, sizeof(byte), Count, pFile) != Count ) {
00107             printf("Cannot write1 to the file\n");
00108             exit(1);
00109             }
00110
00111         Count = (size_t) ulSizeToWrite;
00112         if ( fwrite( pbBuffer, sizeof(byte), Count, pFile) != Count ) {
00113             printf("Cannot write2 to the file\n");
00114             exit(1);
00115             }
00116
00117         if ( fclose( pFile ) != 0) {
00118             printf("Failed to close the file\n");
00119             exit(1);
00120             }
00121         }
00122 }
00123
00124 void ReadDataFromFile(
00125     char *          pszFileName,
00126     char *          pbBuffer,
00127     unsigned long   ulBufferSize )
00128 {
00129     FILE *          pFile;
00130     size_t          Count;
00131     unsigned long   ulWrittenSize;
00132
00133
00134     if ( pszFileName ) {
00135
00136         pFile = fopen( pszFileName, "r+b" );
00137         if ( pFile == NULL ) {
00138             printf("Cannot open the file for reading\n");
00139             exit(1);
00140             }
00141
00142         Count = sizeof(long);
00143         if ( fread( &ulWrittenSize, sizeof(byte), Count, pFile) != Count ) {
00144             printf("Cannot read1 from the file\n");
00145             exit(1);
00146             }
00147
00148         Count = (size_t)ulWrittenSize;
00149         if ( fread( pbBuffer, sizeof(byte), Count, pFile) != Count ) {
00150             printf("Cannot read2 from the file\n");
00151             exit(1);
00152             }
00153
00154         if ( fclose( pFile ) != 0) {
00155             printf("Failed to close the file\n");
00156             exit(1);
00157             }
00158         }
00159 }
00160
00161 void __cdecl main(int argc, char **argv)
00162 {
00163     RPC_STATUS status;
00164
00165     unsigned char * pbPicklingBuffer = NULL;
00166
00167     char * pszStyle      = NULL;
00168     char * pszFileName   = "pickle.dat";
00169     int i;
00170     int fEncode = 1;
00171     int fFixedStyle = 1;
00172
00173     /* allow the user to override settings with command line switches */
00174     for (i = 1; i < argc; i++) {
00175         if ((*argv[i] == '-') || (*argv[i] == '/')) {
00176             switch (tolower(*(argv[i]+1))) {
00177             case 'd':
00178                 fEncode = 0;
00179                 break;
00180             case 'e':
00181                 fEncode = 1;
00182                 break;
00183             case 'i':
00184                 fFixedStyle = 0;
00185                 break;
00186             case 'f':
00187                 pszFileName = argv[i] + 2;
00188                 break;
00189             case 'h':
00190             case '?':
00191             default:
00192                 Usage(argv[0]);
00193             }
00194         }
00195         else
00196             Usage(argv[0]);
00197     }
00198
00199     /* Fixed buffer style: the buffer should be big enough.
00200        Please note that a pickling buffer has to be aligned at 8.
00201
00202        Also note, the buffer doesn't have to be allocated with
00203        the standard midl_user_allocate - this may be any allocator
00204        that alignes at 8.
00205        In general, midl_user_allocate is not required to return
00206        a buffer aligned at 8.
00207     */
00208
00209     pbPicklingBuffer = (unsigned char *)
00210             midl_user_allocate( BUFSIZE * sizeof(unsigned char));
00211
00212     if ( pbPicklingBuffer == NULL ) {
00213         printf("Cannot allocate the pickling buffer\n");
00214         exit(1);
00215         }
00216     else
00217         memset( pbPicklingBuffer, 0xdd, BUFSIZE );
00218
00219     /*
00220         Set the pickling handle that will be used for data serialization.
00221         The global ImplicitPicHandle is used, but it has to be set up.
00222     */
00223
00224     if ( fEncode ) {
00225
00226         unsigned char * pszNameId;
00227         OBJECT1         Object1;
00228         OBJECT2         Object2a,  *pObject2b;
00229
00230         unsigned long   ulEncodedSize = 0; /* this is a cumulative size */
00231
00232         printf("\nEncoding run: use -d for decoding\n\n");
00233
00234         if ( fFixedStyle ) {
00235
00236             printf("Creating a fixed buffer encoding handle\n");
00237             status = MesEncodeFixedBufferHandleCreate( pbPicklingBuffer,
00238                                                        BUFSIZE,
00239                                                        & ulEncodedSize,
00240                                                        & ImplicitPicHandle );
00241             printf("MesEncodeFixedBufferHandleCreate returned 0x%x\n", status);
00242             if (status) {
00243                 exit(status);
00244             }
00245         }
00246         else {
00247             /* Incremental style */
00248
00249             pUserState->LastSize = 0;
00250             pUserState->pMemBuffer = (char *)pbPicklingBuffer;
00251             pUserState->pBufferStart = (char *)pbPicklingBuffer;
00252
00253             printf("Creating an incremental encoding handle\n");
00254             status = MesEncodeIncrementalHandleCreate( pUserState,
00255                                                        PicAlloc,
00256                                                        PicWrite,
00257                                                        & ImplicitPicHandle );
00258             printf("MesEncodeIncrementalHandleCreate returned 0x%x\n", status);
00259             if (status) {
00260                 exit(status);
00261             }
00262         }
00263
00264         /* Creating objects to manipulate */
00265
00266         pszNameId = "Pickling sample";
00267
00268         for (i = 0; i < ARR_SIZE; i++)
00269             Object1.al[i] = 0x73730000 + i;
00270         Object1.s = 0x6464;
00271
00272         Object2a.sData = 0xa9a9;
00273         Object2a.pObject1 = NULL;
00274
00275         pObject2b = midl_user_allocate( sizeof(OBJECT2) );
00276         if (pObject2b == NULL ) {
00277             printf("Out of memory for Object2b\n");
00278             exit(1);
00279         }
00280         pObject2b->sData = 0xb8b8;
00281         pObject2b->pObject1 = & Object1;
00282
00283         DumpData( "Data to be encoded", &Object2a );
00284         printf("\nEncoding Object2a data to the buffer\n");
00285         OBJECT2_Encode( &Object2a );
00286
00287         /* The second object is encoded to the same buffer,
00288            the size used below is cumulative.
00289            Note that using procedure pickling instead of type pickling,
00290            both objects could be encoded with one call.
00291         */
00292
00293         DumpData( "Data to be encoded", pObject2b );
00294         printf("\nEncoding Object2b data to the buffer\n\n");
00295         OBJECT2_Encode( pObject2b );
00296
00297         printf("Writing the data to the file: %s\n", pszFileName);
00298         WriteDataToFile( pszFileName,
00299                          pbPicklingBuffer,
00300                          fFixedStyle  ? ulEncodedSize
00301                                       : pUserState->LastSize);
00302
00303         midl_user_free( pObject2b );
00304     }
00305     else {
00306         OBJECT2      Object2c, Object2d;
00307
00308         printf("\nDecoding run: use -e for encoding\n\n");
00309
00310         printf("Reading the data from the file: %s\n\n", pszFileName );
00311         ReadDataFromFile( pszFileName,
00312                           pbPicklingBuffer,
00313                           BUFSIZE );
00314
00315         if ( fFixedStyle ) {
00316
00317             printf("Creating a decoding handle\n");
00318             status = MesDecodeBufferHandleCreate( pbPicklingBuffer,
00319                                                   BUFSIZE,
00320                                                   & ImplicitPicHandle );
00321             printf("MesDecodeFixedBufferHandleCreate returned 0x%x\n", status);
00322             if (status) {
00323                 exit(status);
00324             }
00325         }
00326         else {
00327
00328             pUserState->LastSize = 0;
00329             pUserState->pMemBuffer = (char *)pbPicklingBuffer;
00330             pUserState->pBufferStart = (char *)pbPicklingBuffer;
00331
00332             printf("Creating an incremental decoding handle\n");
00333             status = MesDecodeIncrementalHandleCreate( pUserState,
00334                                                        PicRead,
00335                                                        & ImplicitPicHandle );
00336             printf("MesDecodeIncrementalHandleCreate returned 0x%x\n", status);
00337             if (status) {
00338                 exit(status);
00339             }
00340         }
00341
00342         /* Creating objects to manipulate */
00343
00344         Object2c.pObject1 = NULL;
00345         Object2d.pObject1 = NULL;
00346
00347         printf("\nDecoding Object2c data from the buffer\n");
00348         OBJECT2_Decode( & Object2c );
00349         DumpData( "Decoded data",  &Object2c );
00350
00351         printf("\nDecoding Object2d data from the buffer\n");
00352         OBJECT2_Decode( & Object2d );
00353         DumpData( "Decoded data",  &Object2d );
00354
00355         /* Need to free Object1 objects as they may have been allocated
00356            when unmarshalling data.
00357         */
00358
00359         if ( Object2c.pObject1 )
00360             midl_user_free( Object2c.pObject1 );
00361         if ( Object2d.pObject1 )
00362             midl_user_free( Object2d.pObject1 );
00363     }
00364
00365     printf("\nData serialization done.\n");
00366
00367     midl_user_free( pbPicklingBuffer );
00368
00369     printf("\nFreeing the serialization handle.\n");
00370     status = MesHandleFree( ImplicitPicHandle );
00371     printf("MesHandleFree returned 0x%x\n", status);
00372
00373     exit(0);
00374
00375 }  // end main()
00376
00377 /*********************************************************************/
00378 /*                 MIDL allocate and free                            */
00379 /*********************************************************************/
00380
00381 /* A pickling buffer has to be aligned at 8.
00382    malloc() doesn't guarantee that, so some gimmick has to be done.
00383 */
00384
00385 #define ALIGN_TO8( p)   (char *)((ULONG_PTR)((char *)p + 7) & ~7)
00386
00387 void __RPC_FAR * __RPC_USER  MIDL_user_allocate(size_t s)
00388 {
00389     unsigned char * pcAllocated;
00390     unsigned char * pcUserPtr;
00391
00392     pcAllocated = (unsigned char *) malloc( s + 15 );
00393     pcUserPtr =  ALIGN_TO8( pcAllocated );
00394     if ( pcUserPtr == pcAllocated )
00395         pcUserPtr = pcAllocated + 8;
00396
00397     *(pcUserPtr - 1) = (char) (pcUserPtr - pcAllocated);
00398
00399     return( pcUserPtr );
00400 }
00401
00402 void __RPC_USER  MIDL_user_free(void __RPC_FAR *f)
00403 {
00404     unsigned char * pcAllocated;
00405     unsigned char * pcUserPtr;
00406
00407     pcUserPtr = (unsigned char *) f;
00408     pcAllocated = pcUserPtr - *(pcUserPtr - 1);
00409
00410     free( pcAllocated );
00411 }
00412
00413 /*********************************************************************/
00414 /*                 Incremental style helper routines                 */
00415 /*********************************************************************/
00416
00417 void  __RPC_USER
00418 PicAlloc(
00419     void *          pState,
00420     char **         ppBuf,
00421     unsigned int  * pCount )
00422 {
00423     /* This routines "allocates" the next part from the preallocated
00424        buffer. It could call midl_user_allocate, too.
00425     */
00426
00427     PickleControlBlock * pPic = (PickleControlBlock *)pState;
00428
00429     if ( (pPic->pMemBuffer - pPic->pBufferStart) + *pCount <= BUFSIZE )
00430         *ppBuf = (char *)pPic->pMemBuffer;
00431     else {
00432         printf(" Buffer too small\n");
00433         exit(1);
00434     }
00435 }
00436
00437 void __RPC_USER
00438 PicWrite(
00439     void *          pState,
00440     char *          pBuf,
00441     unsigned int    Count )
00442 {
00443     /* This routine just marks how much of the preallocated buffer is used.
00444     */
00445
00446     PickleControlBlock * pPic = (PickleControlBlock *)pState;
00447
00448
00449     if ( pPic->pMemBuffer != pBuf ) {
00450         printf(" Buffer poiner corrupted\n");
00451         exit(1);
00452     }
00453     pPic->pMemBuffer += Count;
00454     pPic->LastSize += Count;
00455 }
00456
00457 void __RPC_USER
00458 PicRead(
00459     void *          pState,
00460     char **         ppBuf,
00461     unsigned int  * pCount )
00462 {
00463     /* This routine returns another portion of the preread buffer. */
00464
00465     PickleControlBlock * pPic = (PickleControlBlock *)pState;
00466
00467     *ppBuf = (char *)pPic->pMemBuffer;
00468     pPic->pMemBuffer += *pCount;
00469 }
00470
00471 /* end pickltc.c */
00472
00473
Generated on Wed Nov 13 2024 16:52:20 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: SysMgmt/MMC/Nameext/extend.h Source File

  • SysMgmt
  • MMC
  • Nameext

extend.h

Go to the documentation of this file.
00001 //==============================================================;
00002 //
00003 //  This source code is only intended as a supplement to
00004 //  existing Microsoft documentation.
00005 //
00006 //
00007 //
00008 //
00009 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00010 //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00011 //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
00012 //  PURPOSE.
00013 //
00014 //  Copyright (C) 1999 - 2001 Microsoft Corporation.  All Rights Reserved.
00015 //
00016 //
00017 //
00018 //==============================================================;
00019
00020 #ifndef _EXTEND_H
00021 #define _EXTEND_H
00022
00023 struct EXTENSION_NODE
00024 {
00025     GUID  GUID;
00026     _TCHAR  szDescription[256];
00027 };
00028
00029 enum EXTENSION_TYPE
00030 {
00031     NameSpaceExtension,
00032         ContextMenuExtension,
00033         ToolBarExtension,
00034         PropertySheetExtension,
00035         TaskExtension,
00036         DynamicExtension,
00037   DummyExtension
00038 };
00039
00040 struct EXTENDER_NODE
00041 {
00042     EXTENSION_TYPE  eType;
00043     GUID      guidNode;
00044     GUID      guidExtension;
00045     _TCHAR      szDescription[256];
00046 };
00047
00048 #endif // _EXTEND_H
00049
00050
Generated on Wed Nov 13 2024 16:52:36 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Com/Fundamentals/DCom/TimeOuts/PingResp/DllDatax.c Source File

  • Com
  • Fundamentals
  • DCom
  • TimeOuts
  • PingResp

DllDatax.c

Go to the documentation of this file.
00001 /*+==========================================================================
00002
00003 File: dlldatax.c
00004
00005 Summary:  Wraps MIDL Generated dlldata.c file. Produced by VS6 ATL Wizard.
00006
00007 ----------------------------------------------------------------------------
00008
00009 This file is part of the Microsoft COM+ Samples.
00010
00011 Copyright (C) 1995 - 2000 Microsoft Corporation. All rights reserved.
00012
00013 This source code is intended only as a supplement to Microsoft
00014 Development Tools and/or on-line documentation. See these other
00015 materials for detailed information regarding Microsoft code samples.
00016
00017 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00018 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00020 PARTICULAR PURPOSE.
00021
00022 ==========================================================================+*/
00023 // wrapper for dlldata.c
00024
00025 #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
00026
00027 #define REGISTER_PROXY_DLL //DllRegisterServer, etc.
00028
00029 #define USE_STUBLESS_PROXY  //defined only with MIDL switch /Oicf
00030
00031 #pragma comment(lib, "rpcndr.lib")
00032 #pragma comment(lib, "rpcns4.lib")
00033 #pragma comment(lib, "rpcrt4.lib")
00034
00035 #define DllMain       PrxDllMain
00036 #define DllRegisterServer PrxDllRegisterServer
00037 #define DllUnregisterServer PrxDllUnregisterServer
00038 #define DllGetClassObject   PrxDllGetClassObject
00039 #define DllCanUnloadNow     PrxDllCanUnloadNow
00040
00041 #include "dlldata.c"
00042 #include "PingResp_p.c"
00043
00044 #ifdef _NOPROXY //no midl generated dlldata.c
00045
00046 #define STRICT 1
00047 #include <ole2.h>
00048
00049 BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
00050 {return TRUE;}
00051
00052 STDAPI PrxDllCanUnloadNow(void){return S_OK;}
00053
00054 STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
00055 {return CLASS_E_CLASSNOTAVAILABLE;}
00056
00057 STDAPI PrxDllRegisterServer(void){return S_OK;}
00058
00059 STDAPI PrxDllUnregisterServer(void){return S_OK;}
00060
00061 #endif //!PROXY_DELEGATION
00062
00063 #endif //_MERGE_PROXYSTUB
Generated on Wed Nov 13 2024 16:51:51 for WinXP-Examples by doxygen 1.7.1


WinXP-Examples: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members

CResultset Member List

This is the complete list of members for CResultset, including all inherited members.
_NewEnum(IUnknown **ppunk) | CResultset |
Clear(bool bDelete) | CResultset | [inline]
Count(long *pi4) | CResultset |
CResultset() | CResultset | [inline]
DeleteEntity(long nIndex) | CResultset |
DisconnectObject(DWORD dwReserved) | CResultset | [inline]
get_Record(long nIndex, IEntityData **pVal) | CResultset |
GetClassID(GUID *pClassID) | CResultset | [inline]
GetEntity(long nIndex) | CResultset |
GetMarshalSizeMax(REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags, ULONG *pSize) | CResultset | [inline]
GetSizeMax(_ULARGE_INTEGER *pCbSize) | CResultset | [inline]
GetUnmarshalClass(REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags, CLSID *pCid) | CResultset | [inline]
Initialise(long nRows) | CResultset |
InitNew() | CResultset | [inline]
InterfaceSupportsErrorInfo(REFIID riid) | CResultset |
IsDirty() | CResultset | [inline]
Load(IStream *pStm) | CResultset | [inline]
m_nAlloc | CResultset |
m_nCount | CResultset |
m_pEntity | CResultset |
m_pVar | CResultset |
m_wszDeleteStoredProc | CResultset |
m_wszInsertStoredProc | CResultset |
m_wszKeyField | CResultset |
m_wszReadStoredProc | CResultset |
m_wszUpdateStoredProc | CResultset |
MarshalInterface(IStream *pStm, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags) | CResultset | [inline]
ReleaseMarshalData(IStream *pStm) | CResultset | [inline]
Save(IStream *pStm, int fClearDirty) | CResultset | [inline]
SetCount(long nCount) | CResultset |
UnmarshalInterface(IStream *pStm, REFIID riid, void **ppv) | CResultset | [inline]
~CResultset() | CResultset | [inline]
Generated on Wed Nov 13 2024 16:57:11 for WinXP-Examples by doxygen 1.7.1